@agents24/node 0.2.0 → 0.3.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.
Files changed (54) hide show
  1. package/README.md +17 -4
  2. package/compatibility.json +10 -10
  3. package/dist/bff.cjs +202 -33
  4. package/dist/bff.cjs.map +1 -1
  5. package/dist/bff.d.cts +3 -2
  6. package/dist/bff.d.ts +3 -2
  7. package/dist/bff.js +202 -33
  8. package/dist/bff.js.map +1 -1
  9. package/dist/{client-6MWalxux.d.cts → client-Rmk3dh_D.d.cts} +437 -71
  10. package/dist/{client-6MWalxux.d.ts → client-Rmk3dh_D.d.ts} +437 -71
  11. package/dist/index.cjs +194 -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 +194 -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 +2 -1
  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 +6 -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 +389 -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,
@@ -480,6 +497,12 @@ var EmbedNamespace = class {
480
497
  query: { agent_version_id: agentVersionId }
481
498
  });
482
499
  }
500
+ getResourcePolicy(agentId, request) {
501
+ return this.http.requestJson(`/public/embed/agents/${agentId}/resource-policy`, {
502
+ method: "POST",
503
+ body: request
504
+ });
505
+ }
483
506
  listAgentThreads(agentId, options) {
484
507
  return this.http.requestJson(`/public/embed/agents/${agentId}/threads`, { query: {
485
508
  external_user_id: options.externalUserId,
@@ -516,18 +539,17 @@ var EmbedNamespace = class {
516
539
  external_session_id: options.externalSessionId,
517
540
  before_turn_index: options.beforeTurnIndex,
518
541
  limit: options.limit,
519
- include_run_events: options.includeRunEvents,
520
542
  include_subthreads: options.includeSubthreads,
521
543
  subthread_depth: options.subthreadDepth,
522
544
  subthread_turn_limit: options.subthreadTurnLimit,
523
545
  subthread_child_limit: options.subthreadChildLimit
524
546
  } });
525
547
  }
526
- deleteAgentThread(agentId, threadId, options) {
548
+ deleteAgentThread(agentId, threadId, options, requestOptions) {
527
549
  return this.http.requestJson(`/public/embed/agents/${agentId}/threads/${threadId}`, { method: "DELETE", query: {
528
550
  external_user_id: options.externalUserId,
529
551
  external_session_id: options.externalSessionId
530
- }, mutation: true });
552
+ }, options: requestOptions, mutation: true });
531
553
  }
532
554
  getAgentRunContext(agentId, runId, options) {
533
555
  return this.http.requestJson(`/public/embed/agents/${agentId}/runs/${runId}/context`, { query: {
@@ -535,11 +557,17 @@ var EmbedNamespace = class {
535
557
  external_session_id: options.externalSessionId
536
558
  } });
537
559
  }
538
- cancelAgentRun(agentId, runId, options) {
560
+ cancelAgentRun(agentId, runId, options, requestOptions) {
539
561
  return this.http.requestJson(`/public/embed/agents/${agentId}/runs/${runId}/cancel`, { method: "POST", query: {
540
562
  external_user_id: options.externalUserId,
541
563
  external_session_id: options.externalSessionId
542
- }, body: {}, mutation: true });
564
+ }, body: {}, options: requestOptions, mutation: true });
565
+ }
566
+ setAgentRunFeedback(agentId, runId, payload) {
567
+ return this.http.requestJson(
568
+ `/public/embed/agents/${agentId}/runs/${runId}/feedback`,
569
+ { method: "PUT", body: payload, mutation: true }
570
+ );
543
571
  }
544
572
  async uploadAgentAttachments(agentId, options) {
545
573
  const form = new FormData();
@@ -555,6 +583,12 @@ var EmbedNamespace = class {
555
583
  await assertOk(response);
556
584
  return await response.json();
557
585
  }
586
+ createAttachmentContentAccess(agentId, attachmentId, request, options) {
587
+ return this.http.requestJson(
588
+ `/public/embed/agents/${agentId}/attachments/${attachmentId}/content-access`,
589
+ { method: "POST", body: request, options, mutation: true }
590
+ );
591
+ }
558
592
  };
