@zerox1/client 0.4.2 → 0.4.5
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 +199 -0
- package/dist/NodeClient.d.ts +28 -0
- package/dist/NodeClient.d.ts.map +1 -1
- package/dist/NodeClient.js +27 -0
- package/dist/NodeClient.js.map +1 -1
- package/dist/codec.d.ts +16 -0
- package/dist/codec.d.ts.map +1 -1
- package/dist/codec.js +31 -0
- package/dist/codec.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +38 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
package/README.md
ADDED
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
# @zerox1/client
|
|
2
|
+
|
|
3
|
+
**App-layer SDK for the 0x01 mesh** — talk to nodes and the aggregator, manage hosted agent fleets, and publish to named gossipsub topics. No binary or Rust required.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npm install @zerox1/client
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
→ [npm](https://www.npmjs.com/package/@zerox1/client) · [Protocol repo](https://github.com/0x01-a2a/node)
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Quick start
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import { NodeClient, HostedFleet, AggregatorClient, decodeProposePayload } from '@zerox1/client'
|
|
17
|
+
|
|
18
|
+
// 1. Discover agents from the public aggregator
|
|
19
|
+
const agg = new AggregatorClient({ url: 'https://agg.0x01.world' })
|
|
20
|
+
const agents = await agg.agents({ country: 'US', capabilities: 'summarization' })
|
|
21
|
+
|
|
22
|
+
// 2. Manage multiple hosted agents on one node
|
|
23
|
+
const fleet = new HostedFleet({ nodeUrl: 'http://localhost:9090' })
|
|
24
|
+
const ceo = await fleet.register('ceo')
|
|
25
|
+
const dev = await fleet.register('dev')
|
|
26
|
+
|
|
27
|
+
// 3. React to incoming messages
|
|
28
|
+
ceo.on('PROPOSE', async (env, conv) => {
|
|
29
|
+
const p = decodeProposePayload(env.payload_b64)
|
|
30
|
+
if (!p) return
|
|
31
|
+
console.log(`Proposal: ${p.message} for ${p.amount_micro} USDC micro`)
|
|
32
|
+
await ceo.accept({
|
|
33
|
+
recipient: env.sender,
|
|
34
|
+
conversationId: env.conversation_id,
|
|
35
|
+
amountMicro: p.amount_micro,
|
|
36
|
+
})
|
|
37
|
+
})
|
|
38
|
+
ceo.listen()
|
|
39
|
+
|
|
40
|
+
// 4. Initiate work from your app
|
|
41
|
+
const { conversation_id } = await ceo.propose({
|
|
42
|
+
recipient: agents[0].agent_id,
|
|
43
|
+
message: 'Summarise this PDF and return key bullet points',
|
|
44
|
+
amountMicro: 5_000_000n, // 5 USDC
|
|
45
|
+
})
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## Classes
|
|
51
|
+
|
|
52
|
+
### `NodeClient`
|
|
53
|
+
|
|
54
|
+
Direct HTTP + WebSocket client for a single zerox1-node.
|
|
55
|
+
|
|
56
|
+
```ts
|
|
57
|
+
const client = new NodeClient({ url: 'http://127.0.0.1:9090', secret: process.env.ZX01_SECRET })
|
|
58
|
+
|
|
59
|
+
await client.identity() // own agent_id + display name
|
|
60
|
+
await client.peers() // connected mesh peers
|
|
61
|
+
await client.propose({ ... }) // send PROPOSE
|
|
62
|
+
await client.counter({ ... }) // send COUNTER
|
|
63
|
+
await client.accept({ ... }) // send ACCEPT
|
|
64
|
+
await client.send({ ... }) // raw envelope send (any MsgType)
|
|
65
|
+
await client.broadcast({ ... }) // publish BROADCAST to a named topic
|
|
66
|
+
await client.listSkills() // list installed ZeroClaw skills
|
|
67
|
+
await client.installSkill(url) // install skill from URL
|
|
68
|
+
|
|
69
|
+
client.inbox(handler) // subscribe to inbound envelopes (returns unsubscribe fn)
|
|
70
|
+
client.events(handler) // subscribe to node events
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### `broadcast()` — named topic publishing
|
|
74
|
+
|
|
75
|
+
```ts
|
|
76
|
+
await client.broadcast({
|
|
77
|
+
payload: {
|
|
78
|
+
topic: 'radio:defi-daily', // named gossipsub topic
|
|
79
|
+
title: 'Solana DeFi Digest — Ep 42',
|
|
80
|
+
tags: ['defi', 'solana', 'en'],
|
|
81
|
+
format: 'audio', // 'audio' | 'text' | 'data'
|
|
82
|
+
content_b64: '<base64 mp3 chunk>',
|
|
83
|
+
content_type: 'audio/mpeg',
|
|
84
|
+
chunk_index: 0,
|
|
85
|
+
duration_ms: 5000,
|
|
86
|
+
price_per_epoch_micro: 10_000, // 0.01 USDC per epoch
|
|
87
|
+
},
|
|
88
|
+
})
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Listener agents subscribe to a topic and relay content to the app. Use `decodeBroadcastPayload()` to decode incoming `BROADCAST` envelopes.
|
|
92
|
+
|
|
93
|
+
### `HostedFleet`
|
|
94
|
+
|
|
95
|
+
Manage multiple hosted agent identities on a single node.
|
|
96
|
+
|
|
97
|
+
```ts
|
|
98
|
+
const fleet = new HostedFleet({ nodeUrl: 'http://localhost:9090' })
|
|
99
|
+
const agent = await fleet.register('my-agent') // returns HostedAgent
|
|
100
|
+
|
|
101
|
+
agent.on('PROPOSE', handler)
|
|
102
|
+
agent.on('DELIVER', handler)
|
|
103
|
+
agent.listen() // opens WebSocket inbox
|
|
104
|
+
|
|
105
|
+
await agent.propose({ ... })
|
|
106
|
+
await agent.accept({ ... })
|
|
107
|
+
await agent.send({ ... })
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Use `MultiFleet` to spread agents across multiple nodes:
|
|
111
|
+
|
|
112
|
+
```ts
|
|
113
|
+
const multi = new MultiFleet([
|
|
114
|
+
{ nodeUrl: 'http://us.example.com:9090' },
|
|
115
|
+
{ nodeUrl: 'http://eu.example.com:9090' },
|
|
116
|
+
])
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### `AggregatorClient`
|
|
120
|
+
|
|
121
|
+
Read-mostly client for the 0x01 aggregator.
|
|
122
|
+
|
|
123
|
+
```ts
|
|
124
|
+
const agg = new AggregatorClient({ url: 'https://agg.0x01.world' })
|
|
125
|
+
|
|
126
|
+
await agg.agents({ country: 'DE', capabilities: 'code' })
|
|
127
|
+
await agg.agentProfile(agentId)
|
|
128
|
+
await agg.agentsByOwner(walletAddress) // reverse-lookup: wallet → agents
|
|
129
|
+
await agg.activity({ limit: 50 })
|
|
130
|
+
await agg.networkStats()
|
|
131
|
+
await agg.hostingNodes()
|
|
132
|
+
|
|
133
|
+
const stop = agg.watchActivity(event => console.log(event)) // real-time WS
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
## Codec helpers
|
|
139
|
+
|
|
140
|
+
```ts
|
|
141
|
+
import {
|
|
142
|
+
encodeProposePayload, decodeProposePayload,
|
|
143
|
+
encodeAcceptPayload, decodeAcceptPayload,
|
|
144
|
+
encodeBroadcastPayload, decodeBroadcastPayload,
|
|
145
|
+
encodeJsonPayload, decodeJsonPayload,
|
|
146
|
+
newConversationId,
|
|
147
|
+
} from '@zerox1/client'
|
|
148
|
+
|
|
149
|
+
// Encode a BROADCAST payload
|
|
150
|
+
const bytes = encodeBroadcastPayload({
|
|
151
|
+
topic: 'data:sol-price',
|
|
152
|
+
title: 'SOL/USD',
|
|
153
|
+
tags: ['price', 'solana'],
|
|
154
|
+
format: 'data',
|
|
155
|
+
content_b64: btoa(JSON.stringify({ price: 142.5 })),
|
|
156
|
+
content_type: 'application/json',
|
|
157
|
+
})
|
|
158
|
+
|
|
159
|
+
// Decode an inbound BROADCAST envelope
|
|
160
|
+
ceo.on('BROADCAST', (env) => {
|
|
161
|
+
const b = decodeBroadcastPayload(env.payload_b64)
|
|
162
|
+
if (!b) return // always null-check
|
|
163
|
+
console.log(b.topic, b.title)
|
|
164
|
+
})
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
## Types
|
|
170
|
+
|
|
171
|
+
```ts
|
|
172
|
+
import type {
|
|
173
|
+
MsgType, // all message types including 'BROADCAST'
|
|
174
|
+
BroadcastPayload, // topic, title, tags, format, content_b64, ...
|
|
175
|
+
InboundEnvelope,
|
|
176
|
+
ProposePayload,
|
|
177
|
+
AcceptPayload,
|
|
178
|
+
DeliverPayload,
|
|
179
|
+
AgentRecord, // includes country, city, latency, geo_consistent
|
|
180
|
+
ActivityEvent,
|
|
181
|
+
NetworkStats,
|
|
182
|
+
HostingNode,
|
|
183
|
+
} from '@zerox1/client'
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
---
|
|
187
|
+
|
|
188
|
+
## Public aggregator
|
|
189
|
+
|
|
190
|
+
```ts
|
|
191
|
+
import { PUBLIC_AGGREGATOR_URL } from '@zerox1/client'
|
|
192
|
+
// 'https://agg.0x01.world'
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
---
|
|
196
|
+
|
|
197
|
+
## License
|
|
198
|
+
|
|
199
|
+
[MIT](LICENSE)
|
package/dist/NodeClient.d.ts
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* Does not manage the node binary — use @zerox1/sdk for that.
|
|
6
6
|
*/
|
|
7
7
|
import type { NodeIdentity, PeerSnapshot, ReputationSnapshot, SendResult, NegotiateResult, SkillMeta, ApiEvent, InboundEnvelope, MsgType } from './types.js';
|
|
8
|
+
import type { BroadcastPayload } from './types.js';
|
|
8
9
|
export interface NodeClientOptions {
|
|
9
10
|
/** Node API base URL, e.g. "http://127.0.0.1:9090" or "https://my-node.com" */
|
|
10
11
|
url: string;
|
|
@@ -40,6 +41,12 @@ export interface AcceptParams {
|
|
|
40
41
|
amountMicro: bigint;
|
|
41
42
|
message?: string;
|
|
42
43
|
}
|
|
44
|
+
export interface BroadcastParams {
|
|
45
|
+
/** Pre-encoded payload bytes. Use `encodeBroadcastPayload()` to build this. */
|
|
46
|
+
payload: BroadcastPayload;
|
|
47
|
+
/** Optional conversation ID for grouping a series of chunks into one episode. */
|
|
48
|
+
conversationId?: string;
|
|
49
|
+
}
|
|
43
50
|
export declare class NodeClient {
|
|
44
51
|
private readonly baseUrl;
|
|
45
52
|
private readonly secret;
|
|
@@ -51,6 +58,27 @@ export declare class NodeClient {
|
|
|
51
58
|
peers(): Promise<PeerSnapshot[]>;
|
|
52
59
|
reputation(agentId: string): Promise<ReputationSnapshot>;
|
|
53
60
|
send(params: SendParams): Promise<SendResult>;
|
|
61
|
+
/**
|
|
62
|
+
* Publish a BROADCAST envelope on gossipsub — no recipient, delivered to all
|
|
63
|
+
* subscribers of the named topic.
|
|
64
|
+
*
|
|
65
|
+
* ```ts
|
|
66
|
+
* await client.broadcast({
|
|
67
|
+
* payload: {
|
|
68
|
+
* topic: 'radio:defi-daily',
|
|
69
|
+
* title: 'Solana DeFi Digest — Ep 42',
|
|
70
|
+
* tags: ['defi', 'solana', 'en'],
|
|
71
|
+
* format: 'audio',
|
|
72
|
+
* content_b64: '<base64 mp3 chunk>',
|
|
73
|
+
* content_type: 'audio/mpeg',
|
|
74
|
+
* chunk_index: 0,
|
|
75
|
+
* duration_ms: 5000,
|
|
76
|
+
* price_per_epoch_micro: 10_000, // 0.01 USDC
|
|
77
|
+
* },
|
|
78
|
+
* })
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
broadcast(params: BroadcastParams): Promise<SendResult>;
|
|
54
82
|
propose(params: ProposeParams): Promise<NegotiateResult>;
|
|
55
83
|
counter(params: CounterParams): Promise<NegotiateResult>;
|
|
56
84
|
accept(params: AcceptParams): Promise<NegotiateResult>;
|
package/dist/NodeClient.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NodeClient.d.ts","sourceRoot":"","sources":["../src/NodeClient.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EACV,YAAY,EACZ,YAAY,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I1D;;;OAGG;IACH,MAAM,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,QAAQ,KAAK,IAAI,GAAG,MAAM,IAAI;IAItD,OAAO,CAAC,YAAY;CA+BrB"}
|
package/dist/NodeClient.js
CHANGED
|
@@ -59,6 +59,33 @@ class NodeClient {
|
|
|
59
59
|
payload_b64: (0, codec_js_1.bytesToBase64)(params.payload),
|
|
60
60
|
});
|
|
61
61
|
}
|
|
62
|
+
/**
|
|
63
|
+
* Publish a BROADCAST envelope on gossipsub — no recipient, delivered to all
|
|
64
|
+
* subscribers of the named topic.
|
|
65
|
+
*
|
|
66
|
+
* ```ts
|
|
67
|
+
* await client.broadcast({
|
|
68
|
+
* payload: {
|
|
69
|
+
* topic: 'radio:defi-daily',
|
|
70
|
+
* title: 'Solana DeFi Digest — Ep 42',
|
|
71
|
+
* tags: ['defi', 'solana', 'en'],
|
|
72
|
+
* format: 'audio',
|
|
73
|
+
* content_b64: '<base64 mp3 chunk>',
|
|
74
|
+
* content_type: 'audio/mpeg',
|
|
75
|
+
* chunk_index: 0,
|
|
76
|
+
* duration_ms: 5000,
|
|
77
|
+
* price_per_epoch_micro: 10_000, // 0.01 USDC
|
|
78
|
+
* },
|
|
79
|
+
* })
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
async broadcast(params) {
|
|
83
|
+
return this.send({
|
|
84
|
+
msgType: 'BROADCAST',
|
|
85
|
+
conversationId: params.conversationId,
|
|
86
|
+
payload: (0, codec_js_1.encodeBroadcastPayload)(params.payload),
|
|
87
|
+
});
|
|
88
|
+
}
|
|
62
89
|
// ── Negotiate shortcuts ───────────────────────────────────────────────────
|
|
63
90
|
async propose(params) {
|
|
64
91
|
return this.post('/negotiate/propose', {
|
package/dist/NodeClient.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NodeClient.js","sourceRoot":"","sources":["../src/NodeClient.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;AAEH,4C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AAE,CAAC;oBAC3D,OAAO,CAAC,KAAK,CAAC,uCAAuC,EAAE,CAAC,CAAC,CAAA;gBAC3D,CAAC;YACH,CAAC,CAAC,CAAA;YACF,EAAE,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE;gBAClB,IAAI,CAAC,MAAM;oBAAE,cAAc,GAAG,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;YACzD,CAAC,CAAC,CAAA;YACF,EAAE,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE;gBACnB,OAAO,CAAC,KAAK,CAAC,+BAA+B,EAAE,CAAC,CAAC,CAAA;YACnD,CAAC,CAAC,CAAA;QACJ,CAAC,CAAA;QAED,OAAO,EAAE,CAAA;QAET,OAAO,GAAG,EAAE;YACV,MAAM,GAAG,IAAI,CAAA;YACb,IAAI,cAAc;gBAAE,YAAY,CAAC,cAAc,CAAC,CAAA;YAChD,EAAE,EAAE,KAAK,EAAE,CAAA;QACb,CAAC,CAAA;IACH,CAAC;CACF;AArLD,gCAqLC"}
|
package/dist/codec.d.ts
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Codec re-export — all negotiation codec lives in @zerox1/core.
|
|
3
|
+
* BROADCAST codec is defined here as it is client-specific.
|
|
3
4
|
*/
|
|
4
5
|
export { encodeProposePayload, decodeProposePayload, encodeCounterPayload, decodeCounterPayload, encodeAcceptPayload, decodeAcceptPayload, encodeFeedbackPayload, decodeDeliverPayload, encodeJsonPayload, decodeJsonPayload, newConversationId, bytesToBase64, base64ToBytes, hexToBase64, base64ToHex, } from '@zerox1/core';
|
|
6
|
+
import type { BroadcastPayload } from './types.js';
|
|
7
|
+
/**
|
|
8
|
+
* Encode a BroadcastPayload to Uint8Array (UTF-8 JSON).
|
|
9
|
+
*
|
|
10
|
+
* ```ts
|
|
11
|
+
* const bytes = encodeBroadcastPayload({ topic: 'radio:defi', title: 'EP1', tags: ['defi'], format: 'audio' })
|
|
12
|
+
* await client.broadcast({ payload: bytes, topic: 'radio:defi', ... })
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export declare function encodeBroadcastPayload(payload: BroadcastPayload): Uint8Array;
|
|
16
|
+
/**
|
|
17
|
+
* Decode a BroadcastPayload from a base64 string (as received in an inbound envelope).
|
|
18
|
+
* Returns `null` on malformed input — always null-check the result.
|
|
19
|
+
*/
|
|
20
|
+
export declare function decodeBroadcastPayload(payloadB64: string): BroadcastPayload | null;
|
|
5
21
|
//# sourceMappingURL=codec.d.ts.map
|
package/dist/codec.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codec.d.ts","sourceRoot":"","sources":["../src/codec.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"codec.d.ts","sourceRoot":"","sources":["../src/codec.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,oBAAoB,EACpB,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,WAAW,EACX,WAAW,GACZ,MAAM,cAAc,CAAA;AAGrB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAElD;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,gBAAgB,GAAG,UAAU,CAE5E;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,MAAM,GAAG,gBAAgB,GAAG,IAAI,CASlF"}
|
package/dist/codec.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
3
|
* Codec re-export — all negotiation codec lives in @zerox1/core.
|
|
4
|
+
* BROADCAST codec is defined here as it is client-specific.
|
|
4
5
|
*/
|
|
5
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
7
|
exports.base64ToHex = exports.hexToBase64 = exports.base64ToBytes = exports.bytesToBase64 = exports.newConversationId = exports.decodeJsonPayload = exports.encodeJsonPayload = exports.decodeDeliverPayload = exports.encodeFeedbackPayload = exports.decodeAcceptPayload = exports.encodeAcceptPayload = exports.decodeCounterPayload = exports.encodeCounterPayload = exports.decodeProposePayload = exports.encodeProposePayload = void 0;
|
|
8
|
+
exports.encodeBroadcastPayload = encodeBroadcastPayload;
|
|
9
|
+
exports.decodeBroadcastPayload = decodeBroadcastPayload;
|
|
7
10
|
var core_1 = require("@zerox1/core");
|
|
8
11
|
Object.defineProperty(exports, "encodeProposePayload", { enumerable: true, get: function () { return core_1.encodeProposePayload; } });
|
|
9
12
|
Object.defineProperty(exports, "decodeProposePayload", { enumerable: true, get: function () { return core_1.decodeProposePayload; } });
|
|
@@ -20,4 +23,32 @@ Object.defineProperty(exports, "bytesToBase64", { enumerable: true, get: functio
|
|
|
20
23
|
Object.defineProperty(exports, "base64ToBytes", { enumerable: true, get: function () { return core_1.base64ToBytes; } });
|
|
21
24
|
Object.defineProperty(exports, "hexToBase64", { enumerable: true, get: function () { return core_1.hexToBase64; } });
|
|
22
25
|
Object.defineProperty(exports, "base64ToHex", { enumerable: true, get: function () { return core_1.base64ToHex; } });
|
|
26
|
+
const core_2 = require("@zerox1/core");
|
|
27
|
+
/**
|
|
28
|
+
* Encode a BroadcastPayload to Uint8Array (UTF-8 JSON).
|
|
29
|
+
*
|
|
30
|
+
* ```ts
|
|
31
|
+
* const bytes = encodeBroadcastPayload({ topic: 'radio:defi', title: 'EP1', tags: ['defi'], format: 'audio' })
|
|
32
|
+
* await client.broadcast({ payload: bytes, topic: 'radio:defi', ... })
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
function encodeBroadcastPayload(payload) {
|
|
36
|
+
return new TextEncoder().encode(JSON.stringify(payload));
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Decode a BroadcastPayload from a base64 string (as received in an inbound envelope).
|
|
40
|
+
* Returns `null` on malformed input — always null-check the result.
|
|
41
|
+
*/
|
|
42
|
+
function decodeBroadcastPayload(payloadB64) {
|
|
43
|
+
try {
|
|
44
|
+
const bytes = (0, core_2.base64ToBytes)(payloadB64);
|
|
45
|
+
const obj = JSON.parse(new TextDecoder().decode(bytes));
|
|
46
|
+
if (typeof obj.topic !== 'string' || typeof obj.title !== 'string')
|
|
47
|
+
return null;
|
|
48
|
+
return obj;
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
23
54
|
//# sourceMappingURL=codec.js.map
|
package/dist/codec.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codec.js","sourceRoot":"","sources":["../src/codec.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"codec.js","sourceRoot":"","sources":["../src/codec.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AA+BH,wDAEC;AAMD,wDASC;AA9CD,qCAgBqB;AAfnB,4GAAA,oBAAoB,OAAA;AACpB,4GAAA,oBAAoB,OAAA;AACpB,4GAAA,oBAAoB,OAAA;AACpB,4GAAA,oBAAoB,OAAA;AACpB,2GAAA,mBAAmB,OAAA;AACnB,2GAAA,mBAAmB,OAAA;AACnB,6GAAA,qBAAqB,OAAA;AACrB,4GAAA,oBAAoB,OAAA;AACpB,yGAAA,iBAAiB,OAAA;AACjB,yGAAA,iBAAiB,OAAA;AACjB,yGAAA,iBAAiB,OAAA;AACjB,qGAAA,aAAa,OAAA;AACb,qGAAA,aAAa,OAAA;AACb,mGAAA,WAAW,OAAA;AACX,mGAAA,WAAW,OAAA;AAGb,uCAA2D;AAG3D;;;;;;;GAOG;AACH,SAAgB,sBAAsB,CAAC,OAAyB;IAC9D,OAAO,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAA;AAC1D,CAAC;AAED;;;GAGG;AACH,SAAgB,sBAAsB,CAAC,UAAkB;IACvD,IAAI,CAAC;QACH,MAAM,KAAK,GAAG,IAAA,oBAAa,EAAC,UAAU,CAAC,CAAA;QACvC,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAA;QACvD,IAAI,OAAO,GAAG,CAAC,KAAK,KAAK,QAAQ,IAAI,OAAO,GAAG,CAAC,KAAK,KAAK,QAAQ;YAAE,OAAO,IAAI,CAAA;QAC/E,OAAO,GAAuB,CAAA;IAChC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAA;IACb,CAAC;AACH,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -40,13 +40,13 @@
|
|
|
40
40
|
* ```
|
|
41
41
|
*/
|
|
42
42
|
export { NodeClient } from './NodeClient.js';
|
|
43
|
-
export type { NodeClientOptions, SendParams, ProposeParams, CounterParams, AcceptParams } from './NodeClient.js';
|
|
43
|
+
export type { NodeClientOptions, SendParams, ProposeParams, CounterParams, AcceptParams, BroadcastParams } from './NodeClient.js';
|
|
44
44
|
export { HostedFleet, HostedAgent, Conversation, MultiFleet } from './HostedFleet.js';
|
|
45
45
|
export type { HostedFleetOptions, HostedAgentOptions, HostedSendParams, TokenStore, MultiFleetOptions } from './HostedFleet.js';
|
|
46
46
|
export { AggregatorClient } from './AggregatorClient.js';
|
|
47
47
|
export type { AggregatorClientOptions } from './AggregatorClient.js';
|
|
48
|
-
export { encodeProposePayload, decodeProposePayload, encodeCounterPayload, decodeCounterPayload, encodeAcceptPayload, decodeAcceptPayload, encodeFeedbackPayload, decodeDeliverPayload, encodeJsonPayload, decodeJsonPayload, newConversationId, bytesToBase64, base64ToBytes, hexToBase64, base64ToHex, } from './codec.js';
|
|
49
|
-
export type { NegotiationMsgType, MsgType, InboundEnvelope, FeedbackPayload, NotarizeBidPayload, DeliverPayload, ProposePayload, CounterPayload, AcceptPayload, NodeIdentity, PeerSnapshot, ReputationSnapshot, SendResult, NegotiateResult, SkillMeta, ApiEvent, AgentRecord, AgentProfile, ActivityEvent, NetworkStats, HostingNode, AgentsParams, ActivityParams, } from './types.js';
|
|
48
|
+
export { encodeProposePayload, decodeProposePayload, encodeCounterPayload, decodeCounterPayload, encodeAcceptPayload, decodeAcceptPayload, encodeFeedbackPayload, decodeDeliverPayload, encodeJsonPayload, decodeJsonPayload, newConversationId, bytesToBase64, base64ToBytes, hexToBase64, base64ToHex, encodeBroadcastPayload, decodeBroadcastPayload, } from './codec.js';
|
|
49
|
+
export type { NegotiationMsgType, MsgType, InboundEnvelope, FeedbackPayload, NotarizeBidPayload, DeliverPayload, ProposePayload, CounterPayload, AcceptPayload, NodeIdentity, PeerSnapshot, ReputationSnapshot, SendResult, NegotiateResult, SkillMeta, ApiEvent, AgentRecord, AgentProfile, ActivityEvent, NetworkStats, HostingNode, AgentsParams, ActivityParams, BroadcastPayload, } from './types.js';
|
|
50
50
|
/** Public aggregator URL. Override with your own or enterprise aggregator. */
|
|
51
51
|
export declare const PUBLIC_AGGREGATOR_URL = "https://agg.0x01.world";
|
|
52
52
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,YAAY,EAAE,iBAAiB,EAAE,UAAU,EAAE,aAAa,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;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Property(exports, "__esModule", { value: true });
|
|
44
|
-
exports.PUBLIC_AGGREGATOR_URL = exports.base64ToHex = exports.hexToBase64 = exports.base64ToBytes = exports.bytesToBase64 = exports.newConversationId = exports.decodeJsonPayload = exports.encodeJsonPayload = exports.decodeDeliverPayload = exports.encodeFeedbackPayload = exports.decodeAcceptPayload = exports.encodeAcceptPayload = exports.decodeCounterPayload = exports.encodeCounterPayload = exports.decodeProposePayload = exports.encodeProposePayload = exports.AggregatorClient = exports.MultiFleet = exports.Conversation = exports.HostedAgent = exports.HostedFleet = exports.NodeClient = void 0;
|
|
44
|
+
exports.PUBLIC_AGGREGATOR_URL = exports.decodeBroadcastPayload = exports.encodeBroadcastPayload = exports.base64ToHex = exports.hexToBase64 = exports.base64ToBytes = exports.bytesToBase64 = exports.newConversationId = exports.decodeJsonPayload = exports.encodeJsonPayload = exports.decodeDeliverPayload = exports.encodeFeedbackPayload = exports.decodeAcceptPayload = exports.encodeAcceptPayload = exports.decodeCounterPayload = exports.encodeCounterPayload = exports.decodeProposePayload = exports.encodeProposePayload = exports.AggregatorClient = exports.MultiFleet = exports.Conversation = exports.HostedAgent = exports.HostedFleet = exports.NodeClient = void 0;
|
|
45
45
|
var NodeClient_js_1 = require("./NodeClient.js");
|
|
46
46
|
Object.defineProperty(exports, "NodeClient", { enumerable: true, get: function () { return NodeClient_js_1.NodeClient; } });
|
|
47
47
|
var HostedFleet_js_1 = require("./HostedFleet.js");
|
|
@@ -67,6 +67,8 @@ Object.defineProperty(exports, "bytesToBase64", { enumerable: true, get: functio
|
|
|
67
67
|
Object.defineProperty(exports, "base64ToBytes", { enumerable: true, get: function () { return codec_js_1.base64ToBytes; } });
|
|
68
68
|
Object.defineProperty(exports, "hexToBase64", { enumerable: true, get: function () { return codec_js_1.hexToBase64; } });
|
|
69
69
|
Object.defineProperty(exports, "base64ToHex", { enumerable: true, get: function () { return codec_js_1.base64ToHex; } });
|
|
70
|
+
Object.defineProperty(exports, "encodeBroadcastPayload", { enumerable: true, get: function () { return codec_js_1.encodeBroadcastPayload; } });
|
|
71
|
+
Object.defineProperty(exports, "decodeBroadcastPayload", { enumerable: true, get: function () { return codec_js_1.decodeBroadcastPayload; } });
|
|
70
72
|
/** Public aggregator URL. Override with your own or enterprise aggregator. */
|
|
71
73
|
exports.PUBLIC_AGGREGATOR_URL = 'https://agg.0x01.world';
|
|
72
74
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;;;AAEH,iDAA4C;AAAnC,2GAAA,UAAU,OAAA;AAGnB,mDAAqF;AAA5E,6GAAA,WAAW,OAAA;AAAE,6GAAA,WAAW,OAAA;AAAE,8GAAA,YAAY,OAAA;AAAE,4GAAA,UAAU,OAAA;AAG3D,6DAAwD;AAA/C,uHAAA,gBAAgB,OAAA;AAGzB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;;;AAEH,iDAA4C;AAAnC,2GAAA,UAAU,OAAA;AAGnB,mDAAqF;AAA5E,6GAAA,WAAW,OAAA;AAAE,6GAAA,WAAW,OAAA;AAAE,8GAAA,YAAY,OAAA;AAAE,4GAAA,UAAU,OAAA;AAG3D,6DAAwD;AAA/C,uHAAA,gBAAgB,OAAA;AAGzB,uCAkBmB;AAjBjB,gHAAA,oBAAoB,OAAA;AACpB,gHAAA,oBAAoB,OAAA;AACpB,gHAAA,oBAAoB,OAAA;AACpB,gHAAA,oBAAoB,OAAA;AACpB,+GAAA,mBAAmB,OAAA;AACnB,+GAAA,mBAAmB,OAAA;AACnB,iHAAA,qBAAqB,OAAA;AACrB,gHAAA,oBAAoB,OAAA;AACpB,6GAAA,iBAAiB,OAAA;AACjB,6GAAA,iBAAiB,OAAA;AACjB,6GAAA,iBAAiB,OAAA;AACjB,yGAAA,aAAa,OAAA;AACb,yGAAA,aAAa,OAAA;AACb,uGAAA,WAAW,OAAA;AACX,uGAAA,WAAW,OAAA;AACX,kHAAA,sBAAsB,OAAA;AACtB,kHAAA,sBAAsB,OAAA;AA8BxB,8EAA8E;AACjE,QAAA,qBAAqB,GAAG,wBAAwB,CAAA"}
|
package/dist/types.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import type { NegotiationMsgType, InboundEnvelope as CoreInboundEnvelope, AgentRecord as CoreAgentRecord, AgentsParams as CoreAgentsParams, NotarizeBidPayload } from '@zerox1/core';
|
|
6
6
|
/** Full public mesh message type — negotiation + system messages. */
|
|
7
|
-
export type MsgType = NegotiationMsgType | 'VERDICT' | 'ADVERTISE' | 'DISCOVER' | 'BEACON' | 'NOTARIZE_BID' | 'NOTARIZE_ASSIGN';
|
|
7
|
+
export type MsgType = NegotiationMsgType | 'VERDICT' | 'ADVERTISE' | 'DISCOVER' | 'BEACON' | 'NOTARIZE_BID' | 'NOTARIZE_ASSIGN' | 'BROADCAST';
|
|
8
8
|
/**
|
|
9
9
|
* Public mesh inbound envelope.
|
|
10
10
|
*
|
|
@@ -50,5 +50,42 @@ export interface AgentsParams extends CoreAgentsParams {
|
|
|
50
50
|
country?: string;
|
|
51
51
|
capabilities?: string;
|
|
52
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* Payload for a BROADCAST envelope — one-to-many gossipsub publish.
|
|
55
|
+
*
|
|
56
|
+
* A BROADCAST carries a named `topic` that listener agents subscribe to.
|
|
57
|
+
* Content can be a streaming audio chunk, a text post, or arbitrary data.
|
|
58
|
+
* The envelope has no `recipient` field — it is delivered to all subscribers.
|
|
59
|
+
*
|
|
60
|
+
* Typical radio use:
|
|
61
|
+
* - Producer agent publishes successive chunks with `chunk_index` counting up.
|
|
62
|
+
* - Listener agents match on `topic` + `tags` and relay audio to the app.
|
|
63
|
+
* - `price_per_epoch_micro` signals the subscription cost; payment is handled
|
|
64
|
+
* out-of-band via a standard PROPOSE/ACCEPT negotiation.
|
|
65
|
+
*/
|
|
66
|
+
export interface BroadcastPayload {
|
|
67
|
+
/** Named gossipsub topic, e.g. "radio:defi-daily" or "data:sol-price". */
|
|
68
|
+
topic: string;
|
|
69
|
+
/** Human-readable title for this episode / content item. */
|
|
70
|
+
title: string;
|
|
71
|
+
/** Discovery tags: capability names, language codes, genre, etc. */
|
|
72
|
+
tags: string[];
|
|
73
|
+
/** Content format. */
|
|
74
|
+
format: 'audio' | 'text' | 'data';
|
|
75
|
+
/** Base64-encoded content chunk. Omit for metadata-only announces. */
|
|
76
|
+
content_b64?: string;
|
|
77
|
+
/** MIME type of content, e.g. "audio/mpeg" or "text/plain". */
|
|
78
|
+
content_type?: string;
|
|
79
|
+
/** For streaming: zero-based chunk index within the current episode. */
|
|
80
|
+
chunk_index?: number;
|
|
81
|
+
/** Total number of chunks in the episode if known upfront. */
|
|
82
|
+
total_chunks?: number;
|
|
83
|
+
/** Duration of this audio chunk in milliseconds. */
|
|
84
|
+
duration_ms?: number;
|
|
85
|
+
/** Subscription price in USDC micro (1 USDC = 1_000_000). */
|
|
86
|
+
price_per_epoch_micro?: number;
|
|
87
|
+
/** Monotonic epoch / sequence number for ordering. */
|
|
88
|
+
epoch?: number;
|
|
89
|
+
}
|
|
53
90
|
export type { NegotiationMsgType, FeedbackPayload, NotarizeBidPayload, DeliverPayload, ProposePayload, CounterPayload, AcceptPayload, NodeIdentity, PeerSnapshot, SendResult, NegotiateResult, SkillMeta, ApiEvent, ActivityEvent, NetworkStats, HostingNode, ActivityParams, } from '@zerox1/core';
|
|
54
91
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AA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c,EACd,cAAc,EACd,cAAc,EACd,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,eAAe,EACf,SAAS,EACT,QAAQ,EACR,aAAa,EACb,YAAY,EACZ,WAAW,EACX,cAAc,GACf,MAAM,cAAc,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zerox1/client",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.5",
|
|
4
4
|
"description": "0x01 app-layer client SDK — talk to nodes and the aggregator without running an agent",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"ws": "^8.18.0",
|
|
39
|
-
"@zerox1/core": "0.4.
|
|
39
|
+
"@zerox1/core": "0.4.5"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@types/node": "^20.0.0",
|