@tangle-network/agent-app 0.52.17 → 0.53.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.
@@ -1,21 +1,35 @@
1
1
  /**
2
- * Persistent assistant entry point: a floating launcher that opens the chat
3
- * panel as a right-side drawer (full-screen on small viewports), with focus
4
- * trapping and a resizable width. Owns the chat state (via useAssistantChat) so
5
- * the conversation survives the drawer closing — host-shell concerns (the user,
6
- * navigation, balance, money formatting, the graph renderer, and the workflow-
7
- * mutation signal) are injected.
2
+ * The assistant's place in the app shell: a right-side panel that mirrors the
3
+ * left sidebar. A panel toggle opens and closes it (top right while closed,
4
+ * the header's inner edge while open) and ⌘E / Ctrl+E does the same. On wide
5
+ * viewports the panel docks beside the page: it is non-modal, resizable, and
6
+ * the launcher's `inset` tells the shell how far to pad its page column so the
7
+ * panel never covers page content. On narrower viewports it opens as a modal
8
+ * sheet, full screen on phones. Width and open state persist per user.
9
+ *
10
+ * The dock owns the chat state (via useAssistantChat) so the conversation
11
+ * survives the panel closing. Host-shell concerns (the user, navigation,
12
+ * balance, money formatting, renderers, the page context, and the
13
+ * workflow-mutation signal) are injected.
8
14
  *
9
15
  * Mount inside an <AssistantClientProvider> (transport) and an
10
- * <AssistantLauncherProvider> (open/seed state).
16
+ * <AssistantLauncherProvider> (panel state).
11
17
  */
12
18
  import { type ReactNode } from "react";
13
- import { type ToolDetailRenderers } from "../web-react";
19
+ import type { ToolDetailRenderers } from "../web-react";
14
20
  import { type AssistantPanelProps } from "./AssistantPanel";
15
- import type { AssistantTranscriptView, ConfirmedResult, ConnectionRequirement, ConnectRequirementResult } from "./types";
21
+ import type { AssistantPageContext, ConfirmedResult, ConnectionRequirement, ConnectRequirementResult } from "./types";
16
22
  export interface AssistantDockProps {
17
23
  /** The signed-in user this conversation belongs to (null when signed out). */
18
24
  userId: string | null;
25
+ /** The page the user has open. Shown in the panel header and sent with
26
+ * every turn. */
27
+ context?: AssistantPageContext | null;
28
+ /** Render the panel toggle at the viewport's top right while the panel is
29
+ * closed. Pass false when the host places `AssistantPanelToggle` in its own
30
+ * header. Hosts can tune the floating position with the
31
+ * `--assistant-toggle-top` and `--assistant-toggle-right` CSS variables. */
32
+ floatingToggle?: boolean;
19
33
  /** Host navigation for error CTAs and connect targets. */
20
34
  navigate?: (path: string) => void;
21
35
  balanceUsd?: number | null;
@@ -23,34 +37,25 @@ export interface AssistantDockProps {
23
37
  /** Render workflow YAML as a node graph in a proposal card. */
24
38
  renderGraph?: (yaml: string) => ReactNode;
25
39
  /** Render the brand icon for a proposal requirement's integration provider.
26
- * The host owns the provider→icon mapping (its integrations catalog); when
27
- * absent, the card falls back to its built-in provider mark. */
40
+ * When absent, the card falls back to its built-in provider mark. */
28
41
  renderProviderIcon?: (provider: string) => ReactNode;
29
42
  /** Called after a workflow-mutating tool is confirmed (host re-fetches its list). */
30
43
  onWorkflowMutation?: () => void;
31
- /** In-place connect handler for a proposal's integration requirements. The host
32
- * runs its own connect flow (OAuth popup, api-key modal, app install) and
33
- * resolves whether the requirement is now satisfied; the proposal card then
34
- * flips it to connected. Host-agnostic — when omitted, the card falls back to
35
- * navigating the requirement's connect target via `navigate`. */
44
+ /** In-place connect handler for a proposal's integration requirements. The
45
+ * host runs its own connect flow and resolves whether the requirement is now
46
+ * satisfied. When omitted, the card navigates to the requirement's connect
47
+ * target via `navigate`. */
36
48
  onConnectRequirement?: (requirement: ConnectionRequirement) => Promise<ConnectRequirementResult>;
37
- /** Markdown renderer for assistant message content (plain text when absent). */
38
- renderMarkdown?: (content: string) => ReactNode;
39
- /** Per-tool custom detail renderers for expanded tool cards in the transcript. */
49
+ /** Per-tool detail renderers for expanded tool rows. */
40
50
  toolRenderers?: ToolDetailRenderers;
41
51
  /** Render a prominent card for a CONFIRMED tool's result (e.g. a one-time
42
- * API-key reveal for `create_api_key`), shown inline after the action's status
43
- * line. The result's `output` may carry a one-time secret — see
44
- * {@link ConfirmedResult} for the never-persist/never-to-model contract. */
52
+ * API-key reveal for `create_api_key`). The result's `output` may carry a
53
+ * one-time secret — see {@link ConfirmedResult}. */
45
54
  renderConfirmedResult?: (result: ConfirmedResult) => ReactNode;
46
- /** Swap the conversation rendering for a host-supplied renderer (see
47
- * {@link AssistantPanelProps.renderTranscript}); the dock chrome, composer,
48
- * transport, and proposal flow stay owned by the panel. */
49
- renderTranscript?: (view: AssistantTranscriptView) => ReactNode;
50
- /** Opt-in attachment surface for the dock's composer — forwarded to
55
+ /** Opt-in attachment surface for the composer — forwarded to
51
56
  * {@link AssistantPanelProps.composerAttachments}. */
52
57
  composerAttachments?: AssistantPanelProps["composerAttachments"];
53
58
  /** Forwarded to {@link AssistantPanelProps.onComposerSend}. */
54
59
  onComposerSend?: AssistantPanelProps["onComposerSend"];
55
60
  }
