@earendil-works/pi-coding-agent 0.81.0 → 0.82.0

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 (113) hide show
  1. package/CHANGELOG.md +59 -0
  2. package/README.md +13 -0
  3. package/dist/cli/config-selector.d.ts.map +1 -1
  4. package/dist/cli/config-selector.js +1 -1
  5. package/dist/cli/config-selector.js.map +1 -1
  6. package/dist/cli/startup-ui.d.ts.map +1 -1
  7. package/dist/cli/startup-ui.js +1 -1
  8. package/dist/cli/startup-ui.js.map +1 -1
  9. package/dist/core/agent-session.d.ts +33 -0
  10. package/dist/core/agent-session.d.ts.map +1 -1
  11. package/dist/core/agent-session.js +37 -3
  12. package/dist/core/agent-session.js.map +1 -1
  13. package/dist/core/compaction/branch-summarization.d.ts +5 -0
  14. package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
  15. package/dist/core/compaction/branch-summarization.js +5 -7
  16. package/dist/core/compaction/branch-summarization.js.map +1 -1
  17. package/dist/core/compaction/compaction.d.ts +13 -4
  18. package/dist/core/compaction/compaction.d.ts.map +1 -1
  19. package/dist/core/compaction/compaction.js +29 -17
  20. package/dist/core/compaction/compaction.js.map +1 -1
  21. package/dist/core/extensions/runner.d.ts.map +1 -1
  22. package/dist/core/extensions/runner.js +4 -0
  23. package/dist/core/extensions/runner.js.map +1 -1
  24. package/dist/core/extensions/types.d.ts +5 -1
  25. package/dist/core/extensions/types.d.ts.map +1 -1
  26. package/dist/core/extensions/types.js.map +1 -1
  27. package/dist/core/model-config.d.ts +30 -0
  28. package/dist/core/model-config.d.ts.map +1 -1
  29. package/dist/core/model-config.js +6 -0
  30. package/dist/core/model-config.js.map +1 -1
  31. package/dist/core/model-registry.d.ts.map +1 -1
  32. package/dist/core/model-registry.js +2 -2
  33. package/dist/core/model-registry.js.map +1 -1
  34. package/dist/core/model-resolver.d.ts.map +1 -1
  35. package/dist/core/model-resolver.js +7 -0
  36. package/dist/core/model-resolver.js.map +1 -1
  37. package/dist/core/model-runtime.d.ts +0 -1
  38. package/dist/core/model-runtime.d.ts.map +1 -1
  39. package/dist/core/model-runtime.js +3 -5
  40. package/dist/core/model-runtime.js.map +1 -1
  41. package/dist/core/remote-catalog-provider.d.ts +1 -1
  42. package/dist/core/remote-catalog-provider.d.ts.map +1 -1
  43. package/dist/core/remote-catalog-provider.js +5 -10
  44. package/dist/core/remote-catalog-provider.js.map +1 -1
  45. package/dist/core/sdk.d.ts.map +1 -1
  46. package/dist/core/sdk.js +7 -3
  47. package/dist/core/sdk.js.map +1 -1
  48. package/dist/core/settings-manager.d.ts +1 -1
  49. package/dist/core/settings-manager.d.ts.map +1 -1
  50. package/dist/core/settings-manager.js.map +1 -1
  51. package/dist/core/system-prompt.d.ts.map +1 -1
  52. package/dist/core/system-prompt.js +1 -1
  53. package/dist/core/system-prompt.js.map +1 -1
  54. package/dist/core/tools/bash.d.ts +2 -0
  55. package/dist/core/tools/bash.d.ts.map +1 -1
  56. package/dist/core/tools/bash.js +34 -5
  57. package/dist/core/tools/bash.js.map +1 -1
  58. package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -1
  59. package/dist/core/tools/tool-definition-wrapper.js +3 -1
  60. package/dist/core/tools/tool-definition-wrapper.js.map +1 -1
  61. package/dist/extensions/llama/provider.d.ts.map +1 -1
  62. package/dist/extensions/llama/provider.js +1 -2
  63. package/dist/extensions/llama/provider.js.map +1 -1
  64. package/dist/main.d.ts.map +1 -1
  65. package/dist/main.js +2 -1
  66. package/dist/main.js.map +1 -1
  67. package/dist/modes/interactive/components/extension-editor.d.ts +1 -2
  68. package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -1
  69. package/dist/modes/interactive/components/extension-editor.js +16 -46
  70. package/dist/modes/interactive/components/extension-editor.js.map +1 -1
  71. package/dist/modes/interactive/external-editor.d.ts +12 -0
  72. package/dist/modes/interactive/external-editor.d.ts.map +1 -0
  73. package/dist/modes/interactive/external-editor.js +37 -0
  74. package/dist/modes/interactive/external-editor.js.map +1 -0
  75. package/dist/modes/interactive/interactive-mode.d.ts +2 -1
  76. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  77. package/dist/modes/interactive/interactive-mode.js +58 -46
  78. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  79. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  80. package/dist/modes/rpc/rpc-mode.js +1 -0
  81. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  82. package/dist/utils/clipboard.d.ts.map +1 -1
  83. package/dist/utils/clipboard.js +19 -8
  84. package/dist/utils/clipboard.js.map +1 -1
  85. package/dist/utils/version-check.d.ts.map +1 -1
  86. package/dist/utils/version-check.js +3 -1
  87. package/dist/utils/version-check.js.map +1 -1
  88. package/docs/compaction.md +1 -1
  89. package/docs/custom-provider.md +5 -2
  90. package/docs/environment-variables.md +88 -0
  91. package/docs/extensions.md +11 -3
  92. package/docs/index.md +1 -0
  93. package/docs/json.md +5 -1
  94. package/docs/models.md +6 -2
  95. package/docs/providers.md +8 -1
  96. package/docs/rpc.md +56 -6
  97. package/docs/sdk.md +3 -0
  98. package/docs/settings.md +1 -1
  99. package/docs/usage.md +0 -13
  100. package/examples/extensions/custom-compaction.ts +3 -0
  101. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  102. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  103. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  104. package/examples/extensions/gondolin/package-lock.json +2 -2
  105. package/examples/extensions/gondolin/package.json +1 -1
  106. package/examples/extensions/handoff.ts +9 -1
  107. package/examples/extensions/sandbox/package-lock.json +2 -2
  108. package/examples/extensions/sandbox/package.json +1 -1
  109. package/examples/extensions/summarize.ts +3 -0
  110. package/examples/extensions/with-deps/package-lock.json +2 -2
  111. package/examples/extensions/with-deps/package.json +1 -1
  112. package/npm-shrinkwrap.json +16 -15
  113. package/package.json +5 -4
