nolo-cli 0.97.0-alpha.1 → 0.98.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 (58) hide show
  1. package/{_executeModel-JIG7MRXQ.js → _executeModel-FHVQOYWX.js} +13 -13
  2. package/{agentDeleteCommand-THAZ5GQS.js → agentDeleteCommand-4427YKQF.js} +6 -6
  3. package/{agentEmailCommands-A7T7AJA4.js → agentEmailCommands-LYDIAUOP.js} +15 -15
  4. package/{agentListCommands-BRZFEJQM.js → agentListCommands-O4AEMQVV.js} +6 -6
  5. package/{agentMachineCommands-DM4N5PK3.js → agentMachineCommands-F6IHXMPD.js} +7 -7
  6. package/{agentRecordCommands-TTAEMNHB.js → agentRecordCommands-BDLFOU7E.js} +15 -15
  7. package/{agentRunCommand-JVSTGVG2.js → agentRunCommand-HSSYFGMC.js} +15 -15
  8. package/{agentRuntimeLocal-73CVIWBB.js → agentRuntimeLocal-IW3IM5P6.js} +6 -6
  9. package/{agentSlice-6X4JL2E3.js → agentSlice-G54NT6PX.js} +1 -1
  10. package/{appDeleteCommands-S7CK4OYL.js → appDeleteCommands-ZXLXNRHF.js} +6 -6
  11. package/{appDeployCommands-U6TMS5GO.js → appDeployCommands-PWB4YERK.js} +6 -6
  12. package/{appDeployStatusCommands-DTNQJ3LJ.js → appDeployStatusCommands-2EZKZP7Y.js} +6 -6
  13. package/{appGetCommands-3SHZEQD5.js → appGetCommands-JNUKOWHO.js} +6 -6
  14. package/{appListCommands-E2ZMIUB6.js → appListCommands-6X3H67SS.js} +6 -6
  15. package/{chatQueueReduxAdapter-LAQEZQKE.js → chatQueueReduxAdapter-VJXYSZ2D.js} +4 -4
  16. package/{chunk-OF7AQZUG.js → chunk-2YMRWISD.js} +1 -1
  17. package/{chunk-3IIEFNGY.js → chunk-4EZHSKTB.js} +1 -1
  18. package/{chunk-Y5HW6GM2.js → chunk-7REEVK4I.js} +2 -2
  19. package/{chunk-WADCY6G6.js → chunk-ASQYTZTR.js} +43 -6
  20. package/{chunk-ESWUWEFS.js → chunk-AVV3M6CX.js} +3 -3
  21. package/{chunk-R2B3MIZA.js → chunk-DL2LVM5E.js} +2 -2
  22. package/{chunk-HWIZU4OL.js → chunk-F5OE5KSJ.js} +1 -1
  23. package/{chunk-54ADB4W7.js → chunk-FEEHCOBD.js} +1 -1
  24. package/{chunk-TZJJ77KQ.js → chunk-GGMVRZRO.js} +9 -9
  25. package/{chunk-LXF6XQDT.js → chunk-HOBJGHLD.js} +25 -11
  26. package/{chunk-3WD6RUUJ.js → chunk-IIBAPOTQ.js} +2 -2
  27. package/{chunk-LZIWMYX4.js → chunk-L7I247DF.js} +1 -1
  28. package/{chunk-JAXOVNM4.js → chunk-NEDZDG3M.js} +1 -1
  29. package/{chunk-7OLPQSMQ.js → chunk-RTUYRRBM.js} +1 -1
  30. package/{chunk-ZWUOR654.js → chunk-SDTTBMBU.js} +105 -36
  31. package/{chunk-YVIV7WT4.js → chunk-SL4QHSPQ.js} +13 -9
  32. package/{chunk-6FVRQBRR.js → chunk-SPUTJ4DW.js} +4 -4
  33. package/{chunk-K4YGZD3P.js → chunk-STHU4Y5X.js} +18 -14
  34. package/{chunk-JCIHVIVG.js → chunk-VQW3EKYS.js} +6 -6
  35. package/{chunk-SQQVLHMH.js → chunk-XTAZCQUT.js} +3 -3
  36. package/{contentThunks-ATLWNC2D.js → contentThunks-D6QQKIPF.js} +5 -5
  37. package/{createAgentAutomationAction-QYYWTVUR.js → createAgentAutomationAction-UIPWW4DG.js} +5 -5
  38. package/{createDialogAction-7I5VGWCR.js → createDialogAction-573VVP3X.js} +6 -6
  39. package/{createPageAction-WNURYCWU.js → createPageAction-LRFSS6TD.js} +5 -5
  40. package/{dialogCommands-RILHDRQ5.js → dialogCommands-KFK2FF5B.js} +6 -6
  41. package/{dialogSlice-W5BYELVR.js → dialogSlice-EXLC5XTD.js} +4 -4
  42. package/{docCreateCommands-GSTPU7SG.js → docCreateCommands-V777WOZ7.js} +6 -6
  43. package/{docDeleteCommands-2FC3LSUT.js → docDeleteCommands-5KHT7Z5Q.js} +6 -6
  44. package/{docReadCommands-27POBA34.js → docReadCommands-BLROGWP3.js} +6 -6
  45. package/{docStore-7LAHBFP2.js → docStore-DZNGJXX7.js} +1 -1
  46. package/{docUpdateCommands-U4II6VCO.js → docUpdateCommands-QXOZHQ5H.js} +6 -6
  47. package/{handleSendMessageAction-SKMJMVRU.js → handleSendMessageAction-OROTZBPO.js} +4 -4
  48. package/index.js +42 -42
  49. package/{machineCommands-S2RNYKVJ.js → machineCommands-IJWERHRH.js} +15 -15
  50. package/{machineWsRunDispatch-JC44LBLP.js → machineWsRunDispatch-XQ36M4L7.js} +15 -15
  51. package/package.json +1 -1
  52. package/{readlineWorkspace-VZSBXUH4.js → readlineWorkspace-EB3362L3.js} +18 -15
  53. package/{runAgentClientLoop-ZYENU7GH.js → runAgentClientLoop-3MR2NPWR.js} +11 -11
  54. package/{spaceCommands-QB3NNEMN.js → spaceCommands-TIDVUPDV.js} +6 -6
  55. package/{streamAgentChatTurn-43GPPQSN.js → streamAgentChatTurn-CLP2JWCQ.js} +13 -13
  56. package/{tools-SX6Y4STZ.js → tools-OXEEBABR.js} +8 -8
  57. package/{tuiSummaryLlmCaller-T2SHYMDZ.js → tuiSummaryLlmCaller-VJY3YD2Q.js} +2 -2
  58. package/{updateDialogTitleAction-VAKA4ZNY.js → updateDialogTitleAction-4YWKF2OE.js} +5 -5
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  toolRegistry
3
- } from "./chunk-TZJJ77KQ.js";
3
+ } from "./chunk-GGMVRZRO.js";
4
4
  import {
5
5
  i18n_default
6
- } from "./chunk-K4YGZD3P.js";
6
+ } from "./chunk-STHU4Y5X.js";
7
7
  import {
8
8
  canonicalizeToolNames
9
9
  } from "./chunk-O6OSWFZQ.js";
