mixdog 0.9.166 → 0.9.167

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.
Files changed (221) hide show
  1. package/package.json +1 -1
  2. package/scripts/audit-usage-ledger.mjs +86 -0
  3. package/scripts/generate-voice-runtime-manifest.mjs +22 -17
  4. package/scripts/memory-chunk-quality.mjs +128 -0
  5. package/scripts/memory-layer2-check.mjs +133 -0
  6. package/scripts/model-catalog-audit.mjs +6 -0
  7. package/scripts/native-tool-download.mjs +14 -0
  8. package/scripts/prepare-native-assets.mjs +2 -7
  9. package/scripts/tool-failures.mjs +7 -2
  10. package/scripts/verify-release-assets.mjs +48 -90
  11. package/src/defaults/skills/browser-use/SKILL.md +33 -18
  12. package/src/defaults/skills/computer-use/SKILL.md +16 -8
  13. package/src/lib/keychain-cjs.cjs +0 -1
  14. package/src/lib/rules-builder.cjs +4 -1
  15. package/src/rules/agent/40-cycle1-agent.md +21 -13
  16. package/src/rules/lead/01-general.md +8 -3
  17. package/src/rules/shared/10-tool-workflow.md +20 -11
  18. package/src/rules/shared/30-exploration.md +11 -4
  19. package/src/rules/shared/40-editing.md +2 -3
  20. package/src/rules/shared/50-execution.md +6 -3
  21. package/src/rules/shared/60-verification.md +3 -2
  22. package/src/rules/shared/70-delivery.md +0 -4
  23. package/src/runtime/agent/orchestrator/agent-runtime/agent-dispatch.mjs +51 -45
  24. package/src/runtime/agent/orchestrator/agent-runtime/agent-progress-watchdog.mjs +3 -4
  25. package/src/runtime/agent/orchestrator/agent-trace-format.mjs +44 -7
  26. package/src/runtime/agent/orchestrator/agent-trace.mjs +9 -0
  27. package/src/runtime/agent/orchestrator/config.mjs +9 -4
  28. package/src/runtime/agent/orchestrator/context/collect.mjs +25 -1055
  29. package/src/runtime/agent/orchestrator/context/deferred-tools.mjs +272 -0
  30. package/src/runtime/agent/orchestrator/context/role-instructions.mjs +296 -0
  31. package/src/runtime/agent/orchestrator/context/skill-catalog.mjs +523 -0
  32. package/src/runtime/agent/orchestrator/providers/account-pool.mjs +7 -2
  33. package/src/runtime/agent/orchestrator/providers/anthropic-sse.mjs +13 -14
  34. package/src/runtime/agent/orchestrator/providers/antigravity-oauth-catalog.mjs +214 -0
  35. package/src/runtime/agent/orchestrator/providers/antigravity-oauth-login.mjs +220 -116
  36. package/src/runtime/agent/orchestrator/providers/antigravity-oauth-tokens.mjs +74 -44
  37. package/src/runtime/agent/orchestrator/providers/antigravity-oauth.mjs +191 -29
  38. package/src/runtime/agent/orchestrator/providers/antigravity-request.mjs +13 -12
  39. package/src/runtime/agent/orchestrator/providers/cursor-wire-guards.mjs +1 -9
  40. package/src/runtime/agent/orchestrator/providers/cursor-wire-protobuf.mjs +5 -2
  41. package/src/runtime/agent/orchestrator/providers/cursor-wire.mjs +48 -25
  42. package/src/runtime/agent/orchestrator/providers/gemini-schema.mjs +28 -2
  43. package/src/runtime/agent/orchestrator/providers/gemini-stream.mjs +3 -1
  44. package/src/runtime/agent/orchestrator/providers/grok-oauth-tokens.mjs +1 -8
  45. package/src/runtime/agent/orchestrator/providers/lib/action-input-contract.mjs +32 -0
  46. package/src/runtime/agent/orchestrator/providers/lib/anthropic-request-utils.mjs +21 -6
  47. package/src/runtime/agent/orchestrator/providers/lib/grok-tool-schema.mjs +61 -13
  48. package/src/runtime/agent/orchestrator/providers/model-catalog-projection.mjs +6 -1
  49. package/src/runtime/agent/orchestrator/providers/model-catalog.mjs +123 -118
  50. package/src/runtime/agent/orchestrator/providers/model-pricing-rates.mjs +54 -0
  51. package/src/runtime/agent/orchestrator/providers/oauth-credential-probes.mjs +5 -2
  52. package/src/runtime/agent/orchestrator/providers/oauth-usage.mjs +34 -3
  53. package/src/runtime/agent/orchestrator/providers/openai-codex-endpoints.mjs +21 -0
  54. package/src/runtime/agent/orchestrator/providers/openai-oauth-catalog.mjs +154 -0
  55. package/src/runtime/agent/orchestrator/providers/openai-oauth-http-sse.mjs +2 -1
  56. package/src/runtime/agent/orchestrator/providers/openai-oauth-tokens.mjs +322 -0
  57. package/src/runtime/agent/orchestrator/providers/openai-oauth.mjs +243 -702
  58. package/src/runtime/agent/orchestrator/providers/openai-responses-payload.mjs +2 -2
  59. package/src/runtime/agent/orchestrator/providers/openai-startup-prewarm.mjs +221 -0
  60. package/src/runtime/agent/orchestrator/providers/openai-ws-stream.mjs +3 -2
  61. package/src/runtime/agent/orchestrator/providers/openai-ws.mjs +1 -1
  62. package/src/runtime/agent/orchestrator/providers/provider-catalog-cache.mjs +19 -0
  63. package/src/runtime/agent/orchestrator/providers/provider-model-identities.mjs +40 -0
  64. package/src/runtime/agent/orchestrator/session/agent-loop.mjs +120 -710
  65. package/src/runtime/agent/orchestrator/session/cache/read-cache.mjs +36 -15
  66. package/src/runtime/agent/orchestrator/session/cache/util.mjs +9 -0
  67. package/src/runtime/agent/orchestrator/session/compact/execution-tail.mjs +17 -4
  68. package/src/runtime/agent/orchestrator/session/compact/runner.mjs +36 -31
  69. package/src/runtime/agent/orchestrator/session/compact.mjs +4 -5
  70. package/src/runtime/agent/orchestrator/session/context-compaction-policy.mjs +6 -5
  71. package/src/runtime/agent/orchestrator/session/eager-dispatch.mjs +8 -6
  72. package/src/runtime/agent/orchestrator/session/loop/assistant-commit.mjs +121 -0
  73. package/src/runtime/agent/orchestrator/session/loop/compact-policy.mjs +2 -3
  74. package/src/runtime/agent/orchestrator/session/loop/diagnostics.mjs +74 -0
  75. package/src/runtime/agent/orchestrator/session/loop/fresh-context.mjs +44 -17
  76. package/src/runtime/agent/orchestrator/session/loop/no-tool-turn.mjs +266 -0
  77. package/src/runtime/agent/orchestrator/session/loop/request-boundary.mjs +111 -0
  78. package/src/runtime/agent/orchestrator/session/loop/request-projection.mjs +99 -0
  79. package/src/runtime/agent/orchestrator/session/loop/steering.mjs +91 -0
  80. package/src/runtime/agent/orchestrator/session/loop/usage.mjs +36 -0
  81. package/src/runtime/agent/orchestrator/session/manager/compaction-runner.mjs +3 -3
  82. package/src/runtime/agent/orchestrator/session/manager/runtime-liveness.mjs +12 -0
  83. package/src/runtime/agent/orchestrator/session/manager/session-lifecycle.mjs +20 -11
  84. package/src/runtime/agent/orchestrator/session/pre-send-compact.mjs +3 -5
  85. package/src/runtime/agent/orchestrator/session/send-with-recovery.mjs +9 -3
  86. package/src/runtime/agent/orchestrator/session/store-summary-reader.mjs +39 -0
  87. package/src/runtime/agent/orchestrator/session/store-transcript-cache.mjs +3 -2
  88. package/src/runtime/agent/orchestrator/session/tool-batch.mjs +21 -3
  89. package/src/runtime/agent/orchestrator/tools/builtin/arg-guard.mjs +1 -1
  90. package/src/runtime/agent/orchestrator/tools/builtin/bash-tool.mjs +2 -3
  91. package/src/runtime/agent/orchestrator/tools/builtin/builtin-tools.mjs +25 -25
  92. package/src/runtime/agent/orchestrator/tools/builtin/git-command-tool.mjs +62 -10
  93. package/src/runtime/agent/orchestrator/tools/builtin/path-utils.mjs +17 -0
  94. package/src/runtime/agent/orchestrator/tools/builtin/read-batch.mjs +61 -4
  95. package/src/runtime/agent/orchestrator/tools/builtin/read-single-tool.mjs +13 -9
  96. package/src/runtime/agent/orchestrator/tools/builtin/read-snapshot-runtime.mjs +12 -2
  97. package/src/runtime/agent/orchestrator/tools/builtin/read-streaming.mjs +3 -2
  98. package/src/runtime/agent/orchestrator/tools/builtin/read-tool.mjs +8 -3
  99. package/src/runtime/agent/orchestrator/tools/builtin/runtime-capabilities.mjs +69 -6
  100. package/src/runtime/agent/orchestrator/tools/builtin.mjs +14 -17
  101. package/src/runtime/agent/orchestrator/tools/code-graph/dispatch.mjs +1 -1
  102. package/src/runtime/agent/orchestrator/tools/code-graph/source-access.mjs +1 -1
  103. package/src/runtime/agent/orchestrator/tools/code-graph-tool-defs.mjs +6 -6
  104. package/src/runtime/agent/orchestrator/tools/patch-tool-defs.mjs +1 -1
  105. package/src/runtime/bridge-discovery.mjs +8 -0
  106. package/src/runtime/browser-bridge/action-schema.mjs +37 -43
  107. package/src/runtime/browser-bridge/client.mjs +111 -99
  108. package/src/runtime/browser-bridge/input-fields.mjs +187 -0
  109. package/src/runtime/browser-bridge/tool-defs.mjs +12 -227
  110. package/src/runtime/computer-bridge/action-schema.mjs +2 -46
  111. package/src/runtime/computer-bridge/client.mjs +69 -77
  112. package/src/runtime/computer-bridge/core-actions.mjs +7 -5
  113. package/src/runtime/computer-bridge/error-recovery.mjs +41 -37
  114. package/src/runtime/computer-bridge/tool-defs.mjs +1 -1
  115. package/src/runtime/github/commands.mjs +4 -1
  116. package/src/runtime/github/contract.mjs +1 -1
  117. package/src/runtime/github/tool.mjs +2 -2
  118. package/src/runtime/media/adapters/antigravity-image.mjs +72 -0
  119. package/src/runtime/media/adapters/gemini-image.mjs +20 -11
  120. package/src/runtime/media/auth.mjs +12 -0
  121. package/src/runtime/media/catalog.mjs +30 -10
  122. package/src/runtime/media/jobs.mjs +4 -0
  123. package/src/runtime/media/lanes.mjs +40 -31
  124. package/src/runtime/memory/index.mjs +2 -9
  125. package/src/runtime/memory/lib/compact-handoff.mjs +26 -18
  126. package/src/runtime/memory/lib/memory-chunk-audit.mjs +41 -0
  127. package/src/runtime/memory/lib/memory-chunk-quality.mjs +388 -0
  128. package/src/runtime/memory/lib/memory-cycle1.mjs +95 -394
  129. package/src/runtime/memory/lib/memory-recall-scope-filter.mjs +29 -4
  130. package/src/runtime/memory/lib/memory-recall-store.mjs +8 -12
  131. package/src/runtime/memory/lib/memory-retrievers.mjs +8 -11
  132. package/src/runtime/memory/lib/memory.mjs +2 -0
  133. package/src/runtime/memory/lib/query-handlers.mjs +98 -144
  134. package/src/runtime/memory/lib/query-ranking.mjs +23 -9
  135. package/src/runtime/memory/lib/recall-format.mjs +37 -27
  136. package/src/runtime/memory/lib/session-ingest-runtime.mjs +14 -8
  137. package/src/runtime/memory/lib/session-ingest.mjs +45 -84
  138. package/src/runtime/memory/lib/transcript-ingest.mjs +19 -21
  139. package/src/runtime/memory/tool-defs.mjs +2 -2
  140. package/src/runtime/office/authoring/pptx-author-session.mjs +3 -7
  141. package/src/runtime/office/core/office-actions-batch.mjs +2 -8
  142. package/src/runtime/office/core/office-actions-open.mjs +124 -0
  143. package/src/runtime/office/core/office-actions-read.mjs +127 -0
  144. package/src/runtime/office/core/office-core.mjs +80 -1
  145. package/src/runtime/office/core/office-sessions.mjs +116 -138
  146. package/src/runtime/office/index.mjs +18 -271
  147. package/src/runtime/office/pdf/pdf-analysis.mjs +2 -2
  148. package/src/runtime/office/pdf/pdf-limits.mjs +2 -0
  149. package/src/runtime/office/tool-defs.mjs +7 -6
  150. package/src/runtime/shared/agent-route-config.mjs +8 -8
  151. package/src/runtime/shared/child-spawn-gate.mjs +10 -13
  152. package/src/runtime/shared/config.mjs +2 -7
  153. package/src/runtime/shared/env.mjs +3 -3
  154. package/src/runtime/shared/err-text.mjs +1 -1
  155. package/src/runtime/shared/extension-scopes.mjs +3 -2
  156. package/src/runtime/shared/heap-cap.mjs +10 -6
  157. package/src/runtime/shared/llm/cost.mjs +35 -10
  158. package/src/runtime/shared/llm/usage-accounting.mjs +11 -1
  159. package/src/runtime/shared/llm/usage-context.mjs +6 -0
  160. package/src/runtime/shared/llm/usage-ledger-import.mjs +5 -0
  161. package/src/runtime/shared/llm/usage-ledger-repair.mjs +109 -0
  162. package/src/runtime/shared/llm/usage-ledger.mjs +59 -20
  163. package/src/runtime/shared/llm/usage-pricing-refresh.mjs +26 -0
  164. package/src/runtime/shared/llm/usage-rollup.mjs +17 -15
  165. package/src/runtime/shared/native-asset.mjs +3 -4
  166. package/src/runtime/shared/object.mjs +4 -0
  167. package/src/runtime/shared/pg-schema-db.mjs +21 -0
  168. package/src/runtime/shared/plugin-metadata.mjs +3 -1
  169. package/src/runtime/shared/resource-admission.mjs +1 -6
  170. package/src/runtime/shared/schedules-db.mjs +8 -24
  171. package/src/runtime/shared/schema-value-error.d.mts +2 -0
  172. package/src/runtime/shared/schema-value-error.mjs +68 -0
  173. package/src/runtime/shared/singleton-owner.mjs +11 -24
  174. package/src/runtime/shared/staged-update.mjs +1 -10
  175. package/src/runtime/shared/tool-card-model.mjs +8 -5
  176. package/src/runtime/shared/tool-execution-contract.mjs +1 -1
  177. package/src/runtime/shared/tool-surface.mjs +1 -5
  178. package/src/runtime/shared/user-data-guard.mjs +1 -4
  179. package/src/runtime/shared/webhooks-db.mjs +8 -24
  180. package/src/runtime/web-search/index.mjs +32 -8
  181. package/src/runtime/web-search/tool-defs.mjs +4 -4
  182. package/src/session-runtime/config-lifecycle.mjs +34 -0
  183. package/src/session-runtime/context-status.mjs +19 -0
  184. package/src/session-runtime/cwd-plugins.mjs +12 -29
  185. package/src/session-runtime/goal-tasks.mjs +2 -2
  186. package/src/session-runtime/goal-tool-defs.mjs +3 -2
  187. package/src/session-runtime/internal-tool-executor.mjs +7 -0
  188. package/src/session-runtime/lifecycle-api.mjs +5 -11
  189. package/src/session-runtime/notification-bus.mjs +41 -0
  190. package/src/session-runtime/prewarm.mjs +22 -0
  191. package/src/session-runtime/runtime-bootstrap.mjs +90 -0
  192. package/src/session-runtime/runtime-core.mjs +88 -202
  193. package/src/session-runtime/runtime-feature-gates.mjs +37 -0
  194. package/src/session-runtime/session-lifecycle.mjs +5 -5
  195. package/src/session-runtime/session-turn-api.mjs +1 -12
  196. package/src/session-runtime/setup-tool/executor.mjs +13 -5
  197. package/src/session-runtime/setup-tool/tool-defs.mjs +52 -46
  198. package/src/session-runtime/tool-defs.mjs +73 -4
  199. package/src/session-runtime/usage-stats-api.mjs +4 -1
  200. package/src/session-runtime/warmup-schedulers.mjs +8 -2
  201. package/src/session-runtime/workflow.mjs +14 -0
  202. package/src/standalone/channel-session-router.mjs +3 -1
  203. package/src/standalone/channel-worker.mjs +18 -9
  204. package/src/standalone/daemon-crash-capture.mjs +534 -0
  205. package/src/standalone/daemon-telemetry.mjs +175 -0
  206. package/src/standalone/daemon.mjs +31 -21
  207. package/src/standalone/session-client.mjs +31 -23
  208. package/src/standalone/usage-dashboard-model.mjs +2 -0
  209. package/src/standalone/usage-stats-hours.mjs +18 -11
  210. package/src/standalone/usage-stats-model.mjs +39 -28
  211. package/src/standalone/usage-stats-period.mjs +43 -45
  212. package/src/tui/app/use-transcript-window.mjs +1 -1
  213. package/src/tui/components/StatusLine.jsx +13 -42
  214. package/src/tui/dist/index.mjs +256 -239
  215. package/src/tui/session/session-api-ext.mjs +44 -41
  216. package/src/tui/session/session-api.mjs +4 -0
  217. package/src/tui/session/tool-card-results.mjs +25 -78
  218. package/src/tui/session/tool-result-status.mjs +94 -1
  219. package/src/tui/session/turn-aggregate-cards.mjs +17 -54
  220. package/src/ui/statusline-format.mjs +6 -26
  221. package/src/workflows/default/WORKFLOW.md +5 -0
