copilot-operator 0.1.64 → 0.1.67
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/src/api/operator.controller.js +56 -1
- package/dist/src/api/operator.service.js +418 -54
- package/dist/src/cli.js +1 -0
- package/dist/src/config/schema.js +7 -0
- package/dist/src/exec/authorizer.js +26 -6
- package/dist/src/exec/commandHeads.js +30 -6
- package/dist/src/exec/dangerous.js +12 -0
- package/dist/src/exec/platforms.js +13 -2
- package/dist/src/exec/policy.js +31 -4
- package/dist/src/exec/policyManifest.js +9 -0
- package/dist/src/exec/readOnly.js +158 -0
- package/dist/src/exec/runner.js +75 -2
- package/dist/src/exec/stepEnv.js +13 -2
- package/dist/src/orchestrator/taskRunner.js +16 -3
- package/dist/src/plan/kerrigan.js +34 -6
- package/dist/src/plan/systemGuide.js +199 -0
- package/dist/src/queue/queue.js +65 -4
- package/dist/src/queue/queueBranch.js +66 -0
- package/dist/src/session/compose.js +15 -0
- package/dist/src/session/store.js +4 -0
- package/dist/src/vcs/newBranch.js +241 -0
- package/dist/src/vcs/remoteAuth.js +119 -0
- package/dist/web/404.html +2 -2
- package/dist/web/_next/static/chunks/1024-5f630cbb54e7346f.js +1 -0
- package/dist/web/_next/static/chunks/1077.3b82a837cf810f8b.js +1 -0
- package/dist/web/_next/static/chunks/1548.52bfcd01c16aaafe.js +1 -0
- package/dist/web/_next/static/chunks/2163.e60d3be9bb3f8b3f.js +1 -0
- package/dist/web/_next/static/chunks/6262-d074473db83ee798.js +1 -0
- package/dist/web/_next/static/chunks/714.b452ef814760b5a5.js +1 -0
- package/dist/web/_next/static/chunks/7220.96b18052ed9c06c7.js +1 -0
- package/dist/web/_next/static/chunks/7921-dd201ce7aa02c12d.js +1 -0
- package/dist/web/_next/static/chunks/8124-c27ce7bd781f4c56.js +1 -0
- package/dist/web/_next/static/chunks/8584.ab8d406781cdd45c.js +1 -0
- package/dist/web/_next/static/chunks/9067.5b8abc40104d51d9.js +1 -0
- package/dist/web/_next/static/chunks/9747.cf0353e7ffec2ee4.js +1 -0
- package/dist/web/_next/static/chunks/app/{layout-9201c637ca24b2c9.js → layout-5e0e7601702723bb.js} +1 -1
- package/dist/web/_next/static/chunks/app/page-ab73d1b3ba9181c2.js +1 -0
- package/dist/web/_next/static/chunks/app/queue/page-fb49cb2d3dc6d14c.js +1 -0
- package/dist/web/_next/static/chunks/app/settings/page-7d120feb5af0ace9.js +1 -0
- package/dist/web/_next/static/chunks/{webpack-d85f02ecd2903252.js → webpack-23ace264f775d98a.js} +1 -1
- package/dist/web/_next/static/css/532df8667473c4fc.css +1 -0
- package/dist/web/defaults.html +2 -2
- package/dist/web/defaults.txt +8 -8
- package/dist/web/index.html +3 -3
- package/dist/web/index.txt +9 -9
- package/dist/web/queue.html +2 -2
- package/dist/web/queue.txt +9 -9
- package/dist/web/settings.html +2 -2
- package/dist/web/settings.txt +9 -9
- package/dist/web/system.html +2 -2
- package/dist/web/system.txt +9 -9
- package/package.json +5 -2
- package/dist/web/_next/static/chunks/1077.32bfff8490ea3d67.js +0 -1
- package/dist/web/_next/static/chunks/1548.2bbbbb4759fd5073.js +0 -1
- package/dist/web/_next/static/chunks/2163.147b0ca65a65d5dd.js +0 -1
- package/dist/web/_next/static/chunks/714.16070ca6426f260c.js +0 -1
- package/dist/web/_next/static/chunks/7220.f71047baa16e6be0.js +0 -1
- package/dist/web/_next/static/chunks/7921-90ed63bfdf7162f3.js +0 -1
- package/dist/web/_next/static/chunks/8124-5458b17433987fab.js +0 -1
- package/dist/web/_next/static/chunks/8584.abc09920f03375b1.js +0 -1
- package/dist/web/_next/static/chunks/9067.538dec4d8ec0b04e.js +0 -1
- package/dist/web/_next/static/chunks/9747.9d15583d6ebafba3.js +0 -1
- package/dist/web/_next/static/chunks/app/page-185efe80d6e8dd05.js +0 -1
- package/dist/web/_next/static/chunks/app/queue/page-d4155eb6ab172c03.js +0 -1
- package/dist/web/_next/static/chunks/app/settings/page-9a83381087178f80.js +0 -1
- package/dist/web/_next/static/css/d107848da2f006af.css +0 -1
- /package/dist/web/_next/static/{vU04zVwJyicqgtWQsApuV → JpBxrjYpw2xowWbFoiPjO}/_buildManifest.js +0 -0
- /package/dist/web/_next/static/{vU04zVwJyicqgtWQsApuV → JpBxrjYpw2xowWbFoiPjO}/_ssgManifest.js +0 -0
|
@@ -297,6 +297,13 @@ export const RunConfigSchema = z.object({
|
|
|
297
297
|
// ordinary Windows inspection and housekeeping a build or test reaches for
|
|
298
298
|
'where', 'findstr', 'tasklist', 'taskkill', 'netstat', 'robocopy', 'xcopy', 'tar', 'curl', 'docker', 'docker-compose',
|
|
299
299
|
]),
|
|
300
|
+
/**
|
|
301
|
+
* Programs on the list above set to read only, "for reference" (operator, 2026-10-26): a command of theirs that only
|
|
302
|
+
* reads runs without a card, one that changes something, signs in or out or shows a secret is refused, one that
|
|
303
|
+
* cannot be read is asked about in every mode. Only programs with a rule (`exec/readOnly.ts`: az) can be; others
|
|
304
|
+
* named here are ignored.
|
|
305
|
+
*/
|
|
306
|
+
readOnlyPrograms: z.array(z.string()).default([]),
|
|
300
307
|
denyPatterns: z
|
|
301
308
|
.array(z.string())
|
|
302
309
|
.default([
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { staticCheck, describeStep } from './policy.js';
|
|
2
2
|
import { networkFetchReason, networkFetchRefusal } from './network.js';
|
|
3
3
|
import { scriptNetworkReason } from './policy.js';
|
|
4
|
-
import { platformReason } from './platforms.js';
|
|
4
|
+
import { platformOf, platformReason } from './platforms.js';
|
|
5
|
+
import { readOnlyUnclearRefusal, readOnlyVerdict } from './readOnly.js';
|
|
5
6
|
import { createInterface } from 'node:readline/promises';
|
|
6
7
|
import { stdin, stdout } from 'node:process';
|
|
7
8
|
/**
|
|
@@ -32,17 +33,28 @@ export function makeAuthorizer(cfg, ask, signal) {
|
|
|
32
33
|
return blocked;
|
|
33
34
|
const cwd = ctx.confinement?.cwd;
|
|
34
35
|
const network = networkFetchReason(step.cmd, cwd) ?? (cwd ? scriptNetworkReason(step.cmd, cwd) : null);
|
|
35
|
-
|
|
36
|
-
|
|
36
|
+
/*
|
|
37
|
+
* A platform reached with the operator's access (2026-10-23): asked in every mode, unless Settings agree to it. A
|
|
38
|
+
* program set to read only (2026-10-26) is not asked about when the line only reads with it; when it cannot be
|
|
39
|
+
* read as reading, it is asked about in every mode, Settings' agreement or not — the operator said it must not write.
|
|
40
|
+
*/
|
|
41
|
+
const reading = readOnlyVerdict(step.cmd, step.shell, cfg.readOnlyPrograms);
|
|
42
|
+
const unclear = reading?.kind === 'unclear' ? reading : null;
|
|
43
|
+
const platform = unclear
|
|
44
|
+
? (platformReason(step.cmd, step.shell) ?? platformOf(unclear.program) ?? unclear.program)
|
|
45
|
+
: cfg.platformAccess === 'allow'
|
|
46
|
+
? null
|
|
47
|
+
: platformReason(step.cmd, step.shell, reading?.kind === 'reads' ? new Set(reading.programs) : undefined);
|
|
48
|
+
const held = { ...(platform ? { platform } : {}), ...(unclear ? { readOnly: unclear.why, readOnlyProgram: unclear.program } : {}) };
|
|
37
49
|
if (network) {
|
|
38
50
|
if (cfg.mode === 'unattended' && cfg.networkFetch === 'refuse')
|
|
39
51
|
return { action: 'skip', reason: networkFetchRefusal(network) };
|
|
40
52
|
if (!platform && cfg.mode === 'unattended' && cfg.networkFetch === 'run')
|
|
41
53
|
return { action: 'run' };
|
|
42
|
-
return await ask(step, ctx, { network, ...
|
|
54
|
+
return await ask(step, ctx, { network, ...held });
|
|
43
55
|
}
|
|
44
56
|
if (platform)
|
|
45
|
-
return await ask(step, ctx,
|
|
57
|
+
return await ask(step, ctx, held);
|
|
46
58
|
if (cfg.mode === 'unattended')
|
|
47
59
|
return { action: 'run' };
|
|
48
60
|
return await ask(step, ctx);
|
|
@@ -63,6 +75,8 @@ export function terminalAuthorizer(cfg, print) {
|
|
|
63
75
|
print(` held: ${held.network}`);
|
|
64
76
|
if (held?.platform)
|
|
65
77
|
print(` held: it reaches ${held.platform} with your access`);
|
|
78
|
+
if (held?.readOnly)
|
|
79
|
+
print(` held: ${held.readOnlyProgram ?? 'the program'} is set to read only, and this could not be read as only reading (${held.readOnly})`);
|
|
66
80
|
const rl = createInterface({ input: stdin, output: stdout });
|
|
67
81
|
try {
|
|
68
82
|
const answer = (await rl.question(' [Enter] run [s] skip [q] abort > ')).trim().toLowerCase();
|
|
@@ -87,5 +101,11 @@ export function terminalAuthorizer(cfg, print) {
|
|
|
87
101
|
* those steps.
|
|
88
102
|
*/
|
|
89
103
|
export function unattendedAuthorizer(cfg) {
|
|
90
|
-
return makeAuthorizer({ ...cfg, mode: 'unattended' }, async (_step, _ctx, held) => held?.network
|
|
104
|
+
return makeAuthorizer({ ...cfg, mode: 'unattended' }, async (_step, _ctx, held) => held?.network
|
|
105
|
+
? { action: 'skip', reason: networkFetchRefusal(held.network) }
|
|
106
|
+
: held?.readOnly
|
|
107
|
+
? { action: 'skip', reason: readOnlyUnclearRefusal(held.readOnlyProgram ?? 'the program', held.readOnly) }
|
|
108
|
+
: held?.platform
|
|
109
|
+
? { action: 'skip', reason: platformRefusal(held.platform) }
|
|
110
|
+
: { action: 'run' });
|
|
91
111
|
}
|
|
@@ -74,6 +74,7 @@ const isTerminator = (c) => c === '' || c === ';' || c === '\n' || c === '|' ||
|
|
|
74
74
|
class PowerShellScan {
|
|
75
75
|
s;
|
|
76
76
|
heads = [];
|
|
77
|
+
calls = [];
|
|
77
78
|
uncertain;
|
|
78
79
|
depth = 0;
|
|
79
80
|
constructor(s) {
|
|
@@ -81,7 +82,14 @@ class PowerShellScan {
|
|
|
81
82
|
}
|
|
82
83
|
run() {
|
|
83
84
|
this.statements(0, null);
|
|
84
|
-
return this.uncertain ? { heads: this.heads, uncertain: this.uncertain } : { heads: this.heads };
|
|
85
|
+
return this.uncertain ? { heads: this.heads, calls: this.calls, uncertain: this.uncertain } : { heads: this.heads, calls: this.calls };
|
|
86
|
+
}
|
|
87
|
+
/** A literal head: recorded, with the invocation its arguments are read into. */
|
|
88
|
+
record(head) {
|
|
89
|
+
this.heads.push(head);
|
|
90
|
+
const call = { head, args: [] };
|
|
91
|
+
this.calls.push(call);
|
|
92
|
+
return call;
|
|
85
93
|
}
|
|
86
94
|
fail(why) {
|
|
87
95
|
this.uncertain ??= why;
|
|
@@ -229,7 +237,7 @@ class PowerShellScan {
|
|
|
229
237
|
if (word.dynamic)
|
|
230
238
|
this.fail(`the command "${word.literal}" is built from a variable, so which program it starts is known only when it runs`);
|
|
231
239
|
else if (word.literal)
|
|
232
|
-
this.
|
|
240
|
+
return this.commandArgs(word.end, this.record(word.literal));
|
|
233
241
|
return this.commandArgs(word.end);
|
|
234
242
|
}
|
|
235
243
|
/**
|
|
@@ -272,11 +280,14 @@ class PowerShellScan {
|
|
|
272
280
|
if (word.dynamic)
|
|
273
281
|
this.fail(`the program "${word.literal}" is built from a variable, so which program it starts is known only when it runs`);
|
|
274
282
|
else if (word.literal)
|
|
275
|
-
this.
|
|
283
|
+
return this.commandArgs(word.end, this.record(word.literal));
|
|
276
284
|
return this.commandArgs(word.end);
|
|
277
285
|
}
|
|
278
|
-
/**
|
|
279
|
-
|
|
286
|
+
/**
|
|
287
|
+
* A command's arguments, up to the end of its pipeline element. Nested statements are read. With `call`, each
|
|
288
|
+
* argument is recorded on it: a word or a quoted string as it reads, anything else as known only when it runs.
|
|
289
|
+
*/
|
|
290
|
+
commandArgs(i, call) {
|
|
280
291
|
for (;;) {
|
|
281
292
|
i = this.skip(i);
|
|
282
293
|
const c = this.at(i);
|
|
@@ -285,6 +296,7 @@ class PowerShellScan {
|
|
|
285
296
|
return i;
|
|
286
297
|
// `--%` hands the rest of the line to the program untouched, up to a pipe or a newline.
|
|
287
298
|
if (c === '-' && n === '-' && this.at(i + 2) === '%') {
|
|
299
|
+
call?.args.push({ literal: '--%', dynamic: true });
|
|
288
300
|
while (i < this.s.length && this.at(i) !== '\n' && this.at(i) !== '|')
|
|
289
301
|
i += 1;
|
|
290
302
|
continue;
|
|
@@ -298,12 +310,22 @@ class PowerShellScan {
|
|
|
298
310
|
i += 1;
|
|
299
311
|
continue;
|
|
300
312
|
}
|
|
313
|
+
// A quoted argument is read as a word is, so the program gets the text it will get: `'vm' 'list'` is `vm list`.
|
|
314
|
+
if (isSingleQuote(c) || isDoubleQuote(c)) {
|
|
315
|
+
const word = this.readWord(i);
|
|
316
|
+
call?.args.push({ literal: word.literal, dynamic: word.dynamic });
|
|
317
|
+
i = word.end > i ? word.end : i + 1;
|
|
318
|
+
continue;
|
|
319
|
+
}
|
|
301
320
|
const nested = this.nested(i, 'statements');
|
|
302
321
|
if (nested !== null) {
|
|
322
|
+
call?.args.push({ literal: this.s.slice(i, nested), dynamic: true });
|
|
303
323
|
i = nested;
|
|
304
324
|
continue;
|
|
305
325
|
}
|
|
306
326
|
const word = this.readWord(i);
|
|
327
|
+
if (word.end > i)
|
|
328
|
+
call?.args.push({ literal: word.literal, dynamic: word.dynamic });
|
|
307
329
|
i = word.end > i ? word.end : i + 1;
|
|
308
330
|
}
|
|
309
331
|
}
|
|
@@ -698,6 +720,7 @@ class PowerShellScan {
|
|
|
698
720
|
*/
|
|
699
721
|
function scanCmd(src) {
|
|
700
722
|
const heads = [];
|
|
723
|
+
const calls = [];
|
|
701
724
|
let uncertain;
|
|
702
725
|
const fail = (why) => {
|
|
703
726
|
uncertain ??= why;
|
|
@@ -794,6 +817,7 @@ function scanCmd(src) {
|
|
|
794
817
|
continue;
|
|
795
818
|
}
|
|
796
819
|
heads.push(literal);
|
|
820
|
+
calls.push({ head: literal, args: tokens.slice(k + 1).map((t) => ({ literal: t.replace(/"/g, ''), dynamic: /%[^%\s]+%|![^!\s]+!/.test(t) })) });
|
|
797
821
|
}
|
|
798
|
-
return uncertain ? { heads, uncertain } : { heads };
|
|
822
|
+
return uncertain ? { heads, calls, uncertain } : { heads, calls };
|
|
799
823
|
}
|
|
@@ -150,6 +150,18 @@ export const DANGEROUS_TECHNIQUES = [
|
|
|
150
150
|
pattern: /\bInvoke-Item\b|\|\s*ii(?![\w.\-:\\\/])|(?:^|[;&({\n]|\$[\w:.{}\[\]]+\s*=)\s*[.&]?\s*ii(?:\s+[^\s;|&)}]|\()|\b(?:pwsh|powershell)(?:\.exe)?\b(?:(?:(?![\s'"]-f)[^|;\n])*?[\s'"]-(?:c|co|com|comm|comma|comman|command)\b['"]?(?:\s*,\s*|\s+)|(?:\s+-(?!f)\w+(?::\S+)?(?:\s+(?![-'"])[\w.]+)?)*\s+)["']?ii(?![\w.\-:\\\/])|\b(Start-Process|saps|start)\s+(?:-\w+\s+)*(?:-FilePath\s+)?["']?(?:[^\s"']+\.(hta|vbs|vbe|js|jse|wsf|wsh|lnk|url|scr|cpl|msc|reg|inf|msi|msp|chm|pif)\b|https?:\/\/|ms-\w+:|file:\/\/)/i,
|
|
151
151
|
why: 'a file opened through its registered handler, or a URL opened in the browser, runs whatever Windows has registered for it under this runner. Start the program itself, by name, with the file as its argument.',
|
|
152
152
|
},
|
|
153
|
+
{
|
|
154
|
+
name: 'credential-capture',
|
|
155
|
+
/*
|
|
156
|
+
* Git asks the operator for a password through its own window (2026-10-26, `stepEnv.ts`), and the answer goes from
|
|
157
|
+
* the window straight to git. A step that ran the window itself, or a credential helper, or set git's or ssh's own
|
|
158
|
+
* password and ssh programs, could put up the same window with its own question and catch the answer in its output
|
|
159
|
+
* — which goes to the chat. Git asks for what it needs by itself: `git push`, `git fetch`, `git pull` and
|
|
160
|
+
* `git clone` are not touched by this.
|
|
161
|
+
*/
|
|
162
|
+
pattern: /\b(?:git|ssh)-askpass\b|\b(?:GIT_ASKPASS|SSH_ASKPASS(?:_REQUIRE)?|GIT_SSH_COMMAND|GIT_SSH|GCM_[A-Z_]+)\b|\bcore\.(?:askpass|sshCommand)\b|\bcredential\.(?:helper|[\w.-]*\.helper)\b|\bgit-credential(?:-[\w-]+)?\b|\bgit(?:\.exe)?(?:\s+-[-\w.=]+(?:\s+[^\s-][^\s]*)?)*\s+credential(?:-[\w-]+)?\b/i,
|
|
163
|
+
why: 'the password Git asks for goes from its own window straight to git; a step that runs that window, a credential helper or git\'s password settings itself could catch what the operator types. Run git itself — push, fetch, pull, clone — and Git asks for what it needs in its own window.',
|
|
164
|
+
},
|
|
153
165
|
{
|
|
154
166
|
name: 'obfuscated-name',
|
|
155
167
|
/*
|
|
@@ -64,13 +64,24 @@ const REGISTRIES = [
|
|
|
64
64
|
[/(?:^|[\s;|&(])gem\s+(?:push|yank|signin)\b/i, 'RubyGems'],
|
|
65
65
|
[/(?:^|[\s;|&(])cargo(?:\.exe)?\s+(?:publish|yank|login)\b/i, 'crates.io'],
|
|
66
66
|
];
|
|
67
|
+
/** The platform tools, by program, as the card names each (for Settings' list of programs, 2026-10-26). */
|
|
68
|
+
export function platformTools() {
|
|
69
|
+
return { ...TOOLS };
|
|
70
|
+
}
|
|
71
|
+
/** The platform a program reaches, as the card names it, or null. */
|
|
72
|
+
export function platformOf(program) {
|
|
73
|
+
return TOOLS[program.toLowerCase()] ?? null;
|
|
74
|
+
}
|
|
67
75
|
/**
|
|
68
76
|
* The platform a command reaches with the operator's access, as the card names it, or null. `Connect-AzAccount` is
|
|
69
|
-
* Azure; `npm publish` the npm registry; `az login; gh repo list` the first one met.
|
|
77
|
+
* Azure; `npm publish` the npm registry; `az login; gh repo list` the first one met. `reading`: programs set to read
|
|
78
|
+
* only whose every command on this line only reads (`readOnly.ts`), which are not asked about.
|
|
70
79
|
*/
|
|
71
|
-
export function platformReason(command, shell) {
|
|
80
|
+
export function platformReason(command, shell, reading) {
|
|
72
81
|
for (const head of commandHeads(command, shell)) {
|
|
73
82
|
const program = externalProgram(head);
|
|
83
|
+
if (program && reading?.has(program.toLowerCase()))
|
|
84
|
+
continue;
|
|
74
85
|
if (program && TOOLS[program.toLowerCase()])
|
|
75
86
|
return TOOLS[program.toLowerCase()];
|
|
76
87
|
const bare = head.replace(/^.*[\\/]/, '').replace(/^['"]|['"]$/g, '');
|
package/dist/src/exec/policy.js
CHANGED
|
@@ -6,6 +6,8 @@ import { unattendedIsolationRefusal } from './isolation.js';
|
|
|
6
6
|
import { confinementRefusal } from './confinement.js';
|
|
7
7
|
import { botSelfRefusal, networkFetchReason, networkFetchRefusal } from './network.js';
|
|
8
8
|
import { ownScriptRefusal, scriptFileRefusal } from './scriptFiles.js';
|
|
9
|
+
import { readOnlyRefusal, readOnlyUnaskedRefusal, readOnlyUnclearRefusal, readOnlyVerdict } from './readOnly.js';
|
|
10
|
+
import { platformReason } from './platforms.js';
|
|
9
11
|
export function describeStep(step) {
|
|
10
12
|
// The shell it will really be read by, not the one this file used to assume: a line in the
|
|
11
13
|
// log that names an interpreter the machine has not got explains the wrong failure.
|
|
@@ -64,7 +66,9 @@ export function commandRefusal(command, shell, denyPatterns, allowedPrograms = [
|
|
|
64
66
|
* speak of — a check run by hand, a test of some other rule. Every path that runs a command for a
|
|
65
67
|
* task passes it: the implementer's steps and checks, and the reviewer's steps and derived checks.
|
|
66
68
|
*/
|
|
67
|
-
confinement
|
|
69
|
+
confinement,
|
|
70
|
+
/** Programs set to read only: a command of theirs that changes something is refused. See `readOnly.ts`. */
|
|
71
|
+
readOnlyPrograms = []) {
|
|
68
72
|
// The built-in refusals first, because the operator's list can add to them and must not be
|
|
69
73
|
// able to stand in for them: a config written before they existed, or edited since, still gets
|
|
70
74
|
// them. See `dangerous.ts` for what is on the list and why each one is.
|
|
@@ -95,6 +99,10 @@ confinement) {
|
|
|
95
99
|
const offlist = programRefusal(command, allowedPrograms, shell);
|
|
96
100
|
if (offlist)
|
|
97
101
|
return offlist;
|
|
102
|
+
// A program on the list but set to read only, asked to change something (2026-10-26).
|
|
103
|
+
const writes = readOnlyRefusal(command, shell, readOnlyPrograms);
|
|
104
|
+
if (writes)
|
|
105
|
+
return writes;
|
|
98
106
|
const trap = findShellExecuteTrap(command, shell, env);
|
|
99
107
|
if (trap)
|
|
100
108
|
return trap;
|
|
@@ -108,7 +116,9 @@ confinement) {
|
|
|
108
116
|
repositoryInternalsRefusal(text) ??
|
|
109
117
|
(matchDenyPattern(text, denyPatterns) ? `matches deny pattern /${matchDenyPattern(text, denyPatterns)}/` : null) ??
|
|
110
118
|
confinementRefusal(text, confinement) ??
|
|
111
|
-
programRefusal(text, allowedPrograms)
|
|
119
|
+
programRefusal(text, allowedPrograms) ??
|
|
120
|
+
// Inside a script nothing is put to the operator command by command: one that cannot be read as reading is refused.
|
|
121
|
+
readOnlyUnaskedRefusal(text, undefined, readOnlyPrograms));
|
|
112
122
|
}
|
|
113
123
|
return null;
|
|
114
124
|
}
|
|
@@ -119,12 +129,29 @@ confinement) {
|
|
|
119
129
|
* reviewer's checks refused downloads, the plan's did not).
|
|
120
130
|
*/
|
|
121
131
|
export function checkCommandRefusal(command, shell, cfg, confinement, env = process.env) {
|
|
122
|
-
const refusal = commandRefusal(command, shell, cfg.denyPatterns, cfg.allowedPrograms, env, confinement);
|
|
132
|
+
const refusal = commandRefusal(command, shell, cfg.denyPatterns, cfg.allowedPrograms, env, confinement, cfg.readOnlyPrograms ?? []);
|
|
123
133
|
if (refusal)
|
|
124
134
|
return refusal;
|
|
135
|
+
const access = checkAccessRefusal(command, shell, cfg);
|
|
136
|
+
if (access)
|
|
137
|
+
return access;
|
|
125
138
|
const network = networkFetchReason(command, confinement.cwd) ?? scriptNetworkReason(command, confinement.cwd);
|
|
126
139
|
return network ? networkFetchRefusal(network) : null;
|
|
127
140
|
}
|
|
141
|
+
/**
|
|
142
|
+
* A check reaching a platform with the operator's access, which a step puts to the operator every time (2026-10-26):
|
|
143
|
+
* a check has nobody to put it to, so it is refused unless Settings agree with what the bot proposes. A program set to
|
|
144
|
+
* read only passes with a command that only reads; one that cannot be read as reading is refused.
|
|
145
|
+
*/
|
|
146
|
+
export function checkAccessRefusal(command, shell, cfg) {
|
|
147
|
+
const reading = readOnlyVerdict(command, shell, cfg.readOnlyPrograms);
|
|
148
|
+
if (reading?.kind === 'unclear')
|
|
149
|
+
return readOnlyUnclearRefusal(reading.program, reading.why);
|
|
150
|
+
const platform = cfg.questions === 'agree' ? null : platformReason(command, shell, reading?.kind === 'reads' ? new Set(reading.programs) : undefined);
|
|
151
|
+
if (!platform)
|
|
152
|
+
return null;
|
|
153
|
+
return `refused: this check reaches ${platform} with the operator's access, which only the operator may allow, and a check runs with nobody asked. Check it another way, or do it in a step, where it is put to the operator.`;
|
|
154
|
+
}
|
|
128
155
|
/** A fetch inside a script the line runs — held or refused exactly as one on the line would be. */
|
|
129
156
|
export function scriptNetworkReason(command, cwd) {
|
|
130
157
|
let found = null;
|
|
@@ -185,7 +212,7 @@ export function staticCheck(step, cfg, env = process.env, confinement) {
|
|
|
185
212
|
}
|
|
186
213
|
// Screened against the shell that will actually read it: the traps in `shellExecuteTrap.ts`
|
|
187
214
|
// are shell-specific, so screening for one interpreter and running in another finds nothing.
|
|
188
|
-
const reason = commandRefusal(step.cmd, effectiveShell(step.shell), cfg.denyPatterns, cfg.allowedPrograms, env, confinement);
|
|
215
|
+
const reason = commandRefusal(step.cmd, effectiveShell(step.shell), cfg.denyPatterns, cfg.allowedPrograms, env, confinement, cfg.readOnlyPrograms ?? []);
|
|
189
216
|
if (reason)
|
|
190
217
|
return { action: 'skip', reason };
|
|
191
218
|
/*
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
import { createHash } from 'node:crypto';
|
|
24
24
|
import { DANGEROUS_TECHNIQUES } from './dangerous.js';
|
|
25
25
|
import { describeIsolation } from './isolation.js';
|
|
26
|
+
import { readOnlyCapable } from './readOnly.js';
|
|
26
27
|
/** A short, stable digest of a list, order-independent so a reordered config is not a changed one. */
|
|
27
28
|
export function digestOf(values) {
|
|
28
29
|
// JSON rather than a separator character: unambiguous for any entry, and free of the control
|
|
@@ -46,6 +47,12 @@ export function networkFetchStatement(mode, choice = 'ask') {
|
|
|
46
47
|
return `${FETCHES} RUNS WITHOUT ANYONE READING IT — the operator chose this (execution.networkFetch: run). Only the deny list and the built-in refusals applied`;
|
|
47
48
|
return `${FETCHES} is held for the operator even in this unattended run (execution.networkFetch: ask); with nobody to ask it is refused. ${NOT_HELD}`;
|
|
48
49
|
}
|
|
50
|
+
/** The programs set to read only that a rule reads and, with the gate on, the list names: the ones in force. */
|
|
51
|
+
function readOnlyInForce(readOnly, allowed) {
|
|
52
|
+
const capable = new Set(readOnlyCapable());
|
|
53
|
+
const listed = new Set(allowed.map((p) => p.trim().toLowerCase()));
|
|
54
|
+
return [...new Set(readOnly.map((p) => p.trim().toLowerCase()))].filter((p) => capable.has(p) && (listed.size === 0 || listed.has(p)));
|
|
55
|
+
}
|
|
49
56
|
export function collectPolicyManifest(input, env = process.env) {
|
|
50
57
|
const names = DANGEROUS_TECHNIQUES.map((t) => t.name);
|
|
51
58
|
return {
|
|
@@ -59,6 +66,7 @@ export function collectPolicyManifest(input, env = process.env) {
|
|
|
59
66
|
digest: digestOf(input.allowedPrograms),
|
|
60
67
|
programs: [...input.allowedPrograms],
|
|
61
68
|
},
|
|
69
|
+
readOnly: readOnlyInForce(input.readOnlyPrograms ?? [], input.allowedPrograms),
|
|
62
70
|
chatFiles: 'the chat cannot supply a file: this runner has no file step and executes nothing it did not receive as a command',
|
|
63
71
|
networkFetch: networkFetchStatement(input.mode, input.networkFetch),
|
|
64
72
|
denyPatterns: { count: input.denyPatterns.length, digest: digestOf(input.denyPatterns) },
|
|
@@ -79,6 +87,7 @@ export function describePolicyManifest(m) {
|
|
|
79
87
|
return [
|
|
80
88
|
`mode : ${m.mode}${m.mode === 'unattended' ? ' (no person saw the steps as they ran)' : ' (a person approved each step)'}`,
|
|
81
89
|
`allowlist : ${m.allowlist.enforced ? `${m.allowlist.count} programs, digest ${m.allowlist.digest}` : 'NOT ENFORCED — any program could be started'}`,
|
|
90
|
+
`read only : ${m.readOnly.length ? `${m.readOnly.join(', ')} — a command that changes something, signs in or out or shows a secret is refused` : 'none'}`,
|
|
82
91
|
`chat files : ${m.chatFiles}`,
|
|
83
92
|
`downloads : ${m.networkFetch}`,
|
|
84
93
|
`deny list : ${m.denyPatterns.count} patterns, digest ${m.denyPatterns.digest}`,
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Programs set to read only (operator, 2026-10-26: "give the bot az, with me signing in myself and the bot never
|
|
3
|
+
* learning my credentials; but it is important that it runs without writing, for reference only"). A program on the
|
|
4
|
+
* allowlist that reaches a platform with the operator's access is put to the operator on every command
|
|
5
|
+
* (`platforms.ts`). Set to read only, its commands are read by their own words instead:
|
|
6
|
+
*
|
|
7
|
+
* reads `az vm list`, `az group show`, `az graph query`: run without a card, as any other command does
|
|
8
|
+
* refused a change (create, delete, update, start, deploy…), a sign-in or sign-out, a secret shown (keys, tokens,
|
|
9
|
+
* connection strings, app settings), `az rest`, a download: sent back to the chat with why
|
|
10
|
+
* unclear a verb known neither way, a word known only when it runs, or the program named where it is not run
|
|
11
|
+
* directly (a string, `cmd /c`, `Start-Process`): held on a card in every mode, even when Settings agree
|
|
12
|
+
* with what the bot proposes, since the operator said this program must not write
|
|
13
|
+
*
|
|
14
|
+
* The sign-in is the operator's own: `az login` in their terminal. The bot's commands use it as it is and never see a
|
|
15
|
+
* password, which Microsoft's own window takes. The bot never signs in or out, and az's token cache is outside the
|
|
16
|
+
* project, where no command may reach (`confinement.ts`).
|
|
17
|
+
*
|
|
18
|
+
* The honest limit, the same as everywhere in this folder: this reads the command line. A program the project contains,
|
|
19
|
+
* such as a script that calls Azure's API, is not seen. What makes "read only" true is the account: one with only the
|
|
20
|
+
* Reader role has Azure itself refuse every change.
|
|
21
|
+
*/
|
|
22
|
+
import { scanCommandHeads } from './commandHeads.js';
|
|
23
|
+
import { externalProgram } from './programs.js';
|
|
24
|
+
/** The programs whose commands can be told apart, reading from changing, each by its own rule. */
|
|
25
|
+
const RULES = { az: azReading };
|
|
26
|
+
/** The programs that may be set to read only: the ones with a rule. */
|
|
27
|
+
export function readOnlyCapable() {
|
|
28
|
+
return Object.keys(RULES);
|
|
29
|
+
}
|
|
30
|
+
const normalise = (p) => p.trim().toLowerCase().replace(/\.(exe|cmd|bat|com)$/i, '');
|
|
31
|
+
/**
|
|
32
|
+
* What a line does with the programs set to read only, or null when it starts none of them. Refused at the first
|
|
33
|
+
* invocation that changes something; unclear when one cannot be read, or when a program is named more often than the
|
|
34
|
+
* line runs it directly — the rest of its mentions are where its words cannot be read.
|
|
35
|
+
*/
|
|
36
|
+
export function readOnlyVerdict(command, shell, readOnlyPrograms) {
|
|
37
|
+
const set = new Set((readOnlyPrograms ?? []).map(normalise).filter((p) => p in RULES));
|
|
38
|
+
if (set.size === 0)
|
|
39
|
+
return null;
|
|
40
|
+
const scan = scanCommandHeads(command, shell ?? 'pwsh');
|
|
41
|
+
const runs = new Map();
|
|
42
|
+
const programs = [];
|
|
43
|
+
let unclear = null;
|
|
44
|
+
for (const call of scan.calls) {
|
|
45
|
+
const program = externalProgram(call.head);
|
|
46
|
+
if (!program || !set.has(program))
|
|
47
|
+
continue;
|
|
48
|
+
runs.set(program, (runs.get(program) ?? 0) + 1);
|
|
49
|
+
const r = RULES[program](call.args);
|
|
50
|
+
if (r.kind === 'refused')
|
|
51
|
+
return r;
|
|
52
|
+
if (r.kind === 'unclear')
|
|
53
|
+
unclear ??= { program, why: r.why };
|
|
54
|
+
else if (!programs.includes(program))
|
|
55
|
+
programs.push(program);
|
|
56
|
+
}
|
|
57
|
+
for (const program of set) {
|
|
58
|
+
if (mentions(command, program) > (runs.get(program) ?? 0)) {
|
|
59
|
+
unclear ??= { program, why: `${program} is named where its words cannot be read (in a string, a nested shell, Start-Process or a name built at run time)` };
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
if (unclear)
|
|
63
|
+
return { kind: 'unclear', ...unclear };
|
|
64
|
+
return programs.length > 0 ? { kind: 'reads', programs } : null;
|
|
65
|
+
}
|
|
66
|
+
/** Why a line must not run because a program set to read only would change something, or null. */
|
|
67
|
+
export function readOnlyRefusal(command, shell, readOnlyPrograms) {
|
|
68
|
+
const v = readOnlyVerdict(command, shell, readOnlyPrograms);
|
|
69
|
+
return v?.kind === 'refused' ? v.reason : null;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* The same for the text of a script the line runs, and for a check, which run with nobody asked: a command that cannot
|
|
73
|
+
* be read as only reading has nobody to put it to, so it is refused as well.
|
|
74
|
+
*/
|
|
75
|
+
export function readOnlyUnaskedRefusal(command, shell, readOnlyPrograms) {
|
|
76
|
+
const v = readOnlyVerdict(command, shell, readOnlyPrograms);
|
|
77
|
+
if (v?.kind === 'refused')
|
|
78
|
+
return v.reason;
|
|
79
|
+
if (v?.kind === 'unclear')
|
|
80
|
+
return readOnlyUnclearRefusal(v.program, v.why);
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
/** What the chat is told of a command that could not be read as only reading and had nobody to ask. */
|
|
84
|
+
export function readOnlyUnclearRefusal(program, why) {
|
|
85
|
+
return (`refused: ${program} is set to read only here, and this could not be read as only reading (${why}); ` +
|
|
86
|
+
`nobody is there to judge it. Call ${program} directly on the step's own line, with a command that only reads — list, show or query.`);
|
|
87
|
+
}
|
|
88
|
+
/** How many times the line names the program as a word of its own: `az`, `az.cmd`, `'az'`; not `az.txt` or `lazy`. */
|
|
89
|
+
function mentions(command, program) {
|
|
90
|
+
const name = program.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
91
|
+
return command.match(new RegExp(`(?<![\\w.\\\\/$@-])${name}(?:\\.(?:cmd|exe|bat))?(?![\\w.\\\\/-])`, 'gi'))?.length ?? 0;
|
|
92
|
+
}
|
|
93
|
+
// ------------------------------------------------------------------------------------------
|
|
94
|
+
// az
|
|
95
|
+
// ------------------------------------------------------------------------------------------
|
|
96
|
+
/** A word of the command that shows a secret: keys, tokens, passwords, connection strings, app settings. */
|
|
97
|
+
const AZ_SECRET = /(?:^|-)(?:keys?|credentials?|secrets?|passwords?|tokens?|sas|connection-strings?|appsettings|publishing-profiles?|kubeconfig)(?:$|-)/;
|
|
98
|
+
/** The verbs that only read. `get-…`, `list-…` and `show-…` after the secrets are taken out. */
|
|
99
|
+
const AZ_READ = /^(?:list|show|query|exists|wait|version|what-if|(?:list|show|get)-[a-z0-9-]+|check-name(?:-availability)?)$/;
|
|
100
|
+
/** The verbs that change something, in Azure or in az's own setup; and the ones named after them (`create-for-rbac`). */
|
|
101
|
+
const AZ_WRITE = /^(?:create|delete|update|set|unset|add|remove|start|stop|restart|reboot|deploy|redeploy|reimage|deallocate|generalize|capture|resize|scale|swap|assign|unassign|purge|recover|restore|backup|renew|regenerate|rotate|reset|import|upload|sync|move|lock|unlock|enable|disable|approve|reject|attach|detach|connect|disconnect|apply|cancel|abort|run|invoke|execute|install|uninstall|register|unregister|grant|revoke|push|tag|untag|migrate|upgrade|failover|promote|convert|link|unlink|clear|flush|cordon|drain|retry|rerun|trigger|publish|release|merge|close|reopen|accept|archive|unarchive|schedule|power-off|rollback|repair|refresh|replace|rename|copy|patch|put|post|send|mount|unmount|activate|deactivate|pause|resume|suspend|terminate|kill)(?:-[a-z0-9-]+)?$/;
|
|
102
|
+
/**
|
|
103
|
+
* One `az` invocation. Its command is the group path and the verb at its end, the words before the first option:
|
|
104
|
+
* `az storage account list --query ...` is `storage account list`, read by `list`. `--help` anywhere only prints help.
|
|
105
|
+
*/
|
|
106
|
+
function azReading(args) {
|
|
107
|
+
if (args.some((a) => !a.dynamic && /^(?:--help|-h)$/i.test(a.literal)))
|
|
108
|
+
return { kind: 'reads' };
|
|
109
|
+
const path = [];
|
|
110
|
+
for (const a of args) {
|
|
111
|
+
if (a.dynamic)
|
|
112
|
+
return { kind: 'unclear', why: 'a word of the az command is known only when it runs' };
|
|
113
|
+
if (a.literal.startsWith('-'))
|
|
114
|
+
break;
|
|
115
|
+
path.push(a.literal.toLowerCase());
|
|
116
|
+
}
|
|
117
|
+
// `az`, `az --version`: nothing but the version or the help.
|
|
118
|
+
if (path.length === 0)
|
|
119
|
+
return { kind: 'reads' };
|
|
120
|
+
const p = path.join(' ');
|
|
121
|
+
if (path[0] === 'rest') {
|
|
122
|
+
return { kind: 'refused', reason: 'refused: "az rest" sends any request to Azure, one that changes something too, and az is set to read only here. Use the resource\'s own list, show or query command.' };
|
|
123
|
+
}
|
|
124
|
+
if (path.some((w) => w === 'login' || w === 'logout')) {
|
|
125
|
+
return {
|
|
126
|
+
kind: 'refused',
|
|
127
|
+
reason: `refused: "az ${p}" signs in or out. The operator signs in with az login themselves; the bot uses that sign-in as it is and never signs in, out or as anyone else. If az says nobody is signed in, end blocked and say so in notes.`,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
if (path[0] === 'account' && (path[1] === 'set' || path[1] === 'clear')) {
|
|
131
|
+
return { kind: 'refused', reason: `refused: "az account ${path[1]}" changes the subscription the operator's own az uses. Name it on the command instead: --subscription <name or id>.` };
|
|
132
|
+
}
|
|
133
|
+
if (path[0] === 'interactive' || path[0] === 'init') {
|
|
134
|
+
return { kind: 'refused', reason: `refused: "az ${p}" waits for a person to type, and nobody types into a step. Run the command itself.` };
|
|
135
|
+
}
|
|
136
|
+
if (path.some((w) => AZ_SECRET.test(w))) {
|
|
137
|
+
return {
|
|
138
|
+
kind: 'refused',
|
|
139
|
+
reason: `refused: "az ${p}" shows a secret (a key, a token, a password, a connection string or app settings), and az is set to read only here: what a step prints goes to the chat. Read the resource with show or list, which leave the secrets out.`,
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
// `az find "<words>"` takes what it looks for after it; every other command ends at its verb.
|
|
143
|
+
if (path[0] === 'find')
|
|
144
|
+
return { kind: 'reads' };
|
|
145
|
+
const verb = path.at(-1);
|
|
146
|
+
if (/^download(?:-|$)/.test(verb)) {
|
|
147
|
+
return { kind: 'refused', reason: `refused: "az ${p}" downloads a file, and the bot does not download files; az is set to read only here. Read with list, show or query.` };
|
|
148
|
+
}
|
|
149
|
+
if (AZ_WRITE.test(verb)) {
|
|
150
|
+
return {
|
|
151
|
+
kind: 'refused',
|
|
152
|
+
reason: `refused: "az ${p}" changes something, and az is set to read only here (for reference): its commands may look, never change. Read with list, show or query; if something has to change, say in notes what and leave it to the operator.`,
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
if (AZ_READ.test(verb))
|
|
156
|
+
return { kind: 'reads' };
|
|
157
|
+
return { kind: 'unclear', why: `"az ${p}" is not known as only reading` };
|
|
158
|
+
}
|
package/dist/src/exec/runner.js
CHANGED
|
@@ -27,6 +27,10 @@ import { StringDecoder } from 'node:string_decoder';
|
|
|
27
27
|
import { effectiveShell, invocationFor, missingShellProblem, resolveShell } from './shells.js';
|
|
28
28
|
import { stopTree } from './processes.js';
|
|
29
29
|
import { stepEnvironment } from './stepEnv.js';
|
|
30
|
+
import { closePasswordWindows, passwordWindowOpen } from '../vcs/remoteAuth.js';
|
|
31
|
+
/** How long a step is quiet before Git's password window is looked for, and how often then. */
|
|
32
|
+
const PASSWORD_QUIET_MS = 3_000;
|
|
33
|
+
const PASSWORD_PROBE_MS = 2_000;
|
|
30
34
|
const DEFAULT_HARD_TIMEOUT_MS = 4 * 60 * 60 * 1000;
|
|
31
35
|
const DEFAULT_IDLE_TIMEOUT_MS = 15 * 60 * 1000;
|
|
32
36
|
/** How often a running step says how it is doing, unless the caller asks for another pace. */
|
|
@@ -202,7 +206,7 @@ opts = {}) {
|
|
|
202
206
|
cwd: req.cwd,
|
|
203
207
|
// Named, not inherited: a step must not see the bot's own token or whatever else the
|
|
204
208
|
// operator's shell holds. See `stepEnv.ts`.
|
|
205
|
-
env: stepEnvironment(req.env ?? process.env, req.passEnv),
|
|
209
|
+
env: stepEnvironment(req.env ?? process.env, req.passEnv, req.askpass),
|
|
206
210
|
// True for `cmd`, whose command line `invocationFor` has already written in full: quoted again
|
|
207
211
|
// here, every double quote in a step would reach `cmd` as `\"`, which it does not understand.
|
|
208
212
|
windowsVerbatimArguments,
|
|
@@ -222,6 +226,9 @@ opts = {}) {
|
|
|
222
226
|
clearInterval(heartbeat);
|
|
223
227
|
clearTimeout(hardTimer);
|
|
224
228
|
clearInterval(idleTimer);
|
|
229
|
+
clearInterval(passwordTimer);
|
|
230
|
+
if (passwordOpen)
|
|
231
|
+
opts.onPasswordWindow?.(false);
|
|
225
232
|
opts.signal?.removeEventListener('abort', onAbort);
|
|
226
233
|
log.end(`\n# outcome=${outcome} exit=${exitCode} durationMs=${Date.now() - startedAt}\n`);
|
|
227
234
|
resolve({
|
|
@@ -356,11 +363,77 @@ opts = {}) {
|
|
|
356
363
|
const hardTimer = setTimeout(() => {
|
|
357
364
|
stop('hard-timeout', -1, `hard timeout after ${Math.round(hardTimeoutMs / 1000)}s`);
|
|
358
365
|
}, hardTimeoutMs);
|
|
366
|
+
/*
|
|
367
|
+
* While Git's password window is open the step is waiting for the operator, not hung (2026-10-26): its idle clock is
|
|
368
|
+
* held, and the caller is told when the window opens and when it closes, so the chat can say where to look. Looked
|
|
369
|
+
* for when the step has been quiet a while, and always before a quiet step is stopped as hung. The time the window
|
|
370
|
+
* was open never counts: the clock starts again when it closes. A window nobody answers for as long as the idle
|
|
371
|
+
* limit — a run with nobody there — ends the step, and is closed.
|
|
372
|
+
*/
|
|
373
|
+
let passwordOpen = false;
|
|
374
|
+
let passwordSince = 0;
|
|
375
|
+
let probing = false;
|
|
376
|
+
const probe = opts.passwordProbe ?? passwordWindowOpen;
|
|
377
|
+
/** Whether the step is to be held: the window open now, or closed just now. */
|
|
378
|
+
const lookForPassword = async () => {
|
|
379
|
+
const open = await probe(startedAt);
|
|
380
|
+
if (settled)
|
|
381
|
+
return true;
|
|
382
|
+
if (open) {
|
|
383
|
+
if (!passwordOpen) {
|
|
384
|
+
passwordOpen = true;
|
|
385
|
+
passwordSince = Date.now();
|
|
386
|
+
opts.onPasswordWindow?.(true);
|
|
387
|
+
}
|
|
388
|
+
if (Date.now() - passwordSince >= idleTimeoutMs)
|
|
389
|
+
return false;
|
|
390
|
+
lastOutputAt = Date.now();
|
|
391
|
+
return true;
|
|
392
|
+
}
|
|
393
|
+
if (passwordOpen) {
|
|
394
|
+
passwordOpen = false;
|
|
395
|
+
lastOutputAt = Date.now();
|
|
396
|
+
opts.onPasswordWindow?.(false);
|
|
397
|
+
return true;
|
|
398
|
+
}
|
|
399
|
+
return false;
|
|
400
|
+
};
|
|
359
401
|
const idleTimer = setInterval(() => {
|
|
360
402
|
if (Date.now() - lastOutputAt < idleTimeoutMs)
|
|
361
403
|
return;
|
|
362
|
-
|
|
404
|
+
const hung = () => {
|
|
405
|
+
if (!passwordOpen)
|
|
406
|
+
return stop('idle-timeout', -1, `no output for ${Math.round(idleTimeoutMs / 1000)}s, treating as hung`);
|
|
407
|
+
// Nobody answered Git's password window: the step ends, and the window, left behind by its process tree, is closed.
|
|
408
|
+
stop('idle-timeout', -1, `Git's password window was not answered for ${Math.round(idleTimeoutMs / 1000)}s`);
|
|
409
|
+
if (req.askpass)
|
|
410
|
+
void closePasswordWindows(req.askpass, new Date(startedAt - 1000));
|
|
411
|
+
};
|
|
412
|
+
if (!req.askpass)
|
|
413
|
+
return hung();
|
|
414
|
+
if (probing)
|
|
415
|
+
return;
|
|
416
|
+
probing = true;
|
|
417
|
+
void lookForPassword()
|
|
418
|
+
.then((held) => {
|
|
419
|
+
if (!held && !settled)
|
|
420
|
+
hung();
|
|
421
|
+
})
|
|
422
|
+
.catch(() => hung())
|
|
423
|
+
.finally(() => {
|
|
424
|
+
probing = false;
|
|
425
|
+
});
|
|
363
426
|
}, Math.min(idleTimeoutMs, 30_000));
|
|
427
|
+
const passwordTimer = setInterval(() => {
|
|
428
|
+
if (!req.askpass || probing || settled || Date.now() - lastOutputAt < PASSWORD_QUIET_MS)
|
|
429
|
+
return;
|
|
430
|
+
probing = true;
|
|
431
|
+
void lookForPassword()
|
|
432
|
+
.catch(() => undefined)
|
|
433
|
+
.finally(() => {
|
|
434
|
+
probing = false;
|
|
435
|
+
});
|
|
436
|
+
}, PASSWORD_PROBE_MS);
|
|
364
437
|
const heartbeat = setInterval(() => {
|
|
365
438
|
opts.onHeartbeat?.({
|
|
366
439
|
id: req.id,
|
package/dist/src/exec/stepEnv.js
CHANGED
|
@@ -59,7 +59,15 @@ const FORCED = {
|
|
|
59
59
|
};
|
|
60
60
|
/** Names a step must never be given, even if the operator lists them: the bot's own keys. */
|
|
61
61
|
const NEVER = /^(NEXT_PUBLIC_COP_|COP_)/i;
|
|
62
|
-
|
|
62
|
+
/**
|
|
63
|
+
* `askpass`: Git for Windows' own password window (operator, 2026-10-26: "if the chat works with git and a password is
|
|
64
|
+
* needed, the bot stops, a window opens for the operator to type it, and the work goes on; every time one is asked").
|
|
65
|
+
* Set, not passed: ssh and git ask through it — and Git Credential Manager through its own window — so a `git push` or
|
|
66
|
+
* `git fetch` a step runs asks the operator there, and the answer goes from the window straight to git, never through
|
|
67
|
+
* the step's output. No terminal prompt: a step has none. See `remoteAuth.ts`; a step that names any of this itself
|
|
68
|
+
* is refused (`dangerous.ts`, credential-capture).
|
|
69
|
+
*/
|
|
70
|
+
export function stepEnvironment(from = process.env, extra = [], askpass) {
|
|
63
71
|
const wanted = new Set([...PASSED, ...extra].map((n) => n.toLowerCase()));
|
|
64
72
|
const out = {};
|
|
65
73
|
for (const [k, v] of Object.entries(from)) {
|
|
@@ -68,5 +76,8 @@ export function stepEnvironment(from = process.env, extra = []) {
|
|
|
68
76
|
if (wanted.has(k.toLowerCase()) || PASSED_BY_SHAPE.test(k))
|
|
69
77
|
out[k] = v;
|
|
70
78
|
}
|
|
71
|
-
|
|
79
|
+
const asking = askpass
|
|
80
|
+
? { GIT_ASKPASS: askpass, SSH_ASKPASS: askpass, SSH_ASKPASS_REQUIRE: 'force', GIT_TERMINAL_PROMPT: '0', GCM_INTERACTIVE: 'auto', DISPLAY: from.DISPLAY || 'needs-to-be-defined' }
|
|
81
|
+
: {};
|
|
82
|
+
return { ...out, ...FORCED, ...asking };
|
|
72
83
|
}
|