@lotics/cli 0.321.38 → 0.321.40
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/AGENTS.md +3 -3
- package/README.md +5 -5
- package/dist/src/cli.js +296 -299
- package/dist/src/client.d.ts +4 -6
- package/dist/src/client.js +4 -4
- package/docs/cli_reference.md +2 -2
- package/package.json +1 -1
package/dist/src/client.d.ts
CHANGED
|
@@ -245,17 +245,15 @@ export type CliLoginState = {
|
|
|
245
245
|
workspace_id: string;
|
|
246
246
|
};
|
|
247
247
|
/**
|
|
248
|
-
* Ask Lotics
|
|
248
|
+
* Ask Lotics for a sign-in request, and read back whether it was confirmed.
|
|
249
249
|
*
|
|
250
250
|
* Plain functions rather than `LoticsClient` methods: there is no key to build
|
|
251
251
|
* a client around, and that is the whole point — this is the pair a terminal holding NO credential
|
|
252
252
|
* uses to obtain one. Sending an `Authorization` header would make the endpoint
|
|
253
|
-
* answerable only to callers who no longer need it.
|
|
254
|
-
*
|
|
255
|
-
* The same answer whether or not the address has an account: it would
|
|
256
|
-
* otherwise tell any stranger which emails are registered here.
|
|
253
|
+
* answerable only to callers who no longer need it. The request names nobody:
|
|
254
|
+
* whoever signs in on its page and confirms is the account it is for.
|
|
257
255
|
*/
|
|
258
|
-
export declare function startCliLogin(apiUrl: string
|
|
256
|
+
export declare function startCliLogin(apiUrl: string): Promise<CliLoginRequest>;
|
|
259
257
|
export declare function pollCliLogin(apiUrl: string, request_id: string, secret: string): Promise<CliLoginState>;
|
|
260
258
|
export declare class LoticsClient {
|
|
261
259
|
private apiKey;
|
package/dist/src/client.js
CHANGED
|
@@ -210,22 +210,22 @@ function errorCode(cause) {
|
|
|
210
210
|
}
|
|
211
211
|
var WEB_APP_URL = process.env.LOTICS_WEB_URL ?? "https://lotics.ai";
|
|
212
212
|
var PUBLIC_FETCH_TIMEOUT_MS = 1e4;
|
|
213
|
-
async function startCliLogin(apiUrl
|
|
213
|
+
async function startCliLogin(apiUrl) {
|
|
214
214
|
let response;
|
|
215
215
|
try {
|
|
216
216
|
response = await fetch(`${apiUrl}/v1/cli/login_requests`, {
|
|
217
217
|
method: "POST",
|
|
218
218
|
headers: { "Content-Type": "application/json" },
|
|
219
|
-
body: JSON.stringify({
|
|
219
|
+
body: JSON.stringify({}),
|
|
220
220
|
signal: AbortSignal.timeout(PUBLIC_FETCH_TIMEOUT_MS)
|
|
221
221
|
});
|
|
222
222
|
} catch (error) {
|
|
223
223
|
throw new Error(
|
|
224
|
-
`Could not reach Lotics to
|
|
224
|
+
`Could not reach Lotics to ask for a sign-in (${error instanceof Error ? error.message : String(error)}). Check your connection, or sign in at ${WEB_APP_URL}.`
|
|
225
225
|
);
|
|
226
226
|
}
|
|
227
227
|
if (!response.ok) {
|
|
228
|
-
throw new Error(`Lotics answered ${response.status} asking for a sign-in
|
|
228
|
+
throw new Error(`Lotics answered ${response.status} asking for a sign-in.`);
|
|
229
229
|
}
|
|
230
230
|
return await response.json();
|
|
231
231
|
}
|
package/docs/cli_reference.md
CHANGED
|
@@ -6,14 +6,14 @@ Per-command syntax, flags, contracts, and gotchas for the public `lotics` CLI. S
|
|
|
6
6
|
|---|---|
|
|
7
7
|
| `lotics` / `lotics --help` | Show full help: capabilities, the verb list (§ COMMANDS), flags, config. `lotics <verb> --help` prints that verb's entries alone (`lotics app --help`, `lotics file download --help`); `lotics report --help` prints the report frame. |
|
|
8
8
|
| `lotics auth signup <email>` | Create account + org + API key, sends magic link email. Refused on a private instance, whose people arrive by invitation; prints that creating the account accepts the Terms and Privacy Policy. Registers the new org as a profile; `--local` pins this directory to it (pointer) instead of setting the global default. |
|
|
9
|
-
| `lotics auth login
|
|
9
|
+
| `lotics auth login` | Sign in an account that already exists, on a machine holding no key. It takes no argument and sends no mail. **Two steps, and it does not wait for the person.** The first prints the page to open — `https://lotics.ai/cli_login/<request_id>` — and the code that page must show, records the request, and exits 0. They sign in there if asked, check the code, pick the organization and press Confirm. **Then the next command that needs a credential collects the key** before it does its own work, so the second step is just re-running whatever was wanted; a command run before Confirm exits 1 naming the page and the code again, and once the 15 minutes are up it says to ask again. The handful that run WITHOUT a credential — `docs` among them — claim nothing, so one of those run after Confirm still answers as though signed out. `--wait` keeps one command instead, holding the terminal until Confirm; `--local` pins this directory to that org rather than setting the global default, and implies `--wait` (a pin names THIS directory, so only the terminal that stays in it can write one). `--json` prints `organization_id`, `workspace_id` and `organization_name` when it finishes signed in, and `request_id`, `confirm_url`, `code`, `expires_at` when it is the first step. The request's secret is never printed and the org's key never leaves the store. |
|
|
10
10
|
| — | **A flag is refused on a verb that does not read it**, naming the verbs that do, before any request or credential: `--check` on `lotics run` would otherwise be parsed and ignored, and the write it was meant to stop would run. `--json`, `--workspace`, `--api-key` and `--timeout` are read by every verb. |
|
|
11
11
|
| — | **Every call a verb makes waits for the server's answer**; `--timeout <ms>` (a whole number of milliseconds from 1 to 2147483647) stops each wait early. The wait ends without an answer when `--timeout` passes or no answer arrives from the server. A read with no answer changed nothing: the command exits non-zero naming the request id. A write with no answer exits non-zero with `error_code: "outcome_unknown"` and the request id under `--json`, because it cannot say whether the call took effect: read before running it again. The one fetch outside this is the download from an object-storage signed URL, which carries no request id and is stopped by `--timeout` alone. Under `--json` every error is one object on stdout: `error`, with `error_code` and `request_id` where the error has them. |
|
|
12
12
|
| `lotics auth api-key [key]` | `whoami` → **upsert** the key's org as a profile in the global store (never overwrites). The profile records the instance the key was verified against (`LOTICS_API_URL`, default `https://api.lotics.ai`), and every later command for that org goes there. `--local` additionally pins this directory to it (pointer) instead of setting the global default. |
|
|
13
13
|
| `lotics auth web` | Send a magic link email to access the web app (requires auth) |
|
|
14
14
|
| `lotics auth whoami` | Print active account name, email, org, resolved workspace, the instance the credential belongs to, which **kind** of credential this machine holds (a sign-in from `auth login`, or an API key — read from the saved profile, and from the server when the profile does not say, which covers `--api-key`/`LOTICS_API_KEY` and a profile saved before the field existed; unknown only when neither can say), and the resolution **source** (flag/env/local/app-manifest/global). `--json` adds `workspace_id`, `api_url`, `credential_kind` + `source`. |
|
|
15
15
|
| `lotics auth logout [<name\|id>]` | In a pinned dir: delete the local pin. Else: remove the profile (default the active org), `--all` for every one. What happens server-side depends on which KIND of credential it is. A **sign-in** (`auth login` / `auth signup`) is revoked — logging that terminal out ends its credential rather than leaving a live one behind; a server that cannot be reached, or a credential already dead, never blocks the local forget, and one line names the org and Settings → Security → *Keys and terminals*. An **API key** (`auth api-key`) is only forgotten here — an admin issued it and it is routinely on a server and on other machines, so one terminal signing out must not kill it for everyone; the line says it is still active and names both pages, because Settings → API keys is admin-only and the credential may well be the holder's own sign-in, which they revoke themselves at Settings → Security → *Keys and terminals*. A profile saved before the kind was recorded states nothing, so the SERVER is asked (`auth whoami`) and it is revoked only if the answer is a sign-in: an older server, a credential minted before the column, and a request that fails all leave it alone. |
|
|
16
|
-
| — | **A refused credential says which way it is dead, and names the remedy that ends its kind.** `This credential expired.` / `was revoked.` / `belongs to a member who is no longer active in this organization.` carries `Run \`lotics auth login
|
|
16
|
+
| — | **A refused credential says which way it is dead, and names the remedy that ends its kind.** `This credential expired.` / `was revoked.` / `belongs to a member who is no longer active in this organization.` carries `Run \`lotics auth login\` to sign in again.` for a sign-in and `Ask an admin for a new API key (Settings → API keys).` for an issued key. A credential minted before that was recorded still gets BOTH in one sentence, because nothing on the row tells them apart — so a headless box is never sent looking for a browser alone. A key the server does not recognize at all gets one flat `Invalid or disabled API key.` — deliberately, so a guessed key learns nothing, not even that it named a row. The body carries `reason` for a script to branch on, since the code stays `unauthorized` for every 401. Changing or resetting the account's password revokes its sign-ins, never an issued key. |
|
|
17
17
|
| `lotics org` | List saved orgs (profiles) from the global store with the instance each belongs to, marks active for this directory (a local pin wins over the global default). |
|
|
18
18
|
| `LOTICS_ORG=<name\|id>` | Scope every command in this shell to one saved org. **Resolved once, before any command dispatches**, so a value matching no saved credential refuses every verb with one sentence — a read, a write, and a local check that needs no credential alike — and refuses it before the first byte is written. It refuses even when a credential arrives another way, because `--api-key` / `LOTICS_API_KEY` outrank it in the precedence chain and a write must never fall through to whatever THOSE name while the variable says otherwise; when the variable resolves and a key is also given, the key decides and the command says so. The refusal lists the orgs this machine holds, so it is answerable without another command (`lotics org` is refused by the same rule). A name is whatever the credential was SAVED under — a server-side rename never moves it, and the new name resolves too, so both keep working and `lotics org` prints the pair. |
|
|
19
19
|
| `lotics org use <name\|id> [--local]` | Switch the active org by org name (case-insensitive, ambiguous → error) or id. No flag → global `active_org`; `--local` → a `.lotics/config.json` pointer in the current dir. |
|