nolo-cli 0.201.0-alpha.2 → 0.202.0-alpha.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.
Files changed (124) hide show
  1. package/{_executeModel-BNYZLAN6.js → _executeModel-IPRTPSW7.js} +34 -33
  2. package/{agentDeleteCommand-4V4YSAXS.js → agentDeleteCommand-WHT2MMAP.js} +49 -47
  3. package/{agentEmailCommands-EYIQEH6Z.js → agentEmailCommands-4LW2BFLY.js} +51 -49
  4. package/{agentListCommands-2KGUT7UB.js → agentListCommands-2KF47HY6.js} +81 -45
  5. package/{agentMachineCommands-WUN47ILO.js → agentMachineCommands-QQCFQQ4T.js} +28 -26
  6. package/{agentProviderCommands-T6E3JCR6.js → agentProviderCommands-5ALOQLE5.js} +2 -2
  7. package/{agentRecordCommands-XL2CON36.js → agentRecordCommands-ARVXF2C2.js} +47 -45
  8. package/{agentRunCommand-R237ZGMQ.js → agentRunCommand-3IL5PW2S.js} +49 -47
  9. package/{agentRunControl-6HHESKDB.js → agentRunControl-ABDUPJLX.js} +10 -5
  10. package/{agentRuntimeLocal-XLLWFAVI.js → agentRuntimeLocal-YXHJV65L.js} +24 -22
  11. package/{agentSlice-Z5NKGMB7.js → agentSlice-BFDKYW6H.js} +4 -3
  12. package/{appDeleteCommands-IPF2VI3W.js → appDeleteCommands-OWJO3WFB.js} +29 -27
  13. package/{appDeployCommands-IBQ7GUXO.js → appDeployCommands-X7HLT27G.js} +29 -27
  14. package/{appDeployStatusCommands-6ESVU6XE.js → appDeployStatusCommands-CHCZ7ZUD.js} +29 -27
  15. package/{appGetCommands-VTSYTM4V.js → appGetCommands-AZW2EE4R.js} +29 -27
  16. package/{appListCommands-VCP5TUX7.js → appListCommands-YFN6DP6K.js} +29 -27
  17. package/{authCommand-RV5MQDWN.js → authCommand-W34UWJGR.js} +14 -13
  18. package/{builtinSkillRegistry-7RAJP7FD.js → builtinSkillRegistry-NJVHQIKY.js} +1 -1
  19. package/{chromeOpsCommands-BA6CS4DI.js → chromeOpsCommands-USKE4B4K.js} +15 -4
  20. package/{chunk-RE3B2OCC.js → chunk-266E37EL.js} +69 -14
  21. package/chunk-2BMURXSB.js +1863 -0
  22. package/{chunk-RRHJJUA3.js → chunk-2PI4QFAL.js} +174 -100
  23. package/{chunk-NABJEYPJ.js → chunk-2Q3LOAFE.js} +38 -3
  24. package/{chunk-EOLPKHSB.js → chunk-326HCB6L.js} +28 -24
  25. package/{chunk-4CEAZRZ4.js → chunk-33W4IFUU.js} +1 -1
  26. package/{chunk-V3MGT3RF.js → chunk-3CWF2EUZ.js} +8 -8
  27. package/{chunk-G6OOUQWJ.js → chunk-4KB6WQUL.js} +2 -0
  28. package/{chunk-DYQXB46J.js → chunk-4KPB3KWX.js} +2 -2
  29. package/{chunk-SW5AAI5D.js → chunk-4SH22ZG7.js} +5 -5
  30. package/{chunk-WAZ6BTSC.js → chunk-5E4FSR4J.js} +1 -1
  31. package/{chunk-PVD7CRYV.js → chunk-6I7ZP7KJ.js} +3 -3
  32. package/chunk-6UBGXX2W.js +12 -0
  33. package/{chunk-ZBCBFOWC.js → chunk-A2ZMIRLN.js} +2 -2
  34. package/{chunk-Z646E5YH.js → chunk-ASG7VWPK.js} +3 -3
  35. package/{chunk-QWVGFBOQ.js → chunk-BLFZULEQ.js} +3 -3
  36. package/{chunk-JIFYXQRD.js → chunk-BTYQAODF.js} +26 -8
  37. package/{chunk-KORCRPLO.js → chunk-C7PKPHK6.js} +334 -12
  38. package/{chunk-6WZQGT5X.js → chunk-CJ37ZMCQ.js} +6 -2
  39. package/{chunk-VHGD6FHV.js → chunk-CKAHAVMK.js} +40 -10
  40. package/{chunk-UNOILAZP.js → chunk-CLTGWJVT.js} +76 -4
  41. package/{chunk-Q6RMLYSA.js → chunk-CMLBKYEI.js} +4 -2
  42. package/{chunk-NVOYW6H4.js → chunk-CQHMBWZH.js} +12 -8
  43. package/{chunk-7KWPNGVJ.js → chunk-CTZ4O3XD.js} +1 -1
  44. package/{chunk-OHRDHS4N.js → chunk-CVCRAO6Q.js} +9 -4
  45. package/{chunk-26CRLZFD.js → chunk-D57YYGMD.js} +2 -2
  46. package/{chunk-TEC5UHQK.js → chunk-DHJXDGC3.js} +2 -2
  47. package/{chunk-QYOB7RVA.js → chunk-DKZJJ2NQ.js} +3 -2
  48. package/{chunk-4YX7VQOC.js → chunk-E2FC5RMU.js} +17 -14
  49. package/{chunk-EH4MNUMF.js → chunk-ETTDZBK5.js} +4 -4
  50. package/{chunk-BUXH3H5M.js → chunk-FWMOJTGR.js} +3722 -4851
  51. package/{chunk-ZWQUWF6W.js → chunk-G7Y4GXTY.js} +8 -14
  52. package/{chunk-5KTQVMCX.js → chunk-GOO6G4PY.js} +85 -0
  53. package/{chunk-FMOZ57LN.js → chunk-H7HWWNJB.js} +1 -1
  54. package/{chunk-A5VR65AE.js → chunk-HJS5EIKS.js} +4 -4
  55. package/{chunk-H44LQSZ2.js → chunk-HKWGI3TM.js} +178 -311
  56. package/{chunk-BBGYSMUE.js → chunk-JH7KMNGT.js} +143 -19
  57. package/{chunk-YXMZHGNA.js → chunk-KDUYNEJ5.js} +33 -16
  58. package/{chunk-O5V7QQAF.js → chunk-LEX6DEH4.js} +114 -2
  59. package/{chunk-BTBT2566.js → chunk-MNUOMXJH.js} +412 -9
  60. package/{chunk-N7E3LQ4A.js → chunk-MZXWSY4E.js} +1 -1
  61. package/{chunk-ZQ3EAOY3.js → chunk-NTLJGRAT.js} +1 -1
  62. package/{chunk-WFUIXNKC.js → chunk-P4YLK2OD.js} +3 -3
  63. package/chunk-PRJ473FK.js +63 -0
  64. package/{chunk-2SHLT6JB.js → chunk-Q7GNBUT4.js} +2 -2
  65. package/{chunk-C2UXCAMB.js → chunk-RIKSN62L.js} +3 -3
  66. package/{chunk-GTP6VNWH.js → chunk-RQ22OZD7.js} +3 -3
  67. package/{chunk-H7NIQGTU.js → chunk-RS66RJLA.js} +2 -2
  68. package/{chunk-GC64WGMD.js → chunk-SM3NSZJV.js} +16 -5
  69. package/{chunk-QKDMI22S.js → chunk-SSK4WNJA.js} +1 -1
  70. package/{chunk-6MAFLMAO.js → chunk-SUBNV2JH.js} +3 -3
  71. package/{chunk-HLAL63BZ.js → chunk-T43B7LB2.js} +1 -1
  72. package/{chunk-HTLIKE5U.js → chunk-TWVVTUNG.js} +2 -2
  73. package/{chunk-X3RWBJDQ.js → chunk-U7HTU2S7.js} +1 -1
  74. package/{chunk-76YUTLOT.js → chunk-UIOEHFF6.js} +1 -1
  75. package/{chunk-IIX6VWLW.js → chunk-VCFU3BO5.js} +224 -38
  76. package/{chunk-QU3TLYBR.js → chunk-VEUSD6OF.js} +35 -11
  77. package/{chunk-4YMD7B4Y.js → chunk-WPOKOKZA.js} +2 -2
  78. package/{chunk-K6TZSON4.js → chunk-WTKYP6QO.js} +19 -5
  79. package/{chunk-FEKMTBKJ.js → chunk-XW6B2RJW.js} +192 -55
  80. package/{chunk-ZSO5B6SW.js → chunk-Y2WUYX4I.js} +9 -0
  81. package/{chunk-A3SXTJDE.js → chunk-YAGFPXOX.js} +14 -14
  82. package/{chunk-TVGX5QIN.js → chunk-YUA6OAH5.js} +2 -2
  83. package/{chunk-NYE2INIO.js → chunk-YV2RSLM4.js} +13 -13
  84. package/{chunk-MJWUBTK7.js → chunk-YZGNKHUM.js} +2 -2
  85. package/{commandRegistry-YFXWA5SF.js → commandRegistry-HEBIO2A4.js} +87 -67
  86. package/{contentThunks-2BV7CFUP.js → contentThunks-I4IHSDTM.js} +14 -13
  87. package/{cooldownCommands-KRILPXOZ.js → cooldownCommands-5SJ74DNP.js} +1 -1
  88. package/{createAgentAutomationAction-T6CGXCSO.js → createAgentAutomationAction-WQCH5HR2.js} +14 -13
  89. package/{createDialogAction-X27IA3G2.js → createDialogAction-CKMZK5JQ.js} +15 -14
  90. package/{createPageAction-EHDHNW5P.js → createPageAction-QAZHQGY7.js} +14 -13
  91. package/{dialogCommands-XZXH3HSQ.js → dialogCommands-YMAHICPJ.js} +30 -28
  92. package/{dialogSlice-AZNPVOCU.js → dialogSlice-GEGACCH2.js} +13 -12
  93. package/{docCreateCommands-Z64V5BFZ.js → docCreateCommands-SNMAKBXN.js} +28 -26
  94. package/{docDeleteCommands-7UFHIM4C.js → docDeleteCommands-K52UESRC.js} +29 -27
  95. package/{docReadCommands-NLU7Y67R.js → docReadCommands-AG6LLHJ7.js} +28 -26
  96. package/{docStore-M37Q6JFO.js → docStore-B4EFT53J.js} +1 -1
  97. package/{docUpdateCommands-S2KGBEG3.js → docUpdateCommands-B5EZ7DYN.js} +28 -26
  98. package/{fetchMessages-HWBVATSE.js → fetchMessages-YY4SATNR.js} +1 -1
  99. package/{getPricing-E2PLNWCR.js → getPricing-3PQY3TGI.js} +3 -3
  100. package/{handleSendMessageAction-KUJQZ6B6.js → handleSendMessageAction-4BACQWOG.js} +70 -29
  101. package/index.js +7 -7
  102. package/{lib-4YTWAGY7.js → lib-5KKIBFIT.js} +439 -272
  103. package/{localDialogRead-CT5HGDMC.js → localDialogRead-FUXGZ57B.js} +1 -1
  104. package/{localRuntimeAdapter-5BNHO6JZ.js → localRuntimeAdapter-5CVSCXHI.js} +45 -43
  105. package/{machineCommands-2KDROAVV.js → machineCommands-R7L4IBQL.js} +48 -46
  106. package/{machineWsRunDispatch-4NP5M574.js → machineWsRunDispatch-KZHTW7DW.js} +46 -44
  107. package/{models-UUNO6DOL.js → models-PJBE6JDV.js} +2 -2
  108. package/{oauthTokenStore-PADKLNOC.js → oauthTokenStore-OEERZFUC.js} +2 -1
  109. package/package.json +1 -1
  110. package/{providerPresetApply-JGNMO2KX.js → providerPresetApply-HBBUUVJD.js} +6 -6
  111. package/{providerRegistry-33J3ZYFJ.js → providerRegistry-5LK2NXYE.js} +6 -6
  112. package/{readlineWorkspace-MKUSR6HA.js → readlineWorkspace-PDPEWRSG.js} +290 -121
  113. package/{runAgentClientLoop-J32KRVN7.js → runAgentClientLoop-QKV66PX5.js} +31 -30
  114. package/{runtimeDoctorCommands-NYBOTA6D.js → runtimeDoctorCommands-3VFVTGPI.js} +8 -7
  115. package/{secretCommands-N6CMCJDZ.js → secretCommands-MKU25CDP.js} +311 -3
  116. package/{settingThunks-YRYNPWJM.js → settingThunks-4WU7YE62.js} +2 -2
  117. package/{skillDiscovery-F3TMVQOJ.js → skillDiscovery-BKLWW2EZ.js} +2 -2
  118. package/{spaceCommands-VV4K7TGI.js → spaceCommands-VD3CZWXM.js} +27 -25
  119. package/{streamAgentChatTurn-S2Q7STXS.js → streamAgentChatTurn-GM3UNSLS.js} +46 -43
  120. package/{tools-KOIPW4ZA.js → tools-UJLEQBKI.js} +25 -24
  121. package/{tuiSummaryLlmCaller-FSOADMXK.js → tuiSummaryLlmCaller-73QO3HAD.js} +12 -12
  122. package/{updateCommands-KE6LP3QX.js → updateCommands-RVDAFHBT.js} +3 -3
  123. package/{updateDialogTitleAction-ILS5OIXF.js → updateDialogTitleAction-24QO27NT.js} +14 -13
  124. package/{windowsSelfUpdate-26TSFXEZ.js → windowsSelfUpdate-N2VH2OBW.js} +2 -2
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-5ZUL4CUO.js";
4
4
  import {
5
5
  getModelContextWindow
6
- } from "./chunk-JIFYXQRD.js";
6
+ } from "./chunk-BTYQAODF.js";
7
7
  import {
8
8
  normalizeTimingMs
9
9
  } from "./chunk-H57T64RA.js";
