@athenaintel/react 0.56.0 → 0.57.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/README.md +71 -1
  2. package/dist/agent-runtime/src/inbound-channel.cjs +96 -0
  3. package/dist/agent-runtime/src/inbound-channel.cjs.map +1 -0
  4. package/dist/agent-runtime/src/inbound-channel.d.ts +75 -0
  5. package/dist/agent-runtime/src/inbound-channel.js +96 -0
  6. package/dist/agent-runtime/src/inbound-channel.js.map +1 -0
  7. package/dist/agent-runtime/src/index.d.ts +2 -1
  8. package/dist/agent-runtime/src/interrupts.cjs +45 -3
  9. package/dist/agent-runtime/src/interrupts.cjs.map +1 -1
  10. package/dist/agent-runtime/src/interrupts.d.ts +51 -4
  11. package/dist/agent-runtime/src/interrupts.js +46 -4
  12. package/dist/agent-runtime/src/interrupts.js.map +1 -1
  13. package/dist/agent-runtime/src/offline-status.cjs.map +1 -1
  14. package/dist/agent-runtime/src/offline-status.d.ts +25 -0
  15. package/dist/agent-runtime/src/offline-status.js.map +1 -1
  16. package/dist/agent-runtime/src/thread-handoff-flow-machine.d.ts +8 -8
  17. package/dist/agent-runtime/src/tool-metadata.cjs +8 -0
  18. package/dist/agent-runtime/src/tool-metadata.cjs.map +1 -1
  19. package/dist/agent-runtime/src/tool-metadata.js +8 -0
  20. package/dist/agent-runtime/src/tool-metadata.js.map +1 -1
  21. package/dist/auth/AthenaSSOProvider.cjs +54 -12
  22. package/dist/auth/AthenaSSOProvider.cjs.map +1 -1
  23. package/dist/auth/AthenaSSOProvider.d.ts +23 -2
  24. package/dist/auth/AthenaSSOProvider.js +54 -12
  25. package/dist/auth/AthenaSSOProvider.js.map +1 -1
  26. package/dist/auth/index.cjs +2 -0
  27. package/dist/auth/index.cjs.map +1 -1
  28. package/dist/auth/index.d.ts +1 -0
  29. package/dist/auth/index.js +2 -0
  30. package/dist/auth/index.js.map +1 -1
  31. package/dist/auth/sign-back-in.cjs +141 -0
  32. package/dist/auth/sign-back-in.cjs.map +1 -0
  33. package/dist/auth/sign-back-in.d.ts +117 -0
  34. package/dist/auth/sign-back-in.js +141 -0
  35. package/dist/auth/sign-back-in.js.map +1 -0
  36. package/dist/chat/AthenaChat.cjs +7 -2
  37. package/dist/chat/AthenaChat.cjs.map +1 -1
  38. package/dist/chat/AthenaChat.js +7 -2
  39. package/dist/chat/AthenaChat.js.map +1 -1
  40. package/dist/chat/StatewireApprovalCard.cjs +6 -2
  41. package/dist/chat/StatewireApprovalCard.cjs.map +1 -1
  42. package/dist/chat/StatewireApprovalCard.d.ts +8 -1
  43. package/dist/chat/StatewireApprovalCard.js +7 -3
  44. package/dist/chat/StatewireApprovalCard.js.map +1 -1
  45. package/dist/chat-ui/index.cjs +4 -0
  46. package/dist/chat-ui/index.cjs.map +1 -1
  47. package/dist/chat-ui/index.d.ts +1 -0
  48. package/dist/chat-ui/index.js +5 -1
  49. package/dist/chat-ui/index.js.map +1 -1
  50. package/dist/chat-ui/messages/inbound-channel-message.cjs +219 -0
  51. package/dist/chat-ui/messages/inbound-channel-message.cjs.map +1 -0
  52. package/dist/chat-ui/messages/inbound-channel-message.d.ts +60 -0
  53. package/dist/chat-ui/messages/inbound-channel-message.js +219 -0
  54. package/dist/chat-ui/messages/inbound-channel-message.js.map +1 -0
  55. package/dist/chat-ui/messages/inbound-channel-reader.cjs +184 -0
  56. package/dist/chat-ui/messages/inbound-channel-reader.cjs.map +1 -0
  57. package/dist/chat-ui/messages/inbound-channel-reader.d.ts +65 -0
  58. package/dist/chat-ui/messages/inbound-channel-reader.js +184 -0
  59. package/dist/chat-ui/messages/inbound-channel-reader.js.map +1 -0
  60. package/dist/chat-ui/messages/message-components.cjs +18 -14
  61. package/dist/chat-ui/messages/message-components.cjs.map +1 -1
  62. package/dist/chat-ui/messages/message-components.d.ts +7 -0
  63. package/dist/chat-ui/messages/message-components.js +19 -15
  64. package/dist/chat-ui/messages/message-components.js.map +1 -1
  65. package/dist/composer/sign-back-in-draft.cjs +62 -0
  66. package/dist/composer/sign-back-in-draft.cjs.map +1 -0
  67. package/dist/composer/sign-back-in-draft.d.ts +34 -0
  68. package/dist/composer/sign-back-in-draft.js +62 -0
  69. package/dist/composer/sign-back-in-draft.js.map +1 -0
  70. package/dist/diagnostics/athena-diagnostics.cjs.map +1 -1
  71. package/dist/diagnostics/athena-diagnostics.d.ts +6 -1
  72. package/dist/diagnostics/athena-diagnostics.js.map +1 -1
  73. package/dist/index.cjs +8 -0
  74. package/dist/index.cjs.map +1 -1
  75. package/dist/index.d.ts +2 -0
  76. package/dist/index.js +8 -0
  77. package/dist/index.js.map +1 -1
  78. package/dist/provider/AthenaProvider.cjs +48 -3
  79. package/dist/provider/AthenaProvider.cjs.map +1 -1
  80. package/dist/provider/AthenaProvider.js +49 -4
  81. package/dist/provider/AthenaProvider.js.map +1 -1
  82. package/dist/react/package.json.cjs +1 -1
  83. package/dist/react/package.json.js +1 -1
  84. package/dist/runtime/auth.cjs +11 -0
  85. package/dist/runtime/auth.cjs.map +1 -1
  86. package/dist/runtime/auth.d.ts +18 -1
  87. package/dist/runtime/auth.js +11 -0
  88. package/dist/runtime/auth.js.map +1 -1
  89. package/dist/styles.css +1 -1
  90. package/package.json +1 -1
