@code-yeongyu/senpi 2026.7.23 → 2026.7.24

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 (825) hide show
  1. package/CHANGELOG.md +131 -6
  2. package/README.md +14 -1
  3. package/dist/cli/args.d.ts +2 -0
  4. package/dist/cli/args.d.ts.map +1 -1
  5. package/dist/cli/args.js +6 -0
  6. package/dist/cli/args.js.map +1 -1
  7. package/dist/cli/config-selector.js +1 -1
  8. package/dist/cli/config-selector.js.map +1 -1
  9. package/dist/core/agent-session-runtime.d.ts +15 -1
  10. package/dist/core/agent-session-runtime.d.ts.map +1 -1
  11. package/dist/core/agent-session-runtime.js +12 -2
  12. package/dist/core/agent-session-runtime.js.map +1 -1
  13. package/dist/core/agent-session.d.ts +102 -4
  14. package/dist/core/agent-session.d.ts.map +1 -1
  15. package/dist/core/agent-session.js +1295 -320
  16. package/dist/core/agent-session.js.map +1 -1
  17. package/dist/core/compaction/branch-summarization.d.ts +7 -1
  18. package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
  19. package/dist/core/compaction/branch-summarization.js +8 -12
  20. package/dist/core/compaction/branch-summarization.js.map +1 -1
  21. package/dist/core/compaction/compaction.d.ts +22 -4
  22. package/dist/core/compaction/compaction.d.ts.map +1 -1
  23. package/dist/core/compaction/compaction.js +114 -51
  24. package/dist/core/compaction/compaction.js.map +1 -1
  25. package/dist/core/compaction/lifecycle.d.ts +69 -0
  26. package/dist/core/compaction/lifecycle.d.ts.map +1 -0
  27. package/dist/core/compaction/lifecycle.js +104 -0
  28. package/dist/core/compaction/lifecycle.js.map +1 -0
  29. package/dist/core/compaction/utils.d.ts +12 -1
  30. package/dist/core/compaction/utils.d.ts.map +1 -1
  31. package/dist/core/compaction/utils.js +22 -17
  32. package/dist/core/compaction/utils.js.map +1 -1
  33. package/dist/core/event-bus.d.ts.map +1 -1
  34. package/dist/core/event-bus.js +11 -1
  35. package/dist/core/event-bus.js.map +1 -1
  36. package/dist/core/extensions/builtin/compaction/index.d.ts +2 -1
  37. package/dist/core/extensions/builtin/compaction/index.d.ts.map +1 -1
  38. package/dist/core/extensions/builtin/compaction/index.js +42 -30
  39. package/dist/core/extensions/builtin/compaction/index.js.map +1 -1
  40. package/dist/core/extensions/builtin/compaction/openai-remote-model.d.ts +9 -2
  41. package/dist/core/extensions/builtin/compaction/openai-remote-model.d.ts.map +1 -1
  42. package/dist/core/extensions/builtin/compaction/openai-remote-model.js +78 -28
  43. package/dist/core/extensions/builtin/compaction/openai-remote-model.js.map +1 -1
  44. package/dist/core/extensions/builtin/compaction/openai-remote-schema.d.ts +3 -1
  45. package/dist/core/extensions/builtin/compaction/openai-remote-schema.d.ts.map +1 -1
  46. package/dist/core/extensions/builtin/compaction/openai-remote-schema.js +19 -1
  47. package/dist/core/extensions/builtin/compaction/openai-remote-schema.js.map +1 -1
  48. package/dist/core/extensions/builtin/compaction/openai-remote.d.ts +20 -6
  49. package/dist/core/extensions/builtin/compaction/openai-remote.d.ts.map +1 -1
  50. package/dist/core/extensions/builtin/compaction/openai-remote.js +207 -22
  51. package/dist/core/extensions/builtin/compaction/openai-remote.js.map +1 -1
  52. package/dist/core/extensions/builtin/compaction/speculative.d.ts +4 -2
  53. package/dist/core/extensions/builtin/compaction/speculative.d.ts.map +1 -1
  54. package/dist/core/extensions/builtin/compaction/speculative.js +25 -13
  55. package/dist/core/extensions/builtin/compaction/speculative.js.map +1 -1
  56. package/dist/core/extensions/builtin/config-reload/index.d.ts +7 -0
  57. package/dist/core/extensions/builtin/config-reload/index.d.ts.map +1 -1
  58. package/dist/core/extensions/builtin/config-reload/index.js +49 -17
  59. package/dist/core/extensions/builtin/config-reload/index.js.map +1 -1
  60. package/dist/core/extensions/builtin/hooks/index.js +1 -1
  61. package/dist/core/extensions/builtin/hooks/index.js.map +1 -1
  62. package/dist/core/extensions/builtin/hooks/lifecycle-adapter.d.ts +3 -1
  63. package/dist/core/extensions/builtin/hooks/lifecycle-adapter.d.ts.map +1 -1
  64. package/dist/core/extensions/builtin/hooks/lifecycle-adapter.js +2 -1
  65. package/dist/core/extensions/builtin/hooks/lifecycle-adapter.js.map +1 -1
  66. package/dist/core/extensions/builtin/mcp/auth/commands-auth-dispatch.d.ts +2 -1
  67. package/dist/core/extensions/builtin/mcp/auth/commands-auth-dispatch.d.ts.map +1 -1
  68. package/dist/core/extensions/builtin/mcp/auth/commands-auth-dispatch.js +5 -3
  69. package/dist/core/extensions/builtin/mcp/auth/commands-auth-dispatch.js.map +1 -1
  70. package/dist/core/extensions/builtin/mcp/auth/commands-auth.d.ts +5 -0
  71. package/dist/core/extensions/builtin/mcp/auth/commands-auth.d.ts.map +1 -1
  72. package/dist/core/extensions/builtin/mcp/auth/commands-auth.js +8 -3
  73. package/dist/core/extensions/builtin/mcp/auth/commands-auth.js.map +1 -1
  74. package/dist/core/extensions/builtin/mcp/catalog.d.ts +3 -1
  75. package/dist/core/extensions/builtin/mcp/catalog.d.ts.map +1 -1
  76. package/dist/core/extensions/builtin/mcp/catalog.js +2 -0
  77. package/dist/core/extensions/builtin/mcp/catalog.js.map +1 -1
  78. package/dist/core/extensions/builtin/mcp/commands.d.ts +1 -1
  79. package/dist/core/extensions/builtin/mcp/commands.d.ts.map +1 -1
  80. package/dist/core/extensions/builtin/mcp/commands.js +34 -39
  81. package/dist/core/extensions/builtin/mcp/commands.js.map +1 -1
  82. package/dist/core/extensions/builtin/mcp/connection-types.d.ts +2 -0
  83. package/dist/core/extensions/builtin/mcp/connection-types.d.ts.map +1 -1
  84. package/dist/core/extensions/builtin/mcp/connection-types.js.map +1 -1
  85. package/dist/core/extensions/builtin/mcp/connection.d.ts.map +1 -1
  86. package/dist/core/extensions/builtin/mcp/connection.js +3 -0
  87. package/dist/core/extensions/builtin/mcp/connection.js.map +1 -1
  88. package/dist/core/extensions/builtin/mcp/elicitation.d.ts +7 -3
  89. package/dist/core/extensions/builtin/mcp/elicitation.d.ts.map +1 -1
  90. package/dist/core/extensions/builtin/mcp/elicitation.js +5 -5
  91. package/dist/core/extensions/builtin/mcp/elicitation.js.map +1 -1
  92. package/dist/core/extensions/builtin/mcp/expose/register.d.ts.map +1 -1
  93. package/dist/core/extensions/builtin/mcp/expose/register.js +1 -0
  94. package/dist/core/extensions/builtin/mcp/expose/register.js.map +1 -1
  95. package/dist/core/extensions/builtin/mcp/expose/session.d.ts +2 -0
  96. package/dist/core/extensions/builtin/mcp/expose/session.d.ts.map +1 -1
  97. package/dist/core/extensions/builtin/mcp/expose/session.js +3 -0
  98. package/dist/core/extensions/builtin/mcp/expose/session.js.map +1 -1
  99. package/dist/core/extensions/builtin/mcp/guard/output-guard.d.ts +9 -1
  100. package/dist/core/extensions/builtin/mcp/guard/output-guard.d.ts.map +1 -1
  101. package/dist/core/extensions/builtin/mcp/guard/output-guard.js +18 -6
  102. package/dist/core/extensions/builtin/mcp/guard/output-guard.js.map +1 -1
  103. package/dist/core/extensions/builtin/mcp/index.d.ts +4 -2
  104. package/dist/core/extensions/builtin/mcp/index.d.ts.map +1 -1
  105. package/dist/core/extensions/builtin/mcp/index.js +150 -127
  106. package/dist/core/extensions/builtin/mcp/index.js.map +1 -1
  107. package/dist/core/extensions/builtin/mcp/instructions.d.ts +1 -1
  108. package/dist/core/extensions/builtin/mcp/instructions.d.ts.map +1 -1
  109. package/dist/core/extensions/builtin/mcp/instructions.js +6 -6
  110. package/dist/core/extensions/builtin/mcp/instructions.js.map +1 -1
  111. package/dist/core/extensions/builtin/mcp/prompts.d.ts +2 -0
  112. package/dist/core/extensions/builtin/mcp/prompts.d.ts.map +1 -1
  113. package/dist/core/extensions/builtin/mcp/prompts.js +9 -3
  114. package/dist/core/extensions/builtin/mcp/prompts.js.map +1 -1
  115. package/dist/core/extensions/builtin/mcp/resources.d.ts +2 -0
  116. package/dist/core/extensions/builtin/mcp/resources.d.ts.map +1 -1
  117. package/dist/core/extensions/builtin/mcp/resources.js +1 -0
  118. package/dist/core/extensions/builtin/mcp/resources.js.map +1 -1
  119. package/dist/core/extensions/builtin/mcp/service-register.d.ts.map +1 -1
  120. package/dist/core/extensions/builtin/mcp/service-register.js +1 -0
  121. package/dist/core/extensions/builtin/mcp/service-register.js.map +1 -1
  122. package/dist/core/extensions/builtin/mcp/service-types.d.ts +2 -0
  123. package/dist/core/extensions/builtin/mcp/service-types.d.ts.map +1 -1
  124. package/dist/core/extensions/builtin/mcp/service-types.js.map +1 -1
  125. package/dist/core/extensions/builtin/mcp/service.d.ts +12 -1
  126. package/dist/core/extensions/builtin/mcp/service.d.ts.map +1 -1
  127. package/dist/core/extensions/builtin/mcp/service.js +44 -2
  128. package/dist/core/extensions/builtin/mcp/service.js.map +1 -1
  129. package/dist/core/extensions/builtin/mcp/transport.d.ts +2 -0
  130. package/dist/core/extensions/builtin/mcp/transport.d.ts.map +1 -1
  131. package/dist/core/extensions/builtin/mcp/transport.js +7 -7
  132. package/dist/core/extensions/builtin/mcp/transport.js.map +1 -1
  133. package/dist/core/extensions/builtin/prompt-preset/claude-fable-5.d.ts.map +1 -1
  134. package/dist/core/extensions/builtin/prompt-preset/claude-fable-5.js +86 -7
  135. package/dist/core/extensions/builtin/prompt-preset/claude-fable-5.js.map +1 -1
  136. package/dist/core/extensions/builtin/prompt-preset/claude-opus-5.d.ts +3 -0
  137. package/dist/core/extensions/builtin/prompt-preset/claude-opus-5.d.ts.map +1 -0
  138. package/dist/core/extensions/builtin/prompt-preset/claude-opus-5.js +102 -0
  139. package/dist/core/extensions/builtin/prompt-preset/claude-opus-5.js.map +1 -0
  140. package/dist/core/extensions/builtin/prompt-preset/kimi-k3.d.ts.map +1 -1
  141. package/dist/core/extensions/builtin/prompt-preset/kimi-k3.js +96 -6
  142. package/dist/core/extensions/builtin/prompt-preset/kimi-k3.js.map +1 -1
  143. package/dist/core/extensions/builtin/prompt-preset/presets.d.ts.map +1 -1
  144. package/dist/core/extensions/builtin/prompt-preset/presets.js +9 -0
  145. package/dist/core/extensions/builtin/prompt-preset/presets.js.map +1 -1
  146. package/dist/core/extensions/builtin/prompt-preset/settings.d.ts +1 -1
  147. package/dist/core/extensions/builtin/prompt-preset/settings.d.ts.map +1 -1
  148. package/dist/core/extensions/builtin/prompt-preset/settings.js +1 -0
  149. package/dist/core/extensions/builtin/prompt-preset/settings.js.map +1 -1
  150. package/dist/core/extensions/builtin/terminal/extension.d.ts.map +1 -1
  151. package/dist/core/extensions/builtin/terminal/extension.js +1 -0
  152. package/dist/core/extensions/builtin/terminal/extension.js.map +1 -1
  153. package/dist/core/extensions/builtin/terminal/tools/bash.d.ts +15 -3
  154. package/dist/core/extensions/builtin/terminal/tools/bash.d.ts.map +1 -1
  155. package/dist/core/extensions/builtin/terminal/tools/bash.js +30 -6
  156. package/dist/core/extensions/builtin/terminal/tools/bash.js.map +1 -1
  157. package/dist/core/extensions/builtin/terminal/tools/context.d.ts +5 -0
  158. package/dist/core/extensions/builtin/terminal/tools/context.d.ts.map +1 -1
  159. package/dist/core/extensions/builtin/terminal/tools/context.js.map +1 -1
  160. package/dist/core/extensions/runner.d.ts +14 -7
  161. package/dist/core/extensions/runner.d.ts.map +1 -1
  162. package/dist/core/extensions/runner.js +64 -37
  163. package/dist/core/extensions/runner.js.map +1 -1
  164. package/dist/core/extensions/types.d.ts +30 -3
  165. package/dist/core/extensions/types.d.ts.map +1 -1
  166. package/dist/core/extensions/types.js.map +1 -1
  167. package/dist/core/http-dispatcher.d.ts.map +1 -1
  168. package/dist/core/http-dispatcher.js +16 -0
  169. package/dist/core/http-dispatcher.js.map +1 -1
  170. package/dist/core/messages.d.ts +1 -1
  171. package/dist/core/messages.d.ts.map +1 -1
  172. package/dist/core/messages.js +10 -8
  173. package/dist/core/messages.js.map +1 -1
  174. package/dist/core/model-registry.d.ts +1 -0
  175. package/dist/core/model-registry.d.ts.map +1 -1
  176. package/dist/core/model-registry.js +3 -2
  177. package/dist/core/model-registry.js.map +1 -1
  178. package/dist/core/model-resolver.d.ts.map +1 -1
  179. package/dist/core/model-resolver.js +9 -0
  180. package/dist/core/model-resolver.js.map +1 -1
  181. package/dist/core/model-runtime.d.ts +4 -2
  182. package/dist/core/model-runtime.d.ts.map +1 -1
  183. package/dist/core/model-runtime.js +34 -18
  184. package/dist/core/model-runtime.js.map +1 -1
  185. package/dist/core/remote-catalog-provider.d.ts +1 -1
  186. package/dist/core/remote-catalog-provider.d.ts.map +1 -1
  187. package/dist/core/remote-catalog-provider.js +21 -7
  188. package/dist/core/remote-catalog-provider.js.map +1 -1
  189. package/dist/core/resolve-config-value.d.ts.map +1 -1
  190. package/dist/core/resolve-config-value.js +12 -8
  191. package/dist/core/resolve-config-value.js.map +1 -1
  192. package/dist/core/sdk.d.ts +1 -1
  193. package/dist/core/sdk.d.ts.map +1 -1
  194. package/dist/core/sdk.js +8 -3
  195. package/dist/core/sdk.js.map +1 -1
  196. package/dist/core/session-manager.d.ts +22 -3
  197. package/dist/core/session-manager.d.ts.map +1 -1
  198. package/dist/core/session-manager.js +155 -58
  199. package/dist/core/session-manager.js.map +1 -1
  200. package/dist/core/settings-manager.d.ts +1 -1
  201. package/dist/core/settings-manager.d.ts.map +1 -1
  202. package/dist/core/settings-manager.js.map +1 -1
  203. package/dist/core/system-prompt.js +1 -1
  204. package/dist/core/system-prompt.js.map +1 -1
  205. package/dist/core/tools/bash.d.ts +2 -0
  206. package/dist/core/tools/bash.d.ts.map +1 -1
  207. package/dist/core/tools/bash.js +34 -5
  208. package/dist/core/tools/bash.js.map +1 -1
  209. package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -1
  210. package/dist/core/tools/tool-definition-wrapper.js +3 -1
  211. package/dist/core/tools/tool-definition-wrapper.js.map +1 -1
  212. package/dist/core/usage-totals.d.ts +19 -0
  213. package/dist/core/usage-totals.d.ts.map +1 -0
  214. package/dist/core/usage-totals.js +52 -0
  215. package/dist/core/usage-totals.js.map +1 -0
  216. package/dist/extensions/llama/client.d.ts.map +1 -1
  217. package/dist/extensions/llama/client.js +3 -1
  218. package/dist/extensions/llama/client.js.map +1 -1
  219. package/dist/extensions/llama/index.js +3 -3
  220. package/dist/extensions/llama/index.js.map +1 -1
  221. package/dist/extensions/llama/provider.d.ts.map +1 -1
  222. package/dist/extensions/llama/provider.js +1 -2
  223. package/dist/extensions/llama/provider.js.map +1 -1
  224. package/dist/index.d.ts +2 -2
  225. package/dist/index.d.ts.map +1 -1
  226. package/dist/index.js +1 -1
  227. package/dist/index.js.map +1 -1
  228. package/dist/main.d.ts.map +1 -1
  229. package/dist/main.js +37 -5
  230. package/dist/main.js.map +1 -1
  231. package/dist/modes/app-server/daemon/occupancy.d.ts +22 -0
  232. package/dist/modes/app-server/daemon/occupancy.d.ts.map +1 -0
  233. package/dist/modes/app-server/daemon/occupancy.js +67 -0
  234. package/dist/modes/app-server/daemon/occupancy.js.map +1 -0
  235. package/dist/modes/app-server/daemon/probe.d.ts +3 -3
  236. package/dist/modes/app-server/daemon/probe.d.ts.map +1 -1
  237. package/dist/modes/app-server/daemon/probe.js +33 -10
  238. package/dist/modes/app-server/daemon/probe.js.map +1 -1
  239. package/dist/modes/app-server/daemon.d.ts.map +1 -1
  240. package/dist/modes/app-server/daemon.js +58 -18
  241. package/dist/modes/app-server/daemon.js.map +1 -1
  242. package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -1
  243. package/dist/modes/interactive/components/compaction-summary-message.js +8 -1
  244. package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -1
  245. package/dist/modes/interactive/components/extension-editor.d.ts +1 -2
  246. package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -1
  247. package/dist/modes/interactive/components/extension-editor.js +16 -46
  248. package/dist/modes/interactive/components/extension-editor.js.map +1 -1
  249. package/dist/modes/interactive/components/footer.d.ts.map +1 -1
  250. package/dist/modes/interactive/components/footer.js.map +1 -1
  251. package/dist/modes/interactive/components/status-indicator.d.ts +4 -0
  252. package/dist/modes/interactive/components/status-indicator.d.ts.map +1 -1
  253. package/dist/modes/interactive/components/status-indicator.js +13 -0
  254. package/dist/modes/interactive/components/status-indicator.js.map +1 -1
  255. package/dist/modes/interactive/external-editor.d.ts +12 -0
  256. package/dist/modes/interactive/external-editor.d.ts.map +1 -0
  257. package/dist/modes/interactive/external-editor.js +37 -0
  258. package/dist/modes/interactive/external-editor.js.map +1 -0
  259. package/dist/modes/interactive/interactive-mode.d.ts +3 -1
  260. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  261. package/dist/modes/interactive/interactive-mode.js +96 -78
  262. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  263. package/dist/modes/rpc/connection-handler.d.ts +6 -0
  264. package/dist/modes/rpc/connection-handler.d.ts.map +1 -1
  265. package/dist/modes/rpc/connection-handler.js +34 -9
  266. package/dist/modes/rpc/connection-handler.js.map +1 -1
  267. package/dist/modes/rpc/multi-session-host.d.ts +15 -0
  268. package/dist/modes/rpc/multi-session-host.d.ts.map +1 -0
  269. package/dist/modes/rpc/multi-session-host.js +60 -0
  270. package/dist/modes/rpc/multi-session-host.js.map +1 -0
  271. package/dist/modes/rpc/neo-runtime-options.d.ts.map +1 -1
  272. package/dist/modes/rpc/neo-runtime-options.js +1 -0
  273. package/dist/modes/rpc/neo-runtime-options.js.map +1 -1
  274. package/dist/modes/rpc/rpc-client.d.ts +4 -0
  275. package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
  276. package/dist/modes/rpc/rpc-client.js +7 -0
  277. package/dist/modes/rpc/rpc-client.js.map +1 -1
  278. package/dist/modes/rpc/rpc-mode.d.ts +49 -0
  279. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  280. package/dist/modes/rpc/rpc-mode.js +49 -0
  281. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  282. package/dist/modes/rpc/rpc-types.d.ts +85 -1
  283. package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
  284. package/dist/modes/rpc/rpc-types.js +8 -1
  285. package/dist/modes/rpc/rpc-types.js.map +1 -1
  286. package/dist/modes/rpc/session-binding.d.ts +13 -0
  287. package/dist/modes/rpc/session-binding.d.ts.map +1 -0
  288. package/dist/modes/rpc/session-binding.js +33 -0
  289. package/dist/modes/rpc/session-binding.js.map +1 -0
  290. package/dist/modes/rpc/session-command-router.d.ts +19 -0
  291. package/dist/modes/rpc/session-command-router.d.ts.map +1 -0
  292. package/dist/modes/rpc/session-command-router.js +159 -0
  293. package/dist/modes/rpc/session-command-router.js.map +1 -0
  294. package/dist/modes/rpc/session-event-writer.d.ts +34 -0
  295. package/dist/modes/rpc/session-event-writer.d.ts.map +1 -0
  296. package/dist/modes/rpc/session-event-writer.js +92 -0
  297. package/dist/modes/rpc/session-event-writer.js.map +1 -0
  298. package/dist/modes/rpc/session-extension-ui-requests.d.ts +15 -0
  299. package/dist/modes/rpc/session-extension-ui-requests.d.ts.map +1 -0
  300. package/dist/modes/rpc/session-extension-ui-requests.js +27 -0
  301. package/dist/modes/rpc/session-extension-ui-requests.js.map +1 -0
  302. package/dist/modes/rpc/session-registry.d.ts +58 -0
  303. package/dist/modes/rpc/session-registry.d.ts.map +1 -0
  304. package/dist/modes/rpc/session-registry.js +162 -0
  305. package/dist/modes/rpc/session-registry.js.map +1 -0
  306. package/dist/utils/clipboard.d.ts.map +1 -1
  307. package/dist/utils/clipboard.js +19 -8
  308. package/dist/utils/clipboard.js.map +1 -1
  309. package/dist/utils/version-check.d.ts.map +1 -1
  310. package/dist/utils/version-check.js +3 -1
  311. package/dist/utils/version-check.js.map +1 -1
  312. package/docs/app-server-daemon.md +3 -2
  313. package/docs/compaction.md +9 -4
  314. package/docs/custom-provider.md +5 -2
  315. package/docs/environment-variables.md +88 -0
  316. package/docs/extensions.md +25 -7
  317. package/docs/index.md +1 -0
  318. package/docs/json.md +5 -1
  319. package/docs/models.md +6 -2
  320. package/docs/providers.md +12 -1
  321. package/docs/rpc.md +154 -8
  322. package/docs/sdk.md +3 -0
  323. package/docs/session-format.md +17 -3
  324. package/docs/settings.md +2 -2
  325. package/docs/usage.md +1 -14
  326. package/examples/extensions/custom-compaction.ts +4 -0
  327. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  328. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  329. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  330. package/examples/extensions/gondolin/package-lock.json +2 -2
  331. package/examples/extensions/gondolin/package.json +1 -1
  332. package/examples/extensions/handoff.ts +9 -1
  333. package/examples/extensions/sandbox/package-lock.json +2 -2
  334. package/examples/extensions/sandbox/package.json +1 -1
  335. package/examples/extensions/summarize.ts +3 -0
  336. package/examples/extensions/with-deps/package-lock.json +2 -2
  337. package/examples/extensions/with-deps/package.json +1 -1
  338. package/node_modules/@code-yeongyu/senpi-codemode/CHANGELOG.md +24 -0
  339. package/node_modules/@code-yeongyu/senpi-codemode/package.json +3 -3
  340. package/node_modules/@earendil-works/pi-agent-core/README.md +31 -12
  341. package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.d.ts +4 -4
  342. package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.d.ts.map +1 -1
  343. package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.js +8 -7
  344. package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.js.map +1 -1
  345. package/node_modules/@earendil-works/pi-agent-core/dist/agent.d.ts +10 -3
  346. package/node_modules/@earendil-works/pi-agent-core/dist/agent.d.ts.map +1 -1
  347. package/node_modules/@earendil-works/pi-agent-core/dist/agent.js +61 -27
  348. package/node_modules/@earendil-works/pi-agent-core/dist/agent.js.map +1 -1
  349. package/node_modules/@earendil-works/pi-agent-core/dist/harness/agent-harness.d.ts +11 -12
  350. package/node_modules/@earendil-works/pi-agent-core/dist/harness/agent-harness.d.ts.map +1 -1
  351. package/node_modules/@earendil-works/pi-agent-core/dist/harness/agent-harness.js +47 -22
  352. package/node_modules/@earendil-works/pi-agent-core/dist/harness/agent-harness.js.map +1 -1
  353. package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/branch-summarization.d.ts +5 -1
  354. package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/branch-summarization.d.ts.map +1 -1
  355. package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/branch-summarization.js +6 -8
  356. package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/branch-summarization.js.map +1 -1
  357. package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/compaction.d.ts +17 -5
  358. package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/compaction.d.ts.map +1 -1
  359. package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/compaction.js +82 -27
  360. package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/compaction.js.map +1 -1
  361. package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/utils.d.ts +12 -1
  362. package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/utils.d.ts.map +1 -1
  363. package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/utils.js +22 -17
  364. package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/utils.js.map +1 -1
  365. package/node_modules/@earendil-works/pi-agent-core/dist/harness/env/nodejs.d.ts +3 -9
  366. package/node_modules/@earendil-works/pi-agent-core/dist/harness/env/nodejs.d.ts.map +1 -1
  367. package/node_modules/@earendil-works/pi-agent-core/dist/harness/env/nodejs.js +118 -11
  368. package/node_modules/@earendil-works/pi-agent-core/dist/harness/env/nodejs.js.map +1 -1
  369. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-storage.d.ts +11 -3
  370. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-storage.d.ts.map +1 -1
  371. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-storage.js +56 -4
  372. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-storage.js.map +1 -1
  373. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-storage.d.ts +11 -3
  374. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-storage.d.ts.map +1 -1
  375. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-storage.js +56 -4
  376. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-storage.js.map +1 -1
  377. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/repo-utils.d.ts.map +1 -1
  378. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/repo-utils.js +2 -2
  379. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/repo-utils.js.map +1 -1
  380. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/session.d.ts +6 -4
  381. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/session.d.ts.map +1 -1
  382. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/session.js +30 -14
  383. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/session.js.map +1 -1
  384. package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/bash.d.ts +27 -0
  385. package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/bash.d.ts.map +1 -0
  386. package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/bash.js +132 -0
  387. package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/bash.js.map +1 -0
  388. package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/edit-diff.d.ts +89 -0
  389. package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/edit-diff.d.ts.map +1 -0
  390. package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/edit-diff.js +386 -0
  391. package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/edit-diff.js.map +1 -0
  392. package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/edit.d.ts +19 -0
  393. package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/edit.d.ts.map +1 -0
  394. package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/edit.js +95 -0
  395. package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/edit.js.map +1 -0
  396. package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/file-mutation-queue.d.ts +4 -0
  397. package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/file-mutation-queue.d.ts.map +1 -0
  398. package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/file-mutation-queue.js +46 -0
  399. package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/file-mutation-queue.js.map +1 -0
  400. package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/image.d.ts +3 -0
  401. package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/image.d.ts.map +1 -0
  402. package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/image.js +106 -0
  403. package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/image.js.map +1 -0
  404. package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/index.d.ts +6 -0
  405. package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/index.d.ts.map +1 -0
  406. package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/index.js +5 -0
  407. package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/index.js.map +1 -0
  408. package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/path-utils.d.ts +4 -0
  409. package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/path-utils.d.ts.map +1 -0
  410. package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/path-utils.js +26 -0
  411. package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/path-utils.js.map +1 -0
  412. package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/read.d.ts +34 -0
  413. package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/read.d.ts.map +1 -0
  414. package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/read.js +110 -0
  415. package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/read.js.map +1 -0
  416. package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/tool-context.d.ts +6 -0
  417. package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/tool-context.d.ts.map +1 -0
  418. package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/tool-context.js +2 -0
  419. package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/tool-context.js.map +1 -0
  420. package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/write.d.ts +11 -0
  421. package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/write.d.ts.map +1 -0
  422. package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/write.js +31 -0
  423. package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/write.js.map +1 -0
  424. package/node_modules/@earendil-works/pi-agent-core/dist/harness/types.d.ts +80 -18
  425. package/node_modules/@earendil-works/pi-agent-core/dist/harness/types.d.ts.map +1 -1
  426. package/node_modules/@earendil-works/pi-agent-core/dist/harness/types.js.map +1 -1
  427. package/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/shell-output.d.ts +12 -4
  428. package/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/shell-output.d.ts.map +1 -1
  429. package/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/shell-output.js +90 -35
  430. package/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/shell-output.js.map +1 -1
  431. package/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/truncate.d.ts.map +1 -1
  432. package/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/truncate.js +10 -4
  433. package/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/truncate.js.map +1 -1
  434. package/node_modules/@earendil-works/pi-agent-core/dist/index.d.ts +4 -2
  435. package/node_modules/@earendil-works/pi-agent-core/dist/index.d.ts.map +1 -1
  436. package/node_modules/@earendil-works/pi-agent-core/dist/index.js +5 -2
  437. package/node_modules/@earendil-works/pi-agent-core/dist/index.js.map +1 -1
  438. package/node_modules/@earendil-works/pi-agent-core/dist/stream-fn.d.ts +10 -0
  439. package/node_modules/@earendil-works/pi-agent-core/dist/stream-fn.d.ts.map +1 -0
  440. package/node_modules/@earendil-works/pi-agent-core/dist/stream-fn.js +17 -0
  441. package/node_modules/@earendil-works/pi-agent-core/dist/stream-fn.js.map +1 -0
  442. package/node_modules/@earendil-works/pi-agent-core/dist/types.d.ts +8 -2
  443. package/node_modules/@earendil-works/pi-agent-core/dist/types.d.ts.map +1 -1
  444. package/node_modules/@earendil-works/pi-agent-core/dist/types.js.map +1 -1
  445. package/node_modules/@earendil-works/pi-agent-core/package.json +4 -3
  446. package/node_modules/@earendil-works/pi-ai/README.md +44 -4
  447. package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.d.ts.map +1 -1
  448. package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js +45 -27
  449. package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js.map +1 -1
  450. package/node_modules/@earendil-works/pi-ai/dist/api/azure-openai-responses.d.ts.map +1 -1
  451. package/node_modules/@earendil-works/pi-ai/dist/api/azure-openai-responses.js +21 -8
  452. package/node_modules/@earendil-works/pi-ai/dist/api/azure-openai-responses.js.map +1 -1
  453. package/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.d.ts.map +1 -1
  454. package/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.js +17 -10
  455. package/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.js.map +1 -1
  456. package/node_modules/@earendil-works/pi-ai/dist/api/constrained-sampling.d.ts +17 -0
  457. package/node_modules/@earendil-works/pi-ai/dist/api/constrained-sampling.d.ts.map +1 -0
  458. package/node_modules/@earendil-works/pi-ai/dist/api/constrained-sampling.js +104 -0
  459. package/node_modules/@earendil-works/pi-ai/dist/api/constrained-sampling.js.map +1 -0
  460. package/node_modules/@earendil-works/pi-ai/dist/api/google-generative-ai.d.ts.map +1 -1
  461. package/node_modules/@earendil-works/pi-ai/dist/api/google-generative-ai.js +7 -11
  462. package/node_modules/@earendil-works/pi-ai/dist/api/google-generative-ai.js.map +1 -1
  463. package/node_modules/@earendil-works/pi-ai/dist/api/google-shared.d.ts +4 -3
  464. package/node_modules/@earendil-works/pi-ai/dist/api/google-shared.d.ts.map +1 -1
  465. package/node_modules/@earendil-works/pi-ai/dist/api/google-shared.js +17 -3
  466. package/node_modules/@earendil-works/pi-ai/dist/api/google-shared.js.map +1 -1
  467. package/node_modules/@earendil-works/pi-ai/dist/api/google-vertex.d.ts.map +1 -1
  468. package/node_modules/@earendil-works/pi-ai/dist/api/google-vertex.js +7 -11
  469. package/node_modules/@earendil-works/pi-ai/dist/api/google-vertex.js.map +1 -1
  470. package/node_modules/@earendil-works/pi-ai/dist/api/mistral-conversations.d.ts.map +1 -1
  471. package/node_modules/@earendil-works/pi-ai/dist/api/mistral-conversations.js +13 -9
  472. package/node_modules/@earendil-works/pi-ai/dist/api/mistral-conversations.js.map +1 -1
  473. package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.d.ts.map +1 -1
  474. package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.js +73 -47
  475. package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.js.map +1 -1
  476. package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.d.ts +7 -9
  477. package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.d.ts.map +1 -1
  478. package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js +142 -33
  479. package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js.map +1 -1
  480. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.d.ts +7 -0
  481. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.d.ts.map +1 -1
  482. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.js +180 -80
  483. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.js.map +1 -1
  484. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.d.ts.map +1 -1
  485. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.js +37 -15
  486. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.js.map +1 -1
  487. package/node_modules/@earendil-works/pi-ai/dist/api/openrouter-images.d.ts.map +1 -1
  488. package/node_modules/@earendil-works/pi-ai/dist/api/openrouter-images.js +8 -3
  489. package/node_modules/@earendil-works/pi-ai/dist/api/openrouter-images.js.map +1 -1
  490. package/node_modules/@earendil-works/pi-ai/dist/api/pi-messages.d.ts.map +1 -1
  491. package/node_modules/@earendil-works/pi-ai/dist/api/pi-messages.js +2 -4
  492. package/node_modules/@earendil-works/pi-ai/dist/api/pi-messages.js.map +1 -1
  493. package/node_modules/@earendil-works/pi-ai/dist/api-registry.d.ts +15 -0
  494. package/node_modules/@earendil-works/pi-ai/dist/api-registry.d.ts.map +1 -1
  495. package/node_modules/@earendil-works/pi-ai/dist/api-registry.js +52 -6
  496. package/node_modules/@earendil-works/pi-ai/dist/api-registry.js.map +1 -1
  497. package/node_modules/@earendil-works/pi-ai/dist/auth/helpers.d.ts.map +1 -1
  498. package/node_modules/@earendil-works/pi-ai/dist/auth/helpers.js +3 -2
  499. package/node_modules/@earendil-works/pi-ai/dist/auth/helpers.js.map +1 -1
  500. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/kimi-coding.d.ts +10 -0
  501. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/kimi-coding.d.ts.map +1 -0
  502. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/kimi-coding.js +249 -0
  503. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/kimi-coding.js.map +1 -0
  504. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/load.d.ts +4 -0
  505. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/load.d.ts.map +1 -1
  506. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/load.js +10 -0
  507. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/load.js.map +1 -1
  508. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/openai-codex.d.ts.map +1 -1
  509. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/openai-codex.js +2 -18
  510. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/openai-codex.js.map +1 -1
  511. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/openrouter.d.ts +13 -0
  512. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/openrouter.d.ts.map +1 -0
  513. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/openrouter.js +222 -0
  514. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/openrouter.js.map +1 -0
  515. package/node_modules/@earendil-works/pi-ai/dist/bun-oauth.d.ts.map +1 -1
  516. package/node_modules/@earendil-works/pi-ai/dist/bun-oauth.js +4 -0
  517. package/node_modules/@earendil-works/pi-ai/dist/bun-oauth.js.map +1 -1
  518. package/node_modules/@earendil-works/pi-ai/dist/compat.d.ts.map +1 -1
  519. package/node_modules/@earendil-works/pi-ai/dist/compat.js +2 -1
  520. package/node_modules/@earendil-works/pi-ai/dist/compat.js.map +1 -1
  521. package/node_modules/@earendil-works/pi-ai/dist/context-provenance.d.ts +16 -0
  522. package/node_modules/@earendil-works/pi-ai/dist/context-provenance.d.ts.map +1 -0
  523. package/node_modules/@earendil-works/pi-ai/dist/context-provenance.js +32 -0
  524. package/node_modules/@earendil-works/pi-ai/dist/context-provenance.js.map +1 -0
  525. package/node_modules/@earendil-works/pi-ai/dist/env-api-keys.d.ts +3 -0
  526. package/node_modules/@earendil-works/pi-ai/dist/env-api-keys.d.ts.map +1 -1
  527. package/node_modules/@earendil-works/pi-ai/dist/env-api-keys.js +11 -3
  528. package/node_modules/@earendil-works/pi-ai/dist/env-api-keys.js.map +1 -1
  529. package/node_modules/@earendil-works/pi-ai/dist/image-models.generated.d.ts +15 -0
  530. package/node_modules/@earendil-works/pi-ai/dist/image-models.generated.d.ts.map +1 -1
  531. package/node_modules/@earendil-works/pi-ai/dist/image-models.generated.js +15 -0
  532. package/node_modules/@earendil-works/pi-ai/dist/image-models.generated.js.map +1 -1
  533. package/node_modules/@earendil-works/pi-ai/dist/images-api-registry.d.ts +19 -2
  534. package/node_modules/@earendil-works/pi-ai/dist/images-api-registry.d.ts.map +1 -1
  535. package/node_modules/@earendil-works/pi-ai/dist/images-api-registry.js +68 -3
  536. package/node_modules/@earendil-works/pi-ai/dist/images-api-registry.js.map +1 -1
  537. package/node_modules/@earendil-works/pi-ai/dist/index.d.ts +5 -0
  538. package/node_modules/@earendil-works/pi-ai/dist/index.d.ts.map +1 -1
  539. package/node_modules/@earendil-works/pi-ai/dist/index.js +5 -0
  540. package/node_modules/@earendil-works/pi-ai/dist/index.js.map +1 -1
  541. package/node_modules/@earendil-works/pi-ai/dist/model-catalog.d.ts +17 -0
  542. package/node_modules/@earendil-works/pi-ai/dist/model-catalog.d.ts.map +1 -0
  543. package/node_modules/@earendil-works/pi-ai/dist/model-catalog.js +4 -0
  544. package/node_modules/@earendil-works/pi-ai/dist/model-catalog.js.map +1 -0
  545. package/node_modules/@earendil-works/pi-ai/dist/model.d.ts +2 -2
  546. package/node_modules/@earendil-works/pi-ai/dist/model.d.ts.map +1 -1
  547. package/node_modules/@earendil-works/pi-ai/dist/model.js.map +1 -1
  548. package/node_modules/@earendil-works/pi-ai/dist/models-store.d.ts +2 -0
  549. package/node_modules/@earendil-works/pi-ai/dist/models-store.d.ts.map +1 -1
  550. package/node_modules/@earendil-works/pi-ai/dist/models-store.js.map +1 -1
  551. package/node_modules/@earendil-works/pi-ai/dist/models.d.ts +0 -6
  552. package/node_modules/@earendil-works/pi-ai/dist/models.d.ts.map +1 -1
  553. package/node_modules/@earendil-works/pi-ai/dist/models.generated.d.ts +76 -4448
  554. package/node_modules/@earendil-works/pi-ai/dist/models.generated.d.ts.map +1 -1
  555. package/node_modules/@earendil-works/pi-ai/dist/models.generated.js +4 -0
  556. package/node_modules/@earendil-works/pi-ai/dist/models.generated.js.map +1 -1
  557. package/node_modules/@earendil-works/pi-ai/dist/models.js +0 -53
  558. package/node_modules/@earendil-works/pi-ai/dist/models.js.map +1 -1
  559. package/node_modules/@earendil-works/pi-ai/dist/node/provider-scope.d.ts +12 -0
  560. package/node_modules/@earendil-works/pi-ai/dist/node/provider-scope.d.ts.map +1 -0
  561. package/node_modules/@earendil-works/pi-ai/dist/node/provider-scope.js +34 -0
  562. package/node_modules/@earendil-works/pi-ai/dist/node/provider-scope.js.map +1 -0
  563. package/node_modules/@earendil-works/pi-ai/dist/providers/alibaba-token-plan.models.d.ts +3 -63
  564. package/node_modules/@earendil-works/pi-ai/dist/providers/alibaba-token-plan.models.d.ts.map +1 -1
  565. package/node_modules/@earendil-works/pi-ai/dist/providers/alibaba-token-plan.models.js +2 -1
  566. package/node_modules/@earendil-works/pi-ai/dist/providers/alibaba-token-plan.models.js.map +1 -1
  567. package/node_modules/@earendil-works/pi-ai/dist/providers/all.d.ts +2 -0
  568. package/node_modules/@earendil-works/pi-ai/dist/providers/all.d.ts.map +1 -1
  569. package/node_modules/@earendil-works/pi-ai/dist/providers/all.js +10 -0
  570. package/node_modules/@earendil-works/pi-ai/dist/providers/all.js.map +1 -1
  571. package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.d.ts.map +1 -1
  572. package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.js +3 -2
  573. package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.js.map +1 -1
  574. package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.models.d.ts +3 -439
  575. package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.models.d.ts.map +1 -1
  576. package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.models.js +2 -1
  577. package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.models.js.map +1 -1
  578. package/node_modules/@earendil-works/pi-ai/dist/providers/ant-ling.models.d.ts +3 -15
  579. package/node_modules/@earendil-works/pi-ai/dist/providers/ant-ling.models.d.ts.map +1 -1
  580. package/node_modules/@earendil-works/pi-ai/dist/providers/ant-ling.models.js +2 -1
  581. package/node_modules/@earendil-works/pi-ai/dist/providers/ant-ling.models.js.map +1 -1
  582. package/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.d.ts.map +1 -1
  583. package/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.js +30 -3
  584. package/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.js.map +1 -1
  585. package/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.models.d.ts +3 -59
  586. package/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.models.d.ts.map +1 -1
  587. package/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.models.js +2 -1
  588. package/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.models.js.map +1 -1
  589. package/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.models.d.ts +3 -187
  590. package/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.models.d.ts.map +1 -1
  591. package/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.models.js +2 -1
  592. package/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.models.js.map +1 -1
  593. package/node_modules/@earendil-works/pi-ai/dist/providers/cerebras.models.d.ts +3 -15
  594. package/node_modules/@earendil-works/pi-ai/dist/providers/cerebras.models.d.ts.map +1 -1
  595. package/node_modules/@earendil-works/pi-ai/dist/providers/cerebras.models.js +2 -1
  596. package/node_modules/@earendil-works/pi-ai/dist/providers/cerebras.models.js.map +1 -1
  597. package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-ai-gateway.models.d.ts +3 -171
  598. package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-ai-gateway.models.d.ts.map +1 -1
  599. package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-ai-gateway.models.js +2 -1
  600. package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-ai-gateway.models.js.map +1 -1
  601. package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-workers-ai.models.d.ts +3 -55
  602. package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-workers-ai.models.d.ts.map +1 -1
  603. package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-workers-ai.models.js +2 -1
  604. package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-workers-ai.models.js.map +1 -1
  605. package/node_modules/@earendil-works/pi-ai/dist/providers/data/.manifest.json +1 -0
  606. package/node_modules/@earendil-works/pi-ai/dist/providers/data/alibaba-token-plan.json +1 -1
  607. package/node_modules/@earendil-works/pi-ai/dist/providers/data/amazon-bedrock.json +1 -1
  608. package/node_modules/@earendil-works/pi-ai/dist/providers/data/ant-ling.json +1 -1
  609. package/node_modules/@earendil-works/pi-ai/dist/providers/data/anthropic.json +1 -1
  610. package/node_modules/@earendil-works/pi-ai/dist/providers/data/azure-openai-responses.json +1 -1
  611. package/node_modules/@earendil-works/pi-ai/dist/providers/data/cerebras.json +1 -1
  612. package/node_modules/@earendil-works/pi-ai/dist/providers/data/cloudflare-ai-gateway.json +1 -1
  613. package/node_modules/@earendil-works/pi-ai/dist/providers/data/cloudflare-workers-ai.json +1 -1
  614. package/node_modules/@earendil-works/pi-ai/dist/providers/data/deepseek.json +1 -1
  615. package/node_modules/@earendil-works/pi-ai/dist/providers/data/fireworks.json +1 -1
  616. package/node_modules/@earendil-works/pi-ai/dist/providers/data/github-copilot.json +1 -1
  617. package/node_modules/@earendil-works/pi-ai/dist/providers/data/google-vertex.json +1 -1
  618. package/node_modules/@earendil-works/pi-ai/dist/providers/data/google.json +1 -1
  619. package/node_modules/@earendil-works/pi-ai/dist/providers/data/groq.json +1 -1
  620. package/node_modules/@earendil-works/pi-ai/dist/providers/data/huggingface.json +1 -1
  621. package/node_modules/@earendil-works/pi-ai/dist/providers/data/kimi-coding.json +1 -1
  622. package/node_modules/@earendil-works/pi-ai/dist/providers/data/minimax-cn.json +1 -1
  623. package/node_modules/@earendil-works/pi-ai/dist/providers/data/minimax.json +1 -1
  624. package/node_modules/@earendil-works/pi-ai/dist/providers/data/mistral.json +1 -1
  625. package/node_modules/@earendil-works/pi-ai/dist/providers/data/moonshotai-cn.json +1 -1
  626. package/node_modules/@earendil-works/pi-ai/dist/providers/data/moonshotai.json +1 -1
  627. package/node_modules/@earendil-works/pi-ai/dist/providers/data/nvidia.json +1 -1
  628. package/node_modules/@earendil-works/pi-ai/dist/providers/data/openai-codex.json +1 -1
  629. package/node_modules/@earendil-works/pi-ai/dist/providers/data/openai.json +1 -1
  630. package/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode-go.json +1 -1
  631. package/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode.json +1 -1
  632. package/node_modules/@earendil-works/pi-ai/dist/providers/data/openrouter.json +1 -1
  633. package/node_modules/@earendil-works/pi-ai/dist/providers/data/qwen-token-plan-cn.json +1 -0
  634. package/node_modules/@earendil-works/pi-ai/dist/providers/data/qwen-token-plan.json +1 -0
  635. package/node_modules/@earendil-works/pi-ai/dist/providers/data/together.json +1 -1
  636. package/node_modules/@earendil-works/pi-ai/dist/providers/data/vercel-ai-gateway.json +1 -1
  637. package/node_modules/@earendil-works/pi-ai/dist/providers/data/xai.json +1 -1
  638. package/node_modules/@earendil-works/pi-ai/dist/providers/data/xiaomi-token-plan-ams.json +1 -1
  639. package/node_modules/@earendil-works/pi-ai/dist/providers/data/xiaomi-token-plan-cn.json +1 -1
  640. package/node_modules/@earendil-works/pi-ai/dist/providers/data/xiaomi-token-plan-sgp.json +1 -1
  641. package/node_modules/@earendil-works/pi-ai/dist/providers/data/xiaomi.json +1 -1
  642. package/node_modules/@earendil-works/pi-ai/dist/providers/data/zai-coding-cn.json +1 -1
  643. package/node_modules/@earendil-works/pi-ai/dist/providers/data/zai.json +1 -1
  644. package/node_modules/@earendil-works/pi-ai/dist/providers/deepseek.models.d.ts +3 -11
  645. package/node_modules/@earendil-works/pi-ai/dist/providers/deepseek.models.d.ts.map +1 -1
  646. package/node_modules/@earendil-works/pi-ai/dist/providers/deepseek.models.js +2 -1
  647. package/node_modules/@earendil-works/pi-ai/dist/providers/deepseek.models.js.map +1 -1
  648. package/node_modules/@earendil-works/pi-ai/dist/providers/fireworks.models.d.ts +3 -67
  649. package/node_modules/@earendil-works/pi-ai/dist/providers/fireworks.models.d.ts.map +1 -1
  650. package/node_modules/@earendil-works/pi-ai/dist/providers/fireworks.models.js +2 -1
  651. package/node_modules/@earendil-works/pi-ai/dist/providers/fireworks.models.js.map +1 -1
  652. package/node_modules/@earendil-works/pi-ai/dist/providers/github-copilot.models.d.ts +3 -115
  653. package/node_modules/@earendil-works/pi-ai/dist/providers/github-copilot.models.d.ts.map +1 -1
  654. package/node_modules/@earendil-works/pi-ai/dist/providers/github-copilot.models.js +2 -1
  655. package/node_modules/@earendil-works/pi-ai/dist/providers/github-copilot.models.js.map +1 -1
  656. package/node_modules/@earendil-works/pi-ai/dist/providers/google-vertex.models.d.ts +3 -51
  657. package/node_modules/@earendil-works/pi-ai/dist/providers/google-vertex.models.d.ts.map +1 -1
  658. package/node_modules/@earendil-works/pi-ai/dist/providers/google-vertex.models.js +2 -1
  659. package/node_modules/@earendil-works/pi-ai/dist/providers/google-vertex.models.js.map +1 -1
  660. package/node_modules/@earendil-works/pi-ai/dist/providers/google.models.d.ts +3 -75
  661. package/node_modules/@earendil-works/pi-ai/dist/providers/google.models.d.ts.map +1 -1
  662. package/node_modules/@earendil-works/pi-ai/dist/providers/google.models.js +2 -1
  663. package/node_modules/@earendil-works/pi-ai/dist/providers/google.models.js.map +1 -1
  664. package/node_modules/@earendil-works/pi-ai/dist/providers/groq.models.d.ts +3 -31
  665. package/node_modules/@earendil-works/pi-ai/dist/providers/groq.models.d.ts.map +1 -1
  666. package/node_modules/@earendil-works/pi-ai/dist/providers/groq.models.js +2 -1
  667. package/node_modules/@earendil-works/pi-ai/dist/providers/groq.models.js.map +1 -1
  668. package/node_modules/@earendil-works/pi-ai/dist/providers/huggingface.models.d.ts +3 -203
  669. package/node_modules/@earendil-works/pi-ai/dist/providers/huggingface.models.d.ts.map +1 -1
  670. package/node_modules/@earendil-works/pi-ai/dist/providers/huggingface.models.js +2 -1
  671. package/node_modules/@earendil-works/pi-ai/dist/providers/huggingface.models.js.map +1 -1
  672. package/node_modules/@earendil-works/pi-ai/dist/providers/images/register-builtins.js +2 -2
  673. package/node_modules/@earendil-works/pi-ai/dist/providers/images/register-builtins.js.map +1 -1
  674. package/node_modules/@earendil-works/pi-ai/dist/providers/kimi-coding.d.ts.map +1 -1
  675. package/node_modules/@earendil-works/pi-ai/dist/providers/kimi-coding.js +10 -2
  676. package/node_modules/@earendil-works/pi-ai/dist/providers/kimi-coding.js.map +1 -1
  677. package/node_modules/@earendil-works/pi-ai/dist/providers/kimi-coding.models.d.ts +3 -19
  678. package/node_modules/@earendil-works/pi-ai/dist/providers/kimi-coding.models.d.ts.map +1 -1
  679. package/node_modules/@earendil-works/pi-ai/dist/providers/kimi-coding.models.js +2 -1
  680. package/node_modules/@earendil-works/pi-ai/dist/providers/kimi-coding.models.js.map +1 -1
  681. package/node_modules/@earendil-works/pi-ai/dist/providers/minimax-cn.models.d.ts +3 -15
  682. package/node_modules/@earendil-works/pi-ai/dist/providers/minimax-cn.models.d.ts.map +1 -1
  683. package/node_modules/@earendil-works/pi-ai/dist/providers/minimax-cn.models.js +2 -1
  684. package/node_modules/@earendil-works/pi-ai/dist/providers/minimax-cn.models.js.map +1 -1
  685. package/node_modules/@earendil-works/pi-ai/dist/providers/minimax.models.d.ts +3 -15
  686. package/node_modules/@earendil-works/pi-ai/dist/providers/minimax.models.d.ts.map +1 -1
  687. package/node_modules/@earendil-works/pi-ai/dist/providers/minimax.models.js +2 -1
  688. package/node_modules/@earendil-works/pi-ai/dist/providers/minimax.models.js.map +1 -1
  689. package/node_modules/@earendil-works/pi-ai/dist/providers/mistral.models.d.ts +3 -123
  690. package/node_modules/@earendil-works/pi-ai/dist/providers/mistral.models.d.ts.map +1 -1
  691. package/node_modules/@earendil-works/pi-ai/dist/providers/mistral.models.js +2 -1
  692. package/node_modules/@earendil-works/pi-ai/dist/providers/mistral.models.js.map +1 -1
  693. package/node_modules/@earendil-works/pi-ai/dist/providers/moonshotai-cn.models.d.ts +3 -43
  694. package/node_modules/@earendil-works/pi-ai/dist/providers/moonshotai-cn.models.d.ts.map +1 -1
  695. package/node_modules/@earendil-works/pi-ai/dist/providers/moonshotai-cn.models.js +2 -1
  696. package/node_modules/@earendil-works/pi-ai/dist/providers/moonshotai-cn.models.js.map +1 -1
  697. package/node_modules/@earendil-works/pi-ai/dist/providers/moonshotai.models.d.ts +3 -43
  698. package/node_modules/@earendil-works/pi-ai/dist/providers/moonshotai.models.d.ts.map +1 -1
  699. package/node_modules/@earendil-works/pi-ai/dist/providers/moonshotai.models.js +2 -1
  700. package/node_modules/@earendil-works/pi-ai/dist/providers/moonshotai.models.js.map +1 -1
  701. package/node_modules/@earendil-works/pi-ai/dist/providers/nvidia.models.d.ts +3 -79
  702. package/node_modules/@earendil-works/pi-ai/dist/providers/nvidia.models.d.ts.map +1 -1
  703. package/node_modules/@earendil-works/pi-ai/dist/providers/nvidia.models.js +2 -1
  704. package/node_modules/@earendil-works/pi-ai/dist/providers/nvidia.models.js.map +1 -1
  705. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-codex.models.d.ts +3 -31
  706. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-codex.models.d.ts.map +1 -1
  707. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-codex.models.js +2 -1
  708. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-codex.models.js.map +1 -1
  709. package/node_modules/@earendil-works/pi-ai/dist/providers/openai.models.d.ts +3 -187
  710. package/node_modules/@earendil-works/pi-ai/dist/providers/openai.models.d.ts.map +1 -1
  711. package/node_modules/@earendil-works/pi-ai/dist/providers/openai.models.js +2 -1
  712. package/node_modules/@earendil-works/pi-ai/dist/providers/openai.models.js.map +1 -1
  713. package/node_modules/@earendil-works/pi-ai/dist/providers/opencode-go.models.d.ts +3 -67
  714. package/node_modules/@earendil-works/pi-ai/dist/providers/opencode-go.models.d.ts.map +1 -1
  715. package/node_modules/@earendil-works/pi-ai/dist/providers/opencode-go.models.js +2 -1
  716. package/node_modules/@earendil-works/pi-ai/dist/providers/opencode-go.models.js.map +1 -1
  717. package/node_modules/@earendil-works/pi-ai/dist/providers/opencode.models.d.ts +3 -227
  718. package/node_modules/@earendil-works/pi-ai/dist/providers/opencode.models.d.ts.map +1 -1
  719. package/node_modules/@earendil-works/pi-ai/dist/providers/opencode.models.js +2 -1
  720. package/node_modules/@earendil-works/pi-ai/dist/providers/opencode.models.js.map +1 -1
  721. package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter-images.d.ts.map +1 -1
  722. package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter-images.js +10 -2
  723. package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter-images.js.map +1 -1
  724. package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.d.ts.map +1 -1
  725. package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.js +10 -2
  726. package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.js.map +1 -1
  727. package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.models.d.ts +3 -1095
  728. package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.models.d.ts.map +1 -1
  729. package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.models.js +2 -1
  730. package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.models.js.map +1 -1
  731. package/node_modules/@earendil-works/pi-ai/dist/providers/qwen-token-plan-cn.d.ts +3 -0
  732. package/node_modules/@earendil-works/pi-ai/dist/providers/qwen-token-plan-cn.d.ts.map +1 -0
  733. package/node_modules/@earendil-works/pi-ai/dist/providers/qwen-token-plan-cn.js +15 -0
  734. package/node_modules/@earendil-works/pi-ai/dist/providers/qwen-token-plan-cn.js.map +1 -0
  735. package/node_modules/@earendil-works/pi-ai/dist/providers/qwen-token-plan-cn.models.d.ts +4 -0
  736. package/node_modules/@earendil-works/pi-ai/dist/providers/qwen-token-plan-cn.models.d.ts.map +1 -0
  737. package/node_modules/@earendil-works/pi-ai/dist/providers/qwen-token-plan-cn.models.js +6 -0
  738. package/node_modules/@earendil-works/pi-ai/dist/providers/qwen-token-plan-cn.models.js.map +1 -0
  739. package/node_modules/@earendil-works/pi-ai/dist/providers/qwen-token-plan.d.ts +3 -0
  740. package/node_modules/@earendil-works/pi-ai/dist/providers/qwen-token-plan.d.ts.map +1 -0
  741. package/node_modules/@earendil-works/pi-ai/dist/providers/qwen-token-plan.js +15 -0
  742. package/node_modules/@earendil-works/pi-ai/dist/providers/qwen-token-plan.js.map +1 -0
  743. package/node_modules/@earendil-works/pi-ai/dist/providers/qwen-token-plan.models.d.ts +4 -0
  744. package/node_modules/@earendil-works/pi-ai/dist/providers/qwen-token-plan.models.d.ts.map +1 -0
  745. package/node_modules/@earendil-works/pi-ai/dist/providers/qwen-token-plan.models.js +6 -0
  746. package/node_modules/@earendil-works/pi-ai/dist/providers/qwen-token-plan.models.js.map +1 -0
  747. package/node_modules/@earendil-works/pi-ai/dist/providers/radius-config.d.ts.map +1 -1
  748. package/node_modules/@earendil-works/pi-ai/dist/providers/radius-config.js +18 -14
  749. package/node_modules/@earendil-works/pi-ai/dist/providers/radius-config.js.map +1 -1
  750. package/node_modules/@earendil-works/pi-ai/dist/providers/together.models.d.ts +3 -67
  751. package/node_modules/@earendil-works/pi-ai/dist/providers/together.models.d.ts.map +1 -1
  752. package/node_modules/@earendil-works/pi-ai/dist/providers/together.models.js +2 -1
  753. package/node_modules/@earendil-works/pi-ai/dist/providers/together.models.js.map +1 -1
  754. package/node_modules/@earendil-works/pi-ai/dist/providers/vercel-ai-gateway.models.d.ts +3 -775
  755. package/node_modules/@earendil-works/pi-ai/dist/providers/vercel-ai-gateway.models.d.ts.map +1 -1
  756. package/node_modules/@earendil-works/pi-ai/dist/providers/vercel-ai-gateway.models.js +2 -1
  757. package/node_modules/@earendil-works/pi-ai/dist/providers/vercel-ai-gateway.models.js.map +1 -1
  758. package/node_modules/@earendil-works/pi-ai/dist/providers/xai.models.d.ts +3 -15
  759. package/node_modules/@earendil-works/pi-ai/dist/providers/xai.models.d.ts.map +1 -1
  760. package/node_modules/@earendil-works/pi-ai/dist/providers/xai.models.js +2 -1
  761. package/node_modules/@earendil-works/pi-ai/dist/providers/xai.models.js.map +1 -1
  762. package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi-token-plan-ams.models.d.ts +3 -15
  763. package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi-token-plan-ams.models.d.ts.map +1 -1
  764. package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi-token-plan-ams.models.js +2 -1
  765. package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi-token-plan-ams.models.js.map +1 -1
  766. package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi-token-plan-cn.models.d.ts +3 -15
  767. package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi-token-plan-cn.models.d.ts.map +1 -1
  768. package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi-token-plan-cn.models.js +2 -1
  769. package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi-token-plan-cn.models.js.map +1 -1
  770. package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi-token-plan-sgp.models.d.ts +3 -15
  771. package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi-token-plan-sgp.models.d.ts.map +1 -1
  772. package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi-token-plan-sgp.models.js +2 -1
  773. package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi-token-plan-sgp.models.js.map +1 -1
  774. package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi.models.d.ts +3 -27
  775. package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi.models.d.ts.map +1 -1
  776. package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi.models.js +2 -1
  777. package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi.models.js.map +1 -1
  778. package/node_modules/@earendil-works/pi-ai/dist/providers/zai-coding-cn.models.d.ts +3 -27
  779. package/node_modules/@earendil-works/pi-ai/dist/providers/zai-coding-cn.models.d.ts.map +1 -1
  780. package/node_modules/@earendil-works/pi-ai/dist/providers/zai-coding-cn.models.js +2 -1
  781. package/node_modules/@earendil-works/pi-ai/dist/providers/zai-coding-cn.models.js.map +1 -1
  782. package/node_modules/@earendil-works/pi-ai/dist/providers/zai.models.d.ts +3 -27
  783. package/node_modules/@earendil-works/pi-ai/dist/providers/zai.models.d.ts.map +1 -1
  784. package/node_modules/@earendil-works/pi-ai/dist/providers/zai.models.js +2 -1
  785. package/node_modules/@earendil-works/pi-ai/dist/providers/zai.models.js.map +1 -1
  786. package/node_modules/@earendil-works/pi-ai/dist/types.d.ts +43 -3
  787. package/node_modules/@earendil-works/pi-ai/dist/types.d.ts.map +1 -1
  788. package/node_modules/@earendil-works/pi-ai/dist/types.js.map +1 -1
  789. package/node_modules/@earendil-works/pi-ai/dist/utils/openai-codex-auth.d.ts +11 -0
  790. package/node_modules/@earendil-works/pi-ai/dist/utils/openai-codex-auth.d.ts.map +1 -0
  791. package/node_modules/@earendil-works/pi-ai/dist/utils/openai-codex-auth.js +30 -0
  792. package/node_modules/@earendil-works/pi-ai/dist/utils/openai-codex-auth.js.map +1 -0
  793. package/node_modules/@earendil-works/pi-ai/dist/utils/overflow.d.ts +1 -0
  794. package/node_modules/@earendil-works/pi-ai/dist/utils/overflow.d.ts.map +1 -1
  795. package/node_modules/@earendil-works/pi-ai/dist/utils/overflow.js +3 -0
  796. package/node_modules/@earendil-works/pi-ai/dist/utils/overflow.js.map +1 -1
  797. package/node_modules/@earendil-works/pi-ai/dist/utils/provider-retry.d.ts +16 -0
  798. package/node_modules/@earendil-works/pi-ai/dist/utils/provider-retry.d.ts.map +1 -0
  799. package/node_modules/@earendil-works/pi-ai/dist/utils/provider-retry.js +94 -0
  800. package/node_modules/@earendil-works/pi-ai/dist/utils/provider-retry.js.map +1 -0
  801. package/node_modules/@earendil-works/pi-ai/dist/utils/retry.d.ts +41 -0
  802. package/node_modules/@earendil-works/pi-ai/dist/utils/retry.d.ts.map +1 -1
  803. package/node_modules/@earendil-works/pi-ai/dist/utils/retry.js +82 -0
  804. package/node_modules/@earendil-works/pi-ai/dist/utils/retry.js.map +1 -1
  805. package/node_modules/@earendil-works/pi-ai/dist/utils/text.d.ts +6 -0
  806. package/node_modules/@earendil-works/pi-ai/dist/utils/text.d.ts.map +1 -0
  807. package/node_modules/@earendil-works/pi-ai/dist/utils/text.js +10 -0
  808. package/node_modules/@earendil-works/pi-ai/dist/utils/text.js.map +1 -0
  809. package/node_modules/@earendil-works/pi-ai/dist/utils/uuid.d.ts +3 -0
  810. package/node_modules/@earendil-works/pi-ai/dist/utils/uuid.d.ts.map +1 -0
  811. package/node_modules/@earendil-works/{pi-agent-core/dist/harness/session → pi-ai/dist/utils}/uuid.js +2 -2
  812. package/node_modules/@earendil-works/pi-ai/dist/utils/uuid.js.map +1 -0
  813. package/node_modules/@earendil-works/pi-ai/package.json +11 -4
  814. package/node_modules/@earendil-works/pi-pty/package.json +1 -1
  815. package/node_modules/@earendil-works/pi-tui/dist/components/editor.d.ts.map +1 -1
  816. package/node_modules/@earendil-works/pi-tui/dist/components/editor.js +31 -22
  817. package/node_modules/@earendil-works/pi-tui/dist/components/editor.js.map +1 -1
  818. package/node_modules/@earendil-works/pi-tui/dist/tui.d.ts.map +1 -1
  819. package/node_modules/@earendil-works/pi-tui/dist/tui.js +2 -0
  820. package/node_modules/@earendil-works/pi-tui/dist/tui.js.map +1 -1
  821. package/node_modules/@earendil-works/pi-tui/package.json +1 -1
  822. package/package.json +7 -6
  823. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/uuid.d.ts +0 -2
  824. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/uuid.d.ts.map +0 -1
  825. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/uuid.js.map +0 -1
