@caupulican/pi-adaptative 0.80.103 → 0.81.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 (409) hide show
  1. package/CHANGELOG.md +128 -0
  2. package/dist/cli/session-picker.d.ts +1 -1
  3. package/dist/cli/session-picker.d.ts.map +1 -1
  4. package/dist/cli/session-picker.js.map +1 -1
  5. package/dist/cli.d.ts.map +1 -1
  6. package/dist/cli.js +7 -1
  7. package/dist/cli.js.map +1 -1
  8. package/dist/core/agent-session-runtime.d.ts +1 -1
  9. package/dist/core/agent-session-runtime.d.ts.map +1 -1
  10. package/dist/core/agent-session-runtime.js +6 -6
  11. package/dist/core/agent-session-runtime.js.map +1 -1
  12. package/dist/core/agent-session-services.d.ts +1 -1
  13. package/dist/core/agent-session-services.d.ts.map +1 -1
  14. package/dist/core/agent-session-services.js.map +1 -1
  15. package/dist/core/agent-session.d.ts +154 -512
  16. package/dist/core/agent-session.d.ts.map +1 -1
  17. package/dist/core/agent-session.js +675 -4589
  18. package/dist/core/agent-session.js.map +1 -1
  19. package/dist/core/autonomy/session-lane-record.d.ts +1 -1
  20. package/dist/core/autonomy/session-lane-record.d.ts.map +1 -1
  21. package/dist/core/autonomy/session-lane-record.js.map +1 -1
  22. package/dist/core/autonomy/status.d.ts +1 -0
  23. package/dist/core/autonomy/status.d.ts.map +1 -1
  24. package/dist/core/autonomy/status.js +1 -0
  25. package/dist/core/autonomy/status.js.map +1 -1
  26. package/dist/core/autonomy-telemetry.d.ts +80 -0
  27. package/dist/core/autonomy-telemetry.d.ts.map +1 -0
  28. package/dist/core/autonomy-telemetry.js +266 -0
  29. package/dist/core/autonomy-telemetry.js.map +1 -0
  30. package/dist/core/background-lane-controller.d.ts +186 -0
  31. package/dist/core/background-lane-controller.d.ts.map +1 -0
  32. package/dist/core/background-lane-controller.js +691 -0
  33. package/dist/core/background-lane-controller.js.map +1 -0
  34. package/dist/core/bash-execution-controller.d.ts +51 -0
  35. package/dist/core/bash-execution-controller.d.ts.map +1 -0
  36. package/dist/core/bash-execution-controller.js +96 -0
  37. package/dist/core/bash-execution-controller.js.map +1 -0
  38. package/dist/core/bash-executor.d.ts.map +1 -1
  39. package/dist/core/bash-executor.js +9 -2
  40. package/dist/core/bash-executor.js.map +1 -1
  41. package/dist/core/compaction-support.d.ts +56 -0
  42. package/dist/core/compaction-support.d.ts.map +1 -0
  43. package/dist/core/compaction-support.js +99 -0
  44. package/dist/core/compaction-support.js.map +1 -0
  45. package/dist/core/context/artifact-retrieval.d.ts +1 -1
  46. package/dist/core/context/artifact-retrieval.d.ts.map +1 -1
  47. package/dist/core/context/artifact-retrieval.js +1 -1
  48. package/dist/core/context/artifact-retrieval.js.map +1 -1
  49. package/dist/core/context/context-composition.d.ts.map +1 -1
  50. package/dist/core/context/context-composition.js +1 -1
  51. package/dist/core/context/context-composition.js.map +1 -1
  52. package/dist/core/context/tool-output-packer.d.ts +1 -1
  53. package/dist/core/context/tool-output-packer.d.ts.map +1 -1
  54. package/dist/core/context/tool-output-packer.js +1 -1
  55. package/dist/core/context/tool-output-packer.js.map +1 -1
  56. package/dist/core/context-gc.d.ts.map +1 -1
  57. package/dist/core/context-gc.js +1 -1
  58. package/dist/core/context-gc.js.map +1 -1
  59. package/dist/core/context-pipeline.d.ts +223 -0
  60. package/dist/core/context-pipeline.d.ts.map +1 -0
  61. package/dist/core/context-pipeline.js +594 -0
  62. package/dist/core/context-pipeline.js.map +1 -0
  63. package/dist/core/cost/daily-usage.d.ts +1 -1
  64. package/dist/core/cost/daily-usage.d.ts.map +1 -1
  65. package/dist/core/cost/daily-usage.js +1 -1
  66. package/dist/core/cost/daily-usage.js.map +1 -1
  67. package/dist/core/cost/session-usage.d.ts +1 -1
  68. package/dist/core/cost/session-usage.d.ts.map +1 -1
  69. package/dist/core/cost/session-usage.js +1 -1
  70. package/dist/core/cost/session-usage.js.map +1 -1
  71. package/dist/core/delegation/session-worker-result.d.ts +1 -1
  72. package/dist/core/delegation/session-worker-result.d.ts.map +1 -1
  73. package/dist/core/delegation/session-worker-result.js.map +1 -1
  74. package/dist/core/exec.d.ts +2 -0
  75. package/dist/core/exec.d.ts.map +1 -1
  76. package/dist/core/exec.js +15 -9
  77. package/dist/core/exec.js.map +1 -1
  78. package/dist/core/export-html/index.d.ts +1 -1
  79. package/dist/core/export-html/index.d.ts.map +1 -1
  80. package/dist/core/export-html/index.js +2 -2
  81. package/dist/core/export-html/index.js.map +1 -1
  82. package/dist/core/extensions/builtin.d.ts.map +1 -1
  83. package/dist/core/extensions/builtin.js +2 -2
  84. package/dist/core/extensions/builtin.js.map +1 -1
  85. package/dist/core/extensions/runner.d.ts +1 -1
  86. package/dist/core/extensions/runner.d.ts.map +1 -1
  87. package/dist/core/extensions/runner.js.map +1 -1
  88. package/dist/core/extensions/types.d.ts +2 -4
  89. package/dist/core/extensions/types.d.ts.map +1 -1
  90. package/dist/core/extensions/types.js.map +1 -1
  91. package/dist/core/goal-loop-controller.d.ts +24 -0
  92. package/dist/core/goal-loop-controller.d.ts.map +1 -0
  93. package/dist/core/goal-loop-controller.js +83 -0
  94. package/dist/core/goal-loop-controller.js.map +1 -0
  95. package/dist/core/goals/goal-runtime-snapshot.d.ts +1 -1
  96. package/dist/core/goals/goal-runtime-snapshot.d.ts.map +1 -1
  97. package/dist/core/goals/goal-runtime-snapshot.js.map +1 -1
  98. package/dist/core/goals/session-goal-state.d.ts +1 -1
  99. package/dist/core/goals/session-goal-state.d.ts.map +1 -1
  100. package/dist/core/goals/session-goal-state.js.map +1 -1
  101. package/dist/core/http-dispatcher.d.ts +4 -1
  102. package/dist/core/http-dispatcher.d.ts.map +1 -1
  103. package/dist/core/http-dispatcher.js +6 -1
  104. package/dist/core/http-dispatcher.js.map +1 -1
  105. package/dist/core/index.d.ts +1 -1
  106. package/dist/core/index.d.ts.map +1 -1
  107. package/dist/core/index.js.map +1 -1
  108. package/dist/core/learning/learning-audit.d.ts +1 -1
  109. package/dist/core/learning/learning-audit.d.ts.map +1 -1
  110. package/dist/core/learning/learning-audit.js.map +1 -1
  111. package/dist/core/learning/session-learning-decision.d.ts +1 -1
  112. package/dist/core/learning/session-learning-decision.d.ts.map +1 -1
  113. package/dist/core/learning/session-learning-decision.js.map +1 -1
  114. package/dist/core/local-runtime-controller.d.ts +99 -0
  115. package/dist/core/local-runtime-controller.d.ts.map +1 -0
  116. package/dist/core/local-runtime-controller.js +214 -0
  117. package/dist/core/local-runtime-controller.js.map +1 -0
  118. package/dist/core/memory/providers/transcript-recall.d.ts.map +1 -1
  119. package/dist/core/memory/providers/transcript-recall.js +1 -1
  120. package/dist/core/memory/providers/transcript-recall.js.map +1 -1
  121. package/dist/core/memory-controller.d.ts +139 -0
  122. package/dist/core/memory-controller.d.ts.map +1 -0
  123. package/dist/core/memory-controller.js +323 -0
  124. package/dist/core/memory-controller.js.map +1 -0
  125. package/dist/core/model-router/status.d.ts +1 -1
  126. package/dist/core/model-router/status.d.ts.map +1 -1
  127. package/dist/core/model-router/status.js.map +1 -1
  128. package/dist/core/model-router-controller.d.ts +140 -0
  129. package/dist/core/model-router-controller.d.ts.map +1 -0
  130. package/dist/core/model-router-controller.js +623 -0
  131. package/dist/core/model-router-controller.js.map +1 -0
  132. package/dist/core/model-selection-controller.d.ts +95 -0
  133. package/dist/core/model-selection-controller.d.ts.map +1 -0
  134. package/dist/core/model-selection-controller.js +252 -0
  135. package/dist/core/model-selection-controller.js.map +1 -0
  136. package/dist/core/models/model-ref.d.ts +13 -0
  137. package/dist/core/models/model-ref.d.ts.map +1 -1
  138. package/dist/core/models/model-ref.js +22 -0
  139. package/dist/core/models/model-ref.js.map +1 -1
  140. package/dist/core/profile-filter-controller.d.ts +77 -0
  141. package/dist/core/profile-filter-controller.d.ts.map +1 -0
  142. package/dist/core/profile-filter-controller.js +159 -0
  143. package/dist/core/profile-filter-controller.js.map +1 -0
  144. package/dist/core/reflection-controller.d.ts +111 -0
  145. package/dist/core/reflection-controller.d.ts.map +1 -0
  146. package/dist/core/reflection-controller.js +412 -0
  147. package/dist/core/reflection-controller.js.map +1 -0
  148. package/dist/core/research/model-fitness.d.ts +12 -0
  149. package/dist/core/research/model-fitness.d.ts.map +1 -1
  150. package/dist/core/research/model-fitness.js +21 -0
  151. package/dist/core/research/model-fitness.js.map +1 -1
  152. package/dist/core/research/session-evidence-bundle.d.ts +1 -1
  153. package/dist/core/research/session-evidence-bundle.d.ts.map +1 -1
  154. package/dist/core/research/session-evidence-bundle.js.map +1 -1
  155. package/dist/core/runtime-builder.d.ts +222 -0
  156. package/dist/core/runtime-builder.d.ts.map +1 -0
  157. package/dist/core/runtime-builder.js +640 -0
  158. package/dist/core/runtime-builder.js.map +1 -0
  159. package/dist/core/sdk.d.ts +2 -2
  160. package/dist/core/sdk.d.ts.map +1 -1
  161. package/dist/core/sdk.js +3 -4
  162. package/dist/core/sdk.js.map +1 -1
  163. package/dist/core/session-analytics.d.ts +96 -0
  164. package/dist/core/session-analytics.d.ts.map +1 -0
  165. package/dist/core/session-analytics.js +331 -0
  166. package/dist/core/session-analytics.js.map +1 -0
  167. package/dist/core/session-manager-factory.d.ts +18 -0
  168. package/dist/core/session-manager-factory.d.ts.map +1 -0
  169. package/dist/core/session-manager-factory.js +32 -0
  170. package/dist/core/session-manager-factory.js.map +1 -0
  171. package/dist/core/session-tree-navigator.d.ts +68 -0
  172. package/dist/core/session-tree-navigator.d.ts.map +1 -0
  173. package/dist/core/session-tree-navigator.js +217 -0
  174. package/dist/core/session-tree-navigator.js.map +1 -0
  175. package/dist/core/settings-manager.d.ts +16 -0
  176. package/dist/core/settings-manager.d.ts.map +1 -1
  177. package/dist/core/settings-manager.js +22 -0
  178. package/dist/core/settings-manager.js.map +1 -1
  179. package/dist/core/system-prompt-builder.d.ts +63 -0
  180. package/dist/core/system-prompt-builder.d.ts.map +1 -0
  181. package/dist/core/system-prompt-builder.js +181 -0
  182. package/dist/core/system-prompt-builder.js.map +1 -0
  183. package/dist/core/tool-gate-controller.d.ts +36 -0
  184. package/dist/core/tool-gate-controller.d.ts.map +1 -0
  185. package/dist/core/tool-gate-controller.js +94 -0
  186. package/dist/core/tool-gate-controller.js.map +1 -0
  187. package/dist/core/tools/artifact-retrieve.d.ts.map +1 -1
  188. package/dist/core/tools/artifact-retrieve.js +1 -1
  189. package/dist/core/tools/artifact-retrieve.js.map +1 -1
  190. package/dist/core/tools/bash.d.ts +4 -2
  191. package/dist/core/tools/bash.d.ts.map +1 -1
  192. package/dist/core/tools/bash.js +49 -7
  193. package/dist/core/tools/bash.js.map +1 -1
  194. package/dist/core/tools/file-mutation-queue.d.ts +6 -0
  195. package/dist/core/tools/file-mutation-queue.d.ts.map +1 -1
  196. package/dist/core/tools/file-mutation-queue.js +61 -1
  197. package/dist/core/tools/file-mutation-queue.js.map +1 -1
  198. package/dist/core/tools/find.d.ts +1 -1
  199. package/dist/core/tools/find.d.ts.map +1 -1
  200. package/dist/core/tools/find.js +1 -1
  201. package/dist/core/tools/find.js.map +1 -1
  202. package/dist/core/tools/grep.d.ts +1 -1
  203. package/dist/core/tools/grep.d.ts.map +1 -1
  204. package/dist/core/tools/grep.js +1 -1
  205. package/dist/core/tools/grep.js.map +1 -1
  206. package/dist/core/tools/index.d.ts +1 -1
  207. package/dist/core/tools/index.d.ts.map +1 -1
  208. package/dist/core/tools/index.js +1 -1
  209. package/dist/core/tools/index.js.map +1 -1
  210. package/dist/core/tools/ls.d.ts +1 -1
  211. package/dist/core/tools/ls.d.ts.map +1 -1
  212. package/dist/core/tools/ls.js +1 -1
  213. package/dist/core/tools/ls.js.map +1 -1
  214. package/dist/core/tools/output-accumulator.d.ts +1 -1
  215. package/dist/core/tools/output-accumulator.d.ts.map +1 -1
  216. package/dist/core/tools/output-accumulator.js +1 -1
  217. package/dist/core/tools/output-accumulator.js.map +1 -1
  218. package/dist/core/tools/read.d.ts +1 -1
  219. package/dist/core/tools/read.d.ts.map +1 -1
  220. package/dist/core/tools/read.js +1 -1
  221. package/dist/core/tools/read.js.map +1 -1
  222. package/dist/core/tools/render-utils.d.ts.map +1 -1
  223. package/dist/core/tools/render-utils.js +1 -1
  224. package/dist/core/tools/render-utils.js.map +1 -1
  225. package/dist/index.d.ts +2 -3
  226. package/dist/index.d.ts.map +1 -1
  227. package/dist/index.js +3 -4
  228. package/dist/index.js.map +1 -1
  229. package/dist/main.d.ts.map +1 -1
  230. package/dist/main.js +13 -12
  231. package/dist/main.js.map +1 -1
  232. package/dist/modes/interactive/auth-dialogs-controller.d.ts +59 -0
  233. package/dist/modes/interactive/auth-dialogs-controller.d.ts.map +1 -0
  234. package/dist/modes/interactive/auth-dialogs-controller.js +398 -0
  235. package/dist/modes/interactive/auth-dialogs-controller.js.map +1 -0
  236. package/dist/modes/interactive/auto-learn-controller.d.ts +168 -0
  237. package/dist/modes/interactive/auto-learn-controller.d.ts.map +1 -0
  238. package/dist/modes/interactive/auto-learn-controller.js +1239 -0
  239. package/dist/modes/interactive/auto-learn-controller.js.map +1 -0
  240. package/dist/modes/interactive/autocomplete-provider.d.ts +26 -0
  241. package/dist/modes/interactive/autocomplete-provider.d.ts.map +1 -0
  242. package/dist/modes/interactive/autocomplete-provider.js +103 -0
  243. package/dist/modes/interactive/autocomplete-provider.js.map +1 -0
  244. package/dist/modes/interactive/autonomy-commands.d.ts +38 -0
  245. package/dist/modes/interactive/autonomy-commands.d.ts.map +1 -0
  246. package/dist/modes/interactive/autonomy-commands.js +142 -0
  247. package/dist/modes/interactive/autonomy-commands.js.map +1 -0
  248. package/dist/modes/interactive/clipboard-input.d.ts +37 -0
  249. package/dist/modes/interactive/clipboard-input.d.ts.map +1 -0
  250. package/dist/modes/interactive/clipboard-input.js +59 -0
  251. package/dist/modes/interactive/clipboard-input.js.map +1 -0
  252. package/dist/modes/interactive/compaction-queue.d.ts +30 -0
  253. package/dist/modes/interactive/compaction-queue.d.ts.map +1 -0
  254. package/dist/modes/interactive/compaction-queue.js +91 -0
  255. package/dist/modes/interactive/compaction-queue.js.map +1 -0
  256. package/dist/modes/interactive/components/bash-execution.d.ts +1 -1
  257. package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -1
  258. package/dist/modes/interactive/components/bash-execution.js +1 -1
  259. package/dist/modes/interactive/components/bash-execution.js.map +1 -1
  260. package/dist/modes/interactive/components/branch-summary-message.d.ts +1 -1
  261. package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -1
  262. package/dist/modes/interactive/components/branch-summary-message.js.map +1 -1
  263. package/dist/modes/interactive/components/compaction-summary-message.d.ts +1 -1
  264. package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -1
  265. package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -1
  266. package/dist/modes/interactive/components/custom-message.d.ts +1 -1
  267. package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
  268. package/dist/modes/interactive/components/custom-message.js.map +1 -1
  269. package/dist/modes/interactive/components/session-selector-search.d.ts +1 -1
  270. package/dist/modes/interactive/components/session-selector-search.d.ts.map +1 -1
  271. package/dist/modes/interactive/components/session-selector-search.js.map +1 -1
  272. package/dist/modes/interactive/components/session-selector.d.ts +1 -1
  273. package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
  274. package/dist/modes/interactive/components/session-selector.js.map +1 -1
  275. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  276. package/dist/modes/interactive/components/tool-execution.js +2 -2
  277. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  278. package/dist/modes/interactive/components/tree-selector.d.ts +1 -1
  279. package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
  280. package/dist/modes/interactive/components/tree-selector.js.map +1 -1
  281. package/dist/modes/interactive/config-backup.d.ts +27 -0
  282. package/dist/modes/interactive/config-backup.d.ts.map +1 -0
  283. package/dist/modes/interactive/config-backup.js +146 -0
  284. package/dist/modes/interactive/config-backup.js.map +1 -0
  285. package/dist/modes/interactive/editor-overlay-host.d.ts +48 -0
  286. package/dist/modes/interactive/editor-overlay-host.d.ts.map +1 -0
  287. package/dist/modes/interactive/editor-overlay-host.js +43 -0
  288. package/dist/modes/interactive/editor-overlay-host.js.map +1 -0
  289. package/dist/modes/interactive/extension-ui-host.d.ts +165 -0
  290. package/dist/modes/interactive/extension-ui-host.d.ts.map +1 -0
  291. package/dist/modes/interactive/extension-ui-host.js +610 -0
  292. package/dist/modes/interactive/extension-ui-host.js.map +1 -0
  293. package/dist/modes/interactive/external-editor.d.ts +18 -0
  294. package/dist/modes/interactive/external-editor.d.ts.map +1 -0
  295. package/dist/modes/interactive/external-editor.js +107 -0
  296. package/dist/modes/interactive/external-editor.js.map +1 -0
  297. package/dist/modes/interactive/history-reload-math.d.ts +24 -0
  298. package/dist/modes/interactive/history-reload-math.d.ts.map +1 -0
  299. package/dist/modes/interactive/history-reload-math.js +129 -0
  300. package/dist/modes/interactive/history-reload-math.js.map +1 -0
  301. package/dist/modes/interactive/interactive-mode.d.ts +22 -238
  302. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  303. package/dist/modes/interactive/interactive-mode.js +714 -5910
  304. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  305. package/dist/modes/interactive/key-handlers.d.ts +46 -0
  306. package/dist/modes/interactive/key-handlers.d.ts.map +1 -0
  307. package/dist/modes/interactive/key-handlers.js +80 -0
  308. package/dist/modes/interactive/key-handlers.js.map +1 -0
  309. package/dist/modes/interactive/local-model-commands.d.ts +68 -0
  310. package/dist/modes/interactive/local-model-commands.d.ts.map +1 -0
  311. package/dist/modes/interactive/local-model-commands.js +288 -0
  312. package/dist/modes/interactive/local-model-commands.js.map +1 -0
  313. package/dist/modes/interactive/profile-menu-controller.d.ts +77 -0
  314. package/dist/modes/interactive/profile-menu-controller.d.ts.map +1 -0
  315. package/dist/modes/interactive/profile-menu-controller.js +917 -0
  316. package/dist/modes/interactive/profile-menu-controller.js.map +1 -0
  317. package/dist/modes/interactive/report-commands.d.ts +46 -0
  318. package/dist/modes/interactive/report-commands.d.ts.map +1 -0
  319. package/dist/modes/interactive/report-commands.js +255 -0
  320. package/dist/modes/interactive/report-commands.js.map +1 -0
  321. package/dist/modes/interactive/resource-display.d.ts +73 -0
  322. package/dist/modes/interactive/resource-display.d.ts.map +1 -0
  323. package/dist/modes/interactive/resource-display.js +278 -0
  324. package/dist/modes/interactive/resource-display.js.map +1 -0
  325. package/dist/modes/interactive/resource-shell-commands.d.ts +64 -0
  326. package/dist/modes/interactive/resource-shell-commands.d.ts.map +1 -0
  327. package/dist/modes/interactive/resource-shell-commands.js +202 -0
  328. package/dist/modes/interactive/resource-shell-commands.js.map +1 -0
  329. package/dist/modes/interactive/session-flow-commands.d.ts +139 -0
  330. package/dist/modes/interactive/session-flow-commands.d.ts.map +1 -0
  331. package/dist/modes/interactive/session-flow-commands.js +458 -0
  332. package/dist/modes/interactive/session-flow-commands.js.map +1 -0
  333. package/dist/modes/interactive/session-io-commands.d.ts +73 -0
  334. package/dist/modes/interactive/session-io-commands.d.ts.map +1 -0
  335. package/dist/modes/interactive/session-io-commands.js +202 -0
  336. package/dist/modes/interactive/session-io-commands.js.map +1 -0
  337. package/dist/modes/interactive/settings-selector-flow.d.ts +42 -0
  338. package/dist/modes/interactive/settings-selector-flow.d.ts.map +1 -0
  339. package/dist/modes/interactive/settings-selector-flow.js +287 -0
  340. package/dist/modes/interactive/settings-selector-flow.js.map +1 -0
  341. package/dist/modes/interactive/signal-lifecycle.d.ts +55 -0
  342. package/dist/modes/interactive/signal-lifecycle.d.ts.map +1 -0
  343. package/dist/modes/interactive/signal-lifecycle.js +177 -0
  344. package/dist/modes/interactive/signal-lifecycle.js.map +1 -0
  345. package/dist/modes/interactive/startup-checks.d.ts +38 -0
  346. package/dist/modes/interactive/startup-checks.d.ts.map +1 -0
  347. package/dist/modes/interactive/startup-checks.js +189 -0
  348. package/dist/modes/interactive/startup-checks.js.map +1 -0
  349. package/dist/modes/rpc/rpc-client.d.ts +1 -1
  350. package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
  351. package/dist/modes/rpc/rpc-client.js.map +1 -1
  352. package/dist/modes/rpc/rpc-types.d.ts +1 -1
  353. package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
  354. package/dist/modes/rpc/rpc-types.js.map +1 -1
  355. package/dist/utils/paths.d.ts +2 -14
  356. package/dist/utils/paths.d.ts.map +1 -1
  357. package/dist/utils/paths.js +5 -30
  358. package/dist/utils/paths.js.map +1 -1
  359. package/dist/utils/process-memory.d.ts +8 -0
  360. package/dist/utils/process-memory.d.ts.map +1 -0
  361. package/dist/utils/process-memory.js +11 -0
  362. package/dist/utils/process-memory.js.map +1 -0
  363. package/dist/utils/shell.d.ts +0 -9
  364. package/dist/utils/shell.d.ts.map +1 -1
  365. package/dist/utils/shell.js +0 -37
  366. package/dist/utils/shell.js.map +1 -1
  367. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  368. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  369. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  370. package/examples/extensions/sandbox/package-lock.json +2 -2
  371. package/examples/extensions/sandbox/package.json +1 -1
  372. package/examples/extensions/with-deps/package-lock.json +2 -2
  373. package/examples/extensions/with-deps/package.json +1 -1
  374. package/examples/sdk/11-sessions.ts +8 -8
  375. package/examples/sdk/13-session-runtime.ts +1 -1
  376. package/npm-shrinkwrap.json +12 -12
  377. package/package.json +4 -4
  378. package/dist/core/compaction/branch-summarization.d.ts +0 -88
  379. package/dist/core/compaction/branch-summarization.d.ts.map +0 -1
  380. package/dist/core/compaction/branch-summarization.js +0 -243
  381. package/dist/core/compaction/branch-summarization.js.map +0 -1
  382. package/dist/core/compaction/compaction.d.ts +0 -143
  383. package/dist/core/compaction/compaction.d.ts.map +0 -1
  384. package/dist/core/compaction/compaction.js +0 -659
  385. package/dist/core/compaction/compaction.js.map +0 -1
  386. package/dist/core/compaction/index.d.ts +0 -7
  387. package/dist/core/compaction/index.d.ts.map +0 -1
  388. package/dist/core/compaction/index.js +0 -7
  389. package/dist/core/compaction/index.js.map +0 -1
  390. package/dist/core/compaction/utils.d.ts +0 -38
  391. package/dist/core/compaction/utils.d.ts.map +0 -1
  392. package/dist/core/compaction/utils.js +0 -153
  393. package/dist/core/compaction/utils.js.map +0 -1
  394. package/dist/core/message-retention.d.ts +0 -26
  395. package/dist/core/message-retention.d.ts.map +0 -1
  396. package/dist/core/message-retention.js +0 -95
  397. package/dist/core/message-retention.js.map +0 -1
  398. package/dist/core/messages.d.ts +0 -77
  399. package/dist/core/messages.d.ts.map +0 -1
  400. package/dist/core/messages.js +0 -123
  401. package/dist/core/messages.js.map +0 -1
  402. package/dist/core/session-manager.d.ts +0 -337
  403. package/dist/core/session-manager.d.ts.map +0 -1
  404. package/dist/core/session-manager.js +0 -1328
  405. package/dist/core/session-manager.js.map +0 -1
  406. package/dist/core/tools/truncate.d.ts +0 -70
  407. package/dist/core/tools/truncate.d.ts.map +0 -1
  408. package/dist/core/tools/truncate.js +0 -215
  409. package/dist/core/tools/truncate.js.map +0 -1
