@caupulican/pi-adaptative 0.80.79 → 0.80.81

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 (70) hide show
  1. package/CHANGELOG.md +56 -0
  2. package/dist/core/agent-session.d.ts +15 -14
  3. package/dist/core/agent-session.d.ts.map +1 -1
  4. package/dist/core/agent-session.js +202 -9
  5. package/dist/core/agent-session.js.map +1 -1
  6. package/dist/core/cost/daily-usage.d.ts +23 -0
  7. package/dist/core/cost/daily-usage.d.ts.map +1 -0
  8. package/dist/core/cost/daily-usage.js +135 -0
  9. package/dist/core/cost/daily-usage.js.map +1 -0
  10. package/dist/core/model-router/config-diagnostics.d.ts +4 -0
  11. package/dist/core/model-router/config-diagnostics.d.ts.map +1 -0
  12. package/dist/core/model-router/config-diagnostics.js +26 -0
  13. package/dist/core/model-router/config-diagnostics.js.map +1 -0
  14. package/dist/core/model-router/intent-classifier.d.ts +3 -0
  15. package/dist/core/model-router/intent-classifier.d.ts.map +1 -0
  16. package/dist/core/model-router/intent-classifier.js +12 -0
  17. package/dist/core/model-router/intent-classifier.js.map +1 -0
  18. package/dist/core/model-router/session-buffer.d.ts +21 -0
  19. package/dist/core/model-router/session-buffer.d.ts.map +1 -0
  20. package/dist/core/model-router/session-buffer.js +20 -0
  21. package/dist/core/model-router/session-buffer.js.map +1 -0
  22. package/dist/core/model-router/status.d.ts +17 -0
  23. package/dist/core/model-router/status.d.ts.map +1 -0
  24. package/dist/core/model-router/status.js +66 -0
  25. package/dist/core/model-router/status.js.map +1 -0
  26. package/dist/core/model-router/tool-escalation.d.ts +9 -0
  27. package/dist/core/model-router/tool-escalation.d.ts.map +1 -0
  28. package/dist/core/model-router/tool-escalation.js +97 -0
  29. package/dist/core/model-router/tool-escalation.js.map +1 -0
  30. package/dist/core/resource-loader.d.ts +6 -0
  31. package/dist/core/resource-loader.d.ts.map +1 -1
  32. package/dist/core/resource-loader.js +49 -34
  33. package/dist/core/resource-loader.js.map +1 -1
  34. package/dist/core/resource-profile-equality.d.ts +5 -0
  35. package/dist/core/resource-profile-equality.d.ts.map +1 -0
  36. package/dist/core/resource-profile-equality.js +18 -0
  37. package/dist/core/resource-profile-equality.js.map +1 -0
  38. package/dist/core/settings-manager.d.ts +11 -0
  39. package/dist/core/settings-manager.d.ts.map +1 -1
  40. package/dist/core/settings-manager.js +7 -0
  41. package/dist/core/settings-manager.js.map +1 -1
  42. package/dist/core/slash-commands.d.ts.map +1 -1
  43. package/dist/core/slash-commands.js +2 -0
  44. package/dist/core/slash-commands.js.map +1 -1
  45. package/dist/main.d.ts.map +1 -1
  46. package/dist/main.js +5 -0
  47. package/dist/main.js.map +1 -1
  48. package/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
  49. package/dist/modes/interactive/components/config-selector.js +3 -3
  50. package/dist/modes/interactive/components/config-selector.js.map +1 -1
  51. package/dist/modes/interactive/components/footer.d.ts.map +1 -1
  52. package/dist/modes/interactive/components/footer.js +6 -1
  53. package/dist/modes/interactive/components/footer.js.map +1 -1
  54. package/dist/modes/interactive/components/settings-selector.d.ts +2 -1
  55. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  56. package/dist/modes/interactive/components/settings-selector.js +15 -0
  57. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  58. package/dist/modes/interactive/interactive-mode.d.ts +2 -0
  59. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  60. package/dist/modes/interactive/interactive-mode.js +84 -15
  61. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  62. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  63. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  64. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  65. package/examples/extensions/sandbox/package-lock.json +2 -2
  66. package/examples/extensions/sandbox/package.json +1 -1
  67. package/examples/extensions/with-deps/package-lock.json +2 -2
  68. package/examples/extensions/with-deps/package.json +1 -1
  69. package/npm-shrinkwrap.json +12 -12
  70. package/package.json +4 -4
