mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-10-30 13:20:54 +01:00
## Thinking Path > - Paperclip manages agents and their task execution. > - Runner uses ACPX to connect to Claude sessions. > - Claude receives native options when ACPX creates a session. > - ACPX omits those options when it loads or resumes the same session. > - A reconnect can lose allowed tools, instructions, and settings sources. > - This pull request replays the existing options through the existing Claude metadata contract. > - Resumed tasks keep the configuration admitted for their session. ## Linked Issues or Issue Description **What happened?** A Claude task can complete its first turn and then fail on a warm follow-up. The provider refuses an internal completion tool because `session/load` omits the `allowedTools` options sent with `session/new`. The same omission exists on `session/resume`. **Expected behavior** Creation, load, and resume must supply the same caller-selected native session options. The existing policy for native user settings must stay unchanged. **Steps to reproduce** Create a persistent Claude ACP session with an explicit allowed-tool list and appended instructions. Complete a turn, close its connection, and reconnect to the saved session. Inspect the ACP request. Before this change, the reconnect has no `_meta` field. **Paperclip version or commit** Reproduced on Runner source `e8b78cce5bb557b086bee9ca930eeaab1d09b244`. The offline protocol regression also fails on the current base `80a2b9284bf189e93ca4313085814548f48b8dc8`. Related: #18089 added prepared harness storage. #11798 concerns the separate legacy adapter and does not fix Runner reconnect metadata. ## Upstream status and backport scope ACPX [0.21.1](https://github.com/openclaw/acpx/releases/tag/v0.21.1) already replays session metadata on load and resume in its [released client implementation](https://github.com/openclaw/acpx/blob/v0.21.1/src/acp/client.ts). This PR backports that behavior to the currently qualified 0.13.1 integration. The released 0.21.1 runtime does not expose equivalents for all hooks used by Runner's existing patch: verified executable spawning, synchronous protocol admission guards, provider extension dispatch, and response-delivery receipts. Upgrading requires a compatibility pass that preserves these guarantees and removes local changes already covered upstream. This backport does not add a new Paperclip-specific dependency contract. ## What Changed - Replay existing Claude native options on `session/load` and `session/resume` through the same metadata builder used at creation. Other providers keep their existing reconnect requests. - Test both reconnect methods against the installed ACPX manager and a local ACP wire fixture. Cover allowed tools, model, turn limit, instructions, and both existing settings-source modes. - Update exact source attestations and generated profile declarations required by the shared ACPX patch. Keep historical fixtures unchanged. - Document the reconnect contract. No new home mode, plugin policy, or provider permission rule is added. ## Verification - Confirmed the new load and resume tests fail before the patch because metadata is absent. - Applied the canonical patch to pristine package bytes and confirmed it matches the tested runtime. - Targeted installed-package model-selection and reconnect suite plus changed Grok identity tests: 22 passed. - Rechecked the four new reconnect cases against the cleanly applied patch, with explicit expected values for all supplied options. - Three targeted current-profile and revision-boundary assertions pass locally. Updated the native Pi test digest; native compilation and execution remain in CI. - Maintained profile generators pass their consistency checks. - GitHub CI is green, including typecheck, native Runner checks, package contracts, packaged installation, build, and server/browser suites. One unrelated server database-cleanup timeout passed on the bounded failed-job rerun. No comprehensive local suite was run. Live post-deployment acceptance remains pending. ## Risks Claude reconnects now receive the same native settings sources and options as creation. This corrects configuration loss without changing caller policy. The shared dependency patch requires new source identities for other attested profiles; their reconnect behavior is unchanged. No database migration is required. ## Model Used OpenAI Codex, GPT-6 family, with code and tool use. Exact deployment ID and context-window size are not exposed in this session. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [x] All Paperclip CI gates are green - [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge --------- Co-authored-by: Paperclip <noreply@paperclip.ing>
107 lines
6.7 KiB
JavaScript
107 lines
6.7 KiB
JavaScript
#!/usr/bin/env node
|
|
// Run in a credential-free public npm consumer after `paperclipai runtime setup pi`.
|
|
// Use the server's normal packaged daemon resolver; never submit a prompt.
|
|
import assert from 'node:assert/strict';
|
|
import { createHash } from 'node:crypto';
|
|
import { mkdir, mkdtemp, readFile, realpath, rm } from 'node:fs/promises';
|
|
import { tmpdir } from 'node:os';
|
|
import { join, resolve } from 'node:path';
|
|
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
|
|
export async function verifyPiPackagedDaemon(server, daemon, target, runnerBinaryTarget) {
|
|
assert.match(target, /^(?:linux|darwin)-(?:x64|arm64)$/);
|
|
const output = join(server, 'dist/vendor/paperclip-runner'), manifestPath = join(output, 'bin/release-manifest.json');
|
|
let manifest;
|
|
try { manifest = JSON.parse(await readFile(manifestPath, 'utf8')); }
|
|
catch (error) { if (error.code !== 'ENOENT') throw error; }
|
|
let expectedPath = join(output, 'bin/paperclip-runnerd');
|
|
if (manifest !== undefined) {
|
|
assert.ok(manifest && typeof manifest === 'object' && !Array.isArray(manifest), 'Release manifest must be an object');
|
|
assert.equal(await realpath(manifestPath), manifestPath, 'Release manifest must remain inside the installed package');
|
|
assert.equal(manifest.schema, 'paperclip.runner.release-binaries.v1');
|
|
assert.match(manifest.sourceRevision, /^[a-f0-9]{40}$/);
|
|
const build = JSON.parse(await readFile(join(server, 'dist/build-info.json'), 'utf8'));
|
|
assert.equal(manifest.sourceRevision, build.commit, 'Packaged daemon source must match the installed server build');
|
|
const artifact = manifest.platforms?.[target];
|
|
assert.equal(artifact?.path, `${target}/paperclip-runnerd`, 'Packaged daemon must use the known host target path');
|
|
assert.match(artifact.sha256, /^sha256:[a-f0-9]{64}$/);
|
|
expectedPath = join(output, 'bin', artifact.path);
|
|
assert.equal(await realpath(daemon), expectedPath, 'Production must select the installed host daemon');
|
|
assert.equal(await realpath(expectedPath), expectedPath, 'Packaged daemon cannot escape through a symlink');
|
|
const bytes = await readFile(expectedPath);
|
|
assert.equal(`sha256:${createHash('sha256').update(bytes).digest('hex')}`, artifact.sha256);
|
|
assert.equal(runnerBinaryTarget(bytes), target);
|
|
} else {
|
|
assert.equal(await realpath(daemon), expectedPath);
|
|
assert.equal(runnerBinaryTarget(await readFile(expectedPath)), target);
|
|
}
|
|
}
|
|
|
|
async function main() {
|
|
|
|
const [serverDirectory, ...extra] = process.argv.slice(2);
|
|
assert.ok(serverDirectory && extra.length === 0, 'Usage: pi-public-install-probe.mjs INSTALLED_SERVER_ROOT');
|
|
for (const key of Object.keys(process.env)) {
|
|
assert.ok(!/(?:API_KEY|TOKEN|SECRET|PASSWORD)$/.test(key), `Unexpected credential variable: ${key}`);
|
|
}
|
|
assert.equal(process.env.PAPERCLIP_RUNNER_BINARY, undefined);
|
|
assert.equal(process.env.NODE_OPTIONS, undefined);
|
|
assert.equal(process.env.NODE_PATH, undefined);
|
|
const server = await realpath(serverDirectory);
|
|
assert.equal(JSON.parse(await readFile(join(server, 'package.json'), 'utf8')).name, '@paperclipai/server');
|
|
const { resolvePaperclipRunnerBinary } = await import(pathToFileURL(join(server, 'dist/services/native-runtime/native-codex-runner.js')));
|
|
const { createCapabilityRunnerdCodexTransport } = await import(pathToFileURL(join(server, 'dist/vendor/paperclip-runner/live/runnerd-codex-transport.js')));
|
|
const { QUALIFIED_ACPX_PROFILES } = await import(pathToFileURL(join(server, 'dist/vendor/paperclip-runner/drivers/acpx/qualified-profiles.js')));
|
|
assert.equal(QUALIFIED_ACPX_PROFILES.pi.agentProfileVersion, 33);
|
|
assert.equal(QUALIFIED_ACPX_PROFILES.pi.commandDigest, 'sha256:0260d5810e9247986800ad46c1f9b3511a5abd06cb8f142405d5caacbc3960fc');
|
|
assert.equal(Object.hasOwn(QUALIFIED_ACPX_PROFILES.pi, 'qualificationModel'), false);
|
|
assert.equal(Object.hasOwn(QUALIFIED_ACPX_PROFILES.pi, 'reportedModelId'), false);
|
|
const daemon = resolvePaperclipRunnerBinary();
|
|
const { runnerBinaryTarget } = await import(pathToFileURL(join(server, 'dist/vendor/paperclip-runner/live/runner-binary.js')));
|
|
await verifyPiPackagedDaemon(server, daemon, `${process.platform}-${process.arch}`, runnerBinaryTarget);
|
|
const root = await mkdtemp(join(tmpdir(), 'pi-public-install-probe-'));
|
|
const evidence = [];
|
|
const started = performance.now();
|
|
const watchdog = setTimeout(() => { console.error('Pi public-install probe exceeded its cleanup deadline'); process.exit(1); }, 85_000);
|
|
let bundle;
|
|
let failure;
|
|
let settledMs;
|
|
try {
|
|
const workspace = join(root, 'workspace'); await mkdir(workspace);
|
|
bundle = createCapabilityRunnerdCodexTransport({
|
|
provider: 'acpx', acpxAgent: 'pi', piThinkingLevel: 'low', acpxPermissionMode: 'deny-all',
|
|
runnerBinary: daemon, stateDirectory: join(root, 'state'),
|
|
environment: { PATH: '/usr/bin:/bin', LANG: 'C.UTF-8' },
|
|
onEvidence: value => evidence.push(value),
|
|
});
|
|
try {
|
|
await bundle.transport.request('initialize', { clientInfo: { name: 'pi-public-install-verification', version: '1' } });
|
|
await bundle.transport.request('thread/start', {
|
|
cwd: workspace, model: 'openrouter/deepseek/deepseek-v4-flash-0731',
|
|
baseInstructions: 'Credential-free admission probe. No prompt is submitted.',
|
|
permissions: 'paperclip-runner-workspace-read-only', dynamicTools: [],
|
|
});
|
|
} catch (error) { failure = String(error); }
|
|
settledMs = Math.round(performance.now() - started);
|
|
await bundle.transport.close();
|
|
assert.match(failure ?? '', /session\.open failed/);
|
|
assert.match(failure, /retryable=false, classification=session_ensure_failed/);
|
|
assert.doesNotMatch(failure, /timed out/);
|
|
assert.ok(settledMs < 60_000, `Pi admission took ${settledMs} ms`);
|
|
assert.ok(evidence.some(item => item.runnerExited === true && item.runnerExitCode === 0));
|
|
for (const item of evidence) assert.deepEqual(item.childEnvironmentKeys, ['LANG', 'PATH']);
|
|
const state = JSON.parse(await readFile(join(root, 'state/runner/acpx-provider-state.json'), 'utf8'));
|
|
assert.equal(state.descriptor.agent, 'pi');
|
|
assert.equal(state.descriptor.agentRuntimeVersion, '1.0.0');
|
|
assert.equal(state.descriptor.piThinkingLevel, 'low');
|
|
assert.equal(state.activeTurnId, null);
|
|
assert.equal(state.identity, null);
|
|
assert.equal(state.providerExitUnconfirmed, false);
|
|
console.log(JSON.stringify({ schema: 'paperclip.pi.public-npm-install.v1', target: `${process.platform}-${process.arch}`, normalPackagedDaemon: true, exactPiProfile: QUALIFIED_ACPX_PROFILES.pi.agentProfileVersion, runtime: '1.0.0', credentials: 'none', promptCalls: 0, settledMs, cleanRunnerExit: true }));
|
|
} finally {
|
|
try { await bundle?.transport.close(); }
|
|
finally { clearTimeout(watchdog); await rm(root, { recursive: true, force: true }); }
|
|
}
|
|
}
|
|
if (process.argv[1] && resolve(process.argv[1]) === fileURLToPath(import.meta.url)) await main();
|