@papermap/papermap 1.0.4 → 1.1.1

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/index.d.mts CHANGED
@@ -1,37 +1,393 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import * as React$1 from 'react';
3
- import React__default, { RefObject } from 'react';
3
+ import React__default, { ReactNode, RefObject } from 'react';
4
+ import { Layout } from 'react-grid-layout';
5
+ import { LucideIcon } from 'lucide-react';
4
6
  import * as class_variance_authority_types from 'class-variance-authority/types';
5
7
  import { VariantProps } from 'class-variance-authority';
6
8
  import * as zustand from 'zustand';
9
+ import { QueryClient } from '@tanstack/react-query';
7
10
  import * as axios from 'axios';
8
11
  import { AxiosInstance } from 'axios';
9
- import { Layout } from 'react-grid-layout';
12
+ import { DriveStep } from 'driver.js';
13
+
14
+ /** Matches main-app embedded layout (`EmbeddedLayout` / `?theme=`). */
15
+ type PapermapColorScheme = 'light' | 'dark' | 'system';
16
+
17
+ /**
18
+ * Host-supplied avatar nodes for chat message rows.
19
+ *
20
+ * A supplied node is rendered **as-is** inside a 32px-square layout slot — the
21
+ * default circle background, rounding and color are NOT applied to it, so host
22
+ * colors, gradients, images and borders are preserved across light and dark
23
+ * themes. Provide a self-contained node (e.g.
24
+ * `<img className="h-full w-full rounded-full object-cover" />` or a styled
25
+ * element using `h-full w-full`). Any slot left undefined falls back to the
26
+ * built-in icon inside the default circle.
27
+ */
28
+ interface PaperChatAvatars {
29
+ /** Replaces the built-in `User` avatar on user-role rows. */
30
+ user?: React__default.ReactNode;
31
+ /** Replaces the built-in `LogoStandAlone` avatar on assistant-role rows. */
32
+ assistant?: React__default.ReactNode;
33
+ /** Replaces the built-in `ThinkingLogo` loader shown while the assistant generates. */
34
+ thinking?: React__default.ReactNode;
35
+ }
36
+ declare function ChatAssistant({ hideChartArea, inline: inlineProp, showAvatars: showAvatarsProp, avatars, greetingMessage, }: {
37
+ hideChartArea?: boolean;
38
+ /** Sheet side panel: same as main app `inline={true}`; overrides store `assistantInline` when passed. */
39
+ inline?: boolean;
40
+ /**
41
+ * Force the user / assistant avatars to render even when `inline` (or the store's
42
+ * `assistantInline`) is true. Without this, inline mode hides avatars for a compact
43
+ * column layout. Side and dialog variants opt in so the brand/identity stays visible
44
+ * in those chrome-rich surfaces.
45
+ */
46
+ showAvatars?: boolean;
47
+ /** Override the user / assistant / thinking avatar icons. */
48
+ avatars?: PaperChatAvatars;
49
+ /**
50
+ * Optional welcome line rendered as the first assistant bubble before any
51
+ * real messages have been exchanged. Skipped automatically once the user
52
+ * sends a message or a chat is loaded with history.
53
+ */
54
+ greetingMessage?: string;
55
+ }): react_jsx_runtime.JSX.Element;
10
56
 
