@runtypelabs/persona 1.44.2 → 1.45.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.cjs +29 -29
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +137 -2
- package/dist/index.d.ts +137 -2
- package/dist/index.global.js +52 -52
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +30 -30
- package/dist/index.js.map +1 -1
- package/dist/widget.css +68 -0
- package/package.json +1 -1
- package/src/client.ts +123 -0
- package/src/components/approval-bubble.ts +223 -0
- package/src/components/message-bubble.ts +10 -5
- package/src/components/reasoning-bubble.ts +1 -1
- package/src/components/tool-bubble.ts +4 -4
- package/src/index.ts +3 -0
- package/src/plugins/types.ts +10 -0
- package/src/session.ts +120 -0
- package/src/styles/widget.css +68 -0
- package/src/types.ts +80 -1
- package/src/ui.ts +93 -0
package/dist/index.d.cts
CHANGED
|
@@ -65,6 +65,15 @@ interface AgentWidgetPlugin {
|
|
|
65
65
|
defaultRenderer: () => HTMLElement;
|
|
66
66
|
config: AgentWidgetConfig;
|
|
67
67
|
}) => HTMLElement | null;
|
|
68
|
+
/**
|
|
69
|
+
* Custom renderer for approval bubbles
|
|
70
|
+
* Return null to use default renderer
|
|
71
|
+
*/
|
|
72
|
+
renderApproval?: (context: {
|
|
73
|
+
message: AgentWidgetMessage;
|
|
74
|
+
defaultRenderer: () => HTMLElement;
|
|
75
|
+
config: AgentWidgetConfig;
|
|
76
|
+
}) => HTMLElement | null;
|
|
68
77
|
/**
|
|
69
78
|
* Custom renderer for loading indicator
|
|
70
79
|
* Return null to use default renderer (or config-based renderer)
|
|
@@ -431,6 +440,14 @@ type AgentWidgetControllerEventMap = {
|
|
|
431
440
|
"eventStream:closed": {
|
|
432
441
|
timestamp: number;
|
|
433
442
|
};
|
|
443
|
+
"approval:requested": {
|
|
444
|
+
approval: AgentWidgetApproval;
|
|
445
|
+
message: AgentWidgetMessage;
|
|
446
|
+
};
|
|
447
|
+
"approval:resolved": {
|
|
448
|
+
approval: AgentWidgetApproval;
|
|
449
|
+
decision: string;
|
|
450
|
+
};
|
|
434
451
|
};
|
|
435
452
|
type AgentWidgetFeatureFlags = {
|
|
436
453
|
showReasoning?: boolean;
|
|
@@ -748,6 +765,49 @@ type AgentWidgetVoiceRecognitionConfig = {
|
|
|
748
765
|
showRecordingIndicator?: boolean;
|
|
749
766
|
autoResume?: boolean | "assistant";
|
|
750
767
|
};
|
|
768
|
+
/**
|
|
769
|
+
* Configuration for tool approval bubbles.
|
|
770
|
+
* Controls styling, labels, and behavior of the approval UI.
|
|
771
|
+
*/
|
|
772
|
+
type AgentWidgetApprovalConfig = {
|
|
773
|
+
/** Background color of the approval bubble */
|
|
774
|
+
backgroundColor?: string;
|
|
775
|
+
/** Border color of the approval bubble */
|
|
776
|
+
borderColor?: string;
|
|
777
|
+
/** Color for the title text */
|
|
778
|
+
titleColor?: string;
|
|
779
|
+
/** Color for the description text */
|
|
780
|
+
descriptionColor?: string;
|
|
781
|
+
/** Background color for the approve button */
|
|
782
|
+
approveButtonColor?: string;
|
|
783
|
+
/** Text color for the approve button */
|
|
784
|
+
approveButtonTextColor?: string;
|
|
785
|
+
/** Background color for the deny button */
|
|
786
|
+
denyButtonColor?: string;
|
|
787
|
+
/** Text color for the deny button */
|
|
788
|
+
denyButtonTextColor?: string;
|
|
789
|
+
/** Background color for the parameters block */
|
|
790
|
+
parameterBackgroundColor?: string;
|
|
791
|
+
/** Text color for the parameters block */
|
|
792
|
+
parameterTextColor?: string;
|
|
793
|
+
/** Title text displayed above the description */
|
|
794
|
+
title?: string;
|
|
795
|
+
/** Label for the approve button */
|
|
796
|
+
approveLabel?: string;
|
|
797
|
+
/** Label for the deny button */
|
|
798
|
+
denyLabel?: string;
|
|
799
|
+
/**
|
|
800
|
+
* Custom handler for approval decisions.
|
|
801
|
+
* Return void to let the SDK auto-resolve via the API,
|
|
802
|
+
* or return a Response/ReadableStream for custom handling.
|
|
803
|
+
*/
|
|
804
|
+
onDecision?: (data: {
|
|
805
|
+
approvalId: string;
|
|
806
|
+
executionId: string;
|
|
807
|
+
agentId: string;
|
|
808
|
+
toolName: string;
|
|
809
|
+
}, decision: 'approved' | 'denied') => Promise<Response | ReadableStream<Uint8Array> | void>;
|
|
810
|
+
};
|
|
751
811
|
type AgentWidgetToolCallConfig = {
|
|
752
812
|
backgroundColor?: string;
|
|
753
813
|
borderColor?: string;
|
|
@@ -1771,6 +1831,23 @@ type AgentWidgetConfig = {
|
|
|
1771
1831
|
statusIndicator?: AgentWidgetStatusIndicatorConfig;
|
|
1772
1832
|
voiceRecognition?: AgentWidgetVoiceRecognitionConfig;
|
|
1773
1833
|
toolCall?: AgentWidgetToolCallConfig;
|
|
1834
|
+
/**
|
|
1835
|
+
* Configuration for tool approval bubbles.
|
|
1836
|
+
* Set to `false` to disable built-in approval handling entirely.
|
|
1837
|
+
*
|
|
1838
|
+
* @example
|
|
1839
|
+
* ```typescript
|
|
1840
|
+
* config: {
|
|
1841
|
+
* approval: {
|
|
1842
|
+
* title: "Permission Required",
|
|
1843
|
+
* approveLabel: "Allow",
|
|
1844
|
+
* denyLabel: "Block",
|
|
1845
|
+
* approveButtonColor: "#16a34a"
|
|
1846
|
+
* }
|
|
1847
|
+
* }
|
|
1848
|
+
* ```
|
|
1849
|
+
*/
|
|
1850
|
+
approval?: AgentWidgetApprovalConfig | false;
|
|
1774
1851
|
postprocessMessage?: (context: {
|
|
1775
1852
|
text: string;
|
|
1776
1853
|
message: AgentWidgetMessage;
|
|
@@ -2110,7 +2187,22 @@ type AgentWidgetToolCall = {
|
|
|
2110
2187
|
completedAt?: number;
|
|
2111
2188
|
durationMs?: number;
|
|
2112
2189
|
};
|
|
2113
|
-
|
|
2190
|
+
/**
|
|
2191
|
+
* Represents a tool approval request in the chat conversation.
|
|
2192
|
+
* Created when the agent requires human approval before executing a tool.
|
|
2193
|
+
*/
|
|
2194
|
+
type AgentWidgetApproval = {
|
|
2195
|
+
id: string;
|
|
2196
|
+
status: "pending" | "approved" | "denied" | "timeout";
|
|
2197
|
+
agentId: string;
|
|
2198
|
+
executionId: string;
|
|
2199
|
+
toolName: string;
|
|
2200
|
+
toolType?: string;
|
|
2201
|
+
description: string;
|
|
2202
|
+
parameters?: unknown;
|
|
2203
|
+
resolvedAt?: number;
|
|
2204
|
+
};
|
|
2205
|
+
type AgentWidgetMessageVariant = "assistant" | "reasoning" | "tool" | "approval";
|
|
2114
2206
|
/**
|
|
2115
2207
|
* Represents a message in the chat conversation.
|
|
2116
2208
|
*
|
|
@@ -2145,6 +2237,8 @@ type AgentWidgetMessage = {
|
|
|
2145
2237
|
reasoning?: AgentWidgetReasoning;
|
|
2146
2238
|
toolCall?: AgentWidgetToolCall;
|
|
2147
2239
|
tools?: AgentWidgetToolCall[];
|
|
2240
|
+
/** Approval data for messages with variant "approval" */
|
|
2241
|
+
approval?: AgentWidgetApproval;
|
|
2148
2242
|
viaVoice?: boolean;
|
|
2149
2243
|
/**
|
|
2150
2244
|
* Raw structured payload for this message (e.g., JSON action response).
|
|
@@ -2409,6 +2503,21 @@ declare class AgentWidgetClient {
|
|
|
2409
2503
|
* Agent mode dispatch
|
|
2410
2504
|
*/
|
|
2411
2505
|
private dispatchAgent;
|
|
2506
|
+
/**
|
|
2507
|
+
* Process an external SSE stream through the SDK's event pipeline.
|
|
2508
|
+
* This allows piping responses from endpoints like agent approval
|
|
2509
|
+
* through the same message/tool/reasoning handling as dispatch().
|
|
2510
|
+
*/
|
|
2511
|
+
processStream(body: ReadableStream<Uint8Array>, onEvent: SSEHandler, assistantMessageId?: string): Promise<void>;
|
|
2512
|
+
/**
|
|
2513
|
+
* Send an approval decision to the API and return the response
|
|
2514
|
+
* for streaming continuation.
|
|
2515
|
+
*/
|
|
2516
|
+
resolveApproval(approval: {
|
|
2517
|
+
agentId: string;
|
|
2518
|
+
executionId: string;
|
|
2519
|
+
approvalId: string;
|
|
2520
|
+
}, decision: 'approved' | 'denied'): Promise<Response>;
|
|
2412
2521
|
private buildAgentPayload;
|
|
2413
2522
|
private buildPayload;
|
|
2414
2523
|
/**
|
|
@@ -2604,6 +2713,19 @@ declare class AgentWidgetSession {
|
|
|
2604
2713
|
* session.continueConversation();
|
|
2605
2714
|
*/
|
|
2606
2715
|
continueConversation(): Promise<void>;
|
|
2716
|
+
/**
|
|
2717
|
+
* Connect an external SSE stream (e.g. from an approval endpoint) and
|
|
2718
|
+
* process it through the SDK's native event pipeline.
|
|
2719
|
+
*/
|
|
2720
|
+
connectStream(stream: ReadableStream<Uint8Array>, options?: {
|
|
2721
|
+
assistantMessageId?: string;
|
|
2722
|
+
}): Promise<void>;
|
|
2723
|
+
/**
|
|
2724
|
+
* Resolve a tool approval request (approve or deny).
|
|
2725
|
+
* Updates the approval message status, calls the API (or custom onDecision),
|
|
2726
|
+
* and pipes the response stream through connectStream().
|
|
2727
|
+
*/
|
|
2728
|
+
resolveApproval(approval: AgentWidgetApproval, decision: 'approved' | 'denied'): Promise<void>;
|
|
2607
2729
|
cancel(): void;
|
|
2608
2730
|
clearMessages(): void;
|
|
2609
2731
|
hydrateMessages(messages: AgentWidgetMessage[]): void;
|
|
@@ -2722,6 +2844,13 @@ type Controller = {
|
|
|
2722
2844
|
showNPSFeedback: (options?: Partial<NPSFeedbackOptions>) => void;
|
|
2723
2845
|
submitCSATFeedback: (rating: number, comment?: string) => Promise<void>;
|
|
2724
2846
|
submitNPSFeedback: (rating: number, comment?: string) => Promise<void>;
|
|
2847
|
+
/**
|
|
2848
|
+
* Connect an external SSE stream and process it through the SDK's
|
|
2849
|
+
* native event pipeline (tools, reasoning, streaming text, etc.).
|
|
2850
|
+
*/
|
|
2851
|
+
connectStream: (stream: ReadableStream<Uint8Array>, options?: {
|
|
2852
|
+
assistantMessageId?: string;
|
|
2853
|
+
}) => Promise<void>;
|
|
2725
2854
|
/** Push a raw event into the event stream buffer (for testing/debugging) */
|
|
2726
2855
|
__pushEventStreamEvent: (event: {
|
|
2727
2856
|
type: string;
|
|
@@ -2733,6 +2862,12 @@ type Controller = {
|
|
|
2733
2862
|
hideEventStream: () => void;
|
|
2734
2863
|
/** Returns current visibility state of the event stream panel */
|
|
2735
2864
|
isEventStreamVisible: () => boolean;
|
|
2865
|
+
/**
|
|
2866
|
+
* Programmatically resolve a pending approval.
|
|
2867
|
+
* @param approvalId - The approval ID to resolve
|
|
2868
|
+
* @param decision - "approved" or "denied"
|
|
2869
|
+
*/
|
|
2870
|
+
resolveApproval: (approvalId: string, decision: 'approved' | 'denied') => Promise<void>;
|
|
2736
2871
|
};
|
|
2737
2872
|
declare const createAgentExperience: (mount: HTMLElement, initialConfig?: AgentWidgetConfig, runtimeOptions?: {
|
|
2738
2873
|
debugTools?: boolean;
|
|
@@ -3493,4 +3628,4 @@ declare const getHeaderLayout: (layoutName: string) => HeaderLayoutRenderer;
|
|
|
3493
3628
|
*/
|
|
3494
3629
|
declare const buildHeaderWithLayout: (config: AgentWidgetConfig, layoutConfig?: AgentWidgetHeaderLayoutConfig, context?: Partial<HeaderLayoutContext>) => HeaderElements;
|
|
3495
3630
|
|
|
3496
|
-
export { type AgentConfig, type AgentExecutionState, type AgentLoopConfig, type AgentMessageMetadata, type AgentRequestOptions, type AgentWidgetAgentRequestPayload, type AgentWidgetAttachmentsConfig, type AgentWidgetAvatarConfig, AgentWidgetClient, type AgentWidgetConfig, type AgentWidgetController, type AgentWidgetControllerEventMap, type AgentWidgetCustomFetch, type AgentWidgetEvent, type AgentWidgetFeatureFlags, type AgentWidgetHeaderLayoutConfig, type AgentWidgetHeadersFunction, type AgentWidgetInitHandle, type AgentWidgetInitOptions, type AgentWidgetLauncherConfig, type AgentWidgetLayoutConfig, type AgentWidgetLoadingIndicatorConfig, type AgentWidgetMarkdownConfig, type AgentWidgetMarkdownOptions, type AgentWidgetMarkdownRendererOverrides, type AgentWidgetMessage, type AgentWidgetMessageActionsConfig, type AgentWidgetMessageFeedback, type AgentWidgetMessageLayoutConfig, type AgentWidgetPlugin, type AgentWidgetRequestPayload, type AgentWidgetSSEEventParser, type AgentWidgetSSEEventResult, AgentWidgetSession, type AgentWidgetSessionStatus, type AgentWidgetStreamParser, type AgentWidgetStreamParserResult, type AgentWidgetTheme, type AgentWidgetTimestampConfig, AttachmentManager, type AttachmentManagerConfig, type CSATFeedbackOptions, type ClientChatRequest, type ClientFeedbackRequest, type ClientFeedbackType, type ClientInitResponse, type ClientSession, type CodeFormat, type CodeGeneratorHooks, type CodeGeneratorOptions, type ComponentContext, type ComponentDirective, type ComponentRenderer, type ComposerBuildContext, type ComposerElements, type ContentPart, type CreateStandardBubbleOptions, DEFAULT_DARK_THEME, DEFAULT_LIGHT_THEME, DEFAULT_WIDGET_CONFIG, type EventStreamBadgeColor, type EventStreamConfig, type EventStreamPayloadRenderContext, type EventStreamRowRenderContext, type EventStreamToolbarRenderContext, type EventStreamViewRenderContext, type HeaderBuildContext, type HeaderElements, type HeaderLayoutContext, type HeaderLayoutRenderer, type HeaderRenderContext, type IdleIndicatorRenderContext, type ImageContentPart, type InjectAssistantMessageOptions, type InjectMessageOptions, type InjectSystemMessageOptions, type InjectUserMessageOptions, type LoadingIndicatorRenderContext, type LoadingIndicatorRenderer, type MarkdownProcessorOptions, type MessageActionCallbacks, type MessageContent, type MessageRenderContext, type MessageTransform, type NPSFeedbackOptions, type PendingAttachment, type SSEEventCallback, type SSEEventRecord, type SlotRenderContext, type SlotRenderer, type TextContentPart, VERSION, type WidgetLayoutSlot, attachHeaderToContainer, buildComposer, buildDefaultHeader, buildExpandedHeader, buildHeader, buildHeaderWithLayout, buildMinimalHeader, componentRegistry, createActionManager, createAgentExperience, createBubbleWithLayout, createCSATFeedback, createComponentMiddleware, createComponentStreamParser, createDirectivePostprocessor, createFlexibleJsonStreamParser, createImagePart, createJsonStreamParser, createLocalStorageAdapter, createMarkdownProcessor, createMarkdownProcessorFromConfig, createMessageActions, createNPSFeedback, createPlainTextParser, createRegexJsonParser, createStandardBubble, createTextPart, createTypingIndicator, createXmlParser, initAgentWidget as default, defaultActionHandlers, defaultJsonActionParser, directivePostprocessor, escapeHtml, extractComponentDirectiveFromMessage, fileToImagePart, generateAssistantMessageId, generateCodeSnippet, generateMessageId, generateUserMessageId, getDisplayText, getHeaderLayout, getImageParts, hasComponentDirective, hasImages, headerLayouts, initAgentWidget, isComponentDirectiveType, markdownPostprocessor, mergeWithDefaults, normalizeContent, pluginRegistry, renderComponentDirective, renderLoadingIndicatorWithFallback, validateImageFile };
|
|
3631
|
+
export { type AgentConfig, type AgentExecutionState, type AgentLoopConfig, type AgentMessageMetadata, type AgentRequestOptions, type AgentWidgetAgentRequestPayload, type AgentWidgetApproval, type AgentWidgetApprovalConfig, type AgentWidgetAttachmentsConfig, type AgentWidgetAvatarConfig, AgentWidgetClient, type AgentWidgetConfig, type AgentWidgetController, type AgentWidgetControllerEventMap, type AgentWidgetCustomFetch, type AgentWidgetEvent, type AgentWidgetFeatureFlags, type AgentWidgetHeaderLayoutConfig, type AgentWidgetHeadersFunction, type AgentWidgetInitHandle, type AgentWidgetInitOptions, type AgentWidgetLauncherConfig, type AgentWidgetLayoutConfig, type AgentWidgetLoadingIndicatorConfig, type AgentWidgetMarkdownConfig, type AgentWidgetMarkdownOptions, type AgentWidgetMarkdownRendererOverrides, type AgentWidgetMessage, type AgentWidgetMessageActionsConfig, type AgentWidgetMessageFeedback, type AgentWidgetMessageLayoutConfig, type AgentWidgetPlugin, type AgentWidgetRequestPayload, type AgentWidgetSSEEventParser, type AgentWidgetSSEEventResult, AgentWidgetSession, type AgentWidgetSessionStatus, type AgentWidgetStreamParser, type AgentWidgetStreamParserResult, type AgentWidgetTheme, type AgentWidgetTimestampConfig, AttachmentManager, type AttachmentManagerConfig, type CSATFeedbackOptions, type ClientChatRequest, type ClientFeedbackRequest, type ClientFeedbackType, type ClientInitResponse, type ClientSession, type CodeFormat, type CodeGeneratorHooks, type CodeGeneratorOptions, type ComponentContext, type ComponentDirective, type ComponentRenderer, type ComposerBuildContext, type ComposerElements, type ContentPart, type CreateStandardBubbleOptions, DEFAULT_DARK_THEME, DEFAULT_LIGHT_THEME, DEFAULT_WIDGET_CONFIG, type EventStreamBadgeColor, type EventStreamConfig, type EventStreamPayloadRenderContext, type EventStreamRowRenderContext, type EventStreamToolbarRenderContext, type EventStreamViewRenderContext, type HeaderBuildContext, type HeaderElements, type HeaderLayoutContext, type HeaderLayoutRenderer, type HeaderRenderContext, type IdleIndicatorRenderContext, type ImageContentPart, type InjectAssistantMessageOptions, type InjectMessageOptions, type InjectSystemMessageOptions, type InjectUserMessageOptions, type LoadingIndicatorRenderContext, type LoadingIndicatorRenderer, type MarkdownProcessorOptions, type MessageActionCallbacks, type MessageContent, type MessageRenderContext, type MessageTransform, type NPSFeedbackOptions, type PendingAttachment, type SSEEventCallback, type SSEEventRecord, type SlotRenderContext, type SlotRenderer, type TextContentPart, VERSION, type WidgetLayoutSlot, attachHeaderToContainer, buildComposer, buildDefaultHeader, buildExpandedHeader, buildHeader, buildHeaderWithLayout, buildMinimalHeader, componentRegistry, createActionManager, createAgentExperience, createBubbleWithLayout, createCSATFeedback, createComponentMiddleware, createComponentStreamParser, createDirectivePostprocessor, createFlexibleJsonStreamParser, createImagePart, createJsonStreamParser, createLocalStorageAdapter, createMarkdownProcessor, createMarkdownProcessorFromConfig, createMessageActions, createNPSFeedback, createPlainTextParser, createRegexJsonParser, createStandardBubble, createTextPart, createTypingIndicator, createXmlParser, initAgentWidget as default, defaultActionHandlers, defaultJsonActionParser, directivePostprocessor, escapeHtml, extractComponentDirectiveFromMessage, fileToImagePart, generateAssistantMessageId, generateCodeSnippet, generateMessageId, generateUserMessageId, getDisplayText, getHeaderLayout, getImageParts, hasComponentDirective, hasImages, headerLayouts, initAgentWidget, isComponentDirectiveType, markdownPostprocessor, mergeWithDefaults, normalizeContent, pluginRegistry, renderComponentDirective, renderLoadingIndicatorWithFallback, validateImageFile };
|
package/dist/index.d.ts
CHANGED
|
@@ -65,6 +65,15 @@ interface AgentWidgetPlugin {
|
|
|
65
65
|
defaultRenderer: () => HTMLElement;
|
|
66
66
|
config: AgentWidgetConfig;
|
|
67
67
|
}) => HTMLElement | null;
|
|
68
|
+
/**
|
|
69
|
+
* Custom renderer for approval bubbles
|
|
70
|
+
* Return null to use default renderer
|
|
71
|
+
*/
|
|
72
|
+
renderApproval?: (context: {
|
|
73
|
+
message: AgentWidgetMessage;
|
|
74
|
+
defaultRenderer: () => HTMLElement;
|
|
75
|
+
config: AgentWidgetConfig;
|
|
76
|
+
}) => HTMLElement | null;
|
|
68
77
|
/**
|
|
69
78
|
* Custom renderer for loading indicator
|
|
70
79
|
* Return null to use default renderer (or config-based renderer)
|
|
@@ -431,6 +440,14 @@ type AgentWidgetControllerEventMap = {
|
|
|
431
440
|
"eventStream:closed": {
|
|
432
441
|
timestamp: number;
|
|
433
442
|
};
|
|
443
|
+
"approval:requested": {
|
|
444
|
+
approval: AgentWidgetApproval;
|
|
445
|
+
message: AgentWidgetMessage;
|
|
446
|
+
};
|
|
447
|
+
"approval:resolved": {
|
|
448
|
+
approval: AgentWidgetApproval;
|
|
449
|
+
decision: string;
|
|
450
|
+
};
|
|
434
451
|
};
|
|
435
452
|
type AgentWidgetFeatureFlags = {
|
|
436
453
|
showReasoning?: boolean;
|
|
@@ -748,6 +765,49 @@ type AgentWidgetVoiceRecognitionConfig = {
|
|
|
748
765
|
showRecordingIndicator?: boolean;
|
|
749
766
|
autoResume?: boolean | "assistant";
|
|
750
767
|
};
|
|
768
|
+
/**
|
|
769
|
+
* Configuration for tool approval bubbles.
|
|
770
|
+
* Controls styling, labels, and behavior of the approval UI.
|
|
771
|
+
*/
|
|
772
|
+
type AgentWidgetApprovalConfig = {
|
|
773
|
+
/** Background color of the approval bubble */
|
|
774
|
+
backgroundColor?: string;
|
|
775
|
+
/** Border color of the approval bubble */
|
|
776
|
+
borderColor?: string;
|
|
777
|
+
/** Color for the title text */
|
|
778
|
+
titleColor?: string;
|
|
779
|
+
/** Color for the description text */
|
|
780
|
+
descriptionColor?: string;
|
|
781
|
+
/** Background color for the approve button */
|
|
782
|
+
approveButtonColor?: string;
|
|
783
|
+
/** Text color for the approve button */
|
|
784
|
+
approveButtonTextColor?: string;
|
|
785
|
+
/** Background color for the deny button */
|
|
786
|
+
denyButtonColor?: string;
|
|
787
|
+
/** Text color for the deny button */
|
|
788
|
+
denyButtonTextColor?: string;
|
|
789
|
+
/** Background color for the parameters block */
|
|
790
|
+
parameterBackgroundColor?: string;
|
|
791
|
+
/** Text color for the parameters block */
|
|
792
|
+
parameterTextColor?: string;
|
|
793
|
+
/** Title text displayed above the description */
|
|
794
|
+
title?: string;
|
|
795
|
+
/** Label for the approve button */
|
|
796
|
+
approveLabel?: string;
|
|
797
|
+
/** Label for the deny button */
|
|
798
|
+
denyLabel?: string;
|
|
799
|
+
/**
|
|
800
|
+
* Custom handler for approval decisions.
|
|
801
|
+
* Return void to let the SDK auto-resolve via the API,
|
|
802
|
+
* or return a Response/ReadableStream for custom handling.
|
|
803
|
+
*/
|
|
804
|
+
onDecision?: (data: {
|
|
805
|
+
approvalId: string;
|
|
806
|
+
executionId: string;
|
|
807
|
+
agentId: string;
|
|
808
|
+
toolName: string;
|
|
809
|
+
}, decision: 'approved' | 'denied') => Promise<Response | ReadableStream<Uint8Array> | void>;
|
|
810
|
+
};
|
|
751
811
|
type AgentWidgetToolCallConfig = {
|
|
752
812
|
backgroundColor?: string;
|
|
753
813
|
borderColor?: string;
|
|
@@ -1771,6 +1831,23 @@ type AgentWidgetConfig = {
|
|
|
1771
1831
|
statusIndicator?: AgentWidgetStatusIndicatorConfig;
|
|
1772
1832
|
voiceRecognition?: AgentWidgetVoiceRecognitionConfig;
|
|
1773
1833
|
toolCall?: AgentWidgetToolCallConfig;
|
|
1834
|
+
/**
|
|
1835
|
+
* Configuration for tool approval bubbles.
|
|
1836
|
+
* Set to `false` to disable built-in approval handling entirely.
|
|
1837
|
+
*
|
|
1838
|
+
* @example
|
|
1839
|
+
* ```typescript
|
|
1840
|
+
* config: {
|
|
1841
|
+
* approval: {
|
|
1842
|
+
* title: "Permission Required",
|
|
1843
|
+
* approveLabel: "Allow",
|
|
1844
|
+
* denyLabel: "Block",
|
|
1845
|
+
* approveButtonColor: "#16a34a"
|
|
1846
|
+
* }
|
|
1847
|
+
* }
|
|
1848
|
+
* ```
|
|
1849
|
+
*/
|
|
1850
|
+
approval?: AgentWidgetApprovalConfig | false;
|
|
1774
1851
|
postprocessMessage?: (context: {
|
|
1775
1852
|
text: string;
|
|
1776
1853
|
message: AgentWidgetMessage;
|
|
@@ -2110,7 +2187,22 @@ type AgentWidgetToolCall = {
|
|
|
2110
2187
|
completedAt?: number;
|
|
2111
2188
|
durationMs?: number;
|
|
2112
2189
|
};
|
|
2113
|
-
|
|
2190
|
+
/**
|
|
2191
|
+
* Represents a tool approval request in the chat conversation.
|
|
2192
|
+
* Created when the agent requires human approval before executing a tool.
|
|
2193
|
+
*/
|
|
2194
|
+
type AgentWidgetApproval = {
|
|
2195
|
+
id: string;
|
|
2196
|
+
status: "pending" | "approved" | "denied" | "timeout";
|
|
2197
|
+
agentId: string;
|
|
2198
|
+
executionId: string;
|
|
2199
|
+
toolName: string;
|
|
2200
|
+
toolType?: string;
|
|
2201
|
+
description: string;
|
|
2202
|
+
parameters?: unknown;
|
|
2203
|
+
resolvedAt?: number;
|
|
2204
|
+
};
|
|
2205
|
+
type AgentWidgetMessageVariant = "assistant" | "reasoning" | "tool" | "approval";
|
|
2114
2206
|
/**
|
|
2115
2207
|
* Represents a message in the chat conversation.
|
|
2116
2208
|
*
|
|
@@ -2145,6 +2237,8 @@ type AgentWidgetMessage = {
|
|
|
2145
2237
|
reasoning?: AgentWidgetReasoning;
|
|
2146
2238
|
toolCall?: AgentWidgetToolCall;
|
|
2147
2239
|
tools?: AgentWidgetToolCall[];
|
|
2240
|
+
/** Approval data for messages with variant "approval" */
|
|
2241
|
+
approval?: AgentWidgetApproval;
|
|
2148
2242
|
viaVoice?: boolean;
|
|
2149
2243
|
/**
|
|
2150
2244
|
* Raw structured payload for this message (e.g., JSON action response).
|
|
@@ -2409,6 +2503,21 @@ declare class AgentWidgetClient {
|
|
|
2409
2503
|
* Agent mode dispatch
|
|
2410
2504
|
*/
|
|
2411
2505
|
private dispatchAgent;
|
|
2506
|
+
/**
|
|
2507
|
+
* Process an external SSE stream through the SDK's event pipeline.
|
|
2508
|
+
* This allows piping responses from endpoints like agent approval
|
|
2509
|
+
* through the same message/tool/reasoning handling as dispatch().
|
|
2510
|
+
*/
|
|
2511
|
+
processStream(body: ReadableStream<Uint8Array>, onEvent: SSEHandler, assistantMessageId?: string): Promise<void>;
|
|
2512
|
+
/**
|
|
2513
|
+
* Send an approval decision to the API and return the response
|
|
2514
|
+
* for streaming continuation.
|
|
2515
|
+
*/
|
|
2516
|
+
resolveApproval(approval: {
|
|
2517
|
+
agentId: string;
|
|
2518
|
+
executionId: string;
|
|
2519
|
+
approvalId: string;
|
|
2520
|
+
}, decision: 'approved' | 'denied'): Promise<Response>;
|
|
2412
2521
|
private buildAgentPayload;
|
|
2413
2522
|
private buildPayload;
|
|
2414
2523
|
/**
|
|
@@ -2604,6 +2713,19 @@ declare class AgentWidgetSession {
|
|
|
2604
2713
|
* session.continueConversation();
|
|
2605
2714
|
*/
|
|
2606
2715
|
continueConversation(): Promise<void>;
|
|
2716
|
+
/**
|
|
2717
|
+
* Connect an external SSE stream (e.g. from an approval endpoint) and
|
|
2718
|
+
* process it through the SDK's native event pipeline.
|
|
2719
|
+
*/
|
|
2720
|
+
connectStream(stream: ReadableStream<Uint8Array>, options?: {
|
|
2721
|
+
assistantMessageId?: string;
|
|
2722
|
+
}): Promise<void>;
|
|
2723
|
+
/**
|
|
2724
|
+
* Resolve a tool approval request (approve or deny).
|
|
2725
|
+
* Updates the approval message status, calls the API (or custom onDecision),
|
|
2726
|
+
* and pipes the response stream through connectStream().
|
|
2727
|
+
*/
|
|
2728
|
+
resolveApproval(approval: AgentWidgetApproval, decision: 'approved' | 'denied'): Promise<void>;
|
|
2607
2729
|
cancel(): void;
|
|
2608
2730
|
clearMessages(): void;
|
|
2609
2731
|
hydrateMessages(messages: AgentWidgetMessage[]): void;
|
|
@@ -2722,6 +2844,13 @@ type Controller = {
|
|
|
2722
2844
|
showNPSFeedback: (options?: Partial<NPSFeedbackOptions>) => void;
|
|
2723
2845
|
submitCSATFeedback: (rating: number, comment?: string) => Promise<void>;
|
|
2724
2846
|
submitNPSFeedback: (rating: number, comment?: string) => Promise<void>;
|
|
2847
|
+
/**
|
|
2848
|
+
* Connect an external SSE stream and process it through the SDK's
|
|
2849
|
+
* native event pipeline (tools, reasoning, streaming text, etc.).
|
|
2850
|
+
*/
|
|
2851
|
+
connectStream: (stream: ReadableStream<Uint8Array>, options?: {
|
|
2852
|
+
assistantMessageId?: string;
|
|
2853
|
+
}) => Promise<void>;
|
|
2725
2854
|
/** Push a raw event into the event stream buffer (for testing/debugging) */
|
|
2726
2855
|
__pushEventStreamEvent: (event: {
|
|
2727
2856
|
type: string;
|
|
@@ -2733,6 +2862,12 @@ type Controller = {
|
|
|
2733
2862
|
hideEventStream: () => void;
|
|
2734
2863
|
/** Returns current visibility state of the event stream panel */
|
|
2735
2864
|
isEventStreamVisible: () => boolean;
|
|
2865
|
+
/**
|
|
2866
|
+
* Programmatically resolve a pending approval.
|
|
2867
|
+
* @param approvalId - The approval ID to resolve
|
|
2868
|
+
* @param decision - "approved" or "denied"
|
|
2869
|
+
*/
|
|
2870
|
+
resolveApproval: (approvalId: string, decision: 'approved' | 'denied') => Promise<void>;
|
|
2736
2871
|
};
|
|
2737
2872
|
declare const createAgentExperience: (mount: HTMLElement, initialConfig?: AgentWidgetConfig, runtimeOptions?: {
|
|
2738
2873
|
debugTools?: boolean;
|
|
@@ -3493,4 +3628,4 @@ declare const getHeaderLayout: (layoutName: string) => HeaderLayoutRenderer;
|
|
|
3493
3628
|
*/
|
|
3494
3629
|
declare const buildHeaderWithLayout: (config: AgentWidgetConfig, layoutConfig?: AgentWidgetHeaderLayoutConfig, context?: Partial<HeaderLayoutContext>) => HeaderElements;
|
|
3495
3630
|
|
|
3496
|
-
export { type AgentConfig, type AgentExecutionState, type AgentLoopConfig, type AgentMessageMetadata, type AgentRequestOptions, type AgentWidgetAgentRequestPayload, type AgentWidgetAttachmentsConfig, type AgentWidgetAvatarConfig, AgentWidgetClient, type AgentWidgetConfig, type AgentWidgetController, type AgentWidgetControllerEventMap, type AgentWidgetCustomFetch, type AgentWidgetEvent, type AgentWidgetFeatureFlags, type AgentWidgetHeaderLayoutConfig, type AgentWidgetHeadersFunction, type AgentWidgetInitHandle, type AgentWidgetInitOptions, type AgentWidgetLauncherConfig, type AgentWidgetLayoutConfig, type AgentWidgetLoadingIndicatorConfig, type AgentWidgetMarkdownConfig, type AgentWidgetMarkdownOptions, type AgentWidgetMarkdownRendererOverrides, type AgentWidgetMessage, type AgentWidgetMessageActionsConfig, type AgentWidgetMessageFeedback, type AgentWidgetMessageLayoutConfig, type AgentWidgetPlugin, type AgentWidgetRequestPayload, type AgentWidgetSSEEventParser, type AgentWidgetSSEEventResult, AgentWidgetSession, type AgentWidgetSessionStatus, type AgentWidgetStreamParser, type AgentWidgetStreamParserResult, type AgentWidgetTheme, type AgentWidgetTimestampConfig, AttachmentManager, type AttachmentManagerConfig, type CSATFeedbackOptions, type ClientChatRequest, type ClientFeedbackRequest, type ClientFeedbackType, type ClientInitResponse, type ClientSession, type CodeFormat, type CodeGeneratorHooks, type CodeGeneratorOptions, type ComponentContext, type ComponentDirective, type ComponentRenderer, type ComposerBuildContext, type ComposerElements, type ContentPart, type CreateStandardBubbleOptions, DEFAULT_DARK_THEME, DEFAULT_LIGHT_THEME, DEFAULT_WIDGET_CONFIG, type EventStreamBadgeColor, type EventStreamConfig, type EventStreamPayloadRenderContext, type EventStreamRowRenderContext, type EventStreamToolbarRenderContext, type EventStreamViewRenderContext, type HeaderBuildContext, type HeaderElements, type HeaderLayoutContext, type HeaderLayoutRenderer, type HeaderRenderContext, type IdleIndicatorRenderContext, type ImageContentPart, type InjectAssistantMessageOptions, type InjectMessageOptions, type InjectSystemMessageOptions, type InjectUserMessageOptions, type LoadingIndicatorRenderContext, type LoadingIndicatorRenderer, type MarkdownProcessorOptions, type MessageActionCallbacks, type MessageContent, type MessageRenderContext, type MessageTransform, type NPSFeedbackOptions, type PendingAttachment, type SSEEventCallback, type SSEEventRecord, type SlotRenderContext, type SlotRenderer, type TextContentPart, VERSION, type WidgetLayoutSlot, attachHeaderToContainer, buildComposer, buildDefaultHeader, buildExpandedHeader, buildHeader, buildHeaderWithLayout, buildMinimalHeader, componentRegistry, createActionManager, createAgentExperience, createBubbleWithLayout, createCSATFeedback, createComponentMiddleware, createComponentStreamParser, createDirectivePostprocessor, createFlexibleJsonStreamParser, createImagePart, createJsonStreamParser, createLocalStorageAdapter, createMarkdownProcessor, createMarkdownProcessorFromConfig, createMessageActions, createNPSFeedback, createPlainTextParser, createRegexJsonParser, createStandardBubble, createTextPart, createTypingIndicator, createXmlParser, initAgentWidget as default, defaultActionHandlers, defaultJsonActionParser, directivePostprocessor, escapeHtml, extractComponentDirectiveFromMessage, fileToImagePart, generateAssistantMessageId, generateCodeSnippet, generateMessageId, generateUserMessageId, getDisplayText, getHeaderLayout, getImageParts, hasComponentDirective, hasImages, headerLayouts, initAgentWidget, isComponentDirectiveType, markdownPostprocessor, mergeWithDefaults, normalizeContent, pluginRegistry, renderComponentDirective, renderLoadingIndicatorWithFallback, validateImageFile };
|
|
3631
|
+
export { type AgentConfig, type AgentExecutionState, type AgentLoopConfig, type AgentMessageMetadata, type AgentRequestOptions, type AgentWidgetAgentRequestPayload, type AgentWidgetApproval, type AgentWidgetApprovalConfig, type AgentWidgetAttachmentsConfig, type AgentWidgetAvatarConfig, AgentWidgetClient, type AgentWidgetConfig, type AgentWidgetController, type AgentWidgetControllerEventMap, type AgentWidgetCustomFetch, type AgentWidgetEvent, type AgentWidgetFeatureFlags, type AgentWidgetHeaderLayoutConfig, type AgentWidgetHeadersFunction, type AgentWidgetInitHandle, type AgentWidgetInitOptions, type AgentWidgetLauncherConfig, type AgentWidgetLayoutConfig, type AgentWidgetLoadingIndicatorConfig, type AgentWidgetMarkdownConfig, type AgentWidgetMarkdownOptions, type AgentWidgetMarkdownRendererOverrides, type AgentWidgetMessage, type AgentWidgetMessageActionsConfig, type AgentWidgetMessageFeedback, type AgentWidgetMessageLayoutConfig, type AgentWidgetPlugin, type AgentWidgetRequestPayload, type AgentWidgetSSEEventParser, type AgentWidgetSSEEventResult, AgentWidgetSession, type AgentWidgetSessionStatus, type AgentWidgetStreamParser, type AgentWidgetStreamParserResult, type AgentWidgetTheme, type AgentWidgetTimestampConfig, AttachmentManager, type AttachmentManagerConfig, type CSATFeedbackOptions, type ClientChatRequest, type ClientFeedbackRequest, type ClientFeedbackType, type ClientInitResponse, type ClientSession, type CodeFormat, type CodeGeneratorHooks, type CodeGeneratorOptions, type ComponentContext, type ComponentDirective, type ComponentRenderer, type ComposerBuildContext, type ComposerElements, type ContentPart, type CreateStandardBubbleOptions, DEFAULT_DARK_THEME, DEFAULT_LIGHT_THEME, DEFAULT_WIDGET_CONFIG, type EventStreamBadgeColor, type EventStreamConfig, type EventStreamPayloadRenderContext, type EventStreamRowRenderContext, type EventStreamToolbarRenderContext, type EventStreamViewRenderContext, type HeaderBuildContext, type HeaderElements, type HeaderLayoutContext, type HeaderLayoutRenderer, type HeaderRenderContext, type IdleIndicatorRenderContext, type ImageContentPart, type InjectAssistantMessageOptions, type InjectMessageOptions, type InjectSystemMessageOptions, type InjectUserMessageOptions, type LoadingIndicatorRenderContext, type LoadingIndicatorRenderer, type MarkdownProcessorOptions, type MessageActionCallbacks, type MessageContent, type MessageRenderContext, type MessageTransform, type NPSFeedbackOptions, type PendingAttachment, type SSEEventCallback, type SSEEventRecord, type SlotRenderContext, type SlotRenderer, type TextContentPart, VERSION, type WidgetLayoutSlot, attachHeaderToContainer, buildComposer, buildDefaultHeader, buildExpandedHeader, buildHeader, buildHeaderWithLayout, buildMinimalHeader, componentRegistry, createActionManager, createAgentExperience, createBubbleWithLayout, createCSATFeedback, createComponentMiddleware, createComponentStreamParser, createDirectivePostprocessor, createFlexibleJsonStreamParser, createImagePart, createJsonStreamParser, createLocalStorageAdapter, createMarkdownProcessor, createMarkdownProcessorFromConfig, createMessageActions, createNPSFeedback, createPlainTextParser, createRegexJsonParser, createStandardBubble, createTextPart, createTypingIndicator, createXmlParser, initAgentWidget as default, defaultActionHandlers, defaultJsonActionParser, directivePostprocessor, escapeHtml, extractComponentDirectiveFromMessage, fileToImagePart, generateAssistantMessageId, generateCodeSnippet, generateMessageId, generateUserMessageId, getDisplayText, getHeaderLayout, getImageParts, hasComponentDirective, hasImages, headerLayouts, initAgentWidget, isComponentDirectiveType, markdownPostprocessor, mergeWithDefaults, normalizeContent, pluginRegistry, renderComponentDirective, renderLoadingIndicatorWithFallback, validateImageFile };
|