@agents24/node 0.2.0 → 0.2.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.
Files changed (54) hide show
  1. package/README.md +17 -4
  2. package/compatibility.json +10 -10
  3. package/dist/bff.cjs +204 -33
  4. package/dist/bff.cjs.map +1 -1
  5. package/dist/bff.d.cts +5 -3
  6. package/dist/bff.d.ts +5 -3
  7. package/dist/bff.js +204 -33
  8. package/dist/bff.js.map +1 -1
  9. package/dist/{client-6MWalxux.d.cts → client-CnOaaCVH.d.cts} +431 -71
  10. package/dist/{client-6MWalxux.d.ts → client-CnOaaCVH.d.ts} +431 -71
  11. package/dist/index.cjs +187 -45
  12. package/dist/index.cjs.map +1 -1
  13. package/dist/index.d.cts +3 -3
  14. package/dist/index.d.ts +3 -3
  15. package/dist/index.js +187 -45
  16. package/dist/index.js.map +1 -1
  17. package/dist/server.cjs +52 -6
  18. package/dist/server.cjs.map +1 -1
  19. package/dist/server.d.cts +14 -2
  20. package/dist/server.d.ts +14 -2
  21. package/dist/server.js +50 -7
  22. package/dist/server.js.map +1 -1
  23. package/dist/types/agents.d.ts +5 -4
  24. package/dist/types/agents.d.ts.map +1 -1
  25. package/dist/types/bff.d.ts +4 -2
  26. package/dist/types/bff.d.ts.map +1 -1
  27. package/dist/types/builders.d.ts +2 -0
  28. package/dist/types/builders.d.ts.map +1 -1
  29. package/dist/types/client-runtime-admin.d.ts +1 -1
  30. package/dist/types/client.d.ts +4 -0
  31. package/dist/types/client.d.ts.map +1 -1
  32. package/dist/types/embed.d.ts +5 -3
  33. package/dist/types/embed.d.ts.map +1 -1
  34. package/dist/types/errors.d.ts +10 -2
  35. package/dist/types/errors.d.ts.map +1 -1
  36. package/dist/types/generated/instructions.d.ts +8 -0
  37. package/dist/types/generated/instructions.d.ts.map +1 -0
  38. package/dist/types/generated/manifest.d.ts +1 -1
  39. package/dist/types/generated/manifest.d.ts.map +1 -1
  40. package/dist/types/generated/resourceBundles.d.ts +4 -1
  41. package/dist/types/generated/resourceBundles.d.ts.map +1 -1
  42. package/dist/types/generated/resourcePolicies.d.ts +14 -0
  43. package/dist/types/generated/resourcePolicies.d.ts.map +1 -0
  44. package/dist/types/http.d.ts +0 -2
  45. package/dist/types/http.d.ts.map +1 -1
  46. package/dist/types/index.d.ts +1 -1
  47. package/dist/types/index.d.ts.map +1 -1
  48. package/dist/types/runs.d.ts +4 -2
  49. package/dist/types/runs.d.ts.map +1 -1
  50. package/dist/types/server.d.ts +13 -1
  51. package/dist/types/server.d.ts.map +1 -1
  52. package/dist/types/types.d.ts +384 -60
  53. package/dist/types/types.d.ts.map +1 -1
  54. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -8,16 +8,37 @@ export { CONTRACT_HASH, RUNTIME_PROTOCOL_VERSION, THREAD_SUMMARY_PROTOCOL_VERSIO
8
8
  var Agents24SDKError = class extends Error {
9
9
  kind;
10
10
  status;
11
- details;
11
+ failure;
12
12
  responseHeaders;
13
13
  constructor(message, options) {
14
14
  super(message, { cause: options.cause });
15
15
  this.name = "Agents24SDKError";
16
16
  this.kind = options.kind;
17
17
  this.status = options.status;
18
- this.details = options.details;
18
+ this.failure = options.failure;
19
19
  this.responseHeaders = options.responseHeaders;
20
20
  }
21
+ get code() {
22
+ return this.failure?.code;
23
+ }
24
+ get category() {
25
+ return this.failure?.category;
26
+ }
27
+ get failureId() {
28
+ return this.failure?.failure_id;
29
+ }
30
+ get requestId() {
31
+ return this.failure?.request_id ?? void 0;
32
+ }
33
+ get retryable() {
34
+ return this.failure?.retryable ?? false;
35
+ }
36
+ get retryAfterMs() {
37
+ return this.failure?.retry_after_ms ?? void 0;
38
+ }
39
+ get details() {
40
+ return this.failure?.details ?? {};
41
+ }
21
42
  };
22
43
 
23
44
  // src/http.ts
@@ -43,17 +64,10 @@ async function errorDetails(response) {
43
64
  return text;
44
65
  }
45
66
  }
