Files
PaperClipAI/server/src/services/native-runtime/remote-provider-pack.ts
T
DottaandPaperclip 1ad5dd9dce fix(runner): preserve admitted remote provider pack across reattach and relaunch (#22850)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - Native Paperclip Runner executes remote OpenCode and ACPX sessions
in sandbox environments backed by immutable image provider packs and
durable session state
> - When a remote run reattaches, relaunches a settled runner, or
resumes a warm runner after a controller restart or deploy on an
ephemeral server, `prepareRemoteRunnerAssets` rejected the sandbox's
immutable image pack with `exact_identity` and then probed a
non-existent workspace-staged `provider-pack` path, failing with
`exitCode=127` (`No such file or directory`)
> - This happened for two reasons: the reattach/warm-recovery branch
skipped the `artifactStorage && providerArtifacts` fast path used during
cold startup, and when local `provider-pack-authority.json` was absent
(`ENOENT`), the controller fell back to its newer bundled manifest
instead of re-pinning against the durable verified admission receipt in
PostgreSQL
> - When an immutable image pack genuinely failed compatibility and no
workspace-staged pack existed, swallowing the rejection also masked the
real `exact_identity` or interface failure behind `exitCode=127`
> - This pull request aligns reattach and warm-recovery provider-pack
preparation with durable artifact storage and verified DB admission
receipts while keeping all integrity and confinement checks fail-closed
> - The benefit is reliable mid-run reattach, settled-runner relaunch,
and warm-session recovery across deploys without sacrificing
pack-identity verification

## Linked Issues or Issue Description

**What happened?**

During remote `reattach_remote_runner` or `remoteWarmRecovery` (for
example after a hard controller restart or deploy on an ephemeral
server), `prepareRemoteRunnerAssets` failed with
`runner_remote_provider_artifact_incompatible: provider pack
verification failed (exitCode=127;
.../.paperclip-runtime/paperclip-runner/provider-pack/node_modules/node/bin/node:
No such file or directory)` right after `provider_pack.compatibility`
logged `installation_unprotected` on `workspace` and `exact_identity` on
`image`.

**Expected behavior**

A reattach, settled-runner relaunch, or warm recovery on a reused
sandbox must preserve the admitted provider pack:
1. When an OpenCode session already has durable
`nativeProviderArtifacts`, reattach/relaunch must restore that admitted
artifact bundle using any immutable image pack's `node` executable as
bootstrap instead of demanding an exact-identity match on
`/opt/paperclip-runner/provider-pack`.
2. When ephemeral local `provider-pack-authority.json` is absent
(`ENOENT`) after a controller restart or deploy, the controller must
re-pin an OS-protected immutable image pack whose self-sealed manifest
cryptographically matches the verified `nativeProviderPackAdmission`
receipt stored in PostgreSQL for that exact `(companyId, agentId, runId,
sessionId, runnerInstanceId, environmentLeaseId)`.
3. When no valid receipt matches (or the installed pack genuinely
mismatches), reattach must fail closed with a permanent
`runner_remote_provider_artifact_incompatible` error that preserves the
real `failureCheck` (such as `exact_identity`) instead of masking it
behind `exitCode=127` on a missing workspace path.

**Steps to reproduce**

1. Start a remote native OpenCode or ACPX session in a sandbox whose
immutable `/opt/paperclip-runner/provider-pack` was built from an
earlier revision than the replacement controller's bundled manifest (so
no workspace-staged `.paperclip-runtime/paperclip-runner/provider-pack`
exists).
2. Restart or deploy the controller onto a fresh ephemeral filesystem
(so local `provider-pack-authority.json` is absent) while durable
`nativeProviderArtifacts` or a verified `nativeProviderPackAdmission`
receipt exists in PostgreSQL.
3. Reattach or relaunch the settled remote runner
(`reattach_remote_runner`) or recover the warm runner
(`remoteWarmRecovery`). On unfixed `master`, `prepareRemoteRunnerAssets`
rejects `/opt/paperclip-runner/provider-pack` with `exact_identity` and
fails with `exitCode=127` on the missing workspace path.

**Paperclip version or commit**

Reproduced on `origin/master` (`fb900bf0fe`).

## What Changed

