From c91ab882781f8a091d0d84708e8297990ea7acd5 Mon Sep 17 00:00:00 2001 From: Codex Date: Thu, 25 Jun 2026 03:20:29 +0000 Subject: [PATCH] fix: render AgentRun tool credential projections --- scripts/src/agentrun.ts | 38 +++++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/scripts/src/agentrun.ts b/scripts/src/agentrun.ts index 392c3caf..dbc4d2da 100644 --- a/scripts/src/agentrun.ts +++ b/scripts/src/agentrun.ts @@ -6377,10 +6377,12 @@ function agentRunAipodBindingDisclosure(task: Record, aipod: st })); const toolCredentials = arrayRecords(secretScope.toolCredentials).map((credential) => ({ tool: credential.tool ?? null, + purpose: credential.purpose ?? null, secretRef: { name: record(credential.secretRef).name ?? null, keys: Array.isArray(record(credential.secretRef).keys) ? record(credential.secretRef).keys : [], }, + projection: record(credential.projection), valuesPrinted: false, })); return { @@ -7295,10 +7297,12 @@ function agentRunExecutionPolicyWithLaneCredentials(basePolicy: Record { +function agentRunToolCredentialRefs(spec: AgentRunLaneSpec, options: { includeUnsupported?: boolean } = {}): Array<{ tool: string; purpose: string; projection: Record; sourceId: string; secretRef: { namespace: string; name: string; key: string }; valuesPrinted: false }> { return spec.secrets .filter((secret) => secret.providerCredentialProfile === null && secret.id.startsWith("tool-")) .map((secret) => { - const tool = secret.id.replace(/^tool-/u, "").replace(/-token$/u, ""); + const binding = agentRunToolCredentialBinding(secret.id, secret.targetRef.key); return { - tool, + tool: binding.tool, + purpose: binding.purpose, + projection: binding.projection, sourceId: secret.id, secretRef: secret.targetRef, valuesPrinted: false as const, }; }) - .filter((credential) => options.includeUnsupported === true || AGENTRUN_DEFAULT_TOOL_CREDENTIALS.has(credential.tool)); + .filter((credential) => options.includeUnsupported === true || AGENTRUN_DEFAULT_TOOL_CREDENTIAL_IDS.has(credential.sourceId)); +} + +function agentRunToolCredentialBinding(sourceId: string, key: string): { tool: string; purpose: string; projection: Record } { + if (sourceId === "tool-github-pr-token") { + return { + tool: "github", + purpose: "github-pr", + projection: { kind: "env", envName: key, secretKey: key }, + }; + } + if (sourceId === "tool-unidesk-ssh-token") { + return { + tool: "unidesk-ssh", + purpose: "ssh-passthrough", + projection: { kind: "env", envName: key, secretKey: key }, + }; + } + return { + tool: sourceId.replace(/^tool-/u, "").replace(/-token$/u, ""), + purpose: sourceId.replace(/^tool-/u, ""), + projection: {}, + }; } function renderAgentRunSessionPolicyExplanation(args: string[] = [], options: AgentRunRestTargetOptions = { node: null, lane: null }): string {