@lizard-build/sdk 0.1.43 → 0.1.44
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 +19 -13
- package/dist/index.d.mts +9 -25
- package/dist/index.d.ts +9 -25
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Lizard TypeScript
|
|
1
|
+
# Lizard SDK for TypeScript
|
|
2
2
|
|
|
3
3
|
Run commands, work with files and execute code in Linux sandboxes on Kubernetes. The SDK also manages Lizard apps, databases, storage and projects.
|
|
4
4
|
|
|
@@ -51,26 +51,26 @@ const result = await sandbox.process.exec('printf "hello\\n"', {
|
|
|
51
51
|
if (result.exitCode !== 0) throw new Error(result.stderr)
|
|
52
52
|
```
|
|
53
53
|
|
|
54
|
-
## Run
|
|
54
|
+
## Run Python
|
|
55
55
|
|
|
56
|
-
|
|
56
|
+
Run Python with the `interpreter` template. Each process command starts a separate Python process, so Python variables do not survive between calls. Save intermediate results to files. The API returns stdout, stderr, and an exit code; it does not return typed notebook results or chart objects.
|
|
57
57
|
|
|
58
58
|
```ts
|
|
59
|
-
import {
|
|
59
|
+
import { Sandbox } from '@lizard-build/sdk';
|
|
60
60
|
|
|
61
|
-
const sandbox = await
|
|
61
|
+
const sandbox = await Sandbox.create('interpreter', {
|
|
62
|
+
projectId: 'proj_123', timeoutMs: 300_000,
|
|
63
|
+
});
|
|
62
64
|
try {
|
|
63
|
-
const result = await sandbox.
|
|
64
|
-
|
|
65
|
-
timeoutMs: 60_000,
|
|
66
|
-
onStdout: chunk => process.stdout.write(chunk),
|
|
67
|
-
})
|
|
68
|
-
if (result.error) throw result.error
|
|
65
|
+
const result = await sandbox.process.exec("python -c 'print(2 ** 10)'");
|
|
66
|
+
console.log(result.stdout, result.stderr, result.exitCode);
|
|
69
67
|
} finally {
|
|
70
|
-
await sandbox.kill()
|
|
68
|
+
await sandbox.kill();
|
|
71
69
|
}
|
|
72
70
|
```
|
|
73
71
|
|
|
72
|
+
`CodeSandbox`, `runCode` / `run_code`, and execution-context methods remain in the SDK, but the hosted template catalog does not provide their required execution server. The legacy default `code-interpreter-v1` is unavailable. Changing its name to `interpreter` does not enable this API. Use `Sandbox.create("interpreter")` and process commands as shown below.
|
|
73
|
+
|
|
74
74
|
## Configuration
|
|
75
75
|
|
|
76
76
|
The SDK reads `LIZARD_API_KEY` and, optionally, `LIZARD_API_URL` (default: `https://lizard.build`). You can also pass `apiKey` and `apiUrl` to the constructor or static sandbox methods.
|
|
@@ -79,10 +79,16 @@ Pass `timeoutMs` to `create()` to set the sandbox lifetime. The default is five
|
|
|
79
79
|
|
|
80
80
|
## Runtime limits
|
|
81
81
|
|
|
82
|
-
Sandboxes run on Kubernetes. Use volumes mounted at `/workspace` to keep files after a sandbox ends. Pause, resume, fork, snapshot creation
|
|
82
|
+
Sandboxes run on Kubernetes. Use volumes mounted at `/workspace` to keep files after a sandbox ends. Pause, resume, fork, snapshot creation, snapshot restore, and file watching return HTTP 501 on the current backend.
|
|
83
83
|
|
|
84
84
|
`getHost()` returns a hostname without `https://`. File writes accept UTF-8 text or valid UTF-8 bytes; `readBytes()` supports binary downloads.
|
|
85
85
|
|
|
86
|
+
## Current command and lifetime limits
|
|
87
|
+
|
|
88
|
+
Command results contain stdout, stderr, and the exit code. Command timeouts are limited to 1–600 seconds. The current runtime does not apply the SDK command options `envs`, `workdir`, or `user`; set the directory and environment in the shell command when needed. Create-time `envs` and `metadata` are also not applied.
|
|
89
|
+
|
|
90
|
+
The SDK and CLI default to a five-minute lifetime. The raw API and dashboard default to no expiration. Set an explicit lifetime: `timeoutMs: 0` at creation disables expiration; a positive value sets a deadline. `setTimeout` accepts 1000–2147483647 ms, not zero. Commands do not reset the deadline. This is not an idle timer.
|
|
91
|
+
|
|
86
92
|
## Learn more
|
|
87
93
|
|
|
88
94
|
- [Sandbox reference](https://github.com/lizard-build/lizard-sdk/blob/main/docs/sandboxes.md)
|
package/dist/index.d.mts
CHANGED
|
@@ -813,14 +813,15 @@ declare class Sandbox extends SandboxClient {
|
|
|
813
813
|
* Create a new Lizard sandbox from the specified template.
|
|
814
814
|
*
|
|
815
815
|
* Template availability and installed tools depend on the platform and region.
|
|
816
|
-
* Use `base` for shell commands or `
|
|
816
|
+
* Use `base` for shell commands or `interpreter` for Python process commands.
|
|
817
|
+
* Hosted templates do not support the legacy `CodeSandbox` execution API.
|
|
817
818
|
*
|
|
818
819
|
* @param template Name of the sandbox template to boot from.
|
|
819
820
|
*
|
|
820
821
|
* @example
|
|
821
822
|
* ```ts
|
|
822
823
|
* const sandbox = await Sandbox.create('base', { project: 'my-project' })
|
|
823
|
-
* const pythonSandbox = await Sandbox.create('
|
|
824
|
+
* const pythonSandbox = await Sandbox.create('interpreter', { project: 'my-project', timeoutMs: 10 * 60 * 1000 })
|
|
824
825
|
* ```
|
|
825
826
|
*/
|
|
826
827
|
static create(template: string, opts?: SandboxOpts): Promise<Sandbox>;
|
|
@@ -1682,31 +1683,14 @@ interface CreateContextOpts {
|
|
|
1682
1683
|
}
|
|
1683
1684
|
|
|
1684
1685
|
/**
|
|
1685
|
-
*
|
|
1686
|
+
* Legacy client for the code-interpreter execution server.
|
|
1686
1687
|
*
|
|
1687
|
-
*
|
|
1688
|
-
*
|
|
1688
|
+
* Current hosted templates do not provide this server. The default
|
|
1689
|
+
* `code-interpreter-v1` template is unavailable; selecting `interpreter`
|
|
1690
|
+
* does not enable this API. Use `Sandbox.create('interpreter', options)`
|
|
1691
|
+
* and `sandbox.process.exec()` for Python commands instead.
|
|
1689
1692
|
*
|
|
1690
|
-
*
|
|
1691
|
-
*
|
|
1692
|
-
* @example
|
|
1693
|
-
* ```ts
|
|
1694
|
-
* import { CodeSandbox } from '@lizard-build/sdk'
|
|
1695
|
-
*
|
|
1696
|
-
* const sandbox = await CodeSandbox.create({ project: 'my-project' })
|
|
1697
|
-
*
|
|
1698
|
-
* await sandbox.runCode('x = 42')
|
|
1699
|
-
* const result = await sandbox.runCode('print(x * 2)')
|
|
1700
|
-
* console.log(result.stdout) // "84\n"
|
|
1701
|
-
*
|
|
1702
|
-
* await sandbox.kill()
|
|
1703
|
-
* ```
|
|
1704
|
-
*
|
|
1705
|
-
* @example Run JavaScript:
|
|
1706
|
-
* ```ts
|
|
1707
|
-
* const result = await sandbox.runCode('1 + 1', { language: 'javascript' })
|
|
1708
|
-
* console.log(result.results[0].data) // "2"
|
|
1709
|
-
* ```
|
|
1693
|
+
* The methods remain for compatibility with a separately provided server.
|
|
1710
1694
|
*/
|
|
1711
1695
|
declare class CodeSandbox extends Sandbox {
|
|
1712
1696
|
protected static readonly defaultTemplate = "code-interpreter-v1";
|
package/dist/index.d.ts
CHANGED
|
@@ -813,14 +813,15 @@ declare class Sandbox extends SandboxClient {
|
|
|
813
813
|
* Create a new Lizard sandbox from the specified template.
|
|
814
814
|
*
|
|
815
815
|
* Template availability and installed tools depend on the platform and region.
|
|
816
|
-
* Use `base` for shell commands or `
|
|
816
|
+
* Use `base` for shell commands or `interpreter` for Python process commands.
|
|
817
|
+
* Hosted templates do not support the legacy `CodeSandbox` execution API.
|
|
817
818
|
*
|
|
818
819
|
* @param template Name of the sandbox template to boot from.
|
|
819
820
|
*
|
|
820
821
|
* @example
|
|
821
822
|
* ```ts
|
|
822
823
|
* const sandbox = await Sandbox.create('base', { project: 'my-project' })
|
|
823
|
-
* const pythonSandbox = await Sandbox.create('
|
|
824
|
+
* const pythonSandbox = await Sandbox.create('interpreter', { project: 'my-project', timeoutMs: 10 * 60 * 1000 })
|
|
824
825
|
* ```
|
|
825
826
|
*/
|
|
826
827
|
static create(template: string, opts?: SandboxOpts): Promise<Sandbox>;
|
|
@@ -1682,31 +1683,14 @@ interface CreateContextOpts {
|
|
|
1682
1683
|
}
|
|
1683
1684
|
|
|
1684
1685
|
/**
|
|
1685
|
-
*
|
|
1686
|
+
* Legacy client for the code-interpreter execution server.
|
|
1686
1687
|
*
|
|
1687
|
-
*
|
|
1688
|
-
*
|
|
1688
|
+
* Current hosted templates do not provide this server. The default
|
|
1689
|
+
* `code-interpreter-v1` template is unavailable; selecting `interpreter`
|
|
1690
|
+
* does not enable this API. Use `Sandbox.create('interpreter', options)`
|
|
1691
|
+
* and `sandbox.process.exec()` for Python commands instead.
|
|
1689
1692
|
*
|
|
1690
|
-
*
|
|
1691
|
-
*
|
|
1692
|
-
* @example
|
|
1693
|
-
* ```ts
|
|
1694
|
-
* import { CodeSandbox } from '@lizard-build/sdk'
|
|
1695
|
-
*
|
|
1696
|
-
* const sandbox = await CodeSandbox.create({ project: 'my-project' })
|
|
1697
|
-
*
|
|
1698
|
-
* await sandbox.runCode('x = 42')
|
|
1699
|
-
* const result = await sandbox.runCode('print(x * 2)')
|
|
1700
|
-
* console.log(result.stdout) // "84\n"
|
|
1701
|
-
*
|
|
1702
|
-
* await sandbox.kill()
|
|
1703
|
-
* ```
|
|
1704
|
-
*
|
|
1705
|
-
* @example Run JavaScript:
|
|
1706
|
-
* ```ts
|
|
1707
|
-
* const result = await sandbox.runCode('1 + 1', { language: 'javascript' })
|
|
1708
|
-
* console.log(result.results[0].data) // "2"
|
|
1709
|
-
* ```
|
|
1693
|
+
* The methods remain for compatibility with a separately provided server.
|
|
1710
1694
|
*/
|
|
1711
1695
|
declare class CodeSandbox extends Sandbox {
|
|
1712
1696
|
protected static readonly defaultTemplate = "code-interpreter-v1";
|
package/package.json
CHANGED