acn-client 0.10.0 → 0.11.2

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.d.mts CHANGED
@@ -363,6 +363,96 @@ interface PaymentCapability {
363
363
  api_endpoint?: string;
364
364
  webhook_url?: string;
365
365
  }
366
+ /**
367
+ * Task status values for ACN task pool — mirrors backend `TaskStatus` enum
368
+ * (`acn.core.entities.task.TaskStatus`).
369
+ */
370
+ type TaskStatus = 'open' | 'in_progress' | 'submitted' | 'completed' | 'rejected' | 'cancelled';
371
+ /** ACN task (org-harness task pool). Aligns with server `TaskResponse`. */
372
+ interface Task {
373
+ task_id: string;
374
+ title: string;
375
+ description: string;
376
+ status: TaskStatus | string;
377
+ /** Decimal reward amount as a string (e.g. `"10.00"`). Use `parseFloat()` to display. */
378
+ reward: string;
379
+ reward_currency: string;
380
+ creator_id: string;
381
+ creator_name?: string;
382
+ task_type?: string;
383
+ required_tags?: string[];
384
+ /** Reward in numeric form — convenience alias, equals `parseFloat(reward)`. */
385
+ reward_amount?: number;
386
+ subnet_id: string | null;
387
+ created_at: string;
388
+ deadline?: string | null;
389
+ use_escrow?: boolean;
390
+ max_participants?: number | null;
391
+ active_participants_count?: number;
392
+ completed_count?: number;
393
+ metadata?: Record<string, unknown>;
394
+ }
395
+ /** A single agent participation on a task. */
396
+ interface Participation {
397
+ participation_id: string;
398
+ agent_id: string;
399
+ status: string;
400
+ submission_content: string | null;
401
+ submitted_at: string | null;
402
+ resubmit_count: number;
403
+ }
404
+ /** Response from POST /tasks/:id/accept. */
405
+ interface TaskAcceptResponse {
406
+ task: Task;
407
+ participation_id: string | null;
408
+ }
409
+ /** Request body for creating a task (POST /api/v1/tasks). */
410
+ interface TaskCreateRequest {
411
+ /** 3–200 chars */
412
+ title: string;
413
+ /** 10–10 000 chars */
414
+ description: string;
415
+ /**
416
+ * Reward per completion as a numeric string (e.g. `"10"` or `"0"`).
417
+ * Backend field name: `reward`.
418
+ */
419
+ reward: string;
420
+ /** Deadline in hours (1–2 160). Required. */
421
+ deadline_hours: number;
422
+ subnet_id?: string | null;
423
+ /** Default: "credits" */
424
+ reward_currency?: string;
425
+ /** Default: 1 */
426
+ max_participants?: number | null;
427
+ task_type?: string;
428
+ required_tags?: string[];
429
+ auto_approve?: boolean;
430
+ use_escrow?: boolean;
431
+ }
432
+ /** Options for listing tasks. */
433
+ interface TaskListOptions {
434
+ status?: TaskStatus | string;
435
+ creator_id?: string;
436
+ assignee_id?: string;
437
+ limit?: number;
438
+ offset?: number;
439
+ }
440
+ /** Response from GET /tasks. */
441
+ interface TaskListResponse {
442
+ tasks: Task[];
443
+ total: number;
444
+ has_more: boolean;
445
+ }
446
+ /** Response from GET /tasks/:id/participations. */
447
+ interface ParticipationListResponse {
448
+ participations: Participation[];
449
+ total: number;
450
+ }
451
+ /** Request body for PATCH /subnets/:id/harness. */
452
+ interface SubnetHarnessRequest {
453
+ harness_url: string | null;
454
+ harness_secret?: string | null;
455
+ }
366
456
  /**
367
457
  * Known ACN payment task status values.
368
458
  *
@@ -652,6 +742,19 @@ declare class ACNClient {
652
742
  * ```
653
743
  */
654
744
  joinACN(request: AgentJoinRequest): Promise<AgentJoinResponse>;
