@north-light/crouter 0.3.329 → 0.3.331
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/dist/builtin-memory/crouter-plugin/INDEX.md +12 -0
- package/dist/builtin-memory/crouter-plugin/README.md +25 -0
- package/dist/builtin-memory/crouter-plugin/bundles-and-memory.md +32 -0
- package/dist/builtin-memory/crouter-plugin/commands.md +21 -0
- package/dist/builtin-memory/crouter-plugin/deploying.md +33 -0
- package/dist/builtin-memory/crouter-plugin/errors.md +42 -0
- package/dist/builtin-memory/crouter-plugin/getting-started.md +28 -0
- package/dist/builtin-memory/crouter-plugin/output.md +30 -0
- package/dist/builtin-memory/crouter-plugin/parameters.md +29 -0
- package/dist/builtin-memory/crouter-sdk/INDEX.md +13 -0
- package/dist/builtin-memory/crouter-sdk/README.md +65 -0
- package/dist/builtin-memory/crouter-sdk/bash.md +41 -0
- package/dist/builtin-memory/crouter-sdk/client.md +98 -0
- package/dist/builtin-memory/crouter-sdk/docker.md +72 -0
- package/dist/builtin-memory/crouter-sdk/errors.md +112 -0
- package/dist/builtin-memory/crouter-sdk/files.md +51 -0
- package/dist/builtin-memory/crouter-sdk/getting-started.md +169 -0
- package/dist/builtin-memory/crouter-sdk/memory.md +88 -0
- package/dist/builtin-memory/crouter-sdk/migration.md +118 -0
- package/dist/builtin-memory/crouter-sdk/nodes.md +197 -0
- package/dist/builtin-memory/crouter-sdk/resources.md +88 -0
- package/dist/builtin-memory/crouter-sdk/streaming.md +148 -0
- package/dist/clients/attach/overlays/graph.js +1 -1
- package/dist/clients/attach/viewer.js +508 -508
- package/package.json +1 -1
- package/runtime.lock.json +8 -8
- package/dist/builtin-memory/crouter-plugin.md +0 -16
- package/dist/builtin-memory/crouter-sdk.md +0 -90
package/package.json
CHANGED
package/runtime.lock.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@north-light/crouter",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.331",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@north-light/crouter",
|
|
9
|
-
"version": "0.3.
|
|
9
|
+
"version": "0.3.331",
|
|
10
10
|
"hasInstallScript": true,
|
|
11
11
|
"license": "GPL-3.0-only",
|
|
12
12
|
"workspaces": [
|
|
@@ -4795,28 +4795,28 @@
|
|
|
4795
4795
|
},
|
|
4796
4796
|
"packages/crouter-api": {
|
|
4797
4797
|
"name": "@north-light/crouter-api",
|
|
4798
|
-
"version": "0.3.
|
|
4798
|
+
"version": "0.3.331",
|
|
4799
4799
|
"license": "GPL-3.0-only"
|
|
4800
4800
|
},
|
|
4801
4801
|
"packages/crouter-env-docker": {
|
|
4802
4802
|
"name": "@north-light/crouter-env-docker",
|
|
4803
|
-
"version": "0.3.
|
|
4803
|
+
"version": "0.3.331",
|
|
4804
4804
|
"license": "GPL-3.0-only"
|
|
4805
4805
|
},
|
|
4806
4806
|
"packages/crouter-plugin": {
|
|
4807
4807
|
"name": "@north-light/crouter-plugin",
|
|
4808
|
-
"version": "0.3.
|
|
4808
|
+
"version": "0.3.331",
|
|
4809
4809
|
"license": "GPL-3.0-only",
|
|
4810
4810
|
"dependencies": {
|
|
4811
|
-
"@north-light/crouter-api": "^0.3.
|
|
4811
|
+
"@north-light/crouter-api": "^0.3.331"
|
|
4812
4812
|
}
|
|
4813
4813
|
},
|
|
4814
4814
|
"packages/crouter-sdk": {
|
|
4815
4815
|
"name": "@north-light/crouter-sdk",
|
|
4816
|
-
"version": "0.3.
|
|
4816
|
+
"version": "0.3.331",
|
|
4817
4817
|
"license": "GPL-3.0-only",
|
|
4818
4818
|
"dependencies": {
|
|
4819
|
-
"@north-light/crouter-api": "^0.3.
|
|
4819
|
+
"@north-light/crouter-api": "^0.3.331"
|
|
4820
4820
|
}
|
|
4821
4821
|
}
|
|
4822
4822
|
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
kind: knowledge
|
|
3
|
-
when-and-why-to-read: When an application needs to expose operations as crtr commands over HTTP, this knowledge should be read because one typed command definition can provide the handler and install archive without a hand-written manifest drifting from the app.
|
|
4
|
-
short-form: Use @north-light/crouter-plugin to expose an application's typed HTTP operations as crtr commands from one TypeScript command tree.
|
|
5
|
-
surfaces:
|
|
6
|
-
- on: boot
|
|
7
|
-
at: preview
|
|
8
|
-
---
|
|
9
|
-
|
|
10
|
-
# `@north-light/crouter-plugin`
|
|
11
|
-
|
|
12
|
-
Use `@north-light/crouter-plugin` when an application should provide crtr commands through an HTTP endpoint. It generates `commands.json` and the endpoint install archive from the same typed command tree that its Fetch handler runs, so an application does not write a manifest, route table, or `plugin.json`.
|
|
13
|
-
|
|
14
|
-
Read `node_modules/@north-light/crouter-plugin/README.md` after installing the package for the shortest working plugin, and https://github.com/vallum-security/crouter/tree/main/docs/plugin for parameters, outputs, errors, streaming, deployment, bundles, and memory docs. Confirm the installed package exports before writing against it; the authoring surface is `definePlugin`, `defineBranch`, `defineLeaf`, `defineStreamingLeaf`, `param`, `field`, `createFetchHandler`, `buildCommandManifest`, `buildBundle`, `LeafError`, `ManifestInvalidError`, `PluginDefinitionError`, and `kebab`.
|
|
15
|
-
|
|
16
|
-
Install a deployed handler with `crtr pkg plugin install --endpoint <public-handler-url> --name <plugin-name>`. The generated REST paths include the handler's public mount path, so install the URL the handler actually serves. Crouter synthesizes `.crouter-plugin/plugin.json` for this install; the application does not author it.
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
kind: knowledge
|
|
3
|
-
description: Driving a crouter daemon from an application with @north-light/crouter-sdk
|
|
4
|
-
when-and-why-to-read: When you are writing or reviewing application code that runs a crtr agent — installing @north-light/crouter-sdk, constructing a client, creating a node, watching its event stream, reading its result, reading or writing memory, or connecting a browser to a daemon — this reference should be read because `generate()` and `local()` were deleted, while the typed client keeps daemon transport and agent outcomes distinct.
|
|
5
|
-
short-form: The ESM-only application-facing client for a crtrd daemon. Construction and transports, `client.nodes` create/wait/parse/stream, activity snapshots, phase-2 resources including files and bash, `client.memory`, the returned-not-thrown outcome union, and error classes.
|
|
6
|
-
surfaces:
|
|
7
|
-
- on: boot
|
|
8
|
-
at: name
|
|
9
|
-
---
|
|
10
|
-
|
|
11
|
-
# `@north-light/crouter-sdk`
|
|
12
|
-
|
|
13
|
-
One ESM-only client an application installs to drive a crouter daemon over its `/v1` API: create agent runs, watch their event streams, wait for typed results, and reach the rest of the daemon. Resource methods issue `/v1` requests; `createAndWait`, `parse`, `stream`, and `auth.status` compose requests. crtrd stays the sole owner of canvas state. The runtime model behind the objects — nodes, the canvas, lifecycle, reports — is `internal/nodes-and-canvas`.
|
|
14
|
-
|
|
15
|
-
## Check what has shipped before you write against it
|
|
16
|
-
|
|
17
|
-
Streaming is shipped: `client.nodes.stream`, `client.nodes.events`, and `GET /v1/nodes/{id}/events`. Memory is shipped: `client.memory` exposes `list`, `retrieve`, `create`, `update`, `delete`, `move`, `search`, `history`, and `resolve`.
|
|
18
|
-
|
|
19
|
-
The client also ships construction and transports, `client.nodes` create / retrieve / list / outcome / waitForOutcome / createAndWait / parse / message / cancel / interrupt, `nodes.reports.list`, `profiles`, `system.status`, `files.read` / `write` / `list`, the error hierarchy, and per-request options. Phase 2 also ships node lifecycle, job, worktree, and result resources; canvas and canvas history; crons; human requests and inbox; models; and `client.bash.run`.
|
|
20
|
-
|
|
21
|
-
Confirm against the installed package's types rather than against any document, including this one.
|
|
22
|
-
|
|
23
|
-
## The published README is stale
|
|
24
|
-
|
|
25
|
-
`generate()`, `local()`, and the `Environment` interface were **deleted**, not deprecated — a hard cut with no shim. Code written from the npm README or from training data will call `generate({ prompt, schema, env: local() })` and will not compile. The replacement is `new Crouter()` plus `client.nodes.parse({ prompt, output_schema })`.
|
|
26
|
-
|
|
27
|
-
## A run, end to end
|
|
28
|
-
|
|
29
|
-
An agent run needs a daemon. `npm i -g @north-light/crouter` installs `crtr` and `crtrd`; `new Crouter()` starts the daemon itself on a cold socket, so nothing has to be running first.
|
|
30
|
-
|
|
31
|
-
```ts
|
|
32
|
-
import Crouter from '@north-light/crouter-sdk';
|
|
33
|
-
import { z } from 'zod';
|
|
34
|
-
|
|
35
|
-
const client = new Crouter();
|
|
36
|
-
|
|
37
|
-
const run = await client.nodes.parse({
|
|
38
|
-
prompt: 'Read package.json here and report its name and version.',
|
|
39
|
-
cwd: '/path/to/repo',
|
|
40
|
-
output_schema: z.object({ name: z.string(), version: z.string() }),
|
|
41
|
-
root: true,
|
|
42
|
-
root_lifecycle: 'terminal',
|
|
43
|
-
});
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
`root: true` means the run has no parent node and reports to nobody, which is what an application's run is. `root_lifecycle: 'terminal'` finishes and reaps; `'resident'` keeps the node for a person to open. Wire fields are `snake_case` and the SDK does not camelize them.
|
|
47
|
-
|
|
48
|
-
## The agent's own outcome is returned, never thrown
|
|
49
|
-
|
|
50
|
-
A run that refused the schema, hit its deadline, or crashed comes back as a value. Wrapping the call in `try`/`catch` and treating the catch as the failure path silently drops every agent-side outcome, because none of them throw.
|
|
51
|
-
|
|
52
|
-
```ts
|
|
53
|
-
if (run.kind === 'result') use(run.output_parsed);
|
|
54
|
-
else if (run.reason === 'declined') handleRefusal(run.declined?.reason, run.declined?.retryable);
|
|
55
|
-
else handleFailure(run.reason, run.detail);
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
A decline is `kind: 'failure'` with `reason: 'declined'` — narrow on `reason`, not on `kind`. `output_parsed` is non-null exactly when `kind === 'result'`. A Zod schema supplies its inferred output type; a Standard Schema supplies `~standard.types.output`; a JSON-Schema literal or any other `{ toJSONSchema() }` object makes it `unknown`. The SDK does not re-validate the result because the daemon already enforced the schema when the agent submitted.
|
|
59
|
-
|
|
60
|
-
Exceptions are for the layer underneath: `BadRequestError`, `AuthenticationError`, `PermissionDeniedError`, `NotFoundError`, `ConflictError`, `UnprocessableEntityError`, `RateLimitError`, `InternalServerError`, `APIConnectionError`, `APIConnectionTimeoutError`, `APIUserAbortError`, all extending `APIError` with `status`, `code`, `message`, `details`, `headers`. Branch on `code` — it is the stable machine-readable identity (`node_id_exists`, `daemon_unavailable`, `node_dormant`).
|
|
61
|
-
|
|
62
|
-
## A retried create spawns a second agent unless you pass `node_id`
|
|
63
|
-
|
|
64
|
-
`maxRetries` (default 2) covers connection errors and 429/5xx on `GET`, `HEAD`, and `DELETE`. **`POST` and `PATCH` are never retried**, because a mutation whose response was interrupted may already have been applied. A caller that wants a retry-safe create passes `node_id`: the duplicate then fails with `409 node_id_exists`, which the caller catches and turns into a `waitForOutcome` on the run that already exists.
|
|
65
|
-
|
|
66
|
-
## `waitForOutcome` has no time bound
|
|
67
|
-
|
|
68
|
-
It polls until the node settles, however long that takes. Bound it from one side or the other: a `deadline` on `create` makes the daemon cancel the run, a `signal` makes your client stop waiting. Aborting the signal stops the client, not the agent — `client.nodes.cancel(id)` stops the agent, `client.nodes.interrupt(id)` stops only the current turn.
|
|
69
|
-
|
|
70
|
-
## Watch a run
|
|
71
|
-
|
|
72
|
-
`const stream = client.nodes.stream(params, options?)` returns synchronously. `stream.node` resolves to the created node; `for await (const event of stream)` and `stream.on(type, listener)` receive the same typed events; `await stream.finalOutcome()` resolves from `node.settled`; and `stream.abort()` disconnects the observer without stopping the node. `client.nodes.events(id, options?)` watches an existing node; its options add `after` and omit request `timeout`. A `stream_gap` error event is followed by continuation; `stream_dropped` and `stream_error` reject `finalOutcome()`.
|
|
73
|
-
|
|
74
|
-
`followActivity(stream, { describe? })` converts tool-call events into immutable `ActivityStep[]` snapshots. `describeToolDefault` names common tools. A custom `describe(tool, summary)` returns a label or `null` to hide the call; `summary` states only the argument shape, never values, raw arguments, or tool output.
|
|
75
|
-
|
|
76
|
-
## Reaching a daemon that is not on this machine
|
|
77
|
-
|
|
78
|
-
`new Crouter()` uses the owner's unix socket, which authenticates by filesystem permission. A browser has no unix sockets and a remote process has no access to that one, so both use the TCP listener with a bearer token: `new Crouter({ baseURL, token })`.
|
|
79
|
-
|
|
80
|
-
The listener is off until someone runs `crtr sys connect` on the daemon's machine, which stores the address and token and hands the daemon over to a successor that boots with it on, then prints both to paste into the application. The token is the owner credential — whoever holds it reaches the whole surface. Cross-origin calls work only when a token is set; an unauthenticated listener stays same-origin so that no page the user happens to visit can drive their daemon. A page served over HTTPS calling `http://localhost:<port>` also needs Chrome's Local Network Access permission, which the browser prompts for once per site and which requires no response header.
|
|
81
|
-
|
|
82
|
-
`baseURL` and `socketPath` are mutually exclusive — passing both throws `TypeError` at construction. Options fall back to `CRTR_BASE_URL`, `CRTR_SOCKET`, `CRTR_HOME`, and `CRTRD_TOKEN`, read once at construction.
|
|
83
|
-
|
|
84
|
-
## Reaching a route the SDK does not wrap
|
|
85
|
-
|
|
86
|
-
`client.request(method, path, body?, options?)` carries the same authentication, retry policy, and error mapping as every generated method. Some routes are deliberately outside the typed surface — tmux focuses, a node's own inbox mail claim, local attach, and the broker's control plane — because an external caller invoking them either cannot use the result or becomes a second writer to state the broker and daemon coordinate between themselves.
|
|
87
|
-
|
|
88
|
-
## The full reference
|
|
89
|
-
|
|
90
|
-
Page-per-topic detail — the complete create-parameter table, streaming event table, memory scope object, resource map, and migration table — lives in the crouter repository under `docs/sdk/`, published at <https://github.com/vallum-security/crouter/tree/main/docs/sdk>.
|