559
593
 
560
594
  // src/generated/resourceBundles.ts
@@ -563,6 +597,29 @@ var ResourceBundlesNamespace = class {
563
597
  this.http = http;
564
598
  }
565
599
  http;
600
+ exportPlan(request) {
601
+ return this.http.requestJson("/resource-bundles/export/plan", {
602
+ method: "POST",
603
+ body: request
604
+ });
605
+ }
606
+ exportBundle(request) {
607
+ return this.http.requestJson("/resource-bundles/export", {
608
+ method: "POST",
609
+ body: request
610
+ });
611
+ }
612
+ candidates(options) {
613
+ return this.http.requestJson("/resource-bundles/candidates", {
614
+ query: {
615
+ kind: options.kind,
616
+ q: options.query,
617
+ limit: options.limit,
618
+ offset: options.offset,
619
+ required_capability: options.requiredCapability
620
+ }
621
+ });
622
+ }
566
623
  importPreview(request) {
567
624
  return this.http.requestJson("/resource-bundles/import/preview", {
568
625
  method: "POST",
@@ -645,12 +702,81 @@ var RunsNamespace = class {
645
702
  getContext(runId) {
646
703
  return this.http.requestJson(`/agents/runs/${runId}/context`);
647
704
  }
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 };
705
+ getTrace(runId, options = {}) {
706
+ return this.http.requestJson(`/agents/runs/${runId}/trace`, {
707
+ query: { include_diagnostics: options.includeDiagnostics }
708
+ });
709
+ }
710
+ };
711
+
712
+ // src/generated/instructions.ts
713
+ var InstructionsNamespace = class {
714
+ constructor(http) {
715
+ this.http = http;
716
+ }
717
+ http;
718
+ publish(instructionId, options) {
719
+ return this.http.requestJson(`/prompts/${instructionId}/publish`, {
720
+ method: "POST",
721
+ body: {},
722
+ options,
723
+ mutation: true
724
+ });
725
+ }
726
+ };
727
+
728
+ // src/generated/resourcePolicies.ts
729
+ var ResourcePoliciesNamespace = class {
730
+ constructor(http) {
731
+ this.http = http;
732
+ }
733
+ http;
734
+ list() {
735
+ return this.http.requestJson("/admin/security/resource-policies/sets");
736
+ }
737
+ setCustomerAssignment(request, options) {
738
+ return this.http.requestJson("/admin/security/resource-policies/customer-assignments/set", {
739
+ method: "POST",
740
+ body: request,
741
+ options,
742
+ mutation: true
743
+ });
744
+ }
745
+ getCustomerAssignment(request) {
746
+ return this.http.requestJson("/admin/security/resource-policies/customer-assignments/get", {
747
+ method: "POST",
748
+ body: request
749
+ });
750
+ }
751
+ clearCustomerAssignment(request, options) {
752
+ return this.http.requestJson("/admin/security/resource-policies/customer-assignments/clear", {
753
+ method: "POST",
754
+ body: request,
755
+ options,
756
+ mutation: true
757
+ });
758
+ }
759
+ getEffectiveCustomerPolicy(request) {
760
+ return this.http.requestJson("/admin/security/resource-policies/customers/effective", {
761
+ method: "POST",
762
+ body: request
763
+ });
764
+ }
765
+ setQuotaSchedule(request, options) {
766
+ return this.http.requestJson("/admin/security/resource-policies/quota-schedules/set", {
767
+ method: "POST",
768
+ body: request,
769
+ options,
770
+ mutation: true
771
+ });
772
+ }
773
+ resetQuotaNow(request, options) {
774
+ return this.http.requestJson("/admin/security/resource-policies/quota-schedules/reset-now", {
775
+ method: "POST",
776
+ body: request,
777
+ options,
778
+ mutation: true
779
+ });
654
780
  }
655
781
  };
656
782
 
@@ -663,6 +789,8 @@ var Agents24 = class {
663
789
  resourcePackages;
664
790
  clientDeployments;
665
791
  clientSessions;
792
+ instructions;
793
+ resourcePolicies;
666
794
  constructor(options) {
667
795
  const http = new Agents24HttpClient(options);
668
796
  this.agents = new AgentsNamespace(http);
@@ -672,6 +800,8 @@ var Agents24 = class {
672
800
  this.resourcePackages = new ResourcePackagesNamespace(http);
673
801
  this.clientDeployments = new ClientDeploymentsNamespace(http);
674
802
  this.clientSessions = new ClientSessionsNamespace(http);
803
+ this.instructions = new InstructionsNamespace(http);
804
+ this.resourcePolicies = new ResourcePoliciesNamespace(http);
675
805
  }
676
806
  agent(options) {
677
807
  return new AgentDefinitionBuilder(this.agents, options);
@@ -686,6 +816,7 @@ var SDK_OPERATION_IDS = [
686
816
  "agents.cancel_run",
687
817
  "agents.catalog",
688
818
  "agents.create",
819
+ "agents.create_attachment_content_access",
689
820
  "agents.delete",
690
821
  "agents.get",
691
822
  "agents.list",
@@ -698,20 +829,23 @@ var SDK_OPERATION_IDS = [
698
829
  "agents.update_graph",
699
830
  "agents.upload_attachments",
700
831
  "agents.validate",
832
+ "client.attachments.create_content_access",
701
833
  "client.attachments.upload",
702
834
  "client.bootstrap",
703
835
  "client.chat.stream",
704
836
  "client.deployments.create",
837
+ "client.deployments.delete",
705
838
  "client.deployments.get",
706
839
  "client.deployments.list",
707
- "client.deployments.revoke",
708
840
  "client.deployments.update",
709
841
  "client.hitl.resume",
710
842
  "client.jwks",
711
843
  "client.mcp.redeem",
712
844
  "client.mcp.start",
845
+ "client.resource_policy",
713
846
  "client.runs.attach",
714
847
  "client.runs.cancel",
848
+ "client.runs.set_feedback",
715
849
  "client.sessions.anonymous",
716
850
  "client.sessions.backendExchange",
717
851
  "client.sessions.refresh",
@@ -722,26 +856,41 @@ var SDK_OPERATION_IDS = [
722
856
  "client.threads.list",
723
857
  "embed.attach_agent_run",
724
858
  "embed.cancel_agent_run",
859
+ "embed.create_attachment_content_access",
725
860
  "embed.delete_agent_thread",
726
861
  "embed.get_agent_run_context",
727
862
  "embed.get_agent_thread",
863
+ "embed.get_resource_policy",
728
864
  "embed.get_runtime_bootstrap",
729
865
  "embed.list_agent_threads",
730
866
  "embed.list_agent_threads_multi",
731
867
  "embed.resume_agent_run",
868
+ "embed.set_agent_run_feedback",
732
869
  "embed.start_agent_run_mcp_auth",
733
870
  "embed.stream_agent",
734
871
  "embed.stream_agent_thread_events",
735
872
  "embed.stream_agent_thread_events_multi",
736
873
  "embed.upload_agent_attachments",
874
+ "instructions.publish",
875
+ "resource_bundles.candidates",
876
+ "resource_bundles.export",
877
+ "resource_bundles.export_plan",
737
878
  "resource_bundles.import",
738
879
  "resource_bundles.import_preview",
739
880
  "resource_packages.compile",
740
881
  "resource_packages.export",
741
882
  "resource_packages.validate",
883
+ "resource_policies.clear_customer_assignment",
884
+ "resource_policies.get_customer_assignment",
885
+ "resource_policies.get_effective_customer_policy",
886
+ "resource_policies.list",
887
+ "resource_policies.reset_quota_now",
888
+ "resource_policies.set_customer_assignment",
889
+ "resource_policies.set_quota_schedule",
742
890
  "runs.get",
743
891
  "runs.get_context",
744
892
  "runs.get_events",
893
+ "runs.get_trace",
745
894
  "runs.get_tree"
746
895
  ];
747
896