@timbal-ai/timbal-react 0.2.2 → 0.4.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.
package/dist/index.d.ts CHANGED
@@ -1,16 +1,180 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import * as React from 'react';
3
- import React__default, { ReactNode, FC, ComponentType, ComponentPropsWithRef, ElementType } from 'react';
4
- import { ToolCallMessagePartComponent } from '@assistant-ui/react';
5
- export { ActionBarPrimitive, ComposerPrimitive, MessagePrimitive, ThreadPrimitive, useComposerRuntime, useMessageRuntime, useThread, useThreadRuntime } from '@assistant-ui/react';
3
+ import React__default, { ReactNode, FC, ComponentType, Dispatch, CSSProperties, ElementType } from 'react';
4
+ import { AttachmentAdapter, ToolCallMessagePartComponent } from '@assistant-ui/react';
5
+ export { ActionBarMorePrimitive, ActionBarPrimitive, AssistantRuntimeProvider, AttachmentAdapter, AuiIf, ComposerPrimitive, ErrorPrimitive, MessagePartPrimitive, MessagePrimitive, ThreadPrimitive, ToolCallMessagePartComponent, useAuiState, useComposerRuntime, useMessageRuntime, useThread, useThreadRuntime } from '@assistant-ui/react';
6
+ import { WorkforceItem, Session } from '@timbal-ai/timbal-sdk';
7
+ export { parseSSELine } from '@timbal-ai/timbal-sdk';
8
+ import { SyntaxHighlighterProps } from '@assistant-ui/react-markdown';
6
9
  import * as class_variance_authority_types from 'class-variance-authority/types';
7
10
  import { VariantProps } from 'class-variance-authority';
8
- import { SyntaxHighlighterProps } from '@assistant-ui/react-markdown';
9
- import { Session } from '@timbal-ai/timbal-sdk';
10
11
  import { Tooltip as Tooltip$1, Avatar as Avatar$1, Dialog as Dialog$1 } from 'radix-ui';
11
12
  import { ClassValue } from 'clsx';
12
13
 
