@code-yeongyu/senpi 2026.7.23 → 2026.7.25-2

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 (900) hide show
  1. package/CHANGELOG.md +162 -6
  2. package/README.md +14 -1
  3. package/dist/beta/omo-local-update.d.ts +207 -0
  4. package/dist/beta/omo-local-update.d.ts.map +1 -0
  5. package/dist/beta/omo-local-update.js +708 -0
  6. package/dist/beta/omo-local-update.js.map +1 -0
  7. package/dist/cli/args.d.ts +2 -0
  8. package/dist/cli/args.d.ts.map +1 -1
  9. package/dist/cli/args.js +6 -0
  10. package/dist/cli/args.js.map +1 -1
  11. package/dist/cli/config-selector.js +1 -1
  12. package/dist/cli/config-selector.js.map +1 -1
  13. package/dist/core/agent-session-runtime.d.ts +15 -1
  14. package/dist/core/agent-session-runtime.d.ts.map +1 -1
  15. package/dist/core/agent-session-runtime.js +12 -2
  16. package/dist/core/agent-session-runtime.js.map +1 -1
  17. package/dist/core/agent-session.d.ts +115 -4
  18. package/dist/core/agent-session.d.ts.map +1 -1
  19. package/dist/core/agent-session.js +1317 -320
  20. package/dist/core/agent-session.js.map +1 -1
  21. package/dist/core/compaction/branch-summarization.d.ts +7 -1
  22. package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
  23. package/dist/core/compaction/branch-summarization.js +8 -12
  24. package/dist/core/compaction/branch-summarization.js.map +1 -1
  25. package/dist/core/compaction/compaction.d.ts +22 -4
  26. package/dist/core/compaction/compaction.d.ts.map +1 -1
  27. package/dist/core/compaction/compaction.js +114 -51
  28. package/dist/core/compaction/compaction.js.map +1 -1
  29. package/dist/core/compaction/lifecycle.d.ts +69 -0
  30. package/dist/core/compaction/lifecycle.d.ts.map +1 -0
  31. package/dist/core/compaction/lifecycle.js +104 -0
  32. package/dist/core/compaction/lifecycle.js.map +1 -0
  33. package/dist/core/compaction/utils.d.ts +12 -1
  34. package/dist/core/compaction/utils.d.ts.map +1 -1
  35. package/dist/core/compaction/utils.js +22 -17
  36. package/dist/core/compaction/utils.js.map +1 -1
  37. package/dist/core/event-bus.d.ts.map +1 -1
  38. package/dist/core/event-bus.js +11 -1
  39. package/dist/core/event-bus.js.map +1 -1
  40. package/dist/core/extensions/builtin/compaction/index.d.ts +2 -1
  41. package/dist/core/extensions/builtin/compaction/index.d.ts.map +1 -1
  42. package/dist/core/extensions/builtin/compaction/index.js +42 -30
  43. package/dist/core/extensions/builtin/compaction/index.js.map +1 -1
  44. package/dist/core/extensions/builtin/compaction/openai-remote-model.d.ts +9 -2
  45. package/dist/core/extensions/builtin/compaction/openai-remote-model.d.ts.map +1 -1
  46. package/dist/core/extensions/builtin/compaction/openai-remote-model.js +78 -28
  47. package/dist/core/extensions/builtin/compaction/openai-remote-model.js.map +1 -1
  48. package/dist/core/extensions/builtin/compaction/openai-remote-schema.d.ts +3 -1
  49. package/dist/core/extensions/builtin/compaction/openai-remote-schema.d.ts.map +1 -1
  50. package/dist/core/extensions/builtin/compaction/openai-remote-schema.js +19 -1
  51. package/dist/core/extensions/builtin/compaction/openai-remote-schema.js.map +1 -1
  52. package/dist/core/extensions/builtin/compaction/openai-remote.d.ts +20 -6
  53. package/dist/core/extensions/builtin/compaction/openai-remote.d.ts.map +1 -1
  54. package/dist/core/extensions/builtin/compaction/openai-remote.js +207 -22
  55. package/dist/core/extensions/builtin/compaction/openai-remote.js.map +1 -1
  56. package/dist/core/extensions/builtin/compaction/speculative.d.ts +4 -2
  57. package/dist/core/extensions/builtin/compaction/speculative.d.ts.map +1 -1
  58. package/dist/core/extensions/builtin/compaction/speculative.js +25 -13
  59. package/dist/core/extensions/builtin/compaction/speculative.js.map +1 -1
  60. package/dist/core/extensions/builtin/config-reload/index.d.ts +7 -0
  61. package/dist/core/extensions/builtin/config-reload/index.d.ts.map +1 -1
  62. package/dist/core/extensions/builtin/config-reload/index.js +69 -34
  63. package/dist/core/extensions/builtin/config-reload/index.js.map +1 -1
  64. package/dist/core/extensions/builtin/config-reload/log.d.ts +4 -1
  65. package/dist/core/extensions/builtin/config-reload/log.d.ts.map +1 -1
  66. package/dist/core/extensions/builtin/config-reload/log.js +3 -0
  67. package/dist/core/extensions/builtin/config-reload/log.js.map +1 -1
  68. package/dist/core/extensions/builtin/config-reload/routine-settings.d.ts +15 -0
  69. package/dist/core/extensions/builtin/config-reload/routine-settings.d.ts.map +1 -0
  70. package/dist/core/extensions/builtin/config-reload/routine-settings.js +102 -0
  71. package/dist/core/extensions/builtin/config-reload/routine-settings.js.map +1 -0
  72. package/dist/core/extensions/builtin/hooks/index.js +1 -1
  73. package/dist/core/extensions/builtin/hooks/index.js.map +1 -1
  74. package/dist/core/extensions/builtin/hooks/lifecycle-adapter.d.ts +3 -1
  75. package/dist/core/extensions/builtin/hooks/lifecycle-adapter.d.ts.map +1 -1
  76. package/dist/core/extensions/builtin/hooks/lifecycle-adapter.js +2 -1
  77. package/dist/core/extensions/builtin/hooks/lifecycle-adapter.js.map +1 -1
  78. package/dist/core/extensions/builtin/mcp/auth/commands-auth-dispatch.d.ts +2 -1
  79. package/dist/core/extensions/builtin/mcp/auth/commands-auth-dispatch.d.ts.map +1 -1
  80. package/dist/core/extensions/builtin/mcp/auth/commands-auth-dispatch.js +5 -3
  81. package/dist/core/extensions/builtin/mcp/auth/commands-auth-dispatch.js.map +1 -1
  82. package/dist/core/extensions/builtin/mcp/auth/commands-auth.d.ts +5 -0
  83. package/dist/core/extensions/builtin/mcp/auth/commands-auth.d.ts.map +1 -1
  84. package/dist/core/extensions/builtin/mcp/auth/commands-auth.js +8 -3
  85. package/dist/core/extensions/builtin/mcp/auth/commands-auth.js.map +1 -1
  86. package/dist/core/extensions/builtin/mcp/catalog.d.ts +3 -1
  87. package/dist/core/extensions/builtin/mcp/catalog.d.ts.map +1 -1
  88. package/dist/core/extensions/builtin/mcp/catalog.js +2 -0
  89. package/dist/core/extensions/builtin/mcp/catalog.js.map +1 -1
  90. package/dist/core/extensions/builtin/mcp/commands.d.ts +1 -1
  91. package/dist/core/extensions/builtin/mcp/commands.d.ts.map +1 -1
  92. package/dist/core/extensions/builtin/mcp/commands.js +34 -39
  93. package/dist/core/extensions/builtin/mcp/commands.js.map +1 -1
  94. package/dist/core/extensions/builtin/mcp/connection-types.d.ts +2 -0
  95. package/dist/core/extensions/builtin/mcp/connection-types.d.ts.map +1 -1
  96. package/dist/core/extensions/builtin/mcp/connection-types.js.map +1 -1
  97. package/dist/core/extensions/builtin/mcp/connection.d.ts.map +1 -1
  98. package/dist/core/extensions/builtin/mcp/connection.js +3 -0
  99. package/dist/core/extensions/builtin/mcp/connection.js.map +1 -1
  100. package/dist/core/extensions/builtin/mcp/elicitation.d.ts +7 -3
  101. package/dist/core/extensions/builtin/mcp/elicitation.d.ts.map +1 -1
  102. package/dist/core/extensions/builtin/mcp/elicitation.js +5 -5
  103. package/dist/core/extensions/builtin/mcp/elicitation.js.map +1 -1
  104. package/dist/core/extensions/builtin/mcp/expose/register.d.ts.map +1 -1
  105. package/dist/core/extensions/builtin/mcp/expose/register.js +1 -0
  106. package/dist/core/extensions/builtin/mcp/expose/register.js.map +1 -1
  107. package/dist/core/extensions/builtin/mcp/expose/session.d.ts +2 -0
  108. package/dist/core/extensions/builtin/mcp/expose/session.d.ts.map +1 -1
  109. package/dist/core/extensions/builtin/mcp/expose/session.js +3 -0
  110. package/dist/core/extensions/builtin/mcp/expose/session.js.map +1 -1
  111. package/dist/core/extensions/builtin/mcp/guard/output-guard.d.ts +9 -1
  112. package/dist/core/extensions/builtin/mcp/guard/output-guard.d.ts.map +1 -1
  113. package/dist/core/extensions/builtin/mcp/guard/output-guard.js +18 -6
  114. package/dist/core/extensions/builtin/mcp/guard/output-guard.js.map +1 -1
  115. package/dist/core/extensions/builtin/mcp/index.d.ts +4 -2
  116. package/dist/core/extensions/builtin/mcp/index.d.ts.map +1 -1
  117. package/dist/core/extensions/builtin/mcp/index.js +150 -127
  118. package/dist/core/extensions/builtin/mcp/index.js.map +1 -1
  119. package/dist/core/extensions/builtin/mcp/instructions.d.ts +1 -1
  120. package/dist/core/extensions/builtin/mcp/instructions.d.ts.map +1 -1
  121. package/dist/core/extensions/builtin/mcp/instructions.js +6 -6
  122. package/dist/core/extensions/builtin/mcp/instructions.js.map +1 -1
  123. package/dist/core/extensions/builtin/mcp/prompts.d.ts +2 -0
  124. package/dist/core/extensions/builtin/mcp/prompts.d.ts.map +1 -1
  125. package/dist/core/extensions/builtin/mcp/prompts.js +9 -3
  126. package/dist/core/extensions/builtin/mcp/prompts.js.map +1 -1
  127. package/dist/core/extensions/builtin/mcp/resources.d.ts +2 -0
  128. package/dist/core/extensions/builtin/mcp/resources.d.ts.map +1 -1
  129. package/dist/core/extensions/builtin/mcp/resources.js +1 -0
  130. package/dist/core/extensions/builtin/mcp/resources.js.map +1 -1
  131. package/dist/core/extensions/builtin/mcp/service-register.d.ts.map +1 -1
  132. package/dist/core/extensions/builtin/mcp/service-register.js +1 -0
  133. package/dist/core/extensions/builtin/mcp/service-register.js.map +1 -1
  134. package/dist/core/extensions/builtin/mcp/service-types.d.ts +2 -0
  135. package/dist/core/extensions/builtin/mcp/service-types.d.ts.map +1 -1
  136. package/dist/core/extensions/builtin/mcp/service-types.js.map +1 -1
  137. package/dist/core/extensions/builtin/mcp/service.d.ts +12 -1
  138. package/dist/core/extensions/builtin/mcp/service.d.ts.map +1 -1
  139. package/dist/core/extensions/builtin/mcp/service.js +44 -2
  140. package/dist/core/extensions/builtin/mcp/service.js.map +1 -1
  141. package/dist/core/extensions/builtin/mcp/transport.d.ts +2 -0
  142. package/dist/core/extensions/builtin/mcp/transport.d.ts.map +1 -1
  143. package/dist/core/extensions/builtin/mcp/transport.js +7 -7
  144. package/dist/core/extensions/builtin/mcp/transport.js.map +1 -1
  145. package/dist/core/extensions/builtin/prompt-preset/claude-fable-5.d.ts.map +1 -1
  146. package/dist/core/extensions/builtin/prompt-preset/claude-fable-5.js +86 -7
  147. package/dist/core/extensions/builtin/prompt-preset/claude-fable-5.js.map +1 -1
  148. package/dist/core/extensions/builtin/prompt-preset/claude-opus-5.d.ts +3 -0
  149. package/dist/core/extensions/builtin/prompt-preset/claude-opus-5.d.ts.map +1 -0
  150. package/dist/core/extensions/builtin/prompt-preset/claude-opus-5.js +102 -0
  151. package/dist/core/extensions/builtin/prompt-preset/claude-opus-5.js.map +1 -0
  152. package/dist/core/extensions/builtin/prompt-preset/gpt-5.6.d.ts +48 -0
  153. package/dist/core/extensions/builtin/prompt-preset/gpt-5.6.d.ts.map +1 -1
  154. package/dist/core/extensions/builtin/prompt-preset/gpt-5.6.js +88 -64
  155. package/dist/core/extensions/builtin/prompt-preset/gpt-5.6.js.map +1 -1
  156. package/dist/core/extensions/builtin/prompt-preset/kimi-k3.d.ts.map +1 -1
  157. package/dist/core/extensions/builtin/prompt-preset/kimi-k3.js +96 -6
  158. package/dist/core/extensions/builtin/prompt-preset/kimi-k3.js.map +1 -1
  159. package/dist/core/extensions/builtin/prompt-preset/presets.d.ts.map +1 -1
  160. package/dist/core/extensions/builtin/prompt-preset/presets.js +9 -0
  161. package/dist/core/extensions/builtin/prompt-preset/presets.js.map +1 -1
  162. package/dist/core/extensions/builtin/prompt-preset/settings.d.ts +1 -1
  163. package/dist/core/extensions/builtin/prompt-preset/settings.d.ts.map +1 -1
  164. package/dist/core/extensions/builtin/prompt-preset/settings.js +1 -0
  165. package/dist/core/extensions/builtin/prompt-preset/settings.js.map +1 -1
  166. package/dist/core/extensions/builtin/terminal/extension.d.ts.map +1 -1
  167. package/dist/core/extensions/builtin/terminal/extension.js +1 -0
  168. package/dist/core/extensions/builtin/terminal/extension.js.map +1 -1
  169. package/dist/core/extensions/builtin/terminal/tools/bash.d.ts +15 -3
  170. package/dist/core/extensions/builtin/terminal/tools/bash.d.ts.map +1 -1
  171. package/dist/core/extensions/builtin/terminal/tools/bash.js +30 -6
  172. package/dist/core/extensions/builtin/terminal/tools/bash.js.map +1 -1
  173. package/dist/core/extensions/builtin/terminal/tools/context.d.ts +5 -0
  174. package/dist/core/extensions/builtin/terminal/tools/context.d.ts.map +1 -1
  175. package/dist/core/extensions/builtin/terminal/tools/context.js.map +1 -1
  176. package/dist/core/extensions/builtin/websearch/index.d.ts.map +1 -1
  177. package/dist/core/extensions/builtin/websearch/index.js +2 -4
  178. package/dist/core/extensions/builtin/websearch/index.js.map +1 -1
  179. package/dist/core/extensions/builtin/websearch/websearch/config.d.ts.map +1 -1
  180. package/dist/core/extensions/builtin/websearch/websearch/config.js +4 -1
  181. package/dist/core/extensions/builtin/websearch/websearch/config.js.map +1 -1
  182. package/dist/core/extensions/builtin/websearch/websearch/native.d.ts.map +1 -1
  183. package/dist/core/extensions/builtin/websearch/websearch/native.js +2 -4
  184. package/dist/core/extensions/builtin/websearch/websearch/native.js.map +1 -1
  185. package/dist/core/extensions/builtin/websearch/websearch/renderers.d.ts.map +1 -1
  186. package/dist/core/extensions/builtin/websearch/websearch/renderers.js +20 -8
  187. package/dist/core/extensions/builtin/websearch/websearch/renderers.js.map +1 -1
  188. package/dist/core/extensions/builtin/websearch/websearch/search.d.ts +6 -1
  189. package/dist/core/extensions/builtin/websearch/websearch/search.d.ts.map +1 -1
  190. package/dist/core/extensions/builtin/websearch/websearch/search.js +15 -11
  191. package/dist/core/extensions/builtin/websearch/websearch/search.js.map +1 -1
  192. package/dist/core/extensions/builtin/websearch/websearch/tool.d.ts.map +1 -1
  193. package/dist/core/extensions/builtin/websearch/websearch/tool.js +5 -10
  194. package/dist/core/extensions/builtin/websearch/websearch/tool.js.map +1 -1
  195. package/dist/core/extensions/builtin/websearch/websearch/types.d.ts +1 -0
  196. package/dist/core/extensions/builtin/websearch/websearch/types.d.ts.map +1 -1
  197. package/dist/core/extensions/builtin/websearch/websearch/types.js.map +1 -1
  198. package/dist/core/extensions/runner.d.ts +14 -7
  199. package/dist/core/extensions/runner.d.ts.map +1 -1
  200. package/dist/core/extensions/runner.js +64 -37
  201. package/dist/core/extensions/runner.js.map +1 -1
  202. package/dist/core/extensions/types.d.ts +32 -3
  203. package/dist/core/extensions/types.d.ts.map +1 -1
  204. package/dist/core/extensions/types.js.map +1 -1
  205. package/dist/core/http-dispatcher.d.ts.map +1 -1
  206. package/dist/core/http-dispatcher.js +16 -0
  207. package/dist/core/http-dispatcher.js.map +1 -1
  208. package/dist/core/messages.d.ts +1 -1
  209. package/dist/core/messages.d.ts.map +1 -1
  210. package/dist/core/messages.js +10 -8
  211. package/dist/core/messages.js.map +1 -1
  212. package/dist/core/model-registry.d.ts +1 -0
  213. package/dist/core/model-registry.d.ts.map +1 -1
  214. package/dist/core/model-registry.js +3 -2
  215. package/dist/core/model-registry.js.map +1 -1
  216. package/dist/core/model-resolver.d.ts +1 -0
  217. package/dist/core/model-resolver.d.ts.map +1 -1
  218. package/dist/core/model-resolver.js +22 -3
  219. package/dist/core/model-resolver.js.map +1 -1
  220. package/dist/core/model-runtime.d.ts +4 -2
  221. package/dist/core/model-runtime.d.ts.map +1 -1
  222. package/dist/core/model-runtime.js +34 -18
  223. package/dist/core/model-runtime.js.map +1 -1
  224. package/dist/core/remote-catalog-provider.d.ts +1 -1
  225. package/dist/core/remote-catalog-provider.d.ts.map +1 -1
  226. package/dist/core/remote-catalog-provider.js +39 -7
  227. package/dist/core/remote-catalog-provider.js.map +1 -1
  228. package/dist/core/resolve-config-value.d.ts.map +1 -1
  229. package/dist/core/resolve-config-value.js +12 -8
  230. package/dist/core/resolve-config-value.js.map +1 -1
  231. package/dist/core/resource-loader.d.ts.map +1 -1
  232. package/dist/core/resource-loader.js +3 -0
  233. package/dist/core/resource-loader.js.map +1 -1
  234. package/dist/core/retry-fallback/controller.d.ts +7 -0
  235. package/dist/core/retry-fallback/controller.d.ts.map +1 -1
  236. package/dist/core/retry-fallback/controller.js +13 -0
  237. package/dist/core/retry-fallback/controller.js.map +1 -1
  238. package/dist/core/sdk.d.ts +1 -1
  239. package/dist/core/sdk.d.ts.map +1 -1
  240. package/dist/core/sdk.js +8 -3
  241. package/dist/core/sdk.js.map +1 -1
  242. package/dist/core/session-manager.d.ts +22 -3
  243. package/dist/core/session-manager.d.ts.map +1 -1
  244. package/dist/core/session-manager.js +155 -58
  245. package/dist/core/session-manager.js.map +1 -1
  246. package/dist/core/settings-manager.d.ts +8 -1
  247. package/dist/core/settings-manager.d.ts.map +1 -1
  248. package/dist/core/settings-manager.js +10 -0
  249. package/dist/core/settings-manager.js.map +1 -1
  250. package/dist/core/system-prompt.js +1 -1
  251. package/dist/core/system-prompt.js.map +1 -1
  252. package/dist/core/thinking-levels.d.ts.map +1 -1
  253. package/dist/core/thinking-levels.js +9 -2
  254. package/dist/core/thinking-levels.js.map +1 -1
  255. package/dist/core/tools/bash.d.ts +2 -0
  256. package/dist/core/tools/bash.d.ts.map +1 -1
  257. package/dist/core/tools/bash.js +34 -5
  258. package/dist/core/tools/bash.js.map +1 -1
  259. package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -1
  260. package/dist/core/tools/tool-definition-wrapper.js +3 -1
  261. package/dist/core/tools/tool-definition-wrapper.js.map +1 -1
  262. package/dist/core/usage-totals.d.ts +19 -0
  263. package/dist/core/usage-totals.d.ts.map +1 -0
  264. package/dist/core/usage-totals.js +52 -0
  265. package/dist/core/usage-totals.js.map +1 -0
  266. package/dist/extensions/llama/client.d.ts.map +1 -1
  267. package/dist/extensions/llama/client.js +3 -1
  268. package/dist/extensions/llama/client.js.map +1 -1
  269. package/dist/extensions/llama/index.js +3 -3
  270. package/dist/extensions/llama/index.js.map +1 -1
  271. package/dist/extensions/llama/provider.d.ts.map +1 -1
  272. package/dist/extensions/llama/provider.js +7 -2
  273. package/dist/extensions/llama/provider.js.map +1 -1
  274. package/dist/index.d.ts +2 -2
  275. package/dist/index.d.ts.map +1 -1
  276. package/dist/index.js +1 -1
  277. package/dist/index.js.map +1 -1
  278. package/dist/main.d.ts.map +1 -1
  279. package/dist/main.js +37 -5
  280. package/dist/main.js.map +1 -1
  281. package/dist/modes/app-server/daemon/occupancy.d.ts +22 -0
  282. package/dist/modes/app-server/daemon/occupancy.d.ts.map +1 -0
  283. package/dist/modes/app-server/daemon/occupancy.js +67 -0
  284. package/dist/modes/app-server/daemon/occupancy.js.map +1 -0
  285. package/dist/modes/app-server/daemon/probe.d.ts +3 -3
  286. package/dist/modes/app-server/daemon/probe.d.ts.map +1 -1
  287. package/dist/modes/app-server/daemon/probe.js +33 -10
  288. package/dist/modes/app-server/daemon/probe.js.map +1 -1
  289. package/dist/modes/app-server/daemon.d.ts.map +1 -1
  290. package/dist/modes/app-server/daemon.js +58 -18
  291. package/dist/modes/app-server/daemon.js.map +1 -1
  292. package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -1
  293. package/dist/modes/interactive/components/compaction-summary-message.js +8 -1
  294. package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -1
  295. package/dist/modes/interactive/components/custom-message.d.ts +3 -1
  296. package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
  297. package/dist/modes/interactive/components/custom-message.js +9 -2
  298. package/dist/modes/interactive/components/custom-message.js.map +1 -1
  299. package/dist/modes/interactive/components/extension-editor.d.ts +1 -2
  300. package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -1
  301. package/dist/modes/interactive/components/extension-editor.js +16 -46
  302. package/dist/modes/interactive/components/extension-editor.js.map +1 -1
  303. package/dist/modes/interactive/components/footer.d.ts.map +1 -1
  304. package/dist/modes/interactive/components/footer.js.map +1 -1
  305. package/dist/modes/interactive/components/status-indicator.d.ts +4 -0
  306. package/dist/modes/interactive/components/status-indicator.d.ts.map +1 -1
  307. package/dist/modes/interactive/components/status-indicator.js +13 -0
  308. package/dist/modes/interactive/components/status-indicator.js.map +1 -1
  309. package/dist/modes/interactive/external-editor.d.ts +12 -0
  310. package/dist/modes/interactive/external-editor.d.ts.map +1 -0
  311. package/dist/modes/interactive/external-editor.js +37 -0
  312. package/dist/modes/interactive/external-editor.js.map +1 -0
  313. package/dist/modes/interactive/interactive-mode.d.ts +3 -1
  314. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  315. package/dist/modes/interactive/interactive-mode.js +105 -80
  316. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  317. package/dist/modes/rpc/connection-handler.d.ts +6 -0
  318. package/dist/modes/rpc/connection-handler.d.ts.map +1 -1
  319. package/dist/modes/rpc/connection-handler.js +34 -9
  320. package/dist/modes/rpc/connection-handler.js.map +1 -1
  321. package/dist/modes/rpc/multi-session-host.d.ts +15 -0
  322. package/dist/modes/rpc/multi-session-host.d.ts.map +1 -0
  323. package/dist/modes/rpc/multi-session-host.js +60 -0
  324. package/dist/modes/rpc/multi-session-host.js.map +1 -0
  325. package/dist/modes/rpc/neo-runtime-options.d.ts.map +1 -1
  326. package/dist/modes/rpc/neo-runtime-options.js +1 -0
  327. package/dist/modes/rpc/neo-runtime-options.js.map +1 -1
  328. package/dist/modes/rpc/rpc-client.d.ts +4 -0
  329. package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
  330. package/dist/modes/rpc/rpc-client.js +7 -0
  331. package/dist/modes/rpc/rpc-client.js.map +1 -1
  332. package/dist/modes/rpc/rpc-mode.d.ts +49 -0
  333. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  334. package/dist/modes/rpc/rpc-mode.js +49 -0
  335. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  336. package/dist/modes/rpc/rpc-types.d.ts +85 -1
  337. package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
  338. package/dist/modes/rpc/rpc-types.js +8 -1
  339. package/dist/modes/rpc/rpc-types.js.map +1 -1
  340. package/dist/modes/rpc/session-binding.d.ts +13 -0
  341. package/dist/modes/rpc/session-binding.d.ts.map +1 -0
  342. package/dist/modes/rpc/session-binding.js +33 -0
  343. package/dist/modes/rpc/session-binding.js.map +1 -0
  344. package/dist/modes/rpc/session-command-router.d.ts +19 -0
  345. package/dist/modes/rpc/session-command-router.d.ts.map +1 -0
  346. package/dist/modes/rpc/session-command-router.js +159 -0
  347. package/dist/modes/rpc/session-command-router.js.map +1 -0
  348. package/dist/modes/rpc/session-event-writer.d.ts +34 -0
  349. package/dist/modes/rpc/session-event-writer.d.ts.map +1 -0
  350. package/dist/modes/rpc/session-event-writer.js +92 -0
  351. package/dist/modes/rpc/session-event-writer.js.map +1 -0
  352. package/dist/modes/rpc/session-extension-ui-requests.d.ts +15 -0
  353. package/dist/modes/rpc/session-extension-ui-requests.d.ts.map +1 -0
  354. package/dist/modes/rpc/session-extension-ui-requests.js +27 -0
  355. package/dist/modes/rpc/session-extension-ui-requests.js.map +1 -0
  356. package/dist/modes/rpc/session-registry.d.ts +58 -0
  357. package/dist/modes/rpc/session-registry.d.ts.map +1 -0
  358. package/dist/modes/rpc/session-registry.js +162 -0
  359. package/dist/modes/rpc/session-registry.js.map +1 -0
  360. package/dist/package-manager-cli.d.ts.map +1 -1
  361. package/dist/package-manager-cli.js +11 -0
  362. package/dist/package-manager-cli.js.map +1 -1
  363. package/dist/utils/clipboard.d.ts.map +1 -1
  364. package/dist/utils/clipboard.js +19 -8
  365. package/dist/utils/clipboard.js.map +1 -1
  366. package/dist/utils/version-check.d.ts.map +1 -1
  367. package/dist/utils/version-check.js +3 -1
  368. package/dist/utils/version-check.js.map +1 -1
  369. package/docs/app-server-daemon.md +3 -2
  370. package/docs/compaction.md +9 -4
  371. package/docs/custom-provider.md +5 -2
  372. package/docs/environment-variables.md +88 -0
  373. package/docs/extensions.md +27 -9
  374. package/docs/index.md +1 -0
  375. package/docs/json.md +5 -1
  376. package/docs/models.md +6 -2
  377. package/docs/providers.md +12 -1
  378. package/docs/rpc.md +154 -8
  379. package/docs/sdk.md +3 -0
  380. package/docs/session-format.md +17 -3
  381. package/docs/settings.md +13 -2
  382. package/docs/usage.md +1 -14
  383. package/examples/extensions/custom-compaction.ts +4 -0
  384. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  385. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  386. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  387. package/examples/extensions/gondolin/package-lock.json +2 -2
  388. package/examples/extensions/gondolin/package.json +1 -1
  389. package/examples/extensions/handoff.ts +9 -1
  390. package/examples/extensions/message-renderer.ts +2 -2
  391. package/examples/extensions/sandbox/package-lock.json +2 -2
  392. package/examples/extensions/sandbox/package.json +1 -1
  393. package/examples/extensions/summarize.ts +3 -0
  394. package/examples/extensions/with-deps/package-lock.json +2 -2
  395. package/examples/extensions/with-deps/package.json +1 -1
  396. package/node_modules/@code-yeongyu/senpi-codemode/CHANGELOG.md +36 -0
  397. package/node_modules/@code-yeongyu/senpi-codemode/package.json +3 -3
  398. package/node_modules/@earendil-works/pi-agent-core/README.md +31 -12
  399. package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.d.ts +4 -4
  400. package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.d.ts.map +1 -1
  401. package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.js +8 -7
  402. package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.js.map +1 -1
  403. package/node_modules/@earendil-works/pi-agent-core/dist/agent.d.ts +13 -3
  404. package/node_modules/@earendil-works/pi-agent-core/dist/agent.d.ts.map +1 -1
  405. package/node_modules/@earendil-works/pi-agent-core/dist/agent.js +63 -27
  406. package/node_modules/@earendil-works/pi-agent-core/dist/agent.js.map +1 -1
  407. package/node_modules/@earendil-works/pi-agent-core/dist/harness/agent-harness.d.ts +11 -12
  408. package/node_modules/@earendil-works/pi-agent-core/dist/harness/agent-harness.d.ts.map +1 -1
  409. package/node_modules/@earendil-works/pi-agent-core/dist/harness/agent-harness.js +47 -22
  410. package/node_modules/@earendil-works/pi-agent-core/dist/harness/agent-harness.js.map +1 -1
  411. package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/branch-summarization.d.ts +5 -1
  412. package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/branch-summarization.d.ts.map +1 -1
  413. package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/branch-summarization.js +6 -8
  414. package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/branch-summarization.js.map +1 -1
  415. package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/compaction.d.ts +17 -5
  416. package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/compaction.d.ts.map +1 -1
  417. package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/compaction.js +82 -27
  418. package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/compaction.js.map +1 -1
  419. package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/utils.d.ts +12 -1
  420. package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/utils.d.ts.map +1 -1
  421. package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/utils.js +22 -17
  422. package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/utils.js.map +1 -1
  423. package/node_modules/@earendil-works/pi-agent-core/dist/harness/env/nodejs.d.ts +3 -9
  424. package/node_modules/@earendil-works/pi-agent-core/dist/harness/env/nodejs.d.ts.map +1 -1
  425. package/node_modules/@earendil-works/pi-agent-core/dist/harness/env/nodejs.js +118 -11
  426. package/node_modules/@earendil-works/pi-agent-core/dist/harness/env/nodejs.js.map +1 -1
  427. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-storage.d.ts +11 -3
  428. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-storage.d.ts.map +1 -1
  429. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-storage.js +56 -4
  430. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-storage.js.map +1 -1
  431. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-storage.d.ts +11 -3
  432. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-storage.d.ts.map +1 -1
  433. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-storage.js +56 -4
  434. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-storage.js.map +1 -1
  435. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/repo-utils.d.ts.map +1 -1
  436. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/repo-utils.js +2 -2
  437. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/repo-utils.js.map +1 -1
  438. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/session.d.ts +6 -4
  439. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/session.d.ts.map +1 -1
  440. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/session.js +30 -14
  441. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/session.js.map +1 -1
  442. package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/bash.d.ts +27 -0
  443. package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/bash.d.ts.map +1 -0
  444. package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/bash.js +132 -0
  445. package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/bash.js.map +1 -0
  446. package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/edit-diff.d.ts +89 -0
  447. package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/edit-diff.d.ts.map +1 -0
  448. package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/edit-diff.js +386 -0
  449. package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/edit-diff.js.map +1 -0
  450. package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/edit.d.ts +19 -0
  451. package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/edit.d.ts.map +1 -0
  452. package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/edit.js +95 -0
  453. package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/edit.js.map +1 -0
  454. package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/file-mutation-queue.d.ts +4 -0
  455. package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/file-mutation-queue.d.ts.map +1 -0
  456. package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/file-mutation-queue.js +46 -0
  457. package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/file-mutation-queue.js.map +1 -0
  458. package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/image.d.ts +3 -0
  459. package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/image.d.ts.map +1 -0
  460. package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/image.js +106 -0
  461. package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/image.js.map +1 -0
  462. package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/index.d.ts +6 -0
  463. package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/index.d.ts.map +1 -0
  464. package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/index.js +5 -0
  465. package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/index.js.map +1 -0
  466. package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/path-utils.d.ts +4 -0
  467. package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/path-utils.d.ts.map +1 -0
  468. package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/path-utils.js +26 -0
  469. package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/path-utils.js.map +1 -0
  470. package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/read.d.ts +34 -0
  471. package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/read.d.ts.map +1 -0
  472. package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/read.js +110 -0
  473. package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/read.js.map +1 -0
  474. package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/tool-context.d.ts +6 -0
  475. package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/tool-context.d.ts.map +1 -0
  476. package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/tool-context.js +2 -0
  477. package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/tool-context.js.map +1 -0
  478. package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/write.d.ts +11 -0
  479. package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/write.d.ts.map +1 -0
  480. package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/write.js +31 -0
  481. package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/write.js.map +1 -0
  482. package/node_modules/@earendil-works/pi-agent-core/dist/harness/types.d.ts +80 -18
  483. package/node_modules/@earendil-works/pi-agent-core/dist/harness/types.d.ts.map +1 -1
  484. package/node_modules/@earendil-works/pi-agent-core/dist/harness/types.js.map +1 -1
  485. package/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/shell-output.d.ts +12 -4
  486. package/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/shell-output.d.ts.map +1 -1
  487. package/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/shell-output.js +90 -35
  488. package/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/shell-output.js.map +1 -1
  489. package/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/truncate.d.ts.map +1 -1
  490. package/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/truncate.js +10 -4
  491. package/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/truncate.js.map +1 -1
  492. package/node_modules/@earendil-works/pi-agent-core/dist/index.d.ts +4 -2
  493. package/node_modules/@earendil-works/pi-agent-core/dist/index.d.ts.map +1 -1
  494. package/node_modules/@earendil-works/pi-agent-core/dist/index.js +5 -2
  495. package/node_modules/@earendil-works/pi-agent-core/dist/index.js.map +1 -1
  496. package/node_modules/@earendil-works/pi-agent-core/dist/stream-fn.d.ts +10 -0
  497. package/node_modules/@earendil-works/pi-agent-core/dist/stream-fn.d.ts.map +1 -0
  498. package/node_modules/@earendil-works/pi-agent-core/dist/stream-fn.js +17 -0
  499. package/node_modules/@earendil-works/pi-agent-core/dist/stream-fn.js.map +1 -0
  500. package/node_modules/@earendil-works/pi-agent-core/dist/types.d.ts +8 -2
  501. package/node_modules/@earendil-works/pi-agent-core/dist/types.d.ts.map +1 -1
  502. package/node_modules/@earendil-works/pi-agent-core/dist/types.js.map +1 -1
  503. package/node_modules/@earendil-works/pi-agent-core/package.json +4 -3
  504. package/node_modules/@earendil-works/pi-ai/README.md +44 -4
  505. package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.d.ts.map +1 -1
  506. package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js +130 -47
  507. package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js.map +1 -1
  508. package/node_modules/@earendil-works/pi-ai/dist/api/azure-openai-responses.d.ts.map +1 -1
  509. package/node_modules/@earendil-works/pi-ai/dist/api/azure-openai-responses.js +36 -15
  510. package/node_modules/@earendil-works/pi-ai/dist/api/azure-openai-responses.js.map +1 -1
  511. package/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.d.ts.map +1 -1
  512. package/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.js +55 -26
  513. package/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.js.map +1 -1
  514. package/node_modules/@earendil-works/pi-ai/dist/api/constrained-sampling.d.ts +17 -0
  515. package/node_modules/@earendil-works/pi-ai/dist/api/constrained-sampling.d.ts.map +1 -0
  516. package/node_modules/@earendil-works/pi-ai/dist/api/constrained-sampling.js +104 -0
  517. package/node_modules/@earendil-works/pi-ai/dist/api/constrained-sampling.js.map +1 -0
  518. package/node_modules/@earendil-works/pi-ai/dist/api/google-generative-ai.d.ts.map +1 -1
  519. package/node_modules/@earendil-works/pi-ai/dist/api/google-generative-ai.js +16 -13
  520. package/node_modules/@earendil-works/pi-ai/dist/api/google-generative-ai.js.map +1 -1
  521. package/node_modules/@earendil-works/pi-ai/dist/api/google-shared.d.ts +4 -3
  522. package/node_modules/@earendil-works/pi-ai/dist/api/google-shared.d.ts.map +1 -1
  523. package/node_modules/@earendil-works/pi-ai/dist/api/google-shared.js +17 -3
  524. package/node_modules/@earendil-works/pi-ai/dist/api/google-shared.js.map +1 -1
  525. package/node_modules/@earendil-works/pi-ai/dist/api/google-vertex.d.ts.map +1 -1
  526. package/node_modules/@earendil-works/pi-ai/dist/api/google-vertex.js +19 -13
  527. package/node_modules/@earendil-works/pi-ai/dist/api/google-vertex.js.map +1 -1
  528. package/node_modules/@earendil-works/pi-ai/dist/api/mistral-conversations.d.ts.map +1 -1
  529. package/node_modules/@earendil-works/pi-ai/dist/api/mistral-conversations.js +13 -9
  530. package/node_modules/@earendil-works/pi-ai/dist/api/mistral-conversations.js.map +1 -1
  531. package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.d.ts.map +1 -1
  532. package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.js +92 -58
  533. package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.js.map +1 -1
  534. package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.d.ts +7 -9
  535. package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.d.ts.map +1 -1
  536. package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js +263 -56
  537. package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js.map +1 -1
  538. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.d.ts +7 -0
  539. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.d.ts.map +1 -1
  540. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.js +180 -80
  541. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.js.map +1 -1
  542. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.d.ts.map +1 -1
  543. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.js +48 -21
  544. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.js.map +1 -1
  545. package/node_modules/@earendil-works/pi-ai/dist/api/openrouter-images.d.ts.map +1 -1
  546. package/node_modules/@earendil-works/pi-ai/dist/api/openrouter-images.js +8 -3
  547. package/node_modules/@earendil-works/pi-ai/dist/api/openrouter-images.js.map +1 -1
  548. package/node_modules/@earendil-works/pi-ai/dist/api/pi-messages.d.ts.map +1 -1
  549. package/node_modules/@earendil-works/pi-ai/dist/api/pi-messages.js +2 -4
  550. package/node_modules/@earendil-works/pi-ai/dist/api/pi-messages.js.map +1 -1
  551. package/node_modules/@earendil-works/pi-ai/dist/api/simple-options.d.ts.map +1 -1
  552. package/node_modules/@earendil-works/pi-ai/dist/api/simple-options.js +1 -0
  553. package/node_modules/@earendil-works/pi-ai/dist/api/simple-options.js.map +1 -1
  554. package/node_modules/@earendil-works/pi-ai/dist/api-registry.d.ts +15 -0
  555. package/node_modules/@earendil-works/pi-ai/dist/api-registry.d.ts.map +1 -1
  556. package/node_modules/@earendil-works/pi-ai/dist/api-registry.js +52 -6
  557. package/node_modules/@earendil-works/pi-ai/dist/api-registry.js.map +1 -1
  558. package/node_modules/@earendil-works/pi-ai/dist/auth/helpers.d.ts.map +1 -1
  559. package/node_modules/@earendil-works/pi-ai/dist/auth/helpers.js +3 -2
  560. package/node_modules/@earendil-works/pi-ai/dist/auth/helpers.js.map +1 -1
  561. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/kimi-coding.d.ts +10 -0
  562. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/kimi-coding.d.ts.map +1 -0
  563. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/kimi-coding.js +249 -0
  564. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/kimi-coding.js.map +1 -0
  565. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/load.d.ts +4 -0
  566. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/load.d.ts.map +1 -1
  567. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/load.js +10 -0
  568. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/load.js.map +1 -1
  569. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/openai-codex.d.ts.map +1 -1
  570. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/openai-codex.js +2 -18
  571. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/openai-codex.js.map +1 -1
  572. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/openrouter.d.ts +13 -0
  573. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/openrouter.d.ts.map +1 -0
  574. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/openrouter.js +222 -0
  575. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/openrouter.js.map +1 -0
  576. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/radius.d.ts +3 -2
  577. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/radius.d.ts.map +1 -1
  578. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/radius.js +37 -35
  579. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/radius.js.map +1 -1
  580. package/node_modules/@earendil-works/pi-ai/dist/auth/resolve.d.ts.map +1 -1
  581. package/node_modules/@earendil-works/pi-ai/dist/auth/resolve.js +11 -1
  582. package/node_modules/@earendil-works/pi-ai/dist/auth/resolve.js.map +1 -1
  583. package/node_modules/@earendil-works/pi-ai/dist/bun-oauth.d.ts.map +1 -1
  584. package/node_modules/@earendil-works/pi-ai/dist/bun-oauth.js +4 -0
  585. package/node_modules/@earendil-works/pi-ai/dist/bun-oauth.js.map +1 -1
  586. package/node_modules/@earendil-works/pi-ai/dist/compat.d.ts.map +1 -1
  587. package/node_modules/@earendil-works/pi-ai/dist/compat.js +2 -1
  588. package/node_modules/@earendil-works/pi-ai/dist/compat.js.map +1 -1
  589. package/node_modules/@earendil-works/pi-ai/dist/context-provenance.d.ts +16 -0
  590. package/node_modules/@earendil-works/pi-ai/dist/context-provenance.d.ts.map +1 -0
  591. package/node_modules/@earendil-works/pi-ai/dist/context-provenance.js +32 -0
  592. package/node_modules/@earendil-works/pi-ai/dist/context-provenance.js.map +1 -0
  593. package/node_modules/@earendil-works/pi-ai/dist/env-api-keys.d.ts +3 -0
  594. package/node_modules/@earendil-works/pi-ai/dist/env-api-keys.d.ts.map +1 -1
  595. package/node_modules/@earendil-works/pi-ai/dist/env-api-keys.js +11 -3
  596. package/node_modules/@earendil-works/pi-ai/dist/env-api-keys.js.map +1 -1
  597. package/node_modules/@earendil-works/pi-ai/dist/image-models.generated.d.ts +15 -0
  598. package/node_modules/@earendil-works/pi-ai/dist/image-models.generated.d.ts.map +1 -1
  599. package/node_modules/@earendil-works/pi-ai/dist/image-models.generated.js +15 -0
  600. package/node_modules/@earendil-works/pi-ai/dist/image-models.generated.js.map +1 -1
  601. package/node_modules/@earendil-works/pi-ai/dist/images-api-registry.d.ts +19 -2
  602. package/node_modules/@earendil-works/pi-ai/dist/images-api-registry.d.ts.map +1 -1
  603. package/node_modules/@earendil-works/pi-ai/dist/images-api-registry.js +68 -3
  604. package/node_modules/@earendil-works/pi-ai/dist/images-api-registry.js.map +1 -1
  605. package/node_modules/@earendil-works/pi-ai/dist/index.d.ts +6 -0
  606. package/node_modules/@earendil-works/pi-ai/dist/index.d.ts.map +1 -1
  607. package/node_modules/@earendil-works/pi-ai/dist/index.js +6 -0
  608. package/node_modules/@earendil-works/pi-ai/dist/index.js.map +1 -1
  609. package/node_modules/@earendil-works/pi-ai/dist/model-catalog.d.ts +17 -0
  610. package/node_modules/@earendil-works/pi-ai/dist/model-catalog.d.ts.map +1 -0
  611. package/node_modules/@earendil-works/pi-ai/dist/model-catalog.js +4 -0
  612. package/node_modules/@earendil-works/pi-ai/dist/model-catalog.js.map +1 -0
  613. package/node_modules/@earendil-works/pi-ai/dist/model.d.ts +2 -2
  614. package/node_modules/@earendil-works/pi-ai/dist/model.d.ts.map +1 -1
  615. package/node_modules/@earendil-works/pi-ai/dist/model.js.map +1 -1
  616. package/node_modules/@earendil-works/pi-ai/dist/models-store.d.ts +7 -0
  617. package/node_modules/@earendil-works/pi-ai/dist/models-store.d.ts.map +1 -1
  618. package/node_modules/@earendil-works/pi-ai/dist/models-store.js.map +1 -1
  619. package/node_modules/@earendil-works/pi-ai/dist/models.d.ts +0 -6
  620. package/node_modules/@earendil-works/pi-ai/dist/models.d.ts.map +1 -1
  621. package/node_modules/@earendil-works/pi-ai/dist/models.generated.d.ts +76 -4448
  622. package/node_modules/@earendil-works/pi-ai/dist/models.generated.d.ts.map +1 -1
  623. package/node_modules/@earendil-works/pi-ai/dist/models.generated.js +4 -0
  624. package/node_modules/@earendil-works/pi-ai/dist/models.generated.js.map +1 -1
  625. package/node_modules/@earendil-works/pi-ai/dist/models.js +5 -54
  626. package/node_modules/@earendil-works/pi-ai/dist/models.js.map +1 -1
  627. package/node_modules/@earendil-works/pi-ai/dist/node/provider-scope.d.ts +12 -0
  628. package/node_modules/@earendil-works/pi-ai/dist/node/provider-scope.d.ts.map +1 -0
  629. package/node_modules/@earendil-works/pi-ai/dist/node/provider-scope.js +34 -0
  630. package/node_modules/@earendil-works/pi-ai/dist/node/provider-scope.js.map +1 -0
  631. package/node_modules/@earendil-works/pi-ai/dist/providers/alibaba-token-plan.models.d.ts +3 -63
  632. package/node_modules/@earendil-works/pi-ai/dist/providers/alibaba-token-plan.models.d.ts.map +1 -1
  633. package/node_modules/@earendil-works/pi-ai/dist/providers/alibaba-token-plan.models.js +2 -1
  634. package/node_modules/@earendil-works/pi-ai/dist/providers/alibaba-token-plan.models.js.map +1 -1
  635. package/node_modules/@earendil-works/pi-ai/dist/providers/all.d.ts +2 -0
  636. package/node_modules/@earendil-works/pi-ai/dist/providers/all.d.ts.map +1 -1
  637. package/node_modules/@earendil-works/pi-ai/dist/providers/all.js +10 -0
  638. package/node_modules/@earendil-works/pi-ai/dist/providers/all.js.map +1 -1
  639. package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.d.ts.map +1 -1
  640. package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.js +3 -2
  641. package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.js.map +1 -1
  642. package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.models.d.ts +3 -439
  643. package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.models.d.ts.map +1 -1
  644. package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.models.js +2 -1
  645. package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.models.js.map +1 -1
  646. package/node_modules/@earendil-works/pi-ai/dist/providers/ant-ling.models.d.ts +3 -15
  647. package/node_modules/@earendil-works/pi-ai/dist/providers/ant-ling.models.d.ts.map +1 -1
  648. package/node_modules/@earendil-works/pi-ai/dist/providers/ant-ling.models.js +2 -1
  649. package/node_modules/@earendil-works/pi-ai/dist/providers/ant-ling.models.js.map +1 -1
  650. package/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.d.ts.map +1 -1
  651. package/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.js +30 -3
  652. package/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.js.map +1 -1
  653. package/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.models.d.ts +3 -59
  654. package/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.models.d.ts.map +1 -1
  655. package/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.models.js +2 -1
  656. package/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.models.js.map +1 -1
  657. package/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.models.d.ts +3 -187
  658. package/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.models.d.ts.map +1 -1
  659. package/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.models.js +2 -1
  660. package/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.models.js.map +1 -1
  661. package/node_modules/@earendil-works/pi-ai/dist/providers/cerebras.models.d.ts +3 -15
  662. package/node_modules/@earendil-works/pi-ai/dist/providers/cerebras.models.d.ts.map +1 -1
  663. package/node_modules/@earendil-works/pi-ai/dist/providers/cerebras.models.js +2 -1
  664. package/node_modules/@earendil-works/pi-ai/dist/providers/cerebras.models.js.map +1 -1
  665. package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-ai-gateway.models.d.ts +3 -171
  666. package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-ai-gateway.models.d.ts.map +1 -1
  667. package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-ai-gateway.models.js +2 -1
  668. package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-ai-gateway.models.js.map +1 -1
  669. package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-workers-ai.models.d.ts +3 -55
  670. package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-workers-ai.models.d.ts.map +1 -1
  671. package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-workers-ai.models.js +2 -1
  672. package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-workers-ai.models.js.map +1 -1
  673. package/node_modules/@earendil-works/pi-ai/dist/providers/data/.manifest.json +1 -0
  674. package/node_modules/@earendil-works/pi-ai/dist/providers/data/alibaba-token-plan.json +1 -1
  675. package/node_modules/@earendil-works/pi-ai/dist/providers/data/amazon-bedrock.json +1 -1
  676. package/node_modules/@earendil-works/pi-ai/dist/providers/data/ant-ling.json +1 -1
  677. package/node_modules/@earendil-works/pi-ai/dist/providers/data/anthropic.json +1 -1
  678. package/node_modules/@earendil-works/pi-ai/dist/providers/data/azure-openai-responses.json +1 -1
  679. package/node_modules/@earendil-works/pi-ai/dist/providers/data/cerebras.json +1 -1
  680. package/node_modules/@earendil-works/pi-ai/dist/providers/data/cloudflare-ai-gateway.json +1 -1
  681. package/node_modules/@earendil-works/pi-ai/dist/providers/data/cloudflare-workers-ai.json +1 -1
  682. package/node_modules/@earendil-works/pi-ai/dist/providers/data/deepseek.json +1 -1
  683. package/node_modules/@earendil-works/pi-ai/dist/providers/data/fireworks.json +1 -1
  684. package/node_modules/@earendil-works/pi-ai/dist/providers/data/github-copilot.json +1 -1
  685. package/node_modules/@earendil-works/pi-ai/dist/providers/data/google-vertex.json +1 -1
  686. package/node_modules/@earendil-works/pi-ai/dist/providers/data/google.json +1 -1
  687. package/node_modules/@earendil-works/pi-ai/dist/providers/data/groq.json +1 -1
  688. package/node_modules/@earendil-works/pi-ai/dist/providers/data/huggingface.json +1 -1
  689. package/node_modules/@earendil-works/pi-ai/dist/providers/data/kimi-coding.json +1 -1
  690. package/node_modules/@earendil-works/pi-ai/dist/providers/data/minimax-cn.json +1 -1
  691. package/node_modules/@earendil-works/pi-ai/dist/providers/data/minimax.json +1 -1
  692. package/node_modules/@earendil-works/pi-ai/dist/providers/data/mistral.json +1 -1
  693. package/node_modules/@earendil-works/pi-ai/dist/providers/data/moonshotai-cn.json +1 -1
  694. package/node_modules/@earendil-works/pi-ai/dist/providers/data/moonshotai.json +1 -1
  695. package/node_modules/@earendil-works/pi-ai/dist/providers/data/nvidia.json +1 -1
  696. package/node_modules/@earendil-works/pi-ai/dist/providers/data/openai-codex.json +1 -1
  697. package/node_modules/@earendil-works/pi-ai/dist/providers/data/openai.json +1 -1
  698. package/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode-go.json +1 -1
  699. package/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode.json +1 -1
  700. package/node_modules/@earendil-works/pi-ai/dist/providers/data/openrouter.json +1 -1
  701. package/node_modules/@earendil-works/pi-ai/dist/providers/data/qwen-token-plan-cn.json +1 -0
  702. package/node_modules/@earendil-works/pi-ai/dist/providers/data/qwen-token-plan.json +1 -0
  703. package/node_modules/@earendil-works/pi-ai/dist/providers/data/together.json +1 -1
  704. package/node_modules/@earendil-works/pi-ai/dist/providers/data/vercel-ai-gateway.json +1 -1
  705. package/node_modules/@earendil-works/pi-ai/dist/providers/data/xai.json +1 -1
  706. package/node_modules/@earendil-works/pi-ai/dist/providers/data/xiaomi-token-plan-ams.json +1 -1
  707. package/node_modules/@earendil-works/pi-ai/dist/providers/data/xiaomi-token-plan-cn.json +1 -1
  708. package/node_modules/@earendil-works/pi-ai/dist/providers/data/xiaomi-token-plan-sgp.json +1 -1
  709. package/node_modules/@earendil-works/pi-ai/dist/providers/data/xiaomi.json +1 -1
  710. package/node_modules/@earendil-works/pi-ai/dist/providers/data/zai-coding-cn.json +1 -1
  711. package/node_modules/@earendil-works/pi-ai/dist/providers/data/zai.json +1 -1
  712. package/node_modules/@earendil-works/pi-ai/dist/providers/deepseek.models.d.ts +3 -11
  713. package/node_modules/@earendil-works/pi-ai/dist/providers/deepseek.models.d.ts.map +1 -1
  714. package/node_modules/@earendil-works/pi-ai/dist/providers/deepseek.models.js +2 -1
  715. package/node_modules/@earendil-works/pi-ai/dist/providers/deepseek.models.js.map +1 -1
  716. package/node_modules/@earendil-works/pi-ai/dist/providers/fireworks.models.d.ts +3 -67
  717. package/node_modules/@earendil-works/pi-ai/dist/providers/fireworks.models.d.ts.map +1 -1
  718. package/node_modules/@earendil-works/pi-ai/dist/providers/fireworks.models.js +2 -1
  719. package/node_modules/@earendil-works/pi-ai/dist/providers/fireworks.models.js.map +1 -1
  720. package/node_modules/@earendil-works/pi-ai/dist/providers/github-copilot.models.d.ts +3 -115
  721. package/node_modules/@earendil-works/pi-ai/dist/providers/github-copilot.models.d.ts.map +1 -1
  722. package/node_modules/@earendil-works/pi-ai/dist/providers/github-copilot.models.js +2 -1
  723. package/node_modules/@earendil-works/pi-ai/dist/providers/github-copilot.models.js.map +1 -1
  724. package/node_modules/@earendil-works/pi-ai/dist/providers/google-vertex.models.d.ts +3 -51
  725. package/node_modules/@earendil-works/pi-ai/dist/providers/google-vertex.models.d.ts.map +1 -1
  726. package/node_modules/@earendil-works/pi-ai/dist/providers/google-vertex.models.js +2 -1
  727. package/node_modules/@earendil-works/pi-ai/dist/providers/google-vertex.models.js.map +1 -1
  728. package/node_modules/@earendil-works/pi-ai/dist/providers/google.models.d.ts +3 -75
  729. package/node_modules/@earendil-works/pi-ai/dist/providers/google.models.d.ts.map +1 -1
  730. package/node_modules/@earendil-works/pi-ai/dist/providers/google.models.js +2 -1
  731. package/node_modules/@earendil-works/pi-ai/dist/providers/google.models.js.map +1 -1
  732. package/node_modules/@earendil-works/pi-ai/dist/providers/groq.models.d.ts +3 -31
  733. package/node_modules/@earendil-works/pi-ai/dist/providers/groq.models.d.ts.map +1 -1
  734. package/node_modules/@earendil-works/pi-ai/dist/providers/groq.models.js +2 -1
  735. package/node_modules/@earendil-works/pi-ai/dist/providers/groq.models.js.map +1 -1
  736. package/node_modules/@earendil-works/pi-ai/dist/providers/huggingface.models.d.ts +3 -203
  737. package/node_modules/@earendil-works/pi-ai/dist/providers/huggingface.models.d.ts.map +1 -1
  738. package/node_modules/@earendil-works/pi-ai/dist/providers/huggingface.models.js +2 -1
  739. package/node_modules/@earendil-works/pi-ai/dist/providers/huggingface.models.js.map +1 -1
  740. package/node_modules/@earendil-works/pi-ai/dist/providers/images/register-builtins.js +2 -2
  741. package/node_modules/@earendil-works/pi-ai/dist/providers/images/register-builtins.js.map +1 -1
  742. package/node_modules/@earendil-works/pi-ai/dist/providers/kimi-coding.d.ts.map +1 -1
  743. package/node_modules/@earendil-works/pi-ai/dist/providers/kimi-coding.js +10 -2
  744. package/node_modules/@earendil-works/pi-ai/dist/providers/kimi-coding.js.map +1 -1
  745. package/node_modules/@earendil-works/pi-ai/dist/providers/kimi-coding.models.d.ts +3 -19
  746. package/node_modules/@earendil-works/pi-ai/dist/providers/kimi-coding.models.d.ts.map +1 -1
  747. package/node_modules/@earendil-works/pi-ai/dist/providers/kimi-coding.models.js +2 -1
  748. package/node_modules/@earendil-works/pi-ai/dist/providers/kimi-coding.models.js.map +1 -1
  749. package/node_modules/@earendil-works/pi-ai/dist/providers/minimax-cn.models.d.ts +3 -15
  750. package/node_modules/@earendil-works/pi-ai/dist/providers/minimax-cn.models.d.ts.map +1 -1
  751. package/node_modules/@earendil-works/pi-ai/dist/providers/minimax-cn.models.js +2 -1
  752. package/node_modules/@earendil-works/pi-ai/dist/providers/minimax-cn.models.js.map +1 -1
  753. package/node_modules/@earendil-works/pi-ai/dist/providers/minimax.models.d.ts +3 -15
  754. package/node_modules/@earendil-works/pi-ai/dist/providers/minimax.models.d.ts.map +1 -1
  755. package/node_modules/@earendil-works/pi-ai/dist/providers/minimax.models.js +2 -1
  756. package/node_modules/@earendil-works/pi-ai/dist/providers/minimax.models.js.map +1 -1
  757. package/node_modules/@earendil-works/pi-ai/dist/providers/mistral.models.d.ts +3 -123
  758. package/node_modules/@earendil-works/pi-ai/dist/providers/mistral.models.d.ts.map +1 -1
  759. package/node_modules/@earendil-works/pi-ai/dist/providers/mistral.models.js +2 -1
  760. package/node_modules/@earendil-works/pi-ai/dist/providers/mistral.models.js.map +1 -1
  761. package/node_modules/@earendil-works/pi-ai/dist/providers/moonshotai-cn.models.d.ts +3 -43
  762. package/node_modules/@earendil-works/pi-ai/dist/providers/moonshotai-cn.models.d.ts.map +1 -1
  763. package/node_modules/@earendil-works/pi-ai/dist/providers/moonshotai-cn.models.js +2 -1
  764. package/node_modules/@earendil-works/pi-ai/dist/providers/moonshotai-cn.models.js.map +1 -1
  765. package/node_modules/@earendil-works/pi-ai/dist/providers/moonshotai.models.d.ts +3 -43
  766. package/node_modules/@earendil-works/pi-ai/dist/providers/moonshotai.models.d.ts.map +1 -1
  767. package/node_modules/@earendil-works/pi-ai/dist/providers/moonshotai.models.js +2 -1
  768. package/node_modules/@earendil-works/pi-ai/dist/providers/moonshotai.models.js.map +1 -1
  769. package/node_modules/@earendil-works/pi-ai/dist/providers/nvidia.models.d.ts +3 -79
  770. package/node_modules/@earendil-works/pi-ai/dist/providers/nvidia.models.d.ts.map +1 -1
  771. package/node_modules/@earendil-works/pi-ai/dist/providers/nvidia.models.js +2 -1
  772. package/node_modules/@earendil-works/pi-ai/dist/providers/nvidia.models.js.map +1 -1
  773. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-codex.models.d.ts +3 -31
  774. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-codex.models.d.ts.map +1 -1
  775. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-codex.models.js +2 -1
  776. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-codex.models.js.map +1 -1
  777. package/node_modules/@earendil-works/pi-ai/dist/providers/openai.models.d.ts +3 -187
  778. package/node_modules/@earendil-works/pi-ai/dist/providers/openai.models.d.ts.map +1 -1
  779. package/node_modules/@earendil-works/pi-ai/dist/providers/openai.models.js +2 -1
  780. package/node_modules/@earendil-works/pi-ai/dist/providers/openai.models.js.map +1 -1
  781. package/node_modules/@earendil-works/pi-ai/dist/providers/opencode-go.models.d.ts +3 -67
  782. package/node_modules/@earendil-works/pi-ai/dist/providers/opencode-go.models.d.ts.map +1 -1
  783. package/node_modules/@earendil-works/pi-ai/dist/providers/opencode-go.models.js +2 -1
  784. package/node_modules/@earendil-works/pi-ai/dist/providers/opencode-go.models.js.map +1 -1
  785. package/node_modules/@earendil-works/pi-ai/dist/providers/opencode.models.d.ts +3 -227
  786. package/node_modules/@earendil-works/pi-ai/dist/providers/opencode.models.d.ts.map +1 -1
  787. package/node_modules/@earendil-works/pi-ai/dist/providers/opencode.models.js +2 -1
  788. package/node_modules/@earendil-works/pi-ai/dist/providers/opencode.models.js.map +1 -1
  789. package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter-images.d.ts.map +1 -1
  790. package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter-images.js +10 -2
  791. package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter-images.js.map +1 -1
  792. package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.d.ts.map +1 -1
  793. package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.js +10 -2
  794. package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.js.map +1 -1
  795. package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.models.d.ts +3 -1095
  796. package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.models.d.ts.map +1 -1
  797. package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.models.js +2 -1
  798. package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.models.js.map +1 -1
  799. package/node_modules/@earendil-works/pi-ai/dist/providers/qwen-token-plan-cn.d.ts +3 -0
  800. package/node_modules/@earendil-works/pi-ai/dist/providers/qwen-token-plan-cn.d.ts.map +1 -0
  801. package/node_modules/@earendil-works/pi-ai/dist/providers/qwen-token-plan-cn.js +15 -0
  802. package/node_modules/@earendil-works/pi-ai/dist/providers/qwen-token-plan-cn.js.map +1 -0
  803. package/node_modules/@earendil-works/pi-ai/dist/providers/qwen-token-plan-cn.models.d.ts +4 -0
  804. package/node_modules/@earendil-works/pi-ai/dist/providers/qwen-token-plan-cn.models.d.ts.map +1 -0
  805. package/node_modules/@earendil-works/pi-ai/dist/providers/qwen-token-plan-cn.models.js +6 -0
  806. package/node_modules/@earendil-works/pi-ai/dist/providers/qwen-token-plan-cn.models.js.map +1 -0
  807. package/node_modules/@earendil-works/pi-ai/dist/providers/qwen-token-plan.d.ts +3 -0
  808. package/node_modules/@earendil-works/pi-ai/dist/providers/qwen-token-plan.d.ts.map +1 -0
  809. package/node_modules/@earendil-works/pi-ai/dist/providers/qwen-token-plan.js +15 -0
  810. package/node_modules/@earendil-works/pi-ai/dist/providers/qwen-token-plan.js.map +1 -0
  811. package/node_modules/@earendil-works/pi-ai/dist/providers/qwen-token-plan.models.d.ts +4 -0
  812. package/node_modules/@earendil-works/pi-ai/dist/providers/qwen-token-plan.models.d.ts.map +1 -0
  813. package/node_modules/@earendil-works/pi-ai/dist/providers/qwen-token-plan.models.js +6 -0
  814. package/node_modules/@earendil-works/pi-ai/dist/providers/qwen-token-plan.models.js.map +1 -0
  815. package/node_modules/@earendil-works/pi-ai/dist/providers/radius-config.d.ts.map +1 -1
  816. package/node_modules/@earendil-works/pi-ai/dist/providers/radius-config.js +18 -14
  817. package/node_modules/@earendil-works/pi-ai/dist/providers/radius-config.js.map +1 -1
  818. package/node_modules/@earendil-works/pi-ai/dist/providers/together.models.d.ts +3 -67
  819. package/node_modules/@earendil-works/pi-ai/dist/providers/together.models.d.ts.map +1 -1
  820. package/node_modules/@earendil-works/pi-ai/dist/providers/together.models.js +2 -1
  821. package/node_modules/@earendil-works/pi-ai/dist/providers/together.models.js.map +1 -1
  822. package/node_modules/@earendil-works/pi-ai/dist/providers/vercel-ai-gateway.models.d.ts +3 -775
  823. package/node_modules/@earendil-works/pi-ai/dist/providers/vercel-ai-gateway.models.d.ts.map +1 -1
  824. package/node_modules/@earendil-works/pi-ai/dist/providers/vercel-ai-gateway.models.js +2 -1
  825. package/node_modules/@earendil-works/pi-ai/dist/providers/vercel-ai-gateway.models.js.map +1 -1
  826. package/node_modules/@earendil-works/pi-ai/dist/providers/xai.models.d.ts +3 -15
  827. package/node_modules/@earendil-works/pi-ai/dist/providers/xai.models.d.ts.map +1 -1
  828. package/node_modules/@earendil-works/pi-ai/dist/providers/xai.models.js +2 -1
  829. package/node_modules/@earendil-works/pi-ai/dist/providers/xai.models.js.map +1 -1
  830. package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi-token-plan-ams.models.d.ts +3 -15
  831. package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi-token-plan-ams.models.d.ts.map +1 -1
  832. package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi-token-plan-ams.models.js +2 -1
  833. package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi-token-plan-ams.models.js.map +1 -1
  834. package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi-token-plan-cn.models.d.ts +3 -15
  835. package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi-token-plan-cn.models.d.ts.map +1 -1
  836. package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi-token-plan-cn.models.js +2 -1
  837. package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi-token-plan-cn.models.js.map +1 -1
  838. package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi-token-plan-sgp.models.d.ts +3 -15
  839. package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi-token-plan-sgp.models.d.ts.map +1 -1
  840. package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi-token-plan-sgp.models.js +2 -1
  841. package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi-token-plan-sgp.models.js.map +1 -1
  842. package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi.models.d.ts +3 -27
  843. package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi.models.d.ts.map +1 -1
  844. package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi.models.js +2 -1
  845. package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi.models.js.map +1 -1
  846. package/node_modules/@earendil-works/pi-ai/dist/providers/zai-coding-cn.models.d.ts +3 -27
  847. package/node_modules/@earendil-works/pi-ai/dist/providers/zai-coding-cn.models.d.ts.map +1 -1
  848. package/node_modules/@earendil-works/pi-ai/dist/providers/zai-coding-cn.models.js +2 -1
  849. package/node_modules/@earendil-works/pi-ai/dist/providers/zai-coding-cn.models.js.map +1 -1
  850. package/node_modules/@earendil-works/pi-ai/dist/providers/zai.models.d.ts +3 -27
  851. package/node_modules/@earendil-works/pi-ai/dist/providers/zai.models.d.ts.map +1 -1
  852. package/node_modules/@earendil-works/pi-ai/dist/providers/zai.models.js +2 -1
  853. package/node_modules/@earendil-works/pi-ai/dist/providers/zai.models.js.map +1 -1
  854. package/node_modules/@earendil-works/pi-ai/dist/types.d.ts +52 -3
  855. package/node_modules/@earendil-works/pi-ai/dist/types.d.ts.map +1 -1
  856. package/node_modules/@earendil-works/pi-ai/dist/types.js.map +1 -1
  857. package/node_modules/@earendil-works/pi-ai/dist/utils/error-body.d.ts.map +1 -1
  858. package/node_modules/@earendil-works/pi-ai/dist/utils/error-body.js +8 -3
  859. package/node_modules/@earendil-works/pi-ai/dist/utils/error-body.js.map +1 -1
  860. package/node_modules/@earendil-works/pi-ai/dist/utils/openai-codex-auth.d.ts +11 -0
  861. package/node_modules/@earendil-works/pi-ai/dist/utils/openai-codex-auth.d.ts.map +1 -0
  862. package/node_modules/@earendil-works/pi-ai/dist/utils/openai-codex-auth.js +30 -0
  863. package/node_modules/@earendil-works/pi-ai/dist/utils/openai-codex-auth.js.map +1 -0
  864. package/node_modules/@earendil-works/pi-ai/dist/utils/overflow.d.ts +1 -0
  865. package/node_modules/@earendil-works/pi-ai/dist/utils/overflow.d.ts.map +1 -1
  866. package/node_modules/@earendil-works/pi-ai/dist/utils/overflow.js +3 -0
  867. package/node_modules/@earendil-works/pi-ai/dist/utils/overflow.js.map +1 -1
  868. package/node_modules/@earendil-works/pi-ai/dist/utils/provider-retry.d.ts +16 -0
  869. package/node_modules/@earendil-works/pi-ai/dist/utils/provider-retry.d.ts.map +1 -0
  870. package/node_modules/@earendil-works/pi-ai/dist/utils/provider-retry.js +94 -0
  871. package/node_modules/@earendil-works/pi-ai/dist/utils/provider-retry.js.map +1 -0
  872. package/node_modules/@earendil-works/pi-ai/dist/utils/retry.d.ts +41 -0
  873. package/node_modules/@earendil-works/pi-ai/dist/utils/retry.d.ts.map +1 -1
  874. package/node_modules/@earendil-works/pi-ai/dist/utils/retry.js +82 -0
  875. package/node_modules/@earendil-works/pi-ai/dist/utils/retry.js.map +1 -1
  876. package/node_modules/@earendil-works/pi-ai/dist/utils/server-fallback-receipt.d.ts +30 -0
  877. package/node_modules/@earendil-works/pi-ai/dist/utils/server-fallback-receipt.d.ts.map +1 -0
  878. package/node_modules/@earendil-works/pi-ai/dist/utils/server-fallback-receipt.js +70 -0
  879. package/node_modules/@earendil-works/pi-ai/dist/utils/server-fallback-receipt.js.map +1 -0
  880. package/node_modules/@earendil-works/pi-ai/dist/utils/text.d.ts +6 -0
  881. package/node_modules/@earendil-works/pi-ai/dist/utils/text.d.ts.map +1 -0
  882. package/node_modules/@earendil-works/pi-ai/dist/utils/text.js +10 -0
  883. package/node_modules/@earendil-works/pi-ai/dist/utils/text.js.map +1 -0
  884. package/node_modules/@earendil-works/pi-ai/dist/utils/uuid.d.ts +3 -0
  885. package/node_modules/@earendil-works/pi-ai/dist/utils/uuid.d.ts.map +1 -0
  886. package/node_modules/@earendil-works/{pi-agent-core/dist/harness/session → pi-ai/dist/utils}/uuid.js +2 -2
  887. package/node_modules/@earendil-works/pi-ai/dist/utils/uuid.js.map +1 -0
  888. package/node_modules/@earendil-works/pi-ai/package.json +11 -4
  889. package/node_modules/@earendil-works/pi-pty/package.json +1 -1
  890. package/node_modules/@earendil-works/pi-tui/dist/components/editor.d.ts.map +1 -1
  891. package/node_modules/@earendil-works/pi-tui/dist/components/editor.js +31 -22
  892. package/node_modules/@earendil-works/pi-tui/dist/components/editor.js.map +1 -1
  893. package/node_modules/@earendil-works/pi-tui/dist/tui.d.ts.map +1 -1
  894. package/node_modules/@earendil-works/pi-tui/dist/tui.js +2 -0
  895. package/node_modules/@earendil-works/pi-tui/dist/tui.js.map +1 -1
  896. package/node_modules/@earendil-works/pi-tui/package.json +1 -1
  897. package/package.json +7 -10
  898. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/uuid.d.ts +0 -2
  899. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/uuid.d.ts.map +0 -1
  900. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/uuid.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"rpc-types.js","sourceRoot":"","sources":["../../../src/modes/rpc/rpc-types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG","sourcesContent":["/**\n * RPC protocol types for headless operation.\n *\n * Commands are sent as JSON lines on stdin.\n * Responses and events are emitted as JSON lines on stdout.\n */\n\nimport type { AgentMessage, ThinkingLevel } from \"@earendil-works/pi-agent-core\";\nimport type { ImageContent, Model } from \"@earendil-works/pi-ai\";\nimport type { SessionStats } from \"../../core/agent-session.ts\";\nimport type { BashResult } from \"../../core/bash-executor.ts\";\nimport type { CompactionResult } from \"../../core/compaction/index.ts\";\nimport type { SessionEntry, SessionTreeNode } from \"../../core/session-manager.ts\";\nimport type { SourceInfo } from \"../../core/source-info.ts\";\n\n// ============================================================================\n// RPC Commands (stdin)\n// ============================================================================\n\nexport type RpcCommand =\n\t// Prompting\n\t| {\n\t\t\tid?: string;\n\t\t\ttype: \"prompt\";\n\t\t\tmessage: string;\n\t\t\timages?: ImageContent[];\n\t\t\tstreamingBehavior?: \"steer\" | \"followUp\";\n\t\t\tthinkingLevel?: ThinkingLevel;\n\t }\n\t| { id?: string; type: \"steer\"; message: string; images?: ImageContent[] }\n\t| { id?: string; type: \"follow_up\"; message: string; images?: ImageContent[] }\n\t| { id?: string; type: \"abort\" }\n\t| { id?: string; type: \"new_session\"; parentSession?: string }\n\n\t// State\n\t| { id?: string; type: \"get_state\" }\n\n\t// Model\n\t| { id?: string; type: \"set_model\"; provider: string; modelId: string }\n\t| { id?: string; type: \"cycle_model\" }\n\t| { id?: string; type: \"get_available_models\" }\n\n\t// Thinking\n\t| { id?: string; type: \"set_thinking_level\"; level: ThinkingLevel; scope?: \"turn\" }\n\t| { id?: string; type: \"cycle_thinking_level\" }\n\n\t// Queue modes\n\t| { id?: string; type: \"set_steering_mode\"; mode: \"all\" | \"one-at-a-time\" }\n\t| { id?: string; type: \"set_follow_up_mode\"; mode: \"all\" | \"one-at-a-time\" }\n\n\t// Compaction\n\t| { id?: string; type: \"compact\"; customInstructions?: string }\n\t| { id?: string; type: \"set_auto_compaction\"; enabled: boolean }\n\n\t// Retry\n\t| { id?: string; type: \"set_auto_retry\"; enabled: boolean }\n\t| { id?: string; type: \"abort_retry\" }\n\n\t// Bash\n\t| { id?: string; type: \"bash\"; command: string; excludeFromContext?: boolean }\n\t| { id?: string; type: \"abort_bash\" }\n\n\t// Session\n\t| { id?: string; type: \"get_session_stats\" }\n\t| { id?: string; type: \"export_html\"; outputPath?: string }\n\t| { id?: string; type: \"switch_session\"; sessionPath: string }\n\t| { id?: string; type: \"fork\"; entryId: string }\n\t| { id?: string; type: \"clone\" }\n\t| { id?: string; type: \"get_fork_messages\" }\n\t| { id?: string; type: \"get_entries\"; since?: string }\n\t| { id?: string; type: \"get_tree\" }\n\t| { id?: string; type: \"get_last_assistant_text\" }\n\t| { id?: string; type: \"set_session_name\"; name: string }\n\n\t// Messages\n\t| { id?: string; type: \"get_messages\" }\n\n\t// Commands (available for invocation via prompt)\n\t| { id?: string; type: \"get_commands\" }\n\n\t// Auth (task 13) is additive. get_auth_providers, login_api_key and logout\n\t// answer synchronously. login_start responds immediately (flow-started) and\n\t// completion is delivered via auth_login_url / auth_login_end EVENTS, because\n\t// an interactive OAuth round-trip cannot fit the 30s request timeout.\n\t| { id?: string; type: \"get_auth_providers\" }\n\t| { id?: string; type: \"login_start\"; provider: string }\n\t| { id?: string; type: \"login_cancel\"; provider: string }\n\t| { id?: string; type: \"login_api_key\"; provider: string; key: string }\n\t| { id?: string; type: \"logout\"; provider: string };\n\n// ============================================================================\n// Auth provider info (get_auth_providers response)\n// ============================================================================\n\n/** One provider row for the /login and /logout selectors. */\nexport interface RpcAuthProvider {\n\t/** Provider id (e.g. \"anthropic\", \"openai\"). */\n\tid: string;\n\t/** Human-readable display name. */\n\tname: string;\n\t/** How this provider authenticates. */\n\tauthType: \"oauth\" | \"api_key\";\n\t/** Auth status without exposing or refreshing any credential. */\n\tstatus: RpcAuthStatus;\n}\n\n/** Auth status mirror (no credential values), from getProviderAuthStatus. */\nexport interface RpcAuthStatus {\n\tconfigured: boolean;\n\tsource?: \"stored\" | \"runtime\" | \"environment\" | \"fallback\" | \"models_json_key\" | \"models_json_command\";\n\tlabel?: string;\n}\n\n// ============================================================================\n// RPC Slash Command (for get_commands response)\n// ============================================================================\n\n/** A command available for invocation via prompt */\nexport interface RpcSlashCommand {\n\t/** Command name (without leading slash) */\n\tname: string;\n\t/** Human-readable description */\n\tdescription?: string;\n\t/** What kind of command this is */\n\tsource: \"extension\" | \"prompt\" | \"skill\";\n\t/** Source metadata for the owning resource */\n\tsourceInfo: SourceInfo;\n}\n\n// ============================================================================\n// RPC State\n// ============================================================================\n\nexport interface RpcSessionState {\n\tmodel?: Model<any>;\n\tthinkingLevel: ThinkingLevel;\n\tisStreaming: boolean;\n\tisCompacting: boolean;\n\tsteeringMode: \"all\" | \"one-at-a-time\";\n\tfollowUpMode: \"all\" | \"one-at-a-time\";\n\tsessionFile?: string;\n\tsessionId: string;\n\tsessionName?: string;\n\tautoCompactionEnabled: boolean;\n\tmessageCount: number;\n\tpendingMessageCount: number;\n}\n\n// ============================================================================\n// RPC Responses (stdout)\n// ============================================================================\n\n// Success responses with data\nexport type RpcResponse =\n\t// Prompting (async - events follow)\n\t| { id?: string; type: \"response\"; command: \"prompt\"; success: true }\n\t| { id?: string; type: \"response\"; command: \"steer\"; success: true }\n\t| { id?: string; type: \"response\"; command: \"follow_up\"; success: true }\n\t| { id?: string; type: \"response\"; command: \"abort\"; success: true }\n\t| { id?: string; type: \"response\"; command: \"new_session\"; success: true; data: { cancelled: boolean } }\n\n\t// State\n\t| { id?: string; type: \"response\"; command: \"get_state\"; success: true; data: RpcSessionState }\n\n\t// Model\n\t| {\n\t\t\tid?: string;\n\t\t\ttype: \"response\";\n\t\t\tcommand: \"set_model\";\n\t\t\tsuccess: true;\n\t\t\tdata: Model<any>;\n\t }\n\t| {\n\t\t\tid?: string;\n\t\t\ttype: \"response\";\n\t\t\tcommand: \"cycle_model\";\n\t\t\tsuccess: true;\n\t\t\tdata: { model: Model<any>; thinkingLevel: ThinkingLevel; isScoped: boolean } | null;\n\t }\n\t| {\n\t\t\tid?: string;\n\t\t\ttype: \"response\";\n\t\t\tcommand: \"get_available_models\";\n\t\t\tsuccess: true;\n\t\t\tdata: { models: Array<Model<any> & { supportedThinkingLevels: ThinkingLevel[] }> };\n\t }\n\n\t// Thinking\n\t| { id?: string; type: \"response\"; command: \"set_thinking_level\"; success: true }\n\t| {\n\t\t\tid?: string;\n\t\t\ttype: \"response\";\n\t\t\tcommand: \"cycle_thinking_level\";\n\t\t\tsuccess: true;\n\t\t\tdata: { level: ThinkingLevel } | null;\n\t }\n\n\t// Queue modes\n\t| { id?: string; type: \"response\"; command: \"set_steering_mode\"; success: true }\n\t| { id?: string; type: \"response\"; command: \"set_follow_up_mode\"; success: true }\n\n\t// Compaction\n\t| { id?: string; type: \"response\"; command: \"compact\"; success: true; data: CompactionResult }\n\t| { id?: string; type: \"response\"; command: \"set_auto_compaction\"; success: true }\n\n\t// Retry\n\t| { id?: string; type: \"response\"; command: \"set_auto_retry\"; success: true }\n\t| { id?: string; type: \"response\"; command: \"abort_retry\"; success: true }\n\n\t// Bash\n\t| { id?: string; type: \"response\"; command: \"bash\"; success: true; data: BashResult }\n\t| { id?: string; type: \"response\"; command: \"abort_bash\"; success: true }\n\n\t// Session\n\t| { id?: string; type: \"response\"; command: \"get_session_stats\"; success: true; data: SessionStats }\n\t| { id?: string; type: \"response\"; command: \"export_html\"; success: true; data: { path: string } }\n\t| { id?: string; type: \"response\"; command: \"switch_session\"; success: true; data: { cancelled: boolean } }\n\t| { id?: string; type: \"response\"; command: \"fork\"; success: true; data: { text: string; cancelled: boolean } }\n\t| { id?: string; type: \"response\"; command: \"clone\"; success: true; data: { cancelled: boolean } }\n\t| {\n\t\t\tid?: string;\n\t\t\ttype: \"response\";\n\t\t\tcommand: \"get_fork_messages\";\n\t\t\tsuccess: true;\n\t\t\tdata: { messages: Array<{ entryId: string; text: string }> };\n\t }\n\t| {\n\t\t\tid?: string;\n\t\t\ttype: \"response\";\n\t\t\tcommand: \"get_entries\";\n\t\t\tsuccess: true;\n\t\t\tdata: { entries: SessionEntry[]; leafId: string | null };\n\t }\n\t| {\n\t\t\tid?: string;\n\t\t\ttype: \"response\";\n\t\t\tcommand: \"get_tree\";\n\t\t\tsuccess: true;\n\t\t\tdata: { tree: SessionTreeNode[]; leafId: string | null };\n\t }\n\t| {\n\t\t\tid?: string;\n\t\t\ttype: \"response\";\n\t\t\tcommand: \"get_last_assistant_text\";\n\t\t\tsuccess: true;\n\t\t\tdata: { text: string | null };\n\t }\n\t| { id?: string; type: \"response\"; command: \"set_session_name\"; success: true }\n\n\t// Messages\n\t| { id?: string; type: \"response\"; command: \"get_messages\"; success: true; data: { messages: AgentMessage[] } }\n\n\t// Commands\n\t| {\n\t\t\tid?: string;\n\t\t\ttype: \"response\";\n\t\t\tcommand: \"get_commands\";\n\t\t\tsuccess: true;\n\t\t\tdata: { commands: RpcSlashCommand[] };\n\t }\n\n\t// Auth (task 13)\n\t| {\n\t\t\tid?: string;\n\t\t\ttype: \"response\";\n\t\t\tcommand: \"get_auth_providers\";\n\t\t\tsuccess: true;\n\t\t\tdata: { providers: RpcAuthProvider[] };\n\t }\n\t// login_start returns immediately: success:true means the flow has started.\n\t// The URL and completion arrive as auth_login_url / auth_login_end events.\n\t| { id?: string; type: \"response\"; command: \"login_start\"; success: true }\n\t| { id?: string; type: \"response\"; command: \"login_cancel\"; success: true }\n\t| { id?: string; type: \"response\"; command: \"login_api_key\"; success: true }\n\t| { id?: string; type: \"response\"; command: \"logout\"; success: true }\n\n\t// Error response (any command can fail)\n\t| { id?: string; type: \"response\"; command: string; success: false; error: string };\n\n// ============================================================================\n// Extension UI Events (stdout)\n// ============================================================================\n\n/** Emitted when an extension needs user input */\nexport type RpcExtensionUIRequest =\n\t| { type: \"extension_ui_request\"; id: string; method: \"select\"; title: string; options: string[]; timeout?: number }\n\t| { type: \"extension_ui_request\"; id: string; method: \"confirm\"; title: string; message: string; timeout?: number }\n\t| {\n\t\t\ttype: \"extension_ui_request\";\n\t\t\tid: string;\n\t\t\tmethod: \"input\";\n\t\t\ttitle: string;\n\t\t\tplaceholder?: string;\n\t\t\ttimeout?: number;\n\t }\n\t| { type: \"extension_ui_request\"; id: string; method: \"editor\"; title: string; prefill?: string }\n\t| {\n\t\t\ttype: \"extension_ui_request\";\n\t\t\tid: string;\n\t\t\tmethod: \"notify\";\n\t\t\tmessage: string;\n\t\t\tnotifyType?: \"info\" | \"warning\" | \"error\";\n\t }\n\t| {\n\t\t\ttype: \"extension_ui_request\";\n\t\t\tid: string;\n\t\t\tmethod: \"setStatus\";\n\t\t\tstatusKey: string;\n\t\t\tstatusText: string | undefined;\n\t }\n\t| {\n\t\t\ttype: \"extension_ui_request\";\n\t\t\tid: string;\n\t\t\tmethod: \"setWidget\";\n\t\t\twidgetKey: string;\n\t\t\twidgetLines: string[] | undefined;\n\t\t\twidgetPlacement?: \"aboveEditor\" | \"belowEditor\";\n\t }\n\t| { type: \"extension_ui_request\"; id: string; method: \"setTitle\"; title: string }\n\t| { type: \"extension_ui_request\"; id: string; method: \"set_editor_text\"; text: string }\n\t// Additive (task 13/14): emitted ONLY when the client advertised the\n\t// \"custom_unsupported\" capability. ctx.ui.custom cannot render a third-party\n\t// component in RPC mode, so a flagged client gets this notice before custom()\n\t// returns undefined. Default clients never see it (byte-identical behavior).\n\t| { type: \"extension_ui_request\"; id: string; method: \"custom_unsupported\"; extensionName: string };\n\n// ============================================================================\n// Extension UI Commands (stdin)\n// ============================================================================\n\n/** Response to an extension UI request */\nexport type RpcExtensionUIResponse =\n\t| { type: \"extension_ui_response\"; id: string; value: string }\n\t| { type: \"extension_ui_response\"; id: string; confirmed: boolean }\n\t| { type: \"extension_ui_response\"; id: string; cancelled: true };\n\n/** Emitted when the effective session thinking level changes. */\nexport interface RpcThinkingLevelChangedEvent {\n\ttype: \"thinking_level_changed\";\n\tlevel: ThinkingLevel;\n}\n"]}
