@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,215 +1,78 @@
1
1
  # Remote sessions
2
2
 
3
- In a remote session, the terminal stays on your machine while the session host and execution environment run elsewhere. `tau attach` is the same TUI, connected over WebSocket. What changes is which machine holds credentials and saved sessions, and where the agent's commands run.
3
+ In a remote session, the terminal stays on your machine while the host and the agent's work run elsewhere. Read [how Tau works](how-tau-works.md) first for which machine owns what.
4
4
 
5
- ## Choose the connection shape
6
-
7
- Choose the simplest setup that matches how long the host should live.
8
-
9
- | Setup | Best for | Lifetime and ownership |
10
- | --- | --- | --- |
11
- | `tau serve` plus WebSocket attach | Long-running hosts, reconnects, and multiple observers | The server owns the host independently of any one TUI. |
12
- | Node SDK with its default client | Applications that want an in-process host | The SDK client owns the host and closes it with the client. |
13
- | Node SDK over WebSocket | Applications sharing a long-running `tau serve` host | The server owns sessions; the SDK observes them remotely. |
14
-
15
- Use `tau serve` for remote TUI and SDK connections. To rely on SSH for security, keep it on loopback and connect through an SSH tunnel. The [session protocol](session-protocol.md) and [Node SDK](node-sdk.md) cover the developer APIs and wire format; this page covers operation.
16
-
17
- ## Host sessions over WebSocket
18
-
19
- Start a server on the host:
5
+ ## Start a host
20
6
 
21
7
  ```sh
22
8
  tau serve
23
9
  ```
24
10
 
25
- By default the server listens on `127.0.0.1:8787`, which suits local clients or a reverse proxy on the same machine. To listen on another interface, set it explicitly and require a strong token:
26
-
27
- ```sh
28
- export TAU_WS_AUTH_TOKEN="$(openssl rand -hex 32)"
29
- tau serve --host 0.0.0.0 --port 8787 --auth-token "$TAU_WS_AUTH_TOKEN"
30
- ```
31
-
32
- From the client machine:
33
-
34
- ```sh
35
- export TAU_WS_AUTH_TOKEN='the-same-token'
36
- tau attach ws://buildbox.example:8787
37
- ```
38
-
39
- `tau attach` uses `TAU_WS_AUTH_TOKEN` when `--auth-token` is not given. You can also pass the token explicitly:
40
-
41
- ```sh
42
- tau attach --auth-token "$TAU_WS_AUTH_TOKEN" ws://buildbox.example:8787
43
- ```
44
-
45
- The token gives full access to all hosted sessions. Without `--auth-token` or `TAU_WS_AUTH_TOKEN`, the server has no authentication. Tau serves plain WebSocket and has no TLS settings. On an untrusted network, put it behind a trusted TLS reverse proxy and attach with `wss://`, or keep it on loopback and use an SSH tunnel. The token is sent when the connection is set up, so treat proxy logs and WebSocket handshake data as sensitive.
46
-
47
- A typical tunnel, with Tau on loopback:
11
+ It listens on `127.0.0.1:8787` with no authentication. The simplest secure setup keeps it there and uses an SSH tunnel:
48
12
 
49
13
  ```sh
50
14
  ssh -N -L 8787:127.0.0.1:8787 dev@buildbox.example
51
- ```
52
-
53
- Then attach locally:
54
-
55
- ```sh
56
15
  tau attach ws://127.0.0.1:8787
57
16
  ```
58
17
 
59
- ## List, select, create, or attach
60
-
61
- Without `--session` or `--new`, `tau attach` asks the host for its session list and opens an interactive selector:
18
+ To listen on another interface, require a token:
62
19
 
63
20
  ```sh
64
- tau attach ws://127.0.0.1:8787
21
+ export TAU_WS_AUTH_TOKEN="$(openssl rand -hex 32)"
22
+ tau serve --host 0.0.0.0 --port 8787
65
23
  ```
66
24
 
67
- The selector shows each session ID and whether it is idle or running, and can also create a session. It needs a terminal: if stdin or stdout is not a TTY, pass `--session` or `--new`.
25
+ `tau attach` reads the same variable, or takes `--auth-token`. The token gives full access to every session. Tau has no TLS, so across an untrusted network use an SSH tunnel or a TLS reverse proxy with `wss://`. A proxy must pass the WebSocket upgrade and the query string, which carries the token as `tau_token`, so keep it out of the logs.
68
26
 
69
- If you know the session ID, attach directly:
70
-
71
- ```sh
72
- tau attach \
73
- --session 0195d6e4-4cf9-7f44-a2d8-f8f7f49ee9d3 \
74
- ws://127.0.0.1:8787
75
- ```
27
+ Set the default persona for new sessions when starting the host, with `tau serve --persona opus-5.5-coder`, or switch with `/persona:<id>` after attaching.
76
28
 
77
- To create a new session, give an absolute `--cwd` in the chosen execution environment:
29
+ ## Attach
78
30
 
79
31
  ```sh
80
- tau attach \
81
- --new \
82
- --cwd /srv/workspaces/tau \
83
- ws://127.0.0.1:8787
32
+ tau attach ws://127.0.0.1:8787
33
+ tau attach --session 0195d6e4-4cf9-7f44-a2d8-f8f7f49ee9d3 ws://127.0.0.1:8787
34
+ tau attach --new --cwd /srv/workspaces/tau ws://127.0.0.1:8787
84
35
  ```
