c8ctl-plugin-nano 1.70.8 → 1.72.0

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 CHANGED
@@ -1363,7 +1363,10 @@ c8ctl nano supervisor reload # roll it into the running fleet, zero downtime
1363
1363
  since the daemon is a thin process manager. `supervisor status` shows an
1364
1364
  `on disk:` line flagging "update available" whenever the code on disk has
1365
1365
  advanced past the running daemon, so you know when a reload (or restart) is
1366
- worthwhile.
1366
+ worthwhile. While a reload is in progress, `supervisor status` also prints a
1367
+ `reload:` line (`rolling N/M adopted — draining <id> — do not restart the
1368
+ daemon`) so a detached operator can see the roll without staying attached to
1369
+ the streaming `reload` command.
1367
1370
 
1368
1371
  ### Surviving SSH logout: `supervisor install` / `uninstall`
1369
1372
 
package/c8ctl-plugin.js CHANGED
@@ -9961,6 +9961,39 @@ function baseAgentEnv(profile, job) {
9961
9961
  * is force-removed so it never leaks a slot or disk.
9962
9962
  * Both paths resolve to the same result contract.
9963
9963
  */
9964
+ // #305: derive the harness PROVIDER timeout from the worker idle-kill budget.
9965
+ // The worker idle-kills a silent harness after `idleTimeoutMs`; if the harness's
9966
+ // own provider (LLM request) stall timeout is >= that budget, a hung model request
9967
+ // kills the WHOLE run instead of being retried inside the harness. We hand the
9968
+ // harness `NANO_CODER_PROVIDER_TIMEOUT_SECS = floor(idleMs/1000/2)` so a stalled
9969
+ // request always times out (and can retry) well inside the idle window. Returns
9970
+ // null when there is no idle kill (<= 0 / non-finite) or the budget is too small
9971
+ // to express a whole-second timeout strictly below it. Invariant (tested):
9972
+ // `secs * 1000 < idleTimeoutMs` whenever non-null.
9973
+ export const PROVIDER_TIMEOUT_ENV = 'NANO_CODER_PROVIDER_TIMEOUT_SECS';
9974
+ export function deriveProviderTimeoutSecs(idleTimeoutMs) {
9975
+ const ms = Number(idleTimeoutMs);
9976
+ if (!Number.isFinite(ms) || ms <= 0) return null;
9977
+ const secs = Math.floor(ms / 1000 / 2);
9978
+ return secs >= 1 ? secs : null;
9979
+ }
9980
+ export function providerTimeoutEnv(idleTimeoutMs) {
9981
+ const secs = deriveProviderTimeoutSecs(idleTimeoutMs);
9982
+ return secs == null ? {} : { [PROVIDER_TIMEOUT_ENV]: String(secs) };
9983
+ }
9984
+ // #305: startup guard — a profile-configured harness provider timeout that is
9985
+ // >= the idle budget means a hung request idle-kills the run. Returns a warning
9986
+ // string (or null).
9987
+ export function providerTimeoutWarning(env, idleTimeoutMs) {
9988
+ const raw = env && typeof env === 'object' ? env[PROVIDER_TIMEOUT_ENV] : undefined;
9989
+ const ms = Number(idleTimeoutMs);
9990
+ if (raw == null || String(raw).trim() === '' || !Number.isFinite(ms) || ms <= 0) return null;
9991
+ const secs = Number(String(raw).trim());
9992
+ if (!Number.isFinite(secs)) return null;
9993
+ if (secs * 1000 < ms) return null;
9994
+ return `configured harness provider timeout ${PROVIDER_TIMEOUT_ENV}=${raw}s is >= the worker idle budget (${ms}ms) — a hung model request will idle-kill the whole run instead of being retried inside the harness; lower it below ${Math.floor(ms / 1000)}s (derived default: ${deriveProviderTimeoutSecs(ms) ?? 'unset'}s)`;
9995
+ }
9996
+
9964
9997
  function runAgentJob(profile, job, opts = {}) {
9965
9998
  const { timeoutMs, idleTimeoutMs, recoveryWindowMs, envelope, sandbox = 'none', image, runId, secretEnv = {}, passThroughSecretNames = [], cwd, extraEnv = {}, profileEnv = {}, gitEnv = null, resultFile, stream = false, streamPrefix = '', onStreamOut, onStreamErr, args: commandArgs, terminal = 'pipe', protocol = 'pipe', permission = 'yolo', relaySession = null, ptyFactory, nudgePayload = null, onAcpUpdate = null, abortSignal = null, onSpawn = null, resumePlan = null } = opts;
9966
9999
  // #110: `protocol`/`permission` drive the ACP executor branch below. The
@@ -9982,7 +10015,7 @@ function runAgentJob(profile, job, opts = {}) {
9982
10015
  // harness's permission toggles) plus the per-job envelope's setup.env
9983
10016
  // (job-specific tuning wins over the profile default). Reserved AGENT_* and
9984
10017
  // resolved secrets are layered on top so user env can never shadow them.
9985
- const staticEnv = { ...normalizeEnvMap(profileEnv), ...normalizeEnvMap(envelope?.setup?.env) };
10018
+ const staticEnv = { ...providerTimeoutEnv(idleTimeoutMs), ...normalizeEnvMap(profileEnv), ...normalizeEnvMap(envelope?.setup?.env) };
9986
10019
  // #283: the provisioning git env (non-interactive editor no-ops,
9987
10020
  // GIT_TERMINAL_PROMPT=0, GIT_CONFIG_NOSYSTEM=1, …) is the harness env's
9988
10021
  // BOTTOM layer above process.env — a headless agent's own `git commit` (no
@@ -11953,6 +11986,11 @@ async function workAgent(req, flags, ctx) {
11953
11986
  logger.info(` sandbox: ${sandbox}${isContainer ? ` (image ${image})` : ''}`);
11954
11987
  const profileEnvKeys = Object.keys(profileEnv);
11955
11988
  if (profileEnvKeys.length > 0) logger.info(` harness env: ${profileEnvKeys.join(', ')}`);
11989
+ {
11990
+ const ptWarn = providerTimeoutWarning(profileEnv, idleTimeoutMs);
11991
+ if (ptWarn) logger.warn(` ${ptWarn}`);
11992
+ else if (deriveProviderTimeoutSecs(idleTimeoutMs) != null && !(PROVIDER_TIMEOUT_ENV in profileEnv)) logger.info(` harness provider timeout: ${PROVIDER_TIMEOUT_ENV}=${deriveProviderTimeoutSecs(idleTimeoutMs)}s (derived from idle budget ${idleTimeoutMs}ms)`);
11993
+ }
11956
11994
  if (autoMode) {
11957
11995
  logger.info(` enrolment: --auto (zero-config engine read${autoScope ? `, scope "${autoScope}"` : ', all agent job types'}) — no capability gate; serves any deployed agent job on this engine.`);
11958
11996
  }
@@ -15092,6 +15130,24 @@ function formatSupervisorStatus(status) {
15092
15130
  if (onDiskVersion && d.version && onDiskVersion !== d.version) {
15093
15131
  lines.push(` on disk: ${onDiskVersion} (update available — run \`c8ctl nano supervisor reload\` to adopt new worker code; restart the daemon for new supervisor code)`);
15094
15132
  }
15133
+ // A rolling reload can run for a long time (each worker drains in-flight
15134
+ // work). Surface it on every `status` so a detached operator — or someone
15135
+ // who only ever polls status — can see the roll is live and must not
15136
+ // `restart` the daemon. `reload` is the progress object from the live
15137
+ // socket frame; absent on the socket-unreachable fallback.
15138
+ const roll = status.reload;
15139
+ if (roll && roll.inProgress) {
15140
+ const done = Array.isArray(roll.reloaded) ? roll.reloaded.length : 0;
15141
+ const total = Number(roll.total) || 0;
15142
+ const current = roll.current ? String(roll.current) : null;
15143
+ const parts = [`rolling ${done}/${total} adopted`];
15144
+ if (current) parts.push(`draining ${current}`);
15145
+ if (onDiskVersion && d.version && onDiskVersion !== d.version) {
15146
+ parts.push(`${d.version} → ${onDiskVersion}`);
15147
+ }
15148
+ parts.push('do not restart the daemon');
15149
+ lines.push(` reload: ${parts.join(' — ')}`);
15150
+ }
15095
15151
  if (d.startedAt) lines.push(` started: ${d.startedAt}`);
15096
15152
  if (d.socket) lines.push(` control: ${d.socket}`);
15097
15153
  const workers = Array.isArray(status.workers) ? status.workers : [];
@@ -15383,6 +15439,11 @@ async function runSupervisorDaemon() {
15383
15439
  // them one at a time (so the fleet keeps serving). This flag rejects a second
15384
15440
  // concurrent reload — a single rolling pass owns the fleet until it finishes.
15385
15441
  let reloading = false;
15442
+ // Progress for `status.reload` while `reloading` is true. Reset when the
15443
+ // roll starts; `reloadCurrent` is the id in `reloadWorker` right now.
15444
+ let reloadTargets = [];
15445
+ let reloadDone = [];
15446
+ let reloadCurrent = null;
15386
15447
  // Live-view monitor: tracks the last-broadcast fleet signature so we push a
15387
15448
  // refreshed status to attached consoles only on real change (see below).
15388
15449
  let monitorTimer = null;
@@ -15801,12 +15862,24 @@ async function runSupervisorDaemon() {
15801
15862
  // shutting down. Never clears `supervisor.json` — a reload is not a stop.
15802
15863
  const runReload = async (ids, sock) => {
15803
15864
  reloading = true;
15865
+ reloadTargets = [...ids];
15866
+ reloadDone = [];
15867
+ reloadCurrent = null;
15804
15868
  const reloaded = [];
15805
15869
  const skipped = [];
15806
15870
  let interrupted = false;
15807
15871
  try {
15808
15872
  for (let i = 0; i < ids.length; i++) {
15809
15873
  const id = ids[i];
15874
+ reloadCurrent = id;
15875
+ // Broadcast (not just to the initiating socket) on every target
15876
+ // transition so every attached console sees the drain progress and the
15877
+ // "do not restart the daemon" warning even with periodic monitoring
15878
+ // disabled (NANO_SUPERVISOR_MONITOR_MS=0). The initiator is itself an
15879
+ // attach client, so it is covered too.
15880
+ if (!shuttingDown) {
15881
+ try { broadcast(statusFrame(false)); } catch { /* best effort */ }
15882
+ }
15810
15883
  // If the daemon starts shutting down mid-roll, the remaining workers
15811
15884
  // never adopt the new code — record them as skipped (and flag the roll
15812
15885
  // interrupted) so the terminal frame can't report a clean success for a
@@ -15830,6 +15903,8 @@ async function runSupervisorDaemon() {
15830
15903
  const ok = await reloadWorker(id);
15831
15904
  if (ok) {
15832
15905
  reloaded.push(id);
15906
+ reloadDone.push(id);
15907
+ reloadCurrent = null;
15833
15908
  // Emit the per-worker "reloaded" progress signal ONLY after the final
15834
15909
  // success gate above confirmed a live, still-current replacement — not
15835
15910
  // at spawn time. A crash/spawn-fail makes `reloadWorker` return false
@@ -15850,13 +15925,24 @@ async function runSupervisorDaemon() {
15850
15925
  for (let j = i; j < ids.length; j++) skipped.push(ids[j]);
15851
15926
  break;
15852
15927
  }
15853
- try { sock.write(encodeFrame(statusFrame(false))); } catch { /* client gone */ }
15928
+ try { broadcast(statusFrame(false)); } catch { /* best effort */ }
15854
15929
  }
15855
15930
  } catch (err) {
15856
15931
  interrupted = true;
15857
15932
  dlog(`reload error: ${err?.message || err}`);
15858
15933
  } finally {
15859
15934
  reloading = false;
15935
+ reloadCurrent = null;
15936
+ reloadTargets = [];
15937
+ reloadDone = [];
15938
+ // Clearing the progress flags may not change the monitor signature (it may
15939
+ // already have sampled the final replacement mid-readiness-wait), and the
15940
+ // terminal `reloaded` frame goes only to the initiating socket — so push a
15941
+ // fresh status to every attached console now, or they could keep showing
15942
+ // the "rolling … do not restart the daemon" line after completion.
15943
+ if (!shuttingDown && attachClients.size > 0) {
15944
+ try { broadcast(statusFrame(false)); } catch { /* best effort */ }
15945
+ }
15860
15946
  // Terminal success requires BOTH a clean pass (not interrupted) AND nothing
15861
15947
  // skipped: a skipped worker (failed reload, or removed/absent mid-roll) is a
15862
15948
  // partial reload, so `ok: true` would let the streaming client exit zero and
@@ -15889,6 +15975,18 @@ async function runSupervisorDaemon() {
15889
15975
  // i.e. a `supervisor reload` would adopt new worker code (and a daemon
15890
15976
  // restart new supervisor code). Best-effort; falls back to the daemon's own.
15891
15977
  pluginVersion: (() => { try { return pluginPackage().version; } catch { return daemonVersion; } })(),
15978
+ // Live rolling-reload progress so `supervisor status` (and the attach
15979
+ // view) show a roll that was detached or started by someone else.
15980
+ // `inProgress` is the latch; `current` is the worker being drained
15981
+ // right now (null between respawn and the next drain); `reloaded` /
15982
+ // `targets` / `total` let the renderer print N/M.
15983
+ reload: {
15984
+ inProgress: reloading,
15985
+ current: reloadCurrent,
15986
+ targets: reloadTargets,
15987
+ reloaded: [...reloadDone],
15988
+ total: reloadTargets.length,
15989
+ },
15892
15990
  workers: pub || [...workers.values()].map(workerPublic),
15893
15991
  ...(final ? { final: true } : {}),
15894
15992
  });
@@ -16030,6 +16128,9 @@ async function runSupervisorDaemon() {
16030
16128
  // rolling pass over the same workers. The flag is reset in runReload's
16031
16129
  // `finally`.
16032
16130
  reloading = true;
16131
+ reloadTargets = [...ids];
16132
+ reloadDone = [];
16133
+ reloadCurrent = null;
16033
16134
  attachClients.add(sock);
16034
16135
  sock.write(encodeFrame({ ok: true, type: 'reloading', targets: ids }));
16035
16136
  sock.write(encodeFrame(statusFrame(false)));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "c8ctl-plugin-nano",
3
- "version": "1.70.8",
3
+ "version": "1.72.0",
4
4
  "type": "module",
5
5
  "description": "c8ctl plugin to start, inspect, and stop a local Nano BPM (nanobpmn) cluster",
6
6
  "main": "c8ctl-plugin.js",
@@ -76,12 +76,12 @@
76
76
  },
77
77
  "optionalDependencies": {
78
78
  "node-pty": "^1.0.0",
79
- "@nanobpm/c8ctl-plugin-nano-darwin-arm64": "1.70.8",
80
- "@nanobpm/c8ctl-plugin-nano-darwin-x64": "1.70.8",
81
- "@nanobpm/c8ctl-plugin-nano-linux-x64": "1.70.8",
82
- "@nanobpm/c8ctl-plugin-nano-linux-arm64": "1.70.8",
83
- "@nanobpm/c8ctl-plugin-nano-linux-armv7": "1.70.8",
84
- "@nanobpm/c8ctl-plugin-nano-linux-armv6": "1.70.8",
85
- "@nanobpm/c8ctl-plugin-nano-win32-x64": "1.70.8"
79
+ "@nanobpm/c8ctl-plugin-nano-darwin-arm64": "1.72.0",
80
+ "@nanobpm/c8ctl-plugin-nano-darwin-x64": "1.72.0",
81
+ "@nanobpm/c8ctl-plugin-nano-linux-x64": "1.72.0",
82
+ "@nanobpm/c8ctl-plugin-nano-linux-arm64": "1.72.0",
83
+ "@nanobpm/c8ctl-plugin-nano-linux-armv7": "1.72.0",
84
+ "@nanobpm/c8ctl-plugin-nano-linux-armv6": "1.72.0",
85
+ "@nanobpm/c8ctl-plugin-nano-win32-x64": "1.72.0"
86
86
  }
87
87
  }