@stigmer/server 3.24.0 → 3.26.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 (341) hide show
  1. package/dist/authorization/authorizer.d.ts +10 -4
  2. package/dist/authorization/authorizer.d.ts.map +1 -1
  3. package/dist/authorization/authorizer.js +11 -4
  4. package/dist/authorization/authorizer.js.map +1 -1
  5. package/dist/authorization/model/index.d.ts +4 -4
  6. package/dist/authorization/model/index.d.ts.map +1 -1
  7. package/dist/authorization/model/index.js +2 -0
  8. package/dist/authorization/model/index.js.map +1 -1
  9. package/dist/authorization/model/oauth_app.d.ts.map +1 -1
  10. package/dist/authorization/model/oauth_app.js +3 -2
  11. package/dist/authorization/model/oauth_app.js.map +1 -1
  12. package/dist/authorization/model/platform_client.d.ts +2 -0
  13. package/dist/authorization/model/platform_client.d.ts.map +1 -0
  14. package/dist/authorization/model/platform_client.js +31 -0
  15. package/dist/authorization/model/platform_client.js.map +1 -0
  16. package/dist/boot/compose.d.ts.map +1 -1
  17. package/dist/boot/compose.js +99 -13
  18. package/dist/boot/compose.js.map +1 -1
  19. package/dist/boot/list-indexes.d.ts +3 -0
  20. package/dist/boot/list-indexes.d.ts.map +1 -0
  21. package/dist/boot/list-indexes.js +24 -0
  22. package/dist/boot/list-indexes.js.map +1 -0
  23. package/dist/boot/route-shadowing.d.ts +25 -0
  24. package/dist/boot/route-shadowing.d.ts.map +1 -0
  25. package/dist/boot/route-shadowing.js +17 -0
  26. package/dist/boot/route-shadowing.js.map +1 -0
  27. package/dist/domain/agentexecution/controller.d.ts.map +1 -1
  28. package/dist/domain/agentexecution/controller.js +6 -8
  29. package/dist/domain/agentexecution/controller.js.map +1 -1
  30. package/dist/domain/agentexecution/list-index.d.ts +2 -0
  31. package/dist/domain/agentexecution/list-index.d.ts.map +1 -0
  32. package/dist/domain/agentexecution/list-index.js +23 -0
  33. package/dist/domain/agentexecution/list-index.js.map +1 -0
  34. package/dist/domain/agentexecution/steps.d.ts +17 -33
  35. package/dist/domain/agentexecution/steps.d.ts.map +1 -1
  36. package/dist/domain/agentexecution/steps.js +94 -95
  37. package/dist/domain/agentexecution/steps.js.map +1 -1
  38. package/dist/domain/agentexecution/usage.d.ts.map +1 -1
  39. package/dist/domain/agentexecution/usage.js +37 -14
  40. package/dist/domain/agentexecution/usage.js.map +1 -1
  41. package/dist/domain/artifact/controller.d.ts.map +1 -1
  42. package/dist/domain/artifact/controller.js +27 -15
  43. package/dist/domain/artifact/controller.js.map +1 -1
  44. package/dist/domain/artifact/list-index.d.ts +2 -0
  45. package/dist/domain/artifact/list-index.d.ts.map +1 -0
  46. package/dist/domain/artifact/list-index.js +21 -0
  47. package/dist/domain/artifact/list-index.js.map +1 -0
  48. package/dist/domain/iampolicy/membership.d.ts +6 -1
  49. package/dist/domain/iampolicy/membership.d.ts.map +1 -1
  50. package/dist/domain/iampolicy/membership.js +8 -2
  51. package/dist/domain/iampolicy/membership.js.map +1 -1
  52. package/dist/domain/identityaccount/constants.d.ts +13 -0
  53. package/dist/domain/identityaccount/constants.d.ts.map +1 -1
  54. package/dist/domain/identityaccount/constants.js +17 -0
  55. package/dist/domain/identityaccount/constants.js.map +1 -1
  56. package/dist/domain/identityaccount/controller.d.ts +3 -1
  57. package/dist/domain/identityaccount/controller.d.ts.map +1 -1
  58. package/dist/domain/identityaccount/controller.js +15 -6
  59. package/dist/domain/identityaccount/controller.js.map +1 -1
  60. package/dist/domain/identityaccount/operator.d.ts.map +1 -1
  61. package/dist/domain/identityaccount/operator.js +1 -0
  62. package/dist/domain/identityaccount/operator.js.map +1 -1
  63. package/dist/domain/identityaccount/provisioning.d.ts +18 -0
  64. package/dist/domain/identityaccount/provisioning.d.ts.map +1 -1
  65. package/dist/domain/identityaccount/provisioning.js +1 -0
  66. package/dist/domain/identityaccount/provisioning.js.map +1 -1
  67. package/dist/domain/identityaccount/resource-store.js +9 -5
  68. package/dist/domain/identityaccount/resource-store.js.map +1 -1
  69. package/dist/domain/identityaccount/steps.d.ts +11 -2
  70. package/dist/domain/identityaccount/steps.d.ts.map +1 -1
  71. package/dist/domain/identityaccount/steps.js +42 -4
  72. package/dist/domain/identityaccount/steps.js.map +1 -1
  73. package/dist/domain/identityaccount/store-contract.d.ts.map +1 -1
  74. package/dist/domain/identityaccount/store-contract.js +33 -0
  75. package/dist/domain/identityaccount/store-contract.js.map +1 -1
  76. package/dist/domain/identityaccount/store.d.ts +7 -5
  77. package/dist/domain/identityaccount/store.d.ts.map +1 -1
  78. package/dist/domain/identityaccount/store.js.map +1 -1
  79. package/dist/domain/platform/controller.d.ts +10 -0
  80. package/dist/domain/platform/controller.d.ts.map +1 -1
  81. package/dist/domain/platform/controller.js +2 -1
  82. package/dist/domain/platform/controller.js.map +1 -1
  83. package/dist/domain/platformclient/constants.d.ts +60 -0
  84. package/dist/domain/platformclient/constants.d.ts.map +1 -0
  85. package/dist/domain/platformclient/constants.js +78 -0
  86. package/dist/domain/platformclient/constants.js.map +1 -0
  87. package/dist/domain/platformclient/controller.d.ts +59 -0
  88. package/dist/domain/platformclient/controller.d.ts.map +1 -0
  89. package/dist/domain/platformclient/controller.js +191 -0
  90. package/dist/domain/platformclient/controller.js.map +1 -0
  91. package/dist/domain/platformclient/credentials.d.ts +13 -0
  92. package/dist/domain/platformclient/credentials.d.ts.map +1 -0
  93. package/dist/domain/platformclient/credentials.js +56 -0
  94. package/dist/domain/platformclient/credentials.js.map +1 -0
  95. package/dist/domain/platformclient/mint.d.ts +23 -0
  96. package/dist/domain/platformclient/mint.d.ts.map +1 -0
  97. package/dist/domain/platformclient/mint.js +254 -0
  98. package/dist/domain/platformclient/mint.js.map +1 -0
  99. package/dist/domain/platformclient/origin-guard.d.ts +9 -0
  100. package/dist/domain/platformclient/origin-guard.d.ts.map +1 -0
  101. package/dist/domain/platformclient/origin-guard.js +81 -0
  102. package/dist/domain/platformclient/origin-guard.js.map +1 -0
  103. package/dist/domain/platformclient/resource-store.d.ts +4 -0
  104. package/dist/domain/platformclient/resource-store.d.ts.map +1 -0
  105. package/dist/domain/platformclient/resource-store.js +117 -0
  106. package/dist/domain/platformclient/resource-store.js.map +1 -0
  107. package/dist/domain/platformclient/steps.d.ts +51 -0
  108. package/dist/domain/platformclient/steps.d.ts.map +1 -0
  109. package/dist/domain/platformclient/steps.js +339 -0
  110. package/dist/domain/platformclient/steps.js.map +1 -0
  111. package/dist/domain/platformclient/store-contract.d.ts +8 -0
  112. package/dist/domain/platformclient/store-contract.d.ts.map +1 -0
  113. package/dist/domain/platformclient/store-contract.js +208 -0
  114. package/dist/domain/platformclient/store-contract.js.map +1 -0
  115. package/dist/domain/platformclient/store.d.ts +58 -0
  116. package/dist/domain/platformclient/store.d.ts.map +1 -0
  117. package/dist/domain/platformclient/store.js +13 -0
  118. package/dist/domain/platformclient/store.js.map +1 -0
  119. package/dist/domain/platformclient/system-managed.d.ts +18 -0
  120. package/dist/domain/platformclient/system-managed.d.ts.map +1 -0
  121. package/dist/domain/platformclient/system-managed.js +80 -0
  122. package/dist/domain/platformclient/system-managed.js.map +1 -0
  123. package/dist/domain/platformclient/token-controller.d.ts +11 -0
  124. package/dist/domain/platformclient/token-controller.d.ts.map +1 -0
  125. package/dist/domain/platformclient/token-controller.js +32 -0
  126. package/dist/domain/platformclient/token-controller.js.map +1 -0
  127. package/dist/domain/platformclient/verifier.d.ts +10 -0
  128. package/dist/domain/platformclient/verifier.d.ts.map +1 -0
  129. package/dist/domain/platformclient/verifier.js +76 -0
  130. package/dist/domain/platformclient/verifier.js.map +1 -0
  131. package/dist/domain/session/list-index.d.ts +4 -0
  132. package/dist/domain/session/list-index.d.ts.map +1 -0
  133. package/dist/domain/session/list-index.js +26 -0
  134. package/dist/domain/session/list-index.js.map +1 -0
  135. package/dist/domain/session/steps.d.ts +7 -8
  136. package/dist/domain/session/steps.d.ts.map +1 -1
  137. package/dist/domain/session/steps.js +76 -78
  138. package/dist/domain/session/steps.js.map +1 -1
  139. package/dist/domain/workflowexecution/controller.d.ts.map +1 -1
  140. package/dist/domain/workflowexecution/controller.js +53 -55
  141. package/dist/domain/workflowexecution/controller.js.map +1 -1
  142. package/dist/domain/workflowexecution/execution-filter.d.ts +4 -0
  143. package/dist/domain/workflowexecution/execution-filter.d.ts.map +1 -1
  144. package/dist/domain/workflowexecution/execution-filter.js +11 -5
  145. package/dist/domain/workflowexecution/execution-filter.js.map +1 -1
  146. package/dist/domain/workflowexecution/get-execution-summary.d.ts.map +1 -1
  147. package/dist/domain/workflowexecution/get-execution-summary.js +23 -17
  148. package/dist/domain/workflowexecution/get-execution-summary.js.map +1 -1
  149. package/dist/domain/workflowexecution/list-index.d.ts +2 -0
  150. package/dist/domain/workflowexecution/list-index.d.ts.map +1 -0
  151. package/dist/domain/workflowexecution/list-index.js +21 -0
  152. package/dist/domain/workflowexecution/list-index.js.map +1 -0
  153. package/dist/domain/workflowexecution/list-pending-approvals.d.ts.map +1 -1
  154. package/dist/domain/workflowexecution/list-pending-approvals.js +69 -32
  155. package/dist/domain/workflowexecution/list-pending-approvals.js.map +1 -1
  156. package/dist/domain/workflowexecution/queries.d.ts +30 -4
  157. package/dist/domain/workflowexecution/queries.d.ts.map +1 -1
  158. package/dist/domain/workflowexecution/queries.js +76 -22
  159. package/dist/domain/workflowexecution/queries.js.map +1 -1
  160. package/dist/encryption/key-manager.d.ts +20 -3
  161. package/dist/encryption/key-manager.d.ts.map +1 -1
  162. package/dist/encryption/key-manager.js +64 -42
  163. package/dist/encryption/key-manager.js.map +1 -1
  164. package/dist/extensions/caller-guards.d.ts +8 -3
  165. package/dist/extensions/caller-guards.d.ts.map +1 -1
  166. package/dist/extensions/drivers.d.ts +37 -0
  167. package/dist/extensions/drivers.d.ts.map +1 -1
  168. package/dist/extensions/guest-token-minting.d.ts +26 -0
  169. package/dist/extensions/guest-token-minting.d.ts.map +1 -0
  170. package/dist/extensions/guest-token-minting.js +2 -0
  171. package/dist/extensions/guest-token-minting.js.map +1 -0
  172. package/dist/extensions/identity.d.ts +6 -4
  173. package/dist/extensions/identity.d.ts.map +1 -1
  174. package/dist/extensions/identity.js.map +1 -1
  175. package/dist/extensions/list-read-scope.d.ts +9 -12
  176. package/dist/extensions/list-read-scope.d.ts.map +1 -1
  177. package/dist/extensions/list-read-scope.js.map +1 -1
  178. package/dist/extensions/registry.d.ts +30 -1
  179. package/dist/extensions/registry.d.ts.map +1 -1
  180. package/dist/extensions/registry.js +34 -1
  181. package/dist/extensions/registry.js.map +1 -1
  182. package/dist/index.d.ts +15 -2
  183. package/dist/index.d.ts.map +1 -1
  184. package/dist/index.js +6 -0
  185. package/dist/index.js.map +1 -1
  186. package/dist/pipeline/interceptors/auth.d.ts +14 -0
  187. package/dist/pipeline/interceptors/auth.d.ts.map +1 -1
  188. package/dist/pipeline/interceptors/auth.js +24 -0
  189. package/dist/pipeline/interceptors/auth.js.map +1 -1
  190. package/dist/pipeline/steps/build-update-state.d.ts +11 -1
  191. package/dist/pipeline/steps/build-update-state.d.ts.map +1 -1
  192. package/dist/pipeline/steps/build-update-state.js +5 -2
  193. package/dist/pipeline/steps/build-update-state.js.map +1 -1
  194. package/dist/pipeline/steps/list-page.d.ts +63 -0
  195. package/dist/pipeline/steps/list-page.d.ts.map +1 -0
  196. package/dist/pipeline/steps/list-page.js +187 -0
  197. package/dist/pipeline/steps/list-page.js.map +1 -0
  198. package/dist/platformtoken/envelope.d.ts +100 -0
  199. package/dist/platformtoken/envelope.d.ts.map +1 -0
  200. package/dist/platformtoken/envelope.js +184 -0
  201. package/dist/platformtoken/envelope.js.map +1 -0
  202. package/dist/platformtoken/key-ring.d.ts +85 -0
  203. package/dist/platformtoken/key-ring.d.ts.map +1 -0
  204. package/dist/platformtoken/key-ring.js +164 -0
  205. package/dist/platformtoken/key-ring.js.map +1 -0
  206. package/dist/query/activity/handler.d.ts +6 -7
  207. package/dist/query/activity/handler.d.ts.map +1 -1
  208. package/dist/query/activity/handler.js +42 -59
  209. package/dist/query/activity/handler.js.map +1 -1
  210. package/dist/store/interface.d.ts +29 -0
  211. package/dist/store/interface.d.ts.map +1 -1
  212. package/dist/store/interface.js.map +1 -1
  213. package/dist/store/list-index.d.ts +123 -0
  214. package/dist/store/list-index.d.ts.map +1 -0
  215. package/dist/store/list-index.js +277 -0
  216. package/dist/store/list-index.js.map +1 -0
  217. package/dist/store/logger.d.ts +3 -0
  218. package/dist/store/logger.d.ts.map +1 -1
  219. package/dist/store/logger.js +5 -1
  220. package/dist/store/logger.js.map +1 -1
  221. package/dist/store/postgres/migrations.d.ts +10 -6
  222. package/dist/store/postgres/migrations.d.ts.map +1 -1
  223. package/dist/store/postgres/migrations.js +64 -6
  224. package/dist/store/postgres/migrations.js.map +1 -1
  225. package/dist/store/postgres/store.d.ts +26 -5
  226. package/dist/store/postgres/store.d.ts.map +1 -1
  227. package/dist/store/postgres/store.js +377 -22
  228. package/dist/store/postgres/store.js.map +1 -1
  229. package/dist/store/sqlite/migrations.d.ts +11 -5
  230. package/dist/store/sqlite/migrations.d.ts.map +1 -1
  231. package/dist/store/sqlite/migrations.js +50 -4
  232. package/dist/store/sqlite/migrations.js.map +1 -1
  233. package/dist/store/sqlite/store.d.ts +18 -3
  234. package/dist/store/sqlite/store.d.ts.map +1 -1
  235. package/dist/store/sqlite/store.js +321 -15
  236. package/dist/store/sqlite/store.js.map +1 -1
  237. package/package.json +6 -6
  238. package/src/authorization/README.md +1 -1
  239. package/src/authorization/__tests__/authorizer.test.ts +6 -2
  240. package/src/authorization/__tests__/drivers.ts +6 -1
  241. package/src/authorization/__tests__/wire-permissions.test.ts +1 -0
  242. package/src/authorization/authorizer.ts +11 -4
  243. package/src/authorization/model/__tests__/registry.test.ts +8 -1
  244. package/src/authorization/model/index.ts +6 -4
  245. package/src/authorization/model/oauth_app.ts +3 -2
  246. package/src/authorization/model/platform_client.ts +43 -0
  247. package/src/boot/__tests__/auth-enabled-composition.test.ts +2 -1
  248. package/src/boot/__tests__/list-indexes.test.ts +65 -0
  249. package/src/boot/__tests__/route-shadowing.test.ts +67 -0
  250. package/src/boot/compose.ts +113 -18
  251. package/src/boot/list-indexes.ts +25 -0
  252. package/src/boot/route-shadowing.ts +47 -0
  253. package/src/domain/agentexecution/__tests__/agentexecution.test.ts +85 -3
  254. package/src/domain/agentexecution/controller.ts +8 -10
  255. package/src/domain/agentexecution/list-index.ts +24 -0
  256. package/src/domain/agentexecution/steps.ts +118 -115
  257. package/src/domain/agentexecution/usage.ts +38 -17
  258. package/src/domain/artifact/controller.ts +28 -18
  259. package/src/domain/artifact/list-index.ts +22 -0
  260. package/src/domain/iampolicy/__tests__/membership.test.ts +7 -0
  261. package/src/domain/iampolicy/membership.ts +8 -2
  262. package/src/domain/identityaccount/__tests__/platform-client-accounts.test.ts +124 -0
  263. package/src/domain/identityaccount/__tests__/resource-store.test.ts +1 -0
  264. package/src/domain/identityaccount/constants.ts +20 -0
  265. package/src/domain/identityaccount/controller.ts +16 -4
  266. package/src/domain/identityaccount/operator.ts +1 -0
  267. package/src/domain/identityaccount/provisioning.ts +17 -0
  268. package/src/domain/identityaccount/resource-store.ts +9 -5
  269. package/src/domain/identityaccount/steps.ts +58 -3
  270. package/src/domain/identityaccount/store-contract.ts +51 -0
  271. package/src/domain/identityaccount/store.ts +7 -5
  272. package/src/domain/platform/__tests__/platform.test.ts +7 -1
  273. package/src/domain/platform/controller.ts +12 -1
  274. package/src/domain/platformclient/__tests__/controller.test.ts +397 -0
  275. package/src/domain/platformclient/__tests__/credentials.test.ts +46 -0
  276. package/src/domain/platformclient/__tests__/mint.test.ts +415 -0
  277. package/src/domain/platformclient/__tests__/resource-store.test.ts +140 -0
  278. package/src/domain/platformclient/__tests__/system-managed.test.ts +101 -0
  279. package/src/domain/platformclient/__tests__/verifier-and-guard.test.ts +207 -0
  280. package/src/domain/platformclient/constants.ts +120 -0
  281. package/src/domain/platformclient/controller.ts +449 -0
  282. package/src/domain/platformclient/credentials.ts +68 -0
  283. package/src/domain/platformclient/mint.ts +412 -0
  284. package/src/domain/platformclient/origin-guard.ts +117 -0
  285. package/src/domain/platformclient/resource-store.ts +150 -0
  286. package/src/domain/platformclient/steps.ts +472 -0
  287. package/src/domain/platformclient/store-contract.ts +318 -0
  288. package/src/domain/platformclient/store.ts +63 -0
  289. package/src/domain/platformclient/system-managed.ts +115 -0
  290. package/src/domain/platformclient/token-controller.ts +49 -0
  291. package/src/domain/platformclient/verifier.ts +106 -0
  292. package/src/domain/session/list-index.ts +28 -0
  293. package/src/domain/session/steps.ts +108 -123
  294. package/src/domain/workflowexecution/__tests__/list-read-scope-summaries.test.ts +155 -99
  295. package/src/domain/workflowexecution/__tests__/workflowexecution.test.ts +193 -31
  296. package/src/domain/workflowexecution/controller.ts +54 -82
  297. package/src/domain/workflowexecution/execution-filter.ts +20 -7
  298. package/src/domain/workflowexecution/get-execution-summary.ts +31 -24
  299. package/src/domain/workflowexecution/list-index.ts +22 -0
  300. package/src/domain/workflowexecution/list-pending-approvals.ts +82 -25
  301. package/src/domain/workflowexecution/queries.ts +134 -23
  302. package/src/encryption/key-manager.ts +87 -44
  303. package/src/extensions/__tests__/extension-composition.test.ts +3 -2
  304. package/src/extensions/__tests__/platform-client-composed.test.ts +288 -0
  305. package/src/extensions/__tests__/registry.test.ts +4 -1
  306. package/src/extensions/__tests__/tier-truthfulness.test.ts +8 -0
  307. package/src/extensions/caller-guards.ts +8 -3
  308. package/src/extensions/drivers.ts +37 -0
  309. package/src/extensions/guest-token-minting.ts +32 -0
  310. package/src/extensions/identity.ts +6 -4
  311. package/src/extensions/list-read-scope.ts +9 -12
  312. package/src/extensions/registry.ts +77 -3
  313. package/src/index.ts +65 -1
  314. package/src/pipeline/interceptors/auth.ts +27 -0
  315. package/src/pipeline/steps/__tests__/list-page.test.ts +186 -0
  316. package/src/pipeline/steps/__tests__/references.test.ts +2 -0
  317. package/src/pipeline/steps/build-update-state.ts +5 -2
  318. package/src/pipeline/steps/list-page.ts +284 -0
  319. package/src/platformtoken/__tests__/envelope.test.ts +277 -0
  320. package/src/platformtoken/__tests__/key-ring.test.ts +205 -0
  321. package/src/platformtoken/envelope.ts +276 -0
  322. package/src/platformtoken/key-ring.ts +266 -0
  323. package/src/query/activity/handler.ts +57 -78
  324. package/src/runnerauth/__tests__/runner-subject-composed.test.ts +9 -3
  325. package/src/store/README.md +51 -32
  326. package/src/store/__tests__/list-index.measure.test.ts +293 -0
  327. package/src/store/__tests__/list-index.test.ts +328 -0
  328. package/src/store/__tests__/store-contract.ts +346 -3
  329. package/src/store/interface.ts +39 -0
  330. package/src/store/list-index.ts +465 -0
  331. package/src/store/logger.ts +8 -1
  332. package/src/store/postgres/__tests__/list-index-repair.test.ts +133 -0
  333. package/src/store/postgres/__tests__/migrations.test.ts +27 -19
  334. package/src/store/postgres/__tests__/store-contract.test.ts +50 -3
  335. package/src/store/postgres/migrations.ts +69 -7
  336. package/src/store/postgres/store.ts +485 -29
  337. package/src/store/sqlite/__tests__/migrations.test.ts +51 -7
  338. package/src/store/sqlite/__tests__/store-contract.test.ts +70 -16
  339. package/src/store/sqlite/__tests__/support.ts +12 -3
  340. package/src/store/sqlite/migrations.ts +57 -6
  341. package/src/store/sqlite/store.ts +462 -21