@@ -409,13 +409,14 @@ var normalizeContextUsageRatio = (value) => {
409
409
  const ratio = value > 1 ? value / 100 : value;
410
410
  return ratio >= 0 && ratio <= 1 ? ratio : void 0;
411
411
  };
412
- var emptyPlan = (startIndex) => ({
412
+ var emptyPlan = (startIndex, diagnostics) => ({
413
413
  shouldCompress: false,
414
414
  compressCount: 0,
415
415
  msgsToCompress: [],
416
416
  msgsToKeep: [],
417
417
  newSummarizedBeforeId: void 0,
418
- startIndex
418
+ startIndex,
419
+ ...diagnostics ? { diagnostics } : {}
419
420
  });
420
421
  function findPendingMessages(allMsgs, summarizedBeforeId) {
421
422
  let startIndex = 0;
@@ -489,7 +490,20 @@ function planCompression(input) {
489
490
  coldResume
490
491
  } = input;
491
492
  const { pendingMsgs, startIndex } = findPendingMessages(allMsgs, summarizedBeforeId);
492
- if (pendingMsgs.length === 0) return emptyPlan(startIndex);
493
+ if (pendingMsgs.length === 0) {
494
+ return emptyPlan(startIndex, {
495
+ pendingMsgCount: 0,
496
+ totalUsed: estimateTokenCount(summary || ""),
497
+ historyBudget: 0,
498
+ triggerRatio: resolveCompressionTriggerRatio(contextWindow),
499
+ realUsageRatio: normalizeContextUsageRatio(realContextUsagePercent),
500
+ triggeredByRealUsage: false,
501
+ triggeredByEstimate: false,
502
+ triggeredByColdResume: false,
503
+ shouldRunActiveSummary: false,
504
+ emptyReason: "no-pending"
505
+ });
506
+ }
493
507
  const summaryTokens = estimateTokenCount(summary || "");
494
508
  const pendingTokens = pendingMsgs.reduce((sum, msg) => sum + getMessageTokenCount(msg), 0);
495
509
  const totalUsed = summaryTokens + pendingTokens;
@@ -517,14 +531,36 @@ function planCompression(input) {
517
531
  coldResume,
518
532
  lastMsg: pendingMsgs[pendingMsgs.length - 1]
519
533
  });
520
- if (!trigger) return emptyPlan(startIndex);
534
+ const diagnostics = {
535
+ pendingMsgCount: pendingMsgs.length,
536
+ totalUsed,
537
+ historyBudget,
538
+ triggerRatio,
539
+ realUsageRatio: normalizeContextUsageRatio(realContextUsagePercent),
540
+ triggeredByRealUsage,
541
+ triggeredByEstimate: normalizeContextUsageRatio(realContextUsagePercent) === void 0 && totalUsed >= historyBudget,
542
+ triggeredByColdResume,
543
+ shouldRunActiveSummary
544
+ };
545
+ if (!trigger) {
546
+ return emptyPlan(startIndex, {
547
+ ...diagnostics,
548
+ emptyReason: "not-triggered"
549
+ });
550
+ }
521
551
  let compressCount = calculateCompressCount(pendingMsgs, rawMessageBudget, {
522
552
  keepTailCount: shouldRunActiveSummary || triggeredByRealUsage || triggeredByColdResume,
523
553
  totalUsed,
524
554
  historyBudget
525
555
  });
526
556
  compressCount = guardToolChainBoundary(pendingMsgs, compressCount);
527
- if (compressCount < MIN_COMPRESS_COUNT) return emptyPlan(startIndex);
557
+ if (compressCount < MIN_COMPRESS_COUNT) {
558
+ return emptyPlan(startIndex, {
559
+ ...diagnostics,
560
+ compressCount,
561
+ emptyReason: "below-min-compress-count"
562
+ });
563
+ }
528
564
  const msgsToCompress = pendingMsgs.slice(0, compressCount);
529
565
  const msgsToKeep = pendingMsgs.slice(compressCount);
530
566
  const newSummarizedBeforeId = msgsToCompress[msgsToCompress.length - 1].id;
@@ -534,7 +570,8 @@ function planCompression(input) {
534
570
  msgsToCompress,
535
571
  msgsToKeep,
536
572
  newSummarizedBeforeId,
537
- startIndex
573
+ startIndex,
574
+ diagnostics: { ...diagnostics, compressCount }
538
575
  };
539
576
  }
540
577
 
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  createCliLocalRuntimeAdapter,
3
3
  summarizeEndpoint
4
- } from "./chunk-YVIV7WT4.js";
4
+ } from "./chunk-SL4QHSPQ.js";
5
5
  import {
6
6
  clipMultilineText
7
- } from "./chunk-TZJJ77KQ.js";
7
+ } from "./chunk-GGMVRZRO.js";
8
8
  import {
9
9
  runLocalAgentTurn
10
- } from "./chunk-ZWUOR654.js";
10
+ } from "./chunk-SDTTBMBU.js";
11
11
  import {
12
12
  applyToolSurfaceConstraints
13
13
  } from "./chunk-IIVGDG4I.js";
