@chatterfly/widget 0.2.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -15,6 +15,27 @@ declare class WidgetError {
15
15
  constructor(code: WidgetErrorCode, message: string);
16
16
  toString(): string;
17
17
  }
18
+ /**
19
+ * Config for the "click to start" gate (Phase 119.6b): the widget mounts but
20
+ * does not auto-start a run until the user clicks. `true` uses the default
21
+ * copy; pass an object to customize. Only meaningful for `workflowId` /
22
+ * `deploymentId` (serverless auto-start) embeds — ignored for direct `runId`
23
+ * connections.
24
+ */
25
+ interface ClickToStartConfig {
26
+ label?: string;
27
+ description?: string;
28
+ }
29
+ /**
30
+ * Config for the resume choice card (Phase 119.6b): shown instead of silently
31
+ * resuming when a persisted session exists. `true` uses the default copy;
32
+ * pass an object to customize.
33
+ */
34
+ interface ResumePromptConfig {
35
+ title?: string;
36
+ continueLabel?: string;
37
+ restartLabel?: string;
38
+ }
18
39
  /**
19
40
  * Imperative handle exposed via `ref` on `ChatterflyWidget` (Phase 114.1).
20
41
  * Lets host chrome trigger actions without prop churn — e.g. a "Start over"
@@ -97,8 +118,31 @@ interface WidgetConfig {
97
118
  * like `POST /api/v1/runs`. Ignored when connecting via `runId` directly.
98
119
  */
99
120
  initialInput?: Record<string, unknown>;
121
+ /**
122
+ * Tunes (or disables, via `"always-on"`) the dormancy/hibernation
123
+ * lifecycle. See `ConnectionPolicy`. Defaults apply when omitted.
124
+ */
125
+ connectionPolicy?: ConnectionPolicy | "always-on";
126
+ }
127
+ type RunStatus = "idle" | "connecting" | "replaying" | "running" | "awaiting_input" | "awaiting_voice" | "awaiting_form" | "awaiting_chat" | "awaiting_editor" | "completed" | "error" | "offline" | "expired";
128
+ /**
129
+ * Connection lifecycle tuning (Phase 119.4/119.5). Controls when an
130
+ * idle-at-input widget deliberately drops its socket ("dormant"), lazily
131
+ * polls for updates instead, and eventually stops polling entirely
132
+ * ("hibernating") until a wake trigger (focus, visibility, `sendMessage`,
133
+ * `submitHandback`, coming back online…). `"always-on"` disables all of
134
+ * this and keeps the socket held open like pre-119 widgets — use it for
135
+ * hosts that need instant push (e.g. multi-participant dashboards). See
136
+ * docs/plan/widget-connection-lifecycle.md.
137
+ */
138
+ interface ConnectionPolicy {
139
+ /** Idle time at a parked HITL input before deliberately disconnecting. Default 5 min. */
140
+ idleDisconnectMs?: number;
141
+ /** Poll interval while dormant. Default 45 s. */
142
+ pollIntervalMs?: number;
143
+ /** Additional dormant time before polling stops too (hibernating). Default 1 h. */
144
+ hibernateAfterMs?: number;
100
145
  }
