@markusylisiurunen/tau 0.3.102 → 0.3.104
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/code_mode/runtime.d.ts +6 -0
- package/dist/code_mode/runtime.js +2 -0
- package/dist/code_mode/runtime.js.map +1 -1
- package/dist/core/code_mode/sdk.js +4 -0
- package/dist/core/code_mode/sdk.js.map +1 -1
- package/dist/core/code_mode/web.js +5 -5
- package/dist/core/code_mode/web.js.map +1 -1
- package/dist/core/history/migrations.js +40 -0
- 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/code_mode/sandbox_runner.mjs +19 -2
- package/dist/core/static/tau_docs/client-tools.md +46 -385
- package/dist/core/static/tau_docs/code-mode.md +114 -41
- 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 -46
- package/dist/core/static/tau_docs/instructions-and-skills.md +81 -0
- package/dist/core/static/tau_docs/manifest.json +15 -21
- 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 -192
- 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 -282
- package/dist/core/telegram/adapter.js +4 -4
- package/dist/core/telegram/adapter.js.map +1 -1
- package/dist/core/telegram/runtime.js +3 -2
- package/dist/core/telegram/runtime.js.map +1 -1
- package/dist/core/tools/code.js +13 -12
- package/dist/core/tools/code.js.map +1 -1
- package/dist/core/tools/code_jobs.js.map +1 -1
- package/dist/core/tools/code_mode.js +4 -0
- package/dist/core/tools/code_mode.js.map +1 -1
- package/dist/core/tools/code_preloads.js +94 -0
- package/dist/core/tools/code_preloads.js.map +1 -0
- package/dist/core/version.js +1 -1
- package/dist/history/worker/index.js +16 -22
- package/dist/history/worker/index.js.map +1 -1
- 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/tui/session_chat_controller.js +21 -31
- package/dist/tui/session_chat_controller.js.map +1 -1
- package/dist/tui/ui/app_intro.js +45 -12
- package/dist/tui/ui/app_intro.js.map +1 -1
- package/package.json +4 -3
- package/dist/core/static/tau_docs/config-reference.md +0 -367
- 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-commands.md +0 -55
- package/dist/core/static/tau_docs/telegram-projects.md +0 -197
|
@@ -1,32 +1,16 @@
|
|
|
1
1
|
# Session protocol
|
|
2
2
|
|
|
3
|
-
|
|
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
|
-
|
|
5
|
+
## Messages
|
|
6
6
|
|
|
7
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
141
|
-
|
|
142
|
-
|
|
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
|
-
|
|
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
|
-
|
|
52
|
+
The **snapshot** is the saved state of a session. Important fields:
|
|
148
53
|
|
|
149
|
-
`
|
|
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
|
|
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
|
-
|
|
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": "
|
|
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
|
-
|
|
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
|
-
|
|
90
|
+
Three other channels are separate from the snapshot, are not saved, and are empty after recovery:
|
|
227
91
|
|
|
228
|
-
`session.
|
|
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
|
-
|
|
96
|
+
## Concurrency
|
|
231
97
|
|
|
232
|
-
|
|
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
|
-
|
|
100
|
+
## Client tools
|
|
235
101
|
|
|
236
|
-
|
|
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
|
-
|
|
104
|
+
## Keeping a session loaded
|
|
241
105
|
|
|
242
|
-
|
|
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
|
-
|
|
108
|
+
Before deleting files that a session uses:
|
|
245
109
|
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
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
|
-
|
|
114
|
+
## Methods
|
|
261
115
|
|
|
262
|
-
|
|
116
|
+
Every request has `params`, even if empty. All `session.*` methods take `sessionId`, except `session.create` and `session.list`.
|
|
263
117
|
|
|
264
|
-
|
|
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
|
-
| `
|
|
290
|
-
| `
|
|
291
|
-
| `
|
|
292
|
-
| `
|
|
293
|
-
| `
|
|
294
|
-
| `
|
|
295
|
-
| `
|
|
296
|
-
| `
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
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. |
|