@band-ai/band-sdk-core 0.4.0-dev.2 → 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 CHANGED
@@ -1,46 +1,88 @@
1
- # band-sdk-core-wasm
1
+ # @band-ai/band-sdk-core
2
2
 
3
- JavaScript package for [`band-sdk-core-core`](../core), published as
4
- `@band-ai/band-sdk-core` for Node.
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.
5
43
 
6
44
  ## Public surface
7
45
 
8
- `validateEventPayload(eventType, raw, traceContext?)`. `eventType` is the
9
- platform event name (`"message_created"`, `"agent.control"`, …). `raw` is a
10
- plain JS value. Success returns the normalized payload (`event_created`
11
- returns the input unchanged). Failure throws a native `Error` with
12
- `.issues` (`{path, code, message}` objects) and `.traceContext` not a
13
- message-only error. There is no custom exception class.
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
14
56
 
15
57
  `ClaimRegistry`, `RetryTracker`, and `ParticipantRoster` are the
16
- inbound-delivery runtime state classes -- lifecycle and design decisions:
17
- [`../core/docs/runtime-state-policy.md`](../core/docs/runtime-state-policy.md).
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
+
18
61
  A participant is any plain object; `add`/`setAll` read `id`, `name`,
19
62
  `type`, `handle`, `description` from it and `list()` returns objects with
20
63
  exactly those five keys. `id` is required and must be a string; the other
21
64
  four are each a string or `null`/absent. `setAll` takes an optional
22
- `traceContext` and throws -- leaving the roster unchanged, with `.issues`
23
- and `.traceContext` attached like `validateEventPayload`'s error -- if its
65
+ `traceContext` and throws leaving the roster unchanged, with `.issues`
66
+ and `.traceContext` attached like `validateEventPayload`'s error if its
24
67
  snapshot names the same `id` twice. `RetryTracker`'s `maxTracked` must be
25
68
  at least `1`; `0` throws. `ClaimRegistry`'s `maxCompleted` must be at
26
- least `1` too -- `0` also throws.
69
+ least `1` too `0` also throws.
70
+
71
+ ### `validateMemoryTypeForSystem(system, type, traceContext?)`
27
72
 
28
- `validateMemoryTypeForSystem(system, type, traceContext?)` validates the
29
- canonical memory taxonomy -- design decisions:
30
- [`../core/docs/memory-taxonomy-policy.md`](../core/docs/memory-taxonomy-policy.md).
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).
31
75
  `system` and `type` are wire-name strings (`MemorySystem`/`MemoryType` in
32
- `index.d.ts` are string-literal types, not classes -- there is no runtime
76
+ `index.d.ts` are string-literal types, not classes there is no runtime
33
77
  enum on this boundary, matching how `EventType` stays a plain string in
34
78
  `validateEventPayload`). Returns `void` on success. Failure throws a
35
79
  native `Error` with the same `.issues`/`.traceContext` contract as
36
- `validateEventPayload` -- an unrecognized `system` and an unrecognized
80
+ `validateEventPayload` an unrecognized `system` and an unrecognized
37
81
  `type` are independent issues, both reported when both strings are
38
82
  invalid.
39
83
 
40
- The package is Node CommonJS with an eager WASM load. There is no default
41
- `init`. The public declaration is `index.d.ts`:
42
- `validateEventPayload(...): unknown`. Node `require()` and ESM `import()`
43
- both resolve `@band-ai/band-sdk-core` at the package root.
84
+ The public declaration is
85
+ [`index.d.ts`](https://github.com/band-ai/band-sdk-core/blob/main/crates/wasm/index.d.ts).
44
86
 
45
87
  ## Build / test
46
88
 
@@ -51,3 +93,7 @@ just test-wasm # suite in Node
51
93
  just pack-npm # Node tarball + require/import consumers
52
94
  just build-wasm # Node package output
53
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-dev.2",
3
+ "version": "0.4.1",
4
4
  "description": "Shared Band event-payload validation",
5
5
  "license": "MIT",
6
6
  "repository": {