@pillar-ai/sdk 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +129 -0
- package/dist/actions/definitions/analytics.d.ts +18 -0
- package/dist/actions/definitions/content.d.ts +40 -0
- package/dist/actions/definitions/index.d.ts +26 -0
- package/dist/actions/definitions/navigation.d.ts +65 -0
- package/dist/actions/definitions/settings.d.ts +162 -0
- package/dist/actions/definitions/sources.d.ts +44 -0
- package/dist/actions/definitions/support.d.ts +15 -0
- package/dist/actions/definitions/team.d.ts +120 -0
- package/dist/actions/index.d.ts +33 -0
- package/dist/actions/registry.d.ts +110 -0
- package/dist/actions/types.d.ts +388 -0
- package/dist/api/client.d.ts +186 -0
- package/dist/api/mcp-client.d.ts +226 -0
- package/dist/button/FloatingButton.d.ts +44 -0
- package/dist/cli/sync.d.ts +2 -0
- package/dist/components/Button/EdgeTrigger.d.ts +78 -0
- package/dist/components/Button/FloatingButton.d.ts +46 -0
- package/dist/components/Button/index.d.ts +5 -0
- package/dist/components/Cards/ConfirmActionCard.d.ts +23 -0
- package/dist/components/Cards/index.d.ts +6 -0
- package/dist/components/Panel/ChatInput.d.ts +5 -0
- package/dist/components/Panel/ContextTag.d.ts +18 -0
- package/dist/components/Panel/Header.d.ts +14 -0
- package/dist/components/Panel/Panel.d.ts +104 -0
- package/dist/components/Panel/PanelContent.d.ts +6 -0
- package/dist/components/Panel/TaskButton.d.ts +59 -0
- package/dist/components/Panel/UnifiedChatInput.d.ts +23 -0
- package/dist/components/Panel/WorkflowChecklist.d.ts +9 -0
- package/dist/components/Panel/index.d.ts +13 -0
- package/dist/components/Panel/styles.d.ts +20 -0
- package/dist/components/Plan/InlinePlanView.d.ts +24 -0
- package/dist/components/Plan/PlanStepItem.d.ts +18 -0
- package/dist/components/Plan/PlanView.d.ts +10 -0
- package/dist/components/Plan/index.d.ts +8 -0
- package/dist/components/TextSelection/TextSelectionManager.d.ts +34 -0
- package/dist/components/TextSelection/TextSelectionPopover.d.ts +14 -0
- package/dist/components/TextSelection/index.d.ts +6 -0
- package/dist/components/TextSelection/styles.d.ts +5 -0
- package/dist/components/Tooltips/Tooltip.d.ts +46 -0
- package/dist/components/Tooltips/TooltipManager.d.ts +41 -0
- package/dist/components/Tooltips/index.d.ts +6 -0
- package/dist/components/Tooltips/styles.d.ts +5 -0
- package/dist/components/Views/ArticleChatView.d.ts +9 -0
- package/dist/components/Views/ArticleView.d.ts +10 -0
- package/dist/components/Views/CategoryView.d.ts +11 -0
- package/dist/components/Views/ChatView.d.ts +5 -0
- package/dist/components/Views/DeveloperView.d.ts +6 -0
- package/dist/components/Views/HomeView.d.ts +5 -0
- package/dist/components/Views/SearchView.d.ts +10 -0
- package/dist/components/Views/index.d.ts +5 -0
- package/dist/components/context.d.ts +21 -0
- package/dist/components/index.d.ts +9 -0
- package/dist/components/shared/ArticleCard.d.ts +17 -0
- package/dist/components/shared/CategoryCard.d.ts +17 -0
- package/dist/components/shared/Empty.d.ts +11 -0
- package/dist/components/shared/Loading.d.ts +6 -0
- package/dist/components/shared/MessageInputArea.d.ts +19 -0
- package/dist/components/shared/QuestionChip.d.ts +14 -0
- package/dist/components/shared/index.d.ts +7 -0
- package/dist/content/extensions/AccordionNode.d.ts +10 -0
- package/dist/content/extensions/CalloutNode.d.ts +11 -0
- package/dist/content/extensions/index.d.ts +5 -0
- package/dist/content/index.d.ts +5 -0
- package/dist/content/renderer.d.ts +24 -0
- package/dist/core/Pillar.d.ts +454 -0
- package/dist/core/config.d.ts +253 -0
- package/dist/core/context.d.ts +71 -0
- package/dist/core/events.d.ts +228 -0
- package/dist/core/plan-executor.d.ts +101 -0
- package/dist/core/plan.d.ts +155 -0
- package/dist/core/workflow.d.ts +89 -0
- package/dist/index.d.ts +32 -0
- package/dist/panel/Panel.d.ts +53 -0
- package/dist/panel/PanelUI.d.ts +43 -0
- package/dist/panel/components/ArticleCard.d.ts +10 -0
- package/dist/panel/components/CategoryCard.d.ts +10 -0
- package/dist/panel/components/ChatInput.d.ts +36 -0
- package/dist/panel/components/Header.d.ts +16 -0
- package/dist/panel/components/SearchInput.d.ts +11 -0
- package/dist/panel/styles.d.ts +5 -0
- package/dist/panel/views/ArticleView.d.ts +21 -0
- package/dist/panel/views/CategoryView.d.ts +20 -0
- package/dist/panel/views/ChatView.d.ts +30 -0
- package/dist/panel/views/HomeView.d.ts +18 -0
- package/dist/panel/views/SearchView.d.ts +22 -0
- package/dist/pillar.esm.js +10338 -0
- package/dist/pillar.esm.js.map +1 -0
- package/dist/pillar.js +10362 -0
- package/dist/pillar.js.map +1 -0
- package/dist/pillar.min.js +2 -0
- package/dist/pillar.min.js.map +1 -0
- package/dist/store/chat.d.ts +85 -0
- package/dist/store/context.d.ts +46 -0
- package/dist/store/developer.d.ts +19 -0
- package/dist/store/index.d.ts +10 -0
- package/dist/store/panel.d.ts +43 -0
- package/dist/store/plan-persistence.d.ts +47 -0
- package/dist/store/plan.d.ts +45 -0
- package/dist/store/router.d.ts +18 -0
- package/dist/store/tooltips.d.ts +21 -0
- package/dist/store/workflow.d.ts +48 -0
- package/dist/tooltips/Tooltip.d.ts +63 -0
- package/dist/tooltips/TooltipManager.d.ts +42 -0
- package/dist/tooltips/styles.d.ts +5 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/user-context.d.ts +29 -0
- package/dist/utils/dom.d.ts +46 -0
- package/dist/utils/markdown.d.ts +9 -0
- package/dist/utils/positioning.d.ts +52 -0
- package/dist/utils/urlParams.d.ts +27 -0
- package/package.json +86 -0
- package/src/actions/types.ts +468 -0
- package/src/cli/sync.ts +477 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* QuestionChip Component
|
|
3
|
+
* Clickable chip for suggested questions
|
|
4
|
+
*/
|
|
5
|
+
import { h } from 'preact';
|
|
6
|
+
export interface QuestionChipProps {
|
|
7
|
+
text: string;
|
|
8
|
+
onClick: () => void;
|
|
9
|
+
}
|
|
10
|
+
export declare function QuestionChip({ text, onClick }: QuestionChipProps): h.JSX.Element;
|
|
11
|
+
/**
|
|
12
|
+
* Skeleton placeholder for loading state
|
|
13
|
+
*/
|
|
14
|
+
export declare function QuestionChipSkeleton(): h.JSX.Element;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Accordion Node Extension for TipTap (vanilla - HTML rendering only)
|
|
3
|
+
* Used to render collapsible accordion blocks in article content
|
|
4
|
+
*/
|
|
5
|
+
import { Node } from '@tiptap/core';
|
|
6
|
+
/**
|
|
7
|
+
* TipTap Accordion Node Extension (vanilla, no React)
|
|
8
|
+
* Renders accordion blocks using HTML details/summary elements
|
|
9
|
+
*/
|
|
10
|
+
export declare const AccordionNode: Node<any, any>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Callout Node Extension for TipTap (vanilla - HTML rendering only)
|
|
3
|
+
* Used to render callout blocks in article content
|
|
4
|
+
*/
|
|
5
|
+
import { Node } from '@tiptap/core';
|
|
6
|
+
export type CalloutType = 'info' | 'warning' | 'tip' | 'error' | 'success';
|
|
7
|
+
/**
|
|
8
|
+
* TipTap Callout Node Extension (vanilla, no React)
|
|
9
|
+
* Renders callout blocks with type-specific styling classes
|
|
10
|
+
*/
|
|
11
|
+
export declare const CalloutNode: Node<any, any>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TipTap Content Renderer
|
|
3
|
+
* Converts TipTap JSON content to HTML for display in the SDK panel
|
|
4
|
+
*/
|
|
5
|
+
import type { JSONContent } from '@tiptap/core';
|
|
6
|
+
/**
|
|
7
|
+
* Check if content is TipTap JSON format (has a 'type' property)
|
|
8
|
+
*/
|
|
9
|
+
export declare function isJSONContent(content: unknown): content is JSONContent;
|
|
10
|
+
/**
|
|
11
|
+
* Render TipTap JSON content to HTML
|
|
12
|
+
*
|
|
13
|
+
* @param content - TipTap JSON content object
|
|
14
|
+
* @returns HTML string
|
|
15
|
+
*/
|
|
16
|
+
export declare function renderTipTapContent(content: JSONContent): string;
|
|
17
|
+
/**
|
|
18
|
+
* Render article content to HTML
|
|
19
|
+
* Handles both TipTap JSON and legacy HTML string content
|
|
20
|
+
*
|
|
21
|
+
* @param content - TipTap JSON content or HTML string
|
|
22
|
+
* @returns HTML string
|
|
23
|
+
*/
|
|
24
|
+
export declare function renderArticleContent(content: JSONContent | string | null | undefined): string;
|
|
@@ -0,0 +1,454 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Main Pillar SDK Class
|
|
3
|
+
* Entry point for all SDK functionality
|
|
4
|
+
*/
|
|
5
|
+
import { type PillarConfig, type ResolvedConfig, type ThemeConfig } from './config';
|
|
6
|
+
import { type ProductContext, type Suggestion, type UserProfile } from './context';
|
|
7
|
+
import { type CardRenderer, type PillarEvents, type TaskExecutePayload } from './events';
|
|
8
|
+
import type { ExecutionPlan } from './plan';
|
|
9
|
+
import type { Workflow } from './workflow';
|
|
10
|
+
export type PillarState = 'uninitialized' | 'initializing' | 'ready' | 'error';
|
|
11
|
+
export declare class Pillar {
|
|
12
|
+
private static instance;
|
|
13
|
+
private _state;
|
|
14
|
+
private _config;
|
|
15
|
+
private _events;
|
|
16
|
+
private _api;
|
|
17
|
+
private _mcpClient;
|
|
18
|
+
private _planExecutor;
|
|
19
|
+
private _tooltipManager;
|
|
20
|
+
private _textSelectionManager;
|
|
21
|
+
private _panel;
|
|
22
|
+
private _floatingButton;
|
|
23
|
+
private _initPromise;
|
|
24
|
+
private _rootContainer;
|
|
25
|
+
private _unsubscribeHoverMode;
|
|
26
|
+
private _productContext;
|
|
27
|
+
private _userProfile;
|
|
28
|
+
private _taskHandlers;
|
|
29
|
+
private _anyTaskHandler;
|
|
30
|
+
private _cardRenderers;
|
|
31
|
+
constructor();
|
|
32
|
+
/**
|
|
33
|
+
* Create or get the shared root container for all Pillar UI elements.
|
|
34
|
+
* Uses isolation: isolate to create a new stacking context.
|
|
35
|
+
* Z-index changes based on hover mode (999 in hover mode, -1 in push mode).
|
|
36
|
+
*/
|
|
37
|
+
private _createRootContainer;
|
|
38
|
+
/**
|
|
39
|
+
* Subscribe to hover mode changes and update root container z-index.
|
|
40
|
+
*/
|
|
41
|
+
private _subscribeToHoverModeForRoot;
|
|
42
|
+
/**
|
|
43
|
+
* Initialize the Pillar SDK
|
|
44
|
+
*/
|
|
45
|
+
static init(config: PillarConfig): Promise<Pillar>;
|
|
46
|
+
/**
|
|
47
|
+
* Get the current Pillar instance
|
|
48
|
+
*/
|
|
49
|
+
static getInstance(): Pillar | null;
|
|
50
|
+
/**
|
|
51
|
+
* Destroy the Pillar instance
|
|
52
|
+
*/
|
|
53
|
+
static destroy(): void;
|
|
54
|
+
/**
|
|
55
|
+
* Current SDK state
|
|
56
|
+
*/
|
|
57
|
+
get state(): PillarState;
|
|
58
|
+
/**
|
|
59
|
+
* Whether SDK is ready
|
|
60
|
+
*/
|
|
61
|
+
get isReady(): boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Whether the panel is currently open
|
|
64
|
+
*/
|
|
65
|
+
get isPanelOpen(): boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Get the resolved configuration
|
|
68
|
+
*/
|
|
69
|
+
get config(): ResolvedConfig | null;
|
|
70
|
+
/**
|
|
71
|
+
* Subscribe to SDK events
|
|
72
|
+
*/
|
|
73
|
+
on<K extends keyof PillarEvents>(event: K, callback: (data: PillarEvents[K]) => void): () => void;
|
|
74
|
+
/**
|
|
75
|
+
* Open the help panel
|
|
76
|
+
*/
|
|
77
|
+
open(options?: {
|
|
78
|
+
view?: string;
|
|
79
|
+
article?: string;
|
|
80
|
+
search?: string;
|
|
81
|
+
focusInput?: boolean;
|
|
82
|
+
}): void;
|
|
83
|
+
/**
|
|
84
|
+
* Close the help panel
|
|
85
|
+
*/
|
|
86
|
+
close(): void;
|
|
87
|
+
/**
|
|
88
|
+
* Toggle the help panel
|
|
89
|
+
*/
|
|
90
|
+
toggle(): void;
|
|
91
|
+
/**
|
|
92
|
+
* Navigate to a specific view in the panel
|
|
93
|
+
*/
|
|
94
|
+
navigate(view: string, params?: Record<string, string>): void;
|
|
95
|
+
/**
|
|
96
|
+
* Update the user context
|
|
97
|
+
*/
|
|
98
|
+
setContext(context: ResolvedConfig['context']): void;
|
|
99
|
+
/**
|
|
100
|
+
* Update the theme at runtime.
|
|
101
|
+
* Use this to sync with your app's theme (e.g., dark mode toggle).
|
|
102
|
+
*
|
|
103
|
+
* @param theme - Partial theme config to merge with current theme
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* // Switch to dark mode
|
|
107
|
+
* pillar.setTheme({ mode: 'dark' });
|
|
108
|
+
*
|
|
109
|
+
* // Switch to light mode with custom primary color
|
|
110
|
+
* pillar.setTheme({ mode: 'light', colors: { primary: '#ff0000' } });
|
|
111
|
+
*
|
|
112
|
+
* // Let system preference decide
|
|
113
|
+
* pillar.setTheme({ mode: 'auto' });
|
|
114
|
+
*/
|
|
115
|
+
setTheme(theme: Partial<ThemeConfig>): void;
|
|
116
|
+
/**
|
|
117
|
+
* Enable or disable the text selection "Ask AI" popover at runtime.
|
|
118
|
+
*
|
|
119
|
+
* @param enabled - Whether to show the popover when text is selected
|
|
120
|
+
*
|
|
121
|
+
* @example
|
|
122
|
+
* // Disable text selection popover
|
|
123
|
+
* pillar.setTextSelectionEnabled(false);
|
|
124
|
+
*
|
|
125
|
+
* // Re-enable it
|
|
126
|
+
* pillar.setTextSelectionEnabled(true);
|
|
127
|
+
*/
|
|
128
|
+
setTextSelectionEnabled(enabled: boolean): void;
|
|
129
|
+
/**
|
|
130
|
+
* Manually trigger tooltip scan
|
|
131
|
+
*/
|
|
132
|
+
scanTooltips(): void;
|
|
133
|
+
/**
|
|
134
|
+
* Show a specific tooltip
|
|
135
|
+
*/
|
|
136
|
+
showTooltip(tooltipId: string): void;
|
|
137
|
+
/**
|
|
138
|
+
* Hide a specific tooltip
|
|
139
|
+
*/
|
|
140
|
+
hideTooltip(tooltipId: string): void;
|
|
141
|
+
/**
|
|
142
|
+
* Mount the panel to a specific container element.
|
|
143
|
+
* Used for manual mounting mode (e.g., from React component).
|
|
144
|
+
*/
|
|
145
|
+
mountPanelTo(container: HTMLElement): void;
|
|
146
|
+
/**
|
|
147
|
+
* Get the panel host element for external mounting
|
|
148
|
+
*/
|
|
149
|
+
getPanelHostElement(): HTMLElement | null;
|
|
150
|
+
/**
|
|
151
|
+
* Get the current product context
|
|
152
|
+
*/
|
|
153
|
+
get productContext(): ProductContext;
|
|
154
|
+
/**
|
|
155
|
+
* Get the current user profile
|
|
156
|
+
*/
|
|
157
|
+
get userProfile(): UserProfile;
|
|
158
|
+
/**
|
|
159
|
+
* Set the complete product context.
|
|
160
|
+
* Use this when navigating to a new page or starting a new session.
|
|
161
|
+
*/
|
|
162
|
+
setProductContext(context: ProductContext): void;
|
|
163
|
+
/**
|
|
164
|
+
* Update specific product context fields without replacing the entire context.
|
|
165
|
+
* Use this for incremental updates like tracking actions.
|
|
166
|
+
*/
|
|
167
|
+
updateContext(updates: Partial<ProductContext>): void;
|
|
168
|
+
/**
|
|
169
|
+
* Set the user profile for personalization.
|
|
170
|
+
*/
|
|
171
|
+
setUserProfile(profile: UserProfile): void;
|
|
172
|
+
/**
|
|
173
|
+
* Report a user action for context building.
|
|
174
|
+
* Recent actions are tracked and sent with chat requests for better context.
|
|
175
|
+
*
|
|
176
|
+
* @param action - Description of the action (e.g., "clicked_upgrade", "viewed_invoice")
|
|
177
|
+
* @param metadata - Optional metadata about the action
|
|
178
|
+
*/
|
|
179
|
+
reportAction(action: string, metadata?: Record<string, unknown>): void;
|
|
180
|
+
/**
|
|
181
|
+
* Clear any error state from the context.
|
|
182
|
+
*/
|
|
183
|
+
clearErrorState(): void;
|
|
184
|
+
/**
|
|
185
|
+
* Set an error state in the context.
|
|
186
|
+
* The assistant will use this to provide relevant troubleshooting help.
|
|
187
|
+
*/
|
|
188
|
+
setErrorState(code: string, message: string): void;
|
|
189
|
+
/**
|
|
190
|
+
* Get contextual help suggestions based on current product context.
|
|
191
|
+
* Returns relevant articles, videos, and actions.
|
|
192
|
+
*/
|
|
193
|
+
getSuggestions(): Promise<Suggestion[]>;
|
|
194
|
+
/**
|
|
195
|
+
* Get the full context object to send to the backend.
|
|
196
|
+
* Used internally by the API client.
|
|
197
|
+
*/
|
|
198
|
+
getAssistantContext(): {
|
|
199
|
+
product: ProductContext;
|
|
200
|
+
user: UserProfile;
|
|
201
|
+
};
|
|
202
|
+
/**
|
|
203
|
+
* Register a handler for a specific task.
|
|
204
|
+
* Called when the AI suggests a task and the user clicks it.
|
|
205
|
+
*
|
|
206
|
+
* @param taskName - The task identifier (e.g., 'invite_team_member')
|
|
207
|
+
* @param handler - Function to handle the task execution
|
|
208
|
+
* @returns Unsubscribe function
|
|
209
|
+
*
|
|
210
|
+
* @example
|
|
211
|
+
* pillar.onTask('invite_team_member', (data) => {
|
|
212
|
+
* openInviteModal(data);
|
|
213
|
+
* });
|
|
214
|
+
*/
|
|
215
|
+
onTask(taskName: string, handler: (data: Record<string, unknown>) => void): () => void;
|
|
216
|
+
/**
|
|
217
|
+
* Register a catch-all handler for any task.
|
|
218
|
+
* Useful for logging, analytics, or handling unknown tasks.
|
|
219
|
+
*
|
|
220
|
+
* @param handler - Function called with task name and data
|
|
221
|
+
* @returns Unsubscribe function
|
|
222
|
+
*
|
|
223
|
+
* @example
|
|
224
|
+
* pillar.onAnyTask((name, data) => {
|
|
225
|
+
* analytics.track('task_executed', { name, data });
|
|
226
|
+
* });
|
|
227
|
+
*/
|
|
228
|
+
onAnyTask(handler: (name: string, data: Record<string, unknown>) => void): () => void;
|
|
229
|
+
/**
|
|
230
|
+
* Remove a task handler.
|
|
231
|
+
*
|
|
232
|
+
* @param taskName - The task identifier to stop handling
|
|
233
|
+
*/
|
|
234
|
+
offTask(taskName: string): void;
|
|
235
|
+
/**
|
|
236
|
+
* Execute a task programmatically.
|
|
237
|
+
* This is called internally by the widget when a user clicks a task button.
|
|
238
|
+
* Can also be called directly if you want to trigger a task.
|
|
239
|
+
*
|
|
240
|
+
* @param payload - Task execution payload
|
|
241
|
+
*/
|
|
242
|
+
executeTask(payload: TaskExecutePayload): void;
|
|
243
|
+
/**
|
|
244
|
+
* Mark a task as complete.
|
|
245
|
+
* Call this after your task handler finishes successfully.
|
|
246
|
+
*
|
|
247
|
+
* @param taskName - The task identifier
|
|
248
|
+
* @param success - Whether the task completed successfully
|
|
249
|
+
* @param data - Optional result data
|
|
250
|
+
*/
|
|
251
|
+
completeTask(taskName: string, success?: boolean, data?: Record<string, unknown>): void;
|
|
252
|
+
/**
|
|
253
|
+
* Confirm task execution result.
|
|
254
|
+
* Call this after your task handler completes to report success/failure
|
|
255
|
+
* back to Pillar for implementation status tracking.
|
|
256
|
+
*
|
|
257
|
+
* @param taskId - The database UUID of the task (from task:execute event)
|
|
258
|
+
* @param status - 'success' or 'failure'
|
|
259
|
+
* @param details - Optional execution details
|
|
260
|
+
*
|
|
261
|
+
* @example
|
|
262
|
+
* pillar.on('task:execute', async (task) => {
|
|
263
|
+
* const startTime = Date.now();
|
|
264
|
+
* try {
|
|
265
|
+
* await performAction(task);
|
|
266
|
+
* pillar.confirmTaskExecution(task.id, 'success', {
|
|
267
|
+
* duration_ms: Date.now() - startTime,
|
|
268
|
+
* });
|
|
269
|
+
* } catch (error) {
|
|
270
|
+
* pillar.confirmTaskExecution(task.id, 'failure', {
|
|
271
|
+
* error: error.message,
|
|
272
|
+
* duration_ms: Date.now() - startTime,
|
|
273
|
+
* });
|
|
274
|
+
* }
|
|
275
|
+
* });
|
|
276
|
+
*/
|
|
277
|
+
confirmTaskExecution(taskId: string, status: 'success' | 'failure', details?: {
|
|
278
|
+
error?: string;
|
|
279
|
+
duration_ms?: number;
|
|
280
|
+
[key: string]: unknown;
|
|
281
|
+
}): void;
|
|
282
|
+
/**
|
|
283
|
+
* Register a custom card renderer for inline_ui type actions.
|
|
284
|
+
*
|
|
285
|
+
* When the AI returns an action with action_type: 'inline_ui' and
|
|
286
|
+
* a card_type in its data, the SDK will look for a registered renderer
|
|
287
|
+
* and call it to render the inline UI card.
|
|
288
|
+
*
|
|
289
|
+
* @param cardType - The card type identifier (e.g., 'invite_members')
|
|
290
|
+
* @param renderer - Function that renders the card into a container
|
|
291
|
+
* @returns Unsubscribe function
|
|
292
|
+
*
|
|
293
|
+
* @example
|
|
294
|
+
* // Vanilla JS
|
|
295
|
+
* pillar.registerCard('invite_members', (container, data, callbacks) => {
|
|
296
|
+
* container.innerHTML = `
|
|
297
|
+
* <div class="invite-card">
|
|
298
|
+
* <h3>Invite Team Members</h3>
|
|
299
|
+
* ${data.emails.map(e => `<div>${e}</div>`).join('')}
|
|
300
|
+
* <button id="confirm">Send Invites</button>
|
|
301
|
+
* </div>
|
|
302
|
+
* `;
|
|
303
|
+
* container.querySelector('#confirm').onclick = callbacks.onConfirm;
|
|
304
|
+
* return () => container.innerHTML = ''; // cleanup
|
|
305
|
+
* });
|
|
306
|
+
*/
|
|
307
|
+
registerCard(cardType: string, renderer: CardRenderer): () => void;
|
|
308
|
+
/**
|
|
309
|
+
* Get a registered card renderer by type.
|
|
310
|
+
* Returns undefined if no renderer is registered for the given type.
|
|
311
|
+
*
|
|
312
|
+
* @param cardType - The card type identifier
|
|
313
|
+
*/
|
|
314
|
+
getCardRenderer(cardType: string): CardRenderer | undefined;
|
|
315
|
+
/**
|
|
316
|
+
* Check if a card renderer is registered for a given type.
|
|
317
|
+
*
|
|
318
|
+
* @param cardType - The card type identifier
|
|
319
|
+
*/
|
|
320
|
+
hasCardRenderer(cardType: string): boolean;
|
|
321
|
+
/**
|
|
322
|
+
* Get the active workflow, if any.
|
|
323
|
+
*/
|
|
324
|
+
get workflow(): Workflow | null;
|
|
325
|
+
/**
|
|
326
|
+
* Start a workflow.
|
|
327
|
+
* Called when the AI returns a workflow in its response.
|
|
328
|
+
*
|
|
329
|
+
* @param workflow - The workflow to start
|
|
330
|
+
*/
|
|
331
|
+
startWorkflow(workflow: Workflow): void;
|
|
332
|
+
/**
|
|
333
|
+
* Initiate a workflow step that requires user confirmation.
|
|
334
|
+
* Called when user clicks "Start" on a step with auto_run=false.
|
|
335
|
+
*
|
|
336
|
+
* @param stepIndex - Optional step index (defaults to current)
|
|
337
|
+
*/
|
|
338
|
+
initiateWorkflowStep(stepIndex?: number): void;
|
|
339
|
+
/**
|
|
340
|
+
* Confirm a workflow step as complete.
|
|
341
|
+
* Called by the host app after the action is done.
|
|
342
|
+
* Automatically advances to the next step.
|
|
343
|
+
*
|
|
344
|
+
* @param success - Whether the step completed successfully
|
|
345
|
+
* @param stepIndex - Optional step index (defaults to current)
|
|
346
|
+
*/
|
|
347
|
+
confirmWorkflowStep(success: boolean, stepIndex?: number): void;
|
|
348
|
+
/**
|
|
349
|
+
* Skip a workflow step.
|
|
350
|
+
*
|
|
351
|
+
* @param stepIndex - Optional step index (defaults to current)
|
|
352
|
+
*/
|
|
353
|
+
skipWorkflowStep(stepIndex?: number): void;
|
|
354
|
+
/**
|
|
355
|
+
* Cancel the active workflow.
|
|
356
|
+
*/
|
|
357
|
+
cancelWorkflow(): void;
|
|
358
|
+
/**
|
|
359
|
+
* Execute a workflow step.
|
|
360
|
+
* Internal method that runs the task and handles auto_complete.
|
|
361
|
+
*/
|
|
362
|
+
private _executeWorkflowStep;
|
|
363
|
+
/**
|
|
364
|
+
* Get the active execution plan, if any.
|
|
365
|
+
*/
|
|
366
|
+
get activePlan(): ExecutionPlan | null;
|
|
367
|
+
/**
|
|
368
|
+
* Handle a plan received from the AI streaming response.
|
|
369
|
+
* Called when the ReAct agent creates a plan via the create_plan tool.
|
|
370
|
+
*
|
|
371
|
+
* @param plan - The execution plan from the server
|
|
372
|
+
*/
|
|
373
|
+
handlePlanReceived(plan: ExecutionPlan): void;
|
|
374
|
+
/**
|
|
375
|
+
* Start a plan that was waiting for user confirmation.
|
|
376
|
+
* For plans with auto_execute=false, the user must explicitly start execution.
|
|
377
|
+
*/
|
|
378
|
+
startPlan(): Promise<void>;
|
|
379
|
+
/**
|
|
380
|
+
* Confirm a plan step requiring confirmation.
|
|
381
|
+
*
|
|
382
|
+
* @param stepId - UUID of the step to confirm
|
|
383
|
+
* @param data - Optional modified data from user input
|
|
384
|
+
*/
|
|
385
|
+
confirmPlanStep(stepId: string, data?: Record<string, unknown>): Promise<void>;
|
|
386
|
+
/**
|
|
387
|
+
* Skip a plan step.
|
|
388
|
+
*
|
|
389
|
+
* @param stepId - UUID of the step to skip
|
|
390
|
+
*/
|
|
391
|
+
skipPlanStep(stepId: string): Promise<void>;
|
|
392
|
+
/**
|
|
393
|
+
* Retry a failed step in the active plan.
|
|
394
|
+
*
|
|
395
|
+
* @param stepId - UUID of the step to retry
|
|
396
|
+
*/
|
|
397
|
+
retryPlanStep(stepId: string): Promise<void>;
|
|
398
|
+
/**
|
|
399
|
+
* Cancel the active plan.
|
|
400
|
+
*/
|
|
401
|
+
cancelPlan(): Promise<void>;
|
|
402
|
+
/**
|
|
403
|
+
* Complete a plan step by action name.
|
|
404
|
+
*
|
|
405
|
+
* Use this when the host app completes a wizard or flow that was started
|
|
406
|
+
* by a plan step. The plan will advance to the next step.
|
|
407
|
+
*
|
|
408
|
+
* @param actionName - The action name (e.g., 'add_new_source')
|
|
409
|
+
* @param success - Whether the action completed successfully (default: true)
|
|
410
|
+
* @param data - Optional result data
|
|
411
|
+
*
|
|
412
|
+
* @example
|
|
413
|
+
* // In your source creation success handler:
|
|
414
|
+
* pillar.completePlanStepByAction('add_new_source');
|
|
415
|
+
*/
|
|
416
|
+
completePlanStepByAction(actionName: string, success?: boolean, data?: Record<string, unknown>): Promise<void>;
|
|
417
|
+
/**
|
|
418
|
+
* Mark a plan step as done by step ID.
|
|
419
|
+
*
|
|
420
|
+
* Use this when the UI "Done" button is clicked for a wizard step.
|
|
421
|
+
* The step must be in 'awaiting_result' status.
|
|
422
|
+
*
|
|
423
|
+
* @param stepId - UUID of the step to mark as done
|
|
424
|
+
*/
|
|
425
|
+
markPlanStepDone(stepId: string): Promise<void>;
|
|
426
|
+
/**
|
|
427
|
+
* Send action result back to the agent.
|
|
428
|
+
*
|
|
429
|
+
* Called automatically for actions with `returns: true` after their
|
|
430
|
+
* handler completes. The result is sent to the agent for further reasoning.
|
|
431
|
+
*
|
|
432
|
+
* @param actionName - The name of the action that was executed
|
|
433
|
+
* @param result - The result data to send back to the agent
|
|
434
|
+
* @internal
|
|
435
|
+
*/
|
|
436
|
+
sendActionResult(actionName: string, result: unknown): void;
|
|
437
|
+
/**
|
|
438
|
+
* Internal initialization
|
|
439
|
+
*/
|
|
440
|
+
private _init;
|
|
441
|
+
/**
|
|
442
|
+
* Actual initialization logic
|
|
443
|
+
*/
|
|
444
|
+
private _doInit;
|
|
445
|
+
/**
|
|
446
|
+
* Handle URL parameters for auto-opening the panel
|
|
447
|
+
*/
|
|
448
|
+
private _handleUrlParams;
|
|
449
|
+
/**
|
|
450
|
+
* Internal cleanup
|
|
451
|
+
*/
|
|
452
|
+
private _destroy;
|
|
453
|
+
}
|
|
454
|
+
export default Pillar;
|