@tangle-network/agent-app 0.60.234 → 0.60.236

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 (61) hide show
  1. package/dist/assistant/index.js +8 -9
  2. package/dist/assistant/index.js.map +1 -1
  3. package/dist/chat-react/index.js +4 -4
  4. package/dist/{chunk-BNFUJNPS.js → chunk-A77IBQ7S.js} +456 -431
  5. package/dist/chunk-A77IBQ7S.js.map +1 -0
  6. package/dist/chunk-BDEBQ4WO.js +38 -0
  7. package/dist/chunk-BDEBQ4WO.js.map +1 -0
  8. package/dist/{chunk-FJEGGUOQ.js → chunk-BGDQ7245.js} +4345 -3610
  9. package/dist/chunk-BGDQ7245.js.map +1 -0
  10. package/dist/{chunk-232KA6MR.js → chunk-CI53V6DD.js} +3 -3
  11. package/dist/{chunk-4JAXSEYW.js → chunk-DLVMKDFX.js} +3 -3
  12. package/dist/{chunk-JYVUFRRV.js → chunk-FUZETA6Z.js} +2 -2
  13. package/dist/{chunk-XIN7DOAB.js → chunk-R4X5474U.js} +35 -33
  14. package/dist/chunk-R4X5474U.js.map +1 -0
  15. package/dist/{chunk-3K45OQ5X.js → chunk-ZDPUC6CM.js} +43 -3
  16. package/dist/chunk-ZDPUC6CM.js.map +1 -0
  17. package/dist/{mention-editor-6FJ6HRSN.js → mention-editor-B23OMFT2.js} +2 -2
  18. package/dist/settings-react/index.js +1 -1
  19. package/dist/studio-react/index.js +2 -4
  20. package/dist/studio-react/index.js.map +1 -1
  21. package/dist/web-react/agent-profile-editor.js +4 -4
  22. package/dist/web-react/chat-composer-types.d.ts +301 -0
  23. package/dist/web-react/chat-composer.d.ts +2 -300
  24. package/dist/web-react/chat-empty-state.d.ts +27 -0
  25. package/dist/web-react/chat-message-body.d.ts +23 -0
  26. package/dist/web-react/chat-message-metrics.d.ts +6 -0
  27. package/dist/web-react/chat-message-types.d.ts +158 -0
  28. package/dist/web-react/chat-messages.d.ts +17 -0
  29. package/dist/web-react/chat-tool-call.d.ts +31 -0
  30. package/dist/web-react/composer-glyphs.d.ts +28 -0
  31. package/dist/web-react/index.d.ts +6 -245
  32. package/dist/web-react/index.js +13 -14
  33. package/dist/web-react/record-grid-editors.d.ts +31 -0
  34. package/dist/web-react/record-grid-review-actions.d.ts +13 -0
  35. package/dist/web-react/record-grid-source-marker.d.ts +27 -0
  36. package/dist/web-react/record-grid-types.d.ts +86 -0
  37. package/dist/web-react/record-grid.d.ts +2 -85
  38. package/dist/web-react/run-drill-in.d.ts +28 -0
  39. package/dist/web-react/session-history-panel.d.ts +84 -0
  40. package/dist/web-react/session-history.d.ts +4 -187
  41. package/dist/web-react/use-composer-commands.d.ts +25 -0
  42. package/dist/web-react/use-composer-file-intake.d.ts +20 -0
  43. package/dist/web-react/use-composer-send.d.ts +34 -0
  44. package/dist/web-react/use-infinite-scroll.d.ts +20 -0
  45. package/dist/web-react/use-session-actions.d.ts +47 -0
  46. package/dist/web-react/use-session-history.d.ts +44 -0
  47. package/dist/workspace-react/index.js +5 -7
  48. package/dist/workspace-react/index.js.map +1 -1
  49. package/package.json +1 -1
  50. package/dist/chunk-35APKGPB.js +0 -749
  51. package/dist/chunk-35APKGPB.js.map +0 -1
  52. package/dist/chunk-3K45OQ5X.js.map +0 -1
  53. package/dist/chunk-A2GG4D4A.js +0 -43
  54. package/dist/chunk-A2GG4D4A.js.map +0 -1
  55. package/dist/chunk-BNFUJNPS.js.map +0 -1
  56. package/dist/chunk-FJEGGUOQ.js.map +0 -1
  57. package/dist/chunk-XIN7DOAB.js.map +0 -1
  58. /package/dist/{chunk-232KA6MR.js.map → chunk-CI53V6DD.js.map} +0 -0
  59. /package/dist/{chunk-4JAXSEYW.js.map → chunk-DLVMKDFX.js.map} +0 -0
  60. /package/dist/{chunk-JYVUFRRV.js.map → chunk-FUZETA6Z.js.map} +0 -0
  61. /package/dist/{mention-editor-6FJ6HRSN.js.map → mention-editor-B23OMFT2.js.map} +0 -0
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  AGENT_PROFILE_EDITOR_SECTIONS,
3
3
  AgentProfileEditor
