@north-light/cli 0.3.789 → 0.3.790
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/api/client.d.ts +3 -1
- package/dist/api/client.js +1 -1
- package/dist/api/contract.d.ts +1 -1
- package/dist/api/contract.js +1 -1
- package/dist/clients/attach/viewer.js +255 -255
- package/dist/commands/canvas-history/shared.js +1 -1
- package/dist/commands/node/create.js +2 -2
- package/dist/commands/person-settings.js +1 -1
- package/dist/commands/profile/daemon-profiles.js +4 -4
- package/dist/commands/sys.js +1 -1
- package/dist/core/canvas/history.d.ts +2 -8
- package/dist/core/canvas/history.js +9 -9
- package/dist/core/canvas/node-tokens.js +3 -3
- package/dist/core/canvas/person-state.d.ts +5 -7
- package/dist/core/canvas/person-state.js +1 -1
- package/dist/core/canvas/person.d.ts +3 -30
- package/dist/core/canvas/person.js +1 -11
- package/dist/core/config.d.ts +4 -1
- package/dist/core/config.js +1 -1
- package/dist/core/directory/join.d.ts +4 -6
- package/dist/core/directory/join.js +1 -1
- package/dist/core/grants/sync.js +1 -1
- package/dist/core/human/requests.d.ts +11 -1
- package/dist/core/human/requests.js +22 -22
- package/dist/core/review/store.js +1 -1
- package/dist/core/runtime/broker.js +1 -1
- package/dist/core/runtime/host.js +3 -3
- package/dist/core/runtime/launch-config-worker.js +1 -1
- package/dist/core/runtime/launch-target.d.ts +6 -4
- package/dist/core/runtime/launch-target.js +1 -1
- package/dist/core/runtime/launch.d.ts +5 -1
- package/dist/core/runtime/launch.js +2 -2
- package/dist/core/runtime/runner/machine/runner.js +1 -1
- package/dist/core/runtime/spawn-env-rows.js +1 -1
- package/dist/core/runtime/spawn.js +2 -2
- package/dist/core/secrets/environment-owner.js +1 -1
- package/dist/daemon/api/handlers/canvas.js +5 -5
- package/dist/daemon/api/handlers/nodes.js +1 -1
- package/dist/daemon/api/handlers/profiles.js +1 -1
- package/dist/daemon/cron/lease-recovery.js +1 -1
- package/dist/daemon/human/sweep.js +1 -1
- package/dist/daemon/peer/ingress.d.ts +2 -2
- package/dist/daemon/reconcilers/grove-instance-sweep.js +1 -1
- package/dist/daemon/runs/observer.js +6 -5
- package/package.json +3 -3
- package/packages/crouter-api/dist/api/client.js +2 -2
- package/packages/crouter-api/dist/api/contract.js +1 -1
- package/packages/crouter-api/dist/core/canvas/person-state.js +9 -11
- package/packages/crouter-api/dist/core/config.js +10 -0
- package/packages/crouter-api/dist/core/directory/join.js +11 -45
- 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/join.d.ts +0 -3
- package/dist/commands/sys/join.js +0 -1
|
@@ -934,6 +934,8 @@ function readRawProfileConfig(profileId) {
|
|
|
934
934
|
* — the SCOPE THE CONFIG IS FOR, not necessarily the calling process's own
|
|
935
935
|
* ambient cwd/profile (see `readMergedLaunchConfig`). */
|
|
936
936
|
function readRawProjectScopeConfigs(targetCwd, targetProfileId) {
|
|
937
|
+
if (targetCwd === null)
|
|
938
|
+
return [];
|
|
937
939
|
const nearestFirst = findProjectScopeRoots(targetCwd, targetProfileId);
|
|
938
940
|
const farthestFirst = [...nearestFirst].reverse();
|
|
939
941
|
// A root with no config.json still contributes: its installed plugins may
|
|
@@ -1020,6 +1022,14 @@ export function readMergedLaunchConfig(targetCwd = process.cwd(), targetProfileI
|
|
|
1020
1022
|
spawnEnv,
|
|
1021
1023
|
};
|
|
1022
1024
|
}
|
|
1025
|
+
/** The launch config a process holding the project's files adds on top of a recipe's config, which a cloud control plane built without them:
|
|
1026
|
+
* the project stack's kinds (and the kinds its enabled plugins declare) in `cwd`, over the recipe's kinds. */
|
|
1027
|
+
export function overlayProjectLaunchConfig(base, cwd, profileId) {
|
|
1028
|
+
let kinds = base.kinds;
|
|
1029
|
+
for (const { root, raw } of readRawProjectScopeConfigs(cwd, profileId))
|
|
1030
|
+
kinds = mergeKinds(raw?.kinds, layerPluginKinds('project', root, kinds));
|
|
1031
|
+
return { ...base, kinds };
|
|
1032
|
+
}
|
|
1023
1033
|
/** The effective `KindConfig` for one full kind string (top-level, e.g.
|
|
1024
1034
|
* `developer`, or sub-kind, e.g. `audit/security`), across
|
|
1025
1035
|
* project > user > builtin precedence. Returns `undefined` for a kind no
|
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
// Runtime registration: send the directory a new public ES256 key under a credential (a
|
|
2
|
-
// boot, or a signed-in person's bearer from `crtr sys signin`), then record the returned identity and the private key in the runtime-client file.
|
|
1
|
+
// Runtime registration: send the directory a new public ES256 key under a credential (a signed-in person's bearer from `crtr sys signin`), then record the returned identity and the private key in the runtime-client file.
|
|
3
2
|
// It writes no settings (the daemon applies them at its start); the private key never leaves this computer.
|
|
4
3
|
import { createHash, generateKeyPairSync, randomUUID } from 'node:crypto';
|
|
5
4
|
import { existsSync, mkdirSync, readdirSync, rmSync } from 'node:fs';
|
|
6
|
-
import { request } from 'node:http';
|
|
7
5
|
import { hostname } from 'node:os';
|
|
8
6
|
import { join } from 'node:path';
|
|
9
7
|
import { InputError } from '../io.js';
|
|
10
8
|
import { network } from '../errors.js';
|
|
11
9
|
import { secretsDir } from '../layout.js';
|
|
12
|
-
import { apiSocketPath } from '../canvas/paths.js';
|
|
13
10
|
import { atomicWriteJson, readJsonIfExists } from '../fs-utils.js';
|
|
14
11
|
import { launcherPresent } from '../grants/sandboxes.js';
|
|
15
12
|
import { crtrVersion } from '../../shared/crtr-version.js';
|
|
@@ -74,7 +71,7 @@ async function register(directory, token, publicJwk, name, retry) {
|
|
|
74
71
|
if (response.status < 500)
|
|
75
72
|
rmSync(pendingPath(), { force: true });
|
|
76
73
|
throw new InputError({
|
|
77
|
-
error: '
|
|
74
|
+
error: 'registration_refused',
|
|
78
75
|
message: `directory refused the registration: ${response.status} ${text.slice(0, 500)}`,
|
|
79
76
|
next: retry,
|
|
80
77
|
});
|
|
@@ -88,34 +85,27 @@ async function register(directory, token, publicJwk, name, retry) {
|
|
|
88
85
|
throw error;
|
|
89
86
|
}
|
|
90
87
|
}
|
|
91
|
-
/** What a successful
|
|
92
|
-
* without
|
|
93
|
-
* and
|
|
88
|
+
/** What a successful registration recorded in the client file, or null when none did (no file, or one provisioned
|
|
89
|
+
* without registration, which has no `token_sha256`). Registration writes no settings: the daemon applies this at its start (`applyBootSettings`),
|
|
90
|
+
* and takes `owner` as the install's person. */
|
|
94
91
|
function readJoined() {
|
|
95
92
|
const stored = readJsonIfExists(clientPath());
|
|
96
93
|
if (stored?.token_sha256 === undefined)
|
|
97
94
|
return null;
|
|
98
95
|
const { owner } = stored;
|
|
99
96
|
if (typeof owner !== 'string' || !/^user:.+/.test(owner))
|
|
100
|
-
throw new Error(`${clientPath()} was written by
|
|
97
|
+
throw new Error(`${clientPath()} was written by registration but has a missing or invalid owner`);
|
|
101
98
|
return stored;
|
|
102
99
|
}
|
|
103
|
-
/** The owner a successful
|
|
100
|
+
/** The owner a successful registration recorded, or null when no registration wrote the client file. */
|
|
104
101
|
export function joinedOwner() { return readJoined()?.owner ?? null; }
|
|
105
|
-
/** The issuer a successful
|
|
102
|
+
/** The issuer a successful registration recorded, or null. */
|
|
106
103
|
export function joinedIssuer() { return readJoined()?.issuer ?? null; }
|
|
107
|
-
/** The whole registration a successful
|
|
104
|
+
/** The whole registration a successful registration recorded, or null; a damaged file throws. */
|
|
108
105
|
export function joinedClient() {
|
|
109
106
|
const stored = readJoined();
|
|
110
107
|
return stored === null ? null : registration(stored);
|
|
111
108
|
}
|
|
112
|
-
function daemonRunningError(socket) {
|
|
113
|
-
return new InputError({
|
|
114
|
-
error: 'daemon_running',
|
|
115
|
-
message: `cannot register while a daemon answers on ${socket}`,
|
|
116
|
-
next: 'Stop the daemon that owns this volume, then run `crtr sys join` again.',
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
109
|
/** Register (or reuse the stored registration) without touching local state beyond the pending key. */
|
|
120
110
|
async function obtainRegistration(directory, token, name, tokenHash, retry) {
|
|
121
111
|
const stored = readJsonIfExists(clientPath());
|
|
@@ -143,7 +133,7 @@ function requireDirectory(directory) {
|
|
|
143
133
|
async function registerAndStore(directory, credential, name, retry) {
|
|
144
134
|
requireDirectory(directory);
|
|
145
135
|
if (credential === '')
|
|
146
|
-
throw new InputError({ error: 'invalid_token', message: 'credential is empty', field: 'token', next: '
|
|
136
|
+
throw new InputError({ error: 'invalid_token', message: 'credential is empty', field: 'token', next: 'Sign in again with `crtr sys signin`.' });
|
|
147
137
|
const { joined, registered, client } = await obtainRegistration(directory, credential, name, createHash('sha256').update(credential).digest('hex'), retry);
|
|
148
138
|
if (client) {
|
|
149
139
|
atomicWriteJson(clientPath(), client, { mode: 0o600 });
|
|
@@ -151,32 +141,8 @@ async function registerAndStore(directory, credential, name, retry) {
|
|
|
151
141
|
}
|
|
152
142
|
return { ...joined, registered };
|
|
153
143
|
}
|
|
154
|
-
/** True when a daemon answers /healthz on the socket (a blocked daemon still answers and owns its files). */
|
|
155
|
-
function daemonAnswers(socketPath) {
|
|
156
|
-
return new Promise(resolve => {
|
|
157
|
-
const req = request({ socketPath, path: '/healthz', method: 'GET', timeout: 1000 }, res => {
|
|
158
|
-
res.resume();
|
|
159
|
-
resolve(true);
|
|
160
|
-
});
|
|
161
|
-
req.on('timeout', () => req.destroy(new Error('daemon probe timed out')));
|
|
162
|
-
req.on('error', error => {
|
|
163
|
-
if (error.code === 'ENOENT' || error.code === 'ECONNREFUSED')
|
|
164
|
-
resolve(false);
|
|
165
|
-
else
|
|
166
|
-
resolve(true); // Uncertain probe: do not touch an owned volume.
|
|
167
|
-
});
|
|
168
|
-
req.end();
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
/** A hosted runtime's first boot: register with the provisioning enrollment token before any daemon exists. Refuses `daemon_running` when one answers. */
|
|
172
|
-
export async function joinDirectory(directory, token, name = hostname()) {
|
|
173
|
-
const socket = apiSocketPath();
|
|
174
|
-
if (await daemonAnswers(socket))
|
|
175
|
-
throw daemonRunningError(socket);
|
|
176
|
-
return registerAndStore(directory, token, name, 'Provisioning must supply a new enrollment token; they are single-use and expire after 10 minutes.');
|
|
177
|
-
}
|
|
178
144
|
/** `crtr sys signin`'s registration: the signed-in person's bearer registers this computer as one of the person's runtimes, once. A computer that
|
|
179
|
-
* already holds a registration for this directory's owner (
|
|
145
|
+
* already holds a registration for this directory's owner (an earlier signin) is left as it is. */
|
|
180
146
|
export async function registerSignedInMac(directory, bearer) {
|
|
181
147
|
if (readJoined() !== null)
|
|
182
148
|
return null;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@north-light/api",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.790",
|
|
4
4
|
"description": "Typed crtrd /v1 API contract — DTOs, route builders, the error contract, the CrtrClient, and the command-plugin manifest format. Zero runtime dependencies.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/api/index.js",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@north-light/plugin",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.790",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
"postpack": "node ../../scripts/pack-minify.mjs postpack packages/crouter-plugin"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@north-light/api": "0.3.
|
|
31
|
-
"@north-light/identity": "0.3.
|
|
30
|
+
"@north-light/api": "0.3.790",
|
|
31
|
+
"@north-light/identity": "0.3.790"
|
|
32
32
|
},
|
|
33
33
|
"license": "UNLICENSED",
|
|
34
34
|
"publishConfig": {
|
package/runtime.lock.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@north-light/cli",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.790",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@north-light/cli",
|
|
9
|
-
"version": "0.3.
|
|
9
|
+
"version": "0.3.790",
|
|
10
10
|
"hasInstallScript": true,
|
|
11
11
|
"license": "UNLICENSED",
|
|
12
12
|
"workspaces": [
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"@milkdown/preset-gfm": "^7.22.3",
|
|
29
29
|
"@milkdown/prose": "^7.22.3",
|
|
30
30
|
"@milkdown/utils": "^7.22.3",
|
|
31
|
-
"@north-light/identity": "0.3.
|
|
32
|
-
"@north-light/plugin": "0.3.
|
|
31
|
+
"@north-light/identity": "0.3.790",
|
|
32
|
+
"@north-light/plugin": "0.3.790",
|
|
33
33
|
"cron-parser": "^5.6.0",
|
|
34
34
|
"esbuild": "0.28.2",
|
|
35
35
|
"jose": "^6.2.12",
|
|
@@ -11902,17 +11902,17 @@
|
|
|
11902
11902
|
},
|
|
11903
11903
|
"packages/crouter-api": {
|
|
11904
11904
|
"name": "@north-light/api",
|
|
11905
|
-
"version": "0.3.
|
|
11905
|
+
"version": "0.3.790",
|
|
11906
11906
|
"license": "UNLICENSED"
|
|
11907
11907
|
},
|
|
11908
11908
|
"packages/crouter-env-docker": {
|
|
11909
11909
|
"name": "@north-light/env-docker",
|
|
11910
|
-
"version": "0.3.
|
|
11910
|
+
"version": "0.3.790",
|
|
11911
11911
|
"license": "UNLICENSED"
|
|
11912
11912
|
},
|
|
11913
11913
|
"packages/crouter-identity": {
|
|
11914
11914
|
"name": "@north-light/identity",
|
|
11915
|
-
"version": "0.3.
|
|
11915
|
+
"version": "0.3.790",
|
|
11916
11916
|
"license": "UNLICENSED",
|
|
11917
11917
|
"dependencies": {
|
|
11918
11918
|
"jose": "^6.2.1"
|
|
@@ -11920,21 +11920,21 @@
|
|
|
11920
11920
|
},
|
|
11921
11921
|
"packages/crouter-plugin": {
|
|
11922
11922
|
"name": "@north-light/plugin",
|
|
11923
|
-
"version": "0.3.
|
|
11923
|
+
"version": "0.3.790",
|
|
11924
11924
|
"license": "UNLICENSED",
|
|
11925
11925
|
"dependencies": {
|
|
11926
|
-
"@north-light/api": "0.3.
|
|
11927
|
-
"@north-light/identity": "0.3.
|
|
11926
|
+
"@north-light/api": "0.3.790",
|
|
11927
|
+
"@north-light/identity": "0.3.790"
|
|
11928
11928
|
}
|
|
11929
11929
|
},
|
|
11930
11930
|
"packages/crouter-sdk": {
|
|
11931
11931
|
"name": "@north-light/sdk",
|
|
11932
|
-
"version": "0.3.
|
|
11932
|
+
"version": "0.3.790",
|
|
11933
11933
|
"license": "UNLICENSED",
|
|
11934
11934
|
"dependencies": {
|
|
11935
|
-
"@north-light/api": "0.3.
|
|
11936
|
-
"@north-light/identity": "0.3.
|
|
11937
|
-
"@north-light/plugin": "0.3.
|
|
11935
|
+
"@north-light/api": "0.3.790",
|
|
11936
|
+
"@north-light/identity": "0.3.790",
|
|
11937
|
+
"@north-light/plugin": "0.3.790",
|
|
11938
11938
|
"jose": "^6.2.1"
|
|
11939
11939
|
},
|
|
11940
11940
|
"bin": {
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
/** Whether a broker (a node's engine) is an ancestor of this process, or cannot be ruled out. Stopping the daemon kills every broker, so a join run from one would die mid-way. */
|
|
2
|
-
export declare function insideBroker(): boolean;
|
|
3
|
-
export declare const sysJoinLeaf: import("../../core/command.js").LeafDef;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var s=Object.defineProperty;var r=(t,n)=>s(t,"name",{value:n,configurable:!0});import{defineLeaf as a}from"../../core/command.js";import{joinDirectory as o}from"../../core/directory/join.js";import{listProcessTable as d}from"../../core/canvas/pid.js";import{envNodeId as u}from"../../shared/env.js";function y(){const t=d();if(t===null||(u()??"")!=="")return!0;const n=new Map(t.map(e=>[e.pid,e])),i=new Set;for(let e=process.ppid;e>1&&!i.has(e);e=n.get(e)?.ppid??0)if(i.add(e),n.get(e)?.command.includes("broker-cli"))return!0;return!1}r(y,"insideBroker");const f=a({name:"join",description:"register a hosted runtime with its directory using the provisioning enrollment token, before its daemon starts",whenToUse:"only at a hosted runtime's first boot, before the daemon starts, with the enrollment token provisioning passed in. A person's own computer registers through `crtr sys signin`.",help:{name:"sys join",summary:"exchange a directory enrollment token for a new runtime client key and record the returned identity",guide:"Generates a new ES256 client key, sends only its public key to `PUT <directory>/v1/runtimes/registration` with the token as bearer, and learns the runtime id, client id, issuer, owner and URL from the answer. Only after that answer does it write the key file. It writes no settings and touches no canvas.db: the daemon's next start replaces this install's person with the owner everywhere in canvas.db and sets `runtime.issuer` and `runtime.audience` from the key file. It never touches a daemon: while one answers it refuses `daemon_running`. Presenting the token of the stored successful registration again finishes without calling the directory. Any other token generates a new key and registers again.",params:[{kind:"flag",name:"directory",type:"string",required:!0,constraint:"Directory base URL (http or https) that minted the token."},{kind:"flag",name:"token",type:"string",required:!0,sensitive:!0,constraint:"Single-use enrollment token. Sensitive: never echoed in output or errors."},{kind:"flag",name:"name",type:"string",required:!1,constraint:"Label shown for this machine on the account page. Default: this computer's hostname."}],output:[{name:"runtime",type:"string",required:!0,constraint:"Runtime principal from the directory, `runtime:<id>`."},{name:"client_id",type:"string",required:!0,constraint:"OAuth client id registered for the new key."},{name:"issuer",type:"string",required:!0,constraint:"Canonical issuer, written to `runtime.issuer`."},{name:"owner",type:"string",required:!0,constraint:"Owner principal, `user:<id>`, that replaces this install's own person at the next daemon start."},{name:"canvas_rewrite",type:"string",required:!0,constraint:"Always `next daemon start`: when canvas.db identity fields are rewritten."},{name:"url",type:"string",required:!0,constraint:"Runtime URL, written to `runtime.audience`."},{name:"registered",type:"boolean",required:!0,constraint:"False when the token matched the stored registration and the directory was not called."}],outputKind:"object",effects:["On a new token: calls the directory once; on success writes `<runtime>/secrets/runtime-client.json` (mode 0600) with the private key, registration and the token's SHA-256, replacing any earlier key file. A refused or failed call writes nothing.","Sends name, platform, crtr version, installed plugin ids and sandbox state with the public key. Before the request it writes `runtime-client.pending.json` (mode 0600); a rerun with the same token and directory reuses that key, so a lost reply is retried safely. The file is deleted on success or a refusal.","At the next daemon start, before any listener, the person this install minted is replaced by the owner in every canvas.db column that holds a person, and the legacy local person's profile grantees become `app:terminal`."]},run:r(async t=>({...await o(t.directory,t.token,t.name||void 0),canvas_rewrite:"next daemon start"}),"run")});export{y as insideBroker,f as sysJoinLeaf};
|