@@ -0,0 +1,162 @@
1
+ import { existsSync, realpathSync } from "node:fs";
2
+ import { basename, dirname, isAbsolute, resolve } from "node:path";
3
+ import { ProviderScope, runWithProviderScope } from "@earendil-works/pi-ai/node/provider-scope";
4
+ import { createAgentSessionRuntime, } from "../../core/agent-session-runtime.js";
5
+ import { SessionManager } from "../../core/session-manager.js";
6
+ export class RpcSessionRegistryError extends Error {
7
+ constructor(code) {
8
+ super(code);
9
+ this.code = code;
10
+ this.name = "RpcSessionRegistryError";
11
+ }
12
+ }
13
+ function canonicalPath(path) {
14
+ const absolutePath = resolve(path);
15
+ if (existsSync(absolutePath))
16
+ return realpathSync(absolutePath);
17
+ return `${realpathSync(dirname(absolutePath))}/${basename(absolutePath)}`;
18
+ }
19
+ function frozenProfile(profile) {
20
+ return Object.freeze({
21
+ ...profile,
22
+ ...(profile.creationModel ? { creationModel: Object.freeze({ ...profile.creationModel }) } : {}),
23
+ });
24
+ }
25
+ /** Process-local lifecycle owner for multi-session RPC runtimes. */
26
+ export class RpcSessionRegistry {
27
+ constructor(options) {
28
+ this.entries = new Map();
29
+ this.reservations = new Set();
30
+ this.nextHandle = 0;
31
+ this.options = options;
32
+ }
33
+ async openSession(profile) {
34
+ this.validateProfile(profile);
35
+ const sessionPath = profile.sessionPath ? canonicalPath(profile.sessionPath) : undefined;
36
+ if (sessionPath && this.reservations.has(sessionPath))
37
+ throw new RpcSessionRegistryError("session_path_in_use");
38
+ if (sessionPath)
39
+ this.reservations.add(sessionPath);
40
+ // Resume vs create parity (D1 + omo SenpiSessionRuntime.ts:198-200):
41
+ // Create-only launch semantics mirror classic startup flags. A resumed
42
+ // session restores its persisted model and thinking level instead of being
43
+ // overridden by the new open_session request.
44
+ const isResume = sessionPath !== undefined && existsSync(sessionPath);
45
+ const storedProfile = frozenProfile({ ...profile, ...(sessionPath ? { sessionPath } : {}) });
46
+ const runtimeProfile = isResume
47
+ ? frozenProfile({ ...storedProfile, creationModel: undefined, initialThinkingLevel: undefined })
48
+ : storedProfile;
49
+ const handle = `rpc-${++this.nextHandle}`;
50
+ const entry = {
51
+ state: "opening",
52
+ scope: new ProviderScope(),
53
+ profile: storedProfile,
54
+ sessionPath,
55
+ lifecycleMutex: Promise.resolve(),
56
+ };
57
+ this.entries.set(handle, entry);
58
+ try {
59
+ const manager = sessionPath
60
+ ? SessionManager.open(sessionPath, undefined, storedProfile.cwd)
61
+ : SessionManager.create(storedProfile.cwd);
62
+ entry.runtime = await runWithProviderScope(entry.scope, () => createAgentSessionRuntime(this.options.createRuntime, {
63
+ cwd: manager.getCwd(),
64
+ agentDir: this.options.agentDir,
65
+ sessionManager: manager,
66
+ launchProfile: runtimeProfile,
67
+ }));
68
+ entry.durableSessionId = manager.getSessionId();
69
+ entry.sessionPath ??= manager.getSessionFile();
70
+ entry.state = "open";
71
+ return { sessionId: handle, durableSessionId: entry.durableSessionId, sessionPath: entry.sessionPath };
72
+ }
73
+ catch (error) {
74
+ // Runtime construction may have started extensions, watchers, and provider
75
+ // registrations before it rejects. Keep the reservation and entry private
76
+ // until all of those resources have been torn down, then release them as
77
+ // one rollback so the path can immediately be opened again.
78
+ try {
79
+ await entry.runtime?.dispose();
80
+ }
81
+ catch {
82
+ // The original construction error remains the externally visible cause.
83
+ }
84
+ finally {
85
+ try {
86
+ await entry.scope.close?.();
87
+ }
88
+ finally {
89
+ this.entries.delete(handle);
90
+ if (sessionPath)
91
+ this.reservations.delete(sessionPath);
92
+ }
93
+ }
94
+ if (error instanceof RpcSessionRegistryError)
95
+ throw error;
96
+ throw new RpcSessionRegistryError("open_failed");
97
+ }
98
+ }
99
+ getForCommand(handle, command) {
100
+ const entry = this.entries.get(handle);
101
+ if (!entry)
102
+ throw new RpcSessionRegistryError("unknown_session");
103
+ if (entry.state === "closing" && !["abort", "abort_bash", "extension_ui_response"].includes(command)) {
104
+ throw new RpcSessionRegistryError("session_closing");
105
+ }
106
+ if (entry.state !== "open" && entry.state !== "closing")
107
+ throw new RpcSessionRegistryError("unknown_session");
108
+ return entry;
109
+ }
110
+ /**
111
+ * Starts a close synchronously. Call this before disposing any session-owned
112
+ * binding so a concurrent command cannot reach a half-disposed handler.
113
+ */
114
+ beginClose(handle) {
115
+ const entry = this.entries.get(handle);
116
+ if (entry?.state !== "open")
117
+ throw new RpcSessionRegistryError("unknown_session");
118
+ entry.state = "closing";
119
+ return entry;
120
+ }
121
+ async close(handle) {
122
+ this.beginClose(handle);
123
+ return this.closeMarked(handle);
124
+ }
125
+ /** Completes a close previously made visible by beginClose(). */
126
+ async closeMarked(handle) {
127
+ const entry = this.entries.get(handle);
128
+ if (entry?.state !== "closing")
129
+ throw new RpcSessionRegistryError("unknown_session");
130
+ entry.lifecycleMutex = (async () => {
131
+ try {
132
+ await entry.runtime?.session.abort();
133
+ await entry.runtime?.session.waitForIdle();
134
+ await entry.runtime?.dispose();
135
+ await entry.scope.close?.();
136
+ }
137
+ finally {
138
+ entry.state = "closed";
139
+ this.entries.delete(handle);
140
+ if (entry.sessionPath)
141
+ this.reservations.delete(entry.sessionPath);
142
+ }
143
+ })();
144
+ return entry.lifecycleMutex;
145
+ }
146
+ list() {
147
+ return [...this.entries].map(([sessionId, entry]) => ({
148
+ sessionId,
149
+ durableSessionId: entry.durableSessionId,
150
+ sessionPath: entry.sessionPath,
151
+ cwd: entry.profile.cwd,
152
+ name: entry.runtime?.session.sessionManager.getSessionName(),
153
+ status: entry.state,
154
+ }));
155
+ }
156
+ validateProfile(profile) {
157
+ if (!isAbsolute(profile.cwd) || (profile.sessionPath !== undefined && !isAbsolute(profile.sessionPath))) {
158
+ throw new RpcSessionRegistryError("invalid_path");
159
+ }
160
+ }
161
+ }
162
+ //# sourceMappingURL=session-registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-registry.js","sourceRoot":"","sources":["../../../src/modes/rpc/session-registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AAChG,OAAO,EAI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AAC,OAAO,CAAC,WAAW,KAAK,SAAS,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC;YACzG,MAAM,IAAI,uBAAuB,CAAC,cAAc,CAAC,CAAC;QACnD,CAAC;IACF,CAAC;CACD","sourcesContent":["import { existsSync, realpathSync } from \"node:fs\";\nimport { basename, dirname, isAbsolute, resolve } from \"node:path\";\nimport { ProviderScope, runWithProviderScope } from \"@earendil-works/pi-ai/node/provider-scope\";\nimport {\n\ttype AgentSessionLaunchProfile,\n\ttype AgentSessionRuntime,\n\ttype CreateAgentSessionRuntimeFactory,\n\tcreateAgentSessionRuntime,\n} from \"../../core/agent-session-runtime.ts\";\nimport { SessionManager } from \"../../core/session-manager.ts\";\n\n/** The immutable flags selected when a routing session is opened. */\nexport interface RpcSessionLaunchProfile extends AgentSessionLaunchProfile {\n\tsessionPath?: string;\n}\n\nexport type SessionRuntime = Pick<AgentSessionRuntime, \"session\" | \"dispose\">;\nexport type RpcSessionState = \"opening\" | \"open\" | \"closing\" | \"closed\";\n\nexport interface RpcSessionEntry {\n\tstate: RpcSessionState;\n\truntime?: SessionRuntime;\n\tscope: ProviderScope;\n\tprofile: Readonly<RpcSessionLaunchProfile>;\n\tdurableSessionId?: string;\n\tsessionPath?: string;\n\tlifecycleMutex: Promise<void>;\n}\n\nexport class RpcSessionRegistryError extends Error {\n\treadonly code: \"unknown_session\" | \"session_closing\" | \"session_path_in_use\" | \"invalid_path\" | \"open_failed\";\n\n\tconstructor(code: RpcSessionRegistryError[\"code\"]) {\n\t\tsuper(code);\n\t\tthis.code = code;\n\t\tthis.name = \"RpcSessionRegistryError\";\n\t}\n}\n\nexport interface RpcSessionRegistryOptions {\n\tagentDir: string;\n\tcreateRuntime: CreateAgentSessionRuntimeFactory;\n}\n\nexport interface OpenRpcSession {\n\tsessionId: string;\n\tdurableSessionId: string;\n\tsessionPath?: string;\n}\n\nfunction canonicalPath(path: string): string {\n\tconst absolutePath = resolve(path);\n\tif (existsSync(absolutePath)) return realpathSync(absolutePath);\n\treturn `${realpathSync(dirname(absolutePath))}/${basename(absolutePath)}`;\n}\n\nfunction frozenProfile(profile: RpcSessionLaunchProfile): Readonly<RpcSessionLaunchProfile> {\n\treturn Object.freeze({\n\t\t...profile,\n\t\t...(profile.creationModel ? { creationModel: Object.freeze({ ...profile.creationModel }) } : {}),\n\t});\n}\n\n/** Process-local lifecycle owner for multi-session RPC runtimes. */\nexport class RpcSessionRegistry {\n\tprivate readonly entries = new Map<string, RpcSessionEntry>();\n\tprivate readonly reservations = new Set<string>();\n\tprivate nextHandle = 0;\n\tprivate readonly options: RpcSessionRegistryOptions;\n\n\tconstructor(options: RpcSessionRegistryOptions) {\n\t\tthis.options = options;\n\t}\n\n\tasync openSession(profile: RpcSessionLaunchProfile): Promise<OpenRpcSession> {\n\t\tthis.validateProfile(profile);\n\t\tconst sessionPath = profile.sessionPath ? canonicalPath(profile.sessionPath) : undefined;\n\t\tif (sessionPath && this.reservations.has(sessionPath)) throw new RpcSessionRegistryError(\"session_path_in_use\");\n\t\tif (sessionPath) this.reservations.add(sessionPath);\n\n\t\t// Resume vs create parity (D1 + omo SenpiSessionRuntime.ts:198-200):\n\t\t// Create-only launch semantics mirror classic startup flags. A resumed\n\t\t// session restores its persisted model and thinking level instead of being\n\t\t// overridden by the new open_session request.\n\t\tconst isResume = sessionPath !== undefined && existsSync(sessionPath);\n\t\tconst storedProfile = frozenProfile({ ...profile, ...(sessionPath ? { sessionPath } : {}) });\n\t\tconst runtimeProfile = isResume\n\t\t\t? frozenProfile({ ...storedProfile, creationModel: undefined, initialThinkingLevel: undefined })\n\t\t\t: storedProfile;\n\n\t\tconst handle = `rpc-${++this.nextHandle}`;\n\t\tconst entry: RpcSessionEntry = {\n\t\t\tstate: \"opening\",\n\t\t\tscope: new ProviderScope(),\n\t\t\tprofile: storedProfile,\n\t\t\tsessionPath,\n\t\t\tlifecycleMutex: Promise.resolve(),\n\t\t};\n\t\tthis.entries.set(handle, entry);\n\t\ttry {\n\t\t\tconst manager = sessionPath\n\t\t\t\t? SessionManager.open(sessionPath, undefined, storedProfile.cwd)\n\t\t\t\t: SessionManager.create(storedProfile.cwd);\n\t\t\tentry.runtime = await runWithProviderScope(entry.scope, () =>\n\t\t\t\tcreateAgentSessionRuntime(this.options.createRuntime, {\n\t\t\t\t\tcwd: manager.getCwd(),\n\t\t\t\t\tagentDir: this.options.agentDir,\n\t\t\t\t\tsessionManager: manager,\n\t\t\t\t\tlaunchProfile: runtimeProfile,\n\t\t\t\t}),\n\t\t\t);\n\t\t\tentry.durableSessionId = manager.getSessionId();\n\t\t\tentry.sessionPath ??= manager.getSessionFile();\n\t\t\tentry.state = \"open\";\n\t\t\treturn { sessionId: handle, durableSessionId: entry.durableSessionId, sessionPath: entry.sessionPath };\n\t\t} catch (error) {\n\t\t\t// Runtime construction may have started extensions, watchers, and provider\n\t\t\t// registrations before it rejects. Keep the reservation and entry private\n\t\t\t// until all of those resources have been torn down, then release them as\n\t\t\t// one rollback so the path can immediately be opened again.\n\t\t\ttry {\n\t\t\t\tawait entry.runtime?.dispose();\n\t\t\t} catch {\n\t\t\t\t// The original construction error remains the externally visible cause.\n\t\t\t} finally {\n\t\t\t\ttry {\n\t\t\t\t\tawait entry.scope.close?.();\n\t\t\t\t} finally {\n\t\t\t\t\tthis.entries.delete(handle);\n\t\t\t\t\tif (sessionPath) this.reservations.delete(sessionPath);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (error instanceof RpcSessionRegistryError) throw error;\n\t\t\tthrow new RpcSessionRegistryError(\"open_failed\");\n\t\t}\n\t}\n\n\tgetForCommand(handle: string, command: string): RpcSessionEntry {\n\t\tconst entry = this.entries.get(handle);\n\t\tif (!entry) throw new RpcSessionRegistryError(\"unknown_session\");\n\t\tif (entry.state === \"closing\" && ![\"abort\", \"abort_bash\", \"extension_ui_response\"].includes(command)) {\n\t\t\tthrow new RpcSessionRegistryError(\"session_closing\");\n\t\t}\n\t\tif (entry.state !== \"open\" && entry.state !== \"closing\") throw new RpcSessionRegistryError(\"unknown_session\");\n\t\treturn entry;\n\t}\n\n\t/**\n\t * Starts a close synchronously. Call this before disposing any session-owned\n\t * binding so a concurrent command cannot reach a half-disposed handler.\n\t */\n\tbeginClose(handle: string): RpcSessionEntry {\n\t\tconst entry = this.entries.get(handle);\n\t\tif (entry?.state !== \"open\") throw new RpcSessionRegistryError(\"unknown_session\");\n\t\tentry.state = \"closing\";\n\t\treturn entry;\n\t}\n\n\tasync close(handle: string): Promise<void> {\n\t\tthis.beginClose(handle);\n\t\treturn this.closeMarked(handle);\n\t}\n\n\t/** Completes a close previously made visible by beginClose(). */\n\tasync closeMarked(handle: string): Promise<void> {\n\t\tconst entry = this.entries.get(handle);\n\t\tif (entry?.state !== \"closing\") throw new RpcSessionRegistryError(\"unknown_session\");\n\t\tentry.lifecycleMutex = (async () => {\n\t\t\ttry {\n\t\t\t\tawait entry.runtime?.session.abort();\n\t\t\t\tawait entry.runtime?.session.waitForIdle();\n\t\t\t\tawait entry.runtime?.dispose();\n\t\t\t\tawait entry.scope.close?.();\n\t\t\t} finally {\n\t\t\t\tentry.state = \"closed\";\n\t\t\t\tthis.entries.delete(handle);\n\t\t\t\tif (entry.sessionPath) this.reservations.delete(entry.sessionPath);\n\t\t\t}\n\t\t})();\n\t\treturn entry.lifecycleMutex;\n\t}\n\n\tlist(): Array<{\n\t\tsessionId: string;\n\t\tdurableSessionId?: string;\n\t\tsessionPath?: string;\n\t\tcwd: string;\n\t\tname?: string;\n\t\tstatus: RpcSessionState;\n\t}> {\n\t\treturn [...this.entries].map(([sessionId, entry]) => ({\n\t\t\tsessionId,\n\t\t\tdurableSessionId: entry.durableSessionId,\n\t\t\tsessionPath: entry.sessionPath,\n\t\t\tcwd: entry.profile.cwd,\n\t\t\tname: entry.runtime?.session.sessionManager.getSessionName(),\n\t\t\tstatus: entry.state,\n\t\t}));\n\t}\n\n\tprivate validateProfile(profile: RpcSessionLaunchProfile): void {\n\t\tif (!isAbsolute(profile.cwd) || (profile.sessionPath !== undefined && !isAbsolute(profile.sessionPath))) {\n\t\t\tthrow new RpcSessionRegistryError(\"invalid_path\");\n\t\t}\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"clipboard.d.ts","sourceRoot":"","sources":["../../src/utils/clipboard.ts"],"names":[],"mappings":"AAkCA,0FAA0F;AAC1F,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAWhE;AAED,wBAAsB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA4FjE"}
1
+ {"version":3,"file":"clipboard.d.ts","sourceRoot":"","sources":["../../src/utils/clipboard.ts"],"names":[],"mappings":"AAkCA,0FAA0F;AAC1F,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAWhE;AAED,wBAAsB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAsGjE"}
@@ -91,15 +91,26 @@ export async function copyToClipboard(text) {
91
91
  try {
92
92
  // Verify wl-copy exists (spawn errors are async and won't be caught)
93
93
  execSync("which wl-copy", { stdio: "ignore" });
94
- // wl-copy with execSync hangs due to fork behavior; use spawn instead
95
- const proc = spawn("wl-copy", [], { stdio: ["pipe", "ignore", "ignore"] });
96
- proc.stdin.on("error", () => {
97
- // Ignore EPIPE errors if wl-copy exits early
94
+ // wl-copy with execSync hangs due to fork behavior; use spawn instead.
95
+ // Await the exit code and only claim success on a clean exit, so a
96
+ // failed wl-copy falls through to the xclip/OSC 52 fallbacks.
97
+ const wlCopyExit = await new Promise((resolve) => {
98
+ const proc = spawn("wl-copy", [], { stdio: ["pipe", "ignore", "ignore"] });
99
+ proc.on("error", () => resolve(1));
100
+ proc.on("close", (code) => resolve(code ?? 1));
101
+ proc.stdin.on("error", () => {
102
+ // Ignore EPIPE errors if wl-copy exits early
103
+ });
104
+ proc.stdin.write(text);
105
+ proc.stdin.end();
98
106
  });
99
- proc.stdin.write(text);
100
- proc.stdin.end();
101
- proc.unref();
102
- copied = true;
107
+ if (wlCopyExit === 0) {
108
+ copied = true;
109
+ }
110
+ else if (hasX11Display) {
111
+ copyToX11Clipboard(options);
112
+ copied = true;
113
+ }
103
114
  }
104
115
  catch {
105
116
  if (hasX11Display) {
@@ -1 +1 @@
1
- {"version":3,"file":"clipboard.js","sourceRoot":"","sources":["../../src/utils/clipboard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AAC9B,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAQlD,SAAS,kBAAkB,CAAC,OAAmC;IAC9D,IAAI,CAAC;QACJ,QAAQ,CAAC,4BAA4B,EAAE,OAAO,CAAC,CAAC;IACjD,CAAC;IAAC,MAAM,CAAC;QACR,QAAQ,CAAC,0BAA0B,EAAE,OAAO,CAAC,CAAC;IAC/C,CAAC;AACF,CAAC;AAED,MAAM,wBAAwB,GAAG,OAAO,CAAC;AAEzC,SAAS,eAAe,CAAC,GAAG,GAAsB,OAAO,CAAC,GAAG;IAC5D,OAAO,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,GAAG,CAAC,UAAU,IAAI,GAAG,CAAC,eAAe,CAAC,CAAC;AAC7E,CAAC;AAED,SAAS,SAAS,CAAC,IAAY;IAC9B,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACrD,IAAI,OAAO,CAAC,MAAM,GAAG,wBAAwB,EAAE,CAAC;QAC/C,OAAO,KAAK,CAAC;IACd,CAAC;IACD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,aAAa,OAAO,MAAM,CA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AAG,EAAE,CAAC;4BACjB,IAAI,CAAC,KAAK,EAAE,CAAC;4BACb,MAAM,GAAG,IAAI,CAAC;wBACf,CAAC;wBAAC,MAAM,CAAC;4BACR,IAAI,aAAa,EAAE,CAAC;gCACnB,kBAAkB,CAAC,OAAO,CAAC,CAAC;gCAC5B,MAAM,GAAG,IAAI,CAAC;4BACf,CAAC;wBACF,CAAC;oBACF,CAAC;yBAAM,IAAI,aAAa,EAAE,CAAC;wBAC1B,kBAAkB,CAAC,OAAO,CAAC,CAAC;wBAC5B,MAAM,GAAG,IAAI,CAAC;oBACf,CAAC;gBACF,CAAC;YACF,CAAC;QACF,CAAC;QAAC,MAAM,CAAC;YACR,mCAAmC;QACpC,CAAC;IACF,CAAC;IAED,IAAI,MAAM,IAAI,CAAC,MAAM,EAAE,CAAC;QACvB,MAAM,WAAW,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;QACpC,MAAM,GAAG,MAAM,IAAI,WAAW,CAAC;IAChC,CAAC;IAED,IAAI,CAAC,MAAM,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;IAChD,CAAC;AACF,CAAC","sourcesContent":["import { execSync, spawn } from \"child_process\";\nimport { platform } from \"os\";\nimport { isWaylandSession } from \"./clipboard-image.ts\";\nimport { clipboard } from \"./clipboard-native.ts\";\n\ntype NativeClipboardExecOptions = {\n\tinput: string;\n\ttimeout: number;\n\tstdio: [\"pipe\", \"ignore\", \"ignore\"];\n};\n\nfunction copyToX11Clipboard(options: NativeClipboardExecOptions): void {\n\ttry {\n\t\texecSync(\"xclip -selection clipboard\", options);\n\t} catch {\n\t\texecSync(\"xsel --clipboard --input\", options);\n\t}\n}\n\nconst MAX_OSC52_ENCODED_LENGTH = 100_000;\n\nfunction isRemoteSession(env: NodeJS.ProcessEnv = process.env): boolean {\n\treturn Boolean(env.SSH_CONNECTION || env.SSH_CLIENT || env.MOSH_CONNECTION);\n}\n\nfunction emitOsc52(text: string): boolean {\n\tconst encoded = Buffer.from(text).toString(\"base64\");\n\tif (encoded.length > MAX_OSC52_ENCODED_LENGTH) {\n\t\treturn false;\n\t}\n\tprocess.stdout.write(`\\x1b]52;c;${encoded}\\x07`);\n\treturn true;\n}\n\n/** Read plain text from the system clipboard, if native clipboard access is available. */\nexport async function readClipboardText(): Promise<string | null> {\n\tif (!clipboard) {\n\t\treturn null;\n\t}\n\n\ttry {\n\t\tconst text = await clipboard.getText();\n\t\treturn text || null;\n\t} catch {\n\t\treturn null;\n\t}\n}\n\nexport async function copyToClipboard(text: string): Promise<void> {\n\tlet copied = false;\n\n\tconst p = platform();\n\n\t// Prefer direct clipboard writes. Emitting OSC 52 first can make terminals\n\t// write the same native clipboard concurrently with the addon, and very large\n\t// OSC 52 payloads can desynchronize terminal rendering.\n\t//\n\t// On Linux, skip the native addon. The underlying `clipboard-rs` crate is\n\t// X11-only and does not retain selection ownership after `set_text`\n\t// resolves, so on Wayland-only compositors (Hyprland, Niri, ...) and even\n\t// some X11 sessions the call resolves successfully without populating the\n\t// clipboard. The platform tools below (wl-copy, xclip, xsel) properly\n\t// daemonize and keep ownership.\n\ttry {\n\t\tif (clipboard && p !== \"linux\") {\n\t\t\tawait clipboard.setText(text);\n\t\t\tcopied = true;\n\t\t}\n\t} catch {\n\t\t// Fall through to platform-specific clipboard tools.\n\t}\n\n\tconst remote = isRemoteSession();\n\tif (copied && !remote) {\n\t\treturn;\n\t}\n\n\tconst options: NativeClipboardExecOptions = { input: text, timeout: 5000, stdio: [\"pipe\", \"ignore\", \"ignore\"] };\n\n\tif (!copied) {\n\t\ttry {\n\t\t\tif (p === \"darwin\") {\n\t\t\t\texecSync(\"pbcopy\", options);\n\t\t\t\tcopied = true;\n\t\t\t} else if (p === \"win32\") {\n\t\t\t\texecSync(\"clip\", options);\n\t\t\t\tcopied = true;\n\t\t\t} else {\n\t\t\t\t// Linux. Try Termux, Wayland, or X11 clipboard tools.\n\t\t\t\tif (process.env.TERMUX_VERSION) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\texecSync(\"termux-clipboard-set\", options);\n\t\t\t\t\t\tcopied = true;\n\t\t\t\t\t} catch {\n\t\t\t\t\t\t// Fall back to Wayland or X11 tools.\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (!copied) {\n\t\t\t\t\tconst hasWaylandDisplay = Boolean(process.env.WAYLAND_DISPLAY);\n\t\t\t\t\tconst hasX11Display = Boolean(process.env.DISPLAY);\n\t\t\t\t\tconst isWayland = isWaylandSession();\n\t\t\t\t\tif (isWayland && hasWaylandDisplay) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t// Verify wl-copy exists (spawn errors are async and won't be caught)\n\t\t\t\t\t\t\texecSync(\"which wl-copy\", { stdio: \"ignore\" });\n\t\t\t\t\t\t\t// wl-copy with execSync hangs due to fork behavior; use spawn instead\n\t\t\t\t\t\t\tconst proc = spawn(\"wl-copy\", [], { stdio: [\"pipe\", \"ignore\", \"ignore\"] });\n\t\t\t\t\t\t\tproc.stdin.on(\"error\", () => {\n\t\t\t\t\t\t\t\t// Ignore EPIPE errors if wl-copy exits early\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tproc.stdin.write(text);\n\t\t\t\t\t\t\tproc.stdin.end();\n\t\t\t\t\t\t\tproc.unref();\n\t\t\t\t\t\t\tcopied = true;\n\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\tif (hasX11Display) {\n\t\t\t\t\t\t\t\tcopyToX11Clipboard(options);\n\t\t\t\t\t\t\t\tcopied = true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (hasX11Display) {\n\t\t\t\t\t\tcopyToX11Clipboard(options);\n\t\t\t\t\t\tcopied = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} catch {\n\t\t\t// Fall through to OSC 52 fallback.\n\t\t}\n\t}\n\n\tif (remote || !copied) {\n\t\tconst osc52Copied = emitOsc52(text);\n\t\tcopied = copied || osc52Copied;\n\t}\n\n\tif (!copied) {\n\t\tthrow new Error(\"Failed to copy to clipboard\");\n\t}\n}\n"]}
1
+ {"version":3,"file":"clipboard.js","sourceRoot":"","sources":["../../src/utils/clipboard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AAC9B,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAQlD,SAAS,kBAAkB,CAAC,OAAmC;IAC9D,IAAI,CAAC;QACJ,QAAQ,CAAC,4BAA4B,EAAE,OAAO,CAAC,CAAC;IACjD,CAAC;IAAC,MAAM,CAAC;QACR,QAAQ,CAAC,0BAA0B,EAAE,OAAO,CAAC,CAAC;IAC/C,CAAC;AACF,CAAC;AAED,MAAM,wBAAwB,GAAG,OAAO,CAAC;AAEzC,SAAS,eAAe,CAAC,GAAG,GAAsB,OAAO,CAAC,GAAG;IAC5D,OAAO,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,GAAG,CAAC,UAAU,IAAI,GAAG,CAAC,eAAe,CAAC,CAAC;AAC7E,CAAC;AAED,SAAS,SAAS,CAAC,IAAY;IAC9B,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACrD,IAAI,OAAO,CAAC,MAAM,GAAG,wBAAwB,EAAE,CAAC;QAC/C,OAAO,KAAK,CAAC;IACd,CAAC;IACD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,aAAa,OAAO,MAAM,CAAC,CAAC;IACjD,OAAO,IAAI,CAAC;AACb,CAAC;AAED,0FAA0F;AAC1F,MAAM,CAAC,KAAK,UAAU,iBAAiB;IACtC,IAAI,CAAC,SAAS,EAAE,CAAC;QAChB,OAAO,IAAI,CAAC;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E,CAAC,OAAO,EAAE,GAAG,EAAE;oCAC3B,6CAA6C;gCAC9C,CAAC,CAAC,CAAC;gCACH,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;gCACvB,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;4BAClB,CAAC,CAAC,CAAC;4BACH,IAAI,UAAU,KAAK,CAAC,EAAE,CAAC;gCACtB,MAAM,GAAG,IAAI,CAAC;4BACf,CAAC;iCAAM,IAAI,aAAa,EAAE,CAAC;gCAC1B,kBAAkB,CAAC,OAAO,CAAC,CAAC;gCAC5B,MAAM,GAAG,IAAI,CAAC;4BACf,CAAC;wBACF,CAAC;wBAAC,MAAM,CAAC;4BACR,IAAI,aAAa,EAAE,CAAC;gCACnB,kBAAkB,CAAC,OAAO,CAAC,CAAC;gCAC5B,MAAM,GAAG,IAAI,CAAC;4BACf,CAAC;wBACF,CAAC;oBACF,CAAC;yBAAM,IAAI,aAAa,EAAE,CAAC;wBAC1B,kBAAkB,CAAC,OAAO,CAAC,CAAC;wBAC5B,MAAM,GAAG,IAAI,CAAC;oBACf,CAAC;gBACF,CAAC;YACF,CAAC;QACF,CAAC;QAAC,MAAM,CAAC;YACR,mCAAmC;QACpC,CAAC;IACF,CAAC;IAED,IAAI,MAAM,IAAI,CAAC,MAAM,EAAE,CAAC;QACvB,MAAM,WAAW,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;QACpC,MAAM,GAAG,MAAM,IAAI,WAAW,CAAC;IAChC,CAAC;IAED,IAAI,CAAC,MAAM,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;IAChD,CAAC;AACF,CAAC","sourcesContent":["import { execSync, spawn } from \"child_process\";\nimport { platform } from \"os\";\nimport { isWaylandSession } from \"./clipboard-image.ts\";\nimport { clipboard } from \"./clipboard-native.ts\";\n\ntype NativeClipboardExecOptions = {\n\tinput: string;\n\ttimeout: number;\n\tstdio: [\"pipe\", \"ignore\", \"ignore\"];\n};\n\nfunction copyToX11Clipboard(options: NativeClipboardExecOptions): void {\n\ttry {\n\t\texecSync(\"xclip -selection clipboard\", options);\n\t} catch {\n\t\texecSync(\"xsel --clipboard --input\", options);\n\t}\n}\n\nconst MAX_OSC52_ENCODED_LENGTH = 100_000;\n\nfunction isRemoteSession(env: NodeJS.ProcessEnv = process.env): boolean {\n\treturn Boolean(env.SSH_CONNECTION || env.SSH_CLIENT || env.MOSH_CONNECTION);\n}\n\nfunction emitOsc52(text: string): boolean {\n\tconst encoded = Buffer.from(text).toString(\"base64\");\n\tif (encoded.length > MAX_OSC52_ENCODED_LENGTH) {\n\t\treturn false;\n\t}\n\tprocess.stdout.write(`\\x1b]52;c;${encoded}\\x07`);\n\treturn true;\n}\n\n/** Read plain text from the system clipboard, if native clipboard access is available. */\nexport async function readClipboardText(): Promise<string | null> {\n\tif (!clipboard) {\n\t\treturn null;\n\t}\n\n\ttry {\n\t\tconst text = await clipboard.getText();\n\t\treturn text || null;\n\t} catch {\n\t\treturn null;\n\t}\n}\n\nexport async function copyToClipboard(text: string): Promise<void> {\n\tlet copied = false;\n\n\tconst p = platform();\n\n\t// Prefer direct clipboard writes. Emitting OSC 52 first can make terminals\n\t// write the same native clipboard concurrently with the addon, and very large\n\t// OSC 52 payloads can desynchronize terminal rendering.\n\t//\n\t// On Linux, skip the native addon. The underlying `clipboard-rs` crate is\n\t// X11-only and does not retain selection ownership after `set_text`\n\t// resolves, so on Wayland-only compositors (Hyprland, Niri, ...) and even\n\t// some X11 sessions the call resolves successfully without populating the\n\t// clipboard. The platform tools below (wl-copy, xclip, xsel) properly\n\t// daemonize and keep ownership.\n\ttry {\n\t\tif (clipboard && p !== \"linux\") {\n\t\t\tawait clipboard.setText(text);\n\t\t\tcopied = true;\n\t\t}\n\t} catch {\n\t\t// Fall through to platform-specific clipboard tools.\n\t}\n\n\tconst remote = isRemoteSession();\n\tif (copied && !remote) {\n\t\treturn;\n\t}\n\n\tconst options: NativeClipboardExecOptions = { input: text, timeout: 5000, stdio: [\"pipe\", \"ignore\", \"ignore\"] };\n\n\tif (!copied) {\n\t\ttry {\n\t\t\tif (p === \"darwin\") {\n\t\t\t\texecSync(\"pbcopy\", options);\n\t\t\t\tcopied = true;\n\t\t\t} else if (p === \"win32\") {\n\t\t\t\texecSync(\"clip\", options);\n\t\t\t\tcopied = true;\n\t\t\t} else {\n\t\t\t\t// Linux. Try Termux, Wayland, or X11 clipboard tools.\n\t\t\t\tif (process.env.TERMUX_VERSION) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\texecSync(\"termux-clipboard-set\", options);\n\t\t\t\t\t\tcopied = true;\n\t\t\t\t\t} catch {\n\t\t\t\t\t\t// Fall back to Wayland or X11 tools.\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (!copied) {\n\t\t\t\t\tconst hasWaylandDisplay = Boolean(process.env.WAYLAND_DISPLAY);\n\t\t\t\t\tconst hasX11Display = Boolean(process.env.DISPLAY);\n\t\t\t\t\tconst isWayland = isWaylandSession();\n\t\t\t\t\tif (isWayland && hasWaylandDisplay) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t// Verify wl-copy exists (spawn errors are async and won't be caught)\n\t\t\t\t\t\t\texecSync(\"which wl-copy\", { stdio: \"ignore\" });\n\t\t\t\t\t\t\t// wl-copy with execSync hangs due to fork behavior; use spawn instead.\n\t\t\t\t\t\t\t// Await the exit code and only claim success on a clean exit, so a\n\t\t\t\t\t\t\t// failed wl-copy falls through to the xclip/OSC 52 fallbacks.\n\t\t\t\t\t\t\tconst wlCopyExit = await new Promise<number>((resolve) => {\n\t\t\t\t\t\t\t\tconst proc = spawn(\"wl-copy\", [], { stdio: [\"pipe\", \"ignore\", \"ignore\"] });\n\t\t\t\t\t\t\t\tproc.on(\"error\", () => resolve(1));\n\t\t\t\t\t\t\t\tproc.on(\"close\", (code) => resolve(code ?? 1));\n\t\t\t\t\t\t\t\tproc.stdin.on(\"error\", () => {\n\t\t\t\t\t\t\t\t\t// Ignore EPIPE errors if wl-copy exits early\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\tproc.stdin.write(text);\n\t\t\t\t\t\t\t\tproc.stdin.end();\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tif (wlCopyExit === 0) {\n\t\t\t\t\t\t\t\tcopied = true;\n\t\t\t\t\t\t\t} else if (hasX11Display) {\n\t\t\t\t\t\t\t\tcopyToX11Clipboard(options);\n\t\t\t\t\t\t\t\tcopied = true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\tif (hasX11Display) {\n\t\t\t\t\t\t\t\tcopyToX11Clipboard(options);\n\t\t\t\t\t\t\t\tcopied = true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (hasX11Display) {\n\t\t\t\t\t\tcopyToX11Clipboard(options);\n\t\t\t\t\t\tcopied = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} catch {\n\t\t\t// Fall through to OSC 52 fallback.\n\t\t}\n\t}\n\n\tif (remote || !copied) {\n\t\tconst osc52Copied = emitOsc52(text);\n\t\tcopied = copied || osc52Copied;\n\t}\n\n\tif (!copied) {\n\t\tthrow new Error(\"Failed to copy to clipboard\");\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"version-check.d.ts","sourceRoot":"","sources":["../../src/utils/version-check.ts"],"names":[],"mappings":"AASA,MAAM,WAAW,eAAe;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;CACd;AAED,wBAAgB,sBAAsB,CAAC,WAAW,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAOpG;AAED,wBAAgB,qBAAqB,CAAC,gBAAgB,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,OAAO,CAM/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SAAS,CAAC,CAE7B;AAED,wBAAsB,oBAAoB,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,GAAG,SAAS,CAAC,CAYvG"}
@@ -26,7 +26,7 @@ export function getReleaseChangelogUrl(version) {
26
26
  return `${RELEASE_CHANGELOG_BASE_URL}/${tag}/${RELEASE_CHANGELOG_PATH}`;
27
27
  }
28
28
  export async function getLatestPiRelease(currentVersion, options = {}) {
29
- if (process.env.PI_SKIP_VERSION_CHECK || process.env.PI_OFFLINE)
29
+ if (process.env.PI_OFFLINE)
30
30
  return undefined;
31
31
  const response = await fetch(LATEST_VERSION_URL, {
32
32
  headers: {
@@ -49,6 +49,8 @@ export async function getLatestPiVersion(currentVersion, options = {}) {
49
49
  return (await getLatestPiRelease(currentVersion, options))?.version;
50
50
  }
51
51
  export async function checkForNewPiVersion(currentVersion) {
52
+ if (process.env.PI_SKIP_VERSION_CHECK)
53
+ return undefined;
52
54
  try {
53
55
  const latestRelease = await getLatestPiRelease(currentVersion);
54
56
  if (latestRelease && isNewerPackageVersion(latestRelease.version, currentVersion)) {
@@ -1 +1 @@
1
- {"version":3,"file":"version-check.js","sourceRoot":"","sources":["../../src/utils/version-check.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD,MAAM,kBAAkB,GAAG,8BAA8B,kBAAkB,CAAC,YAAY,CAAC,SAAS,CAAC;AACnG,MAAM,gCAAgC,GAAG,KAAK,CAAC;AAC/C,MAAM,0BAA0B,GAAG,4CAA4C,CAAC;AAChF,MAAM,sBAAsB,GAAG,oCAAoC,CAAC;AAQpE,MAAM,UAAU,sBAAsB,CAAC,WAAmB,EAAE,YAAoB;IAC/E,MAAM,IAAI,GAAG,KAAK,CAAC,WAAW,CAAC,IAAI,EA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;QACtB,CAAC;QACD,OAAO,SAAS,CAAC;IAClB,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,SAAS,CAAC;IAClB,CAAC;AACF,CAAC","sourcesContent":["import { compare, valid } from \"semver\";\nimport { PACKAGE_NAME } from \"../config.ts\";\nimport { getPiUserAgent } from \"./pi-user-agent.ts\";\n\nconst LATEST_VERSION_URL = `https://registry.npmjs.org/${encodeURIComponent(PACKAGE_NAME)}/latest`;\nconst DEFAULT_VERSION_CHECK_TIMEOUT_MS = 10000;\nconst RELEASE_CHANGELOG_BASE_URL = \"https://github.com/code-yeongyu/senpi/blob\";\nconst RELEASE_CHANGELOG_PATH = \"packages/coding-agent/CHANGELOG.md\";\n\nexport interface LatestPiRelease {\n\tversion: string;\n\tpackageName?: string;\n\tnote?: string;\n}\n\nexport function comparePackageVersions(leftVersion: string, rightVersion: string): number | undefined {\n\tconst left = valid(leftVersion.trim());\n\tconst right = valid(rightVersion.trim());\n\tif (!left || !right) {\n\t\treturn undefined;\n\t}\n\treturn compare(left, right);\n}\n\nexport function isNewerPackageVersion(candidateVersion: string, currentVersion: string): boolean {\n\tconst comparison = comparePackageVersions(candidateVersion, currentVersion);\n\tif (comparison !== undefined) {\n\t\treturn comparison > 0;\n\t}\n\treturn candidateVersion.trim() !== currentVersion.trim();\n}\n\nexport function getReleaseChangelogUrl(version: string): string {\n\tconst trimmedVersion = version.trim();\n\tconst tag = trimmedVersion.startsWith(\"v\") ? trimmedVersion : `v${trimmedVersion}`;\n\treturn `${RELEASE_CHANGELOG_BASE_URL}/${tag}/${RELEASE_CHANGELOG_PATH}`;\n}\n\nexport async function getLatestPiRelease(\n\tcurrentVersion: string,\n\toptions: { timeoutMs?: number } = {},\n): Promise<LatestPiRelease | undefined> {\n\tif (process.env.PI_SKIP_VERSION_CHECK || process.env.PI_OFFLINE) return undefined;\n\n\tconst response = await fetch(LATEST_VERSION_URL, {\n\t\theaders: {\n\t\t\t\"User-Agent\": getPiUserAgent(currentVersion),\n\t\t\taccept: \"application/json\",\n\t\t},\n\t\tsignal: AbortSignal.timeout(options.timeoutMs ?? DEFAULT_VERSION_CHECK_TIMEOUT_MS),\n\t});\n\tif (!response.ok) return undefined;\n\n\tconst data = (await response.json()) as { packageName?: unknown; version?: unknown; note?: unknown };\n\tif (typeof data.version !== \"string\" || !data.version.trim()) {\n\t\treturn undefined;\n\t}\n\tconst packageName =\n\t\ttypeof data.packageName === \"string\" && data.packageName.trim() ? data.packageName.trim() : undefined;\n\tconst note = typeof data.note === \"string\" && data.note.trim() ? data.note.trim() : undefined;\n\treturn { version: data.version.trim(), packageName, note };\n}\n\nexport async function getLatestPiVersion(\n\tcurrentVersion: string,\n\toptions: { timeoutMs?: number } = {},\n): Promise<string | undefined> {\n\treturn (await getLatestPiRelease(currentVersion, options))?.version;\n}\n\nexport async function checkForNewPiVersion(currentVersion: string): Promise<LatestPiRelease | undefined> {\n\ttry {\n\t\tconst latestRelease = await getLatestPiRelease(currentVersion);\n\t\tif (latestRelease && isNewerPackageVersion(latestRelease.version, currentVersion)) {\n\t\t\treturn latestRelease;\n\t\t}\n\t\treturn undefined;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n"]}
1
+ {"version":3,"file":"version-check.js","sourceRoot":"","sources":["../../src/utils/version-check.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD,MAAM,kBAAkB,GAAG,8BAA8B,kBAAkB,CAAC,YAAY,CAAC,SAAS,CAAC;AACnG,MAAM,gCAAgC,GAAG,KAAK,CAAC;AAC/C,MAAM,0BAA0B,GAAG,4CAA4C,CAAC;AAChF,MAAM,sBAAsB,GAAG,oCAAoC,CAAC;AAQpE,MAAM,UAAU,sBAAsB,CAAC,WAAmB,EAAE,YAAoB;IAC/E,MAAM,IAAI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aAAa,CAAC,OAAO,EAAE,cAAc,CAAC,EAAE,CAAC;YACnF,OAAO,aAAa,CAAC;QACtB,CAAC;QACD,OAAO,SAAS,CAAC;IAClB,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,SAAS,CAAC;IAClB,CAAC;AACF,CAAC","sourcesContent":["import { compare, valid } from \"semver\";\nimport { PACKAGE_NAME } from \"../config.ts\";\nimport { getPiUserAgent } from \"./pi-user-agent.ts\";\n\nconst LATEST_VERSION_URL = `https://registry.npmjs.org/${encodeURIComponent(PACKAGE_NAME)}/latest`;\nconst DEFAULT_VERSION_CHECK_TIMEOUT_MS = 10000;\nconst RELEASE_CHANGELOG_BASE_URL = \"https://github.com/code-yeongyu/senpi/blob\";\nconst RELEASE_CHANGELOG_PATH = \"packages/coding-agent/CHANGELOG.md\";\n\nexport interface LatestPiRelease {\n\tversion: string;\n\tpackageName?: string;\n\tnote?: string;\n}\n\nexport function comparePackageVersions(leftVersion: string, rightVersion: string): number | undefined {\n\tconst left = valid(leftVersion.trim());\n\tconst right = valid(rightVersion.trim());\n\tif (!left || !right) {\n\t\treturn undefined;\n\t}\n\treturn compare(left, right);\n}\n\nexport function isNewerPackageVersion(candidateVersion: string, currentVersion: string): boolean {\n\tconst comparison = comparePackageVersions(candidateVersion, currentVersion);\n\tif (comparison !== undefined) {\n\t\treturn comparison > 0;\n\t}\n\treturn candidateVersion.trim() !== currentVersion.trim();\n}\n\nexport function getReleaseChangelogUrl(version: string): string {\n\tconst trimmedVersion = version.trim();\n\tconst tag = trimmedVersion.startsWith(\"v\") ? trimmedVersion : `v${trimmedVersion}`;\n\treturn `${RELEASE_CHANGELOG_BASE_URL}/${tag}/${RELEASE_CHANGELOG_PATH}`;\n}\n\nexport async function getLatestPiRelease(\n\tcurrentVersion: string,\n\toptions: { timeoutMs?: number } = {},\n): Promise<LatestPiRelease | undefined> {\n\tif (process.env.PI_OFFLINE) return undefined;\n\n\tconst response = await fetch(LATEST_VERSION_URL, {\n\t\theaders: {\n\t\t\t\"User-Agent\": getPiUserAgent(currentVersion),\n\t\t\taccept: \"application/json\",\n\t\t},\n\t\tsignal: AbortSignal.timeout(options.timeoutMs ?? DEFAULT_VERSION_CHECK_TIMEOUT_MS),\n\t});\n\tif (!response.ok) return undefined;\n\n\tconst data = (await response.json()) as { packageName?: unknown; version?: unknown; note?: unknown };\n\tif (typeof data.version !== \"string\" || !data.version.trim()) {\n\t\treturn undefined;\n\t}\n\tconst packageName =\n\t\ttypeof data.packageName === \"string\" && data.packageName.trim() ? data.packageName.trim() : undefined;\n\tconst note = typeof data.note === \"string\" && data.note.trim() ? data.note.trim() : undefined;\n\treturn { version: data.version.trim(), packageName, note };\n}\n\nexport async function getLatestPiVersion(\n\tcurrentVersion: string,\n\toptions: { timeoutMs?: number } = {},\n): Promise<string | undefined> {\n\treturn (await getLatestPiRelease(currentVersion, options))?.version;\n}\n\nexport async function checkForNewPiVersion(currentVersion: string): Promise<LatestPiRelease | undefined> {\n\tif (process.env.PI_SKIP_VERSION_CHECK) return undefined;\n\n\ttry {\n\t\tconst latestRelease = await getLatestPiRelease(currentVersion);\n\t\tif (latestRelease && isNewerPackageVersion(latestRelease.version, currentVersion)) {\n\t\t\treturn latestRelease;\n\t\t}\n\t\treturn undefined;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n"]}
@@ -110,8 +110,9 @@ app-server/
110
110
 
111
111
  1. Probe the requested listener with a real `initialize` request.
112
112
  2. If the listener answers, print `already-running`.
113
- 3. If a matching pidfile exists, wait briefly for that process to answer.
114
- 4. Otherwise spawn a detached `senpi app-server --listen <url>` process, write the pidfile and settings, then probe until ready.
113
+ 3. For `ws://` listeners that do not answer, test whether the requested TCP address can be bound. A listener already occupying the address fails immediately with an `EADDRINUSE` diagnostic instead of spawning a child process.
114
+ 4. If a matching pidfile exists, wait briefly for that process to answer.
115
+ 5. Otherwise spawn a detached `senpi app-server --listen <url>` process, write the pidfile and settings, then probe until ready.
115
116
 
116
117
  For websocket listeners, the daemon probe reads the bearer token file and sends `Authorization: Bearer <token>`.
117
118
 
@@ -20,7 +20,7 @@ Senpi has two summarization mechanisms:
20
20
  | Compaction | Context exceeds threshold, or `/compact` | Summarize old messages to free up context |
21
21
  | Branch summarization | `/tree` navigation | Preserve context when switching branches |
22
22
 
23
- Both use the same structured summary format and track file operations cumulatively.
23
+ Both use the same structured summary format and track file operations cumulatively. Compaction and branch-summary requests use fresh routing session IDs and, where supported by the provider, disable prompt-cache writes because these one-off prompts are unlikely to be reused.
24
24
 
25
25
  ## Compaction
26
26
 
@@ -129,6 +129,7 @@ interface CompactionEntry<T = unknown> {
129
129
  summary: string;
130
130
  firstKeptEntryId: string;
131
131
  tokensBefore: number;
132
+ usage?: Usage; // LLM usage that generated the summary
132
133
  fromHook?: boolean; // true if provided by extension (legacy field name)
133
134
  details?: T; // implementation-specific data
134
135
  }
@@ -140,9 +141,9 @@ interface CompactionDetails {
140
141
  }
141
142
  ```
142
143
 
143
- Extensions can store any JSON-serializable data in `details`. The default compaction tracks file operations, but custom extension implementations can use their own structure.
144
+ Extensions can store any JSON-serializable data in `details`. The default compaction tracks file operations, but custom extension implementations can use their own structure. Generated and extension-provided summaries store their LLM `usage` when available so session totals include summarization work.
144
145
 
145
- See [`prepareCompaction()`](https://github.com/earendil-works/pi-mono/blob/main/packages/coding-agent/src/core/compaction/compaction.ts) and [`compact()`](https://github.com/earendil-works/pi-mono/blob/main/packages/coding-agent/src/core/compaction/compaction.ts) for the implementation.
146
+ See [`prepareCompaction()`](https://github.com/earendil-works/pi-mono/blob/main/packages/coding-agent/src/core/compaction/compaction.ts) and [`compact()`](https://github.com/earendil-works/pi-mono/blob/main/packages/coding-agent/src/core/compaction/compaction.ts) for the implementation. For direct programmatic summarization, `generateSummary()` returns the summary text and `generateSummaryWithUsage()` returns `{ text, usage }`.
146
147
 
147
148
  ## Branch Summarization
148
149
 
@@ -195,6 +196,7 @@ interface BranchSummaryEntry<T = unknown> {
195
196
  timestamp: number;
196
197
  summary: string;
197
198
  fromId: string; // Entry we navigated from
199
+ usage?: Usage; // LLM usage that generated the summary
198
200
  fromHook?: boolean; // true if provided by extension (legacy field name)
199
201
  details?: T; // implementation-specific data
200
202
  }
@@ -300,6 +302,7 @@ pi.on("session_before_compact", async (event, ctx) => {
300
302
  summary: "Your summary...",
301
303
  firstKeptEntryId: preparation.firstKeptEntryId,
302
304
  tokensBefore: preparation.tokensBefore,
305
+ // usage: summaryResponse.usage, // Optional; included in session totals
303
306
  details: { /* custom data */ },
304
307
  }
305
308
  };
@@ -328,13 +331,14 @@ pi.on("session_before_compact", async (event, ctx) => {
328
331
  // [Tool result]: output text
329
332
 
330
333
  // Now send to your model for summarization
331
- const summary = await myModel.summarize(conversationText);
334
+ const { summary, usage } = await myModel.summarize(conversationText);
332
335
 
333
336
  return {
334
337
  compaction: {
335
338
  summary,
336
339
  firstKeptEntryId: preparation.firstKeptEntryId,
337
340
  tokensBefore: preparation.tokensBefore,
341
+ usage,
338
342
  }
339
343
  };
340
344
  });
@@ -364,6 +368,7 @@ pi.on("session_before_tree", async (event, ctx) => {
364
368
  return {
365
369
  summary: {
366
370
  summary: "Your summary...",
371
+ // usage: summaryResponse.usage, // Optional; included in session totals
367
372
  details: { /* custom data */ },
368
373
  }
369
374
  };
@@ -259,7 +259,7 @@ models: [{
259
259
  ```
260
260
 
261
261
  Use `openrouter` for OpenRouter-style `reasoning: { effort }` controls. Use `together` for Together-style `reasoning: { enabled }` controls; with `supportsReasoningEffort`, it also sends `reasoning_effort`. Use `qwen-chat-template` for local Qwen-compatible servers that read `chat_template_kwargs.enable_thinking` and need `preserve_thinking`.
262
- Use `cacheControlFormat: "anthropic"` for OpenAI-compatible providers that expose Anthropic-style prompt caching via `cache_control` on the system prompt, last tool definition, and last user/assistant text content.
262
+ Use `cacheControlFormat: "anthropic"` for OpenAI-compatible providers that expose Anthropic-style prompt caching via `cache_control` on the system prompt, last tool definition, and last user, assistant, or tool-result text content.
263
263
 
264
264
  For Anthropic-compatible providers using `api: "anthropic-messages"`, set `compat.forceAdaptiveThinking: true` on models or providers whose upstream model requires adaptive thinking (`thinking.type: "adaptive"` plus `output_config.effort`). Built-in adaptive Claude models set this automatically. Set `compat.allowEmptySignature: true` only for providers that emit empty thinking signatures and expect `signature: ""` on replay.
265
265
 
@@ -737,6 +737,8 @@ interface ProviderModelConfig {
737
737
  supportsDeveloperRole?: boolean;
738
738
  supportsReasoningEffort?: boolean;
739
739
  supportsUsageInStreaming?: boolean;
740
+ supportsStrictMode?: boolean;
741
+ supportsOpenAIGrammarTools?: boolean; // openai-completions/openai-responses; false falls back to normal function tools
740
742
  maxTokensField?: "max_completion_tokens" | "max_tokens";
741
743
  requiresToolResultName?: boolean;
742
744
  requiresAssistantAfterToolResult?: boolean;
@@ -755,9 +757,10 @@ interface ProviderModelConfig {
755
757
  supportsCacheControlOnTools?: boolean;
756
758
  forceAdaptiveThinking?: boolean;
757
759
  allowEmptySignature?: boolean;
760
+ supportsStrictTools?: boolean;
758
761
  };
759
762
  }
760
763
  ```
761
764
 
762
765
  `openrouter` sends `reasoning: { effort }`. `deepseek` sends `thinking: { type: "enabled" | "disabled" }` and `reasoning_effort` when enabled. `together` sends `reasoning: { enabled }` and also `reasoning_effort` when `supportsReasoningEffort` is enabled. `qwen` is for DashScope-style top-level `enable_thinking`. Use `qwen-chat-template` for local Qwen-compatible servers that read `chat_template_kwargs.enable_thinking` and need `preserve_thinking`. Use `chat-template` for configurable `chat_template_kwargs`, for example DeepSeek V3.x behind vLLM with `chatTemplateKwargs: { "thinking": { "$var": "thinking.enabled" } }`.
763
- `cacheControlFormat: "anthropic"` applies Anthropic-style `cache_control` markers to the system prompt, last tool definition, and last user/assistant text content.
766
+ `cacheControlFormat: "anthropic"` applies Anthropic-style `cache_control` markers to the system prompt, last tool definition, and last user, assistant, or tool-result text content.
@@ -0,0 +1,88 @@
1
+ # Environment Variables
2
+
3
+ Pi uses environment variables in three ways:
4
+
5
+ - Variables such as `PI_OFFLINE` configure the Pi process.
6
+ - Pi sets `PI_CODING_AGENT` so child processes can detect that they run inside Pi.
7
+ - Commands run by the LLM-callable bash tool receive `PI_*` variables describing the current session.
8
+
9
+ Provider API-key variables are documented separately in [Providers](providers.md#environment-variables-or-auth-file).
10
+
11
+ ## Process Marker
12
+
13
+ The CLI and RPC entry points set `PI_CODING_AGENT=true`. Child processes inherit it and can use it to detect that they run inside Pi. It is not session-specific and is not set automatically when Pi is embedded through the SDK.
14
+
15
+ ## Bash Tool Session Environment
16
+
17
+ Commands run by the bash tool receive the current Pi session state:
18
+
19
+ | Variable | Description |
20
+ |----------|-------------|
21
+ | `PI_SESSION_ID` | Current session ID |
22
+ | `PI_SESSION_FILE` | Absolute path to the current session JSONL file; unset for ephemeral sessions |
23
+ | `PI_PROVIDER` | Currently selected model provider |
24
+ | `PI_MODEL` | Currently selected model ID |
25
+ | `PI_REASONING_LEVEL` | Current effective reasoning level: `off`, `minimal`, `low`, `medium`, `high`, `xhigh`, or `max` |
26
+
27
+ The values are resolved when each command starts. Switching models or changing the reasoning level therefore affects the next bash command without restarting Pi. `PI_PROVIDER` and `PI_MODEL` identify the selected Pi model, not a different upstream model that a router may choose internally.
28
+
29
+ When asked which model or provider is running, inspect these variables instead of inferring the answer from the system prompt:
30
+
31
+ ```bash
32
+ printf '%s/%s\n' "$PI_PROVIDER" "$PI_MODEL"
33
+ printf 'reasoning=%s session=%s\n' "$PI_REASONING_LEVEL" "$PI_SESSION_ID"
34
+ ```
35
+
36
+ The session file can be inspected directly when the session is persistent:
37
+
38
+ ```bash
39
+ if [ -n "$PI_SESSION_FILE" ]; then
40
+ tail -n 1 "$PI_SESSION_FILE"
41
+ fi
42
+ ```
43
+
44
+ These variables are injected into the LLM-callable bash tool. They are not injected into user-entered `!` or `!!` commands.
45
+
46
+ ### Custom Bash Tools
47
+
48
+ Bash tools created with `createBashTool()` expose the session environment by default when registered with Pi. Injection happens before `spawnHook`, so a hook receives the variables in `ctx.env`:
49
+
50
+ ```typescript
51
+ const bashTool = createBashTool(cwd, {
52
+ spawnHook: (ctx) => ({
53
+ ...ctx,
54
+ env: { ...ctx.env, CI: "1" },
55
+ }),
56
+ });
57
+ ```
58
+
59
+ Disable session metadata independently of the spawn hook:
60
+
61
+ ```typescript
62
+ const bashTool = createBashTool(cwd, {
63
+ exposeSessionEnvironment: false,
64
+ spawnHook: (ctx) => ctx,
65
+ });
66
+ ```
67
+
68
+ When disabled, Pi removes inherited values for these variables so nested Pi processes do not expose stale parent-session metadata.
69
+
70
+ ## Pi Process Configuration
71
+
72
+ These variables are read by Pi itself:
73
+
74
+ | Variable | Description |
75
+ |----------|-------------|
76
+ | `PI_CODING_AGENT_DIR` | Override the config directory; default is `~/.pi/agent` |
77
+ | `PI_CODING_AGENT_SESSION_DIR` | Override session storage; overridden by `--session-dir` |
78
+ | `PI_PACKAGE_DIR` | Override the package directory, useful for Nix/Guix store paths |
79
+ | `PI_OFFLINE` | Disable startup network operations, including update checks, package updates, and install/update telemetry |
80
+ | `PI_SKIP_VERSION_CHECK` | Disable the `pi.dev` latest-version request |
81
+ | `PI_TELEMETRY` | Override install/update telemetry and provider attribution headers: `1`/`true`/`yes` or `0`/`false`/`no` |
82
+ | `PI_CACHE_RETENTION` | Set to `long` for extended provider prompt caching where supported |
83
+ | `PI_SHARE_VIEWER_URL` | Override the base URL used by `/share` |
84
+ | `PI_HARDWARE_CURSOR` | Set to `1` to show the hardware cursor; see [Terminal setup](terminal-setup.md) |
85
+ | `VISUAL`, `EDITOR` | External editor fallback when `externalEditor` is unset |
86
+ | `HTTP_PROXY`, `HTTPS_PROXY` | Proxy outbound HTTP requests |
87
+
88
+ Provider credentials such as `ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, and cloud-provider configuration are listed in [Providers](providers.md#environment-variables-or-auth-file).
@@ -497,6 +497,7 @@ pi.on("session_before_compact", async (event, ctx) => {
497
497
  summary: "...",
498
498
  firstKeptEntryId: preparation.firstKeptEntryId,
499
499
  tokensBefore: preparation.tokensBefore,
500
+ // usage: summaryResponse.usage, // Optional; included in session totals
500
501
  }
501
502
  };
502
503
  });
@@ -518,7 +519,13 @@ pi.on("session_before_tree", async (event, ctx) => {
518
519
  const { preparation, signal } = event;
519
520
  return { cancel: true };
520
521
  // OR provide custom summary:
521
- return { summary: { summary: "...", details: {} } };
522
+ return {
523
+ summary: {
524
+ summary: "...",
525
+ // usage: summaryResponse.usage, // Optional; included in session totals
526
+ details: {},
527
+ },
528
+ };
522
529
  });
523
530
 
524
531
  pi.on("session_tree", async (event, ctx) => {
@@ -842,7 +849,7 @@ In parallel tool mode, `tool_result` and `tool_execution_end` may interleave in
842
849
  `tool_result` handlers chain like middleware:
843
850
  - Handlers run in extension load order
844
851
  - Each handler sees the latest result after previous handler changes
845
- - Handlers can return partial patches (`content`, `details`, or `isError`); omitted fields keep their current values
852
+ - Handlers can return partial patches (`content`, `details`, `isError`, or `usage`); omitted fields keep their current values
846
853
 
847
854
  Use `ctx.signal` for nested async work inside the handler. This lets Esc cancel model calls, `fetch()`, and other abort-aware operations started by the extension.
848
855
 
@@ -851,7 +858,7 @@ import { isBashToolResult } from "@earendil-works/pi-coding-agent";
851
858
 
852
859
  pi.on("tool_result", async (event, ctx) => {
853
860
  // event.toolName, event.toolCallId, event.input
854
- // event.content, event.details, event.isError
861
+ // event.content, event.details, event.isError, event.usage
855
862
 
856
863
  if (isBashToolResult(event)) {
857
864
  // event.details is typed as BashToolDetails
@@ -864,7 +871,7 @@ pi.on("tool_result", async (event, ctx) => {
864
871
  });
865
872
 
866
873
  // Modify result:
867
- return { content: [...], details: {...}, isError: false };
874
+ return { content: [...], details: {...}, isError: false, usage: nestedModelUsage };
868
875
  });
869
876
  ```
870
877
 
@@ -1004,9 +1011,9 @@ ctx.sessionManager.buildContextEntries() // Active branch entries with compac
1004
1011
  ctx.sessionManager.getLeafId() // Current leaf entry ID
1005
1012
  ```
1006
1013
 
1007
- ### ctx.modelRegistry / ctx.model
1014
+ ### ctx.modelRegistry / ctx.model / ctx.thinkingLevel
1008
1015
 
1009
- Access to models, providers, and resolved authentication. `ctx.modelRegistry.getProvider(id)` returns the effective pi-ai provider, while `getProviderAuth(id)` resolves its current API key, headers, base URL, and provider-scoped environment without requiring a loaded model. `ctx.model` is the active model.
1016
+ Access to models, providers, and resolved authentication. `ctx.modelRegistry.getProvider(id)` returns the effective pi-ai provider, while `getProviderAuth(id)` resolves its current API key, headers, base URL, and provider-scoped environment without requiring a loaded model. `ctx.model` is the active model, and `ctx.thinkingLevel` is its current effective thinking level.
1010
1017
 
1011
1018
  ### ctx.signal
1012
1019
 
@@ -2056,6 +2063,7 @@ pi.registerTool({
2056
2063
  return {
2057
2064
  content: [{ type: "text", text: "Done" }], // Sent to LLM
2058
2065
  details: { data: result }, // For rendering & state
2066
+ // usage: nestedModelResponse.usage, // Optional nested LLM usage
2059
2067
  // Optional: stop after this tool batch when every finalized tool result
2060
2068
  // in the batch also returns terminate: true.
2061
2069
  terminate: true,
@@ -2068,6 +2076,8 @@ pi.registerTool({
2068
2076
  });
2069
2077
  ```
2070
2078
 
2079
+ **Usage accounting:** If a tool makes nested LLM calls, return their combined `Usage` as `usage`. Pi persists it on the tool result and includes it in footer, `/session`, and RPC session totals. `tool_result` handlers can inspect or replace this value.
2080
+
2071
2081
  **Signaling errors:** To mark a tool execution as failed (sets `isError: true` on the result and reports it to the LLM), throw an error from `execute`. Returning a value never sets the error flag regardless of what properties you include in the return object.
2072
2082
 
2073
2083
  **Early termination:** Return `terminate: true` from `execute()` to hint that the automatic follow-up LLM call should be skipped after the current tool batch. This only takes effect when every finalized tool result in that batch is terminating. See [examples/extensions/structured-output.ts](../examples/extensions/structured-output.ts) for a minimal example where the agent ends on a final structured-output tool call.
@@ -2210,7 +2220,15 @@ const bashTool = createBashTool(cwd, {
2210
2220
  });
2211
2221
  ```
2212
2222
 
2213
- See [examples/extensions/ssh.ts](../examples/extensions/ssh.ts) for a complete SSH example with `--ssh` flag.
2223
+ `createBashTool()` exposes the current session to commands through `PI_SESSION_ID`, `PI_SESSION_FILE`, `PI_PROVIDER`, `PI_MODEL`, and `PI_REASONING_LEVEL`. Injection happens before `spawnHook`, so hooks receive these values in `env` and preserve them when they spread the existing environment as above. Set `exposeSessionEnvironment: false` to disable them:
2224
+
2225
+ ```typescript
2226
+ const bashTool = createBashTool(cwd, {
2227
+ exposeSessionEnvironment: false,
2228
+ });
2229
+ ```
2230
+
2231
+ See [Bash tool session environment](environment-variables.md#bash-tool-session-environment) for variable semantics. See [examples/extensions/ssh.ts](../examples/extensions/ssh.ts) for a complete SSH example with `--ssh` flag.
2214
2232
 
2215
2233
  ### Output Truncation
2216
2234