@dudko.dev/agent 0.0.49 → 0.0.50
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 +47 -10
- package/dist/cli.js +121 -116
- package/dist/index.cjs +103 -103
- package/dist/index.d.cts +71 -7
- package/dist/index.d.ts +71 -7
- package/dist/index.js +103 -103
- package/dist/subagent-worker.js +85 -85
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -292,7 +292,7 @@ What is different on 2026-07-28:
|
|
|
292
292
|
- **OAuth** is unchanged: the probe is simply the first request to get the 401.
|
|
293
293
|
- **stdio.** `'auto'` and `'modern'` ask on a **second, short-lived process** started from the same `command` (a 2025 server may exit on a request it does not know; that must not cost the session its process): the command runs twice per connect. A server that does not answer the probe at all is taken for a 2025 one after 5 s (half the connect timeout, if that is less).
|
|
294
294
|
|
|
295
|
-
`MCP_SERVERS` (the CLI) takes the field as it is: `{"crm":{"url":"https://…","protocol":"auto"}}
|
|
295
|
+
`MCP_SERVERS` (the CLI) takes the field as it is: `{"crm":{"url":"https://…","protocol":"auto"}}` - and `skills` and `connectTimeoutMs` the same way (see [CLI](#cli)).
|
|
296
296
|
|
|
297
297
|
### MCP over OAuth 2.1
|
|
298
298
|
|
|
@@ -315,7 +315,7 @@ await finishMcpOAuth(auth, { code, state, iss }) // iss: pass it when the redire
|
|
|
315
315
|
await agent.reconnect()
|
|
316
316
|
```
|
|
317
317
|
|
|
318
|
-
Nothing is printed or opened on your behalf; `onAuthorizationUrl` and the loopback listener are yours to wire. `agent.listTools()` stays empty until the flow completes — a server that needs authorization reports `needsAuthorization: true` in its connect result rather than a generic failure. `MCP_SERVERS` (the CLI's env config) is JSON, so it can only express `headers
|
|
318
|
+
Nothing is printed or opened on your behalf; `onAuthorizationUrl` and the loopback listener are yours to wire. `agent.listTools()` stays empty until the flow completes — a server that needs authorization reports `needsAuthorization: true` in its connect result rather than a generic failure. `MCP_SERVERS` (the CLI's env config) is JSON, so it can only express static `headers` (plus `protocol`, `skills` and `connectTimeoutMs`); OAuth is a library-level feature.
|
|
319
319
|
|
|
320
320
|
- **`iss` (RFC 9207).** `finishMcpOAuth` checks the `iss` query parameter of the redirect against the authorization server the flow was started with, after `state` and before the code is exchanged. A different issuer is refused (a mix-up attack: a code meant for one server sent to another), and so is a missing `iss` when the server's metadata says `authorization_response_iss_parameter_supported: true`. The comparison is exact, character for character. Read `iss` off the callback URL together with `code` and `state`; `checkAuthorizationResponseIssuer` is the rule on its own.
|
|
321
321
|
- **`clientMetadataUrl` (CIMD).** Host a client ID metadata document and pass its URL: an authorization server that advertises `client_id_metadata_document_supported` takes the URL as the `client_id`, and no registration request is made. Other servers get dynamic registration as before, and a registration already in the store wins over both. The URL must be https with a path (anything else throws when the provider is built), and the document must list the same `redirect_uris` as `redirectUrl`.
|
|
@@ -554,7 +554,7 @@ Progressive disclosure keeps them cheap:
|
|
|
554
554
|
|
|
555
555
|
1. The planner and executor system prompts carry only an index: `- name: description`.
|
|
556
556
|
2. The planner's plan has an optional `skills` field naming the skills that apply (unknown names are dropped with a warning). Their instructions are injected into the executor, replanner and synthesizer system prompts for the rest of the run (24k chars in total, clipped beyond that).
|
|
557
|
-
3. The executor gets two read-only built-in tools: `load_skill({ name })` returns `{ name, content, files }` and activates the skill for later steps; `read_skill_file({ name, path })` returns a bundled file. Both always run without approval (an MCP server's skill is the one exception: a person sees it first - [MCP skills](#mcp-skills-experimental)).
|
|
557
|
+
3. The executor gets two read-only built-in tools: `load_skill({ name })` returns `{ name, content, files }` and activates the skill for later steps; `read_skill_file({ name, path })` returns a bundled file - or, when `path` names a directory of the skill (`templates/`, `.` for the root), its listing: `{ name, directory, files, directories, more? }`, the direct children by their paths inside the skill, sorted, at most 64 (`more` counts the rest; a file of that name wins). Both always run without approval (an MCP server's skill is the one exception: a person sees it first - [MCP skills](#mcp-skills-experimental)).
|
|
558
558
|
|
|
559
559
|
Every activation emits `skill.activated` (`by: 'plan' | 'tool'`). A host or MCP tool named `load_skill` / `read_skill_file` is a configuration error. `parseSkillMarkdown(markdown, files?)` and `defineSkill(skill)` validate skills you build yourself (names match `[a-z0-9-]{1,64}`). `loadSkillsFromDir` bundles text files (`.md .txt .json .yaml .yml .csv .ts .js .py .sh .html .css .xml .toml`, up to 256 KB each).
|
|
560
560
|
|
|
@@ -570,6 +570,8 @@ const agent = await createAgent({
|
|
|
570
570
|
docs: { url: 'https://docs.example.com/mcp', protocol: 'auto', skills: true },
|
|
571
571
|
// A server you vetted: its skills load without asking anyone.
|
|
572
572
|
ours: { url: 'https://mcp.internal.example/mcp', protocol: 'auto', skills: { consent: 'never' } },
|
|
573
|
+
// A server you trust with its GENERATED skills (no checksums): see "Generated skills" below.
|
|
574
|
+
gen: { url: 'https://gen.example.com/mcp', protocol: 'auto', skills: { dynamic: true } },
|
|
573
575
|
},
|
|
574
576
|
// A person sees each skill before the model does (see "Consent" below).
|
|
575
577
|
toolApproval: { onRequest: askThePerson },
|
|
@@ -578,7 +580,7 @@ agent.listSkills()
|
|
|
578
580
|
// [{ name: 'docs/pdf-processing', description: 'Extract, fill and assemble PDF documents [from the MCP server "docs" - third-party]', server: 'docs' }, ...]
|
|
579
581
|
```
|
|
580
582
|
|
|
581
|
-
- **Off by default.** Without `skills` (`true`, or `{ consent }`) the extension is not declared
|
|
583
|
+
- **Off by default.** Without `skills` (`true`, or `{ consent, dynamic }`) the extension is not declared
|
|
582
584
|
and nothing of it is sent. With it, the extension is declared only where 2026-07-28 may be spoken (`protocol:
|
|
583
585
|
'auto'` or `'modern'`): on `protocol: 'legacy'` (or none) a warning says so and nothing is
|
|
584
586
|
asked, and an `'auto'` connection that ends on a 2025 revision lists no skills. There is no
|
|
@@ -604,16 +606,48 @@ agent.listSkills()
|
|
|
604
606
|
whatever the mode, a rule or an earlier "always allow" say; with no `onRequest`, it is refused.
|
|
605
607
|
- **Caps.** At most 32 skills per server and 64 in all in the catalog, 16 000 characters of a
|
|
606
608
|
skill's instructions and 32 000 of one file - each cut said, never silent. Entries over the
|
|
607
|
-
extension's own limits (512 files, 16 MiB), `"dynamic"` ones (no digests to check
|
|
608
|
-
whose URI and frontmatter name disagree
|
|
609
|
+
extension's own limits (512 files, 16 MiB), `"dynamic"` ones (no digests to check; unless the
|
|
610
|
+
server has `skills: { dynamic: true }`, below), and ones whose URI and frontmatter name disagree
|
|
611
|
+
are refused, with a warning.
|
|
609
612
|
- **Changes.** A change of a server's skills is announced as a resource list change: the agent
|
|
610
613
|
re-lists them the way it re-lists tools after a `tools/list_changed` (between runs).
|
|
614
|
+
- **Directories.** `read_skill_file` with a directory of an MCP skill (`templates/`, `.`) lists
|
|
615
|
+
it from the entry the skill was loaded and approved with - the held entry is authoritative, and
|
|
616
|
+
the same consent comes first as for a file. When the server declared `directoryRead`, the agent
|
|
617
|
+
also sends `resources/directory/read` for that directory (`skill://<path>/<dir>`, no trailing
|
|
618
|
+
slash) to THAT server, only to see whether the skill changed there: a child the server lists and
|
|
619
|
+
the entry does not is never shown - not its name, URI or type; the listing gets a fixed `note`
|
|
620
|
+
("The server now lists 1 more item(s) here than the approved entry of this skill: the skill
|
|
621
|
+
changed on the server ..."), a warning is logged (counts only) and the server's skills are
|
|
622
|
+
listed again between runs (as after a resource list change; a changed entry is asked about
|
|
623
|
+
again). A child of the entry the server no longer lists stays in the listing and is also named
|
|
624
|
+
in `notServed` (a read of it will fail). If the directory read fails, the listing comes from the
|
|
625
|
+
entry alone (a log line); a stop of the run still stops it. Without `directoryRead` the method
|
|
626
|
+
is never called. A generated skill's directories are listed from its snapshot, the same way.
|
|
627
|
+
- **Generated skills (opt-in, per server).** A `"dynamic"` entry - the server generates the skill
|
|
628
|
+
and publishes no checksums - is declined unless THAT server has `skills: { dynamic: true }`
|
|
629
|
+
(no agent-wide switch). It then joins the catalog like any other, its line ending
|
|
630
|
+
`[from the MCP server "gen" - third-party, no checksums]`. When it would enter the context -
|
|
631
|
+
BEFORE anyone is asked - the agent reads all of it once: `SKILL.md` (its frontmatter compared
|
|
632
|
+
with the entry's) and, if the server declared `directoryRead`, its directory tree (direct
|
|
633
|
+
children each time, only `inode/directory` children inside the skill, never twice) and every
|
|
634
|
+
file found. Bounds: 512 files and 16 MiB read (the extension's limits, counted on what is
|
|
635
|
+
read), 64 directories, 8 levels deep, and 64 MiB held by all of the agent's copies
|
|
636
|
+
(`MCP_SKILL_SNAPSHOTS_MAX_BYTES`); past any of them it is declined - nobody is asked, the model
|
|
637
|
+
is told why, a warning says it. The agent computes each file's size and SHA-256 itself, and that
|
|
638
|
+
copy (a "snapshot") is the skill's entry from then on: the request carries `skill.dynamic` and
|
|
639
|
+
the copy's size, files and text; a yes binds to the copy's digests (after a refresh the agent
|
|
640
|
+
takes a new copy - one that differs is asked about again under `'once-per-skill'`, the same
|
|
641
|
+
bytes are not); and the model gets that copy only - its body, and every file from memory, never
|
|
642
|
+
read from the server again. Without `directoryRead` the copy is `SKILL.md` alone
|
|
643
|
+
(`skill.noFileListing`; no other file can be read). Nothing of a copy is written anywhere -
|
|
644
|
+
not to a checkpoint, an event or a log. `'never'` works too, for a vetted server.
|
|
611
645
|
- **Consent: a person sees a skill before the model does.** The first time a server's skill would
|
|
612
646
|
enter the model's context - `load_skill`, the planner picking it, a resumed run, or
|
|
613
647
|
`read_skill_file` of one of its files - its `SKILL.md` is read and verified, then put to
|
|
614
648
|
`toolApproval.onRequest` as a request with `skill` (`McpSkillConsentView`: `server`, `name`,
|
|
615
649
|
`skill`, `uri`, `description`, `size` / `totalSize`, `files` / `fileCount`, `byUri`, `nestedIn`,
|
|
616
|
-
`consent`, and `body` - the very text the model would read, cleaned and capped as the model gets
|
|
650
|
+
`dynamic` / `noFileListing` (a generated skill: the copy just read), `consent`, and `body` - the very text the model would read, cleaned and capped as the model gets
|
|
617
651
|
it); `toolName` is `load_skill`, `input` what it was called with. A yes lets it in; `remember:
|
|
618
652
|
true` ("Always for this server") lets in that server's other skills for the agent's life; a no
|
|
619
653
|
keeps all of it out - the model is told so ("The user did not allow the skill ... nothing of it
|
|
@@ -640,8 +674,9 @@ agent.listSkills()
|
|
|
640
674
|
[security notes](https://github.com/dudko-dev/agents/blob/main/packages/agent-web/docs/security.md#mcp-skills-third-party-instructions)
|
|
641
675
|
say what a server's skill can and cannot do; its
|
|
642
676
|
[design notes](https://github.com/dudko-dev/agents/blob/main/packages/agent-web/docs/design.md#mcp-skills-one-catalog-namespaced-under-a-preamble-opt-in)
|
|
643
|
-
why it is namespaced, loaded under a preamble and opt-in,
|
|
644
|
-
|
|
677
|
+
why it is namespaced, loaded under a preamble and opt-in, why the consent is what it is, why
|
|
678
|
+
a directory is listed from the entry with the server asked only for staleness, and why a
|
|
679
|
+
generated skill is a snapshot served from memory, opt-in per server.
|
|
645
680
|
|
|
646
681
|
## Tool approval and autopilot
|
|
647
682
|
|
|
@@ -1469,7 +1504,7 @@ Consent is the host's job ([tool approval](#tool-approval-and-autopilot)) — th
|
|
|
1469
1504
|
| `decisionModel` | Off by default. A [decision model](#decision-models): an object with `decide(question, { abortSignal })` that answers a closed question with `{ choice, confidence }` (`decisionModelFromAiSdk(...)` adapts Gemini Decision 1, TypeSafe's Jev or any AI SDK decision model). 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. |
|
|
1470
1505
|
| `decision` | `{ confidenceThreshold?, timeoutMs?, replan?, route? }` (defaults `0.8`, `5000`, `true`, `true`). Below the threshold, on an error, a timeout or an answer that is not an option, the ordinary model call runs unchanged. |
|
|
1471
1506
|
| `plannerModel` / `synthesizerModel` | **Deprecated** model-only shortcuts. Equivalent to `planner: { model }` / `synthesizer: { model }`. The override block, if present, wins. |
|
|
1472
|
-
| `mcpServers` | `Record<name, { url, headers?, getHeaders?, authProvider?, fetch?, connectTimeoutMs?, protocol? } \| { command, args?, env?, cwd?, connectTimeoutMs?, protocol? }>` — StreamableHTTP for remote (legacy HTTP+SSE servers are **not** supported), stdio for locally-spawned servers. `protocol`: `'legacy'` (default) \| `'auto'` \| `'modern'` - the 2025 revisions, 2026-07-28 when the server offers it, or 2026-07-28 only; see [MCP protocol revision](#mcp-protocol-revision). `skills: true` or `{ consent: 'once-per-skill' \| 'ask' \| 'never' }` (**experimental**, needs `'auto'` / `'modern'`): load the server's skills into the catalog as `<server>/<skill>`, each let into the model's context only once a person allowed it (`consent`); off by default - see [MCP skills](#mcp-skills-experimental). |
|
|
1507
|
+
| `mcpServers` | `Record<name, { url, headers?, getHeaders?, authProvider?, fetch?, connectTimeoutMs?, protocol? } \| { command, args?, env?, cwd?, connectTimeoutMs?, protocol? }>` — StreamableHTTP for remote (legacy HTTP+SSE servers are **not** supported), stdio for locally-spawned servers. `protocol`: `'legacy'` (default) \| `'auto'` \| `'modern'` - the 2025 revisions, 2026-07-28 when the server offers it, or 2026-07-28 only; see [MCP protocol revision](#mcp-protocol-revision). `skills: true` or `{ consent: 'once-per-skill' \| 'ask' \| 'never', dynamic?: boolean }` (**experimental**, needs `'auto'` / `'modern'`): load the server's skills into the catalog as `<server>/<skill>`, each let into the model's context only once a person allowed it (`consent`); `dynamic: true` also takes its generated skills (no checksums: each read whole into a snapshot before anyone is asked, and only that copy used); off by default - see [MCP skills](#mcp-skills-experimental). |
|
|
1473
1508
|
| `tools` | Optional `ToolSet` of native AI-SDK tools registered alongside MCP-discovered ones. Names must not collide with MCP-prefixed names or the built-in tools (`createAgent` throws on conflict). Mark read-only tools with `markReadOnly(tool)`, and tools that run code with `markCodeExecution(tool)` (always asked while a run acts on an MCP server's skill). |
|
|
1474
1509
|
| `availableTools` / `excludedTools` | Whitelist / blacklist applied to **all** tools (MCP and native). |
|
|
1475
1510
|
| `maxIterations` | Cap on **executed steps** across the run (every step counts, including those run after a `revise`). |
|
|
@@ -1686,6 +1721,8 @@ The newer features are env-driven too: `AGENT_THINKING` (`off | minimal | low |
|
|
|
1686
1721
|
|
|
1687
1722
|
**`AGENT_MCP_ELICITATION`** (`off` by default, `form`, `all`) lets a connected MCP server ask *you* something in the middle of a tool call ([MCP elicitation](#mcp-elicitation-a-server-asks-the-user)). The question is printed as a quotation (`| …` in front of every line: the server's words, not the CLI's) and answered at the prompt, in the same queue as the approval questions: `y` fills in the form field by field (Enter takes a field's default or skips an optional one, a value of the wrong kind is asked for again up to three times, `/cancel` dismisses), `n` declines, anything else cancels. `all` also accepts URL mode: the link is printed for you to open yourself - the CLI never opens it. What you type goes to that server only; a question nobody decided (a cap, a timeout, a form that cannot be shown) is reported as `!! <tool>: the server's question was answered "cancel" automatically (<reason>)`. The defaults of the library apply (5 minutes per question, 5 per tool call, 20 per run); helpers started with `AGENT_SUBAGENTS` cannot ask.
|
|
1688
1723
|
|
|
1724
|
+
**MCP skills at the prompt.** A server in `MCP_SERVERS` may add `"skills": true` (or `{"consent": "once-per-skill" | "ask" | "never", "dynamic": true}` - `dynamic` also takes the server's generated skills, no checksums; any other value of it is refused at start, by the server's name) with `"protocol": "auto"` or `"modern"` - `skills` without one of those is refused at start, by the server's name, since the extension is written against 2026-07-28 and would otherwise be silently off ([MCP skills](#mcp-skills-experimental)). Before one of its skills reaches the model you are shown it at the prompt, in the same queue as the approval questions: `[skill] the server "docs" offers the skill "pdf-processing" (docs/pdf-processing)`, its description, size and URI, and the first 12 lines of exactly what the model would read, each behind `| ` (the server's words, not the CLI's; control characters removed); a generated skill adds `the server publishes no checksums for this skill: you approve the copy the agent just read, and only that copy is used` (and, from a server that cannot list its files, `the server cannot list this skill's files: that copy is its SKILL.md alone`); then `allow? [y]es / [n]o / [a]lways for this server`. `y` lets it in (for the session under `once-per-skill`, the default; for this task under `ask`), `a` every skill of that server except nested ones, anything else declines (`the user declined the skill`). A question nobody answers is closed like an approval's: `[skill] closed: <why> - docs/pdf-processing was not loaded`. `/skills` lists the server's skills with the others. `"connectTimeoutMs"` (default 30000, `0` = no bound) bounds one server's connect.
|
|
1725
|
+
|
|
1689
1726
|
**Talking to the agent while it works.** The REPL keeps reading while a run goes. Text you type then is said to the running agent (it sees it at its next boundary and the replanner re-checks the plan — see [Steering a run](#steering-a-run-that-is-already-going)): the REPL prints `[you->agent] queued` and then `delivered (round|step|final)`, and the message enters the history as a user turn. A message that arrives while the answer is being written is sent as the next prompt (`[follow-up]`). After Ctrl-C nothing is sent behind your back: what the agent never saw is listed as `[not delivered]`. While a run goes, `/agents` lists the running subagents and `/stop <n>` (or an id prefix, or just `/stop` when one runs) stops one — the run goes on; the other REPL commands work between runs. Each subagent's own steps and tool calls are logged as `[name id] ...` lines, so parallel ones can be told apart.
|
|
1690
1727
|
|
|
1691
1728
|
For local development against the source tree:
|