agentlane 0.0.0 → 0.4.0-rc.2
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 +118 -0
- package/LICENSE +27 -0
- package/README.md +167 -2
- package/dist/agents/claude-plugin.js +79 -0
- package/dist/agents/cli.js +258 -0
- package/dist/agents/detect.js +88 -0
- package/dist/agents/init.js +251 -0
- package/dist/agents/launcher.js +32 -0
- package/dist/agents/package.js +119 -0
- package/dist/agents/skills.js +59 -0
- package/dist/agents/toml.js +325 -0
- package/dist/agents/wiring-check.js +117 -0
- package/dist/agents/wiring.js +374 -0
- package/dist/bench/host.js +104 -0
- package/dist/bench/live.js +511 -0
- package/dist/bench/mcp-client.js +91 -0
- package/dist/bench/model.js +15 -0
- package/dist/bench/report.js +162 -0
- package/dist/bench/run.js +121 -0
- package/dist/bench/schedule.js +140 -0
- package/dist/bench/stats.js +59 -0
- package/dist/bench-cli.js +167 -0
- package/dist/browser/aria.js +184 -0
- package/dist/browser/control.js +203 -0
- package/dist/browser/env.js +118 -0
- package/dist/browser/evidence.js +44 -0
- package/dist/browser/install.js +361 -0
- package/dist/browser/kinds.js +10 -0
- package/dist/browser/lane-browser.js +224 -0
- package/dist/browser/libraries.js +56 -0
- package/dist/browser/paths.js +29 -0
- package/dist/browser/release.js +121 -0
- package/dist/browser/screen.js +19 -0
- package/dist/browser/signin.js +154 -0
- package/dist/browser/stop.js +163 -0
- package/dist/browser/tools.js +25 -0
- package/dist/cache/build.js +154 -0
- package/dist/cache/config.js +186 -0
- package/dist/cache/index.js +4 -0
- package/dist/cache/key.js +196 -0
- package/dist/cache/store.js +303 -0
- package/dist/cli.js +178 -0
- package/dist/clock.js +4 -0
- package/dist/devices/adb.js +160 -0
- package/dist/devices/android.js +214 -0
- package/dist/devices/backend.js +7 -0
- package/dist/devices/bundler.js +46 -0
- package/dist/devices/common.js +51 -0
- package/dist/devices/controls.js +65 -0
- package/dist/devices/dial.js +56 -0
- package/dist/devices/emulator.js +396 -0
- package/dist/devices/hygiene.js +202 -0
- package/dist/devices/index.js +5 -0
- package/dist/devices/launch.js +76 -0
- package/dist/devices/simctl.js +119 -0
- package/dist/devices/tools.js +1 -0
- package/dist/devices/variant.js +99 -0
- package/dist/devices/xcrun.js +265 -0
- package/dist/driver/absence.js +54 -0
- package/dist/driver/caller.js +51 -0
- package/dist/driver/client.js +312 -0
- package/dist/driver/diff.js +180 -0
- package/dist/driver/elements.js +70 -0
- package/dist/driver/engine-main.js +13 -0
- package/dist/driver/engine.js +499 -0
- package/dist/driver/errors.js +11 -0
- package/dist/driver/exec.js +66 -0
- package/dist/driver/failure.js +156 -0
- package/dist/driver/flow.js +94 -0
- package/dist/driver/idle.js +100 -0
- package/dist/driver/images.js +68 -0
- package/dist/driver/install.js +272 -0
- package/dist/driver/lock.js +101 -0
- package/dist/driver/look.js +223 -0
- package/dist/driver/maestro-child.js +194 -0
- package/dist/driver/maestro-runs.js +46 -0
- package/dist/driver/paths.js +105 -0
- package/dist/driver/pixels.js +144 -0
- package/dist/driver/plan.js +108 -0
- package/dist/driver/release.js +7 -0
- package/dist/driver/runner.js +42 -0
- package/dist/driver/selector.js +91 -0
- package/dist/driver/session.js +474 -0
- package/dist/driver/suggest.js +86 -0
- package/dist/driver/supervisor.js +251 -0
- package/dist/driver/tree.js +426 -0
- package/dist/driver-cli.js +865 -0
- package/dist/evidence/device.js +177 -0
- package/dist/evidence/evidence.js +304 -0
- package/dist/evidence/files.js +92 -0
- package/dist/hooks/env.js +81 -0
- package/dist/hooks/run.js +101 -0
- package/dist/mcp/server.js +69 -0
- package/dist/mcp/tools.js +246 -0
- package/dist/name.js +22 -0
- package/dist/plugin/aims.js +465 -0
- package/dist/plugin/conventions.js +73 -0
- package/dist/plugin/guard.js +163 -0
- package/dist/plugin/hook-cli.js +216 -0
- package/dist/plugin/session-name.js +28 -0
- package/dist/plugin/shell.js +254 -0
- package/dist/processes.js +77 -0
- package/dist/project/config.js +316 -0
- package/dist/project/schema.js +335 -0
- package/dist/project/validate.js +224 -0
- package/dist/registry/config.js +142 -0
- package/dist/registry/format.js +22 -0
- package/dist/registry/owner.js +265 -0
- package/dist/registry/paths.js +50 -0
- package/dist/registry/ports.js +26 -0
- package/dist/registry/prune.js +160 -0
- package/dist/registry/refusal.js +53 -0
- package/dist/registry/registry.js +1027 -0
- package/dist/registry/resources.js +117 -0
- package/dist/registry/rows.js +115 -0
- package/dist/registry/status.js +85 -0
- package/dist/registry/store.js +274 -0
- package/dist/registry/types.js +1 -0
- package/dist/registry-cli.js +544 -0
- package/dist/services/services.js +268 -0
- package/dist/services/system.js +189 -0
- package/dist/up/deps.js +1 -0
- package/dist/up/doctor.js +424 -0
- package/dist/up/exec.js +133 -0
- package/dist/up/lane-files.js +75 -0
- package/dist/up/lane-services.js +38 -0
- package/dist/up/maestro-env.js +172 -0
- package/dist/up/preflight.js +232 -0
- package/dist/up/release.js +148 -0
- package/dist/up/resources.js +178 -0
- package/dist/up/restart.js +87 -0
- package/dist/up/setup.js +28 -0
- package/dist/up/up.js +610 -0
- package/dist/up-cli.js +258 -0
- package/dist/usage.js +16 -0
- package/package.json +58 -3
- package/schema/agentlane.schema.json +675 -0
- package/skills/create-verification-skill/LICENSE +21 -0
- package/skills/create-verification-skill/SKILL.md +88 -0
- package/skills/dev-loop/LICENSE +21 -0
- package/skills/dev-loop/SKILL.md +61 -0
- package/skills/device/SKILL.md +8 -0
- package/skills/drive/SKILL.md +64 -0
- package/skills/maintain-verification-skill/LICENSE +21 -0
- package/skills/maintain-verification-skill/SKILL.md +42 -0
- package/skills/setup/SKILL.md +80 -0
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import { BROWSER_PORT_TYPE } from "../browser/kinds.js";
|
|
3
|
+
import { configPath } from "./paths.js";
|
|
4
|
+
import { UsageError } from "./refusal.js";
|
|
5
|
+
export const HOUR_MS = 3_600_000;
|
|
6
|
+
export const DEVICE_MEMORY_MB = { ios: 4000, android: 3400 };
|
|
7
|
+
export const EMULATOR_PORTS = { first: 5554, last: 5585 };
|
|
8
|
+
export const EMULATOR_SERVICE = 'emulator';
|
|
9
|
+
export function emulatorSerial(consolePort) {
|
|
10
|
+
return `emulator-${String(consolePort)}`;
|
|
11
|
+
}
|
|
12
|
+
export function poolCap(config, platform) {
|
|
13
|
+
return platform === 'ios' ? config.poolSize : config.emulatorPoolSize;
|
|
14
|
+
}
|
|
15
|
+
export const DEFAULT_CONFIG = {
|
|
16
|
+
poolSize: 5,
|
|
17
|
+
emulatorPoolSize: 5,
|
|
18
|
+
memoryBudgetMb: 5 * DEVICE_MEMORY_MB.ios,
|
|
19
|
+
idleMs: 2 * HOUR_MS,
|
|
20
|
+
blocks: {
|
|
21
|
+
metro: { first: 41100, last: 41119 },
|
|
22
|
+
api: { first: 41200, last: 41219 },
|
|
23
|
+
web: { first: 41300, last: 41319 },
|
|
24
|
+
[BROWSER_PORT_TYPE]: { first: 41400, last: 41439 },
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
function isRecord(value) {
|
|
28
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
29
|
+
}
|
|
30
|
+
function isPort(value) {
|
|
31
|
+
return Number.isInteger(value) && value >= 1024 && value <= 65535;
|
|
32
|
+
}
|
|
33
|
+
export function parseConfig(raw, source) {
|
|
34
|
+
const bad = (problem, fix) => new UsageError(`${source}: ${problem}`, fix);
|
|
35
|
+
if (!isRecord(raw))
|
|
36
|
+
throw bad('the file is not a JSON object', `write an object such as {"poolSize": 5}`);
|
|
37
|
+
const known = ['poolSize', 'emulatorPoolSize', 'memoryBudgetGB', 'idleHours', 'ports'];
|
|
38
|
+
for (const key of Object.keys(raw)) {
|
|
39
|
+
if (!known.includes(key))
|
|
40
|
+
throw bad(`unknown setting '${key}'`, `use only ${known.join(', ')}`);
|
|
41
|
+
}
|
|
42
|
+
const count = (key, fallback) => {
|
|
43
|
+
const value = raw[key];
|
|
44
|
+
if (value === undefined)
|
|
45
|
+
return fallback;
|
|
46
|
+
if (!Number.isInteger(value) || value < 1) {
|
|
47
|
+
throw bad(`${key} must be a whole number of at least 1`, `set "${key}": ${String(fallback)} (the default) or more`);
|
|
48
|
+
}
|
|
49
|
+
return value;
|
|
50
|
+
};
|
|
51
|
+
const poolSize = count('poolSize', DEFAULT_CONFIG.poolSize);
|
|
52
|
+
const emulatorPoolSize = count('emulatorPoolSize', DEFAULT_CONFIG.emulatorPoolSize);
|
|
53
|
+
let memoryBudgetMb = DEFAULT_CONFIG.memoryBudgetMb;
|
|
54
|
+
if (raw.memoryBudgetGB !== undefined) {
|
|
55
|
+
const oneDevice = Math.max(...Object.values(DEVICE_MEMORY_MB)) / 1000;
|
|
56
|
+
if (typeof raw.memoryBudgetGB !== 'number' || !(raw.memoryBudgetGB >= oneDevice)) {
|
|
57
|
+
throw bad(`memoryBudgetGB must be a number of at least ${String(oneDevice)} (one simulator)`, `set "memoryBudgetGB": ${String(DEFAULT_CONFIG.memoryBudgetMb / 1000)} (the default)`);
|
|
58
|
+
}
|
|
59
|
+
memoryBudgetMb = Math.round(raw.memoryBudgetGB * 1000);
|
|
60
|
+
}
|
|
61
|
+
let idleMs = DEFAULT_CONFIG.idleMs;
|
|
62
|
+
if (raw.idleHours !== undefined) {
|
|
63
|
+
if (typeof raw.idleHours !== 'number' || !(raw.idleHours > 0)) {
|
|
64
|
+
throw bad('idleHours must be a positive number', 'set "idleHours": 2 (the default)');
|
|
65
|
+
}
|
|
66
|
+
idleMs = raw.idleHours * HOUR_MS;
|
|
67
|
+
}
|
|
68
|
+
const blocks = { ...DEFAULT_CONFIG.blocks };
|
|
69
|
+
if (raw.ports !== undefined) {
|
|
70
|
+
if (!isRecord(raw.ports))
|
|
71
|
+
throw bad('ports must be an object of [first, last] ranges', 'set "ports": {"metro": [41100, 41119]}');
|
|
72
|
+
for (const [type, range] of Object.entries(raw.ports)) {
|
|
73
|
+
if (!/^[a-z][a-z0-9-]*$/.test(type)) {
|
|
74
|
+
throw bad(`port block name '${type}' must be lowercase letters, digits and dashes`, 'rename the block, e.g. "metro"');
|
|
75
|
+
}
|
|
76
|
+
if (!Array.isArray(range) || range.length !== 2 || !isPort(range[0]) || !isPort(range[1]) || range[0] > range[1]) {
|
|
77
|
+
throw bad(`ports.${type} must be [first, last] with 1024 <= first <= last <= 65535`, `set "ports": {"${type}": [41100, 41119]}`);
|
|
78
|
+
}
|
|
79
|
+
blocks[type] = { first: range[0], last: range[1] };
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
const overlap = findOverlap(blocks);
|
|
83
|
+
if (overlap)
|
|
84
|
+
throw bad(`port blocks '${overlap[0]}' and '${overlap[1]}' overlap`, 'give each service type its own range of ports');
|
|
85
|
+
const onEmulators = emulatorOverlap(blocks);
|
|
86
|
+
if (onEmulators)
|
|
87
|
+
throw bad(emulatorOverlapProblem(onEmulators), 'move that block clear of 5554-5585');
|
|
88
|
+
return { poolSize, emulatorPoolSize, memoryBudgetMb, idleMs, blocks };
|
|
89
|
+
}
|
|
90
|
+
function emulatorOverlap(blocks) {
|
|
91
|
+
const hit = Object.entries(blocks).find(([, b]) => b.first <= EMULATOR_PORTS.last && b.last >= EMULATOR_PORTS.first);
|
|
92
|
+
return hit ? hit[0] : null;
|
|
93
|
+
}
|
|
94
|
+
function emulatorOverlapProblem(type) {
|
|
95
|
+
return `port block '${type}' overlaps the Android emulator console and adb ports ${String(EMULATOR_PORTS.first)}-${String(EMULATOR_PORTS.last)}`;
|
|
96
|
+
}
|
|
97
|
+
function findOverlap(blocks) {
|
|
98
|
+
const entries = Object.entries(blocks).sort((a, b) => a[1].first - b[1].first);
|
|
99
|
+
for (let i = 1; i < entries.length; i++) {
|
|
100
|
+
const prev = entries[i - 1];
|
|
101
|
+
const cur = entries[i];
|
|
102
|
+
if (prev && cur && cur[1].first <= prev[1].last)
|
|
103
|
+
return [prev[0], cur[0]];
|
|
104
|
+
}
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
export function withProjectBlocks(config, extra, source) {
|
|
108
|
+
const added = Object.entries(extra).filter(([type]) => !(type in config.blocks));
|
|
109
|
+
if (added.length === 0)
|
|
110
|
+
return config;
|
|
111
|
+
const blocks = { ...config.blocks, ...Object.fromEntries(added) };
|
|
112
|
+
const onEmulators = emulatorOverlap(blocks);
|
|
113
|
+
if (onEmulators)
|
|
114
|
+
throw new UsageError(`${source}: ${emulatorOverlapProblem(onEmulators)}`, 'move that block clear of 5554-5585');
|
|
115
|
+
const overlap = findOverlap(blocks);
|
|
116
|
+
if (overlap) {
|
|
117
|
+
throw new UsageError(`${source}: port blocks '${overlap[0]}' and '${overlap[1]}' overlap`, `give the ${added.map(([type]) => type).join(', ')} service type its own range of ports, clear of ${Object.entries(config.blocks)
|
|
118
|
+
.map(([type, b]) => `${type} ${String(b.first)}-${String(b.last)}`)
|
|
119
|
+
.join(', ')}`);
|
|
120
|
+
}
|
|
121
|
+
return { ...config, blocks };
|
|
122
|
+
}
|
|
123
|
+
export function loadConfig(dir) {
|
|
124
|
+
const file = configPath(dir);
|
|
125
|
+
let text;
|
|
126
|
+
try {
|
|
127
|
+
text = fs.readFileSync(file, 'utf8');
|
|
128
|
+
}
|
|
129
|
+
catch (error) {
|
|
130
|
+
if (error.code === 'ENOENT')
|
|
131
|
+
return DEFAULT_CONFIG;
|
|
132
|
+
throw error;
|
|
133
|
+
}
|
|
134
|
+
let raw;
|
|
135
|
+
try {
|
|
136
|
+
raw = JSON.parse(text);
|
|
137
|
+
}
|
|
138
|
+
catch {
|
|
139
|
+
throw new UsageError(`${file}: not valid JSON`, `fix the JSON, or delete the file to use the defaults`);
|
|
140
|
+
}
|
|
141
|
+
return parseConfig(raw, file);
|
|
142
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
function pad(n) {
|
|
2
|
+
return String(n).padStart(2, '0');
|
|
3
|
+
}
|
|
4
|
+
export function formatTime(ms) {
|
|
5
|
+
const d = new Date(ms);
|
|
6
|
+
return `${String(d.getFullYear())}-${pad(d.getMonth() + 1)}-${pad(d.getDate())} ${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}`;
|
|
7
|
+
}
|
|
8
|
+
export function formatAge(ms) {
|
|
9
|
+
const s = Math.max(0, Math.floor(ms / 1000));
|
|
10
|
+
if (s < 60)
|
|
11
|
+
return `${String(s)}s`;
|
|
12
|
+
const m = Math.floor(s / 60);
|
|
13
|
+
if (m < 60)
|
|
14
|
+
return `${String(m)}m`;
|
|
15
|
+
const h = Math.floor(m / 60);
|
|
16
|
+
if (h < 48)
|
|
17
|
+
return `${String(h)}h ${String(m % 60)}m`;
|
|
18
|
+
return `${String(Math.floor(h / 24))}d ${String(h % 24)}h`;
|
|
19
|
+
}
|
|
20
|
+
export function shellQuote(value) {
|
|
21
|
+
return /^[\w@%+=:,./-]+$/.test(value) ? value : `'${value.replaceAll("'", "'\\''")}'`;
|
|
22
|
+
}
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import os from 'node:os';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { envName } from "../name.js";
|
|
5
|
+
import { identityOf } from "../processes.js";
|
|
6
|
+
import { UsageError } from "./refusal.js";
|
|
7
|
+
export const AGENTS = ['claude', 'codex', 'cursor', 'copilot', 'gemini', 'antigravity'];
|
|
8
|
+
const SIGNATURES = {
|
|
9
|
+
cursor: {
|
|
10
|
+
markers: ['CURSOR_AGENT', 'CURSOR_CONVERSATION_ID'],
|
|
11
|
+
session: 'CURSOR_CONVERSATION_ID',
|
|
12
|
+
programs: ['cursor-agent'],
|
|
13
|
+
paths: ['/cursor-agent/'],
|
|
14
|
+
apps: ['/Cursor.app/'],
|
|
15
|
+
},
|
|
16
|
+
copilot: {
|
|
17
|
+
markers: ['COPILOT_CLI', 'COPILOT_AGENT_SESSION_ID', 'COPILOT_RUN_APP'],
|
|
18
|
+
session: 'COPILOT_AGENT_SESSION_ID',
|
|
19
|
+
programs: ['copilot', 'github-copilot-cli'],
|
|
20
|
+
paths: ['/@github/copilot/'],
|
|
21
|
+
apps: [],
|
|
22
|
+
},
|
|
23
|
+
gemini: {
|
|
24
|
+
markers: ['GEMINI_CLI'],
|
|
25
|
+
session: 'GEMINI_SESSION_ID',
|
|
26
|
+
programs: ['gemini'],
|
|
27
|
+
paths: ['/@google/gemini-cli/'],
|
|
28
|
+
apps: [],
|
|
29
|
+
},
|
|
30
|
+
antigravity: {
|
|
31
|
+
markers: ['ANTIGRAVITY_AGENT', 'ANTIGRAVITY_TRAJECTORY_ID'],
|
|
32
|
+
session: 'ANTIGRAVITY_TRAJECTORY_ID',
|
|
33
|
+
programs: ['agy'],
|
|
34
|
+
paths: [],
|
|
35
|
+
apps: ['/Antigravity.app/'],
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
const PROCESS_AGENTS = Object.keys(SIGNATURES);
|
|
39
|
+
function isProcessAgent(value) {
|
|
40
|
+
return PROCESS_AGENTS.includes(value);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* The agent behind an owner. Toolkit 0.1.3 throws when it releases a lane whose stored kind it doesn't know, so an
|
|
44
|
+
* owner from Cursor, Copilot, Gemini or Antigravity is stored as kind `process`, with `<agent>[:<session id>]` in
|
|
45
|
+
* its session column.
|
|
46
|
+
*/
|
|
47
|
+
export function agentOf(owner) {
|
|
48
|
+
if (owner.kind !== 'process')
|
|
49
|
+
return owner.kind;
|
|
50
|
+
const tag = owner.sessionId?.split(':', 1)[0] ?? '';
|
|
51
|
+
return isProcessAgent(tag) ? tag : null;
|
|
52
|
+
}
|
|
53
|
+
function agentSession(owner) {
|
|
54
|
+
const id = owner.sessionId;
|
|
55
|
+
if (id === null)
|
|
56
|
+
return null;
|
|
57
|
+
const at = id.indexOf(':');
|
|
58
|
+
return at === -1 ? null : id.slice(at + 1);
|
|
59
|
+
}
|
|
60
|
+
export function isProven(state) {
|
|
61
|
+
return state === 'dead' || state === 'pid-reused' || state === 'worktree-gone';
|
|
62
|
+
}
|
|
63
|
+
export const OWNER_PID_ENV = envName('OWNER_PID');
|
|
64
|
+
export function ownerKey(owner) {
|
|
65
|
+
if (owner.kind === 'codex' && owner.threadId)
|
|
66
|
+
return `codex:thread:${owner.threadId}`;
|
|
67
|
+
if (!owner.process)
|
|
68
|
+
throw new Error(`a ${owner.kind} owner needs a process or a thread id`);
|
|
69
|
+
const label = owner.kind === 'process' ? (agentOf(owner) ?? 'process') : owner.kind;
|
|
70
|
+
return `${label}:${String(owner.process.pid)}:${owner.process.start}`;
|
|
71
|
+
}
|
|
72
|
+
export function describeOwner(owner) {
|
|
73
|
+
const pid = owner.process ? `pid ${String(owner.process.pid)}` : null;
|
|
74
|
+
const agent = agentOf(owner);
|
|
75
|
+
if (owner.kind === 'process' && agent !== null) {
|
|
76
|
+
const session = agentSession(owner);
|
|
77
|
+
return session ? `${agent} session ${session.slice(0, 8)} (${pid ?? 'no pid'})` : `${agent} ${pid ?? 'session'}`;
|
|
78
|
+
}
|
|
79
|
+
switch (owner.kind) {
|
|
80
|
+
case 'claude':
|
|
81
|
+
return owner.sessionId
|
|
82
|
+
? `claude session ${owner.sessionId.slice(0, 8)} (${pid ?? 'no pid'})`
|
|
83
|
+
: `claude ${pid ?? 'session'}`;
|
|
84
|
+
case 'codex':
|
|
85
|
+
if (owner.threadId)
|
|
86
|
+
return `codex thread ${owner.threadId}${pid ? ` (${pid})` : ' (no process recorded)'}`;
|
|
87
|
+
return `codex ${pid ?? 'session'}`;
|
|
88
|
+
case 'process':
|
|
89
|
+
return owner.process ? `process ${String(owner.process.pid)}` : 'process (unknown pid)';
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
export function judgeProcess(identity, table) {
|
|
93
|
+
if (!identity || !table)
|
|
94
|
+
return 'cant-tell';
|
|
95
|
+
const start = table.get(identity.pid);
|
|
96
|
+
if (start === undefined)
|
|
97
|
+
return 'dead';
|
|
98
|
+
return start === identity.start ? 'alive' : 'pid-reused';
|
|
99
|
+
}
|
|
100
|
+
export function worktreeState(dir) {
|
|
101
|
+
try {
|
|
102
|
+
return fs.statSync(dir).isDirectory() ? 'present' : 'gone';
|
|
103
|
+
}
|
|
104
|
+
catch (error) {
|
|
105
|
+
const code = error.code;
|
|
106
|
+
return code === 'ENOENT' || code === 'ENOTDIR' ? 'gone' : 'unknown';
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
export function ownerState(verdict, worktree) {
|
|
110
|
+
if (verdict === 'dead' || verdict === 'pid-reused')
|
|
111
|
+
return verdict;
|
|
112
|
+
if (worktree === 'gone')
|
|
113
|
+
return 'worktree-gone';
|
|
114
|
+
return verdict;
|
|
115
|
+
}
|
|
116
|
+
export function describeState(state) {
|
|
117
|
+
switch (state) {
|
|
118
|
+
case 'alive':
|
|
119
|
+
return 'alive';
|
|
120
|
+
case 'dead':
|
|
121
|
+
return 'owner dead';
|
|
122
|
+
case 'pid-reused':
|
|
123
|
+
return 'owner pid reused by another process';
|
|
124
|
+
case 'worktree-gone':
|
|
125
|
+
return 'worktree gone';
|
|
126
|
+
case 'cant-tell':
|
|
127
|
+
return "can't tell";
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
const WRAPPERS = new Set(['node', 'npm', 'npx', 'pnpm', 'pnpx', 'yarn', 'corepack', 'env', 'bun', 'tsx']);
|
|
131
|
+
function argv(info) {
|
|
132
|
+
return info.command.trim().split(/\s+/);
|
|
133
|
+
}
|
|
134
|
+
function commandNames(info) {
|
|
135
|
+
return argv(info)
|
|
136
|
+
.slice(0, 2)
|
|
137
|
+
.map(token => path.basename(token).replace(/^-/, ''));
|
|
138
|
+
}
|
|
139
|
+
export function codexHome(env) {
|
|
140
|
+
const configured = env.CODEX_HOME;
|
|
141
|
+
if (configured && path.isAbsolute(configured))
|
|
142
|
+
return path.resolve(configured);
|
|
143
|
+
return path.join(env.HOME && path.isAbsolute(env.HOME) ? env.HOME : os.homedir(), '.codex');
|
|
144
|
+
}
|
|
145
|
+
export function isCodexDaemon(info, home) {
|
|
146
|
+
const args = argv(info);
|
|
147
|
+
const executable = args[0] ?? '';
|
|
148
|
+
if (path.basename(executable) !== 'codex')
|
|
149
|
+
return false;
|
|
150
|
+
if (executable.startsWith(path.join(home, 'packages', 'app-server-daemon') + path.sep))
|
|
151
|
+
return true;
|
|
152
|
+
if (!args.includes('app-server'))
|
|
153
|
+
return false;
|
|
154
|
+
const listensOnSocket = args.some((arg, i) => arg.startsWith('--listen=unix://') || (arg === '--listen' && (args[i + 1] ?? '').startsWith('unix://')));
|
|
155
|
+
return listensOnSocket || args.includes('--managed-daemon');
|
|
156
|
+
}
|
|
157
|
+
function sessionAncestors(table, selfPid, home) {
|
|
158
|
+
const ancestors = [];
|
|
159
|
+
let pid = table.info(selfPid)?.ppid ?? 0;
|
|
160
|
+
while (pid > 1 && ancestors.length < 32) {
|
|
161
|
+
const info = table.info(pid);
|
|
162
|
+
if (!info)
|
|
163
|
+
break;
|
|
164
|
+
if (isCodexDaemon(info, home))
|
|
165
|
+
return { ancestors, underCodexDaemon: true };
|
|
166
|
+
ancestors.push(info);
|
|
167
|
+
pid = info.ppid;
|
|
168
|
+
}
|
|
169
|
+
return { ancestors, underCodexDaemon: false };
|
|
170
|
+
}
|
|
171
|
+
const INTERPRETERS = new Set(['node', 'bun', 'deno']);
|
|
172
|
+
function programPaths(info) {
|
|
173
|
+
const args = argv(info);
|
|
174
|
+
const executable = args[0] ?? '';
|
|
175
|
+
if (!INTERPRETERS.has(path.basename(executable)))
|
|
176
|
+
return [executable];
|
|
177
|
+
const script = args.slice(1).find(arg => !arg.startsWith('-'));
|
|
178
|
+
return script === undefined ? [executable] : [executable, script];
|
|
179
|
+
}
|
|
180
|
+
function runsProgram(info, agent) {
|
|
181
|
+
if (agent === 'claude' || agent === 'codex')
|
|
182
|
+
return commandNames(info).includes(agent);
|
|
183
|
+
const signature = SIGNATURES[agent];
|
|
184
|
+
return programPaths(info).some(program => signature.programs.includes(path.basename(program).replace(/^-/, '')) ||
|
|
185
|
+
signature.paths.some(fragment => program.includes(fragment)));
|
|
186
|
+
}
|
|
187
|
+
function insideApp(info, agent) {
|
|
188
|
+
return agent !== 'claude' && agent !== 'codex' && SIGNATURES[agent].apps.some(app => info.command.includes(app));
|
|
189
|
+
}
|
|
190
|
+
function present(env, name) {
|
|
191
|
+
const value = env[name];
|
|
192
|
+
return value === undefined || value === '' ? null : value;
|
|
193
|
+
}
|
|
194
|
+
export function agentMarker(env, agent) {
|
|
195
|
+
const names = agent === 'claude' ? ['CLAUDE_PID'] : agent === 'codex' ? ['CODEX_THREAD_ID'] : SIGNATURES[agent].markers;
|
|
196
|
+
return names.find(name => present(env, name) !== null) ?? null;
|
|
197
|
+
}
|
|
198
|
+
function markedAgents(env) {
|
|
199
|
+
return AGENTS.filter(agent => agentMarker(env, agent) !== null);
|
|
200
|
+
}
|
|
201
|
+
function nearestAgent(chain, env) {
|
|
202
|
+
// Claude Code sets CLAUDE_PID for its Bash commands only. Its MCP servers inherit the value from whatever started
|
|
203
|
+
// Claude Code, which names another session when one Claude Code runs inside another. Codex sets CODEX_THREAD_ID the
|
|
204
|
+
// same way, and Cursor, Copilot, Gemini and Antigravity mark the shell commands they run with their own variables,
|
|
205
|
+
// so with more than one agent's variable set, all but one were inherited from an outer session.
|
|
206
|
+
const marked = markedAgents(env);
|
|
207
|
+
const candidates = marked.length === 1 ? marked : AGENTS;
|
|
208
|
+
for (const [i, info] of chain.entries()) {
|
|
209
|
+
const agent = candidates.find(a => runsProgram(info, a) || (marked.includes(a) && insideApp(info, a)));
|
|
210
|
+
if (agent === undefined)
|
|
211
|
+
continue;
|
|
212
|
+
if (!insideApp(info, agent))
|
|
213
|
+
return { agent, info };
|
|
214
|
+
let app = info;
|
|
215
|
+
for (const above of chain.slice(i + 1)) {
|
|
216
|
+
if (!insideApp(above, agent))
|
|
217
|
+
break;
|
|
218
|
+
app = above;
|
|
219
|
+
}
|
|
220
|
+
return { agent, info: app };
|
|
221
|
+
}
|
|
222
|
+
return null;
|
|
223
|
+
}
|
|
224
|
+
function agentOwner(agent, process, env) {
|
|
225
|
+
const variable = SIGNATURES[agent].session;
|
|
226
|
+
const session = variable === null ? null : present(env, variable);
|
|
227
|
+
return { kind: 'process', process, sessionId: session === null ? agent : `${agent}:${session}`, threadId: null };
|
|
228
|
+
}
|
|
229
|
+
function liveIdentity(table, raw, variable, fix) {
|
|
230
|
+
const pid = Number(raw);
|
|
231
|
+
const identity = Number.isInteger(pid) && pid > 1 ? identityOf(table, pid) : undefined;
|
|
232
|
+
if (!identity)
|
|
233
|
+
throw new UsageError(`${variable}=${raw} is not a running process`, fix);
|
|
234
|
+
return identity;
|
|
235
|
+
}
|
|
236
|
+
export function resolveOwner(env, table, selfPid = process.pid) {
|
|
237
|
+
const pinned = env[OWNER_PID_ENV];
|
|
238
|
+
if (pinned) {
|
|
239
|
+
const identity = liveIdentity(table, pinned, OWNER_PID_ENV, `set ${OWNER_PID_ENV} to the pid of a process that lives as long as the lane should`);
|
|
240
|
+
return { kind: 'process', process: identity, sessionId: null, threadId: null };
|
|
241
|
+
}
|
|
242
|
+
const sessionId = present(env, 'CLAUDE_CODE_SESSION_ID');
|
|
243
|
+
const { ancestors: chain, underCodexDaemon } = sessionAncestors(table, selfPid, codexHome(env));
|
|
244
|
+
const identity = (info) => ({ pid: info.pid, start: info.start });
|
|
245
|
+
const threadId = present(env, 'CODEX_THREAD_ID');
|
|
246
|
+
const claudePid = present(env, 'CLAUDE_PID');
|
|
247
|
+
const nearest = nearestAgent(chain, env);
|
|
248
|
+
if (nearest?.agent === 'claude')
|
|
249
|
+
return { kind: 'claude', process: identity(nearest.info), sessionId, threadId: null };
|
|
250
|
+
if (nearest?.agent === 'codex')
|
|
251
|
+
return { kind: 'codex', process: identity(nearest.info), sessionId: null, threadId };
|
|
252
|
+
if (nearest)
|
|
253
|
+
return agentOwner(nearest.agent, identity(nearest.info), env);
|
|
254
|
+
if (threadId && (underCodexDaemon || claudePid === null))
|
|
255
|
+
return { kind: 'codex', process: null, sessionId: null, threadId };
|
|
256
|
+
if (claudePid !== null) {
|
|
257
|
+
const fromEnv = liveIdentity(table, claudePid, 'CLAUDE_PID', `run this from a live Claude Code session, or set ${OWNER_PID_ENV}`);
|
|
258
|
+
return { kind: 'claude', process: fromEnv, sessionId, threadId: null };
|
|
259
|
+
}
|
|
260
|
+
const shell = chain.find(info => !WRAPPERS.has(commandNames(info)[0] ?? ''));
|
|
261
|
+
if (!shell) {
|
|
262
|
+
throw new UsageError('could not find the session or shell that owns this lane', `set ${OWNER_PID_ENV} to the pid of a process that lives as long as the lane should`);
|
|
263
|
+
}
|
|
264
|
+
return { kind: 'process', process: identity(shell), sessionId: null, threadId: null };
|
|
265
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import os from 'node:os';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { EMULATOR_NAME_PREFIX, envName, FORMER, POOL_NAME_PREFIX, TOOL } from "../name.js";
|
|
5
|
+
export const STATE_DIR_ENV = envName('STATE_DIR');
|
|
6
|
+
/**
|
|
7
|
+
* The registry's folder. On a Mac where 0.2.x keeps its registry and this version has none of its own, it is 0.2.x's
|
|
8
|
+
* folder, because 0.2.x reads only that one: both versions then hand out ports, devices and browsers from one registry.
|
|
9
|
+
*/
|
|
10
|
+
export function stateDir(env = process.env) {
|
|
11
|
+
const override = env[STATE_DIR_ENV];
|
|
12
|
+
if (override)
|
|
13
|
+
return path.resolve(override);
|
|
14
|
+
const xdg = env.XDG_STATE_HOME;
|
|
15
|
+
const base = xdg && path.isAbsolute(xdg) ? xdg : path.join(os.homedir(), '.local', 'state');
|
|
16
|
+
const own = path.join(base, TOOL);
|
|
17
|
+
const former = path.join(base, FORMER.tool);
|
|
18
|
+
return !fs.existsSync(databasePath(own)) && fs.existsSync(databasePath(former)) ? former : own;
|
|
19
|
+
}
|
|
20
|
+
/** The names this version writes in a state folder: in 0.2.x's folder, 0.2.x's names, because 0.2.x reads them there. */
|
|
21
|
+
export function diskNames(dir) {
|
|
22
|
+
if (path.basename(dir) === FORMER.tool) {
|
|
23
|
+
return {
|
|
24
|
+
lanes: FORMER.lanesFolder,
|
|
25
|
+
tool: FORMER.tool,
|
|
26
|
+
pool: { ios: FORMER.poolNamePrefix, android: FORMER.emulatorNamePrefix },
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
return { lanes: 'lanes', tool: TOOL, pool: { ios: POOL_NAME_PREFIX, android: EMULATOR_NAME_PREFIX } };
|
|
30
|
+
}
|
|
31
|
+
const POOL_NAMES = {
|
|
32
|
+
ios: new RegExp(`^(?:${POOL_NAME_PREFIX}|${FORMER.poolNamePrefix})[0-9a-f]{6}$`),
|
|
33
|
+
android: new RegExp(`^(?:${EMULATOR_NAME_PREFIX}|${FORMER.emulatorNamePrefix})[0-9a-f]{6}$`),
|
|
34
|
+
};
|
|
35
|
+
/** Whether a device of this platform has a name the registry gives pool devices, in this version or 0.2.x. */
|
|
36
|
+
export function isPoolName(platform, name) {
|
|
37
|
+
return POOL_NAMES[platform].test(name);
|
|
38
|
+
}
|
|
39
|
+
export function lanesRoot(dir) {
|
|
40
|
+
return path.join(dir, diskNames(dir).lanes);
|
|
41
|
+
}
|
|
42
|
+
export function databasePath(dir) {
|
|
43
|
+
return path.join(dir, 'registry.sqlite');
|
|
44
|
+
}
|
|
45
|
+
export function configPath(dir) {
|
|
46
|
+
return path.join(dir, 'config.json');
|
|
47
|
+
}
|
|
48
|
+
export function lockHolderPath(dir) {
|
|
49
|
+
return path.join(dir, 'lock-holder.json');
|
|
50
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import net from 'node:net';
|
|
2
|
+
const NOTHING_THERE = new Set(['ECONNREFUSED', 'EADDRNOTAVAIL', 'ENETUNREACH', 'EAFNOSUPPORT', 'EHOSTUNREACH']);
|
|
3
|
+
function answers(host, port, timeoutMs) {
|
|
4
|
+
return new Promise(resolve => {
|
|
5
|
+
const socket = net.connect({ host, port });
|
|
6
|
+
const done = (listening) => {
|
|
7
|
+
socket.destroy();
|
|
8
|
+
resolve(listening);
|
|
9
|
+
};
|
|
10
|
+
socket.setTimeout(timeoutMs, () => {
|
|
11
|
+
done(true);
|
|
12
|
+
});
|
|
13
|
+
socket.once('connect', () => {
|
|
14
|
+
done(true);
|
|
15
|
+
});
|
|
16
|
+
socket.once('error', (error) => {
|
|
17
|
+
done(!NOTHING_THERE.has(error.code ?? ''));
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
export const tcpProbe = {
|
|
22
|
+
async listening(ports) {
|
|
23
|
+
const results = await Promise.all(ports.map(async (port) => ((await answers('127.0.0.1', port, 500)) || (await answers('::1', port, 500)) ? port : null)));
|
|
24
|
+
return new Set(results.filter((p) => p !== null));
|
|
25
|
+
},
|
|
26
|
+
};
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { CLI, TOOL } from "../name.js";
|
|
2
|
+
import { isPoolName } from "./paths.js";
|
|
3
|
+
import { optText, text } from "./store.js";
|
|
4
|
+
const NOUN = { ios: 'simulator', android: 'emulator' };
|
|
5
|
+
const HAND_DELETE = {
|
|
6
|
+
ios: 'xcrun simctl delete <id>',
|
|
7
|
+
android: 'avdmanager delete avd -n <name>',
|
|
8
|
+
};
|
|
9
|
+
function messageOf(error) {
|
|
10
|
+
return error instanceof Error ? error.message : String(error);
|
|
11
|
+
}
|
|
12
|
+
function noTool(platform) {
|
|
13
|
+
return `this machine has no ${NOUN[platform]} tool to check it with`;
|
|
14
|
+
}
|
|
15
|
+
export function listPrunable(store, dir, backends) {
|
|
16
|
+
const listing = { stateDir: dir, free: [], kept: [], unrecorded: [] };
|
|
17
|
+
const listed = new Map();
|
|
18
|
+
for (const backend of Object.values(backends)) {
|
|
19
|
+
try {
|
|
20
|
+
listed.set(backend.platform, new Map(backend.list().map(d => [d.id, d])));
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
listed.set(backend.platform, error instanceof Error ? error : new Error(String(error)));
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
const recorded = new Set();
|
|
27
|
+
const rows = store ? store.db.prepare('SELECT * FROM devices ORDER BY created_at, name').all() : [];
|
|
28
|
+
for (const row of rows) {
|
|
29
|
+
const name = text(row, 'name');
|
|
30
|
+
const platform = text(row, 'platform');
|
|
31
|
+
const id = optText(row, 'device_id');
|
|
32
|
+
const laneId = optText(row, 'claim_id');
|
|
33
|
+
recorded.add(`${platform} ${name}`);
|
|
34
|
+
if (id !== null)
|
|
35
|
+
recorded.add(`${platform} ${id}`);
|
|
36
|
+
const keep = (reason) => listing.kept.push({ name, platform, id, laneId, reason });
|
|
37
|
+
const devices = listed.get(platform);
|
|
38
|
+
if (laneId !== null)
|
|
39
|
+
keep(`held by lane ${laneId}`);
|
|
40
|
+
else if (id === null)
|
|
41
|
+
keep('a claim is creating it');
|
|
42
|
+
else if (!isPoolName(platform, name))
|
|
43
|
+
keep('its name is not a pool name');
|
|
44
|
+
else if (devices === undefined)
|
|
45
|
+
keep(noTool(platform));
|
|
46
|
+
else if (devices instanceof Error)
|
|
47
|
+
keep(`could not list the ${NOUN[platform]}s: ${devices.message}`);
|
|
48
|
+
else {
|
|
49
|
+
const device = devices.get(id);
|
|
50
|
+
if (device && device.name !== name)
|
|
51
|
+
keep(`${id} is named ${device.name} now`);
|
|
52
|
+
else {
|
|
53
|
+
listing.free.push({
|
|
54
|
+
name,
|
|
55
|
+
platform,
|
|
56
|
+
id,
|
|
57
|
+
deviceTypeName: text(row, 'device_type_name'),
|
|
58
|
+
runtimeName: text(row, 'runtime_name'),
|
|
59
|
+
state: device === undefined ? 'missing' : device.booted ? 'booted' : 'shutdown',
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
for (const [platform, devices] of listed) {
|
|
65
|
+
if (devices instanceof Error)
|
|
66
|
+
continue;
|
|
67
|
+
for (const d of devices.values()) {
|
|
68
|
+
if (recorded.has(`${platform} ${d.id}`) || recorded.has(`${platform} ${d.name}`))
|
|
69
|
+
continue;
|
|
70
|
+
if (isPoolName(platform, d.name))
|
|
71
|
+
listing.unrecorded.push({ name: d.name, platform, id: d.id });
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
listing.unrecorded.sort((a, b) => a.platform.localeCompare(b.platform) || a.name.localeCompare(b.name));
|
|
75
|
+
return listing;
|
|
76
|
+
}
|
|
77
|
+
export function deletePoolDevice(db, backend, device) {
|
|
78
|
+
const result = (outcome, detail = null) => ({ device, outcome, detail });
|
|
79
|
+
const row = db.prepare('SELECT * FROM devices WHERE name = ?').get(device.name);
|
|
80
|
+
if (!row || optText(row, 'device_id') !== device.id || text(row, 'platform') !== device.platform) {
|
|
81
|
+
return result('kept', 'its registry record changed after the listing');
|
|
82
|
+
}
|
|
83
|
+
const laneId = optText(row, 'claim_id');
|
|
84
|
+
if (laneId !== null)
|
|
85
|
+
return result('kept', `lane ${laneId} claimed it after the listing`);
|
|
86
|
+
if (!isPoolName(device.platform, device.name))
|
|
87
|
+
return result('kept', 'its name is not a pool name');
|
|
88
|
+
if (!backend)
|
|
89
|
+
return result('kept', noTool(device.platform));
|
|
90
|
+
let present;
|
|
91
|
+
try {
|
|
92
|
+
present = backend.list().find(d => d.id === device.id);
|
|
93
|
+
}
|
|
94
|
+
catch (error) {
|
|
95
|
+
return result('failed', `could not list the ${NOUN[device.platform]}s: ${messageOf(error)}`);
|
|
96
|
+
}
|
|
97
|
+
if (present && present.name !== device.name)
|
|
98
|
+
return result('kept', `${device.id} is named ${present.name} now`);
|
|
99
|
+
if (present) {
|
|
100
|
+
try {
|
|
101
|
+
if (present.booted)
|
|
102
|
+
backend.shutdown(device.id);
|
|
103
|
+
backend.delete(device.id);
|
|
104
|
+
}
|
|
105
|
+
catch (error) {
|
|
106
|
+
return result('failed', messageOf(error));
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
db.prepare('DELETE FROM devices WHERE name = ?').run(device.name);
|
|
110
|
+
return present ? result('deleted') : result('forgotten', 'it no longer exists');
|
|
111
|
+
}
|
|
112
|
+
function shownId(d) {
|
|
113
|
+
return d.id === null || d.id === d.name ? '' : ` ${d.id}`;
|
|
114
|
+
}
|
|
115
|
+
const STATE = {
|
|
116
|
+
shutdown: 'shutdown',
|
|
117
|
+
booted: 'booted, so it is shut down first',
|
|
118
|
+
missing: 'already deleted, so only its record goes',
|
|
119
|
+
};
|
|
120
|
+
export function renderPruneListing(listing, deleting) {
|
|
121
|
+
const lines = [`${TOOL} registry: ${listing.stateDir}`, ''];
|
|
122
|
+
const { free, kept, unrecorded } = listing;
|
|
123
|
+
if (free.length === 0)
|
|
124
|
+
lines.push('no pool device is free to delete');
|
|
125
|
+
else {
|
|
126
|
+
lines.push(`pool devices no lane holds (${String(free.length)}):`);
|
|
127
|
+
for (const d of free) {
|
|
128
|
+
lines.push(` ${d.name} ${NOUN[d.platform]} ${d.deviceTypeName}, ${d.runtimeName}${shownId(d)} ${STATE[d.state]}`);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
if (kept.length > 0) {
|
|
132
|
+
lines.push('', `kept (${String(kept.length)}):`);
|
|
133
|
+
for (const d of kept)
|
|
134
|
+
lines.push(` ${d.name} ${NOUN[d.platform]}${shownId(d)} ${d.reason}`);
|
|
135
|
+
}
|
|
136
|
+
if (unrecorded.length > 0) {
|
|
137
|
+
lines.push('', `named like pool devices but not in this registry, so left alone (${String(unrecorded.length)}):`);
|
|
138
|
+
for (const d of unrecorded)
|
|
139
|
+
lines.push(` ${d.name} ${NOUN[d.platform]}${shownId(d)}`);
|
|
140
|
+
const platforms = [...new Set(unrecorded.map(d => d.platform))];
|
|
141
|
+
lines.push(` a registry in another state folder may hold them; if none does, ${platforms.map(p => HAND_DELETE[p]).join(' or ')} deletes one`);
|
|
142
|
+
}
|
|
143
|
+
if (!deleting && free.length > 0) {
|
|
144
|
+
lines.push('', `${CLI} prune --yes deletes the ${String(free.length)} pool device${free.length === 1 ? '' : 's'} no lane holds`);
|
|
145
|
+
}
|
|
146
|
+
return `${lines.join('\n')}\n`;
|
|
147
|
+
}
|
|
148
|
+
export function describePruneResult(r) {
|
|
149
|
+
const { name, platform } = r.device;
|
|
150
|
+
switch (r.outcome) {
|
|
151
|
+
case 'deleted':
|
|
152
|
+
return `deleted ${name} (${NOUN[platform]}${r.device.id === name ? '' : ` ${r.device.id}`})`;
|
|
153
|
+
case 'forgotten':
|
|
154
|
+
return `forgot ${name}: ${r.detail ?? ''}`;
|
|
155
|
+
case 'kept':
|
|
156
|
+
return `kept ${name}: ${r.detail ?? ''}`;
|
|
157
|
+
case 'failed':
|
|
158
|
+
return `could not delete ${name}: ${r.detail ?? ''}`;
|
|
159
|
+
}
|
|
160
|
+
}
|