@mcp-b/embedded-agent 0.0.6 → 0.0.7-beta.1

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.ts CHANGED
@@ -1,914 +1,8 @@
1
- import { AssistantRuntime, ThreadMessageLike, ToolCallMessagePartComponent } from "@assistant-ui/react";
2
- import { UIDataTypes, UIMessage, UITools } from "ai";
3
- import * as react0 from "react";
4
- import { ComponentPropsWithRef, FC, HTMLAttributes, ReactNode } from "react";
5
- import { Client } from "@modelcontextprotocol/sdk/client/index.js";
6
- import { Tool } from "@modelcontextprotocol/sdk/types.js";
7
- import * as react_jsx_runtime19 from "react/jsx-runtime";
8
- import { ClassValue } from "clsx";
9
- import { VariantProps } from "class-variance-authority";
10
- import * as TooltipPrimitive from "@radix-ui/react-tooltip";
11
- import * as AvatarPrimitive from "@radix-ui/react-avatar";
12
- import * as DialogPrimitive from "@radix-ui/react-dialog";
13
- import * as ScrollAreaPrimitive from "@radix-ui/react-scroll-area";
14
- import * as SeparatorPrimitive from "@radix-ui/react-separator";
15
- import { CallToolResult, GetPromptResult, MCPConnectionState, MCPSource, MCPSourceConfig, Prompt, ReadResourceResult, Resource, ResourceTemplate, SamplingHandler, Tool as Tool$1, ToolWithSource } from "@mcp-b/cloud-mirror-types";
16
- import * as class_variance_authority_types0 from "class-variance-authority/types";
17
- import { AgentChatState, PendingTool } from "@mcp-b/agents";
18
- import { Transport } from "@modelcontextprotocol/sdk/shared/transport.js";
1
+ import { FC } from "react";
2
+ import { Todo } from "@mcp-b/cloud-mirror-types";
19
3
 
