@north-light/cli 0.3.483 → 0.3.484

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.
Files changed (92) hide show
  1. package/dist/api/client.d.ts +6 -0
  2. package/dist/api/client.js +3 -3
  3. package/dist/api/contract.d.ts +1 -1
  4. package/dist/api/contract.js +1 -1
  5. package/dist/api/dto/custom-objects.d.ts +5 -1
  6. package/dist/api/dto/docs.d.ts +26 -0
  7. package/dist/api/dto/objects.d.ts +21 -1
  8. package/dist/api/dto/plugins.d.ts +22 -0
  9. package/dist/api/dto/plugins.js +0 -0
  10. package/dist/api/index.d.ts +1 -0
  11. package/dist/api/index.js +1 -1
  12. package/dist/api/routes.d.ts +2 -0
  13. package/dist/api/routes.js +1 -1
  14. package/dist/builtin-memory/crouter-plugin/deploying.md +107 -0
  15. package/dist/builtin-memory/crouter-sdk/release-notes.md +69 -0
  16. package/dist/clients/attach/viewer.js +579 -578
  17. package/dist/commands/pkg/plugin-manage.d.ts +4 -0
  18. package/dist/commands/pkg/plugin-manage.js +18 -16
  19. package/dist/core/canvas/migrations.js +27 -18
  20. package/dist/core/command-plugins/bundle.d.ts +4 -1
  21. package/dist/core/command-plugins/bundle.js +1 -1
  22. package/dist/core/command-plugins/caller-header.d.ts +10 -0
  23. package/dist/core/command-plugins/caller-header.js +1 -0
  24. package/dist/core/command-plugins/compose.js +1 -1
  25. package/dist/core/command-plugins/endpoint.d.ts +4 -0
  26. package/dist/core/command-plugins/endpoint.js +1 -1
  27. package/dist/core/command-plugins/transport/exec-invoke-async.d.ts +11 -0
  28. package/dist/core/command-plugins/transport/exec-invoke-async.js +1 -0
  29. package/dist/core/command-plugins/transport/exec-invoke.d.ts +14 -0
  30. package/dist/core/command-plugins/transport/exec-invoke.js +1 -1
  31. package/dist/core/command-plugins/transport/http-invoke.d.ts +9 -2
  32. package/dist/core/command-plugins/transport/http-invoke.js +3 -3
  33. package/dist/core/command-plugins/transport/http-plan.js +1 -1
  34. package/dist/core/command-plugins/transport/sign.d.ts +55 -0
  35. package/dist/core/command-plugins/transport/sign.js +3 -0
  36. package/dist/core/graph/access.d.ts +19 -0
  37. package/dist/core/graph/access.js +3 -3
  38. package/dist/core/graph/custom.d.ts +29 -9
  39. package/dist/core/graph/custom.js +9 -8
  40. package/dist/core/graph/events.js +8 -8
  41. package/dist/core/graph/package-kinds.d.ts +25 -0
  42. package/dist/core/graph/package-kinds.js +1 -0
  43. package/dist/core/graph/package-reconcile.d.ts +20 -0
  44. package/dist/core/graph/package-reconcile.js +1 -0
  45. package/dist/core/graph/reader.d.ts +5 -0
  46. package/dist/core/graph/reader.js +3 -3
  47. package/dist/core/graph/receivers.d.ts +2 -1
  48. package/dist/core/graph/types.d.ts +2 -0
  49. package/dist/core/graph/watches.d.ts +4 -0
  50. package/dist/core/graph/watches.js +9 -8
  51. package/dist/core/peer/directory.d.ts +2 -1
  52. package/dist/core/peer/directory.js +1 -1
  53. package/dist/core/peer/ingest.d.ts +6 -1
  54. package/dist/core/peer/ingest.js +1 -1
  55. package/dist/core/peer/names.d.ts +2 -0
  56. package/dist/core/peer/names.js +1 -1
  57. package/dist/core/peer/outbox-store.d.ts +2 -0
  58. package/dist/core/peer/receiver.js +1 -1
  59. package/dist/core/peer/stubs.d.ts +26 -1
  60. package/dist/core/peer/stubs.js +1 -1
  61. package/dist/core/plugin-app.d.ts +31 -0
  62. package/dist/core/plugin-app.js +1 -0
  63. package/dist/core/plugin-objects-manifest.d.ts +35 -0
  64. package/dist/core/plugin-objects-manifest.js +1 -0
  65. package/dist/core/providers/bundles.js +2 -2
  66. package/dist/core/providers/call.d.ts +3 -0
  67. package/dist/core/providers/call.js +1 -1
  68. package/dist/core/secrets.d.ts +11 -0
  69. package/dist/core/secrets.js +1 -1
  70. package/dist/daemon/api/app-listener.js +13 -13
  71. package/dist/daemon/api/handlers/custom-objects.js +3 -3
  72. package/dist/daemon/api/handlers/objects.js +3 -2
  73. package/dist/daemon/api/handlers/package-docs.js +1 -1
  74. package/dist/daemon/api/handlers/plugin-app-token.d.ts +6 -0
  75. package/dist/daemon/api/handlers/plugin-app-token.js +1 -0
  76. package/dist/daemon/api/handlers/providers.d.ts +7 -0
  77. package/dist/daemon/api/handlers/providers.js +1 -1
  78. package/dist/daemon/api/operations.js +1 -1
  79. package/dist/daemon/api/server.js +1 -1
  80. package/dist/daemon/crtrd.js +7 -5
  81. package/dist/daemon/peer/forward.d.ts +4 -1
  82. package/dist/daemon/peer/forward.js +1 -1
  83. package/dist/daemon/plugin-objects/read-leaf.d.ts +20 -0
  84. package/dist/daemon/plugin-objects/read-leaf.js +2 -0
  85. package/dist/types.d.ts +16 -0
  86. package/docs/plugin/deploying.md +107 -0
  87. package/docs/sdk/release-notes.md +69 -0
  88. package/package.json +2 -2
  89. package/packages/crouter-identity/dist/index.d.ts +1 -1
  90. package/packages/crouter-identity/dist/index.js +6 -2
  91. package/packages/crouter-identity/package.json +1 -1
  92. package/runtime.lock.json +12 -12
