@runtypelabs/persona 3.17.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.d.cts +1 -1
- package/dist/animations/glyph-cycle.d.ts +1 -1
- package/dist/animations/{types-HPZY7oAI.d.cts → types-cwY5HaFD.d.cts} +25 -0
- package/dist/animations/{types-HPZY7oAI.d.ts → types-cwY5HaFD.d.ts} +25 -0
- package/dist/animations/wipe.d.cts +1 -1
- package/dist/animations/wipe.d.ts +1 -1
- package/dist/index.cjs +47 -47
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +300 -1
- package/dist/index.d.ts +300 -1
- package/dist/index.global.js +75 -75
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +47 -47
- package/dist/index.js.map +1 -1
- package/dist/theme-editor.cjs +1432 -159
- package/dist/theme-editor.d.cts +218 -0
- package/dist/theme-editor.d.ts +218 -0
- package/dist/theme-editor.js +1432 -159
- 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 +432 -0
- package/package.json +1 -1
- package/src/client.test.ts +134 -0
- package/src/client.ts +71 -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/messages.ts +33 -1
- package/src/components/panel.ts +41 -4
- package/src/defaults.ts +21 -0
- package/src/index.ts +16 -1
- package/src/plugins/types.ts +57 -0
- package/src/session.test.ts +183 -0
- package/src/session.ts +242 -3
- package/src/styles/widget.css +432 -0
- package/src/types/theme.ts +15 -0
- package/src/types.ts +150 -0
- package/src/ui.ask-user-question-plugin.test.ts +649 -0
- package/src/ui.ts +631 -5
- package/src/utils/storage.ts +10 -2
- package/src/utils/theme.test.ts +36 -0
- package/src/utils/tokens.ts +23 -0
package/src/types/theme.ts
CHANGED
|
@@ -237,6 +237,19 @@ export interface MessageTokens {
|
|
|
237
237
|
border?: TokenReference<'color'>;
|
|
238
238
|
}
|
|
239
239
|
|
|
240
|
+
/**
|
|
241
|
+
* Welcome / intro card rendered above the message list when no messages exist.
|
|
242
|
+
* Set `copy.showWelcomeCard: false` to hide it; use `layout.slots["body-top"]`
|
|
243
|
+
* to replace it wholesale.
|
|
244
|
+
*/
|
|
245
|
+
export interface IntroCardTokens extends ComponentTokenSet {
|
|
246
|
+
background?: TokenReference<'color'>;
|
|
247
|
+
borderRadius?: TokenReference<'radius'>;
|
|
248
|
+
padding?: TokenReference<'spacing'>;
|
|
249
|
+
/** Box-shadow on the intro card (token ref or raw CSS, e.g. `none`). */
|
|
250
|
+
shadow?: string;
|
|
251
|
+
}
|
|
252
|
+
|
|
240
253
|
/** Collapsible widget chrome (tool bubbles, reasoning bubbles, approval bubbles). */
|
|
241
254
|
export interface CollapsibleWidgetTokens {
|
|
242
255
|
/** Background for content areas. */
|
|
@@ -449,6 +462,8 @@ export interface ComponentTokens {
|
|
|
449
462
|
panel: PanelTokens;
|
|
450
463
|
header: HeaderTokens;
|
|
451
464
|
message: MessageTokens;
|
|
465
|
+
/** Welcome / intro card shown above the message list. */
|
|
466
|
+
introCard?: IntroCardTokens;
|
|
452
467
|
/** Markdown surfaces (chat + artifact pane). */
|
|
453
468
|
markdown?: MarkdownTokens;
|
|
454
469
|
voice: VoiceTokens;
|
package/src/types.ts
CHANGED
|
@@ -205,6 +205,31 @@ export type AgentMessageMetadata = {
|
|
|
205
205
|
* or `prompt` step inside the nested flow). Stable key for that step.
|
|
206
206
|
*/
|
|
207
207
|
parentStepId?: string;
|
|
208
|
+
/**
|
|
209
|
+
* Set to `true` on a tool-variant message produced from a `step_await`
|
|
210
|
+
* event (`awaitReason: "local_tool_required"`). Signals to UI code that
|
|
211
|
+
* the tool call is a LOCAL tool and the server is paused waiting for a
|
|
212
|
+
* `POST /v1/dispatch/resume` with the user's answer keyed by tool name.
|
|
213
|
+
*/
|
|
214
|
+
awaitingLocalTool?: boolean;
|
|
215
|
+
/**
|
|
216
|
+
* Set to `true` once the user has picked / typed / dismissed an answer for
|
|
217
|
+
* an `ask_user_question` tool call, so renderers stop re-mounting the
|
|
218
|
+
* answer-pill sheet for this tool call on subsequent render passes.
|
|
219
|
+
*/
|
|
220
|
+
askUserQuestionAnswered?: boolean;
|
|
221
|
+
/**
|
|
222
|
+
* In-progress answers for a multi-question `ask_user_question` payload,
|
|
223
|
+
* keyed by question text. Persisted across refresh so the user lands back
|
|
224
|
+
* where they were if the page reloads mid-flow. Cleared once
|
|
225
|
+
* `askUserQuestionAnswered` flips to `true`.
|
|
226
|
+
*/
|
|
227
|
+
askUserQuestionAnswers?: Record<string, string | string[]>;
|
|
228
|
+
/**
|
|
229
|
+
* Current page index for a multi-question `ask_user_question` payload's
|
|
230
|
+
* paginated stepper. Persists alongside `askUserQuestionAnswers`.
|
|
231
|
+
*/
|
|
232
|
+
askUserQuestionIndex?: number;
|
|
208
233
|
};
|
|
209
234
|
|
|
210
235
|
export type AgentWidgetRequestMiddlewareContext = {
|
|
@@ -270,6 +295,8 @@ export type AgentWidgetActionHandler = (
|
|
|
270
295
|
export type AgentWidgetStoredState = {
|
|
271
296
|
messages?: AgentWidgetMessage[];
|
|
272
297
|
metadata?: Record<string, unknown>;
|
|
298
|
+
artifacts?: PersonaArtifactRecord[];
|
|
299
|
+
selectedArtifactId?: string | null;
|
|
273
300
|
};
|
|
274
301
|
|
|
275
302
|
export interface AgentWidgetStorageAdapter {
|
|
@@ -857,6 +884,118 @@ export type AgentWidgetFeatureFlags = {
|
|
|
857
884
|
artifacts?: AgentWidgetArtifactsFeature;
|
|
858
885
|
/** Reveal animation for streaming assistant text. */
|
|
859
886
|
streamAnimation?: AgentWidgetStreamAnimationFeature;
|
|
887
|
+
/**
|
|
888
|
+
* Built-in interactive answer-pill sheet shown when the assistant invokes
|
|
889
|
+
* the `ask_user_question` tool. Slides up over the composer with tappable
|
|
890
|
+
* pills + optional free-text input.
|
|
891
|
+
*/
|
|
892
|
+
askUserQuestion?: AgentWidgetAskUserQuestionFeature;
|
|
893
|
+
};
|
|
894
|
+
|
|
895
|
+
/**
|
|
896
|
+
* Single selectable option in an `ask_user_question` prompt.
|
|
897
|
+
* Mirrors Anthropic's AskUserQuestion schema.
|
|
898
|
+
*/
|
|
899
|
+
export type AskUserQuestionOption = {
|
|
900
|
+
/** Pill label (required). */
|
|
901
|
+
label: string;
|
|
902
|
+
/** Optional long-form description (shown as a subtitle on tap-hover). */
|
|
903
|
+
description?: string;
|
|
904
|
+
/** Optional rich preview — reserved for future rendering; ignored in v1. */
|
|
905
|
+
preview?: string;
|
|
906
|
+
};
|
|
907
|
+
|
|
908
|
+
/**
|
|
909
|
+
* A single question in an `ask_user_question` tool call.
|
|
910
|
+
* The tool may carry 1–8 prompts. When more than one is supplied, the built-in
|
|
911
|
+
* renderer paginates them as a "Question N of M" stepper with Back / Next /
|
|
912
|
+
* Submit-all controls; single-question payloads render without stepper chrome.
|
|
913
|
+
*/
|
|
914
|
+
export type AskUserQuestionPrompt = {
|
|
915
|
+
/** The question text shown to the user. */
|
|
916
|
+
question: string;
|
|
917
|
+
/** Optional short header label (≤12 chars) used as a compact group title. */
|
|
918
|
+
header?: string;
|
|
919
|
+
/** 2–4 selectable options. */
|
|
920
|
+
options: AskUserQuestionOption[];
|
|
921
|
+
/** When true, the user can pick multiple options and submit together. Default false. */
|
|
922
|
+
multiSelect?: boolean;
|
|
923
|
+
/** When true, a free-text "Other…" pill expands to an input. Default true. */
|
|
924
|
+
allowFreeText?: boolean;
|
|
925
|
+
};
|
|
926
|
+
|
|
927
|
+
/** Parsed payload of an `ask_user_question` tool call. */
|
|
928
|
+
export type AskUserQuestionPayload = {
|
|
929
|
+
/** 1–8 questions. Anything beyond the renderer's cap is truncated with a console warning. */
|
|
930
|
+
questions: AskUserQuestionPrompt[];
|
|
931
|
+
};
|
|
932
|
+
|
|
933
|
+
/**
|
|
934
|
+
* Style overrides for the answer-pill sheet. All values are raw CSS strings
|
|
935
|
+
* and are plumbed through as CSS custom properties on the sheet root.
|
|
936
|
+
*/
|
|
937
|
+
export type AgentWidgetAskUserQuestionStyles = {
|
|
938
|
+
sheetBackground?: string;
|
|
939
|
+
sheetBorder?: string;
|
|
940
|
+
sheetShadow?: string;
|
|
941
|
+
pillBackground?: string;
|
|
942
|
+
pillBackgroundSelected?: string;
|
|
943
|
+
pillTextColor?: string;
|
|
944
|
+
pillTextColorSelected?: string;
|
|
945
|
+
pillBorderRadius?: string;
|
|
946
|
+
customInputBackground?: string;
|
|
947
|
+
};
|
|
948
|
+
|
|
949
|
+
/**
|
|
950
|
+
* Feature config for the built-in `ask_user_question` answer-pill sheet.
|
|
951
|
+
* When a tool call with the name `ask_user_question` arrives, the widget
|
|
952
|
+
* renders an interactive sheet over the composer in place of the generic
|
|
953
|
+
* tool bubble.
|
|
954
|
+
*/
|
|
955
|
+
export type AgentWidgetAskUserQuestionFeature = {
|
|
956
|
+
/** Enable the feature. Defaults to true. When false, `ask_user_question` renders as a regular tool bubble. */
|
|
957
|
+
enabled?: boolean;
|
|
958
|
+
/** Slide-in animation duration in ms. Defaults to 180. */
|
|
959
|
+
slideInMs?: number;
|
|
960
|
+
/** Label for the free-text pill. Defaults to "Other…". */
|
|
961
|
+
freeTextLabel?: string;
|
|
962
|
+
/** Placeholder text in the free-text input. Defaults to "Type your answer…". */
|
|
963
|
+
freeTextPlaceholder?: string;
|
|
964
|
+
/** Button label for submitting multi-select / free-text answers. Defaults to "Send". */
|
|
965
|
+
submitLabel?: string;
|
|
966
|
+
/** Button label advancing to the next question in grouped (paginated) payloads. Defaults to "Next". */
|
|
967
|
+
nextLabel?: string;
|
|
968
|
+
/** Button label moving back to the previous question in grouped payloads. Defaults to "Back". */
|
|
969
|
+
backLabel?: string;
|
|
970
|
+
/** Button label submitting all answers from the final page of a grouped payload. Defaults to "Submit all". */
|
|
971
|
+
submitAllLabel?: string;
|
|
972
|
+
/**
|
|
973
|
+
* In grouped (multi-question) mode, auto-advance to the next page after a
|
|
974
|
+
* single-select pill pick or free-text submit on intermediate pages.
|
|
975
|
+
* Defaults to `true`. The final page never auto-submits — users always
|
|
976
|
+
* confirm with an explicit "Submit all" click. Multi-select pages always
|
|
977
|
+
* require an explicit Next regardless of this setting.
|
|
978
|
+
*/
|
|
979
|
+
groupedAutoAdvance?: boolean;
|
|
980
|
+
/**
|
|
981
|
+
* Visual layout for the option list.
|
|
982
|
+
* - `"rows"` (default) — full-width stacked rows with always-visible
|
|
983
|
+
* descriptions, right-edge number badges (single-select) or checkboxes
|
|
984
|
+
* (multi-select), and an always-visible inline "Other" input.
|
|
985
|
+
* - `"pills"` — legacy compact pill list with horizontal wrap; description
|
|
986
|
+
* surfaces as a tooltip and the "Other…" pill expands on click.
|
|
987
|
+
*/
|
|
988
|
+
layout?: "rows" | "pills";
|
|
989
|
+
/**
|
|
990
|
+
* Button label for skipping the current question in grouped payloads.
|
|
991
|
+
* Defaults to "Skip". On intermediate pages Skip advances without recording
|
|
992
|
+
* an answer; on the final page Skip submits the partial answer record
|
|
993
|
+
* (skipped questions absent from the resolved object). For single-question
|
|
994
|
+
* payloads Skip behaves like dismiss.
|
|
995
|
+
*/
|
|
996
|
+
skipLabel?: string;
|
|
997
|
+
/** Style overrides for the sheet and pills. */
|
|
998
|
+
styles?: AgentWidgetAskUserQuestionStyles;
|
|
860
999
|
};
|
|
861
1000
|
|
|
862
1001
|
export type SSEEventRecord = {
|
|
@@ -2823,6 +2962,17 @@ export type AgentWidgetConfig = {
|
|
|
2823
2962
|
autoFocusInput?: boolean;
|
|
2824
2963
|
launcher?: AgentWidgetLauncherConfig;
|
|
2825
2964
|
initialMessages?: AgentWidgetMessage[];
|
|
2965
|
+
/**
|
|
2966
|
+
* Artifacts to hydrate into the pane at init. Typically populated from
|
|
2967
|
+
* `storageAdapter.load()` alongside `initialMessages` so the artifact pane
|
|
2968
|
+
* survives a page refresh.
|
|
2969
|
+
*/
|
|
2970
|
+
initialArtifacts?: PersonaArtifactRecord[];
|
|
2971
|
+
/**
|
|
2972
|
+
* Which artifact id (if any) should be selected in the pane at init. Paired
|
|
2973
|
+
* with `initialArtifacts`.
|
|
2974
|
+
*/
|
|
2975
|
+
initialSelectedArtifactId?: string | null;
|
|
2826
2976
|
suggestionChips?: string[];
|
|
2827
2977
|
suggestionChipsConfig?: AgentWidgetSuggestionChipsConfig;
|
|
2828
2978
|
debug?: boolean;
|