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,177 @@
|
|
|
1
|
+
import { spawn, spawnSync } from 'node:child_process';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import { DriverError } from "../driver/errors.js";
|
|
4
|
+
import { isAlive, runCommand, tail } from "../driver/exec.js";
|
|
5
|
+
import { TOOL } from "../name.js";
|
|
6
|
+
export const realEvidenceSystem = {
|
|
7
|
+
run: (command, args, timeoutMs) => runCommand(command, args, { timeoutMs }),
|
|
8
|
+
start(command, args, log) {
|
|
9
|
+
const out = fs.openSync(log, 'a', 0o600);
|
|
10
|
+
try {
|
|
11
|
+
const child = spawn(command, [...args], { detached: true, stdio: ['ignore', out, out] });
|
|
12
|
+
child.on('error', () => undefined);
|
|
13
|
+
child.unref();
|
|
14
|
+
return child.pid;
|
|
15
|
+
}
|
|
16
|
+
finally {
|
|
17
|
+
fs.closeSync(out);
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
commandOf(pid) {
|
|
21
|
+
if (!isAlive(pid))
|
|
22
|
+
return undefined;
|
|
23
|
+
const result = spawnSync('ps', ['-o', 'command=', '-p', String(pid)], {
|
|
24
|
+
encoding: 'utf8',
|
|
25
|
+
env: { PATH: '/usr/bin:/bin', LC_ALL: 'C' },
|
|
26
|
+
timeout: 10_000,
|
|
27
|
+
});
|
|
28
|
+
return result.status === 0 && result.stdout.trim() !== '' ? result.stdout.trim() : undefined;
|
|
29
|
+
},
|
|
30
|
+
signal(pid, signal) {
|
|
31
|
+
try {
|
|
32
|
+
process.kill(pid, signal);
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
function failure(what, ran, fix) {
|
|
40
|
+
const said = tail(`${ran.stdout}\n${ran.stderr}`.trim(), 6);
|
|
41
|
+
return new DriverError(`${what} ${ran.error ?? `exited ${String(ran.code)}`}${said ? `:\n${said}` : ''}`, fix);
|
|
42
|
+
}
|
|
43
|
+
function adbOf(target) {
|
|
44
|
+
if (target.adb === undefined)
|
|
45
|
+
throw new Error(`no adb for emulator ${target.device}`);
|
|
46
|
+
return target.adb;
|
|
47
|
+
}
|
|
48
|
+
export function recordCommand(target, file, remote) {
|
|
49
|
+
return target.platform === 'ios'
|
|
50
|
+
? { command: 'xcrun', args: ['simctl', 'io', target.device, 'recordVideo', '--codec=h264', '--force', file] }
|
|
51
|
+
: { command: adbOf(target), args: ['-s', target.device, 'shell', 'screenrecord', '--time-limit', '180', remote] };
|
|
52
|
+
}
|
|
53
|
+
/** Starts recording the device's screen into `file`; returns what its stop needs. */
|
|
54
|
+
export async function startDeviceVideo(system, target, file, clock) {
|
|
55
|
+
const remote = `/sdcard/${TOOL}-${String(clock.now())}.mp4`;
|
|
56
|
+
const { command, args } = recordCommand(target, file, remote);
|
|
57
|
+
const log = `${file}.log`;
|
|
58
|
+
const pid = system.start(command, args, log);
|
|
59
|
+
const startedAt = clock.now();
|
|
60
|
+
if (pid === undefined)
|
|
61
|
+
throw new DriverError(`could not start ${command}`, 'check that Xcode or the Android SDK is installed');
|
|
62
|
+
const until = startedAt + 5000;
|
|
63
|
+
const started = () => target.platform === 'android' || (fs.existsSync(log) && /Recording started/i.test(fs.readFileSync(log, 'utf8')));
|
|
64
|
+
let running = system.commandOf(pid);
|
|
65
|
+
while (running !== undefined && clock.now() < until && !started()) {
|
|
66
|
+
await clock.sleep(200);
|
|
67
|
+
running = system.commandOf(pid);
|
|
68
|
+
}
|
|
69
|
+
if (running === undefined) {
|
|
70
|
+
const said = fs.existsSync(log) ? tail(fs.readFileSync(log, 'utf8'), 6) : '';
|
|
71
|
+
throw new DriverError(`the screen recording stopped as it started${said ? `:\n${said}` : ''}`, target.platform === 'ios' ? 'check that the simulator is booted' : 'check that the emulator is booted');
|
|
72
|
+
}
|
|
73
|
+
return {
|
|
74
|
+
version: 1,
|
|
75
|
+
target: 'device',
|
|
76
|
+
startedAt,
|
|
77
|
+
file,
|
|
78
|
+
pid,
|
|
79
|
+
command: running,
|
|
80
|
+
platform: target.platform,
|
|
81
|
+
device: target.device,
|
|
82
|
+
...(target.platform === 'android' ? { remote } : {}),
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
function stillOurs(system, recording) {
|
|
86
|
+
if (recording.pid === undefined)
|
|
87
|
+
return false;
|
|
88
|
+
const now = system.commandOf(recording.pid);
|
|
89
|
+
return now !== undefined && now === recording.command;
|
|
90
|
+
}
|
|
91
|
+
async function waitGone(system, recording, clock, ms) {
|
|
92
|
+
const until = clock.now() + ms;
|
|
93
|
+
while (stillOurs(system, recording)) {
|
|
94
|
+
if (clock.now() >= until)
|
|
95
|
+
return false;
|
|
96
|
+
await clock.sleep(200);
|
|
97
|
+
}
|
|
98
|
+
return true;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Stops a device recording so its file is complete: an interrupt, as the recorder takes it, then the file pulled off an
|
|
102
|
+
* emulator. A recorder that ignores the interrupt is killed, and its file may not play.
|
|
103
|
+
*/
|
|
104
|
+
export async function stopDeviceVideo(system, recording, clock, adb) {
|
|
105
|
+
const problems = [];
|
|
106
|
+
if (recording.platform === 'android' && recording.device !== undefined && adb !== undefined) {
|
|
107
|
+
const ran = await system.run(adb, ['-s', recording.device, 'shell', 'pkill', '-INT', 'screenrecord'], 15_000);
|
|
108
|
+
if (ran.code !== 0 && stillOurs(system, recording))
|
|
109
|
+
problems.push(`adb could not interrupt screenrecord (exit ${String(ran.code)})`);
|
|
110
|
+
}
|
|
111
|
+
else if (stillOurs(system, recording) && recording.pid !== undefined) {
|
|
112
|
+
system.signal(recording.pid, 'SIGINT');
|
|
113
|
+
}
|
|
114
|
+
if (!(await waitGone(system, recording, clock, 15_000)) && recording.pid !== undefined) {
|
|
115
|
+
system.signal(recording.pid, 'SIGKILL');
|
|
116
|
+
problems.push(`the recorder (pid ${String(recording.pid)}) ignored the interrupt and was killed; the video may not play`);
|
|
117
|
+
}
|
|
118
|
+
if (recording.platform === 'android' &&
|
|
119
|
+
recording.remote !== undefined &&
|
|
120
|
+
recording.device !== undefined &&
|
|
121
|
+
adb !== undefined &&
|
|
122
|
+
recording.file) {
|
|
123
|
+
await clock.sleep(1000);
|
|
124
|
+
const pulled = await system.run(adb, ['-s', recording.device, 'pull', recording.remote, recording.file], 120_000);
|
|
125
|
+
if (pulled.code !== 0)
|
|
126
|
+
problems.push(failure(`adb pull ${recording.remote}`, pulled, '').message);
|
|
127
|
+
await system.run(adb, ['-s', recording.device, 'shell', 'rm', '-f', recording.remote], 15_000);
|
|
128
|
+
}
|
|
129
|
+
const file = recording.file !== undefined && fs.existsSync(recording.file) && fs.statSync(recording.file).size > 0 ? recording.file : null;
|
|
130
|
+
if (file === null)
|
|
131
|
+
problems.push('the recording left no video');
|
|
132
|
+
else
|
|
133
|
+
fs.rmSync(`${file}.log`, { force: true });
|
|
134
|
+
return { file, problems };
|
|
135
|
+
}
|
|
136
|
+
/** The simulator app's executable, whose name the simulator's log records its lines under. */
|
|
137
|
+
export async function appExecutable(system, target) {
|
|
138
|
+
if (target.platform !== 'ios' || target.bundleId === null)
|
|
139
|
+
return undefined;
|
|
140
|
+
const ran = await system.run('xcrun', ['simctl', 'appinfo', target.device, target.bundleId], 30_000);
|
|
141
|
+
if (ran.code !== 0)
|
|
142
|
+
return undefined;
|
|
143
|
+
return /CFBundleExecutable\s*=\s*"?([^";\n]+)"?;/.exec(ran.stdout)?.[1]?.trim();
|
|
144
|
+
}
|
|
145
|
+
export function deviceLogCommand(target, sinceMs, now, executable) {
|
|
146
|
+
if (target.platform === 'ios') {
|
|
147
|
+
const minutes = Math.max(1, Math.ceil(sinceMs / 60_000));
|
|
148
|
+
return {
|
|
149
|
+
command: 'xcrun',
|
|
150
|
+
args: [
|
|
151
|
+
'simctl',
|
|
152
|
+
'spawn',
|
|
153
|
+
target.device,
|
|
154
|
+
'log',
|
|
155
|
+
'show',
|
|
156
|
+
'--style',
|
|
157
|
+
'compact',
|
|
158
|
+
'--last',
|
|
159
|
+
`${String(minutes)}m`,
|
|
160
|
+
...(executable === undefined ? [] : ['--predicate', `process == ${JSON.stringify(executable)}`]),
|
|
161
|
+
],
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
const since = ((now - sinceMs) / 1000).toFixed(3);
|
|
165
|
+
return { command: adbOf(target), args: ['-s', target.device, 'logcat', '-d', '-v', 'threadtime', '-t', since] };
|
|
166
|
+
}
|
|
167
|
+
/** The device's log over the last `sinceMs`, narrowed to the app on a simulator when the app is known. */
|
|
168
|
+
export async function writeDeviceLog(system, target, sinceMs, file, clock) {
|
|
169
|
+
const executable = await appExecutable(system, target);
|
|
170
|
+
const { command, args } = deviceLogCommand(target, sinceMs, clock.now(), executable);
|
|
171
|
+
const ran = await system.run(command, args, 120_000);
|
|
172
|
+
if (ran.code !== 0) {
|
|
173
|
+
throw failure(`${command} ${args.slice(0, 4).join(' ')}`, ran, `check that the ${target.platform === 'ios' ? 'simulator' : 'emulator'} is booted`);
|
|
174
|
+
}
|
|
175
|
+
fs.writeFileSync(file, ran.stdout, { mode: 0o600 });
|
|
176
|
+
return executable === undefined ? 'the whole device' : `the app's process ${executable}`;
|
|
177
|
+
}
|
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { browserOfLane, hasBrowser } from "../browser/lane-browser.js";
|
|
4
|
+
import { adbPath } from "../devices/adb.js";
|
|
5
|
+
import { DriverError, messageOf } from "../driver/errors.js";
|
|
6
|
+
import { enginePaths } from "../driver/paths.js";
|
|
7
|
+
import { evidenceDir } from "../hooks/env.js";
|
|
8
|
+
import { CLI } from "../name.js";
|
|
9
|
+
import { UsageError } from "../registry/refusal.js";
|
|
10
|
+
import { laneDir, readUpRecord } from "../up/lane-files.js";
|
|
11
|
+
import { startDeviceVideo, stopDeviceVideo, writeDeviceLog } from "./device.js";
|
|
12
|
+
import { clearInProgress, copyNewer, newEvidenceFile, newEvidenceFolder, readFrom, readInProgress, sizeOf, writeInProgress, } from "./files.js";
|
|
13
|
+
export function laneEvidence(stateDir, laneId) {
|
|
14
|
+
return evidenceDir(laneDir(stateDir, laneId));
|
|
15
|
+
}
|
|
16
|
+
/** Which of the lane's screens a verb acts on: the one named, or the only one the lane holds. */
|
|
17
|
+
export function evidenceTarget(lane, asked) {
|
|
18
|
+
if (asked === 'device' && lane.device === null) {
|
|
19
|
+
throw new UsageError(`lane ${lane.id} holds no simulator or emulator`, `${CLI} up --platform ios (or android), or pass --browser`);
|
|
20
|
+
}
|
|
21
|
+
if (asked === 'browser' && lane.browser === null) {
|
|
22
|
+
throw new UsageError(`lane ${lane.id} holds no browser`, `${CLI} up --platform web, or pass --device`);
|
|
23
|
+
}
|
|
24
|
+
if (asked)
|
|
25
|
+
return asked;
|
|
26
|
+
if (lane.device && lane.browser) {
|
|
27
|
+
throw new UsageError(`lane ${lane.id} holds a ${lane.device.platform === 'ios' ? 'simulator' : 'emulator'} and a browser`, 'pass --device or --browser');
|
|
28
|
+
}
|
|
29
|
+
if (lane.device)
|
|
30
|
+
return 'device';
|
|
31
|
+
if (lane.browser)
|
|
32
|
+
return 'browser';
|
|
33
|
+
throw new UsageError(`lane ${lane.id} holds no simulator, emulator or browser`, `${CLI} up`);
|
|
34
|
+
}
|
|
35
|
+
export function deviceTargetOf(ctx) {
|
|
36
|
+
const { device } = ctx.lane;
|
|
37
|
+
if (!device)
|
|
38
|
+
throw new UsageError(`lane ${ctx.lane.id} holds no simulator or emulator`, `${CLI} up`);
|
|
39
|
+
const bundleId = readUpRecord(laneDir(ctx.stateDir, ctx.lane.id))?.bundleId ?? null;
|
|
40
|
+
return device.platform === 'ios'
|
|
41
|
+
? { platform: 'ios', device: device.id, bundleId }
|
|
42
|
+
: { platform: 'android', device: device.serial ?? device.id, adb: adbPath(ctx.env), bundleId };
|
|
43
|
+
}
|
|
44
|
+
async function controlOf(ctx) {
|
|
45
|
+
const { lane } = ctx;
|
|
46
|
+
if (!hasBrowser(lane))
|
|
47
|
+
throw new UsageError(`lane ${lane.id} holds no browser`, `${CLI} up --platform web`);
|
|
48
|
+
const { control } = await browserOfLane(ctx.browser, ctx.stateDir, lane, ctx.env);
|
|
49
|
+
if (!(await control.isOpen())) {
|
|
50
|
+
throw new DriverError(`the lane's ${control.driver} browser is not open`, `${CLI} up --platform web (it opens the web app in it)`);
|
|
51
|
+
}
|
|
52
|
+
return control;
|
|
53
|
+
}
|
|
54
|
+
export async function keepScreenshot(ctx, target) {
|
|
55
|
+
const evidence = laneEvidence(ctx.stateDir, ctx.lane.id);
|
|
56
|
+
const at = new Date(ctx.clock.now());
|
|
57
|
+
if (target === 'browser') {
|
|
58
|
+
const file = newEvidenceFile(evidence, 'screenshot-browser', 'png', at);
|
|
59
|
+
await (await controlOf(ctx)).screenshot(file);
|
|
60
|
+
return { path: file, files: [file], notes: [], problems: [] };
|
|
61
|
+
}
|
|
62
|
+
const file = newEvidenceFile(evidence, 'screenshot-device', 'jpg', at);
|
|
63
|
+
fs.writeFileSync(file, await ctx.deviceShot(), { mode: 0o600 });
|
|
64
|
+
return { path: file, files: [file], notes: [], problems: [] };
|
|
65
|
+
}
|
|
66
|
+
export async function startVideo(ctx, target) {
|
|
67
|
+
const evidence = laneEvidence(ctx.stateDir, ctx.lane.id);
|
|
68
|
+
const running = readInProgress(evidence, 'video', target);
|
|
69
|
+
if (running) {
|
|
70
|
+
throw new UsageError(`a ${target} recording runs already, into ${running.file ?? 'its file'}`, `${CLI} evidence video stop --${target}`);
|
|
71
|
+
}
|
|
72
|
+
const at = new Date(ctx.clock.now());
|
|
73
|
+
if (target === 'browser') {
|
|
74
|
+
const file = newEvidenceFile(evidence, 'video-browser', 'webm', at);
|
|
75
|
+
await (await controlOf(ctx)).videoStart(file);
|
|
76
|
+
writeInProgress(evidence, 'video', { version: 1, target, startedAt: ctx.clock.now(), file });
|
|
77
|
+
return { path: file, files: [], notes: [], problems: [] };
|
|
78
|
+
}
|
|
79
|
+
const file = newEvidenceFile(evidence, 'video-device', 'mp4', at);
|
|
80
|
+
const recording = await startDeviceVideo(ctx.system, deviceTargetOf(ctx), file, ctx.clock);
|
|
81
|
+
writeInProgress(evidence, 'video', recording);
|
|
82
|
+
return {
|
|
83
|
+
path: file,
|
|
84
|
+
files: [],
|
|
85
|
+
notes: recording.platform === 'android' ? ['an emulator records at most 3 minutes at a time'] : [],
|
|
86
|
+
problems: [],
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
export async function stopVideo(ctx, target) {
|
|
90
|
+
const evidence = laneEvidence(ctx.stateDir, ctx.lane.id);
|
|
91
|
+
const running = readInProgress(evidence, 'video', target);
|
|
92
|
+
if (!running?.file)
|
|
93
|
+
throw new UsageError(`no ${target} recording runs for lane ${ctx.lane.id}`, `${CLI} evidence video start --${target}`);
|
|
94
|
+
if (target === 'browser') {
|
|
95
|
+
try {
|
|
96
|
+
await (await controlOf(ctx)).videoStop();
|
|
97
|
+
}
|
|
98
|
+
finally {
|
|
99
|
+
clearInProgress(evidence, 'video', target);
|
|
100
|
+
}
|
|
101
|
+
const exists = fs.existsSync(running.file);
|
|
102
|
+
return {
|
|
103
|
+
path: running.file,
|
|
104
|
+
files: exists ? [running.file] : [],
|
|
105
|
+
notes: [],
|
|
106
|
+
problems: exists ? [] : ['the driver wrote no video'],
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
const adb = running.platform === 'android' ? adbPath(ctx.env) : undefined;
|
|
110
|
+
const stopped = await stopDeviceVideo(ctx.system, running, ctx.clock, adb);
|
|
111
|
+
clearInProgress(evidence, 'video', target);
|
|
112
|
+
return { path: running.file, files: stopped.file ? [stopped.file] : [], notes: [], problems: stopped.problems };
|
|
113
|
+
}
|
|
114
|
+
function driverFiles(ctx) {
|
|
115
|
+
const paths = enginePaths(ctx.stateDir, ctx.lane.id);
|
|
116
|
+
return { log: paths.log, steps: paths.steps, shots: paths.shots };
|
|
117
|
+
}
|
|
118
|
+
/** Restarts the background trace a Playwright browser keeps for failures, so a trace stopped now starts here. */
|
|
119
|
+
async function restartTrace(control, scratch) {
|
|
120
|
+
await control.traceStop(scratch).catch(() => []);
|
|
121
|
+
fs.rmSync(scratch, { recursive: true, force: true });
|
|
122
|
+
await control.traceStart();
|
|
123
|
+
}
|
|
124
|
+
export async function startTrace(ctx, target) {
|
|
125
|
+
const evidence = laneEvidence(ctx.stateDir, ctx.lane.id);
|
|
126
|
+
const startedAt = ctx.clock.now();
|
|
127
|
+
if (target === 'browser') {
|
|
128
|
+
const control = await controlOf(ctx);
|
|
129
|
+
if (control.tracesActions)
|
|
130
|
+
await restartTrace(control, path.join(evidence, '.trace-scratch'));
|
|
131
|
+
else
|
|
132
|
+
await control.traceStart();
|
|
133
|
+
writeInProgress(evidence, 'trace', { version: 1, target, startedAt });
|
|
134
|
+
return { path: evidence, files: [], notes: [`tracing the ${control.driver} browser's actions`], problems: [] };
|
|
135
|
+
}
|
|
136
|
+
const files = driverFiles(ctx);
|
|
137
|
+
writeInProgress(evidence, 'trace', {
|
|
138
|
+
version: 1,
|
|
139
|
+
target,
|
|
140
|
+
startedAt,
|
|
141
|
+
driverLogBytes: sizeOf(files.log),
|
|
142
|
+
stepsBytes: sizeOf(files.steps),
|
|
143
|
+
});
|
|
144
|
+
return { path: evidence, files: [], notes: ["tracing the driver's calls, the flows run and the device's log"], problems: [] };
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Stops a trace and keeps it. A browser's is the driver's own: Playwright's action trace (`npx playwright show-trace`
|
|
148
|
+
* opens it), which also runs from `up` on so a stop without a start covers the session so far; agent-browser's is a
|
|
149
|
+
* DevTools performance trace. A device's is what the toolkit saw: the driver's log, the flows that ran, the
|
|
150
|
+
* screenshots they kept, and the device's log, over the traced time.
|
|
151
|
+
*/
|
|
152
|
+
export async function stopTrace(ctx, target) {
|
|
153
|
+
const evidence = laneEvidence(ctx.stateDir, ctx.lane.id);
|
|
154
|
+
const started = readInProgress(evidence, 'trace', target);
|
|
155
|
+
const at = new Date(ctx.clock.now());
|
|
156
|
+
if (target === 'browser') {
|
|
157
|
+
const control = await controlOf(ctx);
|
|
158
|
+
if (!started && !control.tracesActions) {
|
|
159
|
+
throw new UsageError('no browser trace runs: agent-browser traces only between a start and a stop', `${CLI} evidence trace start --browser`);
|
|
160
|
+
}
|
|
161
|
+
const dir = newEvidenceFolder(evidence, 'trace-browser', at);
|
|
162
|
+
const kept = { path: dir, files: [], notes: [], problems: [] };
|
|
163
|
+
try {
|
|
164
|
+
kept.files.push(...(await control.traceStop(dir)));
|
|
165
|
+
}
|
|
166
|
+
finally {
|
|
167
|
+
clearInProgress(evidence, 'trace', target);
|
|
168
|
+
}
|
|
169
|
+
if (control.tracesActions) {
|
|
170
|
+
try {
|
|
171
|
+
await control.traceStart();
|
|
172
|
+
}
|
|
173
|
+
catch (error) {
|
|
174
|
+
kept.problems.push(`could not start the failure trace again: ${messageOf(error).split('\n')[0] ?? ''}`);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
return kept;
|
|
178
|
+
}
|
|
179
|
+
if (!started)
|
|
180
|
+
throw new UsageError(`no device trace runs for lane ${ctx.lane.id}`, `${CLI} evidence trace start --device`);
|
|
181
|
+
const dir = newEvidenceFolder(evidence, 'trace-device', at);
|
|
182
|
+
const kept = { path: dir, files: [], notes: [], problems: [] };
|
|
183
|
+
const files = driverFiles(ctx);
|
|
184
|
+
const write = (name, text) => {
|
|
185
|
+
const file = path.join(dir, name);
|
|
186
|
+
fs.writeFileSync(file, text, { mode: 0o600 });
|
|
187
|
+
kept.files.push(file);
|
|
188
|
+
};
|
|
189
|
+
write('driver.log', readFrom(files.log, started.driverLogBytes ?? 0));
|
|
190
|
+
write('flows.jsonl', readFrom(files.steps, started.stepsBytes ?? 0));
|
|
191
|
+
kept.files.push(...copyNewer(files.shots, path.join(dir, 'screenshots'), started.startedAt));
|
|
192
|
+
try {
|
|
193
|
+
const file = path.join(dir, 'device.log');
|
|
194
|
+
const scope = await writeDeviceLog(ctx.system, deviceTargetOf(ctx), ctx.clock.now() - started.startedAt, file, ctx.clock);
|
|
195
|
+
kept.files.push(file);
|
|
196
|
+
kept.notes.push(`device.log holds ${scope}`);
|
|
197
|
+
}
|
|
198
|
+
catch (error) {
|
|
199
|
+
kept.problems.push(`device log: ${messageOf(error).split('\n')[0] ?? ''}`);
|
|
200
|
+
}
|
|
201
|
+
clearInProgress(evidence, 'trace', target);
|
|
202
|
+
return kept;
|
|
203
|
+
}
|
|
204
|
+
function copyLogs(from, into) {
|
|
205
|
+
const copied = [];
|
|
206
|
+
for (const name of fs.readdirSync(from, { withFileTypes: true })) {
|
|
207
|
+
if (!name.isFile() || !name.name.endsWith('.log'))
|
|
208
|
+
continue;
|
|
209
|
+
fs.mkdirSync(into, { recursive: true, mode: 0o700 });
|
|
210
|
+
fs.copyFileSync(path.join(from, name.name), path.join(into, name.name));
|
|
211
|
+
copied.push(path.join(into, name.name));
|
|
212
|
+
}
|
|
213
|
+
return copied;
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Keeps the lane's logs as they are now: the services' and hooks' logs, the driver's, the device's over the last
|
|
217
|
+
* `sinceMs`, and the browser's console. `targets` names the screens whose own logs to take.
|
|
218
|
+
*/
|
|
219
|
+
export async function keepLogs(ctx, targets, sinceMs) {
|
|
220
|
+
const evidence = laneEvidence(ctx.stateDir, ctx.lane.id);
|
|
221
|
+
const dir = newEvidenceFolder(evidence, 'logs', new Date(ctx.clock.now()));
|
|
222
|
+
const kept = { path: dir, files: [], notes: [], problems: [] };
|
|
223
|
+
const lane = laneDir(ctx.stateDir, ctx.lane.id);
|
|
224
|
+
if (fs.existsSync(lane)) {
|
|
225
|
+
kept.files.push(...copyLogs(lane, path.join(dir, 'services')));
|
|
226
|
+
const hooks = path.join(lane, 'hooks');
|
|
227
|
+
if (fs.existsSync(hooks))
|
|
228
|
+
kept.files.push(...copyLogs(hooks, path.join(dir, 'hooks')));
|
|
229
|
+
}
|
|
230
|
+
const driverLog = driverFiles(ctx).log;
|
|
231
|
+
if (fs.existsSync(driverLog)) {
|
|
232
|
+
fs.copyFileSync(driverLog, path.join(dir, 'driver.log'));
|
|
233
|
+
kept.files.push(path.join(dir, 'driver.log'));
|
|
234
|
+
}
|
|
235
|
+
if (targets.includes('device') && ctx.lane.device) {
|
|
236
|
+
try {
|
|
237
|
+
const file = path.join(dir, 'device.log');
|
|
238
|
+
const scope = await writeDeviceLog(ctx.system, deviceTargetOf(ctx), sinceMs, file, ctx.clock);
|
|
239
|
+
kept.files.push(file);
|
|
240
|
+
kept.notes.push(`device.log holds ${scope}`);
|
|
241
|
+
}
|
|
242
|
+
catch (error) {
|
|
243
|
+
kept.problems.push(`device log: ${messageOf(error).split('\n')[0] ?? ''}`);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
if (targets.includes('browser') && ctx.lane.browser) {
|
|
247
|
+
try {
|
|
248
|
+
const file = path.join(dir, 'browser-console.txt');
|
|
249
|
+
fs.writeFileSync(file, await (await controlOf(ctx)).console(), { mode: 0o600 });
|
|
250
|
+
kept.files.push(file);
|
|
251
|
+
}
|
|
252
|
+
catch (error) {
|
|
253
|
+
kept.problems.push(`browser console: ${messageOf(error).split('\n')[0] ?? ''}`);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
return kept;
|
|
257
|
+
}
|
|
258
|
+
/** What a failed `run` on the device left: the flow, the failure, the screen, and the driver's log over the run. */
|
|
259
|
+
export function keepRunFailure(stateDir, laneId, run, at = new Date()) {
|
|
260
|
+
const dir = newEvidenceFolder(laneEvidence(stateDir, laneId), 'run-failed', at);
|
|
261
|
+
fs.writeFileSync(path.join(dir, 'flow.yaml'), run.flow, { mode: 0o600 });
|
|
262
|
+
fs.writeFileSync(path.join(dir, 'failure.txt'), `${run.failure.trimEnd()}\n`, { mode: 0o600 });
|
|
263
|
+
if (run.screenshot)
|
|
264
|
+
fs.writeFileSync(path.join(dir, 'screenshot.jpg'), run.screenshot, { mode: 0o600 });
|
|
265
|
+
fs.writeFileSync(path.join(dir, 'driver.log'), readFrom(enginePaths(stateDir, laneId).log, run.driverLogFrom), {
|
|
266
|
+
mode: 0o600,
|
|
267
|
+
});
|
|
268
|
+
return dir;
|
|
269
|
+
}
|
|
270
|
+
/** Ends the lane's recordings at its release so each file is complete; the files stay with the evidence. */
|
|
271
|
+
export async function stopRecordings(ctx, control) {
|
|
272
|
+
const evidence = laneEvidence(ctx.stateDir, ctx.lane.id);
|
|
273
|
+
const result = { notes: [], problems: [] };
|
|
274
|
+
const browser = readInProgress(evidence, 'video', 'browser');
|
|
275
|
+
if (browser) {
|
|
276
|
+
try {
|
|
277
|
+
if (control)
|
|
278
|
+
await control.videoStop();
|
|
279
|
+
result.notes.push(`stopped the browser recording into ${browser.file ?? 'its file'}`);
|
|
280
|
+
}
|
|
281
|
+
catch (error) {
|
|
282
|
+
result.problems.push(`could not stop the browser recording: ${messageOf(error).split('\n')[0] ?? ''}`);
|
|
283
|
+
}
|
|
284
|
+
clearInProgress(evidence, 'video', 'browser');
|
|
285
|
+
}
|
|
286
|
+
const device = readInProgress(evidence, 'video', 'device');
|
|
287
|
+
if (device) {
|
|
288
|
+
let adb;
|
|
289
|
+
try {
|
|
290
|
+
adb = device.platform === 'android' ? adbPath(ctx.env) : undefined;
|
|
291
|
+
}
|
|
292
|
+
catch {
|
|
293
|
+
adb = undefined;
|
|
294
|
+
}
|
|
295
|
+
const stopped = await stopDeviceVideo(ctx.system, device, ctx.clock, adb);
|
|
296
|
+
if (stopped.file)
|
|
297
|
+
result.notes.push(`stopped the device recording into ${stopped.file}`);
|
|
298
|
+
result.problems.push(...stopped.problems.map(p => `device recording: ${p}`));
|
|
299
|
+
clearInProgress(evidence, 'video', 'device');
|
|
300
|
+
}
|
|
301
|
+
clearInProgress(evidence, 'trace', 'browser');
|
|
302
|
+
clearInProgress(evidence, 'trace', 'device');
|
|
303
|
+
return result;
|
|
304
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
export function evidenceStamp(at = new Date()) {
|
|
4
|
+
return at
|
|
5
|
+
.toISOString()
|
|
6
|
+
.replace(/[-:]/g, '')
|
|
7
|
+
.replace(/\.\d+Z$/, 'Z');
|
|
8
|
+
}
|
|
9
|
+
export function evidenceLabel(text) {
|
|
10
|
+
return (text
|
|
11
|
+
.replace(/[^A-Za-z0-9._-]+/g, '-')
|
|
12
|
+
.replace(/^-+|-+$/g, '')
|
|
13
|
+
.slice(0, 40) || 'run');
|
|
14
|
+
}
|
|
15
|
+
/** A new folder in the lane's evidence folder, named by when and what: `<stamp>-<label>`, never one that exists. */
|
|
16
|
+
export function newEvidenceFolder(evidence, label, at = new Date()) {
|
|
17
|
+
const base = path.join(evidence, `${evidenceStamp(at)}-${evidenceLabel(label)}`);
|
|
18
|
+
let dir = base;
|
|
19
|
+
for (let n = 2; fs.existsSync(dir); n += 1)
|
|
20
|
+
dir = `${base}-${String(n)}`;
|
|
21
|
+
fs.mkdirSync(dir, { recursive: true, mode: 0o700 });
|
|
22
|
+
return dir;
|
|
23
|
+
}
|
|
24
|
+
/** A new file name in the lane's evidence folder, never one that exists. */
|
|
25
|
+
export function newEvidenceFile(evidence, label, extension, at = new Date()) {
|
|
26
|
+
fs.mkdirSync(evidence, { recursive: true, mode: 0o700 });
|
|
27
|
+
const base = path.join(evidence, `${evidenceStamp(at)}-${evidenceLabel(label)}`);
|
|
28
|
+
let file = `${base}.${extension}`;
|
|
29
|
+
for (let n = 2; fs.existsSync(file); n += 1)
|
|
30
|
+
file = `${base}-${String(n)}.${extension}`;
|
|
31
|
+
return file;
|
|
32
|
+
}
|
|
33
|
+
function stateFile(evidence, kind, target) {
|
|
34
|
+
return path.join(evidence, `.${kind}-${target}.json`);
|
|
35
|
+
}
|
|
36
|
+
export function readInProgress(evidence, kind, target) {
|
|
37
|
+
try {
|
|
38
|
+
const raw = JSON.parse(fs.readFileSync(stateFile(evidence, kind, target), 'utf8'));
|
|
39
|
+
return raw.version === 1 && raw.target === target && typeof raw.startedAt === 'number' ? raw : null;
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
export function writeInProgress(evidence, kind, state) {
|
|
46
|
+
fs.mkdirSync(evidence, { recursive: true, mode: 0o700 });
|
|
47
|
+
fs.writeFileSync(stateFile(evidence, kind, state.target), `${JSON.stringify(state, null, 2)}\n`, { mode: 0o600 });
|
|
48
|
+
}
|
|
49
|
+
export function clearInProgress(evidence, kind, target) {
|
|
50
|
+
fs.rmSync(stateFile(evidence, kind, target), { force: true });
|
|
51
|
+
}
|
|
52
|
+
/** The bytes a file grew by since `from`, or all of it when it is shorter than that (it was replaced). */
|
|
53
|
+
export function readFrom(file, from) {
|
|
54
|
+
let data;
|
|
55
|
+
try {
|
|
56
|
+
data = fs.readFileSync(file);
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
return '';
|
|
60
|
+
}
|
|
61
|
+
return data.subarray(data.length >= from ? from : 0).toString('utf8');
|
|
62
|
+
}
|
|
63
|
+
export function sizeOf(file) {
|
|
64
|
+
try {
|
|
65
|
+
return fs.statSync(file).size;
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
return 0;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
/** Copies the files a folder holds that changed at or after `since` into `into`; returns what it copied. */
|
|
72
|
+
export function copyNewer(from, into, since) {
|
|
73
|
+
let names;
|
|
74
|
+
try {
|
|
75
|
+
names = fs.readdirSync(from);
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
return [];
|
|
79
|
+
}
|
|
80
|
+
const copied = [];
|
|
81
|
+
for (const name of names) {
|
|
82
|
+
const file = path.join(from, name);
|
|
83
|
+
const stat = fs.statSync(file, { throwIfNoEntry: false });
|
|
84
|
+
if (!stat?.isFile() || stat.mtimeMs < since)
|
|
85
|
+
continue;
|
|
86
|
+
fs.mkdirSync(into, { recursive: true, mode: 0o700 });
|
|
87
|
+
const target = path.join(into, name);
|
|
88
|
+
fs.copyFileSync(file, target);
|
|
89
|
+
copied.push(target);
|
|
90
|
+
}
|
|
91
|
+
return copied;
|
|
92
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { ENV_PREFIX, envName } from "../name.js";
|
|
3
|
+
import { BUILT_IN_SERVICE_TYPES, WEB_PLATFORM } from "../project/schema.js";
|
|
4
|
+
import { OWNER_PID_ENV } from "../registry/owner.js";
|
|
5
|
+
import { STATE_DIR_ENV } from "../registry/paths.js";
|
|
6
|
+
/** glibc has C.UTF-8 built in, but en_US.UTF-8 only where the locales package generated it; macOS has no C.UTF-8. */
|
|
7
|
+
export function hookLocale(platform = process.platform) {
|
|
8
|
+
return platform === 'linux' ? 'C.UTF-8' : 'en_US.UTF-8';
|
|
9
|
+
}
|
|
10
|
+
export const HOOK_LOCALE = hookLocale();
|
|
11
|
+
export const JAVA_HOME_ENV = envName('JAVA_HOME');
|
|
12
|
+
export const LOGS_ENV = envName('LOGS');
|
|
13
|
+
export const VARIANT_ENV = envName('VARIANT');
|
|
14
|
+
export const LAUNCH_ARGS_ENV = envName('LAUNCH_ARGS');
|
|
15
|
+
export const LANE_TOKEN_ENV = envName('LANE_TOKEN');
|
|
16
|
+
export const WEB_URL_ENV = envName('WEB_URL');
|
|
17
|
+
export const EVIDENCE_ENV = envName('EVIDENCE');
|
|
18
|
+
/** Where a lane keeps recordings, traces, screenshots and logs taken on demand or on failure; it outlives the lane. */
|
|
19
|
+
export function evidenceDir(logsDir) {
|
|
20
|
+
return path.join(logsDir, 'evidence');
|
|
21
|
+
}
|
|
22
|
+
const SETTINGS = new Set([STATE_DIR_ENV, OWNER_PID_ENV, JAVA_HOME_ENV]);
|
|
23
|
+
export function portVariable(service) {
|
|
24
|
+
return envName(`${service.toUpperCase().replaceAll('-', '_')}_PORT`);
|
|
25
|
+
}
|
|
26
|
+
/** The web app's URL on this lane's port for its service, or null when the config has no web app or the lane no port. */
|
|
27
|
+
export function webUrl(config, lane) {
|
|
28
|
+
const web = config?.web;
|
|
29
|
+
const port = web ? lane.ports.find(p => p.service === web.service)?.port : undefined;
|
|
30
|
+
return web && port !== undefined ? `http://localhost:${String(port)}${web.path}` : null;
|
|
31
|
+
}
|
|
32
|
+
export function laneVariables(lane, config, logsDir) {
|
|
33
|
+
const vars = { [envName('LANE')]: lane.id };
|
|
34
|
+
if (lane.token !== undefined)
|
|
35
|
+
vars[LANE_TOKEN_ENV] = lane.token;
|
|
36
|
+
vars[envName('WORKTREE')] = lane.worktree;
|
|
37
|
+
if (config?.platform === WEB_PLATFORM)
|
|
38
|
+
vars[envName('PLATFORM')] = WEB_PLATFORM;
|
|
39
|
+
else if (lane.device)
|
|
40
|
+
vars[envName('PLATFORM')] = lane.device.platform;
|
|
41
|
+
if (lane.device)
|
|
42
|
+
vars[envName('DEVICE')] = lane.device.serial ?? lane.device.id;
|
|
43
|
+
for (const p of lane.ports)
|
|
44
|
+
vars[portVariable(p.service)] = String(p.port);
|
|
45
|
+
for (const type of BUILT_IN_SERVICE_TYPES) {
|
|
46
|
+
const ofType = lane.ports.filter(p => p.type === type);
|
|
47
|
+
const [only] = ofType;
|
|
48
|
+
if (!(portVariable(type) in vars) && ofType.length === 1 && only)
|
|
49
|
+
vars[portVariable(type)] = String(only.port);
|
|
50
|
+
}
|
|
51
|
+
const url = webUrl(config, lane);
|
|
52
|
+
if (url !== null)
|
|
53
|
+
vars[WEB_URL_ENV] = url;
|
|
54
|
+
if (config?.app)
|
|
55
|
+
vars[VARIANT_ENV] = config.app.variant;
|
|
56
|
+
if (logsDir) {
|
|
57
|
+
vars[LOGS_ENV] = logsDir;
|
|
58
|
+
vars[EVIDENCE_ENV] = evidenceDir(logsDir);
|
|
59
|
+
}
|
|
60
|
+
for (const resource of lane.resources)
|
|
61
|
+
Object.assign(vars, resource.exports);
|
|
62
|
+
return vars;
|
|
63
|
+
}
|
|
64
|
+
/** Every variable the config's resources export, which a lane's commands never take from the caller's environment. */
|
|
65
|
+
export function resourceVariables(config) {
|
|
66
|
+
return config ? config.resources.flatMap(r => r.exports) : [];
|
|
67
|
+
}
|
|
68
|
+
export function hookEnvironment(base, vars, cleared = []) {
|
|
69
|
+
const env = {};
|
|
70
|
+
const unset = new Set(cleared);
|
|
71
|
+
for (const [key, value] of Object.entries(base)) {
|
|
72
|
+
if ((key.startsWith(`${ENV_PREFIX}_`) && !SETTINGS.has(key)) || unset.has(key))
|
|
73
|
+
continue;
|
|
74
|
+
env[key] = value;
|
|
75
|
+
}
|
|
76
|
+
return { ...env, ...vars, LANG: HOOK_LOCALE, LC_ALL: HOOK_LOCALE };
|
|
77
|
+
}
|
|
78
|
+
/** The environment of a command run for a lane: its variables, and none of its resources' names from the caller. */
|
|
79
|
+
export function laneEnvironment(base, lane, config, logsDir, extra = {}) {
|
|
80
|
+
return hookEnvironment(base, { ...laneVariables(lane, config, logsDir), ...extra }, resourceVariables(config));
|
|
81
|
+
}
|