nolo-cli 0.30.1 → 0.31.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 (108) hide show
  1. package/{_executeModel-FYUR7PQU.js → _executeModel-K47XKKPU.js} +32 -31
  2. package/{action-FENWPT3C.js → action-HI3VRQLP.js} +7 -7
  3. package/{addContentAction-Z5S5ZQ7I.js → addContentAction-NCURJ6PK.js} +6 -6
  4. package/{addDialogAgentAction-VUNVD2XR.js → addDialogAgentAction-RCY4ECF4.js} +5 -5
  5. package/{agentDeleteCommand-HHP47ZB2.js → agentDeleteCommand-7BBZCONG.js} +26 -25
  6. package/{agentEmailCommands-H6KRDTQW.js → agentEmailCommands-D6FAT5HM.js} +38 -37
  7. package/{agentListCommands-GNVFOTB4.js → agentListCommands-YPNNMGSJ.js} +28 -27
  8. package/{agentMachineCommands-4HJHI26F.js → agentMachineCommands-VYRVSKUC.js} +26 -25
  9. package/{agentRecordCommands-W6ITUONM.js → agentRecordCommands-4J52H5NK.js} +37 -36
  10. package/{agentRunCommand-VDLU4VKR.js → agentRunCommand-LH4RA6FA.js} +38 -37
  11. package/{agentRunControl-AKBN2366.js → agentRunControl-SCIVRZWX.js} +9 -1
  12. package/{agentRuntimeLocal-3X3ZTFT2.js → agentRuntimeLocal-G7GK545E.js} +23 -22
  13. package/{agentSlice-5HYCSSTE.js → agentSlice-4ZLEPC3M.js} +6 -6
  14. package/{appDeleteCommands-WFUF34TE.js → appDeleteCommands-AOZED7QJ.js} +27 -26
  15. package/{appDeployCommands-J2EAE53G.js → appDeployCommands-XJY27BDS.js} +27 -26
  16. package/{appDeployStatusCommands-RLXDEHTV.js → appDeployStatusCommands-HKZYAPB2.js} +27 -26
  17. package/{appGetCommands-ZGV3CKCM.js → appGetCommands-VXJLPRYI.js} +27 -26
  18. package/{appListCommands-3VRX3EJI.js → appListCommands-3LU6AB4G.js} +27 -26
  19. package/{authCommand-RR5LAYSW.js → authCommand-3GQR43KB.js} +5 -5
  20. package/{chunk-ZFTCLBEX.js → chunk-2IJAKBK2.js} +3 -1
  21. package/chunk-2K4NDPT5.js +1524 -0
  22. package/{chunk-6QP7LEI6.js → chunk-2MSOY7A5.js} +49 -33
  23. package/{chunk-3IPBZISR.js → chunk-2YT3KLHX.js} +1 -1
  24. package/{chunk-GABCPUMC.js → chunk-3IU7WEJD.js} +1 -1
  25. package/{chunk-Q24P6TUS.js → chunk-43EPBPZ2.js} +1 -1
  26. package/{chunk-5NPAOURO.js → chunk-4URO6HMS.js} +1 -1
  27. package/{chunk-S342XWCB.js → chunk-5EDVWWE3.js} +1 -1
  28. package/{chunk-CTLXD6HB.js → chunk-5JQRISUS.js} +3 -3
  29. package/{chunk-4ZMTXQFB.js → chunk-5MVFYKBL.js} +5 -5
  30. package/{chunk-R5V5G73M.js → chunk-5RDLGLAP.js} +0 -1
  31. package/{chunk-4SAV7BD7.js → chunk-7KNERA53.js} +53 -15
  32. package/{chunk-XORE26Z4.js → chunk-7S54ZGF6.js} +2 -2
  33. package/{chunk-IZ3CBMD5.js → chunk-ATK5WJOA.js} +4 -4
  34. package/chunk-BGTUGS3T.js +702 -0
  35. package/{chunk-YX26YZL4.js → chunk-C3NYMZTQ.js} +16 -14
  36. package/{chunk-R2JHVPHL.js → chunk-CPUZW54L.js} +4 -4
  37. package/{chunk-PJY5AH5A.js → chunk-DPR66GY6.js} +1 -1
  38. package/{chunk-3Z6SPX5X.js → chunk-E2CFIWQR.js} +31 -23
  39. package/{chunk-PACNSC37.js → chunk-E3APEOIM.js} +1 -1
  40. package/{chunk-7QW64TCG.js → chunk-EATVNXFX.js} +7 -7
  41. package/{chunk-G5JHHUAK.js → chunk-F3MP7CP6.js} +1 -1
  42. package/{chunk-YK2QRWTO.js → chunk-FLYQAMF4.js} +3 -3
  43. package/{chunk-446VANPP.js → chunk-G5GVZAXF.js} +4 -4
  44. package/{chunk-KH3JS4D5.js → chunk-H6COXALE.js} +78 -27
  45. package/{chunk-MNUJETMH.js → chunk-K76HYM3O.js} +1 -1
  46. package/{chunk-DKRT67FG.js → chunk-KGEVMUMI.js} +3 -3
  47. package/{chunk-A4JDTA5T.js → chunk-LAXMH7JY.js} +6 -6
  48. package/{chunk-TAS3THIF.js → chunk-LBEWOWVL.js} +4 -4
  49. package/{chunk-72NVMKWA.js → chunk-NEGMZP6Q.js} +1 -1
  50. package/{chunk-QDNVDGLN.js → chunk-NMK2JHKM.js} +9 -7
  51. package/{chunk-JRI2BRJY.js → chunk-OT2AXEQD.js} +26 -5
  52. package/{chunk-LWP3HB56.js → chunk-PTHDLIRB.js} +1 -1
  53. package/{chunk-V5BWE46D.js → chunk-Q6L3O67D.js} +2 -2
  54. package/{chunk-LWYIHJKD.js → chunk-QHWPAW5M.js} +2 -2
  55. package/{chunk-KWCLUYGQ.js → chunk-QL6ELRVS.js} +1 -1
  56. package/chunk-RJ7KLCWY.js +5134 -0
  57. package/{chunk-WJD5RNVB.js → chunk-SFWZUTCI.js} +1 -1
  58. package/{chunk-WTPC3XD4.js → chunk-UDA3ZYLW.js} +1 -1
  59. package/{chunk-YLADSPDU.js → chunk-V54H24CQ.js} +2 -2
  60. package/{chunk-F3A5IZSX.js → chunk-WEID4JLC.js} +2 -2
  61. package/{chunk-IUA36RS4.js → chunk-WMH2G6XJ.js} +58 -124
  62. package/{chunk-4PWB7JRR.js → chunk-XFG3BAKN.js} +1 -0
  63. package/chunk-XGJ75KN2.js +7889 -0
  64. package/{chunk-2TZP235J.js → chunk-XPML3KYZ.js} +6 -6
  65. package/{chunk-2NYIVLAY.js → chunk-YHGHADBQ.js} +2 -2
  66. package/{chunk-MV6UZXZU.js → chunk-YJZGAAVX.js} +14 -12
  67. package/{chunk-BOL2D2JW.js → chunk-ZJ2WITOO.js} +2 -2
  68. package/{chunk-DWQNDGO7.js → chunk-ZJH3LKEW.js} +2 -2
  69. package/{createAgentAutomationAction-EKABYSSA.js → createAgentAutomationAction-AECD5YCU.js} +13 -12
  70. package/{createDialogAction-HLP6TV4H.js → createDialogAction-MZUC37CA.js} +14 -13
  71. package/{createPageAction-4NEEWW6S.js → createPageAction-KRTBWM2S.js} +13 -12
  72. package/{db-IPCJ43PW.js → db-6DPSJ6WT.js} +4 -2
  73. package/{dbSlice-OBV7VFCF.js → dbSlice-BBL3PEVW.js} +5 -5
  74. package/{deleteFile-AC45HYSM.js → deleteFile-RJTEPOT4.js} +3 -3
  75. package/{dialogCommands-XB3ZNSP3.js → dialogCommands-RFADXVV6.js} +27 -26
  76. package/{dialogSlice-4IWM2WIY.js → dialogSlice-EWNZ2HFD.js} +12 -12
  77. package/{docCreateCommands-QSPTTAN7.js → docCreateCommands-ZHX6SX5M.js} +26 -25
  78. package/{docDeleteCommands-2E6JZXCP.js → docDeleteCommands-3EEM7ITO.js} +27 -26
  79. package/{docReadCommands-N2DQVLLT.js → docReadCommands-JOMLMZTC.js} +26 -25
  80. package/{docStore-PFZCPHPC.js → docStore-YKTKKH3N.js} +14 -13
  81. package/{docUpdateCommands-53KFSYEP.js → docUpdateCommands-PGAYLKLC.js} +26 -25
  82. package/{getPricing-67TQVKFV.js → getPricing-QO5TYNCK.js} +2 -2
  83. package/{handleSendMessageAction-4IYJTQAL.js → handleSendMessageAction-VX4CGWAJ.js} +12 -12
  84. package/index.js +63 -63
  85. package/{localDialogRead-P72W2U2R.js → localDialogRead-3DBXVYXS.js} +1 -1
  86. package/{machineCommands-CR34SD5W.js → machineCommands-A2WFB37F.js} +36 -35
  87. package/{machineWsRunDispatch-G4O3NQ3I.js → machineWsRunDispatch-E5R54UWZ.js} +36 -35
  88. package/package.json +1 -1
  89. package/{read-QK7ZRX6G.js → read-64OQDO3I.js} +3 -3
  90. package/{readDocTool-EYDMVRBL.js → readDocTool-MXM3T6PE.js} +1 -1
  91. package/{readlineWorkspace-UAF5D7TC.js → readlineWorkspace-S4A6UYVJ.js} +125 -79
  92. package/{removeDialogAgentAction-TBW3UZJW.js → removeDialogAgentAction-NEKVAMSH.js} +7 -7
  93. package/{runAgentClientLoop-R5WNOWHI.js → runAgentClientLoop-C6IIUQ36.js} +27 -26
  94. package/{setDialogExtraReferencesAction-Q3ANF2NR.js → setDialogExtraReferencesAction-WTOHQDIV.js} +6 -6
  95. package/{setPrimaryDialogAgentAction-FQ5R3EFJ.js → setPrimaryDialogAgentAction-LDJOYC4F.js} +7 -7
  96. package/{settingSlice-JKKV2T7O.js → settingSlice-4M37TN7V.js} +6 -6
  97. package/{skillDiscovery-I3QRA7NE.js → skillDiscovery-Y3HALY2U.js} +3 -3
  98. package/{spaceCommands-RZN5K5ND.js → spaceCommands-SKCMLOC6.js} +210 -28
  99. package/{spaceSlice-3BVGRL3V.js → spaceSlice-6VOPELQN.js} +13 -12
  100. package/{streamAgentChatTurn-RVOJZ2HO.js → streamAgentChatTurn-623CNKWF.js} +35 -32
  101. package/{switchDialogAgentAction-QQGVE4SL.js → switchDialogAgentAction-XVWGKR2Z.js} +5 -5
  102. package/{tableCommands-PRJNWN6Q.js → tableCommands-RJZ3V4TF.js} +1 -1
  103. package/{tools-QAKUH2P6.js → tools-IN4B36PN.js} +21 -20
  104. package/{tuiSummaryLlmCaller-YQBN5IMG.js → tuiSummaryLlmCaller-SRZ4QQUP.js} +19 -5
  105. package/{updateDialogTitleAction-4O5PZVQR.js → updateDialogTitleAction-4ABIVEYY.js} +18 -16
  106. package/chunk-EIQDGAAE.js +0 -5083
  107. package/chunk-O6YCGBJB.js +0 -16338
  108. package/chunk-OB6FBSH3.js +0 -47
