codai-sdk 0.54.1 → 0.55.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +584 -7
- package/dist/index.js +85 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -5066,7 +5066,11 @@ var Sandboxes = class {
|
|
|
5066
5066
|
this.http = http;
|
|
5067
5067
|
this.files = new SandboxFiles(http);
|
|
5068
5068
|
}
|
|
5069
|
-
/**
|
|
5069
|
+
/**
|
|
5070
|
+
* `POST /v1/sandboxes` — start a sandbox (`ttl_seconds` 60–86400, default 3600; `egress` none by default).
|
|
5071
|
+
* `backend: 'v2'` (closed canary) starts a long-lived pod with memory snapshots and accepts `template`
|
|
5072
|
+
* `codai-base` | `brivio-acte` | `desktop`; its reply may carry `restored`.
|
|
5073
|
+
*/
|
|
5070
5074
|
create(input = {}, opts = {}) {
|
|
5071
5075
|
return this.http.json("/v1/sandboxes", {
|
|
5072
5076
|
method: "POST",
|
|
@@ -5143,6 +5147,77 @@ var Sandboxes = class {
|
|
|
5143
5147
|
signal: opts.signal
|
|
5144
5148
|
});
|
|
5145
5149
|
}
|
|
5150
|
+
/**
|
|
5151
|
+
* `POST /v1/sandboxes/{id}/run_code` (v2) — run Python in the persistent kernel; globals survive between
|
|
5152
|
+
* calls, pause/resume and forks. The last expression comes back as `result`.
|
|
5153
|
+
*/
|
|
5154
|
+
runCode(id, input, opts = {}) {
|
|
5155
|
+
return this.http.json(`${base(id)}/run_code`, {
|
|
5156
|
+
method: "POST",
|
|
5157
|
+
body: {
|
|
5158
|
+
code: input.code,
|
|
5159
|
+
...input.timeoutSeconds !== void 0 ? { timeout_seconds: input.timeoutSeconds } : {}
|
|
5160
|
+
},
|
|
5161
|
+
timeoutMs: execTimeoutMs(input.timeoutSeconds),
|
|
5162
|
+
noRetry: true,
|
|
5163
|
+
ext: opts.ext,
|
|
5164
|
+
signal: opts.signal
|
|
5165
|
+
});
|
|
5166
|
+
}
|
|
5167
|
+
/** `POST /v1/sandboxes/{id}/kernel/reset` (v2) — restart the kernel; globals are lost, files kept. */
|
|
5168
|
+
async resetKernel(id, opts = {}) {
|
|
5169
|
+
await this.http.json(`${base(id)}/kernel/reset`, {
|
|
5170
|
+
method: "POST",
|
|
5171
|
+
ext: opts.ext,
|
|
5172
|
+
signal: opts.signal
|
|
5173
|
+
});
|
|
5174
|
+
}
|
|
5175
|
+
/** `POST /v1/sandboxes/{id}/pause` (v2) — memory snapshot, then stop the pod (status `paused`). */
|
|
5176
|
+
pause(id, opts = {}) {
|
|
5177
|
+
return this.http.json(`${base(id)}/pause`, {
|
|
5178
|
+
method: "POST",
|
|
5179
|
+
timeoutMs: LIFECYCLE_TIMEOUT_MS,
|
|
5180
|
+
noRetry: true,
|
|
5181
|
+
ext: opts.ext,
|
|
5182
|
+
signal: opts.signal
|
|
5183
|
+
});
|
|
5184
|
+
}
|
|
5185
|
+
/** `POST /v1/sandboxes/{id}/resume` (v2) — restore a paused sandbox; `restored: false` = cold start. */
|
|
5186
|
+
resume(id, opts = {}) {
|
|
5187
|
+
return this.http.json(`${base(id)}/resume`, {
|
|
5188
|
+
method: "POST",
|
|
5189
|
+
timeoutMs: LIFECYCLE_TIMEOUT_MS,
|
|
5190
|
+
noRetry: true,
|
|
5191
|
+
ext: opts.ext,
|
|
5192
|
+
signal: opts.signal
|
|
5193
|
+
});
|
|
5194
|
+
}
|
|
5195
|
+
/** `POST /v1/sandboxes/{id}/fork` (v2) — start 1–5 copies of a running sandbox from a memory snapshot. */
|
|
5196
|
+
fork(id, input, opts = {}) {
|
|
5197
|
+
return this.http.json(`${base(id)}/fork`, {
|
|
5198
|
+
method: "POST",
|
|
5199
|
+
body: {
|
|
5200
|
+
count: input.count,
|
|
5201
|
+
...input.ttlSeconds !== void 0 ? { ttl_seconds: input.ttlSeconds } : {}
|
|
5202
|
+
},
|
|
5203
|
+
timeoutMs: LIFECYCLE_TIMEOUT_MS,
|
|
5204
|
+
noRetry: true,
|
|
5205
|
+
ext: opts.ext,
|
|
5206
|
+
signal: opts.signal
|
|
5207
|
+
});
|
|
5208
|
+
}
|
|
5209
|
+
/** `POST /v1/sandboxes/{id}/preview` (v2) — signed HTTPS URL on `*.sbx.codai.ro` for a port (≤ 1 h). */
|
|
5210
|
+
preview(id, input, opts = {}) {
|
|
5211
|
+
return this.http.json(`${base(id)}/preview`, {
|
|
5212
|
+
method: "POST",
|
|
5213
|
+
body: {
|
|
5214
|
+
port: input.port,
|
|
5215
|
+
...input.ttlSeconds !== void 0 ? { ttl_seconds: input.ttlSeconds } : {}
|
|
5216
|
+
},
|
|
5217
|
+
ext: opts.ext,
|
|
5218
|
+
signal: opts.signal
|
|
5219
|
+
});
|
|
5220
|
+
}
|
|
5146
5221
|
/** `DELETE /v1/sandboxes/{id}` — destroy the sandbox and its workspace (204). */
|
|
5147
5222
|
async delete(id, opts = {}) {
|
|
5148
5223
|
await this.http.request(base(id), {
|
|
@@ -5167,6 +5242,8 @@ var Sandboxes = class {
|
|
|
5167
5242
|
});
|
|
5168
5243
|
}
|
|
5169
5244
|
};
|
|
5245
|
+
/** Pause / resume / fork wait for a snapshot or a pod start (server caps: 180 s snapshot, 240 s start). */
|
|
5246
|
+
const LIFECYCLE_TIMEOUT_MS = 48e4;
|
|
5170
5247
|
/** Client timeout for a blocking exec: the server limit plus a margin for restore and upload. */
|
|
5171
5248
|
function execTimeoutMs(timeoutSeconds) {
|
|
5172
5249
|
return ((timeoutSeconds ?? 120) + 60) * 1e3;
|
|
@@ -5991,6 +6068,12 @@ const OPERATION_METHODS = {
|
|
|
5991
6068
|
snapshotSandbox: "sandboxes.snapshot",
|
|
5992
6069
|
deleteSandbox: "sandboxes.delete",
|
|
5993
6070
|
runSandbox: "sandboxes.run",
|
|
6071
|
+
runSandboxCode: "sandboxes.runCode",
|
|
6072
|
+
resetSandboxKernel: "sandboxes.resetKernel",
|
|
6073
|
+
pauseSandbox: "sandboxes.pause",
|
|
6074
|
+
resumeSandbox: "sandboxes.resume",
|
|
6075
|
+
forkSandbox: "sandboxes.fork",
|
|
6076
|
+
previewSandbox: "sandboxes.preview",
|
|
5994
6077
|
createSession: "sessions.create",
|
|
5995
6078
|
listSessions: "sessions.list",
|
|
5996
6079
|
getSession: "sessions.get",
|
|
@@ -6319,6 +6402,7 @@ var CodaiApps = class {
|
|
|
6319
6402
|
* client.projects.* client.environments.* (members, ports, secrets)
|
|
6320
6403
|
* client.sandboxes.create / .list / .retrieve / .exec / .execStream / .files.put / .files.get / .files.list
|
|
6321
6404
|
* / .artifacts / .snapshot / .delete / .run (agent sandboxes, beta: isolated gVisor workspaces, no network by default)
|
|
6405
|
+
* / .runCode / .resetKernel / .pause / .resume / .fork / .preview (backend v2, closed canary)
|
|
6322
6406
|
* client.verify.agentOutputKey / .agentOutput (EXPERIMENTAL HIDE-signed agent outputs)
|
|
6323
6407
|
* client.feedback / client.phoneModels
|
|
6324
6408
|
* client.resolve.* (verified bug fixes on https://resolve.codai.ro — resolve.yaml; .list / .iterate page your jobs)
|