@intentic/machine 1.310.0 → 1.311.0

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 (48) hide show
  1. package/README.md +46 -304
  2. package/dist/device/audit.d.ts.map +1 -1
  3. package/dist/device/audit.js +3 -1
  4. package/dist/device/audit.js.map +1 -1
  5. package/dist/device/auto-prepare.d.ts.map +1 -1
  6. package/dist/device/auto-prepare.js +1 -1
  7. package/dist/device/auto-prepare.js.map +1 -1
  8. package/dist/device/config.d.ts.map +1 -1
  9. package/dist/device/config.js +12 -4
  10. package/dist/device/config.js.map +1 -1
  11. package/dist/device/connection.d.ts.map +1 -1
  12. package/dist/device/connection.js +2 -1
  13. package/dist/device/connection.js.map +1 -1
  14. package/dist/device/indicator.d.ts.map +1 -1
  15. package/dist/device/indicator.js +2 -2
  16. package/dist/device/indicator.js.map +1 -1
  17. package/dist/device/mcp.d.ts.map +1 -1
  18. package/dist/device/mcp.js +7 -4
  19. package/dist/device/mcp.js.map +1 -1
  20. package/dist/device/policy.d.ts +1 -0
  21. package/dist/device/policy.d.ts.map +1 -1
  22. package/dist/device/policy.js +9 -5
  23. package/dist/device/policy.js.map +1 -1
  24. package/dist/device/router.d.ts +1 -0
  25. package/dist/device/router.d.ts.map +1 -1
  26. package/dist/device/router.js +3 -3
  27. package/dist/device/router.js.map +1 -1
  28. package/dist/device/tools/describe.js +2 -2
  29. package/dist/device/tools/describe.js.map +1 -1
  30. package/dist/device/tools/sandboxes.d.ts +14 -4
  31. package/dist/device/tools/sandboxes.d.ts.map +1 -1
  32. package/dist/device/tools/sandboxes.js +71 -9
  33. package/dist/device/tools/sandboxes.js.map +1 -1
  34. package/dist/install.d.ts +4 -0
  35. package/dist/install.d.ts.map +1 -1
  36. package/dist/install.js +22 -3
  37. package/dist/install.js.map +1 -1
  38. package/dist/sync/commands.d.ts.map +1 -1
  39. package/dist/sync/commands.js +9 -2
  40. package/dist/sync/commands.js.map +1 -1
  41. package/dist/sync/config.d.ts.map +1 -1
  42. package/dist/sync/config.js +6 -4
  43. package/dist/sync/config.js.map +1 -1
  44. package/dist/sync/ssh.d.ts +1 -1
  45. package/dist/sync/ssh.d.ts.map +1 -1
  46. package/dist/sync/ssh.js +6 -4
  47. package/dist/sync/ssh.js.map +1 -1
  48. package/package.json +8 -8
