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 flag | Arguments | Description |
|---|---|---|
| --version | none | Print 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-signatures | none | Print 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 --mode | regular | reverse:<target_url> | transparent | Select 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 / interface | Signature | Description |
|---|---|---|
| context inspect: Inspector | inspect.new_flow(method: string, url: string) -> Flow | Construct a new synthetic HTTP Flow with the given HTTP method and full URL. |
| Inspector | inspect.parse_flow(json_str: string) -> Flow | Reconstitute a Flow object from its serialized JSON representation. |
| context flow: Flow | flow | Reference the currently active Flow during hook execution. |
| interface RequestHook | @request fn h(flow: Flow) -> void implements RequestHook | Hook invoked on each incoming HTTP request before forwarding to the upstream server. |
| interface ResponseHook | @response fn h(flow: Flow) -> void implements ResponseHook | Hook invoked after receiving an upstream response (or synthetic mock) before returning to the client. |
| interface FlowHook | fn h(flow: Flow) -> void implements FlowHook | General flow lifecycle hook invoked on a Flow object. |
| Flow | f.id() -> string | f.client_addr() -> string | f.duration_ms() -> int | Return the 16-character hex flow ID, client IP:port address, or elapsed request duration in milliseconds. |
| Flow | f.request() -> Request | f.response() -> Response | f.has_response() -> bool | f.error() -> string | Access the mutable Request and Response objects, check whether a response exists, or read any flow error string. |
| Flow | f.respond(status_code: int, body: string, content_type: string) -> void | Attach a synthetic HTTP response directly from the proxy and skip upstream forwarding. |
| Flow | f.intercept() -> void | f.is_intercepted() -> bool | f.resume() -> void | Pause a flow for inspection, check interception state, or resume a paused flow. |
| Flow | f.kill() -> void | f.is_killed() -> bool | Immediately drop the connection and mark the flow as killed, or check killed status. |
| Flow | f.to_json() -> string | Serialize the flow to a credential-sanitized JSON string. |
| global functions | assert(cond: bool, msg: string) -> void | println(msg: string) -> void | Assert a boolean invariant (aborting with an error if false) or print a credential-sanitized line to stdout. |
Request and Response methods
| Type | Method signature | Description |
|---|---|---|
| Request | req.method() -> string | req.set_method(string) -> void | Get or set the HTTP request method (GET, POST, PUT, DELETE, etc.). |
| Request | req.url() -> string | req.set_url(string) -> void | Get or replace the full request URL, updating scheme, host, port, and path automatically. |
| Request | req.scheme() -> string | req.set_scheme(string) -> void | Get or set the URL scheme (http or https). |
| Request | req.host() -> string | req.set_host(string) -> void | req.port() -> int | req.set_port(int) -> void | Get or rewrite the destination hostname and TCP port. |
| Request | req.path() -> string | req.set_path(string) -> void | Get or rewrite the request path and raw query string (/path?k=v). |
| Request | req.header(string) -> string | req.set_header(string, string) -> void | req.remove_header(string) -> void | req.header_names() -> StrList | Read (case-insensitively), set, remove, or list HTTP request headers. |
| Request | req.query(string) -> string | req.set_query(string, string) -> void | req.query_names() -> StrList | Read, set, or list URL query parameter keys and values. |
| Request | req.text() -> string | req.set_text(string) -> void | Read or replace the request payload body as text and update Content-Length. |
| Response | resp.status_code() -> int | resp.set_status_code(int) -> void | Get or set the HTTP response status code (200, 201, 404, 500, etc.). |
| Response | resp.reason() -> string | resp.set_reason(string) -> void | Get or set the HTTP status reason phrase (OK, Not Found, etc.). |
| Response | resp.header(string) -> string | resp.set_header(string, string) -> void | resp.remove_header(string) -> void | resp.header_names() -> StrList | Read, set, remove, or list HTTP response headers. |
| Response | resp.text() -> string | resp.set_text(string) -> void | Read or replace the response payload body as text and synchronize Content-Length. |
Standard lmcode_std_v3 REST and CLI interfaces
| Interface or function | Signature / annotation | Description |
|---|---|---|
| RestGet .. RestOptions | @"/path/:param" fn h(x: RestExchange) -> void implements RestGet | Bind an HTTP GET, POST, PUT, DELETE, PATCH, HEAD, or OPTIONS route handler. |
| RestHandler | @"/path" fn h(x: RestExchange) -> void implements RestHandler | Bind a method-agnostic HTTP route handler. |
| CliCommand | @"cmd" fn h(x: RestExchange) -> void implements CliCommand | Bind a named CLI subcommand dispatched by rest_cli. |
| CliOption | @"--flag" fn h(x: RestExchange) -> void implements CliOption | Bind a CLI option flag (--flag=val or --flag val) evaluated before the command handler. |
| rest_config / rest_route | rest_config(key: string, val: string) -> void | rest_route(method: string, path: string, handler: string) -> void | Configure host, port, or session (ephemeral or global) and dynamically register HTTP route handlers. |
| rest_serve / rest_stop / rest_cli | rest_serve() -> void | rest_stop() -> void | rest_cli(args: StrList) -> string | Start or stop the embedded standard HTTP server or dispatch CLI options, commands, and routes in-process. |
| RestExchange | x.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) -> int | Inspect request metadata, emit plain text or JSON responses, and read or mutate ephemeral/global session state. |
Exit codes
| Exit code | Category | Meaning |
|---|---|---|
| 0 | Success | Proxy exited cleanly, CA generation or flow replay completed, or _lmcode_ bytecode program succeeded. |
| 1 | Operation error | Proxy startup, CA generation, addon initialization, or JSONL replay file open failed. |
| 2 | Usage error | Missing or invalid CLI command, unknown flag, or unreadable program path under LMCODE_INVOCATION_FILE. |
| 3 | Host / VM error | Bytecode load failure, schema mismatch, or runtime execution failure in standalone --lmcode / --dsl mode. |
| 4 | Application failure | Host or application assertion failure reported through the LMCODE_INVOCATION_FILE manifest v1 result contract. |