@@ -29,6 +29,7 @@ import {
29
29
  Harness,
30
30
  } from "@stigmer/protos/ai/stigmer/agentic/session/v1/enum_pb";
31
31
  import { SessionListSchema } from "@stigmer/protos/ai/stigmer/agentic/session/v1/io_pb";
32
+ import type { SessionList } from "@stigmer/protos/ai/stigmer/agentic/session/v1/io_pb";
32
33
  import { SessionQueryController } from "@stigmer/protos/ai/stigmer/agentic/session/v1/query_pb";
33
34
  import { ApiResourceKind } from "@stigmer/protos/ai/stigmer/commons/apiresource/apiresourcekind/api_resource_kind_pb";
34
35
  import { IamPermission } from "@stigmer/protos/ai/stigmer/iam/v1/enum_pb";
@@ -42,27 +43,28 @@ import {
42
43
  } from "../../pipeline/errors.js";
43
44
  import type { PipelineStep } from "../../pipeline/pipeline.js";
44
45
  import type { Authorizer } from "../../extensions/authorizer.js";
46
+ import type { CallerIdentity } from "../../extensions/identity.js";
45
47
  import type { ListReadScope } from "../../extensions/list-read-scope.js";
46
48
  import { restrictListByReadScope } from "../../extensions/list-read-scope.js";