@@ -11,7 +11,7 @@ import {
11
11
  getAntigravityUserAgent,
12
12
  normalizeAntigravityTokenPayload,
13
13
  refreshAntigravityToken
14
- } from "./chunk-2NYIVLAY.js";
14
+ } from "./chunk-YHGHADBQ.js";
15
15
  import {
16
16
  writeOAuthCredential
17
17
  } from "./chunk-JZPBVBIY.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getModelConfig
3
- } from "./chunk-EIQDGAAE.js";
3
+ } from "./chunk-2K4NDPT5.js";
4
4
  import {
5
5
  isPlatformHostedClaudeModel,
6
6
  isPlatformHostedGrokModel
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  patch,
3
3
  read
4
- } from "./chunk-A4JDTA5T.js";
4
+ } from "./chunk-LAXMH7JY.js";
5
5
  import {
6
6
  DEVICE_LOCAL_OWNER_ID,
7
7
  isDeviceLocalSpaceBody,
8
8
  selectIdentityUserId
9
- } from "./chunk-ZFTCLBEX.js";
9
+ } from "./chunk-2IJAKBK2.js";
10
10
 
11
11
  // packages/create/space/spaceKeys.ts
12
12
  var SEPARATOR = "-";
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  readDbRecord,
3
3
  writeAgentRecord