20
- //#region src/core/providers/AgentProvider.d.ts
21
-
22
- interface AgentProviderProps {
23
- children: ReactNode;
24
- /** API base URL for your WebMCP worker */
25
- apiBase?: string;
26
- /** Voice mode token endpoint (defaults to {apiBase}/api/realtime/session) */
27
- tokenEndpoint?: string;
28
- /** Auto-connect to local MCP source (default: true) */
29
- autoConnectLocal?: boolean;
30
- /** Callback when MCP tools change */
31
- onToolsChange?: (tools: ToolWithSource[]) => void;
32
- /** Callback when voice mode errors */
33
- onVoiceError?: (error: string) => void;
34
- /** Callback when voice mode connects */
35
- onVoiceConnect?: () => void;
36
- /** Callback when voice mode disconnects */
37
- onVoiceDisconnect?: (duration: number) => void;
38
- }
39
- /**
40
- * Unified provider for all agent capabilities.
41
- *
42
- * Provides:
43
- * - MCP tool registry and execution
44
- * - Chat runtime (via @assistant-ui/react)
45
- * - Voice mode (if tokenEndpoint is configured)
46
- *
47
- * Use the `useAgent` hook to access agent state and capabilities.
48
- */
49
- declare const AgentProvider: FC<AgentProviderProps>;
50
- //#endregion
51
- //#region src/providers/MCPToolsProvider.d.ts
52
- /** Well-known source IDs */
53
- declare const SOURCE_LOCAL = "local";
54
- declare const SOURCE_REMOTE = "remote";
55
- /**
56
- * MCP Tools Context Value
57
- */
58
- interface MCPToolsContextValue {
59
- /** All tools from all sources, tagged with _sourceId */
60
- tools: ToolWithSource[];
61
- /** All sources and their states */
62
- sources: Map<string, MCPSource>;
63
- /** Add a new source */
64
- addSource: (id: string, config: MCPSourceConfig) => Promise<void>;
65
- /** Remove a source */
66
- removeSource: (id: string) => Promise<void>;
67
- /** Get a specific source */
68
- getSource: (id: string) => MCPSource | undefined;
69
- /** Check if a source is connected */
70
- isConnected: (id: string) => boolean;
71
- /** Call a tool (auto-routes based on tool name lookup) */
72
- callTool: (name: string, args: Record<string, unknown>) => Promise<CallToolResult>;
73
- /** Call a tool on a specific source */
74
- callToolOnSource: (sourceId: string, name: string, args: Record<string, unknown>) => Promise<CallToolResult>;
75
- }
76
- interface MCPToolsProviderProps {
77
- children: ReactNode;
78
- /** Auto-connect to same-tab source on mount (default: true) */
79
- autoConnectLocal?: boolean;
80
- /** Callback when tools change */
81
- onToolsChange?: (tools: ToolWithSource[]) => void;
82
- }
83
- declare function MCPToolsProvider({
84
- children,
85
- autoConnectLocal,
86
- onToolsChange
87
- }: MCPToolsProviderProps): react_jsx_runtime19.JSX.Element;
88
- /**
89
- * Hook to access MCP Tools context
90
- */
91
- declare function useMCPTools(): MCPToolsContextValue;
92
- /**
93
- * Hook to optionally access MCP Tools context
94
- */
95
- declare function useOptionalMCPTools(): MCPToolsContextValue | null;
96
- //#endregion
97
- //#region src/services/realtime/types.d.ts
98
- /**
99
- * Types for OpenAI Realtime API integration
100
- */
101
- interface RealtimeConfig {
102
- model?: string;
103
- voice?: string;
104
- apiUrl?: string;
105
- tokenEndpoint?: string;
106
- }
107
- interface RealtimeSession {
108
- pc: RTCPeerConnection;
109
- dataChannel: RTCDataChannel;
110
- audioElement: HTMLAudioElement;
111
- localStream: MediaStream | null;
112
- remoteStream: MediaStream | null;
113
- cleanup: () => void;
114
- }
115
- type EventCallback = (data: unknown) => void;
116
- interface AudioLevelData {
117
- micLevel: number;
118
- micFrequency: number[];
119
- speakerLevel: number;
120
- speakerFrequency: number[];
121
- }
122
- interface TranscriptData {
123
- type: 'user' | 'assistant';
124
- text: string;
125
- isDone: boolean;
126
- }
127
- interface ToolCallData {
128
- status: 'started' | 'completed';
129
- toolName: string;
130
- error?: string;
131
- }
132
- interface VoiceModeState {
133
- isActive: boolean;
134
- isConnecting: boolean;
135
- isMuted: boolean;
136
- isError: boolean;
137
- connectionState: string;
138
- audioLevel?: AudioLevelData;
139
- transcript?: TranscriptData;
140
- toolCall?: ToolCallData;
141
- error?: string;
142
- }
143
- /**
144
- * Session state event data from the realtime service
145
- */
146
- interface SessionStateEventData {
147
- state: 'connecting' | 'connected' | 'disconnected' | 'error';
148
- isActive: boolean;
149
- isMuted: boolean;
150
- durationSeconds?: number;
151
- }
152
- /**
153
- * User transcript event data
154
- */
155
- interface UserTranscriptEventData {
156
- text: string;
157
- }
158
- /**
159
- * Assistant transcript streaming event data
160
- */
161
- interface AssistantTranscriptEventData {
162
- delta?: string;
163
- transcript?: string;
164
- }
165
- /**
166
- * Tool call started event data
167
- */
168
- interface ToolCallStartedEventData {
169
- name: string;
170
- }
171
- /**
172
- * Tool call completed event data
173
- */
174
- interface ToolCallCompletedEventData {
175
- name: string;
176
- error?: string;
177
- }
178
- /**
179
- * Error event data
180
- */
181
- interface ErrorEventData {
182
- error?: string;
183
- message?: string;
184
- type?: string;
185
- }
186
- /**
187
- * Type guard for SessionStateEventData
188
- */
189
- declare function isSessionStateEventData(data: unknown): data is SessionStateEventData;
190
- /**
191
- * Type guard for UserTranscriptEventData
192
- */
193
- declare function isUserTranscriptEventData(data: unknown): data is UserTranscriptEventData;
194
- /**
195
- * Type guard for AssistantTranscriptEventData
196
- */
197
- declare function isAssistantTranscriptEventData(data: unknown): data is AssistantTranscriptEventData;
198
- /**
199
- * Type guard for ToolCallStartedEventData
200
- */
201
- declare function isToolCallStartedEventData(data: unknown): data is ToolCallStartedEventData;
202
- /**
203
- * Type guard for ToolCallCompletedEventData
204
- */
205
- declare function isToolCallCompletedEventData(data: unknown): data is ToolCallCompletedEventData;
206
- /**
207
- * Type guard for ErrorEventData
208
- */
209
- declare function isErrorEventData(data: unknown): data is ErrorEventData;
210
- /**
211
- * Type guard for AudioLevelData
212
- */
213
- declare function isAudioLevelData(data: unknown): data is AudioLevelData;
214
- //#endregion
215
- //#region src/services/realtime/tool-manager.d.ts
216
- interface RegisteredTool {
217
- name: string;
218
- description: string;
219
- inputSchema?: Record<string, unknown>;
220
- }
221
- type ToolExecutor = (name: string, args: Record<string, unknown>) => Promise<unknown>;
222
- //#endregion
223
- //#region src/services/realtime/openai-realtime-service.d.ts
224
- /**
225
- * OpenAI Realtime API Service
226
- *
227
- * Manages voice conversations with OpenAI's Realtime API,
228
- * including WebRTC connections, tool integration, and message handling.
229
- */
230
- declare class OpenAIRealtimeService {
231
- private session;
232
- private webrtcManager;
233
- private toolManager;
234
- private messageHandler;
235
- private eventEmitter;
236
- private muted;
237
- private lastState;
238
- private localAnalyzer;
239
- private remoteAnalyzer;
240
- private visualizationInterval;
241
- private sessionStartTime;
242
- private onToolsChangedCallback;
243
- constructor(tokenEndpoint: string);
244
- /**
245
- * Set the tools available for the voice session
246
- */
247
- setTools(tools: RegisteredTool[]): void;
248
- /**
249
- * Set the tool executor function
250
- */
251
- setToolExecutor(executor: ToolExecutor): void;
252
- /**
253
- * Register callback for when tools change
254
- */
255
- onToolsChanged(callback: () => void): void;
256
- /**
257
- * Start a new realtime session
258
- */
259
- startSession(config?: RealtimeConfig): Promise<RealtimeSession>;
260
- /**
261
- * Stop the current session
262
- */
263
- stopSession(): void;
264
- /**
265
- * Send a text message to the assistant
266
- */
267
- sendUserMessage(text: string): void;
268
- /**
269
- * Check if session is active
270
- */
271
- isSessionActive(): boolean;
272
- /**
273
- * Get the local audio stream
274
- */
275
- getLocalStream(): MediaStream | null;
276
- /**
277
- * Get the remote audio stream
278
- */
279
- getRemoteStream(): MediaStream | null;
280
- /**
281
- * Toggle audio mute
282
- */
283
- toggleMute(muted: boolean): void;
284
- /**
285
- * Event handling
286
- */
287
- on(event: string, callback: EventCallback): void;
288
- off(event: string, callback: EventCallback): void;
289
- getSessionStatus(): {
290
- state: 'connecting' | 'connected' | 'disconnected' | 'error';
291
- isActive: boolean;
292
- isMuted: boolean;
293
- };
294
- /**
295
- * Private methods
296
- */
297
- private setupDataChannel;
298
- private setupPeerConnectionMonitoring;
299
- private configureSession;
300
- private updateSessionTools;
301
- private getSessionInstructions;
302
- private handleSessionError;
303
- private initializeLocalAnalyzer;
304
- private initializeRemoteAnalyzer;
305
- private startAudioVisualization;
306
- private emitSessionState;
307
- }
308
- //#endregion
309
- //#region src/hooks/useVoiceMode.d.ts
310
- interface UseVoiceModeOptions {
311
- /** Endpoint to get ephemeral tokens from */
312
- tokenEndpoint: string;
313
- /** Tools available for the voice session */
314
- tools?: RegisteredTool[];
315
- /** Tool executor function */
316
- toolExecutor?: ToolExecutor;
317
- /** Callback when session connects */
318
- onConnect?: () => void;
319
- /** Callback when session disconnects */
320
- onDisconnect?: (durationSeconds: number) => void;
321
- /** Callback when error occurs */
322
- onError?: (error: string) => void;
323
- /** Callback when user transcript is complete */
324
- onUserTranscript?: (text: string) => void;
325
- /** Callback when assistant transcript is complete */
326
- onAssistantTranscript?: (text: string) => void;
327
- }
328
- interface UseVoiceModeReturn extends VoiceModeState {
329
- /** Start voice session */
330
- startSession: (config?: RealtimeConfig) => Promise<void>;
331
- /** Stop voice session */
332
- stopSession: () => void;
333
- /** Toggle microphone mute */
334
- toggleMute: (muted?: boolean) => void;
335
- /** Send text message while in voice mode */
336
- sendMessage: (text: string) => void;
337
- }
338
- declare function useVoiceMode(options: UseVoiceModeOptions): UseVoiceModeReturn;
339
- //#endregion
340
- //#region src/providers/VoiceModeProvider.d.ts
341
- /**
342
- * Voice Mode Provider
343
- *
344
- * Provides voice mode state and controls to the component tree.
345
- */
346
- interface VoiceModeContextValue extends UseVoiceModeReturn {
347
- isSupported: boolean;
348
- }
349
- interface VoiceModeProviderProps {
350
- children: ReactNode;
351
- /** Backend endpoint for ephemeral tokens */
352
- tokenEndpoint: string;
353
- /** Tools available for voice mode */
354
- tools?: RegisteredTool[];
355
- /** Tool executor function */
356
- toolExecutor?: ToolExecutor;
357
- /** Callback when session connects */
358
- onConnect?: () => void;
359
- /** Callback when session disconnects */
360
- onDisconnect?: (durationSeconds: number) => void;
361
- /** Callback when error occurs */
362
- onError?: (error: string) => void;
363
- /** Callback when user transcript is complete */
364
- onUserTranscript?: (text: string) => void;
365
- /** Callback when assistant transcript is complete */
366
- onAssistantTranscript?: (text: string) => void;
367
- }
368
- declare function VoiceModeProvider({
369
- children,
370
- tokenEndpoint,
371
- tools,
372
- toolExecutor,
373
- onConnect,
374
- onDisconnect,
375
- onError,
376
- onUserTranscript,
377
- onAssistantTranscript
378
- }: VoiceModeProviderProps): react_jsx_runtime19.JSX.Element;
379
- /**
380
- * Hook to access voice mode context
381
- */
382
- declare function useVoiceModeContext(): VoiceModeContextValue;
383
- /**
384
- * Hook to optionally access voice mode context (returns null if not in provider)
385
- */
386
- declare function useOptionalVoiceModeContext(): VoiceModeContextValue | null;
387
- //#endregion
388
- //#region src/hooks/useActions.d.ts
389
- /**
390
- * Represents a single action derived from a tool call
391
- */
392
- interface Action {
393
- id: string;
394
- label: string;
395
- toolName: string;
396
- status: 'queued' | 'running' | 'success' | 'error';
397
- args?: unknown;
398
- result?: unknown;
399
- error?: string;
400
- startedAt?: number;
401
- duration?: number;
402
- }
403
- /**
404
- * Humanize a tool name for display
405
- * e.g., "search_files" -> "Searching files"
406
- * e.g., "readFile" -> "Reading file"
407
- */
408
- declare function humanizeToolName(toolName: string, isRunning?: boolean): string;
409
- /**
410
- * Hook to derive actions from the current thread's tool calls
411
- *
412
- * Actions are a view of tool calls - not separate state.
413
- * This maintains compatibility with assistant-ui's data model.
414
- */
415
- declare function useActions(): Action[];
416
- /**
417
- * Hook to get the current running action (if any)
418
- */
419
- declare function useCurrentAction(): Action | null;
420
- /**
421
- * Hook to get recently completed actions
422
- */
423
- declare function useRecentActions(limit?: number): Action[];
424
- /**
425
- * Hook to get action summary stats
426
- */
427
- declare function useActionStats(): {
428
- total: number;
429
- completed: number;
430
- running: number;
431
- failed: number;
432
- };
433
- //#endregion
434
- //#region src/hooks/useVoiceSummary.d.ts
435
- /**
436
- * Voice Summary Hook
437
- *
438
- * Tracks the last assistant response from voice mode for display as a summary.
439
- * Maintains the summary for a short time after the voice session ends.
440
- */
441
- interface VoiceSummary {
442
- text: string;
443
- timestamp: number;
444
- }
445
- /**
446
- * Hook to get the latest voice session summary
447
- * Returns the last assistant transcript from the voice session
448
- */
449
- declare function useVoiceSummary(): VoiceSummary | null;
450
- /**
451
- * Hook to check if there's a recent voice summary to display
452
- */
453
- declare function useHasVoiceSummary(): boolean;
454
- //#endregion
455
- //#region src/core/hooks/useAgent.d.ts
456
- /**
457
- * Voice mode state and controls
458
- */
459
- interface AgentVoice {
460
- /** Whether voice session is active */
461
- isActive: boolean;
462
- /** Whether voice is connecting */
463
- isConnecting: boolean;
464
- /** Whether there's an error */
465
- isError: boolean;
466
- /** Whether microphone is muted */
467
- isMuted: boolean;
468
- /** Current error message */
469
- error?: string;
470
- /** Real-time audio levels (mic and speaker) */
471
- audioLevel?: AudioLevelData;
472
- /** Current transcript (user or assistant) */
473
- transcript?: TranscriptData;
474
- /** Current tool call being executed */
475
- toolCall?: ToolCallData;
476
- /** Start voice session */
477
- start: () => Promise<void>;
478
- /** Stop voice session */
479
- stop: () => void;
480
- /** Toggle microphone mute */
481
- toggleMute: (muted?: boolean) => void;
482
- /** Send text message while in voice mode */
483
- sendMessage: (text: string) => void;
484
- }
485
- /**
486
- * MCP tools state and controls
487
- */
488
- interface AgentTools {
489
- /** All available tools */
490
- list: ToolWithSource[];
491
- /** Call a tool by name */
492
- call: (name: string, args: Record<string, unknown>) => Promise<CallToolResult>;
493
- }
494
- /**
495
- * Agent state and controls returned by useAgent
496
- */
497
- interface AgentState {
498
- /** All messages in the thread */
499
- messages: ReadonlyArray<{
500
- id: string;
501
- role: 'user' | 'assistant' | 'system';
502
- content: readonly unknown[];
503
- status?: {
504
- type: string;
505
- };
506
- }>;
507
- /** Whether the agent is currently processing */
508
- isRunning: boolean;
509
- /** Whether thread has any messages */
510
- hasMessages: boolean;
511
- /** All actions derived from tool calls */
512
- actions: Action[];
513
- /** Currently running action (if any) */
514
- currentAction: Action | null;
515
- /** Recently completed actions */
516
- recentActions: Action[];
517
- /** Actions from voice mode (when voice is active) */
518
- voiceActions: Action[];
519
- /** Active actions - voice actions when voice is active, otherwise text actions */
520
- activeActions: Action[];
521
- /** Latest assistant summary (from text or voice) */
522
- summary: string | null;
523
- /** Voice summary (after voice session ends) */
524
- voiceSummary: VoiceSummary | null;
525
- voice: AgentVoice | null;
526
- tools: AgentTools | null;
527
- /** Whether voice mode is currently active */
528
- isVoiceActive: boolean;
529
- }
530
- /**
531
- * Main agent hook - provides unified access to all agent capabilities
532
- */
533
- declare function useAgent(): AgentState;
534
- /**
535
- * Hook to check if agent is available (inside AgentProvider)
536
- */
537
- declare function useIsAgentAvailable(): boolean;
538
- //#endregion
539
- //#region src/hooks/useVoiceActions.d.ts
540
- declare function useVoiceActions(): Action[];
541
- /**
542
- * Hook to get the current running voice action (if any)
543
- */
544
- declare function useCurrentVoiceAction(): Action | null;
545
- /**
546
- * Hook to get recently completed voice actions
547
- */
548
- declare function useRecentVoiceActions(limit?: number): Action[];
549
- //#endregion
550
- //#region src/lib/constants.d.ts
551
- /**
552
- * Shared Constants
553
- *
554
- * Centralized location for all magic numbers, timeouts, and configuration values.
555
- * Having these in one place makes the codebase more maintainable and easier to tune.
556
- */
557
- /** Maximum number of reconnection attempts before giving up */
558
- declare const MCP_MAX_RECONNECT_ATTEMPTS = 5;
559
- /** Base delay in milliseconds for exponential backoff reconnection */
560
- declare const MCP_BASE_RECONNECT_DELAY_MS = 1000;
561
- /** Maximum reconnect delay in milliseconds (caps exponential backoff) */
562
- declare const MCP_MAX_RECONNECT_DELAY_MS = 30000;
563
- /** Delay before auto-connecting to tab-based MCP sources (allows server initialization) */
564
- declare const MCP_TAB_CONNECT_DELAY_MS = 100;
565
- /** Number of frequency bins for audio visualization */
566
- declare const AUDIO_FREQUENCY_BINS = 32;
567
- /** Default OpenAI Realtime model */
568
- declare const REALTIME_DEFAULT_MODEL = "gpt-4o-realtime-preview-2024-12-17";
569
- /** Default voice for OpenAI Realtime */
570
- declare const REALTIME_DEFAULT_VOICE = "verse";
571
- /** Default OpenAI Realtime API URL */
572
- declare const REALTIME_DEFAULT_API_URL = "https://api.openai.com/v1/realtime";
573
- /** Duration to retain voice actions after session ends (for display) */
574
- declare const VOICE_ACTIONS_RETENTION_MS = 3000;
575
- /** Duration to retain voice summary after session ends */
576
- declare const VOICE_SUMMARY_RETENTION_MS = 30000;
577
- /**
578
- * Enable debug logging for development.
579
- * Can be enabled by setting window.__WEBMCP_DEBUG__ = true in the browser console.
580
- * In production builds, this defaults to false.
581
- */
582
- declare const DEBUG_LOGGING_ENABLED: boolean;
583
- /**
584
- * Conditional debug logger that only logs when DEBUG_LOGGING_ENABLED is true.
585
- * Can be enabled at runtime by setting window.__WEBMCP_DEBUG__ = true
586
- *
587
- * @param component - The component or service name for the log prefix
588
- * @param message - The log message
589
- * @param data - Optional data to include in the log
590
- */
591
- declare function debugLog(component: string, message: string, data?: unknown): void;
592
- //#endregion
593
- //#region src/components/pill/AgentPill.d.ts
594
- /** Position of the pill on screen */
595
- type PillPosition = 'bottom-center' | 'bottom-right';
596
- interface AgentPillProps {
597
- /** Position of the pill on screen */
598
- position?: PillPosition;
599
- /** Callback when history button is clicked */
600
- onOpenHistory?: () => void;
601
- /** Show voice button in composer */
602
- showVoiceButton?: boolean;
603
- /** Voice mode active state */
604
- isVoiceActive?: boolean;
605
- /** Voice toggle callback */
606
- onVoiceToggle?: () => void;
607
- /** Auto-collapse after inactivity (default: true) */
608
- autoCollapse?: boolean;
609
- /** Additional class name */
610
- className?: string;
611
- }
612
- /**
613
- * Action-first agent pill UI.
614
- *
615
- * A compact, morphing interface that shows:
616
- * - Current activity when agent is working
617
- * - Action list (collapsible)
618
- * - Summary when complete
619
- * - Input composer
620
- *
621
- * Uses assistant-ui primitives for data binding.
622
- */
623
- declare const AgentPill: FC<AgentPillProps>;
624
- //#endregion
625
- //#region src/components/pill/PillContainer.d.ts
626
- type PillMode = 'collapsed' | 'hovered' | 'composing' | 'active' | 'expanded';
627
- interface PillContainerProps {
628
- mode: PillMode;
629
- children: ReactNode;
630
- onModeChange?: (mode: PillMode) => void;
631
- className?: string;
632
- }
633
- /**
634
- * Morphing container that changes size and shape based on state.
635
- * Uses spring animations for smooth, natural transitions.
636
- *
637
- * States:
638
- * - collapsed: Tiny 4px tall bar (ambient)
639
- * - hovered: Medium pill with prompt
640
- * - composing: User is typing
641
- * - active: Agent is working
642
- * - expanded: Full panel with summary/forms
643
- */
644
- declare const PillContainer: FC<PillContainerProps>;
645
- //#endregion
646
- //#region src/components/pill/PillComposer.d.ts
647
- interface PillComposerProps {
648
- placeholder?: string;
649
- showVoiceButton?: boolean;
650
- isVoiceActive?: boolean;
651
- onVoiceToggle?: () => void;
652
- showCharCount?: boolean;
653
- className?: string;
654
- }
655
- /**
656
- * Compact composer for the pill UI.
657
- * Uses assistant-ui primitives for data binding.
658
- * Features auto-growing textarea and character count.
659
- */
660
- declare const PillComposer: FC<PillComposerProps>;
661
- /**
662
- * Minimal composer for collapsed/hovered states
663
- * Just shows a clickable prompt
664
- */
665
- declare const MinimalComposer: FC<{
666
- onClick: () => void;
667
- className?: string;
668
- }>;
669
- //#endregion
670
- //#region src/components/pill/ToolStatusBorder.d.ts
671
- type ToolBorderStatus = 'idle' | 'calling' | 'success' | 'error';
672
- interface ToolStatusBorderProps {
673
- status: ToolBorderStatus;
674
- children: ReactNode;
675
- className?: string;
676
- borderRadius?: string;
677
- }
678
- /**
679
- * Minimal animated border for tool execution status.
680
- *
681
- * - idle/success: clean, no border (success is the default state)
682
- * - calling: subtle animated gradient
683
- * - error: brief red flash with shake
684
- */
685
- declare const ToolStatusBorder: FC<ToolStatusBorderProps>;
686
- //#endregion
687
- //#region src/components/pill/PillVoice.d.ts
688
- interface PillVoiceProps {
689
- /** Callback when voice mode ends */
690
- onEnd?: () => void;
691
- /** Whether to show a compact version */
692
- compact?: boolean;
693
- /** Additional class name */
694
- className?: string;
695
- }
696
- /**
697
- * Convert voice mode tool call status to border status
698
- */
699
-
700
- /**
701
- * Compact voice mode UI for the pill.
702
- * Shows waveforms, controls, and transcript preview.
703
- * Uses motion animations for smooth transitions.
704
- */
705
- declare const PillVoice: FC<PillVoiceProps>;
706
- /**
707
- * Hook to get voice border status for the pill container
708
- */
709
- declare function useVoiceBorderStatus(): ToolBorderStatus;
710
- //#endregion
711
- //#region src/components/pill/HistorySidebar.d.ts
712
- /**
713
- * Represents a conversation in history
714
- */
715
- interface Conversation {
716
- id: string;
717
- title: string;
718
- preview: string;
719
- timestamp: Date;
720
- messageCount: number;
721
- }
722
- interface HistorySidebarProps {
723
- isOpen: boolean;
724
- onClose: () => void;
725
- conversations?: Conversation[];
726
- selectedId?: string | null;
727
- onSelectConversation?: (id: string) => void;
728
- className?: string;
729
- }
730
- /**
731
- * Sidebar panel showing conversation history and full thread view.
732
- * Opens from the right side of the screen.
733
- */
734
- declare const HistorySidebar: FC<HistorySidebarProps>;
735
- //#endregion
736
- //#region src/components/assistant-modal.d.ts
737
- declare const AssistantModal: FC;
738
- //#endregion
739
- //#region src/components/Thread.d.ts
740
- declare const Thread: FC;
741
- //#endregion
742
- //#region src/components/Composer.d.ts
743
- declare const Composer: FC;
744
- //#endregion
745
- //#region src/components/thread-with-voice.d.ts
746
- declare const ThreadWithVoice: FC;
747
- //#endregion
748
- //#region src/components/UserMessage.d.ts
749
- declare const UserMessage: FC;
750
- //#endregion
751
- //#region src/components/AssistantMessage.d.ts
752
- declare const AssistantMessage: FC;
753
- //#endregion
754
- //#region src/components/pill/ActionList.d.ts
755
- interface ActionListProps {
756
- actions: Action[];
757
- defaultCollapsed?: boolean;
758
- className?: string;
759
- }
760
- /**
761
- * Collapsible list of all actions (tool calls) in the current conversation.
762
- * Shows count in header, expands to show full list with status icons.
763
- */
764
- declare const ActionList: FC<ActionListProps>;
765
- /**
766
- * Compact inline action summary (for collapsed pill states)
767
- */
768
- declare const ActionSummary: FC<{
769
- actions: Action[];
770
- className?: string;
771
- }>;
772
- //#endregion
773
- //#region src/components/pill/CurrentActivity.d.ts
774
- interface CurrentActivityProps {
775
- currentAction: Action | null;
776
- recentActions?: Action[];
777
- showRecent?: boolean;
778
- className?: string;
779
- }
780
- /**
781
- * Displays the current action the agent is performing,
782
- * with optional recent completed steps shown below.
783
- */
784
- declare const CurrentActivity: FC<CurrentActivityProps>;
785
- interface ActionStatusIconProps {
786
- status: Action['status'];
787
- size?: 'sm' | 'md';
788
- className?: string;
789
- }
790
- /**
791
- * Icon component for action status
792
- */
793
- declare const ActionStatusIcon: FC<ActionStatusIconProps>;
794
- /**
795
- * Idle state indicator when no actions are running
796
- */
797
- declare const IdleIndicator: FC<{
798
- className?: string;
799
- }>;
800
- //#endregion
801
- //#region src/components/pill/SummaryBlock.d.ts
802
- interface SummaryBlockProps {
803
- summary: string;
804
- isSuccess?: boolean;
805
- isError?: boolean;
806
- actions?: QuickAction[];
807
- className?: string;
808
- }
809
- interface QuickAction {
810
- label: string;
811
- onClick: () => void;
812
- variant?: 'primary' | 'secondary';
813
- }
814
- /**
815
- * Summary block showing the agent's synthesized output.
816
- * Displayed after task completion instead of token streaming.
817
- * Uses compact styling with max-height and scrolling for long responses.
818
- */
819
- declare const SummaryBlock: FC<SummaryBlockProps>;
820
- /**
821
- * Hook to get the latest summary from the thread
822
- * Returns the last text content from the last assistant message
823
- */
824
- declare function useLatestSummary(): string | null;
825
- /**
826
- * Welcome message for empty state
827
- */
828
- declare const WelcomeMessage: FC<{
829
- className?: string;
830
- }>;
831
- /**
832
- * Wrapper for conditional content based on thread state
833
- */
834
- declare const ThreadContent: FC<{
835
- empty: ReactNode;
836
- running: ReactNode;
837
- complete: ReactNode;
838
- }>;
839
- //#endregion
840
- //#region src/components/live-waveform.d.ts
841
- type LiveWaveformProps = HTMLAttributes<HTMLDivElement> & {
842
- active?: boolean;
843
- processing?: boolean;
844
- barWidth?: number;
845
- barGap?: number;
846
- barRadius?: number;
847
- barColor?: string;
848
- fadeEdges?: boolean;
849
- fadeWidth?: number;
850
- height?: string | number;
851
- sensitivity?: number;
852
- smoothingTimeConstant?: number;
853
- mode?: 'scrolling' | 'static';
854
- /** Manual audio level (0-1) instead of using microphone */
855
- manualAudioLevel?: number;
856
- };
857
- declare const LiveWaveform: ({
858
- active,
859
- processing,
860
- barWidth,
861
- barGap,
862
- barRadius,
863
- barColor,
864
- fadeEdges,
865
- fadeWidth,
866
- height,
867
- sensitivity,
868
- mode,
869
- manualAudioLevel,
870
- className,
871
- ...props
872
- }: LiveWaveformProps) => react_jsx_runtime19.JSX.Element;
873
- //#endregion
874
- //#region src/components/voice-indicator.d.ts
875
- interface VoiceIndicatorProps {
876
- isActive: boolean;
877
- isConnecting: boolean;
878
- isMuted: boolean;
879
- audioLevel?: AudioLevelData;
880
- toolCall?: ToolCallData;
881
- onStart: () => void;
882
- onStop: () => void;
883
- onToggleMute: () => void;
884
- className?: string;
885
- }
886
- declare function VoiceIndicator({
887
- isActive,
888
- isConnecting,
889
- isMuted,
890
- audioLevel,
891
- toolCall,
892
- onStart,
893
- onStop,
894
- onToggleMute,
895
- className
896
- }: VoiceIndicatorProps): react_jsx_runtime19.JSX.Element;
897
- //#endregion
898
- //#region src/components/pill/PillMarkdown.d.ts
899
- interface PillMarkdownProps {
900
- content: string;
901
- className?: string;
902
- /** Compact mode uses smaller text and tighter spacing */
903
- compact?: boolean;
904
- }
905
- /**
906
- * Markdown component for rendering content within pill UI.
907
- * Supports GitHub-flavored markdown with compact styling option.
908
- */
909
- declare const PillMarkdown: FC<PillMarkdownProps>;
910
- //#endregion
911
4
  //#region src/web-component.d.ts