@@ -124,17 +124,30 @@ var topLevel = (field) => (usage) => {
124
124
  return finiteTokenCount(usage[field]);
125
125
  };
126
126
  var nested = (path) => (usage) => readNested(usage, path);
127
- var readCacheReadInputTokens = (usage) => firstPositive(usage, [
127
+ var firstPresentAsNumber = (usage, readers) => {
128
+ let sawField = false;
129
+ for (const read of readers) {
130
+ const value = read(usage);
131
+ if (value === void 0) continue;
132
+ sawField = true;
133
+ if (value !== 0) return value;
134
+ }
135
+ return sawField ? 0 : null;
136
+ };
137
+ var CACHE_READ_READERS = [
128
138
  topLevel("cache_read_input_tokens"),
129
139
  topLevel("prompt_cache_hit_tokens"),
130
140
  nested(["input_tokens_details", "cached_tokens"]),
131
141
  nested(["prompt_tokens_details", "cached_tokens"])
132
- ]);
133
- var readCacheCreationInputTokens = (usage) => firstPositive(usage, [
142
+ ];
143
+ var CACHE_CREATION_READERS = [
134
144
  topLevel("cache_creation_input_tokens"),
135
145
  topLevel("prompt_cache_miss_tokens"),
136
146
  nested(["input_tokens_details", "cache_write_tokens"])
137
- ]);
147
+ ];
148
+ var readCacheReadInputTokens = (usage) => firstPositive(usage, CACHE_READ_READERS);
149
+ var readCacheReadInputTokensOrNull = (usage) => firstPresentAsNumber(usage, CACHE_READ_READERS);
150
+ var readCacheCreationInputTokens = (usage) => firstPositive(usage, CACHE_CREATION_READERS);
138
151
 