46
- function detailMessage(details) {
47
- if (typeof details === "string" && details.trim()) return details.trim();
48
- if (!details || typeof details !== "object" || Array.isArray(details)) return void 0;
49
- const detail = details.detail;
50
- if (typeof detail === "string" && detail.trim()) return detail.trim();
51
- if (detail && typeof detail === "object" && !Array.isArray(detail)) {
52
- const message2 = detail.message;
53
- if (typeof message2 === "string" && message2.trim()) return message2.trim();
54
- }
55
- const message = details.message;
56
- return typeof message === "string" && message.trim() ? message.trim() : void 0;
67
+ function failureView(value) {
68
+ if (!value || typeof value !== "object" || Array.isArray(value)) return void 0;
69
+ const candidate = value;
70
+ return candidate.schema_version === "agents24.failure.v1" && typeof candidate.failure_id === "string" && typeof candidate.code === "string" && typeof candidate.category === "string" && typeof candidate.message === "string" && typeof candidate.retryable === "boolean" && candidate.details !== null && typeof candidate.details === "object" && !Array.isArray(candidate.details) ? candidate : void 0;
57
71
  }
58
72
  function responseHeaders(response) {
59
73
  const headers = {};
@@ -65,19 +79,17 @@ function responseHeaders(response) {
65
79
  }
66
80
  async function assertOk(response) {
67
81
  if (response.ok) return;
68
- const details = await errorDetails(response);
69
- throw new Agents24SDKError(detailMessage(details) || response.statusText || "Agents24 request failed.", {
82
+ const failure = failureView(await errorDetails(response));
83
+ throw new Agents24SDKError(failure?.message || "Agents24 request failed.", {
70
84
  kind: "http",
71
85
  status: response.status,
72
- details,
86
+ failure,
73
87
  responseHeaders: responseHeaders(response)
74
88
  });
75
89
  }
76
90
  var Agents24HttpClient = class {
77
91
  base;
78
92
  apiKey;
79
- organizationId;
80
- projectId;
81
93
  fetchImpl;
82
94
  constructor(options) {
83
95
  if (typeof process === "undefined" || process.release?.name !== "node") {
@@ -85,8 +97,6 @@ var Agents24HttpClient = class {
85
97
  }
86
98
  this.base = normalizeBaseUrl(options.baseUrl);
87
99
  this.apiKey = required(options.apiKey, "apiKey");
88
- this.organizationId = required(options.organizationId, "organizationId");
89
- this.projectId = required(options.projectId, "projectId");
90
100
  if (typeof options.fetchImpl !== "function" && typeof fetch !== "function") {
91
101
  throw new Agents24SDKError("No fetch implementation is available. Use Node 22 or 24.", { kind: "protocol" });
92
102
  }
@@ -111,8 +121,6 @@ var Agents24HttpClient = class {
111
121
  Authorization: `Bearer ${this.apiKey}`,
112
122
  Accept: "application/json",
113
123
  "Content-Type": "application/json",
114
- "X-Organization-ID": this.organizationId,
115
- "X-Project-ID": this.projectId,
116
124
  "X-SDK-Contract": "1",
117
125
  ...mutation ? { "Idempotency-Key": options?.idempotencyKey || randomUUID() } : {},
118
126
  ...options?.requestMetadata ? { "X-Request-Metadata": JSON.stringify(options.requestMetadata) } : {},
@@ -126,8 +134,6 @@ var Agents24HttpClient = class {
126
134
  return {
127
135
  Authorization: `Bearer ${this.apiKey}`,
128
136
  Accept: "application/json",
129
- "X-Organization-ID": this.organizationId,
130
- "X-Project-ID": this.projectId,
131
137
  "X-SDK-Contract": "1",
132
138
  ...mutation ? { "Idempotency-Key": options?.idempotencyKey || randomUUID() } : {},
133
139
  ...extra || {}
@@ -252,6 +258,7 @@ var AgentsNamespace = class {
252
258
  async uploadAttachments(agentId, options) {
253
259
  const form = new FormData();
254
260
  if (options.threadId) form.set("thread_id", options.threadId);
261
+ if (options.agentVersionId) form.set("agent_version_id", options.agentVersionId);
255
262
  for (const file of options.files) form.append("files", file, file.name);
256
263
  const response = await this.http.fetchOrThrow(this.http.url(`/agents/${agentId}/attachments/upload`), {
257
264
  method: "POST",
@@ -261,6 +268,12 @@ var AgentsNamespace = class {
261
268
  await assertOk(response);
262
269
  return await response.json();
263
270
  }
271
+ createAttachmentContentAccess(agentId, attachmentId, request, options) {
272
+ return this.http.requestJson(
273
+ `/agents/${agentId}/attachments/${attachmentId}/content-access`,
274
+ { method: "POST", body: request, options, mutation: true }
275
+ );
276
+ }
264
277
  };
265
278
 
266
279
  // src/builders.ts
@@ -279,12 +292,15 @@ function toolsetAttachments(options) {
279
292
  const id = refId(attachment.toolset);
280
293
  if (!id || seen.has(id)) return [];
281
294
  seen.add(id);
282
- const policy = attachment.versionPolicy || { mode: "latest_published" };
283
- return [{
295
+ const normalized = {
284
296
  toolset_id: id,
285
- loading_mode: attachment.loadingMode || "static",
286
- version_policy: policy.mode === "pinned" ? { mode: "pinned", version_id: policy.versionId } : { mode: "latest_published" }
287
- }];
297
+ loading_mode: attachment.loadingMode || "static"
298
+ };
299
+ const policy = attachment.versionPolicy;
300
+ if (policy) {
301
+ normalized.version_policy = policy.mode === "pinned" ? { mode: "pinned", version_id: policy.versionId } : { mode: "latest_published" };
302
+ }
303
+ return [normalized];
288
304
  });
289
305
  }
290
306
  var AgentDefinitionBuilder = class {
@@ -362,9 +378,10 @@ var GraphBuilder = class {
362
378
  id: options.id || `${sourceId}-${targetId}`,
363
379
  source: sourceId,
364
380
  target: targetId,
365
- type: "control",
381
+ type: options.type || "control",
366
382
  source_handle: options.sourceHandle,
367
- target_handle: options.targetHandle
383
+ target_handle: options.targetHandle,
384
+ condition: options.condition
368
385
  });
369
386
  return this;
370
387
  }
@@ -396,7 +413,7 @@ var ClientDeploymentsNamespace = class {
396
413
  }
397
414
  list(query) {
398
415
  const params = new URLSearchParams({ agent_id: query.agentId });
399
- if (query.status) params.set("status", query.status);
416
+ if (query.lifecycleStatus) params.set("lifecycle_status", query.lifecycleStatus);
400
417
  if (query.cursor) params.set("cursor", query.cursor);
401
418
  if (query.limit !== void 0) params.set("limit", String(query.limit));
402
419
  return this.http.requestJson(
@@ -414,7 +431,7 @@ var ClientDeploymentsNamespace = class {
414
431
  mutation: true
415
432
  });
416
433
  }
417
- revoke(deploymentId, options) {
434
+ delete(deploymentId, options) {
418
435
  return this.http.requestJson(`/client-runtime/deployments/${deploymentId}`, {
419
436
  method: "DELETE",
420
437
  options,
@@ -515,18 +532,17 @@ var EmbedNamespace = class {
515
532
  external_session_id: options.externalSessionId,
516
533
  before_turn_index: options.beforeTurnIndex,
517
534
  limit: options.limit,
518
- include_run_events: options.includeRunEvents,
519
535
  include_subthreads: options.includeSubthreads,
520
536
  subthread_depth: options.subthreadDepth,
521
537
  subthread_turn_limit: options.subthreadTurnLimit,
522
538
  subthread_child_limit: options.subthreadChildLimit
523
539
  } });
524
540
  }
525
- deleteAgentThread(agentId, threadId, options) {
541
+ deleteAgentThread(agentId, threadId, options, requestOptions) {
526
542
  return this.http.requestJson(`/public/embed/agents/${agentId}/threads/${threadId}`, { method: "DELETE", query: {
527
543
  external_user_id: options.externalUserId,
528
544
  external_session_id: options.externalSessionId
529
- }, mutation: true });
545
+ }, options: requestOptions, mutation: true });
530
546
  }
531
547
  getAgentRunContext(agentId, runId, options) {
532
548
  return this.http.requestJson(`/public/embed/agents/${agentId}/runs/${runId}/context`, { query: {
@@ -534,11 +550,17 @@ var EmbedNamespace = class {
534
550
  external_session_id: options.externalSessionId
535
551
  } });
536
552
  }
537
- cancelAgentRun(agentId, runId, options) {
553
+ cancelAgentRun(agentId, runId, options, requestOptions) {
538
554
  return this.http.requestJson(`/public/embed/agents/${agentId}/runs/${runId}/cancel`, { method: "POST", query: {
539
555
  external_user_id: options.externalUserId,
540
556
  external_session_id: options.externalSessionId
541
- }, body: {}, mutation: true });
557
+ }, body: {}, options: requestOptions, mutation: true });
558
+ }
559
+ setAgentRunFeedback(agentId, runId, payload) {
560
+ return this.http.requestJson(
561
+ `/public/embed/agents/${agentId}/runs/${runId}/feedback`,
562
+ { method: "PUT", body: payload, mutation: true }
563
+ );
542
564
  }
543
565
  async uploadAgentAttachments(agentId, options) {
544
566
  const form = new FormData();
@@ -554,6 +576,12 @@ var EmbedNamespace = class {
554
576
  await assertOk(response);
555
577
  return await response.json();
556
578
  }
579
+ createAttachmentContentAccess(agentId, attachmentId, request, options) {
580
+ return this.http.requestJson(
581
+ `/public/embed/agents/${agentId}/attachments/${attachmentId}/content-access`,
582
+ { method: "POST", body: request, options, mutation: true }
583
+ );
584
+ }
557
585
  };
558
586
 
559
587
  // src/generated/resourceBundles.ts
@@ -562,6 +590,29 @@ var ResourceBundlesNamespace = class {
562
590
  this.http = http;
563
591
  }
564
592
  http;
593
+ exportPlan(request) {
594
+ return this.http.requestJson("/resource-bundles/export/plan", {
595
+ method: "POST",
596
+ body: request
597
+ });
598
+ }
599
+ exportBundle(request) {
600
+ return this.http.requestJson("/resource-bundles/export", {
601
+ method: "POST",
602
+ body: request
603
+ });
604
+ }
605
+ candidates(options) {
606
+ return this.http.requestJson("/resource-bundles/candidates", {
607
+ query: {
608
+ kind: options.kind,
609
+ q: options.query,
610
+ limit: options.limit,
611
+ offset: options.offset,
612
+ required_capability: options.requiredCapability
613
+ }
614
+ });
615
+ }
565
616
  importPreview(request) {
566
617
  return this.http.requestJson("/resource-bundles/import/preview", {
567
618
  method: "POST",
@@ -644,12 +695,81 @@ var RunsNamespace = class {
644
695
  getContext(runId) {
645
696
  return this.http.requestJson(`/agents/runs/${runId}/context`);
646
697
  }
647
- async getTrace(runId) {
648
- const run = await this.get(runId);
649
- const tree = await this.getTree(runId);
650
- const events = await this.getEvents(runId);
651
- const context = await this.getContext(runId);
652
- return { run, tree, events, context };
698
+ getTrace(runId, options = {}) {
699
+ return this.http.requestJson(`/agents/runs/${runId}/trace`, {
700
+ query: { include_diagnostics: options.includeDiagnostics }
701
+ });
702
+ }
703
+ };
704
+
705
+ // src/generated/instructions.ts
706
+ var InstructionsNamespace = class {
707
+ constructor(http) {
708
+ this.http = http;
709
+ }
710
+ http;
711
+ publish(instructionId, options) {
712
+ return this.http.requestJson(`/prompts/${instructionId}/publish`, {
713
+ method: "POST",
714
+ body: {},
715
+ options,
716
+ mutation: true
717
+ });
718
+ }
719
+ };
720
+
721
+ // src/generated/resourcePolicies.ts
722
+ var ResourcePoliciesNamespace = class {
723
+ constructor(http) {
724
+ this.http = http;
725
+ }
726
+ http;
727
+ list() {
728
+ return this.http.requestJson("/admin/security/resource-policies/sets");
729
+ }
730
+ setCustomerAssignment(request, options) {
731
+ return this.http.requestJson("/admin/security/resource-policies/customer-assignments/set", {
732
+ method: "POST",
733
+ body: request,
734
+ options,
735
+ mutation: true
736
+ });
737
+ }
738
+ getCustomerAssignment(request) {
739
+ return this.http.requestJson("/admin/security/resource-policies/customer-assignments/get", {
740
+ method: "POST",
741
+ body: request
742
+ });
743
+ }
744
+ clearCustomerAssignment(request, options) {
745
+ return this.http.requestJson("/admin/security/resource-policies/customer-assignments/clear", {
746
+ method: "POST",
747
+ body: request,
748
+ options,
749
+ mutation: true
750
+ });
751
+ }
752
+ getEffectiveCustomerPolicy(request) {
753
+ return this.http.requestJson("/admin/security/resource-policies/customers/effective", {
754
+ method: "POST",
755
+ body: request
756
+ });
757
+ }
758
+ setQuotaSchedule(request, options) {
759
+ return this.http.requestJson("/admin/security/resource-policies/quota-schedules/set", {
760
+ method: "POST",
761
+ body: request,
762
+ options,
763
+ mutation: true
764
+ });
765
+ }
766
+ resetQuotaNow(request, options) {
767
+ return this.http.requestJson("/admin/security/resource-policies/quota-schedules/reset-now", {
768
+ method: "POST",
769
+ body: request,
770
+ options,
771
+ mutation: true
772
+ });
653
773
  }
654
774
  };
655
775
 
@@ -662,6 +782,8 @@ var Agents24 = class {
662
782
  resourcePackages;
663
783
  clientDeployments;
664
784
  clientSessions;
785
+ instructions;
786
+ resourcePolicies;
665
787
  constructor(options) {
666
788
  const http = new Agents24HttpClient(options);
667
789
  this.agents = new AgentsNamespace(http);
@@ -671,6 +793,8 @@ var Agents24 = class {
671
793
  this.resourcePackages = new ResourcePackagesNamespace(http);
672
794
  this.clientDeployments = new ClientDeploymentsNamespace(http);
673
795
  this.clientSessions = new ClientSessionsNamespace(http);
796
+ this.instructions = new InstructionsNamespace(http);
797
+ this.resourcePolicies = new ResourcePoliciesNamespace(http);
674
798
  }
675
799
  agent(options) {
676
800
  return new AgentDefinitionBuilder(this.agents, options);
@@ -685,6 +809,7 @@ var SDK_OPERATION_IDS = [
685
809
  "agents.cancel_run",
686
810
  "agents.catalog",
687
811
  "agents.create",
812
+ "agents.create_attachment_content_access",
688
813
  "agents.delete",
689
814
  "agents.get",
690
815
  "agents.list",
@@ -697,20 +822,23 @@ var SDK_OPERATION_IDS = [
697
822
  "agents.update_graph",
698
823
  "agents.upload_attachments",
699
824
  "agents.validate",
825
+ "client.attachments.create_content_access",
700
826
  "client.attachments.upload",
701
827
  "client.bootstrap",
702
828
  "client.chat.stream",
703
829
  "client.deployments.create",
830
+ "client.deployments.delete",
704
831
  "client.deployments.get",
705
832
  "client.deployments.list",
706
- "client.deployments.revoke",
707
833
  "client.deployments.update",
708
834
  "client.hitl.resume",
709
835
  "client.jwks",
710
836
  "client.mcp.redeem",
711
837
  "client.mcp.start",
838
+ "client.resource_policy",
712
839
  "client.runs.attach",
713
840
  "client.runs.cancel",
841
+ "client.runs.set_feedback",
714
842
  "client.sessions.anonymous",
715
843
  "client.sessions.backendExchange",
716
844
  "client.sessions.refresh",
@@ -721,6 +849,7 @@ var SDK_OPERATION_IDS = [
721
849
  "client.threads.list",
722
850
  "embed.attach_agent_run",
723
851
  "embed.cancel_agent_run",
852
+ "embed.create_attachment_content_access",
724
853
  "embed.delete_agent_thread",
725
854
  "embed.get_agent_run_context",
726
855
  "embed.get_agent_thread",
@@ -728,19 +857,32 @@ var SDK_OPERATION_IDS = [
728
857
  "embed.list_agent_threads",
729
858
  "embed.list_agent_threads_multi",
730
859
  "embed.resume_agent_run",
860
+ "embed.set_agent_run_feedback",
731
861
  "embed.start_agent_run_mcp_auth",
732
862
  "embed.stream_agent",
733
863
  "embed.stream_agent_thread_events",
734
864
  "embed.stream_agent_thread_events_multi",
735
865
  "embed.upload_agent_attachments",
866
+ "instructions.publish",
867
+ "resource_bundles.candidates",
868
+ "resource_bundles.export",
869
+ "resource_bundles.export_plan",
736
870
  "resource_bundles.import",
737
871
  "resource_bundles.import_preview",
738
872
  "resource_packages.compile",
739
873
  "resource_packages.export",
740
874
  "resource_packages.validate",
875
+ "resource_policies.clear_customer_assignment",
876
+ "resource_policies.get_customer_assignment",
877
+ "resource_policies.get_effective_customer_policy",
878
+ "resource_policies.list",
879
+ "resource_policies.reset_quota_now",
880
+ "resource_policies.set_customer_assignment",
881
+ "resource_policies.set_quota_schedule",
741
882
  "runs.get",
742
883
  "runs.get_context",
743
884
  "runs.get_events",
885
+ "runs.get_trace",
744
886
  "runs.get_tree"
745
887
  ];
746
888