101
- type RunStatus = "idle" | "connecting" | "replaying" | "running" | "awaiting_input" | "awaiting_voice" | "awaiting_form" | "awaiting_chat" | "awaiting_editor" | "completed" | "error" | "offline";
102
146
  interface ValidationRule {
103
147
  type: "required" | "min_length" | "max_length" | "min_selected" | "max_selected" | "min" | "max" | "pattern" | "email" | "url" | "phone" | "location" | "llm" | "and" | "or";
104
148
  value?: number | string;
@@ -280,13 +324,24 @@ interface WidgetStrings {
280
324
  statusErrorTitle: string;
281
325
  statusOfflineTitle: string;
282
326
  statusOfflineBody: string;
327
+ statusExpiredTitle: string;
328
+ statusExpiredBody: string;
283
329
  statusListening: string;
284
330
  resumingConversation: string;
331
+ reconnecting: string;
285
332
  conversationCompleted: string;
286
333
  somethingWentWrong: string;
287
334
  chatInputPlaceholder: string;
288
335
  sendButton: string;
289
336
  handBackButton: string;
337
+ converseDoneButton: string;
338
+ startConversation: string;
339
+ clickToStartDescription: string;
340
+ resumeTitle: string;
341
+ resumeContinue: string;
342
+ resumeRestart: string;
343
+ startNewConversation: string;
344
+ conversationEnded: string;
290
345
  }
291
346
  declare const defaultStrings: WidgetStrings;
292
347
  /** Merge a partial override on top of the defaults. */
@@ -372,9 +427,27 @@ interface ChatterflyWidgetProps extends Omit<WidgetConfig, "runId" | "participan
372
427
  * auto-start (`workflowId`/`deploymentId`) so a page refresh resumes the
373
428
  * existing run instead of minting a new one. `true` uses sessionStorage;
374
429
  * pass an options object to use localStorage or a custom key. Ignored for
375
- * direct `runId` embeds. Default `false`.
430
+ * direct `runId` embeds. Default `true` — pass `false` to opt out.
376
431
  */
377
432
  persistSession?: PersistSessionConfig;
433
+ /**
434
+ * Gate serverless auto-start (`workflowId`/`deploymentId`) behind a "Start
435
+ * conversation" button instead of minting a run on mount. `true` uses the
436
+ * default copy; pass an object to customize. Default `false`.
437
+ */
438
+ clickToStart?: boolean | ClickToStartConfig;
439
+ /**
440
+ * When a persisted session exists for an active (non-terminal) run, show a
441
+ * "Continue where you left off? / Start fresh" choice instead of silently
442
+ * resuming. Default `false` (silent resume).
443
+ */
444
+ resumePrompt?: boolean | ResumePromptConfig;
445
+ /**
446
+ * When a persisted session's run already reached a terminal state
447
+ * (completed/error), replay its history read-only with a "Start new
448
+ * conversation" CTA instead of auto-restarting. Default `true`.
449
+ */
450
+ showCompletedHistory?: boolean;
378
451
  /** `inline` (default, zero behavior change) | `floating` (docked launcher bubble + expandable panel). */
379
452
  mode?: "inline" | "floating";
380
453
  /** Where the launcher bubble docks in `floating` mode. Default `bottom-right`. */
@@ -784,7 +857,10 @@ interface UseChatterflyRunOptions extends Omit<WidgetConfig, "runId" | "particip
784
857
  runId?: string;
785
858
  /** Required alongside `runId`. */
786
859
  participantToken?: string;
787
- /** Persist the resolved session across page loads. See `PersistSessionConfig`. */
860
+ /**
861
+ * Persist the resolved session across page loads. See `PersistSessionConfig`.
862
+ * Default `true` — pass `false` to opt out.
863
+ */
788
864
  persistSession?: PersistSessionConfig;
789
865
  /** Firehose of every raw run event, in order. */
790
866
  onEvent?: (event: RunEvent) => void;
@@ -939,4 +1015,4 @@ declare function extractValue(transcript: string, field: FieldSpec): ExtractionR
939
1015
  */
940
1016
  declare function buildSpokenPrompt(field: FieldSpec, voiceHint?: string): string;
941
1017
 
942
- export { type BubbleComponents, type BubbleProps, ChatAdapter, type ChatAdapterProps, type ChatMessage, ChatTimeline, type ChatTimelineProps, ChatterflyWidget, type ChatterflyWidgetHandle, type ChatterflyWidgetProps, type ColorScheme, ConnectionOnboarding, type ConnectionOnboardingProps, type ContinuousVoiceSessionResult, type ContinuousVoiceState, type ExtractionResult, type FieldSpec, type HITLSession, InputBoolean, type InputComponentProps, InputDate, InputDisplay, InputFileUpload, InputLocation, InputMultiSelect, InputNumber, InputRating, InputSingleSelect, InputText, InputTextArea, type InputTypeProps, type LauncherPosition, type LiveSessionConfig, type LiveSessionResult, type LiveTranscript, type LiveVoiceState, type PersistSessionConfig, type PersistSessionOptions, type RecordingState, type RepeaterSpec, type RequiredConnection, type RunEvent, type RunStatus, type SessionRendererProps, type SynthState, type ThemeTokens, type TimelineEntry, type UseChatterflyRunOptions, type UseChatterflyRunResult, type UseParticipantConnectionsResult, type UseRunStreamResult, type UseSpeechSynthesisResult, type UseTranscribeResult, type UseVoiceRecorderResult, type ValidationError, type ValidationRule, VoiceContinuousRenderer, type VoiceContinuousRendererProps, VoiceLiveRenderer, type VoiceLiveRendererProps, VoiceOrb, type VoiceOrbProps, type VoiceOrbState, VoicePromptCard, type VoicePromptCardProps, VoiceRenderer, type VoiceRendererProps, type WidgetConfig, WidgetError, type WidgetErrorCode, type WidgetStrings, buildSpokenPrompt, defaultStrings, extractValue, getInputComponent, registerInputType, registerSessionRenderer, resolveInputType, resolveSessionRenderer, resolveStrings, useChatterflyRun, useContinuousVoiceSession, useGeminiLiveSession, useParticipantConnections, useRunStream, useSpeechSynthesis, useTranscribe, useVoiceRecorder };
1018
+ export { type BubbleComponents, type BubbleProps, ChatAdapter, type ChatAdapterProps, type ChatMessage, ChatTimeline, type ChatTimelineProps, ChatterflyWidget, type ChatterflyWidgetHandle, type ChatterflyWidgetProps, type ClickToStartConfig, type ColorScheme, ConnectionOnboarding, type ConnectionOnboardingProps, type ConnectionPolicy, type ContinuousVoiceSessionResult, type ContinuousVoiceState, type ExtractionResult, type FieldSpec, type HITLSession, InputBoolean, type InputComponentProps, InputDate, InputDisplay, InputFileUpload, InputLocation, InputMultiSelect, InputNumber, InputRating, InputSingleSelect, InputText, InputTextArea, type InputTypeProps, type LauncherPosition, type LiveSessionConfig, type LiveSessionResult, type LiveTranscript, type LiveVoiceState, type PersistSessionConfig, type PersistSessionOptions, type RecordingState, type RepeaterSpec, type RequiredConnection, type ResumePromptConfig, type RunEvent, type RunStatus, type SessionRendererProps, type SynthState, type ThemeTokens, type TimelineEntry, type UseChatterflyRunOptions, type UseChatterflyRunResult, type UseParticipantConnectionsResult, type UseRunStreamResult, type UseSpeechSynthesisResult, type UseTranscribeResult, type UseVoiceRecorderResult, type ValidationError, type ValidationRule, VoiceContinuousRenderer, type VoiceContinuousRendererProps, VoiceLiveRenderer, type VoiceLiveRendererProps, VoiceOrb, type VoiceOrbProps, type VoiceOrbState, VoicePromptCard, type VoicePromptCardProps, VoiceRenderer, type VoiceRendererProps, type WidgetConfig, WidgetError, type WidgetErrorCode, type WidgetStrings, buildSpokenPrompt, defaultStrings, extractValue, getInputComponent, registerInputType, registerSessionRenderer, resolveInputType, resolveSessionRenderer, resolveStrings, useChatterflyRun, useContinuousVoiceSession, useGeminiLiveSession, useParticipantConnections, useRunStream, useSpeechSynthesis, useTranscribe, useVoiceRecorder };
package/dist/index.d.ts CHANGED
@@ -15,6 +15,27 @@ declare class WidgetError {
15
15
  constructor(code: WidgetErrorCode, message: string);
16
16
  toString(): string;
17
17
  }
18
+ /**
19
+ * Config for the "click to start" gate (Phase 119.6b): the widget mounts but
20
+ * does not auto-start a run until the user clicks. `true` uses the default
21
+ * copy; pass an object to customize. Only meaningful for `workflowId` /
22
+ * `deploymentId` (serverless auto-start) embeds — ignored for direct `runId`
23
+ * connections.
24
+ */
25
+ interface ClickToStartConfig {
26
+ label?: string;
27
+ description?: string;
28
+ }
29
+ /**
30
+ * Config for the resume choice card (Phase 119.6b): shown instead of silently
31
+ * resuming when a persisted session exists. `true` uses the default copy;
32
+ * pass an object to customize.
33
+ */
34
+ interface ResumePromptConfig {
35
+ title?: string;
36
+ continueLabel?: string;
37
+ restartLabel?: string;
38
+ }
18
39
  /**
19
40
  * Imperative handle exposed via `ref` on `ChatterflyWidget` (Phase 114.1).
20
41
  * Lets host chrome trigger actions without prop churn — e.g. a "Start over"
@@ -97,8 +118,31 @@ interface WidgetConfig {
97
118
  * like `POST /api/v1/runs`. Ignored when connecting via `runId` directly.
98
119
  */
99
120
  initialInput?: Record<string, unknown>;
121
+ /**
122
+ * Tunes (or disables, via `"always-on"`) the dormancy/hibernation
123
+ * lifecycle. See `ConnectionPolicy`. Defaults apply when omitted.
124
+ */
125
+ connectionPolicy?: ConnectionPolicy | "always-on";
126
+ }
127
+ type RunStatus = "idle" | "connecting" | "replaying" | "running" | "awaiting_input" | "awaiting_voice" | "awaiting_form" | "awaiting_chat" | "awaiting_editor" | "completed" | "error" | "offline" | "expired";
128
+ /**
129
+ * Connection lifecycle tuning (Phase 119.4/119.5). Controls when an
130
+ * idle-at-input widget deliberately drops its socket ("dormant"), lazily
131
+ * polls for updates instead, and eventually stops polling entirely
132
+ * ("hibernating") until a wake trigger (focus, visibility, `sendMessage`,
133
+ * `submitHandback`, coming back online…). `"always-on"` disables all of
134
+ * this and keeps the socket held open like pre-119 widgets — use it for
135
+ * hosts that need instant push (e.g. multi-participant dashboards). See
136
+ * docs/plan/widget-connection-lifecycle.md.
137
+ */
138
+ interface ConnectionPolicy {
139
+ /** Idle time at a parked HITL input before deliberately disconnecting. Default 5 min. */
140
+ idleDisconnectMs?: number;
141
+ /** Poll interval while dormant. Default 45 s. */
142
+ pollIntervalMs?: number;
143
+ /** Additional dormant time before polling stops too (hibernating). Default 1 h. */
144
+ hibernateAfterMs?: number;
100
145
  }
