@tangle-network/agent-app 0.43.24 → 0.43.26

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 (65) hide show
  1. package/dist/app-auth/index.d.ts +163 -0
  2. package/dist/app-auth/index.js +166 -0
  3. package/dist/app-auth/index.js.map +1 -0
  4. package/dist/assets/index.d.ts +2 -2
  5. package/dist/assistant/index.d.ts +2 -0
  6. package/dist/assistant/index.js +3 -1
  7. package/dist/assistant/index.js.map +1 -1
  8. package/dist/chat-routes/index.d.ts +276 -0
  9. package/dist/chat-routes/index.js +564 -0
  10. package/dist/chat-routes/index.js.map +1 -0
  11. package/dist/chat-store/index.d.ts +194 -0
  12. package/dist/chat-store/index.js +198 -0
  13. package/dist/chat-store/index.js.map +1 -0
  14. package/dist/chunk-4TXDD6P2.js +163 -0
  15. package/dist/chunk-4TXDD6P2.js.map +1 -0
  16. package/dist/chunk-5EQCITY3.js +20 -0
  17. package/dist/chunk-5EQCITY3.js.map +1 -0
  18. package/dist/chunk-5SV5PSU7.js +80 -0
  19. package/dist/chunk-5SV5PSU7.js.map +1 -0
  20. package/dist/chunk-7LNGJDNA.js +1 -0
  21. package/dist/chunk-7LNGJDNA.js.map +1 -0
  22. package/dist/{chunk-77RLNLFP.js → chunk-ATRJULKZ.js} +41 -5
  23. package/dist/chunk-ATRJULKZ.js.map +1 -0
  24. package/dist/{chunk-VMY4TKMN.js → chunk-FCQP75JT.js} +936 -436
  25. package/dist/chunk-FCQP75JT.js.map +1 -0
  26. package/dist/chunk-I2R2XT4M.js +62 -0
  27. package/dist/chunk-I2R2XT4M.js.map +1 -0
  28. package/dist/{chunk-3PK3T4KD.js → chunk-JJGZ54EB.js} +44 -1
  29. package/dist/chunk-JJGZ54EB.js.map +1 -0
  30. package/dist/chunk-TKVJE63N.js +304 -0
  31. package/dist/chunk-TKVJE63N.js.map +1 -0
  32. package/dist/{chunk-SAOAAA3S.js → chunk-UHXQ3KNX.js} +1 -22
  33. package/dist/chunk-UHXQ3KNX.js.map +1 -0
  34. package/dist/chunk-Y4QHNQ75.js +203 -0
  35. package/dist/chunk-Y4QHNQ75.js.map +1 -0
  36. package/dist/contract-DYbTzEDf.d.ts +122 -0
  37. package/dist/core-7qIM7svy.d.ts +21 -0
  38. package/dist/index.d.ts +6 -2
  39. package/dist/index.js +179 -92
  40. package/dist/interactions/index.d.ts +141 -0
  41. package/dist/interactions/index.js +60 -0
  42. package/dist/interactions/index.js.map +1 -0
  43. package/dist/parts-BcbitSNp.d.ts +176 -0
  44. package/dist/platform/index.d.ts +2 -270
  45. package/dist/platform/index.js +14 -278
  46. package/dist/platform/index.js.map +1 -1
  47. package/dist/preset-cloudflare/index.d.ts +0 -10
  48. package/dist/preset-cloudflare/index.js +1 -1
  49. package/dist/profile/index.d.ts +33 -2
  50. package/dist/profile/index.js +37 -1
  51. package/dist/profile/index.js.map +1 -1
  52. package/dist/sandbox/index.d.ts +47 -1
  53. package/dist/sandbox/index.js +11 -1
  54. package/dist/sso-CNOsARMJ.d.ts +285 -0
  55. package/dist/stream/index.js +1 -1
  56. package/dist/teams/index.js +9 -9
  57. package/dist/teams/invitations-api.js +3 -3
  58. package/dist/web-react/index.d.ts +229 -99
  59. package/dist/web-react/index.js +72 -22
  60. package/dist/wire-BaUF66AS.d.ts +61 -0
  61. package/package.json +25 -1
  62. package/dist/chunk-3PK3T4KD.js.map +0 -1
  63. package/dist/chunk-77RLNLFP.js.map +0 -1
  64. package/dist/chunk-SAOAAA3S.js.map +0 -1
  65. package/dist/chunk-VMY4TKMN.js.map +0 -1
@@ -1,105 +1,15 @@
1
1
  import * as react from 'react';
2
2
  import { ReactNode } from 'react';
3
- import { InteractionField, InteractionRequest, InteractionData } from '@tangle-network/agent-interface';
3
+ import { C as ChatInteraction, a as ChatInteractionField, b as ChatInteractionStatus, c as ChatSelectField, g as InteractionCancelData, i as InteractionRequestWire } from '../contract-DYbTzEDf.js';
4
+ export { d as ComposerAnswerDelivery, I as INTERACTION_CANCEL_EVENT, e as INTERACTION_EVENT, f as INTERACTION_RESOLVED_EVENT, h as InteractionPersistedPart, N as NoticeKind, j as NoticePersistedPart, P as ParseInteractionResult, k as canTransitionInteractionStatus, l as cancelStatusFor, m as composerAnswerData, n as composerAnswerDeliveries, o as dedupeQuestionInteractionsByContent, p as fieldAcceptsFreeText, q as interactionFromWireRequest, r as interactionPartKey, s as interactionToPersistedPart, t as isRenderableInteractionKind, u as isSafeInteractionFieldKey, v as isTerminalInteractionStatus, w as noticePart, x as noticePartKey, y as parseInteractionCancel, z as parseInteractionRequest, A as persistedPartToInteraction, B as questionInteractionContentSignature } from '../contract-DYbTzEDf.js';
5
+ import { InteractionData } from '@tangle-network/agent-interface';
4
6
  export { InteractionData, InteractionOutcome, InteractionRequest } from '@tangle-network/agent-interface';
