@band-ai/band-sdk-core 0.4.0 → 0.4.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/README.md ADDED
@@ -0,0 +1,99 @@
1
+ # @band-ai/band-sdk-core
2
+
3
+ Shared Band event-payload validation, memory-taxonomy, and inbound-delivery
4
+ runtime state, compiled from Rust to WebAssembly for Node. Every function
5
+ is synchronous, pure computation — no network, filesystem, or logging.
6
+
7
+ ```
8
+ band-sdk-core-core (Rust) --> @band-ai/band-sdk-core (this package, npm) --> band-sdk-typescript
9
+ ```
10
+
11
+ If you're using [`band-sdk-typescript`](https://github.com/band-ai/band-sdk-typescript),
12
+ it already depends on this package — you don't need to install it
13
+ yourself. Install it directly only if you're calling into it without that
14
+ SDK. Full picture: [repository architecture](https://github.com/band-ai/band-sdk-core#architecture).
15
+
16
+ ## Install
17
+
18
+ ```bash
19
+ npm install @band-ai/band-sdk-core
20
+ ```
21
+
22
+ The package is Node CommonJS with an eager WASM load — there is no `init`
23
+ step, and no Rust or `wasm-pack` toolchain needed to install. Both
24
+ `require()` and ESM `import()` resolve it at the package root.
25
+
26
+ ## Quickstart
27
+
28
+ ```js
29
+ const { validateEventPayload } = require("@band-ai/band-sdk-core");
30
+
31
+ try {
32
+ const payload = validateEventPayload("room_deleted", { id: "room-1" });
33
+ } catch (err) {
34
+ for (const { path, code, message } of err.issues) {
35
+ console.error(`${path}: ${code} - ${message}`);
36
+ }
37
+ }
38
+ ```
39
+
40
+ `validateEventPayload` is the platform's inbound WebSocket payload policy:
41
+ normalize a well-formed payload, or throw with every violation reported at
42
+ once, never just the first.
43
+
44
+ ## Public surface
45
+
46
+ ### `validateEventPayload(eventType, raw, traceContext?)`
47
+
48
+ `eventType` is the platform event name (`"message_created"`,
49
+ `"agent.control"`, …). `raw` is a plain JS value. Success returns the
50
+ normalized payload (`event_created` returns the input unchanged). Failure
51
+ throws a native `Error` with `.issues` (`{path, code, message}` objects)
52
+ and `.traceContext` — not a message-only error. There is no custom
53
+ exception class.
54
+
55
+ ### Delivery-state runtime classes
56
+
57
+ `ClaimRegistry`, `RetryTracker`, and `ParticipantRoster` are the
58
+ inbound-delivery runtime state classes — lifecycle and design decisions:
59
+ [`runtime-state-policy.md`](https://github.com/band-ai/band-sdk-core/blob/main/crates/core/docs/runtime-state-policy.md).
60
+
61
+ A participant is any plain object; `add`/`setAll` read `id`, `name`,
62
+ `type`, `handle`, `description` from it and `list()` returns objects with
63
+ exactly those five keys. `id` is required and must be a string; the other
64
+ four are each a string or `null`/absent. `setAll` takes an optional
65
+ `traceContext` and throws — leaving the roster unchanged, with `.issues`
66
+ and `.traceContext` attached like `validateEventPayload`'s error — if its
67
+ snapshot names the same `id` twice. `RetryTracker`'s `maxTracked` must be
68
+ at least `1`; `0` throws. `ClaimRegistry`'s `maxCompleted` must be at
69
+ least `1` too — `0` also throws.
70
+
71
+ ### `validateMemoryTypeForSystem(system, type, traceContext?)`
72
+
73
+ Validates the canonical memory taxonomy — design decisions:
74
+ [`memory-taxonomy-policy.md`](https://github.com/band-ai/band-sdk-core/blob/main/crates/core/docs/memory-taxonomy-policy.md).
75
+ `system` and `type` are wire-name strings (`MemorySystem`/`MemoryType` in
76
+ `index.d.ts` are string-literal types, not classes — there is no runtime
77
+ enum on this boundary, matching how `EventType` stays a plain string in
78
+ `validateEventPayload`). Returns `void` on success. Failure throws a
79
+ native `Error` with the same `.issues`/`.traceContext` contract as
80
+ `validateEventPayload` — an unrecognized `system` and an unrecognized
81
+ `type` are independent issues, both reported when both strings are
82
+ invalid.
83
+
84
+ The public declaration is
85
+ [`index.d.ts`](https://github.com/band-ai/band-sdk-core/blob/main/crates/wasm/index.d.ts).
86
+
87
+ ## Build / test
88
+
89
+ `just check` compiles and lints this crate for the host.
90
+
91
+ ```bash
92
+ just test-wasm # suite in Node
93
+ just pack-npm # Node tarball + require/import consumers
94
+ just build-wasm # Node package output
95
+ ```
96
+
97
+ ## License
98
+
99
+ MIT — see [LICENSE](https://github.com/band-ai/band-sdk-core/blob/main/LICENSE).
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@band-ai/band-sdk-core",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "Shared Band event-payload validation",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -10,7 +10,8 @@
10
10
  "files": [
11
11
  "band_sdk_core.js",
12
12
  "band_sdk_core_bg.wasm",
13
- "index.d.ts"
13
+ "index.d.ts",
14
+ "README.md"
14
15
  ],
15
16
  "main": "./band_sdk_core.js",
16
17
  "types": "./index.d.ts",