4
- } from "./chunk-MNUJETMH.js";
4
+ } from "./chunk-K76HYM3O.js";
5
5
  import {
6
6
  createSpaceKey
7
- } from "./chunk-YLADSPDU.js";
7
+ } from "./chunk-V54H24CQ.js";
8
8
  import {
9
9
  buildSkillSummaryMarker
10
10
  } from "./chunk-VF4K2QE6.js";
@@ -2,22 +2,22 @@ import {
2
2
  buildDialogSummaryLayer,
3
3
  buildLinkedSpacesSection,
4
4
  buildSpaceContextLayer
5
- } from "./chunk-PJY5AH5A.js";
5
+ } from "./chunk-DPR66GY6.js";
6
6
  import {
7
7
  buildCurrentTimeBlock,
8
8
  buildIdentityBlock,
9
9
  buildRuntimeGuidanceBlocks,
10
10
  fetchReferenceContents,
11
11
  resolveToolGuidedSections
12
- } from "./chunk-QDNVDGLN.js";
12
+ } from "./chunk-NMK2JHKM.js";
13
13
  import {
14
14
  getAllToolRuns,
15
15
  resolveAgentRecommendedSkillNames,
16
16
  resolveAgentRequiredPackIds
17
- } from "./chunk-2TZP235J.js";
17
+ } from "./chunk-XPML3KYZ.js";
18
18
  import {
19
19
  getDocState
20
- } from "./chunk-YK2QRWTO.js";
20
+ } from "./chunk-FLYQAMF4.js";
21
21
  import {
22
22
  resolveToolBaseUrl
23
23
  } from "./chunk-44HACRCK.js";
