@pillar-ai/sdk 0.1.8 → 0.1.14

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.
Files changed (58) hide show
  1. package/README.md +118 -60
  2. package/dist/actions/index.d.ts +1 -1
  3. package/dist/actions/registry.d.ts +15 -27
  4. package/dist/actions/types.d.ts +20 -8
  5. package/dist/api/client.d.ts +91 -5
  6. package/dist/api/mcp-client.d.ts +105 -79
  7. package/dist/cli/sync.d.ts +0 -1
  8. package/dist/cli/sync.js +102 -14
  9. package/dist/components/DebugPanel/DebugPanel.d.ts +25 -0
  10. package/dist/components/DebugPanel/index.d.ts +2 -0
  11. package/dist/components/DevTools/index.d.ts +5 -0
  12. package/dist/components/DevTools/styles.d.ts +5 -0
  13. package/dist/components/Panel/Header.d.ts +1 -1
  14. package/dist/components/Panel/HistoryDropdown.d.ts +10 -0
  15. package/dist/components/Panel/Panel.d.ts +1 -0
  16. package/dist/components/Panel/TaskButton.d.ts +4 -14
  17. package/dist/components/Panel/styles.d.ts +1 -1
  18. package/dist/components/Plan/InlinePlanView.d.ts +1 -1
  19. package/dist/components/Plan/PlanDocument.d.ts +18 -0
  20. package/dist/components/Plan/PlanStepItem.d.ts +1 -1
  21. package/dist/components/Plan/PlanView.d.ts +1 -1
  22. package/dist/components/Plan/index.d.ts +1 -0
  23. package/dist/components/Progress/ProgressRow.d.ts +16 -0
  24. package/dist/components/Progress/ProgressStack.d.ts +15 -0
  25. package/dist/components/Progress/ReasoningDisclosure.d.ts +20 -0
  26. package/dist/components/Progress/index.d.ts +3 -0
  27. package/dist/components/Views/HomeView.d.ts +3 -0
  28. package/dist/components/Views/ResumePrompt.d.ts +22 -0
  29. package/dist/components/Views/index.d.ts +1 -0
  30. package/dist/components/index.d.ts +1 -0
  31. package/dist/components/shared/icons.d.ts +24 -0
  32. package/dist/components/shared/index.d.ts +1 -0
  33. package/dist/core/Pillar.d.ts +318 -80
  34. package/dist/core/config.d.ts +141 -3
  35. package/dist/core/events.d.ts +55 -70
  36. package/dist/core/plan-executor.d.ts +29 -0
  37. package/dist/core/plan.d.ts +6 -0
  38. package/dist/hooks/index.d.ts +5 -0
  39. package/dist/hooks/useDebouncedValue.d.ts +22 -0
  40. package/dist/hooks/useInlineCard.d.ts +35 -0
  41. package/dist/hooks/usePillarInstance.d.ts +30 -0
  42. package/dist/index.d.ts +14 -12
  43. package/dist/pillar.esm.js +1 -1
  44. package/dist/store/chat.d.ts +102 -4
  45. package/dist/store/index.d.ts +1 -0
  46. package/dist/store/session-persistence.d.ts +62 -0
  47. package/dist/store/suggestions.d.ts +58 -0
  48. package/dist/types/dom-scanner.d.ts +46 -0
  49. package/dist/types/index.d.ts +1 -0
  50. package/dist/types/user-context.d.ts +32 -1
  51. package/dist/utils/debug.d.ts +150 -0
  52. package/dist/utils/dom-scanner.d.ts +44 -0
  53. package/dist/utils/markdown-components.d.ts +53 -0
  54. package/dist/utils/preact-markdown.d.ts +17 -0
  55. package/dist/utils/route-observer.d.ts +67 -0
  56. package/package.json +1 -1
  57. package/src/actions/types.ts +21 -7
  58. package/dist/utils/markdown.d.ts +0 -9
@@ -2,12 +2,12 @@
2
2
  * Main Pillar SDK Class
3
3
  * Entry point for all SDK functionality
