@pillar-ai/sdk 0.1.34 → 0.2.0

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 (90) hide show
  1. package/README.md +5 -5
  2. package/dist/api/mcp-client.d.ts +0 -4
  3. package/dist/cli/sync.js +0 -0
  4. package/dist/components/Cards/ConfirmActionCard.d.ts +16 -5
  5. package/dist/components/Panel/TaskButton.d.ts +2 -0
  6. package/dist/core/Pillar.d.ts +44 -2
  7. package/dist/core/config.d.ts +7 -1
  8. package/dist/core/events.d.ts +26 -13
  9. package/dist/index.d.ts +6 -4
  10. package/dist/pillar.esm.js +1 -1
  11. package/dist/store/chat.d.ts +5 -0
  12. package/dist/tools/types.d.ts +8 -1
  13. package/package.json +1 -1
  14. package/dist/actions/definitions/analytics.d.ts +0 -18
  15. package/dist/actions/definitions/content.d.ts +0 -40
  16. package/dist/actions/definitions/index.d.ts +0 -26
  17. package/dist/actions/definitions/navigation.d.ts +0 -65
  18. package/dist/actions/definitions/settings.d.ts +0 -162
  19. package/dist/actions/definitions/sources.d.ts +0 -44
  20. package/dist/actions/definitions/support.d.ts +0 -15
  21. package/dist/actions/definitions/team.d.ts +0 -120
  22. package/dist/actions/index.d.ts +0 -33
  23. package/dist/actions/registry.d.ts +0 -98
  24. package/dist/actions/types.d.ts +0 -530
  25. package/dist/api/ag-ui-adapter.d.ts +0 -76
  26. package/dist/api/ag-ui-bridge.d.ts +0 -49
  27. package/dist/api/ag-ui-client.d.ts +0 -102
  28. package/dist/api/ag-ui-handler.d.ts +0 -89
  29. package/dist/button/FloatingButton.d.ts +0 -44
  30. package/dist/components/Button/FloatingButton.d.ts +0 -46
  31. package/dist/components/DevTools/DOMScannerPreview.d.ts +0 -21
  32. package/dist/components/DevTools/styles.d.ts +0 -5
  33. package/dist/components/PagePilot/PagePilotBanner.d.ts +0 -7
  34. package/dist/components/PagePilot/PagePilotManager.d.ts +0 -47
  35. package/dist/components/PagePilot/index.d.ts +0 -6
  36. package/dist/components/PagePilot/styles.d.ts +0 -6
  37. package/dist/components/Panel/styles.d.ts +0 -20
  38. package/dist/components/Plan/InlinePlanView.d.ts +0 -24
  39. package/dist/components/Plan/PlanDocument.d.ts +0 -18
  40. package/dist/components/Plan/PlanStepItem.d.ts +0 -23
  41. package/dist/components/Plan/PlanView.d.ts +0 -10
  42. package/dist/components/Plan/index.d.ts +0 -9
  43. package/dist/components/Progress/AGUIProgress.d.ts +0 -15
  44. package/dist/components/Progress/ReasoningDisclosure.d.ts +0 -16
  45. package/dist/components/TextSelection/styles.d.ts +0 -5
  46. package/dist/components/Tooltips/Tooltip.d.ts +0 -46
  47. package/dist/components/Tooltips/TooltipManager.d.ts +0 -41
  48. package/dist/components/Tooltips/index.d.ts +0 -6
  49. package/dist/components/Tooltips/styles.d.ts +0 -5
  50. package/dist/components/Views/ArticleChatView.d.ts +0 -9
  51. package/dist/components/Views/ArticleView.d.ts +0 -10
  52. package/dist/components/Views/CategoryView.d.ts +0 -11
  53. package/dist/components/Views/DeveloperView.d.ts +0 -6
  54. package/dist/components/Views/SearchView.d.ts +0 -10
  55. package/dist/components/shared/ArticleCard.d.ts +0 -17
  56. package/dist/components/shared/CategoryCard.d.ts +0 -17
  57. package/dist/content/extensions/AccordionNode.d.ts +0 -10
  58. package/dist/content/extensions/CalloutNode.d.ts +0 -11
  59. package/dist/content/extensions/index.d.ts +0 -5
  60. package/dist/content/index.d.ts +0 -5
  61. package/dist/content/renderer.d.ts +0 -24
  62. package/dist/core/plan-executor.d.ts +0 -148
  63. package/dist/core/plan.d.ts +0 -192
  64. package/dist/hooks/useInlineCard.d.ts +0 -35
  65. package/dist/panel/Panel.d.ts +0 -53
  66. package/dist/panel/PanelUI.d.ts +0 -43
  67. package/dist/panel/components/ArticleCard.d.ts +0 -10
  68. package/dist/panel/components/CategoryCard.d.ts +0 -10
  69. package/dist/panel/components/ChatInput.d.ts +0 -36
  70. package/dist/panel/components/Header.d.ts +0 -16
  71. package/dist/panel/components/SearchInput.d.ts +0 -11
  72. package/dist/panel/styles.d.ts +0 -5
  73. package/dist/panel/views/ArticleView.d.ts +0 -21
  74. package/dist/panel/views/CategoryView.d.ts +0 -20
  75. package/dist/panel/views/ChatView.d.ts +0 -30
  76. package/dist/panel/views/HomeView.d.ts +0 -18
  77. package/dist/panel/views/SearchView.d.ts +0 -22
  78. package/dist/store/developer.d.ts +0 -19
  79. package/dist/store/plan-persistence.d.ts +0 -47
  80. package/dist/store/plan.d.ts +0 -45
  81. package/dist/store/tooltips.d.ts +0 -21
  82. package/dist/tooltips/Tooltip.d.ts +0 -63
  83. package/dist/tooltips/TooltipManager.d.ts +0 -42
  84. package/dist/tooltips/styles.d.ts +0 -5
  85. package/dist/ui/config.d.ts +0 -96
  86. package/dist/ui/executor.d.ts +0 -75
  87. package/dist/ui/index.d.ts +0 -11
  88. package/dist/ui/scanner.d.ts +0 -105
  89. package/dist/ui/types.d.ts +0 -293
  90. package/dist/utils/markdown.d.ts +0 -9
