gsd-pi 2.34.0 → 2.35.0-dev.cd3b7ea

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 (418) hide show
  1. package/dist/resources/extensions/gsd/changelog.js +162 -0
  2. package/dist/resources/extensions/gsd/commands-bootstrap.js +1 -0
  3. package/dist/resources/extensions/gsd/commands-prefs-wizard.js +5 -1
  4. package/dist/resources/extensions/gsd/commands.js +8 -1
  5. package/dist/resources/extensions/gsd/docs/preferences-reference.md +10 -0
  6. package/dist/resources/extensions/gsd/doctor-checks.js +113 -5
  7. package/dist/resources/extensions/gsd/doctor-proactive.js +22 -0
  8. package/dist/resources/extensions/gsd/doctor.js +36 -0
  9. package/dist/resources/extensions/gsd/guided-flow.js +4 -2
  10. package/dist/resources/extensions/gsd/preferences-validation.js +38 -0
  11. package/dist/resources/extensions/gsd/preferences.js +2 -0
  12. package/dist/resources/extensions/mcp-client/index.js +2 -1
  13. package/dist/resources/skills/create-gsd-extension/references/events-reference.md +4 -4
  14. package/package.json +1 -1
  15. package/packages/native/dist/native.d.ts +0 -2
  16. package/packages/native/dist/native.js +0 -2
  17. package/packages/native/src/native.ts +0 -3
  18. package/packages/pi-agent-core/dist/agent-loop.d.ts +14 -0
  19. package/packages/pi-agent-core/dist/agent-loop.d.ts.map +1 -1
  20. package/packages/pi-agent-core/dist/agent-loop.js +24 -27
  21. package/packages/pi-agent-core/dist/agent-loop.js.map +1 -1
  22. package/packages/pi-agent-core/dist/agent.d.ts +1 -0
  23. package/packages/pi-agent-core/dist/agent.d.ts.map +1 -1
  24. package/packages/pi-agent-core/dist/agent.js +11 -22
  25. package/packages/pi-agent-core/dist/agent.js.map +1 -1
  26. package/packages/pi-agent-core/dist/proxy.d.ts +1 -25
  27. package/packages/pi-agent-core/dist/proxy.d.ts.map +1 -1
  28. package/packages/pi-agent-core/dist/proxy.js +3 -9
  29. package/packages/pi-agent-core/dist/proxy.js.map +1 -1
  30. package/packages/pi-agent-core/src/agent-loop.ts +30 -27
  31. package/packages/pi-agent-core/src/agent.ts +12 -23
  32. package/packages/pi-agent-core/src/proxy.ts +3 -9
  33. package/packages/pi-ai/dist/api-registry.d.ts +0 -2
  34. package/packages/pi-ai/dist/api-registry.d.ts.map +1 -1
  35. package/packages/pi-ai/dist/api-registry.js +0 -10
  36. package/packages/pi-ai/dist/api-registry.js.map +1 -1
  37. package/packages/pi-ai/dist/providers/anthropic.d.ts +0 -8
  38. package/packages/pi-ai/dist/providers/anthropic.d.ts.map +1 -1
  39. package/packages/pi-ai/dist/providers/anthropic.js +1 -1
  40. package/packages/pi-ai/dist/providers/anthropic.js.map +1 -1
  41. package/packages/pi-ai/dist/providers/azure-openai-responses.d.ts.map +1 -1
  42. package/packages/pi-ai/dist/providers/azure-openai-responses.js +5 -41
  43. package/packages/pi-ai/dist/providers/azure-openai-responses.js.map +1 -1
  44. package/packages/pi-ai/dist/providers/github-copilot-headers.d.ts +0 -1
  45. package/packages/pi-ai/dist/providers/github-copilot-headers.d.ts.map +1 -1
  46. package/packages/pi-ai/dist/providers/github-copilot-headers.js +1 -1
  47. package/packages/pi-ai/dist/providers/github-copilot-headers.js.map +1 -1
  48. package/packages/pi-ai/dist/providers/google-gemini-cli.d.ts +1 -43
  49. package/packages/pi-ai/dist/providers/google-gemini-cli.d.ts.map +1 -1
  50. package/packages/pi-ai/dist/providers/google-gemini-cli.js +2 -2
  51. package/packages/pi-ai/dist/providers/google-gemini-cli.js.map +1 -1
  52. package/packages/pi-ai/dist/providers/google-shared.d.ts +0 -4
  53. package/packages/pi-ai/dist/providers/google-shared.d.ts.map +1 -1
  54. package/packages/pi-ai/dist/providers/google-shared.js +1 -1
  55. package/packages/pi-ai/dist/providers/google-shared.js.map +1 -1
  56. package/packages/pi-ai/dist/providers/openai-completions.d.ts.map +1 -1
  57. package/packages/pi-ai/dist/providers/openai-completions.js +10 -73
  58. package/packages/pi-ai/dist/providers/openai-completions.js.map +1 -1
  59. package/packages/pi-ai/dist/providers/openai-responses.d.ts.map +1 -1
  60. package/packages/pi-ai/dist/providers/openai-responses.js +8 -79
  61. package/packages/pi-ai/dist/providers/openai-responses.js.map +1 -1
  62. package/packages/pi-ai/dist/providers/openai-shared.d.ts +65 -0
  63. package/packages/pi-ai/dist/providers/openai-shared.d.ts.map +1 -0
  64. package/packages/pi-ai/dist/providers/openai-shared.js +146 -0
  65. package/packages/pi-ai/dist/providers/openai-shared.js.map +1 -0
  66. package/packages/pi-ai/dist/providers/register-builtins.d.ts +0 -1
  67. package/packages/pi-ai/dist/providers/register-builtins.d.ts.map +1 -1
  68. package/packages/pi-ai/dist/providers/register-builtins.js +1 -1
  69. package/packages/pi-ai/dist/providers/register-builtins.js.map +1 -1
  70. package/packages/pi-ai/dist/utils/event-stream.d.ts +0 -2
  71. package/packages/pi-ai/dist/utils/event-stream.d.ts.map +1 -1
  72. package/packages/pi-ai/dist/utils/event-stream.js +0 -4
  73. package/packages/pi-ai/dist/utils/event-stream.js.map +1 -1
  74. package/packages/pi-ai/dist/utils/oauth/google-antigravity.d.ts.map +1 -1
  75. package/packages/pi-ai/dist/utils/oauth/google-antigravity.js +7 -135
  76. package/packages/pi-ai/dist/utils/oauth/google-antigravity.js.map +1 -1
  77. package/packages/pi-ai/dist/utils/oauth/google-gemini-cli.d.ts.map +1 -1
  78. package/packages/pi-ai/dist/utils/oauth/google-gemini-cli.js +7 -135
  79. package/packages/pi-ai/dist/utils/oauth/google-gemini-cli.js.map +1 -1
  80. package/packages/pi-ai/dist/utils/oauth/google-oauth-utils.d.ts +46 -0
  81. package/packages/pi-ai/dist/utils/oauth/google-oauth-utils.d.ts.map +1 -0
  82. package/packages/pi-ai/dist/utils/oauth/google-oauth-utils.js +160 -0
  83. package/packages/pi-ai/dist/utils/oauth/google-oauth-utils.js.map +1 -0
  84. package/packages/pi-ai/dist/utils/overflow.d.ts +0 -4
  85. package/packages/pi-ai/dist/utils/overflow.d.ts.map +1 -1
  86. package/packages/pi-ai/dist/utils/overflow.js +0 -6
  87. package/packages/pi-ai/dist/utils/overflow.js.map +1 -1
  88. package/packages/pi-ai/dist/utils/validation.d.ts +0 -8
  89. package/packages/pi-ai/dist/utils/validation.d.ts.map +1 -1
  90. package/packages/pi-ai/dist/utils/validation.js +0 -14
  91. package/packages/pi-ai/dist/utils/validation.js.map +1 -1
  92. package/packages/pi-ai/src/api-registry.ts +0 -12
  93. package/packages/pi-ai/src/providers/anthropic.ts +1 -1
  94. package/packages/pi-ai/src/providers/azure-openai-responses.ts +11 -45
  95. package/packages/pi-ai/src/providers/github-copilot-headers.ts +1 -1
  96. package/packages/pi-ai/src/providers/google-gemini-cli.ts +2 -2
  97. package/packages/pi-ai/src/providers/google-shared.ts +1 -1
  98. package/packages/pi-ai/src/providers/openai-completions.ts +16 -86
  99. package/packages/pi-ai/src/providers/openai-responses.ts +15 -95
  100. package/packages/pi-ai/src/providers/openai-shared.ts +193 -0
  101. package/packages/pi-ai/src/providers/register-builtins.ts +1 -1
  102. package/packages/pi-ai/src/utils/event-stream.ts +0 -5
  103. package/packages/pi-ai/src/utils/oauth/google-antigravity.ts +14 -162
  104. package/packages/pi-ai/src/utils/oauth/google-gemini-cli.ts +13 -161
  105. package/packages/pi-ai/src/utils/oauth/google-oauth-utils.ts +201 -0
  106. package/packages/pi-ai/src/utils/overflow.ts +1 -8
  107. package/packages/pi-ai/src/utils/validation.ts +0 -15
  108. package/packages/pi-coding-agent/dist/config.d.ts +0 -9
  109. package/packages/pi-coding-agent/dist/config.d.ts.map +1 -1
  110. package/packages/pi-coding-agent/dist/config.js +4 -8
  111. package/packages/pi-coding-agent/dist/config.js.map +1 -1
  112. package/packages/pi-coding-agent/dist/core/agent-session.d.ts +16 -63
  113. package/packages/pi-coding-agent/dist/core/agent-session.d.ts.map +1 -1
  114. package/packages/pi-coding-agent/dist/core/agent-session.js +104 -641
  115. package/packages/pi-coding-agent/dist/core/agent-session.js.map +1 -1
  116. package/packages/pi-coding-agent/dist/core/auth-storage.d.ts +0 -1
  117. package/packages/pi-coding-agent/dist/core/auth-storage.d.ts.map +1 -1
  118. package/packages/pi-coding-agent/dist/core/auth-storage.js +4 -35
  119. package/packages/pi-coding-agent/dist/core/auth-storage.js.map +1 -1
  120. package/packages/pi-coding-agent/dist/core/compaction/branch-summarization.d.ts.map +1 -1
  121. package/packages/pi-coding-agent/dist/core/compaction/branch-summarization.js +5 -43
  122. package/packages/pi-coding-agent/dist/core/compaction/branch-summarization.js.map +1 -1
  123. package/packages/pi-coding-agent/dist/core/compaction/compaction.d.ts.map +1 -1
  124. package/packages/pi-coding-agent/dist/core/compaction/compaction.js +11 -69
  125. package/packages/pi-coding-agent/dist/core/compaction/compaction.js.map +1 -1
  126. package/packages/pi-coding-agent/dist/core/compaction/utils.d.ts +40 -0
  127. package/packages/pi-coding-agent/dist/core/compaction/utils.d.ts.map +1 -1
  128. package/packages/pi-coding-agent/dist/core/compaction/utils.js +78 -0
  129. package/packages/pi-coding-agent/dist/core/compaction/utils.js.map +1 -1
  130. package/packages/pi-coding-agent/dist/core/compaction-orchestrator.d.ts +77 -0
  131. package/packages/pi-coding-agent/dist/core/compaction-orchestrator.d.ts.map +1 -0
  132. package/packages/pi-coding-agent/dist/core/compaction-orchestrator.js +331 -0
  133. package/packages/pi-coding-agent/dist/core/compaction-orchestrator.js.map +1 -0
  134. package/packages/pi-coding-agent/dist/core/export-html/ansi-to-html.d.ts +0 -4
  135. package/packages/pi-coding-agent/dist/core/export-html/ansi-to-html.d.ts.map +1 -1
  136. package/packages/pi-coding-agent/dist/core/export-html/ansi-to-html.js +1 -1
  137. package/packages/pi-coding-agent/dist/core/export-html/ansi-to-html.js.map +1 -1
  138. package/packages/pi-coding-agent/dist/core/extensions/index.d.ts +2 -2
  139. package/packages/pi-coding-agent/dist/core/extensions/index.d.ts.map +1 -1
  140. package/packages/pi-coding-agent/dist/core/extensions/index.js +1 -1
  141. package/packages/pi-coding-agent/dist/core/extensions/index.js.map +1 -1
  142. package/packages/pi-coding-agent/dist/core/extensions/runner.d.ts +15 -5
  143. package/packages/pi-coding-agent/dist/core/extensions/runner.d.ts.map +1 -1
  144. package/packages/pi-coding-agent/dist/core/extensions/runner.js +129 -256
  145. package/packages/pi-coding-agent/dist/core/extensions/runner.js.map +1 -1
  146. package/packages/pi-coding-agent/dist/core/extensions/types.d.ts +49 -42
  147. package/packages/pi-coding-agent/dist/core/extensions/types.d.ts.map +1 -1
  148. package/packages/pi-coding-agent/dist/core/extensions/types.js +2 -21
  149. package/packages/pi-coding-agent/dist/core/extensions/types.js.map +1 -1
  150. package/packages/pi-coding-agent/dist/core/keybindings.d.ts +0 -8
  151. package/packages/pi-coding-agent/dist/core/keybindings.d.ts.map +1 -1
  152. package/packages/pi-coding-agent/dist/core/keybindings.js +2 -2
  153. package/packages/pi-coding-agent/dist/core/keybindings.js.map +1 -1
  154. package/packages/pi-coding-agent/dist/core/lock-utils.d.ts +39 -0
  155. package/packages/pi-coding-agent/dist/core/lock-utils.d.ts.map +1 -0
  156. package/packages/pi-coding-agent/dist/core/lock-utils.js +89 -0
  157. package/packages/pi-coding-agent/dist/core/lock-utils.js.map +1 -0
  158. package/packages/pi-coding-agent/dist/core/lsp/client.d.ts +0 -17
  159. package/packages/pi-coding-agent/dist/core/lsp/client.d.ts.map +1 -1
  160. package/packages/pi-coding-agent/dist/core/lsp/client.js +3 -62
  161. package/packages/pi-coding-agent/dist/core/lsp/client.js.map +1 -1
  162. package/packages/pi-coding-agent/dist/core/lsp/config.d.ts +1 -1
  163. package/packages/pi-coding-agent/dist/core/lsp/config.d.ts.map +1 -1
  164. package/packages/pi-coding-agent/dist/core/lsp/config.js +2 -6
  165. package/packages/pi-coding-agent/dist/core/lsp/config.js.map +1 -1
  166. package/packages/pi-coding-agent/dist/core/lsp/edits.d.ts +0 -5
  167. package/packages/pi-coding-agent/dist/core/lsp/edits.d.ts.map +1 -1
  168. package/packages/pi-coding-agent/dist/core/lsp/edits.js +1 -1
  169. package/packages/pi-coding-agent/dist/core/lsp/edits.js.map +1 -1
  170. package/packages/pi-coding-agent/dist/core/lsp/index.d.ts.map +1 -1
  171. package/packages/pi-coding-agent/dist/core/lsp/index.js +52 -107
  172. package/packages/pi-coding-agent/dist/core/lsp/index.js.map +1 -1
  173. package/packages/pi-coding-agent/dist/core/lsp/lspmux.d.ts +0 -1
  174. package/packages/pi-coding-agent/dist/core/lsp/lspmux.d.ts.map +1 -1
  175. package/packages/pi-coding-agent/dist/core/lsp/lspmux.js +3 -22
  176. package/packages/pi-coding-agent/dist/core/lsp/lspmux.js.map +1 -1
  177. package/packages/pi-coding-agent/dist/core/lsp/types.d.ts +0 -1
  178. package/packages/pi-coding-agent/dist/core/lsp/types.d.ts.map +1 -1
  179. package/packages/pi-coding-agent/dist/core/lsp/types.js +0 -28
  180. package/packages/pi-coding-agent/dist/core/lsp/types.js.map +1 -1
  181. package/packages/pi-coding-agent/dist/core/lsp/utils.d.ts +1 -6
  182. package/packages/pi-coding-agent/dist/core/lsp/utils.d.ts.map +1 -1
  183. package/packages/pi-coding-agent/dist/core/lsp/utils.js +1 -28
  184. package/packages/pi-coding-agent/dist/core/lsp/utils.js.map +1 -1
  185. package/packages/pi-coding-agent/dist/core/messages.d.ts +0 -8
  186. package/packages/pi-coding-agent/dist/core/messages.d.ts.map +1 -1
  187. package/packages/pi-coding-agent/dist/core/messages.js +5 -5
  188. package/packages/pi-coding-agent/dist/core/messages.js.map +1 -1
  189. package/packages/pi-coding-agent/dist/core/model-registry.d.ts +0 -3
  190. package/packages/pi-coding-agent/dist/core/model-registry.d.ts.map +1 -1
  191. package/packages/pi-coding-agent/dist/core/model-registry.js +1 -3
  192. package/packages/pi-coding-agent/dist/core/model-registry.js.map +1 -1
  193. package/packages/pi-coding-agent/dist/core/model-resolver.d.ts +1 -26
  194. package/packages/pi-coding-agent/dist/core/model-resolver.d.ts.map +1 -1
  195. package/packages/pi-coding-agent/dist/core/model-resolver.js +3 -59
  196. package/packages/pi-coding-agent/dist/core/model-resolver.js.map +1 -1
  197. package/packages/pi-coding-agent/dist/core/package-manager.d.ts.map +1 -1
  198. package/packages/pi-coding-agent/dist/core/package-manager.js +2 -4
  199. package/packages/pi-coding-agent/dist/core/package-manager.js.map +1 -1
  200. package/packages/pi-coding-agent/dist/core/prompt-templates.d.ts +0 -17
  201. package/packages/pi-coding-agent/dist/core/prompt-templates.d.ts.map +1 -1
  202. package/packages/pi-coding-agent/dist/core/prompt-templates.js +2 -2
  203. package/packages/pi-coding-agent/dist/core/prompt-templates.js.map +1 -1
  204. package/packages/pi-coding-agent/dist/core/resource-loader.d.ts +2 -4
  205. package/packages/pi-coding-agent/dist/core/resource-loader.d.ts.map +1 -1
  206. package/packages/pi-coding-agent/dist/core/resource-loader.js +33 -58
  207. package/packages/pi-coding-agent/dist/core/resource-loader.js.map +1 -1
  208. package/packages/pi-coding-agent/dist/core/retry-handler.d.ts +87 -0
  209. package/packages/pi-coding-agent/dist/core/retry-handler.d.ts.map +1 -0
  210. package/packages/pi-coding-agent/dist/core/retry-handler.js +295 -0
  211. package/packages/pi-coding-agent/dist/core/retry-handler.js.map +1 -0
  212. package/packages/pi-coding-agent/dist/core/session-manager.d.ts +0 -5
  213. package/packages/pi-coding-agent/dist/core/session-manager.d.ts.map +1 -1
  214. package/packages/pi-coding-agent/dist/core/session-manager.js +5 -32
  215. package/packages/pi-coding-agent/dist/core/session-manager.js.map +1 -1
  216. package/packages/pi-coding-agent/dist/core/settings-manager.d.ts +8 -12
  217. package/packages/pi-coding-agent/dist/core/settings-manager.d.ts.map +1 -1
  218. package/packages/pi-coding-agent/dist/core/settings-manager.js +78 -168
  219. package/packages/pi-coding-agent/dist/core/settings-manager.js.map +1 -1
  220. package/packages/pi-coding-agent/dist/core/skills.d.ts.map +1 -1
  221. package/packages/pi-coding-agent/dist/core/skills.js +1 -3
  222. package/packages/pi-coding-agent/dist/core/skills.js.map +1 -1
  223. package/packages/pi-coding-agent/dist/index.d.ts +1 -1
  224. package/packages/pi-coding-agent/dist/index.d.ts.map +1 -1
  225. package/packages/pi-coding-agent/dist/index.js +1 -1
  226. package/packages/pi-coding-agent/dist/index.js.map +1 -1
  227. package/packages/pi-coding-agent/dist/migrations.d.ts +0 -16
  228. package/packages/pi-coding-agent/dist/migrations.d.ts.map +1 -1
  229. package/packages/pi-coding-agent/dist/migrations.js +2 -2
  230. package/packages/pi-coding-agent/dist/migrations.js.map +1 -1
  231. package/packages/pi-coding-agent/dist/modes/interactive/components/session-selector-search.d.ts +0 -2
  232. package/packages/pi-coding-agent/dist/modes/interactive/components/session-selector-search.d.ts.map +1 -1
  233. package/packages/pi-coding-agent/dist/modes/interactive/components/session-selector-search.js +2 -2
  234. package/packages/pi-coding-agent/dist/modes/interactive/components/session-selector-search.js.map +1 -1
  235. package/packages/pi-coding-agent/dist/modes/interactive/components/session-selector.d.ts +1 -1
  236. package/packages/pi-coding-agent/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
  237. package/packages/pi-coding-agent/dist/modes/interactive/components/session-selector.js +9 -26
  238. package/packages/pi-coding-agent/dist/modes/interactive/components/session-selector.js.map +1 -1
  239. package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  240. package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.js +1 -13
  241. package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.js.map +1 -1
  242. package/packages/pi-coding-agent/dist/modes/interactive/components/tree-render-utils.d.ts +44 -0
  243. package/packages/pi-coding-agent/dist/modes/interactive/components/tree-render-utils.d.ts.map +1 -0
  244. package/packages/pi-coding-agent/dist/modes/interactive/components/tree-render-utils.js +61 -0
  245. package/packages/pi-coding-agent/dist/modes/interactive/components/tree-render-utils.js.map +1 -0
  246. package/packages/pi-coding-agent/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
  247. package/packages/pi-coding-agent/dist/modes/interactive/components/tree-selector.js +6 -9
  248. package/packages/pi-coding-agent/dist/modes/interactive/components/tree-selector.js.map +1 -1
  249. package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.d.ts +1 -24
  250. package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  251. package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.js +50 -512
  252. package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.js.map +1 -1
  253. package/packages/pi-coding-agent/dist/modes/interactive/slash-command-handlers.d.ts +71 -0
  254. package/packages/pi-coding-agent/dist/modes/interactive/slash-command-handlers.d.ts.map +1 -0
  255. package/packages/pi-coding-agent/dist/modes/interactive/slash-command-handlers.js +514 -0
  256. package/packages/pi-coding-agent/dist/modes/interactive/slash-command-handlers.js.map +1 -0
  257. package/packages/pi-coding-agent/dist/modes/interactive/theme/theme.d.ts +65 -4
  258. package/packages/pi-coding-agent/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  259. package/packages/pi-coding-agent/dist/modes/interactive/theme/theme.js +6 -23
  260. package/packages/pi-coding-agent/dist/modes/interactive/theme/theme.js.map +1 -1
  261. package/packages/pi-coding-agent/dist/modes/interactive/theme/themes.d.ts +12 -0
  262. package/packages/pi-coding-agent/dist/modes/interactive/theme/themes.d.ts.map +1 -0
  263. package/packages/pi-coding-agent/dist/modes/interactive/theme/themes.js +175 -0
  264. package/packages/pi-coding-agent/dist/modes/interactive/theme/themes.js.map +1 -0
  265. package/packages/pi-coding-agent/dist/modes/interactive/utils/shorten-path.d.ts +6 -0
  266. package/packages/pi-coding-agent/dist/modes/interactive/utils/shorten-path.d.ts.map +1 -0
  267. package/packages/pi-coding-agent/dist/modes/interactive/utils/shorten-path.js +15 -0
  268. package/packages/pi-coding-agent/dist/modes/interactive/utils/shorten-path.js.map +1 -0
  269. package/packages/pi-coding-agent/dist/modes/print-mode.d.ts.map +1 -1
  270. package/packages/pi-coding-agent/dist/modes/print-mode.js +2 -30
  271. package/packages/pi-coding-agent/dist/modes/print-mode.js.map +1 -1
  272. package/packages/pi-coding-agent/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  273. package/packages/pi-coding-agent/dist/modes/rpc/rpc-mode.js +2 -28
  274. package/packages/pi-coding-agent/dist/modes/rpc/rpc-mode.js.map +1 -1
  275. package/packages/pi-coding-agent/dist/modes/shared/command-context-actions.d.ts +19 -0
  276. package/packages/pi-coding-agent/dist/modes/shared/command-context-actions.d.ts.map +1 -0
  277. package/packages/pi-coding-agent/dist/modes/shared/command-context-actions.js +45 -0
  278. package/packages/pi-coding-agent/dist/modes/shared/command-context-actions.js.map +1 -0
  279. package/packages/pi-coding-agent/dist/utils/changelog.d.ts +0 -4
  280. package/packages/pi-coding-agent/dist/utils/changelog.d.ts.map +1 -1
  281. package/packages/pi-coding-agent/dist/utils/changelog.js +1 -1
  282. package/packages/pi-coding-agent/dist/utils/changelog.js.map +1 -1
  283. package/packages/pi-coding-agent/dist/utils/clipboard-image.d.ts +0 -1
  284. package/packages/pi-coding-agent/dist/utils/clipboard-image.d.ts.map +1 -1
  285. package/packages/pi-coding-agent/dist/utils/clipboard-image.js +1 -1
  286. package/packages/pi-coding-agent/dist/utils/clipboard-image.js.map +1 -1
  287. package/packages/pi-coding-agent/dist/utils/error.d.ts +5 -0
  288. package/packages/pi-coding-agent/dist/utils/error.d.ts.map +1 -0
  289. package/packages/pi-coding-agent/dist/utils/error.js +7 -0
  290. package/packages/pi-coding-agent/dist/utils/error.js.map +1 -0
  291. package/packages/pi-coding-agent/dist/utils/photon.d.ts +0 -19
  292. package/packages/pi-coding-agent/dist/utils/photon.d.ts.map +1 -1
  293. package/packages/pi-coding-agent/dist/utils/photon.js +1 -120
  294. package/packages/pi-coding-agent/dist/utils/photon.js.map +1 -1
  295. package/packages/pi-coding-agent/dist/utils/tools-manager.d.ts +0 -1
  296. package/packages/pi-coding-agent/dist/utils/tools-manager.d.ts.map +1 -1
  297. package/packages/pi-coding-agent/dist/utils/tools-manager.js +1 -1
  298. package/packages/pi-coding-agent/dist/utils/tools-manager.js.map +1 -1
  299. package/packages/pi-coding-agent/package.json +1 -1
  300. package/packages/pi-coding-agent/src/config.ts +5 -10
  301. package/packages/pi-coding-agent/src/core/agent-session.ts +117 -745
  302. package/packages/pi-coding-agent/src/core/auth-storage.ts +4 -38
  303. package/packages/pi-coding-agent/src/core/compaction/branch-summarization.ts +7 -53
  304. package/packages/pi-coding-agent/src/core/compaction/compaction.ts +14 -74
  305. package/packages/pi-coding-agent/src/core/compaction/utils.ts +100 -0
  306. package/packages/pi-coding-agent/src/core/compaction-orchestrator.ts +424 -0
  307. package/packages/pi-coding-agent/src/core/export-html/ansi-to-html.ts +1 -1
  308. package/packages/pi-coding-agent/src/core/extensions/index.ts +1 -21
  309. package/packages/pi-coding-agent/src/core/extensions/runner.ts +119 -256
  310. package/packages/pi-coding-agent/src/core/extensions/types.ts +50 -69
  311. package/packages/pi-coding-agent/src/core/keybindings.ts +2 -2
  312. package/packages/pi-coding-agent/src/core/lock-utils.ts +113 -0
  313. package/packages/pi-coding-agent/src/core/lsp/client.ts +3 -73
  314. package/packages/pi-coding-agent/src/core/lsp/config.ts +2 -10
  315. package/packages/pi-coding-agent/src/core/lsp/edits.ts +1 -1
  316. package/packages/pi-coding-agent/src/core/lsp/index.ts +83 -152
  317. package/packages/pi-coding-agent/src/core/lsp/lspmux.ts +3 -23
  318. package/packages/pi-coding-agent/src/core/lsp/types.ts +0 -29
  319. package/packages/pi-coding-agent/src/core/lsp/utils.ts +1 -33
  320. package/packages/pi-coding-agent/src/core/messages.ts +5 -5
  321. package/packages/pi-coding-agent/src/core/model-registry.ts +0 -2
  322. package/packages/pi-coding-agent/src/core/model-resolver.ts +3 -77
  323. package/packages/pi-coding-agent/src/core/package-manager.ts +1 -4
  324. package/packages/pi-coding-agent/src/core/prompt-templates.ts +2 -2
  325. package/packages/pi-coding-agent/src/core/resource-loader.ts +43 -67
  326. package/packages/pi-coding-agent/src/core/retry-handler.ts +359 -0
  327. package/packages/pi-coding-agent/src/core/session-manager.ts +5 -34
  328. package/packages/pi-coding-agent/src/core/settings-manager.ts +87 -166
  329. package/packages/pi-coding-agent/src/core/skills.ts +1 -4
  330. package/packages/pi-coding-agent/src/index.ts +1 -7
  331. package/packages/pi-coding-agent/src/migrations.ts +2 -2
  332. package/packages/pi-coding-agent/src/modes/interactive/components/session-selector-search.ts +2 -2
  333. package/packages/pi-coding-agent/src/modes/interactive/components/session-selector.ts +17 -29
  334. package/packages/pi-coding-agent/src/modes/interactive/components/tool-execution.ts +1 -13
  335. package/packages/pi-coding-agent/src/modes/interactive/components/tree-render-utils.ts +81 -0
  336. package/packages/pi-coding-agent/src/modes/interactive/components/tree-selector.ts +14 -19
  337. package/packages/pi-coding-agent/src/modes/interactive/interactive-mode.ts +50 -561
  338. package/packages/pi-coding-agent/src/modes/interactive/slash-command-handlers.ts +653 -0
  339. package/packages/pi-coding-agent/src/modes/interactive/theme/theme.ts +7 -26
  340. package/packages/pi-coding-agent/src/modes/interactive/theme/themes.ts +196 -0
  341. package/packages/pi-coding-agent/src/modes/interactive/utils/shorten-path.ts +14 -0
  342. package/packages/pi-coding-agent/src/modes/print-mode.ts +2 -30
  343. package/packages/pi-coding-agent/src/modes/rpc/rpc-mode.ts +2 -28
  344. package/packages/pi-coding-agent/src/modes/shared/command-context-actions.ts +53 -0
  345. package/packages/pi-coding-agent/src/utils/changelog.ts +1 -1
  346. package/packages/pi-coding-agent/src/utils/clipboard-image.ts +1 -1
  347. package/packages/pi-coding-agent/src/utils/error.ts +6 -0
  348. package/packages/pi-coding-agent/src/utils/photon.ts +0 -137
  349. package/packages/pi-coding-agent/src/utils/tools-manager.ts +1 -1
  350. package/packages/pi-tui/dist/components/editor.d.ts +0 -10
  351. package/packages/pi-tui/dist/components/editor.d.ts.map +1 -1
  352. package/packages/pi-tui/dist/components/editor.js +1 -1
  353. package/packages/pi-tui/dist/components/editor.js.map +1 -1
  354. package/packages/pi-tui/dist/components/markdown.d.ts +5 -0
  355. package/packages/pi-tui/dist/components/markdown.d.ts.map +1 -1
  356. package/packages/pi-tui/dist/components/markdown.js +25 -31
  357. package/packages/pi-tui/dist/components/markdown.js.map +1 -1
  358. package/packages/pi-tui/dist/keys.d.ts +0 -4
  359. package/packages/pi-tui/dist/keys.d.ts.map +1 -1
  360. package/packages/pi-tui/dist/keys.js +94 -162
  361. package/packages/pi-tui/dist/keys.js.map +1 -1
  362. package/packages/pi-tui/dist/overlay-layout.d.ts +55 -0
  363. package/packages/pi-tui/dist/overlay-layout.d.ts.map +1 -0
  364. package/packages/pi-tui/dist/overlay-layout.js +288 -0
  365. package/packages/pi-tui/dist/overlay-layout.js.map +1 -0
  366. package/packages/pi-tui/dist/tui.d.ts +0 -22
  367. package/packages/pi-tui/dist/tui.d.ts.map +1 -1
  368. package/packages/pi-tui/dist/tui.js +6 -272
  369. package/packages/pi-tui/dist/tui.js.map +1 -1
  370. package/packages/pi-tui/dist/utils.d.ts +0 -7
  371. package/packages/pi-tui/dist/utils.d.ts.map +1 -1
  372. package/packages/pi-tui/dist/utils.js +0 -44
  373. package/packages/pi-tui/dist/utils.js.map +1 -1
  374. package/packages/pi-tui/src/components/editor.ts +1 -1
  375. package/packages/pi-tui/src/components/markdown.ts +25 -29
  376. package/packages/pi-tui/src/keys.ts +94 -173
  377. package/packages/pi-tui/src/overlay-layout.ts +372 -0
  378. package/packages/pi-tui/src/tui.ts +11 -312
  379. package/packages/pi-tui/src/utils.ts +0 -43
  380. package/pkg/dist/core/export-html/ansi-to-html.d.ts +0 -4
  381. package/pkg/dist/core/export-html/ansi-to-html.d.ts.map +1 -1
  382. package/pkg/dist/core/export-html/ansi-to-html.js +1 -1
  383. package/pkg/dist/core/export-html/ansi-to-html.js.map +1 -1
  384. package/pkg/dist/modes/interactive/theme/theme.d.ts +65 -4
  385. package/pkg/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  386. package/pkg/dist/modes/interactive/theme/theme.js +6 -23
  387. package/pkg/dist/modes/interactive/theme/theme.js.map +1 -1
  388. package/pkg/dist/modes/interactive/theme/themes.d.ts +12 -0
  389. package/pkg/dist/modes/interactive/theme/themes.d.ts.map +1 -0
  390. package/pkg/dist/modes/interactive/theme/themes.js +175 -0
  391. package/pkg/dist/modes/interactive/theme/themes.js.map +1 -0
  392. package/pkg/package.json +1 -1
  393. package/src/resources/extensions/gsd/changelog.ts +213 -0
  394. package/src/resources/extensions/gsd/commands-bootstrap.ts +1 -0
  395. package/src/resources/extensions/gsd/commands-prefs-wizard.ts +5 -1
  396. package/src/resources/extensions/gsd/commands.ts +9 -1
  397. package/src/resources/extensions/gsd/docs/preferences-reference.md +10 -0
  398. package/src/resources/extensions/gsd/doctor-checks.ts +107 -5
  399. package/src/resources/extensions/gsd/doctor-proactive.ts +24 -0
  400. package/src/resources/extensions/gsd/doctor-types.ts +9 -1
  401. package/src/resources/extensions/gsd/doctor.ts +35 -0
  402. package/src/resources/extensions/gsd/guided-flow.ts +4 -2
  403. package/src/resources/extensions/gsd/preferences-validation.ts +38 -0
  404. package/src/resources/extensions/gsd/preferences.ts +2 -0
  405. package/src/resources/extensions/gsd/tests/doctor-git.test.ts +98 -2
  406. package/src/resources/extensions/gsd/tests/doctor-runtime.test.ts +59 -3
  407. package/src/resources/extensions/gsd/tests/preferences.test.ts +28 -0
  408. package/src/resources/extensions/mcp-client/index.ts +2 -1
  409. package/src/resources/skills/create-gsd-extension/references/events-reference.md +4 -4
  410. package/packages/pi-coding-agent/dist/modes/interactive/theme/dark.json +0 -85
  411. package/packages/pi-coding-agent/dist/modes/interactive/theme/light.json +0 -84
  412. package/packages/pi-coding-agent/dist/modes/interactive/theme/theme-schema.json +0 -335
  413. package/packages/pi-coding-agent/src/modes/interactive/theme/dark.json +0 -85
  414. package/packages/pi-coding-agent/src/modes/interactive/theme/light.json +0 -84
  415. package/packages/pi-coding-agent/src/modes/interactive/theme/theme-schema.json +0 -335
  416. package/pkg/dist/modes/interactive/theme/dark.json +0 -85
  417. package/pkg/dist/modes/interactive/theme/light.json +0 -84
  418. package/pkg/dist/modes/interactive/theme/theme-schema.json +0 -335
