@caupulican/pi-adaptative 0.80.73 → 0.80.75

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 (33) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/dist/core/agent-session.d.ts +10 -0
  3. package/dist/core/agent-session.d.ts.map +1 -1
  4. package/dist/core/agent-session.js +42 -6
  5. package/dist/core/agent-session.js.map +1 -1
  6. package/dist/core/compaction/compaction.d.ts +22 -0
  7. package/dist/core/compaction/compaction.d.ts.map +1 -1
  8. package/dist/core/compaction/compaction.js +31 -3
  9. package/dist/core/compaction/compaction.js.map +1 -1
  10. package/dist/core/memory/providers/file-store.d.ts.map +1 -1
  11. package/dist/core/memory/providers/file-store.js +33 -2
  12. package/dist/core/memory/providers/file-store.js.map +1 -1
  13. package/dist/core/resource-loader.d.ts +19 -1
  14. package/dist/core/resource-loader.d.ts.map +1 -1
  15. package/dist/core/resource-loader.js +69 -5
  16. package/dist/core/resource-loader.js.map +1 -1
  17. package/dist/core/settings-manager.d.ts +6 -0
  18. package/dist/core/settings-manager.d.ts.map +1 -1
  19. package/dist/core/settings-manager.js +8 -0
  20. package/dist/core/settings-manager.js.map +1 -1
  21. package/dist/modes/interactive/interactive-mode.d.ts +5 -0
  22. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  23. package/dist/modes/interactive/interactive-mode.js +41 -12
  24. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  25. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  26. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  27. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  28. package/examples/extensions/sandbox/package-lock.json +2 -2
  29. package/examples/extensions/sandbox/package.json +1 -1
  30. package/examples/extensions/with-deps/package-lock.json +2 -2
  31. package/examples/extensions/with-deps/package.json +1 -1
  32. package/npm-shrinkwrap.json +12 -12
  33. package/package.json +4 -4
@@ -410,11 +410,15 @@ export class InteractiveMode {
410
410
  loadingAnimation = undefined;
411
411
  // Native-reflection debounce: prevents back-to-back/overlapping background reflection passes (cost
412
412
  // guard). `_nativeReflectionInFlight` blocks a second pass while one runs; `_lastNativeReflectionAt`
413
- // enforces a minimum gap between passes. Skipped corrections aren't lost the next eligible pass
414
- // reflects over the accumulated turn text.
413
+ // enforces a minimum gap between passes. A debounce-skipped turn's text is BUFFERED in
414
+ // `_pendingReflectionText` (not dropped) and folded into the next pass, so no corrective feedback is
415
+ // lost — reflection sees only the current turn's messages, so dropping a skipped turn would lose its
416
+ // learning entirely (bug #29).
415
417
  _nativeReflectionInFlight = false;
416
418
  _lastNativeReflectionAt = 0;
419
+ _pendingReflectionText = [];
417
420
  static NATIVE_REFLECTION_MIN_INTERVAL_MS = 45_000;
421
+ static PENDING_REFLECTION_MAX_CHARS = 12_000;
418
422
  workingMessage = undefined;
419
423
  workingVisible = true;
420
424
  workingIndicatorOptions = undefined;
@@ -4838,18 +4842,29 @@ export class InteractiveMode {
4838
4842
  const thinkingLevel = settings.thinkingLevel ?? "low";
4839
4843
  return { model, thinkingLevel };
4840
4844
  }
4845
+ /** Buffer a debounce-skipped turn's text so its learning is folded into the next pass (bug #29). */
4846
+ _bufferPendingReflection(text) {
4847
+ const t = text.trim();
4848
+ if (!t)
4849
+ return;
4850
+ this._pendingReflectionText.push(t);
4851
+ // Bound the buffer so a long skipped streak can't grow unbounded; drop oldest past the budget
4852
+ // (the most recent corrections matter most).
4853
+ let total = this._pendingReflectionText.reduce((n, s) => n + s.length + 1, 0);
4854
+ while (this._pendingReflectionText.length > 1 && total > InteractiveMode.PENDING_REFLECTION_MAX_CHARS) {
4855
+ total -= (this._pendingReflectionText.shift()?.length ?? 0) + 1;
4856
+ }
4857
+ }
4858
+ _drainPendingReflection() {
4859
+ if (this._pendingReflectionText.length === 0)
4860
+ return "";
4861
+ const joined = this._pendingReflectionText.join("\n");
4862
+ this._pendingReflectionText = [];
4863
+ return joined;
4864
+ }
4841
4865
  maybeRunNativeReflection(messages) {
4842
4866
  if (!this.isNativeReflectionEnabled())
4843
4867
  return;
4844
- // Debounce (cost guard): never run two background reflection passes at once, and never start one
4845
- // within the min interval of the last — a multi-turn correction session would otherwise spawn
4846
- // overlapping passes that re-reason the same task. The accumulated turn text is still reflected
4847
- // on the next eligible pass, so no learning is dropped.
4848
- if (this._nativeReflectionInFlight)
4849
- return;
4850
- const now = Date.now();
4851
- if (now - this._lastNativeReflectionAt < InteractiveMode.NATIVE_REFLECTION_MIN_INTERVAL_MS)
4852
- return;
4853
4868
  const settings = this.getEffectiveAutoLearnSettings();
4854
4869
  const toolCallCount = this.countAgentToolCalls(messages);
4855
4870
  const contextPercent = this.session.getContextUsage()?.percent ?? 0;
@@ -4871,6 +4886,20 @@ export class InteractiveMode {
4871
4886
  .map((m) => `${String(m.role ?? "")}: ${this.getAgentMessagePlainText(m)}`.trim())
4872
4887
  .filter(Boolean)
4873
4888
  .join("\n");
4889
+ // Debounce (cost guard): never run two background reflection passes at once, and never start one
4890
+ // within the min interval of the last — a multi-turn correction session would otherwise spawn
4891
+ // overlapping passes that re-reason the same task. A skipped turn is NOT dropped: its text is
4892
+ // buffered and folded into the next pass, so the corrective feedback is still learned (bug #29).
4893
+ const now = Date.now();
4894
+ const debounced = this._nativeReflectionInFlight ||
4895
+ now - this._lastNativeReflectionAt < InteractiveMode.NATIVE_REFLECTION_MIN_INTERVAL_MS;
4896
+ if (debounced) {
4897
+ this._bufferPendingReflection(recentTurnText);
4898
+ return;
4899
+ }
4900
+ // Fold any buffered (previously debounced) turns into this pass so nothing learned is lost.
4901
+ const pending = this._drainPendingReflection();
4902
+ const reflectionText = pending ? `${pending}\n${recentTurnText}` : recentTurnText;
4874
4903
  // Stable per-turn id so a duplicate scheduling/retry can't double-count the reflection cost.
4875
4904
  // Messages carry no `id` on the real path (only timestamps), so derive the key from the last
4876
4905
  // message's timestamp + the turn size — present on every real turn, stable across a retry of the
@@ -4886,7 +4915,7 @@ export class InteractiveMode {
4886
4915
  void this.session
4887
4916
  .runReflectionPass({
4888
4917
  signals: { trigger, toolCallCount, hadCorrection, contextHeadroomPct, usefulLately: 0 },
4889
- recentTurnText,
4918
+ recentTurnText: reflectionText,
4890
4919
  reportId,
4891
4920
  model,
4892
4921
  thinkingLevel,