lmnr-cli 0.1.10 → 0.1.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -12,26 +12,104 @@ npx lmnr-cli@latest <command>
12
12
  npm install -g lmnr-cli
13
13
  ```
14
14
 
15
- ## Commands
15
+ ## Quick start
16
16
 
17
- ### [`sql`](src/commands/sql/README.md) - SQL Queries
17
+ One command takes you from a fresh install to a working API key in `./.env`:
18
18
 
19
- Run SQL queries against your Laminar project data (spans, traces, events, and more).
19
+ ```bash
20
+ lmnr-cli setup --json
21
+ ```
22
+
23
+ Approve the device-flow URL in your browser, and `setup` will:
24
+
25
+ 1. Log in (if you are not already)
26
+ 2. Select (or create, in the browser) a workspace + project — idempotent on re-runs in the same repo
27
+ 3. Mint a fresh API key and write `LMNR_PROJECT_API_KEY=...` to `./.env`
28
+ 4. Link the directory via `.lmnr/project.json` and install the Laminar agent skill into `.claude/` and `.agents/`
29
+ 5. Print a dashboard URL and the revoke link
20
30
 
21
31
  ```bash
22
- lmnr-cli sql query "SELECT * FROM spans LIMIT 10" --json
23
- lmnr-cli sql schema # Show available tables
32
+ # Verify traces are arriving:
33
+ lmnr-cli sql query "SELECT count() FROM spans"
24
34
  ```
25
35
 
26
- ### [`dev`](src/commands/dev/README.md) - Agent Debugger
36
+ `setup` is designed to be invoked by coding agents. Exit codes:
37
+
38
+ - `0` success
39
+ - `1` generic error
40
+ - `4` no access to the linked project
41
+ - `6` login failed or aborted
42
+ - `7` no project to select (and none could be created)
43
+ - `8` `.env` write failed (the API key is surfaced on stderr so the agent can rescue it)
44
+ - `9` API key mint failed
45
+ - `10` project discovery (`GET /v1/cli/projects`) failed
46
+ - `11` couldn't verify an existing key (network/server error)
47
+ - `12` existing key belongs to a different project
48
+
49
+ See `lmnr-cli setup --help` for all flags.
50
+
51
+ ## Authentication
52
+
53
+ The CLI authenticates as a **user** via the OAuth Device Flow (`lmnr-cli login`).
54
+ Every command runs on that user session — there is no project-API-key auth mode.
55
+ Project commands (`sql`, `dataset`, `trace`, `debug`) target a project via
56
+ `--project-id` or the `.lmnr/project.json` link written by `lmnr-cli setup`.
57
+
58
+ The project API key that `setup` writes to `./.env` is for your **application's
59
+ SDK** (trace ingestion) — the CLI itself never reads it.
27
60
 
28
- Start a language-agnostic debugging session for your AI agents. Connects to the Laminar backend, spawns a worker process for your code, and orchestrates the debugging flow.
61
+ ### OAuth Device Flow
29
62
 
30
63
  ```bash
