@feigi/fleet-ctl 3.126.0 → 3.126.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@feigi/fleet-ctl",
3
- "version": "3.126.0",
3
+ "version": "3.126.1",
4
4
  "description": "Agent fleet: run-team controller, merge bot, PR reviewer, and the ticket pipeline they share",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -14,7 +14,7 @@
14
14
  import { readdirSync, readFileSync, statSync } from "node:fs";
15
15
  import { join, basename, dirname } from "node:path";
16
16
 
17
- import { readOmpSession, normalizeModel, parseMemberName } from "./member-record.mjs";
17
+ import { readOmpSession, normalizeModel, parseMemberName, stampMs } from "./member-record.mjs";
18
18
  import { isOmpSessionDirName } from "./ledger-grammar.mjs";
19
19
  import { stripLevel } from "./tier-roles.mjs";
20
20
  import { reportFamily, reportStatus, defaultScratch } from "./report-files.mjs";
@@ -132,10 +132,12 @@ export const HALT_MS = 60 * 60 * 1000;
132
132
 
133
133
  // The controller transcript's entry instants, in epoch ms, or a string naming
134
134
  // why they cannot be had. It is not a member transcript, so a line is read for
135
- // its timestamp alone. An unparseable LAST line is a write in progress and is
136
- // skipped, as the member fold skips it; an unparseable line before it is lost
137
- // data that may have been the entry breaking a stretch, so a halt there could
138
- // not be told from the run writing, and the instants are unknown.
135
+ // its timestamp alone, under the member fold's own stamp rule (stampMs): a
136
+ // line whose stamp fails it is no instant. An unparseable LAST line is a
137
+ // write in progress and is skipped, as the member fold skips it; an
138
+ // unparseable line before it is lost data that may have been the entry
139
+ // breaking a stretch, so a halt there could not be told from the run
140
+ // writing, and the instants are unknown.
139
141
  function controllerStamps(sessionDir) {
140
142
  let text;
141
143
  try { text = readFileSync(join(dirname(sessionDir), `${basename(sessionDir)}.jsonl`), "utf8"); }
@@ -147,7 +149,7 @@ function controllerStamps(sessionDir) {
147
149
  let d;
148
150
  try { d = JSON.parse(lines[i]); }
149
151
  catch { if (i !== lines.length - 1) return "an unparseable controller transcript line"; continue; }
150
- const ms = typeof d?.timestamp === "string" ? Date.parse(d.timestamp) : NaN;
152
+ const ms = stampMs(d?.timestamp);
151
153
  if (Number.isFinite(ms)) stamps.push(ms);
152
154
  }
153
155
  return stamps;
@@ -368,8 +368,8 @@ export function foldOmpTranscript(jsonlText, filePath) {
368
368
  let input = 0, cacheWrite = 0, cacheWrite1h = 0, cacheRead = 0, output = 0, cost = 0, turns = 0;
369
369
  let sawCost = false, unsplit = false, unpriced = false;
370
370
  let malformedNonLastLines = 0;
371
- // Entries that carry a `timestamp` from which no finite instant was read;
372
- // an entry with no `timestamp` at all is ordinary and not counted.
371
+ // Entries that carry a `timestamp` that is no stamp under stampMs; an entry
372
+ // with no `timestamp` at all is ordinary and not counted.
373
373
  let unparseableStamps = 0;
374
374
  // What the transcript's END says, read for the `ending` column: the last
375
375
  // assistant turn's stopReason, whether a model fell back, whether the
@@ -393,7 +393,7 @@ export function foldOmpTranscript(jsonlText, filePath) {
393
393
  try { d = JSON.parse(raw); }
394
394
  catch { if (i !== lines.length - 1) malformedNonLastLines++; continue; }
395
395
  assertOmpShaped(d, filePath);
396
- const ms = typeof d.timestamp === "string" ? Date.parse(d.timestamp) : NaN;
396
+ const ms = stampMs(d.timestamp);
397
397
  if (Number.isFinite(ms)) stamps.push(ms);
398
398
  else if (Object.hasOwn(d, "timestamp")) unparseableStamps++;
399
399
  if (d.type === "custom" && d.customType === "session_exit") {
@@ -450,10 +450,10 @@ export function foldOmpTranscript(jsonlText, filePath) {
450
450
  if (d.type === "message" && m?.role === "user" && messageText(m).trimStart().startsWith("[budget notice]")) budgetNotice = true;
451
451
  }
452
452
  if (partFirst !== null) workParts.push([partFirst, partLast]);
453
- // `wall_s` is the span of the parseable stamps, latest minus earliest, so it
454
- // does not depend on file order and cannot go negative; an unparseable
455
- // stamp is skipped, and a transcript with none spans 0. `startedAt` is the
456
- // same earliest stamp as an ISO string, or null when none parsed.
453
+ // `wall_s` is the span of the stamps stampMs accepts, latest minus
454
+ // earliest, so it does not depend on file order and cannot go negative; any
455
+ // other stamp is skipped, and a transcript with none spans 0. `startedAt` is
456
+ // the same earliest stamp as an ISO string, or null when none was accepted.
457
457
  let earliest = Infinity, latest = -Infinity;
458
458
  for (const t of stamps) { if (t < earliest) earliest = t; if (t > latest) latest = t; }
459
459
  const span = stamps.length ? (latest - earliest) / 1000 : 0;
@@ -484,6 +484,18 @@ export function foldOmpTranscript(jsonlText, filePath) {
484
484
  };
485
485
  }
486
486
 
487
+ // A transcript entry's `timestamp` as epoch ms, or NaN when it is no stamp.
488
+ // The one stamp rule for every transcript reader: a string in the ECMAScript
489
+ // date-time form with a time of day and an explicit zone —
490
+ // `YYYY-MM-DDTHH:mm`, optional `:ss` and fractional seconds, then `Z` or
491
+ // `±HH:mm` — that Date.parse reads as a finite instant. Date.parse alone
492
+ // also reads strings such as "1" or "2026" as instants, a date-only string
493
+ // has no time of day, and a zone-less one depends on the host's time zone.
494
+ const STAMP_RE = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}:\d{2})$/;
495
+ export function stampMs(timestamp) {
496
+ return typeof timestamp === "string" && STAMP_RE.test(timestamp) ? Date.parse(timestamp) : NaN;
497
+ }
498
+
487
499
  // The report files one transcript tool call writes, as { file, content } with
488
500
  // `file` the written path's basename: the `write` tool's arguments, or each
489
501
  // report a `bash` call writes with a heredoc (`heredocReportWrites`). Only a