@@ -30,25 +30,25 @@ export LEAP0_API_KEY="your-api-key"
3030Or pass it directly when creating a client:
3131
3232``` ts
33- import { Leap0Client } from " leap0"
33+ import { Leap0Client } from " leap0" ;
3434
35- const client = new Leap0Client ({ apiKey: " your-api-key" })
35+ const client = new Leap0Client ({ apiKey: " your-api-key" });
3636```
3737
3838## Quick Start
3939
4040``` ts
41- import { Leap0Client } from " leap0"
41+ import { Leap0Client } from " leap0" ;
4242
43- const client = new Leap0Client ()
44- const sandbox = await client .sandboxes .create ()
43+ const client = new Leap0Client ();
44+ const sandbox = await client .sandboxes .create ();
4545
4646try {
47- const result = await sandbox .process .execute ({ command: " echo hello from leap0" })
48- console .log (result .result .trim ())
47+ const result = await sandbox .process .execute ({ command: " echo hello from leap0" });
48+ console .log (result .result .trim ());
4949} finally {
50- await sandbox .delete ()
51- await client .close ()
50+ await sandbox .delete ();
51+ await client .close ();
5252}
5353```
5454
@@ -59,88 +59,93 @@ try {
5959Stateful code execution with streaming output.
6060
6161``` ts
62- import { CodeLanguage , DEFAULT_CODE_INTERPRETER_TEMPLATE_NAME } from " leap0"
63-
64- const sandbox = await client .sandboxes .create ({ templateName: DEFAULT_CODE_INTERPRETER_TEMPLATE_NAME })
65- const result = await sandbox .codeInterpreter .execute ({ code: " x = 42" , language: CodeLanguage .PYTHON })
62+ import { CodeLanguage , DEFAULT_CODE_INTERPRETER_TEMPLATE_NAME } from " leap0" ;
63+
64+ const sandbox = await client .sandboxes .create ({
65+ templateName: DEFAULT_CODE_INTERPRETER_TEMPLATE_NAME ,
66+ });
67+ const result = await sandbox .codeInterpreter .execute ({
68+ code: " x = 42" ,
69+ language: CodeLanguage .PYTHON ,
70+ });
6671```
6772
6873### Filesystem
6974
7075Read, write, search, and inspect files inside a sandbox.
7176
7277``` ts
73- await sandbox .filesystem .writeFile (" /workspace/hello.txt" , " Hello!" )
74- const content = await sandbox .filesystem .readFile (" /workspace/hello.txt" )
75- const tree = await sandbox .filesystem .tree (" /workspace" , 2 )
78+ await sandbox .filesystem .writeFile (" /workspace/hello.txt" , " Hello!" );
79+ const content = await sandbox .filesystem .readFile (" /workspace/hello.txt" );
80+ const tree = await sandbox .filesystem .tree (" /workspace" , 2 );
7681```
7782
7883### Git
7984
8085Clone repositories and run Git operations inside the sandbox.
8186
8287``` ts
83- await sandbox .git .clone (" https://github.com/octocat/Hello-World.git" , " /workspace/repo" )
84- const status = await sandbox .git .status (" /workspace/repo" )
88+ await sandbox .git .clone (" https://github.com/octocat/Hello-World.git" , " /workspace/repo" );
89+ const status = await sandbox .git .status (" /workspace/repo" );
8590```
8691
8792### Process Execution
8893
8994Run one-off shell commands inside a running sandbox.
9095
9196``` ts
92- const result = await sandbox .process .execute ({ command: " ls -la /workspace" })
93- console .log (result .result )
97+ const result = await sandbox .process .execute ({ command: " ls -la /workspace" });
98+ console .log (result .result );
9499```
95100
96101### Interactive Terminal (PTY)
97102
98103Open persistent terminal sessions over WebSocket.
99104
100105``` ts
101- const session = await sandbox .pty .create ({ cols: 120 , rows: 30 , cwd: " /home/user" })
106+ const session = await sandbox .pty .create ({ cols: 120 , rows: 30 , cwd: " /home/user" });
102107```
103108
104109### Language Server Protocol (LSP)
105110
106111Use language servers for completions and editor-style workflows.
107112
108113``` ts
109- await sandbox .lsp .start ({ languageId: " python" , pathToProject: " /workspace" })
114+ await sandbox .lsp .start ({ languageId: " python" , pathToProject: " /workspace" });
110115```
111116
112117### SSH Access
113118
114119Generate temporary SSH credentials for direct sandbox access.
115120
116121``` ts
117- const access = await sandbox .ssh .createAccess ()
118- console .log (access .hostname , access .port , access .username )
122+ const access = await sandbox .ssh .createAccess ();
123+ console .log (access .hostname , access .port , access .username );
119124```
120125
121126### Desktop Automation
122127
123128Control a graphical desktop inside the sandbox.
124129
125130``` ts
126- const screenshot = await sandbox .desktop .screenshot ()
131+ const screenshot = await sandbox .desktop .screenshot ();
127132```
128133
129134### Snapshots
130135
131136Save and restore sandbox state.
132137
133138``` ts
134- const snapshot = await client .snapshots .create (sandbox , { name: " my-checkpoint" })
135- const restored = await client .snapshots .resume ({ snapshotName: snapshot .name ?? " my-checkpoint" })
139+ const snapshot = await client .snapshots .create (sandbox , { name: " my-checkpoint" });
140+ const restored = await client .snapshots .resume ({ snapshotName: snapshot .name ?? " my-checkpoint" });
136141```
137142
138143## Supported Imports
139144
140145Import clients, enums, and types from the package root:
141146
142147``` ts
143- import { Leap0Client , SandboxState , type CreateSandboxParams } from " leap0"
148+ import { Leap0Client , SandboxState , type CreateSandboxParams } from " leap0" ;
144149```
145150
146151## Examples
0 commit comments