@@ -0,0 +1,87 @@
1
+ /**
2
+ * RetryHandler - Automatic retry logic with exponential backoff and credential/provider fallback.
3
+ *
4
+ * Handles retryable errors (overloaded, rate limit, server errors) by:
5
+ * 1. Trying alternate credentials for the same provider
6
+ * 2. Falling back to other providers via FallbackResolver
7
+ * 3. Exponential backoff with configurable max retries
8
+ *
9
+ * Context overflow errors are NOT handled here (see compaction).
10
+ */
11
+ import type { Agent } from "@gsd/pi-agent-core";
12
+ import type { AssistantMessage, Model } from "@gsd/pi-ai";
13
+ import type { FallbackResolver } from "./fallback-resolver.js";
14
+ import type { ModelRegistry } from "./model-registry.js";
15
+ import type { SettingsManager } from "./settings-manager.js";
16
+ import type { AgentSessionEvent } from "./agent-session.js";
17
+ /** Dependencies injected from AgentSession into RetryHandler */
18
+ export interface RetryHandlerDeps {
19
+ readonly agent: Agent;
20
+ readonly settingsManager: SettingsManager;
21
+ readonly modelRegistry: ModelRegistry;
22
+ readonly fallbackResolver: FallbackResolver;
23
+ getModel: () => Model<any> | undefined;
24
+ getSessionId: () => string;
25
+ emit: (event: AgentSessionEvent) => void;
26
+ /** Called when the retry handler switches to a fallback model */
27
+ onModelChange: (model: Model<any>) => void;
28
+ }
29
+ export declare class RetryHandler {
30
+ private readonly _deps;
31
+ private _retryAbortController;
32
+ private _retryAttempt;
33
+ private _retryPromise;
34
+ private _retryResolve;
35
+ constructor(_deps: RetryHandlerDeps);
36
+ /** Current retry attempt (0 if not retrying) */
37
+ get retryAttempt(): number;
38
+ /** Whether auto-retry is currently in progress */
39
+ get isRetrying(): boolean;
40
+ /** Whether auto-retry is enabled */
41
+ get autoRetryEnabled(): boolean;
42
+ /** Toggle auto-retry setting */
43
+ setAutoRetryEnabled(enabled: boolean): void;
44
+ /**
45
+ * Create a retry promise synchronously for agent_end events.
46
+ * Must be called synchronously from the agent event handler before
47
+ * any async processing, so that waitForRetry() doesn't miss in-flight retries.
48
+ */
49
+ createRetryPromiseForAgentEnd(messages: Array<{
50
+ role: string;
51
+ } & Record<string, any>>): void;
52
+ /**
53
+ * Handle a successful assistant response by resetting retry state.
54
+ * Call this when an assistant message completes without error.
55
+ */
56
+ handleSuccessfulResponse(): void;
57
+ /**
58
+ * Check if an error is retryable (overloaded, rate limit, server errors).
59
+ * Context overflow errors are NOT retryable (handled by compaction instead).
60
+ */
61
+ isRetryableError(message: AssistantMessage): boolean;
62
+ /**
63
+ * Handle retryable errors with exponential backoff.
64
+ * When multiple credentials are available, marks the failing credential
65
+ * as backed off and retries immediately with the next one.
66
+ * @returns true if retry was initiated, false if max retries exceeded or disabled
67
+ */
68
+ handleRetryableError(message: AssistantMessage): Promise<boolean>;
69
+ /** Cancel in-progress retry */
70
+ abortRetry(): void;
71
+ /**
72
+ * Wait for any in-progress retry to complete.
73
+ * Returns immediately if no retry is in progress.
74
+ */
75
+ waitForRetry(): Promise<void>;
76
+ /** Resolve the pending retry promise */
77
+ resolveRetry(): void;
78
+ private _resolveRetry;
79
+ private _findLastAssistantInMessages;
80
+ /**
81
+ * Classify an error message into a usage-limit error type for credential backoff.
82
+ */
83
+ private _classifyErrorType;
84
+ /** Remove the last assistant error message from agent state */
85
+ private _removeLastAssistantError;
86
+ }
87
+ //# sourceMappingURL=retry-handler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"retry-handler.d.ts","sourceRoot":"","sources":["../../src/core/retry-handler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAG1D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAE5D,gEAAgE;AAChE,MA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,CAAC,OAAO,CAAC;IA+KvE,+BAA+B;IAC/B,UAAU,IAAI,IAAI;IAKlB;;;OAGG;IACG,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IAMnC,wCAAwC;IACxC,YAAY,IAAI,IAAI;IAQpB,OAAO,CAAC,aAAa;IAQrB,OAAO,CAAC,4BAA4B;IAYpC;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAQ1B,+DAA+D;IAC/D,OAAO,CAAC,yBAAyB;CAMjC"}
@@ -0,0 +1,295 @@
1
+ /**
2
+ * RetryHandler - Automatic retry logic with exponential backoff and credential/provider fallback.
3
+ *
4
+ * Handles retryable errors (overloaded, rate limit, server errors) by:
5
+ * 1. Trying alternate credentials for the same provider
6
+ * 2. Falling back to other providers via FallbackResolver
7
+ * 3. Exponential backoff with configurable max retries
8
+ *
9
+ * Context overflow errors are NOT handled here (see compaction).
10
+ */
11
+ import { isContextOverflow } from "@gsd/pi-ai";
12
+ import { sleep } from "../utils/sleep.js";
13
+ export class RetryHandler {
14
+ constructor(_deps) {
15
+ this._deps = _deps;
16
+ this._retryAbortController = undefined;
17
+ this._retryAttempt = 0;
18
+ this._retryPromise = undefined;
19
+ this._retryResolve = undefined;
20
+ }
21
+ /** Current retry attempt (0 if not retrying) */
22
+ get retryAttempt() {
23
+ return this._retryAttempt;
24
+ }
25
+ /** Whether auto-retry is currently in progress */
26
+ get isRetrying() {
27
+ return this._retryPromise !== undefined;
28
+ }
29
+ /** Whether auto-retry is enabled */
30
+ get autoRetryEnabled() {
31
+ return this._deps.settingsManager.getRetryEnabled();
32
+ }
33
+ /** Toggle auto-retry setting */
34
+ setAutoRetryEnabled(enabled) {
35
+ this._deps.settingsManager.setRetryEnabled(enabled);
36
+ }
37
+ /**
38
+ * Create a retry promise synchronously for agent_end events.
39
+ * Must be called synchronously from the agent event handler before
40
+ * any async processing, so that waitForRetry() doesn't miss in-flight retries.
41
+ */
42
+ createRetryPromiseForAgentEnd(messages) {
43
+ if (this._retryPromise)
44
+ return;
45
+ const settings = this._deps.settingsManager.getRetrySettings();
46
+ if (!settings.enabled)
47
+ return;
48
+ const lastAssistant = this._findLastAssistantInMessages(messages);
49
+ if (!lastAssistant || !this.isRetryableError(lastAssistant))
50
+ return;
51
+ this._retryPromise = new Promise((resolve) => {
52
+ this._retryResolve = resolve;
53
+ });
54
+ }
55
+ /**
56
+ * Handle a successful assistant response by resetting retry state.
57
+ * Call this when an assistant message completes without error.
58
+ */
59
+ handleSuccessfulResponse() {
60
+ if (this._retryAttempt > 0) {
61
+ this._deps.emit({
62
+ type: "auto_retry_end",
63
+ success: true,
64
+ attempt: this._retryAttempt,
65
+ });
66
+ this._retryAttempt = 0;
67
+ this._resolveRetry();
68
+ }
69
+ }
70
+ /**
71
+ * Check if an error is retryable (overloaded, rate limit, server errors).
72
+ * Context overflow errors are NOT retryable (handled by compaction instead).
73
+ */
74
+ isRetryableError(message) {
75
+ if (message.stopReason !== "error" || !message.errorMessage)
76
+ return false;
77
+ // Context overflow is handled by compaction, not retry
78
+ const contextWindow = this._deps.getModel()?.contextWindow ?? 0;
79
+ if (isContextOverflow(message, contextWindow))
80
+ return false;
81
+ const err = message.errorMessage;
82
+ return /overloaded|rate.?limit|too many requests|429|500|502|503|504|service.?unavailable|server.?error|internal.?error|connection.?error|connection.?refused|other side closed|fetch failed|upstream.?connect|reset before headers|terminated|retry delay|network.?(?:is\s+)?unavailable|credentials.*expired|temporarily backed off/i.test(err);
83
+ }
84
+ /**
85
+ * Handle retryable errors with exponential backoff.
86
+ * When multiple credentials are available, marks the failing credential
87
+ * as backed off and retries immediately with the next one.
88
+ * @returns true if retry was initiated, false if max retries exceeded or disabled
89
+ */
90
+ async handleRetryableError(message) {
91
+ const settings = this._deps.settingsManager.getRetrySettings();
92
+ if (!settings.enabled) {
93
+ this._resolveRetry();
94
+ return false;
95
+ }
96
+ // Retry promise is created synchronously in createRetryPromiseForAgentEnd.
97
+ // Keep a defensive fallback here in case a future refactor bypasses that path.
98
+ if (!this._retryPromise) {
99
+ this._retryPromise = new Promise((resolve) => {
100
+ this._retryResolve = resolve;
101
+ });
102
+ }
103
+ // Try credential fallback before counting against retry budget.
104
+ if (this._deps.getModel() && message.errorMessage) {
105
+ const errorType = this._classifyErrorType(message.errorMessage);
106
+ const isCredentialError = errorType !== "unknown";
107
+ const hasAlternate = isCredentialError &&
108
+ this._deps.modelRegistry.authStorage.markUsageLimitReached(this._deps.getModel().provider, this._deps.getSessionId(), { errorType });
109
+ if (hasAlternate) {
110
+ this._removeLastAssistantError();
111
+ this._deps.emit({
112
+ type: "auto_retry_start",
113
+ attempt: this._retryAttempt + 1,
114
+ maxAttempts: settings.maxRetries,
115
+ delayMs: 0,
116
+ errorMessage: `${message.errorMessage} (switching credential)`,
117
+ });
118
+ // Retry immediately with the next credential - don't increment _retryAttempt
119
+ setTimeout(() => {
120
+ this._deps.agent.continue().catch(() => { });
121
+ }, 0);
122
+ return true;
123
+ }
124
+ // All credentials are backed off. Try cross-provider fallback before giving up.
125
+ if (isCredentialError) {
126
+ const fallbackResult = await this._deps.fallbackResolver.findFallback(this._deps.getModel(), errorType);
127
+ if (fallbackResult) {
128
+ const previousProvider = this._deps.getModel().provider;
129
+ this._deps.agent.setModel(fallbackResult.model);
130
+ this._deps.onModelChange(fallbackResult.model);
131
+ this._removeLastAssistantError();
132
+ this._deps.emit({
133
+ type: "fallback_provider_switch",
134
+ from: `${previousProvider}/${this._deps.getModel()?.id}`,
135
+ to: `${fallbackResult.model.provider}/${fallbackResult.model.id}`,
136
+ reason: fallbackResult.reason,
137
+ });
138
+ this._deps.emit({
139
+ type: "auto_retry_start",
140
+ attempt: this._retryAttempt + 1,
141
+ maxAttempts: settings.maxRetries,
142
+ delayMs: 0,
143
+ errorMessage: `${message.errorMessage} (${fallbackResult.reason})`,
144
+ });
145
+ // Retry immediately with fallback provider - don't increment _retryAttempt
146
+ setTimeout(() => {
147
+ this._deps.agent.continue().catch(() => { });
148
+ }, 0);
149
+ return true;
150
+ }
151
+ // No fallback available either
152
+ if (errorType === "quota_exhausted") {
153
+ this._deps.emit({
154
+ type: "fallback_chain_exhausted",
155
+ reason: `All providers exhausted for ${this._deps.getModel().provider}/${this._deps.getModel().id}`,
156
+ });
157
+ this._deps.emit({
158
+ type: "auto_retry_end",
159
+ success: false,
160
+ attempt: this._retryAttempt,
161
+ finalError: message.errorMessage,
162
+ });
163
+ this._retryAttempt = 0;
164
+ this._resolveRetry();
165
+ return false;
166
+ }
167
+ }
168
+ }
169
+ this._retryAttempt++;
170
+ if (this._retryAttempt > settings.maxRetries) {
171
+ this._deps.emit({
172
+ type: "auto_retry_end",
173
+ success: false,
174
+ attempt: this._retryAttempt - 1,
175
+ finalError: message.errorMessage,
176
+ });
177
+ this._retryAttempt = 0;
178
+ this._resolveRetry();
179
+ return false;
180
+ }
181
+ // Use server-requested delay when available, capped by maxDelayMs.
182
+ // Fall back to exponential backoff when no server hint is present.
183
+ const exponentialDelayMs = settings.baseDelayMs * 2 ** (this._retryAttempt - 1);
184
+ let delayMs;
185
+ if (message.retryAfterMs !== undefined) {
186
+ const cap = settings.maxDelayMs > 0 ? settings.maxDelayMs : Infinity;
187
+ if (message.retryAfterMs > cap) {
188
+ this._deps.emit({
189
+ type: "auto_retry_end",
190
+ success: false,
191
+ attempt: this._retryAttempt - 1,
192
+ finalError: `Rate limit reset in ${Math.ceil(message.retryAfterMs / 1000)}s (max: ${Math.ceil(cap / 1000)}s). ${message.errorMessage || ""}`.trim(),
193
+ });
194
+ this._retryAttempt = 0;
195
+ this._resolveRetry();
196
+ return false;
197
+ }
198
+ delayMs = message.retryAfterMs;
199
+ }
200
+ else {
201
+ delayMs = exponentialDelayMs;
202
+ }
203
+ this._deps.emit({
204
+ type: "auto_retry_start",
205
+ attempt: this._retryAttempt,
206
+ maxAttempts: settings.maxRetries,
207
+ delayMs,
208
+ errorMessage: message.errorMessage || "Unknown error",
209
+ });
210
+ this._removeLastAssistantError();
211
+ // Wait with exponential backoff (abortable)
212
+ this._retryAbortController = new AbortController();
213
+ try {
214
+ await sleep(delayMs, this._retryAbortController.signal);
215
+ }
216
+ catch {
217
+ // Aborted during sleep
218
+ const attempt = this._retryAttempt;
219
+ this._retryAttempt = 0;
220
+ this._retryAbortController = undefined;
221
+ this._deps.emit({
222
+ type: "auto_retry_end",
223
+ success: false,
224
+ attempt,
225
+ finalError: "Retry cancelled",
226
+ });
227
+ this._resolveRetry();
228
+ return false;
229
+ }
230
+ this._retryAbortController = undefined;
231
+ // Retry via continue() - use setTimeout to break out of event handler chain
232
+ setTimeout(() => {
233
+ this._deps.agent.continue().catch(() => { });
234
+ }, 0);
235
+ return true;
236
+ }
237
+ /** Cancel in-progress retry */
238
+ abortRetry() {
239
+ this._retryAbortController?.abort();
240
+ this._resolveRetry();
241
+ }
242
+ /**
243
+ * Wait for any in-progress retry to complete.
244
+ * Returns immediately if no retry is in progress.
245
+ */
246
+ async waitForRetry() {
247
+ if (this._retryPromise) {
248
+ await this._retryPromise;
249
+ }
250
+ }
251
+ /** Resolve the pending retry promise */
252
+ resolveRetry() {
253
+ this._resolveRetry();
254
+ }
255
+ // =========================================================================
256
+ // Private helpers
257
+ // =========================================================================
258
+ _resolveRetry() {
259
+ if (this._retryResolve) {
260
+ this._retryResolve();
261
+ this._retryResolve = undefined;
262
+ this._retryPromise = undefined;
263
+ }
264
+ }
265
+ _findLastAssistantInMessages(messages) {
266
+ for (let i = messages.length - 1; i >= 0; i--) {
267
+ const message = messages[i];
268
+ if (message.role === "assistant") {
269
+ return message;
270
+ }
271
+ }
272
+ return undefined;
273
+ }
274
+ /**
275
+ * Classify an error message into a usage-limit error type for credential backoff.
276
+ */
277
+ _classifyErrorType(errorMessage) {
278
+ const err = errorMessage.toLowerCase();
279
+ if (/quota|billing|exceeded.*limit|usage.*limit/i.test(err))
280
+ return "quota_exhausted";
281
+ if (/rate.?limit|too many requests|429/i.test(err))
282
+ return "rate_limit";
283
+ if (/500|502|503|504|server.?error|internal.?error|service.?unavailable/i.test(err))
284
+ return "server_error";
285
+ return "unknown";
286
+ }
287
+ /** Remove the last assistant error message from agent state */
288
+ _removeLastAssistantError() {
289
+ const messages = this._deps.agent.state.messages;
290
+ if (messages.length > 0 && messages[messages.length - 1].role === "assistant") {
291
+ this._deps.agent.replaceMessages(messages.slice(0, -1));
292
+ }
293
+ }
294
+ }
295
+ //# sourceMappingURL=retry-handler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"retry-handler.js","sourceRoot":"","sources":["../../src/core/retry-handler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAK/C,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAgB1C,MAAM,OAAO,YAAY;IAMxB,YAA6B,KAAuB;QAAvB,UAAK,GAAL,KAAK,CAAkB;QAL5C,0BAAqB,GAAgC,SAAS,CAAC;QAC/D,kBAAa,GAAG,CAAC,CAAC;QAClB,kBAAa,GAA8B,SAAS,CAAC;QACrD,kBAAa,GAA6B,SAAS,CAAC;IAEL,CAAC;IAExD,gDAAgD;IAChD,IAAI,YAAY;QACf,OAAO,IAAI,CAAC,aAAa,CAAC;IAC3B,CAAC;IAED,kDAAkD;IAClD,IAAI,UAAU;QACb,OAAO,IAAI,CAAC,aAAa,KAAK,SAAS,CAAC;IACzC,CAAC;IAED,oCAAoC;IACpC,IAAI,gBAAgB;QACnB,OAAO,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,eAAe,EAAE,CAAC;IACrD,CAAC;IAED,gCAAgC;IAChC,mBAAmB,CAAC,OAAgB;QACnC,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;IACrD,CAAC;IAED;;;;OAIG;IACH,6BAA6B,CAAC,QAAuD;QACpF,IAAI,IAAI,CAAC,aAAa;YAAE,OAAO;QAE/B,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,gBAAgB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C;YAC/E,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,eAAe,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QACzD,CAAC;IACF,CAAC;CACD","sourcesContent":["/**\n * RetryHandler - Automatic retry logic with exponential backoff and credential/provider fallback.\n *\n * Handles retryable errors (overloaded, rate limit, server errors) by:\n * 1. Trying alternate credentials for the same provider\n * 2. Falling back to other providers via FallbackResolver\n * 3. Exponential backoff with configurable max retries\n *\n * Context overflow errors are NOT handled here (see compaction).\n */\n\nimport type { Agent } from \"@gsd/pi-agent-core\";\nimport type { AssistantMessage, Model } from \"@gsd/pi-ai\";\nimport { isContextOverflow } from \"@gsd/pi-ai\";\nimport type { UsageLimitErrorType } from \"./auth-storage.js\";\nimport type { FallbackResolver } from \"./fallback-resolver.js\";\nimport type { ModelRegistry } from \"./model-registry.js\";\nimport type { SettingsManager } from \"./settings-manager.js\";\nimport { sleep } from \"../utils/sleep.js\";\nimport type { AgentSessionEvent } from \"./agent-session.js\";\n\n/** Dependencies injected from AgentSession into RetryHandler */\nexport interface RetryHandlerDeps {\n\treadonly agent: Agent;\n\treadonly settingsManager: SettingsManager;\n\treadonly modelRegistry: ModelRegistry;\n\treadonly fallbackResolver: FallbackResolver;\n\tgetModel: () => Model<any> | undefined;\n\tgetSessionId: () => string;\n\temit: (event: AgentSessionEvent) => void;\n\t/** Called when the retry handler switches to a fallback model */\n\tonModelChange: (model: Model<any>) => void;\n}\n\nexport class RetryHandler {\n\tprivate _retryAbortController: AbortController | undefined = undefined;\n\tprivate _retryAttempt = 0;\n\tprivate _retryPromise: Promise<void> | undefined = undefined;\n\tprivate _retryResolve: (() => void) | undefined = undefined;\n\n\tconstructor(private readonly _deps: RetryHandlerDeps) {}\n\n\t/** Current retry attempt (0 if not retrying) */\n\tget retryAttempt(): number {\n\t\treturn this._retryAttempt;\n\t}\n\n\t/** Whether auto-retry is currently in progress */\n\tget isRetrying(): boolean {\n\t\treturn this._retryPromise !== undefined;\n\t}\n\n\t/** Whether auto-retry is enabled */\n\tget autoRetryEnabled(): boolean {\n\t\treturn this._deps.settingsManager.getRetryEnabled();\n\t}\n\n\t/** Toggle auto-retry setting */\n\tsetAutoRetryEnabled(enabled: boolean): void {\n\t\tthis._deps.settingsManager.setRetryEnabled(enabled);\n\t}\n\n\t/**\n\t * Create a retry promise synchronously for agent_end events.\n\t * Must be called synchronously from the agent event handler before\n\t * any async processing, so that waitForRetry() doesn't miss in-flight retries.\n\t */\n\tcreateRetryPromiseForAgentEnd(messages: Array<{ role: string } & Record<string, any>>): void {\n\t\tif (this._retryPromise) return;\n\n\t\tconst settings = this._deps.settingsManager.getRetrySettings();\n\t\tif (!settings.enabled) return;\n\n\t\tconst lastAssistant = this._findLastAssistantInMessages(messages);\n\t\tif (!lastAssistant || !this.isRetryableError(lastAssistant)) return;\n\n\t\tthis._retryPromise = new Promise((resolve) => {\n\t\t\tthis._retryResolve = resolve;\n\t\t});\n\t}\n\n\t/**\n\t * Handle a successful assistant response by resetting retry state.\n\t * Call this when an assistant message completes without error.\n\t */\n\thandleSuccessfulResponse(): void {\n\t\tif (this._retryAttempt > 0) {\n\t\t\tthis._deps.emit({\n\t\t\t\ttype: \"auto_retry_end\",\n\t\t\t\tsuccess: true,\n\t\t\t\tattempt: this._retryAttempt,\n\t\t\t});\n\t\t\tthis._retryAttempt = 0;\n\t\t\tthis._resolveRetry();\n\t\t}\n\t}\n\n\t/**\n\t * Check if an error is retryable (overloaded, rate limit, server errors).\n\t * Context overflow errors are NOT retryable (handled by compaction instead).\n\t */\n\tisRetryableError(message: AssistantMessage): boolean {\n\t\tif (message.stopReason !== \"error\" || !message.errorMessage) return false;\n\n\t\t// Context overflow is handled by compaction, not retry\n\t\tconst contextWindow = this._deps.getModel()?.contextWindow ?? 0;\n\t\tif (isContextOverflow(message, contextWindow)) return false;\n\n\t\tconst err = message.errorMessage;\n\t\treturn /overloaded|rate.?limit|too many requests|429|500|502|503|504|service.?unavailable|server.?error|internal.?error|connection.?error|connection.?refused|other side closed|fetch failed|upstream.?connect|reset before headers|terminated|retry delay|network.?(?:is\\s+)?unavailable|credentials.*expired|temporarily backed off/i.test(\n\t\t\terr,\n\t\t);\n\t}\n\n\t/**\n\t * Handle retryable errors with exponential backoff.\n\t * When multiple credentials are available, marks the failing credential\n\t * as backed off and retries immediately with the next one.\n\t * @returns true if retry was initiated, false if max retries exceeded or disabled\n\t */\n\tasync handleRetryableError(message: AssistantMessage): Promise<boolean> {\n\t\tconst settings = this._deps.settingsManager.getRetrySettings();\n\t\tif (!settings.enabled) {\n\t\t\tthis._resolveRetry();\n\t\t\treturn false;\n\t\t}\n\n\t\t// Retry promise is created synchronously in createRetryPromiseForAgentEnd.\n\t\t// Keep a defensive fallback here in case a future refactor bypasses that path.\n\t\tif (!this._retryPromise) {\n\t\t\tthis._retryPromise = new Promise((resolve) => {\n\t\t\t\tthis._retryResolve = resolve;\n\t\t\t});\n\t\t}\n\n\t\t// Try credential fallback before counting against retry budget.\n\t\tif (this._deps.getModel() && message.errorMessage) {\n\t\t\tconst errorType = this._classifyErrorType(message.errorMessage);\n\t\t\tconst isCredentialError = errorType !== \"unknown\";\n\t\t\tconst hasAlternate =\n\t\t\t\tisCredentialError &&\n\t\t\t\tthis._deps.modelRegistry.authStorage.markUsageLimitReached(\n\t\t\t\t\tthis._deps.getModel()!.provider,\n\t\t\t\t\tthis._deps.getSessionId(),\n\t\t\t\t\t{ errorType },\n\t\t\t\t);\n\n\t\t\tif (hasAlternate) {\n\t\t\t\tthis._removeLastAssistantError();\n\n\t\t\t\tthis._deps.emit({\n\t\t\t\t\ttype: \"auto_retry_start\",\n\t\t\t\t\tattempt: this._retryAttempt + 1,\n\t\t\t\t\tmaxAttempts: settings.maxRetries,\n\t\t\t\t\tdelayMs: 0,\n\t\t\t\t\terrorMessage: `${message.errorMessage} (switching credential)`,\n\t\t\t\t});\n\n\t\t\t\t// Retry immediately with the next credential - don't increment _retryAttempt\n\t\t\t\tsetTimeout(() => {\n\t\t\t\t\tthis._deps.agent.continue().catch(() => {});\n\t\t\t\t}, 0);\n\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\t// All credentials are backed off. Try cross-provider fallback before giving up.\n\t\t\tif (isCredentialError) {\n\t\t\t\tconst fallbackResult = await this._deps.fallbackResolver.findFallback(\n\t\t\t\t\tthis._deps.getModel()!,\n\t\t\t\t\terrorType,\n\t\t\t\t);\n\n\t\t\t\tif (fallbackResult) {\n\t\t\t\t\tconst previousProvider = this._deps.getModel()!.provider;\n\t\t\t\t\tthis._deps.agent.setModel(fallbackResult.model);\n\t\t\t\t\tthis._deps.onModelChange(fallbackResult.model);\n\t\t\t\t\tthis._removeLastAssistantError();\n\n\t\t\t\t\tthis._deps.emit({\n\t\t\t\t\t\ttype: \"fallback_provider_switch\",\n\t\t\t\t\t\tfrom: `${previousProvider}/${this._deps.getModel()?.id}`,\n\t\t\t\t\t\tto: `${fallbackResult.model.provider}/${fallbackResult.model.id}`,\n\t\t\t\t\t\treason: fallbackResult.reason,\n\t\t\t\t\t});\n\n\t\t\t\t\tthis._deps.emit({\n\t\t\t\t\t\ttype: \"auto_retry_start\",\n\t\t\t\t\t\tattempt: this._retryAttempt + 1,\n\t\t\t\t\t\tmaxAttempts: settings.maxRetries,\n\t\t\t\t\t\tdelayMs: 0,\n\t\t\t\t\t\terrorMessage: `${message.errorMessage} (${fallbackResult.reason})`,\n\t\t\t\t\t});\n\n\t\t\t\t\t// Retry immediately with fallback provider - don't increment _retryAttempt\n\t\t\t\t\tsetTimeout(() => {\n\t\t\t\t\t\tthis._deps.agent.continue().catch(() => {});\n\t\t\t\t\t}, 0);\n\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\n\t\t\t\t// No fallback available either\n\t\t\t\tif (errorType === \"quota_exhausted\") {\n\t\t\t\t\tthis._deps.emit({\n\t\t\t\t\t\ttype: \"fallback_chain_exhausted\",\n\t\t\t\t\t\treason: `All providers exhausted for ${this._deps.getModel()!.provider}/${this._deps.getModel()!.id}`,\n\t\t\t\t\t});\n\t\t\t\t\tthis._deps.emit({\n\t\t\t\t\t\ttype: \"auto_retry_end\",\n\t\t\t\t\t\tsuccess: false,\n\t\t\t\t\t\tattempt: this._retryAttempt,\n\t\t\t\t\t\tfinalError: message.errorMessage,\n\t\t\t\t\t});\n\t\t\t\t\tthis._retryAttempt = 0;\n\t\t\t\t\tthis._resolveRetry();\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tthis._retryAttempt++;\n\n\t\tif (this._retryAttempt > settings.maxRetries) {\n\t\t\tthis._deps.emit({\n\t\t\t\ttype: \"auto_retry_end\",\n\t\t\t\tsuccess: false,\n\t\t\t\tattempt: this._retryAttempt - 1,\n\t\t\t\tfinalError: message.errorMessage,\n\t\t\t});\n\t\t\tthis._retryAttempt = 0;\n\t\t\tthis._resolveRetry();\n\t\t\treturn false;\n\t\t}\n\n\t\t// Use server-requested delay when available, capped by maxDelayMs.\n\t\t// Fall back to exponential backoff when no server hint is present.\n\t\tconst exponentialDelayMs = settings.baseDelayMs * 2 ** (this._retryAttempt - 1);\n\t\tlet delayMs: number;\n\t\tif (message.retryAfterMs !== undefined) {\n\t\t\tconst cap = settings.maxDelayMs > 0 ? settings.maxDelayMs : Infinity;\n\t\t\tif (message.retryAfterMs > cap) {\n\t\t\t\tthis._deps.emit({\n\t\t\t\t\ttype: \"auto_retry_end\",\n\t\t\t\t\tsuccess: false,\n\t\t\t\t\tattempt: this._retryAttempt - 1,\n\t\t\t\t\tfinalError: `Rate limit reset in ${Math.ceil(message.retryAfterMs / 1000)}s (max: ${Math.ceil(cap / 1000)}s). ${message.errorMessage || \"\"}`.trim(),\n\t\t\t\t});\n\t\t\t\tthis._retryAttempt = 0;\n\t\t\t\tthis._resolveRetry();\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tdelayMs = message.retryAfterMs;\n\t\t} else {\n\t\t\tdelayMs = exponentialDelayMs;\n\t\t}\n\n\t\tthis._deps.emit({\n\t\t\ttype: \"auto_retry_start\",\n\t\t\tattempt: this._retryAttempt,\n\t\t\tmaxAttempts: settings.maxRetries,\n\t\t\tdelayMs,\n\t\t\terrorMessage: message.errorMessage || \"Unknown error\",\n\t\t});\n\n\t\tthis._removeLastAssistantError();\n\n\t\t// Wait with exponential backoff (abortable)\n\t\tthis._retryAbortController = new AbortController();\n\t\ttry {\n\t\t\tawait sleep(delayMs, this._retryAbortController.signal);\n\t\t} catch {\n\t\t\t// Aborted during sleep\n\t\t\tconst attempt = this._retryAttempt;\n\t\t\tthis._retryAttempt = 0;\n\t\t\tthis._retryAbortController = undefined;\n\t\t\tthis._deps.emit({\n\t\t\t\ttype: \"auto_retry_end\",\n\t\t\t\tsuccess: false,\n\t\t\t\tattempt,\n\t\t\t\tfinalError: \"Retry cancelled\",\n\t\t\t});\n\t\t\tthis._resolveRetry();\n\t\t\treturn false;\n\t\t}\n\t\tthis._retryAbortController = undefined;\n\n\t\t// Retry via continue() - use setTimeout to break out of event handler chain\n\t\tsetTimeout(() => {\n\t\t\tthis._deps.agent.continue().catch(() => {});\n\t\t}, 0);\n\n\t\treturn true;\n\t}\n\n\t/** Cancel in-progress retry */\n\tabortRetry(): void {\n\t\tthis._retryAbortController?.abort();\n\t\tthis._resolveRetry();\n\t}\n\n\t/**\n\t * Wait for any in-progress retry to complete.\n\t * Returns immediately if no retry is in progress.\n\t */\n\tasync waitForRetry(): Promise<void> {\n\t\tif (this._retryPromise) {\n\t\t\tawait this._retryPromise;\n\t\t}\n\t}\n\n\t/** Resolve the pending retry promise */\n\tresolveRetry(): void {\n\t\tthis._resolveRetry();\n\t}\n\n\t// =========================================================================\n\t// Private helpers\n\t// =========================================================================\n\n\tprivate _resolveRetry(): void {\n\t\tif (this._retryResolve) {\n\t\t\tthis._retryResolve();\n\t\t\tthis._retryResolve = undefined;\n\t\t\tthis._retryPromise = undefined;\n\t\t}\n\t}\n\n\tprivate _findLastAssistantInMessages(\n\t\tmessages: Array<{ role: string } & Record<string, any>>,\n\t): AssistantMessage | undefined {\n\t\tfor (let i = messages.length - 1; i >= 0; i--) {\n\t\t\tconst message = messages[i];\n\t\t\tif (message.role === \"assistant\") {\n\t\t\t\treturn message as AssistantMessage;\n\t\t\t}\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Classify an error message into a usage-limit error type for credential backoff.\n\t */\n\tprivate _classifyErrorType(errorMessage: string): UsageLimitErrorType {\n\t\tconst err = errorMessage.toLowerCase();\n\t\tif (/quota|billing|exceeded.*limit|usage.*limit/i.test(err)) return \"quota_exhausted\";\n\t\tif (/rate.?limit|too many requests|429/i.test(err)) return \"rate_limit\";\n\t\tif (/500|502|503|504|server.?error|internal.?error|service.?unavailable/i.test(err)) return \"server_error\";\n\t\treturn \"unknown\";\n\t}\n\n\t/** Remove the last assistant error message from agent state */\n\tprivate _removeLastAssistantError(): void {\n\t\tconst messages = this._deps.agent.state.messages;\n\t\tif (messages.length > 0 && messages[messages.length - 1].role === \"assistant\") {\n\t\t\tthis._deps.agent.replaceMessages(messages.slice(0, -1));\n\t\t}\n\t}\n}\n"]}
@@ -149,10 +149,6 @@ export declare function getLatestCompactionEntry(entries: SessionEntry[]): Compa
149
149
  * Handles compaction and branch summaries along the path.
