Interface: ProcessService
Defined in: packages/sdk/src/process-service.ts:101
Persistent process / PTY sessions that survive app restarts — the core primitive under the terminal (and future task runners, REPLs) — plus one-shot exec for fire-and-forget subprocess execution. Exposed as ExtensionContext.process.
Methods
spawn()
spawn(opts): Promise<ProcessSession>;Defined in: packages/sdk/src/process-service.ts:103
Spawn a new session in opts.cwd.
Parameters
opts
Returns
Promise<ProcessSession>
attach()
attach(id, opts?): Promise<ProcessSession>;Defined in: packages/sdk/src/process-service.ts:108
Re-attach to an existing session by id (e.g. after an app restart). Rejects with a 404-style error if the session no longer exists.
Parameters
id
string
opts?
cols?
number
rows?
number
Returns
Promise<ProcessSession>
exec()
exec(
command,
args,
options?): Promise<ProcessExecResult>;Defined in: packages/sdk/src/process-service.ts:138
Run a one-shot command and resolve with its captured output — for extensions that wrap a CLI (git, formatters, linters) rather than drive an interactive shell. Use spawn for long-lived interactive sessions instead.
Runs off the UI thread, so a slow or network-bound command never stutters the app. The returned promise rejects only if the process could not be spawned (e.g. the command was not found); a command that runs but exits non-zero resolves — check ProcessExecResult.code and ProcessExecResult.stderr.
Parameters
command
string
Executable to run (resolved via PATH), e.g. "git".
args
string[]
Arguments passed verbatim — not shell-interpreted, so no quoting/escaping concerns and no shell-injection surface.
options?
Optional ProcessExecOptions (e.g. cwd).
Returns
Promise<ProcessExecResult>
Example
const { stdout, code } = await ctx.process.exec(
"git",
["status", "--porcelain=v2"],
{ cwd: workspaceFolder },
);
if (code === 0) parseStatus(stdout);