mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-10-23 17:33:51 +02:00
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - The server ships a copy of Paperclip Runner for native agent execution. > - The Claude ACP bridge is a runner dependency, but it was absent from the server package. > - The runner resolves this bridge dynamically, so the import-based packaging check missed it. > - A Claude session then failed before startup and showed a generic connection error. > - This pull request ships the qualified bridge and reports a missing runtime with repair steps. ## Linked Issues or Issue Description **What happened?** A server install with the vendored runner could not load `@agentclientprotocol/claude-agent-acp/package.json`. The runtime test suggested checking the model or provider connection. The task reported an interrupted runner session. **Expected behavior** The server package includes its qualified Claude ACP runtime. A missing bundled runtime reports an installation error and explains how to repair it. **Steps to reproduce** 1. Use a server install with the vendored runner and no Claude ACP bridge. 2. Select the Paperclip Runner ACP harness and the Claude provider. 3. Run the runtime test or open a session. 4. Observe a missing-module failure before Claude starts. **Paperclip version or commit** Reproduced on `e733bddc45`. This branch is based on current master. **Deployment mode** Self-hosted server built from source. Related: #15224 upgrades the Claude bridge. This PR fixes its omission from the server package and keeps the current qualified version. A future bridge upgrade must update the server pin too. ## What Changed - Add Claude ACP `0.73.0` to the server dependencies and bundled dependencies. - Pin the qualified Claude SDK and bridge dependencies in the npm bundle producer graph. Publish its native packages as consumer optional dependencies instead of shipping the producer executable. - Bind source-built vendored runners to the shared pnpm dependency store while retaining the server manifest as the provider authority. Keep published npm and self-rooted deployment roots unchanged. - Include dynamically resolved Claude and Codex bridges in the vendor dependency check. - Preserve the missing-package category through the sidecar, Rust transport, and native session executor. Stop automatic retries for this installation failure. - Show **Runtime missing** in the runtime test and task thread. Explain the reinstall or rebuild, server restart, and runtime test steps. - Add regression tests and document the repair procedure. ## Verification - Red/green comparison with the production sidecar: the same missing-package setup returns a raw require-stack error on the original code and an actionable, non-retryable missing-runtime error on this branch. - The rebuilt server's vendored Claude installation probe passes using the source-server authority selected by the launcher, without starting a provider or making a model request. - Focused server verification: 830 tests passed. Runner installation and sidecar error tests: 83 passed, with 6 platform-specific skips. Packaging tests: 28 passed. Rust transport tests: 7 passed. - Source/deployment authority tests: 3 passed. Red/green packaging tests include a Linux-produced Claude SDK bundle, actual npm pack, and closed executable admission on Linux x64 and macOS ARM64/x64. - Full UI suite: 8,113 tests passed. - `pnpm -r typecheck` and `pnpm build` passed on the rebased branch. - Full current-head CI passed, including all general and serialized test lanes, Runner Rust/Vitest verification, typecheck, build, and all eight e2e shards. Greptile reviewed `d6a2741834ff922956560f2f689382827bbaf9e0` at 5/5 with no unresolved threads. - Local full-suite limitation: an earlier parallel attempt hit Postgres startup failures and timeouts; the affected server tests and a database fixture passed in isolation. The subsequent serial `pnpm test:run` was stopped while still running after complete CI passed. Focused local tests, full UI tests, typecheck, and build completed as listed above. - Token gates and `git diff --check` passed. ## Risks - Bundling the Claude bridge increases the server package size. The producer graph retains the qualified SDK version and existing isolation patch. Native platform declarations move to the published server manifest, while the runtime keeps its exact version, declared-slot, no-follow, and executable digest checks. - The new failure category is permanent. Operators must repair the server installation before they retry the task. - Existing failed runs retain their recorded error. The clearer message applies to new runtime tests and runs. - No database schema or migration changes. ## Model Used OpenAI GPT-6 through Codex. The system reports the model family; the exact deployment ID and context-window size are not exposed in this session. Used reasoning, browser inspection, tool use, and code execution. ## 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>
211 lines
9.9 KiB
TypeScript
211 lines
9.9 KiB
TypeScript
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
import { assertValidAdapterLoginCapability } from "@paperclipai/adapter-utils";
|
|
import { listServerAdapters, requireServerAdapter } from "./registry.js";
|
|
import * as executionTarget from "@paperclipai/adapter-utils/execution-target";
|
|
import { BUILTIN_ADAPTER_TYPES } from "./builtin-adapter-types.js";
|
|
|
|
const { probeInstallation, probeGrokInstallation, probePiInstallation } = vi.hoisted(() => ({
|
|
probeInstallation: vi.fn(),
|
|
probeGrokInstallation: vi.fn(),
|
|
probePiInstallation: vi.fn(),
|
|
}));
|
|
vi.mock("../vendor/paperclip-runner/live/index.js", () => ({
|
|
probeAcpxClaudeInstallation: probeInstallation,
|
|
probeAcpxGrokInstallation: probeGrokInstallation,
|
|
probeAcpxPiInstallation: probePiInstallation,
|
|
probeAcpxCursorInstallation: vi.fn(async () => undefined),
|
|
}));
|
|
|
|
// The registry registers a login capability for the two built-in interactive
|
|
// adapters. The test checks the scalar values and the presence of the required
|
|
// callbacks. It also runs the shared validator, so the built-in capabilities
|
|
// obey the same fail-closed contract as an external adapter.
|
|
|
|
describe("built-in adapter login capabilities", () => {
|
|
it("registers the Codex device-login capability", () => {
|
|
const capability = requireServerAdapter("codex_local").loginCapability;
|
|
expect(capability).toBeDefined();
|
|
if (!capability) return;
|
|
expect(capability.panelMode).toBe("displayed_code");
|
|
expect(capability.timeoutPolicy).toBe("caller_bounded");
|
|
expect(capability.completionClaim).toBeUndefined();
|
|
expect(typeof capability.getCommand).toBe("function");
|
|
expect(typeof capability.parsePrompt).toBe("function");
|
|
expect(() => assertValidAdapterLoginCapability(capability, "codex_local")).not.toThrow();
|
|
});
|
|
|
|
it("registers the Grok device-login capability", () => {
|
|
const capability = requireServerAdapter("grok_local").loginCapability;
|
|
expect(capability).toBeDefined();
|
|
if (!capability) return;
|
|
expect(capability.panelMode).toBe("displayed_code");
|
|
expect(capability.timeoutPolicy).toBe("caller_bounded");
|
|
expect(capability.completionClaim).toBeUndefined();
|
|
expect(typeof capability.getCommand).toBe("function");
|
|
expect(typeof capability.parsePrompt).toBe("function");
|
|
expect(() => assertValidAdapterLoginCapability(capability, "grok_local")).not.toThrow();
|
|
});
|
|
|
|
it("registers the Claude setup-token capability", () => {
|
|
const capability = requireServerAdapter("claude_local").loginCapability;
|
|
expect(capability).toBeDefined();
|
|
if (!capability) return;
|
|
expect(capability.panelMode).toBe("submitted_browser_code");
|
|
expect(capability.timeoutPolicy).toBe("fixed");
|
|
expect(capability.completionClaim).toBe("storedSessionId");
|
|
expect(typeof capability.getCommand).toBe("function");
|
|
expect(typeof capability.parsePrompt).toBe("function");
|
|
expect(typeof capability.captureCredential).toBe("function");
|
|
expect(() => assertValidAdapterLoginCapability(capability, "claude_local")).not.toThrow();
|
|
});
|
|
});
|
|
|
|
describe("built-in runtime connection tool delivery", () => {
|
|
const expectedStrategies = new Map([
|
|
["acpx_local", "environment"],
|
|
["claude_local", "native_mcp"],
|
|
["codex_local", "native_mcp"],
|
|
["cursor_cloud", "invocation_context"],
|
|
["cursor", "environment"],
|
|
["gemini_local", "environment"],
|
|
["grok_local", "environment"],
|
|
["hermes_gateway", "invocation_context"],
|
|
["hermes_local", "environment"],
|
|
["kimi_local", "environment"],
|
|
["openclaw_gateway", "invocation_context"],
|
|
["opencode_local", "environment"],
|
|
["paperclip_runner", "environment"],
|
|
["pi_local", "environment"],
|
|
["process", "environment"],
|
|
["http", "invocation_context"],
|
|
] as const);
|
|
|
|
it("requires every built-in adapter to declare its expected delivery strategy", () => {
|
|
const builtIns = listServerAdapters().filter((adapter) => BUILTIN_ADAPTER_TYPES.has(adapter.type));
|
|
expect(new Set(builtIns.map((adapter) => adapter.type))).toEqual(BUILTIN_ADAPTER_TYPES);
|
|
expect(new Map(builtIns.map((adapter) => [adapter.type, adapter.runtimeToolDelivery]))).toEqual(
|
|
expectedStrategies,
|
|
);
|
|
});
|
|
|
|
it.each([...expectedStrategies])("delivers %s runtime tools through %s", (type, strategy) => {
|
|
expect(requireServerAdapter(type).runtimeToolDelivery).toBe(strategy);
|
|
});
|
|
});
|
|
|
|
|
|
describe("native ACPX environment checks", () => {
|
|
beforeEach(() => {
|
|
probeInstallation.mockReset().mockResolvedValue(undefined);
|
|
probeGrokInstallation.mockReset().mockResolvedValue(undefined);
|
|
probePiInstallation.mockReset().mockResolvedValue(undefined);
|
|
});
|
|
afterEach(() => vi.restoreAllMocks());
|
|
|
|
const context = {
|
|
companyId: "company-test",
|
|
adapterType: "paperclip_runner",
|
|
config: { provider: "acpx", acpxAgent: "claude", model: "claude-sonnet-5" },
|
|
};
|
|
|
|
it("reports unsupported local platforms before a successful CLI login can mask them", async () => {
|
|
probeInstallation.mockRejectedValue(new Error("ACPX Claude requires a supported runtime platform"));
|
|
const result = await requireServerAdapter("paperclip_runner").testEnvironment!(context);
|
|
expect(result.status).toBe("fail");
|
|
expect(result.checks).toEqual([expect.objectContaining({
|
|
code: "acpx_runtime_unavailable",
|
|
level: "error",
|
|
})]);
|
|
});
|
|
|
|
it("identifies an incomplete installation and gives the operator a repair", async () => {
|
|
probeInstallation.mockRejectedValue(Object.assign(new Error("The Claude ACP runtime package is missing. Reinstall or rebuild Paperclip."), { code: "ACPX_RUNTIME_PACKAGE_MISSING" }));
|
|
const result = await requireServerAdapter("paperclip_runner").testEnvironment!(context);
|
|
expect(result.status).toBe("fail");
|
|
expect(result.checks[0]).toMatchObject({ code: "acpx_runtime_package_missing", message: expect.stringContaining("Reinstall or rebuild") });
|
|
});
|
|
|
|
it("requires a successful installed runtime probe", async () => {
|
|
const result = await requireServerAdapter("paperclip_runner").testEnvironment!(context);
|
|
expect(result.status).toBe("pass");
|
|
expect(probeInstallation).toHaveBeenCalledWith(context.config.model);
|
|
});
|
|
|
|
it.each([true, false])("checks Grok's own installation readiness (%s)", async (ready) => {
|
|
if (!ready) probeGrokInstallation.mockRejectedValueOnce(new Error("Grok executable digest mismatch"));
|
|
const result = await requireServerAdapter("paperclip_runner").testEnvironment!({
|
|
...context,
|
|
config: { provider: "acpx", acpxAgent: "grok", model: "grok-4.7" },
|
|
});
|
|
expect(result.status).toBe(ready ? "pass" : "fail");
|
|
expect(probeGrokInstallation).toHaveBeenCalledWith("grok-4.7");
|
|
expect(probeInstallation).not.toHaveBeenCalled();
|
|
});
|
|
|
|
it.each([true, false])("checks qualified Pi's own installation readiness (%s)", async (ready) => {
|
|
if (!ready) probePiInstallation.mockRejectedValueOnce(new Error("Pi installation integrity mismatch"));
|
|
const model = "openrouter/deepseek/deepseek-v4-flash-0731";
|
|
const result = await requireServerAdapter("paperclip_runner").testEnvironment!({
|
|
...context,
|
|
config: { provider: "acpx", acpxAgent: "pi", model },
|
|
});
|
|
expect(result.status).toBe(ready ? "pass" : "fail");
|
|
expect(probePiInstallation).toHaveBeenCalledWith(model);
|
|
expect(probeInstallation).not.toHaveBeenCalled();
|
|
expect(probeGrokInstallation).not.toHaveBeenCalled();
|
|
});
|
|
|
|
it("does not use the host platform to reject a remote environment", async () => {
|
|
vi.spyOn(process, "platform", "get").mockReturnValue("darwin");
|
|
const result = await requireServerAdapter("paperclip_runner").testEnvironment!({
|
|
...context,
|
|
executionTarget: {
|
|
kind: "remote", transport: "sandbox", remoteCwd: "/workspace", providerKey: "test",
|
|
runner: { execute: vi.fn().mockResolvedValue({ exitCode: 0, timedOut: false, stdout: "Linux\nx86_64\n" }) },
|
|
},
|
|
});
|
|
expect(result.status).toBe("warn");
|
|
expect(result.checks[0].code).toBe("acpx_remote_runtime_unverified");
|
|
expect(probeInstallation).not.toHaveBeenCalled();
|
|
});
|
|
|
|
const sshTarget = {
|
|
kind: "remote" as const, transport: "ssh" as const, remoteCwd: "/workspace",
|
|
spec: {
|
|
host: "example.test", port: 22, username: "tester", remoteCwd: "/workspace",
|
|
remoteWorkspacePath: "/workspace", privateKey: null, knownHosts: null, strictHostKeyChecking: true,
|
|
},
|
|
};
|
|
|
|
it.each([
|
|
["Linux\nx86_64\n", "warn"],
|
|
["Darwin\nx86_64\n", "warn"],
|
|
["Darwin\narm64\n", "warn"],
|
|
["Linux\naarch64\n", "fail"],
|
|
["", "fail"],
|
|
])("qualifies the SSH platform from its own uname output %j", async (stdout, status) => {
|
|
vi.spyOn(process, "platform", "get").mockReturnValue("linux");
|
|
vi.spyOn(process, "arch", "get").mockReturnValue("x64");
|
|
const probe = vi.spyOn(executionTarget, "runAdapterExecutionTargetShellCommand").mockResolvedValue({
|
|
exitCode: 0, timedOut: false, stdout, stderr: "", signal: null, pid: null, startedAt: new Date(0).toISOString(),
|
|
});
|
|
const result = await requireServerAdapter("paperclip_runner").testEnvironment!({ ...context, executionTarget: sshTarget });
|
|
expect(result.status).toBe(status);
|
|
expect(probe).toHaveBeenCalledWith(expect.any(String), sshTarget, "uname -s && uname -m", {
|
|
cwd: "/workspace", env: {}, timeoutSec: 15,
|
|
});
|
|
});
|
|
|
|
it.each(["timeout", "exit", "exception"])("does not qualify an SSH target after a probe %s", async (failure) => {
|
|
const probe = vi.spyOn(executionTarget, "runAdapterExecutionTargetShellCommand");
|
|
if (failure === "exception") probe.mockRejectedValue(new Error("connection unavailable"));
|
|
else probe.mockResolvedValue({
|
|
exitCode: failure === "exit" ? 1 : 0, timedOut: failure === "timeout",
|
|
stdout: "Linux\nx86_64\n", stderr: "", signal: null, pid: null, startedAt: new Date(0).toISOString(),
|
|
});
|
|
const result = await requireServerAdapter("paperclip_runner").testEnvironment!({ ...context, executionTarget: sshTarget });
|
|
expect(result.status).toBe("fail");
|
|
expect(result.checks[0].code).toBe("acpx_runtime_unavailable");
|
|
});
|
|
});
|