@@ -26,26 +26,32 @@ import {
26
26
  getModelPricing,
27
27
  getPrices,
28
28
  hasExplicitAgentPricing
29
- } from "./chunk-PACNSC37.js";
29
+ } from "./chunk-E3APEOIM.js";
30
+ import {
31
+ selectCurrentTable,
32
+ selectTableRows,
33
+ selectViewMode
34
+ } from "./chunk-XGJ75KN2.js";
30
35
  import {
31
36
  PERSONALIZATION_DIALOG_CATEGORY,
32
37
  buildPersonalizationDialogPolicyContext,
33
- estimateTokenCount,
34
38
  extractReferenceKeysFromMessage,
35
39
  getModelContextWindow,
36
- planCompression,
37
- planContextUsage,
38
40
  resolveBuiltinPlatformAgentConfig,
39
- selectAllMsgs,
40
- selectCurrentTable,
41
- selectCurrentUserBalance,
42
- selectTableRows,
43
- selectViewMode,
44
- serializeMessageContent
45
- } from "./chunk-O6YCGBJB.js";
41
+ selectAllMsgs
42
+ } from "./chunk-RJ7KLCWY.js";
46
43
  import {
47
- clipCompactText
48
- } from "./chunk-OB6FBSH3.js";
44
+ COMPACTION_SUMMARY_SYSTEM_PROMPT,
45
+ buildCompactionMetricsFromPlan,
46
+ buildCompactionUserContent,
47
+ clipCompactText,
48
+ estimateTokenCount,
49
+ formatCompactionMetricsLog,
50
+ formatFileOperationsFromMessages,
51
+ formatMessagesForSummaryWithTruncation,
52
+ planCompression,
53
+ planContextUsage
54
+ } from "./chunk-BGTUGS3T.js";
49
55
  import {
50
56
  toErrorMessage
51
57
  } from "./chunk-HNMXYYJR.js";
