@north-light/cli 0.3.712 → 0.3.714
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/input/controller.d.ts +8 -0
- package/dist/clients/attach/input/controller.js +3 -3
- package/dist/clients/attach/input/local-files.d.ts +18 -0
- package/dist/clients/attach/input/local-files.js +11 -0
- package/dist/clients/attach/render/chat-view.d.ts +1 -1
- package/dist/clients/attach/render/chat-view.js +2 -2
- package/dist/clients/attach/session/editor-frame.d.ts +2 -2
- package/dist/clients/attach/session/editor-frame.js +1 -1
- package/dist/clients/attach/session/input-wiring.d.ts +2 -0
- package/dist/clients/attach/session/input-wiring.js +1 -1
- package/dist/clients/attach/viewer.js +526 -517
- package/dist/commands/node/bash.js +1 -1
- package/dist/commands/node/inspect.js +5 -5
- package/dist/core/bash-guard.d.ts +10 -0
- package/dist/core/bash-guard.js +4 -4
- package/dist/core/broker-client/client.d.ts +2 -2
- package/dist/core/broker-client/client.js +1 -1
- package/dist/core/canvas/canvas.js +1 -1
- package/dist/core/canvas/deliveries.js +10 -10
- package/dist/core/canvas/schema-pg/029-model-accounts-refresh-claim.sql +3 -0
- package/dist/core/canvas/schema-version.d.ts +1 -1
- package/dist/core/canvas/schema-version.js +1 -1
- package/dist/core/canvas/types.d.ts +1 -0
- package/dist/core/checkout-identities.js +1 -1
- package/dist/core/conversation-store/row-store.js +1 -1
- package/dist/core/graph/documents.d.ts +5 -5
- package/dist/core/graph/documents.js +9 -9
- package/dist/core/graph/kinds/custom.js +2 -2
- package/dist/core/graph/kinds/document.js +4 -4
- package/dist/core/graph/kinds/environment.js +2 -2
- package/dist/core/graph/kinds/job.js +2 -2
- package/dist/core/graph/kinds/kind.d.ts +9 -1
- package/dist/core/graph/kinds/live-read.d.ts +4 -2
- package/dist/core/graph/kinds/live-read.js +1 -1
- package/dist/core/graph/kinds/node.js +5 -5
- package/dist/core/graph/kinds/owner.js +2 -2
- package/dist/core/import/load/bind.d.ts +8 -0
- package/dist/core/import/load/bind.js +15 -15
- package/dist/core/import/load/prepare.d.ts +8 -1
- package/dist/core/import/load/prepare.js +9 -7
- package/dist/core/import/load/run.js +2 -2
- package/dist/core/llm/run.d.ts +1 -1
- package/dist/core/pool-credential-store.d.ts +5 -5
- package/dist/core/runtime/bearings-render.d.ts +3 -0
- package/dist/core/runtime/bearings-render.js +7 -7
- package/dist/core/runtime/bearings.js +5 -5
- package/dist/core/runtime/broker/frame-dispatch.d.ts +2 -0
- package/dist/core/runtime/broker/frame-dispatch.js +1 -1
- package/dist/core/runtime/broker/frame-read.d.ts +5 -1
- package/dist/core/runtime/broker/frame-read.js +1 -1
- package/dist/core/runtime/broker-protocol.d.ts +37 -2
- package/dist/core/runtime/broker-wedge.d.ts +1 -2
- package/dist/core/runtime/broker-wedge.js +2 -2
- package/dist/core/subscription-state.d.ts +3 -3
- package/dist/core/subscription-state.js +1 -1
- package/dist/daemon/api/handlers/broker-ops.js +1 -1
- package/dist/daemon/api/handlers/llm.js +3 -3
- package/dist/daemon/api/handlers/objects.js +3 -3
- package/dist/daemon/api/handlers/reviews.js +1 -1
- package/dist/daemon/api/map.d.ts +6 -0
- package/dist/daemon/api/map.js +1 -1
- package/dist/daemon/fleet.d.ts +1 -12
- package/dist/daemon/fleet.js +2 -2
- package/dist/daemon/machine-daemon.js +1 -1
- package/dist/daemon/machine-link/holder.js +1 -1
- package/dist/daemon/reconcilers/broker-supervision.js +3 -3
- package/dist/daemon/reconcilers/node-lifecycle/tick.js +1 -1
- package/dist/pi-extensions/canvas-inbox-watcher.js +2 -2
- package/docs/ci-runner.md +4 -4
- package/package.json +3 -3
- package/packages/crouter-api/dist/clients/attach/input/controller.js +43 -12
- package/packages/crouter-api/dist/clients/attach/input/local-files.js +113 -0
- package/packages/crouter-api/dist/clients/attach/render/chat-view.js +9 -8
- package/packages/crouter-api/dist/clients/attach/session/editor-frame.js +27 -8
- package/packages/crouter-api/dist/clients/attach/session/input-wiring.js +1 -0
- package/packages/crouter-api/dist/clients/attach/viewer.js +15 -0
- package/packages/crouter-api/dist/commands/node/bash.js +2 -2
- package/packages/crouter-api/dist/commands/node/inspect.js +4 -3
- package/packages/crouter-api/dist/core/bash-guard.js +1 -1
- package/packages/crouter-api/dist/core/broker-client/client.js +1 -1
- package/packages/crouter-api/dist/core/canvas/canvas.js +1 -1
- package/packages/crouter-api/dist/core/canvas/deliveries.js +1 -1
- package/packages/crouter-api/dist/core/canvas/schema-version.js +1 -1
- package/packages/crouter-api/dist/core/checkout-identities.js +1 -1
- package/packages/crouter-api/dist/core/conversation-store/row-store.js +1 -1
- package/packages/crouter-api/dist/core/graph/documents.js +12 -24
- package/packages/crouter-api/dist/core/graph/kinds/custom.js +1 -3
- package/packages/crouter-api/dist/core/graph/kinds/document.js +8 -25
- package/packages/crouter-api/dist/core/graph/kinds/environment.js +1 -3
- package/packages/crouter-api/dist/core/graph/kinds/job.js +1 -3
- package/packages/crouter-api/dist/core/graph/kinds/node.js +1 -3
- package/packages/crouter-api/dist/core/graph/kinds/owner.js +1 -3
- package/packages/crouter-api/dist/core/import/load/prepare.js +21 -4
- package/packages/crouter-api/dist/core/llm/run.js +1 -1
- package/packages/crouter-api/dist/core/pool-credential-store.js +5 -5
- package/packages/crouter-api/dist/core/runtime/bearings-render.js +11 -0
- package/packages/crouter-api/dist/core/runtime/bearings.js +6 -2
- package/packages/crouter-api/dist/core/runtime/broker-wedge.js +1 -3
- package/packages/crouter-api/dist/core/subscription-state.js +70 -81
- package/packages/crouter-api/dist/daemon/api/handlers/broker-ops.js +5 -6
- package/packages/crouter-api/dist/daemon/api/map.js +1 -1
- package/packages/crouter-api/dist/daemon/machine-link/holder.js +1 -1
- package/packages/crouter-api/dist/daemon/reconcilers/broker-supervision.js +4 -4
- package/packages/crouter-api/dist/{clients/attach/chrome/git-info.js → shared/git-status.js} +5 -5
- package/packages/crouter-api/package.json +1 -1
- package/packages/crouter-identity/package.json +1 -1
- package/packages/crouter-plugin/package.json +3 -3
- package/runtime.lock.json +14 -14
- package/scripts/install-runtime.mjs +3 -2
- package/scripts/self-update.mjs +5 -1
- package/packages/crouter-api/dist/core/graph/kinds/live-read.js +0 -11
- /package/dist/{clients/attach/chrome/git-info.d.ts → shared/git-status.d.ts} +0 -0
- /package/dist/{clients/attach/chrome/git-info.js → shared/git-status.js} +0 -0
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
import { basename } from 'node:path';
|
|
9
9
|
import { modeIcon, personaLabel } from '../../../core/canvas/labels.js';
|
|
10
10
|
import { colorChipStyle, defaultTitleStyle, thinkingBorderColor, thinkingTitleStyle } from '../input/titled-editor.js';
|
|
11
|
-
import {
|
|
11
|
+
import { loadProfileManifest } from '../../../core/profiles/manifest.js';
|
|
12
12
|
/** Nerd Font terminal glyph marks a one-shot node; resident nodes need no
|
|
13
13
|
* lifecycle glyph because they persist by default. */
|
|
14
14
|
const TERMINAL_NODE_ICON = '\uf489';
|
|
@@ -62,7 +62,7 @@ export function displayEditorTitle(sessionName, identity) {
|
|
|
62
62
|
* and paints every frame-attached adornment — border hue, title chip, context
|
|
63
63
|
* badge, and git context. */
|
|
64
64
|
export function createEditorChrome(ctx, hooks) {
|
|
65
|
-
const { meta, tui, pal, editor } = ctx;
|
|
65
|
+
const { meta, tui, pal, editor, socket } = ctx;
|
|
66
66
|
// Shell/bash mode: the editor text leads with `!`. Tracks pi's interactive
|
|
67
67
|
// `isBashMode`, which recolors the editor border green as a visual cue (#7).
|
|
68
68
|
// Three levels: 0 = off, 1 = `!` (output goes to the agent's context), 2 = `!!`
|
|
@@ -72,11 +72,24 @@ export function createEditorChrome(ctx, hooks) {
|
|
|
72
72
|
// `/color` override for the name chip — null means the default (thinking-
|
|
73
73
|
// tracking) chip. Bash mode still wins: the green frame is a live safety cue.
|
|
74
74
|
let chipColor = null;
|
|
75
|
-
|
|
75
|
+
// The badge names the node's profile; a node without one (or whose manifest
|
|
76
|
+
// will not load here) falls back to the folder it runs in.
|
|
77
|
+
const profileLabel = (() => {
|
|
78
|
+
const id = meta.profile_id;
|
|
79
|
+
if (!id)
|
|
80
|
+
return basename(meta.cwd) || meta.cwd;
|
|
81
|
+
try {
|
|
82
|
+
return loadProfileManifest(id).manifest.name;
|
|
83
|
+
}
|
|
84
|
+
catch {
|
|
85
|
+
return id;
|
|
86
|
+
}
|
|
87
|
+
})();
|
|
88
|
+
const syncContextBadge = () => {
|
|
76
89
|
const identity = hooks.nodeIdentity();
|
|
77
90
|
const lifecycle = identity?.lifecycle === 'terminal' ? `${TERMINAL_NODE_ICON} ` : '';
|
|
78
91
|
const persona = identity ? ` · ${personaLabel(identity)}` : '';
|
|
79
|
-
editor.contextBadge = `${lifecycle}${
|
|
92
|
+
editor.contextBadge = `${lifecycle}${profileLabel}${persona}`;
|
|
80
93
|
};
|
|
81
94
|
// Paint the editor border + title chip. Shell/bash mode (leading `!`) wins and
|
|
82
95
|
// forces the whole frame green (#7); otherwise the hue tracks the thinking
|
|
@@ -105,8 +118,9 @@ export function createEditorChrome(ctx, hooks) {
|
|
|
105
118
|
tui.requestRender();
|
|
106
119
|
};
|
|
107
120
|
// Git context painted into the RIGHT of the editor's top border: branch and
|
|
108
|
-
// status symbols (● dirty, ⇡ ahead, ⇣ behind)
|
|
109
|
-
//
|
|
121
|
+
// status symbols (● dirty, ⇡ ahead, ⇣ behind) of the node's own working
|
|
122
|
+
// directory, read by its broker (the viewer may run on another machine).
|
|
123
|
+
// Refreshed by the poll.
|
|
110
124
|
const renderGitInfo = (info) => {
|
|
111
125
|
const parts = [];
|
|
112
126
|
if (info.branch)
|
|
@@ -122,9 +136,14 @@ export function createEditorChrome(ctx, hooks) {
|
|
|
122
136
|
parts.push(sym.join(''));
|
|
123
137
|
// A trailing space keeps the symbols off the very last border cell.
|
|
124
138
|
editor.info = parts.length > 0 ? ` ${parts.join(pal.muted(' · '))} ` : '';
|
|
125
|
-
syncContextBadge(info.dir);
|
|
126
139
|
tui.requestRender();
|
|
127
140
|
};
|
|
141
|
+
const pollGit = () => {
|
|
142
|
+
socket.request({ type: 'get_git_status' }).then((reply) => {
|
|
143
|
+
if (reply.kind === 'git_status')
|
|
144
|
+
renderGitInfo(reply);
|
|
145
|
+
}, () => { });
|
|
146
|
+
};
|
|
128
147
|
return {
|
|
129
148
|
bashMode: () => bashMode,
|
|
130
149
|
setChipColor: (color) => {
|
|
@@ -137,6 +156,6 @@ export function createEditorChrome(ctx, hooks) {
|
|
|
137
156
|
editor.title = displayEditorTitle(sessionName, hooks.nodeIdentity());
|
|
138
157
|
},
|
|
139
158
|
syncContextBadge: () => syncContextBadge(),
|
|
140
|
-
pollGit
|
|
159
|
+
pollGit,
|
|
141
160
|
};
|
|
142
161
|
}
|
|
@@ -93,6 +93,7 @@ export function createInputController(ctx, km, capabilities, hooks) {
|
|
|
93
93
|
onColor: hooks.setChipColor,
|
|
94
94
|
onPromptSent: hooks.onPromptSent,
|
|
95
95
|
onMessageSent: hooks.onMessageSent,
|
|
96
|
+
whenBrokerReady: hooks.whenBrokerReady,
|
|
96
97
|
frecency: hooks.frecency,
|
|
97
98
|
knownRefNames: () => editor.getResolvedRefNames(),
|
|
98
99
|
// Global display toggles (Ctrl+O tools / Ctrl+T thinking) — pure render
|
|
@@ -462,9 +462,22 @@ onConnected) {
|
|
|
462
462
|
socket.send(frame);
|
|
463
463
|
reconnect.probe();
|
|
464
464
|
};
|
|
465
|
+
// Uploading a file needs the broker: a message naming one waits here for the first welcome, at most a minute.
|
|
466
|
+
let brokerReadyResolve = () => { };
|
|
467
|
+
const brokerReady = new Promise((resolve) => { brokerReadyResolve = resolve; });
|
|
468
|
+
const whenBrokerReady = () => {
|
|
469
|
+
if (welcomed)
|
|
470
|
+
return Promise.resolve(true);
|
|
471
|
+
if (settled)
|
|
472
|
+
return Promise.resolve(false);
|
|
473
|
+
let timer;
|
|
474
|
+
const timeout = new Promise((resolve) => { timer = setTimeout(() => resolve(false), 60_000); timer.unref?.(); });
|
|
475
|
+
return Promise.race([brokerReady, timeout]).finally(() => clearTimeout(timer));
|
|
476
|
+
};
|
|
465
477
|
const onFirstWelcome = () => {
|
|
466
478
|
welcomed = true;
|
|
467
479
|
settled = true;
|
|
480
|
+
brokerReadyResolve(true);
|
|
468
481
|
for (const frame of heldFrames.splice(0))
|
|
469
482
|
socket.send(frame);
|
|
470
483
|
};
|
|
@@ -492,6 +505,7 @@ onConnected) {
|
|
|
492
505
|
},
|
|
493
506
|
onMessageSent: (text, viaSocket) => chatView.addPendingSend(text, viaSocket),
|
|
494
507
|
send: sendToBroker,
|
|
508
|
+
whenBrokerReady,
|
|
495
509
|
frecency,
|
|
496
510
|
});
|
|
497
511
|
const whip = () => {
|
|
@@ -912,6 +926,7 @@ onConnected) {
|
|
|
912
926
|
// Text sent while the dial was still running has no broker to hold it: deliver it as the wake message a parked viewer's own sends use.
|
|
913
927
|
// An engine command (`/x`, `!x`) is refused as a later parked submission is, and returned to the editor.
|
|
914
928
|
settled = true;
|
|
929
|
+
brokerReadyResolve(false);
|
|
915
930
|
chatView.stopResendingPendingSends();
|
|
916
931
|
const refused = [];
|
|
917
932
|
for (const frame of heldFrames.splice(0)) {
|
|
@@ -69,8 +69,8 @@ const nodeBashRun = defineLeaf({
|
|
|
69
69
|
throw new InputError({ error: 'no_node', message: '`node bash run` starts a job for the calling node and works only inside a node’s bash tool', next: 'Run it from a node’s bash tool call.' });
|
|
70
70
|
}
|
|
71
71
|
const cwd = process.cwd();
|
|
72
|
-
const {
|
|
73
|
-
const refusal =
|
|
72
|
+
const { destructiveCommandRefusal } = await import('../../core/bash-guard.js');
|
|
73
|
+
const refusal = destructiveCommandRefusal(command, cwd);
|
|
74
74
|
if (refusal !== null) {
|
|
75
75
|
throw new InputError({ error: 'refused', message: refusal, next: 'Run a different command.' });
|
|
76
76
|
}
|
|
@@ -175,9 +175,10 @@ const nodeShow = defineLeaf({
|
|
|
175
175
|
hints.push(`Drill into a child/report: \`crtr node inspect show <node_id>\` (${reports.map((r) => r['node_id']).join(', ')}).`);
|
|
176
176
|
hints.push(`Full machine dump (system prompt + all telemetry): \`crtr --json node inspect show ${id}\`.`);
|
|
177
177
|
const result = { node, fault: node.fault ?? null, reports, managers, pending_crons, paths, follow_up: hints.join('\n') };
|
|
178
|
-
// The environment read answers 400 for a profile that runs on a machine
|
|
179
|
-
|
|
180
|
-
|
|
178
|
+
// The environment read answers 400 for a profile that runs on a machine, and 404 for a profile the caller cannot see
|
|
179
|
+
// (another app's): reading a node does not require its owning profile to be visible, so that is not a failure.
|
|
180
|
+
const inSandbox = node.runner === 'blaxel' || node.profile_id !== null && await client.getProfileEnvironment(node.profile_id).then(() => true, (err) => {
|
|
181
|
+
if (err instanceof ApiError && (err.status === 400 || err.status === 404))
|
|
181
182
|
return false;
|
|
182
183
|
return rethrowAsCliError(err);
|
|
183
184
|
});
|
|
@@ -436,7 +436,7 @@ function broadSearchRefusalMessage(segment, target, reason) {
|
|
|
436
436
|
* `rm -rf "$HOME"` is a scratch directory and runs. A `HOME=/tmp/x cmd`
|
|
437
437
|
* PREFIX applies to that one command only, so a later `rm -rf "$HOME"` is the
|
|
438
438
|
* real home — which is precisely the mistake that destroyed one. */
|
|
439
|
-
function destructiveCommandRefusal(command, cwd, home) {
|
|
439
|
+
export function destructiveCommandRefusal(command, cwd, home = homedir()) {
|
|
440
440
|
const vars = initialVariables(home, cwd);
|
|
441
441
|
// Every directory a relative operand might be resolved from. A `cd` ADDS its
|
|
442
442
|
// destination rather than replacing the previous one, because the guard
|
|
@@ -164,7 +164,7 @@ export class BrokerClient extends EventEmitter {
|
|
|
164
164
|
const entry = this.pending.get(frame.id);
|
|
165
165
|
this.pending.delete(frame.id);
|
|
166
166
|
clearTimeout(entry.timer);
|
|
167
|
-
entry.reject(new Error(frame.message || `request failed: ${frame.code}`));
|
|
167
|
+
entry.reject(Object.assign(new Error(frame.message || `request failed: ${frame.code}`), { code: frame.code }));
|
|
168
168
|
return;
|
|
169
169
|
}
|
|
170
170
|
this.emit('frame', frame);
|
|
@@ -108,6 +108,7 @@ function rowFrom(r) {
|
|
|
108
108
|
parent: r['parent'] ?? null,
|
|
109
109
|
created: r['created'],
|
|
110
110
|
intent: r['intent'] ?? null,
|
|
111
|
+
cycle_pending: r['cycle_pending'] === 1,
|
|
111
112
|
frozen_at: r['frozen_at'] ?? null,
|
|
112
113
|
respawn_failures: r['respawn_failures'] ?? 0,
|
|
113
114
|
respawn_not_before: r['respawn_not_before'] ?? null,
|
|
@@ -153,7 +154,6 @@ async function metaFrom(r, worktree) {
|
|
|
153
154
|
fork_from: r['fork_from'] ?? null,
|
|
154
155
|
fork_source_file: r['fork_source_file'] ?? null,
|
|
155
156
|
passive_default: r['passive_default'] === 1,
|
|
156
|
-
cycle_pending: r['cycle_pending'] === 1,
|
|
157
157
|
model_override: r['model_override'] ?? null,
|
|
158
158
|
scopes: r['scopes_json'] == null ? null : JSON.parse(r['scopes_json']),
|
|
159
159
|
persona_ack: r['persona_ack_json'] == null ? undefined : JSON.parse(r['persona_ack_json']),
|
|
@@ -30,7 +30,7 @@ export function deliveryFrom(row) {
|
|
|
30
30
|
}
|
|
31
31
|
async function executionIsLive(db, nodeId, executionId, rejectRefresh) {
|
|
32
32
|
const row = await db.prepare(`SELECT 1 FROM nodes n JOIN executions e ON e.node_id = n.node_id
|
|
33
|
-
WHERE n.node_id = ? AND e.execution_id = ? AND e.state != 'exited' AND e.stop_reason IS DISTINCT FROM 'release'${rejectRefresh ? " AND n.intent IS DISTINCT FROM 'refresh'" : ''}`).get(nodeId, executionId);
|
|
33
|
+
WHERE n.node_id = ? AND e.execution_id = ? AND e.state != 'exited' AND e.stop_reason IS DISTINCT FROM 'release'${rejectRefresh ? " AND n.intent IS DISTINCT FROM 'refresh' AND n.cycle_pending = 0" : ''}`).get(nodeId, executionId);
|
|
34
34
|
return row !== undefined;
|
|
35
35
|
}
|
|
36
36
|
async function nodeMailRows(db, nodeId, executionId, wake, freshIds, deferredRun = false) {
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
/** The canvas schema version this build supports: the number of the highest delta in `schema-pg/` (the baseline
|
|
7
7
|
* `schema-pg.sql` is version 1). `scripts/install-runtime.mjs` reads this module from a candidate generation to refuse
|
|
8
8
|
* one below the live database's `schema_min_reader`. */
|
|
9
|
-
export const CANVAS_SCHEMA_VERSION =
|
|
9
|
+
export const CANVAS_SCHEMA_VERSION = 29;
|
|
10
10
|
/** The Postgres schema holding the canvas tables: `CRTR_DATABASE_SCHEMA` (`crtr` in the cloud deploy). Unset or empty
|
|
11
11
|
* means the role's own search_path (`public` on a Mac and on a VM). A name that is not a plain identifier is an error:
|
|
12
12
|
* it is put in a `search_path` connection option. */
|
|
@@ -30,7 +30,7 @@ export const machineCheckoutHandlers = {
|
|
|
30
30
|
// ---------------------------------------------------------------------------------------------------------------- the control plane's side
|
|
31
31
|
/** Ask the Mac for the checkout chains of `dirs` and store the answers. A call that fails (offline, lost, refused) stores nothing and returns false. */
|
|
32
32
|
export async function warmMachineCheckouts(environment, dirs) {
|
|
33
|
-
const wanted = [...new Set(dirs.map((d) => resolve(d)))];
|
|
33
|
+
const wanted = [...new Set(dirs.map((d) => resolve(d)))].sort(); // one row order for every writer, so two warms of one Mac cannot deadlock
|
|
34
34
|
if (wanted.length === 0)
|
|
35
35
|
return true;
|
|
36
36
|
let answer;
|
|
@@ -332,9 +332,9 @@ export function createRowStore() {
|
|
|
332
332
|
const db = await openDb();
|
|
333
333
|
const old = await parts(db, id);
|
|
334
334
|
await withCanvasWrite(async (tx) => {
|
|
335
|
+
await tx.prepare('DELETE FROM sessions WHERE session_id = ?').run(id);
|
|
335
336
|
await tx.prepare('DELETE FROM conversation_entries WHERE conversation_id = ?').run(id);
|
|
336
337
|
await tx.prepare('DELETE FROM conversation_parts WHERE conversation_id = ?').run(id);
|
|
337
|
-
await tx.prepare('DELETE FROM sessions WHERE session_id = ?').run(id);
|
|
338
338
|
});
|
|
339
339
|
for (const part of old)
|
|
340
340
|
await (await blobStore()).delete(part.blob_key);
|
|
@@ -99,7 +99,7 @@ export async function heads(db, doc) {
|
|
|
99
99
|
AND NOT EXISTS (SELECT 1 FROM revision_parents p WHERE p.parent = r.rev_id) ORDER BY r.number DESC, r.rev_id`).all(doc.id);
|
|
100
100
|
return (await mapAsync(raws, async (r) => await toRevision(db, r)));
|
|
101
101
|
}
|
|
102
|
-
function headsKeyOf(revs) {
|
|
102
|
+
export function headsKeyOf(revs) {
|
|
103
103
|
return revs.map((r) => r.rev_id).sort().join(',');
|
|
104
104
|
}
|
|
105
105
|
export async function documentRecord(db, doc) {
|
|
@@ -447,32 +447,20 @@ export async function setDocumentRecord(db, reader, doc, fields, rationale) {
|
|
|
447
447
|
}, { savepoint: true });
|
|
448
448
|
}
|
|
449
449
|
// ── read and history ───────────────────────────────────────────────────────
|
|
450
|
-
/** Record that the reader holds the document's current heads: a `read` watch with that read
|
|
451
|
-
* base, and a `read` push. Delivery's content load calls this without reading the body. */
|
|
452
|
-
export async function recordRead(db, reader, doc, reposFn) {
|
|
453
|
-
const actor = actorOf(reader);
|
|
454
|
-
const { heads_key } = await documentRecord(db, doc);
|
|
455
|
-
await recordWatch(db, actor, doc, 'read', { readHeadsKey: heads_key });
|
|
456
|
-
await publish(db, { event: 'read', object: doc, actor, attrs: {} }, reposFn);
|
|
457
|
-
}
|
|
458
450
|
/** The document's record, each head with its body (several = needs merge) and its links under
|
|
459
|
-
* their current names
|
|
460
|
-
export async function readDocument(db, reader, doc
|
|
451
|
+
* their current names. Records nothing. */
|
|
452
|
+
export async function readDocument(db, reader, doc) {
|
|
461
453
|
assertDocument(doc);
|
|
462
454
|
await readable(db, reader, doc);
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
if (!doc.deleted_at)
|
|
473
|
-
await recordRead(db, reader, doc, reposFn);
|
|
474
|
-
return { object: doc, record, heads: current, needsMerge: current.length > 1, links };
|
|
475
|
-
}, { savepoint: true });
|
|
455
|
+
const record = await documentRecord(db, doc);
|
|
456
|
+
const headRows = await heads(db, doc);
|
|
457
|
+
const texts = await getBodies(db, headRows.map((h) => h.body_hash));
|
|
458
|
+
const current = await mapAsync(headRows, async (h) => ({ ...h, body: await withCurrentNames(db, doc, texts.get(h.body_hash)) }));
|
|
459
|
+
const read = await readableOrDeleted(db, await resolveReader(db, reader), 'o');
|
|
460
|
+
const linked = await db.prepareUncached(`SELECT e.written_as AS _written_as, o.* FROM edges e JOIN objects o ON o.id = e.dst
|
|
461
|
+
WHERE e.type = 'links-to' AND e.src = ? AND (${read.sql}) ORDER BY e.written_as`).all(doc.id, ...read.params);
|
|
462
|
+
const links = linked.map(({ _written_as, ...object }) => ({ written_as: _written_as ?? '', object: object, deleted: object.deleted_at !== null }));
|
|
463
|
+
return { object: doc, record, heads: current, needsMerge: current.length > 1, links };
|
|
476
464
|
}
|
|
477
465
|
/** Every revision, newest first, with authors, rationales and parents. Records nothing. */
|
|
478
466
|
export async function history(db, reader, doc) {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { recordLiveRead } from './live-read.js';
|
|
2
1
|
import { header } from './render.js';
|
|
3
2
|
import { objectDTO } from './dto.js';
|
|
4
3
|
import { receiverForObject } from '../receivers.js';
|
|
@@ -10,8 +9,7 @@ export function customKind(name, declared) {
|
|
|
10
9
|
created: { level: 4 }, read: { level: 1 }, watched: { level: 1 },
|
|
11
10
|
deleted: { level: 5 }, configured: { level: 1 }, ...events,
|
|
12
11
|
}, addressable: 'name', receiverFor: receiverForObject,
|
|
13
|
-
async read(db,
|
|
14
|
-
await recordLiveRead(db, reader, object, opts.reposFn);
|
|
12
|
+
async read(db, _reader, object) {
|
|
15
13
|
const row = await db.prepare('SELECT description, summary, state_json, published_at, receiver_json, dropped FROM custom_objects WHERE object = ?')
|
|
16
14
|
.get(object.id);
|
|
17
15
|
const receiver = row?.receiver_json == null ? null : JSON.parse(row.receiver_json);
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { deliveryDocOf, nodeSubject, ownerHandle } from '../../substrate/delivery/corpus.js';
|
|
3
|
-
import { recordContentDelivery } from '../../substrate/delivery/deliver.js';
|
|
1
|
+
import { deliveryDocOf, nodeSubject } from '../../substrate/delivery/corpus.js';
|
|
4
2
|
import { renderExplicitRead } from '../../substrate/delivery/render-event.js';
|
|
5
3
|
import { permits, resolveReader } from '../../permissions/evaluator.js';
|
|
6
|
-
import { documentRecord, readDocument } from '../documents.js';
|
|
7
|
-
import { loadLedger
|
|
8
|
-
import { getById } from '../objects.js';
|
|
4
|
+
import { documentRecord, headsKeyOf, readDocument } from '../documents.js';
|
|
5
|
+
import { loadLedger } from '../exposures.js';
|
|
9
6
|
import { rulesOf } from '../rules.js';
|
|
10
7
|
import { objectDTO, objectDTOs } from './dto.js';
|
|
11
8
|
import { withBase } from './kind.js';
|
|
@@ -28,21 +25,7 @@ async function explicitReadAttachments(db, reader, doc) {
|
|
|
28
25
|
const ledger = isNode ? await loadLedger(db, reader.node.id) : { node: '', preferenceSnapshot: null, objects: new Map(), listed: new Map() };
|
|
29
26
|
const ctx = { db, reader, subject: isNode ? await nodeSubject(db, reader) : null, ledger, channel: 'transcript' };
|
|
30
27
|
const read = await renderExplicitRead(ctx, await deliveryDocOf(db, reader, doc));
|
|
31
|
-
|
|
32
|
-
await recordContentDelivery(db, reader, read.delivered);
|
|
33
|
-
await saveLedger(db, ledger);
|
|
34
|
-
}
|
|
35
|
-
return { attachments: read.attachments, linked: read.linked.map((d) => d.object) };
|
|
36
|
-
}
|
|
37
|
-
/** A node's explicit read of a knowledge or preference document is the analytics memory log's
|
|
38
|
-
* `read` event; its companions are `loaded` rows, written by `recordContentDelivery`. */
|
|
39
|
-
async function recordExplicitMemoryRead(db, reader, doc) {
|
|
40
|
-
if (reader.class !== 'node' || (doc.kind !== 'knowledge' && doc.kind !== 'preference') || doc.owner === null)
|
|
41
|
-
return;
|
|
42
|
-
const owner = await getById(db, doc.owner);
|
|
43
|
-
if (owner === null)
|
|
44
|
-
return;
|
|
45
|
-
await recordMemoryReadsIn(db, reader.node.id, [{ name: doc.name, scope: ownerHandle(owner), at: new Date().toISOString(), type: 'read' }]);
|
|
28
|
+
return { attachments: read.attachments, linked: read.linked.map((d) => d.object), ...(isNode ? { ledger } : {}), delivered: read.delivered };
|
|
46
29
|
}
|
|
47
30
|
function render(o, d) {
|
|
48
31
|
const lines = [];
|
|
@@ -104,11 +87,10 @@ export const documentKind = {
|
|
|
104
87
|
return { summary: (await documentRecord(db, doc)).summary ?? null, rules: (await rulesOf(db, doc)).length };
|
|
105
88
|
},
|
|
106
89
|
async read(db, reader, doc, opts) {
|
|
107
|
-
const read = await readDocument(db, reader, doc
|
|
108
|
-
await recordExplicitMemoryRead(db, reader, doc);
|
|
90
|
+
const read = await readDocument(db, reader, doc);
|
|
109
91
|
const rec = read.record;
|
|
110
92
|
const under = await listingOf(db, await resolveReader(db, reader), doc);
|
|
111
|
-
const { attachments, linked } = await explicitReadAttachments(db, reader, doc);
|
|
93
|
+
const { attachments, linked, ledger, delivered } = await explicitReadAttachments(db, reader, doc);
|
|
112
94
|
const listed = new Set(under.map((o) => o.id));
|
|
113
95
|
const listing = [...under, ...await objectDTOs(db, linked.filter((o) => !listed.has(o.id)))];
|
|
114
96
|
const data = {
|
|
@@ -127,6 +109,7 @@ export const documentKind = {
|
|
|
127
109
|
})),
|
|
128
110
|
};
|
|
129
111
|
}
|
|
130
|
-
return { data: data, text: render(await objectDTO(db, doc), data)
|
|
112
|
+
return { data: data, text: render(await objectDTO(db, doc), data),
|
|
113
|
+
record: { headsKey: headsKeyOf(read.heads), ...(ledger === undefined ? {} : { ledger }), delivered } };
|
|
131
114
|
},
|
|
132
115
|
};
|
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
/** The environment kind: a place objects run. Today only the machine an install runs on. */
|
|
2
2
|
import { objectDTO } from './dto.js';
|
|
3
3
|
import { withBase } from './kind.js';
|
|
4
|
-
import { recordLiveRead } from './live-read.js';
|
|
5
4
|
import { attr, header } from './render.js';
|
|
6
5
|
export const environmentKind = {
|
|
7
6
|
name: 'environment',
|
|
8
7
|
addressable: 'id',
|
|
9
8
|
events: withBase(),
|
|
10
|
-
async read(db,
|
|
9
|
+
async read(db, _reader, environment) {
|
|
11
10
|
const row = await db.prepare('SELECT kind, machine_id, last_seen_at FROM environments WHERE object = ?').get(environment.id);
|
|
12
11
|
if (!row)
|
|
13
12
|
throw new Error(`environment object ${environment.id} has no environments row`);
|
|
14
|
-
await recordLiveRead(db, reader, environment, opts.reposFn);
|
|
15
13
|
const o = await objectDTO(db, environment);
|
|
16
14
|
const data = { kind: row.kind, machine_id: row.machine_id, last_seen_at: row.last_seen_at };
|
|
17
15
|
const text = [header('object', o, attr('machine_id', data.machine_id) + attr('last_seen_at', data.last_seen_at)),
|
|
@@ -2,17 +2,15 @@
|
|
|
2
2
|
import { jobRow } from '../jobs.js';
|
|
3
3
|
import { objectDTO } from './dto.js';
|
|
4
4
|
import { withBase } from './kind.js';
|
|
5
|
-
import { recordLiveRead } from './live-read.js';
|
|
6
5
|
import { attr, header } from './render.js';
|
|
7
6
|
export const jobKind = {
|
|
8
7
|
name: 'job',
|
|
9
8
|
addressable: 'id',
|
|
10
9
|
events: withBase({ exited: { level: 7 }, killed: { level: 7 }, silent: { level: 7 } }),
|
|
11
|
-
async read(db,
|
|
10
|
+
async read(db, _reader, job) {
|
|
12
11
|
const row = await jobRow(db, job);
|
|
13
12
|
if (!row)
|
|
14
13
|
throw new Error(`job object ${job.id} has no jobs row`);
|
|
15
|
-
await recordLiveRead(db, reader, job, opts.reposFn);
|
|
16
14
|
const o = await objectDTO(db, job);
|
|
17
15
|
const data = { command: row.command, status: row.status, exit_code: row.exit_code, output_key: row.output_key };
|
|
18
16
|
const text = [
|
|
@@ -6,7 +6,6 @@ import { readGoal } from '../../runtime/kickoff.js';
|
|
|
6
6
|
import { permits, resolveReader } from '../../permissions/evaluator.js';
|
|
7
7
|
import { objectDTO } from './dto.js';
|
|
8
8
|
import { withBase } from './kind.js';
|
|
9
|
-
import { recordLiveRead } from './live-read.js';
|
|
10
9
|
import { attr, header, section } from './render.js';
|
|
11
10
|
import { mapAsync } from '../../async-array.js';
|
|
12
11
|
const TIERED = [3, 5, 7];
|
|
@@ -65,14 +64,13 @@ export const nodeKind = {
|
|
|
65
64
|
'notice.deadline': { level: 5, levels: TIERED, durable: true, carriesBody: true, elevatesTier: true },
|
|
66
65
|
'notice.close': { level: 5, levels: TIERED, durable: true, carriesBody: true, elevatesTier: true },
|
|
67
66
|
}),
|
|
68
|
-
async read(db, reader, node
|
|
67
|
+
async read(db, reader, node) {
|
|
69
68
|
const row = await db.prepare('SELECT status FROM nodes WHERE node_id = ?').get(node.id);
|
|
70
69
|
const read = await permits(db, await resolveReader(db, reader), 'read', 'o');
|
|
71
70
|
const visible = async (rows) => await mapAsync(rows, async (o) => await objectDTO(db, o));
|
|
72
71
|
const children = await db.prepareUncached(`SELECT o.* FROM nodes n JOIN objects o ON o.id = n.node_id
|
|
73
72
|
WHERE n.parent = ? AND o.deleted_at IS NULL AND ${read.sql} ORDER BY o.seq`).all(node.id, ...read.params);
|
|
74
73
|
const owned = await db.prepareUncached(`SELECT o.* FROM objects o WHERE o.owner = ? AND o.deleted_at IS NULL AND ${read.sql} ORDER BY o.seq`).all(node.id, ...read.params);
|
|
75
|
-
await recordLiveRead(db, reader, node, opts.reposFn);
|
|
76
74
|
const data = {
|
|
77
75
|
status: row?.status ?? 'deleted', mandate_first_line: firstLine(await readGoal(node.id)), children: await visible(children),
|
|
78
76
|
owned: await visible(owned.filter((o) => o.type !== 'job')), jobs: await visible(owned.filter((o) => o.type === 'job')),
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
/** The owner kinds — person, app, repo, profile, group: identities that own objects. Base events only. */
|
|
2
2
|
import { objectDTO } from './dto.js';
|
|
3
3
|
import { withBase } from './kind.js';
|
|
4
|
-
import { recordLiveRead } from './live-read.js';
|
|
5
4
|
import { header } from './render.js';
|
|
6
5
|
function ownerKind(name) {
|
|
7
6
|
return {
|
|
8
7
|
name,
|
|
9
8
|
addressable: 'handle',
|
|
10
9
|
events: withBase(),
|
|
11
|
-
async read(db,
|
|
10
|
+
async read(db, _reader, owner) {
|
|
12
11
|
const id = await db.prepare('SELECT scheme, external_id FROM identities WHERE object = ?').get(owner.id);
|
|
13
|
-
await recordLiveRead(db, reader, owner, opts.reposFn);
|
|
14
12
|
const data = {
|
|
15
13
|
handle: owner.name, display_name: owner.preview || owner.name,
|
|
16
14
|
identity: { scheme: id?.scheme ?? '', external_id: id?.external_id ?? '' },
|
|
@@ -81,20 +81,37 @@ function rewriteJsonPaths(text, map) {
|
|
|
81
81
|
return mapPath(map, text);
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
|
-
/** A profile whose name
|
|
84
|
+
/** A profile whose name another profile already holds is renamed `<name>-<install id>` (staging only; runs before the pre-check), in its `profiles` row and in its `profile`
|
|
85
|
+
* object's handle. The name clashes when the person already uses it for another profile, or when the object's handle is held by any other live profile object: `objects_handle`
|
|
86
|
+
* is unique per type across the whole fleet, so another person's profile counts. Only a handle that is the profile's name moves (a cloud role's handle is the profile id).
|
|
87
|
+
* The new name is a function of the install, so a second load of the bundle derives the same one. Runs after `mapProfileIds`, which leaves the staged identity at the profile's id. */
|
|
85
88
|
export async function renameClashingProfiles(db, schema, target, installId, person) {
|
|
86
89
|
const S = (t) => sq(schema, t);
|
|
87
90
|
const profiles = await db.prepareUncached(`SELECT id, name FROM ${S('profiles')} ORDER BY id`).all();
|
|
88
91
|
let renamed = 0;
|
|
89
92
|
for (const profile of profiles) {
|
|
90
|
-
const
|
|
91
|
-
|
|
93
|
+
const object = await db.prepareUncached(`SELECT o.id FROM ${S('objects')} o JOIN ${S('identities')} i ON i.object = o.id AND i.scheme = 'profile' AND i.external_id = ?
|
|
94
|
+
WHERE o.type = 'profile' AND o.name = ?`).get(profile.id, profile.name);
|
|
95
|
+
const sameName = await db.prepareUncached(`SELECT 1 AS found FROM ${sq(target, 'profiles')} WHERE person = ? AND name = ? AND id <> ?`).get(person, profile.name, profile.id);
|
|
96
|
+
const handleHeld = object === undefined ? undefined : await db.prepareUncached(`SELECT 1 AS found FROM ${sq(target, 'objects')} WHERE type = 'profile' AND home_machine IS NULL AND name = ? AND id <> ?`).get(profile.name, object.id);
|
|
97
|
+
if (sameName === undefined && handleHeld === undefined)
|
|
92
98
|
continue;
|
|
93
|
-
|
|
99
|
+
const next = `${profile.name}-${installId}`;
|
|
100
|
+
await db.prepareUncached(`UPDATE ${S('profiles')} SET name = ? WHERE id = ?`).run(next, profile.id);
|
|
101
|
+
if (object !== undefined)
|
|
102
|
+
await db.prepareUncached(`UPDATE ${S('objects')} SET name = ? WHERE id = ?`).run(next, object.id);
|
|
94
103
|
renamed += 1;
|
|
95
104
|
}
|
|
96
105
|
return renamed;
|
|
97
106
|
}
|
|
107
|
+
/** A migrated usage charge (`legacy:` id, `importLegacyUsage`) has no install id, so two Macs of one person with usage in the same month and model produce one id with
|
|
108
|
+
* different amounts. A staged one whose id the target holds with a different payer, units or usd is renamed `<id>:install-<install id>`; one the target holds unchanged keeps its
|
|
109
|
+
* id and is skipped by the copy. A second load of the same bundle derives the same id. Runs before the pre-check. */
|
|
110
|
+
export async function renameClashingLegacyCharges(db, schema, target, installId) {
|
|
111
|
+
const done = await db.prepareUncached(`UPDATE ${sq(schema, 'charges')} s SET id = s.id || ':install-' || ?::text FROM ${sq(target, 'charges')} t
|
|
112
|
+
WHERE s.id LIKE 'legacy:%' AND t.id = s.id AND (s.payer IS DISTINCT FROM t.payer OR s.units IS DISTINCT FROM t.units OR s.usd IS DISTINCT FROM t.usd)`).run(installId);
|
|
113
|
+
return Number(done.changes);
|
|
114
|
+
}
|
|
98
115
|
/** Fill: a staged profile with no environment gets the source's machine environment (a Mac) or the person's Blaxel environment (hosted, created if
|
|
99
116
|
* absent). Runs in the copy transaction: it writes target objects. */
|
|
100
117
|
export async function fillEnvironments(tx, schema, target, source, person) {
|
|
@@ -44,7 +44,7 @@ function refreshFailure(error, served) {
|
|
|
44
44
|
return error;
|
|
45
45
|
return new RunError(503, 'upstream_model_unavailable', message.slice(0, 500), undefined, { served_model: served });
|
|
46
46
|
}
|
|
47
|
-
/** The account's access token, refreshed under the
|
|
47
|
+
/** The account's access token, refreshed under the account's refresh claim (no connection held during the vendor call) when it has expired. Throws the vendor's refusal unchanged (a rejected refresh token is `isInvalidRefreshTokenError`, and the pool has already flagged the row); a vendor that is unreachable, or a refresh already in flight too long, is the retryable `503 upstream_model_unavailable`. */
|
|
48
48
|
export async function freshSubscriptionAccess(registry, provider, account, served, signal) {
|
|
49
49
|
if (account.expires > Date.now())
|
|
50
50
|
return account.access;
|
|
@@ -69,11 +69,11 @@ export class PoolCredentialStore {
|
|
|
69
69
|
return listedCredentials(stored, (providerId) => sizes.get(providerId) ?? 0);
|
|
70
70
|
}
|
|
71
71
|
/**
|
|
72
|
-
* pi's
|
|
73
|
-
*
|
|
74
|
-
* expired account
|
|
75
|
-
* `invalid_grant`.
|
|
76
|
-
* back on exactly the account whose token was spent.
|
|
72
|
+
* pi's read-modify-write, chiefly its OAuth refresh. Running pi's `fn` and committing the result
|
|
73
|
+
* happen under the account's refresh claim, because a refresh token is single-use: two brokers
|
|
74
|
+
* refreshing the same expired account without it would both spend it and the loser would get a
|
|
75
|
+
* genuine `invalid_grant`. The commit is conditional on the spent token, so the refreshed token
|
|
76
|
+
* lands back on exactly the account whose token was spent.
|
|
77
77
|
*
|
|
78
78
|
* A managed provider with no pool account is NOT created here — pi must not be able to mint a
|
|
79
79
|
* managed account behind crouter's login surfaces, which own the account-identity gate.
|
|
@@ -172,6 +172,17 @@ export function contextDirNote(nodeId, grantee) {
|
|
|
172
172
|
'scripts, data, logs and page modules. Your working dir is the project, NOT this directory, so a ' +
|
|
173
173
|
'bare relative `context/...` lands in the repo, not here.');
|
|
174
174
|
}
|
|
175
|
+
/** Where the node's engine and shell run, by the runner of its latest execution. A cloud sandbox is not the person's
|
|
176
|
+
* computer, so a path from their Mac (a pasted screenshot's temp file, a `/Users/...` path) does not exist there. */
|
|
177
|
+
export function whereYouRunNote(runner) {
|
|
178
|
+
if (runner === 'blaxel') {
|
|
179
|
+
return 'You run in a cloud sandbox, not on the person\'s computer. A file path from their Mac (such as `/Users/...` or `/var/folders/...`) does not exist here; their Mac\'s files and shell are reached through `crtr device`.';
|
|
180
|
+
}
|
|
181
|
+
if (runner === 'process' || runner === 'machine') {
|
|
182
|
+
return 'You run on the person\'s own computer: file paths they give you exist here.';
|
|
183
|
+
}
|
|
184
|
+
return '';
|
|
185
|
+
}
|
|
175
186
|
/** The profile-purview note — rendered ONLY when the profile resolves to a
|
|
176
187
|
* manifest that names at least one project dir. Phrased as PURVIEW, not a cwd
|
|
177
188
|
* replacement: the node's cwd is still its one working dir (bash/edits run
|
|
@@ -15,7 +15,7 @@ import { cadenceDisplay } from '../wake.js';
|
|
|
15
15
|
import { renderKnowledge, renderWorkspaceOpen } from '../substrate/delivery/render-boot.js';
|
|
16
16
|
import { situationalContextEnvelope } from './situational-context.js';
|
|
17
17
|
import { statusRank } from '../canvas/node-order.js';
|
|
18
|
-
import { buildProjectContextBlock, contextDirNote, orchestratorContextNote, profileNote as profileNoteShared, renderGraphMap, buildIdentityAssertion as buildIdentityAssertionShared, worktreeNote, } from './bearings-render.js';
|
|
18
|
+
import { buildProjectContextBlock, contextDirNote, orchestratorContextNote, whereYouRunNote, profileNote as profileNoteShared, renderGraphMap, buildIdentityAssertion as buildIdentityAssertionShared, worktreeNote, } from './bearings-render.js';
|
|
19
19
|
import { mapAsync } from '../async-array.js';
|
|
20
20
|
/** The bearings custom type is shared with every attached renderer. */
|
|
21
21
|
export { CONTEXT_INTRO_CUSTOM_TYPE } from '../../shared/generated-context.js';
|
|
@@ -162,7 +162,11 @@ function managedWorktreeNote(node) {
|
|
|
162
162
|
* documents owned by the directory's repo (its `<repo>/index` is the workspace front door). */
|
|
163
163
|
async function bearingsShell(nodeId, knowledge, workspaceContext) {
|
|
164
164
|
const node = await getNode(nodeId);
|
|
165
|
+
const execution = await latestExecutionForNode(nodeId);
|
|
165
166
|
const bearings = ['<crtr-bearings>', await buildIdentityAssertion(nodeId, node)];
|
|
167
|
+
const whereYouRun = whereYouRunNote(execution?.runner);
|
|
168
|
+
if (whereYouRun !== '')
|
|
169
|
+
bearings.push('', '## Where you run', whereYouRun);
|
|
166
170
|
const map = await buildGraphMap(nodeId, node);
|
|
167
171
|
if (map !== '')
|
|
168
172
|
bearings.push('', '## Your place in the canvas', map);
|
|
@@ -183,7 +187,7 @@ async function bearingsShell(nodeId, knowledge, workspaceContext) {
|
|
|
183
187
|
// nested card inside the outer envelope. Never routed through the visible
|
|
184
188
|
// chat/digest path. '' when nothing was ever set.
|
|
185
189
|
const situational = await situationalContextEnvelope(nodeId) ?? '';
|
|
186
|
-
const projectCtx = node?.cwd !== undefined &&
|
|
190
|
+
const projectCtx = node?.cwd !== undefined && execution?.runner === 'process' ? buildProjectContextBlock(node.cwd) : ''; // reads this host
|
|
187
191
|
return [bearings.join('\n'), knowledge, workspaceContext, situational, projectCtx]
|
|
188
192
|
.filter((s) => s !== '')
|
|
189
193
|
.join('\n');
|
|
@@ -7,11 +7,9 @@ export const YIELD_STALL_GRACE_MS = 3 * 60_000;
|
|
|
7
7
|
export const KILL_ESCALATE_MS = 20_000;
|
|
8
8
|
export const WEDGE_QUIET_MS = 20 * 60_000;
|
|
9
9
|
export const WEDGE_CPU_MAX_PERCENT = 2;
|
|
10
|
-
export function yieldStallVerdict(piPidAlive,
|
|
10
|
+
export function yieldStallVerdict(piPidAlive, busy, stalledFor) {
|
|
11
11
|
if (piPidAlive !== true)
|
|
12
12
|
return 'leave';
|
|
13
|
-
if (intent !== 'refresh')
|
|
14
|
-
return 'leave';
|
|
15
13
|
if (busy)
|
|
16
14
|
return 'leave';
|
|
17
15
|
if (stalledFor === null || stalledFor < YIELD_STALL_GRACE_MS)
|