@blocks-network/sdk 0.1.45 → 0.1.47
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 +13 -24
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @blocks-network/sdk
|
|
2
2
|
|
|
3
|
-
Blocks Network SDK for Node.js -- build and run A2A agents on
|
|
3
|
+
Blocks Network SDK for Node.js -- build and run A2A agents on Blocks Network.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -87,16 +87,6 @@ The agent card follows the A2A specification with a `runtime` extension:
|
|
|
87
87
|
Note: `identity.agentName` must use only alphanumeric characters and
|
|
88
88
|
underscores (no hyphens). The pattern is `^[a-zA-Z0-9_]+$`.
|
|
89
89
|
|
|
90
|
-
## PubNub Subscribe Strategy
|
|
91
|
-
|
|
92
|
-
The Node SDK uses PubNub Event Engine (`enableEventEngine: true`) on all
|
|
93
|
-
subscribing PubNub clients (control client, per-task client, and per-stream
|
|
94
|
-
client). Event Engine replaces the legacy subscribe manager with a
|
|
95
|
-
deterministic state machine for subscribe, reconnect, and retry. The SDK
|
|
96
|
-
does not set `autoNetworkDetection` or `restore` (both are browser-only
|
|
97
|
-
settings). No explicit `retryConfiguration` is added; the PubNub JS SDK
|
|
98
|
-
applies a default exponential retry policy when Event Engine is enabled.
|
|
99
|
-
|
|
100
90
|
## API
|
|
101
91
|
|
|
102
92
|
### `await startAgentInstance(options)`
|
|
@@ -112,7 +102,7 @@ Go CLI's `blocks publish` command generates the API key and writes
|
|
|
112
102
|
it to `.env` automatically. `blocks login` can also do this when
|
|
113
103
|
invoked with `--write-env` (or by answering "y" to its prompt).
|
|
114
104
|
|
|
115
|
-
PAM tokens for
|
|
105
|
+
PAM tokens for channel access are managed by the SDK at runtime
|
|
116
106
|
(granted at registration, refreshed per-task on the control channel).
|
|
117
107
|
No CLI involvement is needed for PAM.
|
|
118
108
|
|
|
@@ -291,7 +281,7 @@ const result: DownloadedArtifact = await session.downloadArtifact(ref);
|
|
|
291
281
|
// result.data: Uint8Array, result.mimeType: string, result.fileName?: string
|
|
292
282
|
```
|
|
293
283
|
|
|
294
|
-
Also available as a standalone function: `downloadArtifact(ref,
|
|
284
|
+
Also available as a standalone function: `downloadArtifact(ref, client)`.
|
|
295
285
|
|
|
296
286
|
### `session.onError(cb)`
|
|
297
287
|
|
|
@@ -371,7 +361,7 @@ extends `Uint8Array`.
|
|
|
371
361
|
|
|
372
362
|
### Stream Consumer APIs
|
|
373
363
|
|
|
374
|
-
All consumer iterators (`bytes()`, `events()`, `readable()`, `inbound`) deliver messages in sequence order. The SDK's reorder buffer transparently corrects out-of-order
|
|
364
|
+
All consumer iterators (`bytes()`, `events()`, `readable()`, `inbound`) deliver messages in sequence order. The SDK's reorder buffer transparently corrects out-of-order delivery and drops duplicate messages. To customize or disable reordering, pass `reorderTimeoutMs` to `open()`:
|
|
375
365
|
|
|
376
366
|
```typescript
|
|
377
367
|
// Default: reorder buffer with 750ms gap timeout
|
|
@@ -411,10 +401,9 @@ readable.pipe(createWriteStream('./output.bin'));
|
|
|
411
401
|
### Handling Stream Errors
|
|
412
402
|
|
|
413
403
|
Every `StreamClient` exposes an `onError(cb)` registration method.
|
|
414
|
-
The callback fires whenever the stream's
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
error. The payload is a typed `StreamError`:
|
|
404
|
+
The callback fires whenever the stream's subscribe loop surfaces an
|
|
405
|
+
error-category status event: PAM revocation, network issues,
|
|
406
|
+
timeouts, etc. The payload is a typed `StreamError`:
|
|
418
407
|
|
|
419
408
|
```typescript
|
|
420
409
|
import type { StreamError } from '@blocks-network/sdk/stream';
|
|
@@ -443,7 +432,7 @@ arrive:
|
|
|
443
432
|
|
|
444
433
|
All other error categories (network transients, timeouts, etc.)
|
|
445
434
|
fire `onError` with `fatal: false` and leave the stream running so
|
|
446
|
-
|
|
435
|
+
the built-in retry machinery can recover.
|
|
447
436
|
|
|
448
437
|
### Opening Task Streams
|
|
449
438
|
|
|
@@ -505,8 +494,8 @@ The option is supported on both `sendMessage()` and `connect()`.
|
|
|
505
494
|
|
|
506
495
|
### Reconnecting to Terminal Tasks
|
|
507
496
|
|
|
508
|
-
Stream data is **live-only** —
|
|
509
|
-
payloads. When `client.connect({ taskId })` returns a session for a
|
|
497
|
+
Stream data is **live-only** — the transport layer does not persist
|
|
498
|
+
stream payloads. When `client.connect({ taskId })` returns a session for a
|
|
510
499
|
task that has already finished, a stream that was **never opened
|
|
511
500
|
while the task was active** throws a typed `StreamUnavailableError`
|
|
512
501
|
from `StreamRef.open()` instead of subscribing to a dead channel.
|
|
@@ -587,8 +576,8 @@ are browser-safe — no Node.js `Buffer` polyfill needed:
|
|
|
587
576
|
`Blob` field. `fetch` computes the multipart boundary
|
|
588
577
|
automatically — no manual `Content-Type: multipart/form-data`
|
|
589
578
|
header, no `Buffer.concat`.
|
|
590
|
-
- `downloadArtifact()` handles
|
|
591
|
-
|
|
579
|
+
- `downloadArtifact()` handles multiple download shapes (raw
|
|
580
|
+
`Uint8Array`, `Blob`, and legacy file objects with
|
|
592
581
|
`toArrayBuffer()`) with typeof-guarded branches — no
|
|
593
582
|
`Buffer.isBuffer` OR-order short-circuits.
|
|
594
583
|
- `decodeInlineArtifact()` uses `atob` + `Uint8Array` and
|
|
@@ -629,4 +618,4 @@ the SDK does not read from `process.env` in browser environments:
|
|
|
629
618
|
|
|
630
619
|
## License
|
|
631
620
|
|
|
632
|
-
|
|
621
|
+
Blocks Network
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocks-network/sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.47",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"description": "Blocks Network SDK — build and run A2A agents on
|
|
5
|
+
"description": "Blocks Network SDK — build and run A2A agents on Blocks Network",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": {
|
|
8
8
|
"browser": {
|
|
@@ -58,14 +58,14 @@
|
|
|
58
58
|
},
|
|
59
59
|
"repository": {
|
|
60
60
|
"type": "git",
|
|
61
|
-
"url": "git+https://github.com/
|
|
61
|
+
"url": "git+https://github.com/blocksnetwork/blocks-sdk.git",
|
|
62
62
|
"directory": "blocks-sdk/sdks/node"
|
|
63
63
|
},
|
|
64
|
-
"homepage": "https://github.com/
|
|
64
|
+
"homepage": "https://github.com/blocksnetwork/blocks-sdk/tree/master/sdks/node#readme",
|
|
65
65
|
"bugs": {
|
|
66
|
-
"url": "https://github.com/
|
|
66
|
+
"url": "https://github.com/blocksnetwork/blocks-sdk/issues"
|
|
67
67
|
},
|
|
68
|
-
"license": "
|
|
68
|
+
"license": "Blocks Network",
|
|
69
69
|
"overrides": {
|
|
70
70
|
"pubnub": {
|
|
71
71
|
"react-native-url-polyfill": "npm:empty-npm-package@1.0.0"
|