@dudko.dev/agent-web-react 0.0.30 → 0.0.32

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.cts CHANGED
@@ -1,9 +1,9 @@
1
1
  import * as react from 'react';
2
2
  import { DependencyList, ReactNode, RefObject, ComponentType, CSSProperties } from 'react';
3
3
  import { RunFile, RunResult, Agent, ToolApprovalMode, AppToolCallRequest, AppSamplingRequest, AppSamplingView, AppSamplingResult, CompactResult, IUsage, AgentEventHandler, BrowserAgentConfig, VirtualFileInfo, VirtualFileSystem, CredentialStore, createWebLLMModel, WebLLMModelOptions, ModelTier, TierReason, EscalationReason, DecisionFallbackReason, AgentEvent, Skill, IPlan, ToolApprovalRequest, ToolApprovalContext, ToolApprovalDecision } from '@dudko.dev/agent-web';
4
- export { Agent, AgentEvent, AgentEventHandler, AgentLoggerSink, AgentTool, AgentToolSet, AppToolCallRequest, AttachmentsNotSupportedError, BrowserAgentConfig, CompactResult, CompactionConfig, CredentialStore, FileToolsOptions, IPlan, IPlanStep, IStepResult, IToolCall, IUsage, ImagesNotSupportedError, IndexedDBStore, LearningConfig, LogLevel, McpAppCsp, McpAppResource, McpAppToolResult, MemoryCredentialStore, MemorySkillStore, MemoryStore, ModelInput, ProviderModelSpec, ProviderType, RunControl, RunFile, RunOptions, RunResult, Skill, SkillStore, SubagentInfo, SubagentToolOptions, SubagentWorkerConfig, ThinkingLevel, ThinkingSetting, TokenLimits, ToolApprovalConfig, ToolApprovalContext, ToolApprovalMode, ToolApprovalRequest, VaultCredentialStore, VfsSkillStore, VirtualFile, VirtualFileInfo, VirtualFileSystem, createAgent, createFileTools, createRunControl, createSubagentTool, createWebLLMModel, defineSkill, defineTool, isWebGPUAvailable, loadSkillFromUrl, markReadOnly, parseSkillMarkdown, preloadWebLLMModel, serveSubagentWorker, supportsImages, supportsPdf, unloadWebLLMModel } from '@dudko.dev/agent-web';
5
- import { A as AgentUiState, C as ChatAttachment, a as ApprovalView, b as ChatMessage, c as AgentStatus, E as ElicitationIssueKind, d as ElicitationOutcomeReason, M as McpAppSandboxReason, L as LessonView, S as SubagentView, e as SubagentNode, P as PendingElicitation, f as McpElicitationResult, g as ElicitationView, W as WrittenFileView, T as ToolCallView, h as StepView, U as UserNoteView, D as DecisionView, i as MediaView, j as AppView, k as McpAppsConnectionLike, l as McpAppSandboxOptions, m as AppRequestView, n as TranscriptView, B as BudgetView, o as CompactionView, p as ModelLoadState, q as McpAppHost, r as AppRequestAnswerOptions } from './elicitation-CcZe5-EK.cjs';
6
- export { s as APP_DEFAULT_HEIGHT, t as APP_MAX_HEIGHT, u as APP_MIN_HEIGHT, v as AppDownload, w as AppDownloadView, x as AppFileSaverEnv, y as AppLink, z as AppReadyDownload, F as AppResourceReader, G as ElicitationControl, H as ElicitationDraft, I as ElicitationDraftValue, J as ElicitationField, K as ElicitationFormOutcome, N as ElicitationIssue, O as ElicitationLink, Q as ElicitationOption, R as FetchView, V as MCP_APP_DISPLAY_MODES, X as MCP_APP_MAX_ARGS_CHARS, Y as MCP_APP_MAX_DOWNLOAD_BYTES, Z as MCP_APP_MAX_FILE_NAME_CHARS, _ as MCP_APP_MAX_IN_FLIGHT, $ as MCP_APP_MAX_MESSAGE_CHARS, a0 as MCP_APP_MAX_URL_CHARS, a1 as MCP_APP_NOTIFICATIONS, a2 as MCP_APP_OPTIONAL_REQUESTS, a3 as MCP_APP_PROTOCOL_VERSION, a4 as MCP_APP_REFUSED, a5 as MCP_APP_REFUSED_DOWNLOAD_EXTENSIONS, a6 as MCP_APP_REFUSED_DOWNLOAD_TYPES, a7 as MCP_APP_RELAY, a8 as MCP_APP_REQUESTS, a9 as MCP_APP_SANDBOX_FRAME_TOKENS, aa as MCP_APP_SANDBOX_GRACE_MS, ab as MCP_APP_SANDBOX_SERVER, ac as MCP_APP_SANDBOX_TIMEOUT_MS, ad as McpAppBridge, ae as McpAppBridgeHandlers, af as McpAppBridgeOptions, ag as McpAppDisplayMode, ah as McpAppRpcError, ai as McpAppRpcMessage, aj as McpAppSandboxInput, ak as McpAppSandboxLink, al as McpAppSandboxLinkOptions, am as McpAppSandboxTarget, an as McpElicitationFieldSchema, ao as McpElicitationRequest, ap as McpElicitationSchema, aq as QueuedMessageView, ar as ReplanState, as as SkillConsentView, at as StepEscalationView, au as UseMcpAppHostOptions, av as appDisplayModeAllowed, aw as appDownloadOf, ax as appDownloadRefusal, ay as appFileExtensionOf, az as appFileNameOf, aA as appGestureOf, aB as appLinkOf, aC as appMessageTextOf, aD as appMimeTypeOf, aE as appSamplingErrorOf, aF as buildMcpAppDocument, aG as buildMcpAppSandboxShell, aH as clampAppHeight, aI as elicitationFields, aJ as elicitationFormAnswer, aK as elicitationInitialDraft, aL as elicitationLink, aM as formatCountdown, aN as grantedAppCsp, aO as mcpAppCsp, aP as mcpAppHostCapabilities, aQ as mcpAppSandboxProxyUrl, aR as mcpAppSandboxShellCsp, aS as mcpAppSandboxTarget, aT as resolveAppDownload, aU as saveAppFile, aV as useMcpAppHost } from './elicitation-CcZe5-EK.cjs';
4
+ export { Agent, AgentEvent, AgentEventHandler, AgentLoggerSink, AgentTool, AgentToolSet, AppToolCallRequest, AttachmentsNotSupportedError, BrowserAgentConfig, CompactResult, CompactionConfig, CredentialStore, FileToolsOptions, IPlan, IPlanStep, IStepResult, IToolCall, IUsage, ImagesNotSupportedError, IndexedDBStore, LearningConfig, LogLevel, McpAppCsp, McpAppResource, McpAppToolResult, MemoryCredentialStore, MemorySkillStore, MemoryStore, ModelInput, ProviderModelSpec, ProviderType, RunControl, RunFile, RunOptions, RunResult, SessionBusyError, SessionHolder, SessionLockMode, SessionRunState, SessionWatch, Skill, SkillStore, StorageChange, StorageChangeKind, StorageChangeOp, SubagentInfo, SubagentToolOptions, SubagentWorkerConfig, ThinkingLevel, ThinkingSetting, TokenLimits, ToolApprovalConfig, ToolApprovalContext, ToolApprovalMode, ToolApprovalRequest, VaultCredentialStore, VfsSkillStore, VirtualFile, VirtualFileInfo, VirtualFileSystem, WatchSessionOptions, createAgent, createFileTools, createRunControl, createSubagentTool, createWebLLMModel, defineSkill, defineTool, isWebGPUAvailable, loadSkillFromUrl, markReadOnly, onStorageChange, parseSkillMarkdown, postStorageChange, preloadWebLLMModel, serveSubagentWorker, supportsImages, supportsPdf, unloadWebLLMModel, watchSession } from '@dudko.dev/agent-web';
5
+ import { A as AgentUiState, C as ChatAttachment, a as ApprovalView, b as ChatMessage, c as AgentStatus, E as ElicitationIssueKind, d as ElicitationOutcomeReason, M as McpAppSandboxReason, R as RemoteRunView, L as LessonView, S as SubagentView, e as SubagentNode, P as PendingElicitation, f as McpElicitationResult, g as ElicitationView, W as WrittenFileView, T as ToolCallView, h as StepView, U as UserNoteView, D as DecisionView, i as MediaView, j as AppView, k as McpAppsConnectionLike, l as McpAppSandboxOptions, m as AppRequestView, n as TranscriptView, B as BudgetView, o as CompactionView, p as ModelLoadState, q as McpAppHost, r as AppRequestAnswerOptions } from './elicitation-BW7R4iIw.cjs';
6
+ export { s as APP_DEFAULT_HEIGHT, t as APP_MAX_HEIGHT, u as APP_MIN_HEIGHT, v as AppDownload, w as AppDownloadView, x as AppFileSaverEnv, y as AppLink, z as AppReadyDownload, F as AppResourceReader, G as ElicitationControl, H as ElicitationDraft, I as ElicitationDraftValue, J as ElicitationField, K as ElicitationFormOutcome, N as ElicitationIssue, O as ElicitationLink, Q as ElicitationOption, V as FetchView, X as MCP_APP_DISPLAY_MODES, Y as MCP_APP_MAX_ARGS_CHARS, Z as MCP_APP_MAX_DOWNLOAD_BYTES, _ as MCP_APP_MAX_FILE_NAME_CHARS, $ as MCP_APP_MAX_IN_FLIGHT, a0 as MCP_APP_MAX_MESSAGE_CHARS, a1 as MCP_APP_MAX_URL_CHARS, a2 as MCP_APP_NOTIFICATIONS, a3 as MCP_APP_OPTIONAL_REQUESTS, a4 as MCP_APP_PROTOCOL_VERSION, a5 as MCP_APP_REFUSED, a6 as MCP_APP_REFUSED_DOWNLOAD_EXTENSIONS, a7 as MCP_APP_REFUSED_DOWNLOAD_TYPES, a8 as MCP_APP_RELAY, a9 as MCP_APP_REQUESTS, aa as MCP_APP_SANDBOX_FRAME_TOKENS, ab as MCP_APP_SANDBOX_GRACE_MS, ac as MCP_APP_SANDBOX_SERVER, ad as MCP_APP_SANDBOX_TIMEOUT_MS, ae as McpAppBridge, af as McpAppBridgeHandlers, ag as McpAppBridgeOptions, ah as McpAppDisplayMode, ai as McpAppRpcError, aj as McpAppRpcMessage, ak as McpAppSandboxInput, al as McpAppSandboxLink, am as McpAppSandboxLinkOptions, an as McpAppSandboxTarget, ao as McpElicitationFieldSchema, ap as McpElicitationRequest, aq as McpElicitationSchema, ar as QueuedMessageView, as as ReplanState, at as SkillConsentView, au as StepEscalationView, av as UseMcpAppHostOptions, aw as appDisplayModeAllowed, ax as appDownloadOf, ay as appDownloadRefusal, az as appFileExtensionOf, aA as appFileNameOf, aB as appGestureOf, aC as appLinkOf, aD as appMessageTextOf, aE as appMimeTypeOf, aF as appSamplingErrorOf, aG as buildMcpAppDocument, aH as buildMcpAppSandboxShell, aI as clampAppHeight, aJ as elicitationFields, aK as elicitationFormAnswer, aL as elicitationInitialDraft, aM as elicitationLink, aN as formatCountdown, aO as grantedAppCsp, aP as mcpAppCsp, aQ as mcpAppHostCapabilities, aR as mcpAppSandboxProxyUrl, aS as mcpAppSandboxShellCsp, aT as mcpAppSandboxTarget, aU as resolveAppDownload, aV as saveAppFile, aW as useMcpAppHost } from './elicitation-BW7R4iIw.cjs';
7
7
  export { M as MCP_APP_POLICY_TOKEN_MAX_CHARS, a as MCP_APP_SANDBOX_PROXY_READY, b as MCP_APP_SANDBOX_RESOURCE_READY, i as isMcpAppSandboxMessage, m as mcpAppPolicyToken } from './mcp-app-policy-DIUmGPJP.cjs';
