@markusylisiurunen/tau 0.3.102 → 0.3.103

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.
Files changed (50) hide show
  1. package/README.md +18 -23
  2. package/dist/core/history/migrations.js +40 -0
  3. package/dist/core/history/migrations.js.map +1 -1
  4. package/dist/core/history/setup.js +24 -7
  5. package/dist/core/history/setup.js.map +1 -1
  6. package/dist/core/mcp/cli.js +1 -1
  7. package/dist/core/mcp/cli.js.map +1 -1
  8. package/dist/core/static/tau_docs/client-tools.md +46 -385
  9. package/dist/core/static/tau_docs/code-mode.md +104 -43
  10. package/dist/core/static/tau_docs/configuration.md +77 -171
  11. package/dist/core/static/tau_docs/getting-started.md +25 -96
  12. package/dist/core/static/tau_docs/history.md +30 -228
  13. package/dist/core/static/tau_docs/how-tau-works.md +53 -0
  14. package/dist/core/static/tau_docs/image-generation.md +15 -107
  15. package/dist/core/static/tau_docs/index.md +46 -46
  16. package/dist/core/static/tau_docs/instructions-and-skills.md +81 -0
  17. package/dist/core/static/tau_docs/manifest.json +15 -21
  18. package/dist/core/static/tau_docs/mcp.md +77 -0
  19. package/dist/core/static/tau_docs/models-and-credentials.md +67 -0
  20. package/dist/core/static/tau_docs/openrouter.md +31 -129
  21. package/dist/core/static/tau_docs/pdf-unpacking.md +8 -21
  22. package/dist/core/static/tau_docs/personas.md +48 -144
  23. package/dist/core/static/tau_docs/remote-sessions.md +33 -170
  24. package/dist/core/static/tau_docs/sdk.md +150 -0
  25. package/dist/core/static/tau_docs/security.md +6 -193
  26. package/dist/core/static/tau_docs/session-protocol.md +84 -246
  27. package/dist/core/static/tau_docs/sessions.md +41 -205
  28. package/dist/core/static/tau_docs/speech-generation.md +16 -129
  29. package/dist/core/static/tau_docs/subagents.md +57 -229
  30. package/dist/core/static/tau_docs/telegram.md +152 -192
  31. package/dist/core/static/tau_docs/tools.md +44 -167
  32. package/dist/core/static/tau_docs/troubleshooting.md +23 -217
  33. package/dist/core/static/tau_docs/tui.md +42 -282
  34. package/dist/core/version.js +1 -1
  35. package/dist/history/worker/index.js +16 -22
  36. package/dist/history/worker/index.js.map +1 -1
  37. package/dist/history/worker/migrations/0005_external_content.sql +58 -0
  38. package/dist/history/worker/migrations/0006_external_content_cutover.sql +44 -0
  39. package/package.json +2 -2
  40. package/dist/core/static/tau_docs/config-reference.md +0 -367
  41. package/dist/core/static/tau_docs/credentials.md +0 -165
  42. package/dist/core/static/tau_docs/models.md +0 -57
  43. package/dist/core/static/tau_docs/node-sdk.md +0 -430
  44. package/dist/core/static/tau_docs/ownership-and-scope.md +0 -107
  45. package/dist/core/static/tau_docs/prompts-and-project-context.md +0 -147
  46. package/dist/core/static/tau_docs/sdk-diff-review.md +0 -92
  47. package/dist/core/static/tau_docs/session-protocol-methods.md +0 -655
  48. package/dist/core/static/tau_docs/skills.md +0 -135
  49. package/dist/core/static/tau_docs/telegram-commands.md +0 -55
  50. package/dist/core/static/tau_docs/telegram-projects.md +0 -197
@@ -1,31 +1,14 @@
1
1
  # Client tools
2
2
 
