modelstat 0.0.53 → 0.1.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/dist/cli.mjs CHANGED
@@ -47286,6 +47286,14 @@ async function scanAll(cb = {}) {
47286
47286
  } catch (e) {
47287
47287
  console.warn("codex scan skipped:", e.message);
47288
47288
  }
47289
+ const ordered = (await Promise.all(
47290
+ jobs.map(async (j) => ({
47291
+ job: j,
47292
+ mtimeMs: (await stat2(j.path).catch(() => null))?.mtimeMs ?? 0
47293
+ }))
47294
+ )).sort((a, b) => b.mtimeMs - a.mtimeMs).map((x) => x.job);
47295
+ const MAX_FILES_PER_SCAN = 12;
47296
+ let morePending = false;
47289
47297
  let filesScanned = 0;
47290
47298
  let filesUnchanged = 0;
47291
47299
  let batchesUploaded = 0;
@@ -47367,9 +47375,9 @@ async function scanAll(cb = {}) {
47367
47375
  toolCallBuffer.push(c);
47368
47376
  }
47369
47377
  };
47370
- for (let i = 0; i < jobs.length; i++) {
47371
- const job = jobs[i];
47372
- cb.onFile?.(job.path, i, jobs.length);
47378
+ for (let i = 0; i < ordered.length; i++) {
47379
+ const job = ordered[i];
47380
+ cb.onFile?.(job.path, i, ordered.length);
47373
47381
  const cur = state.getCursor(job.path);
47374
47382
  const cs = await quickChecksum(job.path).catch(() => null);
47375
47383
  if (cs && cur && cur.size === cs.size && cur.tailHash === cs.tailHash) {
@@ -47392,9 +47400,20 @@ async function scanAll(cb = {}) {
47392
47400
  } catch (e) {
47393
47401
  console.warn(` ! parse failed for ${job.path}:`, e.message);
47394
47402
  }
47403
+ if (filesScanned >= MAX_FILES_PER_SCAN) {
47404
+ morePending = true;
47405
+ break;
47406
+ }
47395
47407
  }
47396
47408
  await flushBatch();
47397
- return { filesScanned, filesUnchanged, batchesUploaded, eventsUploaded, segmentsUploaded };
47409
+ return {
47410
+ filesScanned,
47411
+ filesUnchanged,
47412
+ batchesUploaded,
47413
+ eventsUploaded,
47414
+ segmentsUploaded,
47415
+ morePending
47416
+ };
47398
47417
  }
47399
47418
  var AGENT_VERSION, BATCH_MAX_EVENTS, BATCH_MAX_TOOL_CALLS, BATCH_BUFFER_HARD_CAP, ZERO_TOKENS;
47400
47419
  var init_scan = __esm({
@@ -47407,7 +47426,7 @@ var init_scan = __esm({
47407
47426
  init_api();
47408
47427
  init_config2();
47409
47428
  init_pipeline2();
47410
- AGENT_VERSION = true ? "agent-0.0.53" : "agent-dev";
47429
+ AGENT_VERSION = true ? "agent-0.1.1" : "agent-dev";
47411
47430
  BATCH_MAX_EVENTS = INGEST_BATCH_MAX_EVENTS;
47412
47431
  BATCH_MAX_TOOL_CALLS = 2e4;
47413
47432
  BATCH_BUFFER_HARD_CAP = BATCH_MAX_EVENTS * 2;
@@ -49771,8 +49790,13 @@ async function runScanCycle(reason) {
49771
49790
  });
49772
49791
  bumpStat("files_scanned", r.filesScanned);
49773
49792
  bumpStat("files_unchanged", r.filesUnchanged);
49774
- setPhase("watching", "Waiting for new events");
49775
- setProgress(0, 0);
49793
+ if (r.morePending) {
49794
+ setPhase("processing", "Catching up on history\u2026");
49795
+ setTimeout(() => void requestScan("backfill"), 250);
49796
+ } else {
49797
+ setPhase("watching", "Waiting for new events");
49798
+ setProgress(0, 0);
49799
+ }
49776
49800
  } catch (e) {
49777
49801
  setStat("segments_sending", 0);
49778
49802
  setPhase("offline", `Upload failed: ${describeErrorWithCause(e)}`);
@@ -49907,7 +49931,7 @@ var init_daemon = __esm({
49907
49931
  init_machine_key();
49908
49932
  init_scan();
49909
49933
  init_single_flight();
49910
- AGENT_VERSION2 = true ? "agent-0.0.53" : "agent-dev";
49934
+ AGENT_VERSION2 = true ? "agent-0.1.1" : "agent-dev";
49911
49935
  HEARTBEAT_INTERVAL_MS = 1e4;
49912
49936
  SCAN_INTERVAL_MS = 5 * 60 * 1e3;
49913
49937
  DISCOVERY_INTERVAL_MS = 6e4;
@@ -50175,8 +50199,7 @@ function locateTrayExecutable() {
50175
50199
  function writePlist(cliPath) {
50176
50200
  const p = plistPath();
50177
50201
  mkdirSync3(dirname6(p), { recursive: true });
50178
- const tray = locateTrayExecutable();
50179
- const programArgs = tray ? ` <string>${tray}</string>` : [
50202
+ const programArgs = [
50180
50203
  ` <string>${nodeBinary()}</string>`,
50181
50204
  ` <string>${cliPath}</string>`,
50182
50205
  ` <string>start</string>`
@@ -50201,8 +50224,7 @@ ${programArgs}
50201
50224
  <key>PATH</key><string>/usr/local/bin:/opt/homebrew/bin:/usr/bin:/bin</string>
50202
50225
  <!-- Heap headroom for the startup scan of a large transcript backlog.
50203
50226
  Node's default old-space ceiling (~4 GB) OOM-crashed the daemon on
50204
- big histories; raise it well below typical RAM. Inherited by the
50205
- tray-spawned 'modelstat start' child too (NODE_OPTIONS propagates). -->
50227
+ big histories; raise it well below typical RAM. -->
50206
50228
  <key>NODE_OPTIONS</key><string>--max-old-space-size=8192</string>
50207
50229
  </dict>
50208
50230
  <key>WorkingDirectory</key><string>${home()}</string>
@@ -50509,7 +50531,7 @@ function tryOpenBrowser(url) {
50509
50531
  return false;
50510
50532
  }
50511
50533
  }
50512
- var AGENT_VERSION3 = true ? "agent-0.0.53" : "agent-dev";
50534
+ var AGENT_VERSION3 = true ? "agent-0.1.1" : "agent-dev";
50513
50535
  function osFamily() {
50514
50536
  const p = platform5();
50515
50537
  if (p === "darwin") return "macos";