47
49
  import { newAuthorizeResolvedTargetStep } from "../../pipeline/steps/authorize-resolved-target.js";
48
50
  import type { RequestContext } from "../../pipeline/request-context.js";
49
51
  import { RESOURCE_ID_KEY } from "../../pipeline/steps/delete.js";
50
- import { compareCreatedAtDesc } from "../../pipeline/steps/helpers.js";
52
+ import {
53
+ listPageFingerprint,
54
+ readListPage,
55
+ } from "../../pipeline/steps/list-page.js";
56
+ import type { ListPageRequest } from "../../pipeline/steps/list-page.js";
51
57
  import { EXISTING_RESOURCE_KEY } from "../../pipeline/steps/load-existing.js";
52
58
  import type { Store } from "../../store/interface.js";
59
+ import type { ListIndexQuery, ListIndexRow } from "../../store/list-index.js";
60
+ import { agentExecutionListIndex } from "../agentexecution/list-index.js";
61
+ import { sessionListIndex } from "./list-index.js";
53
62
 
54
63
  type SessionDesc = typeof SessionSchema;
55
64
 
56
65
  /** Context key for the list result (Go listResultKey). */
57
66
  export const LIST_RESULT_KEY = "listResult";
58
67
 
59
- /**
60
- * The session label the channel runtime stamps at create time to record
61
- * which agent channel originated the conversation. Mirrors
62
- * ChannelRuntimeConstants.CHANNEL_ID_METADATA_KEY in Stigmer Cloud.
63
- */
64
- const CHANNEL_ID_LABEL_KEY = "stigmer.ai/channel-id";
65
-
66
68
  // ---------------------------------------------------------------------------