4
- } from "../chunk-4JAXSEYW.js";
5
- import "../chunk-232KA6MR.js";
6
- import "../chunk-JYVUFRRV.js";
7
- import "../chunk-XIN7DOAB.js";
4
+ } from "../chunk-DLVMKDFX.js";
5
+ import "../chunk-CI53V6DD.js";
6
+ import "../chunk-FUZETA6Z.js";
7
+ import "../chunk-R4X5474U.js";
8
8
  import "../chunk-RASGKEAL.js";
9
9
  import "../chunk-VBRUG4N5.js";
10
10
  import "../chunk-B7CL7ENS.js";
@@ -0,0 +1,301 @@
1
+ /** Draft, attachment, command, and host callback contracts for ChatComposer. */
2
+ import type { ReactNode } from 'react';
3
+ import type { ComposerFileRejection } from './composer-file-accept';
4
+ import type { ComposerMentionProp } from './use-file-mentions';
5
+ import type { DictationAudio } from './use-dictation';
6
+ /** Prompt-part descriptor an uploaded file carries (the upload route's
7
+ * `UploadedChatFile.part`), echoed back in the turn body on send. Mirrors
8
+ * `/chat-routes`' wire shape structurally — no server import here. */
9
+ export interface ComposerFilePart {
10
+ type: 'image' | 'file';
11
+ filename?: string;
12
+ mediaType?: string;
13
+ url?: string;
14
+ path?: string;
15
+ content?: string;
16
+ }
17
+ export interface ComposerFile {
18
+ id: string;
19
+ name: string;
20
+ size?: number;
21
+ kind: 'file' | 'folder';
22
+ /** Number of files inside, for a folder chip. */
23
+ fileCount?: number;
24
+ status: 'pending' | 'uploading' | 'ready' | 'error';
25
+ /** Uploaded part descriptor; set once the upload route returns. Only
26
+ * `status: 'ready'` files with a part travel on a parts-aware send. */
27
+ part?: ComposerFilePart;
28
+ /** Object URL for an image thumbnail on the chip. The host owns the URL's
29
+ * whole life — `URL.createObjectURL` when the file is staged,
30
+ * `URL.revokeObjectURL` when it leaves — and the composer only reads it.
31
+ * `useComposerAttachments` already does both. */
32
+ previewUrl?: string;
33
+ /** Why this file failed, shown on the chip while `status: 'error'`. Without
34
+ * it an error chip is red and mute, which tells the user nothing. */
35
+ errorMessage?: string;
36
+ }
37
+ /** A piece of context the agent will see beside the next message — an open
38
+ * file, a selected record, a pinned document. Rendered as its own chip row,
39
+ * separate from staged attachments: context is what the turn already carries,
40
+ * an attachment is what the user is adding to it. */
41
+ export interface ComposerContextItem {
42
+ id: string;
43
+ label: string;
44
+ icon?: ReactNode;
45
+ /** Omit for a chip the user cannot dismiss. */
46
+ onRemove?: () => void;
47
+ }
48
+ /** A send the host refused. `error` is shown verbatim in the composer's notice;
49
+ * omit it for the generic copy. */
50
+ export interface ComposerSendRejected {
51
+ ok: false;
52
+ error?: string;
53
+ }
54
+ /**
55
+ * What a send handler reports back. `void` — what every handler returned before
56
+ * this existed — reads as accepted, so wiring stays unchanged; a thrown error, a
57
+ * rejected promise, or `{ ok: false }` is the rejection that restores the draft.
58
+ * A handler that resolves only when the whole turn finishes still reports
59
+ * correctly: the input already cleared on dispatch, so the answer only decides
60
+ * whether the draft comes back.
61
+ */
62
+ export type ComposerSendOutcome = void | {
63
+ ok: true;
64
+ } | ComposerSendRejected;
65
+ export type ComposerSendResult = ComposerSendOutcome | Promise<ComposerSendOutcome>;
66
+ /**
67
+ * A send handler, typed as a UNION with the legacy `=> void` signature rather
68
+ * than as `(…) => ComposerSendResult` alone.
69
+ *
70
+ * TypeScript's return-type-`void` rule accepts a function returning ANYTHING
71
+ * where a `=> void` is expected, and that rule fires only when the target's
72
+ * return type is exactly `void` — not when it is a union that contains `void`.
73
+ * So narrowing this prop to `ComposerSendResult` would reject handler shapes
74
+ * that compiled against the shipped `onSend?: (message: string) => void`:
75
+ * `onSend={(m) => rows.push(m)}` (returns `number`) and
76
+ * `onSend={(m) => append({ role: 'user', content: m })}` (an ai-sdk append
77
+ * returns `Promise<string | null | undefined>`) both stop compiling, on a
78
+ * package whose pinned consumers must never need a source edit to take a minor.
79
+ *
80
+ * The union keeps both: a legacy handler lands on the first member, and a
81
+ * handler that reports an outcome lands on the second. A call through it
82
+ * resolves to `void | ComposerSendResult`, which IS `ComposerSendResult`, so
83
+ * the composer reads the outcome exactly as before.
84
+ */
85
+ export type ComposerSendHandler = ((message: string) => void) | ((message: string) => ComposerSendResult);
86
+ /** @see ComposerSendHandler — the parts-aware arity, same union for the same reason. */
87
+ export type ComposerSendPartsHandler = ((message: string, parts: ComposerFilePart[]) => void) | ((message: string, parts: ComposerFilePart[]) => ComposerSendResult);
88
+ /** The rejected send, handed to `onSendFailed` so the host can undo whatever it
89
+ * cleared optimistically — most importantly the staged attachments, which the
90
+ * composer does not own (`pendingFiles` is a prop). */
91
+ export interface ComposerSendFailure {
92
+ /** The reason as the composer renders it. */
93
+ message: string;
94
+ /** The user's exact draft, untrimmed. */
95
+ text: string;
96
+ /** The parts the rejected send carried. */
97
+ parts: ComposerFilePart[];
98
+ /** Whatever the handler threw / rejected with, or the `{ ok: false }` value. */
99
+ error: unknown;
100
+ /** True when the draft was put back in the textarea (the box was empty).
101
+ * False means the user had typed a replacement, so the unsent text is held in
102
+ * the notice instead. */
103
+ restored: boolean;
104
+ }
105
+ /**
106
+ * One `/` command the composer offers. Typing `/` at position 0 opens the
107
+ * command menu; the rest of the token filters it (the same prefix > substring
108
+ * > token-order ranking as the command palette). Picking a command CLEARS the
109
+ * token from the draft and calls `run` — what the command does (a route, a
110
+ * dialog, a draft transformation) is the product's business.
111
+ */
112
+ export interface SlashCommand {
113
+ /** Command name without the leading slash: `model`, `clear`. */
114
+ name: string;
115
+ /** One line of what it does, rendered beside the name. */
116
+ description: string;
117
+ run: () => void;
118
+ }
119
+ /** A skill the host has made eligible for this turn. The id is the value the
120
+ * host validates and sends; the name and description are display metadata. */
121
+ export interface ComposerSkillOption {
122
+ id: string;
123
+ name: string;
124
+ description: string;
125
+ }
126
+ export interface ChatComposerProps {
127
+ /** Send the trimmed message, or an empty message when a skill is selected.
128
+ * Attached files travel separately via
129
+ * `onAttach` + `pendingFiles` (the host consumes and clears them on send).
130
+ * Optional when `onSendParts` is wired.
131
+ *
132
+ * Report a refused send by throwing, rejecting, or returning `{ ok: false }`
133
+ * — the composer restores the draft rather than losing it. */
134
+ onSend?: ComposerSendHandler;
135
+ /** Parts-aware send: receives the trimmed message plus the `part`
136
+ * descriptors of every `ready` pending file. Takes precedence over
137
+ * `onSend`; enables file-only sends (empty text, ≥1 ready part).
138
+ *
139
+ * Same rejection contract as `onSend`. */
140
+ onSendParts?: ComposerSendPartsHandler;
141
+ /** Notified when a send is rejected, after the composer has restored what it
142
+ * owns. The host uses it to put back the `pendingFiles` it consumed. */
143
+ onSendFailed?: (failure: ComposerSendFailure) => void;
144
+ /** Notice copy when the handler names no reason of its own. */
145
+ sendFailureMessage?: string;
146
+ /** Stop the in-flight turn; shown in place of Send while `isStreaming`. */
147
+ onCancel?: () => void;
148
+ isStreaming?: boolean;
149
+ /** Block input + send (e.g. while restoring). Distinct from `isStreaming`,
150
+ * which keeps the textarea editable so the next turn can be composed. */
151
+ disabled?: boolean;
152
+ /** Block sending while keeping the draft editable (e.g. model choices load). */
153
+ sendDisabled?: boolean;
154
+ placeholder?: string;
155
+ /** Controlled value. Omit for self-managed internal state (cleared on send). */
156
+ value?: string;
157
+ onValueChange?: (value: string) => void;
158
+ /** Initial text in uncontrolled mode; ignored when `value` is provided. */
159
+ initialValue?: string;
160
+ /** One-shot external prefill: when this becomes a non-null string the
161
+ * composer adopts it as the draft (replacing any current draft), focuses the
162
+ * input with the caret at the end, and reports consumption via
163
+ * `onSeedApplied` so the host can clear its seed state. */
164
+ seed?: string | null;
165
+ onSeedApplied?: () => void;
166
+ /** Inline controls (e.g. `<ModelPicker/>` + `<EffortPicker/>` or
167
+ * `<AgentSessionControls/>`). */
168
+ controls?: ReactNode;
169
+ /**
170
+ * Where {@link controls} sit. `inline` (default) puts them on the card's own
171
+ * action row, beside attach and Send — the model a turn will use reads as
172
+ * part of the input rather than as a separate widget floating above it.
173
+ * `above` keeps them outside the card, for a host that wants the input to be
174
+ * nothing but the input.
175
+ */
176
+ controlsPlacement?: 'above' | 'inline';
177
+ /** Attachments are opt-in: pass `onAttach` to show the attach button, accept
178
+ * drag-and-drop and clipboard paste onto the input, and render
179
+ * `pendingFiles` chips. */
180
+ onAttach?: (files: FileList) => void;
181
+ onAttachFolder?: (files: FileList) => void;
182
+ pendingFiles?: ComposerFile[];
183
+ onRemoveFile?: (id: string) => void;
184
+ /** Pass it and a chip with `status: 'error'` gains a retry button. */
185
+ onRetryFile?: (id: string) => void;
186
+ /**
187
+ * File types the composer takes, in the native `<input accept>` grammar.
188
+ * Enforced on every ingress route — the picker dialog (which the user can
189
+ * override with "All Files"), drag-and-drop, and clipboard paste — so a type
190
+ * the picker will not offer cannot arrive by another route. A non-matching
191
+ * file goes to `onRejectFiles` and never reaches `onAttach`. Folder attach is
192
+ * exempt: directory selection has no native accept semantics.
193
+ */
194
+ accept?: string;
195
+ /** Called with the files `accept` removed from a pick, drop, or paste, each
196
+ * with a reason. Without it a refusal is silent — the same feedback the
197
+ * native picker gives for a type it will not offer. */
198
+ onRejectFiles?: (rejections: ComposerFileRejection[]) => void;
199
+ dropTitle?: string;
200
+ dropDescription?: string;
201
+ /** Context the agent will see beside the next message, as its own chip row
202
+ * above the input. */
203
+ contextItems?: ReadonlyArray<ComposerContextItem>;
204
+ /**
205
+ * Let a staged file stand in for message text, so the send control stays live
206
+ * while an upload is in flight instead of going dead with nothing to explain
207
+ * it. Default false, where an empty message needs a `ready` file.
208
+ *
209
+ * It does NOT make an unfinished file sendable. A turn whose only content is a
210
+ * file that is still uploading or has failed never reaches the send handler —
211
+ * it would arrive empty and the attachment would be lost. The composer
212
+ * refuses it and names the reason in its notice
213
+ * ({@link attachmentsNotReadyMessage}). So the flag decides whether the
214
+ * control is live, and the composer keeps the integrity gate rather than
215
+ * leaving each host to re-derive it.
216
+ */
217
+ canSubmitAttachmentsOnly?: boolean;
218
+ /** Notice copy when a send is refused because no staged file is ready yet.
219
+ * Defaults to wording chosen from whether a file failed or is still
220
+ * uploading. */
221
+ attachmentsNotReadyMessage?: string;
222
+ /**
223
+ * Let Enter and Send keep firing while `isStreaming`, for a surface that
224
+ * queues the next turn rather than blocking on the current one. Default
225
+ * false. The button still flips to Stop while a turn streams, so this opens
226
+ * the keyboard path, not a second button.
227
+ */
228
+ canSubmitWhileBusy?: boolean;
229
+ /** Focus the input on mount — for a surface whose whole job is the input
230
+ * (an entry/hero composer), never for one docked under a transcript. */
231
+ autoFocus?: boolean;
232
+ /** Rows the input shows before it grows. Default 2. */
233
+ minRows?: number;
234
+ /** Pixel height the input grows to before it scrolls. Default 168. */
235
+ maxHeight?: number;
236
+ /** Content between the controls slot and Send — a token meter, a cost, a
237
+ * status line, a model picker. It sits outside the controls slot, so a
238
+ * wrapping picker set cannot push it away; it travels with Send onto its
239
+ * own line when the row is too narrow for both, and wraps inside that line
240
+ * rather than overflowing the card. */
241
+ trailing?: ReactNode;
242
+ /**
243
+ * Opt-in `@`-mentions. Present ⇒ the textarea is swapped for a lazily
244
+ * loaded TipTap rich input that renders mentions as atomic pills and
245
+ * serializes them to `@<id>` in the value; absent ⇒ exactly the plain
246
+ * textarea, with no TipTap in the bundle. Wire `useFileMentions().mention`
247
+ * straight in. The six `@tiptap/*` packages (core, extension-mention, pm,
248
+ * react, starter-kit, suggestion) are OPTIONAL peers — a consumer installs
249
+ * them to use this prop.
250
+ *
251
+ * General `slashCommands` remain disabled while `mention` is set; the
252
+ * skill picker has explicit keyboard handling in both input modes. Seed and
253
+ * failed-send drafts still apply in mention mode, but caret placement (a
254
+ * textarea affordance) degrades to content-only.
255
+ */
256
+ mention?: ComposerMentionProp;
257
+ /** `/` commands offered when the draft is exactly a leading slash token.
258
+ * Omit (or pass []) and `/` types as ordinary text. Inert while `mention`
259
+ * is set — see {@link mention}. */
260
+ slashCommands?: SlashCommand[];
261
+ /** Skills available in the current authenticated workspace and harness.
262
+ * The host resolves eligibility; this list only drives selection UI. */
263
+ eligibleSkills?: ReadonlyArray<ComposerSkillOption>;
264
+ /** The host-owned skill selected for the next turn. */
265
+ selectedSkillId?: string | null;
266
+ /** Picking or removing a skill reports its typed id and display metadata.
267
+ * The host persists selection through queued turns and rejected sends. */
268
+ onSelectedSkillChange?: (skill: ComposerSkillOption | null) => void;
269
+ /** Dictation is opt-in: pass `onDictate` and the action row gains a mic
270
+ * button (browsers without `MediaRecorder`/`getUserMedia` render none).
271
+ * Click starts the capture; the button flips to a stop control with the
272
+ * running elapsed seconds; stop hands the recorded audio blob here. The
273
+ * composer owns capture only — turning the audio into text (e.g. the
274
+ * Whisper provider from `sequences-react`) is the host's. */
275
+ onDictate?: (audio: DictationAudio) => void;
276
+ /** Capture failures (a denied mic prompt, no device), after the composer has
277
+ * shown its own dismissible notice. For hosts that log or track. */
278
+ onDictateError?: (message: string) => void;
279
+ /** Cmd/Ctrl+L focuses the input and shows the hint. Default true. */
280
+ focusShortcut?: boolean;
281
+ /** Called when focus enters the composer: the input or any of its controls.
282
+ * Default: the surrounding workspace shell's prewarm `reassert`
283
+ * (`AgentWorkspaceLayout` with `prewarm`), so a box that suspended while the
284
+ * tab sat open starts resuming before the member sends. */
285
+ onFocusWithin?: () => void;
286
+ /** Float the card on a soft two-layer foreground-tinted shadow (opt-in).
287
+ * Elevation only — radius, ring, and control layout are unchanged. */
288
+ floating?: boolean;
289
+ /** Send button label. Default "Send". */
290
+ sendLabel?: string;
291
+ /** Send control shape. `pill` (default) is the labeled button; `icon` is the
292
+ * 34px circular inverted arrow (streaming: circular outlined stop) — the
293
+ * grammar sandbox-ui's legacy AgentComposer used and the current agent-app
294
+ * canon for new surfaces. */
295
+ sendVariant?: 'pill' | 'icon';
296
+ /** Circular icon send colour. `contrast` (default) preserves the inverted
297
+ * foreground/background canon; `primary` opts into the host brand tokens.
298
+ * The labeled pill already uses primary and is unchanged. */
299
+ sendTone?: 'contrast' | 'primary';
300
+ className?: string;
301
+ }
@@ -34,304 +34,6 @@
34
34
  * tokens — the input renders on-palette instead of collapsing to unstyled
