@dudko.dev/agent-web-react 0.0.33 → 0.0.35
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/README.md +53 -3
- package/dist/{elicitation-B6h_-yLg.d.cts → elicitation-xMLll5W9.d.cts} +52 -3
- package/dist/{elicitation-B6h_-yLg.d.ts → elicitation-xMLll5W9.d.ts} +52 -3
- package/dist/index.cjs +1566 -610
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +346 -9
- package/dist/index.d.ts +346 -9
- package/dist/index.js +1490 -553
- package/dist/index.js.map +1 -1
- package/dist/mcp.d.cts +2 -2
- package/dist/mcp.d.ts +2 -2
- package/dist/styles.css +423 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -35,7 +35,7 @@ app with a single hook and (optionally) a set of pre-styled components:
|
|
|
35
35
|
- 🧩 **Building blocks** — `<AgentComposer>`, `<MessageList>`, `<StepList>`,
|
|
36
36
|
`<ToolApprovalPrompt>`, `<ElicitationPrompt>`, `<ApprovalModeSwitch>`, `<ChatHistoryList>`, `<FilesPanel>`,
|
|
37
37
|
`<LearnedSkills>`, `<ContextMeter>`, `<PlanView>`, `<ModelLoadBar>`, `<UsageBadge>`, `<ApiKeyForm>`; hooks `useChatHistory`,
|
|
38
|
-
`useVirtualFiles`, `useSpeechToText
|
|
38
|
+
`useVirtualFiles`, `useSpeechToText`, `useFollowScroll` (a transcript that follows the answer and leaves a reader where they are); MCP hooks `useMcp` / `useMcpServers` live in
|
|
39
39
|
[`@dudko.dev/agent-web-react/mcp`](#mcp-hooks-live-in-their-own-subpath).
|
|
40
40
|
- 🔑 **`useCredentials`** — store BYOK API keys **encrypted at rest**
|
|
41
41
|
(WebCrypto + IndexedDB).
|
|
@@ -200,6 +200,7 @@ function Custom() {
|
|
|
200
200
|
| `finalText` / `finalReasoning` | the streamed answer and its thoughts |
|
|
201
201
|
| `usage` / `totalUsage` | tokens of this run / of the conversation, by kind - plus `mediaCalls` and `decisionCalls` (calls, not tokens) when the run made some |
|
|
202
202
|
| `pendingApprovals`, `approve(id, { remember })`, `deny(id)` | tool consent (a request made by a helper the model started carries `subagent: { id, depth, name?, role? }`). A request the core stops waiting for - no decision within `toolApproval.timeoutMs` (default five minutes), the run stopped - is settled by the core and leaves the list; a late `approve` does nothing |
|
|
203
|
+
| `pendingQuestions`, `answerQuestion(id, answer)` | the model's questions to the person (the core's `ask_user`, with `askUser` on in the config - see [Questions from the agent](#questions-from-the-agent--ask_user)): the ones waiting in THIS tab, oldest first (`PendingQuestion`: the core's request - `id`, `question`, `options`, `multiple`, `allowOther`, `step?`, `subagent?` - plus `expiresAt`). `answerQuestion` takes `{ choice: [label] }`, `{ other: text }` or `{ declined: true }` and returns false when the question is no longer waiting. How each ended is `questions` (`QuestionView[]`; never what was typed) |
|
|
203
204
|
| `approvalMode` / `setApprovalMode(mode)` | the autopilot switch, live |
|
|
204
205
|
| `approveAppToolCall(call, signal)` / `sampleForApp(request, approve, signal)` | for MCP Apps: an app's tool call through the agent's consent gate; an app's `sampling/createMessage` answered by the agent's model (the core's `Agent.sampleForApp`: checked, rate-limited, put to `approve`, no tools, none of the chat; its tokens count in `totalUsage` only, the answer goes to the caller only) - `<AgentChat>` wires both |
|
|
205
206
|
| `compact()` | summarise the stored transcript now |
|
|
@@ -214,7 +215,9 @@ function Custom() {
|
|
|
214
215
|
|
|
215
216
|
**Options:** `deps` (rebuild the agent when these change — e.g. on a model
|
|
216
217
|
switch), `onEvent` (tap the raw event stream), `autoStart`, `maxEvents`,
|
|
217
|
-
`approvals` (route consent requests into the hook; default true), `
|
|
218
|
+
`approvals` (route consent requests into the hook; default true), `questions` (answer the
|
|
219
|
+
model's `ask_user` questions in the hook when `askUser` is on without an `onQuestion` of the
|
|
220
|
+
host's; default true), `watch` (follow the
|
|
218
221
|
conversation's run in another tab of the site - default true; needs a `memory` the tabs share,
|
|
219
222
|
`IndexedDBStore`). The queue behind `approve` /
|
|
220
223
|
`deny` is exported for a host that builds the core's agent itself: `createApprovalQueue()` gives
|
|
@@ -536,7 +539,7 @@ Two notes:
|
|
|
536
539
|
hooks is what puts it in your build.
|
|
537
540
|
- `oauthSupported` is `false` on cores older than `@dudko.dev/agent-web@0.0.9`,
|
|
538
541
|
which introduced `BrowserOAuthProvider`; header auth still works there. The
|
|
539
|
-
peer floor is `>=0.0.
|
|
542
|
+
peer floor is `>=0.0.46` — the first core with `askUser` (the model's questions: `ask_user`, `user.question-*`), after several tabs (`onStorageChange`, `watchSession`, the session lock), MCP Apps (`approveAppToolCall`,
|
|
540
543
|
`sampleForApp`), MCP skills with consent, `file.written`, elicitation and the
|
|
541
544
|
OAuth `registration` choice this package's chat and hooks use, on top of model
|
|
542
545
|
tiers, dynamic subagents, media and decision models, pipelines, the learning
|
|
@@ -725,6 +728,51 @@ A host that calls the core's `connectMcpHttp` itself can use the same queue the
|
|
|
725
728
|
> NAMES only), its events, the transcript, a saved chat or a log. The core sends it to the server
|
|
726
729
|
> that asked and nowhere else - never to the model.
|
|
727
730
|
|
|
731
|
+
## Questions from the agent — `ask_user`
|
|
732
|
+
|
|
733
|
+
With the core's `askUser` on, the **model** may ask the person ONE closed question with 2-6
|
|
734
|
+
options instead of guessing (the core's built-in `ask_user` tool; off by default - see the
|
|
735
|
+
[core's docs](https://github.com/dudko-dev/agents/blob/main/packages/agent-web/docs/capabilities.md#asking-the-user-a-question-with-choices)).
|
|
736
|
+
`useAgent` answers it when the config turns it on without a handler of its own:
|
|
737
|
+
|
|
738
|
+
```tsx
|
|
739
|
+
const agent = useAgent({ model, tools, askUser: true }) // or { timeoutMs, maxPerRun }
|
|
740
|
+
<AgentChat controller={agent} /> // the question card appears where the consent cards are
|
|
741
|
+
// or anywhere: <QuestionPrompt questions={agent.pendingQuestions}
|
|
742
|
+
// onAnswer={agent.answerQuestion} outcomes={agent.questions} />
|
|
743
|
+
```
|
|
744
|
+
|
|
745
|
+
- **Who answers.** `askUser: true` (or an object without `onQuestion`) makes the hook supply
|
|
746
|
+
`onQuestion` - its queue (`createQuestionQueue`, exported for a host that builds the agent
|
|
747
|
+
itself) - and the questions land in `pendingQuestions`. A host's own `askUser.onQuestion` wins
|
|
748
|
+
(then nothing reaches `pendingQuestions`); `askUser` off stays off, and the core mounts no tool.
|
|
749
|
+
`useAgent(config, { questions: false })` keeps the hook out of it.
|
|
750
|
+
- **`<QuestionPrompt>`** draws one question at a time, with a count: the host's own line ("The
|
|
751
|
+
agent asks you", or which helper asks), the model's question, one button per option with its
|
|
752
|
+
description under it, and **Skip**. A single choice is answered by its button; with `multiple`
|
|
753
|
+
the options are toggles and **Send** sends them; with `allowOther` an **Other…** button opens a
|
|
754
|
+
field for the person's own words. Keys 1-6 pick an option while the card has the focus (Tab
|
|
755
|
+
reaches every button, Enter presses it, Esc closes the field), the card is a `role="group"`
|
|
756
|
+
named by the question, every target is at least 40 px tall, and nothing scrolls sideways at
|
|
757
|
+
320 px. Under it: the time left ("If you do not answer, the agent decides by itself in 4:59").
|
|
758
|
+
- **Without an answer.** A question waits the core's `askUser.timeoutMs` (default five minutes;
|
|
759
|
+
the step's own limit stops meanwhile); then the core tells the model the person did not answer,
|
|
760
|
+
and the card says the agent went on without the answer, and why - as it does for a handler that
|
|
761
|
+
failed. Stop ends the wait at once (and the card goes, without a note). A run ending takes every
|
|
762
|
+
question still open down.
|
|
763
|
+
- **Several tabs.** A question is answered only in the tab that runs the agent: a tab following
|
|
764
|
+
that run shows the question without its buttons ("Answered in the other tab…"), and "It waits
|
|
765
|
+
for an answer in the other tab." above the composer.
|
|
766
|
+
|
|
767
|
+
> **Security.** The question and every option are the MODEL's text (the core cleans them of
|
|
768
|
+
> control and bidirectional characters): the card shows them as text nodes, never as markup.
|
|
769
|
+
> What the person types in Other… stays in the card's own state until Send hands it to
|
|
770
|
+
> `answerQuestion`, which passes it to the core and keeps nothing. The core gives it to the model
|
|
771
|
+
> as the tool's result; the reducer takes it out of everything it keeps (`withoutOwnWords`: an
|
|
772
|
+
> `ask_user` result that is not known to hold labels only loses its `output` in the steps, the
|
|
773
|
+
> transcript, a saved chat and the event log), and the core's `user.question-answered` event never
|
|
774
|
+
> carries it. A host tapping `onEvent` sees the core's raw `step.tool-result`, words included.
|
|
775
|
+
|
|
728
776
|
## MCP Apps — a server's interface in the chat
|
|
729
777
|
|
|
730
778
|
`apps: true` (on `useMcp` or `useMcpServers`) declares the [MCP Apps](https://github.com/modelcontextprotocol/ext-apps)
|
|
@@ -802,10 +850,12 @@ use them standalone. The full guide: [docs/chat.md](docs/chat.md).
|
|
|
802
850
|
| `<StepList>` / `<ToolCallRow>` | Execution steps / one tool call with its cost and images. With model tiers: the tier / model badge, the escalation line, the earlier attempt's calls (`showTiers`); a replanner failure as a warning (`showReplanFailed`); the decision model's note (`showDecisions`); the subagent tree under its step (`showSubagents`); a `web_search` call's results as plain text and safe links (`showSearchResults`). |
|
|
803
851
|
| `<SubagentTree>` / `<SubagentRow>` | The run's subagents - static ones and the helpers the model started - as an indented tree: status, model, tokens, time and a Stop button per node (`onStop`, `showUsage`, `showTools`, `renderSubagent`). |
|
|
804
852
|
| `<GeneratedMedia>` / `<TranscriptBlock>` | A file a media tool wrote, read from the workspace: an image inline or a native audio player (only the types the core generates; never SVG) / a folded "Transcript of …" block. `<MessageList files showMedia renderMedia>` places them in the answer. |
|
|
853
|
+
| `<ImageViewer>` / `<ImageThumb>` | A picture opened over the chat, in the page (never in a new window): fitted to the screen, previous / next within its message (arrows, swipe), zoom, Download as a file; a modal dialog with a focus trap, Esc / backdrop / close. Every picture `<MessageList>` draws is an `<ImageThumb>`; `<AgentChat imageViewer={false}>` keeps the old link in a new tab, `renderImageViewer` draws your own. See [docs/chat.md](docs/chat.md#pictures-open-in-the-page-the-image-viewer). |
|
|
805
854
|
| `<FileChips>` / `<FileChip>` | The files an answer wrote to the workspace (the core's `file.written` / `file.deleted`), as chips: name, kind, size, open, download; an inline preview (text with line numbers, a picture, your own rendering through `renderFileContent`), and an `.html` file in a sandboxed frame with Preview / Source. `<MessageList files showFileChips htmlPreview renderFile renderFileContent>` places them under the answer. |
|
|
806
855
|
| `<SandboxedFrame>` / `<SourceView>` | Untrusted HTML inside chrome the host draws: `<iframe sandbox>` without `allow-same-origin`, by `srcdoc`, no network, fixed height (`html`, `scripts`, `title`, `label`, `actions`, `footer`, `height`) / a file's text with line numbers, never markup. See [the boundary](#the-html-preview-is-a-security-boundary). |
|
|
807
856
|
| `<ToolApprovalPrompt>` | Consent cards (Allow once / Always / Deny); a helper's request says which helper asks (`showHelper`); an MCP App's says the APP asks, with the server's own tool name; an MCP server's skill gets its own card (the server, the skill, a collapsed preview of its text - `showSkillPreview` - and Allow once / Always for this server / Deny). |
|
|
808
857
|
| `<ElicitationPrompt>` | A question an MCP server puts to the user during a tool call: a form (Submit / Decline / Cancel, checked by the core's rules) or a link opened only by a click, one at a time with a count, the time left, and the questions nobody answered (`elicitations`, `onAnswer`, `outcomes`, `showOutcomes`, `showExpiry`, `showHelper`, `renderElicitation`). See [MCP elicitation](#mcp-elicitation--a-server-asks-the-user). |
|
|
858
|
+
| `<QuestionPrompt>` | A question the agent's model puts to the person (`ask_user`): its options as buttons (a description under each), toggles and Send when several may be picked, Other… for an answer in the person's own words, Skip, keys 1-6, the time left, and the questions the agent went on without; another tab's question without buttons (`questions`, `onAnswer`, `outcomes`, `showOutcomes`, `showExpiry`, `showHelper`, `showRemote`, `numberKeys`, `renderQuestion`). See [Questions from the agent](#questions-from-the-agent--ask_user). |
|
|
809
859
|
| `<McpAppFrame>` / `<McpAppLine>` | An MCP App in host-drawn chrome ("App from server “travel” · sandboxed", panel, menu: reload / open in panel / hide): an opaque-origin frame - or, with `host.sandbox` (`useMcpAppHost({ sandbox })`, `<AgentChat appSandbox>`), an origin of its own behind your sandbox page ("· sandboxed on its own origin") - network only to the origins its resource declared, a bridge with an allow-list; inline, folded, in a panel or - with `allowFullscreen`, asked for by the app after a click in it - full screen over the chat with Exit / Esc (`app`, `host`, `variant`, `theme`, `defaultCollapsed`, `onOpenPanel`, `onClosePanel`, `showCalls`, `allowFullscreen`). `<AgentChat mcpApps>` places them under the answer. See [the boundary](#an-mcp-app-is-a-security-boundary). |
|
|
810
860
|
| `<AppRequestPrompt>` | What an MCP App asks for besides a tool call: a link (its host highlighted, opened only on the user's click), a message (put in the message box as a draft, never sent for the user), a file (its sanitized name, type and size; saved by the page on Save file) or an answer of the agent's model (the app's text as text, the token cap; Allow once / Always for this app / Deny). |
|
|
811
861
|
| `<ApprovalModeSwitch>` | Segmented consent-mode switch. |
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { McpAppCsp, McpAppResource, McpAppToolResult, AppSamplingView, AppToolCallRequest, AppSamplingRequest, AppSamplingResult, AgentToolSet, IPlan, IPlanStep, ModelTier, TierReason, EscalationReason, DecisionPoint, DecisionFallbackReason, McpSkillConsentView, IUsage, ReplanMode, AgentEvent, SessionHolder } from '@dudko.dev/agent-web';
|
|
1
|
+
import { McpAppCsp, McpAppResource, McpAppToolResult, AppSamplingView, AppToolCallRequest, AppSamplingRequest, AppSamplingResult, AgentToolSet, IPlan, IPlanStep, ModelTier, TierReason, EscalationReason, DecisionPoint, DecisionFallbackReason, McpSkillConsentView, IUsage, AskUserOption, AskUserAction, ReplanMode, AgentEvent, SessionHolder } from '@dudko.dev/agent-web';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* MCP Apps, the host's side: the security core of `<McpAppFrame>`, as pure code - no React, no
|
|
@@ -1164,6 +1164,44 @@ interface ElicitationView {
|
|
|
1164
1164
|
/** The names of the fields an accepted form was answered with. */
|
|
1165
1165
|
fields?: string[];
|
|
1166
1166
|
}
|
|
1167
|
+
/**
|
|
1168
|
+
* A question the MODEL put to the person (the core's `ask_user`, `config.askUser`; its
|
|
1169
|
+
* `user.question-*` events): the question and the options are the model's text, cleaned - show
|
|
1170
|
+
* them as plain text, never as markup. The view never holds what the person typed: an answer in
|
|
1171
|
+
* their own words is `status: 'other'` and nothing more; `choice` holds labels that were offered.
|
|
1172
|
+
*/
|
|
1173
|
+
interface QuestionView {
|
|
1174
|
+
/** The question's id: the same as `AskUserRequest.id` handed to `onQuestion`. */
|
|
1175
|
+
id: string;
|
|
1176
|
+
question: string;
|
|
1177
|
+
options: AskUserOption[];
|
|
1178
|
+
/** The person may pick several options. */
|
|
1179
|
+
multiple: boolean;
|
|
1180
|
+
/** The person may answer in their own words. */
|
|
1181
|
+
allowOther: boolean;
|
|
1182
|
+
/** The step whose tool call asks (for a helper's question: the step that delegated it). */
|
|
1183
|
+
stepId?: string;
|
|
1184
|
+
/**
|
|
1185
|
+
* Set when a helper or a subagent asks, not the run itself: its id (a node of `subagents`), its
|
|
1186
|
+
* depth, and - when its `subagent.start` was seen - its name and role.
|
|
1187
|
+
*/
|
|
1188
|
+
subagent?: {
|
|
1189
|
+
id: string;
|
|
1190
|
+
depth: number;
|
|
1191
|
+
name?: string;
|
|
1192
|
+
role?: string;
|
|
1193
|
+
};
|
|
1194
|
+
/** Asked in another tab, by a run followed here (`AgentUiState.remote`): answered there only. */
|
|
1195
|
+
remote?: true;
|
|
1196
|
+
/** `pending`, then how it ended (the core's `AskUserAction`). */
|
|
1197
|
+
status: 'pending' | AskUserAction;
|
|
1198
|
+
/** Ended without anybody deciding: a time limit, a stop, a failed handler, an unusable answer. */
|
|
1199
|
+
automatic?: boolean;
|
|
1200
|
+
/** `status: 'choice'`: the labels picked. */
|
|
1201
|
+
choice?: string[];
|
|
1202
|
+
/** Why it ended `declined` automatically (the core's `AskUserReason`), or `stopped`. */
|
|
1203
|
+
reason?: string;
|
|
1204
|
+
}
|
|
1167
1205
|
/** A message sent to the agent while it works, still waiting for a boundary to be shown to the model. */
|
|
1168
1206
|
interface QueuedMessageView {
|
|
1169
1207
|
id: string;
|
|
@@ -1251,7 +1289,12 @@ interface CompactionView {
|
|
|
1251
1289
|
/** An execution step with its accumulated text and tool calls. */
|
|
1252
1290
|
interface StepView {
|
|
1253
1291
|
id: string;
|
|
1292
|
+
/** Its place in the run (1-based). */
|
|
1254
1293
|
index: number;
|
|
1294
|
+
/**
|
|
1295
|
+
* The plan's length as the run's LATEST step started: a replan that grew or cut the plan
|
|
1296
|
+
* renumbers the earlier rows too (1/2, 2/2 - not 1/1, 2/2).
|
|
1297
|
+
*/
|
|
1255
1298
|
total: number;
|
|
1256
1299
|
step: IPlanStep;
|
|
1257
1300
|
/** Streamed executor text for this step (step.text-delta). */
|
|
@@ -1338,6 +1381,12 @@ interface AgentUiState {
|
|
|
1338
1381
|
* transcript, so a saved conversation never holds a server's form.
|
|
1339
1382
|
*/
|
|
1340
1383
|
elicitations?: ElicitationView[];
|
|
1384
|
+
/**
|
|
1385
|
+
* Questions the model put to the person in this run (`ask_user`, `config.askUser`), in the
|
|
1386
|
+
* order they were asked, a helper's included; absent until the first one. Per-run view only:
|
|
1387
|
+
* they are not copied into the transcript, and none holds what the person typed.
|
|
1388
|
+
*/
|
|
1389
|
+
questions?: QuestionView[];
|
|
1341
1390
|
/** Messages sent while the run goes that have not yet been shown to the model. */
|
|
1342
1391
|
queued: QueuedMessageView[];
|
|
1343
1392
|
/** What the user said during this run and when it reached the agent. */
|
|
@@ -1592,5 +1641,5 @@ type ElicitationOutcomeReason = 'timeout' | 'step-timeout' | 'aborted' | 'stoppe
|
|
|
1592
1641
|
/** "4:05" - what is left of a question's time. */
|
|
1593
1642
|
declare const formatCountdown: (ms: number) => string;
|
|
1594
1643
|
|
|
1595
|
-
export {
|
|
1596
|
-
export type { AgentUiState as A, BudgetView as B, ChatAttachment as C, DecisionView as D, ElicitationIssueKind as E, AppResourceReader as F, ElicitationControl as G, ElicitationDraft as H, ElicitationDraftValue as I, ElicitationField as J, ElicitationFormOutcome as K, LessonView as L, McpAppSandboxReason as M, ElicitationIssue as N, ElicitationLink as O, PendingElicitation as P,
|
|
1644
|
+
export { MCP_APP_MAX_FILE_NAME_CHARS as $, MCP_APP_DISPLAY_MODES as Y, MCP_APP_MAX_ARGS_CHARS as Z, MCP_APP_MAX_DOWNLOAD_BYTES as _, MCP_APP_MAX_IN_FLIGHT as a0, MCP_APP_MAX_MESSAGE_CHARS as a1, MCP_APP_MAX_URL_CHARS as a2, MCP_APP_NOTIFICATIONS as a3, MCP_APP_OPTIONAL_REQUESTS as a4, MCP_APP_PROTOCOL_VERSION as a5, MCP_APP_REFUSED as a6, MCP_APP_REFUSED_DOWNLOAD_EXTENSIONS as a7, MCP_APP_REFUSED_DOWNLOAD_TYPES as a8, MCP_APP_RELAY as a9, appFileExtensionOf as aA, appFileNameOf as aB, appGestureOf as aC, appLinkOf as aD, appMessageTextOf as aE, appMimeTypeOf as aF, appSamplingErrorOf as aG, buildMcpAppDocument as aH, buildMcpAppSandboxShell as aI, clampAppHeight as aJ, elicitationFields as aK, elicitationFormAnswer as aL, elicitationInitialDraft as aM, elicitationLink as aN, formatCountdown as aO, grantedAppCsp as aP, mcpAppCsp as aQ, mcpAppHostCapabilities as aR, mcpAppSandboxProxyUrl as aS, mcpAppSandboxShellCsp as aT, mcpAppSandboxTarget as aU, resolveAppDownload as aV, saveAppFile as aW, useMcpAppHost as aX, MCP_APP_REQUESTS as aa, MCP_APP_SANDBOX_FRAME_TOKENS as ab, MCP_APP_SANDBOX_GRACE_MS as ac, MCP_APP_SANDBOX_SERVER as ad, MCP_APP_SANDBOX_TIMEOUT_MS as ae, McpAppBridge as af, McpAppRpcError as aj, McpAppSandboxLink as am, appDisplayModeAllowed as ax, appDownloadOf as ay, appDownloadRefusal as az, createElicitationQueue as bc, elicitationConnectOptions as bd, elicitationSettings as be, elicitationTimeoutOf as bf, APP_DEFAULT_HEIGHT as s, APP_MAX_HEIGHT as t, APP_MIN_HEIGHT as u };
|
|
1645
|
+
export type { AgentUiState as A, BudgetView as B, ChatAttachment as C, DecisionView as D, ElicitationIssueKind as E, AppResourceReader as F, ElicitationControl as G, ElicitationDraft as H, ElicitationDraftValue as I, ElicitationField as J, ElicitationFormOutcome as K, LessonView as L, McpAppSandboxReason as M, ElicitationIssue as N, ElicitationLink as O, PendingElicitation as P, QuestionView as Q, RemoteRunView as R, SubagentView as S, ToolCallView as T, UserNoteView as U, ElicitationOption as V, WrittenFileView as W, FetchView as X, ApprovalView as a, McpCatalogEntry as a$, McpOAuthRegistration as aY, McpProtocolMode as aZ, McpElicitationOptions as a_, McpAppBridgeHandlers as ag, McpAppBridgeOptions as ah, McpAppDisplayMode as ai, McpAppRpcMessage as ak, McpAppSandboxInput as al, McpAppSandboxLinkOptions as an, McpAppSandboxTarget as ao, McpElicitationFieldSchema as ap, McpElicitationRequest as aq, McpElicitationSchema as ar, QueuedMessageView as as, ReplanState as at, SkillConsentView as au, StepEscalationView as av, UseMcpAppHostOptions as aw, ChatMessage as b, McpServerProtocol as b0, McpOAuthRegistrationKind as b1, McpOAuthCallback as b2, McpServerResult as b3, McpModule as b4, ConnectedMcp as b5, BrowserOAuthProviderOptions as b6, BrowserOAuthProvider as b7, ElicitationQueue as b8, ElicitationQueueOptions as b9, McpElicitationHandler as ba, McpServerInstructions as bb, AgentStatus as c, ElicitationOutcomeReason as d, SubagentNode as e, McpElicitationResult as f, ElicitationView as g, StepView as h, MediaView as i, AppView as j, McpAppsConnectionLike as k, McpAppSandboxOptions as l, AppRequestView as m, TranscriptView as n, CompactionView as o, ModelLoadState as p, McpAppHost as q, AppRequestAnswerOptions as r, AppDownload as v, AppDownloadView as w, AppFileSaverEnv as x, AppLink as y, AppReadyDownload as z };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { McpAppCsp, McpAppResource, McpAppToolResult, AppSamplingView, AppToolCallRequest, AppSamplingRequest, AppSamplingResult, AgentToolSet, IPlan, IPlanStep, ModelTier, TierReason, EscalationReason, DecisionPoint, DecisionFallbackReason, McpSkillConsentView, IUsage, ReplanMode, AgentEvent, SessionHolder } from '@dudko.dev/agent-web';
|
|
1
|
+
import { McpAppCsp, McpAppResource, McpAppToolResult, AppSamplingView, AppToolCallRequest, AppSamplingRequest, AppSamplingResult, AgentToolSet, IPlan, IPlanStep, ModelTier, TierReason, EscalationReason, DecisionPoint, DecisionFallbackReason, McpSkillConsentView, IUsage, AskUserOption, AskUserAction, ReplanMode, AgentEvent, SessionHolder } from '@dudko.dev/agent-web';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* MCP Apps, the host's side: the security core of `<McpAppFrame>`, as pure code - no React, no
|
|
@@ -1164,6 +1164,44 @@ interface ElicitationView {
|
|
|
1164
1164
|
/** The names of the fields an accepted form was answered with. */
|
|
1165
1165
|
fields?: string[];
|
|
1166
1166
|
}
|
|
1167
|
+
/**
|
|
1168
|
+
* A question the MODEL put to the person (the core's `ask_user`, `config.askUser`; its
|
|
1169
|
+
* `user.question-*` events): the question and the options are the model's text, cleaned - show
|
|
1170
|
+
* them as plain text, never as markup. The view never holds what the person typed: an answer in
|
|
1171
|
+
* their own words is `status: 'other'` and nothing more; `choice` holds labels that were offered.
|
|
1172
|
+
*/
|
|
1173
|
+
interface QuestionView {
|
|
1174
|
+
/** The question's id: the same as `AskUserRequest.id` handed to `onQuestion`. */
|
|
1175
|
+
id: string;
|
|
1176
|
+
question: string;
|
|
1177
|
+
options: AskUserOption[];
|
|
1178
|
+
/** The person may pick several options. */
|
|
1179
|
+
multiple: boolean;
|
|
1180
|
+
/** The person may answer in their own words. */
|
|
1181
|
+
allowOther: boolean;
|
|
1182
|
+
/** The step whose tool call asks (for a helper's question: the step that delegated it). */
|
|
1183
|
+
stepId?: string;
|
|
1184
|
+
/**
|
|
1185
|
+
* Set when a helper or a subagent asks, not the run itself: its id (a node of `subagents`), its
|
|
1186
|
+
* depth, and - when its `subagent.start` was seen - its name and role.
|
|
1187
|
+
*/
|
|
1188
|
+
subagent?: {
|
|
1189
|
+
id: string;
|
|
1190
|
+
depth: number;
|
|
1191
|
+
name?: string;
|
|
1192
|
+
role?: string;
|
|
1193
|
+
};
|
|
1194
|
+
/** Asked in another tab, by a run followed here (`AgentUiState.remote`): answered there only. */
|
|
1195
|
+
remote?: true;
|
|
1196
|
+
/** `pending`, then how it ended (the core's `AskUserAction`). */
|
|
1197
|
+
status: 'pending' | AskUserAction;
|
|
1198
|
+
/** Ended without anybody deciding: a time limit, a stop, a failed handler, an unusable answer. */
|
|
1199
|
+
automatic?: boolean;
|
|
1200
|
+
/** `status: 'choice'`: the labels picked. */
|
|
1201
|
+
choice?: string[];
|
|
1202
|
+
/** Why it ended `declined` automatically (the core's `AskUserReason`), or `stopped`. */
|
|
1203
|
+
reason?: string;
|
|
1204
|
+
}
|
|
1167
1205
|
/** A message sent to the agent while it works, still waiting for a boundary to be shown to the model. */
|
|
1168
1206
|
interface QueuedMessageView {
|
|
1169
1207
|
id: string;
|
|
@@ -1251,7 +1289,12 @@ interface CompactionView {
|
|
|
1251
1289
|
/** An execution step with its accumulated text and tool calls. */
|
|
1252
1290
|
interface StepView {
|
|
1253
1291
|
id: string;
|
|
1292
|
+
/** Its place in the run (1-based). */
|
|
1254
1293
|
index: number;
|
|
1294
|
+
/**
|
|
1295
|
+
* The plan's length as the run's LATEST step started: a replan that grew or cut the plan
|
|
1296
|
+
* renumbers the earlier rows too (1/2, 2/2 - not 1/1, 2/2).
|
|
1297
|
+
*/
|
|
1255
1298
|
total: number;
|
|
1256
1299
|
step: IPlanStep;
|
|
1257
1300
|
/** Streamed executor text for this step (step.text-delta). */
|
|
@@ -1338,6 +1381,12 @@ interface AgentUiState {
|
|
|
1338
1381
|
* transcript, so a saved conversation never holds a server's form.
|
|
1339
1382
|
*/
|
|
1340
1383
|
elicitations?: ElicitationView[];
|
|
1384
|
+
/**
|
|
1385
|
+
* Questions the model put to the person in this run (`ask_user`, `config.askUser`), in the
|
|
1386
|
+
* order they were asked, a helper's included; absent until the first one. Per-run view only:
|
|
1387
|
+
* they are not copied into the transcript, and none holds what the person typed.
|
|
1388
|
+
*/
|
|
1389
|
+
questions?: QuestionView[];
|
|
1341
1390
|
/** Messages sent while the run goes that have not yet been shown to the model. */
|
|
1342
1391
|
queued: QueuedMessageView[];
|
|
1343
1392
|
/** What the user said during this run and when it reached the agent. */
|
|
@@ -1592,5 +1641,5 @@ type ElicitationOutcomeReason = 'timeout' | 'step-timeout' | 'aborted' | 'stoppe
|
|
|
1592
1641
|
/** "4:05" - what is left of a question's time. */
|
|
1593
1642
|
declare const formatCountdown: (ms: number) => string;
|
|
1594
1643
|
|
|
1595
|
-
export {
|
|
1596
|
-
export type { AgentUiState as A, BudgetView as B, ChatAttachment as C, DecisionView as D, ElicitationIssueKind as E, AppResourceReader as F, ElicitationControl as G, ElicitationDraft as H, ElicitationDraftValue as I, ElicitationField as J, ElicitationFormOutcome as K, LessonView as L, McpAppSandboxReason as M, ElicitationIssue as N, ElicitationLink as O, PendingElicitation as P,
|
|
1644
|
+
export { MCP_APP_MAX_FILE_NAME_CHARS as $, MCP_APP_DISPLAY_MODES as Y, MCP_APP_MAX_ARGS_CHARS as Z, MCP_APP_MAX_DOWNLOAD_BYTES as _, MCP_APP_MAX_IN_FLIGHT as a0, MCP_APP_MAX_MESSAGE_CHARS as a1, MCP_APP_MAX_URL_CHARS as a2, MCP_APP_NOTIFICATIONS as a3, MCP_APP_OPTIONAL_REQUESTS as a4, MCP_APP_PROTOCOL_VERSION as a5, MCP_APP_REFUSED as a6, MCP_APP_REFUSED_DOWNLOAD_EXTENSIONS as a7, MCP_APP_REFUSED_DOWNLOAD_TYPES as a8, MCP_APP_RELAY as a9, appFileExtensionOf as aA, appFileNameOf as aB, appGestureOf as aC, appLinkOf as aD, appMessageTextOf as aE, appMimeTypeOf as aF, appSamplingErrorOf as aG, buildMcpAppDocument as aH, buildMcpAppSandboxShell as aI, clampAppHeight as aJ, elicitationFields as aK, elicitationFormAnswer as aL, elicitationInitialDraft as aM, elicitationLink as aN, formatCountdown as aO, grantedAppCsp as aP, mcpAppCsp as aQ, mcpAppHostCapabilities as aR, mcpAppSandboxProxyUrl as aS, mcpAppSandboxShellCsp as aT, mcpAppSandboxTarget as aU, resolveAppDownload as aV, saveAppFile as aW, useMcpAppHost as aX, MCP_APP_REQUESTS as aa, MCP_APP_SANDBOX_FRAME_TOKENS as ab, MCP_APP_SANDBOX_GRACE_MS as ac, MCP_APP_SANDBOX_SERVER as ad, MCP_APP_SANDBOX_TIMEOUT_MS as ae, McpAppBridge as af, McpAppRpcError as aj, McpAppSandboxLink as am, appDisplayModeAllowed as ax, appDownloadOf as ay, appDownloadRefusal as az, createElicitationQueue as bc, elicitationConnectOptions as bd, elicitationSettings as be, elicitationTimeoutOf as bf, APP_DEFAULT_HEIGHT as s, APP_MAX_HEIGHT as t, APP_MIN_HEIGHT as u };
|
|
1645
|
+
export type { AgentUiState as A, BudgetView as B, ChatAttachment as C, DecisionView as D, ElicitationIssueKind as E, AppResourceReader as F, ElicitationControl as G, ElicitationDraft as H, ElicitationDraftValue as I, ElicitationField as J, ElicitationFormOutcome as K, LessonView as L, McpAppSandboxReason as M, ElicitationIssue as N, ElicitationLink as O, PendingElicitation as P, QuestionView as Q, RemoteRunView as R, SubagentView as S, ToolCallView as T, UserNoteView as U, ElicitationOption as V, WrittenFileView as W, FetchView as X, ApprovalView as a, McpCatalogEntry as a$, McpOAuthRegistration as aY, McpProtocolMode as aZ, McpElicitationOptions as a_, McpAppBridgeHandlers as ag, McpAppBridgeOptions as ah, McpAppDisplayMode as ai, McpAppRpcMessage as ak, McpAppSandboxInput as al, McpAppSandboxLinkOptions as an, McpAppSandboxTarget as ao, McpElicitationFieldSchema as ap, McpElicitationRequest as aq, McpElicitationSchema as ar, QueuedMessageView as as, ReplanState as at, SkillConsentView as au, StepEscalationView as av, UseMcpAppHostOptions as aw, ChatMessage as b, McpServerProtocol as b0, McpOAuthRegistrationKind as b1, McpOAuthCallback as b2, McpServerResult as b3, McpModule as b4, ConnectedMcp as b5, BrowserOAuthProviderOptions as b6, BrowserOAuthProvider as b7, ElicitationQueue as b8, ElicitationQueueOptions as b9, McpElicitationHandler as ba, McpServerInstructions as bb, AgentStatus as c, ElicitationOutcomeReason as d, SubagentNode as e, McpElicitationResult as f, ElicitationView as g, StepView as h, MediaView as i, AppView as j, McpAppsConnectionLike as k, McpAppSandboxOptions as l, AppRequestView as m, TranscriptView as n, CompactionView as o, ModelLoadState as p, McpAppHost as q, AppRequestAnswerOptions as r, AppDownload as v, AppDownloadView as w, AppFileSaverEnv as x, AppLink as y, AppReadyDownload as z };
|