mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-10-11 05:31:46 +02:00
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - Agent adapters select a provider, a model, and a runtime. > - Runner conversion rejected existing Claude agents. The model list mixed providers. > - The native Claude runner rejected custom models and could not launch on macOS. > - This pull request fixes conversion, model selection, and verified macOS execution. > - It also groups configuration fields consistently across adapters and opens artifact images in the task gallery. > - Operators can change an agent configuration and run the selected model on their Mac. ## Linked Issues or Issue Description **What happened?** Converting an existing Claude agent to Paperclip Runner failed with a Codex-only restriction. ACPX Claude showed unrelated models and required `claude-sonnet-5`. Its native runtime rejected macOS. Configuration mixed common model settings with process controls. Artifact cards labeled “Open gallery” navigated to attachment URLs instead of opening the task gallery. **Expected behavior** Conversion keeps agent identity and compatible settings. ACPX Claude uses the normal Claude catalog and accepts typed model IDs. Codex uses the native runner. The verified Claude runtime can launch on macOS ARM64 and x64. Common configuration sections place the same fields together across adapters. Artifact images open in the shared task gallery with navigation and downloads. **Steps to reproduce** 1. Open the configuration of an existing Claude agent. 2. Convert it to Paperclip Runner. 3. Select ACPX Claude and a different catalog model or a typed model ID. 4. Save the agent and run a disposable task on macOS. 5. Inspect configuration and advanced run-policy controls across adapters. **Paperclip version or commit** The bugs were reproduced on `165ca56a22adb60e5fda56045442d9c8498116a8`. This branch was rebased onto `7ed122911`. **Deployment mode** Built from source. Local test-drive instance on macOS ARM64 with an isolated database. Related work: #11798 addresses unsupported ACP session options in the existing adapter path. #13048 addresses working-folder preservation. This change fixes native runner configuration and launch behavior. ## What Changed - Remove the Codex-only conversion restriction. Preserve agent identity, instructions, directories, credentials, and compatible model settings. Reset incompatible sessions while retaining history. - Show ACPX Claude and native Codex as distinct provider choices. Remove ACPX Codex from advertised configuration. Normalize legacy configurations before fresh runs without rewriting historical run descriptors. - Select model catalogs and cache entries by provider. Support refresh and typed model IDs. Pass exact Claude IDs through session creation, model changes, and recovery. - Add verified macOS ARM64 and x64 Claude SDK snapshots. Bound executable allocation and total snapshot size. Preserve package checks, dependency isolation, process ownership, cancellation, and Linux descriptor loading. - Probe local runtime readiness. Report remote platform checks as incomplete until the remote runner verifies its runtime. - Surface actual model rejection and allow correction and retry. - Repair missing ACPX goal-capability helpers exposed by the post-rebase live test. Persist and restore the optional capability without breaking session startup. - Put Agent identity first and intentionally remove the Capabilities editor, as requested. This is removal of UI editing, not relocation: preserve existing capability metadata and API compatibility without adding another editor. Use the themed select for configurable permission modes, with normal text instead of monospace. - Put model and provider under Adapter. Give environment variables their own section. Fold command and arguments under Configuration. Fold lifecycle, timeout, and interrupt grace under Advanced Run Policy. Hide single-option permission controls. - Open image and video artifact cards in the existing task gallery, including cards in the artifacts panel. Chat attachment images use the same gallery. Preserve standalone media previews and download links. ## Verification - Rebased focused UI/API/database suites: 293 tests passed. - Rebased native runtime and ACPX suites: 242 passed, 7 skipped. - Repository typecheck, build, and token gates passed for the runner changes. Gallery follow-up UI typecheck, build, and token gates also passed. - Follow-up UI suites passed (86 tests), packaging checks passed (14 tests), and the final focused runtime suites passed (126 passed, 7 skipped). - Linux container isolation and lifecycle fixtures passed before rebase (57 passed, 2 skipped). Rust ACPX provider-session tests passed after rebase (8 tests). - Browser tests completed actual Claude and native Codex tasks on macOS ARM64. They covered conversion, catalog refresh, a non-default catalog model, a typed `haiku` ID, save/reload, cancel, follow-up session continuity, invalid-model errors, and recovery. - Final-revision live tests completed a typed Claude task, a follow-up with the same provider session, and a native Codex task on macOS ARM64. - Browser tests confirmed the moved interrupt-grace field saves and survives reload. Cross-adapter tests cover Claude, Codex, Gemini, process, gateway, and schema forms. - Full local run: 7,080 passed, 30 skipped, and two timeouts. Both timeout suites passed on isolated rerun (84 tests); the failures were the plugin login-worker exit diagnostic and the runner real-server vertical slice. - Final follow-up checks: 50 registry tests and 45 snapshot/installation tests passed (6 platform-specific skips). Oversized executable rejection is covered before allocation or reading; unsupported-platform tests invoke the real installation probe. - Runner head `ddb5101c483a297f74875ab96b3c66035b002d50`: all CI gates green, including full runner verification, repository build, typecheck, general/serialized server suites, browser tests, and canary dry run. [CI run](https://github.com/paperclipai/paperclip/actions/runs/34286178670). - Greptile: 5/5 on that runner head. All four review threads resolved. Superagent, Socket, and Snyk checks green. - After snapshot hardening, another real Claude task completed on this Mac using the rebuilt runtime. - Gallery follow-up: 148 focused tests passed, covering artifact selection, shared attachment collections, deduplication, image/video cards, standalone previews, downloads, and closing. Live browser verification completed on the settings follow-up: artifact selection, 6-image pagination with wrapping, download action, and closing all stayed on the same task URL. All checks passed on gallery head `96136da58ff195bf6ca00b281eb3022ad12d7bd8`: [CI run](https://github.com/paperclipai/paperclip/actions/runs/34287987536). Greptile returned 5/5 on that exact head with no unresolved threads. - Final settings polish: 96 focused tests, UI typecheck/build, and token gates passed. A real browser walkthrough verified readable permission options, identity placement, Capabilities removal, and permission save/reload. Original test-agent permission mode restored. All 31 checks passed on final head `e46540d6bf32bfb0566dca16b2f4a75ba437618c`: [CI run](https://github.com/paperclipai/paperclip/actions/runs/34292797886). Greptile returned 5/5 with no unresolved threads. ## Risks - Capabilities intentionally has no editable UI field after this change. Existing values remain readable and API-compatible; removing the field does not erase stored metadata. - macOS launch now copies verified package files into private snapshots. The implementation must retain isolation and clean up snapshots on exit. - Runtime provider or model changes reset the current session. Historical runs remain available. - The macOS x64 SDK executable digest was verified, but a live Intel Mac run was not available. Linux verification used container fixtures, not a real Claude task. - Remote environment tests report a warning when only the platform has been checked. They do not claim package readiness from the server host. ## Model Used OpenAI Codex, based on GPT-6. The exact served model identifier and context-window limit are not exposed in this session. Used reasoning, repository inspection, code execution, Rust and TypeScript tests, and browser automation. ## 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 (focused suites and both timeout suites on rerun; full-run counts 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>
466 lines
15 KiB
TypeScript
466 lines
15 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
|
|
import { BUILTIN_ADAPTER_TYPES } from "../../adapters/builtin-adapter-types.js";
|
|
import {
|
|
NativeRunnerSelectionError,
|
|
NativeRuntimeEligibilityError,
|
|
isRunnerIngressAuthorized,
|
|
resolveHeartbeatNativeRuntimeMode,
|
|
resolveHeartbeatRuntimeMode,
|
|
resolveNativeRuntimeMode,
|
|
} from "./runtime-mode.js";
|
|
|
|
const eligible = {
|
|
enabled: true,
|
|
runtimeConfig: {},
|
|
adapterConfig: { provider: "codex" },
|
|
agent: { status: "running", adapterType: "paperclip_runner" },
|
|
issue: { id: "issue", workMode: "standard" },
|
|
target: { kind: "local" },
|
|
workspaceId: "workspace",
|
|
} as const;
|
|
|
|
describe("resolveNativeRuntimeMode", () => {
|
|
it("keeps every direct built-in adapter outside native arbitration", () => {
|
|
for (const adapterType of BUILTIN_ADAPTER_TYPES) {
|
|
if (adapterType === "paperclip_runner") continue;
|
|
expect(resolveNativeRuntimeMode({
|
|
...eligible,
|
|
enabled: false,
|
|
runtimeConfig: {
|
|
nativeRunner: {
|
|
mode: "native",
|
|
backend: "codex_app_server",
|
|
protocolVersion: 1,
|
|
},
|
|
},
|
|
agent: { ...eligible.agent, adapterType },
|
|
})).toEqual({
|
|
kind: "legacy",
|
|
resolverVersion: "phase6-v1",
|
|
reason: "direct_adapter",
|
|
});
|
|
}
|
|
});
|
|
|
|
it("rejects a fresh Paperclip Runner start while the rollout flag is disabled", () => {
|
|
expect(() => resolveNativeRuntimeMode({
|
|
...eligible,
|
|
enabled: false,
|
|
})).toThrow(expect.objectContaining({
|
|
code: "paperclip_runner_rollout_disabled",
|
|
}));
|
|
});
|
|
|
|
it("rejects unknown Paperclip Runner providers", () => {
|
|
expect(() => resolveNativeRuntimeMode({
|
|
...eligible,
|
|
runtimeConfig: {},
|
|
adapterConfig: { provider: "claude" },
|
|
agent: { ...eligible.agent, adapterType: "paperclip_runner" },
|
|
})).toThrow(expect.objectContaining({
|
|
code: "paperclip_runner_provider_unsupported",
|
|
}));
|
|
});
|
|
|
|
it("admits fresh local, managed, and qualified ACPX profiles", () => {
|
|
expect(resolveNativeRuntimeMode({
|
|
...eligible,
|
|
adapterConfig: { provider: "opencode", model: "openrouter/deepseek/deepseek-v4-flash-0731" },
|
|
})).toMatchObject({
|
|
kind: "native",
|
|
profile: { backend: "opencode_server" },
|
|
});
|
|
expect(resolveNativeRuntimeMode({
|
|
...eligible,
|
|
adapterConfig: {
|
|
provider: "claude_managed",
|
|
managedProfileId: "managed-primary",
|
|
managedAgentsRetentionAcknowledged: true,
|
|
},
|
|
})).toMatchObject({
|
|
kind: "native",
|
|
profile: { backend: "claude_managed_agents_api" },
|
|
});
|
|
expect(resolveNativeRuntimeMode({
|
|
...eligible,
|
|
adapterConfig: {
|
|
provider: "aws_agentcore",
|
|
agentCoreProfileId: "agentcore-primary",
|
|
agentCoreRetentionAcknowledged: true,
|
|
},
|
|
})).toMatchObject({
|
|
kind: "native",
|
|
profile: { backend: "aws_agentcore_harness_api" },
|
|
});
|
|
expect(resolveNativeRuntimeMode({
|
|
...eligible,
|
|
adapterConfig: { provider: "acpx", acpxAgent: "claude", model: "claude-sonnet-5" },
|
|
})).toMatchObject({
|
|
kind: "native",
|
|
profile: { backend: "acpx_runtime" },
|
|
});
|
|
expect(resolveNativeRuntimeMode({
|
|
...eligible,
|
|
adapterConfig: { provider: "acpx", acpxAgent: "codex", model: "gpt-5.6-sol" },
|
|
})).toMatchObject({
|
|
kind: "native",
|
|
profile: { backend: "acpx_runtime" },
|
|
});
|
|
});
|
|
|
|
it("rejects malformed OpenCode and unqualified ACPX profiles", () => {
|
|
expect(() => resolveNativeRuntimeMode({
|
|
...eligible,
|
|
adapterConfig: { provider: "opencode", model: "gpt-5.6-sol" },
|
|
})).toThrow(expect.objectContaining({
|
|
code: "paperclip_runner_opencode_model_invalid",
|
|
}));
|
|
expect(() => resolveNativeRuntimeMode({
|
|
...eligible,
|
|
adapterConfig: {
|
|
provider: "acpx",
|
|
acpxAgent: "pi",
|
|
model: "openrouter/deepseek/deepseek-v4-flash-0731",
|
|
},
|
|
})).toThrow(expect.objectContaining({
|
|
code: "paperclip_runner_acpx_agent_unavailable",
|
|
}));
|
|
expect(() => resolveNativeRuntimeMode({
|
|
...eligible,
|
|
adapterConfig: { provider: "acpx", acpxAgent: "claude", model: "claude-opus-5" },
|
|
})).not.toThrow();
|
|
});
|
|
|
|
it("rejects incomplete managed-provider selections before a run is persisted", () => {
|
|
expect(() => resolveNativeRuntimeMode({
|
|
...eligible,
|
|
adapterConfig: {
|
|
provider: "claude_managed",
|
|
managedProfileId: "managed-primary",
|
|
},
|
|
})).toThrow(expect.objectContaining({
|
|
code: "paperclip_runner_claude_managed_retention_required",
|
|
}));
|
|
expect(() => resolveNativeRuntimeMode({
|
|
...eligible,
|
|
adapterConfig: {
|
|
provider: "aws_agentcore",
|
|
agentCoreRetentionAcknowledged: true,
|
|
},
|
|
})).toThrow(expect.objectContaining({
|
|
code: "paperclip_runner_aws_agentcore_profile_required",
|
|
}));
|
|
});
|
|
|
|
it("uses adapterConfig as the fresh provider authority", () => {
|
|
expect(resolveNativeRuntimeMode({
|
|
...eligible,
|
|
runtimeConfig: {
|
|
nativeRunner: { provider: "opencode" },
|
|
},
|
|
adapterConfig: { provider: "codex" },
|
|
})).toMatchObject({
|
|
kind: "native",
|
|
profile: { backend: "codex_app_server" },
|
|
});
|
|
});
|
|
|
|
it("preserves legacy as the default and as the kill-switch behavior", () => {
|
|
const direct = {
|
|
...eligible,
|
|
agent: { ...eligible.agent, adapterType: "codex_local" },
|
|
runtimeConfig: { nativeRunner: { mode: "native", backend: "codex_app_server", protocolVersion: 1 } },
|
|
};
|
|
expect(resolveNativeRuntimeMode(direct)).toEqual(expect.objectContaining({
|
|
kind: "legacy",
|
|
reason: "direct_adapter",
|
|
}));
|
|
expect(resolveNativeRuntimeMode({ ...direct, enabled: false })).toEqual(expect.objectContaining({
|
|
kind: "legacy",
|
|
reason: "direct_adapter",
|
|
}));
|
|
});
|
|
|
|
it("selects native only for an eligible explicit profile", () => {
|
|
expect(resolveNativeRuntimeMode(eligible)).toEqual(expect.objectContaining({
|
|
kind: "native",
|
|
reason: "eligible_opt_in",
|
|
}));
|
|
});
|
|
|
|
it("keeps a persisted active run native while the global flag rejects a fresh runner start", () => {
|
|
const disabled = { ...eligible, enabled: false };
|
|
expect(resolveHeartbeatNativeRuntimeMode({
|
|
...disabled,
|
|
persisted: {
|
|
runtimeMode: "native",
|
|
runtimeModeReason: "eligible_opt_in",
|
|
runtimeModeResolvedAt: new Date(),
|
|
},
|
|
})).toEqual(expect.objectContaining({
|
|
kind: "native",
|
|
reason: "eligible_opt_in",
|
|
authorityDecision: expect.objectContaining({ reasonCode: "live_continuation_registered" }),
|
|
}));
|
|
expect(() => resolveHeartbeatNativeRuntimeMode({
|
|
...disabled,
|
|
persisted: { runtimeMode: null, runtimeModeReason: null, runtimeModeResolvedAt: null },
|
|
})).toThrow(expect.objectContaining({
|
|
code: "paperclip_runner_rollout_disabled",
|
|
}));
|
|
});
|
|
|
|
it("authorizes ingress from the native runtime decision without a second flag", () => {
|
|
const freshNative = resolveHeartbeatNativeRuntimeMode({
|
|
...eligible,
|
|
persisted: {
|
|
runtimeMode: null,
|
|
runtimeModeReason: null,
|
|
runtimeModeResolvedAt: null,
|
|
},
|
|
});
|
|
const persistedNative = resolveHeartbeatNativeRuntimeMode({
|
|
...eligible,
|
|
enabled: false,
|
|
persisted: {
|
|
runtimeMode: "native",
|
|
runtimeModeReason: "eligible_opt_in",
|
|
runtimeModeResolvedAt: new Date(),
|
|
},
|
|
});
|
|
const directLegacy = resolveHeartbeatNativeRuntimeMode({
|
|
...eligible,
|
|
enabled: false,
|
|
agent: { ...eligible.agent, adapterType: "codex_local" },
|
|
persisted: {
|
|
runtimeMode: null,
|
|
runtimeModeReason: null,
|
|
runtimeModeResolvedAt: null,
|
|
},
|
|
});
|
|
|
|
expect(isRunnerIngressAuthorized(freshNative)).toBe(true);
|
|
expect(isRunnerIngressAuthorized(persistedNative)).toBe(true);
|
|
expect(isRunnerIngressAuthorized(directLegacy)).toBe(false);
|
|
});
|
|
|
|
it.each(["paused", "terminated", "pending_approval"])(
|
|
"refuses persisted native recovery for a %s agent",
|
|
(status) => {
|
|
expect(() => resolveHeartbeatNativeRuntimeMode({
|
|
...eligible,
|
|
enabled: false,
|
|
agent: { ...eligible.agent, status },
|
|
persisted: {
|
|
runtimeMode: "native",
|
|
runtimeModeReason: "eligible_opt_in",
|
|
runtimeModeResolvedAt: new Date(),
|
|
driverKind: "codex_app_server",
|
|
},
|
|
})).toThrow(expect.objectContaining({
|
|
code: "paperclip_runner_agent_ineligible",
|
|
}));
|
|
},
|
|
);
|
|
|
|
it("fails closed for an unknown persisted driver", () => {
|
|
expect(() => resolveHeartbeatNativeRuntimeMode({
|
|
...eligible,
|
|
enabled: false,
|
|
persisted: {
|
|
runtimeMode: "native",
|
|
runtimeModeReason: "eligible_opt_in",
|
|
runtimeModeResolvedAt: new Date(),
|
|
driverKind: "unknown_driver",
|
|
},
|
|
})).toThrow(expect.objectContaining({
|
|
code: "paperclip_runner_driver_unsupported",
|
|
}));
|
|
});
|
|
|
|
it("does not recover a native run through a direct adapter", () => {
|
|
expect(() => resolveHeartbeatNativeRuntimeMode({
|
|
...eligible,
|
|
enabled: false,
|
|
agent: { ...eligible.agent, adapterType: "codex_local" },
|
|
persisted: {
|
|
runtimeMode: "native",
|
|
runtimeModeReason: "eligible_opt_in",
|
|
runtimeModeResolvedAt: new Date(),
|
|
driverKind: "codex_app_server",
|
|
},
|
|
})).toThrow(expect.objectContaining({
|
|
code: "paperclip_runner_adapter_binding_mismatch",
|
|
}));
|
|
});
|
|
|
|
it("keeps a persisted OpenCode recovery on its immutable driver", () => {
|
|
expect(resolveHeartbeatNativeRuntimeMode({
|
|
...eligible,
|
|
enabled: false,
|
|
persisted: {
|
|
runtimeMode: "native",
|
|
runtimeModeReason: "eligible_opt_in",
|
|
runtimeModeResolvedAt: new Date(),
|
|
driverKind: "opencode_server",
|
|
},
|
|
})).toEqual(expect.objectContaining({
|
|
profile: { mode: "native", backend: "opencode_server", protocolVersion: 1 },
|
|
}));
|
|
});
|
|
|
|
it.each([
|
|
"claude_managed_agents_api",
|
|
"aws_agentcore_harness_api",
|
|
] as const)("keeps a persisted %s recovery on its immutable driver", (driverKind) => {
|
|
expect(resolveHeartbeatNativeRuntimeMode({
|
|
...eligible,
|
|
enabled: false,
|
|
persisted: {
|
|
runtimeMode: "native",
|
|
runtimeModeReason: "eligible_opt_in",
|
|
runtimeModeResolvedAt: new Date(),
|
|
driverKind,
|
|
},
|
|
})).toEqual(expect.objectContaining({
|
|
profile: { mode: "native", backend: driverKind, protocolVersion: 1 },
|
|
}));
|
|
});
|
|
|
|
it("keeps a persisted ACPX recovery even when fresh selection is disabled", () => {
|
|
expect(resolveHeartbeatNativeRuntimeMode({
|
|
...eligible,
|
|
enabled: false,
|
|
adapterConfig: {
|
|
provider: "acpx",
|
|
acpxAgent: "pi",
|
|
model: "historical",
|
|
},
|
|
persisted: {
|
|
runtimeMode: "native",
|
|
runtimeModeReason: "eligible_opt_in",
|
|
runtimeModeResolvedAt: new Date(),
|
|
driverKind: "acpx_runtime",
|
|
},
|
|
})).toEqual(expect.objectContaining({
|
|
profile: { mode: "native", backend: "acpx_runtime", protocolVersion: 1 },
|
|
}));
|
|
});
|
|
|
|
it("rejects an explicit native profile outside the approved boundary", () => {
|
|
expect(resolveNativeRuntimeMode({ ...eligible, agent: { ...eligible.agent, adapterType: "claude_local" } }))
|
|
.toEqual(expect.objectContaining({ kind: "legacy", reason: "direct_adapter" }));
|
|
expect(() => resolveNativeRuntimeMode({ ...eligible, issue: { id: "issue", workMode: "skill_test" } }))
|
|
.toThrow(NativeRuntimeEligibilityError);
|
|
});
|
|
|
|
it("admits remote targets only through paperclip_runner", () => {
|
|
expect(resolveNativeRuntimeMode({
|
|
...eligible,
|
|
target: { kind: "remote" },
|
|
runtimeConfig: {},
|
|
adapterConfig: { provider: "codex" },
|
|
agent: { ...eligible.agent, adapterType: "paperclip_runner" },
|
|
})).toMatchObject({ kind: "native" });
|
|
expect(resolveNativeRuntimeMode({
|
|
...eligible,
|
|
target: { kind: "remote" },
|
|
agent: { ...eligible.agent, adapterType: "codex_local" },
|
|
})).toMatchObject({ kind: "legacy", reason: "direct_adapter" });
|
|
});
|
|
|
|
it("allows paperclip_runner to use a transient local workspace for projectless issues", () => {
|
|
expect(resolveNativeRuntimeMode({
|
|
...eligible,
|
|
workspaceId: null,
|
|
agent: { ...eligible.agent, adapterType: "paperclip_runner" },
|
|
runtimeConfig: {},
|
|
adapterConfig: { provider: "codex" },
|
|
})).toEqual(expect.objectContaining({ kind: "native" }));
|
|
});
|
|
|
|
it("admits planning only through paperclip_runner", () => {
|
|
expect(resolveNativeRuntimeMode({
|
|
...eligible,
|
|
issue: { id: "plan-issue", workMode: "planning" },
|
|
runtimeConfig: {},
|
|
adapterConfig: { provider: "codex" },
|
|
agent: { ...eligible.agent, adapterType: "paperclip_runner" },
|
|
})).toMatchObject({ kind: "native", profile: { backend: "codex_app_server" } });
|
|
expect(resolveNativeRuntimeMode({
|
|
...eligible,
|
|
issue: { id: "plan-issue", workMode: "planning" },
|
|
agent: { ...eligible.agent, adapterType: "codex_local" },
|
|
})).toEqual(expect.objectContaining({ kind: "legacy", reason: "direct_adapter" }));
|
|
});
|
|
|
|
it("admits ask mode through paperclip_runner while preserving the legacy native boundary", () => {
|
|
expect(resolveNativeRuntimeMode({
|
|
...eligible,
|
|
issue: { id: "ask-issue", workMode: "ask" },
|
|
runtimeConfig: {},
|
|
adapterConfig: { provider: "codex" },
|
|
agent: { ...eligible.agent, adapterType: "paperclip_runner" },
|
|
})).toMatchObject({ kind: "native", profile: { backend: "codex_app_server" } });
|
|
expect(resolveNativeRuntimeMode({
|
|
...eligible,
|
|
issue: { id: "ask-issue", workMode: "ask" },
|
|
agent: { ...eligible.agent, adapterType: "codex_local" },
|
|
})).toEqual(expect.objectContaining({ kind: "legacy", reason: "direct_adapter" }));
|
|
});
|
|
});
|
|
|
|
const compatibilityInput = {
|
|
persisted: { runtimeMode: "legacy", runtimeModeResolvedAt: null },
|
|
enabled: true,
|
|
adapterConfig: { provider: "codex" },
|
|
agentStatus: "running",
|
|
issue: { workMode: "standard" },
|
|
executionTarget: { kind: "local" },
|
|
} as const;
|
|
|
|
describe("resolveHeartbeatRuntimeMode compatibility", () => {
|
|
it("keeps every direct built-in adapter on the legacy path", () => {
|
|
for (const adapterType of BUILTIN_ADAPTER_TYPES) {
|
|
if (adapterType === "paperclip_runner") continue;
|
|
expect(resolveHeartbeatRuntimeMode({
|
|
...compatibilityInput,
|
|
adapterType,
|
|
})).toEqual({
|
|
kind: "legacy",
|
|
resolverVersion: "paperclip-runner-v1",
|
|
reason: "direct_adapter",
|
|
});
|
|
}
|
|
});
|
|
|
|
it("preserves the original public result and error contracts", () => {
|
|
expect(resolveHeartbeatRuntimeMode({
|
|
...compatibilityInput,
|
|
adapterType: "paperclip_runner",
|
|
})).toEqual({
|
|
kind: "native",
|
|
resolverVersion: "paperclip-runner-v1",
|
|
reason: "explicit_paperclip_runner",
|
|
provider: "codex",
|
|
});
|
|
expect(resolveHeartbeatRuntimeMode({
|
|
...compatibilityInput,
|
|
enabled: false,
|
|
adapterType: "paperclip_runner",
|
|
persisted: { runtimeMode: "native", runtimeModeResolvedAt: new Date() },
|
|
})).toEqual({
|
|
kind: "native",
|
|
resolverVersion: "paperclip-runner-v1",
|
|
reason: "persisted_native_selection",
|
|
provider: "codex",
|
|
});
|
|
expect(() => resolveHeartbeatRuntimeMode({
|
|
...compatibilityInput,
|
|
enabled: false,
|
|
adapterType: "paperclip_runner",
|
|
})).toThrow(NativeRunnerSelectionError);
|
|
});
|
|
});
|