@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,226 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Client for Pillar SDK
|
|
3
|
+
*
|
|
4
|
+
* Implements JSON-RPC 2.0 over HTTP with SSE streaming support
|
|
5
|
+
* for communication with the MCP server.
|
|
6
|
+
*/
|
|
7
|
+
import type { TaskButtonData } from '../components/Panel/TaskButton';
|
|
8
|
+
import type { ResolvedConfig } from '../core/config';
|
|
9
|
+
import type { ExecutionPlan } from '../core/plan';
|
|
10
|
+
import type { UserContextItem } from '../types/user-context';
|
|
11
|
+
import type { ArticleSummary } from './client';
|
|
12
|
+
/** MCP Tool result content */
|
|
13
|
+
interface ToolResultContent {
|
|
14
|
+
type: 'text' | 'image' | 'resource';
|
|
15
|
+
text?: string;
|
|
16
|
+
data?: string;
|
|
17
|
+
mimeType?: string;
|
|
18
|
+
}
|
|
19
|
+
/** MCP Tool result */
|
|
20
|
+
export interface ToolResult {
|
|
21
|
+
content: ToolResultContent[];
|
|
22
|
+
isError?: boolean;
|
|
23
|
+
structuredContent?: {
|
|
24
|
+
sources?: ArticleSummary[];
|
|
25
|
+
actions?: ActionData[];
|
|
26
|
+
plan?: ExecutionPlan;
|
|
27
|
+
};
|
|
28
|
+
_meta?: {
|
|
29
|
+
conversation_id?: string;
|
|
30
|
+
query_log_id?: string;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/** Action data from MCP server */
|
|
34
|
+
export interface ActionData {
|
|
35
|
+
id: string;
|
|
36
|
+
name: string;
|
|
37
|
+
description: string;
|
|
38
|
+
action_type: string;
|
|
39
|
+
/** If true, action executes immediately without user clicking */
|
|
40
|
+
auto_run: boolean;
|
|
41
|
+
/** If true, action completes without waiting for host confirmation */
|
|
42
|
+
auto_complete: boolean;
|
|
43
|
+
/** If true, action returns data for agent reasoning */
|
|
44
|
+
returns_data: boolean;
|
|
45
|
+
score: number;
|
|
46
|
+
data: Record<string, unknown>;
|
|
47
|
+
}
|
|
48
|
+
/** Streaming callbacks for tool calls */
|
|
49
|
+
export interface StreamCallbacks {
|
|
50
|
+
/** Called for each text token */
|
|
51
|
+
onToken?: (token: string) => void;
|
|
52
|
+
/** Called when sources are available */
|
|
53
|
+
onSources?: (sources: ArticleSummary[]) => void;
|
|
54
|
+
/** Called when actions are available */
|
|
55
|
+
onActions?: (actions: ActionData[]) => void;
|
|
56
|
+
/** Called when a plan is created (from plan.created event) */
|
|
57
|
+
onPlan?: (plan: ExecutionPlan) => void;
|
|
58
|
+
/** Called on error */
|
|
59
|
+
onError?: (error: string) => void;
|
|
60
|
+
/** Called when stream is complete */
|
|
61
|
+
onComplete?: (conversationId?: string, queryLogId?: string) => void;
|
|
62
|
+
/** Called for progress updates */
|
|
63
|
+
onProgress?: (progress: {
|
|
64
|
+
kind: string;
|
|
65
|
+
message?: string;
|
|
66
|
+
}) => void;
|
|
67
|
+
}
|
|
68
|
+
/** Image for chat requests (from upload-image endpoint) */
|
|
69
|
+
export interface ChatImage {
|
|
70
|
+
/** Signed GCS URL from upload-image endpoint */
|
|
71
|
+
url: string;
|
|
72
|
+
/** Detail level for image analysis. 'low' is faster and cheaper. */
|
|
73
|
+
detail?: 'low' | 'high';
|
|
74
|
+
}
|
|
75
|
+
/** Response from image upload endpoint */
|
|
76
|
+
export interface ImageUploadResponse {
|
|
77
|
+
url: string;
|
|
78
|
+
expires_at: string;
|
|
79
|
+
}
|
|
80
|
+
export declare class MCPClient {
|
|
81
|
+
private config;
|
|
82
|
+
private requestId;
|
|
83
|
+
constructor(config: ResolvedConfig);
|
|
84
|
+
private get baseUrl();
|
|
85
|
+
private get headers();
|
|
86
|
+
private nextId;
|
|
87
|
+
/**
|
|
88
|
+
* Call an MCP tool (non-streaming).
|
|
89
|
+
*/
|
|
90
|
+
callTool(name: string, args: Record<string, unknown>): Promise<ToolResult>;
|
|
91
|
+
/**
|
|
92
|
+
* Call an MCP tool with streaming support.
|
|
93
|
+
*
|
|
94
|
+
* @param name - Tool name (e.g., 'ask')
|
|
95
|
+
* @param args - Tool arguments
|
|
96
|
+
* @param callbacks - Streaming event callbacks
|
|
97
|
+
* @param signal - Optional AbortSignal for cancellation
|
|
98
|
+
*/
|
|
99
|
+
callToolStream(name: string, args: Record<string, unknown>, callbacks: StreamCallbacks, signal?: AbortSignal): Promise<ToolResult>;
|
|
100
|
+
/**
|
|
101
|
+
* Upload an image for use in chat.
|
|
102
|
+
*
|
|
103
|
+
* Returns a signed URL that can be passed to the ask tool.
|
|
104
|
+
* The URL expires after 24 hours.
|
|
105
|
+
*
|
|
106
|
+
* @param file - The image file to upload
|
|
107
|
+
* @returns Promise with signed URL and expiration
|
|
108
|
+
*/
|
|
109
|
+
uploadImage(file: File): Promise<ImageUploadResponse>;
|
|
110
|
+
/**
|
|
111
|
+
* Ask a question using the MCP 'ask' tool with streaming.
|
|
112
|
+
*
|
|
113
|
+
* This is a convenience method for the common use case of asking questions.
|
|
114
|
+
*
|
|
115
|
+
* @param query - The question to ask
|
|
116
|
+
* @param callbacks - Streaming callbacks
|
|
117
|
+
* @param options - Optional configuration including images
|
|
118
|
+
*/
|
|
119
|
+
ask(query: string, callbacks: StreamCallbacks, options?: {
|
|
120
|
+
articleSlug?: string;
|
|
121
|
+
userContext?: UserContextItem[];
|
|
122
|
+
images?: ChatImage[];
|
|
123
|
+
signal?: AbortSignal;
|
|
124
|
+
}): Promise<ToolResult>;
|
|
125
|
+
/**
|
|
126
|
+
* Continue plan execution after receiving step result.
|
|
127
|
+
*
|
|
128
|
+
* Called by the SDK after executing a step that has
|
|
129
|
+
* requires_result_feedback=true. The server analyzes the result
|
|
130
|
+
* and updates subsequent steps if needed.
|
|
131
|
+
*
|
|
132
|
+
* @param planId - UUID of the plan
|
|
133
|
+
* @param stepId - UUID of the completed step
|
|
134
|
+
* @param result - Step execution result
|
|
135
|
+
* @returns Updated plan with all steps
|
|
136
|
+
*/
|
|
137
|
+
continuePlan(planId: string, stepId: string, result: unknown): Promise<{
|
|
138
|
+
plan: ExecutionPlan;
|
|
139
|
+
}>;
|
|
140
|
+
/**
|
|
141
|
+
* Cancel an in-progress plan.
|
|
142
|
+
*
|
|
143
|
+
* Marks the plan as cancelled and skips any pending steps.
|
|
144
|
+
*
|
|
145
|
+
* @param planId - UUID of the plan to cancel
|
|
146
|
+
* @returns Updated plan with cancelled status
|
|
147
|
+
*/
|
|
148
|
+
cancelPlan(planId: string): Promise<{
|
|
149
|
+
plan: ExecutionPlan;
|
|
150
|
+
}>;
|
|
151
|
+
/**
|
|
152
|
+
* Get current state of a plan.
|
|
153
|
+
*
|
|
154
|
+
* Returns the plan and all its steps with current statuses.
|
|
155
|
+
*
|
|
156
|
+
* @param planId - UUID of the plan
|
|
157
|
+
* @returns Plan with all steps
|
|
158
|
+
*/
|
|
159
|
+
getPlan(planId: string): Promise<{
|
|
160
|
+
plan: ExecutionPlan;
|
|
161
|
+
}>;
|
|
162
|
+
/**
|
|
163
|
+
* Start a plan that was waiting for user confirmation.
|
|
164
|
+
*
|
|
165
|
+
* For plans with auto_execute=false, the user must explicitly
|
|
166
|
+
* start execution by calling this method.
|
|
167
|
+
*
|
|
168
|
+
* @param planId - UUID of the plan to start
|
|
169
|
+
* @returns Updated plan with executing status
|
|
170
|
+
*/
|
|
171
|
+
startPlan(planId: string): Promise<{
|
|
172
|
+
plan: ExecutionPlan;
|
|
173
|
+
}>;
|
|
174
|
+
/**
|
|
175
|
+
* Retry a failed step.
|
|
176
|
+
*
|
|
177
|
+
* Increments the retry count and resets the step to ready status.
|
|
178
|
+
* Only works if the step is retriable and hasn't exceeded max_retries.
|
|
179
|
+
*
|
|
180
|
+
* @param planId - UUID of the plan
|
|
181
|
+
* @param stepId - UUID of the step to retry
|
|
182
|
+
* @returns Updated plan with step reset to ready
|
|
183
|
+
*/
|
|
184
|
+
retryStep(planId: string, stepId: string): Promise<{
|
|
185
|
+
plan: ExecutionPlan;
|
|
186
|
+
}>;
|
|
187
|
+
/**
|
|
188
|
+
* Mark a step as failed.
|
|
189
|
+
*
|
|
190
|
+
* Records the error and determines if the plan should also fail
|
|
191
|
+
* (if step is not retriable or out of retries).
|
|
192
|
+
*
|
|
193
|
+
* @param planId - UUID of the plan
|
|
194
|
+
* @param stepId - UUID of the failed step
|
|
195
|
+
* @param errorMessage - Optional error message
|
|
196
|
+
* @returns Updated plan with failed step
|
|
197
|
+
*/
|
|
198
|
+
failStep(planId: string, stepId: string, errorMessage?: string): Promise<{
|
|
199
|
+
plan: ExecutionPlan;
|
|
200
|
+
}>;
|
|
201
|
+
/**
|
|
202
|
+
* Skip a step and advance to the next one.
|
|
203
|
+
*
|
|
204
|
+
* @param planId - UUID of the plan
|
|
205
|
+
* @param stepId - UUID of the step to skip
|
|
206
|
+
* @returns Updated plan with skipped step and next step ready
|
|
207
|
+
*/
|
|
208
|
+
skipStep(planId: string, stepId: string): Promise<{
|
|
209
|
+
plan: ExecutionPlan;
|
|
210
|
+
}>;
|
|
211
|
+
/**
|
|
212
|
+
* Send action result back to the agent.
|
|
213
|
+
*
|
|
214
|
+
* Called after executing a query action (returns_data=true).
|
|
215
|
+
* The result is sent to the agent for further reasoning in the ReAct loop.
|
|
216
|
+
*
|
|
217
|
+
* @param actionName - The name of the action that was executed
|
|
218
|
+
* @param result - The result data to send back to the agent
|
|
219
|
+
*/
|
|
220
|
+
sendActionResult(actionName: string, result: unknown): void;
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Convert ActionData from MCP response to TaskButtonData for UI rendering.
|
|
224
|
+
*/
|
|
225
|
+
export declare function actionToTaskButton(action: ActionData): TaskButtonData;
|
|
226
|
+
export {};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Floating Help Button
|
|
3
|
+
* A floating action button that opens the help panel
|
|
4
|
+
*/
|
|
5
|
+
import type { ResolvedConfig, FloatingButtonPosition } from '../core/config';
|
|
6
|
+
export declare class FloatingButton {
|
|
7
|
+
private config;
|
|
8
|
+
private onClick;
|
|
9
|
+
private element;
|
|
10
|
+
private stylesInjected;
|
|
11
|
+
private _isOpen;
|
|
12
|
+
constructor(config: ResolvedConfig, onClick: () => void);
|
|
13
|
+
/**
|
|
14
|
+
* Initialize the floating button
|
|
15
|
+
*/
|
|
16
|
+
init(): void;
|
|
17
|
+
/**
|
|
18
|
+
* Set the open state (to show/hide when panel opens)
|
|
19
|
+
*/
|
|
20
|
+
setOpen(isOpen: boolean): void;
|
|
21
|
+
/**
|
|
22
|
+
* Show the button
|
|
23
|
+
*/
|
|
24
|
+
show(): void;
|
|
25
|
+
/**
|
|
26
|
+
* Hide the button
|
|
27
|
+
*/
|
|
28
|
+
hide(): void;
|
|
29
|
+
/**
|
|
30
|
+
* Update button position
|
|
31
|
+
*/
|
|
32
|
+
setPosition(position: FloatingButtonPosition): void;
|
|
33
|
+
/**
|
|
34
|
+
* Update button label
|
|
35
|
+
*/
|
|
36
|
+
setLabel(label: string): void;
|
|
37
|
+
/**
|
|
38
|
+
* Destroy the button
|
|
39
|
+
*/
|
|
40
|
+
destroy(): void;
|
|
41
|
+
private createElement;
|
|
42
|
+
private updateIcon;
|
|
43
|
+
private handleClick;
|
|
44
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Edge Trigger Component
|
|
3
|
+
* A sidebar-style trigger that reserves space in the layout and slides out with the panel.
|
|
4
|
+
* The trigger stays visible when panel opens, positioned at the panel's outer edge.
|
|
5
|
+
*/
|
|
6
|
+
import type { FloatingButtonPosition, ResolvedConfig } from '../../core/config';
|
|
7
|
+
/**
|
|
8
|
+
* EdgeTrigger class that manages the edge trigger lifecycle
|
|
9
|
+
* The trigger stays visible when panel opens, sliding out with it
|
|
10
|
+
*/
|
|
11
|
+
export declare class EdgeTrigger {
|
|
12
|
+
private config;
|
|
13
|
+
private onClick;
|
|
14
|
+
private rootContainer;
|
|
15
|
+
private container;
|
|
16
|
+
private stylesInjected;
|
|
17
|
+
private themeStylesInjected;
|
|
18
|
+
private _isHidden;
|
|
19
|
+
private unsubscribeOpen;
|
|
20
|
+
private unsubscribeWidth;
|
|
21
|
+
private unsubscribeHoverMode;
|
|
22
|
+
private unsubscribeActiveTab;
|
|
23
|
+
private themeObserver;
|
|
24
|
+
private currentTheme;
|
|
25
|
+
constructor(config: ResolvedConfig, onClick: () => void, rootContainer?: HTMLElement | null);
|
|
26
|
+
/**
|
|
27
|
+
* Handle tab click - sets active tab and opens panel
|
|
28
|
+
*/
|
|
29
|
+
private handleTabClick;
|
|
30
|
+
/**
|
|
31
|
+
* Get position as 'left' or 'right' from the floating button position config
|
|
32
|
+
*/
|
|
33
|
+
private getEdgePosition;
|
|
34
|
+
/**
|
|
35
|
+
* Detect the current theme from the document
|
|
36
|
+
* Checks for .dark class (next-themes) or data-theme attribute
|
|
37
|
+
* Returns explicit 'light' or 'dark' to match app theme (not system preference)
|
|
38
|
+
*/
|
|
39
|
+
private detectTheme;
|
|
40
|
+
/**
|
|
41
|
+
* Initialize the edge trigger
|
|
42
|
+
*/
|
|
43
|
+
init(): void;
|
|
44
|
+
/**
|
|
45
|
+
* Apply padding to reserve space for trigger + panel (when open in push mode)
|
|
46
|
+
* In hover mode, only reserve trigger width even when panel is open
|
|
47
|
+
*/
|
|
48
|
+
private applyLayoutPadding;
|
|
49
|
+
/**
|
|
50
|
+
* Remove layout padding
|
|
51
|
+
*/
|
|
52
|
+
private removeLayoutPadding;
|
|
53
|
+
/**
|
|
54
|
+
* Set the open state (to update visibility when panel opens)
|
|
55
|
+
*/
|
|
56
|
+
setOpen(_isOpen: boolean): void;
|
|
57
|
+
/**
|
|
58
|
+
* Show the trigger
|
|
59
|
+
*/
|
|
60
|
+
show(): void;
|
|
61
|
+
/**
|
|
62
|
+
* Hide the trigger
|
|
63
|
+
*/
|
|
64
|
+
hide(): void;
|
|
65
|
+
/**
|
|
66
|
+
* Update trigger position
|
|
67
|
+
*/
|
|
68
|
+
setPosition(position: FloatingButtonPosition): void;
|
|
69
|
+
/**
|
|
70
|
+
* Update trigger label
|
|
71
|
+
*/
|
|
72
|
+
setLabel(label: string): void;
|
|
73
|
+
/**
|
|
74
|
+
* Destroy the trigger
|
|
75
|
+
*/
|
|
76
|
+
destroy(): void;
|
|
77
|
+
private render;
|
|
78
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Floating Help Button Component
|
|
3
|
+
* A floating action button that opens the help panel
|
|
4
|
+
*/
|
|
5
|
+
import type { ResolvedConfig, FloatingButtonPosition } from '../../core/config';
|
|
6
|
+
/**
|
|
7
|
+
* FloatingButton class that manages the button lifecycle
|
|
8
|
+
* Uses Preact for rendering but maintains imperative control
|
|
9
|
+
*/
|
|
10
|
+
export declare class FloatingButton {
|
|
11
|
+
private config;
|
|
12
|
+
private onClick;
|
|
13
|
+
private container;
|
|
14
|
+
private stylesInjected;
|
|
15
|
+
private _isHidden;
|
|
16
|
+
constructor(config: ResolvedConfig, onClick: () => void);
|
|
17
|
+
/**
|
|
18
|
+
* Initialize the floating button
|
|
19
|
+
*/
|
|
20
|
+
init(): void;
|
|
21
|
+
/**
|
|
22
|
+
* Set the open state (to update icon when panel opens)
|
|
23
|
+
*/
|
|
24
|
+
setOpen(_isOpen: boolean): void;
|
|
25
|
+
/**
|
|
26
|
+
* Show the button
|
|
27
|
+
*/
|
|
28
|
+
show(): void;
|
|
29
|
+
/**
|
|
30
|
+
* Hide the button
|
|
31
|
+
*/
|
|
32
|
+
hide(): void;
|
|
33
|
+
/**
|
|
34
|
+
* Update button position
|
|
35
|
+
*/
|
|
36
|
+
setPosition(position: FloatingButtonPosition): void;
|
|
37
|
+
/**
|
|
38
|
+
* Update button label
|
|
39
|
+
*/
|
|
40
|
+
setLabel(label: string): void;
|
|
41
|
+
/**
|
|
42
|
+
* Destroy the button
|
|
43
|
+
*/
|
|
44
|
+
destroy(): void;
|
|
45
|
+
private render;
|
|
46
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ConfirmActionCard Component
|
|
3
|
+
*
|
|
4
|
+
* Renders inline_ui type actions as inline cards in the chat.
|
|
5
|
+
* If a custom card renderer is registered for the card_type, it's used.
|
|
6
|
+
* Otherwise, a default confirmation card is rendered.
|
|
7
|
+
*/
|
|
8
|
+
import type { CardCallbacks } from '../../core/events';
|
|
9
|
+
import type { TaskButtonData } from '../Panel/TaskButton';
|
|
10
|
+
/**
|
|
11
|
+
* Create the default confirmation card for inline_ui actions.
|
|
12
|
+
* Used when no custom card renderer is registered.
|
|
13
|
+
*/
|
|
14
|
+
export declare function createDefaultConfirmCard(action: TaskButtonData, callbacks: CardCallbacks): HTMLDivElement;
|
|
15
|
+
/**
|
|
16
|
+
* Create a confirmation card for a confirm_action type action.
|
|
17
|
+
* Uses custom renderer if registered, otherwise uses default.
|
|
18
|
+
*/
|
|
19
|
+
export declare function createConfirmActionCard(action: TaskButtonData, onConfirm: (data?: Record<string, unknown>) => void, onCancel: () => void): HTMLDivElement;
|
|
20
|
+
/**
|
|
21
|
+
* CSS styles for ConfirmActionCard.
|
|
22
|
+
*/
|
|
23
|
+
export declare const CONFIRM_CARD_STYLES = "\n/* Confirm Action Card */\n.pillar-confirm-card-wrapper {\n margin-top: 12px;\n}\n\n.pillar-confirm-card {\n background: var(--pillar-bg-secondary, #f9fafb);\n border: 1px solid var(--pillar-border, #e5e7eb);\n border-radius: 12px;\n overflow: hidden;\n}\n\n.pillar-confirm-card__content {\n padding: 16px;\n}\n\n.pillar-confirm-card__header {\n margin-bottom: 12px;\n}\n\n.pillar-confirm-card__title {\n font-size: 14px;\n font-weight: 600;\n color: var(--pillar-text-primary, #111827);\n}\n\n.pillar-confirm-card__data {\n background: var(--pillar-bg-primary, #ffffff);\n border: 1px solid var(--pillar-border, #e5e7eb);\n border-radius: 8px;\n padding: 12px;\n margin-bottom: 12px;\n}\n\n.pillar-confirm-card__data-row {\n display: flex;\n gap: 8px;\n font-size: 13px;\n margin-bottom: 4px;\n}\n\n.pillar-confirm-card__data-row:last-child {\n margin-bottom: 0;\n}\n\n.pillar-confirm-card__data-key {\n color: var(--pillar-text-secondary, #6b7280);\n flex-shrink: 0;\n}\n\n.pillar-confirm-card__data-value {\n color: var(--pillar-text-primary, #111827);\n word-break: break-word;\n}\n\n.pillar-confirm-card__actions {\n display: flex;\n gap: 8px;\n justify-content: flex-end;\n}\n\n.pillar-confirm-card__btn {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n padding: 8px 14px;\n font-size: 13px;\n font-weight: 500;\n font-family: inherit;\n border-radius: 8px;\n cursor: pointer;\n transition: all 0.15s ease;\n border: 1px solid transparent;\n}\n\n.pillar-confirm-card__btn:disabled {\n opacity: 0.6;\n cursor: not-allowed;\n}\n\n.pillar-confirm-card__btn svg {\n width: 16px;\n height: 16px;\n}\n\n.pillar-confirm-card__btn--primary {\n background: var(--pillar-primary, #2563eb);\n color: #ffffff;\n border-color: var(--pillar-primary, #2563eb);\n}\n\n.pillar-confirm-card__btn--primary:hover:not(:disabled) {\n background: var(--pillar-primary-hover, #1d4ed8);\n border-color: var(--pillar-primary-hover, #1d4ed8);\n}\n\n.pillar-confirm-card__btn--secondary {\n background: var(--pillar-bg-primary, #ffffff);\n color: var(--pillar-text-secondary, #6b7280);\n border-color: var(--pillar-border, #e5e7eb);\n}\n\n.pillar-confirm-card__btn--secondary:hover:not(:disabled) {\n background: var(--pillar-bg-secondary, #f9fafb);\n}\n\n.pillar-confirm-card__success {\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 8px;\n padding: 16px;\n color: #059669;\n font-weight: 500;\n}\n\n.pillar-confirm-card__success-icon svg {\n width: 20px;\n height: 20px;\n}\n\n.pillar-confirm-card__error {\n background: #fef2f2;\n border: 1px solid #fecaca;\n border-radius: 8px;\n padding: 12px;\n margin-bottom: 12px;\n color: #dc2626;\n font-size: 13px;\n}\n\n.pillar-confirm-card__spinner {\n display: inline-flex;\n animation: pillar-spin 1s linear infinite;\n}\n\n@keyframes pillar-spin {\n from { transform: rotate(0deg); }\n to { transform: rotate(360deg); }\n}\n";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Context Tag Component
|
|
3
|
+
* Displays a removable context item (highlighted text, etc.) as a chip/tag
|
|
4
|
+
*/
|
|
5
|
+
import type { UserContextItem } from '../../types/user-context';
|
|
6
|
+
interface ContextTagProps {
|
|
7
|
+
context: UserContextItem;
|
|
8
|
+
onRemove?: (id: string) => void;
|
|
9
|
+
readOnly?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare function ContextTag({ context, onRemove, readOnly }: ContextTagProps): import("preact").JSX.Element;
|
|
12
|
+
interface ContextTagListProps {
|
|
13
|
+
contexts: UserContextItem[];
|
|
14
|
+
onRemove?: (id: string) => void;
|
|
15
|
+
readOnly?: boolean;
|
|
16
|
+
}
|
|
17
|
+
export declare function ContextTagList({ contexts, onRemove, readOnly }: ContextTagListProps): import("preact").JSX.Element | null;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Panel Header Component
|
|
3
|
+
* Navigation header with back, home, and close buttons
|
|
4
|
+
*/
|
|
5
|
+
import { h } from 'preact';
|
|
6
|
+
import { type ViewType } from '../../store/router';
|
|
7
|
+
interface HeaderProps {
|
|
8
|
+
currentView: ViewType;
|
|
9
|
+
customTitle?: string;
|
|
10
|
+
/** Hide back and home navigation buttons */
|
|
11
|
+
hideNavigation?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export declare function Header({ currentView, customTitle, hideNavigation }: HeaderProps): h.JSX.Element;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Panel Container Component
|
|
3
|
+
* Shadow DOM container for the help panel with Preact rendering
|
|
4
|
+
*/
|
|
5
|
+
import type { APIClient } from '../../api/client';
|
|
6
|
+
import type { ResolvedConfig } from '../../core/config';
|
|
7
|
+
import type { EventEmitter } from '../../core/events';
|
|
8
|
+
export declare class Panel {
|
|
9
|
+
private config;
|
|
10
|
+
private api;
|
|
11
|
+
private events;
|
|
12
|
+
private rootContainer;
|
|
13
|
+
private host;
|
|
14
|
+
private shadow;
|
|
15
|
+
private backdrop;
|
|
16
|
+
private panelElement;
|
|
17
|
+
private renderRoot;
|
|
18
|
+
private unsubscribe;
|
|
19
|
+
private isManualMount;
|
|
20
|
+
private themeObserver;
|
|
21
|
+
constructor(config: ResolvedConfig, api: APIClient, events: EventEmitter, rootContainer?: HTMLElement | null);
|
|
22
|
+
/**
|
|
23
|
+
* Detect the current theme from the document
|
|
24
|
+
* Checks for .dark class (next-themes) or data-theme attribute
|
|
25
|
+
* Returns explicit 'light' or 'dark' to match app theme (not system preference)
|
|
26
|
+
*/
|
|
27
|
+
private detectThemeFromDOM;
|
|
28
|
+
/**
|
|
29
|
+
* Whether the panel is currently open
|
|
30
|
+
*/
|
|
31
|
+
get isOpen(): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Initialize the panel
|
|
34
|
+
*/
|
|
35
|
+
init(): Promise<void>;
|
|
36
|
+
/**
|
|
37
|
+
* Open the panel
|
|
38
|
+
*/
|
|
39
|
+
open(options?: {
|
|
40
|
+
view?: string;
|
|
41
|
+
focusInput?: boolean;
|
|
42
|
+
}): void;
|
|
43
|
+
/**
|
|
44
|
+
* Close the panel
|
|
45
|
+
*/
|
|
46
|
+
close(): void;
|
|
47
|
+
/**
|
|
48
|
+
* Navigate to a specific view
|
|
49
|
+
*/
|
|
50
|
+
navigate(view: string, params?: Record<string, string>): void;
|
|
51
|
+
/**
|
|
52
|
+
* Destroy the panel
|
|
53
|
+
*/
|
|
54
|
+
destroy(): void;
|
|
55
|
+
private subscribeToState;
|
|
56
|
+
private applyPushModeStyles;
|
|
57
|
+
private removePushModeStyles;
|
|
58
|
+
/**
|
|
59
|
+
* Get the container for rendering content (shadow root or host element)
|
|
60
|
+
*/
|
|
61
|
+
private get renderContainer();
|
|
62
|
+
/**
|
|
63
|
+
* Transform Shadow DOM :host selectors to work in regular DOM.
|
|
64
|
+
* Replaces :host with [data-pillar-panel] attribute selector.
|
|
65
|
+
*/
|
|
66
|
+
private transformStylesForRegularDOM;
|
|
67
|
+
/**
|
|
68
|
+
* Inject styles into document.head for non-Shadow DOM mode.
|
|
69
|
+
* Uses IDs to prevent duplicate injection.
|
|
70
|
+
*/
|
|
71
|
+
private injectStylesIntoHead;
|
|
72
|
+
/**
|
|
73
|
+
* Inject styles into Shadow DOM for isolated mode.
|
|
74
|
+
*/
|
|
75
|
+
private injectStylesIntoShadow;
|
|
76
|
+
private createHost;
|
|
77
|
+
/**
|
|
78
|
+
* Mount the panel to a specific container element.
|
|
79
|
+
* Used for manual mounting mode (e.g., from React component).
|
|
80
|
+
*/
|
|
81
|
+
mountTo(container: HTMLElement): void;
|
|
82
|
+
/**
|
|
83
|
+
* Get the host element for external mounting
|
|
84
|
+
*/
|
|
85
|
+
getHostElement(): HTMLElement | null;
|
|
86
|
+
private createBackdrop;
|
|
87
|
+
private createPanel;
|
|
88
|
+
private renderPreact;
|
|
89
|
+
private bindEvents;
|
|
90
|
+
private handleKeyDown;
|
|
91
|
+
private setupFocusTrap;
|
|
92
|
+
/**
|
|
93
|
+
* Apply theme mode attribute to host element for CSS targeting
|
|
94
|
+
*/
|
|
95
|
+
private applyThemeMode;
|
|
96
|
+
/**
|
|
97
|
+
* Set up observer to watch for theme changes on documentElement
|
|
98
|
+
*/
|
|
99
|
+
private setupThemeObserver;
|
|
100
|
+
/**
|
|
101
|
+
* Update the theme at runtime
|
|
102
|
+
*/
|
|
103
|
+
setTheme(themeConfig: Partial<ResolvedConfig['theme']>): void;
|
|
104
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TaskButton Component
|
|
3
|
+
*
|
|
4
|
+
* Renders a task action button in chat responses.
|
|
5
|
+
* When clicked, triggers the task execution via the Pillar SDK.
|
|
6
|
+
*
|
|
7
|
+
* Presentation (label, icon) is derived from task name and type.
|
|
8
|
+
* The server only sends: name, task_type, data.
|
|
9
|
+
*/
|
|
10
|
+
import type { TaskExecutePayload } from '../../core/events';
|
|
11
|
+
/**
|
|
12
|
+
* Task data as received from the AI.
|
|
13
|
+
* Simplified: server sends minimal data, SDK derives presentation.
|
|
14
|
+
*/
|
|
15
|
+
export interface TaskButtonData {
|
|
16
|
+
/** Database UUID for the task (used for confirmation) */
|
|
17
|
+
id?: string;
|
|
18
|
+
/** Task unique identifier (e.g., 'invite_team_member') */
|
|
19
|
+
name: string;
|
|
20
|
+
/** Task type (navigate, trigger_action, etc.) */
|
|
21
|
+
taskType?: TaskExecutePayload['taskType'];
|
|
22
|
+
/** Data payload containing type-specific values */
|
|
23
|
+
data?: Record<string, unknown>;
|
|
24
|
+
/** If true, action executes immediately without user clicking */
|
|
25
|
+
autoRun?: boolean;
|
|
26
|
+
/** If true, action completes without waiting for host confirmation */
|
|
27
|
+
autoComplete?: boolean;
|
|
28
|
+
/** @deprecated SDK now derives label from name */
|
|
29
|
+
label?: string;
|
|
30
|
+
/** @deprecated SDK now derives icon from taskType */
|
|
31
|
+
icon?: string;
|
|
32
|
+
/** @deprecated Use default variant */
|
|
33
|
+
buttonVariant?: 'default' | 'primary' | 'secondary' | 'outline' | 'ghost';
|
|
34
|
+
/** @deprecated Included in data.path */
|
|
35
|
+
path?: string;
|
|
36
|
+
/** @deprecated Included in data.url */
|
|
37
|
+
externalUrl?: string;
|
|
38
|
+
}
|
|
39
|
+
interface TaskButtonProps {
|
|
40
|
+
task: TaskButtonData;
|
|
41
|
+
onExecute?: () => void;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Create a TaskButton element.
|
|
45
|
+
*
|
|
46
|
+
* Presentation is derived:
|
|
47
|
+
* - Label: from task.label (legacy) or derived from task.name
|
|
48
|
+
* - Icon: from task.icon (legacy) or derived from task.taskType
|
|
49
|
+
*/
|
|
50
|
+
export declare function createTaskButton(props: TaskButtonProps): HTMLButtonElement;
|
|
51
|
+
/**
|
|
52
|
+
* Create a container with multiple task buttons.
|
|
53
|
+
*/
|
|
54
|
+
export declare function createTaskButtonGroup(tasks: TaskButtonData[]): HTMLDivElement;
|
|
55
|
+
/**
|
|
56
|
+
* CSS styles for TaskButton (to be added to PANEL_STYLES).
|
|
57
|
+
*/
|
|
58
|
+
export declare const TASK_BUTTON_STYLES = "\n/* Task Button Component */\n.pillar-task-btn {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n padding: 8px 14px;\n font-size: 13px;\n font-weight: 500;\n font-family: inherit;\n border-radius: 8px;\n cursor: pointer;\n transition: all 0.15s ease;\n border: 1px solid transparent;\n text-decoration: none;\n}\n\n.pillar-task-btn__icon {\n display: flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n}\n\n.pillar-task-btn__icon svg {\n width: 16px;\n height: 16px;\n}\n\n.pillar-task-btn__label {\n white-space: nowrap;\n}\n\n/* Primary variant (default) */\n.pillar-task-btn--primary {\n background: #2563eb;\n color: #ffffff;\n border-color: #2563eb;\n}\n\n.pillar-task-btn--primary:hover {\n background: #1d4ed8;\n border-color: #1d4ed8;\n}\n\n/* Default variant */\n.pillar-task-btn--default {\n background: #f3f4f6;\n color: #1a1a1a;\n border-color: #e5e7eb;\n}\n\n.pillar-task-btn--default:hover {\n background: #e5e7eb;\n}\n\n/* Secondary variant */\n.pillar-task-btn--secondary {\n background: #eff6ff;\n color: #2563eb;\n border-color: #dbeafe;\n}\n\n.pillar-task-btn--secondary:hover {\n background: #dbeafe;\n}\n\n/* Outline variant */\n.pillar-task-btn--outline {\n background: transparent;\n color: #2563eb;\n border-color: #2563eb;\n}\n\n.pillar-task-btn--outline:hover {\n background: #eff6ff;\n}\n\n/* Ghost variant */\n.pillar-task-btn--ghost {\n background: transparent;\n color: #6b7280;\n border-color: transparent;\n}\n\n.pillar-task-btn--ghost:hover {\n background: #f3f4f6;\n color: #1a1a1a;\n}\n\n/* Task button group */\n.pillar-task-btn-group {\n display: flex;\n flex-wrap: wrap;\n gap: 8px;\n margin-top: 12px;\n}\n\n/* Task suggestion card in chat */\n.pillar-task-suggestion {\n display: flex;\n flex-direction: column;\n gap: 8px;\n padding: 12px;\n background: #f9fafb;\n border: 1px solid #e5e7eb;\n border-radius: 12px;\n margin-top: 12px;\n}\n\n.pillar-task-suggestion__header {\n display: flex;\n align-items: center;\n gap: 6px;\n font-size: 11px;\n font-weight: 600;\n text-transform: uppercase;\n letter-spacing: 0.5px;\n color: #6b7280;\n}\n\n.pillar-task-suggestion__header svg {\n width: 14px;\n height: 14px;\n}\n\n.pillar-task-suggestion__description {\n font-size: 13px;\n color: #374151;\n}\n";
|
|
59
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unified Chat Input Component
|
|
3
|
+
* Reusable input with context tags and image upload support
|
|
4
|
+
* Used across all views in the SDK
|
|
5
|
+
*/
|
|
6
|
+
import { type ChatImage } from '../../store/chat';
|
|
7
|
+
import type { UserContextItem } from '../../types';
|
|
8
|
+
interface UnifiedChatInputProps {
|
|
9
|
+
/** Placeholder text for the input */
|
|
10
|
+
placeholder?: string;
|
|
11
|
+
/** Whether the input is disabled */
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
/** Custom submit handler - if provided, will be called instead of default navigation */
|
|
14
|
+
onSubmit?: (message: string, context: UserContextItem[], images: ChatImage[]) => void;
|
|
15
|
+
/** Whether to show context tags (default: true) */
|
|
16
|
+
showContextTags?: boolean;
|
|
17
|
+
/** Whether to show image upload button (default: true) */
|
|
18
|
+
showImageUpload?: boolean;
|
|
19
|
+
/** Additional CSS class for the wrapper */
|
|
20
|
+
className?: string;
|
|
21
|
+
}
|
|
22
|
+
export declare function UnifiedChatInput({ placeholder, disabled, onSubmit, showContextTags, showImageUpload, className, }: UnifiedChatInputProps): import("preact").JSX.Element;
|
|
23
|
+
export {};
|