remote-pi 0.4.3 → 0.5.1
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 +33 -0
- package/dist/daemon/client.js +5 -2
- package/dist/daemon/client.js.map +1 -1
- package/dist/daemon/control_protocol.d.ts +68 -0
- package/dist/daemon/control_protocol.js.map +1 -1
- package/dist/daemon/cron_log.d.ts +45 -0
- package/dist/daemon/cron_log.js +72 -0
- package/dist/daemon/cron_log.js.map +1 -0
- package/dist/daemon/cron_registry.d.ts +80 -0
- package/dist/daemon/cron_registry.js +194 -0
- package/dist/daemon/cron_registry.js.map +1 -0
- package/dist/daemon/id.d.ts +6 -0
- package/dist/daemon/id.js +6 -0
- package/dist/daemon/id.js.map +1 -1
- package/dist/daemon/install.d.ts +41 -3
- package/dist/daemon/install.js +252 -17
- package/dist/daemon/install.js.map +1 -1
- package/dist/daemon/registry.d.ts +17 -1
- package/dist/daemon/registry.js +34 -4
- package/dist/daemon/registry.js.map +1 -1
- package/dist/daemon/rpc_child.d.ts +91 -0
- package/dist/daemon/rpc_child.js +216 -7
- package/dist/daemon/rpc_child.js.map +1 -1
- package/dist/daemon/supervisor.d.ts +44 -0
- package/dist/daemon/supervisor.js +256 -21
- package/dist/daemon/supervisor.js.map +1 -1
- package/dist/index.d.ts +68 -11
- package/dist/index.js +0 -0
- package/dist/index.js.map +1 -1
- package/dist/mcp/mesh_server.js +18 -9
- package/dist/mcp/mesh_server.js.map +1 -1
- package/dist/pairing/qr.d.ts +8 -1
- package/dist/pairing/qr.js +13 -3
- package/dist/pairing/qr.js.map +1 -1
- package/dist/protocol/codec.js +1 -0
- package/dist/protocol/codec.js.map +1 -1
- package/dist/protocol/types.d.ts +11 -0
- package/dist/rooms.d.ts +20 -0
- package/dist/rooms.js +35 -0
- package/dist/rooms.js.map +1 -1
- package/dist/session/broker.d.ts +79 -3
- package/dist/session/broker.js +155 -28
- package/dist/session/broker.js.map +1 -1
- package/dist/session/broker_remote.d.ts +30 -10
- package/dist/session/broker_remote.js +77 -39
- package/dist/session/broker_remote.js.map +1 -1
- package/dist/session/cwd_lock.d.ts +7 -2
- package/dist/session/cwd_lock.js +39 -9
- package/dist/session/cwd_lock.js.map +1 -1
- package/dist/session/global_config.d.ts +12 -2
- package/dist/session/global_config.js +16 -3
- package/dist/session/global_config.js.map +1 -1
- package/dist/session/ipc.d.ts +27 -0
- package/dist/session/ipc.js +22 -0
- package/dist/session/ipc.js.map +1 -0
- package/dist/session/leader_election.js +8 -2
- package/dist/session/leader_election.js.map +1 -1
- package/dist/session/local_config.d.ts +36 -6
- package/dist/session/local_config.js +103 -28
- package/dist/session/local_config.js.map +1 -1
- package/dist/session/mesh_node.d.ts +15 -1
- package/dist/session/mesh_node.js +26 -5
- package/dist/session/mesh_node.js.map +1 -1
- package/dist/session/peer.d.ts +19 -2
- package/dist/session/peer.js +45 -9
- package/dist/session/peer.js.map +1 -1
- package/dist/session/tools.js +14 -12
- package/dist/session/tools.js.map +1 -1
- package/package.json +2 -1
- package/service-templates/task-launcher.vbs.template +10 -0
- package/service-templates/task-scheduler.xml.template +38 -0
- package/skills/agent-network/SKILL.md +63 -26
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/daemon/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC3F,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,WAAW,CAAC;AAC9E,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/daemon/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,E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AC;AAChC,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { EventEmitter } from "node:events";
|
|
2
2
|
import type { DaemonState } from "./control_protocol.js";
|
|
3
|
+
import { type LocalConfig } from "../session/local_config.js";
|
|
3
4
|
/**
|
|
4
5
|
* Wrapper around a `pi --mode rpc -e <extension>` child process for the
|
|
5
6
|
* supervisor.
|
|
@@ -28,6 +29,15 @@ export interface RpcChildOptions {
|
|
|
28
29
|
/** Additional env vars merged on top of `process.env` + the mandatory
|
|
29
30
|
* `REMOTE_PI_DAEMON=1`. */
|
|
30
31
|
env?: NodeJS.ProcessEnv;
|
|
32
|
+
/**
|
|
33
|
+
* Daemon config injected into the child via `REMOTE_PI_DIRECT_CONFIG`
|
|
34
|
+
* (JSON inline) instead of a per-cwd `.pi/remote-pi/config.json` file. The
|
|
35
|
+
* supervisor builds this from the registry. When set, the child reads it
|
|
36
|
+
* env-first (see `loadLocalConfig`) and no config file is needed. Also the
|
|
37
|
+
* source of the `--name` for the session. Falls back to the on-disk config
|
|
38
|
+
* when omitted.
|
|
39
|
+
*/
|
|
40
|
+
config?: LocalConfig;
|
|
31
41
|
}
|
|
32
42
|
export interface RpcChildExitEvent {
|
|
33
43
|
code: number | null;
|
|
@@ -36,6 +46,58 @@ export interface RpcChildExitEvent {
|
|
|
36
46
|
isCrash: boolean;
|
|
37
47
|
}
|
|
38
48
|
export declare const EXIT_DAEMON_FRESH_SESSION = 42;
|
|
49
|
+
/**
|
|
50
|
+
* Resolve the `pi` executable for `spawn` (plan/40, decision C). On Windows a
|
|
51
|
+
* bare `pi` is actually `pi.cmd`/`pi.ps1`, and `spawn` won't find it without an
|
|
52
|
+
* extension → resolve the real path via `where` (rather than `shell:true`,
|
|
53
|
+
* which risks shell injection). An explicit path or an already-suffixed name is
|
|
54
|
+
* used as-is. POSIX returns the name unchanged. Best-effort: if `where` fails,
|
|
55
|
+
* fall back to the bare name (spawn will surface ENOENT honestly).
|
|
56
|
+
*
|
|
57
|
+
* `where` lists every match in PATH order, which on pi-node installs puts the
|
|
58
|
+
* extensionless `pi` (a shell script) BEFORE `pi.cmd`. Naively taking the first
|
|
59
|
+
* line spawns the unrunnable script → ENOENT → "crashed". So we prefer a result
|
|
60
|
+
* with a real Windows executable extension and only fall back to the first line.
|
|
61
|
+
*/
|
|
62
|
+
export declare function resolvePiBin(piBin: string, plat?: NodeJS.Platform): string;
|
|
63
|
+
/** What to pass to `spawn`: the executable and any args to prepend before the
|
|
64
|
+
* caller's args. On POSIX (and for `.exe`) `prefixArgs` is empty. */
|
|
65
|
+
export interface PiSpawnTarget {
|
|
66
|
+
command: string;
|
|
67
|
+
prefixArgs: string[];
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Resolve `pi` to a directly-spawnable target (plan/40). On Windows `pi` is an
|
|
71
|
+
* npm `.cmd` shim, which modern Node refuses to `spawn` without `shell:true`
|
|
72
|
+
* (EINVAL, post CVE-2024-27980). Wrapping it in `cmd.exe` would (a) add a layer
|
|
73
|
+
* that orphans the real `node` on kill and (b) complicate stdio — both fatal for
|
|
74
|
+
* a long-lived RPC daemon the supervisor must stop/restart cleanly. Instead we
|
|
75
|
+
* parse the shim to recover the underlying `node <cli.js>` and spawn that
|
|
76
|
+
* directly: one process, clean signals, clean stdio.
|
|
77
|
+
*
|
|
78
|
+
* Falls back to the bare resolved path when not a parseable shim (e.g. a real
|
|
79
|
+
* `pi.exe`, or POSIX) so `spawn` surfaces any real error honestly.
|
|
80
|
+
*/
|
|
81
|
+
export declare function resolvePiSpawn(piBin: string, plat?: NodeJS.Platform, nodeExe?: string): PiSpawnTarget;
|
|
82
|
+
/**
|
|
83
|
+
* Extract the JS entry an npm `.cmd` shim launches. npm shims invoke
|
|
84
|
+
* `"%_prog%" "%dp0%\<relative>\entry.js" %*`; we recover `<dir>\<relative>\entry.js`
|
|
85
|
+
* (dir = the shim's own folder, i.e. `%dp0%`). Returns null when the shim
|
|
86
|
+
* doesn't match the expected shape or the target is missing.
|
|
87
|
+
*/
|
|
88
|
+
export declare function _npmShimTarget(cmdPath: string): string | null;
|
|
89
|
+
/**
|
|
90
|
+
* Maps an RPC stdout line to a busy-state transition: `message_start` → true
|
|
91
|
+
* (a message is streaming), `message_end` → false. Other lines → null (no
|
|
92
|
+
* change). Pure + exported for tests.
|
|
93
|
+
*
|
|
94
|
+
* NOTE (plan/39 detail 1): the Pi RPC stream has NO turn-level event — only
|
|
95
|
+
* per-message start/end (and `response{command:"prompt"}` is emitted at
|
|
96
|
+
* PREFLIGHT, i.e. turn START, not end). So this passive flag reflects
|
|
97
|
+
* "a message is being produced right now"; the authoritative turn-busy signal
|
|
98
|
+
* is `get_state.isStreaming` (see `RpcChild.refreshBusy`).
|
|
99
|
+
*/
|
|
100
|
+
export declare function busyTransition(line: string): boolean | null;
|
|
39
101
|
/**
|
|
40
102
|
* CLI args for the daemon's `pi --mode rpc` child.
|
|
41
103
|
*
|
|
@@ -52,6 +114,17 @@ export declare const EXIT_DAEMON_FRESH_SESSION = 42;
|
|
|
52
114
|
* same stable name in the picker/app instead of an auto-generated one. The
|
|
53
115
|
* daemon's name is set at registration (`remote-pi create <cwd> --name "…"`).
|
|
54
116
|
* Omitted when no name resolves, so the arg list stays minimal.
|
|
117
|
+
*
|
|
118
|
+
* `--approve` is mandatory for a daemon (pi ≥0.79 project trust): RPC mode is
|
|
119
|
+
* non-interactive, so without an override Pi resolves an untrusted project
|
|
120
|
+
* folder (any folder with `.pi/` or CLAUDE.md/AGENTS.md) to NOT trusted and
|
|
121
|
+
* silently skips its `.pi/settings.json` (model/provider/keys), instructions,
|
|
122
|
+
* resources and project extensions — the daemon then comes up with no model
|
|
123
|
+
* and fails on the first turn. The operator already authorized this folder by
|
|
124
|
+
* registering/launching a daemon in it, so `--approve` (trust-for-this-run) is
|
|
125
|
+
* the correct non-interactive stance. (Does NOT affect the separate "extension
|
|
126
|
+
* loaded twice" conflict, which comes from the extension being BOTH installed
|
|
127
|
+
* in ~/.pi/agent/extensions or cwd/.pi/extensions AND passed via `-e`.)
|
|
55
128
|
*/
|
|
56
129
|
export declare function rpcSpawnArgs(extensionPath: string, sessionName?: string, useContinue?: boolean): string[];
|
|
57
130
|
export declare class RpcChild extends EventEmitter {
|
|
@@ -70,8 +143,16 @@ export declare class RpcChild extends EventEmitter {
|
|
|
70
143
|
private forceFreshSessionOnNextSpawn;
|
|
71
144
|
/** Accumulates partial stdout lines while waiting for `\n`. */
|
|
72
145
|
private stdoutBuf;
|
|
146
|
+
/** Passive busy flag derived from the RPC stream (message_start/end). Hint
|
|
147
|
+
* only; `refreshBusy` syncs it authoritatively via get_state.isStreaming. */
|
|
148
|
+
private _busy;
|
|
149
|
+
/** In-flight `get_state` requests, keyed by request id. */
|
|
150
|
+
private readonly _statePending;
|
|
73
151
|
constructor(opts: RpcChildOptions);
|
|
74
152
|
get state(): DaemonState;
|
|
153
|
+
/** Passive busy hint from the stream. Prefer `refreshBusy()` for an
|
|
154
|
+
* authoritative check before acting on it (cron skip_if_busy). */
|
|
155
|
+
get isBusy(): boolean;
|
|
75
156
|
get pid(): number | undefined;
|
|
76
157
|
get restartCount(): number;
|
|
77
158
|
get uptimeMs(): number | undefined;
|
|
@@ -96,6 +177,16 @@ export declare class RpcChild extends EventEmitter {
|
|
|
96
177
|
*/
|
|
97
178
|
stop(timeoutMs?: number): Promise<void>;
|
|
98
179
|
private _onStdout;
|
|
180
|
+
private _handleStdoutLine;
|
|
181
|
+
/**
|
|
182
|
+
* Authoritative busy check: queries the child's `get_state` and syncs
|
|
183
|
+
* `_busy` to `isStreaming`. Resolves the passive flag on timeout (no
|
|
184
|
+
* response) or when the child isn't running. Used by the cron `skip_if_busy`
|
|
185
|
+
* gate, where a false "not busy" would pile a prompt onto a live turn.
|
|
186
|
+
*/
|
|
187
|
+
refreshBusy(timeoutMs?: number): Promise<boolean>;
|
|
188
|
+
/** Test-only: feed a raw stdout line through the same handler. */
|
|
189
|
+
_ingestStdoutForTest(line: string): void;
|
|
99
190
|
private _onExit;
|
|
100
191
|
/** Bumps the restart counter — called by the supervisor when it
|
|
101
192
|
* decides to re-spawn after a crash. Exposed so tests can drive it. */
|
package/dist/daemon/rpc_child.js
CHANGED
|
@@ -1,7 +1,132 @@
|
|
|
1
|
-
import { spawn } from "node:child_process";
|
|
1
|
+
import { execFileSync, spawn } from "node:child_process";
|
|
2
2
|
import { EventEmitter } from "node:events";
|
|
3
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
4
|
+
import { dirname, join } from "node:path";
|
|
3
5
|
import { defaultAgentName, loadLocalConfig } from "../session/local_config.js";
|
|
4
6
|
export const EXIT_DAEMON_FRESH_SESSION = 42;
|
|
7
|
+
/** Windows extensions `spawn` (without `shell`) can actually launch, in
|
|
8
|
+
* preference order: native `.exe` first, then the `.cmd`/`.bat` shims (run via
|
|
9
|
+
* cmd.exe). An extensionless `pi` is a Unix shell script Node CANNOT spawn on
|
|
10
|
+
* Windows — picking it yields `spawn … ENOENT` and the daemon shows "crashed". */
|
|
11
|
+
const WIN_EXECUTABLE_EXTS = [".exe", ".cmd", ".bat", ".com"];
|
|
12
|
+
/**
|
|
13
|
+
* Resolve the `pi` executable for `spawn` (plan/40, decision C). On Windows a
|
|
14
|
+
* bare `pi` is actually `pi.cmd`/`pi.ps1`, and `spawn` won't find it without an
|
|
15
|
+
* extension → resolve the real path via `where` (rather than `shell:true`,
|
|
16
|
+
* which risks shell injection). An explicit path or an already-suffixed name is
|
|
17
|
+
* used as-is. POSIX returns the name unchanged. Best-effort: if `where` fails,
|
|
18
|
+
* fall back to the bare name (spawn will surface ENOENT honestly).
|
|
19
|
+
*
|
|
20
|
+
* `where` lists every match in PATH order, which on pi-node installs puts the
|
|
21
|
+
* extensionless `pi` (a shell script) BEFORE `pi.cmd`. Naively taking the first
|
|
22
|
+
* line spawns the unrunnable script → ENOENT → "crashed". So we prefer a result
|
|
23
|
+
* with a real Windows executable extension and only fall back to the first line.
|
|
24
|
+
*/
|
|
25
|
+
export function resolvePiBin(piBin, plat = process.platform) {
|
|
26
|
+
if (plat !== "win32")
|
|
27
|
+
return piBin;
|
|
28
|
+
if (piBin.includes("\\") || piBin.includes("/") || /\.[a-z0-9]+$/i.test(piBin))
|
|
29
|
+
return piBin;
|
|
30
|
+
try {
|
|
31
|
+
const out = execFileSync("where", [piBin], { encoding: "utf8" });
|
|
32
|
+
const lines = out.split(/\r?\n/).map((l) => l.trim()).filter(Boolean);
|
|
33
|
+
const runnable = lines.find((l) => WIN_EXECUTABLE_EXTS.some((ext) => l.toLowerCase().endsWith(ext)));
|
|
34
|
+
const chosen = runnable ?? lines[0];
|
|
35
|
+
if (chosen)
|
|
36
|
+
return chosen;
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
/* `where` unavailable or `pi` not found — fall back to the bare name */
|
|
40
|
+
}
|
|
41
|
+
return piBin;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Resolve `pi` to a directly-spawnable target (plan/40). On Windows `pi` is an
|
|
45
|
+
* npm `.cmd` shim, which modern Node refuses to `spawn` without `shell:true`
|
|
46
|
+
* (EINVAL, post CVE-2024-27980). Wrapping it in `cmd.exe` would (a) add a layer
|
|
47
|
+
* that orphans the real `node` on kill and (b) complicate stdio — both fatal for
|
|
48
|
+
* a long-lived RPC daemon the supervisor must stop/restart cleanly. Instead we
|
|
49
|
+
* parse the shim to recover the underlying `node <cli.js>` and spawn that
|
|
50
|
+
* directly: one process, clean signals, clean stdio.
|
|
51
|
+
*
|
|
52
|
+
* Falls back to the bare resolved path when not a parseable shim (e.g. a real
|
|
53
|
+
* `pi.exe`, or POSIX) so `spawn` surfaces any real error honestly.
|
|
54
|
+
*/
|
|
55
|
+
export function resolvePiSpawn(piBin, plat = process.platform, nodeExe = process.execPath) {
|
|
56
|
+
const resolved = resolvePiBin(piBin, plat);
|
|
57
|
+
if (plat !== "win32")
|
|
58
|
+
return { command: resolved, prefixArgs: [] };
|
|
59
|
+
if (/\.(cmd|bat)$/i.test(resolved)) {
|
|
60
|
+
const target = _npmShimTarget(resolved);
|
|
61
|
+
if (target)
|
|
62
|
+
return { command: nodeExe, prefixArgs: [target] };
|
|
63
|
+
}
|
|
64
|
+
return { command: resolved, prefixArgs: [] };
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Extract the JS entry an npm `.cmd` shim launches. npm shims invoke
|
|
68
|
+
* `"%_prog%" "%dp0%\<relative>\entry.js" %*`; we recover `<dir>\<relative>\entry.js`
|
|
69
|
+
* (dir = the shim's own folder, i.e. `%dp0%`). Returns null when the shim
|
|
70
|
+
* doesn't match the expected shape or the target is missing.
|
|
71
|
+
*/
|
|
72
|
+
export function _npmShimTarget(cmdPath) {
|
|
73
|
+
let content;
|
|
74
|
+
try {
|
|
75
|
+
content = readFileSync(cmdPath, "utf8");
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
const m = content.match(/"%dp0%\\([^"]+\.[cm]?js)"/i);
|
|
81
|
+
if (!m)
|
|
82
|
+
return null;
|
|
83
|
+
const target = join(dirname(cmdPath), m[1]);
|
|
84
|
+
return existsSync(target) ? target : null;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Maps an RPC stdout line to a busy-state transition: `message_start` → true
|
|
88
|
+
* (a message is streaming), `message_end` → false. Other lines → null (no
|
|
89
|
+
* change). Pure + exported for tests.
|
|
90
|
+
*
|
|
91
|
+
* NOTE (plan/39 detail 1): the Pi RPC stream has NO turn-level event — only
|
|
92
|
+
* per-message start/end (and `response{command:"prompt"}` is emitted at
|
|
93
|
+
* PREFLIGHT, i.e. turn START, not end). So this passive flag reflects
|
|
94
|
+
* "a message is being produced right now"; the authoritative turn-busy signal
|
|
95
|
+
* is `get_state.isStreaming` (see `RpcChild.refreshBusy`).
|
|
96
|
+
*/
|
|
97
|
+
export function busyTransition(line) {
|
|
98
|
+
let obj;
|
|
99
|
+
try {
|
|
100
|
+
obj = JSON.parse(line);
|
|
101
|
+
}
|
|
102
|
+
catch {
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
const t = obj?.type;
|
|
106
|
+
if (t === "message_start")
|
|
107
|
+
return true;
|
|
108
|
+
if (t === "message_end")
|
|
109
|
+
return false;
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
/** Parses a `get_state` RPC response line, returning its id + isStreaming. */
|
|
113
|
+
function parseGetStateResponse(line) {
|
|
114
|
+
let obj;
|
|
115
|
+
try {
|
|
116
|
+
obj = JSON.parse(line);
|
|
117
|
+
}
|
|
118
|
+
catch {
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
121
|
+
const o = obj;
|
|
122
|
+
if (o.type !== "response" || o.command !== "get_state")
|
|
123
|
+
return null;
|
|
124
|
+
const data = o.data;
|
|
125
|
+
return {
|
|
126
|
+
id: typeof o.id === "string" ? o.id : undefined,
|
|
127
|
+
isStreaming: typeof data?.isStreaming === "boolean" ? data.isStreaming : undefined,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
5
130
|
/**
|
|
6
131
|
* CLI args for the daemon's `pi --mode rpc` child.
|
|
7
132
|
*
|
|
@@ -18,10 +143,22 @@ export const EXIT_DAEMON_FRESH_SESSION = 42;
|
|
|
18
143
|
* same stable name in the picker/app instead of an auto-generated one. The
|
|
19
144
|
* daemon's name is set at registration (`remote-pi create <cwd> --name "…"`).
|
|
20
145
|
* Omitted when no name resolves, so the arg list stays minimal.
|
|
146
|
+
*
|
|
147
|
+
* `--approve` is mandatory for a daemon (pi ≥0.79 project trust): RPC mode is
|
|
148
|
+
* non-interactive, so without an override Pi resolves an untrusted project
|
|
149
|
+
* folder (any folder with `.pi/` or CLAUDE.md/AGENTS.md) to NOT trusted and
|
|
150
|
+
* silently skips its `.pi/settings.json` (model/provider/keys), instructions,
|
|
151
|
+
* resources and project extensions — the daemon then comes up with no model
|
|
152
|
+
* and fails on the first turn. The operator already authorized this folder by
|
|
153
|
+
* registering/launching a daemon in it, so `--approve` (trust-for-this-run) is
|
|
154
|
+
* the correct non-interactive stance. (Does NOT affect the separate "extension
|
|
155
|
+
* loaded twice" conflict, which comes from the extension being BOTH installed
|
|
156
|
+
* in ~/.pi/agent/extensions or cwd/.pi/extensions AND passed via `-e`.)
|
|
21
157
|
*/
|
|
22
158
|
export function rpcSpawnArgs(extensionPath, sessionName, useContinue = true) {
|
|
23
159
|
return [
|
|
24
160
|
"--mode", "rpc",
|
|
161
|
+
"--approve",
|
|
25
162
|
...(useContinue ? ["--continue"] : []),
|
|
26
163
|
...(sessionName ? ["--name", sessionName] : []),
|
|
27
164
|
"-e", extensionPath,
|
|
@@ -43,11 +180,19 @@ export class RpcChild extends EventEmitter {
|
|
|
43
180
|
forceFreshSessionOnNextSpawn = false;
|
|
44
181
|
/** Accumulates partial stdout lines while waiting for `\n`. */
|
|
45
182
|
stdoutBuf = "";
|
|
183
|
+
/** Passive busy flag derived from the RPC stream (message_start/end). Hint
|
|
184
|
+
* only; `refreshBusy` syncs it authoritatively via get_state.isStreaming. */
|
|
185
|
+
_busy = false;
|
|
186
|
+
/** In-flight `get_state` requests, keyed by request id. */
|
|
187
|
+
_statePending = new Map();
|
|
46
188
|
constructor(opts) {
|
|
47
189
|
super();
|
|
48
190
|
this.opts = opts;
|
|
49
191
|
}
|
|
50
192
|
get state() { return this._state; }
|
|
193
|
+
/** Passive busy hint from the stream. Prefer `refreshBusy()` for an
|
|
194
|
+
* authoritative check before acting on it (cron skip_if_busy). */
|
|
195
|
+
get isBusy() { return this._busy; }
|
|
51
196
|
get pid() { return this.child?.pid; }
|
|
52
197
|
get restartCount() { return this._restartCount; }
|
|
53
198
|
get uptimeMs() {
|
|
@@ -61,26 +206,37 @@ export class RpcChild extends EventEmitter {
|
|
|
61
206
|
if (this.child)
|
|
62
207
|
return;
|
|
63
208
|
this._stopping = false; // fresh start — a later signal IS a real crash
|
|
209
|
+
this._busy = false;
|
|
64
210
|
this._state = "starting";
|
|
65
|
-
const
|
|
211
|
+
const piTarget = resolvePiSpawn(this.opts.piBin ?? "pi");
|
|
66
212
|
// Name the (single) daemon session after the daemon's configured identity,
|
|
67
213
|
// so it shows up stably instead of an auto-generated name on each restart.
|
|
68
|
-
|
|
69
|
-
|
|
214
|
+
// Prefer the supervisor-injected config; fall back to the on-disk file.
|
|
215
|
+
const cfg = this.opts.config ?? loadLocalConfig(this.opts.cwd);
|
|
216
|
+
const sessionName = cfg.agent_name ?? defaultAgentName(this.opts.cwd);
|
|
70
217
|
const useContinue = !this.forceFreshSessionOnNextSpawn;
|
|
71
218
|
this.forceFreshSessionOnNextSpawn = false;
|
|
72
|
-
|
|
219
|
+
// On Windows `prefixArgs` carries pi's cli.js (we spawn node directly); on
|
|
220
|
+
// POSIX it's empty and `command` is `pi` itself.
|
|
221
|
+
const args = [...piTarget.prefixArgs, ...rpcSpawnArgs(this.opts.extensionPath, sessionName, useContinue)];
|
|
73
222
|
const env = {
|
|
74
223
|
...process.env,
|
|
75
224
|
...this.opts.env,
|
|
76
225
|
// Mandatory daemon marker — `_cmdRoot` in index.ts can use this to
|
|
77
226
|
// bail early if local config is missing (no wizard in RPC mode).
|
|
78
227
|
REMOTE_PI_DAEMON: "1",
|
|
228
|
+
// Inject the daemon config inline so the child needs no config file.
|
|
229
|
+
...(this.opts.config ? { REMOTE_PI_DIRECT_CONFIG: JSON.stringify(this.opts.config) } : {}),
|
|
79
230
|
};
|
|
80
|
-
const child = spawn(
|
|
231
|
+
const child = spawn(piTarget.command, args, {
|
|
81
232
|
cwd: this.opts.cwd,
|
|
82
233
|
env,
|
|
83
234
|
stdio: ["pipe", "pipe", "pipe"],
|
|
235
|
+
// Windows: suppress any console window the child might allocate. With the
|
|
236
|
+
// node+cli.js path (resolvePiSpawn) there's no cmd.exe layer, but keep this
|
|
237
|
+
// as belt-and-suspenders alongside the supervisor's hidden wscript launcher
|
|
238
|
+
// (service-templates/task-launcher.vbs.template). No-op on POSIX.
|
|
239
|
+
windowsHide: process.platform === "win32",
|
|
84
240
|
});
|
|
85
241
|
this.child = child;
|
|
86
242
|
this._startedAt = Date.now();
|
|
@@ -154,9 +310,56 @@ export class RpcChild extends EventEmitter {
|
|
|
154
310
|
this.stdoutBuf = this.stdoutBuf.slice(nl + 1);
|
|
155
311
|
if (!line.trim())
|
|
156
312
|
continue;
|
|
157
|
-
this.
|
|
313
|
+
this._handleStdoutLine(line);
|
|
158
314
|
}
|
|
159
315
|
}
|
|
316
|
+
_handleStdoutLine(line) {
|
|
317
|
+
const t = busyTransition(line);
|
|
318
|
+
if (t !== null)
|
|
319
|
+
this._busy = t;
|
|
320
|
+
const gs = parseGetStateResponse(line);
|
|
321
|
+
if (gs && gs.id) {
|
|
322
|
+
const pending = this._statePending.get(gs.id);
|
|
323
|
+
if (pending) {
|
|
324
|
+
clearTimeout(pending.timer);
|
|
325
|
+
this._statePending.delete(gs.id);
|
|
326
|
+
if (typeof gs.isStreaming === "boolean")
|
|
327
|
+
this._busy = gs.isStreaming;
|
|
328
|
+
pending.resolve(this._busy);
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
this.emit("stdout", line);
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* Authoritative busy check: queries the child's `get_state` and syncs
|
|
335
|
+
* `_busy` to `isStreaming`. Resolves the passive flag on timeout (no
|
|
336
|
+
* response) or when the child isn't running. Used by the cron `skip_if_busy`
|
|
337
|
+
* gate, where a false "not busy" would pile a prompt onto a live turn.
|
|
338
|
+
*/
|
|
339
|
+
async refreshBusy(timeoutMs = 1500) {
|
|
340
|
+
if (this._state !== "running" || !this.child?.stdin)
|
|
341
|
+
return this._busy;
|
|
342
|
+
const id = `gs-${Date.now()}-${Math.round(Math.random() * 1e6)}`;
|
|
343
|
+
return new Promise((resolve) => {
|
|
344
|
+
const timer = setTimeout(() => {
|
|
345
|
+
this._statePending.delete(id);
|
|
346
|
+
resolve(this._busy);
|
|
347
|
+
}, timeoutMs);
|
|
348
|
+
this._statePending.set(id, { resolve, timer });
|
|
349
|
+
try {
|
|
350
|
+
this.child.stdin.write(JSON.stringify({ id, type: "get_state" }) + "\n");
|
|
351
|
+
}
|
|
352
|
+
catch {
|
|
353
|
+
clearTimeout(timer);
|
|
354
|
+
this._statePending.delete(id);
|
|
355
|
+
resolve(this._busy);
|
|
356
|
+
}
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
|
+
/** Test-only: feed a raw stdout line through the same handler. */
|
|
360
|
+
_ingestStdoutForTest(line) {
|
|
361
|
+
this._handleStdoutLine(line);
|
|
362
|
+
}
|
|
160
363
|
_onExit(code, signal) {
|
|
161
364
|
// Daemon app-action `/new`: child exits with a private code, supervisor
|
|
162
365
|
// restarts it, and the next spawn omits --continue once to create a fresh
|
|
@@ -169,6 +372,12 @@ export class RpcChild extends EventEmitter {
|
|
|
169
372
|
this._state = isCrash ? "crashed" : "stopped";
|
|
170
373
|
this.child = null;
|
|
171
374
|
this._startedAt = null;
|
|
375
|
+
this._busy = false;
|
|
376
|
+
for (const p of this._statePending.values()) {
|
|
377
|
+
clearTimeout(p.timer);
|
|
378
|
+
p.resolve(false);
|
|
379
|
+
}
|
|
380
|
+
this._statePending.clear();
|
|
172
381
|
this.emit("exit", { code, signal, isCrash });
|
|
173
382
|
}
|
|
174
383
|
/** Bumps the restart counter — called by the supervisor when it
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rpc_child.js","sourceRoot":"","sources":["../../src/daemon/rpc_child.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAwC/E,MAAM,CAAC,MAAM,yBAAyB,GAAG,EAAE,CAAC;AAE5C;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,YAAY,CAC1B,aAAqB,EACrB,WAAoB,EACpB,WAAW,GAAG,IAAI;IAElB,O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,aAAa,CAAC,KAAK,EAAE,CAAC;QAC3B,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAA8B,CAAC,CAAC;IAC3E,CAAC;IAED;4EACwE;IACxE,WAAW;QACT,IAAI,CAAC,aAAa,IAAI,CAAC,CAAC;IAC1B,CAAC;CACF"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type CronResult } from "./cron_log.js";
|
|
1
2
|
/** Thrown by `start()` when another live supervisor already holds the UDS.
|
|
2
3
|
* Prevents a second supervisor from orphaning the first's children. */
|
|
3
4
|
export declare class SupervisorAlreadyRunningError extends Error {
|
|
@@ -12,10 +13,21 @@ export interface SupervisorOptions {
|
|
|
12
13
|
/** Override the `pi` binary path. Defaults to "pi" on PATH. */
|
|
13
14
|
piBin?: string;
|
|
14
15
|
}
|
|
16
|
+
/** Pure decision for `fireJob` (plan/39) — picks the action from the daemon's
|
|
17
|
+
* liveness/busy state + the job's flags. Tested in isolation for all 4 ramos. */
|
|
18
|
+
export type FireAction = "send" | "wake_and_send" | "skip_down" | "skip_busy";
|
|
19
|
+
export declare function decideFireAction(o: {
|
|
20
|
+
running: boolean;
|
|
21
|
+
busy: boolean;
|
|
22
|
+
wake: boolean;
|
|
23
|
+
skipIfBusy: boolean;
|
|
24
|
+
}): FireAction;
|
|
15
25
|
export declare class Supervisor {
|
|
16
26
|
private readonly opts;
|
|
17
27
|
private server;
|
|
18
28
|
private readonly children;
|
|
29
|
+
/** Live croner schedules, keyed by cron job id (plan/39). */
|
|
30
|
+
private readonly cronJobs;
|
|
19
31
|
private shuttingDown;
|
|
20
32
|
constructor(opts: SupervisorOptions);
|
|
21
33
|
/** Bind the control UDS + spawn all registered daemons. */
|
|
@@ -34,10 +46,42 @@ export declare class Supervisor {
|
|
|
34
46
|
* immediately instead of waiting for the next supervisor restart. */
|
|
35
47
|
private _opStart;
|
|
36
48
|
private _opStopAll;
|
|
49
|
+
/** Stop a single registered daemon by id. Idempotent: a daemon that isn't
|
|
50
|
+
* running returns `stopped: false`. Unknown id → ok:false. Mirrors the
|
|
51
|
+
* per-id semantics of `_opStart`. Cancels any pending restart backoff so a
|
|
52
|
+
* deliberate stop stays stopped. */
|
|
53
|
+
private _opStop;
|
|
54
|
+
/** Restart a single registered daemon by id (stop-if-running, then spawn).
|
|
55
|
+
* Unknown id → ok:false. Resets the crash backoff. */
|
|
56
|
+
private _opRestart;
|
|
37
57
|
private _opRestartAll;
|
|
38
58
|
private _opSend;
|
|
39
59
|
private _opRegister;
|
|
40
60
|
private _opUnregister;
|
|
61
|
+
private _opCronAdd;
|
|
62
|
+
private _opCronList;
|
|
63
|
+
private _opCronRemove;
|
|
64
|
+
private _opCronEnable;
|
|
65
|
+
private _opCronRun;
|
|
66
|
+
private _opCronLog;
|
|
67
|
+
private _jobView;
|
|
68
|
+
/** Rebuild all live `Cron` schedules from the registry (enabled jobs only).
|
|
69
|
+
* Called on start; mutations reconcile incrementally via _scheduleCron/_stopCron. */
|
|
70
|
+
private _reconcileCron;
|
|
71
|
+
private _scheduleCron;
|
|
72
|
+
private _stopCron;
|
|
73
|
+
/** Detail 2: on start, run a catchup job once if its previous scheduled run
|
|
74
|
+
* was missed while the supervisor was down. Opt-in (`catchup`), at most 1×. */
|
|
75
|
+
private _runCatchup;
|
|
76
|
+
/**
|
|
77
|
+
* Fires a cron job: resolves the daemon, decides the action (decideFireAction),
|
|
78
|
+
* acts, and records the outcome — ALWAYS one `last_status` update + one JSONL
|
|
79
|
+
* line, for both fires and skips. Returns the result. `manual` bypasses the
|
|
80
|
+
* disabled-skip (used by `cron run` + catchup).
|
|
81
|
+
*/
|
|
82
|
+
fireJob(jobId: string, opts?: {
|
|
83
|
+
manual?: boolean;
|
|
84
|
+
}): Promise<CronResult | "missing">;
|
|
41
85
|
private _spawnAllFromRegistry;
|
|
42
86
|
private _spawnEntry;
|
|
43
87
|
private _onChildExit;
|