@code-yeongyu/senpi 2026.7.31 → 2026.8.1

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 (491) hide show
  1. package/CHANGELOG.md +237 -0
  2. package/dist/core/agent-session.d.ts +49 -13
  3. package/dist/core/agent-session.d.ts.map +1 -1
  4. package/dist/core/agent-session.js +120 -37
  5. package/dist/core/agent-session.js.map +1 -1
  6. package/dist/core/dynamic-prompt/build.d.ts.map +1 -1
  7. package/dist/core/dynamic-prompt/build.js +4 -0
  8. package/dist/core/dynamic-prompt/build.js.map +1 -1
  9. package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/account-command.d.ts +2 -2
  10. package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/account-command.d.ts.map +1 -1
  11. package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/account-command.js +25 -25
  12. package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/account-command.js.map +1 -1
  13. package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/account-events.d.ts.map +1 -1
  14. package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/account-events.js.map +1 -1
  15. package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/account-management.d.ts +1 -1
  16. package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/account-management.d.ts.map +1 -1
  17. package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/account-management.js +2 -2
  18. package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/account-management.js.map +1 -1
  19. package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/accounts.d.ts +9 -9
  20. package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/accounts.d.ts.map +1 -1
  21. package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/accounts.js +2 -2
  22. package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/accounts.js.map +1 -1
  23. package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/affinity.d.ts +1 -1
  24. package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/affinity.d.ts.map +1 -1
  25. package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/affinity.js +3 -3
  26. package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/affinity.js.map +1 -1
  27. package/dist/core/extensions/builtin/claude-sdk-oauth/auth-attempt.d.ts +21 -0
  28. package/dist/core/extensions/builtin/claude-sdk-oauth/auth-attempt.d.ts.map +1 -0
  29. package/dist/core/extensions/builtin/claude-sdk-oauth/auth-attempt.js +30 -0
  30. package/dist/core/extensions/builtin/claude-sdk-oauth/auth-attempt.js.map +1 -0
  31. package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/auth-lane.d.ts +8 -4
  32. package/dist/core/extensions/builtin/claude-sdk-oauth/auth-lane.d.ts.map +1 -0
  33. package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/auth-lane.js +34 -25
  34. package/dist/core/extensions/builtin/claude-sdk-oauth/auth-lane.js.map +1 -0
  35. package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/custom-tools-schema.d.ts.map +1 -1
  36. package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/custom-tools-schema.js.map +1 -1
  37. package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/custom-tools.d.ts.map +1 -1
  38. package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/custom-tools.js.map +1 -1
  39. package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/errors.d.ts +1 -1
  40. package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/errors.d.ts.map +1 -1
  41. package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/errors.js +1 -1
  42. package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/errors.js.map +1 -1
  43. package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/executable.d.ts.map +1 -1
  44. package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/executable.js.map +1 -1
  45. package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/failover.d.ts.map +1 -1
  46. package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/failover.js +1 -1
  47. package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/failover.js.map +1 -1
  48. package/dist/core/extensions/builtin/claude-sdk-oauth/guidance.d.ts +14 -0
  49. package/dist/core/extensions/builtin/claude-sdk-oauth/guidance.d.ts.map +1 -0
  50. package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/guidance.js +37 -1
  51. package/dist/core/extensions/builtin/claude-sdk-oauth/guidance.js.map +1 -0
  52. package/dist/core/extensions/builtin/claude-sdk-oauth/index.d.ts +4 -0
  53. package/dist/core/extensions/builtin/claude-sdk-oauth/index.d.ts.map +1 -0
  54. package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/index.js +12 -10
  55. package/dist/core/extensions/builtin/claude-sdk-oauth/index.js.map +1 -0
  56. package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/oauth-login.d.ts +3 -3
  57. package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/oauth-login.d.ts.map +1 -1
  58. package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/oauth-login.js +2 -2
  59. package/dist/core/extensions/builtin/claude-sdk-oauth/oauth-login.js.map +1 -0
  60. package/dist/core/extensions/builtin/claude-sdk-oauth/options.d.ts +18 -0
  61. package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/options.d.ts.map +1 -1
  62. package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/options.js +70 -10
  63. package/dist/core/extensions/builtin/claude-sdk-oauth/options.js.map +1 -0
  64. package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/prompt-bridge.d.ts.map +1 -1
  65. package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/prompt-bridge.js +32 -19
  66. package/dist/core/extensions/builtin/claude-sdk-oauth/prompt-bridge.js.map +1 -0
  67. package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/sdk-boundary.d.ts +1 -0
  68. package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/sdk-boundary.d.ts.map +1 -1
  69. package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/sdk-boundary.js.map +1 -1
  70. package/dist/core/extensions/builtin/claude-sdk-oauth/session-registry-pump.d.ts +30 -0
  71. package/dist/core/extensions/builtin/claude-sdk-oauth/session-registry-pump.d.ts.map +1 -0
  72. package/dist/core/extensions/builtin/claude-sdk-oauth/session-registry-pump.js +197 -0
  73. package/dist/core/extensions/builtin/claude-sdk-oauth/session-registry-pump.js.map +1 -0
  74. package/dist/core/extensions/builtin/claude-sdk-oauth/session-registry-state.d.ts +18 -0
  75. package/dist/core/extensions/builtin/claude-sdk-oauth/session-registry-state.d.ts.map +1 -0
  76. package/dist/core/extensions/builtin/claude-sdk-oauth/session-registry-state.js +33 -0
  77. package/dist/core/extensions/builtin/claude-sdk-oauth/session-registry-state.js.map +1 -0
  78. package/dist/core/extensions/builtin/claude-sdk-oauth/session-registry-wiring.d.ts +3 -0
  79. package/dist/core/extensions/builtin/claude-sdk-oauth/session-registry-wiring.d.ts.map +1 -0
  80. package/dist/core/extensions/builtin/claude-sdk-oauth/session-registry-wiring.js +134 -0
  81. package/dist/core/extensions/builtin/claude-sdk-oauth/session-registry-wiring.js.map +1 -0
  82. package/dist/core/extensions/builtin/claude-sdk-oauth/session-registry.d.ts +85 -0
  83. package/dist/core/extensions/builtin/claude-sdk-oauth/session-registry.d.ts.map +1 -0
  84. package/dist/core/extensions/builtin/claude-sdk-oauth/session-registry.js +270 -0
  85. package/dist/core/extensions/builtin/claude-sdk-oauth/session-registry.js.map +1 -0
  86. package/dist/core/extensions/builtin/claude-sdk-oauth/session-stream.d.ts +17 -0
  87. package/dist/core/extensions/builtin/claude-sdk-oauth/session-stream.d.ts.map +1 -0
  88. package/dist/core/extensions/builtin/claude-sdk-oauth/session-stream.js +217 -0
  89. package/dist/core/extensions/builtin/claude-sdk-oauth/session-stream.js.map +1 -0
  90. package/dist/core/extensions/builtin/claude-sdk-oauth/session-sync.d.ts +49 -0
  91. package/dist/core/extensions/builtin/claude-sdk-oauth/session-sync.d.ts.map +1 -0
  92. package/dist/core/extensions/builtin/claude-sdk-oauth/session-sync.js +204 -0
  93. package/dist/core/extensions/builtin/claude-sdk-oauth/session-sync.js.map +1 -0
  94. package/dist/core/extensions/builtin/claude-sdk-oauth/settings.d.ts +28 -0
  95. package/dist/core/extensions/builtin/claude-sdk-oauth/settings.d.ts.map +1 -0
  96. package/dist/core/extensions/builtin/claude-sdk-oauth/settings.js +107 -0
  97. package/dist/core/extensions/builtin/claude-sdk-oauth/settings.js.map +1 -0
  98. package/dist/core/extensions/builtin/claude-sdk-oauth/stream-guidance.d.ts +2 -0
  99. package/dist/core/extensions/builtin/claude-sdk-oauth/stream-guidance.d.ts.map +1 -0
  100. package/dist/core/extensions/builtin/claude-sdk-oauth/stream-guidance.js +10 -0
  101. package/dist/core/extensions/builtin/claude-sdk-oauth/stream-guidance.js.map +1 -0
  102. package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/stream-protocol.d.ts.map +1 -1
  103. package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/stream-protocol.js.map +1 -1
  104. package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/stream.d.ts +1 -1
  105. package/dist/core/extensions/builtin/claude-sdk-oauth/stream.d.ts.map +1 -0
  106. package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/stream.js +72 -53
  107. package/dist/core/extensions/builtin/claude-sdk-oauth/stream.js.map +1 -0
  108. package/dist/core/extensions/builtin/claude-sdk-oauth/system-prompt.d.ts +3 -0
  109. package/dist/core/extensions/builtin/claude-sdk-oauth/system-prompt.d.ts.map +1 -0
  110. package/dist/core/extensions/builtin/claude-sdk-oauth/system-prompt.js +25 -0
  111. package/dist/core/extensions/builtin/claude-sdk-oauth/system-prompt.js.map +1 -0
  112. package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/tool-watch.d.ts +1 -1
  113. package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/tool-watch.d.ts.map +1 -1
  114. package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/tool-watch.js +2 -2
  115. package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/tool-watch.js.map +1 -1
  116. package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/tools.d.ts.map +1 -1
  117. package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/tools.js.map +1 -1
  118. package/dist/core/extensions/builtin/compaction/deterministic-fallback.d.ts +18 -0
  119. package/dist/core/extensions/builtin/compaction/deterministic-fallback.d.ts.map +1 -0
  120. package/dist/core/extensions/builtin/compaction/deterministic-fallback.js +69 -0
  121. package/dist/core/extensions/builtin/compaction/deterministic-fallback.js.map +1 -0
  122. package/dist/core/extensions/builtin/compaction/index.d.ts.map +1 -1
  123. package/dist/core/extensions/builtin/compaction/index.js +28 -2
  124. package/dist/core/extensions/builtin/compaction/index.js.map +1 -1
  125. package/dist/core/extensions/builtin/compaction/speculative.d.ts +4 -1
  126. package/dist/core/extensions/builtin/compaction/speculative.d.ts.map +1 -1
  127. package/dist/core/extensions/builtin/compaction/speculative.js +22 -17
  128. package/dist/core/extensions/builtin/compaction/speculative.js.map +1 -1
  129. package/dist/core/extensions/builtin/compaction/task-intent.d.ts +2 -6
  130. package/dist/core/extensions/builtin/compaction/task-intent.d.ts.map +1 -1
  131. package/dist/core/extensions/builtin/compaction/task-intent.js +10 -9
  132. package/dist/core/extensions/builtin/compaction/task-intent.js.map +1 -1
  133. package/dist/core/extensions/builtin/goal/continuation-recovery.d.ts +6 -0
  134. package/dist/core/extensions/builtin/goal/continuation-recovery.d.ts.map +1 -0
  135. package/dist/core/extensions/builtin/goal/continuation-recovery.js +20 -0
  136. package/dist/core/extensions/builtin/goal/continuation-recovery.js.map +1 -0
  137. package/dist/core/extensions/builtin/goal/continuation.d.ts +2 -4
  138. package/dist/core/extensions/builtin/goal/continuation.d.ts.map +1 -1
  139. package/dist/core/extensions/builtin/goal/continuation.js +2 -8
  140. package/dist/core/extensions/builtin/goal/continuation.js.map +1 -1
  141. package/dist/core/extensions/builtin/goal/direct-input-lifecycle.d.ts +19 -0
  142. package/dist/core/extensions/builtin/goal/direct-input-lifecycle.d.ts.map +1 -0
  143. package/dist/core/extensions/builtin/goal/direct-input-lifecycle.js +48 -0
  144. package/dist/core/extensions/builtin/goal/direct-input-lifecycle.js.map +1 -0
  145. package/dist/core/extensions/builtin/goal/index.d.ts.map +1 -1
  146. package/dist/core/extensions/builtin/goal/index.js +17 -15
  147. package/dist/core/extensions/builtin/goal/index.js.map +1 -1
  148. package/dist/core/extensions/builtin/goal/lifecycle-helpers.d.ts.map +1 -1
  149. package/dist/core/extensions/builtin/goal/lifecycle-helpers.js +12 -10
  150. package/dist/core/extensions/builtin/goal/lifecycle-helpers.js.map +1 -1
  151. package/dist/core/extensions/builtin/goal/monitor-continuation.d.ts +5 -1
  152. package/dist/core/extensions/builtin/goal/monitor-continuation.d.ts.map +1 -1
  153. package/dist/core/extensions/builtin/goal/monitor-continuation.js +94 -52
  154. package/dist/core/extensions/builtin/goal/monitor-continuation.js.map +1 -1
  155. package/dist/core/extensions/builtin/goal/persistence.d.ts +16 -0
  156. package/dist/core/extensions/builtin/goal/persistence.d.ts.map +1 -1
  157. package/dist/core/extensions/builtin/goal/persistence.js +185 -11
  158. package/dist/core/extensions/builtin/goal/persistence.js.map +1 -1
  159. package/dist/core/extensions/builtin/goal/ui.d.ts +1 -0
  160. package/dist/core/extensions/builtin/goal/ui.d.ts.map +1 -1
  161. package/dist/core/extensions/builtin/goal/ui.js +11 -2
  162. package/dist/core/extensions/builtin/goal/ui.js.map +1 -1
  163. package/dist/core/extensions/builtin/gpt-apply-patch/extension.d.ts.map +1 -1
  164. package/dist/core/extensions/builtin/gpt-apply-patch/extension.js +15 -0
  165. package/dist/core/extensions/builtin/gpt-apply-patch/extension.js.map +1 -1
  166. package/dist/core/extensions/builtin/gpt-apply-patch/tool.d.ts.map +1 -1
  167. package/dist/core/extensions/builtin/gpt-apply-patch/tool.js +30 -3
  168. package/dist/core/extensions/builtin/gpt-apply-patch/tool.js.map +1 -1
  169. package/dist/core/extensions/builtin/index.d.ts.map +1 -1
  170. package/dist/core/extensions/builtin/index.js +5 -2
  171. package/dist/core/extensions/builtin/index.js.map +1 -1
  172. package/dist/core/extensions/builtin/loop-guard/detectors.d.ts +31 -0
  173. package/dist/core/extensions/builtin/loop-guard/detectors.d.ts.map +1 -0
  174. package/dist/core/extensions/builtin/loop-guard/detectors.js +111 -0
  175. package/dist/core/extensions/builtin/loop-guard/detectors.js.map +1 -0
  176. package/dist/core/extensions/builtin/loop-guard/index.d.ts +3 -0
  177. package/dist/core/extensions/builtin/loop-guard/index.d.ts.map +1 -0
  178. package/dist/core/extensions/builtin/loop-guard/index.js +31 -0
  179. package/dist/core/extensions/builtin/loop-guard/index.js.map +1 -0
  180. package/dist/core/extensions/builtin/loop-guard/notice.d.ts +5 -0
  181. package/dist/core/extensions/builtin/loop-guard/notice.d.ts.map +1 -0
  182. package/dist/core/extensions/builtin/loop-guard/notice.js +42 -0
  183. package/dist/core/extensions/builtin/loop-guard/notice.js.map +1 -0
  184. package/dist/core/extensions/builtin/loop-guard/policy.d.ts +30 -0
  185. package/dist/core/extensions/builtin/loop-guard/policy.d.ts.map +1 -0
  186. package/dist/core/extensions/builtin/loop-guard/policy.js +30 -0
  187. package/dist/core/extensions/builtin/loop-guard/policy.js.map +1 -0
  188. package/dist/core/extensions/builtin/loop-guard/renderer.d.ts +4 -0
  189. package/dist/core/extensions/builtin/loop-guard/renderer.d.ts.map +1 -0
  190. package/dist/core/extensions/builtin/loop-guard/renderer.js +50 -0
  191. package/dist/core/extensions/builtin/loop-guard/renderer.js.map +1 -0
  192. package/dist/core/extensions/builtin/loop-guard/similarity.d.ts +13 -0
  193. package/dist/core/extensions/builtin/loop-guard/similarity.d.ts.map +1 -0
  194. package/dist/core/extensions/builtin/loop-guard/similarity.js +51 -0
  195. package/dist/core/extensions/builtin/loop-guard/similarity.js.map +1 -0
  196. package/dist/core/extensions/builtin/loop-guard/tracker.d.ts +13 -0
  197. package/dist/core/extensions/builtin/loop-guard/tracker.d.ts.map +1 -0
  198. package/dist/core/extensions/builtin/loop-guard/tracker.js +39 -0
  199. package/dist/core/extensions/builtin/loop-guard/tracker.js.map +1 -0
  200. package/dist/core/extensions/builtin/monitor-state-event.d.ts +10 -0
  201. package/dist/core/extensions/builtin/monitor-state-event.d.ts.map +1 -1
  202. package/dist/core/extensions/builtin/monitor-state-event.js.map +1 -1
  203. package/dist/core/extensions/builtin/prompt-preset/deepseek-v4-flash-0731.d.ts +3 -0
  204. package/dist/core/extensions/builtin/prompt-preset/deepseek-v4-flash-0731.d.ts.map +1 -0
  205. package/dist/core/extensions/builtin/prompt-preset/deepseek-v4-flash-0731.js +10 -0
  206. package/dist/core/extensions/builtin/prompt-preset/deepseek-v4-flash-0731.js.map +1 -0
  207. package/dist/core/extensions/builtin/prompt-preset/deepseek-v4-flash.d.ts +3 -0
  208. package/dist/core/extensions/builtin/prompt-preset/deepseek-v4-flash.d.ts.map +1 -0
  209. package/dist/core/extensions/builtin/prompt-preset/deepseek-v4-flash.js +10 -0
  210. package/dist/core/extensions/builtin/prompt-preset/deepseek-v4-flash.js.map +1 -0
  211. package/dist/core/extensions/builtin/prompt-preset/deepseek-v4-pro.d.ts +3 -0
  212. package/dist/core/extensions/builtin/prompt-preset/deepseek-v4-pro.d.ts.map +1 -0
  213. package/dist/core/extensions/builtin/prompt-preset/deepseek-v4-pro.js +11 -0
  214. package/dist/core/extensions/builtin/prompt-preset/deepseek-v4-pro.js.map +1 -0
  215. package/dist/core/extensions/builtin/prompt-preset/deepseek-v4.d.ts +13 -0
  216. package/dist/core/extensions/builtin/prompt-preset/deepseek-v4.d.ts.map +1 -0
  217. package/dist/core/extensions/builtin/prompt-preset/deepseek-v4.js +60 -0
  218. package/dist/core/extensions/builtin/prompt-preset/deepseek-v4.js.map +1 -0
  219. package/dist/core/extensions/builtin/prompt-preset/index.d.ts.map +1 -1
  220. package/dist/core/extensions/builtin/prompt-preset/index.js +8 -4
  221. package/dist/core/extensions/builtin/prompt-preset/index.js.map +1 -1
  222. package/dist/core/extensions/builtin/prompt-preset/presets.d.ts.map +1 -1
  223. package/dist/core/extensions/builtin/prompt-preset/presets.js +42 -0
  224. package/dist/core/extensions/builtin/prompt-preset/presets.js.map +1 -1
  225. package/dist/core/extensions/builtin/prompt-preset/settings.d.ts +1 -1
  226. package/dist/core/extensions/builtin/prompt-preset/settings.d.ts.map +1 -1
  227. package/dist/core/extensions/builtin/prompt-preset/settings.js +3 -0
  228. package/dist/core/extensions/builtin/prompt-preset/settings.js.map +1 -1
  229. package/dist/core/extensions/builtin/recommended-models/index.d.ts.map +1 -1
  230. package/dist/core/extensions/builtin/recommended-models/index.js +2 -1
  231. package/dist/core/extensions/builtin/recommended-models/index.js.map +1 -1
  232. package/dist/core/extensions/builtin/rules/index.js +4 -3
  233. package/dist/core/extensions/builtin/rules/index.js.map +1 -1
  234. package/dist/core/extensions/builtin/rules/rules/constants.d.ts +11 -0
  235. package/dist/core/extensions/builtin/rules/rules/constants.d.ts.map +1 -1
  236. package/dist/core/extensions/builtin/rules/rules/constants.js +11 -0
  237. package/dist/core/extensions/builtin/rules/rules/constants.js.map +1 -1
  238. package/dist/core/extensions/builtin/rules/rules/formatter.d.ts.map +1 -1
  239. package/dist/core/extensions/builtin/rules/rules/formatter.js +15 -1
  240. package/dist/core/extensions/builtin/rules/rules/formatter.js.map +1 -1
  241. package/dist/core/extensions/builtin/service-tier.d.ts.map +1 -1
  242. package/dist/core/extensions/builtin/service-tier.js +23 -21
  243. package/dist/core/extensions/builtin/service-tier.js.map +1 -1
  244. package/dist/core/extensions/builtin/terminal/extension.d.ts.map +1 -1
  245. package/dist/core/extensions/builtin/terminal/extension.js +21 -7
  246. package/dist/core/extensions/builtin/terminal/extension.js.map +1 -1
  247. package/dist/core/extensions/builtin/terminal/monitor-notify.d.ts.map +1 -1
  248. package/dist/core/extensions/builtin/terminal/monitor-notify.js +42 -5
  249. package/dist/core/extensions/builtin/terminal/monitor-notify.js.map +1 -1
  250. package/dist/core/extensions/builtin/terminal/monitor-registry.d.ts +2 -0
  251. package/dist/core/extensions/builtin/terminal/monitor-registry.d.ts.map +1 -1
  252. package/dist/core/extensions/builtin/terminal/monitor-registry.js +2 -0
  253. package/dist/core/extensions/builtin/terminal/monitor-registry.js.map +1 -1
  254. package/dist/core/extensions/builtin/terminal/monitor-status-ticker.d.ts +37 -0
  255. package/dist/core/extensions/builtin/terminal/monitor-status-ticker.d.ts.map +1 -0
  256. package/dist/core/extensions/builtin/terminal/monitor-status-ticker.js +61 -0
  257. package/dist/core/extensions/builtin/terminal/monitor-status-ticker.js.map +1 -0
  258. package/dist/core/extensions/builtin/terminal/monitor-status.d.ts +9 -1
  259. package/dist/core/extensions/builtin/terminal/monitor-status.d.ts.map +1 -1
  260. package/dist/core/extensions/builtin/terminal/monitor-status.js +35 -2
  261. package/dist/core/extensions/builtin/terminal/monitor-status.js.map +1 -1
  262. package/dist/core/extensions/builtin/terminal/tools/monitor.js +1 -1
  263. package/dist/core/extensions/builtin/terminal/tools/monitor.js.map +1 -1
  264. package/dist/core/extensions/builtin/todotools/commands.d.ts +2 -2
  265. package/dist/core/extensions/builtin/todotools/commands.d.ts.map +1 -1
  266. package/dist/core/extensions/builtin/todotools/commands.js.map +1 -1
  267. package/dist/core/extensions/builtin/todotools/index.d.ts.map +1 -1
  268. package/dist/core/extensions/builtin/todotools/index.js +6 -3
  269. package/dist/core/extensions/builtin/todotools/index.js.map +1 -1
  270. package/dist/core/extensions/builtin/todotools/state.d.ts +1 -1
  271. package/dist/core/extensions/builtin/todotools/state.d.ts.map +1 -1
  272. package/dist/core/extensions/builtin/todotools/state.js +1 -1
  273. package/dist/core/extensions/builtin/todotools/state.js.map +1 -1
  274. package/dist/core/extensions/builtin/todotools/todo-widget-component.d.ts +19 -0
  275. package/dist/core/extensions/builtin/todotools/todo-widget-component.d.ts.map +1 -0
  276. package/dist/core/extensions/builtin/todotools/todo-widget-component.js +78 -0
  277. package/dist/core/extensions/builtin/todotools/todo-widget-component.js.map +1 -0
  278. package/dist/core/extensions/builtin/todotools/todo-widget.d.ts +13 -1
  279. package/dist/core/extensions/builtin/todotools/todo-widget.d.ts.map +1 -1
  280. package/dist/core/extensions/builtin/todotools/todo-widget.js +32 -14
  281. package/dist/core/extensions/builtin/todotools/todo-widget.js.map +1 -1
  282. package/dist/core/extensions/builtin/todotools/tools/todo.d.ts +2 -2
  283. package/dist/core/extensions/builtin/todotools/tools/todo.d.ts.map +1 -1
  284. package/dist/core/extensions/builtin/todotools/tools/todo.js +1 -1
  285. package/dist/core/extensions/builtin/todotools/tools/todo.js.map +1 -1
  286. package/dist/core/extensions/builtin/tool-pair-guard/sanitize-anthropic-payload.d.ts +1 -1
  287. package/dist/core/extensions/builtin/tool-pair-guard/sanitize-anthropic-payload.d.ts.map +1 -1
  288. package/dist/core/extensions/builtin/tool-pair-guard/sanitize-anthropic-payload.js +88 -29
  289. package/dist/core/extensions/builtin/tool-pair-guard/sanitize-anthropic-payload.js.map +1 -1
  290. package/dist/core/extensions/builtin/tps.d.ts.map +1 -1
  291. package/dist/core/extensions/builtin/tps.js +5 -2
  292. package/dist/core/extensions/builtin/tps.js.map +1 -1
  293. package/dist/core/extensions/builtin/ttsr/builtin-rules.d.ts +4 -0
  294. package/dist/core/extensions/builtin/ttsr/builtin-rules.d.ts.map +1 -0
  295. package/dist/core/extensions/builtin/ttsr/builtin-rules.js +20 -0
  296. package/dist/core/extensions/builtin/ttsr/builtin-rules.js.map +1 -0
  297. package/dist/core/extensions/builtin/ttsr/commands.js +9 -1
  298. package/dist/core/extensions/builtin/ttsr/commands.js.map +1 -1
  299. package/dist/core/extensions/builtin/ttsr/index.d.ts.map +1 -1
  300. package/dist/core/extensions/builtin/ttsr/index.js +4 -3
  301. package/dist/core/extensions/builtin/ttsr/index.js.map +1 -1
  302. package/dist/core/extensions/builtin/ttsr/manager.js +1 -1
  303. package/dist/core/extensions/builtin/ttsr/manager.js.map +1 -1
  304. package/dist/core/extensions/builtin/websearch/websearch/config.d.ts.map +1 -1
  305. package/dist/core/extensions/builtin/websearch/websearch/config.js +1 -0
  306. package/dist/core/extensions/builtin/websearch/websearch/config.js.map +1 -1
  307. package/dist/core/extensions/builtin/websearch/websearch/native.d.ts.map +1 -1
  308. package/dist/core/extensions/builtin/websearch/websearch/native.js +16 -5
  309. package/dist/core/extensions/builtin/websearch/websearch/native.js.map +1 -1
  310. package/dist/core/extensions/builtin/websearch/websearch/provider-endpoints.d.ts.map +1 -1
  311. package/dist/core/extensions/builtin/websearch/websearch/provider-endpoints.js +1 -0
  312. package/dist/core/extensions/builtin/websearch/websearch/provider-endpoints.js.map +1 -1
  313. package/dist/core/extensions/builtin/websearch/websearch/providers/anthropic.d.ts +4 -1
  314. package/dist/core/extensions/builtin/websearch/websearch/providers/anthropic.d.ts.map +1 -1
  315. package/dist/core/extensions/builtin/websearch/websearch/providers/anthropic.js +44 -37
  316. package/dist/core/extensions/builtin/websearch/websearch/providers/anthropic.js.map +1 -1
  317. package/dist/core/extensions/builtin/websearch/websearch/providers/deepseek.d.ts +3 -0
  318. package/dist/core/extensions/builtin/websearch/websearch/providers/deepseek.d.ts.map +1 -0
  319. package/dist/core/extensions/builtin/websearch/websearch/providers/deepseek.js +12 -0
  320. package/dist/core/extensions/builtin/websearch/websearch/providers/deepseek.js.map +1 -0
  321. package/dist/core/extensions/builtin/websearch/websearch/providers.d.ts.map +1 -1
  322. package/dist/core/extensions/builtin/websearch/websearch/providers.js +2 -0
  323. package/dist/core/extensions/builtin/websearch/websearch/providers.js.map +1 -1
  324. package/dist/core/extensions/builtin/websearch/websearch/renderers.d.ts.map +1 -1
  325. package/dist/core/extensions/builtin/websearch/websearch/renderers.js +3 -3
  326. package/dist/core/extensions/builtin/websearch/websearch/renderers.js.map +1 -1
  327. package/dist/core/extensions/builtin/websearch/websearch/search.d.ts.map +1 -1
  328. package/dist/core/extensions/builtin/websearch/websearch/search.js +1 -3
  329. package/dist/core/extensions/builtin/websearch/websearch/search.js.map +1 -1
  330. package/dist/core/extensions/builtin/websearch/websearch/tool.js +2 -2
  331. package/dist/core/extensions/builtin/websearch/websearch/tool.js.map +1 -1
  332. package/dist/core/extensions/builtin/websearch/websearch/types.d.ts +1 -1
  333. package/dist/core/extensions/builtin/websearch/websearch/types.d.ts.map +1 -1
  334. package/dist/core/extensions/builtin/websearch/websearch/types.js.map +1 -1
  335. package/dist/core/extensions/index.d.ts +1 -1
  336. package/dist/core/extensions/index.d.ts.map +1 -1
  337. package/dist/core/extensions/index.js.map +1 -1
  338. package/dist/core/extensions/loader.d.ts.map +1 -1
  339. package/dist/core/extensions/loader.js +5 -0
  340. package/dist/core/extensions/loader.js.map +1 -1
  341. package/dist/core/extensions/runner.d.ts +1 -1
  342. package/dist/core/extensions/runner.d.ts.map +1 -1
  343. package/dist/core/extensions/runner.js +3 -1
  344. package/dist/core/extensions/runner.js.map +1 -1
  345. package/dist/core/extensions/types.d.ts +22 -1
  346. package/dist/core/extensions/types.d.ts.map +1 -1
  347. package/dist/core/extensions/types.js.map +1 -1
  348. package/dist/core/model-resolver.js +2 -2
  349. package/dist/core/model-resolver.js.map +1 -1
  350. package/dist/core/thinking-levels.d.ts +5 -0
  351. package/dist/core/thinking-levels.d.ts.map +1 -1
  352. package/dist/core/thinking-levels.js +9 -39
  353. package/dist/core/thinking-levels.js.map +1 -1
  354. package/dist/index.d.ts +1 -1
  355. package/dist/index.d.ts.map +1 -1
  356. package/dist/index.js.map +1 -1
  357. package/dist/modes/app-server/server/account.d.ts +1 -1
  358. package/dist/modes/app-server/server/account.js +1 -1
  359. package/dist/modes/app-server/server/account.js.map +1 -1
  360. package/dist/modes/app-server/server/server-core.js +1 -1
  361. package/dist/modes/app-server/server/server-core.js.map +1 -1
  362. package/dist/modes/interactive/compaction-queue-transfer.d.ts +2 -0
  363. package/dist/modes/interactive/compaction-queue-transfer.d.ts.map +1 -1
  364. package/dist/modes/interactive/compaction-queue-transfer.js.map +1 -1
  365. package/dist/modes/interactive/components/footer.d.ts.map +1 -1
  366. package/dist/modes/interactive/components/footer.js +9 -5
  367. package/dist/modes/interactive/components/footer.js.map +1 -1
  368. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  369. package/dist/modes/interactive/interactive-mode.js +38 -12
  370. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  371. package/dist/modes/interactive/risky-main-model-warning.d.ts +1 -1
  372. package/dist/modes/interactive/risky-main-model-warning.d.ts.map +1 -1
  373. package/dist/modes/interactive/risky-main-model-warning.js +1 -1
  374. package/dist/modes/interactive/risky-main-model-warning.js.map +1 -1
  375. package/dist/modes/rpc/connection-handler.js +3 -3
  376. package/dist/modes/rpc/connection-handler.js.map +1 -1
  377. package/docs/extensions.md +10 -0
  378. package/docs/providers.md +21 -5
  379. package/docs/release-guide.md +2 -2
  380. package/docs/settings.md +1 -1
  381. package/examples/extensions/overlay-test.ts +1 -1
  382. package/node_modules/@code-yeongyu/senpi-codemode/CHANGELOG.md +33 -0
  383. package/node_modules/@code-yeongyu/senpi-codemode/README.md +6 -3
  384. package/node_modules/@code-yeongyu/senpi-codemode/package.json +3 -3
  385. package/node_modules/@code-yeongyu/senpi-codemode/src/extension/eval-status-ticker.ts +79 -0
  386. package/node_modules/@code-yeongyu/senpi-codemode/src/extension/eval-status.ts +36 -3
  387. package/node_modules/@code-yeongyu/senpi-codemode/src/index.ts +26 -12
  388. package/node_modules/@code-yeongyu/senpi-codemode/src/tool/cell-execution.ts +146 -0
  389. package/node_modules/@code-yeongyu/senpi-codemode/src/tool/cell-handler.ts +21 -119
  390. package/node_modules/@code-yeongyu/senpi-codemode/src/tool/cell-runtime.ts +157 -0
  391. package/node_modules/@code-yeongyu/senpi-codemode/src/tool/detached-cell-manager.ts +62 -208
  392. package/node_modules/@code-yeongyu/senpi-codemode/src/tool/detached-cell-notification.ts +98 -0
  393. package/node_modules/@code-yeongyu/senpi-codemode/src/tool/detached-cell-snapshot.ts +81 -0
  394. package/node_modules/@code-yeongyu/senpi-codemode/src/tool/detached-cell-state.ts +24 -0
  395. package/node_modules/@code-yeongyu/senpi-codemode/src/tool/detached-eval-result.ts +140 -0
  396. package/node_modules/@code-yeongyu/senpi-codemode/src/tool/detached-notification-queue.ts +53 -0
  397. package/node_modules/@code-yeongyu/senpi-codemode/src/tool/eval-request.ts +45 -0
  398. package/node_modules/@code-yeongyu/senpi-codemode/src/tool/eval-tool-options.ts +45 -0
  399. package/node_modules/@code-yeongyu/senpi-codemode/src/tool/eval-tool.ts +20 -342
  400. package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.d.ts.map +1 -1
  401. package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.js +1 -0
  402. package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.js.map +1 -1
  403. package/node_modules/@earendil-works/pi-agent-core/package.json +2 -2
  404. package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.d.ts.map +1 -1
  405. package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js +10 -15
  406. package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js.map +1 -1
  407. package/node_modules/@earendil-works/pi-ai/dist/api/azure-openai-responses.js +2 -2
  408. package/node_modules/@earendil-works/pi-ai/dist/api/azure-openai-responses.js.map +1 -1
  409. package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses/fallback-state.d.ts +24 -0
  410. package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses/fallback-state.d.ts.map +1 -0
  411. package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses/fallback-state.js +70 -0
  412. package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses/fallback-state.js.map +1 -0
  413. package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.d.ts +2 -16
  414. package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.d.ts.map +1 -1
  415. package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.js +10 -58
  416. package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.js.map +1 -1
  417. package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js +2 -2
  418. package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js.map +1 -1
  419. package/node_modules/@earendil-works/pi-ai/dist/api/openai-prompt-cache.d.ts +1 -0
  420. package/node_modules/@earendil-works/pi-ai/dist/api/openai-prompt-cache.d.ts.map +1 -1
  421. package/node_modules/@earendil-works/pi-ai/dist/api/openai-prompt-cache.js +7 -0
  422. package/node_modules/@earendil-works/pi-ai/dist/api/openai-prompt-cache.js.map +1 -1
  423. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.js +2 -2
  424. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.js.map +1 -1
  425. package/node_modules/@earendil-works/pi-ai/dist/model.d.ts +2 -1
  426. package/node_modules/@earendil-works/pi-ai/dist/model.d.ts.map +1 -1
  427. package/node_modules/@earendil-works/pi-ai/dist/model.js.map +1 -1
  428. package/node_modules/@earendil-works/pi-ai/dist/models.d.ts +14 -0
  429. package/node_modules/@earendil-works/pi-ai/dist/models.d.ts.map +1 -1
  430. package/node_modules/@earendil-works/pi-ai/dist/models.js +95 -19
  431. package/node_modules/@earendil-works/pi-ai/dist/models.js.map +1 -1
  432. package/node_modules/@earendil-works/pi-ai/dist/providers/data/.manifest.json +1 -1
  433. package/node_modules/@earendil-works/pi-ai/dist/providers/data/amazon-bedrock.json +1 -1
  434. package/node_modules/@earendil-works/pi-ai/dist/providers/data/azure-openai-responses.json +1 -1
  435. package/node_modules/@earendil-works/pi-ai/dist/providers/data/openai.json +1 -1
  436. package/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode-go.json +1 -1
  437. package/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode.json +1 -1
  438. package/node_modules/@earendil-works/pi-ai/dist/providers/data/openrouter.json +1 -1
  439. package/node_modules/@earendil-works/pi-ai/dist/providers/data/vercel-ai-gateway.json +1 -1
  440. package/node_modules/@earendil-works/pi-ai/dist/providers/data/zai-coding-cn.json +1 -1
  441. package/node_modules/@earendil-works/pi-ai/dist/providers/data/zai.json +1 -1
  442. package/node_modules/@earendil-works/pi-ai/dist/types.d.ts +5 -0
  443. package/node_modules/@earendil-works/pi-ai/dist/types.d.ts.map +1 -1
  444. package/node_modules/@earendil-works/pi-ai/dist/types.js.map +1 -1
  445. package/node_modules/@earendil-works/pi-ai/dist/utils/unavailable-tool-text.d.ts +3 -0
  446. package/node_modules/@earendil-works/pi-ai/dist/utils/unavailable-tool-text.d.ts.map +1 -0
  447. package/node_modules/@earendil-works/pi-ai/dist/utils/unavailable-tool-text.js +36 -0
  448. package/node_modules/@earendil-works/pi-ai/dist/utils/unavailable-tool-text.js.map +1 -0
  449. package/node_modules/@earendil-works/pi-ai/package.json +1 -1
  450. package/node_modules/@earendil-works/pi-pty/package.json +1 -1
  451. package/node_modules/@earendil-works/pi-tui/dist/mux.js +1 -1
  452. package/node_modules/@earendil-works/pi-tui/dist/mux.js.map +1 -1
  453. package/node_modules/@earendil-works/pi-tui/dist/tui.d.ts +1 -0
  454. package/node_modules/@earendil-works/pi-tui/dist/tui.d.ts.map +1 -1
  455. package/node_modules/@earendil-works/pi-tui/dist/tui.js +17 -3
  456. package/node_modules/@earendil-works/pi-tui/dist/tui.js.map +1 -1
  457. package/node_modules/@earendil-works/pi-tui/package.json +1 -1
  458. package/package.json +6 -6
  459. package/dist/core/extensions/builtin/claude-agent-sdk/auth-lane.d.ts.map +0 -1
  460. package/dist/core/extensions/builtin/claude-agent-sdk/auth-lane.js.map +0 -1
  461. package/dist/core/extensions/builtin/claude-agent-sdk/guidance.d.ts +0 -6
  462. package/dist/core/extensions/builtin/claude-agent-sdk/guidance.d.ts.map +0 -1
  463. package/dist/core/extensions/builtin/claude-agent-sdk/guidance.js.map +0 -1
  464. package/dist/core/extensions/builtin/claude-agent-sdk/index.d.ts +0 -4
  465. package/dist/core/extensions/builtin/claude-agent-sdk/index.d.ts.map +0 -1
  466. package/dist/core/extensions/builtin/claude-agent-sdk/index.js.map +0 -1
  467. package/dist/core/extensions/builtin/claude-agent-sdk/oauth-login.js.map +0 -1
  468. package/dist/core/extensions/builtin/claude-agent-sdk/options.d.ts +0 -16
  469. package/dist/core/extensions/builtin/claude-agent-sdk/options.js.map +0 -1
  470. package/dist/core/extensions/builtin/claude-agent-sdk/prompt-bridge.js.map +0 -1
  471. package/dist/core/extensions/builtin/claude-agent-sdk/settings.d.ts +0 -15
  472. package/dist/core/extensions/builtin/claude-agent-sdk/settings.d.ts.map +0 -1
  473. package/dist/core/extensions/builtin/claude-agent-sdk/settings.js +0 -41
  474. package/dist/core/extensions/builtin/claude-agent-sdk/settings.js.map +0 -1
  475. package/dist/core/extensions/builtin/claude-agent-sdk/stream.d.ts.map +0 -1
  476. package/dist/core/extensions/builtin/claude-agent-sdk/stream.js.map +0 -1
  477. /package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/account-events.d.ts +0 -0
  478. /package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/account-events.js +0 -0
  479. /package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/custom-tools-schema.d.ts +0 -0
  480. /package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/custom-tools-schema.js +0 -0
  481. /package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/custom-tools.d.ts +0 -0
  482. /package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/custom-tools.js +0 -0
  483. /package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/executable.d.ts +0 -0
  484. /package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/executable.js +0 -0
  485. /package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/failover.d.ts +0 -0
  486. /package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/prompt-bridge.d.ts +0 -0
  487. /package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/sdk-boundary.js +0 -0
  488. /package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/stream-protocol.d.ts +0 -0
  489. /package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/stream-protocol.js +0 -0
  490. /package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/tools.d.ts +0 -0
  491. /package/dist/core/extensions/builtin/{claude-agent-sdk → claude-sdk-oauth}/tools.js +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"tool.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/gpt-apply-patch/tool.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAKX,wBAAwB,EAGxB,MAAM,YAAY,CAAC;AAiDpB,wBAAgB,oBAAoB,CAAC,OAAO,GAAE,UAAU,GAAG,MAAmB,GAAG,wBAAwB,CA4FxG"}
