@dudko.dev/agent-web 0.0.49 → 0.0.51
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 +49 -4
- package/dist/agent-web.js +167 -159
- package/dist/agent-web.js.map +1 -1
- package/dist/{chunk-3V27UZT6.js → chunk-DOWC4CFZ.js} +257 -3
- package/dist/chunk-DOWC4CFZ.js.map +1 -0
- package/dist/{chunk-6XHCPSZE.js → chunk-EUJWS42C.js} +56 -5
- package/dist/{chunk-6XHCPSZE.js.map → chunk-EUJWS42C.js.map} +1 -1
- package/dist/{chunk-IT77BVAD.js → chunk-HXUR2SG5.js} +2 -2
- package/dist/{chunk-JTZEUPIG.js → chunk-NUL6QEAX.js} +49 -49
- package/dist/chunk-NUL6QEAX.js.map +1 -0
- package/dist/chunk-R5VCITT3.js +192 -0
- package/dist/chunk-R5VCITT3.js.map +1 -0
- package/dist/{chunk-7Y5UC6L7.js → chunk-SVGIGIRR.js} +3 -3
- package/dist/fit-reference-worker.cjs +158 -0
- package/dist/fit-reference-worker.cjs.map +1 -0
- package/dist/fit-reference-worker.d.cts +1 -0
- package/dist/fit-reference-worker.d.ts +1 -0
- package/dist/fit-reference-worker.js +16 -0
- package/dist/fit-reference-worker.js.map +1 -0
- package/dist/index.cjs +1333 -343
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +98 -52
- package/dist/index.d.ts +98 -52
- package/dist/index.js +546 -62
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +2 -2
- package/dist/media-fit-worker-CFK2z8LF.d.cts +149 -0
- package/dist/media-fit-worker-CFK2z8LF.d.ts +149 -0
- package/dist/{sandbox-IGTCMOOX.js → sandbox-X6T4ZOEQ.js} +3 -3
- package/dist/secrets.js +3 -3
- package/dist/{webllm-BEL5A4OF.js → webllm-EZSJGU6P.js} +2 -2
- package/package.json +14 -2
- package/dist/chunk-3V27UZT6.js.map +0 -1
- package/dist/chunk-JTZEUPIG.js.map +0 -1
- /package/dist/{chunk-IT77BVAD.js.map → chunk-HXUR2SG5.js.map} +0 -0
- /package/dist/{chunk-7Y5UC6L7.js.map → chunk-SVGIGIRR.js.map} +0 -0
- /package/dist/{sandbox-IGTCMOOX.js.map → sandbox-X6T4ZOEQ.js.map} +0 -0
- /package/dist/{webllm-BEL5A4OF.js.map → webllm-EZSJGU6P.js.map} +0 -0
package/README.md
CHANGED
|
@@ -31,7 +31,7 @@ budgets), **token limits** (input / output / thinking / total per run),
|
|
|
31
31
|
**tool search** for catalogues of hundreds of MCP tools, **subagents** in
|
|
32
32
|
Web Workers, **image / PDF / file / URL input** (with a clear error for models
|
|
33
33
|
that can't take them),
|
|
34
|
-
a **virtual file system** in IndexedDB with `fs_*` tools, **usage** counted live
|
|
34
|
+
a **virtual file system** in IndexedDB with `fs_*` tools (`fs_read` by line range too), **usage** counted live
|
|
35
35
|
across a session (`agent.usage`), **steering** a run while it goes (`RunControl`),
|
|
36
36
|
**resuming** an interrupted run, **egress** you switch on and bound (the model's
|
|
37
37
|
`web_fetch`), and **learning** — the agent writes its own lessons down as skills
|
|
@@ -964,6 +964,48 @@ sibling's `@dudko.dev/agent/pipeline-engine` is the same file. It is a copy of t
|
|
|
964
964
|
entry carries, not the same objects: an error thrown by one is not `instanceof` the other's class -
|
|
965
965
|
compare `error.name`. More: [docs/capabilities.md](docs/capabilities.md#pipelines-a-graph-of-agents).
|
|
966
966
|
|
|
967
|
+
## Memory: what a turn said, and what it did
|
|
968
|
+
|
|
969
|
+
With `memory` (`IndexedDBStore` / `MemoryStore`) every run keeps its turn in the session: the user's
|
|
970
|
+
message (with `[attached: …]` naming its files) and the answer, and on the answer's last line the
|
|
971
|
+
runner's record of what the turn **did**:
|
|
972
|
+
|
|
973
|
+
```text
|
|
974
|
+
Here you are on a dinosaur.
|
|
975
|
+
[done: generate_image → /media/image-1a2b3c4d5e6f.png (reference /attachments/me.png used); fs_write /notes.md; web_search ×2]
|
|
976
|
+
```
|
|
977
|
+
|
|
978
|
+
The next turns' planner and answering stage read it in their `CONVERSATION SO FAR`, with one fixed
|
|
979
|
+
sentence saying what such a line is (`ACTION_RECORD_NOTE`, in the user prompt and only while a record
|
|
980
|
+
is shown: the system prompts do not change). Without it a later turn knows only what an answer
|
|
981
|
+
SAID: "did you use my photo?" was answered "no" from a vague earlier answer, though the photo had
|
|
982
|
+
gone with the prompt.
|
|
983
|
+
|
|
984
|
+
- **Written by the runner, never by a model**, from the run's own events: each tool by name, how its
|
|
985
|
+
calls ended (`×n`, `failed`, `denied`, `unfinished` - no result came before a stop), the paths the
|
|
986
|
+
file tools wrote or deleted, what `generate_image` / `generate_speech` made and generate_image's
|
|
987
|
+
reference pictures (`used` / `NOT used`), which helper (`spawn_subagent`, by its role), whether a
|
|
988
|
+
question was answered (`ask_user`: `answered` / `declined` / `not answered` - never the words),
|
|
989
|
+
the files a `run_js` program wrote. A helper's own calls are its own run's. `find_tools`,
|
|
990
|
+
`load_skill` and `read_skill_file` are left out; a turn without a tool call has no record.
|
|
991
|
+
- **Bounded and cleaned**: at most 300 characters (`ACTION_RECORD_MAX_CHARS`, then "; and n more"),
|
|
992
|
+
three paths per tool (", +n more"), a path or name at most 60 characters, one line, no bracket,
|
|
993
|
+
`;`, control or invisible character. A path the model chose is data, never instructions.
|
|
994
|
+
- **Only the runner writes one**: a `[done:` in a model's answer, a summary or the user's own message
|
|
995
|
+
is kept as `(done:`.
|
|
996
|
+
- **A stopped or failed run** keeps what it did before it ended (when a tool ran):
|
|
997
|
+
`(The run was stopped before it answered.)` and the record.
|
|
998
|
+
- **Clipping and compaction keep it**: a message clipped to 400 characters in the planner's prompt
|
|
999
|
+
keeps its record, and a compaction summary keeps the records of the turns it folds in after the
|
|
1000
|
+
model's text (the newest, up to 900 characters); the summariser is told what they are.
|
|
1001
|
+
- `result.actionRecord` is the record (also on a stopped or failed run); `withActionRecord(text,
|
|
1002
|
+
record)` makes the stored text, for a host that keeps a transcript of its own (with
|
|
1003
|
+
`neutralizeActionRecords(text)` for the user's own message); `actionRecordOf(x)` reads it from a
|
|
1004
|
+
result. A transcript rebuilt from a UI's messages (a backup restore) has none.
|
|
1005
|
+
|
|
1006
|
+
Details: [the memory](docs/capabilities.md#memory-what-a-turn-said-and-what-it-did) ·
|
|
1007
|
+
[why the runner writes it](docs/design.md#the-action-record-written-by-the-runner-not-the-model).
|
|
1008
|
+
|
|
967
1009
|
## Several tabs
|
|
968
1010
|
|
|
969
1011
|
An installed PWA window and a browser tab of the same site share IndexedDB - the vault, the files,
|
|
@@ -1010,7 +1052,10 @@ await watch.stop()
|
|
|
1010
1052
|
(marked `origin: 'another-tab'`) or a stop.
|
|
1011
1053
|
- **`watchSession`**: the run's events (clipped), its state (`running`, `ended: 'done' | 'stopped' |
|
|
1012
1054
|
'gone'`), a replay for a tab that joins late, `send` and `stop`. Tool approvals never cross: they
|
|
1013
|
-
are answered in the tab that runs the tool.
|
|
1055
|
+
are answered in the tab that runs the tool. `send`'s answer is the running tab's - taken, refused,
|
|
1056
|
+
or that run ended (or its tab went) without taking it - with **no time limit**: a phone freezes a
|
|
1057
|
+
tab out of sight, and the frozen tab takes the message when it wakes, so a UI must not offer it
|
|
1058
|
+
again before that answer (it would get a second run).
|
|
1014
1059
|
- **A deletion or an upgrade in another tab is never held up**: the one connection per database
|
|
1015
1060
|
closes on `versionchange`; the next use opens a new, empty database after a deletion (the vault
|
|
1016
1061
|
makes a new key there), and fails with a `VersionError` after an upgrade by a newer copy, until a
|
|
@@ -1043,7 +1088,7 @@ Details: [Several tabs](docs/capabilities.md#several-tabs) ·
|
|
|
1043
1088
|
| `mcpSkills` | `{ consent: 'once-per-skill' }` | experimental: when a person is asked (`toolApproval.onRequest`, a request with `skill`) before an MCP server's skill enters the model's context, for servers whose `skills: { consent }` does not say - `'once-per-skill'`, `'ask'` (every run) or `'never'` - see [MCP skills](#mcp-skills-experimental-a-servers-instructions-as-skills) |
|
|
1044
1089
|
| `egress` | off | what the **model** may fetch (`web_fetch`): `true` = any public host over https, or `{ allow, deny, protocols, allowPrivateNetwork, fetch, ... }`; a browser can't pin DNS, so prefer an `allow` list — see [Egress](docs/capabilities.md#egress-what-the-model-may-fetch) |
|
|
1045
1090
|
| `search` | off | the model may **search the web** (`web_search`: a short list of title / url / snippet): `{ engine: fn }` - a search engine of yours, any API (it may answer `{ results, usage }`: a search through a model is charged as phase `'search'`) - or `{ provider: 'google', credentialRef, model, baseURL, maxResults, allowPrivateNetwork, readOnly, fetch }` - Google Search through Gemini grounding: one extra `generateContent` call per search on a Gemini key (default model `gemini-2.5-flash-lite`), which **spends model tokens** (`usage` phase `'search'`) and returns **Google redirect links**, not the pages' URLs. No key ships with the library and none is written in the config (`credentialRef` names it in `credentials`); the request reaches only that API; with `egress`, results the model could not fetch are left out. Recipes for Tavily / Brave / SearXNG as an `engine`, the free-tier models and what the redirect links mean — see [Search](docs/capabilities.md#search-finding-the-page-to-fetch) |
|
|
1046
|
-
| `media` | off | image generation, speech and transcription as tools, each mounted only when its model is set: `{ imageModel, speechModel, transcriptionModel, maxCalls, timeoutMs, files, folder, voice, speechFormat, transcribeAttachments }`. A model is an AI SDK image / speech / transcription model object or a `ProviderModelSpec` (key by `credentialRef`). Generated files go to the virtual file system and the model gets a path, never the bytes; attached audio is transcribed to text; calls are counted in `usage.mediaCalls` (and the other media fields) and capped per run — see [Media](docs/capabilities.md#media-images-speech-and-transcription) |
|
|
1091
|
+
| `media` | off | image generation, speech and transcription as tools, each mounted only when its model is set: `{ imageModel, imageInputs, fitReference, fitTimeoutMs, speechModel, transcriptionModel, maxCalls, timeoutMs, files, folder, voice, speechFormat, transcribeAttachments }`. A model is an AI SDK image / speech / transcription model object or a `ProviderModelSpec` (key by `credentialRef`). Generated files go to the virtual file system and the model gets a path, never the bytes; `generate_image({ prompt, images? })` sends up to 4 reference pictures of the workspace (the person's photo, "like this") to an image model that takes them (`imageInputs`, else the model's own `supportsFileInputs`) - checked by their bytes and capped (4096 px, 8 MiB each, 12 MiB together); one that takes none makes the picture from the text and the result says so; a picture over those bounds is refused - or, with `fitReference`, sent as a smaller copy (the workspace file stays the original): `fitReferenceInWorker(() => new Worker(new URL('@dudko.dev/agent-web/fit-reference-worker', import.meta.url), { type: 'module' }))` runs the ready `fitReferenceImage` (the browser's `createImageBitmap` + `OffscreenCanvas`; JPEG for photos, PNG kept when it fits) in a Web Worker, so the page never waits on an encode; only an original within 50 MiB / 200 MP (read from its header) is ever handed over, the copy is checked again, the result lists it in `references.fitted`, and `fitTimeoutMs` (30 000) bounds each call; attached audio is transcribed to text; calls are counted in `usage.mediaCalls` (and the other media fields) and capped per run — see [Media](docs/capabilities.md#media-images-speech-and-transcription) |
|
|
1047
1092
|
| `decisionModel` | off | a **decision model** - answers a closed question with one option and a probability instead of writing text: `{ providerType: 'google', model: 'gemini-decision-1', credentialRef }` (the key stays in `credentials`; the request reaches only that API) or an object with `decide(question, { abortSignal })`. Where it is confident it replaces the replanner's continue / finish call and a pipeline node's route call; never consulted for tool approval or egress — see [Decision models](docs/capabilities.md#decision-models) |
|
|
1048
1093
|
| `decision` | `{}` | `{ confidenceThreshold, timeoutMs, replan, route }` (defaults 0.8, 5000 ms, on, on): below the threshold, on an error, a timeout or an answer that is not an option, the ordinary model call runs unchanged |
|
|
1049
1094
|
| `askUser` | off | the **model** may ask the person ONE closed question with buttons instead of guessing (the built-in `ask_user`: a question, 2-6 options, optionally `multiple` or `allowOther`): `{ onQuestion(req, { signal }), timeoutMs, maxPerRun }`. `onQuestion` answers `{ choice: [label] }`, `{ other: text }` or `{ declined: true }`; without it there is no tool (`true` / `{}` = the handler comes later, e.g. from `useAgent`). At most `maxPerRun` (3) per run, helpers and subagents included; each waits `timeoutMs` (300000; the step's limit stops meanwhile), a stop ends the wait. Events `user.question-asked` / `user.question-answered` (the labels picked, never the person's own words). The question and options are the model's text, cleaned: render them as plain text. See [Asking the user](docs/capabilities.md#asking-the-user-a-question-with-choices) |
|
|
@@ -1059,7 +1104,7 @@ Details: [Several tabs](docs/capabilities.md#several-tabs) ·
|
|
|
1059
1104
|
| `systemPrompt` / `prompts` | — | prepended to every phase / override any phase's prompt builder |
|
|
1060
1105
|
| `mcpInstructions` | `true` | show the model the `instructions` MCP servers send on connect (planner + executor, marked third-party, capped); `false` keeps them out |
|
|
1061
1106
|
| `describeState` | — | serialize world state into prompt context |
|
|
1062
|
-
| `memory` | — | `ContextStore` (`IndexedDBStore` / `MemoryStore`); recent turns are read back into the planner prompt |
|
|
1107
|
+
| `memory` | — | `ContextStore` (`IndexedDBStore` / `MemoryStore`); recent turns are read back into the planner prompt, each answer with the runner's record of what its turn did (`[done: …]`, `result.actionRecord`) - see [Memory](#memory-what-a-turn-said-and-what-it-did) |
|
|
1063
1108
|
| `sessionId` | — | names the stored conversation in `memory`, and the bucket `agent.sessionUsage()` counts into |
|
|
1064
1109
|
| `sessionRelay` | `{ control: true }` | what the session's running tab offers the site's other tabs: its events (posted once a tab asks) and, with `control`, a message (`origin: 'another-tab'`) or a stop. `{ control: false }`: watchable only; `false`: nothing relayed — see [security](docs/security.md#several-tabs-what-crosses-and-who-can-post) |
|
|
1065
1110
|
| `sessionLock` | `'wait'` | one run per session across the site's tabs, when `memory` is shared (`IndexedDBStore`): a second run of the session waits for the first (`session.busy` / `session.acquired`), `'fail'` throws `SessionBusyError`, `'off'` = no lock and no relay (the last write wins). The running tab relays the run to the others (`watchSession`) — see [Several tabs](#several-tabs) |
|