copilot-operator 0.1.69 → 0.1.75

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.
Files changed (82) hide show
  1. package/dist/src/api/operator.controller.js +6 -3
  2. package/dist/src/api/operator.service.js +58 -13
  3. package/dist/src/api/server.js +10 -0
  4. package/dist/src/cli.js +3 -0
  5. package/dist/src/config/lockedPolicy.js +14 -0
  6. package/dist/src/config/schema.js +29 -0
  7. package/dist/src/exec/authorizer.js +47 -8
  8. package/dist/src/exec/dangerous.js +1 -1
  9. package/dist/src/exec/npmScripts.js +180 -0
  10. package/dist/src/exec/platforms.js +45 -1
  11. package/dist/src/exec/policy.js +124 -9
  12. package/dist/src/exec/policyManifest.js +15 -0
  13. package/dist/src/exec/processes.js +8 -3
  14. package/dist/src/exec/programs.js +6 -1
  15. package/dist/src/exec/redaction.js +17 -2
  16. package/dist/src/exec/scriptFiles.js +230 -34
  17. package/dist/src/exec/scriptKinds.js +86 -0
  18. package/dist/src/exec/stepEnv.js +9 -2
  19. package/dist/src/orchestrator/handoff.js +80 -29
  20. package/dist/src/orchestrator/hold.js +83 -4
  21. package/dist/src/orchestrator/leadRunner.js +5 -2
  22. package/dist/src/orchestrator/review.js +13 -3
  23. package/dist/src/orchestrator/taskRunner.js +106 -19
  24. package/dist/src/plan/kerrigan.js +36 -15
  25. package/dist/src/plan/systemGuide.js +117 -22
  26. package/dist/src/protocol/leadSchema.js +8 -1
  27. package/dist/src/protocol/replySchema.js +13 -3
  28. package/dist/src/protocol/reviewSchema.js +4 -1
  29. package/dist/src/queue/queue.js +8 -4
  30. package/dist/src/session/checkpoint.js +48 -0
  31. package/dist/src/session/compose.js +1 -1
  32. package/dist/src/session/story.js +14 -0
  33. package/dist/src/vcs/gitConfigGuard.js +126 -0
  34. package/dist/src/vcs/newBranch.js +76 -13
  35. package/dist/web/404.html +2 -2
  36. package/dist/web/_next/static/chunks/1024-67625a65f58057ae.js +1 -0
  37. package/dist/web/_next/static/chunks/1077.14d6c828d8f71111.js +1 -0
  38. package/dist/web/_next/static/chunks/1548.2f75926c6e664f79.js +1 -0
  39. package/dist/web/_next/static/chunks/2163.f9f1ad4af05520cc.js +1 -0
  40. package/dist/web/_next/static/chunks/714.4507656685cb9337.js +1 -0
  41. package/dist/web/_next/static/chunks/7220.9bc9dd9f211b11e4.js +1 -0
  42. package/dist/web/_next/static/chunks/7921-9aaec581982b2329.js +1 -0
  43. package/dist/web/_next/static/chunks/8124-a39d85dff0db6600.js +1 -0
  44. package/dist/web/_next/static/chunks/8584.f2cb3ca81223d626.js +1 -0
  45. package/dist/web/_next/static/chunks/9067.a6cb3b9157a80921.js +1 -0
  46. package/dist/web/_next/static/chunks/9747.15aa40a046d54a2a.js +1 -0
  47. package/dist/web/_next/static/chunks/9929-2e0b1d006ebd5345.js +1 -0
  48. package/dist/web/_next/static/chunks/app/{layout-e23bb58f3ea117d5.js → layout-52a2079ffa83c21f.js} +1 -1
  49. package/dist/web/_next/static/chunks/app/page-80730838a81da226.js +1 -0
  50. package/dist/web/_next/static/chunks/app/queue/{page-fb49cb2d3dc6d14c.js → page-82f724d0842f4870.js} +1 -1
  51. package/dist/web/_next/static/chunks/app/settings/page-4f3c739287d7f32e.js +1 -0
  52. package/dist/web/_next/static/chunks/{webpack-77c6c045264c9213.js → webpack-f9f820c51a8952c8.js} +1 -1
  53. package/dist/web/_next/static/css/63b30b8e1a4aa500.css +1 -0
  54. package/dist/web/defaults.html +2 -2
  55. package/dist/web/defaults.txt +8 -8
  56. package/dist/web/index.html +3 -3
  57. package/dist/web/index.txt +9 -9
  58. package/dist/web/queue.html +2 -2
  59. package/dist/web/queue.txt +9 -9
  60. package/dist/web/settings.html +2 -2
  61. package/dist/web/settings.txt +9 -9
  62. package/dist/web/system.html +2 -2
  63. package/dist/web/system.txt +9 -9
  64. package/package.json +3 -2
  65. package/prompts/level1.md +50 -27
  66. package/dist/web/_next/static/chunks/1024-e4e596b184e05e91.js +0 -1
  67. package/dist/web/_next/static/chunks/1077.b3943e5b41c4bef4.js +0 -1
  68. package/dist/web/_next/static/chunks/1548.0ff0c0ece685ffe7.js +0 -1
  69. package/dist/web/_next/static/chunks/2163.9cfb1b06beaf5001.js +0 -1
  70. package/dist/web/_next/static/chunks/6262-d074473db83ee798.js +0 -1
  71. package/dist/web/_next/static/chunks/714.bee98f5a3db75882.js +0 -1
  72. package/dist/web/_next/static/chunks/7220.610988766a1104b7.js +0 -1
  73. package/dist/web/_next/static/chunks/7921-ac5793d5663674b2.js +0 -1
  74. package/dist/web/_next/static/chunks/8124-665327221384ba6e.js +0 -1
  75. package/dist/web/_next/static/chunks/8584.9220e445a8ce2265.js +0 -1
  76. package/dist/web/_next/static/chunks/9067.f05516f2f2a2e8f5.js +0 -1
  77. package/dist/web/_next/static/chunks/9747.e249434ff7e05f4f.js +0 -1
  78. package/dist/web/_next/static/chunks/app/page-fd49cf4fb6681d30.js +0 -1
  79. package/dist/web/_next/static/chunks/app/settings/page-7d120feb5af0ace9.js +0 -1
  80. package/dist/web/_next/static/css/52131c6d864daf3f.css +0 -1
  81. /package/dist/web/_next/static/{8i6gf0zoo-KiUKdzxsCJR → 9DmRzBb0M5BZ3dvVpbFMM}/_buildManifest.js +0 -0
  82. /package/dist/web/_next/static/{8i6gf0zoo-KiUKdzxsCJR → 9DmRzBb0M5BZ3dvVpbFMM}/_ssgManifest.js +0 -0
