@runtypelabs/persona 4.25.0 → 4.26.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/animations/glyph-cycle.d.cts +1 -1
- package/dist/animations/glyph-cycle.d.ts +1 -1
- package/dist/animations/{types-Db61aI9J.d.cts → types-BwKTZhg9.d.cts} +14 -0
- package/dist/animations/{types-Db61aI9J.d.ts → types-BwKTZhg9.d.ts} +14 -0
- package/dist/animations/wipe.d.cts +1 -1
- package/dist/animations/wipe.d.ts +1 -1
- package/dist/animations-extra.d.cts +14 -0
- package/dist/animations-extra.d.ts +14 -0
- package/dist/approval-ui-QAKWNFNM.js +1 -0
- package/dist/approval-ui.cjs +2 -2
- package/dist/approval-ui.d.cts +180 -8
- package/dist/approval-ui.d.ts +180 -8
- package/dist/approval-ui.js +2 -2
- package/dist/{artifacts-ui-IGB5YKLO.js → artifacts-ui-NJGMM27I.js} +1 -1
- package/dist/artifacts-ui.cjs +4 -4
- package/dist/artifacts-ui.d.cts +180 -8
- package/dist/artifacts-ui.d.ts +180 -8
- package/dist/artifacts-ui.js +5 -5
- package/dist/chunk-2ANTRKTV.js +1 -0
- package/dist/chunk-4HPTPUC6.js +1 -0
- package/dist/chunk-6V3MNEKB.js +1 -0
- package/dist/chunk-HGUCGM3K.js +9 -0
- package/dist/chunk-IO5VVUKP.js +3 -0
- package/dist/chunk-J4J3Y2P2.js +1 -0
- package/dist/chunk-K6HKIP5K.js +1 -0
- package/dist/chunk-K7NA7G7J.js +1 -0
- package/dist/chunk-MXUTS3LB.js +1 -0
- package/dist/chunk-PDPVORUF.js +1 -0
- package/dist/chunk-QPPJUSZH.js +1 -0
- package/dist/chunk-QRKGQPU7.js +1 -0
- package/dist/chunk-S6PBWE75.js +1 -0
- package/dist/chunk-T7QM7YMF.js +1 -0
- package/dist/chunk-TR2H475E.js +1 -0
- package/dist/chunk-UPO4GUFC.js +1 -0
- package/dist/chunk-ZC66NAIR.js +1 -0
- package/dist/client-history-YPEG45Q4.js +1 -0
- package/dist/client-history.js +1 -0
- package/dist/client-stream-42FOI3EC.js +4 -0
- package/dist/client-stream.js +5 -0
- package/dist/codegen.cjs +1 -1
- package/dist/codegen.js +1 -1
- package/dist/context-mentions-E7HJYWO6.js +161 -0
- package/dist/{context-mentions-inline-I2RDEBAK.js → context-mentions-inline-QVESLW55.js} +1 -1
- package/dist/context-mentions.cjs +7 -7
- package/dist/context-mentions.d.cts +180 -8
- package/dist/context-mentions.d.ts +180 -8
- package/dist/context-mentions.js +8 -8
- package/dist/event-stream-view-FOIJHFQO.js +1 -0
- package/dist/event-stream-view.cjs +1 -1
- package/dist/event-stream-view.d.cts +183 -31
- package/dist/event-stream-view.d.ts +183 -31
- package/dist/event-stream-view.js +1 -1
- package/dist/forms-ui.d.cts +221 -667
- package/dist/forms-ui.d.ts +221 -667
- package/dist/history-shell-QDQ44PSE.js +3 -0
- package/dist/history-shell.js +3 -0
- package/dist/{history-view-BD6OXLNA.js → history-view-NCFBI5GR.js} +2 -2
- package/dist/history-view.cjs +2 -2
- package/dist/history-view.d.cts +35 -1
- package/dist/history-view.d.ts +35 -1
- package/dist/history-view.js +2 -2
- package/dist/index.cjs +80 -74
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +227 -738
- package/dist/index.d.ts +227 -738
- package/dist/index.global.js +3 -215
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +81 -75
- package/dist/index.js.map +1 -1
- package/dist/install.global.js +1 -1
- package/dist/install.global.js.map +1 -1
- package/dist/launcher.global.js +3 -67
- package/dist/launcher.global.js.map +1 -1
- package/dist/markdown-parsers.js +22 -22
- package/dist/runtype-tts-entry-NFBVWR7N.js +1 -0
- package/dist/runtype-tts.js +1 -1
- package/dist/session-actions-ISSKSI66.js +1 -0
- package/dist/session-actions.js +1 -0
- package/dist/session-reconnect.d.cts +180 -8
- package/dist/session-reconnect.d.ts +180 -8
- package/dist/smart-dom-reader.cjs +13 -13
- package/dist/smart-dom-reader.d.cts +180 -8
- package/dist/smart-dom-reader.d.ts +180 -8
- package/dist/smart-dom-reader.js +11 -11
- package/dist/theme-editor-preview.cjs +116 -98
- package/dist/theme-editor-preview.d.cts +182 -8
- package/dist/theme-editor-preview.d.ts +182 -8
- package/dist/theme-editor-preview.js +49 -54
- package/dist/theme-editor.cjs +2 -2
- package/dist/theme-editor.d.cts +181 -23
- package/dist/theme-editor.d.ts +181 -23
- package/dist/theme-editor.js +2 -2
- package/dist/theme-reference.d.cts +14 -0
- package/dist/theme-reference.d.ts +14 -0
- package/dist/ui-extras-entry-WAYFKVNW.js +3 -0
- package/dist/ui-extras.js +72 -0
- package/dist/voice-runtime-UOQOFAFY.js +17 -0
- package/dist/voice-runtime.cjs +17 -1
- package/dist/voice-runtime.d.cts +11650 -232
- package/dist/voice-runtime.d.ts +11650 -232
- package/dist/voice-runtime.js +17 -1
- package/dist/voice-worklet-player.cjs +19 -4
- package/dist/voice-worklet-player.d.cts +9 -10
- package/dist/voice-worklet-player.d.ts +9 -10
- package/dist/voice-worklet-player.js +19 -4
- package/dist/webmcp-polyfill.js +1 -1
- package/dist/webmcp-runtime-V6ZWW3PI.js +6 -0
- package/dist/webmcp-runtime.cjs +2 -2
- package/dist/webmcp-runtime.d.cts +1 -33
- package/dist/webmcp-runtime.d.ts +1 -33
- package/dist/webmcp-runtime.js +2 -2
- package/dist/widget.css +1 -1
- package/package.json +11 -5
- package/src/approval-paused-tool-settle.test.ts +221 -0
- package/src/client-approve.test.ts +311 -0
- package/src/client-history-eager.ts +9 -0
- package/src/client-history-loader.ts +23 -0
- package/src/client-history.ts +579 -0
- package/src/client-resume.ts +177 -0
- package/src/client-stream-eager.ts +12 -0
- package/src/client-stream-loader.ts +25 -0
- package/src/client-stream.ts +1880 -0
- package/src/client.test.ts +31 -1
- package/src/client.ts +293 -2607
- package/src/components/approval-actions.test.ts +27 -0
- package/src/components/approval-actions.ts +27 -3
- package/src/components/message-bubble.test.ts +19 -0
- package/src/components/message-bubble.ts +2 -0
- package/src/components/registry.ts +6 -6
- package/src/components/tool-bubble.test.ts +9 -0
- package/src/components/tool-bubble.ts +1 -0
- package/src/history-shell-bundle.test.ts +54 -0
- package/src/history-shell-eager.ts +12 -0
- package/src/history-shell-loader.ts +27 -0
- package/src/history-shell.ts +2362 -0
- package/src/history-view-loader.ts +2 -0
- package/src/history-view.ts +3 -0
- package/src/index-core.ts +6 -0
- package/src/index-global.ts +90 -248
- package/src/index.ts +13 -0
- package/src/install.ts +6 -4
- package/src/internal/runtype-history-provider.test.ts +1 -0
- package/src/internal/runtype-history-provider.ts +28 -13
- package/src/plugins/registry.ts +8 -8
- package/src/session-actions-chunk.test.ts +55 -0
- package/src/session-actions-eager.ts +11 -0
- package/src/session-actions-loader.ts +37 -0
- package/src/session-actions.ts +909 -0
- package/src/session-history.test.ts +3 -1
- package/src/session.ts +852 -1536
- package/src/session.voice.test.ts +1170 -5
- package/src/styles/widget.css +58 -0
- package/src/theme-editor/state.ts +91 -91
- package/src/types.ts +198 -5
- package/src/ui-ask-user-sheet.ts +382 -0
- package/src/ui-extras-eager.ts +10 -0
- package/src/ui-extras-entry.ts +9 -0
- package/src/ui-extras-loader.ts +26 -0
- package/src/ui.artifact-rail-resize.test.ts +2 -1
- package/src/ui.ask-user-chunk.test.ts +93 -0
- package/src/ui.history-chunk.test.ts +2 -1
- package/src/ui.history-config-provider.test.ts +2 -1
- package/src/ui.history-confirm-fallback.test.ts +142 -0
- package/src/ui.history-controller.test.ts +2 -1
- package/src/ui.history-lifecycle.test.ts +2 -1
- package/src/ui.history-render-hooks.test.ts +2 -1
- package/src/ui.history-shell.test.ts +2 -1
- package/src/ui.rail-overlay.test.ts +2 -1
- package/src/ui.rail-resize.test.ts +2 -1
- package/src/ui.rail-trigger-pending.test.ts +2 -1
- package/src/ui.ts +340 -2770
- package/src/utils/attachment-manager.ts +67 -67
- package/src/utils/constants.ts +3 -0
- package/src/utils/context-mention-controller.ts +323 -323
- package/src/utils/context-mention-manager.ts +40 -40
- package/src/utils/context-mention-orchestrator.ts +28 -0
- package/src/utils/event-stream-buffer.ts +50 -50
- package/src/utils/event-stream-store.ts +43 -43
- package/src/utils/throughput-tracker.ts +34 -34
- package/src/utils/virtual-scroller.ts +67 -67
- package/src/utils/visitor-store.test.ts +50 -0
- package/src/utils/visitor-store.ts +23 -5
- package/src/voice/__fixtures__/voice-wire/README.md +1 -0
- package/src/voice/__fixtures__/voice-wire/client/cancel.json +3 -0
- package/src/voice/__fixtures__/voice-wire/client/context.json +4 -0
- package/src/voice/__fixtures__/voice-wire/client/delegation_result.json +6 -0
- package/src/voice/__fixtures__/voice-wire/client/delegation_update.json +6 -0
- package/src/voice/__fixtures__/voice-wire/client/ping.json +3 -0
- package/src/voice/__fixtures__/voice-wire/client/playback_progress.json +5 -0
- package/src/voice/__fixtures__/voice-wire/client/start.json +3 -0
- package/src/voice/__fixtures__/voice-wire/server/artifact.json +11 -0
- package/src/voice/__fixtures__/voice-wire/server/attached.json +4 -0
- package/src/voice/__fixtures__/voice-wire/server/audio_clear.json +4 -0
- package/src/voice/__fixtures__/voice-wire/server/audio_end.json +3 -0
- package/src/voice/__fixtures__/voice-wire/server/delegation_cancelled.json +5 -0
- package/src/voice/__fixtures__/voice-wire/server/delegation_completed.json +8 -0
- package/src/voice/__fixtures__/voice-wire/server/delegation_started.json +15 -0
- package/src/voice/__fixtures__/voice-wire/server/error.json +6 -0
- package/src/voice/__fixtures__/voice-wire/server/metrics.json +10 -0
- package/src/voice/__fixtures__/voice-wire/server/pong.json +3 -0
- package/src/voice/__fixtures__/voice-wire/server/session_config.json +16 -0
- package/src/voice/__fixtures__/voice-wire/server/transcript_final.json +7 -0
- package/src/voice/__fixtures__/voice-wire/server/transcript_interim.json +4 -0
- package/src/voice/__fixtures__/voice-wire/server/transcript_partial.json +6 -0
- package/src/voice/__fixtures__/voice-wire/server/transcript_update.json +10 -0
- package/src/voice/__fixtures__/voice-wire/server/warning.json +5 -0
- package/src/voice/audio-playback-manager.test.ts +57 -0
- package/src/voice/audio-playback-manager.ts +120 -98
- package/src/voice/browser-voice-provider.ts +37 -37
- package/src/voice/fallback-speech-engine.ts +22 -16
- package/src/voice/keyed-voice-transcript.ts +314 -0
- package/src/voice/mic-state-styles.ts +182 -0
- package/src/voice/read-aloud-controller.ts +46 -44
- package/src/voice/runtype-speech-engine.ts +35 -33
- package/src/voice/runtype-voice-provider.ts +670 -189
- package/src/voice/session-voice-wiring.ts +266 -0
- package/src/voice/voice-delegation.test.ts +71 -0
- package/src/voice/voice-delegation.ts +364 -0
- package/src/voice/voice-turn-tracker.ts +6 -6
- package/src/voice/voice.test.ts +981 -8
- package/src/voice/worklet-playback-engine.test.ts +81 -0
- package/src/voice/worklet-playback-engine.ts +21 -3
- package/src/voice-runtime-loader.ts +4 -1
- package/src/voice-runtime.ts +7 -0
- package/src/webmcp-runtime-entry.ts +41 -39
- package/dist/approval-ui-3NMYNXBD.js +0 -1
- package/dist/chunk-5EIIHQLQ.js +0 -1
- package/dist/chunk-7CO4T5KB.js +0 -1
- package/dist/chunk-EFJBUH5F.js +0 -1
- package/dist/chunk-R2TMIMDI.js +0 -3
- package/dist/chunk-UTVLOTWB.js +0 -9
- package/dist/context-mentions-45MODWOY.js +0 -161
- package/dist/event-stream-view-GL3ADRY2.js +0 -1
- package/dist/runtype-tts-entry-UJAEF7NZ.js +0 -1
- package/dist/voice-runtime-7DA7MJH4.js +0 -1
- package/dist/webmcp-runtime-JI7T4QYF.js +0 -6
package/dist/forms-ui.d.cts
CHANGED
|
@@ -6831,6 +6831,45 @@ type AgentWidgetVoiceRecognitionConfig = {
|
|
|
6831
6831
|
* @default 30000
|
|
6832
6832
|
*/
|
|
6833
6833
|
attachIdleMs?: number;
|
|
6834
|
+
/**
|
|
6835
|
+
* Full-duplex (speech-to-speech, e.g. GPT-Live) calls: run the turns the
|
|
6836
|
+
* voice model hands off to the agent through this widget's normal chat
|
|
6837
|
+
* pipeline. The spoken request becomes the user message, and the answer
|
|
6838
|
+
* renders as a regular assistant message (streaming, tool and approval
|
|
6839
|
+
* UI, WebMCP page tools, persistence) that the voice model then reads
|
|
6840
|
+
* aloud. Only takes effect when the server supports it (it confirms in
|
|
6841
|
+
* `session_config`); otherwise the agent turn runs on the server and its
|
|
6842
|
+
* spoken reply is transcribed, as before. Set `false` to always keep the
|
|
6843
|
+
* agent turn on the server.
|
|
6844
|
+
* @default true
|
|
6845
|
+
*/
|
|
6846
|
+
clientDelegation?: boolean;
|
|
6847
|
+
/**
|
|
6848
|
+
* Full-duplex calls: extra context for the voice model (for example the
|
|
6849
|
+
* page the visitor is on), sent after the chat history as of call start.
|
|
6850
|
+
* The frame goes out once, when the visitor finishes their first
|
|
6851
|
+
* utterance (or at the first agent hand-off). A function is
|
|
6852
|
+
* called at call start and may be async. This text is capped at 4000 characters and the whole frame
|
|
6853
|
+
* (history included) at 8000. Sent only to servers that accept call
|
|
6854
|
+
* context (they announce it in `session_config`).
|
|
6855
|
+
*/
|
|
6856
|
+
callContext?: string | (() => string | Promise<string>);
|
|
6857
|
+
/**
|
|
6858
|
+
* Full-duplex calls with client delegation: how long a tool approval
|
|
6859
|
+
* that a spoken request raised may wait before it is declined as
|
|
6860
|
+
* expired (and the voice model says so). Server-side approval gates
|
|
6861
|
+
* keep their own timeout too. Hanging up never declines it: the
|
|
6862
|
+
* approval card in the chat stays usable. Capped at 540000 (9 minutes),
|
|
6863
|
+
* under the server's 10-minute delegation deadline.
|
|
6864
|
+
* @default 300000
|
|
6865
|
+
*/
|
|
6866
|
+
approvalTimeoutMs?: number;
|
|
6867
|
+
/**
|
|
6868
|
+
* Speech-to-speech calls: the one-line notice shown in the composer
|
|
6869
|
+
* status area when the call starts. `false` hides it.
|
|
6870
|
+
* @default "You're talking to an AI assistant. Voice is processed by OpenAI."
|
|
6871
|
+
*/
|
|
6872
|
+
disclosureText?: string | false;
|
|
6834
6873
|
/** @deprecated No-op on the realtime path: the server's STT owns turn-taking. */
|
|
6835
6874
|
pauseDuration?: number;
|
|
6836
6875
|
/** @deprecated No-op on the realtime path: the server's STT owns turn-taking. */
|
|
@@ -7069,6 +7108,13 @@ interface VoicePlaybackEngine {
|
|
|
7069
7108
|
onFinished(callback: () => void): void;
|
|
7070
7109
|
/** Release all audio resources. */
|
|
7071
7110
|
destroy(): Promise<void> | void;
|
|
7111
|
+
/**
|
|
7112
|
+
* Optional. Speech-to-speech calls stream reply audio with no end-of-stream
|
|
7113
|
+
* marker, so an engine that holds audio below a prebuffer waterline must, while
|
|
7114
|
+
* continuous, release that held tail on its own (e.g. after a short input gap)
|
|
7115
|
+
* instead of waiting for {@link markStreamEnd}. Engines without a prebuffer can omit it.
|
|
7116
|
+
*/
|
|
7117
|
+
setContinuousMode?(enabled: boolean): void;
|
|
7072
7118
|
}
|
|
7073
7119
|
/**
|
|
7074
7120
|
* A {@link VoicePlaybackEngine} that also supports pause/resume. Returned by
|
|
@@ -7120,6 +7166,14 @@ type VoiceConfig = {
|
|
|
7120
7166
|
prewarmMode?: 'request' | 'attach';
|
|
7121
7167
|
/** See `voiceRecognition.provider.runtype.attachIdleMs`. @default 30000 */
|
|
7122
7168
|
attachIdleMs?: number;
|
|
7169
|
+
/** See `voiceRecognition.provider.runtype.clientDelegation`. @default true */
|
|
7170
|
+
clientDelegation?: boolean;
|
|
7171
|
+
/** See `voiceRecognition.provider.runtype.callContext`. */
|
|
7172
|
+
callContext?: string | (() => string | Promise<string>);
|
|
7173
|
+
/** See `voiceRecognition.provider.runtype.approvalTimeoutMs`. @default 300000 (capped at 540000) */
|
|
7174
|
+
approvalTimeoutMs?: number;
|
|
7175
|
+
/** See `voiceRecognition.provider.runtype.disclosureText`. */
|
|
7176
|
+
disclosureText?: string | false;
|
|
7123
7177
|
/** @deprecated No-op on the realtime path: the server's STT owns turn-taking. */
|
|
7124
7178
|
pauseDuration?: number;
|
|
7125
7179
|
/** @deprecated No-op on the realtime path: the server's STT owns turn-taking. */
|
|
@@ -7152,14 +7206,23 @@ interface VoiceProvider {
|
|
|
7152
7206
|
* Register a callback for incremental transcript updates during a voice turn.
|
|
7153
7207
|
* `isFinal=false` is a live interim update (user partials, or assistant deltas
|
|
7154
7208
|
* on providers that stream them); `isFinal=true` finalizes that role's text.
|
|
7155
|
-
* On the realtime `runtype` path, interim updates fire for the `user`
|
|
7156
|
-
* the `assistant` arrives as a single final
|
|
7157
|
-
*
|
|
7158
|
-
*
|
|
7159
|
-
|
|
7160
|
-
|
|
7161
|
-
|
|
7162
|
-
|
|
7209
|
+
* On the classic realtime `runtype` path, interim updates fire for the `user`
|
|
7210
|
+
* only and the `assistant` arrives as a single final; without a turnId the
|
|
7211
|
+
* session assumes strictly alternating turns, and providers must discard
|
|
7212
|
+
* cancelled output before emitting the next user final.
|
|
7213
|
+
*
|
|
7214
|
+
* When `metadata.turnId` is present (full-duplex / speech-to-speech, e.g.
|
|
7215
|
+
* GPT-Live), the session reconciles by `(turnId, role)`: each pair owns one
|
|
7216
|
+
* bubble that later updates replace in place, turns may overlap or arrive in
|
|
7217
|
+
* any order, and no empty assistant placeholder is injected. User and
|
|
7218
|
+
* assistant may share a turnId (a late user bubble then renders above its
|
|
7219
|
+
* reply) or use distinct ones. `metadata.startMs` (call-relative ms when the
|
|
7220
|
+
* utterance began) orders a new bubble among the call's other keyed bubbles;
|
|
7221
|
+
* without it bubbles order by first arrival. After a stop, keyed providers
|
|
7222
|
+
* must drop the cancelled reply's output until the server acknowledges the
|
|
7223
|
+
* cancel: the session renders every reply it receives.
|
|
7224
|
+
*/
|
|
7225
|
+
onTranscript?(callback: (role: 'user' | 'assistant', text: string, isFinal: boolean, metadata?: VoiceTranscriptMetadata) => void): void;
|
|
7163
7226
|
/** Register a callback for per-turn latency metrics (realtime path). */
|
|
7164
7227
|
onMetrics?(callback: (metrics: VoiceMetrics) => void): void;
|
|
7165
7228
|
/**
|
|
@@ -7187,6 +7250,109 @@ interface VoiceProvider {
|
|
|
7187
7250
|
* repeatedly; throttle as needed.
|
|
7188
7251
|
*/
|
|
7189
7252
|
prewarm?(): void;
|
|
7253
|
+
/**
|
|
7254
|
+
* Called by the session once after construction with the chat-side surface
|
|
7255
|
+
* a full-duplex provider uses to hand agent turns to the chat pipeline
|
|
7256
|
+
* ({@link VoiceSessionBridge}). Providers without client delegation omit it.
|
|
7257
|
+
*/
|
|
7258
|
+
setSessionBridge?(bridge: VoiceSessionBridge): void;
|
|
7259
|
+
/** The AI-disclosure notice for the live call, if one should show (speech-to-speech). */
|
|
7260
|
+
getDisclosure?(): string | null;
|
|
7261
|
+
}
|
|
7262
|
+
/** Metadata on a {@link VoiceProvider.onTranscript} update. */
|
|
7263
|
+
type VoiceTranscriptMetadata = {
|
|
7264
|
+
/** Groups updates that belong to one utterance bubble (full duplex). */
|
|
7265
|
+
turnId?: string;
|
|
7266
|
+
/** Call-relative ms when the utterance began; orders late bubbles. */
|
|
7267
|
+
startMs?: number;
|
|
7268
|
+
/** Call-relative ms of the latest audio this update covers. */
|
|
7269
|
+
endMs?: number;
|
|
7270
|
+
/**
|
|
7271
|
+
* The bubble only captions speech (see `AgentWidgetMessage.voiceCaption`).
|
|
7272
|
+
* The chat pipeline owns the conversation, as with client delegation.
|
|
7273
|
+
*/
|
|
7274
|
+
caption?: boolean;
|
|
7275
|
+
};
|
|
7276
|
+
/** An agent turn a full-duplex voice model handed to the widget. */
|
|
7277
|
+
type VoiceDelegationRequest = {
|
|
7278
|
+
/** The voice model's delegation id (`delegation_started.delegationId`). */
|
|
7279
|
+
delegationId: string;
|
|
7280
|
+
/** What the visitor asked, as the voice model heard it. */
|
|
7281
|
+
userText: string;
|
|
7282
|
+
/**
|
|
7283
|
+
* The user transcript utterances `userText` joins, oldest first (the last
|
|
7284
|
+
* is the one it came from). May be empty.
|
|
7285
|
+
*/
|
|
7286
|
+
userUtteranceIds: string[];
|
|
7287
|
+
/** The voice model's view of the conversation it delegated from. */
|
|
7288
|
+
messages: Array<{
|
|
7289
|
+
role: string;
|
|
7290
|
+
content: unknown;
|
|
7291
|
+
}>;
|
|
7292
|
+
};
|
|
7293
|
+
/**
|
|
7294
|
+
* How a delegated turn ended, or that it waits on an approval (contract
|
|
7295
|
+
* Amendment 5). `pending_approval` is the only non-terminal status. Open:
|
|
7296
|
+
* a receiver treats an unknown terminal status as `failed`.
|
|
7297
|
+
* - `completed`: the work ran.
|
|
7298
|
+
* - `denied`: the visitor said no (Deny tap, or a spoken decline).
|
|
7299
|
+
* - `timeout`: the approval lapsed (`approvalTimeoutMs`, or the server's own timeout).
|
|
7300
|
+
* - `cancelled`: replaced by a newer request, or abandoned by the system.
|
|
7301
|
+
* - `failed`: an error.
|
|
7302
|
+
*/
|
|
7303
|
+
type VoiceDelegationStatus = 'completed' | 'pending_approval' | 'denied' | 'timeout' | 'cancelled' | 'failed' | (string & {});
|
|
7304
|
+
/** The terminal result of a turn that parked on approvals. */
|
|
7305
|
+
type VoiceDelegationFollowUp = {
|
|
7306
|
+
status: VoiceDelegationStatus;
|
|
7307
|
+
/** What to read aloud (Markdown allowed). May be empty: nothing more to say. */
|
|
7308
|
+
text: string;
|
|
7309
|
+
};
|
|
7310
|
+
/** The delegated turn's answer, sent back for the voice model to read aloud. */
|
|
7311
|
+
type VoiceDelegationResult = {
|
|
7312
|
+
/** `pending_approval` when `followUp` is set; otherwise terminal. */
|
|
7313
|
+
status: VoiceDelegationStatus;
|
|
7314
|
+
/** The assistant text (Markdown allowed). */
|
|
7315
|
+
text: string;
|
|
7316
|
+
/**
|
|
7317
|
+
* Set when the turn parked on approvals (`text` then asks for the decision).
|
|
7318
|
+
* Resolves with the terminal result once the visitor decides (or the
|
|
7319
|
+
* approval is replaced, declined by voice, or unanswered for
|
|
7320
|
+
* `approvalTimeoutMs`) and the resumed turn finishes; `null` only when
|
|
7321
|
+
* `signal` aborts first (hang-up, or the server cancelled the delegation).
|
|
7322
|
+
*/
|
|
7323
|
+
followUp?: (options: {
|
|
7324
|
+
signal: AbortSignal;
|
|
7325
|
+
approvalTimeoutMs?: number;
|
|
7326
|
+
/** `false`: run only the approval bookkeeping (expiry, supersede); nothing will be read back. @default true */
|
|
7327
|
+
readBack?: boolean;
|
|
7328
|
+
/** The resumed turn stopped on another approval: ask for it too (`text` is its approval script). */
|
|
7329
|
+
onUpdate?: (text: string) => void;
|
|
7330
|
+
}) => Promise<VoiceDelegationFollowUp | null>;
|
|
7331
|
+
};
|
|
7332
|
+
/**
|
|
7333
|
+
* Chat-side surface the session hands a full-duplex provider: the visible
|
|
7334
|
+
* history (for the call-start context) and a way to run a delegated turn
|
|
7335
|
+
* through the normal chat pipeline.
|
|
7336
|
+
*/
|
|
7337
|
+
interface VoiceSessionBridge {
|
|
7338
|
+
/** Visible user/assistant messages, oldest first. */
|
|
7339
|
+
getHistory(): Array<{
|
|
7340
|
+
role: 'user' | 'assistant';
|
|
7341
|
+
content: string;
|
|
7342
|
+
}>;
|
|
7343
|
+
/**
|
|
7344
|
+
* Submit the turn as the visitor's message (reusing its transcript bubble)
|
|
7345
|
+
* and resolve with the assistant's final answer once the turn settles.
|
|
7346
|
+
* Waits for any chat turn already in flight first. Never rejects.
|
|
7347
|
+
*/
|
|
7348
|
+
runDelegatedTurn(request: VoiceDelegationRequest): Promise<VoiceDelegationResult>;
|
|
7349
|
+
/**
|
|
7350
|
+
* The server dropped this delegation's result (cancelled it, or refused a
|
|
7351
|
+
* late result): its chat answer is no longer spoken, so browser TTS may read it.
|
|
7352
|
+
* `expired`: the server's deadline passed, so its pending approvals are
|
|
7353
|
+
* declined too, as the approval TTL would.
|
|
7354
|
+
*/
|
|
7355
|
+
dropDelegation?(delegationId: string, expired?: boolean): void;
|
|
7190
7356
|
}
|
|
7191
7357
|
/**
|
|
7192
7358
|
* Extra context for an approval decision, surfaced to `onDecision` and to the
|
|
@@ -9881,6 +10047,11 @@ type AgentWidgetToolCall = {
|
|
|
9881
10047
|
startedAt?: number;
|
|
9882
10048
|
completedAt?: number;
|
|
9883
10049
|
durationMs?: number;
|
|
10050
|
+
/**
|
|
10051
|
+
* The call paused for an approval that was granted, and the agent re-ran it
|
|
10052
|
+
* as a new tool call: that later call carries the result, this one has none.
|
|
10053
|
+
*/
|
|
10054
|
+
superseded?: boolean;
|
|
9884
10055
|
};
|
|
9885
10056
|
/**
|
|
9886
10057
|
* Represents a tool approval request in the chat conversation.
|
|
@@ -9902,6 +10073,8 @@ type AgentWidgetApproval = {
|
|
|
9902
10073
|
*/
|
|
9903
10074
|
reason?: string;
|
|
9904
10075
|
parameters?: unknown;
|
|
10076
|
+
/** The paused tool call this approval gates (`approval_start.toolCallId`). */
|
|
10077
|
+
toolCallId?: string;
|
|
9905
10078
|
resolvedAt?: number;
|
|
9906
10079
|
};
|
|
9907
10080
|
type AgentWidgetMessageVariant = "assistant" | "reasoning" | "tool" | "approval";
|
|
@@ -10001,6 +10174,13 @@ type AgentWidgetMessage = {
|
|
|
10001
10174
|
* }
|
|
10002
10175
|
*/
|
|
10003
10176
|
voiceProcessing?: boolean;
|
|
10177
|
+
/**
|
|
10178
|
+
* Display-only caption of full-duplex voice speech, such as the voice
|
|
10179
|
+
* model's own words, or something the visitor said that wasn't submitted
|
|
10180
|
+
* as a chat turn. It renders in the transcript but is never sent to the
|
|
10181
|
+
* model as conversation.
|
|
10182
|
+
*/
|
|
10183
|
+
voiceCaption?: boolean;
|
|
10004
10184
|
/**
|
|
10005
10185
|
* Raw structured payload for this message (e.g., JSON action response).
|
|
10006
10186
|
* Populated automatically when structured parsers run.
|
|
@@ -10116,6 +10296,8 @@ type InjectMessageOptions = {
|
|
|
10116
10296
|
* Consumers can detect this in `messageTransform` to render custom UI.
|
|
10117
10297
|
*/
|
|
10118
10298
|
voiceProcessing?: boolean;
|
|
10299
|
+
/** See {@link AgentWidgetMessage.voiceCaption}. */
|
|
10300
|
+
voiceCaption?: boolean;
|
|
10119
10301
|
/**
|
|
10120
10302
|
* Raw structured payload (typically a JSON string) representing the
|
|
10121
10303
|
* full directive that produced this message: e.g. `{ "text": "...",
|
|
@@ -10318,51 +10500,15 @@ type DispatchOptions = {
|
|
|
10318
10500
|
type SSEHandler = (event: AgentWidgetEvent) => void;
|
|
10319
10501
|
type SSEEventCallback = (eventType: string, payload: unknown) => void;
|
|
10320
10502
|
declare class AgentWidgetClient {
|
|
10503
|
+
#private;
|
|
10321
10504
|
private config;
|
|
10322
10505
|
private historyInternals;
|
|
10323
|
-
private readonly apiUrl;
|
|
10324
|
-
private readonly headers;
|
|
10325
10506
|
private readonly debug;
|
|
10326
|
-
private readonly createStreamParser;
|
|
10327
|
-
private readonly contextProviders;
|
|
10328
|
-
private readonly requestMiddleware?;
|
|
10329
|
-
private readonly customFetch?;
|
|
10330
|
-
private readonly parseSSEEvent?;
|
|
10331
|
-
private readonly getHeaders?;
|
|
10332
|
-
private onSSEEvent?;
|
|
10333
|
-
/**
|
|
10334
|
-
* Turn id of the newest client-token dispatch. A dispatch whose id no longer
|
|
10335
|
-
* matches is superseded, and every SSE frame it still receives is dropped
|
|
10336
|
-
*/
|
|
10337
|
-
private currentClientTurnId;
|
|
10338
10507
|
private clientSession;
|
|
10339
|
-
private sessionInitPromise;
|
|
10340
|
-
/**
|
|
10341
|
-
* Early-init latch for `warmSession()`. `false` = armed. Otherwise it holds
|
|
10342
|
-
* the session value (`null` or an expired session) the one early attempt was
|
|
10343
|
-
* made against, so a failed attempt is not retried on every keystroke. It is
|
|
10344
|
-
* re-armed when a session is installed or cleared, so each session lifetime
|
|
10345
|
-
* gets one early init.
|
|
10346
|
-
*/
|
|
10347
|
-
private sessionWarmLatch;
|
|
10348
10508
|
private lastSentClientToolsFingerprint;
|
|
10349
10509
|
private clientToolsFingerprintSessionId;
|
|
10350
|
-
private sentNonEmptyClientToolsSessionId;
|
|
10351
|
-
private historyUnavailable;
|
|
10352
|
-
private historyUnavailableWarned;
|
|
10353
|
-
private claimInFlight;
|
|
10354
|
-
private historyIdentityStatus;
|
|
10355
|
-
private historyIdentitySubscribers;
|
|
10356
|
-
private historyAvailabilitySubscribers;
|
|
10357
10510
|
private webMcpBridge;
|
|
10358
|
-
private webMcpBridgePromise;
|
|
10359
|
-
/** undefined = never set; null = explicitly cleared. Applied at adoption. */
|
|
10360
|
-
private pendingWebMcpConfirmHandler;
|
|
10361
10511
|
constructor(config?: AgentWidgetConfig, historyInternals?: WidgetHistoryInternals);
|
|
10362
|
-
/** Load the lazy runtime chunk and construct the bridge with core-owned deps. */
|
|
10363
|
-
private createWebMcpBridge;
|
|
10364
|
-
/** Resolve the bridge, loading the runtime chunk on first use. */
|
|
10365
|
-
private getWebMcpBridge;
|
|
10366
10512
|
/**
|
|
10367
10513
|
* Refresh config in place WITHOUT tearing down the live connection or the
|
|
10368
10514
|
* WebMCP bridge. `AgentWidgetSession.updateConfig` calls this when only
|
|
@@ -10420,29 +10566,10 @@ declare class AgentWidgetClient {
|
|
|
10420
10566
|
* Check if running in client token mode
|
|
10421
10567
|
*/
|
|
10422
10568
|
isClientTokenMode(): boolean;
|
|
10423
|
-
/**
|
|
10424
|
-
* Resolve the effective backend routing for the current config. Combines the
|
|
10425
|
-
* explicit `agentId`/`flowId` fields with the normalized `target` string
|
|
10426
|
-
* (resolved via `resolveTarget`). Computed on demand so it stays correct
|
|
10427
|
-
* across `update()`; the `target`/explicit-field conflict is rejected in the
|
|
10428
|
-
* constructor, so at most one source is set here.
|
|
10429
|
-
*/
|
|
10430
|
-
private routing;
|
|
10431
10569
|
/**
|
|
10432
10570
|
* Check if operating in agent execution mode
|
|
10433
10571
|
*/
|
|
10434
10572
|
isAgentMode(): boolean;
|
|
10435
|
-
/**
|
|
10436
|
-
* Base URL for Runtype client-surface routes (`/v1/client/*`,
|
|
10437
|
-
* `/v1/agents/*`). Strips a configured `/v1/dispatch` suffix so an apiUrl
|
|
10438
|
-
* pointed at the dispatch endpoint still resolves its sibling routes. Not
|
|
10439
|
-
* used for proxy-mode URLs, whose resume route is `${apiUrl}/resume`.
|
|
10440
|
-
*/
|
|
10441
|
-
private clientApiBase;
|
|
10442
|
-
/**
|
|
10443
|
-
* Get the appropriate API URL based on mode
|
|
10444
|
-
*/
|
|
10445
|
-
private getClientApiUrl;
|
|
10446
10573
|
/**
|
|
10447
10574
|
* Get the current client session (if any)
|
|
10448
10575
|
*/
|
|
@@ -10476,56 +10603,13 @@ declare class AgentWidgetClient {
|
|
|
10476
10603
|
* `/v1/client/init`.
|
|
10477
10604
|
*/
|
|
10478
10605
|
initSession(): Promise<ClientSession>;
|
|
10479
|
-
/** Visitor history rides on client-token init only, and latches off after a 403 degrade. */
|
|
10480
|
-
private isHistoryCapable;
|
|
10481
10606
|
private readVisitorToken;
|
|
10482
|
-
/** One-way, client-lifetime latch: chat keeps working without history. */
|
|
10483
|
-
private markHistoryUnavailable;
|
|
10484
10607
|
/** Public, secret-free view of the current identity state. */
|
|
10485
10608
|
getHistoryIdentityStatus(): HistoryIdentityStatus;
|
|
10486
10609
|
/** Deduped status notifications; carries no token, proof, or identity value. */
|
|
10487
10610
|
subscribeHistoryIdentityStatus(callback: (status: HistoryIdentityStatus) => void): () => void;
|
|
10488
10611
|
/** Fires only on the one-way 403 degrade; availability never returns. */
|
|
10489
10612
|
subscribeHistoryAvailability(callback: (available: boolean) => void): () => void;
|
|
10490
|
-
/** Config-derived state before any per-operation evidence exists. */
|
|
10491
|
-
private restingIdentityStatus;
|
|
10492
|
-
/** Keeps an already-observed browser_only reason; otherwise derives one. */
|
|
10493
|
-
private browserOnlyStatus;
|
|
10494
|
-
private derivedBrowserOnly;
|
|
10495
|
-
/** Identical consecutive states are not re-announced. */
|
|
10496
|
-
private setHistoryIdentityStatus;
|
|
10497
|
-
/**
|
|
10498
|
-
* The single uncached init primitive: builds one body, performs one fetch.
|
|
10499
|
-
* `conversationId` and `sessionId` are mutually exclusive on the wire (strict
|
|
10500
|
-
* server union), so a resume never carries the stored session id.
|
|
10501
|
-
*/
|
|
10502
|
-
private createClientSession;
|
|
10503
|
-
private _doInitSession;
|
|
10504
|
-
/**
|
|
10505
|
-
* An empty store means this init may mint a visitor, so it runs under the
|
|
10506
|
-
* cross-tab first-init lock: a waiter re-reads inside the lock and joins the
|
|
10507
|
-
* winner's visitor instead of minting a second one.
|
|
10508
|
-
*/
|
|
10509
|
-
private ordinaryInit;
|
|
10510
|
-
private doOrdinaryInit;
|
|
10511
|
-
/**
|
|
10512
|
-
* Ordinary init carrying an identity proof: binds/rebinds the visitor,
|
|
10513
|
-
* persists any replacement token (inside `createClientSession`), and installs
|
|
10514
|
-
* the result as the live session.
|
|
10515
|
-
*/
|
|
10516
|
-
private reinitWithProof;
|
|
10517
|
-
/**
|
|
10518
|
-
* A minted visitor means the record this session just created is still
|
|
10519
|
-
* unowned; one immediate re-init with `{visitorToken, sessionId}` claims it.
|
|
10520
|
-
*/
|
|
10521
|
-
private claimFirstConversation;
|
|
10522
|
-
/**
|
|
10523
|
-
* Continuity guard + id persistence. A different record than the persisted
|
|
10524
|
-
* one is a privacy transition, announced before the new id is written.
|
|
10525
|
-
*/
|
|
10526
|
-
private finishInit;
|
|
10527
|
-
/** Wrap an uncached init so nothing installs until the winner commits. */
|
|
10528
|
-
private prepared;
|
|
10529
10613
|
/**
|
|
10530
10614
|
* Transactional reopen of a known conversation. Always bypasses the session
|
|
10531
10615
|
* cache, never sends the stored session id, and needs a credential the server
|
|
@@ -10552,10 +10636,6 @@ declare class AgentWidgetClient {
|
|
|
10552
10636
|
* when the conversation is reset (`WidgetSession.clearMessages`).
|
|
10553
10637
|
*/
|
|
10554
10638
|
resetClientToolsFingerprint(): void;
|
|
10555
|
-
/**
|
|
10556
|
-
* Get the feedback API URL
|
|
10557
|
-
*/
|
|
10558
|
-
private getFeedbackApiUrl;
|
|
10559
10639
|
/**
|
|
10560
10640
|
* Send feedback for a message (client token mode only).
|
|
10561
10641
|
* Supports upvote, downvote, copy, csat, and nps feedback types.
|
|
@@ -10614,37 +10694,6 @@ declare class AgentWidgetClient {
|
|
|
10614
10694
|
* @param comment - Optional comment
|
|
10615
10695
|
*/
|
|
10616
10696
|
submitNPSFeedback(rating: number, comment?: string): Promise<void>;
|
|
10617
|
-
/** `/v1/client/<path>` with a query string; credentials ride in headers. */
|
|
10618
|
-
private historyUrl;
|
|
10619
|
-
/** Explicit per-operation scope wins; otherwise config, then evidence. */
|
|
10620
|
-
private resolveHistoryScope;
|
|
10621
|
-
private resolveChatIdentityProof;
|
|
10622
|
-
/**
|
|
10623
|
-
* Resolve the proof for one logical request. `null` is an intentional
|
|
10624
|
-
* browser-scope fallback only while the visitor has never been bound.
|
|
10625
|
-
*/
|
|
10626
|
-
private resolveIdentityProof;
|
|
10627
|
-
/** Bind the visitor before the first verified request; admitted proofs only. */
|
|
10628
|
-
private bindIdentity;
|
|
10629
|
-
private readErrorCode;
|
|
10630
|
-
/**
|
|
10631
|
-
* Selective one-shot 401 recovery. Returns the session to retry under;
|
|
10632
|
-
* anything unrecoverable throws typed and is never retried.
|
|
10633
|
-
*/
|
|
10634
|
-
private recoverFromUnauthorized;
|
|
10635
|
-
private historyErrorFor;
|
|
10636
|
-
/**
|
|
10637
|
-
* Validate `X-History-Identity-Status` before any body is committed: the
|
|
10638
|
-
* per-operation acknowledgement, not a prior init, is what proves scope.
|
|
10639
|
-
*/
|
|
10640
|
-
private commitIdentityAcknowledgement;
|
|
10641
|
-
/**
|
|
10642
|
-
* Shared history transport: live session, `sessionId` query param,
|
|
10643
|
-
* `X-Visitor-Token` header, one resolved proof, one-shot 401 recovery, and a
|
|
10644
|
-
* credential-revision guard that discards a response the store outran.
|
|
10645
|
-
*/
|
|
10646
|
-
private historyFetch;
|
|
10647
|
-
private assertHistoryUsable;
|
|
10648
10697
|
/** One page of the visitor's conversations, newest first. */
|
|
10649
10698
|
listConversations(opts?: {
|
|
10650
10699
|
cursor?: string;
|
|
@@ -10696,18 +10745,6 @@ declare class AgentWidgetClient {
|
|
|
10696
10745
|
* Send a message - handles both proxy and client token modes
|
|
10697
10746
|
*/
|
|
10698
10747
|
dispatch(options: DispatchOptions, onEvent: SSEHandler): Promise<void>;
|
|
10699
|
-
/**
|
|
10700
|
-
* Client token mode dispatch
|
|
10701
|
-
*/
|
|
10702
|
-
private dispatchClientToken;
|
|
10703
|
-
/**
|
|
10704
|
-
* Proxy mode dispatch (original implementation)
|
|
10705
|
-
*/
|
|
10706
|
-
private dispatchProxy;
|
|
10707
|
-
/**
|
|
10708
|
-
* Agent mode dispatch
|
|
10709
|
-
*/
|
|
10710
|
-
private dispatchAgent;
|
|
10711
10748
|
/**
|
|
10712
10749
|
* Process an external SSE stream through the SDK's event pipeline.
|
|
10713
10750
|
* This allows piping responses from endpoints like agent approval
|
|
@@ -10717,114 +10754,25 @@ declare class AgentWidgetClient {
|
|
|
10717
10754
|
/**
|
|
10718
10755
|
* Send an approval decision to the API and return the response
|
|
10719
10756
|
* for streaming continuation.
|
|
10757
|
+
*
|
|
10758
|
+
* Routes by mode:
|
|
10759
|
+
* - **client-token mode**: POST `${apiBase}/v1/client/approve` with the
|
|
10760
|
+
* active `sessionId` and no Bearer key (runtypelabs/core#9518). Answers a
|
|
10761
|
+
* gate authored `tools.approval.approver: 'end-user'`; the SSE body has
|
|
10762
|
+
* the same shape as `/v1/client/resume`.
|
|
10763
|
+
* - **dispatch / proxy mode**: POST `${apiBase}/v1/agents/{agentId}/approve`
|
|
10764
|
+
* with the host's headers.
|
|
10720
10765
|
*/
|
|
10721
10766
|
resolveApproval(approval: {
|
|
10722
10767
|
agentId: string;
|
|
10723
10768
|
executionId: string;
|
|
10724
10769
|
approvalId: string;
|
|
10725
10770
|
}, decision: 'approved' | 'denied'): Promise<Response>;
|
|
10726
|
-
/**
|
|
10727
|
-
* Resume a paused flow execution by supplying outputs for LOCAL
|
|
10728
|
-
* (client-executed) tools. Used by the built-in `ask_user_question`
|
|
10729
|
-
* answer-pill sheet, but generic enough for any LOCAL tool.
|
|
10730
|
-
*
|
|
10731
|
-
* Routes by mode:
|
|
10732
|
-
* - **client-token mode**: POST `${apiBase}/v1/client/resume` (the
|
|
10733
|
-
* session-authenticated sibling of `/v1/client/chat`; runtypelabs/core#3889),
|
|
10734
|
-
* with the active `sessionId` in the body and no Bearer key: a browser
|
|
10735
|
-
* client-token page holds no secret. The page's tool registry is
|
|
10736
|
-
* re-snapshotted and sent alongside `toolOutputs` via the same diff-only
|
|
10737
|
-
* `clientTools` / `clientToolsFingerprint` protocol as `/v1/client/chat`
|
|
10738
|
-
* (runtypelabs/core#5361), so tools registered by a mid-run page
|
|
10739
|
-
* navigation replace the run's dispatch-time set and become callable on
|
|
10740
|
-
* the next model turn. Old servers strip the unknown fields and keep the
|
|
10741
|
-
* frozen-at-dispatch behavior.
|
|
10742
|
-
* - **dispatch / proxy mode**: POST `${apiUrl}/resume`: Runtype mounts
|
|
10743
|
-
* resume as a child of `/v1/dispatch`, so the URL is `${apiUrl}/resume`,
|
|
10744
|
-
* and proxies follow the same shape (`/api/chat/dispatch/resume`).
|
|
10745
|
-
*
|
|
10746
|
-
* Returns the raw Response so the caller can pipe its SSE body through
|
|
10747
|
-
* `connectStream()`.
|
|
10748
|
-
*
|
|
10749
|
-
* @param executionId - The paused execution id carried on `await`.
|
|
10750
|
-
* @param toolOutputs - Map keyed by per-call `toolCallId` (core#3878),
|
|
10751
|
-
* falling back to tool name for legacy servers → the tool's result value.
|
|
10752
|
-
*/
|
|
10753
|
-
/**
|
|
10754
|
-
* Diff-only / send-once WebMCP clientTools transport, shared by the
|
|
10755
|
-
* client-token chat (`/v1/client/chat`) and resume (`/v1/client/resume`)
|
|
10756
|
-
* paths — both routes speak the same protocol (runtypelabs/core#5361).
|
|
10757
|
-
*
|
|
10758
|
-
* Decides, against the shared fingerprint cache, whether this request ships
|
|
10759
|
-
* the full `clientTools[]` + fingerprint (first send under this session, or
|
|
10760
|
-
* a changed set) or the fingerprint alone (unchanged set; the server reuses
|
|
10761
|
-
* its stored copy). Runs `doFetch` with the chosen fields and retries
|
|
10762
|
-
* EXACTLY once with the full array on a
|
|
10763
|
-
* `409 { error: 'client_tools_resend_required' }` registry miss — the retry
|
|
10764
|
-
* is 409-*triggered*, never 409-*expected*, so servers predating the
|
|
10765
|
-
* protocol (which strip the unknown fields and never 409) work unchanged.
|
|
10766
|
-
* The 409 body is probed on a `clone()` so the original response body stays
|
|
10767
|
-
* readable by the caller's error handling.
|
|
10768
|
-
*
|
|
10769
|
-
* The cache is NOT committed here: callers invoke the returned `commit()`
|
|
10770
|
-
* only after the server has accepted the request (response OK / stream
|
|
10771
|
-
* started), so a failed request can never record a fingerprint the server
|
|
10772
|
-
* never stored. A resend-required miss invalidates the cached fingerprint
|
|
10773
|
-
* immediately so later turns keep resending in full until a clean success
|
|
10774
|
-
* commits a fresh one.
|
|
10775
|
-
*
|
|
10776
|
-
* `emptyMeansReplace` (resume only): when the live snapshot is empty but a
|
|
10777
|
-
* non-empty set was committed under this session and never explicitly
|
|
10778
|
-
* cleared (the paused tool navigated to a page with no tool registry), ship
|
|
10779
|
-
* an explicit `clientTools: []` so the server REPLACES the persisted
|
|
10780
|
-
* dispatch-time set with nothing and clears its stored registry. Chat keeps
|
|
10781
|
-
* its omit-when-empty behavior: on `/chat`, absent fields already mean "no
|
|
10782
|
-
* tools this turn", whereas on `/resume` absence means "keep the frozen
|
|
10783
|
-
* dispatch-time set".
|
|
10784
|
-
*/
|
|
10785
|
-
private sendWithClientToolsDiff;
|
|
10786
10771
|
resumeFlow(executionId: string, toolOutputs: Record<string, unknown>, options?: {
|
|
10787
10772
|
streamResponse?: boolean;
|
|
10788
10773
|
signal?: AbortSignal;
|
|
10789
10774
|
after?: string;
|
|
10790
10775
|
}): Promise<Response>;
|
|
10791
|
-
/**
|
|
10792
|
-
* The opt-in structured mention channel: the MOST RECENT user turn's
|
|
10793
|
-
* `mentionContext` (set by `session.applyMentionBundle`) namespaced under
|
|
10794
|
-
* `mentions`. Only the latest user message is consulted — otherwise an older
|
|
10795
|
-
* turn's mentions would re-attach to `context.mentions` on every later send.
|
|
10796
|
-
* Returns null when the latest user turn carried no structured mention context.
|
|
10797
|
-
* The default model-visible path (`llmAppend`) already rode into the message's
|
|
10798
|
-
* `llmContent`/`contentParts`, so it needs nothing here.
|
|
10799
|
-
*/
|
|
10800
|
-
private latestMentionContext;
|
|
10801
|
-
/**
|
|
10802
|
-
* Aggregate request `context`: merge every context provider's result with the
|
|
10803
|
-
* opt-in mention context from the latest user turn. Returns null when nothing
|
|
10804
|
-
* contributed, so callers can skip setting `payload.context`. Shared by the
|
|
10805
|
-
* agent and flow payload builders.
|
|
10806
|
-
*/
|
|
10807
|
-
private buildContextAggregate;
|
|
10808
|
-
/**
|
|
10809
|
-
* Non-empty composer selections only. An empty snapshot leaves the field off
|
|
10810
|
-
* the wire entirely, so a widget with no picker and no modes sends exactly
|
|
10811
|
-
* what it sent before.
|
|
10812
|
-
*/
|
|
10813
|
-
private normalizeComposerOptions;
|
|
10814
|
-
/**
|
|
10815
|
-
* Rule 4: an inline client-defined agent may take the turn's model from the
|
|
10816
|
-
* composer, but only for an id the host actually declared in
|
|
10817
|
-
* `composer.models`. Config is untouched; the mapping is per request.
|
|
10818
|
-
*/
|
|
10819
|
-
private applyInlineAgentModel;
|
|
10820
|
-
private buildAgentPayload;
|
|
10821
|
-
private buildPayload;
|
|
10822
|
-
/**
|
|
10823
|
-
* Handle custom SSE event parsing via parseSSEEvent callback
|
|
10824
|
-
* Returns true if event was handled, false otherwise
|
|
10825
|
-
*/
|
|
10826
|
-
private handleCustomSSEEvent;
|
|
10827
|
-
private streamResponse;
|
|
10828
10776
|
}
|
|
10829
10777
|
|
|
10830
10778
|
/** The resolved bundle gathered at submit, merged into the user message. */
|
|
@@ -10898,6 +10846,7 @@ type SessionHistoryNotice = {
|
|
|
10898
10846
|
message: string;
|
|
10899
10847
|
};
|
|
10900
10848
|
declare class AgentWidgetSession {
|
|
10849
|
+
#private;
|
|
10901
10850
|
private config;
|
|
10902
10851
|
private callbacks;
|
|
10903
10852
|
private historyInternals;
|
|
@@ -10906,79 +10855,16 @@ declare class AgentWidgetSession {
|
|
|
10906
10855
|
private status;
|
|
10907
10856
|
private streaming;
|
|
10908
10857
|
private abortController;
|
|
10909
|
-
private sequenceCounter;
|
|
10910
10858
|
private clientSession;
|
|
10911
10859
|
private agentExecution;
|
|
10912
|
-
private resumable;
|
|
10913
|
-
private activeAssistantMessageId;
|
|
10914
|
-
private reconnecting;
|
|
10915
|
-
private reconnectController;
|
|
10916
|
-
private reconnectControllerPromise;
|
|
10917
|
-
private executionStateTimer;
|
|
10918
10860
|
private artifacts;
|
|
10919
|
-
private selectedArtifactId;
|
|
10920
10861
|
private webMcpInflightKeys;
|
|
10921
10862
|
private webMcpResolvedKeys;
|
|
10922
10863
|
private webMcpResolveControllers;
|
|
10923
|
-
private webMcpEpoch;
|
|
10924
10864
|
private webMcpApprovalResolvers;
|
|
10925
|
-
private
|
|
10865
|
+
private approvalTokens;
|
|
10926
10866
|
private webMcpAwaitBatches;
|
|
10927
|
-
private voiceProvider;
|
|
10928
|
-
/** In-flight setupVoice chunk load; toggleVoice awaits it when racing setup. */
|
|
10929
|
-
private voiceSetupPromise;
|
|
10930
|
-
/** Bumped by setupVoice/cleanupVoice so a stale chunk load can't install. */
|
|
10931
|
-
private voiceSetupGeneration;
|
|
10932
|
-
/** Latest 0..1 capture amplitude pushed by a provider that reports one. */
|
|
10933
|
-
private voiceLevel;
|
|
10934
|
-
private voiceActive;
|
|
10935
|
-
private voiceStatus;
|
|
10936
|
-
private activeConversationId;
|
|
10937
|
-
private activeConversationRevision;
|
|
10938
|
-
private historyNextMessageCursor;
|
|
10939
|
-
/** Monotonic: a later selection supersedes every earlier fetch/prepare. */
|
|
10940
|
-
private historyOpenEpoch;
|
|
10941
|
-
/** Blocks `setClientSession`'s welcome branch across a reopen re-init. */
|
|
10942
|
-
private suppressWelcomeInjection;
|
|
10943
|
-
private historyRecovery;
|
|
10944
|
-
private historySendBlocked;
|
|
10945
|
-
/** Continuity wipe / boot reconciliation; dispatch waits on it. */
|
|
10946
|
-
private historyGate;
|
|
10947
|
-
/** Deduped by `(id, cursor)` so repeated clicks issue one request. */
|
|
10948
|
-
private olderPageRequests;
|
|
10949
|
-
/** Serializes projection finalization against every other operation. */
|
|
10950
|
-
private projectionFinalizationPromise;
|
|
10951
|
-
/** Message id → projection the server has acknowledged (sent or finalized). */
|
|
10952
|
-
private acknowledgedProjections;
|
|
10953
|
-
private pendingProjections;
|
|
10954
|
-
/** Persisted revision as it stood before boot init overwrote it. */
|
|
10955
|
-
private bootConversationRevision;
|
|
10956
|
-
private bootRevisionCaptured;
|
|
10957
|
-
/** Exactly one visitor-store subscription per instance; re-keyed with the store. */
|
|
10958
|
-
private visitorStoreUnsubscribe;
|
|
10959
|
-
private subscribedVisitorStore;
|
|
10960
|
-
/** An external credential change happened; the next dispatch must re-init. */
|
|
10961
|
-
private credentialReinitPending;
|
|
10962
|
-
private credentialReinitPromise;
|
|
10963
10867
|
constructor(config: AgentWidgetConfig | undefined, callbacks: SessionCallbacks, historyInternals?: WidgetHistoryInternals);
|
|
10964
|
-
/**
|
|
10965
|
-
* Warm the deferred voice-runtime chunk (provider factory + providers) at
|
|
10966
|
-
* init when a voice provider is configured, so setupVoice / the first mic
|
|
10967
|
-
* click resolve against a warm module. Module fetch only — WebSocket and
|
|
10968
|
-
* AudioContext still wait for their own triggers. Errors are swallowed: the
|
|
10969
|
-
* setupVoice path retries via the chunk loader's rejection-retry.
|
|
10970
|
-
*/
|
|
10971
|
-
private prefetchVoiceRuntime;
|
|
10972
|
-
/**
|
|
10973
|
-
* Warm the deferred Runtype TTS engine chunk at init so it's resolved before
|
|
10974
|
-
* the first "Read aloud" click. Module fetch only — no AudioContext (that
|
|
10975
|
-
* still waits for the user gesture on first playback). In the IIFE/CDN build
|
|
10976
|
-
* this fetches the standalone `runtype-tts.js`; in bundler builds the module
|
|
10977
|
-
* is already inlined, so this is a cheap no-op. Errors are swallowed: a failed
|
|
10978
|
-
* prefetch just means the chunk loads on first click instead (or, on a hard
|
|
10979
|
-
* failure, the browser-voice fallback kicks in).
|
|
10980
|
-
*/
|
|
10981
|
-
private prefetchRuntypeTts;
|
|
10982
10868
|
/**
|
|
10983
10869
|
* Set callback for capturing raw SSE events (forwards to client)
|
|
10984
10870
|
*/
|
|
@@ -11011,6 +10897,8 @@ declare class AgentWidgetSession {
|
|
|
11011
10897
|
* Get current voice status
|
|
11012
10898
|
*/
|
|
11013
10899
|
getVoiceStatus(): VoiceStatus;
|
|
10900
|
+
/** The live call's AI-disclosure notice, if it shows one. */
|
|
10901
|
+
getVoiceDisclosure(): string | null;
|
|
11014
10902
|
/**
|
|
11015
10903
|
* Get the voice interruption mode from the provider (none/cancel/barge-in)
|
|
11016
10904
|
*/
|
|
@@ -11030,30 +10918,12 @@ declare class AgentWidgetSession {
|
|
|
11030
10918
|
isBargeInActive(): boolean;
|
|
11031
10919
|
/** Tear down the barge-in mic pipeline: "hang up" the always-on mic */
|
|
11032
10920
|
deactivateBargeIn(): Promise<void>;
|
|
11033
|
-
private pendingVoiceUserMessageId;
|
|
11034
|
-
private pendingVoiceAssistantMessageId;
|
|
11035
|
-
private voiceTurns;
|
|
11036
|
-
private voiceDisconnectPromise;
|
|
11037
10921
|
private ttsSpokenMessageIds;
|
|
11038
10922
|
private readAloud;
|
|
11039
|
-
/**
|
|
11040
|
-
* Resolve the speech engine behind read-aloud (and auto-speak):
|
|
11041
|
-
* 1. An explicit `textToSpeech.createEngine` always wins (full BYO control).
|
|
11042
|
-
* 2. `provider: 'runtype'` builds the hosted {@link RuntypeSpeechEngine}
|
|
11043
|
-
* from the widget config (host = `apiUrl`, `agentId`, `clientToken`),
|
|
11044
|
-
* wrapped in a browser {@link FallbackSpeechEngine} unless
|
|
11045
|
-
* `browserFallback: false` — so a missing endpoint or transient failure
|
|
11046
|
-
* degrades to the browser voice instead of erroring, and auto-upgrades to
|
|
11047
|
-
* Runtype voices the day the endpoint ships.
|
|
11048
|
-
* 3. Otherwise the browser Web Speech API engine.
|
|
11049
|
-
*/
|
|
11050
|
-
private createSpeechEngine;
|
|
11051
10923
|
/**
|
|
11052
10924
|
* Setup voice recognition with the given configuration
|
|
11053
10925
|
*/
|
|
11054
10926
|
setupVoice(config?: VoiceConfig): void;
|
|
11055
|
-
/** Wire callbacks onto a freshly constructed provider and connect it. */
|
|
11056
|
-
private wireVoiceProvider;
|
|
11057
10927
|
/**
|
|
11058
10928
|
* Toggle voice recognition on/off
|
|
11059
10929
|
*/
|
|
@@ -11069,8 +10939,6 @@ declare class AgentWidgetSession {
|
|
|
11069
10939
|
* Cleanup voice resources
|
|
11070
10940
|
*/
|
|
11071
10941
|
cleanupVoice(): void;
|
|
11072
|
-
private disconnectVoice;
|
|
11073
|
-
private settlePendingVoiceTurn;
|
|
11074
10942
|
/**
|
|
11075
10943
|
* Extract voice configuration from widget config
|
|
11076
10944
|
*/
|
|
@@ -11091,12 +10959,6 @@ declare class AgentWidgetSession {
|
|
|
11091
10959
|
* Set the client session after initialization
|
|
11092
10960
|
*/
|
|
11093
10961
|
setClientSession(session: ClientSession, pristine?: boolean): void;
|
|
11094
|
-
/**
|
|
11095
|
-
* Welcome injection is skipped while `suppressWelcomeInjection` is latched:
|
|
11096
|
-
* reopening a stored conversation is not a new thread, and the hydrated
|
|
11097
|
-
* transcript would otherwise race a welcome bubble.
|
|
11098
|
-
*/
|
|
11099
|
-
private injectWelcomeMessage;
|
|
11100
10962
|
/**
|
|
11101
10963
|
* Get current client session
|
|
11102
10964
|
*/
|
|
@@ -11145,26 +11007,10 @@ declare class AgentWidgetSession {
|
|
|
11145
11007
|
setHistoryInternals(internals: WidgetHistoryInternals): void;
|
|
11146
11008
|
/** Widget teardown: release the visitor-store subscription. */
|
|
11147
11009
|
destroy(): void;
|
|
11148
|
-
/**
|
|
11149
|
-
* The session always owns the continuity transition, whether or not the shell
|
|
11150
|
-
* supplied its own observer: a credential/record break must wipe local state
|
|
11151
|
-
* before the replacement session becomes sendable.
|
|
11152
|
-
*/
|
|
11153
|
-
private composeHistoryInternals;
|
|
11154
|
-
private get historyProvider();
|
|
11155
|
-
private requireHistoryProvider;
|
|
11156
|
-
/**
|
|
11157
|
-
* One resolved scope per logical action. An explicitly requested scope the
|
|
11158
|
-
* provider cannot serve fails locally rather than silently downgrading.
|
|
11159
|
-
*/
|
|
11160
|
-
private historyContext;
|
|
11161
11010
|
getHistoryState(): SessionHistoryState;
|
|
11162
11011
|
getActiveConversationId(): string | null;
|
|
11163
|
-
private emitHistoryState;
|
|
11164
|
-
private notifyHistory;
|
|
11165
11012
|
/** Pending destructive/reconciliation work every other operation waits on. */
|
|
11166
11013
|
awaitHistorySettled(): Promise<void>;
|
|
11167
|
-
private assertHistoryIdle;
|
|
11168
11014
|
listConversations(opts?: {
|
|
11169
11015
|
cursor?: string;
|
|
11170
11016
|
limit?: number;
|
|
@@ -11189,7 +11035,6 @@ declare class AgentWidgetSession {
|
|
|
11189
11035
|
loadOlderMessages(id: string, cursor?: string | null, opts?: {
|
|
11190
11036
|
scope?: HistoryScope;
|
|
11191
11037
|
}): Promise<HistoryOlderPage>;
|
|
11192
|
-
private fetchOlderPage;
|
|
11193
11038
|
/**
|
|
11194
11039
|
* The canonical new-thread operation. A failed prepare leaves the current
|
|
11195
11040
|
* conversation completely intact.
|
|
@@ -11197,11 +11042,6 @@ declare class AgentWidgetSession {
|
|
|
11197
11042
|
startNewConversation(opts?: {
|
|
11198
11043
|
scope?: HistoryScope;
|
|
11199
11044
|
}): Promise<void>;
|
|
11200
|
-
/**
|
|
11201
|
-
* Clear local + persisted conversation state, then commit the replacement.
|
|
11202
|
-
* Welcome injection is deliberately allowed once the transcript is empty.
|
|
11203
|
-
*/
|
|
11204
|
-
private installFreshConversation;
|
|
11205
11045
|
/**
|
|
11206
11046
|
* Deleting the active record (or everything) is already irreversible: the
|
|
11207
11047
|
* transcript is destroyed first, then a replacement session is prepared.
|
|
@@ -11228,60 +11068,12 @@ declare class AgentWidgetSession {
|
|
|
11228
11068
|
resetHistoryDevice(): Promise<{
|
|
11229
11069
|
remoteRevocationConfirmed: boolean;
|
|
11230
11070
|
}>;
|
|
11231
|
-
private recoverFromDestroyedConversation;
|
|
11232
|
-
/**
|
|
11233
|
-
* Never reinstalls the deleted session. A failed preparation leaves an
|
|
11234
|
-
* explicit recoverable state instead of the old transcript.
|
|
11235
|
-
*/
|
|
11236
|
-
private prepareReplacementConversation;
|
|
11237
|
-
/** The next explicit action retries a failed replacement preparation. */
|
|
11238
|
-
private retryRequiredConversation;
|
|
11239
|
-
/**
|
|
11240
|
-
* Install a prepared activation. The provider's commit also invokes the
|
|
11241
|
-
* session binding (`bindActivatedSession`); the fallback covers a shell that
|
|
11242
|
-
* has not wired that callback yet.
|
|
11243
|
-
*/
|
|
11244
|
-
private commitActivation;
|
|
11245
11071
|
/**
|
|
11246
11072
|
* Session-owned binding for a winning prepared activation. Installs the
|
|
11247
11073
|
* client session WITHOUT the ordinary welcome branch while the reopen latch
|
|
11248
11074
|
* is set, and persists the replacement ids through the normal storage path.
|
|
11249
11075
|
*/
|
|
11250
11076
|
bindActivatedSession(session: ClientSession): void;
|
|
11251
|
-
private persistConversationMetadata;
|
|
11252
|
-
/** Conversation-scoped caches that must not leak across records. */
|
|
11253
|
-
private resetConversationScopedState;
|
|
11254
|
-
/**
|
|
11255
|
-
* Irreversible local + persisted clear. Used by new-conversation, active
|
|
11256
|
-
* deletion, 410 recovery, reset, and the continuity wipe.
|
|
11257
|
-
*/
|
|
11258
|
-
private discardConversationState;
|
|
11259
|
-
/**
|
|
11260
|
-
* D6 continuity wipe (session side): a replacement visitor, identity rebind,
|
|
11261
|
-
* cross-tab convergence, or credential expiry selected a different record.
|
|
11262
|
-
* Invalidate synchronously; dispatch stays blocked until cleanup completes.
|
|
11263
|
-
*/
|
|
11264
|
-
private handleHistoryContinuityChanged;
|
|
11265
|
-
/**
|
|
11266
|
-
* One subscription per widget instance, re-keyed when the controller swaps
|
|
11267
|
-
* the store. Owned here so the transition sits beside the continuity wipe it
|
|
11268
|
-
* reuses.
|
|
11269
|
-
*/
|
|
11270
|
-
private syncVisitorStoreSubscription;
|
|
11271
|
-
/**
|
|
11272
|
-
* D3 privacy boundary: a sibling tab cleared or replaced the shared visitor
|
|
11273
|
-
* credential. Privacy wins over turn continuity, so a live turn is cancelled.
|
|
11274
|
-
* A "local" change is this tab's own mint/write and owns its init path; a
|
|
11275
|
-
* change out of an empty store is first-init convergence, not a break.
|
|
11276
|
-
*/
|
|
11277
|
-
private handleExternalCredentialChange;
|
|
11278
|
-
/**
|
|
11279
|
-
* Dispatch may not proceed until a session exists under the NEW credential.
|
|
11280
|
-
* Deliberately lazy: re-initializing on the storage event itself would hand
|
|
11281
|
-
* an idle tab a fresh credential the visitor just deleted elsewhere.
|
|
11282
|
-
*/
|
|
11283
|
-
private completeCredentialReinit;
|
|
11284
|
-
private runCredentialReinit;
|
|
11285
11077
|
/**
|
|
11286
11078
|
* Authoritative boot reconciliation (D4). Runs after a `conversationId` boot
|
|
11287
11079
|
* resume and before chat becomes sendable: an unchanged revision needs no
|
|
@@ -11291,47 +11083,11 @@ declare class AgentWidgetSession {
|
|
|
11291
11083
|
reconcileBootConversation(opts?: {
|
|
11292
11084
|
scope?: HistoryScope;
|
|
11293
11085
|
}): Promise<void>;
|
|
11294
|
-
private runBootReconciliation;
|
|
11295
|
-
/** Runtype transport op: active session + browser scope, never a proof. */
|
|
11296
|
-
private projectionFinalizationEnabled;
|
|
11297
|
-
private setPendingProjections;
|
|
11298
|
-
private readPendingProjections;
|
|
11299
|
-
/** Record what the dispatch payload carried as each message's projection. */
|
|
11300
|
-
private recordDispatchedProjections;
|
|
11301
|
-
/**
|
|
11302
|
-
* After a terminal assistant message, finalize any browser-derived projection
|
|
11303
|
-
* the server cannot have. Painting is never delayed by this.
|
|
11304
|
-
*/
|
|
11305
|
-
private scheduleProjectionFinalization;
|
|
11306
|
-
/** Serialized: operations await this chain instead of racing it. */
|
|
11307
|
-
private enqueueProjectionFinalization;
|
|
11308
|
-
private finalizeProjections;
|
|
11309
|
-
/** Transport-shaped failures only; a contract failure is not retried. */
|
|
11310
|
-
private isTransientProjectionError;
|
|
11311
|
-
private clearFinalizedMarker;
|
|
11312
11086
|
/**
|
|
11313
11087
|
* Boot replay: rebuild the batch from the persisted ids plus the local
|
|
11314
11088
|
* message content, then finalize before display reconciliation completes.
|
|
11315
11089
|
*/
|
|
11316
11090
|
replayPendingProjections(): Promise<void>;
|
|
11317
|
-
/**
|
|
11318
|
-
* A local transcript mutation whose response carries no new revision: clear
|
|
11319
|
-
* the persisted one rather than guessing, so the next boot refreshes safely.
|
|
11320
|
-
*/
|
|
11321
|
-
private invalidateConversationRevision;
|
|
11322
|
-
/** Blocks a send until the owning history transition finishes. */
|
|
11323
|
-
private awaitHistorySendable;
|
|
11324
|
-
private static isConversationDeleted;
|
|
11325
|
-
/**
|
|
11326
|
-
* Safe 410 recovery (D5). The old payload would recreate the transcript that
|
|
11327
|
-
* was just deleted, so the retry carries ONLY the just-submitted user turn.
|
|
11328
|
-
*/
|
|
11329
|
-
private dispatchWithDeletedRecovery;
|
|
11330
|
-
/**
|
|
11331
|
-
* Capture only the newly submitted user message, destroy the deleted record's
|
|
11332
|
-
* local state, and initialize a fresh owned conversation to retry into.
|
|
11333
|
-
*/
|
|
11334
|
-
private recoverFromDeletedConversation;
|
|
11335
11091
|
updateConfig(next: AgentWidgetConfig): void;
|
|
11336
11092
|
getMessages(): AgentWidgetMessage[];
|
|
11337
11093
|
getStatus(): AgentWidgetSessionStatus;
|
|
@@ -11428,15 +11184,6 @@ declare class AgentWidgetSession {
|
|
|
11428
11184
|
* });
|
|
11429
11185
|
*/
|
|
11430
11186
|
injectComponentDirective(options: InjectComponentDirectiveOptions): AgentWidgetMessage;
|
|
11431
|
-
/**
|
|
11432
|
-
* Resolve the gathered mentions and merge them into the user message's
|
|
11433
|
-
* model-visible content. Default path is `llmAppend` → `llmContent` (or a text
|
|
11434
|
-
* `contentPart` when parts are present, since `contentParts` wins the priority
|
|
11435
|
-
* chain); the opt-in structured `context` lands on `mentionContext` for the
|
|
11436
|
-
* client to namespace into the request `context`. Failures were already
|
|
11437
|
-
* dropped by `finalize()`.
|
|
11438
|
-
*/
|
|
11439
|
-
private applyMentionBundle;
|
|
11440
11187
|
sendMessage(rawInput: string, options?: {
|
|
11441
11188
|
viaVoice?: boolean;
|
|
11442
11189
|
/** Multi-modal content parts (e.g., images) to include with the message */
|
|
@@ -11481,6 +11228,15 @@ declare class AgentWidgetSession {
|
|
|
11481
11228
|
* (`composer.streamingSubmitBehavior: "interrupt"`).
|
|
11482
11229
|
*/
|
|
11483
11230
|
interrupt?: boolean;
|
|
11231
|
+
/**
|
|
11232
|
+
* Internal (voice client delegation): this is the delegated voice turn.
|
|
11233
|
+
* `userMessageId` names an existing transcript bubble to submit as the
|
|
11234
|
+
* turn's user message instead of appending a new one, so the spoken
|
|
11235
|
+
* request appears (and is sent) exactly once.
|
|
11236
|
+
*/
|
|
11237
|
+
voiceTurn?: {
|
|
11238
|
+
userMessageId?: string;
|
|
11239
|
+
};
|
|
11484
11240
|
}): Promise<void>;
|
|
11485
11241
|
/**
|
|
11486
11242
|
* Re-run the conversation from one user turn (docs/composer-gap-analysis.md
|
|
@@ -11504,8 +11260,6 @@ declare class AgentWidgetSession {
|
|
|
11504
11260
|
* turn would carry no content; nothing is truncated in that case.
|
|
11505
11261
|
*/
|
|
11506
11262
|
resubmitFrom(messageId: string, options: ComposerResubmitOptions): boolean;
|
|
11507
|
-
/** Submission options → the wire payload shape; quote travels separately. */
|
|
11508
|
-
private toComposerOptionsPayload;
|
|
11509
11263
|
/**
|
|
11510
11264
|
* Continue the conversation without adding a new user message.
|
|
11511
11265
|
* Triggers the model to respond based on the current conversation state.
|
|
@@ -11540,13 +11294,6 @@ declare class AgentWidgetSession {
|
|
|
11540
11294
|
*/
|
|
11541
11295
|
seedContent?: string;
|
|
11542
11296
|
}): Promise<void>;
|
|
11543
|
-
/**
|
|
11544
|
-
* Install the native approval-bubble confirm handler on the WebMCP bridge
|
|
11545
|
-
* when the integrator hasn't supplied a custom `webmcp.onConfirm`. Without
|
|
11546
|
-
* this, the bridge falls back to a blunt `window.confirm`. Safe to call
|
|
11547
|
-
* repeatedly (e.g. after the client is re-created in `updateConfig`).
|
|
11548
|
-
*/
|
|
11549
|
-
private wireDefaultWebMcpConfirm;
|
|
11550
11297
|
/**
|
|
11551
11298
|
* Default WebMCP confirm gate: render Persona's native in-panel approval
|
|
11552
11299
|
* bubble and resolve when the user clicks Approve/Deny. Returns immediately
|
|
@@ -11580,6 +11327,14 @@ declare class AgentWidgetSession {
|
|
|
11580
11327
|
* 3. Append a user-visible bubble with the answer text so the
|
|
11581
11328
|
* transcript reads naturally.
|
|
11582
11329
|
*/
|
|
11330
|
+
resolveAskUserQuestion(toolMessage: AgentWidgetMessage, answer: string | Record<string, string | string[]>): Promise<void>;
|
|
11331
|
+
/**
|
|
11332
|
+
* Resolve a paused auto-resolving LOCAL tool call (`webmcp:*` page tools
|
|
11333
|
+
* and the built-in `suggest_replies`) and post the result to `/resume`.
|
|
11334
|
+
* Triggered automatically from `handleEvent`; idempotent on the message's
|
|
11335
|
+
* `toolCall.id`. See `resolveWebMcpToolCall` in `session-actions.ts`.
|
|
11336
|
+
*/
|
|
11337
|
+
resolveWebMcpToolCall(toolMessage: AgentWidgetMessage): Promise<void>;
|
|
11583
11338
|
/**
|
|
11584
11339
|
* Persist in-progress answers and the current page index for a multi-question
|
|
11585
11340
|
* `ask_user_question` payload, so a refresh resumes on the same page with
|
|
@@ -11598,123 +11353,6 @@ declare class AgentWidgetSession {
|
|
|
11598
11353
|
* answers via top-level merge.
|
|
11599
11354
|
*/
|
|
11600
11355
|
markAskUserQuestionResolved(toolMessage: AgentWidgetMessage, answers?: Record<string, string | string[]>): void;
|
|
11601
|
-
resolveAskUserQuestion(toolMessage: AgentWidgetMessage, answer: string | Record<string, string | string[]>): Promise<void>;
|
|
11602
|
-
/**
|
|
11603
|
-
* Collect an auto-resolving LOCAL-tool `await` (`webmcp:*` page tools
|
|
11604
|
-
* and the built-in `suggest_replies`) into a per-executionId batch
|
|
11605
|
-
* and schedule a single deferred flush. Parallel calls (core#3878) emit
|
|
11606
|
-
* several `await`s for ONE paused execution within the same stream tick;
|
|
11607
|
-
* buffering them and flushing once lets us post ONE `/resume` keyed by the
|
|
11608
|
-
* per-call `webMcpToolCallId` rather than racing N name-keyed resumes on the
|
|
11609
|
-
* same execution (which 404'd on the second and hung the turn).
|
|
11610
|
-
*
|
|
11611
|
-
* Deferred via `queueMicrotask` (epoch-guarded) for the same reason the old
|
|
11612
|
-
* direct resolve was: handleEvent must return first so the dispatch's
|
|
11613
|
-
* `connectStream` sees end-of-stream and releases the shared abortController
|
|
11614
|
-
* before a resolve grabs it.
|
|
11615
|
-
*
|
|
11616
|
-
* Awaits without an `executionId` or `toolCall.id` can't be batched (no key)
|
|
11617
|
-
*: route them straight to the single-call path, which surfaces the malformed
|
|
11618
|
-
* wire shape via `onError` / an `isError` resume.
|
|
11619
|
-
*/
|
|
11620
|
-
private enqueueWebMcpAwait;
|
|
11621
|
-
/**
|
|
11622
|
-
* Flush every buffered local-tool await batch, one `/resume` per executionId.
|
|
11623
|
-
* Called once a stream ends (`status: idle` / `error`): by then all parallel
|
|
11624
|
-
* `await`s the stream carried have been collected, even if split across
|
|
11625
|
-
* SSE chunks. Deferred via `queueMicrotask` (epoch-guarded) so the idle
|
|
11626
|
-
* handler returns first and the stream's end-of-stream teardown (streaming /
|
|
11627
|
-
* abortController) settles before a resolve grabs them: the same ordering the
|
|
11628
|
-
* single-call resolve always relied on.
|
|
11629
|
-
*/
|
|
11630
|
-
private scheduleWebMcpBatchFlush;
|
|
11631
|
-
/**
|
|
11632
|
-
* Run a buffered batch of local-tool awaits for one executionId. Size 1
|
|
11633
|
-
* (single call, or distinct-tool turns that happened to arrive alone) takes
|
|
11634
|
-
* the original single-call path; size >1 (parallel calls) takes the batched
|
|
11635
|
-
* path that posts ONE `/resume`. The batch is removed from the map up front
|
|
11636
|
-
* so any later sibling re-emit (e.g. from a re-pause) forms a fresh batch
|
|
11637
|
-
* rather than mutating one already in flight.
|
|
11638
|
-
*/
|
|
11639
|
-
private flushWebMcpAwaitBatch;
|
|
11640
|
-
private resolveWebMcpToolStartedAt;
|
|
11641
|
-
/**
|
|
11642
|
-
* Persisted-resolution guard for `suggest_replies`. The in-memory dedupe
|
|
11643
|
-
* sets (`webMcpInflightKeys` / `webMcpResolvedKeys`) are cleared by
|
|
11644
|
-
* hydrateMessages/clearMessages/cancel, but `suggestRepliesResolved`
|
|
11645
|
-
* survives on the stored message, so a stale `await` re-emit after a
|
|
11646
|
-
* hydration must not re-POST `/resume` for an already-resolved call (the
|
|
11647
|
-
* historical double-resume failure mode the batching work exists to avoid).
|
|
11648
|
-
* Checks the LIVE message first; the handleEvent snapshot is a fresh wire
|
|
11649
|
-
* skeleton whose metadata never carries the flag.
|
|
11650
|
-
*/
|
|
11651
|
-
private isSuggestRepliesAlreadyResolved;
|
|
11652
|
-
private markWebMcpToolRunning;
|
|
11653
|
-
private markWebMcpToolComplete;
|
|
11654
|
-
/**
|
|
11655
|
-
* Resolve one or more parallel local-tool awaits sharing one paused
|
|
11656
|
-
* executionId with a SINGLE `/resume` (core#3878); `resolveWebMcpToolCall`
|
|
11657
|
-
* delegates size-1 resolves here after its guards. By default each call is
|
|
11658
|
-
* executed against the page registry concurrently: every gated call renders
|
|
11659
|
-
* its own native approval bubble, and a sibling's confirm Promise never
|
|
11660
|
-
* blocks another's execution. With `webmcp.execution: "sequential"` the
|
|
11661
|
-
* calls run one at a time in emission order instead (see the config docs
|
|
11662
|
-
* for when that matters). Outputs are keyed by per-call `webMcpToolCallId`
|
|
11663
|
-
* (server prefers it over tool name; name-keying remains the fallback for
|
|
11664
|
-
* legacy single/distinct-tool turns), so two calls to the SAME tool no longer
|
|
11665
|
-
* collide. The server is tolerant: any call we omit (declined-after-abort,
|
|
11666
|
-
* dedupe, exec failure) simply re-pauses and is retried on its re-emit.
|
|
11667
|
-
*
|
|
11668
|
-
* Owns the dedupe / abort / streaming machinery for both routes; resolved
|
|
11669
|
-
* keys are marked on the shared resume POST's HTTP OK.
|
|
11670
|
-
*/
|
|
11671
|
-
private resolveWebMcpToolCallBatch;
|
|
11672
|
-
/**
|
|
11673
|
-
* Resolve a paused auto-resolving LOCAL tool call and post the result to
|
|
11674
|
-
* `/resume`: `webmcp:*` calls execute against the host page's tool
|
|
11675
|
-
* registry; the built-in `suggest_replies` skips execution entirely and
|
|
11676
|
-
* resumes with a canned "shown" result (the chips render from the message
|
|
11677
|
-
* list, not from this resolve).
|
|
11678
|
-
*
|
|
11679
|
-
* Triggered automatically from `handleEvent` when an `await`-derived
|
|
11680
|
-
* message arrives for such a tool: the user does not click a pill; the
|
|
11681
|
-
* bridge's confirm-bubble gate (WebMCP only) is the only interactive
|
|
11682
|
-
* surface.
|
|
11683
|
-
*
|
|
11684
|
-
* Idempotent on the message's `toolCall.id`: re-emits of the same await
|
|
11685
|
-
* (e.g. from message coalescing) won't double-fire `tool.execute`. Failure
|
|
11686
|
-
* modes, declined, timed out, throw, unknown tool, all resolve into a
|
|
11687
|
-
* `{ isError: true, content: [...] }` payload that resumes the dispatch
|
|
11688
|
-
* cleanly so the agent can recover.
|
|
11689
|
-
*
|
|
11690
|
-
* After the malformed-wire guards this is a thin gate over
|
|
11691
|
-
* `resolveWebMcpToolCallBatch` with a size-1 batch: the dedupe check runs
|
|
11692
|
-
* synchronously here so a stale re-emit never toggles streaming.
|
|
11693
|
-
*/
|
|
11694
|
-
resolveWebMcpToolCall(toolMessage: AgentWidgetMessage): Promise<void>;
|
|
11695
|
-
/**
|
|
11696
|
-
* POST `/resume` with a SINGLE tool's output and pipe the resulting SSE
|
|
11697
|
-
* stream back through `connectStream`. Shared by every single-call local-tool
|
|
11698
|
-
* resolve path (ask_user_question and single WebMCP calls). Parallel WebMCP
|
|
11699
|
-
* calls use `resolveWebMcpToolCallBatch`, which posts one resume for many.
|
|
11700
|
-
*
|
|
11701
|
-
* `resumeKey` is the `toolOutputs` map key: the per-call `webMcpToolCallId`
|
|
11702
|
-
* for WebMCP (core#3878), or the tool name for ask_user_question / legacy
|
|
11703
|
-
* servers. `onHttpOk` runs synchronously between the HTTP-status check and the
|
|
11704
|
-
* stream pipe; it lets the WebMCP resolve path commit the dedupe flag at
|
|
11705
|
-
* "server accepted the answer" rather than "stream finished cleanly".
|
|
11706
|
-
*/
|
|
11707
|
-
private resumeWithToolOutput;
|
|
11708
|
-
/**
|
|
11709
|
-
* Tear down every in-flight WebMCP resolve and advance the epoch. Each
|
|
11710
|
-
* resolve owns a dedicated AbortController (chained/parallel resolves don't
|
|
11711
|
-
* share one), so we abort them individually; the aborts propagate into the
|
|
11712
|
-
* bridge's execute race and into each `/resume` fetch signal. Bumping
|
|
11713
|
-
* `webMcpEpoch` strands any resolve still deferred in a queued microtask: * it captured the prior epoch and bails before installing a fresh
|
|
11714
|
-
* controller, so it can't escape this teardown. Called from every stop /
|
|
11715
|
-
* new-turn boundary (cancel, clearMessages, hydrateMessages, sendMessage).
|
|
11716
|
-
*/
|
|
11717
|
-
private abortWebMcpResolves;
|
|
11718
11356
|
cancel(): void;
|
|
11719
11357
|
clearMessages(): void;
|
|
11720
11358
|
getArtifacts(): PersonaArtifactRecord[];
|
|
@@ -11723,68 +11361,9 @@ declare class AgentWidgetSession {
|
|
|
11723
11361
|
selectArtifact(id: string | null): void;
|
|
11724
11362
|
clearArtifacts(): void;
|
|
11725
11363
|
upsertArtifact(manual: PersonaArtifactManualUpsert): PersonaArtifactRecord;
|
|
11726
|
-
/**
|
|
11727
|
-
* Injects (or refreshes) the in-thread artifact block for a programmatically
|
|
11728
|
-
* upserted artifact, matching the streamed UX: the resolved display mode
|
|
11729
|
-
* picks the component ("collapsed"/"panel" → reference card, "inline" → inline
|
|
11730
|
-
* preview).
|
|
11731
|
-
*
|
|
11732
|
-
* Unlike the streamed path (which embeds content on `artifact_complete`),
|
|
11733
|
-
* the programmatic record is complete up front, so the final markdown /
|
|
11734
|
-
* file meta / component name + props are embedded immediately and the block
|
|
11735
|
-
* hydrates after a refresh without the original registry state.
|
|
11736
|
-
*
|
|
11737
|
-
* A re-upsert of the same id rebuilds the existing block's persisted
|
|
11738
|
-
* rawContent in place (the registry is not persisted, so hydration reads
|
|
11739
|
-
* these props); without this the block would keep the first version's
|
|
11740
|
-
* content after a refresh.
|
|
11741
|
-
*/
|
|
11742
|
-
private injectArtifactRefBlock;
|
|
11743
|
-
/**
|
|
11744
|
-
* Re-materialize existing transcript artifact blocks after a live display
|
|
11745
|
-
* preference update. One messages callback keeps conversion atomic.
|
|
11746
|
-
*/
|
|
11747
|
-
private refreshArtifactReferenceBlocks;
|
|
11748
|
-
private clearArtifactState;
|
|
11749
|
-
private emitArtifactsState;
|
|
11750
|
-
private applyArtifactStreamEvent;
|
|
11751
11364
|
hydrateMessages(messages: AgentWidgetMessage[]): void;
|
|
11752
11365
|
hydrateArtifacts(artifacts: PersonaArtifactRecord[], selectedId?: string | null): void;
|
|
11753
11366
|
private handleEvent;
|
|
11754
|
-
/**
|
|
11755
|
-
* Record the latest SSE `id:` cursor and (lazily) form/advance the resume
|
|
11756
|
-
* handle. Needs an executionId (lifted into `agentExecution` from the same
|
|
11757
|
-
* frame's metadata, handled before this trailing cursor event) and the active
|
|
11758
|
-
* assistant message id.
|
|
11759
|
-
*/
|
|
11760
|
-
private trackCursor;
|
|
11761
|
-
/**
|
|
11762
|
-
* The drop gate: is this stream-end a dropped connection we should reconnect,
|
|
11763
|
-
* rather than a graceful finish or an intentional `await` pause? ALL must
|
|
11764
|
-
* hold (see plan §Design overview keystone 3).
|
|
11765
|
-
*/
|
|
11766
|
-
private isDurableDrop;
|
|
11767
|
-
/**
|
|
11768
|
-
* True when the run is parked awaiting user input (an unanswered
|
|
11769
|
-
* `ask_user_question` / local-tool await, or a pending approval). Those end
|
|
11770
|
-
* the stream with `idle` and no terminal too, but are NOT drops.
|
|
11771
|
-
*/
|
|
11772
|
-
private isAwaitPending;
|
|
11773
|
-
/**
|
|
11774
|
-
* Enter the reconnect flow. Keeps the assistant bubble open and `streaming`
|
|
11775
|
-
* true, flips to `resuming`, and kicks the bounded backoff loop. Re-entrant
|
|
11776
|
-
* calls (a second drop while reconnecting) are no-ops.
|
|
11777
|
-
*/
|
|
11778
|
-
private beginReconnect;
|
|
11779
|
-
/**
|
|
11780
|
-
* Lazily import and instantiate the reconnect controller. Cached so repeated
|
|
11781
|
-
* reconnects reuse one controller (and one module load). Deliberately kept off
|
|
11782
|
-
* every hot path (`sendMessage` / `cancel` / `teardownReconnect`) so a widget
|
|
11783
|
-
* that never reconnects never pulls the chunk.
|
|
11784
|
-
*/
|
|
11785
|
-
private loadReconnectController;
|
|
11786
|
-
/** The narrow surface the lazily-loaded reconnect loop drives. */
|
|
11787
|
-
private buildReconnectHost;
|
|
11788
11367
|
/** Public manual retry (e.g. a "Reconnect" button). */
|
|
11789
11368
|
reconnectNow(): void;
|
|
11790
11369
|
/**
|
|
@@ -11796,34 +11375,13 @@ declare class AgentWidgetSession {
|
|
|
11796
11375
|
executionId: string;
|
|
11797
11376
|
after: string;
|
|
11798
11377
|
}): void;
|
|
11799
|
-
/**
|
|
11800
|
-
* Reopen the trailing assistant bubble (the persisted partial) so replayed
|
|
11801
|
-
* deltas append to it. Returns its id, or null if the last turn doesn't end
|
|
11802
|
-
* in a plain assistant message.
|
|
11803
|
-
*/
|
|
11804
|
-
private reopenTrailingAssistant;
|
|
11805
|
-
/**
|
|
11806
|
-
* Tear down any in-flight/pending reconnect and clear the resume handle. Runs
|
|
11807
|
-
* on every new turn / cancel / hydrate, so it must NOT pull the reconnect
|
|
11808
|
-
* chunk: it only delegates to the controller if one was already created.
|
|
11809
|
-
*/
|
|
11810
|
-
private teardownReconnect;
|
|
11811
|
-
/** Drop the resume handle and notify the host (`onExecutionState(null)`). */
|
|
11812
|
-
private clearResumable;
|
|
11813
|
-
/**
|
|
11814
|
-
* Surface the resume handle to the host for persistence. Immediate on
|
|
11815
|
-
* create/clear; trailing-edge throttled on cursor advances so it isn't called
|
|
11816
|
-
* per delta.
|
|
11817
|
-
*/
|
|
11818
|
-
private notifyExecutionState;
|
|
11819
11378
|
/** The current durable resume handle, if any (read-only). */
|
|
11820
11379
|
getResumableHandle(): ResumableHandle | null;
|
|
11821
|
-
private setStatus;
|
|
11822
|
-
private setStreaming;
|
|
11823
11380
|
/**
|
|
11824
11381
|
* Speak the latest assistant message using the Web Speech API
|
|
11825
11382
|
* if text-to-speech is enabled in the config.
|
|
11826
11383
|
*/
|
|
11384
|
+
/** `only`: speak it only if the latest assistant message is one of these. */
|
|
11827
11385
|
private speakLatestAssistantMessage;
|
|
11828
11386
|
/**
|
|
11829
11387
|
* Pick the best available English voice from a list of SpeechSynthesisVoices.
|
|
@@ -11847,11 +11405,7 @@ declare class AgentWidgetSession {
|
|
|
11847
11405
|
* Stop any in-progress text-to-speech / read-aloud playback.
|
|
11848
11406
|
*/
|
|
11849
11407
|
stopSpeaking(): void;
|
|
11850
|
-
private appendMessage;
|
|
11851
11408
|
private upsertMessage;
|
|
11852
|
-
private ensureSequence;
|
|
11853
|
-
private nextSequence;
|
|
11854
|
-
private sortMessages;
|
|
11855
11409
|
}
|
|
11856
11410
|
|
|
11857
11411
|
declare const formDefinitions: Record<string, {
|