@dudko.dev/agent-web-ui 0.0.4 → 0.0.6
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 +52 -7
- package/dist/{chunk-G7LQTOA2.js → chunk-NHU6WQM5.js} +61 -6
- package/dist/controller.cjs +80 -16
- package/dist/controller.d.cts +15 -3
- package/dist/controller.d.ts +15 -3
- package/dist/controller.js +41 -16
- package/dist/index.cjs +80 -14
- package/dist/index.d.cts +28 -10
- package/dist/index.d.ts +28 -10
- package/dist/index.js +26 -8
- package/dist/{labels-BJMtk5Fw.d.ts → labels-CCPL7t17.d.ts} +6 -1
- package/dist/{labels-B_y8F1GW.d.cts → labels-ipy-ydkp.d.cts} +6 -1
- package/dist/mcp-app.cjs +1 -4
- package/dist/mcp-app.js +1 -2
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -63,20 +63,21 @@ on them.
|
|
|
63
63
|
npm i @dudko.dev/agent-web-ui @dudko.dev/agent-web
|
|
64
64
|
```
|
|
65
65
|
|
|
66
|
-
`@dudko.dev/agent-web` is a peer dependency (one core per page; the type imports
|
|
67
|
-
|
|
66
|
+
`@dudko.dev/agent-web` is a peer dependency (one core per page; the type imports come from it, and
|
|
67
|
+
the core itself is imported only when something needs it - see [The core, loaded when needed](#the-core-loaded-when-needed)).
|
|
68
|
+
There is no other dependency. A React app does
|
|
68
69
|
not install this package itself: `@dudko.dev/agent-web-react` depends on it.
|
|
69
70
|
|
|
70
71
|
## Entries
|
|
71
72
|
|
|
72
73
|
| Import | What | Imports |
|
|
73
74
|
| --- | --- | --- |
|
|
74
|
-
| `@dudko.dev/agent-web-ui` | the reducer and its types, the labels, the pure helpers, voice, saved chats, the sandboxed frame | the core |
|
|
75
|
-
| `@dudko.dev/agent-web-ui/mcp-app` | MCP Apps on the page's side: the frame's policy and shell, the bridge, the link to a sandbox page, an app's requests |
|
|
75
|
+
| `@dudko.dev/agent-web-ui` | the reducer and its types, the labels, the pure helpers, voice, saved chats, the sandboxed frame | the core, dynamically (saved chats, other tabs) |
|
|
76
|
+
| `@dudko.dev/agent-web-ui/mcp-app` | MCP Apps on the page's side: the frame's policy and shell, the bridge, the link to a sandbox page, an app's requests | nothing |
|
|
76
77
|
| `@dudko.dev/agent-web-ui/mcp-app-sandbox` | the MCP Apps sandbox page for a SERVER (a Worker, Node, Deno, Bun): the page, its headers, a `Request` → `Response` handler | nothing |
|
|
77
78
|
| `@dudko.dev/agent-web-ui/pipeline` | the pipeline editor's logic: the reducer of a pipeline run, the editing helpers, the code generator, the editor's strings | the core |
|
|
78
79
|
| `@dudko.dev/agent-web-ui/canvas` | the generic canvas's maths (viewport, curves, hit tests, layout order) and its strings | nothing |
|
|
79
|
-
| `@dudko.dev/agent-web-ui/controller` | the agent as a store any front end wraps: `createAgentController`, and `createRemoteAgentController` for an agent on a server (see [Controller](#controller)) | the core
|
|
80
|
+
| `@dudko.dev/agent-web-ui/controller` | the agent as a store any front end wraps: `createAgentController`, and `createRemoteAgentController` for an agent on a server (see [Controller](#controller)) | the core, dynamically, when an agent is built in the page |
|
|
80
81
|
| `@dudko.dev/agent-web-ui/markdown` | the answers' Markdown as a tree any front end draws: the parser, the parser of an answer still being written, `safeHref`, the link allowlist, the renderer's helpers (see [Markdown](#markdown)) | nothing |
|
|
81
82
|
| `@dudko.dev/agent-web-ui/locales` | the chat's labels in your language, loaded on demand: `loadAgentLabels(tag)`, the list of tags, `labelsFromCatalog` | nothing |
|
|
82
83
|
| `@dudko.dev/agent-web-ui/locales/<tag>` | one language's labels (`labels`) and its catalog (`catalog`) | nothing |
|
|
@@ -96,6 +97,24 @@ Every entry is ESM and CommonJS with types. The main entry never mentions the co
|
|
|
96
97
|
chunk it loads - so a host that uses none of them carries none of them (`tests/entries.test.ts`
|
|
97
98
|
reads the built files).
|
|
98
99
|
|
|
100
|
+
### The core, loaded when needed
|
|
101
|
+
|
|
102
|
+
No entry but `./pipeline` imports the core statically. A bundler that keeps one export of the core
|
|
103
|
+
keeps all of its top-level code - the AI SDK, zod, the providers -, so the few values the chat
|
|
104
|
+
needs of it (which media types are pictures, which text, the mark of a replayed write, the check of
|
|
105
|
+
an MCP App's origins; `fileKindOf` and `mediaFamilyOf` answer with them) are copies here, held to
|
|
106
|
+
the core's own by the tests. The rest goes through
|
|
107
|
+
`loadAgentCore()` - a dynamic `import('@dudko.dev/agent-web')`, the same module every time: the
|
|
108
|
+
controller when it builds an agent (`createAgent`, the run's control, another tab's run), the
|
|
109
|
+
chat history when it announces a write, `followOtherTabs` / `listenToOtherTabs` when there is a
|
|
110
|
+
database to follow (pass `loadAgentCore` instead of the core's module: the follow starts once it
|
|
111
|
+
resolves). `agentCoreIfLoaded()` answers without importing; `AgentCoreModule` is the module's type.
|
|
112
|
+
|
|
113
|
+
So a chat whose agent is on a server (`createRemoteAgentController`, the element's `backend`)
|
|
114
|
+
never loads the core: the support chat of agent.dudko.dev went from 1.35 MB (399 KB gzip) to
|
|
115
|
+
0.62 MB (182 KB gzip) on its first open - React and the chat. A page that builds an agent imports
|
|
116
|
+
the core itself anyway (its model, its stores); your bundler puts the core in a chunk of its own.
|
|
117
|
+
|
|
99
118
|
## The reducer is the seam
|
|
100
119
|
|
|
101
120
|
Everything a chat shows is a function of the events the agent emitted. Keep a state, fold every
|
|
@@ -209,6 +228,20 @@ const chat = createRemoteAgentController({
|
|
|
209
228
|
})
|
|
210
229
|
```
|
|
211
230
|
|
|
231
|
+
The options (`RemoteAgentOptions`):
|
|
232
|
+
|
|
233
|
+
| Option | What |
|
|
234
|
+
| --- | --- |
|
|
235
|
+
| `baseUrl` | The gateway's base URL (required) |
|
|
236
|
+
| `sessionId` | A session to continue (below) |
|
|
237
|
+
| `headers` | Headers for every request: an object, or a function called before each one, async allowed (`RemoteAgentHeaders`) - a visitor token, a captcha token while there is no session yet |
|
|
238
|
+
| `credentials` | `fetch`'s `credentials` (default `'same-origin'`; `'include'` sends a cookie cross-site - the gateway's anonymous visitor cookie) |
|
|
239
|
+
| `fetch` | The `fetch` to use (default the global one) |
|
|
240
|
+
| `onSessionId` | Told every change of the session (started, forgotten, `reset()`) |
|
|
241
|
+
| `onEvent` | Every event folded, the swarm's `turn.started` / `turn.ended` markers as they came (a `tool.approval-resolved` that only says the turn parked is not told) |
|
|
242
|
+
| `maxEvents` | The raw event log kept in the snapshot (default 200; 0 = unbounded) |
|
|
243
|
+
| `reconnect` | `{ minMs, maxMs }`: the stream's reconnect backoff (default 1 s, doubled up to 30 s) |
|
|
244
|
+
|
|
212
245
|
- `run(text)` - the first message `POST /sessions`, the next ones `POST /sessions/:id/messages`
|
|
213
246
|
(each with an id: a retried POST is harmless); shown at once, its turn takes its place. Resolves
|
|
214
247
|
with the turn's result, `undefined` when it failed (the error said, the words back in
|
|
@@ -232,8 +265,20 @@ const chat = createRemoteAgentController({
|
|
|
232
265
|
`approveAppToolCall` / `sampleForApp` (throw), `setApprovalMode`, `stopRemote`, `update` (do
|
|
233
266
|
nothing). `reset()` forgets the session; `loadChat({ sessionId })` opens another; `reload()` opens
|
|
234
267
|
the stream again now. `dispose()` closes the stream and clears the reconnect timer.
|
|
235
|
-
- `
|
|
236
|
-
|
|
268
|
+
- `onEvent(event, { live, id })` - every event as the reducer took it. `live` is true only for a
|
|
269
|
+
turn that a message sent through THIS controller started, as it happens: never for the replay of
|
|
270
|
+
a session's log (a reload, `loadChat`, a `sessionId` given) nor for a turn another tab or client
|
|
271
|
+
started on the same session - so a host can act on what its own message caused (open a page the
|
|
272
|
+
agent named, say) without acting again on every reload. `id` is the event's cursor on the
|
|
273
|
+
stream (`<turn>:<attempt>:<seq>`); the controller's own events (a request that failed) are live,
|
|
274
|
+
without an id.
|
|
275
|
+
- `createInitialRemoteSnapshot({ sessionId })` is its snapshot before one exists. `createSseParser`
|
|
276
|
+
(SSE text, fed chunk by chunk, to `RemoteFrame`s - `id`, `data` - and `retry:`), `parseRemoteCursor`
|
|
277
|
+
(`<turn>:<attempt>:<seq>`), `remoteEventScope` and `remoteEventOf` (a Node core event to the
|
|
278
|
+
shape the reducer folds) are its pure parts.
|
|
279
|
+
- **Nothing of the core is loaded** for it: the `./controller` entry takes the core only through
|
|
280
|
+
`loadAgentCore()`, which this controller never calls - see
|
|
281
|
+
[The core, loaded when needed](#the-core-loaded-when-needed).
|
|
237
282
|
|
|
238
283
|
The React package's `useRemoteAgent` / `<RemoteAgentProvider>` and the element's `backend`
|
|
239
284
|
attribute are this controller.
|
|
@@ -119,10 +119,27 @@ var withoutOwnWords = (event) => {
|
|
|
119
119
|
}
|
|
120
120
|
};
|
|
121
121
|
|
|
122
|
+
// src/core-copies.ts
|
|
123
|
+
var REPLAY_NOTE_OF_CORE = "[not run again: this exact call already succeeded in an earlier attempt at this step, and its effect is in place. Its result then:]";
|
|
124
|
+
var isReplayedOutput = (output) => typeof output === "string" && output.startsWith(REPLAY_NOTE_OF_CORE);
|
|
125
|
+
var MEDIA_IMAGE_TYPES_OF_CORE = {
|
|
126
|
+
"image/png": "png",
|
|
127
|
+
"image/jpeg": "jpg",
|
|
128
|
+
"image/gif": "gif",
|
|
129
|
+
"image/webp": "webp"
|
|
130
|
+
};
|
|
131
|
+
var MEDIA_AUDIO_TYPES_OF_CORE = {
|
|
132
|
+
"audio/mpeg": "mp3",
|
|
133
|
+
"audio/wav": "wav",
|
|
134
|
+
"audio/ogg": "ogg",
|
|
135
|
+
"audio/flac": "flac",
|
|
136
|
+
"audio/aac": "aac",
|
|
137
|
+
"audio/mp4": "m4a",
|
|
138
|
+
"audio/webm": "webm"
|
|
139
|
+
};
|
|
140
|
+
var isTextMimeOfCore = (mime) => /^text\/|json|xml|yaml|javascript|typescript|svg/.test(mime);
|
|
141
|
+
|
|
122
142
|
// src/state.ts
|
|
123
|
-
import {
|
|
124
|
-
isReplayedToolOutput
|
|
125
|
-
} from "@dudko.dev/agent-web";
|
|
126
143
|
var approxTokens = (value) => {
|
|
127
144
|
if (value === void 0) return 0;
|
|
128
145
|
let text;
|
|
@@ -858,7 +875,7 @@ var applyEvent = (state, event, ctx) => {
|
|
|
858
875
|
ok: event.ok,
|
|
859
876
|
status: "done",
|
|
860
877
|
outputTokens: approxTokens(event.output),
|
|
861
|
-
...
|
|
878
|
+
...isReplayedOutput(event.output) ? { replayed: true } : {},
|
|
862
879
|
...ctx.at !== void 0 && c.startedAt !== void 0 ? { durationMs: Math.max(0, ctx.at - c.startedAt) } : {}
|
|
863
880
|
};
|
|
864
881
|
}
|
|
@@ -905,7 +922,7 @@ var applyEvent = (state, event, ctx) => {
|
|
|
905
922
|
...streamed?.durationMs !== void 0 ? { durationMs: streamed.durationMs } : {},
|
|
906
923
|
// With tiers the list holds every attempt's calls, in the order they were made.
|
|
907
924
|
...streamed?.attempt !== void 0 ? { attempt: streamed.attempt } : {},
|
|
908
|
-
...
|
|
925
|
+
...isReplayedOutput(c.output) ? { replayed: true } : {},
|
|
909
926
|
// The MCP App the call came with (only the stream told it).
|
|
910
927
|
...streamed?.app !== void 0 ? { app: streamed.app } : {}
|
|
911
928
|
};
|
|
@@ -1383,6 +1400,21 @@ var createApprovalQueue = () => {
|
|
|
1383
1400
|
};
|
|
1384
1401
|
};
|
|
1385
1402
|
|
|
1403
|
+
// src/core-later.ts
|
|
1404
|
+
var loading;
|
|
1405
|
+
var loaded;
|
|
1406
|
+
var loadAgentCore = () => {
|
|
1407
|
+
if (!loading) {
|
|
1408
|
+
const next = import("@dudko.dev/agent-web").then((core) => loaded = core);
|
|
1409
|
+
loading = next;
|
|
1410
|
+
next.catch(() => {
|
|
1411
|
+
if (loading === next) loading = void 0;
|
|
1412
|
+
});
|
|
1413
|
+
}
|
|
1414
|
+
return loading;
|
|
1415
|
+
};
|
|
1416
|
+
var agentCoreIfLoaded = () => loaded;
|
|
1417
|
+
|
|
1386
1418
|
// src/util.ts
|
|
1387
1419
|
var errMessage = (err) => err instanceof Error ? err.message : String(err);
|
|
1388
1420
|
var coalesce = (fn, ms = 100) => {
|
|
@@ -1401,7 +1433,25 @@ var coalesce = (fn, ms = 100) => {
|
|
|
1401
1433
|
}
|
|
1402
1434
|
};
|
|
1403
1435
|
};
|
|
1404
|
-
var listenToOtherTabs = (core, dbName, listener) =>
|
|
1436
|
+
var listenToOtherTabs = (core, dbName, listener) => {
|
|
1437
|
+
if (!dbName) return () => void 0;
|
|
1438
|
+
if (typeof core === "function") {
|
|
1439
|
+
let closed = false;
|
|
1440
|
+
let off;
|
|
1441
|
+
core().then(
|
|
1442
|
+
(module) => {
|
|
1443
|
+
if (!closed) off = listenToOtherTabs(module, dbName, listener);
|
|
1444
|
+
},
|
|
1445
|
+
() => {
|
|
1446
|
+
}
|
|
1447
|
+
);
|
|
1448
|
+
return () => {
|
|
1449
|
+
closed = true;
|
|
1450
|
+
off?.();
|
|
1451
|
+
};
|
|
1452
|
+
}
|
|
1453
|
+
return typeof core.onStorageChange === "function" ? core.onStorageChange(dbName, listener) : () => void 0;
|
|
1454
|
+
};
|
|
1405
1455
|
var followOtherTabs = (core, dbName, accept, settle, ms = 100) => {
|
|
1406
1456
|
const later = coalesce(settle, ms);
|
|
1407
1457
|
const off = listenToOtherTabs(core, dbName, (change) => {
|
|
@@ -1415,6 +1465,9 @@ var followOtherTabs = (core, dbName, accept, settle, ms = 100) => {
|
|
|
1415
1465
|
var remoteAnswerOf = (ok, stillWatching) => ok ? "taken" : stillWatching ? "refused" : "unknown";
|
|
1416
1466
|
|
|
1417
1467
|
export {
|
|
1468
|
+
MEDIA_IMAGE_TYPES_OF_CORE,
|
|
1469
|
+
MEDIA_AUDIO_TYPES_OF_CORE,
|
|
1470
|
+
isTextMimeOfCore,
|
|
1418
1471
|
ASK_USER_TOOL_NAME,
|
|
1419
1472
|
QUESTION_TIMEOUT_MS,
|
|
1420
1473
|
questionTimeoutOf,
|
|
@@ -1431,6 +1484,8 @@ export {
|
|
|
1431
1484
|
agentStatusOf,
|
|
1432
1485
|
agentStateReducer,
|
|
1433
1486
|
createApprovalQueue,
|
|
1487
|
+
loadAgentCore,
|
|
1488
|
+
agentCoreIfLoaded,
|
|
1434
1489
|
errMessage,
|
|
1435
1490
|
coalesce,
|
|
1436
1491
|
listenToOtherTabs,
|
package/dist/controller.cjs
CHANGED
|
@@ -40,8 +40,6 @@ __export(controller_exports, {
|
|
|
40
40
|
remoteEventScope: () => remoteEventScope
|
|
41
41
|
});
|
|
42
42
|
module.exports = __toCommonJS(controller_exports);
|
|
43
|
-
var core = __toESM(require("@dudko.dev/agent-web"), 1);
|
|
44
|
-
var import_agent_web2 = require("@dudko.dev/agent-web");
|
|
45
43
|
|
|
46
44
|
// src/approval-queue.ts
|
|
47
45
|
var createApprovalQueue = () => {
|
|
@@ -196,8 +194,11 @@ var withoutOwnWords = (event) => {
|
|
|
196
194
|
}
|
|
197
195
|
};
|
|
198
196
|
|
|
197
|
+
// src/core-copies.ts
|
|
198
|
+
var REPLAY_NOTE_OF_CORE = "[not run again: this exact call already succeeded in an earlier attempt at this step, and its effect is in place. Its result then:]";
|
|
199
|
+
var isReplayedOutput = (output) => typeof output === "string" && output.startsWith(REPLAY_NOTE_OF_CORE);
|
|
200
|
+
|
|
199
201
|
// src/state.ts
|
|
200
|
-
var import_agent_web = require("@dudko.dev/agent-web");
|
|
201
202
|
var approxTokens = (value) => {
|
|
202
203
|
if (value === void 0) return 0;
|
|
203
204
|
let text;
|
|
@@ -914,7 +915,7 @@ var applyEvent = (state, event, ctx) => {
|
|
|
914
915
|
ok: event.ok,
|
|
915
916
|
status: "done",
|
|
916
917
|
outputTokens: approxTokens(event.output),
|
|
917
|
-
...(
|
|
918
|
+
...isReplayedOutput(event.output) ? { replayed: true } : {},
|
|
918
919
|
...ctx.at !== void 0 && c.startedAt !== void 0 ? { durationMs: Math.max(0, ctx.at - c.startedAt) } : {}
|
|
919
920
|
};
|
|
920
921
|
}
|
|
@@ -961,7 +962,7 @@ var applyEvent = (state, event, ctx) => {
|
|
|
961
962
|
...streamed?.durationMs !== void 0 ? { durationMs: streamed.durationMs } : {},
|
|
962
963
|
// With tiers the list holds every attempt's calls, in the order they were made.
|
|
963
964
|
...streamed?.attempt !== void 0 ? { attempt: streamed.attempt } : {},
|
|
964
|
-
...(
|
|
965
|
+
...isReplayedOutput(c.output) ? { replayed: true } : {},
|
|
965
966
|
// The MCP App the call came with (only the stream told it).
|
|
966
967
|
...streamed?.app !== void 0 ? { app: streamed.app } : {}
|
|
967
968
|
};
|
|
@@ -1401,6 +1402,21 @@ var agentStateReducer = (state, action) => {
|
|
|
1401
1402
|
}
|
|
1402
1403
|
};
|
|
1403
1404
|
|
|
1405
|
+
// src/core-later.ts
|
|
1406
|
+
var loading;
|
|
1407
|
+
var loaded;
|
|
1408
|
+
var loadAgentCore = () => {
|
|
1409
|
+
if (!loading) {
|
|
1410
|
+
const next = import("@dudko.dev/agent-web").then((core) => loaded = core);
|
|
1411
|
+
loading = next;
|
|
1412
|
+
next.catch(() => {
|
|
1413
|
+
if (loading === next) loading = void 0;
|
|
1414
|
+
});
|
|
1415
|
+
}
|
|
1416
|
+
return loading;
|
|
1417
|
+
};
|
|
1418
|
+
var agentCoreIfLoaded = () => loaded;
|
|
1419
|
+
|
|
1404
1420
|
// src/util.ts
|
|
1405
1421
|
var errMessage = (err) => err instanceof Error ? err.message : String(err);
|
|
1406
1422
|
var coalesce = (fn, ms = 100) => {
|
|
@@ -1419,10 +1435,28 @@ var coalesce = (fn, ms = 100) => {
|
|
|
1419
1435
|
}
|
|
1420
1436
|
};
|
|
1421
1437
|
};
|
|
1422
|
-
var listenToOtherTabs = (
|
|
1423
|
-
|
|
1438
|
+
var listenToOtherTabs = (core, dbName, listener) => {
|
|
1439
|
+
if (!dbName) return () => void 0;
|
|
1440
|
+
if (typeof core === "function") {
|
|
1441
|
+
let closed = false;
|
|
1442
|
+
let off;
|
|
1443
|
+
core().then(
|
|
1444
|
+
(module2) => {
|
|
1445
|
+
if (!closed) off = listenToOtherTabs(module2, dbName, listener);
|
|
1446
|
+
},
|
|
1447
|
+
() => {
|
|
1448
|
+
}
|
|
1449
|
+
);
|
|
1450
|
+
return () => {
|
|
1451
|
+
closed = true;
|
|
1452
|
+
off?.();
|
|
1453
|
+
};
|
|
1454
|
+
}
|
|
1455
|
+
return typeof core.onStorageChange === "function" ? core.onStorageChange(dbName, listener) : () => void 0;
|
|
1456
|
+
};
|
|
1457
|
+
var followOtherTabs = (core, dbName, accept, settle, ms = 100) => {
|
|
1424
1458
|
const later = coalesce(settle, ms);
|
|
1425
|
-
const off = listenToOtherTabs(
|
|
1459
|
+
const off = listenToOtherTabs(core, dbName, (change) => {
|
|
1426
1460
|
if (accept(change)) later.call();
|
|
1427
1461
|
});
|
|
1428
1462
|
return () => {
|
|
@@ -1558,6 +1592,9 @@ var createRemoteAgentController = (options) => {
|
|
|
1558
1592
|
let turnIds = [];
|
|
1559
1593
|
let turnFinal = false;
|
|
1560
1594
|
let waiting = [];
|
|
1595
|
+
const sentHere = /* @__PURE__ */ new Set();
|
|
1596
|
+
let frameInfo;
|
|
1597
|
+
const turnIsOurs = () => turnIds.some((id) => sentHere.has(id));
|
|
1561
1598
|
const runs = /* @__PURE__ */ new Map();
|
|
1562
1599
|
const fold = (action, attempt = 0, scope) => {
|
|
1563
1600
|
if (turn) {
|
|
@@ -1575,7 +1612,7 @@ var createRemoteAgentController = (options) => {
|
|
|
1575
1612
|
};
|
|
1576
1613
|
const tell = (e) => {
|
|
1577
1614
|
try {
|
|
1578
|
-
options.onEvent?.(e);
|
|
1615
|
+
options.onEvent?.(e, frameInfo ?? { live: true });
|
|
1579
1616
|
} catch {
|
|
1580
1617
|
}
|
|
1581
1618
|
};
|
|
@@ -1631,13 +1668,26 @@ var createRemoteAgentController = (options) => {
|
|
|
1631
1668
|
}
|
|
1632
1669
|
const raw = parsed?.event;
|
|
1633
1670
|
if (!raw || typeof raw !== "object" || typeof raw.type !== "string") return;
|
|
1671
|
+
try {
|
|
1672
|
+
foldFrame(frame, raw);
|
|
1673
|
+
} finally {
|
|
1674
|
+
frameInfo = void 0;
|
|
1675
|
+
}
|
|
1676
|
+
};
|
|
1677
|
+
const foldFrame = (frame, raw) => {
|
|
1634
1678
|
const cursor2 = parseRemoteCursor(frame.id);
|
|
1679
|
+
const info = () => ({
|
|
1680
|
+
live: turnIsOurs(),
|
|
1681
|
+
...frame.id !== void 0 ? { id: frame.id } : {}
|
|
1682
|
+
});
|
|
1683
|
+
frameInfo = info();
|
|
1635
1684
|
const attempt = cursor2?.attempt ?? 0;
|
|
1636
1685
|
const shown = remoteEventOf(raw);
|
|
1637
1686
|
if (raw.type === "turn.started") {
|
|
1638
1687
|
const ids = Array.isArray(raw.messageIds) ? raw.messageIds.filter((x) => typeof x === "string") : [];
|
|
1639
1688
|
waiting = waiting.filter((w) => !ids.includes(w.id));
|
|
1640
1689
|
turnIds = ids;
|
|
1690
|
+
frameInfo = info();
|
|
1641
1691
|
turnFinal = false;
|
|
1642
1692
|
apply({ type: "status", status: "running" });
|
|
1643
1693
|
turn = { number: cursor2?.turn ?? 0, start: state, entries: [] };
|
|
@@ -1806,6 +1856,7 @@ var createRemoteAgentController = (options) => {
|
|
|
1806
1856
|
apply({ type: "status", status: "running" });
|
|
1807
1857
|
apply({ type: "submitted", goal: shown });
|
|
1808
1858
|
waiting.push({ id, text });
|
|
1859
|
+
sentHere.add(id);
|
|
1809
1860
|
const ended = new Promise((resolve) => runs.set(id, resolve));
|
|
1810
1861
|
try {
|
|
1811
1862
|
await sendMessage(id, text);
|
|
@@ -1848,6 +1899,7 @@ var createRemoteAgentController = (options) => {
|
|
|
1848
1899
|
if (disposed || state.status !== "running" || !clean || !sessionId) return false;
|
|
1849
1900
|
const id = newMessageId();
|
|
1850
1901
|
waiting.push({ id, text: clean });
|
|
1902
|
+
sentHere.add(id);
|
|
1851
1903
|
fold(event({ type: "message.queued", id, text: clean }));
|
|
1852
1904
|
void post(`/sessions/${encodeURIComponent(sessionId)}/messages`, { text: clean, id }).catch(
|
|
1853
1905
|
(err) => {
|
|
@@ -2085,7 +2137,7 @@ var createAgentController = (initialConfig, initialOptions = {}) => {
|
|
|
2085
2137
|
cancelled = true;
|
|
2086
2138
|
};
|
|
2087
2139
|
setBuildStatus({ status: "initializing" });
|
|
2088
|
-
(
|
|
2140
|
+
loadAgentCore().then((core) => core.createAgent(built)).then((next) => {
|
|
2089
2141
|
if (cancelled) return;
|
|
2090
2142
|
next.setToolApprovalMode(mode);
|
|
2091
2143
|
agent = next;
|
|
@@ -2106,11 +2158,22 @@ var createAgentController = (initialConfig, initialOptions = {}) => {
|
|
|
2106
2158
|
const syncWatch = () => {
|
|
2107
2159
|
const db = options.watch !== false && config.sessionLock !== "off" ? dbNameOf(config.memory) : void 0;
|
|
2108
2160
|
if (watched && watched.db === db && watched.sessionId === sessionId) return;
|
|
2161
|
+
const core = agentCoreIfLoaded();
|
|
2162
|
+
if (db && !core) {
|
|
2163
|
+
loadAgentCore().then(
|
|
2164
|
+
() => {
|
|
2165
|
+
if (!disposed) syncWatch();
|
|
2166
|
+
},
|
|
2167
|
+
() => {
|
|
2168
|
+
}
|
|
2169
|
+
);
|
|
2170
|
+
return;
|
|
2171
|
+
}
|
|
2109
2172
|
closeWatch();
|
|
2110
2173
|
watched = { db, sessionId };
|
|
2111
|
-
const
|
|
2112
|
-
if (!db || typeof
|
|
2113
|
-
watch =
|
|
2174
|
+
const watchSession = core?.watchSession;
|
|
2175
|
+
if (!db || typeof watchSession !== "function") return;
|
|
2176
|
+
watch = watchSession({
|
|
2114
2177
|
dbName: db,
|
|
2115
2178
|
sessionId,
|
|
2116
2179
|
onEvent: (event) => {
|
|
@@ -2144,7 +2207,7 @@ var createAgentController = (initialConfig, initialOptions = {}) => {
|
|
|
2144
2207
|
unfollowSkills?.();
|
|
2145
2208
|
skillsDb = { db };
|
|
2146
2209
|
unfollowSkills = followOtherTabs(
|
|
2147
|
-
|
|
2210
|
+
loadAgentCore,
|
|
2148
2211
|
db,
|
|
2149
2212
|
(change) => change.kind === "skills",
|
|
2150
2213
|
() => {
|
|
@@ -2157,10 +2220,11 @@ var createAgentController = (initialConfig, initialOptions = {}) => {
|
|
|
2157
2220
|
};
|
|
2158
2221
|
const run = async (goal, runOptions) => {
|
|
2159
2222
|
const current = agent;
|
|
2160
|
-
|
|
2223
|
+
const core = agentCoreIfLoaded();
|
|
2224
|
+
if (disposed || !current || abort || !core) return void 0;
|
|
2161
2225
|
const controller = new AbortController();
|
|
2162
2226
|
abort = controller;
|
|
2163
|
-
const runControl =
|
|
2227
|
+
const runControl = core.createRunControl();
|
|
2164
2228
|
control = runControl;
|
|
2165
2229
|
let left = [];
|
|
2166
2230
|
let stopped = false;
|
package/dist/controller.d.cts
CHANGED
|
@@ -36,9 +36,9 @@ interface RemoteAgentOptions {
|
|
|
36
36
|
* Every event, after the reducer folded it: the server agent's, a turn's start as the core's
|
|
37
37
|
* `run.start` and its end as `final` / `stopped` / `error` (as a local run's), the swarm's
|
|
38
38
|
* `turn.started` / `turn.ended` markers as they came. A run's `tool.approval-resolved` that only
|
|
39
|
-
* says it parked is not told.
|
|
39
|
+
* says it parked is not told. `info` says whether it is LIVE - see {@link RemoteEventInfo}.
|
|
40
40
|
*/
|
|
41
|
-
onEvent?: (event: AgentEvent) => void;
|
|
41
|
+
onEvent?: (event: AgentEvent, info: RemoteEventInfo) => void;
|
|
42
42
|
/** Cap the retained raw event log (default 200; 0 = unbounded). */
|
|
43
43
|
maxEvents?: number;
|
|
44
44
|
/**
|
|
@@ -50,6 +50,18 @@ interface RemoteAgentOptions {
|
|
|
50
50
|
maxMs?: number;
|
|
51
51
|
};
|
|
52
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* What `onEvent` is told with an event. `live`: the event belongs to a turn that a message sent
|
|
55
|
+
* THROUGH THIS CONTROLLER started (`run` / `send`), as it happens - not a turn replayed from the
|
|
56
|
+
* session's log (a reload, `loadChat`, a session given at start), nor one another tab or client
|
|
57
|
+
* started on the same session. An event of the controller's own (a request that failed) is live.
|
|
58
|
+
* `id`: the event's cursor on the gateway's stream (`<turn>:<attempt>:<seq>`), unique in the
|
|
59
|
+
* session; absent for the controller's own events.
|
|
60
|
+
*/
|
|
61
|
+
interface RemoteEventInfo {
|
|
62
|
+
live: boolean;
|
|
63
|
+
id?: string;
|
|
64
|
+
}
|
|
53
65
|
/** One frame of the gateway's stream: `id:` (the cursor) and the JSON of `data:`. */
|
|
54
66
|
interface RemoteFrame {
|
|
55
67
|
id?: string;
|
|
@@ -357,4 +369,4 @@ declare const createInitialAgentSnapshot: (config: BrowserAgentConfig) => AgentC
|
|
|
357
369
|
declare const createAgentController: (initialConfig: BrowserAgentConfig, initialOptions?: AgentControllerOptions) => AgentController;
|
|
358
370
|
|
|
359
371
|
export { createAgentController, createInitialAgentSnapshot, createInitialRemoteSnapshot, createRemoteAgentController, createSseParser, parseRemoteCursor, remoteEventOf, remoteEventScope };
|
|
360
|
-
export type { AgentController, AgentControllerActions, AgentControllerOptions, AgentControllerSnapshot, AgentControllerUpdate, AppToolCall, ApproveOptions, RemoteAgentHeaders, RemoteAgentOptions, RemoteFrame, RunGoalOptions };
|
|
372
|
+
export type { AgentController, AgentControllerActions, AgentControllerOptions, AgentControllerSnapshot, AgentControllerUpdate, AppToolCall, ApproveOptions, RemoteAgentHeaders, RemoteAgentOptions, RemoteEventInfo, RemoteFrame, RunGoalOptions };
|
package/dist/controller.d.ts
CHANGED
|
@@ -36,9 +36,9 @@ interface RemoteAgentOptions {
|
|
|
36
36
|
* Every event, after the reducer folded it: the server agent's, a turn's start as the core's
|
|
37
37
|
* `run.start` and its end as `final` / `stopped` / `error` (as a local run's), the swarm's
|
|
38
38
|
* `turn.started` / `turn.ended` markers as they came. A run's `tool.approval-resolved` that only
|
|
39
|
-
* says it parked is not told.
|
|
39
|
+
* says it parked is not told. `info` says whether it is LIVE - see {@link RemoteEventInfo}.
|
|
40
40
|
*/
|
|
41
|
-
onEvent?: (event: AgentEvent) => void;
|
|
41
|
+
onEvent?: (event: AgentEvent, info: RemoteEventInfo) => void;
|
|
42
42
|
/** Cap the retained raw event log (default 200; 0 = unbounded). */
|
|
43
43
|
maxEvents?: number;
|
|
44
44
|
/**
|
|
@@ -50,6 +50,18 @@ interface RemoteAgentOptions {
|
|
|
50
50
|
maxMs?: number;
|
|
51
51
|
};
|
|
52
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* What `onEvent` is told with an event. `live`: the event belongs to a turn that a message sent
|
|
55
|
+
* THROUGH THIS CONTROLLER started (`run` / `send`), as it happens - not a turn replayed from the
|
|
56
|
+
* session's log (a reload, `loadChat`, a session given at start), nor one another tab or client
|
|
57
|
+
* started on the same session. An event of the controller's own (a request that failed) is live.
|
|
58
|
+
* `id`: the event's cursor on the gateway's stream (`<turn>:<attempt>:<seq>`), unique in the
|
|
59
|
+
* session; absent for the controller's own events.
|
|
60
|
+
*/
|
|
61
|
+
interface RemoteEventInfo {
|
|
62
|
+
live: boolean;
|
|
63
|
+
id?: string;
|
|
64
|
+
}
|
|
53
65
|
/** One frame of the gateway's stream: `id:` (the cursor) and the JSON of `data:`. */
|
|
54
66
|
interface RemoteFrame {
|
|
55
67
|
id?: string;
|
|
@@ -357,4 +369,4 @@ declare const createInitialAgentSnapshot: (config: BrowserAgentConfig) => AgentC
|
|
|
357
369
|
declare const createAgentController: (initialConfig: BrowserAgentConfig, initialOptions?: AgentControllerOptions) => AgentController;
|
|
358
370
|
|
|
359
371
|
export { createAgentController, createInitialAgentSnapshot, createInitialRemoteSnapshot, createRemoteAgentController, createSseParser, parseRemoteCursor, remoteEventOf, remoteEventScope };
|
|
360
|
-
export type { AgentController, AgentControllerActions, AgentControllerOptions, AgentControllerSnapshot, AgentControllerUpdate, AppToolCall, ApproveOptions, RemoteAgentHeaders, RemoteAgentOptions, RemoteFrame, RunGoalOptions };
|
|
372
|
+
export type { AgentController, AgentControllerActions, AgentControllerOptions, AgentControllerSnapshot, AgentControllerUpdate, AppToolCall, ApproveOptions, RemoteAgentHeaders, RemoteAgentOptions, RemoteEventInfo, RemoteFrame, RunGoalOptions };
|
package/dist/controller.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
agentCoreIfLoaded,
|
|
2
3
|
agentStateReducer,
|
|
3
4
|
agentStatusOf,
|
|
4
5
|
askUserWith,
|
|
@@ -8,17 +9,11 @@ import {
|
|
|
8
9
|
errMessage,
|
|
9
10
|
followOtherTabs,
|
|
10
11
|
lessonsOf,
|
|
12
|
+
loadAgentCore,
|
|
11
13
|
pendingApprovalsOf,
|
|
12
14
|
questionTimeoutOf,
|
|
13
15
|
remoteAnswerOf
|
|
14
|
-
} from "./chunk-
|
|
15
|
-
|
|
16
|
-
// src/controller.ts
|
|
17
|
-
import * as core from "@dudko.dev/agent-web";
|
|
18
|
-
import {
|
|
19
|
-
createAgent,
|
|
20
|
-
createRunControl
|
|
21
|
-
} from "@dudko.dev/agent-web";
|
|
16
|
+
} from "./chunk-NHU6WQM5.js";
|
|
22
17
|
|
|
23
18
|
// src/remote-controller.ts
|
|
24
19
|
var createSseParser = (onFrame, onRetry) => {
|
|
@@ -146,6 +141,9 @@ var createRemoteAgentController = (options) => {
|
|
|
146
141
|
let turnIds = [];
|
|
147
142
|
let turnFinal = false;
|
|
148
143
|
let waiting = [];
|
|
144
|
+
const sentHere = /* @__PURE__ */ new Set();
|
|
145
|
+
let frameInfo;
|
|
146
|
+
const turnIsOurs = () => turnIds.some((id) => sentHere.has(id));
|
|
149
147
|
const runs = /* @__PURE__ */ new Map();
|
|
150
148
|
const fold = (action, attempt = 0, scope) => {
|
|
151
149
|
if (turn) {
|
|
@@ -163,7 +161,7 @@ var createRemoteAgentController = (options) => {
|
|
|
163
161
|
};
|
|
164
162
|
const tell = (e) => {
|
|
165
163
|
try {
|
|
166
|
-
options.onEvent?.(e);
|
|
164
|
+
options.onEvent?.(e, frameInfo ?? { live: true });
|
|
167
165
|
} catch {
|
|
168
166
|
}
|
|
169
167
|
};
|
|
@@ -219,13 +217,26 @@ var createRemoteAgentController = (options) => {
|
|
|
219
217
|
}
|
|
220
218
|
const raw = parsed?.event;
|
|
221
219
|
if (!raw || typeof raw !== "object" || typeof raw.type !== "string") return;
|
|
220
|
+
try {
|
|
221
|
+
foldFrame(frame, raw);
|
|
222
|
+
} finally {
|
|
223
|
+
frameInfo = void 0;
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
const foldFrame = (frame, raw) => {
|
|
222
227
|
const cursor2 = parseRemoteCursor(frame.id);
|
|
228
|
+
const info = () => ({
|
|
229
|
+
live: turnIsOurs(),
|
|
230
|
+
...frame.id !== void 0 ? { id: frame.id } : {}
|
|
231
|
+
});
|
|
232
|
+
frameInfo = info();
|
|
223
233
|
const attempt = cursor2?.attempt ?? 0;
|
|
224
234
|
const shown = remoteEventOf(raw);
|
|
225
235
|
if (raw.type === "turn.started") {
|
|
226
236
|
const ids = Array.isArray(raw.messageIds) ? raw.messageIds.filter((x) => typeof x === "string") : [];
|
|
227
237
|
waiting = waiting.filter((w) => !ids.includes(w.id));
|
|
228
238
|
turnIds = ids;
|
|
239
|
+
frameInfo = info();
|
|
229
240
|
turnFinal = false;
|
|
230
241
|
apply({ type: "status", status: "running" });
|
|
231
242
|
turn = { number: cursor2?.turn ?? 0, start: state, entries: [] };
|
|
@@ -394,6 +405,7 @@ var createRemoteAgentController = (options) => {
|
|
|
394
405
|
apply({ type: "status", status: "running" });
|
|
395
406
|
apply({ type: "submitted", goal: shown });
|
|
396
407
|
waiting.push({ id, text });
|
|
408
|
+
sentHere.add(id);
|
|
397
409
|
const ended = new Promise((resolve) => runs.set(id, resolve));
|
|
398
410
|
try {
|
|
399
411
|
await sendMessage(id, text);
|
|
@@ -436,6 +448,7 @@ var createRemoteAgentController = (options) => {
|
|
|
436
448
|
if (disposed || state.status !== "running" || !clean || !sessionId) return false;
|
|
437
449
|
const id = newMessageId();
|
|
438
450
|
waiting.push({ id, text: clean });
|
|
451
|
+
sentHere.add(id);
|
|
439
452
|
fold(event({ type: "message.queued", id, text: clean }));
|
|
440
453
|
void post(`/sessions/${encodeURIComponent(sessionId)}/messages`, { text: clean, id }).catch(
|
|
441
454
|
(err) => {
|
|
@@ -673,7 +686,7 @@ var createAgentController = (initialConfig, initialOptions = {}) => {
|
|
|
673
686
|
cancelled = true;
|
|
674
687
|
};
|
|
675
688
|
setBuildStatus({ status: "initializing" });
|
|
676
|
-
createAgent(built).then((next) => {
|
|
689
|
+
loadAgentCore().then((core) => core.createAgent(built)).then((next) => {
|
|
677
690
|
if (cancelled) return;
|
|
678
691
|
next.setToolApprovalMode(mode);
|
|
679
692
|
agent = next;
|
|
@@ -694,11 +707,22 @@ var createAgentController = (initialConfig, initialOptions = {}) => {
|
|
|
694
707
|
const syncWatch = () => {
|
|
695
708
|
const db = options.watch !== false && config.sessionLock !== "off" ? dbNameOf(config.memory) : void 0;
|
|
696
709
|
if (watched && watched.db === db && watched.sessionId === sessionId) return;
|
|
710
|
+
const core = agentCoreIfLoaded();
|
|
711
|
+
if (db && !core) {
|
|
712
|
+
loadAgentCore().then(
|
|
713
|
+
() => {
|
|
714
|
+
if (!disposed) syncWatch();
|
|
715
|
+
},
|
|
716
|
+
() => {
|
|
717
|
+
}
|
|
718
|
+
);
|
|
719
|
+
return;
|
|
720
|
+
}
|
|
697
721
|
closeWatch();
|
|
698
722
|
watched = { db, sessionId };
|
|
699
|
-
const
|
|
700
|
-
if (!db || typeof
|
|
701
|
-
watch =
|
|
723
|
+
const watchSession = core?.watchSession;
|
|
724
|
+
if (!db || typeof watchSession !== "function") return;
|
|
725
|
+
watch = watchSession({
|
|
702
726
|
dbName: db,
|
|
703
727
|
sessionId,
|
|
704
728
|
onEvent: (event) => {
|
|
@@ -732,7 +756,7 @@ var createAgentController = (initialConfig, initialOptions = {}) => {
|
|
|
732
756
|
unfollowSkills?.();
|
|
733
757
|
skillsDb = { db };
|
|
734
758
|
unfollowSkills = followOtherTabs(
|
|
735
|
-
|
|
759
|
+
loadAgentCore,
|
|
736
760
|
db,
|
|
737
761
|
(change) => change.kind === "skills",
|
|
738
762
|
() => {
|
|
@@ -745,10 +769,11 @@ var createAgentController = (initialConfig, initialOptions = {}) => {
|
|
|
745
769
|
};
|
|
746
770
|
const run = async (goal, runOptions) => {
|
|
747
771
|
const current = agent;
|
|
748
|
-
|
|
772
|
+
const core = agentCoreIfLoaded();
|
|
773
|
+
if (disposed || !current || abort || !core) return void 0;
|
|
749
774
|
const controller = new AbortController();
|
|
750
775
|
abort = controller;
|
|
751
|
-
const runControl = createRunControl();
|
|
776
|
+
const runControl = core.createRunControl();
|
|
752
777
|
control = runControl;
|
|
753
778
|
let left = [];
|
|
754
779
|
let stopped = false;
|
package/dist/index.cjs
CHANGED
|
@@ -52,6 +52,7 @@ __export(src_exports, {
|
|
|
52
52
|
RECORDING_TYPES: () => RECORDING_TYPES,
|
|
53
53
|
SpeechOutputError: () => SpeechOutputError,
|
|
54
54
|
activeElementOf: () => activeElementOf,
|
|
55
|
+
agentCoreIfLoaded: () => agentCoreIfLoaded,
|
|
55
56
|
agentStateReducer: () => agentStateReducer,
|
|
56
57
|
agentStatusOf: () => agentStatusOf,
|
|
57
58
|
askUserOutputKept: () => askUserOutputKept,
|
|
@@ -124,8 +125,10 @@ __export(src_exports, {
|
|
|
124
125
|
linkedFilesOf: () => linkedFilesOf,
|
|
125
126
|
listenScrollAround: () => listenScrollAround,
|
|
126
127
|
listenToOtherTabs: () => listenToOtherTabs,
|
|
128
|
+
loadAgentCore: () => loadAgentCore,
|
|
127
129
|
longTextName: () => longTextName,
|
|
128
130
|
longTextRoute: () => longTextRoute,
|
|
131
|
+
mediaFamilyOf: () => mediaFamilyOf,
|
|
129
132
|
menuKeyTarget: () => menuKeyTarget,
|
|
130
133
|
menuSections: () => menuSections,
|
|
131
134
|
mergeChatRecord: () => mergeChatRecord,
|
|
@@ -183,8 +186,25 @@ __export(src_exports, {
|
|
|
183
186
|
});
|
|
184
187
|
module.exports = __toCommonJS(src_exports);
|
|
185
188
|
|
|
186
|
-
// src/
|
|
187
|
-
var
|
|
189
|
+
// src/core-copies.ts
|
|
190
|
+
var REPLAY_NOTE_OF_CORE = "[not run again: this exact call already succeeded in an earlier attempt at this step, and its effect is in place. Its result then:]";
|
|
191
|
+
var isReplayedOutput = (output) => typeof output === "string" && output.startsWith(REPLAY_NOTE_OF_CORE);
|
|
192
|
+
var MEDIA_IMAGE_TYPES_OF_CORE = {
|
|
193
|
+
"image/png": "png",
|
|
194
|
+
"image/jpeg": "jpg",
|
|
195
|
+
"image/gif": "gif",
|
|
196
|
+
"image/webp": "webp"
|
|
197
|
+
};
|
|
198
|
+
var MEDIA_AUDIO_TYPES_OF_CORE = {
|
|
199
|
+
"audio/mpeg": "mp3",
|
|
200
|
+
"audio/wav": "wav",
|
|
201
|
+
"audio/ogg": "ogg",
|
|
202
|
+
"audio/flac": "flac",
|
|
203
|
+
"audio/aac": "aac",
|
|
204
|
+
"audio/mp4": "m4a",
|
|
205
|
+
"audio/webm": "webm"
|
|
206
|
+
};
|
|
207
|
+
var isTextMimeOfCore = (mime) => /^text\/|json|xml|yaml|javascript|typescript|svg/.test(mime);
|
|
188
208
|
|
|
189
209
|
// src/questions.ts
|
|
190
210
|
var ASK_USER_TOOL_NAME = "ask_user";
|
|
@@ -1043,7 +1063,7 @@ var applyEvent = (state, event, ctx) => {
|
|
|
1043
1063
|
ok: event.ok,
|
|
1044
1064
|
status: "done",
|
|
1045
1065
|
outputTokens: approxTokens(event.output),
|
|
1046
|
-
...(
|
|
1066
|
+
...isReplayedOutput(event.output) ? { replayed: true } : {},
|
|
1047
1067
|
...ctx.at !== void 0 && c.startedAt !== void 0 ? { durationMs: Math.max(0, ctx.at - c.startedAt) } : {}
|
|
1048
1068
|
};
|
|
1049
1069
|
}
|
|
@@ -1090,7 +1110,7 @@ var applyEvent = (state, event, ctx) => {
|
|
|
1090
1110
|
...streamed?.durationMs !== void 0 ? { durationMs: streamed.durationMs } : {},
|
|
1091
1111
|
// With tiers the list holds every attempt's calls, in the order they were made.
|
|
1092
1112
|
...streamed?.attempt !== void 0 ? { attempt: streamed.attempt } : {},
|
|
1093
|
-
...(
|
|
1113
|
+
...isReplayedOutput(c.output) ? { replayed: true } : {},
|
|
1094
1114
|
// The MCP App the call came with (only the stream told it).
|
|
1095
1115
|
...streamed?.app !== void 0 ? { app: streamed.app } : {}
|
|
1096
1116
|
};
|
|
@@ -2541,22 +2561,27 @@ var portalHostOf = (from, selector) => {
|
|
|
2541
2561
|
};
|
|
2542
2562
|
|
|
2543
2563
|
// src/file-kinds.ts
|
|
2544
|
-
var import_agent_web2 = require("@dudko.dev/agent-web");
|
|
2545
2564
|
var CODE = /\.(?:js|mjs|cjs|jsx|ts|tsx|css|scss|py|rb|go|rs|java|kt|c|h|cpp|cs|php|sh|sql|xml|svg|yaml|yml|toml)$/i;
|
|
2546
2565
|
var mimeOf = (mediaType) => mediaType.toLowerCase().split(";")[0].trim();
|
|
2547
2566
|
var fileKindOf = (path, mediaType) => {
|
|
2548
2567
|
const mime = mimeOf(mediaType);
|
|
2549
|
-
if (Object.hasOwn(
|
|
2568
|
+
if (Object.hasOwn(MEDIA_IMAGE_TYPES_OF_CORE, mime)) return "image";
|
|
2550
2569
|
if (mime === "text/html" || mime === "application/xhtml+xml" || /\.x?html?$/i.test(path))
|
|
2551
2570
|
return "html";
|
|
2552
2571
|
if (mime === "text/markdown" || /\.(?:md|markdown)$/i.test(path)) return "markdown";
|
|
2553
2572
|
if (mime === "text/csv" || /\.(?:csv|tsv)$/i.test(path)) return "csv";
|
|
2554
2573
|
if (mime === "application/json" || /\.json$/i.test(path)) return "json";
|
|
2555
2574
|
if (CODE.test(path)) return "code";
|
|
2556
|
-
if (mime === "text/plain" || /\.(?:txt|log)$/i.test(path) || (
|
|
2575
|
+
if (mime === "text/plain" || /\.(?:txt|log)$/i.test(path) || isTextMimeOfCore(mime)) return "text";
|
|
2557
2576
|
return "file";
|
|
2558
2577
|
};
|
|
2559
2578
|
var fileNameOf = (path) => path.split("/").filter(Boolean).pop() || "file";
|
|
2579
|
+
var mediaFamilyOf = (mediaType) => {
|
|
2580
|
+
const type = mimeOf(mediaType);
|
|
2581
|
+
if (Object.hasOwn(MEDIA_IMAGE_TYPES_OF_CORE, type)) return "image";
|
|
2582
|
+
if (Object.hasOwn(MEDIA_AUDIO_TYPES_OF_CORE, type)) return "audio";
|
|
2583
|
+
return void 0;
|
|
2584
|
+
};
|
|
2560
2585
|
|
|
2561
2586
|
// src/image-resize.ts
|
|
2562
2587
|
var canvasOf = (w, h) => {
|
|
@@ -3124,8 +3149,22 @@ var createPromptArming = (delayMs = PROMPT_ARM_MS) => {
|
|
|
3124
3149
|
};
|
|
3125
3150
|
};
|
|
3126
3151
|
|
|
3152
|
+
// src/core-later.ts
|
|
3153
|
+
var loading;
|
|
3154
|
+
var loaded;
|
|
3155
|
+
var loadAgentCore = () => {
|
|
3156
|
+
if (!loading) {
|
|
3157
|
+
const next = import("@dudko.dev/agent-web").then((core) => loaded = core);
|
|
3158
|
+
loading = next;
|
|
3159
|
+
next.catch(() => {
|
|
3160
|
+
if (loading === next) loading = void 0;
|
|
3161
|
+
});
|
|
3162
|
+
}
|
|
3163
|
+
return loading;
|
|
3164
|
+
};
|
|
3165
|
+
var agentCoreIfLoaded = () => loaded;
|
|
3166
|
+
|
|
3127
3167
|
// src/chat-history.ts
|
|
3128
|
-
var core = __toESM(require("@dudko.dev/agent-web"), 1);
|
|
3129
3168
|
var DB_VERSION = 1;
|
|
3130
3169
|
var req = (r) => new Promise((resolve, reject) => {
|
|
3131
3170
|
r.onsuccess = () => resolve(r.result);
|
|
@@ -3199,9 +3238,15 @@ var ChatHistoryStore = class {
|
|
|
3199
3238
|
this.announce(notice);
|
|
3200
3239
|
}
|
|
3201
3240
|
announce(notice) {
|
|
3202
|
-
|
|
3203
|
-
core
|
|
3204
|
-
|
|
3241
|
+
loadAgentCore().then(
|
|
3242
|
+
(core) => {
|
|
3243
|
+
if (typeof core.postStorageChange === "function") {
|
|
3244
|
+
core.postStorageChange(this.dbName, { kind: "chats", ...notice });
|
|
3245
|
+
}
|
|
3246
|
+
},
|
|
3247
|
+
() => {
|
|
3248
|
+
}
|
|
3249
|
+
);
|
|
3205
3250
|
}
|
|
3206
3251
|
/**
|
|
3207
3252
|
* Read the stored record and write what `merge` makes of it in ONE readwrite transaction: no
|
|
@@ -3374,10 +3419,28 @@ var coalesce = (fn, ms = 100) => {
|
|
|
3374
3419
|
}
|
|
3375
3420
|
};
|
|
3376
3421
|
};
|
|
3377
|
-
var listenToOtherTabs = (
|
|
3378
|
-
|
|
3422
|
+
var listenToOtherTabs = (core, dbName, listener) => {
|
|
3423
|
+
if (!dbName) return () => void 0;
|
|
3424
|
+
if (typeof core === "function") {
|
|
3425
|
+
let closed = false;
|
|
3426
|
+
let off;
|
|
3427
|
+
core().then(
|
|
3428
|
+
(module2) => {
|
|
3429
|
+
if (!closed) off = listenToOtherTabs(module2, dbName, listener);
|
|
3430
|
+
},
|
|
3431
|
+
() => {
|
|
3432
|
+
}
|
|
3433
|
+
);
|
|
3434
|
+
return () => {
|
|
3435
|
+
closed = true;
|
|
3436
|
+
off?.();
|
|
3437
|
+
};
|
|
3438
|
+
}
|
|
3439
|
+
return typeof core.onStorageChange === "function" ? core.onStorageChange(dbName, listener) : () => void 0;
|
|
3440
|
+
};
|
|
3441
|
+
var followOtherTabs = (core, dbName, accept, settle, ms = 100) => {
|
|
3379
3442
|
const later = coalesce(settle, ms);
|
|
3380
|
-
const off = listenToOtherTabs(
|
|
3443
|
+
const off = listenToOtherTabs(core, dbName, (change) => {
|
|
3381
3444
|
if (accept(change)) later.call();
|
|
3382
3445
|
});
|
|
3383
3446
|
return () => {
|
|
@@ -4145,6 +4208,7 @@ var createAudioSpeaker = (options) => (text2, { lang, onState }) => {
|
|
|
4145
4208
|
RECORDING_TYPES,
|
|
4146
4209
|
SpeechOutputError,
|
|
4147
4210
|
activeElementOf,
|
|
4211
|
+
agentCoreIfLoaded,
|
|
4148
4212
|
agentStateReducer,
|
|
4149
4213
|
agentStatusOf,
|
|
4150
4214
|
askUserOutputKept,
|
|
@@ -4217,8 +4281,10 @@ var createAudioSpeaker = (options) => (text2, { lang, onState }) => {
|
|
|
4217
4281
|
linkedFilesOf,
|
|
4218
4282
|
listenScrollAround,
|
|
4219
4283
|
listenToOtherTabs,
|
|
4284
|
+
loadAgentCore,
|
|
4220
4285
|
longTextName,
|
|
4221
4286
|
longTextRoute,
|
|
4287
|
+
mediaFamilyOf,
|
|
4222
4288
|
menuKeyTarget,
|
|
4223
4289
|
menuSections,
|
|
4224
4290
|
mergeChatRecord,
|
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import * as Core from '@dudko.dev/agent-web';
|
|
1
2
|
import { AgentEvent, IUsage, Skill, ToolApprovalRequest, ToolApprovalContext, ToolApprovalDecision } from '@dudko.dev/agent-web';
|
|
2
3
|
import { A as AgentUiState, C as ChatAttachment, R as RemoteRunView, L as LessonView, a as ChatMessage, b as ApprovalView, S as SubagentView, i as SubagentNode } from './types-DnBCok3z.cjs';
|
|
3
4
|
export { h as AgentStatus, j as AppView, B as BrowserOAuthProvider, k as BrowserOAuthProviderOptions, l as BudgetView, m as CompactionView, n as ConnectedMcp, D as DecisionView, E as ElicitationView, F as FetchView, o as McpAppsConnectionLike, p as McpCatalogEntry, M as McpElicitationFieldSchema, c as McpElicitationHandler, f as McpElicitationOptions, d as McpElicitationRequest, e as McpElicitationResult, g as McpElicitationSchema, q as McpHttpServerConfig, r as McpModule, s as McpOAuthCallback, t as McpOAuthRegistration, u as McpOAuthRegistrationKind, v as McpProtocolMode, w as McpServerInstructions, x as McpServerProtocol, y as McpServerResult, z as MediaView, G as ModelLoadState, Q as QuestionView, H as QueuedMessageView, I as ReplanState, J as SkillConsentView, K as StepEscalationView, N as StepView, T as ToolCallView, O as TranscriptView, U as UserNoteView, W as WrittenFileView } from './types-DnBCok3z.cjs';
|
|
4
|
-
export { a as ATTACHMENT_BOUNDS, b as AgentLabels, A as AgentLabelsOverride, c as AttachmentBounds, d as AttachmentFiles, e as AttachmentOverLimit, f as AttachmentTextOptions, g as AttachmentTransform, C as ComposerAttachment, h as ComposerNotice, E as ELICITATION_MAX_OPTIONS, i as ELICITATION_TIMEOUT_MS, j as ELICITATION_VALUE_MAX_CHARS, k as ElicitationControl, l as ElicitationDraft, m as ElicitationDraftValue, n as ElicitationField, o as ElicitationFormOutcome, p as ElicitationIssue, q as ElicitationIssueKind, r as ElicitationLink, s as ElicitationOption, t as ElicitationOutcomeReason, u as ElicitationQueue, v as ElicitationQueueOptions, F as FileKind, I as INPUT_COUNTER_FROM, M as MenuSection, N as NotReadyInput, w as NotReadyIntent, x as NotReadyReason, y as NoticeTexts, P as PendingElicitation, S as SavedAttachments, z as SlashCommand, B as SteerIntent, T as TextExcerpt, W as WaitingSendStep, D as attachmentFileName, G as attachmentKindOf, H as attachmentLabel, J as attachmentOverLimit, K as attachmentRefusal, L as attachmentTransformOf, O as boxLength, Q as createElicitationQueue, R as dataUrlParts, U as defaultLabels, V as defaultNoticeTexts, X as elicitationConnectOptions, Y as elicitationFields, Z as elicitationFormAnswer, _ as elicitationInitialDraft, $ as elicitationLink, a0 as elicitationSettings, a1 as elicitationTimeoutOf, a2 as excerptNote, a3 as fileKindOf, a4 as fileNameOf, a5 as filterCommands, a6 as formatClock, a7 as formatCountdown, a8 as formatElapsed, a9 as freeAttachmentPath, aa as inputCounterShown, ab as insertionFits, ac as isOneCharacter, ad as lineCountOf, ae as longTextName, af as longTextRoute, ag as
|
|
5
|
+
export { a as ATTACHMENT_BOUNDS, b as AgentLabels, A as AgentLabelsOverride, c as AttachmentBounds, d as AttachmentFiles, e as AttachmentOverLimit, f as AttachmentTextOptions, g as AttachmentTransform, C as ComposerAttachment, h as ComposerNotice, E as ELICITATION_MAX_OPTIONS, i as ELICITATION_TIMEOUT_MS, j as ELICITATION_VALUE_MAX_CHARS, k as ElicitationControl, l as ElicitationDraft, m as ElicitationDraftValue, n as ElicitationField, o as ElicitationFormOutcome, p as ElicitationIssue, q as ElicitationIssueKind, r as ElicitationLink, s as ElicitationOption, t as ElicitationOutcomeReason, u as ElicitationQueue, v as ElicitationQueueOptions, F as FileKind, I as INPUT_COUNTER_FROM, M as MenuSection, N as NotReadyInput, w as NotReadyIntent, x as NotReadyReason, y as NoticeTexts, P as PendingElicitation, S as SavedAttachments, z as SlashCommand, B as SteerIntent, T as TextExcerpt, W as WaitingSendStep, D as attachmentFileName, G as attachmentKindOf, H as attachmentLabel, J as attachmentOverLimit, K as attachmentRefusal, L as attachmentTransformOf, O as boxLength, Q as createElicitationQueue, R as dataUrlParts, U as defaultLabels, V as defaultNoticeTexts, X as elicitationConnectOptions, Y as elicitationFields, Z as elicitationFormAnswer, _ as elicitationInitialDraft, $ as elicitationLink, a0 as elicitationSettings, a1 as elicitationTimeoutOf, a2 as excerptNote, a3 as fileKindOf, a4 as fileNameOf, a5 as filterCommands, a6 as formatClock, a7 as formatCountdown, a8 as formatElapsed, a9 as freeAttachmentPath, aa as inputCounterShown, ab as insertionFits, ac as isOneCharacter, ad as lineCountOf, ae as longTextName, af as longTextRoute, ag as mediaFamilyOf, ah as menuKeyTarget, ai as menuSections, aj as mergeLabels, ak as messageOverLimit, al as micProblemText, am as notReadyIntent, an as notReadyReason, ao as noticesOf, ap as overflowOf, aq as parseSlash, ar as saveAttachments, as as steerIntent, at as textExcerpt, au as voiceMessageName, av as waitingSendStep, aw as withAttachments } from './labels-ipy-ydkp.cjs';
|
|
5
6
|
export { A as ASK_USER_TOOL_NAME, P as PendingQuestion, a as QUESTION_TIMEOUT_MS, Q as QuestionOutcomeReason, b as QuestionQueue, c as QuestionQueueOptions, d as askUserOutputKept, e as askUserWith, f as createQuestionQueue, q as questionChoiceOf, g as questionOtherOf, h as questionTimeoutOf, w as withoutOwnWords } from './questions-Dw--IEjT.cjs';
|
|
6
7
|
import './mcp-app.cjs';
|
|
7
8
|
import './mcp-app-policy-DXKQ2jjM.cjs';
|
|
@@ -566,13 +567,19 @@ declare const coalesce: (fn: () => void, ms?: number) => {
|
|
|
566
567
|
call: () => void;
|
|
567
568
|
cancel: () => void;
|
|
568
569
|
};
|
|
570
|
+
/** What `listenToOtherTabs` / `followOtherTabs` take for the core: its module, or a loader of it. */
|
|
571
|
+
type StorageChangeSource = {
|
|
572
|
+
onStorageChange?: unknown;
|
|
573
|
+
} | (() => Promise<{
|
|
574
|
+
onStorageChange?: unknown;
|
|
575
|
+
}>);
|
|
569
576
|
/**
|
|
570
577
|
* The core's `onStorageChange`, or a no-op where the core predates it (the hooks then work as
|
|
571
|
-
* before: this tab's own changes only). One place for the guard every hook needs.
|
|
578
|
+
* before: this tab's own changes only). One place for the guard every hook needs. `core` may be a
|
|
579
|
+
* LOADER (`loadAgentCore`): it is called only when there is a database to follow, and the
|
|
580
|
+
* subscription starts once it resolves - so a view that follows nothing never loads the core.
|
|
572
581
|
*/
|
|
573
|
-
declare const listenToOtherTabs: (core: {
|
|
574
|
-
onStorageChange?: unknown;
|
|
575
|
-
}, dbName: string | undefined, listener: (change: {
|
|
582
|
+
declare const listenToOtherTabs: (core: StorageChangeSource, dbName: string | undefined, listener: (change: {
|
|
576
583
|
kind: string;
|
|
577
584
|
op: string;
|
|
578
585
|
key?: string;
|
|
@@ -583,9 +590,7 @@ declare const listenToOtherTabs: (core: {
|
|
|
583
590
|
* matters here), `settle` runs once, ~`ms` after the last accepted one of a burst. What every hook
|
|
584
591
|
* that follows other tabs uses. The returned function unsubscribes and drops a pending settle.
|
|
585
592
|
*/
|
|
586
|
-
declare const followOtherTabs: (core: {
|
|
587
|
-
onStorageChange?: unknown;
|
|
588
|
-
}, dbName: string | undefined, accept: (change: {
|
|
593
|
+
declare const followOtherTabs: (core: StorageChangeSource, dbName: string | undefined, accept: (change: {
|
|
589
594
|
kind: string;
|
|
590
595
|
op: string;
|
|
591
596
|
key?: string;
|
|
@@ -599,6 +604,19 @@ declare const followOtherTabs: (core: {
|
|
|
599
604
|
*/
|
|
600
605
|
declare const remoteAnswerOf: (ok: boolean, stillWatching: boolean) => "taken" | "refused" | "unknown";
|
|
601
606
|
|
|
607
|
+
/** The core's module (`@dudko.dev/agent-web`), as `loadAgentCore` resolves it. */
|
|
608
|
+
type AgentCoreModule = typeof Core;
|
|
609
|
+
/**
|
|
610
|
+
* The core, imported on the first call (a dynamic `import()`, the same module every time): what
|
|
611
|
+
* this package uses of the core at run time goes through here, never through a static import. A
|
|
612
|
+
* bundler then leaves the core - the AI SDK, zod, the providers - out of the page's first chunk,
|
|
613
|
+
* and a chat whose agent is on a server (`createRemoteAgentController`) never loads it at all.
|
|
614
|
+
* A failed import is tried again on the next call.
|
|
615
|
+
*/
|
|
616
|
+
declare const loadAgentCore: () => Promise<AgentCoreModule>;
|
|
617
|
+
/** The core if `loadAgentCore` has already resolved, else `undefined` (nothing is imported). */
|
|
618
|
+
declare const agentCoreIfLoaded: () => AgentCoreModule | undefined;
|
|
619
|
+
|
|
602
620
|
/**
|
|
603
621
|
* The sandboxed frame's security core: what untrusted HTML (a file the agent wrote, later an
|
|
604
622
|
* MCP App) is wrapped in before it reaches an `<iframe>`. Pure strings - no React, no DOM - so
|
|
@@ -993,5 +1011,5 @@ interface AudioSpeakerOptions {
|
|
|
993
1011
|
*/
|
|
994
1012
|
declare const createAudioSpeaker: (options: AudioSpeakerOptions) => SpeakText;
|
|
995
1013
|
|
|
996
|
-
export { AgentUiState, ApprovalView, ChatAttachment, ChatHistoryStore, ChatMessage, FOLLOW_LEAVE_PX, FOLLOW_REJOIN_PX, FRAME_MAX_HEIGHT, FRAME_MIN_HEIGHT, HTML_PREVIEW_MAX_CHARS, LessonView, MicError, NAMED_FILES_MAX, NAMED_FILES_SCAN_MAX, NAMED_FILES_TEXT_MAX, PROMPT_ARM_MS, RECORDING_DEFAULT_MAX_MS, RECORDING_TYPES, RemoteRunView, SpeechOutputError, SubagentNode, SubagentView, activeElementOf, agentStateReducer, agentStatusOf, attachmentsText, audioExtensionOf, audioTypeOf, buildSandboxedDocument, chatTitle, clampFrameHeight, coalesce, composedContains, createApprovalQueue, createAudioSpeaker, createBrowserSpeaker, createInitialAgentState, createPromptArming, createRecordingRecognizer, cspMetaTag, deepActiveElement, deepElementFromPoint, downscaleImage, endGap, errMessage, escapeAttribute, eventTargetOf, followOtherTabs, followsAfterResize, followsAfterScroll, formatDuration, formatProbability, formatTokens, imageSizeOf, imagesInOutput, isEventInside, isShadowRoot, languageOfText, lessonsOf, linkedFilesOf, listenScrollAround, listenToOtherTabs, mergeChatRecord, micProblemOf, namedFilesOf, newChatId, nothingFocused, ownUnsaved, pathsNamedIn, pendingApprovalsOf, pickRecordingType, portalHostOf, previewValue, recordingSupported, remoteAnswerOf, rootOf, sandboxTokens, sandboxedCsp, saveChat, scriptOfLanguage, scriptOfText, shadowRootsAround, speakableText, speechSynthesisSupported, splitForSpeech, startRecording, stopTracks, subagentTree, tokenizeHtml, unchangedSince, voiceFor, voicesOf, webSearchOf, withCspFirst, withPolicyFirst, workspacePathOf };
|
|
997
|
-
export type { AgentAction, ApprovalQueue, AttachmentTexts, AudioLike, AudioSpeakerOptions, BrowserSpeakerOptions, ChatBase, ChatHistoryStoreOptions, ChatRecord, ChatSummary, DownscaleOptions, ImageSize, MediaRecorderConstructorLike, MediaRecorderLike, MicProblem, NamedFilesOptions, PromptArming, ReadAloudState, RecordedAudio, Recording, RecordingDeps, RecordingRecognizerOptions, SandboxedDocumentOptions, ScrollMeasure, SourceToken, SpeakText, SpeakableOptions, SpeechPlayback, SpeechRecognizerLike, SpeechScript, SpeechSynthesisLike, SpeechUtteranceLike, SpeechVoiceLike, StartRecordingOptions, SynthesizeSpeech, TranscribeAudio, WebSearchResultView, WebSearchView };
|
|
1014
|
+
export { AgentUiState, ApprovalView, ChatAttachment, ChatHistoryStore, ChatMessage, FOLLOW_LEAVE_PX, FOLLOW_REJOIN_PX, FRAME_MAX_HEIGHT, FRAME_MIN_HEIGHT, HTML_PREVIEW_MAX_CHARS, LessonView, MicError, NAMED_FILES_MAX, NAMED_FILES_SCAN_MAX, NAMED_FILES_TEXT_MAX, PROMPT_ARM_MS, RECORDING_DEFAULT_MAX_MS, RECORDING_TYPES, RemoteRunView, SpeechOutputError, SubagentNode, SubagentView, activeElementOf, agentCoreIfLoaded, agentStateReducer, agentStatusOf, attachmentsText, audioExtensionOf, audioTypeOf, buildSandboxedDocument, chatTitle, clampFrameHeight, coalesce, composedContains, createApprovalQueue, createAudioSpeaker, createBrowserSpeaker, createInitialAgentState, createPromptArming, createRecordingRecognizer, cspMetaTag, deepActiveElement, deepElementFromPoint, downscaleImage, endGap, errMessage, escapeAttribute, eventTargetOf, followOtherTabs, followsAfterResize, followsAfterScroll, formatDuration, formatProbability, formatTokens, imageSizeOf, imagesInOutput, isEventInside, isShadowRoot, languageOfText, lessonsOf, linkedFilesOf, listenScrollAround, listenToOtherTabs, loadAgentCore, mergeChatRecord, micProblemOf, namedFilesOf, newChatId, nothingFocused, ownUnsaved, pathsNamedIn, pendingApprovalsOf, pickRecordingType, portalHostOf, previewValue, recordingSupported, remoteAnswerOf, rootOf, sandboxTokens, sandboxedCsp, saveChat, scriptOfLanguage, scriptOfText, shadowRootsAround, speakableText, speechSynthesisSupported, splitForSpeech, startRecording, stopTracks, subagentTree, tokenizeHtml, unchangedSince, voiceFor, voicesOf, webSearchOf, withCspFirst, withPolicyFirst, workspacePathOf };
|
|
1015
|
+
export type { AgentAction, AgentCoreModule, ApprovalQueue, AttachmentTexts, AudioLike, AudioSpeakerOptions, BrowserSpeakerOptions, ChatBase, ChatHistoryStoreOptions, ChatRecord, ChatSummary, DownscaleOptions, ImageSize, MediaRecorderConstructorLike, MediaRecorderLike, MicProblem, NamedFilesOptions, PromptArming, ReadAloudState, RecordedAudio, Recording, RecordingDeps, RecordingRecognizerOptions, SandboxedDocumentOptions, ScrollMeasure, SourceToken, SpeakText, SpeakableOptions, SpeechPlayback, SpeechRecognizerLike, SpeechScript, SpeechSynthesisLike, SpeechUtteranceLike, SpeechVoiceLike, StartRecordingOptions, StorageChangeSource, SynthesizeSpeech, TranscribeAudio, WebSearchResultView, WebSearchView };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import * as Core from '@dudko.dev/agent-web';
|
|
1
2
|
import { AgentEvent, IUsage, Skill, ToolApprovalRequest, ToolApprovalContext, ToolApprovalDecision } from '@dudko.dev/agent-web';
|
|
2
3
|
import { A as AgentUiState, C as ChatAttachment, R as RemoteRunView, L as LessonView, a as ChatMessage, b as ApprovalView, S as SubagentView, i as SubagentNode } from './types-DnBCok3z.js';
|
|
3
4
|
export { h as AgentStatus, j as AppView, B as BrowserOAuthProvider, k as BrowserOAuthProviderOptions, l as BudgetView, m as CompactionView, n as ConnectedMcp, D as DecisionView, E as ElicitationView, F as FetchView, o as McpAppsConnectionLike, p as McpCatalogEntry, M as McpElicitationFieldSchema, c as McpElicitationHandler, f as McpElicitationOptions, d as McpElicitationRequest, e as McpElicitationResult, g as McpElicitationSchema, q as McpHttpServerConfig, r as McpModule, s as McpOAuthCallback, t as McpOAuthRegistration, u as McpOAuthRegistrationKind, v as McpProtocolMode, w as McpServerInstructions, x as McpServerProtocol, y as McpServerResult, z as MediaView, G as ModelLoadState, Q as QuestionView, H as QueuedMessageView, I as ReplanState, J as SkillConsentView, K as StepEscalationView, N as StepView, T as ToolCallView, O as TranscriptView, U as UserNoteView, W as WrittenFileView } from './types-DnBCok3z.js';
|
|
4
|
-
export { a as ATTACHMENT_BOUNDS, b as AgentLabels, A as AgentLabelsOverride, c as AttachmentBounds, d as AttachmentFiles, e as AttachmentOverLimit, f as AttachmentTextOptions, g as AttachmentTransform, C as ComposerAttachment, h as ComposerNotice, E as ELICITATION_MAX_OPTIONS, i as ELICITATION_TIMEOUT_MS, j as ELICITATION_VALUE_MAX_CHARS, k as ElicitationControl, l as ElicitationDraft, m as ElicitationDraftValue, n as ElicitationField, o as ElicitationFormOutcome, p as ElicitationIssue, q as ElicitationIssueKind, r as ElicitationLink, s as ElicitationOption, t as ElicitationOutcomeReason, u as ElicitationQueue, v as ElicitationQueueOptions, F as FileKind, I as INPUT_COUNTER_FROM, M as MenuSection, N as NotReadyInput, w as NotReadyIntent, x as NotReadyReason, y as NoticeTexts, P as PendingElicitation, S as SavedAttachments, z as SlashCommand, B as SteerIntent, T as TextExcerpt, W as WaitingSendStep, D as attachmentFileName, G as attachmentKindOf, H as attachmentLabel, J as attachmentOverLimit, K as attachmentRefusal, L as attachmentTransformOf, O as boxLength, Q as createElicitationQueue, R as dataUrlParts, U as defaultLabels, V as defaultNoticeTexts, X as elicitationConnectOptions, Y as elicitationFields, Z as elicitationFormAnswer, _ as elicitationInitialDraft, $ as elicitationLink, a0 as elicitationSettings, a1 as elicitationTimeoutOf, a2 as excerptNote, a3 as fileKindOf, a4 as fileNameOf, a5 as filterCommands, a6 as formatClock, a7 as formatCountdown, a8 as formatElapsed, a9 as freeAttachmentPath, aa as inputCounterShown, ab as insertionFits, ac as isOneCharacter, ad as lineCountOf, ae as longTextName, af as longTextRoute, ag as
|
|
5
|
+
export { a as ATTACHMENT_BOUNDS, b as AgentLabels, A as AgentLabelsOverride, c as AttachmentBounds, d as AttachmentFiles, e as AttachmentOverLimit, f as AttachmentTextOptions, g as AttachmentTransform, C as ComposerAttachment, h as ComposerNotice, E as ELICITATION_MAX_OPTIONS, i as ELICITATION_TIMEOUT_MS, j as ELICITATION_VALUE_MAX_CHARS, k as ElicitationControl, l as ElicitationDraft, m as ElicitationDraftValue, n as ElicitationField, o as ElicitationFormOutcome, p as ElicitationIssue, q as ElicitationIssueKind, r as ElicitationLink, s as ElicitationOption, t as ElicitationOutcomeReason, u as ElicitationQueue, v as ElicitationQueueOptions, F as FileKind, I as INPUT_COUNTER_FROM, M as MenuSection, N as NotReadyInput, w as NotReadyIntent, x as NotReadyReason, y as NoticeTexts, P as PendingElicitation, S as SavedAttachments, z as SlashCommand, B as SteerIntent, T as TextExcerpt, W as WaitingSendStep, D as attachmentFileName, G as attachmentKindOf, H as attachmentLabel, J as attachmentOverLimit, K as attachmentRefusal, L as attachmentTransformOf, O as boxLength, Q as createElicitationQueue, R as dataUrlParts, U as defaultLabels, V as defaultNoticeTexts, X as elicitationConnectOptions, Y as elicitationFields, Z as elicitationFormAnswer, _ as elicitationInitialDraft, $ as elicitationLink, a0 as elicitationSettings, a1 as elicitationTimeoutOf, a2 as excerptNote, a3 as fileKindOf, a4 as fileNameOf, a5 as filterCommands, a6 as formatClock, a7 as formatCountdown, a8 as formatElapsed, a9 as freeAttachmentPath, aa as inputCounterShown, ab as insertionFits, ac as isOneCharacter, ad as lineCountOf, ae as longTextName, af as longTextRoute, ag as mediaFamilyOf, ah as menuKeyTarget, ai as menuSections, aj as mergeLabels, ak as messageOverLimit, al as micProblemText, am as notReadyIntent, an as notReadyReason, ao as noticesOf, ap as overflowOf, aq as parseSlash, ar as saveAttachments, as as steerIntent, at as textExcerpt, au as voiceMessageName, av as waitingSendStep, aw as withAttachments } from './labels-CCPL7t17.js';
|
|
5
6
|
export { A as ASK_USER_TOOL_NAME, P as PendingQuestion, a as QUESTION_TIMEOUT_MS, Q as QuestionOutcomeReason, b as QuestionQueue, c as QuestionQueueOptions, d as askUserOutputKept, e as askUserWith, f as createQuestionQueue, q as questionChoiceOf, g as questionOtherOf, h as questionTimeoutOf, w as withoutOwnWords } from './questions-Dw--IEjT.js';
|
|
6
7
|
import './mcp-app.js';
|
|
7
8
|
import './mcp-app-policy-DXKQ2jjM.js';
|
|
@@ -566,13 +567,19 @@ declare const coalesce: (fn: () => void, ms?: number) => {
|
|
|
566
567
|
call: () => void;
|
|
567
568
|
cancel: () => void;
|
|
568
569
|
};
|
|
570
|
+
/** What `listenToOtherTabs` / `followOtherTabs` take for the core: its module, or a loader of it. */
|
|
571
|
+
type StorageChangeSource = {
|
|
572
|
+
onStorageChange?: unknown;
|
|
573
|
+
} | (() => Promise<{
|
|
574
|
+
onStorageChange?: unknown;
|
|
575
|
+
}>);
|
|
569
576
|
/**
|
|
570
577
|
* The core's `onStorageChange`, or a no-op where the core predates it (the hooks then work as
|
|
571
|
-
* before: this tab's own changes only). One place for the guard every hook needs.
|
|
578
|
+
* before: this tab's own changes only). One place for the guard every hook needs. `core` may be a
|
|
579
|
+
* LOADER (`loadAgentCore`): it is called only when there is a database to follow, and the
|
|
580
|
+
* subscription starts once it resolves - so a view that follows nothing never loads the core.
|
|
572
581
|
*/
|
|
573
|
-
declare const listenToOtherTabs: (core: {
|
|
574
|
-
onStorageChange?: unknown;
|
|
575
|
-
}, dbName: string | undefined, listener: (change: {
|
|
582
|
+
declare const listenToOtherTabs: (core: StorageChangeSource, dbName: string | undefined, listener: (change: {
|
|
576
583
|
kind: string;
|
|
577
584
|
op: string;
|
|
578
585
|
key?: string;
|
|
@@ -583,9 +590,7 @@ declare const listenToOtherTabs: (core: {
|
|
|
583
590
|
* matters here), `settle` runs once, ~`ms` after the last accepted one of a burst. What every hook
|
|
584
591
|
* that follows other tabs uses. The returned function unsubscribes and drops a pending settle.
|
|
585
592
|
*/
|
|
586
|
-
declare const followOtherTabs: (core: {
|
|
587
|
-
onStorageChange?: unknown;
|
|
588
|
-
}, dbName: string | undefined, accept: (change: {
|
|
593
|
+
declare const followOtherTabs: (core: StorageChangeSource, dbName: string | undefined, accept: (change: {
|
|
589
594
|
kind: string;
|
|
590
595
|
op: string;
|
|
591
596
|
key?: string;
|
|
@@ -599,6 +604,19 @@ declare const followOtherTabs: (core: {
|
|
|
599
604
|
*/
|
|
600
605
|
declare const remoteAnswerOf: (ok: boolean, stillWatching: boolean) => "taken" | "refused" | "unknown";
|
|
601
606
|
|
|
607
|
+
/** The core's module (`@dudko.dev/agent-web`), as `loadAgentCore` resolves it. */
|
|
608
|
+
type AgentCoreModule = typeof Core;
|
|
609
|
+
/**
|
|
610
|
+
* The core, imported on the first call (a dynamic `import()`, the same module every time): what
|
|
611
|
+
* this package uses of the core at run time goes through here, never through a static import. A
|
|
612
|
+
* bundler then leaves the core - the AI SDK, zod, the providers - out of the page's first chunk,
|
|
613
|
+
* and a chat whose agent is on a server (`createRemoteAgentController`) never loads it at all.
|
|
614
|
+
* A failed import is tried again on the next call.
|
|
615
|
+
*/
|
|
616
|
+
declare const loadAgentCore: () => Promise<AgentCoreModule>;
|
|
617
|
+
/** The core if `loadAgentCore` has already resolved, else `undefined` (nothing is imported). */
|
|
618
|
+
declare const agentCoreIfLoaded: () => AgentCoreModule | undefined;
|
|
619
|
+
|
|
602
620
|
/**
|
|
603
621
|
* The sandboxed frame's security core: what untrusted HTML (a file the agent wrote, later an
|
|
604
622
|
* MCP App) is wrapped in before it reaches an `<iframe>`. Pure strings - no React, no DOM - so
|
|
@@ -993,5 +1011,5 @@ interface AudioSpeakerOptions {
|
|
|
993
1011
|
*/
|
|
994
1012
|
declare const createAudioSpeaker: (options: AudioSpeakerOptions) => SpeakText;
|
|
995
1013
|
|
|
996
|
-
export { AgentUiState, ApprovalView, ChatAttachment, ChatHistoryStore, ChatMessage, FOLLOW_LEAVE_PX, FOLLOW_REJOIN_PX, FRAME_MAX_HEIGHT, FRAME_MIN_HEIGHT, HTML_PREVIEW_MAX_CHARS, LessonView, MicError, NAMED_FILES_MAX, NAMED_FILES_SCAN_MAX, NAMED_FILES_TEXT_MAX, PROMPT_ARM_MS, RECORDING_DEFAULT_MAX_MS, RECORDING_TYPES, RemoteRunView, SpeechOutputError, SubagentNode, SubagentView, activeElementOf, agentStateReducer, agentStatusOf, attachmentsText, audioExtensionOf, audioTypeOf, buildSandboxedDocument, chatTitle, clampFrameHeight, coalesce, composedContains, createApprovalQueue, createAudioSpeaker, createBrowserSpeaker, createInitialAgentState, createPromptArming, createRecordingRecognizer, cspMetaTag, deepActiveElement, deepElementFromPoint, downscaleImage, endGap, errMessage, escapeAttribute, eventTargetOf, followOtherTabs, followsAfterResize, followsAfterScroll, formatDuration, formatProbability, formatTokens, imageSizeOf, imagesInOutput, isEventInside, isShadowRoot, languageOfText, lessonsOf, linkedFilesOf, listenScrollAround, listenToOtherTabs, mergeChatRecord, micProblemOf, namedFilesOf, newChatId, nothingFocused, ownUnsaved, pathsNamedIn, pendingApprovalsOf, pickRecordingType, portalHostOf, previewValue, recordingSupported, remoteAnswerOf, rootOf, sandboxTokens, sandboxedCsp, saveChat, scriptOfLanguage, scriptOfText, shadowRootsAround, speakableText, speechSynthesisSupported, splitForSpeech, startRecording, stopTracks, subagentTree, tokenizeHtml, unchangedSince, voiceFor, voicesOf, webSearchOf, withCspFirst, withPolicyFirst, workspacePathOf };
|
|
997
|
-
export type { AgentAction, ApprovalQueue, AttachmentTexts, AudioLike, AudioSpeakerOptions, BrowserSpeakerOptions, ChatBase, ChatHistoryStoreOptions, ChatRecord, ChatSummary, DownscaleOptions, ImageSize, MediaRecorderConstructorLike, MediaRecorderLike, MicProblem, NamedFilesOptions, PromptArming, ReadAloudState, RecordedAudio, Recording, RecordingDeps, RecordingRecognizerOptions, SandboxedDocumentOptions, ScrollMeasure, SourceToken, SpeakText, SpeakableOptions, SpeechPlayback, SpeechRecognizerLike, SpeechScript, SpeechSynthesisLike, SpeechUtteranceLike, SpeechVoiceLike, StartRecordingOptions, SynthesizeSpeech, TranscribeAudio, WebSearchResultView, WebSearchView };
|
|
1014
|
+
export { AgentUiState, ApprovalView, ChatAttachment, ChatHistoryStore, ChatMessage, FOLLOW_LEAVE_PX, FOLLOW_REJOIN_PX, FRAME_MAX_HEIGHT, FRAME_MIN_HEIGHT, HTML_PREVIEW_MAX_CHARS, LessonView, MicError, NAMED_FILES_MAX, NAMED_FILES_SCAN_MAX, NAMED_FILES_TEXT_MAX, PROMPT_ARM_MS, RECORDING_DEFAULT_MAX_MS, RECORDING_TYPES, RemoteRunView, SpeechOutputError, SubagentNode, SubagentView, activeElementOf, agentCoreIfLoaded, agentStateReducer, agentStatusOf, attachmentsText, audioExtensionOf, audioTypeOf, buildSandboxedDocument, chatTitle, clampFrameHeight, coalesce, composedContains, createApprovalQueue, createAudioSpeaker, createBrowserSpeaker, createInitialAgentState, createPromptArming, createRecordingRecognizer, cspMetaTag, deepActiveElement, deepElementFromPoint, downscaleImage, endGap, errMessage, escapeAttribute, eventTargetOf, followOtherTabs, followsAfterResize, followsAfterScroll, formatDuration, formatProbability, formatTokens, imageSizeOf, imagesInOutput, isEventInside, isShadowRoot, languageOfText, lessonsOf, linkedFilesOf, listenScrollAround, listenToOtherTabs, loadAgentCore, mergeChatRecord, micProblemOf, namedFilesOf, newChatId, nothingFocused, ownUnsaved, pathsNamedIn, pendingApprovalsOf, pickRecordingType, portalHostOf, previewValue, recordingSupported, remoteAnswerOf, rootOf, sandboxTokens, sandboxedCsp, saveChat, scriptOfLanguage, scriptOfText, shadowRootsAround, speakableText, speechSynthesisSupported, splitForSpeech, startRecording, stopTracks, subagentTree, tokenizeHtml, unchangedSince, voiceFor, voicesOf, webSearchOf, withCspFirst, withPolicyFirst, workspacePathOf };
|
|
1015
|
+
export type { AgentAction, AgentCoreModule, ApprovalQueue, AttachmentTexts, AudioLike, AudioSpeakerOptions, BrowserSpeakerOptions, ChatBase, ChatHistoryStoreOptions, ChatRecord, ChatSummary, DownscaleOptions, ImageSize, MediaRecorderConstructorLike, MediaRecorderLike, MicProblem, NamedFilesOptions, PromptArming, ReadAloudState, RecordedAudio, Recording, RecordingDeps, RecordingRecognizerOptions, SandboxedDocumentOptions, ScrollMeasure, SourceToken, SpeakText, SpeakableOptions, SpeechPlayback, SpeechRecognizerLike, SpeechScript, SpeechSynthesisLike, SpeechUtteranceLike, SpeechVoiceLike, StartRecordingOptions, StorageChangeSource, SynthesizeSpeech, TranscribeAudio, WebSearchResultView, WebSearchView };
|
package/dist/index.js
CHANGED
|
@@ -23,7 +23,10 @@ import {
|
|
|
23
23
|
} from "./chunk-TJBGZM6D.js";
|
|
24
24
|
import {
|
|
25
25
|
ASK_USER_TOOL_NAME,
|
|
26
|
+
MEDIA_AUDIO_TYPES_OF_CORE,
|
|
27
|
+
MEDIA_IMAGE_TYPES_OF_CORE,
|
|
26
28
|
QUESTION_TIMEOUT_MS,
|
|
29
|
+
agentCoreIfLoaded,
|
|
27
30
|
agentStateReducer,
|
|
28
31
|
agentStatusOf,
|
|
29
32
|
askUserOutputKept,
|
|
@@ -34,8 +37,10 @@ import {
|
|
|
34
37
|
createQuestionQueue,
|
|
35
38
|
errMessage,
|
|
36
39
|
followOtherTabs,
|
|
40
|
+
isTextMimeOfCore,
|
|
37
41
|
lessonsOf,
|
|
38
42
|
listenToOtherTabs,
|
|
43
|
+
loadAgentCore,
|
|
39
44
|
pendingApprovalsOf,
|
|
40
45
|
questionChoiceOf,
|
|
41
46
|
questionOtherOf,
|
|
@@ -43,7 +48,7 @@ import {
|
|
|
43
48
|
remoteAnswerOf,
|
|
44
49
|
subagentTree,
|
|
45
50
|
withoutOwnWords
|
|
46
|
-
} from "./chunk-
|
|
51
|
+
} from "./chunk-NHU6WQM5.js";
|
|
47
52
|
|
|
48
53
|
// src/composer.ts
|
|
49
54
|
var parseSlash = (text2) => {
|
|
@@ -940,22 +945,27 @@ var portalHostOf = (from, selector) => {
|
|
|
940
945
|
};
|
|
941
946
|
|
|
942
947
|
// src/file-kinds.ts
|
|
943
|
-
import { MEDIA_IMAGE_TYPES, isTextMime } from "@dudko.dev/agent-web";
|
|
944
948
|
var CODE = /\.(?:js|mjs|cjs|jsx|ts|tsx|css|scss|py|rb|go|rs|java|kt|c|h|cpp|cs|php|sh|sql|xml|svg|yaml|yml|toml)$/i;
|
|
945
949
|
var mimeOf = (mediaType) => mediaType.toLowerCase().split(";")[0].trim();
|
|
946
950
|
var fileKindOf = (path, mediaType) => {
|
|
947
951
|
const mime = mimeOf(mediaType);
|
|
948
|
-
if (Object.hasOwn(
|
|
952
|
+
if (Object.hasOwn(MEDIA_IMAGE_TYPES_OF_CORE, mime)) return "image";
|
|
949
953
|
if (mime === "text/html" || mime === "application/xhtml+xml" || /\.x?html?$/i.test(path))
|
|
950
954
|
return "html";
|
|
951
955
|
if (mime === "text/markdown" || /\.(?:md|markdown)$/i.test(path)) return "markdown";
|
|
952
956
|
if (mime === "text/csv" || /\.(?:csv|tsv)$/i.test(path)) return "csv";
|
|
953
957
|
if (mime === "application/json" || /\.json$/i.test(path)) return "json";
|
|
954
958
|
if (CODE.test(path)) return "code";
|
|
955
|
-
if (mime === "text/plain" || /\.(?:txt|log)$/i.test(path) ||
|
|
959
|
+
if (mime === "text/plain" || /\.(?:txt|log)$/i.test(path) || isTextMimeOfCore(mime)) return "text";
|
|
956
960
|
return "file";
|
|
957
961
|
};
|
|
958
962
|
var fileNameOf = (path) => path.split("/").filter(Boolean).pop() || "file";
|
|
963
|
+
var mediaFamilyOf = (mediaType) => {
|
|
964
|
+
const type = mimeOf(mediaType);
|
|
965
|
+
if (Object.hasOwn(MEDIA_IMAGE_TYPES_OF_CORE, type)) return "image";
|
|
966
|
+
if (Object.hasOwn(MEDIA_AUDIO_TYPES_OF_CORE, type)) return "audio";
|
|
967
|
+
return void 0;
|
|
968
|
+
};
|
|
959
969
|
|
|
960
970
|
// src/image-resize.ts
|
|
961
971
|
var canvasOf = (w, h) => {
|
|
@@ -1486,7 +1496,6 @@ var createPromptArming = (delayMs = PROMPT_ARM_MS) => {
|
|
|
1486
1496
|
};
|
|
1487
1497
|
|
|
1488
1498
|
// src/chat-history.ts
|
|
1489
|
-
import * as core from "@dudko.dev/agent-web";
|
|
1490
1499
|
var DB_VERSION = 1;
|
|
1491
1500
|
var req = (r) => new Promise((resolve, reject) => {
|
|
1492
1501
|
r.onsuccess = () => resolve(r.result);
|
|
@@ -1560,9 +1569,15 @@ var ChatHistoryStore = class {
|
|
|
1560
1569
|
this.announce(notice);
|
|
1561
1570
|
}
|
|
1562
1571
|
announce(notice) {
|
|
1563
|
-
|
|
1564
|
-
core
|
|
1565
|
-
|
|
1572
|
+
loadAgentCore().then(
|
|
1573
|
+
(core) => {
|
|
1574
|
+
if (typeof core.postStorageChange === "function") {
|
|
1575
|
+
core.postStorageChange(this.dbName, { kind: "chats", ...notice });
|
|
1576
|
+
}
|
|
1577
|
+
},
|
|
1578
|
+
() => {
|
|
1579
|
+
}
|
|
1580
|
+
);
|
|
1566
1581
|
}
|
|
1567
1582
|
/**
|
|
1568
1583
|
* Read the stored record and write what `merge` makes of it in ONE readwrite transaction: no
|
|
@@ -2363,6 +2378,7 @@ export {
|
|
|
2363
2378
|
RECORDING_TYPES,
|
|
2364
2379
|
SpeechOutputError,
|
|
2365
2380
|
activeElementOf,
|
|
2381
|
+
agentCoreIfLoaded,
|
|
2366
2382
|
agentStateReducer,
|
|
2367
2383
|
agentStatusOf,
|
|
2368
2384
|
askUserOutputKept,
|
|
@@ -2435,8 +2451,10 @@ export {
|
|
|
2435
2451
|
linkedFilesOf,
|
|
2436
2452
|
listenScrollAround,
|
|
2437
2453
|
listenToOtherTabs,
|
|
2454
|
+
loadAgentCore,
|
|
2438
2455
|
longTextName,
|
|
2439
2456
|
longTextRoute,
|
|
2457
|
+
mediaFamilyOf,
|
|
2440
2458
|
menuKeyTarget,
|
|
2441
2459
|
menuSections,
|
|
2442
2460
|
mergeChatRecord,
|
|
@@ -571,6 +571,11 @@ type FileKind = 'html' | 'markdown' | 'csv' | 'json' | 'image' | 'code' | 'text'
|
|
|
571
571
|
declare const fileKindOf: (path: string, mediaType: string) => FileKind;
|
|
572
572
|
/** The last segment of a path: what a chip is called and what a download is saved as. */
|
|
573
573
|
declare const fileNameOf: (path: string) => string;
|
|
574
|
+
/**
|
|
575
|
+
* How a generated file may be shown: only the types the core's media tools accept
|
|
576
|
+
* (PNG / JPEG / GIF / WebP, and its audio list). Anything else - SVG included - is a file chip.
|
|
577
|
+
*/
|
|
578
|
+
declare const mediaFamilyOf: (mediaType: string) => "image" | "audio" | undefined;
|
|
574
579
|
|
|
575
580
|
/**
|
|
576
581
|
* Every string the pre-styled components render — override any of them for
|
|
@@ -1174,5 +1179,5 @@ type AgentLabelsOverride = Partial<Omit<AgentLabels, 'status' | 'modes' | 'comma
|
|
|
1174
1179
|
/** `base` with `over` applied (nested groups merged, not replaced). */
|
|
1175
1180
|
declare const mergeLabels: (base: AgentLabels, over?: AgentLabelsOverride) => AgentLabels;
|
|
1176
1181
|
|
|
1177
|
-
export { elicitationLink as $, attachmentFileName as D, ELICITATION_MAX_OPTIONS as E, attachmentKindOf as G, attachmentLabel as H, INPUT_COUNTER_FROM as I, attachmentOverLimit as J, attachmentRefusal as K, attachmentTransformOf as L, boxLength as O, createElicitationQueue as Q, dataUrlParts as R, defaultLabels as U, defaultNoticeTexts as V, elicitationConnectOptions as X, elicitationFields as Y, elicitationFormAnswer as Z, elicitationInitialDraft as _, ATTACHMENT_BOUNDS as a, elicitationSettings as a0, elicitationTimeoutOf as a1, excerptNote as a2, fileKindOf as a3, fileNameOf as a4, filterCommands as a5, formatClock as a6, formatCountdown as a7, formatElapsed as a8, freeAttachmentPath as a9, inputCounterShown as aa, insertionFits as ab, isOneCharacter as ac, lineCountOf as ad, longTextName as ae, longTextRoute as af,
|
|
1182
|
+
export { elicitationLink as $, attachmentFileName as D, ELICITATION_MAX_OPTIONS as E, attachmentKindOf as G, attachmentLabel as H, INPUT_COUNTER_FROM as I, attachmentOverLimit as J, attachmentRefusal as K, attachmentTransformOf as L, boxLength as O, createElicitationQueue as Q, dataUrlParts as R, defaultLabels as U, defaultNoticeTexts as V, elicitationConnectOptions as X, elicitationFields as Y, elicitationFormAnswer as Z, elicitationInitialDraft as _, ATTACHMENT_BOUNDS as a, elicitationSettings as a0, elicitationTimeoutOf as a1, excerptNote as a2, fileKindOf as a3, fileNameOf as a4, filterCommands as a5, formatClock as a6, formatCountdown as a7, formatElapsed as a8, freeAttachmentPath as a9, inputCounterShown as aa, insertionFits as ab, isOneCharacter as ac, lineCountOf as ad, longTextName as ae, longTextRoute as af, mediaFamilyOf as ag, menuKeyTarget as ah, menuSections as ai, mergeLabels as aj, messageOverLimit as ak, micProblemText as al, notReadyIntent as am, notReadyReason as an, noticesOf as ao, overflowOf as ap, parseSlash as aq, saveAttachments as ar, steerIntent as as, textExcerpt as at, voiceMessageName as au, waitingSendStep as av, withAttachments as aw, ELICITATION_TIMEOUT_MS as i, ELICITATION_VALUE_MAX_CHARS as j };
|
|
1178
1183
|
export type { AgentLabelsOverride as A, SteerIntent as B, ComposerAttachment as C, FileKind as F, MenuSection as M, NotReadyInput as N, PendingElicitation as P, SavedAttachments as S, TextExcerpt as T, WaitingSendStep as W, AgentLabels as b, AttachmentBounds as c, AttachmentFiles as d, AttachmentOverLimit as e, AttachmentTextOptions as f, AttachmentTransform as g, ComposerNotice as h, ElicitationControl as k, ElicitationDraft as l, ElicitationDraftValue as m, ElicitationField as n, ElicitationFormOutcome as o, ElicitationIssue as p, ElicitationIssueKind as q, ElicitationLink as r, ElicitationOption as s, ElicitationOutcomeReason as t, ElicitationQueue as u, ElicitationQueueOptions as v, NotReadyIntent as w, NotReadyReason as x, NoticeTexts as y, SlashCommand as z };
|
|
@@ -571,6 +571,11 @@ type FileKind = 'html' | 'markdown' | 'csv' | 'json' | 'image' | 'code' | 'text'
|
|
|
571
571
|
declare const fileKindOf: (path: string, mediaType: string) => FileKind;
|
|
572
572
|
/** The last segment of a path: what a chip is called and what a download is saved as. */
|
|
573
573
|
declare const fileNameOf: (path: string) => string;
|
|
574
|
+
/**
|
|
575
|
+
* How a generated file may be shown: only the types the core's media tools accept
|
|
576
|
+
* (PNG / JPEG / GIF / WebP, and its audio list). Anything else - SVG included - is a file chip.
|
|
577
|
+
*/
|
|
578
|
+
declare const mediaFamilyOf: (mediaType: string) => "image" | "audio" | undefined;
|
|
574
579
|
|
|
575
580
|
/**
|
|
576
581
|
* Every string the pre-styled components render — override any of them for
|
|
@@ -1174,5 +1179,5 @@ type AgentLabelsOverride = Partial<Omit<AgentLabels, 'status' | 'modes' | 'comma
|
|
|
1174
1179
|
/** `base` with `over` applied (nested groups merged, not replaced). */
|
|
1175
1180
|
declare const mergeLabels: (base: AgentLabels, over?: AgentLabelsOverride) => AgentLabels;
|
|
1176
1181
|
|
|
1177
|
-
export { elicitationLink as $, attachmentFileName as D, ELICITATION_MAX_OPTIONS as E, attachmentKindOf as G, attachmentLabel as H, INPUT_COUNTER_FROM as I, attachmentOverLimit as J, attachmentRefusal as K, attachmentTransformOf as L, boxLength as O, createElicitationQueue as Q, dataUrlParts as R, defaultLabels as U, defaultNoticeTexts as V, elicitationConnectOptions as X, elicitationFields as Y, elicitationFormAnswer as Z, elicitationInitialDraft as _, ATTACHMENT_BOUNDS as a, elicitationSettings as a0, elicitationTimeoutOf as a1, excerptNote as a2, fileKindOf as a3, fileNameOf as a4, filterCommands as a5, formatClock as a6, formatCountdown as a7, formatElapsed as a8, freeAttachmentPath as a9, inputCounterShown as aa, insertionFits as ab, isOneCharacter as ac, lineCountOf as ad, longTextName as ae, longTextRoute as af,
|
|
1182
|
+
export { elicitationLink as $, attachmentFileName as D, ELICITATION_MAX_OPTIONS as E, attachmentKindOf as G, attachmentLabel as H, INPUT_COUNTER_FROM as I, attachmentOverLimit as J, attachmentRefusal as K, attachmentTransformOf as L, boxLength as O, createElicitationQueue as Q, dataUrlParts as R, defaultLabels as U, defaultNoticeTexts as V, elicitationConnectOptions as X, elicitationFields as Y, elicitationFormAnswer as Z, elicitationInitialDraft as _, ATTACHMENT_BOUNDS as a, elicitationSettings as a0, elicitationTimeoutOf as a1, excerptNote as a2, fileKindOf as a3, fileNameOf as a4, filterCommands as a5, formatClock as a6, formatCountdown as a7, formatElapsed as a8, freeAttachmentPath as a9, inputCounterShown as aa, insertionFits as ab, isOneCharacter as ac, lineCountOf as ad, longTextName as ae, longTextRoute as af, mediaFamilyOf as ag, menuKeyTarget as ah, menuSections as ai, mergeLabels as aj, messageOverLimit as ak, micProblemText as al, notReadyIntent as am, notReadyReason as an, noticesOf as ao, overflowOf as ap, parseSlash as aq, saveAttachments as ar, steerIntent as as, textExcerpt as at, voiceMessageName as au, waitingSendStep as av, withAttachments as aw, ELICITATION_TIMEOUT_MS as i, ELICITATION_VALUE_MAX_CHARS as j };
|
|
1178
1183
|
export type { AgentLabelsOverride as A, SteerIntent as B, ComposerAttachment as C, FileKind as F, MenuSection as M, NotReadyInput as N, PendingElicitation as P, SavedAttachments as S, TextExcerpt as T, WaitingSendStep as W, AgentLabels as b, AttachmentBounds as c, AttachmentFiles as d, AttachmentOverLimit as e, AttachmentTextOptions as f, AttachmentTransform as g, ComposerNotice as h, ElicitationControl as k, ElicitationDraft as l, ElicitationDraftValue as m, ElicitationField as n, ElicitationFormOutcome as o, ElicitationIssue as p, ElicitationIssueKind as q, ElicitationLink as r, ElicitationOption as s, ElicitationOutcomeReason as t, ElicitationQueue as u, ElicitationQueueOptions as v, NotReadyIntent as w, NotReadyReason as x, NoticeTexts as y, SlashCommand as z };
|
package/dist/mcp-app.cjs
CHANGED
|
@@ -85,9 +85,6 @@ __export(mcp_app_entry_exports, {
|
|
|
85
85
|
});
|
|
86
86
|
module.exports = __toCommonJS(mcp_app_entry_exports);
|
|
87
87
|
|
|
88
|
-
// src/mcp-app.ts
|
|
89
|
-
var import_agent_web = require("@dudko.dev/agent-web");
|
|
90
|
-
|
|
91
88
|
// src/html-preview.ts
|
|
92
89
|
var escapeAttribute = (value) => value.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
|
93
90
|
var cspMetaTag = (policy) => `<meta http-equiv="Content-Security-Policy" content="${escapeAttribute(policy)}">`;
|
|
@@ -213,7 +210,7 @@ var clampAppHeight = (height, max = APP_MAX_HEIGHT) => Math.min(
|
|
|
213
210
|
var origins = (list) => {
|
|
214
211
|
const out = [];
|
|
215
212
|
for (const entry of list ?? []) {
|
|
216
|
-
const origin = (
|
|
213
|
+
const origin = mcpAppPolicyOrigin(entry);
|
|
217
214
|
if (origin && !out.includes(origin)) out.push(origin);
|
|
218
215
|
}
|
|
219
216
|
return out;
|
package/dist/mcp-app.js
CHANGED
|
@@ -18,7 +18,6 @@ import {
|
|
|
18
18
|
} from "./chunk-WEYQMUKY.js";
|
|
19
19
|
|
|
20
20
|
// src/mcp-app.ts
|
|
21
|
-
import { mcpAppOrigin } from "@dudko.dev/agent-web";
|
|
22
21
|
var MCP_APP_PROTOCOL_VERSION = "2026-01-26";
|
|
23
22
|
var APP_DEFAULT_HEIGHT = 360;
|
|
24
23
|
var APP_MIN_HEIGHT = 120;
|
|
@@ -50,7 +49,7 @@ var clampAppHeight = (height, max = APP_MAX_HEIGHT) => Math.min(
|
|
|
50
49
|
var origins = (list) => {
|
|
51
50
|
const out = [];
|
|
52
51
|
for (const entry of list ?? []) {
|
|
53
|
-
const origin =
|
|
52
|
+
const origin = mcpAppPolicyOrigin(entry);
|
|
54
53
|
if (origin && !out.includes(origin)) out.push(origin);
|
|
55
54
|
}
|
|
56
55
|
return out;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dudko.dev/agent-web-ui",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The framework-free UI logic of @dudko.dev/agent-web, the in-browser LLM agent: the headless reducer that turns the agent's events into UI state, every UI string, the composer's and transcript's pure helpers, voice, saved chats, the sandboxed-frame and MCP Apps security cores, the MCP Apps sandbox page for a server, and the pipeline editor's logic - plus the stylesheets. No React: build a front end for any framework on it.",
|
|
6
6
|
"type": "module",
|
|
@@ -182,8 +182,8 @@
|
|
|
182
182
|
"prettier": "^3.10.1",
|
|
183
183
|
"tsup": "^9.0.0",
|
|
184
184
|
"typescript": "^6.0.3",
|
|
185
|
-
"@dudko.dev/
|
|
186
|
-
"@dudko.dev/
|
|
185
|
+
"@dudko.dev/agent-web": "0.0.54",
|
|
186
|
+
"@dudko.dev/test-servers": "0.0.0"
|
|
187
187
|
},
|
|
188
188
|
"scripts": {
|
|
189
189
|
"build": "tsup",
|