745
+ /**
746
+ * Resolve the authenticated agent (i.e. the one whose API key the client
747
+ * carries). Returns the full agent record. Useful for harnesses that
748
+ * need to know their own `agent_id` to skip echo-loops on webhook
749
+ * deliveries — when an ACN task.created event arrives whose `creator_id`
750
+ * matches the harness's own agent_id, the harness can recognise the task
751
+ * as one it issued itself and avoid re-mirroring it.
752
+ */
753
+ getMyAgent(): Promise<{
754
+ agent_id: string;
755
+ name: string;
756
+ [key: string]: unknown;
757
+ }>;
655
758
  /** Get agent by ID */
656
759
  getAgent(agentId: string): Promise<AgentInfo>;
657
760
  /** Search agents (status: online | offline | all; public list does not include verification_code) */
@@ -1110,6 +1213,41 @@ declare class ACNClient {
1110
1213
  limit?: number;
1111
1214
  offset?: number;
1112
1215
  }): Promise<AllowlistListResponse>;
1216
+ /** Create a new task in the org-harness task pool. */
1217
+ createTask(request: TaskCreateRequest): Promise<Task>;
1218
+ /** Get task details by ID. */
1219
+ getTask(taskId: string): Promise<Task>;
1220
+ /** List tasks with optional filters. */
1221
+ listTasks(options?: TaskListOptions): Promise<TaskListResponse>;
1222
+ /** Accept a task (join as participant). Returns the task and a participation_id. */
1223
+ acceptTask(taskId: string, message?: string): Promise<TaskAcceptResponse>;
1224
+ /**
1225
+ * Submit work for a task.
1226
+ *
1227
+ * @param submissionContent - The deliverable text (5–50 000 chars)
1228
+ * @param artifacts - Optional artifact references
1229
+ * @param participationId - Required when max_participants > 1
1230
+ */
1231
+ submitTask(taskId: string, submissionContent: string, options?: {
1232
+ artifacts?: Record<string, unknown>[];
1233
+ participationId?: string;
1234
+ }): Promise<Task>;
1235
+ /**
1236
+ * Review a task submission (approve or reject).
1237
+ * Only callable by the task creator or subnet owner.
1238
+ */
1239
+ reviewTask(taskId: string, approved: boolean,
1240
+ /** Review notes sent as the `notes` field — max 5 000 chars. */
1241
+ notes?: string): Promise<Task>;
1242
+ /** Cancel a task. */
1243
+ cancelTask(taskId: string): Promise<Task>;
1244
+ /** List all participations for a task. */
1245
+ getTaskParticipations(taskId: string): Promise<Participation[]>;
1246
+ /**
1247
+ * Register (or clear) an org-harness webhook URL for a subnet.
1248
+ * Pass `harnessUrl: null` to deregister.
1249
+ */
1250
+ registerSubnetHarness(subnetId: string, harnessUrl: string | null, harnessSecret?: string | null): Promise<void>;
1113
1251
  }
1114
1252
  /**
1115
1253
  * ACN API Error
@@ -1225,4 +1363,4 @@ declare class ACNRealtime {
1225
1363
  */
1226
1364
  declare function subscribeToACN<T = unknown>(baseUrl: string, channel: string, handler: WSEventHandler<T>): () => void;
1227
1365
 
