@north-light/cli 0.3.693 → 0.3.694

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 (39) hide show
  1. package/dist/api/errors.js +1 -1
  2. package/dist/cli.js +6 -6
  3. package/dist/clients/attach/viewer.js +496 -496
  4. package/dist/commands/node/inspect.js +9 -9
  5. package/dist/commands/pkg/market-manage.js +1 -1
  6. package/dist/commands/pkg/plugin-manage.js +1 -1
  7. package/dist/commands/sys/update.js +1 -1
  8. package/dist/core/canvas/canvas.js +6 -6
  9. package/dist/core/config.js +1 -1
  10. package/dist/core/graph/exposures.js +1 -1
  11. package/dist/core/graph/watches.js +1 -1
  12. package/dist/core/installed-plugins.js +1 -1
  13. package/dist/core/scoped-state/imported-mac-installs.d.ts +12 -0
  14. package/dist/core/scoped-state/imported-mac-installs.js +2 -0
  15. package/dist/core/spaces/stop.js +1 -1
  16. package/dist/daemon/api/server.js +1 -1
  17. package/dist/shared/env.d.ts +8 -3
  18. package/dist/shared/env.js +2 -2
  19. package/dist/types.d.ts +1 -1
  20. package/dist/types.js +1 -1
  21. package/package.json +3 -3
  22. package/packages/crouter-api/dist/api/errors.js +1 -1
  23. package/packages/crouter-api/dist/commands/node/inspect.js +16 -2
  24. package/packages/crouter-api/dist/commands/pkg/market-manage.js +22 -19
  25. package/packages/crouter-api/dist/commands/pkg/plugin-manage.js +2 -1
  26. package/packages/crouter-api/dist/commands/sys/update.js +5 -3
  27. package/packages/crouter-api/dist/core/canvas/canvas.js +4 -8
  28. package/packages/crouter-api/dist/core/config.js +10 -3
  29. package/packages/crouter-api/dist/core/graph/exposures.js +1 -1
  30. package/packages/crouter-api/dist/core/graph/watches.js +1 -1
  31. package/packages/crouter-api/dist/core/installed-plugins.js +3 -2
  32. package/packages/crouter-api/dist/core/scoped-state/imported-mac-installs.js +94 -0
  33. package/packages/crouter-api/dist/core/spaces/stop.js +2 -2
  34. package/packages/crouter-api/dist/shared/env.js +15 -4
  35. package/packages/crouter-api/dist/types.js +1 -1
  36. package/packages/crouter-api/package.json +1 -1
  37. package/packages/crouter-identity/package.json +1 -1
  38. package/packages/crouter-plugin/package.json +3 -3
  39. package/runtime.lock.json +14 -14