1
+ {"version":3,"file":"tool.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/gpt-apply-patch/tool.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAKX,wBAAwB,EAGxB,MAAM,YAAY,CAAC;AA+EpB,wBAAgB,oBAAoB,CAAC,OAAO,GAAE,UAAU,GAAG,MAAmB,GAAG,wBAAwB,CA+FxG"}
@@ -35,13 +35,37 @@ function renderPreviewBox(title, details, isPartial, cwd, expanded, theme) {
35
35
  }
36
36
  function renderTextResult(result, theme) {
37
37
  const component = new Container();
38
- const text = result.content
38
+ const text = resultText(result);
39
+ if (text)
40
+ component.addChild(new Text(theme.fg("toolOutput", text), 0, 0));
41
+ return component;
42
+ }
43
+ function resultText(result) {
44
+ return result.content
39
45
  .filter((block) => block.type === "text")
40
46
  .map((block) => block.text)
41
47
  .filter((value) => typeof value === "string" && value.length > 0)
42
48
  .join("\n");
43
- if (text)
44
- component.addChild(new Text(theme.fg("toolOutput", text), 0, 0));
49
+ }
50
+ function renderFailureBox(result, cwd, expanded, theme) {
51
+ const patchResult = result.details?.result;
52
+ if (!patchResult)
53
+ return renderTextResult(result, theme);
54
+ const component = new Container();
55
+ const appliedCount = patchResult.appliedFiles.length;
56
+ const title = appliedCount > 0 ? "Patch partially failed" : "Patch failed";
57
+ const box = new Box(1, 1, (text) => theme.bg("toolErrorBg", text));
58
+ box.addChild(new Text(theme.fg("toolTitle", theme.bold(title)), 0, 0));
59
+ if (result.details.preview) {
60
+ box.addChild(new Spacer(1));
61
+ box.addChild(new Text(renderPatchPreview(result.details.preview, cwd, theme, expanded), 0, 0));
62
+ }
63
+ const text = resultText(result);
64
+ if (text) {
65
+ box.addChild(new Spacer(1));
66
+ box.addChild(new Text(theme.fg("toolOutput", text), 0, 0));
67
+ }
68
+ component.addChild(box);
45
69
  return component;
46
70
  }