57
+ type PaperChatDialogLauncherPosition = 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
58
+ interface PaperChatDialogInnerProps {
59
+ hideChartArea?: boolean;
60
+ /** Primary label in the dialog header (report / slash-command style). */
61
+ dialogTitle?: string;
62
+ /** Secondary line under the title. */
63
+ dialogSubtitle?: string;
64
+ /** Controlled open state. Omit to manage open state internally (floating launcher toggles). */
65
+ dialogOpen?: boolean;
66
+ onDialogOpenChange?: (open: boolean) => void;
67
+ /** When false, hide the floating launcher (e.g. fully controlled from the host). Default true. */
68
+ showDialogLauncher?: boolean;
69
+ /** `aria-label` / `title` on the floating launcher. */
70
+ dialogLauncherAriaLabel?: string;
71
+ /** Viewport corner for the floating launcher (`fixed` inset). Default `bottom-right`. */
72
+ dialogLauncherPosition?: PaperChatDialogLauncherPosition;
73
+ className?: string;
74
+ /** Optional portal target for the sheet chart overlay (same as side panel). */
75
+ chartOverlayPortalRef?: React__default.RefObject<HTMLDivElement | null>;
76
+ onAssistantClose?: () => void;
77
+ /** Render user / assistant avatars inside the embedded chat. Defaults to `true`. */
78
+ showAvatars?: boolean;
79
+ /** Override the user / assistant / thinking avatar icons. */
80
+ avatars?: PaperChatAvatars;
81
+ /**
82
+ * Custom trigger node replacing the default floating launcher button. Wrapped
83
+ * with a `data-paper-dialog-launcher` element that toggles the dialog on click
84
+ * so any node (icon, branded button, etc.) keeps the open/close UX.
85
+ */
86
+ trigger?: React__default.ReactNode;
87
+ /** Controlled expand/collapse state for the dialog popup. */
88
+ expanded?: boolean;
89
+ /** Uncontrolled initial expanded state. Default `false`. */
90
+ defaultExpanded?: boolean;
91
+ /** Fires when the dialog toggles between default and expanded size. */
92
+ onExpandedChange?: (expanded: boolean) => void;
93
+ /**
94
+ * Greeting message rendered as the first assistant bubble before the user
95
+ * sends anything. Plain string for now; mirrors a live-chat widget welcome.
96
+ */
97
+ greetingMessage?: string;
98
+ }
99
+ /**
100
+ * Report-style chat: floating launcher button + modal shell matching the main app’s
101
+ * in-editor slash chat (header chip, MessageSquare icon, full assistant + composer).
102
+ */
103
+ declare function PaperChatDialogInner({ hideChartArea, dialogTitle, dialogSubtitle, dialogOpen: dialogOpenProp, onDialogOpenChange, showDialogLauncher, dialogLauncherAriaLabel, dialogLauncherPosition, className, chartOverlayPortalRef, onAssistantClose, showAvatars, avatars, trigger, expanded: expandedProp, defaultExpanded, onExpandedChange, greetingMessage, }: PaperChatDialogInnerProps): react_jsx_runtime.JSX.Element;
104
+
105
+ type PaperChatVariant = 'default' | 'side' | 'floating' | 'dialog';
106
+ /** Docking edge for `variant="side"` (viewport-anchored left/right rail). */
107
+ type PaperChatSidePosition = 'left' | 'right';
108
+ type PaperChatSideContentInsetMode = 'none' | 'auto';
109
+
110
+ /**
111
+ * Controls handed to {@link PaperChatProps.renderSidePanelOpenTrigger}. The
112
+ * host's open state remains the source of truth — `show` and `toggle` simply
113
+ * forward to the `onOpenChange` callback.
114
+ */
115
+ interface SidePanelTriggerControls {
116
+ open: boolean;
117
+ show: () => void;
118
+ toggle: () => void;
119
+ }
11
120
  interface PaperChatProps {
121
+ variant?: PaperChatVariant;
12
122
  token?: string;
13
123
  workspaceId?: string;
14
124
  dashboardId?: string;
15
125
  apiUrl?: string;
16
- /**
17
- * Called whenever the toolbar height changes (including multiline expansion).
18
- * Host apps can use this to add bottom padding/margin to their chart area,
19
- * mirroring how the main app dashboard layout reacts to toolbar height.
20
- */
126
+ hideChartArea?: boolean;
21
127
  onToolbarHeightChange?: (height: number) => void;
22
128
  placeholder?: string;
23
129
  shortcutKey?: string;
24
130
  autoFade?: boolean;
25
131
  fadeDelay?: number;
26
132
  className?: string;
133
+ showToolbar?: boolean;
134
+ onAssistantClose?: () => void;
135
+ initialChatScroll?: 'top' | 'bottom';
136
+ isViewer?: boolean;
137
+ assistantInline?: boolean;
27
138
  /**
28
- * Controls whether the fixed bottom chat toolbar (input + quick actions) is rendered.
29
- * Defaults to `true`.
139
+ * Whether to render user / assistant avatars (User icon and Papermap logo)
140
+ * in chat message rows. Defaults to visible across every variant; pass
141
+ * `false` to hide them.
30
142
  */
31
- showToolbar?: boolean;
143
+ showAvatars?: boolean;
144
+ /**
145
+ * Override the user / assistant / thinking avatar icons. Each slot replaces
146
+ * only the icon — the surrounding circle wrapper stays. Useful for
147
+ * white-labeling the chat with the host product's brand.
148
+ */
149
+ avatars?: PaperChatAvatars;
150
+ /**
151
+ * Color scheme when this component creates `PapermapProvider` (main-app embedded `?theme=` parity).
152
+ */
153
+ theme?: PapermapColorScheme;
154
+ /**
155
+ * Which edge the side rail attaches to (border + shadow face the main area).
156
+ * - `"left"` (default): dock to the viewport left edge.
157
+ * - `"right"`: dock to the viewport right edge.
158
+ */
159
+ sidePosition?: PaperChatSidePosition;
160
+ /**
161
+ * Whether the side rail participates in document flow vs overlaying the page.
162
+ * - `"none"` (default): on `md+` the rail is viewport-fixed and overlays host content.
163
+ * - `"auto"`: on `md+` the rail is **in-flow** — place `PaperChat` as a flex sibling next to your
164
+ * main surface (`flex` row, `min-h-0`, main `flex-1 min-w-0 overflow-auto`) so content resizes
165
+ * with the panel. Below `md`, behavior matches `"none"` (slide-over sheet). Hosts should not rely
166
+ * on `body` padding for insetting; the package no longer sets `--papermap-side-inset-*` for this mode.
167
+ */
168
+ sideContentInsetMode?: PaperChatSideContentInsetMode;
169
+ /**
170
+ * Whether the chat surface is open — use with **`onOpenChange`** for
171
+ * **`variant="side"`** (rail), **`variant="floating"`** (overlay), and
172
+ * **`variant="dialog"`** (modal). When omitted, each variant falls back to
173
+ * its own defaults (side: closed; floating: use `visible`; dialog:
174
+ * internal state or `dialogOpen`).
175
+ */
176
+ open?: boolean;
177
+ /**
178
+ * Fires when the surface opens or closes. Use for **`side`**, **`floating`**,
179
+ * and **`dialog`** instead of legacy `onClose` / `onDialogOpenChange`.
180
+ */
181
+ onOpenChange?: (open: boolean) => void;
182
+ onChartVisibilityChange?: (visible: boolean) => void;
183
+ /**
184
+ * Mount node for the sheet chart overlay (`createPortal`). Omit to use `document.body` (no host ref).
185
+ */
186
+ chartOverlayPortalRef?: React__default.RefObject<HTMLDivElement | null>;
187
+ onPendingSheetEditsChange?: (edits: {
188
+ edit_session_id?: string;
189
+ }[]) => void;
190
+ clearPendingSheetEditsRef?: React__default.MutableRefObject<(() => void) | null>;
191
+ /**
192
+ * Render-prop for a custom open trigger shown when `variant === 'side'` and
193
+ * `open === false`. The returned node mounts inside the side wrapper; if you
194
+ * need the trigger to escape the wrapper (e.g. as a floating action button),
195
+ * style it with `fixed` / `absolute` positioning.
196
+ *
197
+ * Omit to render no trigger — keep the existing pattern where the host
198
+ * renders its own open affordance outside `PaperChat`.
199
+ */
200
+ renderSidePanelOpenTrigger?: (controls: SidePanelTriggerControls) => React__default.ReactNode;
201
+ /**
202
+ * @deprecated Use **`open`** for `variant="floating"`. When both are set,
203
+ * `open` takes precedence.
204
+ */
205
+ visible?: boolean;
206
+ /**
207
+ * @deprecated Use **`onOpenChange(false)`** for `variant="floating"`. Still
208
+ * invoked after `onOpenChange` when the overlay requests close, if provided.
209
+ */
210
+ onClose?: () => void;
211
+ historyOpen?: boolean;
212
+ onCloseHistory?: () => void;
213
+ /** Header title inside the modal (default: `Chat`). Prefer `title`. */
214
+ title?: string;
215
+ /** @deprecated Use **`title`**. */
216
+ dialogTitle?: string;
217
+ /** Subtitle under the title. Prefer `subtitle`. */
218
+ subtitle?: string;
219
+ /** @deprecated Use **`subtitle`**. */
220
+ dialogSubtitle?: string;
221
+ /**
222
+ * @deprecated Use **`open`** for controlled dialog state. When both are set,
223
+ * `open` takes precedence.
224
+ */
225
+ dialogOpen?: boolean;
226
+ /**
227
+ * @deprecated Use **`onOpenChange`**. When both are set, `onOpenChange` is
228
+ * preferred.
229
+ */
230
+ onDialogOpenChange?: (open: boolean) => void;
231
+ /** Whether to show the floating launcher. Default `true`. Prefer `showLauncher`. */
232
+ showLauncher?: boolean;
233
+ /** @deprecated Use **`showLauncher`**. */
234
+ showDialogLauncher?: boolean;
235
+ /** Accessible name for the launcher. Prefer `launcherAriaLabel`. */
236
+ launcherAriaLabel?: string;
237
+ /** @deprecated Use **`launcherAriaLabel`**. */
238
+ dialogLauncherAriaLabel?: string;
239
+ /** Viewport corner for the launcher. Prefer `launcherPosition`. */
240
+ launcherPosition?: PaperChatDialogLauncherPosition;
241
+ /** @deprecated Use **`launcherPosition`**. */
242
+ dialogLauncherPosition?: PaperChatDialogLauncherPosition;
243
+ /**
244
+ * Custom trigger node for the `dialog` and `side` variants. The plugin
245
+ * wraps the node with the open/close handler so any element (icon, branded
246
+ * button, link, etc.) keeps the built-in toggle UX and accessibility.
247
+ * Ignored for `default` / `floating` variants.
248
+ */
249
+ trigger?: React__default.ReactNode;
250
+ /** Custom avatar node for assistant message rows. Equivalent to `avatars.assistant`. */
251
+ assistantAvatar?: React__default.ReactNode;
252
+ /** Custom avatar node for user message rows. Equivalent to `avatars.user`. */
253
+ userAvatar?: React__default.ReactNode;
254
+ /**
255
+ * Greeting/welcome line rendered as the first assistant bubble before any
256
+ * real messages have been exchanged. Applies to `side` and `dialog`
257
+ * variants (where the conversation surface is always mounted).
258
+ */
259
+ greetingMessage?: string;
260
+ /** Controlled expanded state for `side` and `dialog` variants. */
261
+ expanded?: boolean;
262
+ /** Uncontrolled initial expanded state. Default `false`. */
263
+ defaultExpanded?: boolean;
264
+ /** Fires when the side panel or dialog toggles between default and expanded size. */
265
+ onExpandedChange?: (expanded: boolean) => void;
266
+ }
267
+ declare function PaperChat({ variant, token, workspaceId, dashboardId, apiUrl, onToolbarHeightChange, onAssistantClose, initialChatScroll, isViewer, assistantInline, theme, showToolbar, showAvatars, avatars, sidePosition, sideContentInsetMode, open, onOpenChange, onChartVisibilityChange, chartOverlayPortalRef, onPendingSheetEditsChange, clearPendingSheetEditsRef, renderSidePanelOpenTrigger, visible, onClose, historyOpen, onCloseHistory, hideChartArea, title, dialogTitle, subtitle, dialogSubtitle, dialogOpen, onDialogOpenChange, showLauncher, showDialogLauncher, launcherAriaLabel, dialogLauncherAriaLabel, launcherPosition, dialogLauncherPosition, trigger, assistantAvatar, userAvatar, greetingMessage, expanded, defaultExpanded, onExpandedChange, ...uiProps }: PaperChatProps): react_jsx_runtime.JSX.Element;
268
+
269
+ type PendingSheetEditLike = {
270
+ edit_session_id?: string;
271
+ };
272
+ interface PaperChatSidePanelProps {
273
+ token?: string;
274
+ workspaceId?: string;
275
+ dashboardId?: string;
276
+ apiUrl?: string;
277
+ initialChatScroll?: 'top' | 'bottom';
278
+ isViewer?: boolean;
279
+ assistantInline?: boolean;
280
+ /** Color scheme when this component creates `PapermapProvider`. */
281
+ theme?: PapermapColorScheme;
282
+ hideChartArea?: boolean;
283
+ open: boolean;
284
+ onOpenChange: (open: boolean) => void;
285
+ onChartVisibilityChange?: (visible: boolean) => void;
286
+ /**
287
+ * Optional mount node for the sheet chart overlay portal. When omitted, the overlay portals to
288
+ * `document.body` so side-panel + dialog embeds work without a host ref.
289
+ */
290
+ chartOverlayPortalRef?: React__default.RefObject<HTMLDivElement | null>;
291
+ onPendingSheetEditsChange?: (edits: PendingSheetEditLike[]) => void;
292
+ clearPendingSheetEditsRef?: React__default.MutableRefObject<(() => void) | null>;
293
+ /** When embedded in a modal (e.g. `PaperChat` variant `dialog`), use full width and skip rail animation. */
294
+ embedInDialog?: boolean;
295
+ /** Hide the panel title row when the host supplies chrome (e.g. report-style dialog header). */
296
+ hideHeader?: boolean;
297
+ /**
298
+ * Which screen edge the sheet rail attaches to (borders/shadow face the main content).
299
+ * Ignored when `embedInDialog` is true.
300
+ */
301
+ sidePosition?: 'left' | 'right';
302
+ /**
303
+ * When true (e.g. `PaperChat` `sideContentInsetMode="auto"`), the desktop rail is laid out in-flow
304
+ * inside a flex host; width clamps use the smaller of viewport and the host column width, and the
305
+ * chart overlay reserves the live rail width instead of a fixed constant.
306
+ */
307
+ layoutFlowRail?: boolean;
308
+ /**
309
+ * Dialog embed only: whether chat chrome or the portaled chart overlay stacks above (focus-driven).
310
+ */
311
+ embedDialogStackLeader?: 'chat' | 'chart';
312
+ /** Ref to the floating chart dock root for embed stacking hit-testing. */
313
+ embedChartDockRef?: React__default.MutableRefObject<HTMLDivElement | null>;
314
+ /** Dialog embed: sync expanded/history fullscreen overlay foreground for Radix stack tiers. */
315
+ onEmbedChartForegroundChange?: (foreground: boolean) => void;
316
+ /**
317
+ * Whether to render user / assistant avatars (User icon and Papermap logo)
318
+ * in message bubbles. Defaults to `true` for this surface — the side rail
319
+ * and dialog modal are chrome-rich and benefit from identity affordances.
320
+ * Set `false` to hide them.
321
+ */
322
+ showAvatars?: boolean;
323
+ /** Override the user / assistant / thinking avatar icons. */
324
+ avatars?: PaperChatAvatars;
325
+ /**
326
+ * Greeting / welcome message rendered as the first assistant bubble before
327
+ * the user sends anything. Mirrors a live-chat widget welcome line.
328
+ */
329
+ greetingMessage?: string;
330
+ /** Controlled expanded state — when true, the panel grows beyond default width. */
331
+ expanded?: boolean;
332
+ /** Uncontrolled initial expanded state. Default `false`. */
333
+ defaultExpanded?: boolean;
334
+ /** Fires when the panel toggles between default and expanded width. */
335
+ onExpandedChange?: (expanded: boolean) => void;
336
+ /** Hide the built-in expand/collapse toggle in the header. Default `false`. */
337
+ hideExpandToggle?: boolean;
338
+ }
339
+ declare function PaperChatSidePanel({ token, workspaceId, dashboardId, apiUrl, initialChatScroll, isViewer, assistantInline, theme, ...panelProps }: PaperChatSidePanelProps): react_jsx_runtime.JSX.Element;
340
+ /** Backward-compatible alias. Prefer `PaperChatSidePanel`. */
341
+ declare function ChatSidePanel(props: PaperChatSidePanelProps): react_jsx_runtime.JSX.Element;
342
+
343
+ interface PaperChatFloatingChartOverlayProps {
344
+ token?: string;
345
+ workspaceId?: string;
346
+ dashboardId?: string;
347
+ apiUrl?: string;
348
+ initialChatScroll?: 'top' | 'bottom';
349
+ isViewer?: boolean;
350
+ assistantInline?: boolean;
351
+ /** Color scheme when this component creates `PapermapProvider`. */
352
+ theme?: PapermapColorScheme;
353
+ visible: boolean;
354
+ onClose: () => void;
355
+ /** Sheet page: charts history list in this overlay instead of the chat column */
356
+ historyOpen?: boolean;
357
+ onCloseHistory?: () => void;
358
+ /**
359
+ * When true (e.g. `PaperChat` variant `dialog`), use the same z-index layer as {@link ChartDialog}
360
+ * (`PAPERMAP_CHAT_DIALOG_Z`) with `fixed` positioning. Prefer portaling to `document.body` in the host.
361
+ */
362
+ stackWithChartDialog?: boolean;
363
+ /**
364
+ * When portaling to `document.body` next to {@link ChatSidePanel}, inset the overlay so it only
365
+ * covers the main area — not the chat rail (`CHAT_SIDE_PANEL_WIDTH_PX`).
366
+ */
367
+ besideRail?: boolean;
368
+ /**
369
+ * When set with `besideRail`, padding matches this width (e.g. in-flow rail after drag/expand)
370
+ * instead of the default `CHAT_SIDE_PANEL_WIDTH_PX`.
371
+ */
372
+ besideRailReservedWidthPx?: number;
373
+ /** Which edge the side panel is on — must match `ChatSidePanel` `sidePosition`. */
374
+ sidePosition?: 'left' | 'right';
375
+ /** When false and `besideRail`, do not reserve rail width (panel collapsed). */
376
+ sideRailOpen?: boolean;
377
+ /** Merged onto the chart overlay card shell (rounded panel). */
378
+ className?: string;
379
+ /** Dialog embed: z-index tier vs chat (from `PaperChatDialogInner`). */
380
+ embedDialogStackLeader?: 'chat' | 'chart';
381
+ embedChartDockRef?: React__default.MutableRefObject<HTMLDivElement | null>;
382
+ /** Dialog embed: expanded or history fullscreen should stack above chat and lower dialog chrome. */
383
+ onEmbedChartForegroundChange?: (foreground: boolean) => void;
32
384
  }
33
- declare function PaperChat({ token, workspaceId, dashboardId, apiUrl, onToolbarHeightChange, showToolbar, ...uiProps }: PaperChatProps): react_jsx_runtime.JSX.Element;
385
+ declare function PaperChatFloatingChartOverlay({ token, workspaceId, dashboardId, apiUrl, initialChatScroll, isViewer, assistantInline, theme, ...overlayProps }: PaperChatFloatingChartOverlayProps): react_jsx_runtime.JSX.Element;
386
+ /** Backward-compatible alias. Prefer `PaperChatFloatingChartOverlay`. */
387
+ declare function FloatingChartOverlay(props: PaperChatFloatingChartOverlayProps): react_jsx_runtime.JSX.Element;
34
388
 
