@bakers-build/conductor 0.18.1-next.4 → 0.18.1-next.5

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.
@@ -454,6 +454,7 @@ async function cmdStartForeground(deps, log = {}, force = false, choice = {}) {
454
454
  }
455
455
  catch (err) {
456
456
  logger.error({ path: secretsFilePath() }, `${err.message}; keeping the running conductor on its last good secrets`);
457
+ cancelRestart();
457
458
  return undefined;
458
459
  }
459
460
  };
@@ -466,6 +467,23 @@ async function cmdStartForeground(deps, log = {}, force = false, choice = {}) {
466
467
  clearInterval(versionTimer);
467
468
  controller.abort();
468
469
  };
470
+ // A restart under a running agent drops its MCP tools for good (the harness does
471
+ // not reconnect): pause claims and re-exec on the first poll with no active run.
472
+ let pendingSince;
473
+ let pendingLogged = false;
474
+ const requestRestart = (since = Date.now()) => {
475
+ pendingSince = Math.min(pendingSince ?? since, since);
476
+ conductor.pauseClaims();
477
+ };
478
+ // A later failed check means the files on disk are bad: keep this process.
479
+ const cancelRestart = () => {
480
+ if (pendingSince === undefined)
481
+ return;
482
+ pendingSince = undefined;
483
+ pendingLogged = false;
484
+ conductor.pauseClaims(false);
485
+ logger.warn({}, 'pending restart cancelled; claiming again');
486
+ };
469
487
  // An upgrade replaces the installed files under this running process: once
470
488
  // two polls read the same new version, migrate, check and come back on it.
471
489
  const startVersion = resolveCliVersion();
@@ -517,7 +535,7 @@ async function cmdStartForeground(deps, log = {}, force = false, choice = {}) {
517
535
  return;
518
536
  }
519
537
  logger.info({ path: envPath }, 'secrets file changed; restarting conductor');
520
- restartNow(cut);
538
+ requestRestart(cut);
521
539
  return;
522
540
  }
523
541
  const path = [...configPaths, ...(envPath ? [envPath] : [])].join(', ');
@@ -528,16 +546,40 @@ async function cmdStartForeground(deps, log = {}, force = false, choice = {}) {
528
546
  return;
529
547
  if (error !== undefined) {
530
548
  logger.error({ path, err: error }, `config check failed; keeping the running conductor: ${error}`);
549
+ cancelRestart();
531
550
  return;
532
551
  }
533
552
  logger.info({ path }, 'config check passed; restarting conductor');
534
- restartNow(cut);
553
+ requestRestart(cut);
535
554
  }, undefined, loadedAt);
536
555
  }
537
556
  }
538
557
  const versionTimer = setInterval(async () => {
539
558
  if (busy || controller.signal.aborted)
540
559
  return;
560
+ if (pendingSince !== undefined) {
561
+ busy = true;
562
+ try {
563
+ const active = await remote.activeRunCount(conductor.id);
564
+ if (controller.signal.aborted || pendingSince === undefined)
565
+ return;
566
+ if (active === 0) {
567
+ restartNow(pendingSince);
568
+ return;
569
+ }
570
+ if (!pendingLogged) {
571
+ pendingLogged = true;
572
+ logger.info({ active }, `restart pending: ${active} active runs; claiming nothing until they finish`);
573
+ }
574
+ }
575
+ catch (err) {
576
+ // Delayed, never forced: a restart under an active run is the bug.
577
+ logger.warn({ err: String(err) }, 'active runs unreadable; the pending restart retries on the next poll');
578
+ }
579
+ finally {
580
+ busy = false;
581
+ }
582
+ }
541
583
  const read = readVersion();
542
584
  const previous = lastRead;
543
585
  lastRead = read;
@@ -570,6 +612,7 @@ async function cmdStartForeground(deps, log = {}, force = false, choice = {}) {
570
612
  return;
571
613
  if (error !== undefined) {
572
614
  logger.error({ from: startVersion, to: read, step, err: error }, `${step} failed; keeping the running conductor on ${startVersion}: ${error}. Recover with \`${prefix} config upgrade --scope all --yes\`, then \`${prefix} oven start --force\``);
615
+ cancelRestart();
573
616
  return;
574
617
  }
575
618
  }
@@ -578,7 +621,7 @@ async function cmdStartForeground(deps, log = {}, force = false, choice = {}) {
578
621
  busy = false;
579
622
  }
580
623
  logger.info({ to: read }, 'config check passed; restarting conductor');
581
- restartNow();
624
+ requestRestart();
582
625
  }, config.poll_interval_ms);
