diff --git a/packages/paperclip-runner/src/index.ts b/packages/paperclip-runner/src/index.ts index 1362b860048..9f93fe24866 100644 --- a/packages/paperclip-runner/src/index.ts +++ b/packages/paperclip-runner/src/index.ts @@ -137,7 +137,7 @@ export { RunnerdDotDriver, type RunnerdDotDriverOptions } from "./drivers/dot/ru export type { RunnerExecutionDriver } from "./control-plane/runner-execution-driver.js"; -export { RUNNER_GITHUB_LAUNCHER_VERSION, bindRunnerLaunchResources, createRunnerProviderLaunch, runnerProviderLaunchRequirements, runnerLaunchRequirementsDigest, validatePreparedRunnerLaunch } from "./live/runner-provider-launch.js"; +export { RUNNER_GITHUB_LAUNCHER_VERSION, bindRunnerLaunchResources, createRunnerProviderLaunch, runnerProviderLaunchRequirements, runnerLaunchPreparationDigest, runnerLaunchRequirementsDigest, runnerLaunchRunDigest, validatePreparedRunnerLaunch } from "./live/runner-provider-launch.js"; export type { RunnerProviderLaunchRequirements, RunnerProviderLaunchEnvironment, PreparedRunnerProviderLaunch, RunnerLaunchPreparer } from "./live/runner-provider-launch.js"; export { resolveGrokDisableWebSearch } from "./drivers/acpx/grok-web-search.js"; diff --git a/packages/paperclip-runner/src/live/runner-launch-preparation.test.ts b/packages/paperclip-runner/src/live/runner-launch-preparation.test.ts index 53ec6a9d828..f091b4ad685 100644 --- a/packages/paperclip-runner/src/live/runner-launch-preparation.test.ts +++ b/packages/paperclip-runner/src/live/runner-launch-preparation.test.ts @@ -1,7 +1,7 @@ import { createHash } from "node:crypto"; import { canonicalNativeRuntimeContextDigest, composeNativeSystemInstructions, NATIVE_RUNTIME_ASSET_SCHEMA } from "../contracts/runtime-context.js"; import { describe, expect, it } from "vitest"; -import { bindRunnerLaunchResources, createRunnerProviderLaunch, runnerLaunchRequirementsDigest, runnerProviderLaunchRequirements, +import { bindRunnerLaunchResources, createRunnerProviderLaunch, runnerLaunchPreparationDigest, runnerLaunchRequirementsDigest, runnerLaunchRunDigest, runnerProviderLaunchRequirements, validatePreparedRunnerLaunch, type RunnerProviderLaunchRequirements } from "./runner-provider-launch.js"; const identity = { runnerInstanceId: "runner", environmentLeaseId: "lease", runId: "run", @@ -96,3 +96,83 @@ describe("environment-owned launch contract", () => { } }); }); + +describe("launch preparation and run digests", () => { + const nextRun = { ...identity, runId: "next-run", turnId: "next-turn", itemId: "next-item" }; + const withIdentity = (value: typeof identity) => ({ ...requirements(), identity: value }); + + it("keeps the preparation digest across runs of one Runner and changes the run digest", () => { + const first = runnerLaunchPreparationDigest(requirements()); + expect(runnerLaunchPreparationDigest(withIdentity(nextRun))).toBe(first); + expect(first).toMatch(/^sha256:[a-f0-9]{64}$/); + expect(first).not.toBe(runnerLaunchRequirementsDigest(requirements())); + const run = runnerLaunchRunDigest(first, withIdentity(identity)); + expect(run).toMatch(/^sha256:[a-f0-9]{64}$/); + expect(runnerLaunchRunDigest(first, withIdentity(nextRun))).not.toBe(run); + expect(runnerLaunchRunDigest(first, withIdentity({ ...identity, itemId: "other-item" }))).not.toBe(run); + expect(runnerLaunchRunDigest(first, withIdentity(identity))).toBe(run); + }); + + const zero = "0".repeat(64); + const one = "1".repeat(64); + type Context = NonNullable; + const baseContext = (): Omit => ({ + prompt: { revision: "fixture", text: "Core policy", digest: createHash("sha256").update("Core policy").digest("hex") }, + instructions: { entryPath: "AGENTS.md", bundle: { schema: NATIVE_RUNTIME_ASSET_SCHEMA, + rootPath: "/controller/instructions", digest: zero, manifestDigest: zero, fileCount: 1, totalBytes: 1 } }, + skills: [{ key: "assigned", runtimeName: "assigned", versionId: "v1", bundle: { + schema: NATIVE_RUNTIME_ASSET_SCHEMA, rootPath: "/controller/skill", digest: zero, manifestDigest: zero, fileCount: 1, totalBytes: 1 } }], + mcp: { assignmentSetId: "assigned", digest: zero, bindingId: "native-mcp:run" }, + }); + const withContext = (value: typeof identity, change: (context: Omit) => void = () => {}): RunnerProviderLaunchRequirements => { + const context = baseContext(); + change(context); + return { ...requirements(), identity: value, runtimeContext: { ...context, aggregateDigest: canonicalNativeRuntimeContextDigest(context) } }; + }; + + // MCP reaches the Runner through Core's tool authority on every run attachment, never through files the environment + // publishes, and Core keeps a warm session across an MCP-only change. So MCP belongs to the run digest only. + it("keeps the preparation digest across warm runs whose runtime context changes only in MCP", () => { + const first = withContext(identity); + const digest = runnerLaunchPreparationDigest(first); + const mcpChanges: Array<[string, RunnerProviderLaunchRequirements]> = [ + ["the run's binding", withContext(nextRun, context => { context.mcp.bindingId = "native-mcp:next-run"; })], + ["no binding", withContext(nextRun, context => { context.mcp.bindingId = null; })], + ["the assigned access set", withContext(nextRun, context => { context.mcp = { assignmentSetId: "other-set", digest: one, bindingId: "native-mcp:next-run" }; })], + ]; + for (const [label, next] of mcpChanges) { + expect(runnerLaunchPreparationDigest(next), label).toBe(digest); + expect(runnerLaunchRunDigest(digest, next), label).not.toBe(runnerLaunchRunDigest(digest, first)); + } + // Within one run, an MCP change still changes the run digest. + const sameRun = withContext(identity, context => { context.mcp.assignmentSetId = "other-set"; }); + expect(runnerLaunchRunDigest(digest, sameRun)).not.toBe(runnerLaunchRunDigest(digest, first)); + }); + + it.each([ + ["instruction bundle", (context: Omit) => { context.instructions.bundle.digest = one; }], + ["instruction entry", (context: Omit) => { context.instructions.entryPath = "CLAUDE.md"; }], + ["skill bundle", (context: Omit) => { context.skills[0]!.bundle.digest = one; }], + ["skill set", (context: Omit) => { context.skills = []; }], + ["instruction working copy", (context: Omit) => { + context.instructions.workingCopy = { rootPath: "/workspace/.paperclip-runtime/agent-files/agent/run", entryPath: "AGENTS.md", kind: "agent_files" }; }], + ["connection instructions", (context: Omit) => { context.connectionInstructions = { text: "Use the connector.", digest: one }; }], + ])("changes the preparation digest when the %s changes", (_label, change) => { + expect(runnerLaunchPreparationDigest(withContext(identity, change))).not.toBe(runnerLaunchPreparationDigest(withContext(identity))); + }); + + it.each([ + ["runner instance", withIdentity({ ...identity, runnerInstanceId: "other-runner" })], + ["environment lease", withIdentity({ ...identity, environmentLeaseId: "other-lease" })], + ["session", withIdentity({ ...identity, normalizedSessionId: "other-session" })], + ["instructions", { ...requirements(), instructions: "Changed instructions" }], + ["model", { ...requirements(), model: "other-model" }], + ["approval policy", { ...requirements(), approvalPolicy: "never" as const }], + ["settings", { ...requirements(), settings: { ...requirements().settings, disableCodexWebSearch: true } }], + ])("changes the preparation digest when the %s changes", (_label, changed) => { + const before = runnerLaunchPreparationDigest(requirements()); + const after = runnerLaunchPreparationDigest(changed as RunnerProviderLaunchRequirements); + expect(after).not.toBe(before); + expect(runnerLaunchRunDigest(after, withIdentity(identity))).not.toBe(runnerLaunchRunDigest(before, withIdentity(identity))); + }); +}); diff --git a/packages/paperclip-runner/src/live/runner-provider-launch.ts b/packages/paperclip-runner/src/live/runner-provider-launch.ts index cff4b9a4154..c224a665536 100644 --- a/packages/paperclip-runner/src/live/runner-provider-launch.ts +++ b/packages/paperclip-runner/src/live/runner-provider-launch.ts @@ -93,13 +93,51 @@ export function bindRunnerLaunchResources( }; } -export function runnerLaunchRequirementsDigest(requirements: RunnerProviderLaunchRequirements): string { - const canonical = JSON.stringify(requirements, (_key, value: unknown) => - value && typeof value === "object" && !Array.isArray(value) - ? Object.fromEntries(Object.entries(value).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0)) : value); +function canonicalDigest(value: unknown): string { + const canonical = JSON.stringify(value, (_key, entry: unknown) => + entry && typeof entry === "object" && !Array.isArray(entry) + ? Object.fromEntries(Object.entries(entry).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0)) : entry); return `sha256:${createHash("sha256").update(canonical).digest("hex")}`; } +export function runnerLaunchRequirementsDigest(requirements: RunnerProviderLaunchRequirements): string { + return canonicalDigest(requirements); +} + +/** + * The launch requirements an environment reconciles when it prepares a Runner: the runner, lease and session identity, + * provider, model and settings, the prompt and instruction text, and the runtime context's instruction and skill + * bundles, working copy and connection instructions. It leaves out what names one run (the run, turn and item ids) and + * the runtime context's MCP assignment and binding: MCP reaches the Runner through Core's tool authority on every run + * attachment, never through files the environment publishes, and Core already continues a warm session across an + * MCP-only change (`nativeRuntimeContextsMatch` with tool refresh). The context's `aggregateDigest` is left out with it, + * since it hashes the MCP assignment and every other field it covers is in this digest directly. + */ +export function runnerLaunchPreparationDigest(requirements: RunnerProviderLaunchRequirements): string { + const { runId: _runId, turnId: _turnId, itemId: _itemId, ...identity } = requirements.identity; + let runtimeContext: Omit | null = null; + if (requirements.runtimeContext) { + const { mcp: _mcp, aggregateDigest: _aggregateDigest, ...prepared } = requirements.runtimeContext; + runtimeContext = prepared; + } + return canonicalDigest({ schema: "paperclip.runner.launch-preparation-digest.v1", requirements: { ...requirements, identity, runtimeContext } }); +} + +/** + * The preparation digest plus everything it leaves out: the run, turn and item ids, and the MCP assignment and binding. + * It is unique to one run's launch. + */ +export function runnerLaunchRunDigest(preparationDigest: string, requirements: { + identity: Pick; + runtimeContext: Pick | null; +}): string { + const { identity } = requirements; + const mcp = requirements.runtimeContext?.mcp; + return canonicalDigest({ schema: "paperclip.runner.launch-run-digest.v1", preparationDigest, + runId: identity.runId, turnId: identity.turnId, itemId: identity.itemId, + mcp: mcp ? { assignmentSetId: mcp.assignmentSetId, digest: mcp.digest, bindingId: mcp.bindingId } : null }); +} + function runnerLaunchPolicy(requirements: RunnerProviderLaunchRequirements): Record { return createRunnerProviderLaunch(requirements, { options: { codexArgs: [] }, root: "/", cwd: "/", codexHome: "/", diff --git a/packages/plugins/sdk/src/environment-tasks.ts b/packages/plugins/sdk/src/environment-tasks.ts index e1f22476d4d..e1b60f9b279 100644 --- a/packages/plugins/sdk/src/environment-tasks.ts +++ b/packages/plugins/sdk/src/environment-tasks.ts @@ -95,6 +95,8 @@ export const environmentTaskOperationSchema = z.discriminatedUnion("kind", [ githubBroker: githubBroker.optional(), recovery: preparedLaunch.optional(), resumeFrom: providerId.optional(), priorIdentity: durableIdentity.optional(), accountIdentity: z.string().min(1).max(1024).optional(), + preparationDigest: z.string().regex(/^sha256:[a-f0-9]{64}$/).optional(), + runDigest: z.string().regex(/^sha256:[a-f0-9]{64}$/).optional(), projectIds: z.array(z.string().uuid()).max(64).refine(ids => new Set(ids).size === ids.length, "Duplicate project IDs"), }).strict(), z.object({ @@ -206,6 +208,7 @@ export const environmentTaskResultSchema = z.discriminatedUnion("kind", [ githubCredentialBrokerVersion: z.literal(1).optional(), configuredEnvironmentVersion: z.literal(1).optional(), resumeLaunchInputsVersion: z.literal(1).optional(), + launchDigestVersion: z.literal(1).optional(), }).strict(), z.object({ kind: z.literal("status"), taskId: providerId, diff --git a/server/src/__tests__/environment-task-runtime.test.ts b/server/src/__tests__/environment-task-runtime.test.ts index 968b51c38ac..68e1df593b0 100644 --- a/server/src/__tests__/environment-task-runtime.test.ts +++ b/server/src/__tests__/environment-task-runtime.test.ts @@ -5,6 +5,7 @@ import { environmentTaskErrorCodeData, environmentTaskOperationSchema, parseEnvi readEnvironmentTaskErrorCode, readEnvironmentTaskErrorDiagnostic } from "@paperclipai/plugin-sdk"; import { executeEnvironmentTask, isSettledReadyRunnerState, settleDispatchedEnvironmentTask } from "../services/environment-task-runtime.js"; import { NativeExecutionContext } from "../services/native-runtime/native-execution-context.js"; +import { runnerLaunchPreparationDigest, runnerLaunchRunDigest } from "../vendor/paperclip-runner/index.js"; const state = vi.hoisted(() => ({ plugin: {} as any, release: vi.fn(), identity: vi.fn(), config: vi.fn() })); vi.mock("../services/provider-fresh-workspace.js", () => ({ @@ -344,6 +345,33 @@ describe("plugin-provided Runner execution", () => { await expect(executeEnvironmentTask(database(row(), []).db, denied as never, { companyId: "company", leaseId, operation })).rejects.toThrow("project unavailable"); expect(denied.call).not.toHaveBeenCalled(); }); + it("accepts prepare launch digests only when they match the requirements", async () => { + const operation = { kind: "prepare" as const, projectIds: [projectId], requirements: { + schema: "paperclip.runner.launch-requirements.v1" as const, + identity: { runnerInstanceId: "runner", environmentLeaseId: leaseId, runId: "run", + normalizedSessionId: "session", turnId: "turn", itemId: "item" }, + provider: "codex" as const, model: "selected", instructions: "Core instructions", runtimeContext: null, + settings: {}, approvalPolicy: "on-request" as const, readOnly: false, + preparedConversation: false, includeCollaborationModeInstructions: true, + } }; + const preparationDigest = runnerLaunchPreparationDigest(operation.requirements); + const runDigest = runnerLaunchRunDigest(preparationDigest, operation.requirements); + const result = { kind: "prepared", taskId: "attempt-1", launch: { configurationId: "configuration-1", + requirementsDigest: `sha256:${"a".repeat(64)}`, provider: { kind: "codex" } } }; + const accepted = worker(result); + await expect(executeEnvironmentTask(database().db, accepted as never, { companyId: "company", leaseId, + operation: { ...operation, preparationDigest, runDigest } })).resolves.toEqual(result); + expect(accepted.call).toHaveBeenCalledWith("original", "environmentTask", expect.objectContaining({ + operation: expect.objectContaining({ preparationDigest, runDigest }) }), 15_000); + const forged = `sha256:${"b".repeat(64)}`; + for (const digests of [{ preparationDigest: forged, runDigest }, { preparationDigest, runDigest: forged }, + { preparationDigest }, { runDigest }]) { + const refused = worker(result); + await expect(executeEnvironmentTask(database().db, refused as never, { companyId: "company", leaseId, + operation: { ...operation, ...digests } })).rejects.toThrow("launch digest mismatch"); + expect(refused.call).not.toHaveBeenCalled(); + } + }); it.each([[false, false], [true, false], [false, true], [true, true]])("prepares scoped configuration with submit-time auth %s and in-prepare auth %s", async (atSubmit, checked) => { const operation = { kind: "prepare" as const, projectIds: [projectId], requirements: { schema: "paperclip.runner.launch-requirements.v1" as const, diff --git a/server/src/services/environment-task-runtime.ts b/server/src/services/environment-task-runtime.ts index 5e3b9abeb4a..d656c547113 100644 --- a/server/src/services/environment-task-runtime.ts +++ b/server/src/services/environment-task-runtime.ts @@ -18,6 +18,7 @@ import type { PluginWorkerManager } from "./plugin-worker-manager.js"; import { NativeExecutionContext } from "./native-runtime/native-execution-context.js"; import { assertPluginTaskSourceAttachment, assertPluginTaskSourceRecovery } from "./native-runtime/plugin-task-source-recovery.js"; import { pluginAgentRuntimeIdentity } from "./plugin-agent-runtime-state.js"; +import { runnerLaunchPreparationDigest, runnerLaunchRunDigest } from "../vendor/paperclip-runner/index.js"; import { assertPluginTaskOwnershipDispatch, PluginTaskOwnershipPendingError, readyPortableTaskSource, reconcilePluginTaskAdmission } from "./plugin-task-ownership.js"; export type PluginTaskDescription = Extract; @@ -61,6 +62,12 @@ export async function executeEnvironmentTask(db: Db, workers: Pick { const operation = environmentTaskOperationSchema.parse(input.operation); + if (operation.kind === "prepare" && (operation.preparationDigest !== undefined || operation.runDigest !== undefined)) { + const preparationDigest = runnerLaunchPreparationDigest(operation.requirements as Parameters[0]); + if (operation.preparationDigest !== preparationDigest || operation.runDigest !== runnerLaunchRunDigest(preparationDigest, operation.requirements as Parameters[1])) { + throw new Error("Plugin Runner launch digest mismatch"); + } + } const [row] = await db.select({ lease: environmentLeases, environment: environments, run: heartbeatRuns }) .from(environmentLeases) .leftJoin(environments, eq(environments.id, environmentLeases.environmentId)) diff --git a/server/src/services/native-runtime/native-session-executor.ts b/server/src/services/native-runtime/native-session-executor.ts index 4ce52dac51f..adb11edef8b 100644 --- a/server/src/services/native-runtime/native-session-executor.ts +++ b/server/src/services/native-runtime/native-session-executor.ts @@ -16657,6 +16657,7 @@ async function createRunnerdBackendWithinSessionClaim( configuredEnvironment: taskConfiguredEnvironment, releaseResumeVersion: description.releaseResumeVersion, resumeLaunchInputsVersion: description.resumeLaunchInputsVersion, + launchDigestVersion: description.launchDigestVersion, authorityRunId: description.releaseResumeVersion === 1 ? input.execution.binding.runId : undefined, releasedSource: input.remoteWarmRecovery?.releasedSource, sessionHandoff: !!input.remoteWarmRecovery?.portableSourceTaskId, diff --git a/server/src/services/native-runtime/plugin-runner-task.test.ts b/server/src/services/native-runtime/plugin-runner-task.test.ts index 873c958eb32..9cea18965be 100644 --- a/server/src/services/native-runtime/plugin-runner-task.test.ts +++ b/server/src/services/native-runtime/plugin-runner-task.test.ts @@ -1,7 +1,7 @@ import { createHash } from "node:crypto"; import { describe, expect, it, vi } from "vitest"; import type { RunnerProviderLaunchRequirements } from "@paperclipai/paperclip-runner"; -import type { RunnerProcessLaunchSpec } from "../../vendor/paperclip-runner/index.js"; +import { runnerLaunchPreparationDigest, runnerLaunchRunDigest, type RunnerProcessLaunchSpec } from "../../vendor/paperclip-runner/index.js"; import { createPluginRunnerTaskOwner } from "./plugin-runner-task.js"; import { NativeExecutionContext } from "./native-execution-context.js"; @@ -831,6 +831,39 @@ it.each(["codex", "claude"])("reuses a warm %s process across run authorities wi expect(nextTask.mock.calls.filter(([op])=>op.kind==="stop")).toHaveLength(1); }); +it.each([ + ["advertised", 1 as const], + ["not advertised", undefined], +] as const)("launch digests are sent on prepare only when the plugin has %s them", async (_label, version) => { + const {task} = provider(); + ingress.connect.mockReturnValue({ready:Promise.resolve(),close:async()=>{}}); + const input = {taskId:"task",task,projectIds:[],harness:"codex",projectAuthCheckVersion:1 as const,warmTaskVersion:1 as const, + accountIdentity:"account",credentialIdentity:"revision",pollMs:1,launchDigestVersion:version}; + const owner = createPluginRunnerTaskOwner(input); + await prepare(owner, launchRequirements("codex")); + const registration = await owner.registration({} as never,"run"); + const spec = launchSpec(); spec.nativeRunner!.lifecyclePolicy = {mode:"warm",idleTimeoutMs:300000}; + const handle = owner.launcher(spec); registration.activate(); await registration.ready(); + const nextIdentity={...requirements.identity,runId:"next-run",turnId:"next-turn",itemId:"next-item"}; + const nextRegistration=await owner.registration({} as never,"next-run"); + await owner.driver.prepareLaunch!({...launchRequirements("codex"),identity:nextIdentity}); + const prepares=task.mock.calls.map(([op])=>op).filter(op=>op.kind==="prepare"); + expect(prepares).toHaveLength(2); + if (version === 1) { + const [first, next] = prepares as Array<{preparationDigest?:string;runDigest?:string}>; + expect(first.preparationDigest).toBe(runnerLaunchPreparationDigest(launchRequirements("codex"))); + expect(next.preparationDigest).toBe(first.preparationDigest); + expect(first.runDigest).toBe(runnerLaunchRunDigest(first.preparationDigest!, launchRequirements("codex"))); + expect(next.runDigest).toBe(runnerLaunchRunDigest(first.preparationDigest!, {...launchRequirements("codex"),identity:nextIdentity})); + expect(next.runDigest).not.toBe(first.runDigest); + } else { + for (const op of prepares) expect(op).not.toHaveProperty("preparationDigest"); + for (const op of prepares) expect(op).not.toHaveProperty("runDigest"); + } + await registration.release(); nextRegistration.activate(); await nextRegistration.ready(); + await nextRegistration.release(); await nextRegistration.checkpoint("settled"); await handle.completion; +}); + it.each([ ["checked inside prepare", true, ["prepare"]], ["left to Core", false, ["prepare", "check_project_auth"]], diff --git a/server/src/services/native-runtime/plugin-runner-task.ts b/server/src/services/native-runtime/plugin-runner-task.ts index ba566839390..b67c03c7608 100644 --- a/server/src/services/native-runtime/plugin-runner-task.ts +++ b/server/src/services/native-runtime/plugin-runner-task.ts @@ -3,7 +3,7 @@ import { createHash } from "node:crypto"; import { setTimeout as delay } from "node:timers/promises"; import { environmentTaskOperationSchema, environmentTaskResultSchema, parseEnvironmentTaskResult, type PluginEnvironmentTaskOperation, type PluginEnvironmentTaskResult, type PluginEnvironmentTaskCredential } from "@paperclipai/plugin-sdk"; import type { RunnerIngressEndpoint } from "@paperclipai/adapter-utils/runner-connectivity"; -import { RUNNER_PRP_PROTOCOL_MIN, RUNNER_PRP_PROTOCOL_MAX, type RunnerProcessHandle, type RunnerProcessLaunchSpec, +import { RUNNER_PRP_PROTOCOL_MIN, RUNNER_PRP_PROTOCOL_MAX, runnerLaunchPreparationDigest, runnerLaunchRunDigest, type RunnerProcessHandle, type RunnerProcessLaunchSpec, type DurablePrpControlPlane, type RunnerExecutionDriver, type RunnerLaunchPreparer, type DurableRecoveryIdentity, type PrpEvent } from "../../vendor/paperclip-runner/index.js"; import { connectRunnerPrpIngress } from "../../realtime/runner-prp-outbound.js"; import type { NativeExecutionContext } from "./native-execution-context.js"; @@ -50,6 +50,7 @@ export function createPluginRunnerTaskOwner(input: { warmTaskVersion?: 1; releaseResumeVersion?: 1; resumeLaunchInputsVersion?: 1; + launchDigestVersion?: 1; releasedSource?: DurableRecoveryIdentity; sessionHandoff?: boolean; onResumed?: (identity: DurableRecoveryIdentity) => Promise; @@ -143,7 +144,9 @@ export function createPluginRunnerTaskOwner(input: { if (input.githubBroker && input.githubCredentialBrokerVersion !== 1) { throw new Error("Update the environment plugin to support the GitHub credential broker v1"); } + const preparationDigest = input.launchDigestVersion === 1 ? runnerLaunchPreparationDigest(requirements) : undefined; const result = await call(environmentTaskOperationSchema.parse({ kind: "prepare", requirements, + ...(preparationDigest ? { preparationDigest, runDigest: runnerLaunchRunDigest(preparationDigest, requirements) } : {}), ...(input.githubBroker ? { githubBroker: input.githubBroker } : {}), projectIds: [...input.projectIds], ...(recovery ? { recovery } : {}), ...(input.resumeFrom && (!authorityRunId || !launchIdentity || launchIdentity.runId === authorityRunId || sourceRecovery) diff --git a/server/src/vendor/paperclip-runner/index.ts b/server/src/vendor/paperclip-runner/index.ts index 24bc7363a46..5bf32f2c904 100644 --- a/server/src/vendor/paperclip-runner/index.ts +++ b/server/src/vendor/paperclip-runner/index.ts @@ -107,6 +107,8 @@ export const runnerCodexDynamicToolsFit = runner.runnerCodexDynamicToolsFit; export const admitToolInputSchema = runner.admitToolInputSchema; export const TOOL_INPUT_SCHEMA_MAX_BYTES = runner.TOOL_INPUT_SCHEMA_MAX_BYTES; export const canonicalToolInputSchema = runner.canonicalToolInputSchema; +export const runnerLaunchPreparationDigest = runner.runnerLaunchPreparationDigest; +export const runnerLaunchRunDigest = runner.runnerLaunchRunDigest; export const inspectWarmRunTransition = runner.inspectWarmRunTransition; export const inspectStagedRunAttachment = runner.inspectStagedRunAttachment; export const inspectRetainedRunInstructions = runner.inspectRetainedRunInstructions; diff --git a/tests/runner-e2e/source-sdk-public-inputs.json b/tests/runner-e2e/source-sdk-public-inputs.json index 26c3e22d86e..df9c7b3366f 100644 --- a/tests/runner-e2e/source-sdk-public-inputs.json +++ b/tests/runner-e2e/source-sdk-public-inputs.json @@ -13,7 +13,7 @@ "packages/plugins/sdk/src/environment-stop-error.ts": "b0e03f8aa2b2170ba095da5c7138050fced3f3cb", "packages/plugins/sdk/src/environment-sync-error.ts": "7d6a51a95da49a7da4525aebbab6382dc5c44ae8", "packages/plugins/sdk/src/environment-task-error.ts": "98aae8a06743b38884b68cb9a3ec44c57b34c0e4", - "packages/plugins/sdk/src/environment-tasks.ts": "e1f22476d4d73502bd4dc56afa3f863f3d1a275a", + "packages/plugins/sdk/src/environment-tasks.ts": "e1b60f9b27952079461889760b68ab79987a33a2", "packages/plugins/sdk/src/host-client-factory.ts": "e0301c390ea13f2340b669383f07af2455e48c8a", "packages/plugins/sdk/src/idle-drain.test.ts": "cc59f7881e7d46c89395a1d93d74f6c6b9b0a64a", "packages/plugins/sdk/src/idle-drain.ts": "ae6e4c6be4657a3d541396922b3bc551b8db557f",