shellpuppet 0.5.1 → 0.5.3
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 +5 -5
- package/dist/agents/agy/nudge.js +58 -5
- package/dist/agents/agy/nudge.js.map +1 -1
- package/dist/agents/codex/index.js +1 -1
- package/dist/agents/codex/index.js.map +1 -1
- package/dist/agents/hermes/index.js +2 -2
- package/dist/agents/hermes/index.js.map +1 -1
- package/dist/agents/hermes/nudge.d.ts +1 -0
- package/dist/agents/hermes/nudge.js +5 -0
- package/dist/agents/hermes/nudge.js.map +1 -1
- package/dist/agents/types.d.ts +4 -0
- package/dist/cli/index.js +47 -3
- package/dist/cli/index.js.map +1 -1
- package/dist/client/http.d.ts +2 -2
- package/dist/client/http.js +1 -1
- package/dist/client/http.js.map +1 -1
- package/dist/core/dialogs.d.ts +4 -1
- package/dist/core/dialogs.js +25 -5
- package/dist/core/dialogs.js.map +1 -1
- package/dist/core/mailbox.d.ts +25 -4
- package/dist/core/mailbox.js +36 -5
- package/dist/core/mailbox.js.map +1 -1
- package/dist/core/manager.d.ts +1 -0
- package/dist/core/manager.js +5 -1
- package/dist/core/manager.js.map +1 -1
- package/dist/core/policy.d.ts +5 -3
- package/dist/core/policy.js +25 -23
- package/dist/core/policy.js.map +1 -1
- package/dist/core/readingContext.d.ts +9 -0
- package/dist/core/readingContext.js +4 -0
- package/dist/core/readingContext.js.map +1 -0
- package/dist/core/reasoning.d.ts +2 -1
- package/dist/core/reasoning.js +33 -11
- package/dist/core/reasoning.js.map +1 -1
- package/dist/core/renderer.d.ts +5 -0
- package/dist/core/renderer.js +31 -2
- package/dist/core/renderer.js.map +1 -1
- package/dist/core/session.d.ts +50 -32
- package/dist/core/session.js +333 -164
- package/dist/core/session.js.map +1 -1
- package/dist/daemon/config.d.ts +11 -1
- package/dist/daemon/config.js +42 -20
- package/dist/daemon/config.js.map +1 -1
- package/dist/daemon/configReload.d.ts +55 -0
- package/dist/daemon/configReload.js +284 -0
- package/dist/daemon/configReload.js.map +1 -0
- package/dist/daemon/configWatcher.d.ts +55 -0
- package/dist/daemon/configWatcher.js +313 -0
- package/dist/daemon/configWatcher.js.map +1 -0
- package/dist/daemon/homeOwner.d.ts +2 -1
- package/dist/daemon/homeOwner.js +33 -8
- package/dist/daemon/homeOwner.js.map +1 -1
- package/dist/daemon/index.js +3 -50
- package/dist/daemon/index.js.map +1 -1
- package/dist/daemon/launchProfiles.d.ts +5 -3
- package/dist/daemon/launchProfiles.js +12 -7
- package/dist/daemon/launchProfiles.js.map +1 -1
- package/dist/daemon/nudgeScheduler.d.ts +4 -4
- package/dist/daemon/nudgeScheduler.js +16 -15
- package/dist/daemon/nudgeScheduler.js.map +1 -1
- package/dist/daemon/paths.d.ts +22 -4
- package/dist/daemon/paths.js +126 -24
- package/dist/daemon/paths.js.map +1 -1
- package/dist/daemon/restartSource.d.ts +3 -3
- package/dist/daemon/restartSource.js +5 -4
- package/dist/daemon/restartSource.js.map +1 -1
- package/dist/daemon/schedules.d.ts +6 -5
- package/dist/daemon/schedules.js +15 -51
- package/dist/daemon/schedules.js.map +1 -1
- package/dist/daemon/server.d.ts +27 -17
- package/dist/daemon/server.js +576 -453
- package/dist/daemon/server.js.map +1 -1
- package/dist/daemon/standaloneOptions.d.ts +4 -0
- package/dist/daemon/standaloneOptions.js +29 -0
- package/dist/daemon/standaloneOptions.js.map +1 -0
- package/dist/mcp/index.js +0 -4
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/tools.d.ts +0 -6
- package/dist/mcp/tools.js +90 -85
- package/dist/mcp/tools.js.map +1 -1
- package/dist/viewer/dashboard.css +24 -2
- package/dist/viewer/dashboard.html +1 -1
- package/dist/viewer/dashboard.js +127 -16
- package/dist/viewer/index.html +4 -3
- package/dist/viewer/pane.js +91 -395
- package/dist/viewer/viewer.css +23 -4
- package/dist/viewer/viewer.js +2 -0
- package/package.json +1 -1
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
import * as fs from 'node:fs';
|
|
2
|
+
import { spawn } from 'node:child_process';
|
|
3
|
+
import { createInterface } from 'node:readline';
|
|
4
|
+
import { join, resolve } from 'node:path';
|
|
5
|
+
import { configPath, ensureWatchedHome, HomeIdentityError } from './paths.js';
|
|
6
|
+
const permissionProblem = 'Cannot verify owner-only permissions for config.json or its directory.';
|
|
7
|
+
const windowsPermissions = `
|
|
8
|
+
function Test-ConfigPermissions([bool]$includeFile) {
|
|
9
|
+
$ErrorActionPreference = 'Stop'
|
|
10
|
+
$id = [Security.Principal.WindowsIdentity]::GetCurrent()
|
|
11
|
+
$sid = $id.User
|
|
12
|
+
$items = @([IO.DirectoryInfo]::new($env:SP_HOME))
|
|
13
|
+
if ($includeFile) { $items += [IO.FileInfo]::new([IO.Path]::Combine($env:SP_HOME,'config.json')) }
|
|
14
|
+
foreach ($item in $items) {
|
|
15
|
+
if (!$item.Exists) { return $false }
|
|
16
|
+
if ($item.Attributes -band [IO.FileAttributes]::ReparsePoint) { return $false }
|
|
17
|
+
$acl = $item.GetAccessControl()
|
|
18
|
+
$rules = @($acl.GetAccessRules($true,$true,$sid.GetType()))
|
|
19
|
+
if ($rules.Count -ne 1 -or $rules[0].IdentityReference -ne $sid -or
|
|
20
|
+
$rules[0].AccessControlType -ne 'Allow' -or [int]$rules[0].PropagationFlags -ne 0 -or $rules[0].FileSystemRights -ne 'FullControl') { return $false }
|
|
21
|
+
$owner = $acl.GetOwner($sid.GetType())
|
|
22
|
+
if ($owner -ne $sid -and !($item -is [IO.FileInfo] -and $rules[0].IsInherited -and $owner -eq $id.Owner)) { return $false }
|
|
23
|
+
if ($item -is [IO.DirectoryInfo] -and (!$acl.AreAccessRulesProtected -or [int]$rules[0].InheritanceFlags -ne 3)) { return $false }
|
|
24
|
+
}
|
|
25
|
+
return $true
|
|
26
|
+
}
|
|
27
|
+
`;
|
|
28
|
+
const powershell = () => join(process.env['SystemRoot'] ?? 'C:\\Windows', 'System32', 'WindowsPowerShell', 'v1.0', 'powershell.exe');
|
|
29
|
+
const argsFor = (script) => ['-NoProfile', '-NonInteractive', '-EncodedCommand',
|
|
30
|
+
Buffer.from(windowsPermissions + script, 'utf16le').toString('base64')];
|
|
31
|
+
const aclEnv = (home) => ({ SystemRoot: process.env['SystemRoot'], SP_HOME: home });
|
|
32
|
+
function namesDirectory(spelling, expected) {
|
|
33
|
+
try {
|
|
34
|
+
const named = fs.statSync(spelling, { bigint: true });
|
|
35
|
+
return named.dev === expected.dev && named.ino === expected.ino;
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/** Reuse the Windows ACL reader. Requests check only this daemon's fixed home and config. */
|
|
42
|
+
export class ConfigPermissions {
|
|
43
|
+
home;
|
|
44
|
+
child;
|
|
45
|
+
reply;
|
|
46
|
+
secured;
|
|
47
|
+
constructor(home) {
|
|
48
|
+
this.home = home;
|
|
49
|
+
}
|
|
50
|
+
async secureHome() {
|
|
51
|
+
this.secured = undefined;
|
|
52
|
+
try {
|
|
53
|
+
const spelling = resolve(this.home);
|
|
54
|
+
const secured = await ensureWatchedHome(this.home, (script, env) => {
|
|
55
|
+
this.close();
|
|
56
|
+
this.startReader(env['SP_PRIVATE_HOME'], script, env);
|
|
57
|
+
return this.waitForReply(15_000);
|
|
58
|
+
});
|
|
59
|
+
// Normalising a path can collapse ".." across a symbolic link.
|
|
60
|
+
// Use that spelling only if it reaches the directory we actually hardened.
|
|
61
|
+
const useSpelling = spelling === secured.directory || namesDirectory(spelling, secured.stat);
|
|
62
|
+
this.secured = { ...secured, spelling: useSpelling ? spelling : secured.directory };
|
|
63
|
+
return this.verifiedHome();
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
this.secured = undefined;
|
|
67
|
+
this.close();
|
|
68
|
+
throw error;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
verifiedHome() {
|
|
72
|
+
if (!this.secured)
|
|
73
|
+
throw new HomeIdentityError(permissionProblem);
|
|
74
|
+
const { directory, spelling, stat } = this.secured;
|
|
75
|
+
const current = fileStat(directory);
|
|
76
|
+
if (!current?.isDirectory() || stat.dev !== current.dev || stat.ino !== current.ino)
|
|
77
|
+
throw new HomeIdentityError(permissionProblem);
|
|
78
|
+
if (spelling !== directory && !namesDirectory(spelling, stat))
|
|
79
|
+
throw new HomeIdentityError(permissionProblem);
|
|
80
|
+
return directory;
|
|
81
|
+
}
|
|
82
|
+
/** The caller's absolute spelling, while it still names the secured directory. */
|
|
83
|
+
get homePath() {
|
|
84
|
+
this.verifiedHome();
|
|
85
|
+
return this.secured.spelling;
|
|
86
|
+
}
|
|
87
|
+
/** Inspect the opened file and its entry under the directory we hardened. */
|
|
88
|
+
async read() {
|
|
89
|
+
const { secured } = this;
|
|
90
|
+
if (!secured)
|
|
91
|
+
throw new Error(permissionProblem);
|
|
92
|
+
const home = secured.directory;
|
|
93
|
+
const file = configPath(home);
|
|
94
|
+
const dir = fileStat(home);
|
|
95
|
+
if (!dir?.isDirectory() || dir.dev !== secured.stat.dev || dir.ino !== secured.stat.ino)
|
|
96
|
+
throw new Error(permissionProblem);
|
|
97
|
+
const before = fileStat(file);
|
|
98
|
+
const uid = process.getuid?.();
|
|
99
|
+
if ((before && (!before.isFile() || before.nlink !== 1n)) ||
|
|
100
|
+
(uid !== undefined && (dir.uid !== BigInt(uid) || (dir.mode & 63n) !== 0n ||
|
|
101
|
+
(before && (before.uid !== BigInt(uid) || (before.mode & 18n) !== 0n)))))
|
|
102
|
+
throw new Error(permissionProblem);
|
|
103
|
+
let verifiedDir = dir;
|
|
104
|
+
const current = () => same(verifiedDir, fileStat(home)) && same(before, fileStat(file));
|
|
105
|
+
const recheckDirectory = async () => {
|
|
106
|
+
const directory = fileStat(home);
|
|
107
|
+
if (!directory || directory.dev !== dir.dev || directory.ino !== dir.ino ||
|
|
108
|
+
directory.mode !== dir.mode || directory.uid !== dir.uid || directory.gid !== dir.gid ||
|
|
109
|
+
!same(before, fileStat(file)))
|
|
110
|
+
return false;
|
|
111
|
+
if (process.platform === 'win32')
|
|
112
|
+
await this.check(before !== undefined);
|
|
113
|
+
verifiedDir = directory;
|
|
114
|
+
return current();
|
|
115
|
+
};
|
|
116
|
+
// Permissions can change without changing the bytes. Verify them on every reread.
|
|
117
|
+
if (process.platform === 'win32') {
|
|
118
|
+
try {
|
|
119
|
+
await this.check(before !== undefined);
|
|
120
|
+
}
|
|
121
|
+
catch {
|
|
122
|
+
throw new Error(permissionProblem);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
if (!current())
|
|
126
|
+
throw new Error('config.json changed during the read.');
|
|
127
|
+
if (!before)
|
|
128
|
+
return { current, recheckDirectory };
|
|
129
|
+
const flags = fs.constants.O_RDONLY | (fs.constants.O_NOFOLLOW ?? 0) | (fs.constants.O_NONBLOCK ?? 0);
|
|
130
|
+
const fd = fs.openSync(file, flags);
|
|
131
|
+
try {
|
|
132
|
+
if (!same(before, fs.fstatSync(fd, { bigint: true })))
|
|
133
|
+
throw new Error('config.json changed during the read.');
|
|
134
|
+
const bytes = fs.readFileSync(fd);
|
|
135
|
+
if (!current() || !same(before, fs.fstatSync(fd, { bigint: true })))
|
|
136
|
+
throw new Error('config.json changed during the read.');
|
|
137
|
+
let text;
|
|
138
|
+
try {
|
|
139
|
+
text = new TextDecoder('utf-8', { fatal: true, ignoreBOM: true }).decode(bytes);
|
|
140
|
+
}
|
|
141
|
+
catch {
|
|
142
|
+
throw new Error('config.json is not valid UTF-8.');
|
|
143
|
+
}
|
|
144
|
+
return { text, current, recheckDirectory };
|
|
145
|
+
}
|
|
146
|
+
finally {
|
|
147
|
+
fs.closeSync(fd);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
startReader(directory, hardening, env) {
|
|
151
|
+
if (this.child)
|
|
152
|
+
return this.child;
|
|
153
|
+
// Run the startup hardener once. A replacement reader only checks permissions.
|
|
154
|
+
const startup = hardening === undefined ? '' : `try {
|
|
155
|
+
${hardening}
|
|
156
|
+
[Console]::WriteLine()
|
|
157
|
+
[Console]::Out.Flush()
|
|
158
|
+
} catch { exit 1 }
|
|
159
|
+
`;
|
|
160
|
+
const script = startup + `
|
|
161
|
+
while ($null -ne ($line = [Console]::ReadLine())) {
|
|
162
|
+
try { $ok = Test-ConfigPermissions ($line -eq '1') } catch { $ok = $false }
|
|
163
|
+
[Console]::WriteLine([int]$ok)
|
|
164
|
+
[Console]::Out.Flush()
|
|
165
|
+
}`;
|
|
166
|
+
const child = this.child = spawn(powershell(), argsFor(script), { windowsHide: true, env: { ...aclEnv(directory), ...env }, stdio: 'pipe' });
|
|
167
|
+
child.stderr.resume();
|
|
168
|
+
createInterface({ input: child.stdout }).on('line', line => { if (this.child === child)
|
|
169
|
+
this.reply?.(line); });
|
|
170
|
+
const lost = () => { if (this.child === child)
|
|
171
|
+
this.close(); };
|
|
172
|
+
child.on('error', lost);
|
|
173
|
+
child.stdin.on('error', lost);
|
|
174
|
+
child.once('close', lost);
|
|
175
|
+
return child;
|
|
176
|
+
}
|
|
177
|
+
waitForReply(timeout) {
|
|
178
|
+
return new Promise((resolve, reject) => {
|
|
179
|
+
const timer = setTimeout(() => this.close(), timeout).unref();
|
|
180
|
+
this.reply = line => {
|
|
181
|
+
clearTimeout(timer);
|
|
182
|
+
this.reply = undefined;
|
|
183
|
+
if (line === undefined)
|
|
184
|
+
reject(new Error(permissionProblem));
|
|
185
|
+
else
|
|
186
|
+
resolve(line);
|
|
187
|
+
};
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
async check(includeFile) {
|
|
191
|
+
const child = this.startReader(this.verifiedHome());
|
|
192
|
+
const reply = this.waitForReply(10_000);
|
|
193
|
+
try {
|
|
194
|
+
child.stdin.write(includeFile ? '1\n' : '0\n');
|
|
195
|
+
}
|
|
196
|
+
catch {
|
|
197
|
+
this.close();
|
|
198
|
+
}
|
|
199
|
+
if (await reply !== '1')
|
|
200
|
+
throw new Error(permissionProblem);
|
|
201
|
+
}
|
|
202
|
+
close() {
|
|
203
|
+
const child = this.child;
|
|
204
|
+
this.child = undefined;
|
|
205
|
+
this.reply?.();
|
|
206
|
+
child?.stdin.end();
|
|
207
|
+
child?.kill();
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
function fileStat(file) {
|
|
211
|
+
try {
|
|
212
|
+
return fs.lstatSync(file, { bigint: true });
|
|
213
|
+
}
|
|
214
|
+
catch (error) {
|
|
215
|
+
if (error.code === 'ENOENT')
|
|
216
|
+
return undefined;
|
|
217
|
+
throw error;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
function same(a, b) {
|
|
221
|
+
if (!a || !b)
|
|
222
|
+
return a === b;
|
|
223
|
+
return a.dev === b.dev && a.ino === b.ino && a.ctimeNs === b.ctimeNs && a.mtimeNs === b.mtimeNs &&
|
|
224
|
+
a.size === b.size && a.mode === b.mode && a.uid === b.uid;
|
|
225
|
+
}
|
|
226
|
+
export class ConfigWatcher {
|
|
227
|
+
options;
|
|
228
|
+
watch;
|
|
229
|
+
timer;
|
|
230
|
+
poll;
|
|
231
|
+
burst;
|
|
232
|
+
stopped = false;
|
|
233
|
+
dirty = false;
|
|
234
|
+
running;
|
|
235
|
+
retryAt = 0;
|
|
236
|
+
retryMs = 1000;
|
|
237
|
+
constructor(options) {
|
|
238
|
+
this.options = options;
|
|
239
|
+
}
|
|
240
|
+
attach() {
|
|
241
|
+
if (this.watch || Date.now() < this.retryAt)
|
|
242
|
+
return;
|
|
243
|
+
const failed = () => {
|
|
244
|
+
if (this.stopped)
|
|
245
|
+
return;
|
|
246
|
+
this.watch?.close();
|
|
247
|
+
this.watch = undefined;
|
|
248
|
+
this.retryAt = Date.now() + this.retryMs;
|
|
249
|
+
this.retryMs = Math.min(30_000, 2 * this.retryMs);
|
|
250
|
+
this.options.health('polling');
|
|
251
|
+
};
|
|
252
|
+
try {
|
|
253
|
+
this.watch = this.options.watch(name => {
|
|
254
|
+
if (this.stopped || (name !== null && name !== 'config.json'))
|
|
255
|
+
return;
|
|
256
|
+
this.burst ??= Date.now();
|
|
257
|
+
clearTimeout(this.timer);
|
|
258
|
+
this.timer = setTimeout(() => { this.burst = undefined; void this.request(); }, Math.max(0, Math.min(100, this.burst + 500 - Date.now()))).unref();
|
|
259
|
+
});
|
|
260
|
+
this.watch.on('error', failed);
|
|
261
|
+
this.options.health('watching');
|
|
262
|
+
this.retryMs = 1000;
|
|
263
|
+
}
|
|
264
|
+
catch {
|
|
265
|
+
failed();
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
start() {
|
|
269
|
+
this.attach();
|
|
270
|
+
this.poll = setInterval(() => { this.attach(); if (!this.running)
|
|
271
|
+
void this.request(); }, 2000).unref();
|
|
272
|
+
return this.request();
|
|
273
|
+
}
|
|
274
|
+
request() {
|
|
275
|
+
this.dirty = true;
|
|
276
|
+
this.running ??= this.drain().finally(() => { this.running = undefined; });
|
|
277
|
+
return this.running;
|
|
278
|
+
}
|
|
279
|
+
async drain() {
|
|
280
|
+
let retriedReplacement = false;
|
|
281
|
+
while (this.dirty && !this.stopped) {
|
|
282
|
+
this.dirty = false;
|
|
283
|
+
try {
|
|
284
|
+
const candidate = await this.options.read();
|
|
285
|
+
if (this.stopped || this.dirty)
|
|
286
|
+
continue;
|
|
287
|
+
if (!candidate.current())
|
|
288
|
+
throw new Error('config.json changed during the read.');
|
|
289
|
+
await this.options.receive(candidate);
|
|
290
|
+
}
|
|
291
|
+
catch (error) {
|
|
292
|
+
if (this.stopped)
|
|
293
|
+
return;
|
|
294
|
+
const message = error instanceof Error ? error.message : '';
|
|
295
|
+
if (message === 'config.json changed during the read.' && !retriedReplacement) {
|
|
296
|
+
retriedReplacement = true;
|
|
297
|
+
this.dirty = true;
|
|
298
|
+
continue;
|
|
299
|
+
}
|
|
300
|
+
this.options.fail([permissionProblem, 'config.json changed during the read.', 'config.json is not valid UTF-8.'].includes(message)
|
|
301
|
+
? message : 'Could not read config.json.');
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
stop() {
|
|
306
|
+
this.stopped = true;
|
|
307
|
+
clearInterval(this.poll);
|
|
308
|
+
clearTimeout(this.timer);
|
|
309
|
+
this.watch?.close();
|
|
310
|
+
this.options.health('stopped');
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
//# sourceMappingURL=configWatcher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configWatcher.js","sourceRoot":"","sources":["../../src/daemon/configWatcher.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAE3C,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAU9E,MAAM,iBAAiB,GAAG,wEAAwE,CAAC;AACnG,MAAM,kBAAkB,GAAG;;;;;;;;;;;;;;;;;;;;CAoB1B,CAAC;AAEF,MAAM,UAAU,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,IAAI,aAAa,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,EAAE,gBAAgB,CAAC,CAAC;AACrI,MAAM,OAAO,GAAG,CAAC,MAAc,EAAE,EAAE,CAAC,CAAC,YAAY,EAAE,iBAAiB,EAAE,iBAAiB;IACrF,MAAM,CAAC,IAAI,CAAC,kBAAkB,GAAG,MAAM,EAAE,SAAS,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC;AAC1E,MAAM,MAAM,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,CAAC,EAAE,UAAU,EAAE,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE,OAAO,EAAE,IA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CAAC,iBAAiB,EAAE,sCAAsC,EAAE,iCAAiC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC;oBAChI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,6BAA6B,CAAC,CAAC;YAC/C,CAAC;QACH,CAAC;IACH,CAAC;IAED,IAAI;QACF,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACpB,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACzB,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACzB,IAAI,CAAC,KAAK,EAAE,KAAK,EAAE,CAAC;QACpB,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IACjC,CAAC;CACF"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { VerifiedHome } from './paths.js';
|
|
1
2
|
export declare class AlreadyRunningError extends Error {
|
|
2
3
|
readonly state: {
|
|
3
4
|
pid: number;
|
|
@@ -12,4 +13,4 @@ export interface HomeOwner {
|
|
|
12
13
|
held: () => boolean;
|
|
13
14
|
release: () => void;
|
|
14
15
|
}
|
|
15
|
-
export declare function acquireHomeOwner(home:
|
|
16
|
+
export declare function acquireHomeOwner(home: VerifiedHome, port: number, instanceId: string): Promise<HomeOwner>;
|
package/dist/daemon/homeOwner.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* keeps this non-empty directory until its last record write. A contender
|
|
4
4
|
* can therefore distinguish a missing discovery file from an unowned home.
|
|
5
5
|
*/
|
|
6
|
-
import { existsSync, mkdirSync,
|
|
6
|
+
import { existsSync, mkdirSync, opendirSync, renameSync, rmdirSync, unlinkSync, writeFileSync } from 'node:fs';
|
|
7
7
|
import { createServer } from 'node:net';
|
|
8
8
|
import { join } from 'node:path';
|
|
9
9
|
import { processExists } from './liveness.js';
|
|
@@ -49,27 +49,48 @@ function portIsFree(port) {
|
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
51
|
export async function acquireHomeOwner(home, port, instanceId) {
|
|
52
|
-
const
|
|
53
|
-
const
|
|
52
|
+
const base = home.homePath;
|
|
53
|
+
const directory = join(base, 'daemon-owner');
|
|
54
|
+
const staging = join(base, 'daemon-owner.' + instanceId);
|
|
54
55
|
const marker = [process.pid, port, instanceId].join('.');
|
|
55
56
|
mkdirSync(staging, { mode: 0o700 });
|
|
56
57
|
try {
|
|
57
58
|
writeFileSync(join(staging, marker), '', { flag: 'wx', mode: 0o600 });
|
|
58
59
|
for (;;) {
|
|
60
|
+
home.verifiedHome();
|
|
59
61
|
try {
|
|
60
62
|
renameSync(staging, directory);
|
|
61
63
|
return {
|
|
62
|
-
held: () =>
|
|
63
|
-
|
|
64
|
+
held: () => {
|
|
65
|
+
try {
|
|
66
|
+
home.verifiedHome();
|
|
67
|
+
const held = existsSync(join(directory, marker));
|
|
68
|
+
home.verifiedHome();
|
|
69
|
+
return held;
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
release: () => { home.verifiedHome(); retire(directory, marker); },
|
|
64
76
|
};
|
|
65
77
|
}
|
|
66
78
|
catch (error) {
|
|
67
79
|
// On Windows rename can return EPERM when the target already exists.
|
|
68
80
|
if (!['EEXIST', 'ENOTEMPTY', 'EPERM', 'EACCES'].includes(codeOf(error) ?? ''))
|
|
69
81
|
throw error;
|
|
70
|
-
|
|
82
|
+
home.verifiedHome();
|
|
83
|
+
const markers = [];
|
|
71
84
|
try {
|
|
72
|
-
|
|
85
|
+
const dir = opendirSync(directory);
|
|
86
|
+
try {
|
|
87
|
+
home.verifiedHome();
|
|
88
|
+
for (let entry = dir.readSync(); entry; entry = dir.readSync())
|
|
89
|
+
markers.push(entry.name);
|
|
90
|
+
}
|
|
91
|
+
finally {
|
|
92
|
+
dir.closeSync();
|
|
93
|
+
}
|
|
73
94
|
}
|
|
74
95
|
catch (readError) {
|
|
75
96
|
if (codeOf(readError) === 'ENOENT' && codeOf(error) !== 'EACCES') {
|
|
@@ -80,6 +101,7 @@ export async function acquireHomeOwner(home, port, instanceId) {
|
|
|
80
101
|
}
|
|
81
102
|
throw readError;
|
|
82
103
|
}
|
|
104
|
+
home.verifiedHome();
|
|
83
105
|
const incumbent = markers[0];
|
|
84
106
|
if (incumbent === undefined) {
|
|
85
107
|
// Another process may have died between unlink and rmdir.
|
|
@@ -91,7 +113,9 @@ export async function acquireHomeOwner(home, port, instanceId) {
|
|
|
91
113
|
throw new Error('Unrecognised daemon-owner record.', { cause: error });
|
|
92
114
|
const oldPort = Number(fields[2]);
|
|
93
115
|
// Our own successful bind may already prove this old port was free.
|
|
94
|
-
|
|
116
|
+
const live = port !== oldPort && processExists(Number(fields[1])) && !(await portIsFree(oldPort));
|
|
117
|
+
home.verifiedHome();
|
|
118
|
+
if (live) {
|
|
95
119
|
throw new AlreadyRunningError({ pid: Number(fields[1]), port: oldPort });
|
|
96
120
|
}
|
|
97
121
|
retire(directory, incumbent);
|
|
@@ -100,6 +124,7 @@ export async function acquireHomeOwner(home, port, instanceId) {
|
|
|
100
124
|
}
|
|
101
125
|
finally {
|
|
102
126
|
// On success the staging directory was renamed.
|
|
127
|
+
home.verifiedHome();
|
|
103
128
|
retire(staging, marker);
|
|
104
129
|
}
|
|
105
130
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"homeOwner.js","sourceRoot":"","sources":["../../src/daemon/homeOwner.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC/G,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"homeOwner.js","sourceRoot":"","sources":["../../src/daemon/homeOwner.ts"],"names":[],"mappings":"AAAA;;;;GAIG;A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CAAC;QACH,CAAC;IACH,CAAC;YAAS,CAAC;QACT,gDAAgD;QAChD,IAAI,CAAC,YAAY,EAAE,CAAC;QACpB,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAC1B,CAAC;AACH,CAAC"}
|
package/dist/daemon/index.js
CHANGED
|
@@ -6,59 +6,15 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { removeClaimCredentials } from '../core/types.js';
|
|
8
8
|
import { Daemon, AlreadyRunningError } from './server.js';
|
|
9
|
-
import * as path from 'node:path';
|
|
10
|
-
import { createAuditor } from './audit.js';
|
|
11
|
-
import { DEFAULT_VIEWER_LAUNCH_MODE, readDaemonConfig, signatureOverBudgetLog } from './config.js';
|
|
12
|
-
import { useDialogSignatures } from '../core/dialogs.js';
|
|
13
|
-
import { useAgentSignatures } from '../core/reasoning.js';
|
|
14
|
-
import { createFileLogger } from './logger.js';
|
|
15
9
|
import { assertNodeVersion } from './meta.js';
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
10
|
+
import { shellpuppetHome } from './paths.js';
|
|
11
|
+
import { WRAPPED_START_IPC } from './wrappedStart.js';
|
|
18
12
|
async function main() {
|
|
19
13
|
assertNodeVersion();
|
|
20
14
|
removeClaimCredentials(process.env);
|
|
21
15
|
const supervised = process.env[WRAPPED_START_IPC] === '1' && process.send !== undefined;
|
|
22
16
|
delete process.env[WRAPPED_START_IPC];
|
|
23
|
-
const
|
|
24
|
-
const logger = createFileLogger(daemonLogPath(home));
|
|
25
|
-
// Shape-validated (design §4.3 fail-closed): a malformed policy section
|
|
26
|
-
// arrives here as deny-all with the problem in its refusal reason. It must
|
|
27
|
-
// never be silently ignored, because ignoring it is fail-open.
|
|
28
|
-
const { config, problems } = readDaemonConfig(home);
|
|
29
|
-
// Recognised by every session's prompt detection from here on. The entries
|
|
30
|
-
// that did not compile are included in the configuration problems. A signature
|
|
31
|
-
// built-in or from config, that runs past its time budget on a screen is
|
|
32
|
-
// reported then and set aside for a minute at a time.
|
|
33
|
-
useDialogSignatures(config.dialogs ?? [], (name, builtIn) => {
|
|
34
|
-
const { message, meta } = signatureOverBudgetLog('dialog', name, builtIn);
|
|
35
|
-
logger.warn(message, meta);
|
|
36
|
-
});
|
|
37
|
-
// How hideReasoning and terminal_result read each agent's screen: the
|
|
38
|
-
// built-in signatures, plus or replaced by the config's.
|
|
39
|
-
useAgentSignatures(config.agentSignatures ?? [], (name, builtIn) => {
|
|
40
|
-
const { message, meta } = signatureOverBudgetLog('agent', name, builtIn);
|
|
41
|
-
logger.warn(message, meta);
|
|
42
|
-
});
|
|
43
|
-
const daemon = new Daemon({
|
|
44
|
-
home,
|
|
45
|
-
logger,
|
|
46
|
-
...(supervised ? { afterPublish: releaseWrappedDaemon } : {}),
|
|
47
|
-
audit: createAuditor(home, { captureContent: config.audit?.captureContent ?? false }, logger),
|
|
48
|
-
...(config.messaging !== undefined ? { messaging: config.messaging } : {}),
|
|
49
|
-
...(config.policy !== undefined ? { policy: config.policy } : {}),
|
|
50
|
-
...(config.sessionEnv !== undefined ? { sessionEnv: config.sessionEnv } : {}),
|
|
51
|
-
...(config.idleMinutes !== undefined ? { idleMs: config.idleMinutes * 60_000 } : {}),
|
|
52
|
-
// The product default is to open the dashboard; the library default in
|
|
53
|
-
// DaemonOptions stays "no-window" so a test daemon can never put browser
|
|
54
|
-
// windows on someone's desktop by forgetting to opt out. Set
|
|
55
|
-
// `viewer.launchMode` to "no-window" in config.json for unattended machines.
|
|
56
|
-
viewer: { launchMode: DEFAULT_VIEWER_LAUNCH_MODE, ...config.viewer },
|
|
57
|
-
...(config.dashboard?.fontSize !== undefined ? { dashboardFontSize: config.dashboard.fontSize } : {}),
|
|
58
|
-
...(config.launcher !== undefined ? { launchProfiles: config.launcher } : {}),
|
|
59
|
-
onSelfStop: () => process.exit(0),
|
|
60
|
-
exitProcessOnStop: true,
|
|
61
|
-
});
|
|
17
|
+
const { daemon, logger } = await Daemon.standalone(shellpuppetHome(), supervised);
|
|
62
18
|
const shutdown = (signal) => {
|
|
63
19
|
logger.info('signal received, shutting down', { signal });
|
|
64
20
|
void daemon.stop().then(() => process.exit(0));
|
|
@@ -76,10 +32,7 @@ async function main() {
|
|
|
76
32
|
void daemon.stop().finally(() => process.exit(1));
|
|
77
33
|
});
|
|
78
34
|
try {
|
|
79
|
-
// start() secures this home before publishing the daemon state or writing diagnostics.
|
|
80
35
|
await daemon.start();
|
|
81
|
-
for (const problem of problems)
|
|
82
|
-
logger.warn('CONFIG PROBLEM', { problem });
|
|
83
36
|
}
|
|
84
37
|
catch (error) {
|
|
85
38
|
if (error instanceof AlreadyRunningError) {
|
package/dist/daemon/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/daemon/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/daemon/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEtD,KAAK,UAAU,IAAI;IACjB,iBAAiB,EAAE,CAAC;IACpB,sBAAsB,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACpC,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,KAAK,GAAG,IAAI,OAAO,CAAC,IAAI,KAAK,SAAS,CAA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AAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IACpD,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC;QACH,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;IACvB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,mBAAmB,EAAE,CAAC;YACzC,MAAM,CAAC,IAAI,CAAC,iCAAiC,EAAE;gBAC7C,GAAG,EAAE,KAAK,CAAC,KAAK,CAAC,GAAG;gBACpB,IAAI,EAAE,KAAK,CAAC,KAAK,CAAC,IAAI;aACvB,CAAC,CAAC;YACH,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QACD,MAAM,CAAC,KAAK,CAAC,wBAAwB,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACjE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC;AAED,KAAK,IAAI,EAAE,CAAC"}
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* route is allowed to perform, and leaves out any entry it cannot read whole.
|
|
10
10
|
*
|
|
11
11
|
* The rules are fail-closed in the same way as `config.ts`: an entry that
|
|
12
|
-
* cannot be parsed is omitted and
|
|
12
|
+
* cannot be parsed is omitted and identified by index in the log. Its siblings
|
|
13
13
|
* still load. A broken launcher section never installs a deny-all policy,
|
|
14
14
|
* because profiles are an addition to policy rather than the policy itself.
|
|
15
15
|
*
|
|
@@ -58,6 +58,8 @@ export interface LaunchProfilePolicy {
|
|
|
58
58
|
deny?: string[];
|
|
59
59
|
}
|
|
60
60
|
export interface LaunchProfile {
|
|
61
|
+
/** Original position in launcher.profiles, before invalid entries were omitted. */
|
|
62
|
+
configIndex?: number;
|
|
61
63
|
resume?: string[];
|
|
62
64
|
name: string;
|
|
63
65
|
role?: 'chair';
|
|
@@ -85,7 +87,7 @@ export interface LauncherConfig {
|
|
|
85
87
|
sessionLaunch?: string[];
|
|
86
88
|
launchesPerMinute?: number;
|
|
87
89
|
profiles: LaunchProfile[];
|
|
88
|
-
/**
|
|
90
|
+
/** Detailed problems for the authenticated dashboard profile list. */
|
|
89
91
|
problems: string[];
|
|
90
92
|
}
|
|
91
93
|
export declare const DEFAULT_LAUNCHES_PER_MINUTE = 8;
|
|
@@ -99,7 +101,7 @@ export declare function parseLaunchesPerMinute(raw: unknown): {
|
|
|
99
101
|
* must also match. There is no `mode` and no `maxSessions` here: a profile
|
|
100
102
|
* cannot widen either.
|
|
101
103
|
*/
|
|
102
|
-
export declare function compileProfilePolicy(policy: LaunchProfilePolicy): CompiledPolicy;
|
|
104
|
+
export declare function compileProfilePolicy(policy: LaunchProfilePolicy, profileIndex?: number): CompiledPolicy;
|
|
103
105
|
/** Parse one entry. Returns the profile, or the sentence naming why not. */
|
|
104
106
|
export declare function parseLaunchProfile(raw: unknown, knownAgents: ReadonlySet<string>): {
|
|
105
107
|
profile: LaunchProfile;
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* route is allowed to perform, and leaves out any entry it cannot read whole.
|
|
10
10
|
*
|
|
11
11
|
* The rules are fail-closed in the same way as `config.ts`: an entry that
|
|
12
|
-
* cannot be parsed is omitted and
|
|
12
|
+
* cannot be parsed is omitted and identified by index in the log. Its siblings
|
|
13
13
|
* still load. A broken launcher section never installs a deny-all policy,
|
|
14
14
|
* because profiles are an addition to policy rather than the policy itself.
|
|
15
15
|
*
|
|
@@ -160,6 +160,8 @@ function entryLabel(index, raw) {
|
|
|
160
160
|
}
|
|
161
161
|
/** A sentence naming the entry and why it did not load. */
|
|
162
162
|
function leftOut(index, raw, reason) {
|
|
163
|
+
if (/^policy\.(allow|deny)\[\d+\] does not compile$/.test(reason))
|
|
164
|
+
return `launcher.profiles[${String(index)}].${reason}`;
|
|
163
165
|
return `${entryLabel(index, raw)} was left out: ${reason}`;
|
|
164
166
|
}
|
|
165
167
|
/**
|
|
@@ -168,12 +170,12 @@ function leftOut(index, raw, reason) {
|
|
|
168
170
|
* must also match. There is no `mode` and no `maxSessions` here: a profile
|
|
169
171
|
* cannot widen either.
|
|
170
172
|
*/
|
|
171
|
-
export function compileProfilePolicy(policy) {
|
|
173
|
+
export function compileProfilePolicy(policy, profileIndex = 0) {
|
|
172
174
|
return compilePolicy({
|
|
173
175
|
mode: policy.allow !== undefined ? 'allowlist' : 'denylist',
|
|
174
176
|
...(policy.allow !== undefined ? { allow: policy.allow } : {}),
|
|
175
177
|
...(policy.deny !== undefined ? { deny: policy.deny } : {}),
|
|
176
|
-
});
|
|
178
|
+
}, `launcher.profiles[${String(profileIndex)}].policy`);
|
|
177
179
|
}
|
|
178
180
|
/** Why a policy object is unusable, or null. */
|
|
179
181
|
function profilePolicyProblem(raw) {
|
|
@@ -190,12 +192,12 @@ function profilePolicyProblem(raw) {
|
|
|
190
192
|
continue;
|
|
191
193
|
if (!isStringArray(list))
|
|
192
194
|
return `policy.${listName} must be an array of regex strings`;
|
|
193
|
-
for (const source of list) {
|
|
195
|
+
for (const [index, source] of list.entries()) {
|
|
194
196
|
try {
|
|
195
197
|
new RegExp(source, 'i');
|
|
196
198
|
}
|
|
197
199
|
catch {
|
|
198
|
-
return `policy.${listName}
|
|
200
|
+
return `policy.${listName}[${String(index)}] does not compile`;
|
|
199
201
|
}
|
|
200
202
|
}
|
|
201
203
|
}
|
|
@@ -399,7 +401,10 @@ export function parseLauncher(raw, knownAgents) {
|
|
|
399
401
|
problems.push(allowance.problem);
|
|
400
402
|
const entries = raw['profiles'];
|
|
401
403
|
if (entries === undefined) {
|
|
402
|
-
|
|
404
|
+
if (raw['sessionLaunch'] !== undefined)
|
|
405
|
+
problems.push('launcher.sessionLaunch requires a profiles list. No launch permission granted.');
|
|
406
|
+
else if (raw['launchesPerMinute'] === undefined)
|
|
407
|
+
problems.push('launcher has no profiles list: no dashboard launch profiles are loaded (an empty list is fine)');
|
|
403
408
|
return { launcher: { profiles, problems, launchesPerMinute: allowance.value }, problems };
|
|
404
409
|
}
|
|
405
410
|
if (!Array.isArray(entries)) {
|
|
@@ -433,7 +438,7 @@ export function parseLauncher(raw, knownAgents) {
|
|
|
433
438
|
`entries that are not variable names: ${dropped.map((name) => `"${name}"`).join(', ')}`);
|
|
434
439
|
}
|
|
435
440
|
}
|
|
436
|
-
profiles.push(profile);
|
|
441
|
+
profiles.push({ ...profile, configIndex: index });
|
|
437
442
|
}
|
|
438
443
|
const grants = raw['sessionLaunch'];
|
|
439
444
|
let sessionLaunch;
|