@dudko.dev/agent-web 0.0.19 → 0.0.21
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 +59 -1
- package/dist/agent-web.js +138 -100
- package/dist/agent-web.js.map +1 -1
- package/dist/{chunk-H7W6MBK2.js → chunk-V7COB2EA.js} +6 -2
- package/dist/chunk-V7COB2EA.js.map +1 -0
- package/dist/index.cjs +2210 -210
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1069 -69
- package/dist/index.d.ts +1069 -69
- package/dist/index.js +2134 -190
- package/dist/index.js.map +1 -1
- package/dist/mcp.cjs +88 -37
- package/dist/mcp.cjs.map +1 -1
- package/dist/mcp.d.cts +10 -0
- package/dist/mcp.d.ts +10 -0
- package/dist/mcp.js +85 -37
- package/dist/mcp.js.map +1 -1
- package/package.json +13 -13
- package/dist/chunk-H7W6MBK2.js.map +0 -1
package/README.md
CHANGED
|
@@ -16,6 +16,16 @@ agent — with host-defined **tools**, optional **MCP**, **system prompts**,
|
|
|
16
16
|
**IndexedDB** storage, and an **encrypted token vault**. UI-agnostic: it streams
|
|
17
17
|
typed events; you render them however you like.
|
|
18
18
|
|
|
19
|
+
The agent loop also has **thinking** (portable reasoning levels or exact
|
|
20
|
+
budgets), **token limits** (input / output / thinking / total per run),
|
|
21
|
+
**context compaction** (automatic and `agent.compact()`), **prompt caching**,
|
|
22
|
+
**skills** (SKILL.md bundles), **tool consent modes with an autopilot switch**,
|
|
23
|
+
**tool search** for catalogues of hundreds of MCP tools, **subagents** in
|
|
24
|
+
Web Workers, **image / PDF / file / URL input** (with a clear error for models
|
|
25
|
+
that can't take them),
|
|
26
|
+
and a **virtual file system** in IndexedDB with `fs_*` tools — see
|
|
27
|
+
[docs/capabilities.md](docs/capabilities.md).
|
|
28
|
+
|
|
19
29
|
[](https://www.npmjs.com/package/@dudko.dev/agent-web)
|
|
20
30
|
[](https://www.npmjs.com/package/@dudko.dev/agent-web)
|
|
21
31
|
[](https://www.npmjs.com/package/@dudko.dev/agent-web)
|
|
@@ -191,6 +201,13 @@ Browsers can only speak the **HTTP (StreamableHTTP)** transport — stdio MCP is
|
|
|
191
201
|
Node-only. The connector lives in the `./mcp` subpath so the MCP SDK never
|
|
192
202
|
enters your core bundle.
|
|
193
203
|
|
|
204
|
+
Pass several servers at once — they connect concurrently, each with its own
|
|
205
|
+
deadline (`connectTimeoutMs`, default 30 s), every page of a paginated
|
|
206
|
+
`tools/list` is read, and tools a server marks `readOnlyHint` are treated as
|
|
207
|
+
read-only by the consent gate. A failing server is reported in `results`; the
|
|
208
|
+
others still mount. With hundreds of tools the agent switches to tool search
|
|
209
|
+
automatically (see [docs/capabilities.md](docs/capabilities.md#large-tool-catalogues-several-mcp-servers)).
|
|
210
|
+
|
|
194
211
|
`connectMcpHttp` returns `{ tools, catalog, results, refreshServer, close }`.
|
|
195
212
|
`tools` and `catalog` are mutated **in place** by `refreshServer(name)`, so an
|
|
196
213
|
agent built from them picks up a server's new tool list (react to it via the
|
|
@@ -270,6 +287,35 @@ browser's silence: it re-probes the endpoint with a plain request and, if that
|
|
|
270
287
|
gets through, says which header is being refused. `diagnoseMcpCors(url)` is
|
|
271
288
|
exported so a UI can show the same sentence.
|
|
272
289
|
|
|
290
|
+
## Thinking, limits, consent, skills, subagents
|
|
291
|
+
|
|
292
|
+
```ts
|
|
293
|
+
import { createAgent, createSubagentTool, defineSkill } from '@dudko.dev/agent-web'
|
|
294
|
+
|
|
295
|
+
const agent = await createAgent({
|
|
296
|
+
model,
|
|
297
|
+
tools: { ...tools, ...mcp.tools },
|
|
298
|
+
thinking: 'high', // or { level, budgetTokens }; per stage via stageThinking
|
|
299
|
+
limits: { maxTotalTokens: 200_000, maxReasoningTokens: 20_000 },
|
|
300
|
+
maxToolCalls: 40,
|
|
301
|
+
compaction: { contextWindowTokens: 128_000 }, // auto-compacts history and long runs
|
|
302
|
+
skills: [defineSkill({ name: 'triage', description: 'Triage a bug report', content: '…' })],
|
|
303
|
+
toolApproval: {
|
|
304
|
+
mode: 'ask-writes', // autopilot | ask-writes | ask-all | read-only
|
|
305
|
+
onRequest: async (req) => window.confirm(`Allow ${req.toolName}?`),
|
|
306
|
+
},
|
|
307
|
+
})
|
|
308
|
+
agent.setToolApprovalMode('autopilot') // flip the switch at any time
|
|
309
|
+
await agent.compact() // summarise the stored transcript now
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
With more than 40 tools (several MCP servers) the executor switches to **tool
|
|
313
|
+
search**: it starts each step small and calls `find_tools` to activate what it
|
|
314
|
+
needs. Subagents are tools too — `createSubagentTool({ config })` runs a child
|
|
315
|
+
agent in-process, `createSubagentTool({ worker, workerConfig })` isolates it in a
|
|
316
|
+
Web Worker served by `serveSubagentWorker()`. Details, defaults and events:
|
|
317
|
+
**[docs/capabilities.md](docs/capabilities.md)**.
|
|
318
|
+
|
|
273
319
|
## Configuration (highlights)
|
|
274
320
|
|
|
275
321
|
| Option | Default | Purpose |
|
|
@@ -280,6 +326,15 @@ exported so a UI can show the same sentence.
|
|
|
280
326
|
| `tools` | `{}` | host tools (`defineTool`) |
|
|
281
327
|
| `availableTools` / `excludedTools` | — | whitelist / blacklist of tool names mounted from `tools` |
|
|
282
328
|
| `toolMode` | `'auto'` | `native` \| `prompted` \| `auto` (cloud→native, local→prompted) |
|
|
329
|
+
| `toolSelectionStrategy` | `'auto'` | `all` \| `plan-narrowed` \| `search` \| `auto` (search above `toolSearchThreshold`, 40) |
|
|
330
|
+
| `toolApproval` | autopilot | consent policy: `{ mode, rules, onRequest, timeoutMs }`; `agent.setToolApprovalMode()` |
|
|
331
|
+
| `skills` | — | SKILL.md bundles (`defineSkill` / `parseSkillMarkdown` / `loadSkillFromUrl`) |
|
|
332
|
+
| `thinking` / `stageThinking` | provider default | `true`, a level (`'low'`…`'xhigh'`, `'none'`), or `{ level, budgetTokens, includeThoughts }` |
|
|
333
|
+
| `limits` | — | run caps `maxInputTokens` / `maxOutputTokens` / `maxReasoningTokens` / `maxTotalTokens` + `perCall` output caps |
|
|
334
|
+
| `maxToolCalls` / `maxPlanSteps` | ∞ / 8 | tool calls per run / steps per plan |
|
|
335
|
+
| `compaction` | auto, ½ of 128k | `{ auto, contextWindowTokens, thresholdTokens, keepRecentTurns, keepRecentSteps, maxToolOutputChars }` |
|
|
336
|
+
| `promptCaching` | `true` | stable system prefixes, Anthropic breakpoints, OpenAI cache key |
|
|
337
|
+
| `vision` / `inputs` | inferred | what the model takes as attachments (`run(goal, { images, files })`); see `agent.capabilities` |
|
|
283
338
|
| `systemPrompt` | — | prepended to every phase |
|
|
284
339
|
| `describeState` | — | serialize world state into prompt context |
|
|
285
340
|
| `memory` | — | `ContextStore` (`IndexedDBStore` / `MemoryStore`); recent turns are read back into the planner prompt |
|
|
@@ -287,11 +342,14 @@ exported so a UI can show the same sentence.
|
|
|
287
342
|
| `chatTimeoutMs` | 120000 | per-call watchdog |
|
|
288
343
|
| `replan` / `synthesize` | `true` | toggle phases |
|
|
289
344
|
| `replanAfter` | `'failure'` | replan trigger: `'failure'` \| `'always'` \| `(stepResult) => boolean \| Promise<boolean>` |
|
|
290
|
-
| `compressAfterChars` | 12000 | summarize old history past this size |
|
|
345
|
+
| `compressAfterChars` | 12000 | legacy: summarize old history past this size (when `compaction` is unset) |
|
|
291
346
|
|
|
292
347
|
## Docs
|
|
293
348
|
|
|
294
349
|
- [docs/design.md](docs/design.md) — architecture & rationale.
|
|
350
|
+
- [docs/capabilities.md](docs/capabilities.md) — thinking, limits, compaction,
|
|
351
|
+
caching, skills, tool consent / autopilot, large MCP catalogues, subagents,
|
|
352
|
+
autonomy, event reference.
|
|
295
353
|
- [docs/providers.md](docs/providers.md) — every provider, CORS & direct-vs-proxy.
|
|
296
354
|
- [docs/security.md](docs/security.md) — the token vault & its threat model.
|
|
297
355
|
- [docs/tasks.md](docs/tasks.md) — status & roadmap.
|