@north-light/cli 0.3.694 → 0.3.696
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/README.md +4 -7
- package/dist/api/command-manifest/result.d.ts +5 -5
- package/dist/api/command-manifest/result.js +1 -1
- package/dist/api/contract.d.ts +1 -1
- package/dist/api/contract.js +1 -1
- package/dist/api/dto/run-events.d.ts +1 -0
- package/dist/api/dto/run-events.js +1 -0
- package/dist/api/dto/worktree.d.ts +0 -4
- package/dist/builtin-memory/crouter-concepts/lifecycle-and-wakes.md +1 -1
- package/dist/builtin-memory/crouter-concepts/nodes-and-the-canvas.md +2 -2
- package/dist/builtin-memory/crouter-concepts/profiles-kinds-and-modes.md +1 -1
- package/dist/builtin-memory/crouter-concepts/scopes-and-trust.md +1 -1
- package/dist/builtin-memory/crouter-concepts/why-a-daemon.md +1 -1
- package/dist/builtin-memory/crouter-sdk/INDEX.md +3 -3
- package/dist/builtin-memory/crouter-sdk/README.md +14 -42
- package/dist/builtin-memory/crouter-sdk/client.md +5 -7
- package/dist/builtin-memory/crouter-sdk/docker.md +1 -1
- package/dist/builtin-memory/crouter-sdk/errors.md +4 -44
- package/dist/builtin-memory/crouter-sdk/getting-started.md +11 -83
- package/dist/builtin-memory/crouter-sdk/release-notes.md +10 -0
- package/dist/builtin-memory/crouter-sdk/resources.md +11 -44
- package/dist/builtin-memory/northlight-apps/guides/stream-a-run.md +6 -7
- package/dist/clients/attach/session/connection.d.ts +11 -2
- package/dist/clients/attach/session/connection.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/pane-tag.d.ts +3 -3
- package/dist/clients/attach/session/reconnect.js +1 -1
- package/dist/clients/attach/viewer.js +539 -538
- package/dist/commands/node-worktree.js +1 -1
- package/dist/commands/surface/node/placement.d.ts +2 -2
- package/dist/commands/surface/node/placement.js +1 -1
- package/dist/commands/surface.js +1 -1
- package/dist/core/broker-client/client.d.ts +6 -9
- package/dist/core/broker-client/client.js +1 -1
- package/dist/core/broker-client/transport-relay.d.ts +12 -1
- package/dist/core/broker-client/transport-relay.js +1 -1
- package/dist/core/canvas/canvas.js +5 -5
- package/dist/core/canvas/types.d.ts +0 -2
- package/dist/core/conversation-store/row-store.js +10 -10
- package/dist/core/graph/names.js +9 -9
- package/dist/core/keybindings/attach-control.d.ts +3 -0
- package/dist/core/keybindings/attach-control.js +1 -1
- package/dist/core/keybindings/catalog.js +1 -1
- package/dist/core/ledger/chunks.d.ts +3 -1
- package/dist/core/ledger/chunks.js +2 -2
- package/dist/core/ledger/index.d.ts +1 -1
- package/dist/core/ledger/index.js +1 -1
- package/dist/core/ledger/read.d.ts +4 -0
- package/dist/core/ledger/read.js +2 -2
- package/dist/core/llm/run.js +2 -2
- package/dist/core/logged-step-timings.d.ts +7 -0
- package/dist/core/logged-step-timings.js +1 -0
- package/dist/core/permissions/evaluator.d.ts +2 -1
- package/dist/core/permissions/evaluator.js +2 -2
- package/dist/core/providers/receipts.js +1 -1
- package/dist/core/runs/operations.js +8 -8
- package/dist/core/runtime/broker/model-adapter.js +3 -3
- package/dist/core/runtime/broker.js +1 -1
- package/dist/core/runtime/nodes.d.ts +1 -1
- package/dist/core/runtime/nodes.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/machine/executor.d.ts +0 -3
- package/dist/core/runtime/runner/machine/executor.js +1 -1
- package/dist/core/runtime/runner/machine/machine-executor.test.js +2 -2
- package/dist/core/runtime/runner/machine/ops.d.ts +7 -13
- package/dist/core/runtime/runner/machine/ops.js +1 -1
- package/dist/core/runtime/runner/machine/runner.d.ts +3 -2
- package/dist/core/runtime/runner/machine/runner.js +1 -1
- package/dist/core/runtime/tmux-bindings.js +3 -3
- package/dist/core/runtime/tmux-driver.d.ts +0 -10
- package/dist/core/runtime/tmux-driver.js +6 -6
- package/dist/core/step-timings.d.ts +7 -1
- package/dist/core/step-timings.js +1 -1
- package/dist/core/worktree-close.js +4 -6
- package/dist/core/worktree-landing.d.ts +0 -38
- package/dist/core/worktree-landing.js +2 -3
- package/dist/core/worktree-sweep.d.ts +0 -1
- package/dist/core/worktree-sweep.js +4 -6
- package/dist/core/worktree.d.ts +0 -4
- package/dist/core/worktree.js +13 -15
- package/dist/daemon/api/app-listener.d.ts +1 -0
- package/dist/daemon/api/app-listener.js +10 -10
- package/dist/daemon/api/bridge.js +5 -5
- package/dist/daemon/api/handlers/attach.js +1 -1
- package/dist/daemon/api/handlers/conversations.js +3 -3
- package/dist/daemon/api/server.d.ts +1 -1
- package/dist/daemon/api/server.js +1 -1
- package/dist/daemon/cron/armed-context.js +1 -1
- package/dist/daemon/crtrd.js +20 -18
- package/dist/daemon/machine-daemon.js +1 -1
- package/dist/daemon/machine-link/client.d.ts +7 -1
- package/dist/daemon/machine-link/client.js +1 -1
- package/dist/daemon/machine-link/forward.d.ts +2 -4
- package/dist/daemon/machine-link/forward.js +1 -1
- package/dist/daemon/machine-link/holder.js +5 -5
- package/dist/daemon/pidfile.js +2 -1
- package/dist/daemon/reconcilers/managed-worktree-sweep.js +1 -1
- package/dist/daemon/reconcilers/node-lifecycle/freeze-lane.js +1 -1
- package/dist/daemon/reconcilers/node-lifecycle/machine-sweep.d.ts +1 -1
- package/dist/daemon/reconcilers/node-lifecycle/machine-sweep.js +2 -2
- package/dist/daemon/runs/append-section.js +2 -2
- package/dist/daemon/runs/observer.js +3 -3
- package/docs/apps/guides/stream-a-run.md +6 -7
- package/docs/concepts/lifecycle-and-wakes.md +1 -1
- package/docs/concepts/nodes-and-the-canvas.md +2 -2
- package/docs/concepts/profiles-kinds-and-modes.md +1 -1
- package/docs/concepts/scopes-and-trust.md +1 -1
- package/docs/concepts/why-a-daemon.md +1 -1
- package/docs/sdk/README.md +13 -41
- package/docs/sdk/client.md +5 -7
- package/docs/sdk/docker.md +1 -1
- package/docs/sdk/errors.md +3 -43
- package/docs/sdk/getting-started.md +11 -83
- package/docs/sdk/release-notes.md +10 -0
- package/docs/sdk/resources.md +11 -44
- package/package.json +3 -3
- package/packages/crouter-api/dist/api/command-manifest/result.js +15 -15
- package/packages/crouter-api/dist/api/contract.js +1 -1
- package/packages/crouter-api/dist/api/dto/run-events.js +1 -1
- package/packages/crouter-api/dist/clients/attach/session/connection.js +73 -25
- package/packages/crouter-api/dist/clients/attach/session/keys.js +1 -0
- package/packages/crouter-api/dist/clients/attach/session/reconnect.js +11 -15
- package/packages/crouter-api/dist/clients/attach/viewer.js +42 -5
- package/packages/crouter-api/dist/commands/node-worktree.js +1 -5
- package/packages/crouter-api/dist/commands/surface/node/placement.js +2 -2
- package/packages/crouter-api/dist/commands/surface.js +2 -3
- package/packages/crouter-api/dist/core/broker-client/client.js +5 -17
- package/packages/crouter-api/dist/core/broker-client/transport-relay.js +24 -7
- package/packages/crouter-api/dist/core/canvas/canvas.js +2 -3
- package/packages/crouter-api/dist/core/conversation-store/row-store.js +7 -4
- package/packages/crouter-api/dist/core/graph/names.js +7 -20
- package/packages/crouter-api/dist/core/keybindings/attach-control.js +1 -0
- package/packages/crouter-api/dist/core/keybindings/catalog.js +2 -1
- package/packages/crouter-api/dist/core/ledger/chunks.js +7 -3
- package/packages/crouter-api/dist/core/ledger/index.js +1 -1
- package/packages/crouter-api/dist/core/ledger/read.js +18 -1
- package/packages/crouter-api/dist/core/llm/run.js +1 -1
- package/packages/crouter-api/dist/core/logged-step-timings.js +52 -0
- package/packages/crouter-api/dist/core/permissions/evaluator.js +15 -1
- package/packages/crouter-api/dist/core/providers/receipts.js +1 -12
- package/packages/crouter-api/dist/core/runs/operations.js +5 -4
- package/packages/crouter-api/dist/core/runtime/broker/model-adapter.js +14 -3
- package/packages/crouter-api/dist/core/runtime/nodes.js +2 -2
- package/packages/crouter-api/dist/core/runtime/placement-tmux.js +1 -1
- package/packages/crouter-api/dist/core/runtime/revive.js +5 -5
- package/packages/crouter-api/dist/core/runtime/runner/machine/ops.js +2 -7
- package/packages/crouter-api/dist/core/runtime/runner/machine/runner.js +14 -32
- package/packages/crouter-api/dist/core/runtime/tmux-bindings.js +1 -1
- package/packages/crouter-api/dist/core/runtime/tmux-driver.js +0 -18
- package/packages/crouter-api/dist/core/step-timings.js +7 -2
- package/packages/crouter-api/dist/core/worktree-close.js +5 -51
- package/packages/crouter-api/dist/core/worktree-landing.js +0 -48
- package/packages/crouter-api/dist/core/worktree.js +9 -74
- package/packages/crouter-api/dist/daemon/cron/armed-context.js +3 -3
- package/packages/crouter-api/dist/daemon/machine-link/forward.js +22 -10
- package/packages/crouter-api/dist/daemon/machine-link/holder.js +7 -0
- package/packages/crouter-api/dist/daemon/pidfile.js +1 -1
- package/packages/crouter-api/dist/daemon/runs/append-section.js +2 -8
- package/packages/crouter-api/dist/daemon/runs/observer.js +3 -4
- package/packages/crouter-api/package.json +1 -1
- package/packages/crouter-identity/package.json +1 -1
- package/packages/crouter-plugin/dist/serve.js +1 -1
- package/packages/crouter-plugin/package.json +3 -3
- package/runtime.lock.json +14 -14
- package/scripts/self-update.mjs +7 -3
- package/dist/builtin-memory/crouter-sdk/bash.md +0 -40
- package/dist/builtin-memory/crouter-sdk/files.md +0 -50
- package/dist/builtin-memory/crouter-sdk/guides/README.md +0 -18
- package/dist/builtin-memory/crouter-sdk/guides/event-driven-assistant.md +0 -91
- package/dist/builtin-memory/crouter-sdk/guides/fan-out-pipeline.md +0 -57
- package/dist/builtin-memory/crouter-sdk/guides/human-approval.md +0 -79
- package/dist/builtin-memory/crouter-sdk/guides/typed-extraction.md +0 -55
- package/dist/builtin-memory/crouter-sdk/nodes.md +0 -195
- package/dist/builtin-memory/crouter-sdk/streaming.md +0 -151
- package/dist/commands/surface-reload.d.ts +0 -7
- package/dist/commands/surface-reload.js +0 -1
- package/docs/sdk/bash.md +0 -39
- package/docs/sdk/files.md +0 -49
- package/docs/sdk/guides/README.md +0 -17
- package/docs/sdk/guides/event-driven-assistant.md +0 -24
- package/docs/sdk/guides/fan-out-pipeline.md +0 -24
- package/docs/sdk/guides/human-approval.md +0 -24
- package/docs/sdk/guides/typed-extraction.md +0 -24
- package/docs/sdk/nodes.md +0 -194
- package/docs/sdk/streaming.md +0 -149
- package/packages/crouter-api/dist/commands/surface-reload.js +0 -129
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
// `crtr surface reload` — hot-reload a viewer pane in place.
|
|
2
|
-
//
|
|
3
|
-
// A viewer process loads its runtime generation at startup and never reloads
|
|
4
|
-
// it, so after a runtime roll an already-open pane keeps running the old
|
|
5
|
-
// generation against the new crtrd. Respawning the pane with the viewer's own
|
|
6
|
-
// `crtr surface attach to <id>` command line means the fresh process picks up
|
|
7
|
-
// the currently selected generation while the pane and broker are untouched.
|
|
8
|
-
import { defineLeaf } from '../core/command.js';
|
|
9
|
-
import { InputError } from '../core/io.js';
|
|
10
|
-
import { listProcessTable } from '../core/canvas/pid.js';
|
|
11
|
-
import { displayMessage } from '../core/runtime/tmux-chrome.js';
|
|
12
|
-
import { nodeInPane, paneCurrentPath, panePid, paneStartCommand, respawnPaneInPlace, respawnPaneSync, viewerSplitEnv, } from './surface/node/placement.js';
|
|
13
|
-
/** True when `rootPid` (the pane's `#{pane_pid}`) or any descendant of it is a
|
|
14
|
-
* live `crtr surface attach to <nodeId>` viewer process. This is how a
|
|
15
|
-
* shell-hosted viewer is recognized: older panes were opened as a login shell
|
|
16
|
-
* that then ran the viewer, so their `#{pane_start_command}` is `zsh -l` and
|
|
17
|
-
* only the live process tree reveals the viewer. One process-table snapshot, walked
|
|
18
|
-
* from the pane's root pid. */
|
|
19
|
-
function paneTreeHasViewer(rootPid, nodeId) {
|
|
20
|
-
const table = listProcessTable();
|
|
21
|
-
if (table === null)
|
|
22
|
-
return false;
|
|
23
|
-
const childrenOf = new Map();
|
|
24
|
-
const commandOf = new Map();
|
|
25
|
-
for (const { pid, ppid, command } of table) {
|
|
26
|
-
commandOf.set(pid, command);
|
|
27
|
-
const siblings = childrenOf.get(ppid) ?? [];
|
|
28
|
-
siblings.push(pid);
|
|
29
|
-
childrenOf.set(ppid, siblings);
|
|
30
|
-
}
|
|
31
|
-
// Node ids are [a-z0-9-] so splicing one into a regex is safe. The viewer
|
|
32
|
-
// shows up as e.g. `node /opt/homebrew/bin/crtr surface attach to <id>`.
|
|
33
|
-
const viewer = new RegExp(`(?:^|\\s)surface attach to ${nodeId}(?:\\s|$)`);
|
|
34
|
-
const queue = [rootPid];
|
|
35
|
-
while (queue.length > 0) {
|
|
36
|
-
const pid = queue.pop();
|
|
37
|
-
const command = commandOf.get(pid);
|
|
38
|
-
if (command !== undefined && viewer.test(command))
|
|
39
|
-
return true;
|
|
40
|
-
const kids = childrenOf.get(pid);
|
|
41
|
-
if (kids !== undefined)
|
|
42
|
-
queue.push(...kids);
|
|
43
|
-
}
|
|
44
|
-
return false;
|
|
45
|
-
}
|
|
46
|
-
/** The node a `crtr surface attach to <id>` command line targets. Panes opened
|
|
47
|
-
* by a respawn path (the Markdown file-open bridge, the review companion) carry
|
|
48
|
-
* a shell-quoted id, so the raw command line is not comparable to the canonical
|
|
49
|
-
* one — the target node is. */
|
|
50
|
-
export function attachTargetNode(command) {
|
|
51
|
-
const match = /(?:^|\s)surface attach to\s+(?:'([^']*)'|"([^"]*)"|(\S+))/.exec(command);
|
|
52
|
-
return match?.[1] ?? match?.[2] ?? match?.[3];
|
|
53
|
-
}
|
|
54
|
-
export const surfaceReloadLeaf = defineLeaf({
|
|
55
|
-
name: 'reload',
|
|
56
|
-
description: 'respawn a viewer pane in place onto the current runtime generation',
|
|
57
|
-
whenToUse: 'a viewer pane predates a runtime roll and should be refreshed onto the selected generation without losing the pane or the node it views',
|
|
58
|
-
help: {
|
|
59
|
-
name: 'surface reload',
|
|
60
|
-
summary: 'kill and re-run a viewer pane’s `crtr surface attach to <node>` command line in place, so the fresh viewer picks up the currently selected runtime generation',
|
|
61
|
-
params: [
|
|
62
|
-
{ kind: 'flag', name: 'pane', type: 'string', required: false, constraint: 'tmux pane id hosting the viewer to reload. Defaults to $TMUX_PANE / your current pane. The Alt+C menu passes this for you.' },
|
|
63
|
-
],
|
|
64
|
-
output: [
|
|
65
|
-
{ name: 'pane', type: 'string', required: true, constraint: 'The respawned tmux pane.' },
|
|
66
|
-
{ name: 'node_id', type: 'string', required: true, constraint: 'The node whose viewer was reloaded.' },
|
|
67
|
-
],
|
|
68
|
-
outputKind: 'object',
|
|
69
|
-
effects: ['Kills the pane’s viewer process and re-runs the viewer command line in the same pane; the node’s broker engine keeps running untouched.'],
|
|
70
|
-
},
|
|
71
|
-
run: async (input) => {
|
|
72
|
-
const pane = input['pane'] ?? process.env['TMUX_PANE'];
|
|
73
|
-
if (pane === undefined || pane === '') {
|
|
74
|
-
throw new InputError({ error: 'not_in_tmux', message: 'viewer reload is tmux-only — no tmux pane to target', next: 'Run it inside tmux, or pass --pane <pane-id> of a tmux viewer pane.' });
|
|
75
|
-
}
|
|
76
|
-
// Only respawn a pane that actually hosts a viewer FOR THE TAGGED NODE. The
|
|
77
|
-
// node tag alone is not enough — workspace shell panes carry `@crtr_node`
|
|
78
|
-
// too, and respawning one would kill a live shell the user is working in.
|
|
79
|
-
// Two shapes qualify:
|
|
80
|
-
// 1. The pane's start command IS the viewer (tmux launched `crtr surface
|
|
81
|
-
// attach to <id>` as the pane command) → a bare `respawn-pane -k`
|
|
82
|
-
// replays that exact line.
|
|
83
|
-
// 2. The pane was started as a shell (`zsh -l`) that is now RUNNING the
|
|
84
|
-
// viewer as a live child process → respawn with an explicit
|
|
85
|
-
// `crtr surface attach to <node>` command, because replaying the
|
|
86
|
-
// shell line would leave a bare shell instead of a viewer.
|
|
87
|
-
// A tagged pane sitting at a shell prompt with no live viewer matches
|
|
88
|
-
// neither and is refused — killing it would lose the user's shell.
|
|
89
|
-
const nodeId = nodeInPane(pane);
|
|
90
|
-
if (nodeId === undefined) {
|
|
91
|
-
displayMessage('crtr: no viewer in pane', pane);
|
|
92
|
-
throw new InputError({ error: 'no_viewer', message: 'this pane does not host an attach viewer', next: 'Pass --pane <pane-id> for a pane running `crtr surface attach to <node>`.' });
|
|
93
|
-
}
|
|
94
|
-
const viewerCommand = `crtr surface attach to ${nodeId}`;
|
|
95
|
-
// tmux wraps #{pane_start_command} in literal double quotes.
|
|
96
|
-
const startCommand = paneStartCommand(pane)?.replace(/^"|"$/g, '');
|
|
97
|
-
if (startCommand !== undefined && startCommand.startsWith('crtr surface attach ')) {
|
|
98
|
-
// The start command must target the TAGGED node — a mismatch means the
|
|
99
|
-
// tag is stale or the viewer belongs to another node; don't touch it.
|
|
100
|
-
if (attachTargetNode(startCommand) !== nodeId) {
|
|
101
|
-
displayMessage('crtr: viewer/node mismatch in pane', pane);
|
|
102
|
-
throw new InputError({ error: 'no_viewer', message: `this pane's viewer command (${startCommand}) does not match its node tag (${nodeId})`, next: 'Pass --pane <pane-id> for a pane running `crtr surface attach to <node>`.' });
|
|
103
|
-
}
|
|
104
|
-
if (!respawnPaneInPlace(pane)) {
|
|
105
|
-
displayMessage('crtr: viewer reload failed', pane);
|
|
106
|
-
throw new InputError({ error: 'respawn_failed', message: `tmux could not respawn pane ${pane}`, next: 'Check the tmux server is reachable, then retry.' });
|
|
107
|
-
}
|
|
108
|
-
displayMessage('crtr: viewer reloaded', pane);
|
|
109
|
-
return { pane, node_id: nodeId };
|
|
110
|
-
}
|
|
111
|
-
const rootPid = panePid(pane);
|
|
112
|
-
if (rootPid === undefined || !paneTreeHasViewer(rootPid, nodeId)) {
|
|
113
|
-
displayMessage('crtr: no viewer in pane', pane);
|
|
114
|
-
throw new InputError({ error: 'no_viewer', message: 'this pane does not host an attach viewer', next: 'Pass --pane <pane-id> for a pane running `crtr surface attach to <node>`.' });
|
|
115
|
-
}
|
|
116
|
-
// Shell-hosted viewer: respawn onto the viewer command directly. The pane
|
|
117
|
-
// deliberately converges on the viewer-as-pane-command shape every other
|
|
118
|
-
// crtr surface uses today, so its start command becomes truthful and the
|
|
119
|
-
// next reload takes the replay path.
|
|
120
|
-
const cwd = paneCurrentPath(pane) ?? process.cwd();
|
|
121
|
-
if (!respawnPaneSync({ pane, cwd, env: viewerSplitEnv(), command: viewerCommand })) {
|
|
122
|
-
displayMessage('crtr: viewer reload failed', pane);
|
|
123
|
-
throw new InputError({ error: 'respawn_failed', message: `tmux could not respawn pane ${pane}`, next: 'Check the tmux server is reachable, then retry.' });
|
|
124
|
-
}
|
|
125
|
-
displayMessage('crtr: viewer reloaded', pane);
|
|
126
|
-
return { pane, node_id: nodeId };
|
|
127
|
-
},
|
|
128
|
-
render: (r) => `Reloaded viewer for ${r['node_id']} in pane ${r['pane']}.`,
|
|
129
|
-
});
|