copilot-operator 0.1.92 → 0.1.94

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 (53) hide show
  1. package/README.md +640 -625
  2. package/dist/src/api/operator.controller.js +26 -0
  3. package/dist/src/api/operator.service.js +117 -25
  4. package/dist/src/exec/readOnly.js +27 -2
  5. package/dist/src/orchestrator/kerriganRunner.js +9 -2
  6. package/dist/src/orchestrator/taskRunner.js +14 -3
  7. package/dist/src/plan/kerrigan.js +263 -243
  8. package/dist/src/plan/systemGuide.js +125 -85
  9. package/dist/src/session/chatbotFile.js +117 -0
  10. package/dist/src/session/compose.js +13 -0
  11. package/dist/src/session/locatorFailures.js +8 -5
  12. package/dist/src/transport/copilotTransport.js +94 -12
  13. package/dist/src/transport/locators.js +53 -0
  14. package/dist/src/transport/pageHtml.js +36 -2
  15. package/dist/src/vcs/newBranch.js +46 -0
  16. package/dist/web/404.html +2 -2
  17. package/dist/web/_next/static/chunks/1077.b7df9cb8ca810075.js +1 -0
  18. package/dist/web/_next/static/chunks/1548.417c17b63c371f00.js +1 -0
  19. package/dist/web/_next/static/chunks/2163.469367b8fbcc862d.js +1 -0
  20. package/dist/web/_next/static/chunks/714.72112704f3cb8127.js +1 -0
  21. package/dist/web/_next/static/chunks/{7220.260579c8dbfa2c30.js → 7220.8bd897c7ddfee701.js} +1 -1
  22. package/dist/web/_next/static/chunks/7921-25d1755799107ea7.js +1 -0
  23. package/dist/web/_next/static/chunks/8584.f87df7324303ab75.js +1 -0
  24. package/dist/web/_next/static/chunks/9067.67a7c7cf3b019b5c.js +1 -0
  25. package/dist/web/_next/static/chunks/9747.a87dbd4acd45e39d.js +1 -0
  26. package/dist/web/_next/static/chunks/app/layout-1b7d13f7b2efd008.js +1 -0
  27. package/dist/web/_next/static/chunks/app/{page-b71841852e6b9ff5.js → page-7eae1e8848525e1d.js} +1 -1
  28. package/dist/web/_next/static/chunks/app/settings/page-c92548f9c6318962.js +1 -0
  29. package/dist/web/_next/static/chunks/{webpack-abd1f09115b96456.js → webpack-91b2de9c3da6f8b9.js} +1 -1
  30. package/dist/web/_next/static/css/{6b92f118889ca88b.css → 523d11041085f836.css} +1 -1
  31. package/dist/web/defaults.html +2 -2
  32. package/dist/web/defaults.txt +8 -8
  33. package/dist/web/index.html +3 -3
  34. package/dist/web/index.txt +9 -9
  35. package/dist/web/queue.html +2 -2
  36. package/dist/web/queue.txt +9 -9
  37. package/dist/web/settings.html +2 -2
  38. package/dist/web/settings.txt +9 -9
  39. package/dist/web/system.html +2 -2
  40. package/dist/web/system.txt +9 -9
  41. package/package.json +2 -1
  42. package/dist/web/_next/static/chunks/1077.922b5f1492f6e0dd.js +0 -1
  43. package/dist/web/_next/static/chunks/1548.4a09f12e23d369ec.js +0 -1
  44. package/dist/web/_next/static/chunks/2163.14e7879a45ae9748.js +0 -1
  45. package/dist/web/_next/static/chunks/714.2daeede6dd07ee60.js +0 -1
  46. package/dist/web/_next/static/chunks/7921-1de1f08d23145c0d.js +0 -1
  47. package/dist/web/_next/static/chunks/8584.01e3a7f9f14f0b4f.js +0 -1
  48. package/dist/web/_next/static/chunks/9067.75d4fdcf47f62fd1.js +0 -1
  49. package/dist/web/_next/static/chunks/9747.f1bdfbefaba61f8b.js +0 -1
  50. package/dist/web/_next/static/chunks/app/layout-f5681fae8247797b.js +0 -1
  51. package/dist/web/_next/static/chunks/app/settings/page-7d343eecdd9c7500.js +0 -1
  52. /package/dist/web/_next/static/{n7rfXOWgaCFmATod4Q6hp → UNygvDtRnBVZrGJt53IE4}/_buildManifest.js +0 -0
  53. /package/dist/web/_next/static/{n7rfXOWgaCFmATod4Q6hp → UNygvDtRnBVZrGJt53IE4}/_ssgManifest.js +0 -0
