@dudko.dev/agent-web-ui 0.0.4 → 0.0.5
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 +24 -5
- package/dist/{chunk-G7LQTOA2.js → chunk-NHU6WQM5.js} +61 -6
- package/dist/controller.cjs +61 -15
- package/dist/controller.js +22 -15
- 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.
|
|
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
|
|
@@ -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 () => {
|
|
@@ -2085,7 +2119,7 @@ var createAgentController = (initialConfig, initialOptions = {}) => {
|
|
|
2085
2119
|
cancelled = true;
|
|
2086
2120
|
};
|
|
2087
2121
|
setBuildStatus({ status: "initializing" });
|
|
2088
|
-
(
|
|
2122
|
+
loadAgentCore().then((core) => core.createAgent(built)).then((next) => {
|
|
2089
2123
|
if (cancelled) return;
|
|
2090
2124
|
next.setToolApprovalMode(mode);
|
|
2091
2125
|
agent = next;
|
|
@@ -2106,11 +2140,22 @@ var createAgentController = (initialConfig, initialOptions = {}) => {
|
|
|
2106
2140
|
const syncWatch = () => {
|
|
2107
2141
|
const db = options.watch !== false && config.sessionLock !== "off" ? dbNameOf(config.memory) : void 0;
|
|
2108
2142
|
if (watched && watched.db === db && watched.sessionId === sessionId) return;
|
|
2143
|
+
const core = agentCoreIfLoaded();
|
|
2144
|
+
if (db && !core) {
|
|
2145
|
+
loadAgentCore().then(
|
|
2146
|
+
() => {
|
|
2147
|
+
if (!disposed) syncWatch();
|
|
2148
|
+
},
|
|
2149
|
+
() => {
|
|
2150
|
+
}
|
|
2151
|
+
);
|
|
2152
|
+
return;
|
|
2153
|
+
}
|
|
2109
2154
|
closeWatch();
|
|
2110
2155
|
watched = { db, sessionId };
|
|
2111
|
-
const
|
|
2112
|
-
if (!db || typeof
|
|
2113
|
-
watch =
|
|
2156
|
+
const watchSession = core?.watchSession;
|
|
2157
|
+
if (!db || typeof watchSession !== "function") return;
|
|
2158
|
+
watch = watchSession({
|
|
2114
2159
|
dbName: db,
|
|
2115
2160
|
sessionId,
|
|
2116
2161
|
onEvent: (event) => {
|
|
@@ -2144,7 +2189,7 @@ var createAgentController = (initialConfig, initialOptions = {}) => {
|
|
|
2144
2189
|
unfollowSkills?.();
|
|
2145
2190
|
skillsDb = { db };
|
|
2146
2191
|
unfollowSkills = followOtherTabs(
|
|
2147
|
-
|
|
2192
|
+
loadAgentCore,
|
|
2148
2193
|
db,
|
|
2149
2194
|
(change) => change.kind === "skills",
|
|
2150
2195
|
() => {
|
|
@@ -2157,10 +2202,11 @@ var createAgentController = (initialConfig, initialOptions = {}) => {
|
|
|
2157
2202
|
};
|
|
2158
2203
|
const run = async (goal, runOptions) => {
|
|
2159
2204
|
const current = agent;
|
|
2160
|
-
|
|
2205
|
+
const core = agentCoreIfLoaded();
|
|
2206
|
+
if (disposed || !current || abort || !core) return void 0;
|
|
2161
2207
|
const controller = new AbortController();
|
|
2162
2208
|
abort = controller;
|
|
2163
|
-
const runControl =
|
|
2209
|
+
const runControl = core.createRunControl();
|
|
2164
2210
|
control = runControl;
|
|
2165
2211
|
let left = [];
|
|
2166
2212
|
let stopped = false;
|
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) => {
|
|
@@ -673,7 +668,7 @@ var createAgentController = (initialConfig, initialOptions = {}) => {
|
|
|
673
668
|
cancelled = true;
|
|
674
669
|
};
|
|
675
670
|
setBuildStatus({ status: "initializing" });
|
|
676
|
-
createAgent(built).then((next) => {
|
|
671
|
+
loadAgentCore().then((core) => core.createAgent(built)).then((next) => {
|
|
677
672
|
if (cancelled) return;
|
|
678
673
|
next.setToolApprovalMode(mode);
|
|
679
674
|
agent = next;
|
|
@@ -694,11 +689,22 @@ var createAgentController = (initialConfig, initialOptions = {}) => {
|
|
|
694
689
|
const syncWatch = () => {
|
|
695
690
|
const db = options.watch !== false && config.sessionLock !== "off" ? dbNameOf(config.memory) : void 0;
|
|
696
691
|
if (watched && watched.db === db && watched.sessionId === sessionId) return;
|
|
692
|
+
const core = agentCoreIfLoaded();
|
|
693
|
+
if (db && !core) {
|
|
694
|
+
loadAgentCore().then(
|
|
695
|
+
() => {
|
|
696
|
+
if (!disposed) syncWatch();
|
|
697
|
+
},
|
|
698
|
+
() => {
|
|
699
|
+
}
|
|
700
|
+
);
|
|
701
|
+
return;
|
|
702
|
+
}
|
|
697
703
|
closeWatch();
|
|
698
704
|
watched = { db, sessionId };
|
|
699
|
-
const
|
|
700
|
-
if (!db || typeof
|
|
701
|
-
watch =
|
|
705
|
+
const watchSession = core?.watchSession;
|
|
706
|
+
if (!db || typeof watchSession !== "function") return;
|
|
707
|
+
watch = watchSession({
|
|
702
708
|
dbName: db,
|
|
703
709
|
sessionId,
|
|
704
710
|
onEvent: (event) => {
|
|
@@ -732,7 +738,7 @@ var createAgentController = (initialConfig, initialOptions = {}) => {
|
|
|
732
738
|
unfollowSkills?.();
|
|
733
739
|
skillsDb = { db };
|
|
734
740
|
unfollowSkills = followOtherTabs(
|
|
735
|
-
|
|
741
|
+
loadAgentCore,
|
|
736
742
|
db,
|
|
737
743
|
(change) => change.kind === "skills",
|
|
738
744
|
() => {
|
|
@@ -745,10 +751,11 @@ var createAgentController = (initialConfig, initialOptions = {}) => {
|
|
|
745
751
|
};
|
|
746
752
|
const run = async (goal, runOptions) => {
|
|
747
753
|
const current = agent;
|
|
748
|
-
|
|
754
|
+
const core = agentCoreIfLoaded();
|
|
755
|
+
if (disposed || !current || abort || !core) return void 0;
|
|
749
756
|
const controller = new AbortController();
|
|
750
757
|
abort = controller;
|
|
751
|
-
const runControl = createRunControl();
|
|
758
|
+
const runControl = core.createRunControl();
|
|
752
759
|
control = runControl;
|
|
753
760
|
let left = [];
|
|
754
761
|
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.5",
|
|
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",
|