@labacacia/nps-sdk 1.0.0-alpha.6 → 1.0.0-alpha.7

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 (365) hide show
  1. package/CHANGELOG.cn.md +115 -0
  2. package/CHANGELOG.md +124 -0
  3. package/README.cn.md +3 -1
  4. package/README.md +3 -1
  5. package/dist/core/anchor-cache.d.ts +42 -0
  6. package/dist/core/anchor-cache.d.ts.map +1 -0
  7. package/dist/core/anchor-cache.js +104 -0
  8. package/dist/core/anchor-cache.js.map +1 -0
  9. package/dist/core/cache.d.ts +14 -0
  10. package/dist/core/cache.d.ts.map +1 -0
  11. package/dist/core/cache.js +80 -0
  12. package/dist/core/cache.js.map +1 -0
  13. package/dist/core/canonical-json.d.ts +12 -0
  14. package/dist/core/canonical-json.d.ts.map +1 -0
  15. package/dist/core/canonical-json.js +44 -0
  16. package/dist/core/canonical-json.js.map +1 -0
  17. package/dist/core/codec.d.ts +32 -0
  18. package/dist/core/codec.d.ts.map +1 -0
  19. package/dist/core/codec.js +119 -0
  20. package/dist/core/codec.js.map +1 -0
  21. package/dist/core/codecs/index.d.ts +4 -0
  22. package/dist/core/codecs/index.d.ts.map +1 -0
  23. package/{src/core/codecs/index.ts → dist/core/codecs/index.js} +1 -0
  24. package/dist/core/codecs/index.js.map +1 -0
  25. package/dist/core/codecs/ncp-codec.d.ts +39 -0
  26. package/dist/core/codecs/ncp-codec.d.ts.map +1 -0
  27. package/dist/core/codecs/ncp-codec.js +93 -0
  28. package/dist/core/codecs/ncp-codec.js.map +1 -0
  29. package/dist/core/codecs/tier1-json-codec.d.ts +10 -0
  30. package/dist/core/codecs/tier1-json-codec.d.ts.map +1 -0
  31. package/{src/core/codecs/tier1-json-codec.ts → dist/core/codecs/tier1-json-codec.js} +11 -16
  32. package/dist/core/codecs/tier1-json-codec.js.map +1 -0
  33. package/dist/core/codecs/tier2-msgpack-codec.d.ts +10 -0
  34. package/dist/core/codecs/tier2-msgpack-codec.d.ts.map +1 -0
  35. package/{src/core/codecs/tier2-msgpack-codec.ts → dist/core/codecs/tier2-msgpack-codec.js} +10 -14
  36. package/dist/core/codecs/tier2-msgpack-codec.js.map +1 -0
  37. package/dist/core/crypto-provider.d.ts +31 -0
  38. package/dist/core/crypto-provider.d.ts.map +1 -0
  39. package/dist/core/crypto-provider.js +10 -0
  40. package/dist/core/crypto-provider.js.map +1 -0
  41. package/dist/core/exceptions.d.ts +27 -0
  42. package/dist/core/exceptions.d.ts.map +1 -0
  43. package/dist/core/exceptions.js +52 -0
  44. package/dist/core/exceptions.js.map +1 -0
  45. package/dist/core/frame-header.d.ts +87 -0
  46. package/dist/core/frame-header.d.ts.map +1 -0
  47. package/dist/core/frame-header.js +185 -0
  48. package/dist/core/frame-header.js.map +1 -0
  49. package/dist/core/frame-registry.d.ts +35 -0
  50. package/dist/core/frame-registry.d.ts.map +1 -0
  51. package/dist/core/frame-registry.js +63 -0
  52. package/dist/core/frame-registry.js.map +1 -0
  53. package/dist/core/frames.d.ts +81 -0
  54. package/dist/core/frames.d.ts.map +1 -0
  55. package/dist/core/frames.js +154 -0
  56. package/dist/core/frames.js.map +1 -0
  57. package/dist/core/index.d.ts +11 -0
  58. package/dist/core/index.d.ts.map +1 -0
  59. package/{src/core/index.ts → dist/core/index.js} +3 -23
  60. package/dist/core/index.js.map +1 -0
  61. package/dist/core/registry.d.ts +11 -0
  62. package/dist/core/registry.d.ts.map +1 -0
  63. package/dist/core/registry.js +17 -0
  64. package/dist/core/registry.js.map +1 -0
  65. package/dist/core/status-codes.d.ts +29 -0
  66. package/dist/core/status-codes.d.ts.map +1 -0
  67. package/dist/core/status-codes.js +39 -0
  68. package/dist/core/status-codes.js.map +1 -0
  69. package/dist/index.d.ts +2 -0
  70. package/dist/index.d.ts.map +1 -0
  71. package/{src/index.ts → dist/index.js} +1 -1
  72. package/dist/index.js.map +1 -0
  73. package/dist/ncp/frames/anchor-frame.d.ts +29 -0
  74. package/dist/ncp/frames/anchor-frame.d.ts.map +1 -0
  75. package/dist/ncp/frames/anchor-frame.js +54 -0
  76. package/dist/ncp/frames/anchor-frame.js.map +1 -0
  77. package/dist/ncp/frames/caps-frame.d.ts +29 -0
  78. package/dist/ncp/frames/caps-frame.d.ts.map +1 -0
  79. package/dist/ncp/frames/caps-frame.js +29 -0
  80. package/dist/ncp/frames/caps-frame.js.map +1 -0
  81. package/dist/ncp/frames/diff-frame.d.ts +32 -0
  82. package/dist/ncp/frames/diff-frame.d.ts.map +1 -0
  83. package/dist/ncp/frames/diff-frame.js +37 -0
  84. package/dist/ncp/frames/diff-frame.js.map +1 -0
  85. package/dist/ncp/frames/error-frame.d.ts +16 -0
  86. package/dist/ncp/frames/error-frame.d.ts.map +1 -0
  87. package/dist/ncp/frames/error-frame.js +13 -0
  88. package/dist/ncp/frames/error-frame.js.map +1 -0
  89. package/dist/ncp/frames/hello-frame.d.ts +21 -0
  90. package/dist/ncp/frames/hello-frame.d.ts.map +1 -0
  91. package/dist/ncp/frames/hello-frame.js +25 -0
  92. package/dist/ncp/frames/hello-frame.js.map +1 -0
  93. package/dist/ncp/frames/stream-frame.d.ts +16 -0
  94. package/dist/ncp/frames/stream-frame.d.ts.map +1 -0
  95. package/dist/ncp/frames/stream-frame.js +18 -0
  96. package/dist/ncp/frames/stream-frame.js.map +1 -0
  97. package/dist/ncp/frames.d.ts +94 -0
  98. package/dist/ncp/frames.d.ts.map +1 -0
  99. package/dist/ncp/frames.js +192 -0
  100. package/dist/ncp/frames.js.map +1 -0
  101. package/dist/ncp/handshake.d.ts +30 -0
  102. package/dist/ncp/handshake.d.ts.map +1 -0
  103. package/dist/ncp/handshake.js +80 -0
  104. package/dist/ncp/handshake.js.map +1 -0
  105. package/dist/ncp/index.d.ts +12 -0
  106. package/dist/ncp/index.d.ts.map +1 -0
  107. package/{src/ncp/index.ts → dist/ncp/index.js} +1 -0
  108. package/dist/ncp/index.js.map +1 -0
  109. package/dist/ncp/ncp-error-codes.d.ts +23 -0
  110. package/dist/ncp/ncp-error-codes.d.ts.map +1 -0
  111. package/dist/ncp/ncp-error-codes.js +34 -0
  112. package/dist/ncp/ncp-error-codes.js.map +1 -0
  113. package/dist/ncp/ncp-patch-format.d.ts +7 -0
  114. package/dist/ncp/ncp-patch-format.d.ts.map +1 -0
  115. package/dist/ncp/ncp-patch-format.js +13 -0
  116. package/dist/ncp/ncp-patch-format.js.map +1 -0
  117. package/dist/ncp/preamble.d.ts +47 -0
  118. package/dist/ncp/preamble.d.ts.map +1 -0
  119. package/dist/ncp/preamble.js +74 -0
  120. package/dist/ncp/preamble.js.map +1 -0
  121. package/dist/ncp/registry.d.ts +3 -0
  122. package/dist/ncp/registry.d.ts.map +1 -0
  123. package/dist/ncp/registry.js +13 -0
  124. package/dist/ncp/registry.js.map +1 -0
  125. package/dist/ncp/stream-manager.d.ts +57 -0
  126. package/dist/ncp/stream-manager.d.ts.map +1 -0
  127. package/dist/ncp/stream-manager.js +163 -0
  128. package/dist/ncp/stream-manager.js.map +1 -0
  129. package/dist/ndp/dns-txt.d.ts +35 -0
  130. package/dist/ndp/dns-txt.d.ts.map +1 -0
  131. package/dist/ndp/dns-txt.js +67 -0
  132. package/dist/ndp/dns-txt.js.map +1 -0
  133. package/dist/ndp/frames.d.ts +56 -0
  134. package/dist/ndp/frames.d.ts.map +1 -0
  135. package/dist/ndp/frames.js +87 -0
  136. package/dist/ndp/frames.js.map +1 -0
  137. package/dist/ndp/index.d.ts +6 -0
  138. package/dist/ndp/index.d.ts.map +1 -0
  139. package/{src/ndp/index.ts → dist/ndp/index.js} +1 -1
  140. package/dist/ndp/index.js.map +1 -0
  141. package/dist/ndp/ndp-registry.d.ts +13 -0
  142. package/dist/ndp/ndp-registry.d.ts.map +1 -0
  143. package/dist/ndp/ndp-registry.js +104 -0
  144. package/dist/ndp/ndp-registry.js.map +1 -0
  145. package/dist/ndp/registry.d.ts +3 -0
  146. package/dist/ndp/registry.d.ts.map +1 -0
  147. package/dist/ndp/registry.js +10 -0
  148. package/dist/ndp/registry.js.map +1 -0
  149. package/dist/ndp/validator.d.ts +18 -0
  150. package/dist/ndp/validator.d.ts.map +1 -0
  151. package/dist/ndp/validator.js +48 -0
  152. package/dist/ndp/validator.js.map +1 -0
  153. package/dist/nip/acme/client.d.ts +31 -0
  154. package/dist/nip/acme/client.d.ts.map +1 -0
  155. package/dist/nip/acme/client.js +136 -0
  156. package/dist/nip/acme/client.js.map +1 -0
  157. package/dist/nip/acme/index.d.ts +6 -0
  158. package/dist/nip/acme/index.d.ts.map +1 -0
  159. package/{src/nip/acme/index.ts → dist/nip/acme/index.js} +1 -1
  160. package/dist/nip/acme/index.js.map +1 -0
  161. package/dist/nip/acme/jws.d.ts +31 -0
  162. package/dist/nip/acme/jws.d.ts.map +1 -0
  163. package/dist/nip/acme/jws.js +76 -0
  164. package/dist/nip/acme/jws.js.map +1 -0
  165. package/dist/nip/acme/messages.d.ts +71 -0
  166. package/dist/nip/acme/messages.d.ts.map +1 -0
  167. package/dist/nip/acme/messages.js +4 -0
  168. package/dist/nip/acme/messages.js.map +1 -0
  169. package/dist/nip/acme/server.d.ts +41 -0
  170. package/dist/nip/acme/server.d.ts.map +1 -0
  171. package/dist/nip/acme/server.js +458 -0
  172. package/dist/nip/acme/server.js.map +1 -0
  173. package/dist/nip/acme/wire.d.ts +19 -0
  174. package/dist/nip/acme/wire.d.ts.map +1 -0
  175. package/dist/nip/acme/wire.js +21 -0
  176. package/dist/nip/acme/wire.js.map +1 -0
  177. package/dist/nip/assurance-level.d.ts +19 -0
  178. package/dist/nip/assurance-level.d.ts.map +1 -0
  179. package/dist/nip/assurance-level.js +38 -0
  180. package/dist/nip/assurance-level.js.map +1 -0
  181. package/dist/nip/cert-format.d.ts +5 -0
  182. package/dist/nip/cert-format.d.ts.map +1 -0
  183. package/dist/nip/cert-format.js +6 -0
  184. package/dist/nip/cert-format.js.map +1 -0
  185. package/dist/nip/error-codes.d.ts +25 -0
  186. package/dist/nip/error-codes.d.ts.map +1 -0
  187. package/{src/nip/error-codes.ts → dist/nip/error-codes.js} +19 -25
  188. package/dist/nip/error-codes.js.map +1 -0
  189. package/dist/nip/frames.d.ts +53 -0
  190. package/dist/nip/frames.d.ts.map +1 -0
  191. package/dist/nip/frames.js +106 -0
  192. package/dist/nip/frames.js.map +1 -0
  193. package/dist/nip/identity.d.ts +18 -0
  194. package/dist/nip/identity.d.ts.map +1 -0
  195. package/dist/nip/identity.js +94 -0
  196. package/dist/nip/identity.js.map +1 -0
  197. package/dist/nip/index.d.ts +11 -0
  198. package/dist/nip/index.d.ts.map +1 -0
  199. package/{src/nip/index.ts → dist/nip/index.js} +3 -2
  200. package/dist/nip/index.js.map +1 -0
  201. package/dist/nip/registry.d.ts +3 -0
  202. package/dist/nip/registry.d.ts.map +1 -0
  203. package/dist/nip/registry.js +10 -0
  204. package/dist/nip/registry.js.map +1 -0
  205. package/dist/nip/reputation-client.d.ts +116 -0
  206. package/dist/nip/reputation-client.d.ts.map +1 -0
  207. package/dist/nip/reputation-client.js +261 -0
  208. package/dist/nip/reputation-client.js.map +1 -0
  209. package/dist/nip/verifier.d.ts +23 -0
  210. package/dist/nip/verifier.d.ts.map +1 -0
  211. package/dist/nip/verifier.js +90 -0
  212. package/dist/nip/verifier.js.map +1 -0
  213. package/dist/nip/x509/builder.d.ts +35 -0
  214. package/dist/nip/x509/builder.d.ts.map +1 -0
  215. package/dist/nip/x509/builder.js +59 -0
  216. package/dist/nip/x509/builder.js.map +1 -0
  217. package/dist/nip/x509/index.d.ts +4 -0
  218. package/dist/nip/x509/index.d.ts.map +1 -0
  219. package/{src/nip/x509/index.ts → dist/nip/x509/index.js} +1 -1
  220. package/dist/nip/x509/index.js.map +1 -0
  221. package/dist/nip/x509/oids.d.ts +16 -0
  222. package/dist/nip/x509/oids.d.ts.map +1 -0
  223. package/{src/nip/x509/oids.ts → dist/nip/x509/oids.js} +5 -10
  224. package/dist/nip/x509/oids.js.map +1 -0
  225. package/dist/nip/x509/verifier.d.ts +26 -0
  226. package/dist/nip/x509/verifier.d.ts.map +1 -0
  227. package/dist/nip/x509/verifier.js +171 -0
  228. package/dist/nip/x509/verifier.js.map +1 -0
  229. package/dist/nop/client.d.ts +34 -0
  230. package/dist/nop/client.d.ts.map +1 -0
  231. package/dist/nop/client.js +90 -0
  232. package/dist/nop/client.js.map +1 -0
  233. package/dist/nop/frames.d.ts +65 -0
  234. package/dist/nop/frames.d.ts.map +1 -0
  235. package/dist/nop/frames.js +148 -0
  236. package/dist/nop/frames.js.map +1 -0
  237. package/dist/nop/index.d.ts +5 -0
  238. package/dist/nop/index.d.ts.map +1 -0
  239. package/{src/nop/index.ts → dist/nop/index.js} +1 -1
  240. package/dist/nop/index.js.map +1 -0
  241. package/dist/nop/models.d.ts +58 -0
  242. package/dist/nop/models.d.ts.map +1 -0
  243. package/dist/nop/models.js +50 -0
  244. package/dist/nop/models.js.map +1 -0
  245. package/dist/nop/nop-types.d.ts +136 -0
  246. package/dist/nop/nop-types.d.ts.map +1 -0
  247. package/dist/nop/nop-types.js +44 -0
  248. package/dist/nop/nop-types.js.map +1 -0
  249. package/dist/nop/registry.d.ts +3 -0
  250. package/dist/nop/registry.d.ts.map +1 -0
  251. package/dist/nop/registry.js +11 -0
  252. package/dist/nop/registry.js.map +1 -0
  253. package/dist/nwp/anchor-client.d.ts +109 -0
  254. package/dist/nwp/anchor-client.d.ts.map +1 -0
  255. package/dist/nwp/anchor-client.js +279 -0
  256. package/dist/nwp/anchor-client.js.map +1 -0
  257. package/dist/nwp/client.d.ts +22 -0
  258. package/dist/nwp/client.d.ts.map +1 -0
  259. package/dist/nwp/client.js +101 -0
  260. package/dist/nwp/client.js.map +1 -0
  261. package/dist/nwp/frames.d.ts +46 -0
  262. package/dist/nwp/frames.d.ts.map +1 -0
  263. package/dist/nwp/frames.js +81 -0
  264. package/dist/nwp/frames.js.map +1 -0
  265. package/dist/nwp/index.d.ts +5 -0
  266. package/dist/nwp/index.d.ts.map +1 -0
  267. package/{src/nwp/index.ts → dist/nwp/index.js} +2 -1
  268. package/dist/nwp/index.js.map +1 -0
  269. package/dist/nwp/registry.d.ts +3 -0
  270. package/dist/nwp/registry.d.ts.map +1 -0
  271. package/dist/nwp/registry.js +9 -0
  272. package/dist/nwp/registry.js.map +1 -0
  273. package/dist/setup.d.ts +10 -0
  274. package/dist/setup.d.ts.map +1 -0
  275. package/{src/setup.ts → dist/setup.js} +13 -16
  276. package/dist/setup.js.map +1 -0
  277. package/package.json +12 -1
  278. package/CONTRIBUTING.cn.md +0 -35
  279. package/CONTRIBUTING.md +0 -35
  280. package/nip-ca-server/Dockerfile +0 -27
  281. package/nip-ca-server/README.md +0 -45
  282. package/nip-ca-server/db/001_init.sql +0 -25
  283. package/nip-ca-server/docker-compose.yml +0 -29
  284. package/nip-ca-server/package.json +0 -23
  285. package/nip-ca-server/src/ca.ts +0 -155
  286. package/nip-ca-server/src/db.ts +0 -104
  287. package/nip-ca-server/src/index.ts +0 -157
  288. package/nip-ca-server/tsconfig.json +0 -13
  289. package/src/core/anchor-cache.ts +0 -129
  290. package/src/core/cache.ts +0 -93
  291. package/src/core/canonical-json.ts +0 -50
  292. package/src/core/codec.ts +0 -158
  293. package/src/core/codecs/ncp-codec.ts +0 -170
  294. package/src/core/crypto-provider.ts +0 -47
  295. package/src/core/exceptions.ts +0 -57
  296. package/src/core/frame-header.ts +0 -282
  297. package/src/core/frame-registry.ts +0 -91
  298. package/src/core/frames.ts +0 -184
  299. package/src/core/registry.ts +0 -28
  300. package/src/core/status-codes.ts +0 -47
  301. package/src/ncp/frames/anchor-frame.ts +0 -87
  302. package/src/ncp/frames/caps-frame.ts +0 -59
  303. package/src/ncp/frames/diff-frame.ts +0 -69
  304. package/src/ncp/frames/error-frame.ts +0 -26
  305. package/src/ncp/frames/hello-frame.ts +0 -50
  306. package/src/ncp/frames/stream-frame.ts +0 -35
  307. package/src/ncp/frames.ts +0 -251
  308. package/src/ncp/handshake.ts +0 -95
  309. package/src/ncp/ncp-error-codes.ts +0 -36
  310. package/src/ncp/ncp-patch-format.ts +0 -16
  311. package/src/ncp/preamble.ts +0 -79
  312. package/src/ncp/registry.ts +0 -15
  313. package/src/ncp/stream-manager.ts +0 -212
  314. package/src/ndp/dns-txt.ts +0 -86
  315. package/src/ndp/frames.ts +0 -124
  316. package/src/ndp/ndp-registry.ts +0 -116
  317. package/src/ndp/registry.ts +0 -12
  318. package/src/ndp/validator.ts +0 -64
  319. package/src/nip/acme/client.ts +0 -185
  320. package/src/nip/acme/jws.ts +0 -109
  321. package/src/nip/acme/messages.ts +0 -85
  322. package/src/nip/acme/server.ts +0 -480
  323. package/src/nip/acme/wire.ts +0 -24
  324. package/src/nip/assurance-level.ts +0 -40
  325. package/src/nip/cert-format.ts +0 -9
  326. package/src/nip/frames.ts +0 -138
  327. package/src/nip/identity.ts +0 -113
  328. package/src/nip/registry.ts +0 -12
  329. package/src/nip/verifier.ts +0 -122
  330. package/src/nip/x509/builder.ts +0 -91
  331. package/src/nip/x509/verifier.ts +0 -214
  332. package/src/nop/client.ts +0 -103
  333. package/src/nop/frames.ts +0 -181
  334. package/src/nop/models.ts +0 -79
  335. package/src/nop/nop-types.ts +0 -208
  336. package/src/nop/registry.ts +0 -13
  337. package/src/nwp/client.ts +0 -114
  338. package/src/nwp/frames.ts +0 -116
  339. package/src/nwp/registry.ts +0 -11
  340. package/tests/_rfc0002-keys.ts +0 -57
  341. package/tests/core/anchor-cache.test.ts +0 -242
  342. package/tests/core/codec.test.ts +0 -205
  343. package/tests/core/frame-registry.test.ts +0 -46
  344. package/tests/core.test.ts +0 -327
  345. package/tests/ncp/diff-binary-bitset.test.ts +0 -107
  346. package/tests/ncp/e2e-enc-reject.test.ts +0 -93
  347. package/tests/ncp/err-error-frame.test.ts +0 -152
  348. package/tests/ncp/frames.test.ts +0 -359
  349. package/tests/ncp/framing.test.ts +0 -233
  350. package/tests/ncp/hello-frame.test.ts +0 -122
  351. package/tests/ncp/inline-anchor.test.ts +0 -88
  352. package/tests/ncp/preamble.test.ts +0 -93
  353. package/tests/ncp/security.test.ts +0 -184
  354. package/tests/ncp/stream-window.test.ts +0 -167
  355. package/tests/ncp/stream.test.ts +0 -242
  356. package/tests/ncp/version-negotiation.test.ts +0 -123
  357. package/tests/ndp.test.ts +0 -377
  358. package/tests/nip-acme-agent01.test.ts +0 -192
  359. package/tests/nip-x509.test.ts +0 -280
  360. package/tests/nip.test.ts +0 -184
  361. package/tests/nop.test.ts +0 -344
  362. package/tests/nwp.test.ts +0 -237
  363. package/tsconfig.json +0 -20
  364. package/tsup.config.ts +0 -20
  365. package/vitest.config.ts +0 -10