56
- export declare function AssistantDock({ userId, navigate, balanceUsd, formatMoney, renderGraph, renderProviderIcon, onWorkflowMutation, onConnectRequirement, renderMarkdown, toolRenderers, renderConfirmedResult, renderTranscript, composerAttachments, onComposerSend, }: AssistantDockProps): import("react").JSX.Element;
61
+ export declare function AssistantDock({ userId, context, floatingToggle, navigate, balanceUsd, formatMoney, renderGraph, renderProviderIcon, onWorkflowMutation, onConnectRequirement, toolRenderers, renderConfirmedResult, composerAttachments, onComposerSend, }: AssistantDockProps): import("react").JSX.Element | null;
@@ -1,52 +1,51 @@
1
1
  /**
2
- * The assistant chat panel, built on web-react's chat components. The reducer
3
- * state is rendered by `AssistantTranscript` (web-react `ChatMessages`: transcript,
4
- * tool chips, reasoning preview, cost, proposal cards) and the composer is a
5
- * `ChatComposer` carrying the `ModelPicker` in its controls slot. The header's
6
- * history toggle swaps the conversation area for a full-panel, searchable history
7
- * view. App-shell concerns — the signed-in user, navigation, the credit balance,
8
- * money formatting, the markdown + tool-detail renderers, and the workflow-graph
9
- * renderer — are injected so the panel is portable across hosts. Chat state is
10
- * owned by the dock and passed in, so the conversation survives the drawer closing.
2
+ * The assistant chat panel. The conversation renders through the main chat's
3
+ * primitives (`AssistantTranscript` over `AgentTimeline`), notices follow the
4
+ * main chat's status banners, and the composer is the same `ChatComposer` the
5
+ * sandbox session uses, with the quiet `ModelPicker` in its controls slot. The
6
+ * header names the page the assistant is looking at; its history toggle swaps
7
+ * the conversation for a searchable history view. App-shell concerns (the
8
+ * signed-in user, navigation, balance, money formatting, tool-detail and graph
9
+ * renderers) are injected so the panel is portable across hosts. Chat state is
10
+ * owned by the dock and passed in, so the conversation survives the panel
11
+ * closing.
11
12
  */
