@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.
Files changed (97) hide show
  1. package/README.md +18 -23
  2. package/dist/core/config/ownership.js +3 -1
  3. package/dist/core/config/ownership.js.map +1 -1
  4. package/dist/core/config/schema.js +3 -1
  5. package/dist/core/config/schema.js.map +1 -1
  6. package/dist/core/history/migrations.js +46 -1
  7. package/dist/core/history/migrations.js.map +1 -1
  8. package/dist/core/history/setup.js +24 -7
  9. package/dist/core/history/setup.js.map +1 -1
  10. package/dist/core/mcp/cli.js +1 -1
  11. package/dist/core/mcp/cli.js.map +1 -1
  12. package/dist/core/static/tau_docs/client-tools.md +46 -385
  13. package/dist/core/static/tau_docs/code-mode.md +104 -43
  14. package/dist/core/static/tau_docs/configuration.md +77 -171
  15. package/dist/core/static/tau_docs/getting-started.md +25 -96
  16. package/dist/core/static/tau_docs/history.md +30 -228
  17. package/dist/core/static/tau_docs/how-tau-works.md +53 -0
  18. package/dist/core/static/tau_docs/image-generation.md +15 -107
  19. package/dist/core/static/tau_docs/index.md +46 -45
  20. package/dist/core/static/tau_docs/instructions-and-skills.md +81 -0
  21. package/dist/core/static/tau_docs/manifest.json +15 -20
  22. package/dist/core/static/tau_docs/mcp.md +77 -0
  23. package/dist/core/static/tau_docs/models-and-credentials.md +67 -0
  24. package/dist/core/static/tau_docs/openrouter.md +31 -129
  25. package/dist/core/static/tau_docs/pdf-unpacking.md +8 -21
  26. package/dist/core/static/tau_docs/personas.md +48 -144
  27. package/dist/core/static/tau_docs/remote-sessions.md +33 -170
  28. package/dist/core/static/tau_docs/sdk.md +150 -0
  29. package/dist/core/static/tau_docs/security.md +6 -193
  30. package/dist/core/static/tau_docs/session-protocol.md +84 -246
  31. package/dist/core/static/tau_docs/sessions.md +41 -205
  32. package/dist/core/static/tau_docs/speech-generation.md +16 -129
  33. package/dist/core/static/tau_docs/subagents.md +57 -229
  34. package/dist/core/static/tau_docs/telegram.md +152 -220
  35. package/dist/core/static/tau_docs/tools.md +44 -167
  36. package/dist/core/static/tau_docs/troubleshooting.md +23 -217
  37. package/dist/core/static/tau_docs/tui.md +42 -276
  38. package/dist/core/subagents/claude_code_runner.mjs +65 -65
  39. package/dist/core/telegram/adapter.js +178 -61
  40. package/dist/core/telegram/adapter.js.map +1 -1
  41. package/dist/core/telegram/cli.js +1 -3
  42. package/dist/core/telegram/cli.js.map +1 -1
  43. package/dist/core/telegram/config.js +3 -1
  44. package/dist/core/telegram/config.js.map +1 -1
  45. package/dist/core/telegram/runtime.js +1 -1
  46. package/dist/core/telegram/runtime.js.map +1 -1
  47. package/dist/core/utils/scribe_transcription.js +283 -0
  48. package/dist/core/utils/scribe_transcription.js.map +1 -0
  49. package/dist/core/utils/speech_cleanup.js +198 -0
  50. package/dist/core/utils/speech_cleanup.js.map +1 -0
  51. package/dist/core/utils/speech_to_text.js +3 -3
  52. package/dist/core/utils/speech_to_text_keywords.js +5 -4
  53. package/dist/core/utils/speech_to_text_keywords.js.map +1 -1
  54. package/dist/core/version.js +1 -1
  55. package/dist/diff_tool/app/dist/assets/{core-CXVpaOO1.js → core-Cnp6wBC7.js} +1 -1
  56. package/dist/diff_tool/app/dist/assets/engine-oniguruma-ConHyUk6.js +1 -0
  57. package/dist/diff_tool/app/dist/assets/{highlights-DuJNYjEh.js → highlights-DeO0fGqQ.js} +1 -1
  58. package/dist/diff_tool/app/dist/assets/index-BDuQ2wXS.js +221 -0
  59. package/dist/diff_tool/app/dist/assets/langs-DDFHLNuJ.js +1 -0
  60. package/dist/diff_tool/app/dist/assets/{loader-bi21_x0K.js → loader-DrwOwtvp.js} +1 -1
  61. package/dist/diff_tool/app/dist/assets/{preload-helper-CRzLMJPS.js → preload-helper-DclECHGd.js} +1 -1
  62. package/dist/diff_tool/app/dist/assets/{shiki-D6ZyrNQD.js → shiki-CwKGJZFi.js} +2 -2
  63. package/dist/diff_tool/app/dist/assets/{stream-tokenizer-BdsyU_yB.js → stream-tokenizer-D4-m26wx.js} +1 -1
  64. package/dist/diff_tool/app/dist/assets/{themes-9lpTYI_i.js → themes-Do3waJhf.js} +2 -2
  65. package/dist/diff_tool/app/dist/index.html +2 -2
  66. package/dist/history/worker/index.js +83 -63
  67. package/dist/history/worker/index.js.map +1 -1
  68. package/dist/history/worker/migrations/0003_digest_schedule.sql +36 -0
  69. package/dist/history/worker/migrations/0004_recent_sessions.sql +1 -0
  70. package/dist/history/worker/migrations/0005_external_content.sql +58 -0
  71. package/dist/history/worker/migrations/0006_external_content_cutover.sql +44 -0
  72. package/dist/store/session_snapshot_migrations.js +14 -1
  73. package/dist/store/session_snapshot_migrations.js.map +1 -1
  74. package/dist/tui/chat_view.js +3 -1
  75. package/dist/tui/chat_view.js.map +1 -1
  76. package/dist/tui/listen_capture.js +7 -5
  77. package/dist/tui/listen_capture.js.map +1 -1
  78. package/dist/tui/session_chat_controller.js +93 -15
  79. package/dist/tui/session_chat_controller.js.map +1 -1
  80. package/dist/tui/ui/custom_editor.js +3 -0
  81. package/dist/tui/ui/custom_editor.js.map +1 -1
  82. package/package.json +8 -7
  83. package/dist/core/static/tau_docs/config-reference.md +0 -355
  84. package/dist/core/static/tau_docs/credentials.md +0 -165
  85. package/dist/core/static/tau_docs/models.md +0 -57
  86. package/dist/core/static/tau_docs/node-sdk.md +0 -430
  87. package/dist/core/static/tau_docs/ownership-and-scope.md +0 -107
  88. package/dist/core/static/tau_docs/prompts-and-project-context.md +0 -147
  89. package/dist/core/static/tau_docs/sdk-diff-review.md +0 -92
  90. package/dist/core/static/tau_docs/session-protocol-methods.md +0 -655
  91. package/dist/core/static/tau_docs/skills.md +0 -135
  92. package/dist/core/static/tau_docs/telegram-projects.md +0 -197
  93. package/dist/core/utils/gemini_transcription.js +0 -566
  94. package/dist/core/utils/gemini_transcription.js.map +0 -1
  95. package/dist/diff_tool/app/dist/assets/engine-oniguruma-Rz_7DPcV.js +0 -1
  96. package/dist/diff_tool/app/dist/assets/index-F9is7PUw.js +0 -221
  97. package/dist/diff_tool/app/dist/assets/langs-CTftvgbb.js +0 -1
