@engini/cli 0.35.0 → 0.36.0

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
@@ -16,7 +16,7 @@ npx @engini/cli --help
16
16
  ## Quickstart
17
17
 
18
18
  ```bash
19
- engini login --api-key eng_… # or bare `engini login` to paste it interactively
19
+ engini login # sign in in the browser (or `engini login key` to paste an API key)
20
20
  engini applications list --available # discover connector apps
21
21
  engini tools list --application monday # discover tools
22
22
  engini tools get monday_create_item --connection 3 # schema as connection 3 sees it
@@ -29,7 +29,8 @@ engini tools result <handle> --select items.email # drill into a large result
29
29
  ## Commands
30
30
 
31
31
  ```
32
- engini login | logout | whoami # auth (whoami also prints an API key's workspace/environment)
32
+ engini login [key] | logout | whoami # auth (whoami also prints the profile, its scope mode and every workspace/environment it can open)
33
+ engini profile list|show|add|use|rename|rm # named logins; every command takes --profile <name>
33
34
  engini tools list | get | call | result # discover, execute & drill into results
34
35
  engini applications list | get # browse connector apps
35
36
  engini toolsets list | get | create | update | delete # scope an agent's tools/connections/workflows
@@ -265,19 +266,112 @@ drill in during the same session.
265
266
 
266
267
  ## Configuration
267
268
 
268
- Credentials and host config live in `$XDG_CONFIG_HOME/engini/config.toml`
269
- (`%APPDATA%\engini\config.toml` on Windows), written `0600`. Resolution order is
270
- **flags > environment > config**; the env vars are `ENGINI_API_KEY` (preferred) or
271
- `ENGINI_API_TOKEN`, plus `ENGINI_COMPANY_TOKEN`.
269
+ Logins live in `$XDG_CONFIG_HOME/engini/config.toml` (`%APPDATA%\engini\config.toml`
270
+ on Windows), written `0600`, as **named profiles**: one login to one account, with its
271
+ hosts, one credential and the company it belongs to. `default_profile` names the one
272
+ used when a command selects none. A config from before profiles loads once as the
273
+ profile `default`, so upgrading logs nobody out.
274
+
275
+ > **Upgrade every `engini` CLI on a machine together.** The first write saves only the
276
+ > profiles shape, so an older CLI no longer sees a login (and its `login`/`logout`
277
+ > would wipe every profile).
278
+
279
+ Which profile a command uses, first match wins:
280
+
281
+ 1. `--profile <name>` (every command except the `profile` verbs)
282
+ 2. `ENGINI_PROFILE=<name>` (per shell; with `ENGINI_API_TOKEN` also set, exit `2`)
283
+ 3. `ENGINI_API_TOKEN` (+ `ENGINI_COMPANY_TOKEN`): a credential for scripts, against the
284
+ default profile's host
285
+ 4. `default_profile`
286
+
287
+ A named profile that does not exist exits `4` (never a fall-back to another login); a
288
+ profile with no credential exits `3`.
289
+
290
+ Which workspace + environment a command acts in (browser logins), first match wins:
291
+
292
+ 1. `--workspace <id> --environment <id>` (GUIDs from `engini whoami`; always together)
293
+ 2. `ENGINI_WORKSPACE_ID` + `ENGINI_ENVIRONMENT_ID` (per shell)
294
+ 3. the profile's default pair (set at login)
295
+ 4. none: lists cover every pair you can open; a **write exits `2`** asking for a pair,
296
+ instead of landing in the account's default workspace
297
+
298
+ Half a pair or a non-GUID exits `2`. An API-key profile is pinned to its key's pair, so
299
+ naming one there (or beside `ENGINI_API_TOKEN`) exits `2`; a profile approved for one
300
+ pair exits `2` on any other. Writes on a browser login print the pair they act in, and
301
+ `--dry-run` output carries it as `scope`. Resume strings repeat a pair named by flag or env.
302
+
303
+ > **`ENGINI_API_KEY` is no longer read by the CLI** (the TypeScript and Python SDK
304
+ > packages still read it). Set, every command exits `2` before any network call, because
305
+ > ignoring it would silently act as whatever default profile the machine has. Save the
306
+ > key in a profile instead: `printf %s "$KEY" | engini login key --profile ci`, then use
307
+ > `--profile ci` (or `ENGINI_PROFILE=ci`).
272
308
 
273
309
  ### `engini login`
274
310
 