12
- import { type ReactNode } from "react";
13
+ import { type ReactNode, type Ref } from "react";
13
14
  import type { CatalogModel } from "../runtime/model-catalog";
14
15
  import { type ComposerFile, type ToolDetailRenderers } from "../web-react";
15
16
  import type { AssistantModels } from "./client";
16
- import type { AssistantTranscriptView, ConfirmedResult } from "./types";
17
+ import type { AssistantPanelLayout } from "./launcher";
18
+ import type { AssistantPageContext, ConfirmedResult } from "./types";
17
19
  import type { AssistantChat } from "./useAssistantChat";
18
20
  export interface AssistantPanelProps {
19
21
  chat: AssistantChat;
20
22
  userId: string | null;
21
23
  onClose: () => void;
24
+ /** `docked` puts the panel toggle on the header's inner edge; `sheet` adds a
25
+ * close button on its outer edge. Defaults to `docked`. */
26
+ layout?: AssistantPanelLayout;
27
+ /** The page the user has open, named under the panel title. */
28
+ context?: AssistantPageContext | null;
29
+ /** Receives the header's panel toggle, so the dock can return focus to it. */
30
+ toggleRef?: Ref<HTMLButtonElement>;
22
31
  /** Host navigation for error CTAs and connect targets. */
23
32
  navigate?: (path: string) => void;
24
- /** The user's credit balance, for the header tile + low-balance nudge. */
33
+ /** The user's credit balance, for the header and the low-balance notice. */
25
34
  balanceUsd?: number | null;
26
35
  /** Format a USD amount; defaults to Intl currency formatting. */
27
36
  formatMoney?: (usd: number | null) => string;
28
- /** Render workflow YAML as a node graph in a proposal card (the `./workflows`
29
- * WorkflowGraph). When absent, proposals show YAML as text. */
37
+ /** Render workflow YAML as a node graph in a proposal card. When absent,
38
+ * proposals show YAML as text. */
30
39
  renderGraph?: (yaml: string) => ReactNode;
31
40
  /** Render the brand icon for a proposal requirement's integration provider.
32
41
  * When absent, the card falls back to its built-in provider mark. */
33
42
  renderProviderIcon?: (provider: string) => ReactNode;
34
- /** Markdown renderer for assistant message content. When absent, content
35
- * renders as plain pre-wrapped text. */
36
- renderMarkdown?: (content: string) => ReactNode;
37
- /** Per-tool custom detail renderers for expanded tool cards in the transcript. */
43
+ /** Per-tool detail renderers for expanded tool rows. A renderer returning
44
+ * null falls back to the shared row's input/output detail. */
38
45
  toolRenderers?: ToolDetailRenderers;
39
46
  /** Render a prominent card for a CONFIRMED tool's result (e.g. a one-time
40
- * API-key reveal for `create_api_key`), shown inline after the action's status
41
- * line. Ignored when a host swaps the whole transcript via `renderTranscript`. */
47
+ * API-key reveal for `create_api_key`), shown after the action's status. */
42
48
  renderConfirmedResult?: (result: ConfirmedResult) => ReactNode;
43
- /** Swap ONLY the conversation rendering for a host-supplied renderer (e.g. a
44
- * different chat-message component), while the panel keeps owning the header,
45
- * composer, model picker, history, transport, and proposal orchestration.
46
- * Receives the transcript slice plus a bound proposal card to place. When
47
- * absent, the built-in transcript (web-react `ChatMessages`) renders the
48
- * conversation. */
49
- renderTranscript?: (view: AssistantTranscriptView) => ReactNode;
50
49
  /** One-shot composer prefill from the host's launcher (e.g. a page's "Create
51
50
  * with assistant" button passing `openAssistant(seed)`). The panel adopts it
52
51
  * as the composer draft and calls `onComposerSeedApplied` once, so the host
@@ -81,4 +80,4 @@ export declare function toPickerModels(models: AssistantModels, selected: string
81
80
  * user to it even after the server default changes). Any other id is stored as-is.
82
81
  */
83
82
  export declare function nextModelSelection(id: string, defaultSlug: string | null): string | null;
