@intentic/machine 1.308.2 → 1.310.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.
- package/README.md +52 -2
- package/dist/daemon-base.d.ts +7 -0
- package/dist/daemon-base.d.ts.map +1 -1
- package/dist/daemon-base.js +22 -0
- package/dist/daemon-base.js.map +1 -1
- package/dist/device/commands.d.ts.map +1 -1
- package/dist/device/commands.js +12 -41
- package/dist/device/commands.js.map +1 -1
- package/dist/device/connection.d.ts +2 -1
- package/dist/device/connection.d.ts.map +1 -1
- package/dist/device/connection.js +13 -2
- package/dist/device/connection.js.map +1 -1
- package/dist/device/indicator.d.ts +28 -0
- package/dist/device/indicator.d.ts.map +1 -0
- package/dist/device/indicator.js +115 -0
- package/dist/device/indicator.js.map +1 -0
- package/dist/device/mcp.d.ts.map +1 -1
- package/dist/device/mcp.js +62 -8
- package/dist/device/mcp.js.map +1 -1
- package/dist/device/policy.d.ts +4 -1
- package/dist/device/policy.d.ts.map +1 -1
- package/dist/device/policy.js +23 -5
- package/dist/device/policy.js.map +1 -1
- package/dist/device/router.d.ts +2 -0
- package/dist/device/router.d.ts.map +1 -1
- package/dist/device/router.js +4 -3
- package/dist/device/router.js.map +1 -1
- package/dist/device/tools/agent.d.ts.map +1 -1
- package/dist/device/tools/agent.js +9 -12
- package/dist/device/tools/agent.js.map +1 -1
- package/dist/device/tools/apps.d.ts +3 -2
- package/dist/device/tools/apps.d.ts.map +1 -1
- package/dist/device/tools/apps.js +5 -2
- package/dist/device/tools/apps.js.map +1 -1
- package/dist/device/tools/describe.d.ts +0 -1
- package/dist/device/tools/describe.d.ts.map +1 -1
- package/dist/device/tools/describe.js +3 -12
- package/dist/device/tools/describe.js.map +1 -1
- package/dist/device/tools/device.d.ts +2 -1
- package/dist/device/tools/device.d.ts.map +1 -1
- package/dist/device/tools/device.js +30 -37
- package/dist/device/tools/device.js.map +1 -1
- package/dist/device/tools/files.d.ts +14 -2
- package/dist/device/tools/files.d.ts.map +1 -1
- package/dist/device/tools/files.js +164 -16
- package/dist/device/tools/files.js.map +1 -1
- package/dist/device/tools/sandboxes.d.ts +7 -4
- package/dist/device/tools/sandboxes.d.ts.map +1 -1
- package/dist/device/tools/sandboxes.js +22 -10
- package/dist/device/tools/sandboxes.js.map +1 -1
- package/dist/device/tools/shell.d.ts +7 -2
- package/dist/device/tools/shell.d.ts.map +1 -1
- package/dist/device/tools/shell.js +101 -43
- package/dist/device/tools/shell.js.map +1 -1
- package/dist/environments/auto-upgrade.d.ts +1 -1
- package/dist/environments/auto-upgrade.d.ts.map +1 -1
- package/dist/environments/auto-upgrade.js +4 -10
- package/dist/environments/auto-upgrade.js.map +1 -1
- package/dist/environments/commands.d.ts.map +1 -1
- package/dist/environments/commands.js +6 -6
- package/dist/environments/commands.js.map +1 -1
- package/dist/environments/crossing.d.ts +2 -5
- package/dist/environments/crossing.d.ts.map +1 -1
- package/dist/environments/crossing.js +6 -6
- package/dist/environments/crossing.js.map +1 -1
- package/dist/environments/machine-upgrade.d.ts +2 -1
- package/dist/environments/machine-upgrade.d.ts.map +1 -1
- package/dist/environments/machine-upgrade.js +24 -20
- package/dist/environments/machine-upgrade.js.map +1 -1
- package/dist/environments/machine.d.ts +1 -0
- package/dist/environments/machine.d.ts.map +1 -1
- package/dist/environments/machine.js +2 -1
- package/dist/environments/machine.js.map +1 -1
- package/dist/install.d.ts +1 -1
- package/dist/install.d.ts.map +1 -1
- package/dist/install.js +5 -13
- package/dist/install.js.map +1 -1
- package/dist/release.d.ts +1 -10
- package/dist/release.d.ts.map +1 -1
- package/dist/release.js +4 -16
- package/dist/release.js.map +1 -1
- package/dist/resident.d.ts.map +1 -1
- package/dist/resident.js +6 -9
- package/dist/resident.js.map +1 -1
- package/dist/status.d.ts +1 -0
- package/dist/status.d.ts.map +1 -1
- package/dist/status.js +16 -5
- package/dist/status.js.map +1 -1
- package/dist/supervision.d.ts.map +1 -1
- package/dist/supervision.js +12 -14
- package/dist/supervision.js.map +1 -1
- package/dist/sync/commands.d.ts.map +1 -1
- package/dist/sync/commands.js +91 -141
- package/dist/sync/commands.js.map +1 -1
- package/dist/sync/mutagen.d.ts.map +1 -1
- package/dist/sync/mutagen.js +6 -9
- package/dist/sync/mutagen.js.map +1 -1
- package/dist/sync/residue.d.ts +1 -1
- package/dist/sync/residue.d.ts.map +1 -1
- package/dist/sync/residue.js +17 -47
- package/dist/sync/residue.js.map +1 -1
- package/dist/upgrade.d.ts +1 -2
- package/dist/upgrade.d.ts.map +1 -1
- package/dist/upgrade.js +6 -13
- package/dist/upgrade.js.map +1 -1
- package/dist/wsl.d.ts +3 -0
- package/dist/wsl.d.ts.map +1 -1
- package/dist/wsl.js +5 -2
- package/dist/wsl.js.map +1 -1
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -17,9 +17,29 @@ The **device half** (`src/device/`, the machine side of the `host` capability):
|
|
|
17
17
|
machine *serves* `deviceContract`, so no port ever opens here. Where it dials is the shared resolver's answer
|
|
18
18
|
(below), re-asked on every reconnect, so a sandbox on this very machine stays connected with its tunnel down.
|
|
19
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.
|
|
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.
|
|
21
23
|
- Enforce the owner's scopes **here**, never in the sandbox, and append every call to an audit log that
|
|
22
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.
|
|
23
43
|
- Manage this machine's sandboxes for a browser button or a model, under the `sandboxes` switch: list them
|
|
24
44
|
with their **share of the machine** (one `docker inspect` per listing: memory and CPU caps, privileged, GPU,
|
|
25
45
|
and who asked for each directive, the approved environment or the owner), start/stop/restart, run the `ic`
|
|
@@ -101,6 +121,36 @@ tab, with every button there gone, while this same process was polling it over l
|
|
|
101
121
|
a pairing sitting on the public URL each minute, so a container started later is promoted with no restart; the
|
|
102
122
|
socket re-resolves on every reconnect.
|
|
103
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
|
+
|
|
104
154
|
## The resident agent
|
|
105
155
|
|
|
106
156
|
`intentic-machine run --foreground` (what systemd, launchd, the Windows logon task and, for a distro, its Windows side
|
|
@@ -213,7 +263,7 @@ said so in a log nobody had been pointed at.
|
|
|
213
263
|
- [src/status.ts](src/status.ts) — both halves as one answer; `--json` is what the desktop app and tray read.
|
|
214
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.
|
|
215
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.
|
|
216
|
-
- [src/device/tools/shell.ts](src/device/tools/shell.ts) — `run_command`, 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.
|
|
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.
|
|
217
267
|
- [src/device/policy.ts](src/device/policy.ts) — what the sandbox is permitted to do here; the security surface.
|
|
218
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.
|
|
219
269
|
- [src/sync/mirror.ts](src/sync/mirror.ts) — the sync tick: ports reconcile, git bridge, revocation handling.
|
package/dist/daemon-base.d.ts
CHANGED
|
@@ -8,6 +8,13 @@ export interface DaemonBase {
|
|
|
8
8
|
readonly local: boolean;
|
|
9
9
|
}
|
|
10
10
|
export declare const resolveDaemonBase: (sandboxUrl: string, fetchImpl?: FetchImpl) => Promise<DaemonBase>;
|
|
11
|
+
export interface WarmingAsk {
|
|
12
|
+
readonly doing: string;
|
|
13
|
+
readonly expired: string;
|
|
14
|
+
readonly attempts?: number | undefined;
|
|
15
|
+
readonly delayMs?: number | undefined;
|
|
16
|
+
}
|
|
17
|
+
export declare const postWhileWarming: (sandboxUrl: string, path: string, init: RequestInit, ask: WarmingAsk) => Promise<Response>;
|
|
11
18
|
export declare const PROMOTION_INTERVAL_MS = 60000;
|
|
12
19
|
export interface DaemonTarget {
|
|
13
20
|
readonly sandboxId: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"daemon-base.d.ts","sourceRoot":"","sources":["../src/daemon-base.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"daemon-base.d.ts","sourceRoot":"","sources":["../src/daemon-base.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAajD,MAAM,MAAM,SAAS,GAAG,CAAC,KAAK,EAAE,WAAW,GAAG,GAAG,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;AAK5F,eAAO,MAAM,UAAU,eAAgB,MAAM,KAAG,MAAM,GAAG,SAGxD,CAAC;AAIF,eAAO,MAAM,cAAc,eAAgB,MAAM,KAAG,SAAS,MAAM,EASlE,CAAC;AAIF,eAAO,MAAM,eAAe,SAAgB,MAAM,cAAc,MAAM,cAAa,SAAS,KAAW,OAAO,CAAC,OAAO,CAWrH,CAAC;AAIF,MAAM,WAAW,UAAU;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;CAC3B;AAID,eAAO,MAAM,iBAAiB,eAAsB,MAAM,cAAa,SAAS,KAAW,OAAO,CAAC,UAAU,CAc5G,CAAC;AAEF,MAAM,WAAW,UAAU;IAEvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAEvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACzC;AAGD,eAAO,MAAM,gBAAgB,eAAsB,MAAM,QAAQ,MAAM,QAAQ,WAAW,OAAO,UAAU,KAAG,OAAO,CAAC,QAAQ,CAqB7H,CAAC;AAMF,eAAO,MAAM,qBAAqB,QAAS,CAAC;AAI5C,MAAM,WAAW,YAAY;IACzB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC/B;AAUD,MAAM,WAAW,WAAW;IACxB,QAAQ,CAAC,OAAO,EAAE,CAAC,OAAO,EAAE,YAAY,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IAC7D,QAAQ,CAAC,MAAM,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;CAChD;AAID,eAAO,MAAM,iBAAiB,QAAS,GAAG,cAAa,SAAS,QAAe,MAAM,MAAM,KAAc,WA8BxG,CAAC;AAGF,MAAM,WAAW,MAAM,CAAC,CAAC,SAAS,YAAY;IAC1C,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACzB;AAGD,eAAO,MAAM,cAAc,GAAU,CAAC,SAAS,YAAY,YAAY,SAAS,CAAC,EAAE,SAAS,WAAW,KAAG,OAAO,CAAC,SAAS,MAAM,CAAC,CAAC,CAAC,EAAE,CAC7B,CAAC"}
|
package/dist/daemon-base.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { sleep } from "@intentic/base/async";
|
|
1
2
|
import { sandboxIdFromUrl } from "@intentic/sandbox-contract";
|
|
2
3
|
import { localDaemonUrlInsecure } from "@intentic/sandbox-run";
|
|
3
4
|
const PROBE_TIMEOUT_MS = 1500;
|
|
@@ -41,6 +42,27 @@ export const resolveDaemonBase = async (sandboxUrl, fetchImpl = fetch) => {
|
|
|
41
42
|
}
|
|
42
43
|
return { base: sandboxUrl.replace(/\/$/, ""), local: false };
|
|
43
44
|
};
|
|
45
|
+
export const postWhileWarming = async (sandboxUrl, path, init, ask) => {
|
|
46
|
+
const { doing, expired, attempts = 10, delayMs = 3000 } = ask;
|
|
47
|
+
for (let attempt = 1;; attempt++) {
|
|
48
|
+
const { base } = await resolveDaemonBase(sandboxUrl);
|
|
49
|
+
const response = await fetch(`${base}${path}`, { ...init, method: "POST" }).catch((error) => {
|
|
50
|
+
if (attempt >= attempts) {
|
|
51
|
+
throw error;
|
|
52
|
+
}
|
|
53
|
+
return undefined;
|
|
54
|
+
});
|
|
55
|
+
if (response?.status === 401) {
|
|
56
|
+
throw new Error(expired);
|
|
57
|
+
}
|
|
58
|
+
if (response !== undefined && (response.status < 500 || attempt >= attempts)) {
|
|
59
|
+
return response;
|
|
60
|
+
}
|
|
61
|
+
const why = response === undefined ? "the sandbox isn't reachable yet" : `the sandbox is warming up (HTTP ${response.status})`;
|
|
62
|
+
process.stderr.write(`${doing}: ${why}, retrying (${attempt}/${attempts})…\n`);
|
|
63
|
+
await sleep(delayMs);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
44
66
|
export const PROMOTION_INTERVAL_MS = 60_000;
|
|
45
67
|
export const createDaemonBases = (log, fetchImpl = fetch, now = Date.now) => {
|
|
46
68
|
const held = new Map();
|
package/dist/daemon-base.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"daemon-base.js","sourceRoot":"","sources":["../src/daemon-base.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"daemon-base.js","sourceRoot":"","sources":["../src/daemon-base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAE7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAQ/D,MAAM,gBAAgB,GAAG,IAAI,CAAC;AAM9B,MAAM,S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,EAAE,IAAI,EAAE,CAAC,CAAC;YAClD,CAAC;QACL,CAAC;KACJ,CAAC;AACN,CAAC,CAAC;AASF,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,EAA0B,QAAsB,EAAE,KAAkB,EAAiC,EAAE,CACtI,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../../src/device/commands.ts"],"names":[],"mappings":"AAGA,OAAO,EAAY,KAAK,GAAG,EAA0B,MAAM,uBAAuB,CAAC;AACnF,OAAO,EAAgB,KAAK,cAAc,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../../src/device/commands.ts"],"names":[],"mappings":"AAGA,OAAO,EAAY,KAAK,GAAG,EAA0B,MAAM,uBAAuB,CAAC;AACnF,OAAO,EAAgB,KAAK,cAAc,EAAE,MAAM,eAAe,CAAC;AAsHlE,eAAO,MAAM,eAAe,QAAe,GAAG,YAAY,MAAM,KAAG,OAAO,CAAC,IAAI,CAyB9E,CAAC;AAgBF,eAAO,MAAM,oBAAoB,QAAe,GAAG,KAAG,OAAO,CAAC,IAAI,CA0BjE,CAAC;AAEF,eAAO,MAAM,cAAc;;;;CAAgE,CAAC"}
|
package/dist/device/commands.js
CHANGED
|
@@ -1,41 +1,18 @@
|
|
|
1
1
|
import { rm } from "node:fs/promises";
|
|
2
|
-
import {
|
|
2
|
+
import { pollUntil } from "@intentic/base/async";
|
|
3
3
|
import { plural } from "@intentic/base/format";
|
|
4
4
|
import { createUi } from "@intentic/local-agent";
|
|
5
5
|
import { buildCommand } from "@stricli/core";
|
|
6
|
-
import {
|
|
6
|
+
import { postWhileWarming } from "../daemon-base.js";
|
|
7
7
|
import { completeSetup, prepareSetup } from "../install.js";
|
|
8
8
|
import { ensureResident } from "../resident.js";
|
|
9
|
-
import { auditPath, configPath, readLinks, readLinkStates, removeLinks, unreachableIn, upsertLink
|
|
10
|
-
const enroll = async (sandboxUrl, pairToken
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
let response;
|
|
15
|
-
try {
|
|
16
|
-
response = await fetch(url, { method: "POST", headers: { "x-intentic-pair": pairToken } });
|
|
17
|
-
}
|
|
18
|
-
catch (error) {
|
|
19
|
-
if (attempt >= attempts) {
|
|
20
|
-
throw error;
|
|
21
|
-
}
|
|
22
|
-
process.stderr.write(`connecting: the sandbox isn't reachable yet, retrying (${attempt}/${attempts})…\n`);
|
|
23
|
-
await sleep(delayMs);
|
|
24
|
-
continue;
|
|
25
|
-
}
|
|
26
|
-
if (response.status === 401) {
|
|
27
|
-
throw new Error("that pairing has expired: click Connect again on the device's card in your sandbox for a fresh command.");
|
|
28
|
-
}
|
|
29
|
-
if (response.status >= 500 && attempt < attempts) {
|
|
30
|
-
process.stderr.write(`connecting: the sandbox is warming up (HTTP ${response.status}), retrying (${attempt}/${attempts})…\n`);
|
|
31
|
-
await sleep(delayMs);
|
|
32
|
-
continue;
|
|
33
|
-
}
|
|
34
|
-
if (!response.ok) {
|
|
35
|
-
throw new Error(`connecting this device failed (${response.status}): ${await response.text()}`);
|
|
36
|
-
}
|
|
37
|
-
return (await response.json());
|
|
9
|
+
import { auditPath, configPath, readLinks, readLinkStates, removeLinks, unreachableIn, upsertLink } from "./config.js";
|
|
10
|
+
const enroll = async (sandboxUrl, pairToken) => {
|
|
11
|
+
const response = await postWhileWarming(sandboxUrl, "/system/hosts/enroll", { headers: { "x-intentic-pair": pairToken } }, { doing: "connecting", expired: "that pairing has expired: click Connect again on the device's card in your sandbox for a fresh command." });
|
|
12
|
+
if (!response.ok) {
|
|
13
|
+
throw new Error(`connecting this device failed (${response.status}): ${await response.text()}`);
|
|
38
14
|
}
|
|
15
|
+
return (await response.json());
|
|
39
16
|
};
|
|
40
17
|
const setup = buildCommand({
|
|
41
18
|
docs: { brief: "Connect this device to an intentic sandbox using a one-time pairing token" },
|
|
@@ -86,16 +63,10 @@ const runSetup = async (ui, out, flags) => {
|
|
|
86
63
|
};
|
|
87
64
|
const LINK_OPEN_TIMEOUT_MS = 20_000;
|
|
88
65
|
const LINK_OPEN_POLL_MS = 500;
|
|
89
|
-
const linkOpens = async (url) => {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
return true;
|
|
94
|
-
}
|
|
95
|
-
await sleep(LINK_OPEN_POLL_MS);
|
|
96
|
-
}
|
|
97
|
-
return false;
|
|
98
|
-
};
|
|
66
|
+
const linkOpens = async (url) => await pollUntil(async () => (await readLinkStates())?.[url]?.state === "open", {
|
|
67
|
+
intervalMs: LINK_OPEN_POLL_MS,
|
|
68
|
+
timeoutMs: LINK_OPEN_TIMEOUT_MS,
|
|
69
|
+
});
|
|
99
70
|
const uninstall = buildCommand({
|
|
100
71
|
docs: { brief: "Disconnect this device from one sandbox, or from all of them" },
|
|
101
72
|
parameters: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commands.js","sourceRoot":"","sources":["../../src/device/commands.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AACtC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"commands.js","sourceRoot":"","sources":["../../src/device/commands.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAoC,MAAM,uBAAuB,CAAC;AACnF,OAAO,EAAE,YAAY,EAAuB,MAAM,eAA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M,EAAE,MAAM,CAAC,qBAAqB,CAAC,CAAC;QACpH,OAAO;IACX,CAAC;IACD,KAAK,MAAM,EAAE,GAAG,EAAE,IAAI,IAAI,EAAE,CAAC;QAEzB,MAAM,WAAW,CAAC,GAAG,CAAC,CAAC;IAC3B,CAAC;IACD,MAAM,IAAI,GAAG,MAAM,SAAS,EAAE,CAAC;IAE/B,MAAM,cAAc,CAAC,GAAG,CAAC,CAAC;IAC1B,GAAG,CAAC,WAAW,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,kBAAkB,CAAC,KAAK,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACrG,GAAG,CACC,IAAI,CAAC,MAAM,KAAK,CAAC;QACb,CAAC,CAAC,sHAAsH;QACxH,CAAC,CAAC,sBAAsB,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,SAAS,EAAE,WAAW,CAAC,GAAG,CAC7E,CAAC;AACN,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG,EAAE,KAAK,EAAE,SAAS,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,CAAC"}
|
|
@@ -2,11 +2,12 @@ import type { Log } from "@intentic/local-agent";
|
|
|
2
2
|
import { type PeerLink } from "@intentic/sandbox-contract/peer-dial";
|
|
3
3
|
import { type DaemonBase } from "../daemon-base.js";
|
|
4
4
|
import { type HostLink } from "./config.js";
|
|
5
|
+
import { type Indicator } from "./indicator.js";
|
|
5
6
|
export interface Dial {
|
|
6
7
|
readonly resolveBase: (sandboxUrl: string) => Promise<DaemonBase>;
|
|
7
8
|
readonly socket: (url: string) => WebSocket;
|
|
8
9
|
}
|
|
9
10
|
declare const forgetLink: (sandboxUrl: string) => Promise<void>;
|
|
10
|
-
export declare const connect: (config: HostLink, version: string, log: Log, dial?: Dial, forget?: typeof forgetLink) => PeerLink;
|
|
11
|
+
export declare const connect: (config: HostLink, version: string, log: Log, dial?: Dial, forget?: typeof forgetLink, indicator?: Indicator) => PeerLink;
|
|
11
12
|
export {};
|
|
12
13
|
//# sourceMappingURL=connection.d.ts.map
|
|
@@ -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;
|
|
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"}
|
|
@@ -4,13 +4,16 @@ import { dialPeer, PEER_LINK_BACKOFF, peerLinkSilenceMs } from "@intentic/sandbo
|
|
|
4
4
|
import { RPCHandler } from "@orpc/server/websocket";
|
|
5
5
|
import { resolveDaemonBase } from "../daemon-base.js";
|
|
6
6
|
import { rememberScopes, removeLinks } from "./config.js";
|
|
7
|
+
import { machineIndicator } from "./indicator.js";
|
|
7
8
|
import { createHostRouter } from "./router.js";
|
|
8
9
|
const realDial = { resolveBase: resolveDaemonBase, socket: (url) => new WebSocket(url) };
|
|
9
10
|
const forgetLink = async (sandboxUrl) => void (await removeLinks(sandboxUrl));
|
|
10
|
-
export const connect = (config, version, log, dial = realDial, forget = forgetLink) => {
|
|
11
|
+
export const connect = (config, version, log, dial = realDial, forget = forgetLink, indicator = machineIndicator()) => {
|
|
11
12
|
const linkLog = (message) => log(`${config.sandboxUrl}: ${message}`);
|
|
12
13
|
let scopes = config.scopes;
|
|
14
|
+
let held;
|
|
13
15
|
const handler = new RPCHandler(createHostRouter({
|
|
16
|
+
sandboxUrl: config.sandboxUrl,
|
|
14
17
|
scopes: () => scopes,
|
|
15
18
|
setScopes: (next) => {
|
|
16
19
|
scopes = next;
|
|
@@ -30,7 +33,15 @@ export const connect = (config, version, log, dial = realDial, forget = forgetLi
|
|
|
30
33
|
};
|
|
31
34
|
},
|
|
32
35
|
hello: () => ({ type: "hello", token: config.token, version }),
|
|
33
|
-
attach: (ws) =>
|
|
36
|
+
attach: (ws) => {
|
|
37
|
+
held = ws;
|
|
38
|
+
ws.addEventListener("close", () => {
|
|
39
|
+
if (held === ws) {
|
|
40
|
+
indicator.release(config.sandboxUrl);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
handler.upgrade(ws);
|
|
44
|
+
},
|
|
34
45
|
backoff: createBackoff(PEER_LINK_BACKOFF),
|
|
35
46
|
silenceMs: peerLinkSilenceMs(HOST_HEARTBEAT_MS),
|
|
36
47
|
log: linkLog,
|
|
@@ -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,EAAiB,MAAM,sCAAsC,CAAC;AACrH,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAmB,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACvE,OAAO,EAAiB,cAAc,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAa/C,MAAM,QAAQ,GAAS,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC;AAG/F,MAAM,UAAU,GAAG,KAAK,EAAE,UAAkB,EAAiB,EAAE,CAAC,KAAK,CAAC,MAAM,WAAW,CAAC,UAAU,CAAC,CAAC,CAAC;AAErG,MAAM,CAAC,MAAM,OAAO,GAAG,
|
|
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,EAAiB,MAAM,sCAAsC,CAAC;AACrH,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAmB,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACvE,OAAO,EAAiB,cAAc,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACzE,OAAO,EAAkB,gBAAgB,EAAE,M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@intentic/desktop-automation";
|
|
3
|
+
import type { Log } from "@intentic/local-agent";
|
|
4
|
+
export declare const PAUSE_HOTKEY = "Ctrl+Alt+Shift+P";
|
|
5
|
+
export declare const IDLE_MS = 30000;
|
|
6
|
+
export declare const readPausedAt: () => Promise<Date | undefined>;
|
|
7
|
+
export interface Caller {
|
|
8
|
+
readonly sandboxUrl: string;
|
|
9
|
+
readonly log: Log;
|
|
10
|
+
}
|
|
11
|
+
export declare const calling: AsyncLocalStorage<Caller>;
|
|
12
|
+
export interface IndicatorDeps {
|
|
13
|
+
readonly open: (events: NoticeEvents) => Notice | undefined;
|
|
14
|
+
readonly paused: () => Promise<boolean>;
|
|
15
|
+
readonly setPaused: (paused: boolean) => Promise<void>;
|
|
16
|
+
readonly audit: (entry: {
|
|
17
|
+
tool: string;
|
|
18
|
+
ok: boolean;
|
|
19
|
+
detail: string;
|
|
20
|
+
}) => Promise<void>;
|
|
21
|
+
}
|
|
22
|
+
export interface Indicator {
|
|
23
|
+
readonly control: (caller: Caller | undefined) => Promise<void>;
|
|
24
|
+
readonly release: (sandboxUrl: string) => void;
|
|
25
|
+
}
|
|
26
|
+
export declare const createIndicator: (deps: IndicatorDeps) => Indicator;
|
|
27
|
+
export declare const machineIndicator: () => Indicator;
|
|
28
|
+
//# sourceMappingURL=indicator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"indicator.d.ts","sourceRoot":"","sources":["../../src/device/indicator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAIrD,OAAO,EAAU,KAAK,MAAM,EAAE,KAAK,YAAY,EAAE,MAAM,8BAA8B,CAAC;AACtF,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAUjD,eAAO,MAAM,YAAY,qBAAqB,CAAC;AAG/C,eAAO,MAAM,OAAO,QAAS,CAAC;AAM9B,eAAO,MAAM,YAAY,QAAa,OAAO,CAAC,IAAI,GAAG,SAAS,CAA0D,CAAC;AAIzH,MAAM,WAAW,MAAM;IACnB,QAAQ,CAAC,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"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
|
+
import { mkdir, rm, stat, writeFile } from "node:fs/promises";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { errorMessage } from "@intentic/base/errors";
|
|
5
|
+
import { notice } from "@intentic/desktop-automation";
|
|
6
|
+
import { baseDir } from "../config.js";
|
|
7
|
+
import { audit } from "./audit.js";
|
|
8
|
+
import { ScopeError } from "./policy.js";
|
|
9
|
+
export const PAUSE_HOTKEY = "Ctrl+Alt+Shift+P";
|
|
10
|
+
export const IDLE_MS = 30_000;
|
|
11
|
+
const pausePath = join(baseDir, "paused");
|
|
12
|
+
export const readPausedAt = async () => (await stat(pausePath).catch(() => undefined))?.mtime;
|
|
13
|
+
export const calling = new AsyncLocalStorage();
|
|
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
|
+
const hostOf = (sandboxUrl) => URL.parse(sandboxUrl)?.host ?? sandboxUrl;
|
|
16
|
+
export const createIndicator = (deps) => {
|
|
17
|
+
const driving = new Map();
|
|
18
|
+
let shown;
|
|
19
|
+
let paused;
|
|
20
|
+
let broken = false;
|
|
21
|
+
let hotkey = true;
|
|
22
|
+
let saved = Promise.resolve();
|
|
23
|
+
const latest = () => [...driving.values()].at(-1)?.caller;
|
|
24
|
+
const log = (message) => latest()?.log(message);
|
|
25
|
+
const text = () => {
|
|
26
|
+
const caller = latest();
|
|
27
|
+
const who = caller === undefined ? "" : ` · ${hostOf(caller.sandboxUrl)}`;
|
|
28
|
+
const keys = hotkey ? ` · ${PAUSE_HOTKEY} ${paused === true ? "resumes" : "pauses"}` : "";
|
|
29
|
+
return `${paused === true ? "Intentic agent paused" : "Intentic agent is controlling this computer"}${who}${keys}`;
|
|
30
|
+
};
|
|
31
|
+
const toggle = () => {
|
|
32
|
+
const now = paused !== true;
|
|
33
|
+
paused = now;
|
|
34
|
+
saved = saved.then(async () => await deps.setPaused(now)).catch((error) => log(`could not save the pause: ${errorMessage(error)}`));
|
|
35
|
+
const detail = `${now ? "paused" : "resumed"} by the person at this computer (${PAUSE_HOTKEY})`;
|
|
36
|
+
log(detail);
|
|
37
|
+
void deps.audit({ tool: "local-pause", ok: true, detail });
|
|
38
|
+
shown?.show(text());
|
|
39
|
+
};
|
|
40
|
+
const open = () => {
|
|
41
|
+
try {
|
|
42
|
+
shown = deps.open({
|
|
43
|
+
hotkey: toggle,
|
|
44
|
+
hotkeyTaken: () => {
|
|
45
|
+
hotkey = false;
|
|
46
|
+
log(`${PAUSE_HOTKEY} is held by another program, so it cannot pause agents here until that program lets go of it.`);
|
|
47
|
+
shown?.show(text());
|
|
48
|
+
},
|
|
49
|
+
exited: (said) => {
|
|
50
|
+
shown = undefined;
|
|
51
|
+
broken = true;
|
|
52
|
+
log(`the on-screen notice stopped: ${said}`);
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
broken = true;
|
|
58
|
+
log(`the on-screen notice could not open: ${errorMessage(error)}`);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
const release = (sandboxUrl) => {
|
|
62
|
+
const entry = driving.get(sandboxUrl);
|
|
63
|
+
if (entry === undefined) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
clearTimeout(entry.timer);
|
|
67
|
+
driving.delete(sandboxUrl);
|
|
68
|
+
if (driving.size > 0) {
|
|
69
|
+
shown?.show(text());
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
const closing = shown;
|
|
73
|
+
shown = undefined;
|
|
74
|
+
broken = false;
|
|
75
|
+
hotkey = true;
|
|
76
|
+
closing?.close();
|
|
77
|
+
};
|
|
78
|
+
return {
|
|
79
|
+
control: async (caller) => {
|
|
80
|
+
if (paused === undefined) {
|
|
81
|
+
const onDisk = await deps.paused();
|
|
82
|
+
paused ??= onDisk;
|
|
83
|
+
}
|
|
84
|
+
const key = caller?.sandboxUrl ?? "";
|
|
85
|
+
clearTimeout(driving.get(key)?.timer);
|
|
86
|
+
driving.delete(key);
|
|
87
|
+
const timer = setTimeout(() => release(key), IDLE_MS);
|
|
88
|
+
timer.unref();
|
|
89
|
+
driving.set(key, { caller, timer });
|
|
90
|
+
if (shown === undefined && !broken) {
|
|
91
|
+
open();
|
|
92
|
+
}
|
|
93
|
+
shown?.show(text());
|
|
94
|
+
if (paused) {
|
|
95
|
+
throw new ScopeError(PAUSED);
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
release,
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
let machine;
|
|
102
|
+
export const machineIndicator = () => (machine ??= createIndicator({
|
|
103
|
+
open: (events) => notice(PAUSE_HOTKEY, events),
|
|
104
|
+
paused: async () => (await readPausedAt()) !== undefined,
|
|
105
|
+
setPaused: async (paused) => {
|
|
106
|
+
if (!paused) {
|
|
107
|
+
await rm(pausePath, { force: true });
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
await mkdir(baseDir, { recursive: true, mode: 0o700 });
|
|
111
|
+
await writeFile(pausePath, "", { mode: 0o600 });
|
|
112
|
+
},
|
|
113
|
+
audit,
|
|
114
|
+
}));
|
|
115
|
+
//# sourceMappingURL=indicator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"indicator.js","sourceRoot":"","sources":["../../src/device/indicator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAkC,MAAM,8BAA8B,CAAC;AAEtF,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAOzC,MAAM,CAAC,MAAM,YAAY,GAAG,kBAAkB,CAAC;AAG/C,MAAM,CAAC,MAAM,OAAO,GAAG,MAAM,CAAC;AAG9B,MAAM,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AC;QACvD,MAAM,SAAS,CAAC,SAAS,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IACpD,CAAC;IACD,KAAK;CACR,CAAC,CAAC,CAAC"}
|
package/dist/device/mcp.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp.d.ts","sourceRoot":"","sources":["../../src/device/mcp.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mcp.d.ts","sourceRoot":"","sources":["../../src/device/mcp.ts"],"names":[],"mappings":"AAyZA,eAAO,MAAM,gBAAgB;;;;;;;;kDAQ3B,CAAC"}
|