@fuzdev/fuz_app 0.150.0 → 0.151.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 (597) hide show
  1. package/README.md +1 -1
  2. package/dist/actions/CLAUDE.md +324 -299
  3. package/dist/actions/action_bridge.d.ts +5 -86
  4. package/dist/actions/action_bridge.d.ts.map +1 -1
  5. package/dist/actions/action_bridge.js +4 -84
  6. package/dist/actions/action_codegen.d.ts +8 -166
  7. package/dist/actions/action_codegen.d.ts.map +1 -1
  8. package/dist/actions/action_codegen.js +19 -95
  9. package/dist/actions/action_dispatcher.d.ts +10 -0
  10. package/dist/actions/action_dispatcher.d.ts.map +1 -1
  11. package/dist/actions/action_dispatcher.js +9 -6
  12. package/dist/actions/action_event.d.ts +1 -2
  13. package/dist/actions/action_event.d.ts.map +1 -1
  14. package/dist/actions/action_event.js +7 -13
  15. package/dist/actions/action_event_helpers.d.ts +1 -40
  16. package/dist/actions/action_event_helpers.d.ts.map +1 -1
  17. package/dist/actions/action_event_helpers.js +1 -25
  18. package/dist/actions/action_rpc.d.ts +10 -215
  19. package/dist/actions/action_rpc.d.ts.map +1 -1
  20. package/dist/actions/action_rpc.js +56 -111
  21. package/dist/actions/action_spec.d.ts +2 -2
  22. package/dist/actions/action_spec.js +2 -2
  23. package/dist/actions/action_types.d.ts +229 -8
  24. package/dist/actions/action_types.d.ts.map +1 -1
  25. package/dist/actions/action_types.js +56 -5
  26. package/dist/actions/broadcast_api.d.ts +22 -17
  27. package/dist/actions/broadcast_api.d.ts.map +1 -1
  28. package/dist/actions/broadcast_api.js +16 -27
  29. package/dist/actions/cancel.d.ts +4 -13
  30. package/dist/actions/cancel.d.ts.map +1 -1
  31. package/dist/actions/cancel.js +5 -17
  32. package/dist/actions/compile_action_registry.d.ts +1 -2
  33. package/dist/actions/compile_action_registry.d.ts.map +1 -1
  34. package/dist/actions/connection_closer.d.ts +120 -50
  35. package/dist/actions/connection_closer.d.ts.map +1 -1
  36. package/dist/actions/connection_closer.js +139 -31
  37. package/dist/actions/{transports_ws_backend.d.ts → connection_registry.d.ts} +120 -132
  38. package/dist/actions/connection_registry.d.ts.map +1 -0
  39. package/dist/actions/{transports_ws_backend.js → connection_registry.js} +149 -152
  40. package/dist/actions/frontend_rpc_client.d.ts +52 -2
  41. package/dist/actions/frontend_rpc_client.d.ts.map +1 -1
  42. package/dist/actions/frontend_rpc_client.js +42 -4
  43. package/dist/actions/peer_ping.d.ts +7 -9
  44. package/dist/actions/peer_ping.d.ts.map +1 -1
  45. package/dist/actions/peer_ping.js +6 -8
  46. package/dist/actions/peer_request.d.ts +6 -5
  47. package/dist/actions/peer_request.d.ts.map +1 -1
  48. package/dist/actions/peer_request.js +6 -5
  49. package/dist/actions/perform_action.d.ts +36 -28
  50. package/dist/actions/perform_action.d.ts.map +1 -1
  51. package/dist/actions/perform_action.js +60 -34
  52. package/dist/actions/protocol.d.ts +14 -0
  53. package/dist/actions/protocol.d.ts.map +1 -1
  54. package/dist/actions/protocol.js +18 -0
  55. package/dist/actions/register_action_ws.d.ts +137 -298
  56. package/dist/actions/register_action_ws.d.ts.map +1 -1
  57. package/dist/actions/register_action_ws.js +155 -923
  58. package/dist/actions/socket.svelte.d.ts +9 -0
  59. package/dist/actions/socket.svelte.d.ts.map +1 -1
  60. package/dist/actions/socket.svelte.js +16 -5
  61. package/dist/actions/transports.d.ts +88 -34
  62. package/dist/actions/transports.d.ts.map +1 -1
  63. package/dist/actions/transports.js +76 -76
  64. package/dist/actions/transports_http.d.ts +48 -12
  65. package/dist/actions/transports_http.d.ts.map +1 -1
  66. package/dist/actions/transports_http.js +75 -44
  67. package/dist/actions/transports_ws.d.ts +29 -0
  68. package/dist/actions/transports_ws.d.ts.map +1 -1
  69. package/dist/actions/transports_ws.js +34 -8
  70. package/dist/actions/ws_endpoint_spec.d.ts +52 -75
  71. package/dist/actions/ws_endpoint_spec.d.ts.map +1 -1
  72. package/dist/actions/ws_endpoint_spec.js +27 -10
  73. package/dist/actions/ws_outbound_writer.d.ts +3 -3
  74. package/dist/actions/ws_outbound_writer.js +3 -3
  75. package/dist/actions/ws_socket_session.d.ts +321 -0
  76. package/dist/actions/ws_socket_session.d.ts.map +1 -0
  77. package/dist/actions/ws_socket_session.js +783 -0
  78. package/dist/auth/CLAUDE.md +70 -44
  79. package/dist/auth/account_action_specs.d.ts +2 -0
  80. package/dist/auth/account_action_specs.d.ts.map +1 -1
  81. package/dist/auth/account_actions.d.ts +1 -1
  82. package/dist/auth/account_actions.d.ts.map +1 -1
  83. package/dist/auth/account_actions.js +9 -3
  84. package/dist/auth/account_queries.d.ts +10 -0
  85. package/dist/auth/account_queries.d.ts.map +1 -1
  86. package/dist/auth/account_queries.js +27 -17
  87. package/dist/auth/account_routes.d.ts +2 -1
  88. package/dist/auth/account_routes.d.ts.map +1 -1
  89. package/dist/auth/account_routes.js +14 -17
  90. package/dist/auth/account_schema.d.ts +5 -5
  91. package/dist/auth/account_schema.d.ts.map +1 -1
  92. package/dist/auth/account_schema.js +5 -2
  93. package/dist/auth/actor_lookup_actions.d.ts +1 -1
  94. package/dist/auth/actor_lookup_actions.d.ts.map +1 -1
  95. package/dist/auth/actor_lookup_actions.js +1 -1
  96. package/dist/auth/actor_search_action_specs.d.ts.map +1 -1
  97. package/dist/auth/actor_search_action_specs.js +2 -1
  98. package/dist/auth/actor_search_actions.d.ts +1 -1
  99. package/dist/auth/actor_search_actions.d.ts.map +1 -1
  100. package/dist/auth/actor_search_actions.js +1 -1
  101. package/dist/auth/actor_search_queries.d.ts +5 -5
  102. package/dist/auth/actor_search_queries.d.ts.map +1 -1
  103. package/dist/auth/actor_search_queries.js +7 -7
  104. package/dist/auth/admin_action_specs.d.ts.map +1 -1
  105. package/dist/auth/admin_action_specs.js +3 -1
  106. package/dist/auth/admin_actions.d.ts +1 -1
  107. package/dist/auth/admin_actions.d.ts.map +1 -1
  108. package/dist/auth/admin_actions.js +12 -42
  109. package/dist/auth/all_cell_actions.d.ts +6 -4
  110. package/dist/auth/all_cell_actions.d.ts.map +1 -1
  111. package/dist/auth/all_cell_actions.js +1 -1
  112. package/dist/auth/api_token_queries.d.ts +1 -0
  113. package/dist/auth/api_token_queries.d.ts.map +1 -1
  114. package/dist/auth/api_token_queries.js +1 -0
  115. package/dist/auth/audit_emitter.d.ts +3 -3
  116. package/dist/auth/audit_emitter.js +2 -2
  117. package/dist/auth/audit_log_route_schema.d.ts.map +1 -1
  118. package/dist/auth/audit_log_route_schema.js +3 -2
  119. package/dist/auth/audit_log_routes.d.ts +20 -11
  120. package/dist/auth/audit_log_routes.d.ts.map +1 -1
  121. package/dist/auth/audit_log_routes.js +49 -29
  122. package/dist/auth/audit_log_schema.d.ts +13 -21
  123. package/dist/auth/audit_log_schema.d.ts.map +1 -1
  124. package/dist/auth/audit_log_schema.js +10 -18
  125. package/dist/auth/bearer_auth.d.ts +7 -4
  126. package/dist/auth/bearer_auth.d.ts.map +1 -1
  127. package/dist/auth/bearer_auth.js +21 -15
  128. package/dist/auth/cell_action_helpers.d.ts +89 -0
  129. package/dist/auth/cell_action_helpers.d.ts.map +1 -0
  130. package/dist/auth/cell_action_helpers.js +113 -0
  131. package/dist/auth/cell_actions.d.ts +22 -13
  132. package/dist/auth/cell_actions.d.ts.map +1 -1
  133. package/dist/auth/cell_actions.js +105 -167
  134. package/dist/auth/cell_audit_actions.d.ts +1 -1
  135. package/dist/auth/cell_audit_actions.d.ts.map +1 -1
  136. package/dist/auth/cell_audit_actions.js +3 -12
  137. package/dist/auth/cell_audit_metadata.d.ts +1 -1
  138. package/dist/auth/cell_audit_metadata.js +1 -1
  139. package/dist/auth/cell_field_actions.d.ts +1 -1
  140. package/dist/auth/cell_field_actions.d.ts.map +1 -1
  141. package/dist/auth/cell_field_actions.js +16 -66
  142. package/dist/auth/cell_grant_action_specs.d.ts +2 -2
  143. package/dist/auth/cell_grant_action_specs.js +3 -3
  144. package/dist/auth/cell_grant_actions.d.ts +73 -11
  145. package/dist/auth/cell_grant_actions.d.ts.map +1 -1
  146. package/dist/auth/cell_grant_actions.js +63 -55
  147. package/dist/auth/cell_grant_audit_metadata.d.ts +6 -3
  148. package/dist/auth/cell_grant_audit_metadata.d.ts.map +1 -1
  149. package/dist/auth/cell_grant_audit_metadata.js +7 -4
  150. package/dist/auth/cell_item_actions.d.ts +1 -1
  151. package/dist/auth/cell_item_actions.d.ts.map +1 -1
  152. package/dist/auth/cell_item_actions.js +21 -82
  153. package/dist/auth/cleanup.d.ts +1 -1
  154. package/dist/auth/cleanup.d.ts.map +1 -1
  155. package/dist/auth/cleanup.js +6 -3
  156. package/dist/auth/credential_deadline.d.ts +3 -3
  157. package/dist/auth/credential_deadline.js +3 -3
  158. package/dist/auth/credential_type_schema.d.ts +5 -5
  159. package/dist/auth/credential_type_schema.js +5 -5
  160. package/dist/auth/daemon_token_middleware.d.ts +12 -6
  161. package/dist/auth/daemon_token_middleware.d.ts.map +1 -1
  162. package/dist/auth/daemon_token_middleware.js +28 -17
  163. package/dist/auth/deps.d.ts +4 -4
  164. package/dist/auth/fail_floor.d.ts +55 -0
  165. package/dist/auth/fail_floor.d.ts.map +1 -0
  166. package/dist/auth/fail_floor.js +63 -0
  167. package/dist/auth/invite_queries.d.ts +3 -15
  168. package/dist/auth/invite_queries.d.ts.map +1 -1
  169. package/dist/auth/invite_queries.js +3 -21
  170. package/dist/auth/middleware.d.ts +12 -7
  171. package/dist/auth/middleware.d.ts.map +1 -1
  172. package/dist/auth/middleware.js +42 -29
  173. package/dist/auth/migrations.d.ts +5 -33
  174. package/dist/auth/migrations.d.ts.map +1 -1
  175. package/dist/auth/migrations.js +9 -16
  176. package/dist/auth/request_context.d.ts +101 -71
  177. package/dist/auth/request_context.d.ts.map +1 -1
  178. package/dist/auth/request_context.js +137 -140
  179. package/dist/auth/resolved_auth.d.ts +122 -36
  180. package/dist/auth/resolved_auth.d.ts.map +1 -1
  181. package/dist/auth/resolved_auth.js +89 -38
  182. package/dist/auth/role_grant_offer_action_specs.d.ts +99 -14
  183. package/dist/auth/role_grant_offer_action_specs.d.ts.map +1 -1
  184. package/dist/auth/role_grant_offer_action_specs.js +26 -13
  185. package/dist/auth/role_grant_offer_actions.d.ts +13 -7
  186. package/dist/auth/role_grant_offer_actions.d.ts.map +1 -1
  187. package/dist/auth/role_grant_offer_actions.js +14 -12
  188. package/dist/auth/role_grant_offer_notifications.d.ts +3 -3
  189. package/dist/auth/role_grant_offer_notifications.js +1 -1
  190. package/dist/auth/role_grant_offer_queries.d.ts +0 -5
  191. package/dist/auth/role_grant_offer_queries.d.ts.map +1 -1
  192. package/dist/auth/role_grant_offer_queries.js +9 -41
  193. package/dist/auth/role_grant_queries.d.ts +17 -67
  194. package/dist/auth/role_grant_queries.d.ts.map +1 -1
  195. package/dist/auth/role_grant_queries.js +34 -106
  196. package/dist/auth/role_grant_sql.d.ts +42 -0
  197. package/dist/auth/role_grant_sql.d.ts.map +1 -0
  198. package/dist/auth/role_grant_sql.js +54 -0
  199. package/dist/auth/scope_kind_schema.d.ts +1 -1
  200. package/dist/auth/scope_kind_schema.js +1 -1
  201. package/dist/auth/self_service_role_actions.d.ts +1 -1
  202. package/dist/auth/self_service_role_actions.d.ts.map +1 -1
  203. package/dist/auth/self_service_role_actions.js +1 -1
  204. package/dist/auth/session_queries.d.ts +2 -1
  205. package/dist/auth/session_queries.d.ts.map +1 -1
  206. package/dist/auth/session_queries.js +2 -1
  207. package/dist/auth/signup_routes.d.ts +2 -1
  208. package/dist/auth/signup_routes.d.ts.map +1 -1
  209. package/dist/auth/signup_routes.js +14 -13
  210. package/dist/auth/standard_rpc_actions.d.ts +1 -1
  211. package/dist/auth/standard_rpc_actions.d.ts.map +1 -1
  212. package/dist/auth/token_scope.d.ts +19 -46
  213. package/dist/auth/token_scope.d.ts.map +1 -1
  214. package/dist/auth/token_scope.js +23 -41
  215. package/dist/db/CLAUDE.md +9 -4
  216. package/dist/db/cell_ddl.d.ts +5 -142
  217. package/dist/db/cell_ddl.d.ts.map +1 -1
  218. package/dist/db/cell_ddl.js +17 -16
  219. package/dist/db/cell_field_queries.d.ts +0 -13
  220. package/dist/db/cell_field_queries.d.ts.map +1 -1
  221. package/dist/db/cell_field_queries.js +0 -16
  222. package/dist/db/cell_grant_queries.d.ts +10 -5
  223. package/dist/db/cell_grant_queries.d.ts.map +1 -1
  224. package/dist/db/cell_grant_queries.js +13 -7
  225. package/dist/db/cell_item_queries.d.ts +0 -7
  226. package/dist/db/cell_item_queries.d.ts.map +1 -1
  227. package/dist/db/cell_item_queries.js +0 -10
  228. package/dist/db/cell_queries.d.ts +12 -48
  229. package/dist/db/cell_queries.d.ts.map +1 -1
  230. package/dist/db/cell_queries.js +24 -55
  231. package/dist/db/cell_view_sql.d.ts +1 -6
  232. package/dist/db/cell_view_sql.d.ts.map +1 -1
  233. package/dist/db/cell_view_sql.js +1 -2
  234. package/dist/db/fact_ddl.d.ts +5 -30
  235. package/dist/db/fact_ddl.d.ts.map +1 -1
  236. package/dist/db/fact_ddl.js +14 -13
  237. package/dist/db/fact_store.d.ts +11 -0
  238. package/dist/db/fact_store.d.ts.map +1 -1
  239. package/dist/db/fact_store.js +4 -1
  240. package/dist/db/migrate.d.ts +44 -6
  241. package/dist/db/migrate.d.ts.map +1 -1
  242. package/dist/db/migrate.js +63 -4
  243. package/dist/dev/setup.d.ts +18 -14
  244. package/dist/dev/setup.d.ts.map +1 -1
  245. package/dist/dev/setup.js +42 -39
  246. package/dist/env/dotenv.d.ts +2 -2
  247. package/dist/env/dotenv.js +2 -2
  248. package/dist/env/update_env_variable.d.ts +33 -21
  249. package/dist/env/update_env_variable.d.ts.map +1 -1
  250. package/dist/env/update_env_variable.js +54 -35
  251. package/dist/hono_context.d.ts +15 -90
  252. package/dist/hono_context.d.ts.map +1 -1
  253. package/dist/hono_context.js +9 -56
  254. package/dist/http/CLAUDE.md +35 -20
  255. package/dist/http/auth_shape.d.ts +1 -8
  256. package/dist/http/auth_shape.d.ts.map +1 -1
  257. package/dist/http/auth_shape.js +6 -12
  258. package/dist/http/common_routes.d.ts.map +1 -1
  259. package/dist/http/common_routes.js +3 -2
  260. package/dist/http/db_routes.d.ts +3 -3
  261. package/dist/http/db_routes.js +3 -3
  262. package/dist/http/error_schemas.d.ts +1 -2
  263. package/dist/http/error_schemas.d.ts.map +1 -1
  264. package/dist/http/error_schemas.js +1 -2
  265. package/dist/http/health_schema.d.ts +16 -0
  266. package/dist/http/health_schema.d.ts.map +1 -0
  267. package/dist/http/health_schema.js +12 -0
  268. package/dist/http/jsonrpc_errors.d.ts +22 -2
  269. package/dist/http/jsonrpc_errors.d.ts.map +1 -1
  270. package/dist/http/jsonrpc_errors.js +41 -3
  271. package/dist/http/jsonrpc_helpers.d.ts +60 -17
  272. package/dist/http/jsonrpc_helpers.d.ts.map +1 -1
  273. package/dist/http/jsonrpc_helpers.js +67 -25
  274. package/dist/http/origin.d.ts +30 -1
  275. package/dist/http/origin.d.ts.map +1 -1
  276. package/dist/http/origin.js +46 -9
  277. package/dist/http/origin_wildcard.d.ts +97 -0
  278. package/dist/http/origin_wildcard.d.ts.map +1 -0
  279. package/dist/http/origin_wildcard.js +142 -0
  280. package/dist/http/pending_effects.d.ts +28 -0
  281. package/dist/http/pending_effects.d.ts.map +1 -1
  282. package/dist/http/pending_effects.js +32 -1
  283. package/dist/http/route_spec.d.ts +4 -3
  284. package/dist/http/route_spec.d.ts.map +1 -1
  285. package/dist/http/route_spec.js +54 -45
  286. package/dist/http/surface.d.ts +1 -1
  287. package/dist/http/surface.d.ts.map +1 -1
  288. package/dist/http/surface_query.d.ts +9 -50
  289. package/dist/http/surface_query.d.ts.map +1 -1
  290. package/dist/http/surface_query.js +48 -94
  291. package/dist/realtime/audit_log_sse.d.ts +180 -0
  292. package/dist/realtime/audit_log_sse.d.ts.map +1 -0
  293. package/dist/realtime/audit_log_sse.js +154 -0
  294. package/dist/realtime/sse.d.ts +21 -6
  295. package/dist/realtime/sse.d.ts.map +1 -1
  296. package/dist/realtime/sse.js +33 -10
  297. package/dist/realtime/sse_constants.d.ts +29 -2
  298. package/dist/realtime/sse_constants.d.ts.map +1 -1
  299. package/dist/realtime/sse_constants.js +35 -2
  300. package/dist/realtime/{subscriber_registry.d.ts → sse_registry.d.ts} +12 -12
  301. package/dist/realtime/sse_registry.d.ts.map +1 -0
  302. package/dist/realtime/{subscriber_registry.js → sse_registry.js} +4 -4
  303. package/dist/schema_meta.d.ts +30 -10
  304. package/dist/schema_meta.d.ts.map +1 -1
  305. package/dist/schema_meta.js +85 -21
  306. package/dist/sensitivity.d.ts +9 -3
  307. package/dist/sensitivity.d.ts.map +1 -1
  308. package/dist/sensitivity.js +3 -2
  309. package/dist/server/app_backend.d.ts +8 -5
  310. package/dist/server/app_backend.d.ts.map +1 -1
  311. package/dist/server/app_backend.js +6 -12
  312. package/dist/server/app_server.d.ts +62 -51
  313. package/dist/server/app_server.d.ts.map +1 -1
  314. package/dist/server/app_server.js +84 -71
  315. package/dist/server/app_server_context.d.ts +1 -1
  316. package/dist/server/app_server_context.d.ts.map +1 -1
  317. package/dist/server/env.d.ts +24 -20
  318. package/dist/server/env.d.ts.map +1 -1
  319. package/dist/server/env.js +24 -34
  320. package/dist/server/serve_fact_route.d.ts +12 -16
  321. package/dist/server/serve_fact_route.d.ts.map +1 -1
  322. package/dist/server/serve_fact_route.js +59 -34
  323. package/dist/server/static.d.ts.map +1 -1
  324. package/dist/server/static.js +2 -2
  325. package/dist/testing/CLAUDE.md +179 -158
  326. package/dist/testing/admin_integration.d.ts.map +1 -1
  327. package/dist/testing/admin_integration.js +10 -19
  328. package/dist/testing/adversarial_headers.d.ts.map +1 -1
  329. package/dist/testing/adversarial_headers.js +8 -0
  330. package/dist/testing/app_server.d.ts +9 -77
  331. package/dist/testing/app_server.d.ts.map +1 -1
  332. package/dist/testing/app_server.js +31 -112
  333. package/dist/testing/attack_surface.d.ts.map +1 -1
  334. package/dist/testing/attack_surface.js +3 -4
  335. package/dist/testing/audit_completeness.d.ts.map +1 -1
  336. package/dist/testing/audit_completeness.js +4 -5
  337. package/dist/testing/auth_apps.d.ts +3 -3
  338. package/dist/testing/auth_apps.d.ts.map +1 -1
  339. package/dist/testing/auth_apps.js +9 -6
  340. package/dist/testing/connection_closer_helpers.d.ts +8 -16
  341. package/dist/testing/connection_closer_helpers.d.ts.map +1 -1
  342. package/dist/testing/connection_closer_helpers.js +7 -20
  343. package/dist/testing/cross_backend/action_manifest.d.ts +15 -4
  344. package/dist/testing/cross_backend/action_manifest.d.ts.map +1 -1
  345. package/dist/testing/cross_backend/action_manifest.js +13 -3
  346. package/dist/testing/cross_backend/action_manifest_parity.d.ts +15 -7
  347. package/dist/testing/cross_backend/action_manifest_parity.d.ts.map +1 -1
  348. package/dist/testing/cross_backend/action_manifest_parity.js +8 -1
  349. package/dist/testing/cross_backend/body_size.d.ts.map +1 -1
  350. package/dist/testing/cross_backend/body_size.js +25 -22
  351. package/dist/testing/cross_backend/build_test_backend_paths.d.ts +22 -3
  352. package/dist/testing/cross_backend/build_test_backend_paths.d.ts.map +1 -1
  353. package/dist/testing/cross_backend/build_test_backend_paths.js +34 -11
  354. package/dist/testing/cross_backend/capabilities.d.ts +13 -7
  355. package/dist/testing/cross_backend/capabilities.d.ts.map +1 -1
  356. package/dist/testing/cross_backend/cell_grant_role.js +2 -2
  357. package/dist/testing/cross_backend/cell_grant_steward.d.ts +4 -0
  358. package/dist/testing/cross_backend/cell_grant_steward.d.ts.map +1 -0
  359. package/dist/testing/cross_backend/cell_grant_steward.js +120 -0
  360. package/dist/testing/cross_backend/cell_relations.d.ts.map +1 -1
  361. package/dist/testing/cross_backend/cell_relations.js +21 -0
  362. package/dist/testing/cross_backend/conformance_table.d.ts +1 -1
  363. package/dist/testing/cross_backend/conformance_table.d.ts.map +1 -1
  364. package/dist/testing/cross_backend/default_backend_configs.d.ts +18 -4
  365. package/dist/testing/cross_backend/default_backend_configs.d.ts.map +1 -1
  366. package/dist/testing/cross_backend/default_backend_configs.js +29 -9
  367. package/dist/testing/cross_backend/default_spine_surface.d.ts +7 -7
  368. package/dist/testing/cross_backend/default_spine_surface.js +2 -2
  369. package/dist/testing/cross_backend/fact_serving.d.ts.map +1 -1
  370. package/dist/testing/cross_backend/fact_serving.js +48 -0
  371. package/dist/testing/cross_backend/full_spine_mount.d.ts +3 -4
  372. package/dist/testing/cross_backend/full_spine_mount.d.ts.map +1 -1
  373. package/dist/testing/cross_backend/full_spine_mount.js +9 -2
  374. package/dist/testing/cross_backend/origin_scope.d.ts.map +1 -1
  375. package/dist/testing/cross_backend/origin_scope.js +5 -13
  376. package/dist/testing/cross_backend/peer_ping_ws.d.ts.map +1 -1
  377. package/dist/testing/cross_backend/peer_ping_ws.js +29 -4
  378. package/dist/testing/cross_backend/postgres_database.d.ts +32 -0
  379. package/dist/testing/cross_backend/postgres_database.d.ts.map +1 -1
  380. package/dist/testing/cross_backend/postgres_database.js +56 -1
  381. package/dist/testing/cross_backend/query_shape.d.ts.map +1 -1
  382. package/dist/testing/cross_backend/query_shape.js +18 -1
  383. package/dist/testing/cross_backend/role_grant_offer_lifecycle.d.ts.map +1 -1
  384. package/dist/testing/cross_backend/role_grant_offer_lifecycle.js +23 -1
  385. package/dist/testing/cross_backend/rpc_success_fixtures.js +2 -2
  386. package/dist/testing/cross_backend/rust_spine_consumer_surface.d.ts +1 -1
  387. package/dist/testing/cross_backend/rust_spine_consumer_surface.d.ts.map +1 -1
  388. package/dist/testing/cross_backend/rust_spine_stub_backend_config.d.ts +17 -5
  389. package/dist/testing/cross_backend/rust_spine_stub_backend_config.d.ts.map +1 -1
  390. package/dist/testing/cross_backend/rust_spine_stub_backend_config.js +5 -4
  391. package/dist/testing/cross_backend/session_cap.d.ts +8 -0
  392. package/dist/testing/cross_backend/session_cap.d.ts.map +1 -1
  393. package/dist/testing/cross_backend/session_cap.js +66 -2
  394. package/dist/testing/cross_backend/setup.d.ts.map +1 -1
  395. package/dist/testing/cross_backend/setup.js +5 -4
  396. package/dist/testing/cross_backend/spine_suites.d.ts +4 -1
  397. package/dist/testing/cross_backend/spine_suites.d.ts.map +1 -1
  398. package/dist/testing/cross_backend/spine_suites.js +21 -0
  399. package/dist/testing/cross_backend/spine_surface_constants.d.ts +22 -7
  400. package/dist/testing/cross_backend/spine_surface_constants.d.ts.map +1 -1
  401. package/dist/testing/cross_backend/spine_surface_constants.js +22 -7
  402. package/dist/testing/cross_backend/sse_round_trip.d.ts.map +1 -1
  403. package/dist/testing/cross_backend/sse_round_trip.js +4 -3
  404. package/dist/testing/cross_backend/standard.d.ts +6 -12
  405. package/dist/testing/cross_backend/standard.d.ts.map +1 -1
  406. package/dist/testing/cross_backend/test_cell_grant_steward_revoke_authorize.d.ts +8 -0
  407. package/dist/testing/cross_backend/test_cell_grant_steward_revoke_authorize.d.ts.map +1 -0
  408. package/dist/testing/cross_backend/test_cell_grant_steward_revoke_authorize.js +22 -0
  409. package/dist/testing/cross_backend/testing_backdoor.d.ts.map +1 -1
  410. package/dist/testing/cross_backend/testing_backdoor.js +4 -6
  411. package/dist/testing/cross_backend/testing_origin_check.d.ts +1 -1
  412. package/dist/testing/cross_backend/testing_origin_check.d.ts.map +1 -1
  413. package/dist/testing/cross_backend/testing_origin_check.js +1 -1
  414. package/dist/testing/cross_backend/testing_reset_actions.d.ts +10 -5
  415. package/dist/testing/cross_backend/testing_reset_actions.d.ts.map +1 -1
  416. package/dist/testing/cross_backend/testing_reset_actions.js +7 -6
  417. package/dist/testing/cross_backend/testing_server_bun.d.ts.map +1 -1
  418. package/dist/testing/cross_backend/testing_server_bun.js +5 -4
  419. package/dist/testing/cross_backend/testing_server_core.d.ts +6 -7
  420. package/dist/testing/cross_backend/testing_server_core.d.ts.map +1 -1
  421. package/dist/testing/cross_backend/testing_server_core.js +1 -1
  422. package/dist/testing/cross_backend/testing_server_node.d.ts.map +1 -1
  423. package/dist/testing/cross_backend/testing_server_node.js +13 -2
  424. package/dist/testing/cross_backend/token_lifetime.d.ts.map +1 -1
  425. package/dist/testing/cross_backend/token_lifetime.js +68 -0
  426. package/dist/testing/cross_backend/transport_composition.d.ts +1 -1
  427. package/dist/testing/cross_backend/transport_composition.d.ts.map +1 -1
  428. package/dist/testing/cross_backend/transport_composition.js +45 -3
  429. package/dist/testing/cross_backend/ts_spine_backend_config.d.ts +16 -2
  430. package/dist/testing/cross_backend/ts_spine_backend_config.d.ts.map +1 -1
  431. package/dist/testing/cross_backend/ts_spine_backend_config.js +11 -8
  432. package/dist/testing/cross_backend/ws_action_rate_limit.d.ts.map +1 -1
  433. package/dist/testing/cross_backend/ws_action_rate_limit.js +30 -12
  434. package/dist/testing/cross_backend/ws_connection_cap.d.ts.map +1 -1
  435. package/dist/testing/cross_backend/ws_connection_cap.js +5 -7
  436. package/dist/testing/cross_backend/ws_endpoint.d.ts +2 -3
  437. package/dist/testing/cross_backend/ws_endpoint.d.ts.map +1 -1
  438. package/dist/testing/cross_backend/ws_envelope.d.ts +17 -0
  439. package/dist/testing/cross_backend/ws_envelope.d.ts.map +1 -0
  440. package/dist/testing/cross_backend/ws_envelope.js +172 -0
  441. package/dist/testing/cross_backend/ws_inbound_dispatch.d.ts +16 -0
  442. package/dist/testing/cross_backend/ws_inbound_dispatch.d.ts.map +1 -1
  443. package/dist/testing/cross_backend/ws_inbound_dispatch.js +8 -4
  444. package/dist/testing/cross_backend/ws_outbound_overflow.d.ts.map +1 -1
  445. package/dist/testing/cross_backend/ws_outbound_overflow.js +5 -8
  446. package/dist/testing/cross_backend/ws_role_gated.js +2 -2
  447. package/dist/testing/cross_backend/ws_round_trip.d.ts.map +1 -1
  448. package/dist/testing/cross_backend/ws_round_trip.js +6 -4
  449. package/dist/{cli/daemon.d.ts → testing/daemon_info.d.ts} +15 -47
  450. package/dist/testing/daemon_info.d.ts.map +1 -0
  451. package/dist/testing/daemon_info.js +108 -0
  452. package/dist/testing/daemon_token_rotation.js +1 -1
  453. package/dist/testing/data_exposure.d.ts.map +1 -1
  454. package/dist/testing/data_exposure.js +3 -4
  455. package/dist/testing/db.js +2 -2
  456. package/dist/testing/integration.d.ts.map +1 -1
  457. package/dist/testing/integration.js +35 -65
  458. package/dist/testing/integration_helpers.d.ts +0 -15
  459. package/dist/testing/integration_helpers.d.ts.map +1 -1
  460. package/dist/testing/integration_helpers.js +2 -42
  461. package/dist/testing/middleware.d.ts +20 -12
  462. package/dist/testing/middleware.d.ts.map +1 -1
  463. package/dist/testing/middleware.js +49 -40
  464. package/dist/testing/rate_limiting.d.ts.map +1 -1
  465. package/dist/testing/rate_limiting.js +13 -22
  466. package/dist/testing/resolved_auth.d.ts +30 -0
  467. package/dist/testing/resolved_auth.d.ts.map +1 -0
  468. package/dist/testing/resolved_auth.js +41 -0
  469. package/dist/testing/rpc_envelope_cases.d.ts.map +1 -1
  470. package/dist/testing/rpc_envelope_cases.js +3 -0
  471. package/dist/testing/rpc_helpers.d.ts +1 -1
  472. package/dist/testing/rpc_helpers.d.ts.map +1 -1
  473. package/dist/testing/rpc_helpers.js +2 -1
  474. package/dist/testing/sse_round_trip.d.ts +5 -4
  475. package/dist/testing/sse_round_trip.d.ts.map +1 -1
  476. package/dist/testing/sse_round_trip.js +2 -2
  477. package/dist/testing/stubs.d.ts +2 -2
  478. package/dist/testing/stubs.d.ts.map +1 -1
  479. package/dist/testing/stubs.js +24 -21
  480. package/dist/testing/test_origin.d.ts +25 -0
  481. package/dist/testing/test_origin.d.ts.map +1 -0
  482. package/dist/testing/test_origin.js +28 -0
  483. package/dist/testing/transports/raw_http.d.ts +54 -0
  484. package/dist/testing/transports/raw_http.d.ts.map +1 -1
  485. package/dist/testing/transports/raw_http.js +58 -0
  486. package/dist/testing/transports/ws_raw_client.d.ts +8 -0
  487. package/dist/testing/transports/ws_raw_client.d.ts.map +1 -1
  488. package/dist/testing/transports/ws_raw_client.js +13 -0
  489. package/dist/testing/transports/ws_transport.d.ts +15 -2
  490. package/dist/testing/transports/ws_transport.d.ts.map +1 -1
  491. package/dist/testing/transports/ws_transport.js +4 -2
  492. package/dist/testing/ws_round_trip.d.ts +27 -25
  493. package/dist/testing/ws_round_trip.d.ts.map +1 -1
  494. package/dist/testing/ws_round_trip.js +34 -26
  495. package/dist/ui/AccountSessions.svelte +48 -19
  496. package/dist/ui/AccountSessions.svelte.d.ts +2 -17
  497. package/dist/ui/AccountSessions.svelte.d.ts.map +1 -1
  498. package/dist/ui/AdminAccounts.svelte +6 -1
  499. package/dist/ui/AdminAuditLog.svelte +61 -22
  500. package/dist/ui/AdminAuditLog.svelte.d.ts.map +1 -1
  501. package/dist/ui/AdminInvites.svelte +1 -1
  502. package/dist/ui/AdminOverview.svelte +76 -37
  503. package/dist/ui/AdminOverview.svelte.d.ts.map +1 -1
  504. package/dist/ui/AdminRoleGrantHistory.svelte +6 -1
  505. package/dist/ui/AdminSessions.svelte +1 -1
  506. package/dist/ui/AppShell.svelte +3 -2
  507. package/dist/ui/AppShell.svelte.d.ts +3 -2
  508. package/dist/ui/AppShell.svelte.d.ts.map +1 -1
  509. package/dist/ui/CLAUDE.md +121 -35
  510. package/dist/ui/Datatable.svelte +33 -18
  511. package/dist/ui/Datatable.svelte.d.ts +2 -14
  512. package/dist/ui/Datatable.svelte.d.ts.map +1 -1
  513. package/dist/ui/OpenSignupToggle.svelte +10 -1
  514. package/dist/ui/OpenSignupToggle.svelte.d.ts.map +1 -1
  515. package/dist/ui/PopoverButton.svelte +13 -8
  516. package/dist/ui/PopoverButton.svelte.d.ts.map +1 -1
  517. package/dist/ui/RoleGrantOfferForm.svelte +3 -2
  518. package/dist/ui/RoleGrantOfferForm.svelte.d.ts +3 -2
  519. package/dist/ui/RoleGrantOfferForm.svelte.d.ts.map +1 -1
  520. package/dist/ui/RoleGrantOfferHistory.svelte +3 -3
  521. package/dist/ui/RoleGrantOfferInbox.svelte +19 -15
  522. package/dist/ui/RoleGrantOfferInbox.svelte.d.ts.map +1 -1
  523. package/dist/ui/SurfaceExplorer.svelte +66 -27
  524. package/dist/ui/SurfaceExplorer.svelte.d.ts.map +1 -1
  525. package/dist/ui/account_sessions_state.svelte.d.ts +7 -14
  526. package/dist/ui/account_sessions_state.svelte.d.ts.map +1 -1
  527. package/dist/ui/admin_accounts_state.svelte.d.ts +14 -9
  528. package/dist/ui/admin_accounts_state.svelte.d.ts.map +1 -1
  529. package/dist/ui/admin_accounts_state.svelte.js +6 -4
  530. package/dist/ui/admin_invites_state.svelte.d.ts +2 -2
  531. package/dist/ui/admin_invites_state.svelte.d.ts.map +1 -1
  532. package/dist/ui/admin_rpc_adapters.d.ts +9 -9
  533. package/dist/ui/admin_rpc_adapters.d.ts.map +1 -1
  534. package/dist/ui/admin_rpc_adapters.js +9 -9
  535. package/dist/ui/app_settings_state.svelte.d.ts +2 -2
  536. package/dist/ui/app_settings_state.svelte.d.ts.map +1 -1
  537. package/dist/ui/audit_log_state.svelte.d.ts +70 -13
  538. package/dist/ui/audit_log_state.svelte.d.ts.map +1 -1
  539. package/dist/ui/audit_log_state.svelte.js +239 -47
  540. package/dist/ui/backend_probe.svelte.d.ts +93 -0
  541. package/dist/ui/backend_probe.svelte.d.ts.map +1 -0
  542. package/dist/ui/backend_probe.svelte.js +140 -0
  543. package/dist/ui/format_scope.d.ts +7 -7
  544. package/dist/ui/format_scope.d.ts.map +1 -1
  545. package/dist/ui/format_scope.js +4 -4
  546. package/dist/ui/keyed_async_slot.svelte.d.ts +2 -2
  547. package/dist/ui/keyed_async_slot.svelte.js +2 -2
  548. package/dist/ui/popover.svelte.d.ts +18 -19
  549. package/dist/ui/popover.svelte.d.ts.map +1 -1
  550. package/dist/ui/popover.svelte.js +103 -16
  551. package/dist/ui/role_grant_offers_state.svelte.d.ts +41 -46
  552. package/dist/ui/role_grant_offers_state.svelte.d.ts.map +1 -1
  553. package/dist/ui/role_grant_offers_state.svelte.js +37 -19
  554. package/dist/ui/ui_format.d.ts +17 -0
  555. package/dist/ui/ui_format.d.ts.map +1 -1
  556. package/dist/ui/ui_format.js +20 -0
  557. package/package.json +2 -1
  558. package/dist/actions/register_ws_endpoint.d.ts +0 -79
  559. package/dist/actions/register_ws_endpoint.d.ts.map +0 -1
  560. package/dist/actions/register_ws_endpoint.js +0 -109
  561. package/dist/actions/transports_ws_auth_guard.d.ts +0 -96
  562. package/dist/actions/transports_ws_auth_guard.d.ts.map +0 -1
  563. package/dist/actions/transports_ws_auth_guard.js +0 -141
  564. package/dist/actions/transports_ws_backend.d.ts.map +0 -1
  565. package/dist/cli/args.d.ts +0 -55
  566. package/dist/cli/args.d.ts.map +0 -1
  567. package/dist/cli/args.js +0 -100
  568. package/dist/cli/config.d.ts +0 -47
  569. package/dist/cli/config.d.ts.map +0 -1
  570. package/dist/cli/config.js +0 -77
  571. package/dist/cli/daemon.d.ts.map +0 -1
  572. package/dist/cli/daemon.js +0 -181
  573. package/dist/cli/help.d.ts +0 -124
  574. package/dist/cli/help.d.ts.map +0 -1
  575. package/dist/cli/help.js +0 -215
  576. package/dist/cli/logger.d.ts +0 -46
  577. package/dist/cli/logger.d.ts.map +0 -1
  578. package/dist/cli/logger.js +0 -48
  579. package/dist/cli/util.d.ts +0 -36
  580. package/dist/cli/util.d.ts.map +0 -1
  581. package/dist/cli/util.js +0 -50
  582. package/dist/realtime/sse_auth_guard.d.ts +0 -197
  583. package/dist/realtime/sse_auth_guard.d.ts.map +0 -1
  584. package/dist/realtime/sse_auth_guard.js +0 -239
  585. package/dist/realtime/subscriber_registry.d.ts.map +0 -1
  586. package/dist/testing/bootstrap_success.d.ts +0 -29
  587. package/dist/testing/bootstrap_success.d.ts.map +0 -1
  588. package/dist/testing/bootstrap_success.js +0 -144
  589. package/dist/testing/mock_fs.d.ts +0 -20
  590. package/dist/testing/mock_fs.d.ts.map +0 -1
  591. package/dist/testing/mock_fs.js +0 -28
  592. package/dist/testing/standard.d.ts +0 -122
  593. package/dist/testing/standard.d.ts.map +0 -1
  594. package/dist/testing/standard.js +0 -73
  595. package/dist/testing/testing_rate_limiter.d.ts +0 -65
  596. package/dist/testing/testing_rate_limiter.d.ts.map +0 -1
  597. package/dist/testing/testing_rate_limiter.js +0 -80