150
150
  */
151
151
  export declare function buildSessionContext(entries: SessionEntry[], leafId?: string | null, byId?: Map<string, SessionEntry>): SessionContext;
152
- /** Exported for testing */
153
- export declare function loadEntriesFromFile(filePath: string): FileEntry[];
154
- /** Exported for testing */
155
- export declare function findMostRecentSession(sessionDir: string): string | null;
156
152
  export type SessionListProgress = (loaded: number, total: number) => void;
157
153
  /**
158
154
  * Manages conversation sessions as append-only trees stored in JSONL files.
@@ -190,7 +186,6 @@ export declare class SessionManager {
190
186
  setSessionFile(sessionFile: string): void;
191
187
  newSession(options?: NewSessionOptions): string | undefined;
192
188
  private _buildIndex;
193
- private acquireSessionLock;
194
189
  private _rewriteFile;
195
190
  isPersisted(): boolean;
196
191
  getCwd(): string;
@@ -1 +1 @@
1
- {"version":3,"file":"session-manager.d.ts","sourceRoot":"","sources":["../../src/core/session-manager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAmBrE,OAAO,EACN,KAAK,oBAAoB,EACzB,KAAK,aAAa,EAIlB,MAAM,eAAe,CAAC;AA0BvB,eAAO,MAAM,uBAAuB,IAAI,CAAC;AAEzC,MAAM,WAAW,aAAa;IAC7B,IAAI,EAAE,SAAS,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,EAAE,MAAM,CAAC;IACZ,aAAa,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,iBAAiB;IACjC,aAAa,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,gBAAgB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,mBAAoB,SAAQ,gBAAgB;IAC5D,IAAI,EAAE,SAAS,CAAC;IAChB,OAAO,EAAE,YAAY,CAAC;CACtB;AAED,MAAM,WAAW,wBAAyB,SAAQ,gBAAgB;IACjE,IAAI,EAAE,uBAAuB,CAAC;IAC9B,aAAa,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,gBAAiB,SAAQ,gBAAgB;IACzD,IAAI,EAAE,cAAc,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,eAAe,CAAC,CAAC,GAAG,OAAO,CAAE,SAAQ,gBAA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AAE,SAAS,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,cAAc;IA2C3F;;;;;OAKG;WACU,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IAO7G;;;OAGG;WACU,OAAO,CAAC,UAAU,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;CAqD9E"}
@@ -3,8 +3,8 @@ import { appendFileSync, closeSync, existsSync, mkdirSync, openSync, readdirSync
3
3
  import { atomicWriteFileSync } from "./fs-utils.js";
4
4
  import { readdir, readFile, stat } from "fs/promises";
5
5
  import { join, resolve } from "path";
6
- import lockfile from "proper-lockfile";
7
6
  import { getAgentDir as getDefaultAgentDir, getBlobsDir, getSessionsDir } from "../config.js";
7
+ import { tryAcquireLockSync } from "./lock-utils.js";
8
8
  import { createBranchSummaryMessage, createCompactionSummaryMessage, createCustomMessage, } from "./messages.js";
9
9
  import { BlobStore, externalizeImageData, isBlobRef, resolveImageData } from "./blob-store.js";
10
10
  /** Inline concurrency limiter to cap parallel async operations. */