- **`server/src/services/native-runtime/remote-provider-pack.ts`**:
- Added `verifiedProviderPackAdmissionReceipt()` to strictly validate a
PostgreSQL `nativeProviderPackAdmission` receipt and its `verified`
admission state against exact `(companyId, agentId, runId, sessionId,
runnerInstanceId, environmentLeaseId)` and digest/revision formats.
- Added `isMissingProviderPackBinaryError()` to identify only
`exitCode=127` `pack_verifier_failed` errors from a missing staged
`node` binary without matching exit-code-3 verification failures or
transient unavailability errors.
-
**`server/src/services/native-runtime/remote-provider-pack-verification.ts`**:
- Extended `verifyRemoteProviderPack` / `compatibleInstallation` with an
optional `admittedReceipt` (honored only when `requireExactIdentity` is
true). It continues to enforce `immutable === true`, root match, schema,
self-sealed `manifest_digest`, target, `pins.opencode`, all artifact
paths/SHA-256 formats, and ACPX agent profile presence while requiring
exact cryptographic match to `providerPackDigest`,
`opencodeProxySha256`, and `sourceRevision`.
- **`server/src/services/native-runtime/native-session-executor.ts`**
*(kept minimal by placing pure validation helpers in
`remote-provider-pack.ts` and `remote-provider-pack-verification.ts`,
since `native-session-executor.ts` already exceeds 1,000 lines)*:
- Added the `if (artifactStorage && providerArtifacts)` fast path to the
`reattach_remote_runner || remoteWarmRecovery` branch of
`prepareRemoteRunnerAssets` (matching cold preparation) and recovered
session `providerArtifacts` via `recordedSessionProviderArtifacts` when
relaunching a settled runner (`!adoptedProcess`).
- Tracked when `selectProviderPackAuthority` fell back to
`resolveCurrentProviderPackManifest()` on local `ENOENT`, loaded the
verified DB admission receipt in `useInstalledProviderPack()`
(supporting both same-run `providerPackAdmissionSource` and prior-run
`remoteWarmRecovery` receipts), and re-bound in-memory
`providerPackAuthority` to the verified manifest while preserving
`runnerArtifact`.
- Surfaced immutable-pack incompatibility rejections when
workspace-staged pack verification fails with `exitCode=127`, while
preserving valid workspace-staged packs and real verification errors
from tampered workspace packs.
- Hardened the `bootstrap` immutable-pack lookup in
`prepareRemoteRunner` to require a valid `nodeCommand.path`.
- **Tests (`native-session-executor.test.ts`,
`remote-provider-pack.test.ts`,
`remote-provider-pack-verification.test.ts`)**:
- Added red-green behavioral regressions (with sandbox path confinement)
covering durable `providerArtifacts` settled-runner relaunch with a
different image pack, mid-run deploy DB receipt recovery for both
OpenCode and ACPX (`claude`), `remoteWarmRecovery` prior-run DB receipt
recovery, and negative fail-closed integrity checks (`exact_identity`
mismatch, `pending`/`unknown`/`wrong-lease`/`missing` receipts,
unprotected `immutable: false` packs, valid and tampered
workspace-staged packs).

## Verification

- **Red -> Green proof**:
- Before production edits, `pnpm --filter @paperclipai/server exec
vitest run src/services/native-runtime/native-session-executor.test.ts
-t "remote provider pack reattach and relaunch after deploy or restart"`
failed 8/9 cases with verbatim
`runner_remote_provider_artifact_incompatible: provider pack
verification failed (exitCode=127; timedOut=false; signal=none; env:
'/workspace/.paperclip-runtime/paperclip-runner/provider-pack/node_modules/node/bin/node':
No such file or directory)`.
  - After the fix (commit `e2e7138024`):
    - `npx tsc --noEmit -p server/tsconfig.json`: passed (0 errors).
