@intentic/machine 1.316.0 → 1.317.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 +67 -6
- package/dist/agent-trial.d.ts +25 -0
- package/dist/agent-trial.d.ts.map +1 -0
- package/dist/agent-trial.js +132 -0
- package/dist/agent-trial.js.map +1 -0
- package/dist/autostart/autostart.d.ts.map +1 -0
- package/dist/{autostart.js → autostart/autostart.js} +1 -1
- package/dist/autostart/autostart.js.map +1 -0
- package/dist/autostart/legacy-autostart.d.ts +4 -0
- package/dist/autostart/legacy-autostart.d.ts.map +1 -0
- package/dist/autostart/legacy-autostart.js +33 -0
- package/dist/autostart/legacy-autostart.js.map +1 -0
- package/dist/commands.d.ts.map +1 -1
- package/dist/commands.js +3 -1
- package/dist/commands.js.map +1 -1
- package/dist/device/grant.d.ts +284 -0
- package/dist/device/grant.d.ts.map +1 -0
- package/dist/device/grant.js +15 -0
- package/dist/device/grant.js.map +1 -0
- package/dist/device/mcp.d.ts.map +1 -1
- package/dist/device/mcp.js +5 -2
- package/dist/device/mcp.js.map +1 -1
- package/dist/device/router.d.ts +3 -2
- package/dist/device/router.d.ts.map +1 -1
- package/dist/device/router.js +20 -6
- package/dist/device/router.js.map +1 -1
- package/dist/device/sandbox-cli.d.ts +6 -0
- package/dist/device/sandbox-cli.d.ts.map +1 -0
- package/dist/device/sandbox-cli.js +76 -0
- package/dist/device/sandbox-cli.js.map +1 -0
- package/dist/device/sandbox-rounds/auto-backup.d.ts +13 -0
- package/dist/device/sandbox-rounds/auto-backup.d.ts.map +1 -0
- package/dist/device/sandbox-rounds/auto-backup.js +97 -0
- package/dist/device/sandbox-rounds/auto-backup.js.map +1 -0
- package/dist/device/sandbox-rounds/auto-prepare.d.ts +11 -0
- package/dist/device/sandbox-rounds/auto-prepare.d.ts.map +1 -0
- package/dist/device/sandbox-rounds/auto-prepare.js +20 -0
- package/dist/device/sandbox-rounds/auto-prepare.js.map +1 -0
- package/dist/device/sandbox-rounds/ic-rounds.d.ts +23 -0
- package/dist/device/sandbox-rounds/ic-rounds.d.ts.map +1 -0
- package/dist/device/sandbox-rounds/ic-rounds.js +78 -0
- package/dist/device/sandbox-rounds/ic-rounds.js.map +1 -0
- package/dist/device/sandbox-rounds/probation-watch.d.ts +32 -0
- package/dist/device/sandbox-rounds/probation-watch.d.ts.map +1 -0
- package/dist/device/sandbox-rounds/probation-watch.js +60 -0
- package/dist/device/sandbox-rounds/probation-watch.js.map +1 -0
- package/dist/device/sandbox-rounds/swap-records.d.ts +14 -0
- package/dist/device/sandbox-rounds/swap-records.d.ts.map +1 -0
- package/dist/device/sandbox-rounds/swap-records.js +45 -0
- package/dist/device/sandbox-rounds/swap-records.js.map +1 -0
- package/dist/device/tools/agent.d.ts.map +1 -1
- package/dist/device/tools/agent.js +13 -0
- package/dist/device/tools/agent.js.map +1 -1
- package/dist/device/tools/command-ledger.d.ts +14 -0
- package/dist/device/tools/command-ledger.d.ts.map +1 -0
- package/dist/device/tools/command-ledger.js +85 -0
- package/dist/device/tools/command-ledger.js.map +1 -0
- package/dist/device/tools/ic-binary.d.ts +1 -1
- package/dist/device/tools/ic-binary.d.ts.map +1 -1
- package/dist/device/tools/ic-binary.js +8 -3
- package/dist/device/tools/ic-binary.js.map +1 -1
- package/dist/device/tools/sandboxes.d.ts +9 -3
- package/dist/device/tools/sandboxes.d.ts.map +1 -1
- package/dist/device/tools/sandboxes.js +67 -20
- package/dist/device/tools/sandboxes.js.map +1 -1
- package/dist/device/tools/shell.d.ts +1 -0
- package/dist/device/tools/shell.d.ts.map +1 -1
- package/dist/device/tools/shell.js +15 -1
- package/dist/device/tools/shell.js.map +1 -1
- package/dist/environments/auto-upgrade.d.ts +2 -0
- package/dist/environments/auto-upgrade.d.ts.map +1 -1
- package/dist/environments/auto-upgrade.js +15 -0
- package/dist/environments/auto-upgrade.js.map +1 -1
- package/dist/environments/children.js +1 -1
- package/dist/environments/children.js.map +1 -1
- package/dist/environments/commands.d.ts +2 -0
- package/dist/environments/commands.d.ts.map +1 -1
- package/dist/environments/commands.js +46 -10
- package/dist/environments/commands.js.map +1 -1
- package/dist/environments/machine-upgrade.d.ts +2 -0
- package/dist/environments/machine-upgrade.d.ts.map +1 -1
- package/dist/environments/machine-upgrade.js +17 -2
- package/dist/environments/machine-upgrade.js.map +1 -1
- package/dist/environments/machine.d.ts +6 -0
- package/dist/environments/machine.d.ts.map +1 -1
- package/dist/environments/machine.js.map +1 -1
- package/dist/release.d.ts.map +1 -1
- package/dist/release.js +1 -6
- package/dist/release.js.map +1 -1
- package/dist/resident.d.ts +1 -0
- package/dist/resident.d.ts.map +1 -1
- package/dist/resident.js +30 -6
- package/dist/resident.js.map +1 -1
- package/dist/supervision.d.ts +1 -0
- package/dist/supervision.d.ts.map +1 -1
- package/dist/supervision.js +17 -1
- package/dist/supervision.js.map +1 -1
- package/dist/sync/commands.d.ts +1 -0
- package/dist/sync/commands.d.ts.map +1 -1
- package/dist/sync/commands.js +30 -7
- package/dist/sync/commands.js.map +1 -1
- package/dist/sync/config.d.ts +2 -0
- package/dist/sync/config.d.ts.map +1 -1
- package/dist/sync/config.js +3 -0
- package/dist/sync/config.js.map +1 -1
- package/dist/sync/mirror.d.ts +3 -1
- package/dist/sync/mirror.d.ts.map +1 -1
- package/dist/sync/mirror.js +72 -20
- package/dist/sync/mirror.js.map +1 -1
- package/dist/sync/mutagen.d.ts +13 -2
- package/dist/sync/mutagen.d.ts.map +1 -1
- package/dist/sync/mutagen.js +50 -13
- package/dist/sync/mutagen.js.map +1 -1
- package/dist/sync/ssh.d.ts +3 -0
- package/dist/sync/ssh.d.ts.map +1 -1
- package/dist/sync/ssh.js +30 -1
- package/dist/sync/ssh.js.map +1 -1
- package/dist/sync/swap-pause.d.ts +10 -0
- package/dist/sync/swap-pause.d.ts.map +1 -0
- package/dist/sync/swap-pause.js +29 -0
- package/dist/sync/swap-pause.js.map +1 -0
- package/dist/sync/symlinks.d.ts +8 -0
- package/dist/sync/symlinks.d.ts.map +1 -0
- package/dist/sync/symlinks.js +30 -0
- package/dist/sync/symlinks.js.map +1 -0
- package/dist/upgrade.d.ts.map +1 -1
- package/dist/upgrade.js +18 -7
- package/dist/upgrade.js.map +1 -1
- package/package.json +8 -8
- package/dist/autostart.d.ts.map +0 -1
- package/dist/autostart.js.map +0 -1
- package/dist/device/auto-prepare.d.ts +0 -18
- package/dist/device/auto-prepare.d.ts.map +0 -1
- package/dist/device/auto-prepare.js +0 -85
- package/dist/device/auto-prepare.js.map +0 -1
- /package/dist/{autostart.d.ts → autostart/autostart.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -23,7 +23,10 @@ flowchart LR
|
|
|
23
23
|
`ic sandbox list --json` passed through, and start, stop, restart, the swaps, `set-shape`, `forget-shape` and the
|
|
24
24
|
logs are ic's own verbs, argv spelled by the contract (`icShapeArgs`, `icPowerArgs`). The shape reaches ic as the
|
|
25
25
|
contract's own object (`--set memoryGib=12`), so no flag of ic's is spelled here; the old `reshape` op is carried
|
|
26
|
-
out through the same verb.
|
|
26
|
+
out through the same verb. A rollback's `to` becomes `ic sandbox rollback <slug> --to <version>`. A sandbox an
|
|
27
|
+
interrupted swap left parked is listed under its own slug and found like any other, so start, rollback and update
|
|
28
|
+
reach it; a listing field a newer ic writes in a way this agent cannot read costs that field, not the whole
|
|
29
|
+
listing. Nothing here runs docker or reads the shape saved for a sandbox's next restart; ic
|
|
27
30
|
answers both. Before its first `ic` call the agent makes
|
|
28
31
|
sure the installed `ic` is at least as new as itself, fetching its own release's into `~/.intentic/ic/bin` when it
|
|
29
32
|
is not ([`tools/ic-binary.ts`](src/device/tools/ic-binary.ts)), since a new verb here arrives with a new verb there.
|
|
@@ -32,14 +35,29 @@ flowchart LR
|
|
|
32
35
|
- **sync** (`src/sync/`): `sync setup` enrolls an SSH key and runs Mutagen against the sandbox's sshd, reached
|
|
33
36
|
through a loopback port tunnelled over a WebSocket. It keeps a folder two-way synced, forwards every workspace
|
|
34
37
|
port to the same localhost port, and fast-forwards local git clones from the sandbox.
|
|
38
|
+
- Only the resident agent creates Mutagen sessions: `setup` records the pairing and waits for the session to
|
|
39
|
+
appear, since two creators racing left one name holding two identical sessions. The agent keeps one session per
|
|
40
|
+
name, terminating any extras, and recreates a session whose rules drifted once there are no conflicts left.
|
|
41
|
+
- `setup` replaces what this agent's `known_hosts` holds for the pairing's alias (hashed entries included): with the
|
|
42
|
+
host key the enrollment carries when it carries one, else with nothing, so `accept-new` records the key the sandbox
|
|
43
|
+
presents now. Outside an enrollment a changed key is still refused. A sandbox whose ports poll has failed for ten
|
|
44
|
+
minutes has its forwards taken off localhost, and they come back with its first answer. `sync uninstall` stops and
|
|
45
|
+
unregisters Mutagen's daemon only when it is this agent's own copy, never a Mutagen the user installed.
|
|
46
|
+
- Symbolic links travel only where the device can create them ([`sync/symlinks.ts`](src/sync/symlinks.ts)). A
|
|
47
|
+
Windows PC without Developer Mode refuses every link, and Mutagen would try again on every cycle, so its sessions
|
|
48
|
+
use `--symlink-mode ignore`. Turning Developer Mode on brings them back at the agent's next start.
|
|
35
49
|
- **Which computer this is** ([`machine-id.ts`](src/machine-id.ts)): a `machineId` minted once at install and kept
|
|
36
50
|
in `~/.intentic/machine/machine-id`, sent in the connect-time facts, the sync report and the sync enrollment. The
|
|
37
51
|
Windows side hands its own to the agent it starts in each distro, so every OS install of one PC answers with one id;
|
|
38
52
|
a sandbox joins enrollments, sync enrollments and device rows on it, never on a hostname.
|
|
39
|
-
- The features a device advertises (`set-shape`, `reshape-later`) are read off the `ic` under it, from
|
|
40
|
-
help (
|
|
41
|
-
an op or field this agent does not know is refused
|
|
42
|
-
|
|
53
|
+
- The features a device advertises (`set-shape`, `reshape-later`, `rollback-to`) are read off the `ic` under it, from
|
|
54
|
+
that `ic`'s own help (`ic sandbox shape --set` for the first two, `ic sandbox rollback --to` for the third), rather
|
|
55
|
+
than listed beside the code. The device RPC inputs are strict, so an op or field this agent does not know is refused
|
|
56
|
+
rather than dropped, and a `to` on anything but a rollback is refused. The one exception is the grant a sandbox
|
|
57
|
+
pushes ([`device/grant.ts`](src/device/grant.ts)): a switch this agent does not know is left off and logged once per
|
|
58
|
+
link, since refusing the grant dropped the link and the sandbox redialled it forever. A known switch with a value it
|
|
59
|
+
has no meaning for is still refused. `reshape-later` and the old `reshape` op stay only for pages and daemons from
|
|
60
|
+
before `set-shape` (v1.312.0 and older), and go in v1.314.0.
|
|
43
61
|
- Every path under the user's home goes through `homeDir()` from [local-agent](../local-agent), which follows a `HOME`
|
|
44
62
|
set after startup; a test holds the sources to it.
|
|
45
63
|
- Scopes are enforced here and nowhere else: the sandbox only asks, and a refusal names the switch that is off.
|
|
@@ -53,9 +71,52 @@ flowchart LR
|
|
|
53
71
|
- The install shims only put a first binary down and run `setup`; `install.ts` decides the rest. `status --json`
|
|
54
72
|
is what the desktop app's tray reads.
|
|
55
73
|
|
|
74
|
+
### Upgrades that can be undone
|
|
75
|
+
|
|
76
|
+
- **A swap is never cut short by this agent.** `ic` runs in a process group of its own on POSIX, keeps its pipes, and
|
|
77
|
+
is never killed when the link or request that asked for it goes away. Every restart of the agent (the auto-upgrade
|
|
78
|
+
tick, `upgrade`, `run`, the browser's Update and Restart) waits while any channel record in this environment's ic
|
|
79
|
+
home (`INTENTIC_HOME`, else `~/.intentic`) says `swap_phase=cutover` with `swap_at` in the last 30 minutes, or while
|
|
80
|
+
this process runs a flow that moves a container ([`device/sandbox-rounds/swap-records.ts`](src/device/sandbox-rounds/swap-records.ts)); the tick
|
|
81
|
+
looks again in five minutes, a command waits and says so.
|
|
82
|
+
- **The probation watch** ([`device/sandbox-rounds/probation-watch.ts`](src/device/sandbox-rounds/probation-watch.ts)) runs
|
|
83
|
+
`ic sandbox watch <slug> --json` every minute for each sandbox whose record names a `swap_phase`, and
|
|
84
|
+
`ic sandbox watch --json` over every sandbox half a minute after start (a reboot mid-swap) and every ten minutes.
|
|
85
|
+
ic finishes or undoes an interrupted cutover and rolls a failing new version back; the agent logs what it did.
|
|
86
|
+
The per-record watch runs in every environment, since only the environment that swapped holds the record; the sweep
|
|
87
|
+
over every sandbox runs on the root only, as the daily jobs below do, because a WSL distro shares the Windows
|
|
88
|
+
side's Docker engine.
|
|
89
|
+
- **Daily**, on the root: `ic sandbox backup <slug> --auto --json` for each running sandbox, one at a time, twenty to
|
|
90
|
+
forty minutes after start and then every day, then one `ic sandbox tidy --json`, whose volumes nobody claims are
|
|
91
|
+
named and never deleted. Both back off from a slug that keeps failing, as auto-prepare does, and each has its switch
|
|
92
|
+
beside the update ones (`intentic-machine updates --backups off`, `--tidy off`).
|
|
93
|
+
- **File sync holds still while its sandbox is swapped here** ([`sync/swap-pause.ts`](src/sync/swap-pause.ts)). A
|
|
94
|
+
pairing's local slug is the first label of its sandbox's public hostname (what ic names a sandbox with one) or the
|
|
95
|
+
id in it (what ic names one from its connect token), so the mapping is exact. Its sessions are paused through the
|
|
96
|
+
cutover and the first quarter hour of probation, and past that while the sandbox does not answer, then resumed; a
|
|
97
|
+
pause somebody made is left alone. Only this environment's records count: a distro syncing a sandbox the Windows side
|
|
98
|
+
swaps is not paused.
|
|
99
|
+
- **A self-update is kept undoable** ([`agent-trial.ts`](src/agent-trial.ts)). The replaced binary stays as
|
|
100
|
+
`<bin>.previous` until the new agent has run for ten minutes and written its "healthy since" marker. Three starts of a
|
|
101
|
+
release within ten minutes, none ended by a stop, restart or upgrade, put `.previous` back (at that start, or at the
|
|
102
|
+
next upgrade pass) and record the release as `skippedAgent` in `machine.json`: neither the auto-upgrade nor an
|
|
103
|
+
`upgrade` moves this environment onto it again until a newer one is published (`upgrade --force` does). A restart
|
|
104
|
+
that throws during an upgrade puts the old binary back too.
|
|
105
|
+
- **What the agent leaves behind.** Under a systemd user unit the default `KillMode` ended the unit's whole cgroup on
|
|
106
|
+
every `systemctl stop` and every agent exit, `ic` mid-swap included: the unit now says `KillMode=process`, and a
|
|
107
|
+
unit an older build wrote is rewritten at the agent's next start, since a repair now replaces an entry that starts
|
|
108
|
+
this same agent with other settings. What outlives the agent on purpose is `ic` (bounded by its own swap), Mutagen's
|
|
109
|
+
daemon and the browser it opened; what must not, the agent ends itself: every `run_command` group still running
|
|
110
|
+
when it stops, and on Linux the groups a crashed agent left, which the next agent ends at its start
|
|
111
|
+
([`tools/command-ledger.ts`](src/device/tools/command-ledger.ts)). The login entries of the two agents this one
|
|
112
|
+
replaced on 2026-08-29 (`intentic-host`, the sync mirror) are removed once, at start.
|
|
113
|
+
- `intentic-machine sandbox <verb> [slug]` passes `list`, `start`, `stop`, `restart`, `update`, `rollback [--to]`,
|
|
114
|
+
`versions`, `logs`, `doctor`, `watch`, `backup` and `backups` straight to ic, in this terminal, with ic's exit code:
|
|
115
|
+
a sandbox can be looked at and repaired from here when no browser reaches it.
|
|
116
|
+
|
|
56
117
|
## Key files
|
|
57
118
|
|
|
58
|
-
- [src/commands.ts](src/commands.ts) — the CLI: `device`, `sync`, `run`, `status`, `upgrade`, `uninstall`.
|
|
119
|
+
- [src/commands.ts](src/commands.ts) — the CLI: `device`, `sync`, `sandbox`, `run`, `status`, `upgrade`, `updates`, `uninstall`.
|
|
59
120
|
- [src/resident.ts](src/resident.ts) — the resident process that holds links, pairings and WSL distros.
|
|
60
121
|
- [src/device/mcp.ts](src/device/mcp.ts) — every tool a sandbox can call on this device.
|
|
61
122
|
- [src/device/policy.ts](src/device/policy.ts) — scope checks and the file-root boundary.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Log } from "@intentic/local-agent";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
export declare const HEALTHY_AFTER_MS: number;
|
|
4
|
+
export declare const CRASH_LOOP_STARTS = 3;
|
|
5
|
+
declare const StartLedgerSchema: z.ZodObject<{
|
|
6
|
+
version: z.ZodString;
|
|
7
|
+
starts: z.ZodArray<z.ZodObject<{
|
|
8
|
+
at: z.ZodNumber;
|
|
9
|
+
pid: z.ZodNumber;
|
|
10
|
+
clean: z.ZodOptional<z.ZodBoolean>;
|
|
11
|
+
}, z.core.$strip>>;
|
|
12
|
+
}, z.core.$strip>;
|
|
13
|
+
export type StartLedger = z.infer<typeof StartLedgerSchema>;
|
|
14
|
+
export declare const withStart: (ledger: StartLedger | undefined, version: string, pid: number, now: number) => StartLedger;
|
|
15
|
+
export declare const withCleanExit: (ledger: StartLedger, pid: number) => StartLedger;
|
|
16
|
+
export declare const crashLooping: (ledger: StartLedger, healthy: string | undefined, now: number) => boolean;
|
|
17
|
+
export declare const recordStopped: (pid: number) => Promise<void>;
|
|
18
|
+
export interface Trial {
|
|
19
|
+
readonly clean: () => Promise<void>;
|
|
20
|
+
readonly prove: (log: Log) => () => void;
|
|
21
|
+
}
|
|
22
|
+
export declare const beginTrial: (log: Log) => Promise<Trial | "restored">;
|
|
23
|
+
export declare const rollBackIfCrashLooping: (log: Log) => Promise<boolean>;
|
|
24
|
+
export {};
|
|
25
|
+
//# sourceMappingURL=agent-trial.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-trial.d.ts","sourceRoot":"","sources":["../src/agent-trial.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAEjD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAexB,eAAO,MAAM,gBAAgB,QAAc,CAAC;AAE5C,eAAO,MAAM,iBAAiB,IAAI,CAAC;AAOnC,QAAA,MAAM,iBAAiB;;;;;;;iBAAkE,CAAC;AAC1F,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAK5D,eAAO,MAAM,SAAS,WAAY,WAAW,GAAG,SAAS,WAAW,MAAM,OAAO,MAAM,OAAO,MAAM,KAAG,WAGrG,CAAC;AAIH,eAAO,MAAM,aAAa,WAAY,WAAW,OAAO,MAAM,KAAG,WAG/D,CAAC;AAIH,eAAO,MAAM,YAAY,WAAY,WAAW,WAAW,MAAM,GAAG,SAAS,OAAO,MAAM,KAAG,OAC2D,CAAC;AAoBzJ,eAAO,MAAM,aAAa,QAAe,MAAM,KAAG,OAAO,CAAC,IAAI,CAM7D,CAAC;AAiEF,MAAM,WAAW,KAAK;IAClB,QAAQ,CAAC,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAEpC,QAAQ,CAAC,KAAK,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,MAAM,IAAI,CAAC;CAC5C;AAOD,eAAO,MAAM,UAAU,QAAe,GAAG,KAAG,OAAO,CAAC,KAAK,GAAG,UAAU,CAsBrE,CAAC;AAIF,eAAO,MAAM,sBAAsB,QAAe,GAAG,KAAG,OAAO,CAAC,OAAO,CAMtE,CAAC"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { readFile, rename, rm } from "node:fs/promises";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { errorMessage } from "@intentic/base/errors";
|
|
5
|
+
import { writeFileAtomic } from "@intentic/base/fs";
|
|
6
|
+
import { DEV_VERSION } from "@intentic/sandbox-contract";
|
|
7
|
+
import { z } from "zod";
|
|
8
|
+
import { baseDir } from "./config.js";
|
|
9
|
+
import { readMachineConfig, updateMachineConfig } from "./environments/machine.js";
|
|
10
|
+
import { installedBuild, runningAsInstalledAgent } from "./installed.js";
|
|
11
|
+
import { agentPath, launcherPath, renameIfPresent } from "./release.js";
|
|
12
|
+
import { MACHINE_VERSION } from "./version.js";
|
|
13
|
+
export const HEALTHY_AFTER_MS = 10 * 60_000;
|
|
14
|
+
export const CRASH_LOOP_STARTS = 3;
|
|
15
|
+
const startsPath = join(baseDir, "agent-starts.json");
|
|
16
|
+
const healthyPath = join(baseDir, "agent-healthy.json");
|
|
17
|
+
const StartSchema = z.object({ at: z.number(), pid: z.number(), clean: z.boolean().optional() });
|
|
18
|
+
const StartLedgerSchema = z.object({ version: z.string(), starts: z.array(StartSchema) });
|
|
19
|
+
const HealthySchema = z.object({ version: z.string(), since: z.number() });
|
|
20
|
+
export const withStart = (ledger, version, pid, now) => ({
|
|
21
|
+
version,
|
|
22
|
+
starts: [...(ledger?.version === version ? ledger.starts.filter((start) => now - start.at < HEALTHY_AFTER_MS) : []), { at: now, pid }],
|
|
23
|
+
});
|
|
24
|
+
export const withCleanExit = (ledger, pid) => ({
|
|
25
|
+
...ledger,
|
|
26
|
+
starts: ledger.starts.map((start) => (start.pid === pid ? { ...start, clean: true } : start)),
|
|
27
|
+
});
|
|
28
|
+
export const crashLooping = (ledger, healthy, now) => ledger.version !== healthy && ledger.starts.filter((start) => start.clean !== true && now - start.at < HEALTHY_AFTER_MS).length >= CRASH_LOOP_STARTS;
|
|
29
|
+
const readJson = async (path, schema) => {
|
|
30
|
+
const raw = await readFile(path, "utf8").catch(() => undefined);
|
|
31
|
+
try {
|
|
32
|
+
const parsed = raw === undefined ? undefined : schema.safeParse(JSON.parse(raw));
|
|
33
|
+
return parsed?.success === true ? parsed.data : undefined;
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
const readLedger = async () => await readJson(startsPath, StartLedgerSchema);
|
|
40
|
+
const readHealthyVersion = async () => (await readJson(healthyPath, HealthySchema))?.version;
|
|
41
|
+
const writeLedger = async (ledger) => await writeFileAtomic(startsPath, JSON.stringify(ledger));
|
|
42
|
+
export const recordStopped = async (pid) => {
|
|
43
|
+
const ledger = await readLedger();
|
|
44
|
+
if (ledger !== undefined) {
|
|
45
|
+
await writeLedger(withCleanExit(ledger, pid)).catch(() => undefined);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
const previousOf = (target) => `${target}.previous`;
|
|
49
|
+
const putBack = async (target) => {
|
|
50
|
+
if (!existsSync(previousOf(target))) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const aside = `${target}.old`;
|
|
54
|
+
await renameIfPresent(target, aside);
|
|
55
|
+
try {
|
|
56
|
+
await rename(previousOf(target), target);
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
await renameIfPresent(aside, target);
|
|
60
|
+
throw error;
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
const rollBack = async (version, log) => {
|
|
64
|
+
try {
|
|
65
|
+
await putBack(launcherPath);
|
|
66
|
+
await putBack(agentPath);
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
log(`the agent ${version} keeps stopping, but the one before it could not be put back (${errorMessage(error)}).`);
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
try {
|
|
73
|
+
await updateMachineConfig((config) => ({ ...config, skippedAgent: { version, at: Date.now() } }));
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
log(`could not record ${version} as skipped (${errorMessage(error)}); an upgrade may offer it again.`);
|
|
77
|
+
}
|
|
78
|
+
log(`the agent ${version} stopped ${CRASH_LOOP_STARTS} times within ${HEALTHY_AFTER_MS / 60_000} minutes of starting, so the one it replaced is back in its place. ${version} is skipped here until a newer release is published.`);
|
|
79
|
+
return true;
|
|
80
|
+
};
|
|
81
|
+
const markHealthy = async (version, since, log) => {
|
|
82
|
+
try {
|
|
83
|
+
await proven(version, since, log);
|
|
84
|
+
}
|
|
85
|
+
catch (error) {
|
|
86
|
+
log(`could not record the agent ${version} as healthy (${errorMessage(error)}).`);
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
const proven = async (version, since, log) => {
|
|
90
|
+
await writeFileAtomic(healthyPath, JSON.stringify({ version, since }));
|
|
91
|
+
const kept = [previousOf(agentPath), previousOf(launcherPath)].filter((path) => existsSync(path));
|
|
92
|
+
await Promise.all(kept.map(async (path) => await rm(path, { force: true })));
|
|
93
|
+
if (kept.length > 0) {
|
|
94
|
+
log(`the agent ${version} has run for ${HEALTHY_AFTER_MS / 60_000} minutes, so the copy of the one before it, kept to undo this update, is dropped.`);
|
|
95
|
+
}
|
|
96
|
+
if ((await readMachineConfig().catch(() => undefined))?.skippedAgent?.version === version) {
|
|
97
|
+
await updateMachineConfig(({ skippedAgent: _lifted, ...rest }) => rest);
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
const INERT = { clean: async () => await Promise.resolve(), prove: () => () => undefined };
|
|
101
|
+
export const beginTrial = async (log) => {
|
|
102
|
+
if (!runningAsInstalledAgent() || MACHINE_VERSION === DEV_VERSION) {
|
|
103
|
+
return INERT;
|
|
104
|
+
}
|
|
105
|
+
const startedAt = Date.now();
|
|
106
|
+
const ledger = withStart(await readLedger(), MACHINE_VERSION, process.pid, startedAt);
|
|
107
|
+
try {
|
|
108
|
+
await writeLedger(ledger);
|
|
109
|
+
}
|
|
110
|
+
catch (error) {
|
|
111
|
+
log(`could not record this start (${errorMessage(error)}); a crash loop of this release goes unnoticed until it can.`);
|
|
112
|
+
}
|
|
113
|
+
if (crashLooping(ledger, await readHealthyVersion(), startedAt) && existsSync(previousOf(agentPath)) && (await rollBack(MACHINE_VERSION, log))) {
|
|
114
|
+
return "restored";
|
|
115
|
+
}
|
|
116
|
+
return {
|
|
117
|
+
clean: async () => await recordStopped(process.pid),
|
|
118
|
+
prove: (say) => {
|
|
119
|
+
const timer = setTimeout(() => void markHealthy(MACHINE_VERSION, startedAt, say), HEALTHY_AFTER_MS);
|
|
120
|
+
timer.unref();
|
|
121
|
+
return () => clearTimeout(timer);
|
|
122
|
+
},
|
|
123
|
+
};
|
|
124
|
+
};
|
|
125
|
+
export const rollBackIfCrashLooping = async (log) => {
|
|
126
|
+
const ledger = await readLedger();
|
|
127
|
+
if (ledger === undefined || !existsSync(previousOf(agentPath)) || installedBuild() !== ledger.version) {
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
130
|
+
return crashLooping(ledger, await readHealthyVersion(), Date.now()) && (await rollBack(ledger.version, log));
|
|
131
|
+
};
|
|
132
|
+
//# sourceMappingURL=agent-trial.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-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AE,CAAC;QAC7I,OAAO,UAAU,CAAC;IACtB,CAAC;IACD,OAAO;QACH,KAAK,EAAE,KAAK,IAAI,EAAE,CAAC,MAAM,aAAa,CAAC,OAAO,CAAC,GAAG,CAAC;QACnD,KAAK,EAAE,CAAC,GAAG,EAAE,EAAE;YACX,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,KAAK,WAAW,CAAC,eAAe,EAAE,SAAS,EAAE,GAAG,CAAC,EAAE,gBAAgB,CAAC,CAAC;YACpG,KAAK,CAAC,KAAK,EAAE,CAAC;YACd,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;QACrC,CAAC;KACJ,CAAC;AACN,CAAC,CAAC;AAIF,MAAM,CAAC,MAAM,sBAAsB,GAAG,KAAK,EAAE,GAAQ,EAAoB,EAAE;IACvE,MAAM,MAAM,GAAG,MAAM,UAAU,EAAE,CAAC;IAClC,IAAI,MAAM,KAAK,SAAS,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,IAAI,cAAc,EAAE,KAAK,MAAM,CAAC,OAAO,EAAE,CAAC;QACpG,OAAO,KAAK,CAAC;IACjB,CAAC;IACD,OAAO,YAAY,CAAC,MAAM,EAAE,MAAM,kBAAkB,EAAE,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,QAAQ,CAAC,MAAM,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC;AACjH,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"autostart.d.ts","sourceRoot":"","sources":["../../src/autostart/autostart.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAM3D,eAAO,MAAM,iBAAiB,EAAE,aAY/B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"autostart.js","sourceRoot":"","sources":["../../src/autostart/autostart.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAK1C,MAAM,CAAC,MAAM,iBAAiB,GAAkB;IAC5C,EAAE,EAAE,kBAAkB;IACtB,eAAe,EAAE,iBAAiB;IAClC,WAAW,EAAE,wBAAwB;IACrC,cAAc,EAAE,yFAAyF;IAEzG,OAAO,EAAE,UAAU;IACnB,WAAW,EAAE,EAAE,KAAK,EAAE,sBAAsB,EAAE;IAC9C,YAAY,EAAE,CAAC,KAAK,CAAC;IACrB,cAAc,EAAE,CAAC,KAAK,EAAE,cAAc,CAAC;IACvC,WAAW,EAAE,CAAC,MAAM,EAAE,EAAE,CACpB,mEAAmE,MAAM,uFAAuF,UAAU,EAAE;CACnL,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"legacy-autostart.d.ts","sourceRoot":"","sources":["../../src/autostart/legacy-autostart.ts"],"names":[],"mappings":"AAGA,OAAO,EAAa,KAAK,aAAa,EAAE,KAAK,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAwBhF,eAAO,MAAM,gBAAgB,EAAE,SAAS,aAAa,EAGpD,CAAC;AAMF,eAAO,MAAM,qBAAqB,QAAe,GAAG,KAAG,OAAO,CAAC,IAAI,CAWlE,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { writeFile } from "node:fs/promises";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { autostart } from "@intentic/local-agent";
|
|
5
|
+
import { baseDir } from "../config.js";
|
|
6
|
+
import { machineLauncher } from "../supervision.js";
|
|
7
|
+
const retired = (id, windowsRunValue) => ({
|
|
8
|
+
id,
|
|
9
|
+
windowsRunValue,
|
|
10
|
+
desktopName: id,
|
|
11
|
+
desktopComment: `retired: ${id}`,
|
|
12
|
+
logPath: join(baseDir, `${id}.log`),
|
|
13
|
+
detachedArgs: [],
|
|
14
|
+
foregroundArgs: [],
|
|
15
|
+
failureNote: (reason) => reason,
|
|
16
|
+
});
|
|
17
|
+
export const LEGACY_AUTOSTART = [
|
|
18
|
+
retired("intentic-host", "IntenticHost"),
|
|
19
|
+
{ ...retired("intentic-sync-mirror", "IntenticSyncMirror"), launchAgent: { label: "dev.intentic.sync-mirror" } },
|
|
20
|
+
];
|
|
21
|
+
const retiredPath = join(baseDir, "legacy-autostart-retired");
|
|
22
|
+
export const retireLegacyAutostart = async (log) => {
|
|
23
|
+
if (existsSync(retiredPath)) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const quiet = () => undefined;
|
|
27
|
+
for (const spec of LEGACY_AUTOSTART) {
|
|
28
|
+
await autostart(spec, machineLauncher(), quiet).unregister();
|
|
29
|
+
}
|
|
30
|
+
await writeFile(retiredPath, `${new Date().toISOString()}\n`, { mode: 0o600 });
|
|
31
|
+
log("removed the login entries intentic-host and intentic-sync's mirror left before they became this agent, wherever any were left.");
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=legacy-autostart.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"legacy-autostart.js","sourceRoot":"","sources":["../../src/autostart/legacy-autostart.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,SAAS,EAAgC,MAAM,uBAAuB,CAAC;AAChF,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AASpD,MAAM,OAAO,GAAG,CAAC,EAAU,EAAE,eAAuB,EAAiB,EAAE,CAAC,CAAC;IACrE,EAAE;IACF,eAAe;IACf,WAAW,EAAE,EAAE;IACf,cAAc,EAAE,YAAY,EAAE,EAAE;IAChC,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,MAAM,CAAC;IACnC,YAAY,EAAE,EAAE;IAChB,cAAc,EAAE,EAAE;IAClB,WAAW,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM;CAClC,CAAC,CAAC;AAIH,MAAM,CAAC,MAAM,gBAAgB,GAA6B;IACtD,OAAO,CAAC,eAAe,EAAE,cAAc,CAAC;IACxC,EAAE,GAAG,OAAO,CAAC,sBAAsB,EAAE,oBAAoB,CAAC,EAAE,WAAW,EAAE,EAAE,KAAK,EAAE,0BAA0B,EAAE,EAAE;CACnH,CAAC;AAGF,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,EAAE,0BAA0B,CAAC,CAAC;AAG9D,MAAM,CAAC,MAAM,qBAAqB,GAAG,KAAK,EAAE,GAAQ,EAAiB,EAAE;IACnE,IAAI,UAAU,CAAC,WAAW,CAAC,EAAE,CAAC;QAC1B,OAAO;IACX,CAAC;IACD,MAAM,KAAK,GAAQ,GAAG,EAAE,CAAC,SAAS,CAAC;IACnC,KAAK,MAAM,IAAI,IAAI,gBAAgB,EAAE,CAAC;QAElC,MAAM,SAAS,CAAC,IAAI,EAAE,eAAe,EAAE,EAAE,KAAK,CAAC,CAAC,UAAU,EAAE,CAAC;IACjE,CAAC;IACD,MAAM,SAAS,CAAC,WAAW,EAAE,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IAC/E,GAAG,CAAC,gIAAgI,CAAC,CAAC;AAC1I,CAAC,CAAC"}
|
package/dist/commands.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../src/commands.ts"],"names":[],"mappings":"AAAA,OAAO,EAA+B,KAAK,cAAc,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../src/commands.ts"],"names":[],"mappings":"AAAA,OAAO,EAA+B,KAAK,cAAc,EAAE,MAAM,eAAe,CAAC;AAoGjF,eAAO,MAAM,QAAQ,kDAoBnB,CAAC"}
|
package/dist/commands.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { buildCommand, buildRouteMap } from "@stricli/core";
|
|
2
2
|
import { deviceCommands, deviceUninstall } from "./device/commands.js";
|
|
3
|
+
import { sandboxRoutes } from "./device/sandbox-cli.js";
|
|
3
4
|
import { environmentRoutes, updates } from "./environments/commands.js";
|
|
4
5
|
import { realMachineIo, upgradeMachine } from "./environments/machine-upgrade.js";
|
|
5
6
|
import { runForeground } from "./resident.js";
|
|
@@ -46,7 +47,7 @@ const upgrade = buildCommand({
|
|
|
46
47
|
flags: {
|
|
47
48
|
force: {
|
|
48
49
|
kind: "boolean",
|
|
49
|
-
brief: "Install the published agent even over one built from source (
|
|
50
|
+
brief: "Install the published agent even over one built from source, or onto a release this machine rolled back from (both otherwise left alone)",
|
|
50
51
|
},
|
|
51
52
|
level: { kind: "boolean", brief: "Bring every side to the newest release one of them already runs, without asking for a newer one", default: false, hidden: true },
|
|
52
53
|
},
|
|
@@ -81,6 +82,7 @@ export const commands = buildRouteMap({
|
|
|
81
82
|
routes: syncCommands,
|
|
82
83
|
docs: { brief: "Mirror a sandbox's files and ports onto this machine (the Desktop sync card)" },
|
|
83
84
|
}),
|
|
85
|
+
sandbox: sandboxRoutes,
|
|
84
86
|
environment: environmentRoutes,
|
|
85
87
|
run,
|
|
86
88
|
status,
|
package/dist/commands.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commands.js","sourceRoot":"","sources":["../src/commands.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAuB,MAAM,eAAe,CAAC;AACjF,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,EAAE,iBAAiB,EAAE,OAAO,EAAE,M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