@@ -1,6 +1,6 @@
1
1
  import { usageRollupDayKey } from '../runtime/shared/llm/usage-rollup.mjs';
2
2
 
3
- const VIEWS = new Set(['hour', 'day', 'week', 'month', 'all']);
3
+ const VIEWS = new Set(['hour', '7d', 'day', 'week', 'month', 'year', 'all', 'custom']);
4
4
 
5
5
  function midnight(value) {
6
6
  const date = new Date(value);
@@ -20,65 +20,63 @@ function anchorDate(anchor, now) {
20
20
  return date;
21
21
  }
22
22
 
23
- function periodStart(date, view) {
24
- const start = midnight(date);
25
- if (view !== 'hour') start.setDate(1);
26
- if (view === 'week') start.setMonth(Math.floor(start.getMonth() / 3) * 3);
27
- if (view === 'month') start.setMonth(0);
28
- return start;
29
- }
30
-
31
- function shiftMonths(date, count) {
23
+ function shiftDays(date, count) {
32
24
  const shifted = new Date(date);
33
- shifted.setMonth(shifted.getMonth() + count);
25
+ shifted.setDate(shifted.getDate() + count);
34
26
  return shifted;
35
27
  }
36
28
 
37
- function calendarCount(from, to) {
38
- const cursor = midnight(from);
39
- const end = midnight(to);
40
- let count = 0;
41
- while (cursor <= end) {
42
- count++;
43
- cursor.setDate(cursor.getDate() + 1);
44
- }
45
- return count;
29
+ function calendarBounds(start, end, now, days) {
30
+ const toMs = Math.min(now, shiftDays(end, 1).getTime() - 1);
31
+ return { fromMs: start.getTime(), toMs, endMs: toMs,
32
+ startDay: usageRollupDayKey(start.getTime()), endDay: usageRollupDayKey(end.getTime()), days };
46
33
  }
47
34
 
48
35
  /**
49
- * One owner for calendar selection and navigation.
50
- * hour = today, day = a month, week = a calendar quarter, month = a year.
51
- * Display bounds include future slots; accounting bounds never exceed now.
36
+ * One owner for trailing ranges and navigation.
37
+ * hour = 24 elapsed hours; 7d/day/week/month = 7/30/90/365 local calendar dates.
38
+ * Calendar ranges include today. An anchor is the final included date.
39
+ * year groups retained history by year; all remains a legacy API alias.
40
+ * Display and accounting bounds both stop at the end of the selected range.
52
41
  */
53
- export function resolveUsageStatsPeriod({ view = 'hour', anchor, now = Date.now() } = {}) {
42
+ export function resolveUsageStatsPeriod({ view = 'hour', anchor, startDay, endDay, now = Date.now() } = {}) {
54
43
  if (!VIEWS.has(view)) throw new TypeError('Unknown usage statistics view');
55
44
  if (!Number.isFinite(now) || now <= 0) throw new TypeError('Usage period requires a valid current time');
56
45
  const today = usageRollupDayKey(now);
57
- if (view === 'all') {
46
+ if (view === 'year' || view === 'all') {
58
47
  return { view, anchor: null, fromMs: 0, toMs: now, startDay: null, endDay: today,
59
48
  days: null, previousAnchor: null, nextAnchor: null, isCurrent: true };
60
49
  }
61
- const current = periodStart(now, view);
62
- // Hourly history is deliberately not navigable.
63
- const requested = view === 'hour' ? current : periodStart(anchorDate(anchor, now), view);
64
- const start = requested > current ? current : requested;
65
- const step = view === 'day' ? 1 : view === 'week' ? 3 : 12;
66
- const next = view === 'hour' ? new Date(start) : shiftMonths(start, step);
67
- if (view === 'hour') next.setDate(next.getDate() + 1);
68
- const endMs = next.getTime() - 1;
69
- const toMs = Math.min(now, endMs);
70
- const previous = view === 'hour' ? null : shiftMonths(start, -step);
50
+ if (view === 'hour') {
51
+ const fromMs = now - 24 * 60 * 60 * 1000;
52
+ return { view, anchor: null, fromMs, toMs: now, endMs: now,
53
+ startDay: usageRollupDayKey(fromMs), endDay: today,
54
+ days: 1, previousAnchor: null, nextAnchor: null, isCurrent: true };
55
+ }
56
+ if (view === 'custom') {
57
+ if (startDay == null || endDay == null) throw new TypeError('Usage range requires a start and end date');
58
+ const start = anchorDate(startDay, now);
59
+ const end = anchorDate(endDay, now);
60
+ if (start > end) throw new RangeError('Usage range start must not follow its end');
61
+ if (end > midnight(now)) throw new RangeError('Usage range cannot include future dates');
62
+ const days = (Date.UTC(end.getFullYear(), end.getMonth(), end.getDate())
63
+ - Date.UTC(start.getFullYear(), start.getMonth(), start.getDate())) / 86400000 + 1;
64
+ return { view, anchor: null, ...calendarBounds(start, end, now, days),
65
+ previousAnchor: null, nextAnchor: null, isCurrent: endDay === today };
66
+ }
67
+ const current = midnight(now);
68
+ const requested = anchorDate(anchor, now);
69
+ const end = requested > current ? current : requested;
70
+ const days = view === '7d' ? 7 : view === 'day' ? 30 : view === 'week' ? 90 : 365;
71
+ const start = shiftDays(end, 1 - days);
72
+ const previous = shiftDays(start, -1);
73
+ const next = shiftDays(end, days);
71
74
  return {
72
75
  view,
73
- anchor: usageRollupDayKey(start.getTime()),
74
- fromMs: start.getTime(),
75
- toMs,
76
- endMs,
77
- startDay: usageRollupDayKey(start.getTime()),
78
- endDay: usageRollupDayKey(endMs),
79
- days: view === 'hour' ? 0 : calendarCount(start, toMs),
80
- previousAnchor: previous && previous.getFullYear() >= 1970 ? usageRollupDayKey(previous.getTime()) : null,
81
- nextAnchor: view !== 'hour' && next <= current ? usageRollupDayKey(next.getTime()) : null,
82
- isCurrent: start.getTime() === current.getTime(),
76
+ anchor: usageRollupDayKey(end.getTime()),
77
+ ...calendarBounds(start, end, now, days),
78
+ previousAnchor: previous.getFullYear() >= 1970 ? usageRollupDayKey(previous.getTime()) : null,
79
+ nextAnchor: end < current ? usageRollupDayKey(Math.min(next.getTime(), current.getTime())) : null,
80
+ isCurrent: end.getTime() === current.getTime(),
83
81
  };
84
82
  }
@@ -27,6 +27,7 @@ import {
27
27
  transcriptHarvestInputsEqual,
28
28
  } from './transcript-window.mjs';
29
29
  import { shouldSuppressFullyFailedToolItem } from '../transcript-tool-failures.mjs';
30
+ import { TUI_DEBUG } from '../session/transcript-spill.mjs';
30
31
 
31
32
  // ── Harvest circuit breaker ────────────────────────────────────────────────
32
33
  // The measured-height harvest is a deps-less layout effect: every
@@ -39,7 +40,6 @@ import { shouldSuppressFullyFailedToolItem } from '../transcript-tool-failures.m
39
40
  // the bump (the caches keep the latest heights, the next external render
40
41
  // consumes them) and trace the culprits for diagnosis.
41
42
  const HARVEST_BUMP_STREAK_LIMIT = 10;
42
- const TUI_DEBUG = /^(1|true|yes|on)$/i.test(String(process.env.MIXDOG_TUI_DEBUG || ''));
43
43
  let harvestBreakerLogged = false;
44
44
  function traceHarvestBreaker(changedKeys) {
45
45
  // Always report the FIRST trip per process (one stderr line beats a crash);
@@ -22,6 +22,7 @@ import { useSharedTick } from '../hooks/useSharedTick.mjs';
22
22
  // instant-local L2 can render the Shell segment itself instead of grafting it
23
23
  // out of the previous full line.
24
24
  import { shellJobsStatus } from '../../ui/statusline-segments.mjs';
25
+ import { formatElapsed, num, terminalColumns } from '../../ui/statusline-format.mjs';
25
26
 
26
27
  // Loaded at RUNTIME (not bundled) so its vendored statusline-lib relative
27
28
  // imports resolve from the real src/ui location, not the dist/ bundle dir.
@@ -138,15 +139,6 @@ function statusColors() {
138
139
  };
139
140
  }
140
141
 
141
- function terminalColumns() {
142
- const cols = Number(process.stdout?.columns);
143
- return Number.isFinite(cols) && cols > 0 ? Math.floor(cols) : 120;
144
- }
145
-
146
- function localNum(value) {
147
- const n = Number(value);
148
- return Number.isFinite(n) ? n : 0;
149
- }
150
142
 
151
143
  function localContextPct({
152
144
  provider = '',
@@ -198,27 +190,6 @@ function localL2SpinnerFrame(now = Date.now()) {
198
190
  return LOCAL_WORKER_SPINNER_FRAMES[index] || LOCAL_WORKER_SPINNER_FRAMES[0];
199
191
  }
200
192
 
201
- // Byte-identical replica of src/tui/time-format.mjs formatDuration() with
202
- // DEFAULT options (no mostSignificantOnly / hideTrailingZeros), wrapped to drop
203
- // sub-1s. Output shape: '' (<1s), `Xs`, `Xm Ys`, `Xh Ym Zs`, `Xd Yh Zm`. Mirrors
204
- // statusline.mjs formatElapsed so instant-local L2 elapsed matches full render.
205
- function localFormatElapsed(ms) {
206
- if (!Number.isFinite(Number(ms))) return '';
207
- const value = Math.max(0, Number(ms) || 0);
208
- if (value < 60_000) {
209
- if (value < 1_000) return '';
210
- return `${Math.floor(value / 1000)}s`;
211
- }
212
- const days = Math.floor(value / 86_400_000);
213
- const hours = Math.floor((value % 86_400_000) / 3_600_000);
214
- const minutes = Math.floor((value % 3_600_000) / 60_000);
215
- const seconds = Math.floor((value % 60_000) / 1000);
216
- if (days > 0) return `${days}d ${hours}h ${minutes}m`;
217
- if (hours > 0) return `${hours}h ${minutes}m ${seconds}s`;
218
- if (minutes > 0) return `${minutes}m ${seconds}s`;
219
- return `${seconds}s`;
220
- }
221
-
222
193
  function localRunningWorkerCount(agentWorkers = [], agentJobs = []) {
223
194
  const seen = new Set();
224
195
  for (const worker of Array.isArray(agentWorkers) ? agentWorkers : []) {
@@ -281,7 +252,7 @@ function localStatusLineL2({
281
252
  if (runningCount > 0) {
282
253
  const label = `Running ${runningCount} Agent${runningCount === 1 ? '' : 's'}`;
283
254
  const oldestStart = localOldestWorkerStartMs(agentWorkers, agentJobs);
284
- const elapsed = oldestStart > 0 ? localFormatElapsed(now - oldestStart) : '';
255
+ const elapsed = oldestStart > 0 ? formatElapsed(now - oldestStart) : '';
285
256
  l2Parts.push(`${spin} ${STATUS}${label}${RESET}${elapsedSuffix(elapsed)}`);
286
257
  }
287
258
  // Session-scoped like the full path: one host process owns many sessions'
@@ -298,12 +269,12 @@ function localStatusLineL2({
298
269
  const tools = activeTools && typeof activeTools === 'object' ? activeTools : {};
299
270
  const exploreInfo = tools.explore || null;
300
271
  const searchInfo = tools.search || null;
301
- if (exploreInfo && localNum(exploreInfo.count) > 0) {
302
- const elapsed = localNum(exploreInfo.startedAt) > 0 ? localFormatElapsed(now - localNum(exploreInfo.startedAt)) : '';
272
+ if (exploreInfo && num(exploreInfo.count) > 0) {
273
+ const elapsed = num(exploreInfo.startedAt) > 0 ? formatElapsed(now - num(exploreInfo.startedAt)) : '';
303
274
  l2Parts.push(`${spin} ${STATUS}Exploring${RESET}${elapsedSuffix(elapsed)}`);
304
275
  }
305
- if (searchInfo && localNum(searchInfo.count) > 0) {
306
- const elapsed = localNum(searchInfo.startedAt) > 0 ? localFormatElapsed(now - localNum(searchInfo.startedAt)) : '';
276
+ if (searchInfo && num(searchInfo.count) > 0) {
277
+ const elapsed = num(searchInfo.startedAt) > 0 ? formatElapsed(now - num(searchInfo.startedAt)) : '';
307
278
  l2Parts.push(`${spin} ${STATUS}Web Searching${RESET}${elapsedSuffix(elapsed)}`);
308
279
  }
309
280
  return l2Parts.length ? l2Parts.join(segSep) : '';
@@ -416,13 +387,13 @@ function StatusLineView({ sessionId, clientHostPid, provider, model, effort, fas
416
387
  : '';
417
388
  const statsForSignature = stats && typeof stats === 'object' ? stats : {};
418
389
  const statsSignature = [
419
- localNum(statsForSignature.currentContextTokens),
420
- localNum(statsForSignature.currentEstimatedContextTokens),
421
- localNum(statsForSignature.inputTokens),
422
- localNum(statsForSignature.latestInputTokens),
423
- localNum(statsForSignature.promptTokens),
424
- localNum(statsForSignature.turns),
425
- localNum(statsForSignature.contextTokens),
390
+ num(statsForSignature.currentContextTokens),
391
+ num(statsForSignature.currentEstimatedContextTokens),
392
+ num(statsForSignature.inputTokens),
393
+ num(statsForSignature.latestInputTokens),
394
+ num(statsForSignature.promptTokens),
395
+ num(statsForSignature.turns),
396
+ num(statsForSignature.contextTokens),
426
397
  String(statsForSignature.currentContextSource || ''),
427
398
  ].join('|');
428
399
  const refreshMs = hasActiveStatuslineWork(line, agentWorkers, agentJobs, activeTools) ? STATUSLINE_ACTIVE_REFRESH_MS : STATUSLINE_REFRESH_MS;