@lizard-build/sdk 0.1.17 → 0.1.18
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.mts +11 -6
- package/dist/index.d.ts +11 -6
- package/dist/index.js +6 -0
- package/dist/index.mjs +6 -0
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -137,6 +137,11 @@ interface SandboxInfo {
|
|
|
137
137
|
metadata?: Record<string, string>;
|
|
138
138
|
}
|
|
139
139
|
interface SandboxOpts extends ConnectionOpts {
|
|
140
|
+
/**
|
|
141
|
+
* ID of the project this sandbox belongs to. Required: a sandbox must be
|
|
142
|
+
* attributed to a project so its CPU, RAM, egress, and storage are billed.
|
|
143
|
+
*/
|
|
144
|
+
projectId: string;
|
|
140
145
|
template?: string;
|
|
141
146
|
metadata?: Record<string, string>;
|
|
142
147
|
envs?: Record<string, string>;
|
|
@@ -175,7 +180,7 @@ declare class SandboxClient {
|
|
|
175
180
|
* ```ts
|
|
176
181
|
* import { Sandbox } from 'lizard'
|
|
177
182
|
*
|
|
178
|
-
* const sandbox = await Sandbox.create('base')
|
|
183
|
+
* const sandbox = await Sandbox.create('base', { projectId: 'proj_abc123' })
|
|
179
184
|
* await sandbox.fs.write('/app/index.js', 'console.log("hello world")')
|
|
180
185
|
* const result = await sandbox.process.exec('node /app/index.js')
|
|
181
186
|
* console.log(result.stdout) // "hello world"
|
|
@@ -184,7 +189,7 @@ declare class SandboxClient {
|
|
|
184
189
|
*
|
|
185
190
|
* @example Pause and resume a long-running session:
|
|
186
191
|
* ```ts
|
|
187
|
-
* const sandbox = await Sandbox.create('code-interpreter-v1')
|
|
192
|
+
* const sandbox = await Sandbox.create('code-interpreter-v1', { projectId: 'proj_abc123' })
|
|
188
193
|
* await sandbox.process.exec('pip install numpy')
|
|
189
194
|
* const id = sandbox.sandboxId
|
|
190
195
|
* await sandbox.pause()
|
|
@@ -229,7 +234,7 @@ declare class Sandbox extends SandboxClient {
|
|
|
229
234
|
*
|
|
230
235
|
* @example
|
|
231
236
|
* ```ts
|
|
232
|
-
* const sandbox = await Sandbox.create()
|
|
237
|
+
* const sandbox = await Sandbox.create({ projectId: 'proj_abc123' })
|
|
233
238
|
* ```
|
|
234
239
|
*/
|
|
235
240
|
static create(opts?: SandboxOpts): Promise<Sandbox>;
|
|
@@ -244,8 +249,8 @@ declare class Sandbox extends SandboxClient {
|
|
|
244
249
|
*
|
|
245
250
|
* @example
|
|
246
251
|
* ```ts
|
|
247
|
-
* const sandbox = await Sandbox.create('base')
|
|
248
|
-
* const sandbox = await Sandbox.create('code-interpreter-v1', { timeoutMs: 10 * 60 * 1000 })
|
|
252
|
+
* const sandbox = await Sandbox.create('base', { projectId: 'proj_abc123' })
|
|
253
|
+
* const sandbox = await Sandbox.create('code-interpreter-v1', { projectId: 'proj_abc123', timeoutMs: 10 * 60 * 1000 })
|
|
249
254
|
* ```
|
|
250
255
|
*/
|
|
251
256
|
static create(template: string, opts?: SandboxOpts): Promise<Sandbox>;
|
|
@@ -409,7 +414,7 @@ interface CreateContextOpts {
|
|
|
409
414
|
* ```ts
|
|
410
415
|
* import { CodeSandbox } from 'lizard/code-interpreter'
|
|
411
416
|
*
|
|
412
|
-
* const sandbox = await CodeSandbox.create()
|
|
417
|
+
* const sandbox = await CodeSandbox.create({ projectId: 'proj_abc123' })
|
|
413
418
|
*
|
|
414
419
|
* await sandbox.runCode('x = 42')
|
|
415
420
|
* const result = await sandbox.runCode('print(x * 2)')
|
package/dist/index.d.ts
CHANGED
|
@@ -137,6 +137,11 @@ interface SandboxInfo {
|
|
|
137
137
|
metadata?: Record<string, string>;
|
|
138
138
|
}
|
|
139
139
|
interface SandboxOpts extends ConnectionOpts {
|
|
140
|
+
/**
|
|
141
|
+
* ID of the project this sandbox belongs to. Required: a sandbox must be
|
|
142
|
+
* attributed to a project so its CPU, RAM, egress, and storage are billed.
|
|
143
|
+
*/
|
|
144
|
+
projectId: string;
|
|
140
145
|
template?: string;
|
|
141
146
|
metadata?: Record<string, string>;
|
|
142
147
|
envs?: Record<string, string>;
|
|
@@ -175,7 +180,7 @@ declare class SandboxClient {
|
|
|
175
180
|
* ```ts
|
|
176
181
|
* import { Sandbox } from 'lizard'
|
|
177
182
|
*
|
|
178
|
-
* const sandbox = await Sandbox.create('base')
|
|
183
|
+
* const sandbox = await Sandbox.create('base', { projectId: 'proj_abc123' })
|
|
179
184
|
* await sandbox.fs.write('/app/index.js', 'console.log("hello world")')
|
|
180
185
|
* const result = await sandbox.process.exec('node /app/index.js')
|
|
181
186
|
* console.log(result.stdout) // "hello world"
|
|
@@ -184,7 +189,7 @@ declare class SandboxClient {
|
|
|
184
189
|
*
|
|
185
190
|
* @example Pause and resume a long-running session:
|
|
186
191
|
* ```ts
|
|
187
|
-
* const sandbox = await Sandbox.create('code-interpreter-v1')
|
|
192
|
+
* const sandbox = await Sandbox.create('code-interpreter-v1', { projectId: 'proj_abc123' })
|
|
188
193
|
* await sandbox.process.exec('pip install numpy')
|
|
189
194
|
* const id = sandbox.sandboxId
|
|
190
195
|
* await sandbox.pause()
|
|
@@ -229,7 +234,7 @@ declare class Sandbox extends SandboxClient {
|
|
|
229
234
|
*
|
|
230
235
|
* @example
|
|
231
236
|
* ```ts
|
|
232
|
-
* const sandbox = await Sandbox.create()
|
|
237
|
+
* const sandbox = await Sandbox.create({ projectId: 'proj_abc123' })
|
|
233
238
|
* ```
|
|
234
239
|
*/
|
|
235
240
|
static create(opts?: SandboxOpts): Promise<Sandbox>;
|
|
@@ -244,8 +249,8 @@ declare class Sandbox extends SandboxClient {
|
|
|
244
249
|
*
|
|
245
250
|
* @example
|
|
246
251
|
* ```ts
|
|
247
|
-
* const sandbox = await Sandbox.create('base')
|
|
248
|
-
* const sandbox = await Sandbox.create('code-interpreter-v1', { timeoutMs: 10 * 60 * 1000 })
|
|
252
|
+
* const sandbox = await Sandbox.create('base', { projectId: 'proj_abc123' })
|
|
253
|
+
* const sandbox = await Sandbox.create('code-interpreter-v1', { projectId: 'proj_abc123', timeoutMs: 10 * 60 * 1000 })
|
|
249
254
|
* ```
|
|
250
255
|
*/
|
|
251
256
|
static create(template: string, opts?: SandboxOpts): Promise<Sandbox>;
|
|
@@ -409,7 +414,7 @@ interface CreateContextOpts {
|
|
|
409
414
|
* ```ts
|
|
410
415
|
* import { CodeSandbox } from 'lizard/code-interpreter'
|
|
411
416
|
*
|
|
412
|
-
* const sandbox = await CodeSandbox.create()
|
|
417
|
+
* const sandbox = await CodeSandbox.create({ projectId: 'proj_abc123' })
|
|
413
418
|
*
|
|
414
419
|
* await sandbox.runCode('x = 42')
|
|
415
420
|
* const result = await sandbox.runCode('print(x * 2)')
|
package/dist/index.js
CHANGED
|
@@ -233,11 +233,17 @@ var Fs = class {
|
|
|
233
233
|
// src/sandbox/client.ts
|
|
234
234
|
var SandboxClient = class {
|
|
235
235
|
static async createSandbox(template, timeoutMs, opts) {
|
|
236
|
+
if (!opts?.projectId) {
|
|
237
|
+
throw new LizardError(
|
|
238
|
+
"projectId is required: a sandbox must belong to a project so its usage is billed. Pass { projectId } to Sandbox.create()."
|
|
239
|
+
);
|
|
240
|
+
}
|
|
236
241
|
const config = new ConnectionConfig(opts);
|
|
237
242
|
const res = await fetch(`${config.apiUrl}/api/sandboxes`, {
|
|
238
243
|
method: "POST",
|
|
239
244
|
headers: config.headers,
|
|
240
245
|
body: JSON.stringify({
|
|
246
|
+
projectId: opts.projectId,
|
|
241
247
|
template,
|
|
242
248
|
timeoutMs,
|
|
243
249
|
metadata: opts?.metadata,
|
package/dist/index.mjs
CHANGED
|
@@ -201,11 +201,17 @@ var Fs = class {
|
|
|
201
201
|
// src/sandbox/client.ts
|
|
202
202
|
var SandboxClient = class {
|
|
203
203
|
static async createSandbox(template, timeoutMs, opts) {
|
|
204
|
+
if (!opts?.projectId) {
|
|
205
|
+
throw new LizardError(
|
|
206
|
+
"projectId is required: a sandbox must belong to a project so its usage is billed. Pass { projectId } to Sandbox.create()."
|
|
207
|
+
);
|
|
208
|
+
}
|
|
204
209
|
const config = new ConnectionConfig(opts);
|
|
205
210
|
const res = await fetch(`${config.apiUrl}/api/sandboxes`, {
|
|
206
211
|
method: "POST",
|
|
207
212
|
headers: config.headers,
|
|
208
213
|
body: JSON.stringify({
|
|
214
|
+
projectId: opts.projectId,
|
|
209
215
|
template,
|
|
210
216
|
timeoutMs,
|
|
211
217
|
metadata: opts?.metadata,
|