@runtypelabs/persona 3.16.0 → 3.18.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/README.md +142 -0
- package/dist/animations/glyph-cycle.cjs +279 -0
- package/dist/animations/glyph-cycle.d.cts +5 -0
- package/dist/animations/glyph-cycle.d.ts +5 -0
- package/dist/animations/glyph-cycle.js +252 -0
- package/dist/animations/types-cwY5HaFD.d.cts +307 -0
- package/dist/animations/types-cwY5HaFD.d.ts +307 -0
- package/dist/animations/wipe.cjs +107 -0
- package/dist/animations/wipe.d.cts +5 -0
- package/dist/animations/wipe.d.ts +5 -0
- package/dist/animations/wipe.js +80 -0
- package/dist/index.cjs +49 -48
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +504 -1
- package/dist/index.d.ts +504 -1
- package/dist/index.global.js +143 -88
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +49 -48
- package/dist/index.js.map +1 -1
- package/dist/testing.cjs +85 -0
- package/dist/testing.d.cts +39 -0
- package/dist/testing.d.ts +39 -0
- package/dist/testing.js +56 -0
- package/dist/theme-editor.cjs +2095 -207
- package/dist/theme-editor.d.cts +432 -2
- package/dist/theme-editor.d.ts +432 -2
- package/dist/theme-editor.js +2093 -207
- package/dist/theme-reference.cjs +1 -1
- package/dist/theme-reference.d.cts +14 -0
- package/dist/theme-reference.d.ts +14 -0
- package/dist/widget.css +565 -0
- package/package.json +20 -3
- package/src/animations/glyph-cycle.ts +332 -0
- package/src/animations/wipe.ts +66 -0
- package/src/client.test.ts +275 -0
- package/src/client.ts +99 -0
- package/src/components/ask-user-question-bubble.test.ts +583 -0
- package/src/components/ask-user-question-bubble.ts +924 -0
- package/src/components/composer-builder.ts +61 -10
- package/src/components/message-bubble.test.ts +181 -2
- package/src/components/message-bubble.ts +209 -14
- package/src/components/messages.ts +33 -1
- package/src/components/panel.ts +45 -5
- package/src/defaults.ts +37 -0
- package/src/index-global.ts +31 -0
- package/src/index.ts +34 -1
- package/src/plugins/types.ts +57 -0
- package/src/session.test.ts +276 -1
- package/src/session.ts +247 -3
- package/src/styles/widget.css +565 -0
- package/src/testing/index.ts +11 -0
- package/src/testing/mock-stream.test.ts +80 -0
- package/src/testing/mock-stream.ts +94 -0
- package/src/testing.ts +2 -0
- package/src/theme-editor/index.ts +4 -0
- package/src/theme-editor/preview-utils.test.ts +60 -0
- package/src/theme-editor/preview-utils.ts +129 -0
- package/src/theme-editor/sections.test.ts +19 -0
- package/src/theme-editor/sections.ts +84 -1
- package/src/types/theme.ts +15 -0
- package/src/types.ts +360 -0
- package/src/ui.ask-user-question-plugin.test.ts +649 -0
- package/src/ui.stop-button.test.ts +165 -0
- package/src/ui.ts +706 -11
- package/src/utils/message-fingerprint.ts +2 -0
- package/src/utils/morph.ts +7 -0
- package/src/utils/storage.ts +10 -2
- package/src/utils/stream-animation.test.ts +417 -0
- package/src/utils/stream-animation.ts +449 -0
- package/src/utils/theme.test.ts +36 -0
- package/src/utils/tokens.ts +23 -0
package/dist/theme-editor.d.cts
CHANGED
|
@@ -217,6 +217,18 @@ interface MessageTokens {
|
|
|
217
217
|
/** Border color between messages in the thread. */
|
|
218
218
|
border?: TokenReference<'color'>;
|
|
219
219
|
}
|
|
220
|
+
/**
|
|
221
|
+
* Welcome / intro card rendered above the message list when no messages exist.
|
|
222
|
+
* Set `copy.showWelcomeCard: false` to hide it; use `layout.slots["body-top"]`
|
|
223
|
+
* to replace it wholesale.
|
|
224
|
+
*/
|
|
225
|
+
interface IntroCardTokens extends ComponentTokenSet {
|
|
226
|
+
background?: TokenReference<'color'>;
|
|
227
|
+
borderRadius?: TokenReference<'radius'>;
|
|
228
|
+
padding?: TokenReference<'spacing'>;
|
|
229
|
+
/** Box-shadow on the intro card (token ref or raw CSS, e.g. `none`). */
|
|
230
|
+
shadow?: string;
|
|
231
|
+
}
|
|
220
232
|
/** Collapsible widget chrome (tool bubbles, reasoning bubbles, approval bubbles). */
|
|
221
233
|
interface CollapsibleWidgetTokens {
|
|
222
234
|
/** Background for content areas. */
|
|
@@ -414,6 +426,8 @@ interface ComponentTokens {
|
|
|
414
426
|
panel: PanelTokens;
|
|
415
427
|
header: HeaderTokens;
|
|
416
428
|
message: MessageTokens;
|
|
429
|
+
/** Welcome / intro card shown above the message list. */
|
|
430
|
+
introCard?: IntroCardTokens;
|
|
417
431
|
/** Markdown surfaces (chat + artifact pane). */
|
|
418
432
|
markdown?: MarkdownTokens;
|
|
419
433
|
voice: VoiceTokens;
|
|
@@ -558,6 +572,61 @@ interface AgentWidgetPlugin {
|
|
|
558
572
|
defaultRenderer: () => HTMLElement;
|
|
559
573
|
config: AgentWidgetConfig;
|
|
560
574
|
}) => HTMLElement | null;
|
|
575
|
+
/**
|
|
576
|
+
* Custom renderer for `ask_user_question` tool calls.
|
|
577
|
+
*
|
|
578
|
+
* When a plugin returns an `HTMLElement`, it is inserted into the transcript
|
|
579
|
+
* in place of the default (which is no transcript bubble — the built-in
|
|
580
|
+
* renders a sheet over the composer). The built-in composer-overlay sheet
|
|
581
|
+
* is suppressed so the plugin's UI fully owns the interaction.
|
|
582
|
+
*
|
|
583
|
+
* Return `null` to fall through to the built-in overlay sheet.
|
|
584
|
+
*
|
|
585
|
+
* The context gives you a pre-parsed `payload` (may be partial while the
|
|
586
|
+
* tool call is still streaming — check `complete`) and two callbacks:
|
|
587
|
+
* `resolve(answer)` resumes the paused LOCAL tool with the user's answer,
|
|
588
|
+
* and `dismiss()` cancels with the sentinel `"(dismissed)"`.
|
|
589
|
+
*
|
|
590
|
+
* @example
|
|
591
|
+
* ```typescript
|
|
592
|
+
* renderAskUserQuestion: ({ payload, resolve, dismiss }) => {
|
|
593
|
+
* const prompt = payload.questions?.[0];
|
|
594
|
+
* if (!prompt) return null;
|
|
595
|
+
* const root = document.createElement("div");
|
|
596
|
+
* root.textContent = prompt.question ?? "";
|
|
597
|
+
* (prompt.options ?? []).forEach((option) => {
|
|
598
|
+
* const btn = document.createElement("button");
|
|
599
|
+
* btn.textContent = option.label;
|
|
600
|
+
* btn.addEventListener("click", () => resolve(option.label));
|
|
601
|
+
* root.appendChild(btn);
|
|
602
|
+
* });
|
|
603
|
+
* return root;
|
|
604
|
+
* }
|
|
605
|
+
* ```
|
|
606
|
+
*/
|
|
607
|
+
renderAskUserQuestion?: (context: {
|
|
608
|
+
message: AgentWidgetMessage;
|
|
609
|
+
/**
|
|
610
|
+
* Parsed `{ questions: [...] }` payload. May be partial while the tool
|
|
611
|
+
* call is still streaming; see `complete`. `null` when no payload has
|
|
612
|
+
* arrived yet.
|
|
613
|
+
*/
|
|
614
|
+
payload: Partial<AskUserQuestionPayload> | null;
|
|
615
|
+
/** `true` once the tool-call args have fully streamed in. */
|
|
616
|
+
complete: boolean;
|
|
617
|
+
/**
|
|
618
|
+
* Resume the paused LOCAL tool with the user's answer. Posts to the
|
|
619
|
+
* resume endpoint, pipes the SSE stream back into the session, and
|
|
620
|
+
* appends a user-visible answer bubble to the transcript.
|
|
621
|
+
*/
|
|
622
|
+
resolve: (answer: string) => void;
|
|
623
|
+
/**
|
|
624
|
+
* Cancel the question. Resumes with the sentinel `"(dismissed)"` so the
|
|
625
|
+
* server doesn't sit in `waiting_for_local` forever. Idempotent.
|
|
626
|
+
*/
|
|
627
|
+
dismiss: () => void;
|
|
628
|
+
config: AgentWidgetConfig;
|
|
629
|
+
}) => HTMLElement | null;
|
|
561
630
|
/**
|
|
562
631
|
* Custom renderer for approval bubbles
|
|
563
632
|
* Return null to use default renderer
|
|
@@ -778,6 +847,31 @@ type AgentMessageMetadata = {
|
|
|
778
847
|
* or `prompt` step inside the nested flow). Stable key for that step.
|
|
779
848
|
*/
|
|
780
849
|
parentStepId?: string;
|
|
850
|
+
/**
|
|
851
|
+
* Set to `true` on a tool-variant message produced from a `step_await`
|
|
852
|
+
* event (`awaitReason: "local_tool_required"`). Signals to UI code that
|
|
853
|
+
* the tool call is a LOCAL tool and the server is paused waiting for a
|
|
854
|
+
* `POST /v1/dispatch/resume` with the user's answer keyed by tool name.
|
|
855
|
+
*/
|
|
856
|
+
awaitingLocalTool?: boolean;
|
|
857
|
+
/**
|
|
858
|
+
* Set to `true` once the user has picked / typed / dismissed an answer for
|
|
859
|
+
* an `ask_user_question` tool call, so renderers stop re-mounting the
|
|
860
|
+
* answer-pill sheet for this tool call on subsequent render passes.
|
|
861
|
+
*/
|
|
862
|
+
askUserQuestionAnswered?: boolean;
|
|
863
|
+
/**
|
|
864
|
+
* In-progress answers for a multi-question `ask_user_question` payload,
|
|
865
|
+
* keyed by question text. Persisted across refresh so the user lands back
|
|
866
|
+
* where they were if the page reloads mid-flow. Cleared once
|
|
867
|
+
* `askUserQuestionAnswered` flips to `true`.
|
|
868
|
+
*/
|
|
869
|
+
askUserQuestionAnswers?: Record<string, string | string[]>;
|
|
870
|
+
/**
|
|
871
|
+
* Current page index for a multi-question `ask_user_question` payload's
|
|
872
|
+
* paginated stepper. Persists alongside `askUserQuestionAnswers`.
|
|
873
|
+
*/
|
|
874
|
+
askUserQuestionIndex?: number;
|
|
781
875
|
};
|
|
782
876
|
type AgentWidgetRequestMiddlewareContext = {
|
|
783
877
|
payload: AgentWidgetRequestPayload;
|
|
@@ -825,6 +919,8 @@ type AgentWidgetActionHandler = (action: AgentWidgetParsedAction, context: Agent
|
|
|
825
919
|
type AgentWidgetStoredState = {
|
|
826
920
|
messages?: AgentWidgetMessage[];
|
|
827
921
|
metadata?: Record<string, unknown>;
|
|
922
|
+
artifacts?: PersonaArtifactRecord[];
|
|
923
|
+
selectedArtifactId?: string | null;
|
|
828
924
|
};
|
|
829
925
|
interface AgentWidgetStorageAdapter {
|
|
830
926
|
load?: () => AgentWidgetStoredState | null | Promise<AgentWidgetStoredState | null>;
|
|
@@ -1221,6 +1317,151 @@ type AgentWidgetReasoningDisplayFeature = {
|
|
|
1221
1317
|
*/
|
|
1222
1318
|
loadingAnimation?: AgentWidgetToolCallLoadingAnimation;
|
|
1223
1319
|
};
|
|
1320
|
+
/**
|
|
1321
|
+
* Reveal animation applied to assistant message text while it is streaming.
|
|
1322
|
+
*
|
|
1323
|
+
* Built-in types always available:
|
|
1324
|
+
* - `none` — text appears as tokens arrive (default).
|
|
1325
|
+
* - `typewriter` — characters fade in with a blinking caret.
|
|
1326
|
+
* - `pop-bubble` — the bubble scales in; text streams normally afterward.
|
|
1327
|
+
* - `letter-rise` — per-char translateY + fade reveal.
|
|
1328
|
+
* - `word-fade` — per-word blur + translateY fade-in.
|
|
1329
|
+
*
|
|
1330
|
+
* Subpath plugins (import from `@runtypelabs/persona/animations/*` to register):
|
|
1331
|
+
* - `wipe`, `glyph-cycle`.
|
|
1332
|
+
*
|
|
1333
|
+
* Custom types are allowed — register a plugin with any string name and
|
|
1334
|
+
* reference it by that name in `type`.
|
|
1335
|
+
*/
|
|
1336
|
+
type AgentWidgetStreamAnimationBuiltinType = "none" | "typewriter" | "word-fade" | "letter-rise" | "glyph-cycle" | "wipe" | "pop-bubble";
|
|
1337
|
+
type AgentWidgetStreamAnimationType = AgentWidgetStreamAnimationBuiltinType | (string & {});
|
|
1338
|
+
/**
|
|
1339
|
+
* Placeholder shown inside a streaming assistant bubble before the first token arrives.
|
|
1340
|
+
* - `none` — use the default typing-dots indicator (existing behavior).
|
|
1341
|
+
* - `skeleton` — shimmer bars, replaced by streaming content once it starts.
|
|
1342
|
+
*/
|
|
1343
|
+
type AgentWidgetStreamAnimationPlaceholder = "none" | "skeleton";
|
|
1344
|
+
/**
|
|
1345
|
+
* How much of the accumulated streaming content to display while tokens are
|
|
1346
|
+
* still arriving. Trimming to a boundary means in-progress words or lines
|
|
1347
|
+
* stay hidden until they complete — useful for animations that benefit from
|
|
1348
|
+
* unit-complete reveals (e.g. wipe, glyph-cycle).
|
|
1349
|
+
* - `none` — show every character as it arrives (default).
|
|
1350
|
+
* - `word` — trim to the last whitespace boundary.
|
|
1351
|
+
* - `line` — trim to the last newline boundary.
|
|
1352
|
+
*/
|
|
1353
|
+
type AgentWidgetStreamAnimationBuffer = "none" | "word" | "line";
|
|
1354
|
+
/**
|
|
1355
|
+
* Context passed to plugin lifecycle hooks. Carries the live DOM references
|
|
1356
|
+
* and resolved animation settings for the currently-streaming message.
|
|
1357
|
+
*/
|
|
1358
|
+
type StreamAnimationContext = {
|
|
1359
|
+
/** The `.persona-message-content` element owning the streamed text. */
|
|
1360
|
+
container: HTMLElement;
|
|
1361
|
+
/** The outer message bubble element. */
|
|
1362
|
+
bubble: HTMLElement;
|
|
1363
|
+
/** ID of the streaming message. */
|
|
1364
|
+
messageId: string;
|
|
1365
|
+
/** Read-only reference to the message being streamed. */
|
|
1366
|
+
message: AgentWidgetMessage;
|
|
1367
|
+
/** Effective `speed` from `streamAnimation.speed`. */
|
|
1368
|
+
speed: number;
|
|
1369
|
+
/** Effective `duration` from `streamAnimation.duration`. */
|
|
1370
|
+
duration: number;
|
|
1371
|
+
};
|
|
1372
|
+
/**
|
|
1373
|
+
* Pluggable stream animation. Third-party packages and inline registrations
|
|
1374
|
+
* implement this interface to add custom reveal effects.
|
|
1375
|
+
*
|
|
1376
|
+
* Lifecycle:
|
|
1377
|
+
* - When the widget mounts and detects a plugin (either passed via config or
|
|
1378
|
+
* auto-registered in the IIFE bundle), it injects `styles` once into the
|
|
1379
|
+
* widget's style host.
|
|
1380
|
+
* - For each streaming assistant message whose `type` matches `name`, the
|
|
1381
|
+
* widget applies `containerClass` / `bubbleClass`, wraps text per `wrap`,
|
|
1382
|
+
* and — if `useCaret` is true — appends a blinking caret.
|
|
1383
|
+
* - Hooks fire after the live DOM is morphed; plugins use stable element IDs
|
|
1384
|
+
* and `data-preserve-animation` to safely mutate per-char or per-word spans
|
|
1385
|
+
* without idiomorph clobbering in-flight work.
|
|
1386
|
+
*/
|
|
1387
|
+
type StreamAnimationPlugin = {
|
|
1388
|
+
/** Plugin identifier. Matches the `type` field in `streamAnimation`. */
|
|
1389
|
+
name: string;
|
|
1390
|
+
/** Class added to `.persona-message-content` while streaming. */
|
|
1391
|
+
containerClass?: string;
|
|
1392
|
+
/** Class added to the bubble element (e.g. a one-shot scale animation). */
|
|
1393
|
+
bubbleClass?: string;
|
|
1394
|
+
/** Wrap mode applied to text nodes during streaming. @default "none" */
|
|
1395
|
+
wrap?: "none" | "char" | "word";
|
|
1396
|
+
/**
|
|
1397
|
+
* HTML tags whose descendant text is skipped during wrapping. Defaults to
|
|
1398
|
+
* `["pre", "code", "a", "script", "style"]` — useful for keeping code
|
|
1399
|
+
* blocks legible and link click-targets intact. Plugins that want to
|
|
1400
|
+
* animate characters inside inline code (e.g. `glyph-cycle`) can narrow
|
|
1401
|
+
* the list.
|
|
1402
|
+
*/
|
|
1403
|
+
skipTags?: string[];
|
|
1404
|
+
/** Append a blinking caret after the last rendered char/word. */
|
|
1405
|
+
useCaret?: boolean;
|
|
1406
|
+
/** CSS string injected into the widget style host on first activation. */
|
|
1407
|
+
styles?: string;
|
|
1408
|
+
/**
|
|
1409
|
+
* Optional custom buffering strategy. Returns the portion of `content`
|
|
1410
|
+
* that should be rendered during streaming. Use this for buffering
|
|
1411
|
+
* schemes beyond the built-in `word` / `line` strategies.
|
|
1412
|
+
*/
|
|
1413
|
+
bufferContent?: (content: string, message: AgentWidgetMessage) => string;
|
|
1414
|
+
/**
|
|
1415
|
+
* Fires once when the plugin is first activated inside a widget instance.
|
|
1416
|
+
* Use this to set up MutationObservers or other long-lived listeners.
|
|
1417
|
+
* Return an optional cleanup function that runs on widget destroy.
|
|
1418
|
+
*/
|
|
1419
|
+
onAttach?: (root: HTMLElement | ShadowRoot) => (() => void) | void;
|
|
1420
|
+
/** Fires after each render that reaches the live DOM. */
|
|
1421
|
+
onAfterRender?: (ctx: StreamAnimationContext) => void;
|
|
1422
|
+
/** Fires when a streamed message's `streaming` flag flips to false. */
|
|
1423
|
+
onStreamComplete?: (ctx: StreamAnimationContext) => void;
|
|
1424
|
+
/**
|
|
1425
|
+
* Report whether the plugin still has in-flight animation work for a
|
|
1426
|
+
* message. When `true`, the widget keeps rendering the message in its
|
|
1427
|
+
* "streaming-animated" mode even after `message.streaming` flips false —
|
|
1428
|
+
* preventing the final non-animated render from yanking the rug out from
|
|
1429
|
+
* under unfinished per-char cycles or reveals.
|
|
1430
|
+
*/
|
|
1431
|
+
isAnimating?: (message: AgentWidgetMessage) => boolean;
|
|
1432
|
+
};
|
|
1433
|
+
type AgentWidgetStreamAnimationFeature = {
|
|
1434
|
+
/** Reveal animation to apply while streaming. @default "none" */
|
|
1435
|
+
type?: AgentWidgetStreamAnimationType;
|
|
1436
|
+
/** Pre-first-token placeholder. @default "none" */
|
|
1437
|
+
placeholder?: AgentWidgetStreamAnimationPlaceholder;
|
|
1438
|
+
/**
|
|
1439
|
+
* Per-unit animation duration (ms) for `typewriter`, `letter-rise`, `word-fade`,
|
|
1440
|
+
* and per-unit plugin animations. Each arriving character/word animates from
|
|
1441
|
+
* invisible to visible over this duration, independent of its position — the
|
|
1442
|
+
* streaming cadence itself provides the visible stagger.
|
|
1443
|
+
* @default 120
|
|
1444
|
+
*/
|
|
1445
|
+
speed?: number;
|
|
1446
|
+
/**
|
|
1447
|
+
* Total duration of container-level animations (`pop-bubble` and custom
|
|
1448
|
+
* plugin animations), in milliseconds.
|
|
1449
|
+
* @default 1800
|
|
1450
|
+
*/
|
|
1451
|
+
duration?: number;
|
|
1452
|
+
/**
|
|
1453
|
+
* Trim the accumulated streaming content to a word or line boundary before
|
|
1454
|
+
* rendering. Hides in-progress units until they complete.
|
|
1455
|
+
* @default "none"
|
|
1456
|
+
*/
|
|
1457
|
+
buffer?: AgentWidgetStreamAnimationBuffer;
|
|
1458
|
+
/**
|
|
1459
|
+
* Extra animation plugins available to this widget instance. Keys are
|
|
1460
|
+
* plugin names; the matching plugin activates when `type` is set to that
|
|
1461
|
+
* name. Built-in types (`typewriter`, `pop-bubble`) are always registered.
|
|
1462
|
+
*/
|
|
1463
|
+
plugins?: Record<string, StreamAnimationPlugin>;
|
|
1464
|
+
};
|
|
1224
1465
|
type AgentWidgetFeatureFlags = {
|
|
1225
1466
|
showReasoning?: boolean;
|
|
1226
1467
|
showToolCalls?: boolean;
|
|
@@ -1235,6 +1476,115 @@ type AgentWidgetFeatureFlags = {
|
|
|
1235
1476
|
eventStream?: EventStreamConfig;
|
|
1236
1477
|
/** Optional artifact sidebar (split pane / mobile drawer) */
|
|
1237
1478
|
artifacts?: AgentWidgetArtifactsFeature;
|
|
1479
|
+
/** Reveal animation for streaming assistant text. */
|
|
1480
|
+
streamAnimation?: AgentWidgetStreamAnimationFeature;
|
|
1481
|
+
/**
|
|
1482
|
+
* Built-in interactive answer-pill sheet shown when the assistant invokes
|
|
1483
|
+
* the `ask_user_question` tool. Slides up over the composer with tappable
|
|
1484
|
+
* pills + optional free-text input.
|
|
1485
|
+
*/
|
|
1486
|
+
askUserQuestion?: AgentWidgetAskUserQuestionFeature;
|
|
1487
|
+
};
|
|
1488
|
+
/**
|
|
1489
|
+
* Single selectable option in an `ask_user_question` prompt.
|
|
1490
|
+
* Mirrors Anthropic's AskUserQuestion schema.
|
|
1491
|
+
*/
|
|
1492
|
+
type AskUserQuestionOption = {
|
|
1493
|
+
/** Pill label (required). */
|
|
1494
|
+
label: string;
|
|
1495
|
+
/** Optional long-form description (shown as a subtitle on tap-hover). */
|
|
1496
|
+
description?: string;
|
|
1497
|
+
/** Optional rich preview — reserved for future rendering; ignored in v1. */
|
|
1498
|
+
preview?: string;
|
|
1499
|
+
};
|
|
1500
|
+
/**
|
|
1501
|
+
* A single question in an `ask_user_question` tool call.
|
|
1502
|
+
* The tool may carry 1–8 prompts. When more than one is supplied, the built-in
|
|
1503
|
+
* renderer paginates them as a "Question N of M" stepper with Back / Next /
|
|
1504
|
+
* Submit-all controls; single-question payloads render without stepper chrome.
|
|
1505
|
+
*/
|
|
1506
|
+
type AskUserQuestionPrompt = {
|
|
1507
|
+
/** The question text shown to the user. */
|
|
1508
|
+
question: string;
|
|
1509
|
+
/** Optional short header label (≤12 chars) used as a compact group title. */
|
|
1510
|
+
header?: string;
|
|
1511
|
+
/** 2–4 selectable options. */
|
|
1512
|
+
options: AskUserQuestionOption[];
|
|
1513
|
+
/** When true, the user can pick multiple options and submit together. Default false. */
|
|
1514
|
+
multiSelect?: boolean;
|
|
1515
|
+
/** When true, a free-text "Other…" pill expands to an input. Default true. */
|
|
1516
|
+
allowFreeText?: boolean;
|
|
1517
|
+
};
|
|
1518
|
+
/** Parsed payload of an `ask_user_question` tool call. */
|
|
1519
|
+
type AskUserQuestionPayload = {
|
|
1520
|
+
/** 1–8 questions. Anything beyond the renderer's cap is truncated with a console warning. */
|
|
1521
|
+
questions: AskUserQuestionPrompt[];
|
|
1522
|
+
};
|
|
1523
|
+
/**
|
|
1524
|
+
* Style overrides for the answer-pill sheet. All values are raw CSS strings
|
|
1525
|
+
* and are plumbed through as CSS custom properties on the sheet root.
|
|
1526
|
+
*/
|
|
1527
|
+
type AgentWidgetAskUserQuestionStyles = {
|
|
1528
|
+
sheetBackground?: string;
|
|
1529
|
+
sheetBorder?: string;
|
|
1530
|
+
sheetShadow?: string;
|
|
1531
|
+
pillBackground?: string;
|
|
1532
|
+
pillBackgroundSelected?: string;
|
|
1533
|
+
pillTextColor?: string;
|
|
1534
|
+
pillTextColorSelected?: string;
|
|
1535
|
+
pillBorderRadius?: string;
|
|
1536
|
+
customInputBackground?: string;
|
|
1537
|
+
};
|
|
1538
|
+
/**
|
|
1539
|
+
* Feature config for the built-in `ask_user_question` answer-pill sheet.
|
|
1540
|
+
* When a tool call with the name `ask_user_question` arrives, the widget
|
|
1541
|
+
* renders an interactive sheet over the composer in place of the generic
|
|
1542
|
+
* tool bubble.
|
|
1543
|
+
*/
|
|
1544
|
+
type AgentWidgetAskUserQuestionFeature = {
|
|
1545
|
+
/** Enable the feature. Defaults to true. When false, `ask_user_question` renders as a regular tool bubble. */
|
|
1546
|
+
enabled?: boolean;
|
|
1547
|
+
/** Slide-in animation duration in ms. Defaults to 180. */
|
|
1548
|
+
slideInMs?: number;
|
|
1549
|
+
/** Label for the free-text pill. Defaults to "Other…". */
|
|
1550
|
+
freeTextLabel?: string;
|
|
1551
|
+
/** Placeholder text in the free-text input. Defaults to "Type your answer…". */
|
|
1552
|
+
freeTextPlaceholder?: string;
|
|
1553
|
+
/** Button label for submitting multi-select / free-text answers. Defaults to "Send". */
|
|
1554
|
+
submitLabel?: string;
|
|
1555
|
+
/** Button label advancing to the next question in grouped (paginated) payloads. Defaults to "Next". */
|
|
1556
|
+
nextLabel?: string;
|
|
1557
|
+
/** Button label moving back to the previous question in grouped payloads. Defaults to "Back". */
|
|
1558
|
+
backLabel?: string;
|
|
1559
|
+
/** Button label submitting all answers from the final page of a grouped payload. Defaults to "Submit all". */
|
|
1560
|
+
submitAllLabel?: string;
|
|
1561
|
+
/**
|
|
1562
|
+
* In grouped (multi-question) mode, auto-advance to the next page after a
|
|
1563
|
+
* single-select pill pick or free-text submit on intermediate pages.
|
|
1564
|
+
* Defaults to `true`. The final page never auto-submits — users always
|
|
1565
|
+
* confirm with an explicit "Submit all" click. Multi-select pages always
|
|
1566
|
+
* require an explicit Next regardless of this setting.
|
|
1567
|
+
*/
|
|
1568
|
+
groupedAutoAdvance?: boolean;
|
|
1569
|
+
/**
|
|
1570
|
+
* Visual layout for the option list.
|
|
1571
|
+
* - `"rows"` (default) — full-width stacked rows with always-visible
|
|
1572
|
+
* descriptions, right-edge number badges (single-select) or checkboxes
|
|
1573
|
+
* (multi-select), and an always-visible inline "Other" input.
|
|
1574
|
+
* - `"pills"` — legacy compact pill list with horizontal wrap; description
|
|
1575
|
+
* surfaces as a tooltip and the "Other…" pill expands on click.
|
|
1576
|
+
*/
|
|
1577
|
+
layout?: "rows" | "pills";
|
|
1578
|
+
/**
|
|
1579
|
+
* Button label for skipping the current question in grouped payloads.
|
|
1580
|
+
* Defaults to "Skip". On intermediate pages Skip advances without recording
|
|
1581
|
+
* an answer; on the final page Skip submits the partial answer record
|
|
1582
|
+
* (skipped questions absent from the resolved object). For single-question
|
|
1583
|
+
* payloads Skip behaves like dismiss.
|
|
1584
|
+
*/
|
|
1585
|
+
skipLabel?: string;
|
|
1586
|
+
/** Style overrides for the sheet and pills. */
|
|
1587
|
+
styles?: AgentWidgetAskUserQuestionStyles;
|
|
1238
1588
|
};
|
|
1239
1589
|
type SSEEventRecord = {
|
|
1240
1590
|
id: string;
|
|
@@ -1523,6 +1873,10 @@ type AgentWidgetSendButtonConfig = {
|
|
|
1523
1873
|
backgroundColor?: string;
|
|
1524
1874
|
textColor?: string;
|
|
1525
1875
|
size?: string;
|
|
1876
|
+
/** Lucide icon name shown while a response is streaming. Clicking the button in this state aborts the stream. Default: "square". */
|
|
1877
|
+
stopIconName?: string;
|
|
1878
|
+
/** Tooltip text shown while streaming. Default: "Stop generating". */
|
|
1879
|
+
stopTooltipText?: string;
|
|
1526
1880
|
};
|
|
1527
1881
|
/** Optional composer UI state for custom `renderComposer` implementations. */
|
|
1528
1882
|
type AgentWidgetComposerConfig = {
|
|
@@ -2922,11 +3276,21 @@ type AgentWidgetConfig = {
|
|
|
2922
3276
|
welcomeSubtitle?: string;
|
|
2923
3277
|
inputPlaceholder?: string;
|
|
2924
3278
|
sendButtonLabel?: string;
|
|
3279
|
+
/** Button label shown in text mode while a response is streaming. Default: "Stop". */
|
|
3280
|
+
stopButtonLabel?: string;
|
|
2925
3281
|
/**
|
|
2926
3282
|
* When false, the welcome / intro card is not shown above the message list.
|
|
2927
3283
|
* @default true
|
|
2928
3284
|
*/
|
|
2929
3285
|
showWelcomeCard?: boolean;
|
|
3286
|
+
/**
|
|
3287
|
+
* Per-stop-reason copy for the inline notice rendered on assistant
|
|
3288
|
+
* bubbles when the runtime reports a non-natural stop (e.g. the agent
|
|
3289
|
+
* loop hit `max_tool_calls` and was cut off mid-loop). Each key is
|
|
3290
|
+
* optional — keys you omit fall back to the built-in defaults. Set a
|
|
3291
|
+
* key to an empty string to suppress the notice for that reason.
|
|
3292
|
+
*/
|
|
3293
|
+
stopReasonNotice?: Partial<Record<StopReasonKind, string>>;
|
|
2930
3294
|
};
|
|
2931
3295
|
/**
|
|
2932
3296
|
* Semantic design tokens (`palette`, `semantic`, `components`).
|
|
@@ -2960,6 +3324,17 @@ type AgentWidgetConfig = {
|
|
|
2960
3324
|
autoFocusInput?: boolean;
|
|
2961
3325
|
launcher?: AgentWidgetLauncherConfig;
|
|
2962
3326
|
initialMessages?: AgentWidgetMessage[];
|
|
3327
|
+
/**
|
|
3328
|
+
* Artifacts to hydrate into the pane at init. Typically populated from
|
|
3329
|
+
* `storageAdapter.load()` alongside `initialMessages` so the artifact pane
|
|
3330
|
+
* survives a page refresh.
|
|
3331
|
+
*/
|
|
3332
|
+
initialArtifacts?: PersonaArtifactRecord[];
|
|
3333
|
+
/**
|
|
3334
|
+
* Which artifact id (if any) should be selected in the pane at init. Paired
|
|
3335
|
+
* with `initialArtifacts`.
|
|
3336
|
+
*/
|
|
3337
|
+
initialSelectedArtifactId?: string | null;
|
|
2963
3338
|
suggestionChips?: string[];
|
|
2964
3339
|
suggestionChipsConfig?: AgentWidgetSuggestionChipsConfig;
|
|
2965
3340
|
debug?: boolean;
|
|
@@ -3424,6 +3799,21 @@ type AgentWidgetApproval = {
|
|
|
3424
3799
|
resolvedAt?: number;
|
|
3425
3800
|
};
|
|
3426
3801
|
type AgentWidgetMessageVariant = "assistant" | "reasoning" | "tool" | "approval";
|
|
3802
|
+
/**
|
|
3803
|
+
* Per-turn / per-step stop reason emitted by the runtime on
|
|
3804
|
+
* `agent_turn_complete` and `step_complete` SSE events. The vocabulary is
|
|
3805
|
+
* owned by the upstream Runtype API — do not extend without coordination.
|
|
3806
|
+
*
|
|
3807
|
+
* - `end_turn` — natural completion (no affordance needed)
|
|
3808
|
+
* - `max_tool_calls` — agent loop tripped the configured tool-call ceiling
|
|
3809
|
+
* - `length` — provider hit max output tokens
|
|
3810
|
+
* - `content_filter` — provider content filter intervened
|
|
3811
|
+
* - `error` — provider/runtime error (prefer existing error rendering)
|
|
3812
|
+
* - `unknown` — explicitly reported but uninformative
|
|
3813
|
+
*
|
|
3814
|
+
* Absent (`undefined`) means "not reported" — distinct from `'unknown'`.
|
|
3815
|
+
*/
|
|
3816
|
+
type StopReasonKind = 'end_turn' | 'max_tool_calls' | 'length' | 'content_filter' | 'error' | 'unknown';
|
|
3427
3817
|
/**
|
|
3428
3818
|
* Represents a message in the chat conversation.
|
|
3429
3819
|
*
|
|
@@ -3510,6 +3900,17 @@ type AgentWidgetMessage = {
|
|
|
3510
3900
|
* Contains execution context like iteration number and turn ID.
|
|
3511
3901
|
*/
|
|
3512
3902
|
agentMetadata?: AgentMessageMetadata;
|
|
3903
|
+
/**
|
|
3904
|
+
* Per-turn stop reason reported by the runtime on `agent_turn_complete`
|
|
3905
|
+
* (agent-loop path) or the last `step_complete` for a prompt step
|
|
3906
|
+
* (dispatch / flow path). Absent when the API did not report a value.
|
|
3907
|
+
*
|
|
3908
|
+
* When set to a non-natural value (`max_tool_calls`, `length`,
|
|
3909
|
+
* `content_filter`, `error`), the widget renders an inline notice on
|
|
3910
|
+
* the assistant bubble. See `config.copy.stopReasonNotice` to override
|
|
3911
|
+
* the default copy.
|
|
3912
|
+
*/
|
|
3913
|
+
stopReason?: StopReasonKind;
|
|
3513
3914
|
};
|
|
3514
3915
|
/**
|
|
3515
3916
|
* Options for injecting a message into the conversation.
|
|
@@ -4004,6 +4405,10 @@ type Controller = {
|
|
|
4004
4405
|
upsertArtifact: (manual: PersonaArtifactManualUpsert) => PersonaArtifactRecord | null;
|
|
4005
4406
|
selectArtifact: (id: string) => void;
|
|
4006
4407
|
clearArtifacts: () => void;
|
|
4408
|
+
/** Read current artifacts (useful on init to rebuild host-side tab state after hydration). */
|
|
4409
|
+
getArtifacts: () => PersonaArtifactRecord[];
|
|
4410
|
+
/** Read the currently selected artifact id (paired with `getArtifacts`). */
|
|
4411
|
+
getSelectedArtifactId: () => string | null;
|
|
4007
4412
|
/**
|
|
4008
4413
|
* Focus the chat input. Returns true if focus succeeded, false if panel is closed
|
|
4009
4414
|
* (launcher mode) or textarea is unavailable.
|
|
@@ -4061,10 +4466,35 @@ declare const MOCK_WORKSPACE_CONTENT = "\n <div class=\"preview-workspace-con
|
|
|
4061
4466
|
*/
|
|
4062
4467
|
declare function buildSrcdoc(mountId: string, shellMode: 'light' | 'dark', docked: boolean, widgetCssPath: string): string;
|
|
4063
4468
|
type PreviewScene = 'home' | 'conversation' | 'minimized' | 'artifact';
|
|
4064
|
-
type PreviewTranscriptEntryPreset = 'user-message' | 'assistant-message' | 'reasoning-streaming' | 'reasoning-complete' | 'tool-running' | 'tool-complete';
|
|
4469
|
+
type PreviewTranscriptEntryPreset = 'user-message' | 'assistant-message' | 'assistant-code-block' | 'assistant-markdown-table' | 'assistant-image' | 'reasoning-streaming' | 'reasoning-complete' | 'tool-running' | 'tool-complete';
|
|
4065
4470
|
declare function getPreviewTranscriptPresetLabel(preset: PreviewTranscriptEntryPreset): string;
|
|
4066
4471
|
declare function createPreviewTranscriptEntry(preset: PreviewTranscriptEntryPreset, index?: number): AgentWidgetMessage;
|
|
4067
4472
|
declare function appendPreviewTranscriptEntry(messages: AgentWidgetMessage[], preset: PreviewTranscriptEntryPreset): AgentWidgetMessage[];
|
|
4473
|
+
/** Presets whose assistant content should stream in so Stream Animation settings engage. */
|
|
4474
|
+
declare function presetStreamsText(preset: PreviewTranscriptEntryPreset): boolean;
|
|
4475
|
+
interface TranscriptStreamFrame {
|
|
4476
|
+
/** Message to upsert into the session. */
|
|
4477
|
+
message: AgentWidgetMessage;
|
|
4478
|
+
/** Delay from the previous frame in ms. The first frame uses 0. */
|
|
4479
|
+
delayMs: number;
|
|
4480
|
+
/** True when this is the final frame (message is no longer streaming). */
|
|
4481
|
+
done: boolean;
|
|
4482
|
+
}
|
|
4483
|
+
interface BuildTranscriptStreamFramesOptions {
|
|
4484
|
+
/** Characters per progressive chunk. Default: 24. */
|
|
4485
|
+
chunkSize?: number;
|
|
4486
|
+
/** Delay between chunks in ms. Default: 42. */
|
|
4487
|
+
delayMs?: number;
|
|
4488
|
+
}
|
|
4489
|
+
/**
|
|
4490
|
+
* Builds progressive snapshots for a transcript preset suitable for feeding into
|
|
4491
|
+
* `injectTestMessage({ type: 'message', message })` on a timer. Each frame upserts
|
|
4492
|
+
* the same message id with more content, ending with `streaming: false`.
|
|
4493
|
+
*
|
|
4494
|
+
* - Streaming-capable presets (assistant text) yield many frames.
|
|
4495
|
+
* - All other presets yield a single `done` frame matching `createPreviewTranscriptEntry`.
|
|
4496
|
+
*/
|
|
4497
|
+
declare function buildTranscriptStreamFrames(preset: PreviewTranscriptEntryPreset, suffix: number, options?: BuildTranscriptStreamFramesOptions): TranscriptStreamFrame[];
|
|
4068
4498
|
declare function createPreviewMessages(scene: PreviewScene, config?: Partial<AgentWidgetConfig>, appendedMessages?: AgentWidgetMessage[]): AgentWidgetMessage[];
|
|
4069
4499
|
declare function applySceneConfig(base: AgentWidgetConfig, scene: PreviewScene, appendedMessages?: AgentWidgetMessage[]): AgentWidgetConfig;
|
|
4070
4500
|
|
|
@@ -4241,4 +4671,4 @@ declare function paletteColorPath(family: string, shade: string): string;
|
|
|
4241
4671
|
declare function resolveThemeColorPath(get: (path: string) => unknown, path: string, depth?: number): string;
|
|
4242
4672
|
declare function tokenRefDisplayName(path: string): string;
|
|
4243
4673
|
|
|
4244
|
-
export { ADVANCED_TOKENS_SECTION, ALL_ROLES, ALL_TABS, BRAND_PALETTE_SECTION, BUILT_IN_PRESETS, COLORS_SECTIONS, COLOR_FAMILIES, COMPONENTS_SECTIONS, COMPONENT_COLOR_SECTIONS, COMPONENT_SHAPE_SECTIONS, CONFIGURE_SECTIONS, CONFIGURE_SUB_GROUPS, type ColorScaleOptions, type CompareMode, type ConfigChangeListener, type ConfiguratorSnapshot, DEVICE_DIMENSIONS, type DetectedRoleAssignment, type FieldDef, type FieldType, HOME_SUGGESTION_CHIPS, INTERFACE_ROLES_SECTION, MOCK_BROWSER_CONTENT, MOCK_WORKSPACE_CONTENT, type OnChangeCallback, PALETTE_SECTION, PREVIEW_STORAGE_ADAPTER, type PreviewConfigOptions, type PreviewDevice, type PreviewLifecycleContext, type PreviewScene, type PreviewShellMode, type PreviewShellPalette, type PreviewTranscriptEntryPreset, ROLE_ASSISTANT_MESSAGES, ROLE_BORDERS, ROLE_FAMILIES, ROLE_FAMILY_LABELS, ROLE_HEADER, ROLE_INPUT, ROLE_INTENSITIES, ROLE_LINKS_FOCUS, ROLE_PRIMARY_ACTIONS, ROLE_SCROLL_TO_BOTTOM, ROLE_SURFACES, ROLE_USER_MESSAGES, type RoleAssignmentOptions, type RoleFamily, type RoleIntensity, type RoleTarget, type RoleTargetKind, SEMANTIC_COLORS_SECTION, SHADE_KEYS, SHELL_STYLE_ID, STATUS_COLORS_SECTION, STATUS_PALETTE_SECTION, STYLE_SECTIONS, STYLE_SECTIONS_V2, type SectionDef, type SectionPreset, type SelectOption, type SliderOptions, type SubGroupDef, THEME_EDITOR_PRESETS, THEME_SECTION, type TabDef, type ThemeEditorPreset, ThemeEditorState, type ThemePreviewHandle, type ThemePreviewOptions, type TokenRefOptions, ZOOM_MAX, ZOOM_MIN, appendPreviewTranscriptEntry, applySceneConfig, applyShellTheme, buildPreviewConfig, buildPreviewConfigWithMessages, buildShellCss, buildSrcdoc, convertFromPx, convertToPx, createPreviewMessages, createPreviewTranscriptEntry, createThemePreview, detectRoleAssignment, escapeHtml, findSection, formatCssValue, generateColorScale, getPreviewTranscriptPresetLabel, getShellPalette, getThemeEditorPreset, hexToHsl, hslToHex, isValidHex, normalizeColorValue, paletteColorPath, parseCssValue, resolveRoleAssignment, resolveThemeColorPath, scopeSection, tokenRefDisplayName, wcagContrastRatio };
|
|
4674
|
+
export { ADVANCED_TOKENS_SECTION, ALL_ROLES, ALL_TABS, BRAND_PALETTE_SECTION, BUILT_IN_PRESETS, type BuildTranscriptStreamFramesOptions, COLORS_SECTIONS, COLOR_FAMILIES, COMPONENTS_SECTIONS, COMPONENT_COLOR_SECTIONS, COMPONENT_SHAPE_SECTIONS, CONFIGURE_SECTIONS, CONFIGURE_SUB_GROUPS, type ColorScaleOptions, type CompareMode, type ConfigChangeListener, type ConfiguratorSnapshot, DEVICE_DIMENSIONS, type DetectedRoleAssignment, type FieldDef, type FieldType, HOME_SUGGESTION_CHIPS, INTERFACE_ROLES_SECTION, MOCK_BROWSER_CONTENT, MOCK_WORKSPACE_CONTENT, type OnChangeCallback, PALETTE_SECTION, PREVIEW_STORAGE_ADAPTER, type PreviewConfigOptions, type PreviewDevice, type PreviewLifecycleContext, type PreviewScene, type PreviewShellMode, type PreviewShellPalette, type PreviewTranscriptEntryPreset, ROLE_ASSISTANT_MESSAGES, ROLE_BORDERS, ROLE_FAMILIES, ROLE_FAMILY_LABELS, ROLE_HEADER, ROLE_INPUT, ROLE_INTENSITIES, ROLE_LINKS_FOCUS, ROLE_PRIMARY_ACTIONS, ROLE_SCROLL_TO_BOTTOM, ROLE_SURFACES, ROLE_USER_MESSAGES, type RoleAssignmentOptions, type RoleFamily, type RoleIntensity, type RoleTarget, type RoleTargetKind, SEMANTIC_COLORS_SECTION, SHADE_KEYS, SHELL_STYLE_ID, STATUS_COLORS_SECTION, STATUS_PALETTE_SECTION, STYLE_SECTIONS, STYLE_SECTIONS_V2, type SectionDef, type SectionPreset, type SelectOption, type SliderOptions, type SubGroupDef, THEME_EDITOR_PRESETS, THEME_SECTION, type TabDef, type ThemeEditorPreset, ThemeEditorState, type ThemePreviewHandle, type ThemePreviewOptions, type TokenRefOptions, type TranscriptStreamFrame, ZOOM_MAX, ZOOM_MIN, appendPreviewTranscriptEntry, applySceneConfig, applyShellTheme, buildPreviewConfig, buildPreviewConfigWithMessages, buildShellCss, buildSrcdoc, buildTranscriptStreamFrames, convertFromPx, convertToPx, createPreviewMessages, createPreviewTranscriptEntry, createThemePreview, detectRoleAssignment, escapeHtml, findSection, formatCssValue, generateColorScale, getPreviewTranscriptPresetLabel, getShellPalette, getThemeEditorPreset, hexToHsl, hslToHex, isValidHex, normalizeColorValue, paletteColorPath, parseCssValue, presetStreamsText, resolveRoleAssignment, resolveThemeColorPath, scopeSection, tokenRefDisplayName, wcagContrastRatio };
|