nolo-cli 0.30.0 → 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-VBHHG7LT.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-LLGZXUYJ.js → agentDeleteCommand-7BBZCONG.js} +26 -25
  6. package/{agentEmailCommands-LC2FPN6G.js → agentEmailCommands-D6FAT5HM.js} +38 -37
  7. package/{agentListCommands-A6OBQ3QX.js → agentListCommands-YPNNMGSJ.js} +28 -27
  8. package/{agentMachineCommands-4O4Q5B5X.js → agentMachineCommands-VYRVSKUC.js} +26 -25
  9. package/{agentRecordCommands-W22RIQRV.js → agentRecordCommands-4J52H5NK.js} +37 -36
  10. package/{agentRunCommand-V4OBU4FB.js → agentRunCommand-LH4RA6FA.js} +38 -37
  11. package/{agentRunControl-AKBN2366.js → agentRunControl-SCIVRZWX.js} +9 -1
  12. package/{agentRuntimeLocal-I57YSGH4.js → agentRuntimeLocal-G7GK545E.js} +23 -22
  13. package/{agentSlice-3ZHY7RAO.js → agentSlice-4ZLEPC3M.js} +6 -6
  14. package/{appDeleteCommands-DJJF466K.js → appDeleteCommands-AOZED7QJ.js} +27 -26
  15. package/{appDeployCommands-WJZGIOEZ.js → appDeployCommands-XJY27BDS.js} +27 -26
  16. package/{appDeployStatusCommands-ICYXUJNO.js → appDeployStatusCommands-HKZYAPB2.js} +27 -26
  17. package/{appGetCommands-UOCWYJPV.js → appGetCommands-VXJLPRYI.js} +27 -26
  18. package/{appListCommands-EOKWTXPW.js → appListCommands-3LU6AB4G.js} +27 -26
  19. package/{authCommand-H5KE7K7K.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-SWOTB2TX.js → chunk-2MSOY7A5.js} +49 -33
  23. package/{chunk-W2YKDXT7.js → chunk-2YT3KLHX.js} +1 -1
  24. package/{chunk-HLG6GAUD.js → chunk-3IU7WEJD.js} +1 -1
  25. package/{chunk-Q24P6TUS.js → chunk-43EPBPZ2.js} +1 -1
  26. package/{chunk-3RIWR23B.js → chunk-4URO6HMS.js} +1 -1
  27. package/{chunk-UTQZ73QQ.js → chunk-5EDVWWE3.js} +1 -1
  28. package/{chunk-GVKTKT3O.js → chunk-5JQRISUS.js} +3 -3
  29. package/{chunk-GAGUBI42.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-MEUZFIAJ.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-DI6MXJK5.js → chunk-C3NYMZTQ.js} +16 -14
  36. package/{chunk-HI7QZNWX.js → chunk-CPUZW54L.js} +4 -4
  37. package/{chunk-PJY5AH5A.js → chunk-DPR66GY6.js} +1 -1
  38. package/{chunk-MMCVBEAD.js → chunk-E2CFIWQR.js} +42 -32
  39. package/{chunk-YWGSCF37.js → chunk-E3APEOIM.js} +1 -1
  40. package/{chunk-UKC5HU2C.js → chunk-EATVNXFX.js} +7 -7
  41. package/{chunk-G5JHHUAK.js → chunk-F3MP7CP6.js} +1 -1
  42. package/{chunk-FS5TTXPS.js → chunk-FLYQAMF4.js} +3 -3
  43. package/{chunk-446VANPP.js → chunk-G5GVZAXF.js} +4 -4
  44. package/{chunk-KWKD3BCC.js → chunk-H6COXALE.js} +78 -27
  45. package/{chunk-56IUA7RU.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-L3VQOVKK.js → chunk-LBEWOWVL.js} +4 -4
  49. package/{chunk-66O5MZYH.js → chunk-NEGMZP6Q.js} +1 -1
  50. package/{chunk-7CD24PU4.js → chunk-NMK2JHKM.js} +9 -7
  51. package/{chunk-QLV2GKU5.js → chunk-OT2AXEQD.js} +26 -5
  52. package/{chunk-CV6I4HBA.js → chunk-PTHDLIRB.js} +1 -1
  53. package/{chunk-2XM5KUNE.js → chunk-Q6L3O67D.js} +2 -2
  54. package/{chunk-G6VITLCZ.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-T3Y5EMJS.js → chunk-SFWZUTCI.js} +1 -1
  58. package/{chunk-XD5NQEOH.js → chunk-UDA3ZYLW.js} +1 -1
  59. package/{chunk-YLADSPDU.js → chunk-V54H24CQ.js} +2 -2
  60. package/{chunk-SZ5CBYMZ.js → chunk-WEID4JLC.js} +2 -2
  61. package/{chunk-KW47OSRJ.js → chunk-WMH2G6XJ.js} +91 -179
  62. package/{chunk-4PWB7JRR.js → chunk-XFG3BAKN.js} +1 -0
  63. package/chunk-XGJ75KN2.js +7889 -0
  64. package/{chunk-OYK7PA5U.js → chunk-XPML3KYZ.js} +6 -6
  65. package/{chunk-TJYWZ3LO.js → chunk-YHGHADBQ.js} +2 -2
  66. package/{chunk-DCWBP2O7.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-3GMH6ORX.js → createAgentAutomationAction-AECD5YCU.js} +13 -12
  70. package/{createDialogAction-R5MCL4RE.js → createDialogAction-MZUC37CA.js} +14 -13
  71. package/{createPageAction-QYTG656R.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-NUQGIXVZ.js → dialogCommands-RFADXVV6.js} +27 -26
  76. package/{dialogSlice-CFDECXEU.js → dialogSlice-EWNZ2HFD.js} +12 -12
  77. package/{docCreateCommands-UNFCXB5N.js → docCreateCommands-ZHX6SX5M.js} +26 -25
  78. package/{docDeleteCommands-NG5IVKE5.js → docDeleteCommands-3EEM7ITO.js} +27 -26
  79. package/{docReadCommands-6J7MUUX6.js → docReadCommands-JOMLMZTC.js} +26 -25
  80. package/{docStore-MZZWJM4F.js → docStore-YKTKKH3N.js} +14 -13
  81. package/{docUpdateCommands-6AW3VZOX.js → docUpdateCommands-PGAYLKLC.js} +26 -25
  82. package/{getPricing-XQYSSVV6.js → getPricing-QO5TYNCK.js} +2 -2
  83. package/{handleSendMessageAction-IU2QNTLM.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-Z2QEWTHZ.js → machineCommands-A2WFB37F.js} +36 -35
  87. package/{machineWsRunDispatch-SJTYHZHN.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-EY3BPXIU.js → readlineWorkspace-S4A6UYVJ.js} +125 -79
  92. package/{removeDialogAgentAction-TBW3UZJW.js → removeDialogAgentAction-NEKVAMSH.js} +7 -7
  93. package/{runAgentClientLoop-N3YDLTMS.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-R6AEQNLG.js → spaceCommands-SKCMLOC6.js} +210 -28
  99. package/{spaceSlice-MCH7RLLP.js → spaceSlice-6VOPELQN.js} +13 -12
  100. package/{streamAgentChatTurn-Q4U2CVMI.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-Y3UBLLYW.js → tools-IN4B36PN.js} +21 -20
  104. package/{tuiSummaryLlmCaller-4474IBTI.js → tuiSummaryLlmCaller-SRZ4QQUP.js} +19 -5
  105. package/{updateDialogTitleAction-3J7GH67I.js → updateDialogTitleAction-4ABIVEYY.js} +18 -16
  106. package/chunk-OB6FBSH3.js +0 -47
  107. package/chunk-THTAR67C.js +0 -16338
  108. package/chunk-VSTUQGLT.js +0 -4937
