@onepointfour-packs/flaredeck-agent 0.2.204 → 0.2.205
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent.d.ts +2 -2
- package/dist/agent.js +3 -3
- package/dist/agent.js.map +1 -1
- package/dist/config.d.ts +1 -3
- package/dist/config.js.map +1 -1
- package/dist/hydrate.d.ts +5 -14
- package/dist/hydrate.js +2 -3
- package/dist/hydrate.js.map +1 -1
- package/dist/jevguard.d.ts +1 -1
- package/dist/jevguard.js +16 -7
- package/dist/jevguard.js.map +1 -1
- package/dist/serve.js +8 -13
- package/dist/serve.js.map +1 -1
- package/dist/trusted-scripts.d.ts +12 -25
- package/dist/trusted-scripts.js +52 -44
- package/dist/trusted-scripts.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,34 +1,21 @@
|
|
|
1
|
-
import { type Checkout } from './workspace.js';
|
|
2
1
|
export type TrustedEntry = {
|
|
3
|
-
|
|
4
|
-
path: string;
|
|
5
|
-
sha256: string;
|
|
2
|
+
name: string;
|
|
6
3
|
description: string;
|
|
4
|
+
body: string;
|
|
7
5
|
};
|
|
8
|
-
/** An
|
|
6
|
+
/** An uploaded script, as it is on this machine. */
|
|
9
7
|
export type TrustedLocal = TrustedEntry & {
|
|
10
8
|
abs: string;
|
|
11
9
|
};
|
|
12
|
-
/**
|
|
13
|
-
export declare function
|
|
10
|
+
/** Write one script as FlareDeck has it. */
|
|
11
|
+
export declare function writeFresh(t: TrustedLocal): void;
|
|
12
|
+
/** Put every uploaded script in `dir`, and take away any that was removed in FlareDeck. */
|
|
13
|
+
export declare function installScripts(entries: TrustedEntry[], dir: string): TrustedLocal[];
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* Kept deliberately narrow: no `;`, `&&`, `||`, command substitution or redirects — only the script
|
|
15
|
+
* The uploaded script this command runs, and nothing else — or null. Kept deliberately narrow: no
|
|
16
|
+
* `;`, `&&`, `||`, command substitution, redirects or variables set in front of it; only the script
|
|
19
17
|
* with its arguments, optionally piped into a reader (`| head -50`).
|
|
20
18
|
*/
|
|
21
|
-
export declare function trustedRun(command: string, cwd: string, local: TrustedLocal[],
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
changed: TrustedLocal;
|
|
25
|
-
} | null;
|
|
26
|
-
/** A trusted script another agent runs: this one asks them. */
|
|
27
|
-
export type OthersScript = {
|
|
28
|
-
repository: string;
|
|
29
|
-
path: string;
|
|
30
|
-
description: string;
|
|
31
|
-
who: string[];
|
|
32
|
-
};
|
|
33
|
-
/** What a session is told: the scripts it may run here, and the ones to ask someone else for. */
|
|
34
|
-
export declare function trustedBrief(local: TrustedLocal[], others?: OthersScript[]): string;
|
|
19
|
+
export declare function trustedRun(command: string, cwd: string, local: TrustedLocal[], home?: string): TrustedLocal | null;
|
|
20
|
+
/** What a session is told: the scripts it may run, where they are, and what they are for. */
|
|
21
|
+
export declare function trustedBrief(local: TrustedLocal[]): string;
|
package/dist/trusted-scripts.js
CHANGED
|
@@ -1,56 +1,61 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Scripts a person
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* Scripts a person uploaded to FlareDeck (Integrations → Scripts), which any agent may run without
|
|
3
|
+
* the command guard judging them — reading production logs through prodscan.sh, say (Cobus, 20 Oct).
|
|
4
|
+
* See flaredeck-mcp/src/vault/scripts.ts.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
6
|
+
* Each is written into the harness's own folder, and written AGAIN, fresh from what FlareDeck sent,
|
|
7
|
+
* every time an agent runs it. So what runs is always what was uploaded: an agent that edited the
|
|
8
|
+
* file on the machine changed nothing. A command is trusted only when it runs exactly one of these
|
|
9
|
+
* files, alone or piped into a reader.
|
|
10
10
|
*/
|
|
11
|
-
import {
|
|
12
|
-
import { existsSync, readFileSync, realpathSync } from 'node:fs';
|
|
11
|
+
import { chmodSync, mkdirSync, readdirSync, realpathSync, rmSync, writeFileSync } from 'node:fs';
|
|
13
12
|
import { isAbsolute, join, resolve } from 'node:path';
|
|
14
|
-
import { repoIdentity } from './workspace.js';
|
|
15
13
|
const real = (p) => { try {
|
|
16
14
|
return realpathSync(p);
|
|
17
15
|
}
|
|
18
16
|
catch {
|
|
19
17
|
return resolve(p);
|
|
20
18
|
} };
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
const safeName = (n) => /^[A-Za-z0-9][A-Za-z0-9._-]{0,80}$/.test(n);
|
|
20
|
+
/** Write one script as FlareDeck has it. */
|
|
21
|
+
export function writeFresh(t) {
|
|
22
|
+
writeFileSync(t.abs, t.body, { mode: 0o755 });
|
|
23
|
+
chmodSync(t.abs, 0o755);
|
|
24
|
+
}
|
|
25
|
+
/** Put every uploaded script in `dir`, and take away any that was removed in FlareDeck. */
|
|
26
|
+
export function installScripts(entries, dir) {
|
|
27
|
+
mkdirSync(dir, { recursive: true });
|
|
23
28
|
const out = [];
|
|
24
29
|
for (const e of entries) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
out.push({ ...e, abs });
|
|
30
|
+
if (!safeName(e.name) || !e.body)
|
|
31
|
+
continue;
|
|
32
|
+
const t = { ...e, abs: join(dir, e.name) };
|
|
33
|
+
try {
|
|
34
|
+
writeFresh(t);
|
|
35
|
+
out.push(t);
|
|
32
36
|
}
|
|
37
|
+
catch { /* an unwritable one is simply not offered */ }
|
|
33
38
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
try {
|
|
38
|
-
return createHash('sha256').update(read(p)).digest('hex');
|
|
39
|
+
const keep = new Set(out.map((t) => t.name));
|
|
40
|
+
for (const f of (() => { try {
|
|
41
|
+
return readdirSync(dir);
|
|
39
42
|
}
|
|
40
43
|
catch {
|
|
41
|
-
return
|
|
44
|
+
return [];
|
|
45
|
+
} })()) {
|
|
46
|
+
if (!keep.has(f))
|
|
47
|
+
rmSync(join(dir, f), { force: true });
|
|
42
48
|
}
|
|
43
|
-
|
|
49
|
+
return out;
|
|
50
|
+
}
|
|
44
51
|
/** What a trusted script's output may be piped into: reading and trimming, nothing that acts. */
|
|
45
52
|
const PIPE_OK = /^(head|tail|grep|egrep|jq|wc|cut|sort|uniq|tr|column)(\s|$)/;
|
|
46
53
|
/**
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
* Kept deliberately narrow: no `;`, `&&`, `||`, command substitution or redirects — only the script
|
|
54
|
+
* The uploaded script this command runs, and nothing else — or null. Kept deliberately narrow: no
|
|
55
|
+
* `;`, `&&`, `||`, command substitution, redirects or variables set in front of it; only the script
|
|
51
56
|
* with its arguments, optionally piped into a reader (`| head -50`).
|
|
52
57
|
*/
|
|
53
|
-
export function trustedRun(command, cwd, local,
|
|
58
|
+
export function trustedRun(command, cwd, local, home = process.env.HOME ?? '') {
|
|
54
59
|
if (!local.length)
|
|
55
60
|
return null;
|
|
56
61
|
const text = command.trim();
|
|
@@ -64,22 +69,25 @@ export function trustedRun(command, cwd, local, read = (p) => readFileSync(p), h
|
|
|
64
69
|
if (/^(bash|sh|zsh)$/.test(tokens[0] ?? ''))
|
|
65
70
|
i = 1;
|
|
66
71
|
const raw = (tokens[i] ?? '').replace(/^["']|["']$/g, '');
|
|
67
|
-
if (!raw)
|
|
72
|
+
if (!raw || raw.includes('='))
|
|
68
73
|
return null;
|
|
69
74
|
const expanded = raw.replace(/^~(?=\/)/, home).replace(/^\$\{?HOME\}?(?=\/)/, home);
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
if (!hit)
|
|
75
|
+
// A bare name runs whatever is in the current folder by that name — never one of these.
|
|
76
|
+
if (!isAbsolute(expanded) && !expanded.includes('/'))
|
|
73
77
|
return null;
|
|
74
|
-
|
|
78
|
+
const abs = real(isAbsolute(expanded) ? expanded : resolve(cwd, expanded));
|
|
79
|
+
return local.find((l) => real(l.abs) === abs) ?? null;
|
|
75
80
|
}
|
|
76
|
-
/** What a session is told: the scripts it may run
|
|
77
|
-
export function trustedBrief(local
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
81
|
+
/** What a session is told: the scripts it may run, where they are, and what they are for. */
|
|
82
|
+
export function trustedBrief(local) {
|
|
83
|
+
if (!local.length)
|
|
84
|
+
return '';
|
|
85
|
+
return [
|
|
86
|
+
'',
|
|
87
|
+
'Scripts a person uploaded to FlareDeck for you — run them by their full path, they need no',
|
|
88
|
+
'approval (piping the output into head, tail, grep or jq is fine; chaining them with other',
|
|
89
|
+
'commands is not). Do not edit them: each is written fresh from FlareDeck before it runs.',
|
|
90
|
+
...local.map((l) => ` · \`${l.abs}\` — ${l.description}`),
|
|
91
|
+
].join('\n');
|
|
84
92
|
}
|
|
85
93
|
//# sourceMappingURL=trusted-scripts.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trusted-scripts.js","sourceRoot":"","sources":["../src/trusted-scripts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"trusted-scripts.js","sourceRoot":"","sources":["../src/trusted-scripts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACjG,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAMtD,MAAM,IAAI,GAAG,CAAC,CAAS,EAAU,EAAE,GAAG,IAAI,CAAC;IAAC,OAAO,YAAY,CAAC,CAAC,CAAC,CAAC;AAAC,CAAC;AAAC,MAAM,CAAC;IAAC,OAAO,OAAO,CAAC,CAAC,CAAC,CAAC;AAAC,CAAC,CAAC,CAAC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|
|
4
4
|
"description": "Run a FlareDeck agent on your own machine: it picks up cards assigned to it, works each one in a checkout of its own, and reports back on the card.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|