lminspect reference

Complete command-line subcommand and flag reference, host schema contexts, hook interfaces, Flow/Request/Response methods, standard lmcode_std_v3 REST and CLI interfaces, and exit codes for lminspect v0.1.0.

Host and CLI commands and flags

Command or flagArgumentsDescription
--versionnonePrint the lminspect version string (lminspect 0.1.0) and exit 0.
--lmcode-schema / --dsl-schema[--json]Write the exact embedded schema/lminspect.dsl.json bytes to stdout and exit 0.
--lmcode-signatures / --dsl-signaturesnonePrint all canonical host and 226 standard lmcode_std_v3 signatures and exit 0.
--lmcode / --dsl<file.dslb> [file...] [--save <out.dslb>]Execute one or more compiled LMScript bytecode files offline, optionally saving the bytecode artifact to --save.
run / proxy[proxy flags]Start the HTTP/HTTPS proxy server with the configured mode, TLS settings, declarative rules, and DSL addon script.
run --listen / --bind / --port--listen <addr> | --bind <ip> | --port <int>Configure proxy bind address and port (default 127.0.0.1:8080).
run --moderegular | reverse:<target_url> | transparentSelect forward proxy mode (regular), reverse proxy mode to an upstream origin, or transparent mode.
run --ssl-bump / --ca-cert / --ca-key[--ssl-bump] [--ca-cert <path>] [--ca-key <path>]Enable dynamic TLS MITM decryption using leaf certificates signed by the specified or ephemeral Root CA.
run --insecure[true|false]Skip TLS certificate verification on upstream server connections (default true).
run --tap / --record / --replay-server[--tap] [--record <file.jsonl>] [--replay-server <file.jsonl>]Stream sanitized flow summaries to stderr, append sanitized flows to a JSONL file, or serve recorded responses from JSONL.
run --script<file.dslb>Load a compiled _lmcode_ bytecode addon implementing RequestHook, ResponseHook, or FlowHook into the proxy pipeline.
run --redirect / --route / --header / --mock<pattern=value> (repeatable)Apply declarative URL redirects, host:port routing overrides, key:val header injections, or status_code:body mock responses.
replay--client <file.jsonl> [--target <host:port>]Replay recorded client requests from a JSONL file, optionally overriding destination host:port, and log sanitized status lines.
certgen[--cert <ca.crt>] [--key <ca.key>]Generate and save a local Root CA certificate and private key for SSL-Bump TLS interception.

Host contexts, hook interfaces, and Flow methods

Type / context / interfaceSignatureDescription
context inspect: Inspectorinspect.new_flow(method: string, url: string) -> FlowConstruct a new synthetic HTTP Flow with the given HTTP method and full URL.
Inspectorinspect.parse_flow(json_str: string) -> FlowReconstitute a Flow object from its serialized JSON representation.
context flow: FlowflowReference the currently active Flow during hook execution.
interface RequestHook@request fn h(flow: Flow) -> void implements RequestHookHook invoked on each incoming HTTP request before forwarding to the upstream server.
interface ResponseHook@response fn h(flow: Flow) -> void implements ResponseHookHook invoked after receiving an upstream response (or synthetic mock) before returning to the client.
interface FlowHookfn h(flow: Flow) -> void implements FlowHookGeneral flow lifecycle hook invoked on a Flow object.
Flowf.id() -> string | f.client_addr() -> string | f.duration_ms() -> intReturn the 16-character hex flow ID, client IP:port address, or elapsed request duration in milliseconds.
Flowf.request() -> Request | f.response() -> Response | f.has_response() -> bool | f.error() -> stringAccess the mutable Request and Response objects, check whether a response exists, or read any flow error string.
Flowf.respond(status_code: int, body: string, content_type: string) -> voidAttach a synthetic HTTP response directly from the proxy and skip upstream forwarding.
Flowf.intercept() -> void | f.is_intercepted() -> bool | f.resume() -> voidPause a flow for inspection, check interception state, or resume a paused flow.
Flowf.kill() -> void | f.is_killed() -> boolImmediately drop the connection and mark the flow as killed, or check killed status.
Flowf.to_json() -> stringSerialize the flow to a credential-sanitized JSON string.
global functionsassert(cond: bool, msg: string) -> void | println(msg: string) -> voidAssert a boolean invariant (aborting with an error if false) or print a credential-sanitized line to stdout.

