@pillar-ai/sdk 0.1.17 → 0.1.19

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.
@@ -43,11 +43,16 @@ export declare class EdgeTrigger {
43
43
  */
44
44
  private getEdgePosition;
45
45
  /**
46
- * Detect the current theme from the document
46
+ * Detect the current theme from the document (for auto mode)
47
47
  * Checks for .dark class (next-themes) or data-theme attribute
48
48
  * Returns explicit 'light' or 'dark' to match app theme (not system preference)
49
49
  */
50
- private detectTheme;
50
+ private detectThemeFromDOM;
51
+ /**
52
+ * Apply theme mode - respects explicit config, only auto-detects when mode is 'auto'
53
+ * Matches Panel behavior for consistency.
54
+ */
55
+ private applyThemeMode;
51
56
  /**
52
57
  * Initialize the edge trigger
53
58
  */
@@ -3,30 +3,35 @@
3
3
  * Manages the "Page being piloted by Agent" banner, rendering it outside Shadow DOM
4
4
  * so it appears above all other content on the page.
5
5
  */
6
+ import type { ThemeMode } from '../../core/config';
6
7
  export declare class PagePilotManager {
7
8
  private container;
8
9
  private stylesInjected;
9
10
  private unsubscribe;
10
11
  private themeObserver;
11
12
  private primaryColor;
13
+ private themeMode;
12
14
  /**
13
- * Detect the current theme from the document
15
+ * Detect the current theme from the document (for auto mode)
14
16
  * Checks for .dark class (next-themes) or data-theme attribute
15
17
  */
16
18
  private detectThemeFromDOM;
17
19
  /**
18
20
  * Apply theme mode to container element
21
+ * Respects explicit config, only auto-detects when mode is 'auto'
19
22
  */
20
- private applyTheme;
23
+ private applyThemeMode;
21
24
  /**
22
25
  * Set up observer to watch for theme changes on documentElement
26
+ * Only needed for auto mode
23
27
  */
24
28
  private setupThemeObserver;
25
29
  /**
26
30
  * Initialize the page pilot manager
27
31
  * @param primaryColor - Optional primary color from theme config to override the default
32
+ * @param themeMode - Theme mode from config ('light', 'dark', or 'auto')
28
33
  */
29
- init(primaryColor?: string): void;
34
+ init(primaryColor?: string, themeMode?: ThemeMode): void;
30
35
  /**
31
36
  * Update the primary color used by the banner
32
37
  */
@@ -15,9 +15,16 @@ export declare class Panel {
15
15
  private backdrop;
16
16
  private panelElement;
17
17
  private renderRoot;
18
+ private resizeHandle;
18
19
  private unsubscribe;
19
20
  private isManualMount;
20
21
  private themeObserver;
22
+ private _isResizing;
23
+ private _resizeStartX;
24
+ private _resizeStartWidth;
25
+ private _resizeRafId;
26
+ private _boundHandleResizeMove;
27
+ private _boundHandleResizeEnd;
21
28
  constructor(config: ResolvedConfig, api: APIClient, events: EventEmitter, rootContainer?: HTMLElement | null);
22
29
  /**
23
30
  * Detect the current theme from the document
@@ -53,6 +60,20 @@ export declare class Panel {
53
60
  * Destroy the panel
54
61
  */
55
62
  destroy(): void;
63
+ /** Internal safety clamp -- not user-configurable */
64
+ private static readonly MIN_PANEL_WIDTH;
65
+ /**
66
+ * Handle resize start from mouse or touch event on the drag handle
67
+ */
68
+ private handleResizeStart;
69
+ /**
70
+ * Handle resize move - throttled via requestAnimationFrame
71
+ */
72
+ private handleResizeMove;
73
+ /**
74
+ * Handle resize end - save final width and clean up
75
+ */
76
+ private handleResizeEnd;
56
77
  private subscribeToState;
57
78
  /**
58
79
  * Toggle backdrop visibility using inline styles.
@@ -2,8 +2,11 @@
2
2
  * Pillar SDK Configuration Types
3
3
  */
4
4
  import type { Platform } from '../actions/types';
5
+ /** Which side of the screen the panel appears on. */
5
6
  export type PanelPosition = 'left' | 'right';
7
+ /** How the panel interacts with page content: 'overlay' floats over it, 'push' shifts it aside. */
6
8
  export type PanelMode = 'overlay' | 'push';
9
+ /** Color mode for the panel theme. 'auto' follows the system preference. */
7
10
  export type ThemeMode = 'light' | 'dark' | 'auto';
8
11
  /**
9
12
  * Sidebar tab configuration
@@ -61,10 +64,25 @@ export interface ThemeConfig {
61
64
  fontFamily?: string;
62
65
  }
63
66
  export interface PanelConfig {
67
+ /**
68
+ * Whether the panel is enabled.
69
+ * @default true
70
+ */
64
71
  enabled?: boolean;
72
+ /**
73
+ * Which side of the screen the panel appears on.
74
+ * @default 'right'
75
+ */
65
76
  position?: PanelPosition;
66
- /** Panel mode: 'overlay' slides over content, 'push' shifts content aside */
77
+ /**
78
+ * Panel mode: 'overlay' slides over content, 'push' shifts content aside.
79
+ * @default 'push'
80
+ */
67
81
  mode?: PanelMode;
82
+ /**
83
+ * Panel width in pixels.
84
+ * @default 380
85
+ */
68
86
  width?: number;
69
87
  /**
70
88
  * Custom mount point for the panel.
@@ -108,6 +126,13 @@ export interface PanelConfig {
108
126
  * @default false
109
127
  */
110
128
  initialOpen?: boolean;
129
+ /**
130
+ * Whether the panel can be resized by dragging its edge.
131
+ * A drag handle appears on the content-facing edge of the panel when enabled.
132
+ * The resized width is persisted to localStorage.
133
+ * @default true
134
+ */
135
+ resizable?: boolean;
111
136
  }
112
137
  export interface UrlParamsConfig {
113
138
  /** Whether to check URL params for auto-opening the panel (default: true) */
@@ -233,8 +258,11 @@ export interface EdgeTriggerConfig {
233
258
  */
234
259
  resizable?: boolean;
235
260
  }
261
+ /** Position of the mobile floating trigger button. */
236
262
  export type MobileTriggerPosition = 'bottom-right' | 'bottom-left';
263
+ /** Preset icon for the mobile floating trigger button. */
237
264
  export type MobileTriggerIcon = 'sparkle' | 'question' | 'help' | 'chat' | 'support';
265
+ /** Size preset for the mobile floating trigger button. */
238
266
  export type MobileTriggerSize = 'small' | 'medium' | 'large';
239
267
  export interface MobileTriggerConfig {
240
268
  /**
@@ -318,15 +346,25 @@ export interface PillarConfig {
318
346
  * @default false
319
347
  */
320
348
  debug?: boolean;
349
+ /** Panel layout and behavior settings. */
321
350
  panel?: PanelConfig;
351
+ /** Edge trigger (sidebar tab that opens the panel). */
322
352
  edgeTrigger?: EdgeTriggerConfig;
353
+ /** Mobile trigger (floating button on small screens). */
323
354
  mobileTrigger?: MobileTriggerConfig;
355
+ /** URL params for auto-opening the panel. */
324
356
  urlParams?: UrlParamsConfig;
357
+ /** Text selection "Ask AI" popover. */
325
358
  textSelection?: TextSelectionConfig;
359
+ /** DOM scanning for page context. */
326
360
  domScanning?: DOMScanningConfig;
361
+ /** Page-aware suggestions. */
327
362
  suggestions?: SuggestionsConfig;
363
+ /** Sidebar tabs configuration. */
328
364
  sidebarTabs?: SidebarTabConfig[];
365
+ /** API base URL. Defaults to Pillar's production API. */
329
366
  apiBaseUrl?: string;
367
+ /** Theme customization. */
330
368
  theme?: ThemeConfig;
331
369
  /**
332
370
  * Custom CSS to inject into the panel's Shadow DOM.
@@ -338,7 +376,9 @@ export interface PillarConfig {
338
376
  * ```
339
377
  */
340
378
  customCSS?: string;
379
+ /** Called when the SDK is initialized and ready. */
341
380
  onReady?: () => void;
381
+ /** Called when the SDK encounters an error. */
342
382
  onError?: (error: Error) => void;
343
383
  }
344
384
  export interface ResolvedPanelConfig {
@@ -358,6 +398,8 @@ export interface ResolvedPanelConfig {
358
398
  fullWidthBreakpoint: number;
359
399
  /** Whether to open the panel automatically on initialization */
360
400
  initialOpen: boolean;
401
+ /** Whether the panel can be resized by dragging its edge */
402
+ resizable: boolean;
361
403
  }
362
404
  export interface ResolvedMobileTriggerConfig {
363
405
  enabled: boolean;
@@ -107,39 +107,53 @@ export interface RegisteredCard {
107
107
  */
108
108
  export type CardRenderer = (container: HTMLElement, data: Record<string, unknown>, callbacks: CardCallbacks) => (() => void) | void;
109
109
  export interface PillarEvents {
110
+ /** SDK is initialized and ready. */
110
111
  ready: void;
112
+ /** SDK encountered an error. */
111
113
  error: Error;
114
+ /** Panel was opened. */
112
115
  "panel:open": void;
116
+ /** Panel was closed. */
113
117
  "panel:close": void;
118
+ /** Panel navigated to a different view. */
114
119
  "panel:navigate": {
115
120
  view: string;
116
121
  params?: Record<string, string>;
117
122
  };
123
+ /** User viewed an article. */
118
124
  "article:view": {
119
125
  articleSlug: string;
120
126
  };
127
+ /** User performed a search. */
121
128
  "search:query": {
122
129
  query: string;
123
130
  };
131
+ /** User sent a chat message. */
124
132
  "chat:message": {
125
133
  message: string;
126
134
  };
135
+ /** Text selection popover was shown. */
127
136
  "textSelection:shown": {
128
137
  text: string;
129
138
  };
139
+ /** User clicked the text selection popover. */
130
140
  "textSelection:click": {
131
141
  text: string;
132
142
  };
143
+ /** Context was updated. */
133
144
  "context:change": {
134
145
  context: Context;
135
146
  };
147
+ /** User profile was updated. */
136
148
  "profile:change": {
137
149
  profile: UserProfile;
138
150
  };
151
+ /** User action was reported. */
139
152
  "action:report": {
140
153
  action: string;
141
154
  metadata?: Record<string, unknown>;
142
155
  };
156
+ /** User was identified. */
143
157
  "user:identified": {
144
158
  userId: string;
145
159
  profile?: {
@@ -148,45 +162,60 @@ export interface PillarEvents {
148
162
  metadata?: Record<string, unknown>;
149
163
  };
150
164
  };
165
+ /** User logged out. */
151
166
  "user:logout": Record<string, never>;
167
+ /** Query action returned a result to the agent. */
152
168
  "action:result": {
153
169
  actionName: string;
154
170
  result: unknown;
155
171
  toolCallId?: string;
156
172
  };
173
+ /** AI-suggested task is being executed. */
157
174
  "task:execute": TaskExecutePayload;
175
+ /** Task completed. */
158
176
  "task:complete": {
159
177
  id?: string;
160
178
  name: string;
161
179
  success: boolean;
162
180
  data?: Record<string, unknown>;
163
181
  };
182
+ /** Multi-step workflow started. */
164
183
  "workflow:start": Workflow;
184
+ /** Workflow step became active. */
165
185
  "workflow:step:active": {
166
186
  workflow: Workflow;
167
187
  step: WorkflowStep;
168
188
  };
189
+ /** Workflow step completed. */
169
190
  "workflow:step:complete": {
170
191
  workflow: Workflow;
171
192
  step: WorkflowStep;
172
193
  success: boolean;
173
194
  };
195
+ /** Workflow step was skipped. */
174
196
  "workflow:step:skip": {
175
197
  workflow: Workflow;
176
198
  step: WorkflowStep;
177
199
  };
200
+ /** Workflow completed all steps. */
178
201
  "workflow:complete": Workflow;
202
+ /** Workflow was cancelled. */
179
203
  "workflow:cancel": Workflow;
204
+ /** Theme was changed. */
180
205
  "theme:change": {
181
206
  theme: ResolvedThemeConfig;
182
207
  };
208
+ /** Text selection feature was toggled. */
183
209
  "textSelection:change": {
184
210
  enabled: boolean;
185
211
  };
212
+ /** DOM was scanned. */
186
213
  "dom:scanned": CompactScanResult;
214
+ /** DOM scanning feature was toggled. */
187
215
  "domScanning:change": {
188
216
  enabled: boolean;
189
217
  };
218
+ /** Page-aware suggestions were updated. */
190
219
  "suggestions:updated": {
191
220
  suggestions: Array<{
192
221
  id: string;
@@ -194,6 +223,7 @@ export interface PillarEvents {
194
223
  }>;
195
224
  route: string;
196
225
  };
226
+ /** Sidebar tab was clicked. Use to integrate external support systems. */
197
227
  "sidebar:click": {
198
228
  tabId: string;
199
229
  label: string;
package/dist/index.d.ts CHANGED
@@ -20,7 +20,7 @@
20
20
  */
21
21
  export { EventEmitter, type CardCallbacks, type CardRenderer, type PillarEvents, type TaskExecutePayload, } from "./core/events";
22
22
  export { Pillar, type ChatContext, type PillarState } from "./core/Pillar";
23
- export { DEFAULT_SIDEBAR_TABS, type DOMScanningConfig, type EdgeTriggerConfig, type InteractionHighlightConfig, type MobileTriggerConfig, type MobileTriggerIcon, type MobileTriggerPosition, type MobileTriggerSize, type PanelConfig, type PanelMode, type PanelPosition, type PillarConfig, type ResolvedConfig, type ResolvedDOMScanningConfig, type ResolvedInteractionHighlightConfig, type ResolvedMobileTriggerConfig, type ResolvedPanelConfig, type ResolvedThemeConfig, type SidebarTabConfig, type TextSelectionConfig, type ThemeColors, type ThemeConfig, type ThemeMode, type UrlParamsConfig, } from "./core/config";
23
+ export { DEFAULT_SIDEBAR_TABS, type DOMScanningConfig, type EdgeTriggerConfig, type InteractionHighlightConfig, type MobileTriggerConfig, type MobileTriggerIcon, type MobileTriggerPosition, type MobileTriggerSize, type PanelConfig, type PanelMode, type PanelPosition, type PillarConfig, type ResolvedConfig, type ResolvedDOMScanningConfig, type ResolvedInteractionHighlightConfig, type ResolvedMobileTriggerConfig, type ResolvedPanelConfig, type ResolvedSuggestionsConfig, type ResolvedThemeConfig, type SidebarTabConfig, type SuggestionsConfig, type TextSelectionConfig, type ThemeColors, type ThemeConfig, type ThemeMode, type UrlParamsConfig, } from "./core/config";
24
24
  export { type AssistantContext, type Context, type Suggestion, type UserProfile, } from "./core/context";
25
25
  export { clearRegistry, getActionCount, getActionDefinition, getActionNames, getClientInfo, getHandler, getManifest, hasAction, setClientInfo, type ActionDataSchema, type ActionDataType, type ActionDefinition, type ActionDefinitions, type ActionManifest, type ActionManifestEntry, type ActionNames, type ActionType, type ActionTypeDataMap, type ClientInfo, type CopyTextData, type ExternalLinkData, type InlineUIData, type NavigateActionData, type Platform, type SyncActionDefinition, type SyncActionDefinitions, type TriggerActionData, type TypedOnTask, type TypedPillarMethods, type TypedTaskHandler, } from "./actions";
26
26
  export { APIClient, type ArticleSummary, type ChatMessage, type ChatResponse, type ProgressEvent, } from "./api/client";