@@ -284,13 +284,16 @@ const StatewireApprovalCardInner = ({
284
284
  const pendingCount = ((_c = hitl == null ? void 0 : hitl.context) == null ? void 0 : _c.pending_action_count) ?? 1;
285
285
  const hasDetails = hitl !== null && actionRequests.length > 0;
286
286
  const showDetails = hasDetails && (detailsOverride ?? actionRequests.length <= 1);
287
- const sessionApprovalOffered = hitl !== null && interrupts.canApproveForSession(actionRequests);
287
+ const sessionOffer = hitl !== null ? interrupts.sessionApprovalOffer(actionRequests) : void 0;
288
+ const sessionApprovalOffered = sessionOffer !== void 0;
289
+ const sessionLabel = sessionOffer ? interrupts.sessionApprovalLabel(sessionOffer) : "";
288
290
  const laneDecided = undecidedLaneIds !== null && laneIds !== null && (undecidedLaneIds.length === 0 || liveSentKey === undecidedLaneIds.join("|"));
289
291
  const locked = pending || laneDecided || replaying || confirming;
290
292
  const editor = !readOnly && hitl !== null && renderEditor ? renderEditor({
291
293
  ...context,
292
294
  locked,
293
295
  sessionApprovalOffered,
296
+ sessionApprovalLabel: sessionLabel,
294
297
  approve: () => decide(interrupts.hitlResumeApprove()),
295
298
  approveForSession: () => decide(interrupts.hitlResumeApproveForSession()),
296
299
  reject: (reason) => decide(interrupts.hitlResumeReject(reason)),
@@ -392,9 +395,10 @@ const StatewireApprovalCardInner = ({
392
395
  disabled: locked,
393
396
  onClick: () => decide(interrupts.hitlResumeApproveForSession()),
394
397
  "data-testid": "statewire-approval-approve-session",
398
+ className: "h-auto min-h-8 whitespace-normal py-1.5 text-left",
395
399
  children: [
396
400
  /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CheckCheckIcon, {}),
397
- "Approve all for this session"
401
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "min-w-0 break-words", children: sessionLabel })
398
402
  ]
399
403
  }
400
404
  ) : null,
@@ -1 +1 @@
1
- {"version":3,"file":"StatewireApprovalCard.cjs","sources":["../../src/chat/StatewireApprovalCard.tsx"],"sourcesContent":["import { useAuiState } from '@assistant-ui/react';\nimport { type StatewireThread, useStatewireState } from '@assistant-ui/react-statewire';\nimport {\n actionRequestToolCallIds,\n asHitlApproval,\n canApproveForSession,\n fanLaneDecision,\n HITL_PENDING_RESUME_GRACE_MS,\n type HitlActionDecision,\n type HitlApprovalPayload,\n hasStatewireThreadExtras,\n hitlResumeActionDecisions,\n hitlResumeApprove,\n hitlResumeApproveForSession,\n hitlResumeReject,\n interruptResumeDecline,\n interruptMirrorPayload,\n laneInterruptIds,\n type PendingActionRequest,\n type PendingApprovalContext,\n type PendingApprovalTitle,\n pendingApprovalTitle,\n readInterruptMessage,\n readInterruptMirror,\n type ResumeExtras,\n resumeValueApproves,\n statewireRejectionDetailMessage,\n} from '@athenaintel/agent-runtime';\nimport {\n CheckCheckIcon,\n CheckIcon,\n ChevronDownIcon,\n ShieldAlertIcon,\n XIcon,\n} from 'lucide-react';\nimport {\n type FC,\n type ReactNode,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { cn } from '../lib/utils';\nimport { Button } from '../ui/button';\nimport {\n type StatewireInterruptPredicate,\n useStatewireApprovalRequest,\n} from './use-statewire-approval-request';\n\n/**\n * Human-in-the-loop approval card for the statewire transport — the one\n * approval UI every Athena chat surface mounts (the SDK's `AthenaChat`, the\n * Chrome side panel, the Office task pane, Olympus).\n *\n * When the deep-agent runtime hits an approval-gated tool call, the backend\n * parks the run on an `interrupt` input request. This card reads that request\n * through `useStatewireApprovalRequest` and answers it with\n * `{ type: 'run/input', requestId, response: { type: 'resume', value } }` —\n * the exact command the backend's resume path consumes. Without an answer the\n * run stays parked forever, so this card must be mounted on every statewire\n * chat surface. On legacy (non-statewire) threads it renders nothing.\n *\n * A gated call raised inside a delegated subagent parks only its lane: the\n * host mirrors that interrupt while the sibling lanes keep streaming, before\n * any input request exists. The card renders the mirrored payload the same\n * way and answers it with `run/lane-input` keyed by the lane's langgraph\n * interrupt id (`laneInterruptIds`); the host queues the decision and applies\n * it the moment the run parks, so the approver never waits on the siblings.\n * Once parked, a payload whose calls all carry interrupt ids resumes as a\n * `lane_decisions` map too — one positional `run/input` can only answer the\n * first of several parked lanes.\n *\n * Recovery of a queued decision the host never applies is ordered host\n * first: the host's answerer resumes the park or drops (and flushes) the\n * queue within `QUEUED_LANE_ANSWER_BUDGET_SECONDS` of the park, and this\n * card's grace (`HITL_PENDING_RESUME_GRACE_MS`, longer than that budget)\n * fires only when the host stayed silent. When it fires, the card that sent\n * the queued decision asks the host to replay it (`run/lane-replay` — the\n * host resumes as the approver, under the meta it recorded, and refuses any\n * other caller); every other card, and a replay the host refuses, hands the\n * decision back to a person by unlocking the actions. A queued decision is\n * never re-sent as a `run/input` of the viewing client's own: that would run\n * the approver's decision under the viewer's identity and configuration.\n *\n * A lone gated call whose resolved envelope (`approval_context`) carries a\n * headline is titled by it in the card's own review: the headline replaces\n * \"`tool` requires approval before it runs\", the summary sits under it, and\n * the default details name the tool instead. A batch keeps the generic copy,\n * since one decision answers every call. So does a host review\n * (`renderDetails`, or an editor from `renderEditor`): it shows the envelope\n * itself, headline included, so the header must not say it again. Display-only:\n * the decision row and what it sends do not change.\n *\n * Host-specific review UIs (subagent cards, email summaries) slot in through\n * `renderDetails`; a host composer that must also OWN the decision (an\n * editable email whose edits have to reach the backend) takes over the\n * details and the decision row through `renderEditor`; requests another\n * surface answers (typed interrupt families, per-lane subagent approvals)\n * stand down through `isHandledElsewhere`; viewers without edit rights see\n * `readOnlyNotice`.\n */\n\n/**\n * The answer a passkey decision check confirms before the card sends it\n * (identity 0b.9): a `run/input` resume of the parked request, or the lane\n * decisions of a `run/lane-input` sent while sibling lanes still stream.\n */\nexport type StatewireDecisionAnswer =\n | {\n readonly kind: 'input';\n readonly requestId: string;\n readonly value: StatewireThread.InputResponse;\n }\n | {\n readonly kind: 'lanes';\n readonly laneDecisions: Readonly<Record<string, StatewireThread.InputResponse>>;\n };\n\n/**\n * Runs the host's passkey check for an approving answer and resolves its\n * token, or `undefined` to send the answer without one. While checks are\n * report-only, an answer goes ahead without a check (no passkey yet, a\n * cancelled prompt); the host decides what to tell the person. Never called\n * for an answer that only rejects.\n */\nexport type StatewireDecisionConfirmer = (\n answer: StatewireDecisionAnswer,\n) => Promise<string | undefined>;\n\nfunction answerApproves(answer: StatewireDecisionAnswer): boolean {\n if (answer.kind === 'input') return resumeValueApproves(answer.value);\n const lanes = Object.values(answer.laneDecisions);\n return lanes.length === 0 || lanes.some(resumeValueApproves);\n}\n\n/** What the card reads in place of the host's queued lanes once it has given up on them. */\nconst NO_HOST_QUEUED_LANE_DECISIONS: Readonly<Record<string, unknown>> = Object.freeze({});\n\n/** The pending request a host slot renders or judges. */\nexport interface StatewireApprovalRequestContext {\n /** The parked input request — `undefined` while the run still streams (a live lane approval). */\n request: StatewireThread.CustomInputRequest | undefined;\n /** The payload narrowed to the Athena HITL approval shape, or `null` for a generic park. */\n hitl: HitlApprovalPayload | null;\n /** Every gated call the approval covers, in decision order (empty for non-HITL parks). */\n actionRequests: PendingActionRequest[];\n /**\n * The approval's title (`pendingApprovalTitle`): a lone call's envelope\n * headline and summary. Absent for a batch, a non-HITL park and a call\n * without one. The default header shows it only above the card's own\n * details; under a host review the host shows the envelope, and may lead\n * with this.\n */\n title?: PendingApprovalTitle;\n}\n\n/** The request a host editor renders, plus the decisions it may send for it. */\nexport interface StatewireApprovalEditorContext extends StatewireApprovalRequestContext {\n /** A decision is in flight (or a live lane already answered); the editor must not send another. */\n locked: boolean;\n /** Whether \"approve all for this session\" may be offered for this batch. */\n sessionApprovalOffered: boolean;\n approve: () => void;\n approveForSession: () => void;\n reject: (reason?: string) => void;\n /**\n * Answer each gated call on its own — the only way an EDITED call reaches\n * the backend. `decision` is asked once per call, in order, so the answer\n * always names exactly the parked calls (a partial map is refused\n * server-side and nothing runs). `null` when the batch cannot take\n * per-action answers: a call without a `tool_call_id`, or a live / multi-\n * lane approval, which resumes per lane and carries no edit.\n */\n decideEach: ((decision: (request: PendingActionRequest) => HitlActionDecision) => void) | null;\n}\n\nexport interface StatewireApprovalCardProps {\n /** Surface-styling overrides merged onto the default classes. */\n classNames?: {\n /** The approval card container. */\n root?: string;\n /** The \"approval was cancelled\" notice container. */\n abandoned?: string;\n /** The disclosed details block. */\n details?: string;\n /** The decision row. */\n actions?: string;\n };\n /** Copy shown when an interrupt payload carries no message. */\n fallbackMessage?: string;\n /**\n * Which pending interrupt this card answers. Defaults to\n * `isApprovalCardInterrupt` (client-tool parks excluded — keep it that way\n * unless the surface handles those itself).\n */\n interruptPredicate?: StatewireInterruptPredicate;\n /**\n * How long a clicked decision keeps the buttons locked when no resume run\n * ever starts (a `run/input` the host rejected before any run began).\n * Defaults to `HITL_PENDING_RESUME_GRACE_MS`.\n */\n pendingResumeGraceMs?: number;\n /**\n * Return true when another surface answers this request (a typed Athena\n * interrupt family, per-lane subagent approval cards). The card renders\n * nothing for it — two surfaces must never answer the same input request.\n */\n isHandledElsewhere?: (context: StatewireApprovalRequestContext) => boolean;\n /**\n * Replace the default argument disclosure (one JSON block per gated call)\n * with a host-specific review UI. Rendered inside the collapsible details\n * region; the decision buttons stay with the card.\n */\n renderDetails?: (context: StatewireApprovalRequestContext) => ReactNode;\n /** Replace the default approval icon and heading. Return null to keep it. */\n renderHeader?: (context: StatewireApprovalRequestContext) => ReactNode;\n /**\n * Replace BOTH the details region and the decision row with a host\n * composer that decides the request itself through the context's\n * callbacks (an editable email whose edits must be what runs). Return\n * `null`/`undefined` to keep the default card for this request. Not\n * consulted for read-only viewers or non-HITL parks.\n */\n renderEditor?: (context: StatewireApprovalEditorContext) => ReactNode;\n /**\n * The viewer may see the request (it explains why the run is parked) but\n * cannot decide it — answering steers the shared run. Renders\n * `readOnlyNotice` in place of the buttons.\n */\n readOnly?: boolean;\n readOnlyNotice?: ReactNode;\n /**\n * Copy for a park that is not a HITL approval — a typed Athena interrupt\n * this surface has no card for. The only honest action is to decline it\n * (`{ action: 'reject' }`, which every typed raiser treats as a clean user\n * decline); a generic \"Continue\" would be rejected by the raiser's resume\n * schema and surface as a tool error.\n */\n nonHitlNotice?: ReactNode;\n /**\n * The host refused a decision (or the transport lost it). The optimistic\n * fold has rolled back and the request is on screen again with its actions\n * re-enabled; this is where a host tells the user why (a toast, a log line).\n */\n onResumeRejected?: (error: unknown, requestId: string) => void;\n /**\n * The host's passkey decision check (identity 0b.9). An answer that lets\n * anything run is handed to it first and sent with the token it resolves\n * as `decisionCheck`; the decision buttons stay locked while it runs. An\n * answer that only rejects never is. Omit it and every answer is sent as\n * before, with no check.\n */\n confirmDecision?: StatewireDecisionConfirmer;\n}\n\nexport const StatewireApprovalCard: FC<StatewireApprovalCardProps> = (props) => {\n const extras = useAuiState((s) => s.thread.extras);\n if (!hasStatewireThreadExtras(extras)) return null;\n return <StatewireApprovalCardInner {...props} />;\n};\n\nconst StatewireApprovalCardInner: FC<StatewireApprovalCardProps> = ({\n classNames,\n fallbackMessage,\n interruptPredicate,\n pendingResumeGraceMs,\n isHandledElsewhere,\n renderDetails,\n renderHeader,\n renderEditor,\n readOnly = false,\n readOnlyNotice = 'Waiting for someone with edit access to respond.',\n nonHitlNotice = 'This request needs an answer this surface cannot collect.',\n onResumeRejected,\n confirmDecision,\n}) => {\n const approvalEpochRef = useRef(0);\n const [decisionFailure, setDecisionFailure] = useState<{\n requestId: string;\n message: string;\n epoch: number;\n }>();\n const reportResumeRejected = useCallback(\n (error: unknown, failedRequestId: string) => {\n setDecisionFailure({\n requestId: failedRequestId,\n message: statewireRejectionDetailMessage(error) ?? 'Your decision could not be sent. Try again.',\n epoch: approvalEpochRef.current,\n });\n onResumeRejected?.(error, failedRequestId);\n },\n [onResumeRejected],\n );\n const {\n request,\n requestId,\n hitl: parkedHitl,\n actionRequests: parkedActionRequests,\n liveHitl,\n liveActionRequests,\n queuedLaneDecisions,\n abandonedInterrupt,\n pending,\n resume,\n sendLaneDecisions,\n replayQueuedLanes,\n } = useStatewireApprovalRequest<StatewireThread.InputResponse>({\n interruptPredicate,\n pendingResumeGraceMs,\n onResumeRejected: reportResumeRejected,\n });\n // Read the host mirror: the optimistic resume fold can temporarily hide\n // `liveHitl` and the parked request without ending this approval.\n const mirroredApproval = useStatewireState(\n (state) => asHitlApproval(interruptMirrorPayload(readInterruptMirror(state))) !== null,\n );\n const approvalPresent = requestId !== undefined || mirroredApproval;\n const previousApprovalPresentRef = useRef(approvalPresent);\n if (previousApprovalPresentRef.current && !approvalPresent) approvalEpochRef.current += 1;\n previousApprovalPresentRef.current = approvalPresent;\n const [dismissedId, setDismissedId] = useState<string>();\n // The card shares the chat column with the thread. A lone gated call is\n // small enough to show inline, but a fan-out of a dozen calls would swallow\n // the conversation, so a batch starts collapsed until someone opens it.\n const [detailsOverride, setDetailsOverride] = useState<boolean>();\n // The live lanes a decision was sent for (joined ids); the buttons stay\n // locked until the host echoes them in `queuedLaneDecisions` or refuses.\n const [liveSentKey, setLiveSentKey] = useState<string>();\n // The parked request whose host-queued lanes outlived the grace window\n // (see `queuedLanesAwaitingHost` below): its queue is read as stale.\n const [staleQueuedRequestId, setStaleQueuedRequestId] = useState<string>();\n // The parked request whose queued lanes this card has asked the host to\n // replay (`run/lane-replay` in flight): locked until the host answers.\n const [replayingRequestId, setReplayingRequestId] = useState<string>();\n // The lanes THIS card decided live (its own `run/lane-input` the host\n // accepted). Only a queue this card recorded is replayed from here — the\n // host refuses any other caller, and a second editor's card must not even\n // ask. Pruned to the lanes on screen whenever a different view arrives, so\n // the record survives the live → parked transition of the same lanes (and\n // a fold that briefly shows nothing) and dies with a new request.\n const sentLaneIdsRef = useRef<Set<string>>(new Set());\n // The parked request already replayed once from here: a request is\n // replayed at most once, then the grace hands the decision back.\n const replayedRequestIdRef = useRef<string>(undefined);\n // A passkey check is running for the answer clicked here; the buttons stay\n // locked until it settles.\n const [confirming, setConfirming] = useState(false);\n // The parked request on screen now, read after a check settles: an answer\n // confirmed for a request that is no longer parked is never sent.\n const currentRequestIdRef = useRef(requestId);\n currentRequestIdRef.current = requestId;\n const confirmDecisionRef = useRef(confirmDecision);\n confirmDecisionRef.current = confirmDecision;\n\n const isLive = request === undefined && liveHitl !== null;\n const hitl = isLive ? liveHitl : parkedHitl;\n const actionRequests = isLive ? liveActionRequests : parkedActionRequests;\n const laneIds = laneInterruptIds(actionRequests);\n // The host answers the lanes it queued from its own settle path, within its\n // published budget of the park (`QUEUED_LANE_ANSWER_BUDGET_SECONDS`). A\n // parked request whose queued lanes are still unanswered past the grace\n // window has a silent answerer, and either this card asked the host to\n // replay them and was refused, or the queue is not this card's to replay —\n // so the queue no longer counts as a decision here: the actions re-enable\n // and the next click answers the parked request itself (a resume the host\n // accepts, and whose dispatch drops the stale queue).\n const hostQueuedLaneDecisions =\n requestId !== undefined && staleQueuedRequestId === requestId\n ? NO_HOST_QUEUED_LANE_DECISIONS\n : queuedLaneDecisions;\n const undecidedLaneIds =\n laneIds?.filter((id) => !(id in hostQueuedLaneDecisions)) ?? null;\n // A lone parked lane (or an unstamped batch) answers with one positional\n // `run/input`; that is the only resume the backend binds per-action answers\n // to, so it is the only place an edited call can go.\n const positional = laneIds === null || (!isLive && laneIds.length <= 1);\n const liveKey = isLive ? (laneIds?.join('|') ?? null) : null;\n const viewKey = requestId ?? liveKey ?? undefined;\n\n // A fresh approval gets the default for ITS batch size, not the disclosure\n // the previous one was left in. Reset during render via React's \"previous\n // value\" pattern.\n const prevViewKeyRef = useRef(viewKey);\n if (prevViewKeyRef.current !== viewKey) {\n prevViewKeyRef.current = viewKey;\n if (detailsOverride !== undefined) setDetailsOverride(undefined);\n if (liveSentKey !== undefined) setLiveSentKey(undefined);\n if (laneIds !== null) {\n for (const id of sentLaneIdsRef.current) {\n if (!laneIds.includes(id)) sentLaneIdsRef.current.delete(id);\n }\n }\n }\n // The per-request marks (stale queue, replayed once, replay in flight)\n // outlive the optimistic fold of a click's own `run/input`: the request\n // leaves and comes back under the SAME id when the host refuses it, and a\n // card that forgot its stale mark then would relock over the standing\n // queue for another grace, and could replay it a second time. They are\n // forgotten only for a genuinely different parked request.\n if (\n requestId !== undefined &&\n staleQueuedRequestId !== undefined &&\n requestId !== staleQueuedRequestId\n ) {\n setStaleQueuedRequestId(undefined);\n }\n if (\n requestId !== undefined &&\n replayingRequestId !== undefined &&\n requestId !== replayingRequestId\n ) {\n setReplayingRequestId(undefined);\n }\n if (\n requestId !== undefined &&\n replayedRequestIdRef.current !== undefined &&\n requestId !== replayedRequestIdRef.current\n ) {\n replayedRequestIdRef.current = undefined;\n }\n\n const title = pendingApprovalTitle({ hitl, actionRequests });\n const context: StatewireApprovalRequestContext = {\n request,\n hitl,\n actionRequests,\n ...(title ? { title } : {}),\n };\n const handledElsewhere = isHandledElsewhere?.(context) ?? false;\n const replaying = replayingRequestId !== undefined && replayingRequestId === requestId;\n\n // Parked, every lane the request covers already queued on the host, no\n // resume of our own in flight, and this card is the one that would decide\n // (not a viewer, not a request another surface owns): the host's answerer\n // is expected to resume the run within its budget. Start the clock on it,\n // longer than that budget. When it runs out the host has stayed silent: if\n // this card queued those lanes itself, it asks the host to replay them as\n // their approver (`run/lane-replay`); otherwise — and when the host refuses\n // the replay — the queue no longer counts as a decision here and the actions\n // re-enable, so a person decides. Never a `run/input` of this client's own\n // carrying someone else's recorded decision.\n const queuedLanesAwaitingHost =\n !isLive &&\n !readOnly &&\n !handledElsewhere &&\n requestId !== undefined &&\n undecidedLaneIds !== null &&\n undecidedLaneIds.length === 0 &&\n !pending &&\n !replaying;\n const queuedLaneGraceMs = pendingResumeGraceMs ?? HITL_PENDING_RESUME_GRACE_MS;\n const laneKey = laneIds?.join('|');\n const onResumeRejectedRef = useRef(reportResumeRejected);\n onResumeRejectedRef.current = reportResumeRejected;\n useEffect(() => {\n if (!queuedLanesAwaitingHost || requestId === undefined || laneKey === undefined) {\n return undefined;\n }\n const timer = setTimeout(() => {\n const ownQueue =\n laneKey.split('|').every((id) => sentLaneIdsRef.current.has(id)) &&\n replayedRequestIdRef.current !== requestId;\n if (!ownQueue) {\n setStaleQueuedRequestId(requestId);\n return;\n }\n replayedRequestIdRef.current = requestId;\n setReplayingRequestId(requestId);\n replayQueuedLanes(requestId).then(\n () => {\n setReplayingRequestId((current) => (current === requestId ? undefined : current));\n },\n (error: unknown) => {\n setReplayingRequestId((current) => (current === requestId ? undefined : current));\n setStaleQueuedRequestId(requestId);\n onResumeRejectedRef.current?.(error, requestId);\n },\n );\n }, queuedLaneGraceMs);\n return () => clearTimeout(timer);\n }, [queuedLanesAwaitingHost, requestId, laneKey, queuedLaneGraceMs, replayQueuedLanes]);\n\n /**\n * Send `answer` through `deliver`, with a passkey check first when it\n * approves and the host runs one. The check is the person's own act on\n * their device; while it is open the card is locked, and if the parked\n * request changed meanwhile the confirmed answer is dropped, never sent to\n * whatever parked next.\n */\n const withDecisionCheck = useCallback(\n (answer: StatewireDecisionAnswer, deliver: (extras?: ResumeExtras) => void) => {\n const confirmer = confirmDecisionRef.current;\n if (confirmer === undefined || !answerApproves(answer)) {\n deliver();\n return;\n }\n setConfirming(true);\n confirmer(answer)\n .catch(() => undefined)\n .then((token) => {\n setConfirming(false);\n if (answer.kind === 'input' && currentRequestIdRef.current !== answer.requestId) {\n return;\n }\n deliver(token ? { decisionCheck: token } : undefined);\n });\n },\n [],\n );\n\n // A live lane decision: the host queues it until the run parks, and holds\n // it for this card's caller, the only queue this card may ask it to replay.\n const sendLiveLanes = useCallback(\n ({\n key,\n lanes,\n epoch,\n extras,\n }: {\n key: string;\n lanes: Readonly<Record<string, StatewireThread.InputResponse>>;\n epoch: number;\n extras?: ResumeExtras;\n }) => {\n const sentLaneIds = key.split('|');\n setLiveSentKey(key);\n Promise.resolve(sendLaneDecisions(lanes, extras)).then(\n () => {\n if (epoch !== approvalEpochRef.current) return;\n for (const id of sentLaneIds) sentLaneIdsRef.current.add(id);\n },\n (error: unknown) => {\n if (epoch !== approvalEpochRef.current) return;\n setLiveSentKey((current) => (current === key ? undefined : current));\n reportResumeRejected(error, sentLaneIds[0] ?? '');\n },\n );\n },\n [sendLaneDecisions, reportResumeRejected],\n );\n\n const decide = useCallback(\n (value: Record<string, string>) => {\n setDecisionFailure(undefined);\n const epoch = approvalEpochRef.current;\n // Several parked lanes (or a live one) answer by interrupt id: a\n // positional `run/input` would resume only the first and re-park the\n // rest. A lone parked lane keeps the positional resume every host\n // already speaks.\n if (positional || undecidedLaneIds === null) {\n if (requestId === undefined) return;\n withDecisionCheck({ kind: 'input', requestId, value }, (extras) => {\n resume(value, extras);\n });\n return;\n }\n const lanes = fanLaneDecision({ interruptIds: undecidedLaneIds, decision: value });\n if (!isLive) {\n if (requestId === undefined) return;\n withDecisionCheck(\n { kind: 'input', requestId, value: { lane_decisions: lanes } },\n (extras) => {\n sendLaneDecisions(lanes, extras);\n },\n );\n return;\n }\n const key = undecidedLaneIds.join('|');\n withDecisionCheck({ kind: 'lanes', laneDecisions: lanes }, (extras) =>\n sendLiveLanes({ key, lanes, epoch, extras }),\n );\n },\n [\n positional,\n undecidedLaneIds,\n isLive,\n requestId,\n resume,\n sendLaneDecisions,\n sendLiveLanes,\n withDecisionCheck,\n ],\n );\n\n const decideEach = useMemo<StatewireApprovalEditorContext['decideEach']>(() => {\n if (actionRequestToolCallIds(actionRequests) === null || !positional) return null;\n return (decision) => {\n setDecisionFailure(undefined);\n const decisions: Record<string, HitlActionDecision> = {};\n for (const request of actionRequests) {\n if (request.toolCallId !== undefined) decisions[request.toolCallId] = decision(request);\n }\n // The edited argument set comes from the wire as JSON; the resume value\n // is that JSON going back.\n const value = hitlResumeActionDecisions(decisions) as StatewireThread.InputResponse;\n if (requestId === undefined) return;\n withDecisionCheck({ kind: 'input', requestId, value }, (extras) => {\n resume(value, extras);\n });\n };\n }, [actionRequests, positional, requestId, resume, withDecisionCheck]);\n\n if (!request && !isLive) {\n if (!abandonedInterrupt || abandonedInterrupt.id === dismissedId) return null;\n return (\n <div\n className={cn(\n 'aui-approval-abandoned flex w-full items-center justify-between gap-3 rounded-xl border border-border bg-muted/40 px-3 py-2 text-muted-foreground text-xs',\n classNames?.abandoned,\n )}\n >\n <p>Approval was cancelled — the run moved on.</p>\n <button\n type=\"button\"\n aria-label=\"Dismiss cancelled approval\"\n onClick={() => setDismissedId(abandonedInterrupt.id)}\n className=\"shrink-0 rounded-md p-1 transition-colors hover:bg-muted hover:text-foreground\"\n >\n <XIcon className=\"size-3.5\" />\n </button>\n </div>\n );\n }\n\n if (handledElsewhere) return null;\n // A live mirror without lane stamps cannot be answered before the run\n // parks; the parked request renders it then.\n if (isLive && laneIds === null) return null;\n\n const message = readInterruptMessage(request ? request.payload : liveHitl, fallbackMessage);\n const toolName = hitl?.context?.tool_name ?? hitl?.context?.tool_id;\n const pendingCount = hitl?.context?.pending_action_count ?? 1;\n const hasDetails = hitl !== null && actionRequests.length > 0;\n const showDetails = hasDetails && (detailsOverride ?? actionRequests.length <= 1);\n const sessionApprovalOffered = hitl !== null && canApproveForSession(actionRequests);\n const laneDecided =\n undecidedLaneIds !== null &&\n laneIds !== null &&\n (undecidedLaneIds.length === 0 || liveSentKey === undecidedLaneIds.join('|'));\n const locked = pending || laneDecided || replaying || confirming;\n\n const editor =\n !readOnly && hitl !== null && renderEditor\n ? renderEditor({\n ...context,\n locked,\n sessionApprovalOffered,\n approve: () => decide(hitlResumeApprove()),\n approveForSession: () => decide(hitlResumeApproveForSession()),\n reject: (reason) => decide(hitlResumeReject(reason)),\n decideEach,\n })\n : undefined;\n const customHeader = renderHeader?.(context);\n // Only the card's own review leads with the title: a host's details or\n // editor show the envelope themselves, headline included.\n const headerTitle = renderDetails === undefined && editor == null ? title : undefined;\n\n return (\n <section\n aria-label={hitl ? 'Approval required' : 'Input required'}\n className={cn(\n 'aui-approval-card w-full rounded-2xl border border-border bg-card px-4 py-3 text-foreground shadow-xs',\n classNames?.root,\n )}\n >\n <div className=\"flex items-start gap-3\">\n {customHeader != null ? (\n <div className=\"min-w-0 flex-1\">{customHeader}</div>\n ) : (\n <>\n <ShieldAlertIcon className=\"mt-0.5 size-4 shrink-0 text-muted-foreground\" />\n <div className=\"min-w-0 flex-1\">\n <p className=\"flex items-center gap-2 font-semibold text-sm\">\n <span>{hitl ? 'Approval required' : 'Waiting for input'}</span>\n {hitl && pendingCount > 1 ? (\n <span className=\"shrink-0 rounded-full border border-border bg-muted px-1.5 py-px font-normal text-[11px] text-muted-foreground\">\n {pendingCount} tool calls\n </span>\n ) : null}\n </p>\n {headerTitle ? (\n <>\n <p\n className=\"break-words pt-1 font-medium text-foreground text-sm leading-snug\"\n data-testid=\"statewire-approval-headline\"\n >\n {headerTitle.headline}\n </p>\n {headerTitle.summary ? (\n <p\n className=\"break-words pt-1 text-muted-foreground text-sm leading-snug\"\n data-testid=\"statewire-approval-summary\"\n >\n {headerTitle.summary}\n </p>\n ) : null}\n </>\n ) : (\n <p className=\"pt-1 text-muted-foreground text-sm leading-snug\">\n {hitl && pendingCount === 1 && toolName ? (\n <>\n <span className=\"font-mono text-foreground\">{toolName}</span> requires approval before it runs.\n </>\n ) : (\n message\n )}\n </p>\n )}\n </div>\n </>\n )}\n </div>\n {decisionFailure && decisionFailure.epoch === approvalEpochRef.current &&\n (decisionFailure.requestId === requestId || laneIds?.includes(decisionFailure.requestId)) ? (\n <p role=\"alert\" data-testid=\"statewire-approval-error\">{decisionFailure.message}</p>\n ) : null}\n {isLive ? (\n <p className=\"pt-1 text-muted-foreground text-xs\" data-testid=\"statewire-approval-live\">\n {laneDecided\n ? 'Decision sent — it applies as soon as this step pauses.'\n : 'Other work keeps running while you decide.'}\n </p>\n ) : null}\n {hasDetails && editor == null ? (\n <button\n type=\"button\"\n onClick={() => setDetailsOverride(!showDetails)}\n aria-expanded={showDetails}\n className=\"mt-2 flex items-center gap-1 rounded px-1 py-0.5 text-muted-foreground text-xs transition-colors hover:text-foreground\"\n >\n <ChevronDownIcon\n className={cn('size-3 transition-transform', showDetails && 'rotate-180')}\n />\n {showDetails ? 'Hide details' : 'Review details'}\n </button>\n ) : null}\n {/* EVERY pending gated call renders, in order — one decision\n authorizes the whole batch, so nothing may hide behind a host's\n richer cards. All read-only: this runtime resumes through\n `hitl_response_to_decisions`, which has no `tool_args` channel —\n an editable composer would let someone rewrite an email and then\n watch the original go out — unless the host takes over the\n decision too (`renderEditor`), which sends the edit per call. */}\n {editor != null ? (\n <div className={cn('mt-3 flex flex-col gap-2', classNames?.details)}>{editor}</div>\n ) : showDetails ? (\n <div className={cn('mt-2 flex flex-col gap-2', classNames?.details)}>\n {renderDetails ? (\n renderDetails(context)\n ) : (\n // A titled card no longer names its tool in the header, so its\n // details do, as a batch's do.\n <DefaultApprovalDetails\n actionRequests={actionRequests}\n showNames={actionRequests.length > 1 || headerTitle !== undefined}\n />\n )}\n </div>\n ) : null}\n {editor != null ? null : (\n <div className={cn('flex flex-wrap items-center gap-2 pt-3', classNames?.actions)}>\n {readOnly ? (\n <p className=\"text-muted-foreground text-sm\" data-testid=\"statewire-approval-read-only\">\n {readOnlyNotice}\n </p>\n ) : hitl ? (\n <>\n <Button\n size=\"sm\"\n disabled={locked}\n onClick={() => decide(hitlResumeApprove())}\n >\n <CheckIcon />\n Approve\n </Button>\n {sessionApprovalOffered ? (\n <Button\n size=\"sm\"\n variant=\"outline\"\n disabled={locked}\n onClick={() => decide(hitlResumeApproveForSession())}\n data-testid=\"statewire-approval-approve-session\"\n >\n <CheckCheckIcon />\n Approve all for this session\n </Button>\n ) : null}\n <Button\n size=\"sm\"\n variant=\"outline\"\n disabled={locked}\n onClick={() => decide(hitlResumeReject())}\n >\n <XIcon />\n Reject\n </Button>\n </>\n ) : (\n <>\n <p className=\"text-muted-foreground text-sm\" data-testid=\"statewire-approval-non-hitl\">\n {nonHitlNotice}\n </p>\n <Button\n size=\"sm\"\n variant=\"outline\"\n disabled={pending}\n onClick={() => resume(interruptResumeDecline())}\n >\n <XIcon />\n Decline\n </Button>\n </>\n )}\n </div>\n )}\n </section>\n );\n};\n\n/**\n * What the backend resolved about a call before asking (where a Slack write\n * goes and as whom, Slack Connect warnings), above its raw arguments. Its\n * headline and summary title the card instead; with nothing else, nothing\n * renders here.\n */\nconst ApprovalContextFacts: FC<{ context: PendingApprovalContext }> = ({ context }) =>\n context.facts.length === 0 && context.warnings.length === 0 ? null : (\n <div className=\"mt-1 space-y-0.5\" data-testid=\"statewire-approval-context\">\n {context.facts.map((fact) => (\n <p key={fact.label}>\n <span className=\"font-semibold\">{fact.label}:</span> {fact.value}\n </p>\n ))}\n {context.warnings.map((warning) => (\n <p\n key={warning.message}\n className={warning.severity === 'info' ? undefined : 'font-semibold'}\n >\n {warning.message}\n </p>\n ))}\n </div>\n );\n\n/**\n * One block per gated call: its name (a batch's, or a titled call's), its\n * resolved facts, and its arguments as JSON.\n */\nconst DefaultApprovalDetails: FC<{ actionRequests: PendingActionRequest[]; showNames: boolean }> = ({\n actionRequests,\n showNames,\n}) => (\n <>\n {actionRequests.map((action, index) => (\n <div\n key={`${action.name}-${index}`}\n className=\"rounded-lg border border-border/60 bg-muted/40 p-2 text-foreground text-xs leading-relaxed\"\n >\n {showNames ? <p className=\"font-mono font-semibold\">{action.name}</p> : null}\n {action.approvalContext ? <ApprovalContextFacts context={action.approvalContext} /> : null}\n {Object.keys(action.args).length > 0 ? (\n <pre className=\"mt-1 max-h-32 overflow-auto whitespace-pre-wrap break-words rounded bg-background p-1.5 font-mono text-[11px]\">\n {JSON.stringify(action.args, null, 2)}\n </pre>\n ) : (\n <p className=\"text-muted-foreground\">No arguments.</p>\n )}\n </div>\n ))}\n </>\n);\n"],"names":["resumeValueApproves","useAuiState","hasStatewireThreadExtras","jsx","useRef","useState","useCallback","statewireRejectionDetailMessage","useStatewireApprovalRequest","useStatewireState","asHitlApproval","interruptMirrorPayload","readInterruptMirror","laneInterruptIds","pendingApprovalTitle","HITL_PENDING_RESUME_GRACE_MS","useEffect","_a","fanLaneDecision","useMemo","actionRequestToolCallIds","request","hitlResumeActionDecisions","jsxs","cn","XIcon","readInterruptMessage","canApproveForSession","hitlResumeApprove","hitlResumeApproveForSession","hitlResumeReject","Fragment","ShieldAlertIcon","ChevronDownIcon","Button","CheckIcon","CheckCheckIcon","interruptResumeDecline"],"mappings":";;;;;;;;;;;;;AAmIA,SAAS,eAAe,QAA0C;AAChE,MAAI,OAAO,SAAS,QAAS,QAAOA,WAAAA,oBAAoB,OAAO,KAAK;AACpE,QAAM,QAAQ,OAAO,OAAO,OAAO,aAAa;AAChD,SAAO,MAAM,WAAW,KAAK,MAAM,KAAKA,WAAAA,mBAAmB;AAC7D;AAGA,MAAM,gCAAmE,OAAO,OAAO,EAAE;AAuHlF,MAAM,wBAAwD,CAAC,UAAU;AAC9E,QAAM,SAASC,MAAAA,YAAY,CAAC,MAAM,EAAE,OAAO,MAAM;AACjD,MAAI,CAACC,aAAAA,yBAAyB,MAAM,EAAG,QAAO;AAC9C,SAAOC,+BAAC,4BAAA,EAA4B,GAAG,MAAA,CAAO;AAChD;AAE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F,CAAC;AAAA,EAClG;AAAA,EACA;AACF,MACEA,2BAAAA,IAAA4B,WAAAA,UAAA,EACG,UAAA,eAAe,IAAI,CAAC,QAAQ,UAC3BR,2BAAAA;AAAAA,EAAC;AAAA,EAAA;AAAA,IAEC,WAAU;AAAA,IAET,UAAA;AAAA,MAAA,2CAAa,KAAA,EAAE,WAAU,2BAA2B,UAAA,OAAO,MAAK,IAAO;AAAA,MACvE,OAAO,kBAAkBpB,2BAAAA,IAAC,wBAAqB,SAAS,OAAO,iBAAiB,IAAK;AAAA,MACrF,OAAO,KAAK,OAAO,IAAI,EAAE,SAAS,IACjCA,2BAAAA,IAAC,OAAA,EAAI,WAAU,iHACZ,eAAK,UAAU,OAAO,MAAM,MAAM,CAAC,EAAA,CACtC,IAEAA,+BAAC,KAAA,EAAE,WAAU,yBAAwB,UAAA,gBAAA,CAAa;AAAA,IAAA;AAAA,EAAA;AAAA,EAV/C,GAAG,OAAO,IAAI,IAAI,KAAK;AAY9B,CACD,GACH;;"}
1
+ {"version":3,"file":"StatewireApprovalCard.cjs","sources":["../../src/chat/StatewireApprovalCard.tsx"],"sourcesContent":["import { useAuiState } from '@assistant-ui/react';\nimport { type StatewireThread, useStatewireState } from '@assistant-ui/react-statewire';\nimport {\n actionRequestToolCallIds,\n asHitlApproval,\n fanLaneDecision,\n HITL_PENDING_RESUME_GRACE_MS,\n type HitlActionDecision,\n type HitlApprovalPayload,\n hasStatewireThreadExtras,\n hitlResumeActionDecisions,\n hitlResumeApprove,\n hitlResumeApproveForSession,\n hitlResumeReject,\n interruptResumeDecline,\n interruptMirrorPayload,\n laneInterruptIds,\n type PendingActionRequest,\n type PendingApprovalContext,\n type PendingApprovalTitle,\n pendingApprovalTitle,\n readInterruptMessage,\n readInterruptMirror,\n type ResumeExtras,\n resumeValueApproves,\n sessionApprovalLabel,\n sessionApprovalOffer,\n statewireRejectionDetailMessage,\n} from '@athenaintel/agent-runtime';\nimport {\n CheckCheckIcon,\n CheckIcon,\n ChevronDownIcon,\n ShieldAlertIcon,\n XIcon,\n} from 'lucide-react';\nimport {\n type FC,\n type ReactNode,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { cn } from '../lib/utils';\nimport { Button } from '../ui/button';\nimport {\n type StatewireInterruptPredicate,\n useStatewireApprovalRequest,\n} from './use-statewire-approval-request';\n\n/**\n * Human-in-the-loop approval card for the statewire transport — the one\n * approval UI every Athena chat surface mounts (the SDK's `AthenaChat`, the\n * Chrome side panel, the Office task pane, Olympus).\n *\n * When the deep-agent runtime hits an approval-gated tool call, the backend\n * parks the run on an `interrupt` input request. This card reads that request\n * through `useStatewireApprovalRequest` and answers it with\n * `{ type: 'run/input', requestId, response: { type: 'resume', value } }` —\n * the exact command the backend's resume path consumes. Without an answer the\n * run stays parked forever, so this card must be mounted on every statewire\n * chat surface. On legacy (non-statewire) threads it renders nothing.\n *\n * A gated call raised inside a delegated subagent parks only its lane: the\n * host mirrors that interrupt while the sibling lanes keep streaming, before\n * any input request exists. The card renders the mirrored payload the same\n * way and answers it with `run/lane-input` keyed by the lane's langgraph\n * interrupt id (`laneInterruptIds`); the host queues the decision and applies\n * it the moment the run parks, so the approver never waits on the siblings.\n * Once parked, a payload whose calls all carry interrupt ids resumes as a\n * `lane_decisions` map too — one positional `run/input` can only answer the\n * first of several parked lanes.\n *\n * Recovery of a queued decision the host never applies is ordered host\n * first: the host's answerer resumes the park or drops (and flushes) the\n * queue within `QUEUED_LANE_ANSWER_BUDGET_SECONDS` of the park, and this\n * card's grace (`HITL_PENDING_RESUME_GRACE_MS`, longer than that budget)\n * fires only when the host stayed silent. When it fires, the card that sent\n * the queued decision asks the host to replay it (`run/lane-replay` — the\n * host resumes as the approver, under the meta it recorded, and refuses any\n * other caller); every other card, and a replay the host refuses, hands the\n * decision back to a person by unlocking the actions. A queued decision is\n * never re-sent as a `run/input` of the viewing client's own: that would run\n * the approver's decision under the viewer's identity and configuration.\n *\n * A lone gated call whose resolved envelope (`approval_context`) carries a\n * headline is titled by it in the card's own review: the headline replaces\n * \"`tool` requires approval before it runs\", the summary sits under it, and\n * the default details name the tool instead. A batch keeps the generic copy,\n * since one decision answers every call. So does a host review\n * (`renderDetails`, or an editor from `renderEditor`): it shows the envelope\n * itself, headline included, so the header must not say it again. Display-only:\n * the decision row and what it sends do not change.\n *\n * Host-specific review UIs (subagent cards, email summaries) slot in through\n * `renderDetails`; a host composer that must also OWN the decision (an\n * editable email whose edits have to reach the backend) takes over the\n * details and the decision row through `renderEditor`; requests another\n * surface answers (typed interrupt families, per-lane subagent approvals)\n * stand down through `isHandledElsewhere`; viewers without edit rights see\n * `readOnlyNotice`.\n */\n\n/**\n * The answer a passkey decision check confirms before the card sends it\n * (identity 0b.9): a `run/input` resume of the parked request, or the lane\n * decisions of a `run/lane-input` sent while sibling lanes still stream.\n */\nexport type StatewireDecisionAnswer =\n | {\n readonly kind: 'input';\n readonly requestId: string;\n readonly value: StatewireThread.InputResponse;\n }\n | {\n readonly kind: 'lanes';\n readonly laneDecisions: Readonly<Record<string, StatewireThread.InputResponse>>;\n };\n\n/**\n * Runs the host's passkey check for an approving answer and resolves its\n * token, or `undefined` to send the answer without one. While checks are\n * report-only, an answer goes ahead without a check (no passkey yet, a\n * cancelled prompt); the host decides what to tell the person. Never called\n * for an answer that only rejects.\n */\nexport type StatewireDecisionConfirmer = (\n answer: StatewireDecisionAnswer,\n) => Promise<string | undefined>;\n\nfunction answerApproves(answer: StatewireDecisionAnswer): boolean {\n if (answer.kind === 'input') return resumeValueApproves(answer.value);\n const lanes = Object.values(answer.laneDecisions);\n return lanes.length === 0 || lanes.some(resumeValueApproves);\n}\n\n/** What the card reads in place of the host's queued lanes once it has given up on them. */\nconst NO_HOST_QUEUED_LANE_DECISIONS: Readonly<Record<string, unknown>> = Object.freeze({});\n\n/** The pending request a host slot renders or judges. */\nexport interface StatewireApprovalRequestContext {\n /** The parked input request — `undefined` while the run still streams (a live lane approval). */\n request: StatewireThread.CustomInputRequest | undefined;\n /** The payload narrowed to the Athena HITL approval shape, or `null` for a generic park. */\n hitl: HitlApprovalPayload | null;\n /** Every gated call the approval covers, in decision order (empty for non-HITL parks). */\n actionRequests: PendingActionRequest[];\n /**\n * The approval's title (`pendingApprovalTitle`): a lone call's envelope\n * headline and summary. Absent for a batch, a non-HITL park and a call\n * without one. The default header shows it only above the card's own\n * details; under a host review the host shows the envelope, and may lead\n * with this.\n */\n title?: PendingApprovalTitle;\n}\n\n/** The request a host editor renders, plus the decisions it may send for it. */\nexport interface StatewireApprovalEditorContext extends StatewireApprovalRequestContext {\n /** A decision is in flight (or a live lane already answered); the editor must not send another. */\n locked: boolean;\n /** Whether a session-wide approval may be offered for this batch. */\n sessionApprovalOffered: boolean;\n /**\n * What the session option's button says, naming exactly what the answer\n * covers (`sessionApprovalLabel`): \"Approve all for this session\" for\n * tools, or \"Approve for this session: only kyle@… and sam@…\" for sends\n * scoped to their recipients. Meaningful only when `sessionApprovalOffered`.\n */\n sessionApprovalLabel: string;\n approve: () => void;\n approveForSession: () => void;\n reject: (reason?: string) => void;\n /**\n * Answer each gated call on its own — the only way an EDITED call reaches\n * the backend. `decision` is asked once per call, in order, so the answer\n * always names exactly the parked calls (a partial map is refused\n * server-side and nothing runs). `null` when the batch cannot take\n * per-action answers: a call without a `tool_call_id`, or a live / multi-\n * lane approval, which resumes per lane and carries no edit.\n */\n decideEach: ((decision: (request: PendingActionRequest) => HitlActionDecision) => void) | null;\n}\n\nexport interface StatewireApprovalCardProps {\n /** Surface-styling overrides merged onto the default classes. */\n classNames?: {\n /** The approval card container. */\n root?: string;\n /** The \"approval was cancelled\" notice container. */\n abandoned?: string;\n /** The disclosed details block. */\n details?: string;\n /** The decision row. */\n actions?: string;\n };\n /** Copy shown when an interrupt payload carries no message. */\n fallbackMessage?: string;\n /**\n * Which pending interrupt this card answers. Defaults to\n * `isApprovalCardInterrupt` (client-tool parks excluded — keep it that way\n * unless the surface handles those itself).\n */\n interruptPredicate?: StatewireInterruptPredicate;\n /**\n * How long a clicked decision keeps the buttons locked when no resume run\n * ever starts (a `run/input` the host rejected before any run began).\n * Defaults to `HITL_PENDING_RESUME_GRACE_MS`.\n */\n pendingResumeGraceMs?: number;\n /**\n * Return true when another surface answers this request (a typed Athena\n * interrupt family, per-lane subagent approval cards). The card renders\n * nothing for it — two surfaces must never answer the same input request.\n */\n isHandledElsewhere?: (context: StatewireApprovalRequestContext) => boolean;\n /**\n * Replace the default argument disclosure (one JSON block per gated call)\n * with a host-specific review UI. Rendered inside the collapsible details\n * region; the decision buttons stay with the card.\n */\n renderDetails?: (context: StatewireApprovalRequestContext) => ReactNode;\n /** Replace the default approval icon and heading. Return null to keep it. */\n renderHeader?: (context: StatewireApprovalRequestContext) => ReactNode;\n /**\n * Replace BOTH the details region and the decision row with a host\n * composer that decides the request itself through the context's\n * callbacks (an editable email whose edits must be what runs). Return\n * `null`/`undefined` to keep the default card for this request. Not\n * consulted for read-only viewers or non-HITL parks.\n */\n renderEditor?: (context: StatewireApprovalEditorContext) => ReactNode;\n /**\n * The viewer may see the request (it explains why the run is parked) but\n * cannot decide it — answering steers the shared run. Renders\n * `readOnlyNotice` in place of the buttons.\n */\n readOnly?: boolean;\n readOnlyNotice?: ReactNode;\n /**\n * Copy for a park that is not a HITL approval — a typed Athena interrupt\n * this surface has no card for. The only honest action is to decline it\n * (`{ action: 'reject' }`, which every typed raiser treats as a clean user\n * decline); a generic \"Continue\" would be rejected by the raiser's resume\n * schema and surface as a tool error.\n */\n nonHitlNotice?: ReactNode;\n /**\n * The host refused a decision (or the transport lost it). The optimistic\n * fold has rolled back and the request is on screen again with its actions\n * re-enabled; this is where a host tells the user why (a toast, a log line).\n */\n onResumeRejected?: (error: unknown, requestId: string) => void;\n /**\n * The host's passkey decision check (identity 0b.9). An answer that lets\n * anything run is handed to it first and sent with the token it resolves\n * as `decisionCheck`; the decision buttons stay locked while it runs. An\n * answer that only rejects never is. Omit it and every answer is sent as\n * before, with no check.\n */\n confirmDecision?: StatewireDecisionConfirmer;\n}\n\nexport const StatewireApprovalCard: FC<StatewireApprovalCardProps> = (props) => {\n const extras = useAuiState((s) => s.thread.extras);\n if (!hasStatewireThreadExtras(extras)) return null;\n return <StatewireApprovalCardInner {...props} />;\n};\n\nconst StatewireApprovalCardInner: FC<StatewireApprovalCardProps> = ({\n classNames,\n fallbackMessage,\n interruptPredicate,\n pendingResumeGraceMs,\n isHandledElsewhere,\n renderDetails,\n renderHeader,\n renderEditor,\n readOnly = false,\n readOnlyNotice = 'Waiting for someone with edit access to respond.',\n nonHitlNotice = 'This request needs an answer this surface cannot collect.',\n onResumeRejected,\n confirmDecision,\n}) => {\n const approvalEpochRef = useRef(0);\n const [decisionFailure, setDecisionFailure] = useState<{\n requestId: string;\n message: string;\n epoch: number;\n }>();\n const reportResumeRejected = useCallback(\n (error: unknown, failedRequestId: string) => {\n setDecisionFailure({\n requestId: failedRequestId,\n message: statewireRejectionDetailMessage(error) ?? 'Your decision could not be sent. Try again.',\n epoch: approvalEpochRef.current,\n });\n onResumeRejected?.(error, failedRequestId);\n },\n [onResumeRejected],\n );\n const {\n request,\n requestId,\n hitl: parkedHitl,\n actionRequests: parkedActionRequests,\n liveHitl,\n liveActionRequests,\n queuedLaneDecisions,\n abandonedInterrupt,\n pending,\n resume,\n sendLaneDecisions,\n replayQueuedLanes,\n } = useStatewireApprovalRequest<StatewireThread.InputResponse>({\n interruptPredicate,\n pendingResumeGraceMs,\n onResumeRejected: reportResumeRejected,\n });\n // Read the host mirror: the optimistic resume fold can temporarily hide\n // `liveHitl` and the parked request without ending this approval.\n const mirroredApproval = useStatewireState(\n (state) => asHitlApproval(interruptMirrorPayload(readInterruptMirror(state))) !== null,\n );\n const approvalPresent = requestId !== undefined || mirroredApproval;\n const previousApprovalPresentRef = useRef(approvalPresent);\n if (previousApprovalPresentRef.current && !approvalPresent) approvalEpochRef.current += 1;\n previousApprovalPresentRef.current = approvalPresent;\n const [dismissedId, setDismissedId] = useState<string>();\n // The card shares the chat column with the thread. A lone gated call is\n // small enough to show inline, but a fan-out of a dozen calls would swallow\n // the conversation, so a batch starts collapsed until someone opens it.\n const [detailsOverride, setDetailsOverride] = useState<boolean>();\n // The live lanes a decision was sent for (joined ids); the buttons stay\n // locked until the host echoes them in `queuedLaneDecisions` or refuses.\n const [liveSentKey, setLiveSentKey] = useState<string>();\n // The parked request whose host-queued lanes outlived the grace window\n // (see `queuedLanesAwaitingHost` below): its queue is read as stale.\n const [staleQueuedRequestId, setStaleQueuedRequestId] = useState<string>();\n // The parked request whose queued lanes this card has asked the host to\n // replay (`run/lane-replay` in flight): locked until the host answers.\n const [replayingRequestId, setReplayingRequestId] = useState<string>();\n // The lanes THIS card decided live (its own `run/lane-input` the host\n // accepted). Only a queue this card recorded is replayed from here — the\n // host refuses any other caller, and a second editor's card must not even\n // ask. Pruned to the lanes on screen whenever a different view arrives, so\n // the record survives the live → parked transition of the same lanes (and\n // a fold that briefly shows nothing) and dies with a new request.\n const sentLaneIdsRef = useRef<Set<string>>(new Set());\n // The parked request already replayed once from here: a request is\n // replayed at most once, then the grace hands the decision back.\n const replayedRequestIdRef = useRef<string>(undefined);\n // A passkey check is running for the answer clicked here; the buttons stay\n // locked until it settles.\n const [confirming, setConfirming] = useState(false);\n // The parked request on screen now, read after a check settles: an answer\n // confirmed for a request that is no longer parked is never sent.\n const currentRequestIdRef = useRef(requestId);\n currentRequestIdRef.current = requestId;\n const confirmDecisionRef = useRef(confirmDecision);\n confirmDecisionRef.current = confirmDecision;\n\n const isLive = request === undefined && liveHitl !== null;\n const hitl = isLive ? liveHitl : parkedHitl;\n const actionRequests = isLive ? liveActionRequests : parkedActionRequests;\n const laneIds = laneInterruptIds(actionRequests);\n // The host answers the lanes it queued from its own settle path, within its\n // published budget of the park (`QUEUED_LANE_ANSWER_BUDGET_SECONDS`). A\n // parked request whose queued lanes are still unanswered past the grace\n // window has a silent answerer, and either this card asked the host to\n // replay them and was refused, or the queue is not this card's to replay —\n // so the queue no longer counts as a decision here: the actions re-enable\n // and the next click answers the parked request itself (a resume the host\n // accepts, and whose dispatch drops the stale queue).\n const hostQueuedLaneDecisions =\n requestId !== undefined && staleQueuedRequestId === requestId\n ? NO_HOST_QUEUED_LANE_DECISIONS\n : queuedLaneDecisions;\n const undecidedLaneIds =\n laneIds?.filter((id) => !(id in hostQueuedLaneDecisions)) ?? null;\n // A lone parked lane (or an unstamped batch) answers with one positional\n // `run/input`; that is the only resume the backend binds per-action answers\n // to, so it is the only place an edited call can go.\n const positional = laneIds === null || (!isLive && laneIds.length <= 1);\n const liveKey = isLive ? (laneIds?.join('|') ?? null) : null;\n const viewKey = requestId ?? liveKey ?? undefined;\n\n // A fresh approval gets the default for ITS batch size, not the disclosure\n // the previous one was left in. Reset during render via React's \"previous\n // value\" pattern.\n const prevViewKeyRef = useRef(viewKey);\n if (prevViewKeyRef.current !== viewKey) {\n prevViewKeyRef.current = viewKey;\n if (detailsOverride !== undefined) setDetailsOverride(undefined);\n if (liveSentKey !== undefined) setLiveSentKey(undefined);\n if (laneIds !== null) {\n for (const id of sentLaneIdsRef.current) {\n if (!laneIds.includes(id)) sentLaneIdsRef.current.delete(id);\n }\n }\n }\n // The per-request marks (stale queue, replayed once, replay in flight)\n // outlive the optimistic fold of a click's own `run/input`: the request\n // leaves and comes back under the SAME id when the host refuses it, and a\n // card that forgot its stale mark then would relock over the standing\n // queue for another grace, and could replay it a second time. They are\n // forgotten only for a genuinely different parked request.\n if (\n requestId !== undefined &&\n staleQueuedRequestId !== undefined &&\n requestId !== staleQueuedRequestId\n ) {\n setStaleQueuedRequestId(undefined);\n }\n if (\n requestId !== undefined &&\n replayingRequestId !== undefined &&\n requestId !== replayingRequestId\n ) {\n setReplayingRequestId(undefined);\n }\n if (\n requestId !== undefined &&\n replayedRequestIdRef.current !== undefined &&\n requestId !== replayedRequestIdRef.current\n ) {\n replayedRequestIdRef.current = undefined;\n }\n\n const title = pendingApprovalTitle({ hitl, actionRequests });\n const context: StatewireApprovalRequestContext = {\n request,\n hitl,\n actionRequests,\n ...(title ? { title } : {}),\n };\n const handledElsewhere = isHandledElsewhere?.(context) ?? false;\n const replaying = replayingRequestId !== undefined && replayingRequestId === requestId;\n\n // Parked, every lane the request covers already queued on the host, no\n // resume of our own in flight, and this card is the one that would decide\n // (not a viewer, not a request another surface owns): the host's answerer\n // is expected to resume the run within its budget. Start the clock on it,\n // longer than that budget. When it runs out the host has stayed silent: if\n // this card queued those lanes itself, it asks the host to replay them as\n // their approver (`run/lane-replay`); otherwise — and when the host refuses\n // the replay — the queue no longer counts as a decision here and the actions\n // re-enable, so a person decides. Never a `run/input` of this client's own\n // carrying someone else's recorded decision.\n const queuedLanesAwaitingHost =\n !isLive &&\n !readOnly &&\n !handledElsewhere &&\n requestId !== undefined &&\n undecidedLaneIds !== null &&\n undecidedLaneIds.length === 0 &&\n !pending &&\n !replaying;\n const queuedLaneGraceMs = pendingResumeGraceMs ?? HITL_PENDING_RESUME_GRACE_MS;\n const laneKey = laneIds?.join('|');\n const onResumeRejectedRef = useRef(reportResumeRejected);\n onResumeRejectedRef.current = reportResumeRejected;\n useEffect(() => {\n if (!queuedLanesAwaitingHost || requestId === undefined || laneKey === undefined) {\n return undefined;\n }\n const timer = setTimeout(() => {\n const ownQueue =\n laneKey.split('|').every((id) => sentLaneIdsRef.current.has(id)) &&\n replayedRequestIdRef.current !== requestId;\n if (!ownQueue) {\n setStaleQueuedRequestId(requestId);\n return;\n }\n replayedRequestIdRef.current = requestId;\n setReplayingRequestId(requestId);\n replayQueuedLanes(requestId).then(\n () => {\n setReplayingRequestId((current) => (current === requestId ? undefined : current));\n },\n (error: unknown) => {\n setReplayingRequestId((current) => (current === requestId ? undefined : current));\n setStaleQueuedRequestId(requestId);\n onResumeRejectedRef.current?.(error, requestId);\n },\n );\n }, queuedLaneGraceMs);\n return () => clearTimeout(timer);\n }, [queuedLanesAwaitingHost, requestId, laneKey, queuedLaneGraceMs, replayQueuedLanes]);\n\n /**\n * Send `answer` through `deliver`, with a passkey check first when it\n * approves and the host runs one. The check is the person's own act on\n * their device; while it is open the card is locked, and if the parked\n * request changed meanwhile the confirmed answer is dropped, never sent to\n * whatever parked next.\n */\n const withDecisionCheck = useCallback(\n (answer: StatewireDecisionAnswer, deliver: (extras?: ResumeExtras) => void) => {\n const confirmer = confirmDecisionRef.current;\n if (confirmer === undefined || !answerApproves(answer)) {\n deliver();\n return;\n }\n setConfirming(true);\n confirmer(answer)\n .catch(() => undefined)\n .then((token) => {\n setConfirming(false);\n if (answer.kind === 'input' && currentRequestIdRef.current !== answer.requestId) {\n return;\n }\n deliver(token ? { decisionCheck: token } : undefined);\n });\n },\n [],\n );\n\n // A live lane decision: the host queues it until the run parks, and holds\n // it for this card's caller, the only queue this card may ask it to replay.\n const sendLiveLanes = useCallback(\n ({\n key,\n lanes,\n epoch,\n extras,\n }: {\n key: string;\n lanes: Readonly<Record<string, StatewireThread.InputResponse>>;\n epoch: number;\n extras?: ResumeExtras;\n }) => {\n const sentLaneIds = key.split('|');\n setLiveSentKey(key);\n Promise.resolve(sendLaneDecisions(lanes, extras)).then(\n () => {\n if (epoch !== approvalEpochRef.current) return;\n for (const id of sentLaneIds) sentLaneIdsRef.current.add(id);\n },\n (error: unknown) => {\n if (epoch !== approvalEpochRef.current) return;\n setLiveSentKey((current) => (current === key ? undefined : current));\n reportResumeRejected(error, sentLaneIds[0] ?? '');\n },\n );\n },\n [sendLaneDecisions, reportResumeRejected],\n );\n\n const decide = useCallback(\n (value: Record<string, string>) => {\n setDecisionFailure(undefined);\n const epoch = approvalEpochRef.current;\n // Several parked lanes (or a live one) answer by interrupt id: a\n // positional `run/input` would resume only the first and re-park the\n // rest. A lone parked lane keeps the positional resume every host\n // already speaks.\n if (positional || undecidedLaneIds === null) {\n if (requestId === undefined) return;\n withDecisionCheck({ kind: 'input', requestId, value }, (extras) => {\n resume(value, extras);\n });\n return;\n }\n const lanes = fanLaneDecision({ interruptIds: undecidedLaneIds, decision: value });\n if (!isLive) {\n if (requestId === undefined) return;\n withDecisionCheck(\n { kind: 'input', requestId, value: { lane_decisions: lanes } },\n (extras) => {\n sendLaneDecisions(lanes, extras);\n },\n );\n return;\n }\n const key = undecidedLaneIds.join('|');\n withDecisionCheck({ kind: 'lanes', laneDecisions: lanes }, (extras) =>\n sendLiveLanes({ key, lanes, epoch, extras }),\n );\n },\n [\n positional,\n undecidedLaneIds,\n isLive,\n requestId,\n resume,\n sendLaneDecisions,\n sendLiveLanes,\n withDecisionCheck,\n ],\n );\n\n const decideEach = useMemo<StatewireApprovalEditorContext['decideEach']>(() => {\n if (actionRequestToolCallIds(actionRequests) === null || !positional) return null;\n return (decision) => {\n setDecisionFailure(undefined);\n const decisions: Record<string, HitlActionDecision> = {};\n for (const request of actionRequests) {\n if (request.toolCallId !== undefined) decisions[request.toolCallId] = decision(request);\n }\n // The edited argument set comes from the wire as JSON; the resume value\n // is that JSON going back.\n const value = hitlResumeActionDecisions(decisions) as StatewireThread.InputResponse;\n if (requestId === undefined) return;\n withDecisionCheck({ kind: 'input', requestId, value }, (extras) => {\n resume(value, extras);\n });\n };\n }, [actionRequests, positional, requestId, resume, withDecisionCheck]);\n\n if (!request && !isLive) {\n if (!abandonedInterrupt || abandonedInterrupt.id === dismissedId) return null;\n return (\n <div\n className={cn(\n 'aui-approval-abandoned flex w-full items-center justify-between gap-3 rounded-xl border border-border bg-muted/40 px-3 py-2 text-muted-foreground text-xs',\n classNames?.abandoned,\n )}\n >\n <p>Approval was cancelled — the run moved on.</p>\n <button\n type=\"button\"\n aria-label=\"Dismiss cancelled approval\"\n onClick={() => setDismissedId(abandonedInterrupt.id)}\n className=\"shrink-0 rounded-md p-1 transition-colors hover:bg-muted hover:text-foreground\"\n >\n <XIcon className=\"size-3.5\" />\n </button>\n </div>\n );\n }\n\n if (handledElsewhere) return null;\n // A live mirror without lane stamps cannot be answered before the run\n // parks; the parked request renders it then.\n if (isLive && laneIds === null) return null;\n\n const message = readInterruptMessage(request ? request.payload : liveHitl, fallbackMessage);\n const toolName = hitl?.context?.tool_name ?? hitl?.context?.tool_id;\n const pendingCount = hitl?.context?.pending_action_count ?? 1;\n const hasDetails = hitl !== null && actionRequests.length > 0;\n const showDetails = hasDetails && (detailsOverride ?? actionRequests.length <= 1);\n const sessionOffer = hitl !== null ? sessionApprovalOffer(actionRequests) : undefined;\n const sessionApprovalOffered = sessionOffer !== undefined;\n const sessionLabel = sessionOffer ? sessionApprovalLabel(sessionOffer) : '';\n const laneDecided =\n undecidedLaneIds !== null &&\n laneIds !== null &&\n (undecidedLaneIds.length === 0 || liveSentKey === undecidedLaneIds.join('|'));\n const locked = pending || laneDecided || replaying || confirming;\n\n const editor =\n !readOnly && hitl !== null && renderEditor\n ? renderEditor({\n ...context,\n locked,\n sessionApprovalOffered,\n sessionApprovalLabel: sessionLabel,\n approve: () => decide(hitlResumeApprove()),\n approveForSession: () => decide(hitlResumeApproveForSession()),\n reject: (reason) => decide(hitlResumeReject(reason)),\n decideEach,\n })\n : undefined;\n const customHeader = renderHeader?.(context);\n // Only the card's own review leads with the title: a host's details or\n // editor show the envelope themselves, headline included.\n const headerTitle = renderDetails === undefined && editor == null ? title : undefined;\n\n return (\n <section\n aria-label={hitl ? 'Approval required' : 'Input required'}\n className={cn(\n 'aui-approval-card w-full rounded-2xl border border-border bg-card px-4 py-3 text-foreground shadow-xs',\n classNames?.root,\n )}\n >\n <div className=\"flex items-start gap-3\">\n {customHeader != null ? (\n <div className=\"min-w-0 flex-1\">{customHeader}</div>\n ) : (\n <>\n <ShieldAlertIcon className=\"mt-0.5 size-4 shrink-0 text-muted-foreground\" />\n <div className=\"min-w-0 flex-1\">\n <p className=\"flex items-center gap-2 font-semibold text-sm\">\n <span>{hitl ? 'Approval required' : 'Waiting for input'}</span>\n {hitl && pendingCount > 1 ? (\n <span className=\"shrink-0 rounded-full border border-border bg-muted px-1.5 py-px font-normal text-[11px] text-muted-foreground\">\n {pendingCount} tool calls\n </span>\n ) : null}\n </p>\n {headerTitle ? (\n <>\n <p\n className=\"break-words pt-1 font-medium text-foreground text-sm leading-snug\"\n data-testid=\"statewire-approval-headline\"\n >\n {headerTitle.headline}\n </p>\n {headerTitle.summary ? (\n <p\n className=\"break-words pt-1 text-muted-foreground text-sm leading-snug\"\n data-testid=\"statewire-approval-summary\"\n >\n {headerTitle.summary}\n </p>\n ) : null}\n </>\n ) : (\n <p className=\"pt-1 text-muted-foreground text-sm leading-snug\">\n {hitl && pendingCount === 1 && toolName ? (\n <>\n <span className=\"font-mono text-foreground\">{toolName}</span> requires approval before it runs.\n </>\n ) : (\n message\n )}\n </p>\n )}\n </div>\n </>\n )}\n </div>\n {decisionFailure && decisionFailure.epoch === approvalEpochRef.current &&\n (decisionFailure.requestId === requestId || laneIds?.includes(decisionFailure.requestId)) ? (\n <p role=\"alert\" data-testid=\"statewire-approval-error\">{decisionFailure.message}</p>\n ) : null}\n {isLive ? (\n <p className=\"pt-1 text-muted-foreground text-xs\" data-testid=\"statewire-approval-live\">\n {laneDecided\n ? 'Decision sent — it applies as soon as this step pauses.'\n : 'Other work keeps running while you decide.'}\n </p>\n ) : null}\n {hasDetails && editor == null ? (\n <button\n type=\"button\"\n onClick={() => setDetailsOverride(!showDetails)}\n aria-expanded={showDetails}\n className=\"mt-2 flex items-center gap-1 rounded px-1 py-0.5 text-muted-foreground text-xs transition-colors hover:text-foreground\"\n >\n <ChevronDownIcon\n className={cn('size-3 transition-transform', showDetails && 'rotate-180')}\n />\n {showDetails ? 'Hide details' : 'Review details'}\n </button>\n ) : null}\n {/* EVERY pending gated call renders, in order — one decision\n authorizes the whole batch, so nothing may hide behind a host's\n richer cards. All read-only: this runtime resumes through\n `hitl_response_to_decisions`, which has no `tool_args` channel —\n an editable composer would let someone rewrite an email and then\n watch the original go out — unless the host takes over the\n decision too (`renderEditor`), which sends the edit per call. */}\n {editor != null ? (\n <div className={cn('mt-3 flex flex-col gap-2', classNames?.details)}>{editor}</div>\n ) : showDetails ? (\n <div className={cn('mt-2 flex flex-col gap-2', classNames?.details)}>\n {renderDetails ? (\n renderDetails(context)\n ) : (\n // A titled card no longer names its tool in the header, so its\n // details do, as a batch's do.\n <DefaultApprovalDetails\n actionRequests={actionRequests}\n showNames={actionRequests.length > 1 || headerTitle !== undefined}\n />\n )}\n </div>\n ) : null}\n {editor != null ? null : (\n <div className={cn('flex flex-wrap items-center gap-2 pt-3', classNames?.actions)}>\n {readOnly ? (\n <p className=\"text-muted-foreground text-sm\" data-testid=\"statewire-approval-read-only\">\n {readOnlyNotice}\n </p>\n ) : hitl ? (\n <>\n <Button\n size=\"sm\"\n disabled={locked}\n onClick={() => decide(hitlResumeApprove())}\n >\n <CheckIcon />\n Approve\n </Button>\n {sessionApprovalOffered ? (\n <Button\n size=\"sm\"\n variant=\"outline\"\n disabled={locked}\n onClick={() => decide(hitlResumeApproveForSession())}\n data-testid=\"statewire-approval-approve-session\"\n className=\"h-auto min-h-8 whitespace-normal py-1.5 text-left\"\n >\n <CheckCheckIcon />\n <span className=\"min-w-0 break-words\">{sessionLabel}</span>\n </Button>\n ) : null}\n <Button\n size=\"sm\"\n variant=\"outline\"\n disabled={locked}\n onClick={() => decide(hitlResumeReject())}\n >\n <XIcon />\n Reject\n </Button>\n </>\n ) : (\n <>\n <p className=\"text-muted-foreground text-sm\" data-testid=\"statewire-approval-non-hitl\">\n {nonHitlNotice}\n </p>\n <Button\n size=\"sm\"\n variant=\"outline\"\n disabled={pending}\n onClick={() => resume(interruptResumeDecline())}\n >\n <XIcon />\n Decline\n </Button>\n </>\n )}\n </div>\n )}\n </section>\n );\n};\n\n/**\n * What the backend resolved about a call before asking (where a Slack write\n * goes and as whom, Slack Connect warnings), above its raw arguments. Its\n * headline and summary title the card instead; with nothing else, nothing\n * renders here.\n */\nconst ApprovalContextFacts: FC<{ context: PendingApprovalContext }> = ({ context }) =>\n context.facts.length === 0 && context.warnings.length === 0 ? null : (\n <div className=\"mt-1 space-y-0.5\" data-testid=\"statewire-approval-context\">\n {context.facts.map((fact) => (\n <p key={fact.label}>\n <span className=\"font-semibold\">{fact.label}:</span> {fact.value}\n </p>\n ))}\n {context.warnings.map((warning) => (\n <p\n key={warning.message}\n className={warning.severity === 'info' ? undefined : 'font-semibold'}\n >\n {warning.message}\n </p>\n ))}\n </div>\n );\n\n/**\n * One block per gated call: its name (a batch's, or a titled call's), its\n * resolved facts, and its arguments as JSON.\n */\nconst DefaultApprovalDetails: FC<{ actionRequests: PendingActionRequest[]; showNames: boolean }> = ({\n actionRequests,\n showNames,\n}) => (\n <>\n {actionRequests.map((action, index) => (\n <div\n key={`${action.name}-${index}`}\n className=\"rounded-lg border border-border/60 bg-muted/40 p-2 text-foreground text-xs leading-relaxed\"\n >\n {showNames ? <p className=\"font-mono font-semibold\">{action.name}</p> : null}\n {action.approvalContext ? <ApprovalContextFacts context={action.approvalContext} /> : null}\n {Object.keys(action.args).length > 0 ? (\n <pre className=\"mt-1 max-h-32 overflow-auto whitespace-pre-wrap break-words rounded bg-background p-1.5 font-mono text-[11px]\">\n {JSON.stringify(action.args, null, 2)}\n </pre>\n ) : (\n <p className=\"text-muted-foreground\">No arguments.</p>\n )}\n </div>\n ))}\n </>\n);\n"],"names":["resumeValueApproves","useAuiState","hasStatewireThreadExtras","jsx","useRef","useState","useCallback","statewireRejectionDetailMessage","useStatewireApprovalRequest","useStatewireState","asHitlApproval","interruptMirrorPayload","readInterruptMirror","laneInterruptIds","pendingApprovalTitle","HITL_PENDING_RESUME_GRACE_MS","useEffect","_a","fanLaneDecision","useMemo","actionRequestToolCallIds","request","hitlResumeActionDecisions","jsxs","cn","XIcon","readInterruptMessage","sessionApprovalOffer","sessionApprovalLabel","hitlResumeApprove","hitlResumeApproveForSession","hitlResumeReject","Fragment","ShieldAlertIcon","ChevronDownIcon","Button","CheckIcon","CheckCheckIcon","interruptResumeDecline"],"mappings":";;;;;;;;;;;;;AAoIA,SAAS,eAAe,QAA0C;AAChE,MAAI,OAAO,SAAS,QAAS,QAAOA,WAAAA,oBAAoB,OAAO,KAAK;AACpE,QAAM,QAAQ,OA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AAC,SAAI,WAAU,oBAAmB,eAAY,8BAC3C,UAAA;AAAA,EAAA,QAAQ,MAAM,IAAI,CAAC,yCACjB,KAAA,EACC,UAAA;AAAA,IAAAA,2BAAAA,KAAC,QAAA,EAAK,WAAU,iBAAiB,UAAA;AAAA,MAAA,KAAK;AAAA,MAAM;AAAA,IAAA,GAAC;AAAA,IAAO;AAAA,IAAE,KAAK;AAAA,EAAA,KADrD,KAAK,KAEb,CACD;AAAA,EACA,QAAQ,SAAS,IAAI,CAAC,YACrBpB,2BAAAA;AAAAA,IAAC;AAAA,IAAA;AAAA,MAEC,WAAW,QAAQ,aAAa,SAAS,SAAY;AAAA,MAEpD,UAAA,QAAQ;AAAA,IAAA;AAAA,IAHJ,QAAQ;AAAA,EAAA,CAKhB;AAAA,GACH;AAOJ,MAAM,yBAA6F,CAAC;AAAA,EAClG;AAAA,EACA;AACF,MACEA,2BAAAA,IAAA6B,WAAAA,UAAA,EACG,UAAA,eAAe,IAAI,CAAC,QAAQ,UAC3BT,2BAAAA;AAAAA,EAAC;AAAA,EAAA;AAAA,IAEC,WAAU;AAAA,IAET,UAAA;AAAA,MAAA,2CAAa,KAAA,EAAE,WAAU,2BAA2B,UAAA,OAAO,MAAK,IAAO;AAAA,MACvE,OAAO,kBAAkBpB,2BAAAA,IAAC,wBAAqB,SAAS,OAAO,iBAAiB,IAAK;AAAA,MACrF,OAAO,KAAK,OAAO,IAAI,EAAE,SAAS,IACjCA,2BAAAA,IAAC,OAAA,EAAI,WAAU,iHACZ,eAAK,UAAU,OAAO,MAAM,MAAM,CAAC,EAAA,CACtC,IAEAA,+BAAC,KAAA,EAAE,WAAU,yBAAwB,UAAA,gBAAA,CAAa;AAAA,IAAA;AAAA,EAAA;AAAA,EAV/C,GAAG,OAAO,IAAI,IAAI,KAAK;AAY9B,CACD,GACH;;"}
@@ -96,8 +96,15 @@ export interface StatewireApprovalRequestContext {
96
96
  export interface StatewireApprovalEditorContext extends StatewireApprovalRequestContext {
97
97
  /** A decision is in flight (or a live lane already answered); the editor must not send another. */
98
98
  locked: boolean;
99
- /** Whether "approve all for this session" may be offered for this batch. */
99
+ /** Whether a session-wide approval may be offered for this batch. */
100
100
  sessionApprovalOffered: boolean;
101
+ /**
102
+ * What the session option's button says, naming exactly what the answer
103
+ * covers (`sessionApprovalLabel`): "Approve all for this session" for
104
+ * tools, or "Approve for this session: only kyle@… and sam@…" for sends
105
+ * scoped to their recipients. Meaningful only when `sessionApprovalOffered`.
106
+ */
107
+ sessionApprovalLabel: string;
101
108
  approve: () => void;
102
109
  approveForSession: () => void;
103
110
  reject: (reason?: string) => void;
@@ -7,7 +7,7 @@ import { Button } from "../ui/button.js";
7
7
  import { useStatewireApprovalRequest } from "./use-statewire-approval-request.js";
8
8
  import { hasStatewireThreadExtras } from "../agent-runtime/src/thread-extras.js";
9
9
  import { statewireRejectionDetailMessage } from "../agent-runtime/src/errors.js";
10
- import { asHitlApproval, interruptMirrorPayload, readInterruptMirror, laneInterruptIds, pendingApprovalTitle, HITL_PENDING_RESUME_GRACE_MS, fanLaneDecision, actionRequestToolCallIds, hitlResumeActionDecisions, readInterruptMessage, canApproveForSession, hitlResumeReject, hitlResumeApproveForSession, hitlResumeApprove, interruptResumeDecline, resumeValueApproves } from "../agent-runtime/src/interrupts.js";
10
+ import { asHitlApproval, interruptMirrorPayload, readInterruptMirror, laneInterruptIds, pendingApprovalTitle, HITL_PENDING_RESUME_GRACE_MS, fanLaneDecision, actionRequestToolCallIds, hitlResumeActionDecisions, readInterruptMessage, sessionApprovalOffer, sessionApprovalLabel, hitlResumeReject, hitlResumeApproveForSession, hitlResumeApprove, interruptResumeDecline, resumeValueApproves } from "../agent-runtime/src/interrupts.js";
11
11
  import { cn } from "cnfast";
12
12
  function answerApproves(answer) {
13
13
  if (answer.kind === "input") return resumeValueApproves(answer.value);
@@ -282,13 +282,16 @@ const StatewireApprovalCardInner = ({
282
282
  const pendingCount = ((_c = hitl == null ? void 0 : hitl.context) == null ? void 0 : _c.pending_action_count) ?? 1;
283
283
  const hasDetails = hitl !== null && actionRequests.length > 0;
284
284
  const showDetails = hasDetails && (detailsOverride ?? actionRequests.length <= 1);
285
- const sessionApprovalOffered = hitl !== null && canApproveForSession(actionRequests);
285
+ const sessionOffer = hitl !== null ? sessionApprovalOffer(actionRequests) : void 0;
286
+ const sessionApprovalOffered = sessionOffer !== void 0;
287
+ const sessionLabel = sessionOffer ? sessionApprovalLabel(sessionOffer) : "";
286
288
  const laneDecided = undecidedLaneIds !== null && laneIds !== null && (undecidedLaneIds.length === 0 || liveSentKey === undecidedLaneIds.join("|"));
287
289
  const locked = pending || laneDecided || replaying || confirming;
288
290
  const editor = !readOnly && hitl !== null && renderEditor ? renderEditor({
289
291
  ...context,
290
292
  locked,
291
293
  sessionApprovalOffered,
294
+ sessionApprovalLabel: sessionLabel,
292
295
  approve: () => decide(hitlResumeApprove()),
293
296
  approveForSession: () => decide(hitlResumeApproveForSession()),
294
297
  reject: (reason) => decide(hitlResumeReject(reason)),
@@ -390,9 +393,10 @@ const StatewireApprovalCardInner = ({
390
393
  disabled: locked,
391
394
  onClick: () => decide(hitlResumeApproveForSession()),
392
395
  "data-testid": "statewire-approval-approve-session",
396
+ className: "h-auto min-h-8 whitespace-normal py-1.5 text-left",
393
397
  children: [
394
398
  /* @__PURE__ */ jsx(CheckCheckIcon, {}),
395
- "Approve all for this session"
399
+ /* @__PURE__ */ jsx("span", { className: "min-w-0 break-words", children: sessionLabel })
396
400
  ]
397
401
  }
398
402
  ) : null,
@@ -1 +1 @@
1
- {"version":3,"file":"StatewireApprovalCard.js","sources":["../../src/chat/StatewireApprovalCard.tsx"],"sourcesContent":["import { useAuiState } from '@assistant-ui/react';\nimport { type StatewireThread, useStatewireState } from '@assistant-ui/react-statewire';\nimport {\n actionRequestToolCallIds,\n asHitlApproval,\n canApproveForSession,\n fanLaneDecision,\n HITL_PENDING_RESUME_GRACE_MS,\n type HitlActionDecision,\n type HitlApprovalPayload,\n hasStatewireThreadExtras,\n hitlResumeActionDecisions,\n hitlResumeApprove,\n hitlResumeApproveForSession,\n hitlResumeReject,\n interruptResumeDecline,\n interruptMirrorPayload,\n laneInterruptIds,\n type PendingActionRequest,\n type PendingApprovalContext,\n type PendingApprovalTitle,\n pendingApprovalTitle,\n readInterruptMessage,\n readInterruptMirror,\n type ResumeExtras,\n resumeValueApproves,\n statewireRejectionDetailMessage,\n} from '@athenaintel/agent-runtime';\nimport {\n CheckCheckIcon,\n CheckIcon,\n ChevronDownIcon,\n ShieldAlertIcon,\n XIcon,\n} from 'lucide-react';\nimport {\n type FC,\n type ReactNode,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { cn } from '../lib/utils';\nimport { Button } from '../ui/button';\nimport {\n type StatewireInterruptPredicate,\n useStatewireApprovalRequest,\n} from './use-statewire-approval-request';\n\n/**\n * Human-in-the-loop approval card for the statewire transport — the one\n * approval UI every Athena chat surface mounts (the SDK's `AthenaChat`, the\n * Chrome side panel, the Office task pane, Olympus).\n *\n * When the deep-agent runtime hits an approval-gated tool call, the backend\n * parks the run on an `interrupt` input request. This card reads that request\n * through `useStatewireApprovalRequest` and answers it with\n * `{ type: 'run/input', requestId, response: { type: 'resume', value } }` —\n * the exact command the backend's resume path consumes. Without an answer the\n * run stays parked forever, so this card must be mounted on every statewire\n * chat surface. On legacy (non-statewire) threads it renders nothing.\n *\n * A gated call raised inside a delegated subagent parks only its lane: the\n * host mirrors that interrupt while the sibling lanes keep streaming, before\n * any input request exists. The card renders the mirrored payload the same\n * way and answers it with `run/lane-input` keyed by the lane's langgraph\n * interrupt id (`laneInterruptIds`); the host queues the decision and applies\n * it the moment the run parks, so the approver never waits on the siblings.\n * Once parked, a payload whose calls all carry interrupt ids resumes as a\n * `lane_decisions` map too — one positional `run/input` can only answer the\n * first of several parked lanes.\n *\n * Recovery of a queued decision the host never applies is ordered host\n * first: the host's answerer resumes the park or drops (and flushes) the\n * queue within `QUEUED_LANE_ANSWER_BUDGET_SECONDS` of the park, and this\n * card's grace (`HITL_PENDING_RESUME_GRACE_MS`, longer than that budget)\n * fires only when the host stayed silent. When it fires, the card that sent\n * the queued decision asks the host to replay it (`run/lane-replay` — the\n * host resumes as the approver, under the meta it recorded, and refuses any\n * other caller); every other card, and a replay the host refuses, hands the\n * decision back to a person by unlocking the actions. A queued decision is\n * never re-sent as a `run/input` of the viewing client's own: that would run\n * the approver's decision under the viewer's identity and configuration.\n *\n * A lone gated call whose resolved envelope (`approval_context`) carries a\n * headline is titled by it in the card's own review: the headline replaces\n * \"`tool` requires approval before it runs\", the summary sits under it, and\n * the default details name the tool instead. A batch keeps the generic copy,\n * since one decision answers every call. So does a host review\n * (`renderDetails`, or an editor from `renderEditor`): it shows the envelope\n * itself, headline included, so the header must not say it again. Display-only:\n * the decision row and what it sends do not change.\n *\n * Host-specific review UIs (subagent cards, email summaries) slot in through\n * `renderDetails`; a host composer that must also OWN the decision (an\n * editable email whose edits have to reach the backend) takes over the\n * details and the decision row through `renderEditor`; requests another\n * surface answers (typed interrupt families, per-lane subagent approvals)\n * stand down through `isHandledElsewhere`; viewers without edit rights see\n * `readOnlyNotice`.\n */\n\n/**\n * The answer a passkey decision check confirms before the card sends it\n * (identity 0b.9): a `run/input` resume of the parked request, or the lane\n * decisions of a `run/lane-input` sent while sibling lanes still stream.\n */\nexport type StatewireDecisionAnswer =\n | {\n readonly kind: 'input';\n readonly requestId: string;\n readonly value: StatewireThread.InputResponse;\n }\n | {\n readonly kind: 'lanes';\n readonly laneDecisions: Readonly<Record<string, StatewireThread.InputResponse>>;\n };\n\n/**\n * Runs the host's passkey check for an approving answer and resolves its\n * token, or `undefined` to send the answer without one. While checks are\n * report-only, an answer goes ahead without a check (no passkey yet, a\n * cancelled prompt); the host decides what to tell the person. Never called\n * for an answer that only rejects.\n */\nexport type StatewireDecisionConfirmer = (\n answer: StatewireDecisionAnswer,\n) => Promise<string | undefined>;\n\nfunction answerApproves(answer: StatewireDecisionAnswer): boolean {\n if (answer.kind === 'input') return resumeValueApproves(answer.value);\n const lanes = Object.values(answer.laneDecisions);\n return lanes.length === 0 || lanes.some(resumeValueApproves);\n}\n\n/** What the card reads in place of the host's queued lanes once it has given up on them. */\nconst NO_HOST_QUEUED_LANE_DECISIONS: Readonly<Record<string, unknown>> = Object.freeze({});\n\n/** The pending request a host slot renders or judges. */\nexport interface StatewireApprovalRequestContext {\n /** The parked input request — `undefined` while the run still streams (a live lane approval). */\n request: StatewireThread.CustomInputRequest | undefined;\n /** The payload narrowed to the Athena HITL approval shape, or `null` for a generic park. */\n hitl: HitlApprovalPayload | null;\n /** Every gated call the approval covers, in decision order (empty for non-HITL parks). */\n actionRequests: PendingActionRequest[];\n /**\n * The approval's title (`pendingApprovalTitle`): a lone call's envelope\n * headline and summary. Absent for a batch, a non-HITL park and a call\n * without one. The default header shows it only above the card's own\n * details; under a host review the host shows the envelope, and may lead\n * with this.\n */\n title?: PendingApprovalTitle;\n}\n\n/** The request a host editor renders, plus the decisions it may send for it. */\nexport interface StatewireApprovalEditorContext extends StatewireApprovalRequestContext {\n /** A decision is in flight (or a live lane already answered); the editor must not send another. */\n locked: boolean;\n /** Whether \"approve all for this session\" may be offered for this batch. */\n sessionApprovalOffered: boolean;\n approve: () => void;\n approveForSession: () => void;\n reject: (reason?: string) => void;\n /**\n * Answer each gated call on its own — the only way an EDITED call reaches\n * the backend. `decision` is asked once per call, in order, so the answer\n * always names exactly the parked calls (a partial map is refused\n * server-side and nothing runs). `null` when the batch cannot take\n * per-action answers: a call without a `tool_call_id`, or a live / multi-\n * lane approval, which resumes per lane and carries no edit.\n */\n decideEach: ((decision: (request: PendingActionRequest) => HitlActionDecision) => void) | null;\n}\n\nexport interface StatewireApprovalCardProps {\n /** Surface-styling overrides merged onto the default classes. */\n classNames?: {\n /** The approval card container. */\n root?: string;\n /** The \"approval was cancelled\" notice container. */\n abandoned?: string;\n /** The disclosed details block. */\n details?: string;\n /** The decision row. */\n actions?: string;\n };\n /** Copy shown when an interrupt payload carries no message. */\n fallbackMessage?: string;\n /**\n * Which pending interrupt this card answers. Defaults to\n * `isApprovalCardInterrupt` (client-tool parks excluded — keep it that way\n * unless the surface handles those itself).\n */\n interruptPredicate?: StatewireInterruptPredicate;\n /**\n * How long a clicked decision keeps the buttons locked when no resume run\n * ever starts (a `run/input` the host rejected before any run began).\n * Defaults to `HITL_PENDING_RESUME_GRACE_MS`.\n */\n pendingResumeGraceMs?: number;\n /**\n * Return true when another surface answers this request (a typed Athena\n * interrupt family, per-lane subagent approval cards). The card renders\n * nothing for it — two surfaces must never answer the same input request.\n */\n isHandledElsewhere?: (context: StatewireApprovalRequestContext) => boolean;\n /**\n * Replace the default argument disclosure (one JSON block per gated call)\n * with a host-specific review UI. Rendered inside the collapsible details\n * region; the decision buttons stay with the card.\n */\n renderDetails?: (context: StatewireApprovalRequestContext) => ReactNode;\n /** Replace the default approval icon and heading. Return null to keep it. */\n renderHeader?: (context: StatewireApprovalRequestContext) => ReactNode;\n /**\n * Replace BOTH the details region and the decision row with a host\n * composer that decides the request itself through the context's\n * callbacks (an editable email whose edits must be what runs). Return\n * `null`/`undefined` to keep the default card for this request. Not\n * consulted for read-only viewers or non-HITL parks.\n */\n renderEditor?: (context: StatewireApprovalEditorContext) => ReactNode;\n /**\n * The viewer may see the request (it explains why the run is parked) but\n * cannot decide it — answering steers the shared run. Renders\n * `readOnlyNotice` in place of the buttons.\n */\n readOnly?: boolean;\n readOnlyNotice?: ReactNode;\n /**\n * Copy for a park that is not a HITL approval — a typed Athena interrupt\n * this surface has no card for. The only honest action is to decline it\n * (`{ action: 'reject' }`, which every typed raiser treats as a clean user\n * decline); a generic \"Continue\" would be rejected by the raiser's resume\n * schema and surface as a tool error.\n */\n nonHitlNotice?: ReactNode;\n /**\n * The host refused a decision (or the transport lost it). The optimistic\n * fold has rolled back and the request is on screen again with its actions\n * re-enabled; this is where a host tells the user why (a toast, a log line).\n */\n onResumeRejected?: (error: unknown, requestId: string) => void;\n /**\n * The host's passkey decision check (identity 0b.9). An answer that lets\n * anything run is handed to it first and sent with the token it resolves\n * as `decisionCheck`; the decision buttons stay locked while it runs. An\n * answer that only rejects never is. Omit it and every answer is sent as\n * before, with no check.\n */\n confirmDecision?: StatewireDecisionConfirmer;\n}\n\nexport const StatewireApprovalCard: FC<StatewireApprovalCardProps> = (props) => {\n const extras = useAuiState((s) => s.thread.extras);\n if (!hasStatewireThreadExtras(extras)) return null;\n return <StatewireApprovalCardInner {...props} />;\n};\n\nconst StatewireApprovalCardInner: FC<StatewireApprovalCardProps> = ({\n classNames,\n fallbackMessage,\n interruptPredicate,\n pendingResumeGraceMs,\n isHandledElsewhere,\n renderDetails,\n renderHeader,\n renderEditor,\n readOnly = false,\n readOnlyNotice = 'Waiting for someone with edit access to respond.',\n nonHitlNotice = 'This request needs an answer this surface cannot collect.',\n onResumeRejected,\n confirmDecision,\n}) => {\n const approvalEpochRef = useRef(0);\n const [decisionFailure, setDecisionFailure] = useState<{\n requestId: string;\n message: string;\n epoch: number;\n }>();\n const reportResumeRejected = useCallback(\n (error: unknown, failedRequestId: string) => {\n setDecisionFailure({\n requestId: failedRequestId,\n message: statewireRejectionDetailMessage(error) ?? 'Your decision could not be sent. Try again.',\n epoch: approvalEpochRef.current,\n });\n onResumeRejected?.(error, failedRequestId);\n },\n [onResumeRejected],\n );\n const {\n request,\n requestId,\n hitl: parkedHitl,\n actionRequests: parkedActionRequests,\n liveHitl,\n liveActionRequests,\n queuedLaneDecisions,\n abandonedInterrupt,\n pending,\n resume,\n sendLaneDecisions,\n replayQueuedLanes,\n } = useStatewireApprovalRequest<StatewireThread.InputResponse>({\n interruptPredicate,\n pendingResumeGraceMs,\n onResumeRejected: reportResumeRejected,\n });\n // Read the host mirror: the optimistic resume fold can temporarily hide\n // `liveHitl` and the parked request without ending this approval.\n const mirroredApproval = useStatewireState(\n (state) => asHitlApproval(interruptMirrorPayload(readInterruptMirror(state))) !== null,\n );\n const approvalPresent = requestId !== undefined || mirroredApproval;\n const previousApprovalPresentRef = useRef(approvalPresent);\n if (previousApprovalPresentRef.current && !approvalPresent) approvalEpochRef.current += 1;\n previousApprovalPresentRef.current = approvalPresent;\n const [dismissedId, setDismissedId] = useState<string>();\n // The card shares the chat column with the thread. A lone gated call is\n // small enough to show inline, but a fan-out of a dozen calls would swallow\n // the conversation, so a batch starts collapsed until someone opens it.\n const [detailsOverride, setDetailsOverride] = useState<boolean>();\n // The live lanes a decision was sent for (joined ids); the buttons stay\n // locked until the host echoes them in `queuedLaneDecisions` or refuses.\n const [liveSentKey, setLiveSentKey] = useState<string>();\n // The parked request whose host-queued lanes outlived the grace window\n // (see `queuedLanesAwaitingHost` below): its queue is read as stale.\n const [staleQueuedRequestId, setStaleQueuedRequestId] = useState<string>();\n // The parked request whose queued lanes this card has asked the host to\n // replay (`run/lane-replay` in flight): locked until the host answers.\n const [replayingRequestId, setReplayingRequestId] = useState<string>();\n // The lanes THIS card decided live (its own `run/lane-input` the host\n // accepted). Only a queue this card recorded is replayed from here — the\n // host refuses any other caller, and a second editor's card must not even\n // ask. Pruned to the lanes on screen whenever a different view arrives, so\n // the record survives the live → parked transition of the same lanes (and\n // a fold that briefly shows nothing) and dies with a new request.\n const sentLaneIdsRef = useRef<Set<string>>(new Set());\n // The parked request already replayed once from here: a request is\n // replayed at most once, then the grace hands the decision back.\n const replayedRequestIdRef = useRef<string>(undefined);\n // A passkey check is running for the answer clicked here; the buttons stay\n // locked until it settles.\n const [confirming, setConfirming] = useState(false);\n // The parked request on screen now, read after a check settles: an answer\n // confirmed for a request that is no longer parked is never sent.\n const currentRequestIdRef = useRef(requestId);\n currentRequestIdRef.current = requestId;\n const confirmDecisionRef = useRef(confirmDecision);\n confirmDecisionRef.current = confirmDecision;\n\n const isLive = request === undefined && liveHitl !== null;\n const hitl = isLive ? liveHitl : parkedHitl;\n const actionRequests = isLive ? liveActionRequests : parkedActionRequests;\n const laneIds = laneInterruptIds(actionRequests);\n // The host answers the lanes it queued from its own settle path, within its\n // published budget of the park (`QUEUED_LANE_ANSWER_BUDGET_SECONDS`). A\n // parked request whose queued lanes are still unanswered past the grace\n // window has a silent answerer, and either this card asked the host to\n // replay them and was refused, or the queue is not this card's to replay —\n // so the queue no longer counts as a decision here: the actions re-enable\n // and the next click answers the parked request itself (a resume the host\n // accepts, and whose dispatch drops the stale queue).\n const hostQueuedLaneDecisions =\n requestId !== undefined && staleQueuedRequestId === requestId\n ? NO_HOST_QUEUED_LANE_DECISIONS\n : queuedLaneDecisions;\n const undecidedLaneIds =\n laneIds?.filter((id) => !(id in hostQueuedLaneDecisions)) ?? null;\n // A lone parked lane (or an unstamped batch) answers with one positional\n // `run/input`; that is the only resume the backend binds per-action answers\n // to, so it is the only place an edited call can go.\n const positional = laneIds === null || (!isLive && laneIds.length <= 1);\n const liveKey = isLive ? (laneIds?.join('|') ?? null) : null;\n const viewKey = requestId ?? liveKey ?? undefined;\n\n // A fresh approval gets the default for ITS batch size, not the disclosure\n // the previous one was left in. Reset during render via React's \"previous\n // value\" pattern.\n const prevViewKeyRef = useRef(viewKey);\n if (prevViewKeyRef.current !== viewKey) {\n prevViewKeyRef.current = viewKey;\n if (detailsOverride !== undefined) setDetailsOverride(undefined);\n if (liveSentKey !== undefined) setLiveSentKey(undefined);\n if (laneIds !== null) {\n for (const id of sentLaneIdsRef.current) {\n if (!laneIds.includes(id)) sentLaneIdsRef.current.delete(id);\n }\n }\n }\n // The per-request marks (stale queue, replayed once, replay in flight)\n // outlive the optimistic fold of a click's own `run/input`: the request\n // leaves and comes back under the SAME id when the host refuses it, and a\n // card that forgot its stale mark then would relock over the standing\n // queue for another grace, and could replay it a second time. They are\n // forgotten only for a genuinely different parked request.\n if (\n requestId !== undefined &&\n staleQueuedRequestId !== undefined &&\n requestId !== staleQueuedRequestId\n ) {\n setStaleQueuedRequestId(undefined);\n }\n if (\n requestId !== undefined &&\n replayingRequestId !== undefined &&\n requestId !== replayingRequestId\n ) {\n setReplayingRequestId(undefined);\n }\n if (\n requestId !== undefined &&\n replayedRequestIdRef.current !== undefined &&\n requestId !== replayedRequestIdRef.current\n ) {\n replayedRequestIdRef.current = undefined;\n }\n\n const title = pendingApprovalTitle({ hitl, actionRequests });\n const context: StatewireApprovalRequestContext = {\n request,\n hitl,\n actionRequests,\n ...(title ? { title } : {}),\n };\n const handledElsewhere = isHandledElsewhere?.(context) ?? false;\n const replaying = replayingRequestId !== undefined && replayingRequestId === requestId;\n\n // Parked, every lane the request covers already queued on the host, no\n // resume of our own in flight, and this card is the one that would decide\n // (not a viewer, not a request another surface owns): the host's answerer\n // is expected to resume the run within its budget. Start the clock on it,\n // longer than that budget. When it runs out the host has stayed silent: if\n // this card queued those lanes itself, it asks the host to replay them as\n // their approver (`run/lane-replay`); otherwise — and when the host refuses\n // the replay — the queue no longer counts as a decision here and the actions\n // re-enable, so a person decides. Never a `run/input` of this client's own\n // carrying someone else's recorded decision.\n const queuedLanesAwaitingHost =\n !isLive &&\n !readOnly &&\n !handledElsewhere &&\n requestId !== undefined &&\n undecidedLaneIds !== null &&\n undecidedLaneIds.length === 0 &&\n !pending &&\n !replaying;\n const queuedLaneGraceMs = pendingResumeGraceMs ?? HITL_PENDING_RESUME_GRACE_MS;\n const laneKey = laneIds?.join('|');\n const onResumeRejectedRef = useRef(reportResumeRejected);\n onResumeRejectedRef.current = reportResumeRejected;\n useEffect(() => {\n if (!queuedLanesAwaitingHost || requestId === undefined || laneKey === undefined) {\n return undefined;\n }\n const timer = setTimeout(() => {\n const ownQueue =\n laneKey.split('|').every((id) => sentLaneIdsRef.current.has(id)) &&\n replayedRequestIdRef.current !== requestId;\n if (!ownQueue) {\n setStaleQueuedRequestId(requestId);\n return;\n }\n replayedRequestIdRef.current = requestId;\n setReplayingRequestId(requestId);\n replayQueuedLanes(requestId).then(\n () => {\n setReplayingRequestId((current) => (current === requestId ? undefined : current));\n },\n (error: unknown) => {\n setReplayingRequestId((current) => (current === requestId ? undefined : current));\n setStaleQueuedRequestId(requestId);\n onResumeRejectedRef.current?.(error, requestId);\n },\n );\n }, queuedLaneGraceMs);\n return () => clearTimeout(timer);\n }, [queuedLanesAwaitingHost, requestId, laneKey, queuedLaneGraceMs, replayQueuedLanes]);\n\n /**\n * Send `answer` through `deliver`, with a passkey check first when it\n * approves and the host runs one. The check is the person's own act on\n * their device; while it is open the card is locked, and if the parked\n * request changed meanwhile the confirmed answer is dropped, never sent to\n * whatever parked next.\n */\n const withDecisionCheck = useCallback(\n (answer: StatewireDecisionAnswer, deliver: (extras?: ResumeExtras) => void) => {\n const confirmer = confirmDecisionRef.current;\n if (confirmer === undefined || !answerApproves(answer)) {\n deliver();\n return;\n }\n setConfirming(true);\n confirmer(answer)\n .catch(() => undefined)\n .then((token) => {\n setConfirming(false);\n if (answer.kind === 'input' && currentRequestIdRef.current !== answer.requestId) {\n return;\n }\n deliver(token ? { decisionCheck: token } : undefined);\n });\n },\n [],\n );\n\n // A live lane decision: the host queues it until the run parks, and holds\n // it for this card's caller, the only queue this card may ask it to replay.\n const sendLiveLanes = useCallback(\n ({\n key,\n lanes,\n epoch,\n extras,\n }: {\n key: string;\n lanes: Readonly<Record<string, StatewireThread.InputResponse>>;\n epoch: number;\n extras?: ResumeExtras;\n }) => {\n const sentLaneIds = key.split('|');\n setLiveSentKey(key);\n Promise.resolve(sendLaneDecisions(lanes, extras)).then(\n () => {\n if (epoch !== approvalEpochRef.current) return;\n for (const id of sentLaneIds) sentLaneIdsRef.current.add(id);\n },\n (error: unknown) => {\n if (epoch !== approvalEpochRef.current) return;\n setLiveSentKey((current) => (current === key ? undefined : current));\n reportResumeRejected(error, sentLaneIds[0] ?? '');\n },\n );\n },\n [sendLaneDecisions, reportResumeRejected],\n );\n\n const decide = useCallback(\n (value: Record<string, string>) => {\n setDecisionFailure(undefined);\n const epoch = approvalEpochRef.current;\n // Several parked lanes (or a live one) answer by interrupt id: a\n // positional `run/input` would resume only the first and re-park the\n // rest. A lone parked lane keeps the positional resume every host\n // already speaks.\n if (positional || undecidedLaneIds === null) {\n if (requestId === undefined) return;\n withDecisionCheck({ kind: 'input', requestId, value }, (extras) => {\n resume(value, extras);\n });\n return;\n }\n const lanes = fanLaneDecision({ interruptIds: undecidedLaneIds, decision: value });\n if (!isLive) {\n if (requestId === undefined) return;\n withDecisionCheck(\n { kind: 'input', requestId, value: { lane_decisions: lanes } },\n (extras) => {\n sendLaneDecisions(lanes, extras);\n },\n );\n return;\n }\n const key = undecidedLaneIds.join('|');\n withDecisionCheck({ kind: 'lanes', laneDecisions: lanes }, (extras) =>\n sendLiveLanes({ key, lanes, epoch, extras }),\n );\n },\n [\n positional,\n undecidedLaneIds,\n isLive,\n requestId,\n resume,\n sendLaneDecisions,\n sendLiveLanes,\n withDecisionCheck,\n ],\n );\n\n const decideEach = useMemo<StatewireApprovalEditorContext['decideEach']>(() => {\n if (actionRequestToolCallIds(actionRequests) === null || !positional) return null;\n return (decision) => {\n setDecisionFailure(undefined);\n const decisions: Record<string, HitlActionDecision> = {};\n for (const request of actionRequests) {\n if (request.toolCallId !== undefined) decisions[request.toolCallId] = decision(request);\n }\n // The edited argument set comes from the wire as JSON; the resume value\n // is that JSON going back.\n const value = hitlResumeActionDecisions(decisions) as StatewireThread.InputResponse;\n if (requestId === undefined) return;\n withDecisionCheck({ kind: 'input', requestId, value }, (extras) => {\n resume(value, extras);\n });\n };\n }, [actionRequests, positional, requestId, resume, withDecisionCheck]);\n\n if (!request && !isLive) {\n if (!abandonedInterrupt || abandonedInterrupt.id === dismissedId) return null;\n return (\n <div\n className={cn(\n 'aui-approval-abandoned flex w-full items-center justify-between gap-3 rounded-xl border border-border bg-muted/40 px-3 py-2 text-muted-foreground text-xs',\n classNames?.abandoned,\n )}\n >\n <p>Approval was cancelled — the run moved on.</p>\n <button\n type=\"button\"\n aria-label=\"Dismiss cancelled approval\"\n onClick={() => setDismissedId(abandonedInterrupt.id)}\n className=\"shrink-0 rounded-md p-1 transition-colors hover:bg-muted hover:text-foreground\"\n >\n <XIcon className=\"size-3.5\" />\n </button>\n </div>\n );\n }\n\n if (handledElsewhere) return null;\n // A live mirror without lane stamps cannot be answered before the run\n // parks; the parked request renders it then.\n if (isLive && laneIds === null) return null;\n\n const message = readInterruptMessage(request ? request.payload : liveHitl, fallbackMessage);\n const toolName = hitl?.context?.tool_name ?? hitl?.context?.tool_id;\n const pendingCount = hitl?.context?.pending_action_count ?? 1;\n const hasDetails = hitl !== null && actionRequests.length > 0;\n const showDetails = hasDetails && (detailsOverride ?? actionRequests.length <= 1);\n const sessionApprovalOffered = hitl !== null && canApproveForSession(actionRequests);\n const laneDecided =\n undecidedLaneIds !== null &&\n laneIds !== null &&\n (undecidedLaneIds.length === 0 || liveSentKey === undecidedLaneIds.join('|'));\n const locked = pending || laneDecided || replaying || confirming;\n\n const editor =\n !readOnly && hitl !== null && renderEditor\n ? renderEditor({\n ...context,\n locked,\n sessionApprovalOffered,\n approve: () => decide(hitlResumeApprove()),\n approveForSession: () => decide(hitlResumeApproveForSession()),\n reject: (reason) => decide(hitlResumeReject(reason)),\n decideEach,\n })\n : undefined;\n const customHeader = renderHeader?.(context);\n // Only the card's own review leads with the title: a host's details or\n // editor show the envelope themselves, headline included.\n const headerTitle = renderDetails === undefined && editor == null ? title : undefined;\n\n return (\n <section\n aria-label={hitl ? 'Approval required' : 'Input required'}\n className={cn(\n 'aui-approval-card w-full rounded-2xl border border-border bg-card px-4 py-3 text-foreground shadow-xs',\n classNames?.root,\n )}\n >\n <div className=\"flex items-start gap-3\">\n {customHeader != null ? (\n <div className=\"min-w-0 flex-1\">{customHeader}</div>\n ) : (\n <>\n <ShieldAlertIcon className=\"mt-0.5 size-4 shrink-0 text-muted-foreground\" />\n <div className=\"min-w-0 flex-1\">\n <p className=\"flex items-center gap-2 font-semibold text-sm\">\n <span>{hitl ? 'Approval required' : 'Waiting for input'}</span>\n {hitl && pendingCount > 1 ? (\n <span className=\"shrink-0 rounded-full border border-border bg-muted px-1.5 py-px font-normal text-[11px] text-muted-foreground\">\n {pendingCount} tool calls\n </span>\n ) : null}\n </p>\n {headerTitle ? (\n <>\n <p\n className=\"break-words pt-1 font-medium text-foreground text-sm leading-snug\"\n data-testid=\"statewire-approval-headline\"\n >\n {headerTitle.headline}\n </p>\n {headerTitle.summary ? (\n <p\n className=\"break-words pt-1 text-muted-foreground text-sm leading-snug\"\n data-testid=\"statewire-approval-summary\"\n >\n {headerTitle.summary}\n </p>\n ) : null}\n </>\n ) : (\n <p className=\"pt-1 text-muted-foreground text-sm leading-snug\">\n {hitl && pendingCount === 1 && toolName ? (\n <>\n <span className=\"font-mono text-foreground\">{toolName}</span> requires approval before it runs.\n </>\n ) : (\n message\n )}\n </p>\n )}\n </div>\n </>\n )}\n </div>\n {decisionFailure && decisionFailure.epoch === approvalEpochRef.current &&\n (decisionFailure.requestId === requestId || laneIds?.includes(decisionFailure.requestId)) ? (\n <p role=\"alert\" data-testid=\"statewire-approval-error\">{decisionFailure.message}</p>\n ) : null}\n {isLive ? (\n <p className=\"pt-1 text-muted-foreground text-xs\" data-testid=\"statewire-approval-live\">\n {laneDecided\n ? 'Decision sent — it applies as soon as this step pauses.'\n : 'Other work keeps running while you decide.'}\n </p>\n ) : null}\n {hasDetails && editor == null ? (\n <button\n type=\"button\"\n onClick={() => setDetailsOverride(!showDetails)}\n aria-expanded={showDetails}\n className=\"mt-2 flex items-center gap-1 rounded px-1 py-0.5 text-muted-foreground text-xs transition-colors hover:text-foreground\"\n >\n <ChevronDownIcon\n className={cn('size-3 transition-transform', showDetails && 'rotate-180')}\n />\n {showDetails ? 'Hide details' : 'Review details'}\n </button>\n ) : null}\n {/* EVERY pending gated call renders, in order — one decision\n authorizes the whole batch, so nothing may hide behind a host's\n richer cards. All read-only: this runtime resumes through\n `hitl_response_to_decisions`, which has no `tool_args` channel —\n an editable composer would let someone rewrite an email and then\n watch the original go out — unless the host takes over the\n decision too (`renderEditor`), which sends the edit per call. */}\n {editor != null ? (\n <div className={cn('mt-3 flex flex-col gap-2', classNames?.details)}>{editor}</div>\n ) : showDetails ? (\n <div className={cn('mt-2 flex flex-col gap-2', classNames?.details)}>\n {renderDetails ? (\n renderDetails(context)\n ) : (\n // A titled card no longer names its tool in the header, so its\n // details do, as a batch's do.\n <DefaultApprovalDetails\n actionRequests={actionRequests}\n showNames={actionRequests.length > 1 || headerTitle !== undefined}\n />\n )}\n </div>\n ) : null}\n {editor != null ? null : (\n <div className={cn('flex flex-wrap items-center gap-2 pt-3', classNames?.actions)}>\n {readOnly ? (\n <p className=\"text-muted-foreground text-sm\" data-testid=\"statewire-approval-read-only\">\n {readOnlyNotice}\n </p>\n ) : hitl ? (\n <>\n <Button\n size=\"sm\"\n disabled={locked}\n onClick={() => decide(hitlResumeApprove())}\n >\n <CheckIcon />\n Approve\n </Button>\n {sessionApprovalOffered ? (\n <Button\n size=\"sm\"\n variant=\"outline\"\n disabled={locked}\n onClick={() => decide(hitlResumeApproveForSession())}\n data-testid=\"statewire-approval-approve-session\"\n >\n <CheckCheckIcon />\n Approve all for this session\n </Button>\n ) : null}\n <Button\n size=\"sm\"\n variant=\"outline\"\n disabled={locked}\n onClick={() => decide(hitlResumeReject())}\n >\n <XIcon />\n Reject\n </Button>\n </>\n ) : (\n <>\n <p className=\"text-muted-foreground text-sm\" data-testid=\"statewire-approval-non-hitl\">\n {nonHitlNotice}\n </p>\n <Button\n size=\"sm\"\n variant=\"outline\"\n disabled={pending}\n onClick={() => resume(interruptResumeDecline())}\n >\n <XIcon />\n Decline\n </Button>\n </>\n )}\n </div>\n )}\n </section>\n );\n};\n\n/**\n * What the backend resolved about a call before asking (where a Slack write\n * goes and as whom, Slack Connect warnings), above its raw arguments. Its\n * headline and summary title the card instead; with nothing else, nothing\n * renders here.\n */\nconst ApprovalContextFacts: FC<{ context: PendingApprovalContext }> = ({ context }) =>\n context.facts.length === 0 && context.warnings.length === 0 ? null : (\n <div className=\"mt-1 space-y-0.5\" data-testid=\"statewire-approval-context\">\n {context.facts.map((fact) => (\n <p key={fact.label}>\n <span className=\"font-semibold\">{fact.label}:</span> {fact.value}\n </p>\n ))}\n {context.warnings.map((warning) => (\n <p\n key={warning.message}\n className={warning.severity === 'info' ? undefined : 'font-semibold'}\n >\n {warning.message}\n </p>\n ))}\n </div>\n );\n\n/**\n * One block per gated call: its name (a batch's, or a titled call's), its\n * resolved facts, and its arguments as JSON.\n */\nconst DefaultApprovalDetails: FC<{ actionRequests: PendingActionRequest[]; showNames: boolean }> = ({\n actionRequests,\n showNames,\n}) => (\n <>\n {actionRequests.map((action, index) => (\n <div\n key={`${action.name}-${index}`}\n className=\"rounded-lg border border-border/60 bg-muted/40 p-2 text-foreground text-xs leading-relaxed\"\n >\n {showNames ? <p className=\"font-mono font-semibold\">{action.name}</p> : null}\n {action.approvalContext ? <ApprovalContextFacts context={action.approvalContext} /> : null}\n {Object.keys(action.args).length > 0 ? (\n <pre className=\"mt-1 max-h-32 overflow-auto whitespace-pre-wrap break-words rounded bg-background p-1.5 font-mono text-[11px]\">\n {JSON.stringify(action.args, null, 2)}\n </pre>\n ) : (\n <p className=\"text-muted-foreground\">No arguments.</p>\n )}\n </div>\n ))}\n </>\n);\n"],"names":["_a","request"],"mappings":";;;;;;;;;;;AAmIA,SAAS,eAAe,QAA0C;AAChE,MAAI,OAAO,SAAS,QAAS,QAAO,oBAAoB,OAAO,KAAK;AACpE,QAAM,QAAQ,OAAO,OAAO,OAAO,aAAa;AAChD,SAAO,MAAM,WAAW,KAAK,MAAM,KAAK,mBAAmB;AAC7D;AAGA,MAAM,gCAAmE,OAAO,OAAO,EAAE;AAuHlF,MAAM,wBAAwD,CAAC,UAAU;AAC9E,QAAM,SAAS,YAAY,CAAC,MAAM,EAAE,OAAO,MAAM;AACjD,MAAI,CAAC,yBAAyB,MAAM,EAAG,QAAO;AAC9C,SAAO,oBAAC,4BAAA,EAA4B,GAAG,MAAA,CAAO;AAChD;AAEA,MAAM,6BAA6D,CAAC;AAAA,EAClE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,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,IAAE,KAAK;AAAA,EAAA,KADrD,KAAK,KAEb,CACD;AAAA,EACA,QAAQ,SAAS,IAAI,CAAC,YACrB;AAAA,IAAC;AAAA,IAAA;AAAA,MAEC,WAAW,QAAQ,aAAa,SAAS,SAAY;AAAA,MAEpD,UAAA,QAAQ;AAAA,IAAA;AAAA,IAHJ,QAAQ;AAAA,EAAA,CAKhB;AAAA,GACH;AAOJ,MAAM,yBAA6F,CAAC;AAAA,EAClG;AAAA,EACA;AACF,MACE,oBAAA,UAAA,EACG,UAAA,eAAe,IAAI,CAAC,QAAQ,UAC3B;AAAA,EAAC;AAAA,EAAA;AAAA,IAEC,WAAU;AAAA,IAET,UAAA;AAAA,MAAA,gCAAa,KAAA,EAAE,WAAU,2BAA2B,UAAA,OAAO,MAAK,IAAO;AAAA,MACvE,OAAO,kBAAkB,oBAAC,wBAAqB,SAAS,OAAO,iBAAiB,IAAK;AAAA,MACrF,OAAO,KAAK,OAAO,IAAI,EAAE,SAAS,IACjC,oBAAC,OAAA,EAAI,WAAU,iHACZ,eAAK,UAAU,OAAO,MAAM,MAAM,CAAC,EAAA,CACtC,IAEA,oBAAC,KAAA,EAAE,WAAU,yBAAwB,UAAA,gBAAA,CAAa;AAAA,IAAA;AAAA,EAAA;AAAA,EAV/C,GAAG,OAAO,IAAI,IAAI,KAAK;AAY9B,CACD,GACH;"}
1
+ {"version":3,"file":"StatewireApprovalCard.js","sources":["../../src/chat/StatewireApprovalCard.tsx"],"sourcesContent":["import { useAuiState } from '@assistant-ui/react';\nimport { type StatewireThread, useStatewireState } from '@assistant-ui/react-statewire';\nimport {\n actionRequestToolCallIds,\n asHitlApproval,\n fanLaneDecision,\n HITL_PENDING_RESUME_GRACE_MS,\n type HitlActionDecision,\n type HitlApprovalPayload,\n hasStatewireThreadExtras,\n hitlResumeActionDecisions,\n hitlResumeApprove,\n hitlResumeApproveForSession,\n hitlResumeReject,\n interruptResumeDecline,\n interruptMirrorPayload,\n laneInterruptIds,\n type PendingActionRequest,\n type PendingApprovalContext,\n type PendingApprovalTitle,\n pendingApprovalTitle,\n readInterruptMessage,\n readInterruptMirror,\n type ResumeExtras,\n resumeValueApproves,\n sessionApprovalLabel,\n sessionApprovalOffer,\n statewireRejectionDetailMessage,\n} from '@athenaintel/agent-runtime';\nimport {\n CheckCheckIcon,\n CheckIcon,\n ChevronDownIcon,\n ShieldAlertIcon,\n XIcon,\n} from 'lucide-react';\nimport {\n type FC,\n type ReactNode,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { cn } from '../lib/utils';\nimport { Button } from '../ui/button';\nimport {\n type StatewireInterruptPredicate,\n useStatewireApprovalRequest,\n} from './use-statewire-approval-request';\n\n/**\n * Human-in-the-loop approval card for the statewire transport — the one\n * approval UI every Athena chat surface mounts (the SDK's `AthenaChat`, the\n * Chrome side panel, the Office task pane, Olympus).\n *\n * When the deep-agent runtime hits an approval-gated tool call, the backend\n * parks the run on an `interrupt` input request. This card reads that request\n * through `useStatewireApprovalRequest` and answers it with\n * `{ type: 'run/input', requestId, response: { type: 'resume', value } }` —\n * the exact command the backend's resume path consumes. Without an answer the\n * run stays parked forever, so this card must be mounted on every statewire\n * chat surface. On legacy (non-statewire) threads it renders nothing.\n *\n * A gated call raised inside a delegated subagent parks only its lane: the\n * host mirrors that interrupt while the sibling lanes keep streaming, before\n * any input request exists. The card renders the mirrored payload the same\n * way and answers it with `run/lane-input` keyed by the lane's langgraph\n * interrupt id (`laneInterruptIds`); the host queues the decision and applies\n * it the moment the run parks, so the approver never waits on the siblings.\n * Once parked, a payload whose calls all carry interrupt ids resumes as a\n * `lane_decisions` map too — one positional `run/input` can only answer the\n * first of several parked lanes.\n *\n * Recovery of a queued decision the host never applies is ordered host\n * first: the host's answerer resumes the park or drops (and flushes) the\n * queue within `QUEUED_LANE_ANSWER_BUDGET_SECONDS` of the park, and this\n * card's grace (`HITL_PENDING_RESUME_GRACE_MS`, longer than that budget)\n * fires only when the host stayed silent. When it fires, the card that sent\n * the queued decision asks the host to replay it (`run/lane-replay` — the\n * host resumes as the approver, under the meta it recorded, and refuses any\n * other caller); every other card, and a replay the host refuses, hands the\n * decision back to a person by unlocking the actions. A queued decision is\n * never re-sent as a `run/input` of the viewing client's own: that would run\n * the approver's decision under the viewer's identity and configuration.\n *\n * A lone gated call whose resolved envelope (`approval_context`) carries a\n * headline is titled by it in the card's own review: the headline replaces\n * \"`tool` requires approval before it runs\", the summary sits under it, and\n * the default details name the tool instead. A batch keeps the generic copy,\n * since one decision answers every call. So does a host review\n * (`renderDetails`, or an editor from `renderEditor`): it shows the envelope\n * itself, headline included, so the header must not say it again. Display-only:\n * the decision row and what it sends do not change.\n *\n * Host-specific review UIs (subagent cards, email summaries) slot in through\n * `renderDetails`; a host composer that must also OWN the decision (an\n * editable email whose edits have to reach the backend) takes over the\n * details and the decision row through `renderEditor`; requests another\n * surface answers (typed interrupt families, per-lane subagent approvals)\n * stand down through `isHandledElsewhere`; viewers without edit rights see\n * `readOnlyNotice`.\n */\n\n/**\n * The answer a passkey decision check confirms before the card sends it\n * (identity 0b.9): a `run/input` resume of the parked request, or the lane\n * decisions of a `run/lane-input` sent while sibling lanes still stream.\n */\nexport type StatewireDecisionAnswer =\n | {\n readonly kind: 'input';\n readonly requestId: string;\n readonly value: StatewireThread.InputResponse;\n }\n | {\n readonly kind: 'lanes';\n readonly laneDecisions: Readonly<Record<string, StatewireThread.InputResponse>>;\n };\n\n/**\n * Runs the host's passkey check for an approving answer and resolves its\n * token, or `undefined` to send the answer without one. While checks are\n * report-only, an answer goes ahead without a check (no passkey yet, a\n * cancelled prompt); the host decides what to tell the person. Never called\n * for an answer that only rejects.\n */\nexport type StatewireDecisionConfirmer = (\n answer: StatewireDecisionAnswer,\n) => Promise<string | undefined>;\n\nfunction answerApproves(answer: StatewireDecisionAnswer): boolean {\n if (answer.kind === 'input') return resumeValueApproves(answer.value);\n const lanes = Object.values(answer.laneDecisions);\n return lanes.length === 0 || lanes.some(resumeValueApproves);\n}\n\n/** What the card reads in place of the host's queued lanes once it has given up on them. */\nconst NO_HOST_QUEUED_LANE_DECISIONS: Readonly<Record<string, unknown>> = Object.freeze({});\n\n/** The pending request a host slot renders or judges. */\nexport interface StatewireApprovalRequestContext {\n /** The parked input request — `undefined` while the run still streams (a live lane approval). */\n request: StatewireThread.CustomInputRequest | undefined;\n /** The payload narrowed to the Athena HITL approval shape, or `null` for a generic park. */\n hitl: HitlApprovalPayload | null;\n /** Every gated call the approval covers, in decision order (empty for non-HITL parks). */\n actionRequests: PendingActionRequest[];\n /**\n * The approval's title (`pendingApprovalTitle`): a lone call's envelope\n * headline and summary. Absent for a batch, a non-HITL park and a call\n * without one. The default header shows it only above the card's own\n * details; under a host review the host shows the envelope, and may lead\n * with this.\n */\n title?: PendingApprovalTitle;\n}\n\n/** The request a host editor renders, plus the decisions it may send for it. */\nexport interface StatewireApprovalEditorContext extends StatewireApprovalRequestContext {\n /** A decision is in flight (or a live lane already answered); the editor must not send another. */\n locked: boolean;\n /** Whether a session-wide approval may be offered for this batch. */\n sessionApprovalOffered: boolean;\n /**\n * What the session option's button says, naming exactly what the answer\n * covers (`sessionApprovalLabel`): \"Approve all for this session\" for\n * tools, or \"Approve for this session: only kyle@… and sam@…\" for sends\n * scoped to their recipients. Meaningful only when `sessionApprovalOffered`.\n */\n sessionApprovalLabel: string;\n approve: () => void;\n approveForSession: () => void;\n reject: (reason?: string) => void;\n /**\n * Answer each gated call on its own — the only way an EDITED call reaches\n * the backend. `decision` is asked once per call, in order, so the answer\n * always names exactly the parked calls (a partial map is refused\n * server-side and nothing runs). `null` when the batch cannot take\n * per-action answers: a call without a `tool_call_id`, or a live / multi-\n * lane approval, which resumes per lane and carries no edit.\n */\n decideEach: ((decision: (request: PendingActionRequest) => HitlActionDecision) => void) | null;\n}\n\nexport interface StatewireApprovalCardProps {\n /** Surface-styling overrides merged onto the default classes. */\n classNames?: {\n /** The approval card container. */\n root?: string;\n /** The \"approval was cancelled\" notice container. */\n abandoned?: string;\n /** The disclosed details block. */\n details?: string;\n /** The decision row. */\n actions?: string;\n };\n /** Copy shown when an interrupt payload carries no message. */\n fallbackMessage?: string;\n /**\n * Which pending interrupt this card answers. Defaults to\n * `isApprovalCardInterrupt` (client-tool parks excluded — keep it that way\n * unless the surface handles those itself).\n */\n interruptPredicate?: StatewireInterruptPredicate;\n /**\n * How long a clicked decision keeps the buttons locked when no resume run\n * ever starts (a `run/input` the host rejected before any run began).\n * Defaults to `HITL_PENDING_RESUME_GRACE_MS`.\n */\n pendingResumeGraceMs?: number;\n /**\n * Return true when another surface answers this request (a typed Athena\n * interrupt family, per-lane subagent approval cards). The card renders\n * nothing for it — two surfaces must never answer the same input request.\n */\n isHandledElsewhere?: (context: StatewireApprovalRequestContext) => boolean;\n /**\n * Replace the default argument disclosure (one JSON block per gated call)\n * with a host-specific review UI. Rendered inside the collapsible details\n * region; the decision buttons stay with the card.\n */\n renderDetails?: (context: StatewireApprovalRequestContext) => ReactNode;\n /** Replace the default approval icon and heading. Return null to keep it. */\n renderHeader?: (context: StatewireApprovalRequestContext) => ReactNode;\n /**\n * Replace BOTH the details region and the decision row with a host\n * composer that decides the request itself through the context's\n * callbacks (an editable email whose edits must be what runs). Return\n * `null`/`undefined` to keep the default card for this request. Not\n * consulted for read-only viewers or non-HITL parks.\n */\n renderEditor?: (context: StatewireApprovalEditorContext) => ReactNode;\n /**\n * The viewer may see the request (it explains why the run is parked) but\n * cannot decide it — answering steers the shared run. Renders\n * `readOnlyNotice` in place of the buttons.\n */\n readOnly?: boolean;\n readOnlyNotice?: ReactNode;\n /**\n * Copy for a park that is not a HITL approval — a typed Athena interrupt\n * this surface has no card for. The only honest action is to decline it\n * (`{ action: 'reject' }`, which every typed raiser treats as a clean user\n * decline); a generic \"Continue\" would be rejected by the raiser's resume\n * schema and surface as a tool error.\n */\n nonHitlNotice?: ReactNode;\n /**\n * The host refused a decision (or the transport lost it). The optimistic\n * fold has rolled back and the request is on screen again with its actions\n * re-enabled; this is where a host tells the user why (a toast, a log line).\n */\n onResumeRejected?: (error: unknown, requestId: string) => void;\n /**\n * The host's passkey decision check (identity 0b.9). An answer that lets\n * anything run is handed to it first and sent with the token it resolves\n * as `decisionCheck`; the decision buttons stay locked while it runs. An\n * answer that only rejects never is. Omit it and every answer is sent as\n * before, with no check.\n */\n confirmDecision?: StatewireDecisionConfirmer;\n}\n\nexport const StatewireApprovalCard: FC<StatewireApprovalCardProps> = (props) => {\n const extras = useAuiState((s) => s.thread.extras);\n if (!hasStatewireThreadExtras(extras)) return null;\n return <StatewireApprovalCardInner {...props} />;\n};\n\nconst StatewireApprovalCardInner: FC<StatewireApprovalCardProps> = ({\n classNames,\n fallbackMessage,\n interruptPredicate,\n pendingResumeGraceMs,\n isHandledElsewhere,\n renderDetails,\n renderHeader,\n renderEditor,\n readOnly = false,\n readOnlyNotice = 'Waiting for someone with edit access to respond.',\n nonHitlNotice = 'This request needs an answer this surface cannot collect.',\n onResumeRejected,\n confirmDecision,\n}) => {\n const approvalEpochRef = useRef(0);\n const [decisionFailure, setDecisionFailure] = useState<{\n requestId: string;\n message: string;\n epoch: number;\n }>();\n const reportResumeRejected = useCallback(\n (error: unknown, failedRequestId: string) => {\n setDecisionFailure({\n requestId: failedRequestId,\n message: statewireRejectionDetailMessage(error) ?? 'Your decision could not be sent. Try again.',\n epoch: approvalEpochRef.current,\n });\n onResumeRejected?.(error, failedRequestId);\n },\n [onResumeRejected],\n );\n const {\n request,\n requestId,\n hitl: parkedHitl,\n actionRequests: parkedActionRequests,\n liveHitl,\n liveActionRequests,\n queuedLaneDecisions,\n abandonedInterrupt,\n pending,\n resume,\n sendLaneDecisions,\n replayQueuedLanes,\n } = useStatewireApprovalRequest<StatewireThread.InputResponse>({\n interruptPredicate,\n pendingResumeGraceMs,\n onResumeRejected: reportResumeRejected,\n });\n // Read the host mirror: the optimistic resume fold can temporarily hide\n // `liveHitl` and the parked request without ending this approval.\n const mirroredApproval = useStatewireState(\n (state) => asHitlApproval(interruptMirrorPayload(readInterruptMirror(state))) !== null,\n );\n const approvalPresent = requestId !== undefined || mirroredApproval;\n const previousApprovalPresentRef = useRef(approvalPresent);\n if (previousApprovalPresentRef.current && !approvalPresent) approvalEpochRef.current += 1;\n previousApprovalPresentRef.current = approvalPresent;\n const [dismissedId, setDismissedId] = useState<string>();\n // The card shares the chat column with the thread. A lone gated call is\n // small enough to show inline, but a fan-out of a dozen calls would swallow\n // the conversation, so a batch starts collapsed until someone opens it.\n const [detailsOverride, setDetailsOverride] = useState<boolean>();\n // The live lanes a decision was sent for (joined ids); the buttons stay\n // locked until the host echoes them in `queuedLaneDecisions` or refuses.\n const [liveSentKey, setLiveSentKey] = useState<string>();\n // The parked request whose host-queued lanes outlived the grace window\n // (see `queuedLanesAwaitingHost` below): its queue is read as stale.\n const [staleQueuedRequestId, setStaleQueuedRequestId] = useState<string>();\n // The parked request whose queued lanes this card has asked the host to\n // replay (`run/lane-replay` in flight): locked until the host answers.\n const [replayingRequestId, setReplayingRequestId] = useState<string>();\n // The lanes THIS card decided live (its own `run/lane-input` the host\n // accepted). Only a queue this card recorded is replayed from here — the\n // host refuses any other caller, and a second editor's card must not even\n // ask. Pruned to the lanes on screen whenever a different view arrives, so\n // the record survives the live → parked transition of the same lanes (and\n // a fold that briefly shows nothing) and dies with a new request.\n const sentLaneIdsRef = useRef<Set<string>>(new Set());\n // The parked request already replayed once from here: a request is\n // replayed at most once, then the grace hands the decision back.\n const replayedRequestIdRef = useRef<string>(undefined);\n // A passkey check is running for the answer clicked here; the buttons stay\n // locked until it settles.\n const [confirming, setConfirming] = useState(false);\n // The parked request on screen now, read after a check settles: an answer\n // confirmed for a request that is no longer parked is never sent.\n const currentRequestIdRef = useRef(requestId);\n currentRequestIdRef.current = requestId;\n const confirmDecisionRef = useRef(confirmDecision);\n confirmDecisionRef.current = confirmDecision;\n\n const isLive = request === undefined && liveHitl !== null;\n const hitl = isLive ? liveHitl : parkedHitl;\n const actionRequests = isLive ? liveActionRequests : parkedActionRequests;\n const laneIds = laneInterruptIds(actionRequests);\n // The host answers the lanes it queued from its own settle path, within its\n // published budget of the park (`QUEUED_LANE_ANSWER_BUDGET_SECONDS`). A\n // parked request whose queued lanes are still unanswered past the grace\n // window has a silent answerer, and either this card asked the host to\n // replay them and was refused, or the queue is not this card's to replay —\n // so the queue no longer counts as a decision here: the actions re-enable\n // and the next click answers the parked request itself (a resume the host\n // accepts, and whose dispatch drops the stale queue).\n const hostQueuedLaneDecisions =\n requestId !== undefined && staleQueuedRequestId === requestId\n ? NO_HOST_QUEUED_LANE_DECISIONS\n : queuedLaneDecisions;\n const undecidedLaneIds =\n laneIds?.filter((id) => !(id in hostQueuedLaneDecisions)) ?? null;\n // A lone parked lane (or an unstamped batch) answers with one positional\n // `run/input`; that is the only resume the backend binds per-action answers\n // to, so it is the only place an edited call can go.\n const positional = laneIds === null || (!isLive && laneIds.length <= 1);\n const liveKey = isLive ? (laneIds?.join('|') ?? null) : null;\n const viewKey = requestId ?? liveKey ?? undefined;\n\n // A fresh approval gets the default for ITS batch size, not the disclosure\n // the previous one was left in. Reset during render via React's \"previous\n // value\" pattern.\n const prevViewKeyRef = useRef(viewKey);\n if (prevViewKeyRef.current !== viewKey) {\n prevViewKeyRef.current = viewKey;\n if (detailsOverride !== undefined) setDetailsOverride(undefined);\n if (liveSentKey !== undefined) setLiveSentKey(undefined);\n if (laneIds !== null) {\n for (const id of sentLaneIdsRef.current) {\n if (!laneIds.includes(id)) sentLaneIdsRef.current.delete(id);\n }\n }\n }\n // The per-request marks (stale queue, replayed once, replay in flight)\n // outlive the optimistic fold of a click's own `run/input`: the request\n // leaves and comes back under the SAME id when the host refuses it, and a\n // card that forgot its stale mark then would relock over the standing\n // queue for another grace, and could replay it a second time. They are\n // forgotten only for a genuinely different parked request.\n if (\n requestId !== undefined &&\n staleQueuedRequestId !== undefined &&\n requestId !== staleQueuedRequestId\n ) {\n setStaleQueuedRequestId(undefined);\n }\n if (\n requestId !== undefined &&\n replayingRequestId !== undefined &&\n requestId !== replayingRequestId\n ) {\n setReplayingRequestId(undefined);\n }\n if (\n requestId !== undefined &&\n replayedRequestIdRef.current !== undefined &&\n requestId !== replayedRequestIdRef.current\n ) {\n replayedRequestIdRef.current = undefined;\n }\n\n const title = pendingApprovalTitle({ hitl, actionRequests });\n const context: StatewireApprovalRequestContext = {\n request,\n hitl,\n actionRequests,\n ...(title ? { title } : {}),\n };\n const handledElsewhere = isHandledElsewhere?.(context) ?? false;\n const replaying = replayingRequestId !== undefined && replayingRequestId === requestId;\n\n // Parked, every lane the request covers already queued on the host, no\n // resume of our own in flight, and this card is the one that would decide\n // (not a viewer, not a request another surface owns): the host's answerer\n // is expected to resume the run within its budget. Start the clock on it,\n // longer than that budget. When it runs out the host has stayed silent: if\n // this card queued those lanes itself, it asks the host to replay them as\n // their approver (`run/lane-replay`); otherwise — and when the host refuses\n // the replay — the queue no longer counts as a decision here and the actions\n // re-enable, so a person decides. Never a `run/input` of this client's own\n // carrying someone else's recorded decision.\n const queuedLanesAwaitingHost =\n !isLive &&\n !readOnly &&\n !handledElsewhere &&\n requestId !== undefined &&\n undecidedLaneIds !== null &&\n undecidedLaneIds.length === 0 &&\n !pending &&\n !replaying;\n const queuedLaneGraceMs = pendingResumeGraceMs ?? HITL_PENDING_RESUME_GRACE_MS;\n const laneKey = laneIds?.join('|');\n const onResumeRejectedRef = useRef(reportResumeRejected);\n onResumeRejectedRef.current = reportResumeRejected;\n useEffect(() => {\n if (!queuedLanesAwaitingHost || requestId === undefined || laneKey === undefined) {\n return undefined;\n }\n const timer = setTimeout(() => {\n const ownQueue =\n laneKey.split('|').every((id) => sentLaneIdsRef.current.has(id)) &&\n replayedRequestIdRef.current !== requestId;\n if (!ownQueue) {\n setStaleQueuedRequestId(requestId);\n return;\n }\n replayedRequestIdRef.current = requestId;\n setReplayingRequestId(requestId);\n replayQueuedLanes(requestId).then(\n () => {\n setReplayingRequestId((current) => (current === requestId ? undefined : current));\n },\n (error: unknown) => {\n setReplayingRequestId((current) => (current === requestId ? undefined : current));\n setStaleQueuedRequestId(requestId);\n onResumeRejectedRef.current?.(error, requestId);\n },\n );\n }, queuedLaneGraceMs);\n return () => clearTimeout(timer);\n }, [queuedLanesAwaitingHost, requestId, laneKey, queuedLaneGraceMs, replayQueuedLanes]);\n\n /**\n * Send `answer` through `deliver`, with a passkey check first when it\n * approves and the host runs one. The check is the person's own act on\n * their device; while it is open the card is locked, and if the parked\n * request changed meanwhile the confirmed answer is dropped, never sent to\n * whatever parked next.\n */\n const withDecisionCheck = useCallback(\n (answer: StatewireDecisionAnswer, deliver: (extras?: ResumeExtras) => void) => {\n const confirmer = confirmDecisionRef.current;\n if (confirmer === undefined || !answerApproves(answer)) {\n deliver();\n return;\n }\n setConfirming(true);\n confirmer(answer)\n .catch(() => undefined)\n .then((token) => {\n setConfirming(false);\n if (answer.kind === 'input' && currentRequestIdRef.current !== answer.requestId) {\n return;\n }\n deliver(token ? { decisionCheck: token } : undefined);\n });\n },\n [],\n );\n\n // A live lane decision: the host queues it until the run parks, and holds\n // it for this card's caller, the only queue this card may ask it to replay.\n const sendLiveLanes = useCallback(\n ({\n key,\n lanes,\n epoch,\n extras,\n }: {\n key: string;\n lanes: Readonly<Record<string, StatewireThread.InputResponse>>;\n epoch: number;\n extras?: ResumeExtras;\n }) => {\n const sentLaneIds = key.split('|');\n setLiveSentKey(key);\n Promise.resolve(sendLaneDecisions(lanes, extras)).then(\n () => {\n if (epoch !== approvalEpochRef.current) return;\n for (const id of sentLaneIds) sentLaneIdsRef.current.add(id);\n },\n (error: unknown) => {\n if (epoch !== approvalEpochRef.current) return;\n setLiveSentKey((current) => (current === key ? undefined : current));\n reportResumeRejected(error, sentLaneIds[0] ?? '');\n },\n );\n },\n [sendLaneDecisions, reportResumeRejected],\n );\n\n const decide = useCallback(\n (value: Record<string, string>) => {\n setDecisionFailure(undefined);\n const epoch = approvalEpochRef.current;\n // Several parked lanes (or a live one) answer by interrupt id: a\n // positional `run/input` would resume only the first and re-park the\n // rest. A lone parked lane keeps the positional resume every host\n // already speaks.\n if (positional || undecidedLaneIds === null) {\n if (requestId === undefined) return;\n withDecisionCheck({ kind: 'input', requestId, value }, (extras) => {\n resume(value, extras);\n });\n return;\n }\n const lanes = fanLaneDecision({ interruptIds: undecidedLaneIds, decision: value });\n if (!isLive) {\n if (requestId === undefined) return;\n withDecisionCheck(\n { kind: 'input', requestId, value: { lane_decisions: lanes } },\n (extras) => {\n sendLaneDecisions(lanes, extras);\n },\n );\n return;\n }\n const key = undecidedLaneIds.join('|');\n withDecisionCheck({ kind: 'lanes', laneDecisions: lanes }, (extras) =>\n sendLiveLanes({ key, lanes, epoch, extras }),\n );\n },\n [\n positional,\n undecidedLaneIds,\n isLive,\n requestId,\n resume,\n sendLaneDecisions,\n sendLiveLanes,\n withDecisionCheck,\n ],\n );\n\n const decideEach = useMemo<StatewireApprovalEditorContext['decideEach']>(() => {\n if (actionRequestToolCallIds(actionRequests) === null || !positional) return null;\n return (decision) => {\n setDecisionFailure(undefined);\n const decisions: Record<string, HitlActionDecision> = {};\n for (const request of actionRequests) {\n if (request.toolCallId !== undefined) decisions[request.toolCallId] = decision(request);\n }\n // The edited argument set comes from the wire as JSON; the resume value\n // is that JSON going back.\n const value = hitlResumeActionDecisions(decisions) as StatewireThread.InputResponse;\n if (requestId === undefined) return;\n withDecisionCheck({ kind: 'input', requestId, value }, (extras) => {\n resume(value, extras);\n });\n };\n }, [actionRequests, positional, requestId, resume, withDecisionCheck]);\n\n if (!request && !isLive) {\n if (!abandonedInterrupt || abandonedInterrupt.id === dismissedId) return null;\n return (\n <div\n className={cn(\n 'aui-approval-abandoned flex w-full items-center justify-between gap-3 rounded-xl border border-border bg-muted/40 px-3 py-2 text-muted-foreground text-xs',\n classNames?.abandoned,\n )}\n >\n <p>Approval was cancelled — the run moved on.</p>\n <button\n type=\"button\"\n aria-label=\"Dismiss cancelled approval\"\n onClick={() => setDismissedId(abandonedInterrupt.id)}\n className=\"shrink-0 rounded-md p-1 transition-colors hover:bg-muted hover:text-foreground\"\n >\n <XIcon className=\"size-3.5\" />\n </button>\n </div>\n );\n }\n\n if (handledElsewhere) return null;\n // A live mirror without lane stamps cannot be answered before the run\n // parks; the parked request renders it then.\n if (isLive && laneIds === null) return null;\n\n const message = readInterruptMessage(request ? request.payload : liveHitl, fallbackMessage);\n const toolName = hitl?.context?.tool_name ?? hitl?.context?.tool_id;\n const pendingCount = hitl?.context?.pending_action_count ?? 1;\n const hasDetails = hitl !== null && actionRequests.length > 0;\n const showDetails = hasDetails && (detailsOverride ?? actionRequests.length <= 1);\n const sessionOffer = hitl !== null ? sessionApprovalOffer(actionRequests) : undefined;\n const sessionApprovalOffered = sessionOffer !== undefined;\n const sessionLabel = sessionOffer ? sessionApprovalLabel(sessionOffer) : '';\n const laneDecided =\n undecidedLaneIds !== null &&\n laneIds !== null &&\n (undecidedLaneIds.length === 0 || liveSentKey === undecidedLaneIds.join('|'));\n const locked = pending || laneDecided || replaying || confirming;\n\n const editor =\n !readOnly && hitl !== null && renderEditor\n ? renderEditor({\n ...context,\n locked,\n sessionApprovalOffered,\n sessionApprovalLabel: sessionLabel,\n approve: () => decide(hitlResumeApprove()),\n approveForSession: () => decide(hitlResumeApproveForSession()),\n reject: (reason) => decide(hitlResumeReject(reason)),\n decideEach,\n })\n : undefined;\n const customHeader = renderHeader?.(context);\n // Only the card's own review leads with the title: a host's details or\n // editor show the envelope themselves, headline included.\n const headerTitle = renderDetails === undefined && editor == null ? title : undefined;\n\n return (\n <section\n aria-label={hitl ? 'Approval required' : 'Input required'}\n className={cn(\n 'aui-approval-card w-full rounded-2xl border border-border bg-card px-4 py-3 text-foreground shadow-xs',\n classNames?.root,\n )}\n >\n <div className=\"flex items-start gap-3\">\n {customHeader != null ? (\n <div className=\"min-w-0 flex-1\">{customHeader}</div>\n ) : (\n <>\n <ShieldAlertIcon className=\"mt-0.5 size-4 shrink-0 text-muted-foreground\" />\n <div className=\"min-w-0 flex-1\">\n <p className=\"flex items-center gap-2 font-semibold text-sm\">\n <span>{hitl ? 'Approval required' : 'Waiting for input'}</span>\n {hitl && pendingCount > 1 ? (\n <span className=\"shrink-0 rounded-full border border-border bg-muted px-1.5 py-px font-normal text-[11px] text-muted-foreground\">\n {pendingCount} tool calls\n </span>\n ) : null}\n </p>\n {headerTitle ? (\n <>\n <p\n className=\"break-words pt-1 font-medium text-foreground text-sm leading-snug\"\n data-testid=\"statewire-approval-headline\"\n >\n {headerTitle.headline}\n </p>\n {headerTitle.summary ? (\n <p\n className=\"break-words pt-1 text-muted-foreground text-sm leading-snug\"\n data-testid=\"statewire-approval-summary\"\n >\n {headerTitle.summary}\n </p>\n ) : null}\n </>\n ) : (\n <p className=\"pt-1 text-muted-foreground text-sm leading-snug\">\n {hitl && pendingCount === 1 && toolName ? (\n <>\n <span className=\"font-mono text-foreground\">{toolName}</span> requires approval before it runs.\n </>\n ) : (\n message\n )}\n </p>\n )}\n </div>\n </>\n )}\n </div>\n {decisionFailure && decisionFailure.epoch === approvalEpochRef.current &&\n (decisionFailure.requestId === requestId || laneIds?.includes(decisionFailure.requestId)) ? (\n <p role=\"alert\" data-testid=\"statewire-approval-error\">{decisionFailure.message}</p>\n ) : null}\n {isLive ? (\n <p className=\"pt-1 text-muted-foreground text-xs\" data-testid=\"statewire-approval-live\">\n {laneDecided\n ? 'Decision sent — it applies as soon as this step pauses.'\n : 'Other work keeps running while you decide.'}\n </p>\n ) : null}\n {hasDetails && editor == null ? (\n <button\n type=\"button\"\n onClick={() => setDetailsOverride(!showDetails)}\n aria-expanded={showDetails}\n className=\"mt-2 flex items-center gap-1 rounded px-1 py-0.5 text-muted-foreground text-xs transition-colors hover:text-foreground\"\n >\n <ChevronDownIcon\n className={cn('size-3 transition-transform', showDetails && 'rotate-180')}\n />\n {showDetails ? 'Hide details' : 'Review details'}\n </button>\n ) : null}\n {/* EVERY pending gated call renders, in order — one decision\n authorizes the whole batch, so nothing may hide behind a host's\n richer cards. All read-only: this runtime resumes through\n `hitl_response_to_decisions`, which has no `tool_args` channel —\n an editable composer would let someone rewrite an email and then\n watch the original go out — unless the host takes over the\n decision too (`renderEditor`), which sends the edit per call. */}\n {editor != null ? (\n <div className={cn('mt-3 flex flex-col gap-2', classNames?.details)}>{editor}</div>\n ) : showDetails ? (\n <div className={cn('mt-2 flex flex-col gap-2', classNames?.details)}>\n {renderDetails ? (\n renderDetails(context)\n ) : (\n // A titled card no longer names its tool in the header, so its\n // details do, as a batch's do.\n <DefaultApprovalDetails\n actionRequests={actionRequests}\n showNames={actionRequests.length > 1 || headerTitle !== undefined}\n />\n )}\n </div>\n ) : null}\n {editor != null ? null : (\n <div className={cn('flex flex-wrap items-center gap-2 pt-3', classNames?.actions)}>\n {readOnly ? (\n <p className=\"text-muted-foreground text-sm\" data-testid=\"statewire-approval-read-only\">\n {readOnlyNotice}\n </p>\n ) : hitl ? (\n <>\n <Button\n size=\"sm\"\n disabled={locked}\n onClick={() => decide(hitlResumeApprove())}\n >\n <CheckIcon />\n Approve\n </Button>\n {sessionApprovalOffered ? (\n <Button\n size=\"sm\"\n variant=\"outline\"\n disabled={locked}\n onClick={() => decide(hitlResumeApproveForSession())}\n data-testid=\"statewire-approval-approve-session\"\n className=\"h-auto min-h-8 whitespace-normal py-1.5 text-left\"\n >\n <CheckCheckIcon />\n <span className=\"min-w-0 break-words\">{sessionLabel}</span>\n </Button>\n ) : null}\n <Button\n size=\"sm\"\n variant=\"outline\"\n disabled={locked}\n onClick={() => decide(hitlResumeReject())}\n >\n <XIcon />\n Reject\n </Button>\n </>\n ) : (\n <>\n <p className=\"text-muted-foreground text-sm\" data-testid=\"statewire-approval-non-hitl\">\n {nonHitlNotice}\n </p>\n <Button\n size=\"sm\"\n variant=\"outline\"\n disabled={pending}\n onClick={() => resume(interruptResumeDecline())}\n >\n <XIcon />\n Decline\n </Button>\n </>\n )}\n </div>\n )}\n </section>\n );\n};\n\n/**\n * What the backend resolved about a call before asking (where a Slack write\n * goes and as whom, Slack Connect warnings), above its raw arguments. Its\n * headline and summary title the card instead; with nothing else, nothing\n * renders here.\n */\nconst ApprovalContextFacts: FC<{ context: PendingApprovalContext }> = ({ context }) =>\n context.facts.length === 0 && context.warnings.length === 0 ? null : (\n <div className=\"mt-1 space-y-0.5\" data-testid=\"statewire-approval-context\">\n {context.facts.map((fact) => (\n <p key={fact.label}>\n <span className=\"font-semibold\">{fact.label}:</span> {fact.value}\n </p>\n ))}\n {context.warnings.map((warning) => (\n <p\n key={warning.message}\n className={warning.severity === 'info' ? undefined : 'font-semibold'}\n >\n {warning.message}\n </p>\n ))}\n </div>\n );\n\n/**\n * One block per gated call: its name (a batch's, or a titled call's), its\n * resolved facts, and its arguments as JSON.\n */\nconst DefaultApprovalDetails: FC<{ actionRequests: PendingActionRequest[]; showNames: boolean }> = ({\n actionRequests,\n showNames,\n}) => (\n <>\n {actionRequests.map((action, index) => (\n <div\n key={`${action.name}-${index}`}\n className=\"rounded-lg border border-border/60 bg-muted/40 p-2 text-foreground text-xs leading-relaxed\"\n >\n {showNames ? <p className=\"font-mono font-semibold\">{action.name}</p> : null}\n {action.approvalContext ? <ApprovalContextFacts context={action.approvalContext} /> : null}\n {Object.keys(action.args).length > 0 ? (\n <pre className=\"mt-1 max-h-32 overflow-auto whitespace-pre-wrap break-words rounded bg-background p-1.5 font-mono text-[11px]\">\n {JSON.stringify(action.args, null, 2)}\n </pre>\n ) : (\n <p className=\"text-muted-foreground\">No arguments.</p>\n )}\n </div>\n ))}\n </>\n);\n"],"names":["_a","request"],"mappings":";;;;;;;;;;;AAoIA,SAAS,eAAe,QAA0C;AAChE,MAAI,OAAO,SAAS,QAAS,QAAO,oBAAoB,OAAO,KAAK;AACpE,QAAM,QAAQ,OAAO,OAAO,OAAO,aAAa;AAChD,SAAO,MAAM,WAAW,KAAK,MAAM,KAAK,mBAAmB;AAC7D;AAGA,MAAM,gCAAmE,OAAO,OAAO,EAAE;AA8HlF,MAAM,wBAAwD,CAAC,UAAU;AAC9E,QAAM,SAAS,YAAY,CAAC,MA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