@miosa/sdk 1.2.5 → 1.2.7
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/README.md +107 -59
- package/dist/index.d.ts +513 -193
- package/dist/index.js +1266 -891
- package/dist/index.js.map +1 -1
- package/package.json +1 -2
- package/src/client.ts +0 -293
- package/src/errors.ts +0 -136
- package/src/http.test.ts +0 -374
- package/src/http.ts +0 -390
- package/src/index.ts +0 -569
- package/src/resources/admin.ts +0 -348
- package/src/resources/analytics.ts +0 -60
- package/src/resources/api-keys.ts +0 -119
- package/src/resources/audit-log.ts +0 -64
- package/src/resources/benchmarks.ts +0 -104
- package/src/resources/builder-sessions.ts +0 -75
- package/src/resources/channels.ts +0 -143
- package/src/resources/checkpoints.ts +0 -225
- package/src/resources/command-center.ts +0 -73
- package/src/resources/community.ts +0 -103
- package/src/resources/completions.ts +0 -104
- package/src/resources/computer-auto-stop.ts +0 -43
- package/src/resources/computer-env.ts +0 -76
- package/src/resources/computer-logs.ts +0 -50
- package/src/resources/computer-osa.ts +0 -76
- package/src/resources/computer-ports.ts +0 -91
- package/src/resources/computer-terminal.ts +0 -61
- package/src/resources/computer-volumes.ts +0 -64
- package/src/resources/computer.ts +0 -551
- package/src/resources/computers.ts +0 -75
- package/src/resources/credits.ts +0 -43
- package/src/resources/cron-jobs.ts +0 -191
- package/src/resources/custom_domains.ts +0 -123
- package/src/resources/dashboard.ts +0 -49
- package/src/resources/databases.ts +0 -218
- package/src/resources/deployments.test.ts +0 -197
- package/src/resources/deployments.ts +0 -1208
- package/src/resources/desktop.ts +0 -134
- package/src/resources/devices.test.ts +0 -92
- package/src/resources/devices.ts +0 -291
- package/src/resources/egress.test.ts +0 -318
- package/src/resources/egressAudit.ts +0 -245
- package/src/resources/egressNetwork.ts +0 -450
- package/src/resources/egressSecrets.ts +0 -577
- package/src/resources/email.ts +0 -212
- package/src/resources/embeddings.ts +0 -36
- package/src/resources/events.ts +0 -296
- package/src/resources/exec.ts +0 -319
- package/src/resources/external-keys.ts +0 -79
- package/src/resources/files.test.ts +0 -339
- package/src/resources/files.ts +0 -220
- package/src/resources/flat-custom-domains.ts +0 -127
- package/src/resources/functions.ts +0 -178
- package/src/resources/health-checks.ts +0 -165
- package/src/resources/integrations.ts +0 -183
- package/src/resources/mcp.ts +0 -70
- package/src/resources/models.ts +0 -45
- package/src/resources/network_policy.ts +0 -73
- package/src/resources/open-computers/agents.ts +0 -91
- package/src/resources/open-computers/apps.ts +0 -102
- package/src/resources/open-computers/clusters.ts +0 -88
- package/src/resources/open-computers/desktop.ts +0 -34
- package/src/resources/open-computers/files.ts +0 -97
- package/src/resources/open-computers/hosts.ts +0 -85
- package/src/resources/open-computers/index.ts +0 -98
- package/src/resources/open-computers/jobs.ts +0 -75
- package/src/resources/open-computers/open_computers.test.ts +0 -288
- package/src/resources/open-computers/secrets.ts +0 -115
- package/src/resources/open-computers/terminal.ts +0 -33
- package/src/resources/open-computers/tunnels.ts +0 -87
- package/src/resources/open-computers/types.ts +0 -343
- package/src/resources/open-computers/workspaces.ts +0 -135
- package/src/resources/org-invites.ts +0 -189
- package/src/resources/project-auth.ts +0 -142
- package/src/resources/project-integrations.ts +0 -133
- package/src/resources/provider-defaults.ts +0 -89
- package/src/resources/regions.ts +0 -94
- package/src/resources/sandbox-templates.ts +0 -195
- package/src/resources/sandboxes.live.test.ts +0 -92
- package/src/resources/sandboxes.test.ts +0 -655
- package/src/resources/sandboxes.ts +0 -1437
- package/src/resources/settings.ts +0 -143
- package/src/resources/snapshots-standalone.ts +0 -51
- package/src/resources/storage.ts +0 -221
- package/src/resources/tenant.ts +0 -66
- package/src/resources/usage.ts +0 -85
- package/src/resources/volumes.ts +0 -117
- package/src/resources/webhooks.ts +0 -239
- package/src/resources/workspace-invites.ts +0 -188
- package/src/resources/workspace-members.test.ts +0 -121
- package/src/resources/workspace-members.ts +0 -143
- package/src/types.ts +0 -463
package/dist/index.js
CHANGED
|
@@ -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,
|
|
26
|
-
const message =
|
|
27
|
-
const code =
|
|
28
|
-
const 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 (
|
|
179
|
+
} else if (body2 !== void 0) {
|
|
180
180
|
headers = { ...headers, "Content-Type": "application/json" };
|
|
181
|
-
fetchBody = JSON.stringify(
|
|
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,
|
|
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,
|
|
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,
|
|
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,
|
|
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
|
|
291
|
+
let body2 = null;
|
|
292
292
|
if (options.body !== void 0) {
|
|
293
293
|
headers = { ...headers, "Content-Type": "application/json" };
|
|
294
|
-
|
|
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,
|
|
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,
|
|
384
|
+
return this.http.post(fullPath, body2);
|
|
385
385
|
case "PUT":
|
|
386
|
-
return this.http.put(fullPath,
|
|
386
|
+
return this.http.put(fullPath, body2);
|
|
387
387
|
case "PATCH":
|
|
388
|
-
return this.http.patch(fullPath,
|
|
388
|
+
return this.http.patch(fullPath, body2);
|
|
389
389
|
case "DELETE":
|
|
390
|
-
return this.http.delete(fullPath,
|
|
390
|
+
return this.http.delete(fullPath, body2);
|
|
391
391
|
}
|
|
392
392
|
}
|
|
393
393
|
// ── Overview ────────────────────────────────────────────────
|
|
@@ -592,10 +592,143 @@ var Admin = class {
|
|
|
592
592
|
model_id: modelId
|
|
593
593
|
});
|
|
594
594
|
}
|
|
595
|
+
/** POST /api/v1/admin/impersonate — returns {token, expires_at}. */
|
|
596
|
+
impersonate(externalUserId, options = {}) {
|
|
597
|
+
return this.http.post("/admin/impersonate", {
|
|
598
|
+
external_user_id: externalUserId,
|
|
599
|
+
ttl_sec: options.ttlSec ?? 3600
|
|
600
|
+
});
|
|
601
|
+
}
|
|
595
602
|
};
|
|
596
603
|
|
|
597
|
-
// src/resources/
|
|
604
|
+
// src/resources/agent-runtime-profiles.ts
|
|
598
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;
|
|
610
|
+
}
|
|
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
|
+
);
|
|
627
|
+
}
|
|
628
|
+
function normalize(profile) {
|
|
629
|
+
const normalized = {
|
|
630
|
+
...profile
|
|
631
|
+
};
|
|
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);
|
|
657
|
+
}
|
|
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;
|
|
700
|
+
}
|
|
701
|
+
function stripUndefined(input) {
|
|
702
|
+
return Object.fromEntries(
|
|
703
|
+
Object.entries(input).filter(([, value]) => value !== void 0)
|
|
704
|
+
);
|
|
705
|
+
}
|
|
706
|
+
var AgentRuns = class {
|
|
707
|
+
constructor(http) {
|
|
708
|
+
this.http = http;
|
|
709
|
+
}
|
|
710
|
+
http;
|
|
711
|
+
async run(params) {
|
|
712
|
+
const body2 = stripUndefined({
|
|
713
|
+
prompt: params.prompt,
|
|
714
|
+
target_kind: params.targetKind,
|
|
715
|
+
target_id: params.targetId,
|
|
716
|
+
sandbox_id: params.sandboxId,
|
|
717
|
+
computer_id: params.computerId,
|
|
718
|
+
provider: params.provider,
|
|
719
|
+
model: params.model,
|
|
720
|
+
command: params.command,
|
|
721
|
+
runtime_command: params.runtimeCommand,
|
|
722
|
+
cwd: params.cwd,
|
|
723
|
+
timeout: params.timeout,
|
|
724
|
+
metadata: params.metadata
|
|
725
|
+
});
|
|
726
|
+
return unwrap2(await this.http.post("/agent-runs", body2));
|
|
727
|
+
}
|
|
728
|
+
};
|
|
729
|
+
|
|
730
|
+
// src/resources/analytics.ts
|
|
731
|
+
function unwrap3(payload) {
|
|
599
732
|
if (payload && typeof payload === "object") {
|
|
600
733
|
const p = payload;
|
|
601
734
|
for (const k of ["data", "analytics", "series", "items"]) {
|
|
@@ -604,7 +737,7 @@ function unwrap(payload) {
|
|
|
604
737
|
}
|
|
605
738
|
return payload;
|
|
606
739
|
}
|
|
607
|
-
function
|
|
740
|
+
function stripUndefined2(input) {
|
|
608
741
|
return Object.fromEntries(
|
|
609
742
|
Object.entries(input).filter(([, v]) => v !== void 0)
|
|
610
743
|
);
|
|
@@ -616,18 +749,18 @@ var Analytics = class {
|
|
|
616
749
|
http;
|
|
617
750
|
/** Get the platform analytics overview. */
|
|
618
751
|
async overview(filters = {}) {
|
|
619
|
-
const query =
|
|
752
|
+
const query = stripUndefined2(filters);
|
|
620
753
|
const data = await this.http.get("/analytics/overview", query);
|
|
621
|
-
return
|
|
754
|
+
return unwrap3(data);
|
|
622
755
|
}
|
|
623
756
|
/** Get a timeseries for a metric over a period. */
|
|
624
757
|
async timeseries(params = {}) {
|
|
625
|
-
const query =
|
|
758
|
+
const query = stripUndefined2(params);
|
|
626
759
|
const data = await this.http.get("/analytics/timeseries", query);
|
|
627
|
-
return
|
|
760
|
+
return unwrap3(data);
|
|
628
761
|
}
|
|
629
762
|
};
|
|
630
|
-
function
|
|
763
|
+
function unwrap4(payload) {
|
|
631
764
|
if (payload && typeof payload === "object" && "data" in payload) {
|
|
632
765
|
return payload.data;
|
|
633
766
|
}
|
|
@@ -643,7 +776,7 @@ function listItems(payload, candidateKeys = ["data", "keys", "api_keys", "items"
|
|
|
643
776
|
}
|
|
644
777
|
return [];
|
|
645
778
|
}
|
|
646
|
-
function
|
|
779
|
+
function stripUndefined3(input) {
|
|
647
780
|
return Object.fromEntries(
|
|
648
781
|
Object.entries(input).filter(([, v]) => v !== void 0)
|
|
649
782
|
);
|
|
@@ -657,22 +790,33 @@ var ApiKeys = class {
|
|
|
657
790
|
}
|
|
658
791
|
http;
|
|
659
792
|
async list(params = {}) {
|
|
660
|
-
const query =
|
|
793
|
+
const query = stripUndefined3({ ...params });
|
|
661
794
|
const data = await this.http.get("/api-keys", query);
|
|
662
795
|
return listItems(data);
|
|
663
796
|
}
|
|
664
797
|
async create(params) {
|
|
665
798
|
const { idempotencyKey: ikey, expiresAt, ...rest } = params;
|
|
666
|
-
const
|
|
799
|
+
const body2 = stripUndefined3({
|
|
667
800
|
...rest,
|
|
668
801
|
expires_at: expiresAt ?? rest.expires_at
|
|
669
802
|
});
|
|
670
803
|
const data = await this.http.request("/api-keys", {
|
|
671
804
|
method: "POST",
|
|
672
|
-
body,
|
|
805
|
+
body: body2,
|
|
673
806
|
headers: { "Idempotency-Key": idempotencyKey(ikey) }
|
|
674
807
|
});
|
|
675
|
-
return
|
|
808
|
+
return unwrap4(data);
|
|
809
|
+
}
|
|
810
|
+
/** POST /api/v1/api-keys/scoped — L2 delegation token bound to one external user. */
|
|
811
|
+
async createScoped(params) {
|
|
812
|
+
const body2 = stripUndefined3({
|
|
813
|
+
external_user_id: params.externalUserId,
|
|
814
|
+
scopes: params.scopes,
|
|
815
|
+
expires_at: params.expiresAt
|
|
816
|
+
});
|
|
817
|
+
return unwrap4(
|
|
818
|
+
await this.http.post("/api-keys/scoped", body2)
|
|
819
|
+
);
|
|
676
820
|
}
|
|
677
821
|
async delete(keyId) {
|
|
678
822
|
await this.http.delete(`/api-keys/${keyId}`);
|
|
@@ -680,7 +824,7 @@ var ApiKeys = class {
|
|
|
680
824
|
};
|
|
681
825
|
|
|
682
826
|
// src/resources/audit-log.ts
|
|
683
|
-
function
|
|
827
|
+
function unwrap5(payload) {
|
|
684
828
|
if (payload && typeof payload === "object") {
|
|
685
829
|
const p = payload;
|
|
686
830
|
for (const k of ["data", "audit_log", "events", "items"]) {
|
|
@@ -689,7 +833,7 @@ function unwrap3(payload) {
|
|
|
689
833
|
}
|
|
690
834
|
return payload;
|
|
691
835
|
}
|
|
692
|
-
function
|
|
836
|
+
function stripUndefined4(input) {
|
|
693
837
|
return Object.fromEntries(
|
|
694
838
|
Object.entries(input).filter(([, v]) => v !== void 0)
|
|
695
839
|
);
|
|
@@ -701,16 +845,16 @@ var AuditLog = class {
|
|
|
701
845
|
http;
|
|
702
846
|
/** List audit-log events with optional filters. */
|
|
703
847
|
async list(params = {}) {
|
|
704
|
-
const query =
|
|
848
|
+
const query = stripUndefined4(params);
|
|
705
849
|
const data = await this.http.get("/audit-log", query);
|
|
706
|
-
const result =
|
|
850
|
+
const result = unwrap5(data);
|
|
707
851
|
if (Array.isArray(result)) return result;
|
|
708
852
|
return [];
|
|
709
853
|
}
|
|
710
854
|
};
|
|
711
855
|
|
|
712
856
|
// src/resources/benchmarks.ts
|
|
713
|
-
function
|
|
857
|
+
function unwrap6(data) {
|
|
714
858
|
if (data && typeof data === "object") {
|
|
715
859
|
const d = data;
|
|
716
860
|
for (const k of ["data", "benchmarks", "samples", "items"]) {
|
|
@@ -742,19 +886,19 @@ var Benchmarks = class {
|
|
|
742
886
|
return unwrapList(data);
|
|
743
887
|
}
|
|
744
888
|
async get(benchmarkId) {
|
|
745
|
-
return
|
|
889
|
+
return unwrap6(
|
|
746
890
|
await this.http.get(`/admin/benchmarks/${benchmarkId}`)
|
|
747
891
|
);
|
|
748
892
|
}
|
|
749
893
|
/** Start a new benchmark run — pass kind and run-specific options. */
|
|
750
894
|
async create(params) {
|
|
751
|
-
const
|
|
895
|
+
const body2 = Object.fromEntries(
|
|
752
896
|
Object.entries(params).filter(([, v]) => v !== void 0)
|
|
753
897
|
);
|
|
754
|
-
return
|
|
898
|
+
return unwrap6(await this.http.post("/admin/benchmarks", body2));
|
|
755
899
|
}
|
|
756
900
|
async cancel(benchmarkId) {
|
|
757
|
-
return
|
|
901
|
+
return unwrap6(
|
|
758
902
|
await this.http.post(`/admin/benchmarks/${benchmarkId}/cancel`)
|
|
759
903
|
);
|
|
760
904
|
}
|
|
@@ -771,17 +915,17 @@ var Benchmarks = class {
|
|
|
771
915
|
}
|
|
772
916
|
/** Compare two benchmark runs. */
|
|
773
917
|
async compare(params) {
|
|
774
|
-
const
|
|
918
|
+
const body2 = Object.fromEntries(
|
|
775
919
|
Object.entries(params).filter(([, v]) => v !== void 0)
|
|
776
920
|
);
|
|
777
|
-
return
|
|
778
|
-
await this.http.post("/admin/benchmarks/compare",
|
|
921
|
+
return unwrap6(
|
|
922
|
+
await this.http.post("/admin/benchmarks/compare", body2)
|
|
779
923
|
);
|
|
780
924
|
}
|
|
781
925
|
};
|
|
782
926
|
|
|
783
927
|
// src/resources/builder-sessions.ts
|
|
784
|
-
function
|
|
928
|
+
function unwrap7(data) {
|
|
785
929
|
if (data && typeof data === "object") {
|
|
786
930
|
const d = data;
|
|
787
931
|
for (const k of ["data", "sessions", "items"]) {
|
|
@@ -818,7 +962,7 @@ var BuilderSessions = class {
|
|
|
818
962
|
return all.find((s) => s.id === sessionId) ?? {};
|
|
819
963
|
}
|
|
820
964
|
async updateTitle(sessionId, title) {
|
|
821
|
-
return
|
|
965
|
+
return unwrap7(
|
|
822
966
|
await this.http.patch(`/builder/sessions/${sessionId}/title`, {
|
|
823
967
|
title
|
|
824
968
|
})
|
|
@@ -830,7 +974,7 @@ var BuilderSessions = class {
|
|
|
830
974
|
};
|
|
831
975
|
|
|
832
976
|
// src/resources/channels.ts
|
|
833
|
-
function
|
|
977
|
+
function unwrap8(payload) {
|
|
834
978
|
if (payload && typeof payload === "object") {
|
|
835
979
|
const p = payload;
|
|
836
980
|
for (const k of ["data", "channels", "notifications", "items"]) {
|
|
@@ -839,7 +983,7 @@ function unwrap6(payload) {
|
|
|
839
983
|
}
|
|
840
984
|
return payload;
|
|
841
985
|
}
|
|
842
|
-
function
|
|
986
|
+
function stripUndefined5(input) {
|
|
843
987
|
return Object.fromEntries(
|
|
844
988
|
Object.entries(input).filter(([, v]) => v !== void 0)
|
|
845
989
|
);
|
|
@@ -856,28 +1000,28 @@ var Channels = class {
|
|
|
856
1000
|
http;
|
|
857
1001
|
/** List all channels for the tenant. */
|
|
858
1002
|
async list(params = {}) {
|
|
859
|
-
const query =
|
|
1003
|
+
const query = stripUndefined5(params);
|
|
860
1004
|
const data = await this.http.get("/channels", query);
|
|
861
|
-
const result =
|
|
1005
|
+
const result = unwrap8(data);
|
|
862
1006
|
if (Array.isArray(result)) return result;
|
|
863
1007
|
return [];
|
|
864
1008
|
}
|
|
865
1009
|
/** Get a single channel. */
|
|
866
1010
|
async get(channelId) {
|
|
867
1011
|
const data = await this.http.get(`/channels/${channelId}`);
|
|
868
|
-
return
|
|
1012
|
+
return unwrap8(data);
|
|
869
1013
|
}
|
|
870
1014
|
/** Create a new channel. */
|
|
871
1015
|
async create(params) {
|
|
872
|
-
const
|
|
873
|
-
const data = await this.http.post("/channels",
|
|
874
|
-
return
|
|
1016
|
+
const body2 = stripUndefObj(params);
|
|
1017
|
+
const data = await this.http.post("/channels", body2);
|
|
1018
|
+
return unwrap8(data);
|
|
875
1019
|
}
|
|
876
1020
|
/** Update a channel. */
|
|
877
1021
|
async update(channelId, params) {
|
|
878
|
-
const
|
|
879
|
-
const data = await this.http.patch(`/channels/${channelId}`,
|
|
880
|
-
return
|
|
1022
|
+
const body2 = stripUndefObj(params);
|
|
1023
|
+
const data = await this.http.patch(`/channels/${channelId}`, body2);
|
|
1024
|
+
return unwrap8(data);
|
|
881
1025
|
}
|
|
882
1026
|
/** Delete a channel. */
|
|
883
1027
|
async delete(channelId) {
|
|
@@ -887,30 +1031,30 @@ var Channels = class {
|
|
|
887
1031
|
/** Get notification preferences across all channels. */
|
|
888
1032
|
async listNotifications() {
|
|
889
1033
|
const data = await this.http.get("/channels/notifications");
|
|
890
|
-
return
|
|
1034
|
+
return unwrap8(data);
|
|
891
1035
|
}
|
|
892
1036
|
/** Update notification preferences. */
|
|
893
1037
|
async updateNotifications(params) {
|
|
894
|
-
const
|
|
895
|
-
const data = await this.http.put("/channels/notifications",
|
|
896
|
-
return
|
|
1038
|
+
const body2 = stripUndefObj(params);
|
|
1039
|
+
const data = await this.http.put("/channels/notifications", body2);
|
|
1040
|
+
return unwrap8(data);
|
|
897
1041
|
}
|
|
898
1042
|
/** Enable a channel. */
|
|
899
1043
|
async enable(channelId) {
|
|
900
1044
|
const data = await this.http.post(`/channels/${channelId}/enable`);
|
|
901
|
-
return
|
|
1045
|
+
return unwrap8(data);
|
|
902
1046
|
}
|
|
903
1047
|
/** Disable a channel. */
|
|
904
1048
|
async disable(channelId) {
|
|
905
1049
|
const data = await this.http.post(
|
|
906
1050
|
`/channels/${channelId}/disable`
|
|
907
1051
|
);
|
|
908
|
-
return
|
|
1052
|
+
return unwrap8(data);
|
|
909
1053
|
}
|
|
910
1054
|
};
|
|
911
1055
|
|
|
912
1056
|
// src/resources/command-center.ts
|
|
913
|
-
function
|
|
1057
|
+
function unwrap9(data) {
|
|
914
1058
|
if (data && typeof data === "object") {
|
|
915
1059
|
const d = data;
|
|
916
1060
|
for (const k of [
|
|
@@ -944,7 +1088,7 @@ var CommandCenter = class {
|
|
|
944
1088
|
http;
|
|
945
1089
|
/** Top-level snapshot (GET /command-center). */
|
|
946
1090
|
async overview() {
|
|
947
|
-
return
|
|
1091
|
+
return unwrap9(await this.http.get("/command-center"));
|
|
948
1092
|
}
|
|
949
1093
|
async agents() {
|
|
950
1094
|
return unwrapList3(await this.http.get("/command-center/agents"));
|
|
@@ -955,13 +1099,13 @@ var CommandCenter = class {
|
|
|
955
1099
|
);
|
|
956
1100
|
}
|
|
957
1101
|
async metrics() {
|
|
958
|
-
return
|
|
1102
|
+
return unwrap9(await this.http.get("/command-center/metrics"));
|
|
959
1103
|
}
|
|
960
1104
|
async presets() {
|
|
961
1105
|
return unwrapList3(await this.http.get("/command-center/presets"));
|
|
962
1106
|
}
|
|
963
1107
|
async tiers() {
|
|
964
|
-
return
|
|
1108
|
+
return unwrap9(await this.http.get("/command-center/tiers"));
|
|
965
1109
|
}
|
|
966
1110
|
/** Stream live command-center events via SSE. */
|
|
967
1111
|
events() {
|
|
@@ -970,7 +1114,7 @@ var CommandCenter = class {
|
|
|
970
1114
|
};
|
|
971
1115
|
|
|
972
1116
|
// src/resources/community.ts
|
|
973
|
-
function
|
|
1117
|
+
function unwrap10(data) {
|
|
974
1118
|
if (data && typeof data === "object") {
|
|
975
1119
|
const d = data;
|
|
976
1120
|
for (const k of ["data", "templates", "agents", "items"]) {
|
|
@@ -1002,7 +1146,7 @@ var Community = class {
|
|
|
1002
1146
|
return unwrapList4(await this.http.get("/community/agents", query));
|
|
1003
1147
|
}
|
|
1004
1148
|
async getAgent(agentId) {
|
|
1005
|
-
return
|
|
1149
|
+
return unwrap10(await this.http.get(`/community/agents/${agentId}`));
|
|
1006
1150
|
}
|
|
1007
1151
|
// ── Templates ─────────────────────────────────────────────────────────
|
|
1008
1152
|
async listTemplates(filters = {}) {
|
|
@@ -1014,41 +1158,41 @@ var Community = class {
|
|
|
1014
1158
|
);
|
|
1015
1159
|
}
|
|
1016
1160
|
async getTemplate(templateId) {
|
|
1017
|
-
return
|
|
1161
|
+
return unwrap10(
|
|
1018
1162
|
await this.http.get(`/community/templates/${templateId}`)
|
|
1019
1163
|
);
|
|
1020
1164
|
}
|
|
1021
1165
|
/** Install a community template into the caller's tenant. */
|
|
1022
1166
|
async installTemplate(templateId, opts = {}) {
|
|
1023
|
-
const
|
|
1167
|
+
const body2 = Object.fromEntries(
|
|
1024
1168
|
Object.entries(opts).filter(([, v]) => v !== void 0)
|
|
1025
1169
|
);
|
|
1026
|
-
return
|
|
1170
|
+
return unwrap10(
|
|
1027
1171
|
await this.http.post(
|
|
1028
1172
|
`/community/templates/${templateId}/install`,
|
|
1029
|
-
|
|
1173
|
+
body2
|
|
1030
1174
|
)
|
|
1031
1175
|
);
|
|
1032
1176
|
}
|
|
1033
1177
|
/** Rate a community template (1–5). */
|
|
1034
1178
|
async rateTemplate(templateId, rating, opts = {}) {
|
|
1035
|
-
const
|
|
1179
|
+
const body2 = {
|
|
1036
1180
|
rating,
|
|
1037
1181
|
...Object.fromEntries(
|
|
1038
1182
|
Object.entries(opts).filter(([, v]) => v !== void 0)
|
|
1039
1183
|
)
|
|
1040
1184
|
};
|
|
1041
|
-
return
|
|
1185
|
+
return unwrap10(
|
|
1042
1186
|
await this.http.post(
|
|
1043
1187
|
`/community/templates/${templateId}/rate`,
|
|
1044
|
-
|
|
1188
|
+
body2
|
|
1045
1189
|
)
|
|
1046
1190
|
);
|
|
1047
1191
|
}
|
|
1048
1192
|
};
|
|
1049
1193
|
|
|
1050
1194
|
// src/resources/completions.ts
|
|
1051
|
-
function
|
|
1195
|
+
function unwrap11(data) {
|
|
1052
1196
|
if (data && typeof data === "object") {
|
|
1053
1197
|
const d = data;
|
|
1054
1198
|
if (Array.isArray(d.choices)) return d;
|
|
@@ -1067,24 +1211,24 @@ var Completions = class {
|
|
|
1067
1211
|
}
|
|
1068
1212
|
http;
|
|
1069
1213
|
create(params) {
|
|
1070
|
-
const
|
|
1214
|
+
const body2 = buildBody(params);
|
|
1071
1215
|
if (params.stream === true) {
|
|
1072
1216
|
return this.http.stream(
|
|
1073
1217
|
"/intelligence/completions",
|
|
1074
|
-
{ method: "POST", body }
|
|
1218
|
+
{ method: "POST", body: body2 }
|
|
1075
1219
|
);
|
|
1076
1220
|
}
|
|
1077
|
-
return this.http.post("/intelligence/completions",
|
|
1221
|
+
return this.http.post("/intelligence/completions", body2).then(unwrap11);
|
|
1078
1222
|
}
|
|
1079
1223
|
chat(params) {
|
|
1080
|
-
const
|
|
1224
|
+
const body2 = buildBody(params);
|
|
1081
1225
|
if (params.stream === true) {
|
|
1082
1226
|
return this.http.stream(
|
|
1083
1227
|
"/intelligence/chat/completions",
|
|
1084
|
-
{ method: "POST", body }
|
|
1228
|
+
{ method: "POST", body: body2 }
|
|
1085
1229
|
);
|
|
1086
1230
|
}
|
|
1087
|
-
return this.http.post("/intelligence/chat/completions",
|
|
1231
|
+
return this.http.post("/intelligence/chat/completions", body2).then(unwrap11);
|
|
1088
1232
|
}
|
|
1089
1233
|
};
|
|
1090
1234
|
|
|
@@ -1207,7 +1351,7 @@ var Checkpoints = class {
|
|
|
1207
1351
|
};
|
|
1208
1352
|
|
|
1209
1353
|
// src/resources/computer-auto-stop.ts
|
|
1210
|
-
function
|
|
1354
|
+
function unwrap12(data) {
|
|
1211
1355
|
if (data && typeof data === "object") {
|
|
1212
1356
|
const d = data;
|
|
1213
1357
|
if ("data" in d && Object.keys(d).length <= 2) {
|
|
@@ -1225,13 +1369,13 @@ var ComputerAutoStop = class {
|
|
|
1225
1369
|
computerId;
|
|
1226
1370
|
/** Return the current auto-stop configuration. */
|
|
1227
1371
|
async get() {
|
|
1228
|
-
return
|
|
1372
|
+
return unwrap12(
|
|
1229
1373
|
await this.http.get(`/computers/${this.computerId}/auto-stop`)
|
|
1230
1374
|
);
|
|
1231
1375
|
}
|
|
1232
1376
|
/** Set the idle timeout in seconds (0 disables auto-stop). */
|
|
1233
1377
|
async update(seconds) {
|
|
1234
|
-
return
|
|
1378
|
+
return unwrap12(
|
|
1235
1379
|
await this.http.patch(
|
|
1236
1380
|
`/computers/${this.computerId}/auto-stop`,
|
|
1237
1381
|
{ seconds }
|
|
@@ -1241,7 +1385,7 @@ var ComputerAutoStop = class {
|
|
|
1241
1385
|
};
|
|
1242
1386
|
|
|
1243
1387
|
// src/resources/computer-env.ts
|
|
1244
|
-
function
|
|
1388
|
+
function unwrap13(data) {
|
|
1245
1389
|
if (data && typeof data === "object") {
|
|
1246
1390
|
const d = data;
|
|
1247
1391
|
if ("data" in d && Object.keys(d).length <= 2) {
|
|
@@ -1276,11 +1420,11 @@ var ComputerEnv = class {
|
|
|
1276
1420
|
}
|
|
1277
1421
|
/** Create a new env var. Use update() to change an existing one. */
|
|
1278
1422
|
async set(name, value) {
|
|
1279
|
-
return
|
|
1423
|
+
return unwrap13(await this.http.post(this.base(), { name, value }));
|
|
1280
1424
|
}
|
|
1281
1425
|
/** Patch the value of an existing env var by name. */
|
|
1282
1426
|
async update(name, value) {
|
|
1283
|
-
return
|
|
1427
|
+
return unwrap13(
|
|
1284
1428
|
await this.http.patch(`${this.base()}/${name}`, { value })
|
|
1285
1429
|
);
|
|
1286
1430
|
}
|
|
@@ -1297,7 +1441,7 @@ var ComputerEnv = class {
|
|
|
1297
1441
|
};
|
|
1298
1442
|
|
|
1299
1443
|
// src/resources/computer-logs.ts
|
|
1300
|
-
function
|
|
1444
|
+
function unwrap14(data) {
|
|
1301
1445
|
if (data && typeof data === "object") {
|
|
1302
1446
|
const d = data;
|
|
1303
1447
|
if ("data" in d && Object.keys(d).length <= 2) {
|
|
@@ -1318,7 +1462,7 @@ var ComputerLogs = class {
|
|
|
1318
1462
|
const query = Object.fromEntries(
|
|
1319
1463
|
Object.entries(params).filter(([, v]) => v !== void 0)
|
|
1320
1464
|
);
|
|
1321
|
-
return
|
|
1465
|
+
return unwrap14(
|
|
1322
1466
|
await this.http.get(`/computers/${this.computerId}/logs`, query)
|
|
1323
1467
|
);
|
|
1324
1468
|
}
|
|
@@ -1331,7 +1475,7 @@ var ComputerLogs = class {
|
|
|
1331
1475
|
};
|
|
1332
1476
|
|
|
1333
1477
|
// src/resources/computer-osa.ts
|
|
1334
|
-
function
|
|
1478
|
+
function unwrap15(data) {
|
|
1335
1479
|
if (data && typeof data === "object") {
|
|
1336
1480
|
const d = data;
|
|
1337
1481
|
if ("data" in d && Object.keys(d).length <= 2) {
|
|
@@ -1349,47 +1493,47 @@ var ComputerOsa = class {
|
|
|
1349
1493
|
computerId;
|
|
1350
1494
|
/** Submit a free-form task to the in-VM OSA agent. */
|
|
1351
1495
|
async submitTask(task, params = {}) {
|
|
1352
|
-
const
|
|
1496
|
+
const body2 = {
|
|
1353
1497
|
task,
|
|
1354
1498
|
...Object.fromEntries(
|
|
1355
1499
|
Object.entries(params).filter(([, v]) => v !== void 0)
|
|
1356
1500
|
)
|
|
1357
1501
|
};
|
|
1358
|
-
return
|
|
1502
|
+
return unwrap15(
|
|
1359
1503
|
await this.http.post(
|
|
1360
1504
|
`/computers/${this.computerId}/osa/task`,
|
|
1361
|
-
|
|
1505
|
+
body2
|
|
1362
1506
|
)
|
|
1363
1507
|
);
|
|
1364
1508
|
}
|
|
1365
1509
|
/** Cancel the currently-running OSA task, if any. */
|
|
1366
1510
|
async cancelTask() {
|
|
1367
|
-
return
|
|
1511
|
+
return unwrap15(
|
|
1368
1512
|
await this.http.delete(`/computers/${this.computerId}/osa/task`)
|
|
1369
1513
|
);
|
|
1370
1514
|
}
|
|
1371
1515
|
/** Return OSA's current task / configuration / health snapshot. */
|
|
1372
1516
|
async status() {
|
|
1373
|
-
return
|
|
1517
|
+
return unwrap15(
|
|
1374
1518
|
await this.http.get(`/computers/${this.computerId}/osa/status`)
|
|
1375
1519
|
);
|
|
1376
1520
|
}
|
|
1377
1521
|
/** Update OSA runtime configuration (model, tools, secrets, etc.). */
|
|
1378
1522
|
async configure(config) {
|
|
1379
|
-
const
|
|
1523
|
+
const body2 = Object.fromEntries(
|
|
1380
1524
|
Object.entries(config).filter(([, v]) => v !== void 0)
|
|
1381
1525
|
);
|
|
1382
|
-
return
|
|
1526
|
+
return unwrap15(
|
|
1383
1527
|
await this.http.post(
|
|
1384
1528
|
`/computers/${this.computerId}/osa/configure`,
|
|
1385
|
-
|
|
1529
|
+
body2
|
|
1386
1530
|
)
|
|
1387
1531
|
);
|
|
1388
1532
|
}
|
|
1389
1533
|
};
|
|
1390
1534
|
|
|
1391
1535
|
// src/resources/computer-ports.ts
|
|
1392
|
-
function
|
|
1536
|
+
function unwrap16(data) {
|
|
1393
1537
|
if (data && typeof data === "object") {
|
|
1394
1538
|
const d = data;
|
|
1395
1539
|
if ("data" in d && Object.keys(d).length <= 2) {
|
|
@@ -1428,21 +1572,21 @@ var ComputerPorts = class {
|
|
|
1428
1572
|
}
|
|
1429
1573
|
/** Expose port with the given visibility options. */
|
|
1430
1574
|
async create(port, opts = {}) {
|
|
1431
|
-
const
|
|
1575
|
+
const body2 = {
|
|
1432
1576
|
port,
|
|
1433
1577
|
...Object.fromEntries(
|
|
1434
1578
|
Object.entries(opts).filter(([, v]) => v !== void 0)
|
|
1435
1579
|
)
|
|
1436
1580
|
};
|
|
1437
|
-
return
|
|
1581
|
+
return unwrap16(await this.http.post(this.base(), body2));
|
|
1438
1582
|
}
|
|
1439
1583
|
/** Patch visibility / auth options for port. */
|
|
1440
1584
|
async update(port, opts) {
|
|
1441
|
-
const
|
|
1585
|
+
const body2 = Object.fromEntries(
|
|
1442
1586
|
Object.entries(opts).filter(([, v]) => v !== void 0)
|
|
1443
1587
|
);
|
|
1444
|
-
return
|
|
1445
|
-
await this.http.patch(`${this.base()}/${port}`,
|
|
1588
|
+
return unwrap16(
|
|
1589
|
+
await this.http.patch(`${this.base()}/${port}`, body2)
|
|
1446
1590
|
);
|
|
1447
1591
|
}
|
|
1448
1592
|
/** Stop exposing port. */
|
|
@@ -1461,14 +1605,14 @@ var ComputerTerminal = class {
|
|
|
1461
1605
|
computerId;
|
|
1462
1606
|
/** Open a new PTY session. Returns the server payload (session id, etc.). */
|
|
1463
1607
|
async create(params = {}) {
|
|
1464
|
-
const
|
|
1608
|
+
const body2 = Object.fromEntries(
|
|
1465
1609
|
Object.entries(params).filter(([, v]) => v !== void 0)
|
|
1466
1610
|
);
|
|
1467
1611
|
const raw = await this.http.post(
|
|
1468
1612
|
`/computers/${this.computerId}/terminal`,
|
|
1469
|
-
|
|
1613
|
+
body2
|
|
1470
1614
|
);
|
|
1471
|
-
return
|
|
1615
|
+
return unwrap17(raw);
|
|
1472
1616
|
}
|
|
1473
1617
|
/** Resize an existing PTY session. */
|
|
1474
1618
|
async resize(sessionId, cols, rows) {
|
|
@@ -1476,10 +1620,10 @@ var ComputerTerminal = class {
|
|
|
1476
1620
|
`/computers/${this.computerId}/pty/${sessionId}/resize`,
|
|
1477
1621
|
{ cols, rows }
|
|
1478
1622
|
);
|
|
1479
|
-
return
|
|
1623
|
+
return unwrap17(raw);
|
|
1480
1624
|
}
|
|
1481
1625
|
};
|
|
1482
|
-
function
|
|
1626
|
+
function unwrap17(data) {
|
|
1483
1627
|
if (data && typeof data === "object") {
|
|
1484
1628
|
const d = data;
|
|
1485
1629
|
if ("data" in d && Object.keys(d).length <= 2) {
|
|
@@ -1490,7 +1634,7 @@ function unwrap15(data) {
|
|
|
1490
1634
|
}
|
|
1491
1635
|
|
|
1492
1636
|
// src/resources/computer-volumes.ts
|
|
1493
|
-
function
|
|
1637
|
+
function unwrap18(data) {
|
|
1494
1638
|
if (data && typeof data === "object") {
|
|
1495
1639
|
const d = data;
|
|
1496
1640
|
if ("data" in d && Object.keys(d).length <= 2) {
|
|
@@ -1524,7 +1668,7 @@ var ComputerVolumes = class {
|
|
|
1524
1668
|
}
|
|
1525
1669
|
/** Attach volumeId at mountPath inside the VM. */
|
|
1526
1670
|
async attach(volumeId, mountPath) {
|
|
1527
|
-
return
|
|
1671
|
+
return unwrap18(
|
|
1528
1672
|
await this.http.post(this.base(), {
|
|
1529
1673
|
volume_id: volumeId,
|
|
1530
1674
|
mount_path: mountPath
|
|
@@ -1697,7 +1841,7 @@ var Desktop = class {
|
|
|
1697
1841
|
};
|
|
1698
1842
|
|
|
1699
1843
|
// src/resources/egressAudit.ts
|
|
1700
|
-
function
|
|
1844
|
+
function unwrap19(payload) {
|
|
1701
1845
|
if (payload && typeof payload === "object") {
|
|
1702
1846
|
const p = payload;
|
|
1703
1847
|
for (const k of ["data", "event", "items"]) {
|
|
@@ -1716,7 +1860,7 @@ function unwrapList8(payload) {
|
|
|
1716
1860
|
}
|
|
1717
1861
|
return [];
|
|
1718
1862
|
}
|
|
1719
|
-
function
|
|
1863
|
+
function stripUndefined6(input) {
|
|
1720
1864
|
return Object.fromEntries(
|
|
1721
1865
|
Object.entries(input).filter(([, v]) => v !== void 0)
|
|
1722
1866
|
);
|
|
@@ -1726,7 +1870,7 @@ function pickFirst(...values) {
|
|
|
1726
1870
|
return void 0;
|
|
1727
1871
|
}
|
|
1728
1872
|
function listQuery(params) {
|
|
1729
|
-
return
|
|
1873
|
+
return stripUndefined6({
|
|
1730
1874
|
resource_id: pickFirst(params.resourceId, params.resource_id),
|
|
1731
1875
|
resource_type: pickFirst(params.resourceType, params.resource_type),
|
|
1732
1876
|
host: params.host,
|
|
@@ -1763,7 +1907,7 @@ var EgressAudit = class {
|
|
|
1763
1907
|
const data = await this.http.get(
|
|
1764
1908
|
`/egress/audit/${id}`
|
|
1765
1909
|
);
|
|
1766
|
-
return
|
|
1910
|
+
return unwrap19(data);
|
|
1767
1911
|
}
|
|
1768
1912
|
/**
|
|
1769
1913
|
* Long-poll the audit endpoint and yield new events as they appear.
|
|
@@ -1839,7 +1983,7 @@ var ComputerAudit = class extends SandboxAudit {
|
|
|
1839
1983
|
};
|
|
1840
1984
|
|
|
1841
1985
|
// src/resources/egressNetwork.ts
|
|
1842
|
-
function
|
|
1986
|
+
function unwrap20(payload) {
|
|
1843
1987
|
if (payload && typeof payload === "object") {
|
|
1844
1988
|
const p = payload;
|
|
1845
1989
|
for (const k of ["data", "policy", "rule", "items"]) {
|
|
@@ -1865,7 +2009,7 @@ function unwrapList9(payload) {
|
|
|
1865
2009
|
}
|
|
1866
2010
|
return [];
|
|
1867
2011
|
}
|
|
1868
|
-
function
|
|
2012
|
+
function stripUndefined7(input) {
|
|
1869
2013
|
return Object.fromEntries(
|
|
1870
2014
|
Object.entries(input).filter(([, v]) => v !== void 0)
|
|
1871
2015
|
);
|
|
@@ -1875,7 +2019,7 @@ function pickFirst2(...values) {
|
|
|
1875
2019
|
return void 0;
|
|
1876
2020
|
}
|
|
1877
2021
|
function ruleBody(host, params, effect) {
|
|
1878
|
-
return
|
|
2022
|
+
return stripUndefined7({
|
|
1879
2023
|
host,
|
|
1880
2024
|
effect,
|
|
1881
2025
|
methods: params.methods,
|
|
@@ -1898,7 +2042,7 @@ var EgressNetwork = class {
|
|
|
1898
2042
|
"/egress/allowlist",
|
|
1899
2043
|
ruleBody(host, params, "allow")
|
|
1900
2044
|
);
|
|
1901
|
-
return
|
|
2045
|
+
return unwrap20(data);
|
|
1902
2046
|
}
|
|
1903
2047
|
/** Add a `deny` rule for `host` to the allowlist. */
|
|
1904
2048
|
async deny(host, params = {}) {
|
|
@@ -1906,11 +2050,11 @@ var EgressNetwork = class {
|
|
|
1906
2050
|
"/egress/allowlist",
|
|
1907
2051
|
ruleBody(host, params, "deny")
|
|
1908
2052
|
);
|
|
1909
|
-
return
|
|
2053
|
+
return unwrap20(data);
|
|
1910
2054
|
}
|
|
1911
2055
|
/** List allowlist rules. */
|
|
1912
2056
|
async rules(params = {}) {
|
|
1913
|
-
const query =
|
|
2057
|
+
const query = stripUndefined7({
|
|
1914
2058
|
policy_id: pickFirst2(params.policyId, params.policy_id),
|
|
1915
2059
|
resource_id: pickFirst2(params.resourceId, params.resource_id),
|
|
1916
2060
|
resource_type: pickFirst2(params.resourceType, params.resource_type)
|
|
@@ -1925,7 +2069,7 @@ var EgressNetwork = class {
|
|
|
1925
2069
|
// ── policies ──────────────────────────────────────────────────────────────
|
|
1926
2070
|
/** List egress policies. */
|
|
1927
2071
|
async policies(params = {}) {
|
|
1928
|
-
const query =
|
|
2072
|
+
const query = stripUndefined7({
|
|
1929
2073
|
resource_id: pickFirst2(params.resourceId, params.resource_id),
|
|
1930
2074
|
resource_type: pickFirst2(params.resourceType, params.resource_type)
|
|
1931
2075
|
});
|
|
@@ -1934,7 +2078,7 @@ var EgressNetwork = class {
|
|
|
1934
2078
|
}
|
|
1935
2079
|
/** Create an egress policy. */
|
|
1936
2080
|
async createPolicy(params) {
|
|
1937
|
-
const
|
|
2081
|
+
const body2 = stripUndefined7({
|
|
1938
2082
|
name: params.name,
|
|
1939
2083
|
mode: params.mode ?? "enforce",
|
|
1940
2084
|
default_effect: pickFirst2(
|
|
@@ -1948,13 +2092,13 @@ var EgressNetwork = class {
|
|
|
1948
2092
|
});
|
|
1949
2093
|
const data = await this.http.post(
|
|
1950
2094
|
"/egress/policies",
|
|
1951
|
-
|
|
2095
|
+
body2
|
|
1952
2096
|
);
|
|
1953
|
-
return
|
|
2097
|
+
return unwrap20(data);
|
|
1954
2098
|
}
|
|
1955
2099
|
/** Update an egress policy by id. */
|
|
1956
2100
|
async updatePolicy(policyId, params) {
|
|
1957
|
-
const
|
|
2101
|
+
const body2 = stripUndefined7({
|
|
1958
2102
|
mode: params.mode,
|
|
1959
2103
|
default_effect: pickFirst2(params.defaultEffect, params.default_effect),
|
|
1960
2104
|
name: params.name,
|
|
@@ -1962,9 +2106,9 @@ var EgressNetwork = class {
|
|
|
1962
2106
|
});
|
|
1963
2107
|
const data = await this.http.patch(
|
|
1964
2108
|
`/egress/policies/${policyId}`,
|
|
1965
|
-
|
|
2109
|
+
body2
|
|
1966
2110
|
);
|
|
1967
|
-
return
|
|
2111
|
+
return unwrap20(data);
|
|
1968
2112
|
}
|
|
1969
2113
|
// ── mode helpers ──────────────────────────────────────────────────────────
|
|
1970
2114
|
/** Set the policy to `mode="enforce"` — denied egress is blocked. */
|
|
@@ -1982,21 +2126,21 @@ var EgressNetwork = class {
|
|
|
1982
2126
|
if (policyId) {
|
|
1983
2127
|
return this.updatePolicy(policyId, { mode });
|
|
1984
2128
|
}
|
|
1985
|
-
const
|
|
2129
|
+
const body2 = resourceId !== void 0 && resourceType !== void 0 ? stripUndefined7({
|
|
1986
2130
|
mode,
|
|
1987
2131
|
resource_id: resourceId,
|
|
1988
2132
|
resource_type: resourceType
|
|
1989
2133
|
}) : { mode };
|
|
1990
2134
|
const data = await this.http.patch(
|
|
1991
2135
|
"/egress/policies",
|
|
1992
|
-
|
|
2136
|
+
body2
|
|
1993
2137
|
);
|
|
1994
|
-
return
|
|
2138
|
+
return unwrap20(data);
|
|
1995
2139
|
}
|
|
1996
2140
|
// ── suggestions ───────────────────────────────────────────────────────────
|
|
1997
2141
|
/** AI-generated allowlist suggestions from recent denied egress. */
|
|
1998
2142
|
async suggestions(params = {}) {
|
|
1999
|
-
const query =
|
|
2143
|
+
const query = stripUndefined7({
|
|
2000
2144
|
resource_id: pickFirst2(params.resourceId, params.resource_id),
|
|
2001
2145
|
resource_type: pickFirst2(params.resourceType, params.resource_type),
|
|
2002
2146
|
since: params.since ?? "7d"
|
|
@@ -2047,28 +2191,28 @@ var SandboxNetwork = class {
|
|
|
2047
2191
|
return this.delegate.removeRule(ruleId);
|
|
2048
2192
|
}
|
|
2049
2193
|
lockdown(params = {}) {
|
|
2050
|
-
const
|
|
2194
|
+
const body2 = {
|
|
2051
2195
|
resource_id: this.resourceId,
|
|
2052
2196
|
resource_type: this.resourceType
|
|
2053
2197
|
};
|
|
2054
|
-
if (params.policyId !== void 0)
|
|
2055
|
-
return this.delegate.lockdown(
|
|
2198
|
+
if (params.policyId !== void 0) body2.policyId = params.policyId;
|
|
2199
|
+
return this.delegate.lockdown(body2);
|
|
2056
2200
|
}
|
|
2057
2201
|
observe(params = {}) {
|
|
2058
|
-
const
|
|
2202
|
+
const body2 = {
|
|
2059
2203
|
resource_id: this.resourceId,
|
|
2060
2204
|
resource_type: this.resourceType
|
|
2061
2205
|
};
|
|
2062
|
-
if (params.policyId !== void 0)
|
|
2063
|
-
return this.delegate.observe(
|
|
2206
|
+
if (params.policyId !== void 0) body2.policyId = params.policyId;
|
|
2207
|
+
return this.delegate.observe(body2);
|
|
2064
2208
|
}
|
|
2065
2209
|
suggestions(params = {}) {
|
|
2066
|
-
const
|
|
2210
|
+
const body2 = {
|
|
2067
2211
|
resource_id: this.resourceId,
|
|
2068
2212
|
resource_type: this.resourceType
|
|
2069
2213
|
};
|
|
2070
|
-
if (params.since !== void 0)
|
|
2071
|
-
return this.delegate.suggestions(
|
|
2214
|
+
if (params.since !== void 0) body2.since = params.since;
|
|
2215
|
+
return this.delegate.suggestions(body2);
|
|
2072
2216
|
}
|
|
2073
2217
|
policies() {
|
|
2074
2218
|
return this.delegate.policies({
|
|
@@ -2082,7 +2226,7 @@ var ComputerNetwork = class extends SandboxNetwork {
|
|
|
2082
2226
|
};
|
|
2083
2227
|
|
|
2084
2228
|
// src/resources/egressSecrets.ts
|
|
2085
|
-
function
|
|
2229
|
+
function unwrap21(payload) {
|
|
2086
2230
|
if (payload && typeof payload === "object") {
|
|
2087
2231
|
const p = payload;
|
|
2088
2232
|
for (const k of ["data", "secret", "binding", "items"]) {
|
|
@@ -2101,7 +2245,7 @@ function unwrapList10(payload) {
|
|
|
2101
2245
|
}
|
|
2102
2246
|
return [];
|
|
2103
2247
|
}
|
|
2104
|
-
function
|
|
2248
|
+
function stripUndefined8(input) {
|
|
2105
2249
|
return Object.fromEntries(
|
|
2106
2250
|
Object.entries(input).filter(([, v]) => v !== void 0)
|
|
2107
2251
|
);
|
|
@@ -2111,7 +2255,7 @@ function pickFirst3(...values) {
|
|
|
2111
2255
|
return void 0;
|
|
2112
2256
|
}
|
|
2113
2257
|
function setBody(params) {
|
|
2114
|
-
return
|
|
2258
|
+
return stripUndefined8({
|
|
2115
2259
|
name: params.name,
|
|
2116
2260
|
value: params.value,
|
|
2117
2261
|
type: params.type ?? "api_key",
|
|
@@ -2132,7 +2276,7 @@ function setBody(params) {
|
|
|
2132
2276
|
});
|
|
2133
2277
|
}
|
|
2134
2278
|
function listQuery2(params) {
|
|
2135
|
-
return
|
|
2279
|
+
return stripUndefined8({
|
|
2136
2280
|
scope: params.scope,
|
|
2137
2281
|
type: params.type,
|
|
2138
2282
|
workspace_id: pickFirst3(params.workspaceId, params.workspace_id),
|
|
@@ -2147,14 +2291,14 @@ function listQuery2(params) {
|
|
|
2147
2291
|
});
|
|
2148
2292
|
}
|
|
2149
2293
|
function rotateBody(params) {
|
|
2150
|
-
return
|
|
2294
|
+
return stripUndefined8({
|
|
2151
2295
|
value: pickFirst3(params.newValue, params.new_value, params.value),
|
|
2152
2296
|
refresh_token: pickFirst3(params.refreshToken, params.refresh_token),
|
|
2153
2297
|
expires_at: pickFirst3(params.expiresAt, params.expires_at)
|
|
2154
2298
|
});
|
|
2155
2299
|
}
|
|
2156
2300
|
function bindingBody(params) {
|
|
2157
|
-
return
|
|
2301
|
+
return stripUndefined8({
|
|
2158
2302
|
secret_id: pickFirst3(params.secretId, params.secret_id),
|
|
2159
2303
|
resource_id: pickFirst3(params.resourceId, params.resource_id),
|
|
2160
2304
|
resource_type: pickFirst3(params.resourceType, params.resource_type),
|
|
@@ -2162,14 +2306,14 @@ function bindingBody(params) {
|
|
|
2162
2306
|
});
|
|
2163
2307
|
}
|
|
2164
2308
|
function bindingQuery(params) {
|
|
2165
|
-
return
|
|
2309
|
+
return stripUndefined8({
|
|
2166
2310
|
resource_id: pickFirst3(params.resourceId, params.resource_id),
|
|
2167
2311
|
resource_type: pickFirst3(params.resourceType, params.resource_type),
|
|
2168
2312
|
secret_id: pickFirst3(params.secretId, params.secret_id)
|
|
2169
2313
|
});
|
|
2170
2314
|
}
|
|
2171
2315
|
function oauthBody(params) {
|
|
2172
|
-
return
|
|
2316
|
+
return stripUndefined8({
|
|
2173
2317
|
provider: params.provider,
|
|
2174
2318
|
expose_as_env: pickFirst3(params.exposeAsEnv, params.expose_as_env),
|
|
2175
2319
|
scope: params.scope,
|
|
@@ -2218,7 +2362,7 @@ var OAuthFlow = class {
|
|
|
2218
2362
|
const data = await this.http.get("/egress/oauth/status", {
|
|
2219
2363
|
state: this.state
|
|
2220
2364
|
});
|
|
2221
|
-
const payload =
|
|
2365
|
+
const payload = unwrap21(data) ?? {};
|
|
2222
2366
|
const status = payload.status;
|
|
2223
2367
|
if (status === "completed" || status === "ready" || status === "succeeded") {
|
|
2224
2368
|
return payload;
|
|
@@ -2250,7 +2394,7 @@ var EgressSecrets = class {
|
|
|
2250
2394
|
"/egress/secrets",
|
|
2251
2395
|
setBody(params)
|
|
2252
2396
|
);
|
|
2253
|
-
return
|
|
2397
|
+
return unwrap21(data);
|
|
2254
2398
|
}
|
|
2255
2399
|
/** List secrets. */
|
|
2256
2400
|
async list(params = {}) {
|
|
@@ -2265,16 +2409,16 @@ var EgressSecrets = class {
|
|
|
2265
2409
|
const data = await this.http.get(
|
|
2266
2410
|
`/egress/secrets/${id}`
|
|
2267
2411
|
);
|
|
2268
|
-
return
|
|
2412
|
+
return unwrap21(data);
|
|
2269
2413
|
}
|
|
2270
2414
|
/** Rotate the secret's value. */
|
|
2271
2415
|
async rotate(id, params) {
|
|
2272
|
-
const
|
|
2416
|
+
const body2 = typeof params === "string" ? rotateBody({ newValue: params }) : rotateBody(params);
|
|
2273
2417
|
const data = await this.http.patch(
|
|
2274
2418
|
`/egress/secrets/${id}`,
|
|
2275
|
-
|
|
2419
|
+
body2
|
|
2276
2420
|
);
|
|
2277
|
-
return
|
|
2421
|
+
return unwrap21(data);
|
|
2278
2422
|
}
|
|
2279
2423
|
/** Delete a secret. */
|
|
2280
2424
|
async delete(id) {
|
|
@@ -2287,7 +2431,7 @@ var EgressSecrets = class {
|
|
|
2287
2431
|
"/egress/bindings",
|
|
2288
2432
|
bindingBody(params)
|
|
2289
2433
|
);
|
|
2290
|
-
return
|
|
2434
|
+
return unwrap21(data);
|
|
2291
2435
|
}
|
|
2292
2436
|
/** List secret bindings. */
|
|
2293
2437
|
async listBindings(params = {}) {
|
|
@@ -2320,7 +2464,7 @@ var EgressSecrets = class {
|
|
|
2320
2464
|
"/egress/oauth/start",
|
|
2321
2465
|
oauthBody(params)
|
|
2322
2466
|
);
|
|
2323
|
-
const payload =
|
|
2467
|
+
const payload = unwrap21(data) ?? {};
|
|
2324
2468
|
return new OAuthFlow(this.http, payload, params.provider);
|
|
2325
2469
|
}
|
|
2326
2470
|
};
|
|
@@ -2884,12 +3028,12 @@ var ComputerInbox = class {
|
|
|
2884
3028
|
return unwrapData(raw);
|
|
2885
3029
|
}
|
|
2886
3030
|
async update(fields) {
|
|
2887
|
-
const
|
|
3031
|
+
const body2 = Object.fromEntries(
|
|
2888
3032
|
Object.entries(fields).filter(([, v]) => v !== void 0)
|
|
2889
3033
|
);
|
|
2890
3034
|
const raw = await this.http.patch(
|
|
2891
3035
|
`/computers/${this.computerId}/inbox`,
|
|
2892
|
-
|
|
3036
|
+
body2
|
|
2893
3037
|
);
|
|
2894
3038
|
return unwrapData(raw);
|
|
2895
3039
|
}
|
|
@@ -3188,12 +3332,12 @@ var Computer = class _Computer {
|
|
|
3188
3332
|
}
|
|
3189
3333
|
/** Clone this computer into a new one. */
|
|
3190
3334
|
async clone(opts = {}) {
|
|
3191
|
-
const
|
|
3335
|
+
const body2 = Object.fromEntries(
|
|
3192
3336
|
Object.entries(opts).filter(([, v]) => v !== void 0)
|
|
3193
3337
|
);
|
|
3194
3338
|
const raw = await this.http.post(
|
|
3195
3339
|
`/computers/${this.id}/clone`,
|
|
3196
|
-
|
|
3340
|
+
body2
|
|
3197
3341
|
);
|
|
3198
3342
|
const data = unwrapData(raw);
|
|
3199
3343
|
return new _Computer(this.http, data);
|
|
@@ -3209,12 +3353,12 @@ var Computer = class _Computer {
|
|
|
3209
3353
|
}
|
|
3210
3354
|
/** Move the computer to a different region or host. */
|
|
3211
3355
|
async move(opts) {
|
|
3212
|
-
const
|
|
3356
|
+
const body2 = Object.fromEntries(
|
|
3213
3357
|
Object.entries(opts).filter(([, v]) => v !== void 0)
|
|
3214
3358
|
);
|
|
3215
3359
|
const updated = await this.http.post(
|
|
3216
3360
|
`/computers/${this.id}/move`,
|
|
3217
|
-
|
|
3361
|
+
body2
|
|
3218
3362
|
);
|
|
3219
3363
|
this.data = updated;
|
|
3220
3364
|
return this;
|
|
@@ -3292,10 +3436,18 @@ var Computers = class {
|
|
|
3292
3436
|
* `computer.start()` once it reaches `stopped` to boot it.
|
|
3293
3437
|
*/
|
|
3294
3438
|
async create(params) {
|
|
3439
|
+
const {
|
|
3440
|
+
agentRuntimeProfileId,
|
|
3441
|
+
agentProfileId,
|
|
3442
|
+
skipAgentRuntimeProfile,
|
|
3443
|
+
...body2
|
|
3444
|
+
} = params;
|
|
3295
3445
|
const data = await this.http.post("/computers", {
|
|
3296
3446
|
template_type: "miosa-desktop",
|
|
3297
3447
|
size: "small",
|
|
3298
|
-
...
|
|
3448
|
+
...body2,
|
|
3449
|
+
agent_runtime_profile_id: agentRuntimeProfileId ?? params.agent_runtime_profile_id ?? agentProfileId ?? params.agent_profile_id,
|
|
3450
|
+
skip_agent_runtime_profile: skipAgentRuntimeProfile ?? params.skip_agent_runtime_profile
|
|
3299
3451
|
});
|
|
3300
3452
|
return new Computer(this.http, data);
|
|
3301
3453
|
}
|
|
@@ -3365,7 +3517,7 @@ var Credits = class {
|
|
|
3365
3517
|
return this.http.get("/credits/usage");
|
|
3366
3518
|
}
|
|
3367
3519
|
};
|
|
3368
|
-
function
|
|
3520
|
+
function unwrap22(payload) {
|
|
3369
3521
|
if (payload && typeof payload === "object" && "data" in payload) {
|
|
3370
3522
|
return payload.data;
|
|
3371
3523
|
}
|
|
@@ -3381,7 +3533,7 @@ function listItems2(payload, candidateKeys = ["data", "cron_jobs", "executions",
|
|
|
3381
3533
|
}
|
|
3382
3534
|
return [];
|
|
3383
3535
|
}
|
|
3384
|
-
function
|
|
3536
|
+
function stripUndefined9(input) {
|
|
3385
3537
|
return Object.fromEntries(
|
|
3386
3538
|
Object.entries(input).filter(([, v]) => v !== void 0)
|
|
3387
3539
|
);
|
|
@@ -3395,28 +3547,28 @@ var CronJobs = class {
|
|
|
3395
3547
|
}
|
|
3396
3548
|
http;
|
|
3397
3549
|
async list(params = {}) {
|
|
3398
|
-
const query =
|
|
3550
|
+
const query = stripUndefined9({ ...params });
|
|
3399
3551
|
const data = await this.http.get("/cron-jobs", query);
|
|
3400
3552
|
return listItems2(data);
|
|
3401
3553
|
}
|
|
3402
3554
|
async get(jobId) {
|
|
3403
3555
|
const data = await this.http.get(`/cron-jobs/${jobId}`);
|
|
3404
|
-
return
|
|
3556
|
+
return unwrap22(data);
|
|
3405
3557
|
}
|
|
3406
3558
|
async create(params) {
|
|
3407
3559
|
const { idempotencyKey: ikey, ...rest } = params;
|
|
3408
|
-
const
|
|
3560
|
+
const body2 = stripUndefined9(rest);
|
|
3409
3561
|
const data = await this.http.request("/cron-jobs", {
|
|
3410
3562
|
method: "POST",
|
|
3411
|
-
body,
|
|
3563
|
+
body: body2,
|
|
3412
3564
|
headers: { "Idempotency-Key": idempotencyKey2(ikey) }
|
|
3413
3565
|
});
|
|
3414
|
-
return
|
|
3566
|
+
return unwrap22(data);
|
|
3415
3567
|
}
|
|
3416
3568
|
async update(jobId, params) {
|
|
3417
|
-
const
|
|
3418
|
-
const data = await this.http.patch(`/cron-jobs/${jobId}`,
|
|
3419
|
-
return
|
|
3569
|
+
const body2 = stripUndefined9(params);
|
|
3570
|
+
const data = await this.http.patch(`/cron-jobs/${jobId}`, body2);
|
|
3571
|
+
return unwrap22(data);
|
|
3420
3572
|
}
|
|
3421
3573
|
async delete(jobId) {
|
|
3422
3574
|
await this.http.delete(`/cron-jobs/${jobId}`);
|
|
@@ -3424,11 +3576,11 @@ var CronJobs = class {
|
|
|
3424
3576
|
// ── Control ────────────────────────────────────────────────────────────────
|
|
3425
3577
|
async pause(jobId) {
|
|
3426
3578
|
const data = await this.http.post(`/cron-jobs/${jobId}/pause`);
|
|
3427
|
-
return
|
|
3579
|
+
return unwrap22(data);
|
|
3428
3580
|
}
|
|
3429
3581
|
async resume(jobId) {
|
|
3430
3582
|
const data = await this.http.post(`/cron-jobs/${jobId}/resume`);
|
|
3431
|
-
return
|
|
3583
|
+
return unwrap22(data);
|
|
3432
3584
|
}
|
|
3433
3585
|
async runNow(jobId, opts = {}) {
|
|
3434
3586
|
const data = await this.http.request(
|
|
@@ -3438,7 +3590,7 @@ var CronJobs = class {
|
|
|
3438
3590
|
headers: { "Idempotency-Key": idempotencyKey2(opts.idempotencyKey) }
|
|
3439
3591
|
}
|
|
3440
3592
|
);
|
|
3441
|
-
return
|
|
3593
|
+
return unwrap22(data);
|
|
3442
3594
|
}
|
|
3443
3595
|
// ── Execution history ──────────────────────────────────────────────────────
|
|
3444
3596
|
async listExecutions(jobId) {
|
|
@@ -3453,12 +3605,12 @@ var CronJobs = class {
|
|
|
3453
3605
|
const data = await this.http.get(
|
|
3454
3606
|
`/cron-jobs/${jobId}/executions/${executionId}`
|
|
3455
3607
|
);
|
|
3456
|
-
return
|
|
3608
|
+
return unwrap22(data);
|
|
3457
3609
|
}
|
|
3458
3610
|
};
|
|
3459
3611
|
|
|
3460
3612
|
// src/resources/dashboard.ts
|
|
3461
|
-
function
|
|
3613
|
+
function unwrap23(payload) {
|
|
3462
3614
|
if (payload && typeof payload === "object") {
|
|
3463
3615
|
const p = payload;
|
|
3464
3616
|
for (const k of ["data", "dashboard", "overview", "items"]) {
|
|
@@ -3475,15 +3627,15 @@ var Dashboard = class {
|
|
|
3475
3627
|
/** Aggregated user dashboard payload. */
|
|
3476
3628
|
async summary() {
|
|
3477
3629
|
const data = await this.http.get("/dashboard");
|
|
3478
|
-
return
|
|
3630
|
+
return unwrap23(data);
|
|
3479
3631
|
}
|
|
3480
3632
|
/** Status / health overview (public endpoint). */
|
|
3481
3633
|
async overview() {
|
|
3482
3634
|
const data = await this.http.get("/overview");
|
|
3483
|
-
return
|
|
3635
|
+
return unwrap23(data);
|
|
3484
3636
|
}
|
|
3485
3637
|
};
|
|
3486
|
-
function
|
|
3638
|
+
function unwrap24(payload) {
|
|
3487
3639
|
if (payload && typeof payload === "object" && "data" in payload) {
|
|
3488
3640
|
return payload.data;
|
|
3489
3641
|
}
|
|
@@ -3499,7 +3651,7 @@ function listItems3(payload, candidateKeys = ["data", "databases", "items"]) {
|
|
|
3499
3651
|
}
|
|
3500
3652
|
return [];
|
|
3501
3653
|
}
|
|
3502
|
-
function
|
|
3654
|
+
function stripUndefined10(input) {
|
|
3503
3655
|
return Object.fromEntries(
|
|
3504
3656
|
Object.entries(input).filter(([, v]) => v !== void 0)
|
|
3505
3657
|
);
|
|
@@ -3513,13 +3665,13 @@ var Databases = class {
|
|
|
3513
3665
|
}
|
|
3514
3666
|
http;
|
|
3515
3667
|
async list(params = {}) {
|
|
3516
|
-
const query =
|
|
3668
|
+
const query = stripUndefined10({ ...params });
|
|
3517
3669
|
const data = await this.http.get("/databases", query);
|
|
3518
3670
|
return listItems3(data);
|
|
3519
3671
|
}
|
|
3520
3672
|
async get(databaseId) {
|
|
3521
3673
|
const data = await this.http.get(`/databases/${databaseId}`);
|
|
3522
|
-
return
|
|
3674
|
+
return unwrap24(data);
|
|
3523
3675
|
}
|
|
3524
3676
|
async create(params) {
|
|
3525
3677
|
const {
|
|
@@ -3530,20 +3682,20 @@ var Databases = class {
|
|
|
3530
3682
|
size: _deprecatedSize,
|
|
3531
3683
|
...rest
|
|
3532
3684
|
} = params;
|
|
3533
|
-
const
|
|
3685
|
+
const body2 = stripUndefined10({
|
|
3534
3686
|
...rest,
|
|
3535
3687
|
engine_version: engine_version ?? version
|
|
3536
3688
|
});
|
|
3537
3689
|
const data = await this.http.request("/databases", {
|
|
3538
3690
|
method: "POST",
|
|
3539
|
-
body,
|
|
3691
|
+
body: body2,
|
|
3540
3692
|
headers: {
|
|
3541
3693
|
"Idempotency-Key": idempotencyKey3(
|
|
3542
3694
|
camelIdempotencyKey ?? snakeIdempotencyKey
|
|
3543
3695
|
)
|
|
3544
3696
|
}
|
|
3545
3697
|
});
|
|
3546
|
-
return
|
|
3698
|
+
return unwrap24(data);
|
|
3547
3699
|
}
|
|
3548
3700
|
async delete(databaseId) {
|
|
3549
3701
|
await this.http.delete(`/databases/${databaseId}`);
|
|
@@ -3553,27 +3705,27 @@ var Databases = class {
|
|
|
3553
3705
|
const data = await this.http.post(
|
|
3554
3706
|
`/databases/${databaseId}/start`
|
|
3555
3707
|
);
|
|
3556
|
-
return
|
|
3708
|
+
return unwrap24(data);
|
|
3557
3709
|
}
|
|
3558
3710
|
async stop(databaseId) {
|
|
3559
3711
|
const data = await this.http.post(`/databases/${databaseId}/stop`);
|
|
3560
|
-
return
|
|
3712
|
+
return unwrap24(data);
|
|
3561
3713
|
}
|
|
3562
3714
|
async restart(databaseId) {
|
|
3563
3715
|
const data = await this.http.post(
|
|
3564
3716
|
`/databases/${databaseId}/restart`
|
|
3565
3717
|
);
|
|
3566
|
-
return
|
|
3718
|
+
return unwrap24(data);
|
|
3567
3719
|
}
|
|
3568
3720
|
// ── Credentials + logs ────────────────────────────────────────────────────
|
|
3569
3721
|
async credentials(databaseId) {
|
|
3570
3722
|
const data = await this.http.get(
|
|
3571
3723
|
`/databases/${databaseId}/credentials`
|
|
3572
3724
|
);
|
|
3573
|
-
return
|
|
3725
|
+
return unwrap24(data);
|
|
3574
3726
|
}
|
|
3575
3727
|
async logs(databaseId, params = {}) {
|
|
3576
|
-
const query =
|
|
3728
|
+
const query = stripUndefined10({
|
|
3577
3729
|
lines: params.lines,
|
|
3578
3730
|
since: params.since
|
|
3579
3731
|
});
|
|
@@ -3600,7 +3752,7 @@ function attributionBody(p) {
|
|
|
3600
3752
|
function idempotencyKey4(key) {
|
|
3601
3753
|
return key ?? randomUUID();
|
|
3602
3754
|
}
|
|
3603
|
-
function
|
|
3755
|
+
function unwrap25(payload) {
|
|
3604
3756
|
if (payload && typeof payload === "object" && "data" in payload) {
|
|
3605
3757
|
return payload.data;
|
|
3606
3758
|
}
|
|
@@ -3616,46 +3768,52 @@ function listItems4(payload, candidateKeys = ["items", "deployments", "versions"
|
|
|
3616
3768
|
}
|
|
3617
3769
|
return [];
|
|
3618
3770
|
}
|
|
3619
|
-
function
|
|
3771
|
+
function stripUndefined11(input) {
|
|
3620
3772
|
return Object.fromEntries(
|
|
3621
3773
|
Object.entries(input).filter(([, v]) => v !== void 0)
|
|
3622
3774
|
);
|
|
3623
3775
|
}
|
|
3624
|
-
function dockerDeployMetadata(metadata
|
|
3625
|
-
return
|
|
3776
|
+
function dockerDeployMetadata(metadata) {
|
|
3777
|
+
return {
|
|
3626
3778
|
...metadata ?? {},
|
|
3627
|
-
deployment_product: "docker_deploy"
|
|
3628
|
-
|
|
3629
|
-
});
|
|
3630
|
-
}
|
|
3631
|
-
function isRecord(value) {
|
|
3632
|
-
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
3779
|
+
deployment_product: "docker_deploy"
|
|
3780
|
+
};
|
|
3633
3781
|
}
|
|
3634
|
-
function
|
|
3635
|
-
return
|
|
3782
|
+
function dockerDeployProduct(deployment) {
|
|
3783
|
+
return deployment.deployment_product ?? deployment.metadata?.deployment_product;
|
|
3636
3784
|
}
|
|
3637
|
-
function
|
|
3638
|
-
const
|
|
3639
|
-
return
|
|
3785
|
+
function dockerDeployHostId(deployment) {
|
|
3786
|
+
const metadataHost = deployment.metadata?.docker_deploy_host_id;
|
|
3787
|
+
return deployment.docker_deploy_host_id ?? (typeof metadataHost === "string" ? metadataHost : null);
|
|
3640
3788
|
}
|
|
3641
|
-
function
|
|
3642
|
-
const
|
|
3643
|
-
|
|
3644
|
-
|
|
3645
|
-
return url.toString();
|
|
3789
|
+
function dockerDeployApp(deployment) {
|
|
3790
|
+
const app = deployment.metadata?.docker_deploy;
|
|
3791
|
+
if (!app || typeof app !== "object" || Array.isArray(app)) return null;
|
|
3792
|
+
return app;
|
|
3646
3793
|
}
|
|
3647
|
-
function
|
|
3794
|
+
function dockerDeployAppPort(app) {
|
|
3795
|
+
const url = app?.url;
|
|
3796
|
+
if (typeof url !== "string") return null;
|
|
3648
3797
|
try {
|
|
3649
|
-
const parsed =
|
|
3650
|
-
|
|
3798
|
+
const parsed = new URL(url);
|
|
3799
|
+
const port = Number.parseInt(parsed.port, 10);
|
|
3800
|
+
return Number.isInteger(port) ? port : null;
|
|
3651
3801
|
} catch {
|
|
3652
|
-
return
|
|
3802
|
+
return null;
|
|
3653
3803
|
}
|
|
3654
3804
|
}
|
|
3655
|
-
function addDoctorCheck(checks, name, ok, message,
|
|
3656
|
-
|
|
3657
|
-
|
|
3658
|
-
|
|
3805
|
+
function addDoctorCheck(checks, name, ok, message, details) {
|
|
3806
|
+
checks.push({ name, ok, message, ...details ? { details } : {} });
|
|
3807
|
+
}
|
|
3808
|
+
function hostHealthy(host) {
|
|
3809
|
+
return Boolean(
|
|
3810
|
+
host && host.status === "active" && host.appliance_status === "healthy"
|
|
3811
|
+
);
|
|
3812
|
+
}
|
|
3813
|
+
function probeUrl(publicUrl, probePath) {
|
|
3814
|
+
const url = new URL(publicUrl);
|
|
3815
|
+
url.pathname = probePath.startsWith("/") ? probePath : `/${probePath}`;
|
|
3816
|
+
return url.toString();
|
|
3659
3817
|
}
|
|
3660
3818
|
var DeploymentVersions = class {
|
|
3661
3819
|
constructor(http, deploymentId) {
|
|
@@ -3665,7 +3823,7 @@ var DeploymentVersions = class {
|
|
|
3665
3823
|
http;
|
|
3666
3824
|
deploymentId;
|
|
3667
3825
|
async list(params = {}) {
|
|
3668
|
-
const query =
|
|
3826
|
+
const query = stripUndefined11({
|
|
3669
3827
|
state: params.state,
|
|
3670
3828
|
limit: params.limit,
|
|
3671
3829
|
cursor: params.cursor,
|
|
@@ -3681,19 +3839,19 @@ var DeploymentVersions = class {
|
|
|
3681
3839
|
const data = await this.http.get(
|
|
3682
3840
|
`/deployments/${this.deploymentId}/versions/${versionId}`
|
|
3683
3841
|
);
|
|
3684
|
-
return
|
|
3842
|
+
return unwrap25(data);
|
|
3685
3843
|
}
|
|
3686
3844
|
async promote(versionId, opts = {}) {
|
|
3687
|
-
const
|
|
3845
|
+
const body2 = stripUndefined11({ environment: opts.environment });
|
|
3688
3846
|
const data = await this.http.request(
|
|
3689
3847
|
`/deployments/${this.deploymentId}/versions/${versionId}/promote`,
|
|
3690
3848
|
{
|
|
3691
3849
|
method: "POST",
|
|
3692
|
-
body,
|
|
3850
|
+
body: body2,
|
|
3693
3851
|
headers: { "Idempotency-Key": idempotencyKey4(opts.idempotencyKey) }
|
|
3694
3852
|
}
|
|
3695
3853
|
);
|
|
3696
|
-
return
|
|
3854
|
+
return unwrap25(data);
|
|
3697
3855
|
}
|
|
3698
3856
|
};
|
|
3699
3857
|
var DeploymentReleases = class {
|
|
@@ -3713,7 +3871,7 @@ var DeploymentReleases = class {
|
|
|
3713
3871
|
const data = await this.http.get(
|
|
3714
3872
|
`/deployments/${this.deploymentId}/releases/${releaseId}`
|
|
3715
3873
|
);
|
|
3716
|
-
return
|
|
3874
|
+
return unwrap25(data);
|
|
3717
3875
|
}
|
|
3718
3876
|
};
|
|
3719
3877
|
var DeploymentRuntimeInstances = class {
|
|
@@ -3733,14 +3891,14 @@ var DeploymentRuntimeInstances = class {
|
|
|
3733
3891
|
const data = await this.http.get(
|
|
3734
3892
|
`/deployments/${this.deploymentId}/runtime-instances/${instanceId}`
|
|
3735
3893
|
);
|
|
3736
|
-
return
|
|
3894
|
+
return unwrap25(data);
|
|
3737
3895
|
}
|
|
3738
3896
|
async logs(instanceId, lines = 100) {
|
|
3739
3897
|
const data = await this.http.get(
|
|
3740
3898
|
`/deployments/${this.deploymentId}/runtime-instances/${instanceId}/logs`,
|
|
3741
3899
|
{ lines }
|
|
3742
3900
|
);
|
|
3743
|
-
const unwrapped =
|
|
3901
|
+
const unwrapped = unwrap25(data);
|
|
3744
3902
|
const result = { logs: String(unwrapped.logs ?? "") };
|
|
3745
3903
|
if (typeof unwrapped.runtime_instance_id === "string") {
|
|
3746
3904
|
result.runtime_instance_id = unwrapped.runtime_instance_id;
|
|
@@ -3762,7 +3920,7 @@ var DeploymentDomains = class {
|
|
|
3762
3920
|
http;
|
|
3763
3921
|
deploymentId;
|
|
3764
3922
|
async add(domain, params = {}) {
|
|
3765
|
-
const
|
|
3923
|
+
const body2 = {
|
|
3766
3924
|
domain,
|
|
3767
3925
|
redirect_policy: params.redirectPolicy ?? params.redirect_policy,
|
|
3768
3926
|
...attributionBody(params)
|
|
@@ -3771,11 +3929,11 @@ var DeploymentDomains = class {
|
|
|
3771
3929
|
`/deployments/${this.deploymentId}/domains`,
|
|
3772
3930
|
{
|
|
3773
3931
|
method: "POST",
|
|
3774
|
-
body:
|
|
3932
|
+
body: stripUndefined11(body2),
|
|
3775
3933
|
headers: { "Idempotency-Key": idempotencyKey4(params.idempotencyKey) }
|
|
3776
3934
|
}
|
|
3777
3935
|
);
|
|
3778
|
-
return
|
|
3936
|
+
return unwrap25(data);
|
|
3779
3937
|
}
|
|
3780
3938
|
async list(filters = {}) {
|
|
3781
3939
|
const data = await this.http.get(
|
|
@@ -3788,7 +3946,7 @@ var DeploymentDomains = class {
|
|
|
3788
3946
|
const data = await this.http.post(
|
|
3789
3947
|
`/deployments/${this.deploymentId}/domains/${domainId}/verify`
|
|
3790
3948
|
);
|
|
3791
|
-
return
|
|
3949
|
+
return unwrap25(data);
|
|
3792
3950
|
}
|
|
3793
3951
|
async delete(domainId) {
|
|
3794
3952
|
await this.http.delete(
|
|
@@ -3803,7 +3961,7 @@ var Deployments = class {
|
|
|
3803
3961
|
http;
|
|
3804
3962
|
async list(params = {}) {
|
|
3805
3963
|
const projectId = params.projectId ?? params.project_id;
|
|
3806
|
-
const query =
|
|
3964
|
+
const query = stripUndefined11({
|
|
3807
3965
|
project_id: projectId,
|
|
3808
3966
|
state: params.state,
|
|
3809
3967
|
limit: params.limit,
|
|
@@ -3818,10 +3976,10 @@ var Deployments = class {
|
|
|
3818
3976
|
}
|
|
3819
3977
|
async get(deploymentId) {
|
|
3820
3978
|
const data = await this.http.get(`/deployments/${deploymentId}`);
|
|
3821
|
-
return
|
|
3979
|
+
return unwrap25(data);
|
|
3822
3980
|
}
|
|
3823
3981
|
async create(params) {
|
|
3824
|
-
const
|
|
3982
|
+
const body2 = stripUndefined11({
|
|
3825
3983
|
name: params.name,
|
|
3826
3984
|
repo_url: params.repoUrl ?? params.repo_url,
|
|
3827
3985
|
branch: params.branch,
|
|
@@ -3829,16 +3987,15 @@ var Deployments = class {
|
|
|
3829
3987
|
run_command: params.runCommand ?? params.run_command,
|
|
3830
3988
|
auto_deploy: params.autoDeploy ?? params.auto_deploy,
|
|
3831
3989
|
database: params.database,
|
|
3832
|
-
docker_deploy_template_id: params.dockerDeployTemplateId ?? params.docker_deploy_template_id,
|
|
3833
3990
|
metadata: params.metadata,
|
|
3834
3991
|
...attributionBody(params)
|
|
3835
3992
|
});
|
|
3836
3993
|
const data = await this.http.request("/deployments", {
|
|
3837
3994
|
method: "POST",
|
|
3838
|
-
body,
|
|
3995
|
+
body: body2,
|
|
3839
3996
|
headers: { "Idempotency-Key": idempotencyKey4(params.idempotencyKey) }
|
|
3840
3997
|
});
|
|
3841
|
-
return
|
|
3998
|
+
return unwrap25(data);
|
|
3842
3999
|
}
|
|
3843
4000
|
/**
|
|
3844
4001
|
* Create a deployment that runs on the workspace's dedicated Docker Deploy
|
|
@@ -3846,184 +4003,146 @@ var Deployments = class {
|
|
|
3846
4003
|
* deployment so the control plane attaches it to the workspace Docker host.
|
|
3847
4004
|
*/
|
|
3848
4005
|
async createDockerDeploy(params) {
|
|
3849
|
-
const templateId = params.dockerDeployTemplateId ?? params.docker_deploy_template_id;
|
|
3850
4006
|
return this.create({
|
|
3851
4007
|
...params,
|
|
3852
|
-
metadata: dockerDeployMetadata(params.metadata
|
|
3853
|
-
});
|
|
3854
|
-
}
|
|
3855
|
-
async listDockerDeployHosts(params = {}) {
|
|
3856
|
-
const data = await this.http.get(
|
|
3857
|
-
"/docker-deploy/hosts",
|
|
3858
|
-
stripUndefined10({
|
|
3859
|
-
workspace_id: params.workspaceId ?? params.workspace_id
|
|
3860
|
-
})
|
|
3861
|
-
);
|
|
3862
|
-
return listItems4(data, ["hosts", "items"]);
|
|
3863
|
-
}
|
|
3864
|
-
async ensureDockerDeployHost(params) {
|
|
3865
|
-
const data = await this.http.request("/docker-deploy/hosts/ensure", {
|
|
3866
|
-
method: "POST",
|
|
3867
|
-
body: stripUndefined10({
|
|
3868
|
-
workspace_id: params.workspaceId ?? params.workspace_id,
|
|
3869
|
-
region: params.region,
|
|
3870
|
-
size: params.size,
|
|
3871
|
-
appliance_image: params.applianceImage ?? params.appliance_image,
|
|
3872
|
-
metadata: params.metadata
|
|
3873
|
-
}),
|
|
3874
|
-
headers: { "Idempotency-Key": idempotencyKey4(params.idempotencyKey) }
|
|
4008
|
+
metadata: dockerDeployMetadata(params.metadata)
|
|
3875
4009
|
});
|
|
3876
|
-
return unwrap23(data);
|
|
3877
|
-
}
|
|
3878
|
-
async getDockerDeployHost(hostId) {
|
|
3879
|
-
const data = await this.http.get(`/docker-deploy/hosts/${hostId}`);
|
|
3880
|
-
return unwrap23(data);
|
|
3881
4010
|
}
|
|
3882
4011
|
/**
|
|
3883
|
-
* Verify a Docker Deploy deployment
|
|
3884
|
-
*
|
|
3885
|
-
*
|
|
3886
|
-
* appliance health, route runtime metadata, and optionally the public URL.
|
|
3887
|
-
* It is intentionally agent-friendly: use this after sandbox.deployDocker()
|
|
3888
|
-
* or createDockerDeploy() before telling a user the app is live.
|
|
4012
|
+
* Verify a Docker Deploy deployment before telling a user or agent it is
|
|
4013
|
+
* live. Checks product markers, appliance host health, route metadata, and
|
|
4014
|
+
* optionally probes the public URL.
|
|
3889
4015
|
*/
|
|
3890
4016
|
async doctorDockerDeploy(deploymentId, params = {}) {
|
|
3891
4017
|
const checks = [];
|
|
3892
4018
|
const deployment = await this.get(deploymentId);
|
|
3893
|
-
const metadata =
|
|
3894
|
-
const product =
|
|
3895
|
-
const hostId =
|
|
4019
|
+
const metadata = deployment.metadata ?? {};
|
|
4020
|
+
const product = dockerDeployProduct(deployment);
|
|
4021
|
+
const hostId = dockerDeployHostId(deployment);
|
|
3896
4022
|
addDoctorCheck(
|
|
3897
4023
|
checks,
|
|
3898
4024
|
"deployment_product",
|
|
3899
4025
|
product === "docker_deploy",
|
|
3900
|
-
product === "docker_deploy" ? "Deployment is marked
|
|
3901
|
-
{
|
|
4026
|
+
product === "docker_deploy" ? "Deployment is marked for Docker Deploy." : `Expected deployment_product=docker_deploy, got ${String(product ?? "missing")}.`,
|
|
4027
|
+
{ deployment_product: product ?? null }
|
|
3902
4028
|
);
|
|
3903
4029
|
addDoctorCheck(
|
|
3904
4030
|
checks,
|
|
3905
4031
|
"docker_deploy_host_id",
|
|
3906
|
-
|
|
3907
|
-
hostId ? "Deployment
|
|
3908
|
-
{ docker_deploy_host_id: hostId
|
|
4032
|
+
Boolean(hostId),
|
|
4033
|
+
hostId ? "Deployment has a Docker Deploy host id." : "Deployment has no docker_deploy_host_id.",
|
|
4034
|
+
{ docker_deploy_host_id: hostId }
|
|
3909
4035
|
);
|
|
3910
4036
|
let host;
|
|
3911
4037
|
if (hostId) {
|
|
3912
4038
|
try {
|
|
3913
|
-
|
|
3914
|
-
|
|
3915
|
-
|
|
3916
|
-
|
|
3917
|
-
|
|
3918
|
-
|
|
4039
|
+
const rawHost = await this.http.get(
|
|
4040
|
+
`/docker-deploy/hosts/${hostId}`
|
|
4041
|
+
);
|
|
4042
|
+
host = unwrap25(
|
|
4043
|
+
rawHost
|
|
4044
|
+
);
|
|
3919
4045
|
addDoctorCheck(
|
|
3920
4046
|
checks,
|
|
3921
4047
|
"docker_deploy_host_health",
|
|
3922
|
-
|
|
3923
|
-
|
|
3924
|
-
{
|
|
4048
|
+
hostHealthy(host),
|
|
4049
|
+
hostHealthy(host) ? "Docker Deploy host is active and healthy." : `Docker Deploy host status=${host.status} appliance=${host.appliance_status}.`,
|
|
4050
|
+
{
|
|
4051
|
+
status: host.status,
|
|
4052
|
+
appliance_status: host.appliance_status
|
|
4053
|
+
}
|
|
3925
4054
|
);
|
|
3926
|
-
} catch (
|
|
4055
|
+
} catch (error) {
|
|
3927
4056
|
addDoctorCheck(
|
|
3928
4057
|
checks,
|
|
3929
4058
|
"docker_deploy_host_health",
|
|
3930
4059
|
false,
|
|
3931
|
-
|
|
4060
|
+
error instanceof Error ? error.message : String(error)
|
|
3932
4061
|
);
|
|
3933
4062
|
}
|
|
3934
4063
|
}
|
|
3935
|
-
const
|
|
3936
|
-
const
|
|
3937
|
-
const
|
|
4064
|
+
const app = dockerDeployApp(deployment);
|
|
4065
|
+
const appPort = dockerDeployAppPort(app);
|
|
4066
|
+
const appRunning = app?.status === "running" && appPort !== null;
|
|
3938
4067
|
addDoctorCheck(
|
|
3939
4068
|
checks,
|
|
3940
|
-
"
|
|
3941
|
-
|
|
3942
|
-
|
|
3943
|
-
|
|
3944
|
-
|
|
3945
|
-
|
|
4069
|
+
"docker_deploy_app",
|
|
4070
|
+
appRunning,
|
|
4071
|
+
appRunning ? "Docker Deploy app metadata points at a running container." : "Deployment is missing running Docker Deploy app metadata.",
|
|
4072
|
+
app ? {
|
|
4073
|
+
app_id: app.app_id,
|
|
4074
|
+
container_id: app.container_id,
|
|
4075
|
+
status: app.status,
|
|
4076
|
+
url: app.url,
|
|
4077
|
+
expected_port: appPort
|
|
4078
|
+
} : void 0
|
|
4079
|
+
);
|
|
4080
|
+
const runtime = metadata.runtime;
|
|
4081
|
+
const runtimeCandidate = typeof runtime === "object" && runtime !== null ? runtime : void 0;
|
|
4082
|
+
const hasRuntimeRoute = typeof runtimeCandidate?.ip === "string" && typeof runtimeCandidate.port === "number";
|
|
4083
|
+
const runtimeRecord = hasRuntimeRoute ? runtimeCandidate : void 0;
|
|
4084
|
+
const routeMatchesContainerPort = hasRuntimeRoute && (appPort === null || runtimeRecord?.port === appPort);
|
|
3946
4085
|
addDoctorCheck(
|
|
3947
4086
|
checks,
|
|
3948
|
-
"
|
|
3949
|
-
|
|
3950
|
-
|
|
3951
|
-
|
|
4087
|
+
"runtime_route",
|
|
4088
|
+
hasRuntimeRoute && routeMatchesContainerPort,
|
|
4089
|
+
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.",
|
|
4090
|
+
runtimeRecord ? {
|
|
4091
|
+
...runtimeRecord,
|
|
4092
|
+
expected_port: appPort,
|
|
4093
|
+
docker_deploy_url: app?.url
|
|
4094
|
+
} : void 0
|
|
3952
4095
|
);
|
|
3953
4096
|
let probe;
|
|
3954
|
-
|
|
3955
|
-
|
|
3956
|
-
|
|
4097
|
+
const publicUrl = deployment.public_url;
|
|
4098
|
+
const path = params.probePath ?? params.probe_path ?? "/";
|
|
4099
|
+
if (publicUrl && typeof fetch === "function") {
|
|
4100
|
+
const url = probeUrl(publicUrl, path);
|
|
3957
4101
|
const controller = new AbortController();
|
|
3958
|
-
const
|
|
4102
|
+
const timeout = setTimeout(
|
|
4103
|
+
() => controller.abort(),
|
|
4104
|
+
params.timeoutMs ?? params.timeout_ms ?? 1e4
|
|
4105
|
+
);
|
|
3959
4106
|
try {
|
|
3960
|
-
const response = await
|
|
3961
|
-
|
|
4107
|
+
const response = await fetch(url, {
|
|
4108
|
+
method: "GET",
|
|
3962
4109
|
signal: controller.signal
|
|
3963
4110
|
});
|
|
3964
|
-
|
|
3965
|
-
const gatewayJson = looksLikeMiosaGatewayJson(text);
|
|
3966
|
-
const ok = response.ok && !gatewayJson;
|
|
3967
|
-
probe = {
|
|
3968
|
-
url,
|
|
3969
|
-
status: response.status,
|
|
3970
|
-
ok,
|
|
3971
|
-
responseSnippet: text.slice(0, 500)
|
|
3972
|
-
};
|
|
3973
|
-
if (gatewayJson) probe.gatewayJson = true;
|
|
4111
|
+
probe = { url, ok: response.ok, status: response.status };
|
|
3974
4112
|
addDoctorCheck(
|
|
3975
4113
|
checks,
|
|
3976
4114
|
"public_url_probe",
|
|
3977
|
-
ok,
|
|
3978
|
-
|
|
3979
|
-
{ status: response.status
|
|
4115
|
+
response.ok,
|
|
4116
|
+
`Public URL returned HTTP ${response.status}.`,
|
|
4117
|
+
{ url, status: response.status }
|
|
3980
4118
|
);
|
|
3981
|
-
} catch (
|
|
3982
|
-
|
|
3983
|
-
|
|
4119
|
+
} catch (error) {
|
|
4120
|
+
probe = {
|
|
4121
|
+
url,
|
|
4122
|
+
ok: false,
|
|
4123
|
+
error: error instanceof Error ? error.message : String(error)
|
|
4124
|
+
};
|
|
3984
4125
|
addDoctorCheck(
|
|
3985
4126
|
checks,
|
|
3986
4127
|
"public_url_probe",
|
|
3987
4128
|
false,
|
|
3988
|
-
|
|
4129
|
+
probe.error ?? "Public URL probe failed.",
|
|
4130
|
+
{ url }
|
|
3989
4131
|
);
|
|
3990
4132
|
} finally {
|
|
3991
|
-
clearTimeout(
|
|
4133
|
+
clearTimeout(timeout);
|
|
3992
4134
|
}
|
|
3993
4135
|
}
|
|
3994
|
-
|
|
4136
|
+
return {
|
|
3995
4137
|
ok: checks.every((check) => check.ok),
|
|
3996
4138
|
deployment,
|
|
3997
|
-
|
|
4139
|
+
...host ? { host } : {},
|
|
4140
|
+
checks,
|
|
4141
|
+
...probe ? { probe } : {}
|
|
3998
4142
|
};
|
|
3999
|
-
if (host) result.host = host;
|
|
4000
|
-
if (publicUrl !== void 0) result.publicUrl = publicUrl;
|
|
4001
|
-
if (probe) result.probe = probe;
|
|
4002
|
-
return result;
|
|
4003
|
-
}
|
|
4004
|
-
async listDockerDeployTemplates(params = {}) {
|
|
4005
|
-
const query = {
|
|
4006
|
-
category: params.category,
|
|
4007
|
-
runtime: params.runtime,
|
|
4008
|
-
framework: params.framework,
|
|
4009
|
-
include_preview: params.includePreview ?? params.include_preview
|
|
4010
|
-
};
|
|
4011
|
-
const data = await this.http.get(
|
|
4012
|
-
"/docker-deploy/templates",
|
|
4013
|
-
stripUndefined10(query)
|
|
4014
|
-
);
|
|
4015
|
-
const templates = unwrap23(data);
|
|
4016
|
-
if (Array.isArray(templates)) return templates;
|
|
4017
|
-
return (templates?.templates ?? templates?.items ?? templates?.data ?? []) || [];
|
|
4018
|
-
}
|
|
4019
|
-
async getDockerDeployTemplate(templateId) {
|
|
4020
|
-
const data = await this.http.get(
|
|
4021
|
-
`/docker-deploy/templates/${templateId}`
|
|
4022
|
-
);
|
|
4023
|
-
return unwrap23(data);
|
|
4024
4143
|
}
|
|
4025
4144
|
async update(deploymentId, params) {
|
|
4026
|
-
const
|
|
4145
|
+
const body2 = stripUndefined11({
|
|
4027
4146
|
name: params.name,
|
|
4028
4147
|
branch: params.branch,
|
|
4029
4148
|
build_command: params.buildCommand ?? params.build_command,
|
|
@@ -4032,37 +4151,29 @@ var Deployments = class {
|
|
|
4032
4151
|
});
|
|
4033
4152
|
const data = await this.http.patch(
|
|
4034
4153
|
`/deployments/${deploymentId}`,
|
|
4035
|
-
|
|
4154
|
+
body2
|
|
4036
4155
|
);
|
|
4037
|
-
return
|
|
4156
|
+
return unwrap25(data);
|
|
4038
4157
|
}
|
|
4039
4158
|
async delete(deploymentId) {
|
|
4040
4159
|
await this.http.delete(`/deployments/${deploymentId}`);
|
|
4041
4160
|
}
|
|
4042
4161
|
async publish(deploymentId, params) {
|
|
4043
|
-
const
|
|
4162
|
+
const body2 = stripUndefined11({
|
|
4044
4163
|
source_sandbox_id: params.sourceSandboxId ?? params.source_sandbox_id,
|
|
4045
4164
|
output_path: params.outputPath ?? params.output_path,
|
|
4046
4165
|
entrypoint: params.entrypoint,
|
|
4047
|
-
promote: params.promote
|
|
4048
|
-
build_command: params.buildCommand ?? params.build_command,
|
|
4049
|
-
run_command: params.runCommand ?? params.run_command,
|
|
4050
|
-
port: params.port,
|
|
4051
|
-
health_check_path: params.healthCheckPath ?? params.health_check_path,
|
|
4052
|
-
deployment_type: params.deploymentType ?? params.deployment_type,
|
|
4053
|
-
docker_deploy_template_id: params.dockerDeployTemplateId ?? params.docker_deploy_template_id,
|
|
4054
|
-
data_services: params.dataServices ?? params.data_services,
|
|
4055
|
-
...attributionBody(params)
|
|
4166
|
+
promote: params.promote
|
|
4056
4167
|
});
|
|
4057
4168
|
const data = await this.http.request(
|
|
4058
4169
|
`/deployments/${deploymentId}/publish`,
|
|
4059
4170
|
{
|
|
4060
4171
|
method: "POST",
|
|
4061
|
-
body,
|
|
4172
|
+
body: body2,
|
|
4062
4173
|
headers: { "Idempotency-Key": idempotencyKey4(params.idempotencyKey) }
|
|
4063
4174
|
}
|
|
4064
4175
|
);
|
|
4065
|
-
return
|
|
4176
|
+
return unwrap25(data);
|
|
4066
4177
|
}
|
|
4067
4178
|
/**
|
|
4068
4179
|
* Backward-compatible bridge: POST /sandboxes/:id/deploy. Works today;
|
|
@@ -4070,46 +4181,38 @@ var Deployments = class {
|
|
|
4070
4181
|
* phase. Prefer `publish()` once Phase 2B/3 lands.
|
|
4071
4182
|
*/
|
|
4072
4183
|
async publishFromSandbox(sandboxId, params = {}) {
|
|
4073
|
-
const
|
|
4184
|
+
const body2 = stripUndefined11({
|
|
4074
4185
|
name: params.name,
|
|
4075
4186
|
deployment_id: params.deploymentId ?? params.deployment_id,
|
|
4076
4187
|
output_path: params.outputPath ?? params.output_path,
|
|
4077
4188
|
source_snapshot_path: params.sourceSnapshotPath ?? params.source_snapshot_path,
|
|
4078
4189
|
entrypoint: params.entrypoint,
|
|
4079
4190
|
domain: params.domain,
|
|
4080
|
-
custom_domain: params.customDomain ?? params.custom_domain
|
|
4081
|
-
build_command: params.buildCommand ?? params.build_command,
|
|
4082
|
-
run_command: params.runCommand ?? params.run_command,
|
|
4083
|
-
port: params.port,
|
|
4084
|
-
health_check_path: params.healthCheckPath ?? params.health_check_path,
|
|
4085
|
-
deployment_type: params.deploymentType ?? params.deployment_type,
|
|
4086
|
-
docker_deploy_template_id: params.dockerDeployTemplateId ?? params.docker_deploy_template_id,
|
|
4087
|
-
data_services: params.dataServices ?? params.data_services,
|
|
4088
|
-
...attributionBody(params)
|
|
4191
|
+
custom_domain: params.customDomain ?? params.custom_domain
|
|
4089
4192
|
});
|
|
4090
4193
|
const data = await this.http.request(
|
|
4091
4194
|
`/sandboxes/${sandboxId}/deploy`,
|
|
4092
4195
|
{
|
|
4093
4196
|
method: "POST",
|
|
4094
|
-
body,
|
|
4197
|
+
body: body2,
|
|
4095
4198
|
headers: { "Idempotency-Key": idempotencyKey4(params.idempotencyKey) }
|
|
4096
4199
|
}
|
|
4097
4200
|
);
|
|
4098
|
-
return
|
|
4201
|
+
return unwrap25(data);
|
|
4099
4202
|
}
|
|
4100
4203
|
async rollback(deploymentId, params = {}) {
|
|
4101
|
-
const
|
|
4204
|
+
const body2 = stripUndefined11({
|
|
4102
4205
|
version_id: params.versionId ?? params.version_id
|
|
4103
4206
|
});
|
|
4104
4207
|
const data = await this.http.request(
|
|
4105
4208
|
`/deployments/${deploymentId}/rollback`,
|
|
4106
4209
|
{
|
|
4107
4210
|
method: "POST",
|
|
4108
|
-
body,
|
|
4211
|
+
body: body2,
|
|
4109
4212
|
headers: { "Idempotency-Key": idempotencyKey4(params.idempotencyKey) }
|
|
4110
4213
|
}
|
|
4111
4214
|
);
|
|
4112
|
-
return
|
|
4215
|
+
return unwrap25(data);
|
|
4113
4216
|
}
|
|
4114
4217
|
async listBuilds(deploymentId) {
|
|
4115
4218
|
const data = await this.http.get(
|
|
@@ -4121,7 +4224,7 @@ var Deployments = class {
|
|
|
4121
4224
|
const data = await this.http.get(
|
|
4122
4225
|
`/deployments/${deploymentId}/builds/${buildId}`
|
|
4123
4226
|
);
|
|
4124
|
-
return
|
|
4227
|
+
return unwrap25(data);
|
|
4125
4228
|
}
|
|
4126
4229
|
async listEnv(deploymentId) {
|
|
4127
4230
|
const data = await this.http.get(
|
|
@@ -4130,10 +4233,10 @@ var Deployments = class {
|
|
|
4130
4233
|
return listItems4(data);
|
|
4131
4234
|
}
|
|
4132
4235
|
async setEnv(deploymentId, vars, opts = {}) {
|
|
4133
|
-
const
|
|
4236
|
+
const body2 = stripUndefined11({ env: vars, environment: opts.environment });
|
|
4134
4237
|
const data = await this.http.post(
|
|
4135
4238
|
`/deployments/${deploymentId}/env`,
|
|
4136
|
-
|
|
4239
|
+
body2
|
|
4137
4240
|
);
|
|
4138
4241
|
return listItems4(data);
|
|
4139
4242
|
}
|
|
@@ -4154,208 +4257,92 @@ var Deployments = class {
|
|
|
4154
4257
|
}
|
|
4155
4258
|
};
|
|
4156
4259
|
|
|
4157
|
-
// src/resources/
|
|
4158
|
-
|
|
4159
|
-
|
|
4160
|
-
|
|
4161
|
-
|
|
4162
|
-
|
|
4163
|
-
|
|
4164
|
-
|
|
4165
|
-
|
|
4166
|
-
|
|
4167
|
-
|
|
4168
|
-
|
|
4169
|
-
|
|
4170
|
-
|
|
4171
|
-
|
|
4172
|
-
|
|
4173
|
-
|
|
4174
|
-
|
|
4175
|
-
|
|
4176
|
-
|
|
4177
|
-
|
|
4178
|
-
|
|
4179
|
-
|
|
4180
|
-
|
|
4181
|
-
{
|
|
4182
|
-
|
|
4183
|
-
|
|
4184
|
-
|
|
4185
|
-
|
|
4186
|
-
|
|
4187
|
-
primaryCommands: [
|
|
4188
|
-
"miosa.computers.create({ name: 'browser-agent' })",
|
|
4189
|
-
"computer.exec.run('npm test')",
|
|
4190
|
-
"computer.desktop.open()"
|
|
4191
|
-
],
|
|
4192
|
-
useWhen: [
|
|
4193
|
-
"The agent needs Chromium or a full desktop.",
|
|
4194
|
-
"The workflow logs into dashboards, fills forms, clicks buttons, or captures screenshots.",
|
|
4195
|
-
"A human and agent share the same persistent machine state."
|
|
4196
|
-
],
|
|
4197
|
-
avoidWhen: [
|
|
4198
|
-
"Simple code generation/build/test work fits a cheaper sandbox worker.",
|
|
4199
|
-
"You only need durable app hosting."
|
|
4200
|
-
]
|
|
4201
|
-
},
|
|
4202
|
-
{
|
|
4203
|
-
kind: "local_device",
|
|
4204
|
-
label: "Local Device",
|
|
4205
|
-
purpose: "Developer-owned machine connected through CLI/MCP for local discovery and private tooling.",
|
|
4206
|
-
lifecycle: "Not hosted by MIOSA; the user owns uptime and state.",
|
|
4207
|
-
persistence: "State is local machine state. Do not assume cloud resume semantics.",
|
|
4208
|
-
primaryCommands: ["miosa mcp install", "miosa doctor --json"],
|
|
4209
|
-
useWhen: [
|
|
4210
|
-
"The agent needs local repository discovery before cloud execution.",
|
|
4211
|
-
"The user intentionally wants local private tools."
|
|
4212
|
-
],
|
|
4213
|
-
avoidWhen: [
|
|
4214
|
-
"Customer code must stay isolated in MIOSA-hosted infrastructure.",
|
|
4215
|
-
"The workflow needs reproducible shared cloud state."
|
|
4216
|
-
]
|
|
4217
|
-
},
|
|
4218
|
-
{
|
|
4219
|
-
kind: "docker_deploy_host",
|
|
4220
|
-
label: "Docker Deploy Host",
|
|
4221
|
-
purpose: "Workspace appliance VM that runs Docker containers for durable apps published from sandboxes.",
|
|
4222
|
-
lifecycle: "Always-on deployment capacity; not an interactive coding workspace.",
|
|
4223
|
-
persistence: "Versioned releases and routing are durable; edits happen in sandboxes before publish.",
|
|
4224
|
-
primaryCommands: [
|
|
4225
|
-
"miosa sandbox publish <id> --docker-deploy",
|
|
4226
|
-
"miosa deploy --docker-deploy"
|
|
4227
|
-
],
|
|
4228
|
-
useWhen: [
|
|
4229
|
-
"You need many small apps, APIs, funnels, or client sites in one workspace appliance.",
|
|
4230
|
-
"You want stable public URLs backed by Docker containers."
|
|
4231
|
-
],
|
|
4232
|
-
avoidWhen: [
|
|
4233
|
-
"Interactive agent work is still happening.",
|
|
4234
|
-
"The app needs the standard MIOSA Deploy runtime."
|
|
4235
|
-
]
|
|
4236
|
-
}
|
|
4237
|
-
];
|
|
4238
|
-
var Devices = class {
|
|
4239
|
-
http;
|
|
4260
|
+
// src/resources/docker-deploy.ts
|
|
4261
|
+
function workspaceId(params) {
|
|
4262
|
+
return params?.workspace_id ?? params?.workspaceId;
|
|
4263
|
+
}
|
|
4264
|
+
function ensureBody(params) {
|
|
4265
|
+
const body2 = {};
|
|
4266
|
+
const id = params.workspace_id ?? params.workspaceId;
|
|
4267
|
+
const externalId = params.external_workspace_id ?? params.externalWorkspaceId;
|
|
4268
|
+
if (id) body2.workspace_id = id;
|
|
4269
|
+
if (externalId) body2.external_workspace_id = externalId;
|
|
4270
|
+
return body2;
|
|
4271
|
+
}
|
|
4272
|
+
function unwrapHost(response) {
|
|
4273
|
+
const host = response.data ?? response.host;
|
|
4274
|
+
if (!host) {
|
|
4275
|
+
throw new Error("Docker Deploy host response was empty.");
|
|
4276
|
+
}
|
|
4277
|
+
return host;
|
|
4278
|
+
}
|
|
4279
|
+
function unwrapTemplates(response) {
|
|
4280
|
+
return response.data ?? response.templates ?? [];
|
|
4281
|
+
}
|
|
4282
|
+
function unwrapTemplate(response) {
|
|
4283
|
+
const template = response.data ?? response.template;
|
|
4284
|
+
if (!template) {
|
|
4285
|
+
throw new Error("Docker Deploy template response was empty.");
|
|
4286
|
+
}
|
|
4287
|
+
return template;
|
|
4288
|
+
}
|
|
4289
|
+
var DockerDeploy = class {
|
|
4240
4290
|
constructor(http) {
|
|
4241
4291
|
this.http = http;
|
|
4242
4292
|
}
|
|
4293
|
+
http;
|
|
4243
4294
|
/**
|
|
4244
|
-
*
|
|
4245
|
-
*
|
|
4295
|
+
* List Docker Deploy appliance hosts scoped to the current tenant.
|
|
4296
|
+
*
|
|
4297
|
+
* Pass a workspace ID to inspect the dedicated always-on appliance machine
|
|
4298
|
+
* for one white-label workspace.
|
|
4246
4299
|
*/
|
|
4247
|
-
|
|
4248
|
-
|
|
4300
|
+
async listHosts(params = {}) {
|
|
4301
|
+
const res = await this.http.get(
|
|
4302
|
+
"/docker-deploy/hosts",
|
|
4303
|
+
{ workspace_id: workspaceId(params) }
|
|
4304
|
+
);
|
|
4305
|
+
return res.data ?? res.hosts ?? [];
|
|
4249
4306
|
}
|
|
4250
4307
|
/**
|
|
4251
|
-
*
|
|
4252
|
-
*
|
|
4253
|
-
*
|
|
4308
|
+
* Ensure a workspace has its dedicated Docker Deploy appliance host.
|
|
4309
|
+
*
|
|
4310
|
+
* The host may still be `pending`, `provisioning`, or `bootstrapping` after
|
|
4311
|
+
* this call. Treat `status === "active"` and `appliance_status === "healthy"`
|
|
4312
|
+
* as the ready condition before sending app/container traffic to it.
|
|
4254
4313
|
*/
|
|
4255
|
-
async
|
|
4256
|
-
const
|
|
4257
|
-
|
|
4258
|
-
|
|
4259
|
-
|
|
4260
|
-
|
|
4261
|
-
const sandboxes = await this.http.get("/sandboxes");
|
|
4262
|
-
devices.push(...unwrapList11(sandboxes, ["sandboxes"]).map(normalizeSandbox));
|
|
4263
|
-
} catch (err) {
|
|
4264
|
-
errors.push(toListError("sandboxes", err));
|
|
4265
|
-
}
|
|
4266
|
-
}
|
|
4267
|
-
if (kind === "all" || kind === "computer") {
|
|
4268
|
-
try {
|
|
4269
|
-
const computers = await this.http.get("/computers");
|
|
4270
|
-
devices.push(...unwrapList11(computers, ["computers"]).map(normalizeComputer));
|
|
4271
|
-
} catch (err) {
|
|
4272
|
-
errors.push(toListError("computers", err));
|
|
4273
|
-
}
|
|
4274
|
-
}
|
|
4275
|
-
return { devices, errors };
|
|
4314
|
+
async ensureHost(params = {}) {
|
|
4315
|
+
const res = await this.http.post(
|
|
4316
|
+
"/docker-deploy/hosts/ensure",
|
|
4317
|
+
ensureBody(params)
|
|
4318
|
+
);
|
|
4319
|
+
return { host: unwrapHost(res), queued: res.queued ?? false };
|
|
4276
4320
|
}
|
|
4277
|
-
|
|
4278
|
-
|
|
4279
|
-
|
|
4280
|
-
|
|
4281
|
-
|
|
4282
|
-
|
|
4283
|
-
if (kind === "computer") return "computer";
|
|
4284
|
-
throw new Error(`Unsupported device kind: ${kind}`);
|
|
4285
|
-
}
|
|
4286
|
-
function normalizeSandbox(row) {
|
|
4287
|
-
return compactRecord({
|
|
4288
|
-
id: stringField(row, "id"),
|
|
4289
|
-
kind: "sandbox_worker",
|
|
4290
|
-
source: "sandboxes",
|
|
4291
|
-
name: optionalString(row, "name"),
|
|
4292
|
-
state: optionalString(row, "state") ?? optionalString(row, "status"),
|
|
4293
|
-
ready: optionalBoolean(row, "ready"),
|
|
4294
|
-
persistent: optionalBoolean(row, "persistent"),
|
|
4295
|
-
alwaysOn: optionalBoolean(row, "always_on"),
|
|
4296
|
-
template: optionalString(row, "template_id") ?? optionalString(row, "template"),
|
|
4297
|
-
previewUrl: optionalString(row, "preview_url"),
|
|
4298
|
-
timeoutRemainingMs: optionalNumber(row, "timeout_remaining_ms")
|
|
4299
|
-
});
|
|
4300
|
-
}
|
|
4301
|
-
function normalizeComputer(row) {
|
|
4302
|
-
return compactRecord({
|
|
4303
|
-
id: stringField(row, "id"),
|
|
4304
|
-
kind: "computer",
|
|
4305
|
-
source: "computers",
|
|
4306
|
-
name: optionalString(row, "name"),
|
|
4307
|
-
state: optionalString(row, "status") ?? optionalString(row, "state"),
|
|
4308
|
-
ready: optionalBoolean(row, "ready"),
|
|
4309
|
-
region: optionalString(row, "region"),
|
|
4310
|
-
template: optionalString(row, "template_type") ?? optionalString(row, "template")
|
|
4311
|
-
});
|
|
4312
|
-
}
|
|
4313
|
-
function compactRecord(record) {
|
|
4314
|
-
return Object.fromEntries(
|
|
4315
|
-
Object.entries(record).filter(([, value]) => value !== void 0)
|
|
4316
|
-
);
|
|
4317
|
-
}
|
|
4318
|
-
function unwrapList11(payload, keys) {
|
|
4319
|
-
const value = isRecord2(payload) && "data" in payload ? payload.data : payload;
|
|
4320
|
-
if (Array.isArray(value)) return value.filter(isRecord2);
|
|
4321
|
-
if (isRecord2(value)) {
|
|
4322
|
-
for (const key of keys) {
|
|
4323
|
-
const nested = value[key];
|
|
4324
|
-
if (Array.isArray(nested)) return nested.filter(isRecord2);
|
|
4325
|
-
}
|
|
4321
|
+
/** Fetch one Docker Deploy host by ID. */
|
|
4322
|
+
async getHost(hostId) {
|
|
4323
|
+
const res = await this.http.get(
|
|
4324
|
+
`/docker-deploy/hosts/${hostId}`
|
|
4325
|
+
);
|
|
4326
|
+
return unwrapHost(res);
|
|
4326
4327
|
}
|
|
4327
|
-
|
|
4328
|
-
|
|
4329
|
-
|
|
4330
|
-
|
|
4331
|
-
|
|
4332
|
-
|
|
4333
|
-
|
|
4334
|
-
|
|
4335
|
-
|
|
4336
|
-
|
|
4337
|
-
|
|
4338
|
-
|
|
4339
|
-
|
|
4340
|
-
|
|
4341
|
-
|
|
4342
|
-
}
|
|
4343
|
-
function optionalString(row, key) {
|
|
4344
|
-
const value = row[key];
|
|
4345
|
-
return typeof value === "string" && value.length > 0 ? value : void 0;
|
|
4346
|
-
}
|
|
4347
|
-
function optionalBoolean(row, key) {
|
|
4348
|
-
return typeof row[key] === "boolean" ? row[key] : void 0;
|
|
4349
|
-
}
|
|
4350
|
-
function optionalNumber(row, key) {
|
|
4351
|
-
return typeof row[key] === "number" ? row[key] : void 0;
|
|
4352
|
-
}
|
|
4353
|
-
function isRecord2(value) {
|
|
4354
|
-
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
4355
|
-
}
|
|
4328
|
+
/** List Docker Deploy starter templates. */
|
|
4329
|
+
async listTemplates() {
|
|
4330
|
+
const res = await this.http.get(
|
|
4331
|
+
"/docker-deploy/templates"
|
|
4332
|
+
);
|
|
4333
|
+
return unwrapTemplates(res);
|
|
4334
|
+
}
|
|
4335
|
+
/** Fetch one Docker Deploy starter template by ID. */
|
|
4336
|
+
async getTemplate(templateId) {
|
|
4337
|
+
const res = await this.http.get(
|
|
4338
|
+
`/docker-deploy/templates/${encodeURIComponent(templateId)}`
|
|
4339
|
+
);
|
|
4340
|
+
return unwrapTemplate(res);
|
|
4341
|
+
}
|
|
4342
|
+
};
|
|
4356
4343
|
|
|
4357
4344
|
// src/resources/email.ts
|
|
4358
|
-
function
|
|
4345
|
+
function unwrap26(data) {
|
|
4359
4346
|
if (data && typeof data === "object") {
|
|
4360
4347
|
const d = data;
|
|
4361
4348
|
for (const k of [
|
|
@@ -4371,7 +4358,7 @@ function unwrap24(data) {
|
|
|
4371
4358
|
}
|
|
4372
4359
|
return data;
|
|
4373
4360
|
}
|
|
4374
|
-
function
|
|
4361
|
+
function unwrapList11(data) {
|
|
4375
4362
|
if (Array.isArray(data)) return data;
|
|
4376
4363
|
if (data && typeof data === "object") {
|
|
4377
4364
|
const d = data;
|
|
@@ -4399,7 +4386,7 @@ var EmailCampaigns = class {
|
|
|
4399
4386
|
}
|
|
4400
4387
|
http;
|
|
4401
4388
|
async list(filters = {}) {
|
|
4402
|
-
return
|
|
4389
|
+
return unwrapList11(
|
|
4403
4390
|
await this.http.get(
|
|
4404
4391
|
"/admin/email-campaigns",
|
|
4405
4392
|
filters
|
|
@@ -4407,12 +4394,12 @@ var EmailCampaigns = class {
|
|
|
4407
4394
|
);
|
|
4408
4395
|
}
|
|
4409
4396
|
async create(attrs) {
|
|
4410
|
-
return
|
|
4397
|
+
return unwrap26(
|
|
4411
4398
|
await this.http.post("/admin/email-campaigns", strip(attrs))
|
|
4412
4399
|
);
|
|
4413
4400
|
}
|
|
4414
4401
|
async recipientCount(filters = {}) {
|
|
4415
|
-
return
|
|
4402
|
+
return unwrap26(
|
|
4416
4403
|
await this.http.get(
|
|
4417
4404
|
"/admin/email-campaigns/recipient-count",
|
|
4418
4405
|
filters
|
|
@@ -4420,7 +4407,7 @@ var EmailCampaigns = class {
|
|
|
4420
4407
|
);
|
|
4421
4408
|
}
|
|
4422
4409
|
async send(campaignId, opts = {}) {
|
|
4423
|
-
return
|
|
4410
|
+
return unwrap26(
|
|
4424
4411
|
await this.http.post(
|
|
4425
4412
|
`/admin/email-campaigns/${campaignId}/send`,
|
|
4426
4413
|
strip(opts)
|
|
@@ -4428,14 +4415,14 @@ var EmailCampaigns = class {
|
|
|
4428
4415
|
);
|
|
4429
4416
|
}
|
|
4430
4417
|
async cancel(campaignId) {
|
|
4431
|
-
return
|
|
4418
|
+
return unwrap26(
|
|
4432
4419
|
await this.http.post(
|
|
4433
4420
|
`/admin/email-campaigns/${campaignId}/cancel`
|
|
4434
4421
|
)
|
|
4435
4422
|
);
|
|
4436
4423
|
}
|
|
4437
4424
|
async deliveries(campaignId, filters = {}) {
|
|
4438
|
-
return
|
|
4425
|
+
return unwrapList11(
|
|
4439
4426
|
await this.http.get(
|
|
4440
4427
|
`/admin/email-campaigns/${campaignId}/deliveries`,
|
|
4441
4428
|
filters
|
|
@@ -4449,12 +4436,12 @@ var EmailTemplates = class {
|
|
|
4449
4436
|
}
|
|
4450
4437
|
http;
|
|
4451
4438
|
async list(filters = {}) {
|
|
4452
|
-
return
|
|
4439
|
+
return unwrapList11(
|
|
4453
4440
|
await this.http.get("/admin/email-templates", filters)
|
|
4454
4441
|
);
|
|
4455
4442
|
}
|
|
4456
4443
|
async create(key, attrs = {}) {
|
|
4457
|
-
return
|
|
4444
|
+
return unwrap26(
|
|
4458
4445
|
await this.http.post("/admin/email-templates", {
|
|
4459
4446
|
key,
|
|
4460
4447
|
...strip(attrs)
|
|
@@ -4462,7 +4449,7 @@ var EmailTemplates = class {
|
|
|
4462
4449
|
);
|
|
4463
4450
|
}
|
|
4464
4451
|
async update(key, attrs) {
|
|
4465
|
-
return
|
|
4452
|
+
return unwrap26(
|
|
4466
4453
|
await this.http.put(
|
|
4467
4454
|
`/admin/email-templates/${key}`,
|
|
4468
4455
|
strip(attrs)
|
|
@@ -4470,7 +4457,7 @@ var EmailTemplates = class {
|
|
|
4470
4457
|
);
|
|
4471
4458
|
}
|
|
4472
4459
|
async reset(key) {
|
|
4473
|
-
return
|
|
4460
|
+
return unwrap26(
|
|
4474
4461
|
await this.http.post(`/admin/email-templates/${key}/reset`)
|
|
4475
4462
|
);
|
|
4476
4463
|
}
|
|
@@ -4481,22 +4468,22 @@ var EmailInbox = class {
|
|
|
4481
4468
|
}
|
|
4482
4469
|
http;
|
|
4483
4470
|
async list(filters = {}) {
|
|
4484
|
-
return
|
|
4471
|
+
return unwrapList11(
|
|
4485
4472
|
await this.http.get("/admin/email-inbox", filters)
|
|
4486
4473
|
);
|
|
4487
4474
|
}
|
|
4488
4475
|
async send(attrs) {
|
|
4489
|
-
return
|
|
4476
|
+
return unwrap26(
|
|
4490
4477
|
await this.http.post("/admin/email-inbox/send", strip(attrs))
|
|
4491
4478
|
);
|
|
4492
4479
|
}
|
|
4493
4480
|
async markRead(messageId) {
|
|
4494
|
-
return
|
|
4481
|
+
return unwrap26(
|
|
4495
4482
|
await this.http.post(`/admin/email-inbox/${messageId}/read`)
|
|
4496
4483
|
);
|
|
4497
4484
|
}
|
|
4498
4485
|
async archive(messageId) {
|
|
4499
|
-
return
|
|
4486
|
+
return unwrap26(
|
|
4500
4487
|
await this.http.post(`/admin/email-inbox/${messageId}/archive`)
|
|
4501
4488
|
);
|
|
4502
4489
|
}
|
|
@@ -4525,18 +4512,18 @@ var Embeddings = class {
|
|
|
4525
4512
|
* `{ object: "list", data: [...], model, usage }`.
|
|
4526
4513
|
*/
|
|
4527
4514
|
async create(params) {
|
|
4528
|
-
const
|
|
4515
|
+
const body2 = Object.fromEntries(
|
|
4529
4516
|
Object.entries(params).filter(([, v]) => v !== void 0)
|
|
4530
4517
|
);
|
|
4531
4518
|
return this.http.post(
|
|
4532
4519
|
"/intelligence/embeddings",
|
|
4533
|
-
|
|
4520
|
+
body2
|
|
4534
4521
|
);
|
|
4535
4522
|
}
|
|
4536
4523
|
};
|
|
4537
4524
|
|
|
4538
4525
|
// src/resources/external-keys.ts
|
|
4539
|
-
function
|
|
4526
|
+
function unwrap27(payload) {
|
|
4540
4527
|
if (payload && typeof payload === "object") {
|
|
4541
4528
|
const p = payload;
|
|
4542
4529
|
for (const k of ["data", "external_keys", "items"]) {
|
|
@@ -4545,7 +4532,7 @@ function unwrap25(payload) {
|
|
|
4545
4532
|
}
|
|
4546
4533
|
return payload;
|
|
4547
4534
|
}
|
|
4548
|
-
function
|
|
4535
|
+
function stripUndefined12(input) {
|
|
4549
4536
|
return Object.fromEntries(
|
|
4550
4537
|
Object.entries(input).filter(([, v]) => v !== void 0)
|
|
4551
4538
|
);
|
|
@@ -4558,22 +4545,22 @@ var ExternalKeys = class {
|
|
|
4558
4545
|
/** List configured external keys. */
|
|
4559
4546
|
async list() {
|
|
4560
4547
|
const data = await this.http.get("/external-keys");
|
|
4561
|
-
const result =
|
|
4548
|
+
const result = unwrap27(data);
|
|
4562
4549
|
if (Array.isArray(result)) return result;
|
|
4563
4550
|
return [];
|
|
4564
4551
|
}
|
|
4565
4552
|
/** Create / register an external provider key. */
|
|
4566
4553
|
async create(params) {
|
|
4567
|
-
const
|
|
4568
|
-
const data = await this.http.post("/external-keys",
|
|
4569
|
-
return
|
|
4554
|
+
const body2 = stripUndefined12(params);
|
|
4555
|
+
const data = await this.http.post("/external-keys", body2);
|
|
4556
|
+
return unwrap27(data);
|
|
4570
4557
|
}
|
|
4571
4558
|
/** Resolve (preview) the stored key for a provider. */
|
|
4572
4559
|
async resolve(provider) {
|
|
4573
4560
|
const data = await this.http.get(
|
|
4574
4561
|
`/external-keys/${provider}/resolve`
|
|
4575
4562
|
);
|
|
4576
|
-
return
|
|
4563
|
+
return unwrap27(data);
|
|
4577
4564
|
}
|
|
4578
4565
|
/**
|
|
4579
4566
|
* Delete the stored key for a provider.
|
|
@@ -4583,7 +4570,7 @@ var ExternalKeys = class {
|
|
|
4583
4570
|
await this.http.delete(`/external-keys/${provider}`);
|
|
4584
4571
|
}
|
|
4585
4572
|
};
|
|
4586
|
-
function
|
|
4573
|
+
function unwrap28(payload) {
|
|
4587
4574
|
if (payload && typeof payload === "object" && "data" in payload) {
|
|
4588
4575
|
return payload.data;
|
|
4589
4576
|
}
|
|
@@ -4599,7 +4586,7 @@ function listItems5(payload, candidateKeys = ["data", "domains", "items"]) {
|
|
|
4599
4586
|
}
|
|
4600
4587
|
return [];
|
|
4601
4588
|
}
|
|
4602
|
-
function
|
|
4589
|
+
function stripUndefined13(input) {
|
|
4603
4590
|
return Object.fromEntries(
|
|
4604
4591
|
Object.entries(input).filter(([, v]) => v !== void 0)
|
|
4605
4592
|
);
|
|
@@ -4613,7 +4600,7 @@ var FlatCustomDomains = class {
|
|
|
4613
4600
|
}
|
|
4614
4601
|
http;
|
|
4615
4602
|
async list(params = {}) {
|
|
4616
|
-
const query =
|
|
4603
|
+
const query = stripUndefined13({ ...params });
|
|
4617
4604
|
const data = await this.http.get("/custom-domains", query);
|
|
4618
4605
|
return listItems5(data);
|
|
4619
4606
|
}
|
|
@@ -4625,7 +4612,7 @@ var FlatCustomDomains = class {
|
|
|
4625
4612
|
redirectPolicy,
|
|
4626
4613
|
...rest
|
|
4627
4614
|
} = params;
|
|
4628
|
-
const
|
|
4615
|
+
const body2 = stripUndefined13({
|
|
4629
4616
|
...rest,
|
|
4630
4617
|
resource_type: resourceType ?? rest.resource_type,
|
|
4631
4618
|
resource_id: resourceId ?? rest.resource_id,
|
|
@@ -4633,16 +4620,16 @@ var FlatCustomDomains = class {
|
|
|
4633
4620
|
});
|
|
4634
4621
|
const data = await this.http.request("/custom-domains", {
|
|
4635
4622
|
method: "POST",
|
|
4636
|
-
body,
|
|
4623
|
+
body: body2,
|
|
4637
4624
|
headers: { "Idempotency-Key": idempotencyKey5(ikey) }
|
|
4638
4625
|
});
|
|
4639
|
-
return
|
|
4626
|
+
return unwrap28(data);
|
|
4640
4627
|
}
|
|
4641
4628
|
async delete(domainId) {
|
|
4642
4629
|
await this.http.delete(`/custom-domains/${domainId}`);
|
|
4643
4630
|
}
|
|
4644
4631
|
};
|
|
4645
|
-
function
|
|
4632
|
+
function unwrap29(payload) {
|
|
4646
4633
|
if (payload && typeof payload === "object" && "data" in payload) {
|
|
4647
4634
|
return payload.data;
|
|
4648
4635
|
}
|
|
@@ -4658,7 +4645,7 @@ function listItems6(payload, candidateKeys = ["data", "functions", "items"]) {
|
|
|
4658
4645
|
}
|
|
4659
4646
|
return [];
|
|
4660
4647
|
}
|
|
4661
|
-
function
|
|
4648
|
+
function stripUndefined14(input) {
|
|
4662
4649
|
return Object.fromEntries(
|
|
4663
4650
|
Object.entries(input).filter(([, v]) => v !== void 0)
|
|
4664
4651
|
);
|
|
@@ -4672,40 +4659,40 @@ var Functions = class {
|
|
|
4672
4659
|
}
|
|
4673
4660
|
http;
|
|
4674
4661
|
async list(params = {}) {
|
|
4675
|
-
const query =
|
|
4662
|
+
const query = stripUndefined14({ ...params });
|
|
4676
4663
|
const data = await this.http.get("/functions", query);
|
|
4677
4664
|
return listItems6(data);
|
|
4678
4665
|
}
|
|
4679
4666
|
async get(functionId) {
|
|
4680
4667
|
const data = await this.http.get(`/functions/${functionId}`);
|
|
4681
|
-
return
|
|
4668
|
+
return unwrap29(data);
|
|
4682
4669
|
}
|
|
4683
4670
|
async create(params) {
|
|
4684
4671
|
const { idempotencyKey: ikey, memoryMb, timeoutSec, ...rest } = params;
|
|
4685
|
-
const
|
|
4672
|
+
const body2 = stripUndefined14({
|
|
4686
4673
|
...rest,
|
|
4687
4674
|
memory_mb: memoryMb ?? rest.memory_mb,
|
|
4688
4675
|
timeout_sec: timeoutSec ?? rest.timeout_sec
|
|
4689
4676
|
});
|
|
4690
4677
|
const data = await this.http.request("/functions", {
|
|
4691
4678
|
method: "POST",
|
|
4692
|
-
body,
|
|
4679
|
+
body: body2,
|
|
4693
4680
|
headers: { "Idempotency-Key": idempotencyKey6(ikey) }
|
|
4694
4681
|
});
|
|
4695
|
-
return
|
|
4682
|
+
return unwrap29(data);
|
|
4696
4683
|
}
|
|
4697
4684
|
async update(functionId, params) {
|
|
4698
4685
|
const { memoryMb, timeoutSec, ...rest } = params;
|
|
4699
|
-
const
|
|
4686
|
+
const body2 = stripUndefined14({
|
|
4700
4687
|
...rest,
|
|
4701
4688
|
memory_mb: memoryMb ?? rest.memory_mb,
|
|
4702
4689
|
timeout_sec: timeoutSec ?? rest.timeout_sec
|
|
4703
4690
|
});
|
|
4704
4691
|
const data = await this.http.patch(
|
|
4705
4692
|
`/functions/${functionId}`,
|
|
4706
|
-
|
|
4693
|
+
body2
|
|
4707
4694
|
);
|
|
4708
|
-
return
|
|
4695
|
+
return unwrap29(data);
|
|
4709
4696
|
}
|
|
4710
4697
|
async delete(functionId) {
|
|
4711
4698
|
await this.http.delete(`/functions/${functionId}`);
|
|
@@ -4726,7 +4713,7 @@ var Functions = class {
|
|
|
4726
4713
|
return data ?? {};
|
|
4727
4714
|
}
|
|
4728
4715
|
};
|
|
4729
|
-
function
|
|
4716
|
+
function unwrap30(payload) {
|
|
4730
4717
|
if (payload && typeof payload === "object" && "data" in payload) {
|
|
4731
4718
|
return payload.data;
|
|
4732
4719
|
}
|
|
@@ -4742,7 +4729,7 @@ function listItems7(payload, candidateKeys = ["data", "health_checks", "items"])
|
|
|
4742
4729
|
}
|
|
4743
4730
|
return [];
|
|
4744
4731
|
}
|
|
4745
|
-
function
|
|
4732
|
+
function stripUndefined15(input) {
|
|
4746
4733
|
return Object.fromEntries(
|
|
4747
4734
|
Object.entries(input).filter(([, v]) => v !== void 0)
|
|
4748
4735
|
);
|
|
@@ -4756,13 +4743,13 @@ var HealthChecks = class {
|
|
|
4756
4743
|
}
|
|
4757
4744
|
http;
|
|
4758
4745
|
async list(params = {}) {
|
|
4759
|
-
const query =
|
|
4746
|
+
const query = stripUndefined15({ ...params });
|
|
4760
4747
|
const data = await this.http.get("/health-checks", query);
|
|
4761
4748
|
return listItems7(data);
|
|
4762
4749
|
}
|
|
4763
4750
|
async get(checkId) {
|
|
4764
4751
|
const data = await this.http.get(`/health-checks/${checkId}`);
|
|
4765
|
-
return
|
|
4752
|
+
return unwrap30(data);
|
|
4766
4753
|
}
|
|
4767
4754
|
async create(params) {
|
|
4768
4755
|
const {
|
|
@@ -4772,7 +4759,7 @@ var HealthChecks = class {
|
|
|
4772
4759
|
expectedStatus,
|
|
4773
4760
|
...rest
|
|
4774
4761
|
} = params;
|
|
4775
|
-
const
|
|
4762
|
+
const body2 = stripUndefined15({
|
|
4776
4763
|
...rest,
|
|
4777
4764
|
interval_sec: intervalSec ?? rest.interval_sec,
|
|
4778
4765
|
timeout_sec: timeoutSec ?? rest.timeout_sec,
|
|
@@ -4780,14 +4767,14 @@ var HealthChecks = class {
|
|
|
4780
4767
|
});
|
|
4781
4768
|
const data = await this.http.request("/health-checks", {
|
|
4782
4769
|
method: "POST",
|
|
4783
|
-
body,
|
|
4770
|
+
body: body2,
|
|
4784
4771
|
headers: { "Idempotency-Key": idempotencyKey7(ikey) }
|
|
4785
4772
|
});
|
|
4786
|
-
return
|
|
4773
|
+
return unwrap30(data);
|
|
4787
4774
|
}
|
|
4788
4775
|
async update(checkId, params) {
|
|
4789
4776
|
const { intervalSec, timeoutSec, expectedStatus, ...rest } = params;
|
|
4790
|
-
const
|
|
4777
|
+
const body2 = stripUndefined15({
|
|
4791
4778
|
...rest,
|
|
4792
4779
|
interval_sec: intervalSec ?? rest.interval_sec,
|
|
4793
4780
|
timeout_sec: timeoutSec ?? rest.timeout_sec,
|
|
@@ -4795,9 +4782,9 @@ var HealthChecks = class {
|
|
|
4795
4782
|
});
|
|
4796
4783
|
const data = await this.http.patch(
|
|
4797
4784
|
`/health-checks/${checkId}`,
|
|
4798
|
-
|
|
4785
|
+
body2
|
|
4799
4786
|
);
|
|
4800
|
-
return
|
|
4787
|
+
return unwrap30(data);
|
|
4801
4788
|
}
|
|
4802
4789
|
async delete(checkId) {
|
|
4803
4790
|
await this.http.delete(`/health-checks/${checkId}`);
|
|
@@ -4805,7 +4792,7 @@ var HealthChecks = class {
|
|
|
4805
4792
|
};
|
|
4806
4793
|
|
|
4807
4794
|
// src/resources/integrations.ts
|
|
4808
|
-
function
|
|
4795
|
+
function unwrap31(payload) {
|
|
4809
4796
|
if (payload && typeof payload === "object") {
|
|
4810
4797
|
const p = payload;
|
|
4811
4798
|
for (const k of ["data", "integrations", "catalog", "items"]) {
|
|
@@ -4815,11 +4802,11 @@ function unwrap29(payload) {
|
|
|
4815
4802
|
return payload;
|
|
4816
4803
|
}
|
|
4817
4804
|
function listItems8(payload) {
|
|
4818
|
-
const result =
|
|
4805
|
+
const result = unwrap31(payload);
|
|
4819
4806
|
if (Array.isArray(result)) return result;
|
|
4820
4807
|
return [];
|
|
4821
4808
|
}
|
|
4822
|
-
function
|
|
4809
|
+
function stripUndefined16(input) {
|
|
4823
4810
|
return Object.fromEntries(
|
|
4824
4811
|
Object.entries(input).filter(([, v]) => v !== void 0)
|
|
4825
4812
|
);
|
|
@@ -4844,14 +4831,14 @@ var Integrations = class {
|
|
|
4844
4831
|
const data = await this.http.get(
|
|
4845
4832
|
`/integrations/${provider}/start`
|
|
4846
4833
|
);
|
|
4847
|
-
return
|
|
4834
|
+
return unwrap31(data);
|
|
4848
4835
|
}
|
|
4849
4836
|
/** Force-refresh the access token for a provider. */
|
|
4850
4837
|
async refresh(provider) {
|
|
4851
4838
|
const data = await this.http.post(
|
|
4852
4839
|
`/integrations/${provider}/refresh`
|
|
4853
4840
|
);
|
|
4854
|
-
return
|
|
4841
|
+
return unwrap31(data);
|
|
4855
4842
|
}
|
|
4856
4843
|
/** Disconnect (revoke) an integration. */
|
|
4857
4844
|
async disconnect(provider) {
|
|
@@ -4871,41 +4858,41 @@ var Integrations = class {
|
|
|
4871
4858
|
// ── Test hooks ─────────────────────────────────────────────────────────────
|
|
4872
4859
|
/** Send a test message to the connected Slack channel. */
|
|
4873
4860
|
async slackSendTest(params = {}) {
|
|
4874
|
-
const
|
|
4861
|
+
const body2 = stripUndefined16(params);
|
|
4875
4862
|
const data = await this.http.post(
|
|
4876
4863
|
"/integrations/slack/send-test",
|
|
4877
|
-
|
|
4864
|
+
body2
|
|
4878
4865
|
);
|
|
4879
|
-
return
|
|
4866
|
+
return unwrap31(data);
|
|
4880
4867
|
}
|
|
4881
4868
|
/** Send a test message to the connected Discord channel. */
|
|
4882
4869
|
async discordSendTest(params = {}) {
|
|
4883
|
-
const
|
|
4870
|
+
const body2 = stripUndefined16(params);
|
|
4884
4871
|
const data = await this.http.post(
|
|
4885
4872
|
"/integrations/discord/send-test",
|
|
4886
|
-
|
|
4873
|
+
body2
|
|
4887
4874
|
);
|
|
4888
|
-
return
|
|
4875
|
+
return unwrap31(data);
|
|
4889
4876
|
}
|
|
4890
4877
|
// ── Linear dedicated controller ────────────────────────────────────────────
|
|
4891
4878
|
/** Begin Linear OAuth — Linear has provider-specific error shapes. */
|
|
4892
4879
|
async linearStart() {
|
|
4893
4880
|
const data = await this.http.get("/integrations/linear/start");
|
|
4894
|
-
return
|
|
4881
|
+
return unwrap31(data);
|
|
4895
4882
|
}
|
|
4896
4883
|
/** Create a Linear issue via the connected workspace. */
|
|
4897
4884
|
async linearCreateIssue(params = {}) {
|
|
4898
|
-
const
|
|
4885
|
+
const body2 = stripUndefined16(params);
|
|
4899
4886
|
const data = await this.http.post(
|
|
4900
4887
|
"/integrations/linear/create-issue",
|
|
4901
|
-
|
|
4888
|
+
body2
|
|
4902
4889
|
);
|
|
4903
|
-
return
|
|
4890
|
+
return unwrap31(data);
|
|
4904
4891
|
}
|
|
4905
4892
|
};
|
|
4906
4893
|
|
|
4907
4894
|
// src/resources/mcp.ts
|
|
4908
|
-
function
|
|
4895
|
+
function unwrap32(payload) {
|
|
4909
4896
|
if (payload && typeof payload === "object") {
|
|
4910
4897
|
const p = payload;
|
|
4911
4898
|
for (const k of ["data", "mcp", "result", "items"]) {
|
|
@@ -4914,7 +4901,7 @@ function unwrap30(payload) {
|
|
|
4914
4901
|
}
|
|
4915
4902
|
return payload;
|
|
4916
4903
|
}
|
|
4917
|
-
function
|
|
4904
|
+
function stripUndefined17(input) {
|
|
4918
4905
|
return Object.fromEntries(
|
|
4919
4906
|
Object.entries(input).filter(([, v]) => v !== void 0)
|
|
4920
4907
|
);
|
|
@@ -4926,12 +4913,12 @@ var Mcp = class {
|
|
|
4926
4913
|
http;
|
|
4927
4914
|
/** Send a JSON-RPC request to the MCP endpoint. */
|
|
4928
4915
|
async dispatch(params = {}) {
|
|
4929
|
-
const
|
|
4916
|
+
const body2 = stripUndefined17(params);
|
|
4930
4917
|
const data = await this.http.post(
|
|
4931
4918
|
"/mcp",
|
|
4932
|
-
Object.keys(
|
|
4919
|
+
Object.keys(body2).length > 0 ? body2 : void 0
|
|
4933
4920
|
);
|
|
4934
|
-
return
|
|
4921
|
+
return unwrap32(data);
|
|
4935
4922
|
}
|
|
4936
4923
|
/**
|
|
4937
4924
|
* Open the MCP listen channel (GET).
|
|
@@ -4941,7 +4928,7 @@ var Mcp = class {
|
|
|
4941
4928
|
*/
|
|
4942
4929
|
async listen() {
|
|
4943
4930
|
const data = await this.http.get("/mcp");
|
|
4944
|
-
return
|
|
4931
|
+
return unwrap32(data);
|
|
4945
4932
|
}
|
|
4946
4933
|
/** Close (terminate) the MCP session. */
|
|
4947
4934
|
async close() {
|
|
@@ -4950,7 +4937,7 @@ var Mcp = class {
|
|
|
4950
4937
|
};
|
|
4951
4938
|
|
|
4952
4939
|
// src/resources/models.ts
|
|
4953
|
-
function
|
|
4940
|
+
function unwrap33(data) {
|
|
4954
4941
|
if (Array.isArray(data)) return data;
|
|
4955
4942
|
if (data && typeof data === "object") {
|
|
4956
4943
|
const d = data;
|
|
@@ -4971,7 +4958,7 @@ var Models = class {
|
|
|
4971
4958
|
Object.entries(filters).filter(([, v]) => v !== void 0)
|
|
4972
4959
|
);
|
|
4973
4960
|
const data = await this.http.get("/intelligence/models", query);
|
|
4974
|
-
return
|
|
4961
|
+
return unwrap33(data);
|
|
4975
4962
|
}
|
|
4976
4963
|
/**
|
|
4977
4964
|
* Get a single model by id.
|
|
@@ -4994,30 +4981,43 @@ var Agents = class {
|
|
|
4994
4981
|
base(hostId) {
|
|
4995
4982
|
return `/opencomputers/hosts/${hostId}/agent`;
|
|
4996
4983
|
}
|
|
4984
|
+
unwrapSession(payload) {
|
|
4985
|
+
const value = payload && typeof payload === "object" && "session" in payload ? payload.session : payload && typeof payload === "object" && "data" in payload ? payload.data : payload;
|
|
4986
|
+
const session = value;
|
|
4987
|
+
if (!session.id && session.session_id) {
|
|
4988
|
+
return { ...session, id: session.session_id };
|
|
4989
|
+
}
|
|
4990
|
+
return session;
|
|
4991
|
+
}
|
|
4992
|
+
unwrapList(payload) {
|
|
4993
|
+
if (payload && typeof payload === "object" && "sessions" in payload) {
|
|
4994
|
+
return { data: payload.sessions };
|
|
4995
|
+
}
|
|
4996
|
+
if (Array.isArray(payload)) {
|
|
4997
|
+
return { data: payload };
|
|
4998
|
+
}
|
|
4999
|
+
return payload;
|
|
5000
|
+
}
|
|
4997
5001
|
/**
|
|
4998
5002
|
* Dispatch a new agent session on the host.
|
|
4999
5003
|
*/
|
|
5000
5004
|
async dispatch(hostId, params) {
|
|
5001
|
-
|
|
5002
|
-
|
|
5003
|
-
params
|
|
5004
|
-
);
|
|
5005
|
+
const payload = await this.http.post(`${this.base(hostId)}/dispatch`, params);
|
|
5006
|
+
return this.unwrapSession(payload);
|
|
5005
5007
|
}
|
|
5006
5008
|
/**
|
|
5007
5009
|
* List all agent sessions for a host.
|
|
5008
5010
|
*/
|
|
5009
5011
|
async list(hostId) {
|
|
5010
|
-
|
|
5011
|
-
|
|
5012
|
-
);
|
|
5012
|
+
const payload = await this.http.get(`${this.base(hostId)}/sessions`);
|
|
5013
|
+
return this.unwrapList(payload);
|
|
5013
5014
|
}
|
|
5014
5015
|
/**
|
|
5015
5016
|
* Fetch the current state of a specific agent session.
|
|
5016
5017
|
*/
|
|
5017
5018
|
async get(hostId, sessionId) {
|
|
5018
|
-
|
|
5019
|
-
|
|
5020
|
-
);
|
|
5019
|
+
const payload = await this.http.get(`${this.base(hostId)}/sessions/${sessionId}`);
|
|
5020
|
+
return this.unwrapSession(payload);
|
|
5021
5021
|
}
|
|
5022
5022
|
/**
|
|
5023
5023
|
* Stream live events from an agent session.
|
|
@@ -5505,49 +5505,49 @@ var OcWorkspaces = class {
|
|
|
5505
5505
|
/**
|
|
5506
5506
|
* Fetch a single workspace.
|
|
5507
5507
|
*/
|
|
5508
|
-
async get(hostId,
|
|
5508
|
+
async get(hostId, workspaceId2) {
|
|
5509
5509
|
return this.http.get(
|
|
5510
|
-
`${this.base(hostId)}/${
|
|
5510
|
+
`${this.base(hostId)}/${workspaceId2}`
|
|
5511
5511
|
);
|
|
5512
5512
|
}
|
|
5513
5513
|
/**
|
|
5514
5514
|
* Update workspace metadata (name, branch).
|
|
5515
5515
|
*/
|
|
5516
|
-
async update(hostId,
|
|
5516
|
+
async update(hostId, workspaceId2, params) {
|
|
5517
5517
|
return this.http.patch(
|
|
5518
|
-
`${this.base(hostId)}/${
|
|
5518
|
+
`${this.base(hostId)}/${workspaceId2}`,
|
|
5519
5519
|
params
|
|
5520
5520
|
);
|
|
5521
5521
|
}
|
|
5522
5522
|
/**
|
|
5523
5523
|
* Delete a workspace.
|
|
5524
5524
|
*/
|
|
5525
|
-
async delete(hostId,
|
|
5526
|
-
return this.http.delete(`${this.base(hostId)}/${
|
|
5525
|
+
async delete(hostId, workspaceId2) {
|
|
5526
|
+
return this.http.delete(`${this.base(hostId)}/${workspaceId2}`);
|
|
5527
5527
|
}
|
|
5528
5528
|
/**
|
|
5529
5529
|
* Pull the latest changes from the remote repository.
|
|
5530
5530
|
*/
|
|
5531
|
-
async pull(hostId,
|
|
5531
|
+
async pull(hostId, workspaceId2) {
|
|
5532
5532
|
return this.http.post(
|
|
5533
|
-
`${this.base(hostId)}/${
|
|
5533
|
+
`${this.base(hostId)}/${workspaceId2}/pull`
|
|
5534
5534
|
);
|
|
5535
5535
|
}
|
|
5536
5536
|
/**
|
|
5537
5537
|
* Open a terminal session scoped to the workspace root directory.
|
|
5538
5538
|
* Returns a short-lived WebSocket ticket.
|
|
5539
5539
|
*/
|
|
5540
|
-
async openTerminal(hostId,
|
|
5540
|
+
async openTerminal(hostId, workspaceId2) {
|
|
5541
5541
|
return this.http.post(
|
|
5542
|
-
`${this.base(hostId)}/${
|
|
5542
|
+
`${this.base(hostId)}/${workspaceId2}/open-terminal`
|
|
5543
5543
|
);
|
|
5544
5544
|
}
|
|
5545
5545
|
/**
|
|
5546
5546
|
* Stream workspace setup / clone / install events.
|
|
5547
5547
|
*/
|
|
5548
|
-
events(hostId,
|
|
5548
|
+
events(hostId, workspaceId2) {
|
|
5549
5549
|
return this.http.stream(
|
|
5550
|
-
`${this.base(hostId)}/${
|
|
5550
|
+
`${this.base(hostId)}/${workspaceId2}/events`
|
|
5551
5551
|
);
|
|
5552
5552
|
}
|
|
5553
5553
|
};
|
|
@@ -5601,7 +5601,7 @@ function resourcePayload(params) {
|
|
|
5601
5601
|
return { resource_type, resource_id };
|
|
5602
5602
|
}
|
|
5603
5603
|
function authConfig(params) {
|
|
5604
|
-
return
|
|
5604
|
+
return stripUndefined18({
|
|
5605
5605
|
...params.config ?? {},
|
|
5606
5606
|
signup_enabled: params.signup_enabled ?? params.signupEnabled,
|
|
5607
5607
|
email_confirm_required: params.email_confirm_required ?? params.emailConfirmRequired,
|
|
@@ -5609,12 +5609,12 @@ function authConfig(params) {
|
|
|
5609
5609
|
});
|
|
5610
5610
|
}
|
|
5611
5611
|
function requestBody(params) {
|
|
5612
|
-
return
|
|
5612
|
+
return stripUndefined18({
|
|
5613
5613
|
...resourcePayload(params),
|
|
5614
5614
|
config: authConfig(params)
|
|
5615
5615
|
});
|
|
5616
5616
|
}
|
|
5617
|
-
function
|
|
5617
|
+
function unwrap34(payload) {
|
|
5618
5618
|
if (payload && typeof payload === "object") {
|
|
5619
5619
|
const p = payload;
|
|
5620
5620
|
for (const k of ["data", "project_auth", "config", "items"]) {
|
|
@@ -5623,7 +5623,7 @@ function unwrap32(payload) {
|
|
|
5623
5623
|
}
|
|
5624
5624
|
return payload;
|
|
5625
5625
|
}
|
|
5626
|
-
function
|
|
5626
|
+
function stripUndefined18(input) {
|
|
5627
5627
|
return Object.fromEntries(
|
|
5628
5628
|
Object.entries(input).filter(([, v]) => v !== void 0)
|
|
5629
5629
|
);
|
|
@@ -5639,13 +5639,13 @@ var ProjectAuth = class {
|
|
|
5639
5639
|
"/project-auth/status",
|
|
5640
5640
|
resourcePayload(params)
|
|
5641
5641
|
);
|
|
5642
|
-
return
|
|
5642
|
+
return unwrap34(data);
|
|
5643
5643
|
}
|
|
5644
5644
|
/** Enable project auth. */
|
|
5645
5645
|
async enable(params) {
|
|
5646
|
-
const
|
|
5647
|
-
const data = await this.http.post("/project-auth/enable",
|
|
5648
|
-
return
|
|
5646
|
+
const body2 = requestBody(params);
|
|
5647
|
+
const data = await this.http.post("/project-auth/enable", body2);
|
|
5648
|
+
return unwrap34(data);
|
|
5649
5649
|
}
|
|
5650
5650
|
/** Disable project auth. */
|
|
5651
5651
|
async disable(params) {
|
|
@@ -5653,18 +5653,18 @@ var ProjectAuth = class {
|
|
|
5653
5653
|
"/project-auth/disable",
|
|
5654
5654
|
resourcePayload(params)
|
|
5655
5655
|
);
|
|
5656
|
-
return
|
|
5656
|
+
return unwrap34(data);
|
|
5657
5657
|
}
|
|
5658
5658
|
/** Update project-auth configuration. */
|
|
5659
5659
|
async update(params) {
|
|
5660
|
-
const
|
|
5661
|
-
const data = await this.http.patch("/project-auth/config",
|
|
5662
|
-
return
|
|
5660
|
+
const body2 = requestBody(params);
|
|
5661
|
+
const data = await this.http.patch("/project-auth/config", body2);
|
|
5662
|
+
return unwrap34(data);
|
|
5663
5663
|
}
|
|
5664
5664
|
};
|
|
5665
5665
|
|
|
5666
5666
|
// src/resources/project-integrations.ts
|
|
5667
|
-
function
|
|
5667
|
+
function unwrap35(payload) {
|
|
5668
5668
|
if (payload && typeof payload === "object") {
|
|
5669
5669
|
const p = payload;
|
|
5670
5670
|
for (const k of ["data", "project_integrations", "catalog", "items"]) {
|
|
@@ -5674,11 +5674,11 @@ function unwrap33(payload) {
|
|
|
5674
5674
|
return payload;
|
|
5675
5675
|
}
|
|
5676
5676
|
function listItems9(payload) {
|
|
5677
|
-
const result =
|
|
5677
|
+
const result = unwrap35(payload);
|
|
5678
5678
|
if (Array.isArray(result)) return result;
|
|
5679
5679
|
return [];
|
|
5680
5680
|
}
|
|
5681
|
-
function
|
|
5681
|
+
function stripUndefined19(input) {
|
|
5682
5682
|
return Object.fromEntries(
|
|
5683
5683
|
Object.entries(input).filter(([, v]) => v !== void 0)
|
|
5684
5684
|
);
|
|
@@ -5695,7 +5695,7 @@ var ProjectIntegrations = class {
|
|
|
5695
5695
|
http;
|
|
5696
5696
|
/** List project integrations. */
|
|
5697
5697
|
async list(params = {}) {
|
|
5698
|
-
const query =
|
|
5698
|
+
const query = stripUndefined19(params);
|
|
5699
5699
|
const data = await this.http.get("/project-integrations", query);
|
|
5700
5700
|
return listItems9(data);
|
|
5701
5701
|
}
|
|
@@ -5709,22 +5709,22 @@ var ProjectIntegrations = class {
|
|
|
5709
5709
|
const data = await this.http.get(
|
|
5710
5710
|
`/project-integrations/${integrationId}`
|
|
5711
5711
|
);
|
|
5712
|
-
return
|
|
5712
|
+
return unwrap35(data);
|
|
5713
5713
|
}
|
|
5714
5714
|
/** Create a project integration. */
|
|
5715
5715
|
async create(params) {
|
|
5716
|
-
const
|
|
5717
|
-
const data = await this.http.post("/project-integrations",
|
|
5718
|
-
return
|
|
5716
|
+
const body2 = stripUndefObj2(params);
|
|
5717
|
+
const data = await this.http.post("/project-integrations", body2);
|
|
5718
|
+
return unwrap35(data);
|
|
5719
5719
|
}
|
|
5720
5720
|
/** Update a project integration. */
|
|
5721
5721
|
async update(integrationId, params) {
|
|
5722
|
-
const
|
|
5722
|
+
const body2 = stripUndefObj2(params);
|
|
5723
5723
|
const data = await this.http.patch(
|
|
5724
5724
|
`/project-integrations/${integrationId}`,
|
|
5725
|
-
|
|
5725
|
+
body2
|
|
5726
5726
|
);
|
|
5727
|
-
return
|
|
5727
|
+
return unwrap35(data);
|
|
5728
5728
|
}
|
|
5729
5729
|
/** Delete a project integration. */
|
|
5730
5730
|
async delete(integrationId) {
|
|
@@ -5733,7 +5733,7 @@ var ProjectIntegrations = class {
|
|
|
5733
5733
|
};
|
|
5734
5734
|
|
|
5735
5735
|
// src/resources/provider-defaults.ts
|
|
5736
|
-
function
|
|
5736
|
+
function unwrap36(data) {
|
|
5737
5737
|
if (data && typeof data === "object") {
|
|
5738
5738
|
const d = data;
|
|
5739
5739
|
for (const k of ["data", "defaults", "provider_defaults", "config"]) {
|
|
@@ -5749,7 +5749,7 @@ var ProviderDefaults = class {
|
|
|
5749
5749
|
http;
|
|
5750
5750
|
/** Get the current fleet-wide provider defaults. */
|
|
5751
5751
|
async list() {
|
|
5752
|
-
return
|
|
5752
|
+
return unwrap36(await this.http.get("/admin/provider-defaults"));
|
|
5753
5753
|
}
|
|
5754
5754
|
/** Return the defaults entry for a single provider, or {} if missing. */
|
|
5755
5755
|
async get(provider) {
|
|
@@ -5762,29 +5762,29 @@ var ProviderDefaults = class {
|
|
|
5762
5762
|
}
|
|
5763
5763
|
/** Replace the fleet-wide defaults (PUT /admin/provider-defaults). */
|
|
5764
5764
|
async update(opts) {
|
|
5765
|
-
const
|
|
5765
|
+
const body2 = Object.fromEntries(
|
|
5766
5766
|
Object.entries(opts).filter(([, v]) => v !== void 0)
|
|
5767
5767
|
);
|
|
5768
|
-
return
|
|
5769
|
-
await this.http.put("/admin/provider-defaults",
|
|
5768
|
+
return unwrap36(
|
|
5769
|
+
await this.http.put("/admin/provider-defaults", body2)
|
|
5770
5770
|
);
|
|
5771
5771
|
}
|
|
5772
5772
|
// ── Per-tenant overrides ────────────────────────────────────────────────
|
|
5773
5773
|
async getTenant(tenantId) {
|
|
5774
|
-
return
|
|
5774
|
+
return unwrap36(
|
|
5775
5775
|
await this.http.get(
|
|
5776
5776
|
`/admin/tenants/${tenantId}/provider-config`
|
|
5777
5777
|
)
|
|
5778
5778
|
);
|
|
5779
5779
|
}
|
|
5780
5780
|
async setTenant(tenantId, opts) {
|
|
5781
|
-
const
|
|
5781
|
+
const body2 = Object.fromEntries(
|
|
5782
5782
|
Object.entries(opts).filter(([, v]) => v !== void 0)
|
|
5783
5783
|
);
|
|
5784
|
-
return
|
|
5784
|
+
return unwrap36(
|
|
5785
5785
|
await this.http.put(
|
|
5786
5786
|
`/admin/tenants/${tenantId}/provider-config`,
|
|
5787
|
-
|
|
5787
|
+
body2
|
|
5788
5788
|
)
|
|
5789
5789
|
);
|
|
5790
5790
|
}
|
|
@@ -5794,7 +5794,7 @@ var ProviderDefaults = class {
|
|
|
5794
5794
|
};
|
|
5795
5795
|
|
|
5796
5796
|
// src/resources/regions.ts
|
|
5797
|
-
function
|
|
5797
|
+
function unwrap37(payload) {
|
|
5798
5798
|
if (payload && typeof payload === "object") {
|
|
5799
5799
|
const p = payload;
|
|
5800
5800
|
for (const k of [
|
|
@@ -5811,7 +5811,7 @@ function unwrap35(payload) {
|
|
|
5811
5811
|
return payload;
|
|
5812
5812
|
}
|
|
5813
5813
|
function listItems10(payload) {
|
|
5814
|
-
const result =
|
|
5814
|
+
const result = unwrap37(payload);
|
|
5815
5815
|
if (Array.isArray(result)) return result;
|
|
5816
5816
|
return [];
|
|
5817
5817
|
}
|
|
@@ -5833,7 +5833,7 @@ var Regions = class {
|
|
|
5833
5833
|
/** Get static compute pricing data. */
|
|
5834
5834
|
async pricing() {
|
|
5835
5835
|
const data = await this.http.get("/compute/pricing");
|
|
5836
|
-
return
|
|
5836
|
+
return unwrap37(data);
|
|
5837
5837
|
}
|
|
5838
5838
|
/** List community computer templates. */
|
|
5839
5839
|
async listTemplates() {
|
|
@@ -5845,7 +5845,7 @@ var Regions = class {
|
|
|
5845
5845
|
const data = await this.http.get(
|
|
5846
5846
|
`/compute/templates/${templateId}`
|
|
5847
5847
|
);
|
|
5848
|
-
return
|
|
5848
|
+
return unwrap37(data);
|
|
5849
5849
|
}
|
|
5850
5850
|
};
|
|
5851
5851
|
|
|
@@ -5859,12 +5859,36 @@ function encodeContent(content) {
|
|
|
5859
5859
|
return btoa(bin);
|
|
5860
5860
|
}
|
|
5861
5861
|
var SANDBOX_TEMPLATE = "miosa-sandbox";
|
|
5862
|
-
|
|
5862
|
+
var AGENT_WORKSPACE_TIMEOUT_SEC = 86400;
|
|
5863
|
+
var AGENT_WORKSPACE_IDLE_TIMEOUT_SEC = 1800;
|
|
5864
|
+
var AGENT_WORKSPACE_SNAPSHOT_EXPIRATION_DAYS = 30;
|
|
5865
|
+
var AGENT_WORKSPACE_KEEP_LAST_SNAPSHOTS = 1;
|
|
5866
|
+
function unwrap38(payload) {
|
|
5863
5867
|
if (payload !== null && typeof payload === "object" && "data" in payload && payload.data !== void 0) {
|
|
5864
5868
|
return payload.data;
|
|
5865
5869
|
}
|
|
5866
5870
|
return payload;
|
|
5867
5871
|
}
|
|
5872
|
+
function normalizeExport(value) {
|
|
5873
|
+
const normalized = {
|
|
5874
|
+
...value,
|
|
5875
|
+
files: (value.files ?? []).map((file) => {
|
|
5876
|
+
const normalized2 = { ...file };
|
|
5877
|
+
const downloadUrl = file.downloadUrl ?? file.download_url;
|
|
5878
|
+
if (downloadUrl !== void 0) normalized2.downloadUrl = downloadUrl;
|
|
5879
|
+
return normalized2;
|
|
5880
|
+
})
|
|
5881
|
+
};
|
|
5882
|
+
const sandboxId = value.sandboxId ?? value.sandbox_id;
|
|
5883
|
+
const archiveDownloadUrl = value.archiveDownloadUrl ?? value.archive_download_url;
|
|
5884
|
+
const createdAt = value.createdAt ?? value.created_at;
|
|
5885
|
+
if (sandboxId !== void 0) normalized.sandboxId = sandboxId;
|
|
5886
|
+
if (archiveDownloadUrl !== void 0) {
|
|
5887
|
+
normalized.archiveDownloadUrl = archiveDownloadUrl;
|
|
5888
|
+
}
|
|
5889
|
+
if (createdAt !== void 0) normalized.createdAt = createdAt;
|
|
5890
|
+
return normalized;
|
|
5891
|
+
}
|
|
5868
5892
|
function listItems11(payload) {
|
|
5869
5893
|
if (Array.isArray(payload)) return payload;
|
|
5870
5894
|
if ("data" in payload && Array.isArray(payload.data)) return payload.data;
|
|
@@ -5875,17 +5899,28 @@ function listItems11(payload) {
|
|
|
5875
5899
|
}
|
|
5876
5900
|
function createBody(params = {}) {
|
|
5877
5901
|
const templateId = params.templateId ?? params.template_id ?? params.image ?? SANDBOX_TEMPLATE;
|
|
5878
|
-
|
|
5902
|
+
const persistent = params.persistent;
|
|
5903
|
+
const snapshotExpirationSec = snapshotExpirationSeconds(params);
|
|
5904
|
+
const keepLastSnapshots = params.keepLastSnapshots ?? params.keep_last_snapshots;
|
|
5905
|
+
const metadata = { ...params.metadata ?? {} };
|
|
5906
|
+
if (persistent !== void 0) metadata.miosa_persistent = persistent;
|
|
5907
|
+
if (snapshotExpirationSec !== void 0) {
|
|
5908
|
+
metadata.snapshot_expiration_sec = snapshotExpirationSec;
|
|
5909
|
+
}
|
|
5910
|
+
if (keepLastSnapshots !== void 0) {
|
|
5911
|
+
metadata.keep_last_snapshots = keepLastSnapshots;
|
|
5912
|
+
}
|
|
5913
|
+
return stripUndefined20({
|
|
5879
5914
|
template_id: templateId,
|
|
5880
5915
|
cpu_count: params.cpuCount ?? params.cpu_count,
|
|
5881
5916
|
memory_mb: params.memoryMb ?? params.memory_mb,
|
|
5882
5917
|
disk_mb: params.diskMb ?? params.disk_mb,
|
|
5883
5918
|
disk_size_mb: params.diskSizeMb ?? params.disk_size_mb,
|
|
5884
|
-
timeout_sec: params.timeoutSec ?? params.timeout_sec,
|
|
5885
|
-
idle_timeout_sec: params.idleTimeoutSec ?? params.idle_timeout_sec,
|
|
5919
|
+
timeout_sec: params.timeoutSec ?? params.timeout_sec ?? (persistent === true ? 86400 : void 0),
|
|
5920
|
+
idle_timeout_sec: params.idleTimeoutSec ?? params.idle_timeout_sec ?? (persistent === true ? 1800 : void 0),
|
|
5886
5921
|
always_on: params.alwaysOn ?? params.always_on,
|
|
5887
5922
|
env: params.env,
|
|
5888
|
-
metadata:
|
|
5923
|
+
metadata: Object.keys(metadata).length > 0 ? metadata : void 0,
|
|
5889
5924
|
services: params.services,
|
|
5890
5925
|
readiness_probe: params.readinessProbe ?? params.readiness_probe,
|
|
5891
5926
|
database: params.database,
|
|
@@ -5897,24 +5932,32 @@ function createBody(params = {}) {
|
|
|
5897
5932
|
entrypoint: params.entrypoint,
|
|
5898
5933
|
tags: params.tags,
|
|
5899
5934
|
slug: params.slug,
|
|
5935
|
+
agent_runtime_profile_id: params.agentRuntimeProfileId ?? params.agent_runtime_profile_id ?? params.agentProfileId ?? params.agent_profile_id,
|
|
5936
|
+
skip_agent_runtime_profile: params.skipAgentRuntimeProfile ?? params.skip_agent_runtime_profile,
|
|
5900
5937
|
external_workspace_id: params.externalWorkspaceId ?? params.external_workspace_id,
|
|
5901
5938
|
external_user_id: params.externalUserId ?? params.external_user_id,
|
|
5902
5939
|
external_project_id: params.externalProjectId ?? params.external_project_id
|
|
5903
5940
|
});
|
|
5904
5941
|
}
|
|
5905
5942
|
function execBody(command, options = {}) {
|
|
5906
|
-
return
|
|
5943
|
+
return stripUndefined20({
|
|
5907
5944
|
command,
|
|
5908
5945
|
cwd: options.cwd ?? options.workingDir ?? options.working_dir,
|
|
5909
5946
|
env: options.env,
|
|
5910
5947
|
timeout: options.timeout ?? options.timeoutSec ?? options.timeout_sec
|
|
5911
5948
|
});
|
|
5912
5949
|
}
|
|
5913
|
-
function
|
|
5950
|
+
function stripUndefined20(input) {
|
|
5914
5951
|
return Object.fromEntries(
|
|
5915
5952
|
Object.entries(input).filter(([, value]) => value !== void 0)
|
|
5916
5953
|
);
|
|
5917
5954
|
}
|
|
5955
|
+
function snapshotExpirationSeconds(params) {
|
|
5956
|
+
const seconds = params.snapshotExpirationSec ?? params.snapshot_expiration_sec;
|
|
5957
|
+
if (seconds !== void 0) return seconds;
|
|
5958
|
+
const days = params.snapshotExpirationDays ?? params.snapshot_expiration_days;
|
|
5959
|
+
return days === void 0 ? void 0 : days * 86400;
|
|
5960
|
+
}
|
|
5918
5961
|
var SandboxCommands = class {
|
|
5919
5962
|
constructor(sandbox) {
|
|
5920
5963
|
this.sandbox = sandbox;
|
|
@@ -6043,11 +6086,11 @@ var SandboxTerminal = class {
|
|
|
6043
6086
|
}
|
|
6044
6087
|
sandbox;
|
|
6045
6088
|
async create(params = {}) {
|
|
6046
|
-
const
|
|
6089
|
+
const body2 = Object.fromEntries(
|
|
6047
6090
|
Object.entries(params).filter(([, v]) => v !== void 0)
|
|
6048
6091
|
);
|
|
6049
|
-
const response =
|
|
6050
|
-
await this.sandbox.http.post(`/sandboxes/${this.sandbox.id}/terminal`,
|
|
6092
|
+
const response = unwrap38(
|
|
6093
|
+
await this.sandbox.http.post(`/sandboxes/${this.sandbox.id}/terminal`, body2)
|
|
6051
6094
|
);
|
|
6052
6095
|
return response;
|
|
6053
6096
|
}
|
|
@@ -6089,21 +6132,21 @@ var SandboxPreviews = class {
|
|
|
6089
6132
|
return [];
|
|
6090
6133
|
}
|
|
6091
6134
|
async create(port, opts = {}) {
|
|
6092
|
-
const
|
|
6135
|
+
const body2 = {
|
|
6093
6136
|
port,
|
|
6094
6137
|
...Object.fromEntries(
|
|
6095
6138
|
Object.entries(opts).filter(([, v]) => v !== void 0)
|
|
6096
6139
|
)
|
|
6097
6140
|
};
|
|
6098
|
-
return
|
|
6141
|
+
return unwrap38(
|
|
6099
6142
|
await this.http.post(
|
|
6100
6143
|
`/sandboxes/${this.sandbox.id}/previews`,
|
|
6101
|
-
|
|
6144
|
+
body2
|
|
6102
6145
|
)
|
|
6103
6146
|
);
|
|
6104
6147
|
}
|
|
6105
6148
|
async get(previewId) {
|
|
6106
|
-
return
|
|
6149
|
+
return unwrap38(
|
|
6107
6150
|
await this.http.get(
|
|
6108
6151
|
`/sandboxes/${this.sandbox.id}/previews/${previewId}`
|
|
6109
6152
|
)
|
|
@@ -6116,7 +6159,7 @@ var SandboxPreviews = class {
|
|
|
6116
6159
|
}
|
|
6117
6160
|
/** Mint a share token for previewId. */
|
|
6118
6161
|
async share(previewId, opts = {}) {
|
|
6119
|
-
return
|
|
6162
|
+
return unwrap38(
|
|
6120
6163
|
await this.http.post(
|
|
6121
6164
|
`/sandboxes/${this.sandbox.id}/previews/${previewId}/share`,
|
|
6122
6165
|
{ ttl_seconds: opts.ttl_seconds ?? opts.expires_in_sec ?? 3600 }
|
|
@@ -6185,7 +6228,7 @@ var SandboxTags = class {
|
|
|
6185
6228
|
sandbox;
|
|
6186
6229
|
/** Replace the full tag list with tags. */
|
|
6187
6230
|
async set(tags) {
|
|
6188
|
-
return
|
|
6231
|
+
return unwrap38(
|
|
6189
6232
|
await this.sandbox.http.patch(`/sandboxes/${this.sandbox.id}/tags`, { tags })
|
|
6190
6233
|
);
|
|
6191
6234
|
}
|
|
@@ -6253,14 +6296,14 @@ var Sandbox = class _Sandbox {
|
|
|
6253
6296
|
return this.data.template_id ?? this.data.image_id ?? "";
|
|
6254
6297
|
}
|
|
6255
6298
|
async refresh() {
|
|
6256
|
-
this.data =
|
|
6299
|
+
this.data = unwrap38(
|
|
6257
6300
|
await this.http.get(`/sandboxes/${this.id}`)
|
|
6258
6301
|
);
|
|
6259
6302
|
return this;
|
|
6260
6303
|
}
|
|
6261
6304
|
async runExec(command, options) {
|
|
6262
6305
|
this.assertRunning("exec");
|
|
6263
|
-
const response =
|
|
6306
|
+
const response = unwrap38(
|
|
6264
6307
|
await this.http.post(
|
|
6265
6308
|
`/sandboxes/${this.id}/exec`,
|
|
6266
6309
|
execBody(command, options)
|
|
@@ -6303,12 +6346,34 @@ var Sandbox = class _Sandbox {
|
|
|
6303
6346
|
`/sandboxes/${this.id}/files/${path.replace(/^\/+/, "")}`
|
|
6304
6347
|
);
|
|
6305
6348
|
}
|
|
6349
|
+
async createExport(params) {
|
|
6350
|
+
const body2 = typeof params === "string" ? { path: params } : Array.isArray(params) ? { paths: params } : params;
|
|
6351
|
+
const response = unwrap38(
|
|
6352
|
+
await this.http.post(
|
|
6353
|
+
`/sandboxes/${this.id}/exports`,
|
|
6354
|
+
body2
|
|
6355
|
+
)
|
|
6356
|
+
);
|
|
6357
|
+
return normalizeExport(response);
|
|
6358
|
+
}
|
|
6359
|
+
async downloadExport(paths, options = {}) {
|
|
6360
|
+
const query = new URLSearchParams();
|
|
6361
|
+
if (Array.isArray(paths)) {
|
|
6362
|
+
for (const path of paths) query.append("paths[]", path);
|
|
6363
|
+
} else {
|
|
6364
|
+
query.set("path", paths);
|
|
6365
|
+
}
|
|
6366
|
+
if (options.filename) query.set("filename", options.filename);
|
|
6367
|
+
return this.http.getBinary(
|
|
6368
|
+
`/sandboxes/${this.id}/exports/download?${query.toString()}`
|
|
6369
|
+
);
|
|
6370
|
+
}
|
|
6306
6371
|
async readFile(path) {
|
|
6307
6372
|
return new TextDecoder().decode(await this.download(path));
|
|
6308
6373
|
}
|
|
6309
6374
|
async listFiles(path = "/workspace") {
|
|
6310
6375
|
this.assertRunning("files.list");
|
|
6311
|
-
const response =
|
|
6376
|
+
const response = unwrap38(
|
|
6312
6377
|
await this.http.get(
|
|
6313
6378
|
`/sandboxes/${this.id}/files`,
|
|
6314
6379
|
{ path }
|
|
@@ -6318,7 +6383,7 @@ var Sandbox = class _Sandbox {
|
|
|
6318
6383
|
}
|
|
6319
6384
|
async statFile(path) {
|
|
6320
6385
|
this.assertRunning("files.stat");
|
|
6321
|
-
return
|
|
6386
|
+
return unwrap38(
|
|
6322
6387
|
await this.http.post(
|
|
6323
6388
|
`/sandboxes/${this.id}/files/stat`,
|
|
6324
6389
|
{ path }
|
|
@@ -6327,7 +6392,7 @@ var Sandbox = class _Sandbox {
|
|
|
6327
6392
|
}
|
|
6328
6393
|
async expose(port) {
|
|
6329
6394
|
this.assertRunning("expose");
|
|
6330
|
-
const response =
|
|
6395
|
+
const response = unwrap38(
|
|
6331
6396
|
await this.http.post(
|
|
6332
6397
|
`/sandboxes/${this.id}/expose`,
|
|
6333
6398
|
port === void 0 ? {} : { port }
|
|
@@ -6337,7 +6402,7 @@ var Sandbox = class _Sandbox {
|
|
|
6337
6402
|
}
|
|
6338
6403
|
async startTemplate(options = {}) {
|
|
6339
6404
|
this.assertRunning("startTemplate");
|
|
6340
|
-
return
|
|
6405
|
+
return unwrap38(
|
|
6341
6406
|
await this.http.post(
|
|
6342
6407
|
`/sandboxes/${this.id}/template/start`,
|
|
6343
6408
|
options
|
|
@@ -6345,7 +6410,7 @@ var Sandbox = class _Sandbox {
|
|
|
6345
6410
|
);
|
|
6346
6411
|
}
|
|
6347
6412
|
async getArtifacts() {
|
|
6348
|
-
return
|
|
6413
|
+
return unwrap38(
|
|
6349
6414
|
await this.http.get(
|
|
6350
6415
|
`/sandboxes/${this.id}/artifacts`
|
|
6351
6416
|
)
|
|
@@ -6356,7 +6421,7 @@ var Sandbox = class _Sandbox {
|
|
|
6356
6421
|
`/sandboxes/${this.id}/logs`,
|
|
6357
6422
|
{ lines }
|
|
6358
6423
|
);
|
|
6359
|
-
return
|
|
6424
|
+
return unwrap38(response);
|
|
6360
6425
|
}
|
|
6361
6426
|
streamLogs() {
|
|
6362
6427
|
return this.http.stream(
|
|
@@ -6365,7 +6430,7 @@ var Sandbox = class _Sandbox {
|
|
|
6365
6430
|
}
|
|
6366
6431
|
async createSnapshot(comment) {
|
|
6367
6432
|
this.assertRunning("snapshots.create");
|
|
6368
|
-
return
|
|
6433
|
+
return unwrap38(
|
|
6369
6434
|
await this.http.post(
|
|
6370
6435
|
`/sandboxes/${this.id}/snapshots`,
|
|
6371
6436
|
comment ? { comment } : {}
|
|
@@ -6373,14 +6438,14 @@ var Sandbox = class _Sandbox {
|
|
|
6373
6438
|
);
|
|
6374
6439
|
}
|
|
6375
6440
|
async listSnapshots() {
|
|
6376
|
-
return
|
|
6441
|
+
return unwrap38(
|
|
6377
6442
|
await this.http.get(
|
|
6378
6443
|
`/sandboxes/${this.id}/snapshots`
|
|
6379
6444
|
)
|
|
6380
6445
|
);
|
|
6381
6446
|
}
|
|
6382
6447
|
async restoreSnapshot(snapshotId) {
|
|
6383
|
-
const data =
|
|
6448
|
+
const data = unwrap38(
|
|
6384
6449
|
await this.http.post(
|
|
6385
6450
|
`/sandboxes/${this.id}/restore/${snapshotId}`,
|
|
6386
6451
|
{}
|
|
@@ -6397,13 +6462,13 @@ var Sandbox = class _Sandbox {
|
|
|
6397
6462
|
*/
|
|
6398
6463
|
async fork(opts = {}) {
|
|
6399
6464
|
this.assertRunning("fork");
|
|
6400
|
-
const
|
|
6401
|
-
if (opts.name !== void 0)
|
|
6402
|
-
if (opts.metadata !== void 0)
|
|
6403
|
-
const data =
|
|
6465
|
+
const body2 = {};
|
|
6466
|
+
if (opts.name !== void 0) body2.name = opts.name;
|
|
6467
|
+
if (opts.metadata !== void 0) body2.metadata = opts.metadata;
|
|
6468
|
+
const data = unwrap38(
|
|
6404
6469
|
await this.http.post(
|
|
6405
6470
|
`/sandboxes/${this.id}/fork`,
|
|
6406
|
-
|
|
6471
|
+
body2
|
|
6407
6472
|
)
|
|
6408
6473
|
);
|
|
6409
6474
|
return new _Sandbox(this.http, data);
|
|
@@ -6412,14 +6477,39 @@ var Sandbox = class _Sandbox {
|
|
|
6412
6477
|
* PATCH /api/v1/sandboxes/{id} — update mutable sandbox fields.
|
|
6413
6478
|
*/
|
|
6414
6479
|
async update(params) {
|
|
6415
|
-
const
|
|
6416
|
-
|
|
6417
|
-
|
|
6480
|
+
const snapshotExpirationSec = snapshotExpirationSeconds(params);
|
|
6481
|
+
const metadata = { ...params.metadata ?? {} };
|
|
6482
|
+
if (params.persistent !== void 0) metadata.miosa_persistent = params.persistent;
|
|
6483
|
+
if (snapshotExpirationSec !== void 0) {
|
|
6484
|
+
metadata.snapshot_expiration_sec = snapshotExpirationSec;
|
|
6418
6485
|
}
|
|
6419
|
-
const
|
|
6486
|
+
const keepLastSnapshots = params.keepLastSnapshots ?? params.keep_last_snapshots;
|
|
6487
|
+
if (keepLastSnapshots !== void 0) {
|
|
6488
|
+
metadata.keep_last_snapshots = keepLastSnapshots;
|
|
6489
|
+
}
|
|
6490
|
+
const body2 = stripUndefined20({
|
|
6491
|
+
name: params.name,
|
|
6492
|
+
slug: params.slug,
|
|
6493
|
+
tags: params.tags,
|
|
6494
|
+
metadata: Object.keys(metadata).length > 0 ? metadata : void 0,
|
|
6495
|
+
always_on: params.always_on ?? params.alwaysOn,
|
|
6496
|
+
timeout_sec: params.timeout_sec ?? params.timeoutSec,
|
|
6497
|
+
idle_timeout_sec: params.idle_timeout_sec ?? params.idleTimeoutSec
|
|
6498
|
+
});
|
|
6499
|
+
const data = unwrap38(
|
|
6420
6500
|
await this.http.patch(
|
|
6421
6501
|
`/sandboxes/${this.id}`,
|
|
6422
|
-
|
|
6502
|
+
body2
|
|
6503
|
+
)
|
|
6504
|
+
);
|
|
6505
|
+
this.data = data;
|
|
6506
|
+
return this;
|
|
6507
|
+
}
|
|
6508
|
+
async extend(timeoutSec) {
|
|
6509
|
+
const data = unwrap38(
|
|
6510
|
+
await this.http.post(
|
|
6511
|
+
`/sandboxes/${this.id}/extend`,
|
|
6512
|
+
{ timeout_sec: timeoutSec }
|
|
6423
6513
|
)
|
|
6424
6514
|
);
|
|
6425
6515
|
this.data = data;
|
|
@@ -6439,7 +6529,7 @@ var Sandbox = class _Sandbox {
|
|
|
6439
6529
|
return raw;
|
|
6440
6530
|
}
|
|
6441
6531
|
async pause() {
|
|
6442
|
-
const data =
|
|
6532
|
+
const data = unwrap38(
|
|
6443
6533
|
await this.http.post(
|
|
6444
6534
|
`/sandboxes/${this.id}/pause`,
|
|
6445
6535
|
{}
|
|
@@ -6449,7 +6539,7 @@ var Sandbox = class _Sandbox {
|
|
|
6449
6539
|
return this;
|
|
6450
6540
|
}
|
|
6451
6541
|
async resume() {
|
|
6452
|
-
const data =
|
|
6542
|
+
const data = unwrap38(
|
|
6453
6543
|
await this.http.post(
|
|
6454
6544
|
`/sandboxes/${this.id}/resume`,
|
|
6455
6545
|
{}
|
|
@@ -6462,7 +6552,7 @@ var Sandbox = class _Sandbox {
|
|
|
6462
6552
|
const idempotencyKey11 = params.idempotencyKey ?? params.idempotency_key;
|
|
6463
6553
|
const requestOptions = {
|
|
6464
6554
|
method: "POST",
|
|
6465
|
-
body:
|
|
6555
|
+
body: stripUndefined20({
|
|
6466
6556
|
name: params.name,
|
|
6467
6557
|
deployment_id: params.deploymentId ?? params.deployment_id,
|
|
6468
6558
|
output_path: params.outputPath ?? params.output_path ?? params.path ?? params.sourcePath ?? params.source_path,
|
|
@@ -6474,7 +6564,6 @@ var Sandbox = class _Sandbox {
|
|
|
6474
6564
|
port: params.port,
|
|
6475
6565
|
health_check_path: params.healthCheckPath ?? params.health_check_path,
|
|
6476
6566
|
deployment_type: params.deploymentType ?? params.deployment_type,
|
|
6477
|
-
docker_deploy_template_id: params.dockerDeployTemplateId ?? params.docker_deploy_template_id,
|
|
6478
6567
|
type: params.type,
|
|
6479
6568
|
mode: params.mode,
|
|
6480
6569
|
database: params.database,
|
|
@@ -6486,7 +6575,7 @@ var Sandbox = class _Sandbox {
|
|
|
6486
6575
|
if (idempotencyKey11) {
|
|
6487
6576
|
requestOptions.headers = { "Idempotency-Key": idempotencyKey11 };
|
|
6488
6577
|
}
|
|
6489
|
-
return
|
|
6578
|
+
return unwrap38(
|
|
6490
6579
|
await this.http.request(
|
|
6491
6580
|
`/sandboxes/${this.id}/deploy`,
|
|
6492
6581
|
requestOptions
|
|
@@ -6498,7 +6587,7 @@ var Sandbox = class _Sandbox {
|
|
|
6498
6587
|
}
|
|
6499
6588
|
/** Check readiness of the sandbox (GET /sandboxes/:id/readiness). */
|
|
6500
6589
|
async readiness() {
|
|
6501
|
-
return
|
|
6590
|
+
return unwrap38(
|
|
6502
6591
|
await this.http.get(
|
|
6503
6592
|
`/sandboxes/${this.id}/readiness`
|
|
6504
6593
|
)
|
|
@@ -6628,6 +6717,32 @@ var Sandboxes = class {
|
|
|
6628
6717
|
this.http = http;
|
|
6629
6718
|
}
|
|
6630
6719
|
http;
|
|
6720
|
+
/**
|
|
6721
|
+
* Create a persistent agent workspace.
|
|
6722
|
+
*
|
|
6723
|
+
* This is the preferred entry point for AI builders, coding agents, and
|
|
6724
|
+
* product workspaces. It gives the sandbox a stable name, a longer interactive
|
|
6725
|
+
* timeout, and metadata that makes the workspace easy to identify later. The
|
|
6726
|
+
* agent should create/edit files in `/workspace`, run installs/tests/builds
|
|
6727
|
+
* inside the sandbox, expose previews from the sandbox, and publish from the
|
|
6728
|
+
* sandbox when ready.
|
|
6729
|
+
*/
|
|
6730
|
+
async createAgentWorkspace(params) {
|
|
6731
|
+
const metadata = {
|
|
6732
|
+
...params.metadata ?? {},
|
|
6733
|
+
miosa_workspace_kind: "agent_workspace"
|
|
6734
|
+
};
|
|
6735
|
+
return this.getOrCreate({
|
|
6736
|
+
persistent: true,
|
|
6737
|
+
timeoutSec: AGENT_WORKSPACE_TIMEOUT_SEC,
|
|
6738
|
+
idleTimeoutSec: AGENT_WORKSPACE_IDLE_TIMEOUT_SEC,
|
|
6739
|
+
snapshotExpirationDays: AGENT_WORKSPACE_SNAPSHOT_EXPIRATION_DAYS,
|
|
6740
|
+
keepLastSnapshots: AGENT_WORKSPACE_KEEP_LAST_SNAPSHOTS,
|
|
6741
|
+
waitUntilReady: true,
|
|
6742
|
+
...params,
|
|
6743
|
+
metadata
|
|
6744
|
+
});
|
|
6745
|
+
}
|
|
6631
6746
|
async create(params = {}) {
|
|
6632
6747
|
const idempotencyKey11 = params.idempotencyKey ?? params.idempotency_key;
|
|
6633
6748
|
const requestOptions = {
|
|
@@ -6637,7 +6752,7 @@ var Sandboxes = class {
|
|
|
6637
6752
|
if (idempotencyKey11) {
|
|
6638
6753
|
requestOptions.headers = { "Idempotency-Key": idempotencyKey11 };
|
|
6639
6754
|
}
|
|
6640
|
-
const data =
|
|
6755
|
+
const data = unwrap38(
|
|
6641
6756
|
await this.http.request(
|
|
6642
6757
|
"/sandboxes",
|
|
6643
6758
|
requestOptions
|
|
@@ -6656,7 +6771,7 @@ var Sandboxes = class {
|
|
|
6656
6771
|
return listItems11(data).map((item) => new Sandbox(this.http, item));
|
|
6657
6772
|
}
|
|
6658
6773
|
async get(id) {
|
|
6659
|
-
const data =
|
|
6774
|
+
const data = unwrap38(
|
|
6660
6775
|
await this.http.get(`/sandboxes/${id}`)
|
|
6661
6776
|
);
|
|
6662
6777
|
return new Sandbox(this.http, data);
|
|
@@ -6664,6 +6779,37 @@ var Sandboxes = class {
|
|
|
6664
6779
|
connect(id) {
|
|
6665
6780
|
return this.get(id);
|
|
6666
6781
|
}
|
|
6782
|
+
async getByName(name) {
|
|
6783
|
+
const data = unwrap38(
|
|
6784
|
+
await this.http.get(
|
|
6785
|
+
`/sandboxes/by-name/${encodeURIComponent(name)}`
|
|
6786
|
+
)
|
|
6787
|
+
);
|
|
6788
|
+
return new Sandbox(this.http, data);
|
|
6789
|
+
}
|
|
6790
|
+
/**
|
|
6791
|
+
* Idempotently obtain a persistent sandbox by stable name.
|
|
6792
|
+
*
|
|
6793
|
+
* If the sandbox exists, it is returned. If it is paused and `resume !== false`,
|
|
6794
|
+
* it is resumed first. If it does not exist, it is created with the supplied
|
|
6795
|
+
* params. Destroyed sandboxes are permanent and are not resumed by this helper.
|
|
6796
|
+
*/
|
|
6797
|
+
async getOrCreate(params) {
|
|
6798
|
+
let sandbox;
|
|
6799
|
+
try {
|
|
6800
|
+
sandbox = await this.getByName(params.name);
|
|
6801
|
+
} catch (error) {
|
|
6802
|
+
if (!(error instanceof NotFoundError)) throw error;
|
|
6803
|
+
sandbox = await this.create(params);
|
|
6804
|
+
}
|
|
6805
|
+
if (sandbox.state === "paused" && params.resume !== false) {
|
|
6806
|
+
await sandbox.resume();
|
|
6807
|
+
}
|
|
6808
|
+
if (params.waitUntilReady === true) {
|
|
6809
|
+
await sandbox.waitUntilReady({ timeout: params.waitTimeoutSec ?? 60 });
|
|
6810
|
+
}
|
|
6811
|
+
return sandbox;
|
|
6812
|
+
}
|
|
6667
6813
|
async delete(id) {
|
|
6668
6814
|
await this.http.delete(`/sandboxes/${id}`);
|
|
6669
6815
|
}
|
|
@@ -6691,7 +6837,7 @@ var Sandboxes = class {
|
|
|
6691
6837
|
async createTemplate(params) {
|
|
6692
6838
|
const response = await this.http.post(
|
|
6693
6839
|
"/sandbox-templates",
|
|
6694
|
-
|
|
6840
|
+
stripUndefined20({
|
|
6695
6841
|
name: params.name,
|
|
6696
6842
|
slug: params.slug,
|
|
6697
6843
|
description: params.description,
|
|
@@ -6699,29 +6845,29 @@ var Sandboxes = class {
|
|
|
6699
6845
|
metadata: params.metadata
|
|
6700
6846
|
})
|
|
6701
6847
|
);
|
|
6702
|
-
return
|
|
6848
|
+
return unwrap38(response);
|
|
6703
6849
|
}
|
|
6704
6850
|
async createTemplateBuild(templateId, params = {}) {
|
|
6705
6851
|
const response = await this.http.post(
|
|
6706
6852
|
`/sandbox-templates/${templateId}/builds`,
|
|
6707
|
-
|
|
6853
|
+
stripUndefined20({
|
|
6708
6854
|
build_spec: params.buildSpec ?? params.build_spec,
|
|
6709
6855
|
metadata: params.metadata
|
|
6710
6856
|
})
|
|
6711
6857
|
);
|
|
6712
|
-
return
|
|
6858
|
+
return unwrap38(response);
|
|
6713
6859
|
}
|
|
6714
6860
|
async listTemplateBuilds(templateId) {
|
|
6715
6861
|
const response = await this.http.get(
|
|
6716
6862
|
`/sandbox-templates/${templateId}/builds`
|
|
6717
6863
|
);
|
|
6718
|
-
return
|
|
6864
|
+
return unwrap38(response);
|
|
6719
6865
|
}
|
|
6720
6866
|
async getTemplateBuild(buildId) {
|
|
6721
6867
|
const response = await this.http.get(
|
|
6722
6868
|
`/sandbox-template-builds/${buildId}`
|
|
6723
6869
|
);
|
|
6724
|
-
return
|
|
6870
|
+
return unwrap38(response);
|
|
6725
6871
|
}
|
|
6726
6872
|
};
|
|
6727
6873
|
function toBase642(bytes) {
|
|
@@ -6733,7 +6879,7 @@ function toBase642(bytes) {
|
|
|
6733
6879
|
}
|
|
6734
6880
|
return btoa(binary);
|
|
6735
6881
|
}
|
|
6736
|
-
function
|
|
6882
|
+
function unwrap39(payload) {
|
|
6737
6883
|
if (payload && typeof payload === "object" && "data" in payload) {
|
|
6738
6884
|
return payload.data;
|
|
6739
6885
|
}
|
|
@@ -6749,7 +6895,7 @@ function listItems12(payload, candidateKeys = ["data", "templates", "builds", "i
|
|
|
6749
6895
|
}
|
|
6750
6896
|
return [];
|
|
6751
6897
|
}
|
|
6752
|
-
function
|
|
6898
|
+
function stripUndefined21(input) {
|
|
6753
6899
|
return Object.fromEntries(
|
|
6754
6900
|
Object.entries(input).filter(([, v]) => v !== void 0)
|
|
6755
6901
|
);
|
|
@@ -6776,7 +6922,7 @@ var SandboxTemplates = class {
|
|
|
6776
6922
|
const data = await this.http.get(
|
|
6777
6923
|
`/sandbox-templates/${templateId}`
|
|
6778
6924
|
);
|
|
6779
|
-
return
|
|
6925
|
+
return unwrap39(data);
|
|
6780
6926
|
}
|
|
6781
6927
|
async create(params) {
|
|
6782
6928
|
const {
|
|
@@ -6786,17 +6932,17 @@ var SandboxTemplates = class {
|
|
|
6786
6932
|
name,
|
|
6787
6933
|
...rest
|
|
6788
6934
|
} = params;
|
|
6789
|
-
const
|
|
6935
|
+
const body2 = stripUndefined21({
|
|
6790
6936
|
name,
|
|
6791
6937
|
build_spec: buildSpec ?? build_spec,
|
|
6792
6938
|
...rest
|
|
6793
6939
|
});
|
|
6794
6940
|
const data = await this.http.request("/sandbox-templates", {
|
|
6795
6941
|
method: "POST",
|
|
6796
|
-
body,
|
|
6942
|
+
body: body2,
|
|
6797
6943
|
headers: { "Idempotency-Key": idempotencyKey8(ikey) }
|
|
6798
6944
|
});
|
|
6799
|
-
return
|
|
6945
|
+
return unwrap39(data);
|
|
6800
6946
|
}
|
|
6801
6947
|
async buildSpecSchema() {
|
|
6802
6948
|
const data = await this.http.get("/sandbox-templates/build-spec");
|
|
@@ -6820,21 +6966,21 @@ var SandboxTemplates = class {
|
|
|
6820
6966
|
}
|
|
6821
6967
|
async createBuild(templateId, params = {}) {
|
|
6822
6968
|
const { idempotencyKey: ikey, ...rest } = params;
|
|
6823
|
-
const
|
|
6969
|
+
const body2 = stripUndefined21(rest);
|
|
6824
6970
|
const data = await this.http.request(
|
|
6825
6971
|
`/sandbox-templates/${templateId}/builds`,
|
|
6826
6972
|
{
|
|
6827
6973
|
method: "POST",
|
|
6828
|
-
body,
|
|
6974
|
+
body: body2,
|
|
6829
6975
|
headers: { "Idempotency-Key": idempotencyKey8(ikey) }
|
|
6830
6976
|
}
|
|
6831
6977
|
);
|
|
6832
|
-
return
|
|
6978
|
+
return unwrap39(data);
|
|
6833
6979
|
}
|
|
6834
6980
|
};
|
|
6835
6981
|
|
|
6836
6982
|
// src/resources/settings.ts
|
|
6837
|
-
function
|
|
6983
|
+
function unwrap40(payload) {
|
|
6838
6984
|
if (payload && typeof payload === "object") {
|
|
6839
6985
|
const p = payload;
|
|
6840
6986
|
for (const k of [
|
|
@@ -6850,11 +6996,11 @@ function unwrap38(payload) {
|
|
|
6850
6996
|
return payload;
|
|
6851
6997
|
}
|
|
6852
6998
|
function listItems13(payload) {
|
|
6853
|
-
const result =
|
|
6999
|
+
const result = unwrap40(payload);
|
|
6854
7000
|
if (Array.isArray(result)) return result;
|
|
6855
7001
|
return [];
|
|
6856
7002
|
}
|
|
6857
|
-
function
|
|
7003
|
+
function stripUndefined22(input) {
|
|
6858
7004
|
return Object.fromEntries(
|
|
6859
7005
|
Object.entries(input).filter(([, v]) => v !== void 0)
|
|
6860
7006
|
);
|
|
@@ -6867,46 +7013,46 @@ var Settings = class {
|
|
|
6867
7013
|
/** Get the current tenant settings. */
|
|
6868
7014
|
async get() {
|
|
6869
7015
|
const data = await this.http.get("/settings");
|
|
6870
|
-
return
|
|
7016
|
+
return unwrap40(data);
|
|
6871
7017
|
}
|
|
6872
7018
|
/** Update tenant settings. */
|
|
6873
7019
|
async update(params) {
|
|
6874
|
-
const
|
|
6875
|
-
const data = await this.http.put("/settings",
|
|
6876
|
-
return
|
|
7020
|
+
const body2 = stripUndefined22(params);
|
|
7021
|
+
const data = await this.http.put("/settings", body2);
|
|
7022
|
+
return unwrap40(data);
|
|
6877
7023
|
}
|
|
6878
7024
|
// ── Branding ──────────────────────────────────────────────────────────────
|
|
6879
7025
|
/** Get tenant branding (logo, colors, custom wordmark). */
|
|
6880
7026
|
async getBranding() {
|
|
6881
7027
|
const data = await this.http.get("/settings/branding");
|
|
6882
|
-
return
|
|
7028
|
+
return unwrap40(data);
|
|
6883
7029
|
}
|
|
6884
7030
|
/** Update tenant branding. */
|
|
6885
7031
|
async updateBranding(params) {
|
|
6886
|
-
const
|
|
6887
|
-
const data = await this.http.put("/settings/branding",
|
|
6888
|
-
return
|
|
7032
|
+
const body2 = stripUndefined22(params);
|
|
7033
|
+
const data = await this.http.put("/settings/branding", body2);
|
|
7034
|
+
return unwrap40(data);
|
|
6889
7035
|
}
|
|
6890
7036
|
// ── Read-only reference data ───────────────────────────────────────────────
|
|
6891
7037
|
/** Get tenant-scoped compute pricing. */
|
|
6892
7038
|
async computePricing() {
|
|
6893
7039
|
const data = await this.http.get("/settings/compute-pricing");
|
|
6894
|
-
return
|
|
7040
|
+
return unwrap40(data);
|
|
6895
7041
|
}
|
|
6896
7042
|
/** Get tenant-scoped GPU pricing. */
|
|
6897
7043
|
async gpuPricing() {
|
|
6898
7044
|
const data = await this.http.get("/settings/gpu-pricing");
|
|
6899
|
-
return
|
|
7045
|
+
return unwrap40(data);
|
|
6900
7046
|
}
|
|
6901
7047
|
/** List models available to this tenant. */
|
|
6902
7048
|
async availableModels() {
|
|
6903
7049
|
const data = await this.http.get("/settings/available-models");
|
|
6904
|
-
return
|
|
7050
|
+
return unwrap40(data);
|
|
6905
7051
|
}
|
|
6906
7052
|
/** List regions enabled for this tenant. */
|
|
6907
7053
|
async regions() {
|
|
6908
7054
|
const data = await this.http.get("/settings/regions");
|
|
6909
|
-
return
|
|
7055
|
+
return unwrap40(data);
|
|
6910
7056
|
}
|
|
6911
7057
|
// ── BYOK provider keys ────────────────────────────────────────────────────
|
|
6912
7058
|
/** List tenant-level BYOK provider keys (Anthropic, OpenAI, etc.). */
|
|
@@ -6916,12 +7062,12 @@ var Settings = class {
|
|
|
6916
7062
|
}
|
|
6917
7063
|
/** Create or update a BYOK provider key. */
|
|
6918
7064
|
async upsertProviderKey(provider, params) {
|
|
6919
|
-
const
|
|
7065
|
+
const body2 = stripUndefined22(params);
|
|
6920
7066
|
const data = await this.http.put(
|
|
6921
7067
|
`/settings/provider-keys/${provider}`,
|
|
6922
|
-
|
|
7068
|
+
body2
|
|
6923
7069
|
);
|
|
6924
|
-
return
|
|
7070
|
+
return unwrap40(data);
|
|
6925
7071
|
}
|
|
6926
7072
|
/** Delete a BYOK provider key. */
|
|
6927
7073
|
async deleteProviderKey(provider) {
|
|
@@ -6930,7 +7076,7 @@ var Settings = class {
|
|
|
6930
7076
|
};
|
|
6931
7077
|
|
|
6932
7078
|
// src/resources/snapshots-standalone.ts
|
|
6933
|
-
function
|
|
7079
|
+
function unwrap41(data) {
|
|
6934
7080
|
if (data && typeof data === "object") {
|
|
6935
7081
|
const d = data;
|
|
6936
7082
|
for (const k of ["data", "snapshots", "items"]) {
|
|
@@ -6939,7 +7085,7 @@ function unwrap39(data) {
|
|
|
6939
7085
|
}
|
|
6940
7086
|
return data;
|
|
6941
7087
|
}
|
|
6942
|
-
function
|
|
7088
|
+
function unwrapList12(data) {
|
|
6943
7089
|
if (Array.isArray(data)) return data;
|
|
6944
7090
|
if (data && typeof data === "object") {
|
|
6945
7091
|
const d = data;
|
|
@@ -6958,17 +7104,17 @@ var SnapshotsStandalone = class {
|
|
|
6958
7104
|
const query = Object.fromEntries(
|
|
6959
7105
|
Object.entries(filters).filter(([, v]) => v !== void 0)
|
|
6960
7106
|
);
|
|
6961
|
-
return
|
|
7107
|
+
return unwrapList12(await this.http.get("/admin/snapshots", query));
|
|
6962
7108
|
}
|
|
6963
7109
|
async get(snapshotId) {
|
|
6964
|
-
return
|
|
7110
|
+
return unwrap41(
|
|
6965
7111
|
await this.http.get(`/admin/snapshots/${snapshotId}`)
|
|
6966
7112
|
);
|
|
6967
7113
|
}
|
|
6968
7114
|
};
|
|
6969
7115
|
|
|
6970
7116
|
// src/resources/storage.ts
|
|
6971
|
-
function
|
|
7117
|
+
function unwrap42(payload) {
|
|
6972
7118
|
if (payload && typeof payload === "object" && "data" in payload) {
|
|
6973
7119
|
return payload.data;
|
|
6974
7120
|
}
|
|
@@ -6984,7 +7130,7 @@ function listItems14(payload, candidateKeys = ["data", "buckets", "objects", "it
|
|
|
6984
7130
|
}
|
|
6985
7131
|
return [];
|
|
6986
7132
|
}
|
|
6987
|
-
function
|
|
7133
|
+
function stripUndefined23(input) {
|
|
6988
7134
|
return Object.fromEntries(
|
|
6989
7135
|
Object.entries(input).filter(([, v]) => v !== void 0)
|
|
6990
7136
|
);
|
|
@@ -7001,24 +7147,24 @@ var Storage = class {
|
|
|
7001
7147
|
}
|
|
7002
7148
|
async createBucket(params) {
|
|
7003
7149
|
const { name, public: isPublic, visibility, ...rest } = params;
|
|
7004
|
-
const
|
|
7150
|
+
const body2 = stripUndefined23({
|
|
7005
7151
|
name,
|
|
7006
7152
|
visibility: visibility ?? (isPublic === void 0 ? void 0 : isPublic ? "public" : "private"),
|
|
7007
7153
|
...rest
|
|
7008
7154
|
});
|
|
7009
|
-
const data = await this.http.post("/storage/buckets",
|
|
7010
|
-
return
|
|
7155
|
+
const data = await this.http.post("/storage/buckets", body2);
|
|
7156
|
+
return unwrap42(data);
|
|
7011
7157
|
}
|
|
7012
7158
|
async getBucket(bucketId) {
|
|
7013
7159
|
const data = await this.http.get(`/storage/buckets/${bucketId}`);
|
|
7014
|
-
return
|
|
7160
|
+
return unwrap42(data);
|
|
7015
7161
|
}
|
|
7016
7162
|
async deleteBucket(bucketId) {
|
|
7017
7163
|
await this.http.delete(`/storage/buckets/${bucketId}`);
|
|
7018
7164
|
}
|
|
7019
7165
|
// ── Objects ────────────────────────────────────────────────────────────────
|
|
7020
7166
|
async listObjects(bucketId, params = {}) {
|
|
7021
|
-
const query =
|
|
7167
|
+
const query = stripUndefined23({
|
|
7022
7168
|
prefix: params.prefix,
|
|
7023
7169
|
max_keys: params.max_keys ?? params.maxKeys ?? params.limit,
|
|
7024
7170
|
marker: params.marker ?? params.cursor
|
|
@@ -7052,16 +7198,16 @@ var Storage = class {
|
|
|
7052
7198
|
// ── Presigned URLs ─────────────────────────────────────────────────────────
|
|
7053
7199
|
async presign(bucketId, params) {
|
|
7054
7200
|
const operationMethod = params.operation === "put" ? "PUT" : params.operation === "get" ? "GET" : void 0;
|
|
7055
|
-
const
|
|
7201
|
+
const body2 = stripUndefined23({
|
|
7056
7202
|
key: params.key,
|
|
7057
7203
|
method: params.method ?? operationMethod ?? "GET",
|
|
7058
7204
|
expires_in: params.expiresIn ?? params.expires_in ?? params.expiresInSec ?? params.expires_in_sec ?? 3600
|
|
7059
7205
|
});
|
|
7060
7206
|
const data = await this.http.post(
|
|
7061
7207
|
`/storage/buckets/${bucketId}/presign`,
|
|
7062
|
-
|
|
7208
|
+
body2
|
|
7063
7209
|
);
|
|
7064
|
-
return
|
|
7210
|
+
return unwrap42(data);
|
|
7065
7211
|
}
|
|
7066
7212
|
};
|
|
7067
7213
|
|
|
@@ -7151,29 +7297,105 @@ var OrgInvites = class {
|
|
|
7151
7297
|
};
|
|
7152
7298
|
|
|
7153
7299
|
// src/resources/tenant.ts
|
|
7154
|
-
function
|
|
7300
|
+
function unwrap43(payload) {
|
|
7155
7301
|
if (payload && typeof payload === "object") {
|
|
7156
7302
|
const p = payload;
|
|
7157
|
-
for (const k of ["data", "tenant", "items"]) {
|
|
7303
|
+
for (const k of ["data", "tenant", "branding", "items"]) {
|
|
7158
7304
|
if (k in p) return p[k];
|
|
7159
7305
|
}
|
|
7160
7306
|
}
|
|
7161
7307
|
return payload;
|
|
7162
7308
|
}
|
|
7309
|
+
function stripUndefined24(input) {
|
|
7310
|
+
return Object.fromEntries(
|
|
7311
|
+
Object.entries(input).filter(([, v]) => v !== void 0)
|
|
7312
|
+
);
|
|
7313
|
+
}
|
|
7314
|
+
var PreviewDomain = class {
|
|
7315
|
+
constructor(http) {
|
|
7316
|
+
this.http = http;
|
|
7317
|
+
}
|
|
7318
|
+
http;
|
|
7319
|
+
/** Get the tenant's white-label preview domain settings. */
|
|
7320
|
+
async get() {
|
|
7321
|
+
const data = await this.http.get("/tenant/preview-domain");
|
|
7322
|
+
return unwrap43(data);
|
|
7323
|
+
}
|
|
7324
|
+
/** Set the tenant's white-label preview domain. */
|
|
7325
|
+
async set(domain) {
|
|
7326
|
+
const data = await this.http.put("/tenant/preview-domain", {
|
|
7327
|
+
preview_domain: domain
|
|
7328
|
+
});
|
|
7329
|
+
return unwrap43(data);
|
|
7330
|
+
}
|
|
7331
|
+
/** Re-run DNS verification for the configured preview domain. */
|
|
7332
|
+
async verify() {
|
|
7333
|
+
const data = await this.http.post(
|
|
7334
|
+
"/tenant/preview-domain/verify",
|
|
7335
|
+
{}
|
|
7336
|
+
);
|
|
7337
|
+
return unwrap43(data);
|
|
7338
|
+
}
|
|
7339
|
+
/** Remove the tenant's custom preview domain. */
|
|
7340
|
+
async delete() {
|
|
7341
|
+
await this.http.delete("/tenant/preview-domain");
|
|
7342
|
+
}
|
|
7343
|
+
};
|
|
7344
|
+
var Branding = class {
|
|
7345
|
+
constructor(http) {
|
|
7346
|
+
this.http = http;
|
|
7347
|
+
}
|
|
7348
|
+
http;
|
|
7349
|
+
/** Get tenant branding used by white-label hosted surfaces. */
|
|
7350
|
+
async get() {
|
|
7351
|
+
const data = await this.http.get("/tenant/branding");
|
|
7352
|
+
return unwrap43(data);
|
|
7353
|
+
}
|
|
7354
|
+
/** Update tenant branding used by white-label hosted surfaces. */
|
|
7355
|
+
async set(params) {
|
|
7356
|
+
const data = await this.http.put("/tenant/branding", {
|
|
7357
|
+
branding: stripUndefined24(params)
|
|
7358
|
+
});
|
|
7359
|
+
return unwrap43(data);
|
|
7360
|
+
}
|
|
7361
|
+
/** Reset tenant branding to platform defaults. */
|
|
7362
|
+
async delete() {
|
|
7363
|
+
await this.http.delete("/tenant/branding");
|
|
7364
|
+
}
|
|
7365
|
+
};
|
|
7163
7366
|
var Tenant = class {
|
|
7164
7367
|
constructor(http) {
|
|
7165
7368
|
this.http = http;
|
|
7369
|
+
this.preview_domain = new PreviewDomain(http);
|
|
7370
|
+
this.previewDomain = this.preview_domain;
|
|
7371
|
+
this.branding = new Branding(http);
|
|
7166
7372
|
}
|
|
7167
7373
|
http;
|
|
7374
|
+
preview_domain;
|
|
7375
|
+
branding;
|
|
7376
|
+
/** camelCase alias for SDK consumers that avoid snake_case properties. */
|
|
7377
|
+
previewDomain;
|
|
7168
7378
|
/** Get the current tenant's plan, limits, and live usage counters. */
|
|
7169
7379
|
async current() {
|
|
7170
7380
|
const data = await this.http.get("/tenant/plan");
|
|
7171
|
-
return
|
|
7381
|
+
return unwrap43(data);
|
|
7382
|
+
}
|
|
7383
|
+
/** Convenience alias for `tenant.branding.get()`. */
|
|
7384
|
+
async getBranding() {
|
|
7385
|
+
return this.branding.get();
|
|
7386
|
+
}
|
|
7387
|
+
/** Convenience alias for `tenant.branding.set(...)`. */
|
|
7388
|
+
async setBranding(params) {
|
|
7389
|
+
return this.branding.set(params);
|
|
7390
|
+
}
|
|
7391
|
+
/** Convenience alias for `tenant.branding.delete()`. */
|
|
7392
|
+
async deleteBranding() {
|
|
7393
|
+
await this.branding.delete();
|
|
7172
7394
|
}
|
|
7173
7395
|
};
|
|
7174
7396
|
|
|
7175
7397
|
// src/resources/usage.ts
|
|
7176
|
-
function
|
|
7398
|
+
function unwrap44(payload) {
|
|
7177
7399
|
if (payload && typeof payload === "object") {
|
|
7178
7400
|
const p = payload;
|
|
7179
7401
|
for (const k of ["data", "usage", "sessions", "summary", "items"]) {
|
|
@@ -7182,7 +7404,7 @@ function unwrap42(payload) {
|
|
|
7182
7404
|
}
|
|
7183
7405
|
return payload;
|
|
7184
7406
|
}
|
|
7185
|
-
function
|
|
7407
|
+
function stripUndefined25(input) {
|
|
7186
7408
|
return Object.fromEntries(
|
|
7187
7409
|
Object.entries(input).filter(([, v]) => v !== void 0)
|
|
7188
7410
|
);
|
|
@@ -7195,24 +7417,24 @@ var Usage = class {
|
|
|
7195
7417
|
/** Get the current period usage summary. */
|
|
7196
7418
|
async current() {
|
|
7197
7419
|
const data = await this.http.get("/usage/summary");
|
|
7198
|
-
return
|
|
7420
|
+
return unwrap44(data);
|
|
7199
7421
|
}
|
|
7200
7422
|
/** List per-session metering events. */
|
|
7201
7423
|
async sessions(params = {}) {
|
|
7202
|
-
const query =
|
|
7424
|
+
const query = stripUndefined25(params);
|
|
7203
7425
|
const data = await this.http.get("/usage/sessions", query);
|
|
7204
|
-
const result =
|
|
7426
|
+
const result = unwrap44(data);
|
|
7205
7427
|
if (Array.isArray(result)) return result;
|
|
7206
7428
|
return [];
|
|
7207
7429
|
}
|
|
7208
7430
|
/** Get a usage report for a period. */
|
|
7209
7431
|
async report(params = {}) {
|
|
7210
|
-
const query =
|
|
7432
|
+
const query = stripUndefined25(params);
|
|
7211
7433
|
const data = await this.http.get("/usage/summary", query);
|
|
7212
|
-
return
|
|
7434
|
+
return unwrap44(data);
|
|
7213
7435
|
}
|
|
7214
7436
|
};
|
|
7215
|
-
function
|
|
7437
|
+
function unwrap45(payload) {
|
|
7216
7438
|
if (payload && typeof payload === "object" && "data" in payload) {
|
|
7217
7439
|
return payload.data;
|
|
7218
7440
|
}
|
|
@@ -7228,7 +7450,7 @@ function listItems15(payload, candidateKeys = ["data", "volumes", "items"]) {
|
|
|
7228
7450
|
}
|
|
7229
7451
|
return [];
|
|
7230
7452
|
}
|
|
7231
|
-
function
|
|
7453
|
+
function stripUndefined26(input) {
|
|
7232
7454
|
return Object.fromEntries(
|
|
7233
7455
|
Object.entries(input).filter(([, v]) => v !== void 0)
|
|
7234
7456
|
);
|
|
@@ -7242,32 +7464,32 @@ var Volumes = class {
|
|
|
7242
7464
|
}
|
|
7243
7465
|
http;
|
|
7244
7466
|
async list(params = {}) {
|
|
7245
|
-
const query =
|
|
7467
|
+
const query = stripUndefined26({ ...params });
|
|
7246
7468
|
const data = await this.http.get("/volumes", query);
|
|
7247
7469
|
return listItems15(data);
|
|
7248
7470
|
}
|
|
7249
7471
|
async get(volumeId) {
|
|
7250
7472
|
const data = await this.http.get(`/volumes/${volumeId}`);
|
|
7251
|
-
return
|
|
7473
|
+
return unwrap45(data);
|
|
7252
7474
|
}
|
|
7253
7475
|
async create(params) {
|
|
7254
7476
|
const { idempotencyKey: ikey, sizeGb, ...rest } = params;
|
|
7255
|
-
const
|
|
7477
|
+
const body2 = stripUndefined26({
|
|
7256
7478
|
...rest,
|
|
7257
7479
|
size_gb: sizeGb ?? rest.size_gb
|
|
7258
7480
|
});
|
|
7259
7481
|
const data = await this.http.request("/volumes", {
|
|
7260
7482
|
method: "POST",
|
|
7261
|
-
body,
|
|
7483
|
+
body: body2,
|
|
7262
7484
|
headers: { "Idempotency-Key": idempotencyKey9(ikey) }
|
|
7263
7485
|
});
|
|
7264
|
-
return
|
|
7486
|
+
return unwrap45(data);
|
|
7265
7487
|
}
|
|
7266
7488
|
async delete(volumeId) {
|
|
7267
7489
|
await this.http.delete(`/volumes/${volumeId}`);
|
|
7268
7490
|
}
|
|
7269
7491
|
};
|
|
7270
|
-
function
|
|
7492
|
+
function unwrap46(payload) {
|
|
7271
7493
|
if (payload && typeof payload === "object" && "data" in payload) {
|
|
7272
7494
|
return payload.data;
|
|
7273
7495
|
}
|
|
@@ -7283,7 +7505,7 @@ function listItems16(payload, candidateKeys = ["data", "webhooks", "deliveries",
|
|
|
7283
7505
|
}
|
|
7284
7506
|
return [];
|
|
7285
7507
|
}
|
|
7286
|
-
function
|
|
7508
|
+
function stripUndefined27(input) {
|
|
7287
7509
|
return Object.fromEntries(
|
|
7288
7510
|
Object.entries(input).filter(([, v]) => v !== void 0)
|
|
7289
7511
|
);
|
|
@@ -7291,43 +7513,35 @@ function stripUndefined25(input) {
|
|
|
7291
7513
|
function idempotencyKey10(key) {
|
|
7292
7514
|
return key ?? randomUUID();
|
|
7293
7515
|
}
|
|
7294
|
-
function
|
|
7295
|
-
|
|
7296
|
-
|
|
7297
|
-
|
|
7298
|
-
|
|
7299
|
-
|
|
7300
|
-
|
|
7301
|
-
|
|
7302
|
-
|
|
7303
|
-
|
|
7304
|
-
|
|
7305
|
-
|
|
7306
|
-
|
|
7516
|
+
function bodyBuffer(body2) {
|
|
7517
|
+
if (Buffer.isBuffer(body2)) return body2;
|
|
7518
|
+
if (typeof body2 === "string") return Buffer.from(body2, "utf8");
|
|
7519
|
+
return Buffer.from(body2);
|
|
7520
|
+
}
|
|
7521
|
+
function verifySignature(body2, header, secret, toleranceSec = 300) {
|
|
7522
|
+
const parts = Object.fromEntries(
|
|
7523
|
+
header.split(",").map((chunk) => chunk.split("=", 2)).filter(([key, value]) => key && value)
|
|
7524
|
+
);
|
|
7525
|
+
const timestamp = parts.t;
|
|
7526
|
+
const received = parts.v1;
|
|
7527
|
+
if (!timestamp || !received || !secret) return false;
|
|
7528
|
+
const unixSeconds = Number(timestamp);
|
|
7529
|
+
if (!Number.isFinite(unixSeconds)) return false;
|
|
7530
|
+
const ageSec = Math.abs(Date.now() / 1e3 - unixSeconds);
|
|
7531
|
+
if (ageSec > toleranceSec) {
|
|
7532
|
+
throw new Error("webhook timestamp too old");
|
|
7533
|
+
}
|
|
7534
|
+
const rawBody = bodyBuffer(body2);
|
|
7535
|
+
const signed = Buffer.concat([Buffer.from(`${timestamp}.`), rawBody]);
|
|
7536
|
+
const expected = createHmac("sha256", secret).update(signed).digest("hex");
|
|
7537
|
+
try {
|
|
7538
|
+
return timingSafeEqual(
|
|
7539
|
+
Buffer.from(expected, "utf8"),
|
|
7540
|
+
Buffer.from(received, "utf8")
|
|
7541
|
+
);
|
|
7542
|
+
} catch {
|
|
7543
|
+
return false;
|
|
7307
7544
|
}
|
|
7308
|
-
if (timestamp == null || signatures.length === 0) return null;
|
|
7309
|
-
return { timestamp, signatures };
|
|
7310
|
-
}
|
|
7311
|
-
function verifySignature(body, header, secret, options = {}) {
|
|
7312
|
-
const parsed = parseSignatureHeader(header);
|
|
7313
|
-
if (!parsed) return false;
|
|
7314
|
-
const toleranceSeconds = options.toleranceSeconds ?? 300;
|
|
7315
|
-
const ageSeconds = Math.abs(Math.floor(Date.now() / 1e3) - parsed.timestamp);
|
|
7316
|
-
if (ageSeconds > toleranceSeconds) {
|
|
7317
|
-
throw new Error("Webhook signature timestamp is too old");
|
|
7318
|
-
}
|
|
7319
|
-
const bodyBuffer = Buffer.isBuffer(body) ? body : Buffer.from(body);
|
|
7320
|
-
const signedPayload = Buffer.concat([
|
|
7321
|
-
Buffer.from(`${parsed.timestamp}.`),
|
|
7322
|
-
bodyBuffer
|
|
7323
|
-
]);
|
|
7324
|
-
const expected = createHmac("sha256", secret).update(signedPayload).digest("hex");
|
|
7325
|
-
const expectedBuffer = Buffer.from(expected, "hex");
|
|
7326
|
-
return parsed.signatures.some((signature) => {
|
|
7327
|
-
const actualBuffer = Buffer.from(signature, "hex");
|
|
7328
|
-
if (actualBuffer.length !== expectedBuffer.length) return false;
|
|
7329
|
-
return timingSafeEqual(actualBuffer, expectedBuffer);
|
|
7330
|
-
});
|
|
7331
7545
|
}
|
|
7332
7546
|
var Webhooks = class {
|
|
7333
7547
|
constructor(http) {
|
|
@@ -7335,30 +7549,29 @@ var Webhooks = class {
|
|
|
7335
7549
|
}
|
|
7336
7550
|
http;
|
|
7337
7551
|
static verifySignature = verifySignature;
|
|
7338
|
-
static verify_signature = verifySignature;
|
|
7339
7552
|
async list(params = {}) {
|
|
7340
|
-
const query =
|
|
7553
|
+
const query = stripUndefined27({ ...params });
|
|
7341
7554
|
const data = await this.http.get("/webhooks", query);
|
|
7342
7555
|
return listItems16(data);
|
|
7343
7556
|
}
|
|
7344
7557
|
async get(webhookId) {
|
|
7345
7558
|
const data = await this.http.get(`/webhooks/${webhookId}`);
|
|
7346
|
-
return
|
|
7559
|
+
return unwrap46(data);
|
|
7347
7560
|
}
|
|
7348
7561
|
async create(params) {
|
|
7349
7562
|
const { idempotencyKey: ikey, ...rest } = params;
|
|
7350
|
-
const
|
|
7563
|
+
const body2 = stripUndefined27(rest);
|
|
7351
7564
|
const data = await this.http.request("/webhooks", {
|
|
7352
7565
|
method: "POST",
|
|
7353
|
-
body,
|
|
7566
|
+
body: body2,
|
|
7354
7567
|
headers: { "Idempotency-Key": idempotencyKey10(ikey) }
|
|
7355
7568
|
});
|
|
7356
|
-
return
|
|
7569
|
+
return unwrap46(data);
|
|
7357
7570
|
}
|
|
7358
7571
|
async update(webhookId, params) {
|
|
7359
|
-
const
|
|
7360
|
-
const data = await this.http.patch(`/webhooks/${webhookId}`,
|
|
7361
|
-
return
|
|
7572
|
+
const body2 = stripUndefined27(params);
|
|
7573
|
+
const data = await this.http.patch(`/webhooks/${webhookId}`, body2);
|
|
7574
|
+
return unwrap46(data);
|
|
7362
7575
|
}
|
|
7363
7576
|
async delete(webhookId) {
|
|
7364
7577
|
await this.http.delete(`/webhooks/${webhookId}`);
|
|
@@ -7371,7 +7584,7 @@ var Webhooks = class {
|
|
|
7371
7584
|
headers: { "Idempotency-Key": idempotencyKey10(opts.idempotencyKey) }
|
|
7372
7585
|
}
|
|
7373
7586
|
);
|
|
7374
|
-
return
|
|
7587
|
+
return unwrap46(data);
|
|
7375
7588
|
}
|
|
7376
7589
|
async deliveries(webhookId) {
|
|
7377
7590
|
const data = await this.http.get(
|
|
@@ -7400,9 +7613,9 @@ var WorkspaceInvites = class {
|
|
|
7400
7613
|
*
|
|
7401
7614
|
* `POST /workspaces/:id/invites`
|
|
7402
7615
|
*/
|
|
7403
|
-
async create(
|
|
7616
|
+
async create(workspaceId2, params) {
|
|
7404
7617
|
return this.http.post(
|
|
7405
|
-
`/workspaces/${
|
|
7618
|
+
`/workspaces/${workspaceId2}/invites`,
|
|
7406
7619
|
params
|
|
7407
7620
|
);
|
|
7408
7621
|
}
|
|
@@ -7411,9 +7624,9 @@ var WorkspaceInvites = class {
|
|
|
7411
7624
|
*
|
|
7412
7625
|
* `GET /workspaces/:id/invites`
|
|
7413
7626
|
*/
|
|
7414
|
-
async list(
|
|
7627
|
+
async list(workspaceId2) {
|
|
7415
7628
|
const res = await this.http.get(
|
|
7416
|
-
`/workspaces/${
|
|
7629
|
+
`/workspaces/${workspaceId2}/invites`
|
|
7417
7630
|
);
|
|
7418
7631
|
return res.data ?? [];
|
|
7419
7632
|
}
|
|
@@ -7425,9 +7638,9 @@ var WorkspaceInvites = class {
|
|
|
7425
7638
|
*
|
|
7426
7639
|
* `DELETE /workspaces/:id/invites/:invite_id`
|
|
7427
7640
|
*/
|
|
7428
|
-
async revoke(
|
|
7641
|
+
async revoke(workspaceId2, inviteId) {
|
|
7429
7642
|
return this.http.delete(
|
|
7430
|
-
`/workspaces/${
|
|
7643
|
+
`/workspaces/${workspaceId2}/invites/${inviteId}`
|
|
7431
7644
|
);
|
|
7432
7645
|
}
|
|
7433
7646
|
/**
|
|
@@ -7481,9 +7694,9 @@ var WorkspaceMembers = class {
|
|
|
7481
7694
|
*
|
|
7482
7695
|
* `GET /workspaces/:id/members`
|
|
7483
7696
|
*/
|
|
7484
|
-
async list(
|
|
7697
|
+
async list(workspaceId2) {
|
|
7485
7698
|
const res = await this.http.get(
|
|
7486
|
-
`/workspaces/${
|
|
7699
|
+
`/workspaces/${workspaceId2}/members`
|
|
7487
7700
|
);
|
|
7488
7701
|
return res.data ?? res;
|
|
7489
7702
|
}
|
|
@@ -7499,9 +7712,9 @@ var WorkspaceMembers = class {
|
|
|
7499
7712
|
* @throws `MiosaError` with code `NOT_TENANT_MEMBER` if the user is not an
|
|
7500
7713
|
* org member.
|
|
7501
7714
|
*/
|
|
7502
|
-
async add(
|
|
7715
|
+
async add(workspaceId2, params) {
|
|
7503
7716
|
const res = await this.http.post(
|
|
7504
|
-
`/workspaces/${
|
|
7717
|
+
`/workspaces/${workspaceId2}/members`,
|
|
7505
7718
|
params
|
|
7506
7719
|
);
|
|
7507
7720
|
return res.data ?? res;
|
|
@@ -7511,9 +7724,9 @@ var WorkspaceMembers = class {
|
|
|
7511
7724
|
*
|
|
7512
7725
|
* `PATCH /workspaces/:id/members/:user_id`
|
|
7513
7726
|
*/
|
|
7514
|
-
async updateRole(
|
|
7727
|
+
async updateRole(workspaceId2, userId, params) {
|
|
7515
7728
|
const res = await this.http.patch(
|
|
7516
|
-
`/workspaces/${
|
|
7729
|
+
`/workspaces/${workspaceId2}/members/${userId}`,
|
|
7517
7730
|
params
|
|
7518
7731
|
);
|
|
7519
7732
|
return res.data ?? res;
|
|
@@ -7528,9 +7741,9 @@ var WorkspaceMembers = class {
|
|
|
7528
7741
|
*
|
|
7529
7742
|
* @throws `MiosaError` with code `LAST_OWNER` if the target is the sole owner.
|
|
7530
7743
|
*/
|
|
7531
|
-
async remove(
|
|
7744
|
+
async remove(workspaceId2, userId) {
|
|
7532
7745
|
return this.http.delete(
|
|
7533
|
-
`/workspaces/${
|
|
7746
|
+
`/workspaces/${workspaceId2}/members/${userId}`
|
|
7534
7747
|
);
|
|
7535
7748
|
}
|
|
7536
7749
|
};
|
|
@@ -7578,17 +7791,21 @@ var Miosa = class {
|
|
|
7578
7791
|
externalKeys;
|
|
7579
7792
|
/** Model Context Protocol — JSON-RPC dispatch + streaming channel. */
|
|
7580
7793
|
mcp;
|
|
7794
|
+
/** Agent Runs — prompt dispatch into sandbox targets. */
|
|
7795
|
+
agentRuns;
|
|
7796
|
+
/** Agent runtime profiles — tenant/workspace defaults for sandbox/computer agents. */
|
|
7797
|
+
agentRuntimeProfiles;
|
|
7581
7798
|
/** Computer management — create, list, get, delete. */
|
|
7582
7799
|
computers;
|
|
7583
7800
|
/** Sandboxes — native code-execution environments under `/sandboxes`. */
|
|
7584
7801
|
sandboxes;
|
|
7585
|
-
/** Agent device facade — route work across Sandboxes, Computers, and deploy hosts. */
|
|
7586
|
-
devices;
|
|
7587
7802
|
/**
|
|
7588
7803
|
* Deployments — publish from a sandbox to a stable production URL.
|
|
7589
7804
|
* Versions, releases, rollback, custom domains.
|
|
7590
7805
|
*/
|
|
7591
7806
|
deployments;
|
|
7807
|
+
/** Docker Deploy appliance hosts — one always-on workspace host, many apps. */
|
|
7808
|
+
dockerDeploy;
|
|
7592
7809
|
/** Credit balance and usage. */
|
|
7593
7810
|
credits;
|
|
7594
7811
|
/** Admin surface (`/api/v1/admin/*`) — requires an admin credential. */
|
|
@@ -7680,10 +7897,12 @@ var Miosa = class {
|
|
|
7680
7897
|
this.projectAuth = new ProjectAuth(this.http);
|
|
7681
7898
|
this.externalKeys = new ExternalKeys(this.http);
|
|
7682
7899
|
this.mcp = new Mcp(this.http);
|
|
7900
|
+
this.agentRuns = new AgentRuns(this.http);
|
|
7901
|
+
this.agentRuntimeProfiles = new AgentRuntimeProfiles(this.http);
|
|
7683
7902
|
this.computers = new Computers(this.http);
|
|
7684
7903
|
this.sandboxes = new Sandboxes(this.http);
|
|
7685
|
-
this.devices = new Devices(this.http);
|
|
7686
7904
|
this.deployments = new Deployments(this.http);
|
|
7905
|
+
this.dockerDeploy = new DockerDeploy(this.http);
|
|
7687
7906
|
this.credits = new Credits(this.http);
|
|
7688
7907
|
this.admin = new Admin(this.http);
|
|
7689
7908
|
this.openComputers = new OpenComputers(this.http);
|
|
@@ -7713,6 +7932,162 @@ var Miosa = class {
|
|
|
7713
7932
|
}
|
|
7714
7933
|
};
|
|
7715
7934
|
|
|
7716
|
-
|
|
7935
|
+
// src/resources/app-auth.ts
|
|
7936
|
+
function unwrapSession(data) {
|
|
7937
|
+
const d = data && typeof data === "object" && "data" in data ? data.data : data;
|
|
7938
|
+
const userId = d.user_id ?? d.userId;
|
|
7939
|
+
const token = d.token ?? d.access_token;
|
|
7940
|
+
const expiresAt = d.expires_at ?? d.expiresAt ?? "";
|
|
7941
|
+
if (!userId || !token) {
|
|
7942
|
+
throw new Error(
|
|
7943
|
+
`AppAuth: unexpected response shape \u2014 got: ${JSON.stringify(d)}`
|
|
7944
|
+
);
|
|
7945
|
+
}
|
|
7946
|
+
return {
|
|
7947
|
+
userId,
|
|
7948
|
+
token,
|
|
7949
|
+
expiresAt
|
|
7950
|
+
};
|
|
7951
|
+
}
|
|
7952
|
+
function base64UrlDecode(s) {
|
|
7953
|
+
const padded = s.replace(/-/g, "+").replace(/_/g, "/");
|
|
7954
|
+
const bin = atob(padded);
|
|
7955
|
+
const bytes = new Uint8Array(bin.length);
|
|
7956
|
+
for (let i = 0; i < bin.length; i++) {
|
|
7957
|
+
bytes[i] = bin.charCodeAt(i);
|
|
7958
|
+
}
|
|
7959
|
+
return bytes;
|
|
7960
|
+
}
|
|
7961
|
+
var AppAuth = class {
|
|
7962
|
+
baseUrl;
|
|
7963
|
+
resourceType;
|
|
7964
|
+
resourceId;
|
|
7965
|
+
jwtSecret;
|
|
7966
|
+
constructor(config) {
|
|
7967
|
+
const authUrl = config.authUrl ?? (typeof process !== "undefined" ? process.env["AUTH_URL"] : void 0);
|
|
7968
|
+
if (!authUrl) {
|
|
7969
|
+
throw new Error(
|
|
7970
|
+
"AppAuth: authUrl is required. Pass authUrl in config or set AUTH_URL env var."
|
|
7971
|
+
);
|
|
7972
|
+
}
|
|
7973
|
+
if (!config.resourceType || !config.resourceId) {
|
|
7974
|
+
throw new Error("AppAuth: resourceType and resourceId are required.");
|
|
7975
|
+
}
|
|
7976
|
+
this.baseUrl = authUrl.replace(/\/$/, "");
|
|
7977
|
+
this.resourceType = config.resourceType;
|
|
7978
|
+
this.resourceId = config.resourceId;
|
|
7979
|
+
this.jwtSecret = config.jwtSecret ?? (typeof process !== "undefined" ? process.env["AUTH_JWT_SECRET"] : void 0);
|
|
7980
|
+
}
|
|
7981
|
+
/** POST /app-auth/:resourceType/:resourceId/signup */
|
|
7982
|
+
async signup(email, password) {
|
|
7983
|
+
return unwrapSession(await this._post("signup", { email, password }));
|
|
7984
|
+
}
|
|
7985
|
+
/** POST /app-auth/:resourceType/:resourceId/login */
|
|
7986
|
+
async login(email, password) {
|
|
7987
|
+
return unwrapSession(await this._post("login", { email, password }));
|
|
7988
|
+
}
|
|
7989
|
+
/**
|
|
7990
|
+
* POST /app-auth/:resourceType/:resourceId/verify
|
|
7991
|
+
* Verifies an email confirmation or magic-link token issued by the backend.
|
|
7992
|
+
*/
|
|
7993
|
+
async verify(token) {
|
|
7994
|
+
return unwrapSession(await this._post("verify", { token }));
|
|
7995
|
+
}
|
|
7996
|
+
/** POST /app-auth/:resourceType/:resourceId/password-reset */
|
|
7997
|
+
async passwordReset(email) {
|
|
7998
|
+
const data = await this._post("password-reset", { email });
|
|
7999
|
+
return { ok: true, ...data };
|
|
8000
|
+
}
|
|
8001
|
+
/**
|
|
8002
|
+
* POST /app-auth/:resourceType/:resourceId/logout
|
|
8003
|
+
* Invalidates the given bearer token server-side.
|
|
8004
|
+
*/
|
|
8005
|
+
async logout(token) {
|
|
8006
|
+
const data = await this._post("logout", { token });
|
|
8007
|
+
return { ok: true, ...data };
|
|
8008
|
+
}
|
|
8009
|
+
/**
|
|
8010
|
+
* GET /app-auth/:resourceType/:resourceId/me
|
|
8011
|
+
* Returns the session for the bearer token.
|
|
8012
|
+
*/
|
|
8013
|
+
async me(token) {
|
|
8014
|
+
const url = `${this.baseUrl}/app-auth/${this.resourceType}/${this.resourceId}/me`;
|
|
8015
|
+
const resp = await fetch(url, {
|
|
8016
|
+
method: "GET",
|
|
8017
|
+
headers: {
|
|
8018
|
+
"Content-Type": "application/json",
|
|
8019
|
+
Authorization: `Bearer ${token}`
|
|
8020
|
+
}
|
|
8021
|
+
});
|
|
8022
|
+
if (!resp.ok) {
|
|
8023
|
+
const body2 = await resp.text();
|
|
8024
|
+
throw new Error(`AppAuth me failed (${resp.status}): ${body2}`);
|
|
8025
|
+
}
|
|
8026
|
+
return unwrapSession(await resp.json());
|
|
8027
|
+
}
|
|
8028
|
+
/**
|
|
8029
|
+
* Verifies a JWT token locally using HS256 + AUTH_JWT_SECRET.
|
|
8030
|
+
*
|
|
8031
|
+
* Does NOT make a network call. Throws if the signature is invalid or the
|
|
8032
|
+
* token is expired. Returns the decoded payload on success.
|
|
8033
|
+
*/
|
|
8034
|
+
async verifyToken(token) {
|
|
8035
|
+
if (!this.jwtSecret) {
|
|
8036
|
+
throw new Error(
|
|
8037
|
+
"AppAuth.verifyToken: jwtSecret is required. Pass jwtSecret in config or set AUTH_JWT_SECRET env var."
|
|
8038
|
+
);
|
|
8039
|
+
}
|
|
8040
|
+
const parts = token.split(".");
|
|
8041
|
+
if (parts.length !== 3) {
|
|
8042
|
+
throw new Error("AppAuth.verifyToken: malformed JWT \u2014 expected 3 parts");
|
|
8043
|
+
}
|
|
8044
|
+
const [headerB64, payloadB64, signatureB64] = parts;
|
|
8045
|
+
const payloadJson = new TextDecoder().decode(base64UrlDecode(payloadB64));
|
|
8046
|
+
const payload = JSON.parse(payloadJson);
|
|
8047
|
+
const now = Math.floor(Date.now() / 1e3);
|
|
8048
|
+
if (typeof payload.exp === "number" && payload.exp < now) {
|
|
8049
|
+
throw new Error(
|
|
8050
|
+
`AppAuth.verifyToken: token expired at ${new Date(payload.exp * 1e3).toISOString()}`
|
|
8051
|
+
);
|
|
8052
|
+
}
|
|
8053
|
+
const encoder = new TextEncoder();
|
|
8054
|
+
const signingInput = `${headerB64}.${payloadB64}`;
|
|
8055
|
+
const secretBytes = encoder.encode(this.jwtSecret);
|
|
8056
|
+
const key = await crypto.subtle.importKey(
|
|
8057
|
+
"raw",
|
|
8058
|
+
secretBytes,
|
|
8059
|
+
{ name: "HMAC", hash: "SHA-256" },
|
|
8060
|
+
false,
|
|
8061
|
+
["verify"]
|
|
8062
|
+
);
|
|
8063
|
+
const signatureBytes = base64UrlDecode(signatureB64).buffer;
|
|
8064
|
+
const valid = await crypto.subtle.verify(
|
|
8065
|
+
"HMAC",
|
|
8066
|
+
key,
|
|
8067
|
+
signatureBytes,
|
|
8068
|
+
encoder.encode(signingInput)
|
|
8069
|
+
);
|
|
8070
|
+
if (!valid) {
|
|
8071
|
+
throw new Error("AppAuth.verifyToken: invalid JWT signature");
|
|
8072
|
+
}
|
|
8073
|
+
return payload;
|
|
8074
|
+
}
|
|
8075
|
+
// ── Private ──────────────────────────────────────────────────────────────────
|
|
8076
|
+
async _post(action, body2) {
|
|
8077
|
+
const url = `${this.baseUrl}/app-auth/${this.resourceType}/${this.resourceId}/${action}`;
|
|
8078
|
+
const resp = await fetch(url, {
|
|
8079
|
+
method: "POST",
|
|
8080
|
+
headers: { "Content-Type": "application/json" },
|
|
8081
|
+
body: JSON.stringify(body2)
|
|
8082
|
+
});
|
|
8083
|
+
if (!resp.ok) {
|
|
8084
|
+
const text = await resp.text();
|
|
8085
|
+
throw new Error(`AppAuth ${action} failed (${resp.status}): ${text}`);
|
|
8086
|
+
}
|
|
8087
|
+
return resp.json();
|
|
8088
|
+
}
|
|
8089
|
+
};
|
|
8090
|
+
|
|
8091
|
+
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 };
|
|
7717
8092
|
//# sourceMappingURL=index.js.map
|
|
7718
8093
|
//# sourceMappingURL=index.js.map
|