@avatarsd-llc/libtracer-client 0.1.0 → 0.4.0

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/dist/tlv.js CHANGED
@@ -1,25 +1,31 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  // SPDX-FileCopyrightText: Copyright 2026 avatarsd LLC
3
- // Pure, side-effect-free TLV builders for the libtracer client SDK (#56,
4
- // ADR-0034). Each function produces the EXACT wire bytes the shared conformance
5
- // vectors pin (`tests/conformance/vectors/v1/`) via the cross-validated core
6
- // codec (`@avatarsd-llc/libtracer`) — nothing here invents wire structure:
7
- //
8
- // - encodeValue -> VALUE TLV (0x01) : value-bool-true / value-ll-u32 / value-ts-abs
9
- // - encodePath -> PATH TLV (0x06, PL=1) : path-sensor-temp + spec/v1.md §3.1
10
- // - encodeSubscriber -> SUBSCRIBER TLV (0x04) : subscriber-path (the subscribe-write payload)
11
- //
12
- // These are the payload TLVs. The path-ADDRESSED request envelope (verb +
13
- // destination vertex:field) is the FWD/FIELD frame RFC-0004 (spec §3) fixes — it
14
- // is built in `./fwd.ts`, not here; these payloads ride inside it.
3
+ /**
4
+ * @brief Pure, side-effect-free TLV builders for the libtracer client SDK
5
+ * (#56, ADR-0034).
6
+ *
7
+ * Each function produces the EXACT wire bytes the shared conformance vectors
8
+ * pin (`tests/conformance/vectors/v1/`) via the cross-validated core codec
9
+ * (`@avatarsd-llc/libtracer`) — nothing here invents wire structure:
10
+ *
11
+ * - encodeValue -> VALUE TLV (0x01) : value-bool-true / value-ll-u32 / value-ts-abs
12
+ * - encodePath -> PATH TLV (0x06, PL=1) : path-sensor-temp + spec/v1.md §3.1
13
+ * - encodeSubscriber -> SUBSCRIBER TLV (0x04) : subscriber-path (the subscribe-write payload)
14
+ *
15
+ * These are the payload TLVs. The path-ADDRESSED request envelope (verb +
16
+ * destination vertex:field) is the FWD/FIELD frame RFC-0004 (spec §3) fixes —
17
+ * it is built in `./fwd.ts`, not here; these payloads ride inside it.
18
+ */
15
19
  import { TYPE, encode } from '@avatarsd-llc/libtracer';
16
- /** Path-segment constraints from reference/03-addressing.md §path syntax. */
20
+ /** @brief Path-segment constraints from reference/03-addressing.md §path syntax. */
17
21
  const MAX_SEGMENT_BYTES = 64;
18
- /** Reserved characters that MUST NOT appear inside a NAME segment (reference/03, /05 §NAME). */
22
+ /** @brief Reserved characters that MUST NOT appear inside a NAME segment (reference/03, /05 §NAME). */
19
23
  const RESERVED_SEGMENT_CHARS = /[/:.[\]*?]/;
20
24
  const utf8 = new TextEncoder();
