@north-light/cli 0.3.743 → 0.3.745
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 +2 -2
- package/dist/builtin-memory/crouter-concepts/scopes-and-trust.md +2 -2
- package/dist/builtin-memory/crouter-sdk/README.md +1 -1
- package/dist/builtin-memory/crouter-sdk/client.md +1 -1
- package/dist/builtin-memory/crouter-sdk/getting-started.md +3 -38
- package/dist/clients/attach/viewer.js +1 -1
- package/dist/commands/sys/provider-login.js +2 -2
- package/dist/commands/sys.js +1 -1
- package/dist/core/canvas/daemon-owner.d.ts +1 -1
- package/dist/core/canvas/paths.d.ts +1 -1
- package/dist/core/canvas/person-state.d.ts +3 -0
- package/dist/core/canvas/person-state.js +1 -1
- package/dist/core/canvas/person.d.ts +2 -3
- package/dist/core/canvas/person.js +7 -7
- package/dist/core/canvas/tree.js +4 -4
- package/dist/core/environments.d.ts +0 -10
- package/dist/core/environments.js +1 -1
- package/dist/core/runtime/blaxel-environment.js +1 -1
- package/dist/core/secrets.d.ts +2 -4
- package/dist/core/secrets.js +1 -1
- package/dist/core/spaces/space.js +2 -2
- package/dist/core/user-settings.js +1 -1
- package/dist/daemon/api/environment-of.d.ts +1 -1
- package/dist/daemon/api/environment-of.js +3 -3
- package/dist/daemon/api/handlers/document-access.js +1 -1
- package/dist/daemon/api/router.d.ts +1 -1
- package/dist/daemon/crtrd-cli.js +1 -1
- package/dist/daemon/crtrd.d.ts +4 -2
- package/dist/daemon/crtrd.js +20 -20
- package/dist/daemon/manage.d.ts +0 -8
- package/dist/daemon/manage.js +3 -3
- package/dist/daemon/reconcilers/node-lifecycle/remote-wake.js +2 -2
- package/dist/daemon/reconcilers/storage-maintenance.d.ts +0 -2
- package/dist/daemon/reconcilers/storage-maintenance.js +1 -1
- package/docs/concepts/scopes-and-trust.md +2 -2
- package/docs/public-api.md +1 -7
- package/docs/sdk/README.md +1 -1
- package/docs/sdk/client.md +1 -1
- package/docs/sdk/getting-started.md +3 -38
- package/package.json +3 -3
- package/packages/crouter-api/dist/commands/sys/provider-login.js +2 -2
- package/packages/crouter-api/dist/commands/sys.js +1 -3
- package/packages/crouter-api/dist/core/canvas/paths.js +1 -1
- package/packages/crouter-api/dist/core/canvas/person-state.js +4 -0
- package/packages/crouter-api/dist/core/canvas/person.js +2 -14
- package/packages/crouter-api/dist/core/canvas/tree.js +3 -1
- package/packages/crouter-api/dist/core/environments.js +2 -38
- package/packages/crouter-api/dist/core/model-auth/daemon-login.js +2 -2
- package/packages/crouter-api/dist/core/runtime/blaxel-environment.js +3 -3
- package/packages/crouter-api/dist/core/secrets.js +1 -11
- package/packages/crouter-api/dist/core/spaces/space.js +2 -2
- package/packages/crouter-api/dist/core/user-settings.js +1 -1
- package/packages/crouter-api/dist/daemon/api/environment-of.js +7 -4
- package/packages/crouter-api/dist/daemon/manage.js +0 -4
- package/packages/crouter-api/dist/daemon/reconcilers/node-lifecycle/remote-wake.js +2 -2
- package/packages/crouter-api/package.json +1 -1
- package/packages/crouter-identity/package.json +1 -1
- package/packages/crouter-plugin/package.json +3 -3
- package/runtime.lock.json +14 -14
- package/dist/commands/sys/connect.d.ts +0 -1
- package/dist/commands/sys/connect.js +0 -3
- package/dist/commands/sys/db.d.ts +0 -1
- package/dist/commands/sys/db.js +0 -1
- package/dist/core/canvas/export-sqlite.d.ts +0 -14
- package/dist/core/canvas/export-sqlite.js +0 -3
- package/dist/daemon/api/document-listener.d.ts +0 -7
- package/dist/daemon/api/document-listener.js +0 -1
- package/dist/daemon/api/document-secret.d.ts +0 -2
- package/dist/daemon/api/document-secret.js +0 -1
- package/dist/daemon/export-sqlite-run.d.ts +0 -1
- package/dist/daemon/export-sqlite-run.js +0 -4
- package/packages/crouter-api/dist/commands/sys/connect.js +0 -185
- package/packages/crouter-api/dist/commands/sys/db.js +0 -69
package/README.md
CHANGED
|
@@ -80,7 +80,7 @@ Each item names the command that does it. `crtr <command> -h` prints the exact c
|
|
|
80
80
|
|
|
81
81
|
**Scheduling.** `crtr cron add` stores a bash command the daemon runs at a time or cadence (`--at`, `--every`) and can route its output to a node's inbox or to a fresh node (`--sink node:<id>` / `spawn:<kind>`). A command that exits 75 is treated as not yet eligible, and the next cadence re-checks it.
|
|
82
82
|
|
|
83
|
-
**Scopes.** A node or a remote token carries an allow-list (`crtr:llm`, `crtr:act`, `crtr:schedule`, `crtr:memory:read:user`, …) that the daemon checks at the route that performs the action.
|
|
83
|
+
**Scopes.** A node or a remote token carries an allow-list (`crtr:llm`, `crtr:act`, `crtr:schedule`, `crtr:memory:read:user`, …) that the daemon checks at the route that performs the action.
|
|
84
84
|
|
|
85
85
|
**Plugins and marketplaces.** A marketplace is a git repository of plugins; `crtr pkg market add <git-url>` registers one and `crtr pkg plugin install <marketplace>/<plugin>` installs from it. A plugin can add commands (local executable or HTTP), documents, agent kinds, and binaries. `crtr custom-object register` makes an outside service a watchable object on the canvas.
|
|
86
86
|
|
|
@@ -97,7 +97,7 @@ flowchart LR
|
|
|
97
97
|
Viewer -. live session .-> Broker
|
|
98
98
|
```
|
|
99
99
|
|
|
100
|
-
`crtrd` is the only writer of canvas state and the only launcher of brokers. The CLI, the viewer and SDK applications call its `/v1` API; none of them opens the canvas database or starts an engine of its own. On one machine they use an owner-only Unix socket. A
|
|
100
|
+
`crtrd` is the only writer of canvas state and the only launcher of brokers. The CLI, the viewer and SDK applications call its `/v1` API; none of them opens the canvas database or starts an engine of its own. On one machine they use an owner-only Unix socket. A remote process uses a TCP listener (`--tcp`) and a bearer token (`CRTRD_TOKEN`).
|
|
101
101
|
|
|
102
102
|
What this costs: a daemon has to be running (the CLI and SDK start it on first use), and a network failure on a remote client fails a request loudly rather than replaying it. What it buys is one owner for state, so a node outlives the terminal, the viewer, or the application that created it. [Why a daemon](https://crouter.docs.northlight.ai/docs/concepts/why-a-daemon) covers the reasoning.
|
|
103
103
|
|
|
@@ -23,7 +23,7 @@ Scope strings are prefixed with `crtr:`. These are the ones the daemon and CLI c
|
|
|
23
23
|
| `crtr:conversations:read:app:<id>`, `crtr:objects:read:app:<id>` | Reading another app's conversations or node objects |
|
|
24
24
|
| `<provider>:<group>` | One tool group of a provider |
|
|
25
25
|
|
|
26
|
-
The `memory` in `crtr:memory:*` is the scope family's name for access to **documents** (see [[crouter-concepts/documents]]); there is no separate memory store.
|
|
26
|
+
The `memory` in `crtr:memory:*` is the scope family's name for access to **documents** (see [[crouter-concepts/documents]]); there is no separate memory store. A node's own documents, and an app's documents for its own nodes, need no `crtr:memory` scope.
|
|
27
27
|
|
|
28
28
|
This is an allow-list, not a claim that code will behave. The daemon checks the scope at the route that performs the action and rejects an unavailable one. The node-create route's `scopes` field narrows a run: a run's list must stay inside what its creator and grant hold, and `crtr:act` requires `crtr:llm`. `client.memory` is not scope-gated: it lists and reads the person's `knowledge` and `preference` documents, and the answer is filtered by privacy, which is `public` or `private`. An app's ceiling is `public` documents; a grant holding `crtr:memory:read_private:user` or `crtr:memory:manage:user` widens it to `private` ones. Within that ceiling, the app's registered schema and the relation facts it writes decide who may read a document, not a per-call scope. The exception is a run started with a `scopes` list: it reads its own app's documents (including automatic delivery of them at boot) only with `crtr:memory:read:app:<id>` and writes or edits them only with `crtr:memory:rw:app:<id>`; a refused write answers `scope_missing` naming the scope. Such a run still publishes its own reports with `crtr push` and its promoted node still gets a roadmap, but cannot edit any other document through that path, and a child never regains a scope its parent's list dropped.
|
|
29
29
|
|
|
@@ -37,6 +37,6 @@ flowchart LR
|
|
|
37
37
|
|
|
38
38
|
Scopes rely on a more basic trust boundary: `crtrd` is the sole writer of durable canvas state and the sole owner of broker lifecycle. SDK clients, the CLI, and viewers call its API; they do not open the canvas database or launch their own broker. One owner serializes lifecycle changes, makes the same API usable locally and remotely, and keeps a client from silently creating a second state authority.
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
A remote process sends a bearer token (`Authorization: Bearer <token>`); its scope list is the ceiling for scope-gated calls and newly created nodes. On Northlight the bearer is the person's or an app's, issued by the directory. Treat any token as a credential.
|
|
41
41
|
|
|
42
42
|
The remote API is an explicit boundary, not permission to reach around it. Keep application code on the SDK or `/v1` contract, and let the daemon own state transitions. Run `crtr canvas read internal/nodes-and-canvas` for the operational ownership model.
|
|
@@ -27,7 +27,7 @@ const node = await crtr.createNode({ prompt: 'List the top-level directories her
|
|
|
27
27
|
|
|
28
28
|
| Page | Covers |
|
|
29
29
|
|---|---|
|
|
30
|
-
| [[crouter-sdk/getting-started]] | Install, `new Crouter()` on the owner's socket, `
|
|
30
|
+
| [[crouter-sdk/getting-started]] | Install, `new Crouter()` on the owner's socket, `--tcp` and `CRTRD_TOKEN` for a browser or remote app, Chrome's local-network prompt |
|
|
31
31
|
| [[crouter-sdk/client]] | Every constructor option and its environment-variable fallback; per-request options |
|
|
32
32
|
| [[crouter-sdk/resources]] | Every namespace with its routes, and the `client.request()` escape hatch |
|
|
33
33
|
| [[crouter-sdk/errors]] | The daemon's scoped-token and wire errors, and identifier validation |
|
|
@@ -27,7 +27,7 @@ An app that signs people in with Northlight uses `OAuth2Client` and `oauth.clien
|
|
|
27
27
|
|---|---|---|---|
|
|
28
28
|
| `baseURL` | `string` | `CRTR_BASE_URL`, else unset | `http(s)://host:port` of a daemon TCP listener. |
|
|
29
29
|
| `socketPath` | `string` | `CRTR_SOCKET`, else `CRTR_API_SOCKET`, else `api.sock` in the runtime root (`${CRTR_HOME:-~/.crouter}/runtime/api.sock` on macOS, `/run/crtr/api.sock` on Linux) | Unix socket. Node only; throws in a browser. |
|
|
30
|
-
| `token` | `string` | `CRTRD_TOKEN` | Sent as `Authorization: Bearer <token>`. The
|
|
30
|
+
| `token` | `string` | `CRTRD_TOKEN` | Sent as `Authorization: Bearer <token>`. The token the daemon was started with (`CRTRD_TOKEN`); a scoped token's ceiling is enforced per request (see [[crouter-sdk/getting-started]]). Ignored by a unix-socket daemon, which authenticates by filesystem permission. |
|
|
31
31
|
| `timeout` | `number` (ms) | `30_000` | Per-request wall clock. Does not apply to a stream. |
|
|
32
32
|
| `maxRetries` | `number` | `2` | Transient-failure retries. Never applied to `POST` or `PATCH` — see [[crouter-sdk/errors]]. |
|
|
33
33
|
| `defaultHeaders` | `Record<string, string>` | `{}` | Merged into every request. |
|
|
@@ -42,50 +42,15 @@ The SDK covers the app routes (`runs`, `uploads`, `docs`, `memory`, …). To cre
|
|
|
42
42
|
|
|
43
43
|
## 4. A browser or a remote application
|
|
44
44
|
|
|
45
|
-
A process that is not on the daemon's machine — or a page in a browser, which has no unix sockets at all — reaches
|
|
46
|
-
|
|
47
|
-
### Turn the listener on, once
|
|
48
|
-
|
|
49
|
-
On the machine running the daemon:
|
|
50
|
-
|
|
51
|
-
```bash
|
|
52
|
-
crtr sys connect
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
This stores a listener address and generates a token if either is missing, then prints the base URL and token before handing the daemon over to a successor that boots with the listener on. It then logs in to the selected model provider when that provider has no usable credential. Run it again and, when the listener is up and that provider is ready, it prints the credentials and changes nothing.
|
|
56
|
-
|
|
57
|
-
The command returns `base_url` and `token`. Use JSON output when a program or a setup UI needs those exact fields:
|
|
58
|
-
|
|
59
|
-
```text
|
|
60
|
-
$ crtr --json sys connect
|
|
61
|
-
{"base_url":"http://127.0.0.1:8787","token":"<64-character bearer token>"}
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
### A token that holds less than the owner
|
|
65
|
-
|
|
66
|
-
```bash
|
|
67
|
-
crtr sys connect --app my-app --scopes crtr:llm,crtr:act,crtr:memory:read:user
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
`--scopes` requires `--app` (the app id, without the `app:` prefix) and accepts only `crtr:llm`, `crtr:act`, `crtr:schedule`, `crtr:memory:read:user`, `crtr:memory:read:app`, `crtr:memory:rw:app`, `crtr:files:read:user:.` and `crtr:files:rw:user:.`. This mints a new token for that app whose scope list is a ceiling, appends it to the same secrets store, prints it in place of the owner token, and always hands the daemon over (it reads tokens once, at boot). The ceiling is checked on every request that carries the token:
|
|
71
|
-
|
|
72
|
-
- A scope-gated operation the ceiling lacks answers `403 scope_denied`. Starting or messaging a run, and creating, reviving, forking, messaging, or yielding a node, needs `crtr:act`, as do `bash`, `files`, and creating a human request or review (there is no separate scope for human requests); arming or running a cron needs `crtr:schedule`; `/v1/llm` needs `crtr:llm`. `client.memory` has no scope of its own: it reads the person's documents filtered by privacy, and a grant holding `crtr:memory:read_private:user` also sees `private` documents, and one holding `crtr:memory:manage:user` sees every level.
|
|
73
|
-
- A run started with `scopes` outside the ceiling answers `403 scope_denied`; `details.scopes` lists the offending scopes. Omit `scopes` and the run gets the ceiling.
|
|
74
|
-
- Owner-only operations — daemon restart, the attach viewer, broker internals, canvas prune, profile pause/resume/delete, model credential install — answer `403 owner_only` to any scoped token.
|
|
75
|
-
|
|
76
|
-
What a scope does **not** do on a developer's machine: there is no OS sandbox. Scopes gate the daemon and the CLI; a run's own bash tool is ungated, and the daemon identifies a calling node by a field the caller declares, so a scope check bounds a well-behaved agent, not a hostile one. A scope the daemon does not check at any route is recorded on the run but not enforced; `sys connect` mints only the scopes listed above. There is no list or revoke verb yet; to retire a scoped token, remove it from the 0600 user secrets store and restart the daemon.
|
|
77
|
-
|
|
78
|
-
### Connect with the saved values
|
|
79
|
-
|
|
80
|
-
Construct the client from the base URL and token the user pasted from `crtr sys connect`:
|
|
45
|
+
A process that is not on the daemon's machine — or a page in a browser, which has no unix sockets at all — reaches a daemon over TCP with a bearer token. A computer signed in with `crtr sys signin` is a fleet machine: its crtr commands go to the Northlight control plane with the person's bearer, and no local listener or owner token is created. Run a daemon with `--tcp <host:port>` and `CRTRD_TOKEN` only for your own control plane under development (`crtrd --role all` with `CRTR_DATABASE_URL` and `CRTR_DIRECTORY_URL`).
|
|
81
46
|
|
|
82
47
|
```ts
|
|
83
48
|
import Crouter from '@north-light/sdk';
|
|
84
49
|
|
|
85
|
-
const client = new Crouter({ baseURL:
|
|
50
|
+
const client = new Crouter({ baseURL: process.env.CRTR_BASE_URL, token: process.env.CRTRD_TOKEN });
|
|
86
51
|
```
|
|
87
52
|
|
|
88
|
-
A rejected token raises `AuthenticationError` and an unreachable listener raises `APIConnectionError
|
|
53
|
+
A rejected token raises `AuthenticationError` and an unreachable listener raises `APIConnectionError`.
|
|
89
54
|
|
|
90
55
|
The root entry of the SDK is browser-safe: it imports nothing from `node:*`. The unix-socket code is reached only through a dynamic import taken when `socketPath` is set, so a browser bundle never resolves it.
|
|
91
56
|
|