@dudko.dev/agent 0.0.58 → 0.0.59
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 +11 -2
- package/dist/cli.js +128 -128
- 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 +1 -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.
|
|
@@ -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. |
|