@pillar-ai/sdk 0.1.13 → 0.1.14

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.
Files changed (53) hide show
  1. package/README.md +46 -44
  2. package/dist/actions/types.d.ts +9 -3
  3. package/dist/api/client.d.ts +91 -16
  4. package/dist/api/mcp-client.d.ts +105 -91
  5. package/dist/cli/sync.js +70 -13
  6. package/dist/components/DebugPanel/DebugPanel.d.ts +25 -0
  7. package/dist/components/DebugPanel/index.d.ts +2 -0
  8. package/dist/components/DevTools/index.d.ts +5 -0
  9. package/dist/components/DevTools/styles.d.ts +5 -0
  10. package/dist/components/Panel/Header.d.ts +1 -1
  11. package/dist/components/Panel/HistoryDropdown.d.ts +10 -0
  12. package/dist/components/Panel/TaskButton.d.ts +4 -14
  13. package/dist/components/Panel/styles.d.ts +1 -1
  14. package/dist/components/Plan/InlinePlanView.d.ts +1 -1
  15. package/dist/components/Plan/PlanDocument.d.ts +18 -0
  16. package/dist/components/Plan/PlanStepItem.d.ts +1 -1
  17. package/dist/components/Plan/PlanView.d.ts +1 -1
  18. package/dist/components/Plan/index.d.ts +1 -0
  19. package/dist/components/Progress/ProgressRow.d.ts +6 -2
  20. package/dist/components/Progress/ProgressStack.d.ts +15 -0
  21. package/dist/components/Progress/ReasoningDisclosure.d.ts +20 -0
  22. package/dist/components/Progress/index.d.ts +2 -0
  23. package/dist/components/Views/HomeView.d.ts +3 -0
  24. package/dist/components/Views/ResumePrompt.d.ts +22 -0
  25. package/dist/components/Views/index.d.ts +1 -0
  26. package/dist/components/shared/icons.d.ts +24 -0
  27. package/dist/components/shared/index.d.ts +1 -0
  28. package/dist/core/Pillar.d.ts +304 -70
  29. package/dist/core/config.d.ts +134 -4
  30. package/dist/core/events.d.ts +55 -70
  31. package/dist/core/plan-executor.d.ts +29 -0
  32. package/dist/core/plan.d.ts +6 -0
  33. package/dist/hooks/index.d.ts +5 -0
  34. package/dist/hooks/useDebouncedValue.d.ts +22 -0
  35. package/dist/hooks/useInlineCard.d.ts +35 -0
  36. package/dist/hooks/usePillarInstance.d.ts +30 -0
  37. package/dist/index.d.ts +11 -9
  38. package/dist/pillar.esm.js +1 -1
  39. package/dist/store/chat.d.ts +94 -17
  40. package/dist/store/index.d.ts +1 -0
  41. package/dist/store/session-persistence.d.ts +62 -0
  42. package/dist/store/suggestions.d.ts +58 -0
  43. package/dist/types/dom-scanner.d.ts +46 -0
  44. package/dist/types/index.d.ts +1 -0
  45. package/dist/types/user-context.d.ts +32 -1
  46. package/dist/utils/debug.d.ts +150 -0
  47. package/dist/utils/dom-scanner.d.ts +44 -0
  48. package/dist/utils/markdown-components.d.ts +53 -0
  49. package/dist/utils/preact-markdown.d.ts +17 -0
  50. package/dist/utils/route-observer.d.ts +67 -0
  51. package/package.json +1 -1
  52. package/src/actions/types.ts +10 -2
  53. package/dist/utils/markdown.d.ts +0 -9
