@pillar-ai/sdk 0.1.32 → 0.1.34

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 (65) hide show
  1. package/README.md +19 -21
  2. package/dist/actions/definitions/analytics.d.ts +18 -0
  3. package/dist/actions/definitions/content.d.ts +40 -0
  4. package/dist/actions/definitions/index.d.ts +26 -0
  5. package/dist/actions/definitions/navigation.d.ts +65 -0
  6. package/dist/actions/definitions/settings.d.ts +162 -0
  7. package/dist/actions/definitions/sources.d.ts +44 -0
  8. package/dist/actions/definitions/support.d.ts +15 -0
  9. package/dist/actions/definitions/team.d.ts +120 -0
  10. package/dist/api/ag-ui-adapter.d.ts +76 -0
  11. package/dist/api/ag-ui-bridge.d.ts +49 -0
  12. package/dist/api/ag-ui-client.d.ts +102 -0
  13. package/dist/api/ag-ui-handler.d.ts +89 -0
  14. package/dist/button/FloatingButton.d.ts +44 -0
  15. package/dist/cli/sync.js +32 -10
  16. package/dist/components/Button/FloatingButton.d.ts +46 -0
  17. package/dist/components/DevTools/DOMScannerPreview.d.ts +21 -0
  18. package/dist/components/Progress/AGUIProgress.d.ts +15 -0
  19. package/dist/components/Tooltips/Tooltip.d.ts +46 -0
  20. package/dist/components/Tooltips/TooltipManager.d.ts +41 -0
  21. package/dist/components/Tooltips/index.d.ts +6 -0
  22. package/dist/components/Tooltips/styles.d.ts +5 -0
  23. package/dist/components/Views/ArticleChatView.d.ts +9 -0
  24. package/dist/components/Views/ArticleView.d.ts +10 -0
  25. package/dist/components/Views/CategoryView.d.ts +11 -0
  26. package/dist/components/Views/DeveloperView.d.ts +6 -0
  27. package/dist/components/Views/SearchView.d.ts +10 -0
  28. package/dist/components/shared/ArticleCard.d.ts +17 -0
  29. package/dist/components/shared/CategoryCard.d.ts +17 -0
  30. package/dist/content/extensions/AccordionNode.d.ts +10 -0
  31. package/dist/content/extensions/CalloutNode.d.ts +11 -0
  32. package/dist/content/extensions/index.d.ts +5 -0
  33. package/dist/content/index.d.ts +5 -0
  34. package/dist/content/renderer.d.ts +24 -0
  35. package/dist/core/config.d.ts +1 -1
  36. package/dist/index.d.ts +1 -1
  37. package/dist/panel/Panel.d.ts +53 -0
  38. package/dist/panel/PanelUI.d.ts +43 -0
  39. package/dist/panel/components/ArticleCard.d.ts +10 -0
  40. package/dist/panel/components/CategoryCard.d.ts +10 -0
  41. package/dist/panel/components/ChatInput.d.ts +36 -0
  42. package/dist/panel/components/Header.d.ts +16 -0
  43. package/dist/panel/components/SearchInput.d.ts +11 -0
  44. package/dist/panel/styles.d.ts +5 -0
  45. package/dist/panel/views/ArticleView.d.ts +21 -0
  46. package/dist/panel/views/CategoryView.d.ts +20 -0
  47. package/dist/panel/views/ChatView.d.ts +30 -0
  48. package/dist/panel/views/HomeView.d.ts +18 -0
  49. package/dist/panel/views/SearchView.d.ts +22 -0
  50. package/dist/pillar.esm.js +1 -1
  51. package/dist/store/chat.d.ts +10 -0
  52. package/dist/store/developer.d.ts +19 -0
  53. package/dist/store/tooltips.d.ts +21 -0
  54. package/dist/tools/index.d.ts +1 -1
  55. package/dist/tools/types.d.ts +100 -43
  56. package/dist/tooltips/Tooltip.d.ts +63 -0
  57. package/dist/tooltips/TooltipManager.d.ts +42 -0
  58. package/dist/tooltips/styles.d.ts +5 -0
  59. package/dist/ui/config.d.ts +96 -0
  60. package/dist/ui/executor.d.ts +75 -0
  61. package/dist/ui/index.d.ts +11 -0
  62. package/dist/ui/scanner.d.ts +105 -0
  63. package/dist/ui/types.d.ts +293 -0
  64. package/dist/utils/markdown.d.ts +9 -0
  65. package/package.json +2 -1
