teapot-coding-agent 0.37.46 → 0.37.48

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/master.js CHANGED
@@ -2167,12 +2167,24 @@ When this task is done (or truly blocked), call finish() with a summary for @${p
2167
2167
  archivedAgents() {
2168
2168
  const archived = this.config.agents.filter((a) => a.archived);
2169
2169
  const ids = new Set(archived.map((a) => a.id));
2170
+ /**
2171
+ * ONE session scan for the whole list.
2172
+ *
2173
+ * `sessionsOf(id)` calls `allSessions()`, which reads every session directory, stats each log
2174
+ * and backfills a manifest for any that lacks one — so mapping over the archived entries made
2175
+ * this O(archived × sessions). Reported as "🗄 archive のロードが遅すぎる". Counting from a
2176
+ * single scan makes it O(sessions) once, which is what the list actually needs: how many
2177
+ * sessions each entry has.
2178
+ */
2179
+ const sessionCounts = new Map();
2180
+ for (const s of this.allSessions())
2181
+ sessionCounts.set(s.agentId, (sessionCounts.get(s.agentId) ?? 0) + 1);
2170
2182
  return archived
2171
2183
  .map((a) => ({
2172
2184
  id: a.id,
2173
2185
  workspace: a.workspace,
2174
2186
  ...(a.archivedAt !== undefined ? { archivedAt: a.archivedAt } : {}),
2175
- sessions: this.sessionsOf(a.id).length,
2187
+ sessions: sessionCounts.get(a.id) ?? 0,
2176
2188
  // A sub-agent is listed under its parent rather than as an equal entry: the
2177
2189
  // operator archived ONE thing, and a flat list of every descendant makes it
2178
2190
  // look like they did several. Only an ARCHIVED parent counts — otherwise a
@@ -2371,8 +2383,28 @@ When this task is done (or truly blocked), call finish() with a summary for @${p
2371
2383
  const cu = process.cpuUsage();
2372
2384
  return {
2373
2385
  uptimeSec: Math.floor((Date.now() - this.startedAt) / 1000),
2386
+ /**
2387
+ * `rssMb` is the process's RESIDENT size, which is not a leak gauge.
2388
+ *
2389
+ * V8 keeps freed pages in its arenas instead of returning them, so RSS sits well above the
2390
+ * live set and only falls on a major GC — reported as "メモリ使用量が多い ... さっきはheapが
2391
+ * 400MBあったのでGCされた?". MEASURED on this machine (442 agents, 836 sessions): a fresh boot
2392
+ * was 37MB heap, and 490 `/api/sessions` calls took it to 50MB heap / 203MB RSS and no
2393
+ * further — flat, GC-reclaimable, not a leak. `heapUsedMb` is the number that answers "is
2394
+ * something growing"; `rssMb` alone cannot, which is why both are reported.
2395
+ */
2374
2396
  rssMb: +(mu.rss / 1048576).toFixed(1),
2375
2397
  heapUsedMb: +(mu.heapUsed / 1048576).toFixed(1),
2398
+ /**
2399
+ * What V8 has actually committed to the heap.
2400
+ *
2401
+ * `heapUsedMb` includes garbage that has not been collected yet, so it can read 400MB one
2402
+ * minute and 200MB the next without anything having been freed to the OS. `heapTotal` after a
2403
+ * GC is the live-set answer, reported by node's own counters so it exists on every platform.
2404
+ */
2405
+ heapTotalMb: +(mu.heapTotal / 1048576).toFixed(1),
2406
+ /** non-heap memory: buffers, native strings, the compiled bundle — the usual RSS/heap gap */
2407
+ externalMb: +(mu.external / 1048576).toFixed(1),
2376
2408
  /**
2377
2409
  * `process.cpuUsage()` reports MICROseconds, so this is divided by 1000.
2378
2410
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "teapot-coding-agent",
3
- "version": "0.37.46",
3
+ "version": "0.37.48",
4
4
  "description": "A lightweight, always-on multi-agent harness for AI coding agents",
5
5
  "type": "module",
6
6
  "license": "AGPL-3.0-or-later",