@dudko.dev/agent-web-react 0.0.36 → 0.0.37
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 +10 -4
- package/dist/{elicitation-xMLll5W9.d.cts → elicitation-NV1_UPkJ.d.cts} +15 -1
- package/dist/{elicitation-xMLll5W9.d.ts → elicitation-NV1_UPkJ.d.ts} +15 -1
- package/dist/index.cjs +36 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +18 -2
- package/dist/index.d.ts +18 -2
- package/dist/index.js +36 -12
- package/dist/index.js.map +1 -1
- package/dist/mcp.d.cts +2 -2
- package/dist/mcp.d.ts +2 -2
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -948,7 +948,8 @@ The state is made of plain, exported view types you can render with your own com
|
|
|
948
948
|
`StepView` (a step and its `ToolCallView`s; `StepEscalationView` for its escalations), `ApprovalView`, `ElicitationView` (a question an MCP server put to the user in the middle of a tool call - `state.elicitations`, see below), `SubagentView`, `UserNoteView` /
|
|
949
949
|
`QueuedMessageView` (steering), `LessonView` / `FetchView` (the notebook and the pages fetched),
|
|
950
950
|
`BudgetView`, `CompactionView`, `AttachmentView`, `ChatMessage` (a transcript entry that keeps its
|
|
951
|
-
own steps, usage and duration
|
|
951
|
+
own steps, usage and duration; `stopped` on an answer whose run was stopped - with no text, the chat
|
|
952
|
+
shows the `answerStopped` label: the state holds no UI text). Outside `<AgentChat>`, `useAgentContext()` returns the controller of
|
|
952
953
|
the enclosing `<AgentProvider>` (it throws outside one; `useOptionalAgentContext()` returns
|
|
953
954
|
`undefined` instead), and `useLabels()` the labels in effect.
|
|
954
955
|
|
|
@@ -981,14 +982,19 @@ the hooks keep them in step, with nothing to configure beyond a shared `memory`
|
|
|
981
982
|
chat is read again from what that tab saved. `watch: false` switches this off.
|
|
982
983
|
- **One run per conversation.** A run started here while the conversation runs elsewhere waits
|
|
983
984
|
for it (`sessionBusy`, "Waiting for the other tab to finish this conversation…", the goal shown
|
|
984
|
-
queued
|
|
985
|
-
|
|
985
|
+
queued - "waiting for the other tab to finish", `queuedForSession`, its `queued` entry marked
|
|
986
|
+
`session`, while the wait lasts) and then goes, with that turn in the agent's memory; a saved chat
|
|
987
|
+
keeps both turns, in order (`saveChat`: one transaction, merged by message identity).
|
|
988
|
+
- **Another tab deletes or upgrades the database** ("delete everything", a newer copy of the site):
|
|
989
|
+
`ChatHistoryStore` closes its connection on `versionchange`, like the core's stores, so that tab is
|
|
990
|
+
not held up; the next use opens a new, empty database (after an upgrade by a newer copy, an error
|
|
991
|
+
until a reload).
|
|
986
992
|
- **What another tab changed appears here without a reload:** a key in the vault
|
|
987
993
|
(`useCredentials().version`), the files (`useVirtualFiles`), the saved chats (`useChatHistory`),
|
|
988
994
|
the agent's notebook (`learned`, through `agent.reloadLearnedSkills()`).
|
|
989
995
|
|
|
990
996
|
`<AgentChat>` shows the notes above the composer (`showOtherTabs`; labels `remoteRunning`,
|
|
991
|
-
`remoteWaitingConsent`, `remoteGone`, `sessionBusy`, `fromAnotherTab`). Details: [docs/chat.md](docs/chat.md#several-tabs).
|
|
997
|
+
`remoteWaitingConsent`, `remoteGone`, `sessionBusy`, `queuedForSession`, `fromAnotherTab`). Details: [docs/chat.md](docs/chat.md#several-tabs).
|
|
992
998
|
|
|
993
999
|
## How it fits together
|
|
994
1000
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { McpAppCsp, McpAppResource, McpAppToolResult, AppSamplingView, AppToolCallRequest, AppSamplingRequest, AppSamplingResult, AgentToolSet, IPlan, IPlanStep, ModelTier, TierReason, EscalationReason, DecisionPoint, DecisionFallbackReason, McpSkillConsentView, IUsage, AskUserOption, AskUserAction, ReplanMode, AgentEvent
|
|
1
|
+
import { McpAppCsp, McpAppResource, McpAppToolResult, AppSamplingView, AppToolCallRequest, AppSamplingRequest, AppSamplingResult, AgentToolSet, IPlan, IPlanStep, ModelTier, TierReason, EscalationReason, DecisionPoint, DecisionFallbackReason, McpSkillConsentView, IUsage, AskUserOption, AskUserAction, SessionHolder, ReplanMode, AgentEvent } 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
|
|
@@ -918,6 +918,13 @@ interface ChatMessage {
|
|
|
918
918
|
apps?: AppView[];
|
|
919
919
|
/** Assistant turn ended with an error. */
|
|
920
920
|
error?: boolean;
|
|
921
|
+
/**
|
|
922
|
+
* Assistant turn: the run was stopped (by the user, here or in another tab) before it was done.
|
|
923
|
+
* `content` is what it had written by then - `''` when nothing: the chat shows the
|
|
924
|
+
* `answerStopped` label in its place (the reducer keeps no UI text). A chat saved before this
|
|
925
|
+
* existed has the old `'Stopped.'` as its content, and shows that.
|
|
926
|
+
*/
|
|
927
|
+
stopped?: true;
|
|
921
928
|
}
|
|
922
929
|
/** A single tool call as it appears in a step, streamed then finalized. */
|
|
923
930
|
interface ToolCallView {
|
|
@@ -1208,6 +1215,13 @@ interface QueuedMessageView {
|
|
|
1208
1215
|
text: string;
|
|
1209
1216
|
/** Another tab of the site sent it to this run (the core's session relay). */
|
|
1210
1217
|
origin?: 'another-tab';
|
|
1218
|
+
/**
|
|
1219
|
+
* What the user sent waits with a run of this tab's that waits for the SESSION (`sessionBusy`):
|
|
1220
|
+
* the other run of the conversation holds it - in another tab, or in this one. The entry is
|
|
1221
|
+
* there only while that wait lasts (the run then starts with it); the chat shows
|
|
1222
|
+
* `queuedForSession` for it, not `queuedWaiting`.
|
|
1223
|
+
*/
|
|
1224
|
+
session?: SessionHolder;
|
|
1211
1225
|
}
|
|
1212
1226
|
/**
|
|
1213
1227
|
* A message the user sent while the run was going, after it reached the agent.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { McpAppCsp, McpAppResource, McpAppToolResult, AppSamplingView, AppToolCallRequest, AppSamplingRequest, AppSamplingResult, AgentToolSet, IPlan, IPlanStep, ModelTier, TierReason, EscalationReason, DecisionPoint, DecisionFallbackReason, McpSkillConsentView, IUsage, AskUserOption, AskUserAction, ReplanMode, AgentEvent
|
|
1
|
+
import { McpAppCsp, McpAppResource, McpAppToolResult, AppSamplingView, AppToolCallRequest, AppSamplingRequest, AppSamplingResult, AgentToolSet, IPlan, IPlanStep, ModelTier, TierReason, EscalationReason, DecisionPoint, DecisionFallbackReason, McpSkillConsentView, IUsage, AskUserOption, AskUserAction, SessionHolder, ReplanMode, AgentEvent } 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
|
|
@@ -918,6 +918,13 @@ interface ChatMessage {
|
|
|
918
918
|
apps?: AppView[];
|
|
919
919
|
/** Assistant turn ended with an error. */
|
|
920
920
|
error?: boolean;
|
|
921
|
+
/**
|
|
922
|
+
* Assistant turn: the run was stopped (by the user, here or in another tab) before it was done.
|
|
923
|
+
* `content` is what it had written by then - `''` when nothing: the chat shows the
|
|
924
|
+
* `answerStopped` label in its place (the reducer keeps no UI text). A chat saved before this
|
|
925
|
+
* existed has the old `'Stopped.'` as its content, and shows that.
|
|
926
|
+
*/
|
|
927
|
+
stopped?: true;
|
|
921
928
|
}
|
|
922
929
|
/** A single tool call as it appears in a step, streamed then finalized. */
|
|
923
930
|
interface ToolCallView {
|
|
@@ -1208,6 +1215,13 @@ interface QueuedMessageView {
|
|
|
1208
1215
|
text: string;
|
|
1209
1216
|
/** Another tab of the site sent it to this run (the core's session relay). */
|
|
1210
1217
|
origin?: 'another-tab';
|
|
1218
|
+
/**
|
|
1219
|
+
* What the user sent waits with a run of this tab's that waits for the SESSION (`sessionBusy`):
|
|
1220
|
+
* the other run of the conversation holds it - in another tab, or in this one. The entry is
|
|
1221
|
+
* there only while that wait lasts (the run then starts with it); the chat shows
|
|
1222
|
+
* `queuedForSession` for it, not `queuedWaiting`.
|
|
1223
|
+
*/
|
|
1224
|
+
session?: SessionHolder;
|
|
1211
1225
|
}
|
|
1212
1226
|
/**
|
|
1213
1227
|
* A message the user sent while the run was going, after it reached the agent.
|
package/dist/index.cjs
CHANGED
|
@@ -1396,7 +1396,7 @@ var applyEvent = (state, event, ctx) => {
|
|
|
1396
1396
|
...ctx.goal ? {
|
|
1397
1397
|
queued: [
|
|
1398
1398
|
...state.queued.filter((q) => q.id !== WAITING_ID),
|
|
1399
|
-
{ id: WAITING_ID, text: ctx.goal }
|
|
1399
|
+
{ id: WAITING_ID, text: ctx.goal, session: event.heldBy }
|
|
1400
1400
|
]
|
|
1401
1401
|
} : {}
|
|
1402
1402
|
};
|
|
@@ -1424,11 +1424,11 @@ var applyEvent = (state, event, ctx) => {
|
|
|
1424
1424
|
(q) => q.status === "pending" ? { ...q, status: "stopped", automatic: true, reason: "stopped" } : q
|
|
1425
1425
|
)
|
|
1426
1426
|
} : {},
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
state
|
|
1430
|
-
|
|
1431
|
-
)
|
|
1427
|
+
// What it had written, or nothing - the chat says "stopped" through its labels.
|
|
1428
|
+
messages: finalizeAssistant(state.messages, state.finalText, {
|
|
1429
|
+
...runDuration(state, ctx.at),
|
|
1430
|
+
stopped: true
|
|
1431
|
+
})
|
|
1432
1432
|
};
|
|
1433
1433
|
case "error":
|
|
1434
1434
|
if (event.phase === "replan") {
|
|
@@ -2044,21 +2044,43 @@ var ChatHistoryStore = class {
|
|
|
2044
2044
|
if (opts.memory || typeof indexedDB === "undefined") this.memory = /* @__PURE__ */ new Map();
|
|
2045
2045
|
this.dbName = this.memory ? void 0 : this.name;
|
|
2046
2046
|
}
|
|
2047
|
+
/**
|
|
2048
|
+
* The store's connection, opened on first use. Never in another tab's way: when another
|
|
2049
|
+
* connection asks to delete or upgrade the database (`versionchange` - another tab's
|
|
2050
|
+
* `indexedDB.deleteDatabase`, a newer copy of this package), it is closed at once, so that
|
|
2051
|
+
* request goes ahead instead of waiting for this tab to close; one the browser closed by itself
|
|
2052
|
+
* (site data cleared) is let go too. The next use opens the database again - after a deletion a
|
|
2053
|
+
* new, empty one (no chats: `list()` is empty, a save starts it again); after an upgrade by a
|
|
2054
|
+
* newer copy, the open fails until the page is reloaded with that copy.
|
|
2055
|
+
*/
|
|
2047
2056
|
open() {
|
|
2048
|
-
this.db
|
|
2057
|
+
if (this.db) return this.db;
|
|
2058
|
+
const opening = new Promise((resolve, reject) => {
|
|
2049
2059
|
const r = indexedDB.open(this.name, DB_VERSION);
|
|
2050
2060
|
r.onupgradeneeded = () => {
|
|
2051
2061
|
if (!r.result.objectStoreNames.contains(this.storeName)) {
|
|
2052
2062
|
r.result.createObjectStore(this.storeName, { keyPath: "id" });
|
|
2053
2063
|
}
|
|
2054
2064
|
};
|
|
2055
|
-
r.onsuccess = () =>
|
|
2065
|
+
r.onsuccess = () => {
|
|
2066
|
+
const db = r.result;
|
|
2067
|
+
const forget = () => {
|
|
2068
|
+
if (this.db === opening) this.db = void 0;
|
|
2069
|
+
};
|
|
2070
|
+
db.addEventListener("versionchange", () => {
|
|
2071
|
+
forget();
|
|
2072
|
+
db.close();
|
|
2073
|
+
});
|
|
2074
|
+
db.addEventListener("close", forget);
|
|
2075
|
+
resolve(db);
|
|
2076
|
+
};
|
|
2056
2077
|
r.onerror = () => reject(r.error);
|
|
2057
2078
|
}).catch((err) => {
|
|
2058
|
-
this.db = void 0;
|
|
2079
|
+
if (this.db === opening) this.db = void 0;
|
|
2059
2080
|
throw err;
|
|
2060
2081
|
});
|
|
2061
|
-
|
|
2082
|
+
this.db = opening;
|
|
2083
|
+
return opening;
|
|
2062
2084
|
}
|
|
2063
2085
|
async tx(mode) {
|
|
2064
2086
|
const db = await this.open();
|
|
@@ -2796,6 +2818,7 @@ var defaultLabels = {
|
|
|
2796
2818
|
fetches: (n) => plural(n, "web request", "web requests"),
|
|
2797
2819
|
fetchRefused: (reason) => `refused: ${reason}`,
|
|
2798
2820
|
answerThoughts: "Thinking about the answer",
|
|
2821
|
+
answerStopped: "Stopped.",
|
|
2799
2822
|
stepThoughts: "Thoughts",
|
|
2800
2823
|
usageTitle: "Tokens this answer spent, by kind",
|
|
2801
2824
|
attachments: "Attachments",
|
|
@@ -2886,6 +2909,7 @@ var defaultLabels = {
|
|
|
2886
2909
|
steer: "Send to the agent",
|
|
2887
2910
|
noAttachmentsWhileBusy: "Files can\u2019t be added while the agent is working \u2014 send them with your next message.",
|
|
2888
2911
|
queuedWaiting: "waiting for the agent\u2019s next step",
|
|
2912
|
+
queuedForSession: (heldBy) => heldBy === "this-tab" ? "waiting for the other run to finish" : "waiting for the other tab to finish",
|
|
2889
2913
|
noteAt: {
|
|
2890
2914
|
round: "you said, between tool calls",
|
|
2891
2915
|
step: "you said, after this step",
|
|
@@ -6068,7 +6092,7 @@ ${draftText}` : draftText);
|
|
|
6068
6092
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ClockIcon, { size: 13, className: "awr-queued__icon" }),
|
|
6069
6093
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "awr-queued__text", title: q.text, children: q.text }),
|
|
6070
6094
|
q.origin === "another-tab" && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "awr-queued__origin", children: L.fromAnotherTab }),
|
|
6071
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "awr-queued__state", children: L.queuedWaiting })
|
|
6095
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "awr-queued__state", children: q.session ? L.queuedForSession(q.session) : L.queuedWaiting })
|
|
6072
6096
|
] }, q.id)),
|
|
6073
6097
|
agent.undelivered.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "awr-queued__item awr-queued__item--undelivered", role: "status", children: [
|
|
6074
6098
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(AlertIcon, { size: 13, className: "awr-queued__icon" }),
|
|
@@ -8423,7 +8447,7 @@ var MessageList = ({
|
|
|
8423
8447
|
showApps && renderApp && m.role === "assistant" && m.apps?.length ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "awr-msg__apps", children: m.apps.map((app) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "awr-msg__app", children: renderApp(app, m) }, app.id)) }) : null,
|
|
8424
8448
|
showMedia && m.transcripts?.length ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "awr-msg__transcripts", children: m.transcripts.map((t, i) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(TranscriptBlock, { transcript: t, labels }, i)) }) : null,
|
|
8425
8449
|
(m.content || m.pending || !m.attachments?.length) && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "awr-msg__bubble", children: [
|
|
8426
|
-
m.content ? renderContent ? renderContent(m) : m.content : null,
|
|
8450
|
+
m.content ? renderContent ? renderContent(m) : m.content : m.stopped && !m.pending ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "awr-msg__stopped", children: L.answerStopped }) : null,
|
|
8427
8451
|
m.pending && !m.content && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(SpinnerIcon, { size: 14, className: "awr-msg__pending" })
|
|
8428
8452
|
] }),
|
|
8429
8453
|
showMedia && m.media?.length ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "awr-msg__media", children: m.media.map((item, i) => {
|