@north-light/cli 0.3.710 → 0.3.711

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 (110) hide show
  1. package/dist/api/contract.d.ts +1 -1
  2. package/dist/api/contract.js +1 -1
  3. package/dist/clients/attach/input/controller.d.ts +1 -1
  4. package/dist/clients/attach/input/controller.js +2 -2
  5. package/dist/clients/attach/render/chat-view.d.ts +13 -2
  6. package/dist/clients/attach/render/chat-view.js +2 -2
  7. package/dist/clients/attach/session/input-wiring.d.ts +2 -2
  8. package/dist/clients/attach/session/layout-record.d.ts +4 -2
  9. package/dist/clients/attach/session/layout-record.js +1 -1
  10. package/dist/clients/attach/session/reconnect.d.ts +8 -1
  11. package/dist/clients/attach/session/reconnect.js +1 -1
  12. package/dist/clients/attach/slash/recover.js +3 -2
  13. package/dist/clients/attach/viewer.js +405 -404
  14. package/dist/commands/human/prompts.js +1 -1
  15. package/dist/commands/human/request.js +1 -1
  16. package/dist/commands/sys/doctor.js +1 -1
  17. package/dist/commands/sys/tutorial/scenario.js +2 -2
  18. package/dist/core/broker-client/client.d.ts +2 -0
  19. package/dist/core/broker-client/client.js +1 -1
  20. package/dist/core/broker-client/transport-relay.d.ts +6 -0
  21. package/dist/core/broker-client/transport-relay.js +1 -1
  22. package/dist/core/broker-client/transport.d.ts +4 -0
  23. package/dist/core/canvas/daemon-actions.d.ts +1 -1
  24. package/dist/core/canvas/daemon-actions.js +7 -7
  25. package/dist/core/canvas/deliveries.d.ts +1 -1
  26. package/dist/core/canvas/deliveries.js +21 -21
  27. package/dist/core/canvas/executions.d.ts +1 -1
  28. package/dist/core/canvas/executions.js +1 -1
  29. package/dist/core/canvas/reconciler-leases.d.ts +4 -0
  30. package/dist/core/canvas/reconciler-leases.js +5 -5
  31. package/dist/core/conversation-store/client.js +2 -2
  32. package/dist/core/conversation-store/index.d.ts +5 -2
  33. package/dist/core/conversation-store/row-store.js +14 -12
  34. package/dist/core/graph/package-docs.js +5 -5
  35. package/dist/core/graph/package-publish.js +4 -3
  36. package/dist/core/human/requests.js +19 -19
  37. package/dist/core/import/load/run.js +2 -2
  38. package/dist/core/runtime/broker/client-registry.d.ts +1 -1
  39. package/dist/core/runtime/broker/client-registry.js +1 -1
  40. package/dist/core/runtime/broker/turn-replies.js +3 -1
  41. package/dist/core/runtime/broker-protocol.d.ts +4 -4
  42. package/dist/core/runtime/broker-protocol.js +3 -3
  43. package/dist/core/runtime/broker.js +1 -1
  44. package/dist/core/runtime/placement-tmux.d.ts +1 -0
  45. package/dist/core/runtime/placement-tmux.js +1 -1
  46. package/dist/core/runtime/session-cycles.d.ts +21 -0
  47. package/dist/core/runtime/session-cycles.js +1 -1
  48. package/dist/daemon/api/app-listener.js +1 -1
  49. package/dist/daemon/api/handlers/charges.d.ts +1 -1
  50. package/dist/daemon/api/handlers/charges.js +1 -1
  51. package/dist/daemon/api/handlers/conversations.js +4 -3
  52. package/dist/daemon/api/handlers/environments.d.ts +1 -1
  53. package/dist/daemon/api/handlers/environments.js +1 -1
  54. package/dist/daemon/api/handlers/limits.js +1 -1
  55. package/dist/daemon/api/handlers/nodes.js +1 -1
  56. package/dist/daemon/api/operations.js +1 -1
  57. package/dist/daemon/api/router.js +1 -1
  58. package/dist/daemon/cron/live-runs.d.ts +3 -0
  59. package/dist/daemon/cron/live-runs.js +1 -1
  60. package/dist/daemon/cron/machine-fire.js +1 -1
  61. package/dist/daemon/crtrd.js +12 -12
  62. package/dist/daemon/due-sources.d.ts +1 -1
  63. package/dist/daemon/due-sources.js +1 -1
  64. package/dist/daemon/due.js +7 -7
  65. package/dist/daemon/human/finish.js +3 -3
  66. package/dist/daemon/human/settle.js +1 -1
  67. package/dist/daemon/reconcilers/action-lane.js +1 -1
  68. package/dist/daemon/reconcilers/delivery-lane.js +2 -2
  69. package/dist/daemon/reconcilers/grant-effects.js +1 -1
  70. package/dist/daemon/reconcilers/node-lifecycle/requested-stops.js +2 -2
  71. package/package.json +4 -3
  72. package/packages/crouter-api/dist/api/contract.js +1 -1
  73. package/packages/crouter-api/dist/clients/attach/input/controller.js +2 -2
  74. package/packages/crouter-api/dist/clients/attach/render/chat-view.js +40 -3
  75. package/packages/crouter-api/dist/clients/attach/session/layout-record.js +7 -7
  76. package/packages/crouter-api/dist/clients/attach/session/reconnect.js +41 -2
  77. package/packages/crouter-api/dist/clients/attach/slash/recover.js +23 -1
  78. package/packages/crouter-api/dist/clients/attach/viewer.js +21 -10
  79. package/packages/crouter-api/dist/commands/human/prompts.js +11 -18
  80. package/packages/crouter-api/dist/commands/human/request.js +3 -0
  81. package/packages/crouter-api/dist/commands/sys/doctor.js +17 -0
  82. package/packages/crouter-api/dist/commands/sys/tutorial/scenario.js +1 -0
  83. package/packages/crouter-api/dist/core/broker-client/client.js +4 -0
  84. package/packages/crouter-api/dist/core/broker-client/transport-relay.js +45 -0
  85. package/packages/crouter-api/dist/core/canvas/daemon-actions.js +3 -2
  86. package/packages/crouter-api/dist/core/canvas/deliveries.js +7 -3
  87. package/packages/crouter-api/dist/core/canvas/executions.js +8 -7
  88. package/packages/crouter-api/dist/core/canvas/reconciler-leases.js +4 -0
  89. package/packages/crouter-api/dist/core/conversation-store/client.js +1 -1
  90. package/packages/crouter-api/dist/core/conversation-store/row-store.js +14 -1
  91. package/packages/crouter-api/dist/core/graph/package-docs.js +8 -3
  92. package/packages/crouter-api/dist/core/graph/package-publish.js +8 -1
  93. package/packages/crouter-api/dist/core/human/requests.js +2 -2
  94. package/packages/crouter-api/dist/core/runtime/broker-protocol.js +4 -4
  95. package/packages/crouter-api/dist/core/runtime/placement-tmux.js +2 -2
  96. package/packages/crouter-api/dist/core/runtime/session-cycles.js +90 -8
  97. package/packages/crouter-api/dist/daemon/api/operations.js +3 -3
  98. package/packages/crouter-api/dist/daemon/api/router.js +1 -4
  99. package/packages/crouter-api/dist/daemon/cron/live-runs.js +4 -5
  100. package/packages/crouter-api/dist/daemon/cron/machine-fire.js +3 -3
  101. package/packages/crouter-api/dist/daemon/human/finish.js +2 -1
  102. package/packages/crouter-api/dist/daemon/human/settle.js +1 -6
  103. package/packages/crouter-api/package.json +1 -1
  104. package/packages/crouter-identity/package.json +1 -1
  105. package/packages/crouter-plugin/package.json +3 -3
  106. package/runtime.lock.json +14 -14
  107. package/scripts/install-runtime.mjs +18 -1
  108. package/scripts/lib/install-source.mjs +49 -0
  109. package/dist/daemon/reconcilers/idle-sandbox.d.ts +0 -18
  110. package/dist/daemon/reconcilers/idle-sandbox.js +0 -7
