LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
LangSmith
  • Client
  • Run Trees
  • Traceable
  • Evaluation
  • Schemas
  • Langchain
  • Jest
  • Vitest
  • Wrappers
  • Anonymizer
  • Jestlike
  • Vercel
  • Anthropic
  • Sandbox
⌘I

LangChain Assistant

Ask a question to get started

Enter to send•Shift+Enter new line

Menu

LangSmith
ClientRun TreesTraceableEvaluationSchemasLangchainJestVitestWrappersAnonymizerJestlikeVercelAnthropicSandbox
Language
Theme
JavaScriptlangsmithexperimentalsandboxSandboxrun
Method●Since v0.6

run

Execute a command in the sandbox.

When wait is true (default) and no streaming callbacks are provided, tries WebSocket first and falls back to HTTP POST.

When wait is false or streaming callbacks are provided, uses WebSocket (required). Returns a CommandHandle for streaming output.

Copy
run(command: string, options: RunOptions  __type): Promise<CommandHandle>

Parameters

NameTypeDescription
command*string

Shell command to execute.

options*RunOptions & __type

Execution options.

Example

Copy
// Blocking (default)
const result = await sandbox.run("echo hello");
console.log(result.stdout);

// Streaming with callbacks
const result = await sandbox.run("make build", {
  onStdout: (data) => process.stdout.write(data),
});

// Non-blocking with CommandHandle
const handle = await sandbox.run("make build", { wait: false });
for await (const chunk of handle) {
  process.stdout.write(chunk.data);
}
const result = await handle.result;
View source on GitHub