@pillar-ai/sdk 0.1.19 → 0.1.21
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/dist/actions/index.d.ts +1 -1
- package/dist/actions/types.d.ts +89 -0
- package/dist/cli/sync.js +230 -170
- package/dist/components/Progress/ErrorRow.d.ts +12 -0
- package/dist/components/Progress/index.d.ts +1 -0
- package/dist/core/Pillar.d.ts +38 -0
- package/dist/index.d.ts +1 -1
- package/dist/pillar.esm.js +1 -1
- package/dist/store/chat.d.ts +10 -0
- package/package.json +10 -2
- package/src/actions/types.ts +98 -0
package/dist/store/chat.d.ts
CHANGED
|
@@ -50,6 +50,16 @@ export declare const isLoading: import("@preact/signals-core").Signal<boolean>;
|
|
|
50
50
|
export declare const activeRequestId: import("@preact/signals-core").Signal<number | null>;
|
|
51
51
|
export declare const setActiveRequestId: (id: number | null) => void;
|
|
52
52
|
export declare const isLoadingHistory: import("@preact/signals-core").Signal<boolean>;
|
|
53
|
+
export interface ChatError {
|
|
54
|
+
message: string;
|
|
55
|
+
/** The user message that triggered the error (for retry) */
|
|
56
|
+
retryMessage: string;
|
|
57
|
+
retryContext?: UserContextItem[];
|
|
58
|
+
retryImages?: ChatImage[];
|
|
59
|
+
}
|
|
60
|
+
export declare const chatError: import("@preact/signals-core").Signal<ChatError | null>;
|
|
61
|
+
export declare const setChatError: (error: ChatError) => void;
|
|
62
|
+
export declare const clearChatError: () => void;
|
|
53
63
|
export interface InterruptedSession {
|
|
54
64
|
conversationId: string;
|
|
55
65
|
userMessage: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pillar-ai/sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.21",
|
|
4
4
|
"description": "Product copilot SDK for SaaS and web apps — AI assistant that executes tasks, not just answers questions",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/pillar.esm.js",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
],
|
|
26
26
|
"scripts": {
|
|
27
27
|
"build": "rollup -c && npm run build:cli && npm run build:types",
|
|
28
|
-
"build:cli": "npx esbuild src/cli/sync.ts --bundle --platform=node --target=node18 --outfile=dist/cli/sync.js --format=esm --banner:js='#!/usr/bin/env node'",
|
|
28
|
+
"build:cli": "npx esbuild src/cli/sync.ts --bundle --platform=node --target=node18 --outfile=dist/cli/sync.js --format=esm --external:typescript --banner:js='#!/usr/bin/env node'",
|
|
29
29
|
"build:types": "tsc --emitDeclarationOnly --outDir dist",
|
|
30
30
|
"dev": "rollup -c -w",
|
|
31
31
|
"clean": "rm -rf dist",
|
|
@@ -56,6 +56,14 @@
|
|
|
56
56
|
"publishConfig": {
|
|
57
57
|
"access": "public"
|
|
58
58
|
},
|
|
59
|
+
"peerDependencies": {
|
|
60
|
+
"typescript": ">=4.7.0"
|
|
61
|
+
},
|
|
62
|
+
"peerDependenciesMeta": {
|
|
63
|
+
"typescript": {
|
|
64
|
+
"optional": true
|
|
65
|
+
}
|
|
66
|
+
},
|
|
59
67
|
"dependencies": {
|
|
60
68
|
"@preact/signals": "^1.3.1",
|
|
61
69
|
"marked": "^17.0.1",
|
package/src/actions/types.ts
CHANGED
|
@@ -522,3 +522,101 @@ export interface TypedPillarMethods<
|
|
|
522
522
|
> {
|
|
523
523
|
onTask: TypedOnTask<TActions>;
|
|
524
524
|
}
|
|
525
|
+
|
|
526
|
+
// ============================================================================
|
|
527
|
+
// Unified Action Schema (new API — co-locates metadata + handler)
|
|
528
|
+
// ============================================================================
|
|
529
|
+
|
|
530
|
+
/**
|
|
531
|
+
* Result returned from an action's execute function.
|
|
532
|
+
*
|
|
533
|
+
* Follows the MCP tool result format. Plain objects are also accepted
|
|
534
|
+
* by the SDK and normalized to this shape automatically.
|
|
535
|
+
*/
|
|
536
|
+
export interface ActionResult {
|
|
537
|
+
content: Array<
|
|
538
|
+
| { type: 'text'; text: string }
|
|
539
|
+
| { type: 'image'; data: string; mimeType: string }
|
|
540
|
+
>;
|
|
541
|
+
isError?: boolean;
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
/**
|
|
545
|
+
* Unified action definition that co-locates metadata and handler.
|
|
546
|
+
*
|
|
547
|
+
* Use with `pillar.defineAction()` or the `usePillarAction()` React hook.
|
|
548
|
+
* The CLI scanner (`npx pillar-sync --scan ./src`) discovers these
|
|
549
|
+
* definitions automatically — no barrel file needed.
|
|
550
|
+
*
|
|
551
|
+
* @template TInput - Type of the input object passed to `execute`
|
|
552
|
+
*
|
|
553
|
+
* @example
|
|
554
|
+
* ```ts
|
|
555
|
+
* pillar.defineAction({
|
|
556
|
+
* name: 'add_to_cart',
|
|
557
|
+
* description: 'Add a product to the shopping cart',
|
|
558
|
+
* inputSchema: {
|
|
559
|
+
* type: 'object',
|
|
560
|
+
* properties: {
|
|
561
|
+
* productId: { type: 'string', description: 'Product ID' },
|
|
562
|
+
* quantity: { type: 'number', description: 'Quantity to add' },
|
|
563
|
+
* },
|
|
564
|
+
* required: ['productId', 'quantity'],
|
|
565
|
+
* },
|
|
566
|
+
* execute: async ({ productId, quantity }) => {
|
|
567
|
+
* await cartApi.add(productId, quantity);
|
|
568
|
+
* return { content: [{ type: 'text', text: 'Added to cart' }] };
|
|
569
|
+
* },
|
|
570
|
+
* });
|
|
571
|
+
* ```
|
|
572
|
+
*/
|
|
573
|
+
export interface ActionSchema<TInput = Record<string, unknown>> {
|
|
574
|
+
/** Unique action name (e.g., 'add_to_cart') */
|
|
575
|
+
name: string;
|
|
576
|
+
|
|
577
|
+
/** Human-readable description for AI matching */
|
|
578
|
+
description: string;
|
|
579
|
+
|
|
580
|
+
/**
|
|
581
|
+
* Type of action - determines how the SDK handles it and organizes it in the UI.
|
|
582
|
+
*/
|
|
583
|
+
type?: ActionType;
|
|
584
|
+
|
|
585
|
+
/**
|
|
586
|
+
* JSON Schema describing the input parameters.
|
|
587
|
+
* The AI extracts structured data from the conversation to populate these.
|
|
588
|
+
*/
|
|
589
|
+
inputSchema?: {
|
|
590
|
+
type: 'object';
|
|
591
|
+
properties: Record<string, unknown>;
|
|
592
|
+
required?: string[];
|
|
593
|
+
};
|
|
594
|
+
|
|
595
|
+
/**
|
|
596
|
+
* Example user queries that should trigger this action.
|
|
597
|
+
* Used for semantic matching alongside the description.
|
|
598
|
+
*/
|
|
599
|
+
examples?: string[];
|
|
600
|
+
|
|
601
|
+
/**
|
|
602
|
+
* Whether to auto-execute without user confirmation.
|
|
603
|
+
* @default false
|
|
604
|
+
*/
|
|
605
|
+
autoRun?: boolean;
|
|
606
|
+
|
|
607
|
+
/**
|
|
608
|
+
* Whether the action completes immediately after execution.
|
|
609
|
+
* @default true
|
|
610
|
+
*/
|
|
611
|
+
autoComplete?: boolean;
|
|
612
|
+
|
|
613
|
+
/**
|
|
614
|
+
* Handler function executed when the AI invokes this action.
|
|
615
|
+
*
|
|
616
|
+
* Can return:
|
|
617
|
+
* - An `ActionResult` with MCP-style content blocks
|
|
618
|
+
* - A plain object (SDK normalizes it for the agent)
|
|
619
|
+
* - `void` if the action has no return value
|
|
620
|
+
*/
|
|
621
|
+
execute: (input: TInput) => Promise<ActionResult | unknown | void> | ActionResult | unknown | void;
|
|
622
|
+
}
|