@@ -0,0 +1,217 @@
1
+ /**
2
+ * Session-tree navigation (in-file branch switching + fork-selector reads).
3
+ *
4
+ * Extracted verbatim from agent-session.ts (god-file decomposition). `navigateTree` moves the leaf
5
+ * to another node in the SAME session file (unlike fork(), which creates a new file), optionally
6
+ * summarizing the abandoned branch via the model or an extension override. It owns no state: the
7
+ * branch-summary abort controller stays on the session (also read by `isCompacting`) and is set/cleared
8
+ * here through a dep so the session's abort/compacting surface is untouched.
9
+ */
10
+ import { collectEntriesForBranchSummary, generateBranchSummary, } from "@caupulican/pi-agent-core/node";
11
+ export class SessionTreeNavigator {
12
+ deps;
13
+ constructor(deps) {
14
+ this.deps = deps;
15
+ }
16
+ /**
17
+ * Navigate to a different node in the session tree.
18
+ * Unlike fork() which creates a new session file, this stays in the same file.
19
+ *
20
+ * @param targetId The entry ID to navigate to
21
+ * @param options.summarize Whether user wants to summarize abandoned branch
22
+ * @param options.customInstructions Custom instructions for summarizer
23
+ * @param options.replaceInstructions If true, customInstructions replaces the default prompt
24
+ * @param options.label Label to attach to the branch summary entry
25
+ * @returns Result with editorText (if user message) and cancelled status
26
+ */
27
+ async navigateTree(targetId, options = {}) {
28
+ const sessionManager = this.deps.getSessionManager();
29
+ const extensionRunner = this.deps.getExtensionRunner();
30
+ const oldLeafId = sessionManager.getLeafId();
31
+ // No-op if already at target
32
+ if (targetId === oldLeafId) {
33
+ return { cancelled: false };
34
+ }
35
+ // Model required for summarization
36
+ if (options.summarize && !this.deps.getModel()) {
37
+ throw new Error("No model available for summarization");
38
+ }
39
+ const targetEntry = sessionManager.getEntry(targetId);
40
+ if (!targetEntry) {
41
+ throw new Error(`Entry ${targetId} not found`);
42
+ }
43
+ // Collect entries to summarize (from old leaf to common ancestor)
44
+ const { entries: entriesToSummarize, commonAncestorId } = collectEntriesForBranchSummary(sessionManager, oldLeafId, targetId);
45
+ // Prepare event data - mutable so extensions can override
46
+ let customInstructions = options.customInstructions;
47
+ let replaceInstructions = options.replaceInstructions;
48
+ let label = options.label;
49
+ const preparation = {
50
+ targetId,
51
+ oldLeafId,
52
+ commonAncestorId,
53
+ entriesToSummarize,
54
+ userWantsSummary: options.summarize ?? false,
55
+ customInstructions,
56
+ replaceInstructions,
57
+ label,
58
+ };
59
+ // Set up abort controller for summarization
60
+ const branchSummaryAbort = new AbortController();
61
+ this.deps.setBranchSummaryAbort(branchSummaryAbort);
62
+ try {
63
+ let extensionSummary;
64
+ let fromExtension = false;
65
+ // Emit session_before_tree event
66
+ if (extensionRunner.hasHandlers("session_before_tree")) {
67
+ const result = (await extensionRunner.emit({
68
+ type: "session_before_tree",
69
+ preparation,
70
+ signal: branchSummaryAbort.signal,
71
+ }));
72
+ if (result?.cancel) {
73
+ return { cancelled: true };
74
+ }
75
+ if (result?.summary && options.summarize) {
76
+ extensionSummary = result.summary;
77
+ fromExtension = true;
78
+ }
79
+ // Allow extensions to override instructions and label
80
+ if (result?.customInstructions !== undefined) {
81
+ customInstructions = result.customInstructions;
82
+ }
83
+ if (result?.replaceInstructions !== undefined) {
84
+ replaceInstructions = result.replaceInstructions;
85
+ }
86
+ if (result?.label !== undefined) {
87
+ label = result.label;
88
+ }
89
+ }
90
+ // Run default summarizer if needed
91
+ let summaryText;
92
+ let summaryDetails;
93
+ if (options.summarize && entriesToSummarize.length > 0 && !extensionSummary) {
94
+ const model = this.deps.getModel();
95
+ const { apiKey, headers } = await this.deps.getRequiredRequestAuth(model);
96
+ const branchSummarySettings = this.deps.getSettingsManager().getBranchSummarySettings();
97
+ const result = await generateBranchSummary(entriesToSummarize, {
98
+ model,
99
+ apiKey,
100
+ headers,
101
+ signal: branchSummaryAbort.signal,
102
+ customInstructions,
103
+ replaceInstructions,
104
+ reserveTokens: branchSummarySettings.reserveTokens,
105
+ });
106
+ if (result.aborted) {
107
+ return { cancelled: true, aborted: true };
108
+ }
109
+ if (result.error) {
110
+ throw new Error(result.error);
111
+ }
112
+ summaryText = result.summary;
113
+ summaryDetails = {
114
+ readFiles: result.readFiles || [],
115
+ modifiedFiles: result.modifiedFiles || [],
116
+ };
117
+ }
118
+ else if (extensionSummary) {
119
+ summaryText = extensionSummary.summary;
120
+ summaryDetails = extensionSummary.details;
121
+ }
122
+ // Determine the new leaf position based on target type
123
+ let newLeafId;
124
+ let editorText;
125
+ if (targetEntry.type === "message" && targetEntry.message.role === "user") {
126
+ // User message: leaf = parent (null if root), text goes to editor
127
+ newLeafId = targetEntry.parentId;
128
+ editorText = this._extractUserMessageText(targetEntry.message.content);
129
+ }
130
+ else if (targetEntry.type === "custom_message") {
131
+ // Custom message: leaf = parent (null if root), text goes to editor
132
+ newLeafId = targetEntry.parentId;
133
+ editorText =
134
+ typeof targetEntry.content === "string"
135
+ ? targetEntry.content
136
+ : targetEntry.content
137
+ .filter((c) => c.type === "text")
138
+ .map((c) => c.text)
139
+ .join("");
140
+ }
141
+ else {
142
+ // Non-user message: leaf = selected node
143
+ newLeafId = targetId;
144
+ }
145
+ // Switch leaf (with or without summary)
146
+ // Summary is attached at the navigation target position (newLeafId), not the old branch
147
+ let summaryEntry;
148
+ if (summaryText) {
149
+ // Create summary at target position (can be null for root)
150
+ const summaryId = sessionManager.branchWithSummary(newLeafId, summaryText, summaryDetails, fromExtension);
151
+ summaryEntry = sessionManager.getEntry(summaryId);
152
+ // Attach label to the summary entry
153
+ if (label) {
154
+ sessionManager.appendLabelChange(summaryId, label);
155
+ }
156
+ }
157
+ else if (newLeafId === null) {
158
+ // No summary, navigating to root - reset leaf
159
+ sessionManager.resetLeaf();
160
+ }
161
+ else {
162
+ // No summary, navigating to non-root
163
+ sessionManager.branch(newLeafId);
164
+ }
165
+ // Attach label to target entry when not summarizing (no summary entry to label)
166
+ if (label && !summaryText) {
167
+ sessionManager.appendLabelChange(targetId, label);
168
+ }
169
+ // Update agent state
170
+ const sessionContext = sessionManager.buildSessionContext();
171
+ this.deps.getAgent().state.messages = sessionContext.messages;
172
+ // Emit session_tree event
173
+ await extensionRunner.emit({
174
+ type: "session_tree",
175
+ newLeafId: sessionManager.getLeafId(),
176
+ oldLeafId,
177
+ summaryEntry,
178
+ fromExtension: summaryText ? fromExtension : undefined,
179
+ });
180
+ // Emit to custom tools
181
+ return { editorText, cancelled: false, summaryEntry };
182
+ }
183
+ finally {
184
+ this.deps.setBranchSummaryAbort(undefined);
185
+ }
186
+ }
187
+ /**
188
+ * Get all user messages from session for fork selector.
189
+ */
190
+ getUserMessagesForForking() {
191
+ const entries = this.deps.getSessionManager().getEntries();
192
+ const result = [];
193
+ for (const entry of entries) {
194
+ if (entry.type !== "message")
195
+ continue;
196
+ if (entry.message.role !== "user")
197
+ continue;
198
+ const text = this._extractUserMessageText(entry.message.content);
199
+ if (text) {
200
+ result.push({ entryId: entry.id, text });
201
+ }
202
+ }
203
+ return result;
204
+ }
205
+ _extractUserMessageText(content) {
206
+ if (typeof content === "string")
207
+ return content;
208
+ if (Array.isArray(content)) {
209
+ return content
210
+ .filter((c) => c.type === "text")
211
+ .map((c) => c.text)
212
+ .join("");
213
+ }
214
+ return "";
215
+ }
216
+ }
217
+ //# sourceMappingURL=session-tree-navigator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-tree-navigator.js","sourceRoot":"","sources":["../../src/core/session-tree-navigator.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EAEN,8BAA8B,EAC9B,qBAAqB,GAErB,MAAM,gCAAgC,CAAC;AAsBxC,MAAM,OAAO,oBAAoB;IACf,IAAI,CAA2B;IAEhD,YAAY,IAA8B,EAAE;QAC3C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IAAA,CACjB;IAED;;;;;;;;;;OAUG;IACH,KAAK,CAAC,YAAY,CACjB,QAAgB,EAChB,OAAO,GAAwG,EAAE,EACJ;QAC7G,MAAM,cAAc,GAAG,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACrD,MAAM,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC,kBAAkB,EAAE,CAAC;QACvD,MAAM,SAAS,GAAG,cAAc,CAAC,SAAS,EAAE,CAAC;QAE7C,6BAA6B;QAC7B,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;YAC5B,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;QAC7B,CAAC;QAED,mCAAmC;QACnC,IAAI,OAAO,CAAC,SAAS,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,CAAC;YAChD,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;QACzD,CAAC;QAED,MAAM,WAAW,GAAG,cAAc,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QACtD,IAAI,CAAC,WAAW,EAAE,CAAC;YAClB,MAAM,IAAI,KAAK,CAAC,SAAS,QAAQ,YAAY,CAAC,CAAC;QAChD,CAAC;QAED,kEAAkE;QAClE,MAAM,EAAE,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,GAAG,8BAA8B,CACvF,cAAc,EACd,SAAS,EACT,QAAQ,CACR,CAAC;QAEF,0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A6C;QACrE,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE,CAAC,UAAU,EAAE,CAAC;QAC3D,MAAM,MAAM,GAA6C,EAAE,CAAC;QAE5D,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;YAC7B,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS;gBAAE,SAAS;YACvC,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,KAAK,MAAM;gBAAE,SAAS;YAE5C,MAAM,IAAI,GAAG,IAAI,CAAC,uBAAuB,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;YACjE,IAAI,IAAI,EAAE,CAAC;gBACV,MAAM,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;YAC1C,CAAC;QACF,CAAC;QAED,OAAO,MAAM,CAAC;IAAA,CACd;IAEO,uBAAuB,CAAC,OAAwD,EAAU;QACjG,IAAI,OAAO,OAAO,KAAK,QAAQ;YAAE,OAAO,OAAO,CAAC;QAChD,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;YAC5B,OAAO,OAAO;iBACZ,MAAM,CAAC,CAAC,CAAC,EAAuC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,CAAC;iBACrE,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;iBAClB,IAAI,CAAC,EAAE,CAAC,CAAC;QACZ,CAAC;QACD,OAAO,EAAE,CAAC;IAAA,CACV;CACD","sourcesContent":["/**\n * Session-tree navigation (in-file branch switching + fork-selector reads).\n *\n * Extracted verbatim from agent-session.ts (god-file decomposition). `navigateTree` moves the leaf\n * to another node in the SAME session file (unlike fork(), which creates a new file), optionally\n * summarizing the abandoned branch via the model or an extension override. It owns no state: the\n * branch-summary abort controller stays on the session (also read by `isCompacting`) and is set/cleared\n * here through a dep so the session's abort/compacting surface is untouched.\n */\n\nimport type { Agent } from \"@caupulican/pi-agent-core\";\nimport {\n\ttype BranchSummaryEntry,\n\tcollectEntriesForBranchSummary,\n\tgenerateBranchSummary,\n\ttype SessionManager,\n} from \"@caupulican/pi-agent-core/node\";\nimport type { Model } from \"@caupulican/pi-ai\";\nimport type { ExtensionRunner, SessionBeforeTreeResult, TreePreparation } from \"./extensions/index.ts\";\nimport type { SettingsManager } from \"./settings-manager.ts\";\n\nexport interface SessionTreeNavigatorDeps {\n\t/** Session log — leaf/branch reads and writes go through this. */\n\tgetSessionManager(): SessionManager;\n\t/** Current model — required to run the default branch summarizer. */\n\tgetModel(): Model<any> | undefined;\n\t/** Extension runner — `session_before_tree`/`session_tree` hooks fire here. */\n\tgetExtensionRunner(): ExtensionRunner;\n\t/** Resolve request auth for the summarizer call (session-owned, also used by compaction). */\n\tgetRequiredRequestAuth(model: Model<any>): Promise<{ apiKey: string; headers?: Record<string, string> }>;\n\t/** Settings — branch-summary reserve tokens. */\n\tgetSettingsManager(): SettingsManager;\n\t/** The underlying agent — the rebuilt message view is assigned to `agent.state.messages`. */\n\tgetAgent(): Agent;\n\t/** Store/clear the in-flight branch-summary abort controller on the session (read by isCompacting). */\n\tsetBranchSummaryAbort(controller: AbortController | undefined): void;\n}\n\nexport class SessionTreeNavigator {\n\tprivate readonly deps: SessionTreeNavigatorDeps;\n\n\tconstructor(deps: SessionTreeNavigatorDeps) {\n\t\tthis.deps = deps;\n\t}\n\n\t/**\n\t * Navigate to a different node in the session tree.\n\t * Unlike fork() which creates a new session file, this stays in the same file.\n\t *\n\t * @param targetId The entry ID to navigate to\n\t * @param options.summarize Whether user wants to summarize abandoned branch\n\t * @param options.customInstructions Custom instructions for summarizer\n\t * @param options.replaceInstructions If true, customInstructions replaces the default prompt\n\t * @param options.label Label to attach to the branch summary entry\n\t * @returns Result with editorText (if user message) and cancelled status\n\t */\n\tasync navigateTree(\n\t\ttargetId: string,\n\t\toptions: { summarize?: boolean; customInstructions?: string; replaceInstructions?: boolean; label?: string } = {},\n\t): Promise<{ editorText?: string; cancelled: boolean; aborted?: boolean; summaryEntry?: BranchSummaryEntry }> {\n\t\tconst sessionManager = this.deps.getSessionManager();\n\t\tconst extensionRunner = this.deps.getExtensionRunner();\n\t\tconst oldLeafId = sessionManager.getLeafId();\n\n\t\t// No-op if already at target\n\t\tif (targetId === oldLeafId) {\n\t\t\treturn { cancelled: false };\n\t\t}\n\n\t\t// Model required for summarization\n\t\tif (options.summarize && !this.deps.getModel()) {\n\t\t\tthrow new Error(\"No model available for summarization\");\n\t\t}\n\n\t\tconst targetEntry = sessionManager.getEntry(targetId);\n\t\tif (!targetEntry) {\n\t\t\tthrow new Error(`Entry ${targetId} not found`);\n\t\t}\n\n\t\t// Collect entries to summarize (from old leaf to common ancestor)\n\t\tconst { entries: entriesToSummarize, commonAncestorId } = collectEntriesForBranchSummary(\n\t\t\tsessionManager,\n\t\t\toldLeafId,\n\t\t\ttargetId,\n\t\t);\n\n\t\t// Prepare event data - mutable so extensions can override\n\t\tlet customInstructions = options.customInstructions;\n\t\tlet replaceInstructions = options.replaceInstructions;\n\t\tlet label = options.label;\n\n\t\tconst preparation: TreePreparation = {\n\t\t\ttargetId,\n\t\t\toldLeafId,\n\t\t\tcommonAncestorId,\n\t\t\tentriesToSummarize,\n\t\t\tuserWantsSummary: options.summarize ?? false,\n\t\t\tcustomInstructions,\n\t\t\treplaceInstructions,\n\t\t\tlabel,\n\t\t};\n\n\t\t// Set up abort controller for summarization\n\t\tconst branchSummaryAbort = new AbortController();\n\t\tthis.deps.setBranchSummaryAbort(branchSummaryAbort);\n\n\t\ttry {\n\t\t\tlet extensionSummary: { summary: string; details?: unknown } | undefined;\n\t\t\tlet fromExtension = false;\n\n\t\t\t// Emit session_before_tree event\n\t\t\tif (extensionRunner.hasHandlers(\"session_before_tree\")) {\n\t\t\t\tconst result = (await extensionRunner.emit({\n\t\t\t\t\ttype: \"session_before_tree\",\n\t\t\t\t\tpreparation,\n\t\t\t\t\tsignal: branchSummaryAbort.signal,\n\t\t\t\t})) as SessionBeforeTreeResult | undefined;\n\n\t\t\t\tif (result?.cancel) {\n\t\t\t\t\treturn { cancelled: true };\n\t\t\t\t}\n\n\t\t\t\tif (result?.summary && options.summarize) {\n\t\t\t\t\textensionSummary = result.summary;\n\t\t\t\t\tfromExtension = true;\n\t\t\t\t}\n\n\t\t\t\t// Allow extensions to override instructions and label\n\t\t\t\tif (result?.customInstructions !== undefined) {\n\t\t\t\t\tcustomInstructions = result.customInstructions;\n\t\t\t\t}\n\t\t\t\tif (result?.replaceInstructions !== undefined) {\n\t\t\t\t\treplaceInstructions = result.replaceInstructions;\n\t\t\t\t}\n\t\t\t\tif (result?.label !== undefined) {\n\t\t\t\t\tlabel = result.label;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Run default summarizer if needed\n\t\t\tlet summaryText: string | undefined;\n\t\t\tlet summaryDetails: unknown;\n\t\t\tif (options.summarize && entriesToSummarize.length > 0 && !extensionSummary) {\n\t\t\t\tconst model = this.deps.getModel()!;\n\t\t\t\tconst { apiKey, headers } = await this.deps.getRequiredRequestAuth(model);\n\t\t\t\tconst branchSummarySettings = this.deps.getSettingsManager().getBranchSummarySettings();\n\t\t\t\tconst result = await generateBranchSummary(entriesToSummarize, {\n\t\t\t\t\tmodel,\n\t\t\t\t\tapiKey,\n\t\t\t\t\theaders,\n\t\t\t\t\tsignal: branchSummaryAbort.signal,\n\t\t\t\t\tcustomInstructions,\n\t\t\t\t\treplaceInstructions,\n\t\t\t\t\treserveTokens: branchSummarySettings.reserveTokens,\n\t\t\t\t});\n\t\t\t\tif (result.aborted) {\n\t\t\t\t\treturn { cancelled: true, aborted: true };\n\t\t\t\t}\n\t\t\t\tif (result.error) {\n\t\t\t\t\tthrow new Error(result.error);\n\t\t\t\t}\n\t\t\t\tsummaryText = result.summary;\n\t\t\t\tsummaryDetails = {\n\t\t\t\t\treadFiles: result.readFiles || [],\n\t\t\t\t\tmodifiedFiles: result.modifiedFiles || [],\n\t\t\t\t};\n\t\t\t} else if (extensionSummary) {\n\t\t\t\tsummaryText = extensionSummary.summary;\n\t\t\t\tsummaryDetails = extensionSummary.details;\n\t\t\t}\n\n\t\t\t// Determine the new leaf position based on target type\n\t\t\tlet newLeafId: string | null;\n\t\t\tlet editorText: string | undefined;\n\n\t\t\tif (targetEntry.type === \"message\" && targetEntry.message.role === \"user\") {\n\t\t\t\t// User message: leaf = parent (null if root), text goes to editor\n\t\t\t\tnewLeafId = targetEntry.parentId;\n\t\t\t\teditorText = this._extractUserMessageText(targetEntry.message.content);\n\t\t\t} else if (targetEntry.type === \"custom_message\") {\n\t\t\t\t// Custom message: leaf = parent (null if root), text goes to editor\n\t\t\t\tnewLeafId = targetEntry.parentId;\n\t\t\t\teditorText =\n\t\t\t\t\ttypeof targetEntry.content === \"string\"\n\t\t\t\t\t\t? targetEntry.content\n\t\t\t\t\t\t: targetEntry.content\n\t\t\t\t\t\t\t\t.filter((c): c is { type: \"text\"; text: string } => c.type === \"text\")\n\t\t\t\t\t\t\t\t.map((c) => c.text)\n\t\t\t\t\t\t\t\t.join(\"\");\n\t\t\t} else {\n\t\t\t\t// Non-user message: leaf = selected node\n\t\t\t\tnewLeafId = targetId;\n\t\t\t}\n\n\t\t\t// Switch leaf (with or without summary)\n\t\t\t// Summary is attached at the navigation target position (newLeafId), not the old branch\n\t\t\tlet summaryEntry: BranchSummaryEntry | undefined;\n\t\t\tif (summaryText) {\n\t\t\t\t// Create summary at target position (can be null for root)\n\t\t\t\tconst summaryId = sessionManager.branchWithSummary(newLeafId, summaryText, summaryDetails, fromExtension);\n\t\t\t\tsummaryEntry = sessionManager.getEntry(summaryId) as BranchSummaryEntry;\n\n\t\t\t\t// Attach label to the summary entry\n\t\t\t\tif (label) {\n\t\t\t\t\tsessionManager.appendLabelChange(summaryId, label);\n\t\t\t\t}\n\t\t\t} else if (newLeafId === null) {\n\t\t\t\t// No summary, navigating to root - reset leaf\n\t\t\t\tsessionManager.resetLeaf();\n\t\t\t} else {\n\t\t\t\t// No summary, navigating to non-root\n\t\t\t\tsessionManager.branch(newLeafId);\n\t\t\t}\n\n\t\t\t// Attach label to target entry when not summarizing (no summary entry to label)\n\t\t\tif (label && !summaryText) {\n\t\t\t\tsessionManager.appendLabelChange(targetId, label);\n\t\t\t}\n\n\t\t\t// Update agent state\n\t\t\tconst sessionContext = sessionManager.buildSessionContext();\n\t\t\tthis.deps.getAgent().state.messages = sessionContext.messages;\n\n\t\t\t// Emit session_tree event\n\t\t\tawait extensionRunner.emit({\n\t\t\t\ttype: \"session_tree\",\n\t\t\t\tnewLeafId: sessionManager.getLeafId(),\n\t\t\t\toldLeafId,\n\t\t\t\tsummaryEntry,\n\t\t\t\tfromExtension: summaryText ? fromExtension : undefined,\n\t\t\t});\n\n\t\t\t// Emit to custom tools\n\n\t\t\treturn { editorText, cancelled: false, summaryEntry };\n\t\t} finally {\n\t\t\tthis.deps.setBranchSummaryAbort(undefined);\n\t\t}\n\t}\n\n\t/**\n\t * Get all user messages from session for fork selector.\n\t */\n\tgetUserMessagesForForking(): Array<{ entryId: string; text: string }> {\n\t\tconst entries = this.deps.getSessionManager().getEntries();\n\t\tconst result: Array<{ entryId: string; text: string }> = [];\n\n\t\tfor (const entry of entries) {\n\t\t\tif (entry.type !== \"message\") continue;\n\t\t\tif (entry.message.role !== \"user\") continue;\n\n\t\t\tconst text = this._extractUserMessageText(entry.message.content);\n\t\t\tif (text) {\n\t\t\t\tresult.push({ entryId: entry.id, text });\n\t\t\t}\n\t\t}\n\n\t\treturn result;\n\t}\n\n\tprivate _extractUserMessageText(content: string | Array<{ type: string; text?: string }>): string {\n\t\tif (typeof content === \"string\") return content;\n\t\tif (Array.isArray(content)) {\n\t\t\treturn content\n\t\t\t\t.filter((c): c is { type: \"text\"; text: string } => c.type === \"text\")\n\t\t\t\t.map((c) => c.text)\n\t\t\t\t.join(\"\");\n\t\t}\n\t\treturn \"\";\n\t}\n}\n"]}
@@ -70,11 +70,17 @@ export interface ProviderRetrySettings {
70
70
  maxRetries?: number;
71
71
  maxRetryDelayMs?: number;
72
72
  }
