buildhive-agent 1.0.0-beta.12 → 1.0.0-beta.13
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/dist/cacheServer/index.d.ts +1 -1
- package/dist/cli-handlers.d.ts +233 -0
- package/dist/cli-handlers.js +542 -0
- package/dist/cli.js +30 -421
- package/dist/index.d.ts +0 -2
- package/dist/index.js +5 -2
- package/dist/registration/apiClient.d.ts +10 -33
- package/dist/registration/apiClient.js +10 -99
- package/dist/runner/startCommand.js +235 -128
- package/dist/runner/supervisor.d.ts +8 -0
- package/dist/runner/supervisor.js +8 -4
- package/package.json +3 -2
- package/dist/auth/loginCommand.d.ts +0 -24
- package/dist/auth/loginCommand.js +0 -62
- package/dist/auth/logoutCommand.d.ts +0 -16
- package/dist/auth/logoutCommand.js +0 -22
- package/dist/auth/whoamiCommand.d.ts +0 -14
- package/dist/auth/whoamiCommand.js +0 -28
- package/dist/registration/index.d.ts +0 -47
- package/dist/registration/index.js +0 -143
- package/dist/registration/types.d.ts +0 -43
- package/dist/registration/types.js +0 -8
- package/dist/runner/cacheStatsReporter.d.ts +0 -46
- package/dist/runner/cacheStatsReporter.js +0 -92
- package/dist/types.d.ts +0 -48
- package/dist/types.js +0 -6
- package/dist/utils/capabilities.d.ts +0 -22
- package/dist/utils/capabilities.js +0 -199
- package/dist/utils/sdkScanner.d.ts +0 -104
- package/dist/utils/sdkScanner.js +0 -458
|
@@ -33,7 +33,7 @@ export interface CacheServerOptions {
|
|
|
33
33
|
}
|
|
34
34
|
/**
|
|
35
35
|
* Hit/miss/bytes snapshot of the cache server's runtime counters.
|
|
36
|
-
* Row 18b Wave 3 / S6 —
|
|
36
|
+
* Row 18b Wave 3 / S6 — exposed via the cache server's getStats().
|
|
37
37
|
*/
|
|
38
38
|
export interface CacheServerStats {
|
|
39
39
|
/** Number of GET /cache requests that returned 200 (cache hit). */
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* cli-handlers — the bodies of every `buildhive-agent <cmd>` action.
|
|
3
|
+
*
|
|
4
|
+
* 2026-06-10 (agent-coverage refinement 2B): hoisted out of the inline
|
|
5
|
+
* `.action(async …)` closures in cli.ts so the dispatch layer is testable
|
|
6
|
+
* in-process. cli.ts keeps the commander wiring + entrypoint guard and calls
|
|
7
|
+
* these handlers with production defaults; tests inject fakes through each
|
|
8
|
+
* handler's `deps` parameter and an `exit` that throws `CliExit` instead of
|
|
9
|
+
* terminating the runner.
|
|
10
|
+
*
|
|
11
|
+
* Behavior contract: every user-facing string, exit code, and side-effect
|
|
12
|
+
* order is preserved verbatim from the pre-refactor cli.ts (the dist-spawn
|
|
13
|
+
* suites cli-routing/cli-flags-published pin several of them).
|
|
14
|
+
*/
|
|
15
|
+
import { spawn as spawnDefault } from 'child_process';
|
|
16
|
+
import { loadConfig as loadConfigDefault } from './config/index.js';
|
|
17
|
+
/**
|
|
18
|
+
* Canonical config path. The loader (`config/loader.ts`) probes
|
|
19
|
+
* `buildhive-agent.json` first, so this MUST match. Two filenames historically
|
|
20
|
+
* existed (`config.json` from `init`, `buildhive-agent.json` from `register`)
|
|
21
|
+
* — unified onto one (Sprint B B4).
|
|
22
|
+
*/
|
|
23
|
+
export declare const CONFIG_PATH: string;
|
|
24
|
+
/**
|
|
25
|
+
* Thrown by a test-injected `exit` in place of `process.exit`. Production
|
|
26
|
+
* never constructs this (the default exit terminates the process), but the
|
|
27
|
+
* outer catch blocks below re-throw it so a test's exit signal is never
|
|
28
|
+
* swallowed into the generic error→exit(1) path.
|
|
29
|
+
*/
|
|
30
|
+
export declare class CliExit extends Error {
|
|
31
|
+
readonly code: number;
|
|
32
|
+
constructor(code: number);
|
|
33
|
+
}
|
|
34
|
+
/** Output/exit seams shared by every handler. Defaults are the real console/process. */
|
|
35
|
+
export interface CmdIo {
|
|
36
|
+
readonly out?: (...args: unknown[]) => void;
|
|
37
|
+
readonly warnOut?: (...args: unknown[]) => void;
|
|
38
|
+
readonly errOut?: (...args: unknown[]) => void;
|
|
39
|
+
readonly exit?: (code: number) => never;
|
|
40
|
+
}
|
|
41
|
+
/** Subset of fs.promises the handlers touch — injectable for tests. */
|
|
42
|
+
export interface FsLike {
|
|
43
|
+
readonly access: (path: string) => Promise<void>;
|
|
44
|
+
readonly readFile: (path: string, encoding: 'utf-8' | 'utf8') => Promise<string>;
|
|
45
|
+
readonly unlink: (path: string) => Promise<void>;
|
|
46
|
+
}
|
|
47
|
+
/** `init` — STUB during Phase 10 pivot (row 17a). Exit 2 = intentionally not implemented. */
|
|
48
|
+
export declare function runInitCmd(deps?: CmdIo): Promise<void>;
|
|
49
|
+
/**
|
|
50
|
+
* Commander option parser for `--jobs <n>`. Exported so the boundary rules
|
|
51
|
+
* (positive integer, ≤64 cap — each slot is a ~200MB runner-dir copy) are
|
|
52
|
+
* unit-testable without spawning the binary.
|
|
53
|
+
*/
|
|
54
|
+
export declare function parseJobsOption(v: string): number;
|
|
55
|
+
export interface StartCmdOpts {
|
|
56
|
+
readonly config?: string;
|
|
57
|
+
readonly owner?: string;
|
|
58
|
+
readonly repo?: string;
|
|
59
|
+
readonly jobs?: number;
|
|
60
|
+
}
|
|
61
|
+
export interface StartCmdDeps extends CmdIo {
|
|
62
|
+
readonly runStartFn?: (opts: {
|
|
63
|
+
owner?: string;
|
|
64
|
+
repo?: string;
|
|
65
|
+
maxConcurrentJobs?: number;
|
|
66
|
+
}) => Promise<{
|
|
67
|
+
exitCode: number;
|
|
68
|
+
}>;
|
|
69
|
+
}
|
|
70
|
+
/** `start` — launches the runner supervisor (row 17b). */
|
|
71
|
+
export declare function runStartCmd(opts: StartCmdOpts, deps?: StartCmdDeps): Promise<void>;
|
|
72
|
+
export interface StopCmdDeps extends CmdIo {
|
|
73
|
+
readonly fsImpl?: FsLike;
|
|
74
|
+
readonly killFn?: (pid: number, signal: NodeJS.Signals | 0) => void;
|
|
75
|
+
readonly sleepFn?: (ms: number) => Promise<void>;
|
|
76
|
+
readonly pidFile?: string;
|
|
77
|
+
}
|
|
78
|
+
/** `stop` — SIGTERM the daemon by PID file, poll ≤15s, SIGKILL fallback. */
|
|
79
|
+
export declare function runStopCmd(deps?: StopCmdDeps): Promise<void>;
|
|
80
|
+
export interface StatusCmdDeps extends CmdIo {
|
|
81
|
+
readonly loadConfigFn?: typeof loadConfigDefault;
|
|
82
|
+
readonly fsImpl?: FsLike;
|
|
83
|
+
readonly killFn?: (pid: number, signal: NodeJS.Signals | 0) => void;
|
|
84
|
+
readonly pidFile?: string;
|
|
85
|
+
}
|
|
86
|
+
/** `status` — print config summary + running/PID state. */
|
|
87
|
+
export declare function runStatusCmd(deps?: StatusCmdDeps): Promise<void>;
|
|
88
|
+
export interface ConfigCmdDeps extends CmdIo {
|
|
89
|
+
readonly fsImpl?: FsLike;
|
|
90
|
+
readonly defaultConfigPath?: string;
|
|
91
|
+
}
|
|
92
|
+
/** `config` — print the config file with the apiKey masked to its last 4 chars. */
|
|
93
|
+
export declare function runConfigCmd(opts: {
|
|
94
|
+
config?: string;
|
|
95
|
+
}, deps?: ConfigCmdDeps): Promise<void>;
|
|
96
|
+
export interface TestCmdDeps extends CmdIo {
|
|
97
|
+
readonly loadConfigFn?: typeof loadConfigDefault;
|
|
98
|
+
/** Factory for the connectivity probe — default lazy-imports BuildHiveApiClient. */
|
|
99
|
+
readonly makeApiClient?: (platformUrl: string) => Promise<{
|
|
100
|
+
testConnection(): Promise<boolean>;
|
|
101
|
+
}>;
|
|
102
|
+
}
|
|
103
|
+
/** `test` — connectivity probe against the platform /health endpoint. */
|
|
104
|
+
export declare function runTestCmd(deps?: TestCmdDeps): Promise<void>;
|
|
105
|
+
export interface LogsCmdDeps extends CmdIo {
|
|
106
|
+
readonly fsImpl?: FsLike;
|
|
107
|
+
readonly spawnFn?: typeof spawnDefault;
|
|
108
|
+
readonly logFile?: string;
|
|
109
|
+
/** Seam for the follow-mode Ctrl+C hook (default registers on process). */
|
|
110
|
+
readonly registerSigint?: (handler: () => void) => void;
|
|
111
|
+
}
|
|
112
|
+
/** `logs` — print the last N lines, or `tail -f` in follow mode. */
|
|
113
|
+
export declare function runLogsCmd(opts: {
|
|
114
|
+
follow?: boolean;
|
|
115
|
+
lines: string;
|
|
116
|
+
}, deps?: LogsCmdDeps): Promise<void>;
|
|
117
|
+
export interface DoctorCmdDeps extends CmdIo {
|
|
118
|
+
readonly runDoctorFn?: () => Promise<{
|
|
119
|
+
exitCode: number;
|
|
120
|
+
}>;
|
|
121
|
+
}
|
|
122
|
+
/** `doctor` — diagnostic checks; implementation lives in ./doctor/. */
|
|
123
|
+
export declare function runDoctorCmd(deps?: DoctorCmdDeps): Promise<void>;
|
|
124
|
+
export interface ServiceInstallCmdDeps extends CmdIo {
|
|
125
|
+
readonly installServiceFn?: (opts: {
|
|
126
|
+
mode: 'system' | 'user';
|
|
127
|
+
cliEntryPath: string;
|
|
128
|
+
}) => Promise<{
|
|
129
|
+
paths: {
|
|
130
|
+
plistPath: string;
|
|
131
|
+
workingDirectory: string;
|
|
132
|
+
logDir: string;
|
|
133
|
+
};
|
|
134
|
+
bootstrapStdout: string;
|
|
135
|
+
}>;
|
|
136
|
+
readonly resolveCliEntry?: () => string;
|
|
137
|
+
}
|
|
138
|
+
/** `service:install` — LaunchAgent default; `--system` LaunchDaemon opt-in. */
|
|
139
|
+
export declare function runServiceInstallCmd(opts: {
|
|
140
|
+
system?: boolean;
|
|
141
|
+
cliEntry?: string;
|
|
142
|
+
}, deps?: ServiceInstallCmdDeps): Promise<void>;
|
|
143
|
+
export interface ServiceUninstallCmdDeps extends CmdIo {
|
|
144
|
+
readonly uninstallServiceFn?: (opts: {
|
|
145
|
+
mode: 'system' | 'user';
|
|
146
|
+
}) => Promise<void>;
|
|
147
|
+
}
|
|
148
|
+
/** `service:uninstall` — idempotent (missing service is not an error). */
|
|
149
|
+
export declare function runServiceUninstallCmd(opts: {
|
|
150
|
+
system?: boolean;
|
|
151
|
+
}, deps?: ServiceUninstallCmdDeps): Promise<void>;
|
|
152
|
+
export interface ServiceStatusCmdDeps extends CmdIo {
|
|
153
|
+
readonly getServiceStatusFn?: (opts: {
|
|
154
|
+
mode: 'system' | 'user';
|
|
155
|
+
}) => Promise<{
|
|
156
|
+
plistFilePresent: boolean;
|
|
157
|
+
loaded: boolean;
|
|
158
|
+
state: string | null;
|
|
159
|
+
lastExitReason: string | null;
|
|
160
|
+
paths: {
|
|
161
|
+
plistPath: string;
|
|
162
|
+
};
|
|
163
|
+
}>;
|
|
164
|
+
}
|
|
165
|
+
/** `service:status` — exit 0 when loaded, 1 otherwise. */
|
|
166
|
+
export declare function runServiceStatusCmd(opts: {
|
|
167
|
+
system?: boolean;
|
|
168
|
+
}, deps?: ServiceStatusCmdDeps): Promise<void>;
|
|
169
|
+
export interface ServiceMigrateCmdDeps extends CmdIo {
|
|
170
|
+
readonly detectLegacyInstallFn?: () => Promise<{
|
|
171
|
+
hasAnyToClean: boolean;
|
|
172
|
+
hasAnyLegacy: boolean;
|
|
173
|
+
macOSLaunchDaemon: {
|
|
174
|
+
plistPresent: boolean;
|
|
175
|
+
installDirPresent: boolean;
|
|
176
|
+
logDirPresent: boolean;
|
|
177
|
+
};
|
|
178
|
+
userScopeState: {
|
|
179
|
+
envFilePresent: boolean;
|
|
180
|
+
};
|
|
181
|
+
ephemeral: {
|
|
182
|
+
tmpDirPresent: boolean;
|
|
183
|
+
};
|
|
184
|
+
linux: {
|
|
185
|
+
systemdUnitPresent: boolean;
|
|
186
|
+
configDirPresent: boolean;
|
|
187
|
+
};
|
|
188
|
+
}>;
|
|
189
|
+
readonly migrateToLaunchAgentFn?: (opts: {
|
|
190
|
+
cliEntryPath: string;
|
|
191
|
+
targetMode: 'system' | 'user';
|
|
192
|
+
sudoPasswordPrompt: () => Promise<string>;
|
|
193
|
+
}) => Promise<{
|
|
194
|
+
cleaned: {
|
|
195
|
+
launchDaemonBootout: boolean;
|
|
196
|
+
plistRemoved: boolean;
|
|
197
|
+
installDirRemoved: boolean;
|
|
198
|
+
envFileRemoved: boolean;
|
|
199
|
+
tmpDirRemoved: boolean;
|
|
200
|
+
systemdUnitRemoved: boolean;
|
|
201
|
+
};
|
|
202
|
+
installed: boolean;
|
|
203
|
+
newPlistPath: string | null;
|
|
204
|
+
skipped: ReadonlyArray<{
|
|
205
|
+
path: string;
|
|
206
|
+
reason: string;
|
|
207
|
+
}>;
|
|
208
|
+
}>;
|
|
209
|
+
readonly resolveCliEntry?: () => string;
|
|
210
|
+
readonly sudoPasswordPromptFn?: () => Promise<string>;
|
|
211
|
+
}
|
|
212
|
+
/** `service:migrate` — legacy LaunchDaemon → LaunchAgent (AGT-G2). */
|
|
213
|
+
export declare function runServiceMigrateCmd(opts: {
|
|
214
|
+
system?: boolean;
|
|
215
|
+
dryRun?: boolean;
|
|
216
|
+
cliEntry?: string;
|
|
217
|
+
}, deps?: ServiceMigrateCmdDeps): Promise<void>;
|
|
218
|
+
export interface JoinCmdDeps extends CmdIo {
|
|
219
|
+
readonly loadConfigFn?: typeof loadConfigDefault;
|
|
220
|
+
readonly runJoinFn?: (opts: {
|
|
221
|
+
token: string;
|
|
222
|
+
platformUrl: string;
|
|
223
|
+
}) => Promise<{
|
|
224
|
+
exitCode: number;
|
|
225
|
+
}>;
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* `join <token>` — row 17c zero-GH enrollment. platformUrl precedence:
|
|
229
|
+
* --url flag > config.platformUrl > https://api.buildhive.app.
|
|
230
|
+
*/
|
|
231
|
+
export declare function runJoinCmd(token: string, opts: {
|
|
232
|
+
url?: string;
|
|
233
|
+
}, deps?: JoinCmdDeps): Promise<void>;
|