@@ -22,6 +22,7 @@ import { cliProviderAliases, defaultModelPerProvider, findExactModelReferenceMat
22
22
  import { DefaultPackageManager } from "../../core/package-manager.js";
23
23
  import { BUILT_IN_PROVIDER_DISPLAY_NAMES } from "../../core/provider-display-names.js";
24
24
  import { getPendingReloadBlockers } from "../../core/reload-blockers.js";
25
+ import { resourceProfileSettingsChangedKinds } from "../../core/resource-profile-equality.js";
25
26
  import { formatMissingSessionCwdPrompt, MissingSessionCwdError } from "../../core/session-cwd.js";
26
27
  import { isAutoLearnSessionId, SessionManager } from "../../core/session-manager.js";
27
28
  import { validateSkillName } from "../../core/skills.js";
@@ -2415,6 +2416,11 @@ export class InteractiveMode {
2415
2416
  text = text.trim();
2416
2417
  if (!text)
2417
2418
  return;
2419
+ if (text === "/quit" || text === "/exit") {
2420
+ this.editor.setText("");
2421
+ await this.shutdown();
2422
+ return;
2423
+ }
2418
2424
  // A ">>" prefix queues the message as a follow-up (delivered after the
2419
2425
  // current work finishes, starting the next round) instead of steering.
2420
2426
  // This is the chord-free alternative to app.message.followUp, which many
@@ -2509,6 +2515,11 @@ export class InteractiveMode {
2509
2515
  this.editor.setText("");
2510
2516
  return;
2511
2517
  }
2518
+ if (text === "/usage" || text === "/cost") {
2519
+ this.handleUsageCommand();
2520
+ this.editor.setText("");
2521
+ return;
2522
+ }
2512
2523
  if (text === "/changelog") {
2513
2524
  this.handleChangelogCommand();
2514
2525
  this.editor.setText("");
@@ -2609,11 +2620,6 @@ export class InteractiveMode {
2609
2620
  this.editor.setText("");
2610
2621
  return;
2611
2622
  }
2612
- if (text === "/quit") {
2613
- this.editor.setText("");
2614
- await this.shutdown();
2615
- return;
2616
- }
2617
2623
  // Handle bash command (! for normal, !! for excluded from context)
2618
2624
  if (text.startsWith("!")) {
2619
2625
  const isExcluded = text.startsWith("!!");
@@ -4253,6 +4259,9 @@ export class InteractiveMode {
4253
4259
  thinkingLevel: settings.thinkingLevel ?? preset.thinkingLevel,
4254
4260
  };
4255
4261
  }
4262
+ getCurrentAutoLearnSettings() {
4263
+ return this.getEffectiveAutoLearnSettings();
4264
+ }
4256
4265
  getAutoLearnTenantKey() {
4257
4266
  return `${this.sessionManager.getCwd()}::${this.session.sessionId}`;
4258
4267
  }
@@ -5140,6 +5149,7 @@ export class InteractiveMode {
5140
5149
  selfModificationScope: projectSettings.selfModification ? "project" : "global",
5141
5150
  autonomy: this.settingsManager.getAutonomySettings(),
5142
5151
  autonomyScope: projectSettings.autonomy ? "project" : "global",
5152
+ modelRouter: this.settingsManager.getModelRouterSettings(),
5143
5153
  autoLearn: this.settingsManager.getAutoLearnSettings(),
5144
5154
  autoLearnScope: projectSettings.autoLearn ? "project" : "global",
5145
5155
  autoLearnModelOptions: this.getAutoLearnModelOptions(),
@@ -5706,18 +5716,16 @@ export class InteractiveMode {
5706
5716
  }, currentScope);
5707
5717
  this.showStatus(`Saved profile "${profileName}" to ${currentScope}.`);
5708
5718
  if (isActiveProfile) {
5709
- const extensionsChanged = originalResources.extensions !== resources.extensions;
5710
- const otherResourcesChanged = originalResources.tools !== resources.tools ||
5711
- originalResources.skills !== resources.skills ||
5712
- originalResources.agents !== resources.agents ||
5713
- originalResources.prompts !== resources.prompts ||
5714
- originalResources.themes !== resources.themes;
5715
- if (extensionsChanged && !otherResourcesChanged) {
5719
+ const changedKinds = resourceProfileSettingsChangedKinds(originalResources, resources);
5720
+ if (changedKinds.size === 1 && changedKinds.has("extensions")) {
5716
5721
  void this.reconcileExtensionsAndRefreshUI(profileName);
5717
5722
  }
5718
- else {
5723
+ else if (changedKinds.size > 0) {
5719
5724
  void this.refreshAfterProfileMutation(profileName);
5720
5725
  }
5726
+ else {
5727
+ this.ui.requestRender();
5728
+ }
5721
5729
  }
5722
5730
  }
5723
5731
  catch (error) {
@@ -7257,10 +7265,71 @@ export class InteractiveMode {
7257
7265
  info += `${theme.fg("dim", "Cache Write:")} ${stats.tokens.cacheWrite.toLocaleString()}\n`;
7258
7266
  }
7259
7267
  info += `${theme.fg("dim", "Total:")} ${stats.tokens.total.toLocaleString()}\n`;
7260
- if (stats.cost > 0) {
7268
+ const dailyUsage = this.session.getDailyUsageTotals();
7269
+ if (stats.cost > 0 || dailyUsage.totalCost > 0) {
7261
7270
  info += `\n${theme.bold("Cost")}\n`;
7262
- info += `${theme.fg("dim", "Total:")} ${stats.cost.toFixed(4)}`;
7271
+ info += `${theme.fg("dim", "Total:")} $${stats.cost.toFixed(4)}\n`;
7272
+ info += `${this.session.getDailyUsageBreakdown((label) => theme.fg("dim", label))}`;
7263
7273
  }
7274
+ info += `\n\n${theme.bold("Model Router")}\n`;
7275
+ info += this.session.getModelRouterStatus((label) => theme.fg("dim", label));
7276
+ this.chatContainer.addChild(new Spacer(1));
7277
+ this.chatContainer.addChild(new Text(info, 1, 0));
7278
+ this.ui.requestRender();
7279
+ }
7280
+ handleUsageCommand() {
7281
+ const stats = this.session.getSessionStats();
7282
+ const spawned = this.session.getSpawnedUsage();
7283
+ const daily = this.session.getDailyUsageTotals();
7284
+ const context = this.session.getContextUsage();
7285
+ const autoLearn = this.getCurrentAutoLearnSettings();
7286
+ const costGuard = this.session.getLastCostGuardDecision();
7287
+ let info = `${theme.bold("Usage & Optimization")}\n\n`;
7288
+ info += `${theme.bold("Session tokens")}\n`;
7289
+ info += `${theme.fg("dim", "Input:")} ${stats.tokens.input.toLocaleString()}\n`;
7290
+ info += `${theme.fg("dim", "Output:")} ${stats.tokens.output.toLocaleString()}\n`;
7291
+ info += `${theme.fg("dim", "Cache read:")} ${stats.tokens.cacheRead.toLocaleString()}\n`;
7292
+ info += `${theme.fg("dim", "Cache write:")} ${stats.tokens.cacheWrite.toLocaleString()}\n`;
7293
+ info += `${theme.fg("dim", "Total:")} ${stats.tokens.total.toLocaleString()}\n\n`;
7294
+ info += `${theme.bold("Cost")}\n`;
7295
+ info += `${theme.fg("dim", "Session:")} $${stats.cost.toFixed(4)}\n`;
7296
+ info += `${theme.fg("dim", "Spawned/background:")} $${spawned.cost.toFixed(4)} (${spawned.reports} reports)\n`;
7297
+ info += `${theme.fg("dim", "Today:")} $${daily.totalCost.toFixed(4)}\n`;
7298
+ info += `${theme.fg("dim", "Today own:")} $${daily.ownCost.toFixed(4)}\n`;
7299
+ info += `${theme.fg("dim", "Today spawned/background:")} $${daily.spawnedCost.toFixed(4)}\n`;
7300
+ info += `${theme.fg("dim", "Today tokens:")} ${daily.totalTokens.toLocaleString()}\n\n`;
7301
+ info += `${theme.bold("Optimization state")}\n`;
7302
+ const contextPercent = context?.percent;
7303
+ const contextTokens = context?.tokens;
7304
+ if (context &&
7305
+ contextPercent !== undefined &&
7306
+ contextPercent !== null &&
7307
+ contextTokens !== undefined &&
7308
+ contextTokens !== null) {
7309
+ info += `${theme.fg("dim", "Context:")} ${contextPercent.toFixed(1)}% (${contextTokens.toLocaleString()}/${context.contextWindow.toLocaleString()})\n`;
7310
+ }
7311
+ else {
7312
+ info += `${theme.fg("dim", "Context:")} unknown until next provider usage sample\n`;
7313
+ }
7314
+ info += `${theme.fg("dim", "Auto-compaction:")} ${this.session.autoCompactionEnabled ? "enabled" : "disabled"}\n`;
7315
+ if (costGuard) {
7316
+ const status = costGuard.over ? "over" : "ok";
7317
+ info += `${theme.fg("dim", "Cost guard:")} ${status} $${costGuard.estUsd.toFixed(4)}/$${costGuard.thresholdUsd.toFixed(4)} (${costGuard.action})\n`;
7318
+ }
7319
+ else {
7320
+ info += `${theme.fg("dim", "Cost guard:")} disabled\n`;
7321
+ }
7322
+ info += `${theme.fg("dim", "Auto Learn:")} ${autoLearn.enabled ? "enabled" : "disabled"}\n`;
7323
+ info += `${theme.fg("dim", "Scavenger model:")} ${autoLearn.model || "active"}\n`;
7324
+ info += `${theme.fg("dim", "Reflection review:")} ${autoLearn.reflectionReview ? "enabled" : "disabled"} (${autoLearn.reflectionMinToolCalls} tool-call trigger)\n`;
7325
+ info += `${theme.fg("dim", "Auto Learn concurrency:")} ${autoLearn.maxConcurrentLearners} learner(s), ${autoLearn.cooldownMinutes}m cooldown\n\n`;
7326
+ info += `${theme.bold("Model Router")}\n`;
7327
+ info += `${this.session.getModelRouterStatus((label) => theme.fg("dim", label))}\n\n`;
7328
+ info += `${theme.bold("Manual controls")}\n`;
7329
+ info += `${theme.fg("dim", "/compact")}: compact the active context now\n`;
7330
+ info += `${theme.fg("dim", "/settings")}: adjust Auto Learn, cost guard, compaction, and model-router config\n`;
7331
+ info += `${theme.fg("dim", "/auto-learn status|run")}: inspect or launch background learning\n`;
7332
+ info += `${theme.fg("dim", "context_audit")}: ask the agent to inspect provider-visible context contributors\n`;
7264
7333
  this.chatContainer.addChild(new Spacer(1));
7265
7334
  this.chatContainer.addChild(new Text(info, 1, 0));
7266
7335
  this.ui.requestRender();