35
35
  * fallbacks when a host hasn't defined a private chat-token set.
36
36
  */
37
- import { type ReactNode } from 'react';
38
- import { type ComposerFileRejection } from './composer-file-accept';
39
- import { type DictationAudio } from './use-dictation';
40
- import type { ComposerMentionProp } from './use-file-mentions';
41
- /** Prompt-part descriptor an uploaded file carries (the upload route's
42
- * `UploadedChatFile.part`), echoed back in the turn body on send. Mirrors
43
- * `/chat-routes`' wire shape structurally — no server import here. */
44
- export interface ComposerFilePart {
45
- type: 'image' | 'file';
46
- filename?: string;
47
- mediaType?: string;
48
- url?: string;
49
- path?: string;
50
- content?: string;
51
- }
52
- export interface ComposerFile {
53
- id: string;
54
- name: string;
55
- size?: number;
56
- kind: 'file' | 'folder';
57
- /** Number of files inside, for a folder chip. */
58
- fileCount?: number;
59
- status: 'pending' | 'uploading' | 'ready' | 'error';
60
- /** Uploaded part descriptor; set once the upload route returns. Only
61
- * `status: 'ready'` files with a part travel on a parts-aware send. */
62
- part?: ComposerFilePart;
63
- /** Object URL for an image thumbnail on the chip. The host owns the URL's
64
- * whole life — `URL.createObjectURL` when the file is staged,
65
- * `URL.revokeObjectURL` when it leaves — and the composer only reads it.
66
- * `useComposerAttachments` already does both. */
67
- previewUrl?: string;
68
- /** Why this file failed, shown on the chip while `status: 'error'`. Without
69
- * it an error chip is red and mute, which tells the user nothing. */
70
- errorMessage?: string;
71
- }
72
- /** A piece of context the agent will see beside the next message — an open
73
- * file, a selected record, a pinned document. Rendered as its own chip row,
74
- * separate from staged attachments: context is what the turn already carries,
75
- * an attachment is what the user is adding to it. */
76
- export interface ComposerContextItem {
77
- id: string;
78
- label: string;
79
- icon?: ReactNode;
80
- /** Omit for a chip the user cannot dismiss. */
81
- onRemove?: () => void;
82
- }
83
- /** A send the host refused. `error` is shown verbatim in the composer's notice;
84
- * omit it for the generic copy. */
85
- export interface ComposerSendRejected {
86
- ok: false;
87
- error?: string;
88
- }
89
- /**
90
- * What a send handler reports back. `void` — what every handler returned before
91
- * this existed — reads as accepted, so wiring stays unchanged; a thrown error, a
92
- * rejected promise, or `{ ok: false }` is the rejection that restores the draft.
93
- * A handler that resolves only when the whole turn finishes still reports
94
- * correctly: the input already cleared on dispatch, so the answer only decides
95
- * whether the draft comes back.
96
- */
97
- export type ComposerSendOutcome = void | {
98
- ok: true;
99
- } | ComposerSendRejected;
100
- export type ComposerSendResult = ComposerSendOutcome | Promise<ComposerSendOutcome>;
101
- /**
102
- * A send handler, typed as a UNION with the legacy `=> void` signature rather
103
- * than as `(…) => ComposerSendResult` alone.
104
- *
105
- * TypeScript's return-type-`void` rule accepts a function returning ANYTHING
106
- * where a `=> void` is expected, and that rule fires only when the target's
107
- * return type is exactly `void` — not when it is a union that contains `void`.
108
- * So narrowing this prop to `ComposerSendResult` would reject handler shapes
109
- * that compiled against the shipped `onSend?: (message: string) => void`:
110
- * `onSend={(m) => rows.push(m)}` (returns `number`) and
111
- * `onSend={(m) => append({ role: 'user', content: m })}` (an ai-sdk append
112
- * returns `Promise<string | null | undefined>`) both stop compiling, on a
113
- * package whose pinned consumers must never need a source edit to take a minor.
114
- *
115
- * The union keeps both: a legacy handler lands on the first member, and a
116
- * handler that reports an outcome lands on the second. A call through it
117
- * resolves to `void | ComposerSendResult`, which IS `ComposerSendResult`, so
118
- * the composer reads the outcome exactly as before.
119
- */
120
- export type ComposerSendHandler = ((message: string) => void) | ((message: string) => ComposerSendResult);
121
- /** @see ComposerSendHandler — the parts-aware arity, same union for the same reason. */
122
- export type ComposerSendPartsHandler = ((message: string, parts: ComposerFilePart[]) => void) | ((message: string, parts: ComposerFilePart[]) => ComposerSendResult);
123
- /** The rejected send, handed to `onSendFailed` so the host can undo whatever it
124
- * cleared optimistically — most importantly the staged attachments, which the
125
- * composer does not own (`pendingFiles` is a prop). */
126
- export interface ComposerSendFailure {
127
- /** The reason as the composer renders it. */
128
- message: string;
129
- /** The user's exact draft, untrimmed. */
130
- text: string;
131
- /** The parts the rejected send carried. */
132
- parts: ComposerFilePart[];
133
- /** Whatever the handler threw / rejected with, or the `{ ok: false }` value. */
134
- error: unknown;
135
- /** True when the draft was put back in the textarea (the box was empty).
136
- * False means the user had typed a replacement, so the unsent text is held in
137
- * the notice instead. */
138
- restored: boolean;
139
- }
140
- /**
141
- * One `/` command the composer offers. Typing `/` at position 0 opens the
142
- * command menu; the rest of the token filters it (the same prefix > substring
143
- * > token-order ranking as the command palette). Picking a command CLEARS the
144
- * token from the draft and calls `run` — what the command does (a route, a
145
- * dialog, a draft transformation) is the product's business.
146
- */
147
- export interface SlashCommand {
148
- /** Command name without the leading slash: `model`, `clear`. */
149
- name: string;
150
- /** One line of what it does, rendered beside the name. */
151
- description: string;
152
- run: () => void;
153
- }
154
- /** A skill the host has made eligible for this turn. The id is the value the
155
- * host validates and sends; the name and description are display metadata. */
156
- export interface ComposerSkillOption {
157
- id: string;
158
- name: string;
159
- description: string;
160
- }
161
- export interface ChatComposerProps {
162
- /** Send the trimmed message, or an empty message when a skill is selected.
163
- * Attached files travel separately via
164
- * `onAttach` + `pendingFiles` (the host consumes and clears them on send).
165
- * Optional when `onSendParts` is wired.
166
- *
167
- * Report a refused send by throwing, rejecting, or returning `{ ok: false }`
168
- * — the composer restores the draft rather than losing it. */
169
- onSend?: ComposerSendHandler;
170
- /** Parts-aware send: receives the trimmed message plus the `part`
171
- * descriptors of every `ready` pending file. Takes precedence over
172
- * `onSend`; enables file-only sends (empty text, ≥1 ready part).
173
- *
174
- * Same rejection contract as `onSend`. */
175
- onSendParts?: ComposerSendPartsHandler;
176
- /** Notified when a send is rejected, after the composer has restored what it
177
- * owns. The host uses it to put back the `pendingFiles` it consumed. */
178
- onSendFailed?: (failure: ComposerSendFailure) => void;
179
- /** Notice copy when the handler names no reason of its own. */
180
- sendFailureMessage?: string;
181
- /** Stop the in-flight turn; shown in place of Send while `isStreaming`. */
182
- onCancel?: () => void;
183
- isStreaming?: boolean;
184
- /** Block input + send (e.g. while restoring). Distinct from `isStreaming`,
185
- * which keeps the textarea editable so the next turn can be composed. */
186
- disabled?: boolean;
187
- /** Block sending while keeping the draft editable (e.g. model choices load). */
188
- sendDisabled?: boolean;
189
- placeholder?: string;
190
- /** Controlled value. Omit for self-managed internal state (cleared on send). */
191
- value?: string;
192
- onValueChange?: (value: string) => void;
193
- /** Initial text in uncontrolled mode; ignored when `value` is provided. */
194
- initialValue?: string;
195
- /** One-shot external prefill: when this becomes a non-null string the
196
- * composer adopts it as the draft (replacing any current draft), focuses the
197
- * input with the caret at the end, and reports consumption via
198
- * `onSeedApplied` so the host can clear its seed state. */
199
- seed?: string | null;
200
- onSeedApplied?: () => void;
201
- /** Inline controls (e.g. `<ModelPicker/>` + `<EffortPicker/>` or
202
- * `<AgentSessionControls/>`). */
203
- controls?: ReactNode;
204
- /**
205
- * Where {@link controls} sit. `inline` (default) puts them on the card's own
206
- * action row, beside attach and Send — the model a turn will use reads as
207
- * part of the input rather than as a separate widget floating above it.
208
- * `above` keeps them outside the card, for a host that wants the input to be
209
- * nothing but the input.
210
- */
211
- controlsPlacement?: 'above' | 'inline';
212
- /** Attachments are opt-in: pass `onAttach` to show the attach button, accept
213
- * drag-and-drop and clipboard paste onto the input, and render
214
- * `pendingFiles` chips. */
215
- onAttach?: (files: FileList) => void;
216
- onAttachFolder?: (files: FileList) => void;
217
- pendingFiles?: ComposerFile[];
218
- onRemoveFile?: (id: string) => void;
219
- /** Pass it and a chip with `status: 'error'` gains a retry button. */
220
- onRetryFile?: (id: string) => void;
221
- /**
222
- * File types the composer takes, in the native `<input accept>` grammar.
223
- * Enforced on every ingress route — the picker dialog (which the user can
224
- * override with "All Files"), drag-and-drop, and clipboard paste — so a type
225
- * the picker will not offer cannot arrive by another route. A non-matching
226
- * file goes to `onRejectFiles` and never reaches `onAttach`. Folder attach is
227
- * exempt: directory selection has no native accept semantics.
228
- */
229
- accept?: string;
230
- /** Called with the files `accept` removed from a pick, drop, or paste, each
231
- * with a reason. Without it a refusal is silent — the same feedback the
232
- * native picker gives for a type it will not offer. */
233
- onRejectFiles?: (rejections: ComposerFileRejection[]) => void;
234
- dropTitle?: string;
235
- dropDescription?: string;
236
- /** Context the agent will see beside the next message, as its own chip row
237
- * above the input. */
238
- contextItems?: ReadonlyArray<ComposerContextItem>;
239
- /**
240
- * Let a staged file stand in for message text, so the send control stays live
241
- * while an upload is in flight instead of going dead with nothing to explain
242
- * it. Default false, where an empty message needs a `ready` file.
243
- *
244
- * It does NOT make an unfinished file sendable. A turn whose only content is a
245
- * file that is still uploading or has failed never reaches the send handler —
246
- * it would arrive empty and the attachment would be lost. The composer
247
- * refuses it and names the reason in its notice
248
- * ({@link attachmentsNotReadyMessage}). So the flag decides whether the
249
- * control is live, and the composer keeps the integrity gate rather than
250
- * leaving each host to re-derive it.
251
- */
252
- canSubmitAttachmentsOnly?: boolean;
253
- /** Notice copy when a send is refused because no staged file is ready yet.
254
- * Defaults to wording chosen from whether a file failed or is still
255
- * uploading. */
256
- attachmentsNotReadyMessage?: string;
257
- /**
258
- * Let Enter and Send keep firing while `isStreaming`, for a surface that
259
- * queues the next turn rather than blocking on the current one. Default
260
- * false. The button still flips to Stop while a turn streams, so this opens
261
- * the keyboard path, not a second button.
262
- */
263
- canSubmitWhileBusy?: boolean;
264
- /** Focus the input on mount — for a surface whose whole job is the input
265
- * (an entry/hero composer), never for one docked under a transcript. */
266
- autoFocus?: boolean;
267
- /** Rows the input shows before it grows. Default 2. */
268
- minRows?: number;
269
- /** Pixel height the input grows to before it scrolls. Default 168. */
270
- maxHeight?: number;
271
- /** Content between the controls slot and Send — a token meter, a cost, a
272
- * status line, a model picker. It sits outside the controls slot, so a
273
- * wrapping picker set cannot push it away; it travels with Send onto its
274
- * own line when the row is too narrow for both, and wraps inside that line
275
- * rather than overflowing the card. */
276
- trailing?: ReactNode;
277
- /**
278
- * Opt-in `@`-mentions. Present ⇒ the textarea is swapped for a lazily
279
- * loaded TipTap rich input that renders mentions as atomic pills and
280
- * serializes them to `@<id>` in the value; absent ⇒ exactly the plain
281
- * textarea, with no TipTap in the bundle. Wire `useFileMentions().mention`
282
- * straight in. The six `@tiptap/*` packages (core, extension-mention, pm,
283
- * react, starter-kit, suggestion) are OPTIONAL peers — a consumer installs
284
- * them to use this prop.
285
- *
286
- * General `slashCommands` remain disabled while `mention` is set; the
287
- * skill picker has explicit keyboard handling in both input modes. Seed and
288
- * failed-send drafts still apply in mention mode, but caret placement (a
289
- * textarea affordance) degrades to content-only.
290
- */
291
- mention?: ComposerMentionProp;
292
- /** `/` commands offered when the draft is exactly a leading slash token.
293
- * Omit (or pass []) and `/` types as ordinary text. Inert while `mention`
294
- * is set — see {@link mention}. */
295
- slashCommands?: SlashCommand[];
296
- /** Skills available in the current authenticated workspace and harness.
297
- * The host resolves eligibility; this list only drives selection UI. */
298
- eligibleSkills?: ReadonlyArray<ComposerSkillOption>;
299
- /** The host-owned skill selected for the next turn. */
300
- selectedSkillId?: string | null;
301
- /** Picking or removing a skill reports its typed id and display metadata.
302
- * The host persists selection through queued turns and rejected sends. */
303
- onSelectedSkillChange?: (skill: ComposerSkillOption | null) => void;
304
- /** Dictation is opt-in: pass `onDictate` and the action row gains a mic
305
- * button (browsers without `MediaRecorder`/`getUserMedia` render none).
306
- * Click starts the capture; the button flips to a stop control with the
307
- * running elapsed seconds; stop hands the recorded audio blob here. The
308
- * composer owns capture only — turning the audio into text (e.g. the
309
- * Whisper provider from `sequences-react`) is the host's. */
310
- onDictate?: (audio: DictationAudio) => void;
311
- /** Capture failures (a denied mic prompt, no device), after the composer has
312
- * shown its own dismissible notice. For hosts that log or track. */
313
- onDictateError?: (message: string) => void;
314
- /** Cmd/Ctrl+L focuses the input and shows the hint. Default true. */
315
- focusShortcut?: boolean;
316
- /** Called when focus enters the composer: the input or any of its controls.
317
- * Default: the surrounding workspace shell's prewarm `reassert`
318
- * (`AgentWorkspaceLayout` with `prewarm`), so a box that suspended while the
319
- * tab sat open starts resuming before the member sends. */
320
- onFocusWithin?: () => void;
321
- /** Float the card on a soft two-layer foreground-tinted shadow (opt-in).
322
- * Elevation only — radius, ring, and control layout are unchanged. */
323
- floating?: boolean;
324
- /** Send button label. Default "Send". */
325
- sendLabel?: string;
326
- /** Send control shape. `pill` (default) is the labeled button; `icon` is the
327
- * 34px circular inverted arrow (streaming: circular outlined stop) — the
328
- * grammar sandbox-ui's legacy AgentComposer used and the current agent-app
329
- * canon for new surfaces. */
330
- sendVariant?: 'pill' | 'icon';
331
- /** Circular icon send colour. `contrast` (default) preserves the inverted
332
- * foreground/background canon; `primary` opts into the host brand tokens.
333
- * The labeled pill already uses primary and is unchanged. */
334
- sendTone?: 'contrast' | 'primary';
335
- className?: string;
336
- }
37
+ import type { ChatComposerProps } from './chat-composer-types';
38
+ export * from './chat-composer-types';
337
39
  export declare function ChatComposer({ onSend, onSendParts, onSendFailed, sendFailureMessage, onCancel, isStreaming, disabled, sendDisabled, placeholder, value, onValueChange, initialValue, seed, onSeedApplied, controls, controlsPlacement, onAttach, onAttachFolder, pendingFiles, onRemoveFile, onRetryFile, accept, onRejectFiles, dropTitle, dropDescription, contextItems, canSubmitAttachmentsOnly, attachmentsNotReadyMessage, canSubmitWhileBusy, autoFocus, minRows, maxHeight, trailing, mention, slashCommands, eligibleSkills, selectedSkillId, onSelectedSkillChange, onDictate, onDictateError, focusShortcut, onFocusWithin, floating, sendLabel, sendVariant, sendTone, className, }: ChatComposerProps): import("react").JSX.Element;
