@agentage/cli 0.51.1 → 0.52.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -15
- package/dist/commands/auth/setup.d.ts +2 -0
- package/dist/commands/auth/setup.js +4 -1
- package/dist/commands/daemon/daemon.d.ts +38 -0
- package/dist/commands/daemon/daemon.js +75 -0
- package/dist/commands/daemon/installer.d.ts +11 -0
- package/dist/commands/daemon/installer.js +87 -0
- package/dist/commands/daemon/move-plan.d.ts +17 -0
- package/dist/commands/daemon/move-plan.js +67 -0
- package/dist/commands/daemon/move-settings.d.ts +5 -0
- package/dist/commands/daemon/move-settings.js +50 -0
- package/dist/commands/daemon/move.d.ts +17 -0
- package/dist/commands/daemon/move.js +106 -0
- package/dist/commands/daemon/run.d.ts +6 -0
- package/dist/commands/daemon/run.js +36 -0
- package/dist/commands/extension/build.d.ts +13 -4
- package/dist/commands/extension/build.js +67 -25
- package/dist/commands/extension/configure.d.ts +26 -0
- package/dist/commands/extension/configure.js +100 -0
- package/dist/commands/extension/create-install.d.ts +26 -0
- package/dist/commands/extension/create-install.js +81 -0
- package/dist/commands/extension/create.d.ts +6 -1
- package/dist/commands/extension/create.js +33 -12
- package/dist/commands/extension/delegate.js +3 -1
- package/dist/commands/extension/doctor.d.ts +1 -1
- package/dist/commands/extension/doctor.js +8 -7
- package/dist/commands/extension/install-once.d.ts +17 -0
- package/dist/commands/extension/install-once.js +57 -0
- package/dist/commands/extension/kit-tool.d.ts +1 -1
- package/dist/commands/extension/lifecycle-commands.d.ts +19 -0
- package/dist/commands/extension/lifecycle-commands.js +80 -0
- package/dist/commands/extension/lifecycle-list.d.ts +26 -0
- package/dist/commands/extension/lifecycle-list.js +92 -0
- package/dist/commands/extension/lifecycle.d.ts +41 -0
- package/dist/commands/extension/lifecycle.js +142 -0
- package/dist/commands/extension/line.d.ts +1 -0
- package/dist/commands/extension/line.js +2 -0
- package/dist/commands/extension/list.d.ts +4 -14
- package/dist/commands/extension/list.js +11 -96
- package/dist/commands/extension/package-build.d.ts +15 -0
- package/dist/commands/extension/package-build.js +51 -0
- package/dist/commands/extension/plan.d.ts +4 -2
- package/dist/commands/extension/plan.js +37 -37
- package/dist/commands/extension/profile-plan.d.ts +16 -0
- package/dist/commands/extension/profile-plan.js +48 -0
- package/dist/commands/extension/release.d.ts +2 -1
- package/dist/commands/extension/release.js +10 -9
- package/dist/commands/extension/row-lines.d.ts +1 -2
- package/dist/commands/extension/row-lines.js +5 -6
- package/dist/commands/extension/rows.js +6 -4
- package/dist/commands/extension/setup-cloud.d.ts +2 -2
- package/dist/commands/extension/setup-cloud.js +6 -5
- package/dist/commands/extension/setup-install.d.ts +8 -0
- package/dist/commands/extension/setup-install.js +56 -0
- package/dist/commands/extension/setup.d.ts +4 -1
- package/dist/commands/extension/setup.js +56 -18
- package/dist/commands/extension/sync.d.ts +6 -11
- package/dist/commands/extension/sync.js +8 -50
- package/dist/commands/extension/up-commands.d.ts +9 -0
- package/dist/commands/extension/up-commands.js +74 -0
- package/dist/commands/extension/up-local.d.ts +21 -0
- package/dist/commands/extension/up-local.js +94 -0
- package/dist/commands/extension/up-run.d.ts +23 -0
- package/dist/commands/extension/up-run.js +75 -0
- package/dist/commands/extension/up.d.ts +10 -10
- package/dist/commands/extension/up.js +62 -74
- package/dist/commands/update/update.d.ts +9 -1
- package/dist/commands/update/update.js +20 -6
- package/dist/core/installer/compare-lock.d.ts +0 -2
- package/dist/core/installer/compare-lock.js +0 -12
- package/dist/core/installer/compat.js +5 -3
- package/dist/core/installer/npm.d.ts +1 -0
- package/dist/core/installer/npm.js +6 -0
- package/dist/core/installer/old-tree.d.ts +3 -0
- package/dist/core/installer/old-tree.js +45 -0
- package/dist/core/installer/package-dir.d.ts +11 -0
- package/dist/core/installer/package-dir.js +53 -0
- package/dist/core/installer/resolve.js +1 -2
- package/dist/core/installer/tree.d.ts +0 -5
- package/dist/core/installer/tree.js +1 -25
- package/dist/core/kit-id.d.ts +1 -0
- package/dist/core/kit-id.js +20 -0
- package/dist/core/loader/discover.d.ts +7 -1
- package/dist/core/loader/discover.js +5 -4
- package/dist/core/loader/installed.d.ts +9 -0
- package/dist/core/loader/installed.js +51 -0
- package/dist/core/loader/manifest.d.ts +4 -0
- package/dist/core/loader/manifest.js +25 -3
- package/dist/core/loader/scan.d.ts +2 -1
- package/dist/core/loader/scan.js +17 -4
- package/dist/core/loader/secrets.d.ts +0 -7
- package/dist/core/loader/secrets.js +0 -11
- package/dist/core/loader/verbs.d.ts +0 -1
- package/dist/core/loader/verbs.js +1 -13
- package/dist/core/profile/machine.d.ts +0 -1
- package/dist/core/profile/machine.js +0 -5
- package/dist/lib/auth/introspect.js +1 -2
- package/dist/lib/auth/sign-in.js +3 -0
- package/dist/lib/child-env.d.ts +1 -0
- package/dist/lib/child-env.js +6 -0
- package/dist/lib/daemon/daemon-answer.d.ts +8 -0
- package/dist/lib/daemon/daemon-answer.js +38 -0
- package/dist/lib/daemon/daemon-client.d.ts +19 -0
- package/dist/lib/daemon/daemon-client.js +125 -0
- package/dist/lib/daemon/daemon-file.d.ts +16 -0
- package/dist/lib/daemon/daemon-file.js +30 -0
- package/dist/lib/daemon/daemon-health.d.ts +16 -0
- package/dist/lib/daemon/daemon-health.js +36 -0
- package/dist/lib/daemon/daemon-probe.d.ts +34 -0
- package/dist/lib/daemon/daemon-probe.js +50 -0
- package/dist/lib/daemon/daemon-stop.d.ts +13 -0
- package/dist/lib/daemon/daemon-stop.js +42 -0
- package/dist/lib/daemon/host-client.d.ts +40 -0
- package/dist/lib/daemon/host-client.js +45 -0
- package/dist/lib/exit-code.d.ts +2 -0
- package/dist/lib/exit-code.js +8 -0
- package/dist/lib/fs/json-file.d.ts +1 -0
- package/dist/lib/fs/json-file.js +1 -1
- package/dist/lib/json-output.d.ts +36 -0
- package/dist/lib/json-output.js +163 -0
- package/dist/lib/net/market-error.d.ts +12 -0
- package/dist/lib/net/market-error.js +28 -0
- package/dist/lib/net/market.d.ts +17 -2
- package/dist/lib/net/market.js +92 -18
- package/dist/lib/wait.d.ts +6 -0
- package/dist/lib/wait.js +17 -0
- package/dist/lib/with-action.d.ts +12 -0
- package/dist/lib/with-action.js +33 -0
- package/dist/program-deps.d.ts +2 -0
- package/dist/program-deps.js +95 -0
- package/dist/program.d.ts +29 -21
- package/dist/program.js +41 -75
- package/package.json +8 -6
- package/CHANGELOG.md +0 -68
- package/dist/commands/extension/install-load.d.ts +0 -7
- package/dist/commands/extension/install-load.js +0 -42
- package/dist/commands/extension/install.d.ts +0 -12
- package/dist/commands/extension/install.js +0 -49
- package/dist/commands/extension/latest.d.ts +0 -2
- package/dist/commands/extension/latest.js +0 -71
- package/dist/commands/extension/remove.d.ts +0 -15
- package/dist/commands/extension/remove.js +0 -86
- package/dist/commands/extension/secrets-prompt.d.ts +0 -6
- package/dist/commands/extension/secrets-prompt.js +0 -47
- package/dist/core/installer/installer.d.ts +0 -28
- package/dist/core/installer/installer.js +0 -87
- package/dist/core/installer/latest.d.ts +0 -27
- package/dist/core/installer/latest.js +0 -90
- package/dist/core/profile/edit.d.ts +0 -4
- package/dist/core/profile/edit.js +0 -27
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { CommanderError } from 'commander';
|
|
2
|
+
import { daemonPort, EADDRINUSE_EXIT } from '../../lib/daemon/daemon-file.js';
|
|
3
|
+
import { getConfigDir } from '../../lib/fs/config.js';
|
|
4
|
+
import { CliError } from '../../lib/json-output.js';
|
|
5
|
+
import { VERSION } from '../../utils/version.js';
|
|
6
|
+
import { KIT_EXIT } from '../extension/kit-commands.js';
|
|
7
|
+
const signalled = () => new Promise((resolve) => {
|
|
8
|
+
process.once('SIGTERM', resolve);
|
|
9
|
+
process.once('SIGINT', resolve);
|
|
10
|
+
});
|
|
11
|
+
// The kit's refusal of a second daemon on one config folder (from the move or from createDaemon).
|
|
12
|
+
const running = (err) => {
|
|
13
|
+
const { code, details } = err;
|
|
14
|
+
if (code !== 'DAEMON_RUNNING')
|
|
15
|
+
throw err;
|
|
16
|
+
const at = `pid ${details?.pid ?? '?'} on 127.0.0.1:${details?.port ?? '?'}`;
|
|
17
|
+
throw new CliError('already_running', `a daemon (${at}) runs on ${getConfigDir()} already`);
|
|
18
|
+
};
|
|
19
|
+
// A busy port exits EADDRINUSE_EXIT, so the cli that spawned this process stops waiting.
|
|
20
|
+
const busy = (err) => {
|
|
21
|
+
if (err.code !== 'EADDRINUSE')
|
|
22
|
+
return running(err);
|
|
23
|
+
console.error(`port ${daemonPort()} is in use`);
|
|
24
|
+
throw new CommanderError(EADDRINUSE_EXIT, KIT_EXIT, 'port in use');
|
|
25
|
+
};
|
|
26
|
+
// The daemon process (hidden `daemon run`): the kit's daemon until SIGTERM, then every child stops.
|
|
27
|
+
export const runDaemon = async (deps) => {
|
|
28
|
+
// Attached first: a stop during the move or the boot is kept and served once the boot ends.
|
|
29
|
+
const stopping = signalled();
|
|
30
|
+
await deps.before?.().catch(running);
|
|
31
|
+
const { createDaemon } = await import('@agentage/extension/host');
|
|
32
|
+
const opts = { configDir: getConfigDir(), port: daemonPort(), version: VERSION };
|
|
33
|
+
const daemon = await createDaemon({ ...opts, install: deps.installer(), startedBy: 'cli' }).catch(busy);
|
|
34
|
+
await stopping;
|
|
35
|
+
await daemon.stop();
|
|
36
|
+
};
|
|
@@ -1,17 +1,26 @@
|
|
|
1
1
|
import { type Command } from 'commander';
|
|
2
2
|
import type { BuildOptions } from '@agentage/extension/tool';
|
|
3
3
|
import { type LoadKitTool } from './kit-tool.js';
|
|
4
|
-
|
|
4
|
+
import { type PackageBuild } from './package-build.js';
|
|
5
|
+
export type ExtensionBuildOptions = Pick<BuildOptions, 'push' | 'dir' | 'registry' | 'container'> & {
|
|
6
|
+
docker?: boolean;
|
|
7
|
+
json?: boolean;
|
|
8
|
+
};
|
|
5
9
|
export type ExtensionCheckOptions = {
|
|
6
10
|
dir?: string;
|
|
7
11
|
json?: boolean;
|
|
8
12
|
write?: boolean;
|
|
9
13
|
};
|
|
10
|
-
export
|
|
11
|
-
export declare const runExtensionCheck: ({ dir, json, write }?: ExtensionCheckOptions, tool?: LoadKitTool, writer?: LoadWriter) => Promise<void>;
|
|
14
|
+
export declare const runExtensionCheck: ({ dir, json, write }?: ExtensionCheckOptions, tool?: LoadKitTool) => Promise<void>;
|
|
12
15
|
export type Committed = (dir: string) => Promise<void>;
|
|
13
16
|
export declare const assertCommitted: Committed;
|
|
14
|
-
export declare const
|
|
17
|
+
export declare const runImageBuild: (opts?: ExtensionBuildOptions, tool?: LoadKitTool, committed?: Committed) => Promise<unknown>;
|
|
18
|
+
export interface BuildFlagDeps {
|
|
19
|
+
tool: LoadKitTool;
|
|
20
|
+
committed: Committed;
|
|
21
|
+
pkg: (dir?: string) => Promise<PackageBuild>;
|
|
22
|
+
}
|
|
23
|
+
export declare const runExtensionBuild: (opts?: ExtensionBuildOptions, deps?: BuildFlagDeps) => Promise<unknown>;
|
|
15
24
|
export interface BuildActions {
|
|
16
25
|
check: (opts: ExtensionCheckOptions) => Promise<void>;
|
|
17
26
|
build: (opts: ExtensionBuildOptions) => Promise<void>;
|
|
@@ -1,21 +1,18 @@
|
|
|
1
1
|
import { execFile } from 'node:child_process';
|
|
2
2
|
import { promisify } from 'node:util';
|
|
3
3
|
import {} from 'commander';
|
|
4
|
+
import { addJson, CliError, omitJson } from '../../lib/json-output.js';
|
|
4
5
|
import { loadKitTool } from './kit-tool.js';
|
|
5
|
-
|
|
6
|
-
const loadWriter = () => import('@agentage/extension/tool');
|
|
6
|
+
import { buildPackage } from './package-build.js';
|
|
7
7
|
// With --json the written paths go to stderr, so stdout stays one JSON document.
|
|
8
|
-
const writeContracts = async (dir,
|
|
9
|
-
const
|
|
10
|
-
if (typeof write !== 'function')
|
|
11
|
-
throw new Error('check --write needs @agentage/extension >= 0.5.1');
|
|
12
|
-
for (const file of await write(dir))
|
|
8
|
+
const writeContracts = async (dir, tool, json) => {
|
|
9
|
+
for (const file of await (await tool()).writeContracts(dir))
|
|
13
10
|
(json ? console.error : console.log)(`wrote ${file}`);
|
|
14
11
|
};
|
|
15
12
|
// The kit's lines, or its report as JSON, on stdout; a package that does not conform exits 1.
|
|
16
|
-
export const runExtensionCheck = async ({ dir = '.', json, write } = {}, tool = loadKitTool
|
|
13
|
+
export const runExtensionCheck = async ({ dir = '.', json, write } = {}, tool = loadKitTool) => {
|
|
17
14
|
if (write)
|
|
18
|
-
await writeContracts(dir,
|
|
15
|
+
await writeContracts(dir, tool, json);
|
|
19
16
|
const { check, checkLines } = await tool();
|
|
20
17
|
const report = await check(dir);
|
|
21
18
|
const lines = checkLines(report);
|
|
@@ -23,31 +20,74 @@ export const runExtensionCheck = async ({ dir = '.', json, write } = {}, tool =
|
|
|
23
20
|
for (const line of json ? [JSON.stringify(report, null, 2)] : lines)
|
|
24
21
|
console.log(line);
|
|
25
22
|
if (!report.conforms)
|
|
26
|
-
throw new
|
|
23
|
+
throw new CliError('not_conforming', fail ?? 'does not conform');
|
|
27
24
|
};
|
|
28
25
|
// The build record names HEAD, so the tree it builds must be HEAD.
|
|
29
26
|
export const assertCommitted = async (dir) => {
|
|
30
|
-
const status = promisify(execFile)('git', ['status', '--porcelain'], {
|
|
27
|
+
const status = promisify(execFile)('git', ['status', '--porcelain'], {
|
|
28
|
+
cwd: dir,
|
|
29
|
+
timeout: 30_000,
|
|
30
|
+
});
|
|
31
31
|
const { stdout } = await status.catch(() => {
|
|
32
32
|
throw new Error(`${dir} is not a git checkout: commit first`);
|
|
33
33
|
});
|
|
34
34
|
if (stdout.trim())
|
|
35
|
-
throw new
|
|
35
|
+
throw new CliError('uncommitted_changes', `${dir} has uncommitted changes: commit first`);
|
|
36
36
|
};
|
|
37
|
-
//
|
|
38
|
-
export const
|
|
37
|
+
// The images of the kit recipe, from a committed tree: --push (the release path) or --container.
|
|
38
|
+
export const runImageBuild = async (opts = {}, tool = loadKitTool, committed = assertCommitted) => {
|
|
39
39
|
await committed(opts.dir ?? '.');
|
|
40
40
|
const { build, buildLines } = await tool();
|
|
41
|
-
|
|
41
|
+
const kit = omitJson(opts);
|
|
42
|
+
delete kit.docker;
|
|
43
|
+
const result = await build(kit);
|
|
44
|
+
for (const line of buildLines(result))
|
|
42
45
|
console.log(line);
|
|
46
|
+
return result;
|
|
47
|
+
};
|
|
48
|
+
const defaultFlagDeps = {
|
|
49
|
+
tool: loadKitTool,
|
|
50
|
+
committed: assertCommitted,
|
|
51
|
+
pkg: (dir) => buildPackage(dir),
|
|
52
|
+
};
|
|
53
|
+
const refusedFlags = (opts) => {
|
|
54
|
+
if (opts.container && opts.docker)
|
|
55
|
+
return '--container and --docker: pick one';
|
|
56
|
+
if (opts.registry && !opts.push && !opts.container && !opts.docker)
|
|
57
|
+
return '--registry names where images go: use it with --docker, --container or --push';
|
|
58
|
+
return '';
|
|
59
|
+
};
|
|
60
|
+
// The package with no Docker: the build script, the contracts, then check; it must conform.
|
|
61
|
+
const packageOnly = async (dir, deps) => {
|
|
62
|
+
const { report, ...done } = await deps.pkg(dir);
|
|
63
|
+
const lines = (await deps.tool()).checkLines(report);
|
|
64
|
+
const fail = report.conforms ? undefined : lines.pop();
|
|
65
|
+
for (const line of lines)
|
|
66
|
+
console.log(line);
|
|
67
|
+
if (!report.conforms)
|
|
68
|
+
throw new CliError('not_conforming', fail ?? 'does not conform');
|
|
69
|
+
return { ...done, conforms: true };
|
|
70
|
+
};
|
|
71
|
+
// No flag: the package. --docker: the part images; --container: one image; --push: pushed, with the record.
|
|
72
|
+
export const runExtensionBuild = async (opts = {}, deps = defaultFlagDeps) => {
|
|
73
|
+
const refused = refusedFlags(opts);
|
|
74
|
+
if (refused)
|
|
75
|
+
throw new CliError('invalid_argument', refused);
|
|
76
|
+
if (!opts.push && !opts.container && !opts.docker)
|
|
77
|
+
return packageOnly(opts.dir, deps);
|
|
78
|
+
return runImageBuild(opts, deps.tool, deps.committed);
|
|
43
79
|
};
|
|
44
80
|
const BUILD_HELP = `
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
81
|
+
With no flag, builds the package in --dir (default: the current folder) with no Docker: its own
|
|
82
|
+
build script, then the contract files the kit writes (such as {id}.mcpc.json), then extension
|
|
83
|
+
check. Any folder state works, committed or not. Exits 1 when a step fails or the package does
|
|
84
|
+
not conform.
|
|
85
|
+
|
|
86
|
+
--container builds one image of the extension, ghcr.io/agentage/<id>:<version>, with the kit's
|
|
87
|
+
recipe (node:26-alpine, the kit host as its command). --docker builds one
|
|
88
|
+
image per server part on this machine. --push builds those, pushes them (run docker login first)
|
|
89
|
+
and writes dist/agentage-extension.json, the build record with every image by digest; with
|
|
90
|
+
--container it pushes the one image. Each needs docker and a committed tree.`;
|
|
51
91
|
export const addBuild = (group, { check, build }) => {
|
|
52
92
|
group
|
|
53
93
|
.command('check')
|
|
@@ -56,12 +96,14 @@ export const addBuild = (group, { check, build }) => {
|
|
|
56
96
|
.option('--json', 'machine-readable report')
|
|
57
97
|
.option('--write', 'write the committed contracts (such as {id}.mcpc.json) first, then check')
|
|
58
98
|
.action((dir, opts) => check({ dir, ...opts }));
|
|
59
|
-
group
|
|
99
|
+
addJson(group
|
|
60
100
|
.command('build')
|
|
61
|
-
.description('Build the
|
|
62
|
-
.option('--
|
|
101
|
+
.description('Build the extension package; --container = one image, all parts')
|
|
102
|
+
.option('--docker', 'one image per server part on this machine (needs docker)')
|
|
103
|
+
.option('--container', 'one image of the extension (needs docker)')
|
|
104
|
+
.option('--push', 'build and push the images, write the build record with their digests')
|
|
63
105
|
.option('--dir <path>', 'the extension package folder (default: the current folder)')
|
|
64
|
-
.option('--registry <host/owner>', 'image registry and owner (default: ghcr.io/agentage)')
|
|
106
|
+
.option('--registry <host/owner>', 'image registry and owner (default: ghcr.io/agentage)'))
|
|
65
107
|
.addHelpText('after', BUILD_HELP)
|
|
66
108
|
.action(build);
|
|
67
109
|
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type ConfirmIo, type LifecycleDeps } from './lifecycle.js';
|
|
2
|
+
export interface ConfigureOptions {
|
|
3
|
+
id: string;
|
|
4
|
+
pairs: string[];
|
|
5
|
+
secret?: boolean;
|
|
6
|
+
json?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface SecretInput extends ConfirmIo {
|
|
9
|
+
readStdin: () => Promise<string>;
|
|
10
|
+
}
|
|
11
|
+
type Tty = Pick<NodeJS.ReadStream, 'on' | 'off' | 'setRawMode' | 'resume' | 'pause'>;
|
|
12
|
+
export declare const readHidden: (question: string, { stdin, stderr }?: {
|
|
13
|
+
stdin: Tty;
|
|
14
|
+
stderr: Pick<NodeJS.WriteStream, "write">;
|
|
15
|
+
}) => Promise<string>;
|
|
16
|
+
export declare const stdinInput: (prompt: SecretInput["prompt"]) => SecretInput;
|
|
17
|
+
export declare const runConfigure: (opts: ConfigureOptions, deps: LifecycleDeps & {
|
|
18
|
+
input: SecretInput;
|
|
19
|
+
}) => Promise<{
|
|
20
|
+
keys: string[];
|
|
21
|
+
id: string;
|
|
22
|
+
version: string;
|
|
23
|
+
state: string;
|
|
24
|
+
error?: string;
|
|
25
|
+
}>;
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { join } from 'node:path';
|
|
2
|
+
import { installationRows } from '../../core/loader/installed.js';
|
|
3
|
+
import { isRecord, readJson } from '../../lib/fs/json-file.js';
|
|
4
|
+
import { CliError, DaemonError, isJsonRun } from '../../lib/json-output.js';
|
|
5
|
+
import { report, specOf } from './lifecycle.js';
|
|
6
|
+
const ENTER = ['\r', '\n', '\u0004'];
|
|
7
|
+
const CTRL_C = '\u0003';
|
|
8
|
+
const BACKSPACE = '\u007f';
|
|
9
|
+
// One keypress: the answer so far, or null once Enter ends it.
|
|
10
|
+
const typed = (answer, char) => {
|
|
11
|
+
if (ENTER.includes(char))
|
|
12
|
+
return null;
|
|
13
|
+
return char === BACKSPACE ? answer.slice(0, -1) : answer + char;
|
|
14
|
+
};
|
|
15
|
+
export const readHidden = (question, { stdin, stderr } = process) => new Promise((resolve) => {
|
|
16
|
+
let answer = '';
|
|
17
|
+
const onData = (chunk) => {
|
|
18
|
+
for (const char of chunk.toString('utf-8')) {
|
|
19
|
+
const next = char === CTRL_C ? null : typed(answer, char);
|
|
20
|
+
if (next === null)
|
|
21
|
+
return finish(char === CTRL_C);
|
|
22
|
+
answer = next;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
const finish = (interrupted) => {
|
|
26
|
+
stdin.off('data', onData).setRawMode(false).pause();
|
|
27
|
+
stderr.write('\n');
|
|
28
|
+
resolve(answer);
|
|
29
|
+
if (interrupted)
|
|
30
|
+
process.kill(process.pid, 'SIGINT');
|
|
31
|
+
};
|
|
32
|
+
stderr.write(question);
|
|
33
|
+
stdin.setRawMode(true).resume().on('data', onData);
|
|
34
|
+
});
|
|
35
|
+
const readAll = async () => {
|
|
36
|
+
let text = '';
|
|
37
|
+
for await (const chunk of process.stdin)
|
|
38
|
+
text += String(chunk);
|
|
39
|
+
return text;
|
|
40
|
+
};
|
|
41
|
+
export const stdinInput = (prompt) => ({
|
|
42
|
+
isTTY: process.stdin.isTTY === true,
|
|
43
|
+
readStdin: readAll,
|
|
44
|
+
prompt,
|
|
45
|
+
});
|
|
46
|
+
const secretValue = async (key, input) => {
|
|
47
|
+
if (!input.isTTY)
|
|
48
|
+
return (await input.readStdin()).replace(/\r?\n$/, '');
|
|
49
|
+
if (isJsonRun())
|
|
50
|
+
throw new CliError('confirmation_required', `${key}: with --json, give the value on stdin`);
|
|
51
|
+
return input.prompt(`${key}: `);
|
|
52
|
+
};
|
|
53
|
+
// `key=value` pairs; with --secret a single bare key reads its value instead.
|
|
54
|
+
const valuesOf = async (opts, input) => {
|
|
55
|
+
const values = {};
|
|
56
|
+
for (const pair of opts.pairs) {
|
|
57
|
+
const at = pair.indexOf('=');
|
|
58
|
+
if (at > 0)
|
|
59
|
+
values[pair.slice(0, at)] = pair.slice(at + 1);
|
|
60
|
+
else if (at < 0 && opts.secret && opts.pairs.length === 1)
|
|
61
|
+
values[pair] = await secretValue(pair, input);
|
|
62
|
+
else
|
|
63
|
+
throw new CliError('invalid_argument', `${pair}: expected <key>=<value>`);
|
|
64
|
+
}
|
|
65
|
+
return values;
|
|
66
|
+
};
|
|
67
|
+
// The keys the installed package declares (null: its folder is not on this disk).
|
|
68
|
+
const declaredOf = (id) => {
|
|
69
|
+
const dir = installationRows().find((row) => row.id === id)?.dir;
|
|
70
|
+
if (!dir)
|
|
71
|
+
return null;
|
|
72
|
+
const agentage = readJson(join(dir, 'package.json'), isRecord)?.['agentage'];
|
|
73
|
+
const settings = isRecord(agentage) ? agentage['settings'] : undefined;
|
|
74
|
+
return Object.keys(isRecord(settings) ? settings : {});
|
|
75
|
+
};
|
|
76
|
+
// The daemon names the key it refused; the answer adds the keys the extension does declare.
|
|
77
|
+
const withDeclared = (id, err) => {
|
|
78
|
+
if (!(err instanceof DaemonError) || !/not declared/.test(err.message))
|
|
79
|
+
return err;
|
|
80
|
+
const keys = declaredOf(id);
|
|
81
|
+
const tail = keys === null
|
|
82
|
+
? 'see agentage.settings in its package.json'
|
|
83
|
+
: keys.length > 0
|
|
84
|
+
? `${id} declares: ${keys.join(', ')}`
|
|
85
|
+
: `${id} declares no settings`;
|
|
86
|
+
return new DaemonError(err.code, `${err.message}; ${tail}`);
|
|
87
|
+
};
|
|
88
|
+
// The daemon starts a new child with the values, then moves the route: no request is lost.
|
|
89
|
+
export const runConfigure = async (opts, deps) => {
|
|
90
|
+
const { id } = specOf(opts.id);
|
|
91
|
+
const values = await valuesOf(opts, deps.input);
|
|
92
|
+
const patch = opts.secret ? { secrets: values } : { settings: values };
|
|
93
|
+
const changed = (await deps.host()).change(id, patch).catch((err) => {
|
|
94
|
+
throw withDeclared(id, err);
|
|
95
|
+
});
|
|
96
|
+
const done = report(await changed);
|
|
97
|
+
const keys = Object.keys(values);
|
|
98
|
+
console.log(`${opts.secret ? 'secrets' : 'settings'} set: ${keys.join(', ')}`);
|
|
99
|
+
return { ...done, keys };
|
|
100
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type HostClient } from '../../lib/daemon/host-client.js';
|
|
2
|
+
import { type LoadKitTool } from './kit-tool.js';
|
|
3
|
+
import { type ConfirmIo } from './lifecycle.js';
|
|
4
|
+
import { type Npm, type PackageBuild } from './package-build.js';
|
|
5
|
+
export interface CreateInstallDeps {
|
|
6
|
+
npm: Npm;
|
|
7
|
+
build: (dir: string) => Promise<PackageBuild>;
|
|
8
|
+
daemon: () => Promise<{
|
|
9
|
+
port: number;
|
|
10
|
+
host: HostClient;
|
|
11
|
+
}>;
|
|
12
|
+
fetch: typeof fetch;
|
|
13
|
+
tool: LoadKitTool;
|
|
14
|
+
}
|
|
15
|
+
export declare const createInstallDeps: CreateInstallDeps;
|
|
16
|
+
export declare const publicPaths: (dir: string) => string[];
|
|
17
|
+
export declare const installCreated: (folder: string, install: boolean, deps?: CreateInstallDeps) => Promise<{
|
|
18
|
+
installed: null;
|
|
19
|
+
url: null;
|
|
20
|
+
} | {
|
|
21
|
+
installed: import("../../lib/daemon/host-client.js").HostSummary;
|
|
22
|
+
url: string | null;
|
|
23
|
+
}>;
|
|
24
|
+
export declare const trustFrom: (from: string, opts: {
|
|
25
|
+
yes?: boolean;
|
|
26
|
+
}, io?: ConfirmIo) => Promise<void>;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
2
|
+
import { join, resolve } from 'node:path';
|
|
3
|
+
import { ensureDaemon } from '../../lib/daemon/daemon-client.js';
|
|
4
|
+
import { daemonOff } from '../../lib/daemon/daemon-file.js';
|
|
5
|
+
import { hostClient } from '../../lib/daemon/host-client.js';
|
|
6
|
+
import { CliError } from '../../lib/json-output.js';
|
|
7
|
+
import { loadKitTool } from './kit-tool.js';
|
|
8
|
+
import { confirmed, report, summaryOf, terminalIo } from './lifecycle.js';
|
|
9
|
+
import { ignoreLocal } from './up-local.js';
|
|
10
|
+
import { buildPackage, npmIn } from './package-build.js';
|
|
11
|
+
export const createInstallDeps = {
|
|
12
|
+
npm: npmIn,
|
|
13
|
+
build: (dir) => buildPackage(dir),
|
|
14
|
+
daemon: async () => {
|
|
15
|
+
const port = await ensureDaemon();
|
|
16
|
+
return { port, host: hostClient(port) };
|
|
17
|
+
},
|
|
18
|
+
fetch: (...args) => fetch(...args),
|
|
19
|
+
tool: loadKitTool,
|
|
20
|
+
};
|
|
21
|
+
// The public GET routes the package's openapi.json names that need no parameter (such as ping).
|
|
22
|
+
export const publicPaths = (dir) => {
|
|
23
|
+
const file = join(dir, 'openapi.json');
|
|
24
|
+
if (!existsSync(file))
|
|
25
|
+
return [];
|
|
26
|
+
const doc = JSON.parse(readFileSync(file, 'utf8'));
|
|
27
|
+
return Object.entries(doc.paths ?? {})
|
|
28
|
+
.filter(([, { get }]) => get && !get.security?.length && !get.parameters?.some((p) => p.required))
|
|
29
|
+
.map(([path]) => path);
|
|
30
|
+
};
|
|
31
|
+
// The first of those that answers 2xx through the daemon.
|
|
32
|
+
const answering = async (deps, port, dir) => {
|
|
33
|
+
for (const path of publicPaths(dir)) {
|
|
34
|
+
const url = `http://127.0.0.1:${port}${path}`;
|
|
35
|
+
const res = await deps.fetch(url, { signal: AbortSignal.timeout(5_000) }).catch(() => null);
|
|
36
|
+
if (res?.ok)
|
|
37
|
+
return url;
|
|
38
|
+
}
|
|
39
|
+
return null;
|
|
40
|
+
};
|
|
41
|
+
// The check's problem lines go to stderr, then the command fails naming the folder.
|
|
42
|
+
const conforms = async (dir, deps) => {
|
|
43
|
+
const { report: checked } = await deps.build(dir);
|
|
44
|
+
if (checked.conforms)
|
|
45
|
+
return;
|
|
46
|
+
for (const text of (await deps.tool()).checkLines(checked))
|
|
47
|
+
console.error(`check ${text}`);
|
|
48
|
+
throw new CliError('not_conforming', `${dir} does not conform: agentage extension check`);
|
|
49
|
+
};
|
|
50
|
+
// After the scaffold: npm ci, the package build, then the daemon runs the folder (POST {source});
|
|
51
|
+
// --no-install leaves the scaffold as it is: no npm, no build.
|
|
52
|
+
export const installCreated = async (folder, install, deps = createInstallDeps) => {
|
|
53
|
+
if (!install)
|
|
54
|
+
return { installed: null, url: null };
|
|
55
|
+
const dir = resolve(folder);
|
|
56
|
+
await deps.npm(dir, ['ci', '--ignore-scripts', '--no-audit', '--no-fund']);
|
|
57
|
+
await conforms(dir, deps);
|
|
58
|
+
ignoreLocal(dir);
|
|
59
|
+
if (daemonOff()) {
|
|
60
|
+
console.log(' install the daemon is off (AGENTAGE_NO_DAEMON=1): not installed');
|
|
61
|
+
return { installed: null, url: null };
|
|
62
|
+
}
|
|
63
|
+
const { port, host } = await deps.daemon();
|
|
64
|
+
const installed = summaryOf(report(await host.add({ source: dir })));
|
|
65
|
+
const url = await answering(deps, port, dir);
|
|
66
|
+
console.log(url ? ` url ${url}` : ' url none answers yet: agentage extension list');
|
|
67
|
+
return { installed, url };
|
|
68
|
+
};
|
|
69
|
+
const OWN_TEMPLATE = 'agentage/extension-template';
|
|
70
|
+
// Another repo, or a branch of ours, is code nobody reviewed for you: its build script runs here.
|
|
71
|
+
export const trustFrom = async (from, opts, io = terminalIo()) => {
|
|
72
|
+
if (from === OWN_TEMPLATE)
|
|
73
|
+
return;
|
|
74
|
+
console.error(`template ${from}: code from that repo will be built and run on this machine`);
|
|
75
|
+
if (opts.yes)
|
|
76
|
+
return;
|
|
77
|
+
if (!io.isTTY)
|
|
78
|
+
throw new CliError('invalid_argument', `--from ${from} with no terminal: pass --yes to run it`);
|
|
79
|
+
if (!(await confirmed(io, 'run it? (y/N) ')))
|
|
80
|
+
throw new CliError('cancelled', `--from ${from}: not confirmed, nothing created`);
|
|
81
|
+
};
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import { type Command } from 'commander';
|
|
2
|
+
import { installCreated } from './create-install.js';
|
|
3
|
+
import { type ConfirmIo } from './lifecycle.js';
|
|
2
4
|
export declare const TEMPLATE = "agentage/extension-template";
|
|
3
5
|
export declare const PARTS: string[];
|
|
4
6
|
export interface ExtensionCreateOptions {
|
|
5
7
|
id: string;
|
|
6
8
|
parts: string[];
|
|
7
9
|
from?: string;
|
|
10
|
+
install?: boolean;
|
|
11
|
+
yes?: boolean;
|
|
12
|
+
json?: boolean;
|
|
8
13
|
}
|
|
9
|
-
export declare const runExtensionCreate: (opts: ExtensionCreateOptions, url?: (from: string) => string) => Promise<
|
|
14
|
+
export declare const runExtensionCreate: (opts: ExtensionCreateOptions, url?: (from: string) => string, after?: typeof installCreated, io?: ConfirmIo) => Promise<unknown>;
|
|
10
15
|
export declare const addCreate: (group: Command, create: (o: ExtensionCreateOptions) => Promise<void>) => Command;
|
|
@@ -3,6 +3,9 @@ import { existsSync, readdirSync, readFileSync, renameSync, rmSync, writeFileSyn
|
|
|
3
3
|
import { join } from 'node:path';
|
|
4
4
|
import { promisify } from 'node:util';
|
|
5
5
|
import {} from 'commander';
|
|
6
|
+
import { addJson, CliError } from '../../lib/json-output.js';
|
|
7
|
+
import { installCreated, trustFrom } from './create-install.js';
|
|
8
|
+
import { terminalIo } from './lifecycle.js';
|
|
6
9
|
const run = promisify(execFile);
|
|
7
10
|
export const TEMPLATE = 'agentage/extension-template';
|
|
8
11
|
export const PARTS = ['pages', 'ui', 'api', 'mcp', 'worker', 'store', 'cli'];
|
|
@@ -10,6 +13,8 @@ const ROUTED = ['pages', 'ui', 'api', 'mcp'];
|
|
|
10
13
|
// `_` is a separator here, so `template__echo` is the id too.
|
|
11
14
|
const WORD = /(?<![A-Za-z0-9])template(?![A-Za-z0-9])/g;
|
|
12
15
|
const LOCK = 'package-lock.json';
|
|
16
|
+
// owner/repo, optionally #branch: a git ref that cannot pass for a flag or leave the repo.
|
|
17
|
+
const FROM = /^[\w.-]+\/[\w.-]+(?:#\w[\w./-]*)?$/;
|
|
13
18
|
// What else goes with a dropped part: manifest keys the kit refuses without it, the store's SQL, the contract file of api and mcp.
|
|
14
19
|
const PRUNE = {
|
|
15
20
|
cli: { keys: [['agentage', 'commands']] },
|
|
@@ -27,8 +32,8 @@ const refusal = ({ id, parts, from = TEMPLATE }, kept) => {
|
|
|
27
32
|
return `id ${id} is a part name: pick another id`;
|
|
28
33
|
if (!kept.some((part) => ROUTED.includes(part)))
|
|
29
34
|
return `an extension needs at least one of ${ROUTED.join(', ')}`;
|
|
30
|
-
if (
|
|
31
|
-
return `--from ${from}: owner/repo`;
|
|
35
|
+
if (!FROM.test(from) || from.includes('..'))
|
|
36
|
+
return `--from ${from}: owner/repo or owner/repo#branch`;
|
|
32
37
|
return existsSync(`extension-${id}`)
|
|
33
38
|
? `extension-${id} exists: pick another id or remove it`
|
|
34
39
|
: '';
|
|
@@ -76,10 +81,20 @@ const renameLock = (dir, id) => {
|
|
|
76
81
|
Object.assign(at, { name });
|
|
77
82
|
save(join(dir, LOCK), lock);
|
|
78
83
|
};
|
|
84
|
+
// --from owner/repo[#branch], checked by refusal() first.
|
|
85
|
+
const repoRef = (from) => {
|
|
86
|
+
const [repo = from, ref] = from.split('#');
|
|
87
|
+
return { repo, ...(ref && { ref }) };
|
|
88
|
+
};
|
|
79
89
|
// Bounded, a partial folder removed; git's own first line says why (no repo, no network, no access).
|
|
80
90
|
const clone = async (url, from, dir) => {
|
|
91
|
+
const { ref } = repoRef(from);
|
|
92
|
+
const branch = ref ? ['--branch', ref] : [];
|
|
81
93
|
const env = { ...process.env, GIT_TERMINAL_PROMPT: '0' };
|
|
82
|
-
await run('git', ['clone', '-q', '--depth', '1', url, dir], {
|
|
94
|
+
await run('git', ['clone', '-q', '--depth', '1', ...branch, url, dir], {
|
|
95
|
+
env,
|
|
96
|
+
timeout: 120_000,
|
|
97
|
+
}).catch((err) => {
|
|
83
98
|
rmSync(dir, { recursive: true, force: true });
|
|
84
99
|
const why = (err.stderr?.trim() || err.message).split('\n')[0];
|
|
85
100
|
throw new Error(`cannot clone template ${from}: ${why}`);
|
|
@@ -116,29 +131,35 @@ const shape = (dir, from, id, kept) => {
|
|
|
116
131
|
};
|
|
117
132
|
const printNext = (dir, from, id, kept) => {
|
|
118
133
|
const kit = String(json(join(dir, 'package.json'))['dependencies']?.['@agentage/extension'] ?? '?');
|
|
119
|
-
|
|
134
|
+
const { repo, ref } = repoRef(from);
|
|
135
|
+
const branch = ref ? `branch ${ref}` : 'default branch';
|
|
136
|
+
console.log(` template ${repo} (${branch}, kit ${kit.replace(/^[\^~]/, '')})`);
|
|
120
137
|
console.log(` kept ${kept.join(', ')}`);
|
|
121
138
|
console.log(` id ${id} · host ${id}.next.agentage.io · contract ${id}.mcpc.json`);
|
|
122
|
-
console.log(` next cd ${dir} &&
|
|
139
|
+
console.log(` next cd ${dir} && agentage extension up`);
|
|
123
140
|
};
|
|
124
|
-
// Clones the template's default branch into ./extension-<id> as a new working copy, no history
|
|
125
|
-
|
|
141
|
+
// Clones the template's default branch (or the #branch of --from) into ./extension-<id> as a new working copy, no history;
|
|
142
|
+
// then installs its dependencies, builds it and (unless --no-install) gives it to the daemon.
|
|
143
|
+
export const runExtensionCreate = async (opts, url = (from) => `https://github.com/${from}`, after = installCreated, io = terminalIo()) => {
|
|
126
144
|
const { id, from = TEMPLATE } = opts;
|
|
127
145
|
const kept = opts.parts.length > 0 ? [...new Set(opts.parts)] : PARTS;
|
|
128
146
|
const refused = refusal(opts, kept);
|
|
129
147
|
if (refused)
|
|
130
|
-
throw new
|
|
148
|
+
throw new CliError('invalid_argument', refused);
|
|
149
|
+
await trustFrom(from, opts, opts.json ? { ...io, isTTY: false } : io);
|
|
131
150
|
const dir = `extension-${id}`;
|
|
132
|
-
await clone(url(from), from, dir);
|
|
151
|
+
await clone(url(repoRef(from).repo), from, dir);
|
|
133
152
|
const ci = shape(dir, from, id, kept);
|
|
134
153
|
printNext(dir, from, id, kept);
|
|
135
154
|
if (ci)
|
|
136
155
|
console.log(ci);
|
|
156
|
+
return { id, dir, from, kept, ...(await after(dir, opts.install !== false)) };
|
|
137
157
|
};
|
|
138
|
-
export const addCreate = (group, create) => group
|
|
158
|
+
export const addCreate = (group, create) => addJson(group
|
|
139
159
|
.command('create')
|
|
140
160
|
.description('Create ./extension-<id> from the extension template with the parts named')
|
|
141
161
|
.argument('<id>', 'the extension id, also its host and contract name')
|
|
142
162
|
.argument('[parts...]', `parts to keep (default: all seven): ${PARTS.join(', ')}`)
|
|
143
|
-
.option('--from <owner/repo>', `the template repo (default: ${TEMPLATE})`)
|
|
144
|
-
.
|
|
163
|
+
.option('--from <owner/repo[#branch]>', `the template repo (default: ${TEMPLATE})`)
|
|
164
|
+
.option('--no-install', 'build the folder, but do not give it to the daemon')
|
|
165
|
+
.option('--yes', 'run code from another --from repo or branch without asking')).action((id, parts, o) => create({ id, parts, ...o }));
|
|
@@ -2,6 +2,7 @@ import {} from 'commander';
|
|
|
2
2
|
import {} from '../../core/loader/discover.js';
|
|
3
3
|
import { loadExtensions } from '../../core/loader/load.js';
|
|
4
4
|
import { loadOrder } from '../../core/loader/order.js';
|
|
5
|
+
import { installedExtensions } from '../../core/loader/installed.js';
|
|
5
6
|
import { loadSet, scan } from '../../core/loader/scan.js';
|
|
6
7
|
import { claimVerbs, commandNames, readHeld } from '../../core/loader/verbs.js';
|
|
7
8
|
import { NO_MACHINE, readMachine } from '../../core/profile/machine.js';
|
|
@@ -37,7 +38,8 @@ const registerApi = (program, ext, run) => {
|
|
|
37
38
|
// Manifests only, never code: each stub hands the command line, --help included, to the extension.
|
|
38
39
|
export const registerDelegates = (program, argv, wrap, tool = loadKitTool) => {
|
|
39
40
|
const core = program.commands.map((command) => command.name());
|
|
40
|
-
|
|
41
|
+
// The daemon's installation once it exists; before the one-time move, the old lists.
|
|
42
|
+
const extensions = installedExtensions() ?? loadSet(scan(readMachine() ?? NO_MACHINE));
|
|
41
43
|
const verbs = claimVerbs(extensions, readHeld());
|
|
42
44
|
for (const ext of extensions) {
|
|
43
45
|
if (ext.kind === 'kit')
|
|
@@ -5,7 +5,7 @@ export interface ExtensionDoctorOptions {
|
|
|
5
5
|
json?: boolean;
|
|
6
6
|
}
|
|
7
7
|
type BeforeLoad = (extensions: DiscoveredExtension[]) => Promise<void>;
|
|
8
|
-
export declare const loadAndGather: (beforeLoad?: BeforeLoad,
|
|
8
|
+
export declare const loadAndGather: (beforeLoad?: BeforeLoad, tool?: LoadKitTool) => Promise<ExtensionsGather>;
|
|
9
9
|
export declare const failedError: (rows: ExtensionRow[]) => Error | null;
|
|
10
10
|
export declare const runExtensionDoctor: (opts?: ExtensionDoctorOptions, tool?: LoadKitTool) => Promise<void>;
|
|
11
11
|
export {};
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
+
import { CliError } from '../../lib/json-output.js';
|
|
1
2
|
import { driftLines } from '../../core/installer/plan.js';
|
|
2
3
|
import {} from '../../core/loader/discover.js';
|
|
3
4
|
import { loadExtensions } from '../../core/loader/load.js';
|
|
4
|
-
import { loadSet,
|
|
5
|
+
import { loadSet, scanNow } from '../../core/loader/scan.js';
|
|
5
6
|
import { loadMachine } from '../../core/profile/machine.js';
|
|
6
7
|
import { kitCheck } from './kit-tool.js';
|
|
7
8
|
import { printReport } from './list.js';
|
|
8
9
|
import { gatherFrom, invalidProfileError, } from './rows.js';
|
|
9
|
-
// Loads what can load once
|
|
10
|
-
export const loadAndGather = async (beforeLoad = async () => undefined,
|
|
11
|
-
const found =
|
|
10
|
+
// Loads what can load once, for the report only; the kit checks kit-shaped ones.
|
|
11
|
+
export const loadAndGather = async (beforeLoad = async () => undefined, tool) => {
|
|
12
|
+
const found = scanNow(await loadMachine());
|
|
12
13
|
const extensions = loadSet(found);
|
|
13
14
|
await beforeLoad(extensions);
|
|
14
15
|
const session = await loadExtensions(extensions, undefined, kitCheck(tool));
|
|
@@ -20,13 +21,13 @@ export const failedError = (rows) => {
|
|
|
20
21
|
if (failed.length === 0)
|
|
21
22
|
return null;
|
|
22
23
|
const count = `${failed.length} extension${failed.length === 1 ? '' : 's'}`;
|
|
23
|
-
return new
|
|
24
|
+
return new CliError('extension_failed', `${count} failed to load: ${failed.join(', ')}`);
|
|
24
25
|
};
|
|
25
26
|
// Integrity drift: the extensions it names were not loaded, and setup refuses to build on it.
|
|
26
|
-
const driftError = (drift) => drift.length === 0 ? null : new
|
|
27
|
+
const driftError = (drift) => drift.length === 0 ? null : new CliError('integrity_drift', driftLines(drift).join('\n'));
|
|
27
28
|
// The rows always print; an invalid profile.json, integrity drift or a failed load fails the step.
|
|
28
29
|
export const runExtensionDoctor = async (opts = {}, tool) => {
|
|
29
|
-
const gathered = await loadAndGather(undefined,
|
|
30
|
+
const gathered = await loadAndGather(undefined, tool);
|
|
30
31
|
printReport(gathered, opts.json);
|
|
31
32
|
const { profile, extensions } = gathered.status;
|
|
32
33
|
const failure = invalidProfileError(profile) ?? driftError(gathered.drift) ?? failedError(extensions);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type HostClient, type HostRow, type HostSummary } from '../../lib/daemon/host-client.js';
|
|
2
|
+
export interface IdBody {
|
|
3
|
+
id: string;
|
|
4
|
+
version?: string;
|
|
5
|
+
enabled?: false;
|
|
6
|
+
}
|
|
7
|
+
export type AddBody = IdBody | {
|
|
8
|
+
source: string;
|
|
9
|
+
enabled?: false;
|
|
10
|
+
};
|
|
11
|
+
export interface Installed {
|
|
12
|
+
row: HostSummary | HostRow;
|
|
13
|
+
already: boolean;
|
|
14
|
+
}
|
|
15
|
+
export declare const addOnce: (host: HostClient, spec: IdBody) => Promise<Installed>;
|
|
16
|
+
export declare const installId: (host: HostClient, spec: IdBody) => Promise<Installed>;
|
|
17
|
+
export declare const installFolder: (host: HostClient, source: string) => Promise<Installed>;
|