13
- type FetchFn = (url: string, options?: RequestInit) => Promise<Response>;
14
+ type UploadFetchFn = (url: string, options?: RequestInit) => Promise<Response>;
15
+ interface CreateDefaultAttachmentAdapterOptions {
16
+ /**
17
+ * API base path used to derive the upload URL when {@link uploadUrl} is
18
+ * omitted. Trailing slashes are stripped. Defaults to `""` (relative
19
+ * `/files/upload`).
20
+ */
21
+ baseUrl?: string;
22
+ /**
23
+ * Absolute or relative URL the adapter `POST`s the multipart upload to.
24
+ * Defaults to `${baseUrl}/files/upload`.
25
+ */
26
+ uploadUrl?: string;
27
+ /**
28
+ * Custom fetch used for the upload. Defaults to {@link authFetch}. Do not
29
+ * set `Content-Type` on multipart uploads — the boundary must be automatic.
30
+ */
31
+ fetch?: UploadFetchFn;
32
+ /**
33
+ * MIME / extension `accept` string for the file picker.
34
+ */
35
+ accept?: string;
36
+ }
37
+ /** @deprecated Use {@link CreateDefaultAttachmentAdapterOptions}. */
38
+ type CreateUploadAttachmentAdapterOptions = CreateDefaultAttachmentAdapterOptions;
39
+ declare const DEFAULT_UPLOAD_ACCEPT = "image/*,application/pdf,text/*,.md,.json,.csv,.tsv,.xlsx,.docx";
40
+ /**
41
+ * Build an `AttachmentAdapter` that uploads each file to a Timbal-style
42
+ * `/files/upload` endpoint and returns a `CompleteAttachment` whose
43
+ * `content[]` references the returned URL.
44
+ */
45
+ declare function createDefaultAttachmentAdapter({ baseUrl, uploadUrl, fetch: fetchFn, accept, }?: CreateDefaultAttachmentAdapterOptions): AttachmentAdapter;
46
+ /** @deprecated Alias of {@link createDefaultAttachmentAdapter}. */
47
+ declare const createUploadAttachmentAdapter: typeof createDefaultAttachmentAdapter;
48
+
49
+ /** Tweaks for the built-in upload adapter (see {@link createDefaultAttachmentAdapter}). */
50
+ type TimbalAttachmentsConfig = {
51
+ uploadUrl?: string;
52
+ accept?: string;
53
+ };
54
+ /**
55
+ * Enable or customise composer attachments.
56
+ *
57
+ * - `true` — built-in adapter posting to `${baseUrl}/files/upload`
58
+ * - `{ uploadUrl?, accept? }` — same adapter with overrides
59
+ * - `AttachmentAdapter` — fully custom (e.g. presigned S3)
60
+ * - `null` — disable attachments (no `+` button / dropzone wiring)
61
+ * - `undefined` — off unless legacy `attachmentsUploadUrl` / `attachmentsAccept` are set
62
+ */
63
+ type TimbalAttachmentsProp = boolean | TimbalAttachmentsConfig | AttachmentAdapter | null;
64
+ interface ResolveAttachmentAdapterOptions {
65
+ baseUrl?: string;
66
+ fetch?: CreateDefaultAttachmentAdapterOptions["fetch"];
67
+ /** @deprecated Prefer `attachments={{ uploadUrl }}` */
68
+ uploadUrl?: string;
69
+ /** @deprecated Prefer `attachments={{ accept }}` */
70
+ accept?: string;
71
+ }
72
+ /**
73
+ * Resolve the `AttachmentAdapter` (if any) for {@link TimbalRuntimeProvider}.
74
+ */
75
+ declare function resolveAttachmentAdapter(attachments: TimbalAttachmentsProp | undefined, options?: ResolveAttachmentAdapterOptions): AttachmentAdapter | undefined;
76
+
77
+ interface TextContentPart {
78
+ type: "text";
79
+ text: string;
80
+ }
81
+ interface ThinkingContentPart {
82
+ type: "thinking";
83
+ text: string;
84
+ }
85
+ /**
86
+ * A tool invocation. `argsText` accumulates from streaming `tool_use_delta`
87
+ * events; `result` is set once the matching `tool_result` arrives in the
88
+ * `OUTPUT` event.
89
+ *
90
+ * `result` is always a JSON-serializable value (string, number, object, array)
91
+ * — the runtime preserves whatever the agent returns. `resultText` is the
92
+ * text representation of the result blocks from `tool_result.content`, useful
93
+ * as a quick fallback when callers don't want to walk the structured result.
94
+ */
95
+ interface ToolCallContentPart {
96
+ type: "tool-call";
97
+ toolCallId: string;
98
+ toolName: string;
99
+ argsText: string;
100
+ result?: unknown;
101
+ resultText?: string;
102
+ status?: "running" | "complete" | "error";
103
+ }
104
+ type ContentPart = TextContentPart | ThinkingContentPart | ToolCallContentPart;
105
+ type MessageRole = "user" | "assistant";
106
+ /**
107
+ * A file attached to a user message. We carry a single `dataUrl` field
108
+ * (despite the name, it may be either a `data:<mime>;base64,<bytes>` URL
109
+ * or a real `https://...` URL returned by an upload adapter) and project
110
+ * it both onto the wire (`{type:"file", file: dataUrl}`) and onto the
111
+ * assistant-ui display layer (`ImageMessagePart` / `FileMessagePart`
112
+ * inside `attachments[].content`).
113
+ *
114
+ * Both forms are accepted by Timbal's `FileContent` factory, so the same
115
+ * field works whether the attachment was inlined as base64 or uploaded
116
+ * to object storage.
117
+ */
118
+ interface ChatAttachment {
119
+ id: string;
120
+ type: "image" | "document" | "file";
121
+ name?: string;
122
+ contentType?: string;
123
+ /**
124
+ * Either a `data:<mime>;base64,<bytes>` URL (inline) or a remote
125
+ * `https://...` URL produced by an upload-style {@link AttachmentAdapter}.
126
+ */
127
+ dataUrl: string;
128
+ }
129
+ interface ChatMessage {
130
+ id: string;
131
+ role: MessageRole;
132
+ content: ContentPart[];
133
+ /** Files attached to a user message. Empty/undefined for assistant messages. */
134
+ attachments?: ChatAttachment[];
135
+ /** Run id stamped from the top-level `START` SSE event. */
136
+ runId?: string;
137
+ }
138
+
139
+ type FetchFn$1 = (url: string, options?: RequestInit) => Promise<Response>;
140
+ interface UseTimbalStreamOptions {
141
+ workforceId: string;
142
+ baseUrl?: string;
143
+ fetch?: FetchFn$1;
144
+ /**
145
+ * When true, every parsed SSE event is `console.debug`-ed with a
146
+ * `[timbal]` prefix. Useful for diagnosing tool/artifact rendering issues
147
+ * without screen-sharing. Default: `false`.
148
+ */
149
+ debug?: boolean;
150
+ }
151
+ interface SendOptions {
152
+ attachments?: ChatAttachment[];
153
+ /** Override the parent run id resolution. Pass `null` to start a new thread. */
154
+ parentId?: string | null;
155
+ }
156
+ interface TimbalStreamApi {
157
+ messages: ChatMessage[];
158
+ isRunning: boolean;
159
+ send: (input: string, options?: SendOptions) => Promise<void>;
160
+ reload: (messageId?: string | null) => Promise<void>;
161
+ cancel: () => void;
162
+ clear: () => void;
163
+ }
164
+ /**
165
+ * Lower-level streaming hook for callers that don't want the full `<Thread>`
166
+ * UI. Exposes the internal message state plus `send`, `reload`, `cancel`, and
167
+ * `clear` actions. Use this to build custom chat surfaces while reusing the
168
+ * Timbal SSE wire format and auth-aware fetching.
169
+ */
170
+ declare function useTimbalStream({ workforceId, baseUrl, fetch: fetchFn, debug, }: UseTimbalStreamOptions): TimbalStreamApi;
171
+ /**
172
+ * Access the underlying `useTimbalStream` API from inside a component tree
173
+ * wrapped by `<TimbalRuntimeProvider>` (or `<TimbalChat>`). Useful for custom
174
+ * UIs that need direct access to messages, send, or cancel without going
175
+ * through the assistant-ui runtime.
176
+ */
177
+ declare function useTimbalRuntime(): TimbalStreamApi;
14
178
  interface TimbalRuntimeProviderProps {
15
179
  workforceId: string;
16
180
  children: ReactNode;
@@ -23,81 +187,819 @@ interface TimbalRuntimeProviderProps {
23
187
  * Custom fetch function for API calls. Defaults to `authFetch` which
24
188
  * attaches Bearer tokens from localStorage and auto-refreshes on 401.
25
189
  */
26
- fetch?: FetchFn;
190
+ fetch?: FetchFn$1;
191
+ /**
192
+ * Enable composer attachments. `true` or `{ uploadUrl?, accept? }` uses
193
+ * the built-in upload adapter (`POST` to `${baseUrl}/files/upload` by
194
+ * default). Pass a custom {@link AttachmentAdapter} for full control, or
195
+ * `null` to disable. Omitted = off (back-compat with pre-attachment chats).
196
+ */
197
+ attachments?: TimbalAttachmentsProp;
198
+ /**
199
+ * Shorthand to enable the default upload adapter with a custom endpoint.
200
+ * Equivalent to `attachments={{ uploadUrl }}` when `attachments` is omitted.
201
+ */
202
+ attachmentsUploadUrl?: string;
203
+ /**
204
+ * Shorthand MIME `accept` for the default upload adapter when `attachments`
205
+ * is omitted or `true`.
206
+ */
207
+ attachmentsAccept?: string;
208
+ /**
209
+ * Forwarded to {@link useTimbalStream}. When `true`, every parsed SSE
210
+ * event is logged via `console.debug` with a `[timbal]` prefix.
211
+ */
212
+ debug?: boolean;
213
+ }
214
+ declare function TimbalRuntimeProvider({ workforceId, children, baseUrl, fetch: fetchFn, attachments, attachmentsUploadUrl, attachmentsAccept, debug, }: TimbalRuntimeProviderProps): react_jsx_runtime.JSX.Element;
215
+
216
+ interface ComposerProps {
217
+ /** Placeholder shown in the textarea. Default: "Send a message..." */
218
+ placeholder?: string;
219
+ /**
220
+ * Show the file-attach button. Default: true. Disable when the agent has no
221
+ * use for attachments to keep the toolbar clean.
222
+ */
223
+ showAttachments?: boolean;
224
+ /** Extra content rendered inside the toolbar, left of the send button. */
225
+ toolbar?: ReactNode;
226
+ /** Tooltip shown on the send button. Default: "Send message". */
227
+ sendTooltip?: string;
228
+ /** Disable autofocus on mount. Default: false. */
229
+ noAutoFocus?: boolean;
230
+ /** Extra className applied to the outer composer wrapper. */
231
+ className?: string;
27
232
  }
28
- declare function TimbalRuntimeProvider({ workforceId, children, baseUrl, fetch: fetchFn, }: TimbalRuntimeProviderProps): react_jsx_runtime.JSX.Element;
233
+ /**
234
+ * Default chat composer — auto-resizing textarea with Enter-to-send,
235
+ * Shift+Enter for newline, attach pill on the left, and a circular send /
236
+ * cancel button on the right. Wraps `ComposerPrimitive` so consumers can
237
+ * override individual slots without losing the Studio chrome.
238
+ */
239
+ declare const Composer: FC<ComposerProps>;
29
240
 
30
241
  interface ThreadSuggestion {
242
+ /** Title shown on the row. Also sent verbatim as the user message. */
31
243
  title: string;
244
+ /** Optional secondary line. */
32
245
  description?: string;
246
+ /** Optional leading icon. */
247
+ icon?: ReactNode;
248
+ /**
249
+ * Override the prompt sent when the row is clicked. Useful when the row
250
+ * label is short ("Weekly recap") but the prompt should be longer.
251
+ */
252
+ prompt?: string;
253
+ }
254
+ /**
255
+ * Suggestions can be passed as a static array, a thunk that returns an
256
+ * array, or an async function for dynamic / per-user suggestions.
257
+ */
258
+ type SuggestionsSource = ThreadSuggestion[] | (() => ThreadSuggestion[] | Promise<ThreadSuggestion[]>);
259
+ interface ThreadSuggestionsProps {
260
+ suggestions?: SuggestionsSource;
261
+ className?: string;
262
+ }
263
+ /**
264
+ * Render suggestions as a stacked column of full-width rows. Each row reads
265
+ * like a list item rather than a chip, matching the Studio playground.
266
+ *
267
+ * On click the row's `prompt` (or `title` if no prompt) is appended as a
268
+ * user message via the thread runtime.
269
+ */
270
+ declare const Suggestions: FC<ThreadSuggestionsProps>;
271
+ /**
272
+ * Resolve a `SuggestionsSource` to an array. Re-runs when the source
273
+ * identity changes. Sync arrays / sync functions resolve immediately;
274
+ * async functions stream in once the promise settles.
275
+ */
276
+ declare function useResolvedSuggestions(source?: SuggestionsSource): ThreadSuggestion[] | undefined;
277
+ interface SuggestionsSlotProps {
278
+ suggestions?: SuggestionsSource;
279
+ className?: string;
280
+ }
281
+ type SuggestionsComponent = ComponentType<SuggestionsSlotProps>;
282
+
283
+ /** A value that is either a literal or a binding into local state. */
284
+ type UiBindable<T> = T | {
285
+ $bind: string;
286
+ };
287
+ interface UiArtifact {
288
+ type: "ui";
289
+ title?: string;
290
+ /** Initial values for `$bind` references. */
291
+ initialState?: Record<string, unknown>;
292
+ /** Root of the node tree. */
293
+ root: UiNode;
294
+ }
295
+ interface UiNodeBase {
296
+ id?: string;
297
+ className?: string;
298
+ }
299
+ interface UiBoxNode extends UiNodeBase {
300
+ kind: "box";
301
+ /** Flex direction. Default: "col". */
302
+ direction?: "row" | "col";
303
+ /** Tailwind spacing units (gap = `gap * 0.25rem`). */
304
+ gap?: number;
305
+ align?: "start" | "center" | "end" | "stretch";
306
+ justify?: "start" | "center" | "end" | "between" | "around";
307
+ wrap?: boolean;
308
+ padding?: number;
309
+ children?: UiNode[];
310
+ }
311
+ interface UiTextNode extends UiNodeBase {
312
+ kind: "text";
313
+ value: UiBindable<string | number>;
314
+ muted?: boolean;
315
+ size?: "xs" | "sm" | "base" | "lg";
316
+ weight?: "normal" | "medium" | "semibold" | "bold";
317
+ }
318
+ interface UiHeadingNode extends UiNodeBase {
319
+ kind: "heading";
320
+ value: UiBindable<string>;
321
+ level?: 1 | 2 | 3 | 4;
322
+ }
323
+ interface UiBadgeNode extends UiNodeBase {
324
+ kind: "badge";
325
+ value: UiBindable<string>;
326
+ tone?: "default" | "primary" | "success" | "warn" | "danger";
327
+ }
328
+ interface UiButtonNode extends UiNodeBase {
329
+ kind: "button";
330
+ label: UiBindable<string>;
331
+ variant?: "default" | "outline" | "ghost" | "secondary" | "destructive" | "link";
332
+ size?: "sm" | "default" | "lg";
333
+ disabled?: UiBindable<boolean>;
334
+ onClick?: UiAction | UiAction[];
335
+ }
336
+ /**
337
+ * Two-state toggle. `binding` is a dotted state path; clicking flips the
338
+ * stored boolean. Optional `onChange` fires *after* the state flip.
339
+ */
340
+ interface UiToggleNode extends UiNodeBase {
341
+ kind: "toggle";
342
+ label?: UiBindable<string>;
343
+ binding: string;
344
+ onChange?: UiAction | UiAction[];
345
+ }
346
+ /**
347
+ * Numeric range input. `binding` is a dotted state path; the slider reads and
348
+ * writes the stored number. Optional `onChange` fires after each commit.
349
+ */
350
+ interface UiSliderNode extends UiNodeBase {
351
+ kind: "slider";
352
+ binding: string;
353
+ min?: number;
354
+ max?: number;
355
+ step?: number;
356
+ label?: UiBindable<string>;
357
+ /** Show the current value next to the slider. Default: true. */
358
+ showValue?: boolean;
359
+ onChange?: UiAction | UiAction[];
360
+ }
361
+ interface UiTooltipNode extends UiNodeBase {
362
+ kind: "tooltip";
363
+ content: UiBindable<string>;
364
+ side?: "top" | "bottom" | "left" | "right";
365
+ child: UiNode;
366
+ }
367
+ /**
368
+ * Wrap any node to make it draggable. Drag is purely visual — release fires
369
+ * `onDragEnd`. If `snapBack` (default) the child returns to its origin.
370
+ */
371
+ interface UiDraggableNode extends UiNodeBase {
372
+ kind: "draggable";
373
+ child: UiNode;
374
+ axis?: "x" | "y" | "both";
375
+ snapBack?: boolean;
376
+ onDragEnd?: UiAction | UiAction[];
377
+ }
378
+ /**
379
+ * Escape hatch: a host-app-registered component. The host registers a
380
+ * renderer by name via `UiCustomNodeRegistryProvider`; props are passed
381
+ * through after binding resolution and children render recursively.
382
+ */
383
+ interface UiCustomNode extends UiNodeBase {
384
+ kind: "custom";
385
+ name: string;
386
+ props?: Record<string, unknown>;
387
+ children?: UiNode[];
388
+ }
389
+ type UiNode = UiBoxNode | UiTextNode | UiHeadingNode | UiBadgeNode | UiButtonNode | UiToggleNode | UiSliderNode | UiTooltipNode | UiDraggableNode | UiCustomNode;
390
+ type UiAction =
391
+ /** Append a user message to the active thread. */
392
+ {
393
+ kind: "message";
394
+ text: UiBindable<string>;
395
+ }
396
+ /** Set a path in local state to a (possibly bound) value. */
397
+ | {
398
+ kind: "set";
399
+ path: string;
400
+ value: UiBindable<unknown>;
401
+ }
402
+ /** Flip a boolean at the given local-state path. */
403
+ | {
404
+ kind: "toggle";
405
+ path: string;
406
+ }
407
+ /** Bubble a named event to the host app via `UiEventProvider`. */
408
+ | {
409
+ kind: "emit";
410
+ name: string;
411
+ payload?: unknown;
412
+ };
413
+ declare function isUiBinding(value: unknown): value is {
414
+ $bind: string;
415
+ };
416
+
417
+ interface ChartArtifact {
418
+ type: "chart";
419
+ /** Chart kind. Renderer maps these to the underlying lib (e.g. recharts). */
420
+ chartType?: "bar" | "line" | "area" | "pie";
421
+ /** Optional title rendered above the chart. */
422
+ title?: string;
423
+ /** Array of data points. Keys map to series via `dataKey` / `xKey`. */
424
+ data: Array<Record<string, unknown>>;
425
+ /** Field name on each data point used for the X axis / category. */
426
+ xKey?: string;
427
+ /** Field name(s) used for series. Defaults to all keys except `xKey`. */
428
+ dataKey?: string | string[];
429
+ /** Optional unit label appended to numeric axis ticks. */
430
+ unit?: string;
431
+ }
432
+ interface QuestionOption {
433
+ id: string;
434
+ label: string;
435
+ description?: string;
436
+ }
437
+ /**
438
+ * Question artifact — renders an in-thread choice widget. When the user picks
439
+ * an option, the renderer calls back into the runtime with the selected
440
+ * label as a new user message. Agents should treat the user response as the
441
+ * answer.
442
+ */
443
+ interface QuestionArtifact {
444
+ type: "question";
445
+ /** Optional prompt shown above the options. Falls back to the message text. */
446
+ prompt?: string;
447
+ options: QuestionOption[];
448
+ /** Allow selecting more than one option. Default: false. */
449
+ multi?: boolean;
450
+ }
451
+ /** HTML/CSS/JS rendered in an iframe. See {@link HtmlArtifactView}. */
452
+ interface HtmlArtifact {
453
+ type: "html";
454
+ content: string;
455
+ /**
456
+ * When true (default) the HTML renders inside a sandboxed iframe. The
457
+ * sandbox allows scripts, forms, and modals but still isolates the
458
+ * document from the host page. Set to `false` for fully unrestricted
459
+ * inline HTML (scripts, external CDN assets, etc.) — trusted content only.
460
+ */
461
+ sandboxed?: boolean;
462
+ /** Optional title rendered above the iframe. */
463
+ title?: string;
464
+ /** Iframe height in CSS pixels or any valid CSS length. Default: "320px". */
465
+ height?: string;
466
+ }
467
+ interface JsonArtifact {
468
+ type: "json";
469
+ title?: string;
470
+ data: unknown;
471
+ }
472
+ interface TableArtifact {
473
+ type: "table";
474
+ title?: string;
475
+ columns?: Array<{
476
+ key: string;
477
+ label?: string;
478
+ }>;
479
+ rows: Array<Record<string, unknown>>;
480
+ }
481
+
482
+ type TimbalArtifact = ChartArtifact | QuestionArtifact | HtmlArtifact | JsonArtifact | TableArtifact | UiArtifact;
483
+ type AnyArtifact = TimbalArtifact | {
484
+ type: string;
485
+ [key: string]: unknown;
486
+ };
487
+ /**
488
+ * Type guard for artifact-shaped objects. Anything with a string `type` field
489
+ * is considered a candidate; specific renderers narrow further.
490
+ */
491
+ declare function isArtifact(value: unknown): value is AnyArtifact;
492
+
493
+ interface ArtifactRendererProps<T extends AnyArtifact = AnyArtifact> {
494
+ artifact: T;
33
495
  }
496
+ type ArtifactRenderer<T extends AnyArtifact = AnyArtifact> = ComponentType<ArtifactRendererProps<T>>;
497
+ type ArtifactRegistry = Record<string, ArtifactRenderer<AnyArtifact>>;
498
+ declare const defaultArtifactRenderers: ArtifactRegistry;
499
+ /**
500
+ * Provide a custom artifact registry to the subtree. Custom renderers are
501
+ * merged on top of the defaults — pass `override: true` to replace.
502
+ */
503
+ declare const ArtifactRegistryProvider: FC<{
504
+ renderers?: ArtifactRegistry;
505
+ override?: boolean;
506
+ children: ReactNode;
507
+ }>;
508
+ declare function useArtifactRegistry(): ArtifactRegistry;
509
+ /**
510
+ * Render an artifact using the closest registry. Falls back to the JSON
511
+ * renderer when no entry matches the artifact's `type`.
512
+ */
513
+ declare const ArtifactView: FC<{
514
+ artifact: AnyArtifact;
515
+ }>;
516
+
517
+ type UiState = Record<string, unknown>;
518
+ type UiStateAction = {
519
+ type: "set";
520
+ path: string;
521
+ value: unknown;
522
+ } | {
523
+ type: "toggle";
524
+ path: string;
525
+ } | {
526
+ type: "replace";
527
+ state: UiState;
528
+ };
529
+ /** Read a dotted path from a state object. Returns undefined when missing. */
530
+ declare function getPath(state: UiState, path: string): unknown;
531
+ /**
532
+ * Set a dotted path on a state object, returning a new object. Intermediate
533
+ * objects are cloned (or created when missing) so the result is safe to use
534
+ * directly with React state without further copying.
535
+ */
536
+ declare function setPath(state: UiState, path: string, value: unknown): UiState;
537
+ /** Resolve a UiBindable into its concrete value against the given state. */
538
+ declare function resolveBindable<T>(value: UiBindable<T>, state: UiState): T;
539
+
540
+ declare function useUiState(): UiState;
541
+ declare function useUiDispatch(): Dispatch<UiStateAction>;
542
+ interface UiEventEnvelope {
543
+ name: string;
544
+ payload?: unknown;
545
+ }
546
+ /**
547
+ * Subscribe the host app to `emit`-kind actions fired from any UiArtifact in
548
+ * the subtree. Wrap your runtime / chat root once.
549
+ */
550
+ declare const UiEventProvider: FC<{
551
+ onEvent: (event: UiEventEnvelope) => void;
552
+ children: ReactNode;
553
+ }>;
554
+ declare function useUiEventEmitter(): ((event: UiEventEnvelope) => void) | null;
555
+ interface UiCustomNodeProps {
556
+ /** Already binding-resolved props from the artifact. */
557
+ props: Record<string, unknown>;
558
+ /** Recursively rendered children. */
559
+ children?: ReactNode;
560
+ }
561
+ type UiCustomNodeRenderer = ComponentType<UiCustomNodeProps>;
562
+ /**
563
+ * Register named renderers for `{ kind: "custom", name: "..." }` nodes. Lets
564
+ * host apps extend the palette without forking the package.
565
+ */
566
+ declare const UiCustomNodeRegistryProvider: FC<{
567
+ renderers: Record<string, UiCustomNodeRenderer>;
568
+ children: ReactNode;
569
+ }>;
570
+ declare function useUiCustomNodeRegistry(): Record<string, UiCustomNodeRenderer>;
571
+
34
572
  interface ThreadWelcomeConfig {
35
573
  heading?: string;
36
574
  subheading?: string;
575
+ /**
576
+ * Optional brand icon rendered above the heading. Pass any ReactNode — the
577
+ * SDK no longer ships a default sparkle icon so apps can drop in their
578
+ * own logo or stay minimal.
579
+ */
580
+ icon?: ReactNode;
37
581
  }
38
582
  interface ThreadWelcomeProps {
39
583
  config?: ThreadWelcomeConfig;
40
- suggestions?: ThreadSuggestion[];
584
+ suggestions?: SuggestionsSource;
585
+ /**
586
+ * The resolved `Suggestions` component (default or user-overridden via
587
+ * `components.Suggestions`). Custom Welcome implementations should render
588
+ * this and pass their `suggestions` source through.
589
+ */
590
+ Suggestions?: SuggestionsComponent;
41
591
  }
42
592
  interface ThreadComponents {
43
- /** Replace the user message bubble. Access message content via `MessagePrimitive.Parts`. */
593
+ /** Replace the user message bubble. Access content via `MessagePrimitive.Parts`. */
44
594
  UserMessage?: ComponentType;
45
- /** Replace the assistant message bubble. Access message content via `MessagePrimitive.Parts`. */
595
+ /** Replace the assistant message bubble. Access content via `MessagePrimitive.Parts`. */
46
596
  AssistantMessage?: ComponentType;
47
597
  /** Replace the inline edit composer. */
48
598
  EditComposer?: ComponentType;
49
- /** Replace the composer (input bar). Receives `placeholder` from `composerPlaceholder`. */
50
- Composer?: ComponentType<{
51
- placeholder?: string;
52
- }>;
53
- /** Replace the welcome / empty state. Receives `config` and `suggestions` props. Controls its own visibility — use `useThread(s => s.isEmpty)` to replicate the default behaviour. */
599
+ /** Replace the composer (input bar). Receives all `ComposerProps` from the parent. */
600
+ Composer?: ComponentType<ComposerProps>;
601
+ /** Replace the welcome / empty state. Renders only while the thread is empty. */
54
602
  Welcome?: ComponentType<ThreadWelcomeProps>;
603
+ /** Replace the suggestion list (rendered inside Welcome). */
604
+ Suggestions?: SuggestionsComponent;
55
605
  /** Replace the scroll-to-bottom button. */
56
606
  ScrollToBottom?: ComponentType;
57
607
  }
608
+ interface ThreadArtifactsConfig {
609
+ /** Custom artifact renderers, merged on top of the built-in defaults. */
610
+ renderers?: ArtifactRegistry;
611
+ /** Replace the built-in renderers entirely instead of merging. */
612
+ override?: boolean;
613
+ }
614
+
58
615
  interface ThreadProps {
59
616
  className?: string;
60
- /** Max width of the message column. Default: "44rem" */
617
+ /** Max width of the message column. Default: "44rem". */
61
618
  maxWidth?: string;
62
- /** Welcome screen text */
619
+ /** Welcome screen text + optional brand icon. */
63
620
  welcome?: ThreadWelcomeConfig;
64
- /** Suggestion chips shown on the welcome screen */
65
- suggestions?: ThreadSuggestion[];
66
- /** Composer input placeholder. Default: "Send a message..." */
621
+ /**
622
+ * Welcome-screen suggestion rows. Accepts a static array, a thunk, or an
623
+ * async function for per-user suggestions.
624
+ */
625
+ suggestions?: SuggestionsSource;
626
+ /** Composer input placeholder. Default: "Send a message...". */
67
627
  composerPlaceholder?: string;
68
628
  /** Override individual UI slots while keeping the rest as defaults. */
69
629
  components?: ThreadComponents;
630
+ /**
631
+ * Configure how rich tool/artifact results render. Pass `renderers` to add
632
+ * support for custom artifact `type` values. Built-in types (`chart`,
633
+ * `question`, `html`, `json`, `table`, `ui`) are always available unless
634
+ * `override: true` is set.
635
+ */
636
+ artifacts?: ThreadArtifactsConfig;
637
+ /**
638
+ * Called when a `ui` artifact fires an `{ kind: "emit" }` action. Use this
639
+ * to react to slider commits, drag gestures, or other host-side logic
640
+ * beyond the built-in `message` action (which already appends a user
641
+ * message).
642
+ */
643
+ onArtifactEvent?: (event: UiEventEnvelope) => void;
70
644
  }
71
645
  declare const Thread: FC<ThreadProps>;
72
646
 
73
647
  interface TimbalChatProps extends Omit<TimbalRuntimeProviderProps, "children">, ThreadProps {
74
648
  }
75
- declare function TimbalChat({ workforceId, baseUrl, fetch, ...threadProps }: TimbalChatProps): react_jsx_runtime.JSX.Element;
649
+ declare function TimbalChat({ workforceId, baseUrl, fetch, attachments, attachmentsUploadUrl, attachmentsAccept, debug, ...threadProps }: TimbalChatProps): react_jsx_runtime.JSX.Element;
76
650
 
77
651
  declare const MarkdownText: React.MemoExoticComponent<() => react_jsx_runtime.JSX.Element>;
78
652
 
653
+ interface ToolStatus {
654
+ type: string;
655
+ reason?: string;
656
+ }
657
+ declare function useToolRunning(props: {
658
+ status?: ToolStatus;
659
+ result?: unknown;
660
+ }): boolean;
79
661
  declare const ToolFallback: ToolCallMessagePartComponent;
80
662
 
663
+ /**
664
+ * Tool-row presence motion shared across the chat surface.
665
+ *
666
+ * Mirrors `timbal-platform` `StudioToolMotion.js` — a soft "luxury" ease in
667
+ * with optional blur, fast exit, and a grid-row collapsible body. Exit
668
+ * durations stay short so the layout doesn't feel sticky when tools resolve
669
+ * quickly.
670
+ */
671
+ declare const luxuryEase: readonly [0.16, 1, 0.3, 1];
672
+ declare function toolPresenceTransition(reduced: boolean): {
673
+ enter: {
674
+ duration: number;
675
+ ease: readonly [0.16, 1, 0.3, 1];
676
+ };
677
+ exit: {
678
+ duration: number;
679
+ ease: readonly [0.4, 0, 1, 1];
680
+ };
681
+ };
682
+ type ToolMotionVariant = "executing" | "settled";
683
+ interface ToolMotionProps {
684
+ children: ReactNode;
685
+ className?: string;
686
+ /** Stable key for AnimatePresence swaps (e.g. `running` → `complete`). */
687
+ motionKey: string;
688
+ }
689
+ /** Single-shot rise-from-below for tool / artifact rows. */
690
+ declare function ToolMotion({ children, className, motionKey }: ToolMotionProps): react_jsx_runtime.JSX.Element;
691
+ interface ToolPresenceProps {
692
+ presenceKey: string;
693
+ children: ReactNode;
694
+ className?: string;
695
+ /** Executing rows skip blur so the shimmer stays readable. */
696
+ variant?: ToolMotionVariant;
697
+ }
698
+ /** Wraps running ↔ complete (or other) tool states with a short crossfade. */
699
+ declare function ToolPresence({ presenceKey, children, className, variant, }: ToolPresenceProps): react_jsx_runtime.JSX.Element;
700
+ interface ToolBodyPresenceProps {
701
+ open: boolean;
702
+ children: ReactNode;
703
+ className?: string;
704
+ }
705
+ /**
706
+ * Expanded tool trace — CSS grid row collapse for smooth contract + opacity.
707
+ * Avoids `AnimatePresence` exit lag when the body closes.
708
+ */
709
+ declare function ToolBodyPresence({ open, children, className, }: ToolBodyPresenceProps): react_jsx_runtime.JSX.Element;
710
+
711
+ /**
712
+ * Copy-paste this into a workforce agent system prompt (or append it to your
713
+ * blueprint's tool-result instructions) so the model knows which artifact
714
+ * payloads the chat UI can render.
715
+ *
716
+ * @example
717
+ * ```ts
718
+ * import { ARTIFACT_AGENT_INSTRUCTIONS } from "@timbal-ai/timbal-react";
719
+ *
720
+ * const systemPrompt = `${basePrompt}\n\n${ARTIFACT_AGENT_INSTRUCTIONS}`;
721
+ * ```
722
+ */
723
+ declare const ARTIFACT_AGENT_INSTRUCTIONS: string;
724
+
725
+ /**
726
+ * Render a `ui` artifact. Each instance gets its own local state seeded from
727
+ * `artifact.initialState`. Toggles, sliders, and `set` actions mutate this
728
+ * state via the reducer; bindings (`{ $bind: "path" }`) read from it.
729
+ *
730
+ * Host apps subscribe to `emit` actions via `<UiEventProvider>` from the
731
+ * registry module and extend the node palette via
732
+ * `<UiCustomNodeRegistryProvider>`.
733
+ */
734
+ declare const UiArtifactView: FC<{
735
+ artifact: UiArtifact;
736
+ }>;
737
+
738
+ declare const UiNodeView: FC<{
739
+ node: UiNode;
740
+ }>;
741
+
742
+ /**
743
+ * Markdown fence languages we treat as artifact payloads. `timbal-artifact`
744
+ * is the canonical form; `timbal` is accepted as an alias because most
745
+ * frontier models drop the suffix when generating fenced blocks.
746
+ */
747
+ declare const ARTIFACT_FENCE_LANGUAGES: ReadonlySet<string>;
748
+ /**
749
+ * Returns true if the given fenced-code-block language should be rendered
750
+ * as an artifact instead of as a code block.
751
+ */
752
+ declare function isArtifactFenceLanguage(language: string | undefined | null): boolean;
753
+ /**
754
+ * Parse a tool result into an artifact, if possible. Strings are tried as
755
+ * JSON first. Timbal often wraps tool return values as
756
+ * `{ type: "text", text: "<json>" }` — we unwrap those before checking
757
+ * `type`. Returns `null` for results that don't look like artifacts.
758
+ */
759
+ declare function parseArtifactFromToolResult(result: unknown): AnyArtifact | null;
760
+ interface MarkdownArtifactMatch {
761
+ /** The artifact payload. */
762
+ artifact: AnyArtifact;
763
+ /** The raw fenced block, including its ``` fences. */
764
+ raw: string;
765
+ /** Start offset in the source string. */
766
+ start: number;
767
+ /** End offset (exclusive). */
768
+ end: number;
769
+ }
770
+ /**
771
+ * Find every `timbal-artifact` fenced block in a markdown string and return
772
+ * each parsed payload along with its source offset. Use the offsets to splice
773
+ * a renderer in place of the fence — see `splitMarkdownByArtifacts`.
774
+ */
775
+ declare function findMarkdownArtifacts(markdown: string): MarkdownArtifactMatch[];
776
+ type MarkdownSegment = {
777
+ kind: "text";
778
+ text: string;
779
+ } | {
780
+ kind: "artifact";
781
+ artifact: AnyArtifact;
782
+ };
783
+ /**
784
+ * Split a markdown string into alternating text/artifact segments, preserving
785
+ * order. Useful when rendering markdown with inline artifact placeholders —
786
+ * render each segment with the appropriate component.
787
+ */
788
+ declare function splitMarkdownByArtifacts(markdown: string): MarkdownSegment[];
789
+
790
+ /**
791
+ * Default `tools.Override` for assistant messages.
792
+ *
793
+ * Renders the tool result as a registered artifact when possible; otherwise
794
+ * falls back to the timeline `ToolFallback`. Wraps the artifact in
795
+ * `ToolMotion` so it shares the same rise-from-below polish as the rest of
796
+ * the chat surface.
797
+ */
798
+ declare const ToolArtifactFallback: ToolCallMessagePartComponent;
799
+
800
+ /**
801
+ * Shared chrome for built-in artifact renderers. Custom renderers don't have
802
+ * to use this — it's just a small visual baseline so charts, tables, and
803
+ * question widgets feel like a coherent set.
804
+ */
805
+ declare const ArtifactCard: FC<{
806
+ title?: string;
807
+ kind?: string;
808
+ className?: string;
809
+ bodyClassName?: string;
810
+ toolbar?: ReactNode;
811
+ children: ReactNode;
812
+ }>;
813
+
814
+ /**
815
+ * Lightweight SVG chart for the four basic chart types. We deliberately don't
816
+ * pull in `recharts` or similar — most artifact charts are small and these
817
+ * render fine at the cost of a few hundred lines of SVG. Apps that need
818
+ * production-grade charting can register a custom renderer that wraps their
819
+ * preferred lib.
820
+ */
821
+ declare const ChartArtifactView: FC<{
822
+ artifact: ChartArtifact;
823
+ }>;
824
+
825
+ /**
826
+ * In-thread choice widget. Single-select submits immediately on click;
827
+ * multi-select shows a confirm button. The answer is sent as a regular
828
+ * user message via the assistant-ui runtime so the agent treats it like
829
+ * any other reply.
830
+ */
831
+ declare const QuestionArtifactView: FC<{
832
+ artifact: QuestionArtifact;
833
+ }>;
834
+
835
+ /**
836
+ * Renders HTML inside an iframe. When `sandboxed` is true (default), scripts
837
+ * and forms run in an isolated sandbox. Set `sandboxed: false` for fully
838
+ * unrestricted inline HTML — trusted content only.
839
+ */
840
+ declare const HtmlArtifactView: FC<{
841
+ artifact: HtmlArtifact;
842
+ }>;
843
+
844
+ /**
845
+ * Default renderer used both for `{ type: "json" }` artifacts and as the
846
+ * fallback when no renderer is registered for a given type. Pretty-prints
847
+ * any JSON-serializable value.
848
+ */
849
+ declare const JsonArtifactView: FC<{
850
+ artifact: JsonArtifact | AnyArtifact;
851
+ }>;
852
+
853
+ declare const TableArtifactView: FC<{
854
+ artifact: TableArtifact;
855
+ }>;
856
+
81
857
  declare const UserMessageAttachments: FC;
82
858
  declare const ComposerAttachments: FC;
83
859
  declare const ComposerAddAttachment: FC;
84
860
 
85
- declare const buttonVariants: (props?: ({
86
- variant?: "default" | "link" | "destructive" | "outline" | "secondary" | "ghost" | null | undefined;
87
- size?: "default" | "xs" | "sm" | "lg" | "icon" | "icon-xs" | "icon-sm" | "icon-lg" | null | undefined;
88
- } & class_variance_authority_types.ClassProp) | undefined) => string;
89
- declare function Button({ className, variant, size, asChild, ...props }: React.ComponentProps<"button"> & VariantProps<typeof buttonVariants> & {
861
+ /**
862
+ * Timbal V2 button design tokens.
863
+ *
864
+ * Mirrors the `timbal-platform` design language (`TimbalV2Button`) so chat
865
+ * surfaces built with the SDK feel identical to the Timbal Studio. Each record
866
+ * is keyed by variant or size and ships only Tailwind utility classes — no
867
+ * runtime JS — so consumers can compose them with `cn(...)` and add their own
868
+ * overrides without ejecting.
869
+ */
870
+ type TimbalV2Variant = "primary" | "secondary" | "ghost" | "informative" | "destructive" | "link";
871
+ type TimbalV2Size = "xs" | "sm" | "md" | "lg";
872
+ declare const TIMBAL_V2_SIZE_HEIGHT: Record<TimbalV2Size, string>;
873
+ declare const TIMBAL_V2_SIZE_ICON: Record<TimbalV2Size, string>;
874
+ declare const TIMBAL_V2_SIZE_LABEL_PX: Record<TimbalV2Size, string>;
875
+ /**
876
+ * Absolute gradient fill layer — scoped to the `group/tbv2` group so the
877
+ * hover/active states can be triggered without wrapping each button in
878
+ * dedicated state classes.
879
+ */
880
+ declare const TIMBAL_V2_FILL: Record<TimbalV2Variant, string>;
881
+ declare const TIMBAL_V2_LABEL: Record<TimbalV2Variant, string>;
882
+ declare const TIMBAL_V2_BORDER: Record<TimbalV2Variant, string>;
883
+ declare const TIMBAL_V2_SHADOW: Record<TimbalV2Variant, string>;
884
+ /** Static pill surface — sidebars, badges, anywhere a button shape is needed without interaction. */
885
+ declare const TIMBAL_V2_PILL_SURFACE = "bg-gradient-to-b from-white to-neutral-50/70 border border-neutral-200/80 shadow-[0_1px_2px_-0.5px_rgba(0,0,0,0.05)] dark:from-white/[0.05] dark:to-white/[0.025] dark:border-white/[0.08] dark:shadow-[0_1px_3px_rgba(0,0,0,0.22)]";
886
+ /** Interactive secondary chrome for native controls beside v2 buttons (selects, search inputs). */
887
+ declare const TIMBAL_V2_SECONDARY_CHROME = "bg-gradient-to-b from-white to-neutral-50/70 border border-neutral-200/80 shadow-[0_1px_2px_-0.5px_rgba(0,0,0,0.05)] transition-[background-color,box-shadow,border-color] duration-200 ease-in-out hover:from-neutral-50/40 hover:to-neutral-100/60 active:from-neutral-100/65 active:to-neutral-200/65 dark:from-white/[0.05] dark:to-white/[0.025] dark:border-white/[0.08] dark:shadow-[0_1px_3px_rgba(0,0,0,0.22)] dark:hover:from-white/[0.07] dark:hover:to-white/[0.045] dark:active:from-white/[0.10] dark:active:to-white/[0.07]";
888
+
889
+ interface TimbalV2ButtonProps extends React.ComponentProps<"button"> {
890
+ variant?: TimbalV2Variant;
891
+ size?: TimbalV2Size;
892
+ isIconOnly?: boolean;
893
+ isLoading?: boolean;
894
+ fullWidth?: boolean;
895
+ /** When true, renders children as the underlying element (Radix Slot pattern). */
90
896
  asChild?: boolean;
91
- }): react_jsx_runtime.JSX.Element;
897
+ }
898
+ /**
899
+ * Canonical Timbal pill button — layered absolute-fill span + relative label
900
+ * row scoped to `group/tbv2`. Mirrors `timbal-platform` `TimbalV2Button` so
901
+ * chat UIs built with the SDK feel identical to the Studio.
902
+ */
903
+ declare const TimbalV2Button: React.ForwardRefExoticComponent<Omit<TimbalV2ButtonProps, "ref"> & React.RefAttributes<HTMLButtonElement>>;
92
904
 
93
- type TooltipIconButtonProps = ComponentPropsWithRef<typeof Button> & {
905
+ interface TooltipIconButtonProps extends Omit<TimbalV2ButtonProps, "isIconOnly"> {
906
+ /** Visible tooltip + accessible label. Always required. */
94
907
  tooltip: string;
908
+ /** Tooltip placement. Default: "bottom". */
95
909
  side?: "top" | "bottom" | "left" | "right";
96
- };
910
+ }
911
+ /**
912
+ * Icon-only Timbal pill button with a tooltip. Used by every chat-surface
913
+ * toolbar (composer send/cancel, message action bar, scroll-to-bottom).
914
+ *
915
+ * Defaults to a soft `secondary` variant so it sits cleanly inside composers,
916
+ * message bubbles, and the action bar. Override via `variant`.
917
+ */
97
918
  declare const TooltipIconButton: React.ForwardRefExoticComponent<Omit<TooltipIconButtonProps, "ref"> & React.RefAttributes<HTMLButtonElement>>;
98
919
 
99
920
  declare const ShikiSyntaxHighlighter: FC<SyntaxHighlighterProps>;
100
921
 
922
+ type FetchFn = (url: string, options?: RequestInit) => Promise<Response>;
923
+ interface UseWorkforcesOptions {
924
+ /** Base URL for API calls. Default: `/api`. */
925
+ baseUrl?: string;
926
+ /** Custom fetch (defaults to `authFetch` for token-auth flows). */
927
+ fetch?: FetchFn;
928
+ /**
929
+ * Pick the initial selected workforce. By default we prefer the first
930
+ * `type === "agent"` entry, falling back to the first item. Pass a custom
931
+ * resolver to override (e.g. remember the user's last choice).
932
+ */
933
+ pickInitial?: (items: WorkforceItem[]) => WorkforceItem | undefined;
934
+ }
935
+ interface UseWorkforcesResult {
936
+ workforces: WorkforceItem[];
937
+ /** Currently selected workforce identifier (id ?? uid ?? name). */
938
+ selectedId: string;
939
+ setSelectedId: (id: string) => void;
940
+ /** The full `WorkforceItem` for `selectedId`, if any. */
941
+ selected: WorkforceItem | undefined;
942
+ isLoading: boolean;
943
+ error: Error | null;
944
+ /** Re-fetch the list. Resets `error`. */
945
+ refresh: () => Promise<void>;
946
+ }
947
+ /**
948
+ * Fetch the list of workforces exposed by the blueprint API and track a
949
+ * selection. Used to power `<WorkforceSelector />` but exported separately
950
+ * so apps can drive their own UI (e.g. a sidebar tree).
951
+ */
952
+ declare function useWorkforces(options?: UseWorkforcesOptions): UseWorkforcesResult;
953
+
954
+ interface WorkforceSelectorProps {
955
+ /** List of workforces to choose from. */
956
+ workforces: WorkforceItem[];
957
+ /** Currently selected workforce id. */
958
+ value: string;
959
+ /** Called when the user picks a different workforce. */
960
+ onChange: (id: string) => void;
961
+ /** Hide the selector when there's only one option. Default: true. */
962
+ hideWhenSingle?: boolean;
963
+ className?: string;
964
+ placeholder?: string;
965
+ }
966
+ /**
967
+ * Minimal headless workforce picker. Wraps a styled native `<select>` so
968
+ * the SDK doesn't need to depend on `@radix-ui/react-select`, while still
969
+ * matching the Studio chrome (gradient pill, soft border, chevron).
970
+ *
971
+ * Apps that want a richer UI (search, descriptions, agent icons) can build
972
+ * their own using `useWorkforces()`.
973
+ */
974
+ declare const WorkforceSelector: FC<WorkforceSelectorProps>;
975
+
976
+ interface TimbalChatShellProps extends Omit<TimbalChatProps, "workforceId"> {
977
+ /**
978
+ * Pre-selected workforce id. When omitted, the shell fetches the workforce
979
+ * list from `{baseUrl}/workforce` and picks the first agent automatically.
980
+ */
981
+ workforceId?: string;
982
+ /** Branding rendered at the start of the header (logo, etc). */
983
+ brand?: ReactNode;
984
+ /** Extra content rendered at the end of the header (theme toggle, logout). */
985
+ headerActions?: ReactNode;
986
+ /** Hide the built-in workforce selector. Default: false. */
987
+ hideWorkforceSelector?: boolean;
988
+ /** Class for the outer flex container. */
989
+ className?: string;
990
+ /** Class for the header bar. */
991
+ headerClassName?: string;
992
+ }
993
+ /**
994
+ * Drop-in shell that wraps `TimbalChat` with the Studio playground chrome:
995
+ * floating topbar with brand + workforce selector + actions, soft gradient
996
+ * background, and the chat thread filling the remaining vertical space.
997
+ *
998
+ * Falls back to picking the first available workforce when `workforceId`
999
+ * isn't supplied.
1000
+ */
1001
+ declare const TimbalChatShell: FC<TimbalChatShellProps>;
1002
+
101
1003
  interface SessionContextType {
102
1004
  user: Session | null;
103
1005
  loading: boolean;
@@ -130,6 +1032,73 @@ declare const refreshAccessToken: () => Promise<boolean>;
130
1032
  declare const authFetch: (url: string, options?: RequestInit) => Promise<Response>;
131
1033
  declare const fetchCurrentUser: () => Promise<Session | null>;
132
1034
 
1035
+ /**
1036
+ * Shared chrome class names + CSS variables for Timbal chat surfaces.
1037
+ *
1038
+ * These mirror `timbal-platform` `studioChrome.js` so the SDK ships the same
1039
+ * design language out of the box. Class consts are pure strings (no runtime
1040
+ * cost) and can be composed with `cn(...)` from `../utils`.
1041
+ */
1042
+
1043
+ declare const STUDIO_TOPBAR_GAP = "0.5rem";
1044
+ declare const STUDIO_TOPBAR_HEIGHT = "3rem";
1045
+ declare const STUDIO_PILL_HEIGHT = "2.5rem";
1046
+ declare const STUDIO_SIDEBAR_GAP = "0.5rem";
1047
+ declare const STUDIO_SIDEBAR_WIDTH = "3rem";
1048
+ declare const STUDIO_INSET_LEFT = "calc(0.5rem + 3rem)";
1049
+ /**
1050
+ * Style object to spread on the chat shell root. Exposes the CSS variables
1051
+ * referenced by topbar/sidebar helper classes so layouts stay self-contained.
1052
+ */
1053
+ declare const studioChromeShellStyle: CSSProperties;
1054
+ declare const studioTopbarPillHeightClass = "h-[var(--studio-chrome-pill-height)] min-h-[var(--studio-chrome-pill-height)]";
1055
+ declare const studioTopbarIconPillClass = "shrink-0 flex-none size-[var(--studio-chrome-pill-height)] min-h-[var(--studio-chrome-pill-height)] min-w-[var(--studio-chrome-pill-height)]";
1056
+ /** Soft playground gradient behind the message column. */
1057
+ declare const studioPlaygroundGradientClass = "bg-gradient-to-b from-neutral-200/60 via-neutral-100/30 to-background dark:from-zinc-800 dark:via-zinc-900 dark:to-zinc-950";
1058
+ /** Composer outer shell — rounded surface with focus-within affordances. */
1059
+ declare const studioComposeInputShellClass = "flex w-full flex-col rounded-2xl border border-neutral-200/60 bg-background shadow-lg shadow-black/5 outline-none transition-[box-shadow,border-color] focus-within:border-neutral-400/80 focus-within:ring-2 focus-within:ring-foreground/5 focus-within:shadow-xl focus-within:shadow-black/10 dark:border-white/12 dark:bg-zinc-900 dark:shadow-black/20 dark:focus-within:border-white/22 dark:focus-within:ring-0";
1060
+ /** Resting pill surface — sidebars, badges. */
1061
+ declare const studioPillSurfaceClass = "bg-gradient-to-b from-white to-neutral-50/70 border border-neutral-200/80 shadow-[0_1px_2px_-0.5px_rgba(0,0,0,0.05)] dark:from-white/[0.05] dark:to-white/[0.025] dark:border-white/[0.08] dark:shadow-[0_1px_3px_rgba(0,0,0,0.22)]";
1062
+ /** Interactive secondary chrome — select triggers, search shells. */
1063
+ declare const studioSecondaryChromeClass = "bg-gradient-to-b from-white to-neutral-50/70 border border-neutral-200/80 shadow-[0_1px_2px_-0.5px_rgba(0,0,0,0.05)] transition-[background-color,box-shadow,border-color] duration-200 ease-in-out hover:from-neutral-50/40 hover:to-neutral-100/60 active:from-neutral-100/65 active:to-neutral-200/65 dark:from-white/[0.05] dark:to-white/[0.025] dark:border-white/[0.08] dark:shadow-[0_1px_3px_rgba(0,0,0,0.22)] dark:hover:from-white/[0.07] dark:hover:to-white/[0.045] dark:active:from-white/[0.10] dark:active:to-white/[0.07]";
1064
+ /**
1065
+ * Solid integration-card surface — used for in-thread tool / artifact cards
1066
+ * so they read on the playground gradient.
1067
+ */
1068
+ declare const studioIntegrationSurfaceSolid = "bg-white bg-gradient-to-b from-white to-neutral-50/70 shadow-[0_1px_2px_-0.5px_rgba(0,0,0,0.05)] dark:bg-zinc-900 dark:from-white/[0.05] dark:to-white/[0.025] dark:shadow-[0_1px_3px_rgba(0,0,0,0.22)]";
1069
+ declare const studioIntegrationBorder = "border border-neutral-200/80 dark:border-white/[0.08]";
1070
+ declare const studioIntegrationCardClass: string;
1071
+ declare const studioIntegrationIconTileClass: string;
1072
+ /**
1073
+ * Full-width selectable row — used by `Suggestions` and any settings-style
1074
+ * list cards. Mirrors `roleListRowSurfaceClass` in timbal-platform.
1075
+ */
1076
+ declare const studioListRowButtonClass: string;
1077
+ /** Compose tool drawer / trace payload well — opaque so JSON reads on the gradient. */
1078
+ declare const studioComposerIoWellClass: string;
1079
+ /** Collapsible tool-call card shell. */
1080
+ declare const studioToolCardShellClass: string;
1081
+ declare const studioTimelineRowButtonClass = "group flex w-full min-w-0 cursor-pointer items-center justify-start rounded-md border-0 bg-transparent py-1 text-left shadow-none focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-foreground/15 focus-visible:ring-offset-2";
1082
+ declare const studioTimelineTextClass = "text-xs font-normal leading-snug";
1083
+ declare const studioTimelineActionClass: string;
1084
+ /** Shimmer action word — text-transparent inherits its colour from the bg clip. */
1085
+ declare const studioTimelineShimmerActionClass: string;
1086
+ declare const studioTimelineDetailClass: string;
1087
+ declare function studioTimelineChevronClass(expanded: boolean): string;
1088
+ /** Padding for the expanded payload under a timeline toggle. */
1089
+ declare const studioTimelineBodyPadClass = "flex flex-col gap-2 pt-0.5 pb-0.5";
1090
+ declare const studioArtifactShellClass: string;
1091
+ declare const studioQuestionOptionClass = "flex w-full items-center gap-2 rounded-lg border border-transparent px-2 py-1.5 text-left text-sm transition-[background-color,border-color,box-shadow] duration-200 hover:bg-neutral-100/80 dark:hover:bg-white/[0.05] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-foreground/15 focus-visible:ring-offset-2";
1092
+ declare const studioQuestionOptionSelectedClass: string;
1093
+
1094
+ declare const buttonVariants: (props?: ({
1095
+ variant?: "default" | "outline" | "ghost" | "secondary" | "destructive" | "link" | null | undefined;
1096
+ size?: "default" | "xs" | "sm" | "lg" | "icon" | "icon-xs" | "icon-sm" | "icon-lg" | null | undefined;
1097
+ } & class_variance_authority_types.ClassProp) | undefined) => string;
1098
+ declare function Button({ className, variant, size, asChild, ...props }: React.ComponentProps<"button"> & VariantProps<typeof buttonVariants> & {
1099
+ asChild?: boolean;
1100
+ }): react_jsx_runtime.JSX.Element;
1101
+
133
1102
  declare function TooltipProvider({ delayDuration, ...props }: React.ComponentProps<typeof Tooltip$1.Provider>): react_jsx_runtime.JSX.Element;
134
1103
  declare function Tooltip({ ...props }: React.ComponentProps<typeof Tooltip$1.Root>): react_jsx_runtime.JSX.Element;
135
1104
  declare function TooltipTrigger({ ...props }: React.ComponentProps<typeof Tooltip$1.Trigger>): react_jsx_runtime.JSX.Element;
@@ -162,4 +1131,4 @@ declare const Shimmer: React.MemoExoticComponent<({ children, as: Component, cla
162
1131
 
163
1132
  declare function cn(...inputs: ClassValue[]): string;
164
1133
 
165
- export { AuthGuard, Avatar, AvatarFallback, AvatarImage, Button, ComposerAddAttachment, ComposerAttachments, Dialog, DialogClose, DialogContent, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, MarkdownText, SessionProvider, Shimmer, ShikiSyntaxHighlighter as SyntaxHighlighter, type TextShimmerProps, Thread, type ThreadComponents, type ThreadProps, type ThreadSuggestion, type ThreadWelcomeConfig, type ThreadWelcomeProps, TimbalChat, type TimbalChatProps, TimbalRuntimeProvider, type TimbalRuntimeProviderProps, ToolFallback, Tooltip, TooltipContent, TooltipIconButton, type TooltipIconButtonProps, TooltipProvider, TooltipTrigger, UserMessageAttachments, authFetch, buttonVariants, clearTokens, cn, fetchCurrentUser, getAccessToken, getRefreshToken, refreshAccessToken, setAccessToken, setRefreshToken, useSession };
1134
+ export { ARTIFACT_AGENT_INSTRUCTIONS, ARTIFACT_FENCE_LANGUAGES, type AnyArtifact, ArtifactCard, type ArtifactRegistry, ArtifactRegistryProvider, type ArtifactRenderer, type ArtifactRendererProps, ArtifactView, AuthGuard, Avatar, AvatarFallback, AvatarImage, Button, type ChartArtifact, ChartArtifactView, type ChatAttachment, type ChatMessage, Composer, ComposerAddAttachment, ComposerAttachments, type ComposerProps, type ContentPart, type CreateDefaultAttachmentAdapterOptions, type CreateUploadAttachmentAdapterOptions, DEFAULT_UPLOAD_ACCEPT, Dialog, DialogClose, DialogContent, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, type HtmlArtifact, HtmlArtifactView, type JsonArtifact, JsonArtifactView, type MarkdownArtifactMatch, type MarkdownSegment, MarkdownText, type QuestionArtifact, QuestionArtifactView, type QuestionOption, type ResolveAttachmentAdapterOptions, STUDIO_INSET_LEFT, STUDIO_PILL_HEIGHT, STUDIO_SIDEBAR_GAP, STUDIO_SIDEBAR_WIDTH, STUDIO_TOPBAR_GAP, STUDIO_TOPBAR_HEIGHT, type SendOptions, SessionProvider, Shimmer, Suggestions, type SuggestionsComponent, type SuggestionsSlotProps, type SuggestionsSource, ShikiSyntaxHighlighter as SyntaxHighlighter, TIMBAL_V2_BORDER, TIMBAL_V2_FILL, TIMBAL_V2_LABEL, TIMBAL_V2_PILL_SURFACE, TIMBAL_V2_SECONDARY_CHROME, TIMBAL_V2_SHADOW, TIMBAL_V2_SIZE_HEIGHT, TIMBAL_V2_SIZE_ICON, TIMBAL_V2_SIZE_LABEL_PX, type TableArtifact, TableArtifactView, type TextContentPart, type TextShimmerProps, type ThinkingContentPart, Thread, type ThreadArtifactsConfig, type ThreadComponents, type ThreadProps, type ThreadSuggestion, type ThreadSuggestionsProps, type ThreadWelcomeConfig, type ThreadWelcomeProps, type TimbalArtifact, type TimbalAttachmentsConfig, type TimbalAttachmentsProp, TimbalChat, type TimbalChatProps, TimbalChatShell, type TimbalChatShellProps, TimbalRuntimeProvider, type TimbalRuntimeProviderProps, type TimbalStreamApi, TimbalV2Button, type TimbalV2ButtonProps, type TimbalV2Size, type TimbalV2Variant, ToolArtifactFallback, ToolBodyPresence, type ToolCallContentPart, ToolFallback, ToolMotion, type ToolMotionVariant, ToolPresence, Tooltip, TooltipContent, TooltipIconButton, type TooltipIconButtonProps, TooltipProvider, TooltipTrigger, type UiAction, type UiArtifact, UiArtifactView, UiCustomNodeRegistryProvider, type UiEventEnvelope, UiEventProvider, type UiNode, UiNodeView, type UploadFetchFn, type UseTimbalStreamOptions, type UseWorkforcesOptions, type UseWorkforcesResult, UserMessageAttachments, WorkforceSelector, type WorkforceSelectorProps, authFetch, buttonVariants, clearTokens, cn, createDefaultAttachmentAdapter, createUploadAttachmentAdapter, defaultArtifactRenderers, fetchCurrentUser, findMarkdownArtifacts, getAccessToken, getPath, getRefreshToken, isArtifact, isArtifactFenceLanguage, isUiBinding, luxuryEase, parseArtifactFromToolResult, refreshAccessToken, resolveAttachmentAdapter, resolveBindable, setAccessToken, setPath, setRefreshToken, splitMarkdownByArtifacts, studioArtifactShellClass, studioChromeShellStyle, studioComposeInputShellClass, studioComposerIoWellClass, studioIntegrationBorder, studioIntegrationCardClass, studioIntegrationIconTileClass, studioIntegrationSurfaceSolid, studioListRowButtonClass, studioPillSurfaceClass, studioPlaygroundGradientClass, studioQuestionOptionClass, studioQuestionOptionSelectedClass, studioSecondaryChromeClass, studioTimelineActionClass, studioTimelineBodyPadClass, studioTimelineChevronClass, studioTimelineDetailClass, studioTimelineRowButtonClass, studioTimelineShimmerActionClass, studioTimelineTextClass, studioToolCardShellClass, studioTopbarIconPillClass, studioTopbarPillHeightClass, toolPresenceTransition, useArtifactRegistry, useResolvedSuggestions, useSession, useTimbalRuntime, useTimbalStream, useToolRunning, useUiCustomNodeRegistry, useUiDispatch, useUiEventEmitter, useUiState, useWorkforces };