@pillar-ai/sdk 0.1.34 → 0.2.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 +5 -5
- package/dist/api/mcp-client.d.ts +0 -4
- package/dist/cli/sync.js +0 -0
- package/dist/components/Cards/ConfirmActionCard.d.ts +16 -5
- package/dist/components/Panel/TaskButton.d.ts +2 -0
- package/dist/core/Pillar.d.ts +44 -2
- package/dist/core/config.d.ts +7 -1
- package/dist/core/events.d.ts +26 -13
- package/dist/index.d.ts +6 -4
- package/dist/pillar.esm.js +1 -1
- package/dist/store/chat.d.ts +5 -0
- package/dist/tools/types.d.ts +8 -1
- package/package.json +1 -1
- package/dist/actions/definitions/analytics.d.ts +0 -18
- package/dist/actions/definitions/content.d.ts +0 -40
- package/dist/actions/definitions/index.d.ts +0 -26
- package/dist/actions/definitions/navigation.d.ts +0 -65
- package/dist/actions/definitions/settings.d.ts +0 -162
- package/dist/actions/definitions/sources.d.ts +0 -44
- package/dist/actions/definitions/support.d.ts +0 -15
- package/dist/actions/definitions/team.d.ts +0 -120
- package/dist/actions/index.d.ts +0 -33
- package/dist/actions/registry.d.ts +0 -98
- package/dist/actions/types.d.ts +0 -530
- package/dist/api/ag-ui-adapter.d.ts +0 -76
- package/dist/api/ag-ui-bridge.d.ts +0 -49
- package/dist/api/ag-ui-client.d.ts +0 -102
- package/dist/api/ag-ui-handler.d.ts +0 -89
- package/dist/button/FloatingButton.d.ts +0 -44
- package/dist/components/Button/FloatingButton.d.ts +0 -46
- package/dist/components/DevTools/DOMScannerPreview.d.ts +0 -21
- package/dist/components/DevTools/styles.d.ts +0 -5
- package/dist/components/PagePilot/PagePilotBanner.d.ts +0 -7
- package/dist/components/PagePilot/PagePilotManager.d.ts +0 -47
- package/dist/components/PagePilot/index.d.ts +0 -6
- package/dist/components/PagePilot/styles.d.ts +0 -6
- package/dist/components/Panel/styles.d.ts +0 -20
- package/dist/components/Plan/InlinePlanView.d.ts +0 -24
- package/dist/components/Plan/PlanDocument.d.ts +0 -18
- package/dist/components/Plan/PlanStepItem.d.ts +0 -23
- package/dist/components/Plan/PlanView.d.ts +0 -10
- package/dist/components/Plan/index.d.ts +0 -9
- package/dist/components/Progress/AGUIProgress.d.ts +0 -15
- package/dist/components/Progress/ReasoningDisclosure.d.ts +0 -16
- package/dist/components/TextSelection/styles.d.ts +0 -5
- package/dist/components/Tooltips/Tooltip.d.ts +0 -46
- package/dist/components/Tooltips/TooltipManager.d.ts +0 -41
- package/dist/components/Tooltips/index.d.ts +0 -6
- package/dist/components/Tooltips/styles.d.ts +0 -5
- package/dist/components/Views/ArticleChatView.d.ts +0 -9
- package/dist/components/Views/ArticleView.d.ts +0 -10
- package/dist/components/Views/CategoryView.d.ts +0 -11
- package/dist/components/Views/DeveloperView.d.ts +0 -6
- package/dist/components/Views/SearchView.d.ts +0 -10
- package/dist/components/shared/ArticleCard.d.ts +0 -17
- package/dist/components/shared/CategoryCard.d.ts +0 -17
- package/dist/content/extensions/AccordionNode.d.ts +0 -10
- package/dist/content/extensions/CalloutNode.d.ts +0 -11
- package/dist/content/extensions/index.d.ts +0 -5
- package/dist/content/index.d.ts +0 -5
- package/dist/content/renderer.d.ts +0 -24
- package/dist/core/plan-executor.d.ts +0 -148
- package/dist/core/plan.d.ts +0 -192
- package/dist/hooks/useInlineCard.d.ts +0 -35
- package/dist/panel/Panel.d.ts +0 -53
- package/dist/panel/PanelUI.d.ts +0 -43
- package/dist/panel/components/ArticleCard.d.ts +0 -10
- package/dist/panel/components/CategoryCard.d.ts +0 -10
- package/dist/panel/components/ChatInput.d.ts +0 -36
- package/dist/panel/components/Header.d.ts +0 -16
- package/dist/panel/components/SearchInput.d.ts +0 -11
- package/dist/panel/styles.d.ts +0 -5
- package/dist/panel/views/ArticleView.d.ts +0 -21
- package/dist/panel/views/CategoryView.d.ts +0 -20
- package/dist/panel/views/ChatView.d.ts +0 -30
- package/dist/panel/views/HomeView.d.ts +0 -18
- package/dist/panel/views/SearchView.d.ts +0 -22
- package/dist/store/developer.d.ts +0 -19
- package/dist/store/plan-persistence.d.ts +0 -47
- package/dist/store/plan.d.ts +0 -45
- package/dist/store/tooltips.d.ts +0 -21
- package/dist/tooltips/Tooltip.d.ts +0 -63
- package/dist/tooltips/TooltipManager.d.ts +0 -42
- package/dist/tooltips/styles.d.ts +0 -5
- package/dist/ui/config.d.ts +0 -96
- package/dist/ui/executor.d.ts +0 -75
- package/dist/ui/index.d.ts +0 -11
- package/dist/ui/scanner.d.ts +0 -105
- package/dist/ui/types.d.ts +0 -293
- package/dist/utils/markdown.d.ts +0 -9
package/dist/actions/types.d.ts
DELETED
|
@@ -1,530 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Action Types - Type definitions for code-first action definitions.
|
|
3
|
-
*
|
|
4
|
-
* These types enable developers to define actions in their application code
|
|
5
|
-
* rather than in the admin UI, with full TypeScript support.
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* ```ts
|
|
9
|
-
* // lib/pillar/actions/index.ts
|
|
10
|
-
* import type { SyncActionDefinitions } from '@pillar-ai/sdk';
|
|
11
|
-
*
|
|
12
|
-
* export const actions = {
|
|
13
|
-
* open_settings: {
|
|
14
|
-
* description: 'Navigate to the settings page',
|
|
15
|
-
* type: 'navigate' as const,
|
|
16
|
-
* path: '/settings',
|
|
17
|
-
* autoRun: true,
|
|
18
|
-
* },
|
|
19
|
-
* } as const satisfies SyncActionDefinitions;
|
|
20
|
-
*
|
|
21
|
-
* export default actions;
|
|
22
|
-
*
|
|
23
|
-
* // Sync via CI/CD: npx pillar-sync --actions ./lib/pillar/actions/index.ts
|
|
24
|
-
* // Register handlers at runtime: pillar.onTask('open_settings', () => router.push('/settings'));
|
|
25
|
-
* ```
|
|
26
|
-
*/
|
|
27
|
-
/**
|
|
28
|
-
* Supported action types.
|
|
29
|
-
*
|
|
30
|
-
* - navigate: Navigate to a page within the app
|
|
31
|
-
* - open_modal: Open a modal or dialog
|
|
32
|
-
* - fill_form: Fill form fields with data
|
|
33
|
-
* - trigger_action: Trigger a custom action
|
|
34
|
-
* - query: Fetch data from the client and return to the agent (implies returns: true)
|
|
35
|
-
* - copy_text: Copy text to clipboard
|
|
36
|
-
* - external_link: Open an external URL
|
|
37
|
-
* - start_tutorial: Start a tutorial/walkthrough
|
|
38
|
-
* - inline_ui: Display inline UI card in chat
|
|
39
|
-
*/
|
|
40
|
-
export type ActionType = 'navigate' | 'open_modal' | 'fill_form' | 'trigger_action' | 'query' | 'copy_text' | 'external_link' | 'start_tutorial' | 'inline_ui';
|
|
41
|
-
/**
|
|
42
|
-
* Supported platforms for action deployments.
|
|
43
|
-
*/
|
|
44
|
-
export type Platform = 'web' | 'ios' | 'android' | 'desktop';
|
|
45
|
-
/**
|
|
46
|
-
* Schema property definition for a single field.
|
|
47
|
-
* Supports nested objects and arrays with items.
|
|
48
|
-
*/
|
|
49
|
-
export interface ActionDataSchemaProperty {
|
|
50
|
-
type: 'string' | 'number' | 'boolean' | 'array' | 'object';
|
|
51
|
-
description?: string;
|
|
52
|
-
enum?: string[];
|
|
53
|
-
default?: unknown;
|
|
54
|
-
/** Items schema for array types */
|
|
55
|
-
items?: ActionDataSchemaProperty;
|
|
56
|
-
/** Nested properties for object types */
|
|
57
|
-
properties?: Record<string, ActionDataSchemaProperty>;
|
|
58
|
-
/** Required fields for nested object types */
|
|
59
|
-
required?: string[];
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* JSON Schema definition for action data.
|
|
63
|
-
*
|
|
64
|
-
* When provided, the AI will extract data from the user's query
|
|
65
|
-
* and populate the action's data field before execution.
|
|
66
|
-
*/
|
|
67
|
-
export interface ActionDataSchema {
|
|
68
|
-
type: 'object';
|
|
69
|
-
properties: Record<string, ActionDataSchemaProperty>;
|
|
70
|
-
required?: string[];
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Definition for a single action.
|
|
74
|
-
*
|
|
75
|
-
* Actions are defined in code and synced to the server during CI/CD.
|
|
76
|
-
* The server stores the metadata, and the SDK executes the handler locally.
|
|
77
|
-
*
|
|
78
|
-
* @template TData - Type for the data passed to the handler
|
|
79
|
-
*/
|
|
80
|
-
export interface ActionDefinition<TData = Record<string, unknown>> {
|
|
81
|
-
/**
|
|
82
|
-
* Human-readable description for AI matching.
|
|
83
|
-
*
|
|
84
|
-
* The AI uses semantic similarity to match user queries to this description.
|
|
85
|
-
* Be specific about when this action should be suggested.
|
|
86
|
-
*
|
|
87
|
-
* @example "Navigate to the billing page. Suggest when user asks about payments, invoices, or subscription."
|
|
88
|
-
*/
|
|
89
|
-
description: string;
|
|
90
|
-
/**
|
|
91
|
-
* Example user queries that should trigger this action.
|
|
92
|
-
*
|
|
93
|
-
* Provide 3-5 natural phrasings users might say:
|
|
94
|
-
* - Imperative: "open settings", "go to billing"
|
|
95
|
-
* - Questions: "where can I change my password?"
|
|
96
|
-
* - Informal: "settings", "show analytics"
|
|
97
|
-
*
|
|
98
|
-
* These are embedded and used for semantic matching alongside the description.
|
|
99
|
-
*/
|
|
100
|
-
examples?: string[];
|
|
101
|
-
/**
|
|
102
|
-
* Type of action - determines how the SDK handles it.
|
|
103
|
-
*/
|
|
104
|
-
type: ActionType;
|
|
105
|
-
/**
|
|
106
|
-
* Path for navigate actions.
|
|
107
|
-
*
|
|
108
|
-
* Can include template variables like `/users/{userId}`.
|
|
109
|
-
*/
|
|
110
|
-
path?: string;
|
|
111
|
-
/**
|
|
112
|
-
* External URL for external_link actions.
|
|
113
|
-
*/
|
|
114
|
-
externalUrl?: string;
|
|
115
|
-
/**
|
|
116
|
-
* JSON Schema for data extraction from user query.
|
|
117
|
-
*
|
|
118
|
-
* When provided, the AI will attempt to extract structured data
|
|
119
|
-
* from the conversation before executing the action.
|
|
120
|
-
*/
|
|
121
|
-
dataSchema?: ActionDataSchema;
|
|
122
|
-
/**
|
|
123
|
-
* Default data to pass to the handler.
|
|
124
|
-
*/
|
|
125
|
-
defaultData?: TData;
|
|
126
|
-
/**
|
|
127
|
-
* Context required for this action to be available.
|
|
128
|
-
*
|
|
129
|
-
* @example { loggedIn: true, plan: 'pro' }
|
|
130
|
-
*/
|
|
131
|
-
requiredContext?: Record<string, unknown>;
|
|
132
|
-
/**
|
|
133
|
-
* Whether to auto-run this action without user confirmation.
|
|
134
|
-
*
|
|
135
|
-
* Only the highest-scoring action can auto-run.
|
|
136
|
-
* Use for simple navigations where user intent is clear.
|
|
137
|
-
*
|
|
138
|
-
* @default false
|
|
139
|
-
*/
|
|
140
|
-
autoRun?: boolean;
|
|
141
|
-
/**
|
|
142
|
-
* Whether the action completes immediately after execution.
|
|
143
|
-
*
|
|
144
|
-
* If false, the SDK waits for host app confirmation.
|
|
145
|
-
* Use true for simple navigations and clipboard operations.
|
|
146
|
-
*
|
|
147
|
-
* @default false
|
|
148
|
-
*/
|
|
149
|
-
autoComplete?: boolean;
|
|
150
|
-
/**
|
|
151
|
-
* Whether this action returns data for the agent.
|
|
152
|
-
*
|
|
153
|
-
* If true, the handler's return value is sent back to the agent
|
|
154
|
-
* for further reasoning. Use for query/lookup actions that inform
|
|
155
|
-
* the agent's next decision.
|
|
156
|
-
*
|
|
157
|
-
* @default false
|
|
158
|
-
*/
|
|
159
|
-
returns?: boolean;
|
|
160
|
-
/**
|
|
161
|
-
* Concrete examples of valid parameter objects for the AI to reference.
|
|
162
|
-
*
|
|
163
|
-
* Each example should have a `description` explaining the scenario
|
|
164
|
-
* and a `parameters` object matching the `dataSchema`.
|
|
165
|
-
* Useful for complex schemas where the AI benefits from seeing
|
|
166
|
-
* what a correct call looks like.
|
|
167
|
-
*/
|
|
168
|
-
parameterExamples?: Array<{
|
|
169
|
-
description: string;
|
|
170
|
-
parameters: Record<string, unknown>;
|
|
171
|
-
}>;
|
|
172
|
-
/**
|
|
173
|
-
* Handler function executed when the action is triggered.
|
|
174
|
-
*
|
|
175
|
-
* This runs in the client - the server only stores metadata.
|
|
176
|
-
* If `returns: true`, the return value is sent to the agent.
|
|
177
|
-
*/
|
|
178
|
-
handler: (data: TData) => void | unknown | Promise<void | unknown>;
|
|
179
|
-
}
|
|
180
|
-
/**
|
|
181
|
-
* Map of action name to definition.
|
|
182
|
-
*
|
|
183
|
-
* Action names should be snake_case identifiers.
|
|
184
|
-
*/
|
|
185
|
-
export type ActionDefinitions = Record<string, ActionDefinition<unknown>>;
|
|
186
|
-
/**
|
|
187
|
-
* Metadata for a single action in the manifest (no handler).
|
|
188
|
-
*
|
|
189
|
-
* This is what gets synced to the server.
|
|
190
|
-
*/
|
|
191
|
-
export interface ActionManifestEntry {
|
|
192
|
-
name: string;
|
|
193
|
-
description: string;
|
|
194
|
-
examples?: string[];
|
|
195
|
-
type: ActionType;
|
|
196
|
-
path?: string;
|
|
197
|
-
external_url?: string;
|
|
198
|
-
auto_run?: boolean;
|
|
199
|
-
auto_complete?: boolean;
|
|
200
|
-
returns_data?: boolean;
|
|
201
|
-
data_schema?: ActionDataSchema;
|
|
202
|
-
default_data?: Record<string, unknown>;
|
|
203
|
-
required_context?: Record<string, unknown>;
|
|
204
|
-
parameter_examples?: Array<{
|
|
205
|
-
description: string;
|
|
206
|
-
parameters: Record<string, unknown>;
|
|
207
|
-
}>;
|
|
208
|
-
}
|
|
209
|
-
/**
|
|
210
|
-
* Action manifest - synced to server during CI/CD.
|
|
211
|
-
*
|
|
212
|
-
* Contains all action metadata without handlers.
|
|
213
|
-
*/
|
|
214
|
-
export interface ActionManifest {
|
|
215
|
-
/**
|
|
216
|
-
* Platform this manifest is for.
|
|
217
|
-
*/
|
|
218
|
-
platform: Platform;
|
|
219
|
-
/**
|
|
220
|
-
* Version of the client app (semver or git SHA).
|
|
221
|
-
*/
|
|
222
|
-
version: string;
|
|
223
|
-
/**
|
|
224
|
-
* Git commit SHA for traceability.
|
|
225
|
-
*/
|
|
226
|
-
gitSha?: string;
|
|
227
|
-
/**
|
|
228
|
-
* When this manifest was generated.
|
|
229
|
-
*/
|
|
230
|
-
generatedAt: string;
|
|
231
|
-
/**
|
|
232
|
-
* Action definitions (without handlers).
|
|
233
|
-
*/
|
|
234
|
-
actions: ActionManifestEntry[];
|
|
235
|
-
/**
|
|
236
|
-
* Custom agent guidance synced alongside actions.
|
|
237
|
-
* Injected into the AI agent's prompt as product_guidance.
|
|
238
|
-
*/
|
|
239
|
-
agentGuidance?: string;
|
|
240
|
-
}
|
|
241
|
-
/**
|
|
242
|
-
* Client info set during SDK initialization.
|
|
243
|
-
*/
|
|
244
|
-
export interface ClientInfo {
|
|
245
|
-
platform: Platform;
|
|
246
|
-
version: string;
|
|
247
|
-
}
|
|
248
|
-
/**
|
|
249
|
-
* Action definition for syncing (without handler).
|
|
250
|
-
*
|
|
251
|
-
* Use this type when defining actions for CI/CD sync.
|
|
252
|
-
* Handlers are registered separately at runtime via pillar.onTask().
|
|
253
|
-
*
|
|
254
|
-
* @example
|
|
255
|
-
* ```ts
|
|
256
|
-
* import type { SyncActionDefinitions } from '@pillar-ai/sdk';
|
|
257
|
-
*
|
|
258
|
-
* export const actions: SyncActionDefinitions = {
|
|
259
|
-
* open_settings: {
|
|
260
|
-
* description: 'Navigate to settings page',
|
|
261
|
-
* type: 'navigate',
|
|
262
|
-
* path: '/settings',
|
|
263
|
-
* autoRun: true,
|
|
264
|
-
* },
|
|
265
|
-
* };
|
|
266
|
-
* ```
|
|
267
|
-
*/
|
|
268
|
-
export interface SyncActionDefinition<TData = Record<string, unknown>> {
|
|
269
|
-
/** Human-readable description for AI matching */
|
|
270
|
-
description: string;
|
|
271
|
-
/** Example user queries that should trigger this action */
|
|
272
|
-
examples?: string[];
|
|
273
|
-
/** Type of action */
|
|
274
|
-
type: ActionType;
|
|
275
|
-
/** Path for navigate actions */
|
|
276
|
-
path?: string;
|
|
277
|
-
/** External URL for external_link actions */
|
|
278
|
-
externalUrl?: string;
|
|
279
|
-
/** JSON Schema for data extraction from user query */
|
|
280
|
-
dataSchema?: ActionDataSchema;
|
|
281
|
-
/** Default data to pass to the handler */
|
|
282
|
-
defaultData?: TData;
|
|
283
|
-
/** Context required for this action to be available */
|
|
284
|
-
requiredContext?: Record<string, unknown>;
|
|
285
|
-
/** Whether to auto-run this action without user confirmation */
|
|
286
|
-
autoRun?: boolean;
|
|
287
|
-
/** Whether the action completes immediately after execution */
|
|
288
|
-
autoComplete?: boolean;
|
|
289
|
-
/**
|
|
290
|
-
* Whether this action returns data for the agent.
|
|
291
|
-
* If true, the handler's return value is sent back to the agent.
|
|
292
|
-
*/
|
|
293
|
-
returns?: boolean;
|
|
294
|
-
/**
|
|
295
|
-
* Concrete examples of valid parameter objects for the AI to reference.
|
|
296
|
-
* Each example should have a `description` and a `parameters` object
|
|
297
|
-
* matching the `dataSchema`.
|
|
298
|
-
*/
|
|
299
|
-
parameterExamples?: Array<{
|
|
300
|
-
description: string;
|
|
301
|
-
parameters: Record<string, unknown>;
|
|
302
|
-
}>;
|
|
303
|
-
}
|
|
304
|
-
/**
|
|
305
|
-
* Map of action name to sync definition (no handlers).
|
|
306
|
-
*
|
|
307
|
-
* Use this type for your actions file that gets synced via CI/CD.
|
|
308
|
-
*/
|
|
309
|
-
export type SyncActionDefinitions = Record<string, SyncActionDefinition<unknown>>;
|
|
310
|
-
/**
|
|
311
|
-
* Base data types for each action type.
|
|
312
|
-
* These are automatically inferred from the action's `type` field.
|
|
313
|
-
*/
|
|
314
|
-
export interface NavigateActionData {
|
|
315
|
-
/** CSS selector to highlight after navigation */
|
|
316
|
-
highlight_selector?: string;
|
|
317
|
-
/** Path that was navigated to (injected by SDK) */
|
|
318
|
-
path?: string;
|
|
319
|
-
}
|
|
320
|
-
export interface TriggerActionData {
|
|
321
|
-
/** The action being triggered */
|
|
322
|
-
action?: string;
|
|
323
|
-
/** Additional action parameters */
|
|
324
|
-
[key: string]: unknown;
|
|
325
|
-
}
|
|
326
|
-
export interface InlineUIData {
|
|
327
|
-
/** Card type for rendering */
|
|
328
|
-
card_type: string;
|
|
329
|
-
/** Additional card data */
|
|
330
|
-
[key: string]: unknown;
|
|
331
|
-
}
|
|
332
|
-
export interface ExternalLinkData {
|
|
333
|
-
/** The URL being opened */
|
|
334
|
-
url?: string;
|
|
335
|
-
}
|
|
336
|
-
export interface CopyTextData {
|
|
337
|
-
/** Text to copy to clipboard */
|
|
338
|
-
text?: string;
|
|
339
|
-
}
|
|
340
|
-
export interface QueryActionData {
|
|
341
|
-
/** Query parameters passed to the handler */
|
|
342
|
-
[key: string]: unknown;
|
|
343
|
-
}
|
|
344
|
-
/**
|
|
345
|
-
* Maps action types to their default data shapes.
|
|
346
|
-
* Used for automatic type inference in onTask handlers.
|
|
347
|
-
*/
|
|
348
|
-
export interface ActionTypeDataMap {
|
|
349
|
-
navigate: NavigateActionData;
|
|
350
|
-
trigger_action: TriggerActionData;
|
|
351
|
-
query: QueryActionData;
|
|
352
|
-
inline_ui: InlineUIData;
|
|
353
|
-
external_link: ExternalLinkData;
|
|
354
|
-
copy_text: CopyTextData;
|
|
355
|
-
open_modal: Record<string, unknown>;
|
|
356
|
-
fill_form: Record<string, unknown>;
|
|
357
|
-
start_tutorial: Record<string, unknown>;
|
|
358
|
-
}
|
|
359
|
-
/**
|
|
360
|
-
* Extract the data type for a specific action from an ActionDefinitions map.
|
|
361
|
-
*
|
|
362
|
-
* Type inference priority:
|
|
363
|
-
* 1. If `defaultData` is defined, use that type (for custom fields)
|
|
364
|
-
* 2. Otherwise, infer from the action's `type` field using ActionTypeDataMap
|
|
365
|
-
* 3. Fall back to Record<string, unknown>
|
|
366
|
-
*
|
|
367
|
-
* @example
|
|
368
|
-
* ```ts
|
|
369
|
-
* const actions = {
|
|
370
|
-
* // Inferred from type: "navigate" → NavigateActionData
|
|
371
|
-
* open_settings: {
|
|
372
|
-
* description: '...',
|
|
373
|
-
* type: 'navigate',
|
|
374
|
-
* path: '/settings',
|
|
375
|
-
* },
|
|
376
|
-
* // Custom data via defaultData
|
|
377
|
-
* add_source: {
|
|
378
|
-
* description: '...',
|
|
379
|
-
* type: 'navigate',
|
|
380
|
-
* defaultData: { type: '', url: '', name: '' },
|
|
381
|
-
* },
|
|
382
|
-
* } as const satisfies SyncActionDefinitions;
|
|
383
|
-
* ```
|
|
384
|
-
*/
|
|
385
|
-
export type ActionDataType<TActions extends SyncActionDefinitions | ActionDefinitions, TName extends keyof TActions> = TActions[TName] extends {
|
|
386
|
-
defaultData: infer D;
|
|
387
|
-
} ? D extends Record<string, unknown> ? D : Record<string, unknown> : TActions[TName] extends {
|
|
388
|
-
type: infer T;
|
|
389
|
-
} ? T extends keyof ActionTypeDataMap ? ActionTypeDataMap[T] : Record<string, unknown> : Record<string, unknown>;
|
|
390
|
-
/**
|
|
391
|
-
* Extract all action names from an ActionDefinitions map.
|
|
392
|
-
*
|
|
393
|
-
* @example
|
|
394
|
-
* ```ts
|
|
395
|
-
* const actions = { open_settings: {...}, add_source: {...} };
|
|
396
|
-
* type Names = ActionNames<typeof actions>; // 'open_settings' | 'add_source'
|
|
397
|
-
* ```
|
|
398
|
-
*/
|
|
399
|
-
export type ActionNames<T extends SyncActionDefinitions | ActionDefinitions> = Extract<keyof T, string>;
|
|
400
|
-
/**
|
|
401
|
-
* Typed task handler function.
|
|
402
|
-
*
|
|
403
|
-
* @template TData - The data type for this action
|
|
404
|
-
*/
|
|
405
|
-
export type TypedTaskHandler<TData = Record<string, unknown>> = (data: TData) => void | Promise<void>;
|
|
406
|
-
/**
|
|
407
|
-
* Type-safe onTask method signature.
|
|
408
|
-
*
|
|
409
|
-
* When actions are provided to PillarProvider, this type enables
|
|
410
|
-
* TypeScript to infer the correct data type for each action handler.
|
|
411
|
-
*
|
|
412
|
-
* @template TActions - The action definitions map
|
|
413
|
-
*/
|
|
414
|
-
export interface TypedOnTask<TActions extends SyncActionDefinitions | ActionDefinitions> {
|
|
415
|
-
<TName extends ActionNames<TActions>>(taskName: TName, handler: TypedTaskHandler<ActionDataType<TActions, TName>>): () => void;
|
|
416
|
-
(taskName: string, handler: TypedTaskHandler): () => void;
|
|
417
|
-
}
|
|
418
|
-
/**
|
|
419
|
-
* Extended Pillar interface with type-safe onTask.
|
|
420
|
-
*
|
|
421
|
-
* Use this when you want strongly typed task handlers based on
|
|
422
|
-
* your action definitions.
|
|
423
|
-
*
|
|
424
|
-
* @template TActions - The action definitions map
|
|
425
|
-
*
|
|
426
|
-
* @example
|
|
427
|
-
* ```ts
|
|
428
|
-
* import type { TypedPillar } from '@pillar-ai/sdk';
|
|
429
|
-
* import type { actions } from './actions';
|
|
430
|
-
*
|
|
431
|
-
* const pillar = usePillar<typeof actions>();
|
|
432
|
-
*
|
|
433
|
-
* // TypeScript knows `data` has { type, url, name }
|
|
434
|
-
* pillar.onTask('add_source', (data) => {
|
|
435
|
-
* console.log(data.url);
|
|
436
|
-
* });
|
|
437
|
-
* ```
|
|
438
|
-
*/
|
|
439
|
-
export interface TypedPillarMethods<TActions extends SyncActionDefinitions | ActionDefinitions> {
|
|
440
|
-
onTask: TypedOnTask<TActions>;
|
|
441
|
-
}
|
|
442
|
-
/**
|
|
443
|
-
* Result returned from an action's execute function.
|
|
444
|
-
*
|
|
445
|
-
* Follows the MCP tool result format. Plain objects are also accepted
|
|
446
|
-
* by the SDK and normalized to this shape automatically.
|
|
447
|
-
*/
|
|
448
|
-
export interface ActionResult {
|
|
449
|
-
content: Array<{
|
|
450
|
-
type: 'text';
|
|
451
|
-
text: string;
|
|
452
|
-
} | {
|
|
453
|
-
type: 'image';
|
|
454
|
-
data: string;
|
|
455
|
-
mimeType: string;
|
|
456
|
-
}>;
|
|
457
|
-
isError?: boolean;
|
|
458
|
-
}
|
|
459
|
-
/**
|
|
460
|
-
* Unified action definition that co-locates metadata and handler.
|
|
461
|
-
*
|
|
462
|
-
* Use with `pillar.defineAction()` or the `usePillarAction()` React hook.
|
|
463
|
-
* The CLI scanner (`npx pillar-sync --scan ./src`) discovers these
|
|
464
|
-
* definitions automatically — no barrel file needed.
|
|
465
|
-
*
|
|
466
|
-
* @template TInput - Type of the input object passed to `execute`
|
|
467
|
-
*
|
|
468
|
-
* @example
|
|
469
|
-
* ```ts
|
|
470
|
-
* pillar.defineAction({
|
|
471
|
-
* name: 'add_to_cart',
|
|
472
|
-
* description: 'Add a product to the shopping cart',
|
|
473
|
-
* inputSchema: {
|
|
474
|
-
* type: 'object',
|
|
475
|
-
* properties: {
|
|
476
|
-
* productId: { type: 'string', description: 'Product ID' },
|
|
477
|
-
* quantity: { type: 'number', description: 'Quantity to add' },
|
|
478
|
-
* },
|
|
479
|
-
* required: ['productId', 'quantity'],
|
|
480
|
-
* },
|
|
481
|
-
* execute: async ({ productId, quantity }) => {
|
|
482
|
-
* await cartApi.add(productId, quantity);
|
|
483
|
-
* return { content: [{ type: 'text', text: 'Added to cart' }] };
|
|
484
|
-
* },
|
|
485
|
-
* });
|
|
486
|
-
* ```
|
|
487
|
-
*/
|
|
488
|
-
export interface ActionSchema<TInput = Record<string, unknown>> {
|
|
489
|
-
/** Unique action name (e.g., 'add_to_cart') */
|
|
490
|
-
name: string;
|
|
491
|
-
/** Human-readable description for AI matching */
|
|
492
|
-
description: string;
|
|
493
|
-
/**
|
|
494
|
-
* Type of action - determines how the SDK handles it and organizes it in the UI.
|
|
495
|
-
*/
|
|
496
|
-
type?: ActionType;
|
|
497
|
-
/**
|
|
498
|
-
* JSON Schema describing the input parameters.
|
|
499
|
-
* The AI extracts structured data from the conversation to populate these.
|
|
500
|
-
*/
|
|
501
|
-
inputSchema?: {
|
|
502
|
-
type: 'object';
|
|
503
|
-
properties: Record<string, unknown>;
|
|
504
|
-
required?: string[];
|
|
505
|
-
};
|
|
506
|
-
/**
|
|
507
|
-
* Example user queries that should trigger this action.
|
|
508
|
-
* Used for semantic matching alongside the description.
|
|
509
|
-
*/
|
|
510
|
-
examples?: string[];
|
|
511
|
-
/**
|
|
512
|
-
* Whether to auto-execute without user confirmation.
|
|
513
|
-
* @default false
|
|
514
|
-
*/
|
|
515
|
-
autoRun?: boolean;
|
|
516
|
-
/**
|
|
517
|
-
* Whether the action completes immediately after execution.
|
|
518
|
-
* @default true
|
|
519
|
-
*/
|
|
520
|
-
autoComplete?: boolean;
|
|
521
|
-
/**
|
|
522
|
-
* Handler function executed when the AI invokes this action.
|
|
523
|
-
*
|
|
524
|
-
* Can return:
|
|
525
|
-
* - An `ActionResult` with MCP-style content blocks
|
|
526
|
-
* - A plain object (SDK normalizes it for the agent)
|
|
527
|
-
* - `void` if the action has no return value
|
|
528
|
-
*/
|
|
529
|
-
execute: (input: TInput) => Promise<ActionResult | unknown | void> | ActionResult | unknown | void;
|
|
530
|
-
}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* AG-UI Client Adapter for Pillar SDK
|
|
3
|
-
*
|
|
4
|
-
* Bridges the new AGUIClient to existing chat store patterns.
|
|
5
|
-
* Allows gradual migration without changing all components at once.
|
|
6
|
-
*
|
|
7
|
-
* Copyright (C) 2025 Pillar Team
|
|
8
|
-
*/
|
|
9
|
-
import type { ResolvedConfig } from '../core/config';
|
|
10
|
-
import type { ExecutionPlan } from '../core/plan';
|
|
11
|
-
import type { TaskButtonData } from '../components/Panel/TaskButton';
|
|
12
|
-
import type { UserContextItem } from '../types/user-context';
|
|
13
|
-
import type { ArticleSummary, ChatMessage, ChatResponse, ProgressEvent } from './client';
|
|
14
|
-
import type { QueryRequest, ChatImage } from './mcp-client';
|
|
15
|
-
import { type ClientTool } from './ag-ui-client';
|
|
16
|
-
export interface LegacyStreamCallbacks {
|
|
17
|
-
/** Called for each text token */
|
|
18
|
-
onToken?: (token: string) => void;
|
|
19
|
-
/** Called when sources are available */
|
|
20
|
-
onSources?: (sources: ArticleSummary[]) => void;
|
|
21
|
-
/** Called when actions are available */
|
|
22
|
-
onActions?: (actions: TaskButtonData[]) => void;
|
|
23
|
-
/** Called when a plan is created */
|
|
24
|
-
onPlan?: (plan: ExecutionPlan) => void;
|
|
25
|
-
/** Called for progress updates */
|
|
26
|
-
onProgress?: (progress: ProgressEvent) => void;
|
|
27
|
-
/** Called when conversation starts (early conversation_id) */
|
|
28
|
-
onConversationStarted?: (conversationId: string, messageId?: string) => void;
|
|
29
|
-
/** Called when agent requests data from host app */
|
|
30
|
-
onQueryRequest?: (request: QueryRequest) => Promise<void>;
|
|
31
|
-
/** Called on error */
|
|
32
|
-
onError?: (error: string) => void;
|
|
33
|
-
/** Called when stream is complete */
|
|
34
|
-
onComplete?: (conversationId?: string, queryLogId?: string) => void;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Wraps AGUIClient to provide the same interface as the legacy MCPClient.
|
|
38
|
-
* Used during migration to minimize component changes.
|
|
39
|
-
*/
|
|
40
|
-
export declare class AGUIClientAdapter {
|
|
41
|
-
private client;
|
|
42
|
-
private currentStep;
|
|
43
|
-
constructor(config: ResolvedConfig);
|
|
44
|
-
/**
|
|
45
|
-
* Register a client-side tool (query action).
|
|
46
|
-
*/
|
|
47
|
-
registerTool(tool: ClientTool): void;
|
|
48
|
-
/**
|
|
49
|
-
* Unregister a client-side tool.
|
|
50
|
-
*/
|
|
51
|
-
unregisterTool(toolName: string): void;
|
|
52
|
-
/**
|
|
53
|
-
* Chat with streaming, using legacy callback patterns.
|
|
54
|
-
*/
|
|
55
|
-
chat(message: string, callbacks: LegacyStreamCallbacks, options?: {
|
|
56
|
-
history?: ChatMessage[];
|
|
57
|
-
userContext?: UserContextItem[];
|
|
58
|
-
images?: ChatImage[];
|
|
59
|
-
signal?: AbortSignal;
|
|
60
|
-
}): Promise<ChatResponse>;
|
|
61
|
-
/**
|
|
62
|
-
* Get current thread ID.
|
|
63
|
-
*/
|
|
64
|
-
get threadId(): string;
|
|
65
|
-
/**
|
|
66
|
-
* Start a new conversation.
|
|
67
|
-
*/
|
|
68
|
-
newThread(): string;
|
|
69
|
-
/**
|
|
70
|
-
* Send action result back to the agent (for query actions).
|
|
71
|
-
*
|
|
72
|
-
* @param actionName - The name of the action that was executed
|
|
73
|
-
* @param result - The result data to send back to the agent
|
|
74
|
-
*/
|
|
75
|
-
sendActionResult(actionName: string, result: unknown): Promise<void>;
|
|
76
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* AG-UI Bridge
|
|
3
|
-
*
|
|
4
|
-
* Temporary bridge that converts Phase 1's JSON-RPC wrapped AG-UI events
|
|
5
|
-
* to native AG-UI events. This allows the SDK to use AG-UI patterns while
|
|
6
|
-
* the backend still uses JSON-RPC transport.
|
|
7
|
-
*
|
|
8
|
-
* Will be removed after Phase 3 (pure AG-UI transport).
|
|
9
|
-
*/
|
|
10
|
-
import type { AGUIEvent } from '@ag-ui/core';
|
|
11
|
-
/**
|
|
12
|
-
* Unwrap an AG-UI event from a JSON-RPC notification.
|
|
13
|
-
*
|
|
14
|
-
* Phase 1 backend wraps AG-UI events like this:
|
|
15
|
-
* {
|
|
16
|
-
* "jsonrpc": "2.0",
|
|
17
|
-
* "method": "notifications/progress",
|
|
18
|
-
* "params": {
|
|
19
|
-
* "ag_ui_event": { "type": "RUN_STARTED", ... }
|
|
20
|
-
* }
|
|
21
|
-
* }
|
|
22
|
-
*
|
|
23
|
-
* @param jsonRpcEvent - The JSON-RPC notification from the backend
|
|
24
|
-
* @returns The unwrapped AG-UI event, or null if not an AG-UI event
|
|
25
|
-
*/
|
|
26
|
-
export declare function unwrapAGUIEvent(jsonRpcEvent: unknown): AGUIEvent | null;
|
|
27
|
-
/**
|
|
28
|
-
* Check if a JSON-RPC event contains an AG-UI event.
|
|
29
|
-
*/
|
|
30
|
-
export declare function isAGUIWrappedEvent(jsonRpcEvent: unknown): boolean;
|
|
31
|
-
/**
|
|
32
|
-
* Convert legacy MCP progress events to AG-UI events.
|
|
33
|
-
*
|
|
34
|
-
* This is for backwards compatibility during the transition.
|
|
35
|
-
* Converts old-style progress events to AG-UI events.
|
|
36
|
-
*
|
|
37
|
-
* @param legacyEvent - The legacy MCP progress event
|
|
38
|
-
* @returns An array of AG-UI events (may be multiple for some conversions)
|
|
39
|
-
*/
|
|
40
|
-
export declare function convertLegacyProgressToAGUI(legacyEvent: Record<string, unknown>): AGUIEvent[];
|
|
41
|
-
/**
|
|
42
|
-
* Process a raw SSE event and extract AG-UI events.
|
|
43
|
-
*
|
|
44
|
-
* Handles both new AG-UI wrapped events and legacy progress events.
|
|
45
|
-
*
|
|
46
|
-
* @param rawEvent - The parsed JSON from an SSE data line
|
|
47
|
-
* @returns An array of AG-UI events
|
|
48
|
-
*/
|
|
49
|
-
export declare function processSSEEvent(rawEvent: unknown): AGUIEvent[];
|