mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-04 02:32:07 +01:00
## Thinking Path > - Paperclip manages agents and their work. > - Native Runner must bind each provider turn to the selected task, account, model, and instructions. > - Antigravity needs native ACP admission and physical process ownership across continuation. > - A saved conversation must not reuse an old process owner or silently switch its effective model. > - This pull request adds the native candidate behind exact operator admission. > - The default release gate remains closed while qualification is pending. ## Linked Issues or Issue Description Builds on merged #18187. Product account setup and the candidate producer are in dependent #18189. The repeatable browser journey is in #18190. Refs: #12503, #14938; those proposals use legacy CLI adapters. **Agent or provider** Google Antigravity ACP 1.4.3. **Why this adapter is useful** Users need to set up an Antigravity agent and run real work through their managed Google subscription. **How the agent is invoked** Native Paperclip Runner uses the pinned Antigravity ACP runtime. Exact operator admission is required while qualification remains pending. ## What Changed - Add native Antigravity ACP model and instruction admission, selected-account homes, and fenced refresh ownership. - Carry exact candidate authority from the control plane through Runner, Rust, the sidecar, and each current run. Clamp daemon lifetime to the absolute permission expiry, including replacement owners. - Preserve a rotated OAuth refresh token before later identity verification can fail, including failed or cancelled startup admission. Make private lease-close retries safe. - Bound native probe retirement and retry the exact original owner; do not delete credential homes before physical proof. - Preserve Gemini API-key recovery when shared Google subscription capability is added. - Resume the same tagged native conversation with fresh per-turn process ownership and physical native retirement. - Include native manifests in isolated Rust image stages, release cache keys, and dev rebuild detection. The workflow changes only extend existing cache input lists. - Keep current master provider behavior and append Grok 13, Pi 35, and Copilot 84 input identities. Preserve prior identities, including saved Copilot 82 and 83 runs. ## Verification - Runner TypeScript main checks, profile generators, Rust formatting, and offline workspace checks pass. The native backend integration target passes 28 tests. - The complete transport and cleanup group passes 387 tests without unhandled rejections. These checks use local scripted children and actual process and port ownership. - Saved-profile decoding, native-execution parsing, installation, and selected-credential controls pass 208 focused tests. All 109 pre-existing profile identity files remain byte-for-byte unchanged. Copilot, Grok, and shared TypeScript/Rust generation checks pass. - The final recovery fixture passes all seven cases. After the master rebase, the combined recovery and owned-Node-runtime group passes all 10 cases. Each expiry case sets one 45-second absolute grant before startup. It includes the deliberate six-second cold delay, four existing eight-second command budgets, and active-turn headroom. The test proves an active turn before expiry and then checks the daemon, owned process group, child processes, and all three native port fences. The 60-second test deadline does not renew provider authority. - The consolidated model-discovery and pending-release group passes 22 tests. Google credential compatibility and auth recovery pass 25 tests, including existing Gemini API-key recovery. The full product settings test group remains intact in #18189. - Earlier failures remain in their original CI runs and local records. They exposed the Copilot 82 decoder gap, an expired five-second fixture bootstrap ticket, and a fixture grant consumed before activation on loaded CI. Each repair has a separate result. Production ticket limits and admission behavior are unchanged by the final test commits. - An unrelated decision-expiry check failed in [the earlier CI run](https://github.com/paperclipai/paperclip/actions/runs/40941986698/job/123688668997). Its owning code is unchanged from the base. The unchanged suite passes 20 tests on isolated PostgreSQL. A controlled database rollback reproduces the earlier wake: clean startup schedules the 120-second decision expiry, while rollback reconciliation leaves a 30-second continuation-coalescing wake. The decision stays open, with no wake delivery or error. The fresh final-head server shard passes; the failed result is preserved. - Final native commit `ec6bc7e4d77f5ae0cc4946dbba6c662e95a87f5b` passed `ci / verify` and `ci / e2e`. Fresh Greptile and Paperclip reviews both score 5/5, with no open findings. Antigravity retains the recorded native `.5` closure and exact low-model profile. This PR does not claim global or cross-platform qualification. ## Risks - The new transport carries private managed credentials. Exact ownership, account generation, model, instructions, and native retirement are fail-closed. - Only local macOS ARM64 has a verified complete Antigravity runtime. Default Antigravity task execution remains disabled without current trusted operator admission. The Google server sign-in lane and production candidate producer ship in #18189; this native slice does not expose the subscription catalog choice. - Shared launch inputs change provider identities. New identities are append-only; existing recorded identities remain available. ## Model Used OpenAI Codex (GPT-6). The host did not expose the exact model revision or context limit. The model used tools for code edits, tests, and review. ## 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>
270 lines
11 KiB
TypeScript
270 lines
11 KiB
TypeScript
export type PaperclipRunnerProvider =
|
|
"codex" | "opencode" | "claude_managed" | "aws_agentcore" | "acpx" | "openai_dot" | "grok_bot" | "muse";
|
|
|
|
export type CodexPermissionMode = "never" | "on-request" | "untrusted";
|
|
export type OpenCodePermissionMode = "allow" | "ask" | "deny";
|
|
export type AcpxPermissionMode = "approve-all" | "approve-paperclip" | "approve-reads" | "deny-all";
|
|
|
|
export type PaperclipRunnerPermissionMode =
|
|
CodexPermissionMode | OpenCodePermissionMode | AcpxPermissionMode;
|
|
|
|
export const PAPERCLIP_RUNNER_IDLE_TIMEOUT_DEFAULT_MS = 300_000;
|
|
export const PAPERCLIP_RUNNER_IDLE_TIMEOUT_MAX_MS = 86_400_000;
|
|
export const PAPERCLIP_RUNNER_DEFAULT_MODELS = {
|
|
codex: "gpt-5.6-sol",
|
|
acpx: "claude-opus-5-5",
|
|
opencode: "openrouter/deepseek/deepseek-v4-flash-0731",
|
|
} as const;
|
|
|
|
export interface PaperclipRunnerPermissionOption<
|
|
TMode extends string = string,
|
|
> {
|
|
value: TMode;
|
|
label: string;
|
|
description: string;
|
|
}
|
|
|
|
export type PaperclipRunnerPermissionCapability =
|
|
| {
|
|
configurable: true;
|
|
configKey:
|
|
"codexPermissionMode" | "opencodePermissionMode" | "acpxPermissionMode";
|
|
defaultMode: PaperclipRunnerPermissionMode;
|
|
options: readonly PaperclipRunnerPermissionOption<PaperclipRunnerPermissionMode>[];
|
|
description: string;
|
|
}
|
|
| {
|
|
configurable: false;
|
|
defaultMode: "provider-managed";
|
|
options: readonly [];
|
|
description: string;
|
|
};
|
|
|
|
/**
|
|
* Control-plane catalog for Paperclip Runner permission UX and validation.
|
|
* Runtime contracts validate the same native values again at the process
|
|
* boundary; this catalog must remain browser-safe.
|
|
*/
|
|
export const PAPERCLIP_RUNNER_PERMISSION_CAPABILITIES = {
|
|
codex: {
|
|
configurable: true,
|
|
configKey: "codexPermissionMode",
|
|
defaultMode: "never",
|
|
// `never` disables provider approval pauses; it does not disable the
|
|
// runner's independent security boundary. Native Codex may use this mode
|
|
// only through the root-denied, workspace-scoped, network-disabled, and
|
|
// environment-allowlisted profile assembled by codex-security-config.ts.
|
|
description:
|
|
"Codex runs automatically inside a root-denied, workspace-scoped, network-disabled Paperclip environment.",
|
|
options: [
|
|
{
|
|
value: "never",
|
|
label: "Automatic (isolated)",
|
|
description:
|
|
"Run without Codex approval pauses while Paperclip keeps its independent workspace, network, and environment restrictions.",
|
|
},
|
|
],
|
|
},
|
|
opencode: {
|
|
configurable: true,
|
|
configKey: "opencodePermissionMode",
|
|
defaultMode: "allow",
|
|
description:
|
|
"Controls OpenCode tool permissions inside the assigned Paperclip environment.",
|
|
options: [
|
|
{
|
|
value: "allow",
|
|
label: "Full auto (allow)",
|
|
description: "Allow OpenCode operations without approval pauses.",
|
|
},
|
|
{
|
|
value: "ask",
|
|
label: "Ask for permission",
|
|
description: "Prompt before protected OpenCode operations.",
|
|
},
|
|
{
|
|
value: "deny",
|
|
label: "Deny operations",
|
|
description: "Reject protected OpenCode operations.",
|
|
},
|
|
],
|
|
},
|
|
claude_managed: {
|
|
configurable: false,
|
|
defaultMode: "provider-managed",
|
|
options: [],
|
|
description:
|
|
"Claude Managed runs non-interactively under its qualified provider profile and Paperclip policy.",
|
|
},
|
|
aws_agentcore: {
|
|
configurable: false,
|
|
defaultMode: "provider-managed",
|
|
options: [],
|
|
description:
|
|
"AWS AgentCore runs non-interactively under its qualified harness profile and Paperclip policy.",
|
|
},
|
|
grok_bot: { configurable: false, defaultMode: "provider-managed", options: [], description: "Grok Bot uses first-party Paperclip tools and retains its native apps. Grok manages its model; spending, live steering, provider transcript streaming and remote interruption are unavailable." },
|
|
muse: { configurable: false, defaultMode: "provider-managed", options: [], description: "Muse uses the admitted Paperclip tool catalog and its own approved tools. Provider usage is unavailable and remote stop is best effort." },
|
|
openai_dot: { configurable: false, defaultMode: "provider-managed", options: [], description: "Dot uses the admitted Paperclip tool catalog. OpenAI manages its model and other tools; provider usage and global interruption are unavailable." },
|
|
acpx: {
|
|
configurable: true,
|
|
configKey: "acpxPermissionMode",
|
|
defaultMode: "approve-all",
|
|
description:
|
|
"Controls ACPX agent operations inside the assigned Paperclip environment.",
|
|
options: [
|
|
{
|
|
value: "approve-all",
|
|
label: "Full auto (approve all)",
|
|
description: "Approve ACPX operations without approval pauses.",
|
|
},
|
|
{
|
|
value: "approve-paperclip",
|
|
label: "Automatic Paperclip actions",
|
|
description:
|
|
"Automatically run assigned Paperclip planning and task tools, including reassignment. Company permissions and approval requirements still apply. Other operations require permission.",
|
|
},
|
|
{
|
|
value: "approve-reads",
|
|
label: "Allow Paperclip reads",
|
|
description:
|
|
"Automatically allow assigned Paperclip read tools. Other operations request a supported permission decision. Company permissions and execution boundaries still apply.",
|
|
},
|
|
{
|
|
value: "deny-all",
|
|
label: "Deny all",
|
|
description: "Reject harness permission requests.",
|
|
},
|
|
],
|
|
},
|
|
} as const satisfies Record<
|
|
PaperclipRunnerProvider,
|
|
PaperclipRunnerPermissionCapability
|
|
>;
|
|
|
|
export function isPaperclipRunnerProvider(
|
|
value: unknown,
|
|
): value is PaperclipRunnerProvider {
|
|
return (
|
|
value === "codex" ||
|
|
value === "opencode" ||
|
|
value === "claude_managed" ||
|
|
value === "aws_agentcore" ||
|
|
value === "acpx" || value === "openai_dot" || value === "grok_bot" || value === "muse"
|
|
);
|
|
}
|
|
|
|
export function resolvePaperclipRunnerPermissionMode(
|
|
provider: PaperclipRunnerProvider,
|
|
value: unknown,
|
|
): PaperclipRunnerPermissionMode | "provider-managed" {
|
|
const capability = PAPERCLIP_RUNNER_PERMISSION_CAPABILITIES[provider];
|
|
if (!capability.configurable) return capability.defaultMode;
|
|
return capability.options.some((option) => option.value === value)
|
|
? (value as PaperclipRunnerPermissionMode)
|
|
: capability.defaultMode;
|
|
}
|
|
|
|
/** Native session behavior is independent of tool permission policy. */
|
|
export function resolvePaperclipRunnerCursorMode(
|
|
provider: unknown,
|
|
agent: unknown,
|
|
value: unknown,
|
|
): "agent" | "plan" | "ask" | undefined {
|
|
if (provider !== "acpx" || agent !== "cursor") {
|
|
if (value !== undefined) throw new Error("acpxSessionMode is supported only for Cursor");
|
|
return undefined;
|
|
}
|
|
if (value === undefined) return "agent";
|
|
if (value === "agent" || value === "plan" || value === "ask") return value;
|
|
throw new Error("Cursor session mode must be agent, plan, or ask");
|
|
}
|
|
|
|
export function resolvePaperclipRunnerModel(
|
|
provider: keyof typeof PAPERCLIP_RUNNER_DEFAULT_MODELS,
|
|
value: unknown,
|
|
): string {
|
|
return typeof value === "string" && value.trim().length > 0
|
|
? value.trim()
|
|
: PAPERCLIP_RUNNER_DEFAULT_MODELS[provider];
|
|
}
|
|
|
|
export function resolvePaperclipRunnerIdleTimeoutMs(value: unknown): number {
|
|
return typeof value === "number" &&
|
|
Number.isSafeInteger(value) &&
|
|
value > 0 &&
|
|
value <= PAPERCLIP_RUNNER_IDLE_TIMEOUT_MAX_MS
|
|
? value
|
|
: PAPERCLIP_RUNNER_IDLE_TIMEOUT_DEFAULT_MS;
|
|
}
|
|
|
|
/** Defaults for converting a local adapter; the operator may override the provider. */
|
|
export function paperclipRunnerTransitionConfig(
|
|
previousAdapterType: string,
|
|
previousModel: unknown,
|
|
providerOverride?: unknown,
|
|
): Record<string, unknown> {
|
|
const previousProvider =
|
|
(["claude_local", "pi_local", "grok_local"].includes(previousAdapterType))
|
|
? "acpx"
|
|
: previousAdapterType === "opencode_local"
|
|
? "opencode"
|
|
: "codex";
|
|
const provider =
|
|
providerOverride === "codex" ||
|
|
providerOverride === "opencode" ||
|
|
providerOverride === "acpx"
|
|
? providerOverride
|
|
: previousProvider;
|
|
return {
|
|
provider,
|
|
model: provider === "acpx" && previousAdapterType === "grok_local"
|
|
? typeof previousModel === "string" && previousModel.trim() && previousModel.trim() !== "grok-build" ? previousModel.trim() : "grok-4.7"
|
|
: provider === "acpx" && previousAdapterType === "pi_local"
|
|
? typeof previousModel === "string" ? previousModel.trim() : ""
|
|
: resolvePaperclipRunnerModel(
|
|
provider,
|
|
provider === previousProvider ? previousModel : undefined,
|
|
),
|
|
...(provider === "acpx" ? { acpxAgent: previousAdapterType === "grok_local" ? "grok" : previousAdapterType === "pi_local" ? "pi" : "claude" } : {}),
|
|
[PAPERCLIP_RUNNER_PERMISSION_CAPABILITIES[provider].configKey]:
|
|
PAPERCLIP_RUNNER_PERMISSION_CAPABILITIES[provider].defaultMode,
|
|
lifecycleMode: "per_turn",
|
|
};
|
|
}
|
|
|
|
/** Old ACPX Codex agent settings use native Codex on their next configuration write. */
|
|
export function normalizeLegacyRunnerProvider(
|
|
config: Record<string, unknown>,
|
|
): Record<string, unknown> {
|
|
if (config.provider !== "acpx" || config.acpxAgent !== "codex") return config;
|
|
const {
|
|
acpxAgent: _agent,
|
|
acpxPermissionMode: _permission,
|
|
...rest
|
|
} = config;
|
|
return { ...rest, provider: "codex", codexPermissionMode: "never" };
|
|
}
|
|
|
|
/** Qualification is a release property, never an operator-configurable bypass. */
|
|
export const PAPERCLIP_RUNNER_ACPX_PROFILES = Object.freeze([
|
|
{ value: "grok", label: "Grok Build", qualified: true, credentialEnvironment: ["XAI_API_KEY"] },
|
|
{ value: "claude", label: "Claude", qualified: true, credentialEnvironment: ["ANTHROPIC_API_KEY", "CLAUDE_CODE_OAUTH_TOKEN"] },
|
|
{ value: "cursor", label: "Cursor", qualified: true, credentialEnvironment: ["CURSOR_API_KEY", "CURSOR_AUTH_TOKEN"] },
|
|
{ value: "copilot", label: "GitHub Copilot", qualified: true, credentialEnvironment: ["COPILOT_GITHUB_TOKEN"] },
|
|
{ value: "pi", label: "Pi", qualified: true, credentialEnvironment: ["OPENROUTER_API_KEY", "OPENAI_API_KEY", "ANTHROPIC_API_KEY", "GEMINI_API_KEY"] },
|
|
{ value: "antigravity", label: "Google Antigravity", qualified: false, credentialEnvironment: ["GEMINI_API_KEY"] },
|
|
] as const);
|
|
|
|
/** Exact Pi native thinking levels; aliases that silently clamp are not configuration. */
|
|
export type PaperclipRunnerPiThinkingLevel = "off" | "low" | "high" | "max";
|
|
export function resolvePaperclipRunnerPiThinkingLevel(provider: unknown, agent: unknown, value: unknown): PaperclipRunnerPiThinkingLevel | undefined {
|
|
if (provider !== "acpx" || agent !== "pi") {
|
|
if (value !== undefined) throw new Error("piThinkingLevel is supported only for Pi");
|
|
return undefined;
|
|
}
|
|
if (value === undefined) return "low";
|
|
if (value === "off" || value === "low" || value === "high" || value === "max") return value;
|
|
throw new Error("Pi thinking level must be off, low, high, or max");
|
|
}
|