@@ -8,7 +8,8 @@
8
8
  * Read by the programs a line starts (`commandHeads`, as the shell reads it), not by words anywhere in it: a file
9
9
  * that mentions `az` is not a command to Azure.
10
10
  */
11
- import { commandHeads, externalProgram } from './programs.js';
11
+ import { commandHeads, externalProgram, startProcessTargets } from './programs.js';
12
+ import { scanCommandHeads } from './commandHeads.js';
12
13
  /** Platform command-line tools, by the program's name. */
13
14
  const TOOLS = {
14
15
  az: 'Azure (az)',
@@ -91,8 +92,51 @@ export function platformReason(command, shell, reading) {
91
92
  if (pattern.test(bare) || pattern.test(bare.toLowerCase()))
92
93
  return name;
93
94
  }
95
+ /*
96
+ * What a package runner or Start-Process starts (audit, 2026-10-27): `npx vercel deploy`, `npm exec -- vercel`,
97
+ * `pnpm dlx netlify deploy`, `Start-Process gh -ArgumentList …` reach the platform as the program itself does.
98
+ */
99
+ for (const program of startedPrograms(command, shell)) {
100
+ if (reading?.has(program))
101
+ continue;
102
+ if (TOOLS[program])
103
+ return TOOLS[program];
104
+ }
94
105
  for (const [pattern, name] of REGISTRIES)
95
106
  if (pattern.test(command))
96
107
  return name;
97
108
  return null;
98
109
  }