47
71
  export function createApplyPatchTool(variant = "freeform") {
@@ -101,6 +125,9 @@ export function createApplyPatchTool(variant = "freeform") {
101
125
  return new Text(theme.fg("toolTitle", theme.bold(text)), 0, 0);
102
126
  },
103
127
  renderResult(result, options, theme, context) {
128
+ if (context.isError && result.details?.result?.failures.length) {
129
+ return renderFailureBox(result, context.cwd, true, theme);
130
+ }
104
131
  if (result.details?.preview) {
105
132
  const expanded = true;
106
133
  return renderPreviewBox(options.isPartial ? "Applying patch" : "Applied patch", result.details, options.isPartial, context.cwd, expanded, theme);
@@ -1 +1 @@
1
- {"version":3,"file":"tool.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/gpt-apply-patch/tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAEtE,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AACzE,OAAO,EACN,gCAAgC,EAChC,4BAA4B,EAC5B,wBAAwB,EACxB,kBAAkB,GAClB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,wBAAwB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACnF,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AAWjE,SAAS,cAAc,CAAC,MAAwB;IAC/C,MAAM,KAAK,GAAG,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC,iBAAiB,CAAC;SACjD,IAAI,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,cAAc,GAAG,KAAK,CAAC,cAAc,CAAC;SACjE,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IACxC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,SAAS,CAAC;IACzC,OAAO;QACN,KAAK;QACL,KAAK,EAAE,KAAK,CAAC,MAA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AAE,CAAC,WAAW,EAAE,KAAK,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;gBAClF,GAAG,CAAC,QAAQ,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;gBAC5B,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;oBAC5B,MAAM,QAAQ,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,IAAI,IAAI,CAAC,CAAC;oBACvE,GAAG,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,GAAG,EAAE,KAAK,EAAE,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;gBACxG,CAAC;gBACD,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;gBACxB,OAAO,SAAS,CAAC;YAClB,CAAC;YACD,OAAO,gBAAgB,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;QACxC,CAAC;KACD,CAAC,CAAC;IAEH,IAAI,OAAO,KAAK,MAAM;QAAE,OAAO,IAAI,CAAC;IACpC,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE;QAC1B,QAAQ,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,wBAAwB,EAA+B;KAChH,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { Box, Container, Spacer, Text } from \"@earendil-works/pi-tui\";\nimport type { AgentToolResult, ToolRenderContext } from \"../../types.ts\";\nimport { defineTool } from \"../../types.ts\";\nimport { applyPatchDetailed, buildPartialFailureText } from \"./apply.ts\";\nimport {\n\tAPPLY_PATCH_FREEFORM_DESCRIPTION,\n\tAPPLY_PATCH_JSON_DESCRIPTION,\n\tAPPLY_PATCH_LARK_GRAMMAR,\n\tAPPLY_PATCH_PARAMS,\n} from \"./constants.ts\";\nimport { normalizeApplyPatchArguments } from \"./params.ts\";\nimport { parsePatch } from \"./parser.ts\";\nimport { createPendingPatchUpdate } from \"./preview.ts\";\nimport { getApplyPatchRenderState, renderPatchPreview } from \"./preview-format.ts\";\nimport { renderStreamingPatchCall } from \"./streaming-render.ts\";\nimport type {\n\tApplyPatchPreview,\n\tApplyPatchRenderState,\n\tApplyPatchResult,\n\tApplyPatchTheme,\n\tApplyPatchToolDefinition,\n\tApplyPatchToolDetails,\n\tFreeformToolFormat,\n} from \"./types.ts\";\n\nfunction appliedPreview(result: ApplyPatchResult): ApplyPatchPreview | undefined {\n\tconst files = [...result.details.appliedOperations]\n\t\t.sort((left, right) => left.operationIndex - right.operationIndex)\n\t\t.map((operation) => operation.preview);\n\tif (files.length === 0) return undefined;\n\treturn {\n\t\tfiles,\n\t\tadded: files.reduce((total, file) => total + file.added, 0),\n\t\tremoved: files.reduce((total, file) => total + file.removed, 0),\n\t};\n}\n\nfunction renderPreviewBox(\n\ttitle: string,\n\tdetails: ApplyPatchToolDetails,\n\tisPartial: boolean,\n\tcwd: string,\n\texpanded: boolean,\n\ttheme: ApplyPatchTheme,\n): Container {\n\tconst component = new Container();\n\tif (!details.preview) return component;\n\tconst bgName = isPartial ? \"toolPendingBg\" : \"toolSuccessBg\";\n\tconst progress = details.progress;\n\tconst renderedTitle = progress ? `Applying patch (${progress.applied + progress.failed}/${progress.total})` : title;\n\tconst box = new Box(1, 1, (text: string) => theme.bg(bgName, text));\n\tbox.addChild(new Text(theme.fg(\"toolTitle\", theme.bold(renderedTitle)), 0, 0));\n\tbox.addChild(new Spacer(1));\n\tbox.addChild(new Text(renderPatchPreview(details.preview, cwd, theme, expanded), 0, 0));\n\tcomponent.addChild(box);\n\treturn component;\n}\n\nfunction renderTextResult(\n\tresult: AgentToolResult<ApplyPatchToolDetails | undefined>,\n\ttheme: ApplyPatchTheme,\n): Container {\n\tconst component = new Container();\n\tconst text = result.content\n\t\t.filter((block) => block.type === \"text\")\n\t\t.map((block) => block.text)\n\t\t.filter((value) => typeof value === \"string\" && value.length > 0)\n\t\t.join(\"\\n\");\n\tif (text) component.addChild(new Text(theme.fg(\"toolOutput\", text), 0, 0));\n\treturn component;\n}\n\nexport function createApplyPatchTool(variant: \"freeform\" | \"json\" = \"freeform\"): ApplyPatchToolDefinition {\n\tconst tool = defineTool<typeof APPLY_PATCH_PARAMS, ApplyPatchToolDetails | undefined, ApplyPatchRenderState>({\n\t\tname: \"apply_patch\",\n\t\tlabel: \"ApplyPatch\",\n\t\tdescription: variant === \"json\" ? APPLY_PATCH_JSON_DESCRIPTION : APPLY_PATCH_FREEFORM_DESCRIPTION,\n\t\tparameters: APPLY_PATCH_PARAMS,\n\t\tprepareArguments: normalizeApplyPatchArguments,\n\t\tpromptSnippet: \"Apply Codex-format file patches with apply_patch\",\n\t\tpromptGuidelines: [\n\t\t\t\"Use apply_patch for file edits instead of mutating files through bash, Python scripts, heredocs, or shell redirection.\",\n\t\t\t\"After apply_patch succeeds, do not re-read the edited files just to confirm the patch applied.\",\n\t\t],\n\t\tasync execute(\n\t\t\t_toolCallId,\n\t\t\tparams,\n\t\t\t_signal,\n\t\t\tonUpdate,\n\t\t\tctx,\n\t\t): Promise<AgentToolResult<ApplyPatchToolDetails | undefined>> {\n\t\t\tconst normalizedParams = normalizeApplyPatchArguments(params);\n\t\t\tif (!normalizedParams.input) throw new Error(\"input is required\");\n\t\t\tlet totalOperations = 0;\n\t\t\ttry {\n\t\t\t\ttotalOperations = parsePatch(normalizedParams.input).length;\n\t\t\t} catch {\n\t\t\t\t// createPendingPatchUpdate keeps incomplete or invalid patch text renderable.\n\t\t\t}\n\t\t\tconst initialProgress = totalOperations > 0 ? { applied: 0, failed: 0, total: totalOperations } : undefined;\n\t\t\tconst pendingUpdate = await createPendingPatchUpdate(ctx.cwd, normalizedParams.input, initialProgress);\n\t\t\tonUpdate?.({ content: [{ type: \"text\", text: pendingUpdate.text }], details: pendingUpdate.details });\n\t\t\tconst preview = pendingUpdate.details?.preview;\n\t\t\tconst result = await applyPatchDetailed(ctx.cwd, normalizedParams.input, async (progress) => {\n\t\t\t\tconst progressUpdate = await createPendingPatchUpdate(ctx.cwd, normalizedParams.input, progress, preview);\n\t\t\t\tonUpdate?.({ content: [{ type: \"text\", text: progressUpdate.text }], details: progressUpdate.details });\n\t\t\t});\n\t\t\tconst resultPreview = appliedPreview(result);\n\t\t\tif (result.failures.length > 0) {\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [{ type: \"text\", text: buildPartialFailureText(result) }],\n\t\t\t\t\tdetails: resultPreview ? { preview: resultPreview, result } : { result },\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tcontent: [{ type: \"text\", text: result.summaries.join(\"\\n\") }],\n\t\t\t\tdetails: resultPreview ? { preview: resultPreview, result } : { result },\n\t\t\t};\n\t\t},\n\t\trenderCall(args, theme, context: ToolRenderContext<ApplyPatchRenderState, { input: string }>) {\n\t\t\tif (!context.executionStarted) {\n\t\t\t\tconst streaming = renderStreamingPatchCall(normalizeApplyPatchArguments(args), theme, context.state);\n\t\t\t\tif (streaming) return streaming;\n\t\t\t}\n\t\t\tif (!context.argsComplete) return new Text(theme.fg(\"toolTitle\", theme.bold(\"apply_patch: Patching\")), 0, 0);\n\t\t\tconst normalizedArgs = normalizeApplyPatchArguments(args);\n\t\t\tconst renderState = getApplyPatchRenderState(context.toolCallId, context.cwd, normalizedArgs.input);\n\t\t\tconst text = renderState.callText?.length ? `apply_patch: ${renderState.callText}` : \"apply_patch\";\n\t\t\treturn new Text(theme.fg(\"toolTitle\", theme.bold(text)), 0, 0);\n\t\t},\n\t\trenderResult(result, options, theme, context) {\n\t\t\tif (result.details?.preview) {\n\t\t\t\tconst expanded = true;\n\t\t\t\treturn renderPreviewBox(\n\t\t\t\t\toptions.isPartial ? \"Applying patch\" : \"Applied patch\",\n\t\t\t\t\tresult.details,\n\t\t\t\t\toptions.isPartial,\n\t\t\t\t\tcontext.cwd,\n\t\t\t\t\texpanded,\n\t\t\t\t\ttheme,\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (result.details?.result) {\n\t\t\t\tconst component = new Container();\n\t\t\t\tconst box = new Box(1, 1, (text: string) =>\n\t\t\t\t\ttheme.bg(options.isPartial ? \"toolPendingBg\" : \"toolSuccessBg\", text),\n\t\t\t\t);\n\t\t\t\tbox.addChild(new Text(theme.fg(\"toolTitle\", theme.bold(\"Applying patch\")), 0, 0));\n\t\t\t\tbox.addChild(new Spacer(1));\n\t\t\t\tif (result.details.preview) {\n\t\t\t\t\tconst expanded = options.isPartial ? true : (options.expanded ?? true);\n\t\t\t\t\tbox.addChild(new Text(renderPatchPreview(result.details.preview, context.cwd, theme, expanded), 0, 0));\n\t\t\t\t}\n\t\t\t\tcomponent.addChild(box);\n\t\t\t\treturn component;\n\t\t\t}\n\t\t\treturn renderTextResult(result, theme);\n\t\t},\n\t});\n\n\tif (variant === \"json\") return tool;\n\treturn Object.assign(tool, {\n\t\tfreeform: { type: \"grammar\", syntax: \"lark\", definition: APPLY_PATCH_LARK_GRAMMAR } satisfies FreeformToolFormat,\n\t});\n}\n"]}
1
+ {"version":3,"file":"tool.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/gpt-apply-patch/tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAEtE,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AACzE,OAAO,EACN,gCAAgC,EAChC,4BAA4B,EAC5B,wBAAwB,EACxB,kBAAkB,GAClB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EAAE,UAAU,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AC,CAAC,CAAC;gBAClF,GAAG,CAAC,QAAQ,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;gBAC5B,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;oBAC5B,MAAM,QAAQ,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,IAAI,IAAI,CAAC,CAAC;oBACvE,GAAG,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,GAAG,EAAE,KAAK,EAAE,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;gBACxG,CAAC;gBACD,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;gBACxB,OAAO,SAAS,CAAC;YAClB,CAAC;YACD,OAAO,gBAAgB,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;QACxC,CAAC;KACD,CAAC,CAAC;IAEH,IAAI,OAAO,KAAK,MAAM;QAAE,OAAO,IAAI,CAAC;IACpC,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE;QAC1B,QAAQ,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,wBAAwB,EAA+B;KAChH,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { Box, Container, Spacer, Text } from \"@earendil-works/pi-tui\";\nimport type { AgentToolResult, ToolRenderContext } from \"../../types.ts\";\nimport { defineTool } from \"../../types.ts\";\nimport { applyPatchDetailed, buildPartialFailureText } from \"./apply.ts\";\nimport {\n\tAPPLY_PATCH_FREEFORM_DESCRIPTION,\n\tAPPLY_PATCH_JSON_DESCRIPTION,\n\tAPPLY_PATCH_LARK_GRAMMAR,\n\tAPPLY_PATCH_PARAMS,\n} from \"./constants.ts\";\nimport { normalizeApplyPatchArguments } from \"./params.ts\";\nimport { parsePatch } from \"./parser.ts\";\nimport { createPendingPatchUpdate } from \"./preview.ts\";\nimport { getApplyPatchRenderState, renderPatchPreview } from \"./preview-format.ts\";\nimport { renderStreamingPatchCall } from \"./streaming-render.ts\";\nimport type {\n\tApplyPatchPreview,\n\tApplyPatchRenderState,\n\tApplyPatchResult,\n\tApplyPatchTheme,\n\tApplyPatchToolDefinition,\n\tApplyPatchToolDetails,\n\tFreeformToolFormat,\n} from \"./types.ts\";\n\nfunction appliedPreview(result: ApplyPatchResult): ApplyPatchPreview | undefined {\n\tconst files = [...result.details.appliedOperations]\n\t\t.sort((left, right) => left.operationIndex - right.operationIndex)\n\t\t.map((operation) => operation.preview);\n\tif (files.length === 0) return undefined;\n\treturn {\n\t\tfiles,\n\t\tadded: files.reduce((total, file) => total + file.added, 0),\n\t\tremoved: files.reduce((total, file) => total + file.removed, 0),\n\t};\n}\n\nfunction renderPreviewBox(\n\ttitle: string,\n\tdetails: ApplyPatchToolDetails,\n\tisPartial: boolean,\n\tcwd: string,\n\texpanded: boolean,\n\ttheme: ApplyPatchTheme,\n): Container {\n\tconst component = new Container();\n\tif (!details.preview) return component;\n\tconst bgName = isPartial ? \"toolPendingBg\" : \"toolSuccessBg\";\n\tconst progress = details.progress;\n\tconst renderedTitle = progress ? `Applying patch (${progress.applied + progress.failed}/${progress.total})` : title;\n\tconst box = new Box(1, 1, (text: string) => theme.bg(bgName, text));\n\tbox.addChild(new Text(theme.fg(\"toolTitle\", theme.bold(renderedTitle)), 0, 0));\n\tbox.addChild(new Spacer(1));\n\tbox.addChild(new Text(renderPatchPreview(details.preview, cwd, theme, expanded), 0, 0));\n\tcomponent.addChild(box);\n\treturn component;\n}\n\nfunction renderTextResult(\n\tresult: AgentToolResult<ApplyPatchToolDetails | undefined>,\n\ttheme: ApplyPatchTheme,\n): Container {\n\tconst component = new Container();\n\tconst text = resultText(result);\n\tif (text) component.addChild(new Text(theme.fg(\"toolOutput\", text), 0, 0));\n\treturn component;\n}\n\nfunction resultText(result: AgentToolResult<ApplyPatchToolDetails | undefined>): string {\n\treturn result.content\n\t\t.filter((block) => block.type === \"text\")\n\t\t.map((block) => block.text)\n\t\t.filter((value) => typeof value === \"string\" && value.length > 0)\n\t\t.join(\"\\n\");\n}\n\nfunction renderFailureBox(\n\tresult: AgentToolResult<ApplyPatchToolDetails>,\n\tcwd: string,\n\texpanded: boolean,\n\ttheme: ApplyPatchTheme,\n): Container {\n\tconst patchResult = result.details?.result;\n\tif (!patchResult) return renderTextResult(result, theme);\n\tconst component = new Container();\n\tconst appliedCount = patchResult.appliedFiles.length;\n\tconst title = appliedCount > 0 ? \"Patch partially failed\" : \"Patch failed\";\n\tconst box = new Box(1, 1, (text: string) => theme.bg(\"toolErrorBg\", text));\n\tbox.addChild(new Text(theme.fg(\"toolTitle\", theme.bold(title)), 0, 0));\n\tif (result.details.preview) {\n\t\tbox.addChild(new Spacer(1));\n\t\tbox.addChild(new Text(renderPatchPreview(result.details.preview, cwd, theme, expanded), 0, 0));\n\t}\n\tconst text = resultText(result);\n\tif (text) {\n\t\tbox.addChild(new Spacer(1));\n\t\tbox.addChild(new Text(theme.fg(\"toolOutput\", text), 0, 0));\n\t}\n\tcomponent.addChild(box);\n\treturn component;\n}\n\nexport function createApplyPatchTool(variant: \"freeform\" | \"json\" = \"freeform\"): ApplyPatchToolDefinition {\n\tconst tool = defineTool<typeof APPLY_PATCH_PARAMS, ApplyPatchToolDetails | undefined, ApplyPatchRenderState>({\n\t\tname: \"apply_patch\",\n\t\tlabel: \"ApplyPatch\",\n\t\tdescription: variant === \"json\" ? APPLY_PATCH_JSON_DESCRIPTION : APPLY_PATCH_FREEFORM_DESCRIPTION,\n\t\tparameters: APPLY_PATCH_PARAMS,\n\t\tprepareArguments: normalizeApplyPatchArguments,\n\t\tpromptSnippet: \"Apply Codex-format file patches with apply_patch\",\n\t\tpromptGuidelines: [\n\t\t\t\"Use apply_patch for file edits instead of mutating files through bash, Python scripts, heredocs, or shell redirection.\",\n\t\t\t\"After apply_patch succeeds, do not re-read the edited files just to confirm the patch applied.\",\n\t\t],\n\t\tasync execute(\n\t\t\t_toolCallId,\n\t\t\tparams,\n\t\t\t_signal,\n\t\t\tonUpdate,\n\t\t\tctx,\n\t\t): Promise<AgentToolResult<ApplyPatchToolDetails | undefined>> {\n\t\t\tconst normalizedParams = normalizeApplyPatchArguments(params);\n\t\t\tif (!normalizedParams.input) throw new Error(\"input is required\");\n\t\t\tlet totalOperations = 0;\n\t\t\ttry {\n\t\t\t\ttotalOperations = parsePatch(normalizedParams.input).length;\n\t\t\t} catch {\n\t\t\t\t// createPendingPatchUpdate keeps incomplete or invalid patch text renderable.\n\t\t\t}\n\t\t\tconst initialProgress = totalOperations > 0 ? { applied: 0, failed: 0, total: totalOperations } : undefined;\n\t\t\tconst pendingUpdate = await createPendingPatchUpdate(ctx.cwd, normalizedParams.input, initialProgress);\n\t\t\tonUpdate?.({ content: [{ type: \"text\", text: pendingUpdate.text }], details: pendingUpdate.details });\n\t\t\tconst preview = pendingUpdate.details?.preview;\n\t\t\tconst result = await applyPatchDetailed(ctx.cwd, normalizedParams.input, async (progress) => {\n\t\t\t\tconst progressUpdate = await createPendingPatchUpdate(ctx.cwd, normalizedParams.input, progress, preview);\n\t\t\t\tonUpdate?.({ content: [{ type: \"text\", text: progressUpdate.text }], details: progressUpdate.details });\n\t\t\t});\n\t\t\tconst resultPreview = appliedPreview(result);\n\t\t\tif (result.failures.length > 0) {\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [{ type: \"text\", text: buildPartialFailureText(result) }],\n\t\t\t\t\tdetails: resultPreview ? { preview: resultPreview, result } : { result },\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tcontent: [{ type: \"text\", text: result.summaries.join(\"\\n\") }],\n\t\t\t\tdetails: resultPreview ? { preview: resultPreview, result } : { result },\n\t\t\t};\n\t\t},\n\t\trenderCall(args, theme, context: ToolRenderContext<ApplyPatchRenderState, { input: string }>) {\n\t\t\tif (!context.executionStarted) {\n\t\t\t\tconst streaming = renderStreamingPatchCall(normalizeApplyPatchArguments(args), theme, context.state);\n\t\t\t\tif (streaming) return streaming;\n\t\t\t}\n\t\t\tif (!context.argsComplete) return new Text(theme.fg(\"toolTitle\", theme.bold(\"apply_patch: Patching\")), 0, 0);\n\t\t\tconst normalizedArgs = normalizeApplyPatchArguments(args);\n\t\t\tconst renderState = getApplyPatchRenderState(context.toolCallId, context.cwd, normalizedArgs.input);\n\t\t\tconst text = renderState.callText?.length ? `apply_patch: ${renderState.callText}` : \"apply_patch\";\n\t\t\treturn new Text(theme.fg(\"toolTitle\", theme.bold(text)), 0, 0);\n\t\t},\n\t\trenderResult(result, options, theme, context) {\n\t\t\tif (context.isError && result.details?.result?.failures.length) {\n\t\t\t\treturn renderFailureBox(result as AgentToolResult<ApplyPatchToolDetails>, context.cwd, true, theme);\n\t\t\t}\n\t\t\tif (result.details?.preview) {\n\t\t\t\tconst expanded = true;\n\t\t\t\treturn renderPreviewBox(\n\t\t\t\t\toptions.isPartial ? \"Applying patch\" : \"Applied patch\",\n\t\t\t\t\tresult.details,\n\t\t\t\t\toptions.isPartial,\n\t\t\t\t\tcontext.cwd,\n\t\t\t\t\texpanded,\n\t\t\t\t\ttheme,\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (result.details?.result) {\n\t\t\t\tconst component = new Container();\n\t\t\t\tconst box = new Box(1, 1, (text: string) =>\n\t\t\t\t\ttheme.bg(options.isPartial ? \"toolPendingBg\" : \"toolSuccessBg\", text),\n\t\t\t\t);\n\t\t\t\tbox.addChild(new Text(theme.fg(\"toolTitle\", theme.bold(\"Applying patch\")), 0, 0));\n\t\t\t\tbox.addChild(new Spacer(1));\n\t\t\t\tif (result.details.preview) {\n\t\t\t\t\tconst expanded = options.isPartial ? true : (options.expanded ?? true);\n\t\t\t\t\tbox.addChild(new Text(renderPatchPreview(result.details.preview, context.cwd, theme, expanded), 0, 0));\n\t\t\t\t}\n\t\t\t\tcomponent.addChild(box);\n\t\t\t\treturn component;\n\t\t\t}\n\t\t\treturn renderTextResult(result, theme);\n\t\t},\n\t});\n\n\tif (variant === \"json\") return tool;\n\treturn Object.assign(tool, {\n\t\tfreeform: { type: \"grammar\", syntax: \"lark\", definition: APPLY_PATCH_LARK_GRAMMAR } satisfies FreeformToolFormat,\n\t});\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/core/extensions/builtin/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAQpD,OAAO,aAAa,MAAM,WAAW,CAAC;AACtC,OAAO,cAAc,MAAM,YAAY,CAAC;AAcxC,OAAO,wBAAwB,MAAM,wBAAwB,CAAC;AAQ9D,OAAO,YAAY,MAAM,UAAU,CAAC;AAMpC,MAAM,WAAW,uBAAuB;IACvC,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,gBAAgB,CAAC;CAC1B;AAED,eAAO,MAAM,yBAAyB,YAAI,MAAM,EAAE,OAAO,EAAE,mBAAmB,EAAE,KAAK,CAAU,CAAC;AAEhG,eAAO,MAAM,+BAA+B;;;;;CAKoC,CAAC;AAEjF,eAAO,MAAM,iBAAiB,EAAE,uBAAuB,EAoCtD,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/core/extensions/builtin/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAQpD,OAAO,aAAa,MAAM,WAAW,CAAC;AACtC,OAAO,cAAc,MAAM,YAAY,CAAC;AAexC,OAAO,wBAAwB,MAAM,wBAAwB,CAAC;AAQ9D,OAAO,YAAY,MAAM,UAAU,CAAC;AAMpC,MAAM,WAAW,uBAAuB;IACvC,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,gBAAgB,CAAC;CAC1B;AAED,eAAO,MAAM,yBAAyB,YAAI,MAAM,EAAE,OAAO,EAAE,mBAAmB,EAAE,KAAK,CAAU,CAAC;AAEhG,eAAO,MAAM,+BAA+B;;;;;CAKoC,CAAC;AAEjF,eAAO,MAAM,iBAAiB,EAAE,uBAAuB,EAsCtD,CAAC"}
@@ -2,7 +2,7 @@ import anthropicBashExtension from "./anthropic-bash/index.js";
2
2
  import anthropicWebSearchExtension from "./anthropic-web-search/index.js";
3
3
  import bashTimeoutExtension from "./bash-timeout/index.js";
4
4
  import btwExtension from "./btw/index.js";
5
- import claudeAgentSdkExtension from "./claude-agent-sdk/index.js";
5
+ import claudeSdkOauthExtension from "./claude-sdk-oauth/index.js";
6
6
  import compactionExtension from "./compaction/index.js";
7
7
  import configReloadExtension from "./config-reload/index.js";
8
8
  import diffExtension from "./diff.js";
@@ -14,6 +14,7 @@ import historySearchExtension from "./history-search/index.js";
14
14
  import hooksExtension from "./hooks/index.js";
15
15
  import importReproExtension from "./import-repro.js";
16
16
  import lookAtExtension from "./look-at/index.js";
17
+ import loopGuardExtension from "./loop-guard/index.js";
17
18
  import mcpExtension from "./mcp/index.js";
18
19
  import modelFallbackExtension from "./model-fallback/index.js";
19
20
  import nestedAgentsMdExtension from "./nested-agents-md/index.js";
@@ -71,7 +72,9 @@ export const builtinExtensions = [
71
72
  { id: "goal", factory: goalExtension },
72
73
  { id: "ttsr", factory: ttsrExtension },
73
74
  { id: "btw", factory: btwExtension },
74
- { id: "claude-agent-sdk", factory: claudeAgentSdkExtension },
75
+ { id: "claude-sdk-oauth", factory: claudeSdkOauthExtension },
76
+ // Loop guard is a pure observer of tool_execution_start; it never mutates payloads, so it slots before config-reload and leaves MCP last.
77
+ { id: "loop-guard", factory: loopGuardExtension },
75
78
  // Config reload follows settings-dependent builtins so reloads rebuild their resolved settings before MCP observes them.
76
79
  { id: "config-reload", factory: configReloadExtension },
77
80
  // Keep MCP last so its eventual provider-payload tap observes all co-resident builtin mutations.
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","s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AAqB,EAAE;IACvD,iGAAiG;IACjG,EAAE,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE;CACpC,CAAC","sourcesContent":["import type { ExtensionFactory } from \"../types.ts\";\nimport anthropicBashExtension from \"./anthropic-bash/index.ts\";\nimport anthropicWebSearchExtension from \"./anthropic-web-search/index.ts\";\nimport bashTimeoutExtension from \"./bash-timeout/index.ts\";\nimport btwExtension from \"./btw/index.ts\";\nimport claudeAgentSdkExtension from \"./claude-agent-sdk/index.ts\";\nimport compactionExtension from \"./compaction/index.ts\";\nimport configReloadExtension from \"./config-reload/index.ts\";\nimport diffExtension from \"./diff.ts\";\nimport filesExtension from \"./files.ts\";\nimport goalExtension from \"./goal/index.ts\";\nimport gptApplyPatchExtension from \"./gpt-apply-patch/index.ts\";\nimport helpExtension from \"./help/index.ts\";\nimport historySearchExtension from \"./history-search/index.ts\";\nimport hooksExtension from \"./hooks/index.ts\";\nimport importReproExtension from \"./import-repro.ts\";\nimport lookAtExtension from \"./look-at/index.ts\";\nimport mcpExtension from \"./mcp/index.ts\";\nimport modelFallbackExtension from \"./model-fallback/index.ts\";\nimport nestedAgentsMdExtension from \"./nested-agents-md/index.ts\";\nimport openaiWebSearchExtension from \"./openai-web-search/index.ts\";\nimport permissionSystemExtension from \"./permission-system/index.ts\";\nimport promptPresetExtension from \"./prompt-preset/index.ts\";\nimport promptUrlWidgetExtension from \"./prompt-url-widget.ts\";\nimport recommendedModelsExtension from \"./recommended-models/index.ts\";\nimport redrawsExtension from \"./redraws.ts\";\nimport piRulesExtension from \"./rules/index.ts\";\nimport serviceTierExtension from \"./service-tier.ts\";\nimport terminalExtension from \"./terminal/index.ts\";\nimport todowriteExtension from \"./todotools/index.ts\";\nimport toolPairGuardExtension from \"./tool-pair-guard/index.ts\";\nimport tpsExtension from \"./tps.ts\";\nimport ttsrExtension from \"./ttsr/index.ts\";\nimport videoInExtension from \"./video-in/index.ts\";\nimport webfetchExtension from \"./webfetch/index.ts\";\nimport websearchExtension from \"./websearch/index.ts\";\n\nexport interface BuiltinExtensionFactory {\n\tid: string;\n\tfactory: ExtensionFactory;\n}\n\nexport const globalDefaultExtensionIds = [\"diff\", \"files\", \"prompt-url-widget\", \"tps\"] as const;\n\nexport const globalDefaultExtensionFactories = {\n\tdiff: diffExtension,\n\tfiles: filesExtension,\n\t\"prompt-url-widget\": promptUrlWidgetExtension,\n\ttps: tpsExtension,\n} satisfies Record<(typeof globalDefaultExtensionIds)[number], ExtensionFactory>;\n\nexport const builtinExtensions: BuiltinExtensionFactory[] = [\n\t{ id: \"hooks\", factory: hooksExtension },\n\t{ id: \"permission-system\", factory: permissionSystemExtension },\n\t{ id: \"gpt-apply-patch\", factory: gptApplyPatchExtension },\n\t{ id: \"prompt-preset\", factory: promptPresetExtension },\n\t{ id: \"todowrite\", factory: todowriteExtension },\n\t{ id: \"redraws\", factory: redrawsExtension },\n\t{ id: \"anthropic-web-search\", factory: anthropicWebSearchExtension },\n\t{ id: \"anthropic-bash\", factory: anthropicBashExtension },\n\t{ id: \"openai-web-search\", factory: openaiWebSearchExtension },\n\t{ id: \"service-tier\", factory: serviceTierExtension },\n\t{ id: \"model-fallback\", factory: modelFallbackExtension },\n\t{ id: \"recommended-models\", factory: recommendedModelsExtension },\n\t{ id: \"bash-timeout\", factory: bashTimeoutExtension },\n\t// Terminal follows bash-timeout so its injected default reaches the PTY bash, and follows\n\t// anthropic-bash so mutual-exclusion (companion step-aside) is evaluated after it registers.\n\t{ id: \"terminal\", factory: terminalExtension },\n\t{ id: \"tool-pair-guard\", factory: toolPairGuardExtension },\n\t{ id: \"compaction\", factory: compactionExtension },\n\t{ id: \"history-search\", factory: historySearchExtension },\n\t{ id: \"help\", factory: helpExtension },\n\t{ id: \"import-repro\", factory: importReproExtension },\n\t{ id: \"websearch\", factory: websearchExtension },\n\t{ id: \"webfetch\", factory: webfetchExtension },\n\t{ id: \"video-in\", factory: videoInExtension },\n\t{ id: \"look-at\", factory: lookAtExtension },\n\t{ id: \"nested-agents-md\", factory: nestedAgentsMdExtension },\n\t{ id: \"rules\", factory: piRulesExtension },\n\t{ id: \"goal\", factory: goalExtension },\n\t{ id: \"ttsr\", factory: ttsrExtension },\n\t{ id: \"btw\", factory: btwExtension },\n\t{ id: \"claude-agent-sdk\", factory: claudeAgentSdkExtension },\n\t// Config reload follows settings-dependent builtins so reloads rebuild their resolved settings before MCP observes them.\n\t{ id: \"config-reload\", factory: configReloadExtension },\n\t// Keep MCP last so its eventual provider-payload tap observes all co-resident builtin mutations.\n\t{ id: \"mcp\", factory: mcpExtension },\n];\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/core/extensions/builtin/index.ts"],"names":[],"mappings":"AACA,OAAO,sBAAsB,MAAM,2BAA2B,CAAC;AAC/D,OAAO,2BAA2B,MAAM,iCAAiC,CAAC;AAC1E,OAAO,oBAAoB,MAAM,yBAAyB,CAAC;AAC3D,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,uBAAuB,MAAM,6BAA6B,CAAC;AAClE,OAAO,mBAAmB,MAAM,uBAAuB,CAAC;AACxD,OAAO,qBAAqB,MAAM,0BAA0B,CAAC;AAC7D,OAAO,aAAa,MAAM,WAAW,CAAC;AACtC,OAAO,cAAc,MAAM,YAAY,CAAC;AACxC,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAC5C,OAAO,sBAAsB,MAAM,4BAA4B,CAAC;AAChE,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAC5C,OAAO,sBAAsB,MAAM,2BAA2B,CAAC;AAC/D,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAC9C,OAAO,oBAAoB,MAAM,mBAAmB,CAAC;AACrD,OAAO,eAAe,MAAM,oBAAoB,CAAC;AACjD,OAAO,kBAAkB,MAAM,uBAAuB,CAAC;AACvD,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,sBAAsB,MAAM,2BAA2B,CAAC;AAC/D,OAAO,uBAAuB,MA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AC3C,EAAE,EAAE,EAAE,kBAAkB,EAAE,OAAO,EAAE,uBAAuB,EAAE;IAC5D,EAAE,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE;IAC1C,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE;IACtC,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE;IACtC,EAAE,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE;IACpC,EAAE,EAAE,EAAE,kBAAkB,EAAE,OAAO,EAAE,uBAAuB,EAAE;IAC5D,0IAA0I;IAC1I,EAAE,EAAE,EAAE,YAAY,EAAE,OAAO,EAAE,kBAAkB,EAAE;IACjD,yHAAyH;IACzH,EAAE,EAAE,EAAE,eAAe,EAAE,OAAO,EAAE,qBAAqB,EAAE;IACvD,iGAAiG;IACjG,EAAE,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE;CACpC,CAAC","sourcesContent":["import type { ExtensionFactory } from \"../types.ts\";\nimport anthropicBashExtension from \"./anthropic-bash/index.ts\";\nimport anthropicWebSearchExtension from \"./anthropic-web-search/index.ts\";\nimport bashTimeoutExtension from \"./bash-timeout/index.ts\";\nimport btwExtension from \"./btw/index.ts\";\nimport claudeSdkOauthExtension from \"./claude-sdk-oauth/index.ts\";\nimport compactionExtension from \"./compaction/index.ts\";\nimport configReloadExtension from \"./config-reload/index.ts\";\nimport diffExtension from \"./diff.ts\";\nimport filesExtension from \"./files.ts\";\nimport goalExtension from \"./goal/index.ts\";\nimport gptApplyPatchExtension from \"./gpt-apply-patch/index.ts\";\nimport helpExtension from \"./help/index.ts\";\nimport historySearchExtension from \"./history-search/index.ts\";\nimport hooksExtension from \"./hooks/index.ts\";\nimport importReproExtension from \"./import-repro.ts\";\nimport lookAtExtension from \"./look-at/index.ts\";\nimport loopGuardExtension from \"./loop-guard/index.ts\";\nimport mcpExtension from \"./mcp/index.ts\";\nimport modelFallbackExtension from \"./model-fallback/index.ts\";\nimport nestedAgentsMdExtension from \"./nested-agents-md/index.ts\";\nimport openaiWebSearchExtension from \"./openai-web-search/index.ts\";\nimport permissionSystemExtension from \"./permission-system/index.ts\";\nimport promptPresetExtension from \"./prompt-preset/index.ts\";\nimport promptUrlWidgetExtension from \"./prompt-url-widget.ts\";\nimport recommendedModelsExtension from \"./recommended-models/index.ts\";\nimport redrawsExtension from \"./redraws.ts\";\nimport piRulesExtension from \"./rules/index.ts\";\nimport serviceTierExtension from \"./service-tier.ts\";\nimport terminalExtension from \"./terminal/index.ts\";\nimport todowriteExtension from \"./todotools/index.ts\";\nimport toolPairGuardExtension from \"./tool-pair-guard/index.ts\";\nimport tpsExtension from \"./tps.ts\";\nimport ttsrExtension from \"./ttsr/index.ts\";\nimport videoInExtension from \"./video-in/index.ts\";\nimport webfetchExtension from \"./webfetch/index.ts\";\nimport websearchExtension from \"./websearch/index.ts\";\n\nexport interface BuiltinExtensionFactory {\n\tid: string;\n\tfactory: ExtensionFactory;\n}\n\nexport const globalDefaultExtensionIds = [\"diff\", \"files\", \"prompt-url-widget\", \"tps\"] as const;\n\nexport const globalDefaultExtensionFactories = {\n\tdiff: diffExtension,\n\tfiles: filesExtension,\n\t\"prompt-url-widget\": promptUrlWidgetExtension,\n\ttps: tpsExtension,\n} satisfies Record<(typeof globalDefaultExtensionIds)[number], ExtensionFactory>;\n\nexport const builtinExtensions: BuiltinExtensionFactory[] = [\n\t{ id: \"hooks\", factory: hooksExtension },\n\t{ id: \"permission-system\", factory: permissionSystemExtension },\n\t{ id: \"gpt-apply-patch\", factory: gptApplyPatchExtension },\n\t{ id: \"prompt-preset\", factory: promptPresetExtension },\n\t{ id: \"todowrite\", factory: todowriteExtension },\n\t{ id: \"redraws\", factory: redrawsExtension },\n\t{ id: \"anthropic-web-search\", factory: anthropicWebSearchExtension },\n\t{ id: \"anthropic-bash\", factory: anthropicBashExtension },\n\t{ id: \"openai-web-search\", factory: openaiWebSearchExtension },\n\t{ id: \"service-tier\", factory: serviceTierExtension },\n\t{ id: \"model-fallback\", factory: modelFallbackExtension },\n\t{ id: \"recommended-models\", factory: recommendedModelsExtension },\n\t{ id: \"bash-timeout\", factory: bashTimeoutExtension },\n\t// Terminal follows bash-timeout so its injected default reaches the PTY bash, and follows\n\t// anthropic-bash so mutual-exclusion (companion step-aside) is evaluated after it registers.\n\t{ id: \"terminal\", factory: terminalExtension },\n\t{ id: \"tool-pair-guard\", factory: toolPairGuardExtension },\n\t{ id: \"compaction\", factory: compactionExtension },\n\t{ id: \"history-search\", factory: historySearchExtension },\n\t{ id: \"help\", factory: helpExtension },\n\t{ id: \"import-repro\", factory: importReproExtension },\n\t{ id: \"websearch\", factory: websearchExtension },\n\t{ id: \"webfetch\", factory: webfetchExtension },\n\t{ id: \"video-in\", factory: videoInExtension },\n\t{ id: \"look-at\", factory: lookAtExtension },\n\t{ id: \"nested-agents-md\", factory: nestedAgentsMdExtension },\n\t{ id: \"rules\", factory: piRulesExtension },\n\t{ id: \"goal\", factory: goalExtension },\n\t{ id: \"ttsr\", factory: ttsrExtension },\n\t{ id: \"btw\", factory: btwExtension },\n\t{ id: \"claude-sdk-oauth\", factory: claudeSdkOauthExtension },\n\t// Loop guard is a pure observer of tool_execution_start; it never mutates payloads, so it slots before config-reload and leaves MCP last.\n\t{ id: \"loop-guard\", factory: loopGuardExtension },\n\t// Config reload follows settings-dependent builtins so reloads rebuild their resolved settings before MCP observes them.\n\t{ id: \"config-reload\", factory: configReloadExtension },\n\t// Keep MCP last so its eventual provider-payload tap observes all co-resident builtin mutations.\n\t{ id: \"mcp\", factory: mcpExtension },\n];\n"]}
@@ -0,0 +1,31 @@
1
+ import type { ToolCallRecord } from "./tracker.ts";
2
+ export type LoopGuardDetection = {
3
+ readonly kind: "identical";
4
+ readonly toolName: string;
5
+ readonly count: number;
6
+ readonly fingerprint: string;
7
+ } | {
8
+ readonly kind: "similar";
9
+ readonly toolName: string;
10
+ readonly count: number;
11
+ readonly similarity: number;
12
+ readonly fingerprint: string;
13
+ } | {
14
+ readonly kind: "cycle";
15
+ readonly period: number;
16
+ readonly count: number;
17
+ readonly cycleTools: readonly string[];
18
+ readonly fingerprint: string;
19
+ };
20
+ export type LoopGuardKind = LoopGuardDetection["kind"];
21
+ export declare function detectIdenticalRun(records: readonly ToolCallRecord[]): LoopGuardDetection | undefined;
22
+ export declare function detectSimilarRun(records: readonly ToolCallRecord[]): LoopGuardDetection | undefined;
23
+ export declare function detectCycle(records: readonly ToolCallRecord[]): LoopGuardDetection | undefined;
24
+ export declare class NoticeGate {
25
+ private entries;
26
+ admit(detection: LoopGuardDetection): boolean;
27
+ prune(active: ReadonlyMap<LoopGuardKind, string>): void;
28
+ reset(): void;
29
+ }
30
+ export declare function detectLoop(records: readonly ToolCallRecord[], gate: NoticeGate): LoopGuardDetection | undefined;
31
+ //# sourceMappingURL=detectors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detectors.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/loop-guard/detectors.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAEnD,MAAM,MAAM,kBAAkB,GAC3B;IAAE,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;CAAE,GAC/G;IACA,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC5B,GACD;IACA,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,CAAC;IACvC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEL,MAAM,MAAM,aAAa,GAAG,kBAAkB,CAAC,MAAM,CAAC,CAAC;AAEvD,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,SAAS,cAAc,EAAE,GAAG,kBAAkB,GAAG,SAAS,CAUrG;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,SAAS,cAAc,EAAE,GAAG,kBAAkB,GAAG,SAAS,CAcnG;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE,SAAS,cAAc,EAAE,GAAG,kBAAkB,GAAG,SAAS,CA6B9F;AAOD,qBAAa,UAAU;IACtB,OAAO,CAAC,OAAO,CAAuC;IAEtD,KAAK,CAAC,SAAS,EAAE,kBAAkB,GAAG,OAAO,CAW5C;IAED,KAAK,CAAC,MAAM,EAAE,WAAW,CAAC,aAAa,EAAE,MAAM,CAAC,GAAG,IAAI,CAItD;IAED,KAAK,IAAI,IAAI,CAEZ;CACD;AAED,wBAAgB,UAAU,CAAC,OAAO,EAAE,SAAS,cAAc,EAAE,EAAE,IAAI,EAAE,UAAU,GAAG,kBAAkB,GAAG,SAAS,CAW/G"}
@@ -0,0 +1,111 @@
1
+ import { CYCLE_MAX_PERIOD, CYCLE_MIN_PERIOD, CYCLE_REPETITION_THRESHOLD, ESCALATION_FACTOR, IDENTICAL_RUN_THRESHOLD, SIMILAR_RUN_THRESHOLD, SIMILARITY_THRESHOLD, } from "./policy.js";
2
+ import { meanAdjacentSimilarity } from "./similarity.js";
3
+ export function detectIdenticalRun(records) {
4
+ const last = records[records.length - 1];
5
+ if (last === undefined)
6
+ return undefined;
7
+ let run = 1;
8
+ for (let i = records.length - 2; i >= 0; i--) {
9
+ if (records[i]?.signature !== last.signature)
10
+ break;
11
+ run++;
12
+ }
13
+ if (run < IDENTICAL_RUN_THRESHOLD)
14
+ return undefined;
15
+ return { kind: "identical", toolName: last.toolName, count: run, fingerprint: last.signature };
16
+ }
17
+ export function detectSimilarRun(records) {
18
+ const last = records[records.length - 1];
19
+ if (last === undefined)
20
+ return undefined;
21
+ let run = 1;
22
+ for (let i = records.length - 2; i >= 0; i--) {
23
+ if (records[i]?.toolName !== last.toolName)
24
+ break;
25
+ run++;
26
+ }
27
+ if (run < SIMILAR_RUN_THRESHOLD)
28
+ return undefined;
29
+ const argStrings = records.slice(records.length - run).map((record) => record.argsJson);
30
+ if (new Set(argStrings).size === 1)
31
+ return undefined;
32
+ const similarity = meanAdjacentSimilarity(argStrings);
33
+ if (similarity < SIMILARITY_THRESHOLD)
34
+ return undefined;
35
+ return { kind: "similar", toolName: last.toolName, count: run, similarity, fingerprint: last.toolName };
36
+ }
37
+ export function detectCycle(records) {
38
+ const total = records.length;
39
+ for (let period = CYCLE_MIN_PERIOD; period <= CYCLE_MAX_PERIOD; period++) {
40
+ if (total < period * CYCLE_REPETITION_THRESHOLD)
41
+ continue;
42
+ const cycle = records.slice(total - period);
43
+ if (new Set(cycle.map((record) => record.signature)).size < 2)
44
+ continue;
45
+ let repetitions = 1;
46
+ while (repetitions * period + period <= total) {
47
+ const blockStart = total - (repetitions + 1) * period;
48
+ let matches = true;
49
+ for (let offset = 0; offset < period; offset++) {
50
+ if (records[blockStart + offset]?.signature !== cycle[offset]?.signature) {
51
+ matches = false;
52
+ break;
53
+ }
54
+ }
55
+ if (!matches)
56
+ break;
57
+ repetitions++;
58
+ }
59
+ if (repetitions < CYCLE_REPETITION_THRESHOLD)
60
+ continue;
61
+ return {
62
+ kind: "cycle",
63
+ period,
64
+ count: repetitions,
65
+ cycleTools: cycle.map((record) => record.toolName),
66
+ fingerprint: cycle.map((record) => record.signature).join("\u0001"),
67
+ };
68
+ }
69
+ return undefined;
70
+ }
71
+ export class NoticeGate {
72
+ constructor() {
73
+ this.entries = new Map();
74
+ }
75
+ admit(detection) {
76
+ const existing = this.entries.get(detection.kind);
77
+ if (existing === undefined || existing.fingerprint !== detection.fingerprint) {
78
+ this.entries.set(detection.kind, { fingerprint: detection.fingerprint, lastNotifiedCount: detection.count });
79
+ return true;
80
+ }
81
+ if (detection.count >= existing.lastNotifiedCount * ESCALATION_FACTOR) {
82
+ existing.lastNotifiedCount = detection.count;
83
+ return true;
84
+ }
85
+ return false;
86
+ }
87
+ prune(active) {
88
+ for (const [kind, entry] of this.entries) {
89
+ if (active.get(kind) !== entry.fingerprint)
90
+ this.entries.delete(kind);
91
+ }
92
+ }
93
+ reset() {
94
+ this.entries.clear();
95
+ }
96
+ }
97
+ export function detectLoop(records, gate) {
98
+ const detections = [detectIdenticalRun(records), detectCycle(records), detectSimilarRun(records)];
99
+ const active = new Map();
100
+ for (const detection of detections) {
101
+ if (detection !== undefined)
102
+ active.set(detection.kind, detection.fingerprint);
103
+ }
104
+ gate.prune(active);
105
+ for (const detection of detections) {
106
+ if (detection !== undefined && gate.admit(detection))
107
+ return detection;
108
+ }
109
+ return undefined;
110
+ }
111
+ //# sourceMappingURL=detectors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detectors.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/loop-guard/detectors.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,gBAAgB,EAChB,gBAAgB,EAChB,0BAA0B,EAC1B,iBAAiB,EACjB,uBAAuB,EACvB,qBAAqB,EACrB,oBAAoB,GACpB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAsBzD,MAAM,UAAU,kBAAkB,CAAC,OAAkC;IACpE,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACzC,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IACzC,IAAI,GAAG,GAAG,CAAC,CAAC;IACZ,K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I,IAAI,CAAC,OAAO,EAAE,CAAC;YAC1C,IAAI,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,KAAK,CAAC,WAAW;gBAAE,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACvE,CAAC;IACF,CAAC;IAED,KAAK;QACJ,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;IACtB,CAAC;CACD;AAED,MAAM,UAAU,UAAU,CAAC,OAAkC,EAAE,IAAgB;IAC9E,MAAM,UAAU,GAAG,CAAC,kBAAkB,CAAC,OAAO,CAAC,EAAE,WAAW,CAAC,OAAO,CAAC,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC;IAClG,MAAM,MAAM,GAAG,IAAI,GAAG,EAAyB,CAAC;IAChD,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACpC,IAAI,SAAS,KAAK,SAAS;YAAE,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,EAAE,SAAS,CAAC,WAAW,CAAC,CAAC;IAChF,CAAC;IACD,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IACnB,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACpC,IAAI,SAAS,KAAK,SAAS,IAAI,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC;YAAE,OAAO,SAAS,CAAC;IACxE,CAAC;IACD,OAAO,SAAS,CAAC;AAClB,CAAC","sourcesContent":["import {\n\tCYCLE_MAX_PERIOD,\n\tCYCLE_MIN_PERIOD,\n\tCYCLE_REPETITION_THRESHOLD,\n\tESCALATION_FACTOR,\n\tIDENTICAL_RUN_THRESHOLD,\n\tSIMILAR_RUN_THRESHOLD,\n\tSIMILARITY_THRESHOLD,\n} from \"./policy.ts\";\nimport { meanAdjacentSimilarity } from \"./similarity.ts\";\nimport type { ToolCallRecord } from \"./tracker.ts\";\n\nexport type LoopGuardDetection =\n\t| { readonly kind: \"identical\"; readonly toolName: string; readonly count: number; readonly fingerprint: string }\n\t| {\n\t\t\treadonly kind: \"similar\";\n\t\t\treadonly toolName: string;\n\t\t\treadonly count: number;\n\t\t\treadonly similarity: number;\n\t\t\treadonly fingerprint: string;\n\t }\n\t| {\n\t\t\treadonly kind: \"cycle\";\n\t\t\treadonly period: number;\n\t\t\treadonly count: number;\n\t\t\treadonly cycleTools: readonly string[];\n\t\t\treadonly fingerprint: string;\n\t };\n\nexport type LoopGuardKind = LoopGuardDetection[\"kind\"];\n\nexport function detectIdenticalRun(records: readonly ToolCallRecord[]): LoopGuardDetection | undefined {\n\tconst last = records[records.length - 1];\n\tif (last === undefined) return undefined;\n\tlet run = 1;\n\tfor (let i = records.length - 2; i >= 0; i--) {\n\t\tif (records[i]?.signature !== last.signature) break;\n\t\trun++;\n\t}\n\tif (run < IDENTICAL_RUN_THRESHOLD) return undefined;\n\treturn { kind: \"identical\", toolName: last.toolName, count: run, fingerprint: last.signature };\n}\n\nexport function detectSimilarRun(records: readonly ToolCallRecord[]): LoopGuardDetection | undefined {\n\tconst last = records[records.length - 1];\n\tif (last === undefined) return undefined;\n\tlet run = 1;\n\tfor (let i = records.length - 2; i >= 0; i--) {\n\t\tif (records[i]?.toolName !== last.toolName) break;\n\t\trun++;\n\t}\n\tif (run < SIMILAR_RUN_THRESHOLD) return undefined;\n\tconst argStrings = records.slice(records.length - run).map((record) => record.argsJson);\n\tif (new Set(argStrings).size === 1) return undefined;\n\tconst similarity = meanAdjacentSimilarity(argStrings);\n\tif (similarity < SIMILARITY_THRESHOLD) return undefined;\n\treturn { kind: \"similar\", toolName: last.toolName, count: run, similarity, fingerprint: last.toolName };\n}\n\nexport function detectCycle(records: readonly ToolCallRecord[]): LoopGuardDetection | undefined {\n\tconst total = records.length;\n\tfor (let period = CYCLE_MIN_PERIOD; period <= CYCLE_MAX_PERIOD; period++) {\n\t\tif (total < period * CYCLE_REPETITION_THRESHOLD) continue;\n\t\tconst cycle = records.slice(total - period);\n\t\tif (new Set(cycle.map((record) => record.signature)).size < 2) continue;\n\t\tlet repetitions = 1;\n\t\twhile (repetitions * period + period <= total) {\n\t\t\tconst blockStart = total - (repetitions + 1) * period;\n\t\t\tlet matches = true;\n\t\t\tfor (let offset = 0; offset < period; offset++) {\n\t\t\t\tif (records[blockStart + offset]?.signature !== cycle[offset]?.signature) {\n\t\t\t\t\tmatches = false;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!matches) break;\n\t\t\trepetitions++;\n\t\t}\n\t\tif (repetitions < CYCLE_REPETITION_THRESHOLD) continue;\n\t\treturn {\n\t\t\tkind: \"cycle\",\n\t\t\tperiod,\n\t\t\tcount: repetitions,\n\t\t\tcycleTools: cycle.map((record) => record.toolName),\n\t\t\tfingerprint: cycle.map((record) => record.signature).join(\"\\u0001\"),\n\t\t};\n\t}\n\treturn undefined;\n}\n\ninterface GateEntry {\n\tfingerprint: string;\n\tlastNotifiedCount: number;\n}\n\nexport class NoticeGate {\n\tprivate entries = new Map<LoopGuardKind, GateEntry>();\n\n\tadmit(detection: LoopGuardDetection): boolean {\n\t\tconst existing = this.entries.get(detection.kind);\n\t\tif (existing === undefined || existing.fingerprint !== detection.fingerprint) {\n\t\t\tthis.entries.set(detection.kind, { fingerprint: detection.fingerprint, lastNotifiedCount: detection.count });\n\t\t\treturn true;\n\t\t}\n\t\tif (detection.count >= existing.lastNotifiedCount * ESCALATION_FACTOR) {\n\t\t\texisting.lastNotifiedCount = detection.count;\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\tprune(active: ReadonlyMap<LoopGuardKind, string>): void {\n\t\tfor (const [kind, entry] of this.entries) {\n\t\t\tif (active.get(kind) !== entry.fingerprint) this.entries.delete(kind);\n\t\t}\n\t}\n\n\treset(): void {\n\t\tthis.entries.clear();\n\t}\n}\n\nexport function detectLoop(records: readonly ToolCallRecord[], gate: NoticeGate): LoopGuardDetection | undefined {\n\tconst detections = [detectIdenticalRun(records), detectCycle(records), detectSimilarRun(records)];\n\tconst active = new Map<LoopGuardKind, string>();\n\tfor (const detection of detections) {\n\t\tif (detection !== undefined) active.set(detection.kind, detection.fingerprint);\n\t}\n\tgate.prune(active);\n\tfor (const detection of detections) {\n\t\tif (detection !== undefined && gate.admit(detection)) return detection;\n\t}\n\treturn undefined;\n}\n"]}
@@ -0,0 +1,3 @@
1
+ import type { ExtensionAPI } from "../../types.ts";
2
+ export default function loopGuardExtension(pi: ExtensionAPI): void;
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/loop-guard/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAMnD,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,EAAE,EAAE,YAAY,GAAG,IAAI,CA+BjE"}
@@ -0,0 +1,31 @@
1
+ import { detectLoop, NoticeGate } from "./detectors.js";
2
+ import { buildLoopGuardReminder, LOOP_GUARD_NOTICE_CUSTOM_TYPE } from "./notice.js";
3
+ import { renderLoopGuardNotice } from "./renderer.js";
4
+ import { ToolCallTracker } from "./tracker.js";
5
+ export default function loopGuardExtension(pi) {
6
+ const tracker = new ToolCallTracker();
7
+ const gate = new NoticeGate();
8
+ const reset = () => {
9
+ tracker.reset();
10
+ gate.reset();
11
+ };
12
+ pi.registerMessageRenderer(LOOP_GUARD_NOTICE_CUSTOM_TYPE, renderLoopGuardNotice);
13
+ pi.on("session_start", () => reset());
14
+ pi.on("input", (event) => {
15
+ if (event.source !== "extension")
16
+ reset();
17
+ });
18
+ pi.on("tool_execution_start", (event) => {
19
+ tracker.record(event.toolName, event.args);
20
+ const detection = detectLoop(tracker.records, gate);
21
+ if (detection === undefined)
22
+ return;
23
+ pi.sendMessage({
24
+ customType: LOOP_GUARD_NOTICE_CUSTOM_TYPE,
25
+ content: buildLoopGuardReminder(detection),
26
+ display: true,
27
+ details: detection,
28
+ }, { triggerTurn: false, deliverAs: "steer" });
29
+ });
30
+ }
31
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/loop-guard/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,sBAAsB,EAAE,6BAA6B,EAAE,MAAM,aAAa,CAAC;AACpF,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,EAAgB;IAC1D,MAAM,OAAO,GAAG,IAAI,eAAe,EAAE,CAAC;IACtC,MAAM,IAAI,GAAG,IAAI,UAAU,EAAE,CAAC;IAE9B,MAAM,KAAK,GAAG,GAAS,EAAE;QACxB,OAAO,CAAC,KAAK,EAAE,CAAC;QAChB,IAAI,CAAC,KAAK,EAAE,CAAC;IACd,CAAC,CAAC;IAEF,EAAE,CAAC,uBAAuB,CAAC,6BAA6B,EAAE,qBAAqB,CAAC,CAAC;IAEjF,EAAE,CAAC,EAAE,CAAC,eAAe,EAAE,GAAG,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC;IAEtC,EAAE,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;QACxB,IAAI,KAAK,CAAC,MAAM,KAAK,WAAW;YAAE,KAAK,EAAE,CAAC;IAC3C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,EAAE,CAAC,sBAAsB,EAAE,CAAC,KAAK,EAAE,EAAE;QACvC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;QAC3C,MAAM,SAAS,GAAG,UAAU,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QACpD,IAAI,SAAS,KAAK,SAAS;YAAE,OAAO;QACpC,EAAE,CAAC,WAAW,CACb;YACC,UAAU,EAAE,6BAA6B;YACzC,OAAO,EAAE,sBAAsB,CAAC,SAAS,CAAC;YAC1C,OAAO,EAAE,IAAI;YACb,OAAO,EAAE,SAAS;SAClB,EACD,EAAE,WAAW,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,CAC1C,CAAC;IACH,CAAC,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import type { ExtensionAPI } from \"../../types.ts\";\nimport { detectLoop, NoticeGate } from \"./detectors.ts\";\nimport { buildLoopGuardReminder, LOOP_GUARD_NOTICE_CUSTOM_TYPE } from \"./notice.ts\";\nimport { renderLoopGuardNotice } from \"./renderer.ts\";\nimport { ToolCallTracker } from \"./tracker.ts\";\n\nexport default function loopGuardExtension(pi: ExtensionAPI): void {\n\tconst tracker = new ToolCallTracker();\n\tconst gate = new NoticeGate();\n\n\tconst reset = (): void => {\n\t\ttracker.reset();\n\t\tgate.reset();\n\t};\n\n\tpi.registerMessageRenderer(LOOP_GUARD_NOTICE_CUSTOM_TYPE, renderLoopGuardNotice);\n\n\tpi.on(\"session_start\", () => reset());\n\n\tpi.on(\"input\", (event) => {\n\t\tif (event.source !== \"extension\") reset();\n\t});\n\n\tpi.on(\"tool_execution_start\", (event) => {\n\t\ttracker.record(event.toolName, event.args);\n\t\tconst detection = detectLoop(tracker.records, gate);\n\t\tif (detection === undefined) return;\n\t\tpi.sendMessage(\n\t\t\t{\n\t\t\t\tcustomType: LOOP_GUARD_NOTICE_CUSTOM_TYPE,\n\t\t\t\tcontent: buildLoopGuardReminder(detection),\n\t\t\t\tdisplay: true,\n\t\t\t\tdetails: detection,\n\t\t\t},\n\t\t\t{ triggerTurn: false, deliverAs: \"steer\" },\n\t\t);\n\t});\n}\n"]}
@@ -0,0 +1,5 @@
1
+ import type { LoopGuardDetection } from "./detectors.ts";
2
+ export declare const LOOP_GUARD_NOTICE_CUSTOM_TYPE = "loop-guard:notice";
3
+ export type LoopGuardNoticeDetails = LoopGuardDetection;
4
+ export declare function buildLoopGuardReminder(detection: LoopGuardDetection): string;
5
+ //# sourceMappingURL=notice.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notice.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/loop-guard/notice.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEzD,eAAO,MAAM,6BAA6B,sBAAsB,CAAC;AAEjE,MAAM,MAAM,sBAAsB,GAAG,kBAAkB,CAAC;AAExD,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,kBAAkB,GAAG,MAAM,CAuC5E"}
@@ -0,0 +1,42 @@
1
+ export const LOOP_GUARD_NOTICE_CUSTOM_TYPE = "loop-guard:notice";
2
+ export function buildLoopGuardReminder(detection) {
3
+ switch (detection.kind) {
4
+ case "identical": {
5
+ const { toolName, count } = detection;
6
+ return [
7
+ `<system-reminder>`,
8
+ `LOOP GUARD - IDENTICAL TOOL CALLS: you called \`${toolName}\` ${count} times in a row with the EXACT same arguments. This is the tool-call stream, not consecutive text - another tool ran between these calls and it changed nothing about your plan. Re-issuing the same call returns the same result. Snap out of it:`,
9
+ `- reuse the result you already received from this exact call;`,
10
+ `- if you were re-checking for new output or state, switch to the monitor/watch tool or change one parameter deliberately (filter, offset, query);`,
11
+ `- if nothing is actually changing, stop calling this tool, state what is blocking you, and try a different tool or ask the user.`,
12
+ `Do not call \`${toolName}\` again with identical arguments.`,
13
+ `</system-reminder>`,
14
+ ].join("\n");
15
+ }
16
+ case "similar": {
17
+ const { toolName, count, similarity } = detection;
18
+ const percent = Math.round(similarity * 100);
19
+ return [
20
+ `<system-reminder>`,
21
+ `LOOP GUARD - NEAR-IDENTICAL TOOL CALLS: your last ${count} calls to \`${toolName}\` had arguments about ${percent}% identical (bigram similarity over canonical args). This may be legitimate batch work - or it may be a lazy loop that only LOOKS like progress. Attention check:`,
22
+ `- if these calls target genuinely different inputs (distinct files, queries, offsets), continue deliberately - but consider batching or widening the scope instead of one call per tiny variation;`,
23
+ `- if you are scanning output incrementally (reads, peeks, polls), widen the window once or use the monitor/watch tool rather than nudging parameters;`,
24
+ `- if the results keep saying the same thing, change strategy now - a different tool, a wider query, or asking the user beats a sixth near-copy.`,
25
+ `</system-reminder>`,
26
+ ].join("\n");
27
+ }
28
+ case "cycle": {
29
+ const { period, count, cycleTools } = detection;
30
+ const pattern = cycleTools.join(" -> ");
31
+ return [
32
+ `<system-reminder>`,
33
+ `LOOP GUARD - REPEATING TOOL-CALL PATTERN: your recent tool calls repeat the cycle [${pattern}] ${count} times (period ${period}), with other calls possibly interleaved between repetitions. A fixed rotation usually means waiting, guessing, or searching without a discriminator:`,
34
+ `- if this is a wait/poll rotation (spawn then peek, write then check), replace the rotation with the monitor/watch tool and react to the decisive event instead;`,
35
+ `- if this is a search rotation, change ONE axis decisively: broader query, different tool, or a different source - repeating the same rotation at the same parameters will not find new information;`,
36
+ `- if the cycle is genuinely progressing (each rotation moves distinct work forward), keep going - but say what each rotation accomplished so the next rotation can end.`,
37
+ `</system-reminder>`,
38
+ ].join("\n");
39
+ }
40
+ }
41
+ }
42
+ //# sourceMappingURL=notice.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notice.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/loop-guard/notice.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,6BAA6B,GAAG,mBAAmB,CAAC;AAIjE,MAAM,UAAU,sBAAsB,CAAC,SAA6B;IACnE,QAAQ,SAAS,CAAC,IAAI,EAAE,CAAC;QACxB,KAAK,WAAW,EAAE,CAAC;YAClB,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,SAAS,CAAC;YACtC,OAAO;gBACN,mBAAmB;gBACnB,mDAAmD,QAAQ,MAAM,KAAK,oPAAoP;gBAC1T,+DAA+D;gBAC/D,mJAAmJ;gBACnJ,kIAAkI;gBAClI,iBAAiB,QAAQ,oCAAoC;gBAC7D,oBAAoB;aACpB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACd,CAAC;QACD,KAAK,SAAS,EAAE,CAAC;YAChB,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,UAAU,EAAE,GAAG,SAAS,CAAC;YAClD,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,GAAG,GAAG,CAAC,CAAC;YAC7C,OAAO;gBACN,mBAAmB;gBACnB,qDAAqD,KAAK,eAAe,QAAQ,0BAA0B,OAAO,mKAAmK;gBACrR,oMAAoM;gBACpM,uJAAuJ;gBACvJ,iJAAiJ;gBACjJ,oBAAoB;aACpB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACd,CAAC;QACD,KAAK,OAAO,EAAE,CAAC;YACd,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,GAAG,SAAS,CAAC;YAChD,MAAM,OAAO,GAAG,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YACxC,OAAO;gBACN,mBAAmB;gBACnB,sFAAsF,OAAO,KAAK,KAAK,kBAAkB,MAAM,uJAAuJ;gBACtR,kKAAkK;gBAClK,sMAAsM;gBACtM,yKAAyK;gBACzK,oBAAoB;aACpB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACd,CAAC;IACF,CAAC;AACF,CAAC","sourcesContent":["import type { LoopGuardDetection } from \"./detectors.ts\";\n\nexport const LOOP_GUARD_NOTICE_CUSTOM_TYPE = \"loop-guard:notice\";\n\nexport type LoopGuardNoticeDetails = LoopGuardDetection;\n\nexport function buildLoopGuardReminder(detection: LoopGuardDetection): string {\n\tswitch (detection.kind) {\n\t\tcase \"identical\": {\n\t\t\tconst { toolName, count } = detection;\n\t\t\treturn [\n\t\t\t\t`<system-reminder>`,\n\t\t\t\t`LOOP GUARD - IDENTICAL TOOL CALLS: you called \\`${toolName}\\` ${count} times in a row with the EXACT same arguments. This is the tool-call stream, not consecutive text - another tool ran between these calls and it changed nothing about your plan. Re-issuing the same call returns the same result. Snap out of it:`,\n\t\t\t\t`- reuse the result you already received from this exact call;`,\n\t\t\t\t`- if you were re-checking for new output or state, switch to the monitor/watch tool or change one parameter deliberately (filter, offset, query);`,\n\t\t\t\t`- if nothing is actually changing, stop calling this tool, state what is blocking you, and try a different tool or ask the user.`,\n\t\t\t\t`Do not call \\`${toolName}\\` again with identical arguments.`,\n\t\t\t\t`</system-reminder>`,\n\t\t\t].join(\"\\n\");\n\t\t}\n\t\tcase \"similar\": {\n\t\t\tconst { toolName, count, similarity } = detection;\n\t\t\tconst percent = Math.round(similarity * 100);\n\t\t\treturn [\n\t\t\t\t`<system-reminder>`,\n\t\t\t\t`LOOP GUARD - NEAR-IDENTICAL TOOL CALLS: your last ${count} calls to \\`${toolName}\\` had arguments about ${percent}% identical (bigram similarity over canonical args). This may be legitimate batch work - or it may be a lazy loop that only LOOKS like progress. Attention check:`,\n\t\t\t\t`- if these calls target genuinely different inputs (distinct files, queries, offsets), continue deliberately - but consider batching or widening the scope instead of one call per tiny variation;`,\n\t\t\t\t`- if you are scanning output incrementally (reads, peeks, polls), widen the window once or use the monitor/watch tool rather than nudging parameters;`,\n\t\t\t\t`- if the results keep saying the same thing, change strategy now - a different tool, a wider query, or asking the user beats a sixth near-copy.`,\n\t\t\t\t`</system-reminder>`,\n\t\t\t].join(\"\\n\");\n\t\t}\n\t\tcase \"cycle\": {\n\t\t\tconst { period, count, cycleTools } = detection;\n\t\t\tconst pattern = cycleTools.join(\" -> \");\n\t\t\treturn [\n\t\t\t\t`<system-reminder>`,\n\t\t\t\t`LOOP GUARD - REPEATING TOOL-CALL PATTERN: your recent tool calls repeat the cycle [${pattern}] ${count} times (period ${period}), with other calls possibly interleaved between repetitions. A fixed rotation usually means waiting, guessing, or searching without a discriminator:`,\n\t\t\t\t`- if this is a wait/poll rotation (spawn then peek, write then check), replace the rotation with the monitor/watch tool and react to the decisive event instead;`,\n\t\t\t\t`- if this is a search rotation, change ONE axis decisively: broader query, different tool, or a different source - repeating the same rotation at the same parameters will not find new information;`,\n\t\t\t\t`- if the cycle is genuinely progressing (each rotation moves distinct work forward), keep going - but say what each rotation accomplished so the next rotation can end.`,\n\t\t\t\t`</system-reminder>`,\n\t\t\t].join(\"\\n\");\n\t\t}\n\t}\n}\n"]}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Loop-guard thresholds.
3
+ *
4
+ * Evidence base (see changes.md for the full rationale):
5
+ * - gemini-cli LoopDetectionService: sha256(name+args) signatures, cycle periods 1..5,
6
+ * threshold 5 repetitions — but it HALTS the run. Loop-guard only steers a reminder,
7
+ * so it can afford to fire earlier.
8
+ * - OpenHands stuck detector: 4+ identical action-observation pairs, 3+ error cycles,
9
+ * 6+ alternating ping-pong cycles — also halting behavior.
10
+ * - Corpus of 400 real senpi sessions: productive same-tool runs (bash/eval/edit/todo)
11
+ * show mean adjacent-args bigram-Dice ~0.52-0.55 (p90 <= 0.72), while repetitive
12
+ * classes (read pagination, bash_output/task_output polling) sit at 0.84-0.93.
13
+ * 0.85 cleanly separates distinct work from near-identical repetition.
14
+ */
15
+ /** Max tool-call records kept per prompt segment. Covers 6-period cycles at escalated counts. */
16
+ export declare const TRACK_WINDOW = 64;
17
+ /** Consecutive byte-identical (tool + canonical args) calls before the firm reminder fires. */
18
+ export declare const IDENTICAL_RUN_THRESHOLD = 3;
19
+ /** Consecutive same-tool calls with near-identical args before the caution fires. */
20
+ export declare const SIMILAR_RUN_THRESHOLD = 5;
21
+ /** Mean adjacent bigram-Dice similarity over canonical args that counts as "near-identical". */
22
+ export declare const SIMILARITY_THRESHOLD = 0.85;
23
+ /** Cycle period bounds (period 1 is the identical detector's job). */
24
+ export declare const CYCLE_MIN_PERIOD = 2;
25
+ export declare const CYCLE_MAX_PERIOD = 6;
26
+ /** Full cycle repetitions before the pattern notice fires. */
27
+ export declare const CYCLE_REPETITION_THRESHOLD = 3;
28
+ /** A pattern that keeps growing re-notifies only when its count reaches this multiple of the last notice. */
29
+ export declare const ESCALATION_FACTOR = 2;
30
+ //# sourceMappingURL=policy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"policy.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/loop-guard/policy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,iGAAiG;AACjG,eAAO,MAAM,YAAY,KAAK,CAAC;AAE/B,+FAA+F;AAC/F,eAAO,MAAM,uBAAuB,IAAI,CAAC;AAEzC,qFAAqF;AACrF,eAAO,MAAM,qBAAqB,IAAI,CAAC;AAEvC,gGAAgG;AAChG,eAAO,MAAM,oBAAoB,OAAO,CAAC;AAEzC,sEAAsE;AACtE,eAAO,MAAM,gBAAgB,IAAI,CAAC;AAClC,eAAO,MAAM,gBAAgB,IAAI,CAAC;AAElC,8DAA8D;AAC9D,eAAO,MAAM,0BAA0B,IAAI,CAAC;AAE5C,6GAA6G;AAC7G,eAAO,MAAM,iBAAiB,IAAI,CAAC"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Loop-guard thresholds.
3
+ *
4
+ * Evidence base (see changes.md for the full rationale):
5
+ * - gemini-cli LoopDetectionService: sha256(name+args) signatures, cycle periods 1..5,
6
+ * threshold 5 repetitions — but it HALTS the run. Loop-guard only steers a reminder,
7
+ * so it can afford to fire earlier.
8
+ * - OpenHands stuck detector: 4+ identical action-observation pairs, 3+ error cycles,
9
+ * 6+ alternating ping-pong cycles — also halting behavior.
10
+ * - Corpus of 400 real senpi sessions: productive same-tool runs (bash/eval/edit/todo)
11
+ * show mean adjacent-args bigram-Dice ~0.52-0.55 (p90 <= 0.72), while repetitive
12
+ * classes (read pagination, bash_output/task_output polling) sit at 0.84-0.93.
13
+ * 0.85 cleanly separates distinct work from near-identical repetition.
14
+ */
15
+ /** Max tool-call records kept per prompt segment. Covers 6-period cycles at escalated counts. */
16
+ export const TRACK_WINDOW = 64;
17
+ /** Consecutive byte-identical (tool + canonical args) calls before the firm reminder fires. */
18
+ export const IDENTICAL_RUN_THRESHOLD = 3;
19
+ /** Consecutive same-tool calls with near-identical args before the caution fires. */
20
+ export const SIMILAR_RUN_THRESHOLD = 5;
21
+ /** Mean adjacent bigram-Dice similarity over canonical args that counts as "near-identical". */
22
+ export const SIMILARITY_THRESHOLD = 0.85;
23
+ /** Cycle period bounds (period 1 is the identical detector's job). */
24
+ export const CYCLE_MIN_PERIOD = 2;
25
+ export const CYCLE_MAX_PERIOD = 6;
26
+ /** Full cycle repetitions before the pattern notice fires. */
27
+ export const CYCLE_REPETITION_THRESHOLD = 3;
28
+ /** A pattern that keeps growing re-notifies only when its count reaches this multiple of the last notice. */
29
+ export const ESCALATION_FACTOR = 2;
30
+ //# sourceMappingURL=policy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"policy.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/loop-guard/policy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,iGAAiG;AACjG,MAAM,CAAC,MAAM,YAAY,GAAG,EAAE,CAAC;AAE/B,+FAA+F;AAC/F,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,CAAC;AAEzC,qFAAqF;AACrF,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC;AAEvC,gGAAgG;AAChG,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,CAAC;AAEzC,sEAAsE;AACtE,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAClC,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAElC,8DAA8D;AAC9D,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,CAAC;AAE5C,6GAA6G;AAC7G,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC","sourcesContent":["/**\n * Loop-guard thresholds.\n *\n * Evidence base (see changes.md for the full rationale):\n * - gemini-cli LoopDetectionService: sha256(name+args) signatures, cycle periods 1..5,\n * threshold 5 repetitions — but it HALTS the run. Loop-guard only steers a reminder,\n * so it can afford to fire earlier.\n * - OpenHands stuck detector: 4+ identical action-observation pairs, 3+ error cycles,\n * 6+ alternating ping-pong cycles — also halting behavior.\n * - Corpus of 400 real senpi sessions: productive same-tool runs (bash/eval/edit/todo)\n * show mean adjacent-args bigram-Dice ~0.52-0.55 (p90 <= 0.72), while repetitive\n * classes (read pagination, bash_output/task_output polling) sit at 0.84-0.93.\n * 0.85 cleanly separates distinct work from near-identical repetition.\n */\n\n/** Max tool-call records kept per prompt segment. Covers 6-period cycles at escalated counts. */\nexport const TRACK_WINDOW = 64;\n\n/** Consecutive byte-identical (tool + canonical args) calls before the firm reminder fires. */\nexport const IDENTICAL_RUN_THRESHOLD = 3;\n\n/** Consecutive same-tool calls with near-identical args before the caution fires. */\nexport const SIMILAR_RUN_THRESHOLD = 5;\n\n/** Mean adjacent bigram-Dice similarity over canonical args that counts as \"near-identical\". */\nexport const SIMILARITY_THRESHOLD = 0.85;\n\n/** Cycle period bounds (period 1 is the identical detector's job). */\nexport const CYCLE_MIN_PERIOD = 2;\nexport const CYCLE_MAX_PERIOD = 6;\n\n/** Full cycle repetitions before the pattern notice fires. */\nexport const CYCLE_REPETITION_THRESHOLD = 3;\n\n/** A pattern that keeps growing re-notifies only when its count reaches this multiple of the last notice. */\nexport const ESCALATION_FACTOR = 2;\n"]}
@@ -0,0 +1,4 @@
1
+ import type { MessageRenderer } from "../../types.ts";
2
+ import type { LoopGuardDetection } from "./detectors.ts";
3
+ export declare const renderLoopGuardNotice: MessageRenderer<LoopGuardDetection>;
4
+ //# sourceMappingURL=renderer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renderer.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/loop-guard/renderer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAKzD,eAAO,MAAM,qBAAqB,EAAE,eAAe,CAAC,kBAAkB,CAUrE,CAAC"}