@caupulican/pi-adaptative 0.81.7 → 0.81.8

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 (39) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/cli/initial-message.d.ts.map +1 -1
  3. package/dist/cli/initial-message.js +9 -8
  4. package/dist/cli/initial-message.js.map +1 -1
  5. package/dist/core/agent-session.d.ts.map +1 -1
  6. package/dist/core/agent-session.js +12 -14
  7. package/dist/core/agent-session.js.map +1 -1
  8. package/dist/core/delegation/worker-actions.d.ts.map +1 -1
  9. package/dist/core/delegation/worker-actions.js +1 -1
  10. package/dist/core/delegation/worker-actions.js.map +1 -1
  11. package/dist/core/model-resolver.d.ts.map +1 -1
  12. package/dist/core/model-resolver.js +33 -3
  13. package/dist/core/model-resolver.js.map +1 -1
  14. package/dist/core/model-router/tool-escalation.d.ts.map +1 -1
  15. package/dist/core/model-router/tool-escalation.js +2 -2
  16. package/dist/core/model-router/tool-escalation.js.map +1 -1
  17. package/dist/core/tools/edit-diff.d.ts +6 -10
  18. package/dist/core/tools/edit-diff.d.ts.map +1 -1
  19. package/dist/core/tools/edit-diff.js +70 -18
  20. package/dist/core/tools/edit-diff.js.map +1 -1
  21. package/dist/core/tools/git-filter.d.ts.map +1 -1
  22. package/dist/core/tools/git-filter.js +3 -4
  23. package/dist/core/tools/git-filter.js.map +1 -1
  24. package/dist/core/tools/read.d.ts.map +1 -1
  25. package/dist/core/tools/read.js +12 -2
  26. package/dist/core/tools/read.js.map +1 -1
  27. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  28. package/dist/modes/rpc/rpc-mode.js +22 -7
  29. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  30. package/docs/bug-ledger.md +15 -0
  31. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  32. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  33. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  34. package/examples/extensions/sandbox/package-lock.json +2 -2
  35. package/examples/extensions/sandbox/package.json +1 -1
  36. package/examples/extensions/with-deps/package-lock.json +2 -2
  37. package/examples/extensions/with-deps/package.json +1 -1
  38. package/npm-shrinkwrap.json +12 -12
  39. package/package.json +4 -4
@@ -2210,8 +2210,8 @@ export class AgentSession {
2210
2210
  const signal = this._compactionAbortController.signal;
2211
2211
  const outcome = await runCompactionLoop({
2212
2212
  measureLiveTokens: () => Math.max(this._estimateCurrentContextTokens(this.agent.state.messages), 1),
2213
- getTriggerThreshold: () => 0,
2214
- getMargin: () => 0,
2213
+ shouldCompact: () => true,
2214
+ getPostApplyMargin: () => 0,
2215
2215
  getBranch: () => this.sessionManager.getBranch(),
2216
2216
  getBaseKeepRecentTokens: () => settings.keepRecentTokens,
2217
2217
  resolveModelAndAuth: async (modelTier) => {
@@ -2251,10 +2251,10 @@ export class AgentSession {
2251
2251
  appliedResult = result;
2252
2252
  },
2253
2253
  verifyPostApplyEffect: () => false,
2254
- onTransition: ({ cycle, cause }) => {
2254
+ onTransition: ({ cycle, cause, detail }) => {
2255
2255
  this._emit({
2256
2256
  type: "warning",
2257
- message: `manual compaction cycle ${cycle}: ${cause} — retrying from step 0 (${this._describeCompactionSummarizer()})`,
2257
+ message: `manual compaction cycle ${cycle}: ${cause}${detail ? ` (${detail})` : ""} — retrying from step 0 (${this._describeCompactionSummarizer()})`,
2258
2258
  });
2259
2259
  },
2260
2260
  signal,
@@ -2457,17 +2457,14 @@ export class AgentSession {
2457
2457
  return false;
2458
2458
  }
2459
2459
  const contextWindow = model.contextWindow;
2460
- const triggerThreshold = Math.max(0, contextWindow - settings.reserveTokens);
2461
2460
  const margin = Math.max(0, Math.floor(0.01 * contextWindow));
2462
- let measureReads = 0;
2463
2461
  const outcome = await runCompactionLoop({
2464
2462
  getBranch: () => this.sessionManager.getBranch(),
2465
- measureLiveTokens: () => {
2466
- const measured = this._pipeline.estimateCurrentContextTokens(this.agent.state.messages);
2467
- return measureReads++ === 0 ? Math.max(measured, triggerThreshold + 1) : measured;
2468
- },
2469
- getTriggerThreshold: () => triggerThreshold,
2470
- getMargin: () => margin,
2463
+ measureLiveTokens: () => this._pipeline.estimateCurrentContextTokens(this.agent.state.messages),
2464
+ shouldCompact: reason === "overflow"
2465
+ ? () => true
2466
+ : (tokens) => shouldCompact(tokens, contextWindow, settings, model.autoCompactionTriggerTokens),
2467
+ getPostApplyMargin: () => margin,
2471
2468
  getBaseKeepRecentTokens: () => settings.keepRecentTokens,
2472
2469
  resolveModelAndAuth: async (modelTier) => this._resolveCompactionModelAndAuth(modelTier === "session" ? model : this._resolveCompactionModel(model), model),
2473
2470
  summarizeAndVerify: async (params, compactModel, apiKey, headers, branchEntries) => {
@@ -2523,10 +2520,11 @@ export class AgentSession {
2523
2520
  });
2524
2521
  }
2525
2522
  },
2526
- onTransition: ({ cycle, cause }) => {
2523
+ verifyPostApplyEffect: reason === "overflow" ? () => false : undefined,
2524
+ onTransition: ({ cycle, cause, detail }) => {
2527
2525
  this._emit({
2528
2526
  type: "warning",
2529
- message: `auto-compaction cycle ${cycle}: ${cause} — retrying from step 0 (${this._describeCompactionSummarizer()})`,
2527
+ message: `auto-compaction cycle ${cycle}: ${cause}${detail ? ` (${detail})` : ""} — retrying from step 0 (${this._describeCompactionSummarizer()})`,
2530
2528
  });
2531
2529
  },
2532
2530
  signal,