@north-light/cli 0.3.760 → 0.3.762
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/internal/nodes-and-canvas.md +1 -1
- package/dist/builtin-memory/internal/storage-tiers.md +1 -1
- package/dist/cli.js +5 -5
- package/dist/clients/attach/config.js +1 -1
- package/dist/clients/attach/viewer.js +467 -467
- package/dist/commands/api-client.d.ts +0 -5
- package/dist/commands/api-client.js +3 -3
- package/dist/commands/daemon-generation.js +1 -1
- package/dist/commands/sys/import/move.d.ts +1 -34
- package/dist/commands/sys/import/move.js +5 -9
- package/dist/commands/sys/import/start.d.ts +0 -3
- package/dist/commands/sys/import/start.js +1 -1
- package/dist/commands/sys/signin.js +2 -2
- package/dist/core/canvas/managed-worktree-sweep-candidates.d.ts +2 -0
- package/dist/core/canvas/managed-worktree-sweep-candidates.js +6 -4
- package/dist/core/command.d.ts +1 -1
- package/dist/core/runtime/front-door.js +9 -10
- package/dist/core/user-settings.d.ts +2 -2
- package/dist/core/worktree-mutation-async.js +5 -5
- package/dist/core/worktree-scripts.d.ts +13 -0
- package/dist/core/worktree-scripts.js +5 -0
- package/dist/core/worktree-sweep.js +4 -4
- package/dist/daemon/api/handlers/daemon.js +1 -1
- package/dist/daemon/crtrd.js +12 -12
- package/dist/daemon/import-dump-run.js +4 -4
- package/dist/daemon/machine-daemon.js +1 -1
- package/dist/daemon/machine-link/config.d.ts +0 -24
- package/dist/daemon/machine-link/config.js +4 -4
- package/dist/daemon/manage.d.ts +1 -1
- package/package.json +3 -3
- package/packages/crouter-api/dist/clients/attach/config.js +2 -1
- package/packages/crouter-api/dist/commands/api-client.js +1 -12
- package/packages/crouter-api/dist/commands/sys/import/move.js +5 -205
- package/packages/crouter-api/dist/commands/sys/import/start.js +15 -51
- package/packages/crouter-api/dist/commands/sys/signin.js +13 -54
- package/packages/crouter-api/dist/core/worktree-mutation-async.js +11 -3
- package/packages/crouter-api/dist/core/worktree-scripts.js +72 -0
- package/packages/crouter-api/dist/core/worktree-sweep.js +10 -1
- package/packages/crouter-api/dist/daemon/machine-link/config.js +1 -27
- 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/import/retry.d.ts +0 -1
- package/dist/commands/sys/import/retry.js +0 -1
- package/dist/daemon/machine-link/move-notify.d.ts +0 -4
- package/dist/daemon/machine-link/move-notify.js +0 -1
- package/packages/crouter-api/dist/commands/sys/import/retry.js +0 -38
- package/packages/crouter-api/dist/daemon/machine-link/move-notify.js +0 -15
|
@@ -3,14 +3,11 @@
|
|
|
3
3
|
// `runtime/secrets/machine-credential` (mode 0600). A Mac with no `machine.json` is a local control plane, not a machine.
|
|
4
4
|
// Also the move record `runtime/import/move.json` (0600): where a move to Northlight that `crtr sys signin` started stands, from before the drain until the
|
|
5
5
|
// computer has switched over (design-crtr-northlight-signin component 4).
|
|
6
|
-
import { chmodSync, existsSync, mkdirSync, readFileSync,
|
|
6
|
+
import { chmodSync, existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
7
7
|
import { randomBytes } from 'node:crypto';
|
|
8
8
|
import { dirname, join } from 'node:path';
|
|
9
9
|
import { runtimeRoot, secretsDir } from '../../core/layout.js';
|
|
10
10
|
import { joinedIssuer } from '../../core/directory/join.js';
|
|
11
|
-
import { CrtrError } from '../../core/errors.js';
|
|
12
|
-
import { atomicWriteJson } from '../../core/fs-utils.js';
|
|
13
|
-
import { ExitCode } from '../../types.js';
|
|
14
11
|
export const machineConfigPath = () => join(runtimeRoot(), 'machine.json');
|
|
15
12
|
export const machineCredentialPath = () => join(secretsDir(), 'machine-credential');
|
|
16
13
|
/** The machine config, or undefined when this install is not an imported machine. A present but malformed file throws. */
|
|
@@ -40,29 +37,6 @@ export function writeMachineCredential(secret) {
|
|
|
40
37
|
writeFileSync(path, `${secret}\n`, { mode: 0o600 });
|
|
41
38
|
chmodSync(path, 0o600);
|
|
42
39
|
}
|
|
43
|
-
export const moveRecordPath = () => join(runtimeRoot(), 'import', 'move.json');
|
|
44
|
-
/** The move record, or undefined when no move is running or unfinished. A present but malformed file throws. */
|
|
45
|
-
export function readMoveRecord() {
|
|
46
|
-
const path = moveRecordPath();
|
|
47
|
-
if (!existsSync(path))
|
|
48
|
-
return undefined;
|
|
49
|
-
const raw = JSON.parse(readFileSync(path, 'utf8'));
|
|
50
|
-
if (typeof raw.runId !== 'string' || typeof raw.apiUrl !== 'string' || typeof raw.directoryUrl !== 'string' || (raw.state !== 'running' && raw.state !== 'committed' && raw.state !== 'activated')
|
|
51
|
-
|| typeof raw.account?.id !== 'string' || typeof raw.account.display !== 'string')
|
|
52
|
-
throw new Error(`${path} is not a move record`);
|
|
53
|
-
return { runId: raw.runId, apiUrl: raw.apiUrl, directoryUrl: raw.directoryUrl, account: { id: raw.account.id, display: raw.account.display },
|
|
54
|
-
notify: typeof raw.notify === 'string' ? raw.notify : null, state: raw.state, notified: raw.notified === true, pid: typeof raw.pid === 'number' ? raw.pid : 0 };
|
|
55
|
-
}
|
|
56
|
-
export function writeMoveRecord(record) {
|
|
57
|
-
atomicWriteJson(moveRecordPath(), record, { mode: 0o600 });
|
|
58
|
-
}
|
|
59
|
-
export function deleteMoveRecord() {
|
|
60
|
-
rmSync(moveRecordPath(), { force: true });
|
|
61
|
-
}
|
|
62
|
-
/** Whether a move's records are in the Northlight account but this computer has not switched over (the record says `committed`). */
|
|
63
|
-
export const isMoveCommitted = () => readMoveRecord()?.state === 'committed';
|
|
64
|
-
/** The one `move_unfinished` error: every command, `crtr sys import resume` and a move whose switch-over failed answer it alike (exit code USAGE, as `not_signed_in`). */
|
|
65
|
-
export const moveUnfinishedError = (reason) => new CrtrError('move_unfinished', `crtr's records are already in your Northlight account, but this computer has not switched over${reason === undefined ? '.' : `: ${reason}`}`, ExitCode.USAGE, { next: 'Run `crtr sys signin` to finish.' });
|
|
66
40
|
/** This computer's install id, kept under `runtime/` so it exists before any daemon: the machine registration names it, and a reinstall that keeps `runtime/` registers the same machine again. */
|
|
67
41
|
export const installIdPath = () => join(runtimeRoot(), 'install-id');
|
|
68
42
|
export function readOrCreateInstallId() {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@north-light/api",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.762",
|
|
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.762",
|
|
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.762",
|
|
31
|
+
"@north-light/identity": "0.3.762"
|
|
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.762",
|
|
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.762",
|
|
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.762",
|
|
32
|
+
"@north-light/plugin": "0.3.762",
|
|
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.762",
|
|
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.762",
|
|
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.762",
|
|
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.762",
|
|
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.762",
|
|
11927
|
+
"@north-light/identity": "0.3.762"
|
|
11928
11928
|
}
|
|
11929
11929
|
},
|
|
11930
11930
|
"packages/crouter-sdk": {
|
|
11931
11931
|
"name": "@north-light/sdk",
|
|
11932
|
-
"version": "0.3.
|
|
11932
|
+
"version": "0.3.762",
|
|
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.762",
|
|
11936
|
+
"@north-light/identity": "0.3.762",
|
|
11937
|
+
"@north-light/plugin": "0.3.762",
|
|
11938
11938
|
"jose": "^6.2.1"
|
|
11939
11939
|
},
|
|
11940
11940
|
"bin": {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const retry: import("../../../core/command.js").LeafDef;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var a=Object.defineProperty;var r=(e,t)=>a(e,"name",{value:t,configurable:!0});import{defineLeaf as d}from"../../../core/command.js";import{usage as s}from"../../../core/errors.js";import{ImportCloud as u}from"../../../core/import/export/cloud.js";import{controlPlaneUrl as l,personBearer as p}from"../../../core/directory/person-credential.js";import{awaitRunOutcome as m,defaultDirectoryUrl as f}from"./move.js";const _=d({name:"retry",description:"load a failed import again from the bundle it already uploaded",whenToUse:"an import failed while Northlight was loading it (a refused or conflicting row) and the cause is fixed: no new upload and no new confirm code",help:{name:"sys import retry",summary:"re-queue a failed run so Northlight loads its kept upload again, then wait for the outcome",guide:"Works for a run that failed before its copy committed and whose upload is under 7 days old (Northlight deletes older ones; run the import again then). The bundle is what was uploaded, so rows this computer changed since are not in it. Prints the final state, or the new failure.",params:[{kind:"positional",name:"run_id",type:"string",required:!0,constraint:"The failed import run (`imp_\u2026`)."},{kind:"flag",name:"api-url",type:"string",required:!1,constraint:"Control plane base URL; default is the one the sign-in is for."}],output:[{name:"run_id",type:"string",required:!0,constraint:"The import run."},{name:"state",type:"string",required:!0,constraint:"Final state of the run, `done`."}],outputKind:"object",effects:["Moves the run from `failed` back to `loading` on the control plane; nothing local changes."]},run:r(async e=>{const t=String(e.run_id??"");if(t==="")throw s("name the failed run: crtr sys import retry <run_id>");const n=f(),i=e.apiUrl===void 0?await l(n):String(e.apiUrl),o=new u(i,()=>p(n));return await o.retry(t),await m(o,t,void 0),{run_id:t,state:"done"}},"run"),render:r(e=>`<import run="${e.run_id}" state="${e.state}"/>`,"render")});export{_ as retry};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { type MoveRecord } from './config.js';
|
|
2
|
-
/** Tell the node that asked for the move that it finished, through the control plane with the person's bearer (`POST /v1/nodes/:id/messages`): the node
|
|
3
|
-
* now lives in the account, so the message is stored there as mail and wakes it once the machine link is up. Then the record says `notified`. */
|
|
4
|
-
export declare function notifyMoveFinished(move: MoveRecord): Promise<MoveRecord>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var i=Object.defineProperty;var n=(t,r)=>i(t,"name",{value:r,configurable:!0});import{CrtrClient as o}from"../../api/index.js";import{northlightFetch as e}from"../../core/directory/person-credential.js";import{writeMoveRecord as c}from"./config.js";async function l(t){if(t.notified||t.notify===null)return t;await new o({baseUrl:t.apiUrl,fetch:e(t.directoryUrl,t.apiUrl)}).sendMessage(t.notify,{from:null,body:`The move to Northlight finished; crtr on this computer now runs with the account ${t.account.display}. Retry the command that needed the account and carry on.`});const r={...t,notified:!0};return c(r),r}n(l,"notifyMoveFinished");export{l as notifyMoveFinished};
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
// `crtr sys import retry <run_id>`: loads a failed import again from the bundle its failure kept.
|
|
2
|
-
import { defineLeaf } from '../../../core/command.js';
|
|
3
|
-
import { usage } from '../../../core/errors.js';
|
|
4
|
-
import { ImportCloud } from '../../../core/import/export/cloud.js';
|
|
5
|
-
import { controlPlaneUrl, personBearer } from '../../../core/directory/person-credential.js';
|
|
6
|
-
import { awaitRunOutcome, defaultDirectoryUrl } from './move.js';
|
|
7
|
-
export const retry = defineLeaf({
|
|
8
|
-
name: 'retry',
|
|
9
|
-
description: 'load a failed import again from the bundle it already uploaded',
|
|
10
|
-
whenToUse: 'an import failed while Northlight was loading it (a refused or conflicting row) and the cause is fixed: no new upload and no new confirm code',
|
|
11
|
-
help: {
|
|
12
|
-
name: 'sys import retry',
|
|
13
|
-
summary: 're-queue a failed run so Northlight loads its kept upload again, then wait for the outcome',
|
|
14
|
-
guide: 'Works for a run that failed before its copy committed and whose upload is under 7 days old (Northlight deletes older ones; run the import again then). The bundle is what was uploaded, so rows this computer changed since are not in it. Prints the final state, or the new failure.',
|
|
15
|
-
params: [
|
|
16
|
-
{ kind: 'positional', name: 'run_id', type: 'string', required: true, constraint: 'The failed import run (`imp_…`).' },
|
|
17
|
-
{ kind: 'flag', name: 'api-url', type: 'string', required: false, constraint: 'Control plane base URL; default is the one the sign-in is for.' },
|
|
18
|
-
],
|
|
19
|
-
output: [
|
|
20
|
-
{ name: 'run_id', type: 'string', required: true, constraint: 'The import run.' },
|
|
21
|
-
{ name: 'state', type: 'string', required: true, constraint: 'Final state of the run, `done`.' },
|
|
22
|
-
],
|
|
23
|
-
outputKind: 'object',
|
|
24
|
-
effects: ['Moves the run from `failed` back to `loading` on the control plane; nothing local changes.'],
|
|
25
|
-
},
|
|
26
|
-
run: async (input) => {
|
|
27
|
-
const runId = String(input['run_id'] ?? '');
|
|
28
|
-
if (runId === '')
|
|
29
|
-
throw usage('name the failed run: crtr sys import retry <run_id>');
|
|
30
|
-
const directoryUrl = defaultDirectoryUrl();
|
|
31
|
-
const apiUrl = input.apiUrl === undefined ? await controlPlaneUrl(directoryUrl) : String(input.apiUrl);
|
|
32
|
-
const cloud = new ImportCloud(apiUrl, () => personBearer(directoryUrl));
|
|
33
|
-
await cloud.retry(runId);
|
|
34
|
-
await awaitRunOutcome(cloud, runId, undefined);
|
|
35
|
-
return { run_id: runId, state: 'done' };
|
|
36
|
-
},
|
|
37
|
-
render: (r) => `<import run="${r['run_id']}" state="${r['state']}"/>`,
|
|
38
|
-
});
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
// src/daemon/machine-link/move-notify.ts — telling the node that asked for a move to Northlight that it finished (design-crtr-northlight-signin component 4).
|
|
2
|
-
import { CrtrClient } from '../../api/index.js';
|
|
3
|
-
import { northlightFetch } from '../../core/directory/person-credential.js';
|
|
4
|
-
import { writeMoveRecord } from './config.js';
|
|
5
|
-
/** Tell the node that asked for the move that it finished, through the control plane with the person's bearer (`POST /v1/nodes/:id/messages`): the node
|
|
6
|
-
* now lives in the account, so the message is stored there as mail and wakes it once the machine link is up. Then the record says `notified`. */
|
|
7
|
-
export async function notifyMoveFinished(move) {
|
|
8
|
-
if (move.notified || move.notify === null)
|
|
9
|
-
return move;
|
|
10
|
-
await new CrtrClient({ baseUrl: move.apiUrl, fetch: northlightFetch(move.directoryUrl, move.apiUrl) }).sendMessage(move.notify, { from: null,
|
|
11
|
-
body: `The move to Northlight finished; crtr on this computer now runs with the account ${move.account.display}. Retry the command that needed the account and carry on.` });
|
|
12
|
-
const notified = { ...move, notified: true };
|
|
13
|
-
writeMoveRecord(notified);
|
|
14
|
-
return notified;
|
|
15
|
-
}
|