package/README.md CHANGED
@@ -1,625 +1,640 @@
1
- <p align="center">
2
- <picture>
3
- <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/ivan-markov-666/copilot-operator/main/docs/brand/logo-dark.svg">
4
- <img src="https://raw.githubusercontent.com/ivan-markov-666/copilot-operator/main/docs/brand/logo-light.svg" alt="copilot-operator" width="240">
5
- </picture>
6
- </p>
7
-
8
- # copilot-operator
9
-
10
- A Windows bot that runs a task loop with Microsoft 365 Copilot.
11
-
12
- Copilot decides what to do, the bot does it and reports back, and the two keep going until
13
- Copilot says the task is finished. The bot drives the real Copilot web app in a real Edge
14
- browser, so it needs no API licence and no admin consent.
15
-
16
- > **Status: working, every part verified against a live Microsoft 365 Copilot tenant.**
17
- > The loop, chat naming, reply parsing, command execution and the results file are confirmed.
18
- > A step printing for 92 s survived while a silent one was stopped at its idle limit. Unattended
19
- > mode is the one thing still untried, deliberately.
20
-
21
- ## What it does
22
-
23
- 1. Opens a conversation and sends **level 1**, the base prompt about how the runner works: phases, json
24
- format, stop word, the final summary, the rules nothing else can override.
25
- 2. Sends **level 2**, the user's instructions for the project and the team, together with
26
- the **task**.
27
- 3. Reads Copilot's reply and parses a strict JSON block out of it. A reply that does not
28
- match is sent back with the reason.
29
- 4. Runs the commands in PowerShell or `cmd`, in order, capturing stdout, stderr and exit codes.
30
- Commands are the only thing it runs: nothing the chat attaches is fetched, saved or executed.
31
- 5. Writes the whole terminal output to a `.txt` file and attaches it to the chat.
32
- 6. Repeats until Copilot finishes with a **summary** of what it did and what the result is.
33
- 7. The next message written in the chat goes on in the same conversation.
34
-
35
- The web UI is a chat beside the project folder, laid out as an IDE: each message is a task, run in
36
- that folder until Copilot says it is done. No file of the project is attached to the chat: it reads
37
- the project by running commands in the project folder, like any other step. There is also a terminal
38
- command for a single task.
39
-
40
- ## Safety
41
-
42
- The bot executes commands written by a language model — commands only; it has no way to take a
43
- file from the chat. Confirm mode is on by default: every step is shown and waits for a keypress.
44
- Unattended mode is behind an explicit flag and its own preconditions. There is a deny list, a
45
- per-step timeout and an iteration cap. Everything a step prints goes to the chat as a file, so
46
- secret-shaped strings — tokens, keys, passwords in assignments and URLs, private key blocks —
47
- are redacted from every report before it is uploaded, always, with `report.redactPatterns`
48
- applied on top. Running it in a dedicated Windows account or Windows Sandbox is recommended.
49
-
50
- **Where the reports go.** Every report — the terminal output of every step, the check results,
51
- the reviewer's transcripts — are uploaded into the
52
- Copilot chat, which stores them in the signed-in account's OneDrive for Business and in the
53
- Copilot conversation history. They stay inside the company's own Microsoft 365 tenant, under its
54
- Purview DLP policies, sensitivity labels, retention and eDiscovery; nothing goes to any other
55
- service. A company deploying this should tell its data-protection and DLP teams so, and set
56
- `runsRetentionDays` so the local copies under `runs/` follow the same retention rule. The run
57
- log says it at the start of every run.
58
-
59
- ### What it will not run
60
-
61
- Some things are refused whatever the task or the configuration says, because a security team
62
- watching the machine cannot tell this tool's use of them from an attacker's, and would be right
63
- not to try. The list lives in `src/exec/dangerous.ts`, is not part of the configuration schema,
64
- and cannot be edited away; `execution.denyPatterns` is the operator's own list and is applied on
65
- top of it — it can add, never subtract.
66
-
67
- | Refused | The ordinary way instead |
68
- |---|---|
69
- | `certutil`, `bitsadmin` | read or convert files with PowerShell in a step of their own |
70
- | `wscript`, `cscript`, `mshta` | run the tool itself; never `.js`, `.vbs` or `.hta` as code |
71
- | `regsvr32`, `rundll32`, `installutil`, `forfiles` | call the program directly |
72
- | `-EncodedCommand`, base64 decoded into code, `Invoke-Expression` | write the command out in full |
73
- | fetching code and running it in one line (`iwr … \| iex`) | write the commands as steps |
74
- | running anything out of `%TEMP%` | work inside the project folder |
75
- | antivirus exclusions, scheduled tasks, Run keys, new services | nothing here should outlive the run |
76
- | opening a file or URL through its registered handler (`Invoke-Item`, `Start-Process` on a document) | start the program by name |
77
- | writing under `.git\`, or `git config <key> <value>` | the runner owns the repository; read history with git |
78
- | reaching the runner itself (its ports, its data folder, its key) | nothing: the bot is not part of the task |
79
-
80
- Every step is a command and every command is read in full before it runs, so there is nowhere for
81
- any of this to arrive unread. A name hidden rather than written — a caret or empty quotes inside a
82
- word, a name assembled from pieces, one resolved by wildcard — is refused as the hiding it is. A
83
- script a step runs with `pwsh -File` is read from disk at the gate and held to the same rules; a
84
- step that writes a script and runs it in the same line is refused, so that the file read is the
85
- file run. What `Start-Process` is asked to start is judged like any other program on the line.
86
-
87
- **Nothing is downloaded on the bot's own account.** A step that fetches from the internet —
88
- `Invoke-WebRequest`, `Invoke-RestMethod`, `curl`, `wget`, `Start-BitsTransfer`, the .NET web
89
- clients, `ftp`/`scp`, a package named by URL or git address, `npx` of a tool not installed in the
90
- project, `docker pull` — is neither refused nor run: it waits on the approval screen, in every
91
- mode, unattended included, and "run the rest without asking" does not answer it. That is the
92
- default, and the one stop an unattended run still makes; `execution.networkFetch` (Settings →
93
- Execution) may instead **refuse** it back to the chat with the reason, so the run never waits, or
94
- **run** it unread on a machine where that is acceptable. The choice applies only to unattended
95
- runs, and each task's policy manifest records which was in force. A check that
96
- fetches is refused, since a check runs with nobody asked. Requests to this machine (`localhost`,
97
- `127.0.0.1`) and the project's own package managers are not held. `npm install` runs with
98
- `ignore-scripts`: a package's install script is code fetched and executed unread, and it does not
99
- run here.
100
-
101
- **A step sees a named environment, not the bot's.** Commands are given the variables Windows and
102
- the toolchains need (`src/exec/stepEnv.ts`) plus whatever `execution.passEnv` names — never the
103
- API token, never whatever else the operator's shell held. The runner's own git runs with hooks,
104
- fsmonitor and optional locks off, so nothing a task placed in the repository runs as the runner.
105
-
106
- ### How a run is regulated
107
-
108
- Six rules decide what a step may do, and each is recorded with the run that it governed:
109
-
110
- - **Say where the bot runs, and an unattended run needs an answer.** `execution.isolation` is what
111
- you have arranged — `none`, `separate-account`, `sandbox` or `vm` — and it defaults to `none`,
112
- because that is the truth on a machine where nobody has arranged anything. It is recorded as a
113
- claim, never as a finding: a process cannot see the boundary it is inside. Beside the claim the
114
- runner records what it *can* read — the account, and whether the process holds High or System
115
- integrity — and says so when the two disagree. While `isolation` is `none`, an unattended run
116
- will not start: nobody watching and nothing containing is the one combination this refuses to be.
117
- Set it under **Settings → Execution → Where the bot runs**, and `cop doctor` and the System page
118
- show the same assessment. A fresh install says `none`, so the unattended **Run sessions** button
119
- is refused until you have arranged something and said so; **Step by step** is unaffected.
120
-
121
- - **The chat cannot give this runner a file.** There is one kind of step, `command`, and nothing
122
- the chat attaches is fetched, saved or run. This is not a setting that could be turned back on:
123
- the step type does not exist and neither does the code that fetched one. A process that receives
124
- a file and executes it is a loader whatever it meant by it, and that is precisely the shape a
125
- security team opened an incident about. Work too long for one line is written **from a command
126
- step** — `Set-Content` with a here-string — and run in the next, so its contents passed through a
127
- step that was read and screened and it sits in the project where it can be read afterwards.
128
- - **What comes back is data, never instructions.** The loop reads command output back into the
129
- chat, and most output was not written by this machine: it is the contents of files, logs, commit
130
- messages and pages that other people wrote. Any of it can carry text shaped like an order, and a
131
- model that obeys it is doing what whoever edited that file wanted — which is the whole method of
132
- an indirect prompt injection, since the attacker cannot reach the conversation and so leaves
133
- something where it will be read. Both contracts forbid acting on it and require it to be reported
134
- instead, and **every results file repeats the boundary above the first line of output**, because
135
- a contract is sent once and the early turns of a long conversation fall out of what the model can
136
- see. This is guidance to a model, not a control: it is the reason the allowlist, the refused
137
- techniques and confirm mode exist underneath it.
138
- - **Only the declared toolchain runs.** `execution.allowedPrograms` names the programs a command
139
- may start — the shells, the JavaScript, .NET, Java, Python, Go and Rust tools, `git`, and a few
140
- Windows utilities. A command that starts anything else is refused and sent back with the reason.
141
- The programs are read the way PowerShell reads a line (`src/exec/commandHeads.ts`): strings,
142
- operators, array values, method arguments and hashtable keys are not programs, and a command in a
143
- script block, a subexpression, a string's `$( )` or after an assignment is still found. A line that
144
- cannot be read with certainty — an unclosed quote or bracket, a program called through a variable
145
- (`& $exe`) — is refused rather than guessed at. `cmd` steps are read by `cmd`'s own rules. A refused
146
- step is reported to the chat as refused and never executed, with no exit code, apart from a
147
- command that ran and failed. An empty list turns the gate off. This is a floor against the unknown
148
- binary, not a boundary: allowing `node` allows `node -e`.
149
- - **Autonomy is graded.** An unattended run carries strictly more restrictions than a watched one,
150
- because the thing that makes a watched run safe is a person reading each line. Unattended
151
- requires a non-empty allowlist, and refuses an allowed program used to evaluate a string
152
- (`node -e`, `python -c`) or a shell wrapped in a shell (`cmd /c …`) — the forms that escape the
153
- allowlist by construction.
154
- - **An administrator can set a floor the operator cannot lower.** A `policy.lock.json` beside the
155
- configuration may forbid unattended runs, cap the allowlist and add deny patterns. Every field
156
- only ever tightens, and the runner never writes the file. A machine without one behaves exactly
157
- as before.
158
-
159
- ### Only the project folders
160
-
161
- Every command a task runs — the implementer's steps and checks, the reviewer's steps and the checks
162
- it derives — is held to the **project folders**: the session's own folder and every project
163
- registered in Settings, so a test suite may still start the application from the repository next
164
- to it. Refused before it runs:
165
-
166
- - a path outside them — absolute, a network share, `..` that climbs out, a `cd` to the root — and
167
- anything built from the operator's profile or the system: `~`, `$HOME`, `$env:USERPROFILE`,
168
- `$env:APPDATA`, `$env:TEMP`, `%TEMP%` and the rest. **Reads as well as writes**: what a step prints
169
- goes to the chat, so reading a key outside the project is sending it there;
170
- - the registry and the other drives that are not files (`HKLM:`, `HKCU:`, `Cert:`);
171
- - managing the computer: services, the network and firewall, local users, the clock, Windows
172
- features, disks, machine-wide PowerShell modules;
173
- - installs that land outside the project — `npm -g`, `dotnet tool -g`, `cargo install`,
174
- `go install`, `pip install` into the machine's Python. The same tools installed into the project
175
- (`npm install -D`, a local tool manifest, a `.venv`) stay open.
176
-
177
- A check's own folder and the file a file check reads are held to the same folders, and a relative
178
- file path is read from the project rather than from wherever the runner was started. A check the
179
- reviewer derives that reaches outside is dropped rather than kept: the finding stands, the check
180
- does not. Every run records the folders it was confined to in its `policy.json`.
181
-
182
- **What this cannot do.** It reads what a step *says*, which is exactly the point — whatever the chat
183
- proposes that reaches outside the project is not run. It cannot see what a program does once it is
184
- running: `node build.js`, `npm run x` and a test suite can read and write anywhere the account can,
185
- and so can a path assembled from variables at run time. That confinement is the operating system's
186
- to give, and it is the real one:
187
-
188
- 1. Create a **standard** (not administrator) local Windows account for the bot, and sign it in to
189
- Copilot once with `cop login`.
190
- 2. Give it modify rights on the project folders and nothing else:
191
- `icacls "C:\Projects\my-app" /grant botuser:(OI)(CI)M`.
192
- 3. **Check what it already has.** Folders created directly under `C:\` usually let every signed-in
193
- user modify them by default, which would hand the bot every project there, not just yours to
194
- give. Look with `icacls C:\Projects` and remove the broad grant where it should not be.
195
- 4. Your own profile — `.ssh`, the browser, OneDrive — is private to you by default; confirm the bot
196
- account cannot open `C:\Users\<you>`.
197
- 5. Run the bot as that account, and set **Settings → Execution → Where the bot runs** to
198
- *A separate low-privilege Windows account*.
199
-
200
- Windows Sandbox, with only the project folders mapped in, gives the same guarantee with less to set
201
- up and nothing left behind.
202
-
203
- ### The local API is not open to everything on the machine
204
-
205
- The API binds `127.0.0.1` only, and that was once taken to mean it needed no authentication. It
206
- did. Two callers were always reachable: any page the operator has open in their ordinary browser,
207
- which can issue requests to `127.0.0.1:4000` — CORS stops it reading the reply, which is no comfort
208
- once a request has started a session — and any other process on the machine. So every request is
209
- checked three ways before it reaches a route:
210
-
211
- - the **`Host`** header must name this loopback port, which is what catches DNS rebinding — the
212
- attacker's domain made to resolve to `127.0.0.1` is same-origin to the browser but still carries
213
- its own name here;
214
- - a present **`Origin`** must be the configured UI, since only a browser sets it and a page cannot
215
- forge it;
216
- - a per-install **token**, generated on first start into `data/api-token` (git-ignored), sent as
217
- `Authorization: Bearer`, `x-cop-token`, or a `token` query parameter for the two cases that
218
- cannot carry a header — `EventSource` and a plain `<a download>`.
219
-
220
- `npm start` creates the token before either process starts and hands it to the web process only —
221
- not to the API, whose environment command steps used to inherit, so a step never sees it; a step
222
- that names the API's or the UI's port is refused. The web server binds `127.0.0.1` only. `GET /api/health` stays open so that "is it up yet" is still
223
- answerable. To rotate the token, delete the file and restart.
224
-
225
- The `data` folder — token, settings, sessions, the level-1 contract — is narrowed at start to the
226
- operator's account and SYSTEM, and the API refuses to start while any other account can open it:
227
- under `C:\Projects` a folder otherwise inherits *Authenticated Users: Modify*, which is every
228
- account on the machine. A step never sees the token (see above) and is refused for naming the API's
229
- ports or the data folder.
230
-
231
- This does not contain a process already running as the operator — nothing at this layer can, since
232
- that process can read the file. It moves the API from "anything on this machine, and several things
233
- off it" to "the operator's own account, through a browser that was handed the key".
234
-
235
- Every task writes `policy.json` into its run folder and a `POLICY` block into its log: the mode,
236
- the allowlist and its digest, that the chat cannot supply files, digests of the deny list and of the
237
- built-in refusals, whether a lock was in force and what it changed, and the account the run used.
238
- So "what was this permitted to do at the time" is answered from the run folder rather than from a
239
- configuration file that has been edited since.
240
-
241
- ### Before a company deploys it
242
-
243
- A compliance review against the common frameworks (CIS Controls v8, NIST SP 800-53, ISO/IEC
244
- 27001 Annex A, the Microsoft baselines) was run on 2026-09-27. Nothing in the software is a
245
- hidden mechanism; what follows is what a company has to decide, approve or configure before it
246
- runs this on managed laptops, because no code change can decide it for them.
247
-
248
- **Approvals to obtain.**
249
-
250
- - *Identity and licensing.* The bot drives a licensed person's Microsoft 365 Copilot through
251
- Edge, not through the API. Microsoft documents the API as the supported way to automate
252
- Copilot; driving the web client is not documented as supported, and a per-user licence is
253
- not meant to be shared or driven by a service identity. Ask the Microsoft contact whether the
254
- intended use is acceptable under the licence, and decide which person's identity signs in —
255
- one licensed identity per operator, never a shared one. Every prompt, upload and Purview
256
- record is attributed to that identity.
257
- - *Conditional Access.* The bot's Edge runs a profile of its own under
258
- `%LOCALAPPDATA%\copilot-operator`, started by `node.exe` with Playwright's debugging channel.
259
- A tenant's sign-in frequency, compliant-device and managed-browser policies may refuse it or
260
- pause it for sign-in; and an Edge policy that forbids remote debugging or forces extensions
261
- stops it outright. Test on one managed device before rolling out; where the baseline cannot
262
- be relaxed, run it in a VM or Windows Sandbox outside the baseline's scope.
263
- - *Data protection.* See "Where the reports go" above. Where the law requires it, record the
264
- processing (a DPIA where automated tooling that stores every command's output and sends it to
265
- an AI service triggers one; works-council consultation where tooling that records employees'
266
- actions requires it). Command output can carry personal data from fixtures and exports.
267
- - *AI-use policy.* Commands written by a language model execute on the endpoint. Confirm mode
268
- keeps a person on every line; unattended mode removes that person and is the decision most
269
- AI-governance policies want recorded. `policy.lock.json` can forbid it machine-wide.
270
- - *Security operations.* Tell the SOC what to expect: `node.exe` starting PowerShell (every
271
- step, as `-Command` text, which PowerShell logging records verbatim) and `taskkill`; Edge
272
- started by `node.exe` over a debugging pipe; updates pulled from a git remote. Register the
273
- install so the process chain is known rather than investigated.
274
-
275
- **Configuration to set** — as an administrator, in `%ProgramData%\copilot-operator\policy.lock.json`,
276
- which the operator cannot edit (the same file beside the install is honoured too):
277
-
278
- ```json
279
- {
280
- "maxMode": "confirm",
281
- "requireIsolation": true,
282
- "passEnv": [],
283
- "allowedPrograms": ["pwsh", "powershell", "cmd", "node", "npm", "npx", "git", "dotnet"],
284
- "update": { "requireSigned": true, "remote": "https://git.example.com/tools/copilot-operator.git" }
285
- }
286
- ```
287
-
288
- Every field only tightens; `update` makes `npm run update` insist on signed commits and refuse
289
- any other remote. Keep `data/` and `runs/` on a local disk (`COP_DATA_DIR`, `runsDir`), set
290
- `runsRetentionDays`, and fork the repository internally so updates come from a remote the
291
- company controls.
292
-
293
- **Keeping it patched.** Dependencies are pinned in `package-lock.json`; `npm audit` reports
294
- known vulnerabilities in them, and `npm run update` brings in whatever the remote has fixed.
295
- Node.js and Edge are patched by the machine's own update process. Nothing here watches for
296
- end-of-support runtimes — that is the deploying company's asset management.
297
-
298
- **Stopping it.** "Stop" on a session cuts in after the current step and ends the task
299
- `aborted`; "Pause" lets the task in flight finish and holds the queue. Ctrl+C in the `npm start`
300
- terminal stops the API and the UI; processes a step started are stopped with the task (asked
301
- first, forced after a few seconds), and the run log names any it could not. To end the bot's
302
- access: `cop logout` signs its profile out, deleting `data/api-token` and restarting rotates the
303
- API key, `cop login --fresh` deletes the profile.
304
-
305
- **Where it does not fit.** On a fleet that enforces PowerShell Constrained Language Mode the
306
- bot's own probes degrade gracefully (permissions are read through `Get-Acl`; elevation reads as
307
- unknown), but the model's steps themselves run constrained, and most builds will not. That is a
308
- fleet to run the bot outside of, in a VM, not one to request exceptions on.
309
-
310
- ### What an update trusts
311
-
312
- `npm run update` fetches commits, fast-forwards onto them, installs what the lockfile names and
313
- builds the result — and that result is the thing that runs commands on this machine. Its trust
314
- boundary is one sentence: **whoever controls the remote controls this bot.** Three things make that
315
- checkable rather than implied.
316
-
317
- - **The remote is pinned.** The address a checkout last updated from is recorded in
318
- `data/update-remote`. If `origin` now points somewhere else the update stops before anything is
319
- fetched, prints both addresses, and asks. Trust on first use — the first update records what is
320
- there. Accept a deliberate move with `npm run update -- --accept-remote`.
321
- - **Signatures, if your fork has them.** `npm run update -- --require-signed` refuses a HEAD that
322
- git cannot verify, and tells an unsigned commit apart from a bad signature. Off by default,
323
- because this project does not sign its commits and a check that always fails is a check that gets
324
- removed; it is here so an organisation whose fork *is* signed can make it mean something.
325
- - **Every update is written down.** A line in `data/update-log.jsonl`: when, from which remote,
326
- which commit to which, how many came in, and whether a signature was demanded. `data/` is
327
- git-ignored, so the record survives the pull it describes.
328
-
329
- None of this verifies what the code *does*. A signed commit from a compromised maintainer is a
330
- signed commit. It narrows "anything that can reach the network" to "whoever holds the remote this
331
- checkout was installed from", and says so out loud.
332
-
333
- **The honest limit.** Everything above except the first rule is pattern matching and configuration.
334
- It raises the cost of the ordinary accident and the ordinary injected instruction; it is not a
335
- security boundary, and a determined attacker with a language model to write for them will find a
336
- phrasing none of it anticipated. The boundary is the first rule — a separate low-privilege Windows
337
- account, Windows Sandbox or a VM — and the runner can record whether you have arranged one, refuse
338
- to run unwatched until you have, and never do it for you.
339
-
340
- ## Requirements
341
-
342
- - Windows 10 or 11
343
- - Node.js 20 or newer
344
- - Microsoft Edge, already installed
345
- - A Microsoft 365 Copilot account, signed in once by the user
346
-
347
- ## Installing it in a project
348
-
349
- ```bash
350
- npm install --save-dev copilot-operator
351
- npx cop login --account you@tenant.org # sign in once; the Edge profile is reused across projects
352
- npx cop start --open # the API and the interface, on http://127.0.0.1:4000/
353
- ```
354
-
355
- Installed this way, the bot belongs to the project it is installed in. Its records — settings,
356
- sessions, the API key, every run's logs and its Edge profile — go to the bot's own folder,
357
- `%LOCALAPPDATA%\copilot-operator`, not into the project, so the project's git never sees them and
358
- the bot's version control finds a clean tree. **System → The bot's folder → Change…** keeps them in
359
- another folder from the next start (optionally copying what is there, so the sign-in stays), and
360
- `COP_HOME` sets one from outside. A version before 0.1.56 kept them in `.copilot-operator/` in the
361
- project: the first start of a newer one copies them over once and says so; the old folder can then
362
- be deleted. The interface ships prebuilt and is served by the same process on one port; there is no
363
- second server and nothing is compiled on the machine. `npx cop start --port 4100` picks another
364
- port. `npm update copilot-operator` updates it; `npm run update` is for a clone.
365
-
366
- **Keeping it out of the project's repository.** A dev dependency is recorded in `package.json`
367
- and the lock file, which are committed. To leave the project untouched, install it globally and
368
- start it from the project's folder — the folder it is started from is the project:
369
-
370
- ```bash
371
- npm install --global copilot-operator
372
- cd C:\path\to\your-project
373
- cop start --open
374
- ```
375
-
376
- Nothing in the project changes. The bot's own code is then outside the folders its steps may write,
377
- which is the safer of the two.
378
-
379
- The bot is then inside the folders its own steps may write, so a step that reaches for
380
- `node_modules/copilot-operator`, for the bot's folder (by its path, or as `%LOCALAPPDATA%\copilot-operator`
381
- in any spelling), or that installs, updates or removes the bot as a package is refused. What no rule can see is a step that rewrites the project's
382
- `package.json` with a different version of the bot for a later `npm install` to fetch; the commit
383
- the bot makes after the task shows such a change, and it is worth a look before the next install.
384
-
385
- ## Releasing a new version
386
-
387
- Publishing is done by GitHub Actions (`.github/workflows/publish.yml`), not from a laptop:
388
-
389
- ```bash
390
- npm version patch # or minor / major: updates package.json, commits, tags vX.Y.Z
391
- git push --follow-tags # the tag starts the workflow: typecheck, checks, build, publish
392
- ```
393
-
394
- The workflow publishes with npm's Trusted Publishing — no npm token is stored anywhere; npm accepts
395
- the package because it comes from this repository's `publish.yml` — and with provenance, so the
396
- package page on npm says which commit and which run built it. Set up once, after the first manual
397
- `npm publish`: on npmjs.com, the package's **Settings → Trusted Publisher → GitHub Actions**, with
398
- repository `ivan-markov-666/copilot-operator` and workflow `publish.yml`. A tag whose version does
399
- not match `package.json` stops the workflow before anything is built.
400
-
401
- ## Working on it from a clone
402
-
403
- ```bash
404
- npm install # root and the web workspace
405
- npx tsx src/cli.ts login --account you@tenant.org # sign in once; the Edge profile is reused
406
- npx tsx src/cli.ts doctor # check the machine
407
- ```
408
-
409
- A pull, a merge or a switch of branch leaves `node_modules` as it was; when what it brought in
410
- names a package that is not installed, or another version of one, `npm start` and the package build
411
- (`npm pack`, `npm publish`) say which and stop before building anything: `npm install` again.
412
-
413
- The bot never types credentials. `login` opens Edge, waits for the chat to appear, checks
414
- that the right account is signed in, and stores nothing but the browser profile.
415
-
416
- ### The web UI
417
-
418
- ```bash
419
- npm start # builds the API, then runs it and the UI together; Ctrl+C stops both
420
- ```
421
-
422
- Then open http://localhost:3210. `npm run dev` does the same and opens the browser for you.
423
- The two can also run separately: `npm run api` (NestJS on 127.0.0.1:4000) and `npm run web`
424
- (Next.js on localhost:3210).
425
-
426
- Open a project folder, write what to change in the chat on the right, approve each command in
427
- the conversation (or let them run without asking), and read the summary when it finishes. The
428
- files of the folder are on the left, with its git; a file opens in the editor, coloured by its
429
- language, and can be edited and saved. "Plan mode" under the chat's box asks Copilot for a plan
430
- first, shown in the conversation to approve; "Review" has a conversation of its own check the work
431
- when Copilot says it is done. "Two chats" gives a complex task to a lead, which plans and directs,
432
- and a worker, which runs the commands of each subtask and reports back — two conversations in the
433
- same Copilot window, the lead asking you only what nobody else can decide. "Pause" holds the work at its next message or command and becomes
434
- "Continue". The interface speaks nine languages (English, Bulgarian, German, Spanish, French,
435
- Portuguese, Japanese, Korean, Arabic), chosen from "Language". "Kerrigan" on the home screen hands out a persona to
436
- give another chat, which then helps you write tasks for this one (optional); she knows your projects,
437
- with the level 2 you write for each in Settings. A project in Settings can be marked "For
438
- reference only": the bot reads it and runs what only reads it, and whatever a command changes there
439
- — files, branches, what is staged — is put back after that command, and the chat is told. See
440
- [`docs/ui.md`](docs/ui.md); the Sessions page, the task register and plans from JSON were removed
441
- on 2026-10-20.
442
-
443
- As in VS Code, Ctrl+P finds a file by name and Ctrl+Shift+F searches the code (match case, whole word,
444
- regular expressions, files to include or exclude); a Markdown file opens as it reads, its mermaid diagrams drawn.
445
- A file opens in the editor of VS Code itself (Monaco): find and replace, several cursors, folding, the minimap,
446
- IntelliSense for TypeScript, JavaScript, JSON, CSS and HTML. The git view shows everything the branch changed, as a
447
- pull request does, against the branch it would go into, with the files not committed yet marked.
448
- Skills keep your instructions for a kind of task that comes back — a new test, a new entity, a migration — in
449
- Settings; a message starting with `/its-name` (or with the skill chosen under the chat's box) carries them to the
450
- chat. The three panels move as in VS Code: drag the grip ⠿ in a panel's head onto another. Settings can also make
451
- the bot pause between messages to Copilot, by a fixed or a random time.
452
-
453
- **What runs, and how.** Every command the chat sends is given to PowerShell as text
454
- (`pwsh -NoProfile -NonInteractive -Command "…"`); the bot writes no script to run it. A script file
455
- — `.ps1`, `.cmd`, `.bat`, `.sh`, `.vbs` — runs only when it is the project's own: committed in its
456
- repository, unchanged since, and committed before the work began. One the chat wrote, changed or
457
- downloaded is refused however it is called, and nothing in `.cop-tmp` is run. The project's tools
458
- go on as usual — `npm test`, `npm run build`, `dotnet test`, `node` starting the application.
459
- Downloads wait for you even in an unattended run, `npm install` runs no install scripts, and the
460
- package itself has none.
461
-
462
- ### Removing it from a machine
463
-
464
- Nothing is installed system-wide, nothing runs at start-up, no service and no scheduled task
465
- exist. What the software leaves, and where:
466
-
467
- | What | Where | Remove |
468
- |---|---|---|
469
- | settings, sessions, the API token, level-1 and context texts | `data/` in the checkout | delete the folder |
470
- | every run's logs, reports and failure screenshots | `runs/` in the checkout | delete the folder (or set `runsRetentionDays`) |
471
- | backups taken by `npm run update` | `data-backups/` in the checkout | delete the folder |
472
- | the bot's own Edge profile, with its Microsoft 365 session | `%LOCALAPPDATA%\copilot-operator\edge-profile` | sign out in that window (`cop login --fresh` deletes it) and delete the folder |
473
- | installed from npm: its settings, sessions, the API token, every run's logs and its Edge profile | the bot's folder, `%LOCALAPPDATA%\copilot-operator` unless another was chosen (System shows which) | delete the folder |
474
- | installed from npm, a version before 0.1.56: the same records | `.copilot-operator\` in the project, or in the folder it was started from | delete the folder; a newer version copied what it needed |
475
- | the API key the browser was handed | the browser's storage for `localhost:3210` | clear site data for that origin |
476
- | logs saved on request by older versions | `Desktop\copilot-operator-logs` | delete them; they may already be in OneDrive, and nothing writes there any more |
477
- | the project copies of versions before 0.1.14 | `Desktop\copilot-operator-context` | delete the folder; nothing writes to it any more |
478
- | the reports uploaded to Copilot | the account's OneDrive and Copilot chat history | delete the conversations, or let the tenant's retention run |
479
- | a machine-wide policy lock, if an administrator placed one | `%ProgramData%\copilot-operator\policy.lock.json` | the administrator removes it |
480
-
481
- The permissions the API set on `data/` and `runs/` (owner and SYSTEM only) go with the folders.
482
-
483
- ### Updating a machine that has been used
484
-
485
- ```bash
486
- npm run update # back up, pull, install, build
487
- npm run update -- --check # say what would happen, change nothing
488
- ```
489
-
490
- **A pull cannot lose what you have entered.** Everything this program records lives in `data/`
491
- (settings, sessions, level 2 presets, a customised level 1, the organisation and work texts, the
492
- model list) and `runs/` (every log, report and artifact of every task). Both are in `.gitignore`,
493
- every write in `src/` goes to one of them, and git does not know they exist.
494
-
495
- What a pull *can* do is refuse to start. `npm run update` deals with each reason in turn: it
496
- copies `data/` to `data-backups/<timestamp>/` before touching anything, refuses to run while the
497
- bot is (swapping the code under a run in flight is the one thing here that could really break
498
- something), puts any local edits to tracked files into a named stash and tells you the command to
499
- get them back, pulls **fast-forward only** so no merge is ever made on your behalf, and then
500
- reinstalls and rebuilds — because a `dist/` older than its `src/` runs the previous version and
501
- reports the previous version's bugs.
502
-
503
- Run it with `--check` first if you want to see what it would do. When nothing has come in it
504
- installs and builds nothing; `--rebuild` forces both. It uses `npm ci`, and only when the pull
505
- actually moved a dependency: `npm install` may rewrite `package-lock.json`, and a rewritten
506
- lockfile is a tracked file that differs from the commit — which is one of the phantom local
507
- changes this is here to stop.
508
-
509
- **`npm warn allow-scripts ... esbuild`** on a machine whose npm requires install scripts to be
510
- approved is expected and usually harmless. esbuild gets its Windows binary from an optional
511
- dependency (`@esbuild/win32-x64`), which installs without any script; the blocked `postinstall`
512
- only revalidates it. Check with `npx tsx --version` — if that answers, `npm run check` will run.
513
- If it does not, `npm approve-scripts esbuild` and install again.
514
-
515
- If files looked modified that you never edited, that was line endings: two Windows machines, one
516
- with `core.autocrlf` set and one without. `.gitattributes` settles it.
517
-
518
- ### The terminal, for one task
519
-
520
- ```bash
521
- cp run.example.yaml run.yaml # then edit it
522
- npx tsx src/cli.ts run run.yaml
523
- ```
524
-
525
- ### Commands
526
-
527
- | Command | What it does |
528
- |---|---|
529
- | `cop login` | opens Edge with the bot profile and waits for you to sign in |
530
- | `cop doctor [run.yaml]` | checks Node, Edge, PowerShell, the bot's Edge profile, the config |
531
- | `cop run <run.yaml>` | one task as a new session; `--unattended` skips the per-step prompt |
532
- | `cop chat [run.yaml]` | prints the last run's conversation name and link |
533
-
534
- Before it is built, run them as `npx tsx src/cli.ts <command>`.
535
-
536
- **Testing it for the first time:** follow [`docs/testing.md`](docs/testing.md). Nine steps,
537
- ordered so the risk climbs slowly, starting with checks that need no account at all.
538
- `run.smoke.yaml` is a ready-made read-only first run.
539
-
540
- ## How it works
541
-
542
- | Piece | File | State |
543
- |---|---|---|
544
- | DOM locators for the Copilot web app | `src/transport/locators.ts` | captured from the live app |
545
- | Command runner, dual timeouts, process-tree kill | `src/exec/runner.ts` | implemented, checked |
546
- | Chat naming and reattach after re-login | `src/transport/chatSession.ts` | implemented, checked |
547
- | Covering message for the results file | `src/protocol/reporter.ts` | implemented, checked |
548
- | The bot's folder: default, chosen on System, moved out of the project once | `src/config/layout.ts`, `src/config/home.ts` | implemented, checked |
549
- | Pacing, send cap, backoff | `src/util/pacing.ts` | implemented, checked |
550
- | Playwright transport | `src/transport/copilotTransport.ts` | implemented; selectors verified live |
551
- | Reply parser and the JSON contract | `src/protocol/parser.ts`, `replySchema.ts` | implemented, checked |
552
- | Report file, splitting, redaction | `src/exec/reportFile.ts` | implemented, checked |
553
- | Deny list and the confirm gate | `src/exec/policy.ts` | implemented, checked |
554
- | Config schema and loader | `src/config/schema.ts` | implemented |
555
- | The loop, per task and per session | `src/orchestrator/taskRunner.ts` | run live end to end |
556
- | Sessions, tasks, level 2 presets on disk | `src/session/` | implemented, checked |
557
- | API | `src/api/` (NestJS) | implemented, exercised over HTTP |
558
- | Web UI | `web/` (Next.js) | implemented |
559
- | CLI | `src/cli.ts` | implemented |
560
-
561
- Design and findings:
562
-
563
- - [`docs/ui.md`](docs/ui.md) — the web UI, the API and the session model
564
- - [`docs/testing.md`](docs/testing.md) — how to test it the first time, step by step
565
- - [`docs/architecture.md`](docs/architecture.md) — the whole design
566
- - [`docs/locators-findings.md`](docs/locators-findings.md) — what the live Copilot DOM looks like and why
567
- - [`docs/tech-stack-research.md`](docs/tech-stack-research.md) — why Playwright and not the alternatives
568
- - [`docs/deferred.md`](docs/deferred.md) — designed, argued and deliberately not built yet, with the reasoning kept
569
-
570
- ### What Kerrigan knows
571
-
572
- Kerrigan (`src/plan/kerrigan.ts`) is the persona the home screen hands out, saved as a file or
573
- copied, for a chat of the operator's own choosing: what copilot-operator is, how a task is best
574
- written for its chat, and the names of the chat's controls, so it can say press "New chat" rather
575
- than "start over". She is optional: the bot's chat does not need her. The names live in
576
- `src/plan/systemGuide.ts`, and `test/guide.check.ts` pins every one of them to `web/lib/strings.ts`
577
- in both languages. Renaming a control in the interface therefore breaks that check by name, and a
578
- new control the operator would ever be told to press has to be added to the guide as well, or the
579
- persona does not know it exists. The same check reads the pages themselves, so a label that is
580
- still in the dictionary but that nothing renders any more fails too, and it holds the labels
581
- Kerrigan quotes in her own prose to the same standard.
582
-
583
- ## Notable findings
584
-
585
- These cost real investigation and are worth knowing before touching the code.
586
-
587
- - **Code blocks cannot be read from the DOM.** They are virtualized and interleave line
588
- numbers with the code. A valid JSON reply came back from `innerText` with a chunk missing.
589
- The message-level "Copy Response" button plus clipboard access is the only safe read.
590
- - **Downloads are plain anchors** with a `blob:` href and a `download` attribute, which is
591
- why nothing useful appears on hover. Playwright's download event handles them.
592
- - **Enter does not send.** The composer is a contenteditable span; the Send button must be
593
- clicked.
594
- - **A message cannot be only an attachment.** Text is mandatory, so the covering message is
595
- part of the protocol rather than decoration.
596
- - **Uploads go through the user's OneDrive.** The chat says so, and the attachment id carries
597
- an `SPO_` prefix. That prefix is also the most reliable "upload finished" signal.
598
- - **Copilot destroys `[name]:` in its own output.** `[math]::Round($x, 2)` reaches the
599
- runner as `:Round($x, 2)`, even inside a fenced code block, because `[label]:` is markdown
600
- for a link reference. `[pscustomobject]` and `[double]$x` survive, since the damage needs
601
- the colon. The prompts forbid that form and the runner refuses a command that arrives
602
- wrecked rather than executing something nobody wrote.
603
- - **`lastChatMessage` is not the whole answer.** It is the answer body; the copy button is
604
- its sibling. A wait built on `[data-testid="lastChatMessage"] [data-testid="CopyButtonTestId"]`
605
- never completes. The anchor is the last `copilot-message-div`.
606
-
607
- ## Checks
608
-
609
- ```bash
610
- npm run check # all of them
611
- ```
612
-
613
- Each one prints what it exercised rather than asserting silently, so a failure is readable.
614
- There is no live-tenant test: that is the part that needs a human and a signed-in browser.
615
-
616
- ## Related
617
-
618
- [context-picker](https://github.com/ivan-markov-666/context-picker) (MIT) — the same author's
619
- VS Code and Visual Studio extension for picking which project files an LLM should see. This
620
- project follows its file-naming convention, so the two produce interchangeable folders, and
621
- can drive it directly for per-file selection.
622
-
623
- ## Licence
624
-
625
- MIT. See [`LICENSE`](LICENSE).
1
+ <p align="center">
2
+ <picture>
3
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/ivan-markov-666/copilot-operator/main/docs/brand/logo-dark.svg">
4
+ <img src="https://raw.githubusercontent.com/ivan-markov-666/copilot-operator/main/docs/brand/logo-light.svg" alt="copilot-operator" width="240">
5
+ </picture>
6
+ </p>
7
+
8
+ # copilot-operator
9
+
10
+ A Windows bot that runs a task loop with Microsoft 365 Copilot.
11
+
12
+ Copilot decides what to do, the bot does it and reports back, and the two keep going until
13
+ Copilot says the task is finished. The bot drives the real Copilot web app in a real Edge
14
+ browser, so it needs no API licence and no admin consent.
15
+
16
+ > **Status: working, every part verified against a live Microsoft 365 Copilot tenant.**
17
+ > The loop, chat naming, reply parsing, command execution and the results file are confirmed.
18
+ > A step printing for 92 s survived while a silent one was stopped at its idle limit. Unattended
19
+ > mode is the one thing still untried, deliberately.
20
+
21
+ ## What it does
22
+
23
+ 1. Opens a conversation and sends **level 1**, the base prompt about how the runner works: phases, json
24
+ format, stop word, the final summary, the rules nothing else can override.
25
+ 2. Sends **level 2**, the user's instructions for the project and the team, together with
26
+ the **task**.
27
+ 3. Reads Copilot's reply and parses a strict JSON block out of it. A reply that does not
28
+ match is sent back with the reason.
29
+ 4. Runs the commands in PowerShell or `cmd`, in order, capturing stdout, stderr and exit codes.
30
+ Commands are the only thing it runs: nothing the chat attaches is fetched, saved or executed.
31
+ 5. Writes the whole terminal output to a `.txt` file and attaches it to the chat.
32
+ 6. Repeats until Copilot finishes with a **summary** of what it did and what the result is.
33
+ 7. The next message written in the chat goes on in the same conversation.
34
+
35
+ The web UI is a chat beside the project folder, laid out as an IDE: each message is a task, run in
36
+ that folder until Copilot says it is done. No file of the project is attached to the chat: it reads
37
+ the project by running commands in the project folder, like any other step. There is also a terminal
38
+ command for a single task.
39
+
40
+ ## Safety
41
+
42
+ The bot executes commands written by a language model — commands only; it has no way to take a
43
+ file from the chat. Confirm mode is on by default: every step is shown and waits for a keypress.
44
+ Unattended mode is behind an explicit flag and its own preconditions. There is a deny list, a
45
+ per-step timeout and an iteration cap. Everything a step prints goes to the chat as a file, so
46
+ secret-shaped strings — tokens, keys, passwords in assignments and URLs, private key blocks —
47
+ are redacted from every report before it is uploaded, always, with `report.redactPatterns`
48
+ applied on top. Running it in a dedicated Windows account or Windows Sandbox is recommended.
49
+
50
+ **Where the reports go.** Every report — the terminal output of every step, the check results,
51
+ the reviewer's transcripts — are uploaded into the
52
+ Copilot chat, which stores them in the signed-in account's OneDrive for Business and in the
53
+ Copilot conversation history. They stay inside the company's own Microsoft 365 tenant, under its
54
+ Purview DLP policies, sensitivity labels, retention and eDiscovery; nothing goes to any other
55
+ service. A company deploying this should tell its data-protection and DLP teams so, and set
56
+ `runsRetentionDays` so the local copies under `runs/` follow the same retention rule. The run
57
+ log says it at the start of every run.
58
+
59
+ ### What it will not run
60
+
61
+ Some things are refused whatever the task or the configuration says, because a security team
62
+ watching the machine cannot tell this tool's use of them from an attacker's, and would be right
63
+ not to try. The list lives in `src/exec/dangerous.ts`, is not part of the configuration schema,
64
+ and cannot be edited away; `execution.denyPatterns` is the operator's own list and is applied on
65
+ top of it — it can add, never subtract.
66
+
67
+ | Refused | The ordinary way instead |
68
+ |---|---|
69
+ | `certutil`, `bitsadmin` | read or convert files with PowerShell in a step of their own |
70
+ | `wscript`, `cscript`, `mshta` | run the tool itself; never `.js`, `.vbs` or `.hta` as code |
71
+ | `regsvr32`, `rundll32`, `installutil`, `forfiles` | call the program directly |
72
+ | `-EncodedCommand`, base64 decoded into code, `Invoke-Expression` | write the command out in full |
73
+ | fetching code and running it in one line (`iwr … \| iex`) | write the commands as steps |
74
+ | running anything out of `%TEMP%` | work inside the project folder |
75
+ | antivirus exclusions, scheduled tasks, Run keys, new services | nothing here should outlive the run |
76
+ | opening a file or URL through its registered handler (`Invoke-Item`, `Start-Process` on a document) | start the program by name |
77
+ | writing under `.git\`, or `git config <key> <value>` | the runner owns the repository; read history with git |
78
+ | reaching the runner itself (its ports, its data folder, its key) | nothing: the bot is not part of the task |
79
+
80
+ Every step is a command and every command is read in full before it runs, so there is nowhere for
81
+ any of this to arrive unread. A name hidden rather than written — a caret or empty quotes inside a
82
+ word, a name assembled from pieces, one resolved by wildcard — is refused as the hiding it is. A
83
+ script a step runs with `pwsh -File` is read from disk at the gate and held to the same rules; a
84
+ step that writes a script and runs it in the same line is refused, so that the file read is the
85
+ file run. What `Start-Process` is asked to start is judged like any other program on the line.
86
+
87
+ **Nothing is downloaded on the bot's own account.** A step that fetches from the internet —
88
+ `Invoke-WebRequest`, `Invoke-RestMethod`, `curl`, `wget`, `Start-BitsTransfer`, the .NET web
89
+ clients, `ftp`/`scp`, a package named by URL or git address, `npx` of a tool not installed in the
90
+ project, `docker pull` — is neither refused nor run: it waits on the approval screen, in every
91
+ mode, unattended included, and "run the rest without asking" does not answer it. That is the
92
+ default, and the one stop an unattended run still makes; `execution.networkFetch` (Settings →
93
+ Execution) may instead **refuse** it back to the chat with the reason, so the run never waits, or
94
+ **run** it unread on a machine where that is acceptable. The choice applies only to unattended
95
+ runs, and each task's policy manifest records which was in force. A check that
96
+ fetches is refused, since a check runs with nobody asked. Requests to this machine (`localhost`,
97
+ `127.0.0.1`) and the project's own package managers are not held. `npm install` runs with
98
+ `ignore-scripts`: a package's install script is code fetched and executed unread, and it does not
99
+ run here.
100
+
101
+ **A step sees a named environment, not the bot's.** Commands are given the variables Windows and
102
+ the toolchains need (`src/exec/stepEnv.ts`) plus whatever `execution.passEnv` names — never the
103
+ API token, never whatever else the operator's shell held. The runner's own git runs with hooks,
104
+ fsmonitor and optional locks off, so nothing a task placed in the repository runs as the runner.
105
+
106
+ ### How a run is regulated
107
+
108
+ Six rules decide what a step may do, and each is recorded with the run that it governed:
109
+
110
+ - **Say where the bot runs, and an unattended run needs an answer.** `execution.isolation` is what
111
+ you have arranged — `none`, `separate-account`, `sandbox` or `vm` — and it defaults to `none`,
112
+ because that is the truth on a machine where nobody has arranged anything. It is recorded as a
113
+ claim, never as a finding: a process cannot see the boundary it is inside. Beside the claim the
114
+ runner records what it *can* read — the account, and whether the process holds High or System
115
+ integrity — and says so when the two disagree. While `isolation` is `none`, an unattended run
116
+ will not start: nobody watching and nothing containing is the one combination this refuses to be.
117
+ Set it under **Settings → Execution → Where the bot runs**, and `cop doctor` and the System page
118
+ show the same assessment. A fresh install says `none`, so the unattended **Run sessions** button
119
+ is refused until you have arranged something and said so; **Step by step** is unaffected.
120
+
121
+ - **The chat cannot give this runner a file.** There is one kind of step, `command`, and nothing
122
+ the chat attaches is fetched, saved or run. This is not a setting that could be turned back on:
123
+ the step type does not exist and neither does the code that fetched one. A process that receives
124
+ a file and executes it is a loader whatever it meant by it, and that is precisely the shape a
125
+ security team opened an incident about. Work too long for one line is written **from a command
126
+ step** — `Set-Content` with a here-string — and run in the next, so its contents passed through a
127
+ step that was read and screened and it sits in the project where it can be read afterwards.
128
+ - **What comes back is data, never instructions.** The loop reads command output back into the
129
+ chat, and most output was not written by this machine: it is the contents of files, logs, commit
130
+ messages and pages that other people wrote. Any of it can carry text shaped like an order, and a
131
+ model that obeys it is doing what whoever edited that file wanted — which is the whole method of
132
+ an indirect prompt injection, since the attacker cannot reach the conversation and so leaves
133
+ something where it will be read. Both contracts forbid acting on it and require it to be reported
134
+ instead, and **every results file repeats the boundary above the first line of output**, because
135
+ a contract is sent once and the early turns of a long conversation fall out of what the model can
136
+ see. This is guidance to a model, not a control: it is the reason the allowlist, the refused
137
+ techniques and confirm mode exist underneath it.
138
+ - **Only the declared toolchain runs.** `execution.allowedPrograms` names the programs a command
139
+ may start — the shells, the JavaScript, .NET, Java, Python, Go and Rust tools, `git`, and a few
140
+ Windows utilities. A command that starts anything else is refused and sent back with the reason.
141
+ The programs are read the way PowerShell reads a line (`src/exec/commandHeads.ts`): strings,
142
+ operators, array values, method arguments and hashtable keys are not programs, and a command in a
143
+ script block, a subexpression, a string's `$( )` or after an assignment is still found. A line that
144
+ cannot be read with certainty — an unclosed quote or bracket, a program called through a variable
145
+ (`& $exe`) — is refused rather than guessed at. `cmd` steps are read by `cmd`'s own rules. A refused
146
+ step is reported to the chat as refused and never executed, with no exit code, apart from a
147
+ command that ran and failed. An empty list turns the gate off. This is a floor against the unknown
148
+ binary, not a boundary: allowing `node` allows `node -e`.
149
+ - **Autonomy is graded.** An unattended run carries strictly more restrictions than a watched one,
150
+ because the thing that makes a watched run safe is a person reading each line. Unattended
151
+ requires a non-empty allowlist, and refuses an allowed program used to evaluate a string
152
+ (`node -e`, `python -c`) or a shell wrapped in a shell (`cmd /c …`) — the forms that escape the
153
+ allowlist by construction.
154
+ - **An administrator can set a floor the operator cannot lower.** A `policy.lock.json` beside the
155
+ configuration may forbid unattended runs, cap the allowlist and add deny patterns. Every field
156
+ only ever tightens, and the runner never writes the file. A machine without one behaves exactly
157
+ as before.
158
+
159
+ ### Only the project folders
160
+
161
+ Every command a task runs — the implementer's steps and checks, the reviewer's steps and the checks
162
+ it derives — is held to the **project folders**: the session's own folder and every project
163
+ registered in Settings, so a test suite may still start the application from the repository next
164
+ to it. Refused before it runs:
165
+
166
+ - a path outside them — absolute, a network share, `..` that climbs out, a `cd` to the root — and
167
+ anything built from the operator's profile or the system: `~`, `$HOME`, `$env:USERPROFILE`,
168
+ `$env:APPDATA`, `$env:TEMP`, `%TEMP%` and the rest. **Reads as well as writes**: what a step prints
169
+ goes to the chat, so reading a key outside the project is sending it there;
170
+ - the registry and the other drives that are not files (`HKLM:`, `HKCU:`, `Cert:`);
171
+ - managing the computer: services, the network and firewall, local users, the clock, Windows
172
+ features, disks, machine-wide PowerShell modules;
173
+ - installs that land outside the project — `npm -g`, `dotnet tool -g`, `cargo install`,
174
+ `go install`, `pip install` into the machine's Python. The same tools installed into the project
175
+ (`npm install -D`, a local tool manifest, a `.venv`) stay open.
176
+
177
+ A check's own folder and the file a file check reads are held to the same folders, and a relative
178
+ file path is read from the project rather than from wherever the runner was started. A check the
179
+ reviewer derives that reaches outside is dropped rather than kept: the finding stands, the check
180
+ does not. Every run records the folders it was confined to in its `policy.json`.
181
+
182
+ **What this cannot do.** It reads what a step *says*, which is exactly the point — whatever the chat
183
+ proposes that reaches outside the project is not run. It cannot see what a program does once it is
184
+ running: `node build.js`, `npm run x` and a test suite can read and write anywhere the account can,
185
+ and so can a path assembled from variables at run time. That confinement is the operating system's
186
+ to give, and it is the real one:
187
+
188
+ 1. Create a **standard** (not administrator) local Windows account for the bot, and sign it in to
189
+ Copilot once with `cop login`.
190
+ 2. Give it modify rights on the project folders and nothing else:
191
+ `icacls "C:\Projects\my-app" /grant botuser:(OI)(CI)M`.
192
+ 3. **Check what it already has.** Folders created directly under `C:\` usually let every signed-in
193
+ user modify them by default, which would hand the bot every project there, not just yours to
194
+ give. Look with `icacls C:\Projects` and remove the broad grant where it should not be.
195
+ 4. Your own profile — `.ssh`, the browser, OneDrive — is private to you by default; confirm the bot
196
+ account cannot open `C:\Users\<you>`.
197
+ 5. Run the bot as that account, and set **Settings → Execution → Where the bot runs** to
198
+ *A separate low-privilege Windows account*.
199
+
200
+ Windows Sandbox, with only the project folders mapped in, gives the same guarantee with less to set
201
+ up and nothing left behind.
202
+
203
+ ### The local API is not open to everything on the machine
204
+
205
+ The API binds `127.0.0.1` only, and that was once taken to mean it needed no authentication. It
206
+ did. Two callers were always reachable: any page the operator has open in their ordinary browser,
207
+ which can issue requests to `127.0.0.1:4000` — CORS stops it reading the reply, which is no comfort
208
+ once a request has started a session — and any other process on the machine. So every request is
209
+ checked three ways before it reaches a route:
210
+
211
+ - the **`Host`** header must name this loopback port, which is what catches DNS rebinding — the
212
+ attacker's domain made to resolve to `127.0.0.1` is same-origin to the browser but still carries
213
+ its own name here;
214
+ - a present **`Origin`** must be the configured UI, since only a browser sets it and a page cannot
215
+ forge it;
216
+ - a per-install **token**, generated on first start into `data/api-token` (git-ignored), sent as
217
+ `Authorization: Bearer`, `x-cop-token`, or a `token` query parameter for the two cases that
218
+ cannot carry a header — `EventSource` and a plain `<a download>`.
219
+
220
+ `npm start` creates the token before either process starts and hands it to the web process only —
221
+ not to the API, whose environment command steps used to inherit, so a step never sees it; a step
222
+ that names the API's or the UI's port is refused. The web server binds `127.0.0.1` only. `GET /api/health` stays open so that "is it up yet" is still
223
+ answerable. To rotate the token, delete the file and restart.
224
+
225
+ The `data` folder — token, settings, sessions, the level-1 contract — is narrowed at start to the
226
+ operator's account and SYSTEM, and the API refuses to start while any other account can open it:
227
+ under `C:\Projects` a folder otherwise inherits *Authenticated Users: Modify*, which is every
228
+ account on the machine. A step never sees the token (see above) and is refused for naming the API's
229
+ ports or the data folder.
230
+
231
+ This does not contain a process already running as the operator — nothing at this layer can, since
232
+ that process can read the file. It moves the API from "anything on this machine, and several things
233
+ off it" to "the operator's own account, through a browser that was handed the key".
234
+
235
+ Every task writes `policy.json` into its run folder and a `POLICY` block into its log: the mode,
236
+ the allowlist and its digest, that the chat cannot supply files, digests of the deny list and of the
237
+ built-in refusals, whether a lock was in force and what it changed, and the account the run used.
238
+ So "what was this permitted to do at the time" is answered from the run folder rather than from a
239
+ configuration file that has been edited since.
240
+
241
+ ### Before a company deploys it
242
+
243
+ A compliance review against the common frameworks (CIS Controls v8, NIST SP 800-53, ISO/IEC
244
+ 27001 Annex A, the Microsoft baselines) was run on 2026-09-27. Nothing in the software is a
245
+ hidden mechanism; what follows is what a company has to decide, approve or configure before it
246
+ runs this on managed laptops, because no code change can decide it for them.
247
+
248
+ **Approvals to obtain.**
249
+
250
+ - *Identity and licensing.* The bot drives a licensed person's Microsoft 365 Copilot through
251
+ Edge, not through the API. Microsoft documents the API as the supported way to automate
252
+ Copilot; driving the web client is not documented as supported, and a per-user licence is
253
+ not meant to be shared or driven by a service identity. Ask the Microsoft contact whether the
254
+ intended use is acceptable under the licence, and decide which person's identity signs in —
255
+ one licensed identity per operator, never a shared one. Every prompt, upload and Purview
256
+ record is attributed to that identity.
257
+ - *Conditional Access.* The bot's Edge runs a profile of its own under
258
+ `%LOCALAPPDATA%\copilot-operator`, started by `node.exe` with Playwright's debugging channel.
259
+ A tenant's sign-in frequency, compliant-device and managed-browser policies may refuse it or
260
+ pause it for sign-in; and an Edge policy that forbids remote debugging or forces extensions
261
+ stops it outright. Test on one managed device before rolling out; where the baseline cannot
262
+ be relaxed, run it in a VM or Windows Sandbox outside the baseline's scope.
263
+ - *Data protection.* See "Where the reports go" above. Where the law requires it, record the
264
+ processing (a DPIA where automated tooling that stores every command's output and sends it to
265
+ an AI service triggers one; works-council consultation where tooling that records employees'
266
+ actions requires it). Command output can carry personal data from fixtures and exports.
267
+ - *AI-use policy.* Commands written by a language model execute on the endpoint. Confirm mode
268
+ keeps a person on every line; unattended mode removes that person and is the decision most
269
+ AI-governance policies want recorded. `policy.lock.json` can forbid it machine-wide.
270
+ - *Security operations.* Tell the SOC what to expect: `node.exe` starting PowerShell (every
271
+ step, as `-Command` text, which PowerShell logging records verbatim) and `taskkill`; Edge
272
+ started by `node.exe` over a debugging pipe; updates pulled from a git remote. Register the
273
+ install so the process chain is known rather than investigated.
274
+
275
+ **Configuration to set** — as an administrator, in `%ProgramData%\copilot-operator\policy.lock.json`,
276
+ which the operator cannot edit (the same file beside the install is honoured too):
277
+
278
+ ```json
279
+ {
280
+ "maxMode": "confirm",
281
+ "requireIsolation": true,
282
+ "passEnv": [],
283
+ "allowedPrograms": ["pwsh", "powershell", "cmd", "node", "npm", "npx", "git", "dotnet"],
284
+ "update": { "requireSigned": true, "remote": "https://git.example.com/tools/copilot-operator.git" }
285
+ }
286
+ ```
287
+
288
+ Every field only tightens; `update` makes `npm run update` insist on signed commits and refuse
289
+ any other remote. Keep `data/` and `runs/` on a local disk (`COP_DATA_DIR`, `runsDir`), set
290
+ `runsRetentionDays`, and fork the repository internally so updates come from a remote the
291
+ company controls.
292
+
293
+ **Keeping it patched.** Dependencies are pinned in `package-lock.json`; `npm audit` reports
294
+ known vulnerabilities in them, and `npm run update` brings in whatever the remote has fixed.
295
+ Node.js and Edge are patched by the machine's own update process. Nothing here watches for
296
+ end-of-support runtimes — that is the deploying company's asset management.
297
+
298
+ **Stopping it.** "Stop" on a session cuts in after the current step and ends the task
299
+ `aborted`; "Pause" lets the task in flight finish and holds the queue. Ctrl+C in the `npm start`
300
+ terminal stops the API and the UI; processes a step started are stopped with the task (asked
301
+ first, forced after a few seconds), and the run log names any it could not. To end the bot's
302
+ access: `cop logout` signs its profile out, deleting `data/api-token` and restarting rotates the
303
+ API key, `cop login --fresh` deletes the profile.
304
+
305
+ **Where it does not fit.** On a fleet that enforces PowerShell Constrained Language Mode the
306
+ bot's own probes degrade gracefully (permissions are read through `Get-Acl`; elevation reads as
307
+ unknown), but the model's steps themselves run constrained, and most builds will not. That is a
308
+ fleet to run the bot outside of, in a VM, not one to request exceptions on.
309
+
310
+ ### What an update trusts
311
+
312
+ `npm run update` fetches commits, fast-forwards onto them, installs what the lockfile names and
313
+ builds the result — and that result is the thing that runs commands on this machine. Its trust
314
+ boundary is one sentence: **whoever controls the remote controls this bot.** Three things make that
315
+ checkable rather than implied.
316
+
317
+ - **The remote is pinned.** The address a checkout last updated from is recorded in
318
+ `data/update-remote`. If `origin` now points somewhere else the update stops before anything is
319
+ fetched, prints both addresses, and asks. Trust on first use — the first update records what is
320
+ there. Accept a deliberate move with `npm run update -- --accept-remote`.
321
+ - **Signatures, if your fork has them.** `npm run update -- --require-signed` refuses a HEAD that
322
+ git cannot verify, and tells an unsigned commit apart from a bad signature. Off by default,
323
+ because this project does not sign its commits and a check that always fails is a check that gets
324
+ removed; it is here so an organisation whose fork *is* signed can make it mean something.
325
+ - **Every update is written down.** A line in `data/update-log.jsonl`: when, from which remote,
326
+ which commit to which, how many came in, and whether a signature was demanded. `data/` is
327
+ git-ignored, so the record survives the pull it describes.
328
+
329
+ None of this verifies what the code *does*. A signed commit from a compromised maintainer is a
330
+ signed commit. It narrows "anything that can reach the network" to "whoever holds the remote this
331
+ checkout was installed from", and says so out loud.
332
+
333
+ **The honest limit.** Everything above except the first rule is pattern matching and configuration.
334
+ It raises the cost of the ordinary accident and the ordinary injected instruction; it is not a
335
+ security boundary, and a determined attacker with a language model to write for them will find a
336
+ phrasing none of it anticipated. The boundary is the first rule — a separate low-privilege Windows
337
+ account, Windows Sandbox or a VM — and the runner can record whether you have arranged one, refuse
338
+ to run unwatched until you have, and never do it for you.
339
+
340
+ ## Requirements
341
+
342
+ - Windows 10 or 11
343
+ - Node.js 20 or newer
344
+ - Microsoft Edge, already installed
345
+ - A Microsoft 365 Copilot account, signed in once by the user
346
+
347
+ ## Installing it in a project
348
+
349
+ ```bash
350
+ npm install --save-dev copilot-operator
351
+ npx cop login --account you@tenant.org # sign in once; the Edge profile is reused across projects
352
+ npx cop start --open # the API and the interface, on http://127.0.0.1:4000/
353
+ ```
354
+
355
+ Installed this way, the bot belongs to the project it is installed in. Its records — settings,
356
+ sessions, the API key, every run's logs and its Edge profile — go to the bot's own folder,
357
+ `%LOCALAPPDATA%\copilot-operator`, not into the project, so the project's git never sees them and
358
+ the bot's version control finds a clean tree. **System → The bot's folder → Change…** keeps them in
359
+ another folder from the next start (optionally copying what is there, so the sign-in stays), and
360
+ `COP_HOME` sets one from outside. A version before 0.1.56 kept them in `.copilot-operator/` in the
361
+ project: the first start of a newer one copies them over once and says so; the old folder can then
362
+ be deleted. The interface ships prebuilt and is served by the same process on one port; there is no
363
+ second server and nothing is compiled on the machine. `npx cop start --port 4100` picks another
364
+ port. `npm update copilot-operator` updates it; `npm run update` is for a clone.
365
+
366
+ **Keeping it out of the project's repository.** A dev dependency is recorded in `package.json`
367
+ and the lock file, which are committed. To leave the project untouched, install it globally and
368
+ start it from the project's folder — the folder it is started from is the project:
369
+
370
+ ```bash
371
+ npm install --global copilot-operator
372
+ cd C:\path\to\your-project
373
+ cop start --open
374
+ ```
375
+
376
+ Nothing in the project changes. The bot's own code is then outside the folders its steps may write,
377
+ which is the safer of the two.
378
+
379
+ The bot is then inside the folders its own steps may write, so a step that reaches for
380
+ `node_modules/copilot-operator`, for the bot's folder (by its path, or as `%LOCALAPPDATA%\copilot-operator`
381
+ in any spelling), or that installs, updates or removes the bot as a package is refused. What no rule can see is a step that rewrites the project's
382
+ `package.json` with a different version of the bot for a later `npm install` to fetch; the commit
383
+ the bot makes after the task shows such a change, and it is worth a look before the next install.
384
+
385
+ ## Releasing a new version
386
+
387
+ Publishing is done by GitHub Actions (`.github/workflows/publish.yml`), not from a laptop:
388
+
389
+ ```bash
390
+ npm version patch # or minor / major: updates package.json, commits, tags vX.Y.Z
391
+ git push --follow-tags # the tag starts the workflow: typecheck, checks, build, publish
392
+ ```
393
+
394
+ The workflow publishes with npm's Trusted Publishing — no npm token is stored anywhere; npm accepts
395
+ the package because it comes from this repository's `publish.yml` — and with provenance, so the
396
+ package page on npm says which commit and which run built it. Set up once, after the first manual
397
+ `npm publish`: on npmjs.com, the package's **Settings → Trusted Publisher → GitHub Actions**, with
398
+ repository `ivan-markov-666/copilot-operator` and workflow `publish.yml`. A tag whose version does
399
+ not match `package.json` stops the workflow before anything is built.
400
+
401
+ ## Working on it from a clone
402
+
403
+ ```bash
404
+ npm install # root and the web workspace
405
+ npx tsx src/cli.ts login --account you@tenant.org # sign in once; the Edge profile is reused
406
+ npx tsx src/cli.ts doctor # check the machine
407
+ ```
408
+
409
+ A pull, a merge or a switch of branch leaves `node_modules` as it was; when what it brought in
410
+ names a package that is not installed, or another version of one, `npm start` and the package build
411
+ (`npm pack`, `npm publish`) say which and stop before building anything: `npm install` again.
412
+
413
+ The bot never types credentials. `login` opens Edge, waits for the chat to appear, checks
414
+ that the right account is signed in, and stores nothing but the browser profile.
415
+
416
+ ### The web UI
417
+
418
+ ```bash
419
+ npm start # builds the API, then runs it and the UI together; Ctrl+C stops both
420
+ ```
421
+
422
+ Then open http://localhost:3210. `npm run dev` does the same and opens the browser for you.
423
+ The two can also run separately: `npm run api` (NestJS on 127.0.0.1:4000) and `npm run web`
424
+ (Next.js on localhost:3210).
425
+
426
+ Open a project folder, write what to change in the chat on the right, approve each command in
427
+ the conversation (or let them run without asking), and read the summary when it finishes. The
428
+ files of the folder are on the left, with its git; a file opens in the editor, coloured by its
429
+ language, and can be edited and saved. "Plan mode" under the chat's box asks Copilot for a plan
430
+ first, shown in the conversation to approve; "Review" has a conversation of its own check the work
431
+ when Copilot says it is done. "Two chats" gives a complex task to a lead, which plans and directs,
432
+ and a worker, which runs the commands of each subtask and reports back — two conversations in the
433
+ same Copilot window, the lead asking you only what nobody else can decide. "Pause" holds the work at its next message or command and becomes
434
+ "Continue". The interface speaks nine languages (English, Bulgarian, German, Spanish, French,
435
+ Portuguese, Japanese, Korean, Arabic), chosen from "Language". "Kerrigan" on the home screen hands out a persona to
436
+ give another chat, which then helps you write tasks for this one and answers any question about the
437
+ program (optional); she knows your projects, with the level 2 you write for each in Settings. A project in Settings can be marked "For
438
+ reference only": the bot reads it and runs what only reads it, and whatever a command changes there
439
+ — files, branches, what is staged — is put back after that command, and the chat is told. See
440
+ [`docs/ui.md`](docs/ui.md); the Sessions page, the task register and plans from JSON were removed
441
+ on 2026-10-20.
442
+
443
+ As in VS Code, Ctrl+P finds a file by name and Ctrl+Shift+F searches the code (match case, whole word,
444
+ regular expressions, files to include or exclude); a Markdown file opens as it reads, its mermaid diagrams drawn.
445
+ A file opens in the editor of VS Code itself (Monaco): find and replace, several cursors, folding, the minimap,
446
+ IntelliSense for TypeScript, JavaScript, JSON, CSS and HTML. The git view shows everything the branch changed, as a
447
+ pull request does, against the branch it would go into, with the files not committed yet marked.
448
+ Skills keep your instructions for a kind of task that comes back — a new test, a new entity, a migration — in
449
+ Settings; a message starting with `/its-name` (or with the skill chosen under the chat's box) carries them to the
450
+ chat. The three panels move as in VS Code: drag the grip ⠿ in a panel's head onto another. Settings can also make
451
+ the bot pause between messages to Copilot, by a fixed or a random time.
452
+
453
+ **What runs, and how.** Every command the chat sends is given to PowerShell as text
454
+ (`pwsh -NoProfile -NonInteractive -Command "…"`); the bot writes no script to run it. A script file
455
+ — `.ps1`, `.cmd`, `.bat`, `.sh`, `.vbs` — runs only when it is the project's own: committed in its
456
+ repository, unchanged since, and committed before the work began. One the chat wrote, changed or
457
+ downloaded is refused however it is called, and nothing in `.cop-tmp` is run. The project's tools
458
+ go on as usual — `npm test`, `npm run build`, `dotnet test`, `node` starting the application.
459
+ Downloads wait for you even in an unattended run, `npm install` runs no install scripts, and the
460
+ package itself has none.
461
+
462
+ ### Removing it from a machine
463
+
464
+ Nothing is installed system-wide, nothing runs at start-up, no service and no scheduled task
465
+ exist. What the software leaves, and where:
466
+
467
+ | What | Where | Remove |
468
+ |---|---|---|
469
+ | settings, sessions, the API token, level-1 and context texts | `data/` in the checkout | delete the folder |
470
+ | every run's logs, reports and failure screenshots | `runs/` in the checkout | delete the folder (or set `runsRetentionDays`) |
471
+ | backups taken by `npm run update` | `data-backups/` in the checkout | delete the folder |
472
+ | the bot's own Edge profile, with its Microsoft 365 session | `%LOCALAPPDATA%\copilot-operator\edge-profile` | sign out in that window (`cop login --fresh` deletes it) and delete the folder |
473
+ | installed from npm: its settings, sessions, the API token, every run's logs and its Edge profile | the bot's folder, `%LOCALAPPDATA%\copilot-operator` unless another was chosen (System shows which) | delete the folder |
474
+ | installed from npm, a version before 0.1.56: the same records | `.copilot-operator\` in the project, or in the folder it was started from | delete the folder; a newer version copied what it needed |
475
+ | the API key the browser was handed | the browser's storage for `localhost:3210` | clear site data for that origin |
476
+ | logs saved on request by older versions | `Desktop\copilot-operator-logs` | delete them; they may already be in OneDrive, and nothing writes there any more |
477
+ | the project copies of versions before 0.1.14 | `Desktop\copilot-operator-context` | delete the folder; nothing writes to it any more |
478
+ | the reports uploaded to Copilot | the account's OneDrive and Copilot chat history | delete the conversations, or let the tenant's retention run |
479
+ | a machine-wide policy lock, if an administrator placed one | `%ProgramData%\copilot-operator\policy.lock.json` | the administrator removes it |
480
+
481
+ The permissions the API set on `data/` and `runs/` (owner and SYSTEM only) go with the folders.
482
+
483
+ ### Updating a machine that has been used
484
+
485
+ ```bash
486
+ npm run update # back up, pull, install, build
487
+ npm run update -- --check # say what would happen, change nothing
488
+ ```
489
+
490
+ **A pull cannot lose what you have entered.** Everything this program records lives in `data/`
491
+ (settings, sessions, level 2 presets, a customised level 1, the organisation and work texts, the
492
+ model list) and `runs/` (every log, report and artifact of every task). Both are in `.gitignore`,
493
+ every write in `src/` goes to one of them, and git does not know they exist.
494
+
495
+ What a pull *can* do is refuse to start. `npm run update` deals with each reason in turn: it
496
+ copies `data/` to `data-backups/<timestamp>/` before touching anything, refuses to run while the
497
+ bot is (swapping the code under a run in flight is the one thing here that could really break
498
+ something), puts any local edits to tracked files into a named stash and tells you the command to
499
+ get them back, pulls **fast-forward only** so no merge is ever made on your behalf, and then
500
+ reinstalls and rebuilds — because a `dist/` older than its `src/` runs the previous version and
501
+ reports the previous version's bugs.
502
+
503
+ Run it with `--check` first if you want to see what it would do. When nothing has come in it
504
+ installs and builds nothing; `--rebuild` forces both. It uses `npm ci`, and only when the pull
505
+ actually moved a dependency: `npm install` may rewrite `package-lock.json`, and a rewritten
506
+ lockfile is a tracked file that differs from the commit — which is one of the phantom local
507
+ changes this is here to stop.
508
+
509
+ **`npm warn allow-scripts ... esbuild`** on a machine whose npm requires install scripts to be
510
+ approved is expected and usually harmless. esbuild gets its Windows binary from an optional
511
+ dependency (`@esbuild/win32-x64`), which installs without any script; the blocked `postinstall`
512
+ only revalidates it. Check with `npx tsx --version` — if that answers, `npm run check` will run.
513
+ If it does not, `npm approve-scripts esbuild` and install again.
514
+
515
+ If files looked modified that you never edited, that was line endings: two Windows machines, one
516
+ with `core.autocrlf` set and one without. `.gitattributes` settles it.
517
+
518
+ ### The terminal, for one task
519
+
520
+ ```bash
521
+ cp run.example.yaml run.yaml # then edit it
522
+ npx tsx src/cli.ts run run.yaml
523
+ ```
524
+
525
+ ### Commands
526
+
527
+ | Command | What it does |
528
+ |---|---|
529
+ | `cop login` | opens Edge with the bot profile and waits for you to sign in |
530
+ | `cop doctor [run.yaml]` | checks Node, Edge, PowerShell, the bot's Edge profile, the config |
531
+ | `cop run <run.yaml>` | one task as a new session; `--unattended` skips the per-step prompt |
532
+ | `cop chat [run.yaml]` | prints the last run's conversation name and link |
533
+
534
+ Before it is built, run them as `npx tsx src/cli.ts <command>`.
535
+
536
+ **Testing it for the first time:** follow [`docs/testing.md`](docs/testing.md). Nine steps,
537
+ ordered so the risk climbs slowly, starting with checks that need no account at all.
538
+ `run.smoke.yaml` is a ready-made read-only first run.
539
+
540
+ ## How it works
541
+
542
+ | Piece | File | State |
543
+ |---|---|---|
544
+ | DOM locators for the Copilot web app | `src/transport/locators.ts` | captured from the live app |
545
+ | Command runner, dual timeouts, process-tree kill | `src/exec/runner.ts` | implemented, checked |
546
+ | Chat naming and reattach after re-login | `src/transport/chatSession.ts` | implemented, checked |
547
+ | Covering message for the results file | `src/protocol/reporter.ts` | implemented, checked |
548
+ | The bot's folder: default, chosen on System, moved out of the project once | `src/config/layout.ts`, `src/config/home.ts` | implemented, checked |
549
+ | Pacing, send cap, backoff | `src/util/pacing.ts` | implemented, checked |
550
+ | Playwright transport | `src/transport/copilotTransport.ts` | implemented; selectors verified live |
551
+ | Reply parser and the JSON contract | `src/protocol/parser.ts`, `replySchema.ts` | implemented, checked |
552
+ | Report file, splitting, redaction | `src/exec/reportFile.ts` | implemented, checked |
553
+ | Deny list and the confirm gate | `src/exec/policy.ts` | implemented, checked |
554
+ | Config schema and loader | `src/config/schema.ts` | implemented |
555
+ | The loop, per task and per session | `src/orchestrator/taskRunner.ts` | run live end to end |
556
+ | Sessions, tasks, level 2 presets on disk | `src/session/` | implemented, checked |
557
+ | API | `src/api/` (NestJS) | implemented, exercised over HTTP |
558
+ | Web UI | `web/` (Next.js) | implemented |
559
+ | CLI | `src/cli.ts` | implemented |
560
+
561
+ Design and findings:
562
+
563
+ - [`docs/ui.md`](docs/ui.md) — the web UI, the API and the session model
564
+ - [`docs/testing.md`](docs/testing.md) — how to test it the first time, step by step
565
+ - [`docs/architecture.md`](docs/architecture.md) — the whole design
566
+ - [`docs/locators-findings.md`](docs/locators-findings.md) — what the live Copilot DOM looks like and why
567
+ - [`docs/tech-stack-research.md`](docs/tech-stack-research.md) — why Playwright and not the alternatives
568
+ - [`docs/deferred.md`](docs/deferred.md) — designed, argued and deliberately not built yet, with the reasoning kept
569
+
570
+ ### What Kerrigan knows
571
+
572
+ Kerrigan (`src/plan/kerrigan.ts`) is the persona the home screen hands out, saved as a file or
573
+ copied, for a chat of the operator's own choosing: what copilot-operator is, how a task is best
574
+ written for its chat, and the names of the chat's controls, so it can say press "New chat" rather
575
+ than "start over". She is optional: the bot's chat does not need her. The names live in
576
+ `src/plan/systemGuide.ts`, and `test/guide.check.ts` pins every one of them to `web/lib/strings.ts`
577
+ in both languages. Renaming a control in the interface therefore breaks that check by name, and a
578
+ new control the operator would ever be told to press has to be added to the guide as well, or the
579
+ persona does not know it exists. The same check reads the pages themselves, so a label that is
580
+ still in the dictionary but that nothing renders any more fails too, and it holds the labels
581
+ Kerrigan quotes in her own prose to the same standard.
582
+
583
+ She knows the whole program, not only how to write a task (2026-11-18): every screen of the guide is in her
584
+ text, the cards and notices shown on every page included, so the operator can just ask her how something works.
585
+ She also takes the file a locator's notice gives ("Download the file for a chatbot") and answers with the new
586
+ locator. The same check holds her under 100,000 characters, so she still fits in the box of a chat like Copilot's,
587
+ which refuses about 120,000; what is too detailed for a helper stays out (`EVERY_PAGE_SKIP` in `kerrigan.ts`).
588
+ She carries the version and the settings of the moment she is taken, so she is taken again after an update.
589
+
590
+ ## Notable findings
591
+
592
+ These cost real investigation and are worth knowing before touching the code.
593
+
594
+ - **Code blocks cannot be read from the DOM.** They are virtualized and interleave line
595
+ numbers with the code. A valid JSON reply came back from `innerText` with a chunk missing.
596
+ The message-level "Copy Response" button plus clipboard access is the only safe read.
597
+ - **Downloads are plain anchors** with a `blob:` href and a `download` attribute, which is
598
+ why nothing useful appears on hover. Playwright's download event handles them.
599
+ - **Enter does not send.** The composer is a contenteditable span; the Send button must be
600
+ clicked.
601
+ - **A message cannot be only an attachment.** Text is mandatory, so the covering message is
602
+ part of the protocol rather than decoration.
603
+ - **Uploads go through the user's OneDrive.** The chat says so, and the attachment id carries
604
+ an `SPO_` prefix. That prefix is also the most reliable "upload finished" signal.
605
+ - **Copilot destroys `[name]:` in its own output.** `[math]::Round($x, 2)` reaches the
606
+ runner as `:Round($x, 2)`, even inside a fenced code block, because `[label]:` is markdown
607
+ for a link reference. `[pscustomobject]` and `[double]$x` survive, since the damage needs
608
+ the colon. The prompts forbid that form and the runner refuses a command that arrives
609
+ wrecked rather than executing something nobody wrote.
610
+ - **`lastChatMessage` is not the whole answer.** It is the answer body; the copy button is
611
+ its sibling. A wait built on `[data-testid="lastChatMessage"] [data-testid="CopyButtonTestId"]`
612
+ never completes. The anchor is the last `copilot-message-div`.
613
+
614
+ ## Checks
615
+
616
+ ```bash
617
+ npm run check # all of them, one after another
618
+ npm run check:all # the types, all of them, the interface and the package: about 75 minutes
619
+ npm run check:parallel # the same, several at a time: about half the time
620
+ ```
621
+
622
+ `check:parallel` (`scripts/check-parallel.mjs`) runs 2 to 4 at a time (`-- --jobs N`), the slowest first by the
623
+ times of the last run, the few that use what the machine shares (the clipboard, processes, the profile lock) alone
624
+ after the others, and `check:release` last. A check that fails among the others is run again alone and said as
625
+ "failed under load": still a failure. Each check's output is kept in a file under the temp folder, named at the end
626
+ with the failures and the slowest ten. `-- --only e2e` runs only the checks whose name holds "e2e".
627
+
628
+ Each one prints what it exercised rather than asserting silently, so a failure is readable.
629
+ There is no live-tenant test: that is the part that needs a human and a signed-in browser.
630
+
631
+ ## Related
632
+
633
+ [context-picker](https://github.com/ivan-markov-666/context-picker) (MIT) — the same author's
634
+ VS Code and Visual Studio extension for picking which project files an LLM should see. This
635
+ project follows its file-naming convention, so the two produce interchangeable folders, and
636
+ can drive it directly for per-file selection.
637
+
638
+ ## Licence
639
+
640
+ MIT. See [`LICENSE`](LICENSE).