@labacacia/nps-sdk 1.0.0-alpha.1 → 1.0.0-alpha.3
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.
- package/CHANGELOG.cn.md +57 -0
- package/CHANGELOG.md +57 -0
- package/CONTRIBUTING.cn.md +35 -0
- package/CONTRIBUTING.md +2 -0
- package/README.cn.md +155 -0
- package/README.md +5 -3
- package/dist/core/anchor-cache.d.ts +0 -0
- package/dist/core/anchor-cache.d.ts.map +0 -0
- package/dist/core/cache.d.ts +0 -0
- package/dist/core/cache.d.ts.map +0 -0
- package/dist/core/canonical-json.d.ts +0 -0
- package/dist/core/canonical-json.d.ts.map +0 -0
- package/dist/core/codec.d.ts +0 -0
- package/dist/core/codec.d.ts.map +0 -0
- package/dist/core/codecs/index.d.ts +0 -0
- package/dist/core/codecs/index.d.ts.map +0 -0
- package/dist/core/codecs/ncp-codec.d.ts +0 -0
- package/dist/core/codecs/ncp-codec.d.ts.map +0 -0
- package/dist/core/codecs/tier1-json-codec.d.ts +0 -0
- package/dist/core/codecs/tier1-json-codec.d.ts.map +0 -0
- package/dist/core/codecs/tier2-msgpack-codec.d.ts +0 -0
- package/dist/core/codecs/tier2-msgpack-codec.d.ts.map +0 -0
- package/dist/core/crypto-provider.d.ts +0 -0
- package/dist/core/crypto-provider.d.ts.map +0 -0
- package/dist/core/exceptions.d.ts +0 -0
- package/dist/core/exceptions.d.ts.map +0 -0
- package/dist/core/frame-header.d.ts +0 -0
- package/dist/core/frame-header.d.ts.map +0 -0
- package/dist/core/frame-registry.d.ts +0 -0
- package/dist/core/frame-registry.d.ts.map +0 -0
- package/dist/core/frames.d.ts +1 -0
- package/dist/core/frames.d.ts.map +1 -1
- package/dist/core/index.cjs +90 -9
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.ts +6 -4
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +405 -9
- package/dist/core/index.js.map +1 -1
- package/dist/core/registry.d.ts +0 -0
- package/dist/core/registry.d.ts.map +0 -0
- package/dist/core/status-codes.d.ts +0 -0
- package/dist/core/status-codes.d.ts.map +0 -0
- package/dist/index.cjs +3 -1551
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -9
- package/dist/index.js.map +1 -1
- package/dist/ncp/frames/anchor-frame.d.ts +0 -0
- package/dist/ncp/frames/anchor-frame.d.ts.map +0 -0
- package/dist/ncp/frames/caps-frame.d.ts +0 -0
- package/dist/ncp/frames/caps-frame.d.ts.map +0 -0
- package/dist/ncp/frames/diff-frame.d.ts +0 -0
- package/dist/ncp/frames/diff-frame.d.ts.map +0 -0
- package/dist/ncp/frames/error-frame.d.ts +0 -0
- package/dist/ncp/frames/error-frame.d.ts.map +0 -0
- package/dist/ncp/frames/hello-frame.d.ts +0 -0
- package/dist/ncp/frames/hello-frame.d.ts.map +0 -0
- package/dist/ncp/frames/stream-frame.d.ts +0 -0
- package/dist/ncp/frames/stream-frame.d.ts.map +0 -0
- package/dist/ncp/frames.d.ts +18 -0
- package/dist/ncp/frames.d.ts.map +1 -1
- package/dist/ncp/handshake.d.ts +0 -0
- package/dist/ncp/handshake.d.ts.map +0 -0
- package/dist/ncp/index.cjs +364 -164
- package/dist/ncp/index.cjs.map +1 -1
- package/dist/ncp/index.d.ts +0 -0
- package/dist/ncp/index.d.ts.map +0 -0
- package/dist/ncp/index.js +368 -12
- package/dist/ncp/index.js.map +1 -1
- package/dist/ncp/ncp-error-codes.d.ts +0 -0
- package/dist/ncp/ncp-error-codes.d.ts.map +0 -0
- package/dist/ncp/ncp-patch-format.d.ts +0 -0
- package/dist/ncp/ncp-patch-format.d.ts.map +0 -0
- package/dist/ncp/registry.d.ts +0 -0
- package/dist/ncp/registry.d.ts.map +1 -1
- package/dist/ncp/stream-manager.d.ts +0 -0
- package/dist/ncp/stream-manager.d.ts.map +0 -0
- package/dist/ndp/frames.d.ts +0 -0
- package/dist/ndp/frames.d.ts.map +0 -0
- package/dist/ndp/index.cjs +0 -0
- package/dist/ndp/index.cjs.map +0 -0
- package/dist/ndp/index.d.ts +0 -0
- package/dist/ndp/index.d.ts.map +0 -0
- package/dist/ndp/index.js +223 -6
- package/dist/ndp/index.js.map +1 -1
- package/dist/ndp/ndp-registry.d.ts +0 -0
- package/dist/ndp/ndp-registry.d.ts.map +0 -0
- package/dist/ndp/registry.d.ts +0 -0
- package/dist/ndp/registry.d.ts.map +0 -0
- package/dist/ndp/validator.d.ts +0 -0
- package/dist/ndp/validator.d.ts.map +0 -0
- package/dist/nip/frames.d.ts +0 -0
- package/dist/nip/frames.d.ts.map +0 -0
- package/dist/nip/identity.d.ts +0 -0
- package/dist/nip/identity.d.ts.map +0 -0
- package/dist/nip/index.cjs +0 -0
- package/dist/nip/index.cjs.map +0 -0
- package/dist/nip/index.d.ts +0 -0
- package/dist/nip/index.d.ts.map +0 -0
- package/dist/nip/index.js +187 -5
- package/dist/nip/index.js.map +1 -1
- package/dist/nip/registry.d.ts +0 -0
- package/dist/nip/registry.d.ts.map +0 -0
- package/dist/nop/client.d.ts +0 -0
- package/dist/nop/client.d.ts.map +0 -0
- package/dist/nop/frames.d.ts +0 -0
- package/dist/nop/frames.d.ts.map +0 -0
- package/dist/nop/index.cjs +62 -1
- package/dist/nop/index.cjs.map +1 -1
- package/dist/nop/index.d.ts +0 -0
- package/dist/nop/index.d.ts.map +0 -0
- package/dist/nop/index.js +789 -6
- package/dist/nop/index.js.map +1 -1
- package/dist/nop/models.d.ts +0 -0
- package/dist/nop/models.d.ts.map +0 -0
- package/dist/nop/nop-types.d.ts +0 -0
- package/dist/nop/nop-types.d.ts.map +0 -0
- package/dist/nop/registry.d.ts +0 -0
- package/dist/nop/registry.d.ts.map +0 -0
- package/dist/nwp/client.d.ts +0 -0
- package/dist/nwp/client.d.ts.map +0 -0
- package/dist/nwp/frames.d.ts +0 -0
- package/dist/nwp/frames.d.ts.map +0 -0
- package/dist/nwp/index.cjs +64 -2
- package/dist/nwp/index.cjs.map +1 -1
- package/dist/nwp/index.d.ts +0 -0
- package/dist/nwp/index.d.ts.map +0 -0
- package/dist/nwp/index.js +693 -5
- package/dist/nwp/index.js.map +1 -1
- package/dist/nwp/registry.d.ts +0 -0
- package/dist/nwp/registry.d.ts.map +0 -0
- package/dist/setup.d.ts +0 -0
- package/dist/setup.d.ts.map +0 -0
- package/doc/nps-sdk.core.cn.md +321 -0
- package/doc/nps-sdk.core.md +326 -0
- package/doc/nps-sdk.ncp.cn.md +270 -0
- package/doc/nps-sdk.ncp.md +276 -0
- package/doc/nps-sdk.ndp.cn.md +267 -0
- package/doc/nps-sdk.ndp.md +273 -0
- package/doc/nps-sdk.nip.cn.md +235 -0
- package/doc/nps-sdk.nip.md +242 -0
- package/doc/nps-sdk.nop.cn.md +329 -0
- package/doc/nps-sdk.nop.md +332 -0
- package/doc/nps-sdk.nwp.cn.md +217 -0
- package/doc/nps-sdk.nwp.md +224 -0
- package/doc/overview.cn.md +149 -0
- package/doc/overview.md +153 -0
- package/package.json +21 -4
- package/src/core/frames.ts +1 -0
- package/src/core/index.ts +37 -5
- package/src/index.ts +1 -1
- package/src/ncp/frames.ts +52 -0
- package/src/ncp/registry.ts +2 -1
- package/dist/codec-CmHeovTV.d.cts +0 -120
- package/dist/codec-CmHeovTV.d.ts +0 -120
- package/dist/core/anchor-cache.js +0 -104
- package/dist/core/anchor-cache.js.map +0 -1
- package/dist/core/cache.js +0 -80
- package/dist/core/cache.js.map +0 -1
- package/dist/core/canonical-json.js +0 -44
- package/dist/core/canonical-json.js.map +0 -1
- package/dist/core/codec.js +0 -119
- package/dist/core/codec.js.map +0 -1
- package/dist/core/codecs/index.js +0 -6
- package/dist/core/codecs/index.js.map +0 -1
- package/dist/core/codecs/ncp-codec.js +0 -93
- package/dist/core/codecs/ncp-codec.js.map +0 -1
- package/dist/core/codecs/tier1-json-codec.js +0 -28
- package/dist/core/codecs/tier1-json-codec.js.map +0 -1
- package/dist/core/codecs/tier2-msgpack-codec.js +0 -26
- package/dist/core/codecs/tier2-msgpack-codec.js.map +0 -1
- package/dist/core/crypto-provider.js +0 -10
- package/dist/core/crypto-provider.js.map +0 -1
- package/dist/core/exceptions.js +0 -52
- package/dist/core/exceptions.js.map +0 -1
- package/dist/core/frame-header.js +0 -185
- package/dist/core/frame-header.js.map +0 -1
- package/dist/core/frame-registry.js +0 -63
- package/dist/core/frame-registry.js.map +0 -1
- package/dist/core/frames.js +0 -153
- package/dist/core/frames.js.map +0 -1
- package/dist/core/index.d.cts +0 -41
- package/dist/core/registry.js +0 -17
- package/dist/core/registry.js.map +0 -1
- package/dist/core/status-codes.js +0 -38
- package/dist/core/status-codes.js.map +0 -1
- package/dist/frames-B3qLdl_g.d.cts +0 -77
- package/dist/frames-Ff7-ZPUl.d.ts +0 -77
- package/dist/index.d.cts +0 -21
- package/dist/ncp/frames/anchor-frame.js +0 -54
- package/dist/ncp/frames/anchor-frame.js.map +0 -1
- package/dist/ncp/frames/caps-frame.js +0 -29
- package/dist/ncp/frames/caps-frame.js.map +0 -1
- package/dist/ncp/frames/diff-frame.js +0 -37
- package/dist/ncp/frames/diff-frame.js.map +0 -1
- package/dist/ncp/frames/error-frame.js +0 -13
- package/dist/ncp/frames/error-frame.js.map +0 -1
- package/dist/ncp/frames/hello-frame.js +0 -25
- package/dist/ncp/frames/hello-frame.js.map +0 -1
- package/dist/ncp/frames/stream-frame.js +0 -18
- package/dist/ncp/frames/stream-frame.js.map +0 -1
- package/dist/ncp/frames.js +0 -147
- package/dist/ncp/frames.js.map +0 -1
- package/dist/ncp/handshake.js +0 -80
- package/dist/ncp/handshake.js.map +0 -1
- package/dist/ncp/index.d.cts +0 -6
- package/dist/ncp/ncp-error-codes.js +0 -32
- package/dist/ncp/ncp-error-codes.js.map +0 -1
- package/dist/ncp/ncp-patch-format.js +0 -13
- package/dist/ncp/ncp-patch-format.js.map +0 -1
- package/dist/ncp/registry.js +0 -12
- package/dist/ncp/registry.js.map +0 -1
- package/dist/ncp/stream-manager.js +0 -163
- package/dist/ncp/stream-manager.js.map +0 -1
- package/dist/ndp/frames.js +0 -87
- package/dist/ndp/frames.js.map +0 -1
- package/dist/ndp/index.d.cts +0 -86
- package/dist/ndp/ndp-registry.js +0 -79
- package/dist/ndp/ndp-registry.js.map +0 -1
- package/dist/ndp/registry.js +0 -10
- package/dist/ndp/registry.js.map +0 -1
- package/dist/ndp/validator.js +0 -48
- package/dist/ndp/validator.js.map +0 -1
- package/dist/nip/frames.js +0 -81
- package/dist/nip/frames.js.map +0 -1
- package/dist/nip/identity.js +0 -94
- package/dist/nip/identity.js.map +0 -1
- package/dist/nip/index.d.cts +0 -65
- package/dist/nip/registry.js +0 -10
- package/dist/nip/registry.js.map +0 -1
- package/dist/nop/client.js +0 -90
- package/dist/nop/client.js.map +0 -1
- package/dist/nop/frames.js +0 -148
- package/dist/nop/frames.js.map +0 -1
- package/dist/nop/index.d.cts +0 -155
- package/dist/nop/models.js +0 -50
- package/dist/nop/models.js.map +0 -1
- package/dist/nop/nop-types.js +0 -44
- package/dist/nop/nop-types.js.map +0 -1
- package/dist/nop/registry.js +0 -11
- package/dist/nop/registry.js.map +0 -1
- package/dist/nwp/client.js +0 -101
- package/dist/nwp/client.js.map +0 -1
- package/dist/nwp/frames.js +0 -81
- package/dist/nwp/frames.js.map +0 -1
- package/dist/nwp/index.d.cts +0 -65
- package/dist/nwp/registry.js +0 -9
- package/dist/nwp/registry.js.map +0 -1
- package/dist/setup.js +0 -29
- package/dist/setup.js.map +0 -1
package/CHANGELOG.cn.md
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
[English Version](./CHANGELOG.md) | 中文版
|
|
2
|
+
|
|
3
|
+
# 变更日志 —— TypeScript SDK (`@labacacia/nps-sdk`)
|
|
4
|
+
|
|
5
|
+
格式参考 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.1.0/),版本号遵循 [语义化版本](https://semver.org/lang/zh-CN/)。
|
|
6
|
+
|
|
7
|
+
在 NPS 达到 v1.0 稳定版之前,套件内所有仓库同步使用同一个预发布版本号。
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## [1.0.0-alpha.3] —— 2026-04-25
|
|
12
|
+
|
|
13
|
+
### Changed
|
|
14
|
+
|
|
15
|
+
- 版本升级至 `1.0.0-alpha.3`,与 NPS `v1.0.0-alpha.3` 套件同步。本次 TypeScript SDK 无功能变更。
|
|
16
|
+
- 264 tests, ≥98% 覆盖率仍全绿。
|
|
17
|
+
|
|
18
|
+
### 套件级 alpha.3 要点(各语言 helper 在 alpha.4 跟进)
|
|
19
|
+
|
|
20
|
+
- **NPS-RFC-0001 —— NCP 连接前导**(Accepted)。原生模式连接现以字面量 `b"NPS/1.0\n"`(8 字节)开头。.NET SDK 已落地参考实现;TypeScript helper 在 alpha.4 跟进。
|
|
21
|
+
- **NPS-RFC-0003 —— Agent 身份保证等级**(Accepted)。NIP IdentFrame 与 NWM 新增三态 `assurance_level`(`anonymous`/`attested`/`verified`)。.NET 参考类型已落地;TypeScript 同步在 alpha.4。
|
|
22
|
+
- **NPS-RFC-0004 —— NID 声誉日志(CT 风格)**(Accepted)。append-only Merkle 日志条目结构发布;.NET 参考签名器已落地(并以 `nps-ledger` daemon Phase 1 形态发布)。TypeScript helper 在 alpha.4 跟进。
|
|
23
|
+
- **NPS-CR-0001 —— Anchor / Bridge 节点拆分。** 旧的 "Gateway Node" 角色更名为 **Anchor Node**;"NPS↔外部协议翻译" 单独成为 **Bridge Node** 类型。AnnounceFrame 新增 `node_kind` / `cluster_anchor` / `bridge_protocols`。源代码层面变更落在 `spec/` + .NET 参考实现。
|
|
24
|
+
- **6 个 NPS 常驻 daemon。** NPS-Dev 新建 `daemons/` 目录,定义 `npsd` / `nps-runner` / `nps-gateway` / `nps-registry` / `nps-cloud-ca` / `nps-ledger`;其中 `npsd` 提供 L1 功能性参考实现,其余为 Phase 1 骨架。
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## [1.0.0-alpha.2] —— 2026-04-19
|
|
29
|
+
|
|
30
|
+
### Fixed
|
|
31
|
+
|
|
32
|
+
- **`NpsFrameCodec is not a constructor`** —— `src/core/index.ts` 现显式从 `./codec.js`、`./registry.js`、`./cache.js` 重新导出随包提供的 OOP API(`NpsFrameCodec`、`Tier1JsonCodec`、`Tier2MsgPackCodec`、`FrameRegistry`、`AnchorFrameCache`)。`./codecs/` 下的并行函数式 API 仍可通过直接路径导入,但不再自动导出(与类 API 在 `FrameType` / `EncodingTier` / `FrameHeader` 上冲突)。
|
|
33
|
+
- **缺失的 Ed25519 运行时依赖** —— `@noble/ed25519` 和 `@noble/hashes` 现已声明为运行时依赖。此前已被 `src/nip/identity.ts` 和 `src/ndp/validator.ts` import 但 `package.json` 未声明,导致 npm 消费者安装失败。
|
|
34
|
+
|
|
35
|
+
### Added
|
|
36
|
+
|
|
37
|
+
- **HelloFrame(NCP 0x06)** —— `src/ncp/frames.ts` 新增 `HelloFrame` 类(snake_case toDict/fromDict),在 `ncp/registry.ts` 中注册。`FrameType.HELLO = 0x06` 加入枚举。
|
|
38
|
+
- **subpath exports** —— `package.json` 的 `exports` 映射新增 `./nwp`、`./nip`、`./ndp`、`./nop`(此前仅声明 `.`、`./core`、`./ncp`,但 README 已示例使用全部六个)。
|
|
39
|
+
|
|
40
|
+
### Changed
|
|
41
|
+
|
|
42
|
+
- Node 引擎要求升级到 `>=22.0.0`。
|
|
43
|
+
- 264 测试全绿(此前为 158 通过 + 5 个文件失败 + 1 个测试失败)。
|
|
44
|
+
|
|
45
|
+
### 涵盖模块
|
|
46
|
+
|
|
47
|
+
- core / ncp / nwp / nip / ndp / nop
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## [1.0.0-alpha.1] —— 2026-04-10
|
|
52
|
+
|
|
53
|
+
作为 NPS 套件 `v1.0.0-alpha.1` 的一部分首次公开 alpha。
|
|
54
|
+
|
|
55
|
+
[1.0.0-alpha.3]: https://github.com/LabAcacia/NPS-Dev/releases/tag/v1.0.0-alpha.3
|
|
56
|
+
[1.0.0-alpha.2]: https://github.com/LabAcacia/NPS-Dev/releases/tag/v1.0.0-alpha.2
|
|
57
|
+
[1.0.0-alpha.1]: https://github.com/LabAcacia/NPS-Dev/releases/tag/v1.0.0-alpha.1
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
English | [中文版](./CHANGELOG.cn.md)
|
|
2
|
+
|
|
3
|
+
# Changelog — TypeScript SDK (`@labacacia/nps-sdk`)
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
|
+
|
|
7
|
+
Until NPS reaches v1.0 stable, every repository in the suite is synchronized to the same pre-release version tag.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## [1.0.0-alpha.3] — 2026-04-25
|
|
12
|
+
|
|
13
|
+
### Changed
|
|
14
|
+
|
|
15
|
+
- Version bump to `1.0.0-alpha.3` for suite-wide synchronization with the NPS `v1.0.0-alpha.3` release. No functional changes in the TypeScript SDK at this milestone.
|
|
16
|
+
- 264 tests, ≥98% coverage still green.
|
|
17
|
+
|
|
18
|
+
### Suite-wide highlights at alpha.3 (per-language helpers planned for alpha.4)
|
|
19
|
+
|
|
20
|
+
- **NPS-RFC-0001 — NCP connection preamble** (Accepted). Native-mode connections now begin with the literal `b"NPS/1.0\n"` (8 bytes). Reference helper landed in the .NET SDK; TypeScript helper deferred to alpha.4.
|
|
21
|
+
- **NPS-RFC-0003 — Agent identity assurance levels** (Accepted). NIP IdentFrame and NWM gain a tri-state `assurance_level` (`anonymous`/`attested`/`verified`). Reference types landed in .NET; TypeScript parity deferred to alpha.4.
|
|
22
|
+
- **NPS-RFC-0004 — NID reputation log (CT-style)** (Accepted). Append-only Merkle log entry shape published; reference signer landed in .NET (and shipped as the `nps-ledger` daemon Phase 1). TypeScript helpers deferred to alpha.4.
|
|
23
|
+
- **NPS-CR-0001 — Anchor / Bridge node split.** The legacy "Gateway Node" role is renamed to **Anchor Node**; the "translate NPS↔external protocol" role is now its own **Bridge Node** type. AnnounceFrame gained `node_kind` / `cluster_anchor` / `bridge_protocols`. Source-of-truth changes are in `spec/` + the .NET reference implementation.
|
|
24
|
+
- **6 NPS resident daemons.** New `daemons/` tree in NPS-Dev defines `npsd` / `nps-runner` / `nps-gateway` / `nps-registry` / `nps-cloud-ca` / `nps-ledger`; `npsd` ships an L1-functional reference and the rest ship as Phase 1 skeletons.
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## [1.0.0-alpha.2] — 2026-04-19
|
|
29
|
+
|
|
30
|
+
### Fixed
|
|
31
|
+
|
|
32
|
+
- **`NpsFrameCodec is not a constructor`** — `src/core/index.ts` now explicitly re-exports the shipped OOP API (`NpsFrameCodec`, `Tier1JsonCodec`, `Tier2MsgPackCodec`, `FrameRegistry`, `AnchorFrameCache`) from `./codec.js`, `./registry.js`, `./cache.js`. The parallel functional API under `./codecs/` remains reachable by direct path but is no longer auto-exported (it collided on `FrameType` / `EncodingTier` / `FrameHeader`).
|
|
33
|
+
- **Missing Ed25519 runtime deps** — `@noble/ed25519` and `@noble/hashes` are now declared as runtime dependencies. Previously imported by `src/nip/identity.ts` and `src/ndp/validator.ts` but not listed in `package.json`, causing install failures for npm consumers.
|
|
34
|
+
|
|
35
|
+
### Added
|
|
36
|
+
|
|
37
|
+
- **HelloFrame (NCP 0x06)** — new `HelloFrame` class in `src/ncp/frames.ts` with snake_case toDict/fromDict, registered in `ncp/registry.ts`. `FrameType.HELLO = 0x06` added to the enum.
|
|
38
|
+
- **Subpath exports** — `package.json` `exports` map now includes `./nwp`, `./nip`, `./ndp`, `./nop` (previously only `.`, `./core`, `./ncp` were declared even though README documented all six).
|
|
39
|
+
|
|
40
|
+
### Changed
|
|
41
|
+
|
|
42
|
+
- Node engine requirement raised to `>=22.0.0`.
|
|
43
|
+
- 264 tests green (up from 158 previously passing + 5 file failures + 1 test failure).
|
|
44
|
+
|
|
45
|
+
### Covered modules
|
|
46
|
+
|
|
47
|
+
- core / ncp / nwp / nip / ndp / nop
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## [1.0.0-alpha.1] — 2026-04-10
|
|
52
|
+
|
|
53
|
+
First public alpha as part of the NPS suite `v1.0.0-alpha.1` release.
|
|
54
|
+
|
|
55
|
+
[1.0.0-alpha.3]: https://github.com/LabAcacia/NPS-Dev/releases/tag/v1.0.0-alpha.3
|
|
56
|
+
[1.0.0-alpha.2]: https://github.com/LabAcacia/NPS-Dev/releases/tag/v1.0.0-alpha.2
|
|
57
|
+
[1.0.0-alpha.1]: https://github.com/LabAcacia/NPS-Dev/releases/tag/v1.0.0-alpha.1
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
[English Version](./CONTRIBUTING.md) | 中文版
|
|
2
|
+
|
|
3
|
+
# 为 NPS 贡献代码
|
|
4
|
+
|
|
5
|
+
感谢你有兴趣为 Neural Protocol Suite 做出贡献。
|
|
6
|
+
|
|
7
|
+
## Issue 前缀
|
|
8
|
+
|
|
9
|
+
| 前缀 | 用途 |
|
|
10
|
+
|------|------|
|
|
11
|
+
| `spec:` | 规范问题与设计讨论 |
|
|
12
|
+
| `impl:` | 实现 Bug 与修复 |
|
|
13
|
+
| `sdk:` | SDK 相关(Python / TypeScript 等) |
|
|
14
|
+
| `docs:` | 文档改进 |
|
|
15
|
+
|
|
16
|
+
## 工作流
|
|
17
|
+
|
|
18
|
+
1. 任何非平凡的变更先开 Issue
|
|
19
|
+
2. Fork 仓库并创建分支:`feature/your-feature` 或 `fix/your-fix`
|
|
20
|
+
3. 提交 Pull Request 并关联对应的 Issue
|
|
21
|
+
|
|
22
|
+
## 规范变更
|
|
23
|
+
|
|
24
|
+
对 `spec/` 目录下文件的变更必须先开讨论 Issue 才能接受 PR。
|
|
25
|
+
涉及线缆格式或帧结构的规范变更必须同时做版本号升级。
|
|
26
|
+
|
|
27
|
+
## 代码风格
|
|
28
|
+
|
|
29
|
+
- **C# / .NET**:遵循 Microsoft 标准 C# 约定,开启 Nullable
|
|
30
|
+
- **Python**:PEP 8,必须带类型标注
|
|
31
|
+
- **TypeScript**:开启严格模式
|
|
32
|
+
|
|
33
|
+
## 许可证
|
|
34
|
+
|
|
35
|
+
一旦提交贡献,你即同意贡献内容按 Apache 2.0 许可证授权。
|
package/CONTRIBUTING.md
CHANGED
package/README.cn.md
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
[English Version](./README.md) | 中文版
|
|
2
|
+
|
|
3
|
+
# @labacacia/nps-sdk — TypeScript / Node.js
|
|
4
|
+
|
|
5
|
+
面向 **Neural Protocol Suite (NPS)** 的 TypeScript SDK —— 为 AI Agent 设计的协议族。
|
|
6
|
+
属 [LabAcacia](https://github.com/LabAcacia) / INNO LOTUS PTY LTD 开源生态。
|
|
7
|
+
|
|
8
|
+
## 状态
|
|
9
|
+
|
|
10
|
+
**v1.0.0-alpha.3 — Phase 2** · 5 个协议 · 264 个测试 · 覆盖率 ≥ 98%
|
|
11
|
+
|
|
12
|
+
| 协议 | 类 | 状态 |
|
|
13
|
+
|------|----|------|
|
|
14
|
+
| NCP — Neural Communication Protocol | 帧、编解码器 | ✅ |
|
|
15
|
+
| NWP — Neural Web Protocol | `NwpClient` | ✅ |
|
|
16
|
+
| NIP — Neural Identity Protocol | `NipIdentity` | ✅ |
|
|
17
|
+
| NDP — Neural Discovery Protocol | `InMemoryNdpRegistry`、`NdpAnnounceValidator` | ✅ |
|
|
18
|
+
| NOP — Neural Orchestration Protocol | `NopClient` | ✅ |
|
|
19
|
+
|
|
20
|
+
## 安装
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npm install @labacacia/nps-sdk
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
> **对等依赖:** Node.js 22+
|
|
27
|
+
|
|
28
|
+
## 快速开始
|
|
29
|
+
|
|
30
|
+
### NWP —— 查询节点
|
|
31
|
+
|
|
32
|
+
```typescript
|
|
33
|
+
import { NwpClient, QueryFrame } from "@labacacia/nps-sdk/nwp";
|
|
34
|
+
|
|
35
|
+
const client = new NwpClient("http://node.example.com:17433");
|
|
36
|
+
const caps = await client.query(new QueryFrame("sha256:<anchor-id>", { active: true }, 20));
|
|
37
|
+
console.log(caps.count, caps.data);
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### NWP —— 流式结果
|
|
41
|
+
|
|
42
|
+
```typescript
|
|
43
|
+
for await (const chunk of client.stream(new QueryFrame("sha256:<anchor-id>"))) {
|
|
44
|
+
console.log(chunk.seq, chunk.data);
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### NWP —— 调用 Action
|
|
49
|
+
|
|
50
|
+
```typescript
|
|
51
|
+
import { ActionFrame } from "@labacacia/nps-sdk/nwp";
|
|
52
|
+
|
|
53
|
+
const result = await client.invoke(new ActionFrame("summarise", { maxTokens: 500 }));
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### NIP —— Ed25519 身份
|
|
57
|
+
|
|
58
|
+
```typescript
|
|
59
|
+
import { NipIdentity } from "@labacacia/nps-sdk/nip";
|
|
60
|
+
|
|
61
|
+
// 生成并持久化
|
|
62
|
+
const id = NipIdentity.generate();
|
|
63
|
+
id.save("./my-key.json", process.env.KEY_PASS!);
|
|
64
|
+
|
|
65
|
+
// 加载并签名
|
|
66
|
+
const loaded = NipIdentity.load("./my-key.json", process.env.KEY_PASS!);
|
|
67
|
+
const sig = loaded.sign({ action: "announce", nid: "urn:nps:node:example.com:data" });
|
|
68
|
+
const ok = loaded.verify({ action: "announce", nid: "urn:nps:node:example.com:data" }, sig);
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### NDP —— 注册表和签名校验
|
|
72
|
+
|
|
73
|
+
```typescript
|
|
74
|
+
import { InMemoryNdpRegistry, NdpAnnounceValidator } from "@labacacia/nps-sdk/ndp";
|
|
75
|
+
import { AnnounceFrame } from "@labacacia/nps-sdk/ndp";
|
|
76
|
+
|
|
77
|
+
const registry = new InMemoryNdpRegistry();
|
|
78
|
+
const validator = new NdpAnnounceValidator();
|
|
79
|
+
validator.registerPublicKey(nid, identity.pubKeyString);
|
|
80
|
+
|
|
81
|
+
registry.announce(frame);
|
|
82
|
+
const resolved = registry.resolve("nwp://example.com/data/items");
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### NOP —— 提交并等待任务
|
|
86
|
+
|
|
87
|
+
```typescript
|
|
88
|
+
import { NopClient, TaskFrame } from "@labacacia/nps-sdk/nop";
|
|
89
|
+
|
|
90
|
+
const client = new NopClient("http://orchestrator.example.com:17433");
|
|
91
|
+
const dag = {
|
|
92
|
+
nodes: [{ id: "classify", action: "classify-text", agent: "urn:nps:node:ml.example.com:classifier" }],
|
|
93
|
+
edges: [],
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
const taskId = await client.submit(new TaskFrame("my-task-1", dag));
|
|
97
|
+
const status = await client.wait(taskId, { timeoutMs: 30_000 });
|
|
98
|
+
console.log(status.state, status.aggregatedResult);
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## 包导出
|
|
102
|
+
|
|
103
|
+
```typescript
|
|
104
|
+
import { ... } from "@labacacia/nps-sdk"; // 全部
|
|
105
|
+
import { ... } from "@labacacia/nps-sdk/core"; // codec、帧、registry、cache
|
|
106
|
+
import { ... } from "@labacacia/nps-sdk/ncp"; // AnchorFrame、CapsFrame、StreamFrame、HelloFrame、…
|
|
107
|
+
import { ... } from "@labacacia/nps-sdk/nwp"; // NwpClient、QueryFrame、ActionFrame
|
|
108
|
+
import { ... } from "@labacacia/nps-sdk/nip"; // NipIdentity、IdentFrame、TrustFrame、RevokeFrame
|
|
109
|
+
import { ... } from "@labacacia/nps-sdk/ndp"; // InMemoryNdpRegistry、NdpAnnounceValidator、AnnounceFrame、…
|
|
110
|
+
import { ... } from "@labacacia/nps-sdk/nop"; // NopClient、NopTaskStatus、TaskFrame、…
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## NCP 编解码
|
|
114
|
+
|
|
115
|
+
编解码层支持双 Tier 编码和对线上字节的直接操作:
|
|
116
|
+
|
|
117
|
+
```typescript
|
|
118
|
+
import { NpsFrameCodec, EncodingTier } from "@labacacia/nps-sdk/core";
|
|
119
|
+
import { createDefaultRegistry } from "@labacacia/nps-sdk";
|
|
120
|
+
|
|
121
|
+
const codec = new NpsFrameCodec(createDefaultRegistry());
|
|
122
|
+
|
|
123
|
+
// 编码(默认 MsgPack)
|
|
124
|
+
const wire = codec.encode(frame);
|
|
125
|
+
|
|
126
|
+
// 编码为 JSON(调试 / 互操作)
|
|
127
|
+
const json = codec.encode(frame, { overrideTier: EncodingTier.JSON });
|
|
128
|
+
|
|
129
|
+
// 解码
|
|
130
|
+
const decoded = codec.decode(wire);
|
|
131
|
+
|
|
132
|
+
// 仅读取帧头,不解码 payload
|
|
133
|
+
const header = NpsFrameCodec.peekHeader(wire);
|
|
134
|
+
console.log(header.frameType, header.isExtended, header.payloadLength);
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
## 开发
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
# 安装
|
|
141
|
+
npm install
|
|
142
|
+
|
|
143
|
+
# 测试
|
|
144
|
+
npm test
|
|
145
|
+
|
|
146
|
+
# 测试 + 覆盖率
|
|
147
|
+
npm run test -- --coverage
|
|
148
|
+
|
|
149
|
+
# 构建(ESM + CJS)
|
|
150
|
+
npm run build
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## 许可证
|
|
154
|
+
|
|
155
|
+
Apache 2.0 —— 详见 [LICENSE](../../LICENSE)。
|
package/README.md
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
English | [中文版](./README.cn.md)
|
|
2
|
+
|
|
1
3
|
# @labacacia/nps-sdk — TypeScript / Node.js
|
|
2
4
|
|
|
3
5
|
TypeScript SDK for the **Neural Protocol Suite** (NPS) — a protocol suite designed for AI Agents.
|
|
@@ -5,7 +7,7 @@ Part of the [LabAcacia](https://github.com/LabAcacia) / INNO LOTUS PTY LTD open-
|
|
|
5
7
|
|
|
6
8
|
## Status
|
|
7
9
|
|
|
8
|
-
**
|
|
10
|
+
**v1.0.0-alpha.3 — Phase 2** · 5 protocols · 264 tests · ≥ 98% coverage
|
|
9
11
|
|
|
10
12
|
| Protocol | Class | Status |
|
|
11
13
|
|----------|-------|--------|
|
|
@@ -21,7 +23,7 @@ Part of the [LabAcacia](https://github.com/LabAcacia) / INNO LOTUS PTY LTD open-
|
|
|
21
23
|
npm install @labacacia/nps-sdk
|
|
22
24
|
```
|
|
23
25
|
|
|
24
|
-
> **Peer requirement:** Node.js
|
|
26
|
+
> **Peer requirement:** Node.js 22+
|
|
25
27
|
|
|
26
28
|
## Quick Start
|
|
27
29
|
|
|
@@ -101,7 +103,7 @@ console.log(status.state, status.aggregatedResult);
|
|
|
101
103
|
```typescript
|
|
102
104
|
import { ... } from "@labacacia/nps-sdk"; // everything
|
|
103
105
|
import { ... } from "@labacacia/nps-sdk/core"; // codec, frames, registry, cache
|
|
104
|
-
import { ... } from "@labacacia/nps-sdk/ncp"; // AnchorFrame, CapsFrame, StreamFrame, …
|
|
106
|
+
import { ... } from "@labacacia/nps-sdk/ncp"; // AnchorFrame, CapsFrame, StreamFrame, HelloFrame, …
|
|
105
107
|
import { ... } from "@labacacia/nps-sdk/nwp"; // NwpClient, QueryFrame, ActionFrame
|
|
106
108
|
import { ... } from "@labacacia/nps-sdk/nip"; // NipIdentity, IdentFrame, TrustFrame, RevokeFrame
|
|
107
109
|
import { ... } from "@labacacia/nps-sdk/ndp"; // InMemoryNdpRegistry, NdpAnnounceValidator, AnnounceFrame, …
|
|
File without changes
|
|
File without changes
|
package/dist/core/cache.d.ts
CHANGED
|
File without changes
|
package/dist/core/cache.d.ts.map
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/dist/core/codec.d.ts
CHANGED
|
File without changes
|
package/dist/core/codec.d.ts.map
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/dist/core/frames.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"frames.d.ts","sourceRoot":"","sources":["../../src/core/frames.ts"],"names":[],"mappings":"AAWA,sEAAsE;AACtE,oBAAY,SAAS;IAEnB,MAAM,IAAa;IACnB,IAAI,IAAe;IACnB,MAAM,IAAa;IACnB,IAAI,IAAe;IACnB,KAAK,IAAc,CAAE,sCAAsC;
|
|
1
|
+
{"version":3,"file":"frames.d.ts","sourceRoot":"","sources":["../../src/core/frames.ts"],"names":[],"mappings":"AAWA,sEAAsE;AACtE,oBAAY,SAAS;IAEnB,MAAM,IAAa;IACnB,IAAI,IAAe;IACnB,MAAM,IAAa;IACnB,IAAI,IAAe;IACnB,KAAK,IAAc,CAAE,sCAAsC;IAC3D,KAAK,IAAc;IAGnB,KAAK,KAAc;IACnB,MAAM,KAAa;IAGnB,KAAK,KAAc;IACnB,KAAK,KAAc;IACnB,MAAM,KAAa;IAGnB,QAAQ,KAAW;IACnB,OAAO,KAAY;IACnB,KAAK,KAAc;IAGnB,IAAI,KAAe;IACnB,QAAQ,KAAW;IACnB,IAAI,KAAe;IACnB,YAAY,KAAO;IAGnB,KAAK,MAAc;CACpB;AAID;;;;GAIG;AACH,oBAAY,YAAY;IACtB,IAAI,IAAU;IACd,OAAO,IAAO;CACf;AAID;;;;;;;;GAQG;AACH,eAAO,MAAM,UAAU;;;;;;;CAOb,CAAC;AAIX,eAAO,MAAM,mBAAmB,IAAK,CAAC;AACtC,eAAO,MAAM,oBAAoB,IAAI,CAAC;AACtC,eAAO,MAAM,mBAAmB,QAAU,CAAC;AAC3C,eAAO,MAAM,oBAAoB,aAAa,CAAC;AAI/C;;;;;;;;;;;;;GAaG;AACH,qBAAa,WAAW;aAEJ,SAAS,EAAE,SAAS;aACpB,KAAK,EAAE,MAAM;aACb,aAAa,EAAE,MAAM;gBAFrB,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,MAAM,EACb,aAAa,EAAE,MAAM;IAGvC,IAAI,UAAU,IAAI,OAAO,CAExB;IAED,IAAI,UAAU,IAAI,MAAM,CAEvB;IAED,IAAI,YAAY,IAAI,YAAY,CAE/B;IAED,IAAI,OAAO,IAAI,OAAO,CAErB;IAED,IAAI,WAAW,IAAI,OAAO,CAEzB;IAID,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,UAAU,GAAG,WAAW;IAiC1C,OAAO,IAAI,UAAU;IAkBrB,QAAQ,IAAI,MAAM;CAGnB"}
|
package/dist/core/index.cjs
CHANGED
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
var msgpack = require('@msgpack/msgpack');
|
|
4
4
|
var crypto = require('crypto');
|
|
5
|
+
var canonicalizeImport = require('canonicalize');
|
|
6
|
+
|
|
7
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
5
8
|
|
|
6
9
|
function _interopNamespace(e) {
|
|
7
10
|
if (e && e.__esModule) return e;
|
|
@@ -22,33 +25,48 @@ function _interopNamespace(e) {
|
|
|
22
25
|
}
|
|
23
26
|
|
|
24
27
|
var msgpack__namespace = /*#__PURE__*/_interopNamespace(msgpack);
|
|
28
|
+
var canonicalizeImport__default = /*#__PURE__*/_interopDefault(canonicalizeImport);
|
|
25
29
|
|
|
26
30
|
// src/core/exceptions.ts
|
|
27
31
|
var NpsError = class extends Error {
|
|
28
32
|
constructor(message) {
|
|
29
33
|
super(message);
|
|
30
|
-
this.name =
|
|
34
|
+
this.name = "NpsError";
|
|
31
35
|
}
|
|
32
36
|
};
|
|
33
37
|
var NpsFrameError = class extends NpsError {
|
|
38
|
+
constructor(message) {
|
|
39
|
+
super(message);
|
|
40
|
+
this.name = "NpsFrameError";
|
|
41
|
+
}
|
|
34
42
|
};
|
|
35
43
|
var NpsCodecError = class extends NpsError {
|
|
44
|
+
constructor(message) {
|
|
45
|
+
super(message);
|
|
46
|
+
this.name = "NpsCodecError";
|
|
47
|
+
}
|
|
36
48
|
};
|
|
37
49
|
var NpsAnchorNotFoundError = class extends NpsError {
|
|
38
|
-
|
|
39
|
-
|
|
50
|
+
anchorId;
|
|
51
|
+
constructor(anchorId, message) {
|
|
52
|
+
super(message ?? `Anchor not found: ${anchorId}`);
|
|
53
|
+
this.name = "NpsAnchorNotFoundError";
|
|
40
54
|
this.anchorId = anchorId;
|
|
41
55
|
}
|
|
42
|
-
anchorId;
|
|
43
56
|
};
|
|
44
57
|
var NpsAnchorPoisonError = class extends NpsError {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
58
|
+
anchorId;
|
|
59
|
+
constructor(anchorId, message) {
|
|
60
|
+
super(message ?? `Anchor poison detected: ${anchorId}`);
|
|
61
|
+
this.name = "NpsAnchorPoisonError";
|
|
49
62
|
this.anchorId = anchorId;
|
|
50
63
|
}
|
|
51
|
-
|
|
64
|
+
};
|
|
65
|
+
var NpsStreamError = class extends NpsError {
|
|
66
|
+
constructor(message) {
|
|
67
|
+
super(message);
|
|
68
|
+
this.name = "NpsStreamError";
|
|
69
|
+
}
|
|
52
70
|
};
|
|
53
71
|
|
|
54
72
|
// src/core/frames.ts
|
|
@@ -58,6 +76,7 @@ var FrameType = /* @__PURE__ */ ((FrameType3) => {
|
|
|
58
76
|
FrameType3[FrameType3["STREAM"] = 3] = "STREAM";
|
|
59
77
|
FrameType3[FrameType3["CAPS"] = 4] = "CAPS";
|
|
60
78
|
FrameType3[FrameType3["ALIGN"] = 5] = "ALIGN";
|
|
79
|
+
FrameType3[FrameType3["HELLO"] = 6] = "HELLO";
|
|
61
80
|
FrameType3[FrameType3["QUERY"] = 16] = "QUERY";
|
|
62
81
|
FrameType3[FrameType3["ACTION"] = 17] = "ACTION";
|
|
63
82
|
FrameType3[FrameType3["IDENT"] = 32] = "IDENT";
|
|
@@ -349,6 +368,64 @@ var AnchorFrameCache = class _AnchorFrameCache {
|
|
|
349
368
|
}
|
|
350
369
|
};
|
|
351
370
|
|
|
371
|
+
// src/core/status-codes.ts
|
|
372
|
+
var NpsStatusCodes = {
|
|
373
|
+
// Success
|
|
374
|
+
NPS_OK: "NPS-OK",
|
|
375
|
+
NPS_OK_ACCEPTED: "NPS-OK-ACCEPTED",
|
|
376
|
+
NPS_OK_NO_CONTENT: "NPS-OK-NO-CONTENT",
|
|
377
|
+
// Auth
|
|
378
|
+
NPS_AUTH_UNAUTHENTICATED: "NPS-AUTH-UNAUTHENTICATED",
|
|
379
|
+
NPS_AUTH_FORBIDDEN: "NPS-AUTH-FORBIDDEN",
|
|
380
|
+
// Client errors
|
|
381
|
+
NPS_CLIENT_BAD_FRAME: "NPS-CLIENT-BAD-FRAME",
|
|
382
|
+
NPS_CLIENT_BAD_PARAM: "NPS-CLIENT-BAD-PARAM",
|
|
383
|
+
NPS_CLIENT_NOT_FOUND: "NPS-CLIENT-NOT-FOUND",
|
|
384
|
+
NPS_CLIENT_CONFLICT: "NPS-CLIENT-CONFLICT",
|
|
385
|
+
NPS_CLIENT_GONE: "NPS-CLIENT-GONE",
|
|
386
|
+
NPS_CLIENT_UNPROCESSABLE: "NPS-CLIENT-UNPROCESSABLE",
|
|
387
|
+
// Server errors
|
|
388
|
+
NPS_SERVER_INTERNAL: "NPS-SERVER-INTERNAL",
|
|
389
|
+
NPS_SERVER_UNAVAILABLE: "NPS-SERVER-UNAVAILABLE",
|
|
390
|
+
NPS_SERVER_TIMEOUT: "NPS-SERVER-TIMEOUT",
|
|
391
|
+
NPS_SERVER_ENCODING_UNSUPPORTED: "NPS-SERVER-ENCODING-UNSUPPORTED",
|
|
392
|
+
// Stream
|
|
393
|
+
NPS_STREAM_SEQ_GAP: "NPS-STREAM-SEQ-GAP",
|
|
394
|
+
NPS_STREAM_NOT_FOUND: "NPS-STREAM-NOT-FOUND",
|
|
395
|
+
NPS_STREAM_LIMIT: "NPS-STREAM-LIMIT",
|
|
396
|
+
// Limit
|
|
397
|
+
NPS_LIMIT_RATE: "NPS-LIMIT-RATE",
|
|
398
|
+
NPS_LIMIT_BUDGET: "NPS-LIMIT-BUDGET",
|
|
399
|
+
NPS_LIMIT_PAYLOAD: "NPS-LIMIT-PAYLOAD",
|
|
400
|
+
NPS_LIMIT_EXCEEDED: "NPS-LIMIT-EXCEEDED",
|
|
401
|
+
// Protocol
|
|
402
|
+
NPS_PROTO_VERSION_INCOMPATIBLE: "NPS-PROTO-VERSION-INCOMPATIBLE"
|
|
403
|
+
};
|
|
404
|
+
var canonicalize = canonicalizeImport__default.default;
|
|
405
|
+
function jcsStringify(obj) {
|
|
406
|
+
const result = canonicalize(obj);
|
|
407
|
+
if (result === void 0) {
|
|
408
|
+
throw new Error("canonicalize returned undefined for input");
|
|
409
|
+
}
|
|
410
|
+
return result;
|
|
411
|
+
}
|
|
412
|
+
function sortKeysStringify(obj) {
|
|
413
|
+
return JSON.stringify(sortKeys(obj));
|
|
414
|
+
}
|
|
415
|
+
function sortKeys(value) {
|
|
416
|
+
if (Array.isArray(value)) {
|
|
417
|
+
return value.map(sortKeys);
|
|
418
|
+
}
|
|
419
|
+
if (value !== null && typeof value === "object") {
|
|
420
|
+
const sorted = {};
|
|
421
|
+
for (const key of Object.keys(value).sort()) {
|
|
422
|
+
sorted[key] = sortKeys(value[key]);
|
|
423
|
+
}
|
|
424
|
+
return sorted;
|
|
425
|
+
}
|
|
426
|
+
return value;
|
|
427
|
+
}
|
|
428
|
+
|
|
352
429
|
exports.AnchorFrameCache = AnchorFrameCache;
|
|
353
430
|
exports.DEFAULT_HEADER_SIZE = DEFAULT_HEADER_SIZE;
|
|
354
431
|
exports.DEFAULT_MAX_PAYLOAD = DEFAULT_MAX_PAYLOAD;
|
|
@@ -365,7 +442,11 @@ exports.NpsCodecError = NpsCodecError;
|
|
|
365
442
|
exports.NpsError = NpsError;
|
|
366
443
|
exports.NpsFrameCodec = NpsFrameCodec;
|
|
367
444
|
exports.NpsFrameError = NpsFrameError;
|
|
445
|
+
exports.NpsStatusCodes = NpsStatusCodes;
|
|
446
|
+
exports.NpsStreamError = NpsStreamError;
|
|
368
447
|
exports.Tier1JsonCodec = Tier1JsonCodec;
|
|
369
448
|
exports.Tier2MsgPackCodec = Tier2MsgPackCodec;
|
|
449
|
+
exports.jcsStringify = jcsStringify;
|
|
450
|
+
exports.sortKeysStringify = sortKeysStringify;
|
|
370
451
|
//# sourceMappingURL=index.cjs.map
|
|
371
452
|
//# sourceMappingURL=index.cjs.map
|