fix(runtime): persist managed Runner credential refreshes across execution targets (#20580)

This commit is contained in:
Nicky Leach authored and GitHub committed 2026-11-10 10:15:29 -08:00
1 parent 85dec04677
commit 17136a6c25
23 files changed
+883 -238

No files matched your search

@@ -4,7 +4,7 @@ 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,
type DurablePrpControlPlane, type RunnerExecutionDriver, type RunnerLaunchPreparer, type DurableRecoveryIdentity } from "../../vendor/paperclip-runner/index.js";
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";
@@ -43,6 +43,7 @@ export function createPluginRunnerTaskOwner(input: {
accountIdentity?: string;
credential?: PluginEnvironmentTaskCredential;
onCredentials?: (credential: PluginEnvironmentTaskCredential) => Promise<void>;
onCredentialsUpdated?: (event: PrpEvent) => Promise<void>;
onSessionRetained?: (state: Record<string, unknown>) => Promise<void>;
onDispatched?: () => Promise<void> | void;
pollMs?: number;
@@ -421,6 +422,8 @@ export function createPluginRunnerTaskOwner(input: {
return result.outcome;
};
return { launcher, registration, driver, readWorkspaceFile, release, resume,
// A warm transport outlives its first lease and invocation's private home.
credentialsUpdated: async (event: PrpEvent) => { await input.onCredentialsUpdated?.(event); },
// This is a lease-bound Launcher receipt, not a terminal phase or a sent
// stop request. Completion also proves credential/writeback obligations ran.
isRetired: () => stoppedState?.executionStopped === true && completed && !detached,