@dexto/core 1.5.3 → 1.5.5

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 (143) hide show
  1. package/dist/agent/DextoAgent.cjs +190 -1
  2. package/dist/agent/DextoAgent.d.ts +71 -0
  3. package/dist/agent/DextoAgent.d.ts.map +1 -1
  4. package/dist/agent/DextoAgent.js +181 -1
  5. package/dist/agent/schemas.d.ts +51 -21
  6. package/dist/agent/schemas.d.ts.map +1 -1
  7. package/dist/context/compaction/overflow.cjs +6 -10
  8. package/dist/context/compaction/overflow.d.ts +14 -11
  9. package/dist/context/compaction/overflow.d.ts.map +1 -1
  10. package/dist/context/compaction/overflow.js +6 -10
  11. package/dist/context/compaction/providers/reactive-overflow-provider.cjs +15 -0
  12. package/dist/context/compaction/providers/reactive-overflow-provider.d.ts +15 -0
  13. package/dist/context/compaction/providers/reactive-overflow-provider.d.ts.map +1 -1
  14. package/dist/context/compaction/providers/reactive-overflow-provider.js +15 -0
  15. package/dist/context/compaction/schemas.cjs +22 -2
  16. package/dist/context/compaction/schemas.d.ts +45 -0
  17. package/dist/context/compaction/schemas.d.ts.map +1 -1
  18. package/dist/context/compaction/schemas.js +22 -2
  19. package/dist/context/compaction/strategies/reactive-overflow.cjs +168 -26
  20. package/dist/context/compaction/strategies/reactive-overflow.d.ts +22 -0
  21. package/dist/context/compaction/strategies/reactive-overflow.d.ts.map +1 -1
  22. package/dist/context/compaction/strategies/reactive-overflow.js +168 -26
  23. package/dist/context/compaction/types.d.ts +13 -1
  24. package/dist/context/compaction/types.d.ts.map +1 -1
  25. package/dist/context/manager.cjs +278 -31
  26. package/dist/context/manager.d.ts +192 -5
  27. package/dist/context/manager.d.ts.map +1 -1
  28. package/dist/context/manager.js +285 -32
  29. package/dist/context/types.d.ts +6 -0
  30. package/dist/context/types.d.ts.map +1 -1
  31. package/dist/context/utils.cjs +77 -11
  32. package/dist/context/utils.d.ts +86 -8
  33. package/dist/context/utils.d.ts.map +1 -1
  34. package/dist/context/utils.js +71 -11
  35. package/dist/errors/types.cjs +0 -2
  36. package/dist/errors/types.d.ts +1 -5
  37. package/dist/errors/types.d.ts.map +1 -1
  38. package/dist/errors/types.js +0 -2
  39. package/dist/events/index.cjs +2 -0
  40. package/dist/events/index.d.ts +21 -6
  41. package/dist/events/index.d.ts.map +1 -1
  42. package/dist/events/index.js +2 -0
  43. package/dist/llm/executor/stream-processor.cjs +104 -28
  44. package/dist/llm/executor/stream-processor.d.ts +7 -0
  45. package/dist/llm/executor/stream-processor.d.ts.map +1 -1
  46. package/dist/llm/executor/stream-processor.js +104 -28
  47. package/dist/llm/executor/turn-executor.cjs +147 -30
  48. package/dist/llm/executor/turn-executor.d.ts +28 -10
  49. package/dist/llm/executor/turn-executor.d.ts.map +1 -1
  50. package/dist/llm/executor/turn-executor.js +147 -30
  51. package/dist/llm/formatters/vercel.cjs +36 -28
  52. package/dist/llm/formatters/vercel.d.ts.map +1 -1
  53. package/dist/llm/formatters/vercel.js +36 -28
  54. package/dist/llm/services/factory.cjs +3 -2
  55. package/dist/llm/services/factory.d.ts +3 -1
  56. package/dist/llm/services/factory.d.ts.map +1 -1
  57. package/dist/llm/services/factory.js +3 -2
  58. package/dist/llm/services/vercel.cjs +31 -6
  59. package/dist/llm/services/vercel.d.ts +18 -3
  60. package/dist/llm/services/vercel.d.ts.map +1 -1
  61. package/dist/llm/services/vercel.js +31 -6
  62. package/dist/session/chat-session.cjs +29 -13
  63. package/dist/session/chat-session.d.ts +6 -4
  64. package/dist/session/chat-session.d.ts.map +1 -1
  65. package/dist/session/chat-session.js +29 -13
  66. package/dist/session/session-manager.cjs +11 -0
  67. package/dist/session/session-manager.d.ts +7 -0
  68. package/dist/session/session-manager.d.ts.map +1 -1
  69. package/dist/session/session-manager.js +11 -0
  70. package/dist/session/title-generator.cjs +2 -2
  71. package/dist/session/title-generator.js +2 -2
  72. package/dist/systemPrompt/in-built-prompts.cjs +36 -0
  73. package/dist/systemPrompt/in-built-prompts.d.ts +18 -1
  74. package/dist/systemPrompt/in-built-prompts.d.ts.map +1 -1
  75. package/dist/systemPrompt/in-built-prompts.js +25 -0
  76. package/dist/systemPrompt/manager.cjs +22 -0
  77. package/dist/systemPrompt/manager.d.ts +10 -0
  78. package/dist/systemPrompt/manager.d.ts.map +1 -1
  79. package/dist/systemPrompt/manager.js +22 -0
  80. package/dist/systemPrompt/registry.cjs +2 -1
  81. package/dist/systemPrompt/registry.d.ts +1 -1
  82. package/dist/systemPrompt/registry.d.ts.map +1 -1
  83. package/dist/systemPrompt/registry.js +2 -1
  84. package/dist/systemPrompt/schemas.cjs +7 -0
  85. package/dist/systemPrompt/schemas.d.ts +13 -13
  86. package/dist/systemPrompt/schemas.d.ts.map +1 -1
  87. package/dist/systemPrompt/schemas.js +7 -0
  88. package/dist/telemetry/telemetry.cjs +12 -5
  89. package/dist/telemetry/telemetry.d.ts.map +1 -1
  90. package/dist/telemetry/telemetry.js +12 -5
  91. package/dist/utils/index.cjs +3 -1
  92. package/dist/utils/index.d.ts +1 -0
  93. package/dist/utils/index.d.ts.map +1 -1
  94. package/dist/utils/index.js +1 -0
  95. package/package.json +15 -5
  96. package/dist/filesystem/error-codes.cjs +0 -53
  97. package/dist/filesystem/error-codes.d.ts +0 -31
  98. package/dist/filesystem/error-codes.d.ts.map +0 -1
  99. package/dist/filesystem/error-codes.js +0 -30
  100. package/dist/filesystem/errors.cjs +0 -303
  101. package/dist/filesystem/errors.d.ts +0 -109
  102. package/dist/filesystem/errors.d.ts.map +0 -1
  103. package/dist/filesystem/errors.js +0 -280
  104. package/dist/filesystem/filesystem-service.cjs +0 -534
  105. package/dist/filesystem/filesystem-service.d.ts +0 -97
  106. package/dist/filesystem/filesystem-service.d.ts.map +0 -1
  107. package/dist/filesystem/filesystem-service.js +0 -501
  108. package/dist/filesystem/index.cjs +0 -37
  109. package/dist/filesystem/index.d.ts +0 -11
  110. package/dist/filesystem/index.d.ts.map +0 -1
  111. package/dist/filesystem/index.js +0 -11
  112. package/dist/filesystem/path-validator.cjs +0 -250
  113. package/dist/filesystem/path-validator.d.ts +0 -103
  114. package/dist/filesystem/path-validator.d.ts.map +0 -1
  115. package/dist/filesystem/path-validator.js +0 -217
  116. package/dist/filesystem/types.cjs +0 -16
  117. package/dist/filesystem/types.d.ts +0 -175
  118. package/dist/filesystem/types.d.ts.map +0 -1
  119. package/dist/filesystem/types.js +0 -0
  120. package/dist/process/command-validator.cjs +0 -554
  121. package/dist/process/command-validator.d.ts +0 -49
  122. package/dist/process/command-validator.d.ts.map +0 -1
  123. package/dist/process/command-validator.js +0 -531
  124. package/dist/process/error-codes.cjs +0 -47
  125. package/dist/process/error-codes.d.ts +0 -25
  126. package/dist/process/error-codes.d.ts.map +0 -1
  127. package/dist/process/error-codes.js +0 -24
  128. package/dist/process/errors.cjs +0 -244
  129. package/dist/process/errors.d.ts +0 -87
  130. package/dist/process/errors.d.ts.map +0 -1
  131. package/dist/process/errors.js +0 -221
  132. package/dist/process/index.cjs +0 -37
  133. package/dist/process/index.d.ts +0 -11
  134. package/dist/process/index.d.ts.map +0 -1
  135. package/dist/process/index.js +0 -11
  136. package/dist/process/process-service.cjs +0 -497
  137. package/dist/process/process-service.d.ts +0 -69
  138. package/dist/process/process-service.d.ts.map +0 -1
  139. package/dist/process/process-service.js +0 -464
  140. package/dist/process/types.cjs +0 -16
  141. package/dist/process/types.d.ts +0 -107
  142. package/dist/process/types.d.ts.map +0 -1
  143. package/dist/process/types.js +0 -0