@@ -11,7 +11,7 @@ import {
11
11
  getAntigravityUserAgent,
12
12
  normalizeAntigravityTokenPayload,
13
13
  refreshAntigravityToken
14
- } from "./chunk-TJYWZ3LO.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-VSTUQGLT.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-56IUA7RU.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-7CD24PU4.js";
12
+ } from "./chunk-NMK2JHKM.js";
13
13
  import {
14
14
  getAllToolRuns,
15
15
  resolveAgentRecommendedSkillNames,
16
16
  resolveAgentRequiredPackIds
17
- } from "./chunk-OYK7PA5U.js";
17
+ } from "./chunk-XPML3KYZ.js";
18
18
  import {
19
19
  getDocState
20
- } from "./chunk-FS5TTXPS.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-YWGSCF37.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-THTAR67C.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-VSTUQGLT.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";
@@ -858,11 +865,6 @@ var buildEditingContextSummary = (state, runtimeOptions) => {
858
865
  };
859
866
 
860
867
  // packages/ai/llm/agentCapabilities.ts
861
- var isCustomAgent = (agent) => {
862
- const apiSource = agent.apiSource?.toLowerCase();
863
- const provider = agent.provider?.toLowerCase();
864
- return apiSource === "custom" || provider === "custom";
865
- };
866
868
  var ANTIGRAVITY_EFFORT_SUFFIXES = [
867
869
  "-tiered",
868
870
  "-extra-low",
@@ -893,21 +895,21 @@ var lookupKnownModelVision = (provider, model) => {
893
895
  const strippedPreview = stripPreviewSuffix(model);
894
896
  if (strippedPreview !== model) candidates.push(strippedPreview);
895
897
  for (const candidate of candidates) {
896
- if (provider) {
898
+ if (provider && provider !== "custom") {
897
899
  const direct = findModelConfig(provider, candidate);
898
- if (direct) return direct.hasVision;
900
+ if (direct && typeof direct.hasVision === "boolean") return direct.hasVision;
899
901
  }
900
902
  const detected = getProviderByModelName(candidate);
901
903
  if (detected) {
902
904
  const found = findModelConfig(detected, candidate)?.hasVision;
903
905
  if (found !== void 0) return found;
904
906
  }
905
- if (!provider && candidate.includes("/")) {
907
+ if (candidate.includes("/")) {
906
908
  const slash = candidate.indexOf("/");
907
909
  const modelProvider = candidate.slice(0, slash).toLowerCase();
908
910
  const modelName = candidate.slice(slash + 1);
909
911
  const nested = findModelConfig(modelProvider, modelName);
910
- if (nested) return nested.hasVision;
912
+ if (nested && typeof nested.hasVision === "boolean") return nested.hasVision;
911
913
  }
912
914
  }
913
915
  return void 0;
@@ -916,18 +918,13 @@ var resolveAgentImageInputSupport = (agent) => {
916
918
  if (!agent) return true;
917
919
  const provider = asTrimmedLowercaseString(agent.provider) || null;
918
920
  const model = asOptionalTrimmedString(agent.model) ?? "";
919
- const custom = isCustomAgent(agent);
920
921
  const catalogHasVision = lookupKnownModelVision(
921
- custom ? null : provider,
922
+ provider,
922
923
  model
923
924
  );
924
- if (!custom && catalogHasVision !== void 0) {
925
+ if (catalogHasVision !== void 0) {
925
926
  return catalogHasVision;
926
927
  }
927
- if (custom) {
928
- if (catalogHasVision === true) return true;
929
- return true;
930
- }
931
928
  if (typeof agent.hasVision === "boolean") {
932
929
  return agent.hasVision;
933
930
  }
@@ -1219,7 +1216,7 @@ ${content}
1219
1216
  return output;
1220
1217
  };
1221
1218
  var validateAccessAndBalance = (agentConfig, state) => {
1222
- const userBalance = selectCurrentUserBalance(state);
1219
+ const userBalance = selectIdentityUserBalance(state);
1223
1220
  const currentUserId = selectIdentityUserId(state);
1224
1221
  const isCustomApi = agentConfig.apiSource === "custom";
1225
1222
  const isCliApi = agentConfig.apiSource === "cli";
@@ -1942,101 +1939,13 @@ var normalizeContextBlockScopes = (legacyBlocks = void 0, scopes = void 0) => {
1942
1939
  };
1943
1940
 
1944
1941
  // packages/agent-runtime/localAutoCompaction.ts
1945
- 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
1946
-
1947
- \u4E25\u683C\u53EA\u8F93\u51FA\u4E0B\u9762\u4E09\u90E8\u5206\uFF0C\u6807\u9898\u5FC5\u987B\u5B8C\u5168\u4E00\u81F4\uFF1A
1948
- \u5173\u952E\u4E8B\u5B9E\u6863\u6848
1949
- - ...
1950
- \u5BF9\u8BDD\u8FDB\u5C55\u4E0E\u5F85\u529E
1951
- - ...
1952
- \u6587\u4EF6\u64CD\u4F5C\u6E05\u5355
1953
- - ...
1954
-
1955
- \u8981\u6C42\uFF1A
1956
- 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
1957
- 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
1958
- 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
1959
- 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
1960
- 5) \u5FFD\u7565\u5BD2\u6684\u3001\u91CD\u590D\u5C1D\u8BD5\u3001\u5DF2\u653E\u5F03\u65B9\u6848\u548C\u65E0\u4EF7\u503C\u5E9F\u8BDD\u3002
1961
- 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`;
1962
- function extractFileOperations(msgs) {
1963
- const result = [];
1964
- const seen = /* @__PURE__ */ new Set();
1965
- for (const msg of msgs) {
1966
- if (!Array.isArray(msg.tool_calls)) continue;
1967
- for (const call of msg.tool_calls) {
1968
- const name = call.function?.name || call.name || "";
1969
- if (!name) continue;
1970
- const canonicalName = canonicalizeToolName(name);
1971
- const fileOperationByTool = {
1972
- readFile: "read",
1973
- writeFile: "write",
1974
- editFile: "edit"
1975
- };
1976
- const opType = fileOperationByTool[canonicalName];
1977
- if (!opType) continue;
1978
- let rawArgs = call.function?.arguments ?? call.arguments;
1979
- let parsedArgs = null;
1980
- if (typeof rawArgs === "string") {
1981
- try {
1982
- parsedArgs = JSON.parse(rawArgs);
1983
- } catch {
1984
- }
1985
- } else if (typeof rawArgs === "object" && rawArgs !== null) {
1986
- parsedArgs = rawArgs;
1987
- }
1988
- const path = parsedArgs?.path ?? parsedArgs?.filePath ?? parsedArgs?.file;
1989
- if (typeof path === "string" && path.trim()) {
1990
- const key = `${opType}:${path.trim()}`;
1991
- if (!seen.has(key)) {
1992
- seen.add(key);
1993
- result.push({ type: opType, path: path.trim() });
1994
- }
1995
- }
1996
- }
1997
- }
1998
- return result;
1999
- }
2000
- function formatFileOperations(msgs) {
2001
- const ops = extractFileOperations(msgs);
2002
- if (ops.length === 0) {
2003
- return "\u65E0";
2004
- }
2005
- const typeLabelMap = {
2006
- read: "\u8BFB\u53D6",
2007
- write: "\u5199\u5165",
2008
- edit: "\u7F16\u8F91"
2009
- };
2010
- return ops.map((op) => `- ${typeLabelMap[op.type]}: ${op.path}`).join("\n");
2011
- }
2012
- function buildLocalAutoCompactionUserContent(previousSummary, messagesText, fileOpsText) {
2013
- const parts = [`\u3010\u73B0\u6709\u8BB0\u5FC6\u3011\uFF1A
2014
- ${previousSummary || "(\u65E0)"}`];
2015
- if (fileOpsText !== void 0) {
2016
- parts.push(`\u3010\u6587\u4EF6\u64CD\u4F5C\u6E05\u5355\u3011\uFF1A
2017
- ${fileOpsText || "\u65E0"}`);
2018
- }
2019
- parts.push(`\u3010\u65B0\u589E\u5BF9\u8BDD\u3011\uFF1A
2020
- ${messagesText}`);
2021
- return parts.join("\n\n").trim();
2022
- }
2023
1942
  function toPlanCompressionMessages(history) {
2024
- return history.map((message, index) => {
2025
- const usage = message.usage;
2026
- return {
2027
- id: `local-${index}`,
2028
- role: message.role,
2029
- content: message.content,
2030
- ...Array.isArray(message.tool_calls) ? { tool_calls: message.tool_calls } : {},
2031
- ...usage?.completion_tokens != null ? { usage: { completion_tokens: usage.completion_tokens } } : {}
2032
- };
2033
- });
2034
- }
2035
- function formatMessagesForLocalSummary(msgs) {
2036
- return msgs.map((msg) => {
2037
- 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]");
2038
- return `${msg.role}: ${content}`;
2039
- }).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
+ }));
2040
1949
  }
2041
1950
  function buildLocalSummaryHistoryMessage(summary) {
2042
1951
  const layer = buildDialogSummaryLayer({ summary });
@@ -2095,6 +2004,9 @@ async function maybeAutoCompactLocalHistory(args) {
2095
2004
  summarizedBeforeId,
2096
2005
  summary: existingSummary,
2097
2006
  contextWindow,
2007
+ // 防死亡螺旋:用 summary 长度作为上次压缩后的基线。如果新内容没让
2008
+ // totalUsed 比 summary 本身增长超过 minNewTokens,不重复触发。
2009
+ lastCompactedTokenCount: existingSummary ? estimateTokenCount(existingSummary) : void 0,
2098
2010
  ...coldResume ? { force: true, reason: "context_budget" } : {}
2099
2011
  });
2100
2012
  const projectExisting = () => {
@@ -2115,15 +2027,18 @@ async function maybeAutoCompactLocalHistory(args) {
2115
2027
  try {
2116
2028
  const provider = await args.resolveProvider();
2117
2029
  const msgsToCompress = plan.msgsToCompress;
2118
- const messagesText = formatMessagesForLocalSummary(msgsToCompress);
2119
- const fileOpsText = formatFileOperations(msgsToCompress);
2120
- const promptContent = buildLocalAutoCompactionUserContent(
2121
- existingSummary,
2030
+ const messagesText = formatMessagesForSummaryWithTruncation(msgsToCompress);
2031
+ const fileOpsText = formatFileOperationsFromMessages(
2032
+ msgsToCompress,
2033
+ canonicalizeToolName
2034
+ );
2035
+ const promptContent = buildCompactionUserContent({
2036
+ previousSummary: existingSummary,
2122
2037
  messagesText,
2123
2038
  fileOpsText
2124
- );
2039
+ });
2125
2040
  const result = await provider.complete([
2126
- { role: "system", content: LOCAL_AUTO_COMPACTION_SYSTEM_PROMPT },
2041
+ { role: "system", content: COMPACTION_SUMMARY_SYSTEM_PROMPT },
2127
2042
  { role: "user", content: promptContent }
2128
2043
  ]);
2129
2044
  const newSummary = typeof result.content === "string" ? result.content.trim() : "";
@@ -2138,6 +2053,14 @@ async function maybeAutoCompactLocalHistory(args) {
2138
2053
  summary: newSummary,
2139
2054
  summarizedBeforeId: plan.newSummarizedBeforeId
2140
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));
2141
2064
  return {
2142
2065
  history: projectHistoryWithSummary({
2143
2066
  history,
@@ -2146,7 +2069,8 @@ async function maybeAutoCompactLocalHistory(args) {
2146
2069
  }),
2147
2070
  compressed: true,
2148
2071
  summaryGenerated: true,
2149
- ...result.usage ? { usage: result.usage } : {}
2072
+ ...result.usage ? { usage: result.usage } : {},
2073
+ metrics
2150
2074
  };
2151
2075
  } catch (error) {
2152
2076
  console.warn("[localLoop] auto-compaction failed:", error);
@@ -2887,13 +2811,35 @@ async function runLocalAgentTurn(input) {
2887
2811
  input: input.input,
2888
2812
  contextReferenceResolver: input.adapter.host === "cli" ? input.contextReferenceResolver : void 0
2889
2813
  });
2890
- const messages = builtMessages.messages;
2814
+ let messages = builtMessages.messages;
2891
2815
  const supportsImages = resolveAgentImageInputSupport({
2892
2816
  apiSource: agentConfig.apiSource,
2893
2817
  provider: agentConfig.provider,
2894
2818
  model: agentConfig.model,
2895
2819
  hasVision: agentConfig.hasVision
2896
2820
  });
2821
+ if (!supportsImages && hasImageInRuntimeMessages(messages)) {
2822
+ const imageUrls = extractImageUrlsFromMessages(messages);
2823
+ const preprocessed = await preprocessImagesForTextOnlyAgent(
2824
+ messages,
2825
+ (urls) => describeImageWithLocalProvider(input.adapter, urls)
2826
+ );
2827
+ if (preprocessed !== messages) {
2828
+ messages = preprocessed;
2829
+ emitLoopEvent(input, {
2830
+ kind: "image-preprocessed",
2831
+ atMs: Date.now(),
2832
+ imageCount: imageUrls.length
2833
+ });
2834
+ } else {
2835
+ messages = filterImagePartsFromMessages(messages, false);
2836
+ emitLoopEvent(input, {
2837
+ kind: "image-downgraded",
2838
+ reason: "no-vision",
2839
+ atMs: Date.now()
2840
+ });
2841
+ }
2842
+ }
2897
2843
  const userInputText = extractUserInputText(input.input);
2898
2844
  let toolCallCount = 0;
2899
2845
  let result;
@@ -2904,7 +2850,6 @@ async function runLocalAgentTurn(input) {
2904
2850
  let round = 0;
2905
2851
  let emptyAssistantRepairPending = false;
2906
2852
  let emptyAssistantRepairUsed = false;
2907
- let imageDowngradeNotified = false;
2908
2853
  let skipFinalAppend = false;
2909
2854
  let partialContent = "";
2910
2855
  try {
@@ -2913,43 +2858,10 @@ async function runLocalAgentTurn(input) {
2913
2858
  partialContent = "";
2914
2859
  throwIfAborted(input);
2915
2860
  const preparedMessages = prepareMessagesForProviderCall(messages);
2916
- let baseRequestMessages;
2917
- if (!supportsImages && hasImageInRuntimeMessages(preparedMessages.messages)) {
2918
- const imageUrls = extractImageUrlsFromMessages(preparedMessages.messages);
2919
- const preprocessed = await preprocessImagesForTextOnlyAgent(
2920
- preparedMessages.messages,
2921
- (urls) => describeImageWithLocalProvider(input.adapter, urls)
2922
- );
2923
- if (preprocessed !== preparedMessages.messages) {
2924
- baseRequestMessages = preprocessed;
2925
- if (!imageDowngradeNotified) {
2926
- imageDowngradeNotified = true;
2927
- emitLoopEvent(input, {
2928
- kind: "image-preprocessed",
2929
- atMs: Date.now(),
2930
- imageCount: imageUrls.length
2931
- });
2932
- }
2933
- } else {
2934
- baseRequestMessages = filterImagePartsFromMessages(
2935
- preparedMessages.messages,
2936
- supportsImages
2937
- );
2938
- if (!imageDowngradeNotified) {
2939
- imageDowngradeNotified = true;
2940
- emitLoopEvent(input, {
2941
- kind: "image-downgraded",
2942
- reason: "no-vision",
2943
- atMs: Date.now()
2944
- });
2945
- }
2946
- }
2947
- } else {
2948
- baseRequestMessages = filterImagePartsFromMessages(
2949
- preparedMessages.messages,
2950
- supportsImages
2951
- );
2952
- }
2861
+ const baseRequestMessages = filterImagePartsFromMessages(
2862
+ preparedMessages.messages,
2863
+ supportsImages
2864
+ );
2953
2865
  const requestMessages = emptyAssistantRepairPending ? [...baseRequestMessages, { role: "user", content: EMPTY_ASSISTANT_REPAIR_PROMPT }] : baseRequestMessages;
2954
2866
  const contextMetrics = {
2955
2867
  ...preparedMessages.metrics,
@@ -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
  };