8
8
 
9
9
  interface UseAgentOptions {
@@ -36,6 +36,14 @@ interface UseAgentOptions {
36
36
  * for the UI to offer (`sendUndelivered` / `discardUndelivered`).
37
37
  */
38
38
  followUp?: boolean;
39
+ /**
40
+ * Follow a run of the current conversation that goes on in ANOTHER tab of the site (default
41
+ * true; needs a `memory` the tabs share - `IndexedDBStore` - and `sessionLock` not `'off'`): its
42
+ * steps and answer show here live (`remote`) and `isRunning` is true meanwhile. Writing to it or
43
+ * stopping it is explicit: `sendRemote` / `stopRemote` (the chat panel's composer and Stop button
44
+ * use them while they follow such a run). Consent requests stay in that tab.
45
+ */
46
+ watch?: boolean;
39
47
  }
40
48
  interface ApproveOptions {
41
49
  /** Also allow this tool for the rest of the agent's life ("always allow"). */
@@ -55,15 +63,35 @@ interface RunGoalOptions {
55
63
  attachments?: ChatAttachment[];
56
64
  }
57
65
  interface UseAgentReturn extends AgentUiState {
58
- /** Run a goal. Resolves with the RunResult, or `undefined` if it couldn't start. */
66
+ /**
67
+ * Run a goal. Resolves with the RunResult, or `undefined` if it couldn't start. When the
68
+ * conversation is running in another tab, the run waits for it (`sessionBusy`; the core's
69
+ * `sessionLock`) and then goes, with that run's turn in its memory.
70
+ */
59
71
  run: (goal: string, options?: RunGoalOptions) => Promise<RunResult | undefined>;
60
- /** Abort the in-flight run (observed between phases and mid-stream). */
72
+ /**
73
+ * Abort the in-flight run of THIS tab (observed between phases and mid-stream), going or waiting
74
+ * for the session. A run followed from another tab is stopped only by `stopRemote`.
75
+ */
61
76
  stop: () => void;
77
+ /**
78
+ * Stop the conversation's run in another tab (`remote`), when that tab allows it (the core's
79
+ * `sessionRelay`). A no-op when none is followed.
80
+ */
81
+ stopRemote: () => void;
82
+ /**
83
+ * Say something to the conversation's run in another tab (`remote`): it reaches that run's
84
+ * model at its next boundary, marked as from another tab. `false` when no such run is followed
85
+ * or the text is empty. A message that tab refuses (or never answers) comes back in
86
+ * `undelivered`.
87
+ */
88
+ sendRemote: (text: string) => boolean;
62
89
  /**
63
90
  * Say something to the agent while it works. It is shown to the model at the next
64
91
  * boundary (between tool calls, or when the step ends — where the replanner then
65
92
  * re-checks the plan), never cutting a tool call short. `false` when no run is in
66
- * flight or the text is empty — then use `run`. Watch `queued` / `notes`.
93
+ * flight or the text is empty — then use `run`. Watch `queued` / `notes`. Only this tab's run:
94
+ * for the conversation's run in another tab, `sendRemote`.
67
95
  */
68
96
  send: (text: string) => boolean;
69
97
  /** Stop ONE running subagent (`SubagentView.id`); the run and its siblings go on. */
@@ -173,15 +201,31 @@ interface ChatHistoryStoreOptions {
173
201
  /** Keep chats in memory only (tests, private mode; also the fallback without IndexedDB). */
174
202
  memory?: boolean;
175
203
  }
176
- /** IndexedDB-backed chat history (raw IndexedDB — no extra dependency). */
204
+ /**
205
+ * IndexedDB-backed chat history (raw IndexedDB — no extra dependency). Every tab of the origin
206
+ * shares it: once a write has committed the other tabs hear which chat changed (a `chats`
207
+ * notice from the core's `postStorageChange` - the id, never a message), and `useChatHistory`
208
+ * there refreshes.
209
+ */
177
210
  declare class ChatHistoryStore {
178
- private readonly dbName;
211
+ /** The IndexedDB database (undefined in memory): the name its `chats` notices go out under. */
212
+ readonly dbName: string | undefined;
213
+ private readonly name;
179
214
  private readonly storeName;
180
215
  private readonly memory?;
181
216
  private db?;
182
217
  constructor(opts?: ChatHistoryStoreOptions);
183
218
  private open;
184
219
  private tx;
220
+ /** One write in its own transaction, resolved once it committed - then the notice. */
221
+ private write;
222
+ private announce;
223
+ /**
224
+ * Read the stored record and write what `merge` makes of it in ONE readwrite transaction: no
225
+ * other tab's save can land between the read and the write. `merge` is synchronous (a
226
+ * transaction does not survive an await). Resolves with what was written, once committed.
227
+ */
228
+ putMerged(id: string, merge: (stored: ChatRecord | undefined) => ChatRecord): Promise<ChatRecord>;
185
229
  list(): Promise<ChatSummary[]>;
186
230
  get(id: string): Promise<ChatRecord | undefined>;
187
231
  put(record: ChatRecord): Promise<void>;
@@ -213,11 +257,43 @@ interface UseChatHistoryReturn {
213
257
  /** Delete a conversation (and start a new one if it was open). */
214
258
  remove: (id: string) => Promise<void>;
215
259
  }
260
+ /** What this tab last read or wrote of a chat: the very message objects, and when. */
261
+ interface ChatBase {
262
+ /** The messages as read or written (by identity: an edit, a reset or a trim is not "known"). */
263
+ known: ReadonlySet<ChatMessage>;
264
+ updatedAt: number;
265
+ }
266
+ /** This tab's view says nothing new (every message is one it read or wrote). */
267
+ declare const unchangedSince: (messages: ChatMessage[], base: ChatBase | undefined) => boolean;
268
+ /**
269
+ * The record to save. A turn this tab only followed from another tab (`remote`) is never saved
270
+ * from here - that tab saves its own, unclipped copy. When another tab saved the chat after this
271
+ * tab last read or wrote it (or saved a chat this tab never read), THAT record is the truth for
272
+ * everything that is not this tab's own: this tab's own new messages - by identity, not by count,
273
+ * so a reset or a trim here drops nothing there - go after it.
274
+ */
275
+ declare const mergeChatRecord: (view: ChatRecord, stored: ChatRecord | undefined, base: ChatBase | undefined) => {
276
+ record: ChatRecord;
277
+ merged: boolean;
278
+ };
279
+ /**
280
+ * What `useChatHistory` does to save the open chat: the stored record is read and the merged one
281
+ * written in ONE readwrite transaction (`ChatHistoryStore.putMerged`), so another tab's save
282
+ * cannot land between the two.
283
+ */
284
+ declare const saveChat: (store: ChatHistoryStore, view: ChatRecord, base: ChatBase | undefined) => Promise<{
285
+ record: ChatRecord;
286
+ merged: boolean;
287
+ }>;
216
288
  /**
217
289
  * Persist an agent's conversations — the transcript with its tool calls, usage
218
290
  * and image attachments — and switch between them. Each chat id is also the
219
291
  * agent's memory session, so with a persistent `memory` (IndexedDBStore) a
220
292
  * reopened chat continues with the model's context intact.
293
+ *
294
+ * Several tabs: the list follows what other tabs of the site save (the store's `chats`
295
+ * notices), the open chat is read again when another tab saved it and nothing runs here, and a
296
+ * run followed from another tab (`agent.remote`) is never saved from here - its own tab saves it.
221
297
  */
222
298
  declare const useChatHistory: (agent: UseAgentReturn, options?: UseChatHistoryOptions) => UseChatHistoryReturn;
223
299
 
@@ -236,9 +312,10 @@ interface UseVirtualFilesReturn {
236
312
  }
237
313
  /**
238
314
  * A live listing of a {@link VirtualFileSystem} (the core's browser
239
- * workspace): re-reads on every write / delete — by the user or by the agent's
240
- * `fs_*` tools — and offers upload / remove / read helpers. Headless: render
241
- * it with `<FilesPanel>` or your own UI.
315
+ * workspace): re-reads on every write / delete — by the user, by the agent's
316
+ * `fs_*` tools, or in another tab of the origin (a `files` notice) — and offers
317
+ * upload / remove / read helpers. Headless: render it with `<FilesPanel>` or
318
+ * your own UI.
242
319
  */
243
320
  declare const useVirtualFiles: (vfs: VirtualFileSystem | undefined, prefix?: string) => UseVirtualFilesReturn;
244
321
 
@@ -306,8 +383,9 @@ interface UseCredentialsReturn {
306
383
  /** Resolve whether a key is currently present for a ref. */
307
384
  hasKey: (ref: string) => Promise<boolean>;
308
385
  /**
309
- * Bumped whenever a key is written or removed — depend on it in an effect to
310
- * re-query `hasKey` and reflect the change in your UI.
386
+ * Bumped whenever a key is written or removed — here, or in another tab of the origin (the
387
+ * vault's `credentials` notice) — depend on it in an effect to re-query `hasKey` and reflect
388
+ * the change in your UI.
311
389
  */
312
390
  version: number;
313
391
  }
@@ -742,6 +820,16 @@ interface AgentLabels {
742
820
  discardUndelivered: string;
743
821
  stopSubagent: string;
744
822
  subagentStopped: string;
823
+ /** The conversation is running in another tab: it is shown here live, and Stop / typing go there. */
824
+ remoteRunning: string;
825
+ /** That run waits for a person's answer - which is given in that tab. */
826
+ remoteWaitingConsent: string;
827
+ /** That tab closed (or crashed) before the run finished. */
828
+ remoteGone: string;
829
+ /** This tab's run waits for the other run of the conversation (in another tab, or in this one). */
830
+ sessionBusy: (heldBy: 'another-tab' | 'this-tab') => string;
831
+ /** The mark on a message written to this run from another tab (queued, and where it arrived). */
832
+ fromAnotherTab: string;
745
833
  failed: string;
746
834
  toolCostTitle: string;
747
835
  /** The tier badge on a step. */
@@ -984,6 +1072,13 @@ interface AgentLabels {
984
1072
  skillConsentByUri: string;
985
1073
  /** It sits inside another skill of the same server. */
986
1074
  skillConsentNested: (enclosing: string) => string;
1075
+ /**
1076
+ * A generated skill (`skill.dynamic`): the server publishes no checksums - the person approves
1077
+ * the copy the agent just read, and only that copy is used.
1078
+ */
1079
+ skillConsentDynamic: string;
1080
+ /** (with `skillConsentDynamic`) The server cannot list the skill's files: SKILL.md alone. */
1081
+ skillConsentNoFileListing: string;
987
1082
  /** The summary of the collapsible preview of its instructions. */
988
1083
  skillConsentPreview: string;
989
1084
  /** Under the preview: its other files, and how many more there are than are shown. */
@@ -1093,6 +1188,18 @@ type AgentAction =
1093
1188
  maxEvents?: number;
1094
1189
  at?: number;
1095
1190
  attachments?: ChatAttachment[];
1191
+ /** The event is another tab's run of this conversation (`watchSession`), relayed here. */
1192
+ remote?: boolean;
1193
+ /** With `session.busy`: the goal that waits (shown as queued until the run starts). */
1194
+ goal?: string;
1195
+ }
1196
+ /**
1197
+ * Another tab's run of this conversation, as `watchSession` reports it (or `undefined`: none
1198
+ * in view). Ended `gone` - that tab closed before it said so - finishes the answer it left.
1199
+ */
1200
+ | {
1201
+ type: 'remote';
1202
+ remote: RemoteRunView | undefined;
1096
1203
  }
1097
1204
  /**
1098
1205
  * The agent's notebook as it is now (the hook sends it when the agent is built: lessons a
@@ -1116,6 +1223,16 @@ type AgentAction =
1116
1223
  | {
1117
1224
  type: 'undelivered';
1118
1225
  texts: string[];
1226
+ keepQueued?: boolean;
1227
+ }
1228
+ /**
1229
+ * The user sent a goal and this tab's run is getting going: its turn is shown at once (a
1230
+ * user message and a pending answer), until the run's `run.start` takes its place.
1231
+ */
1232
+ | {
1233
+ type: 'submitted';
1234
+ goal: string;
1235
+ attachments?: ChatAttachment[];
1119
1236
  };
1120
1237
  /**
1121
1238
  * The notebook view of the agent's own skills (`agent.listLearnedSkills()`): what the core stored
@@ -1129,6 +1246,17 @@ declare const createInitialAgentState: () => AgentUiState;
1129
1246
  * they started. A node whose parent is not in the list (its start was never seen) is a root.
1130
1247
  */
1131
1248
  declare const subagentTree: (subagents: SubagentView[]) => SubagentNode[];
1249
+ /**
1250
+ * The consent requests THIS tab can answer: pending, and not asked in another tab (a run of the
1251
+ * conversation going on there - those are shown, and answered only there). What `useAgent`
1252
+ * returns as `pendingApprovals`.
1253
+ */
1254
+ declare const pendingApprovalsOf: (state: Pick<AgentUiState, "approvals">) => ApprovalView[];
1255
+ /**
1256
+ * The status to show: `running` while another tab runs this conversation (`remote`) and this
1257
+ * tab is otherwise ready or idle - never over `initializing` or `error`, which the host must see.
1258
+ */
1259
+ declare const agentStatusOf: (state: Pick<AgentUiState, "status" | "remote">) => AgentUiState["status"];
1132
1260
  declare const agentStateReducer: (state: AgentUiState, action: AgentAction) => AgentUiState;
1133
1261
 
1134
1262
  interface ComposerModelChip {
@@ -1797,6 +1925,12 @@ interface AgentChatProps {
1797
1925
  * the agent would read (default true; `<ToolApprovalPrompt showSkillPreview>`).
1798
1926
  */
1799
1927
  showSkillPreview?: boolean;
1928
+ /**
1929
+ * Notes about the site's other tabs above the composer (default true): the conversation is
1930
+ * running in another tab (followed here live), that run waits for an answer there, that tab
1931
+ * closed mid-run, or this tab's message waits for the other run to finish.
1932
+ */
1933
+ showOtherTabs?: boolean;
1800
1934
  /**
1801
1935
  * Saved conversations in IndexedDB with a sidebar to switch between them:
1802
1936
  * `true` (default store), your own `ChatHistoryStore`, or the result of your
@@ -2317,5 +2451,5 @@ interface AppRequestPromptProps {
2317
2451
  */
2318
2452
  declare const AppRequestPrompt: ({ requests, onAnswer, renderRequest, labels, className, }: AppRequestPromptProps) => react.JSX.Element | null;
2319
2453
 
2320
- export { AgentChat, AgentComposer, AgentLabelsProvider, AgentProvider, AgentStatus, AgentUiState, ApiKeyForm, AppRequestAnswerOptions, AppRequestPrompt, AppRequestView, AppView, ApprovalModeSwitch, ApprovalView, AttachmentView, BudgetView, ChatAttachment, ChatHistoryList, ChatHistoryStore, ChatMessage, CompactionView, Composer, ContextMeter, DecisionView, ElicitationIssueKind, ElicitationOutcomeReason, ElicitationPrompt, ElicitationView, FILE_PREVIEW_CHARS, FRAME_MAX_HEIGHT, FRAME_MIN_HEIGHT, FileChip, FileChips, FilesPanel, GeneratedMedia, HTML_PREVIEW_MAX_CHARS, LearnedSkills, LessonView, McpAppFrame, McpAppHost, McpAppLine, McpAppSandboxOptions, McpAppSandboxReason, McpAppsConnectionLike, McpElicitationResult, MediaView, MessageList, ModelLoadBar, ModelLoadState, PendingElicitation, PlanView, SandboxedFrame, SourceView, StepList, StepView, SubagentNode, SubagentRow, SubagentTree, SubagentView, ToolApprovalPrompt, ToolCallRow, ToolCallView, TranscriptBlock, TranscriptView, UsageBadge, UserNoteRow, UserNoteView, agentStateReducer, attachmentKindOf, attachmentRefusal, buildSandboxedDocument, chatTitle, clampFrameHeight, createApprovalQueue, createInitialAgentState, createWebLLMEngine, decisionNote, defaultLabels, downscaleImage, escapeAttribute, fileKindOf, fileNameOf, filterCommands, formatElapsed, lessonsOf, linkedFilesOf, mediaFamilyOf, mergeLabels, newChatId, noticesOf, parseSlash, sandboxTokens, sandboxedCsp, steerIntent, subagentTree, tokenizeHtml, usageLine, useAgent, useAgentContext, useChatHistory, useCredentials, useLabels, useLocalModel, useOptionalAgentContext, useSpeechToText, useVirtualFiles, useWebLLMModel, webSearchOf, withAttachments, withCspFirst, withPolicyFirst };
2321
- export type { AgentAction, AgentChatClassNames, AgentChatComponents, AgentChatProps, AgentChatSlots, AgentComposerProps, AgentLabels, AgentLabelsOverride, AgentLabelsProviderProps, AgentProviderProps, ApiKeyFormProps, AppRequestPromptProps, ApprovalModeSwitchProps, ApprovalQueue, ApproveOptions, ChatHistoryListProps, ChatHistoryStoreOptions, ChatRecord, ChatSummary, ComposerAttachment, ComposerModelChip, ComposerNotice, ComposerProps, ComposerThinkingChip, ContextMeterProps, ConvertedFile, DownscaleOptions, ElicitationPromptProps, FileChipProps, FileChipsProps, FileKind, FilesPanelProps, GeneratedMediaProps, HtmlPreviewOptions, LearnedSkillsProps, LocalModelEngine, LocalModelLoadContext, LocalModelProgress, McpAppFrameProps, McpAppLineProps, MessageListProps, ModelLoadBarProps, NoticeTexts, PlanViewProps, RenderSubagent, RenderToolCall, RunGoalOptions, SandboxedDocumentOptions, SandboxedFrameProps, SlashCommand, SourceToken, SourceViewProps, SpeechRecognizerLike, SteerIntent, StepListProps, SubagentRowProps, SubagentTreeProps, ToolApprovalPromptProps, ToolCallRowProps, TranscriptBlockProps, UsageBadgeProps, UseAgentOptions, UseAgentReturn, UseChatHistoryOptions, UseChatHistoryReturn, UseCredentialsReturn, UseLocalModelOptions, UseLocalModelReturn, UseSpeechToTextOptions, UseSpeechToTextReturn, UseVirtualFilesReturn, UseWebLLMModelOptions, UseWebLLMModelReturn, WebLLMModelFactory, WebSearchResultView, WebSearchView };
2454
+ export { AgentChat, AgentComposer, AgentLabelsProvider, AgentProvider, AgentStatus, AgentUiState, ApiKeyForm, AppRequestAnswerOptions, AppRequestPrompt, AppRequestView, AppView, ApprovalModeSwitch, ApprovalView, AttachmentView, BudgetView, ChatAttachment, ChatHistoryList, ChatHistoryStore, ChatMessage, CompactionView, Composer, ContextMeter, DecisionView, ElicitationIssueKind, ElicitationOutcomeReason, ElicitationPrompt, ElicitationView, FILE_PREVIEW_CHARS, FRAME_MAX_HEIGHT, FRAME_MIN_HEIGHT, FileChip, FileChips, FilesPanel, GeneratedMedia, HTML_PREVIEW_MAX_CHARS, LearnedSkills, LessonView, McpAppFrame, McpAppHost, McpAppLine, McpAppSandboxOptions, McpAppSandboxReason, McpAppsConnectionLike, McpElicitationResult, MediaView, MessageList, ModelLoadBar, ModelLoadState, PendingElicitation, PlanView, RemoteRunView, SandboxedFrame, SourceView, StepList, StepView, SubagentNode, SubagentRow, SubagentTree, SubagentView, ToolApprovalPrompt, ToolCallRow, ToolCallView, TranscriptBlock, TranscriptView, UsageBadge, UserNoteRow, UserNoteView, agentStateReducer, agentStatusOf, attachmentKindOf, attachmentRefusal, buildSandboxedDocument, chatTitle, clampFrameHeight, createApprovalQueue, createInitialAgentState, createWebLLMEngine, decisionNote, defaultLabels, downscaleImage, escapeAttribute, fileKindOf, fileNameOf, filterCommands, formatElapsed, lessonsOf, linkedFilesOf, mediaFamilyOf, mergeChatRecord, mergeLabels, newChatId, noticesOf, parseSlash, pendingApprovalsOf, sandboxTokens, sandboxedCsp, saveChat, steerIntent, subagentTree, tokenizeHtml, unchangedSince, usageLine, useAgent, useAgentContext, useChatHistory, useCredentials, useLabels, useLocalModel, useOptionalAgentContext, useSpeechToText, useVirtualFiles, useWebLLMModel, webSearchOf, withAttachments, withCspFirst, withPolicyFirst };
2455
+ export type { AgentAction, AgentChatClassNames, AgentChatComponents, AgentChatProps, AgentChatSlots, AgentComposerProps, AgentLabels, AgentLabelsOverride, AgentLabelsProviderProps, AgentProviderProps, ApiKeyFormProps, AppRequestPromptProps, ApprovalModeSwitchProps, ApprovalQueue, ApproveOptions, ChatBase, ChatHistoryListProps, ChatHistoryStoreOptions, ChatRecord, ChatSummary, ComposerAttachment, ComposerModelChip, ComposerNotice, ComposerProps, ComposerThinkingChip, ContextMeterProps, ConvertedFile, DownscaleOptions, ElicitationPromptProps, FileChipProps, FileChipsProps, FileKind, FilesPanelProps, GeneratedMediaProps, HtmlPreviewOptions, LearnedSkillsProps, LocalModelEngine, LocalModelLoadContext, LocalModelProgress, McpAppFrameProps, McpAppLineProps, MessageListProps, ModelLoadBarProps, NoticeTexts, PlanViewProps, RenderSubagent, RenderToolCall, RunGoalOptions, SandboxedDocumentOptions, SandboxedFrameProps, SlashCommand, SourceToken, SourceViewProps, SpeechRecognizerLike, SteerIntent, StepListProps, SubagentRowProps, SubagentTreeProps, ToolApprovalPromptProps, ToolCallRowProps, TranscriptBlockProps, UsageBadgeProps, UseAgentOptions, UseAgentReturn, UseChatHistoryOptions, UseChatHistoryReturn, UseCredentialsReturn, UseLocalModelOptions, UseLocalModelReturn, UseSpeechToTextOptions, UseSpeechToTextReturn, UseVirtualFilesReturn, UseWebLLMModelOptions, UseWebLLMModelReturn, WebLLMModelFactory, WebSearchResultView, WebSearchView };
package/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import * as react from 'react';
2
2
  import { DependencyList, ReactNode, RefObject, ComponentType, CSSProperties } from 'react';
3
3
  import { RunFile, RunResult, Agent, ToolApprovalMode, AppToolCallRequest, AppSamplingRequest, AppSamplingView, AppSamplingResult, CompactResult, IUsage, AgentEventHandler, BrowserAgentConfig, VirtualFileInfo, VirtualFileSystem, CredentialStore, createWebLLMModel, WebLLMModelOptions, ModelTier, TierReason, EscalationReason, DecisionFallbackReason, AgentEvent, Skill, IPlan, ToolApprovalRequest, ToolApprovalContext, ToolApprovalDecision } from '@dudko.dev/agent-web';
4
- export { Agent, AgentEvent, AgentEventHandler, AgentLoggerSink, AgentTool, AgentToolSet, AppToolCallRequest, AttachmentsNotSupportedError, BrowserAgentConfig, CompactResult, CompactionConfig, CredentialStore, FileToolsOptions, IPlan, IPlanStep, IStepResult, IToolCall, IUsage, ImagesNotSupportedError, IndexedDBStore, LearningConfig, LogLevel, McpAppCsp, McpAppResource, McpAppToolResult, MemoryCredentialStore, MemorySkillStore, MemoryStore, ModelInput, ProviderModelSpec, ProviderType, RunControl, RunFile, RunOptions, RunResult, Skill, SkillStore, SubagentInfo, SubagentToolOptions, SubagentWorkerConfig, ThinkingLevel, ThinkingSetting, TokenLimits, ToolApprovalConfig, ToolApprovalContext, ToolApprovalMode, ToolApprovalRequest, VaultCredentialStore, VfsSkillStore, VirtualFile, VirtualFileInfo, VirtualFileSystem, createAgent, createFileTools, createRunControl, createSubagentTool, createWebLLMModel, defineSkill, defineTool, isWebGPUAvailable, loadSkillFromUrl, markReadOnly, parseSkillMarkdown, preloadWebLLMModel, serveSubagentWorker, supportsImages, supportsPdf, unloadWebLLMModel } from '@dudko.dev/agent-web';
5
- import { A as AgentUiState, C as ChatAttachment, a as ApprovalView, b as ChatMessage, c as AgentStatus, E as ElicitationIssueKind, d as ElicitationOutcomeReason, M as McpAppSandboxReason, L as LessonView, S as SubagentView, e as SubagentNode, P as PendingElicitation, f as McpElicitationResult, g as ElicitationView, W as WrittenFileView, T as ToolCallView, h as StepView, U as UserNoteView, D as DecisionView, i as MediaView, j as AppView, k as McpAppsConnectionLike, l as McpAppSandboxOptions, m as AppRequestView, n as TranscriptView, B as BudgetView, o as CompactionView, p as ModelLoadState, q as McpAppHost, r as AppRequestAnswerOptions } from './elicitation-CcZe5-EK.js';
6
- export { s as APP_DEFAULT_HEIGHT, t as APP_MAX_HEIGHT, u as APP_MIN_HEIGHT, v as AppDownload, w as AppDownloadView, x as AppFileSaverEnv, y as AppLink, z as AppReadyDownload, F as AppResourceReader, G as ElicitationControl, H as ElicitationDraft, I as ElicitationDraftValue, J as ElicitationField, K as ElicitationFormOutcome, N as ElicitationIssue, O as ElicitationLink, Q as ElicitationOption, R as FetchView, V as MCP_APP_DISPLAY_MODES, X as MCP_APP_MAX_ARGS_CHARS, Y as MCP_APP_MAX_DOWNLOAD_BYTES, Z as MCP_APP_MAX_FILE_NAME_CHARS, _ as MCP_APP_MAX_IN_FLIGHT, $ as MCP_APP_MAX_MESSAGE_CHARS, a0 as MCP_APP_MAX_URL_CHARS, a1 as MCP_APP_NOTIFICATIONS, a2 as MCP_APP_OPTIONAL_REQUESTS, a3 as MCP_APP_PROTOCOL_VERSION, a4 as MCP_APP_REFUSED, a5 as MCP_APP_REFUSED_DOWNLOAD_EXTENSIONS, a6 as MCP_APP_REFUSED_DOWNLOAD_TYPES, a7 as MCP_APP_RELAY, a8 as MCP_APP_REQUESTS, a9 as MCP_APP_SANDBOX_FRAME_TOKENS, aa as MCP_APP_SANDBOX_GRACE_MS, ab as MCP_APP_SANDBOX_SERVER, ac as MCP_APP_SANDBOX_TIMEOUT_MS, ad as McpAppBridge, ae as McpAppBridgeHandlers, af as McpAppBridgeOptions, ag as McpAppDisplayMode, ah as McpAppRpcError, ai as McpAppRpcMessage, aj as McpAppSandboxInput, ak as McpAppSandboxLink, al as McpAppSandboxLinkOptions, am as McpAppSandboxTarget, an as McpElicitationFieldSchema, ao as McpElicitationRequest, ap as McpElicitationSchema, aq as QueuedMessageView, ar as ReplanState, as as SkillConsentView, at as StepEscalationView, au as UseMcpAppHostOptions, av as appDisplayModeAllowed, aw as appDownloadOf, ax as appDownloadRefusal, ay as appFileExtensionOf, az as appFileNameOf, aA as appGestureOf, aB as appLinkOf, aC as appMessageTextOf, aD as appMimeTypeOf, aE as appSamplingErrorOf, aF as buildMcpAppDocument, aG as buildMcpAppSandboxShell, aH as clampAppHeight, aI as elicitationFields, aJ as elicitationFormAnswer, aK as elicitationInitialDraft, aL as elicitationLink, aM as formatCountdown, aN as grantedAppCsp, aO as mcpAppCsp, aP as mcpAppHostCapabilities, aQ as mcpAppSandboxProxyUrl, aR as mcpAppSandboxShellCsp, aS as mcpAppSandboxTarget, aT as resolveAppDownload, aU as saveAppFile, aV as useMcpAppHost } from './elicitation-CcZe5-EK.js';
4
+ export { Agent, AgentEvent, AgentEventHandler, AgentLoggerSink, AgentTool, AgentToolSet, AppToolCallRequest, AttachmentsNotSupportedError, BrowserAgentConfig, CompactResult, CompactionConfig, CredentialStore, FileToolsOptions, IPlan, IPlanStep, IStepResult, IToolCall, IUsage, ImagesNotSupportedError, IndexedDBStore, LearningConfig, LogLevel, McpAppCsp, McpAppResource, McpAppToolResult, MemoryCredentialStore, MemorySkillStore, MemoryStore, ModelInput, ProviderModelSpec, ProviderType, RunControl, RunFile, RunOptions, RunResult, SessionBusyError, SessionHolder, SessionLockMode, SessionRunState, SessionWatch, Skill, SkillStore, StorageChange, StorageChangeKind, StorageChangeOp, SubagentInfo, SubagentToolOptions, SubagentWorkerConfig, ThinkingLevel, ThinkingSetting, TokenLimits, ToolApprovalConfig, ToolApprovalContext, ToolApprovalMode, ToolApprovalRequest, VaultCredentialStore, VfsSkillStore, VirtualFile, VirtualFileInfo, VirtualFileSystem, WatchSessionOptions, createAgent, createFileTools, createRunControl, createSubagentTool, createWebLLMModel, defineSkill, defineTool, isWebGPUAvailable, loadSkillFromUrl, markReadOnly, onStorageChange, parseSkillMarkdown, postStorageChange, preloadWebLLMModel, serveSubagentWorker, supportsImages, supportsPdf, unloadWebLLMModel, watchSession } from '@dudko.dev/agent-web';
5
+ import { A as AgentUiState, C as ChatAttachment, a as ApprovalView, b as ChatMessage, c as AgentStatus, E as ElicitationIssueKind, d as ElicitationOutcomeReason, M as McpAppSandboxReason, R as RemoteRunView, L as LessonView, S as SubagentView, e as SubagentNode, P as PendingElicitation, f as McpElicitationResult, g as ElicitationView, W as WrittenFileView, T as ToolCallView, h as StepView, U as UserNoteView, D as DecisionView, i as MediaView, j as AppView, k as McpAppsConnectionLike, l as McpAppSandboxOptions, m as AppRequestView, n as TranscriptView, B as BudgetView, o as CompactionView, p as ModelLoadState, q as McpAppHost, r as AppRequestAnswerOptions } from './elicitation-BW7R4iIw.js';
6
+ export { s as APP_DEFAULT_HEIGHT, t as APP_MAX_HEIGHT, u as APP_MIN_HEIGHT, v as AppDownload, w as AppDownloadView, x as AppFileSaverEnv, y as AppLink, z as AppReadyDownload, F as AppResourceReader, G as ElicitationControl, H as ElicitationDraft, I as ElicitationDraftValue, J as ElicitationField, K as ElicitationFormOutcome, N as ElicitationIssue, O as ElicitationLink, Q as ElicitationOption, V as FetchView, X as MCP_APP_DISPLAY_MODES, Y as MCP_APP_MAX_ARGS_CHARS, Z as MCP_APP_MAX_DOWNLOAD_BYTES, _ as MCP_APP_MAX_FILE_NAME_CHARS, $ as MCP_APP_MAX_IN_FLIGHT, a0 as MCP_APP_MAX_MESSAGE_CHARS, a1 as MCP_APP_MAX_URL_CHARS, a2 as MCP_APP_NOTIFICATIONS, a3 as MCP_APP_OPTIONAL_REQUESTS, a4 as MCP_APP_PROTOCOL_VERSION, a5 as MCP_APP_REFUSED, a6 as MCP_APP_REFUSED_DOWNLOAD_EXTENSIONS, a7 as MCP_APP_REFUSED_DOWNLOAD_TYPES, a8 as MCP_APP_RELAY, a9 as MCP_APP_REQUESTS, aa as MCP_APP_SANDBOX_FRAME_TOKENS, ab as MCP_APP_SANDBOX_GRACE_MS, ac as MCP_APP_SANDBOX_SERVER, ad as MCP_APP_SANDBOX_TIMEOUT_MS, ae as McpAppBridge, af as McpAppBridgeHandlers, ag as McpAppBridgeOptions, ah as McpAppDisplayMode, ai as McpAppRpcError, aj as McpAppRpcMessage, ak as McpAppSandboxInput, al as McpAppSandboxLink, am as McpAppSandboxLinkOptions, an as McpAppSandboxTarget, ao as McpElicitationFieldSchema, ap as McpElicitationRequest, aq as McpElicitationSchema, ar as QueuedMessageView, as as ReplanState, at as SkillConsentView, au as StepEscalationView, av as UseMcpAppHostOptions, aw as appDisplayModeAllowed, ax as appDownloadOf, ay as appDownloadRefusal, az as appFileExtensionOf, aA as appFileNameOf, aB as appGestureOf, aC as appLinkOf, aD as appMessageTextOf, aE as appMimeTypeOf, aF as appSamplingErrorOf, aG as buildMcpAppDocument, aH as buildMcpAppSandboxShell, aI as clampAppHeight, aJ as elicitationFields, aK as elicitationFormAnswer, aL as elicitationInitialDraft, aM as elicitationLink, aN as formatCountdown, aO as grantedAppCsp, aP as mcpAppCsp, aQ as mcpAppHostCapabilities, aR as mcpAppSandboxProxyUrl, aS as mcpAppSandboxShellCsp, aT as mcpAppSandboxTarget, aU as resolveAppDownload, aV as saveAppFile, aW as useMcpAppHost } from './elicitation-BW7R4iIw.js';
7
7
  export { M as MCP_APP_POLICY_TOKEN_MAX_CHARS, a as MCP_APP_SANDBOX_PROXY_READY, b as MCP_APP_SANDBOX_RESOURCE_READY, i as isMcpAppSandboxMessage, m as mcpAppPolicyToken } from './mcp-app-policy-DIUmGPJP.js';
8
8
 
9
9
  interface UseAgentOptions {
@@ -36,6 +36,14 @@ interface UseAgentOptions {
36
36
  * for the UI to offer (`sendUndelivered` / `discardUndelivered`).
37
37
  */
38
38
  followUp?: boolean;
39
+ /**
40
+ * Follow a run of the current conversation that goes on in ANOTHER tab of the site (default
41
+ * true; needs a `memory` the tabs share - `IndexedDBStore` - and `sessionLock` not `'off'`): its
42
+ * steps and answer show here live (`remote`) and `isRunning` is true meanwhile. Writing to it or
43
+ * stopping it is explicit: `sendRemote` / `stopRemote` (the chat panel's composer and Stop button
44
+ * use them while they follow such a run). Consent requests stay in that tab.
45
+ */
46
+ watch?: boolean;
39
47
  }
40
48
  interface ApproveOptions {
41
49
  /** Also allow this tool for the rest of the agent's life ("always allow"). */
@@ -55,15 +63,35 @@ interface RunGoalOptions {
55
63
  attachments?: ChatAttachment[];
56
64
  }
57
65
  interface UseAgentReturn extends AgentUiState {
58
- /** Run a goal. Resolves with the RunResult, or `undefined` if it couldn't start. */
66
+ /**
67
+ * Run a goal. Resolves with the RunResult, or `undefined` if it couldn't start. When the
68
+ * conversation is running in another tab, the run waits for it (`sessionBusy`; the core's
69
+ * `sessionLock`) and then goes, with that run's turn in its memory.
70
+ */
59
71
  run: (goal: string, options?: RunGoalOptions) => Promise<RunResult | undefined>;
60
- /** Abort the in-flight run (observed between phases and mid-stream). */
72
+ /**
73
+ * Abort the in-flight run of THIS tab (observed between phases and mid-stream), going or waiting
74
+ * for the session. A run followed from another tab is stopped only by `stopRemote`.
75
+ */
61
76
  stop: () => void;
77
+ /**
78
+ * Stop the conversation's run in another tab (`remote`), when that tab allows it (the core's
79
+ * `sessionRelay`). A no-op when none is followed.
80
+ */
81
+ stopRemote: () => void;
82
+ /**
83
+ * Say something to the conversation's run in another tab (`remote`): it reaches that run's
84
+ * model at its next boundary, marked as from another tab. `false` when no such run is followed
85
+ * or the text is empty. A message that tab refuses (or never answers) comes back in
86
+ * `undelivered`.
87
+ */
88
+ sendRemote: (text: string) => boolean;
62
89
  /**
63
90
  * Say something to the agent while it works. It is shown to the model at the next
64
91
  * boundary (between tool calls, or when the step ends — where the replanner then
65
92
  * re-checks the plan), never cutting a tool call short. `false` when no run is in
66
- * flight or the text is empty — then use `run`. Watch `queued` / `notes`.
93
+ * flight or the text is empty — then use `run`. Watch `queued` / `notes`. Only this tab's run:
94
+ * for the conversation's run in another tab, `sendRemote`.
67
95
  */
68
96
  send: (text: string) => boolean;
69
97
  /** Stop ONE running subagent (`SubagentView.id`); the run and its siblings go on. */
@@ -173,15 +201,31 @@ interface ChatHistoryStoreOptions {
173
201
  /** Keep chats in memory only (tests, private mode; also the fallback without IndexedDB). */
174
202
  memory?: boolean;
175
203
  }
176
- /** IndexedDB-backed chat history (raw IndexedDB — no extra dependency). */
204
+ /**
205
+ * IndexedDB-backed chat history (raw IndexedDB — no extra dependency). Every tab of the origin
206
+ * shares it: once a write has committed the other tabs hear which chat changed (a `chats`
207
+ * notice from the core's `postStorageChange` - the id, never a message), and `useChatHistory`
208
+ * there refreshes.
209
+ */
177
210
  declare class ChatHistoryStore {
178
- private readonly dbName;
211
+ /** The IndexedDB database (undefined in memory): the name its `chats` notices go out under. */
212
+ readonly dbName: string | undefined;
213
+ private readonly name;
179
214
  private readonly storeName;
180
215
  private readonly memory?;
181
216
  private db?;
182
217
  constructor(opts?: ChatHistoryStoreOptions);
183
218
  private open;
184
219
  private tx;
220
+ /** One write in its own transaction, resolved once it committed - then the notice. */
221
+ private write;
222
+ private announce;
223
+ /**
224
+ * Read the stored record and write what `merge` makes of it in ONE readwrite transaction: no
225
+ * other tab's save can land between the read and the write. `merge` is synchronous (a
226
+ * transaction does not survive an await). Resolves with what was written, once committed.
227
+ */
228
+ putMerged(id: string, merge: (stored: ChatRecord | undefined) => ChatRecord): Promise<ChatRecord>;
185
229
  list(): Promise<ChatSummary[]>;
186
230
  get(id: string): Promise<ChatRecord | undefined>;
187
231
  put(record: ChatRecord): Promise<void>;
@@ -213,11 +257,43 @@ interface UseChatHistoryReturn {
213
257
  /** Delete a conversation (and start a new one if it was open). */
214
258
  remove: (id: string) => Promise<void>;
215
259
  }
260
+ /** What this tab last read or wrote of a chat: the very message objects, and when. */
261
+ interface ChatBase {
262
+ /** The messages as read or written (by identity: an edit, a reset or a trim is not "known"). */
263
+ known: ReadonlySet<ChatMessage>;
264
+ updatedAt: number;
265
+ }
266
+ /** This tab's view says nothing new (every message is one it read or wrote). */
267
+ declare const unchangedSince: (messages: ChatMessage[], base: ChatBase | undefined) => boolean;
268
+ /**
269
+ * The record to save. A turn this tab only followed from another tab (`remote`) is never saved
270
+ * from here - that tab saves its own, unclipped copy. When another tab saved the chat after this
271
+ * tab last read or wrote it (or saved a chat this tab never read), THAT record is the truth for
272
+ * everything that is not this tab's own: this tab's own new messages - by identity, not by count,
273
+ * so a reset or a trim here drops nothing there - go after it.
274
+ */
275
+ declare const mergeChatRecord: (view: ChatRecord, stored: ChatRecord | undefined, base: ChatBase | undefined) => {
276
+ record: ChatRecord;
277
+ merged: boolean;
278
+ };
279
+ /**
280
+ * What `useChatHistory` does to save the open chat: the stored record is read and the merged one
281
+ * written in ONE readwrite transaction (`ChatHistoryStore.putMerged`), so another tab's save
282
+ * cannot land between the two.
283
+ */
284
+ declare const saveChat: (store: ChatHistoryStore, view: ChatRecord, base: ChatBase | undefined) => Promise<{
285
+ record: ChatRecord;
286
+ merged: boolean;
287
+ }>;
216
288
  /**
217
289
  * Persist an agent's conversations — the transcript with its tool calls, usage
218
290
  * and image attachments — and switch between them. Each chat id is also the
219
291
  * agent's memory session, so with a persistent `memory` (IndexedDBStore) a
220
292
  * reopened chat continues with the model's context intact.
293
+ *
294
+ * Several tabs: the list follows what other tabs of the site save (the store's `chats`
295
+ * notices), the open chat is read again when another tab saved it and nothing runs here, and a
296
+ * run followed from another tab (`agent.remote`) is never saved from here - its own tab saves it.
221
297
  */
222
298
  declare const useChatHistory: (agent: UseAgentReturn, options?: UseChatHistoryOptions) => UseChatHistoryReturn;
223
299
 
@@ -236,9 +312,10 @@ interface UseVirtualFilesReturn {
236
312
  }
237
313
  /**
238
314
  * A live listing of a {@link VirtualFileSystem} (the core's browser
239
- * workspace): re-reads on every write / delete — by the user or by the agent's
240
- * `fs_*` tools — and offers upload / remove / read helpers. Headless: render
241
- * it with `<FilesPanel>` or your own UI.
315
+ * workspace): re-reads on every write / delete — by the user, by the agent's
316
+ * `fs_*` tools, or in another tab of the origin (a `files` notice) — and offers
317
+ * upload / remove / read helpers. Headless: render it with `<FilesPanel>` or
318
+ * your own UI.
242
319
  */
243
320
  declare const useVirtualFiles: (vfs: VirtualFileSystem | undefined, prefix?: string) => UseVirtualFilesReturn;
244
321
 
@@ -306,8 +383,9 @@ interface UseCredentialsReturn {
306
383
  /** Resolve whether a key is currently present for a ref. */
307
384
  hasKey: (ref: string) => Promise<boolean>;
308
385
  /**
309
- * Bumped whenever a key is written or removed — depend on it in an effect to
310
- * re-query `hasKey` and reflect the change in your UI.
386
+ * Bumped whenever a key is written or removed — here, or in another tab of the origin (the
387
+ * vault's `credentials` notice) — depend on it in an effect to re-query `hasKey` and reflect
388
+ * the change in your UI.
311
389
  */
312
390
  version: number;
313
391
  }
@@ -742,6 +820,16 @@ interface AgentLabels {
742
820
  discardUndelivered: string;
743
821
  stopSubagent: string;
744
822
  subagentStopped: string;
823
+ /** The conversation is running in another tab: it is shown here live, and Stop / typing go there. */
824
+ remoteRunning: string;
825
+ /** That run waits for a person's answer - which is given in that tab. */
826
+ remoteWaitingConsent: string;
827
+ /** That tab closed (or crashed) before the run finished. */
828
+ remoteGone: string;
829
+ /** This tab's run waits for the other run of the conversation (in another tab, or in this one). */
830
+ sessionBusy: (heldBy: 'another-tab' | 'this-tab') => string;
831
+ /** The mark on a message written to this run from another tab (queued, and where it arrived). */
832
+ fromAnotherTab: string;
745
833
  failed: string;
746
834
  toolCostTitle: string;
747
835
  /** The tier badge on a step. */
@@ -984,6 +1072,13 @@ interface AgentLabels {
984
1072
  skillConsentByUri: string;
985
1073
  /** It sits inside another skill of the same server. */
986
1074
  skillConsentNested: (enclosing: string) => string;
1075
+ /**
1076
+ * A generated skill (`skill.dynamic`): the server publishes no checksums - the person approves
1077
+ * the copy the agent just read, and only that copy is used.
1078
+ */
1079
+ skillConsentDynamic: string;
1080
+ /** (with `skillConsentDynamic`) The server cannot list the skill's files: SKILL.md alone. */
1081
+ skillConsentNoFileListing: string;
987
1082
  /** The summary of the collapsible preview of its instructions. */
988
1083
  skillConsentPreview: string;
989
1084
  /** Under the preview: its other files, and how many more there are than are shown. */
@@ -1093,6 +1188,18 @@ type AgentAction =
1093
1188
  maxEvents?: number;
1094
1189
  at?: number;
1095
1190
  attachments?: ChatAttachment[];
1191
+ /** The event is another tab's run of this conversation (`watchSession`), relayed here. */
1192
+ remote?: boolean;
1193
+ /** With `session.busy`: the goal that waits (shown as queued until the run starts). */
1194
+ goal?: string;
1195
+ }
1196
+ /**
1197
+ * Another tab's run of this conversation, as `watchSession` reports it (or `undefined`: none
1198
+ * in view). Ended `gone` - that tab closed before it said so - finishes the answer it left.
1199
+ */
1200
+ | {
1201
+ type: 'remote';
1202
+ remote: RemoteRunView | undefined;
1096
1203
  }
1097
1204
  /**
1098
1205
  * The agent's notebook as it is now (the hook sends it when the agent is built: lessons a
@@ -1116,6 +1223,16 @@ type AgentAction =
1116
1223
  | {
1117
1224
  type: 'undelivered';
1118
1225
  texts: string[];
1226
+ keepQueued?: boolean;
1227
+ }
1228
+ /**
1229
+ * The user sent a goal and this tab's run is getting going: its turn is shown at once (a
1230
+ * user message and a pending answer), until the run's `run.start` takes its place.
1231
+ */
1232
+ | {
1233
+ type: 'submitted';
1234
+ goal: string;
1235
+ attachments?: ChatAttachment[];
1119
1236
  };
1120
1237
  /**
1121
1238
  * The notebook view of the agent's own skills (`agent.listLearnedSkills()`): what the core stored
@@ -1129,6 +1246,17 @@ declare const createInitialAgentState: () => AgentUiState;
1129
1246
  * they started. A node whose parent is not in the list (its start was never seen) is a root.
1130
1247
  */
1131
1248
  declare const subagentTree: (subagents: SubagentView[]) => SubagentNode[];
1249
+ /**
1250
+ * The consent requests THIS tab can answer: pending, and not asked in another tab (a run of the
1251
+ * conversation going on there - those are shown, and answered only there). What `useAgent`
1252
+ * returns as `pendingApprovals`.
1253
+ */
1254
+ declare const pendingApprovalsOf: (state: Pick<AgentUiState, "approvals">) => ApprovalView[];
1255
+ /**
1256
+ * The status to show: `running` while another tab runs this conversation (`remote`) and this
1257
+ * tab is otherwise ready or idle - never over `initializing` or `error`, which the host must see.
1258
+ */
1259
+ declare const agentStatusOf: (state: Pick<AgentUiState, "status" | "remote">) => AgentUiState["status"];
1132
1260
  declare const agentStateReducer: (state: AgentUiState, action: AgentAction) => AgentUiState;
1133
1261
 
1134
1262
  interface ComposerModelChip {
@@ -1797,6 +1925,12 @@ interface AgentChatProps {
1797
1925
  * the agent would read (default true; `<ToolApprovalPrompt showSkillPreview>`).
1798
1926
  */
1799
1927
  showSkillPreview?: boolean;
1928
+ /**
1929
+ * Notes about the site's other tabs above the composer (default true): the conversation is
1930
+ * running in another tab (followed here live), that run waits for an answer there, that tab
1931
+ * closed mid-run, or this tab's message waits for the other run to finish.
1932
+ */
1933
+ showOtherTabs?: boolean;
1800
1934
  /**
1801
1935
  * Saved conversations in IndexedDB with a sidebar to switch between them:
1802
1936
  * `true` (default store), your own `ChatHistoryStore`, or the result of your
@@ -2317,5 +2451,5 @@ interface AppRequestPromptProps {
2317
2451
  */
2318
2452
  declare const AppRequestPrompt: ({ requests, onAnswer, renderRequest, labels, className, }: AppRequestPromptProps) => react.JSX.Element | null;
2319
2453
 
2320
- export { AgentChat, AgentComposer, AgentLabelsProvider, AgentProvider, AgentStatus, AgentUiState, ApiKeyForm, AppRequestAnswerOptions, AppRequestPrompt, AppRequestView, AppView, ApprovalModeSwitch, ApprovalView, AttachmentView, BudgetView, ChatAttachment, ChatHistoryList, ChatHistoryStore, ChatMessage, CompactionView, Composer, ContextMeter, DecisionView, ElicitationIssueKind, ElicitationOutcomeReason, ElicitationPrompt, ElicitationView, FILE_PREVIEW_CHARS, FRAME_MAX_HEIGHT, FRAME_MIN_HEIGHT, FileChip, FileChips, FilesPanel, GeneratedMedia, HTML_PREVIEW_MAX_CHARS, LearnedSkills, LessonView, McpAppFrame, McpAppHost, McpAppLine, McpAppSandboxOptions, McpAppSandboxReason, McpAppsConnectionLike, McpElicitationResult, MediaView, MessageList, ModelLoadBar, ModelLoadState, PendingElicitation, PlanView, SandboxedFrame, SourceView, StepList, StepView, SubagentNode, SubagentRow, SubagentTree, SubagentView, ToolApprovalPrompt, ToolCallRow, ToolCallView, TranscriptBlock, TranscriptView, UsageBadge, UserNoteRow, UserNoteView, agentStateReducer, attachmentKindOf, attachmentRefusal, buildSandboxedDocument, chatTitle, clampFrameHeight, createApprovalQueue, createInitialAgentState, createWebLLMEngine, decisionNote, defaultLabels, downscaleImage, escapeAttribute, fileKindOf, fileNameOf, filterCommands, formatElapsed, lessonsOf, linkedFilesOf, mediaFamilyOf, mergeLabels, newChatId, noticesOf, parseSlash, sandboxTokens, sandboxedCsp, steerIntent, subagentTree, tokenizeHtml, usageLine, useAgent, useAgentContext, useChatHistory, useCredentials, useLabels, useLocalModel, useOptionalAgentContext, useSpeechToText, useVirtualFiles, useWebLLMModel, webSearchOf, withAttachments, withCspFirst, withPolicyFirst };
2321
- export type { AgentAction, AgentChatClassNames, AgentChatComponents, AgentChatProps, AgentChatSlots, AgentComposerProps, AgentLabels, AgentLabelsOverride, AgentLabelsProviderProps, AgentProviderProps, ApiKeyFormProps, AppRequestPromptProps, ApprovalModeSwitchProps, ApprovalQueue, ApproveOptions, ChatHistoryListProps, ChatHistoryStoreOptions, ChatRecord, ChatSummary, ComposerAttachment, ComposerModelChip, ComposerNotice, ComposerProps, ComposerThinkingChip, ContextMeterProps, ConvertedFile, DownscaleOptions, ElicitationPromptProps, FileChipProps, FileChipsProps, FileKind, FilesPanelProps, GeneratedMediaProps, HtmlPreviewOptions, LearnedSkillsProps, LocalModelEngine, LocalModelLoadContext, LocalModelProgress, McpAppFrameProps, McpAppLineProps, MessageListProps, ModelLoadBarProps, NoticeTexts, PlanViewProps, RenderSubagent, RenderToolCall, RunGoalOptions, SandboxedDocumentOptions, SandboxedFrameProps, SlashCommand, SourceToken, SourceViewProps, SpeechRecognizerLike, SteerIntent, StepListProps, SubagentRowProps, SubagentTreeProps, ToolApprovalPromptProps, ToolCallRowProps, TranscriptBlockProps, UsageBadgeProps, UseAgentOptions, UseAgentReturn, UseChatHistoryOptions, UseChatHistoryReturn, UseCredentialsReturn, UseLocalModelOptions, UseLocalModelReturn, UseSpeechToTextOptions, UseSpeechToTextReturn, UseVirtualFilesReturn, UseWebLLMModelOptions, UseWebLLMModelReturn, WebLLMModelFactory, WebSearchResultView, WebSearchView };
2454
+ export { AgentChat, AgentComposer, AgentLabelsProvider, AgentProvider, AgentStatus, AgentUiState, ApiKeyForm, AppRequestAnswerOptions, AppRequestPrompt, AppRequestView, AppView, ApprovalModeSwitch, ApprovalView, AttachmentView, BudgetView, ChatAttachment, ChatHistoryList, ChatHistoryStore, ChatMessage, CompactionView, Composer, ContextMeter, DecisionView, ElicitationIssueKind, ElicitationOutcomeReason, ElicitationPrompt, ElicitationView, FILE_PREVIEW_CHARS, FRAME_MAX_HEIGHT, FRAME_MIN_HEIGHT, FileChip, FileChips, FilesPanel, GeneratedMedia, HTML_PREVIEW_MAX_CHARS, LearnedSkills, LessonView, McpAppFrame, McpAppHost, McpAppLine, McpAppSandboxOptions, McpAppSandboxReason, McpAppsConnectionLike, McpElicitationResult, MediaView, MessageList, ModelLoadBar, ModelLoadState, PendingElicitation, PlanView, RemoteRunView, SandboxedFrame, SourceView, StepList, StepView, SubagentNode, SubagentRow, SubagentTree, SubagentView, ToolApprovalPrompt, ToolCallRow, ToolCallView, TranscriptBlock, TranscriptView, UsageBadge, UserNoteRow, UserNoteView, agentStateReducer, agentStatusOf, attachmentKindOf, attachmentRefusal, buildSandboxedDocument, chatTitle, clampFrameHeight, createApprovalQueue, createInitialAgentState, createWebLLMEngine, decisionNote, defaultLabels, downscaleImage, escapeAttribute, fileKindOf, fileNameOf, filterCommands, formatElapsed, lessonsOf, linkedFilesOf, mediaFamilyOf, mergeChatRecord, mergeLabels, newChatId, noticesOf, parseSlash, pendingApprovalsOf, sandboxTokens, sandboxedCsp, saveChat, steerIntent, subagentTree, tokenizeHtml, unchangedSince, usageLine, useAgent, useAgentContext, useChatHistory, useCredentials, useLabels, useLocalModel, useOptionalAgentContext, useSpeechToText, useVirtualFiles, useWebLLMModel, webSearchOf, withAttachments, withCspFirst, withPolicyFirst };
2455
+ export type { AgentAction, AgentChatClassNames, AgentChatComponents, AgentChatProps, AgentChatSlots, AgentComposerProps, AgentLabels, AgentLabelsOverride, AgentLabelsProviderProps, AgentProviderProps, ApiKeyFormProps, AppRequestPromptProps, ApprovalModeSwitchProps, ApprovalQueue, ApproveOptions, ChatBase, ChatHistoryListProps, ChatHistoryStoreOptions, ChatRecord, ChatSummary, ComposerAttachment, ComposerModelChip, ComposerNotice, ComposerProps, ComposerThinkingChip, ContextMeterProps, ConvertedFile, DownscaleOptions, ElicitationPromptProps, FileChipProps, FileChipsProps, FileKind, FilesPanelProps, GeneratedMediaProps, HtmlPreviewOptions, LearnedSkillsProps, LocalModelEngine, LocalModelLoadContext, LocalModelProgress, McpAppFrameProps, McpAppLineProps, MessageListProps, ModelLoadBarProps, NoticeTexts, PlanViewProps, RenderSubagent, RenderToolCall, RunGoalOptions, SandboxedDocumentOptions, SandboxedFrameProps, SlashCommand, SourceToken, SourceViewProps, SpeechRecognizerLike, SteerIntent, StepListProps, SubagentRowProps, SubagentTreeProps, ToolApprovalPromptProps, ToolCallRowProps, TranscriptBlockProps, UsageBadgeProps, UseAgentOptions, UseAgentReturn, UseChatHistoryOptions, UseChatHistoryReturn, UseCredentialsReturn, UseLocalModelOptions, UseLocalModelReturn, UseSpeechToTextOptions, UseSpeechToTextReturn, UseVirtualFilesReturn, UseWebLLMModelOptions, UseWebLLMModelReturn, WebLLMModelFactory, WebSearchResultView, WebSearchView };