21
25
  /**
22
- * A fully-cleared option byte (all flags false), with selected flags overridden.
26
+ * @brief A fully-cleared option byte (all flags false), with selected flags
27
+ * overridden.
28
+ *
23
29
  * Shared by the payload builders here and the FWD/FIELD builders in `./fwd.ts`.
24
30
  *
25
31
  * @param over flags to set true (e.g. `{ pl: true }` for a structured TLV)
@@ -29,7 +35,8 @@ export function opt(over = {}) {
29
35
  return { pl: false, ts: false, cr: false, ll: false, cw: false, tf: false, ...over };
30
36
  }
31
37
  /**
32
- * Build a VALUE TLV (`type=0x01`) carrying an opaque application payload.
38
+ * @brief Build a VALUE TLV (`type=0x01`) carrying an opaque application payload.
39
+ *
33
40
  * Vector-pinned: `value-bool-true`, `value-ll-u32`, `value-ts-abs`.
34
41
  *
35
42
  * @param value the opaque payload bytes (the publisher/subscriber agree on the shape out-of-band)
@@ -57,8 +64,8 @@ export function encodeValue(value, opts = {}) {
57
64
  return encode(tlv);
58
65
  }
59
66
  /**
60
- * Build a NAME TLV (`type=0x02`) for one path segment, after validating it
61
- * against the addressing rules (1..64 UTF-8 bytes, no reserved characters).
67
+ * @brief Build a NAME TLV (`type=0x02`) for one path segment, after validating
68
+ * it against the addressing rules (1..64 UTF-8 bytes, no reserved characters).
62
69
  *
63
70
  * @param segment the segment text
64
71
  * @returns a NAME TLV node (no trailer)
@@ -75,8 +82,10 @@ export function nameTlv(segment) {
75
82
  return { type: TYPE.NAME, opt: opt(), payload: bytes, children: [], trailer: null };
76
83
  }
77
84
  /**
78
- * Build a PATH TLV (`type=0x06`, PL=1) from path segments — a NAME child per
79
- * segment. Vector-pinned: `path-sensor-temp`; normative byte layout: spec/v1.md §3.1.
85
+ * @brief Build a PATH TLV (`type=0x06`, PL=1) from path segments — a NAME child
86
+ * per segment.
87
+ *
88
+ * Vector-pinned: `path-sensor-temp`; normative byte layout: spec/v1.md §3.1.
80
89
  *
81
90
  * @param segments the path segments, e.g. `["sensor", "temp"]` for `/sensor/temp`
82
91
  * @returns the encoded PATH TLV bytes
@@ -85,7 +94,7 @@ export function nameTlv(segment) {
85
94
  export function encodePath(segments) {
86
95
  return encode(pathTlv(segments));
87
96
  }
88
- /** The PATH TLV node (shared by {@link encodePath}, {@link encodeSubscriber}, and `./fwd.ts`). */
97
+ /** @brief The PATH TLV node (shared by {@link encodePath}, {@link encodeSubscriber}, and `./fwd.ts`). */
89
98
  export function pathTlv(segments) {
90
99
  if (segments.length < 1)
91
100
  throw new RangeError('a path must have at least one segment');
@@ -100,8 +109,10 @@ export function pathTlv(segments) {
100
109
  };
101
110
  }
102
111
  /**
103
- * Build a SUBSCRIBER TLV (`type=0x04`, PL=1) wrapping a target PATH — the
104
- * payload of a subscribe-write (reference/04 §Subscribe). Vector-pinned:
112
+ * @brief Build a SUBSCRIBER TLV (`type=0x04`, PL=1) wrapping a target PATH —
113
+ * the payload of a subscribe-write (reference/04 §Subscribe).
114
+ *
115
+ * Vector-pinned:
105
116
  * `subscriber-path` = `SUBSCRIBER{ PATH{ NAME "sensor", NAME "temp" } }`.
106
117
  *
107
118
  * The `targetPath` is the SUBSCRIBER's `target_path` child: where the producer
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@avatarsd-llc/libtracer-client",
3
- "version": "0.1.0",
3
+ "version": "0.4.0",
4
4
  "description": "EXPERIMENTAL libtracer client SDK (#56, ADR-0034/0035) — a path-addressed client over the cross-validated codec (@avatarsd-llc/libtracer) and an injected transport seam (e.g. @avatarsd-llc/libtracer-ws). Speaks the RFC-0004 remote operations over FWD: read / write / await / readField / subscribe, each a FWD frame whose source-routed FWD{REPLY} is decoded back. Pre-1.0 and experimental.",
5
5
  "author": "avatarsd LLC",
6
6
  "license": "Apache-2.0",
@@ -33,8 +33,8 @@
33
33
  "access": "public"
34
34
  },
35
35
  "peerDependencies": {
36
- "@avatarsd-llc/libtracer": "^0.0.1",
37
- "@avatarsd-llc/libtracer-ws": "^0.1.0"
36
+ "@avatarsd-llc/libtracer": ">=0.4.0 <0.5.0",
37
+ "@avatarsd-llc/libtracer-ws": ">=0.4.0 <0.5.0"
38
38
  },
39
39
  "peerDependenciesMeta": {
40
40
  "@avatarsd-llc/libtracer-ws": {