67
69
  // ValidateHarnessImmutability — validate_harness_immutability.go: rejects
68
70
  // session updates that attempt to change the harness after the session has
@@ -273,35 +275,33 @@ function isActiveExecutionPhase(phase: ExecutionPhase): boolean {
273
275
  }
274
276
 
275
277
  /**
276
- * Loads every agent execution whose spec.session_id matches the given
277
- * session; malformed rows warn and are skipped. Shared by the guard and
278
- * cascade steps (Go listExecutionsBySession).
278
+ * Every agent execution of the given session, through the list index's
279
+ * session key (exact whoever wrote the rows, store/interface.ts); malformed
280
+ * rows warn and are skipped. Shared by the guard and cascade steps (Go
281
+ * listExecutionsBySession).
279
282
  */
280
283
  async function listExecutionsBySession(
281
284
  store: Store,
282
285
  logger: Logger,
283
286
  sessionId: string,
284
287
  ): Promise<AgentExecution[]> {
285
- let rows: Uint8Array[];
288
+ let rows: ListIndexRow[];
286
289
  try {
287
- rows = await store.listResources(ApiResourceKind.agent_execution);
290
+ rows = await store.queryResources(agentExecutionListIndex, {
291
+ anyKey: [{ name: "session", value: sessionId }],
292
+ });
288
293
  } catch (error) {
289
294
  throw internalError(error, "failed to list agent executions");
290
295
  }
291
296
 
292
297
  const executions: AgentExecution[] = [];
293
- for (const data of rows) {
294
- let execution: AgentExecution;
298
+ for (const row of rows) {
295
299
  try {
296
- execution = fromBinary(AgentExecutionSchema, data);
300
+ executions.push(fromBinary(AgentExecutionSchema, row.data));
297
301
  } catch (error) {
298
302
  logger.warn("Failed to unmarshal execution, skipping", {
299
303
  error: error instanceof Error ? error.message : String(error),
300
304
  });
301
- continue;
302
- }
303
- if ((execution.spec?.sessionId ?? "") === sessionId) {
304
- executions.push(execution);
305
305
  }
306
306
  }
307
307
  return executions;
@@ -427,19 +427,19 @@ function requireSessionId<Desc extends DescMessage>(
427
427
  }
428
428
 
429
429
  // ---------------------------------------------------------------------------
430
- // List steps — list.go and the steps/ package. Full scans with client-side
431
- // filtering, exactly Go (no pagination; no scope composed = no authorization
432
- // filtering, the OSS single-user posture). With a composed ListReadScope
433
- // (20260830.01) each lane narrows to the caller's authorized sessions —
430
+ // List steps — list.go and the steps/ package. Each lane reads its page
431
+ // through the list index (pipeline/steps/list-page.ts): the store narrows
432
+ // by the request's organization or parent key and orders newest first
433
+ // (spec-audit created_at, unstamped last, ties by id); the read scope, when
434
+ // composed, narrows each batch to the caller's authorized sessions last —
434
435
  // the Java list handlers' FGA-ids pattern, guest cookie rule included
435
- // driver-side; the request org is deliberately NOT intersected (the Java
436
- // session lanes never consult it — census lanes 1–3).
436
+ // driver-side. No scope composed = the OSS single-user posture, every
437
+ // matching session.
437
438
  // ---------------------------------------------------------------------------
438
439
 
439
440
  /**
440
- * ListAllSessions — all sessions, newest first by spec-audit created_at
441
- * (seconds then nanos; timestamped entries before untimestamped ones).
442
- * Malformed rows warn and are skipped.
441
+ * ListAllSessions — one page of sessions, the request's organization when
442
+ * it names one, newest first. Malformed rows warn and are skipped.
443
443
  */
444
444
  export function newListAllSessionsStep(
445
445
  store: Store,
@@ -451,34 +451,30 @@ export function newListAllSessionsStep(
451
451
  async execute(
452
452
  ctx: RequestContext<typeof SessionQueryController.method.list.input>,
453
453
  ): Promise<void> {
454
- const sessions = await restrictListByReadScope(
454
+ const input = ctx.input;
455
+ const page = await readSessionPage(
456
+ store,
457
+ logger,
455
458
  listReadScope,
456
459
  ctx.callerIdentity,
457
- ApiResourceKind.session,
458
- await loadAllSessions(store, logger, ctx.apiResourceKind),
459
- "",
460
- );
461
-
462
- sessions.sort((a, b) =>
463
- compareCreatedAtDesc(
464
- a.status?.audit?.specAudit?.createdAt,
465
- b.status?.audit?.specAudit?.createdAt,
466
- ),
467
- );
468
-
469
- logger.info("Loaded sessions from database", { count: sessions.length });
470
-
471
- ctx.set(
472
- LIST_RESULT_KEY,
473
- create(SessionListSchema, { entries: sessions }),
460
+ ctx.input,
461
+ {
462
+ query: { org: input.org },
463
+ fingerprint: {
464
+ lane: "session.list",
465
+ org: input.org,
466
+ tags: input.tags,
467
+ },
468
+ },
474
469
  );
470
+ ctx.set(LIST_RESULT_KEY, page);
475
471
  },
476
472
  };
477
473
  }
478
474
 
479
475
  /**
480
- * FilterByAgentInstance — steps/filter_by_agent_instance.go: sessions
481
- * whose spec.agent_instance_id matches. No sorting (Go doesn't sort here).
476
+ * FilterByAgentInstance — steps/filter_by_agent_instance.go: one page of
477
+ * the sessions whose spec.agent_instance_id matches, newest first.
482
478
  */
483
479
  export function newFilterByAgentInstanceStep(
484
480
  store: Store,
@@ -499,34 +495,22 @@ export function newFilterByAgentInstanceStep(
499
495
  throw invalidArgumentError("agent_instance_id is required");
500
496
  }
501
497
 
502
- // The instance's sessions first, the scope last (census lane 2): a
503
- // composed driver is asked about one instance's rows, not the kind.
504
- const sessions = await loadAllSessions(
498
+ // The instance's sessions through its key, the scope last (census
499
+ // lane 2): a composed driver is asked about one instance's rows.
500
+ const page = await readSessionPage(
505
501
  store,
506
502
  logger,
507
- ctx.apiResourceKind,
508
- );
509
- const filtered = await restrictListByReadScope(
510
503
  listReadScope,
511
504
  ctx.callerIdentity,
512
- ApiResourceKind.session,
513
- sessions.filter(
514
- (session) =>
515
- (session.spec?.agentInstanceId ?? "") === agentInstanceId,
516
- ),
517
- "",
518
- );
519
-
520
- logger.info("Filtered sessions by agent instance", {
521
- agentInstanceId,
522
- totalSessions: sessions.length,
523
- filteredSessions: filtered.length,
524
- });
525
-
526
- ctx.set(
527
- LIST_RESULT_KEY,
528
- create(SessionListSchema, { entries: filtered }),
505
+ ctx.input,
506
+ {
507
+ query: {
508
+ anyKey: [{ name: "agent_instance", value: agentInstanceId }],
509
+ },
510
+ fingerprint: { lane: "session.listByAgentInstance", agentInstanceId },
511
+ },
529
512
  );
513
+ ctx.set(LIST_RESULT_KEY, page);
530
514
  },
531
515
  };
532
516
  }
@@ -563,9 +547,9 @@ export function newAuthorizeChannelAccessStep(
563
547
  }
564
548
 
565
549
  /**
566
- * FilterByChannel — steps/filter_by_channel.go: sessions whose
567
- * metadata.labels carry the channel's stigmer.ai/channel-id stamp. No
568
- * sorting. Channel sessions are created by the cloud channel runtime
550
+ * FilterByChannel — steps/filter_by_channel.go: one page of the sessions
551
+ * whose metadata.labels carry the channel's stigmer.ai/channel-id stamp,
552
+ * newest first. Channel sessions are created by the cloud channel runtime
569
553
  * (Slack/WhatsApp inbound turns), which stamps the label at create time;
570
554
  * the OSS runtime has no channel broker, so this filter typically matches
571
555
  * nothing — the RPC exists for contract parity with Stigmer Cloud (which
@@ -589,63 +573,64 @@ export function newFilterByChannelStep(
589
573
  throw invalidArgumentError("channel_id is required");
590
574
  }
591
575
 
592
- // The channel's sessions first, the scope last (census lane 3).
593
- const sessions = await loadAllSessions(
576
+ // The channel's sessions through its key, the scope last (census lane 3).
577
+ const page = await readSessionPage(
594
578
  store,
595
579
  logger,
596
- ctx.apiResourceKind,
597
- );
598
- const filtered = await restrictListByReadScope(
599
580
  listReadScope,
600
581
  ctx.callerIdentity,
601
- ApiResourceKind.session,
602
- sessions.filter(
603
- (session) =>
604
- (session.metadata?.labels ?? {})[CHANNEL_ID_LABEL_KEY] ===
605
- channelId,
606
- ),
607
- "",
608
- );
609
-
610
- logger.info("Filtered sessions by channel", {
611
- channelId,
612
- totalSessions: sessions.length,
613
- filteredSessions: filtered.length,
614
- });
615
-
616
- ctx.set(
617
- LIST_RESULT_KEY,
618
- create(SessionListSchema, { entries: filtered }),
582
+ ctx.input,
583
+ {
584
+ query: { anyKey: [{ name: "channel", value: channelId }] },
585
+ fingerprint: { lane: "session.listByChannel", channelId },
586
+ },
619
587
  );
588
+ ctx.set(LIST_RESULT_KEY, page);
620
589
  },
621
590
  };
622
591
  }
623
592
 
624
- /** Full-scan session load shared by the list steps; malformed rows warn + skip. */
625
- async function loadAllSessions(
593
+ /** The three session lanes' shared read: one page, the scope last, as a SessionList. */
594
+ async function readSessionPage(
626
595
  store: Store,
627
596
  logger: Logger,
628
- kind: ApiResourceKind,
629
- ): Promise<Session[]> {
630
- let rows: Uint8Array[];
631
- try {
632
- rows = await store.listResources(kind);
633
- } catch (error) {
634
- throw internalError(error, "failed to list sessions");
635
- }
636
-
637
- const sessions: Session[] = [];
638
- for (const data of rows) {
639
- let session: Session;
640
- try {
641
- session = fromBinary(SessionSchema, data);
642
- } catch (error) {
643
- logger.warn("Failed to unmarshal session, skipping", {
644
- error: error instanceof Error ? error.message : String(error),
645
- });
646
- continue;
647
- }
648
- sessions.push(session);
649
- }
650
- return sessions;
597
+ listReadScope: ListReadScope | undefined,
598
+ caller: CallerIdentity,
599
+ request: ListPageRequest,
600
+ lane: {
601
+ readonly query: ListIndexQuery<"agent_instance" | "channel">;
602
+ readonly fingerprint: Readonly<Record<string, unknown>>;
603
+ },
604
+ ): Promise<SessionList> {
605
+ const page = await readListPage({
606
+ store,
607
+ declaration: sessionListIndex,
608
+ query: lane.query,
609
+ request,
610
+ fingerprint: listPageFingerprint(lane.fingerprint),
611
+ decode: (data) => {
612
+ try {
613
+ return fromBinary(SessionSchema, data);
614
+ } catch (error) {
615
+ logger.warn("Failed to unmarshal session, skipping", {
616
+ error: error instanceof Error ? error.message : String(error),
617
+ });
618
+ return undefined;
619
+ }
620
+ },
621
+ scope: (sessions) =>
622
+ restrictListByReadScope(
623
+ listReadScope,
624
+ caller,
625
+ ApiResourceKind.session,
626
+ sessions,
627
+ "",
628
+ ),
629
+ failure: "failed to list sessions",
630
+ });
631
+ return create(SessionListSchema, {
632
+ entries: page.entries,
633
+ nextPageToken: page.nextPageToken,
634
+ totalPages: page.nextPageToken === "" ? 1 : 0,
635
+ });
651
636
  }