@bakers-build/conductor 0.10.1-next.14 → 0.10.1-next.16
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.
|
@@ -2,7 +2,7 @@ import { execFile, spawnSync } from 'node:child_process';
|
|
|
2
2
|
import { basename, dirname, join, resolve } from 'node:path';
|
|
3
3
|
import { createInterface } from 'node:readline';
|
|
4
4
|
import { promisify } from 'node:util';
|
|
5
|
-
import { CommandRunner, checkForUpdate, configHomeOf, createBbConnectionClient, createLogger, declineUpdate, defaultProcProbe, deriveCheckoutRoot, deriveConductorLiveness, homeBbDir, loadReadyBbConnection, loadSecretsFile, printVersionLine, readCliVersion, readMachineContext, resolveCliVersion, resolveConfigPath, setDefaultCommandRunner, signalVerifiedProcess, stemForConfigFile, UNKNOWN_VERSION, updateNotice, verifyConductorProcess, } from '@bakers-build/core';
|
|
5
|
+
import { CommandRunner, checkForUpdate, configHomeOf, createBbConnectionClient, createLogger, declineUpdate, defaultProcProbe, deriveCheckoutRoot, deriveConductorLiveness, homeBbDir, loadReadyBbConnection, loadSecretsFile, printVersionLine, readCliVersion, readMachineContext, resolveCliVersion, resolveConfigPath, secretsFilePath, setDefaultCommandRunner, signalVerifiedProcess, stemForConfigFile, UNKNOWN_VERSION, updateNotice, verifyConductorProcess, } from '@bakers-build/core';
|
|
6
6
|
import { Command } from 'commander';
|
|
7
7
|
import { authStatus } from 'dropsh';
|
|
8
8
|
import { resolveBbProjectContext } from '../bakers-project-context.js';
|
|
@@ -435,20 +435,67 @@ async function cmdStartForeground(deps, log = {}, force = false, choice = {}) {
|
|
|
435
435
|
const execve = deps.execve ?? process.execve?.bind(process);
|
|
436
436
|
let watcher;
|
|
437
437
|
const check = deps.checkConfig ?? defaultCheckConfig;
|
|
438
|
+
// The restart re-runs loadSecretsOrFail, which exits on a bad file: check first.
|
|
439
|
+
const reloadSecrets = () => {
|
|
440
|
+
try {
|
|
441
|
+
return loadSecretsFile();
|
|
442
|
+
}
|
|
443
|
+
catch (err) {
|
|
444
|
+
logger.error({ path: secretsFilePath() }, `${err.message}; keeping the running conductor on its last good secrets`);
|
|
445
|
+
return undefined;
|
|
446
|
+
}
|
|
447
|
+
};
|
|
448
|
+
// Config changes a bad secrets file held back, re-checked on the next change.
|
|
449
|
+
const heldBack = new Set();
|
|
438
450
|
const restartNow = () => {
|
|
439
451
|
restart = true;
|
|
440
452
|
watcher?.close();
|
|
441
453
|
clearInterval(versionTimer);
|
|
442
454
|
controller.abort();
|
|
443
455
|
};
|
|
456
|
+
// An upgrade replaces the installed files under this running process: once
|
|
457
|
+
// two polls read the same new version, migrate, check and come back on it.
|
|
458
|
+
const startVersion = resolveCliVersion();
|
|
459
|
+
const readVersion = deps.readCliVersion ?? readCliVersion;
|
|
460
|
+
const migrate = deps.migrateConfig ?? defaultMigrateConfig;
|
|
461
|
+
const prefix = process.env.BAKERS_CONDUCTOR
|
|
462
|
+
? `bakers --conductor ${process.env.BAKERS_CONDUCTOR}`
|
|
463
|
+
: 'bakers';
|
|
464
|
+
let lastRead;
|
|
465
|
+
let settled; // the new version already handled or refused
|
|
466
|
+
let busy = false;
|
|
444
467
|
if (config.restart_on_change !== false && config.watch_paths) {
|
|
445
468
|
if (!execve) {
|
|
446
469
|
logger.warn({ node: process.version }, 'restart_on_change needs process.execve (Node >= 22.15); the conductor does not restart itself on config changes');
|
|
447
470
|
}
|
|
448
471
|
else {
|
|
449
|
-
watcher = (deps.watchForRestart ?? watchForRestart)(config.watch_paths, async (
|
|
472
|
+
watcher = (deps.watchForRestart ?? watchForRestart)(config.watch_paths, async (paths) => {
|
|
450
473
|
if (controller.signal.aborted)
|
|
451
474
|
return;
|
|
475
|
+
const secretsPath = secretsFilePath();
|
|
476
|
+
for (const p of paths)
|
|
477
|
+
if (p !== secretsPath)
|
|
478
|
+
heldBack.add(p);
|
|
479
|
+
if (!reloadSecrets())
|
|
480
|
+
return;
|
|
481
|
+
const configPaths = [...heldBack];
|
|
482
|
+
heldBack.clear();
|
|
483
|
+
if (!configPaths.length) {
|
|
484
|
+
const read = readVersion();
|
|
485
|
+
if (read !== UNKNOWN_VERSION && read !== startVersion) {
|
|
486
|
+
// A new CLI starts only after migrate and check: retry the upgrade on the next poll.
|
|
487
|
+
settled = undefined;
|
|
488
|
+
logger.info({ path: secretsPath, to: read }, 'secrets file changed; the pending CLI upgrade restarts the conductor');
|
|
489
|
+
return;
|
|
490
|
+
}
|
|
491
|
+
logger.info({ path: secretsPath }, 'secrets file changed; restarting conductor');
|
|
492
|
+
restartNow();
|
|
493
|
+
return;
|
|
494
|
+
}
|
|
495
|
+
const path = [
|
|
496
|
+
...configPaths,
|
|
497
|
+
...paths.filter((p) => p === secretsPath),
|
|
498
|
+
].join(', ');
|
|
452
499
|
logger.info({ path }, `restart_on_change: ${path} changed; checking config`);
|
|
453
500
|
const error = await check();
|
|
454
501
|
// A stop requested while the check ran stays a stop.
|
|
@@ -463,17 +510,6 @@ async function cmdStartForeground(deps, log = {}, force = false, choice = {}) {
|
|
|
463
510
|
});
|
|
464
511
|
}
|
|
465
512
|
}
|
|
466
|
-
// An upgrade replaces the installed files under this running process: once
|
|
467
|
-
// two polls read the same new version, migrate, check and come back on it.
|
|
468
|
-
const startVersion = resolveCliVersion();
|
|
469
|
-
const readVersion = deps.readCliVersion ?? readCliVersion;
|
|
470
|
-
const migrate = deps.migrateConfig ?? defaultMigrateConfig;
|
|
471
|
-
const prefix = process.env.BAKERS_CONDUCTOR
|
|
472
|
-
? `bakers --conductor ${process.env.BAKERS_CONDUCTOR}`
|
|
473
|
-
: 'bakers';
|
|
474
|
-
let lastRead;
|
|
475
|
-
let settled; // the new version already handled or refused
|
|
476
|
-
let busy = false;
|
|
477
513
|
const versionTimer = setInterval(async () => {
|
|
478
514
|
if (busy || controller.signal.aborted)
|
|
479
515
|
return;
|
|
@@ -498,6 +534,8 @@ async function cmdStartForeground(deps, log = {}, force = false, choice = {}) {
|
|
|
498
534
|
logger.info({ from: startVersion, to: read }, `${changed}; upgrading config`);
|
|
499
535
|
busy = true;
|
|
500
536
|
try {
|
|
537
|
+
if (!reloadSecrets())
|
|
538
|
+
return;
|
|
501
539
|
for (const [step, run] of [
|
|
502
540
|
['config upgrade', migrate],
|
|
503
541
|
['config check', check],
|
package/dist/src/config.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { readdirSync } from 'node:fs';
|
|
2
2
|
import { basename, dirname, isAbsolute, resolve } from 'node:path';
|
|
3
3
|
import { pathToFileURL } from 'node:url';
|
|
4
|
-
import { assertSchemaVersion, assertValidConfig, discoverAddons, discoverScoped, findDefaultExportObject, machineContextPath, matchDelimiter, readMachineContext, resolveConductorSlots, resolveModuleEslintStyle, scanTopLevelProperties, scopeAddons, stemForConfigFile, } from '@bakers-build/core';
|
|
4
|
+
import { assertSchemaVersion, assertValidConfig, discoverAddons, discoverScoped, findDefaultExportObject, machineContextPath, matchDelimiter, readMachineContext, resolveConductorSlots, resolveModuleEslintStyle, scanTopLevelProperties, scopeAddons, secretsFilePath, stemForConfigFile, } from '@bakers-build/core';
|
|
5
5
|
import { readBbProjectSelection } from './cli/project-context.js';
|
|
6
6
|
import { SHARED_SECURITY_KEY, validateSharedSecurity, } from './plugins/agent-args.js';
|
|
7
7
|
import { validateMarketplaces } from './plugins/agent-home.js';
|
|
@@ -594,7 +594,7 @@ export async function loadConductorConfig(configFile) {
|
|
|
594
594
|
config_path: configPath,
|
|
595
595
|
restart_on_change: restartOnChange,
|
|
596
596
|
watch_paths: {
|
|
597
|
-
files: [configPath, machineContextPath()],
|
|
597
|
+
files: [configPath, machineContextPath(), secretsFilePath()],
|
|
598
598
|
// A retired entry keeps its spec as key; only resolved modules have a dir.
|
|
599
599
|
dirs: [
|
|
600
600
|
...new Set(effectiveAddons
|
|
@@ -4,12 +4,12 @@ export interface WatchPaths {
|
|
|
4
4
|
dirs: string[];
|
|
5
5
|
}
|
|
6
6
|
/**
|
|
7
|
-
* Call `trigger` with
|
|
8
|
-
* further change. Files are watched through their parent directory, so an
|
|
7
|
+
* Call `trigger` with every path changed since the last trigger, after
|
|
8
|
+
* `debounceMs` without a further change. Files are watched through their parent directory, so an
|
|
9
9
|
* editor's rename-replace save and a newly created file both count; dirs are
|
|
10
10
|
* watched recursively. At most one trigger runs at a time; changes during one
|
|
11
11
|
* re-arm the debounce once it returns.
|
|
12
12
|
*/
|
|
13
|
-
export declare function watchForRestart(paths: WatchPaths, trigger: (
|
|
13
|
+
export declare function watchForRestart(paths: WatchPaths, trigger: (paths: string[]) => Promise<void>, debounceMs?: number): {
|
|
14
14
|
close(): void;
|
|
15
15
|
};
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
// The foreground conductor restarts itself when a file it loaded changes:
|
|
2
|
-
// its config files, the machine config, or a configured
|
|
3
|
-
// module only watches, debounces and serializes; the
|
|
4
|
-
// change becomes a restart (config check, drain,
|
|
2
|
+
// its config files, the machine config, the secrets file, or a configured
|
|
3
|
+
// addon's build. This module only watches, debounces and serializes; the
|
|
4
|
+
// caller decides whether a change becomes a restart (config check, drain,
|
|
5
|
+
// execve).
|
|
5
6
|
import { watch } from 'node:fs';
|
|
6
7
|
import { basename, dirname, join } from 'node:path';
|
|
7
8
|
/**
|
|
8
|
-
* Call `trigger` with
|
|
9
|
-
* further change. Files are watched through their parent directory, so an
|
|
9
|
+
* Call `trigger` with every path changed since the last trigger, after
|
|
10
|
+
* `debounceMs` without a further change. Files are watched through their parent directory, so an
|
|
10
11
|
* editor's rename-replace save and a newly created file both count; dirs are
|
|
11
12
|
* watched recursively. At most one trigger runs at a time; changes during one
|
|
12
13
|
* re-arm the debounce once it returns.
|
|
@@ -14,7 +15,7 @@ import { basename, dirname, join } from 'node:path';
|
|
|
14
15
|
export function watchForRestart(paths, trigger, debounceMs = 2000) {
|
|
15
16
|
const watchers = [];
|
|
16
17
|
let timer;
|
|
17
|
-
|
|
18
|
+
const changedPaths = new Set();
|
|
18
19
|
let running = false;
|
|
19
20
|
let pending = false;
|
|
20
21
|
let closed = false;
|
|
@@ -22,7 +23,9 @@ export function watchForRestart(paths, trigger, debounceMs = 2000) {
|
|
|
22
23
|
timer = undefined;
|
|
23
24
|
running = true;
|
|
24
25
|
try {
|
|
25
|
-
|
|
26
|
+
const paths = [...changedPaths];
|
|
27
|
+
changedPaths.clear();
|
|
28
|
+
await trigger(paths);
|
|
26
29
|
}
|
|
27
30
|
finally {
|
|
28
31
|
running = false;
|
|
@@ -39,7 +42,7 @@ export function watchForRestart(paths, trigger, debounceMs = 2000) {
|
|
|
39
42
|
const changed = (path) => {
|
|
40
43
|
if (closed)
|
|
41
44
|
return;
|
|
42
|
-
|
|
45
|
+
changedPaths.add(path);
|
|
43
46
|
if (running)
|
|
44
47
|
pending = true;
|
|
45
48
|
else
|
|
@@ -11,10 +11,10 @@ export const SITE_TOOLS = [
|
|
|
11
11
|
'bakers_ticket_classify',
|
|
12
12
|
'bakers_ticket_transition',
|
|
13
13
|
'bakers_run_cancel',
|
|
14
|
-
'
|
|
14
|
+
'bakers_comment_create',
|
|
15
15
|
'bakers_metric_write',
|
|
16
16
|
'bakers_ticket_list',
|
|
17
|
-
'
|
|
17
|
+
'bakers_run_list',
|
|
18
18
|
'bakers_label_list',
|
|
19
19
|
'bakers_project_read',
|
|
20
20
|
'bakers_user_read',
|
|
@@ -27,7 +27,7 @@ export const SITE_WRITE_TOOLS = [
|
|
|
27
27
|
'bakers_ticket_classify',
|
|
28
28
|
'bakers_ticket_transition',
|
|
29
29
|
'bakers_run_cancel',
|
|
30
|
-
'
|
|
30
|
+
'bakers_comment_create',
|
|
31
31
|
];
|
|
32
32
|
const WIRE = 'tool_api__';
|
|
33
33
|
export function siteToolProxy(client, logger) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bakers-build/conductor",
|
|
3
|
-
"version": "0.10.1-next.
|
|
3
|
+
"version": "0.10.1-next.16",
|
|
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.10.1-next.
|
|
36
|
-
"@bakers-build/message": "^0.10.1-next.
|
|
35
|
+
"@bakers-build/core": "^0.10.1-next.16",
|
|
36
|
+
"@bakers-build/message": "^0.10.1-next.16",
|
|
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": "940ae2f2e37b915a7c15c59179d8ebc4f4fbd0a4",
|
|
43
43
|
"channel": "next"
|
|
44
44
|
}
|
|
45
45
|
}
|