4
4
  */
5
- import { type PillarConfig, type ResolvedConfig, type ThemeConfig } from './config';
6
- import { type Context, type Suggestion, type UserProfile } from './context';
7
- import { type CardRenderer, type PillarEvents, type TaskExecutePayload } from './events';
8
- import type { ExecutionPlan } from './plan';
9
- import type { Workflow } from './workflow';
10
- export type PillarState = 'uninitialized' | 'initializing' | 'ready' | 'error';
5
+ import { APIClient } from "../api/client";
6
+ import { type PillarConfig, type ResolvedConfig, type ThemeConfig } from "./config";
7
+ import { type Context, type Suggestion, type UserProfile } from "./context";
8
+ import { type CardRenderer, type PillarEvents, type TaskExecutePayload } from "./events";
9
+ import type { Workflow } from "./workflow";
10
+ export type PillarState = "uninitialized" | "initializing" | "ready" | "error";
11
11
  /**
12
12
  * Chat context for escalation to human support.
13
13
  */
@@ -16,7 +16,7 @@ export interface ChatContext {
16
16
  conversationId: string | null;
17
17
  /** Messages in the conversation */
18
18
  messages: Array<{
19
- role: 'user' | 'assistant';
19
+ role: "user" | "assistant";
20
20
  content: string;
21
21
  }>;
22
22
  }