139
152
  // packages/ai/token/normalizeUsage.ts
140
153
  var normalizeStringArray = (value) => {
@@ -382,6 +395,7 @@ export {
382
395
  DEFAULT_AUTO_EXECUTION_PROFILE,
383
396
  resolveAutoExecutionProfile,
384
397
  readCacheReadInputTokens,
398
+ readCacheReadInputTokensOrNull,
385
399
  readCacheCreationInputTokens,
386
400
  devinChannelContextWindow,
387
401
  resolveAgentContextWindow,
@@ -9,7 +9,7 @@ import {
9
9
  resolveRawAgentInput,
10
10
  resolveServerUrl,
11
11
  writeUsage
12
- } from "./chunk-H7NIQGTU.js";
12
+ } from "./chunk-RS66RJLA.js";
13
13
  import {
14
14
  parsePositiveFiniteNumberOrFallback
15
15
  } from "./chunk-Y5GCAMGP.js";
@@ -19,7 +19,7 @@ import {
19
19
  import {
20
20
  readDbRecord,
21
21
  resolveAgentRecordFromHybridStore
22
- } from "./chunk-6WZQGT5X.js";
22
+ } from "./chunk-CJ37ZMCQ.js";
23
23
  import {
24
24
  INSTABOX_RUN_CONFIG_ENV,
25
25
  createCliLocalRuntimeAdapter,
@@ -38,7 +38,7 @@ import {
38
38
  resolveFileWriteGateEnabled,
39
39
  resolveLocalUserId,
40
40
  validateInstaboxWorkspaceSelection
41
- } from "./chunk-RRHJJUA3.js";
41
+ } from "./chunk-2PI4QFAL.js";
42
42
  import {
43
43
  clearCredentialAvailability,
44
44
  readEffectiveCredentialEntry,
@@ -72,14 +72,14 @@ import {
72
72
  } from "./chunk-BMQ2MJUK.js";
73
73
  import {
74
74
  resolveCliLocalRuntimeKeyCapability
75
- } from "./chunk-H44LQSZ2.js";
75
+ } from "./chunk-HKWGI3TM.js";
76
76
  import {
77
77
  isTransientFetchError
78
78
  } from "./chunk-KFHREHUQ.js";
79
79
  import {
80
80
  parseUiCard,
81
81
  uiCardFallback
82
- } from "./chunk-KORCRPLO.js";
82
+ } from "./chunk-C7PKPHK6.js";
83
83
  import {
84
84
  isGatewayHttpStatus
85
85
  } from "./chunk-NF64D32W.js";
@@ -88,7 +88,7 @@ import {
88
88
  chooseMemoryOwners,
89
89
  loadMemoryCandidatesFromDb,
90
90
  resolveAgentMemoryPolicy
91
- } from "./chunk-Z646E5YH.js";
91
+ } from "./chunk-ASG7VWPK.js";
92
92
  import {
93
93
  API_REPORTED_COST_MULTIPLIER,
94
94
  estimateMessagesTokens,
@@ -96,7 +96,7 @@ import {
96
96
  resolveAgentContextWindow,
97
97
  resolveOccupancy,
98
98
  resolveOccupancyWindow
99
- } from "./chunk-EOLPKHSB.js";
99
+ } from "./chunk-326HCB6L.js";
100
100
  import {
101
101
  isCliAuthorityBrokerProtocolError,
102
102
  isCliAuthorityBrokerTimeoutError,
@@ -107,7 +107,7 @@ import {
107
107
  } from "./chunk-P64WRQYV.js";
108
108
  import {
109
109
  buildSkillDiscoveryContextLayer
110
- } from "./chunk-7KWPNGVJ.js";
110
+ } from "./chunk-CTZ4O3XD.js";
111
111
  import {
112
112
  parseExternalSkillMarkdown,
113
113
  parseSkillDocProtocol
@@ -116,10 +116,10 @@ import {
116
116
  LOCAL_AGENT_CONFIG_MISSING_CODE,
117
117
  LOCAL_TURN_ABORTED_CODE,
118
118
  readActionGate
119
- } from "./chunk-BUXH3H5M.js";
119
+ } from "./chunk-FWMOJTGR.js";
120
120
  import {
121
121
  resolveAgentRuntimeConfigFromRecord
122
- } from "./chunk-N7E3LQ4A.js";
122
+ } from "./chunk-MZXWSY4E.js";
123
123
  import {
124
124
  createThinkParserState,
125
125
  flushThinkParser,
@@ -143,8 +143,9 @@ import {
143
143
  normalizeAttachmentPart
144
144
  } from "./chunk-WJZOQR2J.js";
145
145
  import {
146
- normalizeUsage
147
- } from "./chunk-K6TZSON4.js";
146
+ normalizeUsage,
147
+ readCacheReadInputTokensOrNull
148
+ } from "./chunk-WTKYP6QO.js";
148
149
  import {
149
150
  isOAuthApiKeyRef
150
151
  } from "./chunk-UKZX3NHN.js";