31
- lmnr-cli dev agent.ts # TypeScript file
32
- lmnr-cli dev agent.py # Python script mode
33
- lmnr-cli dev -m src.agent # Python module mode
34
- lmnr-cli dev agent.ts --function myAgent # Specific function
64
+ # Start the device authorization flow. Prints a URL + code and opens your browser.
65
+ lmnr-cli login
66
+
67
+ # Self-hosted / headless: point at your deployment, don't auto-open a browser.
68
+ lmnr-cli login --frontend-url http://localhost:3010 --no-browser
69
+
70
+ # Log out (revokes the session server-side, best-effort, then removes local creds).
71
+ lmnr-cli logout
72
+ ```
73
+
74
+ The CLI signs in **one user at a time**. Tokens are stored at
75
+ `~/.config/lmnr/credentials.json` with mode `0600` (XDG-aware via
76
+ `$XDG_CONFIG_HOME`; `%APPDATA%\lmnr` on Windows). Access tokens are
77
+ auto-refreshed when within ~30 seconds of expiry; if the session has been
78
+ revoked or expired, the CLI exits with an error and you must run
79
+ `lmnr-cli login` again.
80
+
81
+ ### Targeting a project
82
+
83
+ Project commands resolve their project from `--project-id`, falling back to the
84
+ `.lmnr/project.json` link that `lmnr-cli setup` writes in the directory:
85
+
86
+ ```bash
87
+ lmnr-cli setup # link this directory
88
+ lmnr-cli sql query "SELECT count() FROM spans" # uses the .lmnr link
89
+ lmnr-cli sql query "SELECT count() FROM spans" --project-id <uuid> # override
90
+ lmnr-cli project list # projects you can access (● = linked)
91
+ ```
92
+
93
+ For a self-hosted Laminar instance, point the CLI at your deployment. `--base-url`
94
+ is the data API and carries **no port** — pass the port separately with `--port`:
95
+
96
+ ```bash
97
+ lmnr-cli sql schema --base-url http://localhost --port 8000
98
+ ```
99
+
100
+ `LMNR_FRONTEND_URL` (default `https://www.laminar.sh`), `LMNR_BASE_URL`
101
+ (default `https://api.lmnr.ai`), and `LMNR_HTTP_PORT` (default `443`) are also
102
+ honored, and are auto-loaded from a `.env` / `.env.local` in the working directory.
103
+
104
+ ## Commands
105
+
106
+ ### [`sql`](src/commands/sql/README.md) - SQL Queries
107
+
108
+ Run SQL queries against your Laminar project data (spans, traces, events, and more).
109
+
110
+ ```bash
111
+ lmnr-cli sql query "SELECT * FROM spans LIMIT 10" --json
112
+ lmnr-cli sql schema # Show available tables
35
113
  ```
36
114
 
37
115
  ### [`dataset`](src/commands/dataset/README.md) - Dataset Management
@@ -45,16 +123,53 @@ lmnr-cli dataset pull output.jsonl -n my-dataset --json # Pull data from a data
45
123
  lmnr-cli dataset create my-dataset data.jsonl -o out.jsonl
46
124
  ```
47
125
 
126
+ ### `trace` / `debug` - Annotate and inspect agent runs
127
+
128
+ Record findings on a trace and review/name agent debug sessions.
129
+
130
+ ```bash
131
+ lmnr-cli trace append-note <trace-id> "note text" # Append a markdown note to a trace
132
+ lmnr-cli debug session set-name <session-id> "title" # Rename a debug session
133
+ lmnr-cli debug session summary <session-id> # Every trace in a session + its note
134
+ ```
135
+
136
+ `trace append-note` accumulates (each call appends a paragraph). See the Laminar
137
+ debugger docs: https://laminar.sh/docs/platform/debugger
138
+
139
+ ### `setup` - One-shot onboarding
140
+
141
+ ```bash
142
+ lmnr-cli setup # Human-readable summary
143
+ lmnr-cli setup --json # Machine-readable single-line JSON
144
+ lmnr-cli setup --project-id <uuid> # Disambiguate when you can access >1 project
145
+ lmnr-cli setup --no-write-env # Skip writing ./.env
146
+ lmnr-cli setup --no-browser # Don't auto-open the device-flow URL
147
+ ```
148
+
149
+ Re-running setup in the same repo reuses the same project but mints a fresh API
150
+ key each time. Old keys remain visible in the dashboard under "API keys" until
151
+ you revoke them.
152
+
153
+ ### `login` / `logout` - Authentication
154
+
155
+ See [Authentication](#authentication) above.
156
+
157
+ ### `project list` - Discovery
158
+
159
+ Lists the projects you can access; the one linked to the current directory is
160
+ marked with `●`. Accepts `--json`.
161
+
48
162
  ## Global Options
49
163
 
50
164
  - `-v, --version` - Display version number
51
165
  - `-h, --help` - Display help
52
166
 
53
- Each command also accepts:
167
+ Project commands (`sql`, `dataset`, `trace`, `debug`, `project`) also accept:
54
168
 
55
- - `--project-api-key <key>` - Project API key (or set `LMNR_PROJECT_API_KEY` env variable)
56
- - `--base-url <url>` - Base URL for the Laminar API (default: https://api.lmnr.ai)
169
+ - `--project-id <id>` - Target project (defaults to the `.lmnr/project.json` link written by `setup`)
170
+ - `--base-url <url>` - Base URL for the Laminar API, no port (default: https://api.lmnr.ai)
57
171
  - `--port <port>` - Port for the Laminar API (default: 443)
172
+ - `--json` - Output structured JSON to stdout
58
173
 
59
174
  ## Development
60
175