@ai-digital-factory/lms-cli
v0.1.10
Published
Command-line interface for querying stored application logs
Readme
@ai-digital-factory/lms-cli
Provider-neutral CLI for coding agents and operators to discover streams and Query stored application logs. Application logging still goes through @ai-digital-factory/logging. This package only reads.
Use this README as the contract. Do not infer provider-specific URLs, headers, or admin APIs.
Goal
Given maintainer connection details, list stream names and run SQL Queries over a required time range. Print JSON to stdout. Never print credentials.
Install and run
Node.js 22 or newer.
# one-shot (preferred for agents)
npx --yes @ai-digital-factory/lms-cli help
npx --yes @ai-digital-factory/lms-cli streams
npx --yes @ai-digital-factory/lms-cli query --sql 'SELECT * FROM "STREAM"' --from 2026-09-21T00:00:00Z --to 2026-09-21T01:00:00Z
# or install
pnpm add -g @ai-digital-factory/lms-cli
lms helpThe published binary is lms. It reads only process.env. It never loads .env or .env.local. The launcher (npx, CI, a shell, or pnpm cli in this repo) must inject the variables.
Required environment
Ask the logging maintainer for:
| Variable | Meaning |
| --- | --- |
| LOG_URL | HTTPS origin of the logging destination, covering every stream (example: https://logger.example). An empty path uses organization default. Use /api/{org} only when the organization is not default. HTTP is upgraded to HTTPS except on localhost. |
| LOG_CREDENTIAL | Opaque Base64 credential. Query and streams need a search-capable credential, not an ingest-only token. Encode email:password (or email + search token) the same way as pnpm credential. |
Never hard-code, log, or commit either value. If a Query returns 401/403, replace the ingest token with the native logging-destination login used in the UI.
export LOG_URL='https://logger.example'
export LOG_CREDENTIAL='<opaque-credential>'Agent workflow
Run commands in this order:
lms help— confirmstreamsandquery.lms streams— JSON array of stream names for SQLFROM.lms query --sql ... --from ... --to ...— JSON array of matching rows.
Do not call provider consoles, invent extra subcommands, or skip the time range.
Commands
lms help
Exit 0. Human-readable usage on stdout.
lms streams
Exit 0. Stdout is a JSON array of strings:
["lmt_dev","example_server","lmt_local","lmt_prod"]Use those names in query SQL, usually quoted: SELECT * FROM "lmt_dev".
lms query
Required flags:
| Flag | Value |
| --- | --- |
| --sql | SQL. Include FROM "<stream>" using a name from streams. |
| --from | Range start, UTC ISO-8601 with Z (example: 2026-09-21T12:30:00Z) |
| --to | Range end, UTC ISO-8601 with Z, strictly after --from |
Optional: --limit (default 100, maximum 1000).
Exit 0. Stdout is a JSON array of row objects. No matches → [].
npx --yes @ai-digital-factory/lms-cli query \
--sql 'SELECT * FROM "lmt_dev"' \
--from 2026-09-21T12:30:00Z \
--to 2026-09-21T14:00:00ZErrors
Non-zero exit. Short message on stderr. Messages may include HTTP status and a sanitized destination reason. They must not include credentials, URLs, or the SQL text.
| Symptom | What to do |
| --- | --- |
| LOG_URL must be configured / LOG_CREDENTIAL must be configured | Export both variables in this process |
| --sql / --from / --to missing or invalid | Pass all three; --from/--to must be ...Z UTC instants |
| --limit must be at most 1000 | Lower --limit |
| 401 / 403 / not authorized to Query | Use a search-capable credential (UI/native login), not an ingest-only token |
| 400 | Fix SQL or the time range |
| Timeout | Narrow --from / --to |
| Unexpected result / not JSON | Maintainer/destination problem; retry later |
Do not
- Load
.envinside the published CLI - Pass
--from/--towithoutZ - Assume a default time window
- Treat ingest-only SDK tokens as sufficient for
streamsorquery - Expect table-formatted output, pagination, ingest, or tail
- Print
LOG_CREDENTIALorLOG_URLin agent traces