@@ -0,0 +1,20 @@
1
+ import type { DatabaseSync } from 'node:sqlite';
2
+ import type { ObjectRow } from '../../core/graph/types.js';
3
+ import type { RequestPrincipal } from '../api/router.js';
4
+ export declare const READ_LEAF_DEADLINE_MS = 15000;
5
+ export interface ReadDelegation {
6
+ plugin: string;
7
+ command: string[];
8
+ id: string;
9
+ name: string;
10
+ }
11
+ export type ReadLeafResult = {
12
+ markdown: string;
13
+ } | {
14
+ unavailable: string;
15
+ };
16
+ /** The delegation for a custom object, or null when its kind has no read leaf or no installed plugin declares it any more (`declared=0`: an inert
17
+ * kind shows the last announcement). Sync: runs inside the first read transaction. */
18
+ export declare function readDelegationFor(db: DatabaseSync, object: ObjectRow): ReadDelegation | null;
19
+ /** Run the declared read leaf as `principal`. Never throws. */
20
+ export declare function runReadLeaf(d: ReadDelegation, principal: RequestPrincipal, deadlineMs?: number): Promise<ReadLeafResult>;
@@ -0,0 +1,2 @@
1
+ var f=Object.defineProperty;var l=(n,o)=>f(n,"name",{value:o,configurable:!0});import{randomUUID as g}from"node:crypto";import{prepared as h}from"../../core/sqlite-statements.js";import{listInstalledPlugins as v}from"../../core/resolver.js";import{validatePluginCommands as b}from"../../core/command-plugins/discovery.js";import{executeExternalLeafAsync as E}from"../../core/command-plugins/transport/exec-invoke-async.js";import{invokeHttpLeaf as k}from"../../core/command-plugins/transport/http-invoke.js";import{sha256Hex as x,signedHeaderDigest as _}from"../../core/command-plugins/transport/sign.js";import{pluginAppEnv as w}from"../../core/plugin-app.js";import{callProvider as y}from"../../core/providers/call.js";import{callerFromRequest as L}from"../api/handlers/providers.js";import{signCallHeaders as P}from"../api/handlers/plugin-app-token.js";const j=15e3;function C(n,o){const a=h(n,`SELECT k.read_json, k.declared, i.scheme, i.external_id FROM object_kinds k
2
+ LEFT JOIN identities i ON i.object = k.owner WHERE k.name = ?`).get(o.type);if(a===void 0||a.read_json===null||a.declared===0||a.scheme!=="app"||a.external_id===null||!a.external_id.startsWith("app:"))return null;const e=JSON.parse(a.read_json).command;return{plugin:a.external_id.slice(4),command:e,id:o.id,name:o.name}}l(C,"readDelegationFor");async function J(n,o,a=j){try{const e=v("user").find(r=>r.name===n.plugin);if(e===void 0||!e.enabled)return{unavailable:`plugin ${n.plugin} is not installed`};const u={id:n.id,name:n.name};let d;if(e.manifest.provider?.id===e.name){const r=AbortSignal.timeout(a),t=y(L(o),{provider:e.name,tool:n.command.join(" "),arguments:u},{requestId:g(),signal:r});t.catch(()=>{}),d=(await Promise.race([t,new Promise((p,i)=>{r.addEventListener("abort",()=>i(new Error(`provider read leaf gave no answer within ${a} ms`)),{once:!0})})])).body}else{const r=b(e),t=r.transport;let i=r.manifest?.roots.find(m=>m.name===e.name);for(const m of n.command)i=i?.kind==="branch"?i.children.find(s=>s?.name===m):void 0;if(i?.kind!=="leaf"||t?.kind!=="exec"&&t?.kind!=="http")return{unavailable:`plugin ${n.plugin} has no read leaf ${n.command.join(" ")}`};if(t.kind==="http"){const m=i;d=await k({registration:{name:e.name,endpoint:t.endpoint,...t.authEnv!==void 0?{authEnv:t.authEnv}:{}},...r.manifest?.baseUrl!==void 0?{baseUrl:r.manifest.baseUrl}:{},timeouts:{...r.manifest?.timeouts,requestMs:a},params:m.params,rest:m.rest,output:m.output,commandPath:[e.name,...n.command]},u,void 0,{callHeaders:l(async s=>P(e.name,o,{method:s.method,url:s.url.href,body_sha256:x(s.body),..._(s.headers)}).headers,"callHeaders")})}else{if(t.executable===void 0)return{unavailable:`plugin ${n.plugin} has no read leaf ${n.command.join(" ")}`};d=await E({plugin:e,executable:t.executable,commandPath:[e.name,...n.command],output:i.output},u,{deadlineMs:a,cwd:e.root,env:{...process.env,...w(e.name)??{}}})}}const c=d?.markdown;return typeof c=="string"?{markdown:c}:{unavailable:"read leaf returned no markdown"}}catch(e){return{unavailable:e instanceof Error?e.message:String(e)}}}l(J,"runReadLeaf");export{j as READ_LEAF_DEADLINE_MS,C as readDelegationFor,J as runReadLeaf};
package/dist/types.d.ts CHANGED
@@ -60,6 +60,18 @@ export type MemoryExtensionDeclaration = BooleanMemoryExtensionDeclaration | Str
60
60
  /** Field declarations owned by one plugin manifest. The plugin's `name` is
61
61
  * the namespace; keys here are its lowercase kebab-case local field names. */