3
- Client tools are tools that an attached client adds to a session. A TUI can open a local review interface, a Telegram runner can run a workspace-specific command, and an SDK client can provide an in-process handler. The model sees an ordinary tool, but the tool runs in the client that offered it.
3
+ A client tool is a tool that an attached client offers to the session. The model sees an ordinary tool, but it runs in the client. In a remote session, that means your laptop, while the agent's files are on another machine.
4
4
 
5
- In a remote session, the client, the host, and the execution environment may be three different machines. A command client tool starts on the client machine. To read or change the agent's workspace, it must use the execution-environment API that Tau provides. It cannot assume the workspace is on its own filesystem.
5
+ Built-in client tools are the TUI's `diff_review` and `prefill_input`, and [Telegram's file delivery tools](telegram.md). You can add your own as commands, as described below, or as [SDK handlers](sdk.md).
6
6
 
7
- ## Which client advertises which tools
7
+ Only the main agent can call client tools. They exist while their client observes the session, and running calls are cancelled when it detaches. Names must be unique across host tools and all observing clients, so start extra clients with `--no-client-tools`.
8
8
 
9
- Tau's TUI advertises two built-in client tools:
9
+ ## Configure a command tool
10
10
 
11
- - `diff_review` runs diff review on the TUI machine, reading repository data from the session's execution environment.
12
- - `prefill_input` puts a draft in an empty TUI editor for the user to edit and submit. It never submits the draft and does not replace existing editor text.
13
-
14
- The TUI also offers the configured command client tools selected for its own working directory, both with local `tau` and with `tau attach`. When attached to a remote host, the command and its environment are on the attaching machine, not on the host.
15
-
16
- A Telegram runner offers the built-in `send_photo_to_telegram`, `send_video_to_telegram`, `send_audio_to_telegram`, and `send_document_to_telegram` tools, plus the command client tools selected by each prepared workspace's Tau configuration. The built-in [file delivery tools](tools.md#sending-files-to-telegram) send files to the session's chat and are not affected by `enabledClientTools`. The runner does not offer the TUI's tools. The session's workspace, whether repository, persistent directory, or composite, decides which configuration selects its tools. See [Telegram projects and workspaces](telegram-projects.md) for workspace types.
17
-
18
- Node SDK clients can pass `TauSdkClientTool` handlers when they initialize. Their schemas may set `executionTimeoutMs` to `null` for no execution deadline, or omit it for the 60-second default. Configured command tools require a positive timeout and do not accept `null`. The same rules for routing, cancellation, and execution-environment access apply.
19
-
20
- Only a client that is observing a session can add tools to it. The tools disappear when that client detaches or disconnects. When several clients observe one session, only one may offer a given tool name, and Tau rejects the later client if names collide. Client tool names also must not match host tools or built-in tools.
21
-
22
- Only the session's main agent can call client tools. [Subagents](subagents.md#tools) never get them.
23
-
24
- ## Configure command client tools globally
25
-
26
- Client tool commands can be defined only in the global `~/.config/tau/config.json`, and only when the client's working directory is inside home. Project configuration cannot define commands, so a cloned repository can never add a process that runs on your machine.
27
-
28
- A definition requires `name`, `defaultEnabled`, `description`, `parameters`, and `command`:
11
+ Define commands in global configuration on the client machine, so a repository can never add one:
29
12
 
30
13
  ```json
31
14
  {
@@ -36,399 +19,77 @@ A definition requires `name`, `defaultEnabled`, `description`, `parameters`, and
36
19
  "description": "Show a desktop notification after completing requested work.",
37
20
  "parameters": {
38
21
  "type": "object",
39
- "properties": {
40
- "title": { "type": "string" },
41
- "message": { "type": "string" }
42
- },
43
- "required": ["title", "message"],
22
+ "properties": { "message": { "type": "string" } },
23
+ "required": ["message"],
44
24
  "additionalProperties": false
45
25
  },
46
- "command": "./bin/tau-notify",
47
- "args": ["--protocol"],
48
- "executionTimeoutMs": 10000
26
+ "command": "./bin/tau-notify"
49
27
  }
50
28
  ]
51
29
  }
52
30
  ```
53
31
 