@@ -54,6 +54,23 @@ class ContextManager {
54
54
  * Maximum number of tokens allowed in the conversation (if specified)
55
55
  */
56
56
  maxInputTokens;
57
+ /**
58
+ * Last known actual input token count from the LLM API response.
59
+ * Updated after each LLM call. Used by /context for accurate reporting.
60
+ */
61
+ lastActualInputTokens = null;
62
+ /**
63
+ * Last known actual output token count from the LLM API response.
64
+ * Updated after each LLM call. Used in the context estimation formula:
65
+ * estimatedNextInput = lastInputTokens + lastOutputTokens + newMessagesEstimate
66
+ */
67
+ lastActualOutputTokens = null;
68
+ /**
69
+ * Message count at the time of the last LLM call.
70
+ * Used to identify which messages are "new" since the last call.
71
+ * Messages after this index are estimated with length/4 heuristic.
72
+ */
73
+ lastCallMessageCount = null;
57
74
  historyProvider;
58
75
  sessionId;
59
76
  /**
@@ -152,6 +169,119 @@ class ContextManager {
152
169
  getMaxInputTokens() {
153
170
  return this.maxInputTokens;
154
171
  }
172
+ /**
173
+ * Returns the last known actual input token count from the LLM API.
174
+ * Returns null if no LLM call has been made yet.
175
+ */
176
+ getLastActualInputTokens() {
177
+ return this.lastActualInputTokens;
178
+ }
179
+ /**
180
+ * Updates the last known actual input token count.
181
+ * Called after each LLM response with the actual usage from the API.
182
+ */
183
+ setLastActualInputTokens(tokens) {
184
+ this.lastActualInputTokens = tokens;
185
+ this.logger.debug(`Updated lastActualInputTokens: ${tokens}`);
186
+ }
187
+ /**
188
+ * Returns the last known actual output token count from the LLM API.
189
+ * Returns null if no LLM call has been made yet.
190
+ */
191
+ getLastActualOutputTokens() {
192
+ return this.lastActualOutputTokens;
193
+ }
194
+ /**
195
+ * Updates the last known actual output token count.
196
+ * Called after each LLM response with the actual usage from the API.
197
+ */
198
+ setLastActualOutputTokens(tokens) {
199
+ this.lastActualOutputTokens = tokens;
200
+ this.logger.debug(`Updated lastActualOutputTokens: ${tokens}`);
201
+ }
202
+ /**
203
+ * Returns the message count at the time of the last LLM call.
204
+ * Returns null if no LLM call has been made yet.
205
+ */
206
+ getLastCallMessageCount() {
207
+ return this.lastCallMessageCount;
208
+ }
209
+ /**
210
+ * Records the current message count after an LLM call completes.
211
+ * This marks the boundary for "new messages" calculation.
212
+ */
213
+ async recordLastCallMessageCount() {
214
+ const history = await this.historyProvider.getHistory();
215
+ this.lastCallMessageCount = history.length;
216
+ this.logger.debug(`Recorded lastCallMessageCount: ${this.lastCallMessageCount}`);
217
+ }
218
+ /**
219
+ * Resets the actual token tracking state.
220
+ * Called after compaction since the context has fundamentally changed.
221
+ */
222
+ resetActualTokenTracking() {
223
+ this.lastActualInputTokens = null;
224
+ this.lastActualOutputTokens = null;
225
+ this.lastCallMessageCount = null;
226
+ this.logger.debug("Reset actual token tracking state (after compaction)");
227
+ }
228
+ // ============= HISTORY PREPARATION =============
229
+ /**
230
+ * Placeholder text used when tool outputs are pruned.
231
+ * Shared constant to ensure consistency between preparation and estimation.
232
+ */
233
+ static PRUNED_TOOL_PLACEHOLDER = "[Old tool result content cleared]";
234
+ /**
235
+ * Prepares conversation history for LLM consumption.
236
+ * This is the single source of truth for history transformation logic.
237
+ *
238
+ * Transformations applied:
239
+ * 1. filterCompacted - Remove pre-summary messages (messages before the most recent summary)
240
+ * 2. Transform pruned tool messages - Replace compactedAt messages with placeholder text
241
+ *
242
+ * Used by both:
243
+ * - getFormattedMessagesForLLM() - For actual LLM calls
244
+ * - getContextTokenEstimate() - For /context command estimation
245
+ *
246
+ * @returns Prepared history and statistics about the transformations
247
+ */
248
+ async prepareHistory() {
249
+ const fullHistory = await this.historyProvider.getHistory();
250
+ const originalCount = fullHistory.length;
251
+ let history = (0, import_utils.filterCompacted)(fullHistory);
252
+ const filteredCount = history.length;
253
+ if (filteredCount < originalCount) {
254
+ this.logger.debug(
255
+ `prepareHistory: filterCompacted reduced from ${originalCount} to ${filteredCount} messages`
256
+ );
257
+ }
258
+ let prunedToolCount = 0;
259
+ history = history.map((msg) => {
260
+ if (msg.role === "tool" && msg.compactedAt) {
261
+ prunedToolCount++;
262
+ return {
263
+ ...msg,
264
+ content: [
265
+ { type: "text", text: ContextManager.PRUNED_TOOL_PLACEHOLDER }
266
+ ]
267
+ };
268
+ }
269
+ return msg;
270
+ });
271
+ if (prunedToolCount > 0) {
272
+ this.logger.debug(
273
+ `prepareHistory: Transformed ${prunedToolCount} pruned tool messages to placeholders`
274
+ );
275
+ }
276
+ return {
277
+ preparedHistory: history,
278
+ stats: {
279
+ originalCount,
280
+ filteredCount,
281
+ prunedToolCount
282
+ }
283
+ };
284
+ }
155
285
  /**
156
286
  * Assembles and returns the current system prompt by invoking the SystemPromptManager.
157
287
  */
@@ -200,6 +330,7 @@ ${prompt}`);
200
330
  }
201
331
  };
202
332
  await this.addMessage(clearMarker);
333
+ this.resetActualTokenTracking();
203
334
  this.logger.debug(`Context cleared for session: ${this.sessionId}`);
204
335
  }
205
336
  /**
@@ -571,51 +702,166 @@ ${prompt}`);
571
702
  /**
572
703
  * Gets the conversation ready for LLM consumption with proper flow:
573
704
  * 1. Get system prompt
574
- * 2. Get history and filter (exclude pre-summary messages)
575
- * 3. Format messages
576
- * This method implements the correct ordering to avoid circular dependencies.
705
+ * 2. Prepare history (filter + transform pruned messages)
706
+ * 3. Format messages for LLM API
577
707
  *
578
708
  * @param contributorContext The DynamicContributorContext for system prompt contributors and formatting
579
709
  * @param llmContext The llmContext for the formatter to decide which messages to include based on the model's capabilities
580
- * @returns Object containing formatted messages and system prompt
710
+ * @returns Object containing formatted messages, system prompt, and prepared history
581
711
  */
