miramarket-cli command. For installation and a first walkthrough, see CLI. For the strategy JSON format and correctness rules, see /agent-strategy-guide.md.
Every command supports --json for machine-readable output. In --json mode, stdout carries exactly one JSON object and nothing else — no banners, color, or spinner frames — except strategies watch --events, noted below. Piping to a non-TTY also disables color and spinners automatically.
Envelope and exit codes
Every command that supports--json emits the same envelope shape on both success and failure:
ok is false and the envelope also carries a human-readable error and a machine-readable code:
code over parsing error text — error wording can change, code is the stable contract.
code values include NOT_AUTHENTICATED, VALIDATION_ERROR, INPUT_ERROR, SERVER_ERROR, PARSE_ERROR, STRATEGY_NOT_FOUND, REGION_RESTRICTED, WALLET_NOT_DELEGATED, WATCH_TIMEOUT, and more — this set grows over time, so don’t treat it as closed.
Sign-in commands
miramarket-cli login [--force]
Authenticates via an OAuth device flow: prints a short code and a verification link, you approve it in any browser (doesn’t need to be the same device — useful over SSH or on a headless machine), and the CLI finishes automatically once approved. A valid cached session short-circuits this by default; pass --force to sign in again (for example, to switch accounts).
Signing in starts a session but does not by itself make the account trade-ready — see account setup under Account commands below.
miramarket-cli logout
Clears the cached session on this machine.
miramarket-cli auth status [--json]
Reports whether a valid session is cached. Always exits 0 — this is a diagnostic, read the payload:
Account commands
A signed-in session is not the same as a trade-ready account — Polymarket orders and live strategy runs also require accepting the platform’s Terms/Privacy/Risk Disclosure and having a delegated deposit wallet with the necessary on-chain approvals.miramarket-cli account status [--json]
Diagnoses trade-readiness across auth, API reachability, region availability, policy acceptance, wallet delegation, and capital. Always exits 0 — ok:true means “the check ran,” not “everything passed.” Read ready and blockers[]:
humanRequired is true on a blocker (not authenticated, wallet not delegated, policies not accepted, region-restricted), surface requiredAction and stop — an agent should never attempt to work around these.
Blocker codes: NOT_AUTHENTICATED, API_UNREACHABLE, REGION_RESTRICTED, POLICIES_NOT_ACCEPTED, WALLET_NOT_DELEGATED, WALLET_CHECK_FAILED.
miramarket-cli account setup [--json]
Idempotent — attaches the wallet-level policy and bootstraps the deposit wallet’s on-chain approvals; safe to re-run any time. Cannot complete onboarding by itself: wallet delegation only happens in a browser during sign-in, and this command never accepts policies on your behalf. It reports exactly what’s still needed and points at account accept-policies or a browser sign-in.
miramarket-cli account policies [--json]
Read-only. Shows the current Terms/Privacy/Risk Disclosure versions, your acceptance status, and canonical URLs.
miramarket-cli account accept-policies
Records legal acceptance of the current Terms, Privacy Policy, and Risk Disclosure. This is a human-only action — it requires typing I accept in an interactive terminal (or, for a human scripting their own machine, pinning the exact current document versions with --i-have-read-and-accept --terms-version=... --privacy-version=... --risk-version=...). An AI agent should never call this on a user’s behalf.
miramarket-cli account capital [--json]
Shows capital currently locked by active strategy runs and pending withdrawal holds — the gap between gross wallet balance and what’s actually spendable.
miramarket-cli account withdraw --recipient <address> [--amount <usd>] --confirm [--json]
Withdraws spendable USDC to an external address. Omit --amount to withdraw all spendable cash. Requesting more than spendable cash is rejected before anything is moved.
0 ok, 3 auth error, 4 server error (a failed transfer releases its hold automatically), 5 bad input.
Strategy authoring commands
See /agent-strategy-guide.md for the JSON format itself and the rules for building a strategy that behaves correctly, not just one that passesvalidate.
miramarket-cli schema [--format=ts|json|markdown]
Prints the strategy schema — ts for TypeScript types, json for a JSON Schema document, markdown for a prose authoring guide with worked examples.
miramarket-cli validate <file> [--json]
Validates a strategy JSON file’s structure. Exit 0 valid, 2 validation errors, 5 bad input (missing file, malformed JSON).
miramarket-cli preview <file> [--json]
Summarizes a strategy without contacting the server — node/edge counts, required principal, and warnings[] for anything that will be silently dropped or misbehave at import.
miramarket-cli edit <file> [flags]
Updates fields in a strategy JSON in place. Edits apply in memory and the result is fully re-validated before writing — if validation fails, the source file is left untouched and the output reports the errors.
miramarket-cli post <file> [flags]
Validates and posts a strategy, then starts a run (unless --no-start). A live (non-demo) post runs a Polymarket market-health check first; demo posts skip it.
0 ok, 2 validation error, 3 auth error, 4 server error, 5 bad input.
Market data commands
None of these require authentication.Trading and portfolio commands
miramarket-cli trade [flags]
Places a CLOB limit order directly — for manual/tactical orders, not strategy automation (use post under Strategy authoring commands for that). Requires authentication and --confirm.
0 ok, 3 auth error, 4 server error, 5 bad input.
Strategy management commands
strategies watch <strategyId> [flags]
Bridging commands
Move USDC between Base and Polygon, or swap Polygon USDC to USDC.e, before trading. All require authentication (the wallet address is resolved from your session).--direction is one of base-to-polygon, polygon-to-base, polygon-usdc-to-usdce, polygon-usdce-to-usdc.
miramarket-cli status
Shows local CLI state: auth, last strategy worked on, last post result, remaining required actions.
Environment variables
Session lifetime
The cached access token lasts 15 minutes, but the CLI also caches a 30-day refresh token (rotated on every use) and silently redeems it at the start of every command — there’s no re-login to babysit, on a laptop or an unattended server alike. If the refresh token itself expires or is revoked, the next command reportsNOT_AUTHENTICATED and you run miramarket-cli login again.