@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,205 @@
1
+ // Package ahptypes contains the wire protocol types for the
2
+ // [Agent Host Protocol] (AHP).
3
+ //
4
+ // Every command, action, notification, and state object defined by the
5
+ // protocol has a Go counterpart here. Structs are tagged for
6
+ // [encoding/json] and use the exact same JSON field names as the wire
7
+ // format. There is no I/O, no goroutines, and no transport code; if you
8
+ // only need to parse or construct AHP messages, this is the only package
9
+ // you need.
10
+ //
11
+ // Most of this package is generated from the canonical TypeScript
12
+ // source-of-truth in types/. Hand-written code lives in common.go and
13
+ // discriminated_unions.go; everything else is rewritten on
14
+ // `npm run generate:go`.
15
+ //
16
+ // # Companion packages
17
+ //
18
+ // - [github.com/microsoft/agent-host-protocol/clients/go/ahp] — async
19
+ // client, reducers, and pluggable Transport.
20
+ // - [github.com/microsoft/agent-host-protocol/clients/go/ahpws] —
21
+ // WebSocket transport built on [github.com/coder/websocket].
22
+ //
23
+ // # Notes on type mapping
24
+ //
25
+ // - TypeScript number → Go int64 (the AHP spec defines numbers as
26
+ // 64-bit ints unless a property carries `@format float`, in which
27
+ // case it's emitted as float64).
28
+ // - TS unknown / object → [encoding/json.RawMessage] (boxes any JSON).
29
+ // - TS discriminated unions → concrete wrapper struct (e.g.
30
+ // [StateAction], [ResponsePart], [ToolCallState]) with a typed
31
+ // Value field plus custom MarshalJSON/UnmarshalJSON. Unknown
32
+ // discriminator values surface as a `*XUnknown` variant with the
33
+ // raw JSON preserved.
34
+ // - Bitset enums → typed uint32 with named flag constants and Has/Or
35
+ // helpers; unknown future bits round-trip naturally.
36
+ // - Required fields are emitted without `,omitempty`. Optional fields
37
+ // are pointer types with `,omitempty`.
38
+ //
39
+ // [Agent Host Protocol]: https://microsoft.github.io/agent-host-protocol/
40
+ package ahptypes
41
+
42
+ import (
43
+ "encoding/json"
44
+ "errors"
45
+ "fmt"
46
+ )
47
+
48
+ // URI is a URI string such as `ahp-root://` or `ahp-session:/<uuid>`.
49
+ //
50
+ // Declared as a defined string type rather than a plain alias so that
51
+ // AHP-typed code can be a little more self-documenting and so future
52
+ // helper methods can hang here without breaking the wire format.
53
+ type URI = string
54
+
55
+ // RootResourceURI is the well-known channel URI for the root channel.
56
+ //
57
+ // Subscribe to this URI to receive [RootState] snapshots and root-level
58
+ // actions (agents changed, active sessions changed, terminals changed,
59
+ // config changed). Always present on every host.
60
+ const RootResourceURI URI = "ahp-root://"
61
+
62
+ // JSONObject is a typed alias for an opaque JSON object. Used for
63
+ // `_meta`, `structuredContent`, and other Record<string, unknown>
64
+ // fields where preserving the raw JSON is preferable to forcing a
65
+ // concrete Go type.
66
+ type JSONObject = map[string]json.RawMessage
67
+
68
+ // AnyValue is an opaque JSON value (the Go counterpart of the
69
+ // TypeScript `unknown` type).
70
+ type AnyValue = json.RawMessage
71
+
72
+ // PartialChatSummary is the partial equivalent of ChatSummary — every field is optional for delta updates.
73
+ type PartialChatSummary struct {
74
+ // Chat URI. Ignored by session/chatUpdated reducers; chat identity never changes.
75
+ Resource *URI `json:"resource,omitempty"`
76
+ // Chat title
77
+ Title *string `json:"title,omitempty"`
78
+ // Current chat status (reuses SessionStatus shape)
79
+ Status *SessionStatus `json:"status,omitempty"`
80
+ // Human-readable description of what the chat is currently doing
81
+ Activity *string `json:"activity,omitempty"`
82
+ // Last modification timestamp (ISO 8601, e.g. `"2025-03-10T18:42:03.123Z"`)
83
+ ModifiedAt *string `json:"modifiedAt,omitempty"`
84
+ // How this chat came into existence
85
+ Origin *ChatOrigin `json:"origin,omitempty"`
86
+ // The subset of the session's working directories this chat uses.
87
+ WorkingDirectories []URI `json:"workingDirectories,omitempty"`
88
+ }
89
+
90
+ // ─── StringOrMarkdown ────────────────────────────────────────────────────
91
+
92
+ // StringOrMarkdown is a wire value that may be either a plain JSON
93
+ // string or an object of the form `{"markdown": "..."}`. The wrapper
94
+ // preserves which form was decoded so that re-encoding round-trips
95
+ // faithfully.
96
+ type StringOrMarkdown struct {
97
+ // Markdown is non-nil iff the value was decoded from the
98
+ // `{"markdown": "..."}` form.
99
+ Markdown *string
100
+
101
+ // Plain holds the value when decoded from a bare JSON string.
102
+ // Either Markdown or Plain (but never both) is non-nil after a
103
+ // successful UnmarshalJSON.
104
+ Plain *string
105
+ }
106
+
107
+ // NewStringOrMarkdownPlain returns a [StringOrMarkdown] that encodes
108
+ // as a bare JSON string.
109
+ func NewStringOrMarkdownPlain(s string) StringOrMarkdown {
110
+ return StringOrMarkdown{Plain: &s}
111
+ }
112
+
113
+ // NewStringOrMarkdownMarkdown returns a [StringOrMarkdown] that
114
+ // encodes as `{"markdown": s}`.
115
+ func NewStringOrMarkdownMarkdown(s string) StringOrMarkdown {
116
+ return StringOrMarkdown{Markdown: &s}
117
+ }
118
+
119
+ // AsText returns the underlying text regardless of which form the
120
+ // value was decoded from. Returns the empty string for the zero value.
121
+ func (s StringOrMarkdown) AsText() string {
122
+ if s.Plain != nil {
123
+ return *s.Plain
124
+ }
125
+ if s.Markdown != nil {
126
+ return *s.Markdown
127
+ }
128
+ return ""
129
+ }
130
+
131
+ // MarshalJSON encodes the value back into its original wire form.
132
+ //
133
+ // The zero value encodes as the empty JSON string `""` to match the
134
+ // Rust client's [Default::default] behaviour. Setting both Plain and
135
+ // Markdown is a programming error; the marshaler prefers Plain in
136
+ // that case.
137
+ func (s StringOrMarkdown) MarshalJSON() ([]byte, error) {
138
+ if s.Plain != nil {
139
+ return json.Marshal(*s.Plain)
140
+ }
141
+ if s.Markdown != nil {
142
+ return json.Marshal(struct {
143
+ Markdown string `json:"markdown"`
144
+ }{*s.Markdown})
145
+ }
146
+ return []byte(`""`), nil
147
+ }
148
+
149
+ // UnmarshalJSON populates the value from either form.
150
+ func (s *StringOrMarkdown) UnmarshalJSON(b []byte) error {
151
+ *s = StringOrMarkdown{}
152
+ if len(b) == 0 || string(b) == "null" {
153
+ return nil
154
+ }
155
+ if b[0] == '"' {
156
+ var v string
157
+ if err := json.Unmarshal(b, &v); err != nil {
158
+ return err
159
+ }
160
+ s.Plain = &v
161
+ return nil
162
+ }
163
+ var obj struct {
164
+ Markdown *string `json:"markdown"`
165
+ }
166
+ if err := json.Unmarshal(b, &obj); err != nil {
167
+ return fmt.Errorf("StringOrMarkdown: %w", err)
168
+ }
169
+ if obj.Markdown == nil {
170
+ return errors.New("StringOrMarkdown: object form missing required `markdown` field")
171
+ }
172
+ s.Markdown = obj.Markdown
173
+ return nil
174
+ }
175
+
176
+ // ─── Discriminated-union helpers ─────────────────────────────────────────
177
+
178
+ // readDiscriminator parses the value of a top-level discriminator
179
+ // field (`type`, `kind`, `status`, …) from a raw JSON object.
180
+ //
181
+ // Returns the string value, a boolean indicating whether the field
182
+ // was present, and an error if the JSON was malformed.
183
+ func readDiscriminator(raw []byte, field string) (string, bool, error) {
184
+ var probe map[string]json.RawMessage
185
+ if err := json.Unmarshal(raw, &probe); err != nil {
186
+ return "", false, err
187
+ }
188
+ v, ok := probe[field]
189
+ if !ok {
190
+ return "", false, nil
191
+ }
192
+ var s string
193
+ if err := json.Unmarshal(v, &s); err != nil {
194
+ return "", false, fmt.Errorf("discriminator %q: %w", field, err)
195
+ }
196
+ return s, true, nil
197
+ }
198
+
199
+ func missingDiscriminatorError(typeName string, field string) error {
200
+ return fmt.Errorf("%s: missing %q discriminator", typeName, field)
201
+ }
202
+
203
+ func unknownDiscriminatorError(typeName string, field string, value string) error {
204
+ return fmt.Errorf("%s: unknown %q discriminator %q", typeName, field, value)
205
+ }
@@ -0,0 +1,65 @@
1
+ // Generated from types/*.ts — do not edit.
2
+ //
3
+ // Regenerate with: npm run generate:go
4
+
5
+ package ahptypes
6
+
7
+ // ─── Standard JSON-RPC Error Codes ─────────────────────────────────────────
8
+
9
+ // Standard JSON-RPC 2.0 error codes.
10
+ const (
11
+ // ErrorCodeParseError indicates the request body was invalid JSON.
12
+ ErrorCodeParseError int32 = -32700
13
+ // ErrorCodeInvalidRequest indicates the payload was not a valid
14
+ // JSON-RPC request.
15
+ ErrorCodeInvalidRequest int32 = -32600
16
+ // ErrorCodeMethodNotFound indicates the requested method does not
17
+ // exist on the server.
18
+ ErrorCodeMethodNotFound int32 = -32601
19
+ // ErrorCodeInvalidParams indicates the method parameters did not
20
+ // match the declared schema.
21
+ ErrorCodeInvalidParams int32 = -32602
22
+ // ErrorCodeInternalError indicates an unspecified server failure.
23
+ ErrorCodeInternalError int32 = -32603
24
+ )
25
+
26
+ // AHP application-specific error codes (above the JSON-RPC reserved
27
+ // range).
28
+ const (
29
+ ErrorCodeSessionNotFound int32 = -32001
30
+ ErrorCodeProviderNotFound int32 = -32002
31
+ ErrorCodeSessionAlreadyExists int32 = -32003
32
+ ErrorCodeTurnInProgress int32 = -32004
33
+ ErrorCodeUnsupportedProtocolVersion int32 = -32005
34
+ // -32006 is intentionally reserved and unassigned.
35
+ ErrorCodeAuthRequired int32 = -32007
36
+ ErrorCodeNotFound int32 = -32008
37
+ ErrorCodePermissionDenied int32 = -32009
38
+ ErrorCodeAlreadyExists int32 = -32010
39
+ )
40
+
41
+ // AhpErrorCode is the type alias used by AHP application error codes.
42
+ type AhpErrorCode = int32
43
+
44
+ // JsonRpcErrorCode is the type alias used by standard JSON-RPC codes.
45
+ type JsonRpcErrorCode = int32
46
+
47
+ // ─── Error Detail Payloads ────────────────────────────────────────────────
48
+
49
+ // AuthRequiredErrorData is the detail payload of an AuthRequired
50
+ // (-32007) error.
51
+ type AuthRequiredErrorData struct {
52
+ Resources []ProtectedResourceMetadata `json:"resources"`
53
+ }
54
+
55
+ // PermissionDeniedErrorData is the detail payload of a
56
+ // PermissionDenied (-32009) error.
57
+ type PermissionDeniedErrorData struct {
58
+ Request *ResourceRequestParams `json:"request,omitempty"`
59
+ }
60
+
61
+ // UnsupportedProtocolVersionErrorData is the detail payload of an
62
+ // UnsupportedProtocolVersion (-32005) error.
63
+ type UnsupportedProtocolVersionErrorData struct {
64
+ SupportedVersions []string `json:"supportedVersions"`
65
+ }
@@ -0,0 +1,138 @@
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
+ "fmt"
10
+ )
11
+
12
+ // ─── JSON-RPC Envelope ────────────────────────────────────────────────────
13
+
14
+ // JsonRpcVersion is the sole allowed value of the `jsonrpc` field
15
+ // (`"2.0"`).
16
+ type JsonRpcVersion string
17
+
18
+ // JsonRpcV2 is the canonical `"2.0"` JSON-RPC version literal.
19
+ const JsonRpcV2 JsonRpcVersion = "2.0"
20
+
21
+ // JsonRpcRequest is a JSON-RPC 2.0 request (method + id).
22
+ type JsonRpcRequest struct {
23
+ JsonRpc JsonRpcVersion `json:"jsonrpc"`
24
+ ID uint64 `json:"id"`
25
+ Method string `json:"method"`
26
+ Params json.RawMessage `json:"params,omitempty"`
27
+ }
28
+
29
+ // JsonRpcSuccessResponse is a JSON-RPC 2.0 success response.
30
+ type JsonRpcSuccessResponse struct {
31
+ JsonRpc JsonRpcVersion `json:"jsonrpc"`
32
+ ID uint64 `json:"id"`
33
+ Result json.RawMessage `json:"result"`
34
+ }
35
+
36
+ // JsonRpcErrorResponse is a JSON-RPC 2.0 error response.
37
+ type JsonRpcErrorResponse struct {
38
+ JsonRpc JsonRpcVersion `json:"jsonrpc"`
39
+ ID uint64 `json:"id"`
40
+ Error JsonRpcError `json:"error"`
41
+ }
42
+
43
+ // JsonRpcError is the standard JSON-RPC 2.0 error object.
44
+ type JsonRpcError struct {
45
+ Code int32 `json:"code"`
46
+ Message string `json:"message"`
47
+ Data json.RawMessage `json:"data,omitempty"`
48
+ }
49
+
50
+ // Error implements the standard error interface.
51
+ func (e *JsonRpcError) Error() string {
52
+ return fmt.Sprintf("jsonrpc error %d: %s", e.Code, e.Message)
53
+ }
54
+
55
+ // JsonRpcNotification is a JSON-RPC 2.0 notification (method, no id).
56
+ type JsonRpcNotification struct {
57
+ JsonRpc JsonRpcVersion `json:"jsonrpc"`
58
+ Method string `json:"method"`
59
+ Params json.RawMessage `json:"params,omitempty"`
60
+ }
61
+
62
+ // JsonRpcMessage is a discriminated union over the four JSON-RPC
63
+ // message shapes. Use [DecodeJsonRpcMessage] to parse an inbound frame
64
+ // into the correct variant.
65
+ type JsonRpcMessage struct {
66
+ Request *JsonRpcRequest
67
+ SuccessResponse *JsonRpcSuccessResponse
68
+ ErrorResponse *JsonRpcErrorResponse
69
+ Notification *JsonRpcNotification
70
+ }
71
+
72
+ // MarshalJSON encodes whichever variant is populated.
73
+ func (m JsonRpcMessage) MarshalJSON() ([]byte, error) {
74
+ switch {
75
+ case m.Request != nil:
76
+ return json.Marshal(m.Request)
77
+ case m.SuccessResponse != nil:
78
+ return json.Marshal(m.SuccessResponse)
79
+ case m.ErrorResponse != nil:
80
+ return json.Marshal(m.ErrorResponse)
81
+ case m.Notification != nil:
82
+ return json.Marshal(m.Notification)
83
+ default:
84
+ return []byte("null"), nil
85
+ }
86
+ }
87
+
88
+ // UnmarshalJSON inspects the raw object's shape to pick a variant.
89
+ //
90
+ // JSON-RPC 2.0's shape rules:
91
+ // - request: has `id` and `method`
92
+ // - notification: has `method` but no `id`
93
+ // - success-resp: has `id` and `result` (no `error`)
94
+ // - error-resp: has `id` and `error` (no `result`)
95
+ func (m *JsonRpcMessage) UnmarshalJSON(data []byte) error {
96
+ *m = JsonRpcMessage{}
97
+ var probe map[string]json.RawMessage
98
+ if err := json.Unmarshal(data, &probe); err != nil {
99
+ return err
100
+ }
101
+ _, hasMethod := probe["method"]
102
+ _, hasID := probe["id"]
103
+ _, hasResult := probe["result"]
104
+ _, hasError := probe["error"]
105
+ switch {
106
+ case hasMethod && hasID:
107
+ var v JsonRpcRequest
108
+ if err := json.Unmarshal(data, &v); err != nil {
109
+ return err
110
+ }
111
+ m.Request = &v
112
+ case hasMethod:
113
+ var v JsonRpcNotification
114
+ if err := json.Unmarshal(data, &v); err != nil {
115
+ return err
116
+ }
117
+ m.Notification = &v
118
+ case hasError:
119
+ var v JsonRpcErrorResponse
120
+ if err := json.Unmarshal(data, &v); err != nil {
121
+ return err
122
+ }
123
+ m.ErrorResponse = &v
124
+ case hasResult:
125
+ var v JsonRpcSuccessResponse
126
+ if err := json.Unmarshal(data, &v); err != nil {
127
+ return err
128
+ }
129
+ m.SuccessResponse = &v
130
+ default:
131
+ return fmt.Errorf("ahptypes: JSON-RPC message has no method/result/error")
132
+ }
133
+ return nil
134
+ }
135
+
136
+ // ActionNotificationParams is the params shape of the server → client
137
+ // `action` JSON-RPC method.
138
+ type ActionNotificationParams = ActionEnvelope
@@ -0,0 +1,264 @@
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
+ // ─── Enums ────────────────────────────────────────────────────────────
17
+
18
+ // Reason why authentication is required.
19
+ type AuthRequiredReason string
20
+
21
+ const (
22
+ // The client has not yet authenticated for the resource
23
+ AuthRequiredReasonRequired AuthRequiredReason = "required"
24
+ // A previously valid token has expired or been revoked. The client must
25
+ // acquire or renew the credential rather than replaying the challenged token.
26
+ AuthRequiredReasonExpired AuthRequiredReason = "expired"
27
+ )
28
+
29
+ // ─── Notification Payloads ────────────────────────────────────────────
30
+
31
+ // Broadcast to all clients subscribed to the root channel when a new session
32
+ // is created.
33
+ type SessionAddedParams struct {
34
+ // Channel URI this notification belongs to (the root channel)
35
+ Channel URI `json:"channel"`
36
+ // Summary of the new session
37
+ Summary SessionSummary `json:"summary"`
38
+ }
39
+
40
+ // Broadcast to all clients subscribed to the root channel when a session is
41
+ // disposed.
42
+ type SessionRemovedParams struct {
43
+ // Channel URI this notification belongs to (the root channel)
44
+ Channel URI `json:"channel"`
45
+ // URI of the removed session
46
+ Session URI `json:"session"`
47
+ }
48
+
49
+ // Broadcast to all clients subscribed to the root channel when an existing
50
+ // session's summary changes (title, status, `modifiedAt`, model, working
51
+ // directory, read/done state, or diff statistics).
52
+ //
53
+ // This notification lets clients that maintain a cached session list — for
54
+ // example, the result of a previous `listSessions()` call — stay in sync with
55
+ // in-flight sessions without having to subscribe to every session URI
56
+ // individually. It is complementary to, not a replacement for,
57
+ // `root/sessionAdded` and `root/sessionRemoved`: those signal lifecycle
58
+ // (creation/disposal), while this signals summary-level mutations on an
59
+ // already-known session.
60
+ //
61
+ // Semantics:
62
+ //
63
+ // - Only fields present in `changes` have new values; omitted fields are
64
+ // unchanged on the client's cached summary.
65
+ // - Identity fields (`resource`, `provider`, `createdAt`) never change and
66
+ // are not carried.
67
+ // - Like all protocol notifications, this is ephemeral: it is **not**
68
+ // replayed on reconnect. On reconnect, clients should re-fetch the full
69
+ // catalog via `listSessions()` as usual.
70
+ // - The server SHOULD emit this notification whenever any mutable field on
71
+ // {@link SessionSummary | `SessionSummary`} changes for a session the
72
+ // server has surfaced via `listSessions()` or `root/sessionAdded`.
73
+ // Servers MAY coalesce or debounce updates for noisy fields (for example,
74
+ // `modifiedAt` bumps while a turn is streaming) at their discretion.
75
+ // - Clients that have no cached entry for `session` MAY ignore the
76
+ // notification; it is not a substitute for `root/sessionAdded`.
77
+ type SessionSummaryChangedParams struct {
78
+ // Channel URI this notification belongs to (the root channel)
79
+ Channel URI `json:"channel"`
80
+ // URI of the session whose summary changed
81
+ Session URI `json:"session"`
82
+ // Mutable summary fields that changed; omitted fields are unchanged.
83
+ //
84
+ // Identity fields (`resource`, `provider`, `createdAt`) never change and
85
+ // MUST be omitted by senders; receivers SHOULD ignore them if present.
86
+ Changes PartialSessionSummary `json:"changes"`
87
+ }
88
+
89
+ // Generic progress notification for a long-running operation.
90
+ //
91
+ // A client opts in to progress for a request by including a `progressToken` in
92
+ // that request (today: the `progressToken` field on `createSession`). If the
93
+ // server does long-running work to service the request — e.g. lazily
94
+ // downloading an agent's native SDK the first time a session of that provider
95
+ // is materialized — it emits `progress` notifications carrying the same token.
96
+ //
97
+ // The notification is operation-agnostic: it says nothing about *what* is
98
+ // progressing. The client correlates `progressToken` back to the request it
99
+ // originated from (and thus the UI surface awaiting it) and renders its own
100
+ // localized indicator. The same channel serves any future long-running
101
+ // operation without a new method.
102
+ //
103
+ // Semantics:
104
+ //
105
+ // - `progress` is monotonically non-decreasing for a given `progressToken`.
106
+ // - `total` is present only when the server knows the magnitude up front
107
+ // (e.g. a `Content-Length`); when absent the client SHOULD show an
108
+ // indeterminate indicator.
109
+ // - The operation is complete when `progress === total`. The server MUST emit a
110
+ // final frame satisfying `progress === total`; when the total was never
111
+ // known, it sets `total` to the final `progress` on that frame. No further
112
+ // frames reference the token afterwards.
113
+ // - The server MAY emit no progress at all (e.g. the work was already done);
114
+ // the client then never shows an indicator.
115
+ // - Like all notifications this is ephemeral and is **not** replayed on
116
+ // reconnect. A client that never receives the terminal frame SHOULD expire
117
+ // the indicator after an idle timeout.
118
+ type ProgressParams struct {
119
+ // Channel URI this notification belongs to (the root channel).
120
+ Channel URI `json:"channel"`
121
+ // Echoes the `progressToken` the client supplied on the originating request
122
+ // (e.g. the `progressToken` field of `createSession`), correlating this frame
123
+ // to that call. Unique across the client's active requests.
124
+ ProgressToken string `json:"progressToken"`
125
+ // Progress so far, in operation-defined units (e.g. bytes received).
126
+ // Monotonically non-decreasing for a given `progressToken`.
127
+ Progress int64 `json:"progress"`
128
+ // Total when known up front (e.g. from a `Content-Length`); omitted ⇒
129
+ // indeterminate. The operation is complete once `progress === total`.
130
+ Total *int64 `json:"total,omitempty"`
131
+ // Optional human-readable progress message. The client owns its own
132
+ // (localized) presentation derived from the originating request; generic
133
+ // clients that don't track the token MAY display this instead.
134
+ Message *string `json:"message,omitempty"`
135
+ }
136
+
137
+ // Sent by the server when a protected resource requires (re-)authentication.
138
+ //
139
+ // This notification MAY be associated with any channel — for example, an
140
+ // agent advertised on the root channel, or a per-session resource. The
141
+ // `channel` field identifies the subscription the auth requirement belongs
142
+ // to; the `resource` field carries the complete OAuth protected resource
143
+ // metadata (per RFC 9728).
144
+ //
145
+ // Clients should obtain or renew the credential and push the resulting token
146
+ // via the `authenticate` command. When `reason` is `expired`, clients MUST NOT
147
+ // blindly replay the challenged token.
148
+ type AuthRequiredParams struct {
149
+ // Channel URI this notification belongs to
150
+ Channel URI `json:"channel"`
151
+ // Complete RFC 9728 metadata for the protected resource that requires authentication
152
+ Resource ProtectedResourceMetadata `json:"resource"`
153
+ // Why authentication is required
154
+ Reason *AuthRequiredReason `json:"reason,omitempty"`
155
+ }
156
+
157
+ // Delivers a batch of OTLP log records to a client subscribed to the host's
158
+ // logs channel (advertised on `TelemetryCapabilities.logs`).
159
+ //
160
+ // The `payload` field is an OTLP/JSON `ExportLogsServiceRequest` value
161
+ // verbatim — i.e. an object of shape `{ resourceLogs: ResourceLogs[] }` as
162
+ // defined by [opentelemetry-proto](https://github.com/open-telemetry/opentelemetry-proto/blob/main/opentelemetry/proto/collector/logs/v1/logs_service.proto).
163
+ // AHP does not redeclare the OTLP type system; clients SHOULD use an
164
+ // OpenTelemetry SDK or schema to parse it.
165
+ //
166
+ // Like all stateless-channel notifications, this is ephemeral: it is not
167
+ // replayed on reconnect. Subscribers receive only batches emitted after
168
+ // their `subscribe` succeeds.
169
+ type OtlpExportLogsParams struct {
170
+ // Channel URI this notification belongs to (an `ahp-otlp:` URI advertised on `TelemetryCapabilities.logs`).
171
+ Channel URI `json:"channel"`
172
+ // OTLP/JSON `ExportLogsServiceRequest` value. The top-level field is
173
+ // `resourceLogs: ResourceLogs[]`; nested shapes are defined by
174
+ // opentelemetry-proto and are not redeclared here.
175
+ Payload map[string]json.RawMessage `json:"payload"`
176
+ }
177
+
178
+ // Delivers a batch of OTLP spans to a client subscribed to the host's
179
+ // traces channel (advertised on `TelemetryCapabilities.traces`).
180
+ //
181
+ // The `payload` field is an OTLP/JSON `ExportTraceServiceRequest` value
182
+ // verbatim — i.e. an object of shape `{ resourceSpans: ResourceSpans[] }`
183
+ // as defined by [opentelemetry-proto](https://github.com/open-telemetry/opentelemetry-proto/blob/main/opentelemetry/proto/collector/trace/v1/trace_service.proto).
184
+ type OtlpExportTracesParams struct {
185
+ // Channel URI this notification belongs to (an `ahp-otlp:` URI advertised on `TelemetryCapabilities.traces`).
186
+ Channel URI `json:"channel"`
187
+ // OTLP/JSON `ExportTraceServiceRequest` value. The top-level field is
188
+ // `resourceSpans: ResourceSpans[]`; nested shapes are defined by
189
+ // opentelemetry-proto and are not redeclared here.
190
+ Payload map[string]json.RawMessage `json:"payload"`
191
+ }
192
+
193
+ // Delivers a batch of OTLP metric data points to a client subscribed to
194
+ // the host's metrics channel (advertised on `TelemetryCapabilities.metrics`).
195
+ //
196
+ // The `payload` field is an OTLP/JSON `ExportMetricsServiceRequest` value
197
+ // verbatim — i.e. an object of shape `{ resourceMetrics: ResourceMetrics[] }`
198
+ // as defined by [opentelemetry-proto](https://github.com/open-telemetry/opentelemetry-proto/blob/main/opentelemetry/proto/collector/metrics/v1/metrics_service.proto).
199
+ type OtlpExportMetricsParams struct {
200
+ // Channel URI this notification belongs to (an `ahp-otlp:` URI advertised on `TelemetryCapabilities.metrics`).
201
+ Channel URI `json:"channel"`
202
+ // OTLP/JSON `ExportMetricsServiceRequest` value. The top-level field is
203
+ // `resourceMetrics: ResourceMetrics[]`; nested shapes are defined by
204
+ // opentelemetry-proto and are not redeclared here.
205
+ Payload map[string]json.RawMessage `json:"payload"`
206
+ }
207
+
208
+ // ─── Partial Summaries ────────────────────────────────────────────────
209
+
210
+ // PartialSessionSummary is the partial equivalent of SessionSummary — every field is optional for delta updates.
211
+ type PartialSessionSummary struct {
212
+ // Agent provider ID
213
+ Provider *string `json:"provider,omitempty"`
214
+ // Session title
215
+ Title *string `json:"title,omitempty"`
216
+ // Current session status
217
+ Status *SessionStatus `json:"status,omitempty"`
218
+ // Human-readable description of what the session is currently doing
219
+ Activity *string `json:"activity,omitempty"`
220
+ // Durable {@link AutomationSessionOrigin}, when an automation run created this session.
221
+ Origin *SessionOrigin `json:"origin,omitempty"`
222
+ // Server-owned project for this session
223
+ Project *ProjectInfo `json:"project,omitempty"`
224
+ // The working directories the session's agent has tool access to, as
225
+ // maintained by working-directory actions. Directories are equal peers except
226
+ // when the agent advertises
227
+ // {@link MultipleWorkingDirectoriesCapability.immutablePrimary} without
228
+ // {@link MultipleWorkingDirectoriesCapability.primaryReplacement} (the first
229
+ // entry is then a fixed process root), or advertises `primaryReplacement`
230
+ // (the first entry is a protected, replaceable primary slot). Individual chats
231
+ // MAY restrict to a subset via
232
+ // {@link ChatSummary.workingDirectories | their own `workingDirectories`}; a
233
+ // chat that sets none operates against this full set.
234
+ WorkingDirectories []URI `json:"workingDirectories,omitempty"`
235
+ // Lightweight summary of this session's inline annotations channel
236
+ // (`ahp-session:/<uuid>/annotations`). Surfaced so badge UI can render
237
+ // annotation / entry counts without subscribing. Absent when the session
238
+ // does not expose an annotations channel.
239
+ Annotations *AnnotationsSummary `json:"annotations,omitempty"`
240
+ // Session URI
241
+ Resource *URI `json:"resource,omitempty"`
242
+ // Creation timestamp (ISO 8601, e.g. `"2025-03-10T18:42:03.123Z"`)
243
+ CreatedAt *string `json:"createdAt,omitempty"`
244
+ // Last modification timestamp (ISO 8601, e.g. `"2025-03-10T18:42:03.123Z"`)
245
+ ModifiedAt *string `json:"modifiedAt,omitempty"`
246
+ // Aggregate summary of file changes associated with this session. Servers
247
+ // may populate this to give clients a quick at-a-glance view of the
248
+ // session's footprint (e.g., for list rendering) without requiring the
249
+ // client to subscribe to a changeset.
250
+ Changes *ChangesSummary `json:"changes,omitempty"`
251
+ // Lightweight server-defined metadata clients may use for the session
252
+ // presentation. The protocol does not interpret these values; producers
253
+ // SHOULD keep the payload small because summaries appear in session lists
254
+ // and session notifications.
255
+ Meta map[string]json.RawMessage `json:"_meta,omitempty"`
256
+ // Lightweight ordered chat catalog for session-list presentation.
257
+ //
258
+ // This intentionally omits volatile chat state such as status and activity,
259
+ // while retaining interactivity so generic clients can hide chats or present
260
+ // them as read-only without subscribing to the session channel.
261
+ Chats []SessionChatSummary `json:"chats,omitempty"`
262
+ // Chat that receives input when no specific chat is selected.
263
+ DefaultChat *URI `json:"defaultChat,omitempty"`
264
+ }