@pillar-ai/sdk 0.1.19 → 0.1.22

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/dist/actions/definitions/analytics.d.ts +18 -0
  2. package/dist/actions/definitions/content.d.ts +40 -0
  3. package/dist/actions/definitions/index.d.ts +26 -0
  4. package/dist/actions/definitions/navigation.d.ts +65 -0
  5. package/dist/actions/definitions/settings.d.ts +162 -0
  6. package/dist/actions/definitions/sources.d.ts +44 -0
  7. package/dist/actions/definitions/support.d.ts +15 -0
  8. package/dist/actions/definitions/team.d.ts +120 -0
  9. package/dist/api/ag-ui-adapter.d.ts +76 -0
  10. package/dist/api/ag-ui-bridge.d.ts +49 -0
  11. package/dist/api/ag-ui-client.d.ts +102 -0
  12. package/dist/api/ag-ui-handler.d.ts +89 -0
  13. package/dist/api/mcp-client.d.ts +46 -24
  14. package/dist/cli/sync.js +253 -174
  15. package/dist/components/Button/FloatingButton.d.ts +46 -0
  16. package/dist/components/PagePilot/styles.d.ts +1 -1
  17. package/dist/components/Panel/TabNavigation.d.ts +16 -0
  18. package/dist/components/Panel/styles.d.ts +1 -1
  19. package/dist/components/Progress/AGUIProgress.d.ts +15 -0
  20. package/dist/components/Progress/ErrorRow.d.ts +12 -0
  21. package/dist/components/Progress/index.d.ts +1 -0
  22. package/dist/components/Tooltips/Tooltip.d.ts +46 -0
  23. package/dist/components/Tooltips/TooltipManager.d.ts +41 -0
  24. package/dist/components/Tooltips/index.d.ts +6 -0
  25. package/dist/components/Tooltips/styles.d.ts +5 -0
  26. package/dist/components/Views/ArticleChatView.d.ts +10 -0
  27. package/dist/components/Views/ArticleView.d.ts +10 -0
  28. package/dist/components/Views/CategoryView.d.ts +11 -0
  29. package/dist/components/Views/HelpCenterArticles.d.ts +17 -0
  30. package/dist/components/Views/SearchView.d.ts +10 -0
  31. package/dist/components/Views/SupportView.d.ts +15 -0
  32. package/dist/components/shared/ArticleCard.d.ts +17 -0
  33. package/dist/components/shared/CategoryCard.d.ts +17 -0
  34. package/dist/content/extensions/AccordionNode.d.ts +10 -0
  35. package/dist/content/extensions/CalloutNode.d.ts +11 -0
  36. package/dist/content/extensions/index.d.ts +5 -0
  37. package/dist/content/index.d.ts +5 -0
  38. package/dist/content/renderer.d.ts +24 -0
  39. package/dist/core/Pillar.d.ts +85 -28
  40. package/dist/core/config.d.ts +1 -1
  41. package/dist/core/events.d.ts +7 -1
  42. package/dist/index.d.ts +2 -2
  43. package/dist/pillar.esm.js +1 -1
  44. package/dist/store/chat.d.ts +12 -0
  45. package/dist/store/tooltips.d.ts +21 -0
  46. package/dist/tools/index.d.ts +27 -0
  47. package/dist/tools/registry.d.ts +106 -0
  48. package/dist/tools/types.d.ts +564 -0
  49. package/dist/utils/helpdesk.d.ts +33 -0
  50. package/dist/utils/markdown.d.ts +9 -0
  51. package/dist/utils/resilient-fetch.d.ts +25 -0
  52. package/package.json +12 -3
  53. package/src/actions/types.ts +0 -524
