v2 SDK process launchers. Spawns the closedcode binary as a headless HTTP server (createOpencodeServer) or as an interactive TUI (createOpencodeTui), passing configuration via env and forwarding aborts.

Methods

(static) createOpencodeServer(optionsopt) → {Promise.<{url: string, close: function()}>}

Spawn a headless closedcode server process and resolve once it is listening.

Parameters:
NameTypeAttributesDescription
optionsObject<optional>

Server options.

Properties
NameTypeAttributesDefaultDescription
hostnamestring<optional>
"127.0.0.1"

Interface to bind.

portnumber<optional>
4096

Port to listen on.

timeoutnumber<optional>
5000

Milliseconds to wait for the server to report it is listening before rejecting.

configObject<optional>

Server config serialized into CLOSEDCODE_CONFIG_CONTENT; config.logLevel is also passed as --log-level.

signalAbortSignal<optional>

Signal that, when aborted, stops the server and rejects the promise.

Returns:

The server URL and a close handle.

Type: 
Promise.<{url: string, close: function()}>

(static) createOpencodeTui(optionsopt) → {Object}

Spawn an interactive closedcode TUI process that inherits the current stdio.

Parameters:
NameTypeAttributesDescription
optionsObject<optional>

TUI options.

Properties
NameTypeAttributesDescription
projectstring<optional>

Project directory to open (--project).

modelstring<optional>

Model to use (--model).

sessionstring<optional>

Session id to resume (--session).

agentstring<optional>

Agent to start with (--agent).

configObject<optional>

Config serialized into CLOSEDCODE_CONFIG_CONTENT.

signalAbortSignal<optional>

Signal that, when aborted, stops the TUI.

Returns:

A handle that terminates the TUI process.

Type: 
Object