@pi-in-go/pigpen-ahp 0.1.0

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 (304) hide show
  1. package/CREDITS.md +27 -0
  2. package/LICENSE +23 -0
  3. package/README.md +148 -0
  4. package/extensions/ahp/access_options_test.go +116 -0
  5. package/extensions/ahp/extension.go +54 -0
  6. package/extensions/ahp/go.mod +12 -0
  7. package/extensions/ahp/go.sum +2 -0
  8. package/extensions/ahp/go.work +8 -0
  9. package/extensions/ahp/internal/channels/chat.go +110 -0
  10. package/extensions/ahp/internal/channels/root.go +32 -0
  11. package/extensions/ahp/internal/channels/session.go +128 -0
  12. package/extensions/ahp/internal/channels/session_test.go +108 -0
  13. package/extensions/ahp/internal/compose/compose.go +153 -0
  14. package/extensions/ahp/internal/compose/compose_test.go +120 -0
  15. package/extensions/ahp/internal/gaps/gaps_test.go +88 -0
  16. package/extensions/ahp/internal/host/handshake_test.go +206 -0
  17. package/extensions/ahp/internal/host/host.go +1305 -0
  18. package/extensions/ahp/internal/host/reconnect_test.go +197 -0
  19. package/extensions/ahp/internal/host/replaywindow_test.go +31 -0
  20. package/extensions/ahp/internal/host/schema_test.go +79 -0
  21. package/extensions/ahp/internal/host/store.go +291 -0
  22. package/extensions/ahp/internal/host/store_update_test.go +85 -0
  23. package/extensions/ahp/internal/host/subscriptions_test.go +160 -0
  24. package/extensions/ahp/internal/host/surface_test.go +95 -0
  25. package/extensions/ahp/internal/host/workarounds.go +458 -0
  26. package/extensions/ahp/internal/host/workarounds_test.go +96 -0
  27. package/extensions/ahp/internal/live/live.go +328 -0
  28. package/extensions/ahp/internal/live/live_test.go +91 -0
  29. package/extensions/ahp/internal/live/store.go +113 -0
  30. package/extensions/ahp/internal/mapper/activity.go +199 -0
  31. package/extensions/ahp/internal/mapper/activity_test.go +188 -0
  32. package/extensions/ahp/internal/mapper/bench_test.go +38 -0
  33. package/extensions/ahp/internal/mapper/event_mapper_test.go +380 -0
  34. package/extensions/ahp/internal/mapper/fixtures_test.go +387 -0
  35. package/extensions/ahp/internal/mapper/helpers_test.go +251 -0
  36. package/extensions/ahp/internal/mapper/js.go +131 -0
  37. package/extensions/ahp/internal/mapper/mapper.go +600 -0
  38. package/extensions/ahp/internal/mapper/message_input_test.go +196 -0
  39. package/extensions/ahp/internal/mapper/messageinput.go +272 -0
  40. package/extensions/ahp/internal/mapper/schema_helpers_test.go +5 -0
  41. package/extensions/ahp/internal/mapper/testdata/LICENSE-pi-ahp +21 -0
  42. package/extensions/ahp/internal/mapper/testdata/fixtures/abort.json +711 -0
  43. package/extensions/ahp/internal/mapper/testdata/fixtures/bash-long-output.json +1312 -0
  44. package/extensions/ahp/internal/mapper/testdata/fixtures/compaction.json +6285 -0
  45. package/extensions/ahp/internal/mapper/testdata/fixtures/parallel-tools.json +2622 -0
  46. package/extensions/ahp/internal/mapper/testdata/fixtures/plain-text.json +1856 -0
  47. package/extensions/ahp/internal/mapper/testdata/fixtures/single-tool.json +1128 -0
  48. package/extensions/ahp/internal/mapper/testdata/fixtures/steering.json +3926 -0
  49. package/extensions/ahp/internal/mapper/testdata/fixtures/tool-bash.json +2372 -0
  50. package/extensions/ahp/internal/mapper/testdata/fixtures/tool-edit.json +3983 -0
  51. package/extensions/ahp/internal/mapper/testdata/fixtures/tool-error.json +2850 -0
  52. package/extensions/ahp/internal/mapper/testdata/fixtures/tool-find.json +1162 -0
  53. package/extensions/ahp/internal/mapper/testdata/fixtures/tool-grep.json +2783 -0
  54. package/extensions/ahp/internal/mapper/testdata/fixtures/tool-loop.json +1693 -0
  55. package/extensions/ahp/internal/mapper/testdata/fixtures/tool-ls.json +2427 -0
  56. package/extensions/ahp/internal/mapper/testdata/fixtures/tool-write.json +1271 -0
  57. package/extensions/ahp/internal/mapper/title.go +34 -0
  58. package/extensions/ahp/internal/mapper/usermsg.go +87 -0
  59. package/extensions/ahp/internal/pi/activeturn_test.go +296 -0
  60. package/extensions/ahp/internal/pi/backend.go +64 -0
  61. package/extensions/ahp/internal/pi/catalogue.go +370 -0
  62. package/extensions/ahp/internal/pi/catalogue_test.go +271 -0
  63. package/extensions/ahp/internal/pi/chatdriver.go +533 -0
  64. package/extensions/ahp/internal/pi/chatdriver_test.go +416 -0
  65. package/extensions/ahp/internal/pi/clientactions.go +212 -0
  66. package/extensions/ahp/internal/pi/clientactions_test.go +273 -0
  67. package/extensions/ahp/internal/pi/completions.go +230 -0
  68. package/extensions/ahp/internal/pi/completions_test.go +272 -0
  69. package/extensions/ahp/internal/pi/config_test.go +269 -0
  70. package/extensions/ahp/internal/pi/deletesession.go +69 -0
  71. package/extensions/ahp/internal/pi/deletesession_test.go +153 -0
  72. package/extensions/ahp/internal/pi/disposal_test.go +362 -0
  73. package/extensions/ahp/internal/pi/fixture_test.go +308 -0
  74. package/extensions/ahp/internal/pi/foreign_test.go +122 -0
  75. package/extensions/ahp/internal/pi/harness_test.go +83 -0
  76. package/extensions/ahp/internal/pi/history.go +269 -0
  77. package/extensions/ahp/internal/pi/hydrated_test.go +171 -0
  78. package/extensions/ahp/internal/pi/hydratedlifecycle_test.go +196 -0
  79. package/extensions/ahp/internal/pi/hydration_test.go +209 -0
  80. package/extensions/ahp/internal/pi/hydrator.go +212 -0
  81. package/extensions/ahp/internal/pi/imageinput.go +224 -0
  82. package/extensions/ahp/internal/pi/imageinput_test.go +57 -0
  83. package/extensions/ahp/internal/pi/lifecycle_test.go +381 -0
  84. package/extensions/ahp/internal/pi/models.go +212 -0
  85. package/extensions/ahp/internal/pi/models_test.go +128 -0
  86. package/extensions/ahp/internal/pi/paging.go +95 -0
  87. package/extensions/ahp/internal/pi/pagingtruncate_test.go +323 -0
  88. package/extensions/ahp/internal/pi/projecttrust.go +222 -0
  89. package/extensions/ahp/internal/pi/registry.go +924 -0
  90. package/extensions/ahp/internal/pi/restart_test.go +185 -0
  91. package/extensions/ahp/internal/pi/services.go +70 -0
  92. package/extensions/ahp/internal/pi/sessionconfig.go +64 -0
  93. package/extensions/ahp/internal/pi/sessionfiles_test.go +74 -0
  94. package/extensions/ahp/internal/pi/sessionstore.go +83 -0
  95. package/extensions/ahp/internal/pi/summary_test.go +426 -0
  96. package/extensions/ahp/internal/pi/workarounds_wire_test.go +208 -0
  97. package/extensions/ahp/internal/pisession/fromentries_test.go +32 -0
  98. package/extensions/ahp/internal/pisession/json.go +31 -0
  99. package/extensions/ahp/internal/pisession/pisession.go +580 -0
  100. package/extensions/ahp/internal/settings/access.go +63 -0
  101. package/extensions/ahp/internal/settings/access_test.go +52 -0
  102. package/extensions/ahp/internal/settings/settings.go +117 -0
  103. package/extensions/ahp/internal/settings/settings_test.go +104 -0
  104. package/extensions/ahp/internal/svc/etag_other.go +15 -0
  105. package/extensions/ahp/internal/svc/etag_unix.go +34 -0
  106. package/extensions/ahp/internal/svc/glob.go +197 -0
  107. package/extensions/ahp/internal/svc/mime.go +37 -0
  108. package/extensions/ahp/internal/svc/paths.go +108 -0
  109. package/extensions/ahp/internal/svc/pty.go +64 -0
  110. package/extensions/ahp/internal/svc/pty_darwin.go +42 -0
  111. package/extensions/ahp/internal/svc/pty_linux.go +36 -0
  112. package/extensions/ahp/internal/svc/pty_other.go +9 -0
  113. package/extensions/ahp/internal/svc/pty_test.go +114 -0
  114. package/extensions/ahp/internal/svc/pty_unix.go +147 -0
  115. package/extensions/ahp/internal/svc/resource.go +495 -0
  116. package/extensions/ahp/internal/svc/resource_test.go +501 -0
  117. package/extensions/ahp/internal/svc/stat_bsd.go +9 -0
  118. package/extensions/ahp/internal/svc/stat_linux.go +9 -0
  119. package/extensions/ahp/internal/svc/terminal.go +454 -0
  120. package/extensions/ahp/internal/svc/terminal_test.go +512 -0
  121. package/extensions/ahp/internal/svc/watch.go +590 -0
  122. package/extensions/ahp/internal/svc/watch_test.go +627 -0
  123. package/extensions/ahp/internal/svc/watchevents_test.go +452 -0
  124. package/extensions/ahp/internal/svc/watchpolicy.go +81 -0
  125. package/extensions/ahp/internal/svc/watchpolicy_test.go +151 -0
  126. package/extensions/ahp/internal/svc/watchracy_test.go +61 -0
  127. package/extensions/ahp/internal/testkit/schema/LICENSE-agent-host-protocol +21 -0
  128. package/extensions/ahp/internal/testkit/schema/actions.schema.json +9208 -0
  129. package/extensions/ahp/internal/testkit/schema/commands.schema.json +10862 -0
  130. package/extensions/ahp/internal/testkit/schema/errors.schema.json +10928 -0
  131. package/extensions/ahp/internal/testkit/schema/notifications.schema.json +6667 -0
  132. package/extensions/ahp/internal/testkit/schema/state.schema.json +6392 -0
  133. package/extensions/ahp/internal/testkit/schema.go +360 -0
  134. package/extensions/ahp/internal/testkit/testkit.go +367 -0
  135. package/extensions/ahp/internal/twin/twin.go +27 -0
  136. package/extensions/ahp/internal/wire/dispatchable.go +106 -0
  137. package/extensions/ahp/internal/wire/dispatchable_list.go +15 -0
  138. package/extensions/ahp/internal/wire/helpers_test.go +5 -0
  139. package/extensions/ahp/internal/wire/wire.go +218 -0
  140. package/extensions/ahp/internal/wire/wire_test.go +123 -0
  141. package/extensions/ahp/internal/ws/helpers_test.go +7 -0
  142. package/extensions/ahp/internal/ws/vscode_test.go +198 -0
  143. package/extensions/ahp/internal/ws/ws.go +674 -0
  144. package/extensions/ahp/internal/ws/ws_test.go +324 -0
  145. package/extensions/ahp/realpig_test.go +589 -0
  146. package/extensions/ahp/runtime.go +311 -0
  147. package/extensions/ahp/runtime_test.go +110 -0
  148. package/extensions/ahp/testdata/upstream-tests.json +3833 -0
  149. package/extensions/ahp/third_party/agent-host-protocol-go/LICENSE +21 -0
  150. package/extensions/ahp/third_party/agent-host-protocol-go/NOTICE-PIGPEN.md +18 -0
  151. package/extensions/ahp/third_party/agent-host-protocol-go/ahp/client.go +1011 -0
  152. package/extensions/ahp/third_party/agent-host-protocol-go/ahp/error.go +111 -0
  153. package/extensions/ahp/third_party/agent-host-protocol-go/ahp/multi_host_state_mirror.go +239 -0
  154. package/extensions/ahp/third_party/agent-host-protocol-go/ahp/reducers.go +1939 -0
  155. package/extensions/ahp/third_party/agent-host-protocol-go/ahp/transport.go +176 -0
  156. package/extensions/ahp/third_party/agent-host-protocol-go/ahptypes/actions.generated.go +2447 -0
  157. package/extensions/ahp/third_party/agent-host-protocol-go/ahptypes/commands.generated.go +1546 -0
  158. package/extensions/ahp/third_party/agent-host-protocol-go/ahptypes/common.go +205 -0
  159. package/extensions/ahp/third_party/agent-host-protocol-go/ahptypes/errors.generated.go +65 -0
  160. package/extensions/ahp/third_party/agent-host-protocol-go/ahptypes/messages.generated.go +138 -0
  161. package/extensions/ahp/third_party/agent-host-protocol-go/ahptypes/notifications.generated.go +264 -0
  162. package/extensions/ahp/third_party/agent-host-protocol-go/ahptypes/state.generated.go +6171 -0
  163. package/extensions/ahp/third_party/agent-host-protocol-go/ahptypes/version.generated.go +31 -0
  164. package/extensions/ahp/third_party/agent-host-protocol-go/go.mod +3 -0
  165. package/extensions/ahp/twins_test.go +91 -0
  166. package/package.json +40 -0
  167. package/proof/PORT.md +121 -0
  168. package/proof/mutations.json +152 -0
  169. package/proof/oracle/LICENSE +21 -0
  170. package/proof/oracle/README.md +120 -0
  171. package/proof/oracle/UPSTREAM.md +7 -0
  172. package/proof/oracle/package.json +68 -0
  173. package/proof/oracle/src/bin/cli.ts +66 -0
  174. package/proof/oracle/src/bin/tunnel.ts +128 -0
  175. package/proof/oracle/src/channels/chat.ts +134 -0
  176. package/proof/oracle/src/channels/root.ts +39 -0
  177. package/proof/oracle/src/channels/session.ts +118 -0
  178. package/proof/oracle/src/channels/terminal.ts +11 -0
  179. package/proof/oracle/src/core/channels.ts +108 -0
  180. package/proof/oracle/src/core/client-workarounds.ts +358 -0
  181. package/proof/oracle/src/core/connection.ts +41 -0
  182. package/proof/oracle/src/core/host.ts +882 -0
  183. package/proof/oracle/src/core/sequencer.ts +75 -0
  184. package/proof/oracle/src/core/state-store.ts +162 -0
  185. package/proof/oracle/src/core/uri.ts +25 -0
  186. package/proof/oracle/src/host/direct-settings.ts +110 -0
  187. package/proof/oracle/src/host/pi-host.ts +220 -0
  188. package/proof/oracle/src/host/serve.ts +71 -0
  189. package/proof/oracle/src/host/terminal-service.ts +346 -0
  190. package/proof/oracle/src/pi/activity.ts +171 -0
  191. package/proof/oracle/src/pi/changeset-service.ts +646 -0
  192. package/proof/oracle/src/pi/changeset-uri.ts +64 -0
  193. package/proof/oracle/src/pi/chat-driver.ts +529 -0
  194. package/proof/oracle/src/pi/completions.ts +160 -0
  195. package/proof/oracle/src/pi/delete-session.ts +53 -0
  196. package/proof/oracle/src/pi/event-mapper.ts +648 -0
  197. package/proof/oracle/src/pi/git-changes.ts +605 -0
  198. package/proof/oracle/src/pi/history.ts +305 -0
  199. package/proof/oracle/src/pi/image-input.ts +56 -0
  200. package/proof/oracle/src/pi/image-mime.ts +8 -0
  201. package/proof/oracle/src/pi/in-process-backend.ts +155 -0
  202. package/proof/oracle/src/pi/message-input.ts +212 -0
  203. package/proof/oracle/src/pi/models.ts +124 -0
  204. package/proof/oracle/src/pi/project-trust.ts +66 -0
  205. package/proof/oracle/src/pi/provider.ts +2 -0
  206. package/proof/oracle/src/pi/resource-paths.ts +80 -0
  207. package/proof/oracle/src/pi/resource-service.ts +356 -0
  208. package/proof/oracle/src/pi/resource-watch-policy.ts +35 -0
  209. package/proof/oracle/src/pi/resource-watch.ts +357 -0
  210. package/proof/oracle/src/pi/session-catalogue.ts +318 -0
  211. package/proof/oracle/src/pi/session-config.ts +84 -0
  212. package/proof/oracle/src/pi/session-history.ts +75 -0
  213. package/proof/oracle/src/pi/session-hydrator.ts +219 -0
  214. package/proof/oracle/src/pi/session-registry.ts +815 -0
  215. package/proof/oracle/src/pi/session-storage.ts +29 -0
  216. package/proof/oracle/src/pi/session-title.ts +18 -0
  217. package/proof/oracle/src/pi/turn-paging.ts +94 -0
  218. package/proof/oracle/src/pi/user-message.ts +66 -0
  219. package/proof/oracle/src/protocol/errors.ts +44 -0
  220. package/proof/oracle/src/protocol/jsonrpc.ts +89 -0
  221. package/proof/oracle/src/protocol/version.ts +39 -0
  222. package/proof/oracle/src/transport/websocket.ts +136 -0
  223. package/proof/oracle/src/tunnel/devtunnel.ts +293 -0
  224. package/proof/oracle/src/tunnel/discovery.ts +37 -0
  225. package/proof/oracle/test/active-turn-reconnect.test.ts +274 -0
  226. package/proof/oracle/test/activity.test.ts +171 -0
  227. package/proof/oracle/test/changeset-lifecycle.test.serial.ts +303 -0
  228. package/proof/oracle/test/changeset-uri.test.ts +37 -0
  229. package/proof/oracle/test/changeset.test.serial.ts +487 -0
  230. package/proof/oracle/test/chat-driver.test.ts +691 -0
  231. package/proof/oracle/test/client-actions.test.ts +409 -0
  232. package/proof/oracle/test/client-workarounds.test.ts +320 -0
  233. package/proof/oracle/test/completions.test.ts +323 -0
  234. package/proof/oracle/test/delete-session.test.ts +142 -0
  235. package/proof/oracle/test/direct-settings.test.ts +81 -0
  236. package/proof/oracle/test/event-mapper.test.ts +619 -0
  237. package/proof/oracle/test/fetch-turns.test.ts +207 -0
  238. package/proof/oracle/test/fixtures/abort.json +711 -0
  239. package/proof/oracle/test/fixtures/bash-long-output.json +1312 -0
  240. package/proof/oracle/test/fixtures/compaction.json +6285 -0
  241. package/proof/oracle/test/fixtures/parallel-tools.json +2622 -0
  242. package/proof/oracle/test/fixtures/plain-text.json +1856 -0
  243. package/proof/oracle/test/fixtures/single-tool.json +1128 -0
  244. package/proof/oracle/test/fixtures/steering.json +3926 -0
  245. package/proof/oracle/test/fixtures/tool-bash.json +2372 -0
  246. package/proof/oracle/test/fixtures/tool-edit.json +3983 -0
  247. package/proof/oracle/test/fixtures/tool-error.json +2850 -0
  248. package/proof/oracle/test/fixtures/tool-find.json +1162 -0
  249. package/proof/oracle/test/fixtures/tool-grep.json +2783 -0
  250. package/proof/oracle/test/fixtures/tool-loop.json +1693 -0
  251. package/proof/oracle/test/fixtures/tool-ls.json +2427 -0
  252. package/proof/oracle/test/fixtures/tool-write.json +1271 -0
  253. package/proof/oracle/test/handshake.test.ts +275 -0
  254. package/proof/oracle/test/harness.ts +153 -0
  255. package/proof/oracle/test/hydrated-session-lifecycle.test.ts +211 -0
  256. package/proof/oracle/test/image-input.test.ts +28 -0
  257. package/proof/oracle/test/image-session.test.ts +69 -0
  258. package/proof/oracle/test/live-turn.test.ts +304 -0
  259. package/proof/oracle/test/mapper-fixtures.test.ts +293 -0
  260. package/proof/oracle/test/message-input.test.ts +181 -0
  261. package/proof/oracle/test/model-discovery.test.ts +170 -0
  262. package/proof/oracle/test/models.test.ts +109 -0
  263. package/proof/oracle/test/pi-host.test.ts +91 -0
  264. package/proof/oracle/test/pi-replay.test.ts +141 -0
  265. package/proof/oracle/test/project-trust.test.ts +125 -0
  266. package/proof/oracle/test/protocol-surface.test.ts +121 -0
  267. package/proof/oracle/test/pty.test.ts +100 -0
  268. package/proof/oracle/test/reconnect.test.ts +389 -0
  269. package/proof/oracle/test/resource-watch-policy.test.ts +78 -0
  270. package/proof/oracle/test/resource-watch.test.serial.ts +536 -0
  271. package/proof/oracle/test/resource.test.ts +499 -0
  272. package/proof/oracle/test/schema.test.ts +88 -0
  273. package/proof/oracle/test/session-catalogue.test.ts +314 -0
  274. package/proof/oracle/test/session-config.test.ts +224 -0
  275. package/proof/oracle/test/session-disposal.test.ts +364 -0
  276. package/proof/oracle/test/session-hydration.test.ts +194 -0
  277. package/proof/oracle/test/session-lifecycle.test.ts +416 -0
  278. package/proof/oracle/test/session-storage.test.serial.ts +32 -0
  279. package/proof/oracle/test/session-summary.test.ts +418 -0
  280. package/proof/oracle/test/subscriptions.test.ts +198 -0
  281. package/proof/oracle/test/support/assertions.ts +32 -0
  282. package/proof/oracle/test/support/async.ts +26 -0
  283. package/proof/oracle/test/support/hydrated-session.ts +205 -0
  284. package/proof/oracle/test/support/images.ts +8 -0
  285. package/proof/oracle/test/support/recorded-fixtures.ts +60 -0
  286. package/proof/oracle/test/support/recorded-scenarios.ts +145 -0
  287. package/proof/oracle/test/support/replay.ts +194 -0
  288. package/proof/oracle/test/support/schema.ts +221 -0
  289. package/proof/oracle/test/support/session-files.ts +12 -0
  290. package/proof/oracle/test/support/session-storage.ts +22 -0
  291. package/proof/oracle/test/support/upstream.ts +25 -0
  292. package/proof/oracle/test/support/watch-events.ts +108 -0
  293. package/proof/oracle/test/terminal-service.test.ts +495 -0
  294. package/proof/oracle/test/truncate.test.ts +230 -0
  295. package/proof/oracle/test/tunnel.test.ts +258 -0
  296. package/proof/oracle/test/upstream-workarounds.test.ts +37 -0
  297. package/proof/oracle/test/uri.test.ts +24 -0
  298. package/proof/oracle/test/watch-events.test.ts +118 -0
  299. package/proof/oracle/tsconfig.json +32 -0
  300. package/proof/proof-piglet/piglet.yaml +18 -0
  301. package/proof/tools/fakellm/go.mod +3 -0
  302. package/proof/tools/fakellm/main.go +109 -0
  303. package/proof/tools/gen-dispatchable.py +30 -0
  304. package/provenance.json +28 -0
