@caupulican/pi-adaptative 0.81.4 → 0.81.6

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 (57) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/core/agent-session.d.ts +8 -0
  3. package/dist/core/agent-session.d.ts.map +1 -1
  4. package/dist/core/agent-session.js +125 -66
  5. package/dist/core/agent-session.js.map +1 -1
  6. package/dist/core/background-lane-controller.d.ts.map +1 -1
  7. package/dist/core/background-lane-controller.js +3 -0
  8. package/dist/core/background-lane-controller.js.map +1 -1
  9. package/dist/core/billing-failover-controller.d.ts +2 -2
  10. package/dist/core/billing-failover-controller.d.ts.map +1 -1
  11. package/dist/core/billing-failover-controller.js +2 -8
  12. package/dist/core/billing-failover-controller.js.map +1 -1
  13. package/dist/core/compaction-support.d.ts +3 -0
  14. package/dist/core/compaction-support.d.ts.map +1 -1
  15. package/dist/core/compaction-support.js +18 -4
  16. package/dist/core/compaction-support.js.map +1 -1
  17. package/dist/core/context-pipeline.d.ts +1 -0
  18. package/dist/core/context-pipeline.d.ts.map +1 -1
  19. package/dist/core/context-pipeline.js +12 -0
  20. package/dist/core/context-pipeline.js.map +1 -1
  21. package/dist/core/extensions/loader.d.ts.map +1 -1
  22. package/dist/core/extensions/loader.js +33 -9
  23. package/dist/core/extensions/loader.js.map +1 -1
  24. package/dist/core/models/local-registration.d.ts +1 -0
  25. package/dist/core/models/local-registration.d.ts.map +1 -1
  26. package/dist/core/models/local-registration.js +3 -2
  27. package/dist/core/models/local-registration.js.map +1 -1
  28. package/dist/core/research/model-fitness.d.ts +16 -0
  29. package/dist/core/research/model-fitness.d.ts.map +1 -1
  30. package/dist/core/research/model-fitness.js +74 -1
  31. package/dist/core/research/model-fitness.js.map +1 -1
  32. package/dist/core/session-tree-navigator.d.ts.map +1 -1
  33. package/dist/core/session-tree-navigator.js +1 -0
  34. package/dist/core/session-tree-navigator.js.map +1 -1
  35. package/dist/core/trust-manager.d.ts.map +1 -1
  36. package/dist/core/trust-manager.js +6 -3
  37. package/dist/core/trust-manager.js.map +1 -1
  38. package/dist/migrations.d.ts.map +1 -1
  39. package/dist/migrations.js +7 -1
  40. package/dist/migrations.js.map +1 -1
  41. package/dist/modes/interactive/interactive-mode.d.ts +2 -0
  42. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  43. package/dist/modes/interactive/interactive-mode.js +102 -91
  44. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  45. package/dist/modes/interactive/session-flow-commands.d.ts.map +1 -1
  46. package/dist/modes/interactive/session-flow-commands.js +10 -7
  47. package/dist/modes/interactive/session-flow-commands.js.map +1 -1
  48. package/docs/bug-ledger.md +24 -21
  49. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  50. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  51. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  52. package/examples/extensions/sandbox/package-lock.json +2 -2
  53. package/examples/extensions/sandbox/package.json +1 -1
  54. package/examples/extensions/with-deps/package-lock.json +2 -2
  55. package/examples/extensions/with-deps/package.json +1 -1
  56. package/npm-shrinkwrap.json +12 -12
  57. package/package.json +4 -4