@@ -1,32 +1,16 @@
1
1
  # Session protocol
2
2
 
3
- Tau's session protocol is the wire format for clients that create, observe, and control sessions hosted by `tau serve`. Node applications can usually use the typed [Node SDK](node-sdk.md) instead.
3
+ This is the protocol that clients use to control sessions hosted by `tau serve`. Node applications can use the [SDK](sdk.md) instead. This page explains the model and lists the methods. For exact field types, read `@markusylisiurunen/tau/sdk` or `src/protocol/session_protocol.ts` in the [source](https://github.com/markusylisiurunen/tau).
4
4
 
5
- The protocol is based on requests and responses, plus server messages for session state, pending input, subagent activity, short-lived feedback, and client tool calls. It does not depend on a particular transport; Tau serves it over WebSocket. The complete method surface is in the [session protocol method reference](session-protocol-methods.md).
5
+ ## Messages
6
6
 
7
- ## Connect over WebSocket
8
-
9
- `tau serve` uses one UTF-8 JSON object per text WebSocket message. Binary messages are not supported. Authentication, TLS, listener setup, SSH tunneling, and host lifetime belong to [remote sessions](remote-sessions.md).
10
-
11
- The server exposes one host. Starting it does not create or select a session. A client lists, creates, or observes sessions explicitly.
12
-
13
- The client, host, and execution environment are separate, even when they share a process or filesystem. Session paths and commands are on the execution environment. Saving, credentials, model calls, and protocol handling are on the host. Client tools and local UI are on the connected client. See [ownership and scope](ownership-and-scope.md) before passing paths or credentials across this boundary.
14
-
15
- ## Connect and initialize
16
-
17
- The server sends `ready` as its first message:
7
+ Each WebSocket text message is one JSON object. Authentication and deployment are in [remote sessions](remote-sessions.md). The server speaks first, and the versions must match exactly:
18
8
 
19
9
  ```json
20
- {
21
- "version": 19,
22
- "type": "ready",
23
- "methods": ["initialize", "session.create", "session.list"]
24
- }
10
+ { "version": 19, "type": "ready", "methods": ["initialize", "session.create"] }
25
11
  ```
26
12
 
27
- The real `methods` array lists every supported method; the example above is shortened. Versions must match exactly and are not negotiated. If client and host disagree on `version`, use matching Tau releases.
28
-
29
- After `ready`, send `initialize` with non-empty client metadata:
13
+ Use the `version` the server sends. Then send `initialize`, optionally advertising client tools:
30
14
 
31
15
  ```json
32
16
  {
@@ -34,145 +18,56 @@ After `ready`, send `initialize` with non-empty client metadata:
34
18
  "type": "request",
35
19
  "id": "init-1",
36
20
  "method": "initialize",
37
- "params": {
38
- "client": { "name": "acme-editor", "version": "1.4.0" }
39
- }
40
- }
41
- ```
42
-
43
- A successful result returns `protocolVersion`, the full `methods` array, and `alreadyInitialized`. Calling `initialize` again is allowed and returns `alreadyInitialized: true`. It does not act on any session, but clients should complete it before other requests.
44
-
45
- A client can offer its own tools in `client.tools` when initializing. Calls to those tools are then sent to it over this connection. [Client tools](client-tools.md) covers tool behavior, permissions, and command helpers; this page covers only the wire messages a raw protocol client needs.
46
-
47
- ## Send requests and match responses
48
-
49
- Every request has the same envelope:
50
-
51
- ```json
52
- {
53
- "version": 19,
54
- "type": "request",
55
- "id": "req-42",
56
- "method": "session.snapshot",
57
- "params": { "sessionId": "0195d6e4-4cf9-7f44-a2d8-f8f7f49ee9d3" }
58
- }
59
- ```
60
-
61
- `id` is a non-empty string chosen by the client, unique among its open requests on the connection. `params` is always required, even if empty, as in `{}` for `session.list`. The host validates required fields, types, discriminators, method names, and the exact protocol version. Unknown fields are accepted and removed, except in system messages and their metadata, where they are rejected.
62
-
63
- Successful responses echo the request id:
64
-
65
- ```json
66
- {
67
- "version": 19,
68
- "type": "response",
69
- "id": "req-42",
70
- "ok": true,
71
- "result": { "sessionId": "..." }
21
+ "params": { "client": { "name": "acme-editor", "version": "1.4.0" } }
72
22
  }
73
23
  ```
74
24
 
75
- A request can remain open while the host emits state messages or handles later requests. Route responses by `id`, never by arrival order. Route streamed messages by `sessionId`.
76
-
77
- ## Observe before consuming session state
78
-
79
- `session.create` creates a session but does not observe it. `session.observe` starts observing on this connection and returns three complete starting states together:
25
+ Responses echo the request ID. A request can stay open while other messages arrive, so route responses by `id` and streamed messages by `sessionId`.
80
26
 
81
27
  ```json
82
- {
83
- "snapshot": { "sessionId": "...", "revision": 8 },
84
- "pendingUserMessages": { "revision": 3, "messages": [] },
85
- "subagentActivities": { "revision": 5, "agents": {} }
86
- }
28
+ { "version": 19, "type": "response", "id": "req-42", "ok": true, "result": {} }
29
+ { "version": 19, "type": "response", "id": "req-42", "ok": false, "error": { "code": "busy", "message": "..." } }
87
30
  ```
88
31
 
89
- Install all three before processing later messages for that session. The host holds back updates while preparing the response, and afterward sends only updates newer than the returned revisions.
90
-
91
- Observing controls which updates you receive; it does not make you the owner. `session.unobserve` stops this connection's updates without deleting the session or interrupting work. Several connections can observe one session, and each can change it. Client tool names must be unique among observing clients.
92
-
93
- ## Keep a session loaded without clients
94
-
95
- After the last client stops observing, the host normally unloads an idle session from memory and keeps it saved. Unloading removes the session's subagents. To keep an unattached session and its idle subagents available, set a retention period with `session.setRetention`. A client that observes the session during that period gets the same live session.
96
-
97
- A session stays loaded while a client observes it, while its retention period lasts, or while work is running. Running work includes turns, maintenance such as compaction, reloads, persona changes, prompt resolution, path autocomplete, `session.exec` commands, `session.sample` calls, ephemeral context creation and submissions, background jobs, and running subagents. Idle subagents do not count as running work. When retention expires or is cleared, only that reason goes away: clients stay attached and work keeps running. The host unloads the session once no reason remains.
98
-
99
- Retention exists only in host memory. It ends when the host shuts down, and a session recovered after a restart has no retention and no subagents.
32
+ Error codes are `parse_error`, `invalid_request`, `method_not_found`, `invalid_params`, `not_found`, `busy`, `cancelled`, and `internal_error`. Branch on the code, never on the message.
100
33
 
101
- Before you delete files that a session uses, make sure the host has unloaded the session:
102
-
103
- 1. Clear retention with `session.setRetention` and `durationMs: null`.
104
- 2. Stop observing with `session.unobserve`, or close the connection.
105
- 3. Call `session.collect`.
106
- 4. If it returns `disposed: true`, the session is unloaded and its execution environment has been released. If it returns `disposed: false`, keep the files and retry later. If the request fails, keep the files and retry later. A failed save can succeed on retry, but after a failed disposal no retry reports `disposed: true` until the host restarts.
107
-
108
- `session.collect` never loads a session, so you can repeat these steps safely. It reports only the state at that moment. Any client can still observe the saved session and load it again, so agree between your clients on when a session is finished.
109
-
110
- See the [method reference](session-protocol-methods.md#keep-sessions-loaded-and-unload-them) for exact parameters and results.
111
-
112
- ## Treat the snapshot as the source of truth
113
-
114
- `SessionProtocolSnapshot` is the saved, recoverable state of one session. Its main fields are:
115
-
116
- | Field | Meaning |
117
- | --- | --- |
118
- | `sessionId`, `attributes`, `createdAt` | Identity and immutable creation metadata. |
119
- | `revision` | Monotonic protocol snapshot revision. |
120
- | `lifecycle` | `idle` or `running`. |
121
- | `agentState` | Independent agent revision, model context key, and optional usage checkpoint. |
122
- | `settings`, `costTotal` | Persona, reasoning, and auto-compaction settings, and accumulated session cost. |
123
- | `bootstrap`, `catalog` | Selected model and prompt metadata plus available personas, prompt metadata, skills, MCP availability, and speech vocabulary. |
124
- | `executionEnvironment` | The environment kind, identity, `cwd`, and home used for agent-visible work. |
125
- | `messages`, `turns` | Messages sent to the model, and a saved record for each accepted turn. |
126
- | `timeline` | Ordered active transcript placement. |
127
- | `tools`, `operations`, `agents` | Changing state that timeline items or client views refer to. |
128
- | `facets` | Versioned client-facing metadata. Unknown facet kinds and versions should be ignored. |
129
-
130
- Both auto-compaction fields in `settings` are required:
131
-
132
- - `autoCompactThresholdTokens` is the configured value: a safe integer of at least 50,000, or `null` to use the default threshold.
133
- - `effectiveAutoCompactThresholdTokens` is the integer threshold clients should display. It resolves the session override, then any host default (such as a Telegram bot's threshold), then the persona default, then the model's context window minus 16,384 tokens. It is capped at that model-based limit.
134
-
135
- `bootstrap.model.contextWindow` is the full model window, regardless of the compaction threshold.
136
-
137
- `catalog.mcp` says whether the session can use MCP. A session on a local execution environment lists its enabled servers by name, and a session on a remote execution environment has none:
34
+ ## Session state
138
35
 
139
36
  ```ts
140
- catalog.mcp:
141
- | { status: "available"; servers: string[] }
142
- | { status: "unavailable"; reason: "remote-execution" };
37
+ // session.create
38
+ params: {
39
+ executionEnvironment:
40
+ | { kind: "local"; cwd: string; env?: Record<string, string> }
41
+ | { kind: "fly-sprite"; spriteName: string; cwd: string };
42
+ attributes: Record<string, string>; // required, can be empty
43
+ personaId?: string;
44
+ reasoning?: Reasoning;
45
+ autoCompactThresholdTokens?: number | null;
46
+ }
47
+ result: { sessionId: string }
143
48
  ```
144
49
 
145
- A listed server may not be connected yet, because servers connect on first use. Connection settings and credentials are never included. The host sets this field when it loads the session, and it stays the same until the host loads the session again.
50
+ `session.create` does not observe a session. `session.observe` starts updates on this connection and returns three starting states: `snapshot`, `pendingUserMessages`, and `subagentActivities`. Install all three before processing later messages. Several connections can observe one session, and each can change it.
146
51
 
147
- `catalog.speechVocabulary` holds the session's merged [`speech.vocabulary`](config-reference.md#speech) terms. The list has at most 100 terms and at most 10,000 Unicode characters in total. Each term is trimmed and non-empty, has at most 100 Unicode characters, and contains no angle brackets or line breaks. Clients that transcribe speech use these terms for this session. The host resolves them again on load, reload, and persona changes.
52
+ The **snapshot** is the saved state of a session. Important fields:
148
53
 
149
- `bootstrap.prompt.subagentSystemPrompt` is present when subagents can be started. It holds the base prompt, and Tau adds each native subagent's role section when it starts that subagent. Each catalog persona has a `subagentLaunchModels` allowlist. Subagent records have task titles and IDs; there are no worker types. Each record in `agents` also has `parentId`, the ID of the agent that started it, and `depth`, which is 1 or 2. A subagent of the main agent has depth 1, and its `parentId` is the session ID.
54
+ - `revision`, `lifecycle` (`idle` or `running`), `settings`, `costTotal`
55
+ - `bootstrap` and `catalog`: the selected model and prompt, and available personas, prompts, skills, and MCP servers
56
+ - `executionEnvironment`: kind, identity, `cwd`, and home
57
+ - `messages`: what the model sees
58
+ - `timeline`: what to render, in order, referencing messages, `tools`, and `operations`
59
+ - `turns`: a record for each accepted turn, keyed by `userHistoryEntryId`
60
+ - `agents`: subagents
150
61
 
151
- Render active transcript order from `timeline.items`, not by sorting or filtering `messages`. A timeline item either contains a notice or references a message, tool, or operation in the corresponding snapshot collection. Some model-visible messages intentionally have no timeline item.
62
+ Render from `timeline.items`, because some model-visible messages have no timeline item. User text is stored raw, so remove Tau metadata and leading `<system>...</system>` blocks before showing it. Use `turns` to find out what happened to a request, and do not infer outcomes from notices or message counts.
152
63
 
153
- The timeline has an `epoch`, a per-epoch sequence high-water mark, and ordered items. Successful compaction replaces the active recoverable timeline and advances the epoch. Rewind stays in the same epoch, removes later items, and preserves the sequence high-water mark so sequence numbers are not reused.
154
-
155
- Assistant messages preserve optional `providerThinkingLevel` strings for provider request reconstruction and prompt-cache reuse after recovery. Tool calls preserve optional `argumentsError` diagnostics; calls with this field are blocked before execution and return the diagnostic as an error result.
156
-
157
- User message text is stored raw. Before showing it, remove Tau metadata and any leading `<system>...</system>\n` blocks; the Node SDK exports helpers for this. Apply this only to user messages, never to assistant, tool-result, or system messages.
158
-
159
- The first system message is the persona's base prompt. Later system messages are history records, in order, with plain-text `content`, a `timestamp`, and required `metadata`: `{ type: "instruction" | "auto-compaction-continuation", version: 1 }`. The model sees them and they are recoverable. The TUI hides them, and searchable history includes them as system entries. Tau metadata is removed before sending to the provider. System messages cannot contain text-block arrays, named sections, or tool changes.
160
-
161
- These later system messages are added without a turn record. Adding one uses the `system-message` delta cause and needs no timeline item. The base prompt has no such metadata, and recovery restores later instructions without duplicating it. Clients cannot insert system messages, and a user's `<system>` text is never turned into one.
162
-
163
- Turn requests return a final outcome, and each accepted user turn is also recorded in `snapshot.turns`, keyed by `userHistoryEntryId`. Use this record to tell an unknown request apart from accepted work that is running or finished. Never infer outcomes from notice titles, message counts, or timing.
164
-
165
- User-facing behavior such as retry, compaction, rewind, and recovery is described in [sessions](sessions.md).
166
-
167
- ## Apply snapshot deltas in order
168
-
169
- Observed snapshot changes arrive as `session.delta`:
64
+ **Deltas** update the snapshot:
170
65
 
171
66
  ```json
172
67
  {
173
68
  "version": 19,
174
69
  "type": "session.delta",
175
- "sessionId": "0195d6e4-4cf9-7f44-a2d8-f8f7f49ee9d3",
70
+ "sessionId": "...",
176
71
  "fromRevision": 8,
177
72
  "toRevision": 9,
178
73
  "cause": { "type": "assistant-stream" },
@@ -190,124 +85,67 @@ Observed snapshot changes arrive as `session.delta`:
190
85
  }
191
86
  ```
192
87
 
193
- For a patch, `fromRevision` must equal your current snapshot revision, and `toRevision` becomes the new one. Apply all `changes` in order, as one unit. Changes can set scalar state, append or replace messages, append streamed content, update the timeline, or set and remove keyed tools, operations, agents, turns, and facets.
194
-
195
- `snapshot.reset` carries a complete new snapshot. Its cause is `compaction`, `rewind`, or `resync`, and compaction and rewind include the timeline data needed to validate the change. Use the cause; never guess at a destructive change from the content.
196
-
197
- If a patch has an unexpected `fromRevision`, or a change would leave invalid references or ordering, stop applying deltas and call `session.snapshot`. A delta whose `toRevision` you already have is stale; do not replay its effects in the UI.
198
-
199
- Node clients can use `applySessionProtocolDelta`, which validates session identity, revision continuity, timeline rules, references, and the resulting snapshot.
200
-
201
- ## Maintain the independent live-state channels
202
-
203
- Some live state is not part of the snapshot. Each of these channels has its own revision or delivery rules.
204
-
205
- ### Pending user messages
206
-
207
- `session.pendingUserMessages` is a full replacement:
208
-
209
- ```json
210
- {
211
- "version": 19,
212
- "type": "session.pendingUserMessages",
213
- "sessionId": "...",
214
- "state": {
215
- "revision": 4,
216
- "messages": [
217
- { "id": "pending-1", "mode": "steer", "text": "Use the smaller API." },
218
- { "id": "pending-2", "mode": "queue", "text": "Run tests afterward." }
219
- ]
220
- }
221
- }
222
- ```
223
-
224
- Replace the whole list, but only when the revision is newer. These revisions are separate from snapshot revisions. All observers share this state while the session is loaded on the host. It is empty after recovery.
88
+ `fromRevision` must match your revision. Apply all changes in order as one unit. A `snapshot.reset` carries a complete new snapshot, and its cause is `compaction`, `rewind`, or `resync`. If a revision is unexpected, stop applying and call `session.snapshot`.
225
89
 
226
- ### Subagent activities
90
+ Three other channels are separate from the snapshot, are not saved, and are empty after recovery:
227
91
 
228
- `session.subagentActivities` carries an independent `revision` and a list of changes. `agent.set` replaces that agent's complete current-run activity list; `agent.remove` deletes it. Apply changes only when the message revision is newer than the installed activity revision. The observe result provides the complete baseline.
92
+ - `session.pendingUserMessages` replaces the whole pending list when its own revision is newer.
93
+ - `session.subagentActivities` carries per-agent changes (`agent.set`, `agent.remove`) with its own revision.
94
+ - `session.ephemeral` carries live notices, which are not guaranteed to arrive and never need a resync. Show a `timeline.item` only if its epoch matches your snapshot.
229
95
 
230
- Activity lists contain limited assistant text, finished tool cards, and notices. They are live progress information, do not replace `snapshot.agents`, and are empty after recovery.
96
+ ## Concurrency
231
97
 
232
- ### Ephemeral events
98
+ One main-session turn runs at a time, and `session.submit` and `session.retry` return `busy` on conflict. `session.queue` waits for idle, and `session.steer` joins the running turn. Session changes run one at a time across all clients. `session.exec`, `session.sample`, and ephemeral threads run alongside everything else.
233
99
 
234
- `session.ephemeral` carries live events that are not guaranteed and have no revision:
100
+ ## Client tools
235
101
 
236
- - `feedback.notice` is short-lived footer feedback.
237
- - `ephemeral-agent.thread-update` reports progress of an ephemeral context and thread.
238
- - `timeline.item` is a notice that is not saved, with a timeline epoch and sequence number.
102
+ A client that advertised a tool receives `session.clientTool.call`. Answer with `session.clientTool.ack` before `ackDeadlineMs`, and start work only after it returns `{ accepted: true }`. Then send one `session.clientTool.result`. If `session.clientTool.cancel` arrives, stop and send no result.
239
103
 
240
- Show a `timeline.item` only if its epoch matches your snapshot. After compaction, drop items from the old epoch; after rewind, drop items past the rewind point. Missing ephemeral events never require a resync.
104
+ ## Keeping a session loaded
241
105
 
242
- ## Delegate client tools
106
+ A host keeps a session loaded while a client observes it, retention is active, or work is running. `session.setRetention` keeps an unattached session and its idle subagents available for a period. Retention exists only in memory and ends when the host shuts down.
243
107
 
244
- An initialized client that advertised a tool can receive:
108
+ Before deleting files that a session uses:
245
109
 
246
- ```json
247
- {
248
- "version": 19,
249
- "type": "session.clientTool.call",
250
- "sessionId": "...",
251
- "agentId": "main",
252
- "callId": "call-1",
253
- "toolName": "local_picker",
254
- "arguments": {},
255
- "ackDeadlineMs": 2000,
256
- "executionDeadlineMs": 60000
257
- }
258
- ```
110
+ 1. Clear retention with `durationMs: null`, and unobserve.
111
+ 2. Call `session.collect`.
112
+ 3. Delete the files only if it returns `disposed: true`. Otherwise keep them and retry later.
259
113
 
260
- `executionDeadlineMs` is a positive duration in milliseconds, or `null` when the advertised tool has no execution deadline. Omitting `executionTimeoutMs` from the tool definition uses 60 seconds; setting it to `null` disables only the execution deadline. Acknowledgement deadlines and cancellation on interruption or client detach still apply.
114
+ ## Methods
261
115
 
262
- Acknowledge promptly with `session.clientTool.ack`, optionally with a partial presentation for the running tool card. Start work only after the acknowledgement returns `{ accepted: true }`. Then send exactly one `session.clientTool.result` with `{ ok: true, content }` or `{ ok: false, error }`, optionally with a separate presentation for the finished card. `content` is an ordered array of text and image blocks. Both presentations may contain `subject`, `subjectWrap`, `details`, and `metadata`. The host sets the action and operation and fills in omitted fields. Fields you set are kept unchanged once they pass validation, while defaults are truncated the way Tau truncates its own cards. An empty `details` or `metadata` array hides that default.
116
+ Every request has `params`, even if empty. All `session.*` methods take `sessionId`, except `session.create` and `session.list`.
263
117
 
264
- A successful result is rejected until the acknowledgement has completed. If preparation fails, send an error result before acknowledging; the host records a preparation failure and the tool never runs. If no result arrives, because of a timeout, cancellation, detach, or other failure, the host shows a complete default card. The result method returns `{ accepted: boolean }`; `false` means the result does not fit the call's current state or the call no longer expects it.
265
-
266
- `session.clientTool.cancel` names the session and call, with reason `aborted`, `timeout`, `client-detached`, or `host-failed`. Stop local work and do not send a result. The SDK handles all of this for you. Permissions and execution-environment access for client tools are covered in [client tools](client-tools.md).
267
-
268
- ## Handle errors and terminal transport failure
269
-
270
- Error responses use `ok: false`:
271
-
272
- ```json
273
- {
274
- "version": 19,
275
- "type": "response",
276
- "id": "req-42",
277
- "ok": false,
278
- "error": {
279
- "code": "busy",
280
- "message": "a session turn is already running"
281
- }
282
- }
283
- ```
284
-
285
- The supported codes are:
286
-
287
- | Code | Meaning |
118
+ | Method | Purpose |
288
119
  | --- | --- |
289
- | `parse_error` | The JSON payload could not be parsed. |
290
- | `invalid_request` | The envelope, version, type, id, or requested operation is invalid. |
291
- | `method_not_found` | The method is unsupported. |
292
- | `invalid_params` | Method parameters failed validation. |
293
- | `not_found` | The addressed session does not exist on this host, or `session.setRetention` set a period on a session that is not loaded. |
294
- | `busy` | Conflicting session work or a same-thread ephemeral submission is active. |
295
- | `cancelled` | Pending input, execution, or sampling was cancelled. |
296
- | `internal_error` | The host could not complete the operation. |
297
-
298
- When the request ID cannot be read, the error response uses `id: null`. The error `message` and optional `data` are for diagnostics. Branch on `code`, never on message text.
299
-
300
- A WebSocket close, a malformed server message, an unsupported version, or another fatal transport failure rejects all open requests. Stop sending, cancel running client tools, and reconnect or create a new transport on purpose. A WebSocket disconnect only detaches from the long-running host.
301
-
302
- ## Coordinate concurrent work
303
-
304
- The server accepts new requests before earlier ones finish, so responses and streamed messages can interleave.
305
-
306
- - Only one main-session turn runs at a time. `session.submit` and `session.retry` return `busy` on conflict.
307
- - `session.queue` waits until the session is idle. `session.steer` joins the running turn at its next safe point. Each request gets its own response when done.
308
- - Session changes run one at a time, in arrival order across all clients. Changes that replace the context can interrupt running work and reject pending input. `session.rewind` instead requires an idle session with no pending input.
309
- - `session.setReasoning` and `session.setAutoCompactThreshold` wait their turn but do not interrupt the running turn. New settings apply from the next logical turn. The running turn and its steering continuations keep their original settings.
310
- - `session.exec` and `session.sample` run alongside everything else: turns, other changes, each other, and ephemeral agents. Clients must coordinate their own use of the workspace.
311
- - Ephemeral contexts are not part of that one-at-a-time ordering. Two submissions to the same ephemeral thread conflict, while different threads can run at once.
312
-
313
- A success response may arrive before or after the deltas the request caused. Keep state from the observed streams, match completion by request ID, and call `session.snapshot` when unsure whether you missed something.
120
+ | `initialize` | Identify the client and advertise client tools. |
121
+ | `session.create` | Create a session in an execution environment. |
122
+ | `session.list` | List sessions on this host. |
123
+ | `session.observe` | Start updates and return starting states. |
124
+ | `session.unobserve` | Stop updates without touching the session. |
125
+ | `session.setRetention` | Set or clear the retention period. |
126
+ | `session.collect` | Unload the session if nothing holds it, and report `disposed`. |
127
+ | `session.record` | Append user text without running a turn. |
128
+ | `session.submit` | Append user text and run a turn on an idle session. |
129
+ | `session.queue` | Run a turn now, or when the session is idle. |
130
+ | `session.steer` | Add input to the running turn. |
131
+ | `session.cancelPendingMessages` | Cancel queued and steering input. |
132
+ | `session.retry` | Run a turn from current history. |
133
+ | `session.interrupt` | Stop turns, commands, samples, and maintenance. |
134
+ | `session.exec` | Run a command in the execution environment, outside the conversation. |
135
+ | `session.cancelExec` | Cancel one running command. |
136
+ | `session.sample` | Run a standalone model call with supplied context. |
137
+ | `session.snapshot` | Return the current snapshot. |
138
+ | `session.setAutoCompactThreshold` | Set the compaction threshold from the next turn. |
139
+ | `session.setReasoning` | Set reasoning from the next turn. |
140
+ | `session.setPersona` | Apply a persona and optional settings. |
141
+ | `session.resolvePrompt` | Load a prompt body. |
142
+ | `session.autocompletePaths` | Suggest paths from the execution environment. |
143
+ | `session.reload` | Reload configuration and content. |
144
+ | `session.compact` | Replace the model's context with a summary. |
145
+ | `session.rewind` | Remove a user message and everything after it. |
146
+ | `session.interruptSubagent` | Interrupt one subagent's run. |
147
+ | `session.ephemeral.create` | Create an unsaved agent context. |
148
+ | `session.ephemeral.submit` | Run or continue an ephemeral thread. |
149
+ | `session.ephemeral.close` | Close a context and its threads. |
150
+ | `session.clientTool.ack` | Acknowledge a client tool call. |
151
+ | `session.clientTool.result` | Complete a client tool call. |