@yefengr/remote-pi 0.7.4 → 0.7.5
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 +81 -586
- package/dist/bin/supervisord.js +4 -5
- package/dist/bin/supervisord.js.map +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/config.js +2 -2
- package/dist/daemon/cli-links.d.ts +30 -0
- package/dist/daemon/cli-links.js +134 -0
- package/dist/daemon/cli-links.js.map +1 -0
- package/dist/daemon/commands.d.ts +27 -0
- package/dist/daemon/commands.js +295 -0
- package/dist/daemon/commands.js.map +1 -0
- package/dist/daemon/control_protocol.d.ts +53 -31
- package/dist/daemon/control_protocol.js +8 -31
- package/dist/daemon/control_protocol.js.map +1 -1
- package/dist/daemon/cron_log.d.ts +2 -23
- package/dist/daemon/cron_log.js +10 -25
- package/dist/daemon/cron_log.js.map +1 -1
- package/dist/daemon/cron_registry.d.ts +3 -40
- package/dist/daemon/cron_registry.js +58 -103
- package/dist/daemon/cron_registry.js.map +1 -1
- package/dist/daemon/install-runtime.d.ts +10 -0
- package/dist/daemon/install-runtime.js +81 -0
- package/dist/daemon/install-runtime.js.map +1 -0
- package/dist/daemon/install.d.ts +3 -63
- package/dist/daemon/install.js +5 -289
- package/dist/daemon/install.js.map +1 -1
- package/dist/daemon/preflight.d.ts +51 -0
- package/dist/daemon/preflight.js +136 -0
- package/dist/daemon/preflight.js.map +1 -0
- package/dist/daemon/registry.d.ts +33 -45
- package/dist/daemon/registry.js +171 -117
- package/dist/daemon/registry.js.map +1 -1
- package/dist/daemon/rpc_child.d.ts +92 -146
- package/dist/daemon/rpc_child.js +336 -263
- package/dist/daemon/rpc_child.js.map +1 -1
- package/dist/daemon/status.d.ts +45 -0
- package/dist/daemon/status.js +87 -0
- package/dist/daemon/status.js.map +1 -0
- package/dist/daemon/supervisor-ipc.d.ts +2 -0
- package/dist/daemon/supervisor-ipc.js +20 -0
- package/dist/daemon/supervisor-ipc.js.map +1 -0
- package/dist/daemon/supervisor.d.ts +48 -71
- package/dist/daemon/supervisor.js +430 -420
- package/dist/daemon/supervisor.js.map +1 -1
- package/dist/extension_ui_bridge.d.ts +4 -3
- package/dist/extension_ui_bridge.js +10 -0
- package/dist/extension_ui_bridge.js.map +1 -1
- package/dist/index.d.ts +25 -230
- package/dist/index.js +515 -5553
- package/dist/index.js.map +1 -1
- package/dist/pairing/crypto.d.ts +8 -1
- package/dist/pairing/crypto.js +56 -6
- package/dist/pairing/crypto.js.map +1 -1
- package/dist/pairing/owner_storage.d.ts +42 -0
- package/dist/pairing/owner_storage.js +207 -0
- package/dist/pairing/owner_storage.js.map +1 -0
- package/dist/pairing/qr.d.ts +3 -42
- package/dist/pairing/qr.js +9 -59
- package/dist/pairing/qr.js.map +1 -1
- package/dist/pairing/storage.d.ts +3 -45
- package/dist/pairing/storage.js +10 -223
- package/dist/pairing/storage.js.map +1 -1
- package/dist/protocol/types.d.ts +1 -1
- package/dist/protocol/v2/schemas.d.ts +1 -1
- package/dist/protocol/v2/schemas.js +1 -1
- package/dist/protocol/v2/schemas.js.map +1 -1
- package/dist/runtime/owner_router.d.ts +16 -0
- package/dist/runtime/owner_router.js +37 -0
- package/dist/runtime/owner_router.js.map +1 -0
- package/dist/session/ipc.d.ts +1 -22
- package/dist/session/ipc.js +4 -11
- package/dist/session/ipc.js.map +1 -1
- package/dist/session/local_config.d.ts +4 -47
- package/dist/session/local_config.js +19 -101
- package/dist/session/local_config.js.map +1 -1
- package/dist/transport/peer_channel.d.ts +25 -39
- package/dist/transport/peer_channel.js +74 -131
- package/dist/transport/peer_channel.js.map +1 -1
- package/dist/transport/relay_client.d.ts +26 -70
- package/dist/transport/relay_client.js +37 -106
- package/dist/transport/relay_client.js.map +1 -1
- package/docs/daemon.md +91 -207
- package/package.json +21 -17
- package/dist/daemon/id.d.ts +0 -24
- package/dist/daemon/id.js +0 -36
- package/dist/daemon/id.js.map +0 -1
- package/dist/mcp/mesh_result.d.ts +0 -10
- package/dist/mcp/mesh_result.js +0 -42
- package/dist/mcp/mesh_result.js.map +0 -1
- package/dist/mcp/mesh_server.d.ts +0 -16
- package/dist/mcp/mesh_server.js +0 -327
- package/dist/mcp/mesh_server.js.map +0 -1
- package/dist/mesh/canonical.d.ts +0 -30
- package/dist/mesh/canonical.js +0 -61
- package/dist/mesh/canonical.js.map +0 -1
- package/dist/mesh/client.d.ts +0 -18
- package/dist/mesh/client.js +0 -125
- package/dist/mesh/client.js.map +0 -1
- package/dist/mesh/encoding.d.ts +0 -38
- package/dist/mesh/encoding.js +0 -216
- package/dist/mesh/encoding.js.map +0 -1
- package/dist/mesh/self_revoke.d.ts +0 -73
- package/dist/mesh/self_revoke.js +0 -401
- package/dist/mesh/self_revoke.js.map +0 -1
- package/dist/mesh/siblings.d.ts +0 -49
- package/dist/mesh/siblings.js +0 -159
- package/dist/mesh/siblings.js.map +0 -1
- package/dist/mesh/types.d.ts +0 -34
- package/dist/mesh/types.js +0 -11
- package/dist/mesh/types.js.map +0 -1
- package/dist/mesh/verify.d.ts +0 -17
- package/dist/mesh/verify.js +0 -86
- package/dist/mesh/verify.js.map +0 -1
- package/dist/rooms.d.ts +0 -29
- package/dist/rooms.js +0 -57
- package/dist/rooms.js.map +0 -1
- package/dist/session/bridge.d.ts +0 -37
- package/dist/session/bridge.js +0 -130
- package/dist/session/bridge.js.map +0 -1
- package/dist/session/broker.d.ts +0 -189
- package/dist/session/broker.js +0 -507
- package/dist/session/broker.js.map +0 -1
- package/dist/session/broker_remote.d.ts +0 -74
- package/dist/session/broker_remote.js +0 -583
- package/dist/session/broker_remote.js.map +0 -1
- package/dist/session/cwd_lock.d.ts +0 -33
- package/dist/session/cwd_lock.js +0 -126
- package/dist/session/cwd_lock.js.map +0 -1
- package/dist/session/envelope.d.ts +0 -33
- package/dist/session/envelope.js +0 -117
- package/dist/session/envelope.js.map +0 -1
- package/dist/session/global_config.d.ts +0 -33
- package/dist/session/global_config.js +0 -73
- package/dist/session/global_config.js.map +0 -1
- package/dist/session/leader_election.d.ts +0 -32
- package/dist/session/leader_election.js +0 -106
- package/dist/session/leader_election.js.map +0 -1
- package/dist/session/mesh_node.d.ts +0 -116
- package/dist/session/mesh_node.js +0 -573
- package/dist/session/mesh_node.js.map +0 -1
- package/dist/session/peer.d.ts +0 -139
- package/dist/session/peer.js +0 -451
- package/dist/session/peer.js.map +0 -1
- package/dist/session/peer_inventory.d.ts +0 -13
- package/dist/session/peer_inventory.js +0 -48
- package/dist/session/peer_inventory.js.map +0 -1
- package/dist/session/peer_limits.d.ts +0 -9
- package/dist/session/peer_limits.js +0 -21
- package/dist/session/peer_limits.js.map +0 -1
- package/dist/session/setup_wizard.d.ts +0 -39
- package/dist/session/setup_wizard.js +0 -63
- package/dist/session/setup_wizard.js.map +0 -1
- package/dist/session/tools.d.ts +0 -24
- package/dist/session/tools.js +0 -252
- package/dist/session/tools.js.map +0 -1
- package/dist/session/wizard.d.ts +0 -13
- package/dist/session/wizard.js +0 -20
- package/dist/session/wizard.js.map +0 -1
- package/dist/transport/pi_forward_client.d.ts +0 -29
- package/dist/transport/pi_forward_client.js +0 -62
- package/dist/transport/pi_forward_client.js.map +0 -1
- package/dist/ui/footer.d.ts +0 -32
- package/dist/ui/footer.js +0 -34
- package/dist/ui/footer.js.map +0 -1
- package/skills/agent-network/SKILL.md +0 -310
|
@@ -3,135 +3,96 @@ import { homedir } from "node:os";
|
|
|
3
3
|
import { randomBytes } from "node:crypto";
|
|
4
4
|
import { dirname, join } from "node:path";
|
|
5
5
|
import { Cron } from "croner";
|
|
6
|
-
/**
|
|
7
|
-
* Cron registry: scheduled prompts for daemons, persisted at
|
|
8
|
-
* `~/.pi/remote/cron.json`. Mirrors `registry.ts` (`daemons.json`) — tolerant
|
|
9
|
-
* load (missing/corrupt → empty), atomic-ish full-file save.
|
|
10
|
-
*
|
|
11
|
-
* Each job targets a daemon by its `daemon_id` (the 8-hex id from
|
|
12
|
-
* `daemonIdForCwd`) and fires `prompt` on `schedule` (a cron expression, run
|
|
13
|
-
* by croner in the supervisor). The scheduler engine + `fireJob` live in
|
|
14
|
-
* `supervisor.ts`; this module only owns persistence + schedule validation.
|
|
15
|
-
*
|
|
16
|
-
* Plan/39. Decisions B (croner), C (min-interval 60s), E (audit via cron_log).
|
|
17
|
-
*/
|
|
18
|
-
/** Minimum allowed interval between two consecutive runs of a schedule. */
|
|
19
6
|
export const MIN_INTERVAL_MS = 60_000;
|
|
20
7
|
function cronPath() {
|
|
21
8
|
const root = process.env["REMOTE_PI_HOME"] || homedir();
|
|
22
9
|
return join(root, ".pi", "remote", "cron.json");
|
|
23
10
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
return cronPath();
|
|
27
|
-
}
|
|
28
|
-
/** Reads the registry; returns empty on missing/corrupt file. */
|
|
11
|
+
export function cronRegistryPath() { return cronPath(); }
|
|
12
|
+
/** Old wake-bearing jobs are intentionally not carried into the new contract. */
|
|
29
13
|
export function loadCronRegistry() {
|
|
30
14
|
if (!existsSync(cronPath()))
|
|
31
15
|
return { jobs: [] };
|
|
32
16
|
try {
|
|
33
17
|
const parsed = JSON.parse(readFileSync(cronPath(), "utf8"));
|
|
34
|
-
if (!parsed || typeof parsed !== "object")
|
|
35
|
-
return { jobs: [] };
|
|
36
|
-
const arr = parsed.jobs;
|
|
37
|
-
if (!Array.isArray(arr))
|
|
18
|
+
if (!parsed || typeof parsed !== "object" || !Array.isArray(parsed.jobs))
|
|
38
19
|
return { jobs: [] };
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
jobs.push(job);
|
|
44
|
-
}
|
|
45
|
-
return { jobs };
|
|
20
|
+
return { jobs: parsed.jobs.flatMap((item) => {
|
|
21
|
+
const job = coerceJob(item);
|
|
22
|
+
return job ? [job] : [];
|
|
23
|
+
}) };
|
|
46
24
|
}
|
|
47
25
|
catch {
|
|
48
26
|
return { jobs: [] };
|
|
49
27
|
}
|
|
50
28
|
}
|
|
51
|
-
export function saveCronRegistry(
|
|
29
|
+
export function saveCronRegistry(registry) {
|
|
52
30
|
mkdirSync(dirname(cronPath()), { recursive: true });
|
|
53
|
-
writeFileSync(cronPath(), JSON.stringify(
|
|
54
|
-
}
|
|
55
|
-
export function listJobs() {
|
|
56
|
-
return loadCronRegistry().jobs;
|
|
31
|
+
writeFileSync(cronPath(), JSON.stringify(registry, null, 2) + "\n");
|
|
57
32
|
}
|
|
58
|
-
export function
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
/** Adds a job with a fresh `j_<hex>` id. Pure persistence — call
|
|
62
|
-
* `validateSchedule` first at the op/CLI boundary. */
|
|
33
|
+
export function listJobs() { return loadCronRegistry().jobs; }
|
|
34
|
+
export function getJob(id) { return listJobs().find((job) => job.id === id); }
|
|
63
35
|
export function addJob(input) {
|
|
64
|
-
const
|
|
36
|
+
const registry = loadCronRegistry();
|
|
65
37
|
const job = {
|
|
66
|
-
id:
|
|
38
|
+
id: freshId(registry.jobs),
|
|
67
39
|
daemon_id: input.daemon_id,
|
|
68
40
|
schedule: input.schedule,
|
|
69
41
|
prompt: input.prompt,
|
|
70
42
|
enabled: true,
|
|
71
43
|
skip_if_busy: input.skip_if_busy ?? true,
|
|
72
|
-
wake: input.wake ?? false,
|
|
73
44
|
catchup: input.catchup ?? false,
|
|
74
45
|
created_at: new Date().toISOString(),
|
|
75
46
|
};
|
|
76
47
|
if (input.tz)
|
|
77
48
|
job.tz = input.tz;
|
|
78
|
-
|
|
79
|
-
saveCronRegistry(
|
|
49
|
+
registry.jobs.push(job);
|
|
50
|
+
saveCronRegistry(registry);
|
|
80
51
|
return job;
|
|
81
52
|
}
|
|
82
53
|
export function removeJob(id) {
|
|
83
|
-
const
|
|
84
|
-
const
|
|
85
|
-
if (
|
|
54
|
+
const registry = loadCronRegistry();
|
|
55
|
+
const index = registry.jobs.findIndex((job) => job.id === id);
|
|
56
|
+
if (index < 0)
|
|
86
57
|
return false;
|
|
87
|
-
|
|
88
|
-
saveCronRegistry(
|
|
58
|
+
registry.jobs.splice(index, 1);
|
|
59
|
+
saveCronRegistry(registry);
|
|
89
60
|
return true;
|
|
90
61
|
}
|
|
91
62
|
export function setJobEnabled(id, enabled) {
|
|
92
|
-
const
|
|
93
|
-
const job =
|
|
63
|
+
const registry = loadCronRegistry();
|
|
64
|
+
const job = registry.jobs.find((item) => item.id === id);
|
|
94
65
|
if (!job)
|
|
95
66
|
return false;
|
|
96
67
|
job.enabled = enabled;
|
|
97
|
-
saveCronRegistry(
|
|
68
|
+
saveCronRegistry(registry);
|
|
98
69
|
return true;
|
|
99
70
|
}
|
|
100
|
-
/** Records the outcome of a fire on the job (the `cron list` shortcut). */
|
|
101
71
|
export function recordRun(id, at, status) {
|
|
102
|
-
const
|
|
103
|
-
const job =
|
|
72
|
+
const registry = loadCronRegistry();
|
|
73
|
+
const job = registry.jobs.find((item) => item.id === id);
|
|
104
74
|
if (!job)
|
|
105
75
|
return;
|
|
106
76
|
job.last_run = at;
|
|
107
77
|
job.last_status = status;
|
|
108
|
-
saveCronRegistry(
|
|
78
|
+
saveCronRegistry(registry);
|
|
109
79
|
}
|
|
110
|
-
/**
|
|
111
|
-
* Validates a cron expression via croner and enforces the ≥60s min-interval
|
|
112
|
-
* (decision C — guards against pileup + token burn). Returns `ok:false` with a
|
|
113
|
-
* user-facing message on a bad expression or a too-frequent schedule.
|
|
114
|
-
*/
|
|
115
80
|
export function validateSchedule(schedule, tz) {
|
|
116
81
|
let cron;
|
|
117
82
|
try {
|
|
118
83
|
cron = new Cron(schedule, tz ? { timezone: tz } : {});
|
|
119
84
|
}
|
|
120
|
-
catch (
|
|
121
|
-
return { ok: false, error: `invalid cron expression: ${
|
|
85
|
+
catch (error) {
|
|
86
|
+
return { ok: false, error: `invalid cron expression: ${error.message}` };
|
|
122
87
|
}
|
|
123
88
|
try {
|
|
124
|
-
const
|
|
125
|
-
const
|
|
126
|
-
if (!
|
|
89
|
+
const first = cron.nextRun();
|
|
90
|
+
const second = first ? cron.nextRun(first) : null;
|
|
91
|
+
if (!first || !second)
|
|
127
92
|
return { ok: false, error: "schedule has no upcoming runs" };
|
|
128
|
-
const intervalMs =
|
|
93
|
+
const intervalMs = second.getTime() - first.getTime();
|
|
129
94
|
if (intervalMs < MIN_INTERVAL_MS) {
|
|
130
|
-
return {
|
|
131
|
-
ok: false,
|
|
132
|
-
intervalMs,
|
|
133
|
-
error: `schedule too frequent: ~${Math.round(intervalMs / 1000)}s between runs (minimum is 60s)`,
|
|
134
|
-
};
|
|
95
|
+
return { ok: false, intervalMs, error: `schedule too frequent: ~${Math.round(intervalMs / 1000)}s between runs (minimum is 60s)` };
|
|
135
96
|
}
|
|
136
97
|
return { ok: true, intervalMs };
|
|
137
98
|
}
|
|
@@ -139,56 +100,50 @@ export function validateSchedule(schedule, tz) {
|
|
|
139
100
|
cron.stop();
|
|
140
101
|
}
|
|
141
102
|
}
|
|
142
|
-
/** Returns the next scheduled run for a job, or null. Used by `cron list`. */
|
|
143
103
|
export function nextRunFor(job) {
|
|
144
104
|
try {
|
|
145
105
|
const cron = new Cron(job.schedule, job.tz ? { timezone: job.tz } : {});
|
|
146
|
-
const
|
|
106
|
+
const next = cron.nextRun();
|
|
147
107
|
cron.stop();
|
|
148
|
-
return
|
|
108
|
+
return next;
|
|
149
109
|
}
|
|
150
110
|
catch {
|
|
151
111
|
return null;
|
|
152
112
|
}
|
|
153
113
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
for (let i = 0; i < 1000; i++) {
|
|
114
|
+
function freshId(existing) {
|
|
115
|
+
for (let attempt = 0; attempt < 1000; attempt += 1) {
|
|
157
116
|
const id = `j_${randomBytes(4).toString("hex")}`;
|
|
158
|
-
if (!existing.some((
|
|
117
|
+
if (!existing.some((job) => job.id === id))
|
|
159
118
|
return id;
|
|
160
119
|
}
|
|
161
120
|
throw new Error("cron id space exhausted");
|
|
162
121
|
}
|
|
163
|
-
function
|
|
164
|
-
if (!
|
|
165
|
-
return null;
|
|
166
|
-
const o = item;
|
|
167
|
-
if (typeof o["id"] !== "string")
|
|
168
|
-
return null;
|
|
169
|
-
if (typeof o["daemon_id"] !== "string")
|
|
122
|
+
function coerceJob(value) {
|
|
123
|
+
if (!value || typeof value !== "object")
|
|
170
124
|
return null;
|
|
171
|
-
|
|
125
|
+
const raw = value;
|
|
126
|
+
// No dual-read/migration of wake: old records are deliberately excluded.
|
|
127
|
+
if (Object.hasOwn(raw, "wake"))
|
|
172
128
|
return null;
|
|
173
|
-
if (typeof
|
|
129
|
+
if (typeof raw["id"] !== "string" || typeof raw["daemon_id"] !== "string" || typeof raw["schedule"] !== "string" || typeof raw["prompt"] !== "string")
|
|
174
130
|
return null;
|
|
175
131
|
const job = {
|
|
176
|
-
id:
|
|
177
|
-
daemon_id:
|
|
178
|
-
schedule:
|
|
179
|
-
prompt:
|
|
180
|
-
enabled:
|
|
181
|
-
skip_if_busy:
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
created_at: typeof o["created_at"] === "string" ? o["created_at"] : new Date(0).toISOString(),
|
|
132
|
+
id: raw["id"],
|
|
133
|
+
daemon_id: raw["daemon_id"],
|
|
134
|
+
schedule: raw["schedule"],
|
|
135
|
+
prompt: raw["prompt"],
|
|
136
|
+
enabled: raw["enabled"] !== false,
|
|
137
|
+
skip_if_busy: raw["skip_if_busy"] !== false,
|
|
138
|
+
catchup: raw["catchup"] === true,
|
|
139
|
+
created_at: typeof raw["created_at"] === "string" ? raw["created_at"] : new Date(0).toISOString(),
|
|
185
140
|
};
|
|
186
|
-
if (typeof
|
|
187
|
-
job.tz =
|
|
188
|
-
if (typeof
|
|
189
|
-
job.last_run =
|
|
190
|
-
if (typeof
|
|
191
|
-
job.last_status =
|
|
141
|
+
if (typeof raw["tz"] === "string")
|
|
142
|
+
job.tz = raw["tz"];
|
|
143
|
+
if (typeof raw["last_run"] === "string")
|
|
144
|
+
job.last_run = raw["last_run"];
|
|
145
|
+
if (typeof raw["last_status"] === "string")
|
|
146
|
+
job.last_status = raw["last_status"];
|
|
192
147
|
return job;
|
|
193
148
|
}
|
|
194
149
|
//# sourceMappingURL=cron_registry.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cron_registry.js","sourceRoot":"","sources":["../../src/daemon/cron_registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B
|
|
1
|
+
{"version":3,"file":"cron_registry.js","sourceRoot":"","sources":["../../src/daemon/cron_registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC;AAmBtC,SAAS,QAAQ;IACf,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,IAAI,OAAO,EAAE,CAAC;IACxD,OAAO,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAC;AAClD,CAAC;AAED,MAAM,UAAU,gBAAgB,KAAa,OAAO,QAAQ,EAAE,CAAC,CAAC,CAAC;AAEjE,iFAAiF;AACjF,MAAM,UAAU,gBAAgB;IAC9B,IAAI,CAAC,UAAU,C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AC,IAAI,CAAC,KAAK,QAAQ;QAAE,GAAG,CAAC,EAAE,GAAG,GAAG,CAAC,IAAI,CAAC,CAAC;IACtD,IAAI,OAAO,GAAG,CAAC,UAAU,CAAC,KAAK,QAAQ;QAAE,GAAG,CAAC,QAAQ,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC;IACxE,IAAI,OAAO,GAAG,CAAC,aAAa,CAAC,KAAK,QAAQ;QAAE,GAAG,CAAC,WAAW,GAAG,GAAG,CAAC,aAAa,CAAC,CAAC;IACjF,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare function execCommand(cmd: string, args: string[], log: string[]): void;
|
|
2
|
+
/** Cleanup commands may fail when the service is not currently installed. */
|
|
3
|
+
export declare function tryExecCommand(cmd: string, args: string[], log: string[]): void;
|
|
4
|
+
/** Build the elevated Windows batch script. Kept pure for cross-platform tests. */
|
|
5
|
+
export declare function buildElevatedCmd(lines: string[], logFile: string): string;
|
|
6
|
+
/** Run a schtasks sequence through one UAC prompt and surface its output. */
|
|
7
|
+
export declare function execElevatedWindows(lines: string[], log: string[]): void;
|
|
8
|
+
export declare const _exec: typeof execCommand;
|
|
9
|
+
export declare const _tryExec: typeof tryExecCommand;
|
|
10
|
+
export declare const _execElevatedWindows: typeof execElevatedWindows;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { execFileSync } from "node:child_process";
|
|
2
|
+
import { readFileSync, unlinkSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { tmpdir } from "node:os";
|
|
5
|
+
export function execCommand(cmd, args, log) {
|
|
6
|
+
try {
|
|
7
|
+
const out = execFileSync(cmd, args, { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] });
|
|
8
|
+
if (out.trim())
|
|
9
|
+
log.push(`$ ${cmd} ${args.join(" ")}\n${out.trim()}`);
|
|
10
|
+
else
|
|
11
|
+
log.push(`$ ${cmd} ${args.join(" ")}`);
|
|
12
|
+
}
|
|
13
|
+
catch (error) {
|
|
14
|
+
const err = error;
|
|
15
|
+
const stderr = typeof err.stderr === "string" ? err.stderr : err.stderr?.toString() ?? "";
|
|
16
|
+
throw new Error(`\`${cmd} ${args.join(" ")}\` exited ${err.status ?? "?"}\n${stderr.trim() || err.message}`);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/** Cleanup commands may fail when the service is not currently installed. */
|
|
20
|
+
export function tryExecCommand(cmd, args, log) {
|
|
21
|
+
try {
|
|
22
|
+
execCommand(cmd, args, log);
|
|
23
|
+
}
|
|
24
|
+
catch { /* expected cleanup failure */ }
|
|
25
|
+
}
|
|
26
|
+
/** Build the elevated Windows batch script. Kept pure for cross-platform tests. */
|
|
27
|
+
export function buildElevatedCmd(lines, logFile) {
|
|
28
|
+
const redirect = ` >> "${logFile}" 2>&1`;
|
|
29
|
+
const body = lines.map((line) => /^\s*(if|exit|rem|@)/i.test(line) ? line : line + redirect);
|
|
30
|
+
return ["@echo off", ...body].join("\r\n") + "\r\n";
|
|
31
|
+
}
|
|
32
|
+
function readIfExists(path) {
|
|
33
|
+
try {
|
|
34
|
+
return readFileSync(path, "utf8");
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
return "";
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/** Run a schtasks sequence through one UAC prompt and surface its output. */
|
|
41
|
+
export function execElevatedWindows(lines, log) {
|
|
42
|
+
const base = join(tmpdir(), `remote-pi-elevate-${process.pid}`);
|
|
43
|
+
const cmdPath = `${base}.cmd`;
|
|
44
|
+
const logFile = `${base}.log`;
|
|
45
|
+
writeFileSync(cmdPath, buildElevatedCmd(lines, logFile));
|
|
46
|
+
try {
|
|
47
|
+
unlinkSync(logFile);
|
|
48
|
+
}
|
|
49
|
+
catch { /* none yet */ }
|
|
50
|
+
let thrown = null;
|
|
51
|
+
try {
|
|
52
|
+
execFileSync("powershell", [
|
|
53
|
+
"-NoProfile", "-NonInteractive", "-Command",
|
|
54
|
+
`$p = Start-Process -FilePath cmd.exe -ArgumentList '/c','"${cmdPath}"' ` +
|
|
55
|
+
"-Verb RunAs -Wait -PassThru -WindowStyle Hidden; exit $p.ExitCode",
|
|
56
|
+
], { stdio: ["ignore", "pipe", "pipe"] });
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
thrown = error;
|
|
60
|
+
}
|
|
61
|
+
const output = readIfExists(logFile).trim();
|
|
62
|
+
if (output)
|
|
63
|
+
log.push(output);
|
|
64
|
+
try {
|
|
65
|
+
unlinkSync(cmdPath);
|
|
66
|
+
}
|
|
67
|
+
catch { /* best-effort */ }
|
|
68
|
+
try {
|
|
69
|
+
unlinkSync(logFile);
|
|
70
|
+
}
|
|
71
|
+
catch { /* best-effort */ }
|
|
72
|
+
if (thrown) {
|
|
73
|
+
throw new Error("administrator privileges required — the UAC prompt was declined or the " +
|
|
74
|
+
"schtasks operation failed. Run the command again and accept the Windows " +
|
|
75
|
+
`elevation prompt.${output ? `\n${output}` : ""}`);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
export const _exec = execCommand;
|
|
79
|
+
export const _tryExec = tryExecCommand;
|
|
80
|
+
export const _execElevatedWindows = execElevatedWindows;
|
|
81
|
+
//# sourceMappingURL=install-runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"install-runtime.js","sourceRoot":"","sources":["../../src/daemon/install-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAClE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEjC,MAAM,UAAU,WAAW,CAAC,GAAW,EAAE,IAAc,EAAE,GAAa;IACpE,IAAI,CAAC;QACH,MAAM,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ACf,MAAM,GAAG,KAAK,CAAC;IACjB,CAAC;IAED,MAAM,MAAM,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,CAAC;IAC5C,IAAI,MAAM;QAAE,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC7B,IAAI,CAAC;QAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IAAC,CAAC;IAAC,MAAM,CAAC,CAAC,iBAAiB,CAAC,CAAC;IACxD,IAAI,CAAC;QAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IAAC,CAAC;IAAC,MAAM,CAAC,CAAC,iBAAiB,CAAC,CAAC;IAExD,IAAI,MAAM,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CACb,yEAAyE;YACzE,0EAA0E;YAC1E,oBAAoB,MAAM,CAAC,CAAC,CAAC,KAAK,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAClD,CAAC;IACJ,CAAC;AACH,CAAC;AAED,MAAM,CAAC,MAAM,KAAK,GAAG,WAAW,CAAC;AACjC,MAAM,CAAC,MAAM,QAAQ,GAAG,cAAc,CAAC;AACvC,MAAM,CAAC,MAAM,oBAAoB,GAAG,mBAAmB,CAAC"}
|
package/dist/daemon/install.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
export { buildElevatedCmd } from "./install-runtime.js";
|
|
2
|
+
export { buildCmdShim, isOnPath, linkCliBinaries, unlinkCliBinaries, userLocalBinDir, } from "./cli-links.js";
|
|
3
|
+
export type { LinkBinariesResult, UnlinkBinariesResult } from "./cli-links.js";
|
|
1
4
|
/**
|
|
2
5
|
* Generates and activates a system service for `pi-supervisord` so the
|
|
3
6
|
* daemon fleet survives reboots (plan/26 W3).
|
|
@@ -105,66 +108,3 @@ export interface UninstallResult {
|
|
|
105
108
|
log: string[];
|
|
106
109
|
}
|
|
107
110
|
export declare function uninstallService(): UninstallResult;
|
|
108
|
-
/**
|
|
109
|
-
* Build the batch script run elevated. Each command line redirects its output
|
|
110
|
-
* to `logFile` so the (separate, elevated) process's output can be read back by
|
|
111
|
-
* the parent. Control-flow lines (`if`/`exit`/`rem`/`@`) run bare — redirecting
|
|
112
|
-
* them would swallow the exit code. Pure + exported for tests.
|
|
113
|
-
*/
|
|
114
|
-
export declare function buildElevatedCmd(lines: string[], logFile: string): string;
|
|
115
|
-
export interface LinkBinariesResult {
|
|
116
|
-
/** `~/.local/bin/`. The two symlinks land here. */
|
|
117
|
-
binDir: string;
|
|
118
|
-
/** Paths of the two symlinks we created/refreshed. */
|
|
119
|
-
links: Array<{
|
|
120
|
-
name: string;
|
|
121
|
-
path: string;
|
|
122
|
-
target: string;
|
|
123
|
-
}>;
|
|
124
|
-
/** True when `binDir` is already on `$PATH`. False → caller surfaces the
|
|
125
|
-
* "add this line to your shell rc" hint to the user. */
|
|
126
|
-
onPath: boolean;
|
|
127
|
-
log: string[];
|
|
128
|
-
}
|
|
129
|
-
export declare function userLocalBinDir(home?: string): string;
|
|
130
|
-
/**
|
|
131
|
-
* Check whether `dir` is on `process.env.PATH`. Tolerates trailing
|
|
132
|
-
* slashes and relative entries (which we treat as not matching — `~/.local/bin`
|
|
133
|
-
* is always absolute on our end).
|
|
134
|
-
*/
|
|
135
|
-
export declare function isOnPath(dir: string, envPath?: string): boolean;
|
|
136
|
-
/**
|
|
137
|
-
* Create (or refresh) the `remote-pi` + `pi-supervisord` symlinks in
|
|
138
|
-
* `~/.local/bin/`. Idempotent — replaces stale links pointing at old
|
|
139
|
-
* extension paths (Pi can reinstall the extension to a different hash dir
|
|
140
|
-
* on upgrades, so this MUST overwrite).
|
|
141
|
-
*
|
|
142
|
-
* Returns `onPath: false` when `~/.local/bin` isn't in the user's `$PATH`.
|
|
143
|
-
* The caller is responsible for surfacing the shell-rc instruction —
|
|
144
|
-
* we don't edit the user's shell config files automatically.
|
|
145
|
-
*/
|
|
146
|
-
export declare function linkCliBinaries(home?: string, paths?: {
|
|
147
|
-
remotePi?: string;
|
|
148
|
-
supervisord?: string;
|
|
149
|
-
}, opts?: {
|
|
150
|
-
node?: string;
|
|
151
|
-
mutatePath?: boolean;
|
|
152
|
-
}): LinkBinariesResult;
|
|
153
|
-
/** A Windows `.cmd` shim that forwards all args to `node "<target>"`. Pure. */
|
|
154
|
-
export declare function buildCmdShim(node: string, target: string): string;
|
|
155
|
-
/**
|
|
156
|
-
* Remove the symlinks `linkCliBinaries` created. Idempotent — missing
|
|
157
|
-
* links are a no-op. Returns whether each link was actually present so
|
|
158
|
-
* the caller can render a useful summary. Targets (the extension files)
|
|
159
|
-
* are NOT touched here — they live outside this dir and belong to Pi.
|
|
160
|
-
*/
|
|
161
|
-
export interface UnlinkBinariesResult {
|
|
162
|
-
binDir: string;
|
|
163
|
-
removed: Array<{
|
|
164
|
-
name: string;
|
|
165
|
-
path: string;
|
|
166
|
-
existed: boolean;
|
|
167
|
-
}>;
|
|
168
|
-
log: string[];
|
|
169
|
-
}
|
|
170
|
-
export declare function unlinkCliBinaries(home?: string): UnlinkBinariesResult;
|