@pillar-ai/sdk 0.1.7 → 0.1.13
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 +117 -67
- package/dist/actions/index.d.ts +1 -1
- package/dist/actions/registry.d.ts +15 -27
- package/dist/actions/types.d.ts +28 -11
- package/dist/api/client.d.ts +15 -4
- package/dist/api/mcp-client.d.ts +13 -1
- package/dist/cli/sync.d.ts +0 -1
- package/dist/cli/sync.js +317 -0
- package/dist/components/Button/EdgeTrigger.d.ts +1 -0
- package/dist/components/Button/MobileTrigger.d.ts +56 -0
- package/dist/components/Button/index.d.ts +1 -0
- package/dist/components/Panel/Panel.d.ts +1 -0
- package/dist/components/Panel/styles.d.ts +1 -1
- package/dist/components/Plan/InlinePlanView.d.ts +1 -1
- package/dist/components/Plan/PlanStepItem.d.ts +7 -2
- package/dist/components/Progress/ProgressRow.d.ts +12 -0
- package/dist/components/Progress/index.d.ts +1 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/core/Pillar.d.ts +79 -33
- package/dist/core/config.d.ts +89 -17
- package/dist/core/context.d.ts +22 -7
- package/dist/core/events.d.ts +2 -2
- package/dist/core/plan-executor.d.ts +18 -0
- package/dist/core/plan.d.ts +33 -2
- package/dist/index.d.ts +7 -9
- package/dist/pillar.esm.js +1 -1
- package/dist/store/chat.d.ts +23 -2
- package/dist/store/context.d.ts +7 -13
- package/dist/store/panel.d.ts +14 -0
- package/package.json +6 -4
- package/src/actions/types.ts +29 -14
- package/src/cli/sync.ts +0 -477
package/README.md
CHANGED
|
@@ -1,114 +1,164 @@
|
|
|
1
1
|
# @pillar-ai/sdk
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Cursor for your product — Embed an AI co-pilot that executes tasks, not just answers questions.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@pillar-ai/sdk)
|
|
6
|
+
[](https://www.npmjs.com/package/@pillar-ai/sdk)
|
|
7
|
+
[](https://opensource.org/licenses/MIT)
|
|
8
|
+
[](https://www.typescriptlang.org/)
|
|
9
|
+
|
|
10
|
+
## What is Pillar?
|
|
11
|
+
|
|
12
|
+
Pillar is an embedded AI co-pilot that helps users complete tasks, not just answer questions. Users say what they want, and Pillar uses your UI to make it happen — navigating pages, pre-filling forms, and calling your APIs.
|
|
13
|
+
|
|
14
|
+
**How it works:**
|
|
15
|
+
|
|
16
|
+
1. User asks: *"Export this to CSV"* or *"Turn off email notifications"*
|
|
17
|
+
2. Pillar understands intent and chains actions
|
|
18
|
+
3. Your code executes with the user's session
|
|
19
|
+
|
|
20
|
+
## Features
|
|
21
|
+
|
|
22
|
+
- **Task Execution** — Navigate pages, pre-fill forms, call APIs on behalf of users
|
|
23
|
+
- **Multi-Step Plans** — Chain actions into workflows for complex tasks
|
|
24
|
+
- **Context-Aware** — Knows current page, user state, and selected text
|
|
25
|
+
- **Knowledge Sync** — Trained on your docs, Zendesk, Intercom, and more
|
|
26
|
+
- **Custom Action Cards** — Render interactive UI for confirmations and data input
|
|
27
|
+
- **Framework Bindings** — First-class support for React, Vue, and Svelte
|
|
28
|
+
|
|
29
|
+
## Why Pillar?
|
|
30
|
+
|
|
31
|
+
- **Runs client-side** with the user's session — no proxy servers, no token forwarding
|
|
32
|
+
- **One npm install**, define your actions, and you're live
|
|
33
|
+
- **Syncs with your docs** for grounded, accurate answers
|
|
34
|
+
|
|
35
|
+
## Documentation
|
|
36
|
+
|
|
37
|
+
**[View Full Documentation](https://trypillar.com/docs)** | [Getting Started](https://trypillar.com/docs/getting-started/quick-start) | [API Reference](https://trypillar.com/docs/reference/core)
|
|
4
38
|
|
|
5
39
|
## Installation
|
|
6
40
|
|
|
7
41
|
```bash
|
|
8
42
|
npm install @pillar-ai/sdk
|
|
43
|
+
# or
|
|
44
|
+
pnpm add @pillar-ai/sdk
|
|
45
|
+
# or
|
|
46
|
+
yarn add @pillar-ai/sdk
|
|
9
47
|
```
|
|
10
48
|
|
|
11
49
|
## Quick Start
|
|
12
50
|
|
|
51
|
+
### 1. Get Your Product Key
|
|
52
|
+
|
|
53
|
+
First, register your product in the [Pillar app](https://app.trypillar.com):
|
|
54
|
+
|
|
55
|
+
1. Sign up or log in at [app.trypillar.com](https://app.trypillar.com)
|
|
56
|
+
2. Create a new product
|
|
57
|
+
3. Copy your **Product Key** from the settings page
|
|
58
|
+
|
|
59
|
+
### 2. Initialize the SDK
|
|
60
|
+
|
|
13
61
|
```javascript
|
|
14
62
|
import { Pillar } from "@pillar-ai/sdk";
|
|
15
63
|
|
|
16
64
|
await Pillar.init({
|
|
17
|
-
|
|
18
|
-
publicKey: "pk_live_xxx",
|
|
65
|
+
productKey: "your-product-key", // From Pillar app
|
|
19
66
|
});
|
|
20
67
|
```
|
|
21
68
|
|
|
22
|
-
##
|
|
69
|
+
## Defining Actions
|
|
70
|
+
|
|
71
|
+
Define what your co-pilot can do. When users make requests, Pillar matches intent to actions and executes them:
|
|
23
72
|
|
|
24
73
|
```javascript
|
|
25
74
|
Pillar.init({
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
position: "right", // 'left' | 'right'
|
|
35
|
-
mode: "push", // 'overlay' | 'push'
|
|
75
|
+
productKey: "your-product-key",
|
|
76
|
+
actions: {
|
|
77
|
+
// Navigation actions
|
|
78
|
+
go_to_settings: {
|
|
79
|
+
type: "navigate",
|
|
80
|
+
label: "Open Settings",
|
|
81
|
+
description: "Navigate to the settings page",
|
|
82
|
+
path: "/settings",
|
|
36
83
|
},
|
|
37
84
|
|
|
38
|
-
//
|
|
39
|
-
|
|
40
|
-
|
|
85
|
+
// Trigger actions that execute code
|
|
86
|
+
export_to_csv: {
|
|
87
|
+
type: "trigger",
|
|
88
|
+
label: "Export to CSV",
|
|
89
|
+
description: "Export current data to a CSV file",
|
|
41
90
|
},
|
|
42
91
|
|
|
43
|
-
//
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
92
|
+
// Actions with data schemas
|
|
93
|
+
update_preferences: {
|
|
94
|
+
type: "trigger",
|
|
95
|
+
label: "Update Preferences",
|
|
96
|
+
description: "Update notification preferences",
|
|
97
|
+
dataSchema: {
|
|
98
|
+
emailAlerts: { type: "boolean" },
|
|
99
|
+
frequency: { type: "string", enum: ["daily", "weekly", "monthly"] },
|
|
48
100
|
},
|
|
49
101
|
},
|
|
50
102
|
},
|
|
103
|
+
|
|
104
|
+
onTask: (actionName, data) => {
|
|
105
|
+
// Your code executes here
|
|
106
|
+
if (actionName === "export_to_csv") {
|
|
107
|
+
downloadCSV();
|
|
108
|
+
}
|
|
109
|
+
if (actionName === "update_preferences") {
|
|
110
|
+
updateUserPreferences(data.emailAlerts, data.frequency);
|
|
111
|
+
}
|
|
112
|
+
},
|
|
51
113
|
});
|
|
52
114
|
```
|
|
53
115
|
|
|
54
|
-
##
|
|
55
|
-
|
|
56
|
-
To use your own button instead of the built-in edge trigger:
|
|
116
|
+
## Configuration
|
|
57
117
|
|
|
58
118
|
```javascript
|
|
59
119
|
Pillar.init({
|
|
60
|
-
|
|
61
|
-
publicKey: "pk_live_xxx",
|
|
62
|
-
edgeTrigger: { enabled: false },
|
|
63
|
-
});
|
|
120
|
+
productKey: "your-product-key",
|
|
64
121
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
```
|
|
122
|
+
panel: {
|
|
123
|
+
position: "right", // 'left' | 'right'
|
|
124
|
+
mode: "push", // 'overlay' | 'push'
|
|
125
|
+
},
|
|
70
126
|
|
|
71
|
-
|
|
127
|
+
edgeTrigger: {
|
|
128
|
+
enabled: true, // Set to false to use your own button
|
|
129
|
+
},
|
|
72
130
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
131
|
+
theme: {
|
|
132
|
+
mode: "auto", // 'light' | 'dark' | 'auto'
|
|
133
|
+
colors: {
|
|
134
|
+
primary: "#6366f1",
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
});
|
|
138
|
+
```
|
|
78
139
|
|
|
79
140
|
## API Reference
|
|
80
141
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
Initialize the SDK with your configuration
|
|
142
|
+
| Method | Description |
|
|
143
|
+
|--------|-------------|
|
|
144
|
+
| `Pillar.init(config)` | Initialize the SDK with your configuration |
|
|
145
|
+
| `Pillar.open()` | Open the co-pilot panel |
|
|
146
|
+
| `Pillar.close()` | Close the co-pilot panel |
|
|
147
|
+
| `Pillar.toggle()` | Toggle the co-pilot panel |
|
|
148
|
+
| `Pillar.setContext(context)` | Update the user/product context |
|
|
149
|
+
| `Pillar.on(event, callback)` | Subscribe to SDK events |
|
|
84
150
|
|
|
85
|
-
|
|
151
|
+
For complete API documentation, see the [API Reference](https://trypillar.com/docs/reference/core).
|
|
86
152
|
|
|
87
|
-
|
|
153
|
+
## Framework Integrations
|
|
88
154
|
|
|
89
|
-
|
|
155
|
+
For idiomatic integration with your framework, use our framework-specific packages:
|
|
90
156
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
### Pillar.setContext(context)
|
|
98
|
-
|
|
99
|
-
Update the user/product context.
|
|
100
|
-
|
|
101
|
-
### Pillar.on(event, callback)
|
|
102
|
-
|
|
103
|
-
Subscribe to SDK events.
|
|
104
|
-
|
|
105
|
-
## React Integration
|
|
106
|
-
|
|
107
|
-
For React applications, use the `@pillar-ai/react` package for a more idiomatic integration with hooks and components.
|
|
108
|
-
|
|
109
|
-
```bash
|
|
110
|
-
npm install @pillar-ai/react
|
|
111
|
-
```
|
|
157
|
+
| Framework | Package | Installation |
|
|
158
|
+
|-----------|---------|--------------|
|
|
159
|
+
| React | [@pillar-ai/react](https://github.com/pillarhq/sdk-react) | `npm install @pillar-ai/react` |
|
|
160
|
+
| Vue | [@pillar-ai/vue](https://github.com/pillarhq/sdk-vue) | `npm install @pillar-ai/vue` |
|
|
161
|
+
| Svelte | [@pillar-ai/svelte](https://github.com/pillarhq/sdk-svelte) | `npm install @pillar-ai/svelte` |
|
|
112
162
|
|
|
113
163
|
## License
|
|
114
164
|
|
package/dist/actions/index.d.ts
CHANGED
|
@@ -30,4 +30,4 @@
|
|
|
30
30
|
* @module actions
|
|
31
31
|
*/
|
|
32
32
|
export type { ActionType, ActionDataSchema, ActionDefinition, ActionDefinitions, ActionManifest, ActionManifestEntry, ClientInfo, Platform, SyncActionDefinition, SyncActionDefinitions, ActionTypeDataMap, NavigateActionData, TriggerActionData, InlineUIData, ExternalLinkData, CopyTextData, ActionDataType, ActionNames, TypedTaskHandler, TypedOnTask, TypedPillarMethods, } from './types';
|
|
33
|
-
export {
|
|
33
|
+
export { setClientInfo, getClientInfo, getHandler, getActionDefinition, hasAction, getActionNames, getManifest, clearRegistry, getActionCount, } from './registry';
|
|
@@ -2,45 +2,33 @@
|
|
|
2
2
|
* Action Registry - Manages code-defined action handlers.
|
|
3
3
|
*
|
|
4
4
|
* This module provides the registration and lookup mechanism for
|
|
5
|
-
* actions defined in code. Actions are registered
|
|
6
|
-
* and can be looked up by name using `getHandler()`.
|
|
5
|
+
* actions defined in code. Actions are registered at runtime via
|
|
6
|
+
* `pillar.onTask()` and can be looked up by name using `getHandler()`.
|
|
7
7
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*/
|
|
11
|
-
import type { ActionDefinition, ActionDefinitions, ActionManifest, ClientInfo, Platform } from './types';
|
|
12
|
-
/**
|
|
13
|
-
* Define and register actions with the SDK.
|
|
14
|
-
*
|
|
15
|
-
* Call this during app initialization to register your action handlers.
|
|
16
|
-
* The metadata will be synced to the server during CI/CD builds.
|
|
8
|
+
* Action metadata is synced to the server during CI/CD builds using
|
|
9
|
+
* the `pillar-sync` CLI with a barrel file export pattern:
|
|
17
10
|
*
|
|
18
11
|
* @example
|
|
19
12
|
* ```ts
|
|
20
|
-
*
|
|
21
|
-
* import {
|
|
13
|
+
* // lib/pillar/actions/index.ts
|
|
14
|
+
* import type { SyncActionDefinitions } from '@pillar-ai/sdk';
|
|
22
15
|
*
|
|
23
|
-
* export const actions =
|
|
16
|
+
* export const actions = {
|
|
24
17
|
* open_settings: {
|
|
25
18
|
* description: 'Navigate to the settings page',
|
|
26
|
-
* type: 'navigate',
|
|
19
|
+
* type: 'navigate' as const,
|
|
27
20
|
* path: '/settings',
|
|
28
|
-
* handler: () => router.push('/settings'),
|
|
29
|
-
* },
|
|
30
|
-
* open_billing: {
|
|
31
|
-
* description: 'Navigate to billing and subscription management',
|
|
32
|
-
* type: 'navigate',
|
|
33
|
-
* path: '/settings/billing',
|
|
34
21
|
* autoRun: true,
|
|
35
|
-
* handler: (data) => router.push('/settings/billing', data),
|
|
36
22
|
* },
|
|
37
|
-
* }
|
|
38
|
-
*
|
|
23
|
+
* } as const satisfies SyncActionDefinitions;
|
|
24
|
+
*
|
|
25
|
+
* export default actions;
|
|
39
26
|
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
27
|
+
* // Sync via CI/CD:
|
|
28
|
+
* // npx pillar-sync --actions ./lib/pillar/actions/index.ts
|
|
29
|
+
* ```
|
|
42
30
|
*/
|
|
43
|
-
|
|
31
|
+
import type { ActionDefinition, ActionManifest, ClientInfo, Platform } from './types';
|
|
44
32
|
/**
|
|
45
33
|
* Set client platform and version info.
|
|
46
34
|
*
|
package/dist/actions/types.d.ts
CHANGED
|
@@ -6,16 +6,22 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @example
|
|
8
8
|
* ```ts
|
|
9
|
-
*
|
|
9
|
+
* // lib/pillar/actions/index.ts
|
|
10
|
+
* import type { SyncActionDefinitions } from '@pillar-ai/sdk';
|
|
10
11
|
*
|
|
11
|
-
* const actions =
|
|
12
|
+
* export const actions = {
|
|
12
13
|
* open_settings: {
|
|
13
14
|
* description: 'Navigate to the settings page',
|
|
14
|
-
* type: 'navigate',
|
|
15
|
+
* type: 'navigate' as const,
|
|
15
16
|
* path: '/settings',
|
|
16
|
-
*
|
|
17
|
+
* autoRun: true,
|
|
17
18
|
* },
|
|
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'));
|
|
19
25
|
* ```
|
|
20
26
|
*/
|
|
21
27
|
/**
|
|
@@ -35,6 +41,22 @@ export type ActionType = 'navigate' | 'open_modal' | 'fill_form' | 'trigger_acti
|
|
|
35
41
|
* Supported platforms for action deployments.
|
|
36
42
|
*/
|
|
37
43
|
export type Platform = 'web' | 'ios' | 'android' | 'desktop';
|
|
44
|
+
/**
|
|
45
|
+
* Schema property definition for a single field.
|
|
46
|
+
* Supports nested objects and arrays with items.
|
|
47
|
+
*/
|
|
48
|
+
export interface ActionDataSchemaProperty {
|
|
49
|
+
type: 'string' | 'number' | 'boolean' | 'array' | 'object';
|
|
50
|
+
description?: string;
|
|
51
|
+
enum?: string[];
|
|
52
|
+
default?: unknown;
|
|
53
|
+
/** Items schema for array types */
|
|
54
|
+
items?: ActionDataSchemaProperty;
|
|
55
|
+
/** Nested properties for object types */
|
|
56
|
+
properties?: Record<string, ActionDataSchemaProperty>;
|
|
57
|
+
/** Required fields for nested object types */
|
|
58
|
+
required?: string[];
|
|
59
|
+
}
|
|
38
60
|
/**
|
|
39
61
|
* JSON Schema definition for action data.
|
|
40
62
|
*
|
|
@@ -43,12 +65,7 @@ export type Platform = 'web' | 'ios' | 'android' | 'desktop';
|
|
|
43
65
|
*/
|
|
44
66
|
export interface ActionDataSchema {
|
|
45
67
|
type: 'object';
|
|
46
|
-
properties: Record<string,
|
|
47
|
-
type: 'string' | 'number' | 'boolean' | 'array' | 'object';
|
|
48
|
-
description?: string;
|
|
49
|
-
enum?: string[];
|
|
50
|
-
default?: unknown;
|
|
51
|
-
}>;
|
|
68
|
+
properties: Record<string, ActionDataSchemaProperty>;
|
|
52
69
|
required?: string[];
|
|
53
70
|
}
|
|
54
71
|
/**
|
package/dist/api/client.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import type { TaskButtonData } from '../components/Panel/TaskButton';
|
|
6
6
|
import type { ResolvedConfig } from '../core/config';
|
|
7
|
-
import type {
|
|
7
|
+
import type { Context, Suggestion, UserProfile } from '../core/context';
|
|
8
8
|
import type { ExecutionPlan } from '../core/plan';
|
|
9
9
|
import type { Workflow } from '../core/workflow';
|
|
10
10
|
import type { UserContextItem } from '../types/user-context';
|
|
@@ -33,9 +33,20 @@ export interface ChatResponse {
|
|
|
33
33
|
actions?: TaskButtonData[];
|
|
34
34
|
}
|
|
35
35
|
export interface ProgressEvent {
|
|
36
|
-
kind: 'search' | 'search_complete' | '
|
|
36
|
+
kind: 'processing' | 'search' | 'search_complete' | 'query' | 'query_complete' | 'query_failed' | 'generating';
|
|
37
37
|
message?: string;
|
|
38
38
|
progress_id?: string;
|
|
39
|
+
metadata?: {
|
|
40
|
+
sources?: Array<{
|
|
41
|
+
title: string;
|
|
42
|
+
url: string;
|
|
43
|
+
score?: number;
|
|
44
|
+
}>;
|
|
45
|
+
result_count?: number;
|
|
46
|
+
query?: string;
|
|
47
|
+
action_name?: string;
|
|
48
|
+
no_sources_used?: boolean;
|
|
49
|
+
};
|
|
39
50
|
}
|
|
40
51
|
/**
|
|
41
52
|
* Server-side embed config response.
|
|
@@ -135,13 +146,13 @@ export declare class APIClient {
|
|
|
135
146
|
* Get contextual help suggestions based on product context.
|
|
136
147
|
* Returns relevant articles, videos, and actions.
|
|
137
148
|
*/
|
|
138
|
-
getSuggestions(
|
|
149
|
+
getSuggestions(ctx: Context, userProfile: UserProfile): Promise<Suggestion[]>;
|
|
139
150
|
/**
|
|
140
151
|
* Chat with enhanced context.
|
|
141
152
|
* Includes product context and user profile for better responses.
|
|
142
153
|
*
|
|
143
154
|
* Note: Context is passed to the MCP ask tool as additional arguments.
|
|
144
155
|
*/
|
|
145
|
-
chatWithContext(message: string, history: ChatMessage[] | undefined,
|
|
156
|
+
chatWithContext(message: string, history: ChatMessage[] | undefined, ctx: Context, userProfile: UserProfile, onChunk?: (chunk: string) => void, existingConversationId?: string | null, onActions?: (actions: TaskButtonData[]) => void): Promise<ChatResponse>;
|
|
146
157
|
cancelAllRequests(): void;
|
|
147
158
|
}
|
package/dist/api/mcp-client.d.ts
CHANGED
|
@@ -59,10 +59,22 @@ export interface StreamCallbacks {
|
|
|
59
59
|
onError?: (error: string) => void;
|
|
60
60
|
/** Called when stream is complete */
|
|
61
61
|
onComplete?: (conversationId?: string, queryLogId?: string) => void;
|
|
62
|
-
/** Called for progress updates */
|
|
62
|
+
/** Called for progress updates (search, query, generating, etc.) */
|
|
63
63
|
onProgress?: (progress: {
|
|
64
64
|
kind: string;
|
|
65
65
|
message?: string;
|
|
66
|
+
progress_id?: string;
|
|
67
|
+
metadata?: {
|
|
68
|
+
sources?: Array<{
|
|
69
|
+
title: string;
|
|
70
|
+
url: string;
|
|
71
|
+
score?: number;
|
|
72
|
+
}>;
|
|
73
|
+
result_count?: number;
|
|
74
|
+
query?: string;
|
|
75
|
+
action_name?: string;
|
|
76
|
+
no_sources_used?: boolean;
|
|
77
|
+
};
|
|
66
78
|
}) => void;
|
|
67
79
|
}
|
|
68
80
|
/** Image for chat requests (from upload-image endpoint) */
|
package/dist/cli/sync.d.ts
CHANGED