5
7
  import { S as StepAgentActivity } from '../agent-activity-C8ZG0F0M.js';
6
8
  import { a as FlowTrace } from '../flow-types-Cb_AblZs.js';
7
9
  export { S as SandboxTerminalConnection, a as SandboxTerminalConnectionResponse, U as UseSandboxTerminalConnectionOptions, b as UseSandboxTerminalConnectionResult, t as tabTerminalConnectionId, u as useSandboxTerminalConnection } from '../sandbox-terminal-BIIC__CP.js';
8
10
  import { CatalogModel } from '../catalog/index.js';
9
11
  import { Harness } from '../harness/index.js';
10
-
11
- /** Sidecar → client: the agent raised an ask; data = `{ request }`. */
12
- declare const INTERACTION_EVENT: "interaction";
13
- /** Sidecar → client: the ask was withdrawn; data = `{ id, reason? }`. */
14
- declare const INTERACTION_CANCEL_EVENT: "interaction.cancel";
15
- /** An ask was answered; data = `{ id, status }`. In the wire contract so a
16
- * server broadcast and a client-local mark share one event name. */
17
- declare const INTERACTION_RESOLVED_EVENT: "interaction.resolved";
18
- declare function isRenderableInteractionKind(kind: string): boolean;
19
- /** Answer/field keys the sidecar will accept: identifier-safe and never a
20
- * prototype-pollution vector. */
21
- declare function isSafeInteractionFieldKey(key: string): boolean;
22
- type ChatSelectField = Extract<InteractionField, {
23
- type: 'select';
24
- }> & {
25
- allowCustom?: boolean;
26
- };
27
- type ChatInteractionField = Exclude<InteractionField, {
28
- type: 'select';
29
- }> | ChatSelectField;
30
- /** `InteractionRequest` whose select fields may carry `allowCustom`. */
31
- type InteractionRequestWire = Omit<InteractionRequest, 'answerSpec'> & {
32
- answerSpec: {
33
- fields: ChatInteractionField[];
34
- };
35
- };
36
- type ChatInteractionStatus = 'pending' | 'answered' | 'declined' | 'cancelled' | 'expired';
37
- /** The client/persisted view of one ask. `fields` come verbatim off the wire. */
38
- interface ChatInteraction {
39
- id: string;
40
- kind: string;
41
- title: string;
42
- body?: string;
43
- fields: ChatInteractionField[];
44
- status: ChatInteractionStatus;
45
- /** Set when status came from an `interaction.cancel` (e.g. "timeout"). */
46
- cancelReason?: string;
47
- }
48
- declare function isTerminalInteractionStatus(status: ChatInteractionStatus): boolean;
49
- /** Statuses only move forward (pending → terminal); a replayed/stale `pending`
50
- * must never resurrect a resolved card. */
51
- declare function canTransitionInteractionStatus(from: ChatInteractionStatus, to: ChatInteractionStatus): boolean;
52
- /** Maps an `interaction.cancel` reason to the card's terminal status. */
53
- declare function cancelStatusFor(reason: string | undefined): ChatInteractionStatus;
54
- /** Content identity for duplicate safety nets. Excludes volatile ids/statuses. */
55
- declare function questionInteractionContentSignature(interaction: ChatInteraction): string | null;
56
- declare function dedupeQuestionInteractionsByContent(interactions: ChatInteraction[]): ChatInteraction[];
57
- type ParseInteractionResult = {
58
- succeeded: true;
59
- value: InteractionRequestWire;
60
- } | {
61
- succeeded: false;
62
- error: string;
63
- };
64
- /** Parses an `interaction` event's data (`{ request }`). Validates the shape
65
- * with the agent-interface schema but returns the raw request so a field a
66
- * pinned schema predates (`allowCustom`) survives. */
67
- declare function parseInteractionRequest(data: Record<string, unknown> | undefined): ParseInteractionResult;
68
- interface InteractionCancelData {
69
- id: string;
70
- reason?: string;
71
- }
72
- declare function parseInteractionCancel(data: Record<string, unknown> | undefined): {
73
- succeeded: true;
74
- value: InteractionCancelData;
75
- } | {
76
- succeeded: false;
77
- error: string;
78
- };
79
- declare function fieldAcceptsFreeText(field: ChatInteractionField): boolean;
80
- interface ComposerAnswerDelivery {
81
- interactionId: string;
82
- field: ChatInteractionField;
83
- }
84
- /** One delivery per pending ask: the first free-text-capable field, else the
85
- * first field. Zero-field asks are skipped (nothing to carry the text). */
86
- declare function composerAnswerDeliveries(pending: ChatInteraction[]): ComposerAnswerDelivery[];
87
- /** Shapes composer text into the respond payload for the routed field
88
- * (select answers are string arrays on the wire; text answers are strings). */
89
- declare function composerAnswerData(field: ChatInteractionField, text: string): InteractionData;
90
- declare function interactionPartKey(id: string): string;
91
- declare function noticePartKey(id: string): string;
92
- type NoticeKind = 'warning' | 'auto-declined';
93
- /** Builds the persisted/streamed `notice` part — a one-line transcript notice
94
- * explaining an out-of-band event (warning, auto-declined interaction). */
95
- declare function noticePart(noticeKind: NoticeKind, id: string, text: string): Record<string, unknown>;
96
- /** Reads a wire request into the client's pending `ChatInteraction`. */
97
- declare function interactionFromWireRequest(request: InteractionRequestWire): ChatInteraction;
98
- /** Builds the persisted/streamed `interaction` part from a wire request. */
99
- declare function interactionToPersistedPart(request: InteractionRequestWire, status: ChatInteractionStatus, cancelReason?: string): Record<string, unknown>;
100
- /** Reads a persisted/streamed `interaction` part back into a `ChatInteraction`.
101
- * Returns null (caller logs) when the part is not one of ours. */
102
- declare function persistedPartToInteraction(part: Record<string, unknown>): ChatInteraction | null;
12
+ export { b as ChatTurnFilePartInput, a as ChatTurnPartInput, C as ChatTurnRequestPayload, f as chatTurnRequestInit } from '../wire-BaUF66AS.js';
103
13
 