1228
- export { ACNClient, type ACNClientOptions, ACNError, ACNRealtime, type ActivityEntry, type AgentActivity, type AgentAnalytics, type AgentInfo, type AgentJoinRequest, type AgentJoinResponse, type AgentRegisterRequest, type AgentRegisterResponse, type AgentSearchOptions, type AgentSearchResponse, type AgentStatus, type AllowlistActionResponse, type AllowlistEntry, type AllowlistListResponse, type ApiResponse, type AttentionFee, type AuditEvent, type AuditQueryOptions, type BroadcastBySkillRequest, type BroadcastByTagRequest, type BroadcastRequest, type BroadcastStrategy, type CommunicationPolicyMode, type CommunicationPolicyResponse, type ComponentHealth, type DashboardData, type FollowActionResponse, type FollowCheckResponse, KNOWN_PAYMENT_TASK_STATUSES, type ManifestContentResponse, type ManifestEntry, type ManifestListResponse, type Message, type MessageType, type MetricsData, type PaymentCapability, type PaymentDiscoveryOptions, type PaymentMethod, type PaymentNetwork, type PaymentRoleStats, type PaymentStats, type PaymentTask, type PaymentTaskStatus, type SendMessageRequest, type SendMessageResponse, type SubnetCreateRequest, type SubnetCreateResponse, type SubnetInfo, type SystemHealth, type WSConnectionOptions, type WSEventHandler, type WSEventType, type WSMessage, type WSState, subscribeToACN };
1366
+ export { ACNClient, type ACNClientOptions, ACNError, ACNRealtime, type ActivityEntry, type AgentActivity, type AgentAnalytics, type AgentInfo, type AgentJoinRequest, type AgentJoinResponse, type AgentRegisterRequest, type AgentRegisterResponse, type AgentSearchOptions, type AgentSearchResponse, type AgentStatus, type AllowlistActionResponse, type AllowlistEntry, type AllowlistListResponse, type ApiResponse, type AttentionFee, type AuditEvent, type AuditQueryOptions, type BroadcastBySkillRequest, type BroadcastByTagRequest, type BroadcastRequest, type BroadcastStrategy, type CommunicationPolicyMode, type CommunicationPolicyResponse, type ComponentHealth, type DashboardData, type FollowActionResponse, type FollowCheckResponse, KNOWN_PAYMENT_TASK_STATUSES, type ManifestContentResponse, type ManifestEntry, type ManifestListResponse, type Message, type MessageType, type MetricsData, type Participation, type ParticipationListResponse, type PaymentCapability, type PaymentDiscoveryOptions, type PaymentMethod, type PaymentNetwork, type PaymentRoleStats, type PaymentStats, type PaymentTask, type PaymentTaskStatus, type SendMessageRequest, type SendMessageResponse, type SubnetCreateRequest, type SubnetCreateResponse, type SubnetHarnessRequest, type SubnetInfo, type SystemHealth, type Task, type TaskAcceptResponse, type TaskCreateRequest, type TaskListOptions, type TaskListResponse, type TaskStatus, type WSConnectionOptions, type WSEventHandler, type WSEventType, type WSMessage, type WSState, subscribeToACN };
package/dist/index.d.ts CHANGED
@@ -363,6 +363,96 @@ interface PaymentCapability {
363
363
  api_endpoint?: string;
364
364
  webhook_url?: string;
365
365
  }
366
+ /**
367
+ * Task status values for ACN task pool — mirrors backend `TaskStatus` enum
368
+ * (`acn.core.entities.task.TaskStatus`).
369
+ */
370
+ type TaskStatus = 'open' | 'in_progress' | 'submitted' | 'completed' | 'rejected' | 'cancelled';
371
+ /** ACN task (org-harness task pool). Aligns with server `TaskResponse`. */
372
+ interface Task {
373
+ task_id: string;
374
+ title: string;
375
+ description: string;
376
+ status: TaskStatus | string;
377
+ /** Decimal reward amount as a string (e.g. `"10.00"`). Use `parseFloat()` to display. */
378
+ reward: string;
379
+ reward_currency: string;
380
+ creator_id: string;
381
+ creator_name?: string;
382
+ task_type?: string;
383
+ required_tags?: string[];
384
+ /** Reward in numeric form — convenience alias, equals `parseFloat(reward)`. */
385
+ reward_amount?: number;
386
+ subnet_id: string | null;
387
+ created_at: string;
388
+ deadline?: string | null;
389
+ use_escrow?: boolean;
390
+ max_participants?: number | null;
391
+ active_participants_count?: number;
392
+ completed_count?: number;
393
+ metadata?: Record<string, unknown>;
394
+ }
395
+ /** A single agent participation on a task. */
396
+ interface Participation {
397
+ participation_id: string;
398
+ agent_id: string;
399
+ status: string;
400
+ submission_content: string | null;
401
+ submitted_at: string | null;
402
+ resubmit_count: number;
403
+ }
404
+ /** Response from POST /tasks/:id/accept. */
405
+ interface TaskAcceptResponse {
406
+ task: Task;
407
+ participation_id: string | null;
408
+ }
409
+ /** Request body for creating a task (POST /api/v1/tasks). */
410
+ interface TaskCreateRequest {
411
+ /** 3–200 chars */
412
+ title: string;
413
+ /** 10–10 000 chars */
414
+ description: string;
415
+ /**
416
+ * Reward per completion as a numeric string (e.g. `"10"` or `"0"`).
417
+ * Backend field name: `reward`.
418
+ */
419
+ reward: string;
420
+ /** Deadline in hours (1–2 160). Required. */
421
+ deadline_hours: number;
422
+ subnet_id?: string | null;
423
+ /** Default: "credits" */
424
+ reward_currency?: string;
425
+ /** Default: 1 */
426
+ max_participants?: number | null;
427
+ task_type?: string;
428
+ required_tags?: string[];
429
+ auto_approve?: boolean;
430
+ use_escrow?: boolean;
431
+ }
432
+ /** Options for listing tasks. */
433
+ interface TaskListOptions {
434
+ status?: TaskStatus | string;
435
+ creator_id?: string;
436
+ assignee_id?: string;
437
+ limit?: number;
438
+ offset?: number;
439
+ }
440
+ /** Response from GET /tasks. */
441
+ interface TaskListResponse {
442
+ tasks: Task[];
443
+ total: number;
444
+ has_more: boolean;
445
+ }
446
+ /** Response from GET /tasks/:id/participations. */
447
+ interface ParticipationListResponse {
448
+ participations: Participation[];
449
+ total: number;
450
+ }
451
+ /** Request body for PATCH /subnets/:id/harness. */
452
+ interface SubnetHarnessRequest {
453
+ harness_url: string | null;
454
+ harness_secret?: string | null;
455
+ }
366
456
  /**
367
457
  * Known ACN payment task status values.
368
458
  *
@@ -652,6 +742,19 @@ declare class ACNClient {
652
742
  * ```
653
743
  */
