@ai-digital-factory/lmt-cli
v1.0.0
Published
Interactive and headless Live Market Terminal client for local and dev.
Readme
Live Market Terminal CLI
Use the published @ai-digital-factory/lmt-cli package to log in to Live Market Terminal, manage Operator Sessions, and complete Zerodha login from your terminal. The executable is lmt; live-market-terminal is an alias with the same commands.
Install or update
Requires Node.js 22 or later, with npm and npx available on your PATH. No source checkout, pnpm, build step, or local configuration file is needed for the published package.
node --version
npm install --global @ai-digital-factory/lmt-cli@latest
lmt --helpRun the same install command to update to the latest published version. To check your installed version:
npm list --global @ai-digital-factory/lmt-cli --depth=0The package includes the non-secret Origins, Gate scopes, and SMS endpoint. Choose --env dev for the deployed dev service, or --env local for a running local stack. Only local and dev are supported; prod is rejected. Installing the CLI does not start services or provision credentials.
@ai-digital-factory/lmt-web-cli (the former lmt-web executable) is deprecated on npm. Its commands are the lmt web command group of this package; there is no lmt-web alias.
Daily routine: the Operator and the Controller
The Controller is the automated agent that operates Live Market Terminal through lmt and lmt web. It authenticates with the Controller Session: one Operator Session per environment, shared by every HTTP command, every lmt web browser (mobile and desktop), every worktree and every local port that reaches the same Gate.
Once per trading day, the Operator runs
lmtin a terminal, chooses the environment and picks Log in. The Operator is unlocked from SMS and the Operator types only the one Kite OTP. The Zerodha access token expires daily, so this is repeated each trading day. If the SMS read credential is missing, the Operator runslmt credential provisiononce first.The Controller runs
lmt status --env <env>before any other step. Exit 0 (outcome: "success") means the Controller Session is usable, so the Controller continues:lmt status --env local lmt status --env devBlocked means exit 4.
outcome: "blocked"and itsnextStepsay what is missing:lmt(log in) orlmt credential provision(no SMS credential). The Controller then asks the Operator once to run that command and waits. It asks before starting the task, never in the middle of it. Every command that needs the Controller Session (settings,token,pair,candle-export,zerodhaandlmt web start) returns the same exit 4 andnextStepwhen it is unusable.
The Controller reuses the shared local Gate and Broker and never starts its own. It never asks for OTPs, passwords or credentials in chat, and never logs the Controller Session out. Checks that must log in or out on their own use --profile NAME (a CLI Client Profile) or lmt web start --fresh, both of which leave the Controller Session untouched.
Candle Export for the Controller
With the Controller Session logged in, request one instrument and optional IST date:
lmt candle-export NSE:IDEA --date 2026-10-23 --env dev --timeout 2mOmitting --date asks Broker for the exchange's latest completed trading session, accounting for holidays and Finalization Grace. The stdout JSON candleExport contains the immutable Hosted URL, filename, resolved identity/date, source availability, reference-fetch metadata, and comparison counts. Missing data or Zerodha authentication is explained in the workbook. Export does not start Zerodha login or token recovery. Local/dev only; see lmt --help for exit conventions.
Price Cross pairs for the Controller
Price Cross runs in Paper mode only. These commands reach the owning Broker through Gate with the Controller Session. They never save Settings, so the Settings Version does not change. They never place Orders, and the CLI has no strategy store or Kite client of its own.
lmt pair list --env dev
lmt pair assign --ce 1 --pe 3 --lots 2 --env dev
lmt pair report PAIR_ID --output ./pair.xlsx --env dev
lmt pair report PAIR_ID --publish --env dev
lmt pair unpair PAIR_ID --confirm --env dev| Command | Success JSON (one line on stdout) |
|---|---|
| pair list | pairs.active and pairs.past. Each pair has its globally unique pairId, ceRow/peRow, frozen ceInstrument/peInstrument, pairLots, frozenLotSize, quantity, assignedAt, unpairedAt (past pairs only) and pnl (exact per-leg, pair and daily Decision P&L). Ended pairs stay listed after their rows are reused. |
| pair assign | reason: "pair_assigned" and pair, the Broker's summary with its identity, roles, frozen lot size and quantity. |
| pair unpair --confirm | reason: "unpaired" with unpair.requestedAt. When a paper position was closed, unpair.exit holds the exit decision, including requestedAt and fills[].priceMinute. When the pair was flat there is no exit. A repeat gives reason: "already_unpaired". |
| pair report | Downloads the lifetime workbook unchanged. report.path, report.bytes, report.sha256 and report.decisionCount describe it. Without --output, the file is saved under the server filename in the current directory and an existing file is never overwritten. |
| pair report --publish | report.url is a new immutable Hosted URL. It matches the exportUrl field on the Broker's price_cross_report_snapshot_published log. Publishing again gives a new URL and leaves the old one unchanged. |
Exit codes: 0 success; 1 refusal or uncertain; 2 invalid invocation (including --env prod); 3 Operator Login required (--profile only); 4 blocked because the Controller Session is unusable.
Refusals. A refusal is outcome: "fail" with exit 1, and reason and error.code both hold the Broker's code, unchanged. The codes are invalid_lots (Pair Lots outside 1 through the configured maximum, default 10), same_type, already_paired, order_in_flight, real_position_open, row_unavailable, row_empty, the *_mismatch codes, flag_disabled, store_unavailable and, for reports, pair_not_found. Each assign refusal matches the fields_reason on its pair_refused log. pair unpair without --confirm is refused locally with exit 2 and sends nothing.
Uncertain outcome. If pair assign, pair unpair or pair report --publish is submitted but no answer arrives before --timeout (or Gate or Broker fails with a 5xx other than store_unavailable), the result is outcome: "uncertain", reason: "submission_uncertain", exit 1. The recovery field says to read pair list. The CLI never repeats the submission. Run lmt pair list to see whether the change happened before submitting again.
Dev-safe QA sequence
Run this outside 09:15–15:30 IST, using a same-expiry CE row and PE row already applied on dev (rows 1 and 3 here).
lmt settings read …and notesettingsVersion.lmt pair assign --ce 1 --pe 3 --lots 2 …: exit 0. Recordpair.pairId,frozenLotSizeandquantity.- Check the refusals:
--lots 0and--lots 11giveinvalid_lots, re-running step 2 givesalready_paired, and--ce 1 --pe 1givessame_type. Each exits 1. lmt pair list …: the pair is inpairs.active.lmt pair report PAIR_ID --output ./pair.xlsx …, thenlmt pair report PAIR_ID --publish …twice. The two URLs differ, and each matches aprice_cross_report_snapshot_publishedrow.lmt pair unpair PAIR_ID …without--confirm: exit 2, and nopair_unpairedrow is logged.lmt pair unpair PAIR_ID --confirm …:unpaired, with exit details or a flat removal. Repeat it:already_unpaired, and there is still only onepair_unpairedrow.- Uncertain:
lmt pair unpair PAIR_ID --confirm --timeout 1ms …on a fresh pair either fails before submission or givesuncertainwith exit 1. In both cases runlmt pair listto reconcile. The CI testa submitted assign or unpair that outlives the timeout is uncertain, nonzero and never repeatedproves that exactly one submission is made. lmt pair list …: the pair is inpairs.past.lmt settings read …shows the samesettingsVersionas step 1.
Automated coverage: pnpm --filter @ai-digital-factory/lmt-cli test runs src/pair-commands.test.ts (stubbed Gate) and integration/price-cross-pairs.test.ts. The integration test uses real Gate and Broker, a temporary Price Cross Store and a recording order client that must see zero calls. It also covers flag-off: existing pairs are listed and can be Unpaired, and a new assign is refused with flag_disabled.
Quick start: interactive login
Obtain an SMS read credential authorized to read
live-market-terminal-operator-directoryin the selected Gate scope from your administrator. You never type the Operator Login username or password; the CLI reads them from SMS.Provision the credential once using the masked prompt:
lmt credential provisionPaste the SMS read credential and press Enter. The prompt shows
SMS credential saved.and exits. The credential is stored in~/.lmt/secrets.pemand shared by every profile and every LMT CLI command, includinglmt web operator-loginin fresh browser sessions.Open the interactive terminal (a terminal is required; without one it exits 2):
lmtThe first screen chooses the Deployment Environment:
localordev, each with its resolved Origin. Production is never listed. Your last confirmed choice is pre-selected (localon first use) and remembered in~/.lmt/preferences.json, an owner-only file kept apart from secrets.lmt --env local(or--env dev) skips this screen.--device mobile|desktoppre-selects the Web menu's device and is shown in the header.The main menu header shows
<env> · <origin> · <login state>, where the state islogged in,needs Zerodha login,needs loginorSMS credential missing, from the same check aslmt status. Choose with ↑/↓ and Enter; Esc returns to the environment screen.- Log in restores the Controller Session when Gate still accepts it, otherwise unlocks the Operator from SMS. It then starts a Zerodha login and asks for the six-digit OTP (masked). A rejected OTP can be re-entered without restarting. When already logged in, the item says so and starts no Zerodha attempt. Without an SMS credential it offers the provision prompt and returns to the menu.
- Status shows the
lmt statusfields. - Log out asks
Log out of <env> everywhere? y/Nand ends the Controller Session for every command and device. - Settings, Token, Pairs, Candle Export, Zerodha, Checks and Credential offer every headless HTTP command without remembering an argument: Settings Read and Edit and save (Market Protection, Entry Categories, and an optional all-four-field Zerodha Credentials replacement), Token Read, Replace and Verify current, Pairs List, Assign, Unpair (explicit confirm) and Report (Publish or Save, warning before an overwrite), Candle Export, Zerodha Status, Observe attempt, Start login and OTP, Validate and Resume Zerodha Validation, Validate Operator Session, and Provision SMS credential. Validate Zerodha Session always starts a new Zerodha login, so when Zerodha is already logged in it asks first; it then asks for the OTP in place (a rejected OTP can be re-entered). Each item calls the same action as its headless command and submits once. An uncertain result says so and names the read to make first; nothing is resubmitted automatically. Refusals show their reason code. Secret inputs are masked and never shown. Items that need a usable Controller Session say
Log in firstand offer Log in. Esc goes back one level. - Web runs every
lmt webcommand without typing session IDs or control references. Start browser picks the device and headless or visible and opens a browser with the Controller Session; when the Controller Session is not authenticated it shows "Log in first" and Enter jumps to Log in. Sessions lists the environment's live browsers (id, device, URL) and makes the chosen one current. Inspect (or Inspect full page) shows the title, URL, Origin, screenshot path and numbered controlsn. [kind] label. Act on a control picks a number from the latest result, then Click, Fill (masked for password-like fields; Tab marks any value secret), Read (secret fields show only present, length and fingerprint), Select (type the option), Paste, Check (masked expected value), Clipboard-check or Scroll. If the page changed, the stale-reference error is shown and you must Inspect again; old numbers are never reused. Clipboard, Navigate (type a path or URL), Scroll (↑/↓, PgUp/PgDn, ←/→), Close (optionally with a full-page screenshot), Stop and Install browser complete the set. Fresh login test starts a--freshbrowser, isolated from the Controller Session, with Operator login/logout and Zerodha login, OTP (masked), cancel and logout. Every result shows its screenshot path.--profileControllers have no Web item. - Quit exits.
The Controller Session is normally established once per trading day, because the Zerodha access token expires daily. Afterwards every HTTP and lmt web command can use it:
lmt status --env devlmt interactive --env dev --profile NAME logs in an isolated CLI Client Profile instead and shows profile: NAME in the header.
Headless Operator login and sessions
Headless commands require --env. They never prompt for input. Without --profile, every command uses the Controller Session: the one Operator Session the Controller holds per environment. It is keyed by environment and Operator, not by local Origin, so every checkout and local port reaching the same Gate shares it. --profile NAME selects an isolated CLI Client Profile instead; logging a profile in or out never touches the Controller Session. Provision the SMS credential using the masked interactive command above, then run:
lmt login --env dev
lmt status --env dev
lmt validate operator-session --env dev
lmt logout --env devlogin reads the configured Operator's username and password from the selected Gate scope's SMS Operator Directory and authenticates through Gate. SMS reads invoke @ai-digital-factory/[email protected] through npx, so npm registry access is needed when it is not cached. Validation exercises login and session behavior using a temporary profile, logs out its temporary sessions, and removes only its temporary records; it never ends the Controller Session.
status prints one JSON line and never creates or replaces a session:
{"version":1,"command":"status","outcome":"blocked","environment":"local","origin":"http://127.0.0.1:5199","session":"controller","smsCredential":"present","operatorSession":"valid","zerodha":"unauthenticated","nextStep":"Run `lmt` in a terminal to log in"}outcome is success (exit 0) only when operatorSession is valid and zerodha is authenticated. Otherwise it is blocked (exit 4) with a nextStep: lmt credential provision when smsCredential is missing, else lmt. A session Gate rejects is cleared locally and reported expired; it is never silently re-authenticated. Gate being unreachable is failure (exit 1). With --profile, session is profile and profile names it. Commands needing an authenticated Controller Session (settings, token, pair, candle-export, zerodha) return blocked, exit 4 and the same nextStep when it is unusable.
logout revokes the Operator Session through Gate and clears its saved cookies and pending Zerodha attempt. If Gate cannot confirm logout, the command fails and retains cookies for retry. Other profiles, the shared SMS credential, and Broker-owned SMS access tokens remain intact.
For automated credential provisioning, pipe one non-empty credential line through protected stdin:
lmt credential provision --env dev --credential-stdin < /path/to/protected-sms-credential-fileReplace the path with an owner-readable credential file supplied by your secret-management process. Keep SMS credentials, passwords, and cookies out of command arguments. Provisioning saves the credential locally; it does not verify SMS access.
Headless Zerodha login
First establish the Operator Session with login. Zerodha credentials stay on Broker. Headless Zerodha login uses one two-step flow, matching Web: start login first, then obtain the OTP from Kite and submit it to that exact attempt.
Start the Zerodha Login Attempt:
lmt zerodha login --env dev --profile my-dev-sessionWhen Zerodha requests the OTP, the command returns
outcome: "blocked",reason: "awaiting_otp", exit code4, andzerodha.attemptId. This is the expected handoff to obtain the OTP from Kite.Copy that attempt ID and submit the current six-digit OTP:
# Bash: mask entry, disable tracing, and send through the builtin printf pipe. set +x IFS= read -r -s -p 'Kite OTP: ' otp_value printf '\n' >&2 printf '%s\n' "$otp_value" | lmt zerodha otp --env dev --profile my-dev-session --attempt ATTEMPT_ID --otp-stdin unset otp_valueReplace
ATTEMPT_IDwithzerodha.attemptIdfrom step 1 and enter the code obtained after the challenge at the masked prompt. Use the same environment and profile in both steps. Success requires verification of the resulting Zerodha Session through Gate. OTPs are excluded from JSON results and diagnostics and never stored.
From the monorepo root, use pnpm -s cli:headless in place of lmt. Both local and dev are supported.
To inspect the attempt or verify the session:
lmt zerodha observe --env dev --profile my-dev-session --attempt ATTEMPT_ID
lmt zerodha status --env dev --profile my-dev-session--attempt ID is required for zerodha otp and zerodha observe. The CLI does not remember attempt IDs. Existing saved attempt IDs are ignored and removed on the next profile-store write; saved cookies and the SMS credential remain usable. Argument-based --otp CODE and --otp=CODE are rejected before credential or network access. Migrate scripts to explicitly selected --otp-stdin; provide one six-digit line through a protected pipe and close it. Terminal input, extra lines, more than eight bytes, and unfinished input past --timeout are rejected. There is no single-pass login or automatic resume. See protected OTP migration and local/dev smoke steps.
An expired, canceled, replaced, or failed attempt fails without starting a new login or submitting the OTP to another attempt. Explicitly run zerodha login again, obtain the new challenge's OTP, and submit it using the new attempt ID. A rejected OTP that leaves the attempt active returns awaiting_otp with Broker's rejection message and retry count; retry zerodha otp with a fresh code and the same ID. Every command remains noninteractive and honors --timeout.
Profiles and local use
Profiles save Client Identity and Operator Session cookies across invocations. Sessions are isolated by profile, environment, canonical Origin, and configured Operator. Profile names must be 1–64 letters, digits, dots, underscores, or hyphens, starting with a letter or digit.
Storage is ~/.lmt/secrets.pem: a protected JSON file containing the shared SMS credential, the Controller Session per environment (a dedicated controllerSessions field, so no profile name can collide with it) and per-profile cookies. The CLI enforces owner-only permissions and migrates legacy storage automatically. Do not share this file or include it in logs or version control.
For local use, first start Web, Gate, and Broker from a configured source checkout with pnpm dev:local in live-market-terminal/. The installed CLI uses the bundled canonical local Origin (http://127.0.0.1:5173) through Web's /api proxy; it does not fall back to a different port.
Different local port. When the CLI runs with --env local from anywhere inside a checkout (the nearest ancestor with a .git directory or worktree file), it reads that checkout's gitignored, repository-root lmt.config.local.json. If it sets environments.local.origin, for example {"environments":{"local":{"origin":"http://127.0.0.1:5199"}}}, both HTTP commands and lmt web commands use that Origin; lmt web results report it as origin. No environment variable is needed. Only the local Origin is read from that file: --env dev, smsEndpoint, Gate scope and Operator always come from the packaged configuration. An unreadable or invalid file, or a local Origin with credentials, a path, a query or a fragment, fails --env local commands with exit code 2 and invalid_local_config. The CLI's SMS read credential is separate from the service credential used by Gate and Broker.
lmt --env local
lmt status --env localBrowser sessions (lmt web)
lmt web drives Live Market Terminal Web in a Playwright Chromium browser and returns structured JSON observations and screenshots. Install its browser runtime once per machine (--with-deps also installs Linux system packages):
lmt web install-browser
lmt web --helpStart a browser, observe it, and end it:
lmt web start --env dev --device desktop
lmt web inspect --session SESSION_ID
lmt web inspect --session SESSION_ID --full-page
lmt web close --session SESSION_ID --full-page
lmt web stop --session SESSION_IDlmt web start opens a browser already authenticated by the environment's Controller Session: it adds the Controller Session's Operator Session and Client Identity cookies before opening the Home Page, so neither device logs in again. Desktop and mobile each keep one live browser, tracked in an owner-only owners.json beside the session sockets. When Gate renews the Operator Session cookie in the browser, the new value is written back to the Controller Session. Cookies never appear in output.
If the Controller Session is not authenticated (as lmt status would report), lmt web start prints outcome: "blocked" with a nextStep naming lmt, exits 4, and opens no browser. After lmt logout, Gate rejects the Controller Session for every browser and command; browser processes that are already open keep running until lmt web stop.
lmt web start --fresh opens a temporary, isolated browser that never reads or writes the Controller Session. The browser login commands (operator-login, operator-logout, zerodha-login, zerodha-otp, zerodha-cancel, zerodha-logout) exist only to test the login screens, so they run only in fresh sessions; on any other session they exit 2 with fresh_session_required. lmt web interactive is retired: run lmt in a terminal to log in.
Test the login screens with --fresh
Use --fresh only when a check must see the Home or Zerodha Login Page. A fresh browser starts logged out and is discarded when it closes:
lmt web start --env dev --device desktop --fresh
lmt web operator-login --session SESSION_ID
lmt web zerodha-login --session SESSION_ID
lmt web zerodha-otp --session SESSION_ID --attempt ATTEMPT_ID --stdin < /path/to/protected-otp
lmt web zerodha-logout --session SESSION_ID
lmt web operator-logout --session SESSION_IDoperator-login fills the rendered Home Page form with the Operator read from SMS, using the shared credential in ~/.lmt/secrets.pem (provision it with lmt credential provision). zerodha-login returns loginAttempt.attemptId with status: awaiting_otp; supply that attempt's fresh six-digit OTP on standard input to zerodha-otp. The tool never retrieves an OTP or repeats a submission. A rejected OTP can be retried while the same attempt is active. A fresh Zerodha login still uses the Operator's Broker-owned shared state, so it can replace the Operator's active attempt; agents ask the Operator before running it.
Interact with the page
Every action returns an updated observation and screenshot, captured once the page has rendered and its pending data requests (fetch and XHR, not EventSource streams) have finished. Use the control references (--ref) from the latest result; they expire with the next observation, and missing, stale or duplicate references fail explicitly.
lmt web fill --session SESSION_ID --ref REF --value "draft text"
lmt web click --session SESSION_ID --ref REF
lmt web select --session SESSION_ID --ref REF --value NSE
lmt web scroll --session SESSION_ID --y 500
lmt web navigate --session SESSION_ID --url /operator
lmt web read --session SESSION_ID --ref REF
lmt web clipboard --session SESSION_ID
lmt web paste --session SESSION_ID --ref REF
lmt web check --session SESSION_ID --ref REF --stdin < /path/to/protected-expectation
lmt web clipboard-check --session SESSION_ID --ref REFNavigation accepts a path or URL within the session's Origin. Credential fields are detected automatically; use fill --secret for other sensitive values. read returns value for an ordinary field; protected fields, secret reads and clipboard observations return only present, length and a 12-hex SHA-256 fingerprint. Screenshots mask secret values. A click whose completion cannot be confirmed returns outcome: "uncertain" and a nonzero exit; inspect before deciding what to do, because the CLI never repeats it.
Mobile emulation (iPhone 13, 390 × 844) and headless mode are the defaults. --device desktop selects the 1440 × 900 desktop preset and --headed shows the window. On Dev Deployment, open the Web UI with ?captureSafe=1 on the first navigation (for example lmt web navigate --session SESSION_ID --url /?captureSafe=1) to keep Capture-safe Mode on for that tab. Screenshots mask access-token values even without it.
Worktree screenshots
To screenshot a worktree's Web on its own port, run that worktree's Web server against the running local Gate, and set the port in the worktree's gitignored lmt.config.local.json (see Different local port). Then, from inside that worktree:
lmt status --env local
lmt web start --env local --device desktop
lmt web navigate --session SESSION_ID --url /settings
lmt web inspect --session SESSION_ID --full-page
lmt web stop --session SESSION_IDNo environment variable is involved. lmt web start reports the targeted origin; confirm it is the worktree's port before comparing screenshots. The Controller Session belongs to the local Gate, so every worktree reuses it without logging in again.
Browser commands need Node.js 22 or later, like every lmt command, and the Chromium runtime from lmt web install-browser.
Output, deadlines, and troubleshooting
Headless commands write one versioned JSON object per line to stdout; diagnostics go to stderr. Inspect outcome, reason, and, on failure, error. Use the process exit code for automation:
| Exit code | Meaning | Next step |
| --- | --- | --- |
| 0 | Success or validation pass | Continue. |
| 1 | Action failure | Read the diagnostic; check SMS permissions or service reachability. |
| 2 | Invalid invocation or target | Check lmt --help; supply local or dev and a valid profile. |
| 3 | Operator Login required (--profile only) | Run login or interactive login with the same environment and profile. |
| 4 | Blocked: Controller Session unusable, validation blocked, or Zerodha awaiting OTP | Run the nextStep; for awaiting_otp, obtain the Kite OTP and run zerodha otp --attempt ID --otp-stdin. |
Actions default to 30 seconds; validation defaults to 2 minutes. Headless actions and validation accept a finite deadline between 1 millisecond and 10 minutes:
lmt status --env dev --profile my-dev-session --timeout 45s
lmt validate operator-session --env dev --profile my-dev-session --timeout 2mlmt: command not found: confirm the global installation withnpm list --global @ai-digital-factory/lmt-cli --depth=0and add npm's global executable directory to PATH (npm prefix --global, thenbin/on macOS/Linux).- Missing SMS credential: run
lmt credential provisionand retry. The credential is shared, but it needs access to the scope used by your chosen environment. - SMS unavailable or invalid Operator Directory: check the credential's read access and the selected Gate scope's Operator Directory with your administrator.
- Session expired or rejected: the CLI clears rejected session cookies. Log in again explicitly using the same profile and environment.
- Origin or Broker unavailable: check the selected deployment. For local use, keep the full stack running at the canonical Origin.
statusrequires Broker to be available even when Gate still accepts the session.
Run from a source checkout
For contributors, from live-market-terminal/:
pnpm cli --env dev
pnpm -s cli:headless status --env dev
pnpm --filter @ai-digital-factory/lmt-cli interactive credential provision --env devThese repository scripts rebuild the CLI. The published commands above run directly from the installed package. The CLI sets NODE_USE_ENV_PROXY=0 on startup so local Gate requests are not sent through HTTP(S)_PROXY.
Maintain the npm package
The Release LMT CLI GitHub Action is dispatched manually on main. It builds
current main, tests the CLI, builds a standalone package with bundled private
contracts, selects the next npm version, and tests a clean installation of the exact
tarball it publishes publicly under latest. Node 22 and pnpm 10.33.3 match CI.
Only SMS_CREDENTIAL is configured as a GitHub Actions secret for this workflow.
It must be able to read NPM_TOKEN from SMS scope infra, at Vault
secret/data/infra/NPM_TOKEN with field value. The endpoint and scope are
non-secret repository configuration. The existing npm token needs publishing
permission for @ai-digital-factory/lmt-cli; it is masked and passed only to the
publishing step. No credential values are included in the package.
@ai-digital-factory/lmt-web-cli is deprecated and no longer released: the Web CLI ships inside this package as lmt web, and its release workflow was removed. The npm deprecation message points users to lmt web.
First publication uses 0.1.0; later runs raise the highest published stable
version by the dispatch's bump choice: patch (default, 0.1.6 to 0.1.7),
minor (0.2.0) or major (1.0.0). Registry/authentication failures stop the release. Versions change
only in the temporary publishing artifact, with no bump commit, git tag, GitHub
Release, Origin Version, or deployment. A retry after successful npm publication
selects another version, since published npm versions are immutable. npm can accept
an upload before public registry processing finishes; the action polls for visibility
for five minutes. If confirmation times out after a successful upload, check npm
before rerunning the release to avoid publishing an unnecessary version.
To reproduce the packaging checks from the repository root:
(cd live-market-terminal && pnpm --filter @ai-digital-factory/lmt-cli package:build)
tarball=$(bash .github/scripts/pack-lmt-cli.sh /tmp/lmt-cli-package)
node .github/scripts/test-lmt-cli-package.mjs "$tarball"Zerodha validation
lmt validate zerodha-session --env local --profile NAME starts a new Broker-owned attempt and returns an attributed blocked report when a human OTP is needed. Resume with the same profile and explicit --attempt ID; add --otp-stdin to submit the protected human code. Without that flag, the supplied attempt is only observed. A pass requires authoritative attempt state followed by a hard session check; status alone does not pass the scenario. The resulting session stays available on the caller profile.
Fresh validation can replace the Operator's active Broker attempt and successful login can refresh its shared token. CLI profile isolation does not isolate that shared state. See local/dev validation smoke steps and recorded prerequisites.
Settings and token commands for the Controller
Read ordinary Settings and their durable Settings Version with:
lmt settings read --env devSave one intent by piping a single JSON object to protected stdin. Supply the version you reviewed and only the settings you intend to change. For example:
printf '%s\n' '{"expectedSettingsVersion":7,"entryCategories":[]}' |
lmt settings save --stdin --env devAn empty list disables all Entry Categories; omitted fields keep their saved values. Replacing credentials requires all four fields (userId, password, apiKey, apiSecret) inside a credentials object supplied through protected stdin. Keep secrets in an owner-readable input file or a protected pipe, never in command arguments or shell history. One changed save advances one Settings Version; a current unchanged save returns unchanged without a write. Every ordinary API write, including standalone credential saves, requires expectedSettingsVersion. Stale saves return settings_conflict; read Settings again and review the intended changes before submitting. A transport timeout after submission or an unconfirmed Broker save returns uncertain with exit code 1. Commands never retry a save. An ambiguous SMS write blocks authoritative Settings reads and further Operator-record writes until Broker restarts and reloads its durable record. The existing Market Watch resize recovery limitation still applies across stores.
Access-token operations use a separate version and endpoint:
lmt token read --env dev
lmt token replace --stdin --env dev < /path/to/protected-token-request.jsonThe token request contains expected (the metadata returned by token read), optionally accessToken for a new value, verifyCurrent: true to validate the saved token without reading its value, and continueReplacement: true after reviewing an active-trading confirmation. A same-token submission verifies the submitter without reinstalling the token. Ordinary Settings Save never replaces access tokens. Token values and saved credentials do not appear in command results.
Save a Candle Export locally
lmt candle-export NSE:IDEA --date 2026-10-28 --env dev --output ./candles.xlsx --timeout 2m--output PATH downloads the newly published workbook with the CLI HTTP client. The JSON retains candleExport.url and adds download.path, download.bytes, and download.sha256. The parent directory must exist; an existing destination is never overwritten. HTTP errors, interrupted downloads, deadlines, and file errors return exit 1 without claiming success or leaving a partial destination. The timeout covers publication and download together. Without --output, the command still returns only the published context.
Use this option when Python urllib receives Cloudflare 403/error 1010 from the public R2 URL (SUK-95). It removes the need for a separate downloader. It does not change the public hosting policy; direct Python downloads still require a delivery configuration change.