- `pnpm --filter @paperclipai/server exec vitest run
src/services/native-runtime/native-session-executor.test.ts -t "remote
provider pack reattach and relaunch after deploy or restart|uses the
bundled Linux image authority|relaunches|reattach"`: **112/112 passed**.
- `pnpm --filter @paperclipai/server exec vitest run
src/services/native-runtime/remote-provider-pack.test.ts
src/services/native-runtime/remote-provider-pack-verification.test.ts
src/services/native-runtime/remote-provider-pack-authority.test.ts
src/services/native-runtime/native-artifact-preparation.test.ts
src/services/native-runtime/native-provider-pack-admission.test.ts
src/services/native-runtime/provider-pack-selection-harness.test.ts`:
**190/190 passed**.
- `pnpm verify --explain`: selects `2375/2735` Vitest files due to
transitive imports of `native-session-executor.ts`; required CI covers
the full repository matrix.
- **Verification environment & limits**:
- Verified locally with unit/behavioral Vitest suites simulating sandbox
confinement and immutable/writable pack inventories on macOS
(`fb900bf0fe` + `e2e7138024`). Live Daytona sandbox reattach after a
staging deploy is not exercised locally and awaits post-merge
deployment.

## Risks

- **Previous-release & upgrade safety**: State saved by prior releases
carries forward cleanly — runs with local
`provider-pack-authority.json`, durable `nativeProviderArtifacts`, or a
verified PostgreSQL `nativeProviderPackAdmission` receipt re-pin to
their exact admitted pack across mid-run deploys. Runs with none of
those receipts remain at the current-release exact-identity gate and
fail closed with permanent
`runner_remote_provider_artifact_incompatible` (`failureCheck:
"exact_identity"`), leaving saved session/checkpoint/workspace state
intact.
- **Security boundary**: `admittedReceipt` is only consulted when
`requireExactIdentity` is true and local authority fell back on
`ENOENT`, and only for OS-protected (`immutable: true`) installations
whose self-sealed manifest digest matches the DB receipt's SHA-256
digest and exact run/session/runner/lease binding. Unprotected
(`immutable: false`), unverified (`pending`/`unknown`), or mismatched
packs continue to fail closed.
- **Overall risk**: Low to medium — scoped strictly to remote
provider-pack verification on `reattach_remote_runner` and
`remoteWarmRecovery`; cold launch and local execution paths are
unchanged.

## Model Used

