@pillar-ai/sdk 0.1.25 → 0.1.26

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/dist/cli/sync.js CHANGED
@@ -27,14 +27,19 @@ function printUsage() {
27
27
  console.log(`
28
28
  Pillar Tool Sync CLI
29
29
 
30
- Scans for usePillarTool/defineTool calls and syncs to the Pillar backend.
31
- Also supports legacy usePillarAction/defineAction calls.
30
+ Scans for tool definitions and syncs to the Pillar backend.
31
+
32
+ Supported patterns:
33
+ - React/Vue: usePillarTool()
34
+ - Angular: injectPillarTool()
35
+ - Vanilla JS: pillar.defineTool()
36
+ - Legacy: usePillarAction(), defineAction(), injectPillarAction()
32
37
 
33
38
  Usage:
34
39
  npx pillar-sync --scan <dir> [--local]
35
40
 
36
41
  Arguments:
37
- --scan <dir> Directory to scan for usePillarTool/defineTool calls
42
+ --scan <dir> Directory to scan for tool definitions
38
43
  --local Use localhost:8003 as the API URL (for local development)
39
44
  --force Force sync even if manifest hash matches an existing deployment
40
45
  --help Show this help message
@@ -230,7 +235,14 @@ async function scanTools(scanDir) {
230
235
  }
231
236
  const files = globFiles(absoluteDir, [".ts", ".tsx", ".js", ".jsx", ".mjs"]);
232
237
  console.log(`[pillar-sync] Scanning ${files.length} files in ${scanDir}`);
233
- const PATTERNS = ["defineTool", "usePillarTool", "defineAction", "usePillarAction"];
238
+ const PATTERNS = [
239
+ "defineTool",
240
+ "usePillarTool",
241
+ "injectPillarTool",
242
+ "defineAction",
243
+ "usePillarAction",
244
+ "injectPillarAction"
245
+ ];
234
246
  const candidateFiles = files.filter((file) => {
235
247
  const content = fs.readFileSync(file, "utf-8");
236
248
  return PATTERNS.some((p) => content.includes(p));
@@ -313,7 +325,27 @@ async function scanTools(scanDir) {
313
325
  );
314
326
  visit2(sourceFile);
315
327
  }
316
- return tools;
328
+ const toolsByName = /* @__PURE__ */ new Map();
329
+ for (const tool of tools) {
330
+ const existing = toolsByName.get(tool.name);
331
+ if (existing) {
332
+ existing.push(tool);
333
+ } else {
334
+ toolsByName.set(tool.name, [tool]);
335
+ }
336
+ }
337
+ const deduplicatedTools = [];
338
+ for (const [name, instances] of toolsByName) {
339
+ if (instances.length > 1) {
340
+ const locations = instances.map((t) => `${t.sourceFile}:${t.line}`).join(", ");
341
+ console.warn(
342
+ `[pillar-sync] \u26A0 Duplicate tool "${name}" found in ${instances.length} locations: ${locations}`
343
+ );
344
+ console.warn(`[pillar-sync] Using first definition from ${instances[0].sourceFile}:${instances[0].line}`);
345
+ }
346
+ deduplicatedTools.push(instances[0]);
347
+ }
348
+ return deduplicatedTools;
317
349
  }
318
350
  function findAgentGuidance(scanDir) {
319
351
  const absoluteDir = path.resolve(process.cwd(), scanDir);
@@ -36,6 +36,7 @@ export declare class EdgeTrigger {
36
36
  /**
37
37
  * Handle tab click - sets active tab and opens panel
38
38
  * For non-assistant tabs, emits event for customer's code to handle (e.g., Intercom, Zendesk)
39
+ * Tools tab (debug only) opens the panel with tool debugger
39
40
  */
40
41
  private handleTabClick;
41
42
  /**
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Tool Debug Panel Component
3
+ *
4
+ * Shows registered tools and allows testing execution.
5
+ * Only rendered when debug: true is passed to Pillar.init()
6
+ *
7
+ * Features:
8
+ * - Searchable list of all registered tools
9
+ * - Tool details with input schema
10
+ * - JSON editor for testing tool execution
11
+ * - Execute button with result display
12
+ */
13
+ interface ToolDebugPanelProps {
14
+ /** Called when user wants to close the panel */
15
+ onClose?: () => void;
16
+ }
17
+ /**
18
+ * Tool Debug Panel Component
19
+ */
20
+ export declare function ToolDebugPanel({ onClose }: ToolDebugPanelProps): import("preact").JSX.Element;
21
+ export default ToolDebugPanel;
@@ -0,0 +1 @@
1
+ export { ToolDebugPanel, default } from "./ToolDebugPanel";
@@ -2,7 +2,7 @@
2
2
  * Main Pillar SDK Class
3
3
  * Entry point for all SDK functionality
4
4
  */
5
- import { type ToolSchema } from "../tools";
5
+ import { type ToolSchema, type ToolType } from "../tools";
6
6
  import { type PillarConfig, type ResolvedConfig, type ThemeConfig } from "./config";
7
7
  import { type Context, type Suggestion, type UserProfile } from "./context";
8
8
  import { type CardRenderer, type PillarEvents, type TaskExecutePayload } from "./events";
@@ -20,7 +20,29 @@ export interface ChatContext {
20
20
  content: string;
21
21
  }>;
22
22
  }
23
+ /**
24
+ * Tool information for the debug panel.
25
+ */
26
+ export interface ToolInfo {
27
+ /** Tool name (unique identifier) */
28
+ name: string;
29
+ /** Human-readable description */
30
+ description: string;
31
+ /** Tool type (navigate, query, trigger_tool, etc.) */
32
+ type?: ToolType;
33
+ /** JSON Schema for input parameters */
34
+ inputSchema?: {
35
+ type: "object";
36
+ properties: Record<string, unknown>;
37
+ required?: string[];
38
+ };
39
+ /** Where this tool was registered from */
40
+ source: "defined" | "registered" | "registry";
41
+ /** Whether the tool has an execute handler */
42
+ hasHandler: boolean;
43
+ }
23
44
  export declare class Pillar {
45
+ static readonly version: string;
24
46
  private static instance;
25
47
  private _state;
26
48
  private _config;
@@ -112,6 +134,28 @@ export declare class Pillar {
112
134
  * Clear debug log entries.
113
135
  */
114
136
  clearDebugLog(): void;
137
+ /**
138
+ * Get all registered tools for debugging.
139
+ * Returns tools from all sources: defineTool(), registerTool(), and onTask() handlers.
140
+ *
141
+ * Only available when debug mode is enabled.
142
+ *
143
+ * @returns Array of tool information objects
144
+ */
145
+ getTools(): ToolInfo[];
146
+ /**
147
+ * Execute a tool by name for debugging purposes.
148
+ * Only available when debug mode is enabled.
149
+ *
150
+ * @param toolName - Name of the tool to execute
151
+ * @param input - Input parameters to pass to the tool
152
+ * @returns Promise resolving to the tool's result or error
153
+ */
154
+ executeToolForDebug(toolName: string, input: Record<string, unknown>): Promise<{
155
+ success: boolean;
156
+ result?: unknown;
157
+ error?: string;
158
+ }>;
115
159
  /**
116
160
  * Subscribe to SDK events
117
161
  */
@@ -17,7 +17,7 @@ export interface SidebarTabConfig {
17
17
  enabled: boolean;
18
18
  order: number;
19
19
  /** Preset icon for this tab */
20
- icon?: 'help' | 'support' | 'settings' | 'feedback' | 'chat' | 'calendar' | 'mail';
20
+ icon?: 'help' | 'support' | 'settings' | 'feedback' | 'chat' | 'calendar' | 'mail' | 'tools';
21
21
  }
22
22
  export declare const DEFAULT_SIDEBAR_TABS: SidebarTabConfig[];
23
23
  /**
@@ -27,7 +27,11 @@ export interface TaskExecutePayload {
27
27
  * Callbacks provided to custom card renderers.
28
28
  */
29
29
  export interface CardCallbacks {
30
- /** Called when user confirms the action. Pass modified data if needed. */
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
+ */
31
35
  onConfirm: (modifiedData?: Record<string, unknown>) => void;
32
36
  /** Called when user cancels the action */
33
37
  onCancel: () => void;
@@ -234,6 +238,11 @@ export interface PillarEvents {
234
238
  tabId: string;
235
239
  label: string;
236
240
  };
241
+ /** A tool was registered or unregistered. */
242
+ "tools:change": {
243
+ action: "add" | "remove";
244
+ name: string;
245
+ };
237
246
  /** @deprecated Use 'sidebar:click' instead. Will be removed in next major version. */
238
247
  "support:request": {
239
248
  tabId: string;
package/dist/index.d.ts CHANGED
@@ -19,7 +19,7 @@
19
19
  * });
20
20
  */
21
21
  export { EventEmitter, type CardCallbacks, type CardRenderer, type PillarEvents, type TaskExecutePayload, } from "./core/events";
22
- export { Pillar, type ChatContext, type PillarState } from "./core/Pillar";
22
+ export { Pillar, type ChatContext, type PillarState, type ToolInfo } from "./core/Pillar";
23
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, 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 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";