@dudko.dev/agent 0.0.58 → 0.0.60
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 +13 -4
- package/dist/cli.js +142 -139
- package/dist/index.cjs +110 -110
- package/dist/index.d.cts +760 -755
- package/dist/index.d.ts +760 -755
- package/dist/index.js +110 -110
- package/dist/subagent-worker.js +97 -97
- package/package.json +6 -1
package/README.md
CHANGED
|
@@ -1492,6 +1492,7 @@ const { mediaCalls, imagesGenerated, transcriptionSeconds } = result.usage // 2,
|
|
|
1492
1492
|
| `imageInputs` | Whether the image model takes reference pictures. Default: what the model object declares (`supportsFileInputs`; unknown counts as no). |
|
|
1493
1493
|
| `fitReference` | Make a reference picture that is over the bounds small enough to send, instead of refusing it (below). This package ships no image codec: your function (e.g. on `sharp`), or `fitReferenceInWorker(module)` to run your module in a worker thread. It must not block the event loop. Default: none - refused. |
|
|
1494
1494
|
| `fitTimeoutMs` | One call of `fitReference`. Default `30000` (`MEDIA_FIT_TIMEOUT_MS`). |
|
|
1495
|
+
| `viewGenerated` | Show the executor's model the picture `generate_image` made, **once**, in the request right after the call (below). Default: on where the step's model reads pictures; `true`: on for any model whose adapter carries a picture in a tool result; `false`: off - the path alone. |
|
|
1495
1496
|
| `speechModel` | Mounts `generate_speech({ text, voice?, language? })`. |
|
|
1496
1497
|
| `transcriptionModel` | Mounts `transcribe_audio({ path })` and lets a run take audio in `run({ files })`. |
|
|
1497
1498
|
| `maxCalls` | Media calls **one run** may make, attachments included. Default `8` (`MEDIA_DEFAULT_MAX_CALLS`); `0` = no cap. |
|
|
@@ -1500,13 +1501,21 @@ const { mediaCalls, imagesGenerated, transcriptionSeconds } = result.usage // 2,
|
|
|
1500
1501
|
| `voice` | The voice of `generate_speech` when the model names none (a provider-specific id). |
|
|
1501
1502
|
| `speechFormat` | The format asked of the speech model (`'mp3'`, `'wav'`, ...). Default: the provider's. |
|
|
1502
1503
|
|
|
1503
|
-
**Where the bytes go.**
|
|
1504
|
+
**Where the bytes go.** Not into the context: a base64 image in a tool result would fill it and be billed as tokens on every later call (the one exception, a picture shown to the model once, is `viewGenerated`, below). `generate_image` and `generate_speech` write a file and return `{ path, mediaType, bytes }`; the `media.generated` event carries the same, so a UI shows the picture or plays the audio from the path. By default the file lands in the run's own directory (`<sandboxRoot>/<runId>/media/`, the same per-run directory binary MCP results are spilled to) and **is removed with it when the run ends** unless `keepSandbox` is set - copy it in the event handler, or set `media.dir` to a directory of yours, which the agent never cleans.
|
|
1504
1505
|
|
|
1505
1506
|
- **What a file is, is read from its bytes.** The signature decides the type and the extension; what the provider declared is ignored. Only PNG, JPEG, GIF and WebP are written as images, and MP3, WAV, Ogg, FLAC, AAC, M4A and WebM as audio. Anything else - HTML, SVG (it can carry a script), raw PCM, an empty answer - is refused and nothing is written.
|
|
1506
1507
|
- **Size caps**: an image or an audio file of at most 8 MiB is written (`MEDIA_MAX_IMAGE_BYTES`, `MEDIA_MAX_SPEECH_BYTES`); audio of at most 20 MiB is sent for transcription (`MEDIA_MAX_AUDIO_INPUT_BYTES`); a prompt or a text to speak is at most 4 000 characters.
|
|
1507
1508
|
- **The tool names the file**: `image-<random>.png`, `speech-<random>.mp3`. The model has no argument that is a path or a name, an existing file is never replaced, and the final path is checked to be a direct child of the folder.
|
|
1508
1509
|
- **`transcribe_audio` reads only inside the run's directory** (and `media.dir`): the path a tool returned for an audio file - an MCP tool's spilled audio, or a file `generate_speech` wrote. Both sides are resolved through symlinks before they are compared, so `../`, an absolute path elsewhere and a link that points out are all refused before a byte is read. The Node agent has no workspace of the user's files, which is why the tool reaches no further; the browser sibling's reads its virtual file system.
|
|
1509
1510
|
|
|
1511
|
+
**The model sees the picture it made** (`media.viewGenerated`). With only a path the model cannot check a picture against the request ("is the cat on the left?"), make a wrong one again, or say later what it drew. So after a successful `generate_image`, a model that reads pictures gets the picture itself - an image part of that call's tool result (the AI SDK's tool-result content, `{ type: 'file', mediaType, data }`) - in the executor's **next request only**: from the request after it, the picture is taken out again and a line says it was shown. Nothing else carries it: the tool's output (`{ path, mediaType, bytes }`), the `step.tool-result` and `media.generated` events, the trace and the result, snapshots, the call journal and the conversation you keep are exactly as without it; the picture waits in the run's memory until that request, and a step that ends first drops it.
|
|
1512
|
+
|
|
1513
|
+
- **Which models.** Only an executor model whose AI SDK adapter sends an image part of a tool result as an image - Gemini (`google.generative-ai`, `google.vertex.chat`), Claude (`anthropic.messages`), OpenAI's Responses API (`openai.responses`, `azure.responses`; the `openai(id)` default), xAI (`xai.responses`), DeepSeek (`deepseek.chat` / `deepseek.responses`) - read from the model object's `provider`. The others turn a tool result's content into JSON text: OpenAI's Chat Completions (`openai.chat(id)`) and every OpenAI-compatible endpoint would put megabytes of base64 into the prompt, so they **never** get one, whatever the setting says. Among those adapters the default is on for a model known to read pictures (not a text-only family - GPT-3.5, o1-mini / o3-mini, embeddings -, and only DeepSeek's Flash line); `viewGenerated: true` turns it on for any model of those adapters, `false` turns it off. Judged per step (an escalated step's model is judged again). A model given as a string (the gateway) is unknown: off.
|
|
1514
|
+
- **Bounded.** The picture is sent at most once - the request after its call - and at most 4 per step (`MEDIA_VIEW_MAX_WAITING`; one more is not shown and its result says so). At most 1568 px on the longer side and 3.75 MiB (`MEDIA_VIEW_MAX_SIDE`, `MEDIA_VIEW_MAX_BYTES`): what Anthropic reads at full detail (it scales anything larger down itself), inside OpenAI's 2048 px box, and 5 MB once base64 adds a third - Anthropic's limit for one image. A picture over either is shown as a smaller copy made by your `media.fitReference` (asked with `{ maxSide: 1568, maxBytes: 3932160 }`, its answer checked again; the file stays the original) - or, without it, **not at all**: never the full original. A picture that is not shown leaves a `pictureNote` in the result, the sentence the model reads (it then has the path only and is told not to describe it). Only PNG, JPEG and WebP are shown.
|
|
1515
|
+
- **What it costs.** One picture is about 1 100-1 600 input tokens whoever reads it (Claude ≈ width × height / 750, OpenAI 85 + 170 a 512 px tile, Gemini 258 a 768 px tile), once: at the default media budget (8 calls) at most ~13 000 tokens a run. On by default, because a model that cannot see what it made describes a picture it never saw.
|
|
1516
|
+
- **A resume.** A call the journal hands back does not run again, so it shows no picture: the journal hashes a `generate_image` result without its output (`withoutGeneratedPictures`), and the resumed run replays the requests it recorded instead of diverging.
|
|
1517
|
+
- What the picture shows is a model's output: anything written in it is part of the picture, and the text with it says so.
|
|
1518
|
+
|
|
1510
1519
|
**Reference pictures.** `generate_image({ prompt, images: ['me.jpg'] })` sends up to 4 pictures with the prompt - "a picture of me riding a dinosaur", "like this" - through the AI SDK's image prompt with images (`generateImage({ prompt: { text, images } })`: Gemini's image models get them in the request, OpenAI's GPT Image models through the edits endpoint, OpenRouter's as `input_references`). The result says what became of them: `references: { used: true, count: 1, paths: ['/…/me.jpg'] }`.
|
|
1511
1520
|
|
|
1512
1521
|
- **Which models take them**: `media.imageInputs`, else the model object's `supportsFileInputs` (the AI SDK's own field; `@ai-sdk/openai` says true for GPT Image, false for DALL·E 3; `@ai-sdk/google` true only for the Gemini ids it knows). Unknown counts as no. A model that takes none is **not refused**: the picture is made from the text alone, nothing is read, and the result says so plainly (`used: false` and a note: the picture was NOT sent, do not say it was made from the user's picture) - so the agent never claims otherwise. The tool's description says the same, and when to pass the person's picture.
|
|
@@ -1554,7 +1563,7 @@ createAgent({
|
|
|
1554
1563
|
})
|
|
1555
1564
|
```
|
|
1556
1565
|
|
|
1557
|
-
The path is absolute (or a `file:` URL); `resourceLimits` bounds the worker's heap. The browser sibling ships a ready implementation on the browser's codecs (`fitReferenceImage`); Node has no canvas, so this package ships none.
|
|
1566
|
+
The path is absolute (or a `file:` URL); `resourceLimits` bounds the worker's heap. The browser sibling ships a ready implementation on the browser's codecs (`fitReferenceImage`); Node has no canvas, so this package ships none. The REPL (`dd-agent`) is a host too: with `sharp` installed it uses the recipe above (a PNG kept when its smaller copy fits, else a JPEG on white; EXIF orientation applied) - `AGENT_MEDIA_FIT_REFERENCE`.
|
|
1558
1567
|
|
|
1559
1568
|
**Audio attachments.** `run({ input, files: [{ data, name?, mediaType? }] })` takes audio as bytes, base64 or a data URL. Each file is transcribed **once**, before planning, and its text is put under the input in a fenced block that says what it is:
|
|
1560
1569
|
|
|
@@ -1951,7 +1960,7 @@ Consent is the host's job ([tool approval](#tool-approval-and-autopilot)) — th
|
|
|
1951
1960
|
| `outputSanitizer` | Optional `(toolName, output) => unknown` hook to redact tool results before they reach the LLM. |
|
|
1952
1961
|
| `inputSanitizer` | Optional `(toolName, input) => unknown` hook to redact LLM-generated tool args before they hit the MCP server **and** before they appear in `step.tool-call` events. **Must be idempotent** — applied at both the event boundary and the dispatch boundary. |
|
|
1953
1962
|
| `outputSanitizer` ordering | The sanitizer runs on the **raw MCP `result.content`** (image/audio base64 still inline), **before** the agent spills binary parts to the sandbox. This favors privacy: a sanitizer that drops a sensitive image keeps the bytes out of the disk entirely. If you want post-spill sanitization (e.g. redact a path), do it in your tool wrapper instead. A result with `structuredContent` calls the sanitizer a second time with that object, so it cannot bypass redaction. |
|
|
1954
|
-
| `media` | Off by default. `{ imageModel, imageInputs, fitReference, fitTimeoutMs, speechModel, transcriptionModel, maxCalls, timeoutMs, dir, voice, speechFormat }`: each model mounts its tool (`generate_image` - with reference pictures for a model that takes them; one over 4096 px / 8 MiB refused, or made smaller by your `fitReference` (no codec here: `sharp`, or `fitReferenceInWorker(module)`; it must not block the event loop) -, `generate_speech`, `transcribe_audio` + audio attachments). Files on disk, never bytes in the context; calls counted in `usage.mediaCalls` (and the other media fields) and capped per run. See [Media](#media-images-speech-and-transcription). |
|
|
1963
|
+
| `media` | Off by default. `{ imageModel, imageInputs, fitReference, fitTimeoutMs, viewGenerated, speechModel, transcriptionModel, maxCalls, timeoutMs, dir, voice, speechFormat }`: each model mounts its tool (`generate_image` - with reference pictures for a model that takes them; one over 4096 px / 8 MiB refused, or made smaller by your `fitReference` (no codec here: `sharp`, or `fitReferenceInWorker(module)`; it must not block the event loop) -, `generate_speech`, `transcribe_audio` + audio attachments). Files on disk, never bytes in the context - except the picture `generate_image` made, shown once to an executor model that reads pictures (`viewGenerated`); calls counted in `usage.mediaCalls` (and the other media fields) and capped per run. See [Media](#media-images-speech-and-transcription). |
|
|
1955
1964
|
| `sandboxRoot` | Per-run sandbox subdirs are created at `<sandboxRoot>/<runId>/` for tools that spill binary content (images, audio, blob resources). Defaults to `<os.tmpdir()>/agent-sandbox`. |
|
|
1956
1965
|
| `keepSandbox` | When `true`, the per-run directory is not removed after the run completes. Default `false`. |
|
|
1957
1966
|
| `systemPrompt` | Appended to the planner, executor, replanner, and synthesizer system prompts so the same domain context (persona, language, tone) reaches every stage. |
|
|
@@ -2171,7 +2180,7 @@ dd-agent --env-file=.env
|
|
|
2171
2180
|
|
|
2172
2181
|
`--env-file=<path>` is loaded via Node's built-in `process.loadEnvFile`, so no `dotenv` dependency is needed. Without the flag the CLI reads the ambient process env. `-h` / `--help` prints the supported flags and the in-REPL slash commands (`/status`, `/usage`, `/tools`, `/history`, `/reset`, `/compact`, `/autopilot`, `/approval <mode>`, `/reconnect`, `/skills`, `/forget <name>`, `/agents`, `/stop [n]`, `/exit` — `/quit` does the same).
|
|
2173
2182
|
|
|
2174
|
-
The newer features are env-driven too: `AGENT_THINKING` (`off | minimal | low | medium | high | xhigh | <budget tokens>`), `AGENT_MAX_INPUT_TOKENS` / `AGENT_MAX_OUTPUT_TOKENS` / `AGENT_MAX_REASONING_TOKENS` / `AGENT_MAX_TOTAL_TOKENS`, `AGENT_MAX_TOOL_CALLS`, `AGENT_PER_CALL_TOKENS` (JSON `{"executor":16000,"synthesizer":0}` — per-stage output caps, `0` = no cap, see [Token limits](#token-limits-and-step-caps)), `AGENT_TOOL_APPROVAL` (`autopilot | ask-writes | ask-all | read-only`), `AGENT_TOOL_RULES` (JSON `{ "<tool or glob*>": "allow" | "ask" | "deny" }`, beats the mode — e.g. `{"github__delete_*":"deny"}`), `AGENT_EGRESS` (`on | off`; with `AGENT_EGRESS_ALLOW`, `AGENT_EGRESS_DENY`, `AGENT_EGRESS_PROTOCOLS`, `AGENT_EGRESS_ALLOW_PRIVATE` — see [Egress](#egress-what-the-model-may-fetch)), `AGENT_SEARCH` (`google | off` - Google Search through Gemini grounding, the one provider the CLI offers: another search API is a function, which an environment cannot carry; with `AGENT_SEARCH_API_KEY` (a Gemini key; `AGENT_API_KEY` is used when `AGENT_PROVIDER_TYPE=google`), `AGENT_SEARCH_MODEL`, `AGENT_SEARCH_BASE_URL`, `AGENT_SEARCH_MAX_RESULTS`, `AGENT_SEARCH_ALLOW_PRIVATE` — see [Search](#search-finding-the-page-to-fetch)), `AGENT_SANDBOX` (`on | off`; with `AGENT_SANDBOX_TIMEOUT_MS`, `AGENT_SANDBOX_MEMORY_MB` — see [Running code](#running-code-the-sandbox)), `AGENT_SUBAGENTS` (`on | off`; with `AGENT_SUBAGENTS_MAX_DEPTH`, `AGENT_SUBAGENTS_MAX_CHILDREN`, `AGENT_SUBAGENTS_MAX_CONCURRENT` — see [Dynamic subagents](#dynamic-subagents-helpers-the-model-starts-itself); `/agents` and `/stop` list and stop helpers, and an approval prompt says when a helper is asking), `AGENT_IMAGE_MODEL` / `AGENT_SPEECH_MODEL` / `AGENT_TRANSCRIPTION_MODEL` (a model id each; each mounts its tool - with `AGENT_MEDIA_PROVIDER_TYPE` / `AGENT_MEDIA_API_KEY` / `AGENT_MEDIA_BASE_URL` / `AGENT_MEDIA_PROVIDER_OPTIONS` when those models live at another provider than the main one, `AGENT_MEDIA_DIR` (default `./agent-media`), `AGENT_MEDIA_MAX_CALLS`, `AGENT_SPEECH_VOICE` — see [Media](#media-images-speech-and-transcription); in the REPL `/audio <file> [question]` attaches an audio file, and `/usage` shows the media calls beside the tokens), `AGENT_SKILLS_DIR`, `AGENT_LEARNING` (`on | off`; `AGENT_LEARNING_DIR` keeps the lessons across sessions — see [Learning](#learning-lessons-that-outlive-the-task)), `AGENT_TOOL_SELECTION_STRATEGY` (`auto | all | plan-narrowed | search`), `AGENT_CONTEXT_WINDOW_TOKENS`, `AGENT_COMPACTION_THRESHOLD` (percent of the window where auto-compaction starts, default 85) and `AGENT_COMPACTION=off`. The REPL prints the model's thoughts dimmed, auto-compacts its history with the same settings, and — when the approval mode asks — prompts `allow? [y]es / [n]o / [a]lways` right in the terminal; `/autopilot` toggles between autopilot and the last asking mode. A question nobody answers within 5 minutes is denied, and the prompt is closed with one line (`[approve] closed: no decision within 300000ms - <tool> did not run`); Ctrl-C closes it the same way (`the run was stopped`). An MCP server's question at the prompt is closed likewise when its own time runs out or the run stops. The next question is shown as usual - none waits behind one nobody can answer any more.
|
|
2183
|
+
The newer features are env-driven too: `AGENT_THINKING` (`off | minimal | low | medium | high | xhigh | <budget tokens>`), `AGENT_MAX_INPUT_TOKENS` / `AGENT_MAX_OUTPUT_TOKENS` / `AGENT_MAX_REASONING_TOKENS` / `AGENT_MAX_TOTAL_TOKENS`, `AGENT_MAX_TOOL_CALLS`, `AGENT_PER_CALL_TOKENS` (JSON `{"executor":16000,"synthesizer":0}` — per-stage output caps, `0` = no cap, see [Token limits](#token-limits-and-step-caps)), `AGENT_TOOL_APPROVAL` (`autopilot | ask-writes | ask-all | read-only`), `AGENT_TOOL_RULES` (JSON `{ "<tool or glob*>": "allow" | "ask" | "deny" }`, beats the mode — e.g. `{"github__delete_*":"deny"}`), `AGENT_EGRESS` (`on | off`; with `AGENT_EGRESS_ALLOW`, `AGENT_EGRESS_DENY`, `AGENT_EGRESS_PROTOCOLS`, `AGENT_EGRESS_ALLOW_PRIVATE` — see [Egress](#egress-what-the-model-may-fetch)), `AGENT_SEARCH` (`google | off` - Google Search through Gemini grounding, the one provider the CLI offers: another search API is a function, which an environment cannot carry; with `AGENT_SEARCH_API_KEY` (a Gemini key; `AGENT_API_KEY` is used when `AGENT_PROVIDER_TYPE=google`), `AGENT_SEARCH_MODEL`, `AGENT_SEARCH_BASE_URL`, `AGENT_SEARCH_MAX_RESULTS`, `AGENT_SEARCH_ALLOW_PRIVATE` — see [Search](#search-finding-the-page-to-fetch)), `AGENT_SANDBOX` (`on | off`; with `AGENT_SANDBOX_TIMEOUT_MS`, `AGENT_SANDBOX_MEMORY_MB` — see [Running code](#running-code-the-sandbox)), `AGENT_SUBAGENTS` (`on | off`; with `AGENT_SUBAGENTS_MAX_DEPTH`, `AGENT_SUBAGENTS_MAX_CHILDREN`, `AGENT_SUBAGENTS_MAX_CONCURRENT` — see [Dynamic subagents](#dynamic-subagents-helpers-the-model-starts-itself); `/agents` and `/stop` list and stop helpers, and an approval prompt says when a helper is asking), `AGENT_IMAGE_MODEL` / `AGENT_SPEECH_MODEL` / `AGENT_TRANSCRIPTION_MODEL` (a model id each; each mounts its tool - with `AGENT_MEDIA_PROVIDER_TYPE` / `AGENT_MEDIA_API_KEY` / `AGENT_MEDIA_BASE_URL` / `AGENT_MEDIA_PROVIDER_OPTIONS` when those models live at another provider than the main one, `AGENT_MEDIA_DIR` (default `./agent-media`), `AGENT_MEDIA_MAX_CALLS`, `AGENT_SPEECH_VOICE`, `AGENT_MEDIA_FIT_REFERENCE` (`auto | on | off`: a reference picture over 4096 px / 8 MiB is sent as a smaller copy made with [`sharp`](https://sharp.pixelplumbing.com) when it is installed - `npm install sharp`, an optional peer the REPL loads only with an image model; `on` requires it, `off` refuses such a picture as before; the start line says which) — see [Media](#media-images-speech-and-transcription); in the REPL `/audio <file> [question]` attaches an audio file, and `/usage` shows the media calls beside the tokens), `AGENT_SKILLS_DIR`, `AGENT_LEARNING` (`on | off`; `AGENT_LEARNING_DIR` keeps the lessons across sessions — see [Learning](#learning-lessons-that-outlive-the-task)), `AGENT_TOOL_SELECTION_STRATEGY` (`auto | all | plan-narrowed | search`), `AGENT_CONTEXT_WINDOW_TOKENS`, `AGENT_COMPACTION_THRESHOLD` (percent of the window where auto-compaction starts, default 85) and `AGENT_COMPACTION=off`. The REPL prints the model's thoughts dimmed, auto-compacts its history with the same settings, and — when the approval mode asks — prompts `allow? [y]es / [n]o / [a]lways` right in the terminal; `/autopilot` toggles between autopilot and the last asking mode. A question nobody answers within 5 minutes is denied, and the prompt is closed with one line (`[approve] closed: no decision within 300000ms - <tool> did not run`); Ctrl-C closes it the same way (`the run was stopped`). An MCP server's question at the prompt is closed likewise when its own time runs out or the run stops. The next question is shown as usual - none waits behind one nobody can answer any more.
|
|
2175
2184
|
|
|
2176
2185
|
**`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.
|
|
2177
2186
|
|