85
36
 
86
- With the default `local` execution kind, this path is on the host machine, not the attaching machine. The directory must already exist and contain the repository or workspace you want. Tau creates only the session, not the directory or repository.
87
-
88
- A remote `--new` sets the creation attribute `source: "tui"`. It does not look at the remote directory to fill in repository information. Clients that need it should create sessions through the SDK or protocol and send `repository` themselves. The host still records `machine` and `cwd` for the session. See [sessions](sessions.md).
89
-
90
- `tau attach` does not accept the persona flags of local startup. Set the server's default when starting the host, for example `tau serve --persona opus-5.5-coder`, or switch the new session with `/persona:<id>` after attaching.
37
+ The first form opens a selector and needs a terminal. `--new` needs an absolute `--cwd` that already exists in the execution environment, and for the default `local` kind that is a path on the host. Tau does not create directories or clone repositories.
91
38
 
92
- ## Select an execution environment
39
+ ## Fly Sprites
93
40
 
94
- A session can use a directory on the host or an existing Fly Sprite. Either way, the working directory is an absolute path inside that environment.
41
+ A session can work on an existing Fly Sprite while the host stays on its own machine. Configure the connection in the host's configuration before starting it:
95
42
 
96
- ### Host-local directory
97
-
98
- `local` is the default:
99
-
100
- ```sh
101
- tau attach --new --cwd /srv/workspaces/tau ws://host.example:8787
43
+ ```json
44
+ {
45
+ "flySprites": {
46
+ "tokenEnv": "FLY_SPRITES_TOKEN"
47
+ }
48
+ }
102
49
  ```
103
50
 
104
- The agent's file operations and commands run on the host machine. Tau does not clone, pull, or set up a repository.
105
-
106
- ### Fly Sprite
107
-
108
- The host must have a `flySprites` connection configured, and the Sprite must already exist:
109
-
110
51
  ```sh
111
- tau attach \
112
- --new \
113
- --execution-kind fly-sprite \
114
- --fly-sprite tau-build-7 \
52
+ tau attach --new \
53
+ --execution-kind fly-sprite --fly-sprite tau-build-7 \
115
54
  --cwd /home/sprite/tau \
116
55
  wss://tau.example.com
117
56
  ```
118
57
 
119
- `--fly-sprite` names an existing Sprite. Tau does not provision it or prepare its repository.
120
-
121
- The Sprite API URL, home path, and token are host [configuration](configuration.md). When the session is created, Tau reads project configuration and content from the working directory inside the Sprite.
122
-
123
- ## Keep the ownership boundaries clear
124
-
125
- An attached session involves three separate parts, even when two of them run on the same machine.
126
-
127
- ### The attaching client owns
128
-
129
- - terminal rendering, editor drafts, clipboard operations, and local notifications
130
- - loaded themes and `defaultTheme`
131
- - `/listen`, `/speak`, and their local credentials and OS commands
132
- - the built-in diff tool process
133
- - configured command-backed client-tool processes
134
- - the client’s Tau binary and TUI behavior
135
-
136
- ### The session host owns
137
-
138
- - session orchestration, persistence, and recovery
139
- - provider credential resolution and model execution
140
- - WebSocket authentication and listener lifetime
141
- - hosted execution environment settings and credentials
142
- - pending input while the session remains live
143
- - the host’s Tau binary and built-in agent documentation
144
-
145
- ### The execution environment owns
146
-
147
- - the agent-visible cwd, home, files, and repository
148
- - project `.tau` content, prompts, skills, and AGENTS.md files
149
- - command execution, platform, PATH, and runtime dependencies
150
- - automatic-compaction archives and other target-side temporary files
151
-
152
- That is why a host's theme setting does not affect a remote TUI, why `!git status` runs in the execution environment, and why the built-in diff review tool opens on the attaching machine. [Ownership and scope](ownership-and-scope.md) applies the same model across Tau.
58
+ Tau does not create the Sprite or prepare its repository. Project configuration comes from the working directory inside the Sprite. Sessions on a Sprite have no [MCP servers](mcp.md).
153
59
 
154
- ## Reload or restart the correct process
60
+ ## Disconnecting and reconnecting
155
61
 
156
- Each kind of change belongs to a different process:
62
+ A client disconnecting leaves work running, and you can reattach with the same session ID. The host unloads a session from memory after the last client has left and work has finished, and keeps it saved.
157
63
 
158
- | Change | Action |
159
- | --- | --- |
160
- | Project config, personas, prompts, skills, or AGENTS.md in the execution environment | Wait for idle, then run `/reload`. |
161
- | MCP server definitions | Start a new session, or reopen the session after the host has unloaded it. See [`mcpServers`](config-reference.md#mcpservers). |
162
- | Global model `apiKeys` on the host | Restart the host. |
163
- | Codex auth changed with `tau auth` | No restart needed; every new request reads auth storage again. |
164
- | Attaching themes, voice, recording shortcut, personal speech vocabulary, or configured client tools | Restart `tau attach`. |
165
- | Host environment variables, history target, WebSocket listener, Fly Sprite connection, or host startup flags | Restart `tau serve`. |
166
- | Host Tau package, built-in tools, protocol, session recovery code, or built-in documentation | Upgrade and restart the host. |
167
- | TUI package, keybindings, rendering, local speech, or client-tool implementation | Upgrade and restart the attaching client. |
64
+ Shutting down `tau serve` interrupts running work and saves sessions. They come back idle after a restart, without pending messages or subagents. See [sessions](sessions.md).
168
65
 
169
- `/reload` acts on the session. The host reads session content again from the execution environment. It does not reload either process's code or environment. For a long-running WebSocket host, restarting only the client does not update the host's tools or the documentation its agent reads. For an old client attached to a new host, restarting only the host does not update the TUI. See [credentials](credentials.md) for complete precedence and apply boundaries.
66
+ ## Several clients
170
67
 
171
- ## Reconnect and observe safely
172
-
173
- A WebSocket connection observes a hosted session. It does not own the saved session and cannot delete it. After the last client disconnects, the host unloads an idle session from memory and keeps it saved. If a client disconnects while work is running, the host keeps working and unloads the session only after the work finishes. Protocol and SDK clients can also keep an unattached session and its idle subagents loaded for a limited time with [retention](session-protocol.md#keep-a-session-loaded-without-clients). Reattach with the same session ID to get the current state and continue receiving updates.
174
-
175
- A clean `tau serve` shutdown interrupts running work, saves live sessions, and closes clients. After a restart, the host lists the sessions whose execution environments it can reconnect. Recovered sessions come back idle, without queued or steering messages, and without subagents.
176
-
177
- ## Use multiple observers carefully
178
-
179
- Several WebSocket clients can observe the same live session and receive the same updates and pending messages. Every one of them can also submit, queue, steer, interrupt, or change the session. None is read-only, so agree on who, or which automation, is in charge.
180
-
181
- Each TUI offers its `diff_review` and `prefill_input` tools plus its enabled configured client tools. Only one client may offer a given tool name in a session. Start additional clients with:
68
+ Several clients can observe one session and see the same updates. Each of them can also submit, steer, interrupt, or change it, so agree on who is in charge. Only one client can offer a given tool name, so start the others without client tools:
182
69
 
183
70
  ```sh