package/README.md CHANGED
@@ -61,62 +61,61 @@ First, register your product in the [Pillar app](https://app.trypillar.com):
61
61
  ```javascript
62
62
  import { Pillar } from "@pillar-ai/sdk";
63
63
 
64
- await Pillar.init({
64
+ // Initialize and get the instance
65
+ const pillar = await Pillar.init({
65
66
  productKey: "your-product-key", // From Pillar app
66
67
  });
68
+
69
+ // Now you can use instance methods
70
+ pillar.setContext({ currentPage: "/dashboard" });
71
+ pillar.open();
72
+ ```
73
+
74
+ You can also get the instance later using `Pillar.getInstance()`:
75
+
76
+ ```javascript
77
+ // Anywhere in your app after init
78
+ const pillar = Pillar.getInstance();
79
+ pillar?.setContext({ currentPage: "/settings" });
67
80
  ```
68
81
 
69
82
  ## Defining Actions
70
83
 
71
- Define what your co-pilot can do. When users make requests, Pillar matches intent to actions and executes them:
84
+ Define what your co-pilot can do. When users make requests, Pillar matches intent to actions and executes them.
85
+
86
+ ### Register Task Handlers
87
+
88
+ Use `onTask` to handle actions when the AI executes them:
72
89
 
73
90
  ```javascript
74
- Pillar.init({
91
+ const pillar = await Pillar.init({
75
92
  productKey: "your-product-key",
76
- actions: {
77
- // Navigation actions
78
- go_to_settings: {
79
- type: "navigate",
80
- label: "Open Settings",
81
- description: "Navigate to the settings page",
82
- path: "/settings",
83
- },
93
+ });
84
94
 
85
- // Trigger actions that execute code
86
- export_to_csv: {
87
- type: "trigger",
88
- label: "Export to CSV",
89
- description: "Export current data to a CSV file",
90
- },
95
+ // Handle navigation
96
+ pillar.onTask("go_to_settings", (data) => {
97
+ router.push("/settings");
98
+ });
91
99
 
92
- // Actions with data schemas
93
- update_preferences: {
94
- type: "trigger",
95
- label: "Update Preferences",
96
- description: "Update notification preferences",
97
- dataSchema: {
98
- emailAlerts: { type: "boolean" },
99
- frequency: { type: "string", enum: ["daily", "weekly", "monthly"] },
100
- },
101
- },
102
- },
100
+ // Handle triggers
101
+ pillar.onTask("export_to_csv", async (data) => {
102
+ await downloadCSV();
103
+ });
103
104
 
104
- onTask: (actionName, data) => {
105
- // Your code executes here
106
- if (actionName === "export_to_csv") {
107
- downloadCSV();
108
- }
109
- if (actionName === "update_preferences") {
110
- updateUserPreferences(data.emailAlerts, data.frequency);
111
- }
112
- },
105
+ // Handle actions with data
106
+ pillar.onTask("update_preferences", (data) => {
107
+ updateUserPreferences(data.emailAlerts, data.frequency);
113
108
  });
114
109
  ```
115
110
 
111
+ ### Code-First Action Definitions
112
+
113
+ For production, define actions in code and sync them via the `pillar-sync` CLI during CI/CD. See [Setting Up Actions](https://trypillar.com/docs/guides/actions) for details.
114
+
116
115
  ## Configuration
117
116
 
118
117
  ```javascript
119
- Pillar.init({
118
+ const pillar = await Pillar.init({
120
119
  productKey: "your-product-key",
121
120
 
122
121
  panel: {
@@ -141,12 +140,15 @@ Pillar.init({
141
140
 
142
141
  | Method | Description |
143
142
  |--------|-------------|
144
- | `Pillar.init(config)` | Initialize the SDK with your configuration |
145
- | `Pillar.open()` | Open the co-pilot panel |
146
- | `Pillar.close()` | Close the co-pilot panel |
147
- | `Pillar.toggle()` | Toggle the co-pilot panel |
148
- | `Pillar.setContext(context)` | Update the user/product context |
149
- | `Pillar.on(event, callback)` | Subscribe to SDK events |
143
+ | `Pillar.init(config)` | Initialize the SDK, returns the instance |
144
+ | `Pillar.getInstance()` | Get the initialized SDK instance |
145
+ | `pillar.open()` | Open the co-pilot panel |
146
+ | `pillar.close()` | Close the co-pilot panel |
147
+ | `pillar.toggle()` | Toggle the co-pilot panel |
148
+ | `pillar.setContext(context)` | Update the user/product context |
149
+ | `pillar.on(event, callback)` | Subscribe to SDK events |
150
+
151
+ > **Note:** `Pillar.init()` and `Pillar.getInstance()` are static methods on the class. All other methods (lowercase `pillar`) are instance methods - call them on the instance returned from `init()` or `getInstance()`.
150
152
 
151
153
  For complete API documentation, see the [API Reference](https://trypillar.com/docs/reference/core).
152
154
 
@@ -31,12 +31,13 @@
31
31
  * - open_modal: Open a modal or dialog
32
32
  * - fill_form: Fill form fields with data
33
33
  * - trigger_action: Trigger a custom action
34
+ * - query: Fetch data from the client and return to the agent (implies returns: true)
34
35
  * - copy_text: Copy text to clipboard
35
36
  * - external_link: Open an external URL
36
37
  * - start_tutorial: Start a tutorial/walkthrough
37
38
  * - inline_ui: Display inline UI card in chat
38
39
  */
39
- export type ActionType = 'navigate' | 'open_modal' | 'fill_form' | 'trigger_action' | 'copy_text' | 'external_link' | 'start_tutorial' | 'inline_ui';
40
+ export type ActionType = 'navigate' | 'open_modal' | 'fill_form' | 'trigger_action' | 'query' | 'copy_text' | 'external_link' | 'start_tutorial' | 'inline_ui';
40
41
  /**
41
42
  * Supported platforms for action deployments.
42
43
  */
@@ -169,7 +170,7 @@ export interface ActionDefinition<TData = Record<string, unknown>> {
169
170
  *
170
171
  * Action names should be snake_case identifiers.
171
172
  */
172
- export type ActionDefinitions = Record<string, ActionDefinition<any>>;
173
+ export type ActionDefinitions = Record<string, ActionDefinition<unknown>>;
173
174
  /**
174
175
  * Metadata for a single action in the manifest (no handler).
175
176
  *
@@ -275,7 +276,7 @@ export interface SyncActionDefinition<TData = Record<string, unknown>> {
275
276
  *
276
277
  * Use this type for your actions file that gets synced via CI/CD.
277
278
  */
278
- export type SyncActionDefinitions = Record<string, SyncActionDefinition<any>>;
279
+ export type SyncActionDefinitions = Record<string, SyncActionDefinition<unknown>>;
279
280
  /**
280
281
  * Base data types for each action type.
281
282
  * These are automatically inferred from the action's `type` field.
@@ -306,6 +307,10 @@ export interface CopyTextData {
306
307
  /** Text to copy to clipboard */
307
308
  text?: string;
308
309
  }
310
+ export interface QueryActionData {
311
+ /** Query parameters passed to the handler */
312
+ [key: string]: unknown;
313
+ }
309
314
  /**
310
315
  * Maps action types to their default data shapes.
311
316
  * Used for automatic type inference in onTask handlers.
@@ -313,6 +318,7 @@ export interface CopyTextData {
313
318
  export interface ActionTypeDataMap {
314
319
  navigate: NavigateActionData;
315
320
  trigger_action: TriggerActionData;
321
+ query: QueryActionData;
316
322
  inline_ui: InlineUIData;
317
323
  external_link: ExternalLinkData;
318
324
  copy_text: CopyTextData;
@@ -5,10 +5,10 @@
5
5
  import type { TaskButtonData } from '../components/Panel/TaskButton';
6
6
  import type { ResolvedConfig } from '../core/config';
7
7
  import type { Context, Suggestion, UserProfile } from '../core/context';
8
- import type { ExecutionPlan } from '../core/plan';
9
8
  import type { Workflow } from '../core/workflow';
10
9
  import type { UserContextItem } from '../types/user-context';
11
- import type { ChatImage, ImageUploadResponse } from './mcp-client';
10
+ import type { ActionRequest, ChatImage, ImageUploadResponse } from './mcp-client';
11
+ import { MCPClient } from './mcp-client';
12
12
  export interface ArticleSummary {
13
13
  id: string;
14
14
  title: string;
@@ -23,6 +23,8 @@ export interface ChatMessage {
23
23
  export interface SuggestedQuestion {
24
24
  id: string;
25
25
  text: string;
26
+ /** If true, this is an admin-configured suggestion that should rank first */
27
+ manual?: boolean;
26
28
  }
27
29
  export interface ChatResponse {
28
30
  message: string;
@@ -32,21 +34,31 @@ export interface ChatResponse {
32
34
  messageId?: string;
33
35
  actions?: TaskButtonData[];
34
36
  }
37
+ /**
38
+ * Child item within a progress event (e.g., search source, plan step).
39
+ */
40
+ export interface ProgressChild {
41
+ id: string;
42
+ label: string;
43
+ url?: string;
44
+ }
45
+ /**
46
+ * Progress event for tracking AI response generation steps.
47
+ * Uses a generic design where the server controls display text via `label`.
48
+ *
49
+ * The new schema uses `id` and `status` fields. Legacy fields are kept
50
+ * for backwards compatibility with older backend versions.
51
+ */
35
52
  export interface ProgressEvent {
36
- kind: 'processing' | 'search' | 'search_complete' | 'query' | 'query_complete' | 'query_failed' | 'generating';
37
- message?: string;
53
+ kind: string;
54
+ id?: string;
55
+ label?: string;
56
+ status?: 'active' | 'done' | 'error';
57
+ text?: string;
58
+ children?: ProgressChild[];
59
+ metadata?: Record<string, unknown>;
38
60
  progress_id?: string;
39
- metadata?: {
40
- sources?: Array<{
41
- title: string;
42
- url: string;
43
- score?: number;
44
- }>;
45
- result_count?: number;
46
- query?: string;
47
- action_name?: string;
48
- no_sources_used?: boolean;
49
- };
61
+ message?: string;
50
62
  }
51
63
  /**
52
64
  * Server-side embed config response.
@@ -69,12 +81,48 @@ export interface ServerEmbedConfig {
69
81
  };
70
82
  };
71
83
  }
84
+ /**
85
+ * Conversation summary in history list.
86
+ */
87
+ export interface ConversationSummary {
88
+ id: string;
89
+ title: string;
90
+ startedAt: string | null;
91
+ lastMessageAt: string | null;
92
+ messageCount: number;
93
+ }
94
+ /**
95
+ * Full conversation with messages.
96
+ */
97
+ export interface ConversationDetail extends ConversationSummary {
98
+ messages: Array<{
99
+ id: string;
100
+ role: 'user' | 'assistant';
101
+ content: string;
102
+ timestamp: string | null;
103
+ }>;
104
+ }
72
105
  export declare class APIClient {
73
106
  private config;
74
107
  private abortControllers;
75
108
  private mcpClient;
109
+ private _externalUserId;
76
110
  constructor(config: ResolvedConfig);
111
+ /**
112
+ * Get the underlying MCP client.
113
+ * Used by Pillar for direct MCP operations like sendActionResult.
114
+ */
115
+ get mcp(): MCPClient;
77
116
  private get baseUrl();
117
+ /**
118
+ * Set the external user ID for authenticated users.
119
+ * This ID will be included in all subsequent requests.
120
+ */
121
+ setExternalUserId(userId: string): void;
122
+ /**
123
+ * Clear the external user ID (for logout).
124
+ */
125
+ clearExternalUserId(): void;
78
126
  /**
79
127
  * Get or create a persistent visitor ID.
80
128
  * Stored in localStorage to persist across sessions.
@@ -110,7 +158,7 @@ export declare class APIClient {
110
158
  * @returns Promise with signed URL and expiration
111
159
  */
112
160
  uploadImage(file: File): Promise<ImageUploadResponse>;
113
- chat(message: string, history?: ChatMessage[], onChunk?: (chunk: string) => void, articleSlug?: string, existingConversationId?: string | null, onActions?: (actions: TaskButtonData[]) => void, onPlan?: (plan: ExecutionPlan) => void, userContext?: UserContextItem[], images?: ChatImage[], onProgress?: (progress: ProgressEvent) => void): Promise<ChatResponse>;
161
+ chat(message: string, history?: ChatMessage[], onChunk?: (chunk: string) => void, articleSlug?: string, existingConversationId?: string | null, onActions?: (actions: TaskButtonData[]) => void, userContext?: UserContextItem[], images?: ChatImage[], onProgress?: (progress: ProgressEvent) => void, onConversationStarted?: (conversationId: string, messageId?: string) => void, onActionRequest?: (request: ActionRequest) => Promise<void>): Promise<ChatResponse>;
114
162
  /**
115
163
  * Legacy chat method using the old /ai/chat/ endpoint.
116
164
  * @deprecated Use chat() which uses the MCP protocol.
@@ -154,5 +202,32 @@ export declare class APIClient {
154
202
  * Note: Context is passed to the MCP ask tool as additional arguments.
155
203
  */
156
204
  chatWithContext(message: string, history: ChatMessage[] | undefined, ctx: Context, userProfile: UserProfile, onChunk?: (chunk: string) => void, existingConversationId?: string | null, onActions?: (actions: TaskButtonData[]) => void): Promise<ChatResponse>;
205
+ /**
206
+ * Identify the current user after login.
207
+ * Links the anonymous visitor to the authenticated user ID, enabling
208
+ * cross-device conversation history.
209
+ *
210
+ * @param userId - Client's authenticated user ID
211
+ * @param profile - Optional user profile data
212
+ */
213
+ identify(userId: string, profile?: {
214
+ name?: string;
215
+ email?: string;
216
+ metadata?: Record<string, unknown>;
217
+ }): Promise<void>;
218
+ /**
219
+ * List past conversations for the current visitor.
220
+ *
221
+ * @param limit - Max number of conversations to return (default: 20, max: 50)
222
+ * @returns List of conversation summaries
223
+ */
224
+ listConversations(limit?: number): Promise<ConversationSummary[]>;
225
+ /**
226
+ * Get a single conversation with all messages.
227
+ *
228
+ * @param conversationId - UUID of the conversation
229
+ * @returns Conversation with messages
230
+ */
231
+ getConversation(conversationId: string): Promise<ConversationDetail | null>;
157
232
  cancelAllRequests(): void;
158
233
  }
@@ -6,8 +6,8 @@
6
6
  */
7
7
  import type { TaskButtonData } from '../components/Panel/TaskButton';
8
8
  import type { ResolvedConfig } from '../core/config';
9
- import type { ExecutionPlan } from '../core/plan';
10
9
  import type { UserContextItem } from '../types/user-context';
10
+ import { type LogEntry } from '../utils/debug';
11
11
  import type { ArticleSummary } from './client';
12
12
  /** MCP Tool result content */
13
13
  interface ToolResultContent {
@@ -23,7 +23,8 @@ export interface ToolResult {
23
23
  structuredContent?: {
24
24
  sources?: ArticleSummary[];
25
25
  actions?: ActionData[];
26
- plan?: ExecutionPlan;
26
+ /** Registered actions for dynamic action tools (persisted across turns) */
27
+ registered_actions?: Record<string, unknown>[];
27
28
  };
28
29
  _meta?: {
29
30
  conversation_id?: string;
@@ -45,6 +46,17 @@ export interface ActionData {
45
46
  score: number;
46
47
  data: Record<string, unknown>;
47
48
  }
49
+ /** Action request from agent (unified for all action execution) */
50
+ export interface ActionRequest {
51
+ /** Action name to execute */
52
+ action_name: string;
53
+ /** Parameters for the action */
54
+ parameters: Record<string, unknown>;
55
+ /** Full action definition (optional, for handler lookup) */
56
+ action?: ActionData;
57
+ /** Unique ID for this specific tool invocation (for result correlation) */
58
+ tool_call_id?: string;
59
+ }
48
60
  /** Streaming callbacks for tool calls */
49
61
  export interface StreamCallbacks {
50
62
  /** Called for each text token */
@@ -53,29 +65,32 @@ export interface StreamCallbacks {
53
65
  onSources?: (sources: ArticleSummary[]) => void;
54
66
  /** Called when actions are available */
55
67
  onActions?: (actions: ActionData[]) => void;
56
- /** Called when a plan is created (from plan.created event) */
57
- onPlan?: (plan: ExecutionPlan) => void;
68
+ /** Called when registered actions are received (for dynamic action tools) */
69
+ onRegisteredActions?: (actions: Record<string, unknown>[]) => void;
58
70
  /** Called on error */
59
71
  onError?: (error: string) => void;
72
+ /** Called when conversation_started event is received (early conversation_id) */
73
+ onConversationStarted?: (conversationId: string, messageId?: string) => void;
60
74
  /** Called when stream is complete */
61
75
  onComplete?: (conversationId?: string, queryLogId?: string) => void;
62
- /** Called for progress updates (search, query, generating, etc.) */
76
+ /** Called for progress updates (search, query, generating, thinking, etc.) */
63
77
  onProgress?: (progress: {
64
78
  kind: string;
65
- message?: string;
79
+ id?: string;
80
+ label?: string;
81
+ status?: 'active' | 'done' | 'error';
82
+ text?: string;
83
+ children?: Array<{
84
+ id: string;
85
+ label: string;
86
+ url?: string;
87
+ }>;
88
+ metadata?: Record<string, unknown>;
66
89
  progress_id?: string;
67
- metadata?: {
68
- sources?: Array<{
69
- title: string;
70
- url: string;
71
- score?: number;
72
- }>;
73
- result_count?: number;
74
- query?: string;
75
- action_name?: string;
76
- no_sources_used?: boolean;
77
- };
90
+ message?: string;
78
91
  }) => void;
92
+ /** Called when agent requests action execution (unified handler) */
93
+ onActionRequest?: (request: ActionRequest) => Promise<void>;
79
94
  }
80
95
  /** Image for chat requests (from upload-image endpoint) */
81
96
  export interface ChatImage {
@@ -92,7 +107,27 @@ export interface ImageUploadResponse {
92
107
  export declare class MCPClient {
93
108
  private config;
94
109
  private requestId;
110
+ private _externalUserId;
95
111
  constructor(config: ResolvedConfig);
112
+ /**
113
+ * Set the external user ID for authenticated users.
114
+ * Enables cross-device conversation history.
115
+ */
116
+ setExternalUserId(userId: string): void;
117
+ /**
118
+ * Get or create a persistent visitor ID.
119
+ * Stored in localStorage to persist across sessions.
120
+ */
121
+ private getVisitorId;
122
+ /**
123
+ * Get or create a session ID for MCP request correlation.
124
+ * Stored in sessionStorage to persist only for the current browser session.
125
+ */
126
+ private getSessionId;
127
+ /**
128
+ * Get the current page URL for analytics tracking.
129
+ */
130
+ private getPageUrl;
96
131
  private get baseUrl();
97
132
  private get headers();
98
133
  private nextId;
@@ -132,104 +167,83 @@ export declare class MCPClient {
132
167
  articleSlug?: string;
133
168
  userContext?: UserContextItem[];
134
169
  images?: ChatImage[];
170
+ history?: Array<{
171
+ role: 'user' | 'assistant';
172
+ content: string;
173
+ }>;
174
+ /** Registered actions from previous turns (for dynamic action tools) */
175
+ registeredActions?: Record<string, unknown>[];
135
176
  signal?: AbortSignal;
136
177
  }): Promise<ToolResult>;
137
178
  /**
138
- * Continue plan execution after receiving step result.
179
+ * Send action result back to the agent.
139
180
  *
140
- * Called by the SDK after executing a step that has
141
- * requires_result_feedback=true. The server analyzes the result
142
- * and updates subsequent steps if needed.
181
+ * Called after executing a query action (returns_data=true).
182
+ * The result is sent to the agent for further reasoning in the ReAct loop.
143
183
  *
144
- * @param planId - UUID of the plan
145
- * @param stepId - UUID of the completed step
146
- * @param result - Step execution result
147
- * @returns Updated plan with all steps
184
+ * @param actionName - The name of the action that was executed
185
+ * @param result - The result data to send back to the agent
186
+ * @param toolCallId - Unique ID for this specific tool invocation (for result correlation)
187
+ * @returns Promise that resolves when the result is delivered, or rejects on error
148
188
  */
149
- continuePlan(planId: string, stepId: string, result: unknown): Promise<{
150
- plan: ExecutionPlan;
151
- }>;
189
+ sendActionResult(actionName: string, result: unknown, toolCallId?: string): Promise<void>;
152
190
  /**
153
- * Cancel an in-progress plan.
191
+ * Send a client-side log to the server for debugging.
154
192
  *
155
- * Marks the plan as cancelled and skips any pending steps.
193
+ * Logs are correlated with agent sessions via the MCP session ID.
194
+ * Use this to forward important SDK events to server logs.
156
195
  *
157
- * @param planId - UUID of the plan to cancel
158
- * @returns Updated plan with cancelled status
196
+ * @param level - Log level: 'log', 'warn', or 'error'
197
+ * @param message - The log message
198
+ * @param data - Optional additional data to include
159
199
  */
160
- cancelPlan(planId: string): Promise<{
161
- plan: ExecutionPlan;
162
- }>;
200
+ sendLog(level: 'log' | 'warn' | 'error', message: string, data?: unknown): Promise<void>;
163
201
  /**
164
- * Get current state of a plan.
202
+ * Send a batch of client-side logs to the server.
165
203
  *
166
- * Returns the plan and all its steps with current statuses.
204
+ * Logs are buffered and sent periodically (every 5 seconds by default)
205
+ * to reduce network requests. This method is called by the debug module.
167
206
  *
168
- * @param planId - UUID of the plan
169
- * @returns Plan with all steps
207
+ * @param logs - Array of log entries to send
170
208
  */
171
- getPlan(planId: string): Promise<{
172
- plan: ExecutionPlan;
173
- }>;
209
+ sendLogBatch(logs: LogEntry[]): void;
174
210
  /**
175
- * Start a plan that was waiting for user confirmation.
211
+ * Check if a conversation has a resumable interrupted session.
176
212
  *
177
- * For plans with auto_execute=false, the user must explicitly
178
- * start execution by calling this method.
179
- *
180
- * @param planId - UUID of the plan to start
181
- * @returns Updated plan with executing status
213
+ * @param conversationId - The conversation UUID to check
214
+ * @returns Session status with resumption details, or null if not resumable
182
215
  */
183
- startPlan(planId: string): Promise<{
184
- plan: ExecutionPlan;
185
- }>;
216
+ getConversationStatus(conversationId: string): Promise<ConversationStatus | null>;
186
217
  /**
187
- * Retry a failed step.
218
+ * Resume an interrupted conversation.
188
219
  *
189
- * Increments the retry count and resets the step to ready status.
190
- * Only works if the step is retriable and hasn't exceeded max_retries.
220
+ * Returns a streaming response that continues the conversation
221
+ * from where it was interrupted.
191
222
  *
192
- * @param planId - UUID of the plan
193
- * @param stepId - UUID of the step to retry
194
- * @returns Updated plan with step reset to ready
195
- */
196
- retryStep(planId: string, stepId: string): Promise<{
197
- plan: ExecutionPlan;
198
- }>;
199
- /**
200
- * Mark a step as failed.
201
- *
202
- * Records the error and determines if the plan should also fail
203
- * (if step is not retriable or out of retries).
204
- *
205
- * @param planId - UUID of the plan
206
- * @param stepId - UUID of the failed step
207
- * @param errorMessage - Optional error message
208
- * @returns Updated plan with failed step
223
+ * @param conversationId - The conversation to resume
224
+ * @param userContext - Optional current page context
225
+ * @param callbacks - Streaming callbacks
209
226
  */
210
- failStep(planId: string, stepId: string, errorMessage?: string): Promise<{
211
- plan: ExecutionPlan;
212
- }>;
227
+ resumeConversation(conversationId: string, userContext: Record<string, unknown> | undefined, callbacks: StreamCallbacks): Promise<void>;
213
228
  /**
214
- * Skip a step and advance to the next one.
215
- *
216
- * @param planId - UUID of the plan
217
- * @param stepId - UUID of the step to skip
218
- * @returns Updated plan with skipped step and next step ready
229
+ * Handle events from the resume stream.
219
230
  */
220
- skipStep(planId: string, stepId: string): Promise<{
221
- plan: ExecutionPlan;
231
+ private handleResumeStreamEvent;
232
+ }
233
+ /**
234
+ * Conversation status for session resumption.
235
+ */
236
+ export interface ConversationStatus {
237
+ resumable: boolean;
238
+ message_id?: string;
239
+ elapsed_ms?: number;
240
+ user_message?: string;
241
+ partial_response?: string;
242
+ summary?: string;
243
+ accomplished?: Array<{
244
+ action: string;
245
+ result_summary: string;
222
246
  }>;
223
- /**
224
- * Send action result back to the agent.
225
- *
226
- * Called after executing a query action (returns_data=true).
227
- * The result is sent to the agent for further reasoning in the ReAct loop.
228
- *
229
- * @param actionName - The name of the action that was executed
230
- * @param result - The result data to send back to the agent
231
- */
232
- sendActionResult(actionName: string, result: unknown): void;
233
247
  }
234
248
  /**
235
249
  * Convert ActionData from MCP response to TaskButtonData for UI rendering.