@@ -326,7 +326,7 @@ async function saveDocState(arg, { dispatch, getState }) {
326
326
  ).unwrap();
327
327
  if (dbSpaceId) {
328
328
  try {
329
- const { updateContentTitle } = await import("./contentThunks-ATLWNC2D.js");
329
+ const { updateContentTitle } = await import("./contentThunks-D6QQKIPF.js");
330
330
  await dispatch(
331
331
  updateContentTitle({
332
332
  spaceId: dbSpaceId,
@@ -365,7 +365,7 @@ async function saveDocState(arg, { dispatch, getState }) {
365
365
  }
366
366
  }
367
367
  async function createDocState(args, thunkApi) {
368
- const { createPageAction } = await import("./createPageAction-WNURYCWU.js");
368
+ const { createPageAction } = await import("./createPageAction-LRFSS6TD.js");
369
369
  return createPageAction(args, thunkApi);
370
370
  }
371
371
  function subscribe(listener) {
@@ -9,7 +9,7 @@ import {
9
9
  initReactI18next,
10
10
  instance,
11
11
  toast
12
- } from "./chunk-K4YGZD3P.js";
12
+ } from "./chunk-STHU4Y5X.js";
13
13
  import {
14
14
  require_date_fns
15
15
  } from "./chunk-M76ECQRD.js";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  fetchReferenceContents,
3
3
  resolveReferenceAssets
4
- } from "./chunk-6FVRQBRR.js";
4
+ } from "./chunk-SPUTJ4DW.js";
5
5
 
6
6
  // packages/ai/agent/fetchAgentContexts.ts
7
7
  async function fetchAgentContexts(references, dispatch) {
@@ -81,10 +81,10 @@ import {
81
81
  } from "./chunk-VF4K2QE6.js";
82
82
  import {
83
83
  createDocState
84
- } from "./chunk-R2B3MIZA.js";
84
+ } from "./chunk-DL2LVM5E.js";
85
85
  import {
86
86
  createDialogAction
87
- } from "./chunk-3WD6RUUJ.js";
87
+ } from "./chunk-IIBAPOTQ.js";
88
88
  import {
89
89
  DEFAULT_COLLAPSED_CATEGORIES,
90
90
  addContentToSpace,
@@ -102,7 +102,7 @@ import {
102
102
  updateContentCategory,
103
103
  updateContentTitle,
104
104
  writeStoredCollapsedCategories
105
- } from "./chunk-HWIZU4OL.js";
105
+ } from "./chunk-F5OE5KSJ.js";
106
106
  import {
107
107
  getCurrentSpaceId,
108
108
  getCurrentSpaceIdRaw,
@@ -124,14 +124,14 @@ import {
124
124
  selectMsgById,
125
125
  uiAskChoiceFunc,
126
126
  uiAskChoiceFunctionSchema
127
- } from "./chunk-K4YGZD3P.js";
127
+ } from "./chunk-STHU4Y5X.js";
128
128
  import {
129
129
  createAgent,
130
130
  deleteServerSyncedCredential,
131
131
  runLlm,
132
132
  streamAgentChatTurn,
133
133
  updateAgent
134
- } from "./chunk-SQQVLHMH.js";
134
+ } from "./chunk-XTAZCQUT.js";
135
135
  import {
136
136
  getActiveDialogKey,
137
137
  selectCurrentDialogKey,
@@ -179,7 +179,7 @@ import {
179
179
  } from "./chunk-FDTR4QJ6.js";
180
180
  import {
181
181
  buildDatabaseFileContentUrl
182
- } from "./chunk-WADCY6G6.js";
182
+ } from "./chunk-ASQYTZTR.js";
183
183
  import {
184
184
  DEFAULT_MODEL
185
185
  } from "./chunk-OIVSQH2O.js";
