@dudko.dev/agent-web-react 0.0.19 → 0.0.20

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,7 +1,7 @@
1
1
  import * as react from 'react';
2
2
  import { DependencyList, ReactNode, RefObject, ComponentType, CSSProperties } from 'react';
3
3
  import { IPlan, IPlanStep, IUsage, ReplanMode, AgentEvent, RunFile, RunResult, Agent, ToolApprovalMode, CompactResult, AgentEventHandler, BrowserAgentConfig, VirtualFileInfo, VirtualFileSystem, CredentialStore, createWebLLMModel, WebLLMModelOptions } from '@dudko.dev/agent-web';
4
- export { Agent, AgentEvent, AgentEventHandler, AgentLoggerSink, AgentTool, AgentToolSet, AttachmentsNotSupportedError, BrowserAgentConfig, CompactResult, CompactionConfig, CredentialStore, FileToolsOptions, IPlan, IPlanStep, IStepResult, IToolCall, IUsage, ImagesNotSupportedError, IndexedDBStore, LogLevel, MemoryCredentialStore, MemoryStore, ModelInput, ProviderModelSpec, ProviderType, RunFile, RunOptions, RunResult, Skill, SubagentToolOptions, SubagentWorkerConfig, ThinkingLevel, ThinkingSetting, TokenLimits, ToolApprovalConfig, ToolApprovalMode, ToolApprovalRequest, VaultCredentialStore, VirtualFile, VirtualFileInfo, VirtualFileSystem, createAgent, createFileTools, createSubagentTool, createWebLLMModel, defineSkill, defineTool, isWebGPUAvailable, loadSkillFromUrl, markReadOnly, parseSkillMarkdown, preloadWebLLMModel, serveSubagentWorker, supportsImages, supportsPdf, unloadWebLLMModel } from '@dudko.dev/agent-web';
4
+ export { Agent, AgentEvent, AgentEventHandler, AgentLoggerSink, AgentTool, AgentToolSet, AttachmentsNotSupportedError, BrowserAgentConfig, CompactResult, CompactionConfig, CredentialStore, FileToolsOptions, IPlan, IPlanStep, IStepResult, IToolCall, IUsage, ImagesNotSupportedError, IndexedDBStore, LogLevel, MemoryCredentialStore, MemoryStore, ModelInput, ProviderModelSpec, ProviderType, RunControl, RunFile, RunOptions, RunResult, Skill, SubagentInfo, SubagentToolOptions, SubagentWorkerConfig, ThinkingLevel, ThinkingSetting, TokenLimits, ToolApprovalConfig, ToolApprovalMode, ToolApprovalRequest, VaultCredentialStore, 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
5
 
6
6
  /** Why a run stopped early (a `budget.exceeded` event). */
7
7
  interface BudgetView {
@@ -44,6 +44,8 @@ interface ChatMessage {
44
44
  approvals?: ApprovalView[];
45
45
  /** Assistant turn: subagent delegations of the run. */
46
46
  subagents?: SubagentView[];
47
+ /** Assistant turn: what the user said while the run was going, and where it reached the agent. */
48
+ notes?: UserNoteView[];
47
49
  /** Assistant turn: the synthesizer's thoughts. */
48
50
  reasoning?: string;
49
51
  /** Assistant turn: tokens the run spent, by kind. */
@@ -84,12 +86,33 @@ interface ApprovalView {
84
86
  /** Decided by policy (rule / read-only mode), not by a person. */
85
87
  automatic?: boolean;
86
88
  }
89
+ /** A message sent to the agent while it works, still waiting for a boundary to be shown to the model. */
90
+ interface QueuedMessageView {
91
+ id: string;
92
+ text: string;
93
+ }
94
+ /**
95
+ * A message the user sent while the run was going, after it reached the agent.
96
+ * `at` says where: `round` = between tool calls inside a step, `step` = at the end
97
+ * of a step (the replanner then re-checked the plan), `final` = just before the
98
+ * answer was written.
99
+ */
100
+ interface UserNoteView {
101
+ id: string;
102
+ text: string;
103
+ at: 'round' | 'step' | 'final';
104
+ /** The step it was delivered in (`round`) or after (`step`); none for `final`. */
105
+ stepId?: string;
106
+ }
87
107
  /** A delegated task running in a subagent (in-process or a Web Worker). */
88
108
  interface SubagentView {
89
109
  id: string;
90
110
  name: string;
91
111
  task: string;
92
- status: 'running' | 'done' | 'error';
112
+ /** `stopped`: the user stopped this subagent; the run went on without it. */
113
+ status: 'running' | 'done' | 'error' | 'stopped';
114
+ /** The profile the parent model chose for this delegation, when there are profiles. */
115
+ profile?: string;
93
116
  /** The step that delegated it, when known. */
94
117
  stepId?: string;
95
118
  /** What the child is doing right now ("step 2: …", "→ tool"). */
@@ -132,6 +155,8 @@ interface ModelLoadState {
132
155
  interface ReplanState {
133
156
  mode: ReplanMode;
134
157
  reason: string;
158
+ /** The replanner ran because the user sent a message, not because a step failed. */
159
+ byUser?: boolean;
135
160
  }
136
161
  /**
137
162
  * The whole UI-facing view of an agent run, rebuilt purely from the stream of
@@ -157,6 +182,16 @@ interface AgentUiState {
157
182
  approvals: ApprovalView[];
158
183
  /** Subagent delegations of this run. */
159
184
  subagents: SubagentView[];
185
+ /** Messages sent while the run goes that have not yet been shown to the model. */
186
+ queued: QueuedMessageView[];
187
+ /** What the user said during this run and when it reached the agent. */
188
+ notes: UserNoteView[];
189
+ /**
190
+ * Messages the run ended without showing the model (sent while the answer was being
191
+ * written, or still queued when the run was stopped). The hook sends them as a
192
+ * follow-up unless the run was stopped; see `useAgent`'s `followUp`.
193
+ */
194
+ undelivered: string[];
160
195
  /** Skills activated in this run. */
161
196
  skills: string[];
162
197
  /** Tools activated by find_tools in this run. */
@@ -212,6 +247,13 @@ interface UseAgentOptions {
212
247
  * (default true). Render them with `<ToolApprovalPrompt>`, or your own UI.
213
248
  */
214
249
  approvals?: boolean;
250
+ /**
251
+ * What the run never showed the agent — a message sent while the answer was being
252
+ * written — is sent as the next message, once the run has ended (default true).
253
+ * A run the user stopped never does this: those messages stay in `undelivered`
254
+ * for the UI to offer (`sendUndelivered` / `discardUndelivered`).
255
+ */
256
+ followUp?: boolean;
215
257
  }
216
258
  interface ApproveOptions {
217
259
  /** Also allow this tool for the rest of the agent's life ("always allow"). */
@@ -235,6 +277,19 @@ interface UseAgentReturn extends AgentUiState {
235
277
  run: (goal: string, options?: RunGoalOptions) => Promise<RunResult | undefined>;
236
278
  /** Abort the in-flight run (observed between phases and mid-stream). */
237
279
  stop: () => void;
280
+ /**
281
+ * Say something to the agent while it works. It is shown to the model at the next
282
+ * boundary (between tool calls, or when the step ends — where the replanner then
283
+ * re-checks the plan), never cutting a tool call short. `false` when no run is in
284
+ * flight or the text is empty — then use `run`. Watch `queued` / `notes`.
285
+ */
286
+ send: (text: string) => boolean;
287
+ /** Stop ONE running subagent (`SubagentView.id`); the run and its siblings go on. */
288
+ stopSubagent: (id: string) => boolean;
289
+ /** Send the `undelivered` messages (a stopped run's leftovers) as a new message. */
290
+ sendUndelivered: () => void;
291
+ /** Drop the `undelivered` messages. */
292
+ discardUndelivered: () => void;
238
293
  /** Clear the whole conversation — transcript, current run, and the agent's memory. */
239
294
  reset: () => void;
240
295
  /** Rebuild the agent now (e.g. after the user stores a new API key). */
@@ -660,6 +715,28 @@ declare const parseSlash: (text: string) => {
660
715
  name: string;
661
716
  args: string;
662
717
  } | undefined;
718
+ /** What pressing Enter does while the agent is working (see {@link steerIntent}). */
719
+ type SteerIntent =
720
+ /** The agent is idle: submit as usual. */
721
+ 'idle'
722
+ /** Say it to the running agent. */
723
+ | 'steer'
724
+ /** There are attachments, which cannot be added to a run that is going. */
725
+ | 'attachments'
726
+ /** Nothing to do (empty, a slash command, or steering is switched off). */
727
+ | 'ignore';
728
+ /**
729
+ * Decide what Enter means while the agent works: text goes to the running agent,
730
+ * files cannot (they are sent with the next message), a "/command" is not a message,
731
+ * and a host that switched steering off gets the old behaviour (nothing happens).
732
+ */
733
+ declare const steerIntent: (input: {
734
+ /** The trimmed text. */
735
+ raw: string;
736
+ busy: boolean;
737
+ steering: boolean;
738
+ hasAttachments: boolean;
739
+ }) => SteerIntent;
663
740
  /** Commands matching what was typed after "/" — name prefix first, then substring. */
664
741
  declare const filterCommands: (commands: SlashCommand[], query: string) => SlashCommand[];
665
742
  /**
@@ -822,6 +899,22 @@ interface AgentLabels {
822
899
  consentWaiting: string;
823
900
  consentAllowed: string;
824
901
  consentDenied: (reason?: string) => string;
902
+ /** Composer placeholder while the agent works (what you type is sent to it). */
903
+ placeholderBusy: string;
904
+ /** The send button while the agent works. */
905
+ steer: string;
906
+ /** Shown when files are attached while the agent works (they can't be added then). */
907
+ noAttachmentsWhileBusy: string;
908
+ /** A message waiting to reach the agent. */
909
+ queuedWaiting: string;
910
+ /** Where a note landed: between tool calls / after a step / before the answer. */
911
+ noteAt: Record<'round' | 'step' | 'final', string>;
912
+ /** Messages the run ended without delivering, offered for sending. */
913
+ undelivered: (n: number) => string;
914
+ sendUndelivered: string;
915
+ discardUndelivered: string;
916
+ stopSubagent: string;
917
+ subagentStopped: string;
825
918
  failed: string;
826
919
  toolCostTitle: string;
827
920
  }
@@ -919,6 +1012,15 @@ type AgentAction =
919
1012
  type: 'load';
920
1013
  messages: ChatMessage[];
921
1014
  totalUsage?: IUsage;
1015
+ }
1016
+ /**
1017
+ * The run is over and these messages never reached the model (`RunResult.undelivered`,
1018
+ * or what was still queued when it was stopped). Clears the queue. An empty list
1019
+ * clears `undelivered` too (the follow-up was sent, or the user discarded them).
1020
+ */
1021
+ | {
1022
+ type: 'undelivered';
1023
+ texts: string[];
922
1024
  };
923
1025
  /** A fresh, empty view. */
924
1026
  declare const createInitialAgentState: () => AgentUiState;
@@ -1014,6 +1116,14 @@ interface AgentComposerProps {
1014
1116
  showApprovalMode?: boolean;
1015
1117
  /** Banners for limits, compaction and errors above the input (default true). */
1016
1118
  showNotices?: boolean;
1119
+ /**
1120
+ * Let the user type to the agent while it works (default true): Enter sends the text
1121
+ * to the running agent, which sees it at its next boundary (see `useAgent().send`).
1122
+ * Off: the input does nothing while a run is going, as before.
1123
+ */
1124
+ steering?: boolean;
1125
+ /** Messages waiting for the agent, and the ones a stopped run left undelivered (default true). */
1126
+ showQueued?: boolean;
1017
1127
  /** Below this width (px) the toolbar chips show icons and numbers only (default 460). */
1018
1128
  compactWidth?: number;
1019
1129
  /** Extra content in the toolbar, after the "/" button. */
@@ -1041,7 +1151,7 @@ interface AgentComposerProps {
1041
1151
  *
1042
1152
  * Every piece can be switched off; `<AgentChat>` uses it as its footer.
1043
1153
  */
1044
- declare const AgentComposer: ({ controller: agent, placeholder, model, thinking, labels: labelsOverride, commands, builtinCommands, skillCommands, attachments, convertFile, convert, files: vfs, dropZone, speech, showTimer, showAgents, showApprovalMode, showNotices, compactWidth, toolbarExtra, toolbarEnd, renderAttachment, disabled, className, }: AgentComposerProps) => react.JSX.Element;
1154
+ declare const AgentComposer: ({ controller: agent, placeholder, model, thinking, labels: labelsOverride, commands, builtinCommands, skillCommands, attachments, convertFile, convert, files: vfs, dropZone, speech, showTimer, showAgents, showApprovalMode, showNotices, steering, showQueued, compactWidth, toolbarExtra, toolbarEnd, renderAttachment, disabled, className, }: AgentComposerProps) => react.JSX.Element;
1045
1155
 
1046
1156
  interface ChatHistoryListProps {
1047
1157
  /** From `useChatHistory(agent)`. */
@@ -1094,9 +1204,19 @@ interface ToolCallRowProps {
1094
1204
  }
1095
1205
  /** One tool call: name, arguments, status — and optionally its cost and any images it returned. */
1096
1206
  declare const ToolCallRow: ({ call, showUsage, labels }: ToolCallRowProps) => react.JSX.Element;
1097
- /** A subagent delegation: name, task, live activity, and its answer when done. */
1098
- declare const SubagentRow: ({ sub, labels, }: {
1207
+ /**
1208
+ * A subagent delegation: name, task, live activity, and its answer when done. With
1209
+ * `onStop`, a running one gets a stop button (the run and its siblings go on).
1210
+ */
1211
+ declare const SubagentRow: ({ sub, onStop, labels, }: {
1099
1212
  sub: SubagentView;
1213
+ /** Stop this subagent (`useAgent().stopSubagent`); the button shows while it runs. */
1214
+ onStop?: (id: string) => void;
1215
+ labels?: AgentLabelsOverride;
1216
+ }) => react.JSX.Element;
1217
+ /** What the user said while the run was going, and where it reached the agent. */
1218
+ declare const UserNoteRow: ({ note, labels, }: {
1219
+ note: UserNoteView;
1100
1220
  labels?: AgentLabelsOverride;
1101
1221
  }) => react.JSX.Element;
1102
1222
  interface StepListProps {
@@ -1105,6 +1225,12 @@ interface StepListProps {
1105
1225
  subagents?: SubagentView[];
1106
1226
  /** Consent decisions (`agent.approvals`) — shown under their step. */
1107
1227
  approvals?: ApprovalView[];
1228
+ /** What the user said mid-run (`agent.notes`) — shown under the step it reached. */
1229
+ notes?: UserNoteView[];
1230
+ /** Show those notes (default true). */
1231
+ showNotes?: boolean;
1232
+ /** Give a running subagent a stop button (`agent.stopSubagent`). */
1233
+ onStopSubagent?: (id: string) => void;
1108
1234
  /** Show each tool call (default true). */
1109
1235
  showToolCalls?: boolean;
1110
1236
  /** Show each tool call's ≈tokens and duration (default true). */
@@ -1120,7 +1246,7 @@ interface StepListProps {
1120
1246
  * The live execution: each step, its thoughts, streamed text, tool calls,
1121
1247
  * consent decisions and subagent delegations.
1122
1248
  */
1123
- declare const StepList: ({ steps, subagents, approvals, showToolCalls, showUsage, showThoughts, renderToolCall, labels, className, }: StepListProps) => react.JSX.Element | null;
1249
+ declare const StepList: ({ steps, subagents, approvals, notes, showNotes, onStopSubagent, showToolCalls, showUsage, showThoughts, renderToolCall, labels, className, }: StepListProps) => react.JSX.Element | null;
1124
1250
 
1125
1251
  interface MessageListProps {
1126
1252
  messages: ChatMessage[];
@@ -1134,6 +1260,10 @@ interface MessageListProps {
1134
1260
  showUsage?: boolean;
1135
1261
  /** Thoughts (step + answer) when the model thinks (default true). */
1136
1262
  showThoughts?: boolean;
1263
+ /** What the user said while the agent worked, under the step it reached (default true). */
1264
+ showNotes?: boolean;
1265
+ /** Give a running subagent a stop button (`useAgent().stopSubagent`). */
1266
+ onStopSubagent?: (id: string) => void;
1137
1267
  /** Open the activity of finished answers too (default: only while it runs). */
1138
1268
  activityOpen?: boolean;
1139
1269
  /** Extra content under the latest assistant turn while it streams (plan thought, …). */
@@ -1165,7 +1295,7 @@ declare const AttachmentView: ({ attachment: a }: {
1165
1295
  * subagents, consent decisions — and the tokens it spent by kind. Every part
1166
1296
  * can be hidden, relabelled or rendered by the host.
1167
1297
  */
1168
- declare const MessageList: ({ messages, empty, showActivity, showToolCalls, showUsage, showThoughts, activityOpen, liveExtra, renderContent, renderMessage, renderAttachment, renderToolCall, labels, className, }: MessageListProps) => react.JSX.Element | null;
1298
+ declare const MessageList: ({ messages, empty, showActivity, showToolCalls, showUsage, showThoughts, showNotes, onStopSubagent, activityOpen, liveExtra, renderContent, renderMessage, renderAttachment, renderToolCall, labels, className, }: MessageListProps) => react.JSX.Element | null;
1169
1299
 
1170
1300
  interface ToolApprovalPromptProps {
1171
1301
  /** Pending requests (e.g. `agent.pendingApprovals`). */
@@ -1241,6 +1371,10 @@ interface AgentChatProps {
1241
1371
  showUsage?: boolean;
1242
1372
  /** Thoughts, when the model thinks (default true). */
1243
1373
  showThoughts?: boolean;
1374
+ /** What you said while the agent worked, under the step it reached (default true). */
1375
+ showNotes?: boolean;
1376
+ /** A stop button on each running subagent (default true). */
1377
+ stoppableSubagents?: boolean;
1244
1378
  /** Conversation total in the header (default true). */
1245
1379
  showTotalUsage?: boolean;
1246
1380
  /** Status dot in the header (default true). */
@@ -1407,5 +1541,5 @@ interface ApiKeyFormProps {
1407
1541
  */
1408
1542
  declare const ApiKeyForm: ({ credentials, credentialRef, label, placeholder, onChange, className, }: ApiKeyFormProps) => react.JSX.Element;
1409
1543
 
1410
- export { AgentChat, AgentComposer, AgentLabelsProvider, AgentProvider, ApiKeyForm, ApprovalModeSwitch, AttachmentView, ChatHistoryList, ChatHistoryStore, Composer, ContextMeter, FilesPanel, MessageList, ModelLoadBar, PlanView, StepList, SubagentRow, ToolApprovalPrompt, ToolCallRow, UsageBadge, agentStateReducer, attachmentKindOf, attachmentRefusal, chatTitle, createInitialAgentState, createWebLLMEngine, defaultLabels, downscaleImage, filterCommands, formatElapsed, mergeLabels, newChatId, noticesOf, parseSlash, usageLine, useAgent, useAgentContext, useChatHistory, useCredentials, useLabels, useLocalModel, useOptionalAgentContext, useSpeechToText, useVirtualFiles, useWebLLMModel, withAttachments };
1411
- export type { AgentAction, AgentChatClassNames, AgentChatComponents, AgentChatProps, AgentChatSlots, AgentComposerProps, AgentLabels, AgentLabelsOverride, AgentLabelsProviderProps, AgentProviderProps, AgentStatus, AgentUiState, ApiKeyFormProps, ApprovalModeSwitchProps, ApprovalView, ApproveOptions, BudgetView, ChatAttachment, ChatHistoryListProps, ChatHistoryStoreOptions, ChatMessage, ChatRecord, ChatSummary, CompactionView, ComposerAttachment, ComposerModelChip, ComposerNotice, ComposerProps, ComposerThinkingChip, ContextMeterProps, ConvertedFile, DownscaleOptions, FilesPanelProps, LocalModelEngine, LocalModelLoadContext, LocalModelProgress, MessageListProps, ModelLoadBarProps, ModelLoadState, NoticeTexts, PlanViewProps, RenderToolCall, ReplanState, RunGoalOptions, SlashCommand, SpeechRecognizerLike, StepListProps, StepView, SubagentView, ToolApprovalPromptProps, ToolCallRowProps, ToolCallView, UsageBadgeProps, UseAgentOptions, UseAgentReturn, UseChatHistoryOptions, UseChatHistoryReturn, UseCredentialsReturn, UseLocalModelOptions, UseLocalModelReturn, UseSpeechToTextOptions, UseSpeechToTextReturn, UseVirtualFilesReturn, UseWebLLMModelOptions, UseWebLLMModelReturn, WebLLMModelFactory };
1544
+ export { AgentChat, AgentComposer, AgentLabelsProvider, AgentProvider, ApiKeyForm, ApprovalModeSwitch, AttachmentView, ChatHistoryList, ChatHistoryStore, Composer, ContextMeter, FilesPanel, MessageList, ModelLoadBar, PlanView, StepList, SubagentRow, ToolApprovalPrompt, ToolCallRow, UsageBadge, UserNoteRow, agentStateReducer, attachmentKindOf, attachmentRefusal, chatTitle, createInitialAgentState, createWebLLMEngine, defaultLabels, downscaleImage, filterCommands, formatElapsed, mergeLabels, newChatId, noticesOf, parseSlash, steerIntent, usageLine, useAgent, useAgentContext, useChatHistory, useCredentials, useLabels, useLocalModel, useOptionalAgentContext, useSpeechToText, useVirtualFiles, useWebLLMModel, withAttachments };
1545
+ export type { AgentAction, AgentChatClassNames, AgentChatComponents, AgentChatProps, AgentChatSlots, AgentComposerProps, AgentLabels, AgentLabelsOverride, AgentLabelsProviderProps, AgentProviderProps, AgentStatus, AgentUiState, ApiKeyFormProps, ApprovalModeSwitchProps, ApprovalView, ApproveOptions, BudgetView, ChatAttachment, ChatHistoryListProps, ChatHistoryStoreOptions, ChatMessage, ChatRecord, ChatSummary, CompactionView, ComposerAttachment, ComposerModelChip, ComposerNotice, ComposerProps, ComposerThinkingChip, ContextMeterProps, ConvertedFile, DownscaleOptions, FilesPanelProps, LocalModelEngine, LocalModelLoadContext, LocalModelProgress, MessageListProps, ModelLoadBarProps, ModelLoadState, NoticeTexts, PlanViewProps, QueuedMessageView, RenderToolCall, ReplanState, RunGoalOptions, SlashCommand, SpeechRecognizerLike, SteerIntent, StepListProps, StepView, SubagentView, ToolApprovalPromptProps, ToolCallRowProps, ToolCallView, UsageBadgeProps, UseAgentOptions, UseAgentReturn, UseChatHistoryOptions, UseChatHistoryReturn, UseCredentialsReturn, UseLocalModelOptions, UseLocalModelReturn, UseSpeechToTextOptions, UseSpeechToTextReturn, UseVirtualFilesReturn, UseWebLLMModelOptions, UseWebLLMModelReturn, UserNoteView, WebLLMModelFactory };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as react from 'react';
2
2
  import { DependencyList, ReactNode, RefObject, ComponentType, CSSProperties } from 'react';
3
3
  import { IPlan, IPlanStep, IUsage, ReplanMode, AgentEvent, RunFile, RunResult, Agent, ToolApprovalMode, CompactResult, AgentEventHandler, BrowserAgentConfig, VirtualFileInfo, VirtualFileSystem, CredentialStore, createWebLLMModel, WebLLMModelOptions } from '@dudko.dev/agent-web';
4
- export { Agent, AgentEvent, AgentEventHandler, AgentLoggerSink, AgentTool, AgentToolSet, AttachmentsNotSupportedError, BrowserAgentConfig, CompactResult, CompactionConfig, CredentialStore, FileToolsOptions, IPlan, IPlanStep, IStepResult, IToolCall, IUsage, ImagesNotSupportedError, IndexedDBStore, LogLevel, MemoryCredentialStore, MemoryStore, ModelInput, ProviderModelSpec, ProviderType, RunFile, RunOptions, RunResult, Skill, SubagentToolOptions, SubagentWorkerConfig, ThinkingLevel, ThinkingSetting, TokenLimits, ToolApprovalConfig, ToolApprovalMode, ToolApprovalRequest, VaultCredentialStore, VirtualFile, VirtualFileInfo, VirtualFileSystem, createAgent, createFileTools, createSubagentTool, createWebLLMModel, defineSkill, defineTool, isWebGPUAvailable, loadSkillFromUrl, markReadOnly, parseSkillMarkdown, preloadWebLLMModel, serveSubagentWorker, supportsImages, supportsPdf, unloadWebLLMModel } from '@dudko.dev/agent-web';
4
+ export { Agent, AgentEvent, AgentEventHandler, AgentLoggerSink, AgentTool, AgentToolSet, AttachmentsNotSupportedError, BrowserAgentConfig, CompactResult, CompactionConfig, CredentialStore, FileToolsOptions, IPlan, IPlanStep, IStepResult, IToolCall, IUsage, ImagesNotSupportedError, IndexedDBStore, LogLevel, MemoryCredentialStore, MemoryStore, ModelInput, ProviderModelSpec, ProviderType, RunControl, RunFile, RunOptions, RunResult, Skill, SubagentInfo, SubagentToolOptions, SubagentWorkerConfig, ThinkingLevel, ThinkingSetting, TokenLimits, ToolApprovalConfig, ToolApprovalMode, ToolApprovalRequest, VaultCredentialStore, 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
5
 
6
6
  /** Why a run stopped early (a `budget.exceeded` event). */
7
7
  interface BudgetView {
@@ -44,6 +44,8 @@ interface ChatMessage {
44
44
  approvals?: ApprovalView[];
45
45
  /** Assistant turn: subagent delegations of the run. */
46
46
  subagents?: SubagentView[];
47
+ /** Assistant turn: what the user said while the run was going, and where it reached the agent. */
48
+ notes?: UserNoteView[];
47
49
  /** Assistant turn: the synthesizer's thoughts. */
48
50
  reasoning?: string;
49
51
  /** Assistant turn: tokens the run spent, by kind. */
@@ -84,12 +86,33 @@ interface ApprovalView {
84
86
  /** Decided by policy (rule / read-only mode), not by a person. */
85
87
  automatic?: boolean;
86
88
  }
89
+ /** A message sent to the agent while it works, still waiting for a boundary to be shown to the model. */
90
+ interface QueuedMessageView {
91
+ id: string;
92
+ text: string;
93
+ }
94
+ /**
95
+ * A message the user sent while the run was going, after it reached the agent.
96
+ * `at` says where: `round` = between tool calls inside a step, `step` = at the end
97
+ * of a step (the replanner then re-checked the plan), `final` = just before the
98
+ * answer was written.
99
+ */
100
+ interface UserNoteView {
101
+ id: string;
102
+ text: string;
103
+ at: 'round' | 'step' | 'final';
104
+ /** The step it was delivered in (`round`) or after (`step`); none for `final`. */
105
+ stepId?: string;
106
+ }
87
107
  /** A delegated task running in a subagent (in-process or a Web Worker). */
88
108
  interface SubagentView {
89
109
  id: string;
90
110
  name: string;
91
111
  task: string;
92
- status: 'running' | 'done' | 'error';
112
+ /** `stopped`: the user stopped this subagent; the run went on without it. */
113
+ status: 'running' | 'done' | 'error' | 'stopped';
114
+ /** The profile the parent model chose for this delegation, when there are profiles. */
115
+ profile?: string;
93
116
  /** The step that delegated it, when known. */
94
117
  stepId?: string;
95
118
  /** What the child is doing right now ("step 2: …", "→ tool"). */
@@ -132,6 +155,8 @@ interface ModelLoadState {
132
155
  interface ReplanState {
133
156
  mode: ReplanMode;
134
157
  reason: string;
158
+ /** The replanner ran because the user sent a message, not because a step failed. */
159
+ byUser?: boolean;
135
160
  }
136
161
  /**
137
162
  * The whole UI-facing view of an agent run, rebuilt purely from the stream of
@@ -157,6 +182,16 @@ interface AgentUiState {
157
182
  approvals: ApprovalView[];
158
183
  /** Subagent delegations of this run. */
159
184
  subagents: SubagentView[];
185
+ /** Messages sent while the run goes that have not yet been shown to the model. */
186
+ queued: QueuedMessageView[];
187
+ /** What the user said during this run and when it reached the agent. */
188
+ notes: UserNoteView[];
189
+ /**
190
+ * Messages the run ended without showing the model (sent while the answer was being
191
+ * written, or still queued when the run was stopped). The hook sends them as a
192
+ * follow-up unless the run was stopped; see `useAgent`'s `followUp`.
193
+ */
194
+ undelivered: string[];
160
195
  /** Skills activated in this run. */
161
196
  skills: string[];
162
197
  /** Tools activated by find_tools in this run. */
@@ -212,6 +247,13 @@ interface UseAgentOptions {
212
247
  * (default true). Render them with `<ToolApprovalPrompt>`, or your own UI.
213
248
  */
214
249
  approvals?: boolean;
250
+ /**
251
+ * What the run never showed the agent — a message sent while the answer was being
252
+ * written — is sent as the next message, once the run has ended (default true).
253
+ * A run the user stopped never does this: those messages stay in `undelivered`
254
+ * for the UI to offer (`sendUndelivered` / `discardUndelivered`).
255
+ */
256
+ followUp?: boolean;
215
257
  }
216
258
  interface ApproveOptions {
217
259
  /** Also allow this tool for the rest of the agent's life ("always allow"). */
@@ -235,6 +277,19 @@ interface UseAgentReturn extends AgentUiState {
235
277
  run: (goal: string, options?: RunGoalOptions) => Promise<RunResult | undefined>;
236
278
  /** Abort the in-flight run (observed between phases and mid-stream). */
237
279
  stop: () => void;
280
+ /**
281
+ * Say something to the agent while it works. It is shown to the model at the next
282
+ * boundary (between tool calls, or when the step ends — where the replanner then
283
+ * re-checks the plan), never cutting a tool call short. `false` when no run is in
284
+ * flight or the text is empty — then use `run`. Watch `queued` / `notes`.
285
+ */
286
+ send: (text: string) => boolean;
287
+ /** Stop ONE running subagent (`SubagentView.id`); the run and its siblings go on. */
288
+ stopSubagent: (id: string) => boolean;
289
+ /** Send the `undelivered` messages (a stopped run's leftovers) as a new message. */
290
+ sendUndelivered: () => void;
291
+ /** Drop the `undelivered` messages. */
292
+ discardUndelivered: () => void;
238
293
  /** Clear the whole conversation — transcript, current run, and the agent's memory. */
239
294
  reset: () => void;
240
295
  /** Rebuild the agent now (e.g. after the user stores a new API key). */
@@ -660,6 +715,28 @@ declare const parseSlash: (text: string) => {
660
715
  name: string;
661
716
  args: string;
662
717
  } | undefined;
718
+ /** What pressing Enter does while the agent is working (see {@link steerIntent}). */
719
+ type SteerIntent =
720
+ /** The agent is idle: submit as usual. */
721
+ 'idle'
722
+ /** Say it to the running agent. */
723
+ | 'steer'
724
+ /** There are attachments, which cannot be added to a run that is going. */
725
+ | 'attachments'
726
+ /** Nothing to do (empty, a slash command, or steering is switched off). */
727
+ | 'ignore';
728
+ /**
729
+ * Decide what Enter means while the agent works: text goes to the running agent,
730
+ * files cannot (they are sent with the next message), a "/command" is not a message,
731
+ * and a host that switched steering off gets the old behaviour (nothing happens).
732
+ */
733
+ declare const steerIntent: (input: {
734
+ /** The trimmed text. */
735
+ raw: string;
736
+ busy: boolean;
737
+ steering: boolean;
738
+ hasAttachments: boolean;
739
+ }) => SteerIntent;
663
740
  /** Commands matching what was typed after "/" — name prefix first, then substring. */
664
741
  declare const filterCommands: (commands: SlashCommand[], query: string) => SlashCommand[];
665
742
  /**
@@ -822,6 +899,22 @@ interface AgentLabels {
822
899
  consentWaiting: string;
823
900
  consentAllowed: string;
824
901
  consentDenied: (reason?: string) => string;
902
+ /** Composer placeholder while the agent works (what you type is sent to it). */
903
+ placeholderBusy: string;
904
+ /** The send button while the agent works. */
905
+ steer: string;
906
+ /** Shown when files are attached while the agent works (they can't be added then). */
907
+ noAttachmentsWhileBusy: string;
908
+ /** A message waiting to reach the agent. */
909
+ queuedWaiting: string;
910
+ /** Where a note landed: between tool calls / after a step / before the answer. */
911
+ noteAt: Record<'round' | 'step' | 'final', string>;
912
+ /** Messages the run ended without delivering, offered for sending. */
913
+ undelivered: (n: number) => string;
914
+ sendUndelivered: string;
915
+ discardUndelivered: string;
916
+ stopSubagent: string;
917
+ subagentStopped: string;
825
918
  failed: string;
826
919
  toolCostTitle: string;
827
920
  }
@@ -919,6 +1012,15 @@ type AgentAction =
919
1012
  type: 'load';
920
1013
  messages: ChatMessage[];
921
1014
  totalUsage?: IUsage;
1015
+ }
1016
+ /**
1017
+ * The run is over and these messages never reached the model (`RunResult.undelivered`,
1018
+ * or what was still queued when it was stopped). Clears the queue. An empty list
1019
+ * clears `undelivered` too (the follow-up was sent, or the user discarded them).
1020
+ */
1021
+ | {
1022
+ type: 'undelivered';
1023
+ texts: string[];
922
1024
  };
923
1025
  /** A fresh, empty view. */
924
1026
  declare const createInitialAgentState: () => AgentUiState;
@@ -1014,6 +1116,14 @@ interface AgentComposerProps {
1014
1116
  showApprovalMode?: boolean;
1015
1117
  /** Banners for limits, compaction and errors above the input (default true). */
1016
1118
  showNotices?: boolean;
1119
+ /**
1120
+ * Let the user type to the agent while it works (default true): Enter sends the text
1121
+ * to the running agent, which sees it at its next boundary (see `useAgent().send`).
1122
+ * Off: the input does nothing while a run is going, as before.
1123
+ */
1124
+ steering?: boolean;
1125
+ /** Messages waiting for the agent, and the ones a stopped run left undelivered (default true). */
1126
+ showQueued?: boolean;
1017
1127
  /** Below this width (px) the toolbar chips show icons and numbers only (default 460). */
1018
1128
  compactWidth?: number;
1019
1129
  /** Extra content in the toolbar, after the "/" button. */
@@ -1041,7 +1151,7 @@ interface AgentComposerProps {
1041
1151
  *
1042
1152
  * Every piece can be switched off; `<AgentChat>` uses it as its footer.
1043
1153
  */
1044
- declare const AgentComposer: ({ controller: agent, placeholder, model, thinking, labels: labelsOverride, commands, builtinCommands, skillCommands, attachments, convertFile, convert, files: vfs, dropZone, speech, showTimer, showAgents, showApprovalMode, showNotices, compactWidth, toolbarExtra, toolbarEnd, renderAttachment, disabled, className, }: AgentComposerProps) => react.JSX.Element;
1154
+ declare const AgentComposer: ({ controller: agent, placeholder, model, thinking, labels: labelsOverride, commands, builtinCommands, skillCommands, attachments, convertFile, convert, files: vfs, dropZone, speech, showTimer, showAgents, showApprovalMode, showNotices, steering, showQueued, compactWidth, toolbarExtra, toolbarEnd, renderAttachment, disabled, className, }: AgentComposerProps) => react.JSX.Element;
1045
1155
 
1046
1156
  interface ChatHistoryListProps {
1047
1157
  /** From `useChatHistory(agent)`. */
@@ -1094,9 +1204,19 @@ interface ToolCallRowProps {
1094
1204
  }
1095
1205
  /** One tool call: name, arguments, status — and optionally its cost and any images it returned. */
1096
1206
  declare const ToolCallRow: ({ call, showUsage, labels }: ToolCallRowProps) => react.JSX.Element;
1097
- /** A subagent delegation: name, task, live activity, and its answer when done. */
1098
- declare const SubagentRow: ({ sub, labels, }: {
1207
+ /**
1208
+ * A subagent delegation: name, task, live activity, and its answer when done. With
1209
+ * `onStop`, a running one gets a stop button (the run and its siblings go on).
1210
+ */
1211
+ declare const SubagentRow: ({ sub, onStop, labels, }: {
1099
1212
  sub: SubagentView;
1213
+ /** Stop this subagent (`useAgent().stopSubagent`); the button shows while it runs. */
1214
+ onStop?: (id: string) => void;
1215
+ labels?: AgentLabelsOverride;
1216
+ }) => react.JSX.Element;
1217
+ /** What the user said while the run was going, and where it reached the agent. */
1218
+ declare const UserNoteRow: ({ note, labels, }: {
1219
+ note: UserNoteView;
1100
1220
  labels?: AgentLabelsOverride;
1101
1221
  }) => react.JSX.Element;
1102
1222
  interface StepListProps {
@@ -1105,6 +1225,12 @@ interface StepListProps {
1105
1225
  subagents?: SubagentView[];
1106
1226
  /** Consent decisions (`agent.approvals`) — shown under their step. */
1107
1227
  approvals?: ApprovalView[];
1228
+ /** What the user said mid-run (`agent.notes`) — shown under the step it reached. */
1229
+ notes?: UserNoteView[];
1230
+ /** Show those notes (default true). */
1231
+ showNotes?: boolean;
1232
+ /** Give a running subagent a stop button (`agent.stopSubagent`). */
1233
+ onStopSubagent?: (id: string) => void;
1108
1234
  /** Show each tool call (default true). */
1109
1235
  showToolCalls?: boolean;
1110
1236
  /** Show each tool call's ≈tokens and duration (default true). */
@@ -1120,7 +1246,7 @@ interface StepListProps {
1120
1246
  * The live execution: each step, its thoughts, streamed text, tool calls,
1121
1247
  * consent decisions and subagent delegations.
1122
1248
  */
1123
- declare const StepList: ({ steps, subagents, approvals, showToolCalls, showUsage, showThoughts, renderToolCall, labels, className, }: StepListProps) => react.JSX.Element | null;
1249
+ declare const StepList: ({ steps, subagents, approvals, notes, showNotes, onStopSubagent, showToolCalls, showUsage, showThoughts, renderToolCall, labels, className, }: StepListProps) => react.JSX.Element | null;
1124
1250
 
1125
1251
  interface MessageListProps {
1126
1252
  messages: ChatMessage[];
@@ -1134,6 +1260,10 @@ interface MessageListProps {
1134
1260
  showUsage?: boolean;
1135
1261
  /** Thoughts (step + answer) when the model thinks (default true). */
1136
1262
  showThoughts?: boolean;
1263
+ /** What the user said while the agent worked, under the step it reached (default true). */
1264
+ showNotes?: boolean;
1265
+ /** Give a running subagent a stop button (`useAgent().stopSubagent`). */
1266
+ onStopSubagent?: (id: string) => void;
1137
1267
  /** Open the activity of finished answers too (default: only while it runs). */
1138
1268
  activityOpen?: boolean;
1139
1269
  /** Extra content under the latest assistant turn while it streams (plan thought, …). */
@@ -1165,7 +1295,7 @@ declare const AttachmentView: ({ attachment: a }: {
1165
1295
  * subagents, consent decisions — and the tokens it spent by kind. Every part
1166
1296
  * can be hidden, relabelled or rendered by the host.
1167
1297
  */
1168
- declare const MessageList: ({ messages, empty, showActivity, showToolCalls, showUsage, showThoughts, activityOpen, liveExtra, renderContent, renderMessage, renderAttachment, renderToolCall, labels, className, }: MessageListProps) => react.JSX.Element | null;
1298
+ declare const MessageList: ({ messages, empty, showActivity, showToolCalls, showUsage, showThoughts, showNotes, onStopSubagent, activityOpen, liveExtra, renderContent, renderMessage, renderAttachment, renderToolCall, labels, className, }: MessageListProps) => react.JSX.Element | null;
1169
1299
 
1170
1300
  interface ToolApprovalPromptProps {
1171
1301
  /** Pending requests (e.g. `agent.pendingApprovals`). */
@@ -1241,6 +1371,10 @@ interface AgentChatProps {
1241
1371
  showUsage?: boolean;
1242
1372
  /** Thoughts, when the model thinks (default true). */
1243
1373
  showThoughts?: boolean;
1374
+ /** What you said while the agent worked, under the step it reached (default true). */
1375
+ showNotes?: boolean;
1376
+ /** A stop button on each running subagent (default true). */
1377
+ stoppableSubagents?: boolean;
1244
1378
  /** Conversation total in the header (default true). */
1245
1379
  showTotalUsage?: boolean;
1246
1380
  /** Status dot in the header (default true). */
@@ -1407,5 +1541,5 @@ interface ApiKeyFormProps {
1407
1541
  */
1408
1542
  declare const ApiKeyForm: ({ credentials, credentialRef, label, placeholder, onChange, className, }: ApiKeyFormProps) => react.JSX.Element;
1409
1543
 
1410
- export { AgentChat, AgentComposer, AgentLabelsProvider, AgentProvider, ApiKeyForm, ApprovalModeSwitch, AttachmentView, ChatHistoryList, ChatHistoryStore, Composer, ContextMeter, FilesPanel, MessageList, ModelLoadBar, PlanView, StepList, SubagentRow, ToolApprovalPrompt, ToolCallRow, UsageBadge, agentStateReducer, attachmentKindOf, attachmentRefusal, chatTitle, createInitialAgentState, createWebLLMEngine, defaultLabels, downscaleImage, filterCommands, formatElapsed, mergeLabels, newChatId, noticesOf, parseSlash, usageLine, useAgent, useAgentContext, useChatHistory, useCredentials, useLabels, useLocalModel, useOptionalAgentContext, useSpeechToText, useVirtualFiles, useWebLLMModel, withAttachments };
1411
- export type { AgentAction, AgentChatClassNames, AgentChatComponents, AgentChatProps, AgentChatSlots, AgentComposerProps, AgentLabels, AgentLabelsOverride, AgentLabelsProviderProps, AgentProviderProps, AgentStatus, AgentUiState, ApiKeyFormProps, ApprovalModeSwitchProps, ApprovalView, ApproveOptions, BudgetView, ChatAttachment, ChatHistoryListProps, ChatHistoryStoreOptions, ChatMessage, ChatRecord, ChatSummary, CompactionView, ComposerAttachment, ComposerModelChip, ComposerNotice, ComposerProps, ComposerThinkingChip, ContextMeterProps, ConvertedFile, DownscaleOptions, FilesPanelProps, LocalModelEngine, LocalModelLoadContext, LocalModelProgress, MessageListProps, ModelLoadBarProps, ModelLoadState, NoticeTexts, PlanViewProps, RenderToolCall, ReplanState, RunGoalOptions, SlashCommand, SpeechRecognizerLike, StepListProps, StepView, SubagentView, ToolApprovalPromptProps, ToolCallRowProps, ToolCallView, UsageBadgeProps, UseAgentOptions, UseAgentReturn, UseChatHistoryOptions, UseChatHistoryReturn, UseCredentialsReturn, UseLocalModelOptions, UseLocalModelReturn, UseSpeechToTextOptions, UseSpeechToTextReturn, UseVirtualFilesReturn, UseWebLLMModelOptions, UseWebLLMModelReturn, WebLLMModelFactory };
1544
+ export { AgentChat, AgentComposer, AgentLabelsProvider, AgentProvider, ApiKeyForm, ApprovalModeSwitch, AttachmentView, ChatHistoryList, ChatHistoryStore, Composer, ContextMeter, FilesPanel, MessageList, ModelLoadBar, PlanView, StepList, SubagentRow, ToolApprovalPrompt, ToolCallRow, UsageBadge, UserNoteRow, agentStateReducer, attachmentKindOf, attachmentRefusal, chatTitle, createInitialAgentState, createWebLLMEngine, defaultLabels, downscaleImage, filterCommands, formatElapsed, mergeLabels, newChatId, noticesOf, parseSlash, steerIntent, usageLine, useAgent, useAgentContext, useChatHistory, useCredentials, useLabels, useLocalModel, useOptionalAgentContext, useSpeechToText, useVirtualFiles, useWebLLMModel, withAttachments };
1545
+ export type { AgentAction, AgentChatClassNames, AgentChatComponents, AgentChatProps, AgentChatSlots, AgentComposerProps, AgentLabels, AgentLabelsOverride, AgentLabelsProviderProps, AgentProviderProps, AgentStatus, AgentUiState, ApiKeyFormProps, ApprovalModeSwitchProps, ApprovalView, ApproveOptions, BudgetView, ChatAttachment, ChatHistoryListProps, ChatHistoryStoreOptions, ChatMessage, ChatRecord, ChatSummary, CompactionView, ComposerAttachment, ComposerModelChip, ComposerNotice, ComposerProps, ComposerThinkingChip, ContextMeterProps, ConvertedFile, DownscaleOptions, FilesPanelProps, LocalModelEngine, LocalModelLoadContext, LocalModelProgress, MessageListProps, ModelLoadBarProps, ModelLoadState, NoticeTexts, PlanViewProps, QueuedMessageView, RenderToolCall, ReplanState, RunGoalOptions, SlashCommand, SpeechRecognizerLike, SteerIntent, StepListProps, StepView, SubagentView, ToolApprovalPromptProps, ToolCallRowProps, ToolCallView, UsageBadgeProps, UseAgentOptions, UseAgentReturn, UseChatHistoryOptions, UseChatHistoryReturn, UseCredentialsReturn, UseLocalModelOptions, UseLocalModelReturn, UseSpeechToTextOptions, UseSpeechToTextReturn, UseVirtualFilesReturn, UseWebLLMModelOptions, UseWebLLMModelReturn, UserNoteView, WebLLMModelFactory };