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