@@ -7,227 +7,20 @@
7
7
  * inside the dispatcher.
8
8
  *
9
9
  * Handler signature: `(input: TInput, ctx: ActionContext) => TOutput`
10
- * where `ActionContext` provides auth identity, DB, and framework context.
10
+ * where `ActionContext` (`actions/action_types.ts`) provides auth identity,
11
+ * DB, and framework context.
11
12
  *
12
13
  * @module
13
14
  */
14
- import { z } from 'zod';
15
15
  import type { Logger } from '@fuzdev/fuz_util/log.ts';
16
- import type { Uuid } from '../primitive_schemas.js';
17
- import type { RequestResponseActionSpec } from './action_spec.js';
16
+ import type { RpcAction } from './action_types.js';
18
17
  import { type RouteSpec } from '../http/route_spec.js';
19
- import { type RequestActorContext, type RequestContext } from '../auth/request_context.js';
20
- import { type CredentialType } from '../hono_context.js';
21
- import type { Db } from '../db/db.js';
22
- import type { RequestClient } from './peer_request.js';
23
- import { type JsonrpcRequestId } from '../http/jsonrpc.js';
24
18
  import type { RateLimiter } from '../rate_limiter.js';
25
19
  /**
26
- * Per-request context provided to action handlers across every transport
27
- * (HTTP RPC, WebSocket, REST bridge). Built once per dispatched action by
28
- * `perform_action` and threaded into the handler.
29
- *
30
- * `auth` is `RequestContext | null` — handlers for authenticated actions
31
- * can narrow via the dispatcher's authorization-phase guarantee.
32
- *
33
- * Single handler context shape across every transport. Consumers inject
34
- * domain deps via factory closures the same way HTTP RPC factories do.
35
- */
36
- export interface ActionContext {
37
- /** The authenticated identity, or `null` for public routes. */
38
- auth: RequestContext | null;
39
- /** The JSON-RPC request ID from the envelope. */
40
- request_id: JsonrpcRequestId;
41
- /**
42
- * Stable per-socket connection id on WebSocket transport; `undefined`
43
- * on HTTP RPC. Consumers key per-connection domain state on this
44
- * directly; HTTP handlers ignore it.
45
- */
46
- connection_id?: Uuid;
47
- /**
48
- * Initiate a JSON-RPC request to the originating client and await its typed
49
- * reply — the server→client direction of ActionPeer. Present only on the
50
- * WebSocket transport (it targets the originating socket); `undefined` on
51
- * HTTP RPC, where there is no return socket. Handlers that depend on it
52
- * must handle its absence — e.g. `peer/ping` surfaces `peer_no_transport`.
53
- */
54
- request_client?: RequestClient;
55
- /**
56
- * Transaction-scoped when `spec.side_effects` is true (the dispatcher
57
- * wraps in `db.transaction`); pool-level otherwise. Handlers that
58
- * need rollback-resilient writes call `deps.audit.emit(ctx, input)`,
59
- * which captures the pool inside its closure.
60
- */
61
- db: Db;
62
- /**
63
- * Eager fire-and-forget queue — push the in-flight `Promise<void>` for
64
- * pool writes already running (audit emits, api-token usage
65
- * tracking). Drained via `flush_pending_effects` after the
66
- * handler returns.
67
- */
68
- pending_effects: Array<Promise<void>>;
69
- /**
70
- * Deferred post-commit thunks — do not push directly; reach for
71
- * `emit_after_commit(ctx, fn)` from `http/pending_effects.ts`. The flush
72
- * site invokes each thunk after the handler (and any wrapping
73
- * `db.transaction`) returns.
74
- */
75
- post_commit_effects: Array<() => void | Promise<void>>;
76
- /**
77
- * Resolved client IP from the trusted-proxy middleware — `'unknown'` if the
78
- * middleware wasn't in the stack (e.g. WS dispatch) or couldn't resolve.
79
- * Thread into `deps.audit.emit` as `ip: ctx.client_ip` for every
80
- * user-initiated action so RPC audit rows match the REST convention. Pass
81
- * `null` only for rows written outside a request (e.g. the
82
- * `role_grant_offer_expire` cleanup sweep in `auth/cleanup.ts`).
83
- */
84
- client_ip: string;
85
- /**
86
- * Credential channel the request arrived on (`'session'` | `'api_token'` |
87
- * `'daemon_token'`), or `null` for anonymous requests. Same value the
88
- * dispatcher's `credential_types` gate consumed at step 3 — exposed here
89
- * so handlers can record it in audit metadata (defense in depth: the
90
- * gate may be loosened or bypassed in a future refactor, but the audit
91
- * row preserves what actually authenticated the request).
92
- */
93
- credential_type: CredentialType | null;
94
- /** Logger instance. */
95
- log: Logger;
96
- /**
97
- * Send a request-scoped JSON-RPC notification to the originator.
98
- *
99
- * On streaming transports (WebSocket) this routes to the originating
100
- * connection only. On the HTTP RPC transport this is a no-op with a
101
- * DEV-mode warn — non-streaming transports have no channel for mid-
102
- * request notifications. The `streams` field on an `ActionSpec` names
103
- * the notification method this handler is expected to emit.
104
- */
105
- notify: (method: string, params: unknown) => void;
106
- /**
107
- * AbortSignal that fires when the originating request is cancelled
108
- * (client disconnect on HTTP, socket close or per-request cancel
109
- * notification on WebSocket). Streaming handlers should check this
110
- * for early termination.
111
- */
112
- signal: AbortSignal;
113
- }
114
- /**
115
- * Handler function for an RPC action.
116
- *
117
- * Receives validated input and an `ActionContext` with per-request deps.
118
- * Returns the output value (serialized to JSON by the wrapper).
119
- */
120
- export type ActionHandler<TInput = any, TOutput = any> = (input: TInput, ctx: ActionContext) => TOutput | Promise<TOutput>;
121
- /**
122
- * `ActionContext` narrowed to a non-null `RequestContext`.
123
- *
124
- * Used by handlers whose spec declares `auth.account === 'required'`
125
- * (with `auth.actor === 'none'`) — the dispatcher's pre-authorization 401
126
- * gate guarantees `request_context` is populated before the handler
127
- * runs, but the actor slot stays null because no `acting` resolution
128
- * happened. Selected automatically by `rpc_action`'s conditional return
129
- * type for the account-grain tier.
130
- */
131
- export interface ActionAuthContext extends Omit<ActionContext, 'auth'> {
132
- auth: RequestContext;
133
- }
134
- /**
135
- * Handler signature for an account-grain RPC action — `auth.account === 'required'`
136
- * and `auth.actor === 'none'`. Mirrors `ActionHandler` but tightens the
137
- * `ctx.auth` slot to the non-null `RequestContext` (with `actor: null`).
138
- */
139
- export type AuthActionHandler<TInput = any, TOutput = any> = (input: TInput, ctx: ActionAuthContext) => TOutput | Promise<TOutput>;
140
- /**
141
- * `ActionContext` narrowed to a resolved acting actor.
142
- *
143
- * Used by handlers whose spec declares `auth.actor === 'required'` —
144
- * the dispatcher's authorization phase resolves an actor (per
145
- * registry-time invariant 2 the input declares `acting?: ActingActor`),
146
- * so `ctx.auth.actor` is non-null. Selected automatically by
147
- * `rpc_action`'s conditional return type for the actor-implying tier.
148
- */
149
- export interface ActionActorContext extends Omit<ActionContext, 'auth'> {
150
- auth: RequestActorContext;
151
- }
152
- /**
153
- * Handler signature for an actor-implying RPC action — `auth.actor === 'required'`.
154
- * Mirrors `ActionHandler` but tightens the `ctx.auth` slot to the
155
- * non-null `RequestActorContext` (with non-null `actor`).
156
- */
157
- export type ActorActionHandler<TInput = any, TOutput = any> = (input: TInput, ctx: ActionActorContext) => TOutput | Promise<TOutput>;
158
- /**
159
- * An RPC action — combines an action spec with its handler.
160
- *
161
- * The spec defines the contract (method, auth, schemas, side effects).
162
- * The handler implements the behavior.
163
- */
164
- export interface RpcAction {
165
- spec: RequestResponseActionSpec;
166
- handler: ActionHandler;
167
- }
168
- /**
169
- * Conditional handler shape for `rpc_action` — picks the narrowest
170
- * `ctx.auth` type the dispatcher's runtime guarantee allows:
171
- *
172
- * - `auth.actor === 'required'` → `ActorActionHandler` (`ctx.auth: RequestActorContext`).
173
- * - `auth.account === 'required' && auth.actor === 'none'` → `AuthActionHandler` (`ctx.auth: RequestContext`).
174
- * - else (public, optional axes) → `ActionHandler` (`ctx.auth: RequestContext | null`).
175
- *
176
- * The bracketed form `[T] extends ['required']` defeats distributive
177
- * conditionals so a degraded `AuthAxisState` union (when the spec was
178
- * typed without preserving its literal) falls through to the loosest
179
- * tier instead of collapsing to the narrowest.
180
- */
181
- export type HandlerForSpec<TSpec extends RequestResponseActionSpec> = [
182
- TSpec['auth']['actor']
183
- ] extends ['required'] ? ActorActionHandler<z.infer<TSpec['input']>, z.infer<TSpec['output']>> : [TSpec['auth']['account']] extends ['required'] ? AuthActionHandler<z.infer<TSpec['input']>, z.infer<TSpec['output']>> : ActionHandler<z.infer<TSpec['input']>, z.infer<TSpec['output']>>;
184
- /**
185
- * Pair a spec with a handler while preserving per-method input/output types
186
- * and selecting the narrowest `ctx.auth` shape the spec literal admits.
187
- *
188
- * Constructing `{spec, handler}` literals widens `handler` to
189
- * `ActionHandler<any, any>`, so spec/handler drift (renamed Zod schema,
190
- * output field removal, input shape change) slips past the typechecker.
191
- * `rpc_action(spec, handler)` binds the handler signature to
192
- * `(input: z.infer<spec.input>, ctx) => z.infer<spec.output>` via the
193
- * generic spec parameter — drift surfaces at the call site.
194
- *
195
- * The `ctx.auth` narrowing follows the spec's `auth.account` /
196
- * `auth.actor` literals (see `HandlerForSpec`): an actor-implying spec
197
- * gets `ctx.auth: RequestActorContext`; an account-grain spec gets
198
- * `ctx.auth: RequestContext`; everything else stays `ctx.auth:
199
- * RequestContext | null`. Handlers can rely on the dispatcher's
200
- * runtime guarantee without a manual narrowing call.
201
- *
202
- * Fits fuz_app's factory-closure pattern (handlers close over
203
- * `grantable_roles`, `app_settings` ref, `notification_sender`, etc.).
204
- * zzz uses a different shape — a codegen-keyed `Record<Method, Handler>`
205
- * map typed via generated `ActionInputs`/`ActionOutputs` — which works when
206
- * handlers are pure (no closure state) and specs are codegen-enumerated.
207
- * fuz_app's admin + role-grant-offer actions have neither, so per-pair typing
208
- * at the registration site is the right fit.
209
- *
210
- * Spec-literal preservation is load-bearing: declare specs with
211
- * `satisfies RequestResponseActionSpec` (canonical) so `auth.actor`
212
- * keeps its `'required'` / `'none'` literal type. A spec typed
213
- * directly as `RequestResponseActionSpec` widens the axes to
214
- * `AuthAxisState` and the handler defaults to the loosest tier — sound,
215
- * but loses the ergonomic narrowing.
216
- *
217
- * @example
218
- * ```ts
219
- * // actor-implying spec → ctx.auth: RequestActorContext
220
- * rpc_action(role_grant_revoke_action_spec, async (input, ctx) => {
221
- * const revoker_id = ctx.auth.actor.id; // no narrowing needed
222
- * });
223
- *
224
- * // account-grain spec → ctx.auth: RequestContext (actor: null)
225
- * rpc_action(account_verify_action_spec, (_input, ctx) => {
226
- * return to_session_account(ctx.auth.account); // no narrowing needed
227
- * });
228
- * ```
20
+ * The `Cache-Control` every response of the RPC endpoint's `GET` route carries
21
+ * — a read is per caller and per moment, so nothing may store it.
229
22
  */
