@laserdata/laser-sdk 0.0.1-rc.2 → 0.0.1-rc.22

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 (434) hide show
  1. package/README.md +5 -5
  2. package/dist/agent/agdx.d.ts +55 -0
  3. package/dist/agent/agdx.d.ts.map +1 -0
  4. package/dist/agent/agdx.js +447 -0
  5. package/dist/agent/agdx.js.map +1 -0
  6. package/dist/agent/assembler.d.ts +29 -0
  7. package/dist/agent/assembler.d.ts.map +1 -0
  8. package/dist/agent/assembler.js +69 -0
  9. package/dist/agent/assembler.js.map +1 -0
  10. package/dist/agent/builder.d.ts +114 -0
  11. package/dist/agent/builder.d.ts.map +1 -0
  12. package/dist/agent/builder.js +334 -0
  13. package/dist/agent/builder.js.map +1 -0
  14. package/dist/agent/context.d.ts +68 -0
  15. package/dist/agent/context.d.ts.map +1 -0
  16. package/dist/agent/context.js +212 -0
  17. package/dist/agent/context.js.map +1 -0
  18. package/dist/agent/contract.d.ts +70 -0
  19. package/dist/agent/contract.d.ts.map +1 -0
  20. package/dist/agent/contract.js +275 -0
  21. package/dist/agent/contract.js.map +1 -0
  22. package/dist/agent/registry.d.ts +76 -0
  23. package/dist/agent/registry.d.ts.map +1 -0
  24. package/dist/agent/registry.js +286 -0
  25. package/dist/agent/registry.js.map +1 -0
  26. package/dist/agent/reliable-consumer.d.ts +126 -0
  27. package/dist/agent/reliable-consumer.d.ts.map +1 -0
  28. package/dist/agent/reliable-consumer.js +551 -0
  29. package/dist/agent/reliable-consumer.js.map +1 -0
  30. package/dist/agent/replies.d.ts +28 -0
  31. package/dist/agent/replies.d.ts.map +1 -0
  32. package/dist/agent/replies.js +175 -0
  33. package/dist/agent/replies.js.map +1 -0
  34. package/dist/agent/router.d.ts +72 -0
  35. package/dist/agent/router.d.ts.map +1 -0
  36. package/dist/agent/router.js +172 -0
  37. package/dist/agent/router.js.map +1 -0
  38. package/dist/agent/scope.d.ts +16 -0
  39. package/dist/agent/scope.d.ts.map +1 -0
  40. package/dist/agent/scope.js +34 -0
  41. package/dist/agent/scope.js.map +1 -0
  42. package/dist/agent/workflow.d.ts +85 -0
  43. package/dist/agent/workflow.d.ts.map +1 -0
  44. package/dist/agent/workflow.js +416 -0
  45. package/dist/agent/workflow.js.map +1 -0
  46. package/dist/blob.d.ts +12 -0
  47. package/dist/blob.d.ts.map +1 -0
  48. package/dist/blob.js +34 -0
  49. package/dist/blob.js.map +1 -0
  50. package/dist/bridges/a2a.d.ts +89 -0
  51. package/dist/bridges/a2a.d.ts.map +1 -0
  52. package/dist/bridges/a2a.js +244 -0
  53. package/dist/bridges/a2a.js.map +1 -0
  54. package/dist/bridges/agui.d.ts +66 -0
  55. package/dist/bridges/agui.d.ts.map +1 -0
  56. package/dist/bridges/agui.js +335 -0
  57. package/dist/bridges/agui.js.map +1 -0
  58. package/dist/bridges/edge-auth.d.ts +16 -0
  59. package/dist/bridges/edge-auth.d.ts.map +1 -0
  60. package/dist/bridges/edge-auth.js +19 -0
  61. package/dist/bridges/edge-auth.js.map +1 -0
  62. package/dist/bridges/hops.d.ts +9 -0
  63. package/dist/bridges/hops.d.ts.map +1 -0
  64. package/dist/bridges/hops.js +16 -0
  65. package/dist/bridges/hops.js.map +1 -0
  66. package/dist/bridges/mcp.d.ts +79 -0
  67. package/dist/bridges/mcp.d.ts.map +1 -0
  68. package/dist/bridges/mcp.js +248 -0
  69. package/dist/bridges/mcp.js.map +1 -0
  70. package/dist/client/bytes.d.ts +3 -0
  71. package/dist/client/bytes.d.ts.map +1 -0
  72. package/dist/client/bytes.js +9 -0
  73. package/dist/client/bytes.js.map +1 -0
  74. package/dist/client/capabilities.d.ts +36 -0
  75. package/dist/client/capabilities.d.ts.map +1 -0
  76. package/dist/client/capabilities.js +91 -0
  77. package/dist/client/capabilities.js.map +1 -0
  78. package/dist/client/errors.d.ts +178 -0
  79. package/dist/client/errors.d.ts.map +1 -0
  80. package/dist/client/errors.js +192 -0
  81. package/dist/client/errors.js.map +1 -0
  82. package/dist/client/internals.d.ts +5 -0
  83. package/dist/client/internals.d.ts.map +1 -0
  84. package/dist/client/internals.js +5 -0
  85. package/dist/client/internals.js.map +1 -0
  86. package/dist/client/laser.d.ts +238 -0
  87. package/dist/client/laser.d.ts.map +1 -0
  88. package/dist/client/laser.js +831 -0
  89. package/dist/client/laser.js.map +1 -0
  90. package/dist/client/laserdata-ca.d.ts +2 -0
  91. package/dist/client/laserdata-ca.d.ts.map +1 -0
  92. package/dist/client/laserdata-ca.js +35 -0
  93. package/dist/client/laserdata-ca.js.map +1 -0
  94. package/dist/client/managed.d.ts +6 -0
  95. package/dist/client/managed.d.ts.map +1 -0
  96. package/dist/client/managed.js +19 -0
  97. package/dist/client/managed.js.map +1 -0
  98. package/dist/context-scope.d.ts +40 -0
  99. package/dist/context-scope.d.ts.map +1 -0
  100. package/dist/context-scope.js +73 -0
  101. package/dist/context-scope.js.map +1 -0
  102. package/dist/context.d.ts +64 -0
  103. package/dist/context.d.ts.map +1 -0
  104. package/dist/context.js +149 -0
  105. package/dist/context.js.map +1 -0
  106. package/dist/conversation-state.d.ts +24 -0
  107. package/dist/conversation-state.d.ts.map +1 -0
  108. package/dist/conversation-state.js +29 -0
  109. package/dist/conversation-state.js.map +1 -0
  110. package/dist/crash-context.d.ts +11 -0
  111. package/dist/crash-context.d.ts.map +1 -0
  112. package/dist/crash-context.js +62 -0
  113. package/dist/crash-context.js.map +1 -0
  114. package/dist/full.d.ts +3 -0
  115. package/dist/full.d.ts.map +1 -0
  116. package/dist/full.js +3 -0
  117. package/dist/full.js.map +1 -0
  118. package/dist/govern.d.ts +133 -0
  119. package/dist/govern.d.ts.map +1 -0
  120. package/dist/govern.js +347 -0
  121. package/dist/govern.js.map +1 -0
  122. package/dist/iggy/apache-iggy.d.ts +173 -0
  123. package/dist/iggy/apache-iggy.d.ts.map +1 -0
  124. package/dist/iggy/apache-iggy.js +634 -0
  125. package/dist/iggy/apache-iggy.js.map +1 -0
  126. package/dist/index.d.ts +121 -0
  127. package/dist/index.d.ts.map +1 -0
  128. package/dist/index.js +64 -0
  129. package/dist/index.js.map +1 -0
  130. package/dist/intent.d.ts +75 -0
  131. package/dist/intent.d.ts.map +1 -0
  132. package/dist/intent.js +195 -0
  133. package/dist/intent.js.map +1 -0
  134. package/dist/managed/batch.d.ts +5 -0
  135. package/dist/managed/batch.d.ts.map +1 -0
  136. package/dist/managed/batch.js +32 -0
  137. package/dist/managed/batch.js.map +1 -0
  138. package/dist/managed/forks.d.ts +72 -0
  139. package/dist/managed/forks.d.ts.map +1 -0
  140. package/dist/managed/forks.js +188 -0
  141. package/dist/managed/forks.js.map +1 -0
  142. package/dist/managed/graph.d.ts +58 -0
  143. package/dist/managed/graph.d.ts.map +1 -0
  144. package/dist/managed/graph.js +176 -0
  145. package/dist/managed/graph.js.map +1 -0
  146. package/dist/managed/kv.d.ts +144 -0
  147. package/dist/managed/kv.d.ts.map +1 -0
  148. package/dist/managed/kv.js +502 -0
  149. package/dist/managed/kv.js.map +1 -0
  150. package/dist/managed/projections.d.ts +61 -0
  151. package/dist/managed/projections.d.ts.map +1 -0
  152. package/dist/managed/projections.js +191 -0
  153. package/dist/managed/projections.js.map +1 -0
  154. package/dist/managed/query.d.ts +72 -0
  155. package/dist/managed/query.d.ts.map +1 -0
  156. package/dist/managed/query.js +287 -0
  157. package/dist/managed/query.js.map +1 -0
  158. package/dist/managed/rbac.d.ts +16 -0
  159. package/dist/managed/rbac.d.ts.map +1 -0
  160. package/dist/managed/rbac.js +82 -0
  161. package/dist/managed/rbac.js.map +1 -0
  162. package/dist/managed/runs.d.ts +40 -0
  163. package/dist/managed/runs.d.ts.map +1 -0
  164. package/dist/managed/runs.js +112 -0
  165. package/dist/managed/runs.js.map +1 -0
  166. package/dist/managed/watch.d.ts +21 -0
  167. package/dist/managed/watch.d.ts.map +1 -0
  168. package/dist/managed/watch.js +73 -0
  169. package/dist/managed/watch.js.map +1 -0
  170. package/dist/memory/handle.d.ts +77 -0
  171. package/dist/memory/handle.d.ts.map +1 -0
  172. package/dist/memory/handle.js +234 -0
  173. package/dist/memory/handle.js.map +1 -0
  174. package/dist/memory/log-memory.d.ts +38 -0
  175. package/dist/memory/log-memory.d.ts.map +1 -0
  176. package/dist/memory/log-memory.js +309 -0
  177. package/dist/memory/log-memory.js.map +1 -0
  178. package/dist/memory/topic.d.ts +22 -0
  179. package/dist/memory/topic.d.ts.map +1 -0
  180. package/dist/memory/topic.js +56 -0
  181. package/dist/memory/topic.js.map +1 -0
  182. package/dist/memory/types.d.ts +108 -0
  183. package/dist/memory/types.d.ts.map +1 -0
  184. package/dist/memory/types.js +127 -0
  185. package/dist/memory/types.js.map +1 -0
  186. package/dist/memory/vector-memory.d.ts +20 -0
  187. package/dist/memory/vector-memory.d.ts.map +1 -0
  188. package/dist/memory/vector-memory.js +193 -0
  189. package/dist/memory/vector-memory.js.map +1 -0
  190. package/dist/memory.d.ts +7 -0
  191. package/dist/memory.d.ts.map +1 -0
  192. package/dist/memory.js +6 -0
  193. package/dist/memory.js.map +1 -0
  194. package/dist/observe.d.ts +10 -0
  195. package/dist/observe.d.ts.map +1 -0
  196. package/dist/observe.js +5 -0
  197. package/dist/observe.js.map +1 -0
  198. package/dist/opentelemetry.d.ts +22 -0
  199. package/dist/opentelemetry.d.ts.map +1 -0
  200. package/dist/opentelemetry.js +38 -0
  201. package/dist/opentelemetry.js.map +1 -0
  202. package/dist/provenance/agent-topic.d.ts +14 -0
  203. package/dist/provenance/agent-topic.d.ts.map +1 -0
  204. package/dist/provenance/agent-topic.js +13 -0
  205. package/dist/provenance/agent-topic.js.map +1 -0
  206. package/dist/provenance/provenance.d.ts +24 -0
  207. package/dist/provenance/provenance.d.ts.map +1 -0
  208. package/dist/provenance/provenance.js +186 -0
  209. package/dist/provenance/provenance.js.map +1 -0
  210. package/dist/provenance/session-policy.d.ts +4 -0
  211. package/dist/provenance/session-policy.d.ts.map +1 -0
  212. package/dist/provenance/session-policy.js +5 -0
  213. package/dist/provenance/session-policy.js.map +1 -0
  214. package/dist/runtime/async-once.d.ts +6 -0
  215. package/dist/runtime/async-once.d.ts.map +1 -0
  216. package/dist/runtime/async-once.js +19 -0
  217. package/dist/runtime/async-once.js.map +1 -0
  218. package/dist/runtime/clock.d.ts +14 -0
  219. package/dist/runtime/clock.d.ts.map +1 -0
  220. package/dist/runtime/clock.js +21 -0
  221. package/dist/runtime/clock.js.map +1 -0
  222. package/dist/runtime/mutex.d.ts +5 -0
  223. package/dist/runtime/mutex.d.ts.map +1 -0
  224. package/dist/runtime/mutex.js +23 -0
  225. package/dist/runtime/mutex.js.map +1 -0
  226. package/dist/runtime/ulid.d.ts +7 -0
  227. package/dist/runtime/ulid.d.ts.map +1 -0
  228. package/dist/runtime/ulid.js +17 -0
  229. package/dist/runtime/ulid.js.map +1 -0
  230. package/dist/schema-codecs.d.ts +16 -0
  231. package/dist/schema-codecs.d.ts.map +1 -0
  232. package/dist/schema-codecs.js +174 -0
  233. package/dist/schema-codecs.js.map +1 -0
  234. package/dist/signing.d.ts +63 -0
  235. package/dist/signing.d.ts.map +1 -0
  236. package/dist/signing.js +288 -0
  237. package/dist/signing.js.map +1 -0
  238. package/dist/snapshot.d.ts +24 -0
  239. package/dist/snapshot.d.ts.map +1 -0
  240. package/dist/snapshot.js +80 -0
  241. package/dist/snapshot.js.map +1 -0
  242. package/dist/state-store.d.ts +20 -0
  243. package/dist/state-store.d.ts.map +1 -0
  244. package/dist/state-store.js +70 -0
  245. package/dist/state-store.js.map +1 -0
  246. package/dist/stream/codecs.d.ts +9 -0
  247. package/dist/stream/codecs.d.ts.map +1 -0
  248. package/dist/stream/codecs.js +83 -0
  249. package/dist/stream/codecs.js.map +1 -0
  250. package/dist/stream/consumer.d.ts +50 -0
  251. package/dist/stream/consumer.d.ts.map +1 -0
  252. package/dist/stream/consumer.js +145 -0
  253. package/dist/stream/consumer.js.map +1 -0
  254. package/dist/stream/cursor.d.ts +26 -0
  255. package/dist/stream/cursor.d.ts.map +1 -0
  256. package/dist/stream/cursor.js +83 -0
  257. package/dist/stream/cursor.js.map +1 -0
  258. package/dist/stream/header-value.d.ts +18 -0
  259. package/dist/stream/header-value.d.ts.map +1 -0
  260. package/dist/stream/header-value.js +70 -0
  261. package/dist/stream/header-value.js.map +1 -0
  262. package/dist/stream/polling-strategy.d.ts +14 -0
  263. package/dist/stream/polling-strategy.d.ts.map +1 -0
  264. package/dist/stream/polling-strategy.js +2 -0
  265. package/dist/stream/polling-strategy.js.map +1 -0
  266. package/dist/stream/producer.d.ts +44 -0
  267. package/dist/stream/producer.d.ts.map +1 -0
  268. package/dist/stream/producer.js +125 -0
  269. package/dist/stream/producer.js.map +1 -0
  270. package/dist/stream/publish.d.ts +83 -0
  271. package/dist/stream/publish.d.ts.map +1 -0
  272. package/dist/stream/publish.js +287 -0
  273. package/dist/stream/publish.js.map +1 -0
  274. package/dist/stream/record.d.ts +29 -0
  275. package/dist/stream/record.d.ts.map +1 -0
  276. package/dist/stream/record.js +152 -0
  277. package/dist/stream/record.js.map +1 -0
  278. package/dist/stream/routing.d.ts +10 -0
  279. package/dist/stream/routing.d.ts.map +1 -0
  280. package/dist/stream/routing.js +2 -0
  281. package/dist/stream/routing.js.map +1 -0
  282. package/dist/stream/stream.d.ts +14 -0
  283. package/dist/stream/stream.d.ts.map +1 -0
  284. package/dist/stream/stream.js +26 -0
  285. package/dist/stream/stream.js.map +1 -0
  286. package/dist/stream/topic.d.ts +52 -0
  287. package/dist/stream/topic.d.ts.map +1 -0
  288. package/dist/stream/topic.js +181 -0
  289. package/dist/stream/topic.js.map +1 -0
  290. package/dist/stream/typed-topic.d.ts +59 -0
  291. package/dist/stream/typed-topic.d.ts.map +1 -0
  292. package/dist/stream/typed-topic.js +119 -0
  293. package/dist/stream/typed-topic.js.map +1 -0
  294. package/dist/swarm.d.ts +16 -0
  295. package/dist/swarm.d.ts.map +1 -0
  296. package/dist/swarm.js +40 -0
  297. package/dist/swarm.js.map +1 -0
  298. package/dist/testing.d.ts +16 -0
  299. package/dist/testing.d.ts.map +1 -0
  300. package/dist/testing.js +19 -0
  301. package/dist/testing.js.map +1 -0
  302. package/dist/types/ids.d.ts +48 -0
  303. package/dist/types/ids.d.ts.map +1 -0
  304. package/dist/types/ids.js +161 -0
  305. package/dist/types/ids.js.map +1 -0
  306. package/dist/wire/agent-record.d.ts +24 -0
  307. package/dist/wire/agent-record.d.ts.map +1 -0
  308. package/dist/wire/agent-record.js +99 -0
  309. package/dist/wire/agent-record.js.map +1 -0
  310. package/dist/wire/agent-workflow.d.ts +118 -0
  311. package/dist/wire/agent-workflow.d.ts.map +1 -0
  312. package/dist/wire/agent-workflow.js +290 -0
  313. package/dist/wire/agent-workflow.js.map +1 -0
  314. package/dist/wire/agent.d.ts +255 -0
  315. package/dist/wire/agent.d.ts.map +1 -0
  316. package/dist/wire/agent.js +792 -0
  317. package/dist/wire/agent.js.map +1 -0
  318. package/dist/wire/authz.d.ts +186 -0
  319. package/dist/wire/authz.d.ts.map +1 -0
  320. package/dist/wire/authz.js +545 -0
  321. package/dist/wire/authz.js.map +1 -0
  322. package/dist/wire/batch.d.ts +17 -0
  323. package/dist/wire/batch.d.ts.map +1 -0
  324. package/dist/wire/batch.js +41 -0
  325. package/dist/wire/batch.js.map +1 -0
  326. package/dist/wire/browse.d.ts +96 -0
  327. package/dist/wire/browse.d.ts.map +1 -0
  328. package/dist/wire/browse.js +201 -0
  329. package/dist/wire/browse.js.map +1 -0
  330. package/dist/wire/cbor.d.ts +35 -0
  331. package/dist/wire/cbor.d.ts.map +1 -0
  332. package/dist/wire/cbor.js +231 -0
  333. package/dist/wire/cbor.js.map +1 -0
  334. package/dist/wire/change.d.ts +12 -0
  335. package/dist/wire/change.d.ts.map +1 -0
  336. package/dist/wire/change.js +22 -0
  337. package/dist/wire/change.js.map +1 -0
  338. package/dist/wire/clients.d.ts +27 -0
  339. package/dist/wire/clients.d.ts.map +1 -0
  340. package/dist/wire/clients.js +64 -0
  341. package/dist/wire/clients.js.map +1 -0
  342. package/dist/wire/codes.d.ts +67 -0
  343. package/dist/wire/codes.d.ts.map +1 -0
  344. package/dist/wire/codes.js +67 -0
  345. package/dist/wire/codes.js.map +1 -0
  346. package/dist/wire/commands.d.ts +68 -0
  347. package/dist/wire/commands.d.ts.map +1 -0
  348. package/dist/wire/commands.js +140 -0
  349. package/dist/wire/commands.js.map +1 -0
  350. package/dist/wire/content.d.ts +17 -0
  351. package/dist/wire/content.d.ts.map +1 -0
  352. package/dist/wire/content.js +47 -0
  353. package/dist/wire/content.js.map +1 -0
  354. package/dist/wire/control.d.ts +170 -0
  355. package/dist/wire/control.d.ts.map +1 -0
  356. package/dist/wire/control.js +453 -0
  357. package/dist/wire/control.js.map +1 -0
  358. package/dist/wire/fork.d.ts +112 -0
  359. package/dist/wire/fork.d.ts.map +1 -0
  360. package/dist/wire/fork.js +280 -0
  361. package/dist/wire/fork.js.map +1 -0
  362. package/dist/wire/forward.d.ts +23 -0
  363. package/dist/wire/forward.d.ts.map +1 -0
  364. package/dist/wire/forward.js +72 -0
  365. package/dist/wire/forward.js.map +1 -0
  366. package/dist/wire/graph.d.ts +181 -0
  367. package/dist/wire/graph.d.ts.map +1 -0
  368. package/dist/wire/graph.js +554 -0
  369. package/dist/wire/graph.js.map +1 -0
  370. package/dist/wire/hashing.d.ts +2 -0
  371. package/dist/wire/hashing.d.ts.map +1 -0
  372. package/dist/wire/hashing.js +21 -0
  373. package/dist/wire/hashing.js.map +1 -0
  374. package/dist/wire/headers.d.ts +32 -0
  375. package/dist/wire/headers.d.ts.map +1 -0
  376. package/dist/wire/headers.js +32 -0
  377. package/dist/wire/headers.js.map +1 -0
  378. package/dist/wire/hello.d.ts +50 -0
  379. package/dist/wire/hello.d.ts.map +1 -0
  380. package/dist/wire/hello.js +122 -0
  381. package/dist/wire/hello.js.map +1 -0
  382. package/dist/wire/http.d.ts +95 -0
  383. package/dist/wire/http.d.ts.map +1 -0
  384. package/dist/wire/http.js +282 -0
  385. package/dist/wire/http.js.map +1 -0
  386. package/dist/wire/ids.d.ts +50 -0
  387. package/dist/wire/ids.d.ts.map +1 -0
  388. package/dist/wire/ids.js +198 -0
  389. package/dist/wire/ids.js.map +1 -0
  390. package/dist/wire/index.d.ts +32 -0
  391. package/dist/wire/index.d.ts.map +1 -0
  392. package/dist/wire/index.js +32 -0
  393. package/dist/wire/index.js.map +1 -0
  394. package/dist/wire/kv.d.ts +260 -0
  395. package/dist/wire/kv.d.ts.map +1 -0
  396. package/dist/wire/kv.js +650 -0
  397. package/dist/wire/kv.js.map +1 -0
  398. package/dist/wire/limits.d.ts +36 -0
  399. package/dist/wire/limits.d.ts.map +1 -0
  400. package/dist/wire/limits.js +36 -0
  401. package/dist/wire/limits.js.map +1 -0
  402. package/dist/wire/memory.d.ts +17 -0
  403. package/dist/wire/memory.d.ts.map +1 -0
  404. package/dist/wire/memory.js +65 -0
  405. package/dist/wire/memory.js.map +1 -0
  406. package/dist/wire/mutation.d.ts +10 -0
  407. package/dist/wire/mutation.d.ts.map +1 -0
  408. package/dist/wire/mutation.js +18 -0
  409. package/dist/wire/mutation.js.map +1 -0
  410. package/dist/wire/query.d.ts +210 -0
  411. package/dist/wire/query.d.ts.map +1 -0
  412. package/dist/wire/query.js +594 -0
  413. package/dist/wire/query.js.map +1 -0
  414. package/dist/wire/result.d.ts +25 -0
  415. package/dist/wire/result.d.ts.map +1 -0
  416. package/dist/wire/result.js +52 -0
  417. package/dist/wire/result.js.map +1 -0
  418. package/dist/wire/snapshot.d.ts +11 -0
  419. package/dist/wire/snapshot.d.ts.map +1 -0
  420. package/dist/wire/snapshot.js +50 -0
  421. package/dist/wire/snapshot.js.map +1 -0
  422. package/dist/wire/topics.d.ts +5 -0
  423. package/dist/wire/topics.d.ts.map +1 -0
  424. package/dist/wire/topics.js +5 -0
  425. package/dist/wire/topics.js.map +1 -0
  426. package/dist/wire/topology.d.ts +24 -0
  427. package/dist/wire/topology.d.ts.map +1 -0
  428. package/dist/wire/topology.js +56 -0
  429. package/dist/wire/topology.js.map +1 -0
  430. package/dist/wire/value.d.ts +21 -0
  431. package/dist/wire/value.d.ts.map +1 -0
  432. package/dist/wire/value.js +40 -0
  433. package/dist/wire/value.js.map +1 -0
  434. package/package.json +8 -6
