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