@dudko.dev/agent-web-ui 0.0.0 → 0.0.1
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/LICENSE +21 -0
- package/README.md +251 -5
- package/dist/canvas.cjs +266 -0
- package/dist/canvas.cjs.map +1 -0
- package/dist/canvas.d.cts +105 -0
- package/dist/canvas.d.ts +105 -0
- package/dist/canvas.js +200 -0
- package/dist/canvas.js.map +1 -0
- package/dist/chunk-4EHUITGU.js +342 -0
- package/dist/chunk-4EHUITGU.js.map +1 -0
- package/dist/chunk-7O64ZI6Z.js +125 -0
- package/dist/chunk-7O64ZI6Z.js.map +1 -0
- package/dist/chunk-A55Q377T.js +342 -0
- package/dist/chunk-A55Q377T.js.map +1 -0
- package/dist/chunk-EL2YCROY.js +127 -0
- package/dist/chunk-EL2YCROY.js.map +1 -0
- package/dist/chunk-GB7RZJMG.js +98 -0
- package/dist/chunk-GB7RZJMG.js.map +1 -0
- package/dist/chunk-KZQB35LS.js +22 -0
- package/dist/chunk-KZQB35LS.js.map +1 -0
- package/dist/chunk-P2F2P3JC.js +400 -0
- package/dist/chunk-P2F2P3JC.js.map +1 -0
- package/dist/chunk-TPK25QGK.js +342 -0
- package/dist/chunk-TPK25QGK.js.map +1 -0
- package/dist/en-CcNUz2tN.d.cts +342 -0
- package/dist/en-CcNUz2tN.d.ts +342 -0
- package/dist/index.cjs +4143 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +919 -0
- package/dist/index.d.ts +919 -0
- package/dist/index.js +3771 -0
- package/dist/index.js.map +1 -0
- package/dist/labels-B5xpIGf_.d.cts +25 -0
- package/dist/labels-B5xpIGf_.d.ts +25 -0
- package/dist/labels-D5BrHct4.d.cts +1208 -0
- package/dist/labels-UuWI7wPo.d.ts +1208 -0
- package/dist/locales/be.cjs +794 -0
- package/dist/locales/be.cjs.map +1 -0
- package/dist/locales/be.d.cts +14 -0
- package/dist/locales/be.d.ts +14 -0
- package/dist/locales/be.js +374 -0
- package/dist/locales/be.js.map +1 -0
- package/dist/locales/bg.cjs +747 -0
- package/dist/locales/bg.cjs.map +1 -0
- package/dist/locales/bg.d.cts +14 -0
- package/dist/locales/bg.d.ts +14 -0
- package/dist/locales/bg.js +327 -0
- package/dist/locales/bg.js.map +1 -0
- package/dist/locales/ca.cjs +773 -0
- package/dist/locales/ca.cjs.map +1 -0
- package/dist/locales/ca.d.cts +14 -0
- package/dist/locales/ca.d.ts +14 -0
- package/dist/locales/ca.js +353 -0
- package/dist/locales/ca.js.map +1 -0
- package/dist/locales/cs.cjs +794 -0
- package/dist/locales/cs.cjs.map +1 -0
- package/dist/locales/cs.d.cts +14 -0
- package/dist/locales/cs.d.ts +14 -0
- package/dist/locales/cs.js +374 -0
- package/dist/locales/cs.js.map +1 -0
- package/dist/locales/da.cjs +747 -0
- package/dist/locales/da.cjs.map +1 -0
- package/dist/locales/da.d.cts +14 -0
- package/dist/locales/da.d.ts +14 -0
- package/dist/locales/da.js +327 -0
- package/dist/locales/da.js.map +1 -0
- package/dist/locales/de.cjs +756 -0
- package/dist/locales/de.cjs.map +1 -0
- package/dist/locales/de.d.cts +14 -0
- package/dist/locales/de.d.ts +14 -0
- package/dist/locales/de.js +336 -0
- package/dist/locales/de.js.map +1 -0
- package/dist/locales/el.cjs +756 -0
- package/dist/locales/el.cjs.map +1 -0
- package/dist/locales/el.d.cts +14 -0
- package/dist/locales/el.d.ts +14 -0
- package/dist/locales/el.js +336 -0
- package/dist/locales/el.js.map +1 -0
- package/dist/locales/en.cjs +753 -0
- package/dist/locales/en.cjs.map +1 -0
- package/dist/locales/en.d.cts +10 -0
- package/dist/locales/en.d.ts +10 -0
- package/dist/locales/en.js +333 -0
- package/dist/locales/en.js.map +1 -0
- package/dist/locales/es-419.cjs +778 -0
- package/dist/locales/es-419.cjs.map +1 -0
- package/dist/locales/es-419.d.cts +16 -0
- package/dist/locales/es-419.d.ts +16 -0
- package/dist/locales/es-419.js +23 -0
- package/dist/locales/es-419.js.map +1 -0
- package/dist/locales/es.cjs +769 -0
- package/dist/locales/es.cjs.map +1 -0
- package/dist/locales/es.d.cts +14 -0
- package/dist/locales/es.d.ts +14 -0
- package/dist/locales/es.js +14 -0
- package/dist/locales/es.js.map +1 -0
- package/dist/locales/fi.cjs +753 -0
- package/dist/locales/fi.cjs.map +1 -0
- package/dist/locales/fi.d.cts +14 -0
- package/dist/locales/fi.d.ts +14 -0
- package/dist/locales/fi.js +333 -0
- package/dist/locales/fi.js.map +1 -0
- package/dist/locales/fr-CA.cjs +777 -0
- package/dist/locales/fr-CA.cjs.map +1 -0
- package/dist/locales/fr-CA.d.cts +17 -0
- package/dist/locales/fr-CA.d.ts +17 -0
- package/dist/locales/fr-CA.js +22 -0
- package/dist/locales/fr-CA.js.map +1 -0
- package/dist/locales/fr.cjs +769 -0
- package/dist/locales/fr.cjs.map +1 -0
- package/dist/locales/fr.d.cts +14 -0
- package/dist/locales/fr.d.ts +14 -0
- package/dist/locales/fr.js +14 -0
- package/dist/locales/fr.js.map +1 -0
- package/dist/locales/gn.cjs +750 -0
- package/dist/locales/gn.cjs.map +1 -0
- package/dist/locales/gn.d.cts +16 -0
- package/dist/locales/gn.d.ts +16 -0
- package/dist/locales/gn.js +330 -0
- package/dist/locales/gn.js.map +1 -0
- package/dist/locales/hr.cjs +769 -0
- package/dist/locales/hr.cjs.map +1 -0
- package/dist/locales/hr.d.cts +14 -0
- package/dist/locales/hr.d.ts +14 -0
- package/dist/locales/hr.js +349 -0
- package/dist/locales/hr.js.map +1 -0
- package/dist/locales/ht.cjs +750 -0
- package/dist/locales/ht.cjs.map +1 -0
- package/dist/locales/ht.d.cts +16 -0
- package/dist/locales/ht.d.ts +16 -0
- package/dist/locales/ht.js +330 -0
- package/dist/locales/ht.js.map +1 -0
- package/dist/locales/hu.cjs +753 -0
- package/dist/locales/hu.cjs.map +1 -0
- package/dist/locales/hu.d.cts +14 -0
- package/dist/locales/hu.d.ts +14 -0
- package/dist/locales/hu.js +333 -0
- package/dist/locales/hu.js.map +1 -0
- package/dist/locales/index.cjs +537 -0
- package/dist/locales/index.cjs.map +1 -0
- package/dist/locales/index.d.cts +38 -0
- package/dist/locales/index.d.ts +38 -0
- package/dist/locales/index.js +105 -0
- package/dist/locales/index.js.map +1 -0
- package/dist/locales/it.cjs +777 -0
- package/dist/locales/it.cjs.map +1 -0
- package/dist/locales/it.d.cts +14 -0
- package/dist/locales/it.d.ts +14 -0
- package/dist/locales/it.js +357 -0
- package/dist/locales/it.js.map +1 -0
- package/dist/locales/nb.cjs +747 -0
- package/dist/locales/nb.cjs.map +1 -0
- package/dist/locales/nb.d.cts +14 -0
- package/dist/locales/nb.d.ts +14 -0
- package/dist/locales/nb.js +327 -0
- package/dist/locales/nb.js.map +1 -0
- package/dist/locales/nl.cjs +753 -0
- package/dist/locales/nl.cjs.map +1 -0
- package/dist/locales/nl.d.cts +14 -0
- package/dist/locales/nl.d.ts +14 -0
- package/dist/locales/nl.js +333 -0
- package/dist/locales/nl.js.map +1 -0
- package/dist/locales/pl.cjs +794 -0
- package/dist/locales/pl.cjs.map +1 -0
- package/dist/locales/pl.d.cts +14 -0
- package/dist/locales/pl.d.ts +14 -0
- package/dist/locales/pl.js +374 -0
- package/dist/locales/pl.js.map +1 -0
- package/dist/locales/pt-BR.cjs +773 -0
- package/dist/locales/pt-BR.cjs.map +1 -0
- package/dist/locales/pt-BR.d.cts +14 -0
- package/dist/locales/pt-BR.d.ts +14 -0
- package/dist/locales/pt-BR.js +353 -0
- package/dist/locales/pt-BR.js.map +1 -0
- package/dist/locales/pt.cjs +777 -0
- package/dist/locales/pt.cjs.map +1 -0
- package/dist/locales/pt.d.cts +14 -0
- package/dist/locales/pt.d.ts +14 -0
- package/dist/locales/pt.js +357 -0
- package/dist/locales/pt.js.map +1 -0
- package/dist/locales/qu.cjs +756 -0
- package/dist/locales/qu.cjs.map +1 -0
- package/dist/locales/qu.d.cts +16 -0
- package/dist/locales/qu.d.ts +16 -0
- package/dist/locales/qu.js +336 -0
- package/dist/locales/qu.js.map +1 -0
- package/dist/locales/ro.cjs +769 -0
- package/dist/locales/ro.cjs.map +1 -0
- package/dist/locales/ro.d.cts +14 -0
- package/dist/locales/ro.d.ts +14 -0
- package/dist/locales/ro.js +349 -0
- package/dist/locales/ro.js.map +1 -0
- package/dist/locales/ru.cjs +789 -0
- package/dist/locales/ru.cjs.map +1 -0
- package/dist/locales/ru.d.cts +14 -0
- package/dist/locales/ru.d.ts +14 -0
- package/dist/locales/ru.js +369 -0
- package/dist/locales/ru.js.map +1 -0
- package/dist/locales/sk.cjs +794 -0
- package/dist/locales/sk.cjs.map +1 -0
- package/dist/locales/sk.d.cts +14 -0
- package/dist/locales/sk.d.ts +14 -0
- package/dist/locales/sk.js +374 -0
- package/dist/locales/sk.js.map +1 -0
- package/dist/locales/sq.cjs +753 -0
- package/dist/locales/sq.cjs.map +1 -0
- package/dist/locales/sq.d.cts +14 -0
- package/dist/locales/sq.d.ts +14 -0
- package/dist/locales/sq.js +333 -0
- package/dist/locales/sq.js.map +1 -0
- package/dist/locales/sr-Latn.cjs +841 -0
- package/dist/locales/sr-Latn.cjs.map +1 -0
- package/dist/locales/sr-Latn.d.cts +17 -0
- package/dist/locales/sr-Latn.d.ts +17 -0
- package/dist/locales/sr-Latn.js +86 -0
- package/dist/locales/sr-Latn.js.map +1 -0
- package/dist/locales/sr.cjs +769 -0
- package/dist/locales/sr.cjs.map +1 -0
- package/dist/locales/sr.d.cts +14 -0
- package/dist/locales/sr.d.ts +14 -0
- package/dist/locales/sr.js +14 -0
- package/dist/locales/sr.js.map +1 -0
- package/dist/locales/sv.cjs +753 -0
- package/dist/locales/sv.cjs.map +1 -0
- package/dist/locales/sv.d.cts +14 -0
- package/dist/locales/sv.d.ts +14 -0
- package/dist/locales/sv.js +333 -0
- package/dist/locales/sv.js.map +1 -0
- package/dist/locales/tr.cjs +750 -0
- package/dist/locales/tr.cjs.map +1 -0
- package/dist/locales/tr.d.cts +14 -0
- package/dist/locales/tr.d.ts +14 -0
- package/dist/locales/tr.js +330 -0
- package/dist/locales/tr.js.map +1 -0
- package/dist/locales/uk.cjs +794 -0
- package/dist/locales/uk.cjs.map +1 -0
- package/dist/locales/uk.d.cts +14 -0
- package/dist/locales/uk.d.ts +14 -0
- package/dist/locales/uk.js +374 -0
- package/dist/locales/uk.js.map +1 -0
- package/dist/markdown.cjs +620 -0
- package/dist/markdown.cjs.map +1 -0
- package/dist/markdown.d.cts +153 -0
- package/dist/markdown.d.ts +153 -0
- package/dist/markdown.js +573 -0
- package/dist/markdown.js.map +1 -0
- package/dist/mcp-app-entry-BA-Ca39z.d.ts +1480 -0
- package/dist/mcp-app-entry-tybABaHg.d.cts +1480 -0
- package/dist/mcp-app-policy-DXKQ2jjM.d.cts +73 -0
- package/dist/mcp-app-policy-DXKQ2jjM.d.ts +73 -0
- package/dist/mcp-app-sandbox.cjs +323 -0
- package/dist/mcp-app-sandbox.cjs.map +1 -0
- package/dist/mcp-app-sandbox.d.cts +70 -0
- package/dist/mcp-app-sandbox.d.ts +70 -0
- package/dist/mcp-app-sandbox.js +209 -0
- package/dist/mcp-app-sandbox.js.map +1 -0
- package/dist/mcp-app.cjs +980 -0
- package/dist/mcp-app.cjs.map +1 -0
- package/dist/mcp-app.d.cts +3 -0
- package/dist/mcp-app.d.ts +3 -0
- package/dist/mcp-app.js +816 -0
- package/dist/mcp-app.js.map +1 -0
- package/dist/pipeline.cjs +845 -0
- package/dist/pipeline.cjs.map +1 -0
- package/dist/pipeline.css +1407 -0
- package/dist/pipeline.d.cts +348 -0
- package/dist/pipeline.d.ts +348 -0
- package/dist/pipeline.js +778 -0
- package/dist/pipeline.js.map +1 -0
- package/dist/styles.css +4109 -0
- package/dist/types-BmvgYUzF.d.cts +19 -0
- package/dist/types-Cr5gmUts.d.ts +19 -0
- package/package.json +155 -8
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Siarhei Dudko
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,9 +1,255 @@
|
|
|
1
1
|
# @dudko.dev/agent-web-ui
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/@dudko.dev/agent-web-ui)
|
|
4
|
+
[](https://github.com/dudko-dev/agents/blob/main/LICENSE)
|
|
5
|
+
[](https://github.com/dudko-dev/agents/commits/main/packages/agent-web-ui)
|
|
4
6
|
|
|
5
|
-
**
|
|
6
|
-
[dudko-dev/agents](https://github.com/dudko-dev/agents) (`packages/agent-web-ui`), and its releases are
|
|
7
|
-
published from there.
|
|
7
|
+
**[agent.dudko.dev](https://agent.dudko.dev)** · [live demo](https://agent.dudko.dev/demo/) · [source](https://github.com/dudko-dev/agents/tree/main/packages/agent-web-ui)
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
The UI logic of [`@dudko.dev/agent-web`](https://www.npmjs.com/package/@dudko.dev/agent-web), the
|
|
10
|
+
in-browser LLM agent, **with no framework**. It is the part of
|
|
11
|
+
[`@dudko.dev/agent-web-react`](https://www.npmjs.com/package/@dudko.dev/agent-web-react) that never
|
|
12
|
+
needed React: what the chat shows, worked out as plain functions and data. Build a front end for
|
|
13
|
+
any framework on it - a web component, Vue, Angular, Svelte, plain DOM - or use it on a server.
|
|
14
|
+
|
|
15
|
+
- **The headless reducer** - `agentStateReducer` folds the core's `AgentEvent`s into an
|
|
16
|
+
`AgentUiState`: the plan, the steps and their tool calls, the streamed answer, the transcript,
|
|
17
|
+
usage, consent requests, a server's questions, the model's questions, subagents, files written,
|
|
18
|
+
MCP Apps. Pure: no clock, no randomness, no DOM.
|
|
19
|
+
- **Every UI string** - `AgentLabels` / `defaultLabels` / `mergeLabels` (and the pipeline editor's
|
|
20
|
+
`PipelineLabels`): one object to translate or reword.
|
|
21
|
+
- **The pure helpers** behind the chat: the message box (slash commands, attachments and their
|
|
22
|
+
refusals, the long-text rule), the files an answer names, the scroll that follows an answer, the
|
|
23
|
+
consent queue, the question queues, image downscaling, file kinds, formatting.
|
|
24
|
+
- **Voice** - recording over `getUserMedia` + `MediaRecorder` (every track stopped when it ends),
|
|
25
|
+
a recording as a speech recognizer, reading aloud with the device's voices or a provider's.
|
|
26
|
+
- **Saved chats** - `ChatHistoryStore` (IndexedDB, memory fallback) and the merge of two tabs'
|
|
27
|
+
saves of one chat.
|
|
28
|
+
- **The security cores**, as strings and plain objects: the sandboxed frame for untrusted HTML,
|
|
29
|
+
the MCP Apps frame (its policy, its shell, the extension's JSON-RPC bridge) and the MCP Apps
|
|
30
|
+
sandbox page a server serves on an origin of its own.
|
|
31
|
+
- **The stylesheets** - `styles.css` (the chat) and `pipeline.css` (the pipeline editor): plain
|
|
32
|
+
CSS, `awr-` classes and `--awr-*` custom properties, light and dark.
|
|
33
|
+
|
|
34
|
+
It ships no agent logic (the core does that) and draws nothing: a front end draws, this package
|
|
35
|
+
says what to draw. `@dudko.dev/agent-web-react` is built on it and re-exports everything it used to
|
|
36
|
+
export, so a React app keeps importing from the React package.
|
|
37
|
+
|
|
38
|
+
## Install
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
npm i @dudko.dev/agent-web-ui @dudko.dev/agent-web
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
`@dudko.dev/agent-web` is a peer dependency (one core per page; the type imports and the few
|
|
45
|
+
runtime helpers this package uses come from it). There is no other dependency. A React app does
|
|
46
|
+
not install this package itself: `@dudko.dev/agent-web-react` depends on it.
|
|
47
|
+
|
|
48
|
+
## Entries
|
|
49
|
+
|
|
50
|
+
| Import | What | Imports |
|
|
51
|
+
| --- | --- | --- |
|
|
52
|
+
| `@dudko.dev/agent-web-ui` | the reducer and its types, the labels, the pure helpers, voice, saved chats, the sandboxed frame | the core |
|
|
53
|
+
| `@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 | the core |
|
|
54
|
+
| `@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 |
|
|
55
|
+
| `@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 |
|
|
56
|
+
| `@dudko.dev/agent-web-ui/canvas` | the generic canvas's maths (viewport, curves, hit tests, layout order) and its strings | nothing |
|
|
57
|
+
| `@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 renderer's helpers (see [Markdown](#markdown)) | nothing |
|
|
58
|
+
| `@dudko.dev/agent-web-ui/locales` | the chat's labels in your language, loaded on demand: `loadAgentLabels(tag)`, the list of tags, `labelsFromCatalog` | nothing |
|
|
59
|
+
| `@dudko.dev/agent-web-ui/locales/<tag>` | one language's labels (`labels`) and its catalog (`catalog`) | nothing |
|
|
60
|
+
| `@dudko.dev/agent-web-ui/styles.css` | the chat's stylesheet | - |
|
|
61
|
+
| `@dudko.dev/agent-web-ui/pipeline.css` | the pipeline editor's stylesheet (stands on its own) | - |
|
|
62
|
+
|
|
63
|
+
Every entry is ESM and CommonJS with types. The main entry never mentions the core's
|
|
64
|
+
`./mcp` subpath, the MCP SDK, the pipeline code, the Markdown parser or the MCP Apps frame - not in itself and not in a
|
|
65
|
+
chunk it loads - so a host that uses none of them carries none of them (`tests/entries.test.ts`
|
|
66
|
+
reads the built files).
|
|
67
|
+
|
|
68
|
+
## The reducer is the seam
|
|
69
|
+
|
|
70
|
+
Everything a chat shows is a function of the events the agent emitted. Keep a state, fold every
|
|
71
|
+
event into it, draw the state:
|
|
72
|
+
|
|
73
|
+
```ts
|
|
74
|
+
import { createAgent } from '@dudko.dev/agent-web'
|
|
75
|
+
import { agentStateReducer, createInitialAgentState, defaultLabels } from '@dudko.dev/agent-web-ui'
|
|
76
|
+
|
|
77
|
+
let state = createInitialAgentState()
|
|
78
|
+
const render = () => {
|
|
79
|
+
// your framework here: state.status, state.steps, state.messages, state.approvals, …
|
|
80
|
+
document.querySelector('#status')!.textContent = defaultLabels.status[state.status]
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const agent = await createAgent(config)
|
|
84
|
+
await agent.run(goal, {
|
|
85
|
+
onEvent: (event) => {
|
|
86
|
+
state = agentStateReducer(state, { type: 'event', event, at: Date.now() })
|
|
87
|
+
render()
|
|
88
|
+
},
|
|
89
|
+
})
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
The reducer never mutates the state it is given: each action gives a new state object, which
|
|
93
|
+
suits any framework's change detection. The actions besides
|
|
94
|
+
`event` are what the host did (`AgentAction`): a status, a reset, a saved chat loaded, the
|
|
95
|
+
notebook, messages that never reached the model, a text sent to a run in another tab. The run's
|
|
96
|
+
own start, steps and end are events (`run.start`, …). `at` is the only clock: the reducer reads
|
|
97
|
+
none of its own. The state is made of plain, exported view types (`StepView`,
|
|
98
|
+
`ToolCallView`, `ApprovalView`, `ElicitationView`, `QuestionView`, `SubagentView`, `ChatMessage`,
|
|
99
|
+
`AppView`, …): see the React package's [docs/chat.md](https://github.com/dudko-dev/agents/blob/main/packages/agent-web-react/docs/chat.md) for what each
|
|
100
|
+
field means - the React components draw exactly these.
|
|
101
|
+
|
|
102
|
+
What the reducer guarantees, for a UI of your own too: a person's own words given to the model's
|
|
103
|
+
`ask_user` never stay in the steps or a saved chat (`withoutOwnWords`), a server's form and an MCP
|
|
104
|
+
skill's text are never mirrored onto a saved message, and a consent request of an MCP App outlives
|
|
105
|
+
the run that showed it.
|
|
106
|
+
|
|
107
|
+
## Labels
|
|
108
|
+
|
|
109
|
+
`defaultLabels` is every string the chat shows; counted phrases are functions so that languages
|
|
110
|
+
with several plural forms can say them. `mergeLabels(defaultLabels, overrides)` merges the nested
|
|
111
|
+
groups key by key. The React package's `<AgentLabelsProvider>` / `useLabels` are this object in a
|
|
112
|
+
React context; a web component or a Vue plugin can do the same with its own mechanism.
|
|
113
|
+
|
|
114
|
+
## Markdown
|
|
115
|
+
|
|
116
|
+
`./markdown` turns a model's Markdown into a small tree - blocks (`p`, `h`, `code`, `quote`, `hr`,
|
|
117
|
+
`list`, `table`) of inline runs (`text`, `br`, `code`, `strong`, `em`, `del`, `link`, `file`) - that
|
|
118
|
+
a renderer of any front end draws as elements, never as HTML. The React package's `<Markdown>`
|
|
119
|
+
(`@dudko.dev/agent-web-react/markdown`) is one; a web component or a Vue / Svelte component draws
|
|
120
|
+
the same tree the same way.
|
|
121
|
+
|
|
122
|
+
```ts
|
|
123
|
+
import {
|
|
124
|
+
parseMarkdownCached, // a finished text (cached by its text)
|
|
125
|
+
parseMarkdownStreaming, // a text still being written, given the parse of what it was before
|
|
126
|
+
emptyMarkdownStream,
|
|
127
|
+
markdownCellIsLong,
|
|
128
|
+
type MarkdownBlock,
|
|
129
|
+
} from '@dudko.dev/agent-web-ui/markdown'
|
|
130
|
+
|
|
131
|
+
let stream = emptyMarkdownStream()
|
|
132
|
+
const blocksOf = (text: string, pending: boolean): MarkdownBlock[] =>
|
|
133
|
+
pending ? (stream = parseMarkdownStreaming(stream, text)).blocks : parseMarkdownCached(text)
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
What it reads: paragraphs with their line breaks, headings, lists (nested, at most 9 levels),
|
|
137
|
+
fenced code (at any indentation), quotes, rules, GFM tables, `**bold**`, `*italic*`,
|
|
138
|
+
`~~struck~~`, `` `code` ``, links and bare `http(s)` URLs. While an answer is written
|
|
139
|
+
(`parseMarkdownStreaming`) nothing already drawn changes its kind or gets shorter: the last line
|
|
140
|
+
waits while it is only markers, emphasis open at the end is drawn closed, a link is its words
|
|
141
|
+
until its address is whole, and the finished blocks are kept as the same objects.
|
|
142
|
+
|
|
143
|
+
It is a security boundary for a host - the text is the model's:
|
|
144
|
+
|
|
145
|
+
- **Raw HTML is text**: `<script>`, `<img onerror>`, entities - the characters as written. There is
|
|
146
|
+
no node that is markup or carries an attribute.
|
|
147
|
+
- **A link only to `http(s)` or `mailto`** (`safeHref`): anything else - `javascript:`, `data:`,
|
|
148
|
+
`vbscript:`, `file:`, `//host`, a relative address, and their obfuscated forms (entities, which
|
|
149
|
+
are never decoded, percent-encoding, blanks inside, case) - stays text.
|
|
150
|
+
- **A link to a workspace file** is `{ t: 'file', path }` only when its destination,
|
|
151
|
+
percent-decoded first, is a workspace path by `workspacePathOf` (absolute, no `..` / `.` /
|
|
152
|
+
empty segment, no `//host`, no backslash or control character) - `%2e%2e`, `%2F%2Fhost`, `%5C`
|
|
153
|
+
are refused; a whole code span that is one carries `path`. A renderer draws it as a control that
|
|
154
|
+
opens the file in the page, never as `<a href>`. A link's words hold no link of their own.
|
|
155
|
+
- **No picture** is loaded from an answer: `` is its `!` and a link (or a file link).
|
|
156
|
+
- **Linear on any text**: one pass for code spans, lookups for brackets and destinations, one
|
|
157
|
+
opener stack per kind of emphasis, list nesting bounded - long runs of `*`, `_`, `[`, backticks,
|
|
158
|
+
`>`, `|` or ever-deeper lists cost what plain text does (`tests/markdown.test.ts` times them).
|
|
159
|
+
|
|
160
|
+
## In your language
|
|
161
|
+
|
|
162
|
+
The chat's labels come translated into 33 languages - the same 33 as the app at
|
|
163
|
+
https://agent.dudko.dev/app/, whose translations they are:
|
|
164
|
+
|
|
165
|
+
`en`, `ru`, `uk`, `be`, `pl`, `cs`, `sk`, `hr`, `sr`, `sr-Latn`, `bg`, `ro`, `hu`, `de`, `fr`, `it`,
|
|
166
|
+
`es`, `pt`, `nl`, `da`, `sv`, `nb`, `fi`, `el`, `sq`, `ca`, `tr`, `es-419`, `pt-BR`, `fr-CA`, `ht`,
|
|
167
|
+
`qu`, `gn`.
|
|
168
|
+
|
|
169
|
+
```ts
|
|
170
|
+
import { loadAgentLabels } from '@dudko.dev/agent-web-ui/locales'
|
|
171
|
+
import { defaultLabels, mergeLabels } from '@dudko.dev/agent-web-ui'
|
|
172
|
+
|
|
173
|
+
const labels = mergeLabels(defaultLabels, await loadAgentLabels(navigator.language))
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
- **One language, one file.** Each language is an entry of its own
|
|
177
|
+
(`@dudko.dev/agent-web-ui/locales/<tag>`), and `loadAgentLabels` loads it with a literal
|
|
178
|
+
`import()`, so a bundler makes a chunk of each: a page in Russian downloads Russian only (about
|
|
179
|
+
27 KB, 7 KB gzipped), plus the builder every language shares (5 KB gzipped). The variants carry their
|
|
180
|
+
base too: `es-419` is Spanish with the words of the Americas, `fr-CA` French with Québec's
|
|
181
|
+
punctuation, `sr-Latn` the Cyrillic catalog transliterated letter for letter. To have one
|
|
182
|
+
language in your main bundle instead, import it: `import { labels } from
|
|
183
|
+
'@dudko.dev/agent-web-ui/locales/de'`.
|
|
184
|
+
- **Which language.** `loadAgentLabels(tag)` takes any BCP 47 tag: the exact tag (`pt-BR`), then its
|
|
185
|
+
language and script (`sr-Latn-RS` → `sr-Latn`), then its language (`de-AT` → `de`, `es-MX` →
|
|
186
|
+
`es`, `no` → `nb`), then English - also for a tag that is not one. `agentLabelLocaleOf(tag)`
|
|
187
|
+
tells which it picks; `AGENT_LABEL_LOCALES` is the list. Choosing `es-419` for `es-MX` is the
|
|
188
|
+
host's call: pass the tag you mean.
|
|
189
|
+
- **What is not translated stays English.** The labels are an `AgentLabelsOverride`: the chat's
|
|
190
|
+
strings the app shows. What they do not cover yet (a few parts of `AgentLabels` the app does
|
|
191
|
+
not mount, and `emptyState`, which is the host's own words) falls back to `defaultLabels` once
|
|
192
|
+
merged.
|
|
193
|
+
- **Plurals and numbers** are the language's own: a counted phrase picks its form with
|
|
194
|
+
`Intl.PluralRules(tag)` (Russian: 1 шаг, 2 шага, 5 шагов, 21 шаг) and writes its number with
|
|
195
|
+
`Intl.NumberFormat(tag)` (1 234 in Russian, 1.234 in German); sizes and token counts are
|
|
196
|
+
`Intl.NumberFormat`'s units and compact form. No library.
|
|
197
|
+
- **Your own wording or language.** `labelsFromCatalog(tag, catalog)` builds the labels from a
|
|
198
|
+
catalog of the same keys (`AgentLabelCatalog`; plural entries as `{ one, few, many, other }` -
|
|
199
|
+
the categories of the language - with `{count}`): take a language's `catalog`, change what you
|
|
200
|
+
like, or translate English's.
|
|
201
|
+
- **Machine-made, not reviewed:** `ht` (Kreyòl ayisyen), `qu` (Runa Simi) and `gn` (Avañe'ẽ) were
|
|
202
|
+
written with care but have not been read by a native speaker yet - the app marks them the same
|
|
203
|
+
way. Corrections are welcome. The other 30 are reviewed.
|
|
204
|
+
|
|
205
|
+
## Security boundaries
|
|
206
|
+
|
|
207
|
+
Four parts of this package are security boundaries. Each guard has a `guard …` test here
|
|
208
|
+
(`tests/files.test.ts`, `tests/apps*.test.ts`, `tests/app-prompts.test.ts`, `tests/markdown.test.ts`), the React package's
|
|
209
|
+
browser tests run hostile pages and a hostile MCP App against them, and a change needs a mutation
|
|
210
|
+
check.
|
|
211
|
+
|
|
212
|
+
- **The sandboxed frame** (`buildSandboxedDocument`, `sandboxedCsp`, `sandboxTokens`): untrusted
|
|
213
|
+
HTML goes into `<iframe sandbox>` WITHOUT `allow-same-origin`, under a policy with no network
|
|
214
|
+
source, framed by a document of ours whose `frame-src 'none'` is what stops it navigating itself.
|
|
215
|
+
Never render a workspace file by `blob:` / `data:` URL or as markup.
|
|
216
|
+
- **The MCP Apps frame** (`./mcp-app`): the app's policy from its resource's declared origins ONLY
|
|
217
|
+
(frames, workers and `<base>` never granted; `'wasm-unsafe-eval'` always, `'unsafe-eval'` never),
|
|
218
|
+
one inner `sandbox="allow-scripts"` frame, and `McpAppBridge` - an allow-list of methods, their
|
|
219
|
+
parameters checked, nothing but `ping` before `ui/initialize`.
|
|
220
|
+
- **The sandbox page** (`./mcp-app-sandbox`, for a server): an app on an origin of its own. It
|
|
221
|
+
binds to the first ancestor on an allowed host that sends `sandbox-resource-ready`, once, relays
|
|
222
|
+
to exact origins only, and ignores a `sandbox`, `csp` or `permissions` the host sends: the
|
|
223
|
+
header is the policy, and `frame-ancestors` names the hosts.
|
|
224
|
+
- **The Markdown parser** (`./markdown`): raw HTML is text, links only to `http(s)` / `mailto`, a
|
|
225
|
+
file link only to a workspace path (decoded first), no picture, linear on any text - see
|
|
226
|
+
[Markdown](#markdown).
|
|
227
|
+
|
|
228
|
+
```ts
|
|
229
|
+
// A Cloudflare Worker serving the sandbox page
|
|
230
|
+
import { mcpAppSandboxResponse } from '@dudko.dev/agent-web-ui/mcp-app-sandbox'
|
|
231
|
+
|
|
232
|
+
export default {
|
|
233
|
+
fetch: (request: Request, env: { HOSTS?: string }) =>
|
|
234
|
+
mcpAppSandboxResponse(request, { path: '/sandbox/v1', hosts: env.HOSTS }),
|
|
235
|
+
}
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
How an app runs and what the two modes trade: the React package's
|
|
239
|
+
[docs/chat.md](https://github.com/dudko-dev/agents/blob/main/packages/agent-web-react/docs/chat.md#an-app-on-an-origin-of-its-own).
|
|
240
|
+
|
|
241
|
+
## Who uses it
|
|
242
|
+
|
|
243
|
+
- [`@dudko.dev/agent-web-react`](https://github.com/dudko-dev/agents/blob/main/packages/agent-web-react/README.md) - the hook, the context and the components; it
|
|
244
|
+
imports this package (one copy on a page) and re-exports its names, and ships its stylesheets at
|
|
245
|
+
`@dudko.dev/agent-web-react/styles.css` and `/pipeline.css`, copied from here.
|
|
246
|
+
- [`apps/app`](https://github.com/dudko-dev/agents/tree/main/apps/app) and
|
|
247
|
+
[`apps/demo`](https://github.com/dudko-dev/agents/tree/main/apps/demo) draw their answers'
|
|
248
|
+
Markdown with `./markdown`, through the React package's `<Markdown>`.
|
|
249
|
+
- [`apps/app-sandbox`](https://github.com/dudko-dev/agents/tree/main/apps/app-sandbox) - the demo's
|
|
250
|
+
and the app's MCP Apps sandbox page on Cloudflare, `./mcp-app-sandbox` and nothing else.
|
|
251
|
+
- A web component, Vue / Angular / Svelte bindings: built on this package, not on React.
|
|
252
|
+
|
|
253
|
+
## License
|
|
254
|
+
|
|
255
|
+
MIT © Siarhei Dudko
|
package/dist/canvas.cjs
ADDED
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/canvas/index.ts
|
|
21
|
+
var canvas_exports = {};
|
|
22
|
+
__export(canvas_exports, {
|
|
23
|
+
DEFAULT_MAX_ZOOM: () => DEFAULT_MAX_ZOOM,
|
|
24
|
+
DEFAULT_MIN_ZOOM: () => DEFAULT_MIN_ZOOM,
|
|
25
|
+
IDENTITY_VIEWPORT: () => IDENTITY_VIEWPORT,
|
|
26
|
+
boundsOf: () => boundsOf,
|
|
27
|
+
centerOn: () => centerOn,
|
|
28
|
+
clamp: () => clamp,
|
|
29
|
+
curvePath: () => curvePath,
|
|
30
|
+
curvePoint: () => curvePoint,
|
|
31
|
+
defaultCanvasLabels: () => defaultCanvasLabels,
|
|
32
|
+
distanceToCurve: () => distanceToCurve,
|
|
33
|
+
edgeCurve: () => edgeCurve,
|
|
34
|
+
fitViewport: () => fitViewport,
|
|
35
|
+
hitEdge: () => hitEdge,
|
|
36
|
+
hitNode: () => hitNode,
|
|
37
|
+
inputAnchor: () => inputAnchor,
|
|
38
|
+
isRectVisible: () => isRectVisible,
|
|
39
|
+
outputAnchor: () => outputAnchor,
|
|
40
|
+
panBy: () => panBy,
|
|
41
|
+
pinchViewport: () => pinchViewport,
|
|
42
|
+
readingOrder: () => readingOrder,
|
|
43
|
+
rectContains: () => rectContains,
|
|
44
|
+
screenToWorld: () => screenToWorld,
|
|
45
|
+
snapPoint: () => snapPoint,
|
|
46
|
+
snapTo: () => snapTo,
|
|
47
|
+
worldToScreen: () => worldToScreen,
|
|
48
|
+
zoomAt: () => zoomAt
|
|
49
|
+
});
|
|
50
|
+
module.exports = __toCommonJS(canvas_exports);
|
|
51
|
+
|
|
52
|
+
// src/canvas/labels.ts
|
|
53
|
+
var defaultCanvasLabels = {
|
|
54
|
+
canvas: "Canvas",
|
|
55
|
+
help: "Tab moves between nodes and their connections. Arrow keys move the selected node, Enter opens it, Delete removes it, C starts a connection, Escape clears the selection. On the canvas itself the arrow keys pan, plus and minus zoom, 0 fits everything.",
|
|
56
|
+
node: "node",
|
|
57
|
+
edge: (from, to, description) => `Connection from ${from} to ${to}${description ? `: ${description}` : ""}`,
|
|
58
|
+
port: (node, port) => `Connect ${node}${port ? ` (${port})` : ""} to another node`,
|
|
59
|
+
connectsTo: (names) => `Connects to: ${names}.`,
|
|
60
|
+
receivesFrom: (names) => `Receives from: ${names}.`,
|
|
61
|
+
zoomIn: "Zoom in",
|
|
62
|
+
zoomOut: "Zoom out",
|
|
63
|
+
fit: "Fit to view",
|
|
64
|
+
zoomLevel: (percent) => `${percent}%`,
|
|
65
|
+
connectHint: (from) => `Pick the node to connect ${from} to`,
|
|
66
|
+
cancel: "Cancel",
|
|
67
|
+
connected: (from, to) => `Connected ${from} to ${to}`
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
// src/canvas/geometry.ts
|
|
71
|
+
var DEFAULT_MIN_ZOOM = 0.25;
|
|
72
|
+
var DEFAULT_MAX_ZOOM = 2;
|
|
73
|
+
var IDENTITY_VIEWPORT = { x: 0, y: 0, zoom: 1 };
|
|
74
|
+
var clamp = (value, min, max) => Math.min(max, Math.max(min, value));
|
|
75
|
+
var screenToWorld = (point, viewport) => ({
|
|
76
|
+
x: (point.x - viewport.x) / viewport.zoom,
|
|
77
|
+
y: (point.y - viewport.y) / viewport.zoom
|
|
78
|
+
});
|
|
79
|
+
var worldToScreen = (point, viewport) => ({
|
|
80
|
+
x: point.x * viewport.zoom + viewport.x,
|
|
81
|
+
y: point.y * viewport.zoom + viewport.y
|
|
82
|
+
});
|
|
83
|
+
var panBy = (viewport, dx, dy) => ({
|
|
84
|
+
...viewport,
|
|
85
|
+
x: viewport.x + dx,
|
|
86
|
+
y: viewport.y + dy
|
|
87
|
+
});
|
|
88
|
+
var zoomAt = (viewport, zoom, anchor, minZoom = DEFAULT_MIN_ZOOM, maxZoom = DEFAULT_MAX_ZOOM) => {
|
|
89
|
+
const next = clamp(zoom, minZoom, maxZoom);
|
|
90
|
+
if (next === viewport.zoom) return viewport;
|
|
91
|
+
const world = screenToWorld(anchor, viewport);
|
|
92
|
+
return { zoom: next, x: anchor.x - world.x * next, y: anchor.y - world.y * next };
|
|
93
|
+
};
|
|
94
|
+
var pinchViewport = (viewport, before, after, minZoom = DEFAULT_MIN_ZOOM, maxZoom = DEFAULT_MAX_ZOOM) => {
|
|
95
|
+
const distance = (a, b) => Math.hypot(a.x - b.x, a.y - b.y);
|
|
96
|
+
const middle = (a, b) => ({ x: (a.x + b.x) / 2, y: (a.y + b.y) / 2 });
|
|
97
|
+
const was = distance(before[0], before[1]);
|
|
98
|
+
const is = distance(after[0], after[1]);
|
|
99
|
+
const zoom = clamp(was > 0 ? viewport.zoom * is / was : viewport.zoom, minZoom, maxZoom);
|
|
100
|
+
const world = screenToWorld(middle(before[0], before[1]), viewport);
|
|
101
|
+
const at = middle(after[0], after[1]);
|
|
102
|
+
return { zoom, x: at.x - world.x * zoom, y: at.y - world.y * zoom };
|
|
103
|
+
};
|
|
104
|
+
var boundsOf = (rects) => {
|
|
105
|
+
if (rects.length === 0) return void 0;
|
|
106
|
+
let left = Infinity;
|
|
107
|
+
let top = Infinity;
|
|
108
|
+
let right = -Infinity;
|
|
109
|
+
let bottom = -Infinity;
|
|
110
|
+
for (const r of rects) {
|
|
111
|
+
left = Math.min(left, r.x);
|
|
112
|
+
top = Math.min(top, r.y);
|
|
113
|
+
right = Math.max(right, r.x + r.width);
|
|
114
|
+
bottom = Math.max(bottom, r.y + r.height);
|
|
115
|
+
}
|
|
116
|
+
return { x: left, y: top, width: right - left, height: bottom - top };
|
|
117
|
+
};
|
|
118
|
+
var fitAxis = (start, length, room, zoom, padding) => length * zoom <= room - padding * 2 + 0.5 ? (room - length * zoom) / 2 - start * zoom : padding - start * zoom;
|
|
119
|
+
var fitViewport = (rects, size, options = {}) => {
|
|
120
|
+
const bounds = boundsOf(rects);
|
|
121
|
+
if (!bounds || size.width <= 0 || size.height <= 0) return IDENTITY_VIEWPORT;
|
|
122
|
+
const { minZoom = DEFAULT_MIN_ZOOM, maxZoom = 1 } = options;
|
|
123
|
+
const padding = Math.min(options.padding ?? 48, size.width / 8, size.height / 8);
|
|
124
|
+
const zoom = clamp(
|
|
125
|
+
Math.min(
|
|
126
|
+
(size.width - padding * 2) / Math.max(bounds.width, 1),
|
|
127
|
+
(size.height - padding * 2) / Math.max(bounds.height, 1)
|
|
128
|
+
),
|
|
129
|
+
minZoom,
|
|
130
|
+
maxZoom
|
|
131
|
+
);
|
|
132
|
+
return {
|
|
133
|
+
zoom,
|
|
134
|
+
x: fitAxis(bounds.x, bounds.width, size.width, zoom, padding),
|
|
135
|
+
y: fitAxis(bounds.y, bounds.height, size.height, zoom, padding)
|
|
136
|
+
};
|
|
137
|
+
};
|
|
138
|
+
var centerOn = (rect, size, zoom) => ({
|
|
139
|
+
zoom,
|
|
140
|
+
x: size.width / 2 - (rect.x + rect.width / 2) * zoom,
|
|
141
|
+
y: size.height / 2 - (rect.y + rect.height / 2) * zoom
|
|
142
|
+
});
|
|
143
|
+
var isRectVisible = (rect, size, viewport) => {
|
|
144
|
+
const a = worldToScreen(rect, viewport);
|
|
145
|
+
const b = worldToScreen({ x: rect.x + rect.width, y: rect.y + rect.height }, viewport);
|
|
146
|
+
return b.x > 0 && b.y > 0 && a.x < size.width && a.y < size.height;
|
|
147
|
+
};
|
|
148
|
+
var snapTo = (value, grid) => (
|
|
149
|
+
// `+ 0`: a rounded-away negative is 0, not -0.
|
|
150
|
+
grid > 0 ? Math.round(value / grid) * grid + 0 : value
|
|
151
|
+
);
|
|
152
|
+
var snapPoint = (point, grid) => ({
|
|
153
|
+
x: snapTo(point.x, grid),
|
|
154
|
+
y: snapTo(point.y, grid)
|
|
155
|
+
});
|
|
156
|
+
var rectContains = (rect, point) => point.x >= rect.x && point.x <= rect.x + rect.width && point.y >= rect.y && point.y <= rect.y + rect.height;
|
|
157
|
+
var hitNode = (nodes, point) => {
|
|
158
|
+
for (let i = nodes.length - 1; i >= 0; i--) {
|
|
159
|
+
if (rectContains(nodes[i], point)) return nodes[i].id;
|
|
160
|
+
}
|
|
161
|
+
return void 0;
|
|
162
|
+
};
|
|
163
|
+
var inputAnchor = (rect) => ({ x: rect.x, y: rect.y + rect.height / 2 });
|
|
164
|
+
var outputAnchor = (rect, index = 0, count = 1) => ({
|
|
165
|
+
x: rect.x + rect.width,
|
|
166
|
+
y: rect.y + rect.height * (index + 1) / (Math.max(count, 1) + 1)
|
|
167
|
+
});
|
|
168
|
+
var edgeCurve = (from, to, options = {}) => {
|
|
169
|
+
const dx = to.x - from.x;
|
|
170
|
+
const dy = to.y - from.y;
|
|
171
|
+
if (dx >= 40) {
|
|
172
|
+
const reach2 = Math.max(dx / 2, 40);
|
|
173
|
+
return {
|
|
174
|
+
p0: from,
|
|
175
|
+
p1: { x: from.x + reach2, y: from.y },
|
|
176
|
+
p2: { x: to.x - reach2, y: to.y },
|
|
177
|
+
p3: to
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
const reach = clamp(60 + Math.abs(dx) / 4, 60, 220);
|
|
181
|
+
const clearance = options.clearance ?? 90;
|
|
182
|
+
const swing = Math.abs(dy) < clearance ? clearance + Math.abs(dy) / 2 : 0;
|
|
183
|
+
return {
|
|
184
|
+
p0: from,
|
|
185
|
+
p1: { x: from.x + reach, y: from.y + swing },
|
|
186
|
+
p2: { x: to.x - reach, y: to.y + swing },
|
|
187
|
+
p3: to
|
|
188
|
+
};
|
|
189
|
+
};
|
|
190
|
+
var round = (n) => Math.round(n * 100) / 100;
|
|
191
|
+
var curvePath = ({ p0, p1, p2, p3 }) => `M ${round(p0.x)} ${round(p0.y)} C ${round(p1.x)} ${round(p1.y)}, ${round(p2.x)} ${round(p2.y)}, ${round(p3.x)} ${round(p3.y)}`;
|
|
192
|
+
var curvePoint = ({ p0, p1, p2, p3 }, t) => {
|
|
193
|
+
const u = 1 - t;
|
|
194
|
+
const a = u * u * u;
|
|
195
|
+
const b = 3 * u * u * t;
|
|
196
|
+
const c = 3 * u * t * t;
|
|
197
|
+
const d = t * t * t;
|
|
198
|
+
return {
|
|
199
|
+
x: a * p0.x + b * p1.x + c * p2.x + d * p3.x,
|
|
200
|
+
y: a * p0.y + b * p1.y + c * p2.y + d * p3.y
|
|
201
|
+
};
|
|
202
|
+
};
|
|
203
|
+
var distanceToSegment = (p, a, b) => {
|
|
204
|
+
const dx = b.x - a.x;
|
|
205
|
+
const dy = b.y - a.y;
|
|
206
|
+
const length = dx * dx + dy * dy;
|
|
207
|
+
const t = length === 0 ? 0 : clamp(((p.x - a.x) * dx + (p.y - a.y) * dy) / length, 0, 1);
|
|
208
|
+
return Math.hypot(p.x - (a.x + t * dx), p.y - (a.y + t * dy));
|
|
209
|
+
};
|
|
210
|
+
var distanceToCurve = (curve, point, samples = 24) => {
|
|
211
|
+
let best = Infinity;
|
|
212
|
+
let previous = curve.p0;
|
|
213
|
+
for (let i = 1; i <= samples; i++) {
|
|
214
|
+
const next = curvePoint(curve, i / samples);
|
|
215
|
+
best = Math.min(best, distanceToSegment(point, previous, next));
|
|
216
|
+
previous = next;
|
|
217
|
+
}
|
|
218
|
+
return best;
|
|
219
|
+
};
|
|
220
|
+
var hitEdge = (edges, point, tolerance = 8) => {
|
|
221
|
+
let best;
|
|
222
|
+
let bestDistance = Infinity;
|
|
223
|
+
for (const edge of edges) {
|
|
224
|
+
const distance = distanceToCurve(edge.curve, point);
|
|
225
|
+
if (distance <= tolerance && distance < bestDistance) {
|
|
226
|
+
best = edge.id;
|
|
227
|
+
bestDistance = distance;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
return best;
|
|
231
|
+
};
|
|
232
|
+
var readingOrder = (nodes, column = 40) => nodes.map((node, index) => ({ node, index })).sort((a, b) => {
|
|
233
|
+
const ax = Math.round(a.node.x / column);
|
|
234
|
+
const bx = Math.round(b.node.x / column);
|
|
235
|
+
return ax - bx || a.node.y - b.node.y || a.index - b.index;
|
|
236
|
+
}).map(({ node }) => node.id);
|
|
237
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
238
|
+
0 && (module.exports = {
|
|
239
|
+
DEFAULT_MAX_ZOOM,
|
|
240
|
+
DEFAULT_MIN_ZOOM,
|
|
241
|
+
IDENTITY_VIEWPORT,
|
|
242
|
+
boundsOf,
|
|
243
|
+
centerOn,
|
|
244
|
+
clamp,
|
|
245
|
+
curvePath,
|
|
246
|
+
curvePoint,
|
|
247
|
+
defaultCanvasLabels,
|
|
248
|
+
distanceToCurve,
|
|
249
|
+
edgeCurve,
|
|
250
|
+
fitViewport,
|
|
251
|
+
hitEdge,
|
|
252
|
+
hitNode,
|
|
253
|
+
inputAnchor,
|
|
254
|
+
isRectVisible,
|
|
255
|
+
outputAnchor,
|
|
256
|
+
panBy,
|
|
257
|
+
pinchViewport,
|
|
258
|
+
readingOrder,
|
|
259
|
+
rectContains,
|
|
260
|
+
screenToWorld,
|
|
261
|
+
snapPoint,
|
|
262
|
+
snapTo,
|
|
263
|
+
worldToScreen,
|
|
264
|
+
zoomAt
|
|
265
|
+
});
|
|
266
|
+
//# sourceMappingURL=canvas.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/canvas/index.ts","../src/canvas/labels.ts","../src/canvas/geometry.ts"],"sourcesContent":["// The generic canvas's maths (pure functions) and its strings: nothing of agents, no React, no\n// import at all. The React canvas (`@dudko.dev/agent-web-react/pipeline`'s `Canvas`) draws with it;\n// another framework's canvas can too.\nexport { defaultCanvasLabels } from './labels.js'\nexport type { CanvasLabels } from './labels.js'\nexport {\n boundsOf,\n centerOn,\n clamp,\n curvePath,\n curvePoint,\n DEFAULT_MAX_ZOOM,\n DEFAULT_MIN_ZOOM,\n distanceToCurve,\n edgeCurve,\n fitViewport,\n hitEdge,\n hitNode,\n IDENTITY_VIEWPORT,\n inputAnchor,\n isRectVisible,\n outputAnchor,\n panBy,\n pinchViewport,\n readingOrder,\n rectContains,\n screenToWorld,\n snapPoint,\n snapTo,\n worldToScreen,\n zoomAt,\n} from './geometry.js'\nexport type {\n Curve,\n EdgeCurveOptions,\n FitOptions,\n Point,\n Rect,\n Size,\n Viewport,\n} from './geometry.js'\n","// The canvas's strings: what it shows and says to a screen reader. Generic - nothing of agents.\n\n/** Every string the canvas shows or says. */\nexport interface CanvasLabels {\n /** The canvas's own name for a screen reader. */\n canvas: string\n /** How to use it with a keyboard; read once, when the canvas is focused. */\n help: string\n /** `aria-roledescription` of a node. */\n node: string\n edge: (from: string, to: string, description?: string) => string\n port: (node: string, port?: string) => string\n connectsTo: (names: string) => string\n receivesFrom: (names: string) => string\n zoomIn: string\n zoomOut: string\n fit: string\n zoomLevel: (percent: number) => string\n /** Shown (and announced) while a connection is being made without dragging. */\n connectHint: (from: string) => string\n cancel: string\n connected: (from: string, to: string) => string\n}\n\nexport const defaultCanvasLabels: CanvasLabels = {\n canvas: 'Canvas',\n help: 'Tab moves between nodes and their connections. Arrow keys move the selected node, Enter opens it, Delete removes it, C starts a connection, Escape clears the selection. On the canvas itself the arrow keys pan, plus and minus zoom, 0 fits everything.',\n node: 'node',\n edge: (from, to, description) =>\n `Connection from ${from} to ${to}${description ? `: ${description}` : ''}`,\n port: (node, port) => `Connect ${node}${port ? ` (${port})` : ''} to another node`,\n connectsTo: (names) => `Connects to: ${names}.`,\n receivesFrom: (names) => `Receives from: ${names}.`,\n zoomIn: 'Zoom in',\n zoomOut: 'Zoom out',\n fit: 'Fit to view',\n zoomLevel: (percent) => `${percent}%`,\n connectHint: (from) => `Pick the node to connect ${from} to`,\n cancel: 'Cancel',\n connected: (from, to) => `Connected ${from} to ${to}`,\n}\n","// The canvas's maths: viewport transforms, fitting, hit testing and the shape of an edge.\n// Pure functions over plain numbers - no DOM, no React - so they are unit-tested as they are.\n\nexport interface Point {\n x: number\n y: number\n}\n\nexport interface Size {\n width: number\n height: number\n}\n\nexport interface Rect extends Point, Size {}\n\n/**\n * Where the world sits on the screen: a world point `p` is drawn at\n * `p * zoom + (x, y)`, in pixels from the canvas's top-left corner.\n */\nexport interface Viewport {\n x: number\n y: number\n zoom: number\n}\n\n/** The four control points of a cubic Bezier curve. */\nexport interface Curve {\n p0: Point\n p1: Point\n p2: Point\n p3: Point\n}\n\nexport const DEFAULT_MIN_ZOOM = 0.25\nexport const DEFAULT_MAX_ZOOM = 2\nexport const IDENTITY_VIEWPORT: Viewport = { x: 0, y: 0, zoom: 1 }\n\nexport const clamp = (value: number, min: number, max: number): number =>\n Math.min(max, Math.max(min, value))\n\nexport const screenToWorld = (point: Point, viewport: Viewport): Point => ({\n x: (point.x - viewport.x) / viewport.zoom,\n y: (point.y - viewport.y) / viewport.zoom,\n})\n\nexport const worldToScreen = (point: Point, viewport: Viewport): Point => ({\n x: point.x * viewport.zoom + viewport.x,\n y: point.y * viewport.zoom + viewport.y,\n})\n\nexport const panBy = (viewport: Viewport, dx: number, dy: number): Viewport => ({\n ...viewport,\n x: viewport.x + dx,\n y: viewport.y + dy,\n})\n\n/** Set the zoom, keeping the world point under `anchor` (a screen point) where it is. */\nexport const zoomAt = (\n viewport: Viewport,\n zoom: number,\n anchor: Point,\n minZoom = DEFAULT_MIN_ZOOM,\n maxZoom = DEFAULT_MAX_ZOOM,\n): Viewport => {\n const next = clamp(zoom, minZoom, maxZoom)\n if (next === viewport.zoom) return viewport\n const world = screenToWorld(anchor, viewport)\n return { zoom: next, x: anchor.x - world.x * next, y: anchor.y - world.y * next }\n}\n\n/**\n * Two fingers moved from `before` to `after` (screen points): zoom by how far apart they went,\n * and keep the world point that was between them under the point that is between them now.\n */\nexport const pinchViewport = (\n viewport: Viewport,\n before: [Point, Point],\n after: [Point, Point],\n minZoom = DEFAULT_MIN_ZOOM,\n maxZoom = DEFAULT_MAX_ZOOM,\n): Viewport => {\n const distance = (a: Point, b: Point) => Math.hypot(a.x - b.x, a.y - b.y)\n const middle = (a: Point, b: Point): Point => ({ x: (a.x + b.x) / 2, y: (a.y + b.y) / 2 })\n const was = distance(before[0], before[1])\n const is = distance(after[0], after[1])\n const zoom = clamp(was > 0 ? (viewport.zoom * is) / was : viewport.zoom, minZoom, maxZoom)\n const world = screenToWorld(middle(before[0], before[1]), viewport)\n const at = middle(after[0], after[1])\n return { zoom, x: at.x - world.x * zoom, y: at.y - world.y * zoom }\n}\n\n/** The smallest rectangle around all of `rects`; undefined when there are none. */\nexport const boundsOf = (rects: Rect[]): Rect | undefined => {\n if (rects.length === 0) return undefined\n let left = Infinity\n let top = Infinity\n let right = -Infinity\n let bottom = -Infinity\n for (const r of rects) {\n left = Math.min(left, r.x)\n top = Math.min(top, r.y)\n right = Math.max(right, r.x + r.width)\n bottom = Math.max(bottom, r.y + r.height)\n }\n return { x: left, y: top, width: right - left, height: bottom - top }\n}\n\nexport interface FitOptions {\n /** Free space kept around the content, in screen pixels (default 48). */\n padding?: number\n minZoom?: number\n /** Fitting never zooms in past this (default 1: a small graph is not blown up). */\n maxZoom?: number\n}\n\n// One axis of a fit: centred when the content fits, from its start (the padding kept) when it\n// does not - a graph too large for the canvas at the smallest zoom shows where it begins.\nconst fitAxis = (start: number, length: number, room: number, zoom: number, padding: number) =>\n length * zoom <= room - padding * 2 + 0.5\n ? (room - length * zoom) / 2 - start * zoom\n : padding - start * zoom\n\n/**\n * The viewport that shows all of `rects` centred in a canvas of `size`. When they do not fit at\n * `minZoom`, it shows them from their top-left corner at that zoom instead.\n */\nexport const fitViewport = (rects: Rect[], size: Size, options: FitOptions = {}): Viewport => {\n const bounds = boundsOf(rects)\n if (!bounds || size.width <= 0 || size.height <= 0) return IDENTITY_VIEWPORT\n const { minZoom = DEFAULT_MIN_ZOOM, maxZoom = 1 } = options\n // A narrow canvas cannot afford the padding a wide one has.\n const padding = Math.min(options.padding ?? 48, size.width / 8, size.height / 8)\n const zoom = clamp(\n Math.min(\n (size.width - padding * 2) / Math.max(bounds.width, 1),\n (size.height - padding * 2) / Math.max(bounds.height, 1),\n ),\n minZoom,\n maxZoom,\n )\n return {\n zoom,\n x: fitAxis(bounds.x, bounds.width, size.width, zoom, padding),\n y: fitAxis(bounds.y, bounds.height, size.height, zoom, padding),\n }\n}\n\n/** The viewport with `rect` in the middle of a canvas of `size`, at the zoom given. */\nexport const centerOn = (rect: Rect, size: Size, zoom: number): Viewport => ({\n zoom,\n x: size.width / 2 - (rect.x + rect.width / 2) * zoom,\n y: size.height / 2 - (rect.y + rect.height / 2) * zoom,\n})\n\n/** Is any part of `rect` (world) inside a canvas of `size` under `viewport`? */\nexport const isRectVisible = (rect: Rect, size: Size, viewport: Viewport): boolean => {\n const a = worldToScreen(rect, viewport)\n const b = worldToScreen({ x: rect.x + rect.width, y: rect.y + rect.height }, viewport)\n return b.x > 0 && b.y > 0 && a.x < size.width && a.y < size.height\n}\n\nexport const snapTo = (value: number, grid: number): number =>\n // `+ 0`: a rounded-away negative is 0, not -0.\n grid > 0 ? Math.round(value / grid) * grid + 0 : value\n\nexport const snapPoint = (point: Point, grid: number): Point => ({\n x: snapTo(point.x, grid),\n y: snapTo(point.y, grid),\n})\n\nexport const rectContains = (rect: Rect, point: Point): boolean =>\n point.x >= rect.x &&\n point.x <= rect.x + rect.width &&\n point.y >= rect.y &&\n point.y <= rect.y + rect.height\n\n/** The id of the node under `point` (world). Later nodes are drawn on top, so they win. */\nexport const hitNode = <T extends Rect & { id: string }>(\n nodes: T[],\n point: Point,\n): string | undefined => {\n for (let i = nodes.length - 1; i >= 0; i--) {\n if (rectContains(nodes[i], point)) return nodes[i].id\n }\n return undefined\n}\n\n/** Where an edge enters a node: the middle of its left side. */\nexport const inputAnchor = (rect: Rect): Point => ({ x: rect.x, y: rect.y + rect.height / 2 })\n\n/** Where an edge leaves a node that has `count` output ports: spread down its right side. */\nexport const outputAnchor = (rect: Rect, index = 0, count = 1): Point => ({\n x: rect.x + rect.width,\n y: rect.y + (rect.height * (index + 1)) / (Math.max(count, 1) + 1),\n})\n\nexport interface EdgeCurveOptions {\n /**\n * How far an edge that runs backwards (its target is to the left of its source) swings below\n * the two nodes so that it does not cross them (default 90).\n */\n clearance?: number\n}\n\n/**\n * The curve of an edge that leaves `from` to the right and enters `to` from the left. A forward\n * edge is a plain S; a backward one (a loop) swings out and around.\n */\nexport const edgeCurve = (from: Point, to: Point, options: EdgeCurveOptions = {}): Curve => {\n const dx = to.x - from.x\n const dy = to.y - from.y\n if (dx >= 40) {\n const reach = Math.max(dx / 2, 40)\n return {\n p0: from,\n p1: { x: from.x + reach, y: from.y },\n p2: { x: to.x - reach, y: to.y },\n p3: to,\n }\n }\n const reach = clamp(60 + Math.abs(dx) / 4, 60, 220)\n const clearance = options.clearance ?? 90\n // Nearly level: go around below. Otherwise the height difference already keeps it clear.\n const swing = Math.abs(dy) < clearance ? clearance + Math.abs(dy) / 2 : 0\n return {\n p0: from,\n p1: { x: from.x + reach, y: from.y + swing },\n p2: { x: to.x - reach, y: to.y + swing },\n p3: to,\n }\n}\n\nconst round = (n: number): number => Math.round(n * 100) / 100\n\n/** The SVG path data of a curve. */\nexport const curvePath = ({ p0, p1, p2, p3 }: Curve): string =>\n `M ${round(p0.x)} ${round(p0.y)} C ${round(p1.x)} ${round(p1.y)}, ${round(p2.x)} ${round(p2.y)}, ${round(p3.x)} ${round(p3.y)}`\n\n/** The point of a curve at `t` in 0..1. */\nexport const curvePoint = ({ p0, p1, p2, p3 }: Curve, t: number): Point => {\n const u = 1 - t\n const a = u * u * u\n const b = 3 * u * u * t\n const c = 3 * u * t * t\n const d = t * t * t\n return {\n x: a * p0.x + b * p1.x + c * p2.x + d * p3.x,\n y: a * p0.y + b * p1.y + c * p2.y + d * p3.y,\n }\n}\n\nconst distanceToSegment = (p: Point, a: Point, b: Point): number => {\n const dx = b.x - a.x\n const dy = b.y - a.y\n const length = dx * dx + dy * dy\n const t = length === 0 ? 0 : clamp(((p.x - a.x) * dx + (p.y - a.y) * dy) / length, 0, 1)\n return Math.hypot(p.x - (a.x + t * dx), p.y - (a.y + t * dy))\n}\n\n/** How far `point` is from a curve (the curve is walked in `samples` straight pieces). */\nexport const distanceToCurve = (curve: Curve, point: Point, samples = 24): number => {\n let best = Infinity\n let previous = curve.p0\n for (let i = 1; i <= samples; i++) {\n const next = curvePoint(curve, i / samples)\n best = Math.min(best, distanceToSegment(point, previous, next))\n previous = next\n }\n return best\n}\n\n/** The id of the edge within `tolerance` of `point`, the nearest one when several are. */\nexport const hitEdge = (\n edges: { id: string; curve: Curve }[],\n point: Point,\n tolerance = 8,\n): string | undefined => {\n let best: string | undefined\n let bestDistance = Infinity\n for (const edge of edges) {\n const distance = distanceToCurve(edge.curve, point)\n if (distance <= tolerance && distance < bestDistance) {\n best = edge.id\n bestDistance = distance\n }\n }\n return best\n}\n\n/**\n * The order a keyboard walks the nodes in: left to right, then top to bottom - the direction a\n * graph that flows from its entry to its end is read in. Nodes in the same column (within\n * `column` pixels) count as level.\n */\nexport const readingOrder = <T extends Point & { id: string }>(nodes: T[], column = 40): string[] =>\n nodes\n .map((node, index) => ({ node, index }))\n .sort((a, b) => {\n const ax = Math.round(a.node.x / column)\n const bx = Math.round(b.node.x / column)\n return ax - bx || a.node.y - b.node.y || a.index - b.index\n })\n .map(({ node }) => node.id)\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACwBO,IAAM,sBAAoC;AAAA,EAC/C,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM,CAAC,MAAM,IAAI,gBACf,mBAAmB,IAAI,OAAO,EAAE,GAAG,cAAc,KAAK,WAAW,KAAK,EAAE;AAAA,EA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