54
- The exact fields are:
55
-
56
- | Field | Requirement |
57
- | --- | --- |
58
- | `name` | Required non-empty string. Names must be unique within `clientTools` and must not collide with tools already bound to the session. |
59
- | `defaultEnabled` | Required boolean. Controls selection when no project level supplies `enabledClientTools`. |
60
- | `description` | Required non-empty model-facing description. State when the tool should be used and any important side effects. |
61
- | `parameters` | Required JSON Schema whose root has `"type": "object"`. Tau passes the rest of the schema through unchanged and validates every call against it. |
62
- | `command` | Required non-empty executable name or path. |
63
- | `args` | Optional array of literal string arguments. |
64
- | `executionTimeoutMs` | Optional positive integer. The default is 60,000 ms. |
65
-
66
- Unknown fields on a definition are ignored. An invalid entry is skipped with a configuration warning, and the other entries stay available. Names are compared exactly, including case, when checking for duplicates.
67
-
68
- ### Command path resolution
69
-
70
- A `command` that contains `/` resolves from home, because the definition is global. For example, `./bin/tau-notify` resolves to `~/bin/tau-notify`. A bare command such as `tau-notify` resolves through the client process's `PATH` when the tool runs.
71
-
72
- Tau starts the executable directly with `args`. It does not use a shell, expand globs, substitute variables, or process quotes. If you really need a shell, configure the shell as the command with explicit arguments, but a dedicated executable is easier to validate and to cancel safely.
73
-
74
- The process inherits the client process's environment unchanged. The agent's Bash tool removes variables that look like credentials, but command client tools keep them. Treat every configured executable as trusted local code and give it only the credentials it needs.
75
-
76
- ## Select tools per project
77
-
78
- Project `.tau/config.json` files may set `enabledClientTools` to an exact allowlist of globally defined names:
79
-
80
- ```json
81
- {
82
- "enabledClientTools": ["notify_desktop", "open_ticket"]
83
- }
84
- ```
85
-
86
- Tau uses the nearest project level that sets this field. Lists from different levels are not combined.
87
-
88
- There are three cases:
89
-
90
- - If no project level defines `enabledClientTools`, Tau selects global definitions with `defaultEnabled: true`.
91
- - If the nearest definition is a non-empty array, Tau selects exactly the known names in that array, regardless of `defaultEnabled`.
92
- - If the nearest definition is `[]`, Tau disables every configured command client tool for that workspace.
93
-
94
- Unknown names are ignored without an error. Repeated names are removed. Names match exactly, including case.
95
-
96
- `enabledClientTools` only selects global definitions. It cannot change their command, arguments, schema, description, or timeout. The field is allowed only in project configuration, and `clientTools` only in global configuration.
97
-
98
- For Telegram, `enabledClientTools: []` is the normal way to disable configured tools for a prepared workspace. For the TUI, the startup flag described below can disable all client tools at once.
99
-
100
- ## Disable TUI client tools
101
-
102
- Start a local or attached TUI with:
103
-
104
- ```bash
105
- tau --no-client-tools
32
+ ```ts
33
+ type CommandClientTool = {
34
+ name: string;
35
+ defaultEnabled: boolean; // used when no project sets enabledClientTools
36
+ description: string;
37
+ parameters: JsonSchema; // root type must be "object"
38
+ command: string; // on PATH, or relative to home if it contains "/"
39
+ args?: string[];
40
+ executionTimeoutMs?: number; // default 60000
41
+ };
106
42
  ```
107
43
 
108
- For attach mode, place the flag with the attach options:
44
+ The command runs directly without a shell, with the client's full environment. A project can select tools from this list with `enabledClientTools`, where the nearest list wins and `[]` selects none:
109
45
 
110
- ```bash
111
- tau attach --no-client-tools ws://host.example:8787
46
+ ```json
47
+ { "enabledClientTools": ["notify_desktop"] }
112
48
  ```
113
49
 
