Module: cli-entry
Classes
CliInputError
Raised by generated executables when the route module's own inputSchema
rejects parsed input — invalid input is a usage failure (exit 2), never an
execution failure. Construct it through cliInputError so a schema
failure carries its CliInputIssue list; the message-only form stays
for failures that are not attributable to individual arguments.
Extends
Error
Constructors
Constructor
new CliInputError(
message,issues?):CliInputError
Parameters
message
string
issues?
readonly CliInputIssue[]
Returns
Overrides
Error.constructor
Properties
~effect/ErrorReporter/attributes?
readonlyoptional~effect/ErrorReporter/attributes?:ReadonlyRecord<string,unknown>
Inherited from
Error.~effect/ErrorReporter/attributes
~effect/ErrorReporter/ignore?
readonlyoptional~effect/ErrorReporter/ignore?:boolean
Inherited from
Error.~effect/ErrorReporter/ignore
~effect/ErrorReporter/severity?
readonlyoptional~effect/ErrorReporter/severity?:Severity
Inherited from
Error.~effect/ErrorReporter/severity
~effect/Runtime/errorExitCode?
readonlyoptional~effect/Runtime/errorExitCode?:number
Inherited from
Error.~effect/Runtime/errorExitCode
~effect/Runtime/errorReported?
readonlyoptional~effect/Runtime/errorReported?:boolean
Inherited from
Error.~effect/Runtime/errorReported
cause?
optionalcause?:unknown
Inherited from
Error.cause
issues
readonlyissues: readonlyCliInputIssue[]
message
message:
string
Inherited from
Error.message
name
name:
string
Inherited from
Error.name
stack?
optionalstack?:string
Inherited from
Error.stack
stackTraceLimit
staticstackTraceLimit:number
The Error.stackTraceLimit property specifies the number of stack frames
collected by a stack trace (whether generated by new Error().stack or
Error.captureStackTrace(obj)).
The default value is 10 but may be set to any valid JavaScript number. Changes
will affect any stack trace captured after the value has been changed.
If set to a non-number value, or set to a negative number, stack traces will not capture any frames.
Inherited from
Error.stackTraceLimit
Methods
captureStackTrace()
staticcaptureStackTrace(targetObject,constructorOpt?):void
Creates a .stack property on targetObject, which when accessed returns
a string representing the location in the code at which
Error.captureStackTrace() was called.
The first line of the trace will be prefixed with
${myObject.name}: ${myObject.message}.
The optional constructorOpt argument accepts a function. If given, all frames
above constructorOpt, including constructorOpt, will be omitted from the
generated stack trace.
The constructorOpt argument is useful for hiding implementation
details of error generation from the user. For instance:
Parameters
targetObject
object
constructorOpt?
Function
Returns
void
Inherited from
Error.captureStackTrace
prepareStackTrace()
staticprepareStackTrace(err,stackTraces):any
Parameters
err
Error
stackTraces
CallSite[]
Returns
any
See
https://v8.dev/docs/stack-trace-api#customizing-stack-traces
Inherited from
Error.prepareStackTrace
CliUsageError
Raised for argv-shape failures: unknown commands or options, missing or malformed values.
Extends
Error
Constructors
Constructor
new CliUsageError(
message):CliUsageError
Parameters
message
string
Returns
Overrides
Error.constructor
Properties
~effect/ErrorReporter/attributes?
readonlyoptional~effect/ErrorReporter/attributes?:ReadonlyRecord<string,unknown>
Inherited from
Error.~effect/ErrorReporter/attributes
~effect/ErrorReporter/ignore?
readonlyoptional~effect/ErrorReporter/ignore?:boolean
Inherited from
Error.~effect/ErrorReporter/ignore
~effect/ErrorReporter/severity?
readonlyoptional~effect/ErrorReporter/severity?:Severity
Inherited from
Error.~effect/ErrorReporter/severity
~effect/Runtime/errorExitCode?
readonlyoptional~effect/Runtime/errorExitCode?:number
Inherited from
Error.~effect/Runtime/errorExitCode
~effect/Runtime/errorReported?
readonlyoptional~effect/Runtime/errorReported?:boolean
Inherited from
Error.~effect/Runtime/errorReported
cause?
optionalcause?:unknown
Inherited from
Error.cause
message
message:
string
Inherited from
Error.message
name
name:
string
Inherited from
Error.name
stack?
optionalstack?:string
Inherited from
Error.stack
stackTraceLimit
staticstackTraceLimit:number
The Error.stackTraceLimit property specifies the number of stack frames
collected by a stack trace (whether generated by new Error().stack or
Error.captureStackTrace(obj)).
The default value is 10 but may be set to any valid JavaScript number. Changes
will affect any stack trace captured after the value has been changed.
If set to a non-number value, or set to a negative number, stack traces will not capture any frames.
Inherited from
Error.stackTraceLimit
Methods
captureStackTrace()
staticcaptureStackTrace(targetObject,constructorOpt?):void
Creates a .stack property on targetObject, which when accessed returns
a string representing the location in the code at which
Error.captureStackTrace() was called.
The first line of the trace will be prefixed with
${myObject.name}: ${myObject.message}.
The optional constructorOpt argument accepts a function. If given, all frames
above constructorOpt, including constructorOpt, will be omitted from the
generated stack trace.
The constructorOpt argument is useful for hiding implementation
details of error generation from the user. For instance:
Parameters
targetObject
object
constructorOpt?
Function
Returns
void
Inherited from
Error.captureStackTrace
prepareStackTrace()
staticprepareStackTrace(err,stackTraces):any
Parameters
err
Error
stackTraces
CallSite[]
Returns
any
See
https://v8.dev/docs/stack-trace-api#customizing-stack-traces
Inherited from
Error.prepareStackTrace
Interfaces
CliInputIssue
One input-validation failure of a routed command, already spelled in CLI terms (#465): the argument the user typed rather than the schema path.
Properties
expected
readonlyexpected:string
The plain-language expectation, e.g. number <= 55000 or one of: json, text.
message
readonlymessage:string
The schema's own message for the issue, kept for machine consumers.
received?
readonlyoptionalreceived?:unknown
The value the command received at the issue path; absent when nothing was received.
target
readonlytarget:string
The CLI spelling of the failing argument: --flag for a named option,
<name> for a positional, --input.<path> for a projected MCP command,
or input when the issue is not attributable to one argument.
CliRenderedDocument
Properties
root
readonlyroot:CliRenderedDocumentNode
status
readonlystatus:"failed"|"represented-error"|"success"
value?
readonlyoptionalvalue?:unknown
version
readonlyversion:number
GeneratedCliExecuteContext
Properties
args
readonlyargs: readonlystring[]
The raw argv the command consumed, for the provider invocation's args.
json
readonlyjson:boolean
True when --json was passed; plain commands already emit canonical JSON.
signal
readonlysignal:AbortSignal
terminal
readonlyterminal:AgentTerminal
The process's terminal capability (#511), probed once by the shell; the executable mounts it as request.terminal.
GeneratedCliInputSchema
Methods
parse()
parse(
input):unknown
Parameters
input
unknown
Returns
unknown
GeneratedCliRenderContext
Properties
args
readonlyargs: readonlystring[]
The raw argv the command consumed, for the dispatch invocation's args.
signal
readonlysignal:AbortSignal
terminal
readonlyterminal:AgentTerminal
The process's terminal capability (#511), the same value that selected the output mode.
GeneratedCliRenderSession
One rendered run: a live render-event stream plus its validation and teardown.
Properties
close
readonlyclose: () =>Promise<void>
Returns
Promise<void>
events
readonlyevents: () =>ReadableStream<CliRenderedEvent>
Returns
ReadableStream<CliRenderedEvent>
validate
readonlyvalidate: (value) =>unknown
Validates the complete document's value (the route's resultSchema.parse).
Parameters
value
unknown
Returns
unknown
GeneratedCliWebCommand
Properties
run
readonlyrun: (argv,context) =>Promise<number>
Parameters
argv
readonly string[]
context
Returns
Promise<number>
GeneratedCliWebContext
Properties
name
readonlyname:string
signal
readonlysignal:AbortSignal
writeErr
readonlywriteErr: (text) =>void
Parameters
text
string
Returns
void
writeOut
readonlywriteOut: (text) =>void
Parameters
text
string
Returns
void
ParsedGeneratedCliArgv
Properties
input
readonlyinput:Readonly<Record<string,unknown>>
json
readonlyjson:boolean
ndjson
readonlyndjson:boolean
RunGeneratedCliOptions
Properties
argv
readonlyargv: readonlystring[]
commands
readonlycommands: readonlyCompiledCliCommand[]
description?
readonlyoptionaldescription?:string
execute
readonlyexecute: (command,input,context) =>Promise<unknown>
Runs one resolved plain command with parsed input; returns the validated result.
Parameters
command
CompiledCliCommand
input
Readonly<Record<string, unknown>>
context
Returns
Promise<unknown>
name
readonlyname:string
render?
readonlyoptionalrender?: (command,input,context) =>GeneratedCliRenderSession|Promise<GeneratedCliRenderSession>
Opens one rendered run for a resolved .tsx command with parsed input.
Parameters
command
CompiledCliCommand
input
Readonly<Record<string, unknown>>
context
Returns
GeneratedCliRenderSession | Promise<GeneratedCliRenderSession>
signal?
readonlyoptionalsignal?:AbortSignal
terminal?
readonlyoptionalterminal?:AgentTerminal
The terminal capability to report and select the output mode from (#511). Omitted, the shell probes this process's stdout and stderr once.
version
readonlyversion:string
web?
readonlyoptionalweb?:GeneratedCliWebCommand
Framework-owned command dispatched before authored routes (#564).
writeErr?
readonlyoptionalwriteErr?: (text) =>void
Parameters
text
string
Returns
void
writeOut?
readonlyoptionalwriteOut?: (text) =>void
Parameters
text
string
Returns
void
RunGeneratedRenderedScriptOptions
Properties
argv
readonlyargv: readonlystring[]
createSession
readonlycreateSession: (argv,context) =>GeneratedCliRenderSession
Opens one rendered run for the script with the mode flags removed from argv.
Parameters
argv
readonly string[]
context
signal
AbortSignal
terminal
Returns
name
readonlyname:string
signal?
readonlyoptionalsignal?:AbortSignal
terminal?
readonlyoptionalterminal?:AgentTerminal
The terminal capability to report and select the output mode from (#511); probed from the process when omitted.
writeErr?
readonlyoptionalwriteErr?: (text) =>void
Parameters
text
string
Returns
void
writeOut?
readonlyoptionalwriteOut?: (text) =>void
Parameters
text
string
Returns
void
Type Aliases
CliOutputMode
CliOutputMode =
"json"|"markdown"|"ndjson"|"tty"
The four output modes of one rendered invocation: interactive tty
updates progress in place before the final document; piped markdown
emits exactly one final document with no partial fallbacks; json emits
the canonical validated final value; ndjson emits the sequence-numbered
render-event stream (an Agent Bundle CLI/script dialect — never MCP
JSON-RPC, never written to an MCP server's stdout).
CliRenderedDocumentNode
CliRenderedDocumentNode = {
children: readonlyCliRenderedDocumentNode[];kind:"result";metadata?:unknown; } | {kind:"markdown";text:string; } | {kind:"text";text:string; } | {kind:"context";text:string; } | {kind:"json";value:unknown; } | {completed:number;kind:"progress";message?:string;total?:number; } | {data:string;kind:"image";mimeType:string; } | {data:string;kind:"audio";mimeType:string; } | {kind:"resource";mimeType?:string;name:string;uri:string; } | {code:string;kind:"error";message:string; }
Structural mirrors of the runtime package's versioned Agent Document and
render-event contracts (AGENT_DOCUMENT_VERSION 1). The generated
executable feeds real runtime values through these shapes; keeping them
structural means this shell never imports @agent-bundle/runtime — the
generated bundle resolves the runtime from the consumer project instead.
CliRenderedEvent
CliRenderedEvent = {
document:CliRenderedDocument;sequence:number;type:"shell"; } | {completed:number;message?:string;sequence:number;total?:number;type:"progress"; } | {boundaryId:string;document:CliRenderedDocument;sequence:number;type:"replace"; } | {boundaryId?:string;error: {code:string;message:string; };sequence:number;type:"error"; } | {document:CliRenderedDocument;sequence:number;type:"complete"; }
Variables
cliInputError
constcliInputError: (command,input,error) =>CliInputError
Maps a route module's inputSchema failure onto a CliInputError
whose issues name the CLI argument, the expectation, and the received
value (#465). Any other thrown value keeps its message, exactly as before.
Generated executables, the routed-CLI test harness, and the rendered-command
harness all call this so every surface reports the same text.
Parameters
command
CompiledCliCommand
input
unknown
error
unknown
Returns
cliInputInvalidCode
constcliInputInvalidCode:"CLI_INPUT_INVALID"="CLI_INPUT_INVALID"
The machine-readable error code of an input-validation failure in --json and --ndjson output.
cliInputIssueLine
constcliInputIssueLine: (issue) =>string
The one-line human rendering of one input issue.
Parameters
issue
Returns
string
confirmationRequiredMessage
constconfirmationRequiredMessage: (server,tool) =>string
The fail-closed confirmation diagnostic shared by bulk and explicit MCP tool projections.
Parameters
server
string
tool
string
Returns
string
mapGeneratedCliInput
constmapGeneratedCliInput: (command,inputSchema,projectionModule,input) =>Promise<unknown>
Applies projection defaults, mapInput, and the route schema at the generated CLI boundary.
Parameters
command
CompiledCliCommand
inputSchema
projectionModule
Readonly<Record<string, unknown>> | undefined
input
Readonly<Record<string, unknown>>
Returns
Promise<unknown>
parseGeneratedCliArgv
constparseGeneratedCliArgv: (command,argv) =>ParsedGeneratedCliArgv
Parses argv and applies projected-tool confirmation exactly as the generated CLI shell does.
Parameters
command
CompiledCliCommand
argv
readonly string[]
Returns
projectCliDocumentToMarkdown
constprojectCliDocumentToMarkdown: (document) =>string
Projects one final Agent Document onto stable Markdown (the piped and TTY final output).
Parameters
document
Returns
string
renderedDocumentExitCode
constrenderedDocumentExitCode: (policy,document,value) =>number
The exit code a completed rendered run sets once its value has passed the
route's resultSchema: 1 for a non-success document, else the policy's
code. Throws when the result policy finds no valid exitCode (the shell
reports the message and exits 1). Generated bins export this decision so
the Workbench production path records the bin's own verdict.
Parameters
policy
"result" | "zero"
document
Pick<CliRenderedDocument, "status">
value
unknown
Returns
number
runGeneratedCliEntry
construnGeneratedCliEntry: (options) =>Promise<number>
Runs one routed-CLI invocation to completion and returns the process exit
code. Help and machine output go through writeOut; diagnostics through
writeErr; nothing here touches process.
Parameters
options
Returns
Promise<number>
runGeneratedCliProcess
construnGeneratedCliProcess: (options) =>Promise<void>
The generated executable envelope: wires process argv, stdout/stderr,
SIGINT/SIGTERM (which reach the framework AbortSignal and exit 130/143),
and the process exit code around runGeneratedCliEntry.
Parameters
options
Omit<RunGeneratedCliOptions, "argv" | "signal" | "writeErr" | "writeOut">
Returns
Promise<void>
runGeneratedRenderedScript
construnGeneratedRenderedScript: (options) =>Promise<number>
Runs one rendered script (src/scripts/<name>.tsx) to completion and
returns the process exit code. The framework dialect reserves exactly
--json and --ndjson (before a -- terminator); every other argument
passes through to the script component's argv prop untouched. Exit codes
derive from the final document status: 0 on success, 1 otherwise.
Parameters
options
RunGeneratedRenderedScriptOptions
Returns
Promise<number>
runGeneratedRenderedScriptProcess
construnGeneratedRenderedScriptProcess: (options) =>Promise<void>
The generated rendered-script envelope, mirroring runGeneratedCliProcess.
Parameters
options
Omit<RunGeneratedRenderedScriptOptions, "argv" | "signal" | "writeErr" | "writeOut">
Returns
Promise<void>
References
AgentTerminal
Re-exports AgentTerminal