@@ -160,11 +161,12 @@ import {
160
161
  } from "./chunk-DWLEOOGR.js";
161
162
  import {
162
163
  buildAgentsMdLayer,
164
+ buildAgentsMdLayerHeader,
163
165
  buildMemoryOverlayLayer,
164
166
  buildMemoryUseGuidanceLayer,
165
167
  partitionScopedBlocks,
166
168
  renderTurnContextBlocksWithScope
167
- } from "./chunk-Q6RMLYSA.js";
169
+ } from "./chunk-CMLBKYEI.js";
168
170
  import {
169
171
  BUILTIN_NOLO_AGENT_KEY,
170
172
  BUILTIN_NOLO_AGENT_NAME,
@@ -176,10 +178,7 @@ import {
176
178
  } from "./chunk-M2EJHDJP.js";
177
179
  import {
178
180
  isAntigravityOAuthAgent
179
- } from "./chunk-QU3TLYBR.js";
180
- import {
181
- toErrorMessage
182
- } from "./chunk-HNMXYYJR.js";
181
+ } from "./chunk-VEUSD6OF.js";
183
182
  import {
184
183
  createRunActivityTracker,
185
184
  createShellApprovalChild,
@@ -194,7 +193,7 @@ import {
194
193
  serverOriginForDialog,
195
194
  settleRunTerminalAuthoritatively,
196
195
  spawnLocalBackgroundRun
197
- } from "./chunk-BTBT2566.js";
196
+ } from "./chunk-MNUOMXJH.js";
198
197
  import {
199
198
  formatAgentListCard,
200
199
  formatFinishedRunCard,
@@ -207,10 +206,13 @@ import {
207
206
  } from "./chunk-PJNFNEJE.js";
208
207
  import {
209
208
  resolveClientVersion
210
- } from "./chunk-4YMD7B4Y.js";
209
+ } from "./chunk-WPOKOKZA.js";
211
210
  import {
212
211
  findModelConfig
213
- } from "./chunk-GC64WGMD.js";
212
+ } from "./chunk-SM3NSZJV.js";
213
+ import {
214
+ toErrorMessage
215
+ } from "./chunk-HNMXYYJR.js";
214
216
  import {
215
217
  getLogger,
216
218
  normalizeError
@@ -228,7 +230,7 @@ import {
228
230
  t,
229
231
  toolLabel,
230
232
  toolLabelVariants
231
- } from "./chunk-UNOILAZP.js";
233
+ } from "./chunk-CLTGWJVT.js";
232
234
  import {
233
235
  createMemoryKey
234
236
  } from "./chunk-ECX3NKRD.js";
@@ -245,7 +247,7 @@ import {
245
247
  CLIENT_VERSION_TOO_OLD_CODE,
246
248
  NOLO_CLIENT_VERSION_HEADER,
247
249
  buildClientVersionUpgradeMessage
248
- } from "./chunk-5KTQVMCX.js";
250
+ } from "./chunk-GOO6G4PY.js";
249
251
  import {
250
252
  asTrimmedLowercaseString
251
253
  } from "./chunk-QSJ3HFEF.js";