@@ -56,7 +62,7 @@ import {
56
62
  findModelConfig,
57
63
  getModelConfig,
58
64
  getProviderByModelName
59
- } from "./chunk-EIQDGAAE.js";
65
+ } from "./chunk-2K4NDPT5.js";
60
66
  import {
61
67
  PLATFORM_HOSTED_QWEN_37_FLASH_MODEL
62
68
  } from "./chunk-CAENRKNJ.js";
@@ -68,26 +74,27 @@ import {
68
74
  selectKnowledgeCaptureLevel,
69
75
  selectSpaceContextLevel,
70
76
  selectUserTonePreset
71
- } from "./chunk-446VANPP.js";
77
+ } from "./chunk-G5GVZAXF.js";
72
78
  import {
73
79
  asRecordOrEmpty
74
80
  } from "./chunk-KX6YBIHG.js";
75
81
  import {
76
82
  read,
77
83
  selectById
78
- } from "./chunk-A4JDTA5T.js";
84
+ } from "./chunk-LAXMH7JY.js";
79
85
  import {
80
86
  asTrimmedLowercaseString
81
87
  } from "./chunk-QSJ3HFEF.js";
82
88
  import {
83
89
  PUBLIC_QWEN_37_FLASH_AGENT_KEY
84
- } from "./chunk-DWQNDGO7.js";
90
+ } from "./chunk-ZJH3LKEW.js";
85
91
  import {
86
92
  extractCustomId
87
93
  } from "./chunk-TOW4E763.js";
88
94
  import {
95
+ selectIdentityUserBalance,
89
96
  selectIdentityUserId
90
- } from "./chunk-ZFTCLBEX.js";
97
+ } from "./chunk-2IJAKBK2.js";
91
98
  import {
92
99
  isRecord
93
100
  } from "./chunk-KUG52IAP.js";
@@ -1209,7 +1216,7 @@ ${content}
1209
1216
  return output;
1210
1217
  };