84
- export declare function AssistantPanel({ chat, userId, onClose, navigate, balanceUsd, formatMoney, renderGraph, renderProviderIcon, renderMarkdown, toolRenderers, renderConfirmedResult, renderTranscript, composerSeed, onComposerSeedApplied, composerAttachments, onComposerSend, }: AssistantPanelProps): import("react").JSX.Element;
83
+ export declare function AssistantPanel({ chat, userId, onClose, layout, context, toggleRef, navigate, balanceUsd, formatMoney, renderGraph, renderProviderIcon, toolRenderers, renderConfirmedResult, composerSeed, onComposerSeedApplied, composerAttachments, onComposerSend, }: AssistantPanelProps): import("react").JSX.Element;
@@ -1,7 +1,7 @@
1
1
  /**
2
- * Drag-to-resize grip on the assistant drawer's left edge. Pointer capture keeps
2
+ * Drag-to-resize grip on the assistant panel's left edge. Pointer capture keeps
3
3
  * the drag alive while the cursor moves anywhere on screen; arrow keys resize in
4
- * coarse steps for keyboard users. The drawer is right-anchored, so dragging
4
+ * coarse steps for keyboard users. The panel is right-anchored, so dragging
5
5
  * left widens it. The in-memory width updates every move (`onPreview`); the
6
6
  * final width is persisted once on release (`onCommit`).
7
7
  */
@@ -10,7 +10,7 @@ export declare function ResizeHandle({ width, maxWidth, onPreview, onCommit, onN
10
10
  maxWidth: number;
11
11
  /** Live (non-persisted) width update during a drag. The value is the raw
12
12
  * pointer-derived width and is NOT clamped — the consumer must clamp it to its
13
- * own min/max (the bundled `usePanelWidth.previewWidth` does). */
13
+ * own min/max (the launcher's `panel.previewWidth` does). */
14
14
  onPreview: (next: number) => void;
15
15
  /** Persist the final width (drag end). */
16
16
  onCommit: (next: number) => void;
@@ -2,9 +2,10 @@
2
2
  * `@tangle-network/agent-app/assistant` — the in-app assistant/copilot surface,
3
3
  * portable across hosts. A host supplies a transport via {@link createAssistantClient}
4
4
  * and {@link AssistantClientProvider}; the dock, panel, hooks, and proposal card
5
- * consume it and render on web-react's chat components (`ChatComposer`,
6
- * `ChatMessages`, `ModelPicker`). The markdown renderer, per-tool detail
7
- * renderers, and workflow-graph renderer are injected so this subpath carries no
5
+ * consume it. The conversation renders on the main chat's primitives
6
+ * (`@tangle-network/ui` `AgentTimeline` and `InlineToolItem`) and the composer
7
+ * on web-react's `ChatComposer` and `ModelPicker`. Per-tool detail renderers and
8
+ * the workflow-graph renderer are injected so this subpath carries no
8
9
  * product-specific dependency.
9
10
  */
10
11
  export * from "./types";
@@ -15,6 +16,7 @@ export { useAssistantModels } from "./useAssistantModels";
15
16
  export { useAssistantThreads, type AssistantThreads } from "./useAssistantThreads";
16
17
  export { AssistantDock, type AssistantDockProps } from "./AssistantDock";
17
18
  export { AssistantPanel, type AssistantPanelProps } from "./AssistantPanel";
18
- export { AssistantTranscript, type AssistantTranscriptProps, adaptTranscript, assistantIsThinking, } from "./transcript";
19
+ export { AssistantTranscript, type AssistantTranscriptProps, type AssistantTimelineOptions, buildAssistantTimeline, assistantIsThinking, } from "./transcript";
19
20
  export { ProposalCard, type ProposalCardProps } from "./ProposalCard";
20
- export { AssistantLauncherProvider, useAssistantLauncher, type AssistantLauncher, } from "./launcher";
21
+ export { AssistantLauncherProvider, useAssistantLauncher, type AssistantLauncher, type AssistantPanelLayout, } from "./launcher";
22
+ export { AssistantPanelToggle, type AssistantPanelToggleProps, ASSISTANT_PANEL_ID, assistantShortcutLabel, } from "./panel-toggle";