184
- tau attach --no-client-tools --session 0195d6e4-4cf9-7f44-a2d8-f8f7f49ee9d3 ws://host.example:8787
71
+ tau attach --no-client-tools --session <id> ws://host.example:8787
185
72
  ```
186
73
 
187
- A turn keeps the client tools that were available when it started. If the owning client detaches, its tools become unavailable and its running calls are cancelled. After a host restart, client tools return only when a client that offers them attaches again. See [client tools](client-tools.md).
188
-
189
- ## Troubleshoot connection and recovery
190
-
191
- ### The client reports an unsupported protocol version
192
-
193
- Client and host must use exactly the same protocol version; there is no negotiation. Upgrade both to the same Tau release, restart both, and reconnect. The agent's tools and documentation come from the host's installation, and TUI behavior comes from the client's.
194
-
195
- Do not downgrade a host that has already saved sessions in a newer format. Newer Tau versions upgrade supported older sessions when recovering them, but older versions cannot read newer sessions.
196
-
197
- ### A session is missing from the selector
198
-
199
- The host lists only saved sessions whose execution environment it can reconnect. Confirm that:
200
-
201
- - the connection uses the same host user and home directory as the original process
202
- - the Fly Sprite connection is still configured on the host
203
- - host credentials are available to the restarted process
204
- - the target Sprite or local directory still exists
205
- - the session was created on this host rather than another machine with a different store
206
-
207
- Do not edit the session files to change the environment. Restore the configuration or the target instead.
208
-
209
- ### WebSocket attachment is unauthorized
210
-
211
- Check that server and client use the same token, and that any reverse proxy passes through the WebSocket request path and query string. `TAU_WS_AUTH_TOKEN` can supply the token on either side without you noticing, so check the environment as well as the flags. Do not print the token into shared logs.
74
+ ## Upgrades
212
75
 
213
- ### A reconnect shows an interrupted turn
76
+ Client and host must use the same protocol version, and there is no negotiation. Upgrade both to the same release and restart both. Do not downgrade a host, because older versions cannot read sessions saved by newer ones.
214
77
 
215
- A client disconnecting does not stop a turn on a WebSocket host, but a server shutdown does. Look at the last assistant message and tool results, check the execution environment with `!!pwd` and `!!git status --short`, then retry if you mean to. [Sessions](sessions.md) explains recovery and how to check a recovered session.
78
+ The agent's tools and documentation come from the host's installation, and TUI behavior comes from the client's.
@@ -0,0 +1,150 @@
1
+ # Node SDK
2
+
3
+ The SDK is a typed client for creating and controlling Tau sessions from Node, without handling the [wire protocol](session-protocol.md). This page gives an overview. The exported types describe every option and result, and the [source](https://github.com/markusylisiurunen/tau) is the reference for details.
4
+
5
+ ```sh
6
+ npm install @markusylisiurunen/tau
7
+ ```
8
+
9
+ Tau is an ES module package and requires Node.js 24 or newer. Everything you need is exported from `@markusylisiurunen/tau/sdk`.
10
+
11
+ ## Run a session
12
+
13
+ ```ts
14
+ import { createTauSdkClient } from "@markusylisiurunen/tau/sdk";
15
+
16
+ const client = await createTauSdkClient();
17
+ try {
18
+ const session = await client.sessions.create({
19
+ executionEnvironment: { kind: "local", cwd: process.cwd() },
20
+ attributes: { source: "my-app" },
21
+ });
22
+ const result = await session.submit("Summarize the current changes.");
23
+ const snapshot = await session.snapshot();
24
+ console.log(result.turn.status, snapshot.revision);
25
+ } finally {
26
+ await client.close();
27
+ }
28
+ ```
29
+
30
+ `cwd` must be an absolute path in the execution environment, which can also be `{ kind: "fly-sprite", spriteName, cwd }`. A successful call does not mean the turn succeeded, so check `result.turn.status`, which is `completed`, `failed`, `aborted`, or `blocked`.
31
+
32
+ ## Choose a client
33
+
34
+ | Function | Host | When to use it |
35
+ | --- | --- | --- |
36
+ | `createTauSdkClient(options?)` | In your process | Your application runs Tau itself. Closing the client saves sessions and stops the host. |
37
+ | `createTauSdkWebSocketClient({ url, authToken?, ... })` | `tau serve` | You share a long-running host. Closing only ends the connection. |
38
+ | `createTauSdkClientFromTransport(transport)` | Your choice | You bring your own `SessionProtocolTransport`. |
39
+
40
+ The in-process client accepts `persona`, `reasoning`, `noAgentContextFiles`, `refreshModelCatalog`, `clientTools`, and `onDiagnostic`. Sessions read their configuration from their own execution environment. The host never writes diagnostics to stdout or stderr. They arrive through `onDiagnostic`, including configuration warnings and history failures.
41
+
42
+ ## Use a session
43
+
44
+ `client.sessions` has `create`, `list`, `observe`, `setRetention`, and `collect`. A session object has these groups of methods:
45
+
46
+ | Purpose | Methods |
47
+ | --- | --- |
48
+ | Send input | `submit`, `queue`, `steer`, `record`, `retry`, `cancelPendingMessages` |
49
+ | Stop work | `interrupt`, `interruptSubagent` |
50
+ | Read state | `snapshot`, `pendingUserMessages`, `subagentActivities` |
51
+ | Change settings | `setPersona`, `setReasoning`, `setAutoCompactThreshold`, `reload` |
52
+ | Manage context | `compact`, `rewindToHistoryEntryId` |
53
+ | Use the environment | `exec`, `autocompletePaths`, `resolvePrompt` |
54
+ | Call a model | `sample`, `createEphemeralContext`, `submitEphemeralThread`, `closeEphemeralContext` |
55
+ | Finish | `unobserve` |
56
+
57
+ `exec` runs a command in the execution environment without adding it to the conversation:
58
+
59
+ ```ts
60
+ const result = await session.exec("git status --short", { timeoutMs: 10_000 });
61
+ ```
62
+
63
+ `sample` runs a standalone model call with the session's model and only the context you pass, and it never changes the session. Ephemeral contexts run separate agent threads that are not saved, for side tasks such as answering a question about a diff.
64
+
65
+ `submit`, `queue`, and `record` accept a `historyEntryId`. `getTauSdkSessionTurnRecord(snapshot, id)` tells you whether an accepted turn is unknown, running, or finished, which helps after a reconnect.
66
+
67
+ ## Follow live state
68
+
69
+ ```ts
70
+ const stop = session.onDelta((delta) => render(delta));
71
+ ```
72
+
73
+ Apply deltas to your snapshot with `applySessionProtocolDelta`, and fetch `session.snapshot()` if a revision is missing. `onPendingUserMessages` and `onSubagentActivities` send their current state right away and then each change. `onEphemeral` carries live notices that are not guaranteed to arrive. The [session protocol](session-protocol.md) explains these channels.
74
+
75
+ Before showing user text from a snapshot, use `getTauUserDisplayText`, which removes Tau metadata and hidden `<system>` blocks.
76
+
77
+ ## Provide client tools
78
+
79
+ Pass `clientTools` to give the model tools that run in your process:
80
+
81
+ ```ts
82
+ const client = await createTauSdkClient({
83
+ clientTools: [
84
+ {
85
+ schema: {
86
+ name: "workspace_status",
87
+ description: "Report the Git status of the workspace.",
88
+ parameters: {
89
+ type: "object",
90
+ properties: {},
91
+ additionalProperties: false,
92
+ },
93
+ executionTimeoutMs: 60_000, // null for no deadline
94
+ },
95
+ execute: async (args, context) => {
96
+ const status = await context.executionEnvironment.exec(
97
+ "git status --short",
98
+ {
99
+ signal: context.signal,
100
+ },
101
+ );
102
+ return { content: status.output || "Working tree is clean." };
103
+ },
104
+ },
105
+ ],
106
+ });
107
+ ```
108
+
109
+ The handler runs in your process, and `executionEnvironment.exec` runs on the session's machine. Return a string or `{ content, presentation? }`, or `{ ok: false, error }` for a handled failure. An optional `describe` function customizes the running tool card. See [client tools](client-tools.md).
110
+
111
+ `createTauCodeModeClientTool` gives the model a [code mode](code-mode.md) sandbox for an API you define:
112
+
113
+ ```ts
114
+ const tickets = createTauCodeModeClientTool({
115
+ name: "tickets",
116
+ description: "Read support tickets with JavaScript.",
117
+ documentation: "# Tickets API\n\nUse `tickets.get(id)` to read one ticket.",
118
+ api: {
119
+ get: async ([id], { signal }) => ticketClient.get(String(id), { signal }),
120
+ },
121
+ });
122
+ ```
123
+
124
+ ## Host a diff review
125
+
126
+ `startTauSdkDiffReview` serves the browser review interface for an observed session, without opening a browser:
127
+
128
+ ```ts
129
+ const review = await startTauSdkDiffReview({
130
+ session,
131
+ source: { kind: "git_diff", diffArgs: ["main...HEAD"] },
132
+ });
133
+ console.log(review.url);
134
+ try {
135
+ const result = await review.result;
136
+ if (result.status === "returned") console.log(result.outcome, result.review);
137
+ } finally {
138
+ await review.close();
139
+ }
140
+ ```
141
+
142
+ The server listens on loopback and has no authentication, so put it behind a protected proxy to expose it. Pass `storage` to save review state and `onSubmit` to save a submission before the browser sees success.
143
+
144
+ ## Errors and closing
145
+
146
+ Errors extend `TauSessionClientError`. `TauSessionProtocolResponseError` means the host returned an error, so branch on its `code`. `TauTransportError` means the connection failed.
147
+
148
+ Most methods take no `AbortSignal`, so call `session.interrupt()` to stop work on the host. `session.exec` accepts a signal for that command. Always call `client.close()` in `finally`. It rejects open requests and waits for running client tool handlers.
149
+
150
+ To keep a session loaded without clients, or to confirm it is unloaded before deleting its files, see [session protocol](session-protocol.md).
@@ -1,198 +1,11 @@
1
1
  # Security
2
2
 
3
- Tau gives an agent real tools that change files, run processes, and call configured services. A tool runs as soon as the model calls it. Tau adds no confirmation dialog, no restriction to the repository, and no general sandbox.
3
+ A tool runs as soon as the model calls it. Tau adds no confirmation dialog, no restriction to the repository, and no general sandbox. The agent can do what the operating-system account behind the tool can do, so choose the machine and account accordingly. Use a dedicated user, container, or VM when work should be isolated.
4
4
 
5
- So before starting a session, decide which machine the agent may change, which credentials that machine may hold, and which project content you trust. The [ownership and scope](ownership-and-scope.md) page defines the client, host, execution environment, and Telegram runner used below.
5
+ Three things are worth keeping in mind:
6
6
 
7
- ## Direct execution and operating-system authority
7
+ - **Project content is trusted.** Opening a session in a repository loads its `.tau/` directory, skills, and `AGENTS.md`. These can add instructions and start [MCP servers](mcp.md) on the host with its credentials. A project cannot define [client tools](client-tools.md), but it can select ones you defined globally.
8
+ - **Anyone who can reach a host or bot can act through it.** A `tau serve` token gives full access to every session. A Telegram bot follows the instructions of anyone its allowlists permit. See [remote sessions](remote-sessions.md) and [Telegram](telegram.md).
9
+ - **Transcripts contain what the agent saw.** Saved sessions and [history](history.md) keep tool output, which can include source code and secrets. A remote history service holds a copy. Rotate any credential that ends up in a transcript.
8
10
 
9
- Host tools such as `bash`, `write`, and `edit` act in the session's execution environment. They have that environment's operating-system permissions and are not limited to the repository. Absolute paths work wherever the operating system allows. Changes to files and processes remain even if the tool output is truncated, the turn is interrupted, or the model request fails.
10
-
11
- Client tools have separate permissions. A command client tool runs as the client's user, with the client process's current directory and environment. It can also ask to run commands in the execution environment. In a remote session, one turn can therefore act with the permissions of two different machines.
12
-
13
- Give each part only the access it needs:
14
-
15
- - Run Tau and its execution environment as a dedicated, unprivileged user when the workspace does not need access to a personal home directory.
16
- - Use a container, virtual machine, or separate hosted environment when work should be isolated from the host. Tau respects that isolation, but not every execution environment type is a security sandbox.
17
- - Mount or copy only the repositories and files the task needs. Do not point an execution environment at a broad home directory for convenience.
18
- - Give the host only the provider and service credentials needed for its sessions. Give client-tool processes only the client-local credentials they need.
19
- - Use a persona with a shorter `tools` list for work that should not change files or call external services. The built-in `tau_docs` tool is always available regardless of that list.
20
-
21
- Interruption, timeouts, output limits, and process-group termination limit how long and how much a command runs. They do not ask for approval and cannot undo anything already done. Review destructive commands, and use Tau's normal session operations instead of asking an agent to change Tau's internal files.
22
-
23
- [Claude Code subagents](subagents.md#claude-code-subagents) run on the execution environment with permission checks bypassed and the Claude Code sandbox disabled. They load local Claude settings, project instructions, skills, and normally configured MCP servers. Review those files and server permissions before enabling workers. The parent persona controls the selected built-in tools; Claude Code's own configuration controls its MCP connections. Tau disables hooks and nested agents. Managed Claude policies still apply. Claude credentials and transcripts stay on that environment; Tau does not forward host service credentials or MCP connections. Subscription extra usage can incur charges if enabled in the Claude account.
24
-
25
- ## Treat project content as executable policy
26
-
27
- Tau loads more than source files from the execution environment. It reads project `.tau/config.json`, personas, prompts, skills, `.agents/skills`, and `AGENTS.md` from the working directory and its parents. This content can choose models and tools, add instructions, define workflows, and change which of your global client tools are offered.
28
-
29
- Trusting a repository therefore means trusting this content. Before using a repository with valuable credentials or write access, read its `.tau/`, `.agents/`, and `AGENTS.md` content, including nested levels. Look especially at:
30
-
31
- - persona system prompts, tool lists, and model launch allowlists;
32
- - skill instructions and any scripts they direct the agent to run;
33
- - project configuration that sets model notices or hosted-environment connections;
34
- - `enabledClientTools`, which can turn on commands from your global configuration; and
35
- - provision scripts or other repository automation used by integrations such as Telegram.
36
-
37
- Project configuration cannot define client tool commands. It can only select commands defined in global configuration. A repository therefore cannot add a new client tool command to your machine, but a selected command can still do anything it was written to do. MCP servers follow different rules: [project configuration can define them](#trust-mcp-servers).
38
-
39
- `--no-agent-context-files` turns off `AGENTS.md` loading and the list of nested `AGENTS.md` files. Project configuration, personas, skills, and tools still load. `--no-client-tools` turns off TUI client tools, not host tools. Neither flag is a general safe mode.
40
-
41
- Prompt templates are inserted into the editor for you to review; they are never sent automatically. Leading `<system>` blocks, persona prompts, model notices, and session messages are sent to the model and may be saved in the session. Never put secrets in instructions, prompts, or model notices.
42
-
43
- ## Trust remote model metadata as routing configuration
44
-
45
- A Tau host that runs models refreshes compatible provider catalogs from `pi.dev` and caches them in `~/.config/tau/models-store.json`. Treat this like a software update channel. A remote model record can change the model's API adapter, endpoint, headers, compatibility settings, limits, and pricing. If that service were compromised or misconfigured, it could redirect provider requests, along with their credentials. Set `TAU_OFFLINE` to turn off automatic catalog requests.
46
-
47
- ## Keep secrets with the process that needs them
48
-
49
- Most model and service credentials belong on the host, because the host makes model calls, performs web searches, and replicates history. TUI speech credentials and command client tool credentials belong on the client. Telegram bot, transcription, and voice credentials belong to the Telegram runner. Credentials for hosted execution environments belong in the host's startup configuration.
50
-
51
- When attached to a remote host, a credential exported on the laptop does not reach the host. Putting a host credential into the execution environment's shell would needlessly expose it to every process there. See [credentials](credentials.md) for which source wins.
52
-
53
- For personal secrets, prefer host environment variables or global configuration over project files. Some integrations accept a field that names an environment variable, which keeps the secret out of JSON. Telegram stores each bot token in the runner's configuration file, so protect that file like any other secret.
54
-
55
- Never put credentials in:
56
-
57
- - committed project files;
58
- - persona, prompt, skill, `AGENTS.md`, or model-notice text;
59
- - Bash command lines likely to enter shell history or process listings;
60
- - tool results, session messages, issue comments, or debug output.
61
-
62
- Do not debug authentication by printing an environment, a configuration file, `auth.json`, or a service response that includes headers. Check that the expected source is set up for the right process, then run a small operation that uses it. `tau auth list` shows Codex account identities and status without showing tokens.
63
-
64
- If a credential appears in a session, log, shell history, repository, Telegram message, or history, treat it as exposed. First revoke or rotate it at the provider. Then replace the stored value through configuration or the auth command, restart the process that uses it if needed, and delete the exposed copy where retention rules allow. Redacting the copy does not replace rotation.
65
-
66
- ## Understand environment sanitization
67
-
68
- Commands in a local execution environment start from a filtered copy of the Tau process environment. Tau removes inherited variables whose names end in `_KEY`, `_SECRET`, `_TOKEN`, or `_PASSWORD`, and the exact name `API_KEY`. This reduces accidental leaks from a local host into the agent's Bash commands.
69
-
70
- The filter has clear limits:
71
-
72
- - It is name-based, so a secret under another name is not recognized.
73
- - Variables set explicitly for the execution environment are applied after filtering and can add a secret back.
74
- - Hosted execution environments start from their own environment.
75
- - Command client tools inherit the client process environment unchanged.
76
- - Tau's own model and service code on the host uses the host credentials it needs.
77
-
78
- The filter is neither a secret store nor an access control. Avoid printing whole environments, and keep secrets out of every process that does not need them.
79
-
80
- ## Keep login shells automation-safe
81
-
82
- Tau runs each command in a fresh non-interactive login Bash. The execution environment's `HOME` decides which startup files are read. Bash can read `/etc/profile`, the first user login file it finds, and `BASH_ENV`, and a login file may also source `.bashrc`.
83
-
84
- These files run with the same permissions as every tool command. A compromised or careless startup file can change `PATH`, run commands, leak data, exit the shell, or print unexpected output. Review the startup files in each execution environment, especially ones created from shared images or existing user homes.
85
-
86
- Startup files must not print banners, prompt, read stdin, require a TTY, open an editor, or exit the shell. Tau does not suppress their output. There is no TTY and the agent's Bash calls have no stdin, so interactive logins and terminal prompts fail or hang until the timeout. Set up Git, SSH, package managers, and cloud CLIs to work without prompts.
87
-
88
- ## Trust command client tools as local programs
89
-
90
- Command client tools are defined only in your global configuration, and projects can only select them. Tau starts the executable directly, without a shell, and validates the model's arguments against the configured schema. The command still runs as trusted local code, with the client's full environment and file permissions.
91
-
92
- Before enabling one:
93
-
94
- 1. Review the executable and pin or control how it is updated.
95
- 2. Use a narrow schema and describe side effects accurately for the model.
96
- 3. Avoid building shell source from model-provided strings. Prefer fixed commands and argument arrays.
97
- 4. Honor cancellation and set a bounded execution timeout.
98
- 5. Return only the data the model needs, with diagnostics on stderr.
99
- 6. Run commands in the execution environment only for work that really belongs on the session machine.
100
-
101
- A project's `enabledClientTools` can only select definitions you already trust globally. Unknown names are ignored without an error, so check which tools are actually offered after a change. Start an untrusted project with `--no-client-tools` until you have reviewed its selection.
102
-
103
- The TUI's built-in diff review tool also runs as a process on the client machine.
104
-
105
- ## Use code mode as a capability boundary
106
-
107
- JavaScript written by the model for `code` and code-mode client tools runs in a restricted sandbox. It receives only the declared capabilities, `docs`, the JSON `input` value, `printText`, the async `printImage`, the `truncate` and `truncateLines` helpers, the real `Date`, and `Math.random()`. It has no imports, processes, environment variables, credentials, timers, fetch, files, or network access of its own. When Bash is selected, `tau.bash` runs commands with the same permissions as the Bash tool, and the sandbox does not limit what those commands do.
108
-
109
- The API behind each capability runs outside the sandbox, with whatever access the tool gives it. The sandbox limits the model's code to the declared capabilities, but a capability that is too powerful is still dangerous. Tool authors should validate every argument, offer narrow operations, keep credentials outside the sandbox, honor cancellation, and never return secrets.
110
-
111
- `tau.models` sends only the inputs given in each request to OpenRouter. File attachments are read from the session machine, and inline media is checked against its bytes. Provider credentials stay outside the sandbox. Reported model costs are recorded even if the program fails later.
112
-
113
- The `history` API is read-only, but it can see transcripts from every repository and execution environment in the configured collection. The agent uses it only when the user or active instructions directly ask. That rule is no substitute for access control on the history service.
114
-
115
- ## Trust MCP servers
116
-
117
- A session on a local execution environment uses the MCP servers from the global and project configuration of its working directory, if its persona allows `mcp`. Its subagents use the same servers. Opening a session in a repository therefore lets that repository's `.tau/config.json` start commands on the host and use host credentials, with no approval step. This also applies to repositories that Telegram prepares and to directories that a WebSocket client chooses. Review a project's configuration before you open a session in it.
118
-
119
- Anyone who can write a project's configuration can use this authority, including the agent. If the agent adds a server to `.tau/config.json`, that server becomes available the next time a session loads that configuration, for example after recovery. Tau removes secret-like variables from [Bash commands](#understand-environment-sanitization), but a stdio server inherits the full host environment. Definitions can also put any host environment variable into `env` or `headers` with `${NAME}`, and send it to the configured command or URL.
120
-
121
- A session on a remote execution environment has no MCP servers, including servers configured on the host. Servers run on the host, so they could expose the host's files to a session that should see only its own machine, and neither the transport type nor a server's description shows whether they do. Configuration on the remote machine therefore cannot start commands on the host. The cost is that remote sessions also lose servers that only call an external service. This rule does not cover everything outside the remote machine: [Claude Code subagents](subagents.md#claude-code-subagents) use their own MCP configuration on that machine, and an attached client can still offer [command tools](client-tools.md) that run on the client's machine.
122
-
123
- A stdio MCP server is trusted code on the host. It runs outside the code-mode sandbox with the host account's file and process permissions and its full environment, including credentials. Review the executable and arguments before configuring a server. HTTP servers receive the configured headers and the arguments sent to their tools. Use HTTPS for remote servers and give them only the access they need.
124
-
125
- MCP has no confirmation step. Tools can change external systems or host resources immediately. Interrupting a call cannot undo what already happened, and when the outcome is unknown, retrying a change is not safe. Treat server descriptions, instructions, annotations, and results as untrusted data. Annotations such as `readOnlyHint` are not enforced.
126
-
127
- How a stdio server shuts down depends on the MCP transport. Child processes that ignore `SIGTERM` can outlive the server, so do not rely on shutdown to stop untrusted server processes.
128
-
129
- A server that exposes host files or commands gives the agent that access. If that access is not acceptable, remove `mcp` from the persona or disable the server. Connections and credentials stay outside the model's JavaScript, but the server decides what its tools return.
130
-
131
- ## Protect remote session transports
132
-
133
- `tau serve` listens on loopback by default. Keep it that way unless you need remote network access. Without `--auth-token` or `TAU_WS_AUTH_TOKEN`, the WebSocket server has no authentication, and any client that connects can observe and change hosted sessions.
134
-
135
- The token gives full access to all sessions. Tau sends it in the WebSocket URL as the `tau_token` query parameter. Use a strong random value, avoid typing it on command lines that end up in shell history, and make sure reverse proxies and access logs do not record it.
136
-
137
- Tau serves plain WebSocket and has no TLS settings. Across an untrusted network, use one of these setups:
138
-
139
- - bind Tau to loopback and forward it through SSH;
140
- - place it behind a trusted TLS reverse proxy and connect with `wss://`; or
141
- - keep it on a private network whose access controls and confidentiality are understood.
142
-
143
- A reverse proxy must pass through the WebSocket upgrade and the query string, and keep both protected. Limit who can reach the server even when a token is set. Every attached client has full control: it can submit, steer, interrupt, rewind, and offer client tools. See [remote sessions](remote-sessions.md).
144
-
145
- ## Secure Telegram access and workspaces
146
-
147
- A Telegram runner is both a client exposed to the network and a local Tau host. Its bot configuration decides who can start turns that run tools in the configured workspaces.
148
-
149
- Set `allowedUserIds` for allowed senders and `allowedChatIds` for allowed chats. Without `allowedUserIds`, any user can message the bot in a private chat, and without `allowedChatIds`, any private chat is allowed. Group chats are ignored unless their chat id is in `allowedChatIds`, and a group turn starts only when the bot is mentioned. Messages, attachments, audio transcripts, and errors from an allowed group can become context for a later turn, so group membership and history are part of what you trust.
150
-
151
- Each bot's `allowedProjectIds` should list only the intended projects. Telegram sessions are separate per bot and chat, but a persistent-directory project uses the same directory for all of its sessions. Work in one session is visible to later sessions and to other allowed chats that select the same project. Never use a personal home, a credential directory, or an unrelated shared directory as a persistent project.
152
-
153
- Repository and composite projects use managed workspaces and persistent bare repository caches. New or reconstructed repositories may run an executable `.tau/scripts/provision` in the background. Review that script like any other trusted project automation. Persistent-directory projects are never provisioned and never deleted by Tau.
154
-
155
- A bot's `env` can select its own GitHub account and commit identity, but it does not isolate bots from each other. All bots run as the same operating-system user and share repository caches, so a command in one bot's session can read any credential store that user can read. Run separate runners under separate OS accounts when bots must be isolated. Tau saves `env` in each session, so it should hold paths to credential stores and no secrets. See [bot environments](telegram-projects.md#bot-environments).
156
-
157
- Protect the runner configuration, session state, project-preference state, managed workspace root, and temporary attachment storage with a suitable OS account and file permissions. Never run two Telegram runners on the same state. Operational details are in [Telegram](telegram.md) and [Telegram projects and workspaces](telegram-projects.md).
158
-
159
- ## Know what history retains
160
-
161
- Tau keeps a flat transcript history in the host user's home, separate from saved sessions. It contains user messages, intermediate system instructions, assistant text, and completed tool calls. The initial persona prompt is not included. Compaction does not remove entries. Rewind removes entries after the rewind point. Apart from that, entries stay; history is not a temporary cache.
162
-
163
- History also records each native Tau subagent as its own session, whether or not any agent has the `history` tool. Rewinding the parent session does not remove these sessions, so a rewind can leave subagent transcripts in history that came from the removed work.
164
-
165
- Without remote history, it stays in a SQLite database on the host. The `tau.history` capability can search all of it, within the persona's tools and the agent's usage rules. Protect the host account and database as you would the transcripts themselves.
166
-
167
- With global `history` configuration, entries are still written to local SQLite first, and a persistent outbox copies them to the configured service in the background. Remote entries are limited in size, with large content truncated in the middle, but they can still contain source code, tool output, instructions, and personal data. The service also summarizes transcript content with its configured Cloudflare AI service.
168
-
169
- Before turning on remote history, confirm who runs the service, its retention policy and region, who holds access keys, and which projects may be sent. One service key can search the whole shared collection. Rotate it if exposed. Removing the configuration does not delete data that was already copied. See [history](history.md) for storage and service behavior.
170
-
171
- ## Edit configuration without widening authority accidentally
172
-
173
- A configuration change can redirect network traffic, expose tools, or send credentials somewhere new. Follow these steps:
174
-
175
- 1. Find out what reads the setting, and its machine, `cwd`, home, and Tau version.
176
- 2. Read the field's entry in [configuration](configuration.md) and the [configuration reference](config-reference.md).
177
- 3. Check nearer configuration levels that may replace or merge the field.
178
- 4. Back up only the file you are changing, with permissions no broader than the original.
179
- 5. Make the smallest edit at the narrowest level that works. Keep secrets out of project files.
180
- 6. Validate the JSON or frontmatter without printing the whole file into a shared transcript.
181
- 7. For a local startup, run `tau --debug` from the relevant directory, if its prompt output can stay private. For a running session, run `/reload` while idle and read every warning.
182
- 8. If the setting is read at startup, restart the client, host, or runner. Test one small operation before continuing.
183
-
184
- Unknown fields are removed without a warning, so valid JSON can still have no effect. An invalid nearer value may be skipped, leaving a broader value in effect. Check the behavior instead of assuming your edit applied.
185
-
186
- ## Do not edit durable internals
187
-
188
- Tau's internal files hold the state it needs to recover. They are not configuration. Do not edit or casually delete:
189
-
190
- - `~/.config/tau/auth.json`;
191
- - `~/.config/tau/models-store.json`;
192
- - files under `~/.config/tau/sessions`;
193
- - `~/.config/tau/history.sqlite` and its SQLite side files;
194
- - Telegram runner session and project-preference state;
195
- - managed Telegram workspaces or repository caches as a first-line repair;
196
- - code-mode or compaction temporary files as if they were durable state.
197
-
198
- Use `tau auth` for Codex accounts, TUI or session protocol operations for sessions, configuration for behavior, and the documented commands for history. If recovery reports corruption, keep the original data, stop any other process writing to it, write down the exact error and Tau version, and investigate through normal recovery before trying any repair that deletes data.
11
+ Keep secrets out of project files, prompts, and model notices. Secrets in `env` or `apiKeys` are readable by anything running as that user.