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

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 (369) hide show
  1. package/CHANGELOG.cn.md +126 -0
  2. package/CHANGELOG.md +135 -0
  3. package/README.cn.md +9 -2
  4. package/README.md +9 -2
  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 +82 -0
  54. package/dist/core/frames.d.ts.map +1 -0
  55. package/dist/core/frames.js +155 -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 +28 -0
  258. package/dist/nwp/client.d.ts.map +1 -0
  259. package/dist/nwp/client.js +142 -0
  260. package/dist/nwp/client.js.map +1 -0
  261. package/dist/nwp/frames.d.ts +107 -0
  262. package/dist/nwp/frames.d.ts.map +1 -0
  263. package/dist/nwp/frames.js +198 -0
  264. package/dist/nwp/frames.js.map +1 -0
  265. package/dist/nwp/index.d.ts +6 -0
  266. package/dist/nwp/index.d.ts.map +1 -0
  267. package/{src/nwp/index.ts → dist/nwp/index.js} +3 -1
  268. package/dist/nwp/index.js.map +1 -0
  269. package/dist/nwp/manifest.d.ts +69 -0
  270. package/dist/nwp/manifest.d.ts.map +1 -0
  271. package/dist/nwp/manifest.js +4 -0
  272. package/dist/nwp/manifest.js.map +1 -0
  273. package/dist/nwp/registry.d.ts +3 -0
  274. package/dist/nwp/registry.d.ts.map +1 -0
  275. package/dist/nwp/registry.js +10 -0
  276. package/dist/nwp/registry.js.map +1 -0
  277. package/dist/setup.d.ts +10 -0
  278. package/dist/setup.d.ts.map +1 -0
  279. package/{src/setup.ts → dist/setup.js} +13 -16
  280. package/dist/setup.js.map +1 -0
  281. package/package.json +12 -1
  282. package/CONTRIBUTING.cn.md +0 -35
  283. package/CONTRIBUTING.md +0 -35
  284. package/nip-ca-server/Dockerfile +0 -27
  285. package/nip-ca-server/README.md +0 -45
  286. package/nip-ca-server/db/001_init.sql +0 -25
  287. package/nip-ca-server/docker-compose.yml +0 -29
  288. package/nip-ca-server/package.json +0 -23
  289. package/nip-ca-server/src/ca.ts +0 -155
  290. package/nip-ca-server/src/db.ts +0 -104
  291. package/nip-ca-server/src/index.ts +0 -157
  292. package/nip-ca-server/tsconfig.json +0 -13
  293. package/src/core/anchor-cache.ts +0 -129
  294. package/src/core/cache.ts +0 -93
  295. package/src/core/canonical-json.ts +0 -50
  296. package/src/core/codec.ts +0 -158
  297. package/src/core/codecs/ncp-codec.ts +0 -170
  298. package/src/core/crypto-provider.ts +0 -47
  299. package/src/core/exceptions.ts +0 -57
  300. package/src/core/frame-header.ts +0 -282
  301. package/src/core/frame-registry.ts +0 -91
  302. package/src/core/frames.ts +0 -184
  303. package/src/core/registry.ts +0 -28
  304. package/src/core/status-codes.ts +0 -47
  305. package/src/ncp/frames/anchor-frame.ts +0 -87
  306. package/src/ncp/frames/caps-frame.ts +0 -59
  307. package/src/ncp/frames/diff-frame.ts +0 -69
  308. package/src/ncp/frames/error-frame.ts +0 -26
  309. package/src/ncp/frames/hello-frame.ts +0 -50
  310. package/src/ncp/frames/stream-frame.ts +0 -35
  311. package/src/ncp/frames.ts +0 -251
  312. package/src/ncp/handshake.ts +0 -95
  313. package/src/ncp/ncp-error-codes.ts +0 -36
  314. package/src/ncp/ncp-patch-format.ts +0 -16
  315. package/src/ncp/preamble.ts +0 -79
  316. package/src/ncp/registry.ts +0 -15
  317. package/src/ncp/stream-manager.ts +0 -212
  318. package/src/ndp/dns-txt.ts +0 -86
  319. package/src/ndp/frames.ts +0 -124
  320. package/src/ndp/ndp-registry.ts +0 -116
  321. package/src/ndp/registry.ts +0 -12
  322. package/src/ndp/validator.ts +0 -64
  323. package/src/nip/acme/client.ts +0 -185
  324. package/src/nip/acme/jws.ts +0 -109
  325. package/src/nip/acme/messages.ts +0 -85
  326. package/src/nip/acme/server.ts +0 -480
  327. package/src/nip/acme/wire.ts +0 -24
  328. package/src/nip/assurance-level.ts +0 -40
  329. package/src/nip/cert-format.ts +0 -9
  330. package/src/nip/frames.ts +0 -138
  331. package/src/nip/identity.ts +0 -113
  332. package/src/nip/registry.ts +0 -12
  333. package/src/nip/verifier.ts +0 -122
  334. package/src/nip/x509/builder.ts +0 -91
  335. package/src/nip/x509/verifier.ts +0 -214
  336. package/src/nop/client.ts +0 -103
  337. package/src/nop/frames.ts +0 -181
  338. package/src/nop/models.ts +0 -79
  339. package/src/nop/nop-types.ts +0 -208
  340. package/src/nop/registry.ts +0 -13
  341. package/src/nwp/client.ts +0 -114
  342. package/src/nwp/frames.ts +0 -116
  343. package/src/nwp/registry.ts +0 -11
  344. package/tests/_rfc0002-keys.ts +0 -57
  345. package/tests/core/anchor-cache.test.ts +0 -242
  346. package/tests/core/codec.test.ts +0 -205
  347. package/tests/core/frame-registry.test.ts +0 -46
  348. package/tests/core.test.ts +0 -327
  349. package/tests/ncp/diff-binary-bitset.test.ts +0 -107
  350. package/tests/ncp/e2e-enc-reject.test.ts +0 -93
  351. package/tests/ncp/err-error-frame.test.ts +0 -152
  352. package/tests/ncp/frames.test.ts +0 -359
  353. package/tests/ncp/framing.test.ts +0 -233
  354. package/tests/ncp/hello-frame.test.ts +0 -122
  355. package/tests/ncp/inline-anchor.test.ts +0 -88
  356. package/tests/ncp/preamble.test.ts +0 -93
  357. package/tests/ncp/security.test.ts +0 -184
  358. package/tests/ncp/stream-window.test.ts +0 -167
  359. package/tests/ncp/stream.test.ts +0 -242
  360. package/tests/ncp/version-negotiation.test.ts +0 -123
  361. package/tests/ndp.test.ts +0 -377
  362. package/tests/nip-acme-agent01.test.ts +0 -192
  363. package/tests/nip-x509.test.ts +0 -280
  364. package/tests/nip.test.ts +0 -184
  365. package/tests/nop.test.ts +0 -344
  366. package/tests/nwp.test.ts +0 -237
  367. package/tsconfig.json +0 -20
  368. package/tsup.config.ts +0 -20
  369. package/vitest.config.ts +0 -10