5
+
912
6
  /** View mode for the agent UI */
913
7
  type AgentViewMode = 'pill' | 'modal';
914
8
  /**
@@ -932,6 +26,12 @@ interface EmbeddedAgentProps {
932
26
  autoConnectLocal?: boolean;
933
27
  /** UI view mode: 'pill' (action-first) or 'modal' (traditional chat) */
934
28
  viewMode?: AgentViewMode;
29
+ /** Enable planning tools (updateTodosTool, askForPlanApprovalTool) (default: true) */
30
+ enablePlanning?: boolean;
31
+ /** Initial todos for the planning provider */
32
+ initialTodos?: Todo[];
33
+ /** Callback when planning todos change */
34
+ onTodosChange?: (todos: Todo[]) => void;
935
35
  /** Callback when tools are updated */
936
36
  onToolsChange?: (tools: unknown[]) => void;
937
37
  /** Callback when voice mode errors */
@@ -952,13 +52,6 @@ interface EmbeddedAgentProps {
952
52
  * Can be used as a React component or converted to a web component.
953
53
  */
954
54
  declare const EmbeddedAgent: FC<EmbeddedAgentProps>;
955
- /**
956
- * Web Component Definition
957
- *
958
- * Converts EmbeddedAgent to a custom element that can be used in any HTML page.
959
- * Attributes are automatically converted from kebab-case to camelCase props.
960
- */
961
- declare const WebMCPAgentElement: CustomElementConstructor;
962
55
  /**
963
56
  * Register the custom element
964
57
  *
@@ -968,723 +61,5 @@ declare const WebMCPAgentElement: CustomElementConstructor;
968
61
  */
969
62
  declare function registerWebMCPAgent(tagName?: string): void;
970
63
  //#endregion
971
- //#region src/components/markdown-text.d.ts
972
- declare const MarkdownText: react0.MemoExoticComponent<() => react_jsx_runtime19.JSX.Element>;
973
- //#endregion
974
- //#region src/components/tool-fallback.d.ts
975
- declare const ToolFallback: ToolCallMessagePartComponent;
976
- //#endregion
977
- //#region src/components/attachment.d.ts
978
- declare const UserMessageAttachments: FC;
979
- declare const ComposerAttachments: FC;
980
- declare const ComposerAddAttachment: FC;
981
- //#endregion
982
- //#region src/components/realtime-tool-card.d.ts
983
- interface RealtimeToolCardProps {
984
- toolCall: ToolCallData;
985
- className?: string;
986
- }
987
- /**
988
- * Displays a tool call status card for voice mode.
989
- * Shows running, success, or error state with the tool name.
990
- */
991
- declare function RealtimeToolCard({
992
- toolCall,
993
- className
994
- }: RealtimeToolCardProps): react_jsx_runtime19.JSX.Element;
995
- //#endregion
996
- //#region src/components/MCPToolRegistry.d.ts
997
- /**
998
- * Tool registry that registers all MCP tools with assistant-ui.
999
- * Routes tool calls automatically based on _sourceId.
1000
- */
1001
- declare const MCPToolRegistry: FC;
1002
- //#endregion
1003
- //#region src/components/RemoteMCPSettings.d.ts
1004
- declare const RemoteMCPSettings: FC;
1005
- //#endregion
1006
- //#region src/components/button.d.ts
1007
- interface ButtonProps extends react0.ComponentProps<'button'>, VariantProps<typeof buttonVariants> {
1008
- asChild?: boolean;
1009
- }
1010
- declare const buttonVariants: (props?: ({
1011
- variant?: "link" | "default" | "destructive" | "outline" | "secondary" | "ghost" | null | undefined;
1012
- size?: "default" | "sm" | "lg" | "icon" | "icon-sm" | "icon-lg" | null | undefined;
1013
- } & class_variance_authority_types0.ClassProp) | undefined) => string;
1014
- declare function Button({
1015
- className,
1016
- variant,
1017
- size,
1018
- asChild,
1019
- ...props
1020
- }: react0.ComponentProps<'button'> & VariantProps<typeof buttonVariants> & {
1021
- asChild?: boolean;
1022
- }): react_jsx_runtime19.JSX.Element;
1023
- //#endregion
1024
- //#region src/components/avatar.d.ts
1025
- declare function Avatar({
1026
- className,
1027
- ...props
1028
- }: react0.ComponentProps<typeof AvatarPrimitive.Root>): react_jsx_runtime19.JSX.Element;
1029
- declare function AvatarImage({
1030
- className,
1031
- ...props
1032
- }: react0.ComponentProps<typeof AvatarPrimitive.Image>): react_jsx_runtime19.JSX.Element;
1033
- declare function AvatarFallback({
1034
- className,
1035
- ...props
1036
- }: react0.ComponentProps<typeof AvatarPrimitive.Fallback>): react_jsx_runtime19.JSX.Element;
1037
- //#endregion
1038
- //#region src/components/badge.d.ts
1039
- declare const badgeVariants: (props?: ({
1040
- variant?: "default" | "destructive" | "outline" | "secondary" | null | undefined;
1041
- } & class_variance_authority_types0.ClassProp) | undefined) => string;
1042
- interface BadgeProps extends react0.HTMLAttributes<HTMLDivElement>, VariantProps<typeof badgeVariants> {}
1043
- declare function Badge({
1044
- className,
1045
- variant,
1046
- ...props
1047
- }: BadgeProps): react_jsx_runtime19.JSX.Element;
1048
- //#endregion
1049
- //#region src/components/dialog.d.ts
1050
- declare function Dialog({
1051
- ...props
1052
- }: react0.ComponentProps<typeof DialogPrimitive.Root>): react_jsx_runtime19.JSX.Element;
1053
- declare function DialogTrigger({
1054
- ...props
1055
- }: react0.ComponentProps<typeof DialogPrimitive.Trigger>): react_jsx_runtime19.JSX.Element;
1056
- declare function DialogPortal({
1057
- ...props
1058
- }: react0.ComponentProps<typeof DialogPrimitive.Portal>): react_jsx_runtime19.JSX.Element;
1059
- declare function DialogClose({
1060
- ...props
1061
- }: react0.ComponentProps<typeof DialogPrimitive.Close>): react_jsx_runtime19.JSX.Element;
1062
- declare function DialogOverlay({
1063
- className,
1064
- ...props
1065
- }: react0.ComponentProps<typeof DialogPrimitive.Overlay>): react_jsx_runtime19.JSX.Element;
1066
- declare function DialogContent({
1067
- className,
1068
- children,
1069
- showCloseButton,
1070
- ...props
1071
- }: react0.ComponentProps<typeof DialogPrimitive.Content> & {
1072
- showCloseButton?: boolean;
1073
- }): react_jsx_runtime19.JSX.Element;
1074
- declare function DialogHeader({
1075
- className,
1076
- ...props
1077
- }: react0.ComponentProps<'div'>): react_jsx_runtime19.JSX.Element;
1078
- declare function DialogFooter({
1079
- className,
1080
- ...props
1081
- }: react0.ComponentProps<'div'>): react_jsx_runtime19.JSX.Element;
1082
- declare function DialogTitle({
1083
- className,
1084
- ...props
1085
- }: react0.ComponentProps<typeof DialogPrimitive.Title>): react_jsx_runtime19.JSX.Element;
1086
- declare function DialogDescription({
1087
- className,
1088
- ...props
1089
- }: react0.ComponentProps<typeof DialogPrimitive.Description>): react_jsx_runtime19.JSX.Element;
1090
- //#endregion
1091
- //#region src/components/scroll-area.d.ts
1092
- declare function ScrollArea({
1093
- className,
1094
- children,
1095
- ...props
1096
- }: react0.ComponentProps<typeof ScrollAreaPrimitive.Root>): react_jsx_runtime19.JSX.Element;
1097
- declare function ScrollBar({
1098
- className,
1099
- orientation,
1100
- ...props
1101
- }: react0.ComponentProps<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>): react_jsx_runtime19.JSX.Element;
1102
- //#endregion
1103
- //#region src/components/separator.d.ts
1104
- declare function Separator({
1105
- className,
1106
- orientation,
1107
- decorative,
1108
- ...props
1109
- }: react0.ComponentProps<typeof SeparatorPrimitive.Root>): react_jsx_runtime19.JSX.Element;
1110
- //#endregion
1111
- //#region src/components/tooltip.d.ts
1112
- declare function TooltipProvider({
1113
- delayDuration,
1114
- ...props
1115
- }: react0.ComponentProps<typeof TooltipPrimitive.Provider>): react_jsx_runtime19.JSX.Element;
1116
- declare function Tooltip({
1117
- ...props
1118
- }: react0.ComponentProps<typeof TooltipPrimitive.Root>): react_jsx_runtime19.JSX.Element;
1119
- declare function TooltipTrigger({
1120
- ...props
1121
- }: react0.ComponentProps<typeof TooltipPrimitive.Trigger>): react_jsx_runtime19.JSX.Element;
1122
- declare function TooltipContent({
1123
- className,
1124
- sideOffset,
1125
- children,
1126
- ...props
1127
- }: react0.ComponentProps<typeof TooltipPrimitive.Content>): react_jsx_runtime19.JSX.Element;
1128
- //#endregion
1129
- //#region src/components/tooltip-icon-button.d.ts
1130
- type TooltipIconButtonProps = ComponentPropsWithRef<typeof Button> & {
1131
- tooltip: string;
1132
- side?: 'top' | 'bottom' | 'left' | 'right';
1133
- };
1134
- declare const TooltipIconButton: react0.ForwardRefExoticComponent<Omit<TooltipIconButtonProps, "ref"> & react0.RefAttributes<HTMLButtonElement>>;
1135
- //#endregion
1136
- //#region src/hooks/useAgentSdkVoiceMode.d.ts
1137
- interface UseAgentSdkVoiceModeOptions {
1138
- /** Endpoint to get ephemeral tokens from */
1139
- tokenEndpoint: string;
1140
- /** Tools available for the voice session (MCP format with JSON Schema) */
1141
- tools?: RegisteredTool[];
1142
- /** Tool executor function that routes calls to MCP */
1143
- toolExecutor?: ToolExecutor;
1144
- /** Callback when session connects */
1145
- onConnect?: () => void;
1146
- /** Callback when session disconnects */
1147
- onDisconnect?: (durationSeconds: number) => void;
1148
- /** Callback when error occurs */
1149
- onError?: (error: string) => void;
1150
- /** Callback when user transcript is complete */
1151
- onUserTranscript?: (text: string) => void;
1152
- /** Callback when assistant transcript is complete */
1153
- onAssistantTranscript?: (text: string) => void;
1154
- }
1155
- interface UseAgentSdkVoiceModeReturn extends VoiceModeState {
1156
- /** Start voice session */
1157
- startSession: () => Promise<void>;
1158
- /** Stop voice session */
1159
- stopSession: () => void;
1160
- /** Toggle microphone mute */
1161
- toggleMute: (muted?: boolean) => void;
1162
- /** Send text message while in voice mode */
1163
- sendMessage: (text: string) => void;
1164
- }
1165
- declare function useAgentSdkVoiceMode(options: UseAgentSdkVoiceModeOptions): UseAgentSdkVoiceModeReturn;
1166
- //#endregion
1167
- //#region src/providers/AgentSdkVoiceModeProvider.d.ts
1168
- interface AgentSdkVoiceModeContextValue extends UseAgentSdkVoiceModeReturn {
1169
- isSupported: boolean;
1170
- }
1171
- interface AgentSdkVoiceModeProviderProps {
1172
- children: ReactNode;
1173
- /** Backend endpoint for ephemeral tokens */
1174
- tokenEndpoint: string;
1175
- /** Tools available for voice mode (MCP format) */
1176
- tools?: RegisteredTool[];
1177
- /** Tool executor function */
1178
- toolExecutor?: ToolExecutor;
1179
- /** Callback when session connects */
1180
- onConnect?: () => void;
1181
- /** Callback when session disconnects */
1182
- onDisconnect?: (durationSeconds: number) => void;
1183
- /** Callback when error occurs */
1184
- onError?: (error: string) => void;
1185
- /** Callback when user transcript is complete */
1186
- onUserTranscript?: (text: string) => void;
1187
- /** Callback when assistant transcript is complete */
1188
- onAssistantTranscript?: (text: string) => void;
1189
- }
1190
- declare function AgentSdkVoiceModeProvider({
1191
- children,
1192
- tokenEndpoint,
1193
- tools,
1194
- toolExecutor,
1195
- onConnect,
1196
- onDisconnect,
1197
- onError,
1198
- onUserTranscript,
1199
- onAssistantTranscript
1200
- }: AgentSdkVoiceModeProviderProps): react_jsx_runtime19.JSX.Element;
1201
- /**
1202
- * Hook to access Agent SDK voice mode context
1203
- */
1204
- declare function useAgentSdkVoiceModeContext(): AgentSdkVoiceModeContextValue;
1205
- /**
1206
- * Hook to optionally access Agent SDK voice mode context (returns null if not in provider)
1207
- */
1208
- declare function useOptionalAgentSdkVoiceModeContext(): AgentSdkVoiceModeContextValue | null;
1209
- //#endregion
1210
- //#region src/providers/AgentSdkVoiceMCPBridge.d.ts
1211
- interface AgentSdkVoiceMCPBridgeProps {
1212
- children: ReactNode;
1213
- tokenEndpoint: string;
1214
- onError?: (error: string) => void;
1215
- onConnect?: () => void;
1216
- onDisconnect?: (duration: number) => void;
1217
- onUserTranscript?: (text: string) => void;
1218
- onAssistantTranscript?: (text: string) => void;
1219
- }
1220
- /**
1221
- * Bridge component that connects MCP tools to AgentSdkVoiceModeProvider.
1222
- * Uses the MCP context and provides tools + executor to the SDK-based voice mode.
1223
- */
1224
- declare const AgentSdkVoiceMCPBridge: FC<AgentSdkVoiceMCPBridgeProps>;
1225
- //#endregion
1226
- //#region src/providers/ChatRuntimeProvider.d.ts
1227
- interface ChatRuntimeProviderProps {
1228
- children: ReactNode;
1229
- }
1230
- /**
1231
- * Provider that sets up the Assistant UI runtime with Cloudflare Workers backend.
1232
- *
1233
- * This component integrates the Cloudflare Agents SDK with Assistant UI,
1234
- * handling message conversion, tool calls, and HITL (Human-in-the-Loop) approvals.
1235
- *
1236
- * @example
1237
- * ```tsx
1238
- * import { ChatRuntimeProvider, Thread } from '@mcp-b/webmcp-client';
1239
- *
1240
- * function App() {
1241
- * return (
1242
- * <ChatRuntimeProvider>
1243
- * <Thread />
1244
- * </ChatRuntimeProvider>
1245
- * );
1246
- * }
1247
- * ```
1248
- */
1249
- declare const ChatRuntimeProvider: FC<ChatRuntimeProviderProps>;
1250
- //#endregion
1251
- //#region src/hooks/useMCPSource.d.ts
1252
- /**
1253
- * Options for the useMCPSource hook
1254
- */
1255
- interface UseMCPSourceOptions {
1256
- /** Auto-connect on mount (default: true) */
1257
- autoConnect?: boolean;
1258
- /** Callback when tools are updated */
1259
- onToolsUpdate?: (tools: Tool$1[]) => void;
1260
- /** Callback when resources are updated */
1261
- onResourcesUpdate?: (resources: Resource[], templates: ResourceTemplate[]) => void;
1262
- /** Callback when prompts are updated */
1263
- onPromptsUpdate?: (prompts: Prompt[]) => void;
1264
- /** Callback when connection state changes */
1265
- onStateChange?: (state: MCPConnectionState) => void;
1266
- /** Callback on connection error */
1267
- onError?: (error: Error) => void;
1268
- /**
1269
- * Handler for sampling requests from the server.
1270
- * If provided, enables the sampling capability.
1271
- * The handler should call an LLM and return the response.
1272
- */
1273
- samplingHandler?: SamplingHandler;
1274
- }
1275
- /**
1276
- * Return value from the useMCPSource hook
1277
- */
1278
- interface UseMCPSourceReturn {
1279
- /** MCP client instance */
1280
- client: Client | null;
1281
- /** Available tools from this source */
1282
- tools: Tool$1[];
1283
- /** Available resources from this source */
1284
- resources: Resource[];
1285
- /** Available resource templates from this source */
1286
- resourceTemplates: ResourceTemplate[];
1287
- /** Available prompts from this source */
1288
- prompts: Prompt[];
1289
- /** Connection state */
1290
- state: MCPConnectionState;
1291
- /** Whether connected and ready */
1292
- isConnected: boolean;
1293
- /** Connection error (if any) */
1294
- error: Error | null;
1295
- /** Connect to the MCP server */
1296
- connect: () => Promise<void>;
1297
- /** Disconnect from the MCP server */
1298
- disconnect: () => Promise<void>;
1299
- /** Call a tool on this source */
1300
- callTool: (name: string, args: Record<string, unknown>) => Promise<CallToolResult>;
1301
- /** Read a resource by URI */
1302
- readResource: (uri: string) => Promise<ReadResourceResult>;
1303
- /** Get a prompt with optional arguments */
1304
- getPrompt: (name: string, args?: Record<string, string>) => Promise<GetPromptResult>;
1305
- /** Refresh the list of tools */
1306
- refreshTools: () => Promise<void>;
1307
- /** Refresh the list of resources */
1308
- refreshResources: () => Promise<void>;
1309
- /** Refresh the list of prompts */
1310
- refreshPrompts: () => Promise<void>;
1311
- }
1312
- /**
1313
- * Unified hook for connecting to MCP sources.
1314
- * Works with both tab-based (same-tab, iframe) and HTTP/SSE-based (remote) sources.
1315
- * Supports the full MCP specification including tools, resources, prompts, and sampling.
1316
- */
1317
- declare function useMCPSource(id: string, config: MCPSourceConfig, options?: UseMCPSourceOptions): UseMCPSourceReturn;
1318
- //#endregion
1319
- //#region src/hooks/useAgentChat.d.ts
1320
- /**
1321
- * Tool definition for frontend execution.
1322
- * Tools with execute function auto-execute.
1323
- * Tools without execute require manual confirmation via addToolResult.
1324
- */
1325
- interface FrontendTool<TInput = unknown, TOutput = unknown> {
1326
- /** Optional description for UI */
1327
- description?: string;
1328
- /** If provided, tool auto-executes. If omitted, requires manual confirmation. */
1329
- execute?: (input: TInput) => Promise<TOutput> | TOutput;
1330
- }
1331
- /**
1332
- * Map of tool names to tool definitions.
1333
- */
1334
- type FrontendTools = Record<string, FrontendTool>;
1335
- /**
1336
- * Agent connection interface (WebSocket-like).
1337
- */
1338
- interface AgentConnection {
1339
- send: (data: string) => void;
1340
- addEventListener: (event: 'message', handler: (event: MessageEvent) => void) => void;
1341
- removeEventListener: (event: 'message', handler: (event: MessageEvent) => void) => void;
1342
- readyState?: number;
1343
- }
1344
- /**
1345
- * Options for useAgentChat hook.
1346
- */
1347
- interface UseAgentChatOptions {
1348
- /** WebSocket connection to the agent */
1349
- agent: AgentConnection;
1350
- /** Frontend tools for execution */
1351
- tools?: FrontendTools;
1352
- /** Initial messages (optional, typically restored from sync) */
1353
- initialMessages?: UIMessage[];
1354
- /** Callback when tools need confirmation */
1355
- onToolsNeedConfirmation?: (tools: PendingTool[]) => void;
1356
- /** Callback when agent state changes */
1357
- onStateChange?: (state: AgentChatState) => void;
1358
- }
1359
- /**
1360
- * Return value from useAgentChat hook.
1361
- */
1362
- interface UseAgentChatReturn {
1363
- /** Current messages */
1364
- messages: UIMessage[];
1365
- /** Set messages manually */
1366
- setMessages: (messages: UIMessage[]) => void;
1367
- /** Current input value */
1368
- input: string;
1369
- /** Set input value */
1370
- setInput: (input: string) => void;
1371
- /** Handle input submission */
1372
- handleSubmit: (e?: React.FormEvent) => void;
1373
- /** Send a message programmatically */
1374
- sendMessage: (content: string) => void;
1375
- /** Add tool result (for confirmation flow) */
1376
- addToolResult: (toolCallId: string, toolName: string, output: unknown) => void;
1377
- /** Current agent state */
1378
- agentState: AgentChatState;
1379
- /** Whether currently streaming */
1380
- isStreaming: boolean;
1381
- /** Tools awaiting confirmation */
1382
- pendingConfirmationTools: PendingTool[];
1383
- /** Clear chat history */
1384
- clearHistory: () => void;
1385
- }
1386
- /**
1387
- * React hook for DO-first streaming chat.
1388
- *
1389
- * Handles:
1390
- * - Message sending and receiving
1391
- * - State synchronization on reconnect
1392
- * - Automatic tool execution
1393
- * - Confirmation-required tool flow
1394
- */
1395
- declare function useAgentChat(options: UseAgentChatOptions): UseAgentChatReturn;
1396
- //#endregion
1397
- //#region src/hooks/useCloudflareRuntime.d.ts
1398
- /**
1399
- * Options for the useCloudflareRuntime hook.
1400
- */
1401
- interface UseCloudflareRuntimeOptions {
1402
- /**
1403
- * The host for the Cloudflare Agent WebSocket connection.
1404
- * @default 'localhost:8787'
1405
- */
1406
- host?: string;
1407
- /**
1408
- * The agent binding name to connect to.
1409
- * @default 'TOOL_HUB'
1410
- */
1411
- agent?: string;
1412
- /**
1413
- * Frontend tools that can be executed by the client.
1414
- * Tools with an `execute` function will auto-execute.
1415
- * Tools without `execute` require manual confirmation via the UI.
1416
- */
1417
- tools?: FrontendTools;
1418
- /**
1419
- * Callback when tools need user confirmation.
1420
- * Called with the list of tools awaiting approval.
1421
- */
1422
- onToolsNeedConfirmation?: (tools: Array<{
1423
- toolCallId: string;
1424
- toolName: string;
1425
- input: unknown;
1426
- }>) => void;
1427
- }
1428
- /**
1429
- * Hook that provides Assistant UI runtime integration with Cloudflare Workers backend.
1430
- *
1431
- * This hook orchestrates the connection between the Assistant UI component library and
1432
- * a Cloudflare Workers agent backend with DO-first streaming. It handles:
1433
- *
1434
- * 1. **Agent Connection**: Establishes WebSocket connection to the Cloudflare Agent
1435
- * running on the local development server or Cloudflare Workers backend.
1436
- *
1437
- * 2. **DO-First Streaming**: Messages are accumulated on the Durable Object, making
1438
- * streaming refresh-safe. On reconnection, the client receives a sync message
1439
- * with the full state including any in-progress streaming message.
1440
- *
1441
- * 3. **Frontend Tool Execution**: When the LLM requests tool calls, the agent sends
1442
- * a tools_needed message. Tools with `execute` functions auto-run, while others
1443
- * require manual confirmation through the UI.
1444
- *
1445
- * 4. **User Input Handling**: Processes new user messages from the Assistant UI composer
1446
- * and sends them to the Cloudflare Agent for processing.
1447
- *
1448
- * 5. **Message Conversion**: Converts messages between the Vercel AI SDK format
1449
- * (used by Cloudflare Agents) and the Assistant UI format using the converter utility.
1450
- *
1451
- * @param options - Configuration options for the runtime
1452
- * @returns Assistant UI runtime configured with Cloudflare Workers backend integration
1453
- *
1454
- * @example
1455
- * ```tsx
1456
- * function ChatApp() {
1457
- * const runtime = useCloudflareRuntime({
1458
- * host: 'localhost:8787',
1459
- * tools: {
1460
- * getWeather: {
1461
- * execute: async (args) => {
1462
- * const data = await fetchWeather(args.city);
1463
- * return data;
1464
- * }
1465
- * }
1466
- * }
1467
- * });
1468
- * return <Thread runtime={runtime} />;
1469
- * }
1470
- * ```
1471
- */
1472
- declare function useCloudflareRuntime(options?: UseCloudflareRuntimeOptions): AssistantRuntime;
1473
- //#endregion
1474
- //#region src/hooks/useAssistantMCP.d.ts
1475
- interface UseAssistantMCPOptions {
1476
- /** MCP tools to register */
1477
- tools: Tool[];
1478
- /** MCP client for executing tools */
1479
- client: Client;
1480
- /** Optional system prompt to inject */
1481
- systemPrompt?: string;
1482
- }
1483
- /**
1484
- * Registers MCP tools with the Assistant UI runtime so they can be invoked by the
1485
- * assistant without any additional indirection.
1486
- *
1487
- * Tools are registered as frontend tools with execute functions that call the MCP client.
1488
- *
1489
- * @param options - Configuration options
1490
- *
1491
- * @example
1492
- * ```tsx
1493
- * function ChatThread() {
1494
- * const { client, tools } = useMcpClient();
1495
- *
1496
- * useAssistantMCP({
1497
- * tools,
1498
- * client,
1499
- * systemPrompt: 'You are a helpful assistant.',
1500
- * });
1501
- *
1502
- * return <Thread />;
1503
- * }
1504
- * ```
1505
- */
1506
- declare function useAssistantMCP(options: UseAssistantMCPOptions): void;
1507
- //#endregion
1508
- //#region src/lib/utils.d.ts
1509
- /**
1510
- * Merges Tailwind CSS classes with proper precedence handling.
1511
- * Combines clsx for conditional classes and tailwind-merge for deduplication.
1512
- */
1513
- declare function cn(...inputs: ClassValue[]): string;
1514
- //#endregion
1515
- //#region src/lib/converter.d.ts
1516
- /**
1517
- * Converts an array of UI messages to the Assistant UI format used by the thread component.
1518
- *
1519
- * This function transforms messages from the Vercel/Cloudflare AI format to the format
1520
- * expected by Assistant UI. Key transformations include:
1521
- * - Maps the message role to the corresponding Assistant UI role
1522
- * - Converts content parts, preserving text parts as-is
1523
- * - Transforms tool invocations from Vercel's combined call/result format to Assistant UI's
1524
- * distinct tool-call format, separating the execution state (PENDING vs COMPLETED)
1525
- *
1526
- * @param messages - Array of UI messages to convert
1527
- * @returns Array of messages formatted for use in the Assistant UI thread component
1528
- *
1529
- * @example
1530
- * ```ts
1531
- * const messages = [{ role: 'user', parts: [{ type: 'text', text: 'Hello' }] }];
1532
- * const threadMessages = convertToAssistantUiMessages(messages);
1533
- * ```
1534
- */
1535
- declare const convertToAssistantUiMessages: (messages: UIMessage[]) => ThreadMessageLike[];
1536
- /**
1537
- * Converts a single UI message to the Assistant UI format.
1538
- *
1539
- * This function performs the same transformation as convertToAssistantUiMessages but operates
1540
- * on a single message. It's useful for converting individual messages from the Vercel/Cloudflare
1541
- * AI format to the Assistant UI format, particularly for generic UI message types that need
1542
- * advanced type parameters.
1543
- *
1544
- * @param msg - Single UI message to convert
1545
- * @returns Message formatted for use in the Assistant UI thread component
1546
- *
1547
- * @example
1548
- * ```ts
1549
- * const msg: UIMessage = { role: 'assistant', parts: [{ type: 'text', text: 'Hello' }] };
1550
- * const threadMsg = convertAssistantUIMessage(msg);
1551
- * ```
1552
- */
1553
- declare const convertAssistantUIMessage: (msg: UIMessage<unknown, UIDataTypes, UITools>) => ThreadMessageLike;
1554
- //#endregion
1555
- //#region src/lib/mcp-transport.d.ts
1556
- /**
1557
- * Transport type options for HTTP-based connections
1558
- */
1559
- type TransportType = 'http' | 'sse';
1560
- /**
1561
- * Creates the appropriate MCP transport based on source configuration.
1562
- *
1563
- * @param config - The MCP source configuration
1564
- * @param transportType - For HTTP sources, specifies whether to use HTTP or SSE transport
1565
- * @returns A configured MCP Transport instance
1566
- *
1567
- * @example Tab-based transport (same-tab or iframe)
1568
- * ```ts
1569
- * const transport = createMCPTransport({ type: 'tab' })
1570
- * ```
1571
- *
1572
- * @example HTTP transport with auth
1573
- * ```ts
1574
- * const transport = createMCPTransport({
1575
- * type: 'http',
1576
- * url: 'https://example.com/mcp',
1577
- * authToken: 'secret'
1578
- * }, 'http')
1579
- * ```
1580
- */
1581
- declare function createMCPTransport(config: MCPSourceConfig, transportType?: TransportType): Transport;
1582
- /**
1583
- * Check if an error indicates we should try SSE fallback.
1584
- *
1585
- * This handles cases where HTTP streaming isn't supported (404/405) or
1586
- * when the connection fails due to CORS/network issues.
1587
- *
1588
- * @param error - The error from the failed HTTP connection
1589
- * @returns true if the error suggests trying SSE transport instead
1590
- */
1591
- declare function shouldFallbackToSSE(error: Error): boolean;
1592
- /**
1593
- * Calculate exponential backoff delay for reconnection attempts.
1594
- *
1595
- * @param attempt - The current attempt number (0-based)
1596
- * @param baseDelay - Base delay in milliseconds
1597
- * @param maxDelay - Maximum delay cap in milliseconds
1598
- * @returns The calculated delay in milliseconds
1599
- */
1600
- declare function calculateReconnectDelay(attempt: number, baseDelay: number, maxDelay: number): number;
1601
- //#endregion
1602
- //#region src/embed.d.ts
1603
- /**
1604
- * WebMCP Embedded Agent - Intercom-style Installation
1605
- *
1606
- * @example Basic Installation (paste before </body>)
1607
- * ```html
1608
- * <script>
1609
- * window.webmcpSettings = {
1610
- * app_id: "YOUR_APP_ID",
1611
- * api_base: "https://your-worker.workers.dev"
1612
- * };
1613
- * </script>
1614
- * <script>
1615
- * (function(){var w=window;var wm=w.WebMCP;if(typeof wm==="function"){wm('reattach');}else{var q=function(){q.c(arguments);};q.q=[];q.c=function(args){q.q.push(args);};w.WebMCP=q;var l=function(){var s=document.createElement('script');s.type='text/javascript';s.async=true;s.src='https://your-cdn.com/embed.iife.js';var x=document.getElementsByTagName('script')[0];x.parentNode.insertBefore(s,x);};if(document.readyState==='complete'){l();}else{w.addEventListener('load',l,false);}}})();
1616
- * </script>
1617
- * ```
1618
- *
1619
- * @example Programmatic Control
1620
- * ```javascript
1621
- * // Boot with user data
1622
- * window.WebMCP('boot', {
1623
- * app_id: 'YOUR_APP_ID',
1624
- * user_id: 'user_123',
1625
- * email: 'user@example.com'
1626
- * });
1627
- *
1628
- * // Show/hide the messenger
1629
- * window.WebMCP('show');
1630
- * window.WebMCP('hide');
1631
- *
1632
- * // Update settings
1633
- * window.WebMCP('update', { custom_data: { plan: 'pro' } });
1634
- *
1635
- * // Shutdown (clear session)
1636
- * window.WebMCP('shutdown');
1637
- * ```
1638
- */
1639
- /**
1640
- * Configuration options (similar to intercomSettings)
1641
- */
1642
- interface WebMCPSettings {
1643
- /** Your app/workspace ID */
1644
- app_id: string;
1645
- /** API base URL for your WebMCP worker */
1646
- api_base?: string;
1647
- /** Voice mode token endpoint */
1648
- token_endpoint?: string;
1649
- /** User ID for identified users */
1650
- user_id?: string;
1651
- /** User email */
1652
- email?: string;
1653
- /** User name */
1654
- name?: string;
1655
- /** Unix timestamp of user creation */
1656
- created_at?: number;
1657
- /** Custom user attributes */
1658
- custom_data?: Record<string, unknown>;
1659
- /** Auto-connect to local MCP source */
1660
- auto_connect_local?: boolean;
1661
- /** Custom container element ID */
1662
- container_id?: string;
1663
- }
1664
- /**
1665
- * Boot options (can override settings)
1666
- */
1667
- interface WebMCPBootOptions extends Partial<WebMCPSettings> {}
1668
- /**
1669
- * Handle method calls (Intercom-style API)
1670
- */
1671
- type WebMCPMethod = 'boot' | 'shutdown' | 'update' | 'show' | 'hide' | 'showNewMessage' | 'getVisitorId' | 'trackEvent' | 'reattach';
1672
- /**
1673
- * Main API function (Intercom-style)
1674
- */
1675
- interface WebMCPFunction {
1676
- (method: WebMCPMethod, ...args: unknown[]): unknown;
1677
- q?: unknown[][];
1678
- c?: (args: unknown[]) => void;
1679
- booted: boolean;
1680
- visible: boolean;
1681
- }
1682
- declare global {
1683
- interface Window {
1684
- WebMCP: WebMCPFunction;
1685
- webmcpSettings?: WebMCPSettings;
1686
- }
1687
- }
1688
- //#endregion
1689
- export { AUDIO_FREQUENCY_BINS, type Action, ActionList, ActionStatusIcon, ActionSummary, AgentPill, type AgentPillProps, AgentProvider, type AgentProviderProps, AgentSdkVoiceMCPBridge, type AgentSdkVoiceMCPBridgeProps, AgentSdkVoiceModeProvider, type AgentSdkVoiceModeProviderProps, type AgentState, type AgentTools, type AgentViewMode, type AgentVoice, AssistantMessage, AssistantModal, type AssistantTranscriptEventData, type AudioLevelData, Avatar, AvatarFallback, AvatarImage, Badge, type BadgeProps, Button, type ButtonProps, ChatRuntimeProvider, type ChatRuntimeProviderProps, Composer, ComposerAddAttachment, ComposerAttachments, type Conversation, CurrentActivity, DEBUG_LOGGING_ENABLED, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, EmbeddedAgent, type EmbeddedAgentProps, type ErrorEventData, HistorySidebar, IdleIndicator, LiveWaveform, MCPToolRegistry, type MCPToolsContextValue, MCPToolsProvider, type MCPToolsProviderProps, MCP_BASE_RECONNECT_DELAY_MS, MCP_MAX_RECONNECT_ATTEMPTS, MCP_MAX_RECONNECT_DELAY_MS, MCP_TAB_CONNECT_DELAY_MS, MarkdownText, MinimalComposer, OpenAIRealtimeService, PillComposer, PillContainer, PillMarkdown, type PillMode, type PillPosition, PillVoice, REALTIME_DEFAULT_API_URL, REALTIME_DEFAULT_MODEL, REALTIME_DEFAULT_VOICE, type RealtimeConfig, type RealtimeSession, RealtimeToolCard, type RegisteredTool, RemoteMCPSettings, SOURCE_LOCAL, SOURCE_REMOTE, ScrollArea, ScrollBar, Separator, type SessionStateEventData, SummaryBlock, Thread, ThreadContent, ThreadWithVoice, type ToolBorderStatus, type ToolCallCompletedEventData, type ToolCallData, type ToolCallStartedEventData, type ToolExecutor, ToolFallback, ToolStatusBorder, Tooltip, TooltipContent, TooltipIconButton, TooltipProvider, TooltipTrigger, type TranscriptData, type TransportType, type UseAgentChatOptions, type UseAgentChatReturn, type UseAgentSdkVoiceModeOptions, type UseAgentSdkVoiceModeReturn, type UseMCPSourceOptions, type UseMCPSourceReturn, type UseVoiceModeOptions, type UseVoiceModeReturn, UserMessage, UserMessageAttachments, type UserTranscriptEventData, VOICE_ACTIONS_RETENTION_MS, VOICE_SUMMARY_RETENTION_MS, VoiceIndicator, VoiceModeProvider, type VoiceModeProviderProps, type VoiceModeState, type VoiceSummary, WebMCPAgentElement, type WebMCPBootOptions, type WebMCPFunction, type WebMCPMethod, type WebMCPSettings, WelcomeMessage, badgeVariants, buttonVariants, calculateReconnectDelay, cn, convertAssistantUIMessage, convertToAssistantUiMessages, createMCPTransport, debugLog, humanizeToolName, isAssistantTranscriptEventData, isAudioLevelData, isErrorEventData, isSessionStateEventData, isToolCallCompletedEventData, isToolCallStartedEventData, isUserTranscriptEventData, registerWebMCPAgent, shouldFallbackToSSE, useActionStats, useActions, useAgent, useAgentChat, useAgentSdkVoiceMode, useAgentSdkVoiceModeContext, useAssistantMCP, useCloudflareRuntime, useCurrentAction, useCurrentVoiceAction, useHasVoiceSummary, useIsAgentAvailable, useLatestSummary, useMCPSource, useMCPTools, useOptionalAgentSdkVoiceModeContext, useOptionalMCPTools, useOptionalVoiceModeContext, useRecentActions, useRecentVoiceActions, useVoiceActions, useVoiceBorderStatus, useVoiceMode, useVoiceModeContext, useVoiceSummary };
64
+ export { type AgentViewMode, EmbeddedAgent, type EmbeddedAgentProps, registerWebMCPAgent };
1690
65
  //# sourceMappingURL=index.d.ts.map