73
+ export interface StreamStallSettings {
74
+ connectMs?: number;
75
+ activeIdleMs?: number;
76
+ quietIdleMs?: number;
77
+ }
73
78
  export interface RetrySettings {
74
79
  enabled?: boolean;
75
80
  maxRetries?: number;
76
81
  baseDelayMs?: number;
77
82
  provider?: ProviderRetrySettings;
83
+ stall?: StreamStallSettings;
78
84
  }
79
85
  export interface TerminalSettings {
80
86
  showImages?: boolean;
@@ -611,6 +617,16 @@ export declare class SettingsManager {
611
617
  maxRetries: number;
612
618
  baseDelayMs: number;
613
619
  };
620
+ /**
621
+ * Stream-stall watchdog bounds (pi-agent-core reliability/watchdogs.ts). Returns only the
622
+ * fields the user set, validated; unset fields fall back to DEFAULT_STREAM_IDLE at the
623
+ * wiring site (agent-session constructor). Resolved per request, so edits apply live.
624
+ */
625
+ getStreamStallSettings(): {
626
+ connectMs?: number;
627
+ activeIdleMs?: number;
628
+ quietIdleMs?: number;
629
+ };
614
630
  getHttpIdleTimeoutMs(): number;
615
631
  setHttpIdleTimeoutMs(timeoutMs: number): void;
616
632
  getProviderRetrySettings(): {