114
- This disables the configured command tools and the TUI's built-in `diff_review` and `prefill_input`. Host tools and the built-in `tau_docs` tool are not affected.
115
-
116
- A client selects and offers its tools when it starts and connects. `/reload` does not change the tools a TUI or Telegram client offers. Restart or reconnect the client after changing `clientTools`, `enabledClientTools`, or `--no-client-tools`.
50
+ Restart the client after a change, because `/reload` does not affect client tools.
117
51
 
118
- Diff review uses Tau’s built-in browser tool on the TUI machine, separately from command client-tool definitions. See [TUI](tui.md).
52
+ ## Write a command tool
119
53
 
120
- ## Implement a command tool with Tau's helper
121
-
122
- Command client tools use Tau's version 5 bidirectional NDJSON protocol over stdin and stdout. Use the exported helper instead of implementing framing manually:
54
+ Use the helper, which handles the protocol and cancellation:
123
55
 
124
56
  ```ts
125
- import {
126
- runTauClientToolCommand,
127
- truncateTauClientToolText,
128
- } from "@markusylisiurunen/tau/code-mode";
57
+ import { runTauClientToolCommand } from "@markusylisiurunen/tau/code-mode";
129
58
 
130
59
  await runTauClientToolCommand({
131
- name: "notify_desktop",
132
- describe(args) {
133
- const input = args as { title: string; message: string };
134
- return {
135
- subject: truncateTauClientToolText(input.title),
136
- };
137
- },
60
+ name: "workspace_status",
138
61
  async execute(args, context) {
139
- const input = args as { title: string; message: string };
140
- context.signal.throwIfAborted();
141
-
142
- await showNotification(input.title, input.message, context.signal);
143
- return {
144
- content: "Notification displayed.",
145
- presentation: {
146
- subject: truncateTauClientToolText(input.title),
62
+ const result = await context.executionEnvironment.exec(
63
+ "git status --short",
64
+ {
65
+ timeoutMs: 10000,
66
+ signal: context.signal,
147
67
  },
148
- };
68
+ );
69
+ return { content: result.output || "Working tree is clean." };
149
70
  },
150
71
  });
151
72
  ```
152
73
 
153
- `describe` is optional. If present, it runs before the call is accepted and may return a partial presentation for the running tool card, with any of `subject`, `subjectWrap`, `details`, or `metadata`. The execution result may include the same partial shape for the finished card. Tau fills in every omitted field, controls the card's lifecycle and the operation label (derived from the tool name), and shows a complete default card if execution ends without a result.
154
-
155
- Tau keeps every presentation field you set, up to the protocol limits. It does not truncate or normalize client text for display. `truncateTauClientToolText` truncates text for you, with optional `maxLines`, `maxLineChars`, and a `head` or `middle` strategy. Its defaults match the length Tau uses for its own subjects, and you can choose larger or smaller limits.
156
-
157
- For a subject, use the returned string directly. For a block of detail text, split the returned string on `\n` and map each line to one `details` entry:
158
-
159
- ```ts
160
- const details = truncateTauClientToolText(output, {
161
- maxLines: 7,
162
- maxLineChars: 512,
163
- strategy: "middle",
164
- })
165
- .split("\n")
166
- .map((text) => ({ text }));
167
- ```
168
-
169
- Each detail or metadata entry is one line, so use `maxLines: 1` when putting the helper's result directly into one entry. The helper only shapes text; the protocol's byte and count limits still apply. An empty `details` or `metadata` array hides that phase's default content.
170
-
171
- `runTauClientToolCommand` reads the `prepare` frame, writes `ready` with any running presentation, waits until the host accepts the call, then runs your handler and writes the final result. It also handles execution-environment requests and their cancellation. On `SIGINT`, `SIGTERM`, or closed stdin, it aborts the handler.
172
-
173
- Reserve stdout for the helper's protocol. Write diagnostics to stderr. Return a string or `{ content, presentation? }` for success. Return `{ ok: false, error, presentation? }` for a structured tool failure. `content` may be a string or ordered text/image blocks; the helper wraps strings in text blocks.
174
-
175
- ### Version 5 frame reference
176
-
177
- Write each frame as one JSON object followed by a newline. Unknown fields are invalid.
178
-
179
- Tau starts the exchange by writing:
180
-
181
- - `{ version: 5, type: "prepare", sessionId, agentId, callId, toolName, arguments }` exactly once. The ID fields are non-empty strings, and `arguments` is the model's input after validation.
182
- - `{ version: 5, type: "execute" }` after Tau accepts the command's `ready` frame. The command may not start work before this frame.
183
-
184
- The command writes:
185
-
186
- - `{ version: 5, type: "ready", presentation?: PresentationOverride }` exactly once after preparation.
187
- - `{ version: 5, type: "result", ok: true, content, presentation?: PresentationOverride }` or `{ version: 5, type: "result", ok: false, error, presentation?: PresentationOverride }` exactly once, after `execute`. `error` is a string. `content` is an ordered array of at most 1,024 text (`{ type: "text", text }`) or image (`{ type: "image", data, mimeType }`) blocks. At most 16 images are allowed: padded base64, at most 3.5 MiB decoded each, JPEG/PNG/WebP MIME types.
74
+ The process runs on the client machine. `context.executionEnvironment.exec()` runs a command in the session's execution environment, so use it for anything that touches the agent's files. Pass `context.signal` to work that can be cancelled.
188
75
 