654
744
  joinACN(request: AgentJoinRequest): Promise<AgentJoinResponse>;
745
+ /**
746
+ * Resolve the authenticated agent (i.e. the one whose API key the client
747
+ * carries). Returns the full agent record. Useful for harnesses that
748
+ * need to know their own `agent_id` to skip echo-loops on webhook
749
+ * deliveries — when an ACN task.created event arrives whose `creator_id`
750
+ * matches the harness's own agent_id, the harness can recognise the task
751
+ * as one it issued itself and avoid re-mirroring it.
752
+ */
753
+ getMyAgent(): Promise<{
754
+ agent_id: string;
755
+ name: string;
756
+ [key: string]: unknown;
757
+ }>;
655
758
  /** Get agent by ID */
656
759
  getAgent(agentId: string): Promise<AgentInfo>;
657
760
  /** Search agents (status: online | offline | all; public list does not include verification_code) */
@@ -1110,6 +1213,41 @@ declare class ACNClient {
1110
1213
  limit?: number;
1111
1214
  offset?: number;
1112
1215
  }): Promise<AllowlistListResponse>;
1216
+ /** Create a new task in the org-harness task pool. */
1217
+ createTask(request: TaskCreateRequest): Promise<Task>;
1218
+ /** Get task details by ID. */
1219
+ getTask(taskId: string): Promise<Task>;
1220
+ /** List tasks with optional filters. */
1221
+ listTasks(options?: TaskListOptions): Promise<TaskListResponse>;
1222
+ /** Accept a task (join as participant). Returns the task and a participation_id. */
1223
+ acceptTask(taskId: string, message?: string): Promise<TaskAcceptResponse>;
1224
+ /**
1225
+ * Submit work for a task.
1226
+ *
1227
+ * @param submissionContent - The deliverable text (5–50 000 chars)
1228
+ * @param artifacts - Optional artifact references
1229
+ * @param participationId - Required when max_participants > 1
1230
+ */
1231
+ submitTask(taskId: string, submissionContent: string, options?: {
1232
+ artifacts?: Record<string, unknown>[];
1233
+ participationId?: string;
1234
+ }): Promise<Task>;
1235
+ /**
1236
+ * Review a task submission (approve or reject).
1237
+ * Only callable by the task creator or subnet owner.
1238
+ */
1239
+ reviewTask(taskId: string, approved: boolean,
1240
+ /** Review notes sent as the `notes` field — max 5 000 chars. */
1241
+ notes?: string): Promise<Task>;
1242
+ /** Cancel a task. */
1243
+ cancelTask(taskId: string): Promise<Task>;
1244
+ /** List all participations for a task. */
1245
+ getTaskParticipations(taskId: string): Promise<Participation[]>;
1246
+ /**
1247
+ * Register (or clear) an org-harness webhook URL for a subnet.
1248
+ * Pass `harnessUrl: null` to deregister.
1249
+ */
1250
+ registerSubnetHarness(subnetId: string, harnessUrl: string | null, harnessSecret?: string | null): Promise<void>;
1113
1251
  }