@@ -233,7 +233,7 @@ export function createRowStore() {
233
233
  const snap = await snapshot(db, id);
234
234
  const size = snap.parts.reduce((n, p) => n + p.bytes, 0) + snap.tail.reduce((n, p) => n + p.bytes, 0);
235
235
  const entriesOf = (text) => decode(text).filter((entry) => entry.type !== 'session');
236
- if (window === 'cycle') {
236
+ const cycleOffset = async () => {
237
237
  const stored = await db.prepare('SELECT cycle_offset FROM conversation_parts WHERE conversation_id = ? AND seq = 0').get(id);
238
238
  let offset = stored?.cycle_offset == null ? null : Number(stored.cycle_offset);
239
239
  if (offset === null) {
@@ -250,8 +250,21 @@ export function createRowStore() {
250
250
  }
251
251
  await withCanvasWrite(async (tx) => { await tx.prepare('UPDATE conversation_parts SET cycle_offset = ? WHERE conversation_id = ? AND seq = 0 AND cycle_offset IS NULL').run(offset, id); });
252
252
  }
253
+ return offset;
254
+ };
255
+ if (window === 'cycle') {
256
+ const offset = await cycleOffset();
253
257
  return { header, entries: entriesOf((await bytesOf(snap, offset, size)).toString('utf8')), path };
254
258
  }
259
+ if (window && 'beforeCycle' in window) {
260
+ const end = await cycleOffset();
261
+ const from = Math.max(0, end - window.beforeCycle);
262
+ // One byte before the window says whether it begins on a line boundary.
263
+ const lines = (await bytesOf(snap, from > 0 ? from - 1 : 0, end)).toString('utf8').split('\n');
264
+ if (from > 0)
265
+ lines.shift();
266
+ return { header, entries: entriesOf(lines.join('\n')), path };
267
+ }
255
268
  if (!window || size <= window.head + window.tail)
256
269
  return { header, entries: entriesOf((await bytesOf(snap, 0, size)).toString('utf8')), path };
257
270
  const front = (await bytesOf(snap, 0, Math.max(0, window.head))).toString('utf8').split('\n');
@@ -6,7 +6,7 @@
6
6
  * the one `ownerForGrantee` gives), and a document with a `source_path` is shipped. */
7
7
  import { randomUUID } from 'node:crypto';
8
8
  import { documentFields } from '../../migrations/004-canvas-documents/fields.js';
9
- import { get as getBody, put as putBody } from './bodies.js';
9
+ import { findMany as findBodies, put as putBody } from './bodies.js';
10
10
  import { applyDocumentFields, deleteDocument, documentRecord, heads, importDocument, linksIn, moveDocument } from './documents.js';
11
11
  import { deleteShippedReader, writeShippedReader } from '../permissions/facts.js';
12
12
  import { setLinks } from './edges.js';
@@ -59,8 +59,13 @@ export async function relinkAllShipped(db) {
59
59
  for (const { id, owner } of docs) {
60
60
  const doc = (await getById(db, id));
61
61
  const [head] = await heads(db, doc);
62
- if (head !== undefined)
63
- await deriveLinks(db, (await getById(db, owner)), doc, await getBody(db, head.body_hash));
62
+ if (head === undefined)
63
+ continue;
64
+ // A head with no `bodies` row belongs to a package not yet converged in this pass (an upgrade from before text moved into the table);
65
+ // its own publish heals the row, so it is skipped here rather than failing every other package.
66
+ const body = (await findBodies(db, [head.body_hash])).get(head.body_hash);
67
+ if (body !== undefined)
68
+ await deriveLinks(db, (await getById(db, owner)), doc, body);
64
69
  }
65
70
  }
66
71
  export async function convergeFile(db, owner, file, report, reposFn) {
@@ -91,7 +91,9 @@ export async function publish(db, input, publishedBy) {
91
91
  emitEvent({ level: 'warn', event: 'daemon.packages.superseded', fields: { app: snapshot.app, snapshot_version: snapshot.version, published_version: row.version, snapshot_revision: snapshot.revision ?? 'none', published_revision: row.revision === null ? 'none' : Number(row.revision) } });
92
92
  return report;
93
93
  }
94
- const sameBytes = row.digest === snapshot.digest && row.withdrawn_at === null;
94
+ // A shipped document whose head text has no `bodies` row (a release before text moved into the table kept it only in the file) forces a
95
+ // converge, which heals the row, even when the package bytes are unchanged.
96
+ const sameBytes = row.digest === snapshot.digest && row.withdrawn_at === null && !(await missesBody(db, owner.id));
95
97
  if (!sameBytes) {
96
98
  const reposFn = async (cwd, person) => await checkoutsForCwd(db, cwd, person);
97
99
  const seen = new Set();
@@ -112,6 +114,11 @@ export async function publish(db, input, publishedBy) {
112
114
  WHERE app = ?`).run(snapshot.origin, snapshot.version, snapshot.revision, snapshot.source, snapshot.launchKinds === null ? null : canonicalJson(snapshot.launchKinds), snapshot.digest, now, publishedBy, owner.id);
113
115
  return report;
114
116
  }
117
+ /** Whether a live shipped document of `app` has a revision whose text is missing from `bodies`. */
118
+ async function missesBody(db, app) {
119
+ return await db.prepare(`SELECT 1 FROM objects o JOIN documents d ON d.object = o.id AND d.source_path IS NOT NULL JOIN revisions r ON r.document = o.id
120
+ WHERE o.type = 'document' AND o.owner = ? AND o.deleted_at IS NULL AND NOT EXISTS (SELECT 1 FROM bodies b WHERE b.hash = r.body_hash) LIMIT 1`).get(app) !== undefined;
121
+ }
115
122
  /** A package folder that does not exist ships nothing: a plugin without a `memory/` folder. */
116
123
  export function emptyPackageSnapshot(meta) {
117
124
  return snapshotOf({ revision: null, source: null, launchKinds: null, objectKinds: null, ...meta }, [], [], createHash('sha256'));
@@ -186,7 +186,7 @@ export async function listOpenInboxRequests() {
186
186
  /** Every open request a person is being asked to act on: the inbox's set (`listOpenInboxRequests`), plus
187
187
  * answerable pages kept out of the inbox. This is the set the attach viewer's inbox strip shows. */
188
188
  export async function listPendingAsks() {
189
- return (await many(await openDb(), `state = 'open' AND requester_node_id IS NOT NULL AND ((inbox_listed = 1 AND ${NOT_OTHER_APP_QUESTION}) OR (kind = 'page' AND inbox_listed = 0 AND settleable = 1))`, [], 'created_at ASC, request_id ASC'))
189
+ return (await many(await openDb(), `state = 'open' AND requester_node_id IS NOT NULL AND (kind = 'review' OR NOT ${pageIsNoticeSql('specification_json')}) AND ((inbox_listed = 1 AND ${NOT_OTHER_APP_QUESTION}) OR (kind = 'page' AND inbox_listed = 0 AND settleable = 1))`, [], 'created_at ASC, request_id ASC'))
190
190
  .filter((request) => request.inbox_listed || pageAwaitsResponse(JSON.parse(request.specification_json)));
191
191
  }
192
192
  export async function openRequestsByRequester(nodeId) {
@@ -202,7 +202,7 @@ export async function hasOpenReplyBearingRequestByRequester(nodeId) {
202
202
  }
203
203
  /** Indexed attention projection: only open inbox-listed requests with a reply target keep a node wakeable. */
204
204
  export async function listOpenReplyBearingRequests() {
205
- return await many(await openDb(), "state = 'open' AND inbox_listed = 1 AND requester_node_id IS NOT NULL", [], 'created_at DESC, request_id DESC');
205
+ return await many(await openDb(), `state = 'open' AND inbox_listed = 1 AND requester_node_id IS NOT NULL AND (kind = 'review' OR NOT ${pageIsNoticeSql('specification_json')})`, [], 'created_at DESC, request_id DESC');
206
206
  }
207
207
  export async function listBindingRequests() { return await many(await openDb(), "kind = 'review' AND state = 'binding'"); }
208
208
  export async function listSubmitRequestedRequests() { return await many(await openDb(), "kind = 'review' AND state = 'open' AND submit_requested_at IS NOT NULL"); }
@@ -17,12 +17,12 @@
17
17
  // follow pi.
18
18
  import { StringDecoder } from 'node:string_decoder';
19
19
  // Client → broker frames
20
- /** The welcome holds at most the last SNAPSHOT_TAIL messages; older ones are read with `crtr canvas read`. */
21
- export const SNAPSHOT_TAIL = 100;
20
+ /** A requested welcome bound: at most this many of the newest messages. Absent or invalid asks for the
21
+ * default window (`welcomeWindow` in session-cycles.ts: two earlier cycles, then the current cycle by size). */
22
22
  export function normalizeSnapshotTail(value) {
23
23
  if (typeof value !== 'number' || !Number.isSafeInteger(value) || value < 1)
24
- return SNAPSHOT_TAIL;
25
- return Math.min(value, SNAPSHOT_TAIL);
24
+ return undefined;
25
+ return value;
26
26
  }
27
27
  export function toolCallIds(messages) {
28
28
  const ids = new Set();
@@ -16,7 +16,7 @@
16
16
  // tmux-driver.ts — it is the sanctioned pure-tmux seam, re-exporting the driver
17
17
  // verbs other modules need so they never import the driver directly.
18
18
  import { envHomeOverride } from '../../shared/env.js';
19
- import { paneLocation, ensureSession, openNodeWindow, splitWindow, selectLayout, } from './tmux-driver.js';
19
+ import { paneLocation, ensureSession, openNodeWindow, splitWindow, selectLayout, shellQuote, } from './tmux-driver.js';
20
20
  import { BROKER_VIEW_SOCKET_WAIT_MS } from './view-socket.js';
21
21
  // Re-export the pure tmux driver verbs the CLI/viewer consumers need without
22
22
  // exposing the canvas focuses table or sending command modules to the raw driver.
@@ -45,7 +45,7 @@ export function viewerSplitEnv() {
45
45
  * - `besidePane` → a SPLIT beside that pane in its own session (the focus
46
46
  * open-beside-the-caller path); `session` is then only a fallback. */
47
47
  export function openViewerPane(nodeId, session, opts = {}) {
48
- const command = `crtr surface attach to ${nodeId}`;
48
+ const command = `crtr surface attach to ${nodeId}` + (opts.canvas === undefined ? '' : ` --canvas ${shellQuote(opts.canvas)}`);
49
49
  // When the broker may not have bound view.sock yet (a viewer opened right after
50
50
  // a fresh spawn), hand the attach pane CRTR_ATTACH_WAIT_MS so it POLLS the
51
51
  // socket until it accepts instead of failing fast on a cold socket and closing
@@ -40,23 +40,105 @@ export function identifiedMessages(entries, leafId) {
40
40
  const byId = new Map(entries.map((e) => [e.id, e]));
41
41
  return buildContextEntries(entries, leafId, byId).flatMap((entry) => sessionEntryToContextMessages(entry).map((message) => ({ id: entry.id, message: message })));
42
42
  }
43
+ /** An earlier cycle's message as display text: user and assistant text only, without the yield's abort. */
44
+ function earlierText(item) {
45
+ const m = item.message;
46
+ if (m.role !== 'user' && m.role !== 'assistant')
47
+ return undefined;
48
+ const content = typeof m.content === 'string' ? m.content : m.content.filter((part) => part.type === 'text');
49
+ return content.length > 0 ? { ...item, message: { ...withoutYieldAbort(m), content } } : undefined;
50
+ }
51
+ function isCycleMarker(entry) {
52
+ return entry?.type === 'custom' && entry.customType === CRTR_CYCLE_CUSTOM_TYPE;
53
+ }
54
+ /** The line shown where a cycle starts. */
55
+ export function cycleDivider(marker) {
56
+ const data = marker.data;
57
+ return { id: marker.id, message: { role: 'custom', customType: CRTR_CYCLE_CUSTOM_TYPE, content: `cycle ${data?.cycle ?? ''} begins with a fresh context window`, display: true, timestamp: new Date(marker.timestamp).getTime() } };
58
+ }
59
+ /** True for the line `cycleDivider` shows where a cycle starts. */
60
+ export function isCycleDivider(message) {
61
+ return message.role === 'custom' && message.customType === CRTR_CYCLE_CUSTOM_TYPE;
62
+ }
43
63
  /** A whole conversation for display: each earlier cycle as user and assistant
44
64
  * text only, one line where each cycle starts, then the current cycle in full. */
45
65
  export function transcriptMessages(entries, leafId) {
46
66
  const out = [];
47
67
  for (const marker of entries) {
48
- if (marker.type !== 'custom' || marker.customType !== CRTR_CYCLE_CUSTOM_TYPE)
68
+ if (!isCycleMarker(marker))
49
69
  continue;
50
70
  const data = marker.data;
51
71
  for (const item of data?.fromLeaf ? identifiedMessages(entries, data.fromLeaf) : []) {
52
- const m = item.message;
53
- if (m.role !== 'user' && m.role !== 'assistant')
54
- continue;
55
- const content = typeof m.content === 'string' ? m.content : m.content.filter((part) => part.type === 'text');
56
- if (content.length > 0)
57
- out.push({ ...item, message: { ...withoutYieldAbort(m), content } });
72
+ const text = earlierText(item);
73
+ if (text !== undefined)
74
+ out.push(text);
58
75
  }
59
- out.push({ id: marker.id, message: { role: 'custom', customType: CRTR_CYCLE_CUSTOM_TYPE, content: `cycle ${data?.cycle ?? ''} begins with a fresh context window`, display: true, timestamp: new Date(marker.timestamp).getTime() } });
76
+ out.push(cycleDivider(marker));
60
77
  }
61
78
  return [...out, ...identifiedMessages(entries, leafId)];
62
79
  }
80
+ /** Up to `count` cycles before the current one, oldest first, as `transcriptMessages` shows them, from
81
+ * `entries`: the end of the conversation before `currentMarker`, which may start inside an earlier cycle.
82
+ * A cycle cut by that start shows its newest messages only. Ends with `currentMarker`'s divider. */
83
+ export function earlierCycleMessages(entries, currentMarker, count) {
84
+ if (!isCycleMarker(currentMarker))
85
+ return [];
86
+ const byId = new Map(entries.map((e) => [e.id, e]));
87
+ const cycles = [];
88
+ let marker = currentMarker;
89
+ while (cycles.length < count) {
90
+ const leaf = marker.data?.fromLeaf;
91
+ if (!leaf || !byId.has(leaf))
92
+ break;
93
+ const messages = identifiedMessages(entries, leaf).flatMap((item) => earlierText(item) ?? []);
94
+ let root = byId.get(leaf);
95
+ while (root.parentId && byId.has(root.parentId))
96
+ root = byId.get(root.parentId);
97
+ cycles.unshift(isCycleMarker(root) ? [cycleDivider(root), ...messages] : messages);
98
+ if (!isCycleMarker(root))
99
+ break;
100
+ marker = root;
101
+ }
102
+ // The oldest cycle shown begins at its first message; its own start line belongs to the cycle before it.
103
+ if (cycles.length > 0 && cycles[0][0] !== undefined && isCycleDivider(cycles[0][0].message))
104
+ cycles[0] = cycles[0].slice(1);
105
+ return [...cycles.flat(), cycleDivider(currentMarker)];
106
+ }
107
+ /** Earlier cycles a welcome shows. */
108
+ export const WELCOME_EARLIER_CYCLES = 2;
109
+ /** Bytes of the conversation before the current cycle a broker reads for its welcome's earlier cycles. */
110
+ export const WELCOME_EARLIER_BYTES = 4 * 1024 * 1024;
111
+ /** JSON bytes of the current cycle a welcome carries: its newest messages that fit. */
112
+ export const WELCOME_CURRENT_BYTES = 2 * 1024 * 1024;
113
+ /** A welcome's window over a display transcript (`transcriptMessages` shape): the last
114
+ * `WELCOME_EARLIER_CYCLES` earlier cycles in full, then the current cycle's newest messages
115
+ * within `WELCOME_CURRENT_BYTES` of JSON (always at least the newest). Returns the index of the
116
+ * first message kept; `size` gives a message's JSON bytes. */
117
+ export function welcomeWindow(messages, size) {
118
+ let current = 0;
119
+ for (let i = messages.length - 1; i >= 0; i--)
120
+ if (isCycleDivider(messages[i])) {
121
+ current = i + 1;
122
+ break;
123
+ }
124
+ let start = messages.length;
125
+ let bytes = 0;
126
+ while (start > current) {
127
+ bytes += size(messages[start - 1]);
128
+ if (bytes > WELCOME_CURRENT_BYTES && start < messages.length)
129
+ break;
130
+ start--;
131
+ }
132
+ if (start > current)
133
+ return { start };
134
+ // The whole current cycle fits: keep the earlier cycles too, from after the start line of the oldest one shown.
135
+ let dividers = 0;
136
+ for (let i = current - 1; i >= 0; i--) {
137
+ if (!isCycleDivider(messages[i]))
138
+ continue;
139
+ dividers++;
140
+ if (dividers > WELCOME_EARLIER_CYCLES)
141
+ return { start: i + 1 };
142
+ }
143
+ return { start: 0 };
144
+ }
@@ -194,7 +194,7 @@ export const OPERATIONS = [
194
194
  { name: 'profile.env.set', method: 'PUT', path: '/v1/profiles/:name/env/:var', classes: ['person', 'app', 'broker'], resource: 'profile' },
195
195
  { name: 'profile.env.remove', method: 'DELETE', path: '/v1/profiles/:name/env/:var', classes: ['person', 'app', 'broker'], resource: 'profile' },
196
196
  { name: 'profile.environment.get', method: 'GET', path: '/v1/profiles/:name/environment', classes: ['person', 'broker', 'cron'], resource: 'profile' },
197
- { name: 'profile.environment.set', method: 'PUT', path: '/v1/profiles/:name/environment', classes: ['person'], resource: 'profile' },
197
+ { name: 'profile.environment.set', method: 'PUT', path: '/v1/profiles/:name/environment', classes: ['person', 'broker'], resource: 'profile' },
198
198
  { name: 'profiles.delete.116', method: 'DELETE', path: '/v1/profiles/:name', classes: ['person', 'app', 'broker'], resource: 'profile' },
199
199
  { name: 'profile.list', method: 'GET', path: '/v1/profiles', classes: ['person', 'app', 'broker'], resource: 'profile', stage: 'chat' },
200
200
  { name: 'profiles.get.118', method: 'GET', path: '/v1/profiles/:name', classes: ['person', 'app', 'broker'], resource: 'profile' },
@@ -247,13 +247,13 @@ export const OPERATIONS = [
247
247
  { name: 'focus.delete.147', method: 'DELETE', path: '/v1/focuses/:focus_id', classes: ['person', 'broker'], resource: 'none' },
248
248
  { name: 'delivery.retry', method: 'POST', path: '/v1/deliveries/:delivery_id/retry', classes: ['person', 'broker'], resource: 'none' },
249
249
  // Person only: an app (or a broker acting for one) never sets its own limits.
250
- { name: 'limits.show', method: 'GET', path: '/v1/limits', classes: ['person'], resource: 'none' },
250
+ { name: 'limits.show', method: 'GET', path: '/v1/limits', classes: ['person', 'broker'], resource: 'none' },
251
251
  { name: 'limits.set', method: 'PUT', path: '/v1/limits/apps/:app', classes: ['person'], resource: 'none' },
252
252
  { name: 'limits.remove', method: 'DELETE', path: '/v1/limits/apps/:app', classes: ['person'], resource: 'none' },
253
253
  // The money ledger. `charges.list` is stage `objects` so the app listener serves it (an app sees only rows whose grantee it is).
254
254
  { name: 'charges.list', method: 'GET', path: '/v1/charges', classes: ['person', 'app', 'broker'], resource: 'none', stage: 'objects' },
255
255
  // Dollar limits, distinct from the per-app memory and disk limits above. Person only.
256
- { name: 'spend_limits.list', method: 'GET', path: '/v1/spend-limits', classes: ['person'], resource: 'none' },
256
+ { name: 'spend_limits.list', method: 'GET', path: '/v1/spend-limits', classes: ['person', 'broker'], resource: 'none' },
257
257
  { name: 'spend_limits.set', method: 'PUT', path: '/v1/spend-limits/:id', classes: ['person'], resource: 'none' },
258
258
  { name: 'spend_limits.remove', method: 'DELETE', path: '/v1/spend-limits/:id', classes: ['person'], resource: 'none' },
259
259
  { name: 'space.list', method: 'GET', path: '/v1/spaces', classes: ['person', 'broker'], resource: 'none' },
@@ -39,10 +39,7 @@ async function authorizeHumanBody(operation, principal, params, query, body) {
39
39
  // Creation only: `GET /v1/human/reviews` (the list) shares this path and carries no body.
40
40
  if (operation.method === 'POST' && (path === '/v1/human/requests' || path === '/v1/human/reviews')) {
41
41
  const origin = path.endsWith('/reviews') ? fields['origin_node_id'] : fields['requester_node_id'];
42
- // A page with no reply route names no requester (`requester_node_id: null`): nothing is addressed to any node, and the
43
- // handler rejects `delivery.reply` without a requester. A request naming a node must still name the caller.
44
- const displayOnly = path === '/v1/human/requests' && (origin === undefined || origin === null);
45
- if (origin !== principal.node && !displayOnly)
42
+ if (origin !== principal.node)
46
43
  throw new ApiError(403, 'other_app_run', 'a broker may create a human request only for its own node');
47
44
  const source = fields['source'];
48
45
  if (source && typeof source === 'object' && 'nodeId' in source && source.nodeId !== principal.node)
@@ -1,22 +1,21 @@
1
1
  import { randomUUID } from 'node:crypto';
2
- import { claimReconcilerLease, renewReconcilerLease } from '../../core/canvas/reconciler-leases.js';
2
+ import { DAEMON_OWNER_LANE, claimReconcilerLease, renewReconcilerLease } from '../../core/canvas/reconciler-leases.js';
3
3
  import { openDb } from '../../core/canvas/db.js';
4
4
  export const cronDaemonInstanceId = randomUUID();
5
5
  /** A process that owns cron run leases keeps this heartbeat: a `reconciler_leases` row keyed by its instance id. Another process
6
6
  * recovers a run it does not own only once that owner's heartbeat has lapsed, so a live peer still building a run's context
7
7
  * (no pid recorded yet) is never taken for a crashed one. */
8
- const CRON_OWNER_LANE = 'cron-owner';
9
8
  export const CRON_OWNER_HEARTBEAT_TTL_MS = 15_000;
10
9
  const CRON_OWNER_HEARTBEAT_EVERY_MS = 5_000;
11
10
  let heartbeat;
12
11
  let lastBeatAt = 0;
13
12
  async function beat() {
14
- if (await renewReconcilerLease(CRON_OWNER_LANE, cronDaemonInstanceId, cronDaemonInstanceId, CRON_OWNER_HEARTBEAT_TTL_MS)) {
13
+ if (await renewReconcilerLease(DAEMON_OWNER_LANE, cronDaemonInstanceId, cronDaemonInstanceId, CRON_OWNER_HEARTBEAT_TTL_MS)) {
15
14
  lastBeatAt = Date.now();
16
15
  return;
17
16
  }
18
17
  // Absent (first beat) or lapsed (this process stalled): take it again under the same owner.
19
- await claimReconcilerLease(CRON_OWNER_LANE, cronDaemonInstanceId, cronDaemonInstanceId, CRON_OWNER_HEARTBEAT_TTL_MS);
18
+ await claimReconcilerLease(DAEMON_OWNER_LANE, cronDaemonInstanceId, cronDaemonInstanceId, CRON_OWNER_HEARTBEAT_TTL_MS);
20
19
  lastBeatAt = Date.now();
21
20
  }
22
21
  /** Call before naming this process the owner of a cron run lease. Keeps the heartbeat alive from then on; the heartbeat stops
@@ -35,7 +34,7 @@ export async function ensureCronOwnerLease() {
35
34
  /** Whether `owner` (another process's instance id) has a live heartbeat. */
36
35
  export async function cronOwnerAlive(owner) {
37
36
  const row = await (await openDb()).prepare('SELECT 1 AS alive FROM reconciler_leases WHERE lane = ? AND key = ? AND expires_at > ?')
38
- .get(CRON_OWNER_LANE, owner, new Date().toISOString());
37
+ .get(DAEMON_OWNER_LANE, owner, new Date().toISOString());
39
38
  return row !== undefined;
40
39
  }
41
40
  const liveRuns = new Map();
@@ -13,6 +13,7 @@ import { openDb } from '../../core/canvas/db.js';
13
13
  import { isCloudRole } from '../../core/canvas/person.js';
14
14
  import { withCanvasWrite } from '../../core/canvas/db.js';
15
15
  import { getNode } from '../../core/canvas/canvas.js';
16
+ import { contextDir } from '../../core/canvas/paths.js';
16
17
  import { runnerForEnvironment } from '../../core/runtime/runner/index.js';
17
18
  import { callMachine } from '../../core/runtime/runner/machine/call.js';
18
19
  import { machineEnvironmentOfNode } from '../../core/runtime/runner/machine/runner.js';
@@ -178,7 +179,7 @@ async function driveFire(c, fire, prepared, admit) {
178
179
  clearLiveRun(c.cron_id, runId);
179
180
  }
180
181
  }
181
- /** Where a hosted node's files sit inside its sandbox: `CRTR_HOME` and the `apps/<app>/{home,nodes/<id>/context}` layout of scripts/sandbox-start.mjs. */
182
+ /** The sandbox's `CRTR_HOME` (scripts/sandbox-start.mjs), where the app home sits. The context dir is not under it: the node's launch env carries the control plane's `contextDir`. */
182
183
  const SANDBOX_CRTR_HOME = '/var/lib/crtr';
183
184
  /** Fire `c` in its anchor node's sandbox through the Blaxel runner and settle the run. The same run id names the sandbox process, so a
184
185
  * control plane that recovers the run (`resume`) reads the first start instead of running the command again. */
@@ -199,8 +200,7 @@ export async function fireInSandbox(c, fire, admit, resume = false) {
199
200
  throw new Error('an isolated cron needs a root launcher, which a sandbox does not have');
200
201
  const prepared = await prepareRun(c, runId);
201
202
  const anchor = prepared.contextAnchor;
202
- env = { ...prepared.env, CRTR_API_URL: apiUrl, HOME: join(SANDBOX_CRTR_HOME, 'apps', c.grantee.replace(/^app:/, ''), 'home'),
203
- ...(anchor !== null ? { CRTR_CONTEXT_DIR: join(SANDBOX_CRTR_HOME, 'apps', anchor.grantee.replace(/^app:/, ''), 'nodes', anchor.node, 'context') } : {}) };
203
+ env = { ...prepared.env, CRTR_API_URL: apiUrl, HOME: join(SANDBOX_CRTR_HOME, 'apps', c.grantee.replace(/^app:/, ''), 'home'), ...(anchor !== null ? { CRTR_CONTEXT_DIR: contextDir(anchor.node, anchor.grantee) } : {}) };
204
204
  // A recovered run's slot may already have moved past this start; advancing again is a no-op then.
205
205
  if (!outOfBand && c.recur != null && (!resume || Date.parse(c.fire_at) <= startedAtMs)) {
206
206
  const recurrenceError = await advanceRecurrence(c, startedAtMs);
@@ -1,5 +1,6 @@
1
1
  import { getRequest, getRequestByInboxTicket, presentationDir } from '../../core/human/requests.js';
2
2
  import { buildPageSummary } from '../../core/human/summary.js';
3
+ import { pageAwaitsResponse } from '../../core/human/page-schema.js';
3
4
  import { validateFinalPageResponses } from '../../core/human/tickets.js';
4
5
  import { composeHumanCompletion } from '../../core/human/completion.js';
5
6
  import { describePageAnswer } from '../../core/human/answer.js';
@@ -106,7 +107,7 @@ async function cancelBody(request, dismissed, reason) {
106
107
  return body + await feedbackAddendum(request);
107
108
  }
108
109
  function notification(request, disposition, body, result) {
109
- if (request.requester_node_id === null)
110
+ if (request.requester_node_id === null || !pageAwaitsResponse(manifest(request)))
110
111
  return undefined;
111
112
  return { label: firstLine(body), disposition, body_json: { body, result } };
112
113
  }
@@ -25,9 +25,6 @@ export async function settleHumanRequest(input) {
25
25
  return { outcome: 'already_settled', request: winner };
26
26
  }
27
27
  const notification = typeof input.notification === 'function' ? await input.notification(won) : input.notification;
28
- if (won.requester_node_id !== null && notification === undefined) {
29
- throw new Error(`request ${won.request_id} needs a requester notification`);
30
- }
31
28
  if (won.action_json !== null && won.kind === 'page' && input.completion_action === undefined) {
32
29
  throw new Error(`request ${won.request_id} needs its frozen completion action`);
33
30
  }
@@ -39,9 +36,7 @@ export async function settleHumanRequest(input) {
39
36
  }
40
37
  let settlementDeliveryId = null;
41
38
  let actionDeliveryId = null;
42
- if (won.requester_node_id !== null) {
43
- if (notification === undefined)
44
- throw new Error(`request ${won.request_id} needs a requester notification`);
39
+ if (won.requester_node_id !== null && notification !== undefined) {
45
40
  settlementDeliveryId = (await enqueueNodeMail(won.requester_node_id, {
46
41
  kind: 'completed', label: notification.label, senderName: 'crtrd',
47
42
  ...(notification.body_ref === undefined ? {} : { bodyRef: notification.body_ref }),
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@north-light/api",
3
- "version": "0.3.710",
3
+ "version": "0.3.711",
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.710",
3
+ "version": "0.3.711",
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.710",
3
+ "version": "0.3.711",
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.710",
31
- "@north-light/identity": "0.3.710"
30
+ "@north-light/api": "0.3.711",
31
+ "@north-light/identity": "0.3.711"
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.710",
3
+ "version": "0.3.711",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@north-light/cli",
9
- "version": "0.3.710",
9
+ "version": "0.3.711",
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.710",
32
- "@north-light/plugin": "0.3.710",
31
+ "@north-light/identity": "0.3.711",
32
+ "@north-light/plugin": "0.3.711",
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.710",
11905
+ "version": "0.3.711",
11906
11906
  "license": "UNLICENSED"
11907
11907
  },
11908
11908
  "packages/crouter-env-docker": {
11909
11909
  "name": "@north-light/env-docker",
11910
- "version": "0.3.710",
11910
+ "version": "0.3.711",
11911
11911
  "license": "UNLICENSED"
11912
11912
  },
11913
11913
  "packages/crouter-identity": {
11914
11914
  "name": "@north-light/identity",
11915
- "version": "0.3.710",
11915
+ "version": "0.3.711",
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.710",
11923
+ "version": "0.3.711",
11924
11924
  "license": "UNLICENSED",
11925
11925
  "dependencies": {
11926
- "@north-light/api": "0.3.710",
11927
- "@north-light/identity": "0.3.710"
11926
+ "@north-light/api": "0.3.711",
11927
+ "@north-light/identity": "0.3.711"
11928
11928
  }
11929
11929
  },
11930
11930
  "packages/crouter-sdk": {
11931
11931
  "name": "@north-light/sdk",
11932
- "version": "0.3.710",
11932
+ "version": "0.3.711",
11933
11933
  "license": "UNLICENSED",
11934
11934
  "dependencies": {
11935
- "@north-light/api": "0.3.710",
11936
- "@north-light/identity": "0.3.710",
11937
- "@north-light/plugin": "0.3.710",
11935
+ "@north-light/api": "0.3.711",
11936
+ "@north-light/identity": "0.3.711",
11937
+ "@north-light/plugin": "0.3.711",
11938
11938
  "jose": "^6.2.1"
11939
11939
  },
11940
11940
  "bin": {
@@ -14,6 +14,7 @@ import { scrubInheritedBrokerEnv, unsafeIsolationReason } from './lib/isolation-
14
14
  import { packArgs } from './lib/pack-args.mjs';
15
15
  import { runtimeDepsKeyFromFiles } from './lib/runtime-deps-key.mjs';
16
16
  import { assertCandidateMayOpenLiveDatabase, candidateSchemaVersion } from './lib/canvas-schema-gate.mjs';
17
+ import { ALLOW_UNLANDED_FLAG, readInstallSource, refusalMessage, unlandedReasons } from './lib/install-source.mjs';
17
18
 
18
19
  scrubInheritedBrokerEnv();
19
20
  // CI has no account store to protect, and its checkout sits inside the runner's
@@ -22,7 +23,8 @@ const unsafeReason = process.env.CI ? null : unsafeIsolationReason();
22
23
  if (unsafeReason) throw new Error(`Unsafe crouter runtime install: ${unsafeReason}`);
23
24
 
24
25
  const SHARED_FLAG = '--shared-node-modules=';
25
- const positional = process.argv.slice(2).filter((arg) => !arg.startsWith(SHARED_FLAG));
26
+ const ALLOW_UNLANDED = process.argv.slice(2).includes(ALLOW_UNLANDED_FLAG);
27
+ const positional = process.argv.slice(2).filter((arg) => !arg.startsWith(SHARED_FLAG) && arg !== ALLOW_UNLANDED_FLAG);
26
28
  const sharedArg = process.argv.slice(2).find((arg) => arg.startsWith(SHARED_FLAG));
27
29
  const PACKAGE_ROOT = positional[0] ? resolve(positional[0]) : resolve(dirname(fileURLToPath(import.meta.url)), '..');
28
30
  const RUNTIME_HOME = runtimeHome();
@@ -334,6 +336,7 @@ async function pruneGenerations() {
334
336
  if (!retained.has(id)) {
335
337
  await removeStage(join(GENERATIONS, id));
336
338
  await rm(publishedMarkerPath(GENERATIONS, id), { force: true });
339
+ await rm(sourcePath(id), { force: true });
337
340
  }
338
341
  }
339
342
  }
@@ -548,7 +551,17 @@ function loads(path) {
548
551
  });
549
552
  }
550
553
 
554
+ /** Where each generation's install came from, beside the sealed generation (`<id>.source.json`). */
555
+ const sourcePath = (id) => join(GENERATIONS, `${id}.source.json`);
556
+
551
557
  async function install() {
558
+ // CI installs the commit under test, which is not origin/main by design.
559
+ const source = process.env.CI ? undefined : readInstallSource(PACKAGE_ROOT);
560
+ const reasons = source === undefined ? undefined : unlandedReasons(source);
561
+ if (reasons !== undefined && !ALLOW_UNLANDED) {
562
+ process.stderr.write(`${refusalMessage(source, reasons)}\n`);
563
+ process.exit(1);
564
+ }
552
565
  await mkdir(GENERATIONS, { recursive: true });
553
566
  await acquireLock();
554
567
  cleanupState.lockTaken = true;
@@ -620,6 +633,9 @@ async function install() {
620
633
  // Only after the full-hash check above has succeeded for this exact id —
621
634
  // see `publishedMarkerPath`'s doc comment for the ordering invariant.
622
635
  await markPublished(GENERATIONS, id);
636
+ if (source !== undefined) {
637
+ await writeFile(sourcePath(id), `${JSON.stringify({ ...source, unlanded: reasons ?? [], installedAt: new Date().toISOString(), node: process.env.CRTR_NODE_ID ?? null, checkout: PACKAGE_ROOT })}\n`);
638
+ }
623
639
  const selected = join(RUNTIME_HOME, 'selected');
624
640
  temporary = join(RUNTIME_HOME, `.selected-${process.pid}-${Date.now()}`);
625
641
  cleanupState.temporary = temporary;
@@ -634,6 +650,7 @@ async function install() {
634
650
  }
635
651
  // stderr, not stdout: on a fresh install this runs inside the user's first `crtr` command, which may be `--json`.
636
652
  process.stderr.write(`Installed immutable crouter runtime generation ${id}\n`);
653
+ if (reasons !== undefined) process.stderr.write(`WARNING: this machine now runs unlanded code (${reasons.join('; ')}). Land it or reinstall from origin/main before you finish, and say so in your report.\n`);
637
654
  return { generation: id, version: pkg.version, selected };
638
655
  } finally {
639
656
  if (temporary) await rm(temporary, { force: true });
@@ -0,0 +1,49 @@
1
+ // The git state an install comes from. The selected generation is one pointer for the whole
2
+ // machine and the last install wins, so an install from code that is not on origin/main silently
3
+ // replaces landed work (or someone else's) for every crtr process here. An install from a git
4
+ // checkout is refused unless its HEAD is exactly origin/main with a clean tree; `--allow-unlanded`
5
+ // is the explicit bypass. A package root that is not a git checkout (the npm package, image builds)
6
+ // is not checked.
7
+ import { spawnSync } from 'node:child_process';
8
+
9
+ export const ALLOW_UNLANDED_FLAG = '--allow-unlanded';
10
+
11
+ function git(root, args) {
12
+ const result = spawnSync('git', args, { cwd: root, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'], timeout: 30_000 });
13
+ return result.status === 0 ? result.stdout.trim() : undefined;
14
+ }
15
+
16
+ /** The checkout's commit, branch, and how it differs from origin/main; undefined when `root` is not a git checkout. */
17
+ export function readInstallSource(root) {
18
+ if (git(root, ['rev-parse', '--is-inside-work-tree']) !== 'true') return undefined;
19
+ const fetched = spawnSync('git', ['fetch', '--quiet', 'origin', 'main'], { cwd: root, stdio: 'ignore', timeout: 30_000 }).status === 0;
20
+ const commit = git(root, ['rev-parse', 'HEAD']);
21
+ const branch = git(root, ['branch', '--show-current']) || '(detached)';
22
+ const dirty = (git(root, ['status', '--porcelain', '--untracked-files=no']) ?? '') !== '';
23
+ const counts = git(root, ['rev-list', '--left-right', '--count', 'origin/main...HEAD']);
24
+ const [behind, ahead] = counts === undefined ? [undefined, undefined] : counts.split(/\s+/).map(Number);
25
+ return { commit, branch, dirty, behind, ahead, fetched };
26
+ }
27
+
28
+ /** Why `source` may not be installed without the bypass, or undefined when it is exactly origin/main and clean. */
29
+ export function unlandedReasons(source) {
30
+ const reasons = [];
31
+ if (source.behind === undefined) reasons.push('origin/main could not be read, so this checkout cannot be compared with it');
32
+ if (source.behind > 0) reasons.push(`it is ${source.behind} commit(s) behind origin/main, so installing it removes work already landed there`);
33
+ if (source.ahead > 0) reasons.push(`it has ${source.ahead} commit(s) not on origin/main`);
34
+ if (source.dirty) reasons.push('it has uncommitted changes to tracked files');
35
+ return reasons.length > 0 ? reasons : undefined;
36
+ }
37
+
38
+ export function refusalMessage(source, reasons) {
39
+ return [
40
+ `Refused: this install is not origin/main (${source.branch} @ ${source.commit?.slice(0, 9) ?? 'unknown'}${source.fetched ? '' : '; fetching origin failed, so the comparison may be stale'}):`,
41
+ ...reasons.map((reason) => ` - ${reason}`),
42
+ '',
43
+ 'Every crtr process on this machine runs the installed runtime: the daemon, every node, every other agent. An install from code that is not on main replaces their runtime with yours, and the next install from main silently removes yours.',
44
+ '',
45
+ 'Land the work instead: commit it, rebase onto origin/main, push to main, then install from that checkout.',
46
+ '',
47
+ `To test unlanded code you may pass ${ALLOW_UNLANDED_FLAG}, but only when Silas approved installing unlanded code for this task. Even then, do not leave the machine in that state: land the work or reinstall from origin/main before you finish, and say in your report that you did.`,
48
+ ].join('\n');
49
+ }