Open-source, secure environment with real-world tools for enterprise-grade agents.
Python agentaiai-agentai-agentscode-interpretercopilotdevelopmentdevtoolsgptgpt-4javascriptllmnextjsopenaipythonreactsoftwaretypescript
fix(js-sdk): use commands.run in Sandbox.getHost() example (#1531) (#1550)
Mish Ushakov5e141a765ff1
diff --git a/.changeset/fix-gethost-example-command.md b/.changeset/fix-gethost-example-command.mdnew file mode 100644index 000000000..e2c2f8c55--- /dev/null+++ b/.changeset/fix-gethost-example-command.md@@ -0,0 +1,5 @@+---+"e2b": patch+---++Fix the `Sandbox.getHost()` documentation example so it can be copy-pasted. The `@example` called `sandbox.commands.exec(...)`, which is not a method on the `Commands` class (it exposes `run`), so running the snippet threw `TypeError: sandbox.commands.exec is not a function`. It now uses `sandbox.commands.run(..., { background: true })`, allowing the long-running HTTP server to start before the example calls `getHost()`. Documentation only, no behavior change.diff --git a/packages/js-sdk/src/sandbox/index.ts b/packages/js-sdk/src/sandbox/index.tsindex e3133c9c9..5bc8ec529 100644--- a/packages/js-sdk/src/sandbox/index.ts+++ b/packages/js-sdk/src/sandbox/index.ts@@ -511,7 +511,7 @@ export class Sandbox extends SandboxApi {* ```ts* const sandbox = await Sandbox.create()* // Start an HTTP server- * await sandbox.commands.exec('python3 -m http.server 3000')+ * await sandbox.commands.run('python3 -m http.server 3000', { background: true })* // Get the hostname of the HTTP server* const serverURL = sandbox.getHost(3000)* ```