mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-10-07 16:11:46 +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>
147 lines
7.5 KiB
JavaScript
147 lines
7.5 KiB
JavaScript
// Opt-in qualification of the installed CLI, not the fake protocol server.
|
|
// PAPERCLIP_OPENCODE_QUALIFY=1 node --test scripts/qualify-opencode-runtime.test.mjs
|
|
import assert from "node:assert/strict";
|
|
import { spawn, execFileSync } from "node:child_process";
|
|
import { once } from "node:events";
|
|
import { mkdir, mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
|
|
import { createServer } from "node:http";
|
|
import { tmpdir } from "node:os";
|
|
import { dirname, join, resolve } from "node:path";
|
|
import { setTimeout as delay } from "node:timers/promises";
|
|
import test from "node:test";
|
|
|
|
const enabled = process.env.PAPERCLIP_OPENCODE_QUALIFY === "1";
|
|
const packageRoot = resolve(import.meta.dirname, "..");
|
|
const manifest = JSON.parse(await readFile(join(packageRoot, "package.json"), "utf8"));
|
|
|
|
test("the pinned OpenCode executable serves health, sessions, SSE, and a local-provider prompt", {
|
|
skip: !enabled,
|
|
timeout: 60_000,
|
|
}, async (t) => {
|
|
const root = await mkdtemp(join(tmpdir(), "paperclip-opencode-qualification-"));
|
|
let provider;
|
|
let child;
|
|
let exited;
|
|
const streamAbort = new AbortController();
|
|
const killGroup = (signal) => {
|
|
if (!child?.pid) return;
|
|
try { process.kill(-child.pid, signal); } catch (error) { if (error.code !== "ESRCH") throw error; }
|
|
};
|
|
t.after(async () => {
|
|
streamAbort.abort();
|
|
if (child?.pid) {
|
|
killGroup("SIGTERM");
|
|
const kill = setTimeout(() => killGroup("SIGKILL"), 3000);
|
|
try { await exited; } finally { clearTimeout(kill); killGroup("SIGKILL"); }
|
|
}
|
|
if (provider) { provider.closeAllConnections(); await new Promise((done) => provider.close(done)); }
|
|
await rm(root, { recursive: true, force: true });
|
|
});
|
|
const command = resolve(process.env.PAPERCLIP_TEST_OPENCODE_BINARY ?? join(packageRoot, "node_modules/opencode-ai/bin/opencode.exe"));
|
|
assert.equal(execFileSync(command, ["--version"], { encoding: "utf8", timeout: 10_000 }).trim(), manifest.dependencies["opencode-ai"]);
|
|
const requests = [];
|
|
provider = createServer(async (request, response) => {
|
|
const chunks = [];
|
|
for await (const chunk of request) chunks.push(chunk);
|
|
const body = JSON.parse(Buffer.concat(chunks).toString("utf8") || "{}");
|
|
requests.push({ path: request.url, body });
|
|
if (request.url !== "/v1/chat/completions") {
|
|
response.writeHead(404).end();
|
|
return;
|
|
}
|
|
response.writeHead(200, { "Content-Type": "text/event-stream" });
|
|
for (const [delta, finish_reason] of [
|
|
[{ role: "assistant", content: "paperclip-opencode-qualified" }, null],
|
|
[{}, "stop"],
|
|
]) {
|
|
response.write(`data: ${JSON.stringify({ id: "chatcmpl-qualification", object: "chat.completion.chunk", created: 1, model: "qualification", choices: [{ index: 0, delta, finish_reason }] })}\n\n`);
|
|
}
|
|
response.end("data: [DONE]\n\n");
|
|
});
|
|
provider.listen(0, "127.0.0.1");
|
|
await once(provider, "listening");
|
|
const providerUrl = `http://127.0.0.1:${provider.address().port}/v1`;
|
|
const config = join(root, "opencode.json");
|
|
await writeFile(config, JSON.stringify({
|
|
model: "openrouter/qualification",
|
|
small_model: "openrouter/qualification",
|
|
share: "disabled", autoupdate: false, plugin: [],
|
|
enabled_providers: ["openrouter"],
|
|
provider: { openrouter: { options: { baseURL: providerUrl, apiKey: "local-fixture-only" }, models: { qualification: { name: "qualification", limit: { context: 10000, output: 1000 } } } } },
|
|
permission: { "*": "deny" },
|
|
}));
|
|
const workspace = join(root, "workspace");
|
|
await mkdir(workspace);
|
|
child = spawn(command, ["serve", "--hostname", "127.0.0.1", "--port", "0"], {
|
|
cwd: workspace,
|
|
env: {
|
|
PATH: `${dirname(process.execPath)}:${process.env.PATH ?? "/usr/bin:/bin"}`,
|
|
HOME: root, XDG_CONFIG_HOME: join(root, "config"), XDG_DATA_HOME: join(root, "data"), XDG_CACHE_HOME: join(root, "cache"),
|
|
OPENCODE_CONFIG: config,
|
|
OPENCODE_DISABLE_PROJECT_CONFIG: "true", OPENCODE_DISABLE_MODELS_FETCH: "true", OPENCODE_DISABLE_DEFAULT_PLUGINS: "true",
|
|
OPENCODE_SERVER_USERNAME: "paperclip", OPENCODE_SERVER_PASSWORD: "local-fixture-only",
|
|
},
|
|
stdio: ["ignore", "pipe", "pipe"],
|
|
detached: true,
|
|
});
|
|
let output = "";
|
|
for (const stream of [child.stdout, child.stderr]) stream.on("data", (chunk) => { output = `${output}${chunk}`.slice(-16384); });
|
|
exited = once(child, "exit");
|
|
let baseUrl;
|
|
for (let attempt = 0; attempt < 150; attempt++) {
|
|
baseUrl = output.match(/http:\/\/127\.0\.0\.1:\d+/)?.[0];
|
|
if (baseUrl) break;
|
|
assert.equal(child.exitCode, null, output);
|
|
await delay(100);
|
|
}
|
|
assert.ok(baseUrl, `OpenCode did not start: ${output}`);
|
|
const headers = { Authorization: `Basic ${Buffer.from("paperclip:local-fixture-only").toString("base64")}`, "Content-Type": "application/json" };
|
|
const api = async (path, options = {}) => {
|
|
const response = await fetch(`${baseUrl}${path}`, { headers, signal: AbortSignal.timeout(15_000), ...options });
|
|
assert.ok(response.ok, `${path}: ${response.status} ${await response.clone().text()}`);
|
|
return response;
|
|
};
|
|
const health = await (await api("/global/health")).json();
|
|
assert.deepEqual(health, { healthy: true, version: manifest.dependencies["opencode-ai"] });
|
|
const session = await (await api("/session", { method: "POST", body: JSON.stringify({ title: "Runtime qualification" }) })).json();
|
|
assert.equal((await (await api(`/session/${session.id}`)).json()).id, session.id);
|
|
const stream = await fetch(`${baseUrl}/event`, { headers, signal: streamAbort.signal });
|
|
assert.equal(stream.status, 200);
|
|
assert.match(stream.headers.get("content-type"), /text\/event-stream/);
|
|
const reader = stream.body.getReader();
|
|
const events = [];
|
|
const readEvents = (async () => {
|
|
let buffer = "";
|
|
const decoder = new TextDecoder();
|
|
try {
|
|
while (true) {
|
|
const { done, value } = await reader.read();
|
|
if (done) break;
|
|
buffer += decoder.decode(value, { stream: true });
|
|
let boundary;
|
|
while ((boundary = buffer.indexOf("\n\n")) !== -1) {
|
|
const frame = buffer.slice(0, boundary); buffer = buffer.slice(boundary + 2);
|
|
for (const line of frame.split("\n")) if (line.startsWith("data: ")) events.push(JSON.parse(line.slice(6)));
|
|
}
|
|
}
|
|
} catch (error) { if (!streamAbort.signal.aborted) throw error; }
|
|
})();
|
|
const prompt = await api(`/session/${session.id}/prompt_async`, {
|
|
method: "POST",
|
|
body: JSON.stringify({ model: { providerID: "openrouter", modelID: "qualification" }, parts: [{ type: "text", text: "Reply with the qualification marker." }] }),
|
|
});
|
|
assert.equal(prompt.status, 204);
|
|
let messages;
|
|
for (let attempt = 0; attempt < 150; attempt++) {
|
|
messages = await (await api(`/session/${session.id}/message`)).json();
|
|
if (messages.some((message) => message.info.role === "assistant" && message.parts.some((part) => part.type === "text" && part.text === "paperclip-opencode-qualified"))) break;
|
|
await delay(100);
|
|
}
|
|
assert.ok(messages.some((message) => message.info.role === "assistant" && message.parts.some((part) => part.type === "text" && part.text === "paperclip-opencode-qualified")), JSON.stringify(messages));
|
|
assert.ok(requests.some((request) => request.path === "/v1/chat/completions" && request.body.model === "qualification"));
|
|
assert.ok(events.some((event) => event.type === "message.part.updated" || event.type === "message.part.delta"));
|
|
streamAbort.abort();
|
|
await readEvents;
|
|
assert.equal((await api(`/session/${session.id}`, { method: "DELETE" })).status, 200);
|
|
});
|