@@ -0,0 +1,50 @@
1
+ // Copyright 2026 INNO LOTUS PTY LTD
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ export var TaskState;
4
+ (function (TaskState) {
5
+ TaskState["PENDING"] = "pending";
6
+ TaskState["PREFLIGHT"] = "preflight";
7
+ TaskState["RUNNING"] = "running";
8
+ TaskState["WAITING_SYNC"] = "waiting_sync";
9
+ TaskState["COMPLETED"] = "completed";
10
+ TaskState["FAILED"] = "failed";
11
+ TaskState["CANCELLED"] = "cancelled";
12
+ TaskState["SKIPPED"] = "skipped";
13
+ })(TaskState || (TaskState = {}));
14
+ export var TaskPriority;
15
+ (function (TaskPriority) {
16
+ TaskPriority["LOW"] = "low";
17
+ TaskPriority["NORMAL"] = "normal";
18
+ TaskPriority["HIGH"] = "high";
19
+ })(TaskPriority || (TaskPriority = {}));
20
+ export var BackoffStrategy;
21
+ (function (BackoffStrategy) {
22
+ BackoffStrategy["FIXED"] = "fixed";
23
+ BackoffStrategy["LINEAR"] = "linear";
24
+ BackoffStrategy["EXPONENTIAL"] = "exponential";
25
+ })(BackoffStrategy || (BackoffStrategy = {}));
26
+ export var AggregateStrategy;
27
+ (function (AggregateStrategy) {
28
+ AggregateStrategy["MERGE"] = "merge";
29
+ AggregateStrategy["FIRST"] = "first";
30
+ AggregateStrategy["FASTEST_K"] = "fastest_k";
31
+ AggregateStrategy["ALL"] = "all";
32
+ })(AggregateStrategy || (AggregateStrategy = {}));
33
+ export function computeDelayMs(policy, attempt) {
34
+ const base = policy.baseDelayMs ?? 1000;
35
+ const cap = policy.maxDelayMs ?? 30_000;
36
+ let delay;
37
+ switch (policy.backoff) {
38
+ case BackoffStrategy.FIXED:
39
+ delay = base;
40
+ break;
41
+ case BackoffStrategy.LINEAR:
42
+ delay = base * (attempt + 1);
43
+ break;
44
+ case BackoffStrategy.EXPONENTIAL:
45
+ delay = base * Math.pow(2, attempt);
46
+ break;
47
+ }
48
+ return Math.min(delay, cap);
49
+ }
50
+ //# sourceMappingURL=models.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"models.js","sourceRoot":"","sources":["../../src/nop/models.ts"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,sCAAsC;AAEtC,MAAM,CAAN,IAAY,SASX;AATD,WAAY,SAAS;IACnB,gCAAyB,CAAA;IACzB,oCAA2B,CAAA;IAC3B,gCAAyB,CAAA;IACzB,0CAA8B,CAAA;IAC9B,oCAA2B,CAAA;IAC3B,8BAAwB,CAAA;IACxB,oCAA2B,CAAA;IAC3B,gCAAyB,CAAA;AAC3B,CAAC,EATW,SAAS,KAAT,SAAS,QASpB;AAED,MAAM,CAAN,IAAY,YAIX;AAJD,WAAY,YAAY;IACtB,2BAAc,CAAA;IACd,iCAAiB,CAAA;IACjB,6BAAe,CAAA;AACjB,CAAC,EAJW,YAAY,KAAZ,YAAY,QAIvB;AAED,MAAM,CAAN,IAAY,eAIX;AAJD,WAAY,eAAe;IACzB,kCAAqB,CAAA;IACrB,oCAAsB,CAAA;IACtB,8CAA2B,CAAA;AAC7B,CAAC,EAJW,eAAe,KAAf,eAAe,QAI1B;AAED,MAAM,CAAN,IAAY,iBAKX;AALD,WAAY,iBAAiB;IAC3B,oCAAoB,CAAA;IACpB,oCAAoB,CAAA;IACpB,4CAAwB,CAAA;IACxB,gCAAkB,CAAA;AACpB,CAAC,EALW,iBAAiB,KAAjB,iBAAiB,QAK5B;AASD,MAAM,UAAU,cAAc,CAAC,MAAmB,EAAE,OAAe;IACjE,MAAM,IAAI,GAAG,MAAM,CAAC,WAAW,IAAI,IAAI,CAAC;IACxC,MAAM,GAAG,GAAI,MAAM,CAAC,UAAU,IAAK,MAAM,CAAC;IAC1C,IAAI,KAAa,CAAC;IAClB,QAAQ,MAAM,CAAC,OAAO,EAAE,CAAC;QACvB,KAAK,eAAe,CAAC,KAAK;YAAQ,KAAK,GAAG,IAAI,CAAC;YAAC,MAAM;QACtD,KAAK,eAAe,CAAC,MAAM;YAAO,KAAK,GAAG,IAAI,GAAG,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC;YAAC,MAAM;QACtE,KAAK,eAAe,CAAC,WAAW;YAAE,KAAK,GAAG,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;YAAC,MAAM;IAC/E,CAAC;IACD,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;AAC9B,CAAC"}
@@ -0,0 +1,136 @@
1
+ /** NCP protocol version marker */
2
+ type NcpVersion = 1;
3
+ /** Alternative approach considered but not taken */
4
+ export interface Alternative {
5
+ value: string;
6
+ probability: number;
7
+ }
8
+ /** NOP protocol version marker */
9
+ type NopVersion = 1;
10
+ /** Task priority levels */
11
+ export type Priority = "urgent" | "normal" | "low";
12
+ /** Task category — what kind of work this is */
13
+ export type TaskCategory = "code" | "research" | "docs" | "test" | "refactor" | "ops";
14
+ /** Task mailbox paths — where files live during lifecycle */
15
+ export interface Mailbox {
16
+ /** Base path for the task mailbox */
17
+ base: string;
18
+ /** Active directory name. Default: "active" */
19
+ active?: string;
20
+ /** Done directory name. Default: "done" */
21
+ done?: string;
22
+ }
23
+ /** Context the worker needs to do its job */
24
+ export interface TaskContext {
25
+ /** File paths relevant to the task */
26
+ files?: string[];
27
+ /** Key facts the worker needs to know */
28
+ knowledge?: string[];
29
+ /** Git branch to work on */
30
+ branch?: string;
31
+ }
32
+ /** Boundaries the worker must operate within */
33
+ export interface TaskConstraints {
34
+ /** Model to use: "sonnet", "haiku", "opus" */
35
+ model?: string;
36
+ /** Max seconds for task execution */
37
+ time_limit?: number;
38
+ /** Directories/files the worker may touch */
39
+ scope?: string[];
40
+ /** Whether changes need operator approval gate */
41
+ proceed_gate?: boolean;
42
+ }
43
+ /** NOP payload for task dispatch (MVP subset of TaskFrame 0x40) */
44
+ export interface NopIntentPayload {
45
+ _nop: NopVersion;
46
+ /** Unique task ID: task-{source}-{YYYYMMDD}-{HHMMSS} */
47
+ id: string;
48
+ /** Who dispatched — NPS NID format: urn:nps:agent:{domain}:{name} */
49
+ from: string;
50
+ /** Target worker NID. Omit = any available worker picks up */
51
+ to?: string;
52
+ /** ISO 8601 timestamp when task was dispatched */
53
+ created_at: string;
54
+ /** Task priority. Default: "normal" */
55
+ priority?: Priority;
56
+ /** What kind of work this task involves */
57
+ category?: TaskCategory;
58
+ /** Where task files live during lifecycle */
59
+ mailbox: Mailbox;
60
+ /** Context for the worker */
61
+ context?: TaskContext;
62
+ /** Execution boundaries (NPS-5 §3.2 scope carving) */
63
+ constraints?: TaskConstraints;
64
+ }
65
+ /** Terminal task states (NPS-5 §4 state machine) */
66
+ export type TaskStatus = "completed" | "failed" | "timeout" | "blocked";
67
+ /** NOP payload for task result (AlignStream equivalent — NPS-5 §3.4) */
68
+ export interface NopResultPayload {
69
+ _nop: NopVersion;
70
+ /** Same task ID from the intent */
71
+ id: string;
72
+ /** Terminal state */
73
+ status: TaskStatus;
74
+ /** Which worker executed — NPS NID format */
75
+ from: string;
76
+ /** ISO 8601 timestamp when worker claimed the task */
77
+ picked_up_at: string;
78
+ /** ISO 8601 timestamp when worker finished */
79
+ completed_at: string;
80
+ /** Files that were modified */
81
+ files_changed?: string[];
82
+ /** Git commit hashes + messages */
83
+ commits?: string[];
84
+ /** New tasks discovered during execution */
85
+ follow_up?: string[];
86
+ /** Seconds the task took */
87
+ duration?: number;
88
+ /** Error message if failed/timeout */
89
+ error?: string | null;
90
+ }
91
+ /** Complete intent message: NCP envelope + NOP payload */
92
+ export interface IntentMessage {
93
+ _ncp: NcpVersion;
94
+ type: "intent";
95
+ /** Short verb phrase: "fix-bug", "write-test", "research", "refactor" */
96
+ intent: string;
97
+ /** Orchestrator's confidence this is the right task/worker. 0-1 */
98
+ confidence: number;
99
+ /** NOP task payload */
100
+ payload: NopIntentPayload;
101
+ }
102
+ /** Complete result message: NCP envelope + NOP payload */
103
+ export interface ResultMessage {
104
+ _ncp: NcpVersion;
105
+ type: "result";
106
+ /** Human-readable summary of what was done */
107
+ value: string;
108
+ /** Worker's confidence in the result quality. 0-1 */
109
+ probability: number;
110
+ /** Other approaches considered but not taken */
111
+ alternatives: Alternative[];
112
+ /** NOP result payload */
113
+ payload: NopResultPayload;
114
+ }
115
+ /** Any NOP message */
116
+ export type NopMessage = IntentMessage | ResultMessage;
117
+ /** All possible task states */
118
+ export type TaskState = "pending" | "active" | "completed" | "failed" | "timeout" | "blocked" | "cancelled";
119
+ /** Valid state transitions */
120
+ export declare const VALID_TRANSITIONS: Record<string, TaskState[]>;
121
+ /** Directory where a task file lives based on its state */
122
+ export declare const STATE_DIRECTORY: Record<TaskState, string>;
123
+ /** File extensions by message type */
124
+ export declare const FILE_EXTENSIONS: {
125
+ readonly intent: ".intent.json";
126
+ readonly result: ".result.json";
127
+ };
128
+ /** Default mailbox directory names */
129
+ export declare const MAILBOX_DEFAULTS: {
130
+ readonly active: "active";
131
+ readonly done: "done";
132
+ readonly inbox: "inbox";
133
+ readonly blocked: "blocked";
134
+ };
135
+ export {};
136
+ //# sourceMappingURL=nop-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nop-types.d.ts","sourceRoot":"","sources":["../../src/nop/nop-types.ts"],"names":[],"mappings":"AAaA,kCAAkC;AAClC,KAAK,UAAU,GAAG,CAAC,CAAC;AAEpB,oDAAoD;AACpD,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,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ACjB,IAAI,EAAE,QAAQ,CAAC;IACf,8CAA8C;IAC9C,KAAK,EAAE,MAAM,CAAC;IACd,qDAAqD;IACrD,WAAW,EAAE,MAAM,CAAC;IACpB,gDAAgD;IAChD,YAAY,EAAE,WAAW,EAAE,CAAC;IAC5B,yBAAyB;IACzB,OAAO,EAAE,gBAAgB,CAAC;CAC3B;AAED,sBAAsB;AACtB,MAAM,MAAM,UAAU,GAAG,aAAa,GAAG,aAAa,CAAC;AAMvD,+BAA+B;AAC/B,MAAM,MAAM,SAAS,GACjB,SAAS,GACT,QAAQ,GACR,WAAW,GACX,QAAQ,GACR,SAAS,GACT,SAAS,GACT,WAAW,CAAC;AAEhB,8BAA8B;AAC9B,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,EAAE,CAQzD,CAAC;AAMF,2DAA2D;AAC3D,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,SAAS,EAAE,MAAM,CAQrD,CAAC;AAEF,sCAAsC;AACtC,eAAO,MAAM,eAAe;;;CAGlB,CAAC;AAEX,sCAAsC;AACtC,eAAO,MAAM,gBAAgB;;;;;CAKnB,CAAC"}
@@ -0,0 +1,44 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ // Copyright (c) 2026 LabAcacia / INNO LOTUS PTY LTD
3
+ //
4
+ // NOP Task Protocol — TypeScript Type Definitions
5
+ // NPS-5 Neural Orchestration Protocol, MVP subset
6
+ //
7
+ // NCP carries the envelope. NOP fills the payload.
8
+ // IntentFrame dispatches. ResultFrame reports back.
9
+ /** Valid state transitions */
10
+ export const VALID_TRANSITIONS = {
11
+ pending: ["active", "cancelled"],
12
+ active: ["completed", "failed", "timeout", "blocked"],
13
+ blocked: ["active", "cancelled"],
14
+ completed: [],
15
+ failed: [],
16
+ timeout: [],
17
+ cancelled: [],
18
+ };
19
+ // -----------------------------------------------------------------------------
20
+ // File Naming Conventions
21
+ // -----------------------------------------------------------------------------
22
+ /** Directory where a task file lives based on its state */
23
+ export const STATE_DIRECTORY = {
24
+ pending: "inbox",
25
+ active: "active",
26
+ completed: "done",
27
+ failed: "done",
28
+ timeout: "done",
29
+ blocked: "blocked",
30
+ cancelled: "done",
31
+ };
32
+ /** File extensions by message type */
33
+ export const FILE_EXTENSIONS = {
34
+ intent: ".intent.json",
35
+ result: ".result.json",
36
+ };
37
+ /** Default mailbox directory names */
38
+ export const MAILBOX_DEFAULTS = {
39
+ active: "active",
40
+ done: "done",
41
+ inbox: "inbox",
42
+ blocked: "blocked",
43
+ };
44
+ //# sourceMappingURL=nop-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nop-types.js","sourceRoot":"","sources":["../../src/nop/nop-types.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,oDAAoD;AACpD,EAAE;AACF,kDAAkD;AAClD,kDAAkD;AAClD,EAAE;AACF,mDAAmD;AACnD,oDAAoD;AAkKpD,8BAA8B;AAC9B,MAAM,CAAC,MAAM,iBAAiB,GAAgC;IAC5D,OAAO,EAAI,CAAC,QAAQ,EAAE,WAAW,CAAC;IAClC,MAAM,EAAK,CAAC,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,CAAC;IACxD,OAAO,EAAI,CAAC,QAAQ,EAAE,WAAW,CAAC;IAClC,SAAS,EAAE,EAAE;IACb,MAAM,EAAK,EAAE;IACb,OAAO,EAAI,EAAE;IACb,SAAS,EAAE,EAAE;CACd,CAAC;AAEF,gFAAgF;AAChF,0BAA0B;AAC1B,gFAAgF;AAEhF,2DAA2D;AAC3D,MAAM,CAAC,MAAM,eAAe,GAA8B;IACxD,OAAO,EAAI,OAAO;IAClB,MAAM,EAAK,QAAQ;IACnB,SAAS,EAAE,MAAM;IACjB,MAAM,EAAK,MAAM;IACjB,OAAO,EAAI,MAAM;IACjB,OAAO,EAAI,SAAS;IACpB,SAAS,EAAE,MAAM;CAClB,CAAC;AAEF,sCAAsC;AACtC,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,MAAM,EAAE,cAAc;IACtB,MAAM,EAAE,cAAc;CACd,CAAC;AAEX,sCAAsC;AACtC,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,MAAM,EAAE,QAAQ;IAChB,IAAI,EAAE,MAAM;IACZ,KAAK,EAAE,OAAO;IACd,OAAO,EAAE,SAAS;CACV,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { FrameRegistry } from "../core/registry.js";
2
+ export declare function registerNopFrames(registry: FrameRegistry): void;
3
+ //# sourceMappingURL=registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/nop/registry.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAIpD,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,aAAa,GAAG,IAAI,CAK/D"}
@@ -0,0 +1,11 @@
1
+ // Copyright 2026 INNO LOTUS PTY LTD
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ import { FrameType } from "../core/frames.js";
4
+ import { AlignStreamFrame, DelegateFrame, SyncFrame, TaskFrame } from "./frames.js";
5
+ export function registerNopFrames(registry) {
6
+ registry.register(FrameType.TASK, TaskFrame);
7
+ registry.register(FrameType.DELEGATE, DelegateFrame);
8
+ registry.register(FrameType.SYNC, SyncFrame);
9
+ registry.register(FrameType.ALIGN_STREAM, AlignStreamFrame);
10
+ }
11
+ //# sourceMappingURL=registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/nop/registry.ts"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,sCAAsC;AAGtC,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAEpF,MAAM,UAAU,iBAAiB,CAAC,QAAuB;IACvD,QAAQ,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,EAAU,SAAS,CAAC,CAAC;IACrD,QAAQ,CAAC,QAAQ,CAAC,SAAS,CAAC,QAAQ,EAAM,aAAa,CAAC,CAAC;IACzD,QAAQ,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,EAAU,SAAS,CAAC,CAAC;IACrD,QAAQ,CAAC,QAAQ,CAAC,SAAS,CAAC,YAAY,EAAE,gBAAgB,CAAC,CAAC;AAC9D,CAAC"}
@@ -0,0 +1,109 @@
1
+ export interface MemberInfo {
2
+ nid: string;
3
+ node_roles: string[];
4
+ activation_mode: string;
5
+ child_anchor?: boolean;
6
+ member_count?: number;
7
+ tags?: string[];
8
+ joined_at?: string;
9
+ last_seen?: string;
10
+ capabilities?: unknown;
11
+ metrics?: unknown;
12
+ }
13
+ export interface TopologySnapshot {
14
+ version: number;
15
+ anchor_nid: string;
16
+ cluster_size: number;
17
+ members: MemberInfo[];
18
+ truncated?: boolean;
19
+ }
20
+ export interface TopologyFilter {
21
+ tags_any?: string[];
22
+ tags_all?: string[];
23
+ node_roles?: string[];
24
+ }
25
+ export interface MemberChanges {
26
+ node_roles?: string[];
27
+ activation_mode?: string;
28
+ tags?: string[];
29
+ member_count?: number;
30
+ last_seen?: string;
31
+ capabilities?: unknown;
32
+ metrics?: unknown;
33
+ }
34
+ /** Discriminated union for topology stream events (NPS-2 §12.2). */
35
+ export type TopologyEvent = {
36
+ kind: "member_joined";
37
+ version: number;
38
+ member: MemberInfo;
39
+ } | {
40
+ kind: "member_left";
41
+ version: number;
42
+ nid: string;
43
+ } | {
44
+ kind: "member_updated";
45
+ version: number;
46
+ nid: string;
47
+ changes: MemberChanges;
48
+ } | {
49
+ kind: "anchor_state";
50
+ version: number;
51
+ field: string;
52
+ details?: unknown;
53
+ } | {
54
+ kind: "resync_required";
55
+ version: 0;
56
+ reason: string;
57
+ };
58
+ /**
59
+ * Surfaces an Anchor-side topology error to the caller. `nwpErrorCode` matches
60
+ * one of the NWP-TOPOLOGY-* codes; `npsStatus` is the NPS status code.
61
+ */
62
+ export declare class AnchorTopologyError extends Error {
63
+ readonly nwpErrorCode: string;
64
+ readonly npsStatus: string;
65
+ constructor(nwpErrorCode: string, npsStatus: string, message?: string);
66
+ }
67
+ /**
68
+ * Typed client for an Anchor Node's reserved query endpoints.
69
+ *
70
+ * ```ts
71
+ * const client = new AnchorNodeClient("http://anchor.local:8080", "/anchor");
72
+ *
73
+ * const snap = await client.getSnapshot({ scope: "cluster" });
74
+ * for await (const ev of client.subscribe({ sinceVersion: snap.version })) {
75
+ * console.log(ev);
76
+ * }
77
+ * ```
78
+ */
79
+ export declare class AnchorNodeClient {
80
+ private readonly baseUrl;
81
+ private readonly pathPrefix;
82
+ constructor(baseUrl: string, pathPrefix?: string);
83
+ /**
84
+ * Fetch the current cluster topology (NPS-2 §12.1).
85
+ *
86
+ * POSTs a `topology.snapshot` query and returns the first `data` element of
87
+ * the response CapsFrame.
88
+ */
89
+ getSnapshot(options?: {
90
+ scope?: "cluster" | "member";
91
+ include?: string[];
92
+ depth?: number;
93
+ targetNid?: string;
94
+ }): Promise<TopologySnapshot>;
95
+ /**
96
+ * Subscribe to live topology changes (NPS-2 §12.2).
97
+ *
98
+ * The first NDJSON line (subscription ack) is automatically skipped. Each
99
+ * subsequent line is parsed into a `TopologyEvent`. The generator stops after
100
+ * a `resync_required` event — callers MUST issue a fresh `getSnapshot` before
101
+ * resubscribing.
102
+ */
103
+ subscribe(options?: {
104
+ filter?: TopologyFilter;
105
+ sinceVersion?: number;
106
+ scope?: "cluster" | "member";
107
+ }): AsyncGenerator<TopologyEvent>;
108
+ }
109
+ //# sourceMappingURL=anchor-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"anchor-client.d.ts","sourceRoot":"","sources":["../../src/nwp/anchor-client.ts"],"names":[],"mappings":"AAwBA,MAAM,WAAW,UAAU;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,eAAe,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// SPDX-License-Identifier: Apache-2.0
3
+ /**
4
+ * AnchorNodeClient — typed HTTP client for an Anchor Node's reserved query
5
+ * types (NPS-2 §12 — `topology.snapshot` and `topology.stream`).
6
+ *
7
+ * Uses `fetch` only; no extra dependencies.
8
+ */
9
+ // ── Wire constants ────────────────────────────────────────────────────────────
10
+ const SCOPE_CLUSTER = "cluster";
11
+ const SCOPE_MEMBER = "member";
12
+ const TYPE_SNAPSHOT = "topology.snapshot";
13
+ const TYPE_STREAM = "topology.stream";
14
+ const EVENT_MEMBER_JOINED = "member_joined";
15
+ const EVENT_MEMBER_LEFT = "member_left";
16
+ const EVENT_MEMBER_UPDATED = "member_updated";
17
+ const EVENT_ANCHOR_STATE = "anchor_state";
18
+ const EVENT_RESYNC_REQUIRED = "resync_required";
19
+ /**
20
+ * Surfaces an Anchor-side topology error to the caller. `nwpErrorCode` matches
21
+ * one of the NWP-TOPOLOGY-* codes; `npsStatus` is the NPS status code.
22
+ */
23
+ export class AnchorTopologyError extends Error {
24
+ nwpErrorCode;
25
+ npsStatus;
26
+ constructor(nwpErrorCode, npsStatus, message) {
27
+ super(message);
28
+ this.nwpErrorCode = nwpErrorCode;
29
+ this.npsStatus = npsStatus;
30
+ this.name = "AnchorTopologyError";
31
+ }
32
+ }
33
+ // ── AnchorNodeClient ──────────────────────────────────────────────────────────
34
+ /**
35
+ * Typed client for an Anchor Node's reserved query endpoints.
36
+ *
37
+ * ```ts
38
+ * const client = new AnchorNodeClient("http://anchor.local:8080", "/anchor");
39
+ *
40
+ * const snap = await client.getSnapshot({ scope: "cluster" });
41
+ * for await (const ev of client.subscribe({ sinceVersion: snap.version })) {
42
+ * console.log(ev);
43
+ * }
44
+ * ```
45
+ */
46
+ export class AnchorNodeClient {
47
+ baseUrl;
48
+ pathPrefix;
49
+ constructor(baseUrl, pathPrefix = "") {
50
+ // Normalise trailing slashes once.
51
+ this.baseUrl = baseUrl.replace(/\/$/, "");
52
+ this.pathPrefix = pathPrefix.replace(/\/$/, "");
53
+ }
54
+ // ── topology.snapshot ──────────────────────────────────────────────────────
55
+ /**
56
+ * Fetch the current cluster topology (NPS-2 §12.1).
57
+ *
58
+ * POSTs a `topology.snapshot` query and returns the first `data` element of
59
+ * the response CapsFrame.
60
+ */
61
+ async getSnapshot(options) {
62
+ const scope = options?.scope ?? "cluster";
63
+ const include = options?.include ?? ["members"];
64
+ const depth = options?.depth;
65
+ const targetNid = options?.targetNid;
66
+ const topology = {
67
+ scope: scope === "cluster" ? SCOPE_CLUSTER : SCOPE_MEMBER,
68
+ include,
69
+ };
70
+ if (depth !== undefined)
71
+ topology["depth"] = depth;
72
+ if (targetNid !== undefined)
73
+ topology["target_nid"] = targetNid;
74
+ const body = { type: TYPE_SNAPSHOT, topology };
75
+ const url = `${this.baseUrl}${this.pathPrefix}/query`;
76
+ const res = await fetch(url, {
77
+ method: "POST",
78
+ headers: { "Content-Type": "application/json", "Accept": "application/json" },
79
+ body: JSON.stringify(body),
80
+ });
81
+ if (!res.ok) {
82
+ throw await buildFetchError("topology.snapshot", res);
83
+ }
84
+ const caps = await res.json();
85
+ const rows = caps.data;
86
+ if (!Array.isArray(rows) || rows.length !== 1) {
87
+ throw new Error(`topology.snapshot expected exactly 1 data row; got ${Array.isArray(rows) ? rows.length : "non-array"}.`);
88
+ }
89
+ return rows[0];
90
+ }
91
+ // ── topology.stream ────────────────────────────────────────────────────────
92
+ /**
93
+ * Subscribe to live topology changes (NPS-2 §12.2).
94
+ *
95
+ * The first NDJSON line (subscription ack) is automatically skipped. Each
96
+ * subsequent line is parsed into a `TopologyEvent`. The generator stops after
97
+ * a `resync_required` event — callers MUST issue a fresh `getSnapshot` before
98
+ * resubscribing.
99
+ */
100
+ async *subscribe(options) {
101
+ const scope = options?.scope ?? "cluster";
102
+ const filter = options?.filter;
103
+ const sinceVersion = options?.sinceVersion;
104
+ const topology = {
105
+ scope: scope === "cluster" ? SCOPE_CLUSTER : SCOPE_MEMBER,
106
+ };
107
+ if (filter !== undefined)
108
+ topology["filter"] = filter;
109
+ if (sinceVersion !== undefined)
110
+ topology["since_version"] = sinceVersion;
111
+ const body = {
112
+ type: TYPE_STREAM,
113
+ action: "subscribe",
114
+ stream_id: crypto.randomUUID(),
115
+ topology,
116
+ };
117
+ const url = `${this.baseUrl}${this.pathPrefix}/subscribe`;
118
+ const res = await fetch(url, {
119
+ method: "POST",
120
+ headers: {
121
+ "Content-Type": "application/json",
122
+ "Accept": "application/x-ndjson",
123
+ },
124
+ body: JSON.stringify(body),
125
+ });
126
+ if (!res.ok) {
127
+ throw await buildFetchError("topology.stream", res);
128
+ }
129
+ if (res.body === null)
130
+ return;
131
+ let ackSkipped = false;
132
+ for await (const line of readNdjsonLines(res.body)) {
133
+ // Skip the first non-empty line (subscription ack).
134
+ if (!ackSkipped) {
135
+ ackSkipped = true;
136
+ continue;
137
+ }
138
+ // Mid-stream protocol error: { status, error } with no event_type.
139
+ const maybeErr = tryParseStreamError(line);
140
+ if (maybeErr !== null)
141
+ throw maybeErr;
142
+ const ev = parseTopologyEvent(line);
143
+ if (ev === null)
144
+ continue;
145
+ yield ev;
146
+ if (ev.kind === EVENT_RESYNC_REQUIRED)
147
+ return;
148
+ }
149
+ }
150
+ }
151
+ // ── NDJSON line reader ────────────────────────────────────────────────────────
152
+ /**
153
+ * Reads a `ReadableStream<Uint8Array>` and yields complete, non-empty lines.
154
+ * Lines are split on `\n`; trailing `\r` is stripped.
155
+ */
156
+ async function* readNdjsonLines(body) {
157
+ const decoder = new TextDecoder();
158
+ let buffer = "";
159
+ const reader = body.getReader();
160
+ try {
161
+ while (true) {
162
+ const { done, value } = await reader.read();
163
+ if (done)
164
+ break;
165
+ buffer += decoder.decode(value, { stream: true });
166
+ let newlineIdx;
167
+ while ((newlineIdx = buffer.indexOf("\n")) !== -1) {
168
+ const raw = buffer.slice(0, newlineIdx);
169
+ buffer = buffer.slice(newlineIdx + 1);
170
+ const line = raw.endsWith("\r") ? raw.slice(0, -1) : raw;
171
+ if (line.length > 0)
172
+ yield line;
173
+ }
174
+ }
175
+ // Flush decoder.
176
+ buffer += decoder.decode();
177
+ const remaining = buffer.endsWith("\r") ? buffer.slice(0, -1) : buffer;
178
+ if (remaining.length > 0)
179
+ yield remaining;
180
+ }
181
+ finally {
182
+ reader.releaseLock();
183
+ }
184
+ }
185
+ // ── Parsing helpers ───────────────────────────────────────────────────────────
186
+ /** Returns an `AnchorTopologyError` if the line is an error frame, else null. */
187
+ function tryParseStreamError(line) {
188
+ try {
189
+ const obj = JSON.parse(line);
190
+ if (typeof obj !== "object" || obj === null)
191
+ return null;
192
+ if ("event_type" in obj)
193
+ return null; // It's a regular event line.
194
+ if (typeof obj["error"] !== "string")
195
+ return null;
196
+ if (typeof obj["status"] !== "string")
197
+ return null;
198
+ const msg = typeof obj["message"] === "string" ? obj["message"] : undefined;
199
+ return new AnchorTopologyError(obj["error"], obj["status"], msg);
200
+ }
201
+ catch {
202
+ return null;
203
+ }
204
+ }
205
+ /** Parses one NDJSON event line into a `TopologyEvent`, or null if unrecognised. */
206
+ function parseTopologyEvent(line) {
207
+ let obj;
208
+ try {
209
+ obj = JSON.parse(line);
210
+ }
211
+ catch {
212
+ return null;
213
+ }
214
+ if (typeof obj !== "object" || obj === null)
215
+ return null;
216
+ const eventType = obj["event_type"];
217
+ if (typeof eventType !== "string")
218
+ return null;
219
+ const version = typeof obj["seq"] === "number" ? obj["seq"] : 0;
220
+ const payload = (obj["payload"] ?? {});
221
+ switch (eventType) {
222
+ case EVENT_MEMBER_JOINED:
223
+ return {
224
+ kind: "member_joined",
225
+ version,
226
+ member: payload,
227
+ };
228
+ case EVENT_MEMBER_LEFT:
229
+ return {
230
+ kind: "member_left",
231
+ version,
232
+ nid: typeof payload["nid"] === "string" ? payload["nid"] : "",
233
+ };
234
+ case EVENT_MEMBER_UPDATED:
235
+ return {
236
+ kind: "member_updated",
237
+ version,
238
+ nid: typeof payload["nid"] === "string" ? payload["nid"] : "",
239
+ changes: (payload["changes"] ?? {}),
240
+ };
241
+ case EVENT_ANCHOR_STATE:
242
+ return {
243
+ kind: "anchor_state",
244
+ version,
245
+ field: typeof payload["field"] === "string" ? payload["field"] : "",
246
+ details: payload["details"],
247
+ };
248
+ case EVENT_RESYNC_REQUIRED:
249
+ return {
250
+ kind: "resync_required",
251
+ version: 0,
252
+ reason: typeof payload["reason"] === "string" ? payload["reason"] : "unknown",
253
+ };
254
+ default:
255
+ return null;
256
+ }
257
+ }
258
+ /** Builds an `AnchorTopologyError` from a non-ok HTTP response. */
259
+ async function buildFetchError(operation, res) {
260
+ let body;
261
+ try {
262
+ body = await res.text();
263
+ }
264
+ catch {
265
+ body = "";
266
+ }
267
+ try {
268
+ const obj = JSON.parse(body);
269
+ if (typeof obj === "object" && obj !== null &&
270
+ typeof obj["error"] === "string" &&
271
+ typeof obj["status"] === "string") {
272
+ const msg = typeof obj["message"] === "string" ? obj["message"] : body;
273
+ return new AnchorTopologyError(obj["error"], obj["status"], msg);
274
+ }
275
+ }
276
+ catch { /* fall through */ }
277
+ return new AnchorTopologyError("UNKNOWN", `HTTP-${res.status}`, `${operation} returned ${res.status}: ${body}`);
278
+ }
279
+ //# sourceMappingURL=anchor-client.js.map