mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-10-23 00:53:38 +02:00
## Thinking Path > - Paperclip runs agents through local adapters and the native runner. > - Both paths must use the same installed provider CLI. > - New models require current harness releases. > - The runner still pins Codex 0.153.4, Claude SDK 0.3.263, and OpenCode 1.18.29. > - Changing the image alone would fail the runner's exact version and executable checks. > - This pull request updates those dependencies, integrity checks, controller checks, and image pins together. > - Shared installations can then run the current models without a task-time download. ## Linked Issues or Issue Description Refs #13829, which updates model choices and reasoning controls. Searches found no open PR that updates these runtime pins. **Current behavior** The shared provider pack ships old CLIs. Claude Code 2.1.263 cannot run Opus 5.5, which requires 2.1.280. Remote controllers reject provider packs whose versions differ from their declared pins. **Proposed behavior** Use Codex 0.156.0, Claude Agent SDK 0.3.280 / Claude Code 2.1.280, and OpenCode 1.18.32 throughout the runner. Keep the reviewed ACP bridge patches and one shared CLI installation per provider. **Reason and benefit** Current harnesses support the new model IDs while preserving executable verification and remote provider-pack compatibility checks. ## What Changed - Update dependency overrides, the Codex ACP package patch, runtime profiles, and remote controller pins. - Verify the new Claude Linux x64 and macOS arm64/x64 executables and Codex Linux x64 executable against integrity-verified npm archives. - Refresh OpenCode version checks, fixtures, and the runner configuration label. - Refresh the eval image's Grok, Gemini, Kimi, Cursor, and GitHub CLI pins and archive hashes. Hermes remains current at 0.19.0. - Refresh the build-time lock digest from clean pnpm 9.15.4 resolution. Leave lockfile commits to repository automation. - Document model compatibility and the separation between CLI runtimes and patched ACP bridges. ## Verification - `pnpm -r typecheck` and `pnpm build` passed. - Rust workspace release tests passed. - Package/patch and OpenCode binary-materialization contract tests: 11 passed. - Real Codex 0.156.0 startup-ownership and paginated session-resume probes passed with isolated synthetic homes and no model turn. - Codex app-server `thread/start` preserved `gpt-6-sol` and `gpt-6-luna`; no `turn/start` was sent. An unauthenticated built-in catalog does not include those account-served entries. - Installed Claude integrity probes passed for `claude-opus-5-5` and `claude-fable-5-1`. - `pnpm --filter @paperclipai/paperclip-runner test:opencode:qualification` passed with the actual OpenCode 1.18.32 executable under Node 24 and Node 25. The loopback provider exercise covers health/version, session creation/read/delete, SSE, and a completed async prompt. - `pnpm check:token-gates` passed. - The targeted runner suite passed 130 tests. Three macOS failures in snapshot module lookup and OpenCode final-message selection also reproduce on the unchanged base; Linux CI will provide the platform check. - [Final Linux CI](https://github.com/paperclipai/paperclip/actions/runs/35798076399): all gates passed. Four jobs needed one retry after their CI workers received shutdown signals. The PR has 55 successful checks, two skipped checks, Greptile 5/5, and no unresolved review threads. - Changed runner configuration UI tests: 5 passed. - Full macOS `pnpm test:run` reached 13,094 passing server tests, 84 skipped, and 18 failures before the wrapper stopped. Failures involved skill-cache publication permissions, missing bundled connector skills in the worktree, and a conversation-reset timing case. The 10 cache permission failures reproduce on the unchanged base; both conversation-reset cases passed on a targeted retry. The wrapper did not reach its later workspace/serialized groups locally; Linux CI covers those groups. - The local Docker daemon did not respond, so no local Docker build was run. No billable model requests were made. ## Risks - Deploy the matching controller and provider pack together. Older controllers enforce their previous exact pins. - Current upstream CLIs can change behavior. Existing protocol tests and isolated real Codex probes cover the integration boundaries; authenticated model inference is not part of these checks. - ACP bridge package versions and executable digests stay unchanged because their executable bytes are unchanged. Only the underlying CLI/SDK dependencies move. - No schema migration. Revert the runtime and image pins together to roll back. ## Model Used OpenAI GPT-6 via Codex, with repository tools, code execution, and web research. The exact serving model ID and context window were not exposed by 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 for the changed surfaces and real-executable probes; full macOS-suite limitations are listed above - [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>
358 lines
12 KiB
JavaScript
358 lines
12 KiB
JavaScript
import { createHash } from "node:crypto";
|
|
import { execFileSync, spawnSync } from "node:child_process";
|
|
import {
|
|
chmodSync,
|
|
copyFileSync,
|
|
existsSync,
|
|
mkdirSync,
|
|
mkdtempSync,
|
|
readdirSync,
|
|
readFileSync,
|
|
readlinkSync,
|
|
realpathSync,
|
|
renameSync,
|
|
rmSync,
|
|
writeFileSync,
|
|
} from "node:fs";
|
|
import { tmpdir } from "node:os";
|
|
import { dirname, join, relative, resolve } from "node:path";
|
|
import { createRequire } from "node:module";
|
|
import { fileURLToPath } from "node:url";
|
|
|
|
const packageRoot = resolve(dirname(fileURLToPath(import.meta.url)), "..");
|
|
const workspaceRoot = resolve(packageRoot, "../..");
|
|
const outputArgument = process.argv.slice(2).find((value) => value !== "--");
|
|
const outputRoot = resolve(
|
|
process.cwd(),
|
|
outputArgument ?? join(packageRoot, "provider-pack"),
|
|
);
|
|
if (
|
|
outputRoot === workspaceRoot ||
|
|
outputRoot === packageRoot ||
|
|
outputRoot === "/"
|
|
) {
|
|
throw new Error(`Refusing unsafe provider-pack output path: ${outputRoot}`);
|
|
}
|
|
|
|
const temporaryParent = mkdtempSync(join(tmpdir(), "paperclip-provider-pack-"));
|
|
const temporaryRoot = join(temporaryParent, "pack");
|
|
|
|
function canonicalJson(value) {
|
|
if (Array.isArray(value)) return `[${value.map(canonicalJson).join(",")}]`;
|
|
if (value && typeof value === "object") {
|
|
return `{${Object.keys(value)
|
|
.sort()
|
|
.map((key) => `${JSON.stringify(key)}:${canonicalJson(value[key])}`)
|
|
.join(",")}}`;
|
|
}
|
|
return JSON.stringify(value);
|
|
}
|
|
|
|
function sha256File(path) {
|
|
return `sha256:${createHash("sha256")
|
|
.update(readFileSync(path))
|
|
.digest("hex")}`;
|
|
}
|
|
|
|
function sha256Tree(root) {
|
|
const hash = createHash("sha256");
|
|
const visit = (directory, prefix = "") => {
|
|
const entries = readdirSync(directory, { withFileTypes: true }).sort(
|
|
(left, right) => left.name.localeCompare(right.name),
|
|
);
|
|
for (const entry of entries) {
|
|
const relativePath = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
const absolutePath = join(directory, entry.name);
|
|
if (entry.isDirectory()) {
|
|
hash.update(`directory\0${relativePath}\n`);
|
|
visit(absolutePath, relativePath);
|
|
} else if (entry.isFile()) {
|
|
hash.update(`file\0${relativePath}\0${sha256File(absolutePath)}\n`);
|
|
} else if (entry.isSymbolicLink()) {
|
|
hash.update(
|
|
`symlink\0${relativePath}\0${readlinkSync(absolutePath)}\n`,
|
|
);
|
|
} else {
|
|
throw new Error(
|
|
`Provider pack tree contains unsupported entry ${relativePath}`,
|
|
);
|
|
}
|
|
}
|
|
};
|
|
visit(root);
|
|
return `sha256:${hash.digest("hex")}`;
|
|
}
|
|
|
|
function writePortableNodeShim(name, entrypoint) {
|
|
const shimPath = join(temporaryRoot, "node_modules", ".bin", name);
|
|
writeFileSync(
|
|
shimPath,
|
|
[
|
|
"#!/bin/sh",
|
|
"set -eu",
|
|
'basedir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)',
|
|
`exec "$basedir/../node/bin/node" "$basedir/../${entrypoint}" "$@"`,
|
|
"",
|
|
].join("\n"),
|
|
);
|
|
chmodSync(shimPath, 0o755);
|
|
}
|
|
|
|
function writePortableExecutableShim(name, executable) {
|
|
const shimPath = join(temporaryRoot, "node_modules", ".bin", name);
|
|
writeFileSync(
|
|
shimPath,
|
|
[
|
|
"#!/bin/sh",
|
|
"set -eu",
|
|
'basedir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)',
|
|
`exec "$basedir/../${executable}" "$@"`,
|
|
"",
|
|
].join("\n"),
|
|
);
|
|
chmodSync(shimPath, 0o755);
|
|
}
|
|
|
|
try {
|
|
const deployed = spawnSync(
|
|
"pnpm",
|
|
[
|
|
"--filter",
|
|
"@paperclipai/paperclip-runner",
|
|
"deploy",
|
|
"--prod",
|
|
temporaryRoot,
|
|
],
|
|
{ cwd: workspaceRoot, encoding: "utf8", stdio: "inherit" },
|
|
);
|
|
if (deployed.status !== 0) {
|
|
throw new Error(`pnpm deploy failed with exit code ${deployed.status}`);
|
|
}
|
|
|
|
// Fail the image build if a bridge silently brings back an older/private
|
|
// provider CLI. A direct dependency alone does not deduplicate pnpm's graph.
|
|
const packRequire = createRequire(join(temporaryRoot, "package.json"));
|
|
const codexAcpRequire = createRequire(packRequire.resolve("@agentclientprotocol/codex-acp/package.json"));
|
|
if (realpathSync(codexAcpRequire.resolve("@openai/codex/package.json")) !==
|
|
realpathSync(packRequire.resolve("@openai/codex/package.json"))) {
|
|
throw new Error("Codex ACP must share the image's Codex installation");
|
|
}
|
|
|
|
// Reuse the already-qualified build interpreter instead of introducing a
|
|
// package-manager lifecycle hook or a second binary supply chain. The pack
|
|
// manifest binds the copied bytes, platform, architecture, and minimum
|
|
// version before any provider is launched.
|
|
const minimumNodeVersion = [24, 11, 0];
|
|
const actualNodeVersion = process.versions.node.split(".").map(Number);
|
|
if (
|
|
actualNodeVersion[0] < minimumNodeVersion[0] ||
|
|
(actualNodeVersion[0] === minimumNodeVersion[0] &&
|
|
(actualNodeVersion[1] < minimumNodeVersion[1] ||
|
|
(actualNodeVersion[1] === minimumNodeVersion[1] &&
|
|
actualNodeVersion[2] < minimumNodeVersion[2])))
|
|
) {
|
|
throw new Error("Provider pack build Node is older than 24.11.0");
|
|
}
|
|
const stableNodeRoot = join(temporaryRoot, "node_modules", "node");
|
|
if (existsSync(stableNodeRoot)) {
|
|
throw new Error(
|
|
"Provider pack deployment unexpectedly claimed the stable Node path",
|
|
);
|
|
}
|
|
const stableNodeCommand = join(stableNodeRoot, "bin", "node");
|
|
mkdirSync(dirname(stableNodeCommand), { recursive: true, mode: 0o755 });
|
|
copyFileSync(process.execPath, stableNodeCommand);
|
|
chmodSync(stableNodeCommand, 0o755);
|
|
|
|
// pnpm's generated .bin shims embed the temporary deployment directory in
|
|
// NODE_PATH. That makes an otherwise identical provider pack hash differ on
|
|
// every build and leaks a nonexistent host path after relocation. Replace
|
|
// every provider-facing shim with a pack-relative launcher that always uses
|
|
// the pinned Node executable owned by this pack.
|
|
// The image exposes these same installations to every adapter. Never add a
|
|
// separate global/runner-only CLI version; refresh these packages and their
|
|
// qualification digests together to the latest stable releases.
|
|
writePortableNodeShim("codex", "@openai/codex/bin/codex.js");
|
|
const claudeAcpRequire = createRequire(
|
|
packRequire.resolve("@agentclientprotocol/claude-agent-acp/package.json"),
|
|
);
|
|
// Use the ACP bridge's SDK dependency directly, avoiding a second peer-
|
|
// resolved SDK installation just to expose its CLI on the global PATH.
|
|
const sdkRequire = createRequire(claudeAcpRequire.resolve("@anthropic-ai/claude-agent-sdk"));
|
|
const claudeExecutable = sdkRequire.resolve(
|
|
`@anthropic-ai/claude-agent-sdk-${process.platform}-${process.arch}/claude`,
|
|
);
|
|
writePortableExecutableShim(
|
|
"claude",
|
|
relative(realpathSync(join(temporaryRoot, "node_modules")), realpathSync(claudeExecutable)),
|
|
);
|
|
writePortableExecutableShim("node", "node/bin/node");
|
|
writePortableExecutableShim("opencode", "opencode-ai/bin/opencode.exe");
|
|
writePortableNodeShim("acpx", "acpx/dist/cli.js");
|
|
writePortableNodeShim(
|
|
"claude-agent-acp",
|
|
"@agentclientprotocol/claude-agent-acp/dist/index.js",
|
|
);
|
|
writePortableNodeShim(
|
|
"codex-acp",
|
|
"@agentclientprotocol/codex-acp/dist/index.js",
|
|
);
|
|
|
|
// pnpm deploy may retain a workspace self-link under its virtual store. It
|
|
// points outside the immutable pack and is not needed by the deployed
|
|
// package, so it must not be staged or captured.
|
|
rmSync(
|
|
join(
|
|
temporaryRoot,
|
|
"node_modules",
|
|
".pnpm",
|
|
"node_modules",
|
|
"@paperclipai",
|
|
"paperclip-runner",
|
|
),
|
|
{ recursive: true, force: true },
|
|
);
|
|
|
|
for (const shimName of readdirSync(
|
|
join(temporaryRoot, "node_modules", ".bin"),
|
|
)) {
|
|
const shimPath = join(temporaryRoot, "node_modules", ".bin", shimName);
|
|
const contents = readFileSync(shimPath, "utf8");
|
|
if (contents.includes(temporaryParent)) {
|
|
throw new Error(
|
|
`Provider pack shim ${shimName} retains its temporary build path`,
|
|
);
|
|
}
|
|
}
|
|
|
|
// Exercise a clean import from the deployed dependency graph. This catches
|
|
// malformed patch hunks that can look correct in an existing pnpm store but
|
|
// land inside the wrong function when applied to a fresh acpx tarball.
|
|
const acpxImport = spawnSync(
|
|
join(temporaryRoot, "node_modules", "node", "bin", "node"),
|
|
["--input-type=module", "-e", 'await import("acpx/runtime")'],
|
|
{
|
|
cwd: temporaryRoot,
|
|
encoding: "utf8",
|
|
timeout: 30_000,
|
|
},
|
|
);
|
|
if (acpxImport.status !== 0) {
|
|
throw new Error(
|
|
`Provider pack ACPX import failed: ${String(acpxImport.stderr ?? "")
|
|
.trim()
|
|
.slice(-2_000)}`,
|
|
);
|
|
}
|
|
|
|
const opencodeProxyPath = "dist/cli/opencode-app-server-proxy.cjs";
|
|
const acpxSidecarPath = "dist/cli/acpx-runtime-sidecar.cjs";
|
|
const opencodeCommand = "node_modules/.bin/opencode";
|
|
const opencodeExecutable = "node_modules/opencode-ai/bin/opencode.exe";
|
|
const nodeCommand = "node_modules/node/bin/node";
|
|
const productionLock = "pnpm-lock.yaml";
|
|
copyFileSync(
|
|
join(workspaceRoot, "pnpm-lock.yaml"),
|
|
join(temporaryRoot, productionLock),
|
|
);
|
|
for (const relativePath of [
|
|
nodeCommand,
|
|
productionLock,
|
|
opencodeProxyPath,
|
|
acpxSidecarPath,
|
|
opencodeCommand,
|
|
opencodeExecutable,
|
|
]) {
|
|
if (!existsSync(join(temporaryRoot, relativePath))) {
|
|
throw new Error(`Provider pack is missing ${relativePath}`);
|
|
}
|
|
}
|
|
|
|
const opencodeProxySha = sha256File(join(temporaryRoot, opencodeProxyPath));
|
|
const acpxSidecarSha = sha256File(join(temporaryRoot, acpxSidecarPath));
|
|
const distDigest = sha256Tree(join(temporaryRoot, "dist"));
|
|
const configuredRevision =
|
|
process.env.PAPERCLIP_RUNNER_SOURCE_REVISION?.trim();
|
|
const revision =
|
|
configuredRevision ??
|
|
execFileSync("git", ["rev-parse", "HEAD"], {
|
|
cwd: workspaceRoot,
|
|
encoding: "utf8",
|
|
}).trim();
|
|
if (!/^[0-9a-f]{40}$/.test(revision)) {
|
|
throw new Error("PAPERCLIP_RUNNER_SOURCE_REVISION must be a full Git SHA");
|
|
}
|
|
const dirty = configuredRevision
|
|
? false
|
|
: spawnSync("git", ["diff", "--quiet", "--", "packages/paperclip-runner"], {
|
|
cwd: workspaceRoot,
|
|
}).status !== 0;
|
|
const payload = {
|
|
pins: {
|
|
nodeMinimum: minimumNodeVersion.join("."),
|
|
codex: "0.156.0",
|
|
opencode: "1.18.32",
|
|
acpx: "0.13.1",
|
|
claudeAcp: "0.73.0",
|
|
codexAcp: "1.6.2",
|
|
},
|
|
target: { platform: process.platform, architecture: process.arch },
|
|
runnerSourceRevision: `${revision}${dirty ? "-dirty" : ""}`,
|
|
distDigest,
|
|
bridgeDigest: `sha256:${createHash("sha256")
|
|
.update(opencodeProxySha)
|
|
.update("\n")
|
|
.update(acpxSidecarSha)
|
|
.update("\n")
|
|
.update(distDigest)
|
|
.digest("hex")}`,
|
|
acpxProfileDigests: {
|
|
claude:
|
|
"sha256:9d73d1f0f121fb96cc8badb28c22d5bff02d8582eb2e40360a81c189e1b9422a",
|
|
codex:
|
|
"sha256:c4538599d1ab767db5dff50934f13bb5ba313a59d9c4a83e993fac4617ea63d3",
|
|
},
|
|
artifacts: {
|
|
nodeCommand: {
|
|
path: nodeCommand,
|
|
sha256: sha256File(join(temporaryRoot, nodeCommand)),
|
|
},
|
|
productionLock: {
|
|
path: productionLock,
|
|
sha256: sha256File(join(temporaryRoot, productionLock)),
|
|
},
|
|
opencodeCommand: {
|
|
path: opencodeCommand,
|
|
sha256: sha256File(join(temporaryRoot, opencodeCommand)),
|
|
},
|
|
opencodeExecutable: {
|
|
path: opencodeExecutable,
|
|
sha256: sha256File(join(temporaryRoot, opencodeExecutable)),
|
|
},
|
|
opencodeProxy: {
|
|
path: opencodeProxyPath,
|
|
sha256: opencodeProxySha,
|
|
},
|
|
acpxSidecar: { path: acpxSidecarPath, sha256: acpxSidecarSha },
|
|
},
|
|
};
|
|
const manifest = {
|
|
schema: "paperclip-runner/remote-provider-pack/v1",
|
|
digest: `sha256:${createHash("sha256")
|
|
.update(canonicalJson(payload))
|
|
.digest("hex")}`,
|
|
payload,
|
|
};
|
|
writeFileSync(
|
|
join(temporaryRoot, "provider-pack.json"),
|
|
`${JSON.stringify(manifest, null, 2)}\n`,
|
|
{ mode: 0o600 },
|
|
);
|
|
|
|
rmSync(outputRoot, { recursive: true, force: true });
|
|
renameSync(temporaryRoot, outputRoot);
|
|
process.stdout.write(`${outputRoot}\n`);
|
|
} finally {
|
|
rmSync(temporaryParent, { recursive: true, force: true });
|
|
}
|