Documentation Index
Fetch the complete documentation index at: https://mintlify.com/shobcoder/shob/llms.txt
Use this file to discover all available pages before exploring further.
createOpencodeServer launches shob serve as a managed child process from within your Node.js or Bun application, waits until the server is ready to accept connections, and returns the server URL alongside a close() function to tear it down. This lets you embed a Shob server in automated pipelines, test harnesses, or any programmatic workflow without running the CLI yourself.
Installation
createOpencodeServer(options?)
Spawns shob serve and waits for the “server listening” line on stdout before resolving.
Options
The hostname the server binds to. Passed as
--hostname to shob serve.The port the server listens on. Passed as
--port to shob serve.Maximum time in milliseconds to wait for the server to start. If the server has not printed its “listening” line within this window,
createOpencodeServer kills the process and rejects with a timeout error.An
AbortSignal that, when triggered, stops the server process and rejects the startup promise with the signal’s reason. Useful for cancelling server startup in CI or test runners.A Shob configuration object. The value is serialised as JSON and injected into the child process via the
SHOB_CONFIG_CONTENT environment variable. Any key set here overrides the corresponding key in shob.json. The logLevel field is additionally forwarded as --log-level CLI flag.Return value
The full base URL of the started server, e.g.
"http://127.0.0.1:4096". Pass this directly to createOpencodeClient.Stops the server child process and releases any abort-signal listeners. Safe to call multiple times.
Example
Error handling
If the server process exits before printing its “listening” line, the promise rejects with a message containing the exit code and any captured stdout/stderr output:AbortSignal is triggered:
createOpencodeTui(options?)
Launches the Shob interactive TUI as a child process with stdio: "inherit", so it takes over the current terminal. Returns a close() handle.
Options
Open the TUI in the context of a specific project path. Passed as
--project.Pre-select a model in
providerID/modelID format. Passed as --model.Open a specific session by ID. Passed as
--session.Pre-select a specific agent. Passed as
--agent.An
AbortSignal that stops the TUI process when triggered.A Shob configuration object injected via
SHOB_CONFIG_CONTENT.Return value
Stops the TUI child process.
Example
createOpencode(options?)
A convenience function exported from the root @shob-ai/sdk that calls both createOpencodeServer and createOpencodeClient in sequence, returning them together. It accepts the same options as createOpencodeServer.
Return value
The server handle returned by
createOpencodeServer.A ready-to-use
OpencodeClient already pointed at server.url.Example
Using an AbortSignal for cleanup
Thesignal option integrates cleanly with Node.js’s built-in AbortController for timeout-based or external cancellation: