@surfableai/widget 0.1.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.
- package/README.md +62 -0
- package/dist/index.d.mts +174 -0
- package/dist/index.d.ts +174 -0
- package/dist/index.js +17371 -0
- package/dist/index.mjs +17327 -0
- package/package.json +43 -0
package/README.md
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# @surfableai/widget
|
|
2
|
+
|
|
3
|
+
React components for embedding Surfable Search and Agent functionality directly into your application.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @surfableai/widget
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Honest Security Note
|
|
12
|
+
|
|
13
|
+
**Important:** If using an API key in client-side code (inside the browser), you **must** use a key of type `public`.
|
|
14
|
+
A `public` key is safe when the indexed content is already public. Customers indexing private/sensitive content **must** use a `private` key strictly from their own backend server.
|
|
15
|
+
|
|
16
|
+
CORS `allowed_origins` stops browser-based abuse but does **not** stop a `curl` request — `Origin` headers are trivially spoofed server-side. Do not expose private keys!
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
```tsx
|
|
21
|
+
import { SurfableSearchBox, SurfableAgentWidget } from '@surfableai/widget';
|
|
22
|
+
|
|
23
|
+
export function Application() {
|
|
24
|
+
return (
|
|
25
|
+
<div>
|
|
26
|
+
{/* Search Component */}
|
|
27
|
+
<SurfableSearchBox apiKey="pk_YOUR_PUBLIC_KEY" apiBaseUrl="https://api.surfable.ai" routingEnabled={true} />
|
|
28
|
+
|
|
29
|
+
{/* Agent Widget */}
|
|
30
|
+
<SurfableAgentWidget apiKey="pk_YOUR_PUBLIC_KEY" apiBaseUrl="https://api.surfable.ai" routingEnabled={true} showFeedback={true} />
|
|
31
|
+
</div>
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
`apiBaseUrl` is **required** — pass your Surfable API host explicitly (the canonical host is `https://api.surfable.ai`). There is no default, so a missing value is a build-time type error rather than a silent fall-through to production (issue #253).
|
|
37
|
+
|
|
38
|
+
> **Note:** `SurfableChatWidget` is available as a deprecated alias for `SurfableAgentWidget`. It will be removed in the next major version. Migrate to `SurfableAgentWidget`.
|
|
39
|
+
|
|
40
|
+
### Branding (UI Studio)
|
|
41
|
+
|
|
42
|
+
Both widgets auto-fetch tenant branding from `GET /branding` using the API key when they mount. The response (colors, font, radius, density, logo, custom CSS) is applied via `--surfable-*` CSS custom properties and a scoped stylesheet link on the widget root, so changes saved in the dashboard's UI Studio propagate to every embed without redeploying.
|
|
43
|
+
|
|
44
|
+
Precedence (highest first):
|
|
45
|
+
|
|
46
|
+
1. Explicit `theme` prop on `<SurfableSearchBox>` / `<SurfableAgentWidget>` (or `theme-*` attributes on `<surfable-search>` / `<surfable-agent>`).
|
|
47
|
+
2. Legacy `primaryColor` prop on `<SurfableAgentWidget>` (still honoured, but `theme.primaryColor` is preferred).
|
|
48
|
+
3. Branding fetched from `GET /branding` at mount time.
|
|
49
|
+
4. Surfable defaults (teal palette, Inter, medium radius, comfortable density).
|
|
50
|
+
|
|
51
|
+
```tsx
|
|
52
|
+
// Per-page override:
|
|
53
|
+
<SurfableSearchBox apiKey="pk_…" theme={{ primaryColor: '#0F766E', radius: 'lg' }} />
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
If the fetch fails (network error, no allowed origin), the widget falls back to defaults and renders normally — branding is non-fatal.
|
|
57
|
+
|
|
58
|
+
### Widget Routing
|
|
59
|
+
|
|
60
|
+
By default, all widget components automatically pass `originating_url: window.location.href` in their API requests. This enables **Widget Routing Rules** configured in your Surfable dashboard, allowing you to serve different modes (Search or Agent) or system prompts depending on which page the widget is rendered on.
|
|
61
|
+
|
|
62
|
+
If you handle routing yourself or prefer to opt-out of this behavior, you can pass `routingEnabled={false}` to any widget component.
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
|
|
4
|
+
type BrandingFontKey = 'inter' | 'system' | 'serif' | 'mono' | 'rounded';
|
|
5
|
+
type BrandingRadiusKey = 'sm' | 'md' | 'lg';
|
|
6
|
+
type BrandingDensityKey = 'compact' | 'comfortable';
|
|
7
|
+
interface BrandingTheme {
|
|
8
|
+
primaryColor?: string;
|
|
9
|
+
secondaryColor?: string;
|
|
10
|
+
accentColor?: string;
|
|
11
|
+
fontFamily?: BrandingFontKey;
|
|
12
|
+
radius?: BrandingRadiusKey;
|
|
13
|
+
density?: BrandingDensityKey;
|
|
14
|
+
logoUrl?: string | null;
|
|
15
|
+
customCssUrl?: string | null;
|
|
16
|
+
}
|
|
17
|
+
declare const BRANDING_DEFAULTS: Required<Omit<BrandingTheme, 'logoUrl' | 'customCssUrl'>> & {
|
|
18
|
+
logoUrl: string | null;
|
|
19
|
+
customCssUrl: string | null;
|
|
20
|
+
};
|
|
21
|
+
declare function resolveTheme(explicit?: BrandingTheme, fetched?: BrandingTheme | null): Required<Omit<BrandingTheme, 'logoUrl' | 'customCssUrl'>> & {
|
|
22
|
+
logoUrl: string | null;
|
|
23
|
+
customCssUrl: string | null;
|
|
24
|
+
};
|
|
25
|
+
declare function brandingToCssVars(theme: Required<Omit<BrandingTheme, 'logoUrl' | 'customCssUrl'>> & {
|
|
26
|
+
logoUrl: string | null;
|
|
27
|
+
customCssUrl: string | null;
|
|
28
|
+
}): Record<string, string>;
|
|
29
|
+
|
|
30
|
+
type SurfableSummaryMode = 'off' | 'auto' | 'force';
|
|
31
|
+
type SurfableSummarySkippedReason = 'summary_off' | 'typeahead' | 'no_results' | 'low_relevance' | 'no_citable_sources' | 'generation_failed';
|
|
32
|
+
interface SurfableSearchBoxProps {
|
|
33
|
+
apiKey: string;
|
|
34
|
+
apiBaseUrl: string;
|
|
35
|
+
routingEnabled?: boolean;
|
|
36
|
+
onSelect?: (url: string) => void;
|
|
37
|
+
topK?: number;
|
|
38
|
+
/** Legacy flag. When set, maps to summaryMode 'force' (true) or 'off' (false). Prefer `summaryMode`. */
|
|
39
|
+
includeSummary?: boolean;
|
|
40
|
+
showSummary?: boolean;
|
|
41
|
+
showScore?: boolean;
|
|
42
|
+
suggestedQueries?: string[];
|
|
43
|
+
defaultQuery?: string;
|
|
44
|
+
autoSearchOnMount?: boolean;
|
|
45
|
+
/** Live-as-you-type results. Default: true. */
|
|
46
|
+
searchAsYouType?: boolean;
|
|
47
|
+
/** Debounce window for typeahead requests in ms. Default: 350. */
|
|
48
|
+
debounceMs?: number;
|
|
49
|
+
/** Minimum query length before any request fires. Default: 3. */
|
|
50
|
+
minQueryLength?: number;
|
|
51
|
+
/** Delay after the last keystroke before requesting an auto-summary. Default: 800. Must be >= debounceMs. */
|
|
52
|
+
summaryDelayMs?: number;
|
|
53
|
+
/** Server-side summary policy applied to submit interactions. Default: 'auto'. */
|
|
54
|
+
summaryMode?: SurfableSummaryMode;
|
|
55
|
+
/** Show the focus-only trending suggestion tray (fetched from /search/suggestions). Default: true. */
|
|
56
|
+
showSuggestionTray?: boolean;
|
|
57
|
+
/** Explicit branding overrides. When omitted, branding is auto-fetched from GET /branding using the API key. */
|
|
58
|
+
theme?: BrandingTheme;
|
|
59
|
+
/** Fires on every keystroke. Used by composition wrappers (e.g. Hybrid) that need to mirror the current query. */
|
|
60
|
+
onQueryChange?: (query: string) => void;
|
|
61
|
+
/** Element rendered immediately to the right of the Search submit button. Used by composition wrappers (e.g. Hybrid's Ask AI). */
|
|
62
|
+
trailingAction?: React.ReactNode;
|
|
63
|
+
}
|
|
64
|
+
declare function SurfableSearchBox({ apiKey, apiBaseUrl, routingEnabled, onSelect, topK, includeSummary, showSummary, showScore, suggestedQueries, defaultQuery, autoSearchOnMount, searchAsYouType, debounceMs, minQueryLength, summaryDelayMs, summaryMode, showSuggestionTray, theme, onQueryChange, trailingAction, }: SurfableSearchBoxProps): react_jsx_runtime.JSX.Element;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Wait-state copy for a tool call (#848): "Searching your content…", never the raw
|
|
68
|
+
* `retrieve_context` identifier. `displayName` is resolved server-side (tenant override,
|
|
69
|
+
* then a shipped present-participle default, then the raw tool name) — this only formats
|
|
70
|
+
* it for the two states the widget renders while streaming.
|
|
71
|
+
*/
|
|
72
|
+
declare function formatToolWaitLabel(status: 'running' | 'done' | 'error', displayName?: string, toolName?: string): string;
|
|
73
|
+
interface SurfableAgentWidgetProps {
|
|
74
|
+
apiKey: string;
|
|
75
|
+
apiBaseUrl: string;
|
|
76
|
+
routingEnabled?: boolean;
|
|
77
|
+
/** Title shown in the widget header */
|
|
78
|
+
title?: string;
|
|
79
|
+
/** Placeholder text for the input field */
|
|
80
|
+
placeholder?: string;
|
|
81
|
+
/** Whether to show reasoning steps */
|
|
82
|
+
showReasoning?: boolean;
|
|
83
|
+
/** Primary color for the widget. @deprecated Pass `theme.primaryColor` instead. */
|
|
84
|
+
primaryColor?: string;
|
|
85
|
+
/** Explicit branding overrides. When omitted, branding is auto-fetched from GET /branding using the API key. */
|
|
86
|
+
theme?: BrandingTheme;
|
|
87
|
+
/** Whether to show thumbs up/down feedback on completed assistant responses */
|
|
88
|
+
showFeedback?: boolean;
|
|
89
|
+
/** Callback when the agent completes a response */
|
|
90
|
+
onResponse?: (answer: string, sources: Array<{
|
|
91
|
+
url: string;
|
|
92
|
+
title: string;
|
|
93
|
+
}>) => void;
|
|
94
|
+
/** Prefill the input field with this value on mount. The user still has to press Send — no auto-submit. */
|
|
95
|
+
initialInput?: string;
|
|
96
|
+
}
|
|
97
|
+
declare function submitAgentFeedback(apiBaseUrl: string, apiKey: string, messageId: string, rating: 'up' | 'down'): Promise<void>;
|
|
98
|
+
declare function SurfableAgentWidget({ apiKey, apiBaseUrl, routingEnabled, title, placeholder, showReasoning, primaryColor, theme, showFeedback, onResponse, initialInput, }: SurfableAgentWidgetProps): react_jsx_runtime.JSX.Element;
|
|
99
|
+
|
|
100
|
+
interface SurfableHybridWidgetProps {
|
|
101
|
+
apiKey: string;
|
|
102
|
+
apiBaseUrl: string;
|
|
103
|
+
routingEnabled?: boolean;
|
|
104
|
+
theme?: BrandingTheme;
|
|
105
|
+
/** Pass-through props to the embedded SurfableSearchBox (overrides defaults). */
|
|
106
|
+
searchProps?: Omit<SurfableSearchBoxProps, 'apiKey' | 'apiBaseUrl' | 'theme' | 'onQueryChange' | 'trailingAction' | 'routingEnabled'>;
|
|
107
|
+
/** Pass-through props to the embedded SurfableAgentWidget (overrides defaults). */
|
|
108
|
+
agentProps?: Omit<SurfableAgentWidgetProps, 'apiKey' | 'apiBaseUrl' | 'theme' | 'initialInput' | 'routingEnabled'>;
|
|
109
|
+
/** Copy on the search-side trigger that escalates into Agent Chat. Default: "Ask AI". */
|
|
110
|
+
askLabel?: string;
|
|
111
|
+
/** Copy on the chat-side back affordance. Default: "Back to search". */
|
|
112
|
+
backLabel?: string;
|
|
113
|
+
}
|
|
114
|
+
declare function SurfableHybridWidget({ apiKey, apiBaseUrl, routingEnabled, theme, searchProps, agentProps, askLabel, backLabel, }: SurfableHybridWidgetProps): react_jsx_runtime.JSX.Element;
|
|
115
|
+
|
|
116
|
+
interface SurfableFloatingAgentLauncherProps {
|
|
117
|
+
apiKey: string;
|
|
118
|
+
apiBaseUrl: string;
|
|
119
|
+
routingEnabled?: boolean;
|
|
120
|
+
theme?: BrandingTheme;
|
|
121
|
+
/** Pass-through props to the embedded SurfableAgentWidget. */
|
|
122
|
+
agentProps?: Omit<SurfableAgentWidgetProps, 'apiKey' | 'apiBaseUrl' | 'theme' | 'routingEnabled'>;
|
|
123
|
+
/** Launcher button copy. Default: "Chat". */
|
|
124
|
+
launcherLabel?: string;
|
|
125
|
+
/** Distance from the viewport edge in px. Default: 24. */
|
|
126
|
+
offset?: number;
|
|
127
|
+
/** Whether the panel is open on first mount. Default: false. */
|
|
128
|
+
defaultOpen?: boolean;
|
|
129
|
+
/** Optional fixed z-index for the launcher + panel. Default: 9999. */
|
|
130
|
+
zIndex?: number;
|
|
131
|
+
}
|
|
132
|
+
declare function SurfableFloatingAgentLauncher({ apiKey, apiBaseUrl, routingEnabled, theme, agentProps, launcherLabel, offset, defaultOpen, zIndex, }: SurfableFloatingAgentLauncherProps): react_jsx_runtime.JSX.Element;
|
|
133
|
+
|
|
134
|
+
interface SurfableRightPaneLayoutProps {
|
|
135
|
+
apiKey: string;
|
|
136
|
+
apiBaseUrl: string;
|
|
137
|
+
routingEnabled?: boolean;
|
|
138
|
+
theme?: BrandingTheme;
|
|
139
|
+
/** Pass-through props to the embedded SurfableAgentWidget. */
|
|
140
|
+
agentProps?: Omit<SurfableAgentWidgetProps, 'apiKey' | 'apiBaseUrl' | 'theme' | 'routingEnabled'>;
|
|
141
|
+
/** Page content rendered to the left of the pane. */
|
|
142
|
+
children: React.ReactNode;
|
|
143
|
+
/** Width of the pane in px. Default: 380. */
|
|
144
|
+
paneWidth?: number;
|
|
145
|
+
/** Whether the pane is open on first mount. Default: true. */
|
|
146
|
+
defaultOpen?: boolean;
|
|
147
|
+
/** Title shown in the pane header. Default: "Agent". */
|
|
148
|
+
title?: string;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Layout wrapper that reserves a column for an inline Agent Chat pane on the
|
|
152
|
+
* right side of the page. Uses CSS grid so the main content reflows when the
|
|
153
|
+
* pane is collapsed — does not globally mutate the host page's `body` styles.
|
|
154
|
+
*/
|
|
155
|
+
declare function SurfableRightPaneLayout({ apiKey, apiBaseUrl, routingEnabled, theme, agentProps, children, paneWidth, defaultOpen, title, }: SurfableRightPaneLayoutProps): react_jsx_runtime.JSX.Element;
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Session management utilities for Surfable widgets.
|
|
159
|
+
* Handles x-session-id persistence and propagation (MEM.11).
|
|
160
|
+
*/
|
|
161
|
+
/**
|
|
162
|
+
* Get the current session ID from sessionStorage.
|
|
163
|
+
*/
|
|
164
|
+
declare function getSessionId(): string | null;
|
|
165
|
+
/**
|
|
166
|
+
* Save a session ID to sessionStorage.
|
|
167
|
+
*/
|
|
168
|
+
declare function setSessionId(sessionId: string): void;
|
|
169
|
+
/**
|
|
170
|
+
* Clear the stored session ID.
|
|
171
|
+
*/
|
|
172
|
+
declare function clearSessionId(): void;
|
|
173
|
+
|
|
174
|
+
export { BRANDING_DEFAULTS, type BrandingDensityKey, type BrandingFontKey, type BrandingRadiusKey, type BrandingTheme, SurfableAgentWidget, type SurfableAgentWidgetProps, SurfableAgentWidget as SurfableChatWidget, SurfableFloatingAgentLauncher, type SurfableFloatingAgentLauncherProps, SurfableHybridWidget, type SurfableHybridWidgetProps, SurfableRightPaneLayout, type SurfableRightPaneLayoutProps, SurfableSearchBox, type SurfableSearchBoxProps, type SurfableSummaryMode, type SurfableSummarySkippedReason, brandingToCssVars, clearSessionId, formatToolWaitLabel, getSessionId, resolveTheme, setSessionId, submitAgentFeedback };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
|
|
4
|
+
type BrandingFontKey = 'inter' | 'system' | 'serif' | 'mono' | 'rounded';
|
|
5
|
+
type BrandingRadiusKey = 'sm' | 'md' | 'lg';
|
|
6
|
+
type BrandingDensityKey = 'compact' | 'comfortable';
|
|
7
|
+
interface BrandingTheme {
|
|
8
|
+
primaryColor?: string;
|
|
9
|
+
secondaryColor?: string;
|
|
10
|
+
accentColor?: string;
|
|
11
|
+
fontFamily?: BrandingFontKey;
|
|
12
|
+
radius?: BrandingRadiusKey;
|
|
13
|
+
density?: BrandingDensityKey;
|
|
14
|
+
logoUrl?: string | null;
|
|
15
|
+
customCssUrl?: string | null;
|
|
16
|
+
}
|
|
17
|
+
declare const BRANDING_DEFAULTS: Required<Omit<BrandingTheme, 'logoUrl' | 'customCssUrl'>> & {
|
|
18
|
+
logoUrl: string | null;
|
|
19
|
+
customCssUrl: string | null;
|
|
20
|
+
};
|
|
21
|
+
declare function resolveTheme(explicit?: BrandingTheme, fetched?: BrandingTheme | null): Required<Omit<BrandingTheme, 'logoUrl' | 'customCssUrl'>> & {
|
|
22
|
+
logoUrl: string | null;
|
|
23
|
+
customCssUrl: string | null;
|
|
24
|
+
};
|
|
25
|
+
declare function brandingToCssVars(theme: Required<Omit<BrandingTheme, 'logoUrl' | 'customCssUrl'>> & {
|
|
26
|
+
logoUrl: string | null;
|
|
27
|
+
customCssUrl: string | null;
|
|
28
|
+
}): Record<string, string>;
|
|
29
|
+
|
|
30
|
+
type SurfableSummaryMode = 'off' | 'auto' | 'force';
|
|
31
|
+
type SurfableSummarySkippedReason = 'summary_off' | 'typeahead' | 'no_results' | 'low_relevance' | 'no_citable_sources' | 'generation_failed';
|
|
32
|
+
interface SurfableSearchBoxProps {
|
|
33
|
+
apiKey: string;
|
|
34
|
+
apiBaseUrl: string;
|
|
35
|
+
routingEnabled?: boolean;
|
|
36
|
+
onSelect?: (url: string) => void;
|
|
37
|
+
topK?: number;
|
|
38
|
+
/** Legacy flag. When set, maps to summaryMode 'force' (true) or 'off' (false). Prefer `summaryMode`. */
|
|
39
|
+
includeSummary?: boolean;
|
|
40
|
+
showSummary?: boolean;
|
|
41
|
+
showScore?: boolean;
|
|
42
|
+
suggestedQueries?: string[];
|
|
43
|
+
defaultQuery?: string;
|
|
44
|
+
autoSearchOnMount?: boolean;
|
|
45
|
+
/** Live-as-you-type results. Default: true. */
|
|
46
|
+
searchAsYouType?: boolean;
|
|
47
|
+
/** Debounce window for typeahead requests in ms. Default: 350. */
|
|
48
|
+
debounceMs?: number;
|
|
49
|
+
/** Minimum query length before any request fires. Default: 3. */
|
|
50
|
+
minQueryLength?: number;
|
|
51
|
+
/** Delay after the last keystroke before requesting an auto-summary. Default: 800. Must be >= debounceMs. */
|
|
52
|
+
summaryDelayMs?: number;
|
|
53
|
+
/** Server-side summary policy applied to submit interactions. Default: 'auto'. */
|
|
54
|
+
summaryMode?: SurfableSummaryMode;
|
|
55
|
+
/** Show the focus-only trending suggestion tray (fetched from /search/suggestions). Default: true. */
|
|
56
|
+
showSuggestionTray?: boolean;
|
|
57
|
+
/** Explicit branding overrides. When omitted, branding is auto-fetched from GET /branding using the API key. */
|
|
58
|
+
theme?: BrandingTheme;
|
|
59
|
+
/** Fires on every keystroke. Used by composition wrappers (e.g. Hybrid) that need to mirror the current query. */
|
|
60
|
+
onQueryChange?: (query: string) => void;
|
|
61
|
+
/** Element rendered immediately to the right of the Search submit button. Used by composition wrappers (e.g. Hybrid's Ask AI). */
|
|
62
|
+
trailingAction?: React.ReactNode;
|
|
63
|
+
}
|
|
64
|
+
declare function SurfableSearchBox({ apiKey, apiBaseUrl, routingEnabled, onSelect, topK, includeSummary, showSummary, showScore, suggestedQueries, defaultQuery, autoSearchOnMount, searchAsYouType, debounceMs, minQueryLength, summaryDelayMs, summaryMode, showSuggestionTray, theme, onQueryChange, trailingAction, }: SurfableSearchBoxProps): react_jsx_runtime.JSX.Element;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Wait-state copy for a tool call (#848): "Searching your content…", never the raw
|
|
68
|
+
* `retrieve_context` identifier. `displayName` is resolved server-side (tenant override,
|
|
69
|
+
* then a shipped present-participle default, then the raw tool name) — this only formats
|
|
70
|
+
* it for the two states the widget renders while streaming.
|
|
71
|
+
*/
|
|
72
|
+
declare function formatToolWaitLabel(status: 'running' | 'done' | 'error', displayName?: string, toolName?: string): string;
|
|
73
|
+
interface SurfableAgentWidgetProps {
|
|
74
|
+
apiKey: string;
|
|
75
|
+
apiBaseUrl: string;
|
|
76
|
+
routingEnabled?: boolean;
|
|
77
|
+
/** Title shown in the widget header */
|
|
78
|
+
title?: string;
|
|
79
|
+
/** Placeholder text for the input field */
|
|
80
|
+
placeholder?: string;
|
|
81
|
+
/** Whether to show reasoning steps */
|
|
82
|
+
showReasoning?: boolean;
|
|
83
|
+
/** Primary color for the widget. @deprecated Pass `theme.primaryColor` instead. */
|
|
84
|
+
primaryColor?: string;
|
|
85
|
+
/** Explicit branding overrides. When omitted, branding is auto-fetched from GET /branding using the API key. */
|
|
86
|
+
theme?: BrandingTheme;
|
|
87
|
+
/** Whether to show thumbs up/down feedback on completed assistant responses */
|
|
88
|
+
showFeedback?: boolean;
|
|
89
|
+
/** Callback when the agent completes a response */
|
|
90
|
+
onResponse?: (answer: string, sources: Array<{
|
|
91
|
+
url: string;
|
|
92
|
+
title: string;
|
|
93
|
+
}>) => void;
|
|
94
|
+
/** Prefill the input field with this value on mount. The user still has to press Send — no auto-submit. */
|
|
95
|
+
initialInput?: string;
|
|
96
|
+
}
|
|
97
|
+
declare function submitAgentFeedback(apiBaseUrl: string, apiKey: string, messageId: string, rating: 'up' | 'down'): Promise<void>;
|
|
98
|
+
declare function SurfableAgentWidget({ apiKey, apiBaseUrl, routingEnabled, title, placeholder, showReasoning, primaryColor, theme, showFeedback, onResponse, initialInput, }: SurfableAgentWidgetProps): react_jsx_runtime.JSX.Element;
|
|
99
|
+
|
|
100
|
+
interface SurfableHybridWidgetProps {
|
|
101
|
+
apiKey: string;
|
|
102
|
+
apiBaseUrl: string;
|
|
103
|
+
routingEnabled?: boolean;
|
|
104
|
+
theme?: BrandingTheme;
|
|
105
|
+
/** Pass-through props to the embedded SurfableSearchBox (overrides defaults). */
|
|
106
|
+
searchProps?: Omit<SurfableSearchBoxProps, 'apiKey' | 'apiBaseUrl' | 'theme' | 'onQueryChange' | 'trailingAction' | 'routingEnabled'>;
|
|
107
|
+
/** Pass-through props to the embedded SurfableAgentWidget (overrides defaults). */
|
|
108
|
+
agentProps?: Omit<SurfableAgentWidgetProps, 'apiKey' | 'apiBaseUrl' | 'theme' | 'initialInput' | 'routingEnabled'>;
|
|
109
|
+
/** Copy on the search-side trigger that escalates into Agent Chat. Default: "Ask AI". */
|
|
110
|
+
askLabel?: string;
|
|
111
|
+
/** Copy on the chat-side back affordance. Default: "Back to search". */
|
|
112
|
+
backLabel?: string;
|
|
113
|
+
}
|
|
114
|
+
declare function SurfableHybridWidget({ apiKey, apiBaseUrl, routingEnabled, theme, searchProps, agentProps, askLabel, backLabel, }: SurfableHybridWidgetProps): react_jsx_runtime.JSX.Element;
|
|
115
|
+
|
|
116
|
+
interface SurfableFloatingAgentLauncherProps {
|
|
117
|
+
apiKey: string;
|
|
118
|
+
apiBaseUrl: string;
|
|
119
|
+
routingEnabled?: boolean;
|
|
120
|
+
theme?: BrandingTheme;
|
|
121
|
+
/** Pass-through props to the embedded SurfableAgentWidget. */
|
|
122
|
+
agentProps?: Omit<SurfableAgentWidgetProps, 'apiKey' | 'apiBaseUrl' | 'theme' | 'routingEnabled'>;
|
|
123
|
+
/** Launcher button copy. Default: "Chat". */
|
|
124
|
+
launcherLabel?: string;
|
|
125
|
+
/** Distance from the viewport edge in px. Default: 24. */
|
|
126
|
+
offset?: number;
|
|
127
|
+
/** Whether the panel is open on first mount. Default: false. */
|
|
128
|
+
defaultOpen?: boolean;
|
|
129
|
+
/** Optional fixed z-index for the launcher + panel. Default: 9999. */
|
|
130
|
+
zIndex?: number;
|
|
131
|
+
}
|
|
132
|
+
declare function SurfableFloatingAgentLauncher({ apiKey, apiBaseUrl, routingEnabled, theme, agentProps, launcherLabel, offset, defaultOpen, zIndex, }: SurfableFloatingAgentLauncherProps): react_jsx_runtime.JSX.Element;
|
|
133
|
+
|
|
134
|
+
interface SurfableRightPaneLayoutProps {
|
|
135
|
+
apiKey: string;
|
|
136
|
+
apiBaseUrl: string;
|
|
137
|
+
routingEnabled?: boolean;
|
|
138
|
+
theme?: BrandingTheme;
|
|
139
|
+
/** Pass-through props to the embedded SurfableAgentWidget. */
|
|
140
|
+
agentProps?: Omit<SurfableAgentWidgetProps, 'apiKey' | 'apiBaseUrl' | 'theme' | 'routingEnabled'>;
|
|
141
|
+
/** Page content rendered to the left of the pane. */
|
|
142
|
+
children: React.ReactNode;
|
|
143
|
+
/** Width of the pane in px. Default: 380. */
|
|
144
|
+
paneWidth?: number;
|
|
145
|
+
/** Whether the pane is open on first mount. Default: true. */
|
|
146
|
+
defaultOpen?: boolean;
|
|
147
|
+
/** Title shown in the pane header. Default: "Agent". */
|
|
148
|
+
title?: string;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Layout wrapper that reserves a column for an inline Agent Chat pane on the
|
|
152
|
+
* right side of the page. Uses CSS grid so the main content reflows when the
|
|
153
|
+
* pane is collapsed — does not globally mutate the host page's `body` styles.
|
|
154
|
+
*/
|
|
155
|
+
declare function SurfableRightPaneLayout({ apiKey, apiBaseUrl, routingEnabled, theme, agentProps, children, paneWidth, defaultOpen, title, }: SurfableRightPaneLayoutProps): react_jsx_runtime.JSX.Element;
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Session management utilities for Surfable widgets.
|
|
159
|
+
* Handles x-session-id persistence and propagation (MEM.11).
|
|
160
|
+
*/
|
|
161
|
+
/**
|
|
162
|
+
* Get the current session ID from sessionStorage.
|
|
163
|
+
*/
|
|
164
|
+
declare function getSessionId(): string | null;
|
|
165
|
+
/**
|
|
166
|
+
* Save a session ID to sessionStorage.
|
|
167
|
+
*/
|
|
168
|
+
declare function setSessionId(sessionId: string): void;
|
|
169
|
+
/**
|
|
170
|
+
* Clear the stored session ID.
|
|
171
|
+
*/
|
|
172
|
+
declare function clearSessionId(): void;
|
|
173
|
+
|
|
174
|
+
export { BRANDING_DEFAULTS, type BrandingDensityKey, type BrandingFontKey, type BrandingRadiusKey, type BrandingTheme, SurfableAgentWidget, type SurfableAgentWidgetProps, SurfableAgentWidget as SurfableChatWidget, SurfableFloatingAgentLauncher, type SurfableFloatingAgentLauncherProps, SurfableHybridWidget, type SurfableHybridWidgetProps, SurfableRightPaneLayout, type SurfableRightPaneLayoutProps, SurfableSearchBox, type SurfableSearchBoxProps, type SurfableSummaryMode, type SurfableSummarySkippedReason, brandingToCssVars, clearSessionId, formatToolWaitLabel, getSessionId, resolveTheme, setSessionId, submitAgentFeedback };
|