104
14
  /**
105
15
  * Client-side chat-stream consumption — the NDJSON parse loop every agent
@@ -143,7 +53,10 @@ interface ChatStreamCallbacks {
143
53
  completionTokens: number;
144
54
  }) => void;
145
55
  onMetadata?: (data: Record<string, unknown>) => void;
146
- /** A loop-level error event (the turn failed server-side). */
56
+ /** A loop-level error event (the turn failed server-side). Optional, but the
57
+ * error never vanishes: when omitted, the message is synthesized into the
58
+ * transcript via `onText` (rendered by ChatMessages as a text segment) and
59
+ * logged with `console.error`. */
147
60
  onErrorEvent?: (message: string) => void;
148
61
  /** A sidecar interaction ask (kind: "question"/"plan"/…). The run is BLOCKED
149
62
  * in the broker until the user answers; a pending ask is "waiting on the
@@ -181,6 +94,17 @@ interface StreamChatOptions {
181
94
  */
182
95
  declare function streamChatTurn(opts: StreamChatOptions): Promise<ConsumeChatStreamResult>;
183
96
 
97
+ /** Prompt-part descriptor an uploaded file carries (the upload route's
98
+ * `UploadedChatFile.part`), echoed back in the turn body on send. Mirrors
99
+ * `/chat-routes`' wire shape structurally — no server import here. */
100
+ interface ComposerFilePart {
101
+ type: 'image' | 'file';
102
+ filename?: string;
103
+ mediaType?: string;
104
+ url?: string;
105
+ path?: string;
106
+ content?: string;
107
+ }
184
108
  interface ComposerFile {
185
109
  id: string;
186
110
  name: string;
@@ -189,11 +113,19 @@ interface ComposerFile {
189
113
  /** Number of files inside, for a folder chip. */
190
114
  fileCount?: number;
191
115
  status: 'pending' | 'uploading' | 'ready' | 'error';
116
+ /** Uploaded part descriptor; set once the upload route returns. Only
117
+ * `status: 'ready'` files with a part travel on a parts-aware send. */
118
+ part?: ComposerFilePart;
192
119
  }
193
120
  interface ChatComposerProps {
194
121
  /** Send the trimmed, non-empty message. Attached files travel separately via
195
- * `onAttach` + `pendingFiles` (the host consumes and clears them on send). */
196
- onSend: (message: string) => void;
122
+ * `onAttach` + `pendingFiles` (the host consumes and clears them on send).
123
+ * Optional when `onSendParts` is wired. */
124
+ onSend?: (message: string) => void;
125
+ /** Parts-aware send: receives the trimmed message plus the `part`
126
+ * descriptors of every `ready` pending file. Takes precedence over
127
+ * `onSend`; enables file-only sends (empty text, ≥1 ready part). */
128
+ onSendParts?: (message: string, parts: ComposerFilePart[]) => void;
197
129
  /** Stop the in-flight turn; shown in place of Send while `isStreaming`. */
198
130
  onCancel?: () => void;
199
131
  isStreaming?: boolean;
@@ -225,7 +157,205 @@ interface ChatComposerProps {
225
157
  sendLabel?: string;
226
158
  className?: string;
227
159
  }
228
- declare function ChatComposer({ onSend, onCancel, isStreaming, disabled, placeholder, value, onValueChange, initialValue, controls, controlsPlacement, onAttach, onAttachFolder, pendingFiles, onRemoveFile, accept, dropTitle, dropDescription, focusShortcut, sendLabel, className, }: ChatComposerProps): react.JSX.Element;
160
+ declare function ChatComposer({ onSend, onSendParts, onCancel, isStreaming, disabled, placeholder, value, onValueChange, initialValue, controls, controlsPlacement, onAttach, onAttachFolder, pendingFiles, onRemoveFile, accept, dropTitle, dropDescription, focusShortcut, sendLabel, className, }: ChatComposerProps): react.JSX.Element;
161
+
162
+ /**
163
+ * Shared answer-building + submit plumbing for the interaction cards
164
+ * (question, plan). Client-safe, no React: cards own their state, this owns
165
+ * the wire. Lifted from the gtm-agent fork (the most fix-absorbed of the three
166
+ * product copies), including the 30s submit timeout that keeps a dead route
167
+ * from wedging a card in "Submitting…".
168
+ */
169
+
170
+ /** Status-badge labels for an interaction card. `cancelled`/`expired` read the
171
+ * same across cards; each card supplies its own verbs for the other states
172
+ * (a question is answered/declined; a plan is approved/rejected). */
173
+ declare function interactionStatusLabels(labels: {
174
+ pending: string;
175
+ answered: string;
176
+ declined: string;
177
+ }): Record<ChatInteractionStatus, string>;
178
+ /** Terminal-state notes for an interaction card. The expiry/withdrawal lines
179
+ * share one shape around the card's noun ("question"/"plan"); any extra notes
180
+ * (e.g. a plan's `declined` revision line) merge on top. */
181
+ declare function interactionTerminalNotes(noun: string, extra?: Partial<Record<ChatInteractionStatus, string>>): Partial<Record<ChatInteractionStatus, string>>;
182
+ type FieldValues = Record<string, {
183
+ selected?: string[];
184
+ text?: string;
185
+ custom?: string;
186
+ }>;
187
+ /** The submitted value for one field, or null when it has no answer yet. */
188
+ declare function fieldAnswer(field: ChatInteractionField, values: FieldValues): InteractionData[string] | null;
189
+ /** All required fields answered → the respond payload; else null (not
190
+ * submittable yet). Optional unanswered fields are omitted. */
191
+ declare function buildAnswerData(fields: ChatInteractionField[], values: FieldValues): InteractionData | null;
192
+ declare function isLateAnswerableStatus(status: ChatInteractionStatus): boolean;
193
+ /** Secrets must never leave the sidecar answer channel for the visible chat
194
+ * transcript, so a secret-bearing ask cannot be late-answered. */
195
+ declare function hasSecretField(fields: ChatInteractionField[]): boolean;
196
+ /** Renders the late answer as a self-contained chat message: the original
197
+ * question, its context, and the user's answer(s). */
198
+ declare function lateAnswerMessage(interaction: ChatInteraction, data: InteractionData): string;
199
+ declare const INTERACTION_SUBMIT_TIMEOUT_MS = 30000;
200
+ declare const INTERACTION_SUBMIT_TIMEOUT_MESSAGE = "Could not reach the agent. Try again.";
201
+ /** One card submission: which ask, resolved how, with what answers. */
202
+ interface InteractionAnswerSubmission {
203
+ id: string;
204
+ outcome: 'accepted' | 'declined';
205
+ data?: InteractionData;
206
+ }
207
+ type InteractionSubmitResult = {
208
+ ok: true;
209
+ } | {
210
+ ok: false;
211
+ expired: boolean;
212
+ message: string;
213
+ };
214
+ /** The cards' only side-effect seam: POST one resolution, report the normalized
215
+ * outcome. Products bind their route URL + routing fields (workspaceId,
216
+ * threadId, session path param) via `createInteractionAnswerSubmitter` or a
217
+ * hand-rolled implementation. */
218
+ type SubmitInteractionAnswer = (submission: InteractionAnswerSubmission) => Promise<InteractionSubmitResult>;
219
+ /** Extracts the most specific error message a route returned. */
220
+ declare function responseErrorMessage(res: Response): Promise<{
221
+ code?: string;
222
+ message: string;
223
+ }>;
224
+ interface InteractionAnswerSubmitterOptions {
225
+ /** The product's answer route (the POST half of `createInteractionAnswerRoute`).
226
+ * A function when the URL carries the session (e.g. `/api/sessions/${id}/interactions`). */
227
+ url: string | ((submission: InteractionAnswerSubmission) => string);
228
+ /** Extra routing fields merged into the POST body (e.g. workspaceId, threadId). */
229
+ body?: Record<string, unknown> | ((submission: InteractionAnswerSubmission) => Record<string, unknown>);
230
+ timeoutMs?: number;
231
+ fetchImpl?: typeof fetch;
232
+ }
233
+ /**
234
+ * Builds the `SubmitInteractionAnswer` the cards consume: POSTs
235
+ * `{ ...routingFields, id, outcome, data? }` with an abortable timeout and
236
+ * normalizes the outcome. `expired` is the 410 path — the ask is gone
237
+ * (answered elsewhere, timed out, or the session moved on) and the card must
238
+ * flip to the same dead state a cancel event produces.
239
+ */
240
+ declare function createInteractionAnswerSubmitter(options: InteractionAnswerSubmitterOptions): SubmitInteractionAnswer;
241
+
242
+ type InteractionBadgeVariant = 'outline' | 'default' | 'destructive';
243
+ declare function InteractionBadge({ variant, children }: {
244
+ variant: InteractionBadgeVariant;
245
+ children: string;
246
+ }): react.JSX.Element;
247
+ declare function InteractionActionButton({ variant, onClick, disabled, children, }: {
248
+ variant?: 'primary' | 'outline';
249
+ onClick: () => void;
250
+ disabled?: boolean;
251
+ children: string;
252
+ }): react.JSX.Element;
253
+ interface QuestionOptionListProps {
254
+ /** Radio/checkbox group name — unique per field so selection is isolated. */
255
+ groupName: string;
256
+ /** Stable prefix for per-option input ids (label htmlFor pairing). */
257
+ idPrefix: string;
258
+ options: ChatSelectField['options'];
259
+ /** Checkbox (multi-select) vs radio (single). */
260
+ multi: boolean;
261
+ selectedValues: string[];
262
+ disabled: boolean;
263
+ onToggle: (value: string) => void;
264
+ }
265
+ /** The radio/checkbox option rows for a select field. Renders a fragment of
266
+ * option `<label>` rows so a card keeps its own wrapping layout and appends
267
+ * its own write-in input. */
268
+ declare function QuestionOptionList({ groupName, idPrefix, options, multi, selectedValues, disabled, onToggle, }: QuestionOptionListProps): react.JSX.Element;
269
+ interface InteractionQuestionCardProps {
270
+ interaction: ChatInteraction;
271
+ /** Viewer-vs-editor gate: false renders everything read-only. */
272
+ canWrite: boolean;
273
+ /** POST one resolution to the product's answer route (see
274
+ * `createInteractionAnswerSubmitter`). Never called for late answers. */
275
+ submitAnswer: SubmitInteractionAnswer;
276
+ /** Fired when this card resolves locally (answered, or discovered expired
277
+ * via a 410) so the stream/route state stays in sync. */
278
+ onResolved?: (id: string, status: Exclude<ChatInteractionStatus, 'pending'>) => void;
279
+ /** Delivers a late answer (the ask expired/was withdrawn) as a fresh chat
280
+ * turn. Return/resolve `false` when the send was rejected so the card stays
281
+ * retryable. Omit to hide the late-answer affordance entirely. */
282
+ onLateAnswer?: (message: string) => boolean | void | Promise<boolean | void>;
283
+ className?: string;
284
+ }
285
+ declare function InteractionQuestionCard({ interaction, canWrite, submitAnswer, onResolved, onLateAnswer, className, }: InteractionQuestionCardProps): react.JSX.Element;
286
+
287
+ interface InteractionPlanCardProps {
288
+ interaction: ChatInteraction;
289
+ /** Viewer-vs-editor gate: false renders everything read-only. */
290
+ canWrite: boolean;
291
+ /** POST one resolution to the product's answer route (see
292
+ * `createInteractionAnswerSubmitter`). */
293
+ submitAnswer: SubmitInteractionAnswer;
294
+ /** Fired when this card resolves locally (approved/rejected, or discovered
295
+ * expired via a 410) so the stream/route state stays in sync. */
296
+ onResolved?: (id: string, status: Exclude<ChatInteractionStatus, 'pending'>) => void;
297
+ /** Renders the plan body (markdown). Falls back to pre-wrapped plain text. */
298
+ renderMarkdown?: (markdown: string) => ReactNode;
299
+ className?: string;
300
+ }
301
+ declare function InteractionPlanCard({ interaction, canWrite, submitAnswer, onResolved, renderMarkdown, className, }: InteractionPlanCardProps): react.JSX.Element;
302
+
303
+ /**
304
+ * useChatInteractions — the interaction-state wiring every consumer of
305
+ * `ChatStreamCallbacks.onInteraction` re-implements: an id-keyed,
306
+ * insertion-ordered list with
307
+ *
308
+ * - forward-only status transitions (a replayed/stale `pending` never
309
+ * resurrects a resolved card),
310
+ * - pending-question content dedupe (a re-emitted duplicate ask never renders
311
+ * a second card),
312
+ * - cancel-event application (`interaction.cancel` → cancelled/expired),
313
+ * - local resolution marking (the card's `onResolved`),
314
+ * - reload restore from the answer route's GET list (sidecar registry is the
315
+ * source of truth after a reload),
316
+ * - turn-end settling (client mirror of the server's finalize pass: a turn
317
+ * that completed without a cancel was answered; a failed turn can make no
318
+ * such claim).
319
+ *
320
+ * The reducer functions are pure and exported for non-React consumers/tests;
321
+ * the hook is a thin `useState` shell over them.
322
+ */
323
+
324
+ /** Insert or update one interaction. A terminal existing entry wins over any
325
+ * incoming state for the same id; a new pending ask that duplicates another
326
+ * pending ask's content is dropped. Returns the same array when unchanged. */
327
+ declare function upsertChatInteraction(list: ChatInteraction[], interaction: ChatInteraction): ChatInteraction[];
328
+ /** Applies an `interaction.cancel` event: only a pending ask moves, to
329
+ * `expired` (reason:"timeout") or `cancelled`. */
330
+ declare function cancelChatInteraction(list: ChatInteraction[], cancel: InteractionCancelData): ChatInteraction[];
331
+ /** Marks one ask resolved locally (the card's `onResolved`). Forward-only. */
332
+ declare function resolveChatInteraction(list: ChatInteraction[], id: string, status: Exclude<ChatInteractionStatus, 'pending'>): ChatInteraction[];
333
+ /** Settles every still-pending ask when the turn ends: `answered` for a turn
334
+ * that completed cleanly, `expired` for one that failed. */
335
+ declare function terminalizePendingChatInteractions(list: ChatInteraction[], status: Extract<ChatInteractionStatus, 'answered' | 'expired'>): ChatInteraction[];
336
+ /** Reload restore from the answer route's GET list: every listed ask is
337
+ * outstanding (upserted pending), and every previously-pending ask the sidecar
338
+ * no longer lists was resolved while we were away (settled as answered). */
339
+ declare function restoreChatInteractions(list: ChatInteraction[], outstanding: InteractionRequestWire[]): ChatInteraction[];
340
+ interface UseChatInteractionsResult {
341
+ /** All known interactions, insertion-ordered. */
342
+ interactions: ChatInteraction[];
343
+ /** The asks currently blocking the run (waiting on the user). */
344
+ pending: ChatInteraction[];
345
+ /** Wire to `ChatStreamCallbacks.onInteraction` (and persisted-part replay). */
346
+ upsert: (interaction: ChatInteraction) => void;
347
+ /** Wire to `interaction.cancel` events. */
348
+ applyCancel: (cancel: InteractionCancelData) => void;
349
+ /** Wire to the cards' `onResolved`. */
350
+ markResolved: (id: string, status: Exclude<ChatInteractionStatus, 'pending'>) => void;
351
+ /** Wire to the answer route's GET list after a reload/reconnect. */
352
+ restore: (outstanding: InteractionRequestWire[]) => void;
353
+ /** Settle still-pending asks when the turn ends. */
354
+ terminalizePending: (status: Extract<ChatInteractionStatus, 'answered' | 'expired'>) => void;
355
+ /** Drop everything (thread switch). */
356
+ reset: () => void;
357
+ }
358
+ declare function useChatInteractions(): UseChatInteractionsResult;
229
359
 
230
360
  /**
231
361
  * Provider brand marks — real logo path data (simple-icons / SVG Logos, both
@@ -656,4 +786,4 @@ declare function useThinkingSeconds(active: boolean): number;
656
786
  */
657
787
  declare function ChatMessages({ messages, models, renderMarkdown, renderExtras, userLabel, agentLabel, loading, approval, onToolCallClick, toolRenderers, error, onRetry, renderEmpty, emptyState, header, }: ChatMessagesProps): react.JSX.Element;
658
788
 
659
- export { type ActivityTone, type AgentActivityPage, AgentActivityPanel, type AgentActivityPanelProps, type AgentActivityRecord, AgentSessionControls, type AgentSessionControlsProps, CatalogModel, ChatComposer, type ChatComposerProps, type ChatEmptyDoor, ChatEmptyState, type ChatEmptyStateProps, type ChatInteraction, type ChatInteractionField, type ChatInteractionStatus, type ChatMessageMetrics, type ChatMessageSegment, ChatMessages, type ChatMessagesProps, type ChatSelectField, type ChatStreamCallbacks, type ChatStreamToolCall, type ChatStreamToolResult, type ChatToolCallInfo, type ChatUiMessage, type ComposerAnswerDelivery, type ComposerFile, type ConsumeChatStreamResult, DEFAULT_EFFORT_LEVELS, type EffortLevel, EffortPicker, type EffortPickerProps, FlowWaterfall, type FlowWaterfallProps, INTERACTION_CANCEL_EVENT, INTERACTION_EVENT, INTERACTION_RESOLVED_EVENT, type InteractionCancelData, type InteractionRequestWire, MissionActivityLane, type MissionActivityLaneProps, ModelPicker, type ModelPickerProps, type NoticeKind, type ParseInteractionResult, type ProposalApprovalHandlers, ProviderLogo, type ProviderLogoProps, RunDrillIn, type RunDrillInProps, SeatPaywall, type SeatPaywallProps, type SmoothRevealOptions, type StreamChatOptions, type ToolDetailRenderers, type ToolRunRecord, type ToolRunStep, type WaterfallRow, activityTone, canTransitionInteractionStatus, cancelStatusFor, composerAnswerData, composerAnswerDeliveries, consumeChatStream, dedupeQuestionInteractionsByContent, dispatchChatStreamLine, fieldAcceptsFreeText, formatActivityCost, formatActivityDuration, formatModelCost, formatTokensPerSecond, interactionFromWireRequest, interactionPartKey, interactionToPersistedPart, isRenderableInteractionKind, isSafeInteractionFieldKey, isTerminalInteractionStatus, mergeActivityPages, nextRevealCount, noticePart, noticePartKey, parseInteractionCancel, parseInteractionRequest, pendingApprovalOf, persistedPartToInteraction, questionInteractionContentSignature, streamChatTurn, usePending, usePopover, useSmoothText, useThinkingSeconds, waterfallLayout };
789
+ export { type ActivityTone, type AgentActivityPage, AgentActivityPanel, type AgentActivityPanelProps, type AgentActivityRecord, AgentSessionControls, type AgentSessionControlsProps, CatalogModel, ChatComposer, type ChatComposerProps, type ChatEmptyDoor, ChatEmptyState, type ChatEmptyStateProps, ChatInteraction, ChatInteractionField, ChatInteractionStatus, type ChatMessageMetrics, type ChatMessageSegment, ChatMessages, type ChatMessagesProps, ChatSelectField, type ChatStreamCallbacks, type ChatStreamToolCall, type ChatStreamToolResult, type ChatToolCallInfo, type ChatUiMessage, type ComposerFile, type ComposerFilePart, type ConsumeChatStreamResult, DEFAULT_EFFORT_LEVELS, type EffortLevel, EffortPicker, type EffortPickerProps, type FieldValues, FlowWaterfall, type FlowWaterfallProps, INTERACTION_SUBMIT_TIMEOUT_MESSAGE, INTERACTION_SUBMIT_TIMEOUT_MS, InteractionActionButton, type InteractionAnswerSubmission, type InteractionAnswerSubmitterOptions, InteractionBadge, type InteractionBadgeVariant, InteractionCancelData, InteractionPlanCard, type InteractionPlanCardProps, InteractionQuestionCard, type InteractionQuestionCardProps, InteractionRequestWire, type InteractionSubmitResult, MissionActivityLane, type MissionActivityLaneProps, ModelPicker, type ModelPickerProps, type ProposalApprovalHandlers, ProviderLogo, type ProviderLogoProps, QuestionOptionList, type QuestionOptionListProps, RunDrillIn, type RunDrillInProps, SeatPaywall, type SeatPaywallProps, type SmoothRevealOptions, type StreamChatOptions, type SubmitInteractionAnswer, type ToolDetailRenderers, type ToolRunRecord, type ToolRunStep, type UseChatInteractionsResult, type WaterfallRow, activityTone, buildAnswerData, cancelChatInteraction, consumeChatStream, createInteractionAnswerSubmitter, dispatchChatStreamLine, fieldAnswer, formatActivityCost, formatActivityDuration, formatModelCost, formatTokensPerSecond, hasSecretField, interactionStatusLabels, interactionTerminalNotes, isLateAnswerableStatus, lateAnswerMessage, mergeActivityPages, nextRevealCount, pendingApprovalOf, resolveChatInteraction, responseErrorMessage, restoreChatInteractions, streamChatTurn, terminalizePendingChatInteractions, upsertChatInteraction, useChatInteractions, usePending, usePopover, useSmoothText, useThinkingSeconds, waterfallLayout };
@@ -7,54 +7,81 @@ import {
7
7
  DEFAULT_EFFORT_LEVELS,
8
8
  EffortPicker,
9
9
  FlowWaterfall,
10
- INTERACTION_CANCEL_EVENT,
11
- INTERACTION_EVENT,
12
- INTERACTION_RESOLVED_EVENT,
10
+ INTERACTION_SUBMIT_TIMEOUT_MESSAGE,
11
+ INTERACTION_SUBMIT_TIMEOUT_MS,
12
+ InteractionActionButton,
13
+ InteractionBadge,
14
+ InteractionPlanCard,
15
+ InteractionQuestionCard,
13
16
  MissionActivityLane,
14
17
  ModelPicker,
15
18
  ProviderLogo,
19
+ QuestionOptionList,
16
20
  RunDrillIn,
17
21
  SeatPaywall,
18
22
  activityTone,
19
- canTransitionInteractionStatus,
20
- cancelStatusFor,
21
- composerAnswerData,
22
- composerAnswerDeliveries,
23
+ buildAnswerData,
24
+ cancelChatInteraction,
23
25
  consumeChatStream,
24
- dedupeQuestionInteractionsByContent,
26
+ createInteractionAnswerSubmitter,
25
27
  dispatchChatStreamLine,
26
- fieldAcceptsFreeText,
28
+ fieldAnswer,
27
29
  formatActivityCost,
28
30
  formatActivityDuration,
29
31
  formatModelCost,
30
32
  formatTokensPerSecond,
31
- interactionFromWireRequest,
32
- interactionPartKey,
33
- interactionToPersistedPart,
34
- isRenderableInteractionKind,
35
- isSafeInteractionFieldKey,
36
- isTerminalInteractionStatus,
33
+ hasSecretField,
34
+ interactionStatusLabels,
35
+ interactionTerminalNotes,
36
+ isLateAnswerableStatus,
37
+ lateAnswerMessage,
37
38
  mergeActivityPages,
38
39
  nextRevealCount,
39
- noticePart,
40
- noticePartKey,
41
- parseInteractionCancel,
42
- parseInteractionRequest,
43
40
  pendingApprovalOf,
44
- persistedPartToInteraction,
45
- questionInteractionContentSignature,
41
+ resolveChatInteraction,
42
+ responseErrorMessage,
43
+ restoreChatInteractions,
46
44
  streamChatTurn,
45
+ terminalizePendingChatInteractions,
46
+ upsertChatInteraction,
47
+ useChatInteractions,
47
48
  usePending,
48
49
  usePopover,
49
50
  useSmoothText,
50
51
  useThinkingSeconds,
51
52
  waterfallLayout
52
- } from "../chunk-VMY4TKMN.js";
53
+ } from "../chunk-FCQP75JT.js";
53
54
  import {
54
55
  tabTerminalConnectionId,
55
56
  useSandboxTerminalConnection
56
57
  } from "../chunk-65P3HJY3.js";
58
+ import {
59
+ chatTurnRequestInit
60
+ } from "../chunk-5SV5PSU7.js";
57
61
  import "../chunk-2QI7XV2T.js";
62
+ import {
63
+ INTERACTION_CANCEL_EVENT,
64
+ INTERACTION_EVENT,
65
+ INTERACTION_RESOLVED_EVENT,
66
+ canTransitionInteractionStatus,
67
+ cancelStatusFor,
68
+ composerAnswerData,
69
+ composerAnswerDeliveries,
70
+ dedupeQuestionInteractionsByContent,
71
+ fieldAcceptsFreeText,
72
+ interactionFromWireRequest,
73
+ interactionPartKey,
74
+ interactionToPersistedPart,
75
+ isRenderableInteractionKind,
76
+ isSafeInteractionFieldKey,
77
+ isTerminalInteractionStatus,
78
+ noticePart,
79
+ noticePartKey,
80
+ parseInteractionCancel,
81
+ parseInteractionRequest,
82
+ persistedPartToInteraction,
83
+ questionInteractionContentSignature
84
+ } from "../chunk-4TXDD6P2.js";
58
85
  import "../chunk-E7QYOOON.js";
59
86
  export {
60
87
  AgentActivityPanel,
@@ -68,30 +95,47 @@ export {
68
95
  INTERACTION_CANCEL_EVENT,
69
96
  INTERACTION_EVENT,
70
97
  INTERACTION_RESOLVED_EVENT,
98
+ INTERACTION_SUBMIT_TIMEOUT_MESSAGE,
99
+ INTERACTION_SUBMIT_TIMEOUT_MS,
100
+ InteractionActionButton,
101
+ InteractionBadge,
102
+ InteractionPlanCard,
103
+ InteractionQuestionCard,
71
104
  MissionActivityLane,
72
105
  ModelPicker,
73
106
  ProviderLogo,
107
+ QuestionOptionList,
74
108
  RunDrillIn,
75
109
  SeatPaywall,
76
110
  activityTone,
111
+ buildAnswerData,
77
112
  canTransitionInteractionStatus,
113
+ cancelChatInteraction,
78
114
  cancelStatusFor,
115
+ chatTurnRequestInit,
79
116
  composerAnswerData,
80
117
  composerAnswerDeliveries,
81
118
  consumeChatStream,
119
+ createInteractionAnswerSubmitter,
82
120
  dedupeQuestionInteractionsByContent,
83
121
  dispatchChatStreamLine,
84
122
  fieldAcceptsFreeText,
123
+ fieldAnswer,
85
124
  formatActivityCost,
86
125
  formatActivityDuration,
87
126
  formatModelCost,
88
127
  formatTokensPerSecond,
128
+ hasSecretField,
89
129
  interactionFromWireRequest,
90
130
  interactionPartKey,
131
+ interactionStatusLabels,
132
+ interactionTerminalNotes,
91
133
  interactionToPersistedPart,
134
+ isLateAnswerableStatus,
92
135
  isRenderableInteractionKind,
93
136
  isSafeInteractionFieldKey,
94
137
  isTerminalInteractionStatus,
138
+ lateAnswerMessage,
95
139
  mergeActivityPages,
96
140
  nextRevealCount,
97
141
  noticePart,
@@ -101,8 +145,14 @@ export {
101
145
  pendingApprovalOf,
102
146
  persistedPartToInteraction,
103
147
  questionInteractionContentSignature,
148
+ resolveChatInteraction,
149
+ responseErrorMessage,
150
+ restoreChatInteractions,
104
151
  streamChatTurn,
105
152
  tabTerminalConnectionId,
153
+ terminalizePendingChatInteractions,
154
+ upsertChatInteraction,
155
+ useChatInteractions,
106
156
  usePending,
107
157
  usePopover,
108
158
  useSandboxTerminalConnection,
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Wire contract between the chat client (composer + `streamChatTurn`) and the
3
+ * assembled server vertical (`createChatTurnRoutes`). Import-free on purpose:
4
+ * `/web-react` re-exports these types into browser bundles, so nothing here may
5
+ * reach a Node builtin or an engine package.
6
+ *
7
+ * The part shape mirrors the sandbox SDK's `PromptInputPart` structurally
8
+ * (text | image | file with filename/mediaType/url/path/content) — derived
9
+ * here, not imported, so the client bundle never touches the SDK.
10
+ */
11
+ interface ChatTurnTextPartInput {
12
+ type: 'text';
13
+ text: string;
14
+ }
15
+ /** A non-text prompt part the upload route hands back and the client echoes
16
+ * on send. `url` carries an inline `data:` URI for small files; `path` is a
17
+ * sandbox workspace reference for large ones (the >1 MiB gateway body cap
18
+ * makes the two-step upload mandatory). */
19
+ interface ChatTurnFilePartInput {
20
+ type: 'image' | 'file';
21
+ filename?: string;
22
+ mediaType?: string;
23
+ url?: string;
24
+ path?: string;
25
+ content?: string;
26
+ }
27
+ type ChatTurnPartInput = ChatTurnTextPartInput | ChatTurnFilePartInput;
28
+ /** POST body for the turn route. `content` may be empty when `parts` carry the
29
+ * message (an image-only send). Product routing fields (workspaceId etc.) ride
30
+ * alongside and are read by the product's `authorize` seam. */
31
+ interface ChatTurnRequestPayload {
32
+ threadId: string;
33
+ content?: string;
34
+ /** Non-text parts from the upload route, echoed back verbatim. */
35
+ parts?: ChatTurnFilePartInput[];
36
+ model?: string;
37
+ effort?: 'auto' | 'low' | 'medium' | 'high';
38
+ harness?: string;
39
+ /** Client-generated idempotency key for the logical turn (retry-safe). */
40
+ turnId?: string;
41
+ [key: string]: unknown;
42
+ }
43
+ /** `fetch` init for the turn route — the one place the client wire shape is
44
+ * serialized, so composer glue and products never drift from the server's
45
+ * parser. */
46
+ declare function chatTurnRequestInit(payload: ChatTurnRequestPayload): RequestInit;
47
+ declare const INLINE_PARTS_MAX_BYTES = 950000;
48
+ declare class ChatTurnInputError extends Error {
49
+ readonly status: number;
50
+ readonly code: string;
51
+ constructor(message: string, status?: number, code?: string);
52
+ }
53
+ declare function promptPartsByteSize(parts: ChatTurnPartInput[]): number;
54
+ /** Throws `ChatTurnInputError` (413) when the parts' inline payload would blow
55
+ * the gateway cap. Path-ref parts are tiny by construction and always pass. */
56
+ declare function assertPromptPartsWithinCap(parts: ChatTurnPartInput[], maxBytes?: number): void;
57
+ /** Validates the untyped `parts` array off the wire. Returns the typed parts
58
+ * or throws `ChatTurnInputError` (400) naming the offending entry. */
59
+ declare function parseChatTurnParts(raw: unknown): ChatTurnFilePartInput[];
60
+
61
+ export { type ChatTurnRequestPayload as C, INLINE_PARTS_MAX_BYTES as I, type ChatTurnPartInput as a, type ChatTurnFilePartInput as b, ChatTurnInputError as c, type ChatTurnTextPartInput as d, assertPromptPartsWithinCap as e, chatTurnRequestInit as f, promptPartsByteSize as g, parseChatTurnParts as p };