@@ -8699,8 +8701,32 @@ function isToolTreeLeafLine(line) {
8699
8701
  function isToolSingleLine(line) {
8700
8702
  return TOOL_SINGLE_RE.test(plainToolLine(line));
8701
8703
  }
8702
- function isToolGroupBoundary(cur, next) {
8703
- return isToolTreeLeafLine(cur) && isToolTreeHeaderLine(next);
8704
+ function toolGroupKeyOf(line) {
8705
+ const plain = plainToolLine(line);
8706
+ const flat = plain.match(TOOL_SINGLE_RE);
8707
+ if (flat) {
8708
+ const label = (flat[1] ?? "").replace(/\s*×\d+$/, "").trim();
8709
+ return label ? `flat:${label}` : null;
8710
+ }
8711
+ const header = toolTreeHeaderMatch(plain);
8712
+ if (header) {
8713
+ const label = (header[1] ?? "").replace(/\s*×\d+$/, "").trim();
8714
+ return label ? `tree:${label}` : null;
8715
+ }
8716
+ return null;
8717
+ }
8718
+ function toolRowBoundary(cur, next) {
8719
+ const curLeaf = isToolTreeLeafLine(cur);
8720
+ const curHeader = isToolTreeHeaderLine(cur);
8721
+ const nextLeaf = isToolTreeLeafLine(next);
8722
+ const curKey = toolGroupKeyOf(cur);
8723
+ const nextKey = toolGroupKeyOf(next);
8724
+ if (curKey === null && !curLeaf) return null;
8725
+ if (nextKey === null && !nextLeaf) return null;
8726
+ if (curLeaf) return !nextLeaf;
8727
+ if (curHeader && nextLeaf) return false;
8728
+ if (curKey !== null && nextKey !== null) return curKey !== nextKey;
8729
+ return true;
8704
8730
  }
8705
8731
  function statusColorSeq(marker, brightness) {
8706
8732
  if (marker === "\u2713") return colorSeq("success", brightness);
@@ -8766,7 +8792,8 @@ function polishBreathInsertsBlankBetween(cur, next) {
8766
8792
  if (isPolishIntroLine(cur) && isPolishListLikeLine(next)) return false;
8767
8793
  if (isPolishHeadingLine(cur) || isPolishHeadingLine(next)) return false;
8768
8794
  if (isCodeFenceLine(cur) !== isCodeFenceLine(next)) return true;
8769
- if (isToolGroupBoundary(cur, next)) return true;
8795
+ const toolBoundary = toolRowBoundary(cur, next);
8796
+ if (toolBoundary !== null) return toolBoundary;
8770
8797
  return isPolishListLikeLine(cur) !== isPolishListLikeLine(next);
8771
8798
  }
8772
8799
  function convertMarkdownTablesForTerminal(text) {
@@ -9065,16 +9092,22 @@ function classifyStreamLine(line) {
9065
9092
  if (polishHeadingLevel(plain) !== null) return "heading";
9066
9093
  return "prose";
9067
9094
  }
9095
+ function isStreamToolKind(kind) {
9096
+ return kind === "tool-header" || kind === "tool-leaf" || kind === "tool";
9097
+ }
9068
9098
  function isStreamListLike(kind) {
9069
9099
  return kind === "list" || kind === "tool-header" || kind === "tool-leaf" || kind === "tool";
9070
9100
  }
9071
- function needsListProseBreath(prev, next, prevLine = "") {
9101
+ function needsListProseBreath(prev, next, prevLine = "", nextLine = "") {
9072
9102
  if (prev === null || prev === "blank" || next === "blank") return false;
9073
9103
  if (next === "heading") return true;
9074
9104
  if (prev === "heading") return (polishHeadingLevel(prevLine) ?? 7) <= 2;
9075
9105
  if (prev === "fence" !== (next === "fence")) return true;
9076
9106
  if (isStreamListLike(next) && isPolishIntroLine(prevLine)) return false;
9077
- if (prev === "tool-leaf" && next === "tool-header") return true;
9107
+ if (isStreamToolKind(prev) && isStreamToolKind(next)) {
9108
+ const boundary = toolRowBoundary(prevLine, nextLine);
9109
+ if (boundary !== null) return boundary;
9110
+ }
9078
9111
  return isStreamListLike(prev) !== isStreamListLike(next);
9079
9112
  }
9080
9113
  function createRenderAwareStreamWriter(args) {
@@ -9085,13 +9118,13 @@ function createRenderAwareStreamWriter(args) {
9085
9118
  let lastLine = "";
9086
9119
  let pendingBlankRow = false;
9087
9120
  const PARTIAL_FLUSH_THRESHOLD = 48;
9088
- const emitBreathIfNeeded = (nextKind) => {
9121
+ const emitBreathIfNeeded = (nextKind, nextLine = "") => {
9089
9122
  if (pendingBlankRow) {
9090
9123
  args.write("\n");
9091
9124
  pendingBlankRow = false;
9092
9125
  lastKind = "blank";
9093
9126
  }
9094
- if (needsListProseBreath(lastKind, nextKind, lastLine)) args.write("\n");
9127
+ if (needsListProseBreath(lastKind, nextKind, lastLine, nextLine)) args.write("\n");
9095
9128
  };
9096
9129
  const flushPartialProse = () => {
9097
9130
  if (tracker.isInFence() || buffer.length < PARTIAL_FLUSH_THRESHOLD) return;
@@ -9220,7 +9253,7 @@ function createRenderAwareStreamWriter(args) {
9220
9253
  buffer = lines.slice(1).join("\n");
9221
9254
  continue;
9222
9255
  }
9223
- emitBreathIfNeeded(kind);
9256
+ emitBreathIfNeeded(kind, firstLine);
9224
9257
  emitFormattedAssistantBlock(args.write, firstLine, true);
9225
9258
  lastKind = kind;
9226
9259
  lastLine = firstLine;
@@ -9248,6 +9281,7 @@ function createRenderAwareStreamWriter(args) {
9248
9281
  if (tracker.isInFence()) {
9249
9282
  args.write(buffer);
9250
9283
  } else {
9284
+ emitBreathIfNeeded(classifyStreamLine(buffer), buffer);
9251
9285
  emitFormattedAssistantBlock(args.write, buffer);
9252
9286
  }
9253
9287
  buffer = "";
@@ -11378,7 +11412,7 @@ function isBalanceExhaustedError(error) {
11378
11412
 
11379
11413
  // packages/cli/client/agentRun.ts
11380
11414
  async function loadRunLocalAgentTurn() {
11381
- const { runLocalAgentTurn } = await import("./agentRuntimeLocal-XLLWFAVI.js");
11415
+ const { runLocalAgentTurn } = await import("./agentRuntimeLocal-YXHJV65L.js");
11382
11416
  return runLocalAgentTurn;
11383
11417
  }
11384
11418
  var stripDebugNoise = (s) => s.replace(/\s*raw="[\s\S]*"/g, "").replace(/\s*raw=\S+/g, "").replace(/\s*headers=\[[^\]]*\]/g, "").replace(/\s*headers=\S+/g, "").trim();
@@ -12031,7 +12065,11 @@ var FAILURE_BUILDERS = {
12031
12065
  function describeLocalRunFailure(message, rawError) {
12032
12066
  const credentialAccountId = rawError && typeof rawError === "object" && typeof rawError.credentialAccountId === "string" ? rawError.credentialAccountId.trim() || void 0 : void 0;
12033
12067
  if (rawError && typeof rawError === "object" && "code" in rawError && rawError.code === "PLATFORM_STREAM_INTERRUPTED") {
12034
- return "[nolo] The platform LLM stream was interrupted before the turn completed. Your conversation was preserved. Send another message to continue.\n";
12068
+ const detail = rawError;
12069
+ const phaseMessage = detail.phase === "pre-headers" ? "The platform LLM request failed before response headers arrived." : detail.phase === "streaming" ? "The platform LLM stream was interrupted before the turn completed." : "The platform LLM request was interrupted before the turn completed.";
12070
+ const saveMessage = detail.failedTurnPersistence?.status === "saved" ? "The failed turn was saved. Send another message to continue." : detail.failedTurnPersistence?.status === "failed" ? "The failed turn could not be saved. Check your conversation before continuing." : "Saving the failed turn could not be confirmed. Check your conversation before continuing.";
12071
+ return `[nolo] ${phaseMessage} ${saveMessage}
12072
+ `;
12035
12073
  }
12036
12074
  if (isClientVersionTooOldFailure(message, rawError)) {
12037
12075
  return describeClientVersionTooOldFailure(message, rawError);
@@ -12525,6 +12563,9 @@ async function executeLocalAgentTurnForCliWithAdapter(options, settings, resolve
12525
12563
  ...options.contextBlockScopes?.length ? { contextBlockScopes: options.contextBlockScopes } : options.extraContextBlocks?.length ? { contextBlocks: options.extraContextBlocks } : {},
12526
12564
  ...typeof options.timeoutMs === "number" ? { timeoutMs: options.timeoutMs } : {},
12527
12565
  ...options.actionGateHandler ? { onActionGate: options.actionGateHandler } : {},
12566
+ ...options.onPartialText ? { onObservationEvent: (event) => {
12567
+ if (event.kind === "text-delta") options.onPartialText?.(event.chunk);
12568
+ } } : {},
12528
12569
  onLoopEvent: (event) => {
12529
12570
  if (event.kind === "llm-start") {
12530
12571
  turnOutput.showWorking();
@@ -13040,26 +13081,109 @@ function buildHostEnvironmentLayer(options) {
13040
13081
 
13041
13082
  // packages/agent-runtime/agentsMd.ts
13042
13083
  import { existsSync as existsSync2, readFileSync as readFileSync3 } from "node:fs";
13043
- import { join as join2 } from "node:path";
13084
+ import { resolve as resolve2 } from "node:path";
13044
13085
  var AGENTS_MD_MAX_BYTES = 8192;
13086
+ var AGENTS_MD_MARKER_RESERVE_BYTES = 512;
13045
13087
  var AGENTS_MD_CANDIDATES = ["AGENTS.md", "CLAUDE.md"];
13088
+ function truncateAgentsMdContent(content, maxBytes = AGENTS_MD_MAX_BYTES) {
13089
+ const buf = Buffer.from(content, "utf8");
13090
+ if (buf.byteLength <= maxBytes) {
13091
+ return content;
13092
+ }
13093
+ let boundary = Math.min(maxBytes, buf.byteLength);
13094
+ while (boundary > 0 && boundary < buf.byteLength && (buf[boundary] & 192) === 128) {
13095
+ boundary--;
13096
+ }
13097
+ const boundarySlice = buf.subarray(0, boundary).toString("utf8");
13098
+ const slice = buf.subarray(0, maxBytes);
13099
+ const lastNewline = slice.lastIndexOf(10);
13100
+ if (lastNewline > 0) {
13101
+ const lineCandidate = slice.subarray(0, lastNewline).toString("utf8");
13102
+ const lineBytes = Buffer.byteLength(lineCandidate, "utf8");
13103
+ const boundaryBytes = Buffer.byteLength(boundarySlice, "utf8");
13104
+ if (lineCandidate.trim().length > 0 && lineBytes * 2 >= boundaryBytes) {
13105
+ return lineCandidate.replace(/\r$/, "");
13106
+ }
13107
+ }
13108
+ return boundarySlice.replace(/\r$/, "");
13109
+ }
13046
13110
  function readAgentsMdLayerFromDisk(cwd) {
13047
13111
  for (const name of AGENTS_MD_CANDIDATES) {
13048
- const filePath = join2(cwd, name);
13112
+ const filePath = resolve2(cwd, name);
13049
13113
  if (!existsSync2(filePath)) continue;
13050
13114
  try {
13051
- let content = readFileSync3(filePath, "utf8").trim();
13115
+ const raw = readFileSync3(filePath, "utf8");
13116
+ const content = raw.trim();
13052
13117
  if (!content) continue;
13053
- if (Buffer.byteLength(content, "utf8") > AGENTS_MD_MAX_BYTES) {
13054
- content = Buffer.from(content, "utf8").subarray(0, AGENTS_MD_MAX_BYTES).toString("utf8") + "\n\n<!-- AGENTS.md truncated -->";
13118
+ const totalBytes = Buffer.byteLength(raw, "utf8");
13119
+ const trimmedBytes = Buffer.byteLength(content, "utf8");
13120
+ const headerBytes = Buffer.byteLength(buildAgentsMdLayerHeader(name), "utf8");
13121
+ if (headerBytes + trimmedBytes <= AGENTS_MD_MAX_BYTES) {
13122
+ return buildAgentsMdLayer(content, name);
13123
+ }
13124
+ const buildMarker = (omitted2, withPath) => {
13125
+ const pathPart = withPath ? `\u5B8C\u6574\u6587\u4EF6\uFF1A${filePath}` : `\u5B8C\u6574\u6587\u4EF6\uFF1A\u5DE5\u4F5C\u533A\u6839\u76EE\u5F55\u7684 ${name}`;
13126
+ return `<!-- AGENTS.md truncated: \u539F\u6587\u4EF6 ${totalBytes} \u5B57\u8282\uFF0C\u6CE8\u5165\u9884\u7B97 ${AGENTS_MD_MAX_BYTES} \u5B57\u8282\uFF0C\u5DF2\u7701\u7565 ${omitted2} \u5B57\u8282\uFF08\u4E0A\u6587\u53EF\u80FD\u7F3A\u5C11\u6587\u4EF6\u672B\u5C3E\u7684 commit/review \u95E8\u7981\u7EC6\u5219\uFF0C\u63D0\u4EA4/\u8BC4\u5BA1\u524D\u8BF7\u8BFB\u5B8C\u6574\u6587\u4EF6\uFF09\u3002${pathPart} -->`;
13127
+ };
13128
+ const bodyBudget = AGENTS_MD_MAX_BYTES - AGENTS_MD_MARKER_RESERVE_BYTES - 2 - headerBytes;
13129
+ const body = truncateAgentsMdContent(content, bodyBudget);
13130
+ const bodyBytes = Buffer.byteLength(body, "utf8");
13131
+ const omitted = Math.max(0, totalBytes - bodyBytes);
13132
+ let marker = buildMarker(omitted, true);
13133
+ if (Buffer.byteLength(marker, "utf8") > AGENTS_MD_MARKER_RESERVE_BYTES) {
13134
+ marker = buildMarker(omitted, false);
13055
13135
  }
13056
- return buildAgentsMdLayer(content, name);
13136
+ return buildAgentsMdLayer(`${body}
13137
+
13138
+ ${marker}`, name);
13057
13139
  } catch {
13058
13140
  }
13059
13141
  }
13060
13142
  return null;
13061
13143
  }
13062
13144
 
13145
+ // packages/ai/token/cacheRunSummary.ts
13146
+ var finiteCount = (value) => typeof value === "number" && Number.isFinite(value) ? Math.max(0, Math.floor(value)) : void 0;
13147
+ var isUsageObject = (usage) => Boolean(usage) && typeof usage === "object";
13148
+ var readInputTokens = (usage) => finiteCount(usage.input_tokens) ?? finiteCount(usage.prompt_tokens) ?? 0;
13149
+ var computeCacheHitRatio = (inputTokens, cachedTokens) => {
13150
+ if (cachedTokens === null) return null;
13151
+ if (!Number.isFinite(inputTokens) || inputTokens <= 0) return 0;
13152
+ return Math.round(cachedTokens / inputTokens * 1e4) / 1e4;
13153
+ };
13154
+ var withRatio = (inputTokens, cachedTokens) => ({
13155
+ input_tokens: inputTokens,
13156
+ cached_tokens: cachedTokens,
13157
+ cache_hit_ratio: computeCacheHitRatio(inputTokens, cachedTokens)
13158
+ });
13159
+ var summarizeCacheUsage = (usage) => {
13160
+ if (!isUsageObject(usage)) return void 0;
13161
+ if (Object.keys(usage).length === 0) return void 0;
13162
+ return withRatio(readInputTokens(usage), readCacheReadInputTokensOrNull(usage));
13163
+ };
13164
+ var summarizeCacheUsageRecords = (records) => {
13165
+ if (!records || records.length === 0) return void 0;
13166
+ let inputTokens = 0;
13167
+ let cachedTokens = 0;
13168
+ let sawUsage = false;
13169
+ for (const record of records) {
13170
+ const summary = summarizeCacheUsage(record?.usage);
13171
+ if (!summary) continue;
13172
+ sawUsage = true;
13173
+ inputTokens += summary.input_tokens;
13174
+ cachedTokens = cachedTokens === null || summary.cached_tokens === null ? null : cachedTokens + summary.cached_tokens;
13175
+ }
13176
+ if (!sawUsage) return void 0;
13177
+ return withRatio(inputTokens, cachedTokens);
13178
+ };
13179
+ var mergeCacheUsageSummaries = (left, right) => {
13180
+ if (!left) return right;
13181
+ if (!right) return left;
13182
+ const inputTokens = left.input_tokens + right.input_tokens;
13183
+ const cachedTokens = left.cached_tokens === null || right.cached_tokens === null ? null : left.cached_tokens + right.cached_tokens;
13184
+ return withRatio(inputTokens, cachedTokens);
13185
+ };
13186
+
13063
13187
  // packages/cli/agentRunDoD.ts
13064
13188
  import { spawnSync as nodeSpawnSync } from "node:child_process";
13065
13189
  var DOD_COMMAND_TIMEOUT_MS = 12e4;
@@ -13119,16 +13243,16 @@ function runDoDCommands(commands, cwd, deps = {}) {
13119
13243
 
13120
13244
  // packages/cli/agentRunPrompts.ts
13121
13245
  import { existsSync as existsSync3, readFileSync as readFileSync4, readdirSync, statSync as statSync2 } from "node:fs";
13122
- import { dirname, extname, isAbsolute as isAbsolute2, join as join3, relative as relativePath, resolve as resolve2, sep } from "node:path";
13246
+ import { dirname, extname, isAbsolute as isAbsolute2, join as join2, relative as relativePath, resolve as resolve3, sep } from "node:path";
13123
13247
  function workflowRefToCandidatePath(cwd, ref) {
13124
13248
  const normalized = ref.trim();
13125
13249
  if (!normalized) return "";
13126
13250
  if (normalized.endsWith(".md") || normalized.includes("/") || normalized.includes("\\")) {
13127
- const directPath = resolve2(cwd, normalized);
13251
+ const directPath = resolve3(cwd, normalized);
13128
13252
  if (existsSync3(directPath)) return directPath;
13129
13253
  }
13130
13254
  const fileName = normalized.replace(/[^a-zA-Z0-9一-鿿]+/g, "-").replace(/^-+|-+$/g, "");
13131
- return resolve2(cwd, "docs", "workflows", `${fileName}.md`);
13255
+ return resolve3(cwd, "docs", "workflows", `${fileName}.md`);
13132
13256
  }
13133
13257
  var SKILL_SEARCH_DIRS = [
13134
13258
  ".agents/skills"
@@ -13137,15 +13261,15 @@ function skillRefToCandidatePath(cwd, ref) {
13137
13261
  const normalized = ref.trim();
13138
13262
  if (!normalized) return "";
13139
13263
  if (normalized.endsWith(".md") || normalized.includes("/") || normalized.includes("\\")) {
13140
- const directPath = resolve2(cwd, normalized);
13264
+ const directPath = resolve3(cwd, normalized);
13141
13265
  if (existsSync3(directPath)) return directPath;
13142
13266
  }
13143
13267
  const fileName = normalized.replace(/[^a-zA-Z0-9一-鿿]+/g, "-").replace(/^-+|-+$/g, "");
13144
13268
  for (const dir of SKILL_SEARCH_DIRS) {
13145
- const skillMdPath = resolve2(cwd, dir, fileName, "SKILL.md");
13269
+ const skillMdPath = resolve3(cwd, dir, fileName, "SKILL.md");
13146
13270
  if (existsSync3(skillMdPath)) return skillMdPath;
13147
13271
  }
13148
- return resolve2(cwd, ".agents", "skills", fileName, "SKILL.md");
13272
+ return resolve3(cwd, ".agents", "skills", fileName, "SKILL.md");
13149
13273
  }
13150
13274
  async function resolveWorkflowReference(ref, cwd = process.cwd()) {
13151
13275
  const path2 = workflowRefToCandidatePath(cwd, ref);
@@ -13162,11 +13286,11 @@ async function resolveWorkflowReference(ref, cwd = process.cwd()) {
13162
13286
  }
13163
13287
  function inlineRelativeRefs(body, skillDir) {
13164
13288
  const refPattern = /\[([^\]]+)\]\((\.\/[^)]+|[^)]+\/[^)]+)\)/g;
13165
- const normalizedSkillDir = resolve2(skillDir) + sep;
13289
+ const normalizedSkillDir = resolve3(skillDir) + sep;
13166
13290
  return body.replace(refPattern, (match, label, relPath) => {
13167
13291
  const cleaned = relPath.trim();
13168
13292
  if (!cleaned.startsWith("./") && !cleaned.startsWith("../")) return match;
13169
- const absPath = resolve2(skillDir, cleaned);
13293
+ const absPath = resolve3(skillDir, cleaned);
13170
13294
  const relative = relativePath(normalizedSkillDir, absPath);
13171
13295
  if (relative.startsWith("..") || isAbsolute2(relative)) return match;
13172
13296
  if (!existsSync3(absPath) || !absPath.endsWith(".md")) return match;
@@ -13181,7 +13305,7 @@ ${refContent}
13181
13305
  });
13182
13306
  }
13183
13307
  function listSkillScripts(skillDir) {
13184
- const scriptsDir = join3(skillDir, "scripts");
13308
+ const scriptsDir = join2(skillDir, "scripts");
13185
13309
  if (!existsSync3(scriptsDir) || !statSync2(scriptsDir).isDirectory()) return null;
13186
13310
  const entries = readdirSync(scriptsDir).filter((e) => !e.startsWith("."));
13187
13311
  if (entries.length === 0) return null;
@@ -13316,7 +13440,7 @@ function prependSubjectDialogMarker(message, subjectDialogKey) {
13316
13440
  }
13317
13441
  function normalizeCliImageInput(input) {
13318
13442
  if (/^(https?:|data:|file:)/i.test(input)) return input;
13319
- const absolutePath = resolve2(input);
13443
+ const absolutePath = resolve3(input);
13320
13444
  if (!existsSync3(absolutePath)) return input;
13321
13445
  const base64 = readFileSync4(absolutePath).toString("base64");
13322
13446
  return `data:${imageMimeTypeForPath(absolutePath)};base64,${base64}`;
@@ -15677,15 +15801,13 @@ async function runAgentRunCommand(args, deps) {
15677
15801
  stallTimer = setInterval(async () => {
15678
15802
  if (timedOut || stalled) return;
15679
15803
  const activity = activityTracker?.getActivity();
15680
- const lastEventAtMs = activity ? new Date(activity.lastEventAt).getTime() : nowMs();
15681
- const elapsedSinceEvent = nowMs() - lastEventAtMs;
15682
15804
  if (activity?.inFlight?.kind === "tool") {
15683
15805
  return;
15684
15806
  }
15685
- if (activity?.inFlight?.kind === "llm" && elapsedSinceEvent < stallTimeoutMs) {
15686
- return;
15687
- }
15688
- if (elapsedSinceEvent >= stallTimeoutMs) {
15807
+ const lastProgressAt = activity?.lastProgressAt ?? activity?.lastEventAt;
15808
+ const lastProgressAtMs = lastProgressAt ? new Date(lastProgressAt).getTime() : nowMs();
15809
+ const elapsedSinceProgress = nowMs() - lastProgressAtMs;
15810
+ if (elapsedSinceProgress >= stallTimeoutMs) {
15689
15811
  stalled = true;
15690
15812
  clearWatchdogs();
15691
15813
  const note = `stalled: no progress for ${stallTimeoutMs}ms`;
@@ -16028,7 +16150,10 @@ async function runAgentRunCommand(args, deps) {
16028
16150
  ...skillAllowedToolOverride !== void 0 ? { allowedToolNames: skillAllowedToolOverride } : parsed.allowedToolNames?.length ? { allowedToolNames: parsed.allowedToolNames } : {},
16029
16151
  ...parsed.blockedToolNames?.length ? { blockedToolNames: parsed.blockedToolNames } : {},
16030
16152
  ...machineShellOverride ? { runtimeToolPolicyOverride: machineShellOverride } : {},
16031
- ...activityTracker ? { onLoopEvent: activityTracker.onLoopEvent } : {},
16153
+ ...activityTracker ? {
16154
+ onLoopEvent: activityTracker.onLoopEvent,
16155
+ onPartialText: activityTracker.onPartialText
16156
+ } : {},
16032
16157
  background: parsed.background,
16033
16158
  noStream: parsed.noStream,
16034
16159
  ephemeral: parsed.ephemeral,
@@ -16047,6 +16172,7 @@ async function runAgentRunCommand(args, deps) {
16047
16172
  );
16048
16173
  clearWatchdogs();
16049
16174
  let runCreditsTotal = result.turnCredits;
16175
+ let runCacheUsage = summarizeCacheUsageRecords(result.usageRecords);
16050
16176
  if (result.exitCode !== 0 && isQuotaExhaustedError(result.localError) && isLocalRun && parsed.fallbackAgentKeys && parsed.fallbackAgentKeys.length > 0) {
16051
16177
  const fallbackAgentKey = parsed.fallbackAgentKeys[0];
16052
16178
  output.write(
@@ -16066,6 +16192,10 @@ async function runAgentRunCommand(args, deps) {
16066
16192
  if (fallbackResult.turnCredits !== void 0) {
16067
16193
  runCreditsTotal = (runCreditsTotal ?? 0) + fallbackResult.turnCredits;
16068
16194
  }
16195
+ runCacheUsage = mergeCacheUsageSummaries(
16196
+ runCacheUsage,
16197
+ summarizeCacheUsageRecords(fallbackResult.usageRecords)
16198
+ );
16069
16199
  if (fallbackResult.exitCode !== 0) {
16070
16200
  result = {
16071
16201
  ...fallbackResult,
@@ -16112,6 +16242,10 @@ async function runAgentRunCommand(args, deps) {
16112
16242
  if (turnResult.turnCredits !== void 0) {
16113
16243
  runCreditsTotal = (runCreditsTotal ?? 0) + turnResult.turnCredits;
16114
16244
  }
16245
+ runCacheUsage = mergeCacheUsageSummaries(
16246
+ runCacheUsage,
16247
+ summarizeCacheUsageRecords(turnResult.usageRecords)
16248
+ );
16115
16249
  if (result.exitCode !== 0) {
16116
16250
  break;
16117
16251
  }
@@ -16219,6 +16353,9 @@ async function runAgentRunCommand(args, deps) {
16219
16353
  // run 级累计的平台积分(主轮 + fallback + drain 轮):dock 行据此显示
16220
16354
  // 「⚡ x.xx」,让派发任务的消耗可见。undefined = 全程无平台计费。
16221
16355
  ...runCreditsTotal !== void 0 ? { credits: runCreditsTotal } : {},
16356
+ // run 级缓存命中汇总:只进 .result.md 的 front matter(cached_tokens
16357
+ // 为 null 表示 provider 未报缓存指标,与「命中 0」严格区分)。
16358
+ ...runCacheUsage ? { cacheUsage: runCacheUsage } : {},
16222
16359
  ...failureReason ? { failureReason } : {},
16223
16360
  ...toolCallCount !== void 0 ? { toolCallCount } : {},
16224
16361
  ...result.finalText ? { lastAssistantText: result.finalText } : {},
@@ -48,6 +48,15 @@ var fetchMessages = async (db, dialogId, options = {}) => {
48
48
  let count = 0;
49
49
  for await (const [key, value] of iterator) {
50
50
  count++;
51
+ if (count % 32 === 0) {
52
+ await new Promise((resolve) => {
53
+ if (typeof setImmediate === "function") {
54
+ setImmediate(resolve);
55
+ } else {
56
+ setTimeout(resolve, 0);
57
+ }
58
+ });
59
+ }
51
60
  if (!includeDeleted && isTombstoneRecord(value)) {
52
61
  continue;
53
62
  }