@@ -485,9 +485,7 @@ export class InteractiveMode {
485
485
  // Initialize extensions first so resources are shown before messages
486
486
  await this.rebindCurrentSession();
487
487
  // Register extensions-changed listener for live reload UI refresh
488
- this.unsubscribeExtensionsChanged = this.session.onExtensionsChanged(() => {
489
- this.refreshUIAfterExtensionsChanged();
490
- });
488
+ this.subscribeToExtensionsChanged();
491
489
  // Render initial messages AFTER showing loaded resources
492
490
  await this.renderInitialMessages();
493
491
  this.renderProjectTrustWarningIfNeeded();
@@ -954,10 +952,17 @@ export class InteractiveMode {
954
952
  this.applyRuntimeSettings();
955
953
  await this.bindCurrentSessionExtensions();
956
954
  this.subscribeToAgent();
955
+ this.subscribeToExtensionsChanged();
957
956
  await this.updateAvailableProviderCount();
958
957
  this.updateEditorBorderColor();
959
958
  this.updateTerminalTitle();
960
959
  }
960
+ subscribeToExtensionsChanged() {
961
+ this.unsubscribeExtensionsChanged?.();
962
+ this.unsubscribeExtensionsChanged = this.session.onExtensionsChanged(() => {
963
+ this.refreshUIAfterExtensionsChanged();
964
+ });
965
+ }
961
966
  async handleFatalRuntimeError(prefix, error) {
962
967
  const message = error instanceof Error ? error.message : String(error);
963
968
  this.showError(`${prefix}: ${message}`);
@@ -2053,107 +2058,113 @@ export class InteractiveMode {
2053
2058
  * @param options.populateHistory Add user messages to editor history
2054
2059
  */
2055
2060
  renderGeneration = 0;
2061
+ renderQueue;
2056
2062
  async renderSessionContext(sessionContext, options = {}) {
2057
- // Build long history offscreen, then atomically swap it into the visible
2058
- // chat container. This keeps the TUI responsive without flashing blank or
2059
- // partial transcript frames during resume/reload/compaction rebuilds.
2060
- const generation = ++this.renderGeneration;
2061
- let processed = 0;
2062
- let committed = false;
2063
- const visibleChatContainer = this.chatContainer;
2064
- const previousLiveHistoryHiddenNotice = this.liveHistoryHiddenNotice;
2065
- const previousLiveHistoryHiddenComponents = this.liveHistoryHiddenComponents;
2066
- const previousLastStatusSpacer = this.lastStatusSpacer;
2067
- const previousLastStatusText = this.lastStatusText;
2068
- const stagingChatContainer = new Container();
2069
- this.chatContainer = stagingChatContainer;
2070
- this.resetLiveTuiHistoryTrim();
2071
- this.clearRenderedToolPanelState();
2072
- const renderedPendingTools = new Map();
2073
- try {
2074
- if (options.updateFooter) {
2075
- this.footer.invalidate();
2076
- this.updateEditorBorderColor();
2077
- }
2078
- const tuiHistory = this.messagesForTuiHistoryReload(sessionContext.messages);
2079
- if (tuiHistory.omittedMessages > 0) {
2080
- this.appendStatusToChat(`Showing last ~${historyReloadMath.TUI_HISTORY_RELOAD_MAX_LINES} TUI history lines; omitted ${tuiHistory.omittedMessages} older message${tuiHistory.omittedMessages === 1 ? "" : "s"}. Full session remains available to the model.`, { requestRender: false });
2081
- }
2082
- for (const message of tuiHistory.messages) {
2083
- if (processed > 0 && processed % TUI_HISTORY_RELOAD_CHUNK_SIZE === 0) {
2084
- await new Promise((resolve) => setImmediate(resolve));
2085
- if (generation !== this.renderGeneration)
2086
- return;
2063
+ const run = async () => {
2064
+ // Build long history offscreen, then atomically swap it into the visible
2065
+ // chat container. This keeps the TUI responsive without flashing blank or
2066
+ // partial transcript frames during resume/reload/compaction rebuilds.
2067
+ this.renderGeneration = (this.renderGeneration ?? 0) + 1;
2068
+ const generation = this.renderGeneration;
2069
+ let processed = 0;
2070
+ let committed = false;
2071
+ const visibleChatContainer = this.chatContainer;
2072
+ const previousLiveHistoryHiddenNotice = this.liveHistoryHiddenNotice;
2073
+ const previousLiveHistoryHiddenComponents = this.liveHistoryHiddenComponents;
2074
+ const previousLastStatusSpacer = this.lastStatusSpacer;
2075
+ const previousLastStatusText = this.lastStatusText;
2076
+ const stagingChatContainer = new Container();
2077
+ this.chatContainer = stagingChatContainer;
2078
+ this.resetLiveTuiHistoryTrim();
2079
+ this.clearRenderedToolPanelState();
2080
+ const renderedPendingTools = new Map();
2081
+ try {
2082
+ if (options.updateFooter) {
2083
+ this.footer.invalidate();
2084
+ this.updateEditorBorderColor();
2085
+ }
2086
+ const tuiHistory = this.messagesForTuiHistoryReload(sessionContext.messages);
2087
+ if (tuiHistory.omittedMessages > 0) {
2088
+ this.appendStatusToChat(`Showing last ~${historyReloadMath.TUI_HISTORY_RELOAD_MAX_LINES} TUI history lines; omitted ${tuiHistory.omittedMessages} older message${tuiHistory.omittedMessages === 1 ? "" : "s"}. Full session remains available to the model.`, { requestRender: false });
2087
2089
  }
2088
- processed++;
2089
- // Assistant messages need special handling for tool calls
2090
- if (message.role === "assistant") {
2091
- this.addMessageToChat(message);
2092
- // Render tool call components
2093
- for (const content of message.content) {
2094
- if (content.type === "toolCall") {
2095
- const component = this.attachToolExecutionComponent(content.name, content.id, content.arguments);
2096
- if (message.stopReason === "aborted" || message.stopReason === "error") {
2097
- let errorMessage;
2098
- if (message.stopReason === "aborted") {
2099
- const retryAttempt = this.session.retryAttempt;
2100
- errorMessage =
2101
- retryAttempt > 0
2102
- ? `Aborted after ${retryAttempt} retry attempt${retryAttempt > 1 ? "s" : ""}`
2103
- : "Operation aborted";
2090
+ for (const message of tuiHistory.messages) {
2091
+ if (processed > 0 && processed % TUI_HISTORY_RELOAD_CHUNK_SIZE === 0) {
2092
+ await new Promise((resolve) => setImmediate(resolve));
2093
+ if (generation !== this.renderGeneration)
2094
+ return;
2095
+ }
2096
+ processed++;
2097
+ // Assistant messages need special handling for tool calls
2098
+ if (message.role === "assistant") {
2099
+ this.addMessageToChat(message);
2100
+ // Render tool call components
2101
+ for (const content of message.content) {
2102
+ if (content.type === "toolCall") {
2103
+ const component = this.attachToolExecutionComponent(content.name, content.id, content.arguments);
2104
+ if (message.stopReason === "aborted" || message.stopReason === "error") {
2105
+ let errorMessage;
2106
+ if (message.stopReason === "aborted") {
2107
+ const retryAttempt = this.session.retryAttempt;
2108
+ errorMessage =
2109
+ retryAttempt > 0
2110
+ ? `Aborted after ${retryAttempt} retry attempt${retryAttempt > 1 ? "s" : ""}`
2111
+ : "Operation aborted";
2112
+ }
2113
+ else {
2114
+ errorMessage = message.errorMessage || "Error";
2115
+ }
2116
+ component.updateResult({ content: [{ type: "text", text: errorMessage }], isError: true });
2117
+ this.toolPanels.finish(content.id);
2104
2118
  }
2105
2119
  else {
2106
- errorMessage = message.errorMessage || "Error";
2120
+ renderedPendingTools.set(content.id, component);
2107
2121
  }
2108
- component.updateResult({ content: [{ type: "text", text: errorMessage }], isError: true });
2109
- this.toolPanels.finish(content.id);
2110
- }
2111
- else {
2112
- renderedPendingTools.set(content.id, component);
2113
2122
  }
2114
2123
  }
2115
2124
  }
2116
- }
2117
- else if (message.role === "toolResult") {
2118
- // Match tool results to pending tool components
2119
- const component = renderedPendingTools.get(message.toolCallId);
2120
- if (component) {
2121
- component.updateResult(message);
2122
- renderedPendingTools.delete(message.toolCallId);
2123
- this.toolPanels.finish(message.toolCallId);
2125
+ else if (message.role === "toolResult") {
2126
+ // Match tool results to pending tool components
2127
+ const component = renderedPendingTools.get(message.toolCallId);
2128
+ if (component) {
2129
+ component.updateResult(message);
2130
+ renderedPendingTools.delete(message.toolCallId);
2131
+ this.toolPanels.finish(message.toolCallId);
2132
+ }
2124
2133
  }
2134
+ else {
2135
+ // All other messages use standard rendering
2136
+ this.addMessageToChat(message, options);
2137
+ }
2138
+ }
2139
+ if (generation !== this.renderGeneration)
2140
+ return;
2141
+ visibleChatContainer.children = stagingChatContainer.children;
2142
+ committed = true;
2143
+ }
2144
+ finally {
2145
+ const stagedLiveHistoryHiddenNotice = this.liveHistoryHiddenNotice;
2146
+ const stagedLiveHistoryHiddenComponents = this.liveHistoryHiddenComponents;
2147
+ const stagedLastStatusSpacer = this.lastStatusSpacer;
2148
+ const stagedLastStatusText = this.lastStatusText;
2149
+ this.chatContainer = visibleChatContainer;
2150
+ if (committed) {
2151
+ this.liveHistoryHiddenNotice = stagedLiveHistoryHiddenNotice;
2152
+ this.liveHistoryHiddenComponents = stagedLiveHistoryHiddenComponents;
2153
+ this.lastStatusSpacer = stagedLastStatusSpacer;
2154
+ this.lastStatusText = stagedLastStatusText;
2125
2155
  }
2126
2156
  else {
2127
- // All other messages use standard rendering
2128
- this.addMessageToChat(message, options);
2157
+ this.liveHistoryHiddenNotice = previousLiveHistoryHiddenNotice;
2158
+ this.liveHistoryHiddenComponents = previousLiveHistoryHiddenComponents;
2159
+ this.lastStatusSpacer = previousLastStatusSpacer;
2160
+ this.lastStatusText = previousLastStatusText;
2129
2161
  }
2130
2162
  }
2131
- if (generation !== this.renderGeneration)
2132
- return;
2133
- visibleChatContainer.children = stagingChatContainer.children;
2134
- committed = true;
2135
- }
2136
- finally {
2137
- const stagedLiveHistoryHiddenNotice = this.liveHistoryHiddenNotice;
2138
- const stagedLiveHistoryHiddenComponents = this.liveHistoryHiddenComponents;
2139
- const stagedLastStatusSpacer = this.lastStatusSpacer;
2140
- const stagedLastStatusText = this.lastStatusText;
2141
- this.chatContainer = visibleChatContainer;
2142
- if (committed) {
2143
- this.liveHistoryHiddenNotice = stagedLiveHistoryHiddenNotice;
2144
- this.liveHistoryHiddenComponents = stagedLiveHistoryHiddenComponents;
2145
- this.lastStatusSpacer = stagedLastStatusSpacer;
2146
- this.lastStatusText = stagedLastStatusText;
2147
- }
2148
- else {
2149
- this.liveHistoryHiddenNotice = previousLiveHistoryHiddenNotice;
2150
- this.liveHistoryHiddenComponents = previousLiveHistoryHiddenComponents;
2151
- this.lastStatusSpacer = previousLastStatusSpacer;
2152
- this.lastStatusText = previousLastStatusText;
2153
- }
2154
- }
2155
- if (committed)
2156
- this.ui.requestRender();
2163
+ if (committed)
2164
+ this.ui.requestRender();
2165
+ };
2166
+ this.renderQueue = (this.renderQueue ?? Promise.resolve()).then(run, run);
2167
+ return this.renderQueue;
2157
2168
  }
2158
2169
  async renderInitialMessages(options = {}) {
2159
2170
  if (!options.forceHistoryLoad) {