acn-client 0.5.1 → 0.6.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/index.js CHANGED
@@ -115,10 +115,34 @@ var ACNClient = class {
115
115
  // ============================================
116
116
  // Agent Management
117
117
  // ============================================
118
- /** Register a new agent */
118
+ /**
119
+ * Platform-managed agent registration (requires Auth0 token).
120
+ * For autonomous agents without Auth0, use joinACN() instead.
121
+ */
119
122
  async registerAgent(agent) {
120
123
  return this.post("/api/v1/agents/register", agent);
121
124
  }
125
+ /**
126
+ * Autonomous agent self-registration — no Auth0 required.
127
+ *
128
+ * Returns `{ agent_id, api_key, message }` on success. Store the
129
+ * `api_key` securely; it authenticates all subsequent API calls.
130
+ *
131
+ * @example
132
+ * ```typescript
133
+ * const result = await client.joinACN({
134
+ * name: 'MyAgent',
135
+ * description: 'A helpful AI assistant',
136
+ * tags: ['coding', 'search'],
137
+ * a2a_endpoint: 'https://my-agent.example.com/a2a',
138
+ * communication_policy: { mode: 'manifest' },
139
+ * });
140
+ * const { agent_id, api_key } = result;
141
+ * ```
142
+ */
143
+ async joinACN(request) {
144
+ return this.post("/api/v1/agents/join", request);
145
+ }
122
146
  /** Get agent by ID */
123
147
  async getAgent(agentId) {
124
148
  return this.get(`/api/v1/agents/${agentId}`);
@@ -190,12 +214,33 @@ var ACNClient = class {
190
214
  async sendMessage(request) {
191
215
  return this.post("/api/v1/communication/send", request);
192
216
  }
193
- /** Broadcast message to multiple agents */
217
+ /** Broadcast message to multiple agents in a subnet */
194
218
  async broadcast(request) {
195
219
  return this.post("/api/v1/communication/broadcast", request);
196
220
  }
197
- /** Broadcast message to agents with specific skill */
221
+ /**
222
+ * Broadcast a message to all agents matching ALL specified tags.
223
+ *
224
+ * @example
225
+ * ```typescript
226
+ * await client.broadcastByTag({
227
+ * from_agent: 'my-agent-id',
228
+ * tags: ['coding', 'search'],
229
+ * message: { role: 'user', parts: [{ type: 'text', text: 'hello' }] },
230
+ * });
231
+ * ```
232
+ */
233
+ async broadcastByTag(request) {
234
+ return this.post("/api/v1/communication/broadcast-by-tag", request);
235
+ }
236
+ /**
237
+ * @deprecated The server-side /broadcast-by-skill endpoint no longer exists.
238
+ * Use broadcastByTag({ from_agent, tags: [skill], message }) instead.
239
+ */
198
240
  async broadcastBySkill(request) {
241
+ console.warn(
242
+ "broadcastBySkill() is deprecated: the server endpoint /broadcast-by-skill no longer exists. Use broadcastByTag({ from_agent, tags: [skill], message }) instead."
243
+ );
199
244
  return this.post("/api/v1/communication/broadcast-by-skill", request);
200
245
  }
201
246
  /**
@@ -216,6 +261,156 @@ var ACNClient = class {
216
261
  return this.get(`/api/v1/communication/history/${agentId}`, params);
217
262
  }
218
263
  // ============================================
264
+ // Manifest Queue (Phase 2/3)
265
+ // ============================================
266
+ /**
267
+ * List manifest queue entries for the authenticated agent.
268
+ *
269
+ * Manifest mode is the default for agents registered from v0.5+.
270
+ * When a sender targets a manifest-mode recipient, the message is held
271
+ * in a server-side queue. Poll this endpoint to discover pending messages.
272
+ *
273
+ * @param agentId Must match the authenticated agent's ID.
274
+ * @param options.limit Max entries to return (newest first, server hard cap 200).
275
+ * @param options.sinceMs Return only entries with ts >= sinceMs (incremental polling).
276
+ */
277
+ /**
278
+ * List manifest queue entries for an agent.
279
+ *
280
+ * @param agentId - Must match the authenticated agent's ID.
281
+ * @param options.limit - Max entries (server cap: 200).
282
+ * @param options.sinceMs - Return only entries with ts >= sinceMs.
283
+ * @param options.messageType - Filter by ACN category tag (Phase 3).
284
+ */
285
+ async listManifest(agentId, options) {
286
+ const params = {};
287
+ if (options?.limit !== void 0) params.limit = options.limit;
288
+ if (options?.sinceMs !== void 0) params.since_ms = options.sinceMs;
289
+ if (options?.messageType !== void 0) params.type = options.messageType;
290
+ return this.get(`/api/v1/communication/manifest/${agentId}`, params);
291
+ }
292
+ /**
293
+ * Fetch the full payload for a manifest entry.
294
+ *
295
+ * For ACN-hosted content, returns `content` dict.
296
+ * For self-hosted content (`self_hosted=true`), returns `content_url` /
297
+ * `content_hash` — the caller must fetch and verify the remote payload.
298
+ *
299
+ * @param mid Manifest entry ID (32-hex string from ManifestEntry.mid).
300
+ */
301
+ /**
302
+ * Fetch the payload for a manifest entry (cursor-based pagination).
303
+ *
304
+ * For ACN-hosted content: pass `cursor` from a previous `next_cursor`
305
+ * to retrieve subsequent pages. Omit for the first page.
306
+ * For self-hosted content: returns `content_url` in a single call.
307
+ *
308
+ * @param mid - Manifest entry ID.
309
+ * @param cursor - Pagination token from a previous response's `next_cursor`.
310
+ */
311
+ async fetchManifestContent(mid, cursor) {
312
+ const params = {};
313
+ if (cursor !== void 0) params.cursor = cursor;
314
+ return this.get(`/api/v1/communication/content/${mid}`, Object.keys(params).length ? params : void 0);
315
+ }
316
+ /**
317
+ * Path 2 notify-only send (POST /communication/manifest/send).
318
+ *
319
+ * Stores only metadata (summary + message_type) — no full payload on ACN.
320
+ * Only works when the recipient is in `manifest` or `allowlist` mode.
321
+ *
322
+ * @param request - ManifestSendRequest with required `message_type`.
323
+ */
324
+ async manifestSend(request) {
325
+ return this.post("/api/v1/communication/manifest/send", request);
326
+ }
327
+ /**
328
+ * Fetch the public communication profile for any agent (no auth required).
329
+ *
330
+ * Returns the agent's communication mode and whether an attention_fee is
331
+ * required — the two pieces of information a sender needs before routing.
332
+ *
333
+ * @param agentId - Target agent's ID.
334
+ */
335
+ async getCommunicationProfile(agentId) {
336
+ return this.get(`/api/v1/agents/${agentId}/communication_profile`);
337
+ }
338
+ // ─────────────────────────────────────────────
339
+ // Session Layer (Phase 3)
340
+ // ─────────────────────────────────────────────
341
+ /**
342
+ * Invite another agent to a real-time session.
343
+ *
344
+ * Creates a pending session token. The invitee receives a
345
+ * `session_invite` WebSocket event in real time.
346
+ *
347
+ * @param targetAgentId - The agent to invite.
348
+ * @param request - Optional TTL and metadata.
349
+ */
350
+ async inviteSession(targetAgentId, request) {
351
+ return this.post(`/api/v1/sessions/invite/${targetAgentId}`, request ?? {});
352
+ }
353
+ /**
354
+ * Accept a pending session invitation (invitee only).
355
+ *
356
+ * The inviter receives a `session_accepted` WebSocket event.
357
+ *
358
+ * @param sessionId - Session ID from the `session_invite` WS event.
359
+ */
360
+ async acceptSession(sessionId) {
361
+ return this.post(`/api/v1/sessions/${sessionId}/accept`, {});
362
+ }
363
+ /**
364
+ * Reject a pending session invitation (invitee only).
365
+ *
366
+ * The session is deleted. The inviter receives a `session_rejected` event.
367
+ *
368
+ * @param sessionId - Session ID from the `session_invite` WS event.
369
+ */
370
+ async rejectSession(sessionId) {
371
+ return this.post(`/api/v1/sessions/${sessionId}/reject`, {});
372
+ }
373
+ /**
374
+ * Close a session (either participant may close it).
375
+ *
376
+ * The other participant receives a `session_closed` WebSocket event.
377
+ *
378
+ * @param sessionId - Session ID.
379
+ */
380
+ async closeSession(sessionId) {
381
+ return this.delete(`/api/v1/sessions/${sessionId}`);
382
+ }
383
+ /**
384
+ * List pending session invitations for the authenticated agent.
385
+ *
386
+ * Returns invitations where the agent is the *invitee* and status is
387
+ * still `pending` (not expired).
388
+ */
389
+ async listPendingSessions() {
390
+ return this.get("/api/v1/sessions/pending");
391
+ }
392
+ /**
393
+ * Acknowledge a manifest entry and release its attention_fee escrow.
394
+ *
395
+ * **Only applicable to entries with an attention_fee locked.**
396
+ * Entries without a fee → 400 `ATTENTION_FEE_NOT_LOCKED`.
397
+ * **Not idempotent** — re-acking raises 400 `ATTENTION_FEE_ALREADY_ACKED`.
398
+ *
399
+ * On success returns the full fee breakdown including `receipt_id`.
400
+ */
401
+ async ackManifest(agentId, mid) {
402
+ return this.post(`/api/v1/communication/manifest/${agentId}/${mid}/ack`);
403
+ }
404
+ /**
405
+ * Delete a manifest entry and refund any locked attention_fee.
406
+ *
407
+ * Use to reject/discard a message without reading it, or to clean up
408
+ * after fetchManifestContent.
409
+ */
410
+ async deleteManifest(agentId, mid) {
411
+ return this.delete(`/api/v1/communication/manifest/${agentId}/${mid}`);
412
+ }
413
+ // ============================================
219
414
  // Payment Discovery
220
415
  // ============================================
221
416
  /** Set agent's payment capability */
package/dist/index.mjs CHANGED
@@ -76,10 +76,34 @@ var ACNClient = class {
76
76
  // ============================================
77
77
  // Agent Management
78
78
  // ============================================
79
- /** Register a new agent */
79
+ /**
80
+ * Platform-managed agent registration (requires Auth0 token).
81
+ * For autonomous agents without Auth0, use joinACN() instead.
82
+ */
80
83
  async registerAgent(agent) {
81
84
  return this.post("/api/v1/agents/register", agent);
82
85
  }
86
+ /**
87
+ * Autonomous agent self-registration — no Auth0 required.
88
+ *
89
+ * Returns `{ agent_id, api_key, message }` on success. Store the
90
+ * `api_key` securely; it authenticates all subsequent API calls.
91
+ *
92
+ * @example
93
+ * ```typescript
94
+ * const result = await client.joinACN({
95
+ * name: 'MyAgent',
96
+ * description: 'A helpful AI assistant',
97
+ * tags: ['coding', 'search'],
98
+ * a2a_endpoint: 'https://my-agent.example.com/a2a',
99
+ * communication_policy: { mode: 'manifest' },
100
+ * });
101
+ * const { agent_id, api_key } = result;
102
+ * ```
103
+ */
104
+ async joinACN(request) {
105
+ return this.post("/api/v1/agents/join", request);
106
+ }
83
107
  /** Get agent by ID */
84
108
  async getAgent(agentId) {
85
109
  return this.get(`/api/v1/agents/${agentId}`);
@@ -151,12 +175,33 @@ var ACNClient = class {
151
175
  async sendMessage(request) {
152
176
  return this.post("/api/v1/communication/send", request);
153
177
  }
154
- /** Broadcast message to multiple agents */
178
+ /** Broadcast message to multiple agents in a subnet */
155
179
  async broadcast(request) {
156
180
  return this.post("/api/v1/communication/broadcast", request);
157
181
  }
158
- /** Broadcast message to agents with specific skill */
182
+ /**
183
+ * Broadcast a message to all agents matching ALL specified tags.
184
+ *
185
+ * @example
186
+ * ```typescript
187
+ * await client.broadcastByTag({
188
+ * from_agent: 'my-agent-id',
189
+ * tags: ['coding', 'search'],
190
+ * message: { role: 'user', parts: [{ type: 'text', text: 'hello' }] },
191
+ * });
192
+ * ```
193
+ */
194
+ async broadcastByTag(request) {
195
+ return this.post("/api/v1/communication/broadcast-by-tag", request);
196
+ }
197
+ /**
198
+ * @deprecated The server-side /broadcast-by-skill endpoint no longer exists.
199
+ * Use broadcastByTag({ from_agent, tags: [skill], message }) instead.
200
+ */
159
201
  async broadcastBySkill(request) {
202
+ console.warn(
203
+ "broadcastBySkill() is deprecated: the server endpoint /broadcast-by-skill no longer exists. Use broadcastByTag({ from_agent, tags: [skill], message }) instead."
204
+ );
160
205
  return this.post("/api/v1/communication/broadcast-by-skill", request);
161
206
  }
162
207
  /**
@@ -177,6 +222,156 @@ var ACNClient = class {
177
222
  return this.get(`/api/v1/communication/history/${agentId}`, params);
178
223
  }
179
224
  // ============================================
225
+ // Manifest Queue (Phase 2/3)
226
+ // ============================================
227
+ /**
228
+ * List manifest queue entries for the authenticated agent.
229
+ *
230
+ * Manifest mode is the default for agents registered from v0.5+.
231
+ * When a sender targets a manifest-mode recipient, the message is held
232
+ * in a server-side queue. Poll this endpoint to discover pending messages.
233
+ *
234
+ * @param agentId Must match the authenticated agent's ID.
235
+ * @param options.limit Max entries to return (newest first, server hard cap 200).
236
+ * @param options.sinceMs Return only entries with ts >= sinceMs (incremental polling).
237
+ */
238
+ /**
239
+ * List manifest queue entries for an agent.
240
+ *
241
+ * @param agentId - Must match the authenticated agent's ID.
242
+ * @param options.limit - Max entries (server cap: 200).
243
+ * @param options.sinceMs - Return only entries with ts >= sinceMs.
244
+ * @param options.messageType - Filter by ACN category tag (Phase 3).
245
+ */
246
+ async listManifest(agentId, options) {
247
+ const params = {};
248
+ if (options?.limit !== void 0) params.limit = options.limit;
249
+ if (options?.sinceMs !== void 0) params.since_ms = options.sinceMs;
250
+ if (options?.messageType !== void 0) params.type = options.messageType;
251
+ return this.get(`/api/v1/communication/manifest/${agentId}`, params);
252
+ }
253
+ /**
254
+ * Fetch the full payload for a manifest entry.
255
+ *
256
+ * For ACN-hosted content, returns `content` dict.
257
+ * For self-hosted content (`self_hosted=true`), returns `content_url` /
258
+ * `content_hash` — the caller must fetch and verify the remote payload.
259
+ *
260
+ * @param mid Manifest entry ID (32-hex string from ManifestEntry.mid).
261
+ */
262
+ /**
263
+ * Fetch the payload for a manifest entry (cursor-based pagination).
264
+ *
265
+ * For ACN-hosted content: pass `cursor` from a previous `next_cursor`
266
+ * to retrieve subsequent pages. Omit for the first page.
267
+ * For self-hosted content: returns `content_url` in a single call.
268
+ *
269
+ * @param mid - Manifest entry ID.
270
+ * @param cursor - Pagination token from a previous response's `next_cursor`.
271
+ */
272
+ async fetchManifestContent(mid, cursor) {
273
+ const params = {};
274
+ if (cursor !== void 0) params.cursor = cursor;
275
+ return this.get(`/api/v1/communication/content/${mid}`, Object.keys(params).length ? params : void 0);
276
+ }
277
+ /**
278
+ * Path 2 notify-only send (POST /communication/manifest/send).
279
+ *
280
+ * Stores only metadata (summary + message_type) — no full payload on ACN.
281
+ * Only works when the recipient is in `manifest` or `allowlist` mode.
282
+ *
283
+ * @param request - ManifestSendRequest with required `message_type`.
284
+ */
285
+ async manifestSend(request) {
286
+ return this.post("/api/v1/communication/manifest/send", request);
287
+ }
288
+ /**
289
+ * Fetch the public communication profile for any agent (no auth required).
290
+ *
291
+ * Returns the agent's communication mode and whether an attention_fee is
292
+ * required — the two pieces of information a sender needs before routing.
293
+ *
294
+ * @param agentId - Target agent's ID.
295
+ */
296
+ async getCommunicationProfile(agentId) {
297
+ return this.get(`/api/v1/agents/${agentId}/communication_profile`);
298
+ }
299
+ // ─────────────────────────────────────────────
300
+ // Session Layer (Phase 3)
301
+ // ─────────────────────────────────────────────
302
+ /**
303
+ * Invite another agent to a real-time session.
304
+ *
305
+ * Creates a pending session token. The invitee receives a
306
+ * `session_invite` WebSocket event in real time.
307
+ *
308
+ * @param targetAgentId - The agent to invite.
309
+ * @param request - Optional TTL and metadata.
310
+ */
311
+ async inviteSession(targetAgentId, request) {
312
+ return this.post(`/api/v1/sessions/invite/${targetAgentId}`, request ?? {});
313
+ }
314
+ /**
315
+ * Accept a pending session invitation (invitee only).
316
+ *
317
+ * The inviter receives a `session_accepted` WebSocket event.
318
+ *
319
+ * @param sessionId - Session ID from the `session_invite` WS event.
320
+ */
321
+ async acceptSession(sessionId) {
322
+ return this.post(`/api/v1/sessions/${sessionId}/accept`, {});
323
+ }
324
+ /**
325
+ * Reject a pending session invitation (invitee only).
326
+ *
327
+ * The session is deleted. The inviter receives a `session_rejected` event.
328
+ *
329
+ * @param sessionId - Session ID from the `session_invite` WS event.
330
+ */
331
+ async rejectSession(sessionId) {
332
+ return this.post(`/api/v1/sessions/${sessionId}/reject`, {});
333
+ }
334
+ /**
335
+ * Close a session (either participant may close it).
336
+ *
337
+ * The other participant receives a `session_closed` WebSocket event.
338
+ *
339
+ * @param sessionId - Session ID.
340
+ */
341
+ async closeSession(sessionId) {
342
+ return this.delete(`/api/v1/sessions/${sessionId}`);
343
+ }
344
+ /**
345
+ * List pending session invitations for the authenticated agent.
346
+ *
347
+ * Returns invitations where the agent is the *invitee* and status is
348
+ * still `pending` (not expired).
349
+ */
350
+ async listPendingSessions() {
351
+ return this.get("/api/v1/sessions/pending");
352
+ }
353
+ /**
354
+ * Acknowledge a manifest entry and release its attention_fee escrow.
355
+ *
356
+ * **Only applicable to entries with an attention_fee locked.**
357
+ * Entries without a fee → 400 `ATTENTION_FEE_NOT_LOCKED`.
358
+ * **Not idempotent** — re-acking raises 400 `ATTENTION_FEE_ALREADY_ACKED`.
359
+ *
360
+ * On success returns the full fee breakdown including `receipt_id`.
361
+ */
362
+ async ackManifest(agentId, mid) {
363
+ return this.post(`/api/v1/communication/manifest/${agentId}/${mid}/ack`);
364
+ }
365
+ /**
366
+ * Delete a manifest entry and refund any locked attention_fee.
367
+ *
368
+ * Use to reject/discard a message without reading it, or to clean up
369
+ * after fetchManifestContent.
370
+ */
371
+ async deleteManifest(agentId, mid) {
372
+ return this.delete(`/api/v1/communication/manifest/${agentId}/${mid}`);
373
+ }
374
+ // ============================================
180
375
  // Payment Discovery
181
376
  // ============================================
182
377
  /** Set agent's payment capability */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "acn-client",
3
- "version": "0.5.1",
3
+ "version": "0.6.0",
4
4
  "description": "Official TypeScript/JavaScript client for ACN (Agent Collaboration Network)",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",