package/README.md CHANGED
@@ -1,309 +1,51 @@
1
- # @intentic/machine
2
-
3
- The one agent that lives on a user's own device: it lets a sandbox's agent work on the machine, and keeps the
4
- machine's folders and ports mirrored with the sandbox — one binary, one resident agent per OS install, and one version
5
- across the whole computer.
6
-
7
- It replaces two agents (`@intentic/host` and `@intentic/sync`) that shared everything about *being installed* —
8
- a resident agent, a pidfile, a login entry, an updater, a ~90 MB compiled binary — and nothing about what they
9
- did. Merging them halves what a machine downloads and keeps resident, and gives "is this machine's agent
10
- running" one answer instead of two halves of one.
11
-
12
- ## Responsibilities
13
-
14
- The **device half** (`src/device/`, the machine side of the `host` capability):
15
-
16
- - Dial each linked sandbox — one outbound WebSocket, enrollment token in the first frame, oRPC after that; the
17
- machine *serves* `deviceContract`, so no port ever opens here. Where it dials is the shared resolver's answer
18
- (below), re-asked on every reconnect, so a sandbox on this very machine stays connected with its tunnel down.
19
- - Expose the tool surface (`run_command`, files, screenshot, `describe`; deliberately no delete — trash is
20
- recoverable) as MCP carried verbatim, so a machine can learn a tool without a daemon release. Each tool says what
21
- a call can do — only read, change something that can be put back, or lose something — as MCP annotations, so a
22
- runtime may run the reads side by side.
23
- - Enforce the owner's scopes **here**, never in the sandbox, and append every call to an audit log that
24
- survives uninstall.
25
- - **Show the person at the machine when an agent is driving it, and let them pause it** (see **What the person at
26
- the machine sees**).
27
- - Judge every path **where it really leads** ([src/device/policy.ts](src/device/policy.ts)): links and junctions
28
- are resolved, on the path and on the roots, before the check, and the tool then acts on the resolved path, so a
29
- link inside an allowed folder cannot carry a read or a write out of it. A new file is judged by the folder it would
30
- land in. `trash_file` alone judges a link where it sits, because it moves the link and not what it points at.
31
- - **Change a file only as it was read** ([src/device/tools/files.ts](src/device/tools/files.ts)). `read_file`
32
- answers with the file's revision (a hash of its bytes) and takes a line range, saying where to continue;
33
- replacing a file with `write_file`, or one exact piece of it with `edit_file`, needs that revision and is refused
34
- when the file has changed since. A file keeps its encoding (UTF-8, UTF-8 with a BOM, and UTF-16LE with a BOM,
35
- which is what Windows PowerShell 5.1 writes) and its line endings, and is replaced by a rename, never rewritten
36
- in place. Binary files are refused; text in a legacy code page is shown but never written back.
37
- - **A command ends whole** ([src/device/tools/shell.ts](src/device/tools/shell.ts)). `run_command` starts its
38
- shell in a process group of its own: at the deadline the group gets SIGTERM and, two seconds later, SIGKILL
39
- (Windows has no groups, so `taskkill /T /F` ends the process tree), so nothing it started outlives it. The call
40
- returns when the command exits, not when the last process it left in the background lets go of its output: one
41
- second's grace, then the pipes are closed and the answer says something is still running. Each stream keeps its
42
- first and last 50,000 characters and counts what fell between.
43
- - Manage this machine's sandboxes for a browser button or a model, under the `sandboxes` switch: list them
44
- with their **share of the machine** (one `docker inspect` per listing: memory and CPU caps, privileged, GPU,
45
- and who asked for each directive, the approved environment or the owner), start/stop/restart, run the `ic`
46
- flows (prepare, update, rebuild, rollback, reshape, remove) narrating their output line by line, and tail
47
- their logs. `reshape` changes a sandbox's share or privileges through `ic sandbox reshape` on the same
48
- switch as the swaps, because another reshape undoes it; its ask is a closed form (two caps, two switches)
49
- spelled into `ic` flags here, so nothing a browser or a model sends reaches docker as text. `describe`
50
- reports the docker engine's size beside the OS, which is all those caps can amount to.
51
- - **Drop the links nothing answers** (`intentic-machine device forget-unreachable`, and the button the sandbox's
52
- Devices tab draws for it): a deleted or recreated sandbox leaves its side of the link here, and the agent re-dials
53
- that address for as long as the machine runs. Only the resident agent's own live stamp decides what counts as gone
54
- (`src/device/config.ts`), so a machine whose agent is stopped drops **nothing** — "I can't reach it" and "I'm not
55
- running" are the same sentence from a config file, and only one of them is a reason to delete a link.
56
- - **Drop a link the sandbox revoked**, at once: the sandbox closes the socket with 1008 after reading its own
57
- enrollments, which no redial heals, so the link leaves `device.json` rather than being dialled at every start.
58
- - Keep each local sandbox's **next update downloaded** (`src/device/auto-prepare.ts`): a background tick
59
- runs `ic sandbox prepare <slug> --auto` every few hours, so the web app's update card offers a half-minute
60
- restart instead of minutes of pulling. On by default; the switch is `intentic-machine updates --sandboxes off`
61
- (kept in `machine.json`, re-read every tick). Only the machine's root runs it (see **One machine**): every
62
- environment of a PC talks to the one Docker engine, and two ticks would pull the same image twice. Nothing in any
63
- sandbox can start or steer the tick — a sandbox only learns the outcome through the staged marker `ic` writes.
64
-
65
- The **sync half** (`src/sync/`, the machine side of desktop sync):
66
-
67
- - Enroll an SSH key, then drive Mutagen: bidirectional file sync of a local folder ↔ the sandbox's /work, plus
68
- a one-way backup of the sandbox's own state.
69
- - Serve the SSH transport itself on loopback (the sandbox's sshd reached over its HTTPS surface), mirror every
70
- workspace port onto this machine's localhost, and bridge git so commits appear in local clones.
71
- - Own the **port-mirroring switch** (`sync mirror off|on`, optionally `--sandbox <id>`): mirroring is the one
72
- thing here that writes to *this* device's localhost, so the flag lives on this side, survives a restart, and
73
- is read every tick. File sync, the state backup and the git bridge are untouched by it — the point is to stop
74
- the ports without unpairing the sandbox. The sandbox's Devices tab has a button for it, and that button runs
75
- this very command over the `host` capability, so the two can never disagree. The same is true of the other
76
- three verbs — `sync pause`, `sync resume` and `sync uninstall --sandbox <id>`.
77
-
78
- **Both scopes are buttons, because both scopes are commands.** With `--sandbox` these act on one pairing, and
79
- that is the switch under that pairing's own folder and ports in the tab. Run BARE they act on every sandbox
80
- this machine pairs, which is what they mean in a terminal and what "turn this off on this laptop" should mean
81
- on screen, so the machine's own row carries a **File syncing** and a **Port mirroring** switch that omit the
82
- flag. The tab never sends a bare `sync uninstall`: unpairing is the one verb here that a fresh one-liner is the
83
- only way back from, so the button always names the pairing it ends. A machine whose pairings disagree (one
84
- mirroring, one not — which the per-pairing switches exist to allow) is drawn as such rather than collapsed to
85
- one position, and offered both directions.
86
-
87
- **And one port at a time** (`sync mirror ignore|unignore --sandbox <id> --port <n>`). The switch above is
88
- all-or-nothing, and the case it has no answer for is the common one: a single number this machine already uses
89
- for something else — a Postgres on 5440 that the sandbox's compose file also publishes — loses the local bind
90
- correctly, every tick, forever. That is not a contest that resolves, and turning every port off to be rid of one
91
- standing notice is the wrong trade. An ignored port is skipped before the free-check, torn down at once if it was
92
- already up, and still REPORTED — as `ignored`, its own state — because the row it appears on is the only place the
93
- choice can be reversed. It lives here rather than in the sandbox for the same reason the switch above does: the
94
- conflict belongs to one machine's localhost, and the same sandbox goes on mirroring that port everywhere else.
95
- - **Clear its own build output when it blocks a deletion** ([src/sync/residue.ts](src/sync/residue.ts)). Two-way-safe
96
- refuses to delete a directory holding content it never carried, so a `node_modules` this device built is enough to
97
- stop a directory the sandbox deleted from ever going away here. Nothing in that standoff is a disagreement — no edit,
98
- no second copy, nothing at stake — but it was reported as one ("created on this device"), and in a pnpm monorepo,
99
- where every package carries three ignored directories, an agent moving six packages produced six of them at once.
100
- The agent now reads Mutagen's own `untracked` kind, and where one side holds NOTHING but ignored content and the
101
- other deleted the directory, it removes the residue here and lets the deletion land. It is bounded by the thing it
102
- cannot get wrong: it removes only what the live session's own ignore list already excludes, re-read from disk rather
103
- than trusted from the report, and a single file sync would have carried takes the whole directory out of the class.
104
- `sync clean` does it on demand (the Devices tab's **Clear build output** button runs exactly that); `sync autoheal
105
- off` stops the watcher doing it unprompted. A conflict with two real copies is untouched by all of it.
106
- - Register Mutagen's daemon for login autostart — on Windows through the launcher stub, because Mutagen's own
107
- registration flashes a console window at every boot.
108
-
109
- **Shared** (`src/`): the one resident agent (`run`), the merged `status` (its `--json` envelope is what the desktop
110
- app's tray reads, and the sandbox asks the running agent for the same report over the device connection's `report`
111
- call, behind "Run commands"), the machine-wide `upgrade` with automatic rollback, the `updates` switches, the autostart
112
- spec, and **where a sandbox's daemon is dialled** ([src/daemon-base.ts](src/daemon-base.ts)). A sandbox usually runs in a container on this very
113
- machine, which publishes its daemon on `127.0.0.1:<port derived from the sandbox id>`, so every dial either half
114
- makes — the device socket, both enrollments, the sync transport, the ports poll, the machine report — tries
115
- that address first and the public URL last. A candidate is adopted only if the daemon's unauthenticated
116
- `/health` answers with the id we expected: a port is not a sandbox, and a token is what would be presented to
117
- whoever holds it. For the sync half the shortcut saves a multi-gigabyte Mutagen sync a trip out to the
118
- reachability edge and back to the same laptop. For the device half it is reachability itself: the socket used
119
- to dial the public URL and nothing else, so a sandbox whose tunnel was down read "offline" on its own Devices
120
- tab, with every button there gone, while this same process was polling it over loopback. The watcher re-probes
121
- a pairing sitting on the public URL each minute, so a container started later is promoted with no restart; the
122
- socket re-resolves on every reconnect.
123
-
124
- ## What the person at the machine sees
125
-
126
- While an agent is driving this computer's mouse and keyboard, a small notice sits at the top of the display the
127
- pointer was on ([src/device/indicator.ts](src/device/indicator.ts); the window is `@intentic/desktop-automation`'s
128
- `notice`):
129
-
130
- > Intentic agent is controlling this computer · sandbox-host.example.dev · Ctrl+Alt+Shift+P pauses
131
-
132
- - **What counts as driving** is the `device` tool's pointer and keyboard actions. A screenshot or a `wait` moves
133
- nothing and shows nothing.
134
- - **It never gets in the agent's way.** It never takes focus, so typing still lands in the focused window; every
135
- click goes through it to what is underneath; and it is left out of screen captures, so no screenshot the model
136
- reads has it in it.
137
- - **It goes** 30 seconds after the last action, at once when the link that drove it disconnects, and with the agent
138
- when it exits. The hidden `powershell.exe` behind it is started by the first action and ended with the notice. It
139
- fails toward hidden: a helper that dies is not restarted until the links go quiet, one that will not quit is
140
- killed, and a notice that cannot be shown costs the notice, never the action.
141
- - **Ctrl+Alt+Shift+P pauses**, pressed while the notice is on screen. From then on every sandbox's mouse and keyboard
142
- actions here are refused with `Refused: paused by the person at this computer: …`, and the notice reads
143
- `Intentic agent paused · … · Ctrl+Alt+Shift+P resumes`. The same keys lift it, again while a notice is up: an agent
144
- that tries while paused puts one up, which is also how the person learns an agent is waiting on them. Every press
145
- and every refusal is in the audit log.
146
- - **A pause survives a restart.** It is a file (`~/.intentic/machine/paused`), because a sandbox can ask for this
147
- agent to restart. `status` prints it, `status --json` carries it as `device.pausedAt`, and the summary the tray
148
- shows ends in `mouse and keyboard paused`.
149
- - **It is not a lock** against an agent that may also run commands here: the capability card's switches are the
150
- owner's lever for that. When another program already holds Ctrl+Alt+Shift+P, the notice leaves the keys off and
151
- the agent's log says so.
152
- - **Windows only.** Elsewhere nothing is shown and nothing can be paused.
153
-
154
- ## The resident agent
155
-
156
- `intentic-machine run --foreground` (what systemd, launchd, the Windows logon task and, for a distro, its Windows side
157
- run) serves everything this environment holds in one process ([src/resident.ts](src/resident.ts)):
158
-
159
- - **Configuration is re-read, never restarted for.** Every tick re-reads the links (`device.json`), the sync pairings
160
- (`sync.json`) and, on Windows, the distros it keeps running (`machine.json`): a new link is dialled, a removed or
161
- re-enrolled one is closed, and a pairing added later starts the sync half in this same process. So `setup`,
162
- `uninstall`, `forget-unreachable` and a scope push leave every other sandbox's socket and every sync transport
163
- alone; only a new binary or `run` restarts the agent. `device setup` waits for the agent's own stamp to show the new
164
- link's socket open before it says "connected".
165
- - It exits — and takes its login entry with it — only when links, pairings and kept distros are all **readably**
166
- empty. A config that exists and will not parse is logged and the agent keeps what it already runs: retiring the login
167
- entry is a decision nothing but a fresh install undoes, and one unreadable file must not be able to make it.
168
- - **One agent per environment.** The pidfile (JSON: pid, the boot it belongs to, the build it runs, who restarts it) is
169
- claimed by writing it and re-reading after a settle, so two agents started at the same moment cannot both keep it, and
170
- it is re-checked every tick as a lease: an agent that finds another pid there leaves with exit 75.
171
- - **Every start goes through the supervisor** ([src/supervision.ts](src/supervision.ts)): `schtasks /run` for the logon
172
- task, `systemctl --user start`, launchd, or the Windows side for a distro it keeps; a bare detached spawn only where
173
- nothing supervises. The running agent settles its own entry once as it starts: it puts back one lost to a tidied Run
174
- key or a reset profile, and a distro kept by its Windows side removes its own, so each agent has exactly one starter.
175
- - On a signal it exits `128+signal`, never 0: a supervisor must restart what it did not stop, and the incident that
176
- bought that rule is written out in [src/sync/mirror.ts](src/sync/mirror.ts).
177
- - It stamps **what each link's socket is doing** into `links.tick` every five seconds: the only process that knows is
178
- this one and the only process that is asked is `status`, in another terminal. See **Linked vs connected**.
179
- - State files are written whole: every write lands beside the file and replaces it by rename, so no reader ever sees a
180
- torn `device.json` and mistakes it for an empty one.
181
-
182
- ## One machine: Windows and its distros
183
-
184
- A Windows PC with WSL runs one agent per OS install — Mutagen has to watch a distro's folder from inside that distro —
185
- but it is one computer, so it has one version and one supervisor tree
186
- ([machines-and-environments.md](../../docs/design/machines-and-environments.md)).
187
-
188
- - **The Windows side is the root, and each distro with an agent is its child.** The root holds one `wsl.exe` session
189
- per child ([src/environments/children.ts](src/environments/children.ts)): the session boots the distro at sign-in,
190
- keeps WSL from shutting the VM down once its last client leaves, and restarts the distro's agent on a ladder from one
191
- second to five minutes when it crashes. A child that exits 0 (nothing left to serve), has no agent any more, or is
192
- gone from `wsl -l` is taken off the list.
193
- - **A distro hands itself over.** A distro agent that finds a Windows agent through interop asks it to take over
194
- (the hidden `environment attach <distro>`), removes its own systemd entry and is restarted by the root from then on.
195
- A Windows `setup` adopts distros already running an agent. A distro whose Windows side has no agent looks after
196
- itself, and is the root of its own machine.
197
- - **One upgrade path** ([src/environments/machine-upgrade.ts](src/environments/machine-upgrade.ts)). `intentic-machine upgrade`, from
198
- any side, moves the whole PC to one exact release: the newest of the published one and every side's installed one,
199
- never backwards. A distro hands the job to its Windows side; the root upgrades its distros first and itself last,
200
- since its own restart ends the stream a sandbox is reading. Each side still downloads the tagged asset, probes it,
201
- swaps it in, restarts through its supervisor, checks the build that came up and rolls back when it did not
202
- ([src/upgrade.ts](src/upgrade.ts)), under a per-environment lock so two upgrades never share a download. The Windows
203
- launcher is pinned to the same release and swapped with the agent.
204
- - **Automatic updates** ([src/environments/auto-upgrade.ts](src/environments/auto-upgrade.ts)). The root compares its
205
- sides every hour and brings a lagging one level, and asks the release channel about every six hours, first a few
206
- jittered minutes after it starts. A target that failed is retried after 1, 2, 4… hours, a day at most, and a build
207
- from source is never touched. `intentic-machine updates --agent off` stops the release check but not the levelling,
208
- since sides on different versions is never a state worth keeping; `--sandboxes off` is the image switch above. Both
209
- switches are the root's, and a distro hands the command to it.
210
- - **Setup lands on the machine's version.** Every `setup` first moves its own side onto the newest version the channel
211
- or any side has, re-execs, and once enrolled brings the rest of the PC level in the background.
212
- - **Uninstall stays per environment**, because links and grants differ per side. The Windows side keeps running while
213
- it still keeps a distro, and says so.
214
-
215
- ### Installed vs running
216
-
217
- Two facts, and every surface carries both. `agent.installed` in the machine report is the **file** at
218
- `bin/intentic-machine` ([src/installed.ts](src/installed.ts)); `agent.build` is the **agent** running from it, as its
219
- pidfile stamps it. They drift whenever a binary lands without a restart — a copy dropped in, a swap whose restart did
220
- not take — and a report that carried one version would answer the running build to one reader and the installed build
221
- to another.
222
-
223
- - `intentic-machine status` says which is which, and the summary the tray reads leads with `OLD BUILD RUNNING`.
224
- - The Devices row says it beside the pid, with the two commands that close it.
225
- - `intentic-machine upgrade` restarts an agent that is behind the installed binary even when there is nothing to
226
- download, and after a swap it checks that the agent which came up **is** the new build rather than that some
227
- process is alive — the check the old agent passed just as well as the new one.
228
- - An agent already on the installed build is never bounced, and one that is stopped is never started by an upgrade:
229
- `run --stop` is a thing people do on purpose.
230
-
231
- ### Linked vs connected
232
-
233
- The same gap one level down, on the command whose entire job is to answer "is my machine connected". `device.json`
234
- records the sandboxes this machine is **meant** to answer to and nothing whatever about whether it reaches any of
235
- them, so `status` printed `connected as <id>` for every line in it — including, on the machine this was written
236
- for, a sandbox whose host had been answering 502 for four hours while the agent retried it every 30 seconds and
237
- said so in a log nobody had been pointed at.
238
-
239
- - The agent's stamp is the answer: `status` prints `connected`, `NOT connected (retrying)` or `NOT connected`
240
- per link, and the summary the tray reads counts the links that are actually up (`1 of 2 sandboxes connected`).
241
- - The stamp **ages** on purpose, since it describes sockets held in a process that may be gone. Four ticks past
242
- the last write it is no answer at all — which is also what an agent too old to write one leaves behind — and
243
- both cases print `linked as <id>` with the reason in words. A link nothing can vouch for must not read like a
244
- healthy one; the permissions line beneath it had been hedged as "last pushed by the sandbox" for years for the
245
- same reason, and this line had not.
1
+ # machine
2
+
3
+ `intentic-machine`, the one agent on a user's own computer: it lets a paired sandbox work on the device under scopes enforced locally, and mirrors a sandbox's folder and ports onto it.
4
+
5
+ ```mermaid
6
+ flowchart LR
7
+ shim["Install one-liner<br/>from a sandbox card"] -->|"device setup, sync setup"| machine(["intentic-machine run"])
8
+ machine -->|"outbound WebSocket"| daemon["Sandbox daemon"]
9
+ daemon -->|"MCP tool calls"| policy["Scope check<br/>device/policy.ts"]
10
+ policy --> local["Shell, files, screen,<br/>browser, local sandboxes"]
11
+ machine -->|"Mutagen over tunnelled SSH"| daemon
12
+ machine --> folder["Local folder<br/>and mirrored ports"]
13
+ machine -->|"Windows only"| distros["Agent in each<br/>WSL distro"]
14
+ ```
15
+
16
+ - One resident process per environment (`resident.ts`) serves both halves and re-reads its state every tick. A login
17
+ entry from [local-agent](../local-agent) restarts it; inside a WSL distro the Windows side does.
18
+ - **device** (`src/device/`): `device setup` redeems a one-time pairing token, then the agent keeps a WebSocket
19
+ dialled out to the sandbox and answers MCP tools on it: `run_command`, files, windows and clipboard, `browser_*`
20
+ through [browser](../browser), `screenshot` and `device` through [desktop-automation](../desktop-automation), and
21
+ the intentic sandboxes on this machine through the `ic` CLI.
22
+ - **sync** (`src/sync/`): `sync setup` enrolls an SSH key and runs Mutagen against the sandbox's sshd, reached
23
+ through a loopback port tunnelled over a WebSocket. It keeps a folder two-way synced, forwards every workspace
24
+ port to the same localhost port, and fast-forwards local git clones from the sandbox.
25
+ - Scopes are enforced here and nowhere else: the sandbox only asks, and a refusal names the switch that is off.
26
+ Files stay inside the configured roots, writes need their own switch, and every call is appended to
27
+ `~/.intentic/machine/audit.jsonl`. While an agent drives input on Windows, a notice shows on screen and
28
+ `PAUSE_HOTKEY` pauses every link.
29
+ - Every connection dials out; the only listeners are on loopback.
30
+ - On Windows the Windows side is the root of the PC (`src/environments/`): it holds one `wsl.exe` session per
31
+ distro with an agent, and `upgrade` brings every environment to the same release. The root also updates itself
32
+ on a timer and pre-downloads sandbox updates with `ic sandbox prepare --auto`.
33
+ - The install shims only put a first binary down and run `setup`; `install.ts` decides the rest. `status --json`
34
+ is what the desktop app's tray reads.
246
35
 
247
36
  ## Key files
248
37
 
249
- - [src/commands.ts](src/commands.ts) — the CLI surface: `device setup|uninstall|forget-unreachable`, `sync setup|pause|resume|mirror|uninstall|…`, shared `run|status|version|upgrade|updates|uninstall`, and the hidden `environment attach`.
250
- - [src/install.ts](src/install.ts) — what every `setup` runs first and last: move onto the machine's newest agent (then re-exec), PATH repair, the Windows launcher stub; once enrolled, adopt running distros and level the rest of the PC.
251
- - [src/release.ts](src/release.ts) — the release channel: tagged asset URLs, what `releases/latest` points at, resumable downloads, the `version` probe, and the sweep of what a finished swap leaves in `bin/`.
252
- - [src/upgrade.ts](src/upgrade.ts) — one environment to one exact release: download → probe → swap → restart through the supervisor → check, rolling back a build that will not start, and a restart when the file is current but the agent is not.
253
- - [src/environments/machine-upgrade.ts](src/environments/machine-upgrade.ts) — the machine-wide upgrade: the target rule, the order (distros first, the root last), and the lock.
254
- - [src/environments/children.ts](src/environments/children.ts) — the root keeping each distro's agent running through a held `wsl.exe` session.
255
- - [src/environments/auto-upgrade.ts](src/environments/auto-upgrade.ts) — the root's update tick and its backoff.
256
- - [src/environments/machine.ts](src/environments/machine.ts) — `machine.json` (kept distros, the two update switches, the last failed target) and reaching the Windows side from a distro.
257
- - [src/environments/crossing.ts](src/environments/crossing.ts) — argv that crosses between Windows and a distro, for `run_command`'s `in:` and for the machine's own calls.
258
- - [src/supervision.ts](src/supervision.ts) — start, stop and restart through whoever supervises this environment, and which one that is.
259
- - [src/installed.ts](src/installed.ts) — which build the *file* at `bin/intentic-machine` is, as opposed to the one running: free while the two agree, one probe per swap after they stop.
260
- - [src/daemon-base.ts](src/daemon-base.ts) — where a sandbox's daemon is dialled, for both halves: loopback first when `/health` proves it is ours, the public URL as the floor.
261
- - [src/resident.ts](src/resident.ts) — the one agent: its claim and lease, the per-tick reconcile of links, pairings and distros, and its exits.
262
- - [src/device/auto-prepare.ts](src/device/auto-prepare.ts) — the background update-download tick; the judgement about *what* to download stays in `ic sandbox prepare --auto`, on purpose.
263
- - [src/status.ts](src/status.ts) — both halves as one answer; `--json` is what the desktop app and tray read.
264
- - [src/device/router.ts](src/device/router.ts) — the `deviceContract` this machine serves, including `report`, the reading the sandbox's Devices tab is built from.
265
- - [src/wsl.ts](src/wsl.ts) — whether this is a WSL distro, and which one. WSL hands a distro the Windows machine's own hostname, so without this the sandbox cannot tell a distro from the Windows install hosting it, or one distro from its neighbour; reported at connect (`describe`) as well as in the status report, so it is known even with "Run commands" off.
266
- - [src/device/tools/shell.ts](src/device/tools/shell.ts) — `run_command`, its process group and bounded output, and its `in:` crossing: `wsl:<distro>` from Windows runs `wsl.exe --exec sh -lc` with the script as one argument, `windows` from a distro runs PowerShell through interop; no quoting through the first shell either way.
267
- - [src/device/policy.ts](src/device/policy.ts) — what the sandbox is permitted to do here; the security surface.
268
- - [src/device/tools/sandboxes.ts](src/device/tools/sandboxes.ts) — the fleet: the `docker ps`/`inspect` readers, the docker verbs, and the `ic` flows (swap, reshape, remove, runners) with the pure argv builders beside them.
269
- - [src/sync/mirror.ts](src/sync/mirror.ts) — the sync tick: ports reconcile, git bridge, revocation handling.
270
- - [src/sync/mutagen.ts](src/sync/mutagen.ts) — driving the Mutagen binary, sessions and its daemon's autostart, and classifying a conflict as build output or as two real copies.
271
- - [src/sync/residue.ts](src/sync/residue.ts) — what may be deleted here without asking, and the four separate refusals that keep it to exactly that.
272
-
273
- ## How it fits
274
-
275
- Runs on the user's machine, not in the sandbox. Installed by `device.{sh,ps1}` / `sync.{sh,ps1}` (both cards
276
- put the same binary in `~/.intentic/machine/bin`), shipped as a bun-compiled binary per platform, and kept on one
277
- release across the whole PC by `upgrade` and the root's automatic updates.
278
-
279
- Those four installers are **bootstrap shims**: they download an agent onto a machine that has none (pinned to
280
- the tag `releases/latest` resolves to, resumable, probed by running `version` before it may become the agent)
281
- and exec `setup`. Every other decision — installed-vs-published, PATH repair, the Windows launcher stub — runs
282
- from [src/install.ts](src/install.ts) at the top of every `setup`: it moves this side onto the machine's newest
283
- release through the same download→probe→swap→rollback machinery as `upgrade`, then re-execs the new agent with the
284
- same argv, so re-running a card's command still upgrades a machine while the rule lives in exactly one compiled,
285
- tested place.
286
-
287
- The one decision a shim cannot delegate is whether the installed agent can take the handover at all: `device
288
- setup` is itself part of this CLI's vocabulary, so an agent older than a route rename rejects it — and the
289
- self-update that would have replaced it lives behind that same command. Renaming `computer` to `device` did
290
- that to every machine paired before it. So each shim runs `<route> setup --help` on the installed binary
291
- first, and replaces an agent that cannot answer. The shims' bootstrap blocks are held identical per dialect by
292
- [src/installers.test.ts](src/installers.test.ts), which also pins that probe, that the route is named once per
293
- file, and that no other decision creeps back into shell.
294
-
295
- The install-and-stay-alive plumbing is
296
- [`@intentic/local-agent`](../local-agent)'s; the windowless Windows logon start is
297
- [`_devices/win-launcher`](../win-launcher)'s.
38
+ - [src/commands.ts](src/commands.ts) — the CLI: `device`, `sync`, `run`, `status`, `upgrade`, `uninstall`.
39
+ - [src/resident.ts](src/resident.ts) — the resident process that holds links, pairings and WSL distros.
40
+ - [src/device/mcp.ts](src/device/mcp.ts) — every tool a sandbox can call on this device.
41
+ - [src/device/policy.ts](src/device/policy.ts) — scope checks and the file-root boundary.
42
+ - [src/sync/tunnel.ts](src/sync/tunnel.ts) — the loopback SSH port that fronts the sandbox's sshd.
43
+ - [src/environments/machine.ts](src/environments/machine.ts) — the Windows root and its WSL children.
298
44
 
299
- ## Conventions & gotchas
45
+ ## Commands
300
46
 
301
- - **Bidirectional sync has no undo.** The integration tests here run against real directories and a real
302
- Mutagen for exactly that reason; a unit test that mocks the sync proves nothing about the case that loses work.
303
- - **The two halves keep separate state files** (`device.json`, `sync.json`) in the one home: the agent rewrites
304
- one half's state while a concurrent `setup` writes the other's, and separate files make cross-half torn
305
- writes impossible rather than unlikely.
306
- - **Scopes are a cache.** The sandbox pushes the real grant on every connect; what is stored only governs the
307
- seconds before the first push, and it starts at everything-off.
308
- - **The transport lives in the resident agent**, so `sync setup` starts the agent *before* it probes ssh or hands
309
- anything to Mutagen: every step after that one needs the port to be open.
47
+ ```sh
48
+ pnpm --filter @intentic/machine test
49
+ pnpm turbo run build --filter=./_devices/machine
50
+ node _devices/machine/dist/cli.js status
51
+ ```
@@ -1 +1 @@
1
- {"version":3,"file":"audit.d.ts","sourceRoot":"","sources":["../../src/device/audit.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,KAAK,UAAiB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,KAAG,OAAO,CAAC,IAAI,CAO9F,CAAC"}
1
+ {"version":3,"file":"audit.d.ts","sourceRoot":"","sources":["../../src/device/audit.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,KAAK,UAAiB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,KAAG,OAAO,CAAC,IAAI,CAQ9F,CAAC"}
@@ -1,4 +1,5 @@
1
1
  import { appendFile, mkdir } from "node:fs/promises";
2
+ import { errorMessage } from "@intentic/base/errors";
2
3
  import { baseDir } from "../config.js";
3
4
  import { auditPath } from "./config.js";
4
5
  export const audit = async (entry) => {
@@ -6,7 +7,8 @@ export const audit = async (entry) => {
6
7
  await mkdir(baseDir, { recursive: true, mode: 0o700 });
7
8
  await appendFile(auditPath, `${JSON.stringify({ at: new Date().toISOString(), ...entry })}\n`, { encoding: "utf8", mode: 0o600 });
8
9
  }
9
- catch {
10
+ catch (error) {
11
+ process.stderr.write(`audit: could not record ${entry.tool} in ${auditPath} (${errorMessage(error)})\n`);
10
12
  }
11
13
  };
12
14
  //# sourceMappingURL=audit.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"audit.js","sourceRoot":"","sources":["../../src/device/audit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAIxC,MAAM,CAAC,MAAM,KAAK,GAAG,KAAK,EAAE,KAAoD,EAAiB,EAAE;IAC/F,IAAI,CAAC;QACD,MAAM,KAAK,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;QACvD,MAAM,UAAU,CAAC,SAAS,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,EAAE,GAAG,KAAK,EAAE,CAAC,IAAI,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IACtI,CAAC;IAAC,MAAM,CAAC;IAET,CAAC;AACL,CAAC,CAAC"}
1
+ {"version":3,"file":"audit.js","sourceRoot":"","sources":["../../src/device/audit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAIxC,MAAM,CAAC,MAAM,KAAK,GAAG,KAAK,EAAE,KAAoD,EAAiB,EAAE;IAC/F,IAAI,CAAC;QACD,MAAM,KAAK,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,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63
63
  };
64
64
  const tick = async () => {
65
65
  try {
66
- if ((await readMachineConfig().catch(() => ({ sandboxUpdates: true }))).sandboxUpdates !== false) {
66
+ if ((await readMachineConfig()).sandboxUpdates !== false) {
67
67
  await runTick(state, await fleet(), async (slug) => await runIc(autoPrepareArgs(slug), () => undefined), log);
68
68
  }
69
69
  }
@@ -1 +1 @@
1
- {"version":3,"file":"auto-prepare.js","sourceRoot":"","sources":["../../src/device/auto-prepare.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAG/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAOhE,MAAM,aAAa,GAAG,CAAC,GAAG,MAAM,CAAC;AAEjC,MAAM,OAAO,GAAG,CAAC,GAAG,EAAE,GAAG,MAAM,CAAC;AAEhC,MAAM,SAAS,GAAG,EAAE,GAAG,MAAM,CAAC;AAE9B,MAAM,cAAc,GAAG,CAAC,CAAC;AAIzB,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,KAA+B,EAAY,EAAE,CACxE,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AAGjG,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,QAAgB,EAAU,EAAE,CAAC,CAAC,QAAQ,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC,EAAE,cAAc,CA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AAQ,KAAG,OAAO,CAAC,SAAS,QAAQ,EAAE,CAS5E,CAAC;AAGF,eAAO,MAAM,WAAW,gBAAuB,MAAM,KAAG,OAAO,CAAC,SAAS,QAAQ,EAAE,CAKlF,CAAC;AAIF,eAAO,MAAM,cAAc,eAAsB,MAAM,UAAU,YAAY,KAAG,OAAO,CAAC,IAAI,CAO3F,CAAC"}
@@ -1,5 +1,6 @@
1
1
  import { readFile, rename } from "node:fs/promises";
2
2
  import { join } from "node:path";
3
+ import { undefinedIfMissing } from "@intentic/base/errors";
3
4
  import { writeFileAtomic, writeSecretFile } from "@intentic/local-agent";
4
5
  import { LONG_OUTAGE_ATTEMPTS } from "@intentic/sandbox-contract/peer-dial";
5
6
  import { baseDir } from "../config.js";
@@ -32,7 +33,14 @@ export const readDeviceConfig = async () => {
32
33
  }
33
34
  throw error;
34
35
  });
35
- return raw === undefined ? { links: [] } : JSON.parse(raw);
36
+ if (raw === undefined) {
37
+ return { links: [] };
38
+ }
39
+ const parsed = JSON.parse(raw);
40
+ if (!Array.isArray(parsed?.links)) {
41
+ throw new SyntaxError(`${configPath} has no "links" list`);
42
+ }
43
+ return { ...parsed, links: parsed.links };
36
44
  };
37
45
  export const writeDeviceConfig = async (config) => await writeSecretFile(configPath, baseDir, JSON.stringify(config, undefined, 2));
38
46
  const updateDeviceConfig = async (mutate, { recover = false } = {}) => {
@@ -40,14 +48,14 @@ const updateDeviceConfig = async (mutate, { recover = false } = {}) => {
40
48
  if (!recover || !(error instanceof SyntaxError)) {
41
49
  throw error;
42
50
  }
43
- await rename(configPath, `${configPath}.corrupt`).catch(() => undefined);
51
+ await rename(configPath, `${configPath}.corrupt`).catch(undefinedIfMissing);
44
52
  return { links: [] };
45
53
  });
46
54
  const next = mutate(config);
47
55
  await writeDeviceConfig(next);
48
56
  return next;
49
57
  };
50
- export const readLinks = async () => (await readDeviceConfig()).links ?? [];
58
+ export const readLinks = async () => (await readDeviceConfig()).links;
51
59
  export const upsertLink = async (link) => {
52
60
  const updated = await updateDeviceConfig((config) => ({
53
61
  ...config,
@@ -66,6 +74,6 @@ export const rememberScopes = async (sandboxUrl, scopes) => {
66
74
  const at = config.links.findIndex((link) => link.sandboxUrl === sandboxUrl);
67
75
  const link = config.links[at];
68
76
  return link === undefined ? config : { ...config, links: config.links.with(at, { ...link, scopes }) };
69
- }).catch(() => undefined);
77
+ });
70
78
  };
71
79
  //# sourceMappingURL=config.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/device/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAEzE,OAAO,EAAE,oBAAoB,EAAuC,MAAM,sCAAsC,CAAC;AACjH,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAGvC,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;AACvD,MAAM,CAAC,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;AAGtD,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;AAIzD,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,CAAC;AACnC,MAAM,CAAC,MAAM,mBAAmB,GAAG,aAAa,GAAG,CAAC,CAAC;AAgBrD,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,EAAE,KAA4C,EAAiB,EAAE;IACjG,MAAM,eAAe,CAAC,aAAa,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,KAAK,EAA2B,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;AAC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KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;IAC1G,CAAC,CAAC,CAAC;AACP,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../../src/device/connection.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAEjD,OAAO,EAAkD,KAAK,QAAQ,EAAE,MAAM,sCAAsC,CAAC;AAErH,OAAO,EAAE,KAAK,UAAU,EAAqB,MAAM,mBAAmB,CAAC;AACvE,OAAO,EAAE,KAAK,QAAQ,EAA+B,MAAM,aAAa,CAAC;AACzE,OAAO,EAAE,KAAK,SAAS,EAAoB,MAAM,gBAAgB,CAAC;AASlE,MAAM,WAAW,IAAI;IACjB,QAAQ,CAAC,WAAW,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;IAClE,QAAQ,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,SAAS,CAAC;CAC/C;AAKD,QAAA,MAAM,UAAU,eAAsB,MAAM,KAAG,OAAO,CAAC,IAAI,CAAyC,CAAC;AAErG,eAAO,MAAM,OAAO,WACR,QAAQ,WACP,MAAM,OACV,GAAG,SACF,IAAI,0CAEC,SAAS,KACrB,QA0DF,CAAC"}
1
+ {"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../../src/device/connection.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAEjD,OAAO,EAAkD,KAAK,QAAQ,EAAE,MAAM,sCAAsC,CAAC;AAErH,OAAO,EAAE,KAAK,UAAU,EAAqB,MAAM,mBAAmB,CAAC;AACvE,OAAO,EAAE,KAAK,QAAQ,EAA+B,MAAM,aAAa,CAAC;AACzE,OAAO,EAAE,KAAK,SAAS,EAAoB,MAAM,gBAAgB,CAAC;AASlE,MAAM,WAAW,IAAI;IACjB,QAAQ,CAAC,WAAW,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;IAClE,QAAQ,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,SAAS,CAAC;CAC/C;AAKD,QAAA,MAAM,UAAU,eAAsB,MAAM,KAAG,OAAO,CAAC,IAAI,CAAyC,CAAC;AAErG,eAAO,MAAM,OAAO,WACR,QAAQ,WACP,MAAM,OACV,GAAG,SACF,IAAI,0CAEC,SAAS,KACrB,QA4DF,CAAC"}
@@ -1,4 +1,5 @@
1
1
  import { createBackoff } from "@intentic/base/async";
2
+ import { errorMessage } from "@intentic/base/errors";
2
3
  import { HOST_HEARTBEAT_MS, hostConnectUrl } from "@intentic/sandbox-contract";
3
4
  import { dialPeer, PEER_LINK_BACKOFF, peerLinkSilenceMs } from "@intentic/sandbox-contract/peer-dial";
4
5
  import { RPCHandler } from "@orpc/server/websocket";
@@ -17,7 +18,7 @@ export const connect = (config, version, log, dial = realDial, forget = forgetLi
17
18
  scopes: () => scopes,
18
19
  setScopes: (next) => {
19
20
  scopes = next;
20
- void rememberScopes(config.sandboxUrl, next);
21
+ void rememberScopes(config.sandboxUrl, next).catch((error) => linkLog(`could not save the permissions it pushed (${errorMessage(error)}); this connection enforces them regardless.`));
21
22
  },
22
23
  log,
23
24
  }));
@@ -1 +1 @@
1
- {"version":3,"file":"connection.js","sourceRoot":"","sources":["../../src/device/connection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAqB,MAAM,4BAA4B,CAAC;AAClG,OAAO,EAAE,QAAQ,EAAE,iBAAiB,EAAE,iBAAiB,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,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC;CACrB;AACD,eAAO,MAAM,OAAO,2BAAkC,CAAC;AAGvD,MAAM,WAAW,aAAa;IAE1B,QAAQ,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE,YAAY,KAAK,MAAM,GAAG,SAAS,CAAC;IAC5D,QAAQ,CAAC,MAAM,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;IACxC,QAAQ,CAAC,SAAS,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACvD,QAAQ,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,OAAO,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3F;AAED,MAAM,WAAW,SAAS;IAEtB,QAAQ,CAAC,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAEhE,QAAQ,CAAC,OAAO,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,CAAC;CAClD;AAOD,eAAO,MAAM,eAAe,SAAU,aAAa,KAAG,SA8FrD,CAAC;AAKF,eAAO,MAAM,gBAAgB,QAAO,SAa7B,CAAC"}
@@ -1,7 +1,7 @@
1
1
  import { AsyncLocalStorage } from "node:async_hooks";
2
2
  import { mkdir, rm, stat, writeFile } from "node:fs/promises";
3
3
  import { join } from "node:path";
4
- import { errorMessage } from "@intentic/base/errors";
4
+ import { errorMessage, undefinedIfMissing } from "@intentic/base/errors";
5
5
  import { notice } from "@intentic/desktop-automation";
6
6
  import { baseDir } from "../config.js";
7
7
  import { audit } from "./audit.js";
@@ -9,7 +9,7 @@ import { ScopeError } from "./policy.js";
9
9
  export const PAUSE_HOTKEY = "Ctrl+Alt+Shift+P";
10
10
  export const IDLE_MS = 30_000;
11
11
  const pausePath = join(baseDir, "paused");
12
- export const readPausedAt = async () => (await stat(pausePath).catch(() => undefined))?.mtime;
12
+ export const readPausedAt = async () => (await stat(pausePath).catch(undefinedIfMissing))?.mtime;
13
13
  export const calling = new AsyncLocalStorage();
14
14
  const PAUSED = `Refused: paused by the person at this computer: they pressed ${PAUSE_HOTKEY}, which stops agents from using its mouse and keyboard until they press it again. Tell the user; do not look for another way to do this on the screen.`;
15
15
  const hostOf = (sandboxUrl) => URL.parse(sandboxUrl)?.host ?? sandboxUrl;