@miosa/sdk 1.2.6 → 1.2.8

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.js CHANGED
@@ -1,4 +1,4 @@
1
- import { randomUUID } from 'crypto';
1
+ import { createHmac, timingSafeEqual, randomUUID } from 'crypto';
2
2
  import EventEmitter from 'events';
3
3
 
4
4
  var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
@@ -22,10 +22,10 @@ var MiosaError = class _MiosaError extends Error {
22
22
  this.details = details;
23
23
  this.requestId = requestId;
24
24
  }
25
- static fromResponse(status, body, requestId) {
26
- const message = body.error?.message ?? body.message ?? `HTTP ${status}`;
27
- const code = body.error?.code ?? body.code ?? "UNKNOWN_ERROR";
28
- const details = body.error?.details;
25
+ static fromResponse(status, body2, requestId) {
26
+ const message = body2.error?.message ?? body2.message ?? `HTTP ${status}`;
27
+ const code = body2.error?.code ?? body2.code ?? "UNKNOWN_ERROR";
28
+ const details = body2.error?.details;
29
29
  if (status === 401 || status === 403) {
30
30
  return new AuthError(message, status, code, details, requestId);
31
31
  }
@@ -167,7 +167,7 @@ var HttpClient = class {
167
167
  async request(path, options = {}) {
168
168
  const {
169
169
  method = "GET",
170
- body,
170
+ body: body2,
171
171
  formData,
172
172
  binary = false,
173
173
  timeout = this.timeout
@@ -176,9 +176,9 @@ var HttpClient = class {
176
176
  let fetchBody;
177
177
  if (formData) {
178
178
  fetchBody = formData;
179
- } else if (body !== void 0) {
179
+ } else if (body2 !== void 0) {
180
180
  headers = { ...headers, "Content-Type": "application/json" };
181
- fetchBody = JSON.stringify(body);
181
+ fetchBody = JSON.stringify(body2);
182
182
  }
183
183
  let lastError;
184
184
  for (let attempt = 0; attempt <= this.maxRetries; attempt++) {
@@ -260,17 +260,17 @@ var HttpClient = class {
260
260
  }
261
261
  return this.request(fullPath, { method: "GET" });
262
262
  }
263
- async post(path, body) {
264
- return this.request(path, { method: "POST", body });
263
+ async post(path, body2) {
264
+ return this.request(path, { method: "POST", body: body2 });
265
265
  }
266
- async patch(path, body) {
267
- return this.request(path, { method: "PATCH", body });
266
+ async patch(path, body2) {
267
+ return this.request(path, { method: "PATCH", body: body2 });
268
268
  }
269
- async put(path, body) {
270
- return this.request(path, { method: "PUT", body });
269
+ async put(path, body2) {
270
+ return this.request(path, { method: "PUT", body: body2 });
271
271
  }
272
- async delete(path, body) {
273
- return this.request(path, { method: "DELETE", body });
272
+ async delete(path, body2) {
273
+ return this.request(path, { method: "DELETE", body: body2 });
274
274
  }
275
275
  async getBinary(path) {
276
276
  return this.request(path, { method: "GET", binary: true });
@@ -288,10 +288,10 @@ var HttpClient = class {
288
288
  Accept: "text/event-stream",
289
289
  ...options.headers
290
290
  });
291
- let body = null;
291
+ let body2 = null;
292
292
  if (options.body !== void 0) {
293
293
  headers = { ...headers, "Content-Type": "application/json" };
294
- body = JSON.stringify(options.body);
294
+ body2 = JSON.stringify(options.body);
295
295
  }
296
296
  const controller = new AbortController();
297
297
  let response;
@@ -299,7 +299,7 @@ var HttpClient = class {
299
299
  response = await fetch(`${this.baseUrl}${path}`, {
300
300
  method,
301
301
  headers,
302
- body,
302
+ body: body2,
303
303
  signal: controller.signal
304
304
  });
305
305
  } catch (err) {
@@ -368,7 +368,7 @@ var Admin = class {
368
368
  this.http = http;
369
369
  }
370
370
  /** Escape hatch — call any admin endpoint by method + path. */
371
- async request(method, path, body, query) {
371
+ async request(method, path, body2, query) {
372
372
  const fullPath = query ? (() => {
373
373
  const qs = new URLSearchParams();
374
374
  for (const [k, v] of Object.entries(query)) {
@@ -381,13 +381,13 @@ var Admin = class {
381
381
  case "GET":
382
382
  return this.http.get(fullPath);
383
383
  case "POST":
384
- return this.http.post(fullPath, body);
384
+ return this.http.post(fullPath, body2);
385
385
  case "PUT":
386
- return this.http.put(fullPath, body);
386
+ return this.http.put(fullPath, body2);
387
387
  case "PATCH":
388
- return this.http.patch(fullPath, body);
388
+ return this.http.patch(fullPath, body2);
389
389
  case "DELETE":
390
- return this.http.delete(fullPath, body);
390
+ return this.http.delete(fullPath, body2);
391
391
  }
392
392
  }
393
393
  // ── Overview ────────────────────────────────────────────────
@@ -601,72 +601,168 @@ var Admin = class {
601
601
  }
602
602
  };
603
603
 
604
- // src/resources/agent-runs.ts
605
- function stripUndefined(input) {
606
- return Object.fromEntries(Object.entries(input).filter(([, value]) => value !== void 0));
604
+ // src/resources/agent-runtime-profiles.ts
605
+ function unwrap(payload) {
606
+ if (payload !== null && typeof payload === "object" && "data" in payload && payload.data !== void 0) {
607
+ return payload.data;
608
+ }
609
+ return payload;
607
610
  }
608
- function createBody(params) {
609
- return stripUndefined({
610
- target_id: params.target_id ?? params.targetId ?? params.sandbox_id ?? params.sandboxId ?? params.computer_id ?? params.computerId,
611
- target_kind: params.target_kind ?? params.targetKind,
612
- provider: params.provider,
613
- prompt: params.prompt,
614
- instruction: params.instruction,
615
- command: params.command,
616
- model: params.model,
617
- cwd: params.cwd,
618
- timeout: params.timeout,
619
- metadata: params.metadata
620
- });
611
+ function body(params) {
612
+ return Object.fromEntries(
613
+ Object.entries({
614
+ workspace_id: params.workspaceId ?? params.workspace_id,
615
+ name: params.name,
616
+ runtime: params.runtime,
617
+ description: params.description,
618
+ applies_to: params.appliesTo ?? params.applies_to,
619
+ tools: params.tools,
620
+ connectors: params.connectors,
621
+ env: params.env,
622
+ policy: params.policy,
623
+ metadata: params.metadata,
624
+ is_default: params.isDefault ?? params.is_default
625
+ }).filter(([, value]) => value !== void 0)
626
+ );
621
627
  }
622
- function listQuery(params) {
623
- return {
624
- target_id: params.target_id ?? params.targetId ?? params.sandbox_id ?? params.sandboxId ?? params.computer_id ?? params.computerId,
625
- limit: params.limit
628
+ function normalize(profile) {
629
+ const normalized = {
630
+ ...profile
626
631
  };
627
- }
628
- function unwrapRun(response) {
629
- const run = response.data ?? response.run;
630
- if (!run) {
631
- throw new Error("Agent run response was empty.");
632
+ const tenantId = profile.tenantId ?? profile.tenant_id;
633
+ const workspaceId2 = profile.workspaceId ?? profile.workspace_id;
634
+ const appliesTo = profile.appliesTo ?? profile.applies_to;
635
+ const isDefault = profile.isDefault ?? profile.is_default;
636
+ const createdAt = profile.createdAt ?? profile.created_at;
637
+ const updatedAt = profile.updatedAt ?? profile.updated_at;
638
+ if (tenantId !== void 0) normalized.tenantId = tenantId;
639
+ if (workspaceId2 !== void 0) normalized.workspaceId = workspaceId2;
640
+ if (appliesTo !== void 0) normalized.appliesTo = appliesTo;
641
+ if (isDefault !== void 0) normalized.isDefault = isDefault;
642
+ if (createdAt !== void 0) normalized.createdAt = createdAt;
643
+ if (updatedAt !== void 0) normalized.updatedAt = updatedAt;
644
+ return normalized;
645
+ }
646
+ var AgentRuntimeProfiles = class {
647
+ constructor(http) {
648
+ this.http = http;
649
+ }
650
+ http;
651
+ async list(params = {}) {
652
+ const response = await this.http.get(
653
+ "/agent-runtime-profiles",
654
+ { workspace_id: params.workspaceId ?? params.workspace_id }
655
+ );
656
+ return unwrap(response).map(normalize);
632
657
  }
633
- return run;
658
+ async get(id) {
659
+ return normalize(
660
+ unwrap(
661
+ await this.http.get(
662
+ `/agent-runtime-profiles/${encodeURIComponent(id)}`
663
+ )
664
+ )
665
+ );
666
+ }
667
+ async create(params) {
668
+ return normalize(
669
+ unwrap(
670
+ await this.http.post(
671
+ "/agent-runtime-profiles",
672
+ body(params)
673
+ )
674
+ )
675
+ );
676
+ }
677
+ async update(id, params) {
678
+ return normalize(
679
+ unwrap(
680
+ await this.http.put(
681
+ `/agent-runtime-profiles/${encodeURIComponent(id)}`,
682
+ body(params)
683
+ )
684
+ )
685
+ );
686
+ }
687
+ async delete(id) {
688
+ await this.http.delete(
689
+ `/agent-runtime-profiles/${encodeURIComponent(id)}`
690
+ );
691
+ }
692
+ };
693
+
694
+ // src/resources/agent-runs.ts
695
+ function unwrap2(payload) {
696
+ if (payload && typeof payload === "object" && "data" in payload) {
697
+ return payload.data;
698
+ }
699
+ return payload;
634
700
  }
635
- function unwrapRuns(response) {
636
- if (Array.isArray(response)) return response;
637
- return response.data ?? response.runs ?? [];
701
+ function stripUndefined(input) {
702
+ return Object.fromEntries(
703
+ Object.entries(input).filter(([, value]) => value !== void 0)
704
+ );
638
705
  }
639
706
  var AgentRuns = class {
640
707
  constructor(http) {
641
708
  this.http = http;
642
709
  }
643
710
  http;
644
- /** Dispatch a prompt to a sandbox/computer and persist the run record. */
645
- async create(params) {
646
- const response = await this.http.post("/agent-runs", createBody(params));
647
- return unwrapRun(response);
648
- }
649
- /** Alias for create(), matching the product language. */
650
- async run(params) {
651
- return this.create(params);
652
- }
653
- /** List recent agent runs for the authenticated tenant. */
654
711
  async list(params = {}) {
655
712
  const response = await this.http.get(
656
713
  "/agent-runs",
657
- listQuery(params)
714
+ stripUndefined({
715
+ target_kind: params.targetKind,
716
+ target_id: params.targetId,
717
+ sandbox_id: params.sandboxId,
718
+ computer_id: params.computerId,
719
+ status: params.status
720
+ })
721
+ );
722
+ const data = unwrap2(
723
+ response
658
724
  );
659
- return unwrapRuns(response);
725
+ if (Array.isArray(data)) return data;
726
+ return data.runs ?? data.items ?? [];
727
+ }
728
+ async get(id) {
729
+ return unwrap2(
730
+ await this.http.get(`/agent-runs/${encodeURIComponent(id)}`)
731
+ );
732
+ }
733
+ async run(params) {
734
+ const body2 = stripUndefined({
735
+ prompt: params.prompt,
736
+ target_kind: params.targetKind,
737
+ target_id: params.targetId,
738
+ sandbox_id: params.sandboxId,
739
+ computer_id: params.computerId,
740
+ provider: params.provider,
741
+ model: params.model,
742
+ command: params.command,
743
+ runtime_command: params.runtimeCommand,
744
+ cwd: params.cwd,
745
+ timeout: params.timeout,
746
+ env: params.env,
747
+ agent_runtime_profile_id: params.agentRuntimeProfileId,
748
+ agent_profile_id: params.agentProfileId,
749
+ skip_agent_runtime_profile: params.skipAgentRuntimeProfile,
750
+ metadata: params.metadata
751
+ });
752
+ return unwrap2(await this.http.post("/agent-runs", body2));
660
753
  }
661
- /** Fetch one persisted agent run. */
662
- async get(runId) {
663
- const response = await this.http.get(`/agent-runs/${runId}`);
664
- return unwrapRun(response);
754
+ async cancel(id) {
755
+ return unwrap2(
756
+ await this.http.post(
757
+ `/agent-runs/${encodeURIComponent(id)}/cancel`,
758
+ {}
759
+ )
760
+ );
665
761
  }
666
762
  };
667
763
 
668
764
  // src/resources/analytics.ts
669
- function unwrap(payload) {
765
+ function unwrap3(payload) {
670
766
  if (payload && typeof payload === "object") {
671
767
  const p = payload;
672
768
  for (const k of ["data", "analytics", "series", "items"]) {
@@ -689,16 +785,16 @@ var Analytics = class {
689
785
  async overview(filters = {}) {
690
786
  const query = stripUndefined2(filters);
691
787
  const data = await this.http.get("/analytics/overview", query);
692
- return unwrap(data);
788
+ return unwrap3(data);
693
789
  }
694
790
  /** Get a timeseries for a metric over a period. */
695
791
  async timeseries(params = {}) {
696
792
  const query = stripUndefined2(params);
697
793
  const data = await this.http.get("/analytics/timeseries", query);
698
- return unwrap(data);
794
+ return unwrap3(data);
699
795
  }
700
796
  };
701
- function unwrap2(payload) {
797
+ function unwrap4(payload) {
702
798
  if (payload && typeof payload === "object" && "data" in payload) {
703
799
  return payload.data;
704
800
  }
@@ -734,26 +830,26 @@ var ApiKeys = class {
734
830
  }
735
831
  async create(params) {
736
832
  const { idempotencyKey: ikey, expiresAt, ...rest } = params;
737
- const body = stripUndefined3({
833
+ const body2 = stripUndefined3({
738
834
  ...rest,
739
835
  expires_at: expiresAt ?? rest.expires_at
740
836
  });
741
837
  const data = await this.http.request("/api-keys", {
742
838
  method: "POST",
743
- body,
839
+ body: body2,
744
840
  headers: { "Idempotency-Key": idempotencyKey(ikey) }
745
841
  });
746
- return unwrap2(data);
842
+ return unwrap4(data);
747
843
  }
748
844
  /** POST /api/v1/api-keys/scoped — L2 delegation token bound to one external user. */
749
845
  async createScoped(params) {
750
- const body = stripUndefined3({
846
+ const body2 = stripUndefined3({
751
847
  external_user_id: params.externalUserId,
752
848
  scopes: params.scopes,
753
849
  expires_at: params.expiresAt
754
850
  });
755
- return unwrap2(
756
- await this.http.post("/api-keys/scoped", body)
851
+ return unwrap4(
852
+ await this.http.post("/api-keys/scoped", body2)
757
853
  );
758
854
  }
759
855
  async delete(keyId) {
@@ -762,7 +858,7 @@ var ApiKeys = class {
762
858
  };
763
859
 
764
860
  // src/resources/audit-log.ts
765
- function unwrap3(payload) {
861
+ function unwrap5(payload) {
766
862
  if (payload && typeof payload === "object") {
767
863
  const p = payload;
768
864
  for (const k of ["data", "audit_log", "events", "items"]) {
@@ -785,14 +881,14 @@ var AuditLog = class {
785
881
  async list(params = {}) {
786
882
  const query = stripUndefined4(params);
787
883
  const data = await this.http.get("/audit-log", query);
788
- const result = unwrap3(data);
884
+ const result = unwrap5(data);
789
885
  if (Array.isArray(result)) return result;
790
886
  return [];
791
887
  }
792
888
  };
793
889
 
794
890
  // src/resources/benchmarks.ts
795
- function unwrap4(data) {
891
+ function unwrap6(data) {
796
892
  if (data && typeof data === "object") {
797
893
  const d = data;
798
894
  for (const k of ["data", "benchmarks", "samples", "items"]) {
@@ -824,19 +920,19 @@ var Benchmarks = class {
824
920
  return unwrapList(data);
825
921
  }
826
922
  async get(benchmarkId) {
827
- return unwrap4(
923
+ return unwrap6(
828
924
  await this.http.get(`/admin/benchmarks/${benchmarkId}`)
829
925
  );
830
926
  }
831
927
  /** Start a new benchmark run — pass kind and run-specific options. */
832
928
  async create(params) {
833
- const body = Object.fromEntries(
929
+ const body2 = Object.fromEntries(
834
930
  Object.entries(params).filter(([, v]) => v !== void 0)
835
931
  );
836
- return unwrap4(await this.http.post("/admin/benchmarks", body));
932
+ return unwrap6(await this.http.post("/admin/benchmarks", body2));
837
933
  }
838
934
  async cancel(benchmarkId) {
839
- return unwrap4(
935
+ return unwrap6(
840
936
  await this.http.post(`/admin/benchmarks/${benchmarkId}/cancel`)
841
937
  );
842
938
  }
@@ -853,17 +949,17 @@ var Benchmarks = class {
853
949
  }
854
950
  /** Compare two benchmark runs. */
855
951
  async compare(params) {
856
- const body = Object.fromEntries(
952
+ const body2 = Object.fromEntries(
857
953
  Object.entries(params).filter(([, v]) => v !== void 0)
858
954
  );
859
- return unwrap4(
860
- await this.http.post("/admin/benchmarks/compare", body)
955
+ return unwrap6(
956
+ await this.http.post("/admin/benchmarks/compare", body2)
861
957
  );
862
958
  }
863
959
  };
864
960
 
865
961
  // src/resources/builder-sessions.ts
866
- function unwrap5(data) {
962
+ function unwrap7(data) {
867
963
  if (data && typeof data === "object") {
868
964
  const d = data;
869
965
  for (const k of ["data", "sessions", "items"]) {
@@ -900,7 +996,7 @@ var BuilderSessions = class {
900
996
  return all.find((s) => s.id === sessionId) ?? {};
901
997
  }
902
998
  async updateTitle(sessionId, title) {
903
- return unwrap5(
999
+ return unwrap7(
904
1000
  await this.http.patch(`/builder/sessions/${sessionId}/title`, {
905
1001
  title
906
1002
  })
@@ -912,7 +1008,7 @@ var BuilderSessions = class {
912
1008
  };
913
1009
 
914
1010
  // src/resources/channels.ts
915
- function unwrap6(payload) {
1011
+ function unwrap8(payload) {
916
1012
  if (payload && typeof payload === "object") {
917
1013
  const p = payload;
918
1014
  for (const k of ["data", "channels", "notifications", "items"]) {
@@ -940,26 +1036,26 @@ var Channels = class {
940
1036
  async list(params = {}) {
941
1037
  const query = stripUndefined5(params);
942
1038
  const data = await this.http.get("/channels", query);
943
- const result = unwrap6(data);
1039
+ const result = unwrap8(data);
944
1040
  if (Array.isArray(result)) return result;
945
1041
  return [];
946
1042
  }
947
1043
  /** Get a single channel. */
948
1044
  async get(channelId) {
949
1045
  const data = await this.http.get(`/channels/${channelId}`);
950
- return unwrap6(data);
1046
+ return unwrap8(data);
951
1047
  }
952
1048
  /** Create a new channel. */
953
1049
  async create(params) {
954
- const body = stripUndefObj(params);
955
- const data = await this.http.post("/channels", body);
956
- return unwrap6(data);
1050
+ const body2 = stripUndefObj(params);
1051
+ const data = await this.http.post("/channels", body2);
1052
+ return unwrap8(data);
957
1053
  }
958
1054
  /** Update a channel. */
959
1055
  async update(channelId, params) {
960
- const body = stripUndefObj(params);
961
- const data = await this.http.patch(`/channels/${channelId}`, body);
962
- return unwrap6(data);
1056
+ const body2 = stripUndefObj(params);
1057
+ const data = await this.http.patch(`/channels/${channelId}`, body2);
1058
+ return unwrap8(data);
963
1059
  }
964
1060
  /** Delete a channel. */
965
1061
  async delete(channelId) {
@@ -969,30 +1065,30 @@ var Channels = class {
969
1065
  /** Get notification preferences across all channels. */
970
1066
  async listNotifications() {
971
1067
  const data = await this.http.get("/channels/notifications");
972
- return unwrap6(data);
1068
+ return unwrap8(data);
973
1069
  }
974
1070
  /** Update notification preferences. */
975
1071
  async updateNotifications(params) {
976
- const body = stripUndefObj(params);
977
- const data = await this.http.put("/channels/notifications", body);
978
- return unwrap6(data);
1072
+ const body2 = stripUndefObj(params);
1073
+ const data = await this.http.put("/channels/notifications", body2);
1074
+ return unwrap8(data);
979
1075
  }
980
1076
  /** Enable a channel. */
981
1077
  async enable(channelId) {
982
1078
  const data = await this.http.post(`/channels/${channelId}/enable`);
983
- return unwrap6(data);
1079
+ return unwrap8(data);
984
1080
  }
985
1081
  /** Disable a channel. */
986
1082
  async disable(channelId) {
987
1083
  const data = await this.http.post(
988
1084
  `/channels/${channelId}/disable`
989
1085
  );
990
- return unwrap6(data);
1086
+ return unwrap8(data);
991
1087
  }
992
1088
  };
993
1089
 
994
1090
  // src/resources/command-center.ts
995
- function unwrap7(data) {
1091
+ function unwrap9(data) {
996
1092
  if (data && typeof data === "object") {
997
1093
  const d = data;
998
1094
  for (const k of [
@@ -1026,7 +1122,7 @@ var CommandCenter = class {
1026
1122
  http;
1027
1123
  /** Top-level snapshot (GET /command-center). */
1028
1124
  async overview() {
1029
- return unwrap7(await this.http.get("/command-center"));
1125
+ return unwrap9(await this.http.get("/command-center"));
1030
1126
  }
1031
1127
  async agents() {
1032
1128
  return unwrapList3(await this.http.get("/command-center/agents"));
@@ -1037,13 +1133,13 @@ var CommandCenter = class {
1037
1133
  );
1038
1134
  }
1039
1135
  async metrics() {
1040
- return unwrap7(await this.http.get("/command-center/metrics"));
1136
+ return unwrap9(await this.http.get("/command-center/metrics"));
1041
1137
  }
1042
1138
  async presets() {
1043
1139
  return unwrapList3(await this.http.get("/command-center/presets"));
1044
1140
  }
1045
1141
  async tiers() {
1046
- return unwrap7(await this.http.get("/command-center/tiers"));
1142
+ return unwrap9(await this.http.get("/command-center/tiers"));
1047
1143
  }
1048
1144
  /** Stream live command-center events via SSE. */
1049
1145
  events() {
@@ -1052,7 +1148,7 @@ var CommandCenter = class {
1052
1148
  };
1053
1149
 
1054
1150
  // src/resources/community.ts
1055
- function unwrap8(data) {
1151
+ function unwrap10(data) {
1056
1152
  if (data && typeof data === "object") {
1057
1153
  const d = data;
1058
1154
  for (const k of ["data", "templates", "agents", "items"]) {
@@ -1084,7 +1180,7 @@ var Community = class {
1084
1180
  return unwrapList4(await this.http.get("/community/agents", query));
1085
1181
  }
1086
1182
  async getAgent(agentId) {
1087
- return unwrap8(await this.http.get(`/community/agents/${agentId}`));
1183
+ return unwrap10(await this.http.get(`/community/agents/${agentId}`));
1088
1184
  }
1089
1185
  // ── Templates ─────────────────────────────────────────────────────────
1090
1186
  async listTemplates(filters = {}) {
@@ -1096,41 +1192,41 @@ var Community = class {
1096
1192
  );
1097
1193
  }
1098
1194
  async getTemplate(templateId) {
1099
- return unwrap8(
1195
+ return unwrap10(
1100
1196
  await this.http.get(`/community/templates/${templateId}`)
1101
1197
  );
1102
1198
  }
1103
1199
  /** Install a community template into the caller's tenant. */
1104
1200
  async installTemplate(templateId, opts = {}) {
1105
- const body = Object.fromEntries(
1201
+ const body2 = Object.fromEntries(
1106
1202
  Object.entries(opts).filter(([, v]) => v !== void 0)
1107
1203
  );
1108
- return unwrap8(
1204
+ return unwrap10(
1109
1205
  await this.http.post(
1110
1206
  `/community/templates/${templateId}/install`,
1111
- body
1207
+ body2
1112
1208
  )
1113
1209
  );
1114
1210
  }
1115
1211
  /** Rate a community template (1–5). */
1116
1212
  async rateTemplate(templateId, rating, opts = {}) {
1117
- const body = {
1213
+ const body2 = {
1118
1214
  rating,
1119
1215
  ...Object.fromEntries(
1120
1216
  Object.entries(opts).filter(([, v]) => v !== void 0)
1121
1217
  )
1122
1218
  };
1123
- return unwrap8(
1219
+ return unwrap10(
1124
1220
  await this.http.post(
1125
1221
  `/community/templates/${templateId}/rate`,
1126
- body
1222
+ body2
1127
1223
  )
1128
1224
  );
1129
1225
  }
1130
1226
  };
1131
1227
 
1132
1228
  // src/resources/completions.ts
1133
- function unwrap9(data) {
1229
+ function unwrap11(data) {
1134
1230
  if (data && typeof data === "object") {
1135
1231
  const d = data;
1136
1232
  if (Array.isArray(d.choices)) return d;
@@ -1149,24 +1245,24 @@ var Completions = class {
1149
1245
  }
1150
1246
  http;
1151
1247
  create(params) {
1152
- const body = buildBody(params);
1248
+ const body2 = buildBody(params);
1153
1249
  if (params.stream === true) {
1154
1250
  return this.http.stream(
1155
1251
  "/intelligence/completions",
1156
- { method: "POST", body }
1252
+ { method: "POST", body: body2 }
1157
1253
  );
1158
1254
  }
1159
- return this.http.post("/intelligence/completions", body).then(unwrap9);
1255
+ return this.http.post("/intelligence/completions", body2).then(unwrap11);
1160
1256
  }
1161
1257
  chat(params) {
1162
- const body = buildBody(params);
1258
+ const body2 = buildBody(params);
1163
1259
  if (params.stream === true) {
1164
1260
  return this.http.stream(
1165
1261
  "/intelligence/chat/completions",
1166
- { method: "POST", body }
1262
+ { method: "POST", body: body2 }
1167
1263
  );
1168
1264
  }
1169
- return this.http.post("/intelligence/chat/completions", body).then(unwrap9);
1265
+ return this.http.post("/intelligence/chat/completions", body2).then(unwrap11);
1170
1266
  }
1171
1267
  };
1172
1268
 
@@ -1289,7 +1385,7 @@ var Checkpoints = class {
1289
1385
  };
1290
1386
 
1291
1387
  // src/resources/computer-auto-stop.ts
1292
- function unwrap10(data) {
1388
+ function unwrap12(data) {
1293
1389
  if (data && typeof data === "object") {
1294
1390
  const d = data;
1295
1391
  if ("data" in d && Object.keys(d).length <= 2) {
@@ -1307,13 +1403,13 @@ var ComputerAutoStop = class {
1307
1403
  computerId;
1308
1404
  /** Return the current auto-stop configuration. */
1309
1405
  async get() {
1310
- return unwrap10(
1406
+ return unwrap12(
1311
1407
  await this.http.get(`/computers/${this.computerId}/auto-stop`)
1312
1408
  );
1313
1409
  }
1314
1410
  /** Set the idle timeout in seconds (0 disables auto-stop). */
1315
1411
  async update(seconds) {
1316
- return unwrap10(
1412
+ return unwrap12(
1317
1413
  await this.http.patch(
1318
1414
  `/computers/${this.computerId}/auto-stop`,
1319
1415
  { seconds }
@@ -1323,7 +1419,7 @@ var ComputerAutoStop = class {
1323
1419
  };
1324
1420
 
1325
1421
  // src/resources/computer-env.ts
1326
- function unwrap11(data) {
1422
+ function unwrap13(data) {
1327
1423
  if (data && typeof data === "object") {
1328
1424
  const d = data;
1329
1425
  if ("data" in d && Object.keys(d).length <= 2) {
@@ -1358,11 +1454,11 @@ var ComputerEnv = class {
1358
1454
  }
1359
1455
  /** Create a new env var. Use update() to change an existing one. */
1360
1456
  async set(name, value) {
1361
- return unwrap11(await this.http.post(this.base(), { name, value }));
1457
+ return unwrap13(await this.http.post(this.base(), { name, value }));
1362
1458
  }
1363
1459
  /** Patch the value of an existing env var by name. */
1364
1460
  async update(name, value) {
1365
- return unwrap11(
1461
+ return unwrap13(
1366
1462
  await this.http.patch(`${this.base()}/${name}`, { value })
1367
1463
  );
1368
1464
  }
@@ -1379,7 +1475,7 @@ var ComputerEnv = class {
1379
1475
  };
1380
1476
 
1381
1477
  // src/resources/computer-logs.ts
1382
- function unwrap12(data) {
1478
+ function unwrap14(data) {
1383
1479
  if (data && typeof data === "object") {
1384
1480
  const d = data;
1385
1481
  if ("data" in d && Object.keys(d).length <= 2) {
@@ -1400,7 +1496,7 @@ var ComputerLogs = class {
1400
1496
  const query = Object.fromEntries(
1401
1497
  Object.entries(params).filter(([, v]) => v !== void 0)
1402
1498
  );
1403
- return unwrap12(
1499
+ return unwrap14(
1404
1500
  await this.http.get(`/computers/${this.computerId}/logs`, query)
1405
1501
  );
1406
1502
  }
@@ -1413,7 +1509,7 @@ var ComputerLogs = class {
1413
1509
  };
1414
1510
 
1415
1511
  // src/resources/computer-osa.ts
1416
- function unwrap13(data) {
1512
+ function unwrap15(data) {
1417
1513
  if (data && typeof data === "object") {
1418
1514
  const d = data;
1419
1515
  if ("data" in d && Object.keys(d).length <= 2) {
@@ -1431,47 +1527,47 @@ var ComputerOsa = class {
1431
1527
  computerId;
1432
1528
  /** Submit a free-form task to the in-VM OSA agent. */
1433
1529
  async submitTask(task, params = {}) {
1434
- const body = {
1530
+ const body2 = {
1435
1531
  task,
1436
1532
  ...Object.fromEntries(
1437
1533
  Object.entries(params).filter(([, v]) => v !== void 0)
1438
1534
  )
1439
1535
  };
1440
- return unwrap13(
1536
+ return unwrap15(
1441
1537
  await this.http.post(
1442
1538
  `/computers/${this.computerId}/osa/task`,
1443
- body
1539
+ body2
1444
1540
  )
1445
1541
  );
1446
1542
  }
1447
1543
  /** Cancel the currently-running OSA task, if any. */
1448
1544
  async cancelTask() {
1449
- return unwrap13(
1545
+ return unwrap15(
1450
1546
  await this.http.delete(`/computers/${this.computerId}/osa/task`)
1451
1547
  );
1452
1548
  }
1453
1549
  /** Return OSA's current task / configuration / health snapshot. */
1454
1550
  async status() {
1455
- return unwrap13(
1551
+ return unwrap15(
1456
1552
  await this.http.get(`/computers/${this.computerId}/osa/status`)
1457
1553
  );
1458
1554
  }
1459
1555
  /** Update OSA runtime configuration (model, tools, secrets, etc.). */
1460
1556
  async configure(config) {
1461
- const body = Object.fromEntries(
1557
+ const body2 = Object.fromEntries(
1462
1558
  Object.entries(config).filter(([, v]) => v !== void 0)
1463
1559
  );
1464
- return unwrap13(
1560
+ return unwrap15(
1465
1561
  await this.http.post(
1466
1562
  `/computers/${this.computerId}/osa/configure`,
1467
- body
1563
+ body2
1468
1564
  )
1469
1565
  );
1470
1566
  }
1471
1567
  };
1472
1568
 
1473
1569
  // src/resources/computer-ports.ts
1474
- function unwrap14(data) {
1570
+ function unwrap16(data) {
1475
1571
  if (data && typeof data === "object") {
1476
1572
  const d = data;
1477
1573
  if ("data" in d && Object.keys(d).length <= 2) {
@@ -1510,21 +1606,21 @@ var ComputerPorts = class {
1510
1606
  }
1511
1607
  /** Expose port with the given visibility options. */
1512
1608
  async create(port, opts = {}) {
1513
- const body = {
1609
+ const body2 = {
1514
1610
  port,
1515
1611
  ...Object.fromEntries(
1516
1612
  Object.entries(opts).filter(([, v]) => v !== void 0)
1517
1613
  )
1518
1614
  };
1519
- return unwrap14(await this.http.post(this.base(), body));
1615
+ return unwrap16(await this.http.post(this.base(), body2));
1520
1616
  }
1521
1617
  /** Patch visibility / auth options for port. */
1522
1618
  async update(port, opts) {
1523
- const body = Object.fromEntries(
1619
+ const body2 = Object.fromEntries(
1524
1620
  Object.entries(opts).filter(([, v]) => v !== void 0)
1525
1621
  );
1526
- return unwrap14(
1527
- await this.http.patch(`${this.base()}/${port}`, body)
1622
+ return unwrap16(
1623
+ await this.http.patch(`${this.base()}/${port}`, body2)
1528
1624
  );
1529
1625
  }
1530
1626
  /** Stop exposing port. */
@@ -1543,14 +1639,14 @@ var ComputerTerminal = class {
1543
1639
  computerId;
1544
1640
  /** Open a new PTY session. Returns the server payload (session id, etc.). */
1545
1641
  async create(params = {}) {
1546
- const body = Object.fromEntries(
1642
+ const body2 = Object.fromEntries(
1547
1643
  Object.entries(params).filter(([, v]) => v !== void 0)
1548
1644
  );
1549
1645
  const raw = await this.http.post(
1550
1646
  `/computers/${this.computerId}/terminal`,
1551
- body
1647
+ body2
1552
1648
  );
1553
- return unwrap15(raw);
1649
+ return unwrap17(raw);
1554
1650
  }
1555
1651
  /** Resize an existing PTY session. */
1556
1652
  async resize(sessionId, cols, rows) {
@@ -1558,10 +1654,10 @@ var ComputerTerminal = class {
1558
1654
  `/computers/${this.computerId}/pty/${sessionId}/resize`,
1559
1655
  { cols, rows }
1560
1656
  );
1561
- return unwrap15(raw);
1657
+ return unwrap17(raw);
1562
1658
  }
1563
1659
  };
1564
- function unwrap15(data) {
1660
+ function unwrap17(data) {
1565
1661
  if (data && typeof data === "object") {
1566
1662
  const d = data;
1567
1663
  if ("data" in d && Object.keys(d).length <= 2) {
@@ -1572,7 +1668,7 @@ function unwrap15(data) {
1572
1668
  }
1573
1669
 
1574
1670
  // src/resources/computer-volumes.ts
1575
- function unwrap16(data) {
1671
+ function unwrap18(data) {
1576
1672
  if (data && typeof data === "object") {
1577
1673
  const d = data;
1578
1674
  if ("data" in d && Object.keys(d).length <= 2) {
@@ -1606,7 +1702,7 @@ var ComputerVolumes = class {
1606
1702
  }
1607
1703
  /** Attach volumeId at mountPath inside the VM. */
1608
1704
  async attach(volumeId, mountPath) {
1609
- return unwrap16(
1705
+ return unwrap18(
1610
1706
  await this.http.post(this.base(), {
1611
1707
  volume_id: volumeId,
1612
1708
  mount_path: mountPath
@@ -1779,7 +1875,7 @@ var Desktop = class {
1779
1875
  };
1780
1876
 
1781
1877
  // src/resources/egressAudit.ts
1782
- function unwrap17(payload) {
1878
+ function unwrap19(payload) {
1783
1879
  if (payload && typeof payload === "object") {
1784
1880
  const p = payload;
1785
1881
  for (const k of ["data", "event", "items"]) {
@@ -1807,7 +1903,7 @@ function pickFirst(...values) {
1807
1903
  for (const v of values) if (v !== void 0) return v;
1808
1904
  return void 0;
1809
1905
  }
1810
- function listQuery2(params) {
1906
+ function listQuery(params) {
1811
1907
  return stripUndefined6({
1812
1908
  resource_id: pickFirst(params.resourceId, params.resource_id),
1813
1909
  resource_type: pickFirst(params.resourceType, params.resource_type),
@@ -1836,7 +1932,7 @@ var EgressAudit = class {
1836
1932
  async list(params = {}) {
1837
1933
  const data = await this.http.get(
1838
1934
  "/egress/audit",
1839
- listQuery2(params)
1935
+ listQuery(params)
1840
1936
  );
1841
1937
  return unwrapList8(data);
1842
1938
  }
@@ -1845,7 +1941,7 @@ var EgressAudit = class {
1845
1941
  const data = await this.http.get(
1846
1942
  `/egress/audit/${id}`
1847
1943
  );
1848
- return unwrap17(data);
1944
+ return unwrap19(data);
1849
1945
  }
1850
1946
  /**
1851
1947
  * Long-poll the audit endpoint and yield new events as they appear.
@@ -1863,7 +1959,7 @@ var EgressAudit = class {
1863
1959
  if (since !== void 0) queryParams.since = since;
1864
1960
  const data = await this.http.get(
1865
1961
  "/egress/audit",
1866
- listQuery2(queryParams)
1962
+ listQuery(queryParams)
1867
1963
  );
1868
1964
  const events = unwrapList8(data);
1869
1965
  for (const event of events) {
@@ -1921,7 +2017,7 @@ var ComputerAudit = class extends SandboxAudit {
1921
2017
  };
1922
2018
 
1923
2019
  // src/resources/egressNetwork.ts
1924
- function unwrap18(payload) {
2020
+ function unwrap20(payload) {
1925
2021
  if (payload && typeof payload === "object") {
1926
2022
  const p = payload;
1927
2023
  for (const k of ["data", "policy", "rule", "items"]) {
@@ -1980,7 +2076,7 @@ var EgressNetwork = class {
1980
2076
  "/egress/allowlist",
1981
2077
  ruleBody(host, params, "allow")
1982
2078
  );
1983
- return unwrap18(data);
2079
+ return unwrap20(data);
1984
2080
  }
1985
2081
  /** Add a `deny` rule for `host` to the allowlist. */
1986
2082
  async deny(host, params = {}) {
@@ -1988,7 +2084,7 @@ var EgressNetwork = class {
1988
2084
  "/egress/allowlist",
1989
2085
  ruleBody(host, params, "deny")
1990
2086
  );
1991
- return unwrap18(data);
2087
+ return unwrap20(data);
1992
2088
  }
1993
2089
  /** List allowlist rules. */
1994
2090
  async rules(params = {}) {
@@ -2016,7 +2112,7 @@ var EgressNetwork = class {
2016
2112
  }
2017
2113
  /** Create an egress policy. */
2018
2114
  async createPolicy(params) {
2019
- const body = stripUndefined7({
2115
+ const body2 = stripUndefined7({
2020
2116
  name: params.name,
2021
2117
  mode: params.mode ?? "enforce",
2022
2118
  default_effect: pickFirst2(
@@ -2030,13 +2126,13 @@ var EgressNetwork = class {
2030
2126
  });
2031
2127
  const data = await this.http.post(
2032
2128
  "/egress/policies",
2033
- body
2129
+ body2
2034
2130
  );
2035
- return unwrap18(data);
2131
+ return unwrap20(data);
2036
2132
  }
2037
2133
  /** Update an egress policy by id. */
2038
2134
  async updatePolicy(policyId, params) {
2039
- const body = stripUndefined7({
2135
+ const body2 = stripUndefined7({
2040
2136
  mode: params.mode,
2041
2137
  default_effect: pickFirst2(params.defaultEffect, params.default_effect),
2042
2138
  name: params.name,
@@ -2044,9 +2140,9 @@ var EgressNetwork = class {
2044
2140
  });
2045
2141
  const data = await this.http.patch(
2046
2142
  `/egress/policies/${policyId}`,
2047
- body
2143
+ body2
2048
2144
  );
2049
- return unwrap18(data);
2145
+ return unwrap20(data);
2050
2146
  }
2051
2147
  // ── mode helpers ──────────────────────────────────────────────────────────
2052
2148
  /** Set the policy to `mode="enforce"` — denied egress is blocked. */
@@ -2064,16 +2160,16 @@ var EgressNetwork = class {
2064
2160
  if (policyId) {
2065
2161
  return this.updatePolicy(policyId, { mode });
2066
2162
  }
2067
- const body = resourceId !== void 0 && resourceType !== void 0 ? stripUndefined7({
2163
+ const body2 = resourceId !== void 0 && resourceType !== void 0 ? stripUndefined7({
2068
2164
  mode,
2069
2165
  resource_id: resourceId,
2070
2166
  resource_type: resourceType
2071
2167
  }) : { mode };
2072
2168
  const data = await this.http.patch(
2073
2169
  "/egress/policies",
2074
- body
2170
+ body2
2075
2171
  );
2076
- return unwrap18(data);
2172
+ return unwrap20(data);
2077
2173
  }
2078
2174
  // ── suggestions ───────────────────────────────────────────────────────────
2079
2175
  /** AI-generated allowlist suggestions from recent denied egress. */
@@ -2129,28 +2225,28 @@ var SandboxNetwork = class {
2129
2225
  return this.delegate.removeRule(ruleId);
2130
2226
  }
2131
2227
  lockdown(params = {}) {
2132
- const body = {
2228
+ const body2 = {
2133
2229
  resource_id: this.resourceId,
2134
2230
  resource_type: this.resourceType
2135
2231
  };
2136
- if (params.policyId !== void 0) body.policyId = params.policyId;
2137
- return this.delegate.lockdown(body);
2232
+ if (params.policyId !== void 0) body2.policyId = params.policyId;
2233
+ return this.delegate.lockdown(body2);
2138
2234
  }
2139
2235
  observe(params = {}) {
2140
- const body = {
2236
+ const body2 = {
2141
2237
  resource_id: this.resourceId,
2142
2238
  resource_type: this.resourceType
2143
2239
  };
2144
- if (params.policyId !== void 0) body.policyId = params.policyId;
2145
- return this.delegate.observe(body);
2240
+ if (params.policyId !== void 0) body2.policyId = params.policyId;
2241
+ return this.delegate.observe(body2);
2146
2242
  }
2147
2243
  suggestions(params = {}) {
2148
- const body = {
2244
+ const body2 = {
2149
2245
  resource_id: this.resourceId,
2150
2246
  resource_type: this.resourceType
2151
2247
  };
2152
- if (params.since !== void 0) body.since = params.since;
2153
- return this.delegate.suggestions(body);
2248
+ if (params.since !== void 0) body2.since = params.since;
2249
+ return this.delegate.suggestions(body2);
2154
2250
  }
2155
2251
  policies() {
2156
2252
  return this.delegate.policies({
@@ -2164,7 +2260,7 @@ var ComputerNetwork = class extends SandboxNetwork {
2164
2260
  };
2165
2261
 
2166
2262
  // src/resources/egressSecrets.ts
2167
- function unwrap19(payload) {
2263
+ function unwrap21(payload) {
2168
2264
  if (payload && typeof payload === "object") {
2169
2265
  const p = payload;
2170
2266
  for (const k of ["data", "secret", "binding", "items"]) {
@@ -2213,7 +2309,7 @@ function setBody(params) {
2213
2309
  metadata: params.metadata
2214
2310
  });
2215
2311
  }
2216
- function listQuery3(params) {
2312
+ function listQuery2(params) {
2217
2313
  return stripUndefined8({
2218
2314
  scope: params.scope,
2219
2315
  type: params.type,
@@ -2300,7 +2396,7 @@ var OAuthFlow = class {
2300
2396
  const data = await this.http.get("/egress/oauth/status", {
2301
2397
  state: this.state
2302
2398
  });
2303
- const payload = unwrap19(data) ?? {};
2399
+ const payload = unwrap21(data) ?? {};
2304
2400
  const status = payload.status;
2305
2401
  if (status === "completed" || status === "ready" || status === "succeeded") {
2306
2402
  return payload;
@@ -2332,13 +2428,13 @@ var EgressSecrets = class {
2332
2428
  "/egress/secrets",
2333
2429
  setBody(params)
2334
2430
  );
2335
- return unwrap19(data);
2431
+ return unwrap21(data);
2336
2432
  }
2337
2433
  /** List secrets. */
2338
2434
  async list(params = {}) {
2339
2435
  const data = await this.http.get(
2340
2436
  "/egress/secrets",
2341
- listQuery3(params)
2437
+ listQuery2(params)
2342
2438
  );
2343
2439
  return unwrapList10(data);
2344
2440
  }
@@ -2347,16 +2443,16 @@ var EgressSecrets = class {
2347
2443
  const data = await this.http.get(
2348
2444
  `/egress/secrets/${id}`
2349
2445
  );
2350
- return unwrap19(data);
2446
+ return unwrap21(data);
2351
2447
  }
2352
2448
  /** Rotate the secret's value. */
2353
2449
  async rotate(id, params) {
2354
- const body = typeof params === "string" ? rotateBody({ newValue: params }) : rotateBody(params);
2450
+ const body2 = typeof params === "string" ? rotateBody({ newValue: params }) : rotateBody(params);
2355
2451
  const data = await this.http.patch(
2356
2452
  `/egress/secrets/${id}`,
2357
- body
2453
+ body2
2358
2454
  );
2359
- return unwrap19(data);
2455
+ return unwrap21(data);
2360
2456
  }
2361
2457
  /** Delete a secret. */
2362
2458
  async delete(id) {
@@ -2369,7 +2465,7 @@ var EgressSecrets = class {
2369
2465
  "/egress/bindings",
2370
2466
  bindingBody(params)
2371
2467
  );
2372
- return unwrap19(data);
2468
+ return unwrap21(data);
2373
2469
  }
2374
2470
  /** List secret bindings. */
2375
2471
  async listBindings(params = {}) {
@@ -2402,7 +2498,7 @@ var EgressSecrets = class {
2402
2498
  "/egress/oauth/start",
2403
2499
  oauthBody(params)
2404
2500
  );
2405
- const payload = unwrap19(data) ?? {};
2501
+ const payload = unwrap21(data) ?? {};
2406
2502
  return new OAuthFlow(this.http, payload, params.provider);
2407
2503
  }
2408
2504
  };
@@ -2966,12 +3062,12 @@ var ComputerInbox = class {
2966
3062
  return unwrapData(raw);
2967
3063
  }
2968
3064
  async update(fields) {
2969
- const body = Object.fromEntries(
3065
+ const body2 = Object.fromEntries(
2970
3066
  Object.entries(fields).filter(([, v]) => v !== void 0)
2971
3067
  );
2972
3068
  const raw = await this.http.patch(
2973
3069
  `/computers/${this.computerId}/inbox`,
2974
- body
3070
+ body2
2975
3071
  );
2976
3072
  return unwrapData(raw);
2977
3073
  }
@@ -3270,12 +3366,12 @@ var Computer = class _Computer {
3270
3366
  }
3271
3367
  /** Clone this computer into a new one. */
3272
3368
  async clone(opts = {}) {
3273
- const body = Object.fromEntries(
3369
+ const body2 = Object.fromEntries(
3274
3370
  Object.entries(opts).filter(([, v]) => v !== void 0)
3275
3371
  );
3276
3372
  const raw = await this.http.post(
3277
3373
  `/computers/${this.id}/clone`,
3278
- body
3374
+ body2
3279
3375
  );
3280
3376
  const data = unwrapData(raw);
3281
3377
  return new _Computer(this.http, data);
@@ -3291,12 +3387,12 @@ var Computer = class _Computer {
3291
3387
  }
3292
3388
  /** Move the computer to a different region or host. */
3293
3389
  async move(opts) {
3294
- const body = Object.fromEntries(
3390
+ const body2 = Object.fromEntries(
3295
3391
  Object.entries(opts).filter(([, v]) => v !== void 0)
3296
3392
  );
3297
3393
  const updated = await this.http.post(
3298
3394
  `/computers/${this.id}/move`,
3299
- body
3395
+ body2
3300
3396
  );
3301
3397
  this.data = updated;
3302
3398
  return this;
@@ -3374,10 +3470,18 @@ var Computers = class {
3374
3470
  * `computer.start()` once it reaches `stopped` to boot it.
3375
3471
  */
3376
3472
  async create(params) {
3473
+ const {
3474
+ agentRuntimeProfileId,
3475
+ agentProfileId,
3476
+ skipAgentRuntimeProfile,
3477
+ ...body2
3478
+ } = params;
3377
3479
  const data = await this.http.post("/computers", {
3378
3480
  template_type: "miosa-desktop",
3379
3481
  size: "small",
3380
- ...params
3482
+ ...body2,
3483
+ agent_runtime_profile_id: agentRuntimeProfileId ?? params.agent_runtime_profile_id ?? agentProfileId ?? params.agent_profile_id,
3484
+ skip_agent_runtime_profile: skipAgentRuntimeProfile ?? params.skip_agent_runtime_profile
3381
3485
  });
3382
3486
  return new Computer(this.http, data);
3383
3487
  }
@@ -3447,7 +3551,7 @@ var Credits = class {
3447
3551
  return this.http.get("/credits/usage");
3448
3552
  }
3449
3553
  };
3450
- function unwrap20(payload) {
3554
+ function unwrap22(payload) {
3451
3555
  if (payload && typeof payload === "object" && "data" in payload) {
3452
3556
  return payload.data;
3453
3557
  }
@@ -3483,22 +3587,22 @@ var CronJobs = class {
3483
3587
  }
3484
3588
  async get(jobId) {
3485
3589
  const data = await this.http.get(`/cron-jobs/${jobId}`);
3486
- return unwrap20(data);
3590
+ return unwrap22(data);
3487
3591
  }
3488
3592
  async create(params) {
3489
3593
  const { idempotencyKey: ikey, ...rest } = params;
3490
- const body = stripUndefined9(rest);
3594
+ const body2 = stripUndefined9(rest);
3491
3595
  const data = await this.http.request("/cron-jobs", {
3492
3596
  method: "POST",
3493
- body,
3597
+ body: body2,
3494
3598
  headers: { "Idempotency-Key": idempotencyKey2(ikey) }
3495
3599
  });
3496
- return unwrap20(data);
3600
+ return unwrap22(data);
3497
3601
  }
3498
3602
  async update(jobId, params) {
3499
- const body = stripUndefined9(params);
3500
- const data = await this.http.patch(`/cron-jobs/${jobId}`, body);
3501
- return unwrap20(data);
3603
+ const body2 = stripUndefined9(params);
3604
+ const data = await this.http.patch(`/cron-jobs/${jobId}`, body2);
3605
+ return unwrap22(data);
3502
3606
  }
3503
3607
  async delete(jobId) {
3504
3608
  await this.http.delete(`/cron-jobs/${jobId}`);
@@ -3506,11 +3610,11 @@ var CronJobs = class {
3506
3610
  // ── Control ────────────────────────────────────────────────────────────────
3507
3611
  async pause(jobId) {
3508
3612
  const data = await this.http.post(`/cron-jobs/${jobId}/pause`);
3509
- return unwrap20(data);
3613
+ return unwrap22(data);
3510
3614
  }
3511
3615
  async resume(jobId) {
3512
3616
  const data = await this.http.post(`/cron-jobs/${jobId}/resume`);
3513
- return unwrap20(data);
3617
+ return unwrap22(data);
3514
3618
  }
3515
3619
  async runNow(jobId, opts = {}) {
3516
3620
  const data = await this.http.request(
@@ -3520,7 +3624,7 @@ var CronJobs = class {
3520
3624
  headers: { "Idempotency-Key": idempotencyKey2(opts.idempotencyKey) }
3521
3625
  }
3522
3626
  );
3523
- return unwrap20(data);
3627
+ return unwrap22(data);
3524
3628
  }
3525
3629
  // ── Execution history ──────────────────────────────────────────────────────
3526
3630
  async listExecutions(jobId) {
@@ -3535,12 +3639,12 @@ var CronJobs = class {
3535
3639
  const data = await this.http.get(
3536
3640
  `/cron-jobs/${jobId}/executions/${executionId}`
3537
3641
  );
3538
- return unwrap20(data);
3642
+ return unwrap22(data);
3539
3643
  }
3540
3644
  };
3541
3645
 
3542
3646
  // src/resources/dashboard.ts
3543
- function unwrap21(payload) {
3647
+ function unwrap23(payload) {
3544
3648
  if (payload && typeof payload === "object") {
3545
3649
  const p = payload;
3546
3650
  for (const k of ["data", "dashboard", "overview", "items"]) {
@@ -3557,15 +3661,15 @@ var Dashboard = class {
3557
3661
  /** Aggregated user dashboard payload. */
3558
3662
  async summary() {
3559
3663
  const data = await this.http.get("/dashboard");
3560
- return unwrap21(data);
3664
+ return unwrap23(data);
3561
3665
  }
3562
3666
  /** Status / health overview (public endpoint). */
3563
3667
  async overview() {
3564
3668
  const data = await this.http.get("/overview");
3565
- return unwrap21(data);
3669
+ return unwrap23(data);
3566
3670
  }
3567
3671
  };
3568
- function unwrap22(payload) {
3672
+ function unwrap24(payload) {
3569
3673
  if (payload && typeof payload === "object" && "data" in payload) {
3570
3674
  return payload.data;
3571
3675
  }
@@ -3601,7 +3705,7 @@ var Databases = class {
3601
3705
  }
3602
3706
  async get(databaseId) {
3603
3707
  const data = await this.http.get(`/databases/${databaseId}`);
3604
- return unwrap22(data);
3708
+ return unwrap24(data);
3605
3709
  }
3606
3710
  async create(params) {
3607
3711
  const {
@@ -3612,20 +3716,20 @@ var Databases = class {
3612
3716
  size: _deprecatedSize,
3613
3717
  ...rest
3614
3718
  } = params;
3615
- const body = stripUndefined10({
3719
+ const body2 = stripUndefined10({
3616
3720
  ...rest,
3617
3721
  engine_version: engine_version ?? version
3618
3722
  });
3619
3723
  const data = await this.http.request("/databases", {
3620
3724
  method: "POST",
3621
- body,
3725
+ body: body2,
3622
3726
  headers: {
3623
3727
  "Idempotency-Key": idempotencyKey3(
3624
3728
  camelIdempotencyKey ?? snakeIdempotencyKey
3625
3729
  )
3626
3730
  }
3627
3731
  });
3628
- return unwrap22(data);
3732
+ return unwrap24(data);
3629
3733
  }
3630
3734
  async delete(databaseId) {
3631
3735
  await this.http.delete(`/databases/${databaseId}`);
@@ -3635,24 +3739,24 @@ var Databases = class {
3635
3739
  const data = await this.http.post(
3636
3740
  `/databases/${databaseId}/start`
3637
3741
  );
3638
- return unwrap22(data);
3742
+ return unwrap24(data);
3639
3743
  }
3640
3744
  async stop(databaseId) {
3641
3745
  const data = await this.http.post(`/databases/${databaseId}/stop`);
3642
- return unwrap22(data);
3746
+ return unwrap24(data);
3643
3747
  }
3644
3748
  async restart(databaseId) {
3645
3749
  const data = await this.http.post(
3646
3750
  `/databases/${databaseId}/restart`
3647
3751
  );
3648
- return unwrap22(data);
3752
+ return unwrap24(data);
3649
3753
  }
3650
3754
  // ── Credentials + logs ────────────────────────────────────────────────────
3651
3755
  async credentials(databaseId) {
3652
3756
  const data = await this.http.get(
3653
3757
  `/databases/${databaseId}/credentials`
3654
3758
  );
3655
- return unwrap22(data);
3759
+ return unwrap24(data);
3656
3760
  }
3657
3761
  async logs(databaseId, params = {}) {
3658
3762
  const query = stripUndefined10({
@@ -3682,7 +3786,7 @@ function attributionBody(p) {
3682
3786
  function idempotencyKey4(key) {
3683
3787
  return key ?? randomUUID();
3684
3788
  }
3685
- function unwrap23(payload) {
3789
+ function unwrap25(payload) {
3686
3790
  if (payload && typeof payload === "object" && "data" in payload) {
3687
3791
  return payload.data;
3688
3792
  }
@@ -3709,6 +3813,42 @@ function dockerDeployMetadata(metadata) {
3709
3813
  deployment_product: "docker_deploy"
3710
3814
  };
3711
3815
  }
3816
+ function dockerDeployProduct(deployment) {
3817
+ return deployment.deployment_product ?? deployment.metadata?.deployment_product;
3818
+ }
3819
+ function dockerDeployHostId(deployment) {
3820
+ const metadataHost = deployment.metadata?.docker_deploy_host_id;
3821
+ return deployment.docker_deploy_host_id ?? (typeof metadataHost === "string" ? metadataHost : null);
3822
+ }
3823
+ function dockerDeployApp(deployment) {
3824
+ const app = deployment.metadata?.docker_deploy;
3825
+ if (!app || typeof app !== "object" || Array.isArray(app)) return null;
3826
+ return app;
3827
+ }
3828
+ function dockerDeployAppPort(app) {
3829
+ const url = app?.url;
3830
+ if (typeof url !== "string") return null;
3831
+ try {
3832
+ const parsed = new URL(url);
3833
+ const port = Number.parseInt(parsed.port, 10);
3834
+ return Number.isInteger(port) ? port : null;
3835
+ } catch {
3836
+ return null;
3837
+ }
3838
+ }
3839
+ function addDoctorCheck(checks, name, ok, message, details) {
3840
+ checks.push({ name, ok, message, ...details ? { details } : {} });
3841
+ }
3842
+ function hostHealthy(host) {
3843
+ return Boolean(
3844
+ host && host.status === "active" && host.appliance_status === "healthy"
3845
+ );
3846
+ }
3847
+ function probeUrl(publicUrl, probePath) {
3848
+ const url = new URL(publicUrl);
3849
+ url.pathname = probePath.startsWith("/") ? probePath : `/${probePath}`;
3850
+ return url.toString();
3851
+ }
3712
3852
  var DeploymentVersions = class {
3713
3853
  constructor(http, deploymentId) {
3714
3854
  this.http = http;
@@ -3733,19 +3873,19 @@ var DeploymentVersions = class {
3733
3873
  const data = await this.http.get(
3734
3874
  `/deployments/${this.deploymentId}/versions/${versionId}`
3735
3875
  );
3736
- return unwrap23(data);
3876
+ return unwrap25(data);
3737
3877
  }
3738
3878
  async promote(versionId, opts = {}) {
3739
- const body = stripUndefined11({ environment: opts.environment });
3879
+ const body2 = stripUndefined11({ environment: opts.environment });
3740
3880
  const data = await this.http.request(
3741
3881
  `/deployments/${this.deploymentId}/versions/${versionId}/promote`,
3742
3882
  {
3743
3883
  method: "POST",
3744
- body,
3884
+ body: body2,
3745
3885
  headers: { "Idempotency-Key": idempotencyKey4(opts.idempotencyKey) }
3746
3886
  }
3747
3887
  );
3748
- return unwrap23(data);
3888
+ return unwrap25(data);
3749
3889
  }
3750
3890
  };
3751
3891
  var DeploymentReleases = class {
@@ -3765,7 +3905,7 @@ var DeploymentReleases = class {
3765
3905
  const data = await this.http.get(
3766
3906
  `/deployments/${this.deploymentId}/releases/${releaseId}`
3767
3907
  );
3768
- return unwrap23(data);
3908
+ return unwrap25(data);
3769
3909
  }
3770
3910
  };
3771
3911
  var DeploymentRuntimeInstances = class {
@@ -3785,14 +3925,14 @@ var DeploymentRuntimeInstances = class {
3785
3925
  const data = await this.http.get(
3786
3926
  `/deployments/${this.deploymentId}/runtime-instances/${instanceId}`
3787
3927
  );
3788
- return unwrap23(data);
3928
+ return unwrap25(data);
3789
3929
  }
3790
3930
  async logs(instanceId, lines = 100) {
3791
3931
  const data = await this.http.get(
3792
3932
  `/deployments/${this.deploymentId}/runtime-instances/${instanceId}/logs`,
3793
3933
  { lines }
3794
3934
  );
3795
- const unwrapped = unwrap23(data);
3935
+ const unwrapped = unwrap25(data);
3796
3936
  const result = { logs: String(unwrapped.logs ?? "") };
3797
3937
  if (typeof unwrapped.runtime_instance_id === "string") {
3798
3938
  result.runtime_instance_id = unwrapped.runtime_instance_id;
@@ -3814,7 +3954,7 @@ var DeploymentDomains = class {
3814
3954
  http;
3815
3955
  deploymentId;
3816
3956
  async add(domain, params = {}) {
3817
- const body = {
3957
+ const body2 = {
3818
3958
  domain,
3819
3959
  redirect_policy: params.redirectPolicy ?? params.redirect_policy,
3820
3960
  ...attributionBody(params)
@@ -3823,11 +3963,11 @@ var DeploymentDomains = class {
3823
3963
  `/deployments/${this.deploymentId}/domains`,
3824
3964
  {
3825
3965
  method: "POST",
3826
- body: stripUndefined11(body),
3966
+ body: stripUndefined11(body2),
3827
3967
  headers: { "Idempotency-Key": idempotencyKey4(params.idempotencyKey) }
3828
3968
  }
3829
3969
  );
3830
- return unwrap23(data);
3970
+ return unwrap25(data);
3831
3971
  }
3832
3972
  async list(filters = {}) {
3833
3973
  const data = await this.http.get(
@@ -3840,7 +3980,7 @@ var DeploymentDomains = class {
3840
3980
  const data = await this.http.post(
3841
3981
  `/deployments/${this.deploymentId}/domains/${domainId}/verify`
3842
3982
  );
3843
- return unwrap23(data);
3983
+ return unwrap25(data);
3844
3984
  }
3845
3985
  async delete(domainId) {
3846
3986
  await this.http.delete(
@@ -3870,10 +4010,10 @@ var Deployments = class {
3870
4010
  }
3871
4011
  async get(deploymentId) {
3872
4012
  const data = await this.http.get(`/deployments/${deploymentId}`);
3873
- return unwrap23(data);
4013
+ return unwrap25(data);
3874
4014
  }
3875
4015
  async create(params) {
3876
- const body = stripUndefined11({
4016
+ const body2 = stripUndefined11({
3877
4017
  name: params.name,
3878
4018
  repo_url: params.repoUrl ?? params.repo_url,
3879
4019
  branch: params.branch,
@@ -3886,10 +4026,10 @@ var Deployments = class {
3886
4026
  });
3887
4027
  const data = await this.http.request("/deployments", {
3888
4028
  method: "POST",
3889
- body,
4029
+ body: body2,
3890
4030
  headers: { "Idempotency-Key": idempotencyKey4(params.idempotencyKey) }
3891
4031
  });
3892
- return unwrap23(data);
4032
+ return unwrap25(data);
3893
4033
  }
3894
4034
  /**
3895
4035
  * Create a deployment that runs on the workspace's dedicated Docker Deploy
@@ -3902,8 +4042,141 @@ var Deployments = class {
3902
4042
  metadata: dockerDeployMetadata(params.metadata)
3903
4043
  });
3904
4044
  }
4045
+ /**
4046
+ * Verify a Docker Deploy deployment before telling a user or agent it is
4047
+ * live. Checks product markers, appliance host health, route metadata, and
4048
+ * optionally probes the public URL.
4049
+ */
4050
+ async doctorDockerDeploy(deploymentId, params = {}) {
4051
+ const checks = [];
4052
+ const deployment = await this.get(deploymentId);
4053
+ const metadata = deployment.metadata ?? {};
4054
+ const product = dockerDeployProduct(deployment);
4055
+ const hostId = dockerDeployHostId(deployment);
4056
+ addDoctorCheck(
4057
+ checks,
4058
+ "deployment_product",
4059
+ product === "docker_deploy",
4060
+ product === "docker_deploy" ? "Deployment is marked for Docker Deploy." : `Expected deployment_product=docker_deploy, got ${String(product ?? "missing")}.`,
4061
+ { deployment_product: product ?? null }
4062
+ );
4063
+ addDoctorCheck(
4064
+ checks,
4065
+ "docker_deploy_host_id",
4066
+ Boolean(hostId),
4067
+ hostId ? "Deployment has a Docker Deploy host id." : "Deployment has no docker_deploy_host_id.",
4068
+ { docker_deploy_host_id: hostId }
4069
+ );
4070
+ let host;
4071
+ if (hostId) {
4072
+ try {
4073
+ const rawHost = await this.http.get(
4074
+ `/docker-deploy/hosts/${hostId}`
4075
+ );
4076
+ host = unwrap25(
4077
+ rawHost
4078
+ );
4079
+ addDoctorCheck(
4080
+ checks,
4081
+ "docker_deploy_host_health",
4082
+ hostHealthy(host),
4083
+ hostHealthy(host) ? "Docker Deploy host is active and healthy." : `Docker Deploy host status=${host.status} appliance=${host.appliance_status}.`,
4084
+ {
4085
+ status: host.status,
4086
+ appliance_status: host.appliance_status
4087
+ }
4088
+ );
4089
+ } catch (error) {
4090
+ addDoctorCheck(
4091
+ checks,
4092
+ "docker_deploy_host_health",
4093
+ false,
4094
+ error instanceof Error ? error.message : String(error)
4095
+ );
4096
+ }
4097
+ }
4098
+ const app = dockerDeployApp(deployment);
4099
+ const appPort = dockerDeployAppPort(app);
4100
+ const appRunning = app?.status === "running" && appPort !== null;
4101
+ addDoctorCheck(
4102
+ checks,
4103
+ "docker_deploy_app",
4104
+ appRunning,
4105
+ appRunning ? "Docker Deploy app metadata points at a running container." : "Deployment is missing running Docker Deploy app metadata.",
4106
+ app ? {
4107
+ app_id: app.app_id,
4108
+ container_id: app.container_id,
4109
+ status: app.status,
4110
+ url: app.url,
4111
+ expected_port: appPort
4112
+ } : void 0
4113
+ );
4114
+ const runtime = metadata.runtime;
4115
+ const runtimeCandidate = typeof runtime === "object" && runtime !== null ? runtime : void 0;
4116
+ const hasRuntimeRoute = typeof runtimeCandidate?.ip === "string" && typeof runtimeCandidate.port === "number";
4117
+ const runtimeRecord = hasRuntimeRoute ? runtimeCandidate : void 0;
4118
+ const routeMatchesContainerPort = hasRuntimeRoute && (appPort === null || runtimeRecord?.port === appPort);
4119
+ addDoctorCheck(
4120
+ checks,
4121
+ "runtime_route",
4122
+ hasRuntimeRoute && routeMatchesContainerPort,
4123
+ hasRuntimeRoute && routeMatchesContainerPort ? "Deployment route points at the Docker container host port." : hasRuntimeRoute && appPort !== null ? `Deployment route port ${String(runtimeRecord?.port)} does not match Docker container host port ${appPort}.` : "Deployment is missing appliance runtime route metadata.",
4124
+ runtimeRecord ? {
4125
+ ...runtimeRecord,
4126
+ expected_port: appPort,
4127
+ docker_deploy_url: app?.url
4128
+ } : void 0
4129
+ );
4130
+ let probe;
4131
+ const publicUrl = deployment.public_url;
4132
+ const path = params.probePath ?? params.probe_path ?? "/";
4133
+ if (publicUrl && typeof fetch === "function") {
4134
+ const url = probeUrl(publicUrl, path);
4135
+ const controller = new AbortController();
4136
+ const timeout = setTimeout(
4137
+ () => controller.abort(),
4138
+ params.timeoutMs ?? params.timeout_ms ?? 1e4
4139
+ );
4140
+ try {
4141
+ const response = await fetch(url, {
4142
+ method: "GET",
4143
+ signal: controller.signal
4144
+ });
4145
+ probe = { url, ok: response.ok, status: response.status };
4146
+ addDoctorCheck(
4147
+ checks,
4148
+ "public_url_probe",
4149
+ response.ok,
4150
+ `Public URL returned HTTP ${response.status}.`,
4151
+ { url, status: response.status }
4152
+ );
4153
+ } catch (error) {
4154
+ probe = {
4155
+ url,
4156
+ ok: false,
4157
+ error: error instanceof Error ? error.message : String(error)
4158
+ };
4159
+ addDoctorCheck(
4160
+ checks,
4161
+ "public_url_probe",
4162
+ false,
4163
+ probe.error ?? "Public URL probe failed.",
4164
+ { url }
4165
+ );
4166
+ } finally {
4167
+ clearTimeout(timeout);
4168
+ }
4169
+ }
4170
+ return {
4171
+ ok: checks.every((check) => check.ok),
4172
+ deployment,
4173
+ ...host ? { host } : {},
4174
+ checks,
4175
+ ...probe ? { probe } : {}
4176
+ };
4177
+ }
3905
4178
  async update(deploymentId, params) {
3906
- const body = stripUndefined11({
4179
+ const body2 = stripUndefined11({
3907
4180
  name: params.name,
3908
4181
  branch: params.branch,
3909
4182
  build_command: params.buildCommand ?? params.build_command,
@@ -3912,15 +4185,15 @@ var Deployments = class {
3912
4185
  });
3913
4186
  const data = await this.http.patch(
3914
4187
  `/deployments/${deploymentId}`,
3915
- body
4188
+ body2
3916
4189
  );
3917
- return unwrap23(data);
4190
+ return unwrap25(data);
3918
4191
  }
3919
4192
  async delete(deploymentId) {
3920
4193
  await this.http.delete(`/deployments/${deploymentId}`);
3921
4194
  }
3922
4195
  async publish(deploymentId, params) {
3923
- const body = stripUndefined11({
4196
+ const body2 = stripUndefined11({
3924
4197
  source_sandbox_id: params.sourceSandboxId ?? params.source_sandbox_id,
3925
4198
  output_path: params.outputPath ?? params.output_path,
3926
4199
  entrypoint: params.entrypoint,
@@ -3930,11 +4203,11 @@ var Deployments = class {
3930
4203
  `/deployments/${deploymentId}/publish`,
3931
4204
  {
3932
4205
  method: "POST",
3933
- body,
4206
+ body: body2,
3934
4207
  headers: { "Idempotency-Key": idempotencyKey4(params.idempotencyKey) }
3935
4208
  }
3936
4209
  );
3937
- return unwrap23(data);
4210
+ return unwrap25(data);
3938
4211
  }
3939
4212
  /**
3940
4213
  * Backward-compatible bridge: POST /sandboxes/:id/deploy. Works today;
@@ -3942,7 +4215,7 @@ var Deployments = class {
3942
4215
  * phase. Prefer `publish()` once Phase 2B/3 lands.
3943
4216
  */
3944
4217
  async publishFromSandbox(sandboxId, params = {}) {
3945
- const body = stripUndefined11({
4218
+ const body2 = stripUndefined11({
3946
4219
  name: params.name,
3947
4220
  deployment_id: params.deploymentId ?? params.deployment_id,
3948
4221
  output_path: params.outputPath ?? params.output_path,
@@ -3955,25 +4228,25 @@ var Deployments = class {
3955
4228
  `/sandboxes/${sandboxId}/deploy`,
3956
4229
  {
3957
4230
  method: "POST",
3958
- body,
4231
+ body: body2,
3959
4232
  headers: { "Idempotency-Key": idempotencyKey4(params.idempotencyKey) }
3960
4233
  }
3961
4234
  );
3962
- return unwrap23(data);
4235
+ return unwrap25(data);
3963
4236
  }
3964
4237
  async rollback(deploymentId, params = {}) {
3965
- const body = stripUndefined11({
4238
+ const body2 = stripUndefined11({
3966
4239
  version_id: params.versionId ?? params.version_id
3967
4240
  });
3968
4241
  const data = await this.http.request(
3969
4242
  `/deployments/${deploymentId}/rollback`,
3970
4243
  {
3971
4244
  method: "POST",
3972
- body,
4245
+ body: body2,
3973
4246
  headers: { "Idempotency-Key": idempotencyKey4(params.idempotencyKey) }
3974
4247
  }
3975
4248
  );
3976
- return unwrap23(data);
4249
+ return unwrap25(data);
3977
4250
  }
3978
4251
  async listBuilds(deploymentId) {
3979
4252
  const data = await this.http.get(
@@ -3985,7 +4258,7 @@ var Deployments = class {
3985
4258
  const data = await this.http.get(
3986
4259
  `/deployments/${deploymentId}/builds/${buildId}`
3987
4260
  );
3988
- return unwrap23(data);
4261
+ return unwrap25(data);
3989
4262
  }
3990
4263
  async listEnv(deploymentId) {
3991
4264
  const data = await this.http.get(
@@ -3994,10 +4267,10 @@ var Deployments = class {
3994
4267
  return listItems4(data);
3995
4268
  }
3996
4269
  async setEnv(deploymentId, vars, opts = {}) {
3997
- const body = stripUndefined11({ env: vars, environment: opts.environment });
4270
+ const body2 = stripUndefined11({ env: vars, environment: opts.environment });
3998
4271
  const data = await this.http.post(
3999
4272
  `/deployments/${deploymentId}/env`,
4000
- body
4273
+ body2
4001
4274
  );
4002
4275
  return listItems4(data);
4003
4276
  }
@@ -4023,12 +4296,12 @@ function workspaceId(params) {
4023
4296
  return params?.workspace_id ?? params?.workspaceId;
4024
4297
  }
4025
4298
  function ensureBody(params) {
4026
- const body = {};
4299
+ const body2 = {};
4027
4300
  const id = params.workspace_id ?? params.workspaceId;
4028
4301
  const externalId = params.external_workspace_id ?? params.externalWorkspaceId;
4029
- if (id) body.workspace_id = id;
4030
- if (externalId) body.external_workspace_id = externalId;
4031
- return body;
4302
+ if (id) body2.workspace_id = id;
4303
+ if (externalId) body2.external_workspace_id = externalId;
4304
+ return body2;
4032
4305
  }
4033
4306
  function unwrapHost(response) {
4034
4307
  const host = response.data ?? response.host;
@@ -4103,7 +4376,7 @@ var DockerDeploy = class {
4103
4376
  };
4104
4377
 
4105
4378
  // src/resources/email.ts
4106
- function unwrap24(data) {
4379
+ function unwrap26(data) {
4107
4380
  if (data && typeof data === "object") {
4108
4381
  const d = data;
4109
4382
  for (const k of [
@@ -4155,12 +4428,12 @@ var EmailCampaigns = class {
4155
4428
  );
4156
4429
  }
4157
4430
  async create(attrs) {
4158
- return unwrap24(
4431
+ return unwrap26(
4159
4432
  await this.http.post("/admin/email-campaigns", strip(attrs))
4160
4433
  );
4161
4434
  }
4162
4435
  async recipientCount(filters = {}) {
4163
- return unwrap24(
4436
+ return unwrap26(
4164
4437
  await this.http.get(
4165
4438
  "/admin/email-campaigns/recipient-count",
4166
4439
  filters
@@ -4168,7 +4441,7 @@ var EmailCampaigns = class {
4168
4441
  );
4169
4442
  }
4170
4443
  async send(campaignId, opts = {}) {
4171
- return unwrap24(
4444
+ return unwrap26(
4172
4445
  await this.http.post(
4173
4446
  `/admin/email-campaigns/${campaignId}/send`,
4174
4447
  strip(opts)
@@ -4176,7 +4449,7 @@ var EmailCampaigns = class {
4176
4449
  );
4177
4450
  }
4178
4451
  async cancel(campaignId) {
4179
- return unwrap24(
4452
+ return unwrap26(
4180
4453
  await this.http.post(
4181
4454
  `/admin/email-campaigns/${campaignId}/cancel`
4182
4455
  )
@@ -4202,7 +4475,7 @@ var EmailTemplates = class {
4202
4475
  );
4203
4476
  }
4204
4477
  async create(key, attrs = {}) {
4205
- return unwrap24(
4478
+ return unwrap26(
4206
4479
  await this.http.post("/admin/email-templates", {
4207
4480
  key,
4208
4481
  ...strip(attrs)
@@ -4210,7 +4483,7 @@ var EmailTemplates = class {
4210
4483
  );
4211
4484
  }
4212
4485
  async update(key, attrs) {
4213
- return unwrap24(
4486
+ return unwrap26(
4214
4487
  await this.http.put(
4215
4488
  `/admin/email-templates/${key}`,
4216
4489
  strip(attrs)
@@ -4218,7 +4491,7 @@ var EmailTemplates = class {
4218
4491
  );
4219
4492
  }
4220
4493
  async reset(key) {
4221
- return unwrap24(
4494
+ return unwrap26(
4222
4495
  await this.http.post(`/admin/email-templates/${key}/reset`)
4223
4496
  );
4224
4497
  }
@@ -4234,17 +4507,17 @@ var EmailInbox = class {
4234
4507
  );
4235
4508
  }
4236
4509
  async send(attrs) {
4237
- return unwrap24(
4510
+ return unwrap26(
4238
4511
  await this.http.post("/admin/email-inbox/send", strip(attrs))
4239
4512
  );
4240
4513
  }
4241
4514
  async markRead(messageId) {
4242
- return unwrap24(
4515
+ return unwrap26(
4243
4516
  await this.http.post(`/admin/email-inbox/${messageId}/read`)
4244
4517
  );
4245
4518
  }
4246
4519
  async archive(messageId) {
4247
- return unwrap24(
4520
+ return unwrap26(
4248
4521
  await this.http.post(`/admin/email-inbox/${messageId}/archive`)
4249
4522
  );
4250
4523
  }
@@ -4273,18 +4546,18 @@ var Embeddings = class {
4273
4546
  * `{ object: "list", data: [...], model, usage }`.
4274
4547
  */
4275
4548
  async create(params) {
4276
- const body = Object.fromEntries(
4549
+ const body2 = Object.fromEntries(
4277
4550
  Object.entries(params).filter(([, v]) => v !== void 0)
4278
4551
  );
4279
4552
  return this.http.post(
4280
4553
  "/intelligence/embeddings",
4281
- body
4554
+ body2
4282
4555
  );
4283
4556
  }
4284
4557
  };
4285
4558
 
4286
4559
  // src/resources/external-keys.ts
4287
- function unwrap25(payload) {
4560
+ function unwrap27(payload) {
4288
4561
  if (payload && typeof payload === "object") {
4289
4562
  const p = payload;
4290
4563
  for (const k of ["data", "external_keys", "items"]) {
@@ -4306,22 +4579,22 @@ var ExternalKeys = class {
4306
4579
  /** List configured external keys. */
4307
4580
  async list() {
4308
4581
  const data = await this.http.get("/external-keys");
4309
- const result = unwrap25(data);
4582
+ const result = unwrap27(data);
4310
4583
  if (Array.isArray(result)) return result;
4311
4584
  return [];
4312
4585
  }
4313
4586
  /** Create / register an external provider key. */
4314
4587
  async create(params) {
4315
- const body = stripUndefined12(params);
4316
- const data = await this.http.post("/external-keys", body);
4317
- return unwrap25(data);
4588
+ const body2 = stripUndefined12(params);
4589
+ const data = await this.http.post("/external-keys", body2);
4590
+ return unwrap27(data);
4318
4591
  }
4319
4592
  /** Resolve (preview) the stored key for a provider. */
4320
4593
  async resolve(provider) {
4321
4594
  const data = await this.http.get(
4322
4595
  `/external-keys/${provider}/resolve`
4323
4596
  );
4324
- return unwrap25(data);
4597
+ return unwrap27(data);
4325
4598
  }
4326
4599
  /**
4327
4600
  * Delete the stored key for a provider.
@@ -4331,7 +4604,7 @@ var ExternalKeys = class {
4331
4604
  await this.http.delete(`/external-keys/${provider}`);
4332
4605
  }
4333
4606
  };
4334
- function unwrap26(payload) {
4607
+ function unwrap28(payload) {
4335
4608
  if (payload && typeof payload === "object" && "data" in payload) {
4336
4609
  return payload.data;
4337
4610
  }
@@ -4373,7 +4646,7 @@ var FlatCustomDomains = class {
4373
4646
  redirectPolicy,
4374
4647
  ...rest
4375
4648
  } = params;
4376
- const body = stripUndefined13({
4649
+ const body2 = stripUndefined13({
4377
4650
  ...rest,
4378
4651
  resource_type: resourceType ?? rest.resource_type,
4379
4652
  resource_id: resourceId ?? rest.resource_id,
@@ -4381,16 +4654,16 @@ var FlatCustomDomains = class {
4381
4654
  });
4382
4655
  const data = await this.http.request("/custom-domains", {
4383
4656
  method: "POST",
4384
- body,
4657
+ body: body2,
4385
4658
  headers: { "Idempotency-Key": idempotencyKey5(ikey) }
4386
4659
  });
4387
- return unwrap26(data);
4660
+ return unwrap28(data);
4388
4661
  }
4389
4662
  async delete(domainId) {
4390
4663
  await this.http.delete(`/custom-domains/${domainId}`);
4391
4664
  }
4392
4665
  };
4393
- function unwrap27(payload) {
4666
+ function unwrap29(payload) {
4394
4667
  if (payload && typeof payload === "object" && "data" in payload) {
4395
4668
  return payload.data;
4396
4669
  }
@@ -4426,34 +4699,34 @@ var Functions = class {
4426
4699
  }
4427
4700
  async get(functionId) {
4428
4701
  const data = await this.http.get(`/functions/${functionId}`);
4429
- return unwrap27(data);
4702
+ return unwrap29(data);
4430
4703
  }
4431
4704
  async create(params) {
4432
4705
  const { idempotencyKey: ikey, memoryMb, timeoutSec, ...rest } = params;
4433
- const body = stripUndefined14({
4706
+ const body2 = stripUndefined14({
4434
4707
  ...rest,
4435
4708
  memory_mb: memoryMb ?? rest.memory_mb,
4436
4709
  timeout_sec: timeoutSec ?? rest.timeout_sec
4437
4710
  });
4438
4711
  const data = await this.http.request("/functions", {
4439
4712
  method: "POST",
4440
- body,
4713
+ body: body2,
4441
4714
  headers: { "Idempotency-Key": idempotencyKey6(ikey) }
4442
4715
  });
4443
- return unwrap27(data);
4716
+ return unwrap29(data);
4444
4717
  }
4445
4718
  async update(functionId, params) {
4446
4719
  const { memoryMb, timeoutSec, ...rest } = params;
4447
- const body = stripUndefined14({
4720
+ const body2 = stripUndefined14({
4448
4721
  ...rest,
4449
4722
  memory_mb: memoryMb ?? rest.memory_mb,
4450
4723
  timeout_sec: timeoutSec ?? rest.timeout_sec
4451
4724
  });
4452
4725
  const data = await this.http.patch(
4453
4726
  `/functions/${functionId}`,
4454
- body
4727
+ body2
4455
4728
  );
4456
- return unwrap27(data);
4729
+ return unwrap29(data);
4457
4730
  }
4458
4731
  async delete(functionId) {
4459
4732
  await this.http.delete(`/functions/${functionId}`);
@@ -4474,7 +4747,7 @@ var Functions = class {
4474
4747
  return data ?? {};
4475
4748
  }
4476
4749
  };
4477
- function unwrap28(payload) {
4750
+ function unwrap30(payload) {
4478
4751
  if (payload && typeof payload === "object" && "data" in payload) {
4479
4752
  return payload.data;
4480
4753
  }
@@ -4510,7 +4783,7 @@ var HealthChecks = class {
4510
4783
  }
4511
4784
  async get(checkId) {
4512
4785
  const data = await this.http.get(`/health-checks/${checkId}`);
4513
- return unwrap28(data);
4786
+ return unwrap30(data);
4514
4787
  }
4515
4788
  async create(params) {
4516
4789
  const {
@@ -4520,7 +4793,7 @@ var HealthChecks = class {
4520
4793
  expectedStatus,
4521
4794
  ...rest
4522
4795
  } = params;
4523
- const body = stripUndefined15({
4796
+ const body2 = stripUndefined15({
4524
4797
  ...rest,
4525
4798
  interval_sec: intervalSec ?? rest.interval_sec,
4526
4799
  timeout_sec: timeoutSec ?? rest.timeout_sec,
@@ -4528,14 +4801,14 @@ var HealthChecks = class {
4528
4801
  });
4529
4802
  const data = await this.http.request("/health-checks", {
4530
4803
  method: "POST",
4531
- body,
4804
+ body: body2,
4532
4805
  headers: { "Idempotency-Key": idempotencyKey7(ikey) }
4533
4806
  });
4534
- return unwrap28(data);
4807
+ return unwrap30(data);
4535
4808
  }
4536
4809
  async update(checkId, params) {
4537
4810
  const { intervalSec, timeoutSec, expectedStatus, ...rest } = params;
4538
- const body = stripUndefined15({
4811
+ const body2 = stripUndefined15({
4539
4812
  ...rest,
4540
4813
  interval_sec: intervalSec ?? rest.interval_sec,
4541
4814
  timeout_sec: timeoutSec ?? rest.timeout_sec,
@@ -4543,9 +4816,9 @@ var HealthChecks = class {
4543
4816
  });
4544
4817
  const data = await this.http.patch(
4545
4818
  `/health-checks/${checkId}`,
4546
- body
4819
+ body2
4547
4820
  );
4548
- return unwrap28(data);
4821
+ return unwrap30(data);
4549
4822
  }
4550
4823
  async delete(checkId) {
4551
4824
  await this.http.delete(`/health-checks/${checkId}`);
@@ -4553,7 +4826,7 @@ var HealthChecks = class {
4553
4826
  };
4554
4827
 
4555
4828
  // src/resources/integrations.ts
4556
- function unwrap29(payload) {
4829
+ function unwrap31(payload) {
4557
4830
  if (payload && typeof payload === "object") {
4558
4831
  const p = payload;
4559
4832
  for (const k of ["data", "integrations", "catalog", "items"]) {
@@ -4563,7 +4836,7 @@ function unwrap29(payload) {
4563
4836
  return payload;
4564
4837
  }
4565
4838
  function listItems8(payload) {
4566
- const result = unwrap29(payload);
4839
+ const result = unwrap31(payload);
4567
4840
  if (Array.isArray(result)) return result;
4568
4841
  return [];
4569
4842
  }
@@ -4592,14 +4865,14 @@ var Integrations = class {
4592
4865
  const data = await this.http.get(
4593
4866
  `/integrations/${provider}/start`
4594
4867
  );
4595
- return unwrap29(data);
4868
+ return unwrap31(data);
4596
4869
  }
4597
4870
  /** Force-refresh the access token for a provider. */
4598
4871
  async refresh(provider) {
4599
4872
  const data = await this.http.post(
4600
4873
  `/integrations/${provider}/refresh`
4601
4874
  );
4602
- return unwrap29(data);
4875
+ return unwrap31(data);
4603
4876
  }
4604
4877
  /** Disconnect (revoke) an integration. */
4605
4878
  async disconnect(provider) {
@@ -4619,41 +4892,41 @@ var Integrations = class {
4619
4892
  // ── Test hooks ─────────────────────────────────────────────────────────────
4620
4893
  /** Send a test message to the connected Slack channel. */
4621
4894
  async slackSendTest(params = {}) {
4622
- const body = stripUndefined16(params);
4895
+ const body2 = stripUndefined16(params);
4623
4896
  const data = await this.http.post(
4624
4897
  "/integrations/slack/send-test",
4625
- body
4898
+ body2
4626
4899
  );
4627
- return unwrap29(data);
4900
+ return unwrap31(data);
4628
4901
  }
4629
4902
  /** Send a test message to the connected Discord channel. */
4630
4903
  async discordSendTest(params = {}) {
4631
- const body = stripUndefined16(params);
4904
+ const body2 = stripUndefined16(params);
4632
4905
  const data = await this.http.post(
4633
4906
  "/integrations/discord/send-test",
4634
- body
4907
+ body2
4635
4908
  );
4636
- return unwrap29(data);
4909
+ return unwrap31(data);
4637
4910
  }
4638
4911
  // ── Linear dedicated controller ────────────────────────────────────────────
4639
4912
  /** Begin Linear OAuth — Linear has provider-specific error shapes. */
4640
4913
  async linearStart() {
4641
4914
  const data = await this.http.get("/integrations/linear/start");
4642
- return unwrap29(data);
4915
+ return unwrap31(data);
4643
4916
  }
4644
4917
  /** Create a Linear issue via the connected workspace. */
4645
4918
  async linearCreateIssue(params = {}) {
4646
- const body = stripUndefined16(params);
4919
+ const body2 = stripUndefined16(params);
4647
4920
  const data = await this.http.post(
4648
4921
  "/integrations/linear/create-issue",
4649
- body
4922
+ body2
4650
4923
  );
4651
- return unwrap29(data);
4924
+ return unwrap31(data);
4652
4925
  }
4653
4926
  };
4654
4927
 
4655
4928
  // src/resources/mcp.ts
4656
- function unwrap30(payload) {
4929
+ function unwrap32(payload) {
4657
4930
  if (payload && typeof payload === "object") {
4658
4931
  const p = payload;
4659
4932
  for (const k of ["data", "mcp", "result", "items"]) {
@@ -4674,12 +4947,12 @@ var Mcp = class {
4674
4947
  http;
4675
4948
  /** Send a JSON-RPC request to the MCP endpoint. */
4676
4949
  async dispatch(params = {}) {
4677
- const body = stripUndefined17(params);
4950
+ const body2 = stripUndefined17(params);
4678
4951
  const data = await this.http.post(
4679
4952
  "/mcp",
4680
- Object.keys(body).length > 0 ? body : void 0
4953
+ Object.keys(body2).length > 0 ? body2 : void 0
4681
4954
  );
4682
- return unwrap30(data);
4955
+ return unwrap32(data);
4683
4956
  }
4684
4957
  /**
4685
4958
  * Open the MCP listen channel (GET).
@@ -4689,7 +4962,7 @@ var Mcp = class {
4689
4962
  */
4690
4963
  async listen() {
4691
4964
  const data = await this.http.get("/mcp");
4692
- return unwrap30(data);
4965
+ return unwrap32(data);
4693
4966
  }
4694
4967
  /** Close (terminate) the MCP session. */
4695
4968
  async close() {
@@ -4698,7 +4971,7 @@ var Mcp = class {
4698
4971
  };
4699
4972
 
4700
4973
  // src/resources/models.ts
4701
- function unwrap31(data) {
4974
+ function unwrap33(data) {
4702
4975
  if (Array.isArray(data)) return data;
4703
4976
  if (data && typeof data === "object") {
4704
4977
  const d = data;
@@ -4719,7 +4992,7 @@ var Models = class {
4719
4992
  Object.entries(filters).filter(([, v]) => v !== void 0)
4720
4993
  );
4721
4994
  const data = await this.http.get("/intelligence/models", query);
4722
- return unwrap31(data);
4995
+ return unwrap33(data);
4723
4996
  }
4724
4997
  /**
4725
4998
  * Get a single model by id.
@@ -4742,30 +5015,43 @@ var Agents = class {
4742
5015
  base(hostId) {
4743
5016
  return `/opencomputers/hosts/${hostId}/agent`;
4744
5017
  }
5018
+ unwrapSession(payload) {
5019
+ const value = payload && typeof payload === "object" && "session" in payload ? payload.session : payload && typeof payload === "object" && "data" in payload ? payload.data : payload;
5020
+ const session = value;
5021
+ if (!session.id && session.session_id) {
5022
+ return { ...session, id: session.session_id };
5023
+ }
5024
+ return session;
5025
+ }
5026
+ unwrapList(payload) {
5027
+ if (payload && typeof payload === "object" && "sessions" in payload) {
5028
+ return { data: payload.sessions };
5029
+ }
5030
+ if (Array.isArray(payload)) {
5031
+ return { data: payload };
5032
+ }
5033
+ return payload;
5034
+ }
4745
5035
  /**
4746
5036
  * Dispatch a new agent session on the host.
4747
5037
  */
4748
5038
  async dispatch(hostId, params) {
4749
- return this.http.post(
4750
- `${this.base(hostId)}/dispatch`,
4751
- params
4752
- );
5039
+ const payload = await this.http.post(`${this.base(hostId)}/dispatch`, params);
5040
+ return this.unwrapSession(payload);
4753
5041
  }
4754
5042
  /**
4755
5043
  * List all agent sessions for a host.
4756
5044
  */
4757
5045
  async list(hostId) {
4758
- return this.http.get(
4759
- `${this.base(hostId)}/sessions`
4760
- );
5046
+ const payload = await this.http.get(`${this.base(hostId)}/sessions`);
5047
+ return this.unwrapList(payload);
4761
5048
  }
4762
5049
  /**
4763
5050
  * Fetch the current state of a specific agent session.
4764
5051
  */
4765
5052
  async get(hostId, sessionId) {
4766
- return this.http.get(
4767
- `${this.base(hostId)}/sessions/${sessionId}`
4768
- );
5053
+ const payload = await this.http.get(`${this.base(hostId)}/sessions/${sessionId}`);
5054
+ return this.unwrapSession(payload);
4769
5055
  }
4770
5056
  /**
4771
5057
  * Stream live events from an agent session.
@@ -5362,7 +5648,7 @@ function requestBody(params) {
5362
5648
  config: authConfig(params)
5363
5649
  });
5364
5650
  }
5365
- function unwrap32(payload) {
5651
+ function unwrap34(payload) {
5366
5652
  if (payload && typeof payload === "object") {
5367
5653
  const p = payload;
5368
5654
  for (const k of ["data", "project_auth", "config", "items"]) {
@@ -5387,13 +5673,13 @@ var ProjectAuth = class {
5387
5673
  "/project-auth/status",
5388
5674
  resourcePayload(params)
5389
5675
  );
5390
- return unwrap32(data);
5676
+ return unwrap34(data);
5391
5677
  }
5392
5678
  /** Enable project auth. */
5393
5679
  async enable(params) {
5394
- const body = requestBody(params);
5395
- const data = await this.http.post("/project-auth/enable", body);
5396
- return unwrap32(data);
5680
+ const body2 = requestBody(params);
5681
+ const data = await this.http.post("/project-auth/enable", body2);
5682
+ return unwrap34(data);
5397
5683
  }
5398
5684
  /** Disable project auth. */
5399
5685
  async disable(params) {
@@ -5401,18 +5687,18 @@ var ProjectAuth = class {
5401
5687
  "/project-auth/disable",
5402
5688
  resourcePayload(params)
5403
5689
  );
5404
- return unwrap32(data);
5690
+ return unwrap34(data);
5405
5691
  }
5406
5692
  /** Update project-auth configuration. */
5407
5693
  async update(params) {
5408
- const body = requestBody(params);
5409
- const data = await this.http.patch("/project-auth/config", body);
5410
- return unwrap32(data);
5694
+ const body2 = requestBody(params);
5695
+ const data = await this.http.patch("/project-auth/config", body2);
5696
+ return unwrap34(data);
5411
5697
  }
5412
5698
  };
5413
5699
 
5414
5700
  // src/resources/project-integrations.ts
5415
- function unwrap33(payload) {
5701
+ function unwrap35(payload) {
5416
5702
  if (payload && typeof payload === "object") {
5417
5703
  const p = payload;
5418
5704
  for (const k of ["data", "project_integrations", "catalog", "items"]) {
@@ -5422,7 +5708,7 @@ function unwrap33(payload) {
5422
5708
  return payload;
5423
5709
  }
5424
5710
  function listItems9(payload) {
5425
- const result = unwrap33(payload);
5711
+ const result = unwrap35(payload);
5426
5712
  if (Array.isArray(result)) return result;
5427
5713
  return [];
5428
5714
  }
@@ -5457,22 +5743,22 @@ var ProjectIntegrations = class {
5457
5743
  const data = await this.http.get(
5458
5744
  `/project-integrations/${integrationId}`
5459
5745
  );
5460
- return unwrap33(data);
5746
+ return unwrap35(data);
5461
5747
  }
5462
5748
  /** Create a project integration. */
5463
5749
  async create(params) {
5464
- const body = stripUndefObj2(params);
5465
- const data = await this.http.post("/project-integrations", body);
5466
- return unwrap33(data);
5750
+ const body2 = stripUndefObj2(params);
5751
+ const data = await this.http.post("/project-integrations", body2);
5752
+ return unwrap35(data);
5467
5753
  }
5468
5754
  /** Update a project integration. */
5469
5755
  async update(integrationId, params) {
5470
- const body = stripUndefObj2(params);
5756
+ const body2 = stripUndefObj2(params);
5471
5757
  const data = await this.http.patch(
5472
5758
  `/project-integrations/${integrationId}`,
5473
- body
5759
+ body2
5474
5760
  );
5475
- return unwrap33(data);
5761
+ return unwrap35(data);
5476
5762
  }
5477
5763
  /** Delete a project integration. */
5478
5764
  async delete(integrationId) {
@@ -5481,7 +5767,7 @@ var ProjectIntegrations = class {
5481
5767
  };
5482
5768
 
5483
5769
  // src/resources/provider-defaults.ts
5484
- function unwrap34(data) {
5770
+ function unwrap36(data) {
5485
5771
  if (data && typeof data === "object") {
5486
5772
  const d = data;
5487
5773
  for (const k of ["data", "defaults", "provider_defaults", "config"]) {
@@ -5497,7 +5783,7 @@ var ProviderDefaults = class {
5497
5783
  http;
5498
5784
  /** Get the current fleet-wide provider defaults. */
5499
5785
  async list() {
5500
- return unwrap34(await this.http.get("/admin/provider-defaults"));
5786
+ return unwrap36(await this.http.get("/admin/provider-defaults"));
5501
5787
  }
5502
5788
  /** Return the defaults entry for a single provider, or {} if missing. */
5503
5789
  async get(provider) {
@@ -5510,29 +5796,29 @@ var ProviderDefaults = class {
5510
5796
  }
5511
5797
  /** Replace the fleet-wide defaults (PUT /admin/provider-defaults). */
5512
5798
  async update(opts) {
5513
- const body = Object.fromEntries(
5799
+ const body2 = Object.fromEntries(
5514
5800
  Object.entries(opts).filter(([, v]) => v !== void 0)
5515
5801
  );
5516
- return unwrap34(
5517
- await this.http.put("/admin/provider-defaults", body)
5802
+ return unwrap36(
5803
+ await this.http.put("/admin/provider-defaults", body2)
5518
5804
  );
5519
5805
  }
5520
5806
  // ── Per-tenant overrides ────────────────────────────────────────────────
5521
5807
  async getTenant(tenantId) {
5522
- return unwrap34(
5808
+ return unwrap36(
5523
5809
  await this.http.get(
5524
5810
  `/admin/tenants/${tenantId}/provider-config`
5525
5811
  )
5526
5812
  );
5527
5813
  }
5528
5814
  async setTenant(tenantId, opts) {
5529
- const body = Object.fromEntries(
5815
+ const body2 = Object.fromEntries(
5530
5816
  Object.entries(opts).filter(([, v]) => v !== void 0)
5531
5817
  );
5532
- return unwrap34(
5818
+ return unwrap36(
5533
5819
  await this.http.put(
5534
5820
  `/admin/tenants/${tenantId}/provider-config`,
5535
- body
5821
+ body2
5536
5822
  )
5537
5823
  );
5538
5824
  }
@@ -5542,7 +5828,7 @@ var ProviderDefaults = class {
5542
5828
  };
5543
5829
 
5544
5830
  // src/resources/regions.ts
5545
- function unwrap35(payload) {
5831
+ function unwrap37(payload) {
5546
5832
  if (payload && typeof payload === "object") {
5547
5833
  const p = payload;
5548
5834
  for (const k of [
@@ -5559,7 +5845,7 @@ function unwrap35(payload) {
5559
5845
  return payload;
5560
5846
  }
5561
5847
  function listItems10(payload) {
5562
- const result = unwrap35(payload);
5848
+ const result = unwrap37(payload);
5563
5849
  if (Array.isArray(result)) return result;
5564
5850
  return [];
5565
5851
  }
@@ -5581,7 +5867,7 @@ var Regions = class {
5581
5867
  /** Get static compute pricing data. */
5582
5868
  async pricing() {
5583
5869
  const data = await this.http.get("/compute/pricing");
5584
- return unwrap35(data);
5870
+ return unwrap37(data);
5585
5871
  }
5586
5872
  /** List community computer templates. */
5587
5873
  async listTemplates() {
@@ -5593,7 +5879,7 @@ var Regions = class {
5593
5879
  const data = await this.http.get(
5594
5880
  `/compute/templates/${templateId}`
5595
5881
  );
5596
- return unwrap35(data);
5882
+ return unwrap37(data);
5597
5883
  }
5598
5884
  };
5599
5885
 
@@ -5611,12 +5897,32 @@ var AGENT_WORKSPACE_TIMEOUT_SEC = 86400;
5611
5897
  var AGENT_WORKSPACE_IDLE_TIMEOUT_SEC = 1800;
5612
5898
  var AGENT_WORKSPACE_SNAPSHOT_EXPIRATION_DAYS = 30;
5613
5899
  var AGENT_WORKSPACE_KEEP_LAST_SNAPSHOTS = 1;
5614
- function unwrap36(payload) {
5900
+ function unwrap38(payload) {
5615
5901
  if (payload !== null && typeof payload === "object" && "data" in payload && payload.data !== void 0) {
5616
5902
  return payload.data;
5617
5903
  }
5618
5904
  return payload;
5619
5905
  }
5906
+ function normalizeExport(value) {
5907
+ const normalized = {
5908
+ ...value,
5909
+ files: (value.files ?? []).map((file) => {
5910
+ const normalized2 = { ...file };
5911
+ const downloadUrl = file.downloadUrl ?? file.download_url;
5912
+ if (downloadUrl !== void 0) normalized2.downloadUrl = downloadUrl;
5913
+ return normalized2;
5914
+ })
5915
+ };
5916
+ const sandboxId = value.sandboxId ?? value.sandbox_id;
5917
+ const archiveDownloadUrl = value.archiveDownloadUrl ?? value.archive_download_url;
5918
+ const createdAt = value.createdAt ?? value.created_at;
5919
+ if (sandboxId !== void 0) normalized.sandboxId = sandboxId;
5920
+ if (archiveDownloadUrl !== void 0) {
5921
+ normalized.archiveDownloadUrl = archiveDownloadUrl;
5922
+ }
5923
+ if (createdAt !== void 0) normalized.createdAt = createdAt;
5924
+ return normalized;
5925
+ }
5620
5926
  function listItems11(payload) {
5621
5927
  if (Array.isArray(payload)) return payload;
5622
5928
  if ("data" in payload && Array.isArray(payload.data)) return payload.data;
@@ -5625,7 +5931,7 @@ function listItems11(payload) {
5625
5931
  if ("items" in payload && Array.isArray(payload.items)) return payload.items;
5626
5932
  return [];
5627
5933
  }
5628
- function createBody2(params = {}) {
5934
+ function createBody(params = {}) {
5629
5935
  const templateId = params.templateId ?? params.template_id ?? params.image ?? SANDBOX_TEMPLATE;
5630
5936
  const persistent = params.persistent;
5631
5937
  const snapshotExpirationSec = snapshotExpirationSeconds(params);
@@ -5660,6 +5966,8 @@ function createBody2(params = {}) {
5660
5966
  entrypoint: params.entrypoint,
5661
5967
  tags: params.tags,
5662
5968
  slug: params.slug,
5969
+ agent_runtime_profile_id: params.agentRuntimeProfileId ?? params.agent_runtime_profile_id ?? params.agentProfileId ?? params.agent_profile_id,
5970
+ skip_agent_runtime_profile: params.skipAgentRuntimeProfile ?? params.skip_agent_runtime_profile,
5663
5971
  external_workspace_id: params.externalWorkspaceId ?? params.external_workspace_id,
5664
5972
  external_user_id: params.externalUserId ?? params.external_user_id,
5665
5973
  external_project_id: params.externalProjectId ?? params.external_project_id
@@ -5812,11 +6120,11 @@ var SandboxTerminal = class {
5812
6120
  }
5813
6121
  sandbox;
5814
6122
  async create(params = {}) {
5815
- const body = Object.fromEntries(
6123
+ const body2 = Object.fromEntries(
5816
6124
  Object.entries(params).filter(([, v]) => v !== void 0)
5817
6125
  );
5818
- const response = unwrap36(
5819
- await this.sandbox.http.post(`/sandboxes/${this.sandbox.id}/terminal`, body)
6126
+ const response = unwrap38(
6127
+ await this.sandbox.http.post(`/sandboxes/${this.sandbox.id}/terminal`, body2)
5820
6128
  );
5821
6129
  return response;
5822
6130
  }
@@ -5858,21 +6166,21 @@ var SandboxPreviews = class {
5858
6166
  return [];
5859
6167
  }
5860
6168
  async create(port, opts = {}) {
5861
- const body = {
6169
+ const body2 = {
5862
6170
  port,
5863
6171
  ...Object.fromEntries(
5864
6172
  Object.entries(opts).filter(([, v]) => v !== void 0)
5865
6173
  )
5866
6174
  };
5867
- return unwrap36(
6175
+ return unwrap38(
5868
6176
  await this.http.post(
5869
6177
  `/sandboxes/${this.sandbox.id}/previews`,
5870
- body
6178
+ body2
5871
6179
  )
5872
6180
  );
5873
6181
  }
5874
6182
  async get(previewId) {
5875
- return unwrap36(
6183
+ return unwrap38(
5876
6184
  await this.http.get(
5877
6185
  `/sandboxes/${this.sandbox.id}/previews/${previewId}`
5878
6186
  )
@@ -5885,7 +6193,7 @@ var SandboxPreviews = class {
5885
6193
  }
5886
6194
  /** Mint a share token for previewId. */
5887
6195
  async share(previewId, opts = {}) {
5888
- return unwrap36(
6196
+ return unwrap38(
5889
6197
  await this.http.post(
5890
6198
  `/sandboxes/${this.sandbox.id}/previews/${previewId}/share`,
5891
6199
  { ttl_seconds: opts.ttl_seconds ?? opts.expires_in_sec ?? 3600 }
@@ -5954,7 +6262,7 @@ var SandboxTags = class {
5954
6262
  sandbox;
5955
6263
  /** Replace the full tag list with tags. */
5956
6264
  async set(tags) {
5957
- return unwrap36(
6265
+ return unwrap38(
5958
6266
  await this.sandbox.http.patch(`/sandboxes/${this.sandbox.id}/tags`, { tags })
5959
6267
  );
5960
6268
  }
@@ -6022,14 +6330,14 @@ var Sandbox = class _Sandbox {
6022
6330
  return this.data.template_id ?? this.data.image_id ?? "";
6023
6331
  }
6024
6332
  async refresh() {
6025
- this.data = unwrap36(
6333
+ this.data = unwrap38(
6026
6334
  await this.http.get(`/sandboxes/${this.id}`)
6027
6335
  );
6028
6336
  return this;
6029
6337
  }
6030
6338
  async runExec(command, options) {
6031
6339
  this.assertRunning("exec");
6032
- const response = unwrap36(
6340
+ const response = unwrap38(
6033
6341
  await this.http.post(
6034
6342
  `/sandboxes/${this.id}/exec`,
6035
6343
  execBody(command, options)
@@ -6072,12 +6380,34 @@ var Sandbox = class _Sandbox {
6072
6380
  `/sandboxes/${this.id}/files/${path.replace(/^\/+/, "")}`
6073
6381
  );
6074
6382
  }
6383
+ async createExport(params) {
6384
+ const body2 = typeof params === "string" ? { path: params } : Array.isArray(params) ? { paths: params } : params;
6385
+ const response = unwrap38(
6386
+ await this.http.post(
6387
+ `/sandboxes/${this.id}/exports`,
6388
+ body2
6389
+ )
6390
+ );
6391
+ return normalizeExport(response);
6392
+ }
6393
+ async downloadExport(paths, options = {}) {
6394
+ const query = new URLSearchParams();
6395
+ if (Array.isArray(paths)) {
6396
+ for (const path of paths) query.append("paths[]", path);
6397
+ } else {
6398
+ query.set("path", paths);
6399
+ }
6400
+ if (options.filename) query.set("filename", options.filename);
6401
+ return this.http.getBinary(
6402
+ `/sandboxes/${this.id}/exports/download?${query.toString()}`
6403
+ );
6404
+ }
6075
6405
  async readFile(path) {
6076
6406
  return new TextDecoder().decode(await this.download(path));
6077
6407
  }
6078
6408
  async listFiles(path = "/workspace") {
6079
6409
  this.assertRunning("files.list");
6080
- const response = unwrap36(
6410
+ const response = unwrap38(
6081
6411
  await this.http.get(
6082
6412
  `/sandboxes/${this.id}/files`,
6083
6413
  { path }
@@ -6087,7 +6417,7 @@ var Sandbox = class _Sandbox {
6087
6417
  }
6088
6418
  async statFile(path) {
6089
6419
  this.assertRunning("files.stat");
6090
- return unwrap36(
6420
+ return unwrap38(
6091
6421
  await this.http.post(
6092
6422
  `/sandboxes/${this.id}/files/stat`,
6093
6423
  { path }
@@ -6096,7 +6426,7 @@ var Sandbox = class _Sandbox {
6096
6426
  }
6097
6427
  async expose(port) {
6098
6428
  this.assertRunning("expose");
6099
- const response = unwrap36(
6429
+ const response = unwrap38(
6100
6430
  await this.http.post(
6101
6431
  `/sandboxes/${this.id}/expose`,
6102
6432
  port === void 0 ? {} : { port }
@@ -6106,7 +6436,7 @@ var Sandbox = class _Sandbox {
6106
6436
  }
6107
6437
  async startTemplate(options = {}) {
6108
6438
  this.assertRunning("startTemplate");
6109
- return unwrap36(
6439
+ return unwrap38(
6110
6440
  await this.http.post(
6111
6441
  `/sandboxes/${this.id}/template/start`,
6112
6442
  options
@@ -6114,7 +6444,7 @@ var Sandbox = class _Sandbox {
6114
6444
  );
6115
6445
  }
6116
6446
  async getArtifacts() {
6117
- return unwrap36(
6447
+ return unwrap38(
6118
6448
  await this.http.get(
6119
6449
  `/sandboxes/${this.id}/artifacts`
6120
6450
  )
@@ -6125,7 +6455,7 @@ var Sandbox = class _Sandbox {
6125
6455
  `/sandboxes/${this.id}/logs`,
6126
6456
  { lines }
6127
6457
  );
6128
- return unwrap36(response);
6458
+ return unwrap38(response);
6129
6459
  }
6130
6460
  streamLogs() {
6131
6461
  return this.http.stream(
@@ -6134,7 +6464,7 @@ var Sandbox = class _Sandbox {
6134
6464
  }
6135
6465
  async createSnapshot(comment) {
6136
6466
  this.assertRunning("snapshots.create");
6137
- return unwrap36(
6467
+ return unwrap38(
6138
6468
  await this.http.post(
6139
6469
  `/sandboxes/${this.id}/snapshots`,
6140
6470
  comment ? { comment } : {}
@@ -6142,14 +6472,14 @@ var Sandbox = class _Sandbox {
6142
6472
  );
6143
6473
  }
6144
6474
  async listSnapshots() {
6145
- return unwrap36(
6475
+ return unwrap38(
6146
6476
  await this.http.get(
6147
6477
  `/sandboxes/${this.id}/snapshots`
6148
6478
  )
6149
6479
  );
6150
6480
  }
6151
6481
  async restoreSnapshot(snapshotId) {
6152
- const data = unwrap36(
6482
+ const data = unwrap38(
6153
6483
  await this.http.post(
6154
6484
  `/sandboxes/${this.id}/restore/${snapshotId}`,
6155
6485
  {}
@@ -6166,13 +6496,13 @@ var Sandbox = class _Sandbox {
6166
6496
  */
6167
6497
  async fork(opts = {}) {
6168
6498
  this.assertRunning("fork");
6169
- const body = {};
6170
- if (opts.name !== void 0) body.name = opts.name;
6171
- if (opts.metadata !== void 0) body.metadata = opts.metadata;
6172
- const data = unwrap36(
6499
+ const body2 = {};
6500
+ if (opts.name !== void 0) body2.name = opts.name;
6501
+ if (opts.metadata !== void 0) body2.metadata = opts.metadata;
6502
+ const data = unwrap38(
6173
6503
  await this.http.post(
6174
6504
  `/sandboxes/${this.id}/fork`,
6175
- body
6505
+ body2
6176
6506
  )
6177
6507
  );
6178
6508
  return new _Sandbox(this.http, data);
@@ -6191,7 +6521,7 @@ var Sandbox = class _Sandbox {
6191
6521
  if (keepLastSnapshots !== void 0) {
6192
6522
  metadata.keep_last_snapshots = keepLastSnapshots;
6193
6523
  }
6194
- const body = stripUndefined20({
6524
+ const body2 = stripUndefined20({
6195
6525
  name: params.name,
6196
6526
  slug: params.slug,
6197
6527
  tags: params.tags,
@@ -6200,17 +6530,17 @@ var Sandbox = class _Sandbox {
6200
6530
  timeout_sec: params.timeout_sec ?? params.timeoutSec,
6201
6531
  idle_timeout_sec: params.idle_timeout_sec ?? params.idleTimeoutSec
6202
6532
  });
6203
- const data = unwrap36(
6533
+ const data = unwrap38(
6204
6534
  await this.http.patch(
6205
6535
  `/sandboxes/${this.id}`,
6206
- body
6536
+ body2
6207
6537
  )
6208
6538
  );
6209
6539
  this.data = data;
6210
6540
  return this;
6211
6541
  }
6212
6542
  async extend(timeoutSec) {
6213
- const data = unwrap36(
6543
+ const data = unwrap38(
6214
6544
  await this.http.post(
6215
6545
  `/sandboxes/${this.id}/extend`,
6216
6546
  { timeout_sec: timeoutSec }
@@ -6233,7 +6563,7 @@ var Sandbox = class _Sandbox {
6233
6563
  return raw;
6234
6564
  }
6235
6565
  async pause() {
6236
- const data = unwrap36(
6566
+ const data = unwrap38(
6237
6567
  await this.http.post(
6238
6568
  `/sandboxes/${this.id}/pause`,
6239
6569
  {}
@@ -6243,7 +6573,7 @@ var Sandbox = class _Sandbox {
6243
6573
  return this;
6244
6574
  }
6245
6575
  async resume() {
6246
- const data = unwrap36(
6576
+ const data = unwrap38(
6247
6577
  await this.http.post(
6248
6578
  `/sandboxes/${this.id}/resume`,
6249
6579
  {}
@@ -6279,7 +6609,7 @@ var Sandbox = class _Sandbox {
6279
6609
  if (idempotencyKey11) {
6280
6610
  requestOptions.headers = { "Idempotency-Key": idempotencyKey11 };
6281
6611
  }
6282
- return unwrap36(
6612
+ return unwrap38(
6283
6613
  await this.http.request(
6284
6614
  `/sandboxes/${this.id}/deploy`,
6285
6615
  requestOptions
@@ -6291,7 +6621,7 @@ var Sandbox = class _Sandbox {
6291
6621
  }
6292
6622
  /** Check readiness of the sandbox (GET /sandboxes/:id/readiness). */
6293
6623
  async readiness() {
6294
- return unwrap36(
6624
+ return unwrap38(
6295
6625
  await this.http.get(
6296
6626
  `/sandboxes/${this.id}/readiness`
6297
6627
  )
@@ -6407,9 +6737,12 @@ var Sandbox = class _Sandbox {
6407
6737
  "SANDBOX_DESTROYED"
6408
6738
  );
6409
6739
  }
6740
+ if (this.data.state === "paused" && this.data.persistent === true) {
6741
+ return;
6742
+ }
6410
6743
  if (this.data.state !== "running") {
6411
6744
  throw new MiosaError(
6412
- `Cannot ${operation} on sandbox ${this.id}: state is ${this.data.state}, expected running`,
6745
+ `Cannot ${operation} on sandbox ${this.id}: state is ${this.data.state}, expected running or paused persistent`,
6413
6746
  409,
6414
6747
  "SANDBOX_NOT_RUNNING"
6415
6748
  );
@@ -6451,12 +6784,12 @@ var Sandboxes = class {
6451
6784
  const idempotencyKey11 = params.idempotencyKey ?? params.idempotency_key;
6452
6785
  const requestOptions = {
6453
6786
  method: "POST",
6454
- body: createBody2(params)
6787
+ body: createBody(params)
6455
6788
  };
6456
6789
  if (idempotencyKey11) {
6457
6790
  requestOptions.headers = { "Idempotency-Key": idempotencyKey11 };
6458
6791
  }
6459
- const data = unwrap36(
6792
+ const data = unwrap38(
6460
6793
  await this.http.request(
6461
6794
  "/sandboxes",
6462
6795
  requestOptions
@@ -6475,7 +6808,7 @@ var Sandboxes = class {
6475
6808
  return listItems11(data).map((item) => new Sandbox(this.http, item));
6476
6809
  }
6477
6810
  async get(id) {
6478
- const data = unwrap36(
6811
+ const data = unwrap38(
6479
6812
  await this.http.get(`/sandboxes/${id}`)
6480
6813
  );
6481
6814
  return new Sandbox(this.http, data);
@@ -6484,7 +6817,7 @@ var Sandboxes = class {
6484
6817
  return this.get(id);
6485
6818
  }
6486
6819
  async getByName(name) {
6487
- const data = unwrap36(
6820
+ const data = unwrap38(
6488
6821
  await this.http.get(
6489
6822
  `/sandboxes/by-name/${encodeURIComponent(name)}`
6490
6823
  )
@@ -6549,7 +6882,7 @@ var Sandboxes = class {
6549
6882
  metadata: params.metadata
6550
6883
  })
6551
6884
  );
6552
- return unwrap36(response);
6885
+ return unwrap38(response);
6553
6886
  }
6554
6887
  async createTemplateBuild(templateId, params = {}) {
6555
6888
  const response = await this.http.post(
@@ -6559,19 +6892,19 @@ var Sandboxes = class {
6559
6892
  metadata: params.metadata
6560
6893
  })
6561
6894
  );
6562
- return unwrap36(response);
6895
+ return unwrap38(response);
6563
6896
  }
6564
6897
  async listTemplateBuilds(templateId) {
6565
6898
  const response = await this.http.get(
6566
6899
  `/sandbox-templates/${templateId}/builds`
6567
6900
  );
6568
- return unwrap36(response);
6901
+ return unwrap38(response);
6569
6902
  }
6570
6903
  async getTemplateBuild(buildId) {
6571
6904
  const response = await this.http.get(
6572
6905
  `/sandbox-template-builds/${buildId}`
6573
6906
  );
6574
- return unwrap36(response);
6907
+ return unwrap38(response);
6575
6908
  }
6576
6909
  };
6577
6910
  function toBase642(bytes) {
@@ -6583,7 +6916,7 @@ function toBase642(bytes) {
6583
6916
  }
6584
6917
  return btoa(binary);
6585
6918
  }
6586
- function unwrap37(payload) {
6919
+ function unwrap39(payload) {
6587
6920
  if (payload && typeof payload === "object" && "data" in payload) {
6588
6921
  return payload.data;
6589
6922
  }
@@ -6626,7 +6959,7 @@ var SandboxTemplates = class {
6626
6959
  const data = await this.http.get(
6627
6960
  `/sandbox-templates/${templateId}`
6628
6961
  );
6629
- return unwrap37(data);
6962
+ return unwrap39(data);
6630
6963
  }
6631
6964
  async create(params) {
6632
6965
  const {
@@ -6636,17 +6969,17 @@ var SandboxTemplates = class {
6636
6969
  name,
6637
6970
  ...rest
6638
6971
  } = params;
6639
- const body = stripUndefined21({
6972
+ const body2 = stripUndefined21({
6640
6973
  name,
6641
6974
  build_spec: buildSpec ?? build_spec,
6642
6975
  ...rest
6643
6976
  });
6644
6977
  const data = await this.http.request("/sandbox-templates", {
6645
6978
  method: "POST",
6646
- body,
6979
+ body: body2,
6647
6980
  headers: { "Idempotency-Key": idempotencyKey8(ikey) }
6648
6981
  });
6649
- return unwrap37(data);
6982
+ return unwrap39(data);
6650
6983
  }
6651
6984
  async buildSpecSchema() {
6652
6985
  const data = await this.http.get("/sandbox-templates/build-spec");
@@ -6670,21 +7003,21 @@ var SandboxTemplates = class {
6670
7003
  }
6671
7004
  async createBuild(templateId, params = {}) {
6672
7005
  const { idempotencyKey: ikey, ...rest } = params;
6673
- const body = stripUndefined21(rest);
7006
+ const body2 = stripUndefined21(rest);
6674
7007
  const data = await this.http.request(
6675
7008
  `/sandbox-templates/${templateId}/builds`,
6676
7009
  {
6677
7010
  method: "POST",
6678
- body,
7011
+ body: body2,
6679
7012
  headers: { "Idempotency-Key": idempotencyKey8(ikey) }
6680
7013
  }
6681
7014
  );
6682
- return unwrap37(data);
7015
+ return unwrap39(data);
6683
7016
  }
6684
7017
  };
6685
7018
 
6686
7019
  // src/resources/settings.ts
6687
- function unwrap38(payload) {
7020
+ function unwrap40(payload) {
6688
7021
  if (payload && typeof payload === "object") {
6689
7022
  const p = payload;
6690
7023
  for (const k of [
@@ -6700,7 +7033,7 @@ function unwrap38(payload) {
6700
7033
  return payload;
6701
7034
  }
6702
7035
  function listItems13(payload) {
6703
- const result = unwrap38(payload);
7036
+ const result = unwrap40(payload);
6704
7037
  if (Array.isArray(result)) return result;
6705
7038
  return [];
6706
7039
  }
@@ -6717,46 +7050,46 @@ var Settings = class {
6717
7050
  /** Get the current tenant settings. */
6718
7051
  async get() {
6719
7052
  const data = await this.http.get("/settings");
6720
- return unwrap38(data);
7053
+ return unwrap40(data);
6721
7054
  }
6722
7055
  /** Update tenant settings. */
6723
7056
  async update(params) {
6724
- const body = stripUndefined22(params);
6725
- const data = await this.http.put("/settings", body);
6726
- return unwrap38(data);
7057
+ const body2 = stripUndefined22(params);
7058
+ const data = await this.http.put("/settings", body2);
7059
+ return unwrap40(data);
6727
7060
  }
6728
7061
  // ── Branding ──────────────────────────────────────────────────────────────
6729
7062
  /** Get tenant branding (logo, colors, custom wordmark). */
6730
7063
  async getBranding() {
6731
7064
  const data = await this.http.get("/settings/branding");
6732
- return unwrap38(data);
7065
+ return unwrap40(data);
6733
7066
  }
6734
7067
  /** Update tenant branding. */
6735
7068
  async updateBranding(params) {
6736
- const body = stripUndefined22(params);
6737
- const data = await this.http.put("/settings/branding", body);
6738
- return unwrap38(data);
7069
+ const body2 = stripUndefined22(params);
7070
+ const data = await this.http.put("/settings/branding", body2);
7071
+ return unwrap40(data);
6739
7072
  }
6740
7073
  // ── Read-only reference data ───────────────────────────────────────────────
6741
7074
  /** Get tenant-scoped compute pricing. */
6742
7075
  async computePricing() {
6743
7076
  const data = await this.http.get("/settings/compute-pricing");
6744
- return unwrap38(data);
7077
+ return unwrap40(data);
6745
7078
  }
6746
7079
  /** Get tenant-scoped GPU pricing. */
6747
7080
  async gpuPricing() {
6748
7081
  const data = await this.http.get("/settings/gpu-pricing");
6749
- return unwrap38(data);
7082
+ return unwrap40(data);
6750
7083
  }
6751
7084
  /** List models available to this tenant. */
6752
7085
  async availableModels() {
6753
7086
  const data = await this.http.get("/settings/available-models");
6754
- return unwrap38(data);
7087
+ return unwrap40(data);
6755
7088
  }
6756
7089
  /** List regions enabled for this tenant. */
6757
7090
  async regions() {
6758
7091
  const data = await this.http.get("/settings/regions");
6759
- return unwrap38(data);
7092
+ return unwrap40(data);
6760
7093
  }
6761
7094
  // ── BYOK provider keys ────────────────────────────────────────────────────
6762
7095
  /** List tenant-level BYOK provider keys (Anthropic, OpenAI, etc.). */
@@ -6766,12 +7099,12 @@ var Settings = class {
6766
7099
  }
6767
7100
  /** Create or update a BYOK provider key. */
6768
7101
  async upsertProviderKey(provider, params) {
6769
- const body = stripUndefined22(params);
7102
+ const body2 = stripUndefined22(params);
6770
7103
  const data = await this.http.put(
6771
7104
  `/settings/provider-keys/${provider}`,
6772
- body
7105
+ body2
6773
7106
  );
6774
- return unwrap38(data);
7107
+ return unwrap40(data);
6775
7108
  }
6776
7109
  /** Delete a BYOK provider key. */
6777
7110
  async deleteProviderKey(provider) {
@@ -6780,7 +7113,7 @@ var Settings = class {
6780
7113
  };
6781
7114
 
6782
7115
  // src/resources/snapshots-standalone.ts
6783
- function unwrap39(data) {
7116
+ function unwrap41(data) {
6784
7117
  if (data && typeof data === "object") {
6785
7118
  const d = data;
6786
7119
  for (const k of ["data", "snapshots", "items"]) {
@@ -6811,14 +7144,14 @@ var SnapshotsStandalone = class {
6811
7144
  return unwrapList12(await this.http.get("/admin/snapshots", query));
6812
7145
  }
6813
7146
  async get(snapshotId) {
6814
- return unwrap39(
7147
+ return unwrap41(
6815
7148
  await this.http.get(`/admin/snapshots/${snapshotId}`)
6816
7149
  );
6817
7150
  }
6818
7151
  };
6819
7152
 
6820
7153
  // src/resources/storage.ts
6821
- function unwrap40(payload) {
7154
+ function unwrap42(payload) {
6822
7155
  if (payload && typeof payload === "object" && "data" in payload) {
6823
7156
  return payload.data;
6824
7157
  }
@@ -6851,17 +7184,17 @@ var Storage = class {
6851
7184
  }
6852
7185
  async createBucket(params) {
6853
7186
  const { name, public: isPublic, visibility, ...rest } = params;
6854
- const body = stripUndefined23({
7187
+ const body2 = stripUndefined23({
6855
7188
  name,
6856
7189
  visibility: visibility ?? (isPublic === void 0 ? void 0 : isPublic ? "public" : "private"),
6857
7190
  ...rest
6858
7191
  });
6859
- const data = await this.http.post("/storage/buckets", body);
6860
- return unwrap40(data);
7192
+ const data = await this.http.post("/storage/buckets", body2);
7193
+ return unwrap42(data);
6861
7194
  }
6862
7195
  async getBucket(bucketId) {
6863
7196
  const data = await this.http.get(`/storage/buckets/${bucketId}`);
6864
- return unwrap40(data);
7197
+ return unwrap42(data);
6865
7198
  }
6866
7199
  async deleteBucket(bucketId) {
6867
7200
  await this.http.delete(`/storage/buckets/${bucketId}`);
@@ -6902,16 +7235,16 @@ var Storage = class {
6902
7235
  // ── Presigned URLs ─────────────────────────────────────────────────────────
6903
7236
  async presign(bucketId, params) {
6904
7237
  const operationMethod = params.operation === "put" ? "PUT" : params.operation === "get" ? "GET" : void 0;
6905
- const body = stripUndefined23({
7238
+ const body2 = stripUndefined23({
6906
7239
  key: params.key,
6907
7240
  method: params.method ?? operationMethod ?? "GET",
6908
7241
  expires_in: params.expiresIn ?? params.expires_in ?? params.expiresInSec ?? params.expires_in_sec ?? 3600
6909
7242
  });
6910
7243
  const data = await this.http.post(
6911
7244
  `/storage/buckets/${bucketId}/presign`,
6912
- body
7245
+ body2
6913
7246
  );
6914
- return unwrap40(data);
7247
+ return unwrap42(data);
6915
7248
  }
6916
7249
  };
6917
7250
 
@@ -7001,29 +7334,105 @@ var OrgInvites = class {
7001
7334
  };
7002
7335
 
7003
7336
  // src/resources/tenant.ts
7004
- function unwrap41(payload) {
7337
+ function unwrap43(payload) {
7005
7338
  if (payload && typeof payload === "object") {
7006
7339
  const p = payload;
7007
- for (const k of ["data", "tenant", "items"]) {
7340
+ for (const k of ["data", "tenant", "branding", "items"]) {
7008
7341
  if (k in p) return p[k];
7009
7342
  }
7010
7343
  }
7011
7344
  return payload;
7012
7345
  }
7346
+ function stripUndefined24(input) {
7347
+ return Object.fromEntries(
7348
+ Object.entries(input).filter(([, v]) => v !== void 0)
7349
+ );
7350
+ }
7351
+ var PreviewDomain = class {
7352
+ constructor(http) {
7353
+ this.http = http;
7354
+ }
7355
+ http;
7356
+ /** Get the tenant's white-label preview domain settings. */
7357
+ async get() {
7358
+ const data = await this.http.get("/tenant/preview-domain");
7359
+ return unwrap43(data);
7360
+ }
7361
+ /** Set the tenant's white-label preview domain. */
7362
+ async set(domain) {
7363
+ const data = await this.http.put("/tenant/preview-domain", {
7364
+ preview_domain: domain
7365
+ });
7366
+ return unwrap43(data);
7367
+ }
7368
+ /** Re-run DNS verification for the configured preview domain. */
7369
+ async verify() {
7370
+ const data = await this.http.post(
7371
+ "/tenant/preview-domain/verify",
7372
+ {}
7373
+ );
7374
+ return unwrap43(data);
7375
+ }
7376
+ /** Remove the tenant's custom preview domain. */
7377
+ async delete() {
7378
+ await this.http.delete("/tenant/preview-domain");
7379
+ }
7380
+ };
7381
+ var Branding = class {
7382
+ constructor(http) {
7383
+ this.http = http;
7384
+ }
7385
+ http;
7386
+ /** Get tenant branding used by white-label hosted surfaces. */
7387
+ async get() {
7388
+ const data = await this.http.get("/tenant/branding");
7389
+ return unwrap43(data);
7390
+ }
7391
+ /** Update tenant branding used by white-label hosted surfaces. */
7392
+ async set(params) {
7393
+ const data = await this.http.put("/tenant/branding", {
7394
+ branding: stripUndefined24(params)
7395
+ });
7396
+ return unwrap43(data);
7397
+ }
7398
+ /** Reset tenant branding to platform defaults. */
7399
+ async delete() {
7400
+ await this.http.delete("/tenant/branding");
7401
+ }
7402
+ };
7013
7403
  var Tenant = class {
7014
7404
  constructor(http) {
7015
7405
  this.http = http;
7406
+ this.preview_domain = new PreviewDomain(http);
7407
+ this.previewDomain = this.preview_domain;
7408
+ this.branding = new Branding(http);
7016
7409
  }
7017
7410
  http;
7411
+ preview_domain;
7412
+ branding;
7413
+ /** camelCase alias for SDK consumers that avoid snake_case properties. */
7414
+ previewDomain;
7018
7415
  /** Get the current tenant's plan, limits, and live usage counters. */
7019
7416
  async current() {
7020
7417
  const data = await this.http.get("/tenant/plan");
7021
- return unwrap41(data);
7418
+ return unwrap43(data);
7419
+ }
7420
+ /** Convenience alias for `tenant.branding.get()`. */
7421
+ async getBranding() {
7422
+ return this.branding.get();
7423
+ }
7424
+ /** Convenience alias for `tenant.branding.set(...)`. */
7425
+ async setBranding(params) {
7426
+ return this.branding.set(params);
7427
+ }
7428
+ /** Convenience alias for `tenant.branding.delete()`. */
7429
+ async deleteBranding() {
7430
+ await this.branding.delete();
7022
7431
  }
7023
7432
  };
7024
7433
 
7025
7434
  // src/resources/usage.ts
7026
- function unwrap42(payload) {
7435
+ function unwrap44(payload) {
7027
7436
  if (payload && typeof payload === "object") {
7028
7437
  const p = payload;
7029
7438
  for (const k of ["data", "usage", "sessions", "summary", "items"]) {
@@ -7032,7 +7441,7 @@ function unwrap42(payload) {
7032
7441
  }
7033
7442
  return payload;
7034
7443
  }
7035
- function stripUndefined24(input) {
7444
+ function stripUndefined25(input) {
7036
7445
  return Object.fromEntries(
7037
7446
  Object.entries(input).filter(([, v]) => v !== void 0)
7038
7447
  );
@@ -7045,24 +7454,24 @@ var Usage = class {
7045
7454
  /** Get the current period usage summary. */
7046
7455
  async current() {
7047
7456
  const data = await this.http.get("/usage/summary");
7048
- return unwrap42(data);
7457
+ return unwrap44(data);
7049
7458
  }
7050
7459
  /** List per-session metering events. */
7051
7460
  async sessions(params = {}) {
7052
- const query = stripUndefined24(params);
7461
+ const query = stripUndefined25(params);
7053
7462
  const data = await this.http.get("/usage/sessions", query);
7054
- const result = unwrap42(data);
7463
+ const result = unwrap44(data);
7055
7464
  if (Array.isArray(result)) return result;
7056
7465
  return [];
7057
7466
  }
7058
7467
  /** Get a usage report for a period. */
7059
7468
  async report(params = {}) {
7060
- const query = stripUndefined24(params);
7469
+ const query = stripUndefined25(params);
7061
7470
  const data = await this.http.get("/usage/summary", query);
7062
- return unwrap42(data);
7471
+ return unwrap44(data);
7063
7472
  }
7064
7473
  };
7065
- function unwrap43(payload) {
7474
+ function unwrap45(payload) {
7066
7475
  if (payload && typeof payload === "object" && "data" in payload) {
7067
7476
  return payload.data;
7068
7477
  }
@@ -7078,7 +7487,7 @@ function listItems15(payload, candidateKeys = ["data", "volumes", "items"]) {
7078
7487
  }
7079
7488
  return [];
7080
7489
  }
7081
- function stripUndefined25(input) {
7490
+ function stripUndefined26(input) {
7082
7491
  return Object.fromEntries(
7083
7492
  Object.entries(input).filter(([, v]) => v !== void 0)
7084
7493
  );
@@ -7092,32 +7501,32 @@ var Volumes = class {
7092
7501
  }
7093
7502
  http;
7094
7503
  async list(params = {}) {
7095
- const query = stripUndefined25({ ...params });
7504
+ const query = stripUndefined26({ ...params });
7096
7505
  const data = await this.http.get("/volumes", query);
7097
7506
  return listItems15(data);
7098
7507
  }
7099
7508
  async get(volumeId) {
7100
7509
  const data = await this.http.get(`/volumes/${volumeId}`);
7101
- return unwrap43(data);
7510
+ return unwrap45(data);
7102
7511
  }
7103
7512
  async create(params) {
7104
7513
  const { idempotencyKey: ikey, sizeGb, ...rest } = params;
7105
- const body = stripUndefined25({
7514
+ const body2 = stripUndefined26({
7106
7515
  ...rest,
7107
7516
  size_gb: sizeGb ?? rest.size_gb
7108
7517
  });
7109
7518
  const data = await this.http.request("/volumes", {
7110
7519
  method: "POST",
7111
- body,
7520
+ body: body2,
7112
7521
  headers: { "Idempotency-Key": idempotencyKey9(ikey) }
7113
7522
  });
7114
- return unwrap43(data);
7523
+ return unwrap45(data);
7115
7524
  }
7116
7525
  async delete(volumeId) {
7117
7526
  await this.http.delete(`/volumes/${volumeId}`);
7118
7527
  }
7119
7528
  };
7120
- function unwrap44(payload) {
7529
+ function unwrap46(payload) {
7121
7530
  if (payload && typeof payload === "object" && "data" in payload) {
7122
7531
  return payload.data;
7123
7532
  }
@@ -7133,7 +7542,7 @@ function listItems16(payload, candidateKeys = ["data", "webhooks", "deliveries",
7133
7542
  }
7134
7543
  return [];
7135
7544
  }
7136
- function stripUndefined26(input) {
7545
+ function stripUndefined27(input) {
7137
7546
  return Object.fromEntries(
7138
7547
  Object.entries(input).filter(([, v]) => v !== void 0)
7139
7548
  );
@@ -7141,34 +7550,65 @@ function stripUndefined26(input) {
7141
7550
  function idempotencyKey10(key) {
7142
7551
  return key ?? randomUUID();
7143
7552
  }
7553
+ function bodyBuffer(body2) {
7554
+ if (Buffer.isBuffer(body2)) return body2;
7555
+ if (typeof body2 === "string") return Buffer.from(body2, "utf8");
7556
+ return Buffer.from(body2);
7557
+ }
7558
+ function verifySignature(body2, header, secret, toleranceSec = 300) {
7559
+ const parts = Object.fromEntries(
7560
+ header.split(",").map((chunk) => chunk.split("=", 2)).filter(([key, value]) => key && value)
7561
+ );
7562
+ const timestamp = parts.t;
7563
+ const received = parts.v1;
7564
+ if (!timestamp || !received || !secret) return false;
7565
+ const unixSeconds = Number(timestamp);
7566
+ if (!Number.isFinite(unixSeconds)) return false;
7567
+ const ageSec = Math.abs(Date.now() / 1e3 - unixSeconds);
7568
+ if (ageSec > toleranceSec) {
7569
+ throw new Error("webhook timestamp too old");
7570
+ }
7571
+ const rawBody = bodyBuffer(body2);
7572
+ const signed = Buffer.concat([Buffer.from(`${timestamp}.`), rawBody]);
7573
+ const expected = createHmac("sha256", secret).update(signed).digest("hex");
7574
+ try {
7575
+ return timingSafeEqual(
7576
+ Buffer.from(expected, "utf8"),
7577
+ Buffer.from(received, "utf8")
7578
+ );
7579
+ } catch {
7580
+ return false;
7581
+ }
7582
+ }
7144
7583
  var Webhooks = class {
7145
7584
  constructor(http) {
7146
7585
  this.http = http;
7147
7586
  }
7148
7587
  http;
7588
+ static verifySignature = verifySignature;
7149
7589
  async list(params = {}) {
7150
- const query = stripUndefined26({ ...params });
7590
+ const query = stripUndefined27({ ...params });
7151
7591
  const data = await this.http.get("/webhooks", query);
7152
7592
  return listItems16(data);
7153
7593
  }
7154
7594
  async get(webhookId) {
7155
7595
  const data = await this.http.get(`/webhooks/${webhookId}`);
7156
- return unwrap44(data);
7596
+ return unwrap46(data);
7157
7597
  }
7158
7598
  async create(params) {
7159
7599
  const { idempotencyKey: ikey, ...rest } = params;
7160
- const body = stripUndefined26(rest);
7600
+ const body2 = stripUndefined27(rest);
7161
7601
  const data = await this.http.request("/webhooks", {
7162
7602
  method: "POST",
7163
- body,
7603
+ body: body2,
7164
7604
  headers: { "Idempotency-Key": idempotencyKey10(ikey) }
7165
7605
  });
7166
- return unwrap44(data);
7606
+ return unwrap46(data);
7167
7607
  }
7168
7608
  async update(webhookId, params) {
7169
- const body = stripUndefined26(params);
7170
- const data = await this.http.patch(`/webhooks/${webhookId}`, body);
7171
- return unwrap44(data);
7609
+ const body2 = stripUndefined27(params);
7610
+ const data = await this.http.patch(`/webhooks/${webhookId}`, body2);
7611
+ return unwrap46(data);
7172
7612
  }
7173
7613
  async delete(webhookId) {
7174
7614
  await this.http.delete(`/webhooks/${webhookId}`);
@@ -7181,7 +7621,7 @@ var Webhooks = class {
7181
7621
  headers: { "Idempotency-Key": idempotencyKey10(opts.idempotencyKey) }
7182
7622
  }
7183
7623
  );
7184
- return unwrap44(data);
7624
+ return unwrap46(data);
7185
7625
  }
7186
7626
  async deliveries(webhookId) {
7187
7627
  const data = await this.http.get(
@@ -7352,8 +7792,6 @@ var DEFAULT_MAX_RETRIES2 = 3;
7352
7792
  var Miosa = class {
7353
7793
  /** Per-workspace user roster — list, add, update role, remove. */
7354
7794
  workspaceMembers;
7355
- /** Target-agnostic prompt dispatch to sandboxes/computers with durable records. */
7356
- agentRuns;
7357
7795
  /**
7358
7796
  * Workspace invite flow — create invite, list, revoke, preview, accept.
7359
7797
  * Sending to an email already in the org adds the user directly.
@@ -7390,6 +7828,10 @@ var Miosa = class {
7390
7828
  externalKeys;
7391
7829
  /** Model Context Protocol — JSON-RPC dispatch + streaming channel. */
7392
7830
  mcp;
7831
+ /** Agent Runs — prompt dispatch into sandbox targets. */
7832
+ agentRuns;
7833
+ /** Agent runtime profiles — tenant/workspace defaults for sandbox/computer agents. */
7834
+ agentRuntimeProfiles;
7393
7835
  /** Computer management — create, list, get, delete. */
7394
7836
  computers;
7395
7837
  /** Sandboxes — native code-execution environments under `/sandboxes`. */
@@ -7476,7 +7918,6 @@ var Miosa = class {
7476
7918
  timeout: config.timeout ?? DEFAULT_TIMEOUT2,
7477
7919
  maxRetries: config.maxRetries ?? DEFAULT_MAX_RETRIES2
7478
7920
  });
7479
- this.agentRuns = new AgentRuns(this.http);
7480
7921
  this.workspaceMembers = new WorkspaceMembers(this.http);
7481
7922
  this.workspaceInvites = new WorkspaceInvites(this.http);
7482
7923
  this.orgInvites = new OrgInvites(this.http);
@@ -7493,6 +7934,8 @@ var Miosa = class {
7493
7934
  this.projectAuth = new ProjectAuth(this.http);
7494
7935
  this.externalKeys = new ExternalKeys(this.http);
7495
7936
  this.mcp = new Mcp(this.http);
7937
+ this.agentRuns = new AgentRuns(this.http);
7938
+ this.agentRuntimeProfiles = new AgentRuntimeProfiles(this.http);
7496
7939
  this.computers = new Computers(this.http);
7497
7940
  this.sandboxes = new Sandboxes(this.http);
7498
7941
  this.deployments = new Deployments(this.http);
@@ -7614,8 +8057,8 @@ var AppAuth = class {
7614
8057
  }
7615
8058
  });
7616
8059
  if (!resp.ok) {
7617
- const body = await resp.text();
7618
- throw new Error(`AppAuth me failed (${resp.status}): ${body}`);
8060
+ const body2 = await resp.text();
8061
+ throw new Error(`AppAuth me failed (${resp.status}): ${body2}`);
7619
8062
  }
7620
8063
  return unwrapSession(await resp.json());
7621
8064
  }
@@ -7667,12 +8110,12 @@ var AppAuth = class {
7667
8110
  return payload;
7668
8111
  }
7669
8112
  // ── Private ──────────────────────────────────────────────────────────────────
7670
- async _post(action, body) {
8113
+ async _post(action, body2) {
7671
8114
  const url = `${this.baseUrl}/app-auth/${this.resourceType}/${this.resourceId}/${action}`;
7672
8115
  const resp = await fetch(url, {
7673
8116
  method: "POST",
7674
8117
  headers: { "Content-Type": "application/json" },
7675
- body: JSON.stringify(body)
8118
+ body: JSON.stringify(body2)
7676
8119
  });
7677
8120
  if (!resp.ok) {
7678
8121
  const text = await resp.text();
@@ -7682,6 +8125,6 @@ var AppAuth = class {
7682
8125
  }
7683
8126
  };
7684
8127
 
7685
- export { Admin, AgentRuns, Analytics, ApiKeys, AppAuth, AuditLog, AuthError, Benchmarks, BuilderSessions, Channels, Checkpoints, CommandCenter, Community, Completions, Computer, ComputerAudit, ComputerAutoStop, ComputerEnv, ComputerInbox, ComputerLogs, ComputerNetwork, ComputerOsa, ComputerPorts, ComputerSecrets, ComputerTerminal, ComputerVolumes, Computers, Credits, CronJobs, Dashboard, Databases, DeploymentDomains, DeploymentReleases, DeploymentRuntimeInstances, DeploymentVersions, Deployments, Desktop, DockerDeploy, EgressAudit, EgressNetwork, EgressSecrets, Email, EmailCampaigns, EmailInbox, EmailTemplates, Embeddings, Exec, ExternalKeys, Files, FlatCustomDomains, Functions, HealthChecks, InsufficientCreditsError, Integrations, Mcp, Miosa, MiosaError, Models, NetworkError, NetworkPolicy, NotFoundError, OAuthFlow, OpenComputers, OrgInvites, ProjectAuth, ProjectIntegrations, ProviderDefaults, RateLimitError, Regions, SANDBOX_TEMPLATE, Sandbox, SandboxArtifacts, SandboxAudit, SandboxCommands, SandboxEnv, SandboxEvents, SandboxFiles, SandboxNetwork, SandboxPreview, SandboxPreviews, SandboxSecrets, SandboxTags, SandboxTemplates, SandboxTerminal, Sandboxes, ScopedFs, Settings, SnapshotsStandalone, Storage, Tenant, TimeoutError, Usage, ValidationError, Volumes, Webhooks, WorkspaceInvites, WorkspaceMembers };
8128
+ export { Admin, AgentRuns, AgentRuntimeProfiles, Analytics, ApiKeys, AppAuth, AuditLog, AuthError, Benchmarks, BuilderSessions, Channels, Checkpoints, CommandCenter, Community, Completions, Computer, ComputerAudit, ComputerAutoStop, ComputerEnv, ComputerInbox, ComputerLogs, ComputerNetwork, ComputerOsa, ComputerPorts, ComputerSecrets, ComputerTerminal, ComputerVolumes, Computers, Credits, CronJobs, Dashboard, Databases, DeploymentDomains, DeploymentReleases, DeploymentRuntimeInstances, DeploymentVersions, Deployments, Desktop, DockerDeploy, EgressAudit, EgressNetwork, EgressSecrets, Email, EmailCampaigns, EmailInbox, EmailTemplates, Embeddings, Exec, ExternalKeys, Files, FlatCustomDomains, Functions, HealthChecks, InsufficientCreditsError, Integrations, Mcp, Miosa, MiosaError, Models, NetworkError, NetworkPolicy, NotFoundError, OAuthFlow, OpenComputers, OrgInvites, ProjectAuth, ProjectIntegrations, ProviderDefaults, RateLimitError, Regions, SANDBOX_TEMPLATE, Sandbox, SandboxArtifacts, SandboxAudit, SandboxCommands, SandboxEnv, SandboxEvents, SandboxFiles, SandboxNetwork, SandboxPreview, SandboxPreviews, SandboxSecrets, SandboxTags, SandboxTemplates, SandboxTerminal, Sandboxes, ScopedFs, Settings, SnapshotsStandalone, Storage, Tenant, TimeoutError, Usage, ValidationError, Volumes, Webhooks, WorkspaceInvites, WorkspaceMembers, verifySignature };
7686
8129
  //# sourceMappingURL=index.js.map
7687
8130
  //# sourceMappingURL=index.js.map