@@ -0,0 +1,831 @@
1
+ import { ApacheIggyTransport } from "../iggy/apache-iggy.js";
2
+ import { createAgdx } from "../agent/agdx.js";
3
+ import { decodeAgentMessage } from "../agent/reliable-consumer.js";
4
+ import { ReplyHub } from "../agent/replies.js";
5
+ import { ContractBuilder, scatter, scatterReport } from "../agent/contract.js";
6
+ import { Workflow } from "../agent/workflow.js";
7
+ import { aguiEvents, publishStateDelta, publishStateSnapshot, reconstructState } from "../bridges/agui.js";
8
+ import { AgentScope } from "../agent/scope.js";
9
+ import { ChunkAssembler } from "../agent/assembler.js";
10
+ import { AgentRegistry, ClientMetadataRequest, encodePresenceInput, newRegistryCache } from "../agent/registry.js";
11
+ import { AsyncOnce } from "../runtime/async-once.js";
12
+ import { Stream } from "../stream/stream.js";
13
+ import { ContextScope } from "../context-scope.js";
14
+ import { ActionKind, GovernorState, encodePolicyEvidence, decodePolicyEvidence, POLICY_DECISION_OPERATION } from "../govern.js";
15
+ import { MemoryBackend, MemoryHandle } from "../memory/handle.js";
16
+ import { MemoryTopicBuilder } from "../memory/topic.js";
17
+ import { NOOP_OBSERVER } from "../observe.js";
18
+ import { executeBatch } from "../managed/batch.js";
19
+ import { Fork } from "../managed/forks.js";
20
+ import { Kv } from "../managed/kv.js";
21
+ import { Bindings, Projections, Schemas } from "../managed/projections.js";
22
+ import { QueryRequest } from "../managed/query.js";
23
+ import { authzHistory, bindRoles, defineRole, deleteRole, getBindings, getRole, listRoles, whoami } from "../managed/rbac.js";
24
+ import { GraphHandle } from "../managed/graph.js";
25
+ import { Runs } from "../managed/runs.js";
26
+ import { Watch } from "../managed/watch.js";
27
+ import { AGDX_HELLO_CODE, AGDX_SET_CLIENT_METADATA_CODE, CONTROL_OP_VERSION } from "../wire/codes.js";
28
+ import { QueryCommand } from "../wire/commands.js";
29
+ import { encodeControlEnvelope } from "../wire/control.js";
30
+ import { decodeBackendAnnounce } from "../wire/hello.js";
31
+ import { AgentId, ConversationId } from "../types/ids.js";
32
+ import { ownedBytes } from "./bytes.js";
33
+ import { OPERATION_CARD, OPERATION_QUARANTINE, OPERATION_UNQUARANTINE, METADATA_DATA_CLASSIFICATION, METADATA_DELEGATED_BY, METADATA_PURPOSE, encodeAgentCard, validateAgentCard, AgentKind } from "../wire/agent.js";
34
+ import { ContentType, contentTypeCode } from "../wire/content.js";
35
+ import { CONTENT_TYPE } from "../wire/headers.js";
36
+ import { IDEMPOTENCY_KEY } from "../wire/headers.js";
37
+ import { AgentTopic } from "../provenance/agent-topic.js";
38
+ import { encodeProvenanceHeaders, provenancePartitionKey } from "../provenance/provenance.js";
39
+ import { CHANGES_TOPIC, CONTROL_TOPIC, DLQ_TOPIC, OPS_STREAM } from "../wire/topics.js";
40
+ import { encodeNamed } from "../wire/cbor.js";
41
+ import { ConfigError, NoStreamError, PresenceConflictError, ProtocolError, QueryExecutionError, InvalidError, UnsupportedError } from "./errors.js";
42
+ import { executeManaged } from "./managed.js";
43
+ import { INTERNAL_GOVERN, INTERNAL_REPLY_HUB, INTERNAL_TRANSPORT, INTERNAL_VERIFIER } from "./internals.js";
44
+ import { OPEN_CAPABILITIES, managedCapabilitiesFrom, managedCapabilitiesWithUnknownVersions, servesConsistency } from "./capabilities.js";
45
+ const LOCAL_CONNECTION_STRING = "iggy:iggy@127.0.0.1:8090";
46
+ const DEFAULT_TOPOLOGY = {
47
+ opsStream: OPS_STREAM,
48
+ controlTopic: CONTROL_TOPIC,
49
+ deadLetterTopic: DLQ_TOPIC,
50
+ changesTopic: CHANGES_TOPIC
51
+ };
52
+ export class LaserBuilder {
53
+ create;
54
+ connectionStringValue;
55
+ addressValue;
56
+ credentialsValue;
57
+ clientValue;
58
+ ownershipValue = "borrowed";
59
+ defaultStreamValue;
60
+ capabilitiesValue;
61
+ governorValue;
62
+ observerValue = NOOP_OBSERVER;
63
+ verifierValue;
64
+ topologyValue = DEFAULT_TOPOLOGY;
65
+ constructor(create) {
66
+ this.create = create;
67
+ }
68
+ connectionString(value) {
69
+ this.connectionStringValue = value;
70
+ return this;
71
+ }
72
+ address(host, port = 8090) {
73
+ this.addressValue = { host, port };
74
+ return this;
75
+ }
76
+ credentials(username, password) {
77
+ this.credentialsValue = { kind: "usernamePassword", username, password };
78
+ return this;
79
+ }
80
+ token(value) {
81
+ this.credentialsValue = { kind: "token", token: value };
82
+ return this;
83
+ }
84
+ iggyClient(client, options = {}) {
85
+ this.clientValue = client;
86
+ this.ownershipValue = options.ownership ?? "borrowed";
87
+ return this;
88
+ }
89
+ defaultStream(value) {
90
+ this.defaultStreamValue = value;
91
+ return this;
92
+ }
93
+ capabilities(value) {
94
+ this.capabilitiesValue = value;
95
+ return this;
96
+ }
97
+ governor(policy, mode) {
98
+ this.governorValue = { policy, mode };
99
+ return this;
100
+ }
101
+ observer(value) {
102
+ this.observerValue = value;
103
+ return this;
104
+ }
105
+ verifier(value) {
106
+ this.verifierValue = value;
107
+ return this;
108
+ }
109
+ opsStream(value) {
110
+ this.topologyValue = { ...this.topologyValue, opsStream: value };
111
+ return this;
112
+ }
113
+ controlTopic(value) {
114
+ this.topologyValue = { ...this.topologyValue, controlTopic: value };
115
+ return this;
116
+ }
117
+ deadLetterTopic(value) {
118
+ this.topologyValue = { ...this.topologyValue, deadLetterTopic: value };
119
+ return this;
120
+ }
121
+ changesTopic(value) {
122
+ this.topologyValue = { ...this.topologyValue, changesTopic: value };
123
+ return this;
124
+ }
125
+ connect() {
126
+ const modes = Number(this.connectionStringValue !== undefined) +
127
+ Number(this.addressValue !== undefined) +
128
+ Number(this.clientValue !== undefined);
129
+ if (modes > 1) {
130
+ throw new ConfigError("connectionString(), address(), and iggyClient() are mutually exclusive");
131
+ }
132
+ if (this.credentialsValue !== undefined && this.addressValue === undefined) {
133
+ throw new ConfigError("credentials() and token() require address()");
134
+ }
135
+ if (this.addressValue !== undefined) {
136
+ const { host, port } = this.addressValue;
137
+ if (host.length === 0 || !Number.isInteger(port) || port <= 0 || port > 65_535) {
138
+ throw new ConfigError("address() requires a non-empty host and a valid TCP port");
139
+ }
140
+ }
141
+ const topologyEntries = [
142
+ ["opsStream", this.topologyValue.opsStream],
143
+ ["controlTopic", this.topologyValue.controlTopic],
144
+ ["deadLetterTopic", this.topologyValue.deadLetterTopic],
145
+ ["changesTopic", this.topologyValue.changesTopic]
146
+ ];
147
+ for (const [name, value] of topologyEntries) {
148
+ if (value.length === 0)
149
+ throw new ConfigError(`${name} must not be empty`);
150
+ }
151
+ return this.create({
152
+ ...(this.connectionStringValue !== undefined
153
+ ? { connectionString: this.connectionStringValue }
154
+ : {}),
155
+ ...(this.addressValue !== undefined ? { address: this.addressValue } : {}),
156
+ ...(this.credentialsValue !== undefined ? { credentials: this.credentialsValue } : {}),
157
+ ...(this.clientValue !== undefined ? { client: this.clientValue } : {}),
158
+ ownership: this.ownershipValue,
159
+ ...(this.defaultStreamValue !== undefined ? { defaultStream: this.defaultStreamValue } : {}),
160
+ ...(this.capabilitiesValue !== undefined ? { capabilities: this.capabilitiesValue } : {}),
161
+ ...(this.governorValue !== undefined ? { governor: this.governorValue } : {}),
162
+ observer: this.observerValue,
163
+ ...(this.verifierValue !== undefined ? { verifier: this.verifierValue } : {}),
164
+ topology: this.topologyValue
165
+ });
166
+ }
167
+ }
168
+ export { INTERNAL_GOVERN, INTERNAL_REPLY_HUB, INTERNAL_TRANSPORT, INTERNAL_VERIFIER } from "./internals.js";
169
+ function newSharedState() {
170
+ return { registryCaches: new Map(), replyHubs: new Map() };
171
+ }
172
+ const WELL_KNOWN_AGENT_TOPICS = [
173
+ AgentTopic.Commands,
174
+ AgentTopic.Responses,
175
+ AgentTopic.ToolCalls,
176
+ AgentTopic.ToolResults,
177
+ AgentTopic.LlmIo,
178
+ AgentTopic.HumanInput,
179
+ AgentTopic.Audit,
180
+ AgentTopic.WorkflowJournal,
181
+ AgentTopic.Dlq,
182
+ AgentTopic.Registry
183
+ ];
184
+ function actionKind(kind) {
185
+ switch (kind) {
186
+ case AgentKind.Command:
187
+ return ActionKind.Command;
188
+ case AgentKind.Response:
189
+ return ActionKind.Response;
190
+ case AgentKind.Event:
191
+ return ActionKind.Event;
192
+ case AgentKind.Status:
193
+ return ActionKind.Status;
194
+ case AgentKind.Error:
195
+ return ActionKind.Error;
196
+ case AgentKind.Chunk:
197
+ return ActionKind.Send;
198
+ }
199
+ }
200
+ function metadataString(envelope, key) {
201
+ const value = envelope.metadata?.get(key);
202
+ return value?.kind === "string" ? value.value : undefined;
203
+ }
204
+ function metadataActionFields(envelope) {
205
+ const onBehalfOf = metadataString(envelope, METADATA_DELEGATED_BY);
206
+ const purpose = metadataString(envelope, METADATA_PURPOSE);
207
+ const dataClassification = metadataString(envelope, METADATA_DATA_CLASSIFICATION);
208
+ return {
209
+ ...(onBehalfOf !== undefined ? { onBehalfOf } : {}),
210
+ ...(purpose !== undefined ? { purpose } : {}),
211
+ ...(dataClassification !== undefined ? { dataClassification } : {})
212
+ };
213
+ }
214
+ async function probeCapabilities(transport) {
215
+ let reply;
216
+ try {
217
+ reply = await transport.sendManaged(AGDX_HELLO_CODE, new Uint8Array());
218
+ }
219
+ catch {
220
+ return OPEN_CAPABILITIES;
221
+ }
222
+ if (reply.byteLength === 0) {
223
+ return managedCapabilitiesWithUnknownVersions();
224
+ }
225
+ try {
226
+ return managedCapabilitiesFrom(decodeBackendAnnounce(reply));
227
+ }
228
+ catch {
229
+ return managedCapabilitiesWithUnknownVersions();
230
+ }
231
+ }
232
+ /** Owns one Apache Iggy connection and addresses every stream available through it. */
233
+ export class Laser {
234
+ transport;
235
+ defaultStream;
236
+ capabilitiesOnce;
237
+ shared;
238
+ observer;
239
+ governor;
240
+ verifier;
241
+ ownsClosure;
242
+ closed = false;
243
+ opsStream;
244
+ controlTopic;
245
+ deadLetterTopic;
246
+ changesTopic;
247
+ constructor(transport, defaultStream, capabilitiesOnce, shared, observer = NOOP_OBSERVER, governor, verifier, topology = DEFAULT_TOPOLOGY, ownsClosure = true) {
248
+ this.transport = transport;
249
+ this.defaultStream = defaultStream;
250
+ this.capabilitiesOnce = capabilitiesOnce;
251
+ this.shared = shared;
252
+ this.observer = observer;
253
+ this.governor = governor;
254
+ this.verifier = verifier;
255
+ this.ownsClosure = ownsClosure;
256
+ this.opsStream = topology.opsStream;
257
+ this.controlTopic = topology.controlTopic;
258
+ this.deadLetterTopic = topology.deadLetterTopic;
259
+ this.changesTopic = topology.changesTopic;
260
+ }
261
+ static builder() {
262
+ return new LaserBuilder(async (options) => {
263
+ let transport;
264
+ if (options.client !== undefined) {
265
+ transport = await ApacheIggyTransport.fromClient(options.client, options.ownership);
266
+ }
267
+ else if (options.address !== undefined) {
268
+ const credentials = options.credentials ?? {
269
+ kind: "usernamePassword",
270
+ username: "iggy",
271
+ password: "iggy"
272
+ };
273
+ const userInfo = credentials.kind === "token"
274
+ ? encodeURIComponent(credentials.token)
275
+ : `${encodeURIComponent(credentials.username)}:${encodeURIComponent(credentials.password)}`;
276
+ const authorityHost = options.address.host.includes(":")
277
+ ? `[${options.address.host.replace(/^\[|\]$/g, "")}]`
278
+ : options.address.host;
279
+ transport = await ApacheIggyTransport.connect(`iggy://${userInfo}@${authorityHost}:${String(options.address.port)}`);
280
+ }
281
+ else {
282
+ transport = await ApacheIggyTransport.connect(options.connectionString ?? LOCAL_CONNECTION_STRING);
283
+ }
284
+ return new Laser(transport, options.defaultStream, options.capabilities === undefined
285
+ ? new AsyncOnce()
286
+ : AsyncOnce.resolved(options.capabilities), newSharedState(), options.observer, options.governor === undefined
287
+ ? undefined
288
+ : new GovernorState(options.governor.policy, options.governor.mode), options.verifier, options.topology);
289
+ });
290
+ }
291
+ static fromIggyClient(client, options = {}) {
292
+ const builder = Laser.builder()
293
+ .iggyClient(client, options.ownership === undefined ? {} : { ownership: options.ownership })
294
+ .capabilities(options.capabilities ?? OPEN_CAPABILITIES);
295
+ if (options.defaultStream !== undefined)
296
+ builder.defaultStream(options.defaultStream);
297
+ if (options.observer !== undefined)
298
+ builder.observer(options.observer);
299
+ return builder.connect();
300
+ }
301
+ static async connect(connectionString) {
302
+ const transport = await ApacheIggyTransport.connect(connectionString);
303
+ return new Laser(transport, undefined, new AsyncOnce(), newSharedState());
304
+ }
305
+ static async connectWithStream(connectionString, stream) {
306
+ const transport = await ApacheIggyTransport.connect(connectionString);
307
+ return new Laser(transport, stream, new AsyncOnce(), newSharedState());
308
+ }
309
+ static async connectEnv(env = process.env) {
310
+ const connectionString = env["LASER_CONNECTION_STRING"];
311
+ if (connectionString === undefined || connectionString.length === 0) {
312
+ throw new ConfigError("LASER_CONNECTION_STRING is not set");
313
+ }
314
+ const stream = env["LASER_STREAM"];
315
+ return stream === undefined || stream.length === 0
316
+ ? Laser.connect(connectionString)
317
+ : Laser.connectWithStream(connectionString, stream);
318
+ }
319
+ static async local() {
320
+ return Laser.connect(LOCAL_CONNECTION_STRING);
321
+ }
322
+ withDefaultStream(stream) {
323
+ return new Laser(this.transport, stream, this.capabilitiesOnce, this.shared, this.observer, this.governor, this.verifier, this.topology(), false);
324
+ }
325
+ withCapabilities(capabilities) {
326
+ return new Laser(this.transport, this.defaultStream, AsyncOnce.resolved(capabilities), this.shared, this.observer, this.governor, this.verifier, this.topology(), false);
327
+ }
328
+ withGovernor(governor, mode) {
329
+ return new Laser(this.transport, this.defaultStream, this.capabilitiesOnce, this.shared, this.observer, new GovernorState(governor, mode), this.verifier, this.topology(), false);
330
+ }
331
+ withVerifier(verifier) {
332
+ return new Laser(this.transport, this.defaultStream, this.capabilitiesOnce, this.shared, this.observer, this.governor, verifier, this.topology(), false);
333
+ }
334
+ withObserver(observer) {
335
+ return new Laser(this.transport, this.defaultStream, this.capabilitiesOnce, this.shared, observer, this.governor, this.verifier, this.topology(), false);
336
+ }
337
+ topology() {
338
+ return {
339
+ opsStream: this.opsStream,
340
+ controlTopic: this.controlTopic,
341
+ deadLetterTopic: this.deadLetterTopic,
342
+ changesTopic: this.changesTopic
343
+ };
344
+ }
345
+ async observe(operation, attributes, effect) {
346
+ const span = this.observer.start(operation, attributes);
347
+ try {
348
+ const value = await effect();
349
+ span.end();
350
+ return value;
351
+ }
352
+ catch (error) {
353
+ span.end(error);
354
+ throw error;
355
+ }
356
+ }
357
+ managedTransport() {
358
+ return {
359
+ sendManaged: (commandCode, payload) => this.observe("laser.managed", { operation: "managed", commandCode }, () => this.transport.sendManaged(commandCode, payload))
360
+ };
361
+ }
362
+ async capabilities() {
363
+ return this.capabilitiesOnce.get(() => probeCapabilities(this.managedTransport()));
364
+ }
365
+ [INTERNAL_TRANSPORT]() {
366
+ return this.transport;
367
+ }
368
+ [INTERNAL_VERIFIER]() {
369
+ return this.verifier;
370
+ }
371
+ [INTERNAL_REPLY_HUB](topic) {
372
+ return this.replyHub(topic);
373
+ }
374
+ [INTERNAL_GOVERN](action) {
375
+ if (this.governor === undefined)
376
+ return Promise.resolve(action.payload.slice());
377
+ return this.governor.govern(action, (evidence) => this.emitPolicyEvidence(action.stream, evidence));
378
+ }
379
+ get iggyClient() {
380
+ return this.transport.iggyClient;
381
+ }
382
+ stream(name) {
383
+ return new Stream(this.transport, name, (stream, topic, payload, provenance) => this[INTERNAL_GOVERN]({
384
+ kind: ActionKind.Publish,
385
+ stream,
386
+ topic,
387
+ ...(provenance?.agent !== undefined ? { source: provenance.agent.asString() } : {}),
388
+ ...(provenance?.targetAgentId !== undefined
389
+ ? { target: provenance.targetAgentId.asString() }
390
+ : {}),
391
+ ...(provenance !== undefined ? { conversation: provenance.conversationId } : {}),
392
+ ...(provenance?.correlationId !== undefined
393
+ ? { correlation: provenance.correlationId }
394
+ : {}),
395
+ payload,
396
+ signed: false
397
+ }), async (schemaId) => (await this.schemas().get(schemaId))?.schema, (operation, attributes, effect) => this.observe(operation, attributes, effect));
398
+ }
399
+ topic(name) {
400
+ if (this.defaultStream === undefined) {
401
+ throw new NoStreamError("topic() requires a default stream, use stream(name).topic(name) or withDefaultStream(name)");
402
+ }
403
+ return this.stream(this.defaultStream).topic(name);
404
+ }
405
+ agdx(topic, source, conversation) {
406
+ if (this.defaultStream === undefined) {
407
+ throw new NoStreamError("agdx() requires a default stream, use connectWithStream() or withDefaultStream()");
408
+ }
409
+ const stream = this.defaultStream;
410
+ return createAgdx(this.transport, stream, topic, source, conversation, undefined, (envelope, willSign) => this[INTERNAL_GOVERN]({
411
+ kind: actionKind(envelope.kind),
412
+ stream,
413
+ topic,
414
+ source: envelope.source,
415
+ ...(envelope.target !== undefined ? { target: envelope.target } : {}),
416
+ conversation,
417
+ ...(envelope.correlation !== undefined
418
+ ? { correlation: envelope.correlation.toString() }
419
+ : {}),
420
+ ...(envelope.operation !== undefined ? { operation: envelope.operation } : {}),
421
+ ...(envelope.tool !== undefined ? { tool: envelope.tool } : {}),
422
+ ...metadataActionFields(envelope),
423
+ payload: envelope.body,
424
+ signed: willSign
425
+ }));
426
+ }
427
+ agent(id) {
428
+ return new AgentScope(this, id);
429
+ }
430
+ contract(router) {
431
+ return new ContractBuilder(this, router);
432
+ }
433
+ workflow(name) {
434
+ return new Workflow(this, name);
435
+ }
436
+ publishStateSnapshot(topic, source, conversation, state) {
437
+ return publishStateSnapshot(this, topic, source, conversation, state);
438
+ }
439
+ publishStateDelta(topic, source, conversation, patch) {
440
+ return publishStateDelta(this, topic, source, conversation, patch);
441
+ }
442
+ reconstructState(conversation, topic) {
443
+ return reconstructState(this, conversation, topic);
444
+ }
445
+ aguiEvents(conversation, topic) {
446
+ return aguiEvents(this, conversation, topic);
447
+ }
448
+ scatter(source, selector, payload, inboxRoute, deadlineMs) {
449
+ return scatter(this, source, selector, payload, inboxRoute, deadlineMs);
450
+ }
451
+ scatterReport(source, selector, payload, inboxRoute, deadlineMs) {
452
+ return scatterReport(this, source, selector, payload, inboxRoute, deadlineMs);
453
+ }
454
+ context(conversation) {
455
+ return new ContextScope(this, conversation);
456
+ }
457
+ memory(namespace) {
458
+ return this.memoryWith(namespace, MemoryBackend.Auto);
459
+ }
460
+ /** Opens durable memory on an existing caller-named topic. */
461
+ memoryOnTopic(topic, stream) {
462
+ return MemoryHandle.logTopic(this, topic, stream);
463
+ }
464
+ /** Configures a durable memory topic before opening it. */
465
+ memoryTopic(topic) {
466
+ return new MemoryTopicBuilder(this, topic);
467
+ }
468
+ memoryWith(namespace, backend, embedder) {
469
+ return backend === MemoryBackend.Vector
470
+ ? MemoryHandle.governedVector(this, embedder)
471
+ : MemoryHandle.log(this, namespace);
472
+ }
473
+ memoryCustom(memory) {
474
+ return MemoryHandle.custom(memory);
475
+ }
476
+ async bootstrap(partitions) {
477
+ const stream = this.requireDefaultStream("bootstrap()");
478
+ await this.observe("laser.bootstrap", { operation: "bootstrap", stream, partitions }, async () => {
479
+ await this.transport.ensureStream(stream);
480
+ await Promise.all(WELL_KNOWN_AGENT_TOPICS.map((topic) => this.transport.ensureTopic(stream, topic, partitions)));
481
+ });
482
+ }
483
+ async sendAgent(topic, payload, provenance, options = {}) {
484
+ const stream = this.requireDefaultStream("sendAgent()");
485
+ await this.observe("laser.agent.send", {
486
+ operation: "send",
487
+ stream,
488
+ topic,
489
+ conversation: provenance.conversationId.toString(),
490
+ ...(provenance.correlationId !== undefined
491
+ ? { correlation: provenance.correlationId }
492
+ : {}),
493
+ ...(provenance.agent !== undefined ? { agent: provenance.agent.asString() } : {})
494
+ }, async () => {
495
+ const governedPayload = await this[INTERNAL_GOVERN]({
496
+ kind: ActionKind.Send,
497
+ stream,
498
+ topic,
499
+ ...(provenance.agent !== undefined ? { source: provenance.agent.asString() } : {}),
500
+ ...(provenance.targetAgentId !== undefined
501
+ ? { target: provenance.targetAgentId.asString() }
502
+ : {}),
503
+ conversation: provenance.conversationId,
504
+ ...(provenance.correlationId !== undefined
505
+ ? { correlation: provenance.correlationId }
506
+ : {}),
507
+ payload: ownedBytes(payload),
508
+ signed: false
509
+ });
510
+ const headers = new Map(encodeProvenanceHeaders(provenance));
511
+ if (options.contentType !== undefined) {
512
+ headers.set(CONTENT_TYPE, {
513
+ kind: "uint8",
514
+ value: contentTypeCode(options.contentType)
515
+ });
516
+ }
517
+ await this.transport.sendMessageWithHeaders(stream, topic, governedPayload, headers, provenancePartitionKey(provenance));
518
+ });
519
+ }
520
+ async policyEvidence(conversation) {
521
+ const messages = await this.context(conversation).fetch([AgentTopic.Audit], Number.MAX_SAFE_INTEGER);
522
+ return messages.flatMap((message) => {
523
+ if (message.envelope?.operation !== POLICY_DECISION_OPERATION)
524
+ return [];
525
+ try {
526
+ return [decodePolicyEvidence(message.envelope.body)];
527
+ }
528
+ catch {
529
+ return [];
530
+ }
531
+ });
532
+ }
533
+ async emitPolicyEvidence(stream, evidence) {
534
+ const conversation = evidence.conversation === undefined
535
+ ? ConversationId.parse("00000000000000000000000000")
536
+ : ConversationId.parse(evidence.conversation);
537
+ const source = AgentId.new(evidence.source ?? "governor");
538
+ await createAgdx(this.transport, stream, AgentTopic.Audit, source, conversation)
539
+ .emit(encodePolicyEvidence(evidence))
540
+ .withOperation(POLICY_DECISION_OPERATION)
541
+ .contentType(ContentType.Cbor)
542
+ .send();
543
+ }
544
+ spawnSubconversation(parent) {
545
+ return {
546
+ conversationId: ConversationId.new(),
547
+ parentConversationId: parent.conversationId,
548
+ rootConversationId: parent.rootConversationId ?? parent.conversationId,
549
+ ...(parent.agent !== undefined ? { agent: parent.agent } : {})
550
+ };
551
+ }
552
+ async reassembleChannel(conversation, topic, channel) {
553
+ const cursor = await this.topic(topic).replay({ batchSize: 1_000 });
554
+ const envelopes = [];
555
+ for (;;) {
556
+ const records = await cursor.poll();
557
+ if (records.length === 0)
558
+ break;
559
+ for (const record of records) {
560
+ const decoded = decodeAgentMessage(record);
561
+ if (decoded.kind !== "message")
562
+ continue;
563
+ const envelope = decoded.message.envelope;
564
+ if (envelope?.kind === AgentKind.Chunk &&
565
+ envelope.conversation.toString() === conversation.toString() &&
566
+ envelope.channel?.equals(channel) === true) {
567
+ envelopes.push(envelope);
568
+ }
569
+ }
570
+ }
571
+ envelopes.sort((left, right) => {
572
+ const a = left.sequence ?? 0n;
573
+ const b = right.sequence ?? 0n;
574
+ return a < b ? -1 : a > b ? 1 : 0;
575
+ });
576
+ const assembler = new ChunkAssembler();
577
+ return envelopes.flatMap((envelope) => assembler.feed(envelope));
578
+ }
579
+ async consumed(target, at) {
580
+ if (this.transport.resolveStreamTopicNames === undefined ||
581
+ this.transport.getConsumerOffset === undefined) {
582
+ throw new UnsupportedError("the active Iggy transport cannot resolve consumer offsets");
583
+ }
584
+ const names = await this.transport.resolveStreamTopicNames(at.streamId, at.topicId);
585
+ if (names === undefined) {
586
+ return { kind: "notYetConsumed", behindBy: at.offset + 1n };
587
+ }
588
+ const consumer = target.kind === "group"
589
+ ? {
590
+ kind: "group",
591
+ name: typeof target.name === "string" ? target.name : target.name.asString()
592
+ }
593
+ : { kind: "consumer", name: target.name };
594
+ const offset = await this.transport.getConsumerOffset(names.stream, names.topic, consumer, at.partitionId);
595
+ if (offset === undefined)
596
+ return { kind: "notYetConsumed", behindBy: at.offset + 1n };
597
+ return offset.storedOffset >= at.offset
598
+ ? { kind: "consumed", committed: offset.storedOffset, head: offset.currentOffset }
599
+ : { kind: "notYetConsumed", behindBy: at.offset - offset.storedOffset };
600
+ }
601
+ async redriveDeadLetter(capsule) {
602
+ if (this.transport.resolveStreamTopicNames === undefined) {
603
+ throw new UnsupportedError("the active Iggy transport cannot resolve dead-letter sources");
604
+ }
605
+ const source = capsule.source;
606
+ const names = await this.transport.resolveStreamTopicNames(source.streamId, source.topicId);
607
+ if (names === undefined) {
608
+ throw new InvalidError("dead-letter source stream or topic no longer exists");
609
+ }
610
+ const records = await this.transport.pollMessages(names.stream, names.topic, { kind: "single", partitionId: source.partitionId }, { kind: "offset", value: source.offset }, 1, false);
611
+ const original = records.find((record) => record.offset === source.offset);
612
+ if (original === undefined) {
613
+ throw new InvalidError(`dead-letter source record at offset ${source.offset.toString()} is no longer on the log`);
614
+ }
615
+ const headers = new Map(original.headers);
616
+ const idempotency = headers.get(IDEMPOTENCY_KEY);
617
+ if (idempotency?.kind === "string") {
618
+ headers.set(IDEMPOTENCY_KEY, {
619
+ kind: "string",
620
+ value: `${idempotency.value}/redrive/${String(source.partitionId)}-${source.offset.toString()}`
621
+ });
622
+ }
623
+ const decoded = decodeAgentMessage(original);
624
+ const partitionKey = decoded.kind === "message" ? provenancePartitionKey(decoded.message.provenance) : undefined;
625
+ await this.transport.sendMessageWithHeaders(names.stream, names.topic, original.payload, headers, partitionKey);
626
+ }
627
+ async request(requestTopic, replyTopic, payload, provenance, timeoutMs, signal) {
628
+ if (!Number.isFinite(timeoutMs) || timeoutMs < 0) {
629
+ throw new InvalidError("request() timeout must be a non-negative finite number");
630
+ }
631
+ const correlationId = provenance.correlationId ?? ConversationId.new().toString();
632
+ const correlated = { ...provenance, correlationId };
633
+ const hub = await this.replyHub(replyTopic);
634
+ const ticket = hub.subscribe(correlationId);
635
+ try {
636
+ await this.sendAgent(requestTopic, payload, correlated);
637
+ }
638
+ catch (error) {
639
+ ticket.cancel();
640
+ throw error;
641
+ }
642
+ return ticket.wait(timeoutMs, signal);
643
+ }
644
+ clientMetadata() {
645
+ return new ClientMetadataRequest(this.transport);
646
+ }
647
+ async advertisePresence(presence) {
648
+ const requested = presence.agent.asString();
649
+ const advertised = this.shared.advertisedAgent;
650
+ if (advertised !== undefined && advertised !== requested) {
651
+ throw new PresenceConflictError(advertised, requested);
652
+ }
653
+ this.shared.advertisedAgent = requested;
654
+ await this.managedTransport().sendManaged(AGDX_SET_CLIENT_METADATA_CODE, encodePresenceInput(presence));
655
+ }
656
+ async clearPresence() {
657
+ await this.managedTransport().sendManaged(AGDX_SET_CLIENT_METADATA_CODE, new Uint8Array());
658
+ delete this.shared.advertisedAgent;
659
+ }
660
+ async agentRegistry() {
661
+ const stream = this.requireDefaultStream("agentRegistry()");
662
+ let cache = this.shared.registryCaches.get(stream);
663
+ if (cache === undefined) {
664
+ cache = newRegistryCache();
665
+ this.shared.registryCaches.set(stream, cache);
666
+ }
667
+ const cursor = await this.topic(AgentTopic.Registry).replay();
668
+ return new AgentRegistry(cursor, cache, () => this.clientMetadata(), undefined, this.verifier);
669
+ }
670
+ async publishCard(source, card) {
671
+ validateAgentCard(card);
672
+ const body = encodeNamed(encodeAgentCard(card));
673
+ await this.agdx(AgentTopic.Registry, source, ConversationId.new())
674
+ .status(OPERATION_CARD)
675
+ .body(body)
676
+ .contentType(ContentType.Cbor)
677
+ .send();
678
+ }
679
+ async quarantine(operator, agent) {
680
+ await this.publishRegistryFact(OPERATION_QUARANTINE, operator, agent);
681
+ }
682
+ async unquarantine(operator, agent) {
683
+ await this.publishRegistryFact(OPERATION_UNQUARANTINE, operator, agent);
684
+ }
685
+ async quarantineSigned(operator, agent, key) {
686
+ await this.publishRegistryFact(OPERATION_QUARANTINE, operator, agent, key);
687
+ }
688
+ async unquarantineSigned(operator, agent, key) {
689
+ await this.publishRegistryFact(OPERATION_UNQUARANTINE, operator, agent, key);
690
+ }
691
+ async publishRegistryFact(operation, operator, agent, key) {
692
+ let fact = this.agdx(AgentTopic.Registry, operator, ConversationId.new())
693
+ .status(operation)
694
+ .body(new TextEncoder().encode(agent.asString()));
695
+ if (key !== undefined)
696
+ fact = fact.signedBy(key);
697
+ await fact.send();
698
+ }
699
+ requireDefaultStream(operation) {
700
+ if (this.defaultStream === undefined) {
701
+ throw new NoStreamError(`${operation} requires a default stream, use connectWithStream() or withDefaultStream()`);
702
+ }
703
+ return this.defaultStream;
704
+ }
705
+ async replyHub(topic) {
706
+ const stream = this.requireDefaultStream("request()");
707
+ const key = `${stream}\u001f${topic}`;
708
+ let hub = this.shared.replyHubs.get(key);
709
+ if (hub === undefined) {
710
+ hub = ReplyHub.create(this.transport, stream, topic);
711
+ this.shared.replyHubs.set(key, hub);
712
+ void hub.catch(() => this.shared.replyHubs.delete(key));
713
+ }
714
+ return hub;
715
+ }
716
+ query(index) {
717
+ return new QueryRequest(index, (query) => this.executeQuery(query));
718
+ }
719
+ kv(namespace) {
720
+ return new Kv(this.managedTransport(), () => this.capabilities(), namespace);
721
+ }
722
+ async kvNamespaces() {
723
+ return Kv.namespaces(this.managedTransport(), () => this.capabilities());
724
+ }
725
+ async executeBatch(ops) {
726
+ const capabilities = await this.capabilities();
727
+ return executeBatch(this.managedTransport(), capabilities, ops);
728
+ }
729
+ fork(forkId) {
730
+ return new Fork(this.managedTransport(), () => this.capabilities(), forkId);
731
+ }
732
+ async forks() {
733
+ return Fork.forks(this.managedTransport(), () => this.capabilities());
734
+ }
735
+ projections() {
736
+ return new Projections(this.managedTransport(), () => this.capabilities(), (command) => this.publishControl(command));
737
+ }
738
+ bindings() {
739
+ return new Bindings((command) => this.publishControl(command));
740
+ }
741
+ schemas() {
742
+ return new Schemas(this.managedTransport(), () => this.capabilities(), (command) => this.publishControl(command));
743
+ }
744
+ runs() {
745
+ return new Runs(this.managedTransport(), () => this.capabilities(), (command) => this.publishControl(command));
746
+ }
747
+ watch() {
748
+ return new Watch(() => this.capabilities(), (options) => this.stream(this.opsStream).topic(this.changesTopic).replay(options));
749
+ }
750
+ graph(name) {
751
+ return new GraphHandle(this.managedTransport(), () => this.capabilities(), name);
752
+ }
753
+ async whoami() {
754
+ return whoami(this.managedTransport(), await this.capabilities());
755
+ }
756
+ async listRoles(options) {
757
+ return listRoles(this.managedTransport(), await this.capabilities(), options);
758
+ }
759
+ async getRole(name) {
760
+ return getRole(this.managedTransport(), await this.capabilities(), name);
761
+ }
762
+ async getBindings(userId) {
763
+ return getBindings(this.managedTransport(), await this.capabilities(), userId);
764
+ }
765
+ async defineRole(role) {
766
+ return defineRole(this.managedTransport(), await this.capabilities(), role);
767
+ }
768
+ async deleteRole(name) {
769
+ return deleteRole(this.managedTransport(), await this.capabilities(), name);
770
+ }
771
+ async bindRoles(userId, roles, expectRevision) {
772
+ return bindRoles(this.managedTransport(), await this.capabilities(), userId, roles, expectRevision);
773
+ }
774
+ async authzHistory(subject, limit, afterRevision) {
775
+ return authzHistory(this.managedTransport(), await this.capabilities(), subject, limit, afterRevision);
776
+ }
777
+ async publishControl(command) {
778
+ const envelope = {
779
+ v: CONTROL_OP_VERSION,
780
+ timestampMicros: BigInt(Date.now()) * 1000n,
781
+ command
782
+ };
783
+ const payload = encodeNamed(encodeControlEnvelope(envelope));
784
+ await this.stream(this.opsStream)
785
+ .topic(this.controlTopic)
786
+ .send(payload, { key: new TextEncoder().encode("control") });
787
+ }
788
+ async executeQuery(query) {
789
+ const capabilities = await this.capabilities();
790
+ if (query.text !== undefined && !capabilities.query.keyword) {
791
+ throw new UnsupportedError("keyword query is not served by this deployment");
792
+ }
793
+ if (!servesConsistency(capabilities, query.consistency)) {
794
+ throw new UnsupportedError(`${query.consistency} query consistency is not served by this deployment`);
795
+ }
796
+ const reply = await executeManaged(this.managedTransport(), capabilities, QueryCommand, {
797
+ query
798
+ });
799
+ if (reply.kind === "ok")
800
+ return reply.result;
801
+ if (reply.kind === "unrecognized") {
802
+ throw new ProtocolError(`query returned unknown reply variant \`${reply.tag}\``, {
803
+ commandCode: QueryCommand.code
804
+ });
805
+ }
806
+ if (reply.error.kind === "unsupported") {
807
+ throw new UnsupportedError(reply.error.message);
808
+ }
809
+ throw new QueryExecutionError(`query failed: ${reply.error.kind}`, reply.error);
810
+ }
811
+ /** Closes owned transport resources. Safe to call more than once. */
812
+ async close() {
813
+ if (this.closed)
814
+ return;
815
+ this.closed = true;
816
+ if (!this.ownsClosure)
817
+ return;
818
+ const hubs = await Promise.allSettled(this.shared.replyHubs.values());
819
+ for (const hub of hubs) {
820
+ if (hub.status === "fulfilled")
821
+ hub.value.stop();
822
+ }
823
+ this.shared.replyHubs.clear();
824
+ await this.observe("laser.close", { operation: "close" }, () => this.transport.close());
825
+ }
826
+ /** Delegates async disposal to `close()`. */
827
+ [Symbol.asyncDispose]() {
828
+ return this.close();
829
+ }
830
+ }
831
+ //# sourceMappingURL=laser.js.map