@tangle-network/sandbox-ui 0.39.1 → 0.40.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.
@@ -0,0 +1,169 @@
1
+ import {
2
+ buildWorkflowGraph
3
+ } from "./chunk-SUC6ZJZW.js";
4
+ import {
5
+ providerLabel
6
+ } from "./chunk-7JLB7UZ3.js";
7
+
8
+ // src/workflows/WorkflowGraph.tsx
9
+ import {
10
+ Background,
11
+ Controls,
12
+ Handle,
13
+ Position,
14
+ ReactFlow
15
+ } from "@xyflow/react";
16
+ import "@xyflow/react/dist/style.css";
17
+ import { useEffect, useMemo, useState } from "react";
18
+ import { jsx, jsxs } from "react/jsx-runtime";
19
+ function useColorMode() {
20
+ const [mode, setMode] = useState(
21
+ () => typeof document !== "undefined" && document.documentElement.classList.contains("dark") ? "dark" : "light"
22
+ );
23
+ useEffect(() => {
24
+ const el = document.documentElement;
25
+ const update = () => setMode(el.classList.contains("dark") ? "dark" : "light");
26
+ update();
27
+ const observer = new MutationObserver(update);
28
+ observer.observe(el, { attributes: true, attributeFilter: ["class"] });
29
+ return () => observer.disconnect();
30
+ }, []);
31
+ return mode;
32
+ }
33
+ var TONE_CARD = {
34
+ trigger: "border-primary/60 bg-primary/5",
35
+ structural: "border-accent-yellow/50 bg-accent-yellow/5",
36
+ action: "border-border bg-card"
37
+ };
38
+ var TONE_DOT = {
39
+ trigger: "bg-primary",
40
+ structural: "bg-accent-yellow",
41
+ action: "bg-text-muted"
42
+ };
43
+ var HANDLE_CLASS = "!h-2 !w-2 !min-w-0 !border-0 !bg-transparent opacity-0";
44
+ function WorkflowNode({ data }) {
45
+ const d = data;
46
+ return /* @__PURE__ */ jsxs(
47
+ "div",
48
+ {
49
+ className: `relative w-[240px] rounded-lg border px-3 py-2 shadow-sm ${TONE_CARD[d.tone]}`,
50
+ children: [
51
+ !d.isRoot && /* @__PURE__ */ jsx(
52
+ Handle,
53
+ {
54
+ type: "target",
55
+ position: Position.Top,
56
+ className: HANDLE_CLASS
57
+ }
58
+ ),
59
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
60
+ /* @__PURE__ */ jsx(
61
+ "span",
62
+ {
63
+ "aria-hidden": "true",
64
+ className: `h-2 w-2 shrink-0 rounded-full ${TONE_DOT[d.tone]}`
65
+ }
66
+ ),
67
+ /* @__PURE__ */ jsx("span", { className: "font-medium text-[12px] text-text", children: d.title }),
68
+ d.badge && /* @__PURE__ */ jsx("span", { className: "ml-auto rounded bg-background-tertiary px-1.5 py-0.5 text-[10px] text-text-muted", children: d.badge })
69
+ ] }),
70
+ d.subtitle && /* @__PURE__ */ jsx(
71
+ "p",
72
+ {
73
+ className: "mt-1 truncate text-[11px] text-text-muted",
74
+ title: d.subtitle,
75
+ children: d.subtitle
76
+ }
77
+ ),
78
+ d.provider && /* @__PURE__ */ jsx("span", { className: "mt-1.5 inline-block rounded bg-background-tertiary px-1.5 py-0.5 text-[10px] text-text-muted", children: providerLabel(d.provider) }),
79
+ /* @__PURE__ */ jsx(
80
+ Handle,
81
+ {
82
+ type: "source",
83
+ id: "out",
84
+ position: Position.Bottom,
85
+ className: HANDLE_CLASS
86
+ }
87
+ ),
88
+ d.hasBranches && /* @__PURE__ */ jsx(
89
+ Handle,
90
+ {
91
+ type: "source",
92
+ id: "branch",
93
+ position: Position.Right,
94
+ className: HANDLE_CLASS
95
+ }
96
+ )
97
+ ]
98
+ }
99
+ );
100
+ }
101
+ var NODE_TYPES = { wfNode: WorkflowNode };
102
+ function WorkflowGraph({
103
+ yaml,
104
+ variant = "full",
105
+ className
106
+ }) {
107
+ const colorMode = useColorMode();
108
+ const { nodes, edges, error } = useMemo(() => {
109
+ const graph = buildWorkflowGraph(yaml);
110
+ return {
111
+ error: graph.error,
112
+ nodes: graph.nodes.map(
113
+ (n) => ({
114
+ id: n.id,
115
+ type: "wfNode",
116
+ position: n.position,
117
+ data: n.data
118
+ })
119
+ ),
120
+ edges: graph.edges.map((e) => ({
121
+ id: e.id,
122
+ source: e.source,
123
+ target: e.target,
124
+ sourceHandle: e.sourceHandle,
125
+ type: "smoothstep"
126
+ }))
127
+ };
128
+ }, [yaml]);
129
+ if (error || nodes.length === 0) {
130
+ return /* @__PURE__ */ jsx(
131
+ "div",
132
+ {
133
+ className: `flex items-center justify-center rounded-lg border border-border border-dashed p-4 text-center text-text-muted text-xs ${className ?? ""}`,
134
+ children: error ?? "Nothing to show"
135
+ }
136
+ );
137
+ }
138
+ const isPreview = variant === "preview";
139
+ return /* @__PURE__ */ jsx("div", { className: `wf-graph ${className ?? ""}`, children: /* @__PURE__ */ jsxs(
140
+ ReactFlow,
141
+ {
142
+ nodes,
143
+ edges,
144
+ nodeTypes: NODE_TYPES,
145
+ colorMode,
146
+ fitView: true,
147
+ fitViewOptions: { padding: 0.2 },
148
+ proOptions: { hideAttribution: true },
149
+ nodesDraggable: !isPreview,
150
+ nodesConnectable: false,
151
+ elementsSelectable: !isPreview,
152
+ edgesFocusable: false,
153
+ zoomOnScroll: false,
154
+ zoomOnPinch: true,
155
+ zoomOnDoubleClick: !isPreview,
156
+ panOnDrag: true,
157
+ preventScrolling: false,
158
+ minZoom: 0.2,
159
+ maxZoom: 1.5,
160
+ children: [
161
+ /* @__PURE__ */ jsx(Background, { gap: 16 }),
162
+ /* @__PURE__ */ jsx(Controls, { showInteractive: false, position: "bottom-right" })
163
+ ]
164
+ }
165
+ ) });
166
+ }
167
+ export {
168
+ WorkflowGraph
169
+ };
@@ -0,0 +1,471 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { ReactNode } from 'react';
3
+
4
+ /**
5
+ * Wire + UI types for the in-app assistant panel. The wire shapes mirror the
6
+ * SSE contract emitted by `POST /v1/assistant/chat` (platform-api
7
+ * `routes/assistant.ts`). Drift here only mis-renders the client; the server
8
+ * is the source of truth for what it accepts and emits.
9
+ */
10
+ /** Request body for `POST /api/v1/assistant/chat`. */
11
+ interface ChatRequest {
12
+ message: string;
13
+ /** Model slug to run this turn against; omit to use the server default. */
14
+ model?: string;
15
+ /** Omit to start a new thread; pass to continue an existing one. */
16
+ threadId?: string;
17
+ /** Per-turn idempotency key — guards against double-charge on retry. */
18
+ turnKey?: string;
19
+ }
20
+ interface ThreadEventData {
21
+ threadId: string;
22
+ turnId: string;
23
+ /** The model slug this turn ran against, when the server reports it. */
24
+ model?: string | null;
25
+ }
26
+ interface DeltaEventData {
27
+ text: string;
28
+ }
29
+ /** A chunk of the model's reasoning/thinking, streamed BEFORE the answer for
30
+ * reasoning models. Surfaced as a dim "thinking" block so a long reasoning gap
31
+ * doesn't read as a frozen panel. Absent for non-reasoning models. */
32
+ interface ReasoningEventData {
33
+ text: string;
34
+ }
35
+ /** Emitted when a read-only tool STARTS running, before its result. Lets the
36
+ * panel show live "running <tool>…" progress instead of a silent gap. */
37
+ interface ToolCallEventData {
38
+ callId: string;
39
+ name: string;
40
+ }
41
+ interface ToolResultEventData {
42
+ callId: string;
43
+ name: string;
44
+ ok: boolean;
45
+ output?: unknown;
46
+ error?: {
47
+ code: string;
48
+ message: string;
49
+ };
50
+ }
51
+ /** What kind of connection a requirement names — drives the card's label and
52
+ * connect target. "integration" is an OAuth/api-key connection on the
53
+ * integrations page; "github_app" is the GitHub App installed on the repo (the
54
+ * event source for a GitHub trigger), connected via the App install flow. */
55
+ type ConnectionRequirementKind = "integration" | "github_app";
56
+ /** A connection a proposed workflow references, and whether the user has it
57
+ * connected right now. Surfaced on an authoring proposal so the card can show
58
+ * what must be connected — and WHERE — before the workflow can be created. */
59
+ interface ConnectionRequirement {
60
+ provider: string;
61
+ connected: boolean;
62
+ /** What must be connected. Absent on proposals predating the field — treated
63
+ * as "integration" by the card. */
64
+ kind?: ConnectionRequirementKind;
65
+ /** Where the user connects this requirement, supplied by the server (the
66
+ * GitHub App install URL is deploy config the client can't derive). Null when
67
+ * there's no link to offer (e.g. a github_app requirement on a deploy with no
68
+ * app slug); the card then shows the requirement without a connect link. */
69
+ connectUrl?: string | null;
70
+ }
71
+ interface ToolProposalEventData {
72
+ /** Null only if the server has no proposal store wired (tools then unusable). */
73
+ proposalId: string | null;
74
+ callId: string;
75
+ name: string;
76
+ args: unknown;
77
+ /** Present on a workflow-authoring proposal: the integrations it references
78
+ * and their current connection status. Omitted for non-authoring tools. */
79
+ requirements?: ConnectionRequirement[];
80
+ }
81
+ interface UsageEventData {
82
+ promptTokens: number | null;
83
+ completionTokens: number | null;
84
+ costUsd: number | null;
85
+ balanceUsd: number | null;
86
+ /** True when a completed turn was replayed from storage (no charge). */
87
+ replayed?: boolean;
88
+ }
89
+ interface DoneEventData {
90
+ turnId: string;
91
+ status: string;
92
+ /** True when a mutating tool was proposed and is awaiting confirmation. */
93
+ proposed?: boolean;
94
+ /** True when the agentic loop hit its tool-round cap. */
95
+ capped?: boolean;
96
+ }
97
+ interface ErrorEventData {
98
+ code: string;
99
+ message: string;
100
+ }
101
+ /** Discriminated union the stream reader hands to the reducer. */
102
+ type AssistantStreamEvent = {
103
+ type: "thread";
104
+ data: ThreadEventData;
105
+ } | {
106
+ type: "delta";
107
+ data: DeltaEventData;
108
+ } | {
109
+ type: "reasoning";
110
+ data: ReasoningEventData;
111
+ } | {
112
+ type: "tool_call";
113
+ data: ToolCallEventData;
114
+ } | {
115
+ type: "tool_result";
116
+ data: ToolResultEventData;
117
+ } | {
118
+ type: "tool_proposal";
119
+ data: ToolProposalEventData;
120
+ } | {
121
+ type: "usage";
122
+ data: UsageEventData;
123
+ } | {
124
+ type: "done";
125
+ data: DoneEventData;
126
+ } | {
127
+ type: "error";
128
+ data: ErrorEventData;
129
+ };
130
+ /** A `tool` message is the inline activity chip for a read-only tool the agent
131
+ * ran during a turn (e.g. "Validating workflow… ✓"). */
132
+ type ChatRole = "user" | "assistant" | "status" | "tool";
133
+ /** Live status of a tool-activity chip. */
134
+ type ToolActivityStatus = "running" | "ok" | "failed";
135
+ interface ChatMessage {
136
+ id: string;
137
+ role: ChatRole;
138
+ text: string;
139
+ /** Present only on `tool` messages — the activity's tool name and state. */
140
+ tool?: {
141
+ name: string;
142
+ status: ToolActivityStatus;
143
+ };
144
+ }
145
+ /** A mutating action the assistant proposed, awaiting the user's confirmation. */
146
+ interface PendingProposal {
147
+ proposalId: string | null;
148
+ callId: string;
149
+ name: string;
150
+ args: unknown;
151
+ /** Integration requirements for a workflow-authoring proposal (each provider
152
+ * + whether it's connected); omitted for non-authoring proposals. */
153
+ requirements?: ConnectionRequirement[];
154
+ /** Inline error shown ON the card after a RETRYABLE confirm failure (an
155
+ * unconnected integration): the card stays so the user can connect and
156
+ * confirm again. Null/absent when the card has not failed a retry. */
157
+ retryError?: string | null;
158
+ }
159
+ interface UsageInfo {
160
+ costUsd: number | null;
161
+ balanceUsd: number | null;
162
+ replayed: boolean;
163
+ }
164
+
165
+ /**
166
+ * Configurable network client for the assistant panel: the chat SSE stream, the
167
+ * model/thread/history reads, and the proposal-confirmation call.
168
+ *
169
+ * The transport is injected via {@link AssistantClientConfig} so the same UI can
170
+ * run in different hosts: a same-origin app authenticates with the session
171
+ * cookie (`credentials: "include"`) and an `X-Requested-With` marker, while a
172
+ * cross-origin host points `baseUrl` at the API and supplies a bearer token via
173
+ * `headers`. The request shapes and the defensive wire parsing are identical
174
+ * across hosts — only the base URL and the auth headers vary.
175
+ */
176
+
177
+ /** Host-supplied transport configuration for {@link createAssistantClient}. */
178
+ interface AssistantClientConfig {
179
+ /**
180
+ * Base URL the five assistant endpoints hang off, with no trailing slash —
181
+ * e.g. `"/api/v1/assistant"` for a same-origin SSR edge, or
182
+ * `"https://id.tangle.tools/api/v1/assistant"` cross-origin. Each method
183
+ * appends its own path (`/chat`, `/models`, `/threads`, …).
184
+ */
185
+ baseUrl: string;
186
+ /**
187
+ * `fetch` credentials mode. Defaults to `"include"` so a same-origin cookie
188
+ * session authenticates; a token-based cross-origin host may pass `"omit"`
189
+ * and carry the credential in {@link AssistantClientConfig.headers}.
190
+ */
191
+ credentials?: RequestCredentials;
192
+ /**
193
+ * Headers applied to every request — the auth token and/or the CSRF marker.
194
+ * Called per request so a rotating token is read fresh, never captured once.
195
+ */
196
+ headers?: () => Record<string, string>;
197
+ }
198
+ interface AssistantModelOption {
199
+ slug: string;
200
+ label: string;
201
+ /** USD per million prompt tokens, when the catalog carries pricing. */
202
+ promptUsdPerMillion?: number;
203
+ /** Context window in tokens, when known. */
204
+ contextTokens?: number;
205
+ }
206
+ interface AssistantModels {
207
+ /** The slug the server uses when a turn selects no model. */
208
+ default: string | null;
209
+ models: AssistantModelOption[];
210
+ }
211
+ /** One past conversation in the history switcher. */
212
+ interface AssistantThreadSummary {
213
+ id: string;
214
+ /** Truncated first user message; may be null for an untitled thread. */
215
+ title: string | null;
216
+ createdAt: string;
217
+ updatedAt: string;
218
+ }
219
+ /**
220
+ * Outcome of a model-list fetch. `ok` drives caching: the caller caches on `ok`
221
+ * and retries on `!ok`. An EMPTY list is reported as `!ok` — the server always
222
+ * offers at least the default model when the router is reachable, so an empty
223
+ * menu means the catalog couldn't be loaded and should be retried, not cached
224
+ * for the whole session.
225
+ */
226
+ interface AssistantModelsResult {
227
+ ok: boolean;
228
+ data: AssistantModels;
229
+ }
230
+ /**
231
+ * Outcome of a thread-history restore. The three cases drive different recovery:
232
+ * `ok` rehydrates the transcript; `gone` (the thread 404s — deleted or from a
233
+ * reset DB) tells the caller to drop the dead thread id so the next turn starts
234
+ * fresh; `error` (transient/network/aborted) keeps the thread id and simply
235
+ * doesn't restore, so a later attempt or send still targets the live thread.
236
+ */
237
+ type ThreadHistoryResult = {
238
+ status: "ok";
239
+ messages: ChatMessage[];
240
+ proposals: PendingProposal[];
241
+ } | {
242
+ status: "gone";
243
+ } | {
244
+ status: "error";
245
+ };
246
+ type ConfirmResult = {
247
+ ok: true;
248
+ output: unknown;
249
+ retryable?: boolean;
250
+ } | {
251
+ ok: false;
252
+ error: string;
253
+ };
254
+ /** The assistant network surface, bound to one host's transport config. */
255
+ interface AssistantClient {
256
+ fetchModels(signal?: AbortSignal): Promise<AssistantModelsResult>;
257
+ fetchThreads(signal?: AbortSignal): Promise<AssistantThreadSummary[] | null>;
258
+ fetchThreadHistory(threadId: string, signal?: AbortSignal): Promise<ThreadHistoryResult>;
259
+ streamChat(req: ChatRequest, onEvent: (event: AssistantStreamEvent) => void, signal: AbortSignal): Promise<void>;
260
+ confirmProposal(proposalId: string): Promise<ConfirmResult>;
261
+ }
262
+ /**
263
+ * Build an assistant client bound to one host's transport. The returned methods
264
+ * carry no module state, so a host may create one client per config (or share a
265
+ * single same-origin client for the whole app).
266
+ */
267
+ declare function createAssistantClient(config: AssistantClientConfig): AssistantClient;
268
+
269
+ declare function AssistantClientProvider({ client, children, }: {
270
+ client: AssistantClient;
271
+ children: ReactNode;
272
+ }): react_jsx_runtime.JSX.Element;
273
+ /**
274
+ * The assistant client for the current host. Throws when no provider is mounted
275
+ * rather than silently falling back to a default transport — a missing provider
276
+ * is a wiring bug, and a hidden default would mask it (and could target the
277
+ * wrong origin).
278
+ */
279
+ declare function useAssistantClient(): AssistantClient;
280
+
281
+ /**
282
+ * Pure state machine driving the assistant panel. Every UI transition — a user
283
+ * message, each streamed SSE event, a stream failure, a confirmed/cancelled
284
+ * proposal, a manual stop — is modeled as an action here, so the panel's
285
+ * behavior can be verified without a DOM or a live stream.
286
+ */
287
+
288
+ type ChatStatus = "idle" | "streaming" | "awaiting_confirm";
289
+ interface AssistantState {
290
+ /** The signed-in user this conversation belongs to. Carried in state so it
291
+ * moves atomically with the data it labels — persistence keys off it, and a
292
+ * render whose owner doesn't match the current user is masked (see
293
+ * `selectVisibleState`), preventing a one-frame cross-account leak. */
294
+ ownerId: string | null;
295
+ /** Persisted across reloads to continue the same server-side thread. */
296
+ threadId: string | null;
297
+ messages: ChatMessage[];
298
+ status: ChatStatus;
299
+ /** Id of the assistant message currently accumulating deltas, if any. Set to
300
+ * null mid-turn when a tool runs, so the next text delta opens a fresh
301
+ * assistant bubble — keeping each reasoning segment visually distinct. */
302
+ streamingId: string | null;
303
+ /** Base id for the current turn's assistant bubbles (the `send` assistant id).
304
+ * Post-tool segments derive a unique id from it; null between turns. */
305
+ streamBaseId: string | null;
306
+ /** How many assistant bubbles the current turn has opened (0 = just the first).
307
+ * Drives the per-segment bubble id so segments never collide across turns. */
308
+ segmentSeq: number;
309
+ pendingProposals: PendingProposal[];
310
+ /** Cost/balance from the most recently settled turn. */
311
+ usage: UsageInfo | null;
312
+ /** Model slug the current/most-recent turn ran against (from the thread
313
+ * event), or null before any turn this session. */
314
+ model: string | null;
315
+ /** The current turn's accumulated reasoning/thinking text (reasoning models
316
+ * stream this before the answer). Shown dim while the answer is still pending;
317
+ * reset at the start of each turn. Null when the model emits no reasoning. */
318
+ reasoning: string | null;
319
+ error: {
320
+ code: string;
321
+ message: string;
322
+ } | null;
323
+ }
324
+
325
+ /**
326
+ * React binding for the assistant panel: owns the reducer, drives the chat SSE
327
+ * stream and the proposal-confirmation call, and persists the thread across
328
+ * reloads. All rendering decisions live in the pure reducer + presentation
329
+ * helpers; this hook is the glue between them and the network.
330
+ */
331
+
332
+ /** Host integration callbacks for {@link useAssistantChat}. */
333
+ interface UseAssistantChatOptions {
334
+ /**
335
+ * Called after a workflow-mutating tool (`create_workflow`, `author_workflow`,
336
+ * …) is confirmed successfully — the host re-fetches its workflow list so the
337
+ * result appears without a manual reload. Replaces the in-app cross-module
338
+ * signal the platform used.
339
+ */
340
+ onWorkflowMutation?: () => void;
341
+ }
342
+ interface AssistantChat {
343
+ state: AssistantState;
344
+ /** Proposal ids whose confirmation is currently in flight (for disabling). */
345
+ confirmingIds: ReadonlySet<string>;
346
+ /** The user's selected model slug, or null to use the server default. */
347
+ selectedModel: string | null;
348
+ /** Choose the model for subsequent turns (persisted per user). */
349
+ setModel: (model: string | null) => void;
350
+ send: (message: string) => void;
351
+ stop: () => void;
352
+ confirm: (proposal: PendingProposal) => Promise<void>;
353
+ cancel: (proposal: PendingProposal) => void;
354
+ reset: () => void;
355
+ /** Open an existing thread from history, loading its transcript. */
356
+ switchThread: (threadId: string) => void;
357
+ /** True while a switched-to thread's transcript is loading — the composer is
358
+ * held closed until it resolves so a turn can't run against hidden context. */
359
+ restoring: boolean;
360
+ }
361
+ declare function useAssistantChat(userId: string | null, options?: UseAssistantChatOptions): AssistantChat;
362
+
363
+ /**
364
+ * The assistant's selectable models for the composer's picker. The list is
365
+ * deployment config (not per-user), so it is fetched once per transport and
366
+ * shared across panel mounts via a cache keyed by the `AssistantClient`.
367
+ *
368
+ * The cache has no TTL: it lives for the page session and is revalidated by a
369
+ * page refresh — acceptable for deployment-config data that changes only on a
370
+ * redeploy. An empty/failed fetch is NOT cached, so it retries on the next mount.
371
+ *
372
+ * Keyed by client so a host that swaps the transport (a tenant/origin/account
373
+ * change) never serves the previous client's catalog or skips the fetch for the
374
+ * new one. A WeakMap lets a discarded client's bucket be collected with it.
375
+ *
376
+ * Client-only by design (a `createRoot` SPA, no React SSR), so the cache lives
377
+ * in one browser tab and is never shared across server requests. Under Strict
378
+ * Mode's double-mount the two effect runs share the one in-flight fetch; the
379
+ * first run's `active = false` makes its callback a no-op, the second commits —
380
+ * dedup holds, no torn state.
381
+ */
382
+
383
+ declare function useAssistantModels(): AssistantModels;
384
+
385
+ /**
386
+ * The user's recent assistant chat threads for the history switcher. Unlike the
387
+ * model list (deployment config, fetched once), the thread list changes as the
388
+ * user chats, so it is fetched ON DEMAND — call `refresh()` to (re)load it; the
389
+ * panel does so when the history view opens and after a turn settles a new
390
+ * thread into being. It does NOT fetch on mount, so `threads` stays empty and
391
+ * `loaded` false until the first `refresh()`.
392
+ *
393
+ * Self-protective across account AND transport swaps. The list is tagged with the
394
+ * (user, client) it belongs to and is masked to empty on the SAME commit if that
395
+ * no longer matches the current props — so a swap never shows the prior scope's
396
+ * threads for even one frame. In flight, a late result is dropped if either the
397
+ * user or the client changed, and the request is aborted on the swap.
398
+ */
399
+
400
+ interface AssistantThreads {
401
+ threads: AssistantThreadSummary[];
402
+ loading: boolean;
403
+ /** True once a fetch has settled at least once (drives empty-vs-loading copy). */
404
+ loaded: boolean;
405
+ /** Load (or reload) the thread list. Must be called to populate `threads` —
406
+ * the hook never fetches on mount (the panel calls this when history opens). */
407
+ refresh: () => void;
408
+ }
409
+ declare function useAssistantThreads(userId: string | null): AssistantThreads;
410
+
411
+ interface AssistantDockProps {
412
+ /** The signed-in user this conversation belongs to (null when signed out). */
413
+ userId: string | null;
414
+ /** Host navigation for error CTAs and connect targets. */
415
+ navigate?: (path: string) => void;
416
+ balanceUsd?: number | null;
417
+ formatMoney?: (usd: number | null) => string;
418
+ /** Render workflow YAML as a node graph in a proposal card. */
419
+ renderGraph?: (yaml: string) => ReactNode;
420
+ /** Called after a workflow-mutating tool is confirmed (host re-fetches its list). */
421
+ onWorkflowMutation?: () => void;
422
+ }
423
+ declare function AssistantDock({ userId, navigate, balanceUsd, formatMoney, renderGraph, onWorkflowMutation, }: AssistantDockProps): react_jsx_runtime.JSX.Element;
424
+
425
+ interface AssistantPanelProps {
426
+ chat: AssistantChat;
427
+ userId: string | null;
428
+ onClose: () => void;
429
+ /** Host navigation for error CTAs and connect targets. */
430
+ navigate?: (path: string) => void;
431
+ /** The user's credit balance, for the header tile + low-balance nudge. */
432
+ balanceUsd?: number | null;
433
+ /** Format a USD amount; defaults to Intl currency formatting. */
434
+ formatMoney?: (usd: number | null) => string;
435
+ /** Render workflow YAML as a node graph in a proposal card (the `./workflows`
436
+ * WorkflowGraph). When absent, proposals show YAML as text. */
437
+ renderGraph?: (yaml: string) => ReactNode;
438
+ }
439
+ declare function AssistantPanel({ chat, userId, onClose, navigate, balanceUsd, formatMoney, renderGraph, }: AssistantPanelProps): react_jsx_runtime.JSX.Element;
440
+
441
+ interface ProposalCardProps {
442
+ proposal: PendingProposal;
443
+ /** True while this proposal's confirmation is in flight (disables the buttons). */
444
+ confirming: boolean;
445
+ onConfirm: () => void;
446
+ onCancel: () => void;
447
+ /** Host navigation for connect targets / the integrations page. */
448
+ navigate?: (path: string) => void;
449
+ /** Render the workflow YAML as a node graph (the `./workflows` WorkflowGraph).
450
+ * When absent, the YAML is shown as text. */
451
+ renderGraph?: (yaml: string) => ReactNode;
452
+ }
453
+ declare function ProposalCard({ proposal, confirming, onConfirm, onCancel, navigate, renderGraph, }: ProposalCardProps): react_jsx_runtime.JSX.Element;
454
+
455
+ interface AssistantLauncher {
456
+ /** Whether the assistant drawer is open. */
457
+ open: boolean;
458
+ /** A one-shot starter prompt to prefill the composer with, or null. */
459
+ seed: string | null;
460
+ /** Open the drawer; optionally prefill the composer with `seed`. */
461
+ openAssistant: (seed?: string) => void;
462
+ closeAssistant: () => void;
463
+ /** Clear the pending seed once the composer has applied it (consume-once). */
464
+ clearSeed: () => void;
465
+ }
466
+ declare function AssistantLauncherProvider({ children, }: {
467
+ children: ReactNode;
468
+ }): react_jsx_runtime.JSX.Element;
469
+ declare function useAssistantLauncher(): AssistantLauncher;
470
+
471
+ export { type AssistantChat, type AssistantClient, type AssistantClientConfig, AssistantClientProvider, AssistantDock, type AssistantDockProps, type AssistantLauncher, AssistantLauncherProvider, type AssistantModelOption, type AssistantModels, type AssistantModelsResult, AssistantPanel, type AssistantPanelProps, type AssistantStreamEvent, type AssistantThreadSummary, type AssistantThreads, type ChatMessage, type ChatRequest, type ChatRole, type ConfirmResult, type ConnectionRequirement, type ConnectionRequirementKind, type DeltaEventData, type DoneEventData, type ErrorEventData, type PendingProposal, ProposalCard, type ProposalCardProps, type ReasoningEventData, type ThreadEventData, type ThreadHistoryResult, type ToolActivityStatus, type ToolCallEventData, type ToolProposalEventData, type ToolResultEventData, type UsageEventData, type UsageInfo, type UseAssistantChatOptions, createAssistantClient, useAssistantChat, useAssistantClient, useAssistantLauncher, useAssistantModels, useAssistantThreads };