Request and Response methods

TypeMethod signatureDescription
Requestreq.method() -> string | req.set_method(string) -> voidGet or set the HTTP request method (GET, POST, PUT, DELETE, etc.).
Requestreq.url() -> string | req.set_url(string) -> voidGet or replace the full request URL, updating scheme, host, port, and path automatically.
Requestreq.scheme() -> string | req.set_scheme(string) -> voidGet or set the URL scheme (http or https).
Requestreq.host() -> string | req.set_host(string) -> void | req.port() -> int | req.set_port(int) -> voidGet or rewrite the destination hostname and TCP port.
Requestreq.path() -> string | req.set_path(string) -> voidGet or rewrite the request path and raw query string (/path?k=v).
Requestreq.header(string) -> string | req.set_header(string, string) -> void | req.remove_header(string) -> void | req.header_names() -> StrListRead (case-insensitively), set, remove, or list HTTP request headers.
Requestreq.query(string) -> string | req.set_query(string, string) -> void | req.query_names() -> StrListRead, set, or list URL query parameter keys and values.
Requestreq.text() -> string | req.set_text(string) -> voidRead or replace the request payload body as text and update Content-Length.
Responseresp.status_code() -> int | resp.set_status_code(int) -> voidGet or set the HTTP response status code (200, 201, 404, 500, etc.).
Responseresp.reason() -> string | resp.set_reason(string) -> voidGet or set the HTTP status reason phrase (OK, Not Found, etc.).
Responseresp.header(string) -> string | resp.set_header(string, string) -> void | resp.remove_header(string) -> void | resp.header_names() -> StrListRead, set, remove, or list HTTP response headers.
Responseresp.text() -> string | resp.set_text(string) -> voidRead or replace the response payload body as text and synchronize Content-Length.

Standard lmcode_std_v3 REST and CLI interfaces

Interface or functionSignature / annotationDescription
RestGet .. RestOptions@"/path/:param" fn h(x: RestExchange) -> void implements RestGetBind an HTTP GET, POST, PUT, DELETE, PATCH, HEAD, or OPTIONS route handler.
RestHandler@"/path" fn h(x: RestExchange) -> void implements RestHandlerBind a method-agnostic HTTP route handler.
CliCommand@"cmd" fn h(x: RestExchange) -> void implements CliCommandBind a named CLI subcommand dispatched by rest_cli.
CliOption@"--flag" fn h(x: RestExchange) -> void implements CliOptionBind a CLI option flag (--flag=val or --flag val) evaluated before the command handler.
rest_config / rest_routerest_config(key: string, val: string) -> void | rest_route(method: string, path: string, handler: string) -> voidConfigure host, port, or session (ephemeral or global) and dynamically register HTTP route handlers.
rest_serve / rest_stop / rest_clirest_serve() -> void | rest_stop() -> void | rest_cli(args: StrList) -> stringStart or stop the embedded standard HTTP server or dispatch CLI options, commands, and routes in-process.
RestExchangex.method() | x.path() | x.body() | x.param(string) | x.query(string) | x.header(string) | x.get(string) -> string | x.has_query(string) | x.has_header(string) -> bool | x.status(int) | x.set_header(string, string) | x.send(string) | x.json(string) | x.set(string, string) -> void | x.increment(string) -> intInspect request metadata, emit plain text or JSON responses, and read or mutate ephemeral/global session state.

Exit codes

Exit codeCategoryMeaning
0SuccessProxy exited cleanly, CA generation or flow replay completed, or _lmcode_ bytecode program succeeded.
1Operation errorProxy startup, CA generation, addon initialization, or JSONL replay file open failed.
2Usage errorMissing or invalid CLI command, unknown flag, or unreadable program path under LMCODE_INVOCATION_FILE.
3Host / VM errorBytecode load failure, schema mismatch, or runtime execution failure in standalone --lmcode / --dsl mode.
4Application failureHost or application assertion failure reported through the LMCODE_INVOCATION_FILE manifest v1 result contract.