- Gemini 4 Neon (`gemini-4-neon-high`), via Antigravity agent with tool
use (file inspection/editing, git worktree isolation, Vitest and
TypeScript 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
- [ ] All Paperclip CI gates are green
- [ ] 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>
2026-11-25 04:44:10 -06:00

293 lines
14 KiB
TypeScript

import { redactSensitiveText } from "../../redaction.js";
import { nativeRunFailureCheck, type NativeRunTrace } from "./native-run-trace.js";
import { ANTIGRAVITY_DISTRIBUTION_PINS, COPILOT_CLOSURE_SHA256, type NativeExecutionInput } from "../../vendor/paperclip-runner/index.js";
/** Qualified ACPX releases carry their Linux image manifest and daemon. */
export function shouldUseBundledAcpxImageAssets(input: {
requiresRemoteProviderPack: boolean;
configuredProviderPackRoot: string | null;
provider: NativeExecutionInput["provider"];
}): boolean {
return input.requiresRemoteProviderPack && !input.configuredProviderPackRoot &&
input.provider.kind === "acpx" &&
["cursor", "copilot", "kimi", "antigravity"].includes(input.provider.agent);
}
/**
* The patched Antigravity closure (never the vendor closure) this server
* release admits per platform. It is read from the Runner's generated pins, so
* re-pinning the closure in antigravity-distributions.json can never leave a
* stale server copy; a test keeps it equal to the `verified-closure` platforms.
*/
export const ANTIGRAVITY_PATCHED_CLOSURE_SHA256: Readonly<Record<string, string>> = Object.freeze(
Object.fromEntries(Object.entries(ANTIGRAVITY_DISTRIBUTION_PINS).map(([target, pin]) => [target, pin.closureSha256])),
);
export type ProviderPackEntry = { version: string; profileDigest: string; closureDigest: string };
/**
* The image pack contract for Antigravity. While the profile is pending the
* entry lives only under `candidateProviders`; after the flip only under
* `providers`. It targets Linux x64 and pins this release's profile and the
* patched closure. Returns null when admitted, else a refusal reason.
*/
export function antigravityProviderPackEntryRefusal(input: {
inventory: "providers" | "candidateProviders";
target: { platform: string; architecture: string };
inBoth: boolean;
entry: ProviderPackEntry;
releasePending: boolean;
profile: { agentServerVersion: string; commandDigest: string };
patchedClosures?: Readonly<Record<string, string>>;
}): string | null {
const expectedInventory = input.releasePending ? "candidateProviders" : "providers";
if (input.inventory !== expectedInventory || input.inBoth) return "Antigravity is listed under the wrong pack inventory";
if (input.target.platform !== "linux" || input.target.architecture !== "x64") return "Antigravity pack target must be linux-x64";
const closure = (input.patchedClosures ?? ANTIGRAVITY_PATCHED_CLOSURE_SHA256)["linux-x64"];
if (!closure || input.entry.closureDigest !== `sha256:${closure}`) return "Antigravity closure is not this release's patched closure";
if (input.entry.version !== input.profile.agentServerVersion || input.entry.profileDigest !== input.profile.commandDigest) {
return "Antigravity profile does not match this release";
}
return null;
}
type ProviderPackProfile = { agentServerVersion: string; commandDigest: string };
/** The provider identities one server release admits in a remote pack. */
export type RemoteProviderPackRelease = {
profiles: {
cursor: ProviderPackProfile;
copilot: ProviderPackProfile;
kimi: ProviderPackProfile & { qualificationStatus?: string };
antigravity: ProviderPackProfile;
};
cursorClosures: Readonly<Record<string, { closureSha256: string }>>;
kimiLinuxX64Closure: string;
antigravityReleasePending: boolean;
antigravityPatchedClosures?: Readonly<Record<string, string>>;
};
/** Copilot's pinned closure per platform: the Runner's canonical pins. */
export const COPILOT_PROVIDER_PACK_CLOSURES: Readonly<Record<string, string>> = COPILOT_CLOSURE_SHA256;
/**
* The complete expectation for one provider entry of a remote pack: which
* inventory may list it, its qualification, asset path, digests, and the
* release's profile and closure for the pack target. Returns null when the
* entry is admitted, else the refusal reason.
*/
export function remoteProviderPackEntryRefusal(input: {
provider: string;
inventory: "providers" | "candidateProviders";
allowedProviders: readonly string[];
target: { platform: string; architecture: string };
entry: unknown;
/** Whether the provider is listed in each inventory of the same pack. */
listed: { providers: boolean; candidateProviders: boolean };
release: RemoteProviderPackRelease;
}): string | null {
const { provider, inventory, target, release } = input;
const entry = input.entry as Record<string, unknown> | null | undefined;
const kimiPending = release.profiles.kimi.qualificationStatus === "pending";
const qualified = ["pi", "cursor"].includes(provider) || inventory === "providers" && (provider === "copilot" || provider === "kimi" && !kimiPending
|| provider === "antigravity" && !release.antigravityReleasePending);
if (!input.allowedProviders.includes(provider) || !entry || typeof entry !== "object"
|| Object.keys(entry).some(key => !["version", "profileDigest", "closureDigest", "qualification", "path", "sha256"].includes(key))
|| entry.qualification !== (qualified ? "qualified" : "pending") || entry.path !== `provider-assets/${provider}/${target.platform}-${target.architecture}`
|| typeof entry.version !== "string" || !entry.version || entry.version.length > 120
|| !/^sha256:[a-f0-9]{64}$/.test(String(entry.profileDigest))
|| !/^sha256:[a-f0-9]{64}$/.test(String(entry.closureDigest))
|| !/^sha256:[a-f0-9]{64}$/.test(String(entry.sha256))) {
return "invalid candidate identity";
}
const identity = entry as ProviderPackEntry;
const platform = `${target.platform}-${target.architecture}`;
const matches = (profile: ProviderPackProfile, closure: string | undefined) => closure !== undefined
&& identity.version === profile.agentServerVersion && identity.profileDigest === profile.commandDigest && identity.closureDigest === `sha256:${closure}`;
if (provider === "cursor") {
const closure = Object.hasOwn(release.cursorClosures, platform) ? release.cursorClosures[platform]!.closureSha256 : undefined;
if (!matches(release.profiles.cursor, closure)) return "Cursor profile or closure does not match this release";
}
if (provider === "copilot") {
const closure = Object.hasOwn(COPILOT_PROVIDER_PACK_CLOSURES, platform) ? COPILOT_PROVIDER_PACK_CLOSURES[platform] : undefined;
if ((input.listed.providers && input.listed.candidateProviders) || !matches(release.profiles.copilot, closure)) {
return "Copilot profile or closure does not match this release";
}
}
if (provider === "kimi") {
if (inventory !== (kimiPending ? "candidateProviders" : "providers") || input.listed[kimiPending ? "providers" : "candidateProviders"]
|| platform !== "linux-x64" || !matches(release.profiles.kimi, release.kimiLinuxX64Closure)) {
return "Kimi profile or closure does not match this release";
}
}
if (provider === "antigravity") {
return antigravityProviderPackEntryRefusal({ inventory, target, entry: identity,
inBoth: input.listed.providers && input.listed.candidateProviders,
releasePending: release.antigravityReleasePending, profile: release.profiles.antigravity,
patchedClosures: release.antigravityPatchedClosures });
}
return null;
}
/** A run may adopt a same-content pack from another build only when no saved or operator-selected identity binds it. */
export function providerPackProvenanceReuseAllowed(input: {
retainProviderPack: boolean;
explicitProviderPackSelection: boolean;
authoritySelectable: boolean;
}): boolean {
return !input.retainProviderPack && !input.explicitProviderPackSelection && input.authoritySelectable;
}
type VerificationCommandResult = {
exitCode: number | null;
timedOut: boolean;
signal?: string | null;
stdout: string;
stderr: string;
};
/** Retry only these read-only probes, never provider work or artifact mutations.
* Each transport call enforces its own 30s timeout; two attempts is the hard cap.
* A completed, failing verifier is incompatible. An interrupted probe proves no
* incompatibility. Exhaustion holds the original run: reattachment does not
* spend a new provider attempt, so scheduling another attach could loop.
*/
export async function runRemoteProviderVerification(
execute: () => Promise<VerificationCommandResult>,
label: string,
): Promise<VerificationCommandResult> {
let diagnostic = "command unavailable";
for (let attempt = 1; attempt <= 2; attempt += 1) {
if (attempt > 1) await new Promise<void>(resolve => setTimeout(resolve, 1_000));
let result: VerificationCommandResult;
try {
result = await execute();
} catch (error) {
if (error instanceof Error && error.name === "AbortError") throw error;
diagnostic = redactSensitiveText(error instanceof Error ? error.message : String(error)).slice(-1_024);
continue;
}
diagnostic = `exitCode=${result.exitCode}; timedOut=${result.timedOut}; signal=${result.signal ?? "none"}; ${redactSensitiveText([result.stderr, result.stdout].filter(Boolean).join("\n")).trim().slice(-1_024)}`;
if (result.timedOut || result.exitCode === null || result.signal) continue;
if (result.exitCode !== 0) {
throw new Error(`runner_remote_provider_artifact_incompatible: ${label} failed (${diagnostic})`);
}
return result;
}
throw new Error(`runner_remote_provider_verification_unavailable: ${label} unavailable after 2 verification attempts (${diagnostic.slice(-1_536)})`);
}
/** Reuse only a pack that passes the same full verification as a new upload. */
export async function prepareVerifiedRemoteProviderPack(input: {
trace?: NativeRunTrace;
verifyStaged: () => Promise<void>;
usePreinstalled: (onRejected: (check: string) => void) => Promise<boolean>;
stageAndVerify: () => Promise<void>;
}): Promise<"staged" | "preinstalled" | "uploaded"> {
const scope = input.trace?.start("provider_pack.select");
let failed = false;
let preinstalledCheck = "no_preinstalled_pack";
const select = async () => {
try {
await input.verifyStaged();
return "staged" as const;
} catch {}
let rejected = false;
if (await input.usePreinstalled(check => { if (!rejected) preinstalledCheck = check; rejected = true; })) return "preinstalled" as const;
await input.stageAndVerify();
return "uploaded" as const;
};
try {
const source = scope ? await input.trace!.run(scope, select) : await select();
if (scope) input.trace!.annotate(scope, { stateSource: source,
reason: source === "uploaded" ? "cached_packs_unverified" : "verified_pack_reused",
...(source === "uploaded" ? { check: preinstalledCheck } : {}) });
return source;
} catch (error) {
failed = true;
throw error;
} finally {
if (scope) await input.trace!.end(scope, { outcome: failed ? "failed" : "ok" });
}
}
export async function useVerifiedPreinstalledRemoteProviderPack(input: {
candidates: readonly string[];
verifyAndLink: (root: string) => Promise<void>;
onRejected?: (check: string) => void;
}): Promise<boolean> {
for (const candidate of input.candidates) {
try {
await input.verifyAndLink(candidate);
return true;
} catch (error) {
input.onRejected?.(nativeRunFailureCheck(error) ?? "verification_failed");
}
}
return false;
}
const ADMISSION_DIGEST_RE = /^sha256:[a-f0-9]{64}$/;
const ADMISSION_REVISION_RE = /^[a-f0-9]{40}$/;
const ADMISSION_EPOCH_RE = /^[a-f0-9-]{36}$/;
const ADMISSION_RECEIPT_KEYS = new Set([
"schema", "stage", "authority", "companyId", "agentId", "runId", "sessionId", "runnerInstanceId",
"runnerEnvironmentLeaseId", "providerPackDigest", "opencodeProxySha256", "sourceRevision", "inheritedFromRunId",
]);
/**
* Validates a DB-persisted provider-pack admission receipt and its verified
* state against the exact execution identity so ephemeral controllers can
* re-pin an immutable image pack after losing local authority files.
*/
export function verifiedProviderPackAdmissionReceipt(input: {
receipt: unknown;
state: unknown;
companyId: string;
agentId: string;
runId: string;
sessionId: string;
runnerInstanceId: string;
environmentLeaseId: string;
}): { providerPackDigest: string; opencodeProxySha256: string; sourceRevision: string } | null {
if (!input.state || typeof input.state !== "object" || Array.isArray(input.state)) return null;
const state = input.state as Record<string, unknown>;
if (Object.keys(state).sort().join(",") !== "admissionEpoch,schema,state"
|| state.schema !== "paperclip.native-provider-pack-admission-state.v1"
|| state.state !== "verified"
|| typeof state.admissionEpoch !== "string" || !ADMISSION_EPOCH_RE.test(state.admissionEpoch)) {
return null;
}
if (!input.receipt || typeof input.receipt !== "object" || Array.isArray(input.receipt)) return null;
const receipt = input.receipt as Record<string, unknown>;
if (Object.keys(receipt).some(key => !ADMISSION_RECEIPT_KEYS.has(key))
|| receipt.schema !== "paperclip.native-provider-pack-admission.v1"
|| receipt.stage !== "session_admitted"
|| receipt.authority !== "core_verified_selection"
|| receipt.companyId !== input.companyId
|| receipt.agentId !== input.agentId
|| receipt.runId !== input.runId
|| receipt.sessionId !== input.sessionId
|| receipt.runnerInstanceId !== input.runnerInstanceId
|| receipt.runnerEnvironmentLeaseId !== input.environmentLeaseId
|| typeof receipt.providerPackDigest !== "string" || !ADMISSION_DIGEST_RE.test(receipt.providerPackDigest)
|| typeof receipt.opencodeProxySha256 !== "string" || !ADMISSION_DIGEST_RE.test(receipt.opencodeProxySha256)
|| typeof receipt.sourceRevision !== "string" || !ADMISSION_REVISION_RE.test(receipt.sourceRevision)
|| (receipt.inheritedFromRunId !== undefined && (typeof receipt.inheritedFromRunId !== "string" || !receipt.inheritedFromRunId))) {
return null;
}
return {
providerPackDigest: receipt.providerPackDigest,
opencodeProxySha256: receipt.opencodeProxySha256,
sourceRevision: receipt.sourceRevision,
};
}
/** True only when pack verification failed because the staged pack's node executable was absent (exitCode=127). */
export function isMissingProviderPackBinaryError(error: unknown): boolean {
if (!(error instanceof Error)) return false;
return error.message.startsWith("runner_remote_provider_artifact_incompatible:")
&& nativeRunFailureCheck(error) === "pack_verifier_failed"
&& error.message.includes("exitCode=127;");
}