@bakers-build/conductor 0.7.1-next.2 → 0.7.1-next.4
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.
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { spawnSync } from 'node:child_process';
|
|
2
2
|
import { basename, dirname, join, resolve } from 'node:path';
|
|
3
3
|
import { createInterface } from 'node:readline';
|
|
4
|
-
import { CommandRunner, checkForUpdate, configHomeOf, createBbConnectionClient, createLogger, declineUpdate, defaultProcProbe, deriveCheckoutRoot, deriveConductorLiveness, homeBbDir, loadReadyBbConnection, printVersionLine, resolveConfigPath, setDefaultCommandRunner, signalVerifiedProcess, stemForConfigFile, updateNotice, verifyConductorProcess, } from '@bakers-build/core';
|
|
4
|
+
import { CommandRunner, checkForUpdate, configHomeOf, createBbConnectionClient, createLogger, declineUpdate, defaultProcProbe, deriveCheckoutRoot, deriveConductorLiveness, homeBbDir, loadReadyBbConnection, printVersionLine, readMachineContext, resolveConfigPath, setDefaultCommandRunner, signalVerifiedProcess, stemForConfigFile, updateNotice, verifyConductorProcess, } from '@bakers-build/core';
|
|
5
5
|
import { Command } from 'commander';
|
|
6
6
|
import { authStatus } from 'dropsh';
|
|
7
7
|
import { resolveBbProjectContext } from '../bakers-project-context.js';
|
|
@@ -193,7 +193,7 @@ async function cmdPoll(deps, log = {}) {
|
|
|
193
193
|
const executor = deps.executor ?? (await selectExecutor(config, logger));
|
|
194
194
|
const workspace = deps.workspace ?? (await selectWorkspace(config, logger));
|
|
195
195
|
const agents = deps.agents ?? (await selectAgents(config));
|
|
196
|
-
const conductor = new Conductor(config, remote, executor, workspace, agents, logger, checkoutRoot, frozenStateFileOf(config));
|
|
196
|
+
const conductor = new Conductor(config, remote, executor, workspace, agents, logger, checkoutRoot, frozenStateFileOf(config), undefined, readMachineContext);
|
|
197
197
|
await conductor.start();
|
|
198
198
|
await conductor.tick();
|
|
199
199
|
}
|
|
@@ -305,7 +305,7 @@ async function cmdStartForeground(deps, log = {}, force = false, choice = {}) {
|
|
|
305
305
|
const executor = deps.executor ?? (await selectExecutor(config, logger));
|
|
306
306
|
const workspace = deps.workspace ?? (await selectWorkspace(config, logger));
|
|
307
307
|
const agents = deps.agents ?? (await selectAgents(config));
|
|
308
|
-
const conductor = new Conductor(config, remote, executor, workspace, agents, logger, checkoutRoot, frozenStateFileOf(config));
|
|
308
|
+
const conductor = new Conductor(config, remote, executor, workspace, agents, logger, checkoutRoot, frozenStateFileOf(config), undefined, readMachineContext);
|
|
309
309
|
// This process IS the conductor, so it may report its own pid and config
|
|
310
310
|
// name — the two values a cockpit needs to stop it later. poll/reap build a
|
|
311
311
|
// Conductor too but never claim, so they cannot overwrite this pid.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ConductorLogger } from '@bakers-build/core';
|
|
1
|
+
import { type ConductorLogger, type MachineContext } from '@bakers-build/core';
|
|
2
2
|
import { type RunEnvPolicy } from '../plugins/agent.js';
|
|
3
3
|
import type { BbExecutor } from '../plugins/executor.js';
|
|
4
4
|
import { type ResolvedAgent } from '../plugins/plugins.js';
|
|
@@ -36,6 +36,8 @@ export declare class Conductor {
|
|
|
36
36
|
private readonly checkoutRoot;
|
|
37
37
|
private readonly frozenStateFile?;
|
|
38
38
|
private readonly runHook;
|
|
39
|
+
/** Re-reads machine.config.js per run; absent, `config.tunnel` stays. */
|
|
40
|
+
private readonly readMachine?;
|
|
39
41
|
private uuid;
|
|
40
42
|
/**
|
|
41
43
|
* Frozen tickets seen on the last poll, by uuid, with the worktree their
|
|
@@ -52,7 +54,11 @@ export declare class Conductor {
|
|
|
52
54
|
private toolServer;
|
|
53
55
|
/** Serializes git worktree add/remove: parallel ones fight over git locks. */
|
|
54
56
|
private gitLock;
|
|
55
|
-
|
|
57
|
+
/** The last good machine `tunnel` policy, re-read for each run's env. */
|
|
58
|
+
private tunnel;
|
|
59
|
+
constructor(config: ConductorFileConfig, remote: BbRemote, executor: BbExecutor, workspace: BbWorkspace, agents: ResolvedAgent[], logger: ConductorLogger, checkoutRoot?: string, frozenStateFile?: string | undefined, runHook?: HookRunner,
|
|
60
|
+
/** Re-reads machine.config.js per run; absent, `config.tunnel` stays. */
|
|
61
|
+
readMachine?: (() => Promise<Partial<MachineContext>>) | undefined);
|
|
56
62
|
private serialGit;
|
|
57
63
|
/**
|
|
58
64
|
* `conductor_id` is derived by the loader from the machine UUID, project and
|
|
@@ -221,6 +227,12 @@ export declare class Conductor {
|
|
|
221
227
|
* `after_run` / `after_done` listener contexts (BB-599).
|
|
222
228
|
*/
|
|
223
229
|
private runEnv;
|
|
230
|
+
/**
|
|
231
|
+
* The machine's `tunnel` policy as of now, so a changed machine.config.js
|
|
232
|
+
* reaches the next run without a restart. A file without `machine_id`
|
|
233
|
+
* (missing or broken) or a failed read keeps the last good value.
|
|
234
|
+
*/
|
|
235
|
+
private currentTunnel;
|
|
224
236
|
/** Dispatches one claimed run; a failure terminalises it (BB-149). */
|
|
225
237
|
private dispatchOrFail;
|
|
226
238
|
/** `at.worktree` is set once the workspace exists, so a failure can signal it. */
|
|
@@ -189,6 +189,7 @@ export class Conductor {
|
|
|
189
189
|
checkoutRoot;
|
|
190
190
|
frozenStateFile;
|
|
191
191
|
runHook;
|
|
192
|
+
readMachine;
|
|
192
193
|
uuid = null;
|
|
193
194
|
/**
|
|
194
195
|
* Frozen tickets seen on the last poll, by uuid, with the worktree their
|
|
@@ -205,7 +206,11 @@ export class Conductor {
|
|
|
205
206
|
toolServer;
|
|
206
207
|
/** Serializes git worktree add/remove: parallel ones fight over git locks. */
|
|
207
208
|
gitLock = Promise.resolve();
|
|
208
|
-
|
|
209
|
+
/** The last good machine `tunnel` policy, re-read for each run's env. */
|
|
210
|
+
tunnel;
|
|
211
|
+
constructor(config, remote, executor, workspace, agents, logger, checkoutRoot = process.cwd(), frozenStateFile, runHook = shellHookRunner(config.hooks, logger),
|
|
212
|
+
/** Re-reads machine.config.js per run; absent, `config.tunnel` stays. */
|
|
213
|
+
readMachine) {
|
|
209
214
|
this.config = config;
|
|
210
215
|
this.remote = remote;
|
|
211
216
|
this.executor = executor;
|
|
@@ -215,6 +220,8 @@ export class Conductor {
|
|
|
215
220
|
this.checkoutRoot = checkoutRoot;
|
|
216
221
|
this.frozenStateFile = frozenStateFile;
|
|
217
222
|
this.runHook = runHook;
|
|
223
|
+
this.readMachine = readMachine;
|
|
224
|
+
this.tunnel = config.tunnel === true;
|
|
218
225
|
this.inboxAddons = new InboxRuntime(config.inboxAddons ?? [], remote, logger, (ticket) => this.runEnv(ticket, undefined, ticket.state), config.tools);
|
|
219
226
|
this.queue = new ActionQueue(logger);
|
|
220
227
|
}
|
|
@@ -1072,7 +1079,7 @@ export class Conductor {
|
|
|
1072
1079
|
...(t.identifier ? { BB_TICKET_IDENTIFIER: t.identifier } : {}),
|
|
1073
1080
|
...(state ? { BB_STATE: state } : {}),
|
|
1074
1081
|
...(runUuid ? { BB_RUN_UUID: runUuid } : {}),
|
|
1075
|
-
BB_TUNNEL: this.
|
|
1082
|
+
BB_TUNNEL: (await this.currentTunnel()) ? '1' : '0',
|
|
1076
1083
|
WORKSPACE_ROOT: this.checkoutRoot,
|
|
1077
1084
|
...(t.issueUrl ? { TICKET_URL: t.issueUrl } : {}),
|
|
1078
1085
|
...(t.projectName ? { BB_PROJECT: t.projectName } : {}),
|
|
@@ -1086,6 +1093,27 @@ export class Conductor {
|
|
|
1086
1093
|
...(agent?.runEnvPolicy ? { policy: agent.runEnvPolicy } : {}),
|
|
1087
1094
|
});
|
|
1088
1095
|
}
|
|
1096
|
+
/**
|
|
1097
|
+
* The machine's `tunnel` policy as of now, so a changed machine.config.js
|
|
1098
|
+
* reaches the next run without a restart. A file without `machine_id`
|
|
1099
|
+
* (missing or broken) or a failed read keeps the last good value.
|
|
1100
|
+
*/
|
|
1101
|
+
async currentTunnel() {
|
|
1102
|
+
if (!this.readMachine)
|
|
1103
|
+
return this.tunnel;
|
|
1104
|
+
try {
|
|
1105
|
+
const machine = await this.readMachine();
|
|
1106
|
+
if (machine.machine_id) {
|
|
1107
|
+
this.tunnel = machine.tunnel === true;
|
|
1108
|
+
return this.tunnel;
|
|
1109
|
+
}
|
|
1110
|
+
this.logger.warn({}, 'machine.config.js has no machine_id; keeping the last tunnel value');
|
|
1111
|
+
}
|
|
1112
|
+
catch (err) {
|
|
1113
|
+
this.logger.warn({ err: String(err) }, 'could not re-read machine.config.js; keeping the last tunnel value');
|
|
1114
|
+
}
|
|
1115
|
+
return this.tunnel;
|
|
1116
|
+
}
|
|
1089
1117
|
/** Dispatches one claimed run; a failure terminalises it (BB-149). */
|
|
1090
1118
|
async dispatchOrFail(run) {
|
|
1091
1119
|
const at = {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bakers-build/conductor",
|
|
3
|
-
"version": "0.7.1-next.
|
|
3
|
+
"version": "0.7.1-next.4",
|
|
4
4
|
"description": "bakers.build conductor engine + CLI: registers, claims tickets via JSON:API, dispatches agents.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -32,14 +32,14 @@
|
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@dropsh/plugin-jsonapi-schema": "^0.8.2",
|
|
34
34
|
"@dropsh/plugin-oauth2": "^0.8.2",
|
|
35
|
-
"@bakers-build/core": "^0.7.1-next.
|
|
36
|
-
"@bakers-build/message": "^0.7.1-next.
|
|
35
|
+
"@bakers-build/core": "^0.7.1-next.4",
|
|
36
|
+
"@bakers-build/message": "^0.7.1-next.4",
|
|
37
37
|
"@modelcontextprotocol/sdk": "1.32.1",
|
|
38
38
|
"commander": "^12.1.0",
|
|
39
39
|
"dropsh": "^0.8.2"
|
|
40
40
|
},
|
|
41
41
|
"bakersBuild": {
|
|
42
|
-
"commit": "
|
|
42
|
+
"commit": "0633e1e4d21ee420a1d0fc3eae2114750eb103bd",
|
|
43
43
|
"channel": "next"
|
|
44
44
|
}
|
|
45
45
|
}
|