@anyswarm/core 0.5.1 → 0.5.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/AGENTS.md +1 -1
- package/README.md +13 -6
- package/dist/examples/README.md +16 -5
- package/dist/examples/authoring/README.md +4 -4
- package/dist/examples/autoresearch/README.md +15 -8
- package/dist/examples/autoresearch/REQUIREMENTS.zh.md +3 -10
- package/dist/examples/autoresearch/demo.js +1 -1
- package/dist/examples/autoresearch/eject.json +2 -0
- package/dist/examples/autoresearch/frontiercs2-config.d.ts +2 -0
- package/dist/examples/autoresearch/frontiercs2-config.js +3 -0
- package/dist/examples/autoresearch/prepare-demo.d.ts +1 -0
- package/dist/examples/autoresearch/prepare-demo.js +15 -0
- package/dist/examples/autoresearch/prepare.js +3 -3
- package/dist/examples/autoresearch/project.d.ts +0 -94
- package/dist/examples/autoresearch/project.js +2 -20
- package/dist/examples/code/README.md +25 -17
- package/dist/examples/code/REQUIREMENTS.zh.md +3 -3
- package/dist/examples/harness-session/README.md +3 -3
- package/dist/examples/messages/README.md +1 -1
- package/dist/examples/notes/README.md +3 -3
- package/dist/examples/services/mathlib-search/README.md +1 -1
- package/dist/examples/services/persistent-board/README.md +5 -2
- package/dist/examples/subagents/README.md +2 -2
- package/dist/examples/subagents/config.js +3 -3
- package/dist/examples/substrate/README.md +2 -2
- package/dist/examples/super/README.md +34 -22
- package/dist/examples/super/actions.d.ts +1 -1
- package/dist/examples/super/actions.js +11 -11
- package/dist/examples/super/config.js +3 -3
- package/dist/examples/super/eject.json +1 -1
- package/dist/examples/super/location.js +1 -1
- package/dist/examples/super/operator.d.ts +1 -0
- package/dist/examples/super/operator.js +31 -0
- package/dist/examples/super/project.d.ts +0 -107
- package/dist/examples/super/project.js +1 -3
- package/dist/scripts/anyswarm-arguments.d.ts +7 -25
- package/dist/scripts/anyswarm-arguments.js +69 -97
- package/dist/scripts/anyswarm-eject.js +1 -1
- package/dist/scripts/anyswarm-harnesses.d.ts +0 -1
- package/dist/scripts/anyswarm-harnesses.js +1 -22
- package/dist/scripts/anyswarm-installation.d.ts +7 -40
- package/dist/scripts/anyswarm-installation.js +17 -291
- package/dist/scripts/anyswarm-launch.d.ts +6 -36
- package/dist/scripts/anyswarm-launch.js +32 -81
- package/dist/scripts/anyswarm-progress.d.ts +6 -0
- package/dist/scripts/anyswarm-progress.js +102 -0
- package/dist/scripts/anyswarm-project.d.ts +1 -9
- package/dist/scripts/anyswarm-project.js +40 -127
- package/dist/scripts/anyswarm-source-runner.js +9 -41
- package/dist/scripts/anyswarm.js +6 -26
- package/dist/scripts/build-provenance.json +1 -1
- package/dist/scripts/local-environment.d.ts +10 -4
- package/dist/scripts/local-environment.js +67 -20
- package/dist/scripts/local-setup.d.ts +3 -0
- package/dist/scripts/local-setup.js +135 -107
- package/dist/scripts/pack-release.js +4 -1
- package/dist/src/core/worker-image.js +1 -1
- package/dist/src/harness/project-harness.d.ts +1 -0
- package/dist/src/harness/project-harness.js +2 -2
- package/dist/src/harness/project-runtime.js +3 -1
- package/docs/INDEX.md +2 -1
- package/docs/architecture/04-services.md +1 -1
- package/docs/architecture/07-run-configuration.md +28 -14
- package/docs/architecture/12-code-coverage.md +56 -57
- package/docs/architecture/17-harness-reporting.md +1 -1
- package/docs/architecture/22-website.md +4 -7
- package/docs/architecture/23-project-harness.md +48 -23
- package/docs/architecture/26-code.md +20 -5
- package/docs/architecture/27-personal.md +23 -8
- package/docs/architecture/28-autoresearch.md +18 -6
- package/docs/architecture/INDEX.md +1 -2
- package/docs/architecture/prompts/source-manifest.json +5 -5
- package/docs/architecture/source-map.json +51 -71
- package/docs/designs/core-harness/01-core.md +2 -2
- package/docs/designs/core-harness/06-project-harness.md +3 -3
- package/docs/designs/core-harness/README.md +2 -2
- package/docs/en/agents.md +1 -1
- package/docs/en/build-your-harness.md +1 -1
- package/docs/en/changelog.md +7 -0
- package/docs/en/first-harness.md +6 -6
- package/docs/en/harnesses/lead-worker.md +1 -1
- package/docs/en/harnesses/peermesh.md +2 -2
- package/docs/en/harnesses/subagents.md +2 -2
- package/docs/en/harnesses/substrate.md +4 -4
- package/docs/en/harnesses/taskpool.md +2 -2
- package/docs/en/latest.md +9 -5
- package/docs/en/quickstart.md +20 -41
- package/docs/en/reference/api.md +1 -1
- package/docs/en/reference/cli.md +47 -85
- package/docs/en/sandbox.md +3 -3
- package/docs/operations/trace-viewer.md +1 -1
- package/docs/third-party-notices.md +0 -1
- package/docs/workflows/development.md +14 -12
- package/docs/workflows/release-and-docs-versioning.md +13 -12
- package/docs/workflows/release-cli-acceptance.md +85 -0
- package/docs/zh/agents.md +1 -1
- package/docs/zh/build-your-harness.md +1 -1
- package/docs/zh/changelog.md +8 -1
- package/docs/zh/first-harness.md +7 -7
- package/docs/zh/harnesses/lead-worker.md +1 -1
- package/docs/zh/harnesses/peermesh.md +2 -2
- package/docs/zh/harnesses/subagents.md +2 -2
- package/docs/zh/harnesses/substrate.md +4 -4
- package/docs/zh/harnesses/taskpool.md +2 -2
- package/docs/zh/latest.md +9 -5
- package/docs/zh/quickstart.md +20 -41
- package/docs/zh/reference/api.md +1 -1
- package/docs/zh/reference/cli.md +19 -79
- package/docs/zh/sandbox.md +3 -3
- package/examples/README.md +16 -5
- package/examples/authoring/README.md +4 -4
- package/examples/autoresearch/README.md +15 -8
- package/examples/autoresearch/REQUIREMENTS.zh.md +3 -10
- package/examples/autoresearch/demo.ts +1 -1
- package/examples/autoresearch/eject.json +2 -0
- package/examples/autoresearch/frontiercs2-config.ts +4 -0
- package/examples/autoresearch/prepare-demo.ts +15 -0
- package/examples/autoresearch/prepare.ts +3 -3
- package/examples/autoresearch/project.ts +2 -19
- package/examples/code/README.md +25 -17
- package/examples/code/REQUIREMENTS.zh.md +3 -3
- package/examples/harness-session/README.md +3 -3
- package/examples/messages/README.md +1 -1
- package/examples/notes/README.md +3 -3
- package/examples/services/mathlib-search/README.md +1 -1
- package/examples/services/persistent-board/README.md +5 -2
- package/examples/subagents/README.md +2 -2
- package/examples/subagents/config.ts +4 -3
- package/examples/substrate/README.md +2 -2
- package/examples/super/README.md +34 -22
- package/examples/super/actions.ts +11 -11
- package/examples/super/config.ts +3 -3
- package/examples/super/eject.json +1 -1
- package/examples/super/location.ts +1 -1
- package/examples/super/operator.ts +28 -0
- package/examples/super/project.ts +1 -3
- package/npm-shrinkwrap.development.json +42 -1541
- package/npm-shrinkwrap.json +3 -43
- package/package.development.json +2 -6
- package/package.json +2 -5
- package/scripts/anyswarm-arguments.ts +67 -96
- package/scripts/anyswarm-eject.ts +1 -1
- package/scripts/anyswarm-harnesses.ts +1 -18
- package/scripts/anyswarm-installation.ts +18 -294
- package/scripts/anyswarm-launch.ts +30 -102
- package/scripts/anyswarm-progress.ts +95 -0
- package/scripts/anyswarm-project.ts +31 -123
- package/scripts/anyswarm-source-runner.ts +9 -36
- package/scripts/anyswarm.ts +4 -24
- package/scripts/local-environment.ts +71 -20
- package/scripts/local-setup.ts +134 -94
- package/scripts/pack-release.ts +4 -1
- package/src/core/worker-image.ts +1 -1
- package/src/harness/project-harness.ts +2 -2
- package/src/harness/project-runtime.ts +2 -1
- package/dist/scripts/anyswarm-applications.d.ts +0 -19
- package/dist/scripts/anyswarm-applications.js +0 -19
- package/dist/scripts/anyswarm-tui-config.d.ts +0 -36
- package/dist/scripts/anyswarm-tui-config.js +0 -189
- package/dist/scripts/anyswarm-tui-session.d.ts +0 -66
- package/dist/scripts/anyswarm-tui-session.js +0 -304
- package/dist/scripts/anyswarm-tui-terminal.d.ts +0 -41
- package/dist/scripts/anyswarm-tui-terminal.js +0 -154
- package/dist/scripts/anyswarm-tui.d.ts +0 -2
- package/dist/scripts/anyswarm-tui.js +0 -1012
- package/docs/architecture/25-foreground-tui.md +0 -51
- package/scripts/anyswarm-applications.ts +0 -39
- package/scripts/anyswarm-tui-config.ts +0 -174
- package/scripts/anyswarm-tui-session.ts +0 -295
- package/scripts/anyswarm-tui-terminal.ts +0 -147
- package/scripts/anyswarm-tui.ts +0 -912
|
@@ -1,192 +1,12 @@
|
|
|
1
|
-
import { execFile
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { access, mkdir, mkdtemp, readFile, readlink, realpath, rename, rm, symlink, writeFile } from 'node:fs/promises';
|
|
5
|
-
import { homedir } from 'node:os';
|
|
6
|
-
import { basename, dirname, join, relative, resolve } from 'node:path';
|
|
1
|
+
import { execFile } from 'node:child_process';
|
|
2
|
+
import { readFile, realpath } from 'node:fs/promises';
|
|
3
|
+
import { dirname, join, resolve } from 'node:path';
|
|
7
4
|
import { fileURLToPath } from 'node:url';
|
|
8
5
|
import { promisify } from 'node:util';
|
|
9
6
|
|
|
10
7
|
const execute = promisify(execFile);
|
|
11
8
|
const packageName = '@anyswarm/core';
|
|
12
|
-
const previousPackageNames = ['@anyswarm/anyswarm', '@luna-shi/anyswarm'];
|
|
13
9
|
const packageRoot = resolve(fileURLToPath(new URL('../..', import.meta.url)));
|
|
14
|
-
const releaseRoot = 'https://github.com/AnySwarm/anyswarm/releases/download';
|
|
15
|
-
const stableVersion = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/;
|
|
16
|
-
const bins = ['anyswarm', 'anys', 'swarm'] as const;
|
|
17
|
-
const installDirectory = (prefix: string) => join(prefix, 'lib', 'anyswarm');
|
|
18
|
-
const installedPackage = (stage: string) => join(stage, 'node_modules', packageName);
|
|
19
|
-
const installBin = (prefix: string, name: typeof bins[number]) => join(prefix, 'bin', name);
|
|
20
|
-
|
|
21
|
-
type Installation = {
|
|
22
|
-
schema: 1;
|
|
23
|
-
version: string;
|
|
24
|
-
prefix: string;
|
|
25
|
-
source: string;
|
|
26
|
-
sha256: string;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
async function manifest(root: string): Promise<{ name: string; version: string }> {
|
|
30
|
-
return JSON.parse(await readFile(join(root, 'package.json'), 'utf8'));
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export async function archiveDigest(path: string) {
|
|
34
|
-
const hash = createHash('sha256');
|
|
35
|
-
for await (const chunk of createReadStream(path)) hash.update(chunk);
|
|
36
|
-
return hash.digest('hex');
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
async function replaceLink(path: string, target: string) {
|
|
40
|
-
const temporary = join(dirname(path), `.anyswarm-link-${randomUUID()}`);
|
|
41
|
-
try {
|
|
42
|
-
await symlink(target, temporary);
|
|
43
|
-
await rename(temporary, path);
|
|
44
|
-
} finally {
|
|
45
|
-
await rm(temporary, { force: true });
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
async function inspectLink(path: string) {
|
|
50
|
-
try { return await readlink(path); }
|
|
51
|
-
catch (error) {
|
|
52
|
-
if ((error as NodeJS.ErrnoException).code === 'ENOENT') return undefined;
|
|
53
|
-
if ((error as NodeJS.ErrnoException).code === 'EINVAL') throw new Error(`The regular file at ${path} belongs to another installation.`);
|
|
54
|
-
throw error;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function currentPath(prefix: string) {
|
|
59
|
-
return join(installDirectory(prefix), 'current');
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
function binTarget(prefix: string, name: typeof bins[number]) {
|
|
63
|
-
return relative(join(prefix, 'bin'), join(currentPath(prefix), 'node_modules', '.bin', name));
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
async function lockActivation<T>(prefix: string, action: () => Promise<T>, signal?: AbortSignal) {
|
|
67
|
-
signal?.throwIfAborted();
|
|
68
|
-
const lock = join(installDirectory(prefix), 'activation-flock');
|
|
69
|
-
const darwin = process.platform === 'darwin';
|
|
70
|
-
// Keep the inode stable so waiting and newly arriving processes lock the same file.
|
|
71
|
-
const flags = darwin ? ['-k', '-t', '15'] : ['--exclusive', '--timeout', '15'];
|
|
72
|
-
const child = spawn(darwin ? '/usr/bin/lockf' : 'flock', [...flags, lock, process.execPath, '-e',
|
|
73
|
-
'console.log("locked"); process.stdin.resume()'], { stdio: ['pipe', 'pipe', 'ignore'] });
|
|
74
|
-
child.stdin.on('error', () => {});
|
|
75
|
-
const cancelled = () => child.kill();
|
|
76
|
-
signal?.addEventListener('abort', cancelled, { once: true });
|
|
77
|
-
if (signal?.aborted) cancelled();
|
|
78
|
-
try {
|
|
79
|
-
await new Promise<void>((ready, reject) => {
|
|
80
|
-
child.once('error', reject);
|
|
81
|
-
child.once('exit', () => reject(new Error('The installation is busy. Retry after the other activation finishes.')));
|
|
82
|
-
child.stdout.once('data', () => ready());
|
|
83
|
-
});
|
|
84
|
-
signal?.removeEventListener('abort', cancelled);
|
|
85
|
-
signal?.throwIfAborted();
|
|
86
|
-
return await action();
|
|
87
|
-
} finally {
|
|
88
|
-
signal?.removeEventListener('abort', cancelled);
|
|
89
|
-
child.stdin.end();
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
async function activate(prefix: string, stage: string, source: string, sha256: string, signal?: AbortSignal, expected?: string) {
|
|
94
|
-
const root = installedPackage(stage);
|
|
95
|
-
const { name, version } = await manifest(root);
|
|
96
|
-
if (name !== packageName || !stableVersion.test(version)) throw new Error('The archive does not contain a stable AnySwarm distribution.');
|
|
97
|
-
for (const bin of ['anyswarm', 'swarm']) {
|
|
98
|
-
const path = join(stage, 'node_modules', '.bin', bin);
|
|
99
|
-
if (await realpath(path) !== join(root, 'dist', 'scripts', `${bin}.js`)) {
|
|
100
|
-
throw new Error(`The staged ${bin} entry does not belong to the package.`);
|
|
101
|
-
}
|
|
102
|
-
await access(path, constants.X_OK);
|
|
103
|
-
}
|
|
104
|
-
const { stdout } = await execute(join(stage, 'node_modules', '.bin', 'anyswarm'), ['--version'], {
|
|
105
|
-
signal, timeout: 10_000, env: { ...process.env, NODE_OPTIONS: '' },
|
|
106
|
-
});
|
|
107
|
-
if (stdout.trim() !== version) throw new Error('The staged CLI did not report the package version.');
|
|
108
|
-
await writeFile(join(stage, 'install.json'), JSON.stringify({ schema: 1, prefix, version, source, sha256 } satisfies Installation), { mode: 0o600 });
|
|
109
|
-
await mkdir(join(prefix, 'bin'), { recursive: true });
|
|
110
|
-
return lockActivation(prefix, async () => {
|
|
111
|
-
const changed: { path: string; previous?: string }[] = [];
|
|
112
|
-
try {
|
|
113
|
-
const oldCurrent = await inspectLink(currentPath(prefix));
|
|
114
|
-
if (expected !== undefined && (!oldCurrent || resolve(installDirectory(prefix), oldCurrent) !== expected)) {
|
|
115
|
-
throw new Error('Another process already changed this installation. Run the current CLI to update.');
|
|
116
|
-
}
|
|
117
|
-
for (const bin of bins) {
|
|
118
|
-
const path = installBin(prefix, bin);
|
|
119
|
-
const host = bin === 'anys' ? 'anyswarm' : bin;
|
|
120
|
-
const target = binTarget(prefix, host);
|
|
121
|
-
const previous = await inspectLink(path);
|
|
122
|
-
if (previous === target) continue;
|
|
123
|
-
const npmTargets = [packageName, ...previousPackageNames].map(name =>
|
|
124
|
-
join(prefix, 'lib', 'node_modules', name, 'dist', 'scripts', `${host}.js`));
|
|
125
|
-
const legacyAlias = bin === 'anys' && previous === binTarget(prefix, 'anys') && oldCurrent &&
|
|
126
|
-
dirname(resolve(installDirectory(prefix), oldCurrent)) === join(installDirectory(prefix), 'versions');
|
|
127
|
-
if (previous && !legacyAlias && !npmTargets.includes(resolve(dirname(path), previous))) {
|
|
128
|
-
throw new Error(`The link at ${path} belongs to another installation.`);
|
|
129
|
-
}
|
|
130
|
-
await replaceLink(path, target);
|
|
131
|
-
changed.push({ path, previous });
|
|
132
|
-
}
|
|
133
|
-
signal?.throwIfAborted();
|
|
134
|
-
await replaceLink(currentPath(prefix), relative(installDirectory(prefix), stage));
|
|
135
|
-
return { version, packageRoot: root, path: installBin(prefix, 'anyswarm') };
|
|
136
|
-
} catch (error) {
|
|
137
|
-
for (const { path, previous } of changed.reverse()) {
|
|
138
|
-
if (previous) await replaceLink(path, previous);
|
|
139
|
-
else await rm(path);
|
|
140
|
-
}
|
|
141
|
-
throw error;
|
|
142
|
-
}
|
|
143
|
-
}, signal);
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
async function managedInstallation(invocation: string, version: string) {
|
|
147
|
-
const stage = resolve(packageRoot, '../../..');
|
|
148
|
-
const installation = await readFile(join(stage, 'install.json'), 'utf8')
|
|
149
|
-
.then(data => JSON.parse(data) as Installation).catch(() => undefined);
|
|
150
|
-
if (!installation || installation.schema !== 1 || installation.version !== version ||
|
|
151
|
-
typeof installation.prefix !== 'string' ||
|
|
152
|
-
dirname(stage) !== join(installDirectory(installation.prefix), 'versions') ||
|
|
153
|
-
await realpath(invocation).catch(() => '') !== join(packageRoot, 'dist', 'scripts', 'anyswarm.js')) return undefined;
|
|
154
|
-
const entry = installBin(installation.prefix, 'anyswarm');
|
|
155
|
-
if (await realpath(entry).catch(() => '') !== await realpath(invocation)) {
|
|
156
|
-
throw new Error(`This CLI version is no longer active. Run ${entry} update.`);
|
|
157
|
-
}
|
|
158
|
-
return { ...installation, stage, entry };
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
async function fetchFile(url: string, signal: AbortSignal) {
|
|
162
|
-
const response = await fetch(url, { signal, headers: { 'User-Agent': 'AnySwarm-CLI' } });
|
|
163
|
-
if (!response.ok) throw new Error(`GitHub returned HTTP ${response.status} for the release material.`);
|
|
164
|
-
return response;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
async function latestRelease(signal: AbortSignal) {
|
|
168
|
-
const response = await fetchFile('https://api.github.com/repos/AnySwarm/anyswarm/releases/latest', signal);
|
|
169
|
-
const data = await response.json() as { tag_name?: string; prerelease?: boolean; draft?: boolean };
|
|
170
|
-
const version = data.tag_name?.slice(1);
|
|
171
|
-
if (!data.tag_name?.startsWith('v') || !version || !stableVersion.test(version) || data.draft || data.prerelease) {
|
|
172
|
-
throw new Error('GitHub did not return a stable AnySwarm release.');
|
|
173
|
-
}
|
|
174
|
-
return version;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
async function releaseArchive(version: string, temporary: string, signal: AbortSignal) {
|
|
178
|
-
const directory = `${releaseRoot}/v${version}`;
|
|
179
|
-
const filename = `luna-shi-anyswarm-${version}.tgz`;
|
|
180
|
-
const checksums = await (await fetchFile(`${directory}/SHA256SUMS`, signal)).text();
|
|
181
|
-
const digest = checksums.split('\n').map(line => line.trim().split(/\s+/))
|
|
182
|
-
.find(([hash, name]) => name === filename && /^[a-f0-9]{64}$/.test(hash))?.[0];
|
|
183
|
-
if (!digest) throw new Error('The release does not contain a checksum for the package.');
|
|
184
|
-
const source = `${directory}/${filename}`;
|
|
185
|
-
const response = await fetchFile(source, signal);
|
|
186
|
-
const path = join(temporary, filename);
|
|
187
|
-
await writeFile(path, response.body as unknown as AsyncIterable<Uint8Array>, { signal });
|
|
188
|
-
return { path, source, digest };
|
|
189
|
-
}
|
|
190
10
|
|
|
191
11
|
const quoted = (value: string) => "'" + value.replaceAll("'", "'\\''") + "'";
|
|
192
12
|
|
|
@@ -201,124 +21,28 @@ async function npmGlobalPrefix(invocation: string, signal: AbortSignal) {
|
|
|
201
21
|
}
|
|
202
22
|
|
|
203
23
|
function packageManagerRemedy(path: string) {
|
|
204
|
-
const
|
|
24
|
+
const latest = packageName + '@latest';
|
|
205
25
|
if (path.includes('/.pnpm/') || path.includes('/pnpm/global/')) {
|
|
206
|
-
return `Use pnpm in the original scope: pnpm add${path.includes('/pnpm/global/') ? ' --global' : ''} ${
|
|
26
|
+
return `Use pnpm in the original scope: pnpm add${path.includes('/pnpm/global/') ? ' --global' : ''} ${latest}. Package: ${path}.`;
|
|
207
27
|
}
|
|
208
28
|
if (path.includes('/.yarn/') || path.includes('/yarn/global/')) {
|
|
209
|
-
return `Use Yarn in the original scope: yarn ${path.includes('/yarn/global/') ? 'global ' : ''}add ${
|
|
29
|
+
return `Use Yarn in the original scope: yarn ${path.includes('/yarn/global/') ? 'global ' : ''}add ${latest}. Package: ${path}.`;
|
|
210
30
|
}
|
|
211
31
|
if (path.includes('/node_modules/')) {
|
|
212
32
|
const prefix = path.slice(0, path.lastIndexOf('/node_modules/'));
|
|
213
|
-
return `To change this project's SDK explicitly, run npm install --prefix ${quoted(prefix)} ${
|
|
33
|
+
return `To change this project's SDK explicitly, run npm install --prefix ${quoted(prefix)} ${latest}. Package: ${path}.`;
|
|
214
34
|
}
|
|
215
|
-
return `
|
|
35
|
+
return `Update the package in its original installation scope. Package: ${path}.`;
|
|
216
36
|
}
|
|
217
37
|
|
|
218
|
-
export async function updateAnySwarm(
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
if (npmPrefix) return {
|
|
229
|
-
ok: false, before, after: before, path: invocation, packageRoot, source: 'npm global',
|
|
230
|
-
result: 'preserved', environment: 'separate',
|
|
231
|
-
detail: `This CLI was installed with npm. Update it with \`npm install -g --prefix ${quoted(npmPrefix)} ${packageName}@latest\`.`,
|
|
232
|
-
};
|
|
233
|
-
return {
|
|
234
|
-
ok: false, before, path: invocation, packageRoot, source: 'other',
|
|
235
|
-
detail: packageManagerRemedy(packageRoot), environment: 'separate',
|
|
236
|
-
};
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
const status = { before, path: installation.entry, packageRoot, source: installation.source, environment: 'separate' };
|
|
240
|
-
let temporary: string | undefined;
|
|
241
|
-
let stage: string | undefined;
|
|
242
|
-
let activated = false;
|
|
243
|
-
try {
|
|
244
|
-
const deadline = AbortSignal.any([signal, AbortSignal.timeout(180_000)]);
|
|
245
|
-
const release = options.archive ? undefined : await latestRelease(deadline);
|
|
246
|
-
if (release) {
|
|
247
|
-
const current = before.split('.').map(Number);
|
|
248
|
-
const candidate = release.split('.').map(Number);
|
|
249
|
-
const firstChange = candidate.findIndex((part, index) => part !== current[index]);
|
|
250
|
-
if (firstChange < 0 || candidate[firstChange] < current[firstChange]) {
|
|
251
|
-
return { ok: true, ...status, after: before, result: 'up-to-date' };
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
const parent = installDirectory(installation.prefix);
|
|
255
|
-
temporary = await mkdtemp(join(parent, 'anyswarm-download-'));
|
|
256
|
-
const archive = options.archive
|
|
257
|
-
? { path: resolve(options.archive), source: resolve(options.archive), digest: options.sha256! }
|
|
258
|
-
: await releaseArchive(release!, temporary, deadline);
|
|
259
|
-
if (await archiveDigest(archive.path) !== archive.digest) throw new Error('The archive SHA-256 does not match the expected checksum.');
|
|
260
|
-
const verifiedArchive = join(temporary, 'verified.tgz');
|
|
261
|
-
if (options.archive) {
|
|
262
|
-
await writeFile(verifiedArchive, createReadStream(archive.path), { signal: deadline });
|
|
263
|
-
if (await archiveDigest(verifiedArchive) !== archive.digest) throw new Error('The archive changed while it was being staged.');
|
|
264
|
-
}
|
|
265
|
-
progress(`Preparing ${release ? `AnySwarm ${release}` : 'the specified AnySwarm archive'}`);
|
|
266
|
-
const approvedArchive = options.archive ? verifiedArchive : archive.path;
|
|
267
|
-
const npmFlags = ['--omit=dev', '--prefer-offline', '--ignore-scripts', '--no-audit', '--no-fund'];
|
|
268
|
-
stage = await mkdtemp(join(parent, 'versions', 'release-'));
|
|
269
|
-
await execute('npm', ['install', '--prefix', stage, ...npmFlags, approvedArchive], { timeout: 120_000, signal: deadline });
|
|
270
|
-
const { version } = await manifest(installedPackage(stage));
|
|
271
|
-
if (release && version !== release) throw new Error('The release archive version does not match its release tag.');
|
|
272
|
-
const updated = await activate(installation.prefix, stage, archive.source, archive.digest, deadline, installation.stage);
|
|
273
|
-
activated = true;
|
|
274
|
-
return { ok: true, ...status, ...updated, after: updated.version, source: archive.source, sha256: archive.digest, result: 'updated' };
|
|
275
|
-
} catch (error) {
|
|
276
|
-
const detail = error instanceof Error && 'cmd' in error
|
|
277
|
-
? 'A command failed while installing or verifying the staged CLI. Check npm connectivity and installation permissions.'
|
|
278
|
-
: error instanceof Error ? error.message : String(error);
|
|
279
|
-
const activePath = await realpath(status.path).catch(() => undefined);
|
|
280
|
-
const preserved = activePath === join(packageRoot, 'dist', 'scripts', 'anyswarm.js');
|
|
281
|
-
return { ok: false, ...status, ...(preserved ? { after: before } : {}), result: preserved ? 'preserved' : 'failed', detail };
|
|
282
|
-
} finally {
|
|
283
|
-
if (temporary) await rm(temporary, { recursive: true, force: true }).catch(() => {});
|
|
284
|
-
if (stage && !activated) await rm(stage, { recursive: true, force: true }).catch(() => {});
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
export async function activateOfficialInstall(input: {
|
|
289
|
-
prefix: string; stage: string; source: string; sha256: string; expectedVersion?: string;
|
|
290
|
-
}) {
|
|
291
|
-
const prefix = await realpath(resolve(input.prefix));
|
|
292
|
-
const stage = await realpath(resolve(input.stage));
|
|
293
|
-
if (dirname(stage) !== join(installDirectory(prefix), 'versions')) throw new Error('The staged installation is outside the selected prefix.');
|
|
294
|
-
if (!/^[a-f0-9]{64}$/.test(input.sha256)) throw new Error('A verified archive SHA-256 is required.');
|
|
295
|
-
if (input.expectedVersion && (await manifest(installedPackage(stage))).version !== input.expectedVersion) {
|
|
296
|
-
throw new Error('The archive version does not match the requested GitHub release.');
|
|
297
|
-
}
|
|
298
|
-
const result = await activate(prefix, stage, input.source, input.sha256);
|
|
299
|
-
console.log(`Installed AnySwarm ${result.version} at ${result.path}`);
|
|
300
|
-
console.log(`Package root: ${result.packageRoot}\nInstall source: ${input.source}\nArchive SHA-256: ${input.sha256}`);
|
|
301
|
-
let resolvedOnPath: string | undefined;
|
|
302
|
-
for (const entry of (process.env.PATH ?? '').split(':')) {
|
|
303
|
-
const path = resolve(entry, 'anyswarm');
|
|
304
|
-
if (await access(path, constants.X_OK).then(() => true, () => false)) {
|
|
305
|
-
resolvedOnPath = path;
|
|
306
|
-
break;
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
if (resolvedOnPath !== result.path) {
|
|
310
|
-
const directory = dirname(result.path);
|
|
311
|
-
const display = directory === join(homedir(), '.local', 'bin') ? '"$HOME/.local/bin:$PATH"'
|
|
312
|
-
: `'${directory.replaceAll("'", "'\\''")}':"$PATH"`;
|
|
313
|
-
console.error(`Add the installation to PATH:\n export PATH=${display}`);
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
if (basename(process.argv[1] ?? '') === 'anyswarm-installation.js') {
|
|
318
|
-
const [prefix, stage, source, sha256, expectedVersion] = process.argv.slice(2);
|
|
319
|
-
try { await activateOfficialInstall({ prefix, stage, source, sha256, expectedVersion }); }
|
|
320
|
-
catch (error) {
|
|
321
|
-
console.error(error instanceof Error ? error.message : String(error));
|
|
322
|
-
process.exitCode = 1;
|
|
323
|
-
}
|
|
38
|
+
export async function updateAnySwarm(signal: AbortSignal) {
|
|
39
|
+
const { version } = JSON.parse(await readFile(join(packageRoot, 'package.json'), 'utf8'));
|
|
40
|
+
const path = resolve(process.argv[1]);
|
|
41
|
+
const prefix = await npmGlobalPrefix(path, signal);
|
|
42
|
+
const result = { ok: false, before: version, path, packageRoot, environment: 'separate' };
|
|
43
|
+
if (prefix) return {
|
|
44
|
+
...result, ok: true, after: version, source: 'npm global', result: 'preserved',
|
|
45
|
+
detail: `This CLI was installed with npm. Update it with \`npm install -g --prefix ${quoted(prefix)} ${packageName}@latest\`.`,
|
|
46
|
+
};
|
|
47
|
+
return { ...result, source: 'other', detail: packageManagerRemedy(packageRoot) };
|
|
324
48
|
}
|
|
@@ -1,108 +1,36 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import type {
|
|
4
|
-
import { findApplication, type ApplicationObservation } from './anyswarm-applications.js';
|
|
1
|
+
import { createHarnessSession, loadProjectConfiguration, loadProjectHarnessModule } from '../src/harness/project-harness.js';
|
|
2
|
+
import { ProjectPreflightError } from '../src/harness/project-input.js';
|
|
3
|
+
import type { ProjectCommand } from './anyswarm-arguments.js';
|
|
5
4
|
import { builtins } from './anyswarm-harnesses.js';
|
|
6
5
|
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
signal
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
if (!value || typeof value !== 'object' || !('kind' in value) || value.kind !== 'start-run') return;
|
|
23
|
-
const run = value as ActionRun;
|
|
24
|
-
if (typeof run.cwd !== 'string' || !run.cwd || typeof run.prompt !== 'string' || !run.prompt.trim()) {
|
|
25
|
-
throw new Error('A standalone action must supply a workspace and prompt to start a Run.');
|
|
26
|
-
}
|
|
27
|
-
return run;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export function actionReport(value: unknown): { exitCode: number; result: unknown } | undefined {
|
|
31
|
-
if (!value || typeof value !== 'object' || !('kind' in value) || value.kind !== 'action-report') return;
|
|
32
|
-
if (!('result' in value) || !('exitCode' in value) || typeof value.exitCode !== 'number' ||
|
|
33
|
-
!Number.isSafeInteger(value.exitCode) || value.exitCode < 0 || value.exitCode > 125) {
|
|
34
|
-
throw new Error('An action report must supply a result and an exit code from 0 to 125.');
|
|
35
|
-
}
|
|
36
|
-
return { exitCode: value.exitCode, result: value.result };
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export function configuredStopTimeout(configuration: Record<string, unknown> | undefined) {
|
|
40
|
-
const ms = configuration?.closeTimeoutMs ?? configuration?.cleanupTimeoutMs;
|
|
41
|
-
return typeof ms === 'number' && Number.isSafeInteger(ms) && ms > 0 ? Math.min(2_147_483_647, ms + 5000) : undefined;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export function requestedTraceRoot(value: unknown, runId: string | null) {
|
|
45
|
-
if (!runId || !value || typeof value !== 'object' || !('kind' in value) || value.kind !== 'trace.request' ||
|
|
46
|
-
!('runDirectory' in value) || typeof value.runDirectory !== 'string' || !isAbsolute(value.runDirectory) ||
|
|
47
|
-
basename(value.runDirectory) !== runId) return;
|
|
48
|
-
return value.runDirectory;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
type SlashAction = (options: LaunchContext & { args: string }) => unknown | Promise<unknown>;
|
|
52
|
-
|
|
53
|
-
export async function loadHarness(launchDirectory: string, specifier: string,
|
|
54
|
-
options?: Parameters<typeof loadProjectHarnessModule>[3]) {
|
|
55
|
-
const application = findApplication(specifier);
|
|
56
|
-
if (application && !application.available) throw new Error(application.title + ' is not included in this SDK build.');
|
|
57
|
-
const { module, definition } = await loadProjectHarnessModule(launchDirectory, specifier, builtins, options);
|
|
58
|
-
const observe = typeof module.observe === 'function'
|
|
59
|
-
? module.observe as (options: LaunchContext) => Promise<ApplicationObservation | undefined>
|
|
60
|
-
: undefined;
|
|
61
|
-
const actions = new Map<string, SlashAction>();
|
|
62
|
-
if (module.slashActions && typeof module.slashActions === 'object') {
|
|
63
|
-
for (const [name, handler] of Object.entries(module.slashActions)) {
|
|
64
|
-
if (!/^[a-z][\w-]*$/.test(name) || typeof handler !== 'function') {
|
|
65
|
-
throw new Error('Harness slashActions must map command names to functions.');
|
|
6
|
+
export async function prepareProjectLaunch(command: ProjectCommand, launchDirectory: string,
|
|
7
|
+
options: Parameters<typeof loadProjectHarnessModule>[3], signal: AbortSignal) {
|
|
8
|
+
const { module, definition } = await loadProjectHarnessModule(launchDirectory, command.harness, builtins, options);
|
|
9
|
+
signal.throwIfAborted();
|
|
10
|
+
let cwd = command.mode === 'foreground' ? command.cwd : undefined;
|
|
11
|
+
let configuration: unknown;
|
|
12
|
+
let stopTimeoutMs: number | undefined;
|
|
13
|
+
if (command.mode === 'foreground' && typeof module.resolveWorkspace === 'function') {
|
|
14
|
+
configuration = await loadProjectConfiguration(launchDirectory, command.configPath);
|
|
15
|
+
signal.throwIfAborted();
|
|
16
|
+
if (cwd === undefined) {
|
|
17
|
+
try { cwd = module.resolveWorkspace({ cwd: launchDirectory, configuration }); }
|
|
18
|
+
catch { throw new ProjectPreflightError('INVALID_RUN_CONFIGURATION', 'Could not resolve the Harness workspace'); }
|
|
19
|
+
if (typeof cwd !== 'string' || !cwd.trim()) {
|
|
20
|
+
throw new ProjectPreflightError('INVALID_RUN_CONFIGURATION', 'The Harness workspace resolver must return a directory');
|
|
66
21
|
}
|
|
67
|
-
|
|
22
|
+
}
|
|
23
|
+
const config = configuration as Record<string, unknown> | undefined;
|
|
24
|
+
const timeout = config?.closeTimeoutMs ?? config?.cleanupTimeoutMs;
|
|
25
|
+
if (typeof timeout === 'number' && Number.isSafeInteger(timeout) && timeout > 0) {
|
|
26
|
+
stopTimeoutMs = Math.min(2_147_483_647, timeout + 5000);
|
|
68
27
|
}
|
|
69
28
|
}
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
: undefined
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
const supported = harness.lifetimes ?? ['task'];
|
|
78
|
-
const lifetime = requested ?? (preferred && supported.includes(preferred) ? preferred : supported[0]);
|
|
79
|
-
if (!supported.includes(lifetime)) throw new Error('This Harness does not support the requested lifetime.');
|
|
80
|
-
return lifetime;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
export function splitInput(text: string): [string, string] {
|
|
84
|
-
const end = text.search(/\s/);
|
|
85
|
-
return end < 0 ? [text, ''] : [text.slice(0, end), text.slice(end).trimStart()];
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
export function interactiveTerminal() {
|
|
89
|
-
return process.stdin.isTTY && process.stdout.isTTY && process.env.TERM !== 'dumb';
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
export async function runHarnessSelection(command: HarnessCommand, launchDirectory: string,
|
|
93
|
-
options?: Parameters<typeof loadProjectHarnessModule>[3]) {
|
|
94
|
-
if (command.mode === 'action') {
|
|
95
|
-
const { runHarnessAction } = await import('./anyswarm-project.js');
|
|
96
|
-
return runHarnessAction(command, launchDirectory, options);
|
|
97
|
-
}
|
|
98
|
-
const mode = command.mode === 'auto' ? (interactiveTerminal() ? 'tui' : 'headless') : command.mode;
|
|
99
|
-
if (mode === 'tui') {
|
|
100
|
-
const { runAnySwarmTui } = await import('./anyswarm-tui.js');
|
|
101
|
-
return runAnySwarmTui({ ...command, command: 'tui' }, launchDirectory);
|
|
102
|
-
}
|
|
103
|
-
const { runProjectCommand } = await import('./anyswarm-project.js');
|
|
104
|
-
const project = { ...command, command: 'harness' as const, defaults: true };
|
|
105
|
-
if (mode === 'rpc') return runProjectCommand({ ...project, mode }, launchDirectory, options);
|
|
106
|
-
return runProjectCommand({ ...project, mode, cwd: command.cwd && resolve(launchDirectory, command.cwd),
|
|
107
|
-
prompt: command.prompt ?? 'Run this Harness.' }, launchDirectory, options);
|
|
29
|
+
const session = createHarnessSession(definition, {
|
|
30
|
+
launchDirectory, configuration, stopTimeoutMs,
|
|
31
|
+
configPath: configuration === undefined ? command.configPath : undefined, outputRoot: command.outputRoot,
|
|
32
|
+
lifetime: command.mode === 'foreground' ? 'task' : command.lifetime,
|
|
33
|
+
clientCapabilities: { questions: command.mode === 'rpc' && command.interaction === 'questions' },
|
|
34
|
+
});
|
|
35
|
+
return { session, cwd, harnessId: definition.id };
|
|
108
36
|
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { dirname, join, resolve } from 'node:path';
|
|
2
|
+
import { homedir } from 'node:os';
|
|
3
|
+
import type { HarnessEvent, HarnessResult, HarnessSession } from '../src/harness/harness-session-types.js';
|
|
4
|
+
|
|
5
|
+
function object(value: unknown): Record<string, unknown> {
|
|
6
|
+
return value && typeof value === 'object' && !Array.isArray(value) ? value as Record<string, unknown> : {};
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function shellPath(path: string) {
|
|
10
|
+
return /^[\w./-]+$/.test(path) ? path : "'" + path.replaceAll("'", "'\\''") + "'";
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const serviceActions = new Set(['service.register', 'service.start', 'service.restart', 'service.stop', 'service.retire']);
|
|
14
|
+
|
|
15
|
+
export function foregroundProgress(session: HarnessSession, harnessId: string, launchDirectory: string,
|
|
16
|
+
outputRoot: string | undefined, write: (message: string) => Promise<void>) {
|
|
17
|
+
const root = outputRoot ? resolve(launchDirectory, outputRoot)
|
|
18
|
+
: resolve(process.env.XDG_STATE_HOME || join(homedir(), '.local', 'state'), 'anyswarm', 'runs');
|
|
19
|
+
const report = (message: string) => write(message.replace(/[\p{Cc}\p{Cf}]/gu, character =>
|
|
20
|
+
'\\u' + character.charCodeAt(0).toString(16).padStart(4, '0')));
|
|
21
|
+
const trace = (directory: string) => report('Trace anyswarm trace --root ' + shellPath(directory));
|
|
22
|
+
void report('Starting ' + harnessId);
|
|
23
|
+
void trace(root);
|
|
24
|
+
const agents = new Map<string, string>();
|
|
25
|
+
let phase: string | undefined;
|
|
26
|
+
let services: Promise<void> | undefined;
|
|
27
|
+
let closed = false;
|
|
28
|
+
function observe(event: HarnessEvent) {
|
|
29
|
+
if (event.type === 'state' || event.type === 'snapshot') {
|
|
30
|
+
if (phase !== event.state.phase) {
|
|
31
|
+
phase = event.state.phase;
|
|
32
|
+
if (phase === 'running') {
|
|
33
|
+
void report('Harness running');
|
|
34
|
+
services = session.services.list().then(async sources => {
|
|
35
|
+
const names = [...new Set(sources.map(source => source.name))].sort();
|
|
36
|
+
if (!closed && names.length) await report('Services available ' + names.join(', '));
|
|
37
|
+
}).catch(() => {});
|
|
38
|
+
}
|
|
39
|
+
if (phase === 'stopping') void report('Stopping Run and waiting for cleanup');
|
|
40
|
+
}
|
|
41
|
+
if (!Array.isArray(event.state.agents)) return;
|
|
42
|
+
for (const item of event.state.agents) {
|
|
43
|
+
const { id, profile, status } = object(item);
|
|
44
|
+
if (typeof id !== 'string' || typeof profile !== 'string' || typeof status !== 'string') continue;
|
|
45
|
+
const previous = agents.get(id);
|
|
46
|
+
if (status === previous) continue;
|
|
47
|
+
agents.set(id, status);
|
|
48
|
+
const label = profile + ' [' + id.slice(0, 8) + ']';
|
|
49
|
+
if (status === 'starting') void report('Agent starting ' + label);
|
|
50
|
+
if ((!previous || previous === 'starting') && (status === 'idle' || status === 'running')) {
|
|
51
|
+
void report('Sandbox ready ' + label);
|
|
52
|
+
}
|
|
53
|
+
if (status === 'closed') void report('Agent closed ' + label);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
if (event.type !== 'event') return;
|
|
57
|
+
const { kind, event: raw } = object(event.event);
|
|
58
|
+
if (kind !== 'agent') return;
|
|
59
|
+
const runtime = object(raw);
|
|
60
|
+
if (runtime.type === 'settled' && typeof runtime.agentId === 'string') {
|
|
61
|
+
void report('Agent settled [' + runtime.agentId.slice(0, 8) + '] ' + String(runtime.outcome));
|
|
62
|
+
}
|
|
63
|
+
if (runtime.type !== 'management') return;
|
|
64
|
+
const { operation, definition } = object(runtime.change);
|
|
65
|
+
const { id, state } = object(definition);
|
|
66
|
+
if (typeof operation === 'string' && serviceActions.has(operation) && typeof id === 'string' && typeof state === 'string') {
|
|
67
|
+
void report('Service ' + operation.slice('service.'.length) + ' ' + id + ' (' + state + ')');
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return {
|
|
71
|
+
observe,
|
|
72
|
+
async finish(result: HarnessResult) {
|
|
73
|
+
await services;
|
|
74
|
+
closed = true;
|
|
75
|
+
const message = result.failure?.message ?? result.reportSaveFailure?.message;
|
|
76
|
+
void report('Run ' + result.outcome + ' ' + result.reason + (message ? ' (' + message + ')' : ''));
|
|
77
|
+
for (const artifact of result.artifacts.slice(0, 5)) {
|
|
78
|
+
const path = typeof artifact === 'string' ? artifact : object(artifact).path;
|
|
79
|
+
if (typeof path === 'string') void report('Artifact ' + path);
|
|
80
|
+
}
|
|
81
|
+
if (result.artifacts.length > 5) void report('Additional artifacts ' + (result.artifacts.length - 5));
|
|
82
|
+
if (result.export) void report('Export ' + result.export.status);
|
|
83
|
+
void report('Cleanup ' + result.cleanup.status);
|
|
84
|
+
if (result.reportPath) void report('Run report ' + result.reportPath);
|
|
85
|
+
const prompt = object(object(result).prompt).path;
|
|
86
|
+
const recordPath = result.reportPath ?? (typeof prompt === 'string' ? prompt : undefined);
|
|
87
|
+
await trace(recordPath ? dirname(dirname(recordPath)) : root);
|
|
88
|
+
},
|
|
89
|
+
async fail(code: string, message?: string) {
|
|
90
|
+
closed = true;
|
|
91
|
+
void report(code + (message ? ' ' + message : ''));
|
|
92
|
+
await trace(root);
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
}
|