@@ -26,8 +26,6 @@ export declare class Pillar {
26
26
  private _config;
27
27
  private _events;
28
28
  private _api;
29
- private _mcpClient;
30
- private _planExecutor;
31
29
  private _textSelectionManager;
32
30
  private _panel;
33
31
  private _edgeTrigger;
@@ -37,9 +35,14 @@ export declare class Pillar {
37
35
  private _unsubscribeHoverMode;
38
36
  private _context;
39
37
  private _userProfile;
38
+ private _externalUserId;
40
39
  private _taskHandlers;
41
40
  private _anyTaskHandler;
41
+ _registeredActions: Map<string, Record<string, unknown>>;
42
42
  private _cardRenderers;
43
+ private _debugPanelContainer;
44
+ private _routeObserver;
45
+ private _suggestionPool;
43
46
  constructor();
44
47
  /**
45
48
  * Create or get the shared root container for all Pillar UI elements.
@@ -79,6 +82,24 @@ export declare class Pillar {
79
82
  * Get the resolved configuration
80
83
  */
81
84
  get config(): ResolvedConfig | null;
85
+ /**
86
+ * Whether debug mode is enabled
87
+ */
88
+ get isDebugEnabled(): boolean;
89
+ /**
90
+ * Get debug log entries (for debug panel).
91
+ * Returns empty array if debug mode is not enabled.
92
+ */
93
+ getDebugLog(): import('../utils/debug').DebugEntry[];
94
+ /**
95
+ * Subscribe to debug log updates (for debug panel).
96
+ * Returns unsubscribe function.
97
+ */
98
+ onDebugLog(callback: (entries: import('../utils/debug').DebugEntry[]) => void): () => void;
99
+ /**
100
+ * Clear debug log entries.
101
+ */
102
+ clearDebugLog(): void;
82
103
  /**
83
104
  * Subscribe to SDK events
84
105
  */
@@ -167,6 +188,115 @@ export declare class Pillar {
167
188
  * pillar.setTextSelectionEnabled(true);
168
189
  */
169
190
  setTextSelectionEnabled(enabled: boolean): void;
191
+ /**
192
+ * Enable or disable DOM scanning at runtime.
193
+ *
194
+ * @param enabled - Whether to enable DOM scanning
195
+ *
196
+ * @example
197
+ * // Enable DOM scanning
198
+ * pillar.setDOMScanningEnabled(true);
199
+ *
200
+ * // Disable DOM scanning
201
+ * pillar.setDOMScanningEnabled(false);
202
+ */
203
+ setDOMScanningEnabled(enabled: boolean): void;
204
+ /**
205
+ * Whether DOM scanning is currently enabled.
206
+ */
207
+ get isDOMScanningEnabled(): boolean;
208
+ /** Currently highlighted element (for cleanup) */
209
+ private _highlightedElement;
210
+ /** Timeout for auto-removing highlight */
211
+ private _highlightTimeout;
212
+ /** Timeout for fade-out transition completion */
213
+ private _fadeOutTimeout;
214
+ /** Original styles to restore after highlight */
215
+ private _originalStyles;
216
+ /**
217
+ * Highlight an element to show AI interaction.
218
+ * Scrolls into view if not visible and adds an outline highlight with fade transition.
219
+ *
220
+ * @param el - Element to highlight
221
+ */
222
+ private highlightElement;
223
+ /**
224
+ * Clear the current element highlight with optional fade-out.
225
+ * @param immediate - If true, skip fade-out transition
226
+ */
227
+ private clearHighlight;
228
+ /**
229
+ * Get a DOM element by its pillar selector.
230
+ *
231
+ * @param selector - CSS selector (typically from DOMNode.selector)
232
+ * @returns The matching element or null
233
+ */
234
+ getElement(selector: string): Element | null;
235
+ /**
236
+ * Click an element by its selector.
237
+ * Uses realistic mouse event simulation (mousedown → mouseup → click)
238
+ * for better compatibility with UI frameworks.
239
+ *
240
+ * @param selector - CSS selector for the element to click
241
+ * @returns true if the element was found and clicked, false otherwise
242
+ */
243
+ clickElement(selector: string): boolean;
244
+ /**
245
+ * Type text into an input element.
246
+ * Uses realistic input simulation that works with React controlled inputs.
247
+ *
248
+ * @param selector - CSS selector for the input element
249
+ * @param text - Text to type into the element
250
+ * @returns true if the element was found and text was entered, false otherwise
251
+ */
252
+ typeInElement(selector: string, text: string): boolean;
253
+ /**
254
+ * Select an option in a select element.
255
+ * Uses realistic event simulation for React compatibility.
256
+ *
257
+ * @param selector - CSS selector for the select element
258
+ * @param value - Value of the option to select
259
+ * @returns true if the element was found and option was selected, false otherwise
260
+ */
261
+ selectOption(selector: string, value: string): boolean;
262
+ /**
263
+ * Focus an element by its selector.
264
+ * Fires both focus and focusin events for compatibility.
265
+ *
266
+ * @param selector - CSS selector for the element to focus
267
+ * @returns true if the element was found and focused, false otherwise
268
+ */
269
+ focusElement(selector: string): boolean;
270
+ /**
271
+ * Toggle a checkbox or radio element.
272
+ * Uses click simulation for realistic behavior and React compatibility.
273
+ *
274
+ * @param selector - CSS selector for the checkbox/radio element
275
+ * @returns true if the element was found and toggled, false otherwise
276
+ */
277
+ toggleElement(selector: string): boolean;
278
+ /**
279
+ * Handle the interact_with_page action from the LLM.
280
+ * Routes to appropriate DOM interaction method based on operation.
281
+ *
282
+ * @param params - Interaction parameters from LLM
283
+ * @returns Result object with success status and optional error
284
+ *
285
+ * @example
286
+ * // Click a button
287
+ * pillar.handlePageInteraction({ operation: 'click', ref: 'pr-a1' });
288
+ *
289
+ * // Type in an input
290
+ * pillar.handlePageInteraction({ operation: 'type', ref: 'pr-b1', value: 'hello' });
291
+ */
292
+ handlePageInteraction(params: {
293
+ operation: 'click' | 'type' | 'select' | 'focus' | 'toggle';
294
+ ref: string;
295
+ value?: string;
296
+ }): {
297
+ success: boolean;
298
+ error?: string;
299
+ };
170
300
  /**
171
301
  * Mount the panel to a specific container element.
172
302
  * Used for manual mounting mode (e.g., from React component).
@@ -188,6 +318,70 @@ export declare class Pillar {
188
318
  * Set the user profile for personalization.
189
319
  */
190
320
  setUserProfile(profile: UserProfile): void;
321
+ /**
322
+ * Identify the current user after login.
323
+ *
324
+ * Call this when a user logs into your application to:
325
+ * - Link their anonymous conversation history to their account
326
+ * - Enable cross-device conversation history retrieval
327
+ * - Associate future conversations with their user ID
328
+ *
329
+ * @param userId - Your application's user ID for this user
330
+ * @param profile - Optional user profile data (name, email, metadata)
331
+ * @param options - Optional settings for the identify call
332
+ * @param options.preserveConversation - If true, keeps the current conversation (default: false)
333
+ *
334
+ * @example
335
+ * ```typescript
336
+ * // When user logs in
337
+ * await pillar.identify('user-123', {
338
+ * name: 'John Doe',
339
+ * email: 'john@example.com',
340
+ * });
341
+ *
342
+ * // Keep current conversation when identifying
343
+ * await pillar.identify('user-123', undefined, { preserveConversation: true });
344
+ * ```
345
+ */
346
+ identify(userId: string, profile?: {
347
+ name?: string;
348
+ email?: string;
349
+ metadata?: Record<string, unknown>;
350
+ }, options?: {
351
+ preserveConversation?: boolean;
352
+ }): Promise<void>;
353
+ /**
354
+ * Clear the user's identity (logout).
355
+ *
356
+ * Call this when a user logs out of your application.
357
+ * Future conversations will be tracked anonymously until identify() is called again.
358
+ *
359
+ * Note: This does not delete existing conversations - they remain associated
360
+ * with the user's account for future retrieval.
361
+ *
362
+ * @param options - Optional settings for the logout call
363
+ * @param options.preserveConversation - If true, keeps the current conversation (default: false)
364
+ *
365
+ * @example
366
+ * ```typescript
367
+ * // When user logs out
368
+ * pillar.logout();
369
+ *
370
+ * // Keep current conversation when logging out
371
+ * pillar.logout({ preserveConversation: true });
372
+ * ```
373
+ */
374
+ logout(options?: {
375
+ preserveConversation?: boolean;
376
+ }): void;
377
+ /**
378
+ * Get the current external user ID (if identified).
379
+ */
380
+ get externalUserId(): string | null;
381
+ /**
382
+ * Whether the current user is identified (logged in).
383
+ */
384
+ get isIdentified(): boolean;
191
385
  /**
192
386
  * Report a user action for context building.
193
387
  * Recent actions are tracked and sent with chat requests for better context.
@@ -232,6 +426,57 @@ export declare class Pillar {
232
426
  * });
233
427
  */
234
428
  onTask(taskName: string, handler: (data: Record<string, unknown>) => void): () => void;
429
+ /**
430
+ * Register an action definition at runtime.
431
+ *
432
+ * This is primarily for demos and development. In production, actions
433
+ * should be synced via the `pillar-sync` CLI during CI/CD.
434
+ *
435
+ * The action definition is stored locally and can be used by `onTask`
436
+ * handlers. For actions with `returnsData: true`, the handler's return
437
+ * value is sent back to the agent.
438
+ *
439
+ * @param action - Action definition with name and properties
440
+ *
441
+ * @example
442
+ * pillar.registerAction({
443
+ * name: 'list_datasets',
444
+ * description: 'List available datasets',
445
+ * type: 'query',
446
+ * returnsData: true,
447
+ * });
448
+ */
449
+ registerAction(action: {
450
+ name: string;
451
+ } & Record<string, unknown>): void;
452
+ /**
453
+ * Get a registered action definition by name.
454
+ *
455
+ * @param name - Action name
456
+ * @returns Action definition or undefined
457
+ */
458
+ getRegisteredAction(name: string): Record<string, unknown> | undefined;
459
+ /**
460
+ * Get handler for an action, checking all registration systems.
461
+ *
462
+ * Lookup order:
463
+ * 1. Code-first action registry (synced via pillar-sync CLI) - handler in definition
464
+ * 2. Task handlers (registered via onTask at runtime)
465
+ *
466
+ * This is the recommended pattern:
467
+ * - Action definitions synced to server via CLI (so AI knows what's possible)
468
+ * - Handlers registered at runtime via onTask (client-side execution)
469
+ *
470
+ * @param actionName - Action name to look up
471
+ * @returns Handler function or undefined if not found
472
+ *
473
+ * @example
474
+ * const handler = pillar.getHandler('list_datasources');
475
+ * if (handler) {
476
+ * const result = await handler({ limit: 10 });
477
+ * }
478
+ */
479
+ getHandler(actionName: string): ((data: Record<string, unknown>) => unknown) | undefined;
235
480
  /**
236
481
  * Register a catch-all handler for any task.
237
482
  * Useful for logging, analytics, or handling unknown tasks.
@@ -268,6 +513,22 @@ export declare class Pillar {
268
513
  * @param data - Optional result data
269
514
  */
270
515
  completeTask(taskName: string, success?: boolean, data?: Record<string, unknown>): void;
516
+ /**
517
+ * Signal that an action has completed.
518
+ *
519
+ * For simple actions, this emits the completion event.
520
+ * For wizard actions (modals, multi-step flows), call this when the user
521
+ * finishes the flow.
522
+ *
523
+ * @param actionName - The action identifier
524
+ * @param success - Whether the action completed successfully (default: true)
525
+ * @param data - Optional result data
526
+ *
527
+ * @example
528
+ * // In your wizard completion handler:
529
+ * pillar.completeAction('add_source', true, { sourceId: source.id });
530
+ */
531
+ completeAction(actionName: string, success?: boolean, data?: Record<string, unknown>): Promise<void>;
271
532
  /**
272
533
  * Confirm task execution result.
273
534
  * Call this after your task handler completes to report success/failure
@@ -293,7 +554,7 @@ export declare class Pillar {
293
554
  * }
294
555
  * });
295
556
  */
296
- confirmTaskExecution(taskId: string, status: 'success' | 'failure', details?: {
557
+ confirmTaskExecution(taskId: string, status: "success" | "failure", details?: {
297
558
  error?: string;
298
559
  duration_ms?: number;
299
560
  [key: string]: unknown;
@@ -380,104 +641,81 @@ export declare class Pillar {
380
641
  */
381
642
  private _executeWorkflowStep;
382
643
  /**
383
- * Get the active execution plan, if any.
384
- */
385
- get activePlan(): ExecutionPlan | null;
386
- /**
387
- * Handle a plan received from the AI streaming response.
388
- * Called when the ReAct agent creates a plan via the create_plan tool.
644
+ * Send action result back to the agent.
389
645
  *
390
- * @param plan - The execution plan from the server
391
- */
392
- handlePlanReceived(plan: ExecutionPlan): void;
393
- /**
394
- * Start a plan that was waiting for user confirmation.
395
- * For plans with auto_execute=false, the user must explicitly start execution.
396
- */
397
- startPlan(): Promise<void>;
398
- /**
399
- * Confirm a plan step requiring confirmation.
646
+ * Called automatically for actions with `returns: true` after their
647
+ * handler completes. The result is sent to the agent for further reasoning.
400
648
  *
401
- * @param stepId - UUID of the step to confirm
402
- * @param data - Optional modified data from user input
649
+ * @param actionName - The name of the action that was executed
650
+ * @param result - The result data to send back to the agent
651
+ * @param toolCallId - Unique ID for this specific tool invocation (for result correlation)
652
+ * @returns Promise that resolves when the result is delivered
653
+ * @internal
403
654
  */
404
- confirmPlanStep(stepId: string, data?: Record<string, unknown>): Promise<void>;
655
+ sendActionResult(actionName: string, result: unknown, toolCallId?: string): Promise<void>;
405
656
  /**
406
- * Confirm an inline_ui step with data from the inline card.
657
+ * Execute a query action and send the result back to the agent.
407
658
  *
408
- * This is called when the user interacts with an inline card (e.g., invite form)
409
- * within a plan step and clicks confirm.
659
+ * This is called when the agent sends a `query_request` event.
660
+ * Query actions are expected to return data that the agent can use
661
+ * for further reasoning.
410
662
  *
411
- * @param stepId - UUID of the step to confirm
412
- * @param data - Data from the inline card (e.g., email, form fields)
663
+ * @param actionName - The name of the action to execute
664
+ * @param args - Arguments for the action
665
+ * @param schema - Optional schema for parameter validation
413
666
  */
414
- confirmInlinePlanStep(stepId: string, data?: Record<string, unknown>): Promise<void>;
667
+ executeQueryAction(actionName: string, args?: Record<string, unknown>, schema?: {
668
+ properties?: Record<string, unknown>;
669
+ required?: string[];
670
+ }): Promise<void>;
415
671
  /**
416
- * Skip a plan step.
417
- *
418
- * @param stepId - UUID of the step to skip
672
+ * Validate query parameters against a schema.
673
+ * @returns Error message if validation fails, null if valid
419
674
  */
420
- skipPlanStep(stepId: string): Promise<void>;
675
+ private _validateQueryParams;
421
676
  /**
422
- * Retry a failed step in the active plan.
423
- *
424
- * @param stepId - UUID of the step to retry
677
+ * Internal initialization
425
678
  */
426
- retryPlanStep(stepId: string): Promise<void>;
679
+ private _init;
427
680
  /**
428
- * Cancel the active plan.
681
+ * Actual initialization logic
429
682
  */
430
- cancelPlan(): Promise<void>;
683
+ private _doInit;
431
684
  /**
432
- * Complete a plan step by action name.
433
- *
434
- * Use this when the host app completes a wizard or flow that was started
435
- * by a plan step. The plan will advance to the next step.
436
- *
437
- * @param actionName - The action name (e.g., 'add_new_source')
438
- * @param success - Whether the action completed successfully (default: true)
439
- * @param data - Optional result data
440
- *
441
- * @example
442
- * // In your source creation success handler:
443
- * pillar.completePlanStepByAction('add_new_source');
685
+ * Attempt to recover an interrupted session from localStorage.
686
+ * Checks if there's a saved session hint and validates with the server.
444
687
  */
445
- completePlanStepByAction(actionName: string, success?: boolean, data?: Record<string, unknown>): Promise<void>;
688
+ private _recoverSession;
446
689
  /**
447
- * Mark a plan step as done by step ID.
448
- *
449
- * Use this when the UI "Done" button is clicked for a wizard step.
450
- * The step must be in 'awaiting_result' status.
451
- *
452
- * @param stepId - UUID of the step to mark as done
690
+ * Handle URL parameters for auto-opening the panel
453
691
  */
454
- markPlanStepDone(stepId: string): Promise<void>;
692
+ private _handleUrlParams;
455
693
  /**
456
- * Send action result back to the agent.
457
- *
458
- * Called automatically for actions with `returns: true` after their
459
- * handler completes. The result is sent to the agent for further reasoning.
460
- *
461
- * @param actionName - The name of the action that was executed
462
- * @param result - The result data to send back to the agent
463
- * @internal
694
+ * Mount the debug panel to the document body.
464
695
  */
465
- sendActionResult(actionName: string, result: unknown): void;
696
+ private _mountDebugPanel;
466
697
  /**
467
- * Internal initialization
698
+ * Set up debug event capturing for all SDK events.
699
+ * Logs all events to the debug log store for display in the debug panel.
468
700
  */
469
- private _init;
701
+ private _setupDebugEventCapture;
470
702
  /**
471
- * Actual initialization logic
703
+ * Initialize page-aware suggestions.
704
+ * Fetches the suggestion pool from the backend and starts route observation.
472
705
  */
473
- private _doInit;
706
+ private _initSuggestions;
474
707
  /**
475
- * Handle URL parameters for auto-opening the panel
708
+ * Handle route change by re-sorting suggestions for the new page context.
476
709
  */
477
- private _handleUrlParams;
710
+ private _handleRouteChange;
478
711
  /**
479
712
  * Internal cleanup
480
713
  */
481
714
  private _destroy;
482
715
  }
716
+ /**
717
+ * Get the API client from the current Pillar instance.
718
+ * Returns null if SDK is not initialized.
719
+ */
720
+ export declare function getApiClient(): APIClient | null;
483
721
  export default Pillar;
@@ -110,6 +110,102 @@ export interface TextSelectionConfig {
110
110
  /** Label for the popover button (default: 'Ask AI') */
111
111
  label?: string;
112
112
  }
113
+ export interface InteractionHighlightConfig {
114
+ /**
115
+ * Whether to highlight elements when the AI interacts with them.
116
+ * @default true
117
+ */
118
+ enabled?: boolean;
119
+ /**
120
+ * Outline color for highlighted elements (CSS color value).
121
+ * @default '#3b82f6' (blue-500)
122
+ */
123
+ outlineColor?: string;
124
+ /**
125
+ * Outline width in pixels.
126
+ * @default 2
127
+ */
128
+ outlineWidth?: number;
129
+ /**
130
+ * Outline offset in pixels (space between element and outline).
131
+ * @default 2
132
+ */
133
+ outlineOffset?: number;
134
+ /**
135
+ * Duration in milliseconds to show the highlight.
136
+ * Set to 0 for no auto-removal (highlight stays until next interaction).
137
+ * @default 2000
138
+ */
139
+ duration?: number;
140
+ /**
141
+ * Whether to scroll the element into view if not visible.
142
+ * @default true
143
+ */
144
+ scrollIntoView?: boolean;
145
+ /**
146
+ * Scroll behavior when scrolling element into view.
147
+ * @default 'smooth'
148
+ */
149
+ scrollBehavior?: ScrollBehavior;
150
+ }
151
+ export interface DOMScanningConfig {
152
+ /**
153
+ * Whether DOM scanning is enabled.
154
+ * When enabled, page structure is captured and sent with messages.
155
+ * @default false
156
+ */
157
+ enabled?: boolean;
158
+ /**
159
+ * Whether to include text content in the scan.
160
+ * @default true
161
+ */
162
+ includeText?: boolean;
163
+ /**
164
+ * Maximum depth to traverse the DOM tree.
165
+ * @default 20
166
+ */
167
+ maxDepth?: number;
168
+ /**
169
+ * Whether to only include visible elements.
170
+ * @default true
171
+ */
172
+ visibleOnly?: boolean;
173
+ /**
174
+ * CSS selector for elements to exclude from scanning.
175
+ * @example '.sidebar, .footer, [data-no-scan]'
176
+ */
177
+ excludeSelector?: string;
178
+ /**
179
+ * Maximum text length before truncation.
180
+ * @default 500
181
+ */
182
+ maxTextLength?: number;
183
+ /**
184
+ * Configuration for highlighting elements during AI interactions.
185
+ */
186
+ interactionHighlight?: InteractionHighlightConfig;
187
+ }
188
+ export interface SuggestionsConfig {
189
+ /**
190
+ * Enable page-aware suggestion sorting.
191
+ * When enabled, suggestions are re-sorted based on the current page context
192
+ * whenever the user navigates to a new route.
193
+ * @default true
194
+ */
195
+ enabled?: boolean;
196
+ /**
197
+ * Debounce time for route change detection (ms).
198
+ * Prevents excessive sorting on rapid navigation.
199
+ * @default 100
200
+ */
201
+ debounceMs?: number;
202
+ /**
203
+ * Maximum number of suggestions to display.
204
+ * The backend returns a larger pool which is sorted and trimmed to this limit.
205
+ * @default 6
206
+ */
207
+ displayLimit?: number;
208
+ }
113
209
  export interface EdgeTriggerConfig {
114
210
  /**
115
211
  * Whether to show the edge trigger sidebar tab.
@@ -177,7 +273,11 @@ export interface MobileTriggerConfig {
177
273
  offset?: number;
178
274
  }
179
275
  export interface PillarConfig {
180
- helpCenter: string;
276
+ /**
277
+ * Your product key from the Pillar app.
278
+ * Get it at app.trypillar.com
279
+ */
280
+ productKey?: string;
181
281
  /**
182
282
  * Platform identifier for code-first actions.
183
283
  * Used to filter actions by deployment platform.
@@ -190,11 +290,22 @@ export interface PillarConfig {
190
290
  * @example '1.2.3' or git commit SHA
191
291
  */
192
292
  version?: string;
293
+ /**
294
+ * Enable debug mode for verbose logging and debug panel.
295
+ * When enabled:
296
+ * - All SDK events are logged to console
297
+ * - A debug panel shows real-time execution flow
298
+ * - Network requests/responses are captured
299
+ * @default false
300
+ */
301
+ debug?: boolean;
193
302
  panel?: PanelConfig;
194
303
  edgeTrigger?: EdgeTriggerConfig;
195
304
  mobileTrigger?: MobileTriggerConfig;
196
305
  urlParams?: UrlParamsConfig;
197
306
  textSelection?: TextSelectionConfig;
307
+ domScanning?: DOMScanningConfig;
308
+ suggestions?: SuggestionsConfig;
198
309
  sidebarTabs?: SidebarTabConfig[];
199
310
  apiBaseUrl?: string;
200
311
  theme?: ThemeConfig;
@@ -244,25 +355,52 @@ export interface ResolvedThemeConfig {
244
355
  colors: ThemeColors;
245
356
  darkColors: ThemeColors;
246
357
  }
358
+ export interface ResolvedInteractionHighlightConfig {
359
+ enabled: boolean;
360
+ outlineColor: string;
361
+ outlineWidth: number;
362
+ outlineOffset: number;
363
+ duration: number;
364
+ scrollIntoView: boolean;
365
+ scrollBehavior: ScrollBehavior;
366
+ }
367
+ export interface ResolvedDOMScanningConfig {
368
+ enabled: boolean;
369
+ includeText: boolean;
370
+ maxDepth: number;
371
+ visibleOnly: boolean;
372
+ excludeSelector?: string;
373
+ maxTextLength: number;
374
+ interactionHighlight: ResolvedInteractionHighlightConfig;
375
+ }
376
+ export interface ResolvedSuggestionsConfig {
377
+ enabled: boolean;
378
+ debounceMs: number;
379
+ displayLimit: number;
380
+ }
247
381
  export interface ResolvedConfig {
248
- helpCenter: string;
382
+ productKey: string;
249
383
  apiBaseUrl: string;
250
384
  /** Platform for code-first actions (default: 'web') */
251
385
  platform: Platform;
252
386
  /** App version for code-first actions (optional) */
253
387
  version?: string;
388
+ /** Debug mode enabled */
389
+ debug: boolean;
254
390
  panel: ResolvedPanelConfig;
255
391
  edgeTrigger: Required<EdgeTriggerConfig>;
256
392
  mobileTrigger: ResolvedMobileTriggerConfig;
257
393
  urlParams: Required<UrlParamsConfig>;
258
394
  textSelection: Required<TextSelectionConfig>;
395
+ domScanning: ResolvedDOMScanningConfig;
396
+ suggestions: ResolvedSuggestionsConfig;
259
397
  sidebarTabs: SidebarTabConfig[];
260
398
  theme: ResolvedThemeConfig;
261
399
  customCSS?: string;
262
400
  onReady?: () => void;
263
401
  onError?: (error: Error) => void;
264
402
  }
265
- export declare const DEFAULT_CONFIG: Omit<ResolvedConfig, 'helpCenter' | 'publicKey'>;
403
+ export declare const DEFAULT_CONFIG: Omit<ResolvedConfig, 'productKey' | 'publicKey'>;
266
404
  export declare function resolveConfig(config: PillarConfig): ResolvedConfig;
267
405
  /**
268
406
  * Server embed config type (matches backend response)