110
+ const RUNNERS = { npx: null, pnpx: null, bunx: null, npm: new Set(['exec', 'x']), pnpm: new Set(['exec', 'dlx']), yarn: new Set(['exec', 'dlx']) };
111
+ /** The programs a package runner and Start-Process are given to start, by name. */
112
+ function startedPrograms(command, shell) {
113
+ const out = [];
114
+ const name = (word) => word.replace(/^.*[\\/]/, '').replace(/^['"]|['"]$/g, '').replace(/\.(?:exe|cmd|ps1)$/i, '').replace(/@[^@/]*$/, '').toLowerCase();
115
+ for (const call of scanCommandHeads(command, shell ?? 'pwsh').calls) {
116
+ const runner = name(call.head);
117
+ if (!(runner in RUNNERS))
118
+ continue;
119
+ let args = call.args.map((a) => a.literal);
120
+ const words = RUNNERS[runner];
121
+ if (words) {
122
+ if (!words.has((args[0] ?? '').toLowerCase()))
123
+ continue;
124
+ args = args.slice(1);
125
+ }
126
+ for (let i = 0; i < args.length; i++) {
127
+ const a = args[i];
128
+ if (a === '--')
129
+ continue;
130
+ if (a.startsWith('-')) {
131
+ if (/^(?:-p|--package)$/.test(a))
132
+ out.push(name(args[++i] ?? ''));
133
+ continue;
134
+ }
135
+ out.push(name(a));
136
+ break;
137
+ }
138
+ }
139
+ for (const target of startProcessTargets(command))
140
+ out.push(name(target));
141
+ return out.filter(Boolean);
142
+ }
@@ -5,9 +5,12 @@ import { inlineCodeRefusal, programRefusal } from './programs.js';
5
5
  import { unattendedIsolationRefusal } from './isolation.js';
6
6
  import { confinementRefusal } from './confinement.js';
7
7
  import { botSelfRefusal, networkFetchReason, networkFetchRefusal } from './network.js';
8
- import { ownScriptRefusal, scriptFileRefusal } from './scriptFiles.js';
8
+ import { ownScriptRefusal, scratchScriptRefusal, scriptFileRefusal } from './scriptFiles.js';
9
+ import { existsSync, readdirSync } from 'node:fs';
10
+ import { dirname, join } from 'node:path';
9
11
  import { readOnlyRefusal, readOnlyUnaskedRefusal, readOnlyUnclearRefusal, readOnlyVerdict } from './readOnly.js';
10
12
  import { platformReason } from './platforms.js';
13
+ import { scanCommandHeads } from './commandHeads.js';
11
14
  export function describeStep(step) {
12
15
  // The shell it will really be read by, not the one this file used to assume: a line in the
13
16
  // log that names an interpreter the machine has not got explains the wrong failure.
@@ -28,6 +31,51 @@ export function matchDenyPattern(text, patterns) {
28
31
  }
29
32
  return null;
30
33
  }
34
+ /** `git config`'s switches that read, and the ones that take the next word as their value. */
35
+ const GIT_CONFIG_READS = /^(?:--get|--get-all|--get-regexp|--get-urlmatch|--get-color|--get-colorbool|--list|-l|get|list)$/;
36
+ const GIT_CONFIG_VALUE = /^(?:--type|-t|--file|-f|--blob|--default|--comment|--value)$/;
37
+ const GIT_CONFIG_WRITES = /^(?:set|unset|edit|rename-section|remove-section|-e|--edit|--add|--unset|--unset-all|--replace-all|--rename-section|--remove-section)$/;
38
+ /** Whether a line runs `git config` in any form that is not plainly a read: one key looked up, or a listing. */
39
+ function gitConfigWrites(command) {
40
+ for (const call of scanCommandHeads(command, 'pwsh').calls) {
41
+ if (call.head.replace(/^.*[\\/]/, '').replace(/\.exe$/i, '').toLowerCase() !== 'git')
42
+ continue;
43
+ const args = call.args;
44
+ let i = 0;
45
+ // git's own options before the subcommand: `-C dir`, `-c k=v`, `--git-dir x`, `--no-pager`.
46
+ while (i < args.length && args[i].literal.startsWith('-'))
47
+ i += /^(?:-C|-c|--git-dir|--work-tree|--namespace|--exec-path|--config-env)$/.test(args[i].literal) ? 2 : 1;
48
+ if (args[i]?.literal.toLowerCase() !== 'config')
49
+ continue;
50
+ const rest = args.slice(i + 1);
51
+ if (rest.some((a) => a.dynamic))
52
+ return true;
53
+ let reads = false;
54
+ const words = [];
55
+ for (let k = 0; k < rest.length; k++) {
56
+ const w = rest[k].literal;
57
+ const flag = w.includes('=') && w.startsWith('-') ? w.slice(0, w.indexOf('=')) : w;
58
+ if (GIT_CONFIG_WRITES.test(flag))
59
+ return true;
60
+ if (GIT_CONFIG_READS.test(flag)) {
61
+ reads = true;
62
+ continue;
63
+ }
64
+ if (flag.startsWith('-')) {
65
+ if (!w.includes('=') && GIT_CONFIG_VALUE.test(flag))
66
+ k++;
67
+ continue;
68
+ }
69
+ words.push(w);
70
+ }
71
+ // `git config user.name` looks one key up; with a value after it, it sets one.
72
+ if (!reads && words.length !== 1)
73
+ return true;
74
+ if (reads && words.length > 2)
75
+ return true;
76
+ }
77
+ return false;
78
+ }
31
79
  /**
32
80
  * A step that reaches into the repository's own machinery: a path inside `.git`, or a git setting
33
81
  * written to stay. Built in, like `dangerous.ts`, because the operator's deny list is editable and
@@ -42,8 +90,20 @@ export function matchDenyPattern(text, patterns) {
42
90
  * contract already tells the chat to use git commands, never the folder.
43
91
  */
44
92
  export function repositoryInternalsRefusal(command) {
45
- const intoGitDir = /(^|[\s'"=(\\/,;])\.git[\\/]/i.test(command);
46
- const setting = /\bgit\s+(?:-C\s+\S+\s+)?config\s+(?:(?:--(?:local|global|system|worktree)|--file\s+\S+)\s+)?(?:(?:set|unset)\s+)?[A-Za-z][\w.-]*\s+[^\s|;-]/i.test(command);
93
+ /*
94
+ * A path inside `.git`, and since the audit of 2026-10-27 the folder itself in a line that goes into it or writes:
95
+ * `Set-Location .git; Add-Content config …` and `Add-Content (Join-Path .git config) …` reached the config with no
96
+ * `.git\` in the line. A line that only names it (`Where-Object Name -ne '.git'`) is left alone.
97
+ */
98
+ const intoGitDir = /(^|[\s'"=(\\/,;])\.git[\\/]/i.test(command) ||
99
+ (/(^|[\s'"=(\\/,;])\.git(?=$|[\s'"),;|])/i.test(command) &&
100
+ /\b(Set-Location|sl|cd|chdir|pushd|Push-Location|Join-Path|Set-Content|Add-Content|Out-File|New-Item|Copy-Item|Move-Item|Remove-Item|Rename-Item|Tee-Object|sc|ac|ni|cp|copy|mv|move|rm|del|ren)\b|>/i.test(command));
101
+ /*
102
+ * A git setting written: every `git config` that is not plainly a read (audit, 2026-10-27). The form that wanted a
103
+ * bare key and a value let `git config "filter.x.clean" "node fmt.js"`, `--type=bool`, `-z`, `git.exe config` and
104
+ * the scopes past, and the runner's own git then ran the filter. `--config-env` sets a key for one command, as -c does.
105
+ */
106
+ const setting = gitConfigWrites(command) || /\bgit(?:\.exe)?\b[^|;\n]*\s--config-env\b/i.test(command);
47
107
  // `git -c key=value <command>` sets the key for that one command — and some keys name a program
48
108
  // git then starts (hooks, fsmonitor, the pager, the editor, credential helpers, filters, diff and
49
109
  // merge drivers, aliases), which the allowlist never sees. Those keys are refused inline as well.
@@ -138,6 +198,17 @@ export function checkCommandRefusal(command, shell, cfg, confinement, env = proc
138
198
  const network = networkFetchReason(command, confinement.cwd) ?? scriptNetworkReason(command, confinement.cwd);
139
199
  return network ? networkFetchRefusal(network) : null;
140
200
  }
201
+ /**
202
+ * The gate for a check the reviewer wrote (audit, 2026-10-27): a check's gate, and the rules for the chat's own steps
203
+ * in a run nobody watches, since such a check is kept and run at every later gate with no one asked — no allowed
204
+ * interpreter evaluating a string, no shell inside a shell, and only the scripts the operator's boxes let run. Refused,
205
+ * the finding stands without its check, as for any check the runner will not run.
206
+ */
207
+ export function modelCheckRefusal(command, shell, cfg, confinement, env = process.env) {
208
+ return (checkCommandRefusal(command, shell, cfg, confinement, env) ??
209
+ inlineCodeRefusal(command) ??
210
+ ownScriptRefusal(command, confinement.cwd, confinement.workStartedAt, shell, { rules: cfg.scripts, reviewer: true, screen: writtenScriptScreen(cfg, confinement, env) }));
211
+ }
141
212
  /**
142
213
  * A check reaching a platform with the operator's access, which a step puts to the operator every time (2026-10-26):
143
214
  * a check has nobody to put it to, so it is refused unless Settings agree with what the bot proposes. A program set to
@@ -147,11 +218,44 @@ export function checkAccessRefusal(command, shell, cfg) {
147
218
  const reading = readOnlyVerdict(command, shell, cfg.readOnlyPrograms);
148
219
  if (reading?.kind === 'unclear')
149
220
  return readOnlyUnclearRefusal(reading.program, reading.why);
150
- const platform = cfg.questions === 'agree' ? null : platformReason(command, shell, reading?.kind === 'reads' ? new Set(reading.programs) : undefined);
221
+ const platform = cfg.questions === 'agree' ? null : platformReason(command, shell, notHeldFor(cfg, reading?.kind === 'reads' ? reading.programs : []));
151
222
  if (!platform)
152
223
  return null;
153
224
  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
225
  }
226
+ /**
227
+ * The gate a script the bot wrote is read through when the operator's box lets it run (2026-10-27): its text, as a
228
+ * line of its own. A `.ps1` is read by `scriptFileRefusal` in every case; a `.cmd` or `.bat` and a script of package.json
229
+ * (which npm hands to cmd) by the whole gate for cmd; a bash script by the rules that read text — refused techniques,
230
+ * the bot's own things, the repository's machinery, the deny list, the project's folders — since what it starts are
231
+ * bash's tools, not Windows programs. A script of package.json may start what the project installed
232
+ * (`node_modules/.bin`). A file of code (`.ts`, `.js`, `.py`) is code, and is not read.
233
+ */
234
+ export function writtenScriptScreen(cfg, confinement, env = process.env) {
235
+ return (run, text) => {
236
+ if (run.kind === 'cmd')
237
+ return commandRefusal(text, 'cmd', cfg.denyPatterns, cfg.allowedPrograms, env, confinement, cfg.readOnlyPrograms ?? []);
238
+ if (run.kind === 'npm') {
239
+ const bin = join(dirname(run.file), 'node_modules', '.bin');
240
+ const installed = existsSync(bin) ? readdirSync(bin).map((n) => n.replace(/\.(?:cmd|ps1|exe)$/i, '')) : [];
241
+ const allowed = cfg.allowedPrograms.length ? [...cfg.allowedPrograms, ...installed] : [];
242
+ return commandRefusal(text, 'cmd', cfg.denyPatterns, allowed, env, confinement, cfg.readOnlyPrograms ?? []);
243
+ }
244
+ if (run.kind === 'sh') {
245
+ const deny = matchDenyPattern(text, cfg.denyPatterns);
246
+ return dangerousRefusal(text) ?? botSelfRefusal(text) ?? repositoryInternalsRefusal(text) ?? (deny ? `refused: matches deny pattern /${deny}/` : null) ?? confinementRefusal(text, confinement);
247
+ }
248
+ return null;
249
+ };
250
+ }
251
+ /**
252
+ * The programs whose platform a command is not held for: those set to run without asking (2026-10-28), and those set to
253
+ * read only whose every command on the line only reads.
254
+ */
255
+ export function notHeldFor(cfg, reading) {
256
+ const all = [...(cfg.runWithoutAsking ?? []), ...reading].map((p) => p.trim().toLowerCase().replace(/\.(?:exe|cmd)$/, '')).filter(Boolean);
257
+ return all.length ? new Set(all) : undefined;
258
+ }
155
259
  /** A fetch inside a script the line runs — held or refused exactly as one on the line would be. */
156
260
  export function scriptNetworkReason(command, cwd) {
157
261
  let found = null;
@@ -199,14 +303,25 @@ export function unattendedPrecondition(cfg) {
199
303
  * Applies the automatic rules. Returns null when the step is acceptable so far, or a
200
304
  * decision when it is refused without asking anyone.
201
305
  */
202
- export function staticCheck(step, cfg, env = process.env, confinement) {
306
+ export function staticCheck(step, cfg, env = process.env, confinement,
307
+ /** Whose step: the reviewer is told to check another way, since a review hands nothing over. */
308
+ actor) {
203
309
  /*
204
- * Only the project's own scripts, and nothing from .cop-tmp (operator, 2026-10-21): a script the chat wrote is not
205
- * run, however it is called. First, so the chat is told that, and not the older advice of the shared gate to write
206
- * a script in one step and run it in the next. See `scriptFiles.ts`.
310
+ * The project's own scripts, and the bot's only where the operator's box lets them (2026-10-21, boxes 2026-10-27): a
311
+ * script the chat wrote is otherwise not run, however it is called, and one it is let run is read first. First, so
312
+ * the chat is told that, and not the older advice of the shared gate to write a script in one step and run it in the
313
+ * next. See `scriptFiles.ts`.
207
314
  */
208
315
  if (confinement) {
209
- const own = ownScriptRefusal(step.cmd, confinement.cwd, confinement.workStartedAt, effectiveShell(step.shell));
316
+ // No script written only to be run (operator, 2026-10-28): one written into .cop-tmp is refused at the writing.
317
+ const scratch = scratchScriptRefusal(step.cmd, actor === 'review');
318
+ if (scratch)
319
+ return { action: 'skip', reason: scratch };
320
+ const own = ownScriptRefusal(step.cmd, confinement.cwd, confinement.workStartedAt, effectiveShell(step.shell), {
321
+ rules: cfg.scripts,
322
+ reviewer: actor === 'review',
323
+ screen: writtenScriptScreen(cfg, confinement, env),
324
+ });
210
325
  if (own)
211
326
  return { action: 'skip', reason: own };
212
327
  }
@@ -20,6 +20,7 @@
20
20
  * says plainly that isolation is not determined here. A manifest that overstated its own evidence
21
21
  * would be worse than none, because somebody would rely on it.
22
22
  */
23
+ import { DEFAULT_SCRIPT_RULES, SCRIPT_KINDS } from './scriptKinds.js';
23
24
  import { createHash } from 'node:crypto';
24
25
  import { DANGEROUS_TECHNIQUES } from './dangerous.js';
25
26
  import { describeIsolation } from './isolation.js';
@@ -53,6 +54,16 @@ function readOnlyInForce(readOnly, allowed) {
53
54
  const listed = new Set(allowed.map((p) => p.trim().toLowerCase()));
54
55
  return [...new Set(readOnly.map((p) => p.trim().toLowerCase()))].filter((p) => capable.has(p) && (listed.size === 0 || listed.has(p)));
55
56
  }
57
+ /** What the scripts' boxes allowed in this run, in one line: the record says it, rather than implying it. */
58
+ function scriptsStatement(rules, written, mode) {
59
+ const mine = SCRIPT_KINDS.filter((k) => rules[k].written);
60
+ const notOwn = SCRIPT_KINDS.filter((k) => !rules[k].own);
61
+ const own = notOwn.length ? `the project's ran except ${notOwn.join(', ')}` : "the project's ran";
62
+ if (mine.length === 0)
63
+ return `${own}; none the bot wrote (each handed to the operator)`;
64
+ const how = mode === 'unattended' && written === 'run' ? 'without asking' : 'after the operator saw each';
65
+ return `${own}; the bot's own of ${mine.join(', ')} ran ${how}; the others it wrote were handed to the operator`;
66
+ }
56
67
  export function collectPolicyManifest(input, env = process.env) {
57
68
  const names = DANGEROUS_TECHNIQUES.map((t) => t.name);
58
69
  return {
@@ -67,6 +78,8 @@ export function collectPolicyManifest(input, env = process.env) {
67
78
  programs: [...input.allowedPrograms],
68
79
  },
69
80
  readOnly: readOnlyInForce(input.readOnlyPrograms ?? [], input.allowedPrograms),
81
+ scripts: scriptsStatement(input.scripts ?? DEFAULT_SCRIPT_RULES, input.writtenScripts ?? 'ask', input.mode),
82
+ runWithoutAsking: [...(input.runWithoutAsking ?? [])],
70
83
  chatFiles: 'the chat cannot supply a file: this runner has no file step and executes nothing it did not receive as a command',
71
84
  networkFetch: networkFetchStatement(input.mode, input.networkFetch),
72
85
  denyPatterns: { count: input.denyPatterns.length, digest: digestOf(input.denyPatterns) },
@@ -88,6 +101,8 @@ export function describePolicyManifest(m) {
88
101
  `mode : ${m.mode}${m.mode === 'unattended' ? ' (no person saw the steps as they ran)' : ' (a person approved each step)'}`,
89
102
  `allowlist : ${m.allowlist.enforced ? `${m.allowlist.count} programs, digest ${m.allowlist.digest}` : 'NOT ENFORCED — any program could be started'}`,
90
103
  `read only : ${m.readOnly.length ? `${m.readOnly.join(', ')} — a command that changes something, signs in or out or shows a secret is refused` : 'none'}`,
104
+ `scripts : ${m.scripts}`,
105
+ `no card for : ${m.runWithoutAsking.length ? `${m.runWithoutAsking.join(', ')} — reaching a platform with the operator's access, run without asking, changes included` : 'none — every platform command was put to the operator'}`,
91
106
  `chat files : ${m.chatFiles}`,
92
107
  `downloads : ${m.networkFetch}`,
93
108
  `deny list : ${m.denyPatterns.count} patterns, digest ${m.denyPatterns.digest}`,
@@ -144,12 +144,17 @@ export async function processTable(since) {
144
144
  }))
145
145
  .filter((p) => p.pid !== process.pid);
146
146
  }
147
- /** The ports these processes are listening on — asked about them only, not the whole machine. */
147
+ /**
148
+ * The ports these processes are listening on — asked about them only, not the whole machine. A socket with no other end
149
+ * (remote port 0) counts as well as one in the Listen state: seen on 2026-10-29, Windows on this machine reported a
150
+ * server's listening socket, which answered requests, as "Closed", and `-State Listen` found nothing.
151
+ */
148
152
  async function listenersOf(pids) {
149
153
  if (pids.length === 0)
150
154
  return [];
151
- const text = await powershell(`Get-NetTCPConnection -State Listen -OwningProcess ${pids.map((p) => Math.trunc(p)).join(',')} -ErrorAction SilentlyContinue | ` +
152
- 'Select-Object LocalPort, OwningProcess | ConvertTo-Json -Compress');
155
+ const text = await powershell(`Get-NetTCPConnection -OwningProcess ${pids.map((p) => Math.trunc(p)).join(',')} -ErrorAction SilentlyContinue | ` +
156
+ "Where-Object { $_.State -eq 'Listen' -or $_.RemotePort -eq 0 } | " +
157
+ 'Select-Object LocalPort, OwningProcess -Unique | ConvertTo-Json -Compress');
153
158
  return parseJsonList(text).map((l) => ({ port: l.LocalPort, pid: l.OwningProcess }));
154
159
  }
155
160
  /**
@@ -140,7 +140,12 @@ const INLINE_CODE = [
140
140
  { what: 'ruby -e', pattern: /\bruby(\.exe)?\s+(-\S+\s+)*?-e\b/i },
141
141
  { what: 'php -r', pattern: /\bphp(\.exe)?\s+(-\S+\s+)*?-r\b/i },
142
142
  { what: 'a nested PowerShell', pattern: /\b(pwsh|powershell)(\.exe)?\s+(-\S+\s+)*?-c(ommand)?\b/i },
143
- { what: 'a nested cmd', pattern: /\bcmd(\.exe)?\s+(\/\S+\s+)*?\/c\b/i },
143
+ /*
144
+ * A nested cmd — but not one given a script file and nothing else (2026-10-27): `cmd /c tools\build.cmd` is how a
145
+ * `.cmd` or `.bat` is run, as `pwsh -File` runs a `.ps1`, and the file is read by the script rules
146
+ * (`scriptFiles.ts`) where no line is; `cmd /c "a & b"` and `cmd /c x.bat & calc` are still code the list cannot see.
147
+ */
148
+ { what: 'a nested cmd', pattern: /\bcmd(\.exe)?\s+(\/\S+\s+)*?\/c\b(?!\s+["']?[^\s"'&|<>^]+\.(?:cmd|bat)["']?(?:[ \t]+[^&|<>^\n;'"]*)?\s*(?:$|[;\n]))/i },
144
149
  ];
145
150
  /** Shells whose start through `Start-Process` is a nested shell however the arguments are spelled. */
146
151
  const SHELLS = new Set(['pwsh', 'powershell', 'cmd', 'wsl', 'bash', 'sh']);
@@ -24,6 +24,14 @@ const SHAPES = [
24
24
  },
25
25
  { name: 'JWT', pattern: /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g, replace: '[REDACTED JWT]' },
26
26
  { name: 'bearer token', pattern: /\b(bearer)\s+[A-Za-z0-9\-._~+/]{16,}=*/gi, replace: '$1 [REDACTED]' },
27
+ // An HTTP header with credentials in it, as git's and curl's traces print them (audit, 2026-10-27).
28
+ {
29
+ name: 'authorization header',
30
+ pattern: /\b((?:proxy-)?authorization:\s*)(basic|digest|ntlm|negotiate|token|sharedkey)\s+[A-Za-z0-9+/=._~:,"-]{8,}/gi,
31
+ replace: '$1$2 [REDACTED]',
32
+ },
33
+ { name: 'cookie header', pattern: /^([ \t>]*(?:set-)?cookie:[ \t]*)\S.*$/gim, replace: '$1[REDACTED]' },
34
+ { name: 'Stripe key', pattern: /\b(?:sk|rk|pk)_(?:live|test)_[A-Za-z0-9]{16,}\b/g, replace: '[REDACTED STRIPE KEY]' },
27
35
  { name: 'AWS access key', pattern: /\b(AKIA|ASIA)[0-9A-Z]{16}\b/g, replace: '[REDACTED AWS KEY]' },
28
36
  { name: 'GitHub token', pattern: /\b(?:gh[pousr]_[A-Za-z0-9]{20,}|github_pat_[A-Za-z0-9_]{20,})\b/g, replace: '[REDACTED GITHUB TOKEN]' },
29
37
  { name: 'Slack token', pattern: /\bxox[abprs]-[A-Za-z0-9-]{10,}\b/g, replace: '[REDACTED SLACK TOKEN]' },
@@ -38,9 +46,16 @@ const SHAPES = [
38
46
  name: 'secret in an environment listing',
39
47
  // `Get-ChildItem env:` and `set` print NAME and value in columns, with no `=` or `:` between —
40
48
  // the one shape the assignment rule below cannot see.
41
- pattern: /^([ \t]*[A-Za-z0-9_]*(?:PASSWORD|PASSWD|SECRET|TOKEN|API_?KEY|ACCESS_?KEY|PRIVATE_?KEY|CONN\w*STRING)[A-Za-z0-9_]*)([ \t]{2,})(\S.*)$/gim,
49
+ pattern: /^([ \t]*[A-Za-z0-9_]*(?:PASSWORD|PASSWD|_PASS|SECRET|TOKEN|CREDENTIAL|API_?KEY|ACCESS_?KEY|PRIVATE_?KEY|[A-Z0-9]_KEY|CONN\w*STRING)[A-Za-z0-9_]*)([ \t]{2,})(\S.*)$/gim,
42
50
  replace: '$1$2[REDACTED]',
43
51
  },
52
+ {
53
+ name: 'secret assignment (quoted)',
54
+ // A quoted value is the secret up to its closing quote, spaces and all (audit, 2026-10-27:
55
+ // `"password": "correct horse battery staple"` kept everything after its first word).
56
+ pattern: /\b([A-Za-z0-9_]*?(?:password|passwd|pwd|pass(?=["']?\s*[=:])|secret|credential|api[_-]?key|access[_-]?key|client[_-]?secret|auth[_-]?token|access[_-]?token|refresh[_-]?token|private[_-]?key|token|[A-Za-z0-9]_key)[A-Za-z0-9_]*)(["']?\s*[=:]\s*)(["'])([^"'\r\n]{6,})\3/gi,
57
+ replace: (_m, name, sep, quote, value) => NOT_A_VALUE.has(value.trim().toLowerCase()) || value.startsWith('[REDACTED') ? _m : `${name}${sep}${quote}[REDACTED]${quote}`,
58
+ },
44
59
  {
45
60
  name: 'secret assignment',
46
61
  // `password=...`, `api_key: ...`, `"client_secret": "..."` — the name is kept, the value goes.
@@ -51,7 +66,7 @@ const SHAPES = [
51
66
  // `AWS_SECRET_ACCESS_KEY` — which is how environments and config files spell them; matching the
52
67
  // bare word only let every one of those through. Six characters is short enough for a real
53
68
  // password and long enough to leave `token: null` and `pwd: ok` alone.
54
- pattern: /\b([A-Za-z0-9_]*?(?:password|passwd|pwd|secret|api[_-]?key|access[_-]?key|client[_-]?secret|auth[_-]?token|access[_-]?token|refresh[_-]?token|private[_-]?key|token)[A-Za-z0-9_]*)(["']?\s*[=:]\s*)(["']?)([^\s"';,]{6,})\3/gi,
69
+ pattern: /\b([A-Za-z0-9_]*?(?:password|passwd|pwd|pass(?=["']?\s*[=:])|secret|credential|api[_-]?key|access[_-]?key|client[_-]?secret|auth[_-]?token|access[_-]?token|refresh[_-]?token|private[_-]?key|token|[A-Za-z0-9]_key)[A-Za-z0-9_]*)(["']?\s*[=:]\s*)(["']?)([^\s"';,]{6,})\3/gi,
55
70
  replace: (_m, name, sep, quote, value) => NOT_A_VALUE.has(value.toLowerCase()) || value.startsWith('[REDACTED') ? _m : `${name}${sep}${quote}[REDACTED]${quote}`,
56
71
  },
57
72
  ];