@markusylisiurunen/tau 0.3.101 → 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.
- package/README.md +18 -23
- package/dist/core/config/ownership.js +3 -1
- package/dist/core/config/ownership.js.map +1 -1
- package/dist/core/config/schema.js +3 -1
- package/dist/core/config/schema.js.map +1 -1
- package/dist/core/history/migrations.js +46 -1
- package/dist/core/history/migrations.js.map +1 -1
- package/dist/core/history/setup.js +24 -7
- package/dist/core/history/setup.js.map +1 -1
- package/dist/core/mcp/cli.js +1 -1
- package/dist/core/mcp/cli.js.map +1 -1
- package/dist/core/static/tau_docs/client-tools.md +46 -385
- package/dist/core/static/tau_docs/code-mode.md +104 -43
- package/dist/core/static/tau_docs/configuration.md +77 -171
- package/dist/core/static/tau_docs/getting-started.md +25 -96
- package/dist/core/static/tau_docs/history.md +30 -228
- package/dist/core/static/tau_docs/how-tau-works.md +53 -0
- package/dist/core/static/tau_docs/image-generation.md +15 -107
- package/dist/core/static/tau_docs/index.md +46 -45
- package/dist/core/static/tau_docs/instructions-and-skills.md +81 -0
- package/dist/core/static/tau_docs/manifest.json +15 -20
- package/dist/core/static/tau_docs/mcp.md +77 -0
- package/dist/core/static/tau_docs/models-and-credentials.md +67 -0
- package/dist/core/static/tau_docs/openrouter.md +31 -129
- package/dist/core/static/tau_docs/pdf-unpacking.md +8 -21
- package/dist/core/static/tau_docs/personas.md +48 -144
- package/dist/core/static/tau_docs/remote-sessions.md +33 -170
- package/dist/core/static/tau_docs/sdk.md +150 -0
- package/dist/core/static/tau_docs/security.md +6 -193
- package/dist/core/static/tau_docs/session-protocol.md +84 -246
- package/dist/core/static/tau_docs/sessions.md +41 -205
- package/dist/core/static/tau_docs/speech-generation.md +16 -129
- package/dist/core/static/tau_docs/subagents.md +57 -229
- package/dist/core/static/tau_docs/telegram.md +152 -220
- package/dist/core/static/tau_docs/tools.md +44 -167
- package/dist/core/static/tau_docs/troubleshooting.md +23 -217
- package/dist/core/static/tau_docs/tui.md +42 -276
- package/dist/core/subagents/claude_code_runner.mjs +65 -65
- package/dist/core/telegram/adapter.js +178 -61
- package/dist/core/telegram/adapter.js.map +1 -1
- package/dist/core/telegram/cli.js +1 -3
- package/dist/core/telegram/cli.js.map +1 -1
- package/dist/core/telegram/config.js +3 -1
- package/dist/core/telegram/config.js.map +1 -1
- package/dist/core/telegram/runtime.js +1 -1
- package/dist/core/telegram/runtime.js.map +1 -1
- package/dist/core/utils/scribe_transcription.js +283 -0
- package/dist/core/utils/scribe_transcription.js.map +1 -0
- package/dist/core/utils/speech_cleanup.js +198 -0
- package/dist/core/utils/speech_cleanup.js.map +1 -0
- package/dist/core/utils/speech_to_text.js +3 -3
- package/dist/core/utils/speech_to_text_keywords.js +5 -4
- package/dist/core/utils/speech_to_text_keywords.js.map +1 -1
- package/dist/core/version.js +1 -1
- package/dist/diff_tool/app/dist/assets/{core-CXVpaOO1.js → core-Cnp6wBC7.js} +1 -1
- package/dist/diff_tool/app/dist/assets/engine-oniguruma-ConHyUk6.js +1 -0
- package/dist/diff_tool/app/dist/assets/{highlights-DuJNYjEh.js → highlights-DeO0fGqQ.js} +1 -1
- package/dist/diff_tool/app/dist/assets/index-BDuQ2wXS.js +221 -0
- package/dist/diff_tool/app/dist/assets/langs-DDFHLNuJ.js +1 -0
- package/dist/diff_tool/app/dist/assets/{loader-bi21_x0K.js → loader-DrwOwtvp.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{preload-helper-CRzLMJPS.js → preload-helper-DclECHGd.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{shiki-D6ZyrNQD.js → shiki-CwKGJZFi.js} +2 -2
- package/dist/diff_tool/app/dist/assets/{stream-tokenizer-BdsyU_yB.js → stream-tokenizer-D4-m26wx.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{themes-9lpTYI_i.js → themes-Do3waJhf.js} +2 -2
- package/dist/diff_tool/app/dist/index.html +2 -2
- package/dist/history/worker/index.js +83 -63
- package/dist/history/worker/index.js.map +1 -1
- package/dist/history/worker/migrations/0003_digest_schedule.sql +36 -0
- package/dist/history/worker/migrations/0004_recent_sessions.sql +1 -0
- package/dist/history/worker/migrations/0005_external_content.sql +58 -0
- package/dist/history/worker/migrations/0006_external_content_cutover.sql +44 -0
- package/dist/store/session_snapshot_migrations.js +14 -1
- package/dist/store/session_snapshot_migrations.js.map +1 -1
- package/dist/tui/chat_view.js +3 -1
- package/dist/tui/chat_view.js.map +1 -1
- package/dist/tui/listen_capture.js +7 -5
- package/dist/tui/listen_capture.js.map +1 -1
- package/dist/tui/session_chat_controller.js +93 -15
- package/dist/tui/session_chat_controller.js.map +1 -1
- package/dist/tui/ui/custom_editor.js +3 -0
- package/dist/tui/ui/custom_editor.js.map +1 -1
- package/package.json +8 -7
- package/dist/core/static/tau_docs/config-reference.md +0 -355
- package/dist/core/static/tau_docs/credentials.md +0 -165
- package/dist/core/static/tau_docs/models.md +0 -57
- package/dist/core/static/tau_docs/node-sdk.md +0 -430
- package/dist/core/static/tau_docs/ownership-and-scope.md +0 -107
- package/dist/core/static/tau_docs/prompts-and-project-context.md +0 -147
- package/dist/core/static/tau_docs/sdk-diff-review.md +0 -92
- package/dist/core/static/tau_docs/session-protocol-methods.md +0 -655
- package/dist/core/static/tau_docs/skills.md +0 -135
- package/dist/core/static/tau_docs/telegram-projects.md +0 -197
- package/dist/core/utils/gemini_transcription.js +0 -566
- package/dist/core/utils/gemini_transcription.js.map +0 -1
- package/dist/diff_tool/app/dist/assets/engine-oniguruma-Rz_7DPcV.js +0 -1
- package/dist/diff_tool/app/dist/assets/index-F9is7PUw.js +0 -221
- package/dist/diff_tool/app/dist/assets/langs-CTftvgbb.js +0 -1
|
@@ -1,31 +1,14 @@
|
|
|
1
1
|
# Client tools
|
|
2
2
|
|
|
3
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
9
|
+
## Configure a command tool
|
|
10
10
|
|
|
11
|
-
|
|
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
|
-
|
|
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
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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
|
-
|
|
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
|
-
```
|
|
111
|
-
|
|
46
|
+
```json
|
|
47
|
+
{ "enabledClientTools": ["notify_desktop"] }
|
|
112
48
|
```
|
|
113
49
|
|
|
114
|
-
|
|
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
|
-
|
|
52
|
+
## Write a command tool
|
|
119
53
|
|
|
120
|
-
|
|
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: "
|
|
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
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
78
|
+
Keep stdout free for the protocol and write diagnostics to stderr.
|
|
192
79
|
|
|
193
|
-
|
|
194
|
-
- `{ version: 5, type: "exec.result", requestId, ok: false, error: string }`
|
|
80
|
+
## Without the helper
|
|
195
81
|
|
|
196
|
-
|
|
82
|
+
Any executable can implement the protocol. It exchanges one JSON object per line on stdin and stdout:
|
|
197
83
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
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
|
-
`
|
|
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
|
-
|
|
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
|
-
|
|
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.
|