583
626
  try {
584
627
  await conductor.serve(controller.signal);
@@ -4,7 +4,7 @@
4
4
  import { readFileSync } from 'node:fs';
5
5
  import { Client } from '@modelcontextprotocol/sdk/client/index.js';
6
6
  import { StreamableHTTPClientTransport, StreamableHTTPError, } from '@modelcontextprotocol/sdk/client/streamableHttp.js';
7
- import { CONDUCTOR_TOKEN_ENV, CONDUCTOR_URL_ENV } from '../plugins/agent.js';
7
+ import { CONDUCTOR_TOKEN_ENV, CONDUCTOR_TOOL_TIMEOUT_MS, CONDUCTOR_URL_ENV, } from '../plugins/agent.js';
8
8
  const processIo = {
9
9
  out: (line) => process.stdout.write(`${line}\n`),
10
10
  err: (line) => process.stderr.write(`${line}\n`),
@@ -72,7 +72,10 @@ export async function ovenTools(name, opts, env = process.env, io = processIo) {
72
72
  io.out(JSON.stringify(tool.inputSchema, null, 2));
73
73
  return EXIT.ok;
74
74
  }
75
- const result = await client.callTool({ name, arguments: args });
75
+ // The SDK default (60 s) would cut provision tools; use the MCP launch's limit.
76
+ const result = await client.callTool({ name, arguments: args }, undefined, {
77
+ timeout: CONDUCTOR_TOOL_TIMEOUT_MS,
78
+ });
76
79
  const text = result.structuredContent
77
80
  ? JSON.stringify(result.structuredContent, null, 2)
78
81
  : (result.content ?? [])
@@ -45,6 +45,8 @@ export declare class Conductor {
45
45
  private claimBackoffMs;
46
46
  /** No claim before this epoch ms while refused. */
47
47
  private claimsRefusedUntil;
48
+ /** Set by a pending self-restart: claim nothing until it re-execs. */
49
+ private claimsPaused;
48
50
  /**
49
51
  * Frozen tickets seen on the last poll, by uuid, with the worktree their
50
52
  * hook ran in. Mirrored to `frozenStateFile` when one is given, so an
@@ -137,6 +139,8 @@ export declare class Conductor {
137
139
  * its remedy, then retry claims at a doubling interval up to five minutes.
138
140
  */
139
141
  private refuseClaims;
142
+ /** Claim no new runs (or again); everything else keeps running. */
143
+ pauseClaims(paused?: boolean): void;
140
144
  /** One tick that also waits for its actions: `bakers conductor once`, tests. */
141
145
  tick(): Promise<void>;
142
146
  /** A failing list query must not stop the other steps or the claims. */
@@ -208,6 +208,8 @@ export class Conductor {
208
208
  claimBackoffMs = 0;
209
209
  /** No claim before this epoch ms while refused. */
210
210
  claimsRefusedUntil = 0;
211
+ /** Set by a pending self-restart: claim nothing until it re-execs. */
212
+ claimsPaused = false;
211
213
  /**
212
214
  * Frozen tickets seen on the last poll, by uuid, with the worktree their
213
215
  * hook ran in. Mirrored to `frozenStateFile` when one is given, so an
@@ -496,6 +498,10 @@ export class Conductor {
496
498
  }
497
499
  this.claimsRefusedUntil = Date.now() + this.claimBackoffMs;
498
500
  }
501
+ /** Claim no new runs (or again); everything else keeps running. */
502
+ pauseClaims(paused = true) {
503
+ this.claimsPaused = paused;
504
+ }
499
505
  /** One tick that also waits for its actions: `bakers conductor once`, tests. */
500
506
  async tick() {
501
507
  await this.produce();
@@ -562,7 +568,9 @@ export class Conductor {
562
568
  }
563
569
  let claimed = 0;
564
570
  // A refusal backs off silently: counted as withheld, so no idle line.
565
- let withheld = unavailable.length > 0 || Date.now() < this.claimsRefusedUntil;
571
+ let withheld = this.claimsPaused ||
572
+ unavailable.length > 0 ||
573
+ Date.now() < this.claimsRefusedUntil;
566
574
  while (!withheld && machineLoad < maxParallel) {
567
575
  let run;
568
576
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bakers-build/conductor",
3
- "version": "0.18.1-next.4",
3
+ "version": "0.18.1-next.5",
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.18.1-next.4",
36
- "@bakers-build/message": "^0.18.1-next.4",
35
+ "@bakers-build/core": "^0.18.1-next.5",
36
+ "@bakers-build/message": "^0.18.1-next.5",
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": "b15ff3eb4e969a0241b909b0e1a6395632d0860a",
42
+ "commit": "d5377887451377580fae79a26da7d729b4381202",
43
43
  "channel": "next"
44
44
  }
45
45
  }