101
- type RunStatus = "idle" | "connecting" | "replaying" | "running" | "awaiting_input" | "awaiting_voice" | "awaiting_form" | "awaiting_chat" | "awaiting_editor" | "completed" | "error" | "offline";
102
146
  interface ValidationRule {
103
147
  type: "required" | "min_length" | "max_length" | "min_selected" | "max_selected" | "min" | "max" | "pattern" | "email" | "url" | "phone" | "location" | "llm" | "and" | "or";
104
148
  value?: number | string;
@@ -280,13 +324,24 @@ interface WidgetStrings {
280
324
  statusErrorTitle: string;
281
325
  statusOfflineTitle: string;
282
326
  statusOfflineBody: string;
327
+ statusExpiredTitle: string;
328
+ statusExpiredBody: string;
283
329
  statusListening: string;
284
330
  resumingConversation: string;
331
+ reconnecting: string;
285
332
  conversationCompleted: string;
286
333
  somethingWentWrong: string;
287
334
  chatInputPlaceholder: string;
288
335
  sendButton: string;
289
336
  handBackButton: string;
337
+ converseDoneButton: string;
338
+ startConversation: string;
339
+ clickToStartDescription: string;
340
+ resumeTitle: string;
341
+ resumeContinue: string;
342
+ resumeRestart: string;
343
+ startNewConversation: string;
344
+ conversationEnded: string;
290
345
  }
291
346
  declare const defaultStrings: WidgetStrings;
292
347
  /** Merge a partial override on top of the defaults. */
@@ -372,9 +427,27 @@ interface ChatterflyWidgetProps extends Omit<WidgetConfig, "runId" | "participan
372
427
  * auto-start (`workflowId`/`deploymentId`) so a page refresh resumes the
373
428
  * existing run instead of minting a new one. `true` uses sessionStorage;
374
429
  * pass an options object to use localStorage or a custom key. Ignored for
375
- * direct `runId` embeds. Default `false`.
430
+ * direct `runId` embeds. Default `true` — pass `false` to opt out.
376
431
  */
377
432
  persistSession?: PersistSessionConfig;
433
+ /**
434
+ * Gate serverless auto-start (`workflowId`/`deploymentId`) behind a "Start
435
+ * conversation" button instead of minting a run on mount. `true` uses the
436
+ * default copy; pass an object to customize. Default `false`.
437
+ */
438
+ clickToStart?: boolean | ClickToStartConfig;
439
+ /**
440
+ * When a persisted session exists for an active (non-terminal) run, show a
441
+ * "Continue where you left off? / Start fresh" choice instead of silently
442
+ * resuming. Default `false` (silent resume).
443
+ */
444
+ resumePrompt?: boolean | ResumePromptConfig;
445
+ /**
446
+ * When a persisted session's run already reached a terminal state
447
+ * (completed/error), replay its history read-only with a "Start new
448
+ * conversation" CTA instead of auto-restarting. Default `true`.
449
+ */
450
+ showCompletedHistory?: boolean;
378
451
  /** `inline` (default, zero behavior change) | `floating` (docked launcher bubble + expandable panel). */
379
452
  mode?: "inline" | "floating";
380
453
  /** Where the launcher bubble docks in `floating` mode. Default `bottom-right`. */
@@ -784,7 +857,10 @@ interface UseChatterflyRunOptions extends Omit<WidgetConfig, "runId" | "particip
784
857
  runId?: string;
785
858
  /** Required alongside `runId`. */
786
859
  participantToken?: string;
787
- /** Persist the resolved session across page loads. See `PersistSessionConfig`. */
860
+ /**
861
+ * Persist the resolved session across page loads. See `PersistSessionConfig`.
862
+ * Default `true` — pass `false` to opt out.
863
+ */
788
864
  persistSession?: PersistSessionConfig;
789
865
  /** Firehose of every raw run event, in order. */
790
866
  onEvent?: (event: RunEvent) => void;
@@ -939,4 +1015,4 @@ declare function extractValue(transcript: string, field: FieldSpec): ExtractionR
939
1015
  */
940
1016
  declare function buildSpokenPrompt(field: FieldSpec, voiceHint?: string): string;
941
1017
 
942
- export { type BubbleComponents, type BubbleProps, ChatAdapter, type ChatAdapterProps, type ChatMessage, ChatTimeline, type ChatTimelineProps, ChatterflyWidget, type ChatterflyWidgetHandle, type ChatterflyWidgetProps, type ColorScheme, ConnectionOnboarding, type ConnectionOnboardingProps, type ContinuousVoiceSessionResult, type ContinuousVoiceState, type ExtractionResult, type FieldSpec, type HITLSession, InputBoolean, type InputComponentProps, InputDate, InputDisplay, InputFileUpload, InputLocation, InputMultiSelect, InputNumber, InputRating, InputSingleSelect, InputText, InputTextArea, type InputTypeProps, type LauncherPosition, type LiveSessionConfig, type LiveSessionResult, type LiveTranscript, type LiveVoiceState, type PersistSessionConfig, type PersistSessionOptions, type RecordingState, type RepeaterSpec, type RequiredConnection, type RunEvent, type RunStatus, type SessionRendererProps, type SynthState, type ThemeTokens, type TimelineEntry, type UseChatterflyRunOptions, type UseChatterflyRunResult, type UseParticipantConnectionsResult, type UseRunStreamResult, type UseSpeechSynthesisResult, type UseTranscribeResult, type UseVoiceRecorderResult, type ValidationError, type ValidationRule, VoiceContinuousRenderer, type VoiceContinuousRendererProps, VoiceLiveRenderer, type VoiceLiveRendererProps, VoiceOrb, type VoiceOrbProps, type VoiceOrbState, VoicePromptCard, type VoicePromptCardProps, VoiceRenderer, type VoiceRendererProps, type WidgetConfig, WidgetError, type WidgetErrorCode, type WidgetStrings, buildSpokenPrompt, defaultStrings, extractValue, getInputComponent, registerInputType, registerSessionRenderer, resolveInputType, resolveSessionRenderer, resolveStrings, useChatterflyRun, useContinuousVoiceSession, useGeminiLiveSession, useParticipantConnections, useRunStream, useSpeechSynthesis, useTranscribe, useVoiceRecorder };
1018
+ export { type BubbleComponents, type BubbleProps, ChatAdapter, type ChatAdapterProps, type ChatMessage, ChatTimeline, type ChatTimelineProps, ChatterflyWidget, type ChatterflyWidgetHandle, type ChatterflyWidgetProps, type ClickToStartConfig, type ColorScheme, ConnectionOnboarding, type ConnectionOnboardingProps, type ConnectionPolicy, type ContinuousVoiceSessionResult, type ContinuousVoiceState, type ExtractionResult, type FieldSpec, type HITLSession, InputBoolean, type InputComponentProps, InputDate, InputDisplay, InputFileUpload, InputLocation, InputMultiSelect, InputNumber, InputRating, InputSingleSelect, InputText, InputTextArea, type InputTypeProps, type LauncherPosition, type LiveSessionConfig, type LiveSessionResult, type LiveTranscript, type LiveVoiceState, type PersistSessionConfig, type PersistSessionOptions, type RecordingState, type RepeaterSpec, type RequiredConnection, type ResumePromptConfig, type RunEvent, type RunStatus, type SessionRendererProps, type SynthState, type ThemeTokens, type TimelineEntry, type UseChatterflyRunOptions, type UseChatterflyRunResult, type UseParticipantConnectionsResult, type UseRunStreamResult, type UseSpeechSynthesisResult, type UseTranscribeResult, type UseVoiceRecorderResult, type ValidationError, type ValidationRule, VoiceContinuousRenderer, type VoiceContinuousRendererProps, VoiceLiveRenderer, type VoiceLiveRendererProps, VoiceOrb, type VoiceOrbProps, type VoiceOrbState, VoicePromptCard, type VoicePromptCardProps, VoiceRenderer, type VoiceRendererProps, type WidgetConfig, WidgetError, type WidgetErrorCode, type WidgetStrings, buildSpokenPrompt, defaultStrings, extractValue, getInputComponent, registerInputType, registerSessionRenderer, resolveInputType, resolveSessionRenderer, resolveStrings, useChatterflyRun, useContinuousVoiceSession, useGeminiLiveSession, useParticipantConnections, useRunStream, useSpeechSynthesis, useTranscribe, useVoiceRecorder };