@@ -3945,7 +3945,7 @@ async function deleteDialogsFunc(args, thunkApi) {
3945
3945
  const deletedDialogIds = [];
3946
3946
  const deletedDialogKeys = [];
3947
3947
  const failures = [];
3948
- const { deleteDialog: deleteDialog2 } = await import("./dialogSlice-W5BYELVR.js");
3948
+ const { deleteDialog: deleteDialog2 } = await import("./dialogSlice-EXLC5XTD.js");
3949
3949
  for (const target of targets) {
3950
3950
  try {
3951
3951
  await thunkApi.dispatch(deleteDialog2(target.dbKey)).unwrap();
@@ -14906,7 +14906,7 @@ var executeToolRun = createAsyncThunk(
14906
14906
  if (!executionInput) {
14907
14907
  throw new Error(`ToolRun ${id} has no input to execute with.`);
14908
14908
  }
14909
- const { findToolExecutor: findToolExecutor2 } = await import("./tools-SX6Y4STZ.js");
14909
+ const { findToolExecutor: findToolExecutor2 } = await import("./tools-OXEEBABR.js");
14910
14910
  const { executor } = findToolExecutor2(run.toolName);
14911
14911
  toolRunStarted({
14912
14912
  id: run.id,
@@ -17413,7 +17413,7 @@ async function updateDocFunc(args, thunkApi) {
17413
17413
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
17414
17414
  };
17415
17415
  await dispatch(write({ data: updatedPageData, customKey: id })).unwrap();
17416
- const { getDocState, applyExternalDocUpdate } = await import("./docStore-7LAHBFP2.js");
17416
+ const { getDocState, applyExternalDocUpdate } = await import("./docStore-DZNGJXX7.js");
17417
17417
  if (getDocState().pageKey === id) {
17418
17418
  applyExternalDocUpdate({
17419
17419
  slateData: finalSlateData,
@@ -27,7 +27,7 @@ import {
27
27
  resolveLocalUserId,
28
28
  t,
29
29
  toolLabel
30
- } from "./chunk-YVIV7WT4.js";
30
+ } from "./chunk-SL4QHSPQ.js";
31
31
  import {
32
32
  createRunActivityTracker,
33
33
  popSingleQueueMessage,
@@ -64,7 +64,7 @@ import {
64
64
  } from "./chunk-LTRXGFMS.js";
65
65
  import {
66
66
  formatAgentListCard
67
- } from "./chunk-TZJJ77KQ.js";
67
+ } from "./chunk-GGMVRZRO.js";
68
68
  import {
69
69
  isTransientFetchError
70
70
  } from "./chunk-5UTFL4QJ.js";
@@ -85,11 +85,11 @@ import {
85
85
  chooseMemoryOwners,
86
86
  loadMemoryCandidatesFromDb,
87
87
  resolveAgentMemoryPolicy
88
- } from "./chunk-3WD6RUUJ.js";
88
+ } from "./chunk-IIBAPOTQ.js";
89
89
  import {
90
90
  API_REPORTED_COST_MULTIPLIER,
91
91
  parseUiAskChoiceContent
92
- } from "./chunk-K4YGZD3P.js";
92
+ } from "./chunk-STHU4Y5X.js";
93
93
  import {
94
94
  isOAuthApiKeyRef
95
95
  } from "./chunk-YYLHWIW6.js";
@@ -112,10 +112,10 @@ import {
112
112
  LOCAL_AGENT_CONFIG_MISSING_CODE,
113
113
  LOCAL_TURN_ABORTED_CODE,
114
114
  readActionGate
115
- } from "./chunk-ZWUOR654.js";
115
+ } from "./chunk-SDTTBMBU.js";
116
116
  import {
117
117
  resolveAgentRuntimeConfigFromRecord
118
- } from "./chunk-3IIEFNGY.js";
118
+ } from "./chunk-4EZHSKTB.js";
119
119
  import {
120
120
  createThinkParserState,
121
121
  flushThinkParser,
@@ -138,10 +138,10 @@ import {
138
138
  DEFAULT_CONTEXT_WINDOW,
139
139
  getModelContextWindow,
140
140
  normalizeUsage
141
- } from "./chunk-JAXOVNM4.js";
141
+ } from "./chunk-NEDZDG3M.js";
142
142
  import {
143
143
  clipCompactText
144
- } from "./chunk-WADCY6G6.js";
144
+ } from "./chunk-ASQYTZTR.js";
145
145
  import {
146
146
  findModelConfig
147
147
  } from "./chunk-OIVSQH2O.js";
@@ -9821,6 +9821,14 @@ function formatCompactionSummaryLine(event) {
9821
9821
  return `${STYLE.dim}\u81EA\u52A8\u4E0A\u4E0B\u6587\u538B\u7F29\u5931\u8D25${reason}\uFF0C\u672C\u8F6E\u4EE5\u672A\u538B\u7F29\u4E0A\u4E0B\u6587\u7EE7\u7EED\u3002\u82E5\u53CD\u590D\u51FA\u73B0\u53EF\u624B\u52A8 /compact\u3002${STYLE.reset}
9822
9822
  `;
9823
9823
  }
9824
+ if (event.skipped) {
9825
+ if (event.skipReason === "adapter-missing-summary-methods" || event.skipReason === "load-summary-failed") {
9826
+ return `${STYLE.dim}\u81EA\u52A8\u4E0A\u4E0B\u6587\u538B\u7F29\u4E0D\u53EF\u7528\uFF08${event.skipReason}\uFF09\uFF0C\u672C\u8F6E\u4E0D\u538B\u7F29\u3002${STYLE.reset}
9827
+ `;
9828
+ }
9829
+ return "";
9830
+ }
9831
+ if (!event.summaryGenerated) return "";
9824
9832
  let detail = "\u751F\u6210\u5386\u53F2\u6458\u8981";
9825
9833
  const saved = typeof event.savedTokens === "number" ? event.savedTokens : void 0;
9826
9834
  let line = `\u5DF2\u538B\u7F29\u4E0A\u4E0B\u6587\uFF1A${detail}`;
@@ -9990,9 +9998,15 @@ ${options.agentName}${IDENTITY_LABEL_SEPARATOR}`);
9990
9998
  markThinkingDelta(chunk);
9991
9999
  },
9992
10000
  handleToolEvent,
9993
- /** 记录一条 compaction 观测事件(TUI 在 turn 结束时渲染一行 dim 摘要)。 */
10001
+ /** 记录一条 compaction 观测事件(TUI 在 turn 结束时渲染一行 dim 摘要)。
10002
+ * 一轮内可能来多条(轮开始 + 每个 round),按显著性保留最高者:
10003
+ * 失败 > 新生成摘要 > 投影复用 > 跳过,避免末尾的例行跳过事件
10004
+ * 覆盖掉中途真正发生的压缩。 */
9994
10005
  recordCompaction(event) {
9995
- compactionEvent = event;
10006
+ const significance = (e) => e.failed ? 4 : e.summaryGenerated ? 3 : e.compressed ? 2 : 1;
10007
+ if (!compactionEvent || significance(event) >= significance(compactionEvent)) {
10008
+ compactionEvent = event;
10009
+ }
9996
10010
  },
9997
10011
  showWorking(label) {
9998
10012
  const activeLabel = label ?? workingLabel;
@@ -10419,7 +10433,7 @@ function findCollapsedPasteSpanAt(buffer, pos, opts = {}) {
10419
10433
  // packages/cli/client/agentRun.ts
10420
10434
  import { ulid as ulid2 } from "ulid";
10421
10435
  async function loadRunLocalAgentTurn() {
10422
- const { runLocalAgentTurn } = await import("./agentRuntimeLocal-73CVIWBB.js");
10436
+ const { runLocalAgentTurn } = await import("./agentRuntimeLocal-IW3IM5P6.js");
10423
10437
  return runLocalAgentTurn;
10424
10438
  }
10425
10439
  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();
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  addContentToSpace
3
- } from "./chunk-HWIZU4OL.js";
3
+ } from "./chunk-F5OE5KSJ.js";
4
4
  import {
5
5
  prepareAndPersistMessage,
6
6
  uiAskChoiceFunc,
7
7
  uiAskChoiceFunctionSchema
8
- } from "./chunk-K4YGZD3P.js";
8
+ } from "./chunk-STHU4Y5X.js";
9
9
  import {
10
10
  require_date_fns
11
11
  } from "./chunk-M76ECQRD.js";
@@ -7,7 +7,7 @@ import {
7
7
  } from "./chunk-IIVGDG4I.js";
8
8
  import {
9
9
  getModelContextWindow
10
- } from "./chunk-JAXOVNM4.js";
10
+ } from "./chunk-NEDZDG3M.js";
11
11
  import {
12
12
  estimateTokenCount
13
13
  } from "./chunk-PSCNXBYA.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  normalizeTimingMs
3
- } from "./chunk-WADCY6G6.js";
3
+ } from "./chunk-ASQYTZTR.js";
4
4
  import {
5
5
  MODEL_LOOKUP_MAP
6
6
  } from "./chunk-OIVSQH2O.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  clearCliLocalRuntimePreparedAgentCache
3
- } from "./chunk-YVIV7WT4.js";
3
+ } from "./chunk-SL4QHSPQ.js";
4
4
  import {
5
5
  getReadableCliDb
6
6
  } from "./chunk-LS2ZANRJ.js";
@@ -8,7 +8,7 @@ import {
8
8
  readSseFrames,
9
9
  streamSseDataValues,
10
10
  throwIfChatCompletionStreamFailed
11
- } from "./chunk-OF7AQZUG.js";
11
+ } from "./chunk-2YMRWISD.js";
12
12
  import {
13
13
  DEVIN_CONNECT_URL
14
14
  } from "./chunk-Q5FJJ6XI.js";
@@ -20,7 +20,7 @@ import {
20
20
  resolveHistoricalToolContentCap,
21
21
  resolveToolOutputProfile,
22
22
  stripImagePartsFromMessages
23
- } from "./chunk-3IIEFNGY.js";
23
+ } from "./chunk-4EZHSKTB.js";
24
24
  import {
25
25
  downgradeUnparsableToolCalls,
26
26
  hasParsableObjectArguments,
@@ -46,7 +46,7 @@ import {
46
46
  requiresBareImageUrl,
47
47
  resolveToolGuidedSections,
48
48
  toBareImageUrlMessages
49
- } from "./chunk-LZIWMYX4.js";
49
+ } from "./chunk-L7I247DF.js";
50
50
  import {
51
51
  convertMessagesToResponsesInput,
52
52
  extractReasoningFromResponseOutput,
@@ -93,7 +93,7 @@ import {
93
93
  resolveEmptyAssistantFallbackMessage,
94
94
  resolveEmptyAssistantOutcome,
95
95
  resolveTruncatedReasoningTailLog
96
- } from "./chunk-JAXOVNM4.js";
96
+ } from "./chunk-NEDZDG3M.js";
97
97
  import {
98
98
  COMPACTION_SUMMARY_SCHEMA_VERSION,
99
99
  COMPACTION_SUMMARY_SYSTEM_PROMPT,
@@ -112,7 +112,7 @@ import {
112
112
  resolveCompressionTriggerRatio,
113
113
  truncateToolOutputForContext,
114
114
  withProviderCallTimingFields
115
- } from "./chunk-WADCY6G6.js";
115
+ } from "./chunk-ASQYTZTR.js";
116
116
  import {
117
117
  estimateTokenCount
118
118
  } from "./chunk-PSCNXBYA.js";
@@ -12627,20 +12627,33 @@ function isColdResume(history, nowMs) {
12627
12627
  }
12628
12628
  async function maybeAutoCompactLocalHistory(args2) {
12629
12629
  const { adapter, dialogId, history } = args2;
12630
- const unchanged = () => ({
12630
+ const unchanged = (decision) => ({
12631
12631
  history,
12632
12632
  compressed: false,
12633
- summaryGenerated: false
12633
+ summaryGenerated: false,
12634
+ decision
12634
12635
  });
12635
- if (!dialogId || history.length === 0 || typeof adapter.loadDialogSummary !== "function" || typeof adapter.saveDialogSummary !== "function") {
12636
- return unchanged();
12636
+ if (!dialogId) {
12637
+ return unchanged({ outcome: "skipped", skipReason: "no-dialog-id" });
12638
+ }
12639
+ if (history.length === 0) {
12640
+ return unchanged({ outcome: "skipped", skipReason: "empty-history" });
12641
+ }
12642
+ if (typeof adapter.loadDialogSummary !== "function" || typeof adapter.saveDialogSummary !== "function") {
12643
+ return unchanged({
12644
+ outcome: "skipped",
12645
+ skipReason: "adapter-missing-summary-methods"
12646
+ });
12637
12647
  }
12638
12648
  let stored = null;
12639
12649
  try {
12640
12650
  stored = await adapter.loadDialogSummary(dialogId);
12641
12651
  } catch (error) {
12642
12652
  console.warn("[localLoop] loadDialogSummary failed:", error);
12643
- return unchanged();
12653
+ return unchanged({
12654
+ outcome: "skipped",
12655
+ skipReason: "load-summary-failed"
12656
+ });
12644
12657
  }
12645
12658
  const bridged = toPlanCompressionMessages(history);
12646
12659
  const validation = validateStoredSummary({ history, stored: stored ?? {} });
@@ -12676,7 +12689,21 @@ async function maybeAutoCompactLocalHistory(args2) {
12676
12689
  ...args2.realContextUsagePercent !== void 0 ? { realContextUsagePercent: args2.realContextUsagePercent } : {}
12677
12690
  });
12678
12691
  const projectExisting = () => {
12679
- if (!existingSummary.trim()) return unchanged();
12692
+ const diag = plan.diagnostics;
12693
+ const diagSnapshot = diag ? {
12694
+ estimatedTokens: diag.totalUsed,
12695
+ historyBudget: diag.historyBudget,
12696
+ triggerRatio: diag.triggerRatio,
12697
+ ...diag.realUsageRatio !== void 0 ? { realUsageRatio: diag.realUsageRatio } : {}
12698
+ } : {};
12699
+ const skippedDecision = {
12700
+ outcome: "skipped",
12701
+ skipReason: diag?.emptyReason === "no-pending" ? "no-pending" : diag?.emptyReason === "below-min-compress-count" ? "below-min-compress-count" : "below-trigger",
12702
+ ...diagSnapshot,
12703
+ ...diag ? { pendingMsgCount: diag.pendingMsgCount } : {},
12704
+ ...diag?.compressCount !== void 0 ? { compressCount: diag.compressCount } : {}
12705
+ };
12706
+ if (!existingSummary.trim()) return unchanged(skippedDecision);
12680
12707
  return {
12681
12708
  history: projectHistoryWithSummary({
12682
12709
  history,
@@ -12684,7 +12711,12 @@ async function maybeAutoCompactLocalHistory(args2) {
12684
12711
  summarizedBeforeId
12685
12712
  }),
12686
12713
  compressed: true,
12687
- summaryGenerated: false
12714
+ summaryGenerated: false,
12715
+ decision: {
12716
+ outcome: "compressed",
12717
+ trigger: "existing-summary",
12718
+ ...diagSnapshot
12719
+ }
12688
12720
  };
12689
12721
  };
12690
12722
  if (!plan.shouldCompress) {
@@ -12714,7 +12746,11 @@ async function maybeAutoCompactLocalHistory(args2) {
12714
12746
  );
12715
12747
  return {
12716
12748
  ...projectExisting(),
12717
- failureMessage: "summary model returned empty content"
12749
+ failureMessage: "summary model returned empty content",
12750
+ decision: {
12751
+ outcome: "failed",
12752
+ detail: "summary model returned empty content"
12753
+ }
12718
12754
  };
12719
12755
  }
12720
12756
  await adapter.saveDialogSummary({
@@ -12751,12 +12787,26 @@ async function maybeAutoCompactLocalHistory(args2) {
12751
12787
  beforeTokens: metrics.previousSummaryTokens + metrics.compressedTokens,
12752
12788
  afterTokens: metrics.newSummaryTokens + metrics.retainedTokens,
12753
12789
  ...result4.usage ? { usage: result4.usage } : {},
12754
- metrics
12790
+ metrics,
12791
+ decision: {
12792
+ outcome: "compressed",
12793
+ trigger: invalidSummary ? "invalid-summary" : coldResume ? "cold-resume" : plan.diagnostics?.triggeredByRealUsage ? "real-usage" : "estimate",
12794
+ ...plan.diagnostics ? {
12795
+ estimatedTokens: plan.diagnostics.totalUsed,
12796
+ historyBudget: plan.diagnostics.historyBudget,
12797
+ triggerRatio: plan.diagnostics.triggerRatio,
12798
+ ...plan.diagnostics.realUsageRatio !== void 0 ? { realUsageRatio: plan.diagnostics.realUsageRatio } : {}
12799
+ } : {}
12800
+ }
12755
12801
  };
12756
12802
  } catch (error) {
12757
12803
  console.warn("[localLoop] auto-compaction failed:", error);
12758
12804
  const failureMessage = error instanceof Error && error.message ? error.message.slice(0, 200) : String(error).slice(0, 200);
12759
- return { ...projectExisting(), failureMessage };
12805
+ return {
12806
+ ...projectExisting(),
12807
+ failureMessage,
12808
+ decision: { outcome: "failed", detail: failureMessage }
12809
+ };
12760
12810
  }
12761
12811
  }
12762
12812
 
@@ -13587,19 +13637,29 @@ async function runLocalAgentTurn(input) {
13587
13637
  }
13588
13638
  let compactionUsage;
13589
13639
  const emitCompactionObservation = (compacted) => {
13590
- if (compacted.compressed || compacted.summaryGenerated || compacted.failureMessage) {
13591
- emitLoopEvent(observationBoundary, {
13592
- kind: "compaction",
13593
- atMs: Date.now(),
13594
- reason: compacted.reason ?? "context_budget",
13595
- summaryGenerated: compacted.summaryGenerated,
13596
- compressed: compacted.compressed,
13597
- ...compacted.failureMessage ? { failed: true, detail: compacted.failureMessage } : {},
13598
- ...compacted.beforeTokens !== void 0 ? { beforeTokens: compacted.beforeTokens } : {},
13599
- ...compacted.afterTokens !== void 0 ? { afterTokens: compacted.afterTokens } : {},
13600
- ...compacted.savedTokens !== void 0 ? { savedTokens: compacted.savedTokens } : {}
13601
- });
13640
+ const decision = compacted.decision;
13641
+ if (decision?.outcome === "skipped") {
13642
+ const isProtectionGap = decision.skipReason === "adapter-missing-summary-methods" || decision.skipReason === "load-summary-failed";
13643
+ const approachingBudget = decision.skipReason === "below-trigger" && typeof decision.estimatedTokens === "number" && typeof decision.historyBudget === "number" && decision.historyBudget > 0 && decision.estimatedTokens >= decision.historyBudget * 0.5;
13644
+ if (!isProtectionGap && !approachingBudget) return;
13602
13645
  }
13646
+ emitLoopEvent(observationBoundary, {
13647
+ kind: "compaction",
13648
+ atMs: Date.now(),
13649
+ ...compacted.reason ? { reason: compacted.reason } : {},
13650
+ summaryGenerated: compacted.summaryGenerated,
13651
+ compressed: compacted.compressed,
13652
+ ...compacted.failureMessage ? { failed: true, detail: compacted.failureMessage } : {},
13653
+ ...decision?.outcome === "skipped" ? { skipped: true, skipReason: decision.skipReason } : {},
13654
+ ...decision && "trigger" in decision && decision.trigger ? { trigger: decision.trigger } : {},
13655
+ ...decision && "estimatedTokens" in decision && decision.estimatedTokens !== void 0 ? { estimatedTokens: decision.estimatedTokens } : {},
13656
+ ...decision && "historyBudget" in decision && decision.historyBudget !== void 0 ? { historyBudget: decision.historyBudget } : {},
13657
+ ...decision && "realUsageRatio" in decision && decision.realUsageRatio !== void 0 ? { realUsageRatio: decision.realUsageRatio } : {},
13658
+ ...decision && "triggerRatio" in decision && decision.triggerRatio !== void 0 ? { triggerRatio: decision.triggerRatio } : {},
13659
+ ...compacted.beforeTokens !== void 0 ? { beforeTokens: compacted.beforeTokens } : {},
13660
+ ...compacted.afterTokens !== void 0 ? { afterTokens: compacted.afterTokens } : {},
13661
+ ...compacted.savedTokens !== void 0 ? { savedTokens: compacted.savedTokens } : {}
13662
+ });
13603
13663
  };
13604
13664
  try {
13605
13665
  const compacted = await maybeAutoCompactLocalHistory({
@@ -13680,17 +13740,26 @@ async function runLocalAgentTurn(input) {
13680
13740
  let skipFinalAppend = false;
13681
13741
  let partialContent = "";
13682
13742
  const progressGuard = createLocalLoopProgressGuard(input.progressGuardConfig);
13743
+ let ephemeralSummary = null;
13744
+ const ephemeralDialogId = `ephemeral-${crypto.randomUUID()}`;
13745
+ const compactionAdapter = input.continueDialogId ? input.adapter : {
13746
+ ...input.adapter,
13747
+ loadDialogSummary: async () => ephemeralSummary,
13748
+ saveDialogSummary: async (summaryInput) => {
13749
+ ephemeralSummary = summaryInput;
13750
+ }
13751
+ };
13752
+ const compactionDialogId = input.continueDialogId ?? ephemeralDialogId;
13683
13753
  const maybeCompactInLoop = async () => {
13684
- if (!input.continueDialogId) return;
13685
- if (!contextUsage) return;
13686
- const inputTokens = normalizeUsage(contextUsage).input_tokens;
13687
- if (!inputTokens || inputTokens <= 0) return;
13688
- const ratio = Math.min(1, inputTokens / contextWindow);
13689
- if (ratio < compressionTriggerRatio) return;
13754
+ const inputTokens = contextUsage ? normalizeUsage(contextUsage).input_tokens : 0;
13755
+ const ratio = inputTokens > 0 ? Math.min(1, inputTokens / contextWindow) : void 0;
13756
+ if (ratio !== void 0 && ratio < compressionTriggerRatio * 0.85) {
13757
+ return;
13758
+ }
13690
13759
  try {
13691
13760
  const compacted = await maybeAutoCompactLocalHistory({
13692
- adapter: input.adapter,
13693
- dialogId: input.continueDialogId,
13761
+ adapter: compactionAdapter,
13762
+ dialogId: compactionDialogId,
13694
13763
  // canonical 坐标:store 全量历史 + 本轮消息的「持久化形态」
13695
13764
  // (applyPersistedTurnInput 会把首条 user 消息换成 paste 展开形态)。
13696
13765
  // 锚点与 sourceHash 都必须按持久化形态计算——否则下轮从 store
@@ -13706,7 +13775,7 @@ async function runLocalAgentTurn(input) {
13706
13775
  model: agentConfig.model,
13707
13776
  resolveProvider: resolveProviderOnce,
13708
13777
  contextWindow,
13709
- realContextUsagePercent: ratio
13778
+ ...ratio !== void 0 ? { realContextUsagePercent: ratio } : {}
13710
13779
  });
13711
13780
  if (compacted.usage) {
13712
13781
  compactionUsage = addOutOfBandUsage(compactionUsage, compacted.usage);