1
+ {"version":3,"file":"rpc-types.js","sourceRoot":"","sources":["../../../src/modes/rpc/rpc-types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAsFH,iDAAiD;AACjD,MAAM,CAAC,MAAM,yBAAyB,GAAG,iBAAiB,CAAC;AAC3D,MAAM,CAAC,MAAM,yBAAyB,GAAG,iBAAiB,CAAC;AAC3D,MAAM,CAAC,MAAM,6BAA6B,GAAG,qBAAqB,CAAC;AACnE,MAAM,CAAC,MAAM,4BAA4B,GAAG,oBAAoB,CAAC;AACjE,MAAM,CAAC,MAAM,gCAAgC,GAAG,wBAAwB,CAAC;AACzE,MAAM,CAAC,MAAM,sBAAsB,GAAG,cAAc,CAAC;AACrD,MAAM,CAAC,MAAM,qBAAqB,GAAG,aAAa,CAAC","sourcesContent":["/**\n * RPC protocol types for headless operation.\n *\n * Commands are sent as JSON lines on stdin.\n * Responses and events are emitted as JSON lines on stdout.\n */\n\nimport type { AgentMessage, ThinkingLevel } from \"@earendil-works/pi-agent-core\";\nimport type { ImageContent, Model } from \"@earendil-works/pi-ai\";\nimport type { SessionStats } from \"../../core/agent-session.ts\";\nimport type { BashResult } from \"../../core/bash-executor.ts\";\nimport type { CompactionResult } from \"../../core/compaction/index.ts\";\nimport type { SessionEntry, SessionTreeNode } from \"../../core/session-manager.ts\";\nimport type { SourceInfo } from \"../../core/source-info.ts\";\n\n// ============================================================================\n// RPC Commands (stdin)\n// ============================================================================\n\ntype RpcSessionCommand =\n\t// Prompting\n\t| {\n\t\t\tid?: string;\n\t\t\ttype: \"prompt\";\n\t\t\tmessage: string;\n\t\t\timages?: ImageContent[];\n\t\t\tstreamingBehavior?: \"steer\" | \"followUp\";\n\t\t\tthinkingLevel?: ThinkingLevel;\n\t }\n\t| { id?: string; type: \"steer\"; message: string; images?: ImageContent[] }\n\t| { id?: string; type: \"follow_up\"; message: string; images?: ImageContent[] }\n\t| { id?: string; type: \"abort\" }\n\t| { id?: string; type: \"new_session\"; parentSession?: string }\n\n\t// State\n\t| { id?: string; type: \"get_state\" }\n\n\t// Model\n\t| { id?: string; type: \"set_model\"; provider: string; modelId: string }\n\t| { id?: string; type: \"cycle_model\" }\n\t| { id?: string; type: \"get_available_models\" }\n\n\t// Thinking\n\t| { id?: string; type: \"set_thinking_level\"; level: ThinkingLevel; scope?: \"turn\" }\n\t| { id?: string; type: \"cycle_thinking_level\" }\n\t| { id?: string; type: \"get_available_thinking_levels\" }\n\n\t// Queue modes\n\t| { id?: string; type: \"set_steering_mode\"; mode: \"all\" | \"one-at-a-time\" }\n\t| { id?: string; type: \"set_follow_up_mode\"; mode: \"all\" | \"one-at-a-time\" }\n\n\t// Compaction\n\t| { id?: string; type: \"compact\"; customInstructions?: string }\n\t| { id?: string; type: \"set_auto_compaction\"; enabled: boolean }\n\n\t// Retry\n\t| { id?: string; type: \"set_auto_retry\"; enabled: boolean }\n\t| { id?: string; type: \"abort_retry\" }\n\n\t// Bash\n\t| { id?: string; type: \"bash\"; command: string; excludeFromContext?: boolean }\n\t| { id?: string; type: \"abort_bash\" }\n\n\t// Session\n\t| { id?: string; type: \"get_session_stats\" }\n\t| { id?: string; type: \"export_html\"; outputPath?: string }\n\t| { id?: string; type: \"switch_session\"; sessionPath: string }\n\t| { id?: string; type: \"fork\"; entryId: string }\n\t| { id?: string; type: \"clone\" }\n\t| { id?: string; type: \"get_fork_messages\" }\n\t| { id?: string; type: \"get_entries\"; since?: string }\n\t| { id?: string; type: \"get_tree\" }\n\t| { id?: string; type: \"get_last_assistant_text\" }\n\t| { id?: string; type: \"set_session_name\"; name: string }\n\n\t// Messages\n\t| { id?: string; type: \"get_messages\" }\n\n\t// Commands (available for invocation via prompt)\n\t| { id?: string; type: \"get_commands\" }\n\n\t// Auth (task 13) is additive. get_auth_providers, login_api_key and logout\n\t// answer synchronously. login_start responds immediately (flow-started) and\n\t// completion is delivered via auth_login_url / auth_login_end EVENTS, because\n\t// an interactive OAuth round-trip cannot fit the 30s request timeout.\n\t| { id?: string; type: \"get_auth_providers\" }\n\t| { id?: string; type: \"login_start\"; provider: string }\n\t| { id?: string; type: \"login_cancel\"; provider: string }\n\t| { id?: string; type: \"login_api_key\"; provider: string; key: string }\n\t| { id?: string; type: \"logout\"; provider: string };\n\n/** Stable multi-session protocol error codes. */\nexport const RPC_ERROR_UNKNOWN_SESSION = \"unknown_session\";\nexport const RPC_ERROR_SESSION_CLOSING = \"session_closing\";\nexport const RPC_ERROR_SESSION_PATH_IN_USE = \"session_path_in_use\";\nexport const RPC_ERROR_MISSING_SESSION_ID = \"missing_session_id\";\nexport const RPC_ERROR_MULTI_SESSION_DISABLED = \"multi_session_disabled\";\nexport const RPC_ERROR_INVALID_PATH = \"invalid_path\";\nexport const RPC_ERROR_OPEN_FAILED = \"open_failed\";\n\nexport type RpcErrorCode =\n\t| typeof RPC_ERROR_UNKNOWN_SESSION\n\t| typeof RPC_ERROR_SESSION_CLOSING\n\t| typeof RPC_ERROR_SESSION_PATH_IN_USE\n\t| typeof RPC_ERROR_MISSING_SESSION_ID\n\t| typeof RPC_ERROR_MULTI_SESSION_DISABLED\n\t| typeof RPC_ERROR_INVALID_PATH\n\t| typeof RPC_ERROR_OPEN_FAILED;\n\n/** Every established command accepts an additive routing envelope. */\nexport type RpcCommand =\n\t| (RpcSessionCommand & { sessionId?: string })\n\t| { id?: string; type: \"get_protocol_info\" }\n\t| {\n\t\t\tid?: string;\n\t\t\ttype: \"open_session\";\n\t\t\tsessionPath?: string;\n\t\t\tcwd?: string;\n\t\t\tprovider?: string;\n\t\t\tmodelId?: string;\n\t\t\tthinkingLevel?: ThinkingLevel;\n\t\t\tpermissionPreset?: string;\n\t }\n\t| { id?: string; type: \"close_session\"; sessionId: string }\n\t| { id?: string; type: \"list_sessions\" };\n\n// ============================================================================\n// Auth provider info (get_auth_providers response)\n// ============================================================================\n\n/** One provider row for the /login and /logout selectors. */\nexport interface RpcAuthProvider {\n\t/** Provider id (e.g. \"anthropic\", \"openai\"). */\n\tid: string;\n\t/** Human-readable display name. */\n\tname: string;\n\t/** How this provider authenticates. */\n\tauthType: \"oauth\" | \"api_key\";\n\t/** Auth status without exposing or refreshing any credential. */\n\tstatus: RpcAuthStatus;\n}\n\n/** Auth status mirror (no credential values), from getProviderAuthStatus. */\nexport interface RpcAuthStatus {\n\tconfigured: boolean;\n\tsource?: \"stored\" | \"runtime\" | \"environment\" | \"fallback\" | \"models_json_key\" | \"models_json_command\";\n\tlabel?: string;\n}\n\n// ============================================================================\n// RPC Slash Command (for get_commands response)\n// ============================================================================\n\n/** A command available for invocation via prompt */\nexport interface RpcSlashCommand {\n\t/** Command name (without leading slash) */\n\tname: string;\n\t/** Human-readable description */\n\tdescription?: string;\n\t/** What kind of command this is */\n\tsource: \"extension\" | \"prompt\" | \"skill\";\n\t/** Source metadata for the owning resource */\n\tsourceInfo: SourceInfo;\n}\n\n// ============================================================================\n// RPC State\n// ============================================================================\n\nexport interface RpcSessionState {\n\tmodel?: Model<any>;\n\tthinkingLevel: ThinkingLevel;\n\tisStreaming: boolean;\n\tisCompacting: boolean;\n\tsteeringMode: \"all\" | \"one-at-a-time\";\n\tfollowUpMode: \"all\" | \"one-at-a-time\";\n\tsessionFile?: string;\n\tsessionId: string;\n\tsessionName?: string;\n\tautoCompactionEnabled: boolean;\n\tmessageCount: number;\n\tpendingMessageCount: number;\n}\n\n// ============================================================================\n// RPC Responses (stdout)\n// ============================================================================\n\n// Success responses with data\nexport type RpcResponse =\n\t| {\n\t\t\tid?: string;\n\t\t\ttype: \"response\";\n\t\t\tcommand: \"get_protocol_info\";\n\t\t\tsuccess: true;\n\t\t\tdata: { protocolVersion: 1; capabilities: [\"multi_session\"]; mode: \"classic\" | \"multi\" };\n\t }\n\t| {\n\t\t\tid?: string;\n\t\t\ttype: \"response\";\n\t\t\tcommand: \"open_session\";\n\t\t\tsuccess: true;\n\t\t\tdata: { sessionId: string; state: RpcSessionState };\n\t }\n\t| { id?: string; type: \"response\"; command: \"close_session\"; success: true; data: Record<string, never> }\n\t| {\n\t\t\tid?: string;\n\t\t\ttype: \"response\";\n\t\t\tcommand: \"list_sessions\";\n\t\t\tsuccess: true;\n\t\t\tdata: {\n\t\t\t\tsessions: Array<{\n\t\t\t\t\tsessionId: string;\n\t\t\t\t\tdurableSessionId?: string;\n\t\t\t\t\tsessionPath?: string;\n\t\t\t\t\tcwd: string;\n\t\t\t\t\tname?: string;\n\t\t\t\t\tstatus: \"opening\" | \"open\" | \"closing\" | \"closed\";\n\t\t\t\t}>;\n\t\t\t};\n\t }\n\t// Prompting (async - events follow)\n\t| { id?: string; type: \"response\"; command: \"prompt\"; success: true }\n\t| { id?: string; type: \"response\"; command: \"steer\"; success: true }\n\t| { id?: string; type: \"response\"; command: \"follow_up\"; success: true }\n\t| { id?: string; type: \"response\"; command: \"abort\"; success: true }\n\t| { id?: string; type: \"response\"; command: \"new_session\"; success: true; data: { cancelled: boolean } }\n\n\t// State\n\t| { id?: string; type: \"response\"; command: \"get_state\"; success: true; data: RpcSessionState }\n\n\t// Model\n\t| {\n\t\t\tid?: string;\n\t\t\ttype: \"response\";\n\t\t\tcommand: \"set_model\";\n\t\t\tsuccess: true;\n\t\t\tdata: Model<any>;\n\t }\n\t| {\n\t\t\tid?: string;\n\t\t\ttype: \"response\";\n\t\t\tcommand: \"cycle_model\";\n\t\t\tsuccess: true;\n\t\t\tdata: { model: Model<any>; thinkingLevel: ThinkingLevel; isScoped: boolean } | null;\n\t }\n\t| {\n\t\t\tid?: string;\n\t\t\ttype: \"response\";\n\t\t\tcommand: \"get_available_models\";\n\t\t\tsuccess: true;\n\t\t\tdata: { models: Array<Model<any> & { supportedThinkingLevels: ThinkingLevel[] }> };\n\t }\n\n\t// Thinking\n\t| { id?: string; type: \"response\"; command: \"set_thinking_level\"; success: true }\n\t| {\n\t\t\tid?: string;\n\t\t\ttype: \"response\";\n\t\t\tcommand: \"cycle_thinking_level\";\n\t\t\tsuccess: true;\n\t\t\tdata: { level: ThinkingLevel } | null;\n\t }\n\t| {\n\t\t\tid?: string;\n\t\t\ttype: \"response\";\n\t\t\tcommand: \"get_available_thinking_levels\";\n\t\t\tsuccess: true;\n\t\t\tdata: { levels: ThinkingLevel[] };\n\t }\n\n\t// Queue modes\n\t| { id?: string; type: \"response\"; command: \"set_steering_mode\"; success: true }\n\t| { id?: string; type: \"response\"; command: \"set_follow_up_mode\"; success: true }\n\n\t// Compaction\n\t| { id?: string; type: \"response\"; command: \"compact\"; success: true; data: CompactionResult }\n\t| { id?: string; type: \"response\"; command: \"set_auto_compaction\"; success: true }\n\n\t// Retry\n\t| { id?: string; type: \"response\"; command: \"set_auto_retry\"; success: true }\n\t| { id?: string; type: \"response\"; command: \"abort_retry\"; success: true }\n\n\t// Bash\n\t| { id?: string; type: \"response\"; command: \"bash\"; success: true; data: BashResult }\n\t| { id?: string; type: \"response\"; command: \"abort_bash\"; success: true }\n\n\t// Session\n\t| { id?: string; type: \"response\"; command: \"get_session_stats\"; success: true; data: SessionStats }\n\t| { id?: string; type: \"response\"; command: \"export_html\"; success: true; data: { path: string } }\n\t| { id?: string; type: \"response\"; command: \"switch_session\"; success: true; data: { cancelled: boolean } }\n\t| { id?: string; type: \"response\"; command: \"fork\"; success: true; data: { text: string; cancelled: boolean } }\n\t| { id?: string; type: \"response\"; command: \"clone\"; success: true; data: { cancelled: boolean } }\n\t| {\n\t\t\tid?: string;\n\t\t\ttype: \"response\";\n\t\t\tcommand: \"get_fork_messages\";\n\t\t\tsuccess: true;\n\t\t\tdata: { messages: Array<{ entryId: string; text: string }> };\n\t }\n\t| {\n\t\t\tid?: string;\n\t\t\ttype: \"response\";\n\t\t\tcommand: \"get_entries\";\n\t\t\tsuccess: true;\n\t\t\tdata: { entries: SessionEntry[]; leafId: string | null };\n\t }\n\t| {\n\t\t\tid?: string;\n\t\t\ttype: \"response\";\n\t\t\tcommand: \"get_tree\";\n\t\t\tsuccess: true;\n\t\t\tdata: { tree: SessionTreeNode[]; leafId: string | null };\n\t }\n\t| {\n\t\t\tid?: string;\n\t\t\ttype: \"response\";\n\t\t\tcommand: \"get_last_assistant_text\";\n\t\t\tsuccess: true;\n\t\t\tdata: { text: string | null };\n\t }\n\t| { id?: string; type: \"response\"; command: \"set_session_name\"; success: true }\n\n\t// Messages\n\t| { id?: string; type: \"response\"; command: \"get_messages\"; success: true; data: { messages: AgentMessage[] } }\n\n\t// Commands\n\t| {\n\t\t\tid?: string;\n\t\t\ttype: \"response\";\n\t\t\tcommand: \"get_commands\";\n\t\t\tsuccess: true;\n\t\t\tdata: { commands: RpcSlashCommand[] };\n\t }\n\n\t// Auth (task 13)\n\t| {\n\t\t\tid?: string;\n\t\t\ttype: \"response\";\n\t\t\tcommand: \"get_auth_providers\";\n\t\t\tsuccess: true;\n\t\t\tdata: { providers: RpcAuthProvider[] };\n\t }\n\t// login_start returns immediately: success:true means the flow has started.\n\t// The URL and completion arrive as auth_login_url / auth_login_end events.\n\t| { id?: string; type: \"response\"; command: \"login_start\"; success: true }\n\t| { id?: string; type: \"response\"; command: \"login_cancel\"; success: true }\n\t| { id?: string; type: \"response\"; command: \"login_api_key\"; success: true }\n\t| { id?: string; type: \"response\"; command: \"logout\"; success: true }\n\n\t// Error response (any command can fail)\n\t| { id?: string; type: \"response\"; command: string; success: false; error: string };\n\n// ============================================================================\n// Extension UI Events (stdout)\n// ============================================================================\n\n/** Emitted when an extension needs user input */\nexport type RpcExtensionUIRequest =\n\t| { type: \"extension_ui_request\"; id: string; method: \"select\"; title: string; options: string[]; timeout?: number }\n\t| { type: \"extension_ui_request\"; id: string; method: \"confirm\"; title: string; message: string; timeout?: number }\n\t| {\n\t\t\ttype: \"extension_ui_request\";\n\t\t\tid: string;\n\t\t\tmethod: \"input\";\n\t\t\ttitle: string;\n\t\t\tplaceholder?: string;\n\t\t\ttimeout?: number;\n\t }\n\t| { type: \"extension_ui_request\"; id: string; method: \"editor\"; title: string; prefill?: string }\n\t| {\n\t\t\ttype: \"extension_ui_request\";\n\t\t\tid: string;\n\t\t\tmethod: \"notify\";\n\t\t\tmessage: string;\n\t\t\tnotifyType?: \"info\" | \"warning\" | \"error\";\n\t }\n\t| {\n\t\t\ttype: \"extension_ui_request\";\n\t\t\tid: string;\n\t\t\tmethod: \"setStatus\";\n\t\t\tstatusKey: string;\n\t\t\tstatusText: string | undefined;\n\t }\n\t| {\n\t\t\ttype: \"extension_ui_request\";\n\t\t\tid: string;\n\t\t\tmethod: \"setWidget\";\n\t\t\twidgetKey: string;\n\t\t\twidgetLines: string[] | undefined;\n\t\t\twidgetPlacement?: \"aboveEditor\" | \"belowEditor\";\n\t }\n\t| { type: \"extension_ui_request\"; id: string; method: \"setTitle\"; title: string }\n\t| { type: \"extension_ui_request\"; id: string; method: \"set_editor_text\"; text: string }\n\t// Additive (task 13/14): emitted ONLY when the client advertised the\n\t// \"custom_unsupported\" capability. ctx.ui.custom cannot render a third-party\n\t// component in RPC mode, so a flagged client gets this notice before custom()\n\t// returns undefined. Default clients never see it (byte-identical behavior).\n\t| { type: \"extension_ui_request\"; id: string; method: \"custom_unsupported\"; extensionName: string };\n\n// ============================================================================\n// Extension UI Commands (stdin)\n// ============================================================================\n\n/** Response to an extension UI request */\nexport type RpcExtensionUIResponse =\n\t| { type: \"extension_ui_response\"; id: string; value: string }\n\t| { type: \"extension_ui_response\"; id: string; confirmed: boolean }\n\t| { type: \"extension_ui_response\"; id: string; cancelled: true };\n\n/** Emitted when the effective session thinking level changes. */\nexport interface RpcThinkingLevelChangedEvent {\n\ttype: \"thinking_level_changed\";\n\tlevel: ThinkingLevel;\n}\n"]}
@@ -0,0 +1,13 @@
1
+ import type { SessionEventWriter } from "./session-event-writer.ts";
2
+ import type { RpcSessionEntry } from "./session-registry.ts";
3
+ /** A session-owned adapter around the classic command and extension-UI wiring. */
4
+ export interface RpcSessionBinding {
5
+ handle(command: object): Promise<void>;
6
+ dispose(): Promise<void>;
7
+ }
8
+ /**
9
+ * Creates the extension UI bridge and subscriptions within the entry's provider
10
+ * scope. The classic handler remains the single source of command semantics.
11
+ */
12
+ export declare function createRpcSessionBinding(sessionId: string, entry: RpcSessionEntry, writer: SessionEventWriter, requestClose: () => void): Promise<RpcSessionBinding>;
13
+ //# sourceMappingURL=session-binding.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-binding.d.ts","sourceRoot":"","sources":["../../../src/modes/rpc/session-binding.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D,kFAAkF;AAClF,MAAM,WAAW,iBAAiB;IACjC,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACvC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACzB;AAQD;;;GAGG;AACH,wBAAsB,uBAAuB,CAC5C,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,eAAe,EACtB,MAAM,EAAE,kBAAkB,EAC1B,YAAY,EAAE,MAAM,IAAI,GACtB,OAAO,CAAC,iBAAiB,CAAC,CAkB5B"}
@@ -0,0 +1,33 @@
1
+ import { bindToProviderScope, runWithProviderScope } from "@earendil-works/pi-ai/node/provider-scope";
2
+ import { createRpcConnectionHandler } from "./connection-handler.js";
3
+ function enqueueRecords(writer, sessionId, chunk) {
4
+ for (const line of chunk.split("\n")) {
5
+ if (line)
6
+ writer.enqueue(sessionId, JSON.parse(line));
7
+ }
8
+ }
9
+ /**
10
+ * Creates the extension UI bridge and subscriptions within the entry's provider
11
+ * scope. The classic handler remains the single source of command semantics.
12
+ */
13
+ export async function createRpcSessionBinding(sessionId, entry, writer, requestClose) {
14
+ if (!entry.runtime)
15
+ throw new Error("Session runtime was not created");
16
+ const handler = await runWithProviderScope(entry.scope, async () => {
17
+ const taggedSink = {
18
+ writeRaw: bindToProviderScope((chunk) => enqueueRecords(writer, sessionId, chunk)),
19
+ waitForBackpressure: bindToProviderScope(async () => { }),
20
+ };
21
+ return createRpcConnectionHandler(entry.runtime, taggedSink, {
22
+ sessionId,
23
+ shutdownHandler: bindToProviderScope(requestClose),
24
+ disposeRuntime: false,
25
+ });
26
+ });
27
+ await handler.ready;
28
+ return {
29
+ handle: (command) => runWithProviderScope(entry.scope, () => handler.handleInputLine(JSON.stringify(command))),
30
+ dispose: () => runWithProviderScope(entry.scope, () => handler.dispose()),
31
+ };
32
+ }
33
+ //# sourceMappingURL=session-binding.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-binding.js","sourceRoot":"","sources":["../../../src/modes/rpc/session-binding.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AAEtG,OAAO,EAAE,0BAA0B,EAAqD,MAAM,yBAAyB,CAAC;AAUxH,SAAS,cAAc,CAAC,MAA0B,EAAE,SAAiB,EAAE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AAC,OAAO,EAAE,CAAC;KACzE,CAAC;AACH,CAAC","sourcesContent":["import { bindToProviderScope, runWithProviderScope } from \"@earendil-works/pi-ai/node/provider-scope\";\nimport type { AgentSessionRuntime } from \"../../core/agent-session-runtime.ts\";\nimport { createRpcConnectionHandler, type RpcConnectionHandler, type RpcConnectionSink } from \"./connection-handler.ts\";\nimport type { SessionEventWriter } from \"./session-event-writer.ts\";\nimport type { RpcSessionEntry } from \"./session-registry.ts\";\n\n/** A session-owned adapter around the classic command and extension-UI wiring. */\nexport interface RpcSessionBinding {\n\thandle(command: object): Promise<void>;\n\tdispose(): Promise<void>;\n}\n\nfunction enqueueRecords(writer: SessionEventWriter, sessionId: string, chunk: string): void {\n\tfor (const line of chunk.split(\"\\n\")) {\n\t\tif (line) writer.enqueue(sessionId, JSON.parse(line) as object);\n\t}\n}\n\n/**\n * Creates the extension UI bridge and subscriptions within the entry's provider\n * scope. The classic handler remains the single source of command semantics.\n */\nexport async function createRpcSessionBinding(\n\tsessionId: string,\n\tentry: RpcSessionEntry,\n\twriter: SessionEventWriter,\n\trequestClose: () => void,\n): Promise<RpcSessionBinding> {\n\tif (!entry.runtime) throw new Error(\"Session runtime was not created\");\n\tconst handler: RpcConnectionHandler = await runWithProviderScope(entry.scope, async () => {\n\t\tconst taggedSink: RpcConnectionSink = {\n\t\t\twriteRaw: bindToProviderScope((chunk: string) => enqueueRecords(writer, sessionId, chunk)),\n\t\t\twaitForBackpressure: bindToProviderScope(async () => {}),\n\t\t};\n\t\treturn createRpcConnectionHandler(entry.runtime! as AgentSessionRuntime, taggedSink, {\n\t\t\tsessionId,\n\t\t\tshutdownHandler: bindToProviderScope(requestClose),\n\t\t\tdisposeRuntime: false,\n\t\t});\n\t});\n\tawait handler.ready;\n\treturn {\n\t\thandle: (command) => runWithProviderScope(entry.scope, () => handler.handleInputLine(JSON.stringify(command))),\n\t\tdispose: () => runWithProviderScope(entry.scope, () => handler.dispose()),\n\t};\n}\n"]}
@@ -0,0 +1,19 @@
1
+ import type { RpcCommand, RpcResponse } from "./rpc-types.ts";
2
+ import { createRpcSessionBinding } from "./session-binding.ts";
3
+ import type { SessionEventWriter } from "./session-event-writer.ts";
4
+ import type { RpcSessionLaunchProfile, RpcSessionRegistry } from "./session-registry.ts";
5
+ /** Routes control messages and enforces a routing handle for every session command. */
6
+ export declare class SessionCommandRouter {
7
+ private readonly bindings;
8
+ private readonly registry;
9
+ private readonly writer;
10
+ private readonly defaults;
11
+ private readonly createBinding;
12
+ constructor(registry: RpcSessionRegistry, writer: SessionEventWriter, defaults: Pick<RpcSessionLaunchProfile, "cwd" | "permissionPreset" | "creationModel" | "initialThinkingLevel">, createBinding?: typeof createRpcSessionBinding);
13
+ handle(command: RpcCommand): Promise<RpcResponse | undefined>;
14
+ dispose(): Promise<void>;
15
+ private open;
16
+ private close;
17
+ private code;
18
+ }
19
+ //# sourceMappingURL=session-command-router.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-command-router.d.ts","sourceRoot":"","sources":["../../../src/modes/rpc/session-command-router.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAO9D,OAAO,EAAE,uBAAuB,EAA0B,MAAM,sBAAsB,CAAC;AACvF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,KAAK,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AASzF,uFAAuF;AACvF,qBAAa,oBAAoB;IAChC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAwC;IACjE,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAqB;IAC9C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAqB;IAC5C,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAGvB;IACF,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAiC;IAE/D,YACC,QAAQ,EAAE,kBAAkB,EAC5B,MAAM,EAAE,kBAAkB,EAC1B,QAAQ,EAAE,IAAI,CAAC,uBAAuB,EAAE,KAAK,GAAG,kBAAkB,GAAG,eAAe,GAAG,sBAAsB,CAAC,EAC9G,aAAa,GAAE,OAAO,uBAAiD,EAMvE;IAEK,MAAM,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC,CA6BlE;IAEK,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAiB7B;YAEa,IAAI;YA6DJ,KAAK;IAwBnB,OAAO,CAAC,IAAI;CASZ"}
@@ -0,0 +1,159 @@
1
+ import { RPC_ERROR_MISSING_SESSION_ID, RPC_ERROR_OPEN_FAILED, RPC_ERROR_SESSION_CLOSING, RPC_ERROR_UNKNOWN_SESSION, } from "./rpc-types.js";
2
+ import { createRpcSessionBinding } from "./session-binding.js";
3
+ import { RpcSessionRegistryError } from "./session-registry.js";
4
+ const controls = new Set(["get_protocol_info", "open_session", "close_session", "list_sessions"]);
5
+ function error(id, command, code) {
6
+ return { id, type: "response", command, success: false, error: code };
7
+ }
8
+ /** Routes control messages and enforces a routing handle for every session command. */
9
+ export class SessionCommandRouter {
10
+ constructor(registry, writer, defaults, createBinding = createRpcSessionBinding) {
11
+ this.bindings = new Map();
12
+ this.registry = registry;
13
+ this.writer = writer;
14
+ this.defaults = defaults;
15
+ this.createBinding = createBinding;
16
+ }
17
+ async handle(command) {
18
+ if (command.type === "get_protocol_info") {
19
+ return {
20
+ id: command.id,
21
+ type: "response",
22
+ command: "get_protocol_info",
23
+ success: true,
24
+ data: { protocolVersion: 1, capabilities: ["multi_session"], mode: "multi" },
25
+ };
26
+ }
27
+ if (command.type === "list_sessions")
28
+ return {
29
+ id: command.id,
30
+ type: "response",
31
+ command: "list_sessions",
32
+ success: true,
33
+ data: { sessions: this.registry.list() },
34
+ };
35
+ if (command.type === "open_session")
36
+ return this.open(command);
37
+ if (command.type === "close_session")
38
+ return this.close(command);
39
+ if (controls.has(command.type))
40
+ return undefined;
41
+ if (!command.sessionId)
42
+ return error(command.id, command.type, RPC_ERROR_MISSING_SESSION_ID);
43
+ try {
44
+ this.registry.getForCommand(command.sessionId, command.type);
45
+ await this.bindings.get(command.sessionId)?.handle(command);
46
+ return undefined;
47
+ }
48
+ catch (cause) {
49
+ return error(command.id, command.type, this.code(cause));
50
+ }
51
+ }
52
+ async dispose() {
53
+ await Promise.all([...this.bindings.entries()].map(async ([sessionId, binding]) => {
54
+ try {
55
+ this.registry.beginClose(sessionId);
56
+ }
57
+ catch {
58
+ return;
59
+ }
60
+ try {
61
+ await binding.dispose();
62
+ }
63
+ finally {
64
+ this.bindings.delete(sessionId);
65
+ await this.registry.closeMarked(sessionId);
66
+ }
67
+ }));
68
+ this.bindings.clear();
69
+ }
70
+ async open(command) {
71
+ let opened;
72
+ try {
73
+ opened = await this.registry.openSession({
74
+ cwd: command.cwd ?? this.defaults.cwd,
75
+ sessionPath: command.sessionPath,
76
+ permissionPreset: command.permissionPreset ?? this.defaults.permissionPreset,
77
+ creationModel: command.provider && command.modelId
78
+ ? { provider: command.provider, modelId: command.modelId }
79
+ : this.defaults.creationModel,
80
+ initialThinkingLevel: command.thinkingLevel ?? this.defaults.initialThinkingLevel,
81
+ });
82
+ const openedSession = opened;
83
+ const entry = this.registry.getForCommand(openedSession.sessionId, "open_session");
84
+ this.bindings.set(openedSession.sessionId, await this.createBinding(openedSession.sessionId, entry, this.writer, () => void this.close({ type: "close_session", sessionId: openedSession.sessionId })));
85
+ const state = entry.runtime.session;
86
+ this.writer.enqueue(opened.sessionId, {
87
+ id: command.id,
88
+ type: "response",
89
+ command: "open_session",
90
+ success: true,
91
+ data: {
92
+ sessionId: opened.sessionId,
93
+ state: {
94
+ model: state.model,
95
+ thinkingLevel: state.thinkingLevel,
96
+ isStreaming: state.isStreaming,
97
+ isCompacting: state.isCompacting,
98
+ steeringMode: state.steeringMode,
99
+ followUpMode: state.followUpMode,
100
+ sessionFile: state.sessionFile,
101
+ sessionId: state.sessionId,
102
+ sessionName: state.sessionName,
103
+ autoCompactionEnabled: state.autoCompactionEnabled,
104
+ messageCount: state.messages.length,
105
+ pendingMessageCount: state.pendingMessageCount,
106
+ },
107
+ },
108
+ });
109
+ return undefined;
110
+ }
111
+ catch (cause) {
112
+ if (opened) {
113
+ try {
114
+ await this.registry.close(opened.sessionId);
115
+ }
116
+ catch {
117
+ /* The open rollback has already removed the entry. */
118
+ }
119
+ }
120
+ return error(command.id, "open_session", this.code(cause));
121
+ }
122
+ }
123
+ async close(command) {
124
+ try {
125
+ // This must be the first operation: binding.dispose() awaits teardown and
126
+ // otherwise leaves a window where commands can enter the old handler.
127
+ this.registry.beginClose(command.sessionId);
128
+ try {
129
+ await this.bindings.get(command.sessionId)?.dispose();
130
+ }
131
+ finally {
132
+ this.bindings.delete(command.sessionId);
133
+ await this.registry.closeMarked(command.sessionId);
134
+ }
135
+ this.writer.closeSession(command.sessionId, {
136
+ id: command.id,
137
+ type: "response",
138
+ command: "close_session",
139
+ success: true,
140
+ data: {},
141
+ });
142
+ return undefined;
143
+ }
144
+ catch (cause) {
145
+ return error(command.id, "close_session", this.code(cause));
146
+ }
147
+ }
148
+ code(cause) {
149
+ if (cause instanceof RpcSessionRegistryError)
150
+ return cause.code;
151
+ if (cause instanceof Error && [RPC_ERROR_UNKNOWN_SESSION, RPC_ERROR_SESSION_CLOSING].includes(cause.message)) {
152
+ return cause.message;
153
+ }
154
+ return cause instanceof Error && cause.message
155
+ ? `${RPC_ERROR_OPEN_FAILED}: ${cause.message}`
156
+ : RPC_ERROR_UNKNOWN_SESSION;
157
+ }
158
+ }
159
+ //# sourceMappingURL=session-command-router.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-command-router.js","sourceRoot":"","sources":["../../../src/modes/rpc/session-command-router.ts"],"names":[],"mappings":"AACA,OAAO,EACN,4BAA4B,EAC5B,qBAAqB,EACrB,yBAAyB,EACzB,yBAAyB,GACzB,MAAM,gBAAgB,CAAC;AACxB,OAAO,E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AAyB,EAAE,yBAAyB,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;YAC9G,OAAO,KAAK,CAAC,OAAO,CAAC;QACtB,CAAC;QACD,OAAO,KAAK,YAAY,KAAK,IAAI,KAAK,CAAC,OAAO;YAC7C,CAAC,CAAC,GAAG,qBAAqB,KAAK,KAAK,CAAC,OAAO,EAAE;YAC9C,CAAC,CAAC,yBAAyB,CAAC;IAC9B,CAAC;CACD","sourcesContent":["import type { RpcCommand, RpcResponse } from \"./rpc-types.ts\";\nimport {\n\tRPC_ERROR_MISSING_SESSION_ID,\n\tRPC_ERROR_OPEN_FAILED,\n\tRPC_ERROR_SESSION_CLOSING,\n\tRPC_ERROR_UNKNOWN_SESSION,\n} from \"./rpc-types.ts\";\nimport { createRpcSessionBinding, type RpcSessionBinding } from \"./session-binding.ts\";\nimport type { SessionEventWriter } from \"./session-event-writer.ts\";\nimport type { RpcSessionLaunchProfile, RpcSessionRegistry } from \"./session-registry.ts\";\nimport { RpcSessionRegistryError } from \"./session-registry.ts\";\n\nconst controls = new Set([\"get_protocol_info\", \"open_session\", \"close_session\", \"list_sessions\"]);\n\nfunction error(id: string | undefined, command: string, code: string): RpcResponse {\n\treturn { id, type: \"response\", command, success: false, error: code };\n}\n\n/** Routes control messages and enforces a routing handle for every session command. */\nexport class SessionCommandRouter {\n\tprivate readonly bindings = new Map<string, RpcSessionBinding>();\n\tprivate readonly registry: RpcSessionRegistry;\n\tprivate readonly writer: SessionEventWriter;\n\tprivate readonly defaults: Pick<\n\t\tRpcSessionLaunchProfile,\n\t\t\"cwd\" | \"permissionPreset\" | \"creationModel\" | \"initialThinkingLevel\"\n\t>;\n\tprivate readonly createBinding: typeof createRpcSessionBinding;\n\n\tconstructor(\n\t\tregistry: RpcSessionRegistry,\n\t\twriter: SessionEventWriter,\n\t\tdefaults: Pick<RpcSessionLaunchProfile, \"cwd\" | \"permissionPreset\" | \"creationModel\" | \"initialThinkingLevel\">,\n\t\tcreateBinding: typeof createRpcSessionBinding = createRpcSessionBinding,\n\t) {\n\t\tthis.registry = registry;\n\t\tthis.writer = writer;\n\t\tthis.defaults = defaults;\n\t\tthis.createBinding = createBinding;\n\t}\n\n\tasync handle(command: RpcCommand): Promise<RpcResponse | undefined> {\n\t\tif (command.type === \"get_protocol_info\") {\n\t\t\treturn {\n\t\t\t\tid: command.id,\n\t\t\t\ttype: \"response\",\n\t\t\t\tcommand: \"get_protocol_info\",\n\t\t\t\tsuccess: true,\n\t\t\t\tdata: { protocolVersion: 1, capabilities: [\"multi_session\"], mode: \"multi\" },\n\t\t\t};\n\t\t}\n\t\tif (command.type === \"list_sessions\")\n\t\t\treturn {\n\t\t\t\tid: command.id,\n\t\t\t\ttype: \"response\",\n\t\t\t\tcommand: \"list_sessions\",\n\t\t\t\tsuccess: true,\n\t\t\t\tdata: { sessions: this.registry.list() },\n\t\t\t};\n\t\tif (command.type === \"open_session\") return this.open(command);\n\t\tif (command.type === \"close_session\") return this.close(command);\n\t\tif (controls.has(command.type)) return undefined;\n\t\tif (!command.sessionId) return error(command.id, command.type, RPC_ERROR_MISSING_SESSION_ID);\n\t\ttry {\n\t\t\tthis.registry.getForCommand(command.sessionId, command.type);\n\t\t\tawait this.bindings.get(command.sessionId)?.handle(command);\n\t\t\treturn undefined;\n\t\t} catch (cause) {\n\t\t\treturn error(command.id, command.type, this.code(cause));\n\t\t}\n\t}\n\n\tasync dispose(): Promise<void> {\n\t\tawait Promise.all(\n\t\t\t[...this.bindings.entries()].map(async ([sessionId, binding]) => {\n\t\t\t\ttry {\n\t\t\t\t\tthis.registry.beginClose(sessionId);\n\t\t\t\t} catch {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\ttry {\n\t\t\t\t\tawait binding.dispose();\n\t\t\t\t} finally {\n\t\t\t\t\tthis.bindings.delete(sessionId);\n\t\t\t\t\tawait this.registry.closeMarked(sessionId);\n\t\t\t\t}\n\t\t\t}),\n\t\t);\n\t\tthis.bindings.clear();\n\t}\n\n\tprivate async open(command: Extract<RpcCommand, { type: \"open_session\" }>): Promise<RpcResponse | undefined> {\n\t\tlet opened: { sessionId: string } | undefined;\n\t\ttry {\n\t\t\topened = await this.registry.openSession({\n\t\t\t\tcwd: command.cwd ?? this.defaults.cwd,\n\t\t\t\tsessionPath: command.sessionPath,\n\t\t\t\tpermissionPreset: command.permissionPreset ?? this.defaults.permissionPreset,\n\t\t\t\tcreationModel:\n\t\t\t\t\tcommand.provider && command.modelId\n\t\t\t\t\t\t? { provider: command.provider, modelId: command.modelId }\n\t\t\t\t\t\t: this.defaults.creationModel,\n\t\t\t\tinitialThinkingLevel: command.thinkingLevel ?? this.defaults.initialThinkingLevel,\n\t\t\t});\n\t\t\tconst openedSession = opened;\n\t\t\tconst entry = this.registry.getForCommand(openedSession.sessionId, \"open_session\");\n\t\t\tthis.bindings.set(\n\t\t\t\topenedSession.sessionId,\n\t\t\t\tawait this.createBinding(\n\t\t\t\t\topenedSession.sessionId,\n\t\t\t\t\tentry,\n\t\t\t\t\tthis.writer,\n\t\t\t\t\t() => void this.close({ type: \"close_session\", sessionId: openedSession.sessionId }),\n\t\t\t\t),\n\t\t\t);\n\t\t\tconst state = entry.runtime!.session;\n\t\t\tthis.writer.enqueue(opened.sessionId, {\n\t\t\t\tid: command.id,\n\t\t\t\ttype: \"response\",\n\t\t\t\tcommand: \"open_session\",\n\t\t\t\tsuccess: true,\n\t\t\t\tdata: {\n\t\t\t\t\tsessionId: opened.sessionId,\n\t\t\t\t\tstate: {\n\t\t\t\t\t\tmodel: state.model,\n\t\t\t\t\t\tthinkingLevel: state.thinkingLevel,\n\t\t\t\t\t\tisStreaming: state.isStreaming,\n\t\t\t\t\t\tisCompacting: state.isCompacting,\n\t\t\t\t\t\tsteeringMode: state.steeringMode,\n\t\t\t\t\t\tfollowUpMode: state.followUpMode,\n\t\t\t\t\t\tsessionFile: state.sessionFile,\n\t\t\t\t\t\tsessionId: state.sessionId,\n\t\t\t\t\t\tsessionName: state.sessionName,\n\t\t\t\t\t\tautoCompactionEnabled: state.autoCompactionEnabled,\n\t\t\t\t\t\tmessageCount: state.messages.length,\n\t\t\t\t\t\tpendingMessageCount: state.pendingMessageCount,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t});\n\t\t\treturn undefined;\n\t\t} catch (cause) {\n\t\t\tif (opened) {\n\t\t\t\ttry {\n\t\t\t\t\tawait this.registry.close(opened.sessionId);\n\t\t\t\t} catch {\n\t\t\t\t\t/* The open rollback has already removed the entry. */\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn error(command.id, \"open_session\", this.code(cause));\n\t\t}\n\t}\n\n\tprivate async close(command: Extract<RpcCommand, { type: \"close_session\" }>): Promise<RpcResponse | undefined> {\n\t\ttry {\n\t\t\t// This must be the first operation: binding.dispose() awaits teardown and\n\t\t\t// otherwise leaves a window where commands can enter the old handler.\n\t\t\tthis.registry.beginClose(command.sessionId);\n\t\t\ttry {\n\t\t\t\tawait this.bindings.get(command.sessionId)?.dispose();\n\t\t\t} finally {\n\t\t\t\tthis.bindings.delete(command.sessionId);\n\t\t\t\tawait this.registry.closeMarked(command.sessionId);\n\t\t\t}\n\t\t\tthis.writer.closeSession(command.sessionId, {\n\t\t\t\tid: command.id,\n\t\t\t\ttype: \"response\",\n\t\t\t\tcommand: \"close_session\",\n\t\t\t\tsuccess: true,\n\t\t\t\tdata: {},\n\t\t\t});\n\t\t\treturn undefined;\n\t\t} catch (cause) {\n\t\t\treturn error(command.id, \"close_session\", this.code(cause));\n\t\t}\n\t}\n\n\tprivate code(cause: unknown): string {\n\t\tif (cause instanceof RpcSessionRegistryError) return cause.code;\n\t\tif (cause instanceof Error && [RPC_ERROR_UNKNOWN_SESSION, RPC_ERROR_SESSION_CLOSING].includes(cause.message)) {\n\t\t\treturn cause.message;\n\t\t}\n\t\treturn cause instanceof Error && cause.message\n\t\t\t? `${RPC_ERROR_OPEN_FAILED}: ${cause.message}`\n\t\t\t: RPC_ERROR_UNKNOWN_SESSION;\n\t}\n}\n"]}
@@ -0,0 +1,34 @@
1
+ type RawWriter = (chunk: string) => void;
2
+ type FlushScheduler = (flush: () => void) => void;
3
+ /**
4
+ * Process-wide stdout scheduler for multi-session RPC mode.
5
+ *
6
+ * Each queue contains complete JSONL records for one routing handle. Draining
7
+ * takes one record per queue in round-robin order, so a busy session cannot
8
+ * reorder another ready session's next complete record. A record is deliberately
9
+ * written by itself: coalescing records from different sessions would obscure
10
+ * the scheduling boundary and violate D9.
11
+ */
12
+ export declare class SessionEventWriter {
13
+ private readonly queues;
14
+ private readonly readySessions;
15
+ private readonly sealedSessions;
16
+ private readonly writeRaw;
17
+ private readonly scheduleFlush;
18
+ private flushScheduled;
19
+ private flushing;
20
+ constructor(writeRaw: RawWriter, scheduleFlush?: FlushScheduler);
21
+ /** Queue one session-owned response, event, or extension UI request. */
22
+ enqueue(sessionId: string, value: object): boolean;
23
+ /**
24
+ * Prevent subsequent records for a session and append its terminal response.
25
+ * Existing records retain FIFO order; this response is therefore that
26
+ * session's final stdout record.
27
+ */
28
+ closeSession(sessionId: string, response: object): void;
29
+ /** Synchronously drain all currently complete records in fair queue order. */
30
+ flush(): void;
31
+ private requestFlush;
32
+ }
33
+ export {};
34
+ //# sourceMappingURL=session-event-writer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-event-writer.d.ts","sourceRoot":"","sources":["../../../src/modes/rpc/session-event-writer.ts"],"names":[],"mappings":"AAEA,KAAK,SAAS,GAAG,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;AACzC,KAAK,cAAc,GAAG,CAAC,KAAK,EAAE,MAAM,IAAI,KAAK,IAAI,CAAC;AAElD;;;;;;;;GAQG;AACH,qBAAa,kBAAkB;IAC9B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA+B;IACtD,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAgB;IAC9C,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAqB;IACpD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAY;IACrC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAiB;IAC/C,OAAO,CAAC,cAAc,CAAS;IAC/B,OAAO,CAAC,QAAQ,CAAS;IAEzB,YAAY,QAAQ,EAAE,SAAS,EAAE,aAAa,GAAE,cAA+B,EAG9E;IAED,wEAAwE;IACxE,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAYjD;IAED;;;;OAIG;IACH,YAAY,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAYtD;IAED,8EAA8E;IAC9E,KAAK,IAAI,IAAI,CAuBZ;IAED,OAAO,CAAC,YAAY;CAKpB"}
@@ -0,0 +1,92 @@
1
+ import { serializeJsonLine } from "./jsonl.js";
2
+ /**
3
+ * Process-wide stdout scheduler for multi-session RPC mode.
4
+ *
5
+ * Each queue contains complete JSONL records for one routing handle. Draining
6
+ * takes one record per queue in round-robin order, so a busy session cannot
7
+ * reorder another ready session's next complete record. A record is deliberately
8
+ * written by itself: coalescing records from different sessions would obscure
9
+ * the scheduling boundary and violate D9.
10
+ */
11
+ export class SessionEventWriter {
12
+ constructor(writeRaw, scheduleFlush = queueMicrotask) {
13
+ this.queues = new Map();
14
+ this.readySessions = [];
15
+ this.sealedSessions = new Set();
16
+ this.flushScheduled = false;
17
+ this.flushing = false;
18
+ this.writeRaw = writeRaw;
19
+ this.scheduleFlush = scheduleFlush;
20
+ }
21
+ /** Queue one session-owned response, event, or extension UI request. */
22
+ enqueue(sessionId, value) {
23
+ if (this.sealedSessions.has(sessionId))
24
+ return false;
25
+ const queue = this.queues.get(sessionId);
26
+ const record = serializeJsonLine({ ...value, sessionId });
27
+ if (queue) {
28
+ queue.push(record);
29
+ }
30
+ else {
31
+ this.queues.set(sessionId, [record]);
32
+ this.readySessions.push(sessionId);
33
+ }
34
+ this.requestFlush();
35
+ return true;
36
+ }
37
+ /**
38
+ * Prevent subsequent records for a session and append its terminal response.
39
+ * Existing records retain FIFO order; this response is therefore that
40
+ * session's final stdout record.
41
+ */
42
+ closeSession(sessionId, response) {
43
+ if (this.sealedSessions.has(sessionId))
44
+ return;
45
+ this.sealedSessions.add(sessionId);
46
+ const queue = this.queues.get(sessionId);
47
+ const record = serializeJsonLine({ ...response, sessionId });
48
+ if (queue) {
49
+ queue.push(record);
50
+ }
51
+ else {
52
+ this.queues.set(sessionId, [record]);
53
+ this.readySessions.push(sessionId);
54
+ }
55
+ this.requestFlush();
56
+ }
57
+ /** Synchronously drain all currently complete records in fair queue order. */
58
+ flush() {
59
+ if (this.flushing)
60
+ return;
61
+ this.flushScheduled = false;
62
+ this.flushing = true;
63
+ try {
64
+ while (this.readySessions.length > 0) {
65
+ const sessionId = this.readySessions.shift();
66
+ const queue = this.queues.get(sessionId);
67
+ const record = queue?.shift();
68
+ if (!record)
69
+ continue;
70
+ // Exactly one complete record per write. In particular, records from
71
+ // different sessions must never share a batch.
72
+ this.writeRaw(record);
73
+ if (queue && queue.length > 0) {
74
+ this.readySessions.push(sessionId);
75
+ }
76
+ else {
77
+ this.queues.delete(sessionId);
78
+ }
79
+ }
80
+ }
81
+ finally {
82
+ this.flushing = false;
83
+ }
84
+ }
85
+ requestFlush() {
86
+ if (this.flushScheduled || this.flushing)
87
+ return;
88
+ this.flushScheduled = true;
89
+ this.scheduleFlush(() => this.flush());
90
+ }
91
+ }
92
+ //# sourceMappingURL=session-event-writer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-event-writer.js","sourceRoot":"","sources":["../../../src/modes/rpc/session-event-writer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAK/C;;;;;;;;GAQG;AACH,MAAM,OAAO,kBAAkB;IAS9B,YAAY,QAAmB,EAAE,aAAa,GAAmB,cAAc;QAR9D,WAAM,GAAG,IAAI,GAAG,EAAoB,CAAC;QACrC,kBAAa,GAAa,EAAE,CAA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AE,OAAO;QACjD,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;QAC3B,IAAI,CAAC,aAAa,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;IACxC,CAAC;CACD","sourcesContent":["import { serializeJsonLine } from \"./jsonl.ts\";\n\ntype RawWriter = (chunk: string) => void;\ntype FlushScheduler = (flush: () => void) => void;\n\n/**\n * Process-wide stdout scheduler for multi-session RPC mode.\n *\n * Each queue contains complete JSONL records for one routing handle. Draining\n * takes one record per queue in round-robin order, so a busy session cannot\n * reorder another ready session's next complete record. A record is deliberately\n * written by itself: coalescing records from different sessions would obscure\n * the scheduling boundary and violate D9.\n */\nexport class SessionEventWriter {\n\tprivate readonly queues = new Map<string, string[]>();\n\tprivate readonly readySessions: string[] = [];\n\tprivate readonly sealedSessions = new Set<string>();\n\tprivate readonly writeRaw: RawWriter;\n\tprivate readonly scheduleFlush: FlushScheduler;\n\tprivate flushScheduled = false;\n\tprivate flushing = false;\n\n\tconstructor(writeRaw: RawWriter, scheduleFlush: FlushScheduler = queueMicrotask) {\n\t\tthis.writeRaw = writeRaw;\n\t\tthis.scheduleFlush = scheduleFlush;\n\t}\n\n\t/** Queue one session-owned response, event, or extension UI request. */\n\tenqueue(sessionId: string, value: object): boolean {\n\t\tif (this.sealedSessions.has(sessionId)) return false;\n\t\tconst queue = this.queues.get(sessionId);\n\t\tconst record = serializeJsonLine({ ...value, sessionId });\n\t\tif (queue) {\n\t\t\tqueue.push(record);\n\t\t} else {\n\t\t\tthis.queues.set(sessionId, [record]);\n\t\t\tthis.readySessions.push(sessionId);\n\t\t}\n\t\tthis.requestFlush();\n\t\treturn true;\n\t}\n\n\t/**\n\t * Prevent subsequent records for a session and append its terminal response.\n\t * Existing records retain FIFO order; this response is therefore that\n\t * session's final stdout record.\n\t */\n\tcloseSession(sessionId: string, response: object): void {\n\t\tif (this.sealedSessions.has(sessionId)) return;\n\t\tthis.sealedSessions.add(sessionId);\n\t\tconst queue = this.queues.get(sessionId);\n\t\tconst record = serializeJsonLine({ ...response, sessionId });\n\t\tif (queue) {\n\t\t\tqueue.push(record);\n\t\t} else {\n\t\t\tthis.queues.set(sessionId, [record]);\n\t\t\tthis.readySessions.push(sessionId);\n\t\t}\n\t\tthis.requestFlush();\n\t}\n\n\t/** Synchronously drain all currently complete records in fair queue order. */\n\tflush(): void {\n\t\tif (this.flushing) return;\n\t\tthis.flushScheduled = false;\n\t\tthis.flushing = true;\n\t\ttry {\n\t\t\twhile (this.readySessions.length > 0) {\n\t\t\t\tconst sessionId = this.readySessions.shift()!;\n\t\t\t\tconst queue = this.queues.get(sessionId);\n\t\t\t\tconst record = queue?.shift();\n\t\t\t\tif (!record) continue;\n\n\t\t\t\t// Exactly one complete record per write. In particular, records from\n\t\t\t\t// different sessions must never share a batch.\n\t\t\t\tthis.writeRaw(record);\n\t\t\t\tif (queue && queue.length > 0) {\n\t\t\t\t\tthis.readySessions.push(sessionId);\n\t\t\t\t} else {\n\t\t\t\t\tthis.queues.delete(sessionId);\n\t\t\t\t}\n\t\t\t}\n\t\t} finally {\n\t\t\tthis.flushing = false;\n\t\t}\n\t}\n\n\tprivate requestFlush(): void {\n\t\tif (this.flushScheduled || this.flushing) return;\n\t\tthis.flushScheduled = true;\n\t\tthis.scheduleFlush(() => this.flush());\n\t}\n}\n"]}
@@ -0,0 +1,15 @@
1
+ import type { RpcExtensionUIResponse } from "./rpc-types.ts";
2
+ type PendingRequest = {
3
+ resolve: (value: RpcExtensionUIResponse) => void;
4
+ reject: (error: Error) => void;
5
+ };
6
+ /** Per-session extension UI request state; never share this map between bindings. */
7
+ export declare class SessionExtensionUiRequests {
8
+ private readonly pending;
9
+ set(id: string, request: PendingRequest): void;
10
+ delete(id: string): void;
11
+ resolve(response: RpcExtensionUIResponse): boolean;
12
+ close(): void;
13
+ }
14
+ export {};
15
+ //# sourceMappingURL=session-extension-ui-requests.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-extension-ui-requests.d.ts","sourceRoot":"","sources":["../../../src/modes/rpc/session-extension-ui-requests.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAE7D,KAAK,cAAc,GAAG;IACrB,OAAO,EAAE,CAAC,KAAK,EAAE,sBAAsB,KAAK,IAAI,CAAC;IACjD,MAAM,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAC/B,CAAC;AAEF,qFAAqF;AACrF,qBAAa,0BAA0B;IACtC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAqC;IAE7D,GAAG,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,GAAG,IAAI,CAE7C;IAED,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAEvB;IAED,OAAO,CAAC,QAAQ,EAAE,sBAAsB,GAAG,OAAO,CAMjD;IAED,KAAK,IAAI,IAAI,CAKZ;CACD"}
@@ -0,0 +1,27 @@
1
+ /** Per-session extension UI request state; never share this map between bindings. */
2
+ export class SessionExtensionUiRequests {
3
+ constructor() {
4
+ this.pending = new Map();
5
+ }
6
+ set(id, request) {
7
+ this.pending.set(id, request);
8
+ }
9
+ delete(id) {
10
+ this.pending.delete(id);
11
+ }
12
+ resolve(response) {
13
+ const request = this.pending.get(response.id);
14
+ if (!request)
15
+ return false;
16
+ this.pending.delete(response.id);
17
+ request.resolve(response);
18
+ return true;
19
+ }
20
+ close() {
21
+ for (const request of this.pending.values()) {
22
+ request.reject(new Error("Extension UI request cancelled: session closed"));
23
+ }
24
+ this.pending.clear();
25
+ }
26
+ }
27
+ //# sourceMappingURL=session-extension-ui-requests.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-extension-ui-requests.js","sourceRoot":"","sources":["../../../src/modes/rpc/session-extension-ui-requests.ts"],"names":[],"mappings":"AAOA,qFAAqF;AACrF,MAAM,OAAO,0BAA0B;IAAvC;QACkB,YAAO,GAAG,IAAI,GAAG,EAA0B,CAAC;IAwB9D,CAAC;IAtBA,GAAG,CAAC,EAAU,EAAE,OAAuB;QACtC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;IAC/B,CAAC;IAED,MAAM,CAAC,EAAU;QAChB,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IACzB,CAAC;IAED,OAAO,CAAC,QAAgC;QACvC,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QAC9C,IAAI,CAAC,OAAO;YAAE,OAAO,KAAK,CAAC;QAC3B,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QACjC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QAC1B,OAAO,IAAI,CAAC;IACb,CAAC;IAED,KAAK;QACJ,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;YAC7C,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC,CAAC;QAC7E,CAAC;QACD,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;IACtB,CAAC;CACD","sourcesContent":["import type { RpcExtensionUIResponse } from \"./rpc-types.ts\";\n\ntype PendingRequest = {\n\tresolve: (value: RpcExtensionUIResponse) => void;\n\treject: (error: Error) => void;\n};\n\n/** Per-session extension UI request state; never share this map between bindings. */\nexport class SessionExtensionUiRequests {\n\tprivate readonly pending = new Map<string, PendingRequest>();\n\n\tset(id: string, request: PendingRequest): void {\n\t\tthis.pending.set(id, request);\n\t}\n\n\tdelete(id: string): void {\n\t\tthis.pending.delete(id);\n\t}\n\n\tresolve(response: RpcExtensionUIResponse): boolean {\n\t\tconst request = this.pending.get(response.id);\n\t\tif (!request) return false;\n\t\tthis.pending.delete(response.id);\n\t\trequest.resolve(response);\n\t\treturn true;\n\t}\n\n\tclose(): void {\n\t\tfor (const request of this.pending.values()) {\n\t\t\trequest.reject(new Error(\"Extension UI request cancelled: session closed\"));\n\t\t}\n\t\tthis.pending.clear();\n\t}\n}\n"]}
@@ -0,0 +1,58 @@
1
+ import { ProviderScope } from "@earendil-works/pi-ai/node/provider-scope";
2
+ import { type AgentSessionLaunchProfile, type AgentSessionRuntime, type CreateAgentSessionRuntimeFactory } from "../../core/agent-session-runtime.ts";
3
+ /** The immutable flags selected when a routing session is opened. */
4
+ export interface RpcSessionLaunchProfile extends AgentSessionLaunchProfile {
5
+ sessionPath?: string;
6
+ }
7
+ export type SessionRuntime = Pick<AgentSessionRuntime, "session" | "dispose">;
8
+ export type RpcSessionState = "opening" | "open" | "closing" | "closed";
9
+ export interface RpcSessionEntry {
10
+ state: RpcSessionState;
11
+ runtime?: SessionRuntime;
12
+ scope: ProviderScope;
13
+ profile: Readonly<RpcSessionLaunchProfile>;
14
+ durableSessionId?: string;
15
+ sessionPath?: string;
16
+ lifecycleMutex: Promise<void>;
17
+ }
18
+ export declare class RpcSessionRegistryError extends Error {
19
+ readonly code: "unknown_session" | "session_closing" | "session_path_in_use" | "invalid_path" | "open_failed";
20
+ constructor(code: RpcSessionRegistryError["code"]);
21
+ }
22
+ export interface RpcSessionRegistryOptions {
23
+ agentDir: string;
24
+ createRuntime: CreateAgentSessionRuntimeFactory;
25
+ }
26
+ export interface OpenRpcSession {
27
+ sessionId: string;
28
+ durableSessionId: string;
29
+ sessionPath?: string;
30
+ }
31
+ /** Process-local lifecycle owner for multi-session RPC runtimes. */
32
+ export declare class RpcSessionRegistry {
33
+ private readonly entries;
34
+ private readonly reservations;
35
+ private nextHandle;
36
+ private readonly options;
37
+ constructor(options: RpcSessionRegistryOptions);
38
+ openSession(profile: RpcSessionLaunchProfile): Promise<OpenRpcSession>;
39
+ getForCommand(handle: string, command: string): RpcSessionEntry;
40
+ /**
41
+ * Starts a close synchronously. Call this before disposing any session-owned
42
+ * binding so a concurrent command cannot reach a half-disposed handler.
43
+ */
44
+ beginClose(handle: string): RpcSessionEntry;
45
+ close(handle: string): Promise<void>;
46
+ /** Completes a close previously made visible by beginClose(). */
47
+ closeMarked(handle: string): Promise<void>;
48
+ list(): Array<{
49
+ sessionId: string;
50
+ durableSessionId?: string;
51
+ sessionPath?: string;
52
+ cwd: string;
53
+ name?: string;
54
+ status: RpcSessionState;
55
+ }>;
56
+ private validateProfile;
57
+ }
58
+ //# sourceMappingURL=session-registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-registry.d.ts","sourceRoot":"","sources":["../../../src/modes/rpc/session-registry.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAwB,MAAM,2CAA2C,CAAC;AAChG,OAAO,EACN,KAAK,yBAAyB,EAC9B,KAAK,mBAAmB,EACxB,KAAK,gCAAgC,EAErC,MAAM,qCAAqC,CAAC;AAG7C,qEAAqE;AACrE,MAAM,WAAW,uBAAwB,SAAQ,yBAAyB;IACzE,WAAW,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,MAAM,cAAc,GAAG,IAAI,CAAC,mBAAmB,EAAE,SAAS,GAAG,SAAS,CAAC,CAAC;AAC9E,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,GAAG,QAAQ,CAAC;AAExE,MAAM,WAAW,eAAe;IAC/B,KAAK,EAAE,eAAe,CAAC;IACvB,OAAO,CAAC,EAAE,cAAc,CAAC;IACzB,KAAK,EAAE,aAAa,CAAC;IACrB,OAAO,EAAE,QAAQ,CAAC,uBAAuB,CAAC,CAAC;IAC3C,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9B;AAED,qBAAa,uBAAwB,SAAQ,KAAK;IACjD,QAAQ,CAAC,IAAI,EAAE,iBAAiB,GAAG,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