275
- An API key must start with `eng_`. A malformed, empty, or line-broken key exits
276
- `2` and writes nothing — that applies equally to `--api-key` and to the
277
- interactive prompt, which re-asks up to three times.
311
+ Bare `engini login [--profile <name>]` signs in **in the browser** (OAuth with PKCE, as
312
+ the public client `engini-cli` of the sign-in server):
313
+
314
+ 1. The CLI prints the sign-in link and a **confirmation code**, and opens the browser.
315
+ The consent page shows the same code - approve only if they match (a link someone
316
+ else sent you would show a different one).
317
+ 2. Choose the account, then **everything you can open in it** (default) or **one
318
+ workspace + environment**.
319
+ 3. The profile stores an access token (1 hour) and a refresh token; the CLI refreshes
320
+ before a command when under 10 minutes remain (under a per-profile lock, so parallel
321
+ terminals share one session) for up to **30 days**, then asks you to log in again.
322
+ A long `triggers listen` re-authenticates itself.
323
+
324
+ The default pair: in one-pair mode, that pair; otherwise the only pair you can open, or
325
+ the one you name with `--workspace <id> --environment <id>` (refused with exit `5` if you
326
+ cannot open it), or none. `engini whoami` lists every pair with ids (names can repeat).
327
+ Logging in again or `engini logout` revokes the previous session on the server.
328
+
329
+ Flags: `--no-browser` prints the link instead of opening it. The link returns to
330
+ `127.0.0.1:<port>` on the machine that opens it, so on a remote shell forward the port
331
+ first (`ssh -L <port>:127.0.0.1:<port> <host>`) - or use `engini login key`.
332
+ `--timeout <sec>` (default 300); `--auth-url <url>` names the sign-in server (default:
333
+ the API host with `api.` -> `identity.`, e.g. `https://identity.engini.io`);
334
+ `--allow-host <host>` trusts a sign-in host outside `engini.io`. Browser login needs a
335
+ terminal unless `--no-browser` is given.
336
+
337
+ Browser logins reach the Developer API only. The **workflow builder**
338
+ (`engini workflows search|schema|options|tables|columns|connections|compile|plan|create|update`)
339
+ works on both profile kinds, in one workspace + environment: on a browser login every builder
340
+ command - reads included - needs a pair (flag, env var or the profile's default; a one-pair
341
+ login uses its own) and **exits `2` without one**. Workflows in the legacy no-workspace bucket
342
+ are out of reach, and a pair you cannot open is refused by the server (`SCOPE_NOT_ACCESSIBLE`;
343
+ run `engini whoami` to list the pairs you can open). Template submit still needs an API-key
344
+ profile: it answers "This command needs an API-key profile" on a browser login. Other Engini
345
+ services accept the token like any connected app's token.
346
+
347
+ `engini login key [--profile <name>]` (or `--api-key`) pastes an API key instead and
348
+ never opens a browser. It stores the key in a profile (`default`
349
+ when none is named; the first profile becomes the default). An API key must start with
350
+ `eng_`. A malformed, empty, or line-broken key exits `2` and writes nothing — that
351
+ applies equally to `--api-key`, to stdin and to the interactive prompt, which re-asks
352
+ up to three times. The key is checked with `whoami` before it is stored: a rejected key
353
+ exits `3`, and the company, workspace and environment it reports are cached on the
354
+ profile. `--expect-company <name>` refuses a key that belongs to another company (exit
355
+ `5`); `--description <text>` labels the profile; `--dry-run` never touches the network.
356
+
357
+ Interactive entry needs a terminal on **both** stdin and stdout. Without one, either
358
+ pipe the key (`printf %s "$KEY" | engini login key`, the CI path: nothing on the command
359
+ line or in shell history) or pass `--api-key` (visible in process lists). `key` is the
360
+ only method word; any other exits `2`, and the browser-only flags exit `2` on this path.
361
+
362
+ ### `engini profile`
363
+
364
+ ```bash
365
+ engini profile list # name, default, active, company, host, ... (never a credential)
366
+ engini profile show [name]
367
+ engini profile add <name> [key] # like `login --profile <name>`, but refuses an existing name
368
+ engini profile use <name> # set the default (shells with ENGINI_PROFILE are unaffected)
369
+ engini profile rename <old> <new> # also moves the profile's stored results
370
+ engini profile rm <name> [--force] # refuses the default while other profiles exist
371
+ ```
278
372
 
279
- Interactive entry needs a terminal on **both** stdin and stdout. If stdin is
280
- piped (CI, a wrapper script), pass `--api-key` — `engini login` with a redirected
281
- stdin exits `2` rather than prompting into the void.
373
+ Two shells with different `ENGINI_PROFILE` values can run `engini whoami` at the same
374
+ time and each shows its own company. `tools call` results are kept per profile, so a
375
+ handle from one account is never readable as another's.
282
376
 
283
377
  Source & docs: <https://github.com/engini/engini-sdk>