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, next. Source: ui/server/src/commandRunner.mjs.
Classes#
CommandTimeoutError#
Defined in: ui/server/src/commandRunner.mjs:60
Extends#
Error
Constructors#
Constructor
new CommandTimeoutError(
ms):CommandTimeoutError
Defined in: ui/server/src/commandRunner.mjs:61
Parameters
ms
any
Returns
Overrides
Error.constructor
Properties#
name
name:
string
Defined in: ui/server/src/commandRunner.mjs:63
Inherited from
Error.name
Variables#
DEFAULT_COMMAND_TIMEOUT_SEC#
constDEFAULT_COMMAND_TIMEOUT_SEC:900=900
Defined in: ui/server/src/commandRunner.mjs:39
DEFAULT_MAX_CONCURRENT_COMMANDS#
constDEFAULT_MAX_CONCURRENT_COMMANDS:2=2
Defined in: ui/server/src/commandRunner.mjs:52
Functions#
resolveCommandTimeoutMs()#
resolveCommandTimeoutMs(
env?):number
Defined in: ui/server/src/commandRunner.mjs:42
The per-command deadline in milliseconds: CONSTRUCT_COMMAND_TIMEOUT_SEC or the default.
Parameters#
env?
any = process.env
Returns#
number
resolveMaxConcurrentCommands()#
resolveMaxConcurrentCommands(
env?):number
Defined in: ui/server/src/commandRunner.mjs:55
The global concurrency cap: CONSTRUCT_MAX_CONCURRENT_COMMANDS (a positive integer) or the default.
Parameters#
env?
any = process.env
Returns#
number
runCapturing()#
runCapturing(
fn,__namedParameters?):Promise<any>
Defined in: ui/server/src/commandRunner.mjs:215
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, exitCode, error?, httpStatus }
(exitCode is the process exit code the CLI would have ended with, ).
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. Time spent waiting for an earlier command of the
same login, or for a free run slot, is not counted.
timeoutMs``): a command that has not settled by then is abandoned — its console capture and run slot are released, the result is {ok:false, httpStatus:504}` with a message naming
the timeout, and the login's queue moves on to the next command. Whatever
the abandoned command prints afterwards goes to the real console only,
never into any later or concurrent command's capture.
`maxConcurrent``): the command waits for one of that many global run slots before it starts.
Parameters#
fn
any
__namedParameters?
maxConcurrent?
number = ...
timeoutMs?
number = ...
Returns#
Promise<any>
runningCommandCount()#
runningCommandCount():
number
Defined in: ui/server/src/commandRunner.mjs:111
How many commands hold a run slot right now (test seam).
Returns#
number
withDir()#
withDir(
args):any[]
Defined in: ui/server/src/commandRunner.mjs:173
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[]