ui/server/src/commandRunner
Runs one of the core CLI's exported functions (create/refactor/research/ importCommand from src/cli.mjs) and turns its console output into a structured result the frontend can render — in particular, splitting out the...
Cockpit server, v0.8. Source: ui/server/src/commandRunner.mjs.
Classes#
CommandTimeoutError#
Defined in: ui/server/src/commandRunner.mjs:38
Extends#
Error
Constructors#
Constructor
new CommandTimeoutError(
ms):CommandTimeoutError
Defined in: ui/server/src/commandRunner.mjs:39
Parameters
ms
any
Returns
Overrides
Error.constructor
Properties#
name
name:
string
Defined in: ui/server/src/commandRunner.mjs:41
Inherited from
Error.name
Variables#
DEFAULT_COMMAND_TIMEOUT_SEC#
constDEFAULT_COMMAND_TIMEOUT_SEC:900=900
Defined in: ui/server/src/commandRunner.mjs:29
Functions#
resolveCommandTimeoutMs()#
resolveCommandTimeoutMs(
env?):number
Defined in: ui/server/src/commandRunner.mjs:32
The per-command deadline in milliseconds: CONSTRUCT_COMMAND_TIMEOUT_SEC or the default.
Parameters#
env?
any = process.env
Returns#
number
runCapturing()#
runCapturing(
fn,__namedParameters?):Promise<void>
Defined in: ui/server/src/commandRunner.mjs:114
Run fn (an async call into one of the wrapped cli.mjs functions),
capturing every console line it (or anything it calls) prints, and
return { ok, output, attribution, durationSeconds, error?, httpStatus }.
attribution is { tool, llm } parsed from the one [tool: ...] [llm: ...] line the command printed, or null if none was found (shouldn't
normally happen for a successful create/refactor/research/import call,
but callers should not assume it's always present).
durationSeconds is this call's own wall-clock total -- a floor
guarantee independent of whatever per-step timing text the command itself
may already have printed into output: some commands
(research, refactor, a single non-slice create/generate) never print
their own "Total:" line, so the UI still needs a real number from
somewhere. Measured around the whole fn() call including a thrown
error, so a mid-command failure still reports accurate elapsed time
rather than losing it.
timeoutMs``): a command that has not settled by then is abandoned — console is restored, the result is {ok:false, httpStatus:504}` with a message naming the timeout, and the
queue moves on to the next command. Whatever the abandoned command prints
afterwards goes to the real console only, never into a later command's
capture.
Parameters#
fn
any
__namedParameters?
timeoutMs?
number = ...
Returns#
Promise<void>
withDir()#
withDir(
args):any[]
Defined in: ui/server/src/commandRunner.mjs:77
Append --dir <projectDir> (the current settings' project directory) to
an argv array bound for a cli.mjs function — every one of create/
refactor/research/importCommand resolves its root via getRoot(args),
which looks for --dir anywhere in the array.
Parameters#
args
any
Returns#
any[]