@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,253 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pillar SDK Configuration Types
|
|
3
|
+
*/
|
|
4
|
+
import type { Platform } from '../actions/types';
|
|
5
|
+
export type PanelPosition = 'left' | 'right';
|
|
6
|
+
export type PanelMode = 'overlay' | 'push';
|
|
7
|
+
export type FloatingButtonPosition = 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
|
|
8
|
+
export type FloatingButtonStyle = 'floating' | 'edge';
|
|
9
|
+
export type TooltipTrigger = 'hover' | 'click' | 'focus' | 'icon';
|
|
10
|
+
export type TooltipPosition = 'top' | 'bottom' | 'left' | 'right' | 'auto';
|
|
11
|
+
export type ThemeMode = 'light' | 'dark' | 'auto';
|
|
12
|
+
/**
|
|
13
|
+
* Sidebar tab configuration
|
|
14
|
+
*/
|
|
15
|
+
export interface SidebarTabConfig {
|
|
16
|
+
id: string;
|
|
17
|
+
label: string;
|
|
18
|
+
enabled: boolean;
|
|
19
|
+
order: number;
|
|
20
|
+
}
|
|
21
|
+
export declare const DEFAULT_SIDEBAR_TABS: SidebarTabConfig[];
|
|
22
|
+
/**
|
|
23
|
+
* Theme color configuration
|
|
24
|
+
* All colors should be valid CSS color values (hex, rgb, hsl, etc.)
|
|
25
|
+
*/
|
|
26
|
+
export interface ThemeColors {
|
|
27
|
+
/** Primary brand color (buttons, links, accents) */
|
|
28
|
+
primary?: string;
|
|
29
|
+
/** Primary color on hover state */
|
|
30
|
+
primaryHover?: string;
|
|
31
|
+
/** Main background color */
|
|
32
|
+
background?: string;
|
|
33
|
+
/** Secondary/subtle background (inputs, cards) */
|
|
34
|
+
backgroundSecondary?: string;
|
|
35
|
+
/** Primary text color */
|
|
36
|
+
text?: string;
|
|
37
|
+
/** Muted/secondary text color */
|
|
38
|
+
textMuted?: string;
|
|
39
|
+
/** Border color */
|
|
40
|
+
border?: string;
|
|
41
|
+
/** Border color for subtle/light borders */
|
|
42
|
+
borderLight?: string;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Theme configuration for customizing panel appearance
|
|
46
|
+
*/
|
|
47
|
+
export interface ThemeConfig {
|
|
48
|
+
/**
|
|
49
|
+
* Color mode: 'light', 'dark', or 'auto' (follows system preference)
|
|
50
|
+
* @default 'auto'
|
|
51
|
+
*/
|
|
52
|
+
mode?: ThemeMode;
|
|
53
|
+
/** Custom color overrides for light mode */
|
|
54
|
+
colors?: ThemeColors;
|
|
55
|
+
/** Custom color overrides for dark mode (when mode is 'auto' or 'dark') */
|
|
56
|
+
darkColors?: ThemeColors;
|
|
57
|
+
}
|
|
58
|
+
export interface PanelConfig {
|
|
59
|
+
enabled?: boolean;
|
|
60
|
+
position?: PanelPosition;
|
|
61
|
+
/** Panel mode: 'overlay' slides over content, 'push' shifts content aside */
|
|
62
|
+
mode?: PanelMode;
|
|
63
|
+
width?: number;
|
|
64
|
+
/**
|
|
65
|
+
* Custom mount point for the panel.
|
|
66
|
+
* - CSS selector string (e.g., '#pillar-panel')
|
|
67
|
+
* - HTMLElement reference
|
|
68
|
+
* - 'manual' for React component-based mounting
|
|
69
|
+
* - undefined (default) mounts to document.body
|
|
70
|
+
*/
|
|
71
|
+
container?: string | HTMLElement | 'manual';
|
|
72
|
+
/**
|
|
73
|
+
* Whether to use Shadow DOM for style isolation.
|
|
74
|
+
* - false (default): Panel renders in regular DOM, inherits host app CSS.
|
|
75
|
+
* Custom cards can use the host app's design system (Tailwind, etc.)
|
|
76
|
+
* - true: Panel renders in Shadow DOM, fully isolated from host CSS.
|
|
77
|
+
* Use this if you need style isolation on third-party sites.
|
|
78
|
+
* @default false
|
|
79
|
+
*/
|
|
80
|
+
useShadowDOM?: boolean;
|
|
81
|
+
/**
|
|
82
|
+
* Viewport width below which the panel switches from 'push' mode to 'hover' mode.
|
|
83
|
+
* In hover mode, the panel floats over content instead of pushing it aside.
|
|
84
|
+
* - number: The breakpoint in pixels (default: 1200)
|
|
85
|
+
* - false: Disable responsive behavior, always use push mode
|
|
86
|
+
* @default 1200
|
|
87
|
+
*/
|
|
88
|
+
hoverBreakpoint?: number | false;
|
|
89
|
+
/**
|
|
90
|
+
* Whether to show a backdrop overlay when the panel is in hover mode.
|
|
91
|
+
* Only applies when viewport is below hoverBreakpoint.
|
|
92
|
+
* @default true
|
|
93
|
+
*/
|
|
94
|
+
hoverBackdrop?: boolean;
|
|
95
|
+
}
|
|
96
|
+
export interface FloatingButtonConfig {
|
|
97
|
+
enabled?: boolean;
|
|
98
|
+
position?: FloatingButtonPosition;
|
|
99
|
+
label?: string;
|
|
100
|
+
/**
|
|
101
|
+
* Button style:
|
|
102
|
+
* - 'edge': Slim vertical tab on screen edge, expands on hover (default)
|
|
103
|
+
* - 'floating': Traditional floating pill button
|
|
104
|
+
* @default 'edge'
|
|
105
|
+
*/
|
|
106
|
+
style?: FloatingButtonStyle;
|
|
107
|
+
}
|
|
108
|
+
export interface TooltipsConfig {
|
|
109
|
+
enabled?: boolean;
|
|
110
|
+
defaultTrigger?: TooltipTrigger;
|
|
111
|
+
}
|
|
112
|
+
export interface UrlParamsConfig {
|
|
113
|
+
/** Whether to check URL params for auto-opening the panel (default: true) */
|
|
114
|
+
enabled?: boolean;
|
|
115
|
+
/** Prefix for URL params (default: 'pillar-') */
|
|
116
|
+
prefix?: string;
|
|
117
|
+
/** Whether to clear URL params after opening (default: true) */
|
|
118
|
+
clearAfterOpen?: boolean;
|
|
119
|
+
}
|
|
120
|
+
export interface TextSelectionConfig {
|
|
121
|
+
/** Whether to show "Ask AI" popover on text selection (default: true) */
|
|
122
|
+
enabled?: boolean;
|
|
123
|
+
/** Label for the popover button (default: 'Ask AI') */
|
|
124
|
+
label?: string;
|
|
125
|
+
}
|
|
126
|
+
export interface UserContext {
|
|
127
|
+
id?: string;
|
|
128
|
+
persona?: string;
|
|
129
|
+
[key: string]: unknown;
|
|
130
|
+
}
|
|
131
|
+
export interface PillarConfig {
|
|
132
|
+
helpCenter: string;
|
|
133
|
+
publicKey: string;
|
|
134
|
+
/**
|
|
135
|
+
* Platform identifier for code-first actions.
|
|
136
|
+
* Used to filter actions by deployment platform.
|
|
137
|
+
* @default 'web'
|
|
138
|
+
*/
|
|
139
|
+
platform?: Platform;
|
|
140
|
+
/**
|
|
141
|
+
* App version for code-first actions.
|
|
142
|
+
* Used to match actions to the correct deployment version.
|
|
143
|
+
* @example '1.2.3' or git commit SHA
|
|
144
|
+
*/
|
|
145
|
+
version?: string;
|
|
146
|
+
panel?: PanelConfig;
|
|
147
|
+
floatingButton?: FloatingButtonConfig;
|
|
148
|
+
tooltips?: TooltipsConfig;
|
|
149
|
+
urlParams?: UrlParamsConfig;
|
|
150
|
+
textSelection?: TextSelectionConfig;
|
|
151
|
+
sidebarTabs?: SidebarTabConfig[];
|
|
152
|
+
context?: {
|
|
153
|
+
page?: string;
|
|
154
|
+
user?: UserContext;
|
|
155
|
+
};
|
|
156
|
+
apiBaseUrl?: string;
|
|
157
|
+
theme?: ThemeConfig;
|
|
158
|
+
/**
|
|
159
|
+
* Custom CSS to inject into the panel's Shadow DOM.
|
|
160
|
+
* Use public class names (pillar-*) to override default styles.
|
|
161
|
+
* @example
|
|
162
|
+
* ```css
|
|
163
|
+
* .pillar-header { padding: 24px; }
|
|
164
|
+
* .pillar-message-user { border-radius: 8px; }
|
|
165
|
+
* ```
|
|
166
|
+
*/
|
|
167
|
+
customCSS?: string;
|
|
168
|
+
onReady?: () => void;
|
|
169
|
+
onError?: (error: Error) => void;
|
|
170
|
+
}
|
|
171
|
+
export interface ResolvedPanelConfig {
|
|
172
|
+
enabled: boolean;
|
|
173
|
+
position: PanelPosition;
|
|
174
|
+
mode: PanelMode;
|
|
175
|
+
width: number;
|
|
176
|
+
/** Custom mount point - undefined means document.body */
|
|
177
|
+
container?: string | HTMLElement | 'manual';
|
|
178
|
+
/** Whether to use Shadow DOM for style isolation */
|
|
179
|
+
useShadowDOM: boolean;
|
|
180
|
+
/** Viewport width below which panel hovers instead of pushes. false = always push. */
|
|
181
|
+
hoverBreakpoint: number | false;
|
|
182
|
+
/** Whether to show backdrop when in hover mode */
|
|
183
|
+
hoverBackdrop: boolean;
|
|
184
|
+
}
|
|
185
|
+
export interface ResolvedThemeConfig {
|
|
186
|
+
mode: ThemeMode;
|
|
187
|
+
colors: ThemeColors;
|
|
188
|
+
darkColors: ThemeColors;
|
|
189
|
+
}
|
|
190
|
+
export interface ResolvedConfig {
|
|
191
|
+
helpCenter: string;
|
|
192
|
+
publicKey: string;
|
|
193
|
+
apiBaseUrl: string;
|
|
194
|
+
/** Platform for code-first actions (default: 'web') */
|
|
195
|
+
platform: Platform;
|
|
196
|
+
/** App version for code-first actions (optional) */
|
|
197
|
+
version?: string;
|
|
198
|
+
panel: ResolvedPanelConfig;
|
|
199
|
+
floatingButton: Required<FloatingButtonConfig>;
|
|
200
|
+
tooltips: Required<TooltipsConfig>;
|
|
201
|
+
urlParams: Required<UrlParamsConfig>;
|
|
202
|
+
textSelection: Required<TextSelectionConfig>;
|
|
203
|
+
sidebarTabs: SidebarTabConfig[];
|
|
204
|
+
theme: ResolvedThemeConfig;
|
|
205
|
+
customCSS?: string;
|
|
206
|
+
context: {
|
|
207
|
+
page?: string;
|
|
208
|
+
user?: UserContext;
|
|
209
|
+
};
|
|
210
|
+
onReady?: () => void;
|
|
211
|
+
onError?: (error: Error) => void;
|
|
212
|
+
}
|
|
213
|
+
export declare const DEFAULT_CONFIG: Omit<ResolvedConfig, 'helpCenter' | 'publicKey'>;
|
|
214
|
+
export declare function resolveConfig(config: PillarConfig): ResolvedConfig;
|
|
215
|
+
/**
|
|
216
|
+
* Server embed config type (matches backend response)
|
|
217
|
+
*/
|
|
218
|
+
export interface ServerEmbedConfig {
|
|
219
|
+
panel?: {
|
|
220
|
+
enabled?: boolean;
|
|
221
|
+
position?: 'left' | 'right';
|
|
222
|
+
width?: number;
|
|
223
|
+
};
|
|
224
|
+
floatingButton?: {
|
|
225
|
+
enabled?: boolean;
|
|
226
|
+
position?: string;
|
|
227
|
+
label?: string;
|
|
228
|
+
};
|
|
229
|
+
features?: {
|
|
230
|
+
aiChatEnabled?: boolean;
|
|
231
|
+
searchEnabled?: boolean;
|
|
232
|
+
tooltipsEnabled?: boolean;
|
|
233
|
+
};
|
|
234
|
+
sidebarTabs?: SidebarTabConfig[];
|
|
235
|
+
theme?: {
|
|
236
|
+
colors?: {
|
|
237
|
+
primary?: string;
|
|
238
|
+
};
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Merge server config with local config.
|
|
243
|
+
*
|
|
244
|
+
* Priority: DEFAULT_CONFIG < serverConfig < localConfig
|
|
245
|
+
*
|
|
246
|
+
* Server values fill in gaps (admin-configured defaults),
|
|
247
|
+
* but local config (passed to Pillar.init()) always wins.
|
|
248
|
+
*
|
|
249
|
+
* @param localConfig - Config passed to Pillar.init()
|
|
250
|
+
* @param serverConfig - Config fetched from /api/public/products/{subdomain}/embed-config/
|
|
251
|
+
* @returns Merged config with server values filling in gaps
|
|
252
|
+
*/
|
|
253
|
+
export declare function mergeServerConfig(localConfig: PillarConfig, serverConfig: ServerEmbedConfig | null): PillarConfig;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Product Context Types for Pillar SDK
|
|
3
|
+
*
|
|
4
|
+
* These types enable context-aware assistance by providing
|
|
5
|
+
* information about what the user is doing in the product.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Product context for the assistant.
|
|
9
|
+
* Pass this to help the assistant understand what the user is doing.
|
|
10
|
+
*/
|
|
11
|
+
export interface ProductContext {
|
|
12
|
+
/** Current page path (e.g., "/settings/billing") */
|
|
13
|
+
currentPage?: string;
|
|
14
|
+
/** Current feature or section (e.g., "Billing Settings") */
|
|
15
|
+
currentFeature?: string;
|
|
16
|
+
/** User's role in the product (e.g., "admin", "member") */
|
|
17
|
+
userRole?: string;
|
|
18
|
+
/** Current user state or mode (e.g., "onboarding", "trial") */
|
|
19
|
+
userState?: string;
|
|
20
|
+
/** Recent user actions for context */
|
|
21
|
+
recentActions?: string[];
|
|
22
|
+
/** Any error state the user is experiencing */
|
|
23
|
+
errorState?: {
|
|
24
|
+
code: string;
|
|
25
|
+
message: string;
|
|
26
|
+
};
|
|
27
|
+
/** Custom context data */
|
|
28
|
+
custom?: Record<string, unknown>;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* User profile for personalization.
|
|
32
|
+
*/
|
|
33
|
+
export interface UserProfile {
|
|
34
|
+
/** User identifier (for conversation continuity) */
|
|
35
|
+
userId?: string;
|
|
36
|
+
/** User's name for personalized responses */
|
|
37
|
+
name?: string;
|
|
38
|
+
/** User's role/permissions */
|
|
39
|
+
role?: string;
|
|
40
|
+
/** Account/organization info */
|
|
41
|
+
accountType?: string;
|
|
42
|
+
/** User's experience level */
|
|
43
|
+
experienceLevel?: 'beginner' | 'intermediate' | 'advanced';
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Suggestion returned from the suggestions API.
|
|
47
|
+
*/
|
|
48
|
+
export interface Suggestion {
|
|
49
|
+
type: 'article' | 'video' | 'tutorial' | 'action';
|
|
50
|
+
id: string;
|
|
51
|
+
title: string;
|
|
52
|
+
description: string;
|
|
53
|
+
relevanceScore: number;
|
|
54
|
+
url?: string;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Combined context sent to the backend.
|
|
58
|
+
*/
|
|
59
|
+
export interface AssistantContext {
|
|
60
|
+
product: ProductContext;
|
|
61
|
+
user: UserProfile;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Default empty context.
|
|
65
|
+
*/
|
|
66
|
+
export declare const DEFAULT_PRODUCT_CONTEXT: ProductContext;
|
|
67
|
+
export declare const DEFAULT_USER_PROFILE: UserProfile;
|
|
68
|
+
/**
|
|
69
|
+
* Maximum number of recent actions to track.
|
|
70
|
+
*/
|
|
71
|
+
export declare const MAX_RECENT_ACTIONS = 10;
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Simple EventEmitter for SDK events
|
|
3
|
+
*/
|
|
4
|
+
import type { ResolvedThemeConfig } from './config';
|
|
5
|
+
import type { ProductContext, UserProfile } from './context';
|
|
6
|
+
import type { ExecutionPlan, ExecutionStep } from './plan';
|
|
7
|
+
import type { Workflow, WorkflowStep } from './workflow';
|
|
8
|
+
export type EventCallback<T = unknown> = (data: T) => void;
|
|
9
|
+
/**
|
|
10
|
+
* Task execution payload - sent when a task button is clicked.
|
|
11
|
+
*/
|
|
12
|
+
export interface TaskExecutePayload {
|
|
13
|
+
/** Database UUID for the task (used for confirmation) */
|
|
14
|
+
id?: string;
|
|
15
|
+
/** Task unique identifier (e.g., 'invite_team_member') */
|
|
16
|
+
name: string;
|
|
17
|
+
/** Task data payload */
|
|
18
|
+
data: Record<string, unknown>;
|
|
19
|
+
/** Task type hint */
|
|
20
|
+
taskType?: 'navigate' | 'open_modal' | 'fill_form' | 'trigger_action' | 'copy_text' | 'external_link' | 'start_tutorial' | 'inline_ui';
|
|
21
|
+
/** Path template for navigate type (already resolved with params) */
|
|
22
|
+
path?: string;
|
|
23
|
+
/** External URL for external_link type */
|
|
24
|
+
externalUrl?: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Callbacks provided to custom card renderers.
|
|
28
|
+
*/
|
|
29
|
+
export interface CardCallbacks {
|
|
30
|
+
/** Called when user confirms the action. Pass modified data if needed. */
|
|
31
|
+
onConfirm: (modifiedData?: Record<string, unknown>) => void;
|
|
32
|
+
/** Called when user cancels the action */
|
|
33
|
+
onCancel: () => void;
|
|
34
|
+
/** Called to report card state changes (for analytics/confirmation) */
|
|
35
|
+
onStateChange?: (state: 'loading' | 'success' | 'error', message?: string) => void;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Card field schema definition for declarative card configuration.
|
|
39
|
+
*/
|
|
40
|
+
export interface CardFieldSchema {
|
|
41
|
+
/** Field name/key */
|
|
42
|
+
name: string;
|
|
43
|
+
/** Display label */
|
|
44
|
+
label: string;
|
|
45
|
+
/** Field type */
|
|
46
|
+
type: 'text' | 'number' | 'email' | 'select' | 'multiselect' | 'checkbox' | 'textarea' | 'date' | 'hidden';
|
|
47
|
+
/** Whether field is required */
|
|
48
|
+
required?: boolean;
|
|
49
|
+
/** Default value */
|
|
50
|
+
defaultValue?: unknown;
|
|
51
|
+
/** Placeholder text */
|
|
52
|
+
placeholder?: string;
|
|
53
|
+
/** Help text shown below field */
|
|
54
|
+
helpText?: string;
|
|
55
|
+
/** Options for select/multiselect types */
|
|
56
|
+
options?: Array<{
|
|
57
|
+
value: string;
|
|
58
|
+
label: string;
|
|
59
|
+
}>;
|
|
60
|
+
/** Validation rules */
|
|
61
|
+
validation?: {
|
|
62
|
+
min?: number;
|
|
63
|
+
max?: number;
|
|
64
|
+
minLength?: number;
|
|
65
|
+
maxLength?: number;
|
|
66
|
+
pattern?: string;
|
|
67
|
+
patternMessage?: string;
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Enhanced card registration options.
|
|
72
|
+
*/
|
|
73
|
+
export interface CardRegistrationOptions {
|
|
74
|
+
/** Card type identifier (e.g., 'add_to_deal', 'invite_member') */
|
|
75
|
+
cardType: string;
|
|
76
|
+
/** Human-readable card title */
|
|
77
|
+
title?: string;
|
|
78
|
+
/** Card description */
|
|
79
|
+
description?: string;
|
|
80
|
+
/** Schema defining form fields (for auto-generated forms) */
|
|
81
|
+
schema?: CardFieldSchema[];
|
|
82
|
+
/** Custom renderer function (overrides schema-based rendering) */
|
|
83
|
+
renderer?: CardRenderer;
|
|
84
|
+
/** Theme/styling options */
|
|
85
|
+
theme?: {
|
|
86
|
+
variant?: 'default' | 'compact' | 'wide';
|
|
87
|
+
confirmLabel?: string;
|
|
88
|
+
cancelLabel?: string;
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Registered card with metadata.
|
|
93
|
+
*/
|
|
94
|
+
export interface RegisteredCard {
|
|
95
|
+
cardType: string;
|
|
96
|
+
options: CardRegistrationOptions;
|
|
97
|
+
renderer?: CardRenderer;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Card renderer function signature.
|
|
101
|
+
* Customers register these to render custom confirmation cards.
|
|
102
|
+
*
|
|
103
|
+
* @param container - DOM element to render the card into
|
|
104
|
+
* @param data - Action data including extracted values from AI
|
|
105
|
+
* @param callbacks - Callbacks for confirm/cancel actions
|
|
106
|
+
* @returns Optional cleanup function called when card is unmounted
|
|
107
|
+
*/
|
|
108
|
+
export type CardRenderer = (container: HTMLElement, data: Record<string, unknown>, callbacks: CardCallbacks) => (() => void) | void;
|
|
109
|
+
export interface PillarEvents {
|
|
110
|
+
'ready': void;
|
|
111
|
+
'error': Error;
|
|
112
|
+
'panel:open': void;
|
|
113
|
+
'panel:close': void;
|
|
114
|
+
'panel:navigate': {
|
|
115
|
+
view: string;
|
|
116
|
+
params?: Record<string, string>;
|
|
117
|
+
};
|
|
118
|
+
'tooltip:shown': {
|
|
119
|
+
tooltipId: string;
|
|
120
|
+
};
|
|
121
|
+
'tooltip:hidden': {
|
|
122
|
+
tooltipId: string;
|
|
123
|
+
};
|
|
124
|
+
'tooltip:click': {
|
|
125
|
+
tooltipId: string;
|
|
126
|
+
};
|
|
127
|
+
'article:view': {
|
|
128
|
+
articleSlug: string;
|
|
129
|
+
};
|
|
130
|
+
'search:query': {
|
|
131
|
+
query: string;
|
|
132
|
+
};
|
|
133
|
+
'chat:message': {
|
|
134
|
+
message: string;
|
|
135
|
+
};
|
|
136
|
+
'textSelection:shown': {
|
|
137
|
+
text: string;
|
|
138
|
+
};
|
|
139
|
+
'textSelection:click': {
|
|
140
|
+
text: string;
|
|
141
|
+
};
|
|
142
|
+
'context:change': {
|
|
143
|
+
context: ProductContext;
|
|
144
|
+
};
|
|
145
|
+
'profile:change': {
|
|
146
|
+
profile: UserProfile;
|
|
147
|
+
};
|
|
148
|
+
'action:report': {
|
|
149
|
+
action: string;
|
|
150
|
+
metadata?: Record<string, unknown>;
|
|
151
|
+
};
|
|
152
|
+
'action:result': {
|
|
153
|
+
actionName: string;
|
|
154
|
+
result: unknown;
|
|
155
|
+
};
|
|
156
|
+
'task:execute': TaskExecutePayload;
|
|
157
|
+
'task:complete': {
|
|
158
|
+
id?: string;
|
|
159
|
+
name: string;
|
|
160
|
+
success: boolean;
|
|
161
|
+
data?: Record<string, unknown>;
|
|
162
|
+
};
|
|
163
|
+
'workflow:start': Workflow;
|
|
164
|
+
'workflow:step:active': {
|
|
165
|
+
workflow: Workflow;
|
|
166
|
+
step: WorkflowStep;
|
|
167
|
+
};
|
|
168
|
+
'workflow:step:complete': {
|
|
169
|
+
workflow: Workflow;
|
|
170
|
+
step: WorkflowStep;
|
|
171
|
+
success: boolean;
|
|
172
|
+
};
|
|
173
|
+
'workflow:step:skip': {
|
|
174
|
+
workflow: Workflow;
|
|
175
|
+
step: WorkflowStep;
|
|
176
|
+
};
|
|
177
|
+
'workflow:complete': Workflow;
|
|
178
|
+
'workflow:cancel': Workflow;
|
|
179
|
+
'plan:start': ExecutionPlan;
|
|
180
|
+
'plan:step:active': {
|
|
181
|
+
plan: ExecutionPlan;
|
|
182
|
+
step: ExecutionStep;
|
|
183
|
+
};
|
|
184
|
+
'plan:step:confirm': {
|
|
185
|
+
plan: ExecutionPlan;
|
|
186
|
+
step: ExecutionStep;
|
|
187
|
+
};
|
|
188
|
+
'plan:step:complete': {
|
|
189
|
+
plan: ExecutionPlan;
|
|
190
|
+
step: ExecutionStep;
|
|
191
|
+
success: boolean;
|
|
192
|
+
};
|
|
193
|
+
'plan:step:skip': {
|
|
194
|
+
plan: ExecutionPlan;
|
|
195
|
+
step: ExecutionStep;
|
|
196
|
+
};
|
|
197
|
+
'plan:step:retry': {
|
|
198
|
+
plan: ExecutionPlan;
|
|
199
|
+
step: ExecutionStep;
|
|
200
|
+
retryCount: number;
|
|
201
|
+
};
|
|
202
|
+
'plan:step:failed': {
|
|
203
|
+
plan: ExecutionPlan;
|
|
204
|
+
step: ExecutionStep;
|
|
205
|
+
error: Error;
|
|
206
|
+
canRetry?: boolean;
|
|
207
|
+
};
|
|
208
|
+
'plan:updated': ExecutionPlan;
|
|
209
|
+
'plan:complete': ExecutionPlan;
|
|
210
|
+
'plan:cancel': ExecutionPlan;
|
|
211
|
+
'plan:error': {
|
|
212
|
+
plan: ExecutionPlan;
|
|
213
|
+
error: Error;
|
|
214
|
+
};
|
|
215
|
+
'theme:change': {
|
|
216
|
+
theme: ResolvedThemeConfig;
|
|
217
|
+
};
|
|
218
|
+
'textSelection:change': {
|
|
219
|
+
enabled: boolean;
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
export declare class EventEmitter {
|
|
223
|
+
private listeners;
|
|
224
|
+
on<K extends keyof PillarEvents>(event: K, callback: EventCallback<PillarEvents[K]>): () => void;
|
|
225
|
+
off<K extends keyof PillarEvents>(event: K, callback: EventCallback<PillarEvents[K]>): void;
|
|
226
|
+
emit<K extends keyof PillarEvents>(event: K, data?: PillarEvents[K]): void;
|
|
227
|
+
removeAllListeners(event?: keyof PillarEvents): void;
|
|
228
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PlanExecutor - Orchestrates execution of multi-step plans.
|
|
3
|
+
*
|
|
4
|
+
* Manages the execution lifecycle of server-generated execution plans:
|
|
5
|
+
* - Receives plans from streaming events
|
|
6
|
+
* - Executes steps using registered action handlers
|
|
7
|
+
* - Sends results back to server when needed
|
|
8
|
+
* - Handles user confirmations and cancellations
|
|
9
|
+
* - Emits events for UI updates
|
|
10
|
+
*/
|
|
11
|
+
import type { ExecutionPlan } from './plan';
|
|
12
|
+
import type { EventEmitter } from './events';
|
|
13
|
+
import type { MCPClient } from '../api/mcp-client';
|
|
14
|
+
export declare class PlanExecutor {
|
|
15
|
+
private mcpClient;
|
|
16
|
+
private events;
|
|
17
|
+
private siteId;
|
|
18
|
+
constructor(mcpClient: MCPClient, events: EventEmitter, siteId: string);
|
|
19
|
+
/**
|
|
20
|
+
* Receive a new plan and start execution if auto_execute.
|
|
21
|
+
*
|
|
22
|
+
* Called when the ReAct agent creates a plan via the create_plan tool.
|
|
23
|
+
*/
|
|
24
|
+
handlePlanReceived(plan: ExecutionPlan): Promise<void>;
|
|
25
|
+
/**
|
|
26
|
+
* Attempt to recover an active plan from localStorage.
|
|
27
|
+
*
|
|
28
|
+
* Called during SDK initialization to resume plans after page refresh.
|
|
29
|
+
* Fetches latest state from server to ensure consistency.
|
|
30
|
+
*
|
|
31
|
+
* @returns The recovered plan or null if none found/invalid
|
|
32
|
+
*/
|
|
33
|
+
recoverPlan(): Promise<ExecutionPlan | null>;
|
|
34
|
+
/**
|
|
35
|
+
* Persist the current plan to localStorage.
|
|
36
|
+
*/
|
|
37
|
+
private persistPlan;
|
|
38
|
+
/**
|
|
39
|
+
* User clicks "Start Plan" for plans with auto_execute=false.
|
|
40
|
+
*/
|
|
41
|
+
startPlan(): Promise<void>;
|
|
42
|
+
/**
|
|
43
|
+
* Execute the next ready step.
|
|
44
|
+
*/
|
|
45
|
+
private executeNextStep;
|
|
46
|
+
/**
|
|
47
|
+
* User confirms a step requiring confirmation.
|
|
48
|
+
*
|
|
49
|
+
* @param stepId - UUID of the step to confirm
|
|
50
|
+
* @param modifiedData - Optional modified data from user input
|
|
51
|
+
*/
|
|
52
|
+
confirmStep(stepId: string, modifiedData?: Record<string, unknown>): Promise<void>;
|
|
53
|
+
/**
|
|
54
|
+
* User skips a step.
|
|
55
|
+
*
|
|
56
|
+
* @param stepId - UUID of the step to skip
|
|
57
|
+
*/
|
|
58
|
+
skipStep(stepId: string): Promise<void>;
|
|
59
|
+
/**
|
|
60
|
+
* Retry a failed step.
|
|
61
|
+
*
|
|
62
|
+
* @param stepId - UUID of the step to retry
|
|
63
|
+
*/
|
|
64
|
+
retryStep(stepId: string): Promise<void>;
|
|
65
|
+
/**
|
|
66
|
+
* Cancel the active plan.
|
|
67
|
+
*/
|
|
68
|
+
cancel(): Promise<void>;
|
|
69
|
+
/**
|
|
70
|
+
* Complete a plan step by action name.
|
|
71
|
+
*
|
|
72
|
+
* Used by host apps when a wizard/flow completes (e.g., after user finishes
|
|
73
|
+
* adding a knowledge source). The step must be in 'awaiting_result' status.
|
|
74
|
+
*
|
|
75
|
+
* @param actionName - The action name (e.g., 'add_new_source')
|
|
76
|
+
* @param success - Whether the action completed successfully
|
|
77
|
+
* @param data - Optional result data
|
|
78
|
+
*/
|
|
79
|
+
completeStepByAction(actionName: string, success?: boolean, data?: Record<string, unknown>): Promise<void>;
|
|
80
|
+
/**
|
|
81
|
+
* Mark a step as done by step ID.
|
|
82
|
+
*
|
|
83
|
+
* Called by UI when user clicks "Done" button for a wizard step.
|
|
84
|
+
* The step must be in 'awaiting_result' status.
|
|
85
|
+
*
|
|
86
|
+
* @param stepId - UUID of the step to mark done
|
|
87
|
+
*/
|
|
88
|
+
markStepDone(stepId: string): Promise<void>;
|
|
89
|
+
/**
|
|
90
|
+
* Internal helper to mark a step complete and advance to next.
|
|
91
|
+
*/
|
|
92
|
+
private markStepComplete;
|
|
93
|
+
/**
|
|
94
|
+
* Execute a single step.
|
|
95
|
+
*/
|
|
96
|
+
private executeStep;
|
|
97
|
+
/**
|
|
98
|
+
* Get the current active plan.
|
|
99
|
+
*/
|
|
100
|
+
getActivePlan(): ExecutionPlan | null;
|
|
101
|
+
}
|