230
- export declare const rpc_action: <TSpec extends RequestResponseActionSpec>(spec: TSpec, handler: HandlerForSpec<TSpec>) => RpcAction;
23
+ export declare const RPC_GET_CACHE_CONTROL = "no-store";
231
24
  /** Options for `create_rpc_endpoint`. */
232
25
  export interface CreateRpcEndpointOptions {
233
26
  /** Mount path for the endpoint (e.g., `/api/rpc`). */
@@ -262,7 +55,7 @@ export interface CreateRpcEndpointOptions {
262
55
  * Returns two `RouteSpec` entries (GET + POST on the same path) for
263
56
  * `apply_route_specs`. The internal dispatcher handles:
264
57
  *
265
- * 1. **Parse envelope** — POST: JSON body as `JsonrpcRequest`. GET: `method`
58
+ * 1. **Parse envelope** — POST: JSON body through `classify_jsonrpc_message`. GET: `method`
266
59
  * and `params` from query string.
267
60
  * 2. **Lookup method** — find the `RpcAction` by method name.
268
61
  * 3. **Pre-authorization auth** — short-circuit `unauthenticated` when no
@@ -281,7 +74,9 @@ export interface CreateRpcEndpointOptions {
281
74
  * 8. **Dispatch** — acquire DB handle (transaction for mutations, pool for reads),
282
75
  * construct `ActionContext`, call handler, return JSON-RPC response.
283
76
  *
284
- * GET is restricted to `side_effects: false` actions (cacheable reads).
77
+ * GET is restricted to `side_effects: false` actions, and every response the
78
+ * GET handler writes, its refusals included, carries `Cache-Control: no-store`
79
+ * (`RPC_GET_CACHE_CONTROL`) — a refusal by middleware ahead of it does not.
285
80
  * All errors use JSON-RPC format: `{jsonrpc, id, error: {code, message, data?}}`.
286
81
  *
287
82
  * The RouteSpecs use `auth: {type: 'none'}` because auth is checked per-action
@@ -1 +1 @@
1
- {"version":3,"file":"action_rpc.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/actions/action_rpc.ts"],"names":[],"mappings":"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"}
1
+ {"version":3,"file":"action_rpc.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/actions/action_rpc.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAMH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAGtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAqB,KAAK,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAgB1E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAGtD;;;GAGG;AACH,eAAO,MAAM,qBAAqB,aAAa,CAAC;AAEhD,yCAAyC;AACzC,MAAM,WAAW,wBAAwB;IACxC,sDAAsD;IACtD,IAAI,EAAE,MAAM,CAAC;IACb,4BAA4B;IAC5B,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;IAC1B,2CAA2C;IAC3C,GAAG,EAAE,MAAM,CAAC;IACZ;;;;;;;;OAQG;IACH,sBAAsB,EAAE,WAAW,GAAG,IAAI,CAAC;IAC3C;;;;;;;OAOG;IACH,2BAA2B,EAAE,WAAW,GAAG,IAAI,CAAC;CAChD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,eAAO,MAAM,mBAAmB,GAAI,SAAS,wBAAwB,KAAG,KAAK,CAAC,SAAS,CAuNtF,CAAC"}
@@ -7,90 +7,35 @@
7
7
  * inside the dispatcher.
8
8
  *
9
9
  * Handler signature: `(input: TInput, ctx: ActionContext) => TOutput`
10
- * where `ActionContext` provides auth identity, DB, and framework context.
10
+ * where `ActionContext` (`actions/action_types.ts`) provides auth identity,
11
+ * DB, and framework context.
11
12
  *
12
13
  * @module
13
14
  */
14
15
  import { z } from 'zod';
15
16
  import { DEV } from 'esm-env';
17
+ import { UnreachableError } from '@fuzdev/fuz_util/error.ts';
16
18
  import {} from '../http/route_spec.js';
17
19
  import { get_client_ip } from '../http/client_ip.js';
18
20
  import { get_request_context } from '../auth/request_context.js';
19
- import { ACCOUNT_ID_KEY, CREDENTIAL_TYPE_KEY, TOKEN_SCOPE_KEY, TEST_CONTEXT_PRESET_KEY } from '../hono_context.js';
21
+ import { get_resolved_auth } from '../auth/resolved_auth.js';
22
+ import { TEST_CONTEXT_PRESET_KEY } from '../hono_context.js';
20
23
  import { compile_action_registry } from './compile_action_registry.js';
21
- import { JSONRPC_VERSION, JsonrpcRequest } from '../http/jsonrpc.js';
22
- import { jsonrpc_error_messages, jsonrpc_error_code_to_http_status, JSONRPC_ERROR_CODES, dev_only } from '../http/jsonrpc_errors.js';
23
- import { to_jsonrpc_envelope_id } from '../http/jsonrpc_helpers.js';
24
- import { perform_action, perform_action_result_to_envelope } from './perform_action.js';
24
+ import { jsonrpc_error_messages, jsonrpc_error_code_to_http_status, JSONRPC_ERROR_CODES } from '../http/jsonrpc_errors.js';
25
+ import { classify_jsonrpc_message, create_jsonrpc_error_response } from '../http/jsonrpc_helpers.js';
26
+ import { perform_action, serialize_action_result } from './perform_action.js';
25
27
  /**
26
- * Pair a spec with a handler while preserving per-method input/output types
27
- * and selecting the narrowest `ctx.auth` shape the spec literal admits.
28
- *
29
- * Constructing `{spec, handler}` literals widens `handler` to
30
- * `ActionHandler<any, any>`, so spec/handler drift (renamed Zod schema,
31
- * output field removal, input shape change) slips past the typechecker.
32
- * `rpc_action(spec, handler)` binds the handler signature to
33
- * `(input: z.infer<spec.input>, ctx) => z.infer<spec.output>` via the
34
- * generic spec parameter — drift surfaces at the call site.
35
- *
36
- * The `ctx.auth` narrowing follows the spec's `auth.account` /
37
- * `auth.actor` literals (see `HandlerForSpec`): an actor-implying spec
38
- * gets `ctx.auth: RequestActorContext`; an account-grain spec gets
39
- * `ctx.auth: RequestContext`; everything else stays `ctx.auth:
40
- * RequestContext | null`. Handlers can rely on the dispatcher's
41
- * runtime guarantee without a manual narrowing call.
42
- *
43
- * Fits fuz_app's factory-closure pattern (handlers close over
44
- * `grantable_roles`, `app_settings` ref, `notification_sender`, etc.).
45
- * zzz uses a different shape — a codegen-keyed `Record<Method, Handler>`
46
- * map typed via generated `ActionInputs`/`ActionOutputs` — which works when
47
- * handlers are pure (no closure state) and specs are codegen-enumerated.
48
- * fuz_app's admin + role-grant-offer actions have neither, so per-pair typing
49
- * at the registration site is the right fit.
50
- *
51
- * Spec-literal preservation is load-bearing: declare specs with
52
- * `satisfies RequestResponseActionSpec` (canonical) so `auth.actor`
53
- * keeps its `'required'` / `'none'` literal type. A spec typed
54
- * directly as `RequestResponseActionSpec` widens the axes to
55
- * `AuthAxisState` and the handler defaults to the loosest tier — sound,
56
- * but loses the ergonomic narrowing.
57
- *
58
- * @example
59
- * ```ts
60
- * // actor-implying spec → ctx.auth: RequestActorContext
61
- * rpc_action(role_grant_revoke_action_spec, async (input, ctx) => {
62
- * const revoker_id = ctx.auth.actor.id; // no narrowing needed
63
- * });
64
- *
65
- * // account-grain spec → ctx.auth: RequestContext (actor: null)
66
- * rpc_action(account_verify_action_spec, (_input, ctx) => {
67
- * return to_session_account(ctx.auth.account); // no narrowing needed
68
- * });
69
- * ```
70
- */
71
- export const rpc_action = (spec, handler) => ({
72
- spec,
73
- handler: handler
74
- });
75
- /**
76
- * Build a JSON-RPC error envelope for transport-shape errors (envelope
77
- * parse failures, method-not-found, GET-on-mutation rejections). The
78
- * dispatch core in `perform_action` returns a `PerformActionResult`
79
- * directly; this helper covers only the wire-shape errors the HTTP shim
80
- * emits before / after the core runs.
28
+ * The `Cache-Control` every response of the RPC endpoint's `GET` route carries
29
+ * — a read is per caller and per moment, so nothing may store it.
81
30
  */
82
- const jsonrpc_error_envelope = (id, error) => ({
83
- jsonrpc: JSONRPC_VERSION,
84
- id,
85
- error
86
- });
31
+ export const RPC_GET_CACHE_CONTROL = 'no-store';
87
32
  /**
88
33
  * Single JSON-RPC 2.0 endpoint — the canonical RPC transport binding.
89
34
  *
90
35
  * Returns two `RouteSpec` entries (GET + POST on the same path) for
91
36
  * `apply_route_specs`. The internal dispatcher handles:
92
37
  *
93
- * 1. **Parse envelope** — POST: JSON body as `JsonrpcRequest`. GET: `method`
38
+ * 1. **Parse envelope** — POST: JSON body through `classify_jsonrpc_message`. GET: `method`
94
39
  * and `params` from query string.
95
40
  * 2. **Lookup method** — find the `RpcAction` by method name.
96
41
  * 3. **Pre-authorization auth** — short-circuit `unauthenticated` when no
@@ -109,7 +54,9 @@ const jsonrpc_error_envelope = (id, error) => ({
109
54
  * 8. **Dispatch** — acquire DB handle (transaction for mutations, pool for reads),
110
55
  * construct `ActionContext`, call handler, return JSON-RPC response.
111
56
  *
112
- * GET is restricted to `side_effects: false` actions (cacheable reads).
57
+ * GET is restricted to `side_effects: false` actions, and every response the
58
+ * GET handler writes, its refusals included, carries `Cache-Control: no-store`
59
+ * (`RPC_GET_CACHE_CONTROL`) — a refusal by middleware ahead of it does not.
113
60
  * All errors use JSON-RPC format: `{jsonrpc, id, error: {code, message, data?}}`.
114
61
  *
115
62
  * The RouteSpecs use `auth: {type: 'none'}` because auth is checked per-action
@@ -136,22 +83,21 @@ export const create_rpc_endpoint = (options) => {
136
83
  * 1. Resolve the action by method name (HTTP-shape `method_not_found` envelope).
137
84
  * 2. Reject GET requests for `side_effects: true` actions (HTTP-only constraint).
138
85
  * 3. Hand off to `perform_action` for the post-parse pipeline.
139
- * 4. Bind the result to `c.json` — `'ok'` returns the result envelope,
140
- * `'error'` returns the error envelope at the `result.status` HTTP code.
141
- * A result that cannot be serialized answers `internal_error` rather
142
- * than throwing: `perform_action` has already committed, and a throw
143
- * here would have the route wrapper discard the post-commit effects
144
- * the handler queued — a revocation's connection closes among them.
86
+ * 4. Bind the result through `serialize_action_result` — `'ok'` returns the
87
+ * result envelope, `'error'` the error envelope at the `result.status`
88
+ * HTTP code, and a result that cannot be serialized `internal_error`
89
+ * rather than a throw that would discard the committed action's
90
+ * post-commit effects.
145
91
  *
146
92
  * @param restrict_to_reads - `true` for GET (rejects `side_effects: true` actions)
147
93
  */
148
94
  const dispatch = async (c, route, method_name, raw_params, id, restrict_to_reads) => {
149
95
  const action = action_map.get(method_name);
150
96
  if (!action) {
151
- return c.json(jsonrpc_error_envelope(id, jsonrpc_error_messages.method_not_found(method_name)), jsonrpc_error_code_to_http_status(JSONRPC_ERROR_CODES.method_not_found));
97
+ return c.json(create_jsonrpc_error_response(id, jsonrpc_error_messages.method_not_found(method_name)), jsonrpc_error_code_to_http_status(JSONRPC_ERROR_CODES.method_not_found));
152
98
  }
153
99
  if (restrict_to_reads && action.spec.side_effects) {
154
- return c.json(jsonrpc_error_envelope(id, jsonrpc_error_messages.invalid_request({
100
+ return c.json(create_jsonrpc_error_response(id, jsonrpc_error_messages.invalid_request({
155
101
  reason: `method '${method_name}' has side effects and must use POST`
156
102
  })), jsonrpc_error_code_to_http_status(JSONRPC_ERROR_CODES.invalid_request));
157
103
  }
@@ -172,9 +118,7 @@ export const create_rpc_endpoint = (options) => {
172
118
  action,
173
119
  raw_params,
174
120
  request_id: id,
175
- account_id: c.get(ACCOUNT_ID_KEY) ?? null,
176
- credential_type: c.get(CREDENTIAL_TYPE_KEY) ?? null,
177
- token_scope: c.get(TOKEN_SCOPE_KEY) ?? null,
121
+ auth: get_resolved_auth(c),
178
122
  client_ip: get_client_ip(c),
179
123
  signal: c.req.raw.signal,
180
124
  notify,
@@ -187,26 +131,14 @@ export const create_rpc_endpoint = (options) => {
187
131
  action_ip_rate_limiter,
188
132
  action_account_rate_limiter
189
133
  });
190
- const envelope = perform_action_result_to_envelope(id, result);
191
- if (result.kind === 'error') {
192
- // `result.status` is one of the JSON-RPC → HTTP status codes the
193
- // dispatcher emits; Hono types `c.json`'s second arg as
194
- // `ContentfulStatusCode`, which the cast bridges (the value space
195
- // is verified by `jsonrpc_error_code_to_http_status`).
196
- return c.json(envelope, result.status);
197
- }
198
- try {
199
- return c.json(envelope);
200
- }
201
- catch (err) {
202
- // The handler's output is not JSON (a `bigint`, a cycle). Its
203
- // transaction has committed, so this must not propagate: the route
204
- // wrapper reads a throw as a rollback and discards
205
- // `post_commit_effects`, which would drop the closes of a
206
- // revocation that did land.
207
- log.error(`action result is not serializable: ${method_name}`, err);
208
- return c.json(jsonrpc_error_envelope(id, jsonrpc_error_messages.internal_error(dev_only(err instanceof Error ? err.message : undefined))), jsonrpc_error_code_to_http_status(JSONRPC_ERROR_CODES.internal_error));
209
- }
134
+ const { body, status } = serialize_action_result(id, result, method_name, log);
135
+ // `status` is 200 or one of the JSON-RPC → HTTP status codes the
136
+ // dispatcher emits (the value space is verified by
137
+ // `jsonrpc_error_code_to_http_status`), which the cast to Hono's
138
+ // `ContentfulStatusCode` bridges. The content type is `c.json`'s.
139
+ return c.body(body, status, {
140
+ 'Content-Type': 'application/json'
141
+ });
210
142
  };
211
143
  // POST handler — parse JSON-RPC envelope from body
212
144
  const post_handler = async (c, route) => {
@@ -216,29 +148,42 @@ export const create_rpc_endpoint = (options) => {
216
148
  body = await c.req.json();
217
149
  }
218
150
  catch {
219
- const error = jsonrpc_error_envelope(null, jsonrpc_error_messages.parse_error());
151
+ const error = create_jsonrpc_error_response(null, jsonrpc_error_messages.parse_error());
220
152
  return c.json(error, 400);
221
153
  }
222
- const envelope = JsonrpcRequest.safeParse(body);
223
- if (!envelope.success) {
224
- // echo the id when the body is an object carrying one — the same
225
- // extraction the WS path runs; a scalar body answers `id: null`
226
- const error = jsonrpc_error_envelope(to_jsonrpc_envelope_id(body), jsonrpc_error_messages.invalid_request(dev_only({ issues: envelope.error.issues })));
227
- return c.json(error, 400);
154
+ // the classifier the WS path runs; HTTP issues no server-initiated
155
+ // requests and has no notification semantics, so a response or a
156
+ // notification answers `invalid_request` on `id: null`, as on the Rust spine
157
+ const classified = classify_jsonrpc_message(body);
158
+ switch (classified.kind) {
159
+ case 'request': {
160
+ const { method, params, id } = classified.request;
161
+ return dispatch(c, route, method, params, id, false);
162
+ }
163
+ case 'invalid':
164
+ return c.json(create_jsonrpc_error_response(classified.id, classified.error), 400);
165
+ case 'notification':
166
+ case 'response':
167
+ return c.json(create_jsonrpc_error_response(null, jsonrpc_error_messages.invalid_request()), 400);
168
+ default:
169
+ throw new UnreachableError(classified);
228
170
  }
229
- return dispatch(c, route, envelope.data.method, envelope.data.params, envelope.data.id, false);
230
171
  };
231
172
  // GET handler — extract method and params from query string
232
173
  const get_handler = async (c, route) => {
174
+ // A read answers for one caller at one moment: no cache — the browser's,
175
+ // a proxy's — may keep it and answer a later call, or another caller,
176
+ // with it. Every response of the route, errors included.
177
+ c.header('Cache-Control', RPC_GET_CACHE_CONTROL);
233
178
  // step 1: parse from query string
234
179
  const method_name = c.req.query('method');
235
180
  if (!method_name) {
236
- const error = jsonrpc_error_envelope(null, jsonrpc_error_messages.invalid_request({ reason: 'missing method query parameter' }));
181
+ const error = create_jsonrpc_error_response(null, jsonrpc_error_messages.invalid_request({ reason: 'missing method query parameter' }));
237
182
  return c.json(error, 400);
238
183
  }
239
184
  const id_raw = c.req.query('id');
240
185
  if (!id_raw) {
241
- const error = jsonrpc_error_envelope(null, jsonrpc_error_messages.invalid_request({ reason: 'missing id query parameter' }));
186
+ const error = create_jsonrpc_error_response(null, jsonrpc_error_messages.invalid_request({ reason: 'missing id query parameter' }));
242
187
  return c.json(error, 400);
243
188
  }
244
189
  // parse integer ids so GET ?id=42 matches POST {id: 42} behavior
@@ -253,7 +198,7 @@ export const create_rpc_endpoint = (options) => {
253
198
  params = JSON.parse(params_raw);
254
199
  }
255
200
  catch {
256
- const error = jsonrpc_error_envelope(id, jsonrpc_error_messages.invalid_params('params query parameter is not valid JSON'));
201
+ const error = create_jsonrpc_error_response(id, jsonrpc_error_messages.invalid_params('params query parameter is not valid JSON'));
257
202
  return c.json(error, 400);
258
203
  }
259
204
  }
@@ -279,7 +224,7 @@ export const create_rpc_endpoint = (options) => {
279
224
  auth: { account: 'none', actor: 'none' }, // per-action auth inside dispatcher
280
225
  reads_credential: true,
281
226
  handler: get_handler,
282
- description: `JSON-RPC 2.0 endpoint (cacheable reads) — ${actions.length} method${actions.length === 1 ? '' : 's'}`,
227
+ description: `JSON-RPC 2.0 endpoint (side-effect-free reads) — ${actions.length} method${actions.length === 1 ? '' : 's'}`,
283
228
  input: z.null(), // params from query string, validated by dispatcher
284
229
  output: z.any(), // varies by method
285
230
  transaction: false // per-action inside dispatcher
@@ -2,8 +2,8 @@
2
2
  * Action spec types — the canonical source of truth for action contracts.
3
3
  *
4
4
  * Extracted from zzz's action system. Action specs define method, kind,
5
- * auth, side effects, and input/output schemas. Bridge functions in
6
- * `actions/action_bridge.ts` derive `RouteSpec` and `EventSpec` from them.
5
+ * auth, side effects, and input/output schemas. `actions/action_bridge.ts`
6
+ * derives the SSE `EventSpec` of a notification from one.
7
7
  *
8
8
  * @see `actions/action_rpc.ts` for the JSON-RPC dispatcher
9
9
  * @see `actions/register_action_ws.ts` for the WebSocket dispatcher
@@ -2,8 +2,8 @@
2
2
  * Action spec types — the canonical source of truth for action contracts.
3
3
  *
4
4
  * Extracted from zzz's action system. Action specs define method, kind,
5
- * auth, side effects, and input/output schemas. Bridge functions in
6
- * `actions/action_bridge.ts` derive `RouteSpec` and `EventSpec` from them.
5
+ * auth, side effects, and input/output schemas. `actions/action_bridge.ts`
6
+ * derives the SSE `EventSpec` of a notification from one.
7
7
  *
8
8
  * @see `actions/action_rpc.ts` for the JSON-RPC dispatcher
9
9
  * @see `actions/register_action_ws.ts` for the WebSocket dispatcher