@north-light/cli 0.3.673 → 0.3.675
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/session/connection.d.ts +2 -1
- package/dist/clients/attach/session/connection.js +1 -1
- package/dist/clients/attach/viewer.d.ts +11 -1
- package/dist/clients/attach/viewer.js +524 -524
- package/dist/commands/person-settings.d.ts +5 -0
- package/dist/commands/person-settings.js +1 -1
- package/dist/core/graph/reader.d.ts +2 -1
- package/dist/core/graph/reader.js +3 -3
- package/dist/core/graph/repo-sync/repos.d.ts +24 -3
- package/dist/core/graph/repo-sync/repos.js +4 -4
- package/dist/core/profiles/select.d.ts +3 -1
- package/dist/core/profiles/select.js +25 -25
- package/dist/core/runtime/bearings.d.ts +3 -3
- package/dist/core/runtime/bearings.js +6 -6
- package/dist/core/runtime/boot-root.d.ts +3 -3
- package/dist/core/runtime/boot-root.js +6 -4
- package/dist/core/runtime/deliver-live.js +1 -1
- package/dist/core/runtime/front-door.js +1 -1
- package/dist/core/runtime/starting-screen.d.ts +12 -0
- package/dist/core/runtime/starting-screen.js +9 -0
- package/dist/core/substrate/delivery/deliver.d.ts +1 -1
- package/dist/core/substrate/delivery/deliver.js +3 -3
- package/dist/core/substrate/delivery/plan.d.ts +4 -0
- package/dist/core/substrate/delivery/plan.js +2 -2
- package/dist/core/substrate/subject.d.ts +3 -1
- package/dist/core/substrate/subject.js +1 -1
- package/dist/daemon/api/handlers/broker-ops.js +1 -1
- package/dist/daemon/api/handlers/delivery.js +1 -1
- package/package.json +3 -3
- package/packages/crouter-api/dist/clients/attach/session/connection.js +3 -2
- package/packages/crouter-api/dist/clients/attach/viewer.js +16 -7
- package/packages/crouter-api/dist/commands/person-settings.js +10 -3
- package/packages/crouter-api/dist/core/graph/reader.js +9 -4
- package/packages/crouter-api/dist/core/graph/repo-sync/repos.js +56 -13
- package/packages/crouter-api/dist/core/profiles/select.js +17 -7
- package/packages/crouter-api/dist/core/runtime/bearings.js +11 -12
- package/packages/crouter-api/dist/core/runtime/deliver-live.js +1 -1
- package/packages/crouter-api/dist/core/substrate/delivery/deliver.js +27 -6
- package/packages/crouter-api/dist/core/substrate/delivery/plan.js +2 -0
- package/packages/crouter-api/dist/core/substrate/subject.js +4 -4
- package/packages/crouter-api/dist/daemon/api/handlers/broker-ops.js +6 -4
- 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
|
@@ -75,7 +75,7 @@ export async function deliverBearingsLive(nodeId) {
|
|
|
75
75
|
// The boot delivery clears and rewrites the ledger and freezes preferences in
|
|
76
76
|
// one transaction before Pi receives the bearings.
|
|
77
77
|
await warmNodeRepos(await openDb(), nodeId);
|
|
78
|
-
const { content } = await withCanvasWrite(async (db) => await deliver(db, await readerForNode(db, nodeId, async (cwd, person) => await checkoutsForCwd(db, cwd, person)), { activity: 'boot' }));
|
|
78
|
+
const { content } = await withCanvasWrite(async (db) => await deliver(db, await readerForNode(db, nodeId, async (cwd, person, access) => await checkoutsForCwd(db, cwd, person, access)), { activity: 'boot' }));
|
|
79
79
|
await deliverCustomMessageLive(nodeId, {
|
|
80
80
|
customType: CONTEXT_INTRO_CUSTOM_TYPE,
|
|
81
81
|
content: formatCard('bearings', {}, content),
|
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
* caller runs it inside one `withCanvasWrite`, so exposures, watches and
|
|
5
5
|
* events land together or not at all. */
|
|
6
6
|
import { dirname } from 'node:path';
|
|
7
|
+
import { isCloudRole } from '../../canvas/person-state.js';
|
|
8
|
+
import { machineEnvironmentOfProfile } from '../../runtime/runner/machine/environment.js';
|
|
7
9
|
import { clearLedger, demoteTranscript, freezePreferences, loadLedger, saveLedger } from '../../graph/exposures.js';
|
|
8
10
|
import { recordWatches } from '../../graph/watches.js';
|
|
9
11
|
import { publishMany } from '../../graph/events.js';
|
|
@@ -70,13 +72,32 @@ export async function recordContentDelivery(db, reader, delivered, reposFn = asy
|
|
|
70
72
|
}
|
|
71
73
|
/** The file-read reader: the node's own view plus the repos enclosing the read file, so their rules apply. */
|
|
72
74
|
async function fileReadReader(db, reader, file) {
|
|
75
|
+
if (await isMacEnforcedRead(db, reader, file))
|
|
76
|
+
return reader;
|
|
73
77
|
const extra = (await checkoutsForCwd(db, dirname(file))).filter((c) => !reader.repos.some((own) => own.id === c.repo.id));
|
|
74
78
|
return extra.length === 0 ? reader
|
|
75
79
|
: { ...reader, repos: [...reader.repos, ...extra.map((c) => c.repo)], checkouts: [...reader.checkouts, ...extra] };
|
|
76
80
|
}
|
|
81
|
+
/** On a cloud role a terminal-app node's files live on its Mac, which enforces file access itself; the control plane cannot see them,
|
|
82
|
+
* so this read passes on the Mac's say-so and the control plane must not touch its own disk at the path. */
|
|
83
|
+
async function isMacEnforcedRead(db, reader, file) {
|
|
84
|
+
const grantee = await granteeOf(db, reader);
|
|
85
|
+
return grantee === 'app:terminal' && isCloudRole() && reader.profile != null && await machineEnvironmentOfProfile(reader.profile.id) !== null
|
|
86
|
+
&& !readableProjectForScopes(file, grantee, reader.scopes ?? [], null);
|
|
87
|
+
}
|
|
88
|
+
/** The file-read payload: for a Mac-enforced read, empty frontmatter and the repo roots from the node's stored checkouts that enclose the path. */
|
|
89
|
+
async function fileReadPayload(db, reader, file) {
|
|
90
|
+
if (!await isMacEnforcedRead(db, reader, file))
|
|
91
|
+
return { absoluteFile: file };
|
|
92
|
+
const roots = new Map();
|
|
93
|
+
for (const { root, repo } of reader.checkouts)
|
|
94
|
+
if (file.startsWith(root.endsWith('/') ? root : `${root}/`) && !roots.has(repo.id))
|
|
95
|
+
roots.set(repo.id, root);
|
|
96
|
+
return { absoluteFile: file, readFrontmatter: {}, repoRoots: roots, remotePath: true };
|
|
97
|
+
}
|
|
77
98
|
async function assertReadableFile(db, reader, file) {
|
|
78
99
|
const grantee = await granteeOf(db, reader);
|
|
79
|
-
const ok = file.startsWith('/') && ((process.platform !== 'linux' && grantee === 'app:terminal')
|
|
100
|
+
const ok = file.startsWith('/') && ((process.platform !== 'linux' && grantee === 'app:terminal') || await isMacEnforcedRead(db, reader, file)
|
|
80
101
|
|| readableProjectForScopes(file, grantee, reader.scopes ?? [], null));
|
|
81
102
|
if (!ok)
|
|
82
103
|
throw new ApiError(403, 'scope_missing', 'read file is outside the run mounts');
|
|
@@ -174,7 +195,7 @@ async function render(ctx, req) {
|
|
|
174
195
|
await assertReadableFile(db, reader, file);
|
|
175
196
|
const fileReader = await fileReadReader(db, reader, file);
|
|
176
197
|
const fileCtx = { ...ctx, reader: fileReader };
|
|
177
|
-
const r = await renderEvent(fileCtx, 'file-read',
|
|
198
|
+
const r = await renderEvent(fileCtx, 'file-read', await fileReadPayload(db, reader, file), await loadCorpus(db, fileReader, ['file-read']));
|
|
178
199
|
return { result: { content: r.content }, delivered: r.delivered };
|
|
179
200
|
}
|
|
180
201
|
case 'command':
|
|
@@ -231,14 +252,14 @@ async function readDocument(db, reader, raw) {
|
|
|
231
252
|
* inside its boot, and a document read goes through the read route. */
|
|
232
253
|
export const DRY_RUN_ONLY = ['workspace-open', 'document-read'];
|
|
233
254
|
/** One delivery for a live node. Call inside `withCanvasWrite`. */
|
|
234
|
-
export async function deliver(db, reader, req) {
|
|
255
|
+
export async function deliver(db, reader, req, subject) {
|
|
235
256
|
if (DRY_RUN_ONLY.includes(req.activity))
|
|
236
257
|
throw new ApiError(400, 'usage', `delivery activity ${req.activity} is available to a dry run only`);
|
|
237
258
|
const node = nodeOf(reader).node;
|
|
238
259
|
if (req.activity === 'boot' && req.inherited !== true)
|
|
239
260
|
await clearLedger(db, node.id);
|
|
240
261
|
const ledger = await loadLedger(db, node.id);
|
|
241
|
-
const ctx = { db, reader, subject: await nodeSubject(db, reader), ledger, channel: 'transcript' };
|
|
262
|
+
const ctx = { db, reader, subject: subject ?? await nodeSubject(db, reader), ledger, channel: 'transcript' };
|
|
242
263
|
const { result, delivered } = await render(ctx, req);
|
|
243
264
|
await recordContentDelivery(db, reader, delivered);
|
|
244
265
|
await saveLedger(db, ledger);
|
|
@@ -283,7 +304,7 @@ function resolveProfileId(raw, cwd) {
|
|
|
283
304
|
export async function hypotheticalReader(db, h) {
|
|
284
305
|
const app = await ownerForGrantee(db, h.grantee ?? 'app:terminal');
|
|
285
306
|
const profileId = resolveProfileId(h.profile, h.cwd);
|
|
286
|
-
const view = await viewRepos(db, h.cwd, profileId, async (cwd, person) => await checkoutsForCwd(db, cwd, person), liveLookups(db));
|
|
307
|
+
const view = await viewRepos(db, h.cwd, profileId, async (cwd, person, access) => await checkoutsForCwd(db, cwd, person, access), liveLookups(db));
|
|
287
308
|
const { repos } = view;
|
|
288
309
|
const mode = h.mode ?? 'base';
|
|
289
310
|
const node = {
|
|
@@ -313,7 +334,7 @@ export async function inspect(db, reader, req, subjectOverride, baseSubject) {
|
|
|
313
334
|
const on = ACTIVITY_ON[req.activity];
|
|
314
335
|
let plan = null;
|
|
315
336
|
if (on !== undefined) {
|
|
316
|
-
const payload = req.activity === 'file-read' ?
|
|
337
|
+
const payload = req.activity === 'file-read' ? await fileReadPayload(db, nodeOf(reader), req.subject)
|
|
317
338
|
: req.activity === 'command' || req.activity === 'pre-command' ? { command: req.subject }
|
|
318
339
|
: req.activity === 'document-read' && req.subject !== undefined ? { doc: await deliveryDocOf(db, reader, await readDocument(db, reader, req.subject)) }
|
|
319
340
|
: {};
|
|
@@ -33,6 +33,8 @@ export async function planDelivery(db, subject, reader, corpus, on, payload = {}
|
|
|
33
33
|
async function resolvePayload(db, on, payload) {
|
|
34
34
|
if (on !== 'file-read' || payload.absoluteFile === undefined)
|
|
35
35
|
return payload;
|
|
36
|
+
if (payload.remotePath)
|
|
37
|
+
return payload;
|
|
36
38
|
const absoluteFile = realpathOrSelf(payload.absoluteFile);
|
|
37
39
|
return {
|
|
38
40
|
...payload,
|
|
@@ -15,7 +15,7 @@ export { effectiveScopes, scopeForCwd, profileNameFor } from './subject-fields.j
|
|
|
15
15
|
* walking the `parent` chain (canvas-db rows) until a row with no parent (the
|
|
16
16
|
* root). The root is depth 0. Cycle-guarded (parents must not cycle, but never
|
|
17
17
|
* loop forever) — mirrors `rootOfSpine` in runtime/placement.ts. */
|
|
18
|
-
export async function spineDepth(nodeId) {
|
|
18
|
+
export async function spineDepth(nodeId, own) {
|
|
19
19
|
let cur = nodeId;
|
|
20
20
|
const seen = new Set();
|
|
21
21
|
let hops = 0;
|
|
@@ -23,7 +23,7 @@ export async function spineDepth(nodeId) {
|
|
|
23
23
|
if (seen.has(cur))
|
|
24
24
|
break;
|
|
25
25
|
seen.add(cur);
|
|
26
|
-
const row = await getRow(cur);
|
|
26
|
+
const row = cur === nodeId && own !== undefined ? own : await getRow(cur);
|
|
27
27
|
if (row === null || row.parent == null)
|
|
28
28
|
break;
|
|
29
29
|
cur = row.parent;
|
|
@@ -34,7 +34,7 @@ export async function spineDepth(nodeId) {
|
|
|
34
34
|
/** The repos eligible for the node's rules: those enclosing its cwd, then the repos of its profile's project paths. */
|
|
35
35
|
async function eligibleRepos(cwd, profileId) {
|
|
36
36
|
const db = await openDb();
|
|
37
|
-
const view = await viewRepos(db, cwd, profileId, async (dir, person) => await checkoutsForCwd(db, dir, person), liveLookups(db));
|
|
37
|
+
const view = await viewRepos(db, cwd, profileId, async (dir, person, access) => await checkoutsForCwd(db, dir, person, access), liveLookups(db));
|
|
38
38
|
return [...view.repos, ...view.projectRepos];
|
|
39
39
|
}
|
|
40
40
|
/** Assemble the node-config subject for `nodeId` from its `NodeMeta` + the
|
|
@@ -51,7 +51,7 @@ export async function assembleNodeSubject(nodeId, repos) {
|
|
|
51
51
|
hasManager: (meta.parent ?? null) !== null,
|
|
52
52
|
cwd: meta.cwd,
|
|
53
53
|
scope: scopeForCwd(meta.cwd),
|
|
54
|
-
orchestration: { depth: await spineDepth(nodeId) },
|
|
54
|
+
orchestration: { depth: await spineDepth(nodeId, meta) },
|
|
55
55
|
profile: profileNameFor(meta.profile_id),
|
|
56
56
|
app: meta.grantee ?? await appForNode(nodeId),
|
|
57
57
|
scopes: effectiveScopes(meta.scopes),
|
|
@@ -33,6 +33,7 @@ import { runAttachments } from './node-records.js';
|
|
|
33
33
|
import { readerForNode, warmNodeRepos } from '../../../core/graph/reader.js';
|
|
34
34
|
import { checkoutsForCwd } from '../../../core/graph/repo-sync/repos.js';
|
|
35
35
|
import { deliver } from '../../../core/substrate/delivery/deliver.js';
|
|
36
|
+
import { nodeSubject } from '../../../core/substrate/delivery/corpus.js';
|
|
36
37
|
import { ensureRunObserver } from '../../runs/observer.js';
|
|
37
38
|
import { parseNodeTelemetryRecord, writeNodeTelemetryRecord } from './telemetry-record.js';
|
|
38
39
|
import { mapAsync } from '../../../core/async-array.js';
|
|
@@ -300,10 +301,11 @@ async function startupDelivery(nodeId, state, bearings, namesOnly, warmed = fals
|
|
|
300
301
|
if (!warmed)
|
|
301
302
|
await warmNodeRepos(await openDb(), nodeId);
|
|
302
303
|
return await withCanvasWrite(async (db) => {
|
|
303
|
-
const reader = await readerForNode(db, nodeId, async (cwd, person) => await checkoutsForCwd(db, cwd, person));
|
|
304
|
-
const
|
|
305
|
-
const
|
|
306
|
-
const
|
|
304
|
+
const reader = await readerForNode(db, nodeId, async (cwd, person, access) => await checkoutsForCwd(db, cwd, person, access));
|
|
305
|
+
const subject = await nodeSubject(db, reader);
|
|
306
|
+
const names = await deliver(db, reader, { activity: 'names' }, subject);
|
|
307
|
+
const boot = bootOwed ? await deliver(db, reader, { activity: 'boot', ...(bearings === 'inherited' ? { inherited: true } : {}) }, subject) : undefined;
|
|
308
|
+
const system = warm ? undefined : await deliver(db, reader, { activity: 'system-prompt' }, subject);
|
|
307
309
|
return {
|
|
308
310
|
names: { refs: names.refs, names: names.names },
|
|
309
311
|
...(boot === undefined ? {} : { boot: { content: boot.content, ...(boot.inherited === true ? { inherited: true } : {}) } }),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@north-light/api",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.675",
|
|
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.675",
|
|
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.675",
|
|
31
|
+
"@north-light/identity": "0.3.675"
|
|
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.675",
|
|
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.675",
|
|
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.675",
|
|
32
|
+
"@north-light/plugin": "0.3.675",
|
|
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.
|
|
10670
|
+
"version": "0.3.675",
|
|
10671
10671
|
"license": "UNLICENSED"
|
|
10672
10672
|
},
|
|
10673
10673
|
"packages/crouter-env-docker": {
|
|
10674
10674
|
"name": "@north-light/env-docker",
|
|
10675
|
-
"version": "0.3.
|
|
10675
|
+
"version": "0.3.675",
|
|
10676
10676
|
"license": "UNLICENSED"
|
|
10677
10677
|
},
|
|
10678
10678
|
"packages/crouter-identity": {
|
|
10679
10679
|
"name": "@north-light/identity",
|
|
10680
|
-
"version": "0.3.
|
|
10680
|
+
"version": "0.3.675",
|
|
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.
|
|
10688
|
+
"version": "0.3.675",
|
|
10689
10689
|
"license": "UNLICENSED",
|
|
10690
10690
|
"dependencies": {
|
|
10691
|
-
"@north-light/api": "0.3.
|
|
10692
|
-
"@north-light/identity": "0.3.
|
|
10691
|
+
"@north-light/api": "0.3.675",
|
|
10692
|
+
"@north-light/identity": "0.3.675"
|
|
10693
10693
|
}
|
|
10694
10694
|
},
|
|
10695
10695
|
"packages/crouter-sdk": {
|
|
10696
10696
|
"name": "@north-light/sdk",
|
|
10697
|
-
"version": "0.3.
|
|
10697
|
+
"version": "0.3.675",
|
|
10698
10698
|
"license": "UNLICENSED",
|
|
10699
10699
|
"dependencies": {
|
|
10700
|
-
"@north-light/api": "0.3.
|
|
10701
|
-
"@north-light/identity": "0.3.
|
|
10702
|
-
"@north-light/plugin": "0.3.
|
|
10700
|
+
"@north-light/api": "0.3.675",
|
|
10701
|
+
"@north-light/identity": "0.3.675",
|
|
10702
|
+
"@north-light/plugin": "0.3.675",
|
|
10703
10703
|
"jose": "^6.2.1"
|
|
10704
10704
|
},
|
|
10705
10705
|
"bin": {
|