62
62
  export type MemoryExtensionDeclarations = Record<string, MemoryExtensionDeclaration>;
63
+ /** One canvas object kind a plugin declares in `object_kinds`. */
64
+ export interface ObjectKindDeclaration {
65
+ description: string;
66
+ events: Record<string, {
67
+ level: number;
68
+ supersedes?: boolean;
69
+ }>;
70
+ /** A leaf path of the plugin's own commands, run to render an instance as markdown. */
71
+ read?: {
72
+ command: string[];
73
+ };
74
+ }
63
75
  export interface PluginManifest {
64
76
  name: string;
65
77
  version?: string;
@@ -124,6 +136,10 @@ export interface PluginManifest {
124
136
  /** App-scoped env variables required by this plugin, collected during install. */
125
137
  env?: Record<string, import('./core/plugin-env.js').PluginEnvDeclaration>;
126
138
  transport?: PluginTransport;
139
+ /** Canvas object kinds this plugin declares, keyed by kind name (`<plugin>.<name>`). */
140
+ object_kinds?: Record<string, ObjectKindDeclaration>;
141
+ /** Canvas scopes (`crtr:objects:<verb>:<target>`) a local plugin's app credential holds. */
142
+ scopes?: string[];
127
143
  /** Archive source for a crouter-materialized HTTP plugin. Distinct from the invocation transport. */
128
144
  bundle?: PluginBundle;
129
145
  /** A capability provider's `bundle.json` `provider` block, copied by the
@@ -65,6 +65,113 @@ A definition with `version: N`, or a list of definitions with one per supported
65
65
 
66
66
  A new optional flag, a new leaf, a new optional output field and changed prose are additive.
67
67
 
68
+ ## Local plugins
69
+
70
+ A plugin whose endpoint is `http://localhost`, `http://*.localhost` or another loopback host is a local plugin. crtr does not start it: run the service however you like (a terminal, launchd, a container). What crtr gives a local plugin is caller context on every call, a signature that proves the call came from crtr, and a credential for acting on the canvas.
71
+
72
+ ### Declaring object kinds and scopes
73
+
74
+ `plugin.json` (and `bundle.json`) take two optional top-level blocks:
75
+
76
+ ```json
77
+ {
78
+ "object_kinds": {
79
+ "search.page": {
80
+ "description": "A tracked web page",
81
+ "events": { "changed": { "level": 5, "supersedes": true } },
82
+ "read": { "command": ["page", "read"] }
83
+ }
84
+ },
85
+ "scopes": ["crtr:objects:link:node"]
86
+ }
87
+ ```
88
+
89
+ - A kind name's first segment is the plugin name. `events` holds at most 64 entries, each with a `level` from 1 to 10 and an optional boolean `supersedes`.
90
+ - `read.command` is a leaf path below the plugin's root command. crtr calls it with `{ "id", "name" }` to read an instance and expects a string field `markdown`.
91
+ - Each `scopes` entry has the form `crtr:objects:<read|watch|link|write>:<user|profile:<p>|app:<x>|node>`. A scope may not name the plugin's own space (`app:<plugin>`). A provider bundle may not declare `scopes`: a cloud app gets its scopes from directory consent.
92
+ - Install and update refuse an invalid block and leave the installed version in place. A kind another plugin already owns is refused with `kind_owned`; the plugin's other kinds still apply.
93
+
94
+ ### The app token
95
+
96
+ crtr gives each enabled local plugin that declares `object_kinds` or `scopes`, or uses an HTTP endpoint, one credential, `crtr_app_…`, carrying the manifest's `scopes`. The plugin uses it as `Authorization: Bearer <token>` against crtrd's `/v1` API, to register instances, link a caller, publish events and read.
97
+
98
+ A service fetches the token once at startup over crtrd's unix socket, with no bearer: it asks as the person who runs it, so it must run as that user.
99
+
100
+ ```
101
+ GET /v1/plugins/<name>/app-token (over the daemon socket)
102
+ → { "token": "crtr_app_…", "socket": "/path/to/the/daemon.sock" }
103
+ ```
104
+
105
+ The answer is `404 not_found` when the plugin is not installed, not enabled, invalid, or holds no token. Fetch it again after an update, which can change the scopes, and after a `401` (uninstall or disable revokes it).
106
+
107
+ crtr never sends this token to the plugin's port: not as a bearer, a header or a body field. It reaches an exec plugin as `CRTR_APP_TOKEN` and `CRTR_DAEMON_SOCKET` in the environment. Keep it in memory or in a file with mode 0600, and never log it.
108
+
109
+ ### `Crtr-Caller`
110
+
111
+ Every HTTP call to a plugin, local or hosted, carries who made it:
112
+
113
+ ```
114
+ Crtr-Caller: node=<id>; machine=<id>; profile=<id>; run=<id>
115
+ ```
116
+
117
+ The fields appear in that order. A field with no value is left out, and a call with none omits the header. A service uses `node` to link the calling node to an object it owns. The value comes from crtrd's view of the caller; a manifest cannot set `Crtr-Caller`, `Crtr-Signature` or `Crtr-Request-Id`.
118
+
119
+ ### `Crtr-Signature`
120
+
121
+ crtrd signs a call to a local plugin when the plugin holds a token and the request goes to the origin of its installed endpoint. Any other URL gets `Crtr-Caller` and no signature.
122
+
123
+ ```
124
+ Crtr-Signature: v1,t=<unix seconds>,h=<signed header names>,sig=<base64url HMAC-SHA256(token, canonical)>
125
+ ```
126
+
127
+ - `h` lists, lowercase, sorted and joined with `;`, every header crtr sent except `crtr-caller` and `crtr-signature`. It always includes `crtr-request-id`, a fresh UUID per call and the signature's nonce. A retry after a connection error sends the same id and the same signature.
128
+ - `canonical` is these lines joined with `\n`, no trailing newline:
129
+ 1. `v1`
130
+ 2. `t`
131
+ 3. the HTTP method, uppercase
132
+ 4. the request path with its query string, as received
133
+ 5. the lowercase hex sha256 of the exact body bytes (of the empty string when there is no body)
134
+ 6. the `Crtr-Caller` value, or an empty line
135
+ 7. `h`
136
+ 8. the lowercase hex sha256 of `<name>:<value>\n` for each name in `h`, in order, with each value as received: leading and trailing spaces and tabs removed, which is what Node and every other HTTP parser hands the service. crtr trims a mapped header value the same way before it signs and sends, so a padded value in a command argument is delivered without its padding
137
+
138
+ A service verifies a call in this order, and answers `401` when any step fails:
139
+
140
+ 1. Parse the header. The version must be `v1`.
141
+ 2. `|now − t| ≤ 300` seconds.
142
+ 3. `h` must include `crtr-request-id`, be sorted, and name only headers present on the request.
143
+ 4. Recompute `canonical` from the request as received and compare the MAC with a constant-time comparison.
144
+ 5. Reject a `Crtr-Request-Id` seen in the last 600 seconds, and remember this one. Do this after step 4, so a forged request cannot fill the cache.
145
+ 6. Trust only the headers named in `h`, plus `Crtr-Caller`.
146
+
147
+ ```ts
148
+ import { createHash, createHmac, timingSafeEqual } from 'node:crypto';
149
+
150
+ const sha = (data: string | Buffer) => createHash('sha256').update(data).digest('hex');
151
+
152
+ export function verify(token: string, req: { method: string; target: string; body: Buffer; headers: Record<string, string> },
153
+ seen: Map<string, number>, now = Date.now()): boolean {
154
+ const [v, t, h, sig] = (req.headers['crtr-signature'] ?? '').split(',');
155
+ if (v !== 'v1' || !t?.startsWith('t=') || !h?.startsWith('h=') || !sig?.startsWith('sig=')) return false;
156
+ const seconds = Number(t.slice(2));
157
+ if (!Number.isInteger(seconds) || Math.abs(now / 1000 - seconds) > 300) return false;
158
+ const names = h.slice(2).split(';');
159
+ if (!names.includes('crtr-request-id') || names.some((n, i) => req.headers[n] === undefined || (i > 0 && names[i - 1]! >= n))) return false;
160
+ const canonical = ['v1', String(seconds), req.method.toUpperCase(), req.target, sha(req.body),
161
+ req.headers['crtr-caller'] ?? '', names.join(';'), sha(names.map((n) => `${n}:${req.headers[n]}\n`).join(''))].join('\n');
162
+ const expected = createHmac('sha256', token).update(canonical).digest();
163
+ const given = Buffer.from(sig.slice(4), 'base64url');
164
+ if (given.length !== expected.length || !timingSafeEqual(given, expected)) return false;
165
+ for (const [id, at] of seen) if (now - at > 600_000) seen.delete(id);
166
+ const id = req.headers['crtr-request-id']!;
167
+ if (seen.has(id)) return false;
168
+ seen.set(id, now);
169
+ return true;
170
+ }
171
+ ```
172
+
173
+ `req.headers` is keyed by lowercase name (Node's `IncomingMessage` already does this) and `req.target` is `req.url`.
174
+
68
175
  ## Archive response
69
176
 
70
177
  The install response is an uncompressed tar with `Content-Type: application/x-tar`. Do not configure a proxy, CDN, or framework middleware to gzip or otherwise compress it. Crtr rejects compressed archive bytes. The handler sends an ETag and supports conditional `If-None-Match` requests automatically.
@@ -7,6 +7,75 @@ description: Behavior changes in @north-light/sdk that an app must act on, newes
7
7
 
8
8
  Changes to `@north-light/sdk` that can change what an existing app sees. Newest first.
9
9
 
10
+ ## 0.3.484
11
+
12
+ Plugins can now declare canvas object kinds and act on the canvas, and an app token can be granted canvas scopes. Everything below is additive: no request or response an existing app sends or reads changes, with one runtime-side exception under [Unknown bearers](#unknown-bearers-are-refused).
13
+
14
+ ### Plugin manifests declare `object_kinds` and `scopes` (additive)
15
+
16
+ `plugin.json` and `bundle.json` take two optional top-level blocks. `object_kinds` maps a kind name (`<plugin>.<name>`, so the first segment is the plugin's own name) to `{ description, events, read? }`: `events` holds up to 64 entries `{ level: 1-10, supersedes?: boolean }`, and `read.command` is a leaf path below the plugin's root command. That leaf must answer once: a leaf declared `rest.streaming: true` is refused as a `read.command`. `scopes` lists the canvas scopes the plugin asks for. A provider bundle may not declare `scopes`: a cloud app's scopes come from directory consent. Install, update and enable refuse an invalid block and keep the installed version; a kind another owner already holds is reported as `kind_owned` and the plugin's other kinds still apply. `crtr pkg plugin install|update|enable` print these as `warnings`, plus `appScopes` (the scopes the plugin's token now carries). Plugin authors: see [Local plugins](../plugin/deploying.md#local-plugins).
17
+
18
+ `ReconcilePackagesDTO` (the answer of `POST /v1/documents/reconcile-packages`) gains two optional fields: `kinds` (`applied` with `outcome` of `inserted`, `updated` or `unchanged`; `refused` with code `kind_owned`; `invalid` plugins with the reason) and `tokens` (`granted` plugins with their scopes, and `revoked` plugin names).
19
+
20
+ ### Canvas object scopes `crtr:objects:<verb>:<target>` (additive)
21
+
22
+ `@north-light/identity` accepts `crtr:objects:<read|watch|link|write>:<user|node|profile:<id>|app:<x>>`. Each scope is its own grant: `covers` is exact equality, so `crtr:objects:write:user` does not imply `read`. The target is where the object lives:
23
+
24
+ - `user`: objects in the person's space.
25
+ - `profile:<id>`: objects below that profile.
26
+ - `app:<x>`: nodes and custom objects of another app `x`. An app never needs a scope for its own objects, and a plugin may not declare its own `app:<plugin>` space.
27
+ - `node`: any node, including the stub of a node on another of the account's machines.
28
+
29
+ `read` lets the holder read objects of the target, `write` change them, and `link` (below) make a node watch an object the holder owns. `watch` lets a custom object that watches an object of the target read it. Holding a scope never lifts run confinement inside the owning app, and a revoked grant holds nothing. A public custom object is readable by any app that may use the owning app's tools, with no scope. The app listener now serves the canvas operations (`objects.*`, `custom-objects.*`, `docs.*`) to an app grant token under its resolved scopes; those rows answered `unknown operation` there before.
30
+
31
+ ### The `crtr_app_` credential and its socket fetch (additive)
32
+
33
+ Each enabled local plugin that declares `object_kinds` or `scopes`, or serves over HTTP, holds one `crtr_app_…` token carrying its manifest's `scopes`. It is issued when the plugin is installed or enabled, reissued on update (the scopes can change), and revoked on uninstall or disable. crtrd accepts it as a bearer on its unix socket and TCP listener, looks it up on every request (a revoked token stops working on the next one), and treats the holder as app `app:<plugin>`.
34
+
35
+ - `GET /v1/plugins/:name/app-token` (new operation `plugins.app-token`, person and broker callers) answers `{ token, socket }`, or `404 not_found` when the plugin is not installed, enabled, valid and holding a token. A service fetches it once at startup over the socket as the user who runs it. A node whose uid is not the daemon's gets `403 forbidden`.
36
+ - An exec plugin receives the token as `CRTR_APP_TOKEN` and the socket as `CRTR_DAEMON_SOCKET` in its leaf's environment. crtr never sends the token to a plugin's HTTP port.
37
+ - SDK: `CrtrClient.plugins.appToken(name)` and the DTO `PluginAppTokenDTO`; route helper `routes.pluginAppToken(name)`.
38
+
39
+ ### `Crtr-Caller` and `Crtr-Signature` on local HTTP calls (additive)
40
+
41
+ Every HTTP call to a plugin carries `Crtr-Caller: node=<id>; machine=<id>; profile=<id>; run=<id>` (fields in that order, empty ones left out, header omitted when none). Calls to a local plugin's endpoint origin also carry `Crtr-Signature: v1,t=<unix seconds>,h=<signed header names>,sig=<base64url HMAC-SHA256 keyed by the plugin's token>` plus a fresh `Crtr-Request-Id`. A manifest cannot set these three header names. Provider calls carry `Crtr-Caller` too. Plugin authors: the canonical string and a reference verifier are in [Local plugins](../plugin/deploying.md#local-plugins).
42
+
43
+ crtrd signs the call; the CLI never holds the token. `POST /v1/plugins/:name/call-headers` (new operation `plugins.call-headers`, person and broker callers) takes only digests, `{ method, url, body_sha256, header_names, headers_sha256 }`, and answers `{ headers }` (`Crtr-Caller`, and `Crtr-Signature` when the URL is on the installed endpoint's origin and that endpoint is loopback). Any other URL gets `Crtr-Caller` only. An unknown or disabled plugin and a provider plugin answer `404 not_found`; malformed digests answer `400 invalid_request`. SDK: `CrtrClient.plugins.callHeaders(name, request)`, `PluginCallHeadersRequestDTO`, `PluginCallHeadersDTO`, `routes.pluginCallHeaders(name)`.
44
+
45
+ ### Unknown bearers are refused
46
+
47
+ A bearer that crtrd does not recognize is now `401` on the TCP listener as well. A runtime with no owner token used to treat a request with a bearer it did not know as the owner; now only a request with no bearer is, and a live `crtr_app_` token is that app. `crtr_pub_` and the owner token behave as before.
48
+
49
+ ### `custom-objects.register` takes `privacy`, and `events` is optional (additive)
50
+
51
+ `RegisterCustomObjectRequestDTO.privacy?` is `public` (the default), `friends` or `private`; setting it on an existing instance changes it and publishes `configured` with `privacy` in `changed`. `events` is now optional: omit it to create or return an instance of a kind an installed plugin declares, which leaves the kind's catalog alone. Omitting it for any other kind is still `400 invalid_request`. `kind_owned` now guards only the kind catalog: registering an instance of a plugin's kind never conflicts with it.
52
+
53
+ ### Publishing a plugin-declared kind has new refusals
54
+
55
+ `custom-objects.publish` on an instance of a kind that an installed plugin declares (or that crossed from another machine):
56
+
57
+ - `404 not_here` when this machine holds only a stub of the object. Details are `{ id, home_machine }`; ask the home machine.
58
+ - `409 kind_inert` when the kind's plugin is no longer installed and enabled.
59
+ - `403 forbidden` unless the caller is the kind's owning app or holds the instance's publish token.
60
+
61
+ Instances of kinds an app registered itself publish as before.
62
+
63
+ ### Watching with `link` and `watcher_machine` (additive)
64
+
65
+ `POST /v1/objects/:ref/watch` and `DELETE …/watch` take an optional `watcher` ref naming a node or a custom object. A non-person app caller can name a node as the `watcher` when the object is one it owns and it holds `crtr:objects:link:<target of the watcher>`: the node then watches the object. Any miss, whatever the cause, is `404 not_found`. `watcher_machine` (body field; query parameter on DELETE) names the machine of an account's other node as the watcher; crtrd keeps a local stand-in for that node, and an event for a node that never watched the stand-in locally still reaches the node. A `watcher_machine` that is not one of the account's machines is `404`; an unreachable directory is `503 runtime_unreachable`. Custom-object watchers behave as before.
66
+
67
+ A linked node receives the object's events even when it could not read the object by its own access. crtrd keeps the linking app on the watch and checks its scope and ownership again at each publish, so a revoked scope or token stops new deliveries. Across machines, both the object's home machine and the node's machine need this release.
68
+
69
+ ### Reading: `kind_decl`, privacy and plugin read text (additive)
70
+
71
+ `ObjectDTO` gains an optional `kind_decl` (`{ name, description, events, owner }`). The runtime fills it on the object of an `objects.read` answer and of an `objects.watch` answer when the object is an instance of a custom kind, so another machine can hold a stub of it. It grants nothing. `ObjectListItemDTO` extends `ObjectDTO`, so its type carries the field, but list and search answers do not fill it. `privacy` is the field `ObjectDTO` already had: a read answered by another machine now carries the home object's `kind_decl` and `privacy` into the reader's stub, so a stub is never more readable than its home object.
72
+
73
+ A read of an instance of a plugin kind whose manifest sets `read.command` runs that leaf on the home machine (15 s deadline for exec and provider plugins alike), outside the canvas transaction, and returns its `markdown` as `text`. The `read` event and the read watch are recorded once. Access is checked again after the leaf returns, and a reader who lost it gets `not_found`; an object deleted while the leaf ran answers `state: "deleted"`, and one that vanished answers `not_found`. If the leaf cannot answer (plugin not installed or disabled, timeout, no string `markdown`), `text` is the last announcement followed by `\ncontent unavailable: <reason>`. Such a read adds `data.content`: `"live"` or `"unavailable"`. A kind that is no longer declared by an installed plugin, a kind without `read.command`, and every other object read as before, with no `data.content`.
74
+
75
+ ### Migrations v89–v91
76
+
77
+ The canvas database gains `object_kinds.read_json`, `object_kinds.source` (`register`, `manifest` or `peer`) and `object_kinds.declared` (v89), a `peer_ingested_destinations` table recording each event destination already ingested from another machine (v90), and `watches.link_app`, the app that made a watch through `link` (v91). No app action; an older runtime cannot open a database migrated by this release.
78
+
10
79
  ## 0.3.483
11
80
 
12
81
  ### `unavailable`, `step` and `setupLink` on `grant.get` dependencies (additive for the SDK; a type change for exhaustive switches)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@north-light/cli",
3
- "version": "0.3.483",
3
+ "version": "0.3.484",
4
4
  "description": "crtr — agent runtime with memory, plugins, and marketplaces",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -137,7 +137,7 @@
137
137
  },
138
138
  "license": "UNLICENSED",
139
139
  "dependencies": {
140
- "@north-light/identity": "0.3.483",
140
+ "@north-light/identity": "0.3.484",
141
141
  "@earendil-works/pi-agent-core": "1.1.0",
142
142
  "@earendil-works/pi-ai": "1.1.0",
143
143
  "@earendil-works/pi-coding-agent": "1.1.0",
@@ -22,7 +22,7 @@ export interface IdTokenClaims extends JWTPayload {
22
22
  family_name?: string;
23
23
  picture?: string;
24
24
  }
25
- export type Scope = 'crtr:llm' | 'crtr:act' | 'crtr:schedule' | `crtr:memory:${'read' | 'rw'}:user${'' | `:${string}`}` | 'crtr:memory:manage:user' | `crtr:memory:${'read' | 'rw'}:app:${string}` | `crtr:files:${'read' | 'rw'}:${'user' | `app:${string}`}:${string}` | 'crtr:files:share' | `crtr:${'conversations' | 'objects'}:read:app:${string}` | `crtr:objects:${'message' | 'spawn'}:app:${string}` | `crtr:peer:${string}` | `${string}:${string}`;
25
+ export type Scope = 'crtr:llm' | 'crtr:act' | 'crtr:schedule' | `crtr:memory:${'read' | 'rw'}:user${'' | `:${string}`}` | 'crtr:memory:manage:user' | `crtr:memory:${'read' | 'rw'}:app:${string}` | `crtr:files:${'read' | 'rw'}:${'user' | `app:${string}`}:${string}` | 'crtr:files:share' | `crtr:${'conversations' | 'objects'}:read:app:${string}` | `crtr:objects:${'message' | 'spawn'}:app:${string}` | `crtr:objects:${'read' | 'watch' | 'link' | 'write'}:${'user' | 'node' | `profile:${string}` | `app:${string}`}` | `crtr:peer:${string}` | `${string}:${string}`;
26
26
  /** App-memory form keys omit the app id. */
27
27
  export declare const ENFORCED: ReadonlySet<string>;
28
28
  export declare function parseScope(value: string, grantee?: string): Scope;
@@ -31,8 +31,12 @@ function selector(value) {
31
31
  match = /^crtr:files:(read|rw):(user|app:[A-Za-z0-9_-]{1,64}):(.+)$/.exec(value);
32
32
  if (match && validPath(match[3], true))
33
33
  return { kind: 'files', access: match[1], holder: match[2], path: match[3] };
34
- // read, message and spawn are three unrelated scopes: `covers` is exact equality for them.
35
- match = /^crtr:(?:(conversations):read|(objects):(?:read|message|spawn)):app:([A-Za-z0-9_-]{1,64})$/.exec(value);
34
+ // Canvas object scopes `crtr:objects:<read|watch|link|write>:<user|node|profile:<p>|app:<x>>`. They, and the
35
+ // message and spawn scopes below, are unrelated scopes: `covers` is exact equality for every one of them.
36
+ match = /^crtr:objects:(?:read|watch|link|write):(?:user|node|profile:[A-Za-z0-9_-]{1,64}|app:[A-Za-z0-9_-]{1,64})$/.exec(value);
37
+ if (match)
38
+ return { kind: 'objects', value };
39
+ match = /^crtr:(?:(conversations):read|(objects):(?:message|spawn)):app:([A-Za-z0-9_-]{1,64})$/.exec(value);
36
40
  if (match)
37
41
  return { kind: (match[1] ?? match[2]), value };
38
42
  match = /^crtr:peer:([A-Za-z0-9_-]{1,64})$/.exec(value);
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@north-light/identity",
3
- "version": "0.3.483",
3
+ "version": "0.3.484",
4
4
  "description": "Northlight access-token verification and scope rules",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
package/runtime.lock.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@north-light/cli",
3
- "version": "0.3.483",
3
+ "version": "0.3.484",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@north-light/cli",
9
- "version": "0.3.483",
9
+ "version": "0.3.484",
10
10
  "hasInstallScript": true,
11
11
  "license": "UNLICENSED",
12
12
  "workspaces": [
@@ -18,7 +18,7 @@
18
18
  "@earendil-works/pi-ai": "1.1.0",
19
19
  "@earendil-works/pi-coding-agent": "1.1.0",
20
20
  "@earendil-works/pi-tui": "1.1.0",
21
- "@north-light/identity": "0.3.483",
21
+ "@north-light/identity": "0.3.484",
22
22
  "cron-parser": "^5.6.0",
23
23
  "esbuild": "^0.27.7",
24
24
  "jose": "^6.2.12",
@@ -12116,17 +12116,17 @@
12116
12116
  },
12117
12117
  "packages/crouter-api": {
12118
12118
  "name": "@north-light/api",
12119
- "version": "0.3.483",
12119
+ "version": "0.3.484",
12120
12120
  "license": "UNLICENSED"
12121
12121
  },
12122
12122
  "packages/crouter-env-docker": {
12123
12123
  "name": "@north-light/env-docker",
12124
- "version": "0.3.483",
12124
+ "version": "0.3.484",
12125
12125
  "license": "UNLICENSED"
12126
12126
  },
12127
12127
  "packages/crouter-identity": {
12128
12128
  "name": "@north-light/identity",
12129
- "version": "0.3.483",
12129
+ "version": "0.3.484",
12130
12130
  "license": "UNLICENSED",
12131
12131
  "dependencies": {
12132
12132
  "jose": "^6.2.1"
@@ -12134,20 +12134,20 @@
12134
12134
  },
12135
12135
  "packages/crouter-plugin": {
12136
12136
  "name": "@north-light/plugin",
12137
- "version": "0.3.483",
12137
+ "version": "0.3.484",
12138
12138
  "license": "UNLICENSED",
12139
12139
  "dependencies": {
12140
- "@north-light/api": "0.3.483",
12141
- "@north-light/identity": "0.3.483"
12140
+ "@north-light/api": "0.3.484",
12141
+ "@north-light/identity": "0.3.484"
12142
12142
  }
12143
12143
  },
12144
12144
  "packages/crouter-sdk": {
12145
12145
  "name": "@north-light/sdk",
12146
- "version": "0.3.483",
12146
+ "version": "0.3.484",
12147
12147
  "license": "UNLICENSED",
12148
12148
  "dependencies": {
12149
- "@north-light/api": "0.3.483",
12150
- "@north-light/identity": "0.3.483",
12149
+ "@north-light/api": "0.3.484",
12150
+ "@north-light/identity": "0.3.484",
12151
12151
  "jose": "^6.2.1"
12152
12152
  },
12153
12153
  "bin": {