@@ -350,8 +350,7 @@ function resolveBlobRefsInEntries(entries, blobStore) {
350
350
  }
351
351
  }
352
352
  }
353
- /** Exported for testing */
354
- export function loadEntriesFromFile(filePath) {
353
+ function loadEntriesFromFile(filePath) {
355
354
  if (!existsSync(filePath))
356
355
  return [];
357
356
  const content = readFileSync(filePath, "utf8");
@@ -393,8 +392,7 @@ function isValidSessionFile(filePath) {
393
392
  return false;
394
393
  }
395
394
  }
396
- /** Exported for testing */
397
- export function findMostRecentSession(sessionDir) {
395
+ function findMostRecentSession(sessionDir) {
398
396
  try {
399
397
  const files = readdirSync(sessionDir)
400
398
  .filter((f) => f.endsWith(".jsonl"))
@@ -691,38 +689,13 @@ export class SessionManager {
691
689
  }
692
690
  }
693
691
  }
694
- acquireSessionLock(path) {
695
- const maxAttempts = 10;
696
- const delayMs = 20;
697
- let lastError;
698
- for (let attempt = 1; attempt <= maxAttempts; attempt++) {
699
- try {
700
- return lockfile.lockSync(path, { realpath: false });
701
- }
702
- catch (error) {
703
- const code = typeof error === "object" && error !== null && "code" in error
704
- ? String(error.code)
705
- : undefined;
706
- if (code !== "ELOCKED" || attempt === maxAttempts) {
707
- // Non-fatal: proceed without lock rather than losing data
708
- return undefined;
709
- }
710
- lastError = error;
711
- const start = Date.now();
712
- while (Date.now() - start < delayMs) {
713
- // Busy-wait to avoid async
714
- }
715
- }
716
- }
717
- return undefined;
718
- }
719
692
  _rewriteFile() {
720
693
  if (!this.persist || !this.sessionFile)
721
694
  return;
722
695
  const content = `${this.fileEntries.map((e) => JSON.stringify(e)).join("\n")}\n`;
723
696
  let release;
724
697
  try {
725
- release = this.acquireSessionLock(this.sessionFile);
698
+ release = tryAcquireLockSync(this.sessionFile);
726
699
  atomicWriteFileSync(this.sessionFile, content);
727
700
  }
728
701
  finally {
@@ -755,7 +728,7 @@ export class SessionManager {
755
728
  }
756
729
  let release;
757
730
  try {
758
- release = this.acquireSessionLock(this.sessionFile);
731
+ release = tryAcquireLockSync(this.sessionFile);
759
732
  if (!this.flushed) {
760
733
  for (const e of this.fileEntries) {
761
734
  const prepared = prepareForPersistence(e, this.blobStore);