@@ -0,0 +1,2447 @@
1
+ // Generated from types/*.ts — do not edit.
2
+ //
3
+ // Regenerate with: npm run generate:go
4
+
5
+ package ahptypes
6
+
7
+ import (
8
+ "encoding/json"
9
+ )
10
+
11
+ // Reference the encoding/json import to keep gofmt -d from
12
+ // stripping it when a generated file has no struct that mentions
13
+ // json.RawMessage directly (rare but possible). Compiled out.
14
+ var _ = json.RawMessage(nil)
15
+
16
+ // ─── ActionType ──────────────────────────────────────────────────────
17
+
18
+ // Discriminant values for all state actions.
19
+ type ActionType string
20
+
21
+ const (
22
+ ActionTypeRootAgentsChanged ActionType = "root/agentsChanged"
23
+ ActionTypeRootActiveSessionsChanged ActionType = "root/activeSessionsChanged"
24
+ ActionTypeSessionReady ActionType = "session/ready"
25
+ ActionTypeSessionCreationFailed ActionType = "session/creationFailed"
26
+ ActionTypeSessionChatAdded ActionType = "session/chatAdded"
27
+ ActionTypeSessionChatRemoved ActionType = "session/chatRemoved"
28
+ ActionTypeSessionChatUpdated ActionType = "session/chatUpdated"
29
+ ActionTypeSessionDefaultChatChanged ActionType = "session/defaultChatChanged"
30
+ ActionTypeChatTurnStarted ActionType = "chat/turnStarted"
31
+ ActionTypeChatDelta ActionType = "chat/delta"
32
+ ActionTypeChatResponsePart ActionType = "chat/responsePart"
33
+ ActionTypeChatToolCallStart ActionType = "chat/toolCallStart"
34
+ ActionTypeChatToolCallDelta ActionType = "chat/toolCallDelta"
35
+ ActionTypeChatToolCallReady ActionType = "chat/toolCallReady"
36
+ ActionTypeChatToolCallConfirmed ActionType = "chat/toolCallConfirmed"
37
+ ActionTypeChatToolCallComplete ActionType = "chat/toolCallComplete"
38
+ ActionTypeChatToolCallResultConfirmed ActionType = "chat/toolCallResultConfirmed"
39
+ ActionTypeChatToolCallContentChanged ActionType = "chat/toolCallContentChanged"
40
+ ActionTypeChatToolCallAuthRequired ActionType = "chat/toolCallAuthRequired"
41
+ ActionTypeChatToolCallAuthResolved ActionType = "chat/toolCallAuthResolved"
42
+ ActionTypeChatTurnComplete ActionType = "chat/turnComplete"
43
+ ActionTypeChatTurnCancelled ActionType = "chat/turnCancelled"
44
+ ActionTypeChatError ActionType = "chat/error"
45
+ ActionTypeChatTurnResume ActionType = "chat/turnResume"
46
+ ActionTypeChatActivityChanged ActionType = "chat/activityChanged"
47
+ ActionTypeChatChangesetsChanged ActionType = "chat/changesetsChanged"
48
+ ActionTypeChatWorkingDirectorySet ActionType = "chat/workingDirectorySet"
49
+ ActionTypeChatWorkingDirectoryRemoved ActionType = "chat/workingDirectoryRemoved"
50
+ ActionTypeSessionTitleChanged ActionType = "session/titleChanged"
51
+ ActionTypeChatUsage ActionType = "chat/usage"
52
+ ActionTypeChatReasoning ActionType = "chat/reasoning"
53
+ ActionTypeSessionServerToolsChanged ActionType = "session/serverToolsChanged"
54
+ ActionTypeSessionActiveClientSet ActionType = "session/activeClientSet"
55
+ ActionTypeSessionActiveClientRemoved ActionType = "session/activeClientRemoved"
56
+ ActionTypeSessionWorkingDirectorySet ActionType = "session/workingDirectorySet"
57
+ ActionTypeSessionWorkingDirectoryRemoved ActionType = "session/workingDirectoryRemoved"
58
+ ActionTypeSessionWorkingDirectoryReplaced ActionType = "session/workingDirectoryReplaced"
59
+ ActionTypeSessionInputNeededSet ActionType = "session/inputNeededSet"
60
+ ActionTypeSessionInputNeededRemoved ActionType = "session/inputNeededRemoved"
61
+ ActionTypeChatPendingMessageSet ActionType = "chat/pendingMessageSet"
62
+ ActionTypeChatPendingMessageRemoved ActionType = "chat/pendingMessageRemoved"
63
+ ActionTypeChatQueuedMessagesReordered ActionType = "chat/queuedMessagesReordered"
64
+ ActionTypeChatDraftChanged ActionType = "chat/draftChanged"
65
+ ActionTypeChatIsArchivedChanged ActionType = "chat/isArchivedChanged"
66
+ ActionTypeChatInputRequested ActionType = "chat/inputRequested"
67
+ ActionTypeChatInputAnswerChanged ActionType = "chat/inputAnswerChanged"
68
+ ActionTypeChatInputCompleted ActionType = "chat/inputCompleted"
69
+ ActionTypeSessionCustomizationsChanged ActionType = "session/customizationsChanged"
70
+ ActionTypeSessionCustomizationToggled ActionType = "session/customizationToggled"
71
+ ActionTypeSessionCustomizationUpdated ActionType = "session/customizationUpdated"
72
+ ActionTypeSessionCustomizationRemoved ActionType = "session/customizationRemoved"
73
+ ActionTypeSessionMcpServerStateChanged ActionType = "session/mcpServerStateChanged"
74
+ ActionTypeSessionMcpServerStartRequested ActionType = "session/mcpServerStartRequested"
75
+ ActionTypeSessionMcpServerStopRequested ActionType = "session/mcpServerStopRequested"
76
+ ActionTypeSessionMcpServerBackgroundRequested ActionType = "session/mcpServerBackgroundRequested"
77
+ ActionTypeChatTruncated ActionType = "chat/truncated"
78
+ ActionTypeChatTurnsLoaded ActionType = "chat/turnsLoaded"
79
+ ActionTypeSessionIsReadChanged ActionType = "session/isReadChanged"
80
+ ActionTypeSessionIsArchivedChanged ActionType = "session/isArchivedChanged"
81
+ ActionTypeSessionActivityChanged ActionType = "session/activityChanged"
82
+ ActionTypeSessionChangesetsChanged ActionType = "session/changesetsChanged"
83
+ ActionTypeSessionConfigChanged ActionType = "session/configChanged"
84
+ ActionTypeSessionMetaChanged ActionType = "session/metaChanged"
85
+ ActionTypeChangesetStatusChanged ActionType = "changeset/statusChanged"
86
+ ActionTypeChangesetFileSet ActionType = "changeset/fileSet"
87
+ ActionTypeChangesetFileRemoved ActionType = "changeset/fileRemoved"
88
+ ActionTypeChangesetFilesReviewChanged ActionType = "changeset/filesReviewChanged"
89
+ ActionTypeChangesetContentChanged ActionType = "changeset/contentChanged"
90
+ ActionTypeChangesetOperationsChanged ActionType = "changeset/operationsChanged"
91
+ ActionTypeChangesetOperationStatusChanged ActionType = "changeset/operationStatusChanged"
92
+ ActionTypeChangesetCleared ActionType = "changeset/cleared"
93
+ ActionTypeAnnotationsSet ActionType = "annotations/set"
94
+ ActionTypeAnnotationsUpdated ActionType = "annotations/updated"
95
+ ActionTypeAnnotationsRemoved ActionType = "annotations/removed"
96
+ ActionTypeAnnotationsEntrySet ActionType = "annotations/entrySet"
97
+ ActionTypeAnnotationsEntryRemoved ActionType = "annotations/entryRemoved"
98
+ ActionTypeRootTerminalsChanged ActionType = "root/terminalsChanged"
99
+ ActionTypeRootConfigChanged ActionType = "root/configChanged"
100
+ ActionTypeTerminalData ActionType = "terminal/data"
101
+ ActionTypeTerminalInput ActionType = "terminal/input"
102
+ ActionTypeTerminalResized ActionType = "terminal/resized"
103
+ ActionTypeTerminalClaimed ActionType = "terminal/claimed"
104
+ ActionTypeTerminalTitleChanged ActionType = "terminal/titleChanged"
105
+ ActionTypeTerminalCwdChanged ActionType = "terminal/cwdChanged"
106
+ ActionTypeTerminalExited ActionType = "terminal/exited"
107
+ ActionTypeTerminalCleared ActionType = "terminal/cleared"
108
+ ActionTypeTerminalCommandDetectionAvailable ActionType = "terminal/commandDetectionAvailable"
109
+ ActionTypeTerminalCommandExecuted ActionType = "terminal/commandExecuted"
110
+ ActionTypeTerminalCommandFinished ActionType = "terminal/commandFinished"
111
+ ActionTypeResourceWatchChanged ActionType = "resourceWatch/changed"
112
+ ActionTypeAutomationCreateRequested ActionType = "automation/createRequested"
113
+ ActionTypeAutomationUpdateRequested ActionType = "automation/updateRequested"
114
+ ActionTypeAutomationSet ActionType = "automation/set"
115
+ ActionTypeAutomationRemoved ActionType = "automation/removed"
116
+ ActionTypeAutomationRunLifecycleChanged ActionType = "automationRun/lifecycleChanged"
117
+ ActionTypeAutomationRunSessionSet ActionType = "automationRun/sessionSet"
118
+ ActionTypeAutomationRunSessionRemoved ActionType = "automationRun/sessionRemoved"
119
+ ActionTypeAutomationRunPrimarySessionChanged ActionType = "automationRun/primarySessionChanged"
120
+ ActionTypeAutomationRunCancelRequested ActionType = "automationRun/cancelRequested"
121
+ )
122
+
123
+ // ─── Action Envelope ─────────────────────────────────────────────────
124
+
125
+ // Identifies the client that originally dispatched an action.
126
+ type ActionOrigin struct {
127
+ ClientId string `json:"clientId"`
128
+ ClientSeq int64 `json:"clientSeq"`
129
+ }
130
+
131
+ // ActionEnvelope wraps every action with the channel URI it
132
+ // belongs to, the server-assigned monotonic sequence number, and an
133
+ // optional origin record.
134
+ type ActionEnvelope struct {
135
+ Channel URI `json:"channel"`
136
+ Action StateAction `json:"action"`
137
+ ServerSeq int64 `json:"serverSeq"`
138
+ Origin *ActionOrigin `json:"origin,omitempty"`
139
+ RejectionReason *string `json:"rejectionReason,omitempty"`
140
+ }
141
+
142
+ // ─── Action Payloads ─────────────────────────────────────────────────
143
+
144
+ // Fired when available agent backends or their models change.
145
+ type RootAgentsChangedAction struct {
146
+ Type ActionType `json:"type"`
147
+ // Updated agent list
148
+ Agents []AgentInfo `json:"agents"`
149
+ }
150
+
151
+ // Fired when the number of active sessions changes.
152
+ type RootActiveSessionsChangedAction struct {
153
+ Type ActionType `json:"type"`
154
+ // Current count of active sessions
155
+ ActiveSessions int64 `json:"activeSessions"`
156
+ }
157
+
158
+ // Fired when agent-host configuration values change.
159
+ //
160
+ // By default, the reducer merges the new values into `state.config.values`.
161
+ // Set `replace` to `true` to replace all values instead of merging.
162
+ type RootConfigChangedAction struct {
163
+ Type ActionType `json:"type"`
164
+ // Updated config values
165
+ Config map[string]json.RawMessage `json:"config"`
166
+ // When `true`, replaces all config values instead of merging
167
+ Replace *bool `json:"replace,omitempty"`
168
+ }
169
+
170
+ // Session backend initialized successfully.
171
+ type SessionReadyAction struct {
172
+ Type ActionType `json:"type"`
173
+ }
174
+
175
+ // Session backend failed to initialize.
176
+ type SessionCreationFailedAction struct {
177
+ Type ActionType `json:"type"`
178
+ // Error details
179
+ Error ErrorInfo `json:"error"`
180
+ }
181
+
182
+ // A chat was added to this session's catalog. Upsert semantics: if a chat
183
+ // with the same `summary.resource` already exists, the existing entry is
184
+ // replaced.
185
+ //
186
+ // Mirrors the root-channel `root/sessionAdded` notification.
187
+ type SessionChatAddedAction struct {
188
+ Type ActionType `json:"type"`
189
+ // The full summary of the newly added (or upserted) chat.
190
+ Summary ChatSummary `json:"summary"`
191
+ }
192
+
193
+ // A chat was removed from this session's catalog. No-op when no entry matches.
194
+ //
195
+ // Mirrors the root-channel `root/sessionRemoved` notification.
196
+ type SessionChatRemovedAction struct {
197
+ Type ActionType `json:"type"`
198
+ // The URI of the chat to remove.
199
+ Chat URI `json:"chat"`
200
+ }
201
+
202
+ // One existing chat's summary fields changed.
203
+ //
204
+ // Partial-update semantics: only fields present in `changes` are written;
205
+ // omitted fields are preserved. Identity fields (`resource`) MUST NOT be
206
+ // carried in `changes`. No-op when no entry with `chat` exists — clients
207
+ // SHOULD then wait for a {@link SessionChatAddedAction | `session/chatAdded`}.
208
+ //
209
+ // Mirrors the root-channel `root/sessionSummaryChanged` notification.
210
+ type SessionChatUpdatedAction struct {
211
+ Type ActionType `json:"type"`
212
+ // The URI of the chat whose summary changed.
213
+ Chat URI `json:"chat"`
214
+ // Mutable summary fields that changed; omitted fields are unchanged.
215
+ //
216
+ // Identity fields (`resource`) never change and MUST be omitted by
217
+ // senders; receivers SHOULD ignore them if present.
218
+ Changes PartialChatSummary `json:"changes"`
219
+ }
220
+
221
+ // The default chat input-routing hint for this session changed.
222
+ type SessionDefaultChatChangedAction struct {
223
+ Type ActionType `json:"type"`
224
+ // New default chat URI, or `undefined` to clear the hint.
225
+ DefaultChat *URI `json:"defaultChat,omitempty"`
226
+ }
227
+
228
+ // A new message has been sent to the agent, and a new turn starts.
229
+ //
230
+ // A client is only allowed to send {@link MessageKind.User} messages.
231
+ type ChatTurnStartedAction struct {
232
+ Type ActionType `json:"type"`
233
+ // Turn identifier
234
+ TurnId string `json:"turnId"`
235
+ // ISO 8601 timestamp when this turn started.
236
+ StartedAt string `json:"startedAt"`
237
+ // The new message
238
+ Message Message `json:"message"`
239
+ // If this turn was auto-started from a queued message, the ID of that message
240
+ QueuedMessageId *string `json:"queuedMessageId,omitempty"`
241
+ // Additional provider-specific metadata for this action.
242
+ //
243
+ // Clients MAY look for well-known keys here to provide enhanced UI, and
244
+ // agent hosts MAY use it to carry per-event context that does not fit any
245
+ // other field — for example, attributing the event to a specific agent
246
+ // (such as a sub-agent acting within the turn). Mirrors the MCP `_meta`
247
+ // convention.
248
+ Meta map[string]json.RawMessage `json:"_meta,omitempty"`
249
+ }
250
+
251
+ // Streaming text chunk from the assistant, appended to a specific response part.
252
+ //
253
+ // The server MUST first emit a `chat/responsePart` to create the target
254
+ // markdown part, then use this action to append text to it.
255
+ type ChatDeltaAction struct {
256
+ Type ActionType `json:"type"`
257
+ // Turn identifier
258
+ TurnId string `json:"turnId"`
259
+ // Identifier of the response part to append to
260
+ PartId string `json:"partId"`
261
+ // Text chunk
262
+ Content string `json:"content"`
263
+ // Additional provider-specific metadata for this action.
264
+ //
265
+ // Clients MAY look for well-known keys here to provide enhanced UI, and
266
+ // agent hosts MAY use it to carry per-event context that does not fit any
267
+ // other field — for example, attributing the event to a specific agent
268
+ // (such as a sub-agent acting within the turn). Mirrors the MCP `_meta`
269
+ // convention.
270
+ Meta map[string]json.RawMessage `json:"_meta,omitempty"`
271
+ }
272
+
273
+ // Structured content appended to the response.
274
+ //
275
+ // An {@link ErrorResponsePart} MUST be appended with {@link ChatErrorAction}
276
+ // instead so adding the part and ending the turn are one atomic transition.
277
+ type ChatResponsePartAction struct {
278
+ Type ActionType `json:"type"`
279
+ // Turn identifier
280
+ TurnId string `json:"turnId"`
281
+ // Response part to append; error parts are ignored.
282
+ Part ResponsePart `json:"part"`
283
+ // Additional provider-specific metadata for this action.
284
+ //
285
+ // Clients MAY look for well-known keys here to provide enhanced UI, and
286
+ // agent hosts MAY use it to carry per-event context that does not fit any
287
+ // other field — for example, attributing the event to a specific agent
288
+ // (such as a sub-agent acting within the turn). Mirrors the MCP `_meta`
289
+ // convention.
290
+ Meta map[string]json.RawMessage `json:"_meta,omitempty"`
291
+ }
292
+
293
+ // A tool call begins — parameters are streaming from the LM.
294
+ //
295
+ // The server sets {@link ToolCallContributor | `contributor`} to identify
296
+ // the origin of the tool. For client-provided tools, the named client is
297
+ // responsible for executing the tool once it reaches the `running` state
298
+ // and dispatching `chat/toolCallComplete`. For MCP-served tools, the
299
+ // server executes the call against the named `McpServerCustomization`.
300
+ type ChatToolCallStartAction struct {
301
+ // Turn identifier
302
+ TurnId string `json:"turnId"`
303
+ // Tool call identifier
304
+ ToolCallId string `json:"toolCallId"`
305
+ // Additional provider-specific metadata for this tool call.
306
+ //
307
+ // Clients MAY look for well-known keys here to provide enhanced UI.
308
+ // For example, a `ptyTerminal` key with `{ input: string; output: string }`
309
+ // indicates the tool operated on a terminal (both `input` and `output` may
310
+ // contain escape sequences).
311
+ Meta map[string]json.RawMessage `json:"_meta,omitempty"`
312
+ Type ActionType `json:"type"`
313
+ // Internal tool name (for debugging/logging)
314
+ ToolName string `json:"toolName"`
315
+ // Human-readable tool name
316
+ DisplayName string `json:"displayName"`
317
+ // Human-readable description of what the tool invocation intends to do
318
+ Intention *string `json:"intention,omitempty"`
319
+ // Reference to the contributor of the tool being called. Absent for
320
+ // server-side tools that are not contributed by a client or MCP server.
321
+ Contributor *ToolCallContributor `json:"contributor,omitempty"`
322
+ }
323
+
324
+ // Streaming partial parameters for a tool call.
325
+ type ChatToolCallDeltaAction struct {
326
+ // Turn identifier
327
+ TurnId string `json:"turnId"`
328
+ // Tool call identifier
329
+ ToolCallId string `json:"toolCallId"`
330
+ // Additional provider-specific metadata for this tool call.
331
+ //
332
+ // Clients MAY look for well-known keys here to provide enhanced UI.
333
+ // For example, a `ptyTerminal` key with `{ input: string; output: string }`
334
+ // indicates the tool operated on a terminal (both `input` and `output` may
335
+ // contain escape sequences).
336
+ Meta map[string]json.RawMessage `json:"_meta,omitempty"`
337
+ Type ActionType `json:"type"`
338
+ // Partial parameter content to append, if provided by the host.
339
+ Content *string `json:"content,omitempty"`
340
+ // Updated progress message
341
+ InvocationMessage *StringOrMarkdown `json:"invocationMessage,omitempty"`
342
+ }
343
+
344
+ // Tool call parameters are complete, or a running tool requires re-confirmation.
345
+ //
346
+ // When dispatched for a `streaming` tool call, transitions to `pending-confirmation`
347
+ // or directly to `running` if `confirmed` is set.
348
+ //
349
+ // When dispatched for a `running` tool call (e.g. mid-execution permission needed),
350
+ // transitions back to `pending-confirmation`. The `invocationMessage` and `_meta`
351
+ // SHOULD be updated to describe the specific confirmation needed. Clients use the
352
+ // standard `chat/toolCallConfirmed` flow to approve or deny.
353
+ //
354
+ // For client-provided tools, the server typically sets `confirmed` to
355
+ // `'not-needed'` so the tool transitions directly to `running`, where the
356
+ // owning client can begin execution immediately.
357
+ type ChatToolCallReadyAction struct {
358
+ // Turn identifier
359
+ TurnId string `json:"turnId"`
360
+ // Tool call identifier
361
+ ToolCallId string `json:"toolCallId"`
362
+ // Additional provider-specific metadata for this tool call.
363
+ //
364
+ // Clients MAY look for well-known keys here to provide enhanced UI.
365
+ // For example, a `ptyTerminal` key with `{ input: string; output: string }`
366
+ // indicates the tool operated on a terminal (both `input` and `output` may
367
+ // contain escape sequences).
368
+ Meta map[string]json.RawMessage `json:"_meta,omitempty"`
369
+ Type ActionType `json:"type"`
370
+ // Final contributor metadata. MUST NOT change execution ownership established
371
+ // at `chat/toolCallStart`; a client contributor must keep the same `clientId`.
372
+ Contributor *ToolCallContributor `json:"contributor,omitempty"`
373
+ // Final human-readable description of what the tool invocation intends to do.
374
+ // When present, replaces the provisional intention from `chat/toolCallStart`.
375
+ Intention *string `json:"intention,omitempty"`
376
+ // Message describing what the tool will do or what confirmation is needed
377
+ InvocationMessage StringOrMarkdown `json:"invocationMessage"`
378
+ // Final tool input
379
+ ToolInput *ToolInput `json:"toolInput,omitempty"`
380
+ // Short title for the confirmation prompt (e.g. `"Run in terminal"`, `"Write file"`)
381
+ ConfirmationTitle *StringOrMarkdown `json:"confirmationTitle,omitempty"`
382
+ // Risk assessment that informed the confirmation requirement.
383
+ RiskAssessment *ToolCallRiskAssessment `json:"riskAssessment,omitempty"`
384
+ // File edits that this tool call will perform, for preview before confirmation
385
+ Edits *FileEditCollection `json:"edits,omitempty"`
386
+ // Whether the agent host allows the client to edit the tool's input parameters before confirming
387
+ Editable *bool `json:"editable,omitempty"`
388
+ // If set, the tool was auto-confirmed and transitions directly to `running`
389
+ Confirmed *ToolCallConfirmationReason `json:"confirmed,omitempty"`
390
+ // Options the server offers for this confirmation. When present, the client
391
+ // SHOULD render these instead of a plain approve/deny UI. Each option
392
+ // belongs to a {@link ConfirmationOptionGroup} so the client can still
393
+ // categorise the choices.
394
+ Options []ConfirmationOption `json:"options,omitempty"`
395
+ }
396
+
397
+ // ChatToolCallConfirmedAction is the client approves or denies a
398
+ // pending tool call (merged approved + denied variants on the wire).
399
+ type ChatToolCallConfirmedAction struct {
400
+ Type ActionType `json:"type"`
401
+ TurnId string `json:"turnId"`
402
+ ToolCallId string `json:"toolCallId"`
403
+ Meta map[string]json.RawMessage `json:"_meta,omitempty"`
404
+ Approved bool `json:"approved"`
405
+ Confirmed *ToolCallConfirmationReason `json:"confirmed,omitempty"`
406
+ Reason *ToolCallCancellationReason `json:"reason,omitempty"`
407
+ EditedToolInput *string `json:"editedToolInput,omitempty"`
408
+ UserSuggestion *Message `json:"userSuggestion,omitempty"`
409
+ ReasonMessage *StringOrMarkdown `json:"reasonMessage,omitempty"`
410
+ SelectedOptionId *string `json:"selectedOptionId,omitempty"`
411
+ }
412
+
413
+ // Tool execution finished. Transitions to `completed` or `pending-result-confirmation`
414
+ // if `requiresResultConfirmation` is `true`.
415
+ //
416
+ // For client-provided tools (whose tool call state carries a client
417
+ // `ToolCallContributor` with a `clientId`), the owning client dispatches this
418
+ // action with the execution result. The server SHOULD reject this action if the
419
+ // dispatching client does not match the contributor's `clientId`.
420
+ //
421
+ // Servers waiting on a client tool call MAY time out after a reasonable duration
422
+ // if the implementing client disconnects or becomes unresponsive, and dispatch
423
+ // this action with `result.success = false` and an appropriate error.
424
+ //
425
+ // A client MAY also dispatch this action with a **failed** result (
426
+ // `result.success: false`) for a tool call currently in `auth-required`
427
+ // status, to cancel that invocation without completing the pending MCP
428
+ // authentication challenge. This always transitions the tool call straight
429
+ // to `completed`, preserving the fields it had before pausing for auth;
430
+ // `requiresResultConfirmation` is ignored for this transition; the
431
+ // cancellation can never enter `pending-result-confirmation`, since there is
432
+ // no real result to review.
433
+ //
434
+ // A **successful** result (`result.success: true`) is invalid for a tool
435
+ // call in `auth-required` status — execution never resumed after the
436
+ // challenge, so there's nothing that could have produced it. The reducer
437
+ // MUST reject/ignore it as a no-op, leaving the tool call in
438
+ // `auth-required`. The client must resolve the auth challenge
439
+ // (`chat/toolCallAuthResolved`) before completing successfully.
440
+ type ChatToolCallCompleteAction struct {
441
+ // Turn identifier
442
+ TurnId string `json:"turnId"`
443
+ // Tool call identifier
444
+ ToolCallId string `json:"toolCallId"`
445
+ // Additional provider-specific metadata for this tool call.
446
+ //
447
+ // Clients MAY look for well-known keys here to provide enhanced UI.
448
+ // For example, a `ptyTerminal` key with `{ input: string; output: string }`
449
+ // indicates the tool operated on a terminal (both `input` and `output` may
450
+ // contain escape sequences).
451
+ Meta map[string]json.RawMessage `json:"_meta,omitempty"`
452
+ Type ActionType `json:"type"`
453
+ // Execution result
454
+ Result ToolCallResult `json:"result"`
455
+ // If true, the result requires client approval before finalizing
456
+ RequiresResultConfirmation *bool `json:"requiresResultConfirmation,omitempty"`
457
+ }
458
+
459
+ // Client approves or denies a tool's result.
460
+ //
461
+ // If `approved` is `false`, the tool transitions to `cancelled` with reason `result-denied`.
462
+ type ChatToolCallResultConfirmedAction struct {
463
+ // Turn identifier
464
+ TurnId string `json:"turnId"`
465
+ // Tool call identifier
466
+ ToolCallId string `json:"toolCallId"`
467
+ // Additional provider-specific metadata for this tool call.
468
+ //
469
+ // Clients MAY look for well-known keys here to provide enhanced UI.
470
+ // For example, a `ptyTerminal` key with `{ input: string; output: string }`
471
+ // indicates the tool operated on a terminal (both `input` and `output` may
472
+ // contain escape sequences).
473
+ Meta map[string]json.RawMessage `json:"_meta,omitempty"`
474
+ Type ActionType `json:"type"`
475
+ // Whether the result was approved
476
+ Approved bool `json:"approved"`
477
+ }
478
+
479
+ // Partial content produced while a tool is still executing.
480
+ //
481
+ // Replaces the `content` array on the running tool call state. Clients can
482
+ // use this to display live feedback (e.g. a terminal reference) before the
483
+ // tool completes.
484
+ //
485
+ // For client-provided tools (whose tool call state carries a client
486
+ // `ToolCallContributor` with a `clientId`), the owning client dispatches this
487
+ // action to stream intermediate content while executing. The server SHOULD
488
+ // reject this action if the dispatching client does not match the contributor's
489
+ // `clientId`.
490
+ type ChatToolCallContentChangedAction struct {
491
+ // Turn identifier
492
+ TurnId string `json:"turnId"`
493
+ // Tool call identifier
494
+ ToolCallId string `json:"toolCallId"`
495
+ // Additional provider-specific metadata for this tool call.
496
+ //
497
+ // Clients MAY look for well-known keys here to provide enhanced UI.
498
+ // For example, a `ptyTerminal` key with `{ input: string; output: string }`
499
+ // indicates the tool operated on a terminal (both `input` and `output` may
500
+ // contain escape sequences).
501
+ Meta map[string]json.RawMessage `json:"_meta,omitempty"`
502
+ Type ActionType `json:"type"`
503
+ // The current partial content for the running tool call
504
+ Content []ToolResultContent `json:"content"`
505
+ }
506
+
507
+ // A running tool call is paused pending MCP authentication. Transitions the
508
+ // tool call from `running` to `auth-required`.
509
+ //
510
+ // The server dispatches this when the MCP server backing the call responds
511
+ // with a 401/403 challenge mid-execution (see
512
+ // {@link McpAuthRequirement.reason | `insufficientScope`}). The host SHOULD
513
+ // pair this with `session/inputNeededSet` (kind `toolAuthentication`) so the
514
+ // block is visible at the session-summary level, mirroring
515
+ // {@link McpServerAuthRequiredState}'s own `InputNeeded` guidance.
516
+ //
517
+ // Only valid for tool calls contributed by an MCP server — the reducer is a
518
+ // no-op if the tool call's `contributor` is not
519
+ // {@link ToolCallContributorKind.MCP | MCP-kind}.
520
+ type ChatToolCallAuthRequiredAction struct {
521
+ // Turn identifier
522
+ TurnId string `json:"turnId"`
523
+ // Tool call identifier
524
+ ToolCallId string `json:"toolCallId"`
525
+ // Additional provider-specific metadata for this tool call.
526
+ //
527
+ // Clients MAY look for well-known keys here to provide enhanced UI.
528
+ // For example, a `ptyTerminal` key with `{ input: string; output: string }`
529
+ // indicates the tool operated on a terminal (both `input` and `output` may
530
+ // contain escape sequences).
531
+ Meta map[string]json.RawMessage `json:"_meta,omitempty"`
532
+ Type ActionType `json:"type"`
533
+ // The authentication challenge blocking this invocation.
534
+ Auth McpAuthRequirement `json:"auth"`
535
+ }
536
+
537
+ // The authentication challenge blocking a tool call has been resolved (the
538
+ // client pushed a token via `authenticate` and the host validated it).
539
+ // Transitions the tool call from `auth-required` back to `running`,
540
+ // preserving the fields it had before pausing.
541
+ //
542
+ // The host SHOULD remove the corresponding `session/inputNeededSet` entry
543
+ // (kind `toolAuthentication`) once this is dispatched.
544
+ type ChatToolCallAuthResolvedAction struct {
545
+ // Turn identifier
546
+ TurnId string `json:"turnId"`
547
+ // Tool call identifier
548
+ ToolCallId string `json:"toolCallId"`
549
+ // Additional provider-specific metadata for this tool call.
550
+ //
551
+ // Clients MAY look for well-known keys here to provide enhanced UI.
552
+ // For example, a `ptyTerminal` key with `{ input: string; output: string }`
553
+ // indicates the tool operated on a terminal (both `input` and `output` may
554
+ // contain escape sequences).
555
+ Meta map[string]json.RawMessage `json:"_meta,omitempty"`
556
+ Type ActionType `json:"type"`
557
+ }
558
+
559
+ // Turn finished — the assistant is idle.
560
+ type ChatTurnCompleteAction struct {
561
+ Type ActionType `json:"type"`
562
+ // Turn identifier
563
+ TurnId string `json:"turnId"`
564
+ // Elapsed turn duration in milliseconds, measured by the producer's own
565
+ // clock. Clients MUST NOT derive this by subtracting timestamps — cross-
566
+ // client clocks may differ — and MUST treat it as opaque, producer-supplied
567
+ // data.
568
+ Duration int64 `json:"duration"`
569
+ // Additional provider-specific metadata for this action.
570
+ //
571
+ // Clients MAY look for well-known keys here to provide enhanced UI, and
572
+ // agent hosts MAY use it to carry per-event context that does not fit any
573
+ // other field — for example, attributing the event to a specific agent
574
+ // (such as a sub-agent acting within the turn). Mirrors the MCP `_meta`
575
+ // convention.
576
+ Meta map[string]json.RawMessage `json:"_meta,omitempty"`
577
+ }
578
+
579
+ // Turn was aborted; server stops processing.
580
+ type ChatTurnCancelledAction struct {
581
+ Type ActionType `json:"type"`
582
+ // Turn identifier
583
+ TurnId string `json:"turnId"`
584
+ // Elapsed turn duration in milliseconds, measured by the producer's own
585
+ // clock. Clients MUST NOT derive this by subtracting timestamps — cross-
586
+ // client clocks may differ — and MUST treat it as opaque, producer-supplied
587
+ // data.
588
+ Duration int64 `json:"duration"`
589
+ // Additional provider-specific metadata for this action.
590
+ //
591
+ // Clients MAY look for well-known keys here to provide enhanced UI, and
592
+ // agent hosts MAY use it to carry per-event context that does not fit any
593
+ // other field — for example, attributing the event to a specific agent
594
+ // (such as a sub-agent acting within the turn). Mirrors the MCP `_meta`
595
+ // convention.
596
+ Meta map[string]json.RawMessage `json:"_meta,omitempty"`
597
+ }
598
+
599
+ // Error during turn processing.
600
+ type ChatErrorAction struct {
601
+ Type ActionType `json:"type"`
602
+ // Turn identifier
603
+ TurnId string `json:"turnId"`
604
+ // Elapsed turn duration in milliseconds, measured by the producer's own
605
+ // clock. Clients MUST NOT derive this by subtracting timestamps — cross-
606
+ // client clocks may differ — and MUST treat it as opaque, producer-supplied
607
+ // data.
608
+ Duration int64 `json:"duration"`
609
+ // Error part to append to the response stream before finalizing the turn.
610
+ // Its optional `resumable` flag indicates whether the turn can be resumed.
611
+ Part ErrorResponsePart `json:"part"`
612
+ // Additional provider-specific metadata for this action.
613
+ //
614
+ // Clients MAY look for well-known keys here to provide enhanced UI, and
615
+ // agent hosts MAY use it to carry per-event context that does not fit any
616
+ // other field — for example, attributing the event to a specific agent
617
+ // (such as a sub-agent acting within the turn). Mirrors the MCP `_meta`
618
+ // convention.
619
+ Meta map[string]json.RawMessage `json:"_meta,omitempty"`
620
+ }
621
+
622
+ // Resumes the latest errored turn without adding another message.
623
+ //
624
+ // The turn MUST be the latest turn, its state MUST be `error`, and its final
625
+ // response part MUST be a resumable error. The reducer reopens the same turn
626
+ // with its existing message, response parts, and usage intact. The host then
627
+ // resumes the provider's execution for that turn.
628
+ type ChatTurnResumeAction struct {
629
+ Type ActionType `json:"type"`
630
+ // Identifier of the errored turn.
631
+ TurnId string `json:"turnId"`
632
+ }
633
+
634
+ // The activity description of this chat changed.
635
+ //
636
+ // Dispatched by the server to indicate what the chat is currently doing
637
+ // (e.g. running a tool, thinking). Clear activity by omitting it or setting it
638
+ // to `undefined`.
639
+ // Producers SHOULD also update the parent session's chat catalog with
640
+ // `session/chatUpdated` so `ChatSummary.activity` stays in sync.
641
+ type ChatActivityChangedAction struct {
642
+ Type ActionType `json:"type"`
643
+ // Human-readable description of current activity; omit or set `undefined` to clear
644
+ Activity *string `json:"activity,omitempty"`
645
+ }
646
+
647
+ // The {@link Changeset | catalogue of changesets} the agent host advertises
648
+ // for this chat changed. Replaces
649
+ // {@link ChatState.changesets | `state.changesets`} entirely
650
+ // (full-replacement semantics) — set to `undefined` to clear the catalogue.
651
+ //
652
+ // Entries SHOULD describe Branch, Uncommitted Changes, or other views scoped
653
+ // to the chat's effective {@link ChatState.workingDirectories | working
654
+ // directories}. Clients subscribe to each advertised changeset URI for
655
+ // file-level updates through the existing `changeset/*` action stream.
656
+ type ChatChangesetsChangedAction struct {
657
+ Type ActionType `json:"type"`
658
+ // New catalogue, or `undefined` to clear it.
659
+ Changesets []Changeset `json:"changesets,omitempty"`
660
+ }
661
+
662
+ // Session title updated. Fired by the server when the title is auto-generated
663
+ // from conversation, or dispatched by a client to rename a session.
664
+ type SessionTitleChangedAction struct {
665
+ Type ActionType `json:"type"`
666
+ // New title
667
+ Title string `json:"title"`
668
+ }
669
+
670
+ // Token usage report for a turn.
671
+ type ChatUsageAction struct {
672
+ Type ActionType `json:"type"`
673
+ // Turn identifier
674
+ TurnId string `json:"turnId"`
675
+ // Token usage data
676
+ Usage UsageInfo `json:"usage"`
677
+ // Additional provider-specific metadata for this action.
678
+ //
679
+ // Clients MAY look for well-known keys here to provide enhanced UI, and
680
+ // agent hosts MAY use it to carry per-event context that does not fit any
681
+ // other field — for example, attributing the event to a specific agent
682
+ // (such as a sub-agent acting within the turn). Mirrors the MCP `_meta`
683
+ // convention.
684
+ Meta map[string]json.RawMessage `json:"_meta,omitempty"`
685
+ }
686
+
687
+ // Reasoning/thinking text from the model, appended to a specific reasoning response part.
688
+ //
689
+ // The server MUST first emit a `chat/responsePart` to create the target
690
+ // reasoning part, then use this action to append text to it.
691
+ type ChatReasoningAction struct {
692
+ Type ActionType `json:"type"`
693
+ // Turn identifier
694
+ TurnId string `json:"turnId"`
695
+ // Identifier of the reasoning response part to append to
696
+ PartId string `json:"partId"`
697
+ // Reasoning text chunk
698
+ Content string `json:"content"`
699
+ // Additional provider-specific metadata for this action.
700
+ //
701
+ // Clients MAY look for well-known keys here to provide enhanced UI, and
702
+ // agent hosts MAY use it to carry per-event context that does not fit any
703
+ // other field — for example, attributing the event to a specific agent
704
+ // (such as a sub-agent acting within the turn). Mirrors the MCP `_meta`
705
+ // convention.
706
+ Meta map[string]json.RawMessage `json:"_meta,omitempty"`
707
+ }
708
+
709
+ // A pending message was set (upsert semantics: creates or replaces).
710
+ //
711
+ // For steering messages, this always replaces the single steering message.
712
+ // For queued messages, if a message with the given `id` already exists it is
713
+ // updated in place; otherwise it is appended to the queue. If the chat is
714
+ // idle when a queued message is set, the server SHOULD immediately consume it
715
+ // and start a new turn.
716
+ //
717
+ // A client is only allowed to send {@link MessageKind.User} messages.
718
+ type ChatPendingMessageSetAction struct {
719
+ Type ActionType `json:"type"`
720
+ // Whether this is a steering or queued message
721
+ Kind PendingMessageKind `json:"kind"`
722
+ // Unique identifier for this pending message
723
+ Id string `json:"id"`
724
+ // The message content
725
+ Message Message `json:"message"`
726
+ }
727
+
728
+ // A pending message was removed (steering or queued).
729
+ //
730
+ // Dispatched by clients to cancel a pending message, or by the server when
731
+ // it consumes a message (e.g. starting a turn from a queued message or
732
+ // injecting a steering message into the current turn).
733
+ type ChatPendingMessageRemovedAction struct {
734
+ Type ActionType `json:"type"`
735
+ // Whether this is a steering or queued message
736
+ Kind PendingMessageKind `json:"kind"`
737
+ // Identifier of the pending message to remove
738
+ Id string `json:"id"`
739
+ }
740
+
741
+ // Reorder the queued messages.
742
+ //
743
+ // The `order` array contains the IDs of queued messages in their new
744
+ // desired order. IDs not present in the current queue are ignored.
745
+ // Queued messages whose IDs are absent from `order` are appended at
746
+ // the end in their original relative order (so a client with a stale
747
+ // view of the queue never silently drops messages).
748
+ type ChatQueuedMessagesReorderedAction struct {
749
+ Type ActionType `json:"type"`
750
+ // Queued message IDs in the desired order
751
+ Order []string `json:"order"`
752
+ }
753
+
754
+ // The chat's draft input changed.
755
+ //
756
+ // Clients MAY periodically sync their local input state — the message the user
757
+ // is composing, including its {@link Message.model | model} /
758
+ // {@link Message.agent | agent} selection and attachments — into the chat's
759
+ // {@link ChatState.draft | `draft`} so it survives reloads and is visible to
760
+ // other clients viewing the same chat. Eager syncing is **not** required;
761
+ // clients SHOULD debounce and MAY sync only at convenient points. Set `draft`
762
+ // to `undefined` to clear it (e.g. once the message is sent).
763
+ //
764
+ // A client is only allowed to draft {@link MessageKind.User} messages.
765
+ type ChatDraftChangedAction struct {
766
+ Type ActionType `json:"type"`
767
+ // New draft message, or `undefined` to clear it
768
+ Draft *Message `json:"draft,omitempty"`
769
+ }
770
+
771
+ // The archived state of the chat changed.
772
+ //
773
+ // Dispatched by a client to archive a chat independently of its owning
774
+ // session or to restore it. Archiving the session's default chat is equivalent
775
+ // to archiving the session and SHOULD use `session/isArchivedChanged` instead.
776
+ type ChatIsArchivedChangedAction struct {
777
+ Type ActionType `json:"type"`
778
+ // Whether the chat is archived
779
+ IsArchived bool `json:"isArchived"`
780
+ }
781
+
782
+ // A session requested input from the user.
783
+ //
784
+ // Creates an unresolved {@link InputRequestResponsePart} in the active turn,
785
+ // or replaces the unresolved part with the same request `id`. Answer drafts
786
+ // are preserved unless `request.answers` is provided.
787
+ type ChatInputRequestedAction struct {
788
+ Type ActionType `json:"type"`
789
+ // Input request to create or replace
790
+ Request ChatInputRequest `json:"request"`
791
+ }
792
+
793
+ // A client updated, submitted, skipped, or removed a single in-progress answer.
794
+ //
795
+ // Dispatching with `answer: undefined` removes that question's answer draft.
796
+ type ChatInputAnswerChangedAction struct {
797
+ Type ActionType `json:"type"`
798
+ // Input request identifier
799
+ RequestId string `json:"requestId"`
800
+ // Question identifier within the input request
801
+ QuestionId string `json:"questionId"`
802
+ // Updated answer, or `undefined` to clear an answer draft
803
+ Answer *ChatInputAnswer `json:"answer,omitempty"`
804
+ }
805
+
806
+ // A client submitted an accept, decline, or cancel response to an input request.
807
+ //
808
+ // If accepted, the server uses `answers` (when provided) plus the request's
809
+ // synced answer state to resume the blocked operation. The reducer records the
810
+ // response and final answers on the existing {@link InputRequestResponsePart}.
811
+ type ChatInputCompletedAction struct {
812
+ Type ActionType `json:"type"`
813
+ // Input request identifier
814
+ RequestId string `json:"requestId"`
815
+ // Completion outcome
816
+ Response ChatInputResponseKind `json:"response"`
817
+ // Optional final answer replacement, keyed by question ID
818
+ Answers map[string]ChatInputAnswer `json:"answers,omitempty"`
819
+ }
820
+
821
+ // Truncates a session's history. If `turnId` is provided, all turns after that
822
+ // turn are removed and the specified turn is kept. If `turnId` is omitted, all
823
+ // turns are removed.
824
+ //
825
+ // If there is an active turn it is silently dropped and the chat status
826
+ // returns to `idle`.
827
+ //
828
+ // Common use-case: truncate old data then dispatch a new
829
+ // `chat/turnStarted` with an edited message.
830
+ type ChatTruncatedAction struct {
831
+ Type ActionType `json:"type"`
832
+ // Keep turns up to and including this turn. Omit to clear all turns.
833
+ TurnId *string `json:"turnId,omitempty"`
834
+ }
835
+
836
+ // Loads older completed turns into this chat's state.
837
+ //
838
+ // Hosts dispatch this before responding to `fetchTurns`, and before applying
839
+ // any operation that references a turn older than the currently loaded window.
840
+ // `turns` is ordered oldest-first and is prepended to the current `turns`
841
+ // window. `turnsNextCursor` replaces the state's cursor; omit it when all
842
+ // retained turns are now loaded.
843
+ type ChatTurnsLoadedAction struct {
844
+ Type ActionType `json:"type"`
845
+ // Older completed turns loaded into the state, ordered oldest-first.
846
+ Turns []Turn `json:"turns"`
847
+ // Opaque cursor for loading the next older page, if one remains.
848
+ TurnsNextCursor *string `json:"turnsNextCursor,omitempty"`
849
+ }
850
+
851
+ // The read state of the session changed.
852
+ //
853
+ // Dispatched by a client to mark a session as read (e.g. after viewing it)
854
+ // or unread (e.g. after new activity since the client last looked at it).
855
+ type SessionIsReadChangedAction struct {
856
+ Type ActionType `json:"type"`
857
+ // Whether the session has been read
858
+ IsRead bool `json:"isRead"`
859
+ }
860
+
861
+ // The archived state of the session changed.
862
+ //
863
+ // Dispatched by a client to archive a session (e.g. the task is
864
+ // complete) or to unarchive it.
865
+ type SessionIsArchivedChangedAction struct {
866
+ Type ActionType `json:"type"`
867
+ // Whether the session is archived
868
+ IsArchived bool `json:"isArchived"`
869
+ }
870
+
871
+ // The activity description of the session changed.
872
+ //
873
+ // Dispatched by the server to indicate what the session is currently doing
874
+ // (e.g. running a tool, thinking). Clear activity by setting it to `undefined`.
875
+ type SessionActivityChangedAction struct {
876
+ Type ActionType `json:"type"`
877
+ // Human-readable description of current activity, or `undefined` to clear
878
+ Activity *string `json:"activity,omitempty"`
879
+ }
880
+
881
+ // The {@link Changeset | catalogue of changesets} the agent host
882
+ // advertises for this session changed. Replaces
883
+ // {@link SessionState.changesets | `state.changesets`} entirely
884
+ // (full-replacement semantics) — set to `undefined` to clear the
885
+ // catalogue.
886
+ //
887
+ // Producers dispatch this whenever entries are added or removed. The
888
+ // fan-out happens through this action so observers see catalogue
889
+ // mutations in the same {@link ChangesetAction | per-changeset} action
890
+ // stream they already follow for file-level updates.
891
+ type SessionChangesetsChangedAction struct {
892
+ Type ActionType `json:"type"`
893
+ // New catalogue, or `undefined` to clear it
894
+ Changesets []Changeset `json:"changesets,omitempty"`
895
+ }
896
+
897
+ // Server tools for this session have changed.
898
+ //
899
+ // Full-replacement semantics: the `tools` array replaces the previous `serverTools` entirely.
900
+ type SessionServerToolsChangedAction struct {
901
+ Type ActionType `json:"type"`
902
+ // Updated server tools list (full replacement)
903
+ Tools []ToolDefinition `json:"tools"`
904
+ }
905
+
906
+ // An active client for this session was added or updated.
907
+ //
908
+ // Upsert semantics keyed by {@link SessionActiveClient.clientId | `clientId`}:
909
+ // a client dispatches this action with its own `SessionActiveClient` to join
910
+ // the session's active clients or refresh its entry, replacing any existing
911
+ // entry that has the same `clientId`. Multiple clients may be active at once.
912
+ // This is also how a client updates its published tools or customizations —
913
+ // re-dispatch with the full, updated entry. Use
914
+ // {@link SessionActiveClientRemovedAction | `session/activeClientRemoved`} to
915
+ // leave. The server SHOULD automatically dispatch that removal when an active
916
+ // client disconnects.
917
+ type SessionActiveClientSetAction struct {
918
+ Type ActionType `json:"type"`
919
+ // The active client to add or update, matched by `clientId`.
920
+ ActiveClient SessionActiveClient `json:"activeClient"`
921
+ }
922
+
923
+ // An active client was removed from this session.
924
+ //
925
+ // Removes the entry for the client identified by `clientId` from
926
+ // {@link SessionState.activeClients}; a no-op when no entry matches.
927
+ //
928
+ // The host SHOULD dispatch this automatically when a client stops participating
929
+ // in the session — for example when it unsubscribes from the session channel,
930
+ // when it disconnects and does not reconnect within a host-defined grace
931
+ // period, or when a `reconnect` command's `subscriptions` omit a session the
932
+ // client was still active in. When removing a client, the host SHOULD also
933
+ // cancel that client's in-flight tool calls — those whose tool call state
934
+ // carries a client `ToolCallContributor` with the matching `clientId` — by
935
+ // dispatching `chat/toolCallComplete` with `result.success = false`. (There is
936
+ // no per-tool-call server cancel; a failed completion is the cancellation
937
+ // mechanism, and the call ends in `completed` status with a failed result.)
938
+ type SessionActiveClientRemovedAction struct {
939
+ Type ActionType `json:"type"`
940
+ // The `clientId` of the active client to remove.
941
+ ClientId string `json:"clientId"`
942
+ }
943
+
944
+ // A working directory was added to the session's
945
+ // {@link SessionState.workingDirectories} set.
946
+ //
947
+ // Membership semantics keyed by the directory URI: the reducer appends
948
+ // `directory` when the set does not already contain it (creating the set if
949
+ // absent) and is a no-op when it is already present. Only valid when the agent
950
+ // advertises {@link AgentCapabilities.multipleWorkingDirectories}.
951
+ type SessionWorkingDirectorySetAction struct {
952
+ Type ActionType `json:"type"`
953
+ // The working directory to grant the session's agent tool access to.
954
+ Directory URI `json:"directory"`
955
+ }
956
+
957
+ // A working directory was removed from the session's
958
+ // {@link SessionState.workingDirectories} set.
959
+ //
960
+ // Removes `directory` from the set; a no-op when it is not present. There is no
961
+ // atomic backend "remove one" primitive — a host reconfigures its agent to the
962
+ // reduced set — so this action is safe to model as idempotent. A host MAY
963
+ // decline to apply the removal (e.g. an immutable primary directory, see
964
+ // {@link MultipleWorkingDirectoriesCapability.immutablePrimary}); it then leaves
965
+ // the set unchanged. When the agent advertises
966
+ // {@link MultipleWorkingDirectoriesCapability.primaryReplacement}, clients MUST
967
+ // NOT use this generic membership action to remove index `0`; the host MUST
968
+ // reject such a removal, leaving the protected slot intact.
969
+ type SessionWorkingDirectoryRemovedAction struct {
970
+ Type ActionType `json:"type"`
971
+ // The working directory to revoke the session's agent tool access to.
972
+ Directory URI `json:"directory"`
973
+ }
974
+
975
+ // Atomically replaces one of the session's working directories.
976
+ //
977
+ // This is a targeted compare-and-swap: the reducer is a no-op when
978
+ // {@link SessionState.workingDirectories} does not contain `directory`.
979
+ // Otherwise it replaces that entry with `replacement` and deduplicates the
980
+ // result, preserving every other directory's relative order. When
981
+ // `replacement` occurs after the target, it moves to the target's position;
982
+ // for example, `[A, B, C]` with `B → C` becomes `[A, C]`. When it occurs
983
+ // before the target, it retains its earlier position and the target is removed;
984
+ // `[A, B, C]` with `C → A` becomes `[A, B]`.
985
+ //
986
+ // Only valid when the agent advertises
987
+ // {@link AgentCapabilities.multipleWorkingDirectories}. Replacing index `0`
988
+ // additionally requires
989
+ // {@link MultipleWorkingDirectoriesCapability.primaryReplacement}; clients
990
+ // MUST NOT target an immutable primary. The host MUST validate and apply its
991
+ // backend side effect before broadcasting an accepted action, or reject it.
992
+ type SessionWorkingDirectoryReplacedAction struct {
993
+ Type ActionType `json:"type"`
994
+ // URI of the existing entry to replace.
995
+ Directory URI `json:"directory"`
996
+ // URI to place in the replaced entry's position.
997
+ Replacement URI `json:"replacement"`
998
+ }
999
+
1000
+ // A working directory was added to this chat's
1001
+ // {@link ChatState.workingDirectories} subset.
1002
+ //
1003
+ // Membership semantics keyed by the directory URI: the reducer appends
1004
+ // `directory` when the chat's subset does not already contain it (creating the
1005
+ // subset if absent) and is a no-op when it is already present. `directory` MUST
1006
+ // be one of the owning session's {@link SessionState.workingDirectories}; a host
1007
+ // MUST reject a directory that is not. Only valid when the agent advertises
1008
+ // {@link AgentCapabilities.multipleWorkingDirectories}.
1009
+ type ChatWorkingDirectorySetAction struct {
1010
+ Type ActionType `json:"type"`
1011
+ // The working directory to add to this chat's subset.
1012
+ Directory URI `json:"directory"`
1013
+ }
1014
+
1015
+ // A working directory was removed from this chat's
1016
+ // {@link ChatState.workingDirectories} subset.
1017
+ //
1018
+ // Removes `directory` from the chat's subset; a no-op when it is not present.
1019
+ // Idempotent, mirroring `session/workingDirectoryRemoved`. Only affects the
1020
+ // chat's subset — the directory remains in the session's set.
1021
+ type ChatWorkingDirectoryRemovedAction struct {
1022
+ Type ActionType `json:"type"`
1023
+ // The working directory to remove from this chat's subset.
1024
+ Directory URI `json:"directory"`
1025
+ }
1026
+
1027
+ // A session-level input request was added or updated.
1028
+ //
1029
+ // Upsert semantics keyed by {@link SessionInputRequest.id | `request.id`}: the
1030
+ // host dispatches this with the full {@link SessionInputRequest} to append a new
1031
+ // entry to {@link SessionState.inputNeeded} or replace the existing entry with
1032
+ // the same `id`.
1033
+ //
1034
+ // Server-originated: the host mirrors chat-level requests (elicitations, tool
1035
+ // confirmations, client-tool executions) into the session aggregate so clients
1036
+ // subscribed only to the session channel can discover them. Clients respond by
1037
+ // dispatching the ordinary `chat/*` action to the entry's `chat` channel — see
1038
+ // {@link SessionInputRequest}.
1039
+ type SessionInputNeededSetAction struct {
1040
+ Type ActionType `json:"type"`
1041
+ // The input request to add or update, matched by `id`.
1042
+ Request SessionInputRequest `json:"request"`
1043
+ }
1044
+
1045
+ // A session-level input request was removed.
1046
+ //
1047
+ // Removes the entry identified by `id` from
1048
+ // {@link SessionState.inputNeeded}; a no-op when no entry matches.
1049
+ //
1050
+ // Server-originated: the host dispatches this once the underlying request
1051
+ // resolves (the user answers, the tool call is confirmed, or the client
1052
+ // reports its result).
1053
+ type SessionInputNeededRemovedAction struct {
1054
+ Type ActionType `json:"type"`
1055
+ // The `id` of the input request to remove.
1056
+ Id string `json:"id"`
1057
+ }
1058
+
1059
+ // The session's customizations have changed.
1060
+ //
1061
+ // Full-replacement semantics: the `customizations` array replaces the
1062
+ // previous `customizations` entirely.
1063
+ type SessionCustomizationsChangedAction struct {
1064
+ Type ActionType `json:"type"`
1065
+ // Updated customization list (full replacement).
1066
+ Customizations []Customization `json:"customizations"`
1067
+ }
1068
+
1069
+ // A client updated a customization's enablement decisions.
1070
+ //
1071
+ // Matches `id` against every top-level customization first — a plugin or
1072
+ // directory container, or a bare top-level MCP server — then against the
1073
+ // children inside each container (a skill, agent, or other entry). Plugins
1074
+ // and MCP servers retain the matched entry's explicit decisions; other
1075
+ // entries update their `enabled` flag. Disabling a plugin still disables all
1076
+ // of its children — the effective state of a plugin child is the plugin's
1077
+ // derived enabled value and `(child.enabled ?? true)` — so toggling a child
1078
+ // only matters while its plugin is enabled. Is a no-op when no
1079
+ // customization has the given `id`.
1080
+ //
1081
+ // The `enablement` array completely replaces all explicit decisions. A caller
1082
+ // changing one scope must include every decision it intends to preserve.
1083
+ type SessionCustomizationToggledAction struct {
1084
+ Type ActionType `json:"type"`
1085
+ // The id of the container or child to update.
1086
+ Id string `json:"id"`
1087
+ // Explicit enablement decisions, replacing the previous list entirely.
1088
+ Enablement []CustomizationEnablement `json:"enablement"`
1089
+ }
1090
+
1091
+ // Upserts a top-level customization (plugin or directory).
1092
+ //
1093
+ // The reducer locates the existing entry by `customization.id`:
1094
+ //
1095
+ // - If found, the entry is replaced entirely with `customization`,
1096
+ // including its `children` array. To preserve existing children, the
1097
+ // host must include them on the payload.
1098
+ // - If not found, the entry is appended.
1099
+ type SessionCustomizationUpdatedAction struct {
1100
+ Type ActionType `json:"type"`
1101
+ // The customization to upsert (matched by `customization.id`).
1102
+ Customization Customization `json:"customization"`
1103
+ }
1104
+
1105
+ // Removes a customization by id.
1106
+ //
1107
+ // Searches every container and its children for the entry. If the entry
1108
+ // is a container, its children are removed with it. Is a no-op when no
1109
+ // matching id is found.
1110
+ type SessionCustomizationRemovedAction struct {
1111
+ Type ActionType `json:"type"`
1112
+ // The id of the customization to remove.
1113
+ Id string `json:"id"`
1114
+ }
1115
+
1116
+ // Updates the runtime fields of an existing
1117
+ // {@link McpServerCustomization} — narrow alternative to
1118
+ // {@link SessionCustomizationUpdatedAction} for the high-frequency
1119
+ // `starting` ↔ `ready` ↔ `authRequired` transitions.
1120
+ //
1121
+ // Locates the target entry by `id`, searching both the top-level
1122
+ // customization list and the `children` array of every container.
1123
+ // Replaces the entry's {@link McpServerCustomization.state | `state`}
1124
+ // and {@link McpServerCustomization.channel | `channel`}
1125
+ // (full-replacement semantics: omit `channel` to clear an existing
1126
+ // channel URI). Other fields of the customization are preserved.
1127
+ //
1128
+ // Is a no-op when no matching `McpServerCustomization` is found. To
1129
+ // update any other field (name, icons, `mcpApp` capabilities, etc.) use
1130
+ // {@link SessionCustomizationUpdatedAction} instead.
1131
+ //
1132
+ // When the transition is to {@link McpServerStatus.AuthRequired}
1133
+ // because of a request issued mid-turn, the host SHOULD also raise
1134
+ // {@link SessionStatus.InputNeeded} on the session — see
1135
+ // {@link McpServerAuthRequiredState} for the rationale.
1136
+ type SessionMcpServerStateChangedAction struct {
1137
+ Type ActionType `json:"type"`
1138
+ // The id of the {@link McpServerCustomization} to update.
1139
+ Id string `json:"id"`
1140
+ // The new lifecycle state.
1141
+ State McpServerState `json:"state"`
1142
+ // Updated `mcp://` side-channel URI. Full-replacement: omit to clear
1143
+ // an existing channel (typical when leaving
1144
+ // {@link McpServerStatus.Ready | `Ready`}).
1145
+ Channel *URI `json:"channel,omitempty"`
1146
+ }
1147
+
1148
+ // Requests that the host start or restart an existing
1149
+ // {@link McpServerCustomization}.
1150
+ //
1151
+ // Locates the target entry by `id`, searching both the top-level
1152
+ // customization list and the `children` array of every container. The
1153
+ // reducer optimistically moves the server to
1154
+ // {@link McpServerStatus.Starting | `starting`} and clears any previous
1155
+ // {@link McpServerCustomization.channel | `channel`}; the host remains
1156
+ // authoritative and SHOULD follow with
1157
+ // {@link SessionMcpServerStateChangedAction | `session/mcpServerStateChanged`}
1158
+ // once the server becomes ready, needs authentication, fails, or is
1159
+ // rejected. Is a no-op when no matching `McpServerCustomization` is found.
1160
+ type SessionMcpServerStartRequestedAction struct {
1161
+ Type ActionType `json:"type"`
1162
+ // The id of the {@link McpServerCustomization} to start.
1163
+ Id string `json:"id"`
1164
+ }
1165
+
1166
+ // Requests that the host stop an existing {@link McpServerCustomization}.
1167
+ //
1168
+ // Locates the target entry by `id`, searching both the top-level
1169
+ // customization list and the `children` array of every container. The
1170
+ // reducer optimistically moves the server to
1171
+ // {@link McpServerStatus.Stopped | `stopped`} and clears any previous
1172
+ // {@link McpServerCustomization.channel | `channel`}. Replacing an
1173
+ // {@link McpServerStatus.AuthRequired | `authRequired`} lifecycle state with
1174
+ // `stopped` unblocks the server from waiting on authentication. If the host
1175
+ // also raised session-level input-needed state solely for that MCP server, it
1176
+ // SHOULD remove that input-needed entry when accepting the stop.
1177
+ //
1178
+ // The host remains authoritative and MAY reject the action or follow with
1179
+ // {@link SessionMcpServerStateChangedAction | `session/mcpServerStateChanged`}
1180
+ // if the final lifecycle state differs. Is a no-op when no matching
1181
+ // `McpServerCustomization` is found.
1182
+ type SessionMcpServerStopRequestedAction struct {
1183
+ Type ActionType `json:"type"`
1184
+ // The id of the {@link McpServerCustomization} to stop.
1185
+ Id string `json:"id"`
1186
+ }
1187
+
1188
+ // Requests that the host background the startup of an existing
1189
+ // {@link McpServerCustomization} that is currently blocking message
1190
+ // processing (see {@link McpServerStartingState.blocking}), so that new
1191
+ // messages can be processed without waiting for the server to finish
1192
+ // starting.
1193
+ //
1194
+ // The server keeps starting in the background; backgrounding only stops the
1195
+ // host from holding message processing on it.
1196
+ //
1197
+ // Locates the target entry by `id`, searching both the top-level
1198
+ // customization list and the `children` array of every container. When the
1199
+ // server is {@link McpServerStatus.Starting | `starting`} with
1200
+ // `blocking: true`, the reducer optimistically sets `blocking` to `false`,
1201
+ // preserving the rest of the entry. Is a no-op otherwise (no matching
1202
+ // `McpServerCustomization`, a different lifecycle state, or not blocking).
1203
+ // The host remains authoritative and MAY reject the request by following with
1204
+ // {@link SessionMcpServerStateChangedAction | `session/mcpServerStateChanged`}
1205
+ // restoring `blocking: true`.
1206
+ type SessionMcpServerBackgroundRequestedAction struct {
1207
+ Type ActionType `json:"type"`
1208
+ // The id of the {@link McpServerCustomization} to background.
1209
+ Id string `json:"id"`
1210
+ }
1211
+
1212
+ // Client changed a mutable config value mid-session.
1213
+ //
1214
+ // Only properties with `sessionMutable: true` in the config schema may be
1215
+ // changed. The server validates and broadcasts the action; the reducer merges
1216
+ // the new values into `state.config.values`.
1217
+ type SessionConfigChangedAction struct {
1218
+ Type ActionType `json:"type"`
1219
+ // Updated config values
1220
+ Config map[string]json.RawMessage `json:"config"`
1221
+ // When `true`, replaces all config values instead of merging
1222
+ Replace *bool `json:"replace,omitempty"`
1223
+ }
1224
+
1225
+ // The session's `_meta` side-channel changed. Replaces `state._meta`
1226
+ // entirely (full-replacement semantics). Producers SHOULD merge any
1227
+ // keys they wish to preserve into the new value before dispatching.
1228
+ type SessionMetaChangedAction struct {
1229
+ Type ActionType `json:"type"`
1230
+ // New `_meta` payload, or `undefined` to clear it
1231
+ Meta map[string]json.RawMessage `json:"_meta,omitempty"`
1232
+ }
1233
+
1234
+ // The {@link ChangesetState.status} for this changeset transitioned (e.g.
1235
+ // `computing → ready` or `recomputing → ready`). The error payload is set
1236
+ // together with `status` whenever it transitions to
1237
+ // {@link ChangesetStatus.Error | Error}.
1238
+ type ChangesetStatusChangedAction struct {
1239
+ Type ActionType `json:"type"`
1240
+ // New computation lifecycle status.
1241
+ Status ChangesetStatus `json:"status"`
1242
+ // Cause when `status === ChangesetStatus.Error`; otherwise omitted.
1243
+ Error *ErrorInfo `json:"error,omitempty"`
1244
+ }
1245
+
1246
+ // Upsert a {@link ChangesetFile} in the changeset — adds a new entry, or
1247
+ // replaces an existing one identified by {@link ChangesetFile.id}.
1248
+ type ChangesetFileSetAction struct {
1249
+ Type ActionType `json:"type"`
1250
+ // The new or replacement file entry.
1251
+ File ChangesetFile `json:"file"`
1252
+ }
1253
+
1254
+ // Remove a {@link ChangesetFile} from the changeset by its id.
1255
+ //
1256
+ // Typically dispatched when a file is reverted, staged out, or otherwise
1257
+ // no longer in scope (e.g. a renamed file is replaced by a new entry).
1258
+ type ChangesetFileRemovedAction struct {
1259
+ Type ActionType `json:"type"`
1260
+ // The {@link ChangesetFile.id} of the file to remove.
1261
+ FileId string `json:"fileId"`
1262
+ }
1263
+
1264
+ // Set the {@link ChangesetFile.reviewed} flag for one or more files — the
1265
+ // GitHub-style "Viewed" toggle, applied in a single batch.
1266
+ //
1267
+ // Targets files by their {@link ChangesetFile.id}. Ids in {@link files} that
1268
+ // do not match a file currently present in the changeset are ignored; if none
1269
+ // match, the action is a no-op. Only the {@link ChangesetFile.reviewed} field
1270
+ // of each matched file is affected; the files' {@link ChangesetFile.edit | edit}
1271
+ // and {@link ChangesetFile._meta | _meta} are left untouched.
1272
+ //
1273
+ // Only meaningful on a changeset that advertises
1274
+ // {@link ChangesetCapabilities.review}. Unlike every other `changeset/*` action
1275
+ // this one is **client-dispatchable**: a reviewer toggles review state directly,
1276
+ // applying it optimistically through the write-ahead reducer and letting the
1277
+ // server echo it back on the normal `action` envelope stream. The server MAY
1278
+ // also originate it (e.g. an agent marking its own output reviewed).
1279
+ //
1280
+ // There is no protocol-level content version, so review is not reset
1281
+ // automatically when a file's contents change under a stable id. The server,
1282
+ // which is the authority on what changed, resets review explicitly — either by
1283
+ // re-emitting the file without `reviewed: true`, or by dispatching this action
1284
+ // with `reviewed: false`.
1285
+ type ChangesetFilesReviewChangedAction struct {
1286
+ Type ActionType `json:"type"`
1287
+ // The {@link ChangesetFile.id | ids} of the files whose review state changed.
1288
+ Files []string `json:"files"`
1289
+ // New review state applied to every listed file: `true` once reviewed, `false` to clear it.
1290
+ Reviewed bool `json:"reviewed"`
1291
+ }
1292
+
1293
+ // The changeset's full content changed. Full replacement semantics: `files`
1294
+ // replaces the previous file list, and `operations`, when present, replaces
1295
+ // the previous operation list.
1296
+ //
1297
+ // Producers SHOULD use this action for initial snapshots and bulk refreshes;
1298
+ // use {@link ChangesetFileSetAction}, {@link ChangesetFileRemovedAction}, and
1299
+ // {@link ChangesetOperationsChangedAction} for incremental updates.
1300
+ type ChangesetContentChangedAction struct {
1301
+ Type ActionType `json:"type"`
1302
+ // Full replacement file list.
1303
+ Files []ChangesetFile `json:"files"`
1304
+ // Full replacement operation list. Omit when operations are unchanged.
1305
+ Operations []ChangesetOperation `json:"operations,omitempty"`
1306
+ }
1307
+
1308
+ // The set of operations available on this changeset changed. Full
1309
+ // replacement semantics: `operations` replaces the previous list (or
1310
+ // removes it entirely when `operations` is `undefined`).
1311
+ type ChangesetOperationsChangedAction struct {
1312
+ Type ActionType `json:"type"`
1313
+ // Updated operation list. Pass `undefined` to clear all operations.
1314
+ Operations []ChangesetOperation `json:"operations,omitempty"`
1315
+ }
1316
+
1317
+ // The {@link ChangesetOperation.status} for a single operation transitioned
1318
+ // (e.g. `idle → running → idle`, or `running → error`). The error payload
1319
+ // is set together with `status` whenever it transitions to
1320
+ // {@link ChangesetOperationStatus.Error | Error}, and cleared on any other
1321
+ // transition.
1322
+ //
1323
+ // Targets one operation by its {@link ChangesetOperation.id}. If no
1324
+ // operation with that id is currently present in the changeset, the action
1325
+ // is a no-op. Use {@link ChangesetOperationsChangedAction} to add, remove,
1326
+ // or otherwise replace the operation list itself.
1327
+ type ChangesetOperationStatusChangedAction struct {
1328
+ Type ActionType `json:"type"`
1329
+ // The {@link ChangesetOperation.id} whose status changed.
1330
+ OperationId string `json:"operationId"`
1331
+ // New execution status.
1332
+ Status ChangesetOperationStatus `json:"status"`
1333
+ // Cause when `status === ChangesetOperationStatus.Error`; otherwise omitted.
1334
+ Error *ErrorInfo `json:"error,omitempty"`
1335
+ }
1336
+
1337
+ // Drop every file from the changeset.
1338
+ //
1339
+ // Two cases use this:
1340
+ // 1. The underlying source moved (branch switched, fork point invalidated,
1341
+ // …) and the server is recomputing from scratch — subsequent
1342
+ // {@link ChangesetFileSetAction} entries will repopulate it.
1343
+ // 2. The owning session has ended and the URI is becoming
1344
+ // un-subscribable — the server will unsubscribe all clients shortly
1345
+ // after dispatching this action.
1346
+ //
1347
+ // Clients SHOULD release any references on receipt and SHOULD NOT
1348
+ // distinguish the two cases from the action alone — instead, react to
1349
+ // the corresponding session-level lifecycle signal (e.g.
1350
+ // `root/sessionRemoved`) for the "going away" case.
1351
+ type ChangesetClearedAction struct {
1352
+ Type ActionType `json:"type"`
1353
+ }
1354
+
1355
+ // Upsert an {@link Annotation} in the annotations channel — adds a new
1356
+ // annotation, or replaces an existing one identified by
1357
+ // {@link Annotation.id}.
1358
+ //
1359
+ // Dispatched by a client to create an annotation (together with its
1360
+ // mandatory first entry) or to re-anchor / resolve an existing one; the
1361
+ // dispatching client assigns the {@link Annotation.id} and the id of any
1362
+ // new entry. When replacing, the full annotation payload (including its
1363
+ // {@link Annotation.entries | entries} list) is substituted; producers
1364
+ // SHOULD prefer {@link AnnotationsEntrySetAction} for per-entry edits, and
1365
+ // {@link AnnotationsUpdatedAction} to resolve / re-anchor an existing
1366
+ // annotation, to keep wire updates small.
1367
+ type AnnotationsSetAction struct {
1368
+ Type ActionType `json:"type"`
1369
+ // The new or replacement annotation. MUST contain at least one entry.
1370
+ Annotation Annotation `json:"annotation"`
1371
+ }
1372
+
1373
+ // Partially update an existing {@link Annotation}'s own properties — a narrow
1374
+ // alternative to {@link AnnotationsSetAction} for the common case of resolving
1375
+ // / re-opening or re-anchoring an annotation without resending its
1376
+ // {@link Annotation.entries | entries}.
1377
+ //
1378
+ // Targets one annotation by its {@link annotationId}. Only the fields present
1379
+ // on the action are written; omitted fields leave the corresponding
1380
+ // {@link Annotation} property unchanged. The annotation's
1381
+ // {@link Annotation.entries | entries}, {@link Annotation.id | id}, and
1382
+ // {@link Annotation._meta | _meta} are never touched — dispatch
1383
+ // {@link AnnotationsSetAction} to replace those, to clear {@link range}
1384
+ // (re-anchor to the whole file), or {@link AnnotationsEntrySetAction} /
1385
+ // {@link AnnotationsEntryRemovedAction} to edit individual entries.
1386
+ //
1387
+ // If {@link annotationId} does not match any current annotation the action is
1388
+ // a no-op.
1389
+ type AnnotationsUpdatedAction struct {
1390
+ Type ActionType `json:"type"`
1391
+ // The {@link Annotation.id} of the annotation to update.
1392
+ AnnotationId string `json:"annotationId"`
1393
+ // Replaces the annotation's provenance. Omit to leave it unchanged.
1394
+ Origin *AnnotationOrigin `json:"origin,omitempty"`
1395
+ // Re-anchors the annotation to this file. Omit to leave the current
1396
+ // {@link Annotation.resource} unchanged.
1397
+ Resource *URI `json:"resource,omitempty"`
1398
+ // Narrows the annotation to this range within {@link resource}. Omit to
1399
+ // leave the current {@link Annotation.range} unchanged; this action cannot
1400
+ // clear an existing range — dispatch {@link AnnotationsSetAction} to
1401
+ // re-anchor to the whole file.
1402
+ Range *TextRange `json:"range,omitempty"`
1403
+ // Marks the annotation resolved (`true`) or re-opens it (`false`). Omit to
1404
+ // leave the current {@link Annotation.resolved} state unchanged.
1405
+ Resolved *bool `json:"resolved,omitempty"`
1406
+ }
1407
+
1408
+ // Remove an {@link Annotation} from the channel by its id.
1409
+ //
1410
+ // Dispatched to delete an entire annotation and every entry it contains.
1411
+ // Because the protocol forbids empty annotations, a client that wants to
1412
+ // remove the last remaining entry dispatches this action — collapsing the
1413
+ // annotation — rather than {@link AnnotationsEntryRemovedAction}.
1414
+ type AnnotationsRemovedAction struct {
1415
+ Type ActionType `json:"type"`
1416
+ // The {@link Annotation.id} of the annotation to remove.
1417
+ AnnotationId string `json:"annotationId"`
1418
+ }
1419
+
1420
+ // Upsert an {@link AnnotationEntry} within an existing annotation — adds a
1421
+ // new entry, or replaces one identified by {@link AnnotationEntry.id}. The
1422
+ // dispatching client assigns the {@link AnnotationEntry.id} of a new entry.
1423
+ // If {@link annotationId} does not match any current annotation the action
1424
+ // is a no-op.
1425
+ type AnnotationsEntrySetAction struct {
1426
+ Type ActionType `json:"type"`
1427
+ // The {@link Annotation.id} the entry belongs to.
1428
+ AnnotationId string `json:"annotationId"`
1429
+ // The new or replacement entry.
1430
+ Entry AnnotationEntry `json:"entry"`
1431
+ }
1432
+
1433
+ // Remove a single {@link AnnotationEntry} from an annotation without
1434
+ // collapsing the annotation itself. Used when more than one entry remains —
1435
+ // to remove the last entry a client dispatches {@link AnnotationsRemovedAction}
1436
+ // instead, since the protocol forbids empty annotations.
1437
+ //
1438
+ // If either {@link annotationId} or {@link entryId} does not match the
1439
+ // current state the action is a no-op.
1440
+ type AnnotationsEntryRemovedAction struct {
1441
+ Type ActionType `json:"type"`
1442
+ // The {@link Annotation.id} the entry belongs to.
1443
+ AnnotationId string `json:"annotationId"`
1444
+ // The {@link AnnotationEntry.id} to remove.
1445
+ EntryId string `json:"entryId"`
1446
+ }
1447
+
1448
+ // Fired when the list of known terminals changes.
1449
+ //
1450
+ // Full-replacement semantics: the `terminals` array replaces the previous
1451
+ // `terminals` entirely.
1452
+ type RootTerminalsChangedAction struct {
1453
+ Type ActionType `json:"type"`
1454
+ // Updated terminal list (full replacement)
1455
+ Terminals []TerminalInfo `json:"terminals"`
1456
+ }
1457
+
1458
+ // Terminal output data (pty → client direction).
1459
+ //
1460
+ // Appends `data` to the terminal's `content` in the reducer.
1461
+ //
1462
+ // `terminal/data` and `terminal/input` are intentionally separate actions
1463
+ // because standard write-ahead reconciliation is not safe for terminal I/O.
1464
+ // A pty is a stateful, mutable process — optimistically applying input or
1465
+ // predicting output would produce incorrect state. Instead, `terminal/input`
1466
+ // is a side-effect-only action (client → server → pty), and `terminal/data`
1467
+ // is server-authoritative output (pty → server → client).
1468
+ type TerminalDataAction struct {
1469
+ Type ActionType `json:"type"`
1470
+ // Output data (may contain ANSI escape sequences)
1471
+ Data string `json:"data"`
1472
+ }
1473
+
1474
+ // Keyboard input sent to the terminal process (client → pty direction).
1475
+ //
1476
+ // This is a side-effect-only action: the server forwards the data to the
1477
+ // terminal's pty. The reducer treats this as a no-op since `terminal/data`
1478
+ // actions will reflect any resulting output.
1479
+ //
1480
+ // See `terminal/data` for why these two actions are kept separate.
1481
+ type TerminalInputAction struct {
1482
+ Type ActionType `json:"type"`
1483
+ // Input data to send to the pty
1484
+ Data string `json:"data"`
1485
+ }
1486
+
1487
+ // Terminal dimensions changed.
1488
+ //
1489
+ // Dispatchable by clients to request a resize, or by the server to inform
1490
+ // clients of the actual terminal dimensions.
1491
+ type TerminalResizedAction struct {
1492
+ Type ActionType `json:"type"`
1493
+ // Terminal width in columns
1494
+ Cols int64 `json:"cols"`
1495
+ // Terminal height in rows
1496
+ Rows int64 `json:"rows"`
1497
+ }
1498
+
1499
+ // Terminal claim changed. A client or session transfers ownership of the terminal.
1500
+ //
1501
+ // The server SHOULD reject if the dispatching client does not currently hold
1502
+ // the claim.
1503
+ type TerminalClaimedAction struct {
1504
+ Type ActionType `json:"type"`
1505
+ // The new claim
1506
+ Claim TerminalClaim `json:"claim"`
1507
+ }
1508
+
1509
+ // Terminal title changed.
1510
+ //
1511
+ // Fired by the server when the terminal process updates its title (e.g. via
1512
+ // escape sequences), or dispatched by a client to rename a terminal.
1513
+ type TerminalTitleChangedAction struct {
1514
+ Type ActionType `json:"type"`
1515
+ // New terminal title
1516
+ Title string `json:"title"`
1517
+ }
1518
+
1519
+ // Terminal working directory changed.
1520
+ type TerminalCwdChangedAction struct {
1521
+ Type ActionType `json:"type"`
1522
+ // New working directory
1523
+ Cwd URI `json:"cwd"`
1524
+ }
1525
+
1526
+ // Terminal process exited.
1527
+ type TerminalExitedAction struct {
1528
+ Type ActionType `json:"type"`
1529
+ // Process exit code. `undefined` if the process was killed without an exit code.
1530
+ ExitCode *int64 `json:"exitCode,omitempty"`
1531
+ }
1532
+
1533
+ // Terminal scrollback buffer cleared.
1534
+ type TerminalClearedAction struct {
1535
+ Type ActionType `json:"type"`
1536
+ }
1537
+
1538
+ // Shell integration has loaded and the terminal now supports command
1539
+ // detection. The server dispatches this when shell integration becomes
1540
+ // available (which may happen asynchronously after the terminal is created).
1541
+ //
1542
+ // Clients MUST NOT assume command detection is available until this action
1543
+ // (or `terminal/commandExecuted`) has been received.
1544
+ type TerminalCommandDetectionAvailableAction struct {
1545
+ Type ActionType `json:"type"`
1546
+ }
1547
+
1548
+ // A command has been submitted to the shell and is now executing.
1549
+ // All subsequent `terminal/data` actions (until the matching
1550
+ // `terminal/commandFinished`) constitute this command's output.
1551
+ type TerminalCommandExecutedAction struct {
1552
+ Type ActionType `json:"type"`
1553
+ // Stable identifier for this command, scoped to the terminal URI.
1554
+ // Allows correlating `commandExecuted` → `commandFinished` pairs.
1555
+ CommandId string `json:"commandId"`
1556
+ // The command line text that was submitted
1557
+ CommandLine string `json:"commandLine"`
1558
+ // Unix timestamp (ms) of when the command started executing, as measured
1559
+ // on the server.
1560
+ Timestamp int64 `json:"timestamp"`
1561
+ }
1562
+
1563
+ // A command has finished executing.
1564
+ //
1565
+ // The sequence of `terminal/data` actions between the preceding
1566
+ // `terminal/commandExecuted` (same `commandId`) and this action constitutes
1567
+ // the complete output of the command.
1568
+ type TerminalCommandFinishedAction struct {
1569
+ Type ActionType `json:"type"`
1570
+ // Matches the `commandId` from the corresponding `commandExecuted`
1571
+ CommandId string `json:"commandId"`
1572
+ // Shell exit code. `undefined` if the shell did not report one.
1573
+ ExitCode *int64 `json:"exitCode,omitempty"`
1574
+ // Wall-clock duration of the command in milliseconds, as measured by the
1575
+ // shell integration script on the server side.
1576
+ DurationMs *int64 `json:"durationMs,omitempty"`
1577
+ }
1578
+
1579
+ // A batch of resource changes observed by the watcher.
1580
+ //
1581
+ // Watch events are coalesced into batches by the server to keep the
1582
+ // action stream tractable; an empty `changes.items` list MUST NOT be
1583
+ // dispatched. The reducer does not retain change history — these
1584
+ // actions exist purely to deliver events to subscribers, who consume
1585
+ // them directly off the action stream and apply their own logic.
1586
+ type ResourceWatchChangedAction struct {
1587
+ Type ActionType `json:"type"`
1588
+ // The set of changes in this batch, wrapped for forward compatibility.
1589
+ Changes json.RawMessage `json:"changes"`
1590
+ }
1591
+
1592
+ // Ask the host to create a durable automation at a client-chosen resource.
1593
+ //
1594
+ // Clients may dispatch this action only when the host advertises its `create`
1595
+ // automation capability. {@link AutomationCreateRequestedAction.resource |
1596
+ // `resource`} MUST use the `ahp-automation:` scheme and MUST NOT already
1597
+ // identify an unrelated automation.
1598
+ //
1599
+ // This side-effect request leaves optimistic catalogue state unchanged. The
1600
+ // host validates trigger ids and configuration, normalizes event-trigger
1601
+ // titles and descriptions, persists the definition, then publishes the
1602
+ // authoritative result with {@link AutomationSetAction | `automation/set`}.
1603
+ // Rejections leave the catalogue unchanged.
1604
+ type AutomationCreateRequestedAction struct {
1605
+ Type ActionType `json:"type"`
1606
+ // Client-chosen `ahp-automation:` URI that becomes {@link AutomationEntry.resource}.
1607
+ Resource URI `json:"resource"`
1608
+ // Complete initial {@link AutomationEntry.definition}.
1609
+ Definition AutomationDefinition `json:"definition"`
1610
+ }
1611
+
1612
+ // Ask the host to update editable fields of an existing automation.
1613
+ //
1614
+ // Clients may dispatch this action only while the target advertises
1615
+ // {@link AutomationOperation.Update}. The host revalidates that operation and
1616
+ // the client's authorization.
1617
+ //
1618
+ // This side-effect request leaves optimistic catalogue state unchanged. The
1619
+ // host applies accepted patches to its current authoritative definition in
1620
+ // action order, revalidates and normalizes affected event triggers, then
1621
+ // publishes the result with
1622
+ // {@link AutomationSetAction | `automation/set`}. Omitted fields remain
1623
+ // unchanged; when accepted actions replace the same field, the later action in
1624
+ // server order wins.
1625
+ type AutomationUpdateRequestedAction struct {
1626
+ Type ActionType `json:"type"`
1627
+ // Target {@link AutomationEntry.resource}.
1628
+ Resource URI `json:"resource"`
1629
+ // Editable {@link AutomationDefinition} fields to replace.
1630
+ Changes AutomationDefinitionPatch `json:"changes"`
1631
+ }
1632
+
1633
+ // Add or replace one full automation state in
1634
+ // {@link AutomationState.entries}.
1635
+ //
1636
+ // Existing entries are matched by {@link AutomationEntry.resource} and
1637
+ // replaced in place. A previously unseen resource is appended.
1638
+ type AutomationSetAction struct {
1639
+ Type ActionType `json:"type"`
1640
+ // Full new or replacement automation state.
1641
+ Automation AutomationEntry `json:"automation"`
1642
+ }
1643
+
1644
+ // Remove one automation from {@link AutomationState.entries}.
1645
+ //
1646
+ // Clients may dispatch this action only while the target advertises
1647
+ // {@link AutomationOperation.Remove}. The host revalidates that operation
1648
+ // before permanently deleting the automation. A rejected action leaves the
1649
+ // authoritative catalogue and durable definition unchanged.
1650
+ //
1651
+ // Removing an unknown resource is a no-op.
1652
+ type AutomationRemovedAction struct {
1653
+ Type ActionType `json:"type"`
1654
+ // {@link AutomationEntry.resource} to remove.
1655
+ Resource URI `json:"resource"`
1656
+ }
1657
+
1658
+ // Replace the run lifecycle.
1659
+ //
1660
+ // The host dispatches this action for every lifecycle transition.
1661
+ type AutomationRunLifecycleChangedAction struct {
1662
+ Type ActionType `json:"type"`
1663
+ // Complete replacement {@link AutomationRunState.lifecycle}.
1664
+ Lifecycle AutomationRunLifecycle `json:"lifecycle"`
1665
+ }
1666
+
1667
+ // Add a session to {@link AutomationRunState.sessions}.
1668
+ //
1669
+ // Session URIs are unique. Setting an existing URI is a no-op.
1670
+ type AutomationRunSessionSetAction struct {
1671
+ Type ActionType `json:"type"`
1672
+ // Session URI to append to {@link AutomationRunState.sessions} when not already linked.
1673
+ Session URI `json:"session"`
1674
+ }
1675
+
1676
+ // Remove a linked session from the run.
1677
+ //
1678
+ // Removing the current primary session also clears
1679
+ // {@link AutomationRunState.primarySession}. An unknown URI is a no-op.
1680
+ type AutomationRunSessionRemovedAction struct {
1681
+ Type ActionType `json:"type"`
1682
+ // Entry in {@link AutomationRunState.sessions} to remove.
1683
+ Session URI `json:"session"`
1684
+ }
1685
+
1686
+ // Select or clear the session clients should open first for this run.
1687
+ type AutomationRunPrimarySessionChangedAction struct {
1688
+ Type ActionType `json:"type"`
1689
+ // New {@link AutomationRunState.primarySession}, or omitted to clear the selection.
1690
+ PrimarySession *URI `json:"primarySession,omitempty"`
1691
+ }
1692
+
1693
+ // Ask the host to cancel this run.
1694
+ //
1695
+ // This is the only client-dispatchable automation-run action. It is a
1696
+ // side-effect request and deliberately leaves optimistic state unchanged. The
1697
+ // client may dispatch it only when the host advertises its `runCancellation`
1698
+ // capability and the current lifecycle is `pending` or `running`. The host
1699
+ // revalidates that the run is non-terminal. The authoritative outcome arrives
1700
+ // later through
1701
+ // {@link AutomationRunLifecycleChangedAction}: cancellation may transition to
1702
+ // `cancelled`, or the run may complete or fail before cancellation takes
1703
+ // effect.
1704
+ type AutomationRunCancelRequestedAction struct {
1705
+ Type ActionType `json:"type"`
1706
+ }
1707
+
1708
+ // ─── StateAction Union ───────────────────────────────────────────────
1709
+
1710
+ // StateAction is the discriminated union of every state action.
1711
+ type StateAction struct {
1712
+ Value isStateAction
1713
+ }
1714
+
1715
+ // isStateAction is the marker interface implemented by every
1716
+ // concrete variant of StateAction.
1717
+ type isStateAction interface{ isStateAction() }
1718
+
1719
+ func (*RootAgentsChangedAction) isStateAction() {}
1720
+ func (*RootActiveSessionsChangedAction) isStateAction() {}
1721
+ func (*RootConfigChangedAction) isStateAction() {}
1722
+ func (*SessionReadyAction) isStateAction() {}
1723
+ func (*SessionCreationFailedAction) isStateAction() {}
1724
+ func (*SessionChatAddedAction) isStateAction() {}
1725
+ func (*SessionChatRemovedAction) isStateAction() {}
1726
+ func (*SessionChatUpdatedAction) isStateAction() {}
1727
+ func (*SessionDefaultChatChangedAction) isStateAction() {}
1728
+ func (*ChatTurnStartedAction) isStateAction() {}
1729
+ func (*ChatDeltaAction) isStateAction() {}
1730
+ func (*ChatResponsePartAction) isStateAction() {}
1731
+ func (*ChatToolCallStartAction) isStateAction() {}
1732
+ func (*ChatToolCallDeltaAction) isStateAction() {}
1733
+ func (*ChatToolCallReadyAction) isStateAction() {}
1734
+ func (*ChatToolCallConfirmedAction) isStateAction() {}
1735
+ func (*ChatToolCallCompleteAction) isStateAction() {}
1736
+ func (*ChatToolCallResultConfirmedAction) isStateAction() {}
1737
+ func (*ChatToolCallContentChangedAction) isStateAction() {}
1738
+ func (*ChatToolCallAuthRequiredAction) isStateAction() {}
1739
+ func (*ChatToolCallAuthResolvedAction) isStateAction() {}
1740
+ func (*ChatTurnCompleteAction) isStateAction() {}
1741
+ func (*ChatTurnCancelledAction) isStateAction() {}
1742
+ func (*ChatErrorAction) isStateAction() {}
1743
+ func (*ChatTurnResumeAction) isStateAction() {}
1744
+ func (*ChatActivityChangedAction) isStateAction() {}
1745
+ func (*ChatChangesetsChangedAction) isStateAction() {}
1746
+ func (*SessionTitleChangedAction) isStateAction() {}
1747
+ func (*ChatUsageAction) isStateAction() {}
1748
+ func (*ChatReasoningAction) isStateAction() {}
1749
+ func (*ChatPendingMessageSetAction) isStateAction() {}
1750
+ func (*ChatPendingMessageRemovedAction) isStateAction() {}
1751
+ func (*ChatQueuedMessagesReorderedAction) isStateAction() {}
1752
+ func (*ChatDraftChangedAction) isStateAction() {}
1753
+ func (*ChatIsArchivedChangedAction) isStateAction() {}
1754
+ func (*ChatInputRequestedAction) isStateAction() {}
1755
+ func (*ChatInputAnswerChangedAction) isStateAction() {}
1756
+ func (*ChatInputCompletedAction) isStateAction() {}
1757
+ func (*ChatTruncatedAction) isStateAction() {}
1758
+ func (*ChatTurnsLoadedAction) isStateAction() {}
1759
+ func (*SessionIsReadChangedAction) isStateAction() {}
1760
+ func (*SessionIsArchivedChangedAction) isStateAction() {}
1761
+ func (*SessionActivityChangedAction) isStateAction() {}
1762
+ func (*SessionChangesetsChangedAction) isStateAction() {}
1763
+ func (*SessionServerToolsChangedAction) isStateAction() {}
1764
+ func (*SessionActiveClientSetAction) isStateAction() {}
1765
+ func (*SessionActiveClientRemovedAction) isStateAction() {}
1766
+ func (*SessionWorkingDirectorySetAction) isStateAction() {}
1767
+ func (*SessionWorkingDirectoryRemovedAction) isStateAction() {}
1768
+ func (*SessionWorkingDirectoryReplacedAction) isStateAction() {}
1769
+ func (*ChatWorkingDirectorySetAction) isStateAction() {}
1770
+ func (*ChatWorkingDirectoryRemovedAction) isStateAction() {}
1771
+ func (*SessionInputNeededSetAction) isStateAction() {}
1772
+ func (*SessionInputNeededRemovedAction) isStateAction() {}
1773
+ func (*SessionCustomizationsChangedAction) isStateAction() {}
1774
+ func (*SessionCustomizationToggledAction) isStateAction() {}
1775
+ func (*SessionCustomizationUpdatedAction) isStateAction() {}
1776
+ func (*SessionCustomizationRemovedAction) isStateAction() {}
1777
+ func (*SessionMcpServerStateChangedAction) isStateAction() {}
1778
+ func (*SessionMcpServerStartRequestedAction) isStateAction() {}
1779
+ func (*SessionMcpServerStopRequestedAction) isStateAction() {}
1780
+ func (*SessionMcpServerBackgroundRequestedAction) isStateAction() {}
1781
+ func (*SessionConfigChangedAction) isStateAction() {}
1782
+ func (*SessionMetaChangedAction) isStateAction() {}
1783
+ func (*ChangesetStatusChangedAction) isStateAction() {}
1784
+ func (*ChangesetFileSetAction) isStateAction() {}
1785
+ func (*ChangesetFileRemovedAction) isStateAction() {}
1786
+ func (*ChangesetFilesReviewChangedAction) isStateAction() {}
1787
+ func (*ChangesetContentChangedAction) isStateAction() {}
1788
+ func (*ChangesetOperationsChangedAction) isStateAction() {}
1789
+ func (*ChangesetOperationStatusChangedAction) isStateAction() {}
1790
+ func (*ChangesetClearedAction) isStateAction() {}
1791
+ func (*AnnotationsSetAction) isStateAction() {}
1792
+ func (*AnnotationsUpdatedAction) isStateAction() {}
1793
+ func (*AnnotationsRemovedAction) isStateAction() {}
1794
+ func (*AnnotationsEntrySetAction) isStateAction() {}
1795
+ func (*AnnotationsEntryRemovedAction) isStateAction() {}
1796
+ func (*RootTerminalsChangedAction) isStateAction() {}
1797
+ func (*TerminalDataAction) isStateAction() {}
1798
+ func (*TerminalInputAction) isStateAction() {}
1799
+ func (*TerminalResizedAction) isStateAction() {}
1800
+ func (*TerminalClaimedAction) isStateAction() {}
1801
+ func (*TerminalTitleChangedAction) isStateAction() {}
1802
+ func (*TerminalCwdChangedAction) isStateAction() {}
1803
+ func (*TerminalExitedAction) isStateAction() {}
1804
+ func (*TerminalClearedAction) isStateAction() {}
1805
+ func (*TerminalCommandDetectionAvailableAction) isStateAction() {}
1806
+ func (*TerminalCommandExecutedAction) isStateAction() {}
1807
+ func (*TerminalCommandFinishedAction) isStateAction() {}
1808
+ func (*ResourceWatchChangedAction) isStateAction() {}
1809
+ func (*AutomationCreateRequestedAction) isStateAction() {}
1810
+ func (*AutomationUpdateRequestedAction) isStateAction() {}
1811
+ func (*AutomationSetAction) isStateAction() {}
1812
+ func (*AutomationRemovedAction) isStateAction() {}
1813
+ func (*AutomationRunLifecycleChangedAction) isStateAction() {}
1814
+ func (*AutomationRunSessionSetAction) isStateAction() {}
1815
+ func (*AutomationRunSessionRemovedAction) isStateAction() {}
1816
+ func (*AutomationRunPrimarySessionChangedAction) isStateAction() {}
1817
+ func (*AutomationRunCancelRequestedAction) isStateAction() {}
1818
+
1819
+ // StateActionUnknown carries an unrecognized StateAction variant — typically a discriminator value introduced by a newer protocol version. The original JSON object is preserved verbatim so that re-encoding round-trips faithfully.
1820
+ type StateActionUnknown struct {
1821
+ Raw json.RawMessage
1822
+ }
1823
+
1824
+ func (*StateActionUnknown) isStateAction() {}
1825
+
1826
+ // UnmarshalJSON decodes the variant indicated by the "type" discriminator.
1827
+ func (u *StateAction) UnmarshalJSON(data []byte) error {
1828
+ disc, _, err := readDiscriminator(data, "type")
1829
+ if err != nil {
1830
+ return err
1831
+ }
1832
+ switch disc {
1833
+ case "root/agentsChanged":
1834
+ var value RootAgentsChangedAction
1835
+ if err := json.Unmarshal(data, &value); err != nil {
1836
+ return err
1837
+ }
1838
+ u.Value = &value
1839
+ case "root/activeSessionsChanged":
1840
+ var value RootActiveSessionsChangedAction
1841
+ if err := json.Unmarshal(data, &value); err != nil {
1842
+ return err
1843
+ }
1844
+ u.Value = &value
1845
+ case "root/configChanged":
1846
+ var value RootConfigChangedAction
1847
+ if err := json.Unmarshal(data, &value); err != nil {
1848
+ return err
1849
+ }
1850
+ u.Value = &value
1851
+ case "session/ready":
1852
+ var value SessionReadyAction
1853
+ if err := json.Unmarshal(data, &value); err != nil {
1854
+ return err
1855
+ }
1856
+ u.Value = &value
1857
+ case "session/creationFailed":
1858
+ var value SessionCreationFailedAction
1859
+ if err := json.Unmarshal(data, &value); err != nil {
1860
+ return err
1861
+ }
1862
+ u.Value = &value
1863
+ case "session/chatAdded":
1864
+ var value SessionChatAddedAction
1865
+ if err := json.Unmarshal(data, &value); err != nil {
1866
+ return err
1867
+ }
1868
+ u.Value = &value
1869
+ case "session/chatRemoved":
1870
+ var value SessionChatRemovedAction
1871
+ if err := json.Unmarshal(data, &value); err != nil {
1872
+ return err
1873
+ }
1874
+ u.Value = &value
1875
+ case "session/chatUpdated":
1876
+ var value SessionChatUpdatedAction
1877
+ if err := json.Unmarshal(data, &value); err != nil {
1878
+ return err
1879
+ }
1880
+ u.Value = &value
1881
+ case "session/defaultChatChanged":
1882
+ var value SessionDefaultChatChangedAction
1883
+ if err := json.Unmarshal(data, &value); err != nil {
1884
+ return err
1885
+ }
1886
+ u.Value = &value
1887
+ case "chat/turnStarted":
1888
+ var value ChatTurnStartedAction
1889
+ if err := json.Unmarshal(data, &value); err != nil {
1890
+ return err
1891
+ }
1892
+ u.Value = &value
1893
+ case "chat/delta":
1894
+ var value ChatDeltaAction
1895
+ if err := json.Unmarshal(data, &value); err != nil {
1896
+ return err
1897
+ }
1898
+ u.Value = &value
1899
+ case "chat/responsePart":
1900
+ var value ChatResponsePartAction
1901
+ if err := json.Unmarshal(data, &value); err != nil {
1902
+ return err
1903
+ }
1904
+ u.Value = &value
1905
+ case "chat/toolCallStart":
1906
+ var value ChatToolCallStartAction
1907
+ if err := json.Unmarshal(data, &value); err != nil {
1908
+ return err
1909
+ }
1910
+ u.Value = &value
1911
+ case "chat/toolCallDelta":
1912
+ var value ChatToolCallDeltaAction
1913
+ if err := json.Unmarshal(data, &value); err != nil {
1914
+ return err
1915
+ }
1916
+ u.Value = &value
1917
+ case "chat/toolCallReady":
1918
+ var value ChatToolCallReadyAction
1919
+ if err := json.Unmarshal(data, &value); err != nil {
1920
+ return err
1921
+ }
1922
+ u.Value = &value
1923
+ case "chat/toolCallConfirmed":
1924
+ var value ChatToolCallConfirmedAction
1925
+ if err := json.Unmarshal(data, &value); err != nil {
1926
+ return err
1927
+ }
1928
+ u.Value = &value
1929
+ case "chat/toolCallComplete":
1930
+ var value ChatToolCallCompleteAction
1931
+ if err := json.Unmarshal(data, &value); err != nil {
1932
+ return err
1933
+ }
1934
+ u.Value = &value
1935
+ case "chat/toolCallResultConfirmed":
1936
+ var value ChatToolCallResultConfirmedAction
1937
+ if err := json.Unmarshal(data, &value); err != nil {
1938
+ return err
1939
+ }
1940
+ u.Value = &value
1941
+ case "chat/toolCallContentChanged":
1942
+ var value ChatToolCallContentChangedAction
1943
+ if err := json.Unmarshal(data, &value); err != nil {
1944
+ return err
1945
+ }
1946
+ u.Value = &value
1947
+ case "chat/toolCallAuthRequired":
1948
+ var value ChatToolCallAuthRequiredAction
1949
+ if err := json.Unmarshal(data, &value); err != nil {
1950
+ return err
1951
+ }
1952
+ u.Value = &value
1953
+ case "chat/toolCallAuthResolved":
1954
+ var value ChatToolCallAuthResolvedAction
1955
+ if err := json.Unmarshal(data, &value); err != nil {
1956
+ return err
1957
+ }
1958
+ u.Value = &value
1959
+ case "chat/turnComplete":
1960
+ var value ChatTurnCompleteAction
1961
+ if err := json.Unmarshal(data, &value); err != nil {
1962
+ return err
1963
+ }
1964
+ u.Value = &value
1965
+ case "chat/turnCancelled":
1966
+ var value ChatTurnCancelledAction
1967
+ if err := json.Unmarshal(data, &value); err != nil {
1968
+ return err
1969
+ }
1970
+ u.Value = &value
1971
+ case "chat/error":
1972
+ var value ChatErrorAction
1973
+ if err := json.Unmarshal(data, &value); err != nil {
1974
+ return err
1975
+ }
1976
+ u.Value = &value
1977
+ case "chat/turnResume":
1978
+ var value ChatTurnResumeAction
1979
+ if err := json.Unmarshal(data, &value); err != nil {
1980
+ return err
1981
+ }
1982
+ u.Value = &value
1983
+ case "chat/activityChanged":
1984
+ var value ChatActivityChangedAction
1985
+ if err := json.Unmarshal(data, &value); err != nil {
1986
+ return err
1987
+ }
1988
+ u.Value = &value
1989
+ case "chat/changesetsChanged":
1990
+ var value ChatChangesetsChangedAction
1991
+ if err := json.Unmarshal(data, &value); err != nil {
1992
+ return err
1993
+ }
1994
+ u.Value = &value
1995
+ case "session/titleChanged":
1996
+ var value SessionTitleChangedAction
1997
+ if err := json.Unmarshal(data, &value); err != nil {
1998
+ return err
1999
+ }
2000
+ u.Value = &value
2001
+ case "chat/usage":
2002
+ var value ChatUsageAction
2003
+ if err := json.Unmarshal(data, &value); err != nil {
2004
+ return err
2005
+ }
2006
+ u.Value = &value
2007
+ case "chat/reasoning":
2008
+ var value ChatReasoningAction
2009
+ if err := json.Unmarshal(data, &value); err != nil {
2010
+ return err
2011
+ }
2012
+ u.Value = &value
2013
+ case "chat/pendingMessageSet":
2014
+ var value ChatPendingMessageSetAction
2015
+ if err := json.Unmarshal(data, &value); err != nil {
2016
+ return err
2017
+ }
2018
+ u.Value = &value
2019
+ case "chat/pendingMessageRemoved":
2020
+ var value ChatPendingMessageRemovedAction
2021
+ if err := json.Unmarshal(data, &value); err != nil {
2022
+ return err
2023
+ }
2024
+ u.Value = &value
2025
+ case "chat/queuedMessagesReordered":
2026
+ var value ChatQueuedMessagesReorderedAction
2027
+ if err := json.Unmarshal(data, &value); err != nil {
2028
+ return err
2029
+ }
2030
+ u.Value = &value
2031
+ case "chat/draftChanged":
2032
+ var value ChatDraftChangedAction
2033
+ if err := json.Unmarshal(data, &value); err != nil {
2034
+ return err
2035
+ }
2036
+ u.Value = &value
2037
+ case "chat/isArchivedChanged":
2038
+ var value ChatIsArchivedChangedAction
2039
+ if err := json.Unmarshal(data, &value); err != nil {
2040
+ return err
2041
+ }
2042
+ u.Value = &value
2043
+ case "chat/inputRequested":
2044
+ var value ChatInputRequestedAction
2045
+ if err := json.Unmarshal(data, &value); err != nil {
2046
+ return err
2047
+ }
2048
+ u.Value = &value
2049
+ case "chat/inputAnswerChanged":
2050
+ var value ChatInputAnswerChangedAction
2051
+ if err := json.Unmarshal(data, &value); err != nil {
2052
+ return err
2053
+ }
2054
+ u.Value = &value
2055
+ case "chat/inputCompleted":
2056
+ var value ChatInputCompletedAction
2057
+ if err := json.Unmarshal(data, &value); err != nil {
2058
+ return err
2059
+ }
2060
+ u.Value = &value
2061
+ case "chat/truncated":
2062
+ var value ChatTruncatedAction
2063
+ if err := json.Unmarshal(data, &value); err != nil {
2064
+ return err
2065
+ }
2066
+ u.Value = &value
2067
+ case "chat/turnsLoaded":
2068
+ var value ChatTurnsLoadedAction
2069
+ if err := json.Unmarshal(data, &value); err != nil {
2070
+ return err
2071
+ }
2072
+ u.Value = &value
2073
+ case "session/isReadChanged":
2074
+ var value SessionIsReadChangedAction
2075
+ if err := json.Unmarshal(data, &value); err != nil {
2076
+ return err
2077
+ }
2078
+ u.Value = &value
2079
+ case "session/isArchivedChanged":
2080
+ var value SessionIsArchivedChangedAction
2081
+ if err := json.Unmarshal(data, &value); err != nil {
2082
+ return err
2083
+ }
2084
+ u.Value = &value
2085
+ case "session/activityChanged":
2086
+ var value SessionActivityChangedAction
2087
+ if err := json.Unmarshal(data, &value); err != nil {
2088
+ return err
2089
+ }
2090
+ u.Value = &value
2091
+ case "session/changesetsChanged":
2092
+ var value SessionChangesetsChangedAction
2093
+ if err := json.Unmarshal(data, &value); err != nil {
2094
+ return err
2095
+ }
2096
+ u.Value = &value
2097
+ case "session/serverToolsChanged":
2098
+ var value SessionServerToolsChangedAction
2099
+ if err := json.Unmarshal(data, &value); err != nil {
2100
+ return err
2101
+ }
2102
+ u.Value = &value
2103
+ case "session/activeClientSet":
2104
+ var value SessionActiveClientSetAction
2105
+ if err := json.Unmarshal(data, &value); err != nil {
2106
+ return err
2107
+ }
2108
+ u.Value = &value
2109
+ case "session/activeClientRemoved":
2110
+ var value SessionActiveClientRemovedAction
2111
+ if err := json.Unmarshal(data, &value); err != nil {
2112
+ return err
2113
+ }
2114
+ u.Value = &value
2115
+ case "session/workingDirectorySet":
2116
+ var value SessionWorkingDirectorySetAction
2117
+ if err := json.Unmarshal(data, &value); err != nil {
2118
+ return err
2119
+ }
2120
+ u.Value = &value
2121
+ case "session/workingDirectoryRemoved":
2122
+ var value SessionWorkingDirectoryRemovedAction
2123
+ if err := json.Unmarshal(data, &value); err != nil {
2124
+ return err
2125
+ }
2126
+ u.Value = &value
2127
+ case "session/workingDirectoryReplaced":
2128
+ var value SessionWorkingDirectoryReplacedAction
2129
+ if err := json.Unmarshal(data, &value); err != nil {
2130
+ return err
2131
+ }
2132
+ u.Value = &value
2133
+ case "chat/workingDirectorySet":
2134
+ var value ChatWorkingDirectorySetAction
2135
+ if err := json.Unmarshal(data, &value); err != nil {
2136
+ return err
2137
+ }
2138
+ u.Value = &value
2139
+ case "chat/workingDirectoryRemoved":
2140
+ var value ChatWorkingDirectoryRemovedAction
2141
+ if err := json.Unmarshal(data, &value); err != nil {
2142
+ return err
2143
+ }
2144
+ u.Value = &value
2145
+ case "session/inputNeededSet":
2146
+ var value SessionInputNeededSetAction
2147
+ if err := json.Unmarshal(data, &value); err != nil {
2148
+ return err
2149
+ }
2150
+ u.Value = &value
2151
+ case "session/inputNeededRemoved":
2152
+ var value SessionInputNeededRemovedAction
2153
+ if err := json.Unmarshal(data, &value); err != nil {
2154
+ return err
2155
+ }
2156
+ u.Value = &value
2157
+ case "session/customizationsChanged":
2158
+ var value SessionCustomizationsChangedAction
2159
+ if err := json.Unmarshal(data, &value); err != nil {
2160
+ return err
2161
+ }
2162
+ u.Value = &value
2163
+ case "session/customizationToggled":
2164
+ var value SessionCustomizationToggledAction
2165
+ if err := json.Unmarshal(data, &value); err != nil {
2166
+ return err
2167
+ }
2168
+ u.Value = &value
2169
+ case "session/customizationUpdated":
2170
+ var value SessionCustomizationUpdatedAction
2171
+ if err := json.Unmarshal(data, &value); err != nil {
2172
+ return err
2173
+ }
2174
+ u.Value = &value
2175
+ case "session/customizationRemoved":
2176
+ var value SessionCustomizationRemovedAction
2177
+ if err := json.Unmarshal(data, &value); err != nil {
2178
+ return err
2179
+ }
2180
+ u.Value = &value
2181
+ case "session/mcpServerStateChanged":
2182
+ var value SessionMcpServerStateChangedAction
2183
+ if err := json.Unmarshal(data, &value); err != nil {
2184
+ return err
2185
+ }
2186
+ u.Value = &value
2187
+ case "session/mcpServerStartRequested":
2188
+ var value SessionMcpServerStartRequestedAction
2189
+ if err := json.Unmarshal(data, &value); err != nil {
2190
+ return err
2191
+ }
2192
+ u.Value = &value
2193
+ case "session/mcpServerStopRequested":
2194
+ var value SessionMcpServerStopRequestedAction
2195
+ if err := json.Unmarshal(data, &value); err != nil {
2196
+ return err
2197
+ }
2198
+ u.Value = &value
2199
+ case "session/mcpServerBackgroundRequested":
2200
+ var value SessionMcpServerBackgroundRequestedAction
2201
+ if err := json.Unmarshal(data, &value); err != nil {
2202
+ return err
2203
+ }
2204
+ u.Value = &value
2205
+ case "session/configChanged":
2206
+ var value SessionConfigChangedAction
2207
+ if err := json.Unmarshal(data, &value); err != nil {
2208
+ return err
2209
+ }
2210
+ u.Value = &value
2211
+ case "session/metaChanged":
2212
+ var value SessionMetaChangedAction
2213
+ if err := json.Unmarshal(data, &value); err != nil {
2214
+ return err
2215
+ }
2216
+ u.Value = &value
2217
+ case "changeset/statusChanged":
2218
+ var value ChangesetStatusChangedAction
2219
+ if err := json.Unmarshal(data, &value); err != nil {
2220
+ return err
2221
+ }
2222
+ u.Value = &value
2223
+ case "changeset/fileSet":
2224
+ var value ChangesetFileSetAction
2225
+ if err := json.Unmarshal(data, &value); err != nil {
2226
+ return err
2227
+ }
2228
+ u.Value = &value
2229
+ case "changeset/fileRemoved":
2230
+ var value ChangesetFileRemovedAction
2231
+ if err := json.Unmarshal(data, &value); err != nil {
2232
+ return err
2233
+ }
2234
+ u.Value = &value
2235
+ case "changeset/filesReviewChanged":
2236
+ var value ChangesetFilesReviewChangedAction
2237
+ if err := json.Unmarshal(data, &value); err != nil {
2238
+ return err
2239
+ }
2240
+ u.Value = &value
2241
+ case "changeset/contentChanged":
2242
+ var value ChangesetContentChangedAction
2243
+ if err := json.Unmarshal(data, &value); err != nil {
2244
+ return err
2245
+ }
2246
+ u.Value = &value
2247
+ case "changeset/operationsChanged":
2248
+ var value ChangesetOperationsChangedAction
2249
+ if err := json.Unmarshal(data, &value); err != nil {
2250
+ return err
2251
+ }
2252
+ u.Value = &value
2253
+ case "changeset/operationStatusChanged":
2254
+ var value ChangesetOperationStatusChangedAction
2255
+ if err := json.Unmarshal(data, &value); err != nil {
2256
+ return err
2257
+ }
2258
+ u.Value = &value
2259
+ case "changeset/cleared":
2260
+ var value ChangesetClearedAction
2261
+ if err := json.Unmarshal(data, &value); err != nil {
2262
+ return err
2263
+ }
2264
+ u.Value = &value
2265
+ case "annotations/set":
2266
+ var value AnnotationsSetAction
2267
+ if err := json.Unmarshal(data, &value); err != nil {
2268
+ return err
2269
+ }
2270
+ u.Value = &value
2271
+ case "annotations/updated":
2272
+ var value AnnotationsUpdatedAction
2273
+ if err := json.Unmarshal(data, &value); err != nil {
2274
+ return err
2275
+ }
2276
+ u.Value = &value
2277
+ case "annotations/removed":
2278
+ var value AnnotationsRemovedAction
2279
+ if err := json.Unmarshal(data, &value); err != nil {
2280
+ return err
2281
+ }
2282
+ u.Value = &value
2283
+ case "annotations/entrySet":
2284
+ var value AnnotationsEntrySetAction
2285
+ if err := json.Unmarshal(data, &value); err != nil {
2286
+ return err
2287
+ }
2288
+ u.Value = &value
2289
+ case "annotations/entryRemoved":
2290
+ var value AnnotationsEntryRemovedAction
2291
+ if err := json.Unmarshal(data, &value); err != nil {
2292
+ return err
2293
+ }
2294
+ u.Value = &value
2295
+ case "root/terminalsChanged":
2296
+ var value RootTerminalsChangedAction
2297
+ if err := json.Unmarshal(data, &value); err != nil {
2298
+ return err
2299
+ }
2300
+ u.Value = &value
2301
+ case "terminal/data":
2302
+ var value TerminalDataAction
2303
+ if err := json.Unmarshal(data, &value); err != nil {
2304
+ return err
2305
+ }
2306
+ u.Value = &value
2307
+ case "terminal/input":
2308
+ var value TerminalInputAction
2309
+ if err := json.Unmarshal(data, &value); err != nil {
2310
+ return err
2311
+ }
2312
+ u.Value = &value
2313
+ case "terminal/resized":
2314
+ var value TerminalResizedAction
2315
+ if err := json.Unmarshal(data, &value); err != nil {
2316
+ return err
2317
+ }
2318
+ u.Value = &value
2319
+ case "terminal/claimed":
2320
+ var value TerminalClaimedAction
2321
+ if err := json.Unmarshal(data, &value); err != nil {
2322
+ return err
2323
+ }
2324
+ u.Value = &value
2325
+ case "terminal/titleChanged":
2326
+ var value TerminalTitleChangedAction
2327
+ if err := json.Unmarshal(data, &value); err != nil {
2328
+ return err
2329
+ }
2330
+ u.Value = &value
2331
+ case "terminal/cwdChanged":
2332
+ var value TerminalCwdChangedAction
2333
+ if err := json.Unmarshal(data, &value); err != nil {
2334
+ return err
2335
+ }
2336
+ u.Value = &value
2337
+ case "terminal/exited":
2338
+ var value TerminalExitedAction
2339
+ if err := json.Unmarshal(data, &value); err != nil {
2340
+ return err
2341
+ }
2342
+ u.Value = &value
2343
+ case "terminal/cleared":
2344
+ var value TerminalClearedAction
2345
+ if err := json.Unmarshal(data, &value); err != nil {
2346
+ return err
2347
+ }
2348
+ u.Value = &value
2349
+ case "terminal/commandDetectionAvailable":
2350
+ var value TerminalCommandDetectionAvailableAction
2351
+ if err := json.Unmarshal(data, &value); err != nil {
2352
+ return err
2353
+ }
2354
+ u.Value = &value
2355
+ case "terminal/commandExecuted":
2356
+ var value TerminalCommandExecutedAction
2357
+ if err := json.Unmarshal(data, &value); err != nil {
2358
+ return err
2359
+ }
2360
+ u.Value = &value
2361
+ case "terminal/commandFinished":
2362
+ var value TerminalCommandFinishedAction
2363
+ if err := json.Unmarshal(data, &value); err != nil {
2364
+ return err
2365
+ }
2366
+ u.Value = &value
2367
+ case "resourceWatch/changed":
2368
+ var value ResourceWatchChangedAction
2369
+ if err := json.Unmarshal(data, &value); err != nil {
2370
+ return err
2371
+ }
2372
+ u.Value = &value
2373
+ case "automation/createRequested":
2374
+ var value AutomationCreateRequestedAction
2375
+ if err := json.Unmarshal(data, &value); err != nil {
2376
+ return err
2377
+ }
2378
+ u.Value = &value
2379
+ case "automation/updateRequested":
2380
+ var value AutomationUpdateRequestedAction
2381
+ if err := json.Unmarshal(data, &value); err != nil {
2382
+ return err
2383
+ }
2384
+ u.Value = &value
2385
+ case "automation/set":
2386
+ var value AutomationSetAction
2387
+ if err := json.Unmarshal(data, &value); err != nil {
2388
+ return err
2389
+ }
2390
+ u.Value = &value
2391
+ case "automation/removed":
2392
+ var value AutomationRemovedAction
2393
+ if err := json.Unmarshal(data, &value); err != nil {
2394
+ return err
2395
+ }
2396
+ u.Value = &value
2397
+ case "automationRun/lifecycleChanged":
2398
+ var value AutomationRunLifecycleChangedAction
2399
+ if err := json.Unmarshal(data, &value); err != nil {
2400
+ return err
2401
+ }
2402
+ u.Value = &value
2403
+ case "automationRun/sessionSet":
2404
+ var value AutomationRunSessionSetAction
2405
+ if err := json.Unmarshal(data, &value); err != nil {
2406
+ return err
2407
+ }
2408
+ u.Value = &value
2409
+ case "automationRun/sessionRemoved":
2410
+ var value AutomationRunSessionRemovedAction
2411
+ if err := json.Unmarshal(data, &value); err != nil {
2412
+ return err
2413
+ }
2414
+ u.Value = &value
2415
+ case "automationRun/primarySessionChanged":
2416
+ var value AutomationRunPrimarySessionChangedAction
2417
+ if err := json.Unmarshal(data, &value); err != nil {
2418
+ return err
2419
+ }
2420
+ u.Value = &value
2421
+ case "automationRun/cancelRequested":
2422
+ var value AutomationRunCancelRequestedAction
2423
+ if err := json.Unmarshal(data, &value); err != nil {
2424
+ return err
2425
+ }
2426
+ u.Value = &value
2427
+ default:
2428
+ raw := make(json.RawMessage, len(data))
2429
+ copy(raw, data)
2430
+ u.Value = &StateActionUnknown{Raw: raw}
2431
+ }
2432
+ return nil
2433
+ }
2434
+
2435
+ // MarshalJSON encodes the active variant back to JSON.
2436
+ func (u StateAction) MarshalJSON() ([]byte, error) {
2437
+ if unk, ok := u.Value.(*StateActionUnknown); ok {
2438
+ if len(unk.Raw) == 0 {
2439
+ return []byte("null"), nil
2440
+ }
2441
+ return unk.Raw, nil
2442
+ }
2443
+ if u.Value == nil {
2444
+ return []byte("null"), nil
2445
+ }
2446
+ return json.Marshal(u.Value)
2447
+ }