@north-light/cli 0.3.741 → 0.3.743
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/clients/attach/viewer.js +295 -295
- package/dist/core/import/load/copy.d.ts +2 -0
- package/dist/core/import/load/copy.js +9 -9
- package/dist/core/import/load/prepare.d.ts +9 -1
- package/dist/core/import/load/prepare.js +11 -11
- package/dist/core/import/load/rollback.js +7 -6
- package/dist/core/import/load/run.js +2 -2
- package/dist/core/import/load/verify.js +8 -8
- package/dist/daemon/machine-daemon.js +1 -1
- package/dist/daemon/manage.d.ts +5 -5
- package/dist/daemon/manage.js +3 -3
- package/package.json +3 -3
- package/packages/crouter-api/dist/core/import/load/copy.js +18 -1
- package/packages/crouter-api/dist/core/import/load/prepare.js +16 -3
- package/packages/crouter-api/dist/daemon/manage.js +36 -25
- 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
|
@@ -61,6 +61,9 @@ export async function copyRows(input) {
|
|
|
61
61
|
await db.prepareUncached(`UPDATE ${S('review_comments')} c SET created_seq = m.target_key::bigint FROM import_key_map m
|
|
62
62
|
WHERE m.source_install_id = ? AND m.table_name = 'review_comment_events' AND m.source_key = c.created_seq::text`).run(source.installId);
|
|
63
63
|
const order = copyOrder(catalog);
|
|
64
|
+
// Rows the fill step creates have no staged row: kept in staging for verify, and appended to the manifest after the loop so rollback removes them.
|
|
65
|
+
await db.exec(`CREATE TABLE IF NOT EXISTS ${S('_filled')} (tbl text NOT NULL, k jsonb NOT NULL)`);
|
|
66
|
+
const filled = [];
|
|
64
67
|
for (const table of order) {
|
|
65
68
|
if (table in KEY_MAPPED_TABLES)
|
|
66
69
|
continue;
|
|
@@ -68,7 +71,7 @@ export async function copyRows(input) {
|
|
|
68
71
|
if (table === 'profiles') {
|
|
69
72
|
if (order.indexOf('identities') > order.indexOf('profiles'))
|
|
70
73
|
throw new ImportLaneError('copy', 'bundle_invalid', 'identities must be copied before profiles');
|
|
71
|
-
await fillEnvironments(db, schema, target, source, input.person);
|
|
74
|
+
filled.push(...await fillEnvironments(db, schema, target, source, input.person));
|
|
72
75
|
}
|
|
73
76
|
const info = catalog.tables.get(table);
|
|
74
77
|
const staged = Number((await db.prepareUncached(`SELECT count(*) AS n FROM ${S(table)}`).get()).n);
|
|
@@ -115,6 +118,10 @@ export async function copyRows(input) {
|
|
|
115
118
|
await manifest(table, inserted.map((row) => Object.values(row)));
|
|
116
119
|
result.mapped[table] = staged - inserted.length;
|
|
117
120
|
}
|
|
121
|
+
for (const f of filled)
|
|
122
|
+
await db.prepare(`INSERT INTO ${S('_filled')} VALUES (?, ?::jsonb)`).run(f.table, JSON.stringify(f.key));
|
|
123
|
+
for (const table of new Set(filled.map((f) => f.table)))
|
|
124
|
+
await appendManifest(db, runId, table, filled.filter((f) => f.table === table).map((f) => f.key));
|
|
118
125
|
// The rollup is recomputed from the copied charges for every (month, payer) the bundle held: an additive upsert would double on a rerun.
|
|
119
126
|
await db.prepareUncached(`DELETE FROM ${T('charge_totals')} t WHERE (t.month, t.payer) IN (SELECT DISTINCT month, payer FROM ${S('charges')})`).run();
|
|
120
127
|
await db.prepareUncached(`INSERT INTO ${T('charge_totals')} (month, payer, funding, sub, grantee, provider, usd, billed_usd)
|
|
@@ -130,3 +137,13 @@ export async function copyRows(input) {
|
|
|
130
137
|
await db.prepare("UPDATE import_runs SET state = 'committed', committed_at = ?, step = 'copy' WHERE run_id = ?").run(new Date().toISOString(), runId);
|
|
131
138
|
return result;
|
|
132
139
|
}
|
|
140
|
+
/** Adds keys to a table's manifest row, creating it when the copy inserted no row of that table. */
|
|
141
|
+
export async function appendManifest(tx, runId, table, keys) {
|
|
142
|
+
if (keys.length === 0)
|
|
143
|
+
return;
|
|
144
|
+
const existing = await tx.prepare('SELECT inserted_keys FROM import_manifest WHERE run_id = ? AND table_name = ?').get(runId, table);
|
|
145
|
+
if (existing === undefined)
|
|
146
|
+
await tx.prepare('INSERT INTO import_manifest (run_id, table_name, inserted_keys) VALUES (?, ?, ?)').run(runId, table, encodeKeys(keys));
|
|
147
|
+
else
|
|
148
|
+
await tx.prepare('UPDATE import_manifest SET inserted_keys = ? WHERE run_id = ? AND table_name = ?').run(encodeKeys([...decodeKeys(existing.inserted_keys), ...keys]), runId, table);
|
|
149
|
+
}
|
|
@@ -120,22 +120,35 @@ export async function dropExistingWatches(db, schema, target) {
|
|
|
120
120
|
const watches = await db.prepareUncached(`DELETE FROM ${sq(schema, 'watches')} s WHERE EXISTS (SELECT 1 ${same})`).run();
|
|
121
121
|
return { watches: Number(watches.changes), watch_subscriptions: Number(subs.changes) };
|
|
122
122
|
}
|
|
123
|
+
/** A staged idempotency key whose (grantee, key) the target already holds is already imported (a hosted person's runs the control plane has since served): it is dropped, the target's
|
|
124
|
+
* row stands, so the copy never inserts it and verify never compares it. Only this key is skipped; any other difference still fails. Returns the dropped rows. Runs before the pre-check. */
|
|
125
|
+
export async function dropExistingIdempotencyKeys(db, schema, target) {
|
|
126
|
+
const done = await db.prepareUncached(`DELETE FROM ${sq(schema, 'idempotency_keys')} s WHERE EXISTS (SELECT 1 FROM ${sq(target, 'idempotency_keys')} t WHERE t.grantee = s.grantee AND t.key = s.key)`).run();
|
|
127
|
+
return Number(done.changes);
|
|
128
|
+
}
|
|
123
129
|
/** Fill: a staged profile with no environment gets the source's machine environment (a Mac) or the person's Blaxel environment (hosted, created if
|
|
124
130
|
* absent). Runs in the copy transaction: it writes target objects. */
|
|
125
131
|
export async function fillEnvironments(tx, schema, target, source, person) {
|
|
126
132
|
const S = (t) => sq(schema, t);
|
|
127
|
-
|
|
133
|
+
const filled = [];
|
|
128
134
|
const profiles = await tx.prepareUncached(`SELECT id, grantee FROM ${S('profiles')} WHERE environment_id IS NULL ORDER BY id`).all();
|
|
129
135
|
for (const profile of profiles) {
|
|
130
136
|
let environment = source.kind === 'machine' ? source.environmentObject ?? null : null;
|
|
131
137
|
if (source.kind === 'hosted') {
|
|
132
138
|
const existing = await tx.prepareUncached(`SELECT environment_id FROM ${sq(target, 'profiles')} WHERE id = ?`).get(profile.id);
|
|
133
|
-
|
|
139
|
+
if (existing?.environment_id != null)
|
|
140
|
+
environment = existing.environment_id;
|
|
141
|
+
else {
|
|
142
|
+
environment = await createProfileBlaxelEnvironment(tx, { profileId: profile.id, grantee: profile.grantee ?? 'app:terminal', person });
|
|
143
|
+
filled.push({ table: 'objects', key: [environment] }, { table: 'environments', key: [environment] });
|
|
144
|
+
for (const r of await tx.prepareUncached('SELECT resource_type, resource_id, relation, subject_type, subject_id, subject_relation FROM relations WHERE resource_id = ?').all(environment)) {
|
|
145
|
+
filled.push({ table: 'relations', key: [r['resource_type'], r['resource_id'], r['relation'], r['subject_type'], r['subject_id'], r['subject_relation']] });
|
|
146
|
+
}
|
|
147
|
+
}
|
|
134
148
|
}
|
|
135
149
|
if (environment === null)
|
|
136
150
|
throw new ImportLaneError('fill', 'bundle_invalid', `profile ${profile.id} has no environment and the source names none`);
|
|
137
151
|
await tx.prepareUncached(`UPDATE ${S('profiles')} SET environment_id = ? WHERE id = ?`).run(environment, profile.id);
|
|
138
|
-
filled += 1;
|
|
139
152
|
}
|
|
140
153
|
return filled;
|
|
141
154
|
}
|
|
@@ -23,7 +23,7 @@ import { envNoDaemonAutostart } from '../shared/env.js';
|
|
|
23
23
|
import { waitForDaemonAvailability } from '../api/index.js';
|
|
24
24
|
import { localClient } from '../api/node-transport.js';
|
|
25
25
|
// Daemon env sanitization
|
|
26
|
-
/**
|
|
26
|
+
/** Non-`CRTR_*` env keys that must NEVER reach the daemon process. Restarting crtrd is
|
|
27
27
|
* overwhelmingly done from inside an agent node's own bash tool (`crtr sys
|
|
28
28
|
* daemon stop && start`), which inherits that node's FULL env — its identity
|
|
29
29
|
* (`CRTR_NODE_ID`/`CRTR_KIND`/…, the `nodeEnv()` shape in `core/runtime/
|
|
@@ -38,19 +38,6 @@ import { localClient } from '../api/node-transport.js';
|
|
|
38
38
|
* relaunch it ever attempts, for its whole lifetime — the 2026-07-06 diagnosis
|
|
39
39
|
* root cause behind 19 nodes killed with "failed to relaunch and is now dead". */
|
|
40
40
|
export const DAEMON_ENV_STRIP_KEYS = [
|
|
41
|
-
// Node identity (nodeEnv() shape) — meaningless for a process supervising
|
|
42
|
-
// many nodes rather than being one.
|
|
43
|
-
'CRTR_NODE_ID',
|
|
44
|
-
'CRTR_KIND',
|
|
45
|
-
'CRTR_MODE',
|
|
46
|
-
'CRTR_LIFECYCLE',
|
|
47
|
-
'CRTR_NODE_CWD',
|
|
48
|
-
'CRTR_CONTEXT_DIR',
|
|
49
|
-
'CRTR_CYCLES',
|
|
50
|
-
'CRTR_PROFILE_ID',
|
|
51
|
-
'CRTR_PARENT_NODE_ID',
|
|
52
|
-
// Recursion-guard flag — only meaningful inside a pi engine process.
|
|
53
|
-
'CRTR_FRONT_DOOR',
|
|
54
41
|
// Ambient tmux identity of whatever shell first autostarted the daemon. The
|
|
55
42
|
// daemon is a headless supervisor with no pane of its own, but `spawnNode`
|
|
56
43
|
// reads `currentTmux()` for a --root's foreground viewer placement; a stale
|
|
@@ -63,22 +50,46 @@ export const DAEMON_ENV_STRIP_KEYS = [
|
|
|
63
50
|
// unaffected — the tmux CLI reaches the server via its default socket.
|
|
64
51
|
'TMUX',
|
|
65
52
|
'TMUX_PANE',
|
|
66
|
-
// Engine-resolution seams NOT overridden per child launch — the proven and
|
|
67
|
-
// suspected poison vectors.
|
|
68
|
-
'CRTR_BROKER_ENGINE',
|
|
69
|
-
'CRTR_PI_BINARY',
|
|
70
53
|
// Generic Node.js env poisoning (a stray dev/debug flag from the restarting
|
|
71
54
|
// shell).
|
|
72
55
|
'NODE_OPTIONS',
|
|
73
56
|
];
|
|
74
|
-
/**
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
57
|
+
/** The `CRTR_*` names the daemon keeps: deployment and operator settings for the whole canvas. Every other `CRTR_*` name is
|
|
58
|
+
* dropped, because crtr sets the rest on one node, cron, job or broker (its identity, its relay socket, its tokens, its
|
|
59
|
+
* model), and a daemon started from that shell would otherwise act as that one execution. `CRTR_API_SOCKET` reaching the
|
|
60
|
+
* daemon made a Mac's self-update restart refuse with `no_local_daemon`. `CRTR_BROKER_ENGINE` and `CRTR_PI_BINARY` stay
|
|
61
|
+
* out on purpose: an inherited engine override broke every broker relaunch on 2026-07-06. A new operator setting the
|
|
62
|
+
* daemon must read is added here; a new per-execution name needs nothing. */
|
|
63
|
+
const DAEMON_CRTR_ENV_NAMES = new Set([
|
|
64
|
+
'CRTR_HOME', 'CRTR_RUNTIME_HOME', 'CRTR_PIDFILE', 'CRTR_RUNTIME', 'CRTR_INSTALL_ID',
|
|
65
|
+
'CRTR_LOG', 'CRTR_DEBUG', 'CRTR_DEBUG_PID_LIVENESS', 'CRTR_TIMING', 'CRTR_TIMING_PROC',
|
|
66
|
+
'CRTR_NO_DAEMON_AUTOSTART', 'CRTR_NO_AUTO_UPDATE', 'CRTR_NO_AUTO_INIT', 'CRTR_NO_EXPORTS', 'CRTR_LAYOUT_REFUSE',
|
|
67
|
+
'CRTR_POSTGRES_HOME', 'CRTR_DATABASE_URL', 'CRTR_DATABASE_SCHEMA', 'CRTR_DATABASE_POOL_MAX', 'CRTR_SCHEMA_DATABASE_URL',
|
|
68
|
+
'CRTR_DOCUMENT_PORT', 'CRTR_LAUNCHER_SOCKET', 'CRTR_API_ADDRESS', 'CRTR_DIRECTORY_URL', 'CRTR_PUBLIC_API_URL',
|
|
69
|
+
'CRTR_CANVAS_URL', 'CRTR_CANVAS_CLIENT_ID', 'CRTR_CANVAS_JWK_FILE', 'CRTR_SECRETS_KEY', 'CRTR_IMPORT_SERVICE_TOKEN',
|
|
70
|
+
'CRTR_PACKAGES_TOKEN', 'CRTR_FEEDBACK_ENDPOINT', 'CRTR_FEEDBACK_TOKEN', 'CRTR_SUPPORT_REPO',
|
|
71
|
+
'CRTR_BRANDED_HOST', 'CRTR_CODESIGN_IDENTITY', 'CRTR_PLUGIN_REVALIDATE_TTL_MS', 'CRTR_IMPORT_BLOB_WORKERS',
|
|
72
|
+
'CRTR_MAX_LIVE_BROKERS', 'CRTR_WARN_LIVE_BROKERS', 'CRTR_BROKER_RSS_CAP_MB', 'CRTR_UNATTENDED_PARK_MS', 'CRTR_WARM_POOL',
|
|
73
|
+
'CRTR_STREAM_WATCHDOG_MS', 'CRTR_CONVERSATION_COMMIT_DEADLINE_MS', 'CRTR_NAME_MODEL', 'CRTR_MODEL_PROVIDER',
|
|
74
|
+
'CRTR_BROKER_SIGNAL_LONG_PROOF',
|
|
75
|
+
]);
|
|
76
|
+
/** Operator setting families the daemon keeps whole. `CRTR_TEST_` and `CRTR_FAULT_` are test-lane settings a lane exports for the daemon it starts. */
|
|
77
|
+
const DAEMON_CRTR_ENV_PREFIXES = ['CRTR_DB_', 'CRTR_BOOT_', 'CRTR_R2_', 'CRTR_LEDGER_', 'CRTR_BASH_', 'CRTR_WATCHER_', 'CRTR_RECAP_', 'CRTR_MODEL_AUTH_', 'CRTR_TEST_', 'CRTR_FAULT_'];
|
|
78
|
+
/** Whether a daemon process inherits this env name. */
|
|
79
|
+
export function daemonKeepsEnv(key) {
|
|
80
|
+
if (DAEMON_ENV_STRIP_KEYS.includes(key))
|
|
81
|
+
return false;
|
|
82
|
+
if (!key.startsWith('CRTR_'))
|
|
83
|
+
return true;
|
|
84
|
+
return DAEMON_CRTR_ENV_NAMES.has(key) || DAEMON_CRTR_ENV_PREFIXES.some((prefix) => key.startsWith(prefix));
|
|
85
|
+
}
|
|
86
|
+
/** A copy of `process.env` for a daemon process: the ordinary host env and the operator `CRTR_*` settings pass; every
|
|
87
|
+
* per-execution `CRTR_*` name and every `DAEMON_ENV_STRIP_KEYS` entry is dropped. */
|
|
78
88
|
export function sanitizedDaemonEnv() {
|
|
79
|
-
const env = {
|
|
80
|
-
for (const key of
|
|
81
|
-
|
|
89
|
+
const env = {};
|
|
90
|
+
for (const [key, value] of Object.entries(process.env))
|
|
91
|
+
if (daemonKeepsEnv(key))
|
|
92
|
+
env[key] = value;
|
|
82
93
|
return env;
|
|
83
94
|
}
|
|
84
95
|
// Entry point resolution
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@north-light/api",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.743",
|
|
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.743",
|
|
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.743",
|
|
31
|
+
"@north-light/identity": "0.3.743"
|
|
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.743",
|
|
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.743",
|
|
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.743",
|
|
32
|
+
"@north-light/plugin": "0.3.743",
|
|
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.743",
|
|
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.743",
|
|
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.743",
|
|
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.743",
|
|
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.743",
|
|
11927
|
+
"@north-light/identity": "0.3.743"
|
|
11928
11928
|
}
|
|
11929
11929
|
},
|
|
11930
11930
|
"packages/crouter-sdk": {
|
|
11931
11931
|
"name": "@north-light/sdk",
|
|
11932
|
-
"version": "0.3.
|
|
11932
|
+
"version": "0.3.743",
|
|
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.743",
|
|
11936
|
+
"@north-light/identity": "0.3.743",
|
|
11937
|
+
"@north-light/plugin": "0.3.743",
|
|
11938
11938
|
"jose": "^6.2.1"
|
|
11939
11939
|
},
|
|
11940
11940
|
"bin": {
|