@north-light/cli 0.3.708 → 0.3.710
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/api/contract.d.ts +1 -1
- package/dist/api/contract.js +1 -1
- package/dist/api/dto/crons.d.ts +3 -0
- package/dist/clients/attach/chrome/inbox-strip.js +1 -1
- package/dist/clients/attach/chrome/roster.js +6 -6
- package/dist/clients/attach/chrome/status-line.d.ts +1 -1
- package/dist/clients/attach/chrome/status-line.js +1 -1
- package/dist/clients/attach/input/capabilities.js +1 -1
- package/dist/clients/attach/input/controller.d.ts +4 -0
- package/dist/clients/attach/input/controller.js +3 -3
- package/dist/clients/attach/overlays/graph.d.ts +3 -2
- package/dist/clients/attach/overlays/graph.js +1 -1
- package/dist/clients/attach/render/chat-view.d.ts +2 -0
- package/dist/clients/attach/render/chat-view.js +1 -1
- package/dist/clients/attach/render/doc-links.d.ts +1 -1
- package/dist/clients/attach/session/chrome-refresh.js +1 -1
- package/dist/clients/attach/session/connection.d.ts +10 -9
- package/dist/clients/attach/session/connection.js +1 -1
- package/dist/clients/attach/session/context.d.ts +1 -1
- package/dist/clients/attach/session/document-links.d.ts +1 -1
- package/dist/clients/attach/session/document-links.js +1 -1
- package/dist/clients/attach/session/identity.d.ts +2 -0
- package/dist/clients/attach/session/identity.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/session/keys.d.ts +2 -0
- package/dist/clients/attach/session/keys.js +1 -1
- package/dist/clients/attach/session/layout-record.d.ts +13 -0
- package/dist/clients/attach/session/layout-record.js +1 -0
- package/dist/clients/attach/session/pane-tag.d.ts +3 -1
- package/dist/clients/attach/session/pane-tag.js +1 -1
- package/dist/clients/attach/session/reconnect.js +1 -1
- package/dist/clients/attach/session/teardown.d.ts +4 -2
- package/dist/clients/attach/session/teardown.js +9 -7
- package/dist/clients/attach/slash/dispatch.js +2 -2
- package/dist/clients/attach/slash/recover.d.ts +10 -0
- package/dist/clients/attach/slash/recover.js +2 -0
- package/dist/clients/attach/viewer.d.ts +7 -5
- package/dist/clients/attach/viewer.js +563 -558
- package/dist/commands/node/wait.js +2 -6
- package/dist/core/broker-client/client.d.ts +6 -3
- package/dist/core/broker-client/client.js +1 -1
- package/dist/core/canvas/crons.d.ts +11 -1
- package/dist/core/canvas/crons.js +14 -14
- package/dist/core/canvas/executions.js +1 -1
- package/dist/core/canvas/managed-worktree-sweep-candidates.d.ts +2 -2
- package/dist/core/canvas/managed-worktree-sweep-candidates.js +5 -3
- package/dist/core/canvas/schema-pg/026-cron-deadline-body.sql +9 -0
- package/dist/core/canvas/schema-pg/027-cron-fires.sql +4 -0
- package/dist/core/canvas/schema-pg/028-machine-calls-worktree-sweep.sql +6 -0
- package/dist/core/canvas/schema-version.d.ts +1 -1
- package/dist/core/canvas/schema-version.js +1 -1
- package/dist/core/command.js +5 -5
- package/dist/core/feed/messages.d.ts +5 -0
- package/dist/core/feed/messages.js +5 -5
- package/dist/core/runtime/bearings.js +4 -4
- package/dist/core/runtime/boot-root.js +4 -4
- package/dist/core/runtime/broker-request.d.ts +2 -0
- package/dist/core/runtime/broker-request.js +1 -1
- package/dist/core/runtime/broker.js +1 -1
- package/dist/core/runtime/lifecycle.js +2 -2
- package/dist/core/runtime/model-swap.d.ts +2 -1
- package/dist/core/runtime/model-swap.js +1 -1
- package/dist/core/runtime/placement-tmux.d.ts +1 -1
- package/dist/core/runtime/placement-tmux.js +1 -1
- package/dist/core/runtime/revive.js +2 -2
- package/dist/core/runtime/runner/blaxel/client.d.ts +4 -0
- package/dist/core/runtime/runner/blaxel/client.js +1 -1
- package/dist/core/runtime/runner/blaxel/runner.d.ts +2 -3
- package/dist/core/runtime/runner/blaxel/runner.js +3 -3
- package/dist/core/runtime/runner/delete-sandboxes.d.ts +5 -0
- package/dist/core/runtime/runner/delete-sandboxes.js +6 -1
- package/dist/core/runtime/runner/machine/call.js +2 -2
- package/dist/core/runtime/runner/machine/ops.d.ts +11 -1
- package/dist/core/runtime/runner/machine/ops.js +1 -1
- package/dist/core/runtime/runner/types.d.ts +19 -3
- package/dist/core/runtime/tmux-driver.d.ts +7 -0
- package/dist/core/runtime/tmux-driver.js +6 -6
- package/dist/core/worktree-machine.d.ts +4 -1
- package/dist/core/worktree-machine.js +1 -1
- package/dist/core/worktree-sweep.d.ts +14 -3
- package/dist/core/worktree-sweep.js +4 -4
- package/dist/daemon/api/bridge.d.ts +5 -0
- package/dist/daemon/api/bridge.js +3 -3
- package/dist/daemon/api/handlers/crons.d.ts +2 -0
- package/dist/daemon/api/handlers/crons.js +1 -1
- package/dist/daemon/api/handlers/nodes.js +1 -1
- package/dist/daemon/api/operations.js +1 -1
- package/dist/daemon/cron/ended.d.ts +3 -0
- package/dist/daemon/cron/ended.js +2 -2
- package/dist/daemon/cron/lease-recovery.js +1 -1
- package/dist/daemon/cron/machine-fire.d.ts +9 -2
- package/dist/daemon/cron/machine-fire.js +1 -1
- package/dist/daemon/cron/passes.js +1 -1
- package/dist/daemon/cron-run.js +2 -2
- package/dist/daemon/fleet.d.ts +1 -1
- package/dist/daemon/fleet.js +4 -4
- package/dist/daemon/machine-link/client.js +1 -1
- package/dist/daemon/reconcilers/fault-retry-backstop.js +1 -1
- package/dist/daemon/reconcilers/idle-sandbox.d.ts +1 -1
- package/dist/daemon/reconcilers/idle-sandbox.js +2 -2
- package/dist/daemon/reconcilers/managed-worktree-sweep.js +1 -1
- package/dist/daemon/reconcilers/node-lifecycle/remote-wake.js +2 -2
- package/dist/daemon/runs/observer.d.ts +4 -0
- package/dist/daemon/runs/observer.js +1 -1
- package/dist/pi-extensions/canvas-inbox-watcher.js +1 -1
- package/package.json +3 -3
- package/packages/crouter-api/dist/api/contract.js +1 -1
- package/packages/crouter-api/dist/clients/attach/chrome/inbox-strip.js +5 -5
- package/packages/crouter-api/dist/clients/attach/chrome/roster.js +8 -8
- package/packages/crouter-api/dist/clients/attach/chrome/status-line.js +1 -1
- package/packages/crouter-api/dist/clients/attach/input/capabilities.js +3 -1
- package/packages/crouter-api/dist/clients/attach/input/controller.js +17 -0
- package/packages/crouter-api/dist/clients/attach/overlays/graph.js +4 -3
- package/packages/crouter-api/dist/clients/attach/render/chat-view.js +9 -0
- package/packages/crouter-api/dist/clients/attach/session/chrome-refresh.js +6 -3
- package/packages/crouter-api/dist/clients/attach/session/connection.js +53 -53
- package/packages/crouter-api/dist/clients/attach/session/document-links.js +1 -1
- package/packages/crouter-api/dist/clients/attach/session/identity.js +1 -0
- package/packages/crouter-api/dist/clients/attach/session/input-wiring.js +4 -3
- package/packages/crouter-api/dist/clients/attach/session/keys.js +11 -4
- package/packages/crouter-api/dist/clients/attach/session/layout-record.js +52 -0
- package/packages/crouter-api/dist/clients/attach/session/pane-tag.js +7 -1
- package/packages/crouter-api/dist/clients/attach/session/reconnect.js +3 -3
- package/packages/crouter-api/dist/clients/attach/session/teardown.js +9 -4
- package/packages/crouter-api/dist/clients/attach/slash/dispatch.js +12 -0
- package/packages/crouter-api/dist/clients/attach/slash/recover.js +111 -0
- package/packages/crouter-api/dist/clients/attach/viewer.js +86 -31
- package/packages/crouter-api/dist/commands/node/wait.js +2 -10
- package/packages/crouter-api/dist/core/broker-client/client.js +20 -10
- package/packages/crouter-api/dist/core/canvas/crons.js +26 -10
- package/packages/crouter-api/dist/core/canvas/executions.js +7 -2
- package/packages/crouter-api/dist/core/canvas/schema-version.js +1 -1
- package/packages/crouter-api/dist/core/command.js +3 -0
- package/packages/crouter-api/dist/core/feed/messages.js +15 -0
- package/packages/crouter-api/dist/core/runtime/bearings.js +2 -2
- package/packages/crouter-api/dist/core/runtime/broker-ownership.js +6 -0
- package/packages/crouter-api/dist/core/runtime/broker-request.js +1 -1
- package/packages/crouter-api/dist/core/runtime/lifecycle.js +3 -0
- package/packages/crouter-api/dist/core/runtime/model-swap.js +2 -1
- package/packages/crouter-api/dist/core/runtime/placement-tmux.js +1 -1
- package/packages/crouter-api/dist/core/runtime/revive.js +5 -25
- package/packages/crouter-api/dist/core/runtime/runner/blaxel/client.js +15 -8
- package/packages/crouter-api/dist/core/runtime/runner/blaxel/runner.js +60 -19
- package/packages/crouter-api/dist/core/runtime/runner/delete-sandboxes.js +18 -2
- package/packages/crouter-api/dist/core/runtime/runner/machine/call.js +1 -1
- package/packages/crouter-api/dist/core/runtime/runner/machine/executor.js +235 -0
- package/packages/crouter-api/dist/core/runtime/runner/machine/ops.js +1 -1
- package/packages/crouter-api/dist/core/runtime/tmux-driver.js +11 -0
- package/packages/crouter-api/dist/core/worktree-machine.js +20 -0
- package/packages/crouter-api/dist/core/worktree-sweep.js +439 -0
- package/packages/crouter-api/dist/daemon/api/operations.js +2 -2
- package/packages/crouter-api/dist/daemon/cron/ended.js +22 -11
- package/packages/crouter-api/dist/daemon/cron/machine-fire.js +69 -6
- package/packages/crouter-api/dist/daemon/reconcilers/node-lifecycle/remote-wake.js +2 -2
- package/packages/crouter-api/dist/daemon/runs/observer.js +1 -1
- 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/dist/core/runtime/starting-screen.d.ts +0 -12
- package/dist/core/runtime/starting-screen.js +0 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@north-light/cli",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.710",
|
|
4
4
|
"description": "crtr — agent runtime with memory, plugins, and marketplaces",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -157,8 +157,8 @@
|
|
|
157
157
|
},
|
|
158
158
|
"license": "UNLICENSED",
|
|
159
159
|
"dependencies": {
|
|
160
|
-
"@north-light/identity": "0.3.
|
|
161
|
-
"@north-light/plugin": "0.3.
|
|
160
|
+
"@north-light/identity": "0.3.710",
|
|
161
|
+
"@north-light/plugin": "0.3.710",
|
|
162
162
|
"@earendil-works/chord": "1.5.2",
|
|
163
163
|
"@earendil-works/pi-agent-core": "1.5.2",
|
|
164
164
|
"@earendil-works/pi-ai": "1.5.2",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
//
|
|
13
13
|
// PURITY (spec §3.1): Node built-ins + `src/api/*` only.
|
|
14
14
|
/** The contract level this build serves and requires. Written by `scripts/contract.mjs release`; never edit by hand. */
|
|
15
|
-
export const CONTRACT_LEVEL = '1.
|
|
15
|
+
export const CONTRACT_LEVEL = '1.68';
|
|
16
16
|
/** Request header naming the one contract level the caller needs, e.g. `1.3`. Optional: absent means no check. */
|
|
17
17
|
export const REQUIRED_CONTRACT_HEADER = 'Crouter-Required-Contract';
|
|
18
18
|
/** Response header listing the contract levels the server serves, comma-separated, one per major, e.g. `1.3`. */
|
|
@@ -36,7 +36,7 @@ function ageLabel(iso) {
|
|
|
36
36
|
return `${Math.floor(hours / 24)}d`;
|
|
37
37
|
}
|
|
38
38
|
export function createInboxStrip(s, hooks) {
|
|
39
|
-
const {
|
|
39
|
+
const { remote, canvasSource, tui, pal } = s;
|
|
40
40
|
const component = new Container();
|
|
41
41
|
let tickets = [];
|
|
42
42
|
let nodes = new Map();
|
|
@@ -44,7 +44,7 @@ export function createInboxStrip(s, hooks) {
|
|
|
44
44
|
let top = 0; // first visible ticket row
|
|
45
45
|
const rowLine = (t) => {
|
|
46
46
|
const origin = t.source.nodeId;
|
|
47
|
-
const from = origin !== undefined && origin !== nodeId
|
|
47
|
+
const from = origin !== undefined && origin !== s.nodeId
|
|
48
48
|
? ` · ${navLabel(nodes.get(origin) ?? null, origin)}`
|
|
49
49
|
: '';
|
|
50
50
|
return truncate(` ${YELLOW}⚑${RESET} ${t.title}${pal.faint(` · ${ageLabel(ticketTime(t))}${from}`)}`);
|
|
@@ -74,7 +74,7 @@ export function createInboxStrip(s, hooks) {
|
|
|
74
74
|
* same pass already fetched carries every field read here, so the full node
|
|
75
75
|
* list is read only by a source without one. */
|
|
76
76
|
const subtreeNodes = async (view) => {
|
|
77
|
-
const roster = view ?? await canvasSource.panelView?.(nodeId);
|
|
77
|
+
const roster = view ?? await canvasSource.panelView?.(s.nodeId);
|
|
78
78
|
const list = roster === undefined
|
|
79
79
|
? await canvasSource.listNodes()
|
|
80
80
|
: roster.nodes.map((n) => ({ node_id: n.node_id, name: n.name, kind: n.kind, status: n.status, ...(n.description ? { description: n.description } : {}) }));
|
|
@@ -84,7 +84,7 @@ export function createInboxStrip(s, hooks) {
|
|
|
84
84
|
if (out.has(id))
|
|
85
85
|
return;
|
|
86
86
|
const row = rows.get(id) ?? null;
|
|
87
|
-
if (id !== nodeId && row?.kind === 'human')
|
|
87
|
+
if (id !== s.nodeId && row?.kind === 'human')
|
|
88
88
|
return;
|
|
89
89
|
out.set(id, row);
|
|
90
90
|
const below = roster === undefined
|
|
@@ -93,7 +93,7 @@ export function createInboxStrip(s, hooks) {
|
|
|
93
93
|
for (const childId of below)
|
|
94
94
|
await visit(childId);
|
|
95
95
|
};
|
|
96
|
-
await visit(nodeId);
|
|
96
|
+
await visit(s.nodeId);
|
|
97
97
|
return out;
|
|
98
98
|
};
|
|
99
99
|
const refresh = async (view) => {
|
|
@@ -34,7 +34,7 @@ import { buildCanvasPanelLines } from './canvas-panels.js';
|
|
|
34
34
|
/** How long an armed `x` waits for its `y`. */
|
|
35
35
|
const ARM_TIMEOUT_MS = 15_000;
|
|
36
36
|
export function createRoster(s, hooks) {
|
|
37
|
-
const { editor, tui, pal,
|
|
37
|
+
const { editor, tui, pal, remote, role, canvasSource } = s;
|
|
38
38
|
// The node's app comes from the node row the viewer already holds; resolving it from canvas.db would open the db in this process.
|
|
39
39
|
const reports = s.containers.reports;
|
|
40
40
|
let items = [];
|
|
@@ -62,19 +62,19 @@ export function createRoster(s, hooks) {
|
|
|
62
62
|
}
|
|
63
63
|
tui.requestRender();
|
|
64
64
|
};
|
|
65
|
-
const listJobs = async () => (await cliClient().listBashJobs(nodeId)).map(toBashJobStatus);
|
|
65
|
+
const listJobs = async () => (await cliClient().listBashJobs(s.nodeId)).map(toBashJobStatus);
|
|
66
66
|
const refresh = async (view) => {
|
|
67
67
|
const crons = remote ? [] : await cliClient().listCrons();
|
|
68
|
-
const ownedCrons = crons.filter((cron) => cron.created_by === nodeId);
|
|
69
|
-
// Local-only, same gate as ownedCrons: a local nodeId collision must never leak background jobs.
|
|
68
|
+
const ownedCrons = crons.filter((cron) => cron.created_by === s.nodeId);
|
|
69
|
+
// Local-only, same gate as ownedCrons: a local s.nodeId collision must never leak background jobs.
|
|
70
70
|
const bashJobs = remote ? [] : await listJobs();
|
|
71
71
|
// Reviews this node is the origin of: the person still holds an open one, or
|
|
72
72
|
// the daemon is finishing a submitted one behind its companion. Local-only,
|
|
73
73
|
// like the crons above — a remote graph id has no local review surface.
|
|
74
74
|
const openReviews = remote ? [] : (await cliClient().listReviews({ state: 'open' })).reviews;
|
|
75
|
-
const reviews = openReviews.filter((review) => review.origin_node_id === nodeId);
|
|
75
|
+
const reviews = openReviews.filter((review) => review.origin_node_id === s.nodeId);
|
|
76
76
|
const others = remote ? undefined : { crons, reviews: openReviews, jobsOf: async (id) => (await cliClient().listBashJobs(id)).map(toBashJobStatus) };
|
|
77
|
-
const built = await buildCanvasPanelLines(nodeId, hooks.asks(), pal, canvasSource, ownedCrons, bashJobs, reviews, others, view ?? await canvasSource.panelView?.(nodeId));
|
|
77
|
+
const built = await buildCanvasPanelLines(s.nodeId, hooks.asks(), pal, canvasSource, ownedCrons, bashJobs, reviews, others, view ?? await canvasSource.panelView?.(s.nodeId));
|
|
78
78
|
items = built.items;
|
|
79
79
|
// After an in-place swap, land on the previously open node, which has taken
|
|
80
80
|
// the swapped-to node's place in this self-excluding roster.
|
|
@@ -152,7 +152,7 @@ export function createRoster(s, hooks) {
|
|
|
152
152
|
return;
|
|
153
153
|
disarmKill(false);
|
|
154
154
|
hooks.setNotice(`Stopping “${target.label}”…`);
|
|
155
|
-
execFile('crtr', ['node', 'bash', 'kill', target.jobId, '--node', nodeId], (err) => {
|
|
155
|
+
execFile('crtr', ['node', 'bash', 'kill', target.jobId, '--node', s.nodeId], (err) => {
|
|
156
156
|
hooks.setNotice(err === null ? `Stopped “${target.label}”.` : `Could not stop the job: ${err.message.split('\n')[0]}`);
|
|
157
157
|
hooks.requestChromeRefresh();
|
|
158
158
|
});
|
|
@@ -202,7 +202,7 @@ export function createRoster(s, hooks) {
|
|
|
202
202
|
return;
|
|
203
203
|
}
|
|
204
204
|
const id = item.nodeId;
|
|
205
|
-
if (id === nodeId) {
|
|
205
|
+
if (id === s.nodeId) {
|
|
206
206
|
exit();
|
|
207
207
|
return;
|
|
208
208
|
} // already viewing this one
|
|
@@ -24,7 +24,7 @@ import { viewerKeyHint } from './key-hint.js';
|
|
|
24
24
|
const NOTICE_CLEAR_MS = 3_000;
|
|
25
25
|
const formatTokens = (n) => n >= 1000 ? `${(n / 1000).toFixed(n >= 10000 ? 0 : 1)}k` : `${n}`;
|
|
26
26
|
export function createStatusLine(s, hooks) {
|
|
27
|
-
const { pal, tui,
|
|
27
|
+
const { pal, tui, remote } = s;
|
|
28
28
|
const footer = s.containers.footer;
|
|
29
29
|
let notice = '';
|
|
30
30
|
let noticeTimer;
|
|
@@ -25,7 +25,8 @@ export function createViewerCapabilities(input) {
|
|
|
25
25
|
return {
|
|
26
26
|
role,
|
|
27
27
|
remote,
|
|
28
|
-
|
|
28
|
+
// Lazy: a viewer whose node is still being created has no id yet, and reading one then is a bug the source must throw on.
|
|
29
|
+
get nodeId() { return input.nodeId; },
|
|
29
30
|
profileId: input.profileId,
|
|
30
31
|
permittedOperations,
|
|
31
32
|
permits: (operation) => permittedOperations.has(operation),
|
|
@@ -91,6 +92,7 @@ export function viewerOperationForSlash(name, builtin, canvas) {
|
|
|
91
92
|
case 'tutorial': return 'engine-drive';
|
|
92
93
|
// These run local `crtr node …`, rewrite this machine's tmux titles, or read this machine's MCP config:
|
|
93
94
|
// with --canvas they would act on a same-id local node or local state, not the remote node.
|
|
95
|
+
case 'recover':
|
|
94
96
|
case 'promote':
|
|
95
97
|
case 'rename':
|
|
96
98
|
case 'mcp': return 'local-host';
|
|
@@ -73,7 +73,18 @@ export class InputController {
|
|
|
73
73
|
send = (frame) => {
|
|
74
74
|
this.emitCommand(frame);
|
|
75
75
|
};
|
|
76
|
+
/** While the node is being created only these frames are accepted (prompts are held until the welcome; a `!` command is refused like a slash command); everything else needs the node. */
|
|
77
|
+
refuseStarting(frame) {
|
|
78
|
+
if (this.hooks.isStarting?.() !== true)
|
|
79
|
+
return false;
|
|
80
|
+
if (frame !== undefined && (frame.type === 'prompt' || frame.type === 'follow_up'))
|
|
81
|
+
return false;
|
|
82
|
+
this.notify('The node is starting — try again in a moment');
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
76
85
|
emitCommand(frame) {
|
|
86
|
+
if (this.refuseStarting(frame))
|
|
87
|
+
return false;
|
|
77
88
|
const operation = viewerOperationForFrame(frame);
|
|
78
89
|
const refusal = operation === undefined ? undefined : this.capabilities.refusal(operation);
|
|
79
90
|
if (refusal === undefined) {
|
|
@@ -84,6 +95,8 @@ export class InputController {
|
|
|
84
95
|
return false;
|
|
85
96
|
}
|
|
86
97
|
openBrokerPicker(open) {
|
|
98
|
+
if (this.refuseStarting())
|
|
99
|
+
return;
|
|
87
100
|
const refusal = this.capabilities.refusal('engine-drive');
|
|
88
101
|
if (refusal !== undefined) {
|
|
89
102
|
this.notify(refusal);
|
|
@@ -195,6 +208,8 @@ export class InputController {
|
|
|
195
208
|
const trimmed = text.trim();
|
|
196
209
|
if (!trimmed)
|
|
197
210
|
return;
|
|
211
|
+
if (isSlashCommand(trimmed) && this.refuseStarting())
|
|
212
|
+
return;
|
|
198
213
|
if (isSlashCommand(trimmed) && dispatchSlashCommand(trimmed, this.slashContext())) {
|
|
199
214
|
this.recordCommandUse(trimmed);
|
|
200
215
|
this.editor.setText('');
|
|
@@ -264,6 +279,8 @@ export class InputController {
|
|
|
264
279
|
this.clearPastedImages();
|
|
265
280
|
}
|
|
266
281
|
async handleDequeue() {
|
|
282
|
+
if (this.refuseStarting())
|
|
283
|
+
return;
|
|
267
284
|
const refusal = this.capabilities.refusal('dequeue');
|
|
268
285
|
if (refusal !== undefined) {
|
|
269
286
|
this.notify(refusal);
|
|
@@ -102,7 +102,7 @@ function graphRow(dto) {
|
|
|
102
102
|
}
|
|
103
103
|
export class GraphOverlay {
|
|
104
104
|
tui;
|
|
105
|
-
|
|
105
|
+
selfId;
|
|
106
106
|
getAsks;
|
|
107
107
|
palette;
|
|
108
108
|
bindings;
|
|
@@ -129,9 +129,9 @@ export class GraphOverlay {
|
|
|
129
129
|
* default and makes Enter/r/m/x no-op instead of shelling local lifecycle
|
|
130
130
|
* commands against a remote graph row. See the file header. */
|
|
131
131
|
remote;
|
|
132
|
-
constructor(tui,
|
|
132
|
+
constructor(tui, selfId, getAsks, palette, bindings, source, role = 'controller', onRefreshFailure = () => { }, onNotice = () => { }) {
|
|
133
133
|
this.tui = tui;
|
|
134
|
-
this.
|
|
134
|
+
this.selfId = selfId;
|
|
135
135
|
this.getAsks = getAsks;
|
|
136
136
|
this.palette = palette;
|
|
137
137
|
this.bindings = bindings;
|
|
@@ -141,6 +141,7 @@ export class GraphOverlay {
|
|
|
141
141
|
this.onNotice = onNotice;
|
|
142
142
|
this.remote = source instanceof RemoteCanvasSource;
|
|
143
143
|
}
|
|
144
|
+
get self() { return this.selfId(); }
|
|
144
145
|
setBindings(bindings) {
|
|
145
146
|
this.bindings = bindings;
|
|
146
147
|
if (this.handle !== undefined)
|
|
@@ -255,6 +255,15 @@ export class ChatView {
|
|
|
255
255
|
pendingSends = [];
|
|
256
256
|
/** Optional banner, above history and status in the viewport's flat source. */
|
|
257
257
|
bannerContainer;
|
|
258
|
+
/** Add one line to the banner after construction: a new root learns its id only when its create returns. */
|
|
259
|
+
setBannerHint(line) {
|
|
260
|
+
const banner = this.bannerContainer;
|
|
261
|
+
if (banner === undefined)
|
|
262
|
+
return;
|
|
263
|
+
banner.removeChild(banner.children[banner.children.length - 1]);
|
|
264
|
+
banner.addChild(new Text(line, 1, 0));
|
|
265
|
+
banner.addChild(new Spacer(1));
|
|
266
|
+
}
|
|
258
267
|
transcript;
|
|
259
268
|
/** Inline page blocks placed in this transcript, by page id — one block per
|
|
260
269
|
* page, so a `--replace` revision refreshes the block already on screen. */
|
|
@@ -17,7 +17,7 @@ export function isTransientDaemonFailure(error) {
|
|
|
17
17
|
return isDaemonTransportApiError(error) || (error instanceof APIError && error.status >= 500);
|
|
18
18
|
}
|
|
19
19
|
export function createChromeRefresh(ctx, hooks) {
|
|
20
|
-
const {
|
|
20
|
+
const { canvasSource } = ctx;
|
|
21
21
|
let asksMap = {};
|
|
22
22
|
let asksTimer;
|
|
23
23
|
let stopped = false;
|
|
@@ -63,6 +63,9 @@ export function createChromeRefresh(ctx, hooks) {
|
|
|
63
63
|
let chromeRefreshInFlight = false;
|
|
64
64
|
let chromeRefreshQueued = false;
|
|
65
65
|
const refresh = () => {
|
|
66
|
+
// A root still being created has no canvas tree to read; binding the node starts the first refresh.
|
|
67
|
+
if (ctx.nodeId === '')
|
|
68
|
+
return;
|
|
66
69
|
chromeRefreshQueued = true;
|
|
67
70
|
if (chromeRefreshInFlight)
|
|
68
71
|
return;
|
|
@@ -74,7 +77,7 @@ export function createChromeRefresh(ctx, hooks) {
|
|
|
74
77
|
const seqBefore = failureSeq;
|
|
75
78
|
try {
|
|
76
79
|
// One read of this node's tree feeds the panels, the inbox strip and the ask counts.
|
|
77
|
-
const view = await canvasSource.panelView?.(nodeId);
|
|
80
|
+
const view = await canvasSource.panelView?.(ctx.nodeId);
|
|
78
81
|
if (view !== undefined)
|
|
79
82
|
setAsks(view.counts);
|
|
80
83
|
await hooks.refreshRoster(view);
|
|
@@ -120,7 +123,7 @@ export function createChromeRefresh(ctx, hooks) {
|
|
|
120
123
|
// A remote canvas has no tree read: it climbs and counts node by node.
|
|
121
124
|
if (canvasSource.panelView === undefined)
|
|
122
125
|
void (async () => {
|
|
123
|
-
const root = await climbRootFromSource(nodeId);
|
|
126
|
+
const root = await climbRootFromSource(ctx.nodeId);
|
|
124
127
|
const counts = await canvasSource.ticketCountsForView(root);
|
|
125
128
|
if (JSON.stringify(counts) !== JSON.stringify(asksMap)) {
|
|
126
129
|
asksMap = counts;
|
|
@@ -63,61 +63,61 @@ export async function preWaitForViewSocket(nodeId) {
|
|
|
63
63
|
await new Promise((r) => setTimeout(r, 100));
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
|
-
/**
|
|
67
|
-
* a plain `InputError` for an unknown node
|
|
68
|
-
export
|
|
66
|
+
/** Build the not-yet-connected socket and canvas source. No node is resolved or dialed until `bind` names one: a viewer whose root is
|
|
67
|
+
* still being created paints first and binds when the create returns. `bind` rejects with a plain `InputError` for an unknown node. */
|
|
68
|
+
export function connectToNode(canvasName, wakeParked = true) {
|
|
69
69
|
// An imported Mac has no local canvas API: its canvas and its brokers' viewer channels are reached through the cloud control plane,
|
|
70
70
|
// so attach without `--canvas` dials the cloud with the person's sign-in. It is still the person's own attach, not a `--canvas` view:
|
|
71
71
|
// `remote` stays false, so the viewer claims the controller role like any local attach.
|
|
72
72
|
const remote = canvasName !== undefined;
|
|
73
73
|
const machine = remote ? undefined : readMachineConfig();
|
|
74
|
-
// Attach must NOT silently honor a durable `crtr canvas use` selection:
|
|
75
|
-
//
|
|
76
|
-
// not-found and reconnect-give-up handling, so an implicit remote redirect
|
|
77
|
-
// (from a `canvas use cloud` some other command left active) would be
|
|
78
|
-
// surprising for a command whose whole meaning is "attach to a node on THIS
|
|
79
|
-
// canvas". Go remote ONLY when `--canvas` was passed on THIS invocation —
|
|
80
|
-
// never fall through to resolveCanvasSource's activeCanvas precedence, which
|
|
81
|
-
// is right for `node inspect`/`canvas browse` but not here.
|
|
74
|
+
// Attach must NOT silently honor a durable `crtr canvas use` selection: go remote ONLY when `--canvas` was passed on THIS invocation —
|
|
75
|
+
// never fall through to resolveCanvasSource's activeCanvas precedence, which is right for `node inspect`/`canvas browse` but not here.
|
|
82
76
|
const canvasSource = canvasName !== undefined ? cliCanvasSource({ canvasName }) : new ApiCanvasSource();
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
if (localMeta === null) {
|
|
101
|
-
throw new InputError({
|
|
102
|
-
error: 'not_found',
|
|
103
|
-
message: `no node: ${nodeId}`,
|
|
104
|
-
received: nodeId,
|
|
105
|
-
next: 'List nodes with `crtr node inspect list`.',
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
meta = localMeta;
|
|
109
|
-
nodeIdentity = localMeta;
|
|
110
|
-
if (machine !== undefined) {
|
|
111
|
-
// On a Mac the viewer's WebSocket upgrade alone admits the attach: it authorizes, revives and waits for the broker once, and its channel
|
|
112
|
-
// is the viewer's. A focus of a parked node dials without waking it; the upgrade's `node_dormant` refusal says the node is parked.
|
|
113
|
-
transport = new RelayTransport(nodeId, await machineRelayTarget(machine.apiUrl, machine.directoryUrl), wakeParked);
|
|
77
|
+
const socket = new BrokerClient(undefined);
|
|
78
|
+
let boundId;
|
|
79
|
+
const nodeId = () => {
|
|
80
|
+
if (boundId === undefined)
|
|
81
|
+
throw new Error('attach has no node yet');
|
|
82
|
+
return boundId;
|
|
83
|
+
};
|
|
84
|
+
/** Build the transport for `id` and give it to the socket. A remote node id never exists in THIS machine's canvas.db, so `--canvas`
|
|
85
|
+
* skips the local lookup and uses the CLI's own cwd as `meta` (theming and this pane's git status are viewer-local concerns). */
|
|
86
|
+
const bind = async (id, known) => {
|
|
87
|
+
boundId = id;
|
|
88
|
+
let transport;
|
|
89
|
+
let meta;
|
|
90
|
+
let nodeIdentity;
|
|
91
|
+
if (canvasName !== undefined) {
|
|
92
|
+
meta = { cwd: process.cwd() };
|
|
93
|
+
transport = new RelayTransport(id, resolveRemoteCanvasTarget(canvasName));
|
|
114
94
|
}
|
|
115
95
|
else {
|
|
116
|
-
//
|
|
117
|
-
|
|
96
|
+
// A caller that just created the node already holds its detail: no second read.
|
|
97
|
+
const localMeta = known ?? await canvasSource.getNode(id);
|
|
98
|
+
if (localMeta === null) {
|
|
99
|
+
throw new InputError({
|
|
100
|
+
error: 'not_found',
|
|
101
|
+
message: `no node: ${id}`,
|
|
102
|
+
received: id,
|
|
103
|
+
next: 'List nodes with `crtr node inspect list`.',
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
meta = localMeta;
|
|
107
|
+
nodeIdentity = localMeta;
|
|
108
|
+
if (machine !== undefined) {
|
|
109
|
+
// On a Mac the viewer's WebSocket upgrade alone admits the attach: it authorizes, revives and waits for the broker once, and its channel
|
|
110
|
+
// is the viewer's. A focus of a parked node dials without waking it; the upgrade's `node_dormant` refusal says the node is parked.
|
|
111
|
+
transport = new RelayTransport(id, await machineRelayTarget(machine.apiUrl, machine.directoryUrl), wakeParked);
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
// The attach ensure runs in `dial()`; the viewer connects through crtrd's Unix-socket WebSocket bridge.
|
|
115
|
+
transport = new RelayTransport(id, { socketPath: apiSocketPath() });
|
|
116
|
+
}
|
|
118
117
|
}
|
|
119
|
-
|
|
120
|
-
|
|
118
|
+
socket.bindTransport(transport);
|
|
119
|
+
return { meta, nodeIdentity };
|
|
120
|
+
};
|
|
121
121
|
const local = canvasName === undefined && machine === undefined;
|
|
122
122
|
/** One error shape for a connect-time failure. */
|
|
123
123
|
const toAttachError = (err) => {
|
|
@@ -129,19 +129,19 @@ export async function connectToNode(nodeId, canvasName, wakeParked = true, known
|
|
|
129
129
|
return new InputError({
|
|
130
130
|
error: 'no_broker',
|
|
131
131
|
message: err.message,
|
|
132
|
-
received: nodeId,
|
|
132
|
+
received: nodeId(),
|
|
133
133
|
next: 'Focus or revive the node first — attach needs a running headless broker.',
|
|
134
134
|
});
|
|
135
135
|
}
|
|
136
136
|
return new InputError({
|
|
137
137
|
error: 'socket_error',
|
|
138
|
-
message: `could not attach to node ${nodeId}: ${String(err?.message ?? err)}`,
|
|
139
|
-
received: nodeId,
|
|
138
|
+
message: `could not attach to node ${nodeId()}: ${String(err?.message ?? err)}`,
|
|
139
|
+
received: nodeId(),
|
|
140
140
|
next: 'Check the node has a running headless broker.',
|
|
141
141
|
});
|
|
142
142
|
};
|
|
143
143
|
const parkedSnapshot = async () => {
|
|
144
|
-
const saved = await cliClient().getSnapshot(nodeId);
|
|
144
|
+
const saved = await cliClient().getSnapshot(nodeId());
|
|
145
145
|
// The API DTO stays dependency-light and structural; this viewer is the
|
|
146
146
|
// consumer that knows the complete broker snapshot contract.
|
|
147
147
|
return { snapshot: saved.snapshot, commands: saved.commands };
|
|
@@ -151,7 +151,7 @@ export async function connectToNode(nodeId, canvasName, wakeParked = true, known
|
|
|
151
151
|
// Attach revives a dormant node (B2 acceptance): the server-side ensureAttach runs reviveNode (the ONE sanctioned launcher)
|
|
152
152
|
// and waits for the broker's view socket. The daemon, not the broker, owns attending viewer presence.
|
|
153
153
|
try {
|
|
154
|
-
const attach = await cliClient().ensureAttach(nodeId, { resume: true, revive: true, wakeParked });
|
|
154
|
+
const attach = await cliClient().ensureAttach(nodeId(), { resume: true, revive: true, wakeParked });
|
|
155
155
|
// A parked node focused without waking has deliberately no socket to wait for.
|
|
156
156
|
if (attach.parked)
|
|
157
157
|
return await parkedSnapshot();
|
|
@@ -159,7 +159,7 @@ export async function connectToNode(nodeId, canvasName, wakeParked = true, known
|
|
|
159
159
|
catch (err) {
|
|
160
160
|
rethrowAsCliError(err, 'The node may be finalized or otherwise not attachable.');
|
|
161
161
|
}
|
|
162
|
-
await preWaitForViewSocket(nodeId);
|
|
162
|
+
await preWaitForViewSocket(nodeId());
|
|
163
163
|
}
|
|
164
164
|
try {
|
|
165
165
|
await new Promise((resolve, reject) => {
|
|
@@ -181,5 +181,5 @@ export async function connectToNode(nodeId, canvasName, wakeParked = true, known
|
|
|
181
181
|
mark('viewer.transport_open');
|
|
182
182
|
return undefined;
|
|
183
183
|
};
|
|
184
|
-
return { remote, canvasSource,
|
|
184
|
+
return { remote, canvasSource, socket, bind, dial };
|
|
185
185
|
}
|
|
@@ -29,7 +29,7 @@ export function createDocumentLinks(opts) {
|
|
|
29
29
|
}, () => { rosterLoaded = false; });
|
|
30
30
|
};
|
|
31
31
|
const context = {
|
|
32
|
-
selfNodeId
|
|
32
|
+
get selfNodeId() { return opts.selfNodeId(); },
|
|
33
33
|
nodeName: (nodeId) => {
|
|
34
34
|
const name = names.get(nodeId);
|
|
35
35
|
if (name === undefined)
|
|
@@ -21,7 +21,7 @@ import { defaultAgentDir } from '../config.js';
|
|
|
21
21
|
/** Construct the viewer's one capability authority. */
|
|
22
22
|
export function createViewerCapabilitiesForInput(ctx, isBrokerOffline) {
|
|
23
23
|
return createViewerCapabilities({
|
|
24
|
-
nodeId
|
|
24
|
+
get nodeId() { return ctx.nodeId; },
|
|
25
25
|
profileId: ctx.meta.profile_id ?? undefined,
|
|
26
26
|
remote: ctx.remote,
|
|
27
27
|
role: ctx.role,
|
|
@@ -45,7 +45,7 @@ export function lessDetailNotice(change) {
|
|
|
45
45
|
}
|
|
46
46
|
/** Build the viewer's InputController with every hook answered. */
|
|
47
47
|
export function createInputController(ctx, km, capabilities, hooks) {
|
|
48
|
-
const {
|
|
48
|
+
const { socket, tui, editor, containers } = ctx;
|
|
49
49
|
const { setNotice } = hooks;
|
|
50
50
|
// Auth pickers — viewer-local OAuth/API-key flows against the SAME auth.json
|
|
51
51
|
// the broker uses (broker + viewer share a filesystem in the tmux-local attach
|
|
@@ -129,6 +129,7 @@ export function createInputController(ctx, km, capabilities, hooks) {
|
|
|
129
129
|
// broker (it goes to crtrd via `cliClient`), so leaving it wired for an
|
|
130
130
|
// observer would let a read-only viewer wake and message the node.
|
|
131
131
|
isDormant: hooks.isDormant,
|
|
132
|
+
isStarting: hooks.isStarting,
|
|
132
133
|
onDormantSubmit: !capabilities.permits('wake-dormant') ? undefined : (msgText) => {
|
|
133
134
|
void (async () => {
|
|
134
135
|
try {
|
|
@@ -137,7 +138,7 @@ export function createInputController(ctx, km, capabilities, hooks) {
|
|
|
137
138
|
// (verbatim, no "From … — N updates" digest; see coalesce()), exactly
|
|
138
139
|
// like the live path. NOT `CRTR_NODE_ID`: direct keyboard input is
|
|
139
140
|
// the human, not whatever node owns the shell that launched us.
|
|
140
|
-
const res = await cliClient().sendMessage(nodeId, { body: msgText, from: 'human' });
|
|
141
|
+
const res = await cliClient().sendMessage(ctx.nodeId, { body: msgText, from: 'human' });
|
|
141
142
|
setNotice(res.revived ? '↻ waking node…' : '✉ delivered — node reads on next wake');
|
|
142
143
|
}
|
|
143
144
|
catch (err) {
|
|
@@ -16,6 +16,13 @@ const CLEAR_OR_DETACH_MS = 1000;
|
|
|
16
16
|
export function installGlobalKeys(ctx, hooks) {
|
|
17
17
|
const { tui, editor } = ctx;
|
|
18
18
|
let lastClearOrDetachAt = 0;
|
|
19
|
+
// The one starting check for every node-relative action; detach, clear, help, search, the inbox and the request strip work without a node.
|
|
20
|
+
const needsNode = (run) => () => {
|
|
21
|
+
if (hooks.isStarting())
|
|
22
|
+
hooks.setNotice('The node is starting — try again in a moment');
|
|
23
|
+
else
|
|
24
|
+
run();
|
|
25
|
+
};
|
|
19
26
|
const actions = {
|
|
20
27
|
'crtr.attach.detach': hooks.detach,
|
|
21
28
|
'crtr.attach.clear-or-detach': () => {
|
|
@@ -30,17 +37,17 @@ export function installGlobalKeys(ctx, hooks) {
|
|
|
30
37
|
hooks.setNotice(`Editor cleared — press ${hooks.detachHint()} again to cancel the agent`);
|
|
31
38
|
tui.requestRender();
|
|
32
39
|
},
|
|
33
|
-
'crtr.attach.graph.toggle': hooks.toggleGraph,
|
|
40
|
+
'crtr.attach.graph.toggle': needsNode(hooks.toggleGraph),
|
|
34
41
|
'crtr.attach.help.toggle': hooks.toggleHelp,
|
|
35
42
|
'crtr.attach.inbox.toggle': hooks.toggleInbox,
|
|
36
43
|
'crtr.attach.inbox-strip': hooks.toggleInboxStrip,
|
|
37
44
|
// A plain broker frame, so this works locally and remotely alike; the broker gates observers on controller role.
|
|
38
45
|
'crtr.attach.model-ladder.next': () => hooks.cycleModelLadder('forward'),
|
|
39
46
|
'crtr.attach.model-ladder.previous': () => hooks.cycleModelLadder('backward'),
|
|
40
|
-
'crtr.attach.command.inspect': hooks.inspectLoadedCommand,
|
|
41
|
-
'crtr.attach.profile-files': hooks.openProfileFiles,
|
|
47
|
+
'crtr.attach.command.inspect': needsNode(hooks.inspectLoadedCommand),
|
|
48
|
+
'crtr.attach.profile-files': needsNode(hooks.openProfileFiles),
|
|
42
49
|
'crtr.attach.search': hooks.openSearch,
|
|
43
|
-
'crtr.attach.whip': hooks.whip,
|
|
50
|
+
'crtr.attach.whip': needsNode(hooks.whip),
|
|
44
51
|
'crtr.attach.reload-viewer': hooks.reloadViewer,
|
|
45
52
|
};
|
|
46
53
|
return tui.addInputListener((data) => {
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// session/layout-record.ts — one small file per viewed node recording where its viewer pane sits in tmux
|
|
2
|
+
// (session, window, pane position, cwd), so `/recover` can rebuild the viewer layout after a crash or
|
|
3
|
+
// reboot has taken the tmux server with it. This is machine-local tmux state, not canvas state: the
|
|
4
|
+
// daemon never reads it. A viewer rewrites its file whenever it starts or gains focus and deletes it only
|
|
5
|
+
// when the person detaches or the node finishes — a SIGHUP from a dying tmux server leaves it in place.
|
|
6
|
+
import { mkdirSync, readdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
7
|
+
import { join } from 'node:path';
|
|
8
|
+
import { runtimeRoot } from '../../../core/layout.js';
|
|
9
|
+
import { paneCoordinates } from '../../../core/runtime/placement-tmux.js';
|
|
10
|
+
function recordsDir() { return join(runtimeRoot(), 'viewer-panes'); }
|
|
11
|
+
function recordPath(nodeId) { return join(recordsDir(), `${nodeId}.json`); }
|
|
12
|
+
export function writeLayoutRecord(nodeId, pane, cwd) {
|
|
13
|
+
if (pane === undefined || pane === '')
|
|
14
|
+
return;
|
|
15
|
+
const where = paneCoordinates(pane);
|
|
16
|
+
if (where === null)
|
|
17
|
+
return;
|
|
18
|
+
const record = { nodeId, session: where.session, windowIndex: where.windowIndex, windowName: where.windowName, paneIndex: where.paneIndex, cwd, pane };
|
|
19
|
+
try {
|
|
20
|
+
mkdirSync(recordsDir(), { recursive: true });
|
|
21
|
+
writeFileSync(recordPath(nodeId), JSON.stringify(record));
|
|
22
|
+
}
|
|
23
|
+
catch { /* best-effort: a missing record only costs the recovery one pane */ }
|
|
24
|
+
}
|
|
25
|
+
/** Delete this node's record unless another viewer pane has since claimed it. */
|
|
26
|
+
export function removeLayoutRecord(nodeId, pane) {
|
|
27
|
+
try {
|
|
28
|
+
const current = JSON.parse(readFileSync(recordPath(nodeId), 'utf8'));
|
|
29
|
+
if (pane === undefined || current.pane === pane)
|
|
30
|
+
rmSync(recordPath(nodeId), { force: true });
|
|
31
|
+
}
|
|
32
|
+
catch { /* no record */ }
|
|
33
|
+
}
|
|
34
|
+
export function readLayoutRecords() {
|
|
35
|
+
let names;
|
|
36
|
+
try {
|
|
37
|
+
names = readdirSync(recordsDir());
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
return [];
|
|
41
|
+
}
|
|
42
|
+
const records = [];
|
|
43
|
+
for (const name of names) {
|
|
44
|
+
if (!name.endsWith('.json'))
|
|
45
|
+
continue;
|
|
46
|
+
try {
|
|
47
|
+
records.push(JSON.parse(readFileSync(join(recordsDir(), name), 'utf8')));
|
|
48
|
+
}
|
|
49
|
+
catch { /* skip a torn file */ }
|
|
50
|
+
}
|
|
51
|
+
return records;
|
|
52
|
+
}
|
|
@@ -31,10 +31,16 @@ export function createPaneTag(remote, nodeId, io = realPaneTagIo) {
|
|
|
31
31
|
set: () => {
|
|
32
32
|
pane = io.currentPane();
|
|
33
33
|
claimAttachPane(pane, ownerPid, io.writeOption);
|
|
34
|
-
|
|
34
|
+
if (nodeId !== undefined)
|
|
35
|
+
tagAttachPane(remote, pane, nodeId, io.writeOption);
|
|
35
36
|
tagAttachViewerPane(pane, io.writeOption);
|
|
36
37
|
stampAttachPane(remote, pane, io.writeOption);
|
|
37
38
|
},
|
|
39
|
+
bindNode: (id) => {
|
|
40
|
+
nodeId = id;
|
|
41
|
+
if (pane !== undefined)
|
|
42
|
+
tagAttachPane(remote, pane, id, io.writeOption);
|
|
43
|
+
},
|
|
38
44
|
stamp: () => {
|
|
39
45
|
if (remote || pane === undefined || pane === '')
|
|
40
46
|
return;
|
|
@@ -13,7 +13,7 @@ const RECONNECT_ACTIVE_DELAY_CAP_MS = 1_000;
|
|
|
13
13
|
/** Dormant by choice — low-rate patience. */
|
|
14
14
|
const RECONNECT_DORMANT_DELAY_MS = 3_000;
|
|
15
15
|
export function createReconnect(ctx, hooks) {
|
|
16
|
-
const {
|
|
16
|
+
const { socket, canvasSource } = ctx;
|
|
17
17
|
let lastSocketError;
|
|
18
18
|
let reconnecting = false;
|
|
19
19
|
let viewerDormant = false;
|
|
@@ -86,7 +86,7 @@ export function createReconnect(ctx, hooks) {
|
|
|
86
86
|
// `--canvas`, so `getRow` works for both cases — always attempt it.
|
|
87
87
|
let row;
|
|
88
88
|
try {
|
|
89
|
-
row = await canvasSource.getRow(nodeId);
|
|
89
|
+
row = await canvasSource.getRow(ctx.nodeId);
|
|
90
90
|
}
|
|
91
91
|
catch {
|
|
92
92
|
row = undefined;
|
|
@@ -168,7 +168,7 @@ export function createReconnect(ctx, hooks) {
|
|
|
168
168
|
// attach closed that way before the session's first welcome is a refusal,
|
|
169
169
|
// not a broker to redial; a plain drop or a 1011 "no running broker" is redialed.
|
|
170
170
|
if (hooks.remote && hooks.role === 'controller' && refusedByRelay && !welcomed) {
|
|
171
|
-
lastSocketError = `the remote canvas refused the attach to ${nodeId}. A writable attach needs message permission on the node; with read permission only, attach with --observer.`;
|
|
171
|
+
lastSocketError = `the remote canvas refused the attach to ${ctx.nodeId}. A writable attach needs message permission on the node; with read permission only, attach with --observer.`;
|
|
172
172
|
hooks.teardown('broker-gone');
|
|
173
173
|
return;
|
|
174
174
|
}
|