1114
1252
  /**
1115
1253
  * ACN API Error
@@ -1225,4 +1363,4 @@ declare class ACNRealtime {
1225
1363
  */
1226
1364
  declare function subscribeToACN<T = unknown>(baseUrl: string, channel: string, handler: WSEventHandler<T>): () => void;
1227
1365
 
1228
- export { ACNClient, type ACNClientOptions, ACNError, ACNRealtime, type ActivityEntry, type AgentActivity, type AgentAnalytics, type AgentInfo, type AgentJoinRequest, type AgentJoinResponse, type AgentRegisterRequest, type AgentRegisterResponse, type AgentSearchOptions, type AgentSearchResponse, type AgentStatus, type AllowlistActionResponse, type AllowlistEntry, type AllowlistListResponse, type ApiResponse, type AttentionFee, type AuditEvent, type AuditQueryOptions, type BroadcastBySkillRequest, type BroadcastByTagRequest, type BroadcastRequest, type BroadcastStrategy, type CommunicationPolicyMode, type CommunicationPolicyResponse, type ComponentHealth, type DashboardData, type FollowActionResponse, type FollowCheckResponse, KNOWN_PAYMENT_TASK_STATUSES, type ManifestContentResponse, type ManifestEntry, type ManifestListResponse, type Message, type MessageType, type MetricsData, type PaymentCapability, type PaymentDiscoveryOptions, type PaymentMethod, type PaymentNetwork, type PaymentRoleStats, type PaymentStats, type PaymentTask, type PaymentTaskStatus, type SendMessageRequest, type SendMessageResponse, type SubnetCreateRequest, type SubnetCreateResponse, type SubnetInfo, type SystemHealth, type WSConnectionOptions, type WSEventHandler, type WSEventType, type WSMessage, type WSState, subscribeToACN };
1366
+ export { ACNClient, type ACNClientOptions, ACNError, ACNRealtime, type ActivityEntry, type AgentActivity, type AgentAnalytics, type AgentInfo, type AgentJoinRequest, type AgentJoinResponse, type AgentRegisterRequest, type AgentRegisterResponse, type AgentSearchOptions, type AgentSearchResponse, type AgentStatus, type AllowlistActionResponse, type AllowlistEntry, type AllowlistListResponse, type ApiResponse, type AttentionFee, type AuditEvent, type AuditQueryOptions, type BroadcastBySkillRequest, type BroadcastByTagRequest, type BroadcastRequest, type BroadcastStrategy, type CommunicationPolicyMode, type CommunicationPolicyResponse, type ComponentHealth, type DashboardData, type FollowActionResponse, type FollowCheckResponse, KNOWN_PAYMENT_TASK_STATUSES, type ManifestContentResponse, type ManifestEntry, type ManifestListResponse, type Message, type MessageType, type MetricsData, type Participation, type ParticipationListResponse, type PaymentCapability, type PaymentDiscoveryOptions, type PaymentMethod, type PaymentNetwork, type PaymentRoleStats, type PaymentStats, type PaymentTask, type PaymentTaskStatus, type SendMessageRequest, type SendMessageResponse, type SubnetCreateRequest, type SubnetCreateResponse, type SubnetHarnessRequest, type SubnetInfo, type SystemHealth, type Task, type TaskAcceptResponse, type TaskCreateRequest, type TaskListOptions, type TaskListResponse, type TaskStatus, type WSConnectionOptions, type WSEventHandler, type WSEventType, type WSMessage, type WSState, subscribeToACN };
package/dist/index.js CHANGED
@@ -53,7 +53,7 @@ var ACNClient = class {
53
53
  this.timeout = options.timeout ?? 3e4;
54
54
  this.headers = options.headers ?? {};
55
55
  if (options.apiKey) {
56
- this.headers["X-API-Key"] = options.apiKey;
56
+ this.headers["Authorization"] = `Bearer ${options.apiKey}`;
57
57
  }
58
58
  }