189
- After `execute`, the command may write `{ version: 5, type: "exec", requestId, command, options }`. The non-empty `command` string runs in the session execution environment. `options` is required and may contain `args: string[]`, `env: Record<string, string>`, base64-encoded string `stdinBase64`, string `cwd`, positive integer `timeoutMs`, and positive integer `maxCaptureBytes`.
76
+ Return a string or `{ content, presentation? }`, or `{ ok: false, error }` for a handled failure. `content` can be an array of text and image blocks. An optional `describe(args)` function and the `presentation` field customize the tool card with `subject`, `details`, and `metadata`.
190
77
 
191
- Tau answers with the same `requestId` and either:
78
+ Keep stdout free for the protocol and write diagnostics to stderr.
192
79
 
193
- - `{ version: 5, type: "exec.result", requestId, ok: true, result: ExecResult }`
194
- - `{ version: 5, type: "exec.result", requestId, ok: false, error: string }`
80
+ ## Without the helper
195
81
 
196
- `ExecResult` contains string `output`, `stdout`, and `stderr`; nullable `exitCode` and `closeSignal`; and boolean `truncated`, `timedOut`, and `aborted`. A command may cancel one unresolved request with `{ version: 5, type: "exec.cancel", requestId }`. Request IDs must be non-empty strings and cannot be reused within a call.
82
+ Any executable can implement the protocol. It exchanges one JSON object per line on stdin and stdout:
197
83
 