582
- async getFormattedMessagesWithCompression(contributorContext, llmContext) {
712
+ async getFormattedMessagesForLLM(contributorContext, llmContext) {
583
713
  const systemPrompt = await this.getSystemPrompt(contributorContext);
584
- const fullHistory = await this.historyProvider.getHistory();
585
- let history = (0, import_utils.filterCompacted)(fullHistory);
586
- if (history.length < fullHistory.length) {
587
- this.logger.debug(
588
- `filterCompacted: Reduced history from ${fullHistory.length} to ${history.length} messages (summary present)`
589
- );
590
- }
591
- const compactedCount = history.filter((m) => m.role === "tool" && m.compactedAt).length;
592
- if (compactedCount > 0) {
593
- history = history.map((msg) => {
594
- if (msg.role === "tool" && msg.compactedAt) {
595
- return {
596
- ...msg,
597
- content: [
598
- { type: "text", text: "[Old tool result content cleared]" }
599
- ]
600
- };
601
- }
602
- return msg;
603
- });
604
- this.logger.debug(
605
- `Transformed ${compactedCount} compacted tool messages to placeholders`
606
- );
607
- }
714
+ const { preparedHistory } = await this.prepareHistory();
608
715
  const formattedMessages = await this.getFormattedMessages(
609
716
  contributorContext,
610
717
  llmContext,
611
718
  systemPrompt,
612
- history
719
+ preparedHistory
613
720
  );
614
721
  return {
615
722
  formattedMessages,
616
- systemPrompt
723
+ systemPrompt,
724
+ preparedHistory
725
+ };
726
+ }
727
+ /**
728
+ * Estimates context token usage for the /context command and compaction decisions.
729
+ * Uses the same prepareHistory() logic as getFormattedMessagesForLLM() to ensure consistency.
730
+ *
731
+ * When actuals are available from previous LLM calls:
732
+ * estimatedNextInput = lastInputTokens + lastOutputTokens + newMessagesEstimate
733
+ *
734
+ * This formula is more accurate because:
735
+ * - lastInputTokens: exactly what the API processed (ground truth)
736
+ * - lastOutputTokens: exactly what the LLM returned (ground truth)
737
+ * - newMessagesEstimate: only estimate the delta (tool results, new user messages)
738
+ *
739
+ * When no LLM call has been made yet (or after compaction), falls back to pure estimation.
740
+ *
741
+ * @param contributorContext Context for building the system prompt
742
+ * @param tools Tool definitions to include in the estimate
743
+ * @returns Token estimates with breakdown and comparison to actual (if available)
744
+ */
745
+ async getContextTokenEstimate(contributorContext, tools) {
746
+ const systemPrompt = await this.getSystemPrompt(contributorContext);
747
+ const { preparedHistory, stats } = await this.prepareHistory();
748
+ const lastInput = this.lastActualInputTokens;
749
+ const lastOutput = this.lastActualOutputTokens;
750
+ const lastMsgCount = this.lastCallMessageCount;
751
+ const currentHistory = await this.historyProvider.getHistory();
752
+ const pureEstimate = (0, import_utils.estimateContextTokens)(systemPrompt, preparedHistory, tools);
753
+ let total;
754
+ let calculationBasis;
755
+ if (lastInput !== null && lastOutput !== null && lastMsgCount !== null) {
756
+ const newMessages = currentHistory.slice(lastMsgCount);
757
+ const newMessagesEstimate = (0, import_utils.estimateMessagesTokens)(newMessages);
758
+ total = lastInput + lastOutput + newMessagesEstimate;
759
+ calculationBasis = {
760
+ method: "actuals",
761
+ lastInputTokens: lastInput,
762
+ lastOutputTokens: lastOutput,
763
+ newMessagesEstimate
764
+ };
765
+ this.logger.info(
766
+ `Context estimate (actuals-based): lastInput=${lastInput}, lastOutput=${lastOutput}, newMsgs=${newMessagesEstimate} (${newMessages.length} messages), total=${total}`
767
+ );
768
+ } else {
769
+ total = pureEstimate.total;
770
+ calculationBasis = {
771
+ method: "estimate"
772
+ };
773
+ this.logger.debug(
774
+ `Context estimate (pure estimate): total=${total} (no actuals available yet)`
775
+ );
776
+ }
777
+ const systemPromptTokens = pureEstimate.breakdown.systemPrompt;
778
+ const toolsTokens = pureEstimate.breakdown.tools;
779
+ const messagesDisplay = Math.max(0, total - systemPromptTokens - toolsTokens.total);
780
+ if (lastInput !== null) {
781
+ const pureTotal = pureEstimate.total;
782
+ const diff = pureTotal - lastInput;
783
+ const diffPercent = lastInput > 0 ? (diff / lastInput * 100).toFixed(1) : "0.0";
784
+ this.logger.info(
785
+ `Context token calibration: pureEstimate=${pureTotal}, lastActual=${lastInput}, diff=${diff} (${diffPercent}%)`
786
+ );
787
+ }
788
+ return {
789
+ estimated: total,
790
+ actual: lastInput,
791
+ breakdown: {
792
+ systemPrompt: systemPromptTokens,
793
+ tools: toolsTokens,
794
+ messages: messagesDisplay
795
+ },
796
+ stats: {
797
+ originalMessageCount: stats.originalCount,
798
+ filteredMessageCount: stats.filteredCount,
799
+ prunedToolCount: stats.prunedToolCount
800
+ },
801
+ calculationBasis
617
802
  };
618
803
  }
804
+ /**
805
+ * Estimates the next input token count using actual token data from the previous LLM call.
806
+ * This is a lightweight version for compaction pre-checks that only returns the total.
807
+ *
808
+ * ## Formula (when actuals are available):
809
+ * estimatedNextInput = lastInputTokens + lastOutputTokens + newMessagesEstimate
810
+ *
811
+ * ## Why this formula works:
812
+ *
813
+ * Consider two consecutive LLM calls:
814
+ *
815
+ * ```
816
+ * Call N:
817
+ * Input sent: system + tools + [user1] = lastInput tokens
818
+ * Output received: assistant response = lastOutput tokens
819
+ *
820
+ * Call N+1:
821
+ * Input will be: system + tools + [user1, assistant1, user2, ...]
822
+ * ≈ lastInput + assistant1_as_input + new_messages
823
+ * ≈ lastInput + lastOutput + newMessagesEstimate
824
+ * ```
825
+ *
826
+ * The assistant's response (lastOutput) becomes part of the next input as conversation
827
+ * history. Text tokenizes similarly whether sent as input or received as output.
828
+ *
829
+ * ## No double-counting:
830
+ *
831
+ * The assistant message is added to history DURING streaming (before this method runs),
832
+ * and recordLastCallMessageCount() captures the count INCLUDING that message.
833
+ * Therefore, newMessages = history.slice(lastMsgCount) EXCLUDES the assistant message,
834
+ * so lastOutput and newMessages don't overlap.
835
+ *
836
+ * ## Pruning caveat:
837
+ *
838
+ * If tool output pruning occurs between calls, lastInput may be stale (higher than
839
+ * actual). This causes OVERESTIMATION, which is SAFE - we'd trigger compaction
840
+ * earlier rather than risk context overflow.
841
+ *
842
+ * @param systemPrompt The system prompt string
843
+ * @param preparedHistory Message history AFTER filterCompacted and pruning
844
+ * @param tools Tool definitions
845
+ * @returns Estimated total input tokens for the next LLM call
846
+ */
847
+ async getEstimatedNextInputTokens(systemPrompt, preparedHistory, tools) {
848
+ const lastInput = this.lastActualInputTokens;
849
+ const lastOutput = this.lastActualOutputTokens;
850
+ const lastMsgCount = this.lastCallMessageCount;
851
+ const currentHistory = await this.historyProvider.getHistory();
852
+ if (lastInput !== null && lastOutput !== null && lastMsgCount !== null) {
853
+ const newMessages = currentHistory.slice(lastMsgCount);
854
+ const newMessagesEstimate = (0, import_utils.estimateMessagesTokens)(newMessages);
855
+ const total = lastInput + lastOutput + newMessagesEstimate;
856
+ this.logger.debug(
857
+ `Estimated next input (actuals-based): ${lastInput} + ${lastOutput} + ${newMessagesEstimate} = ${total}`
858
+ );
859
+ return total;
860
+ }
861
+ const pureEstimate = (0, import_utils.estimateContextTokens)(systemPrompt, preparedHistory, tools);
862
+ this.logger.debug(`Estimated next input (pure estimate): ${pureEstimate.total}`);
863
+ return pureEstimate.total;
864
+ }
619
865
  /**
620
866
  * Gets the system prompt formatted for the target LLM provider
621
867
  * Some providers handle system prompts differently
@@ -632,6 +878,7 @@ ${prompt}`);
632
878
  */
633
879
  async resetConversation() {
634
880
  await this.historyProvider.clearHistory();
881
+ this.resetActualTokenTracking();
635
882
  this.logger.debug(
636
883
  `ContextManager: Conversation history cleared for session ${this.sessionId}`
637
884
  );
@@ -38,6 +38,23 @@ export declare class ContextManager<TMessage = unknown> {
38
38
  * Maximum number of tokens allowed in the conversation (if specified)
39
39
  */
40
40
  private maxInputTokens;
41
+ /**
42
+ * Last known actual input token count from the LLM API response.
43
+ * Updated after each LLM call. Used by /context for accurate reporting.
44
+ */
45
+ private lastActualInputTokens;
46
+ /**
47
+ * Last known actual output token count from the LLM API response.
48
+ * Updated after each LLM call. Used in the context estimation formula:
49
+ * estimatedNextInput = lastInputTokens + lastOutputTokens + newMessagesEstimate
50
+ */
51
+ private lastActualOutputTokens;
52
+ /**
53
+ * Message count at the time of the last LLM call.
54
+ * Used to identify which messages are "new" since the last call.
55
+ * Messages after this index are estimated with length/4 heuristic.
56
+ */
57
+ private lastCallMessageCount;
41
58
  private historyProvider;
42
59
  private readonly sessionId;
43
60
  /**
@@ -72,6 +89,71 @@ export declare class ContextManager<TMessage = unknown> {
72
89
  * Returns the configured maximum number of input tokens for the conversation.
73
90
  */
74
91
  getMaxInputTokens(): number;
92
+ /**
93
+ * Returns the last known actual input token count from the LLM API.
94
+ * Returns null if no LLM call has been made yet.
95
+ */
96
+ getLastActualInputTokens(): number | null;
97
+ /**
98
+ * Updates the last known actual input token count.
99
+ * Called after each LLM response with the actual usage from the API.
100
+ */
101
+ setLastActualInputTokens(tokens: number): void;
102
+ /**
103
+ * Returns the last known actual output token count from the LLM API.
104
+ * Returns null if no LLM call has been made yet.
105
+ */
106
+ getLastActualOutputTokens(): number | null;
107
+ /**
108
+ * Updates the last known actual output token count.
109
+ * Called after each LLM response with the actual usage from the API.
110
+ */
111
+ setLastActualOutputTokens(tokens: number): void;
112
+ /**
113
+ * Returns the message count at the time of the last LLM call.
114
+ * Returns null if no LLM call has been made yet.
115
+ */
116
+ getLastCallMessageCount(): number | null;
117
+ /**
118
+ * Records the current message count after an LLM call completes.
119
+ * This marks the boundary for "new messages" calculation.
120
+ */
121
+ recordLastCallMessageCount(): Promise<void>;
122
+ /**
123
+ * Resets the actual token tracking state.
124
+ * Called after compaction since the context has fundamentally changed.
125
+ */
126
+ resetActualTokenTracking(): void;
127
+ /**
128
+ * Placeholder text used when tool outputs are pruned.
129
+ * Shared constant to ensure consistency between preparation and estimation.
130
+ */
131
+ private static readonly PRUNED_TOOL_PLACEHOLDER;
132
+ /**
133
+ * Prepares conversation history for LLM consumption.
134
+ * This is the single source of truth for history transformation logic.
135
+ *
136
+ * Transformations applied:
137
+ * 1. filterCompacted - Remove pre-summary messages (messages before the most recent summary)
138
+ * 2. Transform pruned tool messages - Replace compactedAt messages with placeholder text
139
+ *
140
+ * Used by both:
141
+ * - getFormattedMessagesForLLM() - For actual LLM calls
142
+ * - getContextTokenEstimate() - For /context command estimation
143
+ *
144
+ * @returns Prepared history and statistics about the transformations
145
+ */
146
+ prepareHistory(): Promise<{
147
+ preparedHistory: InternalMessage[];
148
+ stats: {
149
+ /** Total messages in raw history */
150
+ originalCount: number;
151
+ /** Messages after filterCompacted (removed pre-summary) */
152
+ filteredCount: number;
153
+ /** Messages with compactedAt that were transformed to placeholders */
154
+ prunedToolCount: number;
155
+ };
156
+ }>;
75
157
  /**
76
158
  * Assembles and returns the current system prompt by invoking the SystemPromptManager.
77
159
  */
@@ -190,18 +272,123 @@ export declare class ContextManager<TMessage = unknown> {
190
272
  /**
191
273
  * Gets the conversation ready for LLM consumption with proper flow:
192
274
  * 1. Get system prompt
193
- * 2. Get history and filter (exclude pre-summary messages)
194
- * 3. Format messages
195
- * This method implements the correct ordering to avoid circular dependencies.
275
+ * 2. Prepare history (filter + transform pruned messages)
276
+ * 3. Format messages for LLM API
196
277
  *
197
278
  * @param contributorContext The DynamicContributorContext for system prompt contributors and formatting
198
279
  * @param llmContext The llmContext for the formatter to decide which messages to include based on the model's capabilities
199
- * @returns Object containing formatted messages and system prompt
280
+ * @returns Object containing formatted messages, system prompt, and prepared history
200
281
  */
201
- getFormattedMessagesWithCompression(contributorContext: DynamicContributorContext, llmContext: LLMContext): Promise<{
282
+ getFormattedMessagesForLLM(contributorContext: DynamicContributorContext, llmContext: LLMContext): Promise<{
202
283
  formattedMessages: TMessage[];
203
284
  systemPrompt: string;
285
+ preparedHistory: InternalMessage[];
286
+ }>;
287
+ /**
288
+ * Estimates context token usage for the /context command and compaction decisions.
289
+ * Uses the same prepareHistory() logic as getFormattedMessagesForLLM() to ensure consistency.
290
+ *
291
+ * When actuals are available from previous LLM calls:
292
+ * estimatedNextInput = lastInputTokens + lastOutputTokens + newMessagesEstimate
293
+ *
294
+ * This formula is more accurate because:
295
+ * - lastInputTokens: exactly what the API processed (ground truth)
296
+ * - lastOutputTokens: exactly what the LLM returned (ground truth)
297
+ * - newMessagesEstimate: only estimate the delta (tool results, new user messages)
298
+ *
299
+ * When no LLM call has been made yet (or after compaction), falls back to pure estimation.
300
+ *
301
+ * @param contributorContext Context for building the system prompt
302
+ * @param tools Tool definitions to include in the estimate
303
+ * @returns Token estimates with breakdown and comparison to actual (if available)
304
+ */
305
+ getContextTokenEstimate(contributorContext: DynamicContributorContext, tools: Record<string, {
306
+ name?: string;
307
+ description?: string;
308
+ parameters?: unknown;
309
+ }>): Promise<{
310
+ /** Total estimated tokens */
311
+ estimated: number;
312
+ /** Last actual token count from LLM API (null if no calls made yet) */
313
+ actual: number | null;
314
+ /** Breakdown by category */
315
+ breakdown: {
316
+ systemPrompt: number;
317
+ tools: {
318
+ total: number;
319
+ perTool: Array<{
320
+ name: string;
321
+ tokens: number;
322
+ }>;
323
+ };
324
+ messages: number;
325
+ };
326
+ /** Preparation stats */
327
+ stats: {
328
+ originalMessageCount: number;
329
+ filteredMessageCount: number;
330
+ prunedToolCount: number;
331
+ };
332
+ /** Calculation basis for debugging/display */
333
+ calculationBasis?: {
334
+ /** Whether we used the actual-based formula or pure estimation */
335
+ method: 'actuals' | 'estimate';
336
+ /** Last actual input tokens from API (if method is 'actuals') */
337
+ lastInputTokens?: number;
338
+ /** Last actual output tokens from API (if method is 'actuals') */
339
+ lastOutputTokens?: number;
340
+ /** Estimated tokens for new messages since last call (if method is 'actuals') */
341
+ newMessagesEstimate?: number;
342
+ };
204
343
  }>;
344
+ /**
345
+ * Estimates the next input token count using actual token data from the previous LLM call.
346
+ * This is a lightweight version for compaction pre-checks that only returns the total.
347
+ *
348
+ * ## Formula (when actuals are available):
349
+ * estimatedNextInput = lastInputTokens + lastOutputTokens + newMessagesEstimate
350
+ *
351
+ * ## Why this formula works:
352
+ *
353
+ * Consider two consecutive LLM calls:
354
+ *
355
+ * ```
356
+ * Call N:
357
+ * Input sent: system + tools + [user1] = lastInput tokens
358
+ * Output received: assistant response = lastOutput tokens
359
+ *
360
+ * Call N+1:
361
+ * Input will be: system + tools + [user1, assistant1, user2, ...]
362
+ * ≈ lastInput + assistant1_as_input + new_messages
363
+ * ≈ lastInput + lastOutput + newMessagesEstimate
364
+ * ```
365
+ *
366
+ * The assistant's response (lastOutput) becomes part of the next input as conversation
367
+ * history. Text tokenizes similarly whether sent as input or received as output.
368
+ *
369
+ * ## No double-counting:
370
+ *
371
+ * The assistant message is added to history DURING streaming (before this method runs),
372
+ * and recordLastCallMessageCount() captures the count INCLUDING that message.
373
+ * Therefore, newMessages = history.slice(lastMsgCount) EXCLUDES the assistant message,
374
+ * so lastOutput and newMessages don't overlap.
375
+ *
376
+ * ## Pruning caveat:
377
+ *
378
+ * If tool output pruning occurs between calls, lastInput may be stale (higher than
379
+ * actual). This causes OVERESTIMATION, which is SAFE - we'd trigger compaction
380
+ * earlier rather than risk context overflow.
381
+ *
382
+ * @param systemPrompt The system prompt string
383
+ * @param preparedHistory Message history AFTER filterCompacted and pruning
384
+ * @param tools Tool definitions
385
+ * @returns Estimated total input tokens for the next LLM call
386
+ */
387
+ getEstimatedNextInputTokens(systemPrompt: string, preparedHistory: readonly InternalMessage[], tools: Record<string, {
388
+ name?: string;
389
+ description?: string;
390
+ parameters?: unknown;
391
+ }>): Promise<number>;
205
392
  /**
206
393
  * Gets the system prompt formatted for the target LLM provider
207
394
  * Some providers handle system prompts differently
@@ -1 +1 @@
1
- {"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../src/context/manager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AACxE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE9E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAI1D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AAE9E,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAEvD;;;;;;;;;;;;;GAaG;AACH,qBAAa,cAAc,CAAC,QAAQ,GAAG,OAAO;IAC1C;;OAEG;IACH,OAAO,CAAC,SAAS,CAAqB;IAEtC;;OAEG;IACH,OAAO,CAAC,mBAAmB,CAAsB;IAEjD;;OAEG;IACH,OAAO,CAAC,SAAS,CAAyB;IAE1C;;OAEG;IACH,OAAO,CAAC,cAAc,CAAS;IAE/B,OAAO,CAAC,eAAe,CAA+B;IACtD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IAEnC;;;;OAIG;IACH,OAAO,CAAC,eAAe,CAAkD;IAEzE,OAAO,CAAC,MAAM,CAAe;IAE7B;;;;;;;;;;OAUG;gBAEC,SAAS,EAAE,kBAAkB,EAC7B,SAAS,EAAE,sBAAsB,EACjC,mBAAmB,EAAE,mBAAmB,EACxC,cAAc,EAAE,MAAM,EACtB,eAAe,EAAE,4BAA4B,EAC7C,SAAS,EAAE,MAA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