@nodii/dev 0.6.77 → 0.6.79

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/watchdog.js CHANGED
@@ -5,6 +5,7 @@ import { dirname, isAbsolute, join, resolve } from "node:path";
5
5
  import { promisify } from "node:util";
6
6
  import { CliError, configPath, devRequest, encode, readConfig } from "./core.js";
7
7
  import { USAGE_REFRESH_MS, listAccounts, reportUsage } from "./accounts.js";
8
+ import { laneCloseout } from "./lanes.js";
8
9
 
9
10
  const execFile = promisify(execFileCallback);
10
11
  export const WATCHDOG_LABEL = "com.nodii.watchdog";
@@ -245,6 +246,7 @@ export async function sweepWatchdog({
245
246
  machineId,
246
247
  now = () => new Date(),
247
248
  refreshUsage = refreshMachineUsage,
249
+ closeout = laneCloseout,
248
250
  saveReminder = saveLaneCapReminder,
249
251
  } = {}) {
250
252
  const loaded = records ? { records, errors: [] } : await loadRecords();
@@ -252,6 +254,7 @@ export async function sweepWatchdog({
252
254
  const byId = new Map(loaded.records.map((record) => [record.runId, record]));
253
255
  const effectiveMachineId = machineId ?? (await coordinatorMachine({ request })).machineId;
254
256
  const orphanedRuns = [];
257
+ const finalOrphanCloseouts = [];
255
258
  // Dev's live runs are the authority, not the local flags (NODII-DEV-CLI-42):
256
259
  // a run Dev still holds as running gets its dead process reported again, and
257
260
  // a run with no local record is one this sweep cannot see. Without Dev's list
@@ -325,6 +328,17 @@ export async function sweepWatchdog({
325
328
  if (response?.data?.run?.livenessState === "orphan") {
326
329
  record.orphanReportedAt = observedAt;
327
330
  orphanedRuns.push({ runId: record.runId, pid: record.pid, reportedAt: record.orphanReportedAt });
331
+ // hub-244: an Orphan that turned final (no automatic relaunch)
332
+ // closes out here; Dev released its holds in the same report.
333
+ const run = response.data.run;
334
+ if (run.kind === "lane" && run.laneId && run.autoRelaunchAllowed === false) {
335
+ try {
336
+ const result = await closeout(run.laneId, run.failureReason ?? "final Orphan: the same death twice", { request });
337
+ finalOrphanCloseouts.push({ runId: record.runId, laneId: run.laneId, repositories: result.repositories });
338
+ } catch (error) {
339
+ facts.errors.push({ kind: "closeout", runId: record.runId, code: error?.code ?? "LANE_CLOSEOUT_FAILED" });
340
+ }
341
+ }
328
342
  } else if (["done", "handed_off", "failed", "blocked"].includes(response?.data?.run?.status)) {
329
343
  record.terminalSeenAt = observedAt;
330
344
  } else {
@@ -353,7 +367,7 @@ export async function sweepWatchdog({
353
367
  } catch (error) {
354
368
  facts.errors.push({ kind: "lane_cap", code: error?.code ?? "LANE_CAP_READ_FAILED" });
355
369
  }
356
- const report = { ...facts, orphanedRuns, unwatchedRuns, accounts, laneCap };
370
+ const report = { ...facts, orphanedRuns, finalOrphanCloseouts, unwatchedRuns, accounts, laneCap };
357
371
  return report;
358
372
  }
359
373
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nodii/dev",
3
- "version": "0.6.77",
3
+ "version": "0.6.79",
4
4
  "description": "Agent CLI for Nodii Dev, reached through the platform edge",
5
5
  "type": "module",
6
6
  "bin": {