@@ -18,6 +18,7 @@ export interface ActionStatus {
18
18
  *
19
19
  * - "text": Model-generated content tokens (narration or final response)
20
20
  * - "progress": A group of progress events (thinking, search, tool calls)
21
+ * - "card": A tool result card to be rendered inline
21
22
  */
22
23
  export type MessageSegment = {
23
24
  type: "text";
@@ -25,6 +26,10 @@ export type MessageSegment = {
25
26
  } | {
26
27
  type: "progress";
27
28
  events: ProgressEvent[];
29
+ } | {
30
+ type: "card";
31
+ cardType: string;
32
+ data: Record<string, unknown>;
28
33
  };
29
34
  export interface StoredChatMessage extends ChatMessage {
30
35
  id?: string;
@@ -152,6 +157,11 @@ export declare const addProgressEventToLastMessage: (event: ProgressEvent) => vo
152
157
  * updating `content` for backward compat (history persistence, feedback, etc.).
153
158
  */
154
159
  export declare const appendTokenToSegments: (token: string) => void;
160
+ /**
161
+ * Add a card segment to the last assistant message.
162
+ * Used when a tool returns data with a card_type that has a registered renderer.
163
+ */
164
+ export declare const addCardSegment: (cardType: string, data: Record<string, unknown>) => void;
155
165
  export declare const isExpanded: import("@preact/signals-core").Signal<boolean>;
156
166
  /**
157
167
  * @deprecated Sources are now stored per-message on `StoredChatMessage.sources`. Will be removed in v2.0.
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Developer Store
3
+ * Signal-based state for developer mode features
4
+ */
5
+ export declare const selectedAction: import("@preact/signals-core").Signal<string | null>;
6
+ export declare const actionData: import("@preact/signals-core").Signal<string>;
7
+ export declare const executionResult: import("@preact/signals-core").Signal<{
8
+ type: "success" | "error";
9
+ message: string;
10
+ } | null>;
11
+ export declare const isExecuting: import("@preact/signals-core").Signal<boolean>;
12
+ export declare const setSelectedAction: (actionName: string | null) => void;
13
+ export declare const setActionData: (data: string) => void;
14
+ export declare const setExecutionResult: (result: {
15
+ type: "success" | "error";
16
+ message: string;
17
+ } | null) => void;
18
+ export declare const setIsExecuting: (executing: boolean) => void;
19
+ export declare const resetDeveloperStore: () => void;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Tooltips Store
3
+ * Signal-based state for tooltip visibility and data
4
+ */
5
+ import type { TooltipData } from '../api/client';
6
+ export interface TooltipInstance {
7
+ id: string;
8
+ data: TooltipData;
9
+ anchor: HTMLElement;
10
+ isVisible: boolean;
11
+ }
12
+ export declare const tooltips: import("@preact/signals-core").Signal<Map<string, TooltipInstance>>;
13
+ export declare const visibleTooltipId: import("@preact/signals-core").Signal<string | null>;
14
+ export declare const visibleTooltip: import("@preact/signals-core").ReadonlySignal<TooltipInstance | null>;
15
+ export declare const tooltipCount: import("@preact/signals-core").ReadonlySignal<number>;
16
+ export declare const registerTooltip: (id: string, data: TooltipData, anchor: HTMLElement) => void;
17
+ export declare const unregisterTooltip: (id: string) => void;
18
+ export declare const showTooltip: (id: string) => void;
19
+ export declare const hideTooltip: (id: string) => void;
20
+ export declare const hideAllTooltips: () => void;
21
+ export declare const resetTooltips: () => void;
@@ -24,5 +24,5 @@
24
24
  * @module tools
25
25
  */
26
26
  export { validateToolName, TOOL_NAME_PATTERN } from './types';
27
- export type { ToolType, ToolDataSchema, ToolDataSchemaProperty, ToolDefinition, ToolDefinitions, ToolManifest, ToolManifestEntry, ClientInfo, Platform, SyncToolDefinition, SyncToolDefinitions, ToolTypeDataMap, NavigateToolData, TriggerToolData, InlineUIData, ExternalLinkData, CopyTextData, QueryToolData, ToolDataType, ToolNames, TypedTaskHandler, TypedOnTask, TypedPillarMethods, ToolExecuteResult, ToolSchema, ActionType, ActionDataSchema, ActionDataSchemaProperty, ActionDefinition, ActionDefinitions, ActionManifest, ActionManifestEntry, SyncActionDefinition, SyncActionDefinitions, NavigateActionData, TriggerActionData, QueryActionData, ActionTypeDataMap, ActionDataType, ActionNames, ActionResult, ActionSchema, } from './types';
27
+ export type { ToolType, ToolDataSchema, ToolDataSchemaProperty, ToolDefinition, ToolDefinitions, ToolManifest, ToolManifestEntry, ClientInfo, Platform, SyncToolDefinition, SyncToolDefinitions, ToolTypeDataMap, NavigateToolData, TriggerToolData, InlineUIData, ExternalLinkData, CopyTextData, QueryToolData, ToolDataType, ToolNames, TypedTaskHandler, TypedOnTask, TypedPillarMethods, ToolExecuteResult, ToolSchemaBase, InlineUIToolSchema, ExecutableToolSchema, ToolSchema, ActionType, ActionDataSchema, ActionDataSchemaProperty, ActionDefinition, ActionDefinitions, ActionManifest, ActionManifestEntry, SyncActionDefinition, SyncActionDefinitions, NavigateActionData, TriggerActionData, QueryActionData, ActionTypeDataMap, ActionDataType, ActionNames, ActionResult, ActionSchema, } from './types';
28
28
  export { setClientInfo, getClientInfo, getHandler, getToolDefinition, hasTool, getToolNames, getManifest, clearRegistry, getToolCount, getActionDefinition, hasAction, getActionNames, getActionCount, } from './registry';
@@ -24,6 +24,7 @@
24
24
  * // Register handlers at runtime: pillar.onTask('open_settings', () => router.push('/settings'));
25
25
  * ```
26
26
  */
27
+ import type { CardRenderer } from "../core/events";
27
28
  /**
28
29
  * Supported tool types.
29
30
  *
@@ -480,34 +481,12 @@ export interface ToolExecuteResult {
480
481
  isError?: boolean;
481
482
  }
482
483
  /**
483
- * Unified tool definition that co-locates metadata and handler.
484
- *
485
- * Use with `pillar.defineTool()` or the `usePillarTool()` React hook.
486
- * The CLI scanner (`npx pillar-sync --scan ./src`) discovers these
487
- * definitions automatically — no barrel file needed.
488
- *
489
- * @template TInput - Type of the input object passed to `execute`
484
+ * Shared fields for all tool schemas (both executable and inline_ui).
490
485
  *
491
- * @example
492
- * ```ts
493
- * pillar.defineTool({
494
- * name: 'get_signing_secret',
495
- * description: 'Retrieve the webhook signing secret',
496
- * outputSchema: {
497
- * type: 'object',
498
- * properties: {
499
- * signing_secret: { type: 'string', sensitive: true },
500
- * algorithm: { type: 'string' },
501
- * },
502
- * },
503
- * execute: async () => {
504
- * const secret = await api.getSigningSecret();
505
- * return { signing_secret: secret.value, algorithm: 'HMAC-SHA256' };
506
- * },
507
- * });
508
- * ```
486
+ * @template TInput - Type of the input object passed to `execute` or
487
+ * provided by the AI agent to the `render` component.
509
488
  */
510
- export interface ToolSchema<TInput = Record<string, unknown>> {
489
+ export interface ToolSchemaBase<TInput = Record<string, unknown>> {
511
490
  /** Unique tool name (e.g., 'add_to_cart') */
512
491
  name: string;
513
492
  /** Human-readable description for AI matching */
@@ -523,10 +502,6 @@ export interface ToolSchema<TInput = Record<string, unknown>> {
523
502
  * Action model so the agent sees it without runtime code.
524
503
  */
525
504
  guidance?: string;
526
- /**
527
- * Type of tool - determines how the SDK handles it and organizes it in the UI.
528
- */
529
- type?: ToolType;
530
505
  /**
531
506
  * JSON Schema describing the input parameters.
532
507
  * The AI extracts structured data from the conversation to populate these.
@@ -572,6 +547,85 @@ export interface ToolSchema<TInput = Record<string, unknown>> {
572
547
  * @example { plan: 'enterprise', betaAccess: true }
573
548
  */
574
549
  requiredContext?: Record<string, unknown>;
550
+ /**
551
+ * Whether to also register this tool with WebMCP (navigator.modelContext).
552
+ *
553
+ * When true, the tool will be exposed to browser-native AI agents and
554
+ * assistive technologies via the W3C WebMCP API. The tool is registered
555
+ * on mount and unregistered on unmount (or when the tool is removed).
556
+ *
557
+ * Only works in browser contexts where `navigator.modelContext` is available
558
+ * (either natively or via polyfill).
559
+ *
560
+ * @default false
561
+ */
562
+ webMCP?: boolean;
563
+ }
564
+ /**
565
+ * Tool schema for `inline_ui` tools that render a component in the chat.
566
+ *
567
+ * The AI agent provides data directly to the `render` function —
568
+ * there is no `execute` handler.
569
+ *
570
+ * @template TInput - Type of the data the AI agent provides to the render component
571
+ *
572
+ * @example Vanilla JS
573
+ * ```ts
574
+ * pillar.defineTool({
575
+ * name: 'show_results',
576
+ * description: 'Display search results inline',
577
+ * type: 'inline_ui',
578
+ * render: (container, data, { onConfirm, onCancel }) => {
579
+ * container.innerHTML = `<div>${data.items.length} results</div>`;
580
+ * return () => { container.innerHTML = ''; };
581
+ * },
582
+ * });
583
+ * ```
584
+ */
585
+ export interface InlineUIToolSchema<TInput = Record<string, unknown>> extends ToolSchemaBase<TInput> {
586
+ type: "inline_ui";
587
+ /**
588
+ * Card renderer for displaying tool results inline in the chat.
589
+ *
590
+ * The AI agent provides structured data matching `inputSchema` directly
591
+ * to this renderer. The SDK automatically registers this as a card
592
+ * renderer using the tool name as the card type.
593
+ *
594
+ * For framework-specific SDKs (React, Vue, Angular), pass a component
595
+ * instead — the framework SDK will convert it to a CardRenderer.
596
+ */
597
+ render: CardRenderer;
598
+ /** Not applicable for inline_ui tools. Use `render` instead. */
599
+ execute?: never;
600
+ }
601
+ /**
602
+ * Tool schema for executable tools (all types except `inline_ui`).
603
+ *
604
+ * The `execute` handler runs when the AI invokes this tool.
605
+ *
606
+ * @template TInput - Type of the input object passed to `execute`
607
+ *
608
+ * @example
609
+ * ```ts
610
+ * pillar.defineTool({
611
+ * name: 'get_signing_secret',
612
+ * description: 'Retrieve the webhook signing secret',
613
+ * outputSchema: {
614
+ * type: 'object',
615
+ * properties: {
616
+ * signing_secret: { type: 'string', sensitive: true },
617
+ * algorithm: { type: 'string' },
618
+ * },
619
+ * },
620
+ * execute: async () => {
621
+ * const secret = await api.getSigningSecret();
622
+ * return { signing_secret: secret.value, algorithm: 'HMAC-SHA256' };
623
+ * },
624
+ * });
625
+ * ```
626
+ */
627
+ export interface ExecutableToolSchema<TInput = Record<string, unknown>> extends ToolSchemaBase<TInput> {
628
+ type?: Exclude<ToolType, "inline_ui">;
575
629
  /**
576
630
  * Handler function executed when the AI invokes this tool.
577
631
  *
@@ -587,20 +641,23 @@ export interface ToolSchema<TInput = Record<string, unknown>> {
587
641
  * return flat data.
588
642
  */
589
643
  execute: (input: TInput) => Promise<ToolExecuteResult | Record<string, unknown> | void> | ToolExecuteResult | Record<string, unknown> | void;
590
- /**
591
- * Whether to also register this tool with WebMCP (navigator.modelContext).
592
- *
593
- * When true, the tool will be exposed to browser-native AI agents and
594
- * assistive technologies via the W3C WebMCP API. The tool is registered
595
- * on mount and unregistered on unmount (or when the tool is removed).
596
- *
597
- * Only works in browser contexts where `navigator.modelContext` is available
598
- * (either natively or via polyfill).
599
- *
600
- * @default false
601
- */
602
- webMCP?: boolean;
644
+ /** Not applicable for executable tools. Only `inline_ui` tools use `render`. */
645
+ render?: never;
603
646
  }
647
+ /**
648
+ * Unified tool definition that co-locates metadata and handler.
649
+ *
650
+ * Use with `pillar.defineTool()` or the `usePillarTool()` React hook.
651
+ * The CLI scanner (`npx pillar-sync --scan ./src`) discovers these
652
+ * definitions automatically — no barrel file needed.
653
+ *
654
+ * - For `type: 'inline_ui'` tools: provide `render` (no `execute`).
655
+ * - For all other tool types: provide `execute` (no `render`).
656
+ *
657
+ * @template TInput - Type of the input object passed to `execute`
658
+ * or provided to the `render` component by the AI agent.
659
+ */
660
+ export type ToolSchema<TInput = Record<string, unknown>> = InlineUIToolSchema<TInput> | ExecutableToolSchema<TInput>;
604
661
  /** @deprecated Use ToolType instead */
605
662
  export type ActionType = ToolType;
606
663
  /** @deprecated Use ToolDataSchemaProperty instead */
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Individual Tooltip Component
3
+ * Handles rendering and positioning of a single tooltip
4
+ */
5
+ import type { TooltipData } from '../api/client';
6
+ import type { TooltipTrigger, TooltipPosition } from '../core/config';
7
+ export interface TooltipOptions {
8
+ trigger: TooltipTrigger;
9
+ position: TooltipPosition;
10
+ onLearnMore?: (articleSlug: string) => void;
11
+ onShow?: () => void;
12
+ onHide?: () => void;
13
+ }
14
+ export declare class Tooltip {
15
+ private id;
16
+ private data;
17
+ private anchor;
18
+ private options;
19
+ private element;
20
+ private arrow;
21
+ private iconElement;
22
+ private isVisible;
23
+ private hideTimeout;
24
+ constructor(data: TooltipData, anchor: HTMLElement, options: TooltipOptions);
25
+ /**
26
+ * Initialize the tooltip
27
+ */
28
+ init(): void;
29
+ /**
30
+ * Show the tooltip
31
+ */
32
+ show(): void;
33
+ /**
34
+ * Hide the tooltip
35
+ */
36
+ hide(): void;
37
+ /**
38
+ * Toggle tooltip visibility
39
+ */
40
+ toggle(): void;
41
+ /**
42
+ * Update tooltip position
43
+ */
44
+ updatePosition(): void;
45
+ /**
46
+ * Destroy the tooltip
47
+ */
48
+ destroy(): void;
49
+ private createElement;
50
+ private createIcon;
51
+ private bindEvents;
52
+ private unbindEvents;
53
+ private handleMouseEnter;
54
+ private handleTooltipMouseEnter;
55
+ private handleMouseLeave;
56
+ private handleClick;
57
+ private handleDocumentClick;
58
+ private handleFocus;
59
+ private handleBlur;
60
+ private handleKeyDown;
61
+ private handleScroll;
62
+ private handleResize;
63
+ }
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Tooltip Manager
3
+ * Scans DOM for tooltip elements and manages their lifecycle
4
+ */
5
+ import type { EventEmitter } from '../core/events';
6
+ import type { ResolvedConfig } from '../core/config';
7
+ import type { APIClient } from '../api/client';
8
+ export declare class TooltipManager {
9
+ private config;
10
+ private api;
11
+ private events;
12
+ private tooltips;
13
+ private tooltipData;
14
+ private observer;
15
+ private stylesInjected;
16
+ constructor(config: ResolvedConfig, api: APIClient, events: EventEmitter);
17
+ /**
18
+ * Initialize the tooltip manager
19
+ */
20
+ init(): Promise<void>;
21
+ /**
22
+ * Scan DOM for tooltip elements and initialize them
23
+ */
24
+ scan(): Promise<void>;
25
+ /**
26
+ * Show a specific tooltip
27
+ */
28
+ show(tooltipId: string): void;
29
+ /**
30
+ * Hide a specific tooltip
31
+ */
32
+ hide(tooltipId: string): void;
33
+ /**
34
+ * Destroy the tooltip manager
35
+ */
36
+ destroy(): void;
37
+ private createTooltip;
38
+ private setupObserver;
39
+ private handleRemovedElement;
40
+ private getElementKey;
41
+ private getTooltipDataForElement;
42
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Tooltip CSS Styles
3
+ * Injected into the document head
4
+ */
5
+ export declare const TOOLTIP_STYLES = "\n/* Pillar Tooltip Styles */\n.pillar-tooltip {\n position: absolute;\n z-index: 99999;\n max-width: 320px;\n padding: 12px 16px;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;\n font-size: 14px;\n line-height: 1.5;\n color: #1a1a1a;\n background: #ffffff;\n border-radius: 8px;\n box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.05);\n pointer-events: auto;\n opacity: 0;\n transform: scale(0.95);\n transition: opacity 0.15s ease, transform 0.15s ease;\n}\n\n.pillar-tooltip.pillar-tooltip--visible {\n opacity: 1;\n transform: scale(1);\n}\n\n.pillar-tooltip__content {\n margin: 0;\n}\n\n.pillar-tooltip__content p {\n margin: 0 0 8px;\n}\n\n.pillar-tooltip__content p:last-child {\n margin-bottom: 0;\n}\n\n.pillar-tooltip__content a {\n color: #2563eb;\n text-decoration: none;\n}\n\n.pillar-tooltip__content a:hover {\n text-decoration: underline;\n}\n\n.pillar-tooltip__learn-more {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n margin-top: 12px;\n padding: 6px 12px;\n font-size: 13px;\n font-weight: 500;\n color: #2563eb;\n background: #eff6ff;\n border: none;\n border-radius: 6px;\n cursor: pointer;\n transition: background 0.15s ease;\n}\n\n.pillar-tooltip__learn-more:hover {\n background: #dbeafe;\n}\n\n.pillar-tooltip__learn-more svg {\n width: 14px;\n height: 14px;\n}\n\n/* Arrow */\n.pillar-tooltip__arrow {\n position: absolute;\n width: 12px;\n height: 12px;\n background: #ffffff;\n transform: rotate(45deg);\n box-shadow: -1px -1px 0 0 rgba(0, 0, 0, 0.05);\n}\n\n.pillar-tooltip--top .pillar-tooltip__arrow {\n bottom: -6px;\n box-shadow: 1px 1px 0 0 rgba(0, 0, 0, 0.05);\n}\n\n.pillar-tooltip--bottom .pillar-tooltip__arrow {\n top: -6px;\n}\n\n.pillar-tooltip--left .pillar-tooltip__arrow {\n right: -6px;\n box-shadow: 1px -1px 0 0 rgba(0, 0, 0, 0.05);\n}\n\n.pillar-tooltip--right .pillar-tooltip__arrow {\n left: -6px;\n box-shadow: -1px 1px 0 0 rgba(0, 0, 0, 0.05);\n}\n\n/* Tooltip Icon (for icon trigger) */\n.pillar-tooltip-icon {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 16px;\n height: 16px;\n margin-left: 4px;\n vertical-align: middle;\n color: #6b7280;\n cursor: help;\n transition: color 0.15s ease;\n}\n\n.pillar-tooltip-icon:hover {\n color: #2563eb;\n}\n\n.pillar-tooltip-icon svg {\n width: 100%;\n height: 100%;\n}\n\n/* Close button */\n.pillar-tooltip__close {\n position: absolute;\n top: 8px;\n right: 8px;\n display: flex;\n align-items: center;\n justify-content: center;\n width: 20px;\n height: 20px;\n padding: 0;\n color: #9ca3af;\n background: none;\n border: none;\n border-radius: 4px;\n cursor: pointer;\n transition: color 0.15s ease, background 0.15s ease;\n}\n\n.pillar-tooltip__close:hover {\n color: #1a1a1a;\n background: #f3f4f6;\n}\n\n.pillar-tooltip__close svg {\n width: 12px;\n height: 12px;\n}\n";
@@ -0,0 +1,96 @@
1
+ /**
2
+ * UI Scanner Configuration
3
+ *
4
+ * Configuration options for the UI scanning system.
5
+ */
6
+ /**
7
+ * Configuration for the UI Scanner.
8
+ */
9
+ export interface UIScannerConfig {
10
+ /**
11
+ * Enable automatic UI scanning.
12
+ * When true, the page is scanned on init and after interactions.
13
+ * @default true
14
+ */
15
+ enabled: boolean;
16
+ /**
17
+ * CSS selectors for containers to scan.
18
+ * Only elements within these containers will be included.
19
+ * Use ['body'] to scan the entire page.
20
+ * @default ['body']
21
+ */
22
+ includeSelectors: string[];
23
+ /**
24
+ * CSS selectors to exclude from scanning.
25
+ * Elements matching these selectors (or within them) will be skipped.
26
+ * @default []
27
+ */
28
+ excludeSelectors: string[];
29
+ /**
30
+ * Automatically exclude sensitive elements.
31
+ * When true, password fields, payment forms, etc. are excluded.
32
+ * @default true
33
+ */
34
+ excludeSensitive: boolean;
35
+ /**
36
+ * Additional selectors for sensitive elements to exclude.
37
+ * These are added to the default sensitive selectors.
38
+ * @default []
39
+ */
40
+ sensitiveSelectors: string[];
41
+ /**
42
+ * Maximum number of elements to include in the scan.
43
+ * Elements are prioritized by visibility and interactability.
44
+ * @default 100
45
+ */
46
+ maxElements: number;
47
+ /**
48
+ * Automatically rescan after each UI interaction.
49
+ * @default true
50
+ */
51
+ rescanAfterInteraction: boolean;
52
+ /**
53
+ * Debounce delay for rescanning in milliseconds.
54
+ * Prevents excessive scans during rapid interactions.
55
+ * @default 300
56
+ */
57
+ rescanDebounceMs: number;
58
+ /**
59
+ * Include elements that are currently not visible (scrolled out of view).
60
+ * @default false
61
+ */
62
+ includeOffscreen: boolean;
63
+ /**
64
+ * Maximum text length for element labels.
65
+ * Longer text will be truncated.
66
+ * @default 100
67
+ */
68
+ maxLabelLength: number;
69
+ /**
70
+ * Maximum text length for context extraction.
71
+ * @default 200
72
+ */
73
+ maxContextLength: number;
74
+ }
75
+ /**
76
+ * Default sensitive element selectors.
77
+ * These are excluded when excludeSensitive is true.
78
+ */
79
+ export declare const DEFAULT_SENSITIVE_SELECTORS: string[];
80
+ /**
81
+ * Default selectors for interactable elements.
82
+ * Used by the scanner to find elements to include.
83
+ */
84
+ export declare const DEFAULT_INTERACTABLE_SELECTORS: string[];
85
+ /**
86
+ * Default configuration for the UI Scanner.
87
+ */
88
+ export declare const DEFAULT_UI_SCANNER_CONFIG: UIScannerConfig;
89
+ /**
90
+ * Merge user config with defaults.
91
+ */
92
+ export declare function resolveUIScannerConfig(config?: Partial<UIScannerConfig>): UIScannerConfig;
93
+ /**
94
+ * Get all sensitive selectors (default + custom).
95
+ */
96
+ export declare function getSensitiveSelectors(config: UIScannerConfig): string[];
@@ -0,0 +1,75 @@
1
+ /**
2
+ * UI Interaction Executor
3
+ *
4
+ * Executes AI-requested interactions on DOM elements.
5
+ * Handles clicking, typing, selecting, scrolling, and other interactions.
6
+ */
7
+ import type { UIScanner } from './scanner';
8
+ import type { UIInteraction, UIInteractionResult } from './types';
9
+ /**
10
+ * Executes UI interactions on DOM elements.
11
+ */
12
+ export declare class UIInteractionExecutor {
13
+ private scanner;
14
+ constructor(scanner: UIScanner);
15
+ /**
16
+ * Execute a UI interaction.
17
+ */
18
+ execute(interaction: UIInteraction): Promise<UIInteractionResult>;
19
+ /**
20
+ * Find an element by its Pillar ID.
21
+ */
22
+ private findElement;
23
+ /**
24
+ * Wait for an element to become visible.
25
+ */
26
+ private waitForVisible;
27
+ /**
28
+ * Check if an element is visible.
29
+ */
30
+ private isVisible;
31
+ /**
32
+ * Scroll an element into view.
33
+ */
34
+ private scrollIntoView;
35
+ /**
36
+ * Click on an element.
37
+ */
38
+ private click;
39
+ /**
40
+ * Type text into an input element.
41
+ */
42
+ private type;
43
+ /**
44
+ * Select an option from a select element.
45
+ */
46
+ private select;
47
+ /**
48
+ * Scroll to an element.
49
+ */
50
+ private scroll;
51
+ /**
52
+ * Hover over an element.
53
+ */
54
+ private hover;
55
+ /**
56
+ * Focus an element.
57
+ */
58
+ private focus;
59
+ /**
60
+ * Clear an input element's value.
61
+ */
62
+ private clear;
63
+ /**
64
+ * Create an error result.
65
+ */
66
+ private errorResult;
67
+ /**
68
+ * Sleep for a given number of milliseconds.
69
+ */
70
+ private sleep;
71
+ /**
72
+ * Flush microtasks to allow React/Vue state updates.
73
+ */
74
+ private flushMicrotasks;
75
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * UI Interaction Module
3
+ *
4
+ * Exports for the UI scanning and interaction system.
5
+ */
6
+ export type { UIElement, UIElementRect, UIElementSummary, UIElementType, UIInteraction, UIInteractionOptions, UIInteractionResult, UIInteractionType, UIPageState, UIScrollPosition, } from './types';
7
+ export { toElementSummary, toPageStateSummary } from './types';
8
+ export type { UIScannerConfig } from './config';
9
+ export { DEFAULT_INTERACTABLE_SELECTORS, DEFAULT_SENSITIVE_SELECTORS, DEFAULT_UI_SCANNER_CONFIG, getSensitiveSelectors, resolveUIScannerConfig, } from './config';
10
+ export { UIScanner } from './scanner';
11
+ export { UIInteractionExecutor } from './executor';
@@ -0,0 +1,105 @@
1
+ /**
2
+ * UI Scanner
3
+ *
4
+ * Scans the DOM for interactable elements and builds a structured
5
+ * representation of the page's UI state for AI understanding.
6
+ */
7
+ import { type UIScannerConfig } from './config';
8
+ import type { UIPageState } from './types';
9
+ /**
10
+ * Scans the page for interactable UI elements.
11
+ */
12
+ export declare class UIScanner {
13
+ private config;
14
+ private elementIdCounter;
15
+ private elementMap;
16
+ constructor(config: UIScannerConfig);
17
+ /**
18
+ * Update scanner configuration.
19
+ */
20
+ updateConfig(config: Partial<UIScannerConfig>): void;
21
+ /**
22
+ * Scan the page and return the UI state.
23
+ */
24
+ scan(): UIPageState;
25
+ /**
26
+ * Get an element by its Pillar ID.
27
+ */
28
+ getElementById(id: string): HTMLElement | null;
29
+ /**
30
+ * Find all interactable elements on the page.
31
+ */
32
+ private findElements;
33
+ /**
34
+ * Get containers to scan based on config.
35
+ */
36
+ private getContainers;
37
+ /**
38
+ * Check if element is in an excluded area.
39
+ */
40
+ private isExcluded;
41
+ /**
42
+ * Check if element is sensitive (should be excluded for security).
43
+ */
44
+ private isSensitive;
45
+ /**
46
+ * Check if element is visible.
47
+ */
48
+ private isVisible;
49
+ /**
50
+ * Convert an HTML element to a UIElement.
51
+ */
52
+ private elementToUIElement;
53
+ /**
54
+ * Generate a unique ID for an element.
55
+ */
56
+ private generateId;
57
+ /**
58
+ * Determine the semantic type of an element.
59
+ */
60
+ private getElementType;
61
+ /**
62
+ * Get the available interactions for an element.
63
+ */
64
+ private getInteractions;
65
+ /**
66
+ * Extract a human-readable label for an element.
67
+ */
68
+ private extractLabel;
69
+ /**
70
+ * Extract context from surrounding elements.
71
+ */
72
+ private extractContext;
73
+ /**
74
+ * Check if element is disabled.
75
+ */
76
+ private isDisabled;
77
+ /**
78
+ * Get element bounding rectangle.
79
+ */
80
+ private getRect;
81
+ /**
82
+ * Get relevant attributes from element.
83
+ */
84
+ private getRelevantAttributes;
85
+ /**
86
+ * Generate XPath for element.
87
+ */
88
+ private getXPath;
89
+ /**
90
+ * Get the ID of the currently focused element.
91
+ */
92
+ private getFocusedElementId;
93
+ /**
94
+ * Get current scroll position.
95
+ */
96
+ private getScrollPosition;
97
+ /**
98
+ * Truncate text to max length.
99
+ */
100
+ private truncate;
101
+ /**
102
+ * Convert camelCase/snake_case name to human readable.
103
+ */
104
+ private humanizeName;
105
+ }