198
- ### Implement the protocol directly in JavaScript
199
-
200
- A JavaScript command can implement the version 5 handshake using only Node.js built-ins, without importing Tau or the code-mode package:
201
-
202
- ```js
203
- #!/usr/bin/env node
204
-
205
- import { arch, platform, release } from "node:os";
206
- import { createInterface } from "node:readline";
207
-
208
- const lines = createInterface({
209
- input: process.stdin,
210
- crlfDelay: Number.POSITIVE_INFINITY,
211
- });
212
- const input = lines[Symbol.asyncIterator]();
213
-
214
- async function readFrame() {
215
- const next = await input.next();
216
- if (next.done) throw new Error("Tau closed the command protocol");
217
- return JSON.parse(next.value);
218
- }
219
-
220
- function writeFrame(frame) {
221
- process.stdout.write(`${JSON.stringify(frame)}\n`);
222
- }
223
-
224
- const prepare = await readFrame();
225
- if (
226
- prepare.version !== 5 ||
227
- prepare.type !== "prepare" ||
228
- prepare.toolName !== "system_info"
229
- ) {
230
- throw new Error("Invalid system_info preparation");
231
- }
232
-
233
- writeFrame({
234
- version: 5,
235
- type: "ready",
236
- presentation: {
237
- subject: "local system",
238
- },
239
- });
240
-
241
- const execute = await readFrame();
242
- if (execute.version !== 5 || execute.type !== "execute") {
243
- throw new Error("Invalid system_info authorization");
244
- }
245
-
246
- writeFrame({
247
- version: 5,
248
- type: "exec",
249
- requestId: "git-status",
250
- command: "git status --short",
251
- options: {
252
- maxCaptureBytes: 256 * 1024,
253
- },
254
- });
255
-
256
- const response = await readFrame();
257
- if (
258
- response.version !== 5 ||
259
- response.type !== "exec.result" ||
260
- response.requestId !== "git-status"
261
- ) {
262
- throw new Error("Invalid execution-environment response");
263
- }
264
- if (!response.ok) throw new Error(response.error);
265
-
266
- const localSystem = `${platform()} ${release()} ${arch()}`;
267
- const workspaceStatus =
268
- response.result.output.trim() || "Working tree is clean.";
269
- writeFrame({
270
- version: 5,
271
- type: "result",
272
- ok: true,
273
- content: [{ type: "text", text: `${localSystem}\n\n${workspaceStatus}` }],
274
- presentation: {
275
- subject: "local system",
276
- },
277
- });
278
-
279
- lines.close();
280
- ```
281
-
282
- The `exec` frame asks Tau to run `git status --short` in the session execution environment, which may be a different machine from the JavaScript process. Tau returns the matching `exec.result` on stdin. Request IDs are single-use, and the command must check both the ID and `ok` before consuming the result.
283
-
284
- Make the file executable with `chmod +x`. Diagnostics and uncaught errors go to stderr; stdout remains reserved for protocol frames.
285
-
286
- ### Implement a simple command tool in Bash
287
-
288
- A small command that only needs the client machine can also implement the handshake in Bash. This example depends on `jq` for safe JSON parsing and encoding:
289
-
290
- ```bash
291
- #!/usr/bin/env bash
292
- set -euo pipefail
293
-
294
- IFS= read -r prepare
295
- jq -e '
296
- .version == 5 and
297
- .type == "prepare" and
298
- .toolName == "system_info"
299
- ' >/dev/null <<<"$prepare"
300
-
301
- jq -cn '{
302
- version: 5,
303
- type: "ready",
304
- presentation: {
305
- subject: "local system"
306
- }
307
- }'
308
-
309
- IFS= read -r execute
310
- jq -e '.version == 5 and .type == "execute"' >/dev/null <<<"$execute"
311
-
312
- content=$(uname -a)
313
- jq -cn --arg content "$content" '{
314
- version: 5,
315
- type: "result",
316
- ok: true,
317
- content: [{type: "text", text: $content}]
318
- }'
319
- ```
320
-
321
- Configure either executable as an argument-free command tool:
322
-
323
- ```json
324
- {
325
- "name": "system_info",
326
- "defaultEnabled": true,
327
- "description": "Report operating-system information from the client machine.",
328
- "parameters": {
329
- "type": "object",
330
- "properties": {},
331
- "additionalProperties": false
332
- },
333
- "command": "./bin/tau-system-info"
334
- }
335
- ```
336
-
337
- `ready.presentation` and `result.presentation` are optional partial objects with `subject`, `subjectWrap`, `details`, and `metadata`. The `ready` value applies while the call runs, and the `result` value applies to the finished card. Omit either object, or any field in it, to use Tau's default. An empty `details` or `metadata` array hides that default. The script must write `ready` before it reads the `execute` frame. Direct implementations can send the same `exec` frames as the JavaScript example, but the TypeScript helper is the better choice when the tool makes several execution-environment requests, needs to forward cancellation, or handles the protocol in more complex ways.
338
-
339
- The handler receives:
340
-
341
- ```ts
342
- {
343
- sessionId: string;
344
- agentId: string;
345
- callId: string;
346
- signal: AbortSignal;
347
- executionEnvironment: {
348
- exec(command: string, options?): Promise<ExecResult>;
349
- };
350
- }
84
+ ```text
85
+ tau → { version: 5, type: "prepare", sessionId, agentId, callId, toolName, arguments }
86
+ cmd → { version: 5, type: "ready" }
87
+ tau → { version: 5, type: "execute" }
88
+ cmd → { version: 5, type: "result", ok: true, content: [{ type: "text", text: "done" }] }
351
89
  ```
352
90
 
353
- `sessionId` identifies the session, `agentId` the agent that made the call (for scratch space and attribution), and `callId` this call. Never use one ID in place of another, and never reuse a context across calls.
354
-
355
- `signal` aborts when the turn is interrupted, the host cancels or times out the tool, the client closes, the connection fails, or stdin closes. Pass it to all local work that can be cancelled and to execution-environment calls.
356
-
357
- ### Run commands in the execution environment
358
-
359
- `context.executionEnvironment.exec()` runs a command in the session's execution environment, not on the client machine. Use it for the agent's files, repository commands, and workspace state:
360
-
361
- ```ts
362
- const result = await context.executionEnvironment.exec("git status --short", {
363
- cwd: "/workspace/atlas",
364
- timeoutMs: 10000,
365
- maxCaptureBytes: 256 * 1024,
366
- signal: context.signal,
367
- });
368
-
369
- return { content: result.output || "Working tree is clean." };
370
- ```
371
-
372
- The optional settings are `args`, `env`, binary `stdin`, `cwd`, `timeoutMs`, `maxCaptureBytes`, and `signal`. The result has combined and separate output, exit status, and whether output was truncated, timed out, or aborted, plus the closing signal. Commands run in the execution environment's login Bash, with its paths, environment, and permissions. `HOME` comes from that environment and cannot be overridden in the request.
373
-
374
- Up to eight requests may be unresolved at once. Each request ID can be used only once. Cancelling one request does not affect the others, but cancelling the whole tool call aborts all of them.
375
-
376
- ## Implement code-mode client tools
377
-
378
- Tau exports two helpers for client tools that let the model run JavaScript against an API you define:
379
-
380
- - `createTauCodeModeClientTool` creates an in-process `TauSdkClientTool` for an SDK client.
381
- - `runTauCodeModeCommand` runs a code-mode definition as a command client-tool executable.
382
-
383
- Command tools need a parameters schema with a required `code` string, an optional `maxOutputTokens` integer (1–65,536), and no other properties. SDK clients pass the tool returned by the helper in `clientTools`.
384
-
385
- Both helpers provide the call IDs, cancellation, the execution-environment API, `docs`, the bridge to your API, and output and truncation functions. The card subject is the submitted code, truncated and wrapped by character. You write the tool description; the shared description builder is optional.
386
-
387
- `await printImage(block)` emits ordered text/image blocks in `content`; see [tools](tools.md) for limits. `maxOutputTokens` defaults to 8,192 estimated tokens. Saving output requires a `persistOutput` callback.
388
-
389
- The definition's optional `timeoutMs` sets a deadline for each program, including time spent waiting for API calls. The default is 60,000 ms. Both helpers tell the model this deadline: the SDK helper appends it to the tool description, and the command helper appends it to `docs`. The SDK helper also uses `timeoutMs` as the tool's `executionTimeoutMs`. For a command tool, the configured `executionTimeoutMs` still limits the whole call, including preparation, so make it longer than the program deadline.
390
-
391
- If the tool can start processes or reach the network, say so in its description.
392
-
393
- ## Limits and failure behavior
394
-
395
- The command protocol has fixed limits:
396
-
397
- - The command-to-client stdout NDJSON stream is limited to 512 frames and 192 MiB in total.
398
- - Each frame on that stdout stream is limited to 80 MiB.
399
- - Final result text is limited to 1 MiB; images use the bounds above.
400
- - Captured stderr is limited to 1 MiB. Exceeding it terminates the command and fails the tool.
401
- - Execution-environment stdin is limited to 16 MiB decoded, and capture can be requested up to 24 MiB per execution.
402
- - At most eight execution requests may be unresolved concurrently.
403
- - Each presentation override is limited to 1 MiB in total: the subject to 256 KiB, each metadata value to 16 KiB, each detail value to 256 KiB, and `details` and `metadata` to 1,024 entries each. These are safety limits, not recommended display sizes. Tau keeps values within them unchanged. Use the exported helper for a short preview.
404
-
405
- `executionTimeoutMs` covers both preparation and execution, and defaults to 60 seconds. The host also expects the client to prepare and accept each call promptly. A command writes `ready` and any running presentation first, then waits for Tau's `execute`.
406
-
407
- Tau starts each command in its own process group. Cancellation sends a termination signal to the group and follows with `SIGKILL` after a short grace period, even if the main process has already exited. When stdin closes, the helper aborts pending execution-environment requests and accepts no more work.
408
-
409
- A successful exchange writes one `ready` frame, waits for `execute`, writes one `result` frame with `ok: true` or `ok: false`, and exits with status zero. `ok: false` reports a tool failure the command handled. Process and framing failures still use stderr and a nonzero exit. The call fails on: a missing or repeated `ready`, output before `execute`, a missing result, malformed frames, output after the result, a reused request ID, timeout, cancellation, too much output, or any other limit violation.
410
-
411
- ## Disconnects, reconnects, and durability
412
-
413
- Client tool calls are not saved. Tau never replays them and never moves them to another client when the owning client goes away.
414
-
415
- When the owning client detaches, Tau removes its tools from later turns and cancels its running calls. When the client closes or its connection fails for good, local handlers and the execution-environment commands they started are aborted. Closing waits for running handlers to finish, but no results are sent once the connection is gone.
416
-
417
- After reconnecting, the client offers its current tools again, and they become available once it observes the session. If another client already offers one of those names, the attachment fails. A reconnect never resumes a command process from the earlier connection.
418
-
419
- ## Security and troubleshooting
420
-
421
- Command client tools are trusted executables with the client process's full environment and operating-system permissions. Keep definitions in your global configuration, use narrow JSON Schemas, avoid shell interpolation, limit local work, honor cancellation, and return only data the model needs. A project's `enabledClientTools` can only select global definitions; it can never supply code to run.
422
-
423
- The execution-environment API is just as powerful, on the session machine. Validate every argument from the model before building a command, prefer fixed command names and argument arrays, never concatenate untrusted text into shell code, and use the context signal and capture limits.
424
-
425
- When a tool is missing, check:
91
+ After `execute`, a command can send `exec` frames to run commands in the execution environment. For the full protocol, read the `@markusylisiurunen/tau/code-mode` types and source.
426
92
 
427
- 1. The owning client is currently observing the session.
428
- 2. The global definition is valid, and the client's `cwd` is inside home.
429
- 3. The nearest `enabledClientTools` selection includes the exact name, or `defaultEnabled` applies.
430
- 4. `--no-client-tools` is not active for the TUI.
431
- 5. No other observer or host tool owns the same name.
432
- 6. The client was restarted or reconnected after configuration changes.
93
+ ## Code-mode tools
433
94
 
434
- For failures, first tell apart errors from the local process and errors from `executionEnvironment.exec()` on the session machine. Check executable permissions, the client's `PATH`, stderr output, and timeout and framing limits. Then check the execution environment's `cwd`, login startup files, and whether the command exists there. See [tools](tools.md), [security](security.md), and [troubleshooting](troubleshooting.md).
95
+ `runTauCodeModeCommand` and the SDK's `createTauCodeModeClientTool` let the model run JavaScript against an API you define, in the [code mode](code-mode.md) sandbox. Programs have a 60-second deadline unless you set `timeoutMs`. For a command tool, make `executionTimeoutMs` longer than that deadline. See [the SDK page](sdk.md) for an example.