nexus-agents 8.8.1 → 8.8.2

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.
@@ -0,0 +1,7 @@
1
+ // src/version.ts
2
+ var VERSION = true ? "8.8.2" : "dev";
3
+
4
+ export {
5
+ VERSION
6
+ };
7
+ //# sourceMappingURL=chunk-H5DTHO7O.js.map
@@ -6,7 +6,7 @@ import {
6
6
  } from "./chunk-OQB3XC5O.js";
7
7
  import {
8
8
  VERSION
9
- } from "./chunk-DROYVWGE.js";
9
+ } from "./chunk-H5DTHO7O.js";
10
10
  import {
11
11
  capitalize
12
12
  } from "./chunk-6T3EPABN.js";
@@ -1201,7 +1201,7 @@ async function runDoctorFix(result) {
1201
1201
  writeLine2("\u2500".repeat(40));
1202
1202
  let fixCount = 0;
1203
1203
  if (!result.dataDirectory.rootExists || result.dataDirectory.subdirectories.some((d) => !d.exists || !d.writable)) {
1204
- const { initDataDirectories: initDataDirectories2, describeDataDirFix: describeDataDirFix2 } = await import("./setup-data-dir-I6LJVAPB.js");
1204
+ const { initDataDirectories: initDataDirectories2, describeDataDirFix: describeDataDirFix2 } = await import("./setup-data-dir-NU3YBIZB.js");
1205
1205
  const outcome = describeDataDirFix2(initDataDirectories2());
1206
1206
  writeLine2(outcome.line);
1207
1207
  if (outcome.counted) fixCount++;
@@ -1303,4 +1303,4 @@ export {
1303
1303
  startStdioServer,
1304
1304
  closeServer
1305
1305
  };
1306
- //# sourceMappingURL=chunk-FUMZUCP2.js.map
1306
+ //# sourceMappingURL=chunk-QY3HOLGD.js.map
@@ -23,7 +23,10 @@ import {
23
23
  toolSuccessStructured,
24
24
  withProgressHeartbeat,
25
25
  wrapToolWithTimeout
26
- } from "./chunk-VBC4JBRH.js";
26
+ } from "./chunk-YQUM3UWK.js";
27
+ import {
28
+ VERSION
29
+ } from "./chunk-H5DTHO7O.js";
27
30
  import {
28
31
  assessPanelIndependence,
29
32
  countDistinctModels,
@@ -5627,8 +5630,33 @@ var JobResultSchema = z8.object({
5627
5630
  * "cancellation can reach this tool", not "the work stopped". Absent means
5628
5631
  * the writer did not report it, which is not the same as `false`.
5629
5632
  */
5630
- signalAccepted: z8.boolean().optional()
5633
+ signalAccepted: z8.boolean().optional(),
5634
+ /**
5635
+ * `VERSION` of the nexus-agents process that WROTE this record (#5008) —
5636
+ * i.e. the build that ran the job, not the build that reads it back.
5637
+ *
5638
+ * `get_job_result` is itself a wrapped tool, so its `_meta['nexus-agents/build']`
5639
+ * stamp (#5056) names the READER's build. After a mid-session global install
5640
+ * the reader and the producer differ, and only the record can say which
5641
+ * build produced the payload. Each writer re-stamps on its own transition,
5642
+ * so a terminal record names the process that settled it.
5643
+ *
5644
+ * Optional so v1 records written before this field existed still parse:
5645
+ * on a SIDECAR record, absence means "produced before this field existed",
5646
+ * not a version of `undefined`. A record adapted from the task-state log
5647
+ * (`jobResultFromTaskState`, selected by `NEXUS_JOB_RESULT_SOURCE=task_state`)
5648
+ * NEVER carries it — that log records no producer version — so a reader
5649
+ * must consult the source (`get_job_result`'s `producerVersionSource`)
5650
+ * before reading absence as age. The value is recorded verbatim, including
5651
+ * `'dev'` — readers MUST run it through {@link isMeasuredBuildVersion}
5652
+ * before treating two stamps as comparable.
5653
+ */
5654
+ producerVersion: z8.string().optional()
5631
5655
  });
5656
+ var UNMEASURED_BUILD_VERSION = "dev";
5657
+ function isMeasuredBuildVersion(version) {
5658
+ return version !== void 0 && version !== "" && version !== UNMEASURED_BUILD_VERSION;
5659
+ }
5632
5660
  function isAbandonedJob(record, nowMs) {
5633
5661
  if (record.status !== "pending") return false;
5634
5662
  const startedMs = Date.parse(record.createdAt);
@@ -5641,7 +5669,7 @@ function persistJobRecord(path, record) {
5641
5669
  writeFileSync3(path, JSON.stringify(record, null, 2), { mode: 384 });
5642
5670
  chmodSync(path, 384);
5643
5671
  }
5644
- function writeJobPending(jobId, toolName, signalAccepted) {
5672
+ function writeJobPending(jobId, toolName, signalAccepted, producerVersion = VERSION) {
5645
5673
  const path = jobResultPath(jobId);
5646
5674
  if (existsSync4(path)) {
5647
5675
  logger7.debug("Job result file already exists \u2014 leaving in place", { jobId });
@@ -5653,12 +5681,13 @@ function writeJobPending(jobId, toolName, signalAccepted) {
5653
5681
  toolName,
5654
5682
  status: "pending",
5655
5683
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
5656
- ...signalAccepted !== void 0 ? { signalAccepted } : {}
5684
+ ...signalAccepted !== void 0 ? { signalAccepted } : {},
5685
+ producerVersion
5657
5686
  };
5658
5687
  persistJobRecord(path, record);
5659
5688
  logger7.debug("Wrote pending job record", { jobId, toolName, signalAccepted });
5660
5689
  }
5661
- function writeJobComplete(jobId, toolName, result) {
5690
+ function writeJobComplete(jobId, toolName, result, producerVersion = VERSION) {
5662
5691
  const existing = readJobResult(jobId);
5663
5692
  if (existing?.status === "cancelled") {
5664
5693
  logger7.debug("Skipping complete write \u2014 job already cancelled (preserving cancellation)", {
@@ -5674,12 +5703,13 @@ function writeJobComplete(jobId, toolName, result) {
5674
5703
  status: "complete",
5675
5704
  createdAt: existing?.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
5676
5705
  completedAt: (/* @__PURE__ */ new Date()).toISOString(),
5677
- result
5706
+ result,
5707
+ producerVersion
5678
5708
  };
5679
5709
  persistJobRecord(jobResultPath(jobId), record);
5680
5710
  logger7.debug("Wrote complete job record", { jobId, toolName });
5681
5711
  }
5682
- function writeJobFailed(jobId, toolName, error) {
5712
+ function writeJobFailed(jobId, toolName, error, producerVersion = VERSION) {
5683
5713
  const existing = readJobResult(jobId);
5684
5714
  if (existing?.status === "cancelled") {
5685
5715
  logger7.debug("Skipping failed write \u2014 job already cancelled (preserving cancellation)", {
@@ -5695,12 +5725,13 @@ function writeJobFailed(jobId, toolName, error) {
5695
5725
  status: "failed",
5696
5726
  createdAt: existing?.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
5697
5727
  completedAt: (/* @__PURE__ */ new Date()).toISOString(),
5698
- error
5728
+ error,
5729
+ producerVersion
5699
5730
  };
5700
5731
  persistJobRecord(jobResultPath(jobId), record);
5701
5732
  logger7.debug("Wrote failed job record", { jobId, toolName, error });
5702
5733
  }
5703
- function writeJobCancelled(jobId, toolName, reason) {
5734
+ function writeJobCancelled(jobId, toolName, reason, producerVersion = VERSION) {
5704
5735
  const record = {
5705
5736
  v: 1,
5706
5737
  jobId,
@@ -5708,7 +5739,8 @@ function writeJobCancelled(jobId, toolName, reason) {
5708
5739
  status: "cancelled",
5709
5740
  createdAt: readJobResult(jobId)?.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
5710
5741
  completedAt: (/* @__PURE__ */ new Date()).toISOString(),
5711
- ...reason !== void 0 ? { error: reason } : {}
5742
+ ...reason !== void 0 ? { error: reason } : {},
5743
+ producerVersion
5712
5744
  };
5713
5745
  persistJobRecord(jobResultPath(jobId), record);
5714
5746
  logger7.debug("Wrote cancelled job record", { jobId, toolName, reason });
@@ -6108,7 +6140,7 @@ function runAsJob(params) {
6108
6140
  return env.busy(suggestRetryAfterMs(params.toolName), params.toolName);
6109
6141
  }
6110
6142
  const jobId = idempotency.jobId;
6111
- writeJobPending(jobId, params.toolName, params.run.length >= 3);
6143
+ writeJobPending(jobId, params.toolName, params.run.length >= 3, params.producerVersion);
6112
6144
  if (params.idempotencyKey !== void 0 && params.idempotencyKey !== "") {
6113
6145
  registerIdempotentJob({
6114
6146
  tool: params.toolName,
@@ -6131,7 +6163,7 @@ async function runJobInBackground(jobId, params) {
6131
6163
  ]);
6132
6164
  const failure = detectFailureShapedResult(result);
6133
6165
  if (failure !== null && params.allowFailureShapedResult === void 0) {
6134
- writeJobFailed(jobId, params.toolName, describeFailureShape(failure));
6166
+ writeJobFailed(jobId, params.toolName, describeFailureShape(failure), params.producerVersion);
6135
6167
  } else {
6136
6168
  if (failure !== null) {
6137
6169
  params.logger?.warn(
@@ -6139,12 +6171,12 @@ async function runJobInBackground(jobId, params) {
6139
6171
  { jobId, key: failure.key, reason: params.allowFailureShapedResult }
6140
6172
  );
6141
6173
  }
6142
- writeJobComplete(jobId, params.toolName, result);
6174
+ writeJobComplete(jobId, params.toolName, result, params.producerVersion);
6143
6175
  }
6144
6176
  } catch (err2) {
6145
6177
  const errObj = err2 instanceof Error ? err2 : new Error(String(err2));
6146
6178
  params.logger?.error(`Async ${params.toolName} dispatch failed`, errObj, { jobId });
6147
- writeJobFailed(jobId, params.toolName, errObj.message);
6179
+ writeJobFailed(jobId, params.toolName, errObj.message, params.producerVersion);
6148
6180
  } finally {
6149
6181
  guard.clear();
6150
6182
  unregisterJobAbort(jobId);
@@ -6858,6 +6890,7 @@ function registerConsensusVoteTool(server, deps) {
6858
6890
  export {
6859
6891
  VOTER_ROLES,
6860
6892
  JobStatusSchema,
6893
+ isMeasuredBuildVersion,
6861
6894
  isAbandonedJob,
6862
6895
  writeJobCancelled,
6863
6896
  readJobResult,
@@ -6939,4 +6972,4 @@ export {
6939
6972
  CONSENSUS_VOTE_TOOL_SCHEMA,
6940
6973
  registerConsensusVoteTool
6941
6974
  };
6942
- //# sourceMappingURL=chunk-OCAMHBJ6.js.map
6975
+ //# sourceMappingURL=chunk-SQCFKQUR.js.map