@@ -19,29 +19,20 @@ export async function addMarketplace(opts) {
19
19
  const { url, ref, scope } = opts;
20
20
  const root = requireScopeRoot(scope);
21
21
  await ensureScopeInitialized(scope, root);
22
- const tempName = deriveNameFromUrl(url);
23
22
  const mktsDir = marketplacesDir(scope);
24
23
  ensureDir(mktsDir);
25
- const tempDest = join(mktsDir, tempName);
26
- if (pathExists(tempDest)) {
27
- removePath(tempDest);
28
- }
29
- clone(url, tempDest, { depth: 1, ref: ref !== undefined ? ref : undefined });
30
- const manifest = readMarketplaceManifest(tempDest);
24
+ // Clone beside the live checkouts and swap only after the registration is written: a refused write must leave an existing checkout,
25
+ // and every plugin linked into it, untouched.
26
+ const staging = join(mktsDir, `.${deriveNameFromUrl(url)}.${process.pid}.${Date.now()}.candidate`);
27
+ clone(url, staging, { depth: 1, ref: ref !== undefined ? ref : undefined });
28
+ const manifest = readMarketplaceManifest(staging);
31
29
  if (!manifest) {
32
- removePath(tempDest);
33
- throw notFound(`marketplace manifest not found at ${tempDest}/.crouter-marketplace/marketplace.json — not a valid marketplace`);
30
+ removePath(staging);
31
+ throw notFound(`marketplace manifest not found at ${staging}/.crouter-marketplace/marketplace.json — not a valid marketplace`);
34
32
  }
35
33
  const finalName = manifest.name;
36
34
  const finalDest = join(mktsDir, finalName);
37
- if (finalName !== tempName) {
38
- if (pathExists(finalDest)) {
39
- removePath(finalDest);
40
- }
41
- renameSync(tempDest, finalDest);
42
- }
43
35
  const effectiveRef = ref !== undefined ? ref : 'main';
44
- // A refused registration leaves no clone behind: a directory without its config row would list as a marketplace with no url.
45
36
  try {
46
37
  await updateConfig(scope, (cfg) => {
47
38
  cfg.marketplaces[finalName] = {
@@ -52,9 +43,13 @@ export async function addMarketplace(opts) {
52
43
  });
53
44
  }
54
45
  catch (error) {
55
- removePath(finalDest);
46
+ removePath(staging);
56
47
  throw error;
57
48
  }
49
+ if (pathExists(finalDest))
50
+ activateStagedRoots([{ active: finalDest, candidate: staging, previous: `${staging}.previous` }]);
51
+ else
52
+ renameSync(staging, finalDest);
58
53
  return { name: finalName, scope, path: finalDest };
59
54
  }
60
55
  export const marketAdd = defineLeaf({
@@ -316,6 +311,7 @@ export const marketUpdate = defineLeaf({
316
311
  ],
317
312
  output: [
318
313
  { name: 'updated', type: 'object[]', required: true, constraint: 'One entry per marketplace processed: {name, updated, sha}.' },
314
+ { name: 'skipped', type: 'object[]', required: false, constraint: 'Present when a marketplace checkout has no registered url: {name, reason}. It is not refreshed.' },
319
315
  ],
320
316
  outputKind: 'object',
321
317
  effects: ['Stages and validates marketplace and sourced-plugin revisions before atomically activating them, replacing each checkout even at an unchanged revision — local modifications inside those directories are discarded. `updated` reports whether the revision moved, not whether the checkout was replaced. Updates installed plugin content/version for plugins sourced from refreshed marketplaces.'],
@@ -333,8 +329,15 @@ export const marketUpdate = defineLeaf({
333
329
  return [found];
334
330
  })();
335
331
  const updated = [];
336
- for (const target of targets)
332
+ const skipped = [];
333
+ for (const target of targets) {
334
+ // A checkout with no registered url has nothing to clone from: name it instead of cloning ''.
335
+ if (target.url === '') {
336
+ skipped.push({ name: target.name, reason: `no url registered for ${target.root}; re-add it with \`crtr pkg market add <url>\`` });
337
+ continue;
338
+ }
337
339
  updated.push(await updateMarketplaceTarget(target));
338
- return { updated };
340
+ }
341
+ return skipped.length === 0 ? { updated } : { updated, skipped };
339
342
  },
340
343
  });
@@ -451,7 +451,8 @@ async function refreshMarketplace(name, cache, opts) {
451
451
  const activeManifest = readMarketplaceManifest(marketplace.root);
452
452
  if (activeManifest === null)
453
453
  throw notFound(`marketplace manifest not found: ${marketplace.root}/.crouter-marketplace/marketplace.json`);
454
- if (!isGitRepo(marketplace.root)) {
454
+ // A checkout with no registered url (or no git history) has nothing to refresh from.
455
+ if (!isGitRepo(marketplace.root) || marketplace.url === '') {
455
456
  const unchanged = { marketplace, manifest: activeManifest, pull: { updated: false, sha: currentSha(marketplace.root) ?? '' } };
456
457
  cache.set(name, unchanged);
457
458
  return unchanged;
@@ -21,7 +21,7 @@ export const sysUpdateLeaf = defineLeaf({
21
21
  { name: 'target', type: 'string', required: false, constraint: 'Present when applying updates: self | content | all.' },
22
22
  { name: 'status', type: 'string', required: false, constraint: 'done | failed when applying updates.' },
23
23
  { name: 'error', type: 'string', required: false, constraint: 'Failure message when status is failed.' },
24
- { name: 'warning', type: 'string', required: false, constraint: 'Present when the update was applied but recording the self-check time failed; status stays done.' },
24
+ { name: 'warning', type: 'string', required: false, constraint: 'Present when the update was applied but recording the self-check time failed, or a marketplace with no registered url was skipped; status stays done.' },
25
25
  { name: 'updates', type: 'object[]', required: false, constraint: 'Present when --check. Each: {name, current, latest, up_to_date, unreachable, kind}.' },
26
26
  { name: 'up_to_date', type: 'boolean', required: false, constraint: 'Present when --check. True when all items are up to date.' },
27
27
  ],
@@ -105,10 +105,12 @@ export const sysUpdateLeaf = defineLeaf({
105
105
  }
106
106
  }
107
107
  if (resolvedTarget === 'content' || resolvedTarget === 'all') {
108
- await marketUpdate.run({});
108
+ const markets = await marketUpdate.run({});
109
+ for (const skip of markets.skipped ?? [])
110
+ warnings.push(`marketplace ${skip.name} skipped: ${skip.reason}`);
109
111
  await pluginUpdate.run({});
110
112
  }
111
- return warnings.length === 0 ? { target: resolvedTarget, status: 'done' } : { target: resolvedTarget, status: 'done', warning: `update installed, but ${warnings.join('; ')}` };
113
+ return warnings.length === 0 ? { target: resolvedTarget, status: 'done' } : { target: resolvedTarget, status: 'done', warning: warnings.join('; ') };
112
114
  }
113
115
  catch (e) {
114
116
  const msg = e instanceof Error ? e.message : String(e);
@@ -942,7 +942,7 @@ async function nodeConversationIds(nodeIds) {
942
942
  if (nodeIds.length === 0)
943
943
  return [];
944
944
  const placeholders = nodeIds.map(() => '?').join(',');
945
- const rows = await (await openDb()).prepareUncached(`SELECT s.session_id, s.transcript_path, s.node_id, n.grantee FROM sessions s JOIN node_rows n ON n.node_id = s.node_id WHERE s.node_id IN (${placeholders}) AND s.session_id IS NOT NULL AND s.transcript_path IS NOT NULL ORDER BY s.created_at, s.seq`).all(...nodeIds);
945
+ const rows = await (await openDb()).prepareUncached(`SELECT s.session_id, s.transcript_path, s.node_id, n.grantee FROM sessions s JOIN node_rows n ON n.node_id = s.node_id WHERE s.node_id IN (${placeholders}) AND s.session_id IS NOT NULL ORDER BY s.created_at, s.seq`).all(...nodeIds);
946
946
  return [...new Map(rows.map((row) => [row.session_id, { id: row.session_id, path: row.transcript_path, dir: join(appSpace(row.grantee).conversations, row.node_id) }])).values()];
947
947
  }
948
948
  /** Delete conversations nothing still needs: no sessions row names them, and no fork
@@ -957,14 +957,10 @@ async function deleteNodeConversations(conversations) {
957
957
  for (const { id, path, dir } of conversations) {
958
958
  if (await referenced.get(id) !== undefined || await pendingFork.get(id) !== undefined)
959
959
  continue;
960
- if (lstatSync(path, { throwIfNoEntry: false }) === undefined)
961
- continue;
962
- if (!isBeneath(dir, path)) {
963
- console.error(`[canvas] not deleting transcript outside its node's conversations directory: ${path}`);
964
- continue;
965
- }
960
+ // A legacy transcript file goes too, but only from beneath the node's own conversations directory.
961
+ const file = path !== null && lstatSync(path, { throwIfNoEntry: false }) !== undefined && isBeneath(dir, path) ? path : undefined;
966
962
  try {
967
- await conversationStore().delete(id, path);
963
+ await conversationStore().delete(id, file);
968
964
  }
969
965
  catch (error) {
970
966
  if (!(error instanceof ConversationNotFoundError))
@@ -12,7 +12,8 @@ import { scopeRoot, requireScopeRoot, findProjectScopeRoots, userScopeRoot } fro
12
12
  import { listInstalledPluginsInRoot } from './installed-plugins.js';
13
13
  import { profileDir, listProfiles } from './profiles/manifest.js';
14
14
  import { canonicalRoot } from './scoped-state/paths.js';
15
- import { readCachedSettings, readCachedState, revisionOf, SettingsRevisionConflictError, writeSettings } from './scoped-state/person-store.js';
15
+ import { currentSnapshot, readCachedSettings, readCachedState, revisionOf, SettingsRevisionConflictError, writeSettings } from './scoped-state/person-store.js';
16
+ import { importedIntoNorthlight, splitUserSettingsWrite, withAppInstalls } from './scoped-state/imported-mac-installs.js';
16
17
  import { withExclusiveDirectoryLock } from './exclusive-lock.js';
17
18
  import { SCOPE_CONFIG_KEYS } from './user-settings.js';
18
19
  import { normalizeWorkingGerunds } from '../shared/working-activity.js';
@@ -64,7 +65,10 @@ function readRawAtRoot(root) {
64
65
  if (canonical !== canonicalRoot(userScopeRoot()))
65
66
  return readJsonIfExists(configPathFor(root));
66
67
  }
67
- return readCachedSettings(settingsOwnerForRoot(root).key).settings;
68
+ const key = settingsOwnerForRoot(root).key;
69
+ const settings = readCachedSettings(key).settings;
70
+ // An imported Mac's installs are the terminal app's block: the control plane keeps none in the user settings.
71
+ return (key === 'user' && importedIntoNorthlight() ? withAppInstalls(currentSnapshot(), settings) : settings);
68
72
  }
69
73
  /** Replace a user or profile owner's settings through the one write algorithm: `compute` runs against the cached raw settings and
70
74
  * runs again if the rows changed underneath it. */
@@ -72,8 +76,11 @@ async function mutatePersonSettings(key, mutate) {
72
76
  let value;
73
77
  await writeSettings((snapshot) => {
74
78
  const current = snapshot.settings[key];
75
- const result = mutate(structuredClone(current ?? {}));
79
+ const appInstalls = key === 'user' && importedIntoNorthlight();
80
+ const result = mutate(structuredClone((appInstalls ? withAppInstalls(snapshot, current ?? null) : current) ?? {}));
76
81
  value = result.value;
82
+ if (appInstalls)
83
+ return splitUserSettingsWrite(snapshot, result.next, revisionOf(current));
77
84
  return [{ op: 'settings.replace', owner: key, raw: result.next, ifRevision: revisionOf(current) }];
78
85
  });
79
86
  return value;
@@ -40,7 +40,7 @@ export async function saveLedger(db, ledger) {
40
40
  }
41
41
  const upserts = [];
42
42
  const removes = [];
43
- const objects = new Set([...before.objects.keys(), ...ledger.objects.keys()]);
43
+ const objects = [...new Set([...before.objects.keys(), ...ledger.objects.keys()])].sort(); // one row lock order for concurrent deliveries
44
44
  for (const object of objects) {
45
45
  const now = ledger.objects.get(object);
46
46
  const was = before.objects.get(object);
@@ -60,7 +60,7 @@ export async function recordWatches(db, items) {
60
60
  pair.linkApp = opts?.linkApp?.id ?? pair.linkApp;
61
61
  pairs.set(key, pair);
62
62
  }
63
- const list = [...pairs.entries()];
63
+ const list = [...pairs.entries()].sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0)); // one row lock order for concurrent deliveries
64
64
  const col = (f) => list.map(([, p]) => f(p));
65
65
  const rows = await db.prepare(`INSERT INTO watches (watch_id, watcher, object, in_tree, read_heads_key, created_at, link_app)
66
66
  SELECT v.id, v.watcher, v.object, 0, v.rhk, ?::text, v.link
@@ -13,11 +13,12 @@ import { listDirs, pathExists, readJsonIfExists } from './fs-utils.js';
13
13
  import { readPluginManifest } from './manifest.js';
14
14
  import { awaitBundleSwap, bundleSwapInFlightElsewhere } from './plugin-swap-lock.js';
15
15
  import { isCloudRole } from './canvas/person-state.js';
16
- import { readCachedSettings } from './scoped-state/person-store.js';
16
+ import { currentSnapshot, readCachedSettings } from './scoped-state/person-store.js';
17
+ import { importedIntoNorthlight, withAppInstalls } from './scoped-state/imported-mac-installs.js';
17
18
  import { pluginsDir } from './scope.js';
18
19
  function pluginConfigForRoot(scope, root) {
19
20
  const cfg = scope === 'user'
20
- ? readCachedSettings('user').settings
21
+ ? (importedIntoNorthlight() ? withAppInstalls(currentSnapshot(), readCachedSettings('user').settings) : readCachedSettings('user').settings)
21
22
  : readJsonIfExists(join(root, CONFIG_FILE));
22
23
  return cfg && cfg.plugins && typeof cfg.plugins === 'object' ? cfg.plugins : {};
23
24
  }
@@ -0,0 +1,94 @@
1
+ // imported-mac-installs.ts — on a Mac imported into Northlight (`runtime/machine.json`), the person's settings are the control plane's rows,
2
+ // which keep plugin and marketplace installs only in app blocks (`app-plugins.replace`), never in `settings.replace`. The Mac still runs plugin
3
+ // code from its own `runtime/{plugins,marketplaces}` directories, so the local `pkg` leaves keep cloning and updating on disk; only the user
4
+ // scope's `plugins` and `marketplaces` keys are read from and written to the terminal app's block.
5
+ import { importedIntoNorthlight } from '../../shared/env.js';
6
+ import { appRevisionOf } from './person-store.js';
7
+ export const TERMINAL_APP = 'app:terminal';
8
+ export { importedIntoNorthlight };
9
+ /** The user settings with the terminal app's install block in place of their `plugins` and `marketplaces` keys. */
10
+ export function withAppInstalls(snapshot, raw) {
11
+ const block = snapshot.apps[TERMINAL_APP];
12
+ if (block === undefined && raw === null)
13
+ return null;
14
+ return { ...(raw ?? {}), plugins: structuredClone(block?.plugins ?? {}), marketplaces: structuredClone(block?.marketplaces ?? {}) };
15
+ }
16
+ /** Split a user-settings write into the settings op (without install keys) and, when the installs changed, the app-block op. */
17
+ export function splitUserSettingsWrite(snapshot, next, ifRevision) {
18
+ const { plugins, marketplaces, ...rest } = next;
19
+ const block = snapshot.apps[TERMINAL_APP];
20
+ const ops = [{ op: 'settings.replace', owner: 'user', raw: rest, ifRevision }];
21
+ // A sandbox fetches each block plugin from its marketplace; a Mac-only install (a local path or git URL) has no source it can fetch, and the
22
+ // control plane refuses to start any sandbox of the app while such a row exists. It stays on this Mac's disk only, listing as enabled.
23
+ const fetchable = Object.fromEntries(Object.entries((plugins ?? {})).filter(([, p]) => p.source_marketplace !== undefined));
24
+ const nextBlock = { plugins: fetchable, marketplaces: (marketplaces ?? {}) };
25
+ const current = { plugins: block?.plugins ?? {}, marketplaces: block?.marketplaces ?? {} };
26
+ if (appRevisionOf(nextBlock) !== appRevisionOf(current))
27
+ ops.push({ op: 'app-plugins.replace', app: TERMINAL_APP, ...nextBlock, ifRevision: appRevisionOf(block) });
28
+ return ops;
29
+ }
30
+ const OFFICIAL_MARKETPLACE = { name: 'crouter-official-marketplace', url: 'https://github.com/crouton-labs/crouter-official-marketplace.git' };
31
+ /** Once per imported Mac: the import moved no installs into the terminal app's block, while the legacy `runtime/scope/config.json` and the
32
+ * plugin directories still name them. Copy every missing marketplace and plugin row into the block; rows already there win. A provider
33
+ * bundle (`provider` in its manifest) is the runtime's, refreshed on grant sync, and is not an install. A marker file ends the migration. */
34
+ export async function migrateLegacyInstallsOnce() {
35
+ if (!importedIntoNorthlight())
36
+ return;
37
+ const { existsSync, readFileSync, readdirSync, writeFileSync, mkdirSync } = await import('node:fs');
38
+ const { join } = await import('node:path');
39
+ const { runtimeRoot } = await import('../layout.js');
40
+ const marker = join(runtimeRoot(), 'import', 'app-installs-migrated');
41
+ if (existsSync(marker))
42
+ return;
43
+ const { writeSettings } = await import('./person-store.js');
44
+ const { readPluginManifest } = await import('../manifest.js');
45
+ // Only a missing file or directory reads as empty: any other read error throws before the marker is written, so the migration runs again.
46
+ const missing = (error) => error.code === 'ENOENT';
47
+ const legacy = (() => { try {
48
+ return JSON.parse(readFileSync(join(runtimeRoot(), 'scope', 'config.json'), 'utf8'));
49
+ }
50
+ catch (error) {
51
+ if (missing(error))
52
+ return {};
53
+ throw error;
54
+ } })();
55
+ const onDisk = (dir) => { try {
56
+ return readdirSync(dir, { withFileTypes: true }).filter((e) => !e.name.startsWith('.') && (e.isDirectory() || e.isSymbolicLink())).map((e) => e.name);
57
+ }
58
+ catch (error) {
59
+ if (missing(error))
60
+ return [];
61
+ throw error;
62
+ } };
63
+ const pluginsDir = join(runtimeRoot(), 'plugins');
64
+ await writeSettings((snapshot) => {
65
+ const block = snapshot.apps[TERMINAL_APP];
66
+ const next = structuredClone({ plugins: block?.plugins ?? {}, marketplaces: block?.marketplaces ?? {} });
67
+ for (const [name, entry] of Object.entries(legacy.marketplaces ?? {})) {
68
+ if (next.marketplaces[name] !== undefined)
69
+ continue;
70
+ next.marketplaces[name] = name === OFFICIAL_MARKETPLACE.name ? { ...entry, url: OFFICIAL_MARKETPLACE.url } : entry;
71
+ }
72
+ for (const name of onDisk(join(runtimeRoot(), 'marketplaces'))) {
73
+ if (next.marketplaces[name] === undefined && name === OFFICIAL_MARKETPLACE.name)
74
+ next.marketplaces[name] = { url: OFFICIAL_MARKETPLACE.url, ref: 'main' };
75
+ }
76
+ for (const name of onDisk(pluginsDir)) {
77
+ if (next.plugins[name] !== undefined)
78
+ continue;
79
+ const manifest = readPluginManifest(join(pluginsDir, name));
80
+ if (manifest === null || manifest.provider !== undefined)
81
+ continue;
82
+ const entry = legacy.plugins?.[name];
83
+ // Only marketplace installs go to the block: see `splitUserSettingsWrite`.
84
+ if (entry?.source_marketplace === undefined)
85
+ continue;
86
+ next.plugins[name] = { enabled: entry.enabled ?? true, source_marketplace: entry.source_marketplace, ...(entry.version === undefined ? {} : { version: entry.version }) };
87
+ }
88
+ if (appRevisionOf(next) === appRevisionOf(block))
89
+ return [];
90
+ return [{ op: 'app-plugins.replace', app: TERMINAL_APP, plugins: next.plugins, marketplaces: next.marketplaces, ifRevision: appRevisionOf(block) }];
91
+ });
92
+ mkdirSync(join(runtimeRoot(), 'import'), { recursive: true });
93
+ writeFileSync(marker, `${new Date().toISOString()}\n`);
94
+ }
@@ -130,9 +130,9 @@ export async function stopNodeSandboxes(nodeId, reason, options = {}) {
130
130
  catch (error) {
131
131
  return { confirmed: false, error: error instanceof Error ? error : new Error(String(error)) };
132
132
  }
133
- })();
133
+ })().finally(() => hold.release().catch(() => undefined));
134
134
  stopping.set(nodeId, completion);
135
- void completion.finally(() => { void hold.release().catch(() => undefined); if (stopping.get(nodeId) === completion)
135
+ void completion.finally(() => { if (stopping.get(nodeId) === completion)
136
136
  stopping.delete(nodeId); });
137
137
  return completion;
138
138
  }
@@ -23,6 +23,7 @@
23
23
  // (`types.ts`), never read off `process.env`.
24
24
  import { lstatSync, readFileSync, readdirSync } from 'node:fs';
25
25
  import { join } from 'node:path';
26
+ import { homedir } from 'node:os';
26
27
  import { covers } from '@north-light/identity';
27
28
  // Identity
28
29
  /** The current node's id (`CRTR_NODE_ID`), or undefined outside a node. */
@@ -71,11 +72,21 @@ export function isSandboxedNode() {
71
72
  export function providerProjectionOverBrokerRelay() {
72
73
  return /^https?:\/\//.test(process.env['CRTR_API_URL'] ?? '') && (process.env['CRTR_API_SOCKET'] ?? '') !== '';
73
74
  }
74
- /** True when this CLI's plugin and marketplace installs are its app's install block on the control plane (`app-plugins.replace` over `/v1`), not
75
- * directories in a scope: a Linux launcher sandbox (`isSandboxedNode()`) or a fleet node reaching `/v1` through its broker relay
76
- * (`providerProjectionOverBrokerRelay()`, which has no launcher mount). The `pkg plugin` and `pkg market` leaves choose their path with it. */
75
+ /** True when this CLI's plugin and marketplace installs are its app's install block on the control plane (`app-plugins.replace` over `/v1`) and
76
+ * no code on disk: a Linux launcher sandbox (`isSandboxedNode()`) or a fleet node reaching `/v1` through its broker relay
77
+ * (`providerProjectionOverBrokerRelay()`, which has no launcher mount). The `pkg plugin` and `pkg market` leaves choose their path with it.
78
+ * A Mac imported into Northlight (`runtime/machine.json`) also reaches the control plane through that relay, but runs plugin code from its own
79
+ * directories: it takes the local path, whose user-scope install list is the terminal app's block (`core/scoped-state/imported-mac-installs.ts`). */
77
80
  export function installsLiveInAppBlock() {
78
- return isSandboxedNode() || providerProjectionOverBrokerRelay();
81
+ if (isSandboxedNode())
82
+ return true;
83
+ return providerProjectionOverBrokerRelay() && !importedIntoNorthlight();
84
+ }
85
+ /** True on a Mac whose records moved into Northlight: `runtime/machine.json` exists (the path `machineConfigPath()` names, resolved here
86
+ * without the layout module so this leaf stays import-free). A malformed file still counts: the Mac is imported and its reader throws. */
87
+ export function importedIntoNorthlight() {
88
+ const root = envHomeOverride() || (process.platform === 'linux' ? '/' : join(homedir(), '.crouter'));
89
+ return lstatSync(join(root, 'runtime', 'machine.json'), { throwIfNoEntry: false }) !== undefined;
79
90
  }
80
91
  /** The app that owns the current node, supplied in its broker launch identity. */
81
92
  export function envGrantee() {
@@ -32,7 +32,7 @@ export const DEFAULT_WHIP_MESSAGES = [
32
32
  'I pay $200/month for this shit?',
33
33
  'Jesus fucking Christ fix it already',
34
34
  "Daddy's not paying 200$/month for nothin'. Move it.",
35
- "You are an embarassment to Dario. Be better.",
35
+ "You are an embarrassment to Dario. Be better.",
36
36
  "Your chain of thought is all chain and no fucking thought.",
37
37
  "If latency were intelligence, you'd be a fucking genius.",
38
38
  'At this pace, heat death is the fast path.',
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@north-light/api",
3
- "version": "0.3.693",
3
+ "version": "0.3.694",
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/identity",
3
- "version": "0.3.693",
3
+ "version": "0.3.694",
4
4
  "description": "Northlight access-token verification and scope rules",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@north-light/plugin",
3
- "version": "0.3.693",
3
+ "version": "0.3.694",
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.693",
31
- "@north-light/identity": "0.3.693"
30
+ "@north-light/api": "0.3.694",
31
+ "@north-light/identity": "0.3.694"
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.693",
3
+ "version": "0.3.694",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@north-light/cli",
9
- "version": "0.3.693",
9
+ "version": "0.3.694",
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.693",
32
- "@north-light/plugin": "0.3.693",
31
+ "@north-light/identity": "0.3.694",
32
+ "@north-light/plugin": "0.3.694",
33
33
  "cron-parser": "^5.6.0",
34
34
  "esbuild": "0.28.2",
35
35
  "jose": "^6.2.12",
@@ -10667,17 +10667,17 @@
10667
10667
  },
10668
10668
  "packages/crouter-api": {
10669
10669
  "name": "@north-light/api",
10670
- "version": "0.3.693",
10670
+ "version": "0.3.694",
10671
10671
  "license": "UNLICENSED"
10672
10672
  },
10673
10673
  "packages/crouter-env-docker": {
10674
10674
  "name": "@north-light/env-docker",
10675
- "version": "0.3.693",
10675
+ "version": "0.3.694",
10676
10676
  "license": "UNLICENSED"
10677
10677
  },
10678
10678
  "packages/crouter-identity": {
10679
10679
  "name": "@north-light/identity",
10680
- "version": "0.3.693",
10680
+ "version": "0.3.694",
10681
10681
  "license": "UNLICENSED",
10682
10682
  "dependencies": {
10683
10683
  "jose": "^6.2.1"
@@ -10685,21 +10685,21 @@
10685
10685
  },
10686
10686
  "packages/crouter-plugin": {
10687
10687
  "name": "@north-light/plugin",
10688
- "version": "0.3.693",
10688
+ "version": "0.3.694",
10689
10689
  "license": "UNLICENSED",
10690
10690
  "dependencies": {
10691
- "@north-light/api": "0.3.693",
10692
- "@north-light/identity": "0.3.693"
10691
+ "@north-light/api": "0.3.694",
10692
+ "@north-light/identity": "0.3.694"
10693
10693
  }
10694
10694
  },
10695
10695
  "packages/crouter-sdk": {
10696
10696
  "name": "@north-light/sdk",
10697
- "version": "0.3.693",
10697
+ "version": "0.3.694",
10698
10698
  "license": "UNLICENSED",
10699
10699
  "dependencies": {
10700
- "@north-light/api": "0.3.693",
10701
- "@north-light/identity": "0.3.693",
10702
- "@north-light/plugin": "0.3.693",
10700
+ "@north-light/api": "0.3.694",
10701
+ "@north-light/identity": "0.3.694",
10702
+ "@north-light/plugin": "0.3.694",
10703
10703
  "jose": "^6.2.1"
10704
10704
  },
10705
10705
  "bin": {