@pillar-ai/react 0.1.7 → 0.1.11
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/LICENSE +21 -0
- package/README.md +225 -91
- package/dist/PillarPanel.d.ts +1 -2
- package/dist/PillarProvider.d.ts +30 -11
- package/dist/Tooltip.d.ts +39 -0
- package/dist/hooks/usePillarTool.d.ts +73 -0
- package/dist/index.d.ts +6 -6
- package/dist/index.esm.js +150 -8
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +150 -6
- package/dist/index.js.map +1 -1
- package/package.json +11 -8
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Pillar, Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,101 +1,181 @@
|
|
|
1
1
|
# @pillar-ai/react
|
|
2
2
|
|
|
3
|
-
React
|
|
3
|
+
React SDK for the [Pillar](https://trypillar.com) open-source AI copilot — embed a product assistant in your React or Next.js app that executes tasks, not just answers questions. [GitHub](https://github.com/pillarhq/pillar) · [Docs](https://trypillar.com/docs)
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@pillar-ai/react)
|
|
6
|
+
[](https://www.npmjs.com/package/@pillar-ai/react)
|
|
7
|
+
[](https://opensource.org/licenses/MIT)
|
|
8
|
+
[](https://www.typescriptlang.org/)
|
|
9
|
+
|
|
10
|
+
## What is Pillar?
|
|
11
|
+
|
|
12
|
+
Pillar is a product copilot for SaaS and web applications. 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
|
+
For example, a user could ask:
|
|
15
|
+
|
|
16
|
+
> "Close the Walmart deal as won in Salesforce and notify implementation"
|
|
17
|
+
|
|
18
|
+
> "Add a weekly signups chart to my Amplitude dashboard"
|
|
19
|
+
|
|
20
|
+
> "Create a P1 bug in Linear for the checkout crash and add it to this sprint"
|
|
21
|
+
|
|
22
|
+
Pillar understands the intent, builds a multi-step plan, and executes it client-side with the user's session.
|
|
23
|
+
|
|
24
|
+
## Features
|
|
25
|
+
|
|
26
|
+
- **Task Execution** — Navigate pages, pre-fill forms, call APIs on behalf of users
|
|
27
|
+
- **React Hooks** — `usePillar` and `useHelpPanel` for idiomatic React integration
|
|
28
|
+
- **Next.js Support** — Works with App Router and Pages Router
|
|
29
|
+
- **Multi-Step Plans** — Chain actions into workflows for complex tasks
|
|
30
|
+
- **Type-Safe Actions** — Full TypeScript support for action definitions
|
|
31
|
+
- **Custom Action Cards** — Render React components for confirmations and data input
|
|
32
|
+
|
|
33
|
+
## Documentation
|
|
34
|
+
|
|
35
|
+
**[View Full Documentation](https://trypillar.com/docs)** | [React Guide](https://trypillar.com/docs/react/installation) | [API Reference](https://trypillar.com/docs/reference/react)
|
|
4
36
|
|
|
5
37
|
## Installation
|
|
6
38
|
|
|
7
39
|
```bash
|
|
8
40
|
npm install @pillar-ai/react
|
|
41
|
+
# or
|
|
42
|
+
pnpm add @pillar-ai/react
|
|
43
|
+
# or
|
|
44
|
+
yarn add @pillar-ai/react
|
|
9
45
|
```
|
|
10
46
|
|
|
11
47
|
## Quick Start
|
|
12
48
|
|
|
13
|
-
|
|
49
|
+
### 1. Get Your Product Key
|
|
50
|
+
|
|
51
|
+
> **⚠️ Beta Onboarding:** Cloud access is currently manual while we learn from early teams. Join the waitlist at [trypillar.com](https://trypillar.com), and we will reach out to onboard you.
|
|
52
|
+
>
|
|
53
|
+
> By default, you'll get an engineer from Pillar to help with setup. If you prefer onboarding without engineering support, include that in your waitlist request and we will support that too.
|
|
54
|
+
|
|
55
|
+
### 2. Add the Provider
|
|
56
|
+
|
|
57
|
+
Wrap your app with `PillarProvider` and define actions:
|
|
14
58
|
|
|
15
59
|
```tsx
|
|
16
60
|
import { PillarProvider } from '@pillar-ai/react';
|
|
17
61
|
|
|
62
|
+
const actions = {
|
|
63
|
+
export_to_csv: {
|
|
64
|
+
type: 'trigger' as const,
|
|
65
|
+
label: 'Export to CSV',
|
|
66
|
+
description: 'Export current data to CSV file',
|
|
67
|
+
},
|
|
68
|
+
go_to_settings: {
|
|
69
|
+
type: 'navigate' as const,
|
|
70
|
+
label: 'Open Settings',
|
|
71
|
+
description: 'Navigate to settings page',
|
|
72
|
+
path: '/settings',
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
|
|
18
76
|
function App() {
|
|
19
77
|
return (
|
|
20
|
-
<PillarProvider
|
|
78
|
+
<PillarProvider
|
|
79
|
+
productKey="your-product-key"
|
|
80
|
+
actions={actions}
|
|
81
|
+
onTask={(actionName, data) => {
|
|
82
|
+
if (actionName === 'export_to_csv') {
|
|
83
|
+
downloadCSV();
|
|
84
|
+
}
|
|
85
|
+
}}
|
|
86
|
+
>
|
|
21
87
|
<MyApp />
|
|
22
88
|
</PillarProvider>
|
|
23
89
|
);
|
|
24
90
|
}
|
|
25
91
|
```
|
|
26
92
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
### PillarProvider
|
|
93
|
+
### Next.js App Router
|
|
30
94
|
|
|
31
|
-
|
|
95
|
+
For Next.js App Router, create a client wrapper component:
|
|
32
96
|
|
|
33
97
|
```tsx
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
publicKey="pk_live_xxx"
|
|
37
|
-
config={{
|
|
38
|
-
panel: { position: 'right', mode: 'push' },
|
|
39
|
-
edgeTrigger: { enabled: true },
|
|
40
|
-
theme: { mode: 'auto' },
|
|
41
|
-
}}
|
|
42
|
-
>
|
|
43
|
-
{children}
|
|
44
|
-
</PillarProvider>
|
|
45
|
-
```
|
|
98
|
+
// providers/PillarClientProvider.tsx
|
|
99
|
+
'use client';
|
|
46
100
|
|
|
47
|
-
|
|
101
|
+
import { PillarProvider } from '@pillar-ai/react';
|
|
102
|
+
import { useRouter } from 'next/navigation';
|
|
48
103
|
|
|
49
|
-
|
|
104
|
+
const actions = {
|
|
105
|
+
go_to_settings: {
|
|
106
|
+
type: 'navigate' as const,
|
|
107
|
+
label: 'Open Settings',
|
|
108
|
+
description: 'Navigate to settings page',
|
|
109
|
+
},
|
|
110
|
+
};
|
|
50
111
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
helpCenter="your-help-center"
|
|
54
|
-
publicKey="pk_live_xxx"
|
|
55
|
-
config={{ edgeTrigger: { enabled: false } }}
|
|
56
|
-
>
|
|
57
|
-
<MyApp />
|
|
58
|
-
</PillarProvider>
|
|
112
|
+
export function PillarClientProvider({ children }: { children: React.ReactNode }) {
|
|
113
|
+
const router = useRouter();
|
|
59
114
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
115
|
+
return (
|
|
116
|
+
<PillarProvider
|
|
117
|
+
productKey="your-product-key"
|
|
118
|
+
actions={actions}
|
|
119
|
+
onTask={(actionName, data) => {
|
|
120
|
+
if (actionName === 'go_to_settings') {
|
|
121
|
+
router.push('/settings');
|
|
122
|
+
}
|
|
123
|
+
}}
|
|
124
|
+
>
|
|
125
|
+
{children}
|
|
126
|
+
</PillarProvider>
|
|
127
|
+
);
|
|
63
128
|
}
|
|
64
129
|
```
|
|
65
130
|
|
|
66
|
-
### Tooltip
|
|
67
|
-
|
|
68
|
-
Attach contextual tooltips to any element:
|
|
69
|
-
|
|
70
131
|
```tsx
|
|
71
|
-
|
|
132
|
+
// app/layout.tsx
|
|
133
|
+
import { PillarClientProvider } from '@/providers/PillarClientProvider';
|
|
72
134
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
135
|
+
export default function RootLayout({ children }) {
|
|
136
|
+
return (
|
|
137
|
+
<html>
|
|
138
|
+
<body>
|
|
139
|
+
<PillarClientProvider>{children}</PillarClientProvider>
|
|
140
|
+
</body>
|
|
141
|
+
</html>
|
|
142
|
+
);
|
|
143
|
+
}
|
|
76
144
|
```
|
|
77
145
|
|
|
78
|
-
|
|
146
|
+
## Defining Actions
|
|
79
147
|
|
|
80
|
-
|
|
148
|
+
Actions define what your co-pilot can do. When users make requests, Pillar matches intent to actions:
|
|
81
149
|
|
|
82
150
|
```tsx
|
|
83
|
-
import {
|
|
151
|
+
import type { ActionDefinitions } from '@pillar-ai/react';
|
|
84
152
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}
|
|
153
|
+
const actions = {
|
|
154
|
+
// Navigation actions
|
|
155
|
+
go_to_billing: {
|
|
156
|
+
type: 'navigate' as const,
|
|
157
|
+
label: 'Open Billing',
|
|
158
|
+
description: 'Navigate to billing and subscription settings',
|
|
159
|
+
},
|
|
160
|
+
|
|
161
|
+
// Trigger actions that execute code
|
|
162
|
+
export_report: {
|
|
163
|
+
type: 'trigger' as const,
|
|
164
|
+
label: 'Export Report',
|
|
165
|
+
description: 'Export the current report to PDF or CSV',
|
|
166
|
+
},
|
|
167
|
+
|
|
168
|
+
// Actions with data schemas (AI extracts parameters)
|
|
169
|
+
invite_team_member: {
|
|
170
|
+
type: 'trigger' as const,
|
|
171
|
+
label: 'Invite Team Member',
|
|
172
|
+
description: 'Send an invitation to join the team',
|
|
173
|
+
dataSchema: {
|
|
174
|
+
email: { type: 'string' as const, required: true },
|
|
175
|
+
role: { type: 'string' as const, enum: ['admin', 'member', 'viewer'] },
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
} satisfies ActionDefinitions;
|
|
99
179
|
```
|
|
100
180
|
|
|
101
181
|
## Hooks
|
|
@@ -112,70 +192,124 @@ function MyComponent() {
|
|
|
112
192
|
|
|
113
193
|
if (!isReady) return <div>Loading...</div>;
|
|
114
194
|
|
|
115
|
-
return <div>
|
|
195
|
+
return <div>Co-pilot is {isOpen ? 'open' : 'closed'}</div>;
|
|
116
196
|
}
|
|
117
197
|
```
|
|
118
198
|
|
|
119
199
|
### useHelpPanel
|
|
120
200
|
|
|
121
|
-
Control the
|
|
201
|
+
Control the co-pilot panel:
|
|
122
202
|
|
|
123
203
|
```tsx
|
|
124
204
|
import { useHelpPanel } from '@pillar-ai/react';
|
|
125
205
|
|
|
126
|
-
function
|
|
206
|
+
function CopilotButton() {
|
|
127
207
|
const { open, close, toggle, isOpen } = useHelpPanel();
|
|
128
208
|
|
|
129
209
|
return (
|
|
130
|
-
<button onClick={toggle}>
|
|
210
|
+
<button onClick={toggle}>
|
|
211
|
+
{isOpen ? 'Close Co-pilot' : 'Open Co-pilot'}
|
|
212
|
+
</button>
|
|
131
213
|
);
|
|
132
214
|
}
|
|
133
215
|
```
|
|
134
216
|
|
|
135
|
-
##
|
|
217
|
+
## Components
|
|
218
|
+
|
|
219
|
+
### PillarProvider
|
|
136
220
|
|
|
137
|
-
|
|
221
|
+
The root provider that initializes the SDK:
|
|
138
222
|
|
|
139
223
|
```tsx
|
|
140
|
-
|
|
141
|
-
|
|
224
|
+
<PillarProvider
|
|
225
|
+
productKey="your-product-key"
|
|
226
|
+
actions={actions}
|
|
227
|
+
onTask={(actionName, data) => { /* handle actions */ }}
|
|
228
|
+
config={{
|
|
229
|
+
panel: { position: 'right', mode: 'push' },
|
|
230
|
+
edgeTrigger: { enabled: true },
|
|
231
|
+
theme: { mode: 'auto' },
|
|
232
|
+
}}
|
|
233
|
+
>
|
|
234
|
+
{children}
|
|
235
|
+
</PillarProvider>
|
|
236
|
+
```
|
|
142
237
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
},
|
|
150
|
-
showNotification: {
|
|
151
|
-
type: 'trigger' as const,
|
|
152
|
-
label: 'Show Notification',
|
|
153
|
-
description: 'Display a notification',
|
|
154
|
-
dataSchema: {
|
|
155
|
-
message: { type: 'string' as const, required: true },
|
|
156
|
-
},
|
|
157
|
-
},
|
|
158
|
-
} satisfies ActionDefinitions;
|
|
238
|
+
### PillarPanel
|
|
239
|
+
|
|
240
|
+
For custom panel placement:
|
|
241
|
+
|
|
242
|
+
```tsx
|
|
243
|
+
import { PillarProvider, PillarPanel } from '@pillar-ai/react';
|
|
159
244
|
|
|
160
245
|
function App() {
|
|
161
246
|
return (
|
|
162
247
|
<PillarProvider
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
actions={actions}
|
|
166
|
-
onTask={(type, data) => {
|
|
167
|
-
// TypeScript knows the exact shape of data based on type
|
|
168
|
-
if (type === 'showNotification') {
|
|
169
|
-
console.log(data.message); // Typed!
|
|
170
|
-
}
|
|
171
|
-
}}
|
|
248
|
+
productKey="your-product-key"
|
|
249
|
+
config={{ panel: { container: 'manual' } }}
|
|
172
250
|
>
|
|
173
|
-
<
|
|
251
|
+
<div className="layout">
|
|
252
|
+
<main>Your content</main>
|
|
253
|
+
<PillarPanel className="sidebar-panel" />
|
|
254
|
+
</div>
|
|
174
255
|
</PillarProvider>
|
|
175
256
|
);
|
|
176
257
|
}
|
|
177
258
|
```
|
|
178
259
|
|
|
260
|
+
### Tooltip
|
|
261
|
+
|
|
262
|
+
Attach contextual tooltips to elements:
|
|
263
|
+
|
|
264
|
+
```tsx
|
|
265
|
+
import { Tooltip } from '@pillar-ai/react';
|
|
266
|
+
|
|
267
|
+
<Tooltip tooltipId="export-help">
|
|
268
|
+
<button>Export Data</button>
|
|
269
|
+
</Tooltip>
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
## Custom Action Cards
|
|
273
|
+
|
|
274
|
+
Render custom UI for inline actions:
|
|
275
|
+
|
|
276
|
+
```tsx
|
|
277
|
+
import { PillarProvider } from '@pillar-ai/react';
|
|
278
|
+
import type { CardComponentProps } from '@pillar-ai/react';
|
|
279
|
+
|
|
280
|
+
function InviteCard({ data, onConfirm, onCancel }: CardComponentProps<{ email: string; role: string }>) {
|
|
281
|
+
return (
|
|
282
|
+
<div className="card">
|
|
283
|
+
<p>Invite {data.email} as {data.role}?</p>
|
|
284
|
+
<button onClick={() => onConfirm()}>Send Invite</button>
|
|
285
|
+
<button onClick={onCancel}>Cancel</button>
|
|
286
|
+
</div>
|
|
287
|
+
);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
<PillarProvider
|
|
291
|
+
productKey="your-product-key"
|
|
292
|
+
cards={{
|
|
293
|
+
invite_team_member: InviteCard,
|
|
294
|
+
}}
|
|
295
|
+
>
|
|
296
|
+
{children}
|
|
297
|
+
</PillarProvider>
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
## Related Packages
|
|
301
|
+
|
|
302
|
+
| Package | Description |
|
|
303
|
+
|---------|-------------|
|
|
304
|
+
| [@pillar-ai/sdk](https://github.com/pillarhq/sdk) | Core vanilla JavaScript SDK |
|
|
305
|
+
| [@pillar-ai/vue](https://github.com/pillarhq/sdk-vue) | Vue 3 bindings |
|
|
306
|
+
| [@pillar-ai/svelte](https://github.com/pillarhq/sdk-svelte) | Svelte bindings |
|
|
307
|
+
|
|
308
|
+
## Requirements
|
|
309
|
+
|
|
310
|
+
- React 17.0.0 or higher
|
|
311
|
+
- React DOM 17.0.0 or higher
|
|
312
|
+
|
|
179
313
|
## License
|
|
180
314
|
|
|
181
315
|
MIT
|
package/dist/PillarPanel.d.ts
CHANGED
|
@@ -20,8 +20,7 @@ export interface PillarPanelProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
20
20
|
* @example
|
|
21
21
|
* ```tsx
|
|
22
22
|
* <PillarProvider
|
|
23
|
-
*
|
|
24
|
-
* publicKey="pk_xxx"
|
|
23
|
+
* productKey="my-product-key"
|
|
25
24
|
* config={{ panel: { container: 'manual' } }}
|
|
26
25
|
* >
|
|
27
26
|
* <div className="my-layout">
|
package/dist/PillarProvider.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* PillarProvider
|
|
3
3
|
* Context provider that initializes and manages the Pillar SDK
|
|
4
4
|
*/
|
|
5
|
-
import { Pillar, type PillarConfig, type PillarEvents, type PillarState, type TaskExecutePayload, type ThemeConfig } from "@pillar-ai/sdk";
|
|
5
|
+
import { Pillar, type CompactScanResult, type PillarConfig, type PillarEvents, type PillarState, type ScanOptions, type TaskExecutePayload, type ThemeConfig } from "@pillar-ai/sdk";
|
|
6
6
|
import React, { type ComponentType, type ReactNode } from "react";
|
|
7
7
|
/**
|
|
8
8
|
* Props passed to custom card components.
|
|
@@ -53,14 +53,25 @@ export interface PillarContextValue {
|
|
|
53
53
|
setTheme: (theme: Partial<ThemeConfig>) => void;
|
|
54
54
|
/** Enable or disable the text selection "Ask AI" popover */
|
|
55
55
|
setTextSelectionEnabled: (enabled: boolean) => void;
|
|
56
|
+
/** Enable or disable DOM scanning */
|
|
57
|
+
setDOMScanningEnabled: (enabled: boolean) => void;
|
|
58
|
+
/** Whether DOM scanning is enabled */
|
|
59
|
+
isDOMScanningEnabled: boolean;
|
|
60
|
+
/** Manually scan the page and get the compact result */
|
|
61
|
+
scanPage: (options?: ScanOptions) => CompactScanResult | null;
|
|
56
62
|
/** Subscribe to SDK events */
|
|
57
63
|
on: <K extends keyof PillarEvents>(event: K, callback: (data: PillarEvents[K]) => void) => () => void;
|
|
58
64
|
}
|
|
59
65
|
export interface PillarProviderProps {
|
|
60
|
-
/**
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
66
|
+
/**
|
|
67
|
+
* Your product key from the Pillar app.
|
|
68
|
+
* Get it at app.trypillar.com
|
|
69
|
+
*/
|
|
70
|
+
productKey?: string;
|
|
71
|
+
/**
|
|
72
|
+
* @deprecated Use `productKey` instead. Will be removed in v1.0.
|
|
73
|
+
*/
|
|
74
|
+
helpCenter?: string;
|
|
64
75
|
/**
|
|
65
76
|
* Additional SDK configuration
|
|
66
77
|
*
|
|
@@ -68,7 +79,7 @@ export interface PillarProviderProps {
|
|
|
68
79
|
* - `panel.useShadowDOM`: Whether to isolate styles in Shadow DOM (default: false).
|
|
69
80
|
* Set to false to let custom cards inherit your app's CSS (Tailwind, etc.)
|
|
70
81
|
*/
|
|
71
|
-
config?: Omit<PillarConfig, "
|
|
82
|
+
config?: Omit<PillarConfig, "productKey" | "helpCenter">;
|
|
72
83
|
/**
|
|
73
84
|
* Handler called when a task action is triggered from the chat.
|
|
74
85
|
* Use this to handle AI-suggested actions like opening modals, navigating, etc.
|
|
@@ -76,8 +87,7 @@ export interface PillarProviderProps {
|
|
|
76
87
|
* @example
|
|
77
88
|
* ```tsx
|
|
78
89
|
* <PillarProvider
|
|
79
|
-
*
|
|
80
|
-
* publicKey="pk_..."
|
|
90
|
+
* productKey="my-product-key"
|
|
81
91
|
* onTask={(task) => {
|
|
82
92
|
* switch (task.name) {
|
|
83
93
|
* case 'invite_team_member':
|
|
@@ -101,8 +111,7 @@ export interface PillarProviderProps {
|
|
|
101
111
|
* import { InviteMembersCard } from './cards/InviteMembersCard';
|
|
102
112
|
*
|
|
103
113
|
* <PillarProvider
|
|
104
|
-
*
|
|
105
|
-
* publicKey="pk_..."
|
|
114
|
+
* productKey="my-product-key"
|
|
106
115
|
* cards={{
|
|
107
116
|
* invite_members: InviteMembersCard,
|
|
108
117
|
* confirm_delete: ConfirmDeleteCard,
|
|
@@ -111,8 +120,18 @@ export interface PillarProviderProps {
|
|
|
111
120
|
* ```
|
|
112
121
|
*/
|
|
113
122
|
cards?: Record<string, CardComponent>;
|
|
123
|
+
/**
|
|
124
|
+
* Enable DOM scanning to send page context with messages.
|
|
125
|
+
* When enabled, interactable elements and text content are captured and sent to the LLM.
|
|
126
|
+
* @default false
|
|
127
|
+
*/
|
|
128
|
+
domScanning?: boolean;
|
|
129
|
+
/**
|
|
130
|
+
* Enable DOM scanning dev mode to preview the scanned page before sending.
|
|
131
|
+
* Shows a modal with the AST tree visualization before each message is sent.
|
|
132
|
+
* Useful for debugging what context will be sent to the LLM.
|
|
114
133
|
/** Children components */
|
|
115
134
|
children: ReactNode;
|
|
116
135
|
}
|
|
117
|
-
export declare function PillarProvider({
|
|
136
|
+
export declare function PillarProvider({ productKey, helpCenter, config, onTask, cards, domScanning, children, }: PillarProviderProps): React.ReactElement;
|
|
118
137
|
export declare function usePillarContext(): PillarContextValue;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tooltip Component
|
|
3
|
+
* Wrapper component that adds tooltip functionality to children
|
|
4
|
+
*/
|
|
5
|
+
import React, { type ReactNode, type CSSProperties } from 'react';
|
|
6
|
+
export interface TooltipProps {
|
|
7
|
+
/** Unique tooltip ID that matches a tooltip in your Pillar dashboard */
|
|
8
|
+
tooltipId: string;
|
|
9
|
+
/** Trigger behavior: hover, click, focus, or icon (shows info icon) */
|
|
10
|
+
trigger?: 'hover' | 'click' | 'focus' | 'icon';
|
|
11
|
+
/** Tooltip position relative to the target */
|
|
12
|
+
position?: 'top' | 'bottom' | 'left' | 'right' | 'auto';
|
|
13
|
+
/** Children elements to attach the tooltip to */
|
|
14
|
+
children: ReactNode;
|
|
15
|
+
/** Additional class name for the wrapper */
|
|
16
|
+
className?: string;
|
|
17
|
+
/** Additional inline styles for the wrapper */
|
|
18
|
+
style?: CSSProperties;
|
|
19
|
+
/** Whether the wrapper should be a span (inline) or div (block) */
|
|
20
|
+
inline?: boolean;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Tooltip wrapper component that adds Pillar tooltip functionality to children
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```tsx
|
|
27
|
+
* <Tooltip tooltipId="feature-explanation" trigger="hover">
|
|
28
|
+
* <button>Learn More</button>
|
|
29
|
+
* </Tooltip>
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```tsx
|
|
34
|
+
* <Tooltip tooltipId="input-help" trigger="icon">
|
|
35
|
+
* <label>Email Address</label>
|
|
36
|
+
* </Tooltip>
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export declare function Tooltip({ tooltipId, trigger, position, children, className, style, inline, }: TooltipProps): React.ReactElement;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* usePillarTool Hook
|
|
3
|
+
*
|
|
4
|
+
* Register one or more tools with co-located metadata and handlers.
|
|
5
|
+
* Tools are registered on mount and unregistered on unmount.
|
|
6
|
+
*
|
|
7
|
+
* @example Single tool
|
|
8
|
+
* ```tsx
|
|
9
|
+
* import { usePillarTool } from '@pillar-ai/react';
|
|
10
|
+
*
|
|
11
|
+
* function CartButton() {
|
|
12
|
+
* usePillarTool({
|
|
13
|
+
* name: 'add_to_cart',
|
|
14
|
+
* description: 'Add a product to the shopping cart',
|
|
15
|
+
* inputSchema: {
|
|
16
|
+
* type: 'object',
|
|
17
|
+
* properties: {
|
|
18
|
+
* productId: { type: 'string', description: 'Product ID' },
|
|
19
|
+
* quantity: { type: 'number', description: 'Quantity to add' },
|
|
20
|
+
* },
|
|
21
|
+
* required: ['productId', 'quantity'],
|
|
22
|
+
* },
|
|
23
|
+
* execute: async ({ productId, quantity }) => {
|
|
24
|
+
* await cartApi.add(productId, quantity);
|
|
25
|
+
* return { content: [{ type: 'text', text: 'Added to cart' }] };
|
|
26
|
+
* },
|
|
27
|
+
* });
|
|
28
|
+
*
|
|
29
|
+
* return <button>Cart</button>;
|
|
30
|
+
* }
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* @example Multiple tools
|
|
34
|
+
* ```tsx
|
|
35
|
+
* import { usePillarTool } from '@pillar-ai/react';
|
|
36
|
+
*
|
|
37
|
+
* function BillingPage() {
|
|
38
|
+
* usePillarTool([
|
|
39
|
+
* {
|
|
40
|
+
* name: 'get_current_plan',
|
|
41
|
+
* description: 'Get the current billing plan',
|
|
42
|
+
* execute: async () => ({ plan: 'pro', price: 29 }),
|
|
43
|
+
* },
|
|
44
|
+
* {
|
|
45
|
+
* name: 'upgrade_plan',
|
|
46
|
+
* description: 'Upgrade to a higher plan',
|
|
47
|
+
* inputSchema: {
|
|
48
|
+
* type: 'object',
|
|
49
|
+
* properties: { planId: { type: 'string' } },
|
|
50
|
+
* required: ['planId'],
|
|
51
|
+
* },
|
|
52
|
+
* execute: async ({ planId }) => {
|
|
53
|
+
* await billingApi.upgrade(planId);
|
|
54
|
+
* return { content: [{ type: 'text', text: 'Upgraded!' }] };
|
|
55
|
+
* },
|
|
56
|
+
* },
|
|
57
|
+
* ]);
|
|
58
|
+
*
|
|
59
|
+
* return <div>Billing Content</div>;
|
|
60
|
+
* }
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
import type { ToolSchema } from '@pillar-ai/sdk';
|
|
64
|
+
/**
|
|
65
|
+
* Register a single Pillar tool with co-located metadata and handler.
|
|
66
|
+
*/
|
|
67
|
+
export declare function usePillarTool<TInput = Record<string, unknown>>(schema: ToolSchema<TInput>): void;
|
|
68
|
+
/**
|
|
69
|
+
* Register multiple Pillar tools with co-located metadata and handlers.
|
|
70
|
+
*/
|
|
71
|
+
export declare function usePillarTool(schemas: ToolSchema[]): void;
|
|
72
|
+
/** @deprecated Use usePillarTool instead */
|
|
73
|
+
export declare const usePillarAction: typeof usePillarTool;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @pillar-ai/react - React bindings for Pillar
|
|
2
|
+
* @pillar-ai/react - React bindings for Pillar SDK
|
|
3
3
|
*
|
|
4
4
|
* @example
|
|
5
5
|
* ```tsx
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*
|
|
8
8
|
* function App() {
|
|
9
9
|
* return (
|
|
10
|
-
* <PillarProvider
|
|
10
|
+
* <PillarProvider productKey="your-product-key">
|
|
11
11
|
* <MyApp />
|
|
12
12
|
* </PillarProvider>
|
|
13
13
|
* );
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
* return (
|
|
21
21
|
* <div>
|
|
22
22
|
* <h1>Welcome!</h1>
|
|
23
|
-
* <button onClick={toggle}>
|
|
23
|
+
* <button onClick={toggle}>Open Co-pilot</button>
|
|
24
24
|
* </div>
|
|
25
25
|
* );
|
|
26
26
|
* }
|
|
@@ -29,8 +29,7 @@
|
|
|
29
29
|
* function AppWithCustomPanel() {
|
|
30
30
|
* return (
|
|
31
31
|
* <PillarProvider
|
|
32
|
-
*
|
|
33
|
-
* publicKey="pk_live_xxx"
|
|
32
|
+
* productKey="your-product-key"
|
|
34
33
|
* config={{ panel: { container: 'manual' } }}
|
|
35
34
|
* >
|
|
36
35
|
* <div className="layout">
|
|
@@ -46,4 +45,5 @@ export { PillarProvider, usePillarContext, type PillarContextValue, type PillarP
|
|
|
46
45
|
export { PillarPanel, type PillarPanelProps } from './PillarPanel';
|
|
47
46
|
export { useHelpPanel, type UseHelpPanelResult } from './hooks/useHelpPanel';
|
|
48
47
|
export { usePillar, type UsePillarResult, type TypedUsePillarResult } from './hooks/usePillar';
|
|
49
|
-
export
|
|
48
|
+
export { usePillarTool, usePillarAction } from './hooks/usePillarTool';
|
|
49
|
+
export type { EdgeTriggerConfig, MobileTriggerConfig, MobileTriggerPosition, MobileTriggerIcon, MobileTriggerSize, PanelConfig, PillarConfig, PillarEvents, PillarState, ResolvedConfig, ResolvedMobileTriggerConfig, ResolvedThemeConfig, TaskExecutePayload, TextSelectionConfig, ThemeColors, ThemeConfig, ThemeMode, CardCallbacks, CardRenderer, SidebarTabConfig, ToolDefinitions, SyncToolDefinitions, ToolDataType, ToolNames, ToolExecuteResult, ToolSchema, ToolType, ActionDefinitions, SyncActionDefinitions, ActionDataType, ActionNames, ActionResult, ActionSchema, ActionType, ChatContext, DOMScanningConfig, ResolvedDOMScanningConfig, ScanOptions, CompactScanResult, InteractionType, scanPageDirect, } from '@pillar-ai/sdk';
|