1211
1218
  var validateAccessAndBalance = (agentConfig, state) => {
1212
- const userBalance = selectCurrentUserBalance(state);
1219
+ const userBalance = selectIdentityUserBalance(state);
1213
1220
  const currentUserId = selectIdentityUserId(state);
1214
1221
  const isCustomApi = agentConfig.apiSource === "custom";
1215
1222
  const isCliApi = agentConfig.apiSource === "cli";
@@ -1932,101 +1939,13 @@ var normalizeContextBlockScopes = (legacyBlocks = void 0, scopes = void 0) => {
1932
1939
  };
1933
1940
 
1934
1941
  // packages/agent-runtime/localAutoCompaction.ts
1935
- var LOCAL_AUTO_COMPACTION_SYSTEM_PROMPT = `\u4F60\u662F\u5BF9\u8BDD\u4E0A\u4E0B\u6587\u538B\u7F29\u5668\u3002\u6839\u636E\u3010\u73B0\u6709\u8BB0\u5FC6\u3011\u548C\u3010\u65B0\u589E\u5BF9\u8BDD\u3011\uFF0C\u8F93\u51FA\u53EF\u66FF\u4EE3\u539F\u59CB\u6D88\u606F\u7684\u4E8B\u5B9E\u6027\u8981\u70B9\uFF0C\u4F9B\u540E\u7EED\u5BF9\u8BDD\u76F4\u63A5\u4F7F\u7528\u3002
1936
-
1937
- \u4E25\u683C\u53EA\u8F93\u51FA\u4E0B\u9762\u4E09\u90E8\u5206\uFF0C\u6807\u9898\u5FC5\u987B\u5B8C\u5168\u4E00\u81F4\uFF1A
1938
- \u5173\u952E\u4E8B\u5B9E\u6863\u6848
1939
- - ...
1940
- \u5BF9\u8BDD\u8FDB\u5C55\u4E0E\u5F85\u529E
1941
- - ...
1942
- \u6587\u4EF6\u64CD\u4F5C\u6E05\u5355
1943
- - ...
1944
-
1945
- \u8981\u6C42\uFF1A
1946
- 1) \u4F7F\u7528\u5BF9\u8BDD\u4E3B\u8BED\u8A00\uFF1B\u6DF7\u5408\u8BED\u8A00\u65F6\u4F18\u5148\u7528\u6237\u4E3B\u8981\u8BED\u8A00\uFF1B\u4E13\u6709\u540D\u8BCD\u3001\u6587\u4EF6\u8DEF\u5F84\u3001\u6807\u8BC6\u7B26\u3001\u547D\u4EE4\u4FDD\u7559\u539F\u6587\u3002
1947
- 2) \u5173\u952E\u4E8B\u5B9E\u6863\u6848\u53EA\u4FDD\u7559\u4E4B\u540E\u7EE7\u7EED\u5BF9\u8BDD\u4ECD\u6709\u4EF7\u503C\u7684\u4FE1\u606F\uFF1A\u7528\u6237\u76EE\u6807/\u504F\u597D\u3001\u7EA6\u675F\u3001\u6280\u672F\u6808\u3001\u786E\u5B9A\u7684\u6587\u4EF6\u8DEF\u5F84\u3001\u6838\u5FC3\u51B3\u7B56\u3001\u672A\u5B8C\u6210\u5F85\u529E\u3002
1948
- 3) \u5BF9\u8BDD\u8FDB\u5C55\u4E0E\u5F85\u529E\uFF1A\u5148\u6781\u7B80\u6982\u62EC\u65E7\u4E0A\u4E0B\u6587\uFF0C\u518D\u66F4\u8BE6\u7EC6\u8BB0\u5F55\u6700\u8FD1\u8FDB\u5C55\u3001\u7ED3\u8BBA\u3001\u5206\u6B67\u4E0E\u4E0B\u4E00\u6B65\u3002
1949
- 4) \u6587\u4EF6\u64CD\u4F5C\u6E05\u5355\uFF1A\u5217\u51FA\u672C\u6B21\u538B\u7F29\u8303\u56F4\u5185\u8BFB\u53D6\u3001\u5199\u5165\u3001\u7F16\u8F91\u8FC7\u7684\u6587\u4EF6\u8DEF\u5F84\u53CA\u64CD\u4F5C\u7C7B\u578B\uFF08\u5982: - \u8BFB\u53D6: path/to/file\uFF1B\u82E5\u672A\u6D89\u53CA\u6587\u4EF6\u64CD\u4F5C\u5199"\u65E0"\uFF09\u3002
1950
- 5) \u5FFD\u7565\u5BD2\u6684\u3001\u91CD\u590D\u5C1D\u8BD5\u3001\u5DF2\u653E\u5F03\u65B9\u6848\u548C\u65E0\u4EF7\u503C\u5E9F\u8BDD\u3002
1951
- 6) \u4E0D\u8981\u7F16\u9020\u672A\u51FA\u73B0\u7684\u4FE1\u606F\uFF1B\u4E0D\u8981\u5F00\u573A\u767D\u3001\u7ED3\u675F\u8BED\u3001markdown \u4EE3\u7801\u5757\u6216\u989D\u5916\u7AE0\u8282\uFF1B\u4E0D\u8981\u8C03\u7528\u4EFB\u4F55\u5DE5\u5177\u3002`;
1952
- function extractFileOperations(msgs) {
1953
- const result = [];
1954
- const seen = /* @__PURE__ */ new Set();
1955
- for (const msg of msgs) {
1956
- if (!Array.isArray(msg.tool_calls)) continue;
1957
- for (const call of msg.tool_calls) {
1958
- const name = call.function?.name || call.name || "";
1959
- if (!name) continue;
1960
- const canonicalName = canonicalizeToolName(name);
1961
- const fileOperationByTool = {
1962
- readFile: "read",
1963
- writeFile: "write",
1964
- editFile: "edit"
1965
- };
1966
- const opType = fileOperationByTool[canonicalName];
1967
- if (!opType) continue;
1968
- let rawArgs = call.function?.arguments ?? call.arguments;
1969
- let parsedArgs = null;
1970
- if (typeof rawArgs === "string") {
1971
- try {
1972
- parsedArgs = JSON.parse(rawArgs);
1973
- } catch {
1974
- }
1975
- } else if (typeof rawArgs === "object" && rawArgs !== null) {
1976
- parsedArgs = rawArgs;
1977
- }
1978
- const path = parsedArgs?.path ?? parsedArgs?.filePath ?? parsedArgs?.file;
1979
- if (typeof path === "string" && path.trim()) {
1980
- const key = `${opType}:${path.trim()}`;
1981
- if (!seen.has(key)) {
1982
- seen.add(key);
1983
- result.push({ type: opType, path: path.trim() });
1984
- }
1985
- }
1986
- }
1987
- }
1988
- return result;
1989
- }
1990
- function formatFileOperations(msgs) {
1991
- const ops = extractFileOperations(msgs);
1992
- if (ops.length === 0) {
1993
- return "\u65E0";
1994
- }
1995
- const typeLabelMap = {
1996
- read: "\u8BFB\u53D6",
1997
- write: "\u5199\u5165",
1998
- edit: "\u7F16\u8F91"
1999
- };
2000
- return ops.map((op) => `- ${typeLabelMap[op.type]}: ${op.path}`).join("\n");
2001
- }
2002
- function buildLocalAutoCompactionUserContent(previousSummary, messagesText, fileOpsText) {
2003
- const parts = [`\u3010\u73B0\u6709\u8BB0\u5FC6\u3011\uFF1A
2004
- ${previousSummary || "(\u65E0)"}`];
2005
- if (fileOpsText !== void 0) {
2006
- parts.push(`\u3010\u6587\u4EF6\u64CD\u4F5C\u6E05\u5355\u3011\uFF1A
2007
- ${fileOpsText || "\u65E0"}`);
2008
- }
2009
- parts.push(`\u3010\u65B0\u589E\u5BF9\u8BDD\u3011\uFF1A
2010
- ${messagesText}`);
2011
- return parts.join("\n\n").trim();
2012
- }
2013
1942
  function toPlanCompressionMessages(history) {
2014
- return history.map((message, index) => {
2015
- const usage = message.usage;
2016
- return {
2017
- id: `local-${index}`,
2018
- role: message.role,
2019
- content: message.content,
2020
- ...Array.isArray(message.tool_calls) ? { tool_calls: message.tool_calls } : {},
2021
- ...usage?.completion_tokens != null ? { usage: { completion_tokens: usage.completion_tokens } } : {}
2022
- };
2023
- });
2024
- }
2025
- function formatMessagesForLocalSummary(msgs) {
2026
- return msgs.map((msg) => {
2027
- const content = serializeMessageContent(msg.content) || (Array.isArray(msg.tool_calls) ? `[tool_calls:${msg.tool_calls.map((c) => c.function?.name).filter(Boolean).join(",")}]` : "[\u975E\u6587\u672C\u5185\u5BB9]");
2028
- return `${msg.role}: ${content}`;
2029
- }).join("\n");
1943
+ return history.map((message, index) => ({
1944
+ id: `local-${index}`,
1945
+ role: message.role,
1946
+ content: message.content,
1947
+ ...Array.isArray(message.tool_calls) ? { tool_calls: message.tool_calls } : {}
1948
+ }));
2030
1949
  }
2031
1950
  function buildLocalSummaryHistoryMessage(summary) {
2032
1951
  const layer = buildDialogSummaryLayer({ summary });
@@ -2085,6 +2004,9 @@ async function maybeAutoCompactLocalHistory(args) {
2085
2004
  summarizedBeforeId,
2086
2005
  summary: existingSummary,
2087
2006
  contextWindow,
2007
+ // 防死亡螺旋:用 summary 长度作为上次压缩后的基线。如果新内容没让
2008
+ // totalUsed 比 summary 本身增长超过 minNewTokens,不重复触发。
2009
+ lastCompactedTokenCount: existingSummary ? estimateTokenCount(existingSummary) : void 0,
2088
2010
  ...coldResume ? { force: true, reason: "context_budget" } : {}
2089
2011
  });
2090
2012
  const projectExisting = () => {
@@ -2105,15 +2027,18 @@ async function maybeAutoCompactLocalHistory(args) {
2105
2027
  try {
2106
2028
  const provider = await args.resolveProvider();
2107
2029
  const msgsToCompress = plan.msgsToCompress;
2108
- const messagesText = formatMessagesForLocalSummary(msgsToCompress);
2109
- const fileOpsText = formatFileOperations(msgsToCompress);
2110
- const promptContent = buildLocalAutoCompactionUserContent(
2111
- existingSummary,
2030
+ const messagesText = formatMessagesForSummaryWithTruncation(msgsToCompress);
2031
+ const fileOpsText = formatFileOperationsFromMessages(
2032
+ msgsToCompress,
2033
+ canonicalizeToolName
2034
+ );
2035
+ const promptContent = buildCompactionUserContent({
2036
+ previousSummary: existingSummary,
2112
2037
  messagesText,
2113
2038
  fileOpsText
2114
- );
2039
+ });
2115
2040
  const result = await provider.complete([
2116
- { role: "system", content: LOCAL_AUTO_COMPACTION_SYSTEM_PROMPT },
2041
+ { role: "system", content: COMPACTION_SUMMARY_SYSTEM_PROMPT },
2117
2042
  { role: "user", content: promptContent }
2118
2043
  ]);
2119
2044
  const newSummary = typeof result.content === "string" ? result.content.trim() : "";
@@ -2128,6 +2053,14 @@ async function maybeAutoCompactLocalHistory(args) {
2128
2053
  summary: newSummary,
2129
2054
  summarizedBeforeId: plan.newSummarizedBeforeId
2130
2055
  });
2056
+ const metrics = buildCompactionMetricsFromPlan({
2057
+ reason: coldResume ? "cold_resume" : "context_budget",
2058
+ previousSummary: existingSummary,
2059
+ plan,
2060
+ newSummary,
2061
+ summaryUsage: result.usage
2062
+ });
2063
+ console.log(formatCompactionMetricsLog(metrics));
2131
2064
  return {
2132
2065
  history: projectHistoryWithSummary({
2133
2066
  history,
@@ -2136,7 +2069,8 @@ async function maybeAutoCompactLocalHistory(args) {
2136
2069
  }),
2137
2070
  compressed: true,
2138
2071
  summaryGenerated: true,
2139
- ...result.usage ? { usage: result.usage } : {}
2072
+ ...result.usage ? { usage: result.usage } : {},
2073
+ metrics
2140
2074
  };
2141
2075
  } catch (error) {
2142
2076
  console.warn("[localLoop] auto-compaction failed:", error);
@@ -4,6 +4,7 @@ var wrapHistoricalSummaryWithReplayGuard = (summary) => {
4
4
  if (!trimmed) return "";
5
5
  return [
6
6
  "\u3010\u5386\u53F2\u53C2\u8003\uFF0C\u975E\u6D3B\u6307\u4EE4\u3011\u4EE5\u4E0B\u4E3A\u51BB\u7ED3\u6458\u8981\uFF0C\u5176\u4E2D\u7684\u4EFB\u52A1/skill/ARGUMENTS \u9ED8\u8BA4\u5DF2\u8FC7\u671F\uFF0C\u4E0D\u5F97\u91CD\u65B0\u6267\u884C\u3002",
7
+ `\u6458\u8981\u4E2D\u6807\u6CE8\u300C\uFF08\u5F85\u9A8C\u8BC1\uFF09\u300D\u7684\u9879\u9700\u590D\u6838\u786E\u8BA4\uFF1B\u672A\u5B8C\u6210\u5F85\u529E\u548C\u300C\u4E0B\u4E00\u6B65\u300D\u9700\u7EE7\u7EED\u63A8\u8FDB\u2014\u2014\u8FD9\u4E9B\u662F\u7EED\u4F5C\u65B9\u5411\uFF0C\u4E0D\u662F\u91CD\u653E\u6307\u4EE4\u3002`,
7
8
  trimmed
8
9
  ].join("\n");
9
10
  };