@@ -0,0 +1,102 @@
1
+ /**
2
+ * AG-UI Protocol Client for Pillar SDK
3
+ *
4
+ * Implements the AG-UI specification for streaming agent interactions.
5
+ * Uses the @ag-ui/client HttpAgent for transport.
6
+ *
7
+ * Copyright (C) 2025 Pillar Team
8
+ */
9
+ import type { ResolvedConfig } from '../core/config';
10
+ export interface AGUIStreamCallbacks {
11
+ /** Called when run starts */
12
+ onRunStarted?: (runId: string) => void;
13
+ /** Called when run completes successfully */
14
+ onRunFinished?: () => void;
15
+ /** Called on error */
16
+ onError?: (error: Error) => void;
17
+ /** Called when a step starts */
18
+ onStepStarted?: (stepName: string) => void;
19
+ /** Called when a step finishes */
20
+ onStepFinished?: (stepName: string) => void;
21
+ /** Called for text message streaming */
22
+ onTextContent?: (messageId: string, delta: string) => void;
23
+ /** Called when text message completes */
24
+ onTextComplete?: (messageId: string, fullContent: string) => void;
25
+ /** Called when tool call starts (for UI display) */
26
+ onToolCallStart?: (toolCallId: string, toolName: string) => void;
27
+ /** Called with tool call arguments */
28
+ onToolCallArgs?: (toolCallId: string, argsJson: string) => void;
29
+ /** Called when tool call completes */
30
+ onToolCallEnd?: (toolCallId: string) => void;
31
+ /** Called when tool result is available */
32
+ onToolCallResult?: (toolCallId: string, result: string) => void;
33
+ /** Called for state delta events (sources, actions, plan) */
34
+ onStateDelta?: (delta: unknown[]) => void;
35
+ /** Called for state snapshots */
36
+ onStateSnapshot?: (state: unknown) => void;
37
+ }
38
+ export interface ClientTool {
39
+ name: string;
40
+ description: string;
41
+ parameters: Record<string, unknown>;
42
+ /** Handler function - called when agent requests this tool */
43
+ handler?: (args: Record<string, unknown>) => Promise<unknown>;
44
+ }
45
+ export declare class AGUIClient {
46
+ private config;
47
+ private agent;
48
+ private currentRunId;
49
+ private currentThreadId;
50
+ private messageAccumulators;
51
+ private toolArgAccumulators;
52
+ private toolCallNames;
53
+ private registeredTools;
54
+ constructor(config: ResolvedConfig);
55
+ /**
56
+ * Get or create a persistent thread ID for this session.
57
+ */
58
+ private getOrCreateThreadId;
59
+ private getBrowserLanguage;
60
+ /**
61
+ * Register a client-side tool that can be called by the agent.
62
+ */
63
+ registerTool(tool: ClientTool): void;
64
+ /**
65
+ * Unregister a client-side tool.
66
+ */
67
+ unregisterTool(toolName: string): void;
68
+ /**
69
+ * Send a message and stream the agent's response.
70
+ */
71
+ chat(message: string, callbacks: AGUIStreamCallbacks, options?: {
72
+ history?: Array<{
73
+ role: 'user' | 'assistant';
74
+ content: string;
75
+ }>;
76
+ userContext?: Array<{
77
+ type: string;
78
+ [key: string]: unknown;
79
+ }>;
80
+ signal?: AbortSignal;
81
+ }): Promise<void>;
82
+ /**
83
+ * Execute a client-side tool if registered.
84
+ */
85
+ private maybeExecuteClientTool;
86
+ /**
87
+ * Send tool execution result back to the server.
88
+ */
89
+ sendToolResult(toolCallId: string, result: unknown, error?: string): Promise<void>;
90
+ /**
91
+ * Start a new conversation thread.
92
+ */
93
+ newThread(): string;
94
+ /**
95
+ * Get current thread ID.
96
+ */
97
+ get threadId(): string;
98
+ /**
99
+ * Get current run ID.
100
+ */
101
+ get runId(): string | null;
102
+ }
@@ -0,0 +1,89 @@
1
+ /**
2
+ * AG-UI Event Handler
3
+ *
4
+ * Processes AG-UI protocol events and maintains UI state.
5
+ * Replaces the complex JSON-RPC parsing in mcp-client.ts.
6
+ */
7
+ import type { AGUIEvent } from '@ag-ui/core';
8
+ /** A streaming text message being accumulated */
9
+ export interface StreamingMessage {
10
+ id: string;
11
+ role: 'user' | 'assistant';
12
+ content: string;
13
+ complete: boolean;
14
+ /** Which step this message belongs to (for thinking vs response) */
15
+ stepName?: string;
16
+ }
17
+ /** A tool call being tracked */
18
+ export interface ToolCallState {
19
+ id: string;
20
+ name: string;
21
+ args: string;
22
+ result?: unknown;
23
+ complete: boolean;
24
+ /** True if this tool executes on the client (query action) */
25
+ isClientSide?: boolean;
26
+ }
27
+ /** State delta data (sources, actions, plan, etc.) */
28
+ export interface StateDeltaData {
29
+ type: string;
30
+ data: unknown;
31
+ timestamp: number;
32
+ }
33
+ /** Complete AG-UI state */
34
+ export interface AGUIState {
35
+ /** Current run ID */
36
+ runId: string | null;
37
+ /** Thread ID (replaces conversation_id) */
38
+ threadId: string | null;
39
+ /** Current step name (e.g., "reasoning", "tool_execution") */
40
+ currentStep: string | null;
41
+ /** Streaming messages keyed by message ID */
42
+ messages: Map<string, StreamingMessage>;
43
+ /** Tool calls keyed by tool call ID */
44
+ toolCalls: Map<string, ToolCallState>;
45
+ /** State deltas received (sources, actions, plans) */
46
+ stateDeltas: StateDeltaData[];
47
+ /** Whether the run is complete */
48
+ isComplete: boolean;
49
+ /** Error if run failed */
50
+ error: Error | null;
51
+ }
52
+ export interface AGUIHandlerCallbacks {
53
+ /** Called whenever state changes */
54
+ onStateChange: (state: AGUIState) => void;
55
+ /** Called when an error occurs */
56
+ onError: (error: Error) => void;
57
+ /** Called when run completes successfully */
58
+ onComplete: () => void;
59
+ /** Called when a client-side tool needs execution */
60
+ onClientToolCall?: (toolCall: ToolCallState) => Promise<unknown>;
61
+ }
62
+ /**
63
+ * Create an AG-UI event handler.
64
+ *
65
+ * Returns an object with a handleEvent method that processes
66
+ * AG-UI events and updates internal state.
67
+ */
68
+ export declare function createAGUIHandler(callbacks: AGUIHandlerCallbacks): {
69
+ handleEvent: (event: AGUIEvent) => Promise<void>;
70
+ reset: () => void;
71
+ getState: () => AGUIState;
72
+ };
73
+ /**
74
+ * Register a tool as client-side.
75
+ * Called when the SDK registers an action with returns: true.
76
+ */
77
+ export declare function registerClientSideTool(toolName: string): void;
78
+ /**
79
+ * Unregister a client-side tool.
80
+ */
81
+ export declare function unregisterClientSideTool(toolName: string): void;
82
+ /**
83
+ * Check if a tool executes on the client side.
84
+ */
85
+ export declare function isClientSideTool(toolName: string): boolean;
86
+ /**
87
+ * Get all registered client-side tools.
88
+ */
89
+ export declare function getClientSideTools(): string[];
@@ -22,8 +22,12 @@ export interface ToolResult {
22
22
  isError?: boolean;
23
23
  structuredContent?: {
24
24
  sources?: ArticleSummary[];
25
- actions?: ActionData[];
26
- /** Registered actions for dynamic action tools (persisted across turns) */
25
+ tools?: ToolData[];
26
+ /** @deprecated Use tools instead */
27
+ actions?: ToolData[];
28
+ /** Registered tools for dynamic tool invocations (persisted across turns) */
29
+ registered_tools?: Record<string, unknown>[];
30
+ /** @deprecated Use registered_tools instead */
27
31
  registered_actions?: Record<string, unknown>[];
28
32
  };
29
33
  _meta?: {
@@ -31,32 +35,36 @@ export interface ToolResult {
31
35
  query_log_id?: string;
32
36
  };
33
37
  }
34
- /** Action data from MCP server */
35
- export interface ActionData {
38
+ /** Tool data from MCP server */
39
+ export interface ToolData {
36
40
  id: string;
37
41
  name: string;
38
42
  description: string;
39
43
  action_type: string;
40
- /** If true, action executes immediately without user clicking */
44
+ /** If true, tool executes immediately without user clicking */
41
45
  auto_run: boolean;
42
- /** If true, action completes without waiting for host confirmation */
46
+ /** If true, tool completes without waiting for host confirmation */
43
47
  auto_complete: boolean;
44
- /** If true, action returns data for agent reasoning */
48
+ /** If true, tool returns data for agent reasoning */
45
49
  returns_data: boolean;
46
50
  score: number;
47
51
  data: Record<string, unknown>;
48
52
  }
49
- /** Action request from agent (unified for all action execution) */
50
- export interface ActionRequest {
51
- /** Action name to execute */
53
+ /** @deprecated Use ToolData instead */
54
+ export type ActionData = ToolData;
55
+ /** Tool request from agent (unified for all tool execution) */
56
+ export interface ToolRequest {
57
+ /** Tool name to execute */
52
58
  action_name: string;
53
- /** Parameters for the action */
59
+ /** Parameters for the tool */
54
60
  parameters: Record<string, unknown>;
55
- /** Full action definition (optional, for handler lookup) */
56
- action?: ActionData;
61
+ /** Full tool definition (optional, for handler lookup) */
62
+ action?: ToolData;
57
63
  /** Unique ID for this specific tool invocation (for result correlation) */
58
64
  tool_call_id?: string;
59
65
  }
66
+ /** @deprecated Use ToolRequest instead */
67
+ export type ActionRequest = ToolRequest;
60
68
  /** Token usage data from the agentic loop (sent after each LLM iteration) */
61
69
  export interface TokenUsage {
62
70
  /** Input tokens for this iteration */
@@ -84,9 +92,13 @@ export interface StreamCallbacks {
84
92
  onToken?: (token: string) => void;
85
93
  /** Called when sources are available */
86
94
  onSources?: (sources: ArticleSummary[]) => void;
87
- /** Called when actions are available */
88
- onActions?: (actions: ActionData[]) => void;
89
- /** Called when registered actions are received (for dynamic action tools) */
95
+ /** Called when tools are available */
96
+ onTools?: (tools: ToolData[]) => void;
97
+ /** @deprecated Use onTools instead */
98
+ onActions?: (actions: ToolData[]) => void;
99
+ /** Called when registered tools are received (for dynamic tool invocations) */
100
+ onRegisteredTools?: (tools: Record<string, unknown>[]) => void;
101
+ /** @deprecated Use onRegisteredTools instead */
90
102
  onRegisteredActions?: (actions: Record<string, unknown>[]) => void;
91
103
  /** Called on error */
92
104
  onError?: (error: string) => void;
@@ -112,8 +124,10 @@ export interface StreamCallbacks {
112
124
  }) => void;
113
125
  /** Called immediately with the request ID (for cancellation support) */
114
126
  onRequestId?: (requestId: number) => void;
115
- /** Called when agent requests action execution (unified handler) */
116
- onActionRequest?: (request: ActionRequest) => Promise<void>;
127
+ /** Called when agent requests tool execution (unified handler) */
128
+ onToolRequest?: (request: ToolRequest) => Promise<void>;
129
+ /** @deprecated Use onToolRequest instead */
130
+ onActionRequest?: (request: ToolRequest) => Promise<void>;
117
131
  /** Called when token usage is updated (after each LLM iteration) */
118
132
  onTokenUsage?: (usage: TokenUsage) => void;
119
133
  }
@@ -199,7 +213,9 @@ export declare class MCPClient {
199
213
  role: 'user' | 'assistant';
200
214
  content: string;
201
215
  }>;
202
- /** Registered actions from previous turns (for dynamic action tools) */
216
+ /** Registered tools from previous turns (for dynamic tool invocations) */
217
+ registeredTools?: Record<string, unknown>[];
218
+ /** @deprecated Use registeredTools instead */
203
219
  registeredActions?: Record<string, unknown>[];
204
220
  signal?: AbortSignal;
205
221
  /** Conversation ID - generated client-side, always provided */
@@ -217,16 +233,18 @@ export declare class MCPClient {
217
233
  */
218
234
  cancelStream(requestId: number | string): Promise<void>;
219
235
  /**
220
- * Send action result back to the agent.
236
+ * Send tool result back to the agent.
221
237
  *
222
- * Called after executing a query action (returns_data=true).
238
+ * Called after executing a query tool (returns_data=true).
223
239
  * The result is sent to the agent for further reasoning in the ReAct loop.
224
240
  *
225
- * @param actionName - The name of the action that was executed
241
+ * @param toolName - The name of the tool that was executed
226
242
  * @param result - The result data to send back to the agent
227
243
  * @param toolCallId - Unique ID for this specific tool invocation (for result correlation)
228
244
  * @returns Promise that resolves when the result is delivered, or rejects on error
229
245
  */
246
+ sendToolResult(toolName: string, result: unknown, toolCallId?: string): Promise<void>;
247
+ /** @deprecated Use sendToolResult instead */
230
248
  sendActionResult(actionName: string, result: unknown, toolCallId?: string): Promise<void>;
231
249
  /**
232
250
  * Send a client-side log to the server for debugging.
@@ -266,10 +284,14 @@ export interface ConversationStatus {
266
284
  user_message?: string;
267
285
  partial_response?: string;
268
286
  display_trace?: DisplayStep[];
287
+ registered_tools?: Record<string, unknown>[];
288
+ /** @deprecated Use registered_tools instead */
269
289
  registered_actions?: Record<string, unknown>[];
270
290
  }
271
291
  /**
272
- * Convert ActionData from MCP response to TaskButtonData for UI rendering.
292
+ * Convert ToolData from MCP response to TaskButtonData for UI rendering.
273
293
  */
274
- export declare function actionToTaskButton(action: ActionData): TaskButtonData;
294
+ export declare function toolToTaskButton(tool: ToolData): TaskButtonData;
295
+ /** @deprecated Use toolToTaskButton instead */
296
+ export declare const actionToTaskButton: typeof toolToTaskButton;
275
297
  export {};