@@ -1420,7 +1420,7 @@ export class AgentSession {
1420
1420
  }
1421
1421
  else {
1422
1422
  // Generate compaction result
1423
- const result = await compact(preparation, this.model, apiKey, headers, customInstructions, this._compactionAbortController.signal, this.thinkingLevel, this.agent.streamFunction, env);
1423
+ const result = await compact(preparation, this.model, apiKey, headers, customInstructions, this._compactionAbortController.signal, this.thinkingLevel, this.agent.streamFunction, env, this.settingsManager.getRetrySettings(), this._summarizationRetryCallbacks({ source: "compaction", reason: "manual" }));
1424
1424
  summary = result.summary;
1425
1425
  firstKeptEntryId = result.firstKeptEntryId;
1426
1426
  tokensBefore = result.tokensBefore;
@@ -1659,7 +1659,7 @@ export class AgentSession {
1659
1659
  }
1660
1660
  else {
1661
1661
  // Generate compaction result
1662
- const compactResult = await compact(preparation, this.model, apiKey, headers, undefined, this._autoCompactionAbortController.signal, this.thinkingLevel, this.agent.streamFunction, env);
1662
+ const compactResult = await compact(preparation, this.model, apiKey, headers, undefined, this._autoCompactionAbortController.signal, this.thinkingLevel, this.agent.streamFunction, env, this.settingsManager.getRetrySettings(), this._summarizationRetryCallbacks({ source: "compaction", reason }));
1663
1663
  summary = compactResult.summary;
1664
1664
  firstKeptEntryId = compactResult.firstKeptEntryId;
1665
1665
  tokensBefore = compactResult.tokensBefore;
@@ -2088,6 +2088,34 @@ export class AgentSession {
2088
2088
  return false;
2089
2089
  return isRetryableAssistantError(message);
2090
2090
  }
2091
+ /**
2092
+ * Retry policy + callbacks shared by compaction and branch-summary summarization calls.
2093
+ * Uses the same `settings.retry` budget/backoff as agent-turn retries so a single transient
2094
+ * stream drop no longer fails the whole operation. `source` carries the context
2095
+ * the TUI needs to render the retry and recreate the underlying indicator.
2096
+ */
2097
+ _summarizationRetryCallbacks(source) {
2098
+ return {
2099
+ onRetryScheduled: (attempt, maxAttempts, delayMs, errorMessage) => {
2100
+ this._emit({
2101
+ type: "summarization_retry_scheduled",
2102
+ attempt,
2103
+ maxAttempts,
2104
+ delayMs,
2105
+ errorMessage,
2106
+ });
2107
+ },
2108
+ onRetryAttemptStart: () => {
2109
+ this._emit({
2110
+ type: "summarization_retry_attempt_start",
2111
+ ...source,
2112
+ });
2113
+ },
2114
+ onRetryFinished: () => {
2115
+ this._emit({ type: "summarization_retry_finished" });
2116
+ },
2117
+ };
2118
+ }
2091
2119
  /**
2092
2120
  * Prepare a retryable error for continuation with exponential backoff.
2093
2121
  * @returns true if the caller should continue the agent, false otherwise
@@ -2167,6 +2195,7 @@ export class AgentSession {
2167
2195
  * @param command The bash command to execute
2168
2196
  * @param onChunk Optional streaming callback for output
2169
2197
  * @param options.excludeFromContext If true, command output won't be sent to LLM (!! prefix)
2198
+ * @param options.id Optional identifier included in bash execution update events
2170
2199
  * @param options.operations Custom BashOperations for remote execution
2171
2200
  */
2172
2201
  async executeBash(command, onChunk, options) {
@@ -2177,7 +2206,10 @@ export class AgentSession {
2177
2206
  const resolvedCommand = prefix ? `${prefix}\n${command}` : command;
2178
2207
  try {
2179
2208
  const result = await executeBashWithOperations(resolvedCommand, this.sessionManager.getCwd(), options?.operations ?? createLocalBashOperations({ shellPath }), {
2180
- onChunk,
2209
+ onChunk: (delta) => {
2210
+ onChunk?.(delta);
2211
+ this._emit({ type: "bash_execution_update", id: options?.id, delta });
2212
+ },
2181
2213
  signal: this._bashAbortController.signal,
2182
2214
  });
2183
2215
  this.recordBashResult(command, result, options);
@@ -2348,6 +2380,8 @@ export class AgentSession {
2348
2380
  replaceInstructions,
2349
2381
  reserveTokens: branchSummarySettings.reserveTokens,
2350
2382
  streamFn: this.agent.streamFunction,
2383
+ retry: this.settingsManager.getRetrySettings(),
2384
+ callbacks: this._summarizationRetryCallbacks({ source: "branchSummary" }),
2351
2385
  });
2352
2386
  if (result.aborted) {
2353
2387
  return { cancelled: true, aborted: true };