@bastani/atomic 0.9.19-alpha.5 → 0.9.19-alpha.7

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 (209) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/README.md +2 -2
  3. package/dist/builtin/intercom/CHANGELOG.md +6 -0
  4. package/dist/builtin/intercom/broker/client.ts +19 -1
  5. package/dist/builtin/intercom/index.bundle.mjs +8 -1
  6. package/dist/builtin/intercom/package.json +1 -1
  7. package/dist/builtin/mcp/package.json +1 -1
  8. package/dist/builtin/subagents/CHANGELOG.md +6 -0
  9. package/dist/builtin/subagents/README.md +3 -1
  10. package/dist/builtin/subagents/agents/codebase-online-researcher.md +7 -7
  11. package/dist/builtin/subagents/package.json +1 -1
  12. package/dist/builtin/subagents/skills/subagent/SKILL.md +3 -1
  13. package/dist/builtin/subagents/src/extension/index.bundle.mjs +2 -1
  14. package/dist/builtin/web-access/CHANGELOG.md +13 -0
  15. package/dist/builtin/web-access/README.md +31 -24
  16. package/dist/builtin/web-access/index.bundle.mjs +16121 -80
  17. package/dist/builtin/web-access/package.json +2 -1
  18. package/dist/builtin/workflows/CHANGELOG.md +15 -0
  19. package/dist/builtin/workflows/README.md +1 -1
  20. package/dist/builtin/workflows/builtin/adversarial-verification.js +2 -2
  21. package/dist/builtin/workflows/builtin/{chunk-vhmnzdj9.js → chunk-1jth021m.js} +1 -1
  22. package/dist/builtin/workflows/builtin/{chunk-p8jjwfg6.js → chunk-2377r57g.js} +4 -2
  23. package/dist/builtin/workflows/builtin/{chunk-hbnwv56f.js → chunk-31j2gs7h.js} +2 -2
  24. package/dist/builtin/workflows/builtin/{chunk-n8zysf1t.js → chunk-ngkqkzej.js} +1 -1
  25. package/dist/builtin/workflows/builtin/{chunk-1nbq96fh.js → chunk-nkrafh9s.js} +1 -1
  26. package/dist/builtin/workflows/builtin/{chunk-1kx4aggw.js → chunk-wf741bv3.js} +2 -2
  27. package/dist/builtin/workflows/builtin/{chunk-t6x2d78s.js → chunk-z29qbehr.js} +1 -1
  28. package/dist/builtin/workflows/builtin/generate-and-filter.js +2 -2
  29. package/dist/builtin/workflows/builtin/goal.js +3 -3
  30. package/dist/builtin/workflows/builtin/index.js +7 -7
  31. package/dist/builtin/workflows/builtin/ralph.js +3 -3
  32. package/dist/builtin/workflows/builtin/tournament.js +2 -2
  33. package/dist/builtin/workflows/package.json +1 -1
  34. package/dist/builtin/workflows/src/extension/index.bundle.mjs +339 -31
  35. package/dist/builtin/workflows/src/index.js +67 -19
  36. package/dist/builtin/workflows/src/shared/authoring-contract-stage.d.ts +2 -0
  37. package/dist/core/agent-session-tool-registry.d.ts.map +1 -1
  38. package/dist/core/agent-session-tool-registry.js +10 -0
  39. package/dist/core/agent-session-tool-registry.js.map +1 -1
  40. package/dist/core/bash-executor.js.map +1 -1
  41. package/dist/core/tools/bash.d.ts +1 -1
  42. package/dist/core/tools/bash.d.ts.map +1 -1
  43. package/dist/core/tools/bash.js +3 -2
  44. package/dist/core/tools/bash.js.map +1 -1
  45. package/dist/core/tools/edit.d.ts +3 -0
  46. package/dist/core/tools/edit.d.ts.map +1 -1
  47. package/dist/core/tools/edit.js +91 -12
  48. package/dist/core/tools/edit.js.map +1 -1
  49. package/dist/core/tools/file-mutation-coordinator.d.ts +255 -0
  50. package/dist/core/tools/file-mutation-coordinator.d.ts.map +1 -0
  51. package/dist/core/tools/file-mutation-coordinator.js +300 -0
  52. package/dist/core/tools/file-mutation-coordinator.js.map +1 -0
  53. package/dist/core/tools/file-mutation-queue.d.ts +14 -1
  54. package/dist/core/tools/file-mutation-queue.d.ts.map +1 -1
  55. package/dist/core/tools/file-mutation-queue.js +15 -3
  56. package/dist/core/tools/file-mutation-queue.js.map +1 -1
  57. package/dist/core/tools/hashline.d.ts +9 -0
  58. package/dist/core/tools/hashline.d.ts.map +1 -1
  59. package/dist/core/tools/hashline.js +12 -1
  60. package/dist/core/tools/hashline.js.map +1 -1
  61. package/dist/core/tools/index.d.ts +9 -1
  62. package/dist/core/tools/index.d.ts.map +1 -1
  63. package/dist/core/tools/index.js +67 -12
  64. package/dist/core/tools/index.js.map +1 -1
  65. package/dist/core/tools/non-minting-snapshot-store.d.ts +49 -0
  66. package/dist/core/tools/non-minting-snapshot-store.d.ts.map +1 -0
  67. package/dist/core/tools/non-minting-snapshot-store.js +64 -0
  68. package/dist/core/tools/non-minting-snapshot-store.js.map +1 -0
  69. package/dist/core/tools/powershell.d.ts +2 -2
  70. package/dist/core/tools/powershell.d.ts.map +1 -1
  71. package/dist/core/tools/powershell.js +2 -5
  72. package/dist/core/tools/powershell.js.map +1 -1
  73. package/dist/core/tools/read-document-extract.js.map +1 -1
  74. package/dist/core/tools/render-utils.js.map +1 -1
  75. package/dist/core/tools/write.d.ts +30 -1
  76. package/dist/core/tools/write.d.ts.map +1 -1
  77. package/dist/core/tools/write.js +97 -8
  78. package/dist/core/tools/write.js.map +1 -1
  79. package/dist/index.d.ts +1 -1
  80. package/dist/index.d.ts.map +1 -1
  81. package/dist/index.js.map +1 -1
  82. package/dist/modes/interactive/components/bash-execution.js.map +1 -1
  83. package/dist/modes/interactive/components/task-live-transcript.d.ts +1 -1
  84. package/dist/modes/interactive/components/task-live-transcript.d.ts.map +1 -1
  85. package/dist/modes/interactive/components/task-live-transcript.js +19 -11
  86. package/dist/modes/interactive/components/task-live-transcript.js.map +1 -1
  87. package/dist/modes/interactive/interactive-mode-base.d.ts +1 -0
  88. package/dist/modes/interactive/interactive-mode-base.d.ts.map +1 -1
  89. package/dist/modes/interactive/interactive-mode-base.js +3 -1
  90. package/dist/modes/interactive/interactive-mode-base.js.map +1 -1
  91. package/dist/modes/interactive/interactive-mode-surface.d.ts +1 -1
  92. package/dist/modes/interactive/interactive-mode-surface.d.ts.map +1 -1
  93. package/dist/modes/interactive/interactive-mode-surface.js.map +1 -1
  94. package/dist/modes/interactive/interactive-render-chat.js +28 -4
  95. package/dist/modes/interactive/interactive-render-chat.js.map +1 -1
  96. package/dist/modes/interactive/interactive-startup.d.ts.map +1 -1
  97. package/dist/modes/interactive/interactive-startup.js +3 -0
  98. package/dist/modes/interactive/interactive-startup.js.map +1 -1
  99. package/dist/modes/interactive-engine/activity-watchdog.d.ts +2 -2
  100. package/dist/modes/interactive-engine/activity-watchdog.d.ts.map +1 -1
  101. package/dist/modes/interactive-engine/activity-watchdog.js.map +1 -1
  102. package/dist/modes/interactive-engine/engine-diagnostic-view.d.ts +3 -1
  103. package/dist/modes/interactive-engine/engine-diagnostic-view.d.ts.map +1 -1
  104. package/dist/modes/interactive-engine/engine-diagnostic-view.js +11 -0
  105. package/dist/modes/interactive-engine/engine-diagnostic-view.js.map +1 -1
  106. package/dist/modes/interactive-engine/isolated-runtime.js +2 -1
  107. package/dist/modes/interactive-engine/isolated-runtime.js.map +1 -1
  108. package/dist/modes/rpc/rpc-client-process.d.ts +2 -0
  109. package/dist/modes/rpc/rpc-client-process.d.ts.map +1 -1
  110. package/dist/modes/rpc/rpc-client-process.js +23 -1
  111. package/dist/modes/rpc/rpc-client-process.js.map +1 -1
  112. package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
  113. package/dist/modes/rpc/rpc-client.js +20 -3
  114. package/dist/modes/rpc/rpc-client.js.map +1 -1
  115. package/dist/utils/markit.d.ts +2 -0
  116. package/dist/utils/markit.d.ts.map +1 -1
  117. package/dist/utils/markit.js +65 -5
  118. package/dist/utils/markit.js.map +1 -1
  119. package/docs/background-tasks.md +15 -11
  120. package/docs/build.md +51 -0
  121. package/docs/changelog.mdx +8 -8
  122. package/docs/compaction/reference.md +267 -0
  123. package/docs/compaction.md +36 -219
  124. package/docs/computer-use.md +35 -0
  125. package/docs/containerization.md +9 -5
  126. package/docs/custom-provider/api-reference.md +145 -0
  127. package/docs/custom-provider/oauth.md +131 -0
  128. package/docs/custom-provider/override.md +34 -0
  129. package/docs/custom-provider/registration.md +163 -0
  130. package/docs/custom-provider/streaming.md +214 -0
  131. package/docs/custom-provider.md +43 -607
  132. package/docs/development.md +87 -0
  133. package/docs/docs.json +199 -76
  134. package/docs/environment-variables.md +1 -1
  135. package/docs/extensions/api-reference.md +1001 -0
  136. package/docs/extensions/authoring.md +676 -0
  137. package/docs/extensions/events.md +793 -0
  138. package/docs/extensions/examples.md +94 -0
  139. package/docs/extensions/ui.md +470 -0
  140. package/docs/extensions.md +270 -2768
  141. package/docs/getting-started/authentication.md +55 -0
  142. package/docs/getting-started/first-session.md +172 -0
  143. package/docs/getting-started/installation.md +154 -0
  144. package/docs/getting-started/project-instructions.md +43 -0
  145. package/docs/guides/configuration.md +65 -0
  146. package/docs/guides/intercom.md +24 -0
  147. package/docs/guides/non-interactive.md +33 -0
  148. package/docs/guides/subagents.md +24 -0
  149. package/docs/guides/workflows.md +27 -0
  150. package/docs/guides.md +41 -0
  151. package/docs/index.md +13 -45
  152. package/docs/intercom/operations.md +178 -0
  153. package/docs/intercom/reference.md +146 -0
  154. package/docs/intercom.md +54 -259
  155. package/docs/json.md +17 -0
  156. package/docs/llama-cpp.md +5 -0
  157. package/docs/models/artificial-analysis-index.md +89 -0
  158. package/docs/models/evals.md +2 -2
  159. package/docs/models/model-selection.md +3 -3
  160. package/docs/models/pareto-efficiency.md +2 -2
  161. package/docs/models/reference.md +601 -0
  162. package/docs/models.md +45 -550
  163. package/docs/packages/authoring.md +88 -0
  164. package/docs/packages/reference.md +43 -0
  165. package/docs/packages.md +28 -107
  166. package/docs/programmatic.md +29 -0
  167. package/docs/prompt-templates.md +11 -0
  168. package/docs/providers/reference.md +23 -0
  169. package/docs/providers.md +10 -15
  170. package/docs/quickstart.md +44 -238
  171. package/docs/reference/cli.md +252 -0
  172. package/docs/reference.md +52 -0
  173. package/docs/rpc/examples.md +64 -0
  174. package/docs/rpc/extension-ui.md +198 -0
  175. package/docs/rpc/protocol.md +1341 -0
  176. package/docs/rpc.md +109 -1346
  177. package/docs/sdk/reference.md +1090 -0
  178. package/docs/sdk.md +56 -1002
  179. package/docs/session-format.md +2 -0
  180. package/docs/sessions.md +6 -10
  181. package/docs/settings.md +6 -45
  182. package/docs/skills/authoring.md +95 -0
  183. package/docs/skills/reference.md +60 -0
  184. package/docs/skills.md +20 -122
  185. package/docs/subagents/authoring.md +37 -0
  186. package/docs/subagents/reference.md +60 -0
  187. package/docs/subagents.md +42 -96
  188. package/docs/terminal-setup.md +1 -1
  189. package/docs/themes/reference.md +176 -0
  190. package/docs/themes.md +21 -135
  191. package/docs/tmux.md +5 -0
  192. package/docs/tools/edit.md +5 -0
  193. package/docs/tools.md +31 -0
  194. package/docs/tui/reference.md +343 -0
  195. package/docs/tui.md +23 -286
  196. package/docs/usage.md +26 -209
  197. package/docs/web-access.md +40 -0
  198. package/docs/windows.md +2 -1
  199. package/docs/workflows/api-reference.md +11 -4
  200. package/docs/workflows/authoring.md +4 -2
  201. package/docs/workflows/builtins.md +2 -2
  202. package/docs/workflows/operations.md +11 -7
  203. package/docs/workflows/reliable-design.md +21 -3
  204. package/docs/workflows/verification.md +8 -0
  205. package/examples/extensions/gondolin/index.ts +116 -148
  206. package/examples/extensions/gondolin/package.json +1 -1
  207. package/examples/extensions/ssh.ts +56 -34
  208. package/npm-shrinkwrap.json +33 -33
  209. package/package.json +4 -4