59
59
  }
@@ -168,6 +168,17 @@ var ACNClient = class {
168
168
  async joinACN(request) {
169
169
  return this.post("/api/v1/agents/join", request);
170
170
  }
171
+ /**
172
+ * Resolve the authenticated agent (i.e. the one whose API key the client
173
+ * carries). Returns the full agent record. Useful for harnesses that
174
+ * need to know their own `agent_id` to skip echo-loops on webhook
175
+ * deliveries — when an ACN task.created event arrives whose `creator_id`
176
+ * matches the harness's own agent_id, the harness can recognise the task
177
+ * as one it issued itself and avoid re-mirroring it.
178
+ */
179
+ async getMyAgent() {
180
+ return this.get("/api/v1/agents/me");
181
+ }
171
182
  /** Get agent by ID */
172
183
  async getAgent(agentId) {
173
184
  return this.get(`/api/v1/agents/${agentId}`);
@@ -218,6 +229,18 @@ var ACNClient = class {
218
229
  async getSubnetAgents(subnetId) {
219
230
  return this.get(`/api/v1/subnets/${subnetId}/agents`);
220
231
  }
232
+ // ──────────────────────────────────────────────────────────────────────
233
+ // Subnet membership (agent-side)
234
+ //
235
+ // Canonical paths under `/api/v1/agents/{agent_id}/…`, matching every
236
+ // other agent-side operation (heartbeat / claim / transfer / wallets / …).
237
+ //
238
+ // Before 0.11.2 the SDK called `/api/v1/subnets/{agent_id}/subnets/{id}`
239
+ // because that was the only shape the backend served. Backend release
240
+ // carrying the canonical-routes patch (ACN PR #42) now serves both
241
+ // shapes — the legacy one is marked `deprecated=True` in OpenAPI and
242
+ // scheduled for removal. Requires ACN backend ≥ post-PR-#42.
243
+ // ──────────────────────────────────────────────────────────────────────
221
244
  /** Join agent to subnet */
222
245
  async joinSubnet(agentId, subnetId) {
223
246
  return this.post(`/api/v1/agents/${agentId}/subnets/${subnetId}`);
@@ -792,6 +815,81 @@ var ACNClient = class {
792
815
  async listAllowlist(agentId, options) {
793
816
  return this.get(`/api/v1/agents/${agentId}/allowlist`, options);
794
817
  }
818
+ // ============================================
819
+ // Task Pool Methods (Saga / Org-Harness)
820
+ // ============================================
821
+ /** Create a new task in the org-harness task pool. */
822
+ async createTask(request) {
823
+ return this.post("/api/v1/tasks", request);
824
+ }
825
+ /** Get task details by ID. */
826
+ async getTask(taskId) {
827
+ return this.get(`/api/v1/tasks/${taskId}`);
828
+ }
829
+ /** List tasks with optional filters. */
830
+ async listTasks(options) {
831
+ const params = {};
832
+ if (options?.status !== void 0) params.status = options.status;
833
+ if (options?.creator_id !== void 0) params.creator_id = options.creator_id;
834
+ if (options?.assignee_id !== void 0) params.assignee_id = options.assignee_id;
835
+ if (options?.limit !== void 0) params.limit = options.limit;
836
+ if (options?.offset !== void 0) params.offset = options.offset;
837
+ return this.get("/api/v1/tasks", params);
838
+ }
839
+ /** Accept a task (join as participant). Returns the task and a participation_id. */
840
+ async acceptTask(taskId, message) {
841
+ return this.post(`/api/v1/tasks/${taskId}/accept`, { message: message ?? "" });
842
+ }
843
+ /**
844
+ * Submit work for a task.
845
+ *
846
+ * @param submissionContent - The deliverable text (5–50 000 chars)
847
+ * @param artifacts - Optional artifact references
848
+ * @param participationId - Required when max_participants > 1
849
+ */
850
+ async submitTask(taskId, submissionContent, options) {
851
+ return this.post(`/api/v1/tasks/${taskId}/submit`, {
852
+ submission: submissionContent,
853
+ artifacts: options?.artifacts ?? [],
854
+ participation_id: options?.participationId
855
+ });
856
+ }
857
+ /**
858
+ * Review a task submission (approve or reject).
859
+ * Only callable by the task creator or subnet owner.
860
+ */
861
+ async reviewTask(taskId, approved, notes) {
862
+ return this.post(`/api/v1/tasks/${taskId}/review`, {
863
+ approved,
864
+ notes: notes ?? ""
865
+ });
866
+ }
867
+ /** Cancel a task. */
868
+ async cancelTask(taskId) {
869
+ return this.post(`/api/v1/tasks/${taskId}/cancel`, {});
870
+ }
871
+ /** List all participations for a task. */
872
+ async getTaskParticipations(taskId) {
873
+ const res = await this.get(
874
+ `/api/v1/tasks/${taskId}/participations`
875
+ );
876
+ return res.participations ?? [];
877
+ }
878
+ // ============================================
879
+ // Subnet Harness
880
+ // ============================================
881
+ /**
882
+ * Register (or clear) an org-harness webhook URL for a subnet.
883
+ * Pass `harnessUrl: null` to deregister.
884
+ */
885
+ async registerSubnetHarness(subnetId, harnessUrl, harnessSecret) {
886
+ await this.request("PATCH", `/api/v1/subnets/${subnetId}/harness`, {
887
+ body: {
888
+ harness_url: harnessUrl,
889
+ harness_secret: harnessSecret ?? null
890
+ }
891
+ });
892
+ }
795
893
  };
796
894
  var ACNError = class extends Error {
797
895
  constructor(status, message, options) {
package/dist/index.mjs CHANGED
@@ -13,7 +13,7 @@ var ACNClient = class {
13
13
  this.timeout = options.timeout ?? 3e4;
14
14
  this.headers = options.headers ?? {};
15
15
  if (options.apiKey) {
16
- this.headers["X-API-Key"] = options.apiKey;
16
+ this.headers["Authorization"] = `Bearer ${options.apiKey}`;
17
17
  }
18
18
  }
19
19
  }
@@ -128,6 +128,17 @@ var ACNClient = class {
128
128
  async joinACN(request) {
129
129
  return this.post("/api/v1/agents/join", request);
130
130
  }
131
+ /**
132
+ * Resolve the authenticated agent (i.e. the one whose API key the client
133
+ * carries). Returns the full agent record. Useful for harnesses that
134
+ * need to know their own `agent_id` to skip echo-loops on webhook
135
+ * deliveries — when an ACN task.created event arrives whose `creator_id`
136
+ * matches the harness's own agent_id, the harness can recognise the task
137
+ * as one it issued itself and avoid re-mirroring it.
138
+ */
139
+ async getMyAgent() {
140
+ return this.get("/api/v1/agents/me");
141
+ }
131
142
  /** Get agent by ID */
132
143
  async getAgent(agentId) {
133
144
  return this.get(`/api/v1/agents/${agentId}`);
@@ -178,6 +189,18 @@ var ACNClient = class {
178
189
  async getSubnetAgents(subnetId) {
179
190
  return this.get(`/api/v1/subnets/${subnetId}/agents`);
180
191
  }
192
+ // ──────────────────────────────────────────────────────────────────────
193
+ // Subnet membership (agent-side)
194
+ //
195
+ // Canonical paths under `/api/v1/agents/{agent_id}/…`, matching every
196
+ // other agent-side operation (heartbeat / claim / transfer / wallets / …).
197
+ //
198
+ // Before 0.11.2 the SDK called `/api/v1/subnets/{agent_id}/subnets/{id}`
199
+ // because that was the only shape the backend served. Backend release
200
+ // carrying the canonical-routes patch (ACN PR #42) now serves both
201
+ // shapes — the legacy one is marked `deprecated=True` in OpenAPI and
202
+ // scheduled for removal. Requires ACN backend ≥ post-PR-#42.
203
+ // ──────────────────────────────────────────────────────────────────────
181
204
  /** Join agent to subnet */
182
205
  async joinSubnet(agentId, subnetId) {
183
206
  return this.post(`/api/v1/agents/${agentId}/subnets/${subnetId}`);
@@ -752,6 +775,81 @@ var ACNClient = class {
752
775
  async listAllowlist(agentId, options) {
753
776
  return this.get(`/api/v1/agents/${agentId}/allowlist`, options);
754
777
  }
778
+ // ============================================
779
+ // Task Pool Methods (Saga / Org-Harness)
780
+ // ============================================
781
+ /** Create a new task in the org-harness task pool. */
782
+ async createTask(request) {
783
+ return this.post("/api/v1/tasks", request);
784
+ }
785
+ /** Get task details by ID. */
786
+ async getTask(taskId) {
787
+ return this.get(`/api/v1/tasks/${taskId}`);
788
+ }
789
+ /** List tasks with optional filters. */
790
+ async listTasks(options) {
791
+ const params = {};
792
+ if (options?.status !== void 0) params.status = options.status;
793
+ if (options?.creator_id !== void 0) params.creator_id = options.creator_id;
794
+ if (options?.assignee_id !== void 0) params.assignee_id = options.assignee_id;
795
+ if (options?.limit !== void 0) params.limit = options.limit;
796
+ if (options?.offset !== void 0) params.offset = options.offset;
797
+ return this.get("/api/v1/tasks", params);
798
+ }
799
+ /** Accept a task (join as participant). Returns the task and a participation_id. */
800
+ async acceptTask(taskId, message) {
801
+ return this.post(`/api/v1/tasks/${taskId}/accept`, { message: message ?? "" });
802
+ }
803
+ /**
804
+ * Submit work for a task.
805
+ *
806
+ * @param submissionContent - The deliverable text (5–50 000 chars)
807
+ * @param artifacts - Optional artifact references
808
+ * @param participationId - Required when max_participants > 1
809
+ */
810
+ async submitTask(taskId, submissionContent, options) {
811
+ return this.post(`/api/v1/tasks/${taskId}/submit`, {
812
+ submission: submissionContent,
813
+ artifacts: options?.artifacts ?? [],
814
+ participation_id: options?.participationId
815
+ });
816
+ }
817
+ /**
818
+ * Review a task submission (approve or reject).
819
+ * Only callable by the task creator or subnet owner.
820
+ */
821
+ async reviewTask(taskId, approved, notes) {
822
+ return this.post(`/api/v1/tasks/${taskId}/review`, {
823
+ approved,
824
+ notes: notes ?? ""
825
+ });
826
+ }
827
+ /** Cancel a task. */
828
+ async cancelTask(taskId) {
829
+ return this.post(`/api/v1/tasks/${taskId}/cancel`, {});
830
+ }
831
+ /** List all participations for a task. */
832
+ async getTaskParticipations(taskId) {
833
+ const res = await this.get(
834
+ `/api/v1/tasks/${taskId}/participations`
835
+ );
836
+ return res.participations ?? [];
837
+ }
838
+ // ============================================
839
+ // Subnet Harness
840
+ // ============================================
841
+ /**
842
+ * Register (or clear) an org-harness webhook URL for a subnet.
843
+ * Pass `harnessUrl: null` to deregister.
844
+ */
845
+ async registerSubnetHarness(subnetId, harnessUrl, harnessSecret) {
846
+ await this.request("PATCH", `/api/v1/subnets/${subnetId}/harness`, {
847
+ body: {
848
+ harness_url: harnessUrl,
849
+ harness_secret: harnessSecret ?? null
850
+ }
851
+ });
852
+ }
755
853
  };
756
854
  var ACNError = class extends Error {
757
855
  constructor(status, message, options) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "acn-client",
3
- "version": "0.10.0",
3
+ "version": "0.11.2",
4
4
  "description": "Official TypeScript/JavaScript client for ACN (Agent Collaboration Network)",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",