agentlane 0.4.1 → 0.5.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/CHANGELOG.md +76 -0
- package/dist/agents/claude-plugin.js +54 -8
- package/dist/agents/cli.js +11 -4
- package/dist/agents/hook-check.js +290 -0
- package/dist/agents/launcher.js +34 -6
- package/dist/agents/wiring-check.js +10 -4
- package/dist/agents/wiring.js +6 -33
- package/dist/browser/env.js +27 -7
- package/dist/browser/install.js +144 -6
- package/dist/browser/lane-browser.js +6 -3
- package/dist/browser/stop.js +2 -17
- package/dist/cache/key.js +23 -11
- package/dist/cli.js +63 -23
- package/dist/devices/backend.js +6 -0
- package/dist/devices/emulator.js +15 -5
- package/dist/devices/simctl.js +15 -3
- package/dist/disk-limits.js +134 -0
- package/dist/driver/caller.js +21 -6
- package/dist/driver/client.js +9 -5
- package/dist/driver/engine.js +29 -14
- package/dist/driver/install.js +88 -36
- package/dist/driver/paths.js +15 -11
- package/dist/driver/session.js +4 -1
- package/dist/driver/superseded.js +378 -0
- package/dist/driver-cli.js +32 -23
- package/dist/evidence/device.js +4 -0
- package/dist/evidence/evidence.js +4 -2
- package/dist/evidence/files.js +68 -0
- package/dist/evidence/strays.js +107 -0
- package/dist/hooks/env.js +2 -1
- package/dist/mcp/server.js +15 -0
- package/dist/mcp/tools.js +9 -1
- package/dist/plugin/guard.js +30 -0
- package/dist/plugin/hook-cli.js +101 -6
- package/dist/plugin/hook-mark.js +73 -0
- package/dist/plugin/hook-once.js +78 -0
- package/dist/plugin/shell.js +109 -8
- package/dist/processes.js +52 -2
- package/dist/registry/config.js +12 -8
- package/dist/registry/holds.js +37 -0
- package/dist/registry/leases.js +109 -0
- package/dist/registry/owner-checks.js +55 -0
- package/dist/registry/owner.js +18 -0
- package/dist/registry/parks.js +60 -0
- package/dist/registry/paths.js +28 -4
- package/dist/registry/ports.js +5 -1
- package/dist/registry/prune.js +643 -24
- package/dist/registry/refusal.js +1 -0
- package/dist/registry/registry.js +1258 -235
- package/dist/registry/rows.js +18 -4
- package/dist/registry/status.js +51 -8
- package/dist/registry/store.js +63 -1
- package/dist/registry/touch.js +180 -0
- package/dist/registry-cli.js +197 -36
- package/dist/services/services.js +223 -54
- package/dist/services/system.js +2 -1
- package/dist/up/answers.js +124 -0
- package/dist/up/doctor.js +27 -3
- package/dist/up/exec.js +29 -4
- package/dist/up/lane-files.js +26 -8
- package/dist/up/lane-services.js +8 -3
- package/dist/up/park.js +146 -0
- package/dist/up/preflight.js +2 -10
- package/dist/up/release.js +20 -24
- package/dist/up/restart.js +9 -2
- package/dist/up/sweep.js +437 -0
- package/dist/up/up.js +33 -12
- package/dist/up/wake.js +124 -0
- package/dist/up/waker.js +49 -0
- package/dist/up-cli.js +6 -1
- package/package.json +2 -2
- package/skills/dev-loop/SKILL.md +7 -5
- package/skills/drive/SKILL.md +4 -0
- package/skills/setup/SKILL.md +2 -2
package/dist/up/lane-files.js
CHANGED
|
@@ -2,14 +2,20 @@ import fs from 'node:fs';
|
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { sweepMaestroRunLinks } from "../driver/maestro-runs.js";
|
|
4
4
|
import { pruneDriverFiles } from "../driver/paths.js";
|
|
5
|
+
import { deviceRecordingMarked } from "../evidence/files.js";
|
|
6
|
+
import { evidenceDir } from "../hooks/env.js";
|
|
5
7
|
import { lanesRoot } from "../registry/paths.js";
|
|
6
8
|
import { HISTORY_KEEP_MS } from "../registry/registry.js";
|
|
7
9
|
export const LANE_FILES_KEEP_MS = HISTORY_KEEP_MS;
|
|
10
|
+
const LANE_ID = /^[0-9a-f]{8}$/;
|
|
8
11
|
export function laneDir(stateDir, laneId) {
|
|
9
|
-
if (
|
|
12
|
+
if (!LANE_ID.test(laneId))
|
|
10
13
|
throw new Error(`'${laneId}' is not a lane id`);
|
|
11
14
|
return path.join(lanesRoot(stateDir), laneId);
|
|
12
15
|
}
|
|
16
|
+
export function lastCallFile(dir) {
|
|
17
|
+
return path.join(dir, 'last-call.json');
|
|
18
|
+
}
|
|
13
19
|
export function serviceLog(dir, service) {
|
|
14
20
|
return path.join(dir, `${service}.log`);
|
|
15
21
|
}
|
|
@@ -28,6 +34,15 @@ export function readUpRecord(dir) {
|
|
|
28
34
|
return null;
|
|
29
35
|
}
|
|
30
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* The folder a wake runs `up` from: the one holding the agentlane.json `up` last read for the lane, which can sit below
|
|
39
|
+
* the git root the lane is keyed by; the lane's worktree when no record names one, or that folder is gone.
|
|
40
|
+
*/
|
|
41
|
+
export function wakeFolder(stateDir, lane) {
|
|
42
|
+
const config = readUpRecord(laneDir(stateDir, lane.id))?.config;
|
|
43
|
+
const folder = config ? path.dirname(config) : null;
|
|
44
|
+
return folder !== null && fs.existsSync(folder) ? folder : lane.worktree;
|
|
45
|
+
}
|
|
31
46
|
export function writeUpRecord(dir, record) {
|
|
32
47
|
fs.mkdirSync(dir, { recursive: true, mode: 0o700 });
|
|
33
48
|
const file = recordFile(dir);
|
|
@@ -35,22 +50,25 @@ export function writeUpRecord(dir, record) {
|
|
|
35
50
|
fs.writeFileSync(tmp, `${JSON.stringify(record, null, 2)}\n`);
|
|
36
51
|
fs.renameSync(tmp, file);
|
|
37
52
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
let names;
|
|
53
|
+
/** The ids of the lane folders in the state folder, of lanes running and ended. */
|
|
54
|
+
export function laneFolderIds(stateDir) {
|
|
41
55
|
try {
|
|
42
|
-
|
|
56
|
+
return fs.readdirSync(lanesRoot(stateDir)).filter(name => LANE_ID.test(name));
|
|
43
57
|
}
|
|
44
58
|
catch {
|
|
45
59
|
return [];
|
|
46
60
|
}
|
|
61
|
+
}
|
|
62
|
+
/** Removes the folders of lanes not in `liveIds` untouched for LANE_FILES_KEEP_MS, but not one a recorder may still write in. */
|
|
63
|
+
export function pruneLaneDirs(stateDir, liveIds, now) {
|
|
64
|
+
const root = lanesRoot(stateDir);
|
|
47
65
|
const removed = [];
|
|
48
|
-
for (const name of
|
|
49
|
-
if (
|
|
66
|
+
for (const name of laneFolderIds(stateDir)) {
|
|
67
|
+
if (liveIds.has(name))
|
|
50
68
|
continue;
|
|
51
69
|
const dir = path.join(root, name);
|
|
52
70
|
try {
|
|
53
|
-
if (now - fs.statSync(dir).mtimeMs < LANE_FILES_KEEP_MS)
|
|
71
|
+
if (now - fs.statSync(dir).mtimeMs < LANE_FILES_KEEP_MS || deviceRecordingMarked(evidenceDir(dir)))
|
|
54
72
|
continue;
|
|
55
73
|
fs.rmSync(dir, { recursive: true, force: true });
|
|
56
74
|
removed.push(name);
|
package/dist/up/lane-services.js
CHANGED
|
@@ -28,11 +28,16 @@ export async function startClaimedService(c, service, port) {
|
|
|
28
28
|
try {
|
|
29
29
|
const ready = await waitForService(deps.system, service, port, proc, deps.clock, log);
|
|
30
30
|
c.registry.recordProcess(c.ref, ready);
|
|
31
|
+
if (ready.aliveAt !== undefined)
|
|
32
|
+
c.registry.recordLeaderAlive(c.ref.id, ready, ready.aliveAt);
|
|
31
33
|
return `started on ${String(port)} (pid ${String(proc.pid)}, log ${log})`;
|
|
32
34
|
}
|
|
33
35
|
catch (error) {
|
|
34
|
-
await stopService(deps.system, proc, deps.clock);
|
|
35
|
-
|
|
36
|
-
|
|
36
|
+
const outcome = await stopService(deps.system, proc, deps.clock);
|
|
37
|
+
if (outcome.kind === 'stopped' || outcome.kind === 'already-gone') {
|
|
38
|
+
c.registry.forgetProcess(c.ref, service.name);
|
|
39
|
+
throw error;
|
|
40
|
+
}
|
|
41
|
+
throw new ServiceFailed(service.name, `failed to start, and could not be stopped after, so the lane keeps its record of it: ${describeStop(proc, outcome)}\n${error instanceof Error ? error.message : String(error)}`, null);
|
|
37
42
|
}
|
|
38
43
|
}
|
package/dist/up/park.js
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { randomBytes } from 'node:crypto';
|
|
2
|
+
import { hasBrowser, stopLaneBrowser } from "../browser/lane-browser.js";
|
|
3
|
+
import { realBrowserTools } from "../browser/tools.js";
|
|
4
|
+
import { stopLaneEngine } from "../driver/client.js";
|
|
5
|
+
import { messageOf } from "../driver/errors.js";
|
|
6
|
+
import { realEvidenceSystem } from "../evidence/device.js";
|
|
7
|
+
import { stopRecordings } from "../evidence/evidence.js";
|
|
8
|
+
import { isProven, judgeProcess } from "../registry/owner.js";
|
|
9
|
+
import { mergeRestarts } from "../registry/parks.js";
|
|
10
|
+
import { laneHasEnded, laneLastCall } from "../registry/touch.js";
|
|
11
|
+
import { describeStop, judgeLeader, stopService } from "../services/services.js";
|
|
12
|
+
import { laneDir, readUpRecord } from "./lane-files.js";
|
|
13
|
+
import { browserControl, clearDeviceState } from "./release.js";
|
|
14
|
+
/** How long a park or wake may stand unfinished before the sweep looks at it again, and between its tries at a lane it could not park in full. */
|
|
15
|
+
export const PARK_RETRY_MS = 5 * 60_000;
|
|
16
|
+
const NOUN = { ios: 'simulator', android: 'emulator' };
|
|
17
|
+
export function attemptId() {
|
|
18
|
+
return randomBytes(6).toString('hex');
|
|
19
|
+
}
|
|
20
|
+
export function deadHolder(park, processes) {
|
|
21
|
+
const holder = park?.holder ?? null;
|
|
22
|
+
if (!holder)
|
|
23
|
+
return null;
|
|
24
|
+
return isProven(judgeProcess(holder, processes.startTimes([holder.pid]))) ? holder : null;
|
|
25
|
+
}
|
|
26
|
+
function bootedNow(backend, id) {
|
|
27
|
+
if (!backend)
|
|
28
|
+
return null;
|
|
29
|
+
try {
|
|
30
|
+
const listed = backend.list().find(d => d.id === id);
|
|
31
|
+
return listed ? listed.booted : null;
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function restartsOf(deps, dir, lane) {
|
|
38
|
+
const device = lane.device;
|
|
39
|
+
const parked = device
|
|
40
|
+
? {
|
|
41
|
+
platform: device.platform,
|
|
42
|
+
name: device.name,
|
|
43
|
+
id: device.id,
|
|
44
|
+
deviceType: device.deviceType,
|
|
45
|
+
deviceTypeName: device.deviceTypeName,
|
|
46
|
+
runtime: device.runtime,
|
|
47
|
+
runtimeName: device.runtimeName,
|
|
48
|
+
booted: bootedNow(deps.devices[device.platform], device.id) ?? true,
|
|
49
|
+
}
|
|
50
|
+
: null;
|
|
51
|
+
return {
|
|
52
|
+
device: parked,
|
|
53
|
+
services: lane.processes.map(p => p.service),
|
|
54
|
+
browser: lane.browser?.driver ?? null,
|
|
55
|
+
app: readUpRecord(laneDir(dir, lane.id))?.bundleId ?? null,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
async function stopEverything(deps, registry, dir, lane) {
|
|
59
|
+
const notes = [];
|
|
60
|
+
const problems = [];
|
|
61
|
+
try {
|
|
62
|
+
if (await stopLaneEngine(dir, lane.id, { processes: deps.processes }))
|
|
63
|
+
notes.push('stopped the driver');
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
problems.push(messageOf(error));
|
|
67
|
+
}
|
|
68
|
+
const tools = deps.browser ?? realBrowserTools;
|
|
69
|
+
const into = { lane: lane.id, notes, problems };
|
|
70
|
+
const control = hasBrowser(lane) ? await browserControl({ env: deps.env, browser: tools }, dir, lane, into) : null;
|
|
71
|
+
const recordings = await stopRecordings({ stateDir: dir, lane, env: deps.env, clock: deps.clock, system: deps.evidence ?? realEvidenceSystem }, control);
|
|
72
|
+
notes.push(...recordings.notes);
|
|
73
|
+
problems.push(...recordings.problems);
|
|
74
|
+
if (hasBrowser(lane)) {
|
|
75
|
+
const stopped = await stopLaneBrowser(tools, dir, lane.id, lane.browser.session, deps.clock, control, true);
|
|
76
|
+
notes.push(...stopped.notes);
|
|
77
|
+
problems.push(...stopped.problems);
|
|
78
|
+
}
|
|
79
|
+
const ref = { id: lane.id, token: lane.token };
|
|
80
|
+
for (const proc of lane.processes) {
|
|
81
|
+
const outcome = await stopService(deps.system, proc, deps.clock);
|
|
82
|
+
const line = describeStop(proc, outcome);
|
|
83
|
+
const down = outcome.kind === 'stopped' ||
|
|
84
|
+
outcome.kind === 'already-gone' ||
|
|
85
|
+
(outcome.kind === 'not-ours' && judgeLeader(deps.system, { ...proc, cwd: null }) === 'pid-reused');
|
|
86
|
+
if (down)
|
|
87
|
+
registry.forgetProcess(ref, proc.service);
|
|
88
|
+
if (outcome.kind === 'stopped' || outcome.kind === 'already-gone')
|
|
89
|
+
notes.push(line);
|
|
90
|
+
else
|
|
91
|
+
problems.push(line);
|
|
92
|
+
}
|
|
93
|
+
await clearDeviceState({ env: deps.env, sim: deps.sim ?? null, ...(deps.adb ? { adb: deps.adb } : {}) }, lane, readUpRecord(laneDir(dir, lane.id)), into);
|
|
94
|
+
return problems;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Parks a lane its owner left unused since `idleSince`, or whose owner a check found gone: stops its driver, browser,
|
|
98
|
+
* recordings and services, clears what `up` left on its device, then frees the device, which goes back to the pool
|
|
99
|
+
* once it is shut down. Its ports, resources and record stay, and the lane is recorded as parked with what its next
|
|
100
|
+
* call restarts. A call that lands meanwhile keeps an idle lane awake.
|
|
101
|
+
*/
|
|
102
|
+
export async function parkLane(deps, registry, candidate, idleSince) {
|
|
103
|
+
const { ref } = candidate;
|
|
104
|
+
const dir = registry.dir;
|
|
105
|
+
const attempt = attemptId();
|
|
106
|
+
let lane;
|
|
107
|
+
try {
|
|
108
|
+
lane = registry.beginPark(ref, idleSince, attempt, deadHolder(candidate.park, deps.processes));
|
|
109
|
+
}
|
|
110
|
+
catch (error) {
|
|
111
|
+
if (laneHasEnded(error))
|
|
112
|
+
return { kind: 'left', lane: ref.id, reason: 'it has ended' };
|
|
113
|
+
throw error;
|
|
114
|
+
}
|
|
115
|
+
if (!lane) {
|
|
116
|
+
const reason = idleSince === 'owner-gone'
|
|
117
|
+
? 'its owner came back, or another call is parking, waking or ending it'
|
|
118
|
+
: 'it was used or held, or another call is parking or waking it';
|
|
119
|
+
return { kind: 'left', lane: ref.id, reason };
|
|
120
|
+
}
|
|
121
|
+
if (idleSince !== 'owner-gone' && laneLastCall(dir, { ...ref, lastUsedAt: lane.lastUsedAt }) > idleSince) {
|
|
122
|
+
registry.abortPark(ref, attempt);
|
|
123
|
+
return { kind: 'left', lane: ref.id, reason: 'it was used' };
|
|
124
|
+
}
|
|
125
|
+
const restarts = mergeRestarts(candidate.park?.restarts ?? restartsOf(deps, dir, lane), restartsOf(deps, dir, lane));
|
|
126
|
+
const notes = [];
|
|
127
|
+
try {
|
|
128
|
+
const problems = await stopEverything(deps, registry, dir, lane);
|
|
129
|
+
if (!registry.finishPark(ref, attempt, restarts, problems, notes)) {
|
|
130
|
+
return { kind: 'left', lane: ref.id, reason: 'another call took it while it was being parked' };
|
|
131
|
+
}
|
|
132
|
+
const device = restarts.device;
|
|
133
|
+
if (device && lane.device && bootedNow(deps.devices[device.platform], device.id) === true) {
|
|
134
|
+
const line = `${NOUN[device.platform]} ${device.name} could not be shut down, so it is back in the pool still running; the next claim on this Mac shuts it down`;
|
|
135
|
+
registry.noteParkProblems(ref, [line]);
|
|
136
|
+
problems.push(line);
|
|
137
|
+
}
|
|
138
|
+
return { kind: 'parked', lane: ref.id, restarts, notes, problems };
|
|
139
|
+
}
|
|
140
|
+
catch (error) {
|
|
141
|
+
if (laneHasEnded(error))
|
|
142
|
+
return { kind: 'left', lane: ref.id, reason: 'it ended while it was being parked' };
|
|
143
|
+
registry.giveUp(ref, attempt, [`parking stopped partway: ${messageOf(error)}`]);
|
|
144
|
+
throw error;
|
|
145
|
+
}
|
|
146
|
+
}
|
package/dist/up/preflight.js
CHANGED
|
@@ -4,6 +4,7 @@ import path from 'node:path';
|
|
|
4
4
|
import { promisify } from 'node:util';
|
|
5
5
|
import { androidToolchain, CacheKeyError, xcodeVersion } from "../cache/key.js";
|
|
6
6
|
import { findAndroidSdk } from "../devices/emulator.js";
|
|
7
|
+
import { registeredJdk17 } from "../driver/install.js";
|
|
7
8
|
import { HOOK_LOCALE, JAVA_HOME_ENV } from "../hooks/env.js";
|
|
8
9
|
import { runCheck } from "../hooks/run.js";
|
|
9
10
|
import { TOOL } from "../name.js";
|
|
@@ -27,15 +28,6 @@ async function javaVersion(home) {
|
|
|
27
28
|
return null;
|
|
28
29
|
}
|
|
29
30
|
}
|
|
30
|
-
async function macJavaHome17() {
|
|
31
|
-
try {
|
|
32
|
-
const { stdout } = await execFileAsync('/usr/libexec/java_home', ['-v', '17'], { timeout: 10_000 });
|
|
33
|
-
return stdout.trim() || null;
|
|
34
|
-
}
|
|
35
|
-
catch {
|
|
36
|
-
return null;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
31
|
function linuxJvms() {
|
|
40
32
|
try {
|
|
41
33
|
return fs
|
|
@@ -75,7 +67,7 @@ export const systemToolchain = {
|
|
|
75
67
|
? [pinned]
|
|
76
68
|
: [
|
|
77
69
|
env.JAVA_HOME,
|
|
78
|
-
await
|
|
70
|
+
await registeredJdk17(),
|
|
79
71
|
'/opt/homebrew/opt/openjdk@17',
|
|
80
72
|
'/usr/local/opt/openjdk@17',
|
|
81
73
|
...linuxJvms(),
|
package/dist/up/release.js
CHANGED
|
@@ -24,7 +24,7 @@ async function stopDriver(deps, stateDir, laneId, into) {
|
|
|
24
24
|
into.problems.push(message(error));
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
-
async function browserControl(deps, stateDir, lane, into) {
|
|
27
|
+
export async function browserControl(deps, stateDir, lane, into) {
|
|
28
28
|
const tools = deps.browser ?? realBrowserTools;
|
|
29
29
|
const state = tools.state(lane.browser.driver, deps.env);
|
|
30
30
|
if (state.kind !== 'installed')
|
|
@@ -52,18 +52,11 @@ export async function stopRecordedProcesses(deps, processes, into) {
|
|
|
52
52
|
into.problems.push(line);
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
const control = hasBrowser(lane) ? await browserControl(deps, stateDir, lane, result) : null;
|
|
61
|
-
const recordings = await stopRecordings({ stateDir, lane, env: deps.env, clock: deps.clock, system: deps.evidence ?? realEvidenceSystem }, control);
|
|
62
|
-
result.notes.push(...recordings.notes);
|
|
63
|
-
result.problems.push(...recordings.problems);
|
|
64
|
-
if (hasBrowser(lane))
|
|
65
|
-
await stopBrowser(deps, stateDir, lane, control, result);
|
|
66
|
-
await stopRecordedProcesses(deps, lane.processes, result);
|
|
55
|
+
/**
|
|
56
|
+
* Clears what `up` left on the lane's device for its app, while the lane still holds the device: the bundler pin and
|
|
57
|
+
* the dial defaults on a booted simulator, and the adb reverse rules on an emulator.
|
|
58
|
+
*/
|
|
59
|
+
export async function clearDeviceState(deps, lane, record, result) {
|
|
67
60
|
const udid = lane.device?.id;
|
|
68
61
|
if (record?.pinned && record.bundleId !== null && udid && deps.sim) {
|
|
69
62
|
try {
|
|
@@ -104,6 +97,20 @@ export async function tearDownLane(deps, stateDir, lane) {
|
|
|
104
97
|
result.notes.push(`left the adb reverse rules on ${serial}: ${message(error)}`);
|
|
105
98
|
}
|
|
106
99
|
}
|
|
100
|
+
}
|
|
101
|
+
export async function tearDownLane(deps, stateDir, lane) {
|
|
102
|
+
const result = { lane: lane.id, notes: [], problems: [] };
|
|
103
|
+
await stopDriver(deps, stateDir, lane.id, result);
|
|
104
|
+
const dir = laneDir(stateDir, lane.id);
|
|
105
|
+
const record = readUpRecord(dir);
|
|
106
|
+
const control = hasBrowser(lane) ? await browserControl(deps, stateDir, lane, result) : null;
|
|
107
|
+
const recordings = await stopRecordings({ stateDir, lane, env: deps.env, clock: deps.clock, system: deps.evidence ?? realEvidenceSystem }, control);
|
|
108
|
+
result.notes.push(...recordings.notes);
|
|
109
|
+
result.problems.push(...recordings.problems);
|
|
110
|
+
if (hasBrowser(lane))
|
|
111
|
+
await stopBrowser(deps, stateDir, lane, control, result);
|
|
112
|
+
await stopRecordedProcesses(deps, lane.processes, result);
|
|
113
|
+
await clearDeviceState(deps, lane, record, result);
|
|
107
114
|
if (record) {
|
|
108
115
|
let teardown = null;
|
|
109
116
|
try {
|
|
@@ -135,14 +142,3 @@ export async function tearDownLane(deps, stateDir, lane) {
|
|
|
135
142
|
}
|
|
136
143
|
return result;
|
|
137
144
|
}
|
|
138
|
-
export async function stopEndedLanes(deps, stateDir, ended) {
|
|
139
|
-
const results = [];
|
|
140
|
-
for (const e of ended) {
|
|
141
|
-
const result = { lane: e.id, notes: [], problems: [] };
|
|
142
|
-
await stopDriver(deps, stateDir, e.id, result);
|
|
143
|
-
await stopRecordedProcesses(deps, e.processes ?? [], result);
|
|
144
|
-
if (result.notes.length > 0 || result.problems.length > 0)
|
|
145
|
-
results.push(result);
|
|
146
|
-
}
|
|
147
|
-
return results;
|
|
148
|
-
}
|
package/dist/up/restart.js
CHANGED
|
@@ -5,10 +5,13 @@ import { describeOwner, resolveOwner } from "../registry/owner.js";
|
|
|
5
5
|
import { stateDir } from "../registry/paths.js";
|
|
6
6
|
import { NotClaimed, UsageError } from "../registry/refusal.js";
|
|
7
7
|
import { Registry } from "../registry/registry.js";
|
|
8
|
+
import { recordCall } from "../registry/touch.js";
|
|
8
9
|
import { resolveFolder } from "../registry-cli.js";
|
|
9
10
|
import { ServiceFailed } from "../services/services.js";
|
|
10
11
|
import { laneDir, readUpRecord } from "./lane-files.js";
|
|
11
12
|
import { claimedPort, recordedProcess, startClaimedService, stopClaimedService } from "./lane-services.js";
|
|
13
|
+
import { enterLane } from "./wake.js";
|
|
14
|
+
import { upWaker } from "./waker.js";
|
|
12
15
|
export async function restart(deps, names, worktree) {
|
|
13
16
|
if (names.length === 0) {
|
|
14
17
|
throw new UsageError('restart needs the name of a service', `${CLI} restart <service>, e.g. KEY=value ${CLI} restart api`);
|
|
@@ -25,10 +28,14 @@ export async function restart(deps, names, worktree) {
|
|
|
25
28
|
...(deps.pollMs !== undefined ? { pollMs: deps.pollMs } : {}),
|
|
26
29
|
});
|
|
27
30
|
try {
|
|
28
|
-
const
|
|
29
|
-
if (!
|
|
31
|
+
const found = registry.takeBack(owner, folder.worktree);
|
|
32
|
+
if (!found) {
|
|
30
33
|
throw new NotClaimed(`${describeOwner(owner)} holds no lane in ${folder.worktree}, so there is no service to restart`, `${CLI} up (it claims a lane, starts every service and launches the app)`);
|
|
31
34
|
}
|
|
35
|
+
recordCall(state, { id: found.id, token: found.token }, deps.clock.now());
|
|
36
|
+
const lane = await enterLane({ stateDir: state, processes: deps.processes, clock: deps.clock }, found, registry.parkOf(found.id), upWaker(deps), line => {
|
|
37
|
+
deps.log(`${TOOL} restart: ${line}`);
|
|
38
|
+
});
|
|
32
39
|
const dir = laneDir(state, lane.id);
|
|
33
40
|
const record = readUpRecord(dir);
|
|
34
41
|
const file = record?.config ?? findProjectConfig(folder.worktree);
|