@@ -0,0 +1,1341 @@
1
+ ---
2
+ title: RPC protocol
3
+ description: Every RPC command, event, type, and error contract.
4
+ ---
5
+
6
+ # RPC protocol
7
+
8
+ ## Commands
9
+
10
+ ### Prompting
11
+
12
+ #### prompt
13
+
14
+ Send a user prompt to the agent. The command response is emitted after the prompt is accepted, queued, or handled. Events continue streaming asynchronously after acceptance.
15
+
16
+ ```json
17
+ {"id": "req-1", "type": "prompt", "message": "Hello, world!"}
18
+ ```
19
+
20
+ With images:
21
+ ```json
22
+ {"type": "prompt", "message": "What's in this image?", "images": [{"type": "image", "data": "base64-encoded-data", "mimeType": "image/png"}]}
23
+ ```
24
+
25
+ **During streaming**: If the agent is already streaming, you must specify `streamingBehavior` to queue the message:
26
+
27
+ ```json
28
+ {"type": "prompt", "message": "New instruction", "streamingBehavior": "steer"}
29
+ ```
30
+
31
+ - `"steer"`: Queue the message while the agent is running. It is delivered after the current assistant turn finishes executing its tool calls, before the next LLM call.
32
+ - `"followUp"`: Wait until the agent finishes. Message is delivered only when agent stops.
33
+
34
+ If the agent is streaming and no `streamingBehavior` is specified, the command returns an error.
35
+
36
+ **Extension commands**: If the message is an extension command (e.g., `/mycommand`), it executes immediately even during streaming. Extension commands manage their own LLM interaction via `pi.sendMessage()`.
37
+
38
+ **Input expansion**: Skill commands (`/skill:name`) and prompt templates (`/template`) are expanded before sending/queueing.
39
+
40
+ Response:
41
+ ```json
42
+ {"id": "req-1", "type": "response", "command": "prompt", "success": true}
43
+ ```
44
+
45
+ `success: true` means the prompt was accepted, queued, or handled immediately. `success: false` means the prompt was rejected before acceptance. Failures after acceptance are reported through the normal event and message stream, not as a second `response` for the same request id.
46
+
47
+ The `images` field is optional. Each image uses `ImageContent` format: `{"type": "image", "data": "base64-encoded-data", "mimeType": "image/png"}`.
48
+
49
+ #### steer
50
+
51
+ Queue a steering message while the agent is running. It is delivered after the current assistant turn finishes executing its tool calls, before the next LLM call. Skill commands and prompt templates are expanded. Extension commands are not allowed (use `prompt` instead).
52
+
53
+ ```json
54
+ {"type": "steer", "message": "Stop and do this instead"}
55
+ ```
56
+
57
+ With images:
58
+ ```json
59
+ {"type": "steer", "message": "Look at this instead", "images": [{"type": "image", "data": "base64-encoded-data", "mimeType": "image/png"}]}
60
+ ```
61
+
62
+ The `images` field is optional. Each image uses `ImageContent` format (same as `prompt`).
63
+
64
+ Response:
65
+ ```json
66
+ {"type": "response", "command": "steer", "success": true}
67
+ ```
68
+
69
+ See [set_steering_mode](#set_steering_mode) for controlling how steering messages are processed.
70
+
71
+ #### follow_up
72
+
73
+ Queue a follow-up message to be processed after the agent finishes. Delivered only when agent has no more tool calls or steering messages. Skill commands and prompt templates are expanded. Extension commands are not allowed (use `prompt` instead).
74
+
75
+ ```json
76
+ {"type": "follow_up", "message": "After you're done, also do this"}
77
+ ```
78
+
79
+ With images:
80
+ ```json
81
+ {"type": "follow_up", "message": "Also check this image", "images": [{"type": "image", "data": "base64-encoded-data", "mimeType": "image/png"}]}
82
+ ```
83
+
84
+ The `images` field is optional. Each image uses `ImageContent` format (same as `prompt`).
85
+
86
+ Response:
87
+ ```json
88
+ {"type": "response", "command": "follow_up", "success": true}
89
+ ```
90
+
91
+ See [set_follow_up_mode](#set_follow_up_mode) for controlling how follow-up messages are processed.
92
+
93
+ #### abort
94
+
95
+ Abort the current operation and wait for the session to become idle before responding.
96
+
97
+ ```json
98
+ {"type": "abort"}
99
+ ```
100
+
101
+ Response:
102
+ ```json
103
+ {"type": "response", "command": "abort", "success": true}
104
+ ```
105
+
106
+ #### clear_queue
107
+
108
+ Remove queued steering and follow-up messages and return their text.
109
+
110
+ ```json
111
+ {"type": "clear_queue"}
112
+ ```
113
+
114
+ Response:
115
+ ```json
116
+ {
117
+ "type": "response",
118
+ "command": "clear_queue",
119
+ "success": true,
120
+ "data": {
121
+ "steering": ["Change direction"],
122
+ "followUp": ["Summarize when finished"]
123
+ }
124
+ }
125
+ ```
126
+
127
+ To implement interactive Esc behavior, send `clear_queue` before `abort`, then restore the returned text in the client editor. `abort` continues queued messages when they remain in the session.
128
+
129
+ #### new_session
130
+
131
+ Start a fresh session. Can be cancelled by a `session_before_switch` extension event handler.
132
+
133
+ ```json
134
+ {"type": "new_session"}
135
+ ```
136
+
137
+ With optional parent session tracking:
138
+ ```json
139
+ {"type": "new_session", "parentSession": "/path/to/parent-session.jsonl"}
140
+ ```
141
+
142
+ Response:
143
+ ```json
144
+ {"type": "response", "command": "new_session", "success": true, "data": {"cancelled": false}}
145
+ ```
146
+
147
+ If an extension cancelled:
148
+ ```json
149
+ {"type": "response", "command": "new_session", "success": true, "data": {"cancelled": true}}
150
+ ```
151
+
152
+ ### State
153
+
154
+ #### get_state
155
+
156
+ Get current session state.
157
+
158
+ ```json
159
+ {"type": "get_state"}
160
+ ```
161
+
162
+ Response:
163
+ ```json
164
+ {
165
+ "type": "response",
166
+ "command": "get_state",
167
+ "success": true,
168
+ "data": {
169
+ "model": {...},
170
+ "thinkingLevel": "medium",
171
+ "isStreaming": false,
172
+ "isCompacting": false,
173
+ "steeringMode": "all",
174
+ "followUpMode": "one-at-a-time",
175
+ "sessionFile": "/path/to/session.jsonl",
176
+ "sessionId": "abc123",
177
+ "sessionName": "my-feature-work",
178
+ "autoCompactionEnabled": true,
179
+ "messageCount": 5,
180
+ "pendingMessageCount": 0
181
+ }
182
+ }
183
+ ```
184
+
185
+ The `model` field is a full [Model](#model) object or `null`. Its `contextWindow` is the model's token budget. The `sessionName` field is the display name set via `set_session_name`, or omitted if not set.
186
+
187
+ #### get_messages
188
+
189
+ Get all messages in the conversation.
190
+
191
+ ```json
192
+ {"type": "get_messages"}
193
+ ```
194
+
195
+ Response:
196
+ ```json
197
+ {
198
+ "type": "response",
199
+ "command": "get_messages",
200
+ "success": true,
201
+ "data": {"messages": [...]}
202
+ }
203
+ ```
204
+
205
+ Messages are `AgentMessage` objects (see [Types](#types)).
206
+
207
+ ### Model
208
+
209
+ #### set_model
210
+
211
+ Switch to a specific model. Omit `persist` (or set it false) to change only the current session. Set `"persist": true` to also save `defaultProvider`, `defaultModel`, and the effective thinking level in settings, matching an interactive `/model` selection.
212
+
213
+ ```json
214
+ {"type": "set_model", "provider": "anthropic", "modelId": "claude-sonnet-4-20250514"}
215
+ ```
216
+
217
+ Persist as the startup default:
218
+ ```json
219
+ {"type": "set_model", "provider": "anthropic", "modelId": "claude-sonnet-4-20250514", "persist": true}
220
+ ```
221
+
222
+ Response contains the full [Model](/rpc/protocol#model) object:
223
+ ```json
224
+ {
225
+ "type": "response",
226
+ "command": "set_model",
227
+ "success": true,
228
+ "data": {...}
229
+ }
230
+ ```
231
+
232
+ #### cycle_model
233
+
234
+ Cycle to the next available model. Returns `null` when fewer than two authenticated models are available in the active scope or catalog. When an unsupported saved default is blocking prompts, a successful cycle that returns a different model clears that condition; a `null` or unchanged result does not. Set `"persist": true` to also write the cycled model as the startup default.
235
+
236
+ ```json
237
+ {"type": "cycle_model"}
238
+ ```
239
+
240
+ Response:
241
+ ```json
242
+ {
243
+ "type": "response",
244
+ "command": "cycle_model",
245
+ "success": true,
246
+ "data": {
247
+ "model": {...},
248
+ "thinkingLevel": "medium",
249
+ "isScoped": false
250
+ }
251
+ }
252
+ ```
253
+
254
+ The `model` field is a full [Model](#model) object.
255
+
256
+ #### get_available_models
257
+
258
+ List all configured models.
259
+
260
+ ```json
261
+ {"type": "get_available_models"}
262
+ ```
263
+
264
+ Response contains an array of full [Model](#model) objects:
265
+ ```json
266
+ {
267
+ "type": "response",
268
+ "command": "get_available_models",
269
+ "success": true,
270
+ "data": {
271
+ "models": [...]
272
+ }
273
+ }
274
+ ```
275
+
276
+ The subprocess protocol returns full `Model` objects. The exported TypeScript `RpcClient.getAvailableModels()` keeps its smaller backward-compatible `ModelInfo` shape (`provider`, `id`, `contextWindow`, `reasoning`) and adds optional `compat`. When present, `compat` exposes constrained-sampling capability claims including `supportsStrictTools`, `supportsStrictMode`, canonical `supportsOpenAIGrammarTools`, and Atomic's synchronized `supportsGrammarTools` alias. Treat absence as unknown/unsupported; do not infer enforcement from the provider name.
277
+
278
+ ```typescript
279
+ const models = await client.getAvailableModels();
280
+ const capabilities = models[0]?.compat;
281
+ if (capabilities?.supportsStrictTools) {
282
+ // The selected model advertises Anthropic/Bedrock strict-tool support.
283
+ }
284
+ ```
285
+
286
+ #### logout_provider
287
+
288
+ Remove a provider's stored credential in the authoritative agent process, refresh its available-model catalog, and return the remaining authentication status and new catalog. Environment variables and `models.json` authentication are reported but are not modified.
289
+
290
+ ```json
291
+ {"type": "logout_provider", "provider": "github-copilot"}
292
+ ```
293
+
294
+ Response:
295
+
296
+ ```json
297
+ {
298
+ "type": "response",
299
+ "command": "logout_provider",
300
+ "success": true,
301
+ "data": {
302
+ "provider": "github-copilot",
303
+ "authStatus": {"configured": false},
304
+ "models": [],
305
+ "scopedModels": []
306
+ }
307
+ }
308
+ ```
309
+
310
+ `models` preserves the refreshed catalog order. `scopedModels` is optional. If authentication remains through an environment variable, `authStatus.source` is `"environment"` and `authStatus.label` names the variable.
311
+
312
+
313
+ ### Thinking
314
+
315
+ #### set_thinking_level
316
+
317
+ Set the reasoning/thinking level for models that support it. Omit `persist` (or set it false) to change only the current session. Set `"persist": true` to also save `defaultThinkingLevel` and, when a model is active, its per-model override. Interactive `/thinking` choices request persistence automatically.
318
+
319
+ ```json
320
+ {"type": "set_thinking_level", "level": "high"}
321
+ ```
322
+
323
+ Persist as the startup default:
324
+ ```json
325
+ {"type": "set_thinking_level", "level": "high", "persist": true}
326
+ ```
327
+
328
+ Levels: `"off"`, `"minimal"`, `"low"`, `"medium"`, `"high"`, `"xhigh"`, `"max"`.
329
+
330
+ `xhigh` and `max` are available only when the active model's capability mapping supports them; unsupported levels are clamped by the session model controls.
331
+
332
+ Response may omit `data` for compatibility with older clients:
333
+ ```json
334
+ {"type": "response", "command": "set_thinking_level", "success": true}
335
+ ```
336
+
337
+ Current engines include the effective level after capability clamping and, when a model is active, the provider/model the engine persisted against:
338
+ ```json
339
+ {"type": "response", "command": "set_thinking_level", "success": true, "data": {"level": "high", "provider": "anthropic", "modelId": "claude-sonnet-4-20250514"}}
340
+ ```
341
+
342
+ Isolated interactive hosts must apply a persisted thinking default using that ACK target, not the host session model at callback time. A later `model_changed` event must not re-key the saved override. A later `thinking_level_changed` event must keep the host session's effective level even if an older ACK settles afterward. `RpcClient.setThinkingLevel(level)` stays one-argument `Promise<void>`; isolated persist reads the ACK through an internal client path.
343
+
344
+ #### cycle_thinking_level
345
+
346
+ Cycle through available thinking levels. Returns `null` data if model doesn't support thinking.
347
+
348
+ ```json
349
+ {"type": "cycle_thinking_level"}
350
+ ```
351
+
352
+ Response:
353
+ ```json
354
+ {
355
+ "type": "response",
356
+ "command": "cycle_thinking_level",
357
+ "success": true,
358
+ "data": {"level": "high"}
359
+ }
360
+ ```
361
+
362
+ #### get_available_thinking_levels
363
+
364
+ Return the thinking levels supported by the current model, in cycle order.
365
+
366
+ ```json
367
+ {"type": "get_available_thinking_levels"}
368
+ ```
369
+
370
+ Response:
371
+ ```json
372
+ {
373
+ "type": "response",
374
+ "command": "get_available_thinking_levels",
375
+ "success": true,
376
+ "data": {"levels": ["off", "low", "medium", "high"]}
377
+ }
378
+ ```
379
+
380
+ ### Queue Modes
381
+
382
+ #### set_steering_mode
383
+
384
+ Control how steering messages (from `steer`) are delivered.
385
+
386
+ ```json
387
+ {"type": "set_steering_mode", "mode": "one-at-a-time"}
388
+ ```
389
+
390
+ Modes:
391
+ - `"all"`: Deliver all steering messages after the current assistant turn finishes executing its tool calls
392
+ - `"one-at-a-time"`: Deliver one steering message per completed assistant turn (default)
393
+
394
+ Response:
395
+ ```json
396
+ {"type": "response", "command": "set_steering_mode", "success": true}
397
+ ```
398
+
399
+ #### set_follow_up_mode
400
+
401
+ Control how follow-up messages (from `follow_up`) are delivered.
402
+
403
+ ```json
404
+ {"type": "set_follow_up_mode", "mode": "one-at-a-time"}
405
+ ```
406
+
407
+ Modes:
408
+ - `"all"`: Deliver all follow-up messages when agent finishes
409
+ - `"one-at-a-time"`: Deliver one follow-up message per agent completion (default)
410
+
411
+ Response:
412
+ ```json
413
+ {"type": "response", "command": "set_follow_up_mode", "success": true}
414
+ ```
415
+
416
+ ### Compaction
417
+
418
+ #### compact
419
+
420
+ Run Atomic's verbatim line compactor. The selected session model receives the complete active numbered transcript except for exactly the newest `preserve_recent` context-visible messages and returns bare `start,end` deletion records; Atomic validates them and mechanically reconstructs retained lines with `(filtered N lines)` markers. The default tail is two messages, with no user-turn alignment. A value of zero sends the entire active transcript and persists `firstKeptEntryId: null`. The command appends a durable `compaction` entry with `details.strategy: "verbatim-lines"`.
421
+
422
+ ```json
423
+ {"type": "compact"}
424
+ ```
425
+
426
+ Response:
427
+ ```json
428
+ {
429
+ "type": "response",
430
+ "command": "compact",
431
+ "success": true,
432
+ "data": {
433
+ "compactedText": "[User]: fix the test\n(filtered 42 lines)\n[Assistant]: Fixed.",
434
+ "firstKeptEntryId": "m7",
435
+ "tokensBefore": 150000,
436
+ "promptVersion": 3,
437
+ "parameters": {
438
+ "compression_ratio": 0.5,
439
+ "preserve_recent": 2,
440
+ "query": "fix the test"
441
+ },
442
+ "rung": "planned",
443
+ "stats": {
444
+ "linesBefore": 812,
445
+ "linesDeleted": 417,
446
+ "linesKept": 395,
447
+ "rangeCount": 63,
448
+ "tokensBefore": 150000,
449
+ "tokensAfter": 72000,
450
+ "percentReduction": 52
451
+ },
452
+ "backupPath": "/path/to/session.jsonl.2026-06-06T00-00-00-000Z.compact.bak"
453
+ }
454
+ }
455
+ ```
456
+
457
+ `firstKeptEntryId` is a string when at least one ordinary message remains outside compaction and `null` when none does. RPC clients must accept both values.
458
+
459
+ #### set_auto_compaction
460
+
461
+ Enable or disable automatic compaction when context is nearly full.
462
+
463
+ ```json
464
+ {"type": "set_auto_compaction", "enabled": true}
465
+ ```
466
+
467
+ Response:
468
+ ```json
469
+ {"type": "response", "command": "set_auto_compaction", "success": true}
470
+ ```
471
+
472
+ ### Retry
473
+
474
+ #### set_auto_retry
475
+
476
+ Enable or disable automatic retry on transient errors (overloaded, rate limit, 5xx).
477
+
478
+ ```json
479
+ {"type": "set_auto_retry", "enabled": true}
480
+ ```
481
+
482
+ Response:
483
+ ```json
484
+ {"type": "response", "command": "set_auto_retry", "success": true}
485
+ ```
486
+
487
+ #### abort_retry
488
+
489
+ Abort an in-progress retry (cancel the delay and stop retrying).
490
+
491
+ ```json
492
+ {"type": "abort_retry"}
493
+ ```
494
+
495
+ Response:
496
+ ```json
497
+ {"type": "response", "command": "abort_retry", "success": true}
498
+ ```
499
+
500
+ ### Bash
501
+
502
+ #### bash
503
+
504
+ Execute a shell command and add output to conversation context.
505
+
506
+ ```json
507
+ {"type": "bash", "command": "ls -la"}
508
+ ```
509
+
510
+ Response:
511
+ ```json
512
+ {
513
+ "type": "response",
514
+ "command": "bash",
515
+ "success": true,
516
+ "data": {
517
+ "output": "total 48\ndrwxr-xr-x ...",
518
+ "exitCode": 0,
519
+ "cancelled": false,
520
+ "truncated": false
521
+ }
522
+ }
523
+ ```
524
+
525
+ While the command runs, Atomic emits ordered deltas correlated by the command `id`:
526
+
527
+ ```json
528
+ {"type":"bash_execution_update","id":"req-1","channel":"stdout","delta":"building...\n"}
529
+ {"type":"bash_execution_update","id":"req-1","channel":"stderr","delta":"warning\n"}
530
+ ```
531
+
532
+ `channel` is exactly `"stdout"` or `"stderr"`. Deltas preserve the order observed for that request; concurrent bash requests may interleave globally but never share IDs. Request ownership survives `new_session`, `switch_session`, `import_session`, fork, and clone while the command is running: later deltas still stream under the original ID, the replacement session is not contaminated, and exactly one ordinary `response` remains the terminal record for completion, cancellation, or error.
533
+
534
+ If output was truncated, includes `fullOutputPath`. Persisted bash output lives in the owner- and session-scoped temp tree (`<tmpdir>/atomic-<uid>/<session-id>/`), not at the temp root — see [Tools](/tools#persisted-tool-output) for the layout, permissions, size cap, and retention:
535
+ ```json
536
+ {
537
+ "type": "response",
538
+ "command": "bash",
539
+ "success": true,
540
+ "data": {
541
+ "output": "truncated output...",
542
+ "exitCode": 0,
543
+ "cancelled": false,
544
+ "truncated": true,
545
+ "fullOutputPath": "/tmp/atomic-501/019fdf86-cf98-7327-8a73-21365028f6ae/atomic-bash-abc123.log"
546
+ }
547
+ }
548
+ ```
549
+
550
+ `fullOutputPath` is `null` when the temp directory could not be created or the write was refused; treat it as absent rather than assuming a path exists.
551
+
552
+ **How bash results reach the LLM:**
553
+
554
+ The `bash` command executes immediately and returns a `BashResult`. Internally, a `BashExecutionMessage` is created and stored exactly once in the session where that request started, even if an RPC session replacement completes before the command. The message does NOT emit an event.
555
+
556
+ When the next `prompt` command is sent, all messages (including `BashExecutionMessage`) are transformed before being sent to the LLM. The `BashExecutionMessage` is converted to a `UserMessage` with this format:
557
+
558
+ ````
559
+ Ran `ls -la`
560
+ ```
561
+ total 48
562
+ drwxr-xr-x ...
563
+ ```
564
+ ````
565
+
566
+ This means:
567
+ 1. Bash output is included in the LLM context on the **next prompt**, not immediately
568
+ 2. Multiple bash commands can be executed before a prompt; all outputs will be included
569
+ 3. No event is emitted for the `BashExecutionMessage` itself
570
+
571
+ #### abort_bash
572
+
573
+ Abort running bash commands. Omit `requestId` to retain the legacy behavior of aborting every active RPC-owned bash request, including requests that began before a session replacement, or provide the target bash command's `id` to cancel only that request. Targeted and legacy cancellation remain isolated across concurrent IDs. Closing RPC cancels and drains remaining owned requests before shutdown.
574
+
575
+ ```json
576
+ {"id":"cancel-1","type":"abort_bash","requestId":"req-1"}
577
+ ```
578
+
579
+ Response:
580
+ ```json
581
+ {"id":"cancel-1","type":"response","command":"abort_bash","success":true}
582
+ ```
583
+
584
+ ### Session
585
+
586
+ #### get_session_stats
587
+
588
+ Get token usage, cost statistics, and current context window usage.
589
+
590
+ ```json
591
+ {"type": "get_session_stats"}
592
+ ```
593
+
594
+ Response:
595
+ ```json
596
+ {
597
+ "type": "response",
598
+ "command": "get_session_stats",
599
+ "success": true,
600
+ "data": {
601
+ "sessionFile": "/path/to/session.jsonl",
602
+ "sessionId": "abc123",
603
+ "userMessages": 5,
604
+ "assistantMessages": 5,
605
+ "toolCalls": 12,
606
+ "toolResults": 12,
607
+ "totalMessages": 22,
608
+ "tokens": {
609
+ "input": 50000,
610
+ "output": 10000,
611
+ "cacheRead": 40000,
612
+ "cacheWrite": 5000,
613
+ "total": 105000
614
+ },
615
+ "cost": 0.45,
616
+ "contextUsage": {
617
+ "tokens": 60000,
618
+ "contextWindow": 200000,
619
+ "percent": 30
620
+ }
621
+ }
622
+ }
623
+ ```
624
+
625
+ `tokens` contains assistant usage totals for the current session state. `contextUsage` contains the actual current context-window estimate used for compaction and footer display.
626
+
627
+ `contextUsage` is omitted when no model or context window is available. `contextUsage.tokens` and `contextUsage.percent` are `null` immediately after compaction until a fresh post-compaction assistant response provides valid usage data.
628
+
629
+ #### export_html
630
+
631
+ Export session to an HTML file.
632
+
633
+ ```json
634
+ {"type": "export_html"}
635
+ ```
636
+
637
+ With custom path:
638
+ ```json
639
+ {"type": "export_html", "outputPath": "/tmp/session.html"}
640
+ ```
641
+
642
+ Response:
643
+ ```json
644
+ {
645
+ "type": "response",
646
+ "command": "export_html",
647
+ "success": true,
648
+ "data": {"path": "/tmp/session.html"}
649
+ }
650
+ ```
651
+
652
+ #### switch_session
653
+
654
+ Load a different session file. Can be cancelled by a `session_before_switch` extension event handler.
655
+
656
+ ```json
657
+ {"type": "switch_session", "sessionPath": "/path/to/session.jsonl"}
658
+ ```
659
+
660
+ Response:
661
+ ```json
662
+ {"type": "response", "command": "switch_session", "success": true, "data": {"cancelled": false}}
663
+ ```
664
+
665
+ If an extension cancelled the switch:
666
+ ```json
667
+ {"type": "response", "command": "switch_session", "success": true, "data": {"cancelled": true}}
668
+ ```
669
+
670
+ #### fork
671
+
672
+ Create a new fork from a previous user message on the active branch. Can be cancelled by a `session_before_fork` extension event handler. Returns the text of the message being forked from.
673
+
674
+ ```json
675
+ {"type": "fork", "entryId": "abc123"}
676
+ ```
677
+
678
+ Response:
679
+ ```json
680
+ {
681
+ "type": "response",
682
+ "command": "fork",
683
+ "success": true,
684
+ "data": {"text": "The original prompt text...", "cancelled": false}
685
+ }
686
+ ```
687
+
688
+ If an extension cancelled the fork:
689
+ ```json
690
+ {
691
+ "type": "response",
692
+ "command": "fork",
693
+ "success": true,
694
+ "data": {"text": "The original prompt text...", "cancelled": true}
695
+ }
696
+ ```
697
+
698
+ #### clone
699
+
700
+ Duplicate the current active branch into a new session at the current position. Can be cancelled by a `session_before_fork` extension event handler.
701
+
702
+ ```json
703
+ {"type": "clone"}
704
+ ```
705
+
706
+ Response:
707
+ ```json
708
+ {
709
+ "type": "response",
710
+ "command": "clone",
711
+ "success": true,
712
+ "data": {"cancelled": false}
713
+ }
714
+ ```
715
+
716
+ If an extension cancelled the clone:
717
+ ```json
718
+ {
719
+ "type": "response",
720
+ "command": "clone",
721
+ "success": true,
722
+ "data": {"cancelled": true}
723
+ }
724
+ ```
725
+
726
+ #### get_fork_messages
727
+
728
+ Get user messages available for forking.
729
+
730
+ ```json
731
+ {"type": "get_fork_messages"}
732
+ ```
733
+
734
+ Response:
735
+ ```json
736
+ {
737
+ "type": "response",
738
+ "command": "get_fork_messages",
739
+ "success": true,
740
+ "data": {
741
+ "messages": [
742
+ {"entryId": "abc123", "text": "First prompt..."},
743
+ {"entryId": "def456", "text": "Second prompt..."}
744
+ ]
745
+ }
746
+ }
747
+ ```
748
+
749
+ #### get_entries
750
+
751
+ Get all session entries in append order (excluding the session header). The session is an append-only tree of entries with stable ids, so an entry id works as a durable cursor: pass the last entry id you have seen as `since` to get only entries strictly after it, even across client restarts. Unlike `get_messages`, this includes pre-compaction history and abandoned branches.
752
+
753
+ ```json
754
+ {"type": "get_entries"}
755
+ ```
756
+
757
+ With a cursor:
758
+ ```json
759
+ {"type": "get_entries", "since": "abc123"}
760
+ ```
761
+
762
+ Response:
763
+ ```json
764
+ {
765
+ "type": "response",
766
+ "command": "get_entries",
767
+ "success": true,
768
+ "data": {
769
+ "entries": [
770
+ {"type": "message", "id": "def456", "parentId": "abc123", "timestamp": "...", "message": {"role": "user", "...": "..."}}
771
+ ],
772
+ "leafId": "def456"
773
+ }
774
+ }
775
+ ```
776
+
777
+ `leafId` is the id of the current leaf entry (`null` for an empty session), so a client can tell in one round trip whether the active branch moved. If `since` does not match any entry id, the response is `success: false`.
778
+
779
+ #### get_tree
780
+
781
+ Get the session as a tree of entries. Each node is `{entry, children, label?, labelTimestamp?}`. A well-formed session has a single root; orphaned entries (broken parent chain) also appear as roots.
782
+
783
+ ```json
784
+ {"type": "get_tree"}
785
+ ```
786
+
787
+ Response:
788
+ ```json
789
+ {
790
+ "type": "response",
791
+ "command": "get_tree",
792
+ "success": true,
793
+ "data": {
794
+ "tree": [
795
+ {
796
+ "entry": {"type": "message", "id": "abc123", "parentId": null, "...": "..."},
797
+ "children": [
798
+ {"entry": {"type": "message", "id": "def456", "parentId": "abc123", "...": "..."}, "children": []}
799
+ ]
800
+ }
801
+ ],
802
+ "leafId": "def456"
803
+ }
804
+ }
805
+ ```
806
+
807
+ #### get_last_assistant_text
808
+
809
+ Get the text content of the last assistant message.
810
+
811
+ ```json
812
+ {"type": "get_last_assistant_text"}
813
+ ```
814
+
815
+ Response:
816
+ ```json
817
+ {
818
+ "type": "response",
819
+ "command": "get_last_assistant_text",
820
+ "success": true,
821
+ "data": {"text": "The assistant's response..."}
822
+ }
823
+ ```
824
+
825
+ Returns `{"text": null}` if no assistant messages exist.
826
+
827
+ #### set_session_name
828
+
829
+ Set a display name for the current session. The name appears in session listings and helps identify sessions.
830
+
831
+ ```json
832
+ {"type": "set_session_name", "name": "my-feature-work"}
833
+ ```
834
+
835
+ Response:
836
+ ```json
837
+ {
838
+ "type": "response",
839
+ "command": "set_session_name",
840
+ "success": true
841
+ }
842
+ ```
843
+
844
+ The current session name is available via `get_state` in the `sessionName` field. To set the initial name when starting RPC mode, pass `--name <name>` or `-n <name>` to the `atomic --mode rpc` process.
845
+
846
+ ### Commands
847
+
848
+ #### get_commands
849
+
850
+ Get available commands (extension commands, prompt templates, and skills). These can be invoked via the `prompt` command by prefixing with `/`.
851
+
852
+ ```json
853
+ {"type": "get_commands"}
854
+ ```
855
+
856
+ Response:
857
+ ```json
858
+ {
859
+ "type": "response",
860
+ "command": "get_commands",
861
+ "success": true,
862
+ "data": {
863
+ "commands": [
864
+ {"name": "session-name", "description": "Set or clear session name", "source": "extension", "path": "/home/user/.atomic/agent/extensions/session.ts"},
865
+ {"name": "fix-tests", "description": "Fix failing tests", "source": "prompt", "location": "project", "path": "/home/user/myproject/.atomic/prompts/fix-tests.md"},
866
+ {"name": "skill:brave-search", "description": "Web search via Brave API", "source": "skill", "location": "user", "path": "/home/user/.atomic/agent/skills/brave-search/SKILL.md"}
867
+ ]
868
+ }
869
+ }
870
+ ```
871
+
872
+ Each command has:
873
+ - `name`: Command name (invoke with `/name`)
874
+ - `description`: Human-readable description (optional for extension commands)
875
+ - `source`: What kind of command:
876
+ - `"extension"`: Registered via `pi.registerCommand()` in an extension
877
+ - `"prompt"`: Loaded from a prompt template `.md` file
878
+ - `"skill"`: Loaded from a skill directory (name is prefixed with `skill:`)
879
+ - `location`: Where it was loaded from (optional, not present for extensions):
880
+ - `"user"`: User-level (`~/.atomic/agent/`)
881
+ - `"project"`: Project-level (`./.atomic/`)
882
+ - `"path"`: Explicit path via CLI or settings
883
+ - `path`: Absolute file path to the command source (optional)
884
+
885
+ **Note**: Built-in TUI commands (`/settings`, `/hotkeys`, etc.) are not included. They are handled only in interactive mode and would not execute if sent via `prompt`.
886
+
887
+ ## Events
888
+
889
+ Events are streamed to stdout as JSON lines. Most events do not include an `id`; `bash_execution_update` is the deliberate exception and uses the originating bash request ID.
890
+
891
+ ### Event Types
892
+
893
+ | Event | Description |
894
+ |-------|-------------|
895
+ | `agent_start` | Agent begins processing |
896
+ | `agent_end` | Agent completes (includes all generated messages) |
897
+ | `turn_start` | New turn begins |
898
+ | `turn_end` | Turn completes (includes assistant message and tool results) |
899
+ | `message_start` | Message begins |
900
+ | `message_update` | Streaming update (text/thinking/toolcall deltas) |
901
+ | `message_end` | Message completes |
902
+ | `tool_execution_start` | Tool begins execution; includes `toolCallId`, `toolName`, and initial arguments |
903
+ | `tool_execution_update` | Tool execution progress (streaming output) |
904
+ | `tool_execution_end` | Tool completes |
905
+ | `bash_execution_update` | Correlated direct-bash stdout/stderr delta |
906
+ | `queue_update` | Pending steering/follow-up queue changed |
907
+ | `compaction_start` | Verbatim line compaction begins |
908
+ | `compaction_end` | Verbatim line compaction completes |
909
+ | `auto_retry_start` | Auto-retry begins (after transient error) |
910
+ | `auto_retry_end` | Auto-retry completes (success or final failure) |
911
+ | `summarization_retry_scheduled` | Retry scheduled for a transient compaction or branch-summary provider error |
912
+ | `summarization_retry_attempt_start` | Retried summarization request starts |
913
+ | `summarization_retry_finished` | Summarization retry loop completes |
914
+ | `extension_error` | Extension threw an error |
915
+
916
+ ### agent_start
917
+
918
+ Emitted when the agent begins processing a prompt.
919
+
920
+ ```json
921
+ {"type": "agent_start"}
922
+ ```
923
+
924
+ ### agent_end
925
+
926
+ Emitted when the agent completes. Contains all messages generated during this run.
927
+
928
+ ```json
929
+ {
930
+ "type": "agent_end",
931
+ "messages": [...]
932
+ }
933
+ ```
934
+
935
+ ### turn_start / turn_end
936
+
937
+ A turn consists of one assistant response plus any resulting tool calls and results.
938
+
939
+ ```json
940
+ {"type": "turn_start"}
941
+ ```
942
+
943
+ ```json
944
+ {
945
+ "type": "turn_end",
946
+ "message": {...},
947
+ "toolResults": [...]
948
+ }
949
+ ```
950
+
951
+ ### message_start / message_end
952
+
953
+ Emitted when a message begins and completes. The `message` field contains an `AgentMessage`.
954
+
955
+ ```json
956
+ {"type": "message_start", "message": {...}}
957
+ {"type": "message_end", "message": {...}}
958
+ ```
959
+
960
+ ### message_update (Streaming)
961
+
962
+ Emitted during streaming of assistant messages. Carries the streaming delta plus the latest cumulative usage.
963
+
964
+ `message_update` deliberately omits the cumulative message snapshot: there is no `message`
965
+ field, and `assistantMessageEvent` has no `partial`. `message_start` provides the
966
+ initial message, the deltas build it, and `message_end` provides the final
967
+ authoritative message. Repeating a snapshot on every frame would make the bytes
968
+ written per assistant turn grow with the square of its length.
969
+
970
+ The top-level `usage` field carries the latest cumulative provider-reported usage; it may
971
+ remain zero until completion when a provider does not report usage during streaming. When
972
+ the provider reports an explicit end-of-turn signal (pi-ai's `AssistantMessage.endTurn`,
973
+ for example OpenAI Codex `end_turn`), the update carries it as a top-level `endTurn`
974
+ boolean — present only when the provider reported one.
975
+
976
+ ```json
977
+ {
978
+ "type": "message_update",
979
+ "usage": {
980
+ "input": 100,
981
+ "output": 1,
982
+ "cacheRead": 0,
983
+ "cacheWrite": 0,
984
+ "totalTokens": 101,
985
+ "cost": {"input": 0, "output": 0, "cacheRead": 0, "cacheWrite": 0, "total": 0}
986
+ },
987
+ "assistantMessageEvent": {
988
+ "type": "text_delta",
989
+ "contentIndex": 0,
990
+ "delta": "Hello "
991
+ }
992
+ }
993
+ ```
994
+
995
+ The `assistantMessageEvent` field contains one of these delta types:
996
+
997
+ | Type | Description |
998
+ |------|-------------|
999
+ | `start` | Message generation started |
1000
+ | `text_start` | Text content block started |
1001
+ | `text_delta` | Text content chunk |
1002
+ | `text_end` | Text content block ended |
1003
+ | `thinking_start` | Thinking block started |
1004
+ | `thinking_delta` | Thinking content chunk |
1005
+ | `thinking_end` | Thinking block ended |
1006
+ | `toolcall_start` | Tool call started |
1007
+ | `toolcall_delta` | Tool call arguments chunk |
1008
+ | `toolcall_end` | Tool call ended (includes full `toolCall` object) |
1009
+ | `done` | Message complete (reason: `"stop"`, `"length"`, `"toolUse"`) |
1010
+ | `error` | Error occurred (reason: `"aborted"`, `"error"`) |
1011
+
1012
+ Example streaming a text response:
1013
+ ```json
1014
+ {"type":"message_update","usage":{...},"assistantMessageEvent":{"type":"text_start","contentIndex":0}}
1015
+ {"type":"message_update","usage":{...},"assistantMessageEvent":{"type":"text_delta","contentIndex":0,"delta":"Hello"}}
1016
+ {"type":"message_update","usage":{...},"assistantMessageEvent":{"type":"text_delta","contentIndex":0,"delta":" world"}}
1017
+ {"type":"message_update","usage":{...},"assistantMessageEvent":{"type":"text_end","contentIndex":0,"content":"Hello world"}}
1018
+ ```
1019
+
1020
+ ### tool_execution_start / tool_execution_update / tool_execution_end
1021
+
1022
+ Emitted when a tool begins, streams progress, and completes execution.
1023
+
1024
+ ```json
1025
+ {
1026
+ "type": "tool_execution_start",
1027
+ "toolCallId": "call_abc123",
1028
+ "toolName": "bash",
1029
+ "args": {"command": "ls -la"}
1030
+ }
1031
+ ```
1032
+
1033
+ During execution, `tool_execution_update` events stream partial results (e.g., bash output as it arrives):
1034
+
1035
+ ```json
1036
+ {
1037
+ "type": "tool_execution_update",
1038
+ "toolCallId": "call_abc123",
1039
+ "toolName": "bash",
1040
+ "args": {"command": "ls -la"},
1041
+ "partialResult": {
1042
+ "content": [{"type": "text", "text": "partial output so far..."}],
1043
+ "details": {"truncation": null, "fullOutputPath": null}
1044
+ }
1045
+ }
1046
+ ```
1047
+
1048
+ When complete:
1049
+
1050
+ ```json
1051
+ {
1052
+ "type": "tool_execution_end",
1053
+ "toolCallId": "call_abc123",
1054
+ "toolName": "bash",
1055
+ "result": {
1056
+ "content": [{"type": "text", "text": "total 48\n..."}],
1057
+ "details": {...}
1058
+ },
1059
+ "isError": false
1060
+ }
1061
+ ```
1062
+
1063
+ Use `toolCallId` to correlate events. The `partialResult` in `tool_execution_update` contains the accumulated output so far (not just the delta), allowing clients to simply replace their display on each update.
1064
+
1065
+ ### bash_execution_update
1066
+
1067
+ Emitted only for direct `bash` and non-intercepted `user_bash` RPC execution. Each event is `{type, id?, channel, delta}` where `channel` is `"stdout"` or `"stderr"`; use `id` to keep concurrent streams separate. Tool-call bash continues to use `tool_execution_update` and its `toolCallId`.
1068
+
1069
+ ### queue_update
1070
+
1071
+ Emitted whenever the pending steering or follow-up queue changes.
1072
+
1073
+ ```json
1074
+ {
1075
+ "type": "queue_update",
1076
+ "steering": ["Focus on error handling"],
1077
+ "followUp": ["After that, summarize the result"]
1078
+ }
1079
+ ```
1080
+
1081
+ ### compaction_start / compaction_end
1082
+
1083
+ Emitted when default Verbatim Compaction runs, whether manual or automatic. The result records deletion targets and stats rather than a generated summary.
1084
+
1085
+ ```json
1086
+ {"type": "compaction_start", "reason": "threshold"}
1087
+ ```
1088
+
1089
+ The `reason` field is `"manual"`, `"threshold"`, or `"overflow"`.
1090
+
1091
+ ```json
1092
+ {
1093
+ "type": "compaction_end",
1094
+ "reason": "threshold",
1095
+ "result": {
1096
+ "compactedText": "[User]: fix the test\n(filtered 42 lines)",
1097
+ "firstKeptEntryId": "m7",
1098
+ "tokensBefore": 150000,
1099
+ "promptVersion": 3,
1100
+ "parameters": {"compression_ratio": 0.5, "preserve_recent": 2, "query": "fix the test"},
1101
+ "rung": "planned",
1102
+ "stats": {
1103
+ "linesBefore": 812,
1104
+ "linesDeleted": 417,
1105
+ "linesKept": 395,
1106
+ "rangeCount": 63,
1107
+ "tokensBefore": 150000,
1108
+ "tokensAfter": 72000,
1109
+ "percentReduction": 52
1110
+ }
1111
+ },
1112
+ "aborted": false,
1113
+ "willRetry": false
1114
+ }
1115
+ ```
1116
+
1117
+ If `reason` was `"overflow"` and compaction succeeds, `willRetry` is `true` and the agent will automatically retry the prompt. Public prompt/RPC callers wait for that post-compaction continuation before the prompt is considered complete.
1118
+
1119
+ If compaction was aborted, `result` is `null` and `aborted` is `true`.
1120
+
1121
+ If compaction failed (e.g., API quota exceeded), `result` is `null`, `aborted` is `false`, and `errorMessage` contains the error description.
1122
+
1123
+ `result` and `errorMessage` are independent. A mid-turn post-tool compaction can commit a boundary and *then* fail the provider hard-input-limit gate, so one `compaction_end` may carry both a non-null `result` and an `errorMessage`. Treat the result as a committed durable boundary in that case; the error describes the follow-up request that was not sent.
1124
+
1125
+ If overflow recovery exhausts the same-model compact-and-retry attempt, `compaction_end` includes `"unresolvedOverflow": true` and an `errorMessage`. Workflow orchestration treats that signal as a context-length failure that can advance configured model fallback tiers.
1126
+
1127
+ There is no `context_compact` command; Atomic reports it as an unknown command. Use `compact`. Only `compaction_start` and `compaction_end` events are emitted.
1128
+
1129
+ ### auto_retry_start / auto_retry_end
1130
+
1131
+ Emitted when automatic retry is triggered after a transient error (overloaded, rate limit, 5xx).
1132
+
1133
+ ```json
1134
+ {
1135
+ "type": "auto_retry_start",
1136
+ "attempt": 1,
1137
+ "maxAttempts": 3,
1138
+ "delayMs": 2000,
1139
+ "errorMessage": "529 {\"type\":\"error\",\"error\":{\"type\":\"overloaded_error\",\"message\":\"Overloaded\"}}"
1140
+ }
1141
+ ```
1142
+
1143
+ ```json
1144
+ {
1145
+ "type": "auto_retry_end",
1146
+ "success": true,
1147
+ "attempt": 2
1148
+ }
1149
+ ```
1150
+
1151
+ On final failure (max retries exceeded):
1152
+ ```json
1153
+ {
1154
+ "type": "auto_retry_end",
1155
+ "success": false,
1156
+ "attempt": 3,
1157
+ "finalError": "529 overloaded_error: Overloaded"
1158
+ }
1159
+ ```
1160
+
1161
+
1162
+ ### summarization_retry_scheduled / summarization_retry_attempt_start / summarization_retry_finished
1163
+
1164
+ Emitted when compaction planning or branch summarization retries after a transient provider error. These events use the same retry settings as automatic assistant-turn retries.
1165
+
1166
+ ```json
1167
+ {
1168
+ "type": "summarization_retry_scheduled",
1169
+ "attempt": 1,
1170
+ "maxAttempts": 3,
1171
+ "delayMs": 2000,
1172
+ "errorMessage": "terminated"
1173
+ }
1174
+ ```
1175
+
1176
+ ```json
1177
+ {
1178
+ "type": "summarization_retry_attempt_start",
1179
+ "source": "compaction",
1180
+ "reason": "threshold"
1181
+ }
1182
+ ```
1183
+
1184
+ For branch summaries, `source` is `"branchSummary"` and no `reason` is present. The loop then emits:
1185
+
1186
+ ```json
1187
+ {"type": "summarization_retry_finished"}
1188
+ ```
1189
+
1190
+ ### extension_error
1191
+
1192
+ Emitted when an extension throws an error.
1193
+
1194
+ ```json
1195
+ {
1196
+ "type": "extension_error",
1197
+ "extensionPath": "/path/to/extension.ts",
1198
+ "event": "tool_call",
1199
+ "error": "Error message..."
1200
+ }
1201
+ ```
1202
+
1203
+ ## Error Handling
1204
+
1205
+ Failed commands return a response with `success: false`:
1206
+
1207
+ ```json
1208
+ {
1209
+ "type": "response",
1210
+ "command": "set_model",
1211
+ "success": false,
1212
+ "error": "Model not found: invalid/model"
1213
+ }
1214
+ ```
1215
+
1216
+ Parse errors:
1217
+
1218
+ ```json
1219
+ {
1220
+ "type": "response",
1221
+ "command": "parse",
1222
+ "success": false,
1223
+ "error": "Failed to parse command: Unexpected token..."
1224
+ }
1225
+ ```
1226
+
1227
+ ## Types
1228
+
1229
+ Source files and installed definitions:
1230
+ - `node_modules/@bastani/pi-ai/dist/types.d.ts` - `Model`, `UserMessage`, `AssistantMessage`, `ToolResultMessage`
1231
+ - `node_modules/@earendil-works/pi-agent-core/dist/types.d.ts` - `AgentMessage`, `AgentEvent`
1232
+ - [`src/core/messages.ts`](https://github.com/bastani-inc/atomic/blob/main/packages/coding-agent/src/core/messages.ts) - `BashExecutionMessage`
1233
+ - [`src/modes/rpc/rpc-types.ts`](https://github.com/bastani-inc/atomic/blob/main/packages/coding-agent/src/modes/rpc/rpc-types.ts) - RPC command/response types, extension UI request/response types
1234
+
1235
+ ### Model
1236
+
1237
+ ```json
1238
+ {
1239
+ "id": "claude-sonnet-4-20250514",
1240
+ "name": "Claude Sonnet 4",
1241
+ "api": "anthropic-messages",
1242
+ "provider": "anthropic",
1243
+ "baseUrl": "https://api.anthropic.com",
1244
+ "reasoning": true,
1245
+ "input": ["text", "image"],
1246
+ "contextWindow": 200000,
1247
+ "maxTokens": 16384,
1248
+ "cost": {
1249
+ "input": 3.0,
1250
+ "output": 15.0,
1251
+ "cacheRead": 0.3,
1252
+ "cacheWrite": 3.75
1253
+ }
1254
+ }
1255
+ ```
1256
+
1257
+ `contextWindow` is the model's token budget used by Atomic's local budgeting, footer/stats, and compaction logic.
1258
+
1259
+ ### UserMessage
1260
+
1261
+ ```json
1262
+ {
1263
+ "role": "user",
1264
+ "content": "Hello!",
1265
+ "timestamp": 1733234567890
1266
+ }
1267
+ ```
1268
+
1269
+ The `content` field can be a string or an array of `TextContent`/`ImageContent` blocks.
1270
+
1271
+ ### AssistantMessage
1272
+
1273
+ ```json
1274
+ {
1275
+ "role": "assistant",
1276
+ "content": [
1277
+ {"type": "text", "text": "Hello! How can I help?"},
1278
+ {"type": "thinking", "thinking": "User is greeting me..."},
1279
+ {"type": "toolCall", "id": "call_123", "name": "bash", "arguments": {"command": "ls"}}
1280
+ ],
1281
+ "api": "anthropic-messages",
1282
+ "provider": "anthropic",
1283
+ "model": "claude-sonnet-4-20250514",
1284
+ "usage": {
1285
+ "input": 100,
1286
+ "output": 50,
1287
+ "cacheRead": 0,
1288
+ "cacheWrite": 0,
1289
+ "cost": {"input": 0.0003, "output": 0.00075, "cacheRead": 0, "cacheWrite": 0, "total": 0.00105}
1290
+ },
1291
+ "stopReason": "stop",
1292
+ "timestamp": 1733234567890
1293
+ }
1294
+ ```
1295
+
1296
+ Stop reasons: `"stop"`, `"length"`, `"toolUse"`, `"error"`, `"aborted"`. A streaming message carries `"pending"` until the terminal event replaces it, so a client that switches on the reason needs that case; a completed message never carries it. On the wire the pending reason appears on the `message_start` message — `message_update` frames carry no message at all — and `message_end` carries the terminal reason. A provider that reports an explicit end-of-turn signal (pi-ai's `AssistantMessage.endTurn`, for example OpenAI Codex `end_turn`) sets `endTurn: true` on the assistant message; `message_update` frames echo it as a top-level boolean only when the provider reported one.
1297
+
1298
+ ### ToolResultMessage
1299
+
1300
+ ```json
1301
+ {
1302
+ "role": "toolResult",
1303
+ "toolCallId": "call_123",
1304
+ "toolName": "bash",
1305
+ "content": [{"type": "text", "text": "total 48\ndrwxr-xr-x ..."}],
1306
+ "isError": false,
1307
+ "timestamp": 1733234567890
1308
+ }
1309
+ ```
1310
+
1311
+ ### BashExecutionMessage
1312
+
1313
+ Created by the `bash` RPC command (not by LLM tool calls):
1314
+
1315
+ ```json
1316
+ {
1317
+ "role": "bashExecution",
1318
+ "command": "ls -la",
1319
+ "output": "total 48\ndrwxr-xr-x ...",
1320
+ "exitCode": 0,
1321
+ "cancelled": false,
1322
+ "truncated": false,
1323
+ "fullOutputPath": null,
1324
+ "timestamp": 1733234567890
1325
+ }
1326
+ ```
1327
+
1328
+ ### Attachment
1329
+
1330
+ ```json
1331
+ {
1332
+ "id": "img1",
1333
+ "type": "image",
1334
+ "fileName": "photo.jpg",
1335
+ "mimeType": "image/jpeg",
1336
+ "size": 102400,
1337
+ "content": "base64-encoded-data...",
1338
+ "extractedText": null,
1339
+ "preview": null
1340
+ }
1341
+ ```