389
+ /** One row of tabular chart data (column keys depend on the query). */
390
+ type ChartDataRow = Record<string, unknown>;
35
391
  type TChartMeta$1 = {
36
392
  title?: string;
37
393
  subtitle?: string;
@@ -39,7 +395,14 @@ type TChartMeta$1 = {
39
395
  footer?: string;
40
396
  showLegend?: boolean;
41
397
  variant?: string;
42
- [key: string]: any;
398
+ [key: string]: unknown;
399
+ };
400
+ type ChartVisualizationConfig = {
401
+ colors: string[];
402
+ width: number;
403
+ height: number;
404
+ title?: string;
405
+ [key: string]: unknown;
43
406
  };
44
407
  type TChartResponse = {
45
408
  llm_data_chat_id: string;
@@ -48,7 +411,7 @@ type TChartResponse = {
48
411
  chart_response?: {
49
412
  chart_type: string;
50
413
  error?: boolean;
51
- data: any[];
414
+ data: ChartDataRow[];
52
415
  response_type: string;
53
416
  text_response?: string;
54
417
  schema_hints: {
@@ -56,13 +419,7 @@ type TChartResponse = {
56
419
  y_key: string;
57
420
  label_key: string;
58
421
  };
59
- visualization_config: {
60
- colors: string[];
61
- width: number;
62
- height: number;
63
- title?: string;
64
- [key: string]: any;
65
- };
422
+ visualization_config: ChartVisualizationConfig;
66
423
  };
67
424
  meta: TChartMeta$1;
68
425
  pin: boolean;
@@ -83,8 +440,8 @@ interface VisualizationConfig {
83
440
  colors: string[];
84
441
  width: number;
85
442
  height: number;
86
- title: string;
87
- [key: string]: any;
443
+ title?: string;
444
+ [key: string]: unknown;
88
445
  }
89
446
  interface ChartResponse {
90
447
  response_type: string;
@@ -101,6 +458,34 @@ type ConversationHistory = Omit<TChartResponse, 'chart_response'> & {
101
458
  latest_user_name?: string | null;
102
459
  };
103
460
 
461
+ type ResizeHandle = 'n' | 's' | 'e' | 'w' | 'ne' | 'nw' | 'se' | 'sw';
462
+ type TLayout = Layout & {
463
+ resizeHandles?: ResizeHandle[];
464
+ };
465
+ type PaperBoardLayouts = {
466
+ [key: string]: TLayout[];
467
+ };
468
+ interface DashboardTheme {
469
+ primary: string;
470
+ secondary: string;
471
+ interactive: string;
472
+ container: string;
473
+ module: string;
474
+ accent: string;
475
+ outline: string;
476
+ dialog: string;
477
+ fontFamily: string;
478
+ borderRadius: number;
479
+ cardBg?: string;
480
+ dashboardBg?: string;
481
+ cardIcons?: string;
482
+ cardText?: string;
483
+ cardTitle?: string;
484
+ buttonPrimary?: string;
485
+ buttonSecondary?: string;
486
+ buttonText?: string;
487
+ }
488
+
104
489
  interface PaperCardProps {
105
490
  /**
106
491
  * Connection details for API calls. Optional when the card is rendered inside
@@ -122,6 +507,16 @@ interface PaperCardProps {
122
507
  * and logged only.
123
508
  */
124
509
  onSave?: (chart: TChartResponse) => void;
510
+ /**
511
+ * Called after the user successfully pins/saves a chart to the dashboard (streaming dialog
512
+ * or built-in ChartView save). Use this to refetch dashboard data from the host.
513
+ */
514
+ onPinnedToDashboard?: (chart: TChartResponse) => void;
515
+ /**
516
+ * Called after the streaming chart assistant dialog closes. Use with `onPinnedToDashboard`
517
+ * to refetch dashboard data so tiles reflect edits made in the assistant.
518
+ */
519
+ onAssistantClosed?: () => void;
125
520
  /**
126
521
  * The chat ID to load a chart for. When provided, the component will
127
522
  * fetch the latest chart for this chat on mount (overrides `id` → localStorage map).
@@ -135,8 +530,9 @@ interface PaperCardProps {
135
530
  /**
136
531
  * Visual theme for the chart card. When set, renders in the specified
137
532
  * mode independent of the host app. Omit to inherit the host page's theme.
533
+ * When the card creates its own `PapermapProvider`, this also sets the provider color scheme.
138
534
  */
139
- theme?: 'light' | 'dark';
535
+ theme?: 'light' | 'dark' | 'system';
140
536
  /**
141
537
  * Called when the user clicks the edit button on the chart card.
142
538
  * In streaming variant, if not provided, the built-in StreamingChartDialog opens.
@@ -162,12 +558,12 @@ interface PaperCardProps {
162
558
  wide?: boolean;
163
559
  /** Hide the chart variation selector. Defaults to true. */
164
560
  hideVariants?: boolean;
165
- /** Show the toolbar with edit/delete/maximize buttons. Defaults to true. */
561
+ /** Show the card chrome toolbar (maximize, edit, delete). Main app `ChartCard` uses `showChatToolbar`. Default true. */
166
562
  showToolbar?: boolean;
167
563
  /** When true, chart toolbar actions are visually disabled during layout editing. */
168
564
  isEditMode?: boolean;
169
565
  /** When true, show resize affordance and disable toolbar actions. */
170
- /** Optional stable identifier for standalone resize handle instrumentation. */
566
+ /** Optional stable identifier for standalone resize handle / host linking (when used). */
171
567
  className?: string;
172
568
  /**
173
569
  * Card variant. When `"streaming"`, clicking the edit icon opens an
@@ -175,10 +571,16 @@ interface PaperCardProps {
175
571
  * just calling onEditClick or opening the toolbar chat.
176
572
  */
177
573
  variant?: 'default' | 'streaming';
574
+ /**
575
+ * When true with `variant="streaming"` and no chart yet, omits the extra
576
+ * chat-bar hint row (“Ask anything about your data”). Used by `PaperBoard`
577
+ * so grid tiles are not redundant with board-level empty copy.
578
+ */
579
+ hideStreamingEmptySubtext?: boolean;
580
+ /** Passed into maximize `ChartDialog` / streaming dialog for themed dashboards (e.g. from `PaperBoard`). */
581
+ dashboardTheme?: DashboardTheme;
178
582
  }
179
- declare function PaperCard({ token: tokenProp, workspaceId: workspaceIdProp, dashboardId: dashboardIdProp, apiUrl: apiUrlProp, id, onSave, chartId, chart: chartProp, theme, onEditClick, onDelete, isViewer, wide, hideVariants, showToolbar, isEditMode, className, variant, }: PaperCardProps): react_jsx_runtime.JSX.Element;
180
-
181
- declare function ChatAssistant(): react_jsx_runtime.JSX.Element;
583
+ declare function PaperCard({ token: tokenProp, workspaceId: workspaceIdProp, dashboardId: dashboardIdProp, apiUrl: apiUrlProp, id, onSave, onPinnedToDashboard, onAssistantClosed, chartId, chart: chartProp, theme, onEditClick, onDelete, isViewer, wide, hideVariants, showToolbar, isEditMode, className, variant, hideStreamingEmptySubtext, dashboardTheme, }: PaperCardProps): react_jsx_runtime.JSX.Element;
182
584
 
183
585
  interface AgentThought {
184
586
  type: 'agent_thought';
@@ -187,16 +589,34 @@ interface AgentThought {
187
589
  iteration: number;
188
590
  timestamp: string;
189
591
  }
592
+ /** Native model reasoning (OpenAI summaries, Claude extended thinking) */
593
+ interface Reasoning {
594
+ type: 'reasoning';
595
+ content: string;
596
+ is_complete: boolean;
597
+ iteration: number;
598
+ timestamp: string;
599
+ }
600
+ /** SSE payload when the agent requires user confirmation before executing a tool */
601
+ interface ConfirmationRequired {
602
+ type: 'confirmation_required';
603
+ confirmation_id: string;
604
+ tool_display_name: string;
605
+ message: string;
606
+ action_description: string;
607
+ timeout_seconds: number;
608
+ timestamp: string;
609
+ }
190
610
  interface FinalResponse {
191
611
  type: 'final_response';
192
612
  response_data: {
193
613
  response_type: string;
194
614
  generated_text: string;
195
615
  chart_type?: string;
196
- data?: any[];
616
+ data?: unknown[];
197
617
  pandas_code?: string;
198
618
  thoughts?: string;
199
- [key: string]: any;
619
+ [key: string]: unknown;
200
620
  };
201
621
  llm_data_id: string;
202
622
  total_iterations: number;
@@ -212,7 +632,7 @@ interface ToolCall {
212
632
  tool_name: string;
213
633
  tool_display_name: string;
214
634
  args_preview: string;
215
- status: 'announced' | 'streaming' | 'ready' | 'executing' | 'success' | 'error';
635
+ status: 'announced' | 'streaming' | 'ready' | 'confirmation_pending' | 'executing' | 'success' | 'error' | 'denied';
216
636
  output?: string;
217
637
  code?: string;
218
638
  isStreamingArgs?: boolean;
@@ -221,13 +641,17 @@ interface ToolCall {
221
641
  duration_ms?: number;
222
642
  error_message?: string;
223
643
  tool_call_id?: string;
644
+ /** Present while status is `confirmation_pending` */
645
+ confirmationData?: ConfirmationRequired;
224
646
  timestamp: string;
225
647
  }
226
648
  interface TimelineEvent {
227
- type: 'thought' | 'tool';
649
+ type: 'thought' | 'reasoning' | 'tool';
228
650
  timestamp: string;
229
651
  iteration?: number;
230
652
  thoughtData?: AgentThought;
653
+ /** For native model reasoning */
654
+ reasoningData?: Reasoning;
231
655
  toolData?: ToolCall;
232
656
  }
233
657
  interface StreamState {
@@ -236,16 +660,17 @@ interface StreamState {
236
660
  timeline: TimelineEvent[];
237
661
  currentPhase: string;
238
662
  error: string | null;
239
- finalResponse: any | null;
663
+ finalResponse: unknown | null;
240
664
  isComplete: boolean;
241
665
  isConnected: boolean;
242
666
  isStreaming: boolean;
243
667
  }
244
668
 
245
- declare function StreamingTimeline({ timeline, collapseThreshold, recentFullCount, }: {
669
+ declare function StreamingTimeline({ timeline, collapseThreshold, recentFullCount, onConfirmationResponse, }: {
246
670
  timeline: TimelineEvent[];
247
671
  collapseThreshold?: number;
248
672
  recentFullCount?: number;
673
+ onConfirmationResponse?: (confirmationId: string, confirmed: boolean, message?: string) => Promise<void>;
249
674
  }): react_jsx_runtime.JSX.Element | null;
250
675
 
251
676
  interface AgentThoughtDisplayProps {
@@ -261,31 +686,178 @@ interface ToolCallDisplayProps {
261
686
  className?: string;
262
687
  showAll?: boolean;
263
688
  isLatest?: boolean;
689
+ onConfirmationResponse?: (confirmationId: string, confirmed: boolean, message?: string) => Promise<void>;
264
690
  }
265
- declare function ToolCallDisplay({ toolCalls, className, showAll, isLatest, }: ToolCallDisplayProps): react_jsx_runtime.JSX.Element | null;
691
+ declare function ToolCallDisplay({ toolCalls, className, showAll, isLatest, onConfirmationResponse, }: ToolCallDisplayProps): react_jsx_runtime.JSX.Element | null;
266
692
 
267
- declare function RecentConversations(): react_jsx_runtime.JSX.Element;
693
+ declare function RecentConversations({ embedInPanel }?: {
694
+ embedInPanel?: boolean;
695
+ }): react_jsx_runtime.JSX.Element;
268
696
 
269
697
  declare function ChartHistory(): react_jsx_runtime.JSX.Element;
270
698
 
271
699
  declare function SavedMemory(): react_jsx_runtime.JSX.Element;
272
700
 
701
+ /**
702
+ * In the main app, workspace/dashboard selection lives in Redux. The plugin
703
+ * provides the same `WorkspaceSelector` API (`dashboardTheme` only) and
704
+ * supplies selection state and callbacks through this context (see PaperBoard).
705
+ */
706
+ type WorkspaceSelectorControl = {
707
+ workspaceId: string;
708
+ dashboardId: string;
709
+ onSelect: (next: {
710
+ workspaceId: string;
711
+ dashboardId: string;
712
+ }) => void;
713
+ isViewer?: boolean;
714
+ };
715
+ declare function WorkspaceSelectorProvider({ value, children, }: {
716
+ value: WorkspaceSelectorControl;
717
+ children: ReactNode;
718
+ }): react_jsx_runtime.JSX.Element;
719
+
720
+ declare function DashboardAppHeader({ dashboardTheme, showWorkspaceSelector, workspaceSelectorValue, user, onLogout, billingHref, settingsHref, logoutUrl, appHeaderRightSlot, className,
721
+ /**
722
+ * When false, the header does not use `position: sticky` — use with a parent flex column where
723
+ * the scroll region is a sibling below the header (main-app `AuthenticatedLayout` pattern).
724
+ */
725
+ sticky, }: {
726
+ dashboardTheme?: DashboardTheme | null;
727
+ showWorkspaceSelector: boolean;
728
+ workspaceSelectorValue: WorkspaceSelectorControl;
729
+ user?: {
730
+ name?: string | null;
731
+ email?: string | null;
732
+ } | null;
733
+ onLogout?: () => void;
734
+ billingHref?: string;
735
+ settingsHref?: string;
736
+ logoutUrl?: string;
737
+ appHeaderRightSlot?: ReactNode;
738
+ className?: string;
739
+ sticky?: boolean;
740
+ }): react_jsx_runtime.JSX.Element;
741
+
742
+ declare function UserNav({ dashboardTheme, user: userProp, onLogout, billingHref, settingsHref, logoutUrl, }: {
743
+ dashboardTheme?: DashboardTheme | null;
744
+ user?: {
745
+ name?: string | null;
746
+ email?: string | null;
747
+ } | null;
748
+ /** Called when user picks Log out; if omitted, navigates to `logoutUrl` or Papermap home. */
749
+ onLogout?: () => void;
750
+ /** Defaults: `/billing` and `/settings` on the hosted web app. */
751
+ billingHref?: string;
752
+ settingsHref?: string;
753
+ logoutUrl?: string;
754
+ }): react_jsx_runtime.JSX.Element;
755
+
756
+ /**
757
+ * Main app: [IntegrationsBar](papermap/src/components/IntegrationsBar.tsx) — Slack in the package;
758
+ * WhatsApp is main-app-only (omitted to avoid a large second port).
759
+ */
760
+ declare function IntegrationsBar({ dashboardTheme, }: Readonly<{
761
+ dashboardTheme?: DashboardTheme | null;
762
+ }>): react_jsx_runtime.JSX.Element;
763
+
764
+ /**
765
+ * Same surface API as the main app `src/components/dashboard/workspace-selector.tsx`:
766
+ * `dashboardTheme` for scoped styling. Selection state and `onSelect` are provided by
767
+ * {@link WorkspaceSelectorProvider} (wired from PaperBoard).
768
+ */
769
+ declare function WorkspaceSelector({ dashboardTheme }: {
770
+ dashboardTheme?: DashboardTheme;
771
+ }): react_jsx_runtime.JSX.Element;
772
+
773
+ interface PaperDashboardSelectProps {
774
+ workspaceId: string;
775
+ dashboardId: string;
776
+ onChange: (dashboardId: string) => void;
777
+ dashboardTheme?: DashboardTheme;
778
+ disabled?: boolean;
779
+ className?: string;
780
+ /**
781
+ * When true, sets `dashboardId` on the current URL search params via `replaceState`
782
+ * (same idea as the main app embedded dashboard).
783
+ */
784
+ syncDashboardIdToUrl?: boolean;
785
+ }
786
+ /**
787
+ * Dashboard picker for the current workspace only (matches main app `DashboardSelect` / embedded UX).
788
+ */
789
+ declare function PaperDashboardSelect({ workspaceId, dashboardId, onChange, dashboardTheme, disabled, className, syncDashboardIdToUrl, }: PaperDashboardSelectProps): react_jsx_runtime.JSX.Element;
790
+
791
+ type DashboardNavbarItem = {
792
+ title: string;
793
+ /** Absolute or relative URL; pathname (before `?`) is used for the active state. */
794
+ href: string;
795
+ disabled?: boolean;
796
+ icon?: LucideIcon;
797
+ };
798
+ interface DashboardTabNavigationProps {
799
+ className?: string;
800
+ items: DashboardNavbarItem[];
801
+ dashboardTheme?: DashboardTheme;
802
+ /** Sticky offset below the app header. Main app uses `top-14` (3.5rem) under a 14 (`h-14`) top bar. */
803
+ stickyTopClassName?: string;
804
+ /** When false, tabs are not `position: sticky` (stack below the header; scroll is a sibling below). */
805
+ sticky?: boolean;
806
+ rightSlot?: ReactNode;
807
+ }
808
+ /**
809
+ * Top tab bar styled like the main app `TabNavigation` (embedded layout navbar), without Next.js `Link`.
810
+ *
811
+ * **Active tab:** each item’s `href` pathname is compared to `window.location.pathname`. In a single-page
812
+ * embed where every tab would share the same path, no tab may appear active unless the host uses distinct
813
+ * paths or supplies custom `items` / a future `activeNavId`-style override.
814
+ */
815
+ declare function DashboardTabNavigation({ className, items, dashboardTheme, stickyTopClassName,
816
+ /** When false, tabs are not `position: sticky` (stack below a fixed top bar; scroll is a sibling below). */
817
+ sticky, rightSlot, }: DashboardTabNavigationProps): react_jsx_runtime.JSX.Element;
818
+
819
+ type CreatedDashboard = {
820
+ dashboard_id: string;
821
+ title: string;
822
+ };
823
+ type CreateDashboardDialogProps = {
824
+ open: boolean;
825
+ onOpenChange: (open: boolean) => void;
826
+ workspaceId: string;
827
+ onSuccess: (dashboard: CreatedDashboard) => void;
828
+ };
829
+ declare function CreateDashboardDialog({ open, onOpenChange, workspaceId, onSuccess, }: CreateDashboardDialogProps): react_jsx_runtime.JSX.Element;
830
+
831
+ type CreatedUnifiedWorkspace = {
832
+ workspace_id: string;
833
+ name: string;
834
+ default_dashboard: string;
835
+ };
836
+ type CreateUnifiedWorkspaceDialogProps = {
837
+ open: boolean;
838
+ onOpenChange: (open: boolean) => void;
839
+ /** Called after API success with IDs so the host can navigate / invalidate queries. */
840
+ onSuccess: (workspace: CreatedUnifiedWorkspace) => void;
841
+ };
842
+ declare function CreateUnifiedWorkspaceDialog({ open, onOpenChange, onSuccess, }: CreateUnifiedWorkspaceDialogProps): react_jsx_runtime.JSX.Element;
843
+
273
844
  interface TChartMeta {
274
845
  title?: string;
275
846
  subtitle?: string;
847
+ description?: string;
276
848
  footer?: string;
277
849
  variant?: string;
278
850
  showLegend?: boolean;
279
851
  }
280
852
  interface ChartViewProps {
281
- data: any[];
853
+ data: ChartDataRow[];
282
854
  chartMeta: TChartMeta;
283
855
  error?: boolean;
284
856
  chartType: string;
285
857
  variant?: string;
286
858
  className?: string;
287
859
  containerClassName?: string;
288
- visualizationConfig?: Record<string, any>;
860
+ visualizationConfig?: Record<string, unknown>;
289
861
  previewMode?: boolean;
290
862
  onMetaChange?: (key: 'title' | 'description' | 'footer' | 'subtitle', value: string) => void;
291
863
  chartId?: string;
@@ -308,6 +880,18 @@ interface ChartViewProps {
308
880
  * of the default bottom-left outline button. Used in streaming layouts.
309
881
  */
310
882
  compactSave?: boolean;
883
+ /**
884
+ * Called after a successful pin/save to the dashboard via the built-in save action.
885
+ * Not invoked when `onSaveToDashboard` overrides the handler.
886
+ */
887
+ onAfterPinToDashboard?: () => void;
888
+ /** When set (and not skipped), header and controls use dashboard theme tokens. */
889
+ dashboardTheme?: DashboardTheme;
890
+ /** When true, ignore `dashboardTheme` (e.g. dialog with `skipDashboardTheme`). */
891
+ skipDashboardTheme?: boolean;
892
+ /** When provided, renders a camera/screenshot control next to chart variations (main-app parity). */
893
+ onScreenshot?: () => void;
894
+ isScreenshotting?: boolean;
311
895
  }
312
896
  declare function ChartView(props: ChartViewProps): react_jsx_runtime.JSX.Element;
313
897
 
@@ -326,7 +910,38 @@ interface ChartDialogProps {
326
910
  visualizationConfig: Record<string, any>;
327
911
  onMetaChange: (key: 'title' | 'description' | 'footer' | 'subtitle', value: string) => void;
328
912
  variant?: string;
913
+ hideChartArea?: boolean;
914
+ /**
915
+ * Optional callback (main app passes it from chat but does not invoke it from the dialog minimize control).
916
+ * Minimize calls `onOpenChange(false)` only, matching the main Papermap `ChartDialog`.
917
+ */
329
918
  onClose?: () => void;
919
+ /**
920
+ * When true, hides the chart variation selector in the dialog (embedded edge cases).
921
+ * Default false — matches main-app maximize dialog (variant switching allowed).
922
+ */
923
+ hideVariantControls?: boolean;
924
+ /**
925
+ * Workspace dashboard theme: injects scoped CSS and `dashboard-theme` on the dialog surface (main-app parity).
926
+ * Omit when no custom theme; combine with `skipDashboardTheme` for chat-embedded dialogs.
927
+ */
928
+ dashboardTheme?: DashboardTheme;
929
+ /**
930
+ * When true, do not apply `dashboardTheme` to the dialog shell or inner `ChartView` (e.g. `ChatAssistant`).
931
+ */
932
+ skipDashboardTheme?: boolean;
933
+ /**
934
+ * Package-only: near-full viewport sizing for expanded `ChatAssistant` / streaming hosts.
935
+ * The main app `ChartDialog` has no equivalent prop; default `false` matches main-app layout.
936
+ */
937
+ fullBleed?: boolean;
938
+ /** Color scheme when this component creates `PapermapProvider`. */
939
+ theme?: PapermapColorScheme;
940
+ /**
941
+ * Hide the floating screenshot control (main app keeps it on maximize dialogs from grid/chat paths).
942
+ * `FloatingChartOverlay` omits chart screenshots in the embed package.
943
+ */
944
+ hideScreenshotButton?: boolean;
330
945
  }
331
946
  declare function ChartDialog(props: ChartDialogProps): react_jsx_runtime.JSX.Element;
332
947
 
@@ -337,17 +952,19 @@ interface StreamingChartDialogProps {
337
952
  onClose?: () => void;
338
953
  /** After a successful Save-to-dashboard (pin) from this dialog; errors from the host are caught and logged. */
339
954
  onSave?: (chart: TChartResponse) => void;
955
+ /** Optional workspace theme for inline chart and maximize `ChartDialog` (from `PaperCard` / `PaperBoard`). */
956
+ dashboardTheme?: DashboardTheme;
340
957
  }
341
- declare function StreamingChartDialog({ isOpen, onOpenChange, chartId, onClose, onSave, }: StreamingChartDialogProps): React$1.ReactPortal;
958
+ declare function StreamingChartDialog({ isOpen, onOpenChange, chartId, onClose, onSave, dashboardTheme, }: StreamingChartDialogProps): React$1.ReactPortal;
342
959
 
343
960
  interface DataTableProps {
344
961
  data: any[];
345
- dashboardTheme?: any;
962
+ dashboardTheme?: DashboardTheme | null;
346
963
  }
347
964
  declare function DataTable({ data, dashboardTheme }: DataTableProps): react_jsx_runtime.JSX.Element;
348
965
 
349
966
  declare const buttonVariants: (props?: ({
350
- variant?: "default" | "link" | "destructive" | "outline" | "secondary" | "ghost" | null | undefined;
967
+ variant?: "link" | "default" | "destructive" | "outline" | "secondary" | "ghost" | null | undefined;
351
968
  size?: "default" | "sm" | "lg" | "icon" | null | undefined;
352
969
  } & class_variance_authority_types.ClassProp) | undefined) => string;
353
970
  interface ButtonProps extends React$1.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof buttonVariants> {
@@ -386,7 +1003,11 @@ interface FeedbackButtonsProps {
386
1003
  }
387
1004
  declare function FeedbackButtons({ onFeedback, className, isLoading, selectedFeedback, loadingType, }: FeedbackButtonsProps): react_jsx_runtime.JSX.Element;
388
1005
 
389
- declare function ModelSelector(): react_jsx_runtime.JSX.Element;
1006
+ interface ModelSelectorProps {
1007
+ /** `icon` = sparkles only; `compact` = sparkles + current model label (main toolbar when expanded / multiline). */
1008
+ variant?: 'icon' | 'compact';
1009
+ }
1010
+ declare function ModelSelector({ variant }: ModelSelectorProps): react_jsx_runtime.JSX.Element;
390
1011
 
391
1012
  interface StreamingChatPanelProps {
392
1013
  className?: string;
@@ -395,12 +1016,17 @@ interface StreamingChatPanelProps {
395
1016
  * dialog when the chart column is hidden so chat isn’t artificially narrow.
396
1017
  */
397
1018
  expandMessageColumnOnMobile?: boolean;
1019
+ /**
1020
+ * Horizontal padding for the scrollable message list (main `ChatAssistant` uses wide gutters
1021
+ * when expanded without the chart split: `px-32 md:px-48 lg:px-[320px] xl:px-[448px]`).
1022
+ */
1023
+ messagesPaddingClassName?: string;
398
1024
  /** Auto-focuses the prompt input when this panel mounts (used by dialog hosts). */
399
1025
  autoFocusInput?: boolean;
400
1026
  /** Optional action rendered beside submit button in the input row. */
401
1027
  inputAction?: React__default.ReactNode;
402
1028
  }
403
- declare function StreamingChatPanel({ className, expandMessageColumnOnMobile, autoFocusInput, inputAction, }: StreamingChatPanelProps): react_jsx_runtime.JSX.Element;
1029
+ declare function StreamingChatPanel({ className, expandMessageColumnOnMobile, messagesPaddingClassName, autoFocusInput, inputAction, }: StreamingChatPanelProps): react_jsx_runtime.JSX.Element;
404
1030
 
405
1031
  interface LogoStandAloneProps {
406
1032
  className?: string;
@@ -430,39 +1056,23 @@ declare function createStreamingService(client: AxiosInstance): {
430
1056
  cancelChartRequest: (request_id: string, reason?: string) => Promise<any>;
431
1057
  };
432
1058
 
433
- type ResizeHandle = 'n' | 's' | 'e' | 'w' | 'ne' | 'nw' | 'se' | 'sw';
434
- type TLayout = Layout & {
435
- resizeHandles?: ResizeHandle[];
436
- };
437
- type PaperBoardLayouts = {
438
- [key: string]: TLayout[];
439
- };
440
- interface DashboardTheme {
441
- primary: string;
442
- secondary: string;
443
- interactive: string;
444
- container: string;
445
- module: string;
446
- accent: string;
447
- outline: string;
448
- dialog: string;
449
- fontFamily: string;
450
- borderRadius: number;
451
- cardBg?: string;
452
- dashboardBg?: string;
453
- cardIcons?: string;
454
- cardText?: string;
455
- cardTitle?: string;
456
- buttonPrimary?: string;
457
- buttonSecondary?: string;
458
- buttonText?: string;
459
- }
460
-
461
1059
  declare function createChartService(client: AxiosInstance): {
462
1060
  getDashboards: (params: {
463
1061
  workspace_id: string;
464
1062
  }) => Promise<any>;
1063
+ getDashboardsPaginated: (params: {
1064
+ workspace_id: string;
1065
+ page?: number;
1066
+ per_page?: number;
1067
+ search_term?: string;
1068
+ }) => Promise<any>;
1069
+ getDashboardById: (dashboardId: string) => Promise<any>;
465
1070
  updateDashboardLayout: (dashboardId: string, layout: TLayout[]) => Promise<any>;
1071
+ createDashboard: (payload: {
1072
+ title: string;
1073
+ description?: string;
1074
+ workspace_id: string;
1075
+ }) => Promise<any>;
466
1076
  createChat: (data: {
467
1077
  name: string;
468
1078
  dashboard_id: string;
@@ -491,7 +1101,7 @@ declare function createChartService(client: AxiosInstance): {
491
1101
  page?: number;
492
1102
  }) => Promise<any>;
493
1103
  getChartById: (chartId: string) => Promise<any>;
494
- updateChartMeta: (chatId: string, meta: Record<string, any>) => Promise<any>;
1104
+ updateChartMeta: (chatId: string, meta: TChartMeta$1) => Promise<any>;
495
1105
  updateChartPin: (chatId: string, pin: boolean) => Promise<any>;
496
1106
  bookmarkConversation: (data: {
497
1107
  llm_data_id: string;
@@ -500,6 +1110,12 @@ declare function createChartService(client: AxiosInstance): {
500
1110
  removeBookmark: (bookmarkId: string) => Promise<any>;
501
1111
  updateResponseLabel: (llm_data_id: string, label: "positive" | "negative") => Promise<any>;
502
1112
  branchConversation: (dashboard_id: string, llm_data_id: string) => Promise<any>;
1113
+ submitToolConfirmation: (data: {
1114
+ request_id: string;
1115
+ confirmation_id: string;
1116
+ confirmed: boolean;
1117
+ message?: string;
1118
+ }) => Promise<any>;
503
1119
  getModels: () => Promise<any>;
504
1120
  generateProactiveDashboard: (payload: {
505
1121
  workspace_id: string;
@@ -508,9 +1124,105 @@ declare function createChartService(client: AxiosInstance): {
508
1124
  }) => Promise<any>;
509
1125
  };
510
1126
 
1127
+ interface SlackIntegrationStatus {
1128
+ connected: boolean;
1129
+ team_name?: string;
1130
+ team_id?: string;
1131
+ connected_at?: string;
1132
+ scopes?: string[];
1133
+ requires_reauth?: boolean;
1134
+ error_code?: string;
1135
+ error_message?: string;
1136
+ error_timestamp?: string;
1137
+ can_reactivate?: boolean;
1138
+ }
1139
+ interface SlackDisconnectResponse {
1140
+ success: boolean;
1141
+ message: string;
1142
+ count: number;
1143
+ }
1144
+ interface SlackReactivateResponse {
1145
+ success: boolean;
1146
+ message: string;
1147
+ status: {
1148
+ status: string;
1149
+ team_name?: string;
1150
+ team_id?: string;
1151
+ requires_reauth?: boolean;
1152
+ error_code?: string;
1153
+ };
1154
+ }
1155
+ interface WorkspaceAccess {
1156
+ workspace_id: string;
1157
+ name: string;
1158
+ workspace_type: string;
1159
+ allowed: boolean;
1160
+ }
1161
+ interface WorkspaceAccessSettings {
1162
+ team_id: string;
1163
+ team_name: string;
1164
+ total_workspaces: number;
1165
+ allowed_workspaces: number;
1166
+ updated_at: string | null;
1167
+ updated_by_user_id: string | null;
1168
+ }
1169
+ interface WorkspaceAccessResponse {
1170
+ success: boolean;
1171
+ workspaces: WorkspaceAccess[];
1172
+ settings: WorkspaceAccessSettings;
1173
+ }
1174
+
1175
+ /**
1176
+ * Slack API (matches [slack.service](papermap/src/services/slack.service.ts)); uses the Papermap API client and embed token.
1177
+ */
1178
+ declare function createSlackService(client: AxiosInstance, baseUrl: string): {
1179
+ getStatus(): Promise<SlackIntegrationStatus>;
1180
+ initiateOAuth(rawToken: string): Promise<void>;
1181
+ disconnect(): Promise<SlackDisconnectResponse>;
1182
+ reactivate(): Promise<SlackReactivateResponse>;
1183
+ getWorkspaceAccess(teamId: string): Promise<WorkspaceAccessResponse>;
1184
+ updateWorkspaceAccess(teamId: string, allowedWorkspaceIds: string[]): Promise<WorkspaceAccessResponse>;
1185
+ };
1186
+
1187
+ /** Plain JSON object (not array, not null). */
1188
+ type JsonObject = Record<string, unknown>;
1189
+ /** Workspace `meta` fields used for dashboard theming (matches main app). */
1190
+ interface WorkspaceMeta {
1191
+ apply_theme_to_all_dashboards?: boolean;
1192
+ default_theme?: DashboardTheme;
1193
+ theme?: Record<string, DashboardTheme | undefined>;
1194
+ [key: string]: unknown;
1195
+ }
1196
+ /**
1197
+ * Minimal workspace/dashboard document shape returned by workspace and dashboard APIs.
1198
+ * Extra fields are preserved via the index signature.
1199
+ */
1200
+ interface WorkspaceEntity {
1201
+ id?: string;
1202
+ name?: string;
1203
+ workspace_type?: string;
1204
+ default_dashboard?: string;
1205
+ meta?: WorkspaceMeta;
1206
+ /** Present on some dashboard GET payloads */
1207
+ title?: string;
1208
+ [key: string]: unknown;
1209
+ }
1210
+ /**
1211
+ * Normalizes workspace or dashboard API responses that may be either the entity or `{ data: entity }`.
1212
+ * Returns `null` when the payload is not a non-null object (e.g. raw array or primitive).
1213
+ */
1214
+ declare function unwrapWorkspacePayload(res: unknown): WorkspaceEntity | null;
1215
+
511
1216
  declare function createWorkspaceService(client: AxiosInstance): {
1217
+ listWorkspaces: (params?: {
1218
+ page?: number;
1219
+ per_page?: number;
1220
+ search_term?: string;
1221
+ }) => Promise<any>;
512
1222
  getWorkspace: (workspaceId: string) => Promise<any>;
513
- updateWorkspace: (workspaceId: string, workspace: Record<string, any>) => Promise<any>;
1223
+ updateWorkspace: (workspaceId: string, workspace: JsonObject) => Promise<any>;
1224
+ verifyDatabaseConnection: (workspaceId: string) => Promise<any>;
1225
+ createUnifiedWorkspace: (name?: string) => Promise<any>;
514
1226
  };
515
1227
 
516
1228
  type PapermapHttpServices = {
@@ -518,6 +1230,9 @@ type PapermapHttpServices = {
518
1230
  streamingSvc: ReturnType<typeof createStreamingService>;
519
1231
  chartSvc: ReturnType<typeof createChartService>;
520
1232
  workspaceSvc: ReturnType<typeof createWorkspaceService>;
1233
+ slackSvc: ReturnType<typeof createSlackService>;
1234
+ /** Raw embed token (used for Slack OAuth redirect). */
1235
+ token: string;
521
1236
  baseUrl: string;
522
1237
  };
523
1238
  declare function createPapermapServices(config: {
@@ -525,8 +1240,13 @@ declare function createPapermapServices(config: {
525
1240
  apiUrl?: string;
526
1241
  }): PapermapHttpServices;
527
1242
 
1243
+ type MessageProgressEvent = {
1244
+ event_type?: string;
1245
+ data?: JsonObject;
1246
+ };
528
1247
  interface Message {
529
1248
  id?: string;
1249
+ /** Preferred id for bookmark / feedback / branch APIs when both are present (matches main app). */
530
1250
  llm_data_id?: string;
531
1251
  content: string;
532
1252
  role: 'user' | 'assistant' | 'error' | 'branch';
@@ -541,13 +1261,40 @@ interface Message {
541
1261
  rundown_turn_label?: string;
542
1262
  noIcons?: boolean;
543
1263
  feedback?: 'positive' | 'negative' | null;
544
- progress_events?: {
545
- event_type?: string;
546
- data?: Record<string, any>;
547
- }[];
1264
+ progress_events?: MessageProgressEvent[];
548
1265
  originalContent?: string;
549
- [key: string]: any;
1266
+ [key: string]: unknown;
1267
+ }
1268
+
1269
+ type PapermapTelemetryLevel = 'debug' | 'info' | 'warn' | 'error';
1270
+ interface PapermapTelemetryEvent {
1271
+ level: PapermapTelemetryLevel;
1272
+ category: 'store' | 'sse' | 'network' | 'plugin' | 'ui' | 'runtime' | string;
1273
+ message: string;
1274
+ data?: Record<string, unknown>;
1275
+ /** Original error or value; hosts should treat as opaque if serialized. */
1276
+ cause?: unknown;
1277
+ }
1278
+ interface PapermapObservability {
1279
+ emit: (event: PapermapTelemetryEvent) => void;
1280
+ reportError: (error: unknown, context?: Record<string, unknown>) => void;
1281
+ }
1282
+ interface PapermapObservabilityOptions {
1283
+ /** Receives every structured event (debug–error). */
1284
+ onTelemetry?: (event: PapermapTelemetryEvent) => void;
1285
+ /** Shortcut for failures; also receives a normalized telemetry event via `onTelemetry` when both are set. */
1286
+ onError?: (error: unknown, context?: Record<string, unknown>) => void;
1287
+ /**
1288
+ * When true (default), mirror `warn`/`error` telemetry to the console in non-production runtimes.
1289
+ * Set false in tests or strict hosts. Production never mirrors unless you log inside `onTelemetry`.
1290
+ */
1291
+ mirrorToConsoleInDev?: boolean;
550
1292
  }
1293
+ /**
1294
+ * Builds the observability facade used by `PapermapProvider` / `createPapermapStore`.
1295
+ * With no options, production is silent; dev (non-test) mirrors warn/error to `console`.
1296
+ */
1297
+ declare function createPapermapObservability(options?: PapermapObservabilityOptions): PapermapObservability;
551
1298
 
552
1299
  declare const CHAT_MODAL_TAB: {
553
1300
  readonly CHAT: "CHAT";
@@ -561,6 +1308,11 @@ interface PapermapStoreConfig {
561
1308
  workspaceId: string;
562
1309
  dashboardId: string;
563
1310
  apiUrl?: string;
1311
+ /**
1312
+ * React Query client used when the store invalidates queries (e.g. after creating a chat).
1313
+ * `PapermapProvider` supplies a per-identity instance so cache cannot leak across tenant/workspace switches.
1314
+ */
1315
+ queryClient?: QueryClient;
564
1316
  /**
565
1317
  * Optional: use your own state (e.g. Redux) to control the selected model.
566
1318
  * When provided, this value is used as the initial model instead of sessionStorage.
@@ -571,6 +1323,26 @@ interface PapermapStoreConfig {
571
1323
  * Ideal place to dispatch a Redux action in the host app.
572
1324
  */
573
1325
  onModelChange?: (model: string | null) => void;
1326
+ /**
1327
+ * Structured telemetry for hosts. Defaults to a quiet implementation (no production console noise).
1328
+ * `PapermapProvider` supplies a shared instance when `observability` options are passed.
1329
+ */
1330
+ observability?: PapermapObservability;
1331
+ /**
1332
+ * ChatAssistant scroll: `top` mimics main-app onboarding (open at top, less aggressive bottom follow).
1333
+ * Omit or `bottom` for default bottom-anchored chat scrolling.
1334
+ */
1335
+ initialChatScroll?: 'top' | 'bottom';
1336
+ /**
1337
+ * When true, bookmark actions in chat are hidden (mirrors main app viewer role).
1338
+ * `PapermapProvider` / `PaperChat` forward this; hosts using only metadata can pass without an API role fetch.
1339
+ */
1340
+ isViewer?: boolean;
1341
+ /**
1342
+ * When true, `ChatAssistant` uses column-friendly layout (no floating card chrome). Hosts embed via
1343
+ * `PapermapProvider` + a sized parent, or pass from `PaperChat` when it creates the provider.
1344
+ */
1345
+ assistantInline?: boolean;
574
1346
  }
575
1347
  type Services = PapermapHttpServices;
576
1348
  interface Refs {
@@ -608,10 +1380,10 @@ interface PapermapState {
608
1380
  browserUse: boolean;
609
1381
  selectedModel: string | null;
610
1382
  viewExecution: boolean;
611
- chartData: any[];
1383
+ chartData: ChartDataRow[];
612
1384
  allMeta: TChartMeta$1;
613
1385
  selectedChartType: string;
614
- chartVisuals: Record<string, any>;
1386
+ chartVisuals: Record<string, unknown>;
615
1387
  totalPages: number;
616
1388
  currentPage: number;
617
1389
  isLoadingMore: boolean;
@@ -626,6 +1398,30 @@ interface PapermapState {
626
1398
  sseIsStreaming: boolean;
627
1399
  sseIsComplete: boolean;
628
1400
  sseError: string | null;
1401
+ /**
1402
+ * Bound to `useAnalyticsStream().submitConfirmation` while an SSE request is active.
1403
+ * Used by `StreamingTimeline` / tool confirmation UI.
1404
+ */
1405
+ sseSubmitConfirmation: ((confirmationId: string, confirmed: boolean, message?: string) => Promise<void>) | null;
1406
+ /** Workspace role: hide bookmark affordances when true. Synced from `PapermapStoreConfig.isViewer`. */
1407
+ isViewer: boolean;
1408
+ /** Column / side-panel layout for `ChatAssistant` (see `PapermapStoreConfig.assistantInline`). */
1409
+ assistantInline: boolean;
1410
+ /**
1411
+ * Bottom toolbar height (PaperChat input strip), measured via ResizeObserver.
1412
+ * Feeds `getAssistantDimensions` expanded height like main app `useChartStore().toolbarHeight`.
1413
+ */
1414
+ toolbarHeight: number;
1415
+ /**
1416
+ * Sheet / floating chart overlay open — mirrors main `sheetChartUiOpen` on `ChatAssistant`
1417
+ * so the inline “Show Chart” chip hides when the overlay is already up.
1418
+ */
1419
+ sheetChartUiOpen: boolean;
1420
+ /**
1421
+ * Registered by `ChatSidePanelInner` so inline `ChatAssistant` can open `FloatingChartOverlay`
1422
+ * instead of only toggling the split chart column.
1423
+ */
1424
+ externalShowChartHandler: ((visible: boolean) => void) | null;
629
1425
  }
630
1426
  interface PapermapActions {
631
1427
  setMessages: (messages: Message[] | ((prev: Message[]) => Message[])) => void;
@@ -643,16 +1439,27 @@ interface PapermapActions {
643
1439
  updateBrowserUse: (v: boolean) => void;
644
1440
  setSelectedModel: (v: string | null) => void;
645
1441
  setViewExecution: (v: boolean) => void;
646
- updateChartData: (data: any[]) => void;
1442
+ updateChartData: (data: ChartDataRow[]) => void;
647
1443
  updateAllMeta: (meta: TChartMeta$1) => void;
648
1444
  updateChartType: (v: string) => void;
649
- updateChartVisuals: (v: Record<string, any>) => void;
650
- updateLatestChart: (result: any) => void;
1445
+ updateChartVisuals: (v: Record<string, unknown>) => void;
1446
+ updateLatestChart: (result: unknown) => void;
651
1447
  clearLatestChart: () => void;
1448
+ /**
1449
+ * Merge one chart meta field into `allMeta` (dialog title edits, etc.). Matches main `updateChartMeta` field-wise merge.
1450
+ */
1451
+ patchChartMeta: (key: 'title' | 'description' | 'footer' | 'subtitle', value: string) => void;
652
1452
  setUseSSEStreaming: (v: boolean) => void;
653
1453
  setSseRequestId: (v: string | null) => void;
654
1454
  setSseChatId: (v: string | null) => void;
655
1455
  clearStreamingState: () => void;
1456
+ /** Called from `SSESync` to wire tool Allow/Deny into the analytics stream hook */
1457
+ setSseSubmitConfirmation: (fn: ((confirmationId: string, confirmed: boolean, message?: string) => Promise<void>) | null) => void;
1458
+ setIsViewer: (v: boolean) => void;
1459
+ setAssistantInline: (v: boolean) => void;
1460
+ setToolbarHeight: (v: number) => void;
1461
+ setSheetChartUiOpen: (v: boolean) => void;
1462
+ setExternalShowChartHandler: (fn: ((visible: boolean) => void) | null) => void;
656
1463
  syncSseDisplay: (data: {
657
1464
  thoughts: AgentThought[];
658
1465
  toolCalls: ToolCall[];
@@ -675,6 +1482,8 @@ interface PapermapActions {
675
1482
  getConfig: () => PapermapStoreConfig;
676
1483
  }
677
1484
  type PapermapStore = PapermapState & PapermapActions;
1485
+ /** Default assistant bubble when a thread has no messages yet (API empty or before load). */
1486
+ declare const PAPERMAP_CHAT_GREETING_MESSAGE: Message;
678
1487
  declare function createPapermapStore(config: PapermapStoreConfig, injectedServices?: PapermapHttpServices): zustand.StoreApi<PapermapStore>;
679
1488
  type PapermapStoreApi = ReturnType<typeof createPapermapStore>;
680
1489
  interface OpenPapermapChatAssistantOptions {
@@ -700,13 +1509,62 @@ interface OpenPapermapChatAssistantOptions {
700
1509
  * open in edit mode for that chart.
701
1510
  *
702
1511
  * When chart is provided (e.g. from ChartCard), primes the store like the main
703
- * app openEditChartModal: setMessages([]), updateAllMeta(chart.meta),
1512
+ * app openEditChartModal: setMessages([greeting]), updateAllMeta(chart.meta),
704
1513
  * updateChartData/Type/Visuals(chart.chart_response), then set editChatId and open.
705
1514
  * ConversationLoader still runs loadConversations() for messages; variant shows
706
1515
  * immediately from chart.meta.
707
1516
  */
708
1517
  declare function openPapermapChatAssistant(storeApi: PapermapStoreApi, options?: OpenPapermapChatAssistantOptions): void;
709
1518
 
1519
+ /** Mirrors `package.json` version; run `npm run sync:sdk-version` or `npm run build` to refresh. */
1520
+ declare const PAPERMAP_SDK_VERSION: "1.1.1";
1521
+ /** Contract revision for hosts that gate advanced features; bump only for breaking contract changes. */
1522
+ declare const PAPERMAP_PLUGIN_CONTRACT_VERSION: 1;
1523
+ type PapermapCapability = 'chat' | 'charts' | 'dashboard' | 'streaming' | 'workspace' | (string & {});
1524
+ interface PapermapPluginManifest {
1525
+ id: string;
1526
+ name?: string;
1527
+ /** Plugin’s own semver. */
1528
+ version: string;
1529
+ /**
1530
+ * Required SDK range for this package, e.g. `^1.0.0`.
1531
+ * Only caret (`^x.y.z`) and exact `x.y.z` forms are interpreted; unknown shapes are ignored (lenient).
1532
+ */
1533
+ peerRange?: string;
1534
+ capabilities?: PapermapCapability[];
1535
+ }
1536
+ interface PapermapPluginContext {
1537
+ manifest: PapermapPluginManifest;
1538
+ workspaceId: string;
1539
+ dashboardId: string;
1540
+ apiUrl?: string;
1541
+ observability: PapermapObservability;
1542
+ }
1543
+ interface PapermapPluginLifecycle {
1544
+ onActivate?: (ctx: PapermapPluginContext) => void | Promise<void>;
1545
+ onDeactivate?: (ctx: PapermapPluginContext) => void | Promise<void>;
1546
+ onDispose?: (ctx: PapermapPluginContext) => void | Promise<void>;
1547
+ }
1548
+ interface PapermapPluginRegistration {
1549
+ manifest: PapermapPluginManifest;
1550
+ lifecycle?: PapermapPluginLifecycle;
1551
+ }
1552
+ declare function parseSemverPrefix(version: string): [number, number, number] | null;
1553
+ /**
1554
+ * Returns whether the running SDK version satisfies the plugin’s declared range.
1555
+ */
1556
+ declare function checkPluginPeerCompatibility(hostSdkVersion: string, pluginPeerRange?: string): {
1557
+ ok: true;
1558
+ } | {
1559
+ ok: false;
1560
+ reason: string;
1561
+ };
1562
+ declare function createPluginContext(registration: PapermapPluginRegistration, identity: {
1563
+ workspaceId: string;
1564
+ dashboardId: string;
1565
+ apiUrl?: string;
1566
+ }, observability: PapermapObservability): PapermapPluginContext;
1567
+
710
1568
  type PapermapConnectionValue = {
711
1569
  token: string;
712
1570
  workspaceId: string;
@@ -714,10 +1572,32 @@ type PapermapConnectionValue = {
714
1572
  apiUrl?: string;
715
1573
  services: PapermapHttpServices;
716
1574
  };
717
- interface PapermapProviderProps extends PapermapStoreConfig {
1575
+ type PapermapProviderProps = Omit<PapermapStoreConfig, 'observability'> & {
718
1576
  children: React__default.ReactNode;
719
- }
720
- declare function PapermapProvider({ children, token, workspaceId, dashboardId, apiUrl, initialModel, onModelChange, }: PapermapProviderProps): react_jsx_runtime.JSX.Element;
1577
+ /**
1578
+ * Color scheme for the plugin UI (`light` / `dark` / `system`), matching main-app embedded
1579
+ * `?theme=` and `EmbeddedThemeProvider` (`next-themes` + `document.documentElement` class sync).
1580
+ * Default `light`.
1581
+ */
1582
+ theme?: PapermapColorScheme;
1583
+ /** Optional structured telemetry; forwarded to the Zustand store and SSE bridge. */
1584
+ observability?: PapermapObservabilityOptions;
1585
+ /** Optional plugin manifest + lifecycle (v1 contract). Safe to omit for all existing embeds. */
1586
+ plugin?: PapermapPluginRegistration;
1587
+ };
1588
+ /**
1589
+ * Supplies Zustand chat state, HTTP services, and React Query for one **identity boundary**.
1590
+ *
1591
+ * **Runtime switches:** When any of `token`, `workspaceId`, `dashboardId`, or `apiUrl` change, the
1592
+ * provider creates a **new** Zustand store and **new** `QueryClient`. Chat UI state and TanStack Query
1593
+ * cache from the previous boundary are not carried over, which avoids stale tenant/workspace data.
1594
+ *
1595
+ * **Stable props:** Changing only `initialModel`, `initialChatScroll`, `isViewer`, `assistantInline`, `theme`, `onModelChange`, `observability`, `plugin`, or
1596
+ * `children` does **not** reset the store or query cache (except `observability.mirrorToConsoleInDev`,
1597
+ * which recreates the telemetry facade). `onModelChange` / `onTelemetry` / `onError` may be inline —
1598
+ * the latest callback is always invoked via refs.
1599
+ */
1600
+ declare function PapermapProvider({ children, token, workspaceId, dashboardId, apiUrl, initialModel, initialChatScroll, isViewer, assistantInline, onModelChange, observability: observabilityProp, plugin, theme, }: PapermapProviderProps): react_jsx_runtime.JSX.Element;
721
1601
  declare function usePapermapStore<T>(selector: (state: PapermapStore) => T): T;
722
1602
  /**
723
1603
  * Access the raw store API (for refs, services, imperative calls).
@@ -733,12 +1613,25 @@ declare function usePapermapStoreApiOptional(): PapermapStoreApi | null;
733
1613
  declare function usePapermapConnection(): PapermapConnectionValue;
734
1614
  declare function usePapermapConnectionOptional(): PapermapConnectionValue | null;
735
1615
 
736
- interface KeyboardShortcutHandlers {
1616
+ interface UseKeyboardShortcutsOptions {
1617
+ shortcutKey?: string;
737
1618
  onToggle?: () => void;
1619
+ /**
1620
+ * Legacy Escape when not using `escapeLayerActive` + `instanceId`.
1621
+ * Prefer `onEscapeLayerClose` for multiple embeds.
1622
+ */
738
1623
  onEscape?: () => void;
739
- shortcutKey?: string;
1624
+ /** Stable id from `useId()` — enables multi-instance shortcut + Escape stacking. */
1625
+ instanceId?: string;
1626
+ /** Root that contains this chat surface (toolbar, overlays, portaled UI). */
1627
+ shortcutRootRef?: RefObject<HTMLElement | null>;
1628
+ /** When true, Escape is handled via a global stack (deepest / last-opened closes first). */
1629
+ escapeLayerActive?: boolean;
1630
+ onEscapeLayerClose?: () => void;
1631
+ /** Bumps when portaled DOM attaches so `shortcutRootRef` can be bound. */
1632
+ shortcutLayoutSyncKey?: string | number;
740
1633
  }
741
- declare function useKeyboardShortcuts({ onToggle, onEscape, shortcutKey, }: KeyboardShortcutHandlers): void;
1634
+ declare function useKeyboardShortcuts({ onToggle, onEscape, shortcutKey, instanceId, shortcutRootRef, escapeLayerActive, onEscapeLayerClose, shortcutLayoutSyncKey, }: UseKeyboardShortcutsOptions): void;
742
1635
 
743
1636
  declare function useAutoResize(textareaRef: RefObject<HTMLTextAreaElement | null>, minHeight?: number, maxHeight?: number): {
744
1637
  resize: () => void;
@@ -750,10 +1643,17 @@ declare function useAutoFade(enabled: boolean, delay?: number, suppressWhen?: bo
750
1643
  };
751
1644
 
752
1645
  interface UseAnalyticsStreamOptions {
753
- onComplete?: (data: any) => void;
1646
+ onComplete?: (data: unknown) => void;
754
1647
  onError?: (error: string) => void;
755
1648
  onThought?: (thought: AgentThought) => void;
756
1649
  onToolCall?: (toolCall: ToolCall) => void;
1650
+ /** HTTP implementation — typically `chartSvc.submitToolConfirmation` from the store */
1651
+ submitToolConfirmationRequest?: (data: {
1652
+ request_id: string;
1653
+ confirmation_id: string;
1654
+ confirmed: boolean;
1655
+ message?: string;
1656
+ }) => Promise<unknown>;
757
1657
  }
758
1658
  /**
759
1659
  * Adapted from papermap's useAnalyticsStream.
@@ -762,17 +1662,36 @@ interface UseAnalyticsStreamOptions {
762
1662
  declare function useAnalyticsStream(requestId: string | null, authHeaders: Record<string, string>, apiUrl: string, options?: UseAnalyticsStreamOptions): {
763
1663
  disconnect: () => void;
764
1664
  markRequestAsCompleted: (reqId: string) => void;
1665
+ submitConfirmation: (confirmationId: string, confirmed: boolean, message?: string) => Promise<void>;
765
1666
  thoughts: AgentThought[];
766
1667
  toolCalls: ToolCall[];
767
1668
  timeline: TimelineEvent[];
768
1669
  currentPhase: string;
769
1670
  error: string | null;
770
- finalResponse: any | null;
1671
+ finalResponse: unknown | null;
771
1672
  isComplete: boolean;
772
1673
  isConnected: boolean;
773
1674
  isStreaming: boolean;
774
1675
  };
775
1676
 
1677
+ interface TourStep extends DriveStep {
1678
+ element?: string;
1679
+ popover?: {
1680
+ title?: string;
1681
+ description: string;
1682
+ side?: 'left' | 'right' | 'top' | 'bottom';
1683
+ align?: 'start' | 'center' | 'end';
1684
+ };
1685
+ }
1686
+ interface UseTourOptions {
1687
+ onComplete?: () => void;
1688
+ onSkip?: () => void;
1689
+ }
1690
+ declare function useTour(options?: UseTourOptions): {
1691
+ startTour: (steps: TourStep[]) => void;
1692
+ stopTour: () => void;
1693
+ };
1694
+
776
1695
  interface DecodedToken {
777
1696
  api_key_id: string;
778
1697
  workspace_id: string;
@@ -789,6 +1708,35 @@ declare function createApiClient(token: string, apiUrl?: string): {
789
1708
  authHeaders: Record<string, string>;
790
1709
  };
791
1710
 
1711
+ /** Normalized API origin segment so keys differ per host when IDs collide. */
1712
+ declare function papermapApiBaseSegment(apiUrl?: string): string;
1713
+ /**
1714
+ * Hierarchical TanStack Query keys scoped by API base + workspace + dashboard.
1715
+ * Prevents cache bleed when the same dashboard id appears under different workspaces or APIs.
1716
+ */
1717
+ declare const papermapQueryKeys: {
1718
+ readonly root: readonly ["papermap"];
1719
+ readonly scope: (params: {
1720
+ workspaceId: string;
1721
+ dashboardId: string;
1722
+ apiUrl?: string;
1723
+ }) => readonly ["papermap", string, "ws", string, "dash", string];
1724
+ readonly conversationHistory: (workspaceId: string, dashboardId: string, apiUrl?: string) => readonly ["papermap", string, "ws", string, "dash", string, "conversationHistory"];
1725
+ readonly chartCards: (workspaceId: string, dashboardId: string, apiUrl?: string) => readonly ["papermap", string, "ws", string, "dash", string, "chartCards"];
1726
+ readonly dashboardsForWorkspace: (workspaceId: string, apiUrl?: string) => readonly ["papermap", string, "ws", string, "dashboards"];
1727
+ readonly workspacesList: (apiUrl?: string) => readonly ["papermap", string, "workspaces", "list"];
1728
+ /** Infinite workspace list with optional search (matches main app workspace selector). */
1729
+ readonly workspacesInfinite: (apiUrl: string | undefined, searchTerm: string | undefined) => readonly ["papermap", string, "workspaces", "infinite", string];
1730
+ /** Paginated dashboards for a workspace with optional search. */
1731
+ readonly dashboardsPaginated: (workspaceId: string | undefined, apiUrl: string | undefined, page: number, perPage: number, searchTerm: string | undefined) => readonly ["papermap", string, "ws", string, "dashboardsPaginated", number, number, string];
1732
+ readonly models: (apiUrl: string | undefined, token: string) => readonly ["papermap", string, "models", string];
1733
+ readonly slack: {
1734
+ readonly all: (apiUrl: string | undefined) => readonly ["papermap", string, "slack"];
1735
+ readonly status: (apiUrl: string | undefined) => readonly ["papermap", string, "slack", "status"];
1736
+ readonly workspaceAccess: (apiUrl: string | undefined, teamId: string) => readonly ["papermap", string, "slack", "workspace-access", string];
1737
+ };
1738
+ };
1739
+
792
1740
  interface PaperBoardProps {
793
1741
  token?: string;
794
1742
  workspaceId?: string;
@@ -798,7 +1746,17 @@ interface PaperBoardProps {
798
1746
  layouts?: PaperBoardLayouts;
799
1747
  onLayoutsChange?: (layouts: PaperBoardLayouts) => void;
800
1748
  isEditMode?: boolean;
1749
+ /**
1750
+ * Show the **dashboard** toolbar (generate, screenshot, edit layout, theme, etc.) in the page header.
1751
+ * Main app `TGridDashboard.showToolbar`. Default `true`.
1752
+ */
801
1753
  showToolbar?: boolean;
1754
+ /**
1755
+ * Show **per-chart** controls (maximize, edit, delete) on each `PaperCard`. Independent of `showToolbar`.
1756
+ * Main app `TGridDashboard.showChatToolbar` on `ChartCard`. When omitted, matches `showToolbar` so
1757
+ * `showToolbar={false}` still hides both toolbars.
1758
+ */
1759
+ showChatToolbar?: boolean;
802
1760
  showScreenshot?: boolean;
803
1761
  showGenerateDashboard?: boolean;
804
1762
  editLayout?: boolean;
@@ -832,8 +1790,84 @@ interface PaperBoardProps {
832
1790
  enableFetch?: boolean;
833
1791
  showChatAssistant?: boolean;
834
1792
  variant?: 'default' | 'streaming';
1793
+ /**
1794
+ * When true, shows a “Tour” control in the header and enables the dashboard product tour (driver.js).
1795
+ * Default false until the embed tour UX is finalized.
1796
+ */
1797
+ showDashboardTour?: boolean;
1798
+ /**
1799
+ * When true, starts the tour once after load if it has not been completed (localStorage).
1800
+ * Waits until the chat bar is not open or focused. Default false for embeds.
1801
+ */
1802
+ autoStartDashboardTour?: boolean;
1803
+ /** Overrides localStorage key for tour completion (`1` = done). */
1804
+ dashboardTourStorageKey?: string;
1805
+ /** Called when the user finishes or skips the tour (after persisting completion). */
1806
+ onDashboardTourComplete?: () => void;
1807
+ /**
1808
+ * When true (default), show workspace and dashboard dropdowns in the header when `enableFetch` is on
1809
+ * and the board is not in viewer mode. With a parent `PapermapProvider`, you must also pass
1810
+ * `onWorkspaceDashboardChange` so the host can update provider props.
1811
+ */
1812
+ showWorkspaceDashboardSelect?: boolean;
1813
+ /** Update parent state when the user picks another workspace or dashboard (required with a parent provider). */
1814
+ onWorkspaceDashboardChange?: (ctx: {
1815
+ workspaceId: string;
1816
+ dashboardId: string;
1817
+ }) => void;
1818
+ /** Color scheme when this component creates `PapermapProvider` (embedded `?theme=` parity). */
1819
+ theme?: PapermapColorScheme;
1820
+ /**
1821
+ * When true, render main-app-style top bar (logo, workspace selector, integrations, user)
1822
+ * and tab navigation above the `PageHeader` and grid. Default `false` for embeds; set `true` for full-app chrome.
1823
+ */
1824
+ showAppChrome?: boolean;
1825
+ /**
1826
+ * Override default tab items (Papermap web app deep links with workspace/dashboard query params).
1827
+ * When omitted, items are built from the workspace API entity (see `buildDashboardNavItems`).
1828
+ */
1829
+ navItems?: DashboardNavbarItem[];
1830
+ /** Shown in the user menu; optional when using embed tokens without a user profile. */
1831
+ user?: {
1832
+ name?: string | null;
1833
+ email?: string | null;
1834
+ } | null;
1835
+ onLogout?: () => void;
1836
+ billingHref?: string;
1837
+ settingsHref?: string;
1838
+ /** Default: Papermap web app origin. */
1839
+ logoutUrl?: string;
1840
+ appHeaderRightSlot?: ReactNode;
835
1841
  }
836
- declare function PaperBoard({ token, workspaceId, dashboardId, apiUrl, ...rest }: PaperBoardProps): react_jsx_runtime.JSX.Element;
1842
+ declare function PaperBoard({ token, workspaceId, dashboardId, apiUrl, theme, showWorkspaceDashboardSelect, onWorkspaceDashboardChange, showAppChrome, navItems: navItemsProp, user: userProp, onLogout, billingHref, settingsHref, logoutUrl, appHeaderRightSlot, ...rest }: PaperBoardProps): react_jsx_runtime.JSX.Element;
1843
+
1844
+ declare function readDashboardTourCompleted(key: string): boolean;
1845
+ declare function markDashboardTourCompleted(key: string): void;
1846
+ type BuildDashboardTourStepsOptions = {
1847
+ showToolbar: boolean;
1848
+ showChatAssistant: boolean;
1849
+ };
1850
+ /**
1851
+ * Driver.js steps aligned with main app GridDashboard tour (workspace selector omitted in embed).
1852
+ */
1853
+ declare function buildDashboardTourSteps({ showToolbar, showChatAssistant, }: BuildDashboardTourStepsOptions): TourStep[];
1854
+
1855
+ type BuildDashboardNavItemsParams = {
1856
+ workspaceId: string;
1857
+ dashboardId: string;
1858
+ /** From workspace entity */
1859
+ workspaceType?: string;
1860
+ /** Present when Google Sheet source exists */
1861
+ sheet?: string;
1862
+ isAdmin?: boolean;
1863
+ /** When true, user is read-only; hides editor-only tabs (matches main app viewer gating). */
1864
+ isViewer: boolean;
1865
+ };
1866
+ /**
1867
+ * Main app: [src/navigation/sidebar/sidebarItems.tsx](papermap/src/navigation/sidebar/sidebarItems.tsx).
1868
+ * Links open the hosted Papermap web app with `workspace_id` / `dashboard_id` query params.
1869
+ */
1870
+ declare function buildDashboardNavItems(params: BuildDashboardNavItemsParams): DashboardNavbarItem[];
837
1871
 
838
1872
  type ThemePreset = 'default' | 'lime' | 'blue' | 'green' | 'purple' | 'ocean' | 'sunset' | 'dark' | 'minimal';
839
1873
 
@@ -865,10 +1899,7 @@ declare const presetDisplayNames: Record<ThemePreset, string>;
865
1899
  * 1. `meta.apply_theme_to_all_dashboards` + `meta.default_theme`
866
1900
  * 2. `meta.theme[dashboardId]` (falls back to `default_dashboard` when `dashboardId` is empty)
867
1901
  */
868
- declare function resolveDashboardThemeFromWorkspace(workspace: {
869
- meta?: Record<string, any>;
870
- default_dashboard?: string;
871
- } | null | undefined, dashboardId: string): DashboardTheme | undefined;
1902
+ declare function resolveDashboardThemeFromWorkspace(workspace: WorkspaceEntity | null | undefined, dashboardId: string): DashboardTheme | undefined;
872
1903
 
873
1904
  /**
874
1905
  * Persistent link between a host-owned stable id (`id` on {@link PaperCard})
@@ -917,4 +1948,4 @@ declare function resolveChartFetchChatId(params: {
917
1948
  dashboardId?: string;
918
1949
  }): string | undefined;
919
1950
 
920
- export { type AgentThought, AgentThoughtDisplay, BookmarkButton, BranchButton, ButtonWithTooltip, CHART_CARD_CHAT_MAP_KEY, CHAT_MODAL_TAB, type ChartCardIdLink, type ChartCardStorageNamespace, ChartDialog, ChartHistory, type ChartResponse, ChartView, ChatAssistant, type ChatModalTabType, type ConversationHistory, type DashboardTheme, DataTable, type DecodedToken, FeedbackButtons, type FinalResponse, LogoStandAlone, type Message, ModelSelector, MorphGradient, type OpenPapermapChatAssistantOptions, PaperBoard, type TLayout as PaperBoardLayoutItem, type PaperBoardLayouts, PaperCard, type PaperCardProps, PaperChat, type PaperChatProps, type PapermapActions, PapermapProvider as PapermapConfigProvider, type PapermapConnectionValue, type PapermapHttpServices, PapermapProvider, type PapermapState, type PapermapStore, type PapermapStoreApi, type PapermapStoreConfig, RecentConversations, SavedMemory, type StreamState, StreamingChartDialog, StreamingChatPanel, StreamingTimeline, type TChartMeta$1 as TChartMeta, type TChartResponse, ThemeCustomizationSettings, type ThemeCustomizationSettingsProps, type ThemePreset, type ThemeSaveMeta, type TimelineEvent, type ToolCall, ToolCallDisplay, buildAuthHeaders, createApiClient, createPapermapServices, createPapermapStore, decodeToken, defaultTheme, getChartCardIdLink, openPapermapChatAssistant, presetDisplayNames, removeChartCardIdLink, resolveChartFetchChatId, resolveDashboardThemeFromWorkspace, themePresetList, themePresets, upsertChartCardIdLink, useAnalyticsStream, useAutoFade, useAutoResize, useKeyboardShortcuts, usePapermapConnection, usePapermapConnectionOptional, usePapermapStore, usePapermapStoreApi, usePapermapStoreApiOptional };
1951
+ export { type AgentThought, AgentThoughtDisplay, BookmarkButton, BranchButton, type BuildDashboardNavItemsParams, ButtonWithTooltip, CHART_CARD_CHAT_MAP_KEY, CHAT_MODAL_TAB, type ChartCardIdLink, type ChartCardStorageNamespace, type ChartDataRow, ChartDialog, ChartHistory, type ChartResponse, ChartView, type ChartVisualizationConfig, ChatAssistant, type ChatModalTabType, ChatSidePanel, type ConversationHistory, CreateDashboardDialog, type CreateDashboardDialogProps, CreateUnifiedWorkspaceDialog, type CreateUnifiedWorkspaceDialogProps, type CreatedDashboard, type CreatedUnifiedWorkspace, DashboardAppHeader, type DashboardNavbarItem, DashboardTabNavigation, type DashboardTabNavigationProps, type DashboardTheme, DataTable, type DecodedToken, FeedbackButtons, type FinalResponse, FloatingChartOverlay, IntegrationsBar, type JsonObject, LogoStandAlone, type Message, type MessageProgressEvent, ModelSelector, MorphGradient, type OpenPapermapChatAssistantOptions, PAPERMAP_CHAT_GREETING_MESSAGE, PAPERMAP_PLUGIN_CONTRACT_VERSION, PAPERMAP_SDK_VERSION, PaperBoard, type TLayout as PaperBoardLayoutItem, type PaperBoardLayouts, PaperCard, type PaperCardProps, PaperChat, type PaperChatAvatars, PaperChatDialogInner, type PaperChatDialogInnerProps, type PaperChatDialogLauncherPosition, PaperChatFloatingChartOverlay, type PaperChatFloatingChartOverlayProps, type PaperChatProps, PaperChatSidePanel, type PaperChatSidePanelProps, type PaperChatSidePosition, type PaperChatVariant, PaperDashboardSelect, type PaperDashboardSelectProps, type PapermapActions, type PapermapCapability, type PapermapColorScheme, PapermapProvider as PapermapConfigProvider, type PapermapConnectionValue, type PapermapHttpServices, type PapermapObservability, type PapermapObservabilityOptions, type PapermapPluginContext, type PapermapPluginLifecycle, type PapermapPluginManifest, type PapermapPluginRegistration, PapermapProvider, type PapermapState, type PapermapStore, type PapermapStoreApi, type PapermapStoreConfig, type PapermapTelemetryEvent, type PapermapTelemetryLevel, RecentConversations, SavedMemory, type StreamState, StreamingChartDialog, StreamingChatPanel, StreamingTimeline, type TChartMeta$1 as TChartMeta, type TChartResponse, ThemeCustomizationSettings, type ThemeCustomizationSettingsProps, type ThemePreset, type ThemeSaveMeta, type TimelineEvent, type ToolCall, ToolCallDisplay, type TourStep, type UseTourOptions, UserNav, type WorkspaceEntity, type WorkspaceMeta, WorkspaceSelector, type WorkspaceSelectorControl, WorkspaceSelectorProvider, buildAuthHeaders, buildDashboardNavItems, buildDashboardTourSteps, checkPluginPeerCompatibility, createApiClient, createPapermapObservability, createPapermapServices, createPapermapStore, createPluginContext, decodeToken, defaultTheme, getChartCardIdLink, markDashboardTourCompleted, openPapermapChatAssistant, papermapApiBaseSegment, papermapQueryKeys, parseSemverPrefix, presetDisplayNames, readDashboardTourCompleted, removeChartCardIdLink, resolveChartFetchChatId, resolveDashboardThemeFromWorkspace, themePresetList, themePresets, unwrapWorkspacePayload, upsertChartCardIdLink, useAnalyticsStream, useAutoFade, useAutoResize, useKeyboardShortcuts, usePapermapConnection, usePapermapConnectionOptional, usePapermapStore, usePapermapStoreApi, usePapermapStoreApiOptional, useTour };