@labacacia/nps-sdk 1.0.0-alpha.1
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/CONTRIBUTING.md +33 -0
- package/LICENSE +170 -0
- package/NOTICE +7 -0
- package/README.md +153 -0
- package/dist/codec-CmHeovTV.d.cts +120 -0
- package/dist/codec-CmHeovTV.d.ts +120 -0
- package/dist/core/anchor-cache.d.ts +42 -0
- package/dist/core/anchor-cache.d.ts.map +1 -0
- package/dist/core/anchor-cache.js +104 -0
- package/dist/core/anchor-cache.js.map +1 -0
- package/dist/core/cache.d.ts +14 -0
- package/dist/core/cache.d.ts.map +1 -0
- package/dist/core/cache.js +80 -0
- package/dist/core/cache.js.map +1 -0
- package/dist/core/canonical-json.d.ts +12 -0
- package/dist/core/canonical-json.d.ts.map +1 -0
- package/dist/core/canonical-json.js +44 -0
- package/dist/core/canonical-json.js.map +1 -0
- package/dist/core/codec.d.ts +32 -0
- package/dist/core/codec.d.ts.map +1 -0
- package/dist/core/codec.js +119 -0
- package/dist/core/codec.js.map +1 -0
- package/dist/core/codecs/index.d.ts +4 -0
- package/dist/core/codecs/index.d.ts.map +1 -0
- package/dist/core/codecs/index.js +6 -0
- package/dist/core/codecs/index.js.map +1 -0
- package/dist/core/codecs/ncp-codec.d.ts +39 -0
- package/dist/core/codecs/ncp-codec.d.ts.map +1 -0
- package/dist/core/codecs/ncp-codec.js +93 -0
- package/dist/core/codecs/ncp-codec.js.map +1 -0
- package/dist/core/codecs/tier1-json-codec.d.ts +10 -0
- package/dist/core/codecs/tier1-json-codec.d.ts.map +1 -0
- package/dist/core/codecs/tier1-json-codec.js +28 -0
- package/dist/core/codecs/tier1-json-codec.js.map +1 -0
- package/dist/core/codecs/tier2-msgpack-codec.d.ts +10 -0
- package/dist/core/codecs/tier2-msgpack-codec.d.ts.map +1 -0
- package/dist/core/codecs/tier2-msgpack-codec.js +26 -0
- package/dist/core/codecs/tier2-msgpack-codec.js.map +1 -0
- package/dist/core/crypto-provider.d.ts +31 -0
- package/dist/core/crypto-provider.d.ts.map +1 -0
- package/dist/core/crypto-provider.js +10 -0
- package/dist/core/crypto-provider.js.map +1 -0
- package/dist/core/exceptions.d.ts +27 -0
- package/dist/core/exceptions.d.ts.map +1 -0
- package/dist/core/exceptions.js +52 -0
- package/dist/core/exceptions.js.map +1 -0
- package/dist/core/frame-header.d.ts +87 -0
- package/dist/core/frame-header.d.ts.map +1 -0
- package/dist/core/frame-header.js +185 -0
- package/dist/core/frame-header.js.map +1 -0
- package/dist/core/frame-registry.d.ts +35 -0
- package/dist/core/frame-registry.d.ts.map +1 -0
- package/dist/core/frame-registry.js +63 -0
- package/dist/core/frame-registry.js.map +1 -0
- package/dist/core/frames.d.ts +80 -0
- package/dist/core/frames.d.ts.map +1 -0
- package/dist/core/frames.js +153 -0
- package/dist/core/frames.js.map +1 -0
- package/dist/core/index.cjs +371 -0
- package/dist/core/index.cjs.map +1 -0
- package/dist/core/index.d.cts +41 -0
- package/dist/core/index.d.ts +9 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +10 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/registry.d.ts +11 -0
- package/dist/core/registry.d.ts.map +1 -0
- package/dist/core/registry.js +17 -0
- package/dist/core/registry.js.map +1 -0
- package/dist/core/status-codes.d.ts +28 -0
- package/dist/core/status-codes.d.ts.map +1 -0
- package/dist/core/status-codes.js +38 -0
- package/dist/core/status-codes.js.map +1 -0
- package/dist/frames-B3qLdl_g.d.cts +77 -0
- package/dist/frames-Ff7-ZPUl.d.ts +77 -0
- package/dist/index.cjs +1556 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +21 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/ncp/frames/anchor-frame.d.ts +29 -0
- package/dist/ncp/frames/anchor-frame.d.ts.map +1 -0
- package/dist/ncp/frames/anchor-frame.js +54 -0
- package/dist/ncp/frames/anchor-frame.js.map +1 -0
- package/dist/ncp/frames/caps-frame.d.ts +29 -0
- package/dist/ncp/frames/caps-frame.d.ts.map +1 -0
- package/dist/ncp/frames/caps-frame.js +29 -0
- package/dist/ncp/frames/caps-frame.js.map +1 -0
- package/dist/ncp/frames/diff-frame.d.ts +32 -0
- package/dist/ncp/frames/diff-frame.d.ts.map +1 -0
- package/dist/ncp/frames/diff-frame.js +37 -0
- package/dist/ncp/frames/diff-frame.js.map +1 -0
- package/dist/ncp/frames/error-frame.d.ts +16 -0
- package/dist/ncp/frames/error-frame.d.ts.map +1 -0
- package/dist/ncp/frames/error-frame.js +13 -0
- package/dist/ncp/frames/error-frame.js.map +1 -0
- package/dist/ncp/frames/hello-frame.d.ts +21 -0
- package/dist/ncp/frames/hello-frame.d.ts.map +1 -0
- package/dist/ncp/frames/hello-frame.js +25 -0
- package/dist/ncp/frames/hello-frame.js.map +1 -0
- package/dist/ncp/frames/stream-frame.d.ts +16 -0
- package/dist/ncp/frames/stream-frame.d.ts.map +1 -0
- package/dist/ncp/frames/stream-frame.js +18 -0
- package/dist/ncp/frames/stream-frame.js.map +1 -0
- package/dist/ncp/frames.d.ts +76 -0
- package/dist/ncp/frames.d.ts.map +1 -0
- package/dist/ncp/frames.js +147 -0
- package/dist/ncp/frames.js.map +1 -0
- package/dist/ncp/handshake.d.ts +30 -0
- package/dist/ncp/handshake.d.ts.map +1 -0
- package/dist/ncp/handshake.js +80 -0
- package/dist/ncp/handshake.js.map +1 -0
- package/dist/ncp/index.cjs +188 -0
- package/dist/ncp/index.cjs.map +1 -0
- package/dist/ncp/index.d.cts +6 -0
- package/dist/ncp/index.d.ts +11 -0
- package/dist/ncp/index.d.ts.map +1 -0
- package/dist/ncp/index.js +13 -0
- package/dist/ncp/index.js.map +1 -0
- package/dist/ncp/ncp-error-codes.d.ts +22 -0
- package/dist/ncp/ncp-error-codes.d.ts.map +1 -0
- package/dist/ncp/ncp-error-codes.js +32 -0
- package/dist/ncp/ncp-error-codes.js.map +1 -0
- package/dist/ncp/ncp-patch-format.d.ts +7 -0
- package/dist/ncp/ncp-patch-format.d.ts.map +1 -0
- package/dist/ncp/ncp-patch-format.js +13 -0
- package/dist/ncp/ncp-patch-format.js.map +1 -0
- package/dist/ncp/registry.d.ts +3 -0
- package/dist/ncp/registry.d.ts.map +1 -0
- package/dist/ncp/registry.js +12 -0
- package/dist/ncp/registry.js.map +1 -0
- package/dist/ncp/stream-manager.d.ts +57 -0
- package/dist/ncp/stream-manager.d.ts.map +1 -0
- package/dist/ncp/stream-manager.js +163 -0
- package/dist/ncp/stream-manager.js.map +1 -0
- package/dist/ndp/frames.d.ts +56 -0
- package/dist/ndp/frames.d.ts.map +1 -0
- package/dist/ndp/frames.js +87 -0
- package/dist/ndp/frames.js.map +1 -0
- package/dist/ndp/index.cjs +252 -0
- package/dist/ndp/index.cjs.map +1 -0
- package/dist/ndp/index.d.cts +86 -0
- package/dist/ndp/index.d.ts +5 -0
- package/dist/ndp/index.d.ts.map +1 -0
- package/dist/ndp/index.js +7 -0
- package/dist/ndp/index.js.map +1 -0
- package/dist/ndp/ndp-registry.d.ts +11 -0
- package/dist/ndp/ndp-registry.d.ts.map +1 -0
- package/dist/ndp/ndp-registry.js +79 -0
- package/dist/ndp/ndp-registry.js.map +1 -0
- package/dist/ndp/registry.d.ts +3 -0
- package/dist/ndp/registry.d.ts.map +1 -0
- package/dist/ndp/registry.js +10 -0
- package/dist/ndp/registry.js.map +1 -0
- package/dist/ndp/validator.d.ts +18 -0
- package/dist/ndp/validator.d.ts.map +1 -0
- package/dist/ndp/validator.js +48 -0
- package/dist/ndp/validator.js.map +1 -0
- package/dist/nip/frames.d.ts +44 -0
- package/dist/nip/frames.d.ts.map +1 -0
- package/dist/nip/frames.js +81 -0
- package/dist/nip/frames.js.map +1 -0
- package/dist/nip/identity.d.ts +18 -0
- package/dist/nip/identity.d.ts.map +1 -0
- package/dist/nip/identity.js +94 -0
- package/dist/nip/identity.js.map +1 -0
- package/dist/nip/index.cjs +214 -0
- package/dist/nip/index.cjs.map +1 -0
- package/dist/nip/index.d.cts +65 -0
- package/dist/nip/index.d.ts +4 -0
- package/dist/nip/index.d.ts.map +1 -0
- package/dist/nip/index.js +6 -0
- package/dist/nip/index.js.map +1 -0
- package/dist/nip/registry.d.ts +3 -0
- package/dist/nip/registry.d.ts.map +1 -0
- package/dist/nip/registry.js +10 -0
- package/dist/nip/registry.js.map +1 -0
- package/dist/nop/client.d.ts +34 -0
- package/dist/nop/client.d.ts.map +1 -0
- package/dist/nop/client.js +90 -0
- package/dist/nop/client.js.map +1 -0
- package/dist/nop/frames.d.ts +65 -0
- package/dist/nop/frames.d.ts.map +1 -0
- package/dist/nop/frames.js +148 -0
- package/dist/nop/frames.js.map +1 -0
- package/dist/nop/index.cjs +762 -0
- package/dist/nop/index.cjs.map +1 -0
- package/dist/nop/index.d.cts +155 -0
- package/dist/nop/index.d.ts +5 -0
- package/dist/nop/index.d.ts.map +1 -0
- package/dist/nop/index.js +7 -0
- package/dist/nop/index.js.map +1 -0
- package/dist/nop/models.d.ts +58 -0
- package/dist/nop/models.d.ts.map +1 -0
- package/dist/nop/models.js +50 -0
- package/dist/nop/models.js.map +1 -0
- package/dist/nop/nop-types.d.ts +136 -0
- package/dist/nop/nop-types.d.ts.map +1 -0
- package/dist/nop/nop-types.js +44 -0
- package/dist/nop/nop-types.js.map +1 -0
- package/dist/nop/registry.d.ts +3 -0
- package/dist/nop/registry.d.ts.map +1 -0
- package/dist/nop/registry.js +11 -0
- package/dist/nop/registry.js.map +1 -0
- package/dist/nwp/client.d.ts +22 -0
- package/dist/nwp/client.d.ts.map +1 -0
- package/dist/nwp/client.js +101 -0
- package/dist/nwp/client.js.map +1 -0
- package/dist/nwp/frames.d.ts +46 -0
- package/dist/nwp/frames.d.ts.map +1 -0
- package/dist/nwp/frames.js +81 -0
- package/dist/nwp/frames.js.map +1 -0
- package/dist/nwp/index.cjs +658 -0
- package/dist/nwp/index.cjs.map +1 -0
- package/dist/nwp/index.d.cts +65 -0
- package/dist/nwp/index.d.ts +4 -0
- package/dist/nwp/index.d.ts.map +1 -0
- package/dist/nwp/index.js +6 -0
- package/dist/nwp/index.js.map +1 -0
- package/dist/nwp/registry.d.ts +3 -0
- package/dist/nwp/registry.d.ts.map +1 -0
- package/dist/nwp/registry.js +9 -0
- package/dist/nwp/registry.js.map +1 -0
- package/dist/setup.d.ts +10 -0
- package/dist/setup.d.ts.map +1 -0
- package/dist/setup.js +29 -0
- package/dist/setup.js.map +1 -0
- package/nip-ca-server/Dockerfile +27 -0
- package/nip-ca-server/README.md +45 -0
- package/nip-ca-server/db/001_init.sql +25 -0
- package/nip-ca-server/docker-compose.yml +29 -0
- package/nip-ca-server/package.json +23 -0
- package/nip-ca-server/src/ca.ts +155 -0
- package/nip-ca-server/src/db.ts +104 -0
- package/nip-ca-server/src/index.ts +157 -0
- package/nip-ca-server/tsconfig.json +13 -0
- package/package.json +47 -0
- package/src/core/anchor-cache.ts +129 -0
- package/src/core/cache.ts +93 -0
- package/src/core/canonical-json.ts +50 -0
- package/src/core/codec.ts +158 -0
- package/src/core/codecs/index.ts +5 -0
- package/src/core/codecs/ncp-codec.ts +170 -0
- package/src/core/codecs/tier1-json-codec.ts +33 -0
- package/src/core/codecs/tier2-msgpack-codec.ts +30 -0
- package/src/core/crypto-provider.ts +47 -0
- package/src/core/exceptions.ts +57 -0
- package/src/core/frame-header.ts +282 -0
- package/src/core/frame-registry.ts +91 -0
- package/src/core/frames.ts +183 -0
- package/src/core/index.ts +10 -0
- package/src/core/registry.ts +28 -0
- package/src/core/status-codes.ts +46 -0
- package/src/index.ts +10 -0
- package/src/ncp/frames/anchor-frame.ts +87 -0
- package/src/ncp/frames/caps-frame.ts +59 -0
- package/src/ncp/frames/diff-frame.ts +69 -0
- package/src/ncp/frames/error-frame.ts +26 -0
- package/src/ncp/frames/hello-frame.ts +50 -0
- package/src/ncp/frames/stream-frame.ts +35 -0
- package/src/ncp/frames.ts +199 -0
- package/src/ncp/handshake.ts +95 -0
- package/src/ncp/index.ts +12 -0
- package/src/ncp/ncp-error-codes.ts +34 -0
- package/src/ncp/ncp-patch-format.ts +16 -0
- package/src/ncp/registry.ts +14 -0
- package/src/ncp/stream-manager.ts +212 -0
- package/src/ndp/frames.ts +124 -0
- package/src/ndp/index.ts +7 -0
- package/src/ndp/ndp-registry.ts +82 -0
- package/src/ndp/registry.ts +12 -0
- package/src/ndp/validator.ts +64 -0
- package/src/nip/frames.ts +106 -0
- package/src/nip/identity.ts +113 -0
- package/src/nip/index.ts +6 -0
- package/src/nip/registry.ts +12 -0
- package/src/nop/client.ts +103 -0
- package/src/nop/frames.ts +181 -0
- package/src/nop/index.ts +7 -0
- package/src/nop/models.ts +79 -0
- package/src/nop/nop-types.ts +208 -0
- package/src/nop/registry.ts +13 -0
- package/src/nwp/client.ts +114 -0
- package/src/nwp/frames.ts +116 -0
- package/src/nwp/index.ts +6 -0
- package/src/nwp/registry.ts +11 -0
- package/src/setup.ts +32 -0
- package/tests/core/anchor-cache.test.ts +242 -0
- package/tests/core/codec.test.ts +205 -0
- package/tests/core/frame-registry.test.ts +46 -0
- package/tests/core.test.ts +327 -0
- package/tests/ncp/diff-binary-bitset.test.ts +107 -0
- package/tests/ncp/e2e-enc-reject.test.ts +93 -0
- package/tests/ncp/err-error-frame.test.ts +152 -0
- package/tests/ncp/frames.test.ts +359 -0
- package/tests/ncp/framing.test.ts +233 -0
- package/tests/ncp/hello-frame.test.ts +122 -0
- package/tests/ncp/inline-anchor.test.ts +88 -0
- package/tests/ncp/security.test.ts +184 -0
- package/tests/ncp/stream-window.test.ts +167 -0
- package/tests/ncp/stream.test.ts +242 -0
- package/tests/ncp/version-negotiation.test.ts +123 -0
- package/tests/ndp.test.ts +271 -0
- package/tests/nip.test.ts +184 -0
- package/tests/nop.test.ts +344 -0
- package/tests/nwp.test.ts +237 -0
- package/tsconfig.json +20 -0
- package/tsup.config.ts +20 -0
- package/vitest.config.ts +10 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// Copyright (c) 2026 LabAcacia / INNO LOTUS PTY LTD
|
|
3
|
+
//
|
|
4
|
+
// ErrorFrame (0xFE) — Unified error frame for all NPS protocol layers
|
|
5
|
+
// NPS-1 §4.7
|
|
6
|
+
/** Type guard for ErrorFrame. */
|
|
7
|
+
export function isErrorFrame(obj) {
|
|
8
|
+
if (typeof obj !== "object" || obj === null)
|
|
9
|
+
return false;
|
|
10
|
+
const o = obj;
|
|
11
|
+
return o.frame === "0xFE" && typeof o.status === "string" && typeof o.error === "string";
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=error-frame.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-frame.js","sourceRoot":"","sources":["../../../src/ncp/frames/error-frame.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,oDAAoD;AACpD,EAAE;AACF,sEAAsE;AACtE,aAAa;AAgBb,iCAAiC;AACjC,MAAM,UAAU,YAAY,CAAC,GAAY;IACvC,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IAC1D,MAAM,CAAC,GAAG,GAA8B,CAAC;IACzC,OAAO,CAAC,CAAC,KAAK,KAAK,MAAM,IAAI,OAAO,CAAC,CAAC,MAAM,KAAK,QAAQ,IAAI,OAAO,CAAC,CAAC,KAAK,KAAK,QAAQ,CAAC;AAC3F,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface HelloFrame {
|
|
2
|
+
frame: string;
|
|
3
|
+
nps_version: string;
|
|
4
|
+
min_version?: string;
|
|
5
|
+
supported_encodings: string[];
|
|
6
|
+
supported_protocols: string[];
|
|
7
|
+
agent_id?: string;
|
|
8
|
+
max_frame_payload?: number;
|
|
9
|
+
ext_support?: boolean;
|
|
10
|
+
max_concurrent_streams?: number;
|
|
11
|
+
e2e_enc_algorithms?: string[];
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Validate a HelloFrame.
|
|
15
|
+
*
|
|
16
|
+
* Required fields: nps_version, supported_encodings (non-empty), supported_protocols (non-empty).
|
|
17
|
+
*
|
|
18
|
+
* @throws {NcpError} NPS-CLIENT-BAD-FRAME if any required field is missing or empty.
|
|
19
|
+
*/
|
|
20
|
+
export declare function validateHelloFrame(frame: HelloFrame): void;
|
|
21
|
+
//# sourceMappingURL=hello-frame.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hello-frame.d.ts","sourceRoot":"","sources":["../../../src/ncp/frames/hello-frame.ts"],"names":[],"mappings":"AAQA,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,mBAAmB,EAAE,MAAM,EAAE,CAAC;IAC9B,mBAAmB,EAAE,MAAM,EAAE,CAAC;IAC9B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAC;CAC/B;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI,CAqB1D"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// Copyright (c) 2026 LabAcacia / INNO LOTUS PTY LTD
|
|
3
|
+
//
|
|
4
|
+
// HelloFrame (0x06) — Native-mode client handshake
|
|
5
|
+
// NPS-1 §4.6
|
|
6
|
+
import { NcpError } from "../../core/frame-header.js";
|
|
7
|
+
/**
|
|
8
|
+
* Validate a HelloFrame.
|
|
9
|
+
*
|
|
10
|
+
* Required fields: nps_version, supported_encodings (non-empty), supported_protocols (non-empty).
|
|
11
|
+
*
|
|
12
|
+
* @throws {NcpError} NPS-CLIENT-BAD-FRAME if any required field is missing or empty.
|
|
13
|
+
*/
|
|
14
|
+
export function validateHelloFrame(frame) {
|
|
15
|
+
if (!frame.nps_version) {
|
|
16
|
+
throw new NcpError("NPS-CLIENT-BAD-FRAME", "HelloFrame missing required field: nps_version");
|
|
17
|
+
}
|
|
18
|
+
if (!frame.supported_encodings || frame.supported_encodings.length === 0) {
|
|
19
|
+
throw new NcpError("NPS-CLIENT-BAD-FRAME", "HelloFrame missing required field: supported_encodings (must be non-empty)");
|
|
20
|
+
}
|
|
21
|
+
if (!frame.supported_protocols || frame.supported_protocols.length === 0) {
|
|
22
|
+
throw new NcpError("NPS-CLIENT-BAD-FRAME", "HelloFrame missing required field: supported_protocols (must be non-empty)");
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=hello-frame.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hello-frame.js","sourceRoot":"","sources":["../../../src/ncp/frames/hello-frame.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,oDAAoD;AACpD,EAAE;AACF,mDAAmD;AACnD,aAAa;AAEb,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAetD;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAAiB;IAClD,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC;QACvB,MAAM,IAAI,QAAQ,CAChB,sBAAsB,EACtB,gDAAgD,CACjD,CAAC;IACJ,CAAC;IAED,IAAI,CAAC,KAAK,CAAC,mBAAmB,IAAI,KAAK,CAAC,mBAAmB,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzE,MAAM,IAAI,QAAQ,CAChB,sBAAsB,EACtB,4EAA4E,CAC7E,CAAC;IACJ,CAAC;IAED,IAAI,CAAC,KAAK,CAAC,mBAAmB,IAAI,KAAK,CAAC,mBAAmB,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzE,MAAM,IAAI,QAAQ,CAChB,sBAAsB,EACtB,4EAA4E,CAC7E,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface StreamFrame {
|
|
2
|
+
frame: string;
|
|
3
|
+
stream_id: string;
|
|
4
|
+
seq: number;
|
|
5
|
+
is_last: boolean;
|
|
6
|
+
anchor_ref?: string;
|
|
7
|
+
data: unknown[];
|
|
8
|
+
window_size?: number;
|
|
9
|
+
error_code?: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Validate stream_id is a valid UUID v4.
|
|
13
|
+
* @throws {NcpError} NPS-CLIENT-BAD-FRAME if stream_id is not a valid UUID v4.
|
|
14
|
+
*/
|
|
15
|
+
export declare function validateStreamFrame(frame: StreamFrame): void;
|
|
16
|
+
//# sourceMappingURL=stream-frame.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stream-frame.d.ts","sourceRoot":"","sources":["../../../src/ncp/frames/stream-frame.ts"],"names":[],"mappings":"AAQA,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,OAAO,EAAE,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAMD;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,WAAW,GAAG,IAAI,CAO5D"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// Copyright (c) 2026 LabAcacia / INNO LOTUS PTY LTD
|
|
3
|
+
//
|
|
4
|
+
// StreamFrame (0x03) — Streaming data chunks with flow control
|
|
5
|
+
// NPS-1 §4.3
|
|
6
|
+
import { NcpError } from "../../core/frame-header.js";
|
|
7
|
+
// UUID v4 format: xxxxxxxx-xxxx-4xxx-[89ab]xxx-xxxxxxxxxxxx
|
|
8
|
+
const UUID_V4_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
9
|
+
/**
|
|
10
|
+
* Validate stream_id is a valid UUID v4.
|
|
11
|
+
* @throws {NcpError} NPS-CLIENT-BAD-FRAME if stream_id is not a valid UUID v4.
|
|
12
|
+
*/
|
|
13
|
+
export function validateStreamFrame(frame) {
|
|
14
|
+
if (!UUID_V4_RE.test(frame.stream_id)) {
|
|
15
|
+
throw new NcpError("NPS-CLIENT-BAD-FRAME", `stream_id "${frame.stream_id}" is not a valid UUID v4`);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=stream-frame.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stream-frame.js","sourceRoot":"","sources":["../../../src/ncp/frames/stream-frame.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,oDAAoD;AACpD,EAAE;AACF,+DAA+D;AAC/D,aAAa;AAEb,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAatD,4DAA4D;AAC5D,MAAM,UAAU,GACd,wEAAwE,CAAC;AAE3E;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAAkB;IACpD,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,QAAQ,CAChB,sBAAsB,EACtB,cAAc,KAAK,CAAC,SAAS,0BAA0B,CACxD,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { EncodingTier, FrameType } from "../core/frames.js";
|
|
2
|
+
import type { NpsFrame } from "../core/codec.js";
|
|
3
|
+
export interface SchemaField {
|
|
4
|
+
name: string;
|
|
5
|
+
type: string;
|
|
6
|
+
semantic?: string;
|
|
7
|
+
nullable?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface FrameSchema {
|
|
10
|
+
fields: readonly SchemaField[];
|
|
11
|
+
}
|
|
12
|
+
export declare class AnchorFrame implements NpsFrame {
|
|
13
|
+
readonly anchorId: string;
|
|
14
|
+
readonly schema: FrameSchema;
|
|
15
|
+
readonly ttl: number;
|
|
16
|
+
readonly frameType = FrameType.ANCHOR;
|
|
17
|
+
readonly preferredTier = EncodingTier.MSGPACK;
|
|
18
|
+
constructor(anchorId: string, schema: FrameSchema, ttl?: number);
|
|
19
|
+
toDict(): Record<string, unknown>;
|
|
20
|
+
static fromDict(data: Record<string, unknown>): AnchorFrame;
|
|
21
|
+
}
|
|
22
|
+
export interface JsonPatchOperation {
|
|
23
|
+
op: string;
|
|
24
|
+
path: string;
|
|
25
|
+
value?: unknown;
|
|
26
|
+
}
|
|
27
|
+
export declare class DiffFrame implements NpsFrame {
|
|
28
|
+
readonly anchorRef: string;
|
|
29
|
+
readonly baseSeq: number;
|
|
30
|
+
readonly patch: readonly JsonPatchOperation[];
|
|
31
|
+
readonly entityId?: string | undefined;
|
|
32
|
+
readonly frameType = FrameType.DIFF;
|
|
33
|
+
readonly preferredTier = EncodingTier.MSGPACK;
|
|
34
|
+
constructor(anchorRef: string, baseSeq: number, patch: readonly JsonPatchOperation[], entityId?: string | undefined);
|
|
35
|
+
toDict(): Record<string, unknown>;
|
|
36
|
+
static fromDict(data: Record<string, unknown>): DiffFrame;
|
|
37
|
+
}
|
|
38
|
+
export declare class StreamFrame implements NpsFrame {
|
|
39
|
+
readonly streamId: string;
|
|
40
|
+
readonly seq: number;
|
|
41
|
+
readonly isLast: boolean;
|
|
42
|
+
readonly data: readonly Record<string, unknown>[];
|
|
43
|
+
readonly anchorRef?: string | undefined;
|
|
44
|
+
readonly windowSize?: number | undefined;
|
|
45
|
+
readonly frameType = FrameType.STREAM;
|
|
46
|
+
readonly preferredTier = EncodingTier.MSGPACK;
|
|
47
|
+
constructor(streamId: string, seq: number, isLast: boolean, data: readonly Record<string, unknown>[], anchorRef?: string | undefined, windowSize?: number | undefined);
|
|
48
|
+
toDict(): Record<string, unknown>;
|
|
49
|
+
static fromDict(data: Record<string, unknown>): StreamFrame;
|
|
50
|
+
}
|
|
51
|
+
export declare class CapsFrame implements NpsFrame {
|
|
52
|
+
readonly anchorRef: string;
|
|
53
|
+
readonly count: number;
|
|
54
|
+
readonly data: readonly Record<string, unknown>[];
|
|
55
|
+
readonly nextCursor?: string | undefined;
|
|
56
|
+
readonly tokenEst?: number | undefined;
|
|
57
|
+
readonly cached?: boolean | undefined;
|
|
58
|
+
readonly tokenizerUsed?: string | undefined;
|
|
59
|
+
readonly frameType = FrameType.CAPS;
|
|
60
|
+
readonly preferredTier = EncodingTier.MSGPACK;
|
|
61
|
+
constructor(anchorRef: string, count: number, data: readonly Record<string, unknown>[], nextCursor?: string | undefined, tokenEst?: number | undefined, cached?: boolean | undefined, tokenizerUsed?: string | undefined);
|
|
62
|
+
toDict(): Record<string, unknown>;
|
|
63
|
+
static fromDict(data: Record<string, unknown>): CapsFrame;
|
|
64
|
+
}
|
|
65
|
+
export declare class ErrorFrame implements NpsFrame {
|
|
66
|
+
readonly status: string;
|
|
67
|
+
readonly error: string;
|
|
68
|
+
readonly message?: string | undefined;
|
|
69
|
+
readonly details?: Record<string, unknown> | undefined;
|
|
70
|
+
readonly frameType = FrameType.ERROR;
|
|
71
|
+
readonly preferredTier = EncodingTier.MSGPACK;
|
|
72
|
+
constructor(status: string, error: string, message?: string | undefined, details?: Record<string, unknown> | undefined);
|
|
73
|
+
toDict(): Record<string, unknown>;
|
|
74
|
+
static fromDict(data: Record<string, unknown>): ErrorFrame;
|
|
75
|
+
}
|
|
76
|
+
//# sour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VxC,QAAQ,CAAC,SAAS,kBAAsB;IACxC,QAAQ,CAAC,aAAa,wBAAwB;gBAG5B,SAAS,EAAO,MAAM,EACtB,KAAK,EAAW,MAAM,EACtB,IAAI,EAAY,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,EAClD,UAAU,CAAC,EAAK,MAAM,YAAA,EACtB,QAAQ,CAAC,EAAO,MAAM,YAAA,EACtB,MAAM,CAAC,EAAS,OAAO,YAAA,EACvB,aAAa,CAAC,EAAE,MAAM,YAAA;IAGxC,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAYjC,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS;CAW1D;AAID,qBAAa,UAAW,YAAW,QAAQ;aAKvB,MAAM,EAAI,MAAM;aAChB,KAAK,EAAK,MAAM;aAChB,OAAO,CAAC,EAAE,MAAM;aAChB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAPnD,QAAQ,CAAC,SAAS,mBAAuB;IACzC,QAAQ,CAAC,aAAa,wBAAwB;gBAG5B,MAAM,EAAI,MAAM,EAChB,KAAK,EAAK,MAAM,EAChB,OAAO,CAAC,EAAE,MAAM,YAAA,EAChB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,YAAA;IAGnD,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IASjC,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,UAAU;CAQ3D"}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
// Copyright 2026 INNO LOTUS PTY LTD
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { EncodingTier, FrameType } from "../core/frames.js";
|
|
4
|
+
// ── AnchorFrame ───────────────────────────────────────────────────────────────
|
|
5
|
+
export class AnchorFrame {
|
|
6
|
+
anchorId;
|
|
7
|
+
schema;
|
|
8
|
+
ttl;
|
|
9
|
+
frameType = FrameType.ANCHOR;
|
|
10
|
+
preferredTier = EncodingTier.MSGPACK;
|
|
11
|
+
constructor(anchorId, schema, ttl = 3600) {
|
|
12
|
+
this.anchorId = anchorId;
|
|
13
|
+
this.schema = schema;
|
|
14
|
+
this.ttl = ttl;
|
|
15
|
+
}
|
|
16
|
+
toDict() {
|
|
17
|
+
return {
|
|
18
|
+
anchor_id: this.anchorId,
|
|
19
|
+
schema: { fields: this.schema.fields.map((f) => ({ ...f })) },
|
|
20
|
+
ttl: this.ttl,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
static fromDict(data) {
|
|
24
|
+
const schemaRaw = data["schema"];
|
|
25
|
+
return new AnchorFrame(data["anchor_id"], { fields: schemaRaw.fields }, data["ttl"] ?? 3600);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
// ── DiffFrame ─────────────────────────────────────────────────────────────────
|
|
29
|
+
export class DiffFrame {
|
|
30
|
+
anchorRef;
|
|
31
|
+
baseSeq;
|
|
32
|
+
patch;
|
|
33
|
+
entityId;
|
|
34
|
+
frameType = FrameType.DIFF;
|
|
35
|
+
preferredTier = EncodingTier.MSGPACK;
|
|
36
|
+
constructor(anchorRef, baseSeq, patch, entityId) {
|
|
37
|
+
this.anchorRef = anchorRef;
|
|
38
|
+
this.baseSeq = baseSeq;
|
|
39
|
+
this.patch = patch;
|
|
40
|
+
this.entityId = entityId;
|
|
41
|
+
}
|
|
42
|
+
toDict() {
|
|
43
|
+
return {
|
|
44
|
+
anchor_ref: this.anchorRef,
|
|
45
|
+
base_seq: this.baseSeq,
|
|
46
|
+
patch: this.patch.map((p) => ({ ...p })),
|
|
47
|
+
entity_id: this.entityId ?? null,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
static fromDict(data) {
|
|
51
|
+
return new DiffFrame(data["anchor_ref"], data["base_seq"], data["patch"], data["entity_id"] ?? undefined);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
// ── StreamFrame ───────────────────────────────────────────────────────────────
|
|
55
|
+
export class StreamFrame {
|
|
56
|
+
streamId;
|
|
57
|
+
seq;
|
|
58
|
+
isLast;
|
|
59
|
+
data;
|
|
60
|
+
anchorRef;
|
|
61
|
+
windowSize;
|
|
62
|
+
frameType = FrameType.STREAM;
|
|
63
|
+
preferredTier = EncodingTier.MSGPACK;
|
|
64
|
+
constructor(streamId, seq, isLast, data, anchorRef, windowSize) {
|
|
65
|
+
this.streamId = streamId;
|
|
66
|
+
this.seq = seq;
|
|
67
|
+
this.isLast = isLast;
|
|
68
|
+
this.data = data;
|
|
69
|
+
this.anchorRef = anchorRef;
|
|
70
|
+
this.windowSize = windowSize;
|
|
71
|
+
}
|
|
72
|
+
toDict() {
|
|
73
|
+
return {
|
|
74
|
+
stream_id: this.streamId,
|
|
75
|
+
seq: this.seq,
|
|
76
|
+
is_last: this.isLast,
|
|
77
|
+
data: this.data,
|
|
78
|
+
anchor_ref: this.anchorRef ?? null,
|
|
79
|
+
window_size: this.windowSize ?? null,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
static fromDict(data) {
|
|
83
|
+
return new StreamFrame(data["stream_id"], data["seq"], data["is_last"], data["data"], data["anchor_ref"] ?? undefined, data["window_size"] ?? undefined);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
// ── CapsFrame ─────────────────────────────────────────────────────────────────
|
|
87
|
+
export class CapsFrame {
|
|
88
|
+
anchorRef;
|
|
89
|
+
count;
|
|
90
|
+
data;
|
|
91
|
+
nextCursor;
|
|
92
|
+
tokenEst;
|
|
93
|
+
cached;
|
|
94
|
+
tokenizerUsed;
|
|
95
|
+
frameType = FrameType.CAPS;
|
|
96
|
+
preferredTier = EncodingTier.MSGPACK;
|
|
97
|
+
constructor(anchorRef, count, data, nextCursor, tokenEst, cached, tokenizerUsed) {
|
|
98
|
+
this.anchorRef = anchorRef;
|
|
99
|
+
this.count = count;
|
|
100
|
+
this.data = data;
|
|
101
|
+
this.nextCursor = nextCursor;
|
|
102
|
+
this.tokenEst = tokenEst;
|
|
103
|
+
this.cached = cached;
|
|
104
|
+
this.tokenizerUsed = tokenizerUsed;
|
|
105
|
+
}
|
|
106
|
+
toDict() {
|
|
107
|
+
return {
|
|
108
|
+
anchor_ref: this.anchorRef,
|
|
109
|
+
count: this.count,
|
|
110
|
+
data: this.data,
|
|
111
|
+
next_cursor: this.nextCursor ?? null,
|
|
112
|
+
token_est: this.tokenEst ?? null,
|
|
113
|
+
cached: this.cached ?? null,
|
|
114
|
+
tokenizer_used: this.tokenizerUsed ?? null,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
static fromDict(data) {
|
|
118
|
+
return new CapsFrame(data["anchor_ref"], data["count"], data["data"], data["next_cursor"] ?? undefined, data["token_est"] ?? undefined, data["cached"] ?? undefined, data["tokenizer_used"] ?? undefined);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
// ── ErrorFrame ────────────────────────────────────────────────────────────────
|
|
122
|
+
export class ErrorFrame {
|
|
123
|
+
status;
|
|
124
|
+
error;
|
|
125
|
+
message;
|
|
126
|
+
details;
|
|
127
|
+
frameType = FrameType.ERROR;
|
|
128
|
+
preferredTier = EncodingTier.MSGPACK;
|
|
129
|
+
constructor(status, error, message, details) {
|
|
130
|
+
this.status = status;
|
|
131
|
+
this.error = error;
|
|
132
|
+
this.message = message;
|
|
133
|
+
this.details = details;
|
|
134
|
+
}
|
|
135
|
+
toDict() {
|
|
136
|
+
return {
|
|
137
|
+
status: this.status,
|
|
138
|
+
error: this.error,
|
|
139
|
+
message: this.message ?? null,
|
|
140
|
+
details: this.details ?? null,
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
static fromDict(data) {
|
|
144
|
+
return new ErrorFrame(data["status"], data["error"], data["message"] ?? undefined, data["details"] ?? undefined);
|
|
145
|
+
}
|
|
146
|
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AAI,SAAS,EAC9C,IAAI,CAAC,SAAS,CAAoC,IAAI,SAAS,CACjE,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Negotiate the session NPS version between client and server.
|
|
3
|
+
*
|
|
4
|
+
* Session version = numeric min of client.nps_version and server.nps_version
|
|
5
|
+
* (component-wise — "0.9" < "0.10" < "1.0").
|
|
6
|
+
* If the effective client minimum (min_version ?? nps_version) > server.nps_version,
|
|
7
|
+
* the versions are incompatible.
|
|
8
|
+
*
|
|
9
|
+
* Spec: NPS-1 §2.6
|
|
10
|
+
*/
|
|
11
|
+
export declare function negotiateVersion(client: {
|
|
12
|
+
nps_version: string;
|
|
13
|
+
min_version?: string;
|
|
14
|
+
}, server: {
|
|
15
|
+
nps_version: string;
|
|
16
|
+
}): {
|
|
17
|
+
session_version: string;
|
|
18
|
+
compatible: boolean;
|
|
19
|
+
error_code?: string;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Negotiate the encoding between client and server preferred lists.
|
|
23
|
+
*
|
|
24
|
+
* Returns the first mutually supported encoding, preferring "msgpack" over "json".
|
|
25
|
+
* Returns null if there is no intersection.
|
|
26
|
+
*/
|
|
27
|
+
export declare function negotiateEncoding(client: string[], server: string[]): {
|
|
28
|
+
encoding: string | null;
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=handshake.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handshake.d.ts","sourceRoot":"","sources":["../../src/ncp/handshake.ts"],"names":[],"mappings":"AAgCA;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,EACrD,MAAM,EAAE;IAAE,WAAW,EAAE,MAAM,CAAA;CAAE,GAC9B;IAAE,eAAe,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,OAAO,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,CAmBvE;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,MAAM,EAAE,EAChB,MAAM,EAAE,MAAM,EAAE,GACf;IAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAmB7B"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// Copyright (c) 2026 LabAcacia / INNO LOTUS PTY LTD
|
|
3
|
+
//
|
|
4
|
+
// Handshake — Version negotiation and encoding negotiation
|
|
5
|
+
// NPS-1 §2.6
|
|
6
|
+
/**
|
|
7
|
+
* Parse a "major.minor" (optionally "major.minor.patch") version string into a
|
|
8
|
+
* tuple of numeric components. Invalid parts become NaN which makes subsequent
|
|
9
|
+
* comparisons return false in both directions (safe failure).
|
|
10
|
+
*/
|
|
11
|
+
function parseVersion(v) {
|
|
12
|
+
return v.split(".").map((p) => Number.parseInt(p, 10));
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Numeric component-wise comparison of two version strings.
|
|
16
|
+
* Returns negative if a < b, zero if equal, positive if a > b.
|
|
17
|
+
* Avoids the lexicographic pitfall where "0.9" > "0.10".
|
|
18
|
+
*/
|
|
19
|
+
function compareVersions(a, b) {
|
|
20
|
+
const partsA = parseVersion(a);
|
|
21
|
+
const partsB = parseVersion(b);
|
|
22
|
+
const len = Math.max(partsA.length, partsB.length);
|
|
23
|
+
for (let i = 0; i < len; i += 1) {
|
|
24
|
+
const x = partsA[i] ?? 0;
|
|
25
|
+
const y = partsB[i] ?? 0;
|
|
26
|
+
if (x !== y)
|
|
27
|
+
return x - y;
|
|
28
|
+
}
|
|
29
|
+
return 0;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Negotiate the session NPS version between client and server.
|
|
33
|
+
*
|
|
34
|
+
* Session version = numeric min of client.nps_version and server.nps_version
|
|
35
|
+
* (component-wise — "0.9" < "0.10" < "1.0").
|
|
36
|
+
* If the effective client minimum (min_version ?? nps_version) > server.nps_version,
|
|
37
|
+
* the versions are incompatible.
|
|
38
|
+
*
|
|
39
|
+
* Spec: NPS-1 §2.6
|
|
40
|
+
*/
|
|
41
|
+
export function negotiateVersion(client, server) {
|
|
42
|
+
const clientMin = client.min_version ?? client.nps_version;
|
|
43
|
+
const serverVersion = server.nps_version;
|
|
44
|
+
if (compareVersions(clientMin, serverVersion) > 0) {
|
|
45
|
+
return {
|
|
46
|
+
session_version: serverVersion,
|
|
47
|
+
compatible: false,
|
|
48
|
+
error_code: "NCP-VERSION-INCOMPATIBLE",
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
// Session version = component-wise min of client.nps_version and server.nps_version
|
|
52
|
+
const sessionVersion = compareVersions(client.nps_version, serverVersion) <= 0
|
|
53
|
+
? client.nps_version
|
|
54
|
+
: serverVersion;
|
|
55
|
+
return { session_version: sessionVersion, compatible: true };
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Negotiate the encoding between client and server preferred lists.
|
|
59
|
+
*
|
|
60
|
+
* Returns the first mutually supported encoding, preferring "msgpack" over "json".
|
|
61
|
+
* Returns null if there is no intersection.
|
|
62
|
+
*/
|
|
63
|
+
export function negotiateEncoding(client, server) {
|
|
64
|
+
const serverSet = new Set(server);
|
|
65
|
+
// Prefer msgpack over json (and over any other encoding)
|
|
66
|
+
if (client.includes("msgpack") && serverSet.has("msgpack")) {
|
|
67
|
+
return { encoding: "msgpack" };
|
|
68
|
+
}
|
|
69
|
+
if (client.includes("json") && serverSet.has("json")) {
|
|
70
|
+
return { encoding: "json" };
|
|
71
|
+
}
|
|
72
|
+
// Fall back to first intersection in client-preference order
|
|
73
|
+
for (const enc of client) {
|
|
74
|
+
if (serverSet.has(enc)) {
|
|
75
|
+
return { encoding: enc };
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return { encoding: null };
|
|
79
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|
3
|
+
// src/ncp/frames.ts
|
|
4
|
+
var AnchorFrame = class _AnchorFrame {
|
|
5
|
+
constructor(anchorId, schema, ttl = 3600) {
|
|
6
|
+
this.anchorId = anchorId;
|
|
7
|
+
this.schema = schema;
|
|
8
|
+
this.ttl = ttl;
|
|
9
|
+
}
|
|
10
|
+
anchorId;
|
|
11
|
+
schema;
|
|
12
|
+
ttl;
|
|
13
|
+
frameType = 1 /* ANCHOR */;
|
|
14
|
+
preferredTier = 1 /* MSGPACK */;
|
|
15
|
+
toDict() {
|
|
16
|
+
return {
|
|
17
|
+
anchor_id: this.anchorId,
|
|
18
|
+
schema: { fields: this.schema.fields.map((f) => ({ ...f })) },
|
|
19
|
+
ttl: this.ttl
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
static fromDict(data) {
|
|
23
|
+
const schemaRaw = data["schema"];
|
|
24
|
+
return new _AnchorFrame(
|
|
25
|
+
data["anchor_id"],
|
|
26
|
+
{ fields: schemaRaw.fields },
|
|
27
|
+
data["ttl"] ?? 3600
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
var DiffFrame = class _DiffFrame {
|
|
32
|
+
constructor(anchorRef, baseSeq, patch, entityId) {
|
|
33
|
+
this.anchorRef = anchorRef;
|
|
34
|
+
this.baseSeq = baseSeq;
|
|
35
|
+
this.patch = patch;
|
|
36
|
+
this.entityId = entityId;
|
|
37
|
+
}
|
|
38
|
+
anchorRef;
|
|
39
|
+
baseSeq;
|
|
40
|
+
patch;
|
|
41
|
+
entityId;
|
|
42
|
+
frameType = 2 /* DIFF */;
|
|
43
|
+
preferredTier = 1 /* MSGPACK */;
|
|
44
|
+
toDict() {
|
|
45
|
+
return {
|
|
46
|
+
anchor_ref: this.anchorRef,
|
|
47
|
+
base_seq: this.baseSeq,
|
|
48
|
+
patch: this.patch.map((p) => ({ ...p })),
|
|
49
|
+
entity_id: this.entityId ?? null
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
static fromDict(data) {
|
|
53
|
+
return new _DiffFrame(
|
|
54
|
+
data["anchor_ref"],
|
|
55
|
+
data["base_seq"],
|
|
56
|
+
data["patch"],
|
|
57
|
+
data["entity_id"] ?? void 0
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
var StreamFrame = class _StreamFrame {
|
|
62
|
+
constructor(streamId, seq, isLast, data, anchorRef, windowSize) {
|
|
63
|
+
this.streamId = streamId;
|
|
64
|
+
this.seq = seq;
|
|
65
|
+
this.isLast = isLast;
|
|
66
|
+
this.data = data;
|
|
67
|
+
this.anchorRef = anchorRef;
|
|
68
|
+
this.windowSize = windowSize;
|
|
69
|
+
}
|
|
70
|
+
streamId;
|
|
71
|
+
seq;
|
|
72
|
+
isLast;
|
|
73
|
+
data;
|
|
74
|
+
anchorRef;
|
|
75
|
+
windowSize;
|
|
76
|
+
frameType = 3 /* STREAM */;
|
|
77
|
+
preferredTier = 1 /* MSGPACK */;
|
|
78
|
+
toDict() {
|
|
79
|
+
return {
|
|
80
|
+
stream_id: this.streamId,
|
|
81
|
+
seq: this.seq,
|
|
82
|
+
is_last: this.isLast,
|
|
83
|
+
data: this.data,
|
|
84
|
+
anchor_ref: this.anchorRef ?? null,
|
|
85
|
+
window_size: this.windowSize ?? null
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
static fromDict(data) {
|
|
89
|
+
return new _StreamFrame(
|
|
90
|
+
data["stream_id"],
|
|
91
|
+
data["seq"],
|
|
92
|
+
data["is_last"],
|
|
93
|
+
data["data"],
|
|
94
|
+
data["anchor_ref"] ?? void 0,
|
|
95
|
+
data["window_size"] ?? void 0
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
var CapsFrame = class _CapsFrame {
|
|
100
|
+
constructor(anchorRef, count, data, nextCursor, tokenEst, cached, tokenizerUsed) {
|
|
101
|
+
this.anchorRef = anchorRef;
|
|
102
|
+
this.count = count;
|
|
103
|
+
this.data = data;
|
|
104
|
+
this.nextCursor = nextCursor;
|
|
105
|
+
this.tokenEst = tokenEst;
|
|
106
|
+
this.cached = cached;
|
|
107
|
+
this.tokenizerUsed = tokenizerUsed;
|
|
108
|
+
}
|
|
109
|
+
anchorRef;
|
|
110
|
+
count;
|
|
111
|
+
data;
|
|
112
|
+
nextCursor;
|
|
113
|
+
tokenEst;
|
|
114
|
+
cached;
|
|
115
|
+
tokenizerUsed;
|
|
116
|
+
frameType = 4 /* CAPS */;
|
|
117
|
+
preferredTier = 1 /* MSGPACK */;
|
|
118
|
+
toDict() {
|
|
119
|
+
return {
|
|
120
|
+
anchor_ref: this.anchorRef,
|
|
121
|
+
count: this.count,
|
|
122
|
+
data: this.data,
|
|
123
|
+
next_cursor: this.nextCursor ?? null,
|
|
124
|
+
token_est: this.tokenEst ?? null,
|
|
125
|
+
cached: this.cached ?? null,
|
|
126
|
+
tokenizer_used: this.tokenizerUsed ?? null
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
static fromDict(data) {
|
|
130
|
+
return new _CapsFrame(
|
|
131
|
+
data["anchor_ref"],
|
|
132
|
+
data["count"],
|
|
133
|
+
data["data"],
|
|
134
|
+
data["next_cursor"] ?? void 0,
|
|
135
|
+
data["token_est"] ?? void 0,
|
|
136
|
+
data["cached"] ?? void 0,
|
|
137
|
+
data["tokenizer_used"] ?? void 0
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
var ErrorFrame = class _ErrorFrame {
|
|
142
|
+
constructor(status, error, message, details) {
|
|
143
|
+
this.status = status;
|
|
144
|
+
this.error = error;
|
|
145
|
+
this.message = message;
|
|
146
|
+
this.details = details;
|
|
147
|
+
}
|
|
148
|
+
status;
|
|
149
|
+
error;
|
|
150
|
+
message;
|
|
151
|
+
details;
|
|
152
|
+
frameType = 254 /* ERROR */;
|
|
153
|
+
preferredTier = 1 /* MSGPACK */;
|
|
154
|
+
toDict() {
|
|
155
|
+
return {
|
|
156
|
+
status: this.status,
|
|
157
|
+
error: this.error,
|
|
158
|
+
message: this.message ?? null,
|
|
159
|
+
details: this.details ?? null
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
static fromDict(data) {
|
|
163
|
+
return new _ErrorFrame(
|
|
164
|
+
data["status"],
|
|
165
|
+
data["error"],
|
|
166
|
+
data["message"] ?? void 0,
|
|
167
|
+
data["details"] ?? void 0
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
// src/ncp/registry.ts
|
|
173
|
+
function registerNcpFrames(registry) {
|
|
174
|
+
registry.register(1 /* ANCHOR */, AnchorFrame);
|
|
175
|
+
registry.register(2 /* DIFF */, DiffFrame);
|
|
176
|
+
registry.register(3 /* STREAM */, StreamFrame);
|
|
177
|
+
registry.register(4 /* CAPS */, CapsFrame);
|
|
178
|
+
registry.register(254 /* ERROR */, ErrorFrame);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
exports.AnchorFrame = AnchorFrame;
|
|
182
|
+
exports.CapsFrame = CapsFrame;
|
|
183
|
+
exports.DiffFrame = DiffFrame;
|
|
184
|
+
exports.ErrorFrame = ErrorFrame;
|
|
185
|
+
exports.StreamFrame = StreamFrame;
|
|
186
|
+
exports.registerNcpFrames = registerNcpFrames;
|
|
187
|
+
//# sourceMappingURL=index.cjs.map
|
|
188
|
+
//# sourceMappingURL=index.cjs.map
|