package/src/nop/frames.ts DELETED
@@ -1,181 +0,0 @@
1
- // Copyright 2026 INNO LOTUS PTY LTD
2
- // SPDX-License-Identifier: Apache-2.0
3
-
4
- import { EncodingTier, FrameType } from "../core/frames.js";
5
- import type { NpsFrame } from "../core/codec.js";
6
- import type { AggregateStrategy, TaskContext, TaskDag, TaskPriority } from "./models.js";
7
-
8
- // ── TaskFrame ─────────────────────────────────────────────────────────────────
9
-
10
- export class TaskFrame implements NpsFrame {
11
- readonly frameType = FrameType.TASK;
12
- readonly preferredTier = EncodingTier.MSGPACK;
13
-
14
- constructor(
15
- public readonly taskId: string,
16
- public readonly dag: TaskDag,
17
- public readonly timeoutMs?: number,
18
- public readonly callbackUrl?: string,
19
- public readonly context?: TaskContext,
20
- public readonly priority?: TaskPriority,
21
- public readonly depth?: number,
22
- ) {}
23
-
24
- toDict(): Record<string, unknown> {
25
- return {
26
- task_id: this.taskId,
27
- dag: this.dag,
28
- timeout_ms: this.timeoutMs ?? null,
29
- callback_url: this.callbackUrl ?? null,
30
- context: this.context ?? null,
31
- priority: this.priority ?? null,
32
- depth: this.depth ?? null,
33
- };
34
- }
35
-
36
- static fromDict(data: Record<string, unknown>): TaskFrame {
37
- return new TaskFrame(
38
- data["task_id"] as string,
39
- data["dag"] as TaskDag,
40
- (data["timeout_ms"] as number | null) ?? undefined,
41
- (data["callback_url"] as string | null) ?? undefined,
42
- (data["context"] as TaskContext | null) ?? undefined,
43
- (data["priority"] as TaskPriority | null) ?? undefined,
44
- (data["depth"] as number | null) ?? undefined,
45
- );
46
- }
47
- }
48
-
49
- // ── DelegateFrame ─────────────────────────────────────────────────────────────
50
-
51
- export class DelegateFrame implements NpsFrame {
52
- readonly frameType = FrameType.DELEGATE;
53
- readonly preferredTier = EncodingTier.MSGPACK;
54
-
55
- constructor(
56
- public readonly taskId: string,
57
- public readonly subtaskId: string,
58
- public readonly action: string,
59
- public readonly agentNid: string,
60
- public readonly inputs?: Record<string, unknown>,
61
- public readonly params?: Record<string, unknown>,
62
- public readonly idempotencyKey?: string,
63
- ) {}
64
-
65
- toDict(): Record<string, unknown> {
66
- return {
67
- task_id: this.taskId,
68
- subtask_id: this.subtaskId,
69
- action: this.action,
70
- agent_nid: this.agentNid,
71
- inputs: this.inputs ?? null,
72
- params: this.params ?? null,
73
- idempotency_key: this.idempotencyKey ?? null,
74
- };
75
- }
76
-
77
- static fromDict(data: Record<string, unknown>): DelegateFrame {
78
- return new DelegateFrame(
79
- data["task_id"] as string,
80
- data["subtask_id"] as string,
81
- data["action"] as string,
82
- data["agent_nid"] as string,
83
- (data["inputs"] as Record<string, unknown> | null) ?? undefined,
84
- (data["params"] as Record<string, unknown> | null) ?? undefined,
85
- (data["idempotency_key"] as string | null) ?? undefined,
86
- );
87
- }
88
- }
89
-
90
- // ── SyncFrame ─────────────────────────────────────────────────────────────────
91
-
92
- export class SyncFrame implements NpsFrame {
93
- readonly frameType = FrameType.SYNC;
94
- readonly preferredTier = EncodingTier.MSGPACK;
95
-
96
- constructor(
97
- public readonly taskId: string,
98
- public readonly syncId: string,
99
- public readonly waitFor: readonly string[],
100
- public readonly minRequired: number = 0,
101
- public readonly aggregate: AggregateStrategy | string = "merge",
102
- public readonly timeoutMs?: number,
103
- ) {}
104
-
105
- toDict(): Record<string, unknown> {
106
- return {
107
- task_id: this.taskId,
108
- sync_id: this.syncId,
109
- wait_for: this.waitFor,
110
- min_required: this.minRequired,
111
- aggregate: this.aggregate,
112
- timeout_ms: this.timeoutMs ?? null,
113
- };
114
- }
115
-
116
- static fromDict(data: Record<string, unknown>): SyncFrame {
117
- return new SyncFrame(
118
- data["task_id"] as string,
119
- data["sync_id"] as string,
120
- data["wait_for"] as string[],
121
- (data["min_required"] as number) ?? 0,
122
- (data["aggregate"] as string) ?? "merge",
123
- (data["timeout_ms"] as number | null) ?? undefined,
124
- );
125
- }
126
- }
127
-
128
- // ── StreamError ───────────────────────────────────────────────────────────────
129
-
130
- export interface StreamError {
131
- errorCode: string;
132
- message?: string;
133
- }
134
-
135
- // ── AlignStreamFrame ──────────────────────────────────────────────────────────
136
-
137
- export class AlignStreamFrame implements NpsFrame {
138
- readonly frameType = FrameType.ALIGN_STREAM;
139
- readonly preferredTier = EncodingTier.MSGPACK;
140
-
141
- constructor(
142
- public readonly streamId: string,
143
- public readonly taskId: string,
144
- public readonly subtaskId: string,
145
- public readonly seq: number,
146
- public readonly isFinal: boolean,
147
- public readonly senderNid: string,
148
- public readonly data?: Record<string, unknown>,
149
- public readonly error?: StreamError,
150
- public readonly windowSize?: number,
151
- ) {}
152
-
153
- toDict(): Record<string, unknown> {
154
- return {
155
- stream_id: this.streamId,
156
- task_id: this.taskId,
157
- subtask_id: this.subtaskId,
158
- seq: this.seq,
159
- is_final: this.isFinal,
160
- sender_nid: this.senderNid,
161
- data: this.data ?? null,
162
- error: this.error ? { error_code: this.error.errorCode, message: this.error.message ?? null } : null,
163
- window_size: this.windowSize ?? null,
164
- };
165
- }
166
-
167
- static fromDict(data: Record<string, unknown>): AlignStreamFrame {
168
- const rawError = data["error"] as { error_code: string; message?: string } | null;
169
- return new AlignStreamFrame(
170
- data["stream_id"] as string,
171
- data["task_id"] as string,
172
- data["subtask_id"] as string,
173
- data["seq"] as number,
174
- data["is_final"] as boolean,
175
- data["sender_nid"] as string,
176
- (data["data"] as Record<string, unknown> | null) ?? undefined,
177
- rawError ? { errorCode: rawError.error_code, ...(rawError.message != null ? { message: rawError.message } : {}) } : undefined,
178
- (data["window_size"] as number | null) ?? undefined,
179
- );
180
- }
181
- }
package/src/nop/models.ts DELETED
@@ -1,79 +0,0 @@
1
- // Copyright 2026 INNO LOTUS PTY LTD
2
- // SPDX-License-Identifier: Apache-2.0
3
-
4
- export enum TaskState {
5
- PENDING = "pending",
6
- PREFLIGHT = "preflight",
7
- RUNNING = "running",
8
- WAITING_SYNC = "waiting_sync",
9
- COMPLETED = "completed",
10
- FAILED = "failed",
11
- CANCELLED = "cancelled",
12
- SKIPPED = "skipped",
13
- }
14
-
15
- export enum TaskPriority {
16
- LOW = "low",
17
- NORMAL = "normal",
18
- HIGH = "high",
19
- }
20
-
21
- export enum BackoffStrategy {
22
- FIXED = "fixed",
23
- LINEAR = "linear",
24
- EXPONENTIAL = "exponential",
25
- }
26
-
27
- export enum AggregateStrategy {
28
- MERGE = "merge",
29
- FIRST = "first",
30
- FASTEST_K = "fastest_k",
31
- ALL = "all",
32
- }
33
-
34
- export interface RetryPolicy {
35
- maxRetries: number;
36
- backoff: BackoffStrategy;
37
- baseDelayMs?: number;
38
- maxDelayMs?: number;
39
- }
40
-
41
- export function computeDelayMs(policy: RetryPolicy, attempt: number): number {
42
- const base = policy.baseDelayMs ?? 1000;
43
- const cap = policy.maxDelayMs ?? 30_000;
44
- let delay: number;
45
- switch (policy.backoff) {
46
- case BackoffStrategy.FIXED: delay = base; break;
47
- case BackoffStrategy.LINEAR: delay = base * (attempt + 1); break;
48
- case BackoffStrategy.EXPONENTIAL: delay = base * Math.pow(2, attempt); break;
49
- }
50
- return Math.min(delay, cap);
51
- }
52
-
53
- export interface TaskContext {
54
- sessionKey?: string;
55
- requesterNid?: string;
56
- traceId?: string;
57
- }
58
-
59
- export interface DagNode {
60
- id: string;
61
- action: string;
62
- agent: string;
63
- inputFrom?: readonly string[];
64
- inputMapping?: Record<string, string>;
65
- timeoutMs?: number;
66
- retryPolicy?: RetryPolicy;
67
- condition?: string;
68
- minRequired?: number;
69
- }
70
-
71
- export interface DagEdge {
72
- from: string;
73
- to: string;
74
- }
75
-
76
- export interface TaskDag {
77
- nodes: readonly DagNode[];
78
- edges: readonly DagEdge[];
79
- }
@@ -1,208 +0,0 @@
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
-
10
- // -----------------------------------------------------------------------------
11
- // NCP Envelope Types (NPS-1)
12
- // -----------------------------------------------------------------------------
13
-
14
- /** NCP protocol version marker */
15
- type NcpVersion = 1;
16
-
17
- /** Alternative approach considered but not taken */
18
- export interface Alternative {
19
- value: string;
20
- probability: number;
21
- }
22
-
23
- // -----------------------------------------------------------------------------
24
- // NOP Payload Types — Intent (Dispatch)
25
- // -----------------------------------------------------------------------------
26
-
27
- /** NOP protocol version marker */
28
- type NopVersion = 1;
29
-
30
- /** Task priority levels */
31
- export type Priority = "urgent" | "normal" | "low";
32
-
33
- /** Task category — what kind of work this is */
34
- export type TaskCategory = "code" | "research" | "docs" | "test" | "refactor" | "ops";
35
-
36
- /** Task mailbox paths — where files live during lifecycle */
37
- export interface Mailbox {
38
- /** Base path for the task mailbox */
39
- base: string;
40
- /** Active directory name. Default: "active" */
41
- active?: string;
42
- /** Done directory name. Default: "done" */
43
- done?: string;
44
- }
45
-
46
- /** Context the worker needs to do its job */
47
- export interface TaskContext {
48
- /** File paths relevant to the task */
49
- files?: string[];
50
- /** Key facts the worker needs to know */
51
- knowledge?: string[];
52
- /** Git branch to work on */
53
- branch?: string;
54
- }
55
-
56
- /** Boundaries the worker must operate within */
57
- export interface TaskConstraints {
58
- /** Model to use: "sonnet", "haiku", "opus" */
59
- model?: string;
60
- /** Max seconds for task execution */
61
- time_limit?: number;
62
- /** Directories/files the worker may touch */
63
- scope?: string[];
64
- /** Whether changes need operator approval gate */
65
- proceed_gate?: boolean;
66
- }
67
-
68
- /** NOP payload for task dispatch (MVP subset of TaskFrame 0x40) */
69
- export interface NopIntentPayload {
70
- _nop: NopVersion;
71
- /** Unique task ID: task-{source}-{YYYYMMDD}-{HHMMSS} */
72
- id: string;
73
- /** Who dispatched — NPS NID format: urn:nps:agent:{domain}:{name} */
74
- from: string;
75
- /** Target worker NID. Omit = any available worker picks up */
76
- to?: string;
77
- /** ISO 8601 timestamp when task was dispatched */
78
- created_at: string;
79
- /** Task priority. Default: "normal" */
80
- priority?: Priority;
81
- /** What kind of work this task involves */
82
- category?: TaskCategory;
83
- /** Where task files live during lifecycle */
84
- mailbox: Mailbox;
85
- /** Context for the worker */
86
- context?: TaskContext;
87
- /** Execution boundaries (NPS-5 §3.2 scope carving) */
88
- constraints?: TaskConstraints;
89
- }
90
-
91
- // -----------------------------------------------------------------------------
92
- // NOP Payload Types — Result (Report Back)
93
- // -----------------------------------------------------------------------------
94
-
95
- /** Terminal task states (NPS-5 §4 state machine) */
96
- export type TaskStatus = "completed" | "failed" | "timeout" | "blocked";
97
-
98
- /** NOP payload for task result (AlignStream equivalent — NPS-5 §3.4) */
99
- export interface NopResultPayload {
100
- _nop: NopVersion;
101
- /** Same task ID from the intent */
102
- id: string;
103
- /** Terminal state */
104
- status: TaskStatus;
105
- /** Which worker executed — NPS NID format */
106
- from: string;
107
- /** ISO 8601 timestamp when worker claimed the task */
108
- picked_up_at: string;
109
- /** ISO 8601 timestamp when worker finished */
110
- completed_at: string;
111
- /** Files that were modified */
112
- files_changed?: string[];
113
- /** Git commit hashes + messages */
114
- commits?: string[];
115
- /** New tasks discovered during execution */
116
- follow_up?: string[];
117
- /** Seconds the task took */
118
- duration?: number;
119
- /** Error message if failed/timeout */
120
- error?: string | null;
121
- }
122
-
123
- // -----------------------------------------------------------------------------
124
- // Full NCP+NOP Messages
125
- // -----------------------------------------------------------------------------
126
-
127
- /** Complete intent message: NCP envelope + NOP payload */
128
- export interface IntentMessage {
129
- _ncp: NcpVersion;
130
- type: "intent";
131
- /** Short verb phrase: "fix-bug", "write-test", "research", "refactor" */
132
- intent: string;
133
- /** Orchestrator's confidence this is the right task/worker. 0-1 */
134
- confidence: number;
135
- /** NOP task payload */
136
- payload: NopIntentPayload;
137
- }
138
-
139
- /** Complete result message: NCP envelope + NOP payload */
140
- export interface ResultMessage {
141
- _ncp: NcpVersion;
142
- type: "result";
143
- /** Human-readable summary of what was done */
144
- value: string;
145
- /** Worker's confidence in the result quality. 0-1 */
146
- probability: number;
147
- /** Other approaches considered but not taken */
148
- alternatives: Alternative[];
149
- /** NOP result payload */
150
- payload: NopResultPayload;
151
- }
152
-
153
- /** Any NOP message */
154
- export type NopMessage = IntentMessage | ResultMessage;
155
-
156
- // -----------------------------------------------------------------------------
157
- // Task Lifecycle (NPS-5 §4)
158
- // -----------------------------------------------------------------------------
159
-
160
- /** All possible task states */
161
- export type TaskState =
162
- | "pending" // inbox/ — waiting for pickup
163
- | "active" // active/ — worker executing
164
- | "completed" // done/ — success
165
- | "failed" // done/ — error
166
- | "timeout" // done/ — exceeded time_limit
167
- | "blocked" // blocked/ — needs external input
168
- | "cancelled"; // done/ — orchestrator cancelled
169
-
170
- /** Valid state transitions */
171
- export const VALID_TRANSITIONS: Record<string, TaskState[]> = {
172
- pending: ["active", "cancelled"],
173
- active: ["completed", "failed", "timeout", "blocked"],
174
- blocked: ["active", "cancelled"],
175
- completed: [],
176
- failed: [],
177
- timeout: [],
178
- cancelled: [],
179
- };
180
-
181
- // -----------------------------------------------------------------------------
182
- // File Naming Conventions
183
- // -----------------------------------------------------------------------------
184
-
185
- /** Directory where a task file lives based on its state */
186
- export const STATE_DIRECTORY: Record<TaskState, string> = {
187
- pending: "inbox",
188
- active: "active",
189
- completed: "done",
190
- failed: "done",
191
- timeout: "done",
192
- blocked: "blocked",
193
- cancelled: "done",
194
- };
195
-
196
- /** File extensions by message type */
197
- export const FILE_EXTENSIONS = {
198
- intent: ".intent.json",
199
- result: ".result.json",
200
- } as const;
201
-
202
- /** Default mailbox directory names */
203
- export const MAILBOX_DEFAULTS = {
204
- active: "active",
205
- done: "done",
206
- inbox: "inbox",
207
- blocked: "blocked",
208
- } as const;
@@ -1,13 +0,0 @@
1
- // Copyright 2026 INNO LOTUS PTY LTD
2
- // SPDX-License-Identifier: Apache-2.0
3
-
4
- import { FrameRegistry } from "../core/registry.js";
5
- import { FrameType } from "../core/frames.js";
6
- import { AlignStreamFrame, DelegateFrame, SyncFrame, TaskFrame } from "./frames.js";
7
-
8
- export function registerNopFrames(registry: FrameRegistry): void {
9
- registry.register(FrameType.TASK, TaskFrame);
10
- registry.register(FrameType.DELEGATE, DelegateFrame);
11
- registry.register(FrameType.SYNC, SyncFrame);
12
- registry.register(FrameType.ALIGN_STREAM, AlignStreamFrame);
13
- }
package/src/nwp/client.ts DELETED
@@ -1,114 +0,0 @@
1
- // Copyright 2026 INNO LOTUS PTY LTD
2
- // SPDX-License-Identifier: Apache-2.0
3
-
4
- /**
5
- * NwpClient — async HTTP-mode client for NPS Neural Web Protocol nodes (NPS-2).
6
- */
7
-
8
- import { NpsFrameCodec } from "../core/codec.js";
9
- import { EncodingTier } from "../core/frames.js";
10
- import { FrameRegistry } from "../core/registry.js";
11
- import { registerNcpFrames } from "../ncp/registry.js";
12
- import { CapsFrame } from "../ncp/frames.js";
13
- import type { StreamFrame } from "../ncp/frames.js";
14
- import { registerNwpFrames } from "./registry.js";
15
- import { ActionFrame, asyncActionResponseFromDict } from "./frames.js";
16
- import type { AnchorFrame } from "../ncp/frames.js";
17
- import type { QueryFrame, AsyncActionResponse } from "./frames.js";
18
-
19
- const CONTENT_TYPE = "application/x-nps-frame";
20
-
21
- export class NwpClient {
22
- private readonly _baseUrl: string;
23
- private readonly _codec: NpsFrameCodec;
24
- private readonly _tier: EncodingTier;
25
-
26
- constructor(
27
- baseUrl: string,
28
- options: { defaultTier?: EncodingTier; maxPayload?: number; registry?: FrameRegistry } = {},
29
- ) {
30
- this._baseUrl = baseUrl.replace(/\/$/, "");
31
- this._tier = options.defaultTier ?? EncodingTier.MSGPACK;
32
-
33
- const registry = options.registry ?? (() => {
34
- const r = new FrameRegistry();
35
- registerNcpFrames(r);
36
- registerNwpFrames(r);
37
- return r;
38
- })();
39
- const codecOpts = options.maxPayload !== undefined ? { maxPayload: options.maxPayload } : {};
40
- this._codec = new NpsFrameCodec(registry, codecOpts);
41
- }
42
-
43
- async sendAnchor(frame: AnchorFrame): Promise<void> {
44
- const wire = this._codec.encode(frame, { overrideTier: this._tier });
45
- const res = await fetch(`${this._baseUrl}/anchor`, {
46
- method: "POST",
47
- body: wire as BodyInit,
48
- headers: { "Content-Type": CONTENT_TYPE, "Accept": CONTENT_TYPE },
49
- });
50
- if (!res.ok) throw new Error(`NWP /anchor failed: HTTP ${res.status}`);
51
- }
52
-
53
- async query(frame: QueryFrame): Promise<CapsFrame> {
54
- const wire = this._codec.encode(frame, { overrideTier: this._tier });
55
- const res = await fetch(`${this._baseUrl}/query`, {
56
- method: "POST",
57
- body: wire as BodyInit,
58
- headers: { "Content-Type": CONTENT_TYPE, "Accept": CONTENT_TYPE },
59
- });
60
- if (!res.ok) throw new Error(`NWP /query failed: HTTP ${res.status}`);
61
-
62
- const buf = new Uint8Array(await res.arrayBuffer());
63
- const result = this._codec.decode(buf);
64
- if (!(result instanceof CapsFrame)) {
65
- throw new TypeError(`Expected CapsFrame from /query, got ${result.constructor.name}.`);
66
- }
67
- return result;
68
- }
69
-
70
- async *stream(frame: QueryFrame): AsyncGenerator<StreamFrame> {
71
- const wire = this._codec.encode(frame, { overrideTier: this._tier });
72
- const res = await fetch(`${this._baseUrl}/stream`, {
73
- method: "POST",
74
- body: wire as BodyInit,
75
- headers: { "Content-Type": CONTENT_TYPE, "Accept": CONTENT_TYPE },
76
- });
77
- if (!res.ok) throw new Error(`NWP /stream failed: HTTP ${res.status}`);
78
- if (res.body === null) return;
79
-
80
- const { StreamFrame: SF } = await import("../ncp/frames.js");
81
-
82
- for await (const chunk of res.body) {
83
- const bytes = chunk instanceof Uint8Array ? chunk : new Uint8Array(chunk as ArrayBuffer);
84
- if (bytes.length === 0) continue;
85
- const result = this._codec.decode(bytes);
86
- if (!(result instanceof SF)) {
87
- throw new TypeError(`Expected StreamFrame from /stream, got ${result.constructor.name}.`);
88
- }
89
- yield result;
90
- if (result.isLast) break;
91
- }
92
- }
93
-
94
- async invoke(frame: ActionFrame): Promise<unknown> {
95
- const wire = this._codec.encode(frame, { overrideTier: this._tier });
96
- const res = await fetch(`${this._baseUrl}/invoke`, {
97
- method: "POST",
98
- body: wire as BodyInit,
99
- headers: { "Content-Type": CONTENT_TYPE, "Accept": CONTENT_TYPE },
100
- });
101
- if (!res.ok) throw new Error(`NWP /invoke failed: HTTP ${res.status}`);
102
-
103
- if (frame.async_) {
104
- return asyncActionResponseFromDict(await res.json() as Record<string, unknown>) as AsyncActionResponse;
105
- }
106
-
107
- const contentType = res.headers.get("content-type") ?? "";
108
- if (contentType.includes(CONTENT_TYPE)) {
109
- const buf = new Uint8Array(await res.arrayBuffer());
110
- return this._codec.decode(buf);
111
- }
112
- return res.json();
113
- }
114
- }