package/README.md CHANGED
@@ -56,9 +56,9 @@ yarn add @pillar-ai/sdk
56
56
 
57
57
  ## Quick Start
58
58
 
59
- ### 1. Get your product key
59
+ ### 1. Get your agent slug
60
60
 
61
- Sign up at [app.trypillar.com](https://app.trypillar.com) and grab your product key from the dashboard.
61
+ Sign up at [app.trypillar.com](https://app.trypillar.com) and grab your agent slug from the dashboard.
62
62
 
63
63
  ### 2. Initialize the SDK
64
64
 
@@ -67,7 +67,7 @@ import { Pillar } from "@pillar-ai/sdk";
67
67
 
68
68
  // Initialize and get the instance
69
69
  const pillar = await Pillar.init({
70
- productKey: "your-product-key", // Provided during onboarding
70
+ agentSlug: "your-agent-slug", // Provided during onboarding
71
71
  });
72
72
 
73
73
  // Now you can use instance methods
@@ -93,7 +93,7 @@ Use `onTask` to handle actions when the AI executes them:
93
93
 
94
94
  ```javascript
95
95
  const pillar = await Pillar.init({
96
- productKey: "your-product-key",
96
+ agentSlug: "your-agent-slug",
97
97
  });
98
98
 
99
99
  // Handle navigation
@@ -120,7 +120,7 @@ For production, define tools in code and sync them via the `pillar-sync` CLI dur
120
120
 
121
121
  ```javascript
122
122
  const pillar = await Pillar.init({
123
- productKey: "your-product-key",
123
+ agentSlug: "your-agent-slug",
124
124
 
125
125
  panel: {
126
126
  position: "right", // 'left' | 'right'
@@ -27,8 +27,6 @@ export interface ToolResult {
27
27
  actions?: ToolData[];
28
28
  /** Registered tools for dynamic tool invocations (persisted across turns) */
29
29
  registered_tools?: Record<string, unknown>[];
30
- /** @deprecated Use registered_tools instead */
31
- registered_actions?: Record<string, unknown>[];
32
30
  };
33
31
  _meta?: {
34
32
  conversation_id?: string;
@@ -285,8 +283,6 @@ export interface ConversationStatus {
285
283
  partial_response?: string;
286
284
  display_trace?: DisplayStep[];
287
285
  registered_tools?: Record<string, unknown>[];
288
- /** @deprecated Use registered_tools instead */
289
- registered_actions?: Record<string, unknown>[];
290
286
  }
291
287
  /**
292
288
  * Convert ToolData from MCP response to TaskButtonData for UI rendering.
package/dist/cli/sync.js CHANGED
File without changes
@@ -3,17 +3,28 @@
3
3
  *
4
4
  * Renders inline_ui type actions as inline cards in the chat.
5
5
  * If a custom card renderer is registered for the card_type, it's used.
6
- * Otherwise, a default confirmation card is rendered.
6
+ * Otherwise, a default preview card is rendered.
7
+ *
8
+ * When `needsConfirmation` is set, the default card includes Confirm / Cancel
9
+ * buttons that gate execution of the tool's `execute` handler.
7
10
  */
8
11
  import type { CardCallbacks } from '../../core/events';
9
12
  import type { TaskButtonData } from '../Panel/TaskButton';
10
13
  /**
11
- * Create the default confirmation card for inline_ui actions.
12
- * Used when no custom card renderer is registered.
14
+ * Create the default card for inline_ui actions.
15
+ * When callbacks include onConfirm/onCancel, confirm/cancel buttons are shown.
13
16
  */
14
17
  export declare function createDefaultConfirmCard(action: TaskButtonData, callbacks: CardCallbacks): HTMLDivElement;
18
+ export interface ConfirmActionCardOptions {
19
+ needsConfirmation?: boolean;
20
+ onConfirm?: (data?: Record<string, unknown>) => void;
21
+ onCancel?: () => void;
22
+ }
15
23
  /**
16
- * Create a confirmation card for a confirm_action type action.
24
+ * Create a card for an inline_ui type action.
17
25
  * Uses custom renderer if registered, otherwise uses default.
26
+ *
27
+ * When `options.needsConfirmation` is true, the card includes Confirm/Cancel
28
+ * buttons that call the provided `onConfirm`/`onCancel` callbacks.
18
29
  */
19
- export declare function createConfirmActionCard(action: TaskButtonData, onConfirm: (data?: Record<string, unknown>) => void, onCancel: () => void): HTMLDivElement;
30
+ export declare function createConfirmActionCard(action: TaskButtonData, options?: ConfirmActionCardOptions): HTMLDivElement;
@@ -26,6 +26,8 @@ export interface TaskButtonData {
26
26
  autoRun?: boolean;
27
27
  /** If true, action completes without waiting for host confirmation */
28
28
  autoComplete?: boolean;
29
+ /** If true, show a confirmation card before executing */
30
+ needsConfirmation?: boolean;
29
31
  }
30
32
  interface TaskButtonProps {
31
33
  task: TaskButtonData;
@@ -675,10 +675,8 @@ export declare class Pillar {
675
675
  * <div class="invite-card">
676
676
  * <h3>Invite Team Members</h3>
677
677
  * ${data.emails.map(e => `<div>${e}</div>`).join('')}
678
- * <button id="confirm">Send Invites</button>
679
678
  * </div>
680
679
  * `;
681
- * container.querySelector('#confirm').onclick = callbacks.onConfirm;
682
680
  * return () => container.innerHTML = ''; // cleanup
683
681
  * });
684
682
  */
@@ -696,6 +694,36 @@ export declare class Pillar {
696
694
  * @param cardType - The card type identifier
697
695
  */
698
696
  hasCardRenderer(cardType: string): boolean;
697
+ /**
698
+ * Get the position (messageIndex, segmentIndex) of the last card segment
699
+ * in the current message list. Returns null if there are no card segments.
700
+ */
701
+ getLatestCardPosition(): {
702
+ messageIndex: number;
703
+ segmentIndex: number;
704
+ } | null;
705
+ /**
706
+ * Check if a given message position is in the latest message.
707
+ * This becomes false as soon as any new message is added (including hidden
708
+ * messages from sendResult). Segment position within the same message is
709
+ * ignored — text segments after a card in the same assistant turn don't
710
+ * make the card "stale".
711
+ */
712
+ isPositionLatest(messageIndex: number, _segmentIndex: number): boolean;
713
+ /**
714
+ * Subscribe to message list changes (for reactive card context).
715
+ * Returns an unsubscribe function.
716
+ */
717
+ subscribeToMessages(callback: () => void): () => void;
718
+ /**
719
+ * Whether the chat is currently streaming a response.
720
+ */
721
+ get isChatLoading(): boolean;
722
+ /**
723
+ * Subscribe to chat loading-state changes (for reactive `isReady` in card context).
724
+ * Returns an unsubscribe function.
725
+ */
726
+ subscribeToLoadingState(callback: () => void): () => void;
699
727
  /**
700
728
  * Get the active workflow, if any.
701
729
  */
@@ -753,6 +781,20 @@ export declare class Pillar {
753
781
  sendToolResult(toolName: string, result: unknown, toolCallId?: string): Promise<void>;
754
782
  /** @deprecated Use sendToolResult instead */
755
783
  sendActionResult(actionName: string, result: unknown, toolCallId?: string): Promise<void>;
784
+ /**
785
+ * Send a tool result as a new chat message, triggering a fresh LLM turn.
786
+ *
787
+ * Unlike `sendToolResult` (which responds to a pending tool call via `action/result`),
788
+ * this method injects the data as a new user message so the LLM can reason about it
789
+ * and decide what to do next (e.g., call another tool like `display_checkout`).
790
+ *
791
+ * Use this for results from already-rendered inline_ui cards where the original
792
+ * tool call has already completed and there is no pending `tool_call_id`.
793
+ *
794
+ * @param toolName - The name of the tool that generated the result
795
+ * @param result - Structured data to send to the LLM
796
+ */
797
+ sendToolResultAsMessage(toolName: string, result: Record<string, unknown>): void;
756
798
  /**
757
799
  * Execute a query tool and send the result back to the agent.
758
800
  *
@@ -332,9 +332,14 @@ export interface ZIndexConfig {
332
332
  }
333
333
  export interface PillarConfig {
334
334
  /**
335
- * Your product key from the Pillar app.
335
+ * Your agent slug from the Pillar dashboard.
336
+ * This is the primary identifier for your copilot agent.
336
337
  * Get it at app.trypillar.com
337
338
  */
339
+ agentSlug?: string;
340
+ /**
341
+ * @deprecated Use `agentSlug` instead. Will be removed in a future version.
342
+ */
338
343
  productKey?: string;
339
344
  /**
340
345
  * Display name for the assistant shown in the sidebar tab.
@@ -500,6 +505,7 @@ export interface ResolvedSuggestionsConfig {
500
505
  }
501
506
  export interface ResolvedConfig {
502
507
  productKey: string;
508
+ agentSlug?: string;
503
509
  apiBaseUrl: string;
504
510
  /** Display name for the assistant shown in the sidebar tab */
505
511
  assistantDisplayName: string;
@@ -27,17 +27,32 @@ export interface TaskExecutePayload {
27
27
  * Callbacks provided to custom card renderers.
28
28
  */
29
29
  export interface CardCallbacks {
30
- /**
31
- * Called when user confirms the action. Pass modified data if needed.
32
- * WARNING: Data passed here flows through the SDK pipeline (telemetry,
33
- * agent context, logs). Never include secrets, tokens, or PII.
34
- */
35
- onConfirm: (modifiedData?: Record<string, unknown>) => void;
36
- /** Called when user cancels the action */
37
- onCancel: () => void;
30
+ /** Confirm the action — triggers the tool's `execute` handler. Only present when the tool has `needsConfirmation`. */
31
+ onConfirm?: (modifiedData?: Record<string, unknown>) => void;
32
+ /** Cancel the action dismisses the card. Only present when the tool has `needsConfirmation`. */
33
+ onCancel?: () => void;
34
+ /** Send a result back to the AI agent so it can continue reasoning. */
35
+ sendResult?: (result: Record<string, unknown>) => Promise<void>;
38
36
  /** Called to report card state changes (for analytics/confirmation) */
39
37
  onStateChange?: (state: "loading" | "success" | "error", message?: string) => void;
40
38
  }
39
+ /**
40
+ * Context about a card's position in the chat.
41
+ * Passed to card renderers so they can adapt their UI
42
+ * (e.g., collapse when no longer the latest card).
43
+ */
44
+ export interface ToolCardContext {
45
+ /** True when this is the last card segment across all messages. */
46
+ isLatest: boolean;
47
+ /** True when no message is being streamed — safe to call sendResult. */
48
+ isReady: boolean;
49
+ /** Zero-based index of the message containing this card. */
50
+ messageIndex: number;
51
+ /** Zero-based index of this segment within its message's segments array. */
52
+ segmentIndex: number;
53
+ /** The tool name / card type. */
54
+ toolName: string;
55
+ }
41
56
  /**
42
57
  * Card field schema definition for declarative card configuration.
43
58
  */
@@ -88,8 +103,6 @@ export interface CardRegistrationOptions {
88
103
  /** Theme/styling options */
89
104
  theme?: {
90
105
  variant?: "default" | "compact" | "wide";
91
- confirmLabel?: string;
92
- cancelLabel?: string;
93
106
  };
94
107
  }
95
108
  /**
@@ -102,14 +115,14 @@ export interface RegisteredCard {
102
115
  }
103
116
  /**
104
117
  * Card renderer function signature.
105
- * Customers register these to render custom confirmation cards.
118
+ * Customers register these to render custom inline UI cards.
106
119
  *
107
120
  * @param container - DOM element to render the card into
108
121
  * @param data - Action data including extracted values from AI
109
- * @param callbacks - Callbacks for confirm/cancel actions
122
+ * @param callbacks - Callbacks for state reporting
110
123
  * @returns Optional cleanup function called when card is unmounted
111
124
  */
112
- export type CardRenderer = (container: HTMLElement, data: Record<string, unknown>, callbacks: CardCallbacks) => (() => void) | void;
125
+ export type CardRenderer = (container: HTMLElement, data: Record<string, unknown>, callbacks: CardCallbacks, context?: ToolCardContext) => (() => void) | void;
113
126
  export interface PillarEvents {
114
127
  /** SDK is initialized and ready. */
115
128
  ready: void;
package/dist/index.d.ts CHANGED
@@ -6,7 +6,7 @@
6
6
  * <script src="https://cdn.trypillar.com/sdk/pillar.min.js"></script>
7
7
  * <script>
8
8
  * Pillar.init({
9
- * productKey: 'your-product-key',
9
+ * agentSlug: 'your-agent-slug',
10
10
  * });
11
11
  * </script>
12
12
  *
@@ -15,16 +15,18 @@
15
15
  * import { Pillar } from '@pillar-ai/sdk';
16
16
  *
17
17
  * await Pillar.init({
18
- * productKey: 'your-product-key',
18
+ * agentSlug: 'your-agent-slug',
19
19
  * });
20
20
  */
21
- export { EventEmitter, type CardCallbacks, type CardRenderer, type PillarEvents, type TaskExecutePayload, } from "./core/events";
22
- export { Pillar, type ChatContext, type PillarState, type ToolInfo } from "./core/Pillar";
21
+ export { EventEmitter, type CardCallbacks, type CardRenderer, type ToolCardContext, type PillarEvents, type TaskExecutePayload, } from "./core/events";
22
+ export { Pillar, getApiClient, type ChatContext, type PillarState, type ToolInfo } from "./core/Pillar";
23
+ export { getPillarInstance } from "./core/instance";
23
24
  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, type ZIndexConfig, } from "./core/config";
24
25
  export { type AssistantContext, type Context, type Suggestion, type UserProfile, } from "./core/context";
25
26
  export { clearRegistry, getToolCount, getToolDefinition, getToolNames, getClientInfo, getHandler, getManifest, hasTool, setClientInfo, type ToolDataSchema, type ToolDataSchemaProperty, type ToolDataType, type ToolDefinition, type ToolDefinitions, type ToolManifest, type ToolManifestEntry, type ToolNames, type ToolType, type ToolTypeDataMap, type ToolExecuteResult, type ToolSchemaBase, type InlineUIToolSchema, type ExecutableToolSchema, type ToolSchema, type ClientInfo, type CopyTextData, type ExternalLinkData, type InlineUIData, type NavigateToolData, type TriggerToolData, type QueryToolData, type Platform, type SyncToolDefinition, type SyncToolDefinitions, type TypedOnTask, type TypedPillarMethods, type TypedTaskHandler, getActionCount, getActionDefinition, getActionNames, hasAction, type ActionDataSchema, type ActionDataSchemaProperty, type ActionDataType, type ActionDefinition, type ActionDefinitions, type ActionManifest, type ActionManifestEntry, type ActionNames, type ActionType, type ActionTypeDataMap, type ActionResult, type ActionSchema, type NavigateActionData, type TriggerActionData, type QueryActionData, type SyncActionDefinition, type SyncActionDefinitions, } from "./tools";
26
27
  export { APIClient, type ArticleSummary, type ChatMessage, type ChatResponse, type ProgressEvent, } from "./api/client";
27
28
  export { type ToolRequest, type ToolData, type ChatImage, type ImageUploadResponse, type TokenUsage, toolToTaskButton, type ActionRequest, type ActionData, actionToTaskButton, } from "./api/mcp-client";
29
+ export { normalizeToolResult } from "./utils/normalize-tool-result";
28
30
  export { DEFAULT_SCAN_OPTIONS, INTERACTABLE_ROLES, INTERACTABLE_TAGS, SKIP_TAGS, type CompactScanResult, type InteractionType, type ScanOptions, } from "./types/dom-scanner";
29
31
  export { buildSelectorFromRef, clearPillarRefs, isDestructiveElement, isInteractable, isRedacted, isValidPillarRef, scanPageDirect, } from "./utils/dom-scanner";
30
32
  export { generateContextId, getContextDisplayLabel, isDOMSnapshotContext, isHighlightedTextContext, type DOMSnapshotContext, type GenericContext, type HighlightedTextContext, type ProductContext, type UserContextItem, type UserProfileContext, } from "./types/user-context";