Skip to content

Automate browser based workflows with AI

Show a copilot receipt for a silently auto-bound credential, with Change to correct it (#8065)

Celal Zamanoğlu79242f0830c1
diff --git a/skyvern-frontend/src/routes/workflows/copilot/WorkflowCopilotChat.credentialCard.test.tsx b/skyvern-frontend/src/routes/workflows/copilot/WorkflowCopilotChat.credentialCard.test.tsx
index df3e9608f..c04204b35 100644
--- a/skyvern-frontend/src/routes/workflows/copilot/WorkflowCopilotChat.credentialCard.test.tsx
+++ b/skyvern-frontend/src/routes/workflows/copilot/WorkflowCopilotChat.credentialCard.test.tsx
@@ -342,6 +342,29 @@ const terminalPromptResponse = (turnId = "turn-9") => ({
},
});
+// A turn that silently auto-bound a credential (no ask): carries credentialAutoBound, no prompt/pause.
+const terminalAutoBoundResponse = (turnId = "turn-9") => ({
+ type: "response",
+ workflow_copilot_chat_id: "chat-1",
+ message: "Signing in with your saved credential.",
+ updated_workflow: null,
+ response_time: "2026-07-13T00:00:05Z",
+ proposal_disposition: "no_proposal",
+ turn_id: turnId,
+ narrative_payload: {
+ turnId,
+ turnIndex: 0,
+ mode: "build",
+ responseType: "REPLY",
+ terminal: "response",
+ terminalMessage: "Signing in with your saved credential.",
+ narrativeSummary: "Signing in with your saved credential.",
+ startedAt: "2026-07-13T00:00:00Z",
+ endedAt: "2026-07-13T00:00:05Z",
+ credentialAutoBound: { credentialId: "cred_work", name: "Work login" },
+ },
+});
+
// A pause that engaged but never sent a frame — no card should render.
const terminalDeclinedResponse = (turnId = "turn-7") => ({
type: "response",
@@ -931,6 +954,87 @@ describe("WorkflowCopilotChat — credential card wiring (flag on)", () => {
await screen.findByTestId("mock-create-credential");
expect(modalDefaultTestUrl.current).toBeUndefined();
});
+
+ it("renders the auto-bind receipt from the credentialAutoBound signal", async () => {
+ flagMap.current = { [COPILOT_UX_V1_FLAG]: true };
+ await renderChat();
+ await submit("sign in and grab my dashboard");
+ await waitFor(() => expect(postStreaming).toHaveBeenCalledTimes(1));
+ await act(async () => {
+ streamCalls[0]!.onMessage(turnStart("turn-9"));
+ streamCalls[0]!.onMessage(terminalAutoBoundResponse("turn-9"));
+ streamCalls[0]!.resolve();
+ });
+ expect(
+ await screen.findByText("Using credential 'Work login'"),
+ ).toBeTruthy();
+ });
+
+ it("Change re-picks through the existing terminal-continue path (no third path)", async () => {
+ flagMap.current = { [COPILOT_UX_V1_FLAG]: true };
+ credentialsData.current = [
+ { credential_id: "cred_work", name: "Work login", tested_url: null },
+ {
+ credential_id: "cred_personal",
+ name: "Personal login",
+ tested_url: null,
+ },
+ ];
+ await renderChat();
+ await submit("sign in and grab my dashboard");
+ await waitFor(() => expect(postStreaming).toHaveBeenCalledTimes(1));
+ await act(async () => {
+ streamCalls[0]!.onMessage(turnStart("turn-9"));
+ streamCalls[0]!.onMessage(terminalAutoBoundResponse("turn-9"));
+ streamCalls[0]!.resolve();
+ });
+ expect(
+ await screen.findByText("Using credential 'Work login'"),
+ ).toBeTruthy();
+ // Open the Change picker and pick a different credential.
+ await act(async () => {
+ fireEvent.click(await screen.findByRole("combobox"));
+ });
+ await act(async () => {
+ fireEvent.click(
+ await screen.findByRole("button", { name: "Personal login" }),
+ );
+ });
+ // A fresh turn fires referencing the picked credential by id (the deterministic continue path),
+ // and NOT a typed credential-response POST — the same path a terminal ask pick uses.
+ await waitFor(() => expect(postStreaming).toHaveBeenCalledTimes(2));
+ expect(streamCalls[1]!.body.message).toContain("cred_personal");
+ expect(streamCalls[1]!.body.message).toContain("continue");
+ expect(credentialResponsePosts()).toHaveLength(0);
+ expect(
+ await screen.findByText("Continuing with 'Personal login'…"),
+ ).toBeTruthy();
+ });
+
+ it("defers the auto-bind receipt to a co-occurring credential ask", async () => {
+ flagMap.current = { [COPILOT_UX_V1_FLAG]: true };
+ await renderChat();
+ await submit("sign in to both sites");
+ await waitFor(() => expect(postStreaming).toHaveBeenCalledTimes(1));
+ const base = terminalAutoBoundResponse("turn-9");
+ await act(async () => {
+ streamCalls[0]!.onMessage(turnStart("turn-9"));
+ streamCalls[0]!.onMessage({
+ ...base,
+ narrative_payload: {
+ ...base.narrative_payload,
+ credentialPrompt: { reason: "credential_name_unresolved" },
+ },
+ });
+ streamCalls[0]!.resolve();
+ });
+ // The credential ask owns this turn's credential UI and its credentialResolutions entry; the
+ // auto-bind receipt defers so it can't adopt the ask's resolution.
+ expect(screen.queryByText(/Using credential/)).toBeNull();
+ expect(
+ screen.getByRole("button", { name: "Connect credential" }),
+ ).toBeTruthy();
+ });
});
describe("WorkflowCopilotChat — credential card (flag off parity)", () => {
@@ -947,4 +1051,16 @@ describe("WorkflowCopilotChat — credential card (flag off parity)", () => {
screen.queryByRole("button", { name: "Connect credential" }),
).toBeNull();
});
+
+ it("renders no auto-bind receipt with the flag off", async () => {
+ await renderChat();
+ await submit("sign in and grab my dashboard");
+ await waitFor(() => expect(postStreaming).toHaveBeenCalledTimes(1));
+ await act(async () => {
+ streamCalls[0]!.onMessage(turnStart("turn-9"));
+ streamCalls[0]!.onMessage(terminalAutoBoundResponse("turn-9"));
+ streamCalls[0]!.resolve();
+ });
+ expect(screen.queryByText(/Using credential/)).toBeNull();
+ });
});
diff --git a/skyvern-frontend/src/routes/workflows/copilot/WorkflowCopilotChat.tsx b/skyvern-frontend/src/routes/workflows/copilot/WorkflowCopilotChat.tsx
index f1ea8093a..8e5a9f30f 100644
--- a/skyvern-frontend/src/routes/workflows/copilot/WorkflowCopilotChat.tsx
+++ b/skyvern-frontend/src/routes/workflows/copilot/WorkflowCopilotChat.tsx
@@ -3279,6 +3279,60 @@ export function WorkflowCopilotChat({
/>
);
})()}
+ {(() => {
+ if (
+ isLoadingHistory ||
+ !copilotUxV1Enabled ||
+ turnId === null
+ )
+ return null;
+ const autoBound = message.narrative.credentialAutoBound;
+ // A co-occurring credential ask/pause owns this turn's credential UI and its
+ // credentialResolutions[turnId] entry; the auto-bind receipt would double up and
+ // mis-adopt that ask's resolution, so it defers whenever a card frame exists.
+ if (
+ !autoBound ||
+ credentialCardFrameFor(message.narrative)
+ )
+ return null;
+ // The receipt renders on any message (scrollback-safe). Before a Change it shows
+ // the auto-bound credential with a Change picker; after one, the local resolution
+ // routes into CredentialCard's existing "Continuing with 'X'…" receipt.
+ const localResolution = credentialResolutions[turnId];
+ const canContinue =
+ isLastMessage ||
+ strandedTerminalContinuations.has(turnId);
+ return (
+ <CredentialCard
+ frame={{
+ type: "credential_required",
+ reason: "workflow_credential_inputs_unbound",
+ }}
+ mode="auto-bound"
+ autoBound={autoBound}
+ // Not while a turn is in flight: the shared continue path would still record
+ // an optimistic "connected" even though it suppresses the actual send.
+ canChange={canContinue && !isLoading}
+ reloadKey={credentialsReloadKey}
+ resolvedOutcome={localResolution}
+ continued={Boolean(localResolution?.continued)}
+ // Change re-enters the same terminal-continue path a terminal ask pick uses
+ // (send "Use the credential <id> — continue", or open the add modal). A silent
+ // bind never has a live pause, so never the typed credential-response path.
+ onConnect={(credentialId, name) =>
+ credentialId
+ ? continueAfterTerminalConnect(
+ turnId,
+ credentialId,
+ name ?? localResolution?.name,
+ canContinue,
+ )
+ : openCredentialModal(null, turnId, canContinue)
+ }
+ onSkip={() => {}}
+ />
+ );
+ })()}
</div>
);
}
diff --git a/skyvern-frontend/src/routes/workflows/copilot/cards/CredentialCard.test.tsx b/skyvern-frontend/src/routes/workflows/copilot/cards/CredentialCard.test.tsx
index 7dd6e3aab..c0c8b3874 100644
--- a/skyvern-frontend/src/routes/workflows/copilot/cards/CredentialCard.test.tsx
+++ b/skyvern-frontend/src/routes/workflows/copilot/cards/CredentialCard.test.tsx
@@ -887,3 +887,123 @@ describe("CredentialCard historical (resolvedOutcome) rendering", () => {
).toBeTruthy();
});
});
+
+describe("CredentialCard auto-bound receipt", () => {
+ it("names the silently-bound credential in the receipt", () => {
+ render(
+ <CredentialCard
+ frame={buildCredentialRequiredFrame()}
+ mode="auto-bound"
+ autoBound={{ credentialId: "cred_work", name: "Work login" }}
+ onConnect={vi.fn()}
+ onSkip={vi.fn()}
+ />,
+ );
+ expect(screen.getByText("Using credential 'Work login'")).toBeTruthy();
+ });
+
+ it("offers a Change picker that routes a pick through onConnect (no third path)", async () => {
+ const onConnect = vi.fn();
+ credsData.current = [
+ { credential_id: "cred_work", name: "Work login" },
+ { credential_id: "cred_personal", name: "Personal login" },
+ ];
+ render(
+ <CredentialCard
+ frame={buildCredentialRequiredFrame()}
+ mode="auto-bound"
+ autoBound={{ credentialId: "cred_work", name: "Work login" }}
+ canChange
+ onConnect={onConnect}
+ onSkip={vi.fn()}
+ />,
+ );
+ fireEvent.click(
+ await screen.findByRole("button", { name: "Personal login" }),
+ );
+ expect(onConnect).toHaveBeenCalledWith("cred_personal", "Personal login");
+ });
+
+ it("stays read-only (no Change) on a scrollback turn where change is not live", async () => {
+ credsData.current = [
+ { credential_id: "cred_work", name: "Work login" },
+ { credential_id: "cred_personal", name: "Personal login" },
+ ];
+ render(
+ <CredentialCard
+ frame={buildCredentialRequiredFrame()}
+ mode="auto-bound"
+ autoBound={{ credentialId: "cred_work", name: "Work login" }}
+ canChange={false}
+ onConnect={vi.fn()}
+ onSkip={vi.fn()}
+ />,
+ );
+ // The receipt still names the credential, but a scrollback turn offers no Change picker — a pick
+ // there would optimistically resolve without an actual continuation behind it.
+ expect(screen.getByText("Using credential 'Work login'")).toBeTruthy();
+ expect(screen.queryByRole("combobox")).toBeNull();
+ expect(screen.queryByRole("button", { name: "Change" })).toBeNull();
+ // And a read-only receipt does not fetch the org list at all (no per-scrollback-receipt fetch).
+ expect(getClientMock).not.toHaveBeenCalled();
+ });
+
+ it("hands off to the existing continuing receipt once a change resolves", () => {
+ render(
+ <CredentialCard
+ frame={buildCredentialRequiredFrame()}
+ mode="auto-bound"
+ autoBound={{ credentialId: "cred_work", name: "Work login" }}
+ resolvedOutcome={RESOLVED_OUTCOME_CONNECTED}
+ continued
+ onConnect={vi.fn()}
+ onSkip={vi.fn()}
+ />,
+ );
+ expect(screen.getByText("Continuing with 'HN login'…")).toBeTruthy();
+ expect(screen.queryByText(/Using credential/)).toBeNull();
+ });
+
+ it("offers an add-credential Change when the bound one is the org's only credential", async () => {
+ const onConnect = vi.fn();
+ // No OTHER credential to pick, but a correction must stay reachable — Change falls back to adding a
+ // new credential (onConnect(undefined) opens the add modal), not a redundant re-pick of the bound one.
+ credsData.current = [{ credential_id: "cred_work", name: "Work login" }];
+ render(
+ <CredentialCard
+ frame={buildCredentialRequiredFrame()}
+ mode="auto-bound"
+ autoBound={{ credentialId: "cred_work", name: "Work login" }}
+ canChange
+ onConnect={onConnect}
+ onSkip={vi.fn()}
+ />,
+ );
+ await waitFor(() => expect(getClientMock).toHaveBeenCalled());
+ expect(screen.getByText("Using credential 'Work login'")).toBeTruthy();
+ // A fallback button (not the searchable combobox), routing to the add modal.
+ expect(screen.queryByRole("combobox")).toBeNull();
+ fireEvent.click(screen.getByRole("button", { name: "Change" }));
+ expect(onConnect).toHaveBeenCalledWith(undefined);
+ });
+
+ it("keeps Change reachable when the credential list fails to load", async () => {
+ const onConnect = vi.fn();
+ // A transient /credentials failure leaves the list null; Change must not vanish (alternates may
+ // exist) — it falls back to the add-credential path so the auto-bound pick stays correctable.
+ credsFail.current = true;
+ render(
+ <CredentialCard
+ frame={buildCredentialRequiredFrame()}
+ mode="auto-bound"
+ autoBound={{ credentialId: "cred_work", name: "Work login" }}
+ canChange
+ onConnect={onConnect}
+ onSkip={vi.fn()}
+ />,
+ );
+ await waitFor(() => expect(getClientMock).toHaveBeenCalled());
+ fireEvent.click(await screen.findByRole("button", { name: "Change" }));
+ expect(onConnect).toHaveBeenCalledWith(undefined);
+ });
+});
diff --git a/skyvern-frontend/src/routes/workflows/copilot/cards/CredentialCard.tsx b/skyvern-frontend/src/routes/workflows/copilot/cards/CredentialCard.tsx
index cbfe8411c..1c893e573 100644
--- a/skyvern-frontend/src/routes/workflows/copilot/cards/CredentialCard.tsx
+++ b/skyvern-frontend/src/routes/workflows/copilot/cards/CredentialCard.tsx
@@ -51,7 +51,7 @@ export interface CredentialRequiredFrame {
timestamp?: string;
}
-export type CredentialCardMode = "terminal" | "inline-pause";
+export type CredentialCardMode = "terminal" | "inline-pause" | "auto-bound";
export type CredentialPauseOutcome = "connected" | "skipped" | "timeout";
@@ -86,6 +86,11 @@ export interface CredentialCardProps {
// Bumped by the parent when a credential is created so the one-shot fetch re-runs and the new
// credential shows up in the picker (e.g. if the resume POST failed and the ask is still live).
reloadKey?: number;
+ // "auto-bound" mode only: the credential the turn silently bound, named in the receipt.
+ autoBound?: { credentialId: string; name: string };
+ // "auto-bound" mode only: whether the Change affordance is live (the tail turn). A scrollback
+ // receipt stays read-only so a pick can't optimistically resolve without an actual continuation.
+ canChange?: boolean;
}
const SIGN_IN_WHY_LINE =
@@ -201,6 +206,11 @@ function CredentialPicker({
suggestedIds,
disabled,
onPick,
+ triggerLabel = "Use existing…",
+ triggerClassName = "h-6 w-[200px] justify-between px-3 text-xs font-normal",
+ // Popover content matches the trigger width by default; a content-width trigger (e.g. "Change")
+ // needs an explicit width here or the dropdown collapses to the label and hides its search/rows.
+ contentClassName = "w-[var(--radix-popover-trigger-width)]",
}: {
credentials: PickerCredential[];
// Copilot's suggested candidates for this sign-in (only inline-pause frames carry them; terminal
@@ -208,6 +218,9 @@ function CredentialPicker({
suggestedIds?: string[];
disabled?: boolean;
onPick: (credentialId: string, name: string) => void;
+ triggerLabel?: string;
+ triggerClassName?: string;
+ contentClassName?: string;
}) {
const [open, setOpen] = useState(false);
const suggestedSet = new Set(suggestedIds ?? []);
@@ -245,16 +258,13 @@ function CredentialPicker({
aria-expanded={open}
variant="outline"
disabled={disabled}
- className="h-6 w-[200px] justify-between px-3 text-xs font-normal"
+ className={triggerClassName}
>
- <span className="truncate">Use existing…</span>
+ <span className="truncate">{triggerLabel}</span>
<ChevronDownIcon className="ml-2 size-3 shrink-0 opacity-50" />
</Button>
</PopoverTrigger>
- <PopoverContent
- className="w-[var(--radix-popover-trigger-width)] p-0"
- align="start"
- >
+ <PopoverContent className={`${contentClassName} p-0`} align="start">
<Command>
<CommandInput placeholder="Search credentials..." />
<CommandList>
@@ -286,6 +296,8 @@ export function CredentialCard({
onSkip,
continued = false,
reloadKey,
+ autoBound,
+ canChange = false,
}: Readonly<CredentialCardProps>) {
// Terminal mode never expires by design: its signal carries no timeout/expiry
// semantics at all, so there is nothing to compare "now" against. Only a
@@ -311,8 +323,11 @@ export function CredentialCard({
// page_size 100 with no pagination — a >100-credential org shows only the 100 most-recent; older
// ones are reachable only by creating a new credential. Add the route's `search` param if that bites.
const isAsk = !resolvedOutcome;
+ // An auto-bound receipt only needs the org list when its Change affordance is live; a read-only
+ // scrollback receipt must not each fire its own 100-credential fetch.
+ const needsCredentialList = isAsk && (mode !== "auto-bound" || canChange);
useEffect(() => {
- if (!isAsk) return;
+ if (!needsCredentialList) return;
// Generation guard: a fetch superseded by a reloadKey change (or a slow one) must not set state
// after a newer fetch has started, so a stale response can't overwrite the current list.
const generation = ++fetchGeneration.current;
@@ -342,7 +357,7 @@ export function CredentialCard({
}
}
})();
- }, [isAsk, reloadKey, credentialGetter]);
+ }, [needsCredentialList, reloadKey, credentialGetter]);
if (resolvedOutcome) {
switch (resolvedOutcome.outcome) {
@@ -384,6 +399,52 @@ export function CredentialCard({
}
}
+ if (mode === "auto-bound" && autoBound) {
+ // Change re-picks only OTHER credentials (re-picking the bound one fires a redundant continuation).
+ // When none are pickable yet — list still loading, fetch failed, or the bound one is the org's only
+ // credential — fall back to adding a new credential so a correction is always reachable.
+ const others = (orgCredentials ?? []).filter(
+ (credential) => credential.credentialId !== autoBound.credentialId,
+ );
+ return (
+ <div className="rounded-lg border border-border bg-slate-elevation2 p-3">
+ <div className="flex flex-wrap items-center justify-between gap-2">
+ <div className="flex min-w-0 items-center gap-2 text-xs font-semibold text-foreground">
+ <span aria-hidden="true">🔑</span>
+ <span className="truncate" title={autoBound.name}>
+ Using credential &apos;{autoBound.name}&apos;
+ </span>
+ </div>
+ {canChange ? (
+ others.length > 0 ? (
+ <CredentialPicker
+ credentials={others}
+ onPick={(credentialId, name) => onConnect(credentialId, name)}
+ triggerLabel="Change"
+ triggerClassName="h-6 gap-1 px-2 text-xs font-medium"
+ contentClassName="w-[240px]"
+ />
+ ) : (
+ <Button
+ type="button"
+ variant="outline"
+ onClick={() => onConnect(undefined)}
+ className="h-6 flex-none px-2 text-xs font-medium"
+ >
+ Change
+ </Button>
+ )
+ ) : null}
+ </div>
+ <p className="mt-1 text-xs text-muted-foreground">
+ {canChange
+ ? "Auto-selected to sign in on your behalf — Change it if this isn't right."
+ : "Auto-selected to sign in on your behalf."}
+ </p>
+ </div>
+ );
+ }
+
const site = siteFromLoginPageUrls(frame.login_page_urls);
return (
diff --git a/skyvern-frontend/src/routes/workflows/copilot/narrativeState.credentialPause.test.ts b/skyvern-frontend/src/routes/workflows/copilot/narrativeState.credentialPause.test.ts
index 04263b06f..bd413c293 100644
--- a/skyvern-frontend/src/routes/workflows/copilot/narrativeState.credentialPause.test.ts
+++ b/skyvern-frontend/src/routes/workflows/copilot/narrativeState.credentialPause.test.ts
@@ -4,6 +4,7 @@ import {
applyNarrativeEvent,
EMPTY_NARRATIVE,
hydrateNarrativeFromPayload,
+ parseCredentialAutoBound,
parseCredentialPause,
parseCredentialPrompt,
} from "./narrativeState";
@@ -70,13 +71,39 @@ describe("parseCredentialPause", () => {
});
});
+describe("parseCredentialAutoBound", () => {
+ it("accepts a well-formed auto-bind signal", () => {
+ expect(
+ parseCredentialAutoBound({ credentialId: "cred_x", name: "Work login" }),
+ ).toEqual({ credentialId: "cred_x", name: "Work login" });
+ });
+
+ it("rejects malformed shapes so the receipt can't crash", () => {
+ expect(parseCredentialAutoBound(null)).toBeNull();
+ expect(parseCredentialAutoBound({})).toBeNull();
+ expect(parseCredentialAutoBound({ credentialId: "cred_x" })).toBeNull();
+ expect(parseCredentialAutoBound({ name: "Work" })).toBeNull();
+ expect(
+ parseCredentialAutoBound({ credentialId: "", name: "Work" }),
+ ).toBeNull();
+ expect(
+ parseCredentialAutoBound({ credentialId: "cred_x", name: "" }),
+ ).toBeNull();
+ expect(
+ parseCredentialAutoBound({ credentialId: 3, name: "Work" }),
+ ).toBeNull();
+ });
+});
+
describe("hydrateNarrativeFromPayload — credential signals", () => {
- it("defaults both signals to null when absent", () => {
+ it("defaults every credential signal to null when absent", () => {
expect(EMPTY_NARRATIVE.credentialPrompt).toBeNull();
expect(EMPTY_NARRATIVE.credentialPause).toBeNull();
+ expect(EMPTY_NARRATIVE.credentialAutoBound).toBeNull();
const hydrated = hydrateNarrativeFromPayload(basePayload());
expect(hydrated?.credentialPrompt).toBeNull();
expect(hydrated?.credentialPause).toBeNull();
+ expect(hydrated?.credentialAutoBound).toBeNull();
});
it("hydrates credentialPrompt from the narrative payload", () => {
@@ -102,6 +129,18 @@ describe("hydrateNarrativeFromPayload — credential signals", () => {
});
});
+ it("hydrates a credentialAutoBound receipt from the narrative payload", () => {
+ const hydrated = hydrateNarrativeFromPayload(
+ basePayload({
+ credentialAutoBound: { credentialId: "cred_work", name: "Work login" },
+ }),
+ );
+ expect(hydrated?.credentialAutoBound).toEqual({
+ credentialId: "cred_work",
+ name: "Work login",
+ });
+ });
+
it("carries both signals through the terminal response reducer (reload path)", () => {
const response: WorkflowCopilotStreamResponseUpdate = {
type: "response",
diff --git a/skyvern-frontend/src/routes/workflows/copilot/narrativeState.ts b/skyvern-frontend/src/routes/workflows/copilot/narrativeState.ts
index 9414cce87..d21b60851 100644
--- a/skyvern-frontend/src/routes/workflows/copilot/narrativeState.ts
+++ b/skyvern-frontend/src/routes/workflows/copilot/narrativeState.ts
@@ -244,6 +244,9 @@ export interface TurnNarrativeState {
outcome: "connected" | "skipped" | "timeout" | "declined";
credentialId: string | null;
} | null;
+ // Silently auto-bound credential, from the credentialAutoBound narrative signal — rendered as a
+ // receipt with a Change affordance so a confident-but-wrong pick can be corrected after the fact.
+ credentialAutoBound: { credentialId: string; name: string } | null;
}
export const EMPTY_NARRATIVE: TurnNarrativeState = Object.freeze({
@@ -274,6 +277,7 @@ export const EMPTY_NARRATIVE: TurnNarrativeState = Object.freeze({
lastRunOutcome: null,
credentialPrompt: null,
credentialPause: null,
+ credentialAutoBound: null,
}) as TurnNarrativeState;
// Caps to keep long-running narrations from unbounded growth (and to keep
@@ -332,6 +336,21 @@ export function parseCredentialPause(
};
}
+export function parseCredentialAutoBound(
+ value: unknown,
+): TurnNarrativeState["credentialAutoBound"] {
+ if (!value || typeof value !== "object") return null;
+ const o = value as Record<string, unknown>;
+ const credentialId = o.credentialId;
+ const name = o.name;
+ return typeof credentialId === "string" &&
+ credentialId.length > 0 &&
+ typeof name === "string" &&
+ name.length > 0
+ ? { credentialId, name }
+ : null;
+}
+
// Tool calls that write the workflow definition. update_workflow only
// validates/saves the draft; update_and_run_blocks also runs it, so it's
// the one AUTHORING_TOOLS member that's also a RUN_TOOLS member (its
@@ -1257,6 +1276,7 @@ export function hydrateNarrativeFromPayload(
typeof payload.endedAt === "string" ? (payload.endedAt as string) : null,
credentialPrompt: parseCredentialPrompt(payload.credentialPrompt),
credentialPause: parseCredentialPause(payload.credentialPause),
+ credentialAutoBound: parseCredentialAutoBound(payload.credentialAutoBound),
};
}