@@ -0,0 +1,27 @@
1
+ import type { ReactNode } from 'react';
2
+ /** One starting "door" in the chat first-run state — a concrete, labeled action
3
+ * (start from a template, do it by hand, ask the agent), not a placeholder. */
4
+ export interface ChatEmptyDoor {
5
+ label: string;
6
+ description?: string;
7
+ onSelect: () => void;
8
+ /** Optional glyph rendered left of the label. */
9
+ icon?: ReactNode;
10
+ }
11
+ /** Define properties for rendering the chat empty state with customizable text and starting doors */
12
+ export interface ChatEmptyStateProps {
13
+ /** Product name shown next to the Tangle mark. Default "Agent". */
14
+ productName?: string;
15
+ /** Headline. Default frames delegation, not messaging. */
16
+ headline?: string;
17
+ /** Subline under the headline. */
18
+ subline?: string;
19
+ /** Up to three concrete starting doors. Omit for a mark-and-prompt-only state. */
20
+ doors?: ChatEmptyDoor[];
21
+ }
22
+ /**
23
+ * Branded chat first-run state: the Tangle mark, a delegation-framed prompt, and
24
+ * up to three concrete doors. Replaces the blank thread that read as "empty or
25
+ * broken". Concrete + actionable — never a "coming soon" placeholder.
26
+ */
27
+ export declare function ChatEmptyState({ productName, headline, subline, doors, }: ChatEmptyStateProps): import("react").JSX.Element;