@code-yeongyu/senpi 2026.8.1 → 2026.8.3

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 (988) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/README.md +1 -0
  3. package/dist/cli/args.d.ts +2 -0
  4. package/dist/cli/args.d.ts.map +1 -1
  5. package/dist/cli/args.js +27 -0
  6. package/dist/cli/args.js.map +1 -1
  7. package/dist/cli/credential-print.d.ts +23 -0
  8. package/dist/cli/credential-print.d.ts.map +1 -0
  9. package/dist/cli/credential-print.js +116 -0
  10. package/dist/cli/credential-print.js.map +1 -0
  11. package/dist/client/index.d.ts +3 -0
  12. package/dist/client/index.d.ts.map +1 -0
  13. package/dist/client/index.js +3 -0
  14. package/dist/client/index.js.map +1 -0
  15. package/dist/client/remote-session.d.ts +53 -0
  16. package/dist/client/remote-session.d.ts.map +1 -0
  17. package/dist/client/remote-session.js +340 -0
  18. package/dist/client/remote-session.js.map +1 -0
  19. package/dist/client/transcript.d.ts +12 -0
  20. package/dist/client/transcript.d.ts.map +1 -0
  21. package/dist/client/transcript.js +98 -0
  22. package/dist/client/transcript.js.map +1 -0
  23. package/dist/core/agent-session-runtime.d.ts.map +1 -1
  24. package/dist/core/agent-session-runtime.js +3 -0
  25. package/dist/core/agent-session-runtime.js.map +1 -1
  26. package/dist/core/agent-session.d.ts +36 -1
  27. package/dist/core/agent-session.d.ts.map +1 -1
  28. package/dist/core/agent-session.js +325 -41
  29. package/dist/core/agent-session.js.map +1 -1
  30. package/dist/core/auth-storage.d.ts +5 -0
  31. package/dist/core/auth-storage.d.ts.map +1 -1
  32. package/dist/core/auth-storage.js +72 -11
  33. package/dist/core/auth-storage.js.map +1 -1
  34. package/dist/core/dynamic-prompt/verification.d.ts +2 -2
  35. package/dist/core/dynamic-prompt/verification.d.ts.map +1 -1
  36. package/dist/core/dynamic-prompt/verification.js +2 -2
  37. package/dist/core/dynamic-prompt/verification.js.map +1 -1
  38. package/dist/core/extensions/builtin/claude-sdk-oauth/bounded-queue.d.ts +17 -0
  39. package/dist/core/extensions/builtin/claude-sdk-oauth/bounded-queue.d.ts.map +1 -0
  40. package/dist/core/extensions/builtin/claude-sdk-oauth/bounded-queue.js +56 -0
  41. package/dist/core/extensions/builtin/claude-sdk-oauth/bounded-queue.js.map +1 -0
  42. package/dist/core/extensions/builtin/claude-sdk-oauth/sdk-boundary.d.ts +1 -0
  43. package/dist/core/extensions/builtin/claude-sdk-oauth/sdk-boundary.d.ts.map +1 -1
  44. package/dist/core/extensions/builtin/claude-sdk-oauth/sdk-boundary.js.map +1 -1
  45. package/dist/core/extensions/builtin/claude-sdk-oauth/session-binding.d.ts +32 -0
  46. package/dist/core/extensions/builtin/claude-sdk-oauth/session-binding.d.ts.map +1 -0
  47. package/dist/core/extensions/builtin/claude-sdk-oauth/session-binding.js +43 -0
  48. package/dist/core/extensions/builtin/claude-sdk-oauth/session-binding.js.map +1 -0
  49. package/dist/core/extensions/builtin/claude-sdk-oauth/session-commit-boundary.d.ts +18 -0
  50. package/dist/core/extensions/builtin/claude-sdk-oauth/session-commit-boundary.d.ts.map +1 -0
  51. package/dist/core/extensions/builtin/claude-sdk-oauth/session-commit-boundary.js +46 -0
  52. package/dist/core/extensions/builtin/claude-sdk-oauth/session-commit-boundary.js.map +1 -0
  53. package/dist/core/extensions/builtin/claude-sdk-oauth/session-continuity.d.ts +81 -0
  54. package/dist/core/extensions/builtin/claude-sdk-oauth/session-continuity.d.ts.map +1 -0
  55. package/dist/core/extensions/builtin/claude-sdk-oauth/session-continuity.js +127 -0
  56. package/dist/core/extensions/builtin/claude-sdk-oauth/session-continuity.js.map +1 -0
  57. package/dist/core/extensions/builtin/claude-sdk-oauth/session-entry-annotations.d.ts +10 -0
  58. package/dist/core/extensions/builtin/claude-sdk-oauth/session-entry-annotations.d.ts.map +1 -0
  59. package/dist/core/extensions/builtin/claude-sdk-oauth/session-entry-annotations.js +34 -0
  60. package/dist/core/extensions/builtin/claude-sdk-oauth/session-entry-annotations.js.map +1 -0
  61. package/dist/core/extensions/builtin/claude-sdk-oauth/session-observability.d.ts +56 -0
  62. package/dist/core/extensions/builtin/claude-sdk-oauth/session-observability.d.ts.map +1 -0
  63. package/dist/core/extensions/builtin/claude-sdk-oauth/session-observability.js +174 -0
  64. package/dist/core/extensions/builtin/claude-sdk-oauth/session-observability.js.map +1 -0
  65. package/dist/core/extensions/builtin/claude-sdk-oauth/session-reaper.d.ts +24 -0
  66. package/dist/core/extensions/builtin/claude-sdk-oauth/session-reaper.d.ts.map +1 -0
  67. package/dist/core/extensions/builtin/claude-sdk-oauth/session-reaper.js +34 -0
  68. package/dist/core/extensions/builtin/claude-sdk-oauth/session-reaper.js.map +1 -0
  69. package/dist/core/extensions/builtin/claude-sdk-oauth/session-reattach.d.ts +34 -0
  70. package/dist/core/extensions/builtin/claude-sdk-oauth/session-reattach.d.ts.map +1 -0
  71. package/dist/core/extensions/builtin/claude-sdk-oauth/session-reattach.js +85 -0
  72. package/dist/core/extensions/builtin/claude-sdk-oauth/session-reattach.js.map +1 -0
  73. package/dist/core/extensions/builtin/claude-sdk-oauth/session-registry-pump.d.ts +2 -13
  74. package/dist/core/extensions/builtin/claude-sdk-oauth/session-registry-pump.d.ts.map +1 -1
  75. package/dist/core/extensions/builtin/claude-sdk-oauth/session-registry-pump.js +34 -55
  76. package/dist/core/extensions/builtin/claude-sdk-oauth/session-registry-pump.js.map +1 -1
  77. package/dist/core/extensions/builtin/claude-sdk-oauth/session-registry-wiring.d.ts.map +1 -1
  78. package/dist/core/extensions/builtin/claude-sdk-oauth/session-registry-wiring.js +35 -93
  79. package/dist/core/extensions/builtin/claude-sdk-oauth/session-registry-wiring.js.map +1 -1
  80. package/dist/core/extensions/builtin/claude-sdk-oauth/session-registry.d.ts +13 -11
  81. package/dist/core/extensions/builtin/claude-sdk-oauth/session-registry.d.ts.map +1 -1
  82. package/dist/core/extensions/builtin/claude-sdk-oauth/session-registry.js +44 -55
  83. package/dist/core/extensions/builtin/claude-sdk-oauth/session-registry.js.map +1 -1
  84. package/dist/core/extensions/builtin/claude-sdk-oauth/session-stream.d.ts +3 -1
  85. package/dist/core/extensions/builtin/claude-sdk-oauth/session-stream.d.ts.map +1 -1
  86. package/dist/core/extensions/builtin/claude-sdk-oauth/session-stream.js +101 -126
  87. package/dist/core/extensions/builtin/claude-sdk-oauth/session-stream.js.map +1 -1
  88. package/dist/core/extensions/builtin/claude-sdk-oauth/session-sync.d.ts +2 -31
  89. package/dist/core/extensions/builtin/claude-sdk-oauth/session-sync.d.ts.map +1 -1
  90. package/dist/core/extensions/builtin/claude-sdk-oauth/session-sync.js +26 -98
  91. package/dist/core/extensions/builtin/claude-sdk-oauth/session-sync.js.map +1 -1
  92. package/dist/core/extensions/builtin/claude-sdk-oauth/session-turn-claim.d.ts +14 -0
  93. package/dist/core/extensions/builtin/claude-sdk-oauth/session-turn-claim.d.ts.map +1 -0
  94. package/dist/core/extensions/builtin/claude-sdk-oauth/session-turn-claim.js +42 -0
  95. package/dist/core/extensions/builtin/claude-sdk-oauth/session-turn-claim.js.map +1 -0
  96. package/dist/core/extensions/builtin/claude-sdk-oauth/session-turn-types.d.ts +32 -0
  97. package/dist/core/extensions/builtin/claude-sdk-oauth/session-turn-types.d.ts.map +1 -0
  98. package/dist/core/extensions/builtin/claude-sdk-oauth/session-turn-types.js +8 -0
  99. package/dist/core/extensions/builtin/claude-sdk-oauth/session-turn-types.js.map +1 -0
  100. package/dist/core/extensions/builtin/claude-sdk-oauth/stream-events.d.ts +16 -0
  101. package/dist/core/extensions/builtin/claude-sdk-oauth/stream-events.d.ts.map +1 -0
  102. package/dist/core/extensions/builtin/claude-sdk-oauth/stream-events.js +92 -0
  103. package/dist/core/extensions/builtin/claude-sdk-oauth/stream-events.js.map +1 -0
  104. package/dist/core/extensions/builtin/claude-sdk-oauth/stream.d.ts.map +1 -1
  105. package/dist/core/extensions/builtin/claude-sdk-oauth/stream.js +48 -88
  106. package/dist/core/extensions/builtin/claude-sdk-oauth/stream.js.map +1 -1
  107. package/dist/core/extensions/builtin/claude-sdk-oauth/tools.d.ts +1 -0
  108. package/dist/core/extensions/builtin/claude-sdk-oauth/tools.d.ts.map +1 -1
  109. package/dist/core/extensions/builtin/claude-sdk-oauth/tools.js +1 -0
  110. package/dist/core/extensions/builtin/claude-sdk-oauth/tools.js.map +1 -1
  111. package/dist/core/extensions/builtin/compaction/checkpoint-state.d.ts +18 -1
  112. package/dist/core/extensions/builtin/compaction/checkpoint-state.d.ts.map +1 -1
  113. package/dist/core/extensions/builtin/compaction/checkpoint-state.js +32 -0
  114. package/dist/core/extensions/builtin/compaction/checkpoint-state.js.map +1 -1
  115. package/dist/core/extensions/builtin/compaction/deterministic-fallback.d.ts +1 -1
  116. package/dist/core/extensions/builtin/compaction/deterministic-fallback.d.ts.map +1 -1
  117. package/dist/core/extensions/builtin/compaction/deterministic-fallback.js +4 -0
  118. package/dist/core/extensions/builtin/compaction/deterministic-fallback.js.map +1 -1
  119. package/dist/core/extensions/builtin/compaction/idle-retry.d.ts +21 -0
  120. package/dist/core/extensions/builtin/compaction/idle-retry.d.ts.map +1 -0
  121. package/dist/core/extensions/builtin/compaction/idle-retry.js +24 -0
  122. package/dist/core/extensions/builtin/compaction/idle-retry.js.map +1 -0
  123. package/dist/core/extensions/builtin/compaction/index.d.ts.map +1 -1
  124. package/dist/core/extensions/builtin/compaction/index.js +91 -13
  125. package/dist/core/extensions/builtin/compaction/index.js.map +1 -1
  126. package/dist/core/extensions/builtin/compaction/lane-policy.d.ts +71 -0
  127. package/dist/core/extensions/builtin/compaction/lane-policy.d.ts.map +1 -0
  128. package/dist/core/extensions/builtin/compaction/lane-policy.js +94 -0
  129. package/dist/core/extensions/builtin/compaction/lane-policy.js.map +1 -0
  130. package/dist/core/extensions/builtin/compaction/log.d.ts.map +1 -1
  131. package/dist/core/extensions/builtin/compaction/log.js +1 -0
  132. package/dist/core/extensions/builtin/compaction/log.js.map +1 -1
  133. package/dist/core/extensions/builtin/compaction/overflow-retry.d.ts +59 -0
  134. package/dist/core/extensions/builtin/compaction/overflow-retry.d.ts.map +1 -0
  135. package/dist/core/extensions/builtin/compaction/overflow-retry.js +155 -0
  136. package/dist/core/extensions/builtin/compaction/overflow-retry.js.map +1 -0
  137. package/dist/core/extensions/builtin/compaction/speculative.d.ts.map +1 -1
  138. package/dist/core/extensions/builtin/compaction/speculative.js +17 -98
  139. package/dist/core/extensions/builtin/compaction/speculative.js.map +1 -1
  140. package/dist/core/extensions/builtin/compaction/transient-failure.d.ts.map +1 -1
  141. package/dist/core/extensions/builtin/compaction/transient-failure.js +3 -0
  142. package/dist/core/extensions/builtin/compaction/transient-failure.js.map +1 -1
  143. package/dist/core/extensions/builtin/gpt-apply-patch/apply.d.ts +1 -0
  144. package/dist/core/extensions/builtin/gpt-apply-patch/apply.d.ts.map +1 -1
  145. package/dist/core/extensions/builtin/gpt-apply-patch/apply.js +13 -1
  146. package/dist/core/extensions/builtin/gpt-apply-patch/apply.js.map +1 -1
  147. package/dist/core/extensions/builtin/gpt-apply-patch/index.d.ts +1 -1
  148. package/dist/core/extensions/builtin/gpt-apply-patch/index.d.ts.map +1 -1
  149. package/dist/core/extensions/builtin/gpt-apply-patch/index.js +1 -1
  150. package/dist/core/extensions/builtin/gpt-apply-patch/index.js.map +1 -1
  151. package/dist/core/extensions/builtin/gpt-apply-patch/tool.d.ts +1 -0
  152. package/dist/core/extensions/builtin/gpt-apply-patch/tool.d.ts.map +1 -1
  153. package/dist/core/extensions/builtin/gpt-apply-patch/tool.js +23 -5
  154. package/dist/core/extensions/builtin/gpt-apply-patch/tool.js.map +1 -1
  155. package/dist/core/extensions/builtin/loop-guard/detectors.d.ts.map +1 -1
  156. package/dist/core/extensions/builtin/loop-guard/detectors.js +42 -1
  157. package/dist/core/extensions/builtin/loop-guard/detectors.js.map +1 -1
  158. package/dist/core/extensions/builtin/mcp/health.d.ts.map +1 -1
  159. package/dist/core/extensions/builtin/mcp/health.js +2 -1
  160. package/dist/core/extensions/builtin/mcp/health.js.map +1 -1
  161. package/dist/core/extensions/builtin/prompt-preset/gpt-5.6.d.ts +1 -1
  162. package/dist/core/extensions/builtin/prompt-preset/gpt-5.6.d.ts.map +1 -1
  163. package/dist/core/extensions/builtin/prompt-preset/gpt-5.6.js +5 -3
  164. package/dist/core/extensions/builtin/prompt-preset/gpt-5.6.js.map +1 -1
  165. package/dist/core/extensions/builtin/prompt-preset/kimi-k3.d.ts.map +1 -1
  166. package/dist/core/extensions/builtin/prompt-preset/kimi-k3.js +8 -1
  167. package/dist/core/extensions/builtin/prompt-preset/kimi-k3.js.map +1 -1
  168. package/dist/core/extensions/builtin/terminal/tools/context.d.ts +1 -1
  169. package/dist/core/extensions/builtin/terminal/tools/context.d.ts.map +1 -1
  170. package/dist/core/extensions/builtin/terminal/tools/context.js.map +1 -1
  171. package/dist/core/extensions/builtin/terminal/tools/monitor.d.ts.map +1 -1
  172. package/dist/core/extensions/builtin/terminal/tools/monitor.js +1 -0
  173. package/dist/core/extensions/builtin/terminal/tools/monitor.js.map +1 -1
  174. package/dist/core/extensions/builtin/tool-pair-guard/index.d.ts.map +1 -1
  175. package/dist/core/extensions/builtin/tool-pair-guard/index.js +1 -1
  176. package/dist/core/extensions/builtin/tool-pair-guard/index.js.map +1 -1
  177. package/dist/core/extensions/index.d.ts +1 -1
  178. package/dist/core/extensions/index.d.ts.map +1 -1
  179. package/dist/core/extensions/index.js.map +1 -1
  180. package/dist/core/extensions/loader.d.ts.map +1 -1
  181. package/dist/core/extensions/loader.js +14 -18
  182. package/dist/core/extensions/loader.js.map +1 -1
  183. package/dist/core/extensions/runner.d.ts +4 -1
  184. package/dist/core/extensions/runner.d.ts.map +1 -1
  185. package/dist/core/extensions/runner.js +18 -0
  186. package/dist/core/extensions/runner.js.map +1 -1
  187. package/dist/core/extensions/types.d.ts +16 -1
  188. package/dist/core/extensions/types.d.ts.map +1 -1
  189. package/dist/core/extensions/types.js.map +1 -1
  190. package/dist/core/footer-data-provider.d.ts +10 -0
  191. package/dist/core/footer-data-provider.d.ts.map +1 -1
  192. package/dist/core/footer-data-provider.js +1 -1
  193. package/dist/core/footer-data-provider.js.map +1 -1
  194. package/dist/core/keybindings.d.ts +24 -0
  195. package/dist/core/keybindings.d.ts.map +1 -1
  196. package/dist/core/model-registry.d.ts +2 -1
  197. package/dist/core/model-registry.d.ts.map +1 -1
  198. package/dist/core/model-registry.js +3 -0
  199. package/dist/core/model-registry.js.map +1 -1
  200. package/dist/core/model-runtime.d.ts +2 -0
  201. package/dist/core/model-runtime.d.ts.map +1 -1
  202. package/dist/core/model-runtime.js.map +1 -1
  203. package/dist/core/package-manager.d.ts +0 -1
  204. package/dist/core/package-manager.d.ts.map +1 -1
  205. package/dist/core/package-manager.js +18 -34
  206. package/dist/core/package-manager.js.map +1 -1
  207. package/dist/core/pi-manifest.d.ts +9 -0
  208. package/dist/core/pi-manifest.d.ts.map +1 -0
  209. package/dist/core/pi-manifest.js +25 -0
  210. package/dist/core/pi-manifest.js.map +1 -0
  211. package/dist/core/resource-loader.d.ts +15 -0
  212. package/dist/core/resource-loader.d.ts.map +1 -1
  213. package/dist/core/resource-loader.js +55 -6
  214. package/dist/core/resource-loader.js.map +1 -1
  215. package/dist/core/retry-fallback/hint-policy.d.ts +29 -0
  216. package/dist/core/retry-fallback/hint-policy.d.ts.map +1 -0
  217. package/dist/core/retry-fallback/hint-policy.js +54 -0
  218. package/dist/core/retry-fallback/hint-policy.js.map +1 -0
  219. package/dist/core/retry-fallback/probe-scheduler.d.ts +60 -0
  220. package/dist/core/retry-fallback/probe-scheduler.d.ts.map +1 -0
  221. package/dist/core/retry-fallback/probe-scheduler.js +206 -0
  222. package/dist/core/retry-fallback/probe-scheduler.js.map +1 -0
  223. package/dist/core/retry-fallback/settings.d.ts +9 -0
  224. package/dist/core/retry-fallback/settings.d.ts.map +1 -1
  225. package/dist/core/retry-fallback/settings.js +14 -0
  226. package/dist/core/retry-fallback/settings.js.map +1 -1
  227. package/dist/core/settings-manager.d.ts +10 -1
  228. package/dist/core/settings-manager.d.ts.map +1 -1
  229. package/dist/core/settings-manager.js +21 -1
  230. package/dist/core/settings-manager.js.map +1 -1
  231. package/dist/extensions/llama/provider.js +1 -1
  232. package/dist/extensions/llama/provider.js.map +1 -1
  233. package/dist/index.d.ts +2 -2
  234. package/dist/index.d.ts.map +1 -1
  235. package/dist/index.js.map +1 -1
  236. package/dist/main.d.ts.map +1 -1
  237. package/dist/main.js +44 -0
  238. package/dist/main.js.map +1 -1
  239. package/dist/modes/interactive/components/assistant-message.d.ts +5 -2
  240. package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
  241. package/dist/modes/interactive/components/assistant-message.js +16 -4
  242. package/dist/modes/interactive/components/assistant-message.js.map +1 -1
  243. package/dist/modes/interactive/components/continuity-notice.d.ts +21 -0
  244. package/dist/modes/interactive/components/continuity-notice.d.ts.map +1 -0
  245. package/dist/modes/interactive/components/continuity-notice.js +58 -0
  246. package/dist/modes/interactive/components/continuity-notice.js.map +1 -0
  247. package/dist/modes/interactive/components/markdown-transform.d.ts +3 -0
  248. package/dist/modes/interactive/components/markdown-transform.d.ts.map +1 -0
  249. package/dist/modes/interactive/components/markdown-transform.js +19 -0
  250. package/dist/modes/interactive/components/markdown-transform.js.map +1 -0
  251. package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
  252. package/dist/modes/interactive/components/model-selector.js +4 -1
  253. package/dist/modes/interactive/components/model-selector.js.map +1 -1
  254. package/dist/modes/interactive/components/settings-selector.d.ts +6 -2
  255. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  256. package/dist/modes/interactive/components/settings-selector.js +20 -0
  257. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  258. package/dist/modes/interactive/components/user-message.d.ts +3 -1
  259. package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
  260. package/dist/modes/interactive/components/user-message.js +8 -2
  261. package/dist/modes/interactive/components/user-message.js.map +1 -1
  262. package/dist/modes/interactive/help-content.d.ts.map +1 -1
  263. package/dist/modes/interactive/help-content.js +1 -0
  264. package/dist/modes/interactive/help-content.js.map +1 -1
  265. package/dist/modes/interactive/interactive-mode.d.ts +21 -0
  266. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  267. package/dist/modes/interactive/interactive-mode.js +151 -50
  268. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  269. package/dist/modes/interactive/theme/dark.json +1 -0
  270. package/dist/modes/interactive/theme/grok-day.json +1 -0
  271. package/dist/modes/interactive/theme/grok-night.json +1 -0
  272. package/dist/modes/interactive/theme/light.json +1 -0
  273. package/dist/modes/interactive/theme/theme-schema.json +5 -1
  274. package/dist/modes/interactive/theme/theme.d.ts +2 -2
  275. package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  276. package/dist/modes/interactive/theme/theme.js +13 -3
  277. package/dist/modes/interactive/theme/theme.js.map +1 -1
  278. package/dist/modes/rpc/connection-handler.d.ts.map +1 -1
  279. package/dist/modes/rpc/connection-handler.js +13 -0
  280. package/dist/modes/rpc/connection-handler.js.map +1 -1
  281. package/dist/utils/clipboard.d.ts +1 -1
  282. package/dist/utils/clipboard.d.ts.map +1 -1
  283. package/dist/utils/clipboard.js +22 -2
  284. package/dist/utils/clipboard.js.map +1 -1
  285. package/docs/AGENTS.md +1 -6
  286. package/docs/custom-provider.md +10 -3
  287. package/docs/development.md +1 -2
  288. package/docs/extensions.md +24 -1
  289. package/docs/keybindings.md +13 -0
  290. package/docs/mcp.md +63 -4
  291. package/docs/models.md +1 -0
  292. package/docs/providers.md +20 -0
  293. package/docs/release-guide.md +5 -3
  294. package/docs/session-format.md +2 -0
  295. package/docs/settings.md +2 -0
  296. package/docs/skills.md +29 -0
  297. package/docs/themes.md +5 -3
  298. package/docs/usage.md +5 -0
  299. package/examples/extensions/custom-compaction.ts +1 -2
  300. package/examples/extensions/custom-provider-anthropic/index.ts +8 -2
  301. package/examples/extensions/doom-overlay/wad-finder.ts +7 -3
  302. package/examples/extensions/handoff.ts +2 -3
  303. package/examples/extensions/qna.ts +2 -2
  304. package/examples/rpc-extension-ui.ts +11 -2
  305. package/examples/sdk/02-custom-model.ts +1 -2
  306. package/examples/sdk/12-full-control.ts +2 -0
  307. package/node_modules/@code-yeongyu/senpi-codemode/CHANGELOG.md +12 -0
  308. package/node_modules/@code-yeongyu/senpi-codemode/package.json +3 -3
  309. package/node_modules/@earendil-works/pi-agent-core/dist/harness/agent-harness.d.ts +14 -3
  310. package/node_modules/@earendil-works/pi-agent-core/dist/harness/agent-harness.d.ts.map +1 -1
  311. package/node_modules/@earendil-works/pi-agent-core/dist/harness/agent-harness.js +156 -67
  312. package/node_modules/@earendil-works/pi-agent-core/dist/harness/agent-harness.js.map +1 -1
  313. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/array-session-reader.d.ts +3 -0
  314. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/array-session-reader.d.ts.map +1 -0
  315. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/array-session-reader.js +70 -0
  316. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/array-session-reader.js.map +1 -0
  317. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/fork.d.ts +4 -0
  318. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/fork.d.ts.map +1 -0
  319. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/fork.js +22 -0
  320. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/fork.js.map +1 -0
  321. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-store.d.ts +13 -0
  322. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-store.d.ts.map +1 -0
  323. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-store.js +304 -0
  324. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-store.js.map +1 -0
  325. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/keyed-operation-queue.d.ts +17 -0
  326. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/keyed-operation-queue.d.ts.map +1 -0
  327. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/keyed-operation-queue.js +60 -0
  328. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/keyed-operation-queue.js.map +1 -0
  329. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-store.d.ts +6 -0
  330. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-store.d.ts.map +1 -0
  331. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-store.js +107 -0
  332. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-store.js.map +1 -0
  333. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/repository.d.ts +28 -0
  334. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/repository.d.ts.map +1 -0
  335. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/repository.js +61 -0
  336. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/repository.js.map +1 -0
  337. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/search-backend.d.ts +8 -0
  338. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/search-backend.d.ts.map +1 -0
  339. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/search-backend.js +22 -0
  340. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/search-backend.js.map +1 -0
  341. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/session.d.ts +6 -10
  342. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/session.d.ts.map +1 -1
  343. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/session.js +154 -77
  344. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/session.js.map +1 -1
  345. package/node_modules/@earendil-works/pi-agent-core/dist/harness/types.d.ts +49 -23
  346. package/node_modules/@earendil-works/pi-agent-core/dist/harness/types.d.ts.map +1 -1
  347. package/node_modules/@earendil-works/pi-agent-core/dist/harness/types.js.map +1 -1
  348. package/node_modules/@earendil-works/pi-agent-core/dist/index.d.ts +6 -6
  349. package/node_modules/@earendil-works/pi-agent-core/dist/index.d.ts.map +1 -1
  350. package/node_modules/@earendil-works/pi-agent-core/dist/index.js +6 -6
  351. package/node_modules/@earendil-works/pi-agent-core/dist/index.js.map +1 -1
  352. package/node_modules/@earendil-works/pi-agent-core/dist/proxy.js +1 -1
  353. package/node_modules/@earendil-works/pi-agent-core/dist/proxy.js.map +1 -1
  354. package/node_modules/@earendil-works/pi-agent-core/package.json +4 -4
  355. package/node_modules/@earendil-works/pi-ai/README.md +2 -1
  356. package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.d.ts.map +1 -1
  357. package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js +46 -10
  358. package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js.map +1 -1
  359. package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-tool-pairs.d.ts +3 -0
  360. package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-tool-pairs.d.ts.map +1 -0
  361. package/{dist/core/extensions/builtin/tool-pair-guard/sanitize-anthropic-payload.js → node_modules/@earendil-works/pi-ai/dist/api/anthropic-tool-pairs.js} +3 -3
  362. package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-tool-pairs.js.map +1 -0
  363. package/node_modules/@earendil-works/pi-ai/dist/api/azure-openai-responses.d.ts.map +1 -1
  364. package/node_modules/@earendil-works/pi-ai/dist/api/azure-openai-responses.js +5 -1
  365. package/node_modules/@earendil-works/pi-ai/dist/api/azure-openai-responses.js.map +1 -1
  366. package/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.d.ts.map +1 -1
  367. package/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.js +64 -4
  368. package/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.js.map +1 -1
  369. package/node_modules/@earendil-works/pi-ai/dist/api/google-generative-ai.d.ts.map +1 -1
  370. package/node_modules/@earendil-works/pi-ai/dist/api/google-generative-ai.js +12 -2
  371. package/node_modules/@earendil-works/pi-ai/dist/api/google-generative-ai.js.map +1 -1
  372. package/node_modules/@earendil-works/pi-ai/dist/api/google-shared.d.ts.map +1 -1
  373. package/node_modules/@earendil-works/pi-ai/dist/api/google-shared.js +13 -6
  374. package/node_modules/@earendil-works/pi-ai/dist/api/google-shared.js.map +1 -1
  375. package/node_modules/@earendil-works/pi-ai/dist/api/google-vertex.d.ts.map +1 -1
  376. package/node_modules/@earendil-works/pi-ai/dist/api/google-vertex.js +12 -2
  377. package/node_modules/@earendil-works/pi-ai/dist/api/google-vertex.js.map +1 -1
  378. package/node_modules/@earendil-works/pi-ai/dist/api/mistral-conversations.d.ts.map +1 -1
  379. package/node_modules/@earendil-works/pi-ai/dist/api/mistral-conversations.js +19 -10
  380. package/node_modules/@earendil-works/pi-ai/dist/api/mistral-conversations.js.map +1 -1
  381. package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.d.ts.map +1 -1
  382. package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.js +84 -47
  383. package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.js.map +1 -1
  384. package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.d.ts.map +1 -1
  385. package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js +17 -8
  386. package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js.map +1 -1
  387. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.d.ts.map +1 -1
  388. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.js +11 -1
  389. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.js.map +1 -1
  390. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.d.ts.map +1 -1
  391. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.js +7 -3
  392. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.js.map +1 -1
  393. package/node_modules/@earendil-works/pi-ai/dist/api/openrouter-images.js +3 -2
  394. package/node_modules/@earendil-works/pi-ai/dist/api/openrouter-images.js.map +1 -1
  395. package/node_modules/@earendil-works/pi-ai/dist/api/pi-messages.js +2 -2
  396. package/node_modules/@earendil-works/pi-ai/dist/api/pi-messages.js.map +1 -1
  397. package/node_modules/@earendil-works/pi-ai/dist/api/simple-options.d.ts.map +1 -1
  398. package/node_modules/@earendil-works/pi-ai/dist/api/simple-options.js +1 -0
  399. package/node_modules/@earendil-works/pi-ai/dist/api/simple-options.js.map +1 -1
  400. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/openrouter.d.ts +3 -1
  401. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/openrouter.d.ts.map +1 -1
  402. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/openrouter.js +81 -26
  403. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/openrouter.js.map +1 -1
  404. package/node_modules/@earendil-works/pi-ai/dist/auth/resolve.d.ts +2 -0
  405. package/node_modules/@earendil-works/pi-ai/dist/auth/resolve.d.ts.map +1 -1
  406. package/node_modules/@earendil-works/pi-ai/dist/auth/resolve.js +16 -8
  407. package/node_modules/@earendil-works/pi-ai/dist/auth/resolve.js.map +1 -1
  408. package/node_modules/@earendil-works/pi-ai/dist/index.d.ts +1 -0
  409. package/node_modules/@earendil-works/pi-ai/dist/index.d.ts.map +1 -1
  410. package/node_modules/@earendil-works/pi-ai/dist/index.js +1 -0
  411. package/node_modules/@earendil-works/pi-ai/dist/index.js.map +1 -1
  412. package/node_modules/@earendil-works/pi-ai/dist/providers/data/.manifest.json +1 -1
  413. package/node_modules/@earendil-works/pi-ai/dist/providers/data/cloudflare-ai-gateway.json +1 -1
  414. package/node_modules/@earendil-works/pi-ai/dist/providers/data/fireworks.json +1 -1
  415. package/node_modules/@earendil-works/pi-ai/dist/providers/data/github-copilot.json +1 -1
  416. package/node_modules/@earendil-works/pi-ai/dist/providers/data/huggingface.json +1 -1
  417. package/node_modules/@earendil-works/pi-ai/dist/providers/data/mistral.json +1 -1
  418. package/node_modules/@earendil-works/pi-ai/dist/providers/data/openai-codex.json +1 -1
  419. package/node_modules/@earendil-works/pi-ai/dist/providers/data/openai.json +1 -1
  420. package/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode.json +1 -1
  421. package/node_modules/@earendil-works/pi-ai/dist/providers/data/openrouter.json +1 -1
  422. package/node_modules/@earendil-works/pi-ai/dist/providers/data/qwen-token-plan-cn.json +1 -1
  423. package/node_modules/@earendil-works/pi-ai/dist/providers/data/qwen-token-plan.json +1 -1
  424. package/node_modules/@earendil-works/pi-ai/dist/providers/data/together.json +1 -1
  425. package/node_modules/@earendil-works/pi-ai/dist/providers/data/vercel-ai-gateway.json +1 -1
  426. package/node_modules/@earendil-works/pi-ai/dist/providers/data/zai-coding-cn.json +1 -1
  427. package/node_modules/@earendil-works/pi-ai/dist/providers/data/zai.json +1 -1
  428. package/node_modules/@earendil-works/pi-ai/dist/providers/faux.d.ts.map +1 -1
  429. package/node_modules/@earendil-works/pi-ai/dist/providers/faux.js +4 -1
  430. package/node_modules/@earendil-works/pi-ai/dist/providers/faux.js.map +1 -1
  431. package/node_modules/@earendil-works/pi-ai/dist/providers/opencode-go.js +1 -1
  432. package/node_modules/@earendil-works/pi-ai/dist/providers/opencode-go.js.map +1 -1
  433. package/node_modules/@earendil-works/pi-ai/dist/types.d.ts +13 -1
  434. package/node_modules/@earendil-works/pi-ai/dist/types.d.ts.map +1 -1
  435. package/node_modules/@earendil-works/pi-ai/dist/types.js.map +1 -1
  436. package/node_modules/@earendil-works/pi-ai/dist/utils/error-body.d.ts.map +1 -1
  437. package/node_modules/@earendil-works/pi-ai/dist/utils/error-body.js +23 -4
  438. package/node_modules/@earendil-works/pi-ai/dist/utils/error-body.js.map +1 -1
  439. package/node_modules/@earendil-works/pi-ai/dist/utils/prompt-cache-ttl.d.ts.map +1 -1
  440. package/node_modules/@earendil-works/pi-ai/dist/utils/prompt-cache-ttl.js +10 -1
  441. package/node_modules/@earendil-works/pi-ai/dist/utils/prompt-cache-ttl.js.map +1 -1
  442. package/node_modules/@earendil-works/pi-ai/dist/utils/provider-retry.d.ts +3 -0
  443. package/node_modules/@earendil-works/pi-ai/dist/utils/provider-retry.d.ts.map +1 -1
  444. package/node_modules/@earendil-works/pi-ai/dist/utils/provider-retry.js +13 -12
  445. package/node_modules/@earendil-works/pi-ai/dist/utils/provider-retry.js.map +1 -1
  446. package/node_modules/@earendil-works/pi-ai/dist/utils/retry-hint.d.ts +24 -0
  447. package/node_modules/@earendil-works/pi-ai/dist/utils/retry-hint.d.ts.map +1 -0
  448. package/node_modules/@earendil-works/pi-ai/dist/utils/retry-hint.js +233 -0
  449. package/node_modules/@earendil-works/pi-ai/dist/utils/retry-hint.js.map +1 -0
  450. package/node_modules/@earendil-works/pi-ai/package.json +10 -6
  451. package/node_modules/@earendil-works/pi-client/CHANGELOG.md +7 -0
  452. package/node_modules/@earendil-works/pi-client/README.md +64 -0
  453. package/node_modules/@earendil-works/pi-client/dist/client.d.ts +25 -0
  454. package/node_modules/@earendil-works/pi-client/dist/client.d.ts.map +1 -0
  455. package/node_modules/@earendil-works/pi-client/dist/client.js +386 -0
  456. package/node_modules/@earendil-works/pi-client/dist/client.js.map +1 -0
  457. package/node_modules/@earendil-works/pi-client/dist/connection.d.ts +25 -0
  458. package/node_modules/@earendil-works/pi-client/dist/connection.d.ts.map +1 -0
  459. package/node_modules/@earendil-works/pi-client/dist/connection.js +204 -0
  460. package/node_modules/@earendil-works/pi-client/dist/connection.js.map +1 -0
  461. package/node_modules/@earendil-works/pi-client/dist/errors.d.ts +23 -0
  462. package/node_modules/@earendil-works/pi-client/dist/errors.d.ts.map +1 -0
  463. package/node_modules/@earendil-works/pi-client/dist/errors.js +42 -0
  464. package/node_modules/@earendil-works/pi-client/dist/errors.js.map +1 -0
  465. package/node_modules/@earendil-works/pi-client/dist/index.d.ts +6 -0
  466. package/node_modules/@earendil-works/pi-client/dist/index.d.ts.map +1 -0
  467. package/node_modules/@earendil-works/pi-client/dist/index.js +3 -0
  468. package/node_modules/@earendil-works/pi-client/dist/index.js.map +1 -0
  469. package/node_modules/@earendil-works/pi-client/dist/promise.d.ts +8 -0
  470. package/node_modules/@earendil-works/pi-client/dist/promise.d.ts.map +1 -0
  471. package/node_modules/@earendil-works/pi-client/dist/promise.js +11 -0
  472. package/node_modules/@earendil-works/pi-client/dist/promise.js.map +1 -0
  473. package/node_modules/@earendil-works/pi-client/dist/session-handle.d.ts +54 -0
  474. package/node_modules/@earendil-works/pi-client/dist/session-handle.d.ts.map +1 -0
  475. package/node_modules/@earendil-works/pi-client/dist/session-handle.js +50 -0
  476. package/node_modules/@earendil-works/pi-client/dist/session-handle.js.map +1 -0
  477. package/node_modules/@earendil-works/pi-client/dist/state.d.ts +22 -0
  478. package/node_modules/@earendil-works/pi-client/dist/state.d.ts.map +1 -0
  479. package/node_modules/@earendil-works/pi-client/dist/state.js +149 -0
  480. package/node_modules/@earendil-works/pi-client/dist/state.js.map +1 -0
  481. package/node_modules/@earendil-works/pi-client/dist/transport.d.ts +17 -0
  482. package/node_modules/@earendil-works/pi-client/dist/transport.d.ts.map +1 -0
  483. package/node_modules/@earendil-works/pi-client/dist/transport.js +2 -0
  484. package/node_modules/@earendil-works/pi-client/dist/transport.js.map +1 -0
  485. package/node_modules/@earendil-works/pi-client/dist/types.d.ts +23 -0
  486. package/node_modules/@earendil-works/pi-client/dist/types.d.ts.map +1 -0
  487. package/node_modules/@earendil-works/pi-client/dist/types.js +2 -0
  488. package/node_modules/@earendil-works/pi-client/dist/types.js.map +1 -0
  489. package/node_modules/@earendil-works/pi-client/dist/unix.d.ts +8 -0
  490. package/node_modules/@earendil-works/pi-client/dist/unix.d.ts.map +1 -0
  491. package/node_modules/@earendil-works/pi-client/dist/unix.js +151 -0
  492. package/node_modules/@earendil-works/pi-client/dist/unix.js.map +1 -0
  493. package/node_modules/@earendil-works/pi-client/package.json +56 -0
  494. package/node_modules/@earendil-works/pi-protocol/README.md +68 -0
  495. package/node_modules/@earendil-works/pi-protocol/dist/cbor/decoder.d.ts +4 -0
  496. package/node_modules/@earendil-works/pi-protocol/dist/cbor/decoder.d.ts.map +1 -0
  497. package/node_modules/@earendil-works/pi-protocol/dist/cbor/decoder.js +163 -0
  498. package/node_modules/@earendil-works/pi-protocol/dist/cbor/decoder.js.map +1 -0
  499. package/node_modules/@earendil-works/pi-protocol/dist/cbor/encoder.d.ts +4 -0
  500. package/node_modules/@earendil-works/pi-protocol/dist/cbor/encoder.d.ts.map +1 -0
  501. package/node_modules/@earendil-works/pi-protocol/dist/cbor/encoder.js +199 -0
  502. package/node_modules/@earendil-works/pi-protocol/dist/cbor/encoder.js.map +1 -0
  503. package/node_modules/@earendil-works/pi-protocol/dist/cbor/index.d.ts +4 -0
  504. package/node_modules/@earendil-works/pi-protocol/dist/cbor/index.d.ts.map +1 -0
  505. package/node_modules/@earendil-works/pi-protocol/dist/cbor/index.js +4 -0
  506. package/node_modules/@earendil-works/pi-protocol/dist/cbor/index.js.map +1 -0
  507. package/node_modules/@earendil-works/pi-protocol/dist/cbor/options.d.ts +26 -0
  508. package/node_modules/@earendil-works/pi-protocol/dist/cbor/options.d.ts.map +1 -0
  509. package/node_modules/@earendil-works/pi-protocol/dist/cbor/options.js +29 -0
  510. package/node_modules/@earendil-works/pi-protocol/dist/cbor/options.js.map +1 -0
  511. package/node_modules/@earendil-works/pi-protocol/dist/codec.d.ts +29 -0
  512. package/node_modules/@earendil-works/pi-protocol/dist/codec.d.ts.map +1 -0
  513. package/node_modules/@earendil-works/pi-protocol/dist/codec.js +140 -0
  514. package/node_modules/@earendil-works/pi-protocol/dist/codec.js.map +1 -0
  515. package/node_modules/@earendil-works/pi-protocol/dist/framing.d.ts +29 -0
  516. package/node_modules/@earendil-works/pi-protocol/dist/framing.d.ts.map +1 -0
  517. package/node_modules/@earendil-works/pi-protocol/dist/framing.js +152 -0
  518. package/node_modules/@earendil-works/pi-protocol/dist/framing.js.map +1 -0
  519. package/node_modules/@earendil-works/pi-protocol/dist/index.d.ts +5 -0
  520. package/node_modules/@earendil-works/pi-protocol/dist/index.d.ts.map +1 -0
  521. package/node_modules/@earendil-works/pi-protocol/dist/index.js +5 -0
  522. package/node_modules/@earendil-works/pi-protocol/dist/index.js.map +1 -0
  523. package/node_modules/@earendil-works/pi-protocol/dist/schemas.d.ts +13818 -0
  524. package/node_modules/@earendil-works/pi-protocol/dist/schemas.d.ts.map +1 -0
  525. package/node_modules/@earendil-works/pi-protocol/dist/schemas.js +382 -0
  526. package/node_modules/@earendil-works/pi-protocol/dist/schemas.js.map +1 -0
  527. package/node_modules/@earendil-works/pi-protocol/package.json +48 -0
  528. package/node_modules/@earendil-works/pi-pty/package.json +2 -2
  529. package/node_modules/@earendil-works/pi-tui/README.md +77 -14
  530. package/node_modules/@earendil-works/pi-tui/dist/TuiAltScreen.d.ts +83 -0
  531. package/node_modules/@earendil-works/pi-tui/dist/TuiAltScreen.d.ts.map +1 -0
  532. package/node_modules/@earendil-works/pi-tui/dist/TuiAltScreen.js +687 -0
  533. package/node_modules/@earendil-works/pi-tui/dist/TuiAltScreen.js.map +1 -0
  534. package/node_modules/@earendil-works/pi-tui/dist/TuiMainScreen.d.ts +5 -0
  535. package/node_modules/@earendil-works/pi-tui/dist/TuiMainScreen.d.ts.map +1 -0
  536. package/node_modules/@earendil-works/pi-tui/dist/TuiMainScreen.js +5 -0
  537. package/node_modules/@earendil-works/pi-tui/dist/TuiMainScreen.js.map +1 -0
  538. package/node_modules/@earendil-works/pi-tui/dist/components/alt-screen-flash.d.ts +13 -0
  539. package/node_modules/@earendil-works/pi-tui/dist/components/alt-screen-flash.d.ts.map +1 -0
  540. package/node_modules/@earendil-works/pi-tui/dist/components/alt-screen-flash.js +36 -0
  541. package/node_modules/@earendil-works/pi-tui/dist/components/alt-screen-flash.js.map +1 -0
  542. package/node_modules/@earendil-works/pi-tui/dist/components/h-stack.d.ts +7 -0
  543. package/node_modules/@earendil-works/pi-tui/dist/components/h-stack.d.ts.map +1 -0
  544. package/node_modules/@earendil-works/pi-tui/dist/components/h-stack.js +43 -0
  545. package/node_modules/@earendil-works/pi-tui/dist/components/h-stack.js.map +1 -0
  546. package/node_modules/@earendil-works/pi-tui/dist/components/image.d.ts.map +1 -1
  547. package/node_modules/@earendil-works/pi-tui/dist/components/image.js +4 -4
  548. package/node_modules/@earendil-works/pi-tui/dist/components/image.js.map +1 -1
  549. package/node_modules/@earendil-works/pi-tui/dist/components/markdown.d.ts +2 -0
  550. package/node_modules/@earendil-works/pi-tui/dist/components/markdown.d.ts.map +1 -1
  551. package/node_modules/@earendil-works/pi-tui/dist/components/markdown.js +3 -2
  552. package/node_modules/@earendil-works/pi-tui/dist/components/markdown.js.map +1 -1
  553. package/node_modules/@earendil-works/pi-tui/dist/components/scroll-view.d.ts +51 -0
  554. package/node_modules/@earendil-works/pi-tui/dist/components/scroll-view.d.ts.map +1 -0
  555. package/node_modules/@earendil-works/pi-tui/dist/components/scroll-view.js +163 -0
  556. package/node_modules/@earendil-works/pi-tui/dist/components/scroll-view.js.map +1 -0
  557. package/node_modules/@earendil-works/pi-tui/dist/components/settings-list.d.ts.map +1 -1
  558. package/node_modules/@earendil-works/pi-tui/dist/components/settings-list.js +3 -6
  559. package/node_modules/@earendil-works/pi-tui/dist/components/settings-list.js.map +1 -1
  560. package/node_modules/@earendil-works/pi-tui/dist/components/stack.d.ts +32 -0
  561. package/node_modules/@earendil-works/pi-tui/dist/components/stack.d.ts.map +1 -0
  562. package/node_modules/@earendil-works/pi-tui/dist/components/stack.js +109 -0
  563. package/node_modules/@earendil-works/pi-tui/dist/components/stack.js.map +1 -0
  564. package/node_modules/@earendil-works/pi-tui/dist/components/v-stack.d.ts +8 -0
  565. package/node_modules/@earendil-works/pi-tui/dist/components/v-stack.d.ts.map +1 -0
  566. package/node_modules/@earendil-works/pi-tui/dist/components/v-stack.js +21 -0
  567. package/node_modules/@earendil-works/pi-tui/dist/components/v-stack.js.map +1 -0
  568. package/node_modules/@earendil-works/pi-tui/dist/index.d.ts +10 -4
  569. package/node_modules/@earendil-works/pi-tui/dist/index.d.ts.map +1 -1
  570. package/node_modules/@earendil-works/pi-tui/dist/index.js +10 -4
  571. package/node_modules/@earendil-works/pi-tui/dist/index.js.map +1 -1
  572. package/node_modules/@earendil-works/pi-tui/dist/keybindings.d.ts +30 -0
  573. package/node_modules/@earendil-works/pi-tui/dist/keybindings.d.ts.map +1 -1
  574. package/node_modules/@earendil-works/pi-tui/dist/keybindings.js +18 -0
  575. package/node_modules/@earendil-works/pi-tui/dist/keybindings.js.map +1 -1
  576. package/node_modules/@earendil-works/pi-tui/dist/layout-node.d.ts +40 -0
  577. package/node_modules/@earendil-works/pi-tui/dist/layout-node.d.ts.map +1 -0
  578. package/node_modules/@earendil-works/pi-tui/dist/layout-node.js +6 -0
  579. package/node_modules/@earendil-works/pi-tui/dist/layout-node.js.map +1 -0
  580. package/node_modules/@earendil-works/pi-tui/dist/layout.d.ts +40 -0
  581. package/node_modules/@earendil-works/pi-tui/dist/layout.d.ts.map +1 -0
  582. package/node_modules/@earendil-works/pi-tui/dist/layout.js +315 -0
  583. package/node_modules/@earendil-works/pi-tui/dist/layout.js.map +1 -0
  584. package/node_modules/@earendil-works/pi-tui/dist/terminal-image.d.ts +10 -0
  585. package/node_modules/@earendil-works/pi-tui/dist/terminal-image.d.ts.map +1 -1
  586. package/node_modules/@earendil-works/pi-tui/dist/terminal-image.js +61 -3
  587. package/node_modules/@earendil-works/pi-tui/dist/terminal-image.js.map +1 -1
  588. package/node_modules/@earendil-works/pi-tui/dist/terminal-text.d.ts +1 -0
  589. package/node_modules/@earendil-works/pi-tui/dist/terminal-text.d.ts.map +1 -1
  590. package/node_modules/@earendil-works/pi-tui/dist/terminal-text.js +12 -2
  591. package/node_modules/@earendil-works/pi-tui/dist/terminal-text.js.map +1 -1
  592. package/node_modules/@earendil-works/pi-tui/dist/tui.d.ts +36 -16
  593. package/node_modules/@earendil-works/pi-tui/dist/tui.d.ts.map +1 -1
  594. package/node_modules/@earendil-works/pi-tui/dist/tui.js +72 -18
  595. package/node_modules/@earendil-works/pi-tui/dist/tui.js.map +1 -1
  596. package/node_modules/@earendil-works/pi-tui/dist/utils.d.ts +10 -0
  597. package/node_modules/@earendil-works/pi-tui/dist/utils.d.ts.map +1 -1
  598. package/node_modules/@earendil-works/pi-tui/dist/utils.js +95 -4
  599. package/node_modules/@earendil-works/pi-tui/dist/utils.js.map +1 -1
  600. package/node_modules/@earendil-works/pi-tui/package.json +2 -2
  601. package/node_modules/typebox/build/compile/validator.d.mts +3 -11
  602. package/node_modules/typebox/build/compile/validator.mjs +6 -36
  603. package/node_modules/typebox/build/error/errors.d.mts +1 -7
  604. package/node_modules/typebox/build/format/_idna.mjs +36 -6
  605. package/node_modules/typebox/build/format/_puny.mjs +4 -1
  606. package/node_modules/typebox/build/format/uuid.d.mts +2 -2
  607. package/node_modules/typebox/build/format/uuid.mjs +3 -3
  608. package/node_modules/typebox/build/guard/emit.d.mts +0 -4
  609. package/node_modules/typebox/build/guard/emit.mjs +0 -8
  610. package/node_modules/typebox/build/guard/guard.d.mts +5 -9
  611. package/node_modules/typebox/build/guard/guard.mjs +10 -15
  612. package/node_modules/typebox/build/guard/string.mjs +16 -4
  613. package/node_modules/typebox/build/schema/engine/_functions.mjs +34 -15
  614. package/node_modules/typebox/build/schema/engine/boolean.d.mts +3 -3
  615. package/node_modules/typebox/build/schema/engine/boolean.mjs +4 -4
  616. package/node_modules/typebox/build/schema/engine/index.d.mts +0 -1
  617. package/node_modules/typebox/build/schema/engine/index.mjs +0 -1
  618. package/node_modules/typebox/build/schema/engine/schema.mjs +6 -11
  619. package/node_modules/typebox/build/schema/engine/type.mjs +14 -18
  620. package/node_modules/typebox/build/schema/types/dependencies.mjs +1 -1
  621. package/node_modules/typebox/build/schema/types/index.d.mts +0 -1
  622. package/node_modules/typebox/build/schema/types/index.mjs +0 -1
  623. package/node_modules/typebox/build/schema/types/schema.d.mts +1 -1
  624. package/node_modules/typebox/build/schema/types/schema.mjs +2 -2
  625. package/node_modules/typebox/build/system/locale/ar_001.mjs +0 -1
  626. package/node_modules/typebox/build/system/locale/bn_BD.mjs +0 -1
  627. package/node_modules/typebox/build/system/locale/cs_CZ.mjs +0 -1
  628. package/node_modules/typebox/build/system/locale/de_DE.mjs +0 -1
  629. package/node_modules/typebox/build/system/locale/el_GR.mjs +0 -1
  630. package/node_modules/typebox/build/system/locale/en_US.mjs +0 -1
  631. package/node_modules/typebox/build/system/locale/es_419.mjs +0 -1
  632. package/node_modules/typebox/build/system/locale/es_AR.mjs +0 -1
  633. package/node_modules/typebox/build/system/locale/es_ES.mjs +0 -1
  634. package/node_modules/typebox/build/system/locale/es_MX.mjs +0 -1
  635. package/node_modules/typebox/build/system/locale/fa_IR.mjs +0 -1
  636. package/node_modules/typebox/build/system/locale/fil_PH.mjs +0 -1
  637. package/node_modules/typebox/build/system/locale/fr_CA.mjs +0 -1
  638. package/node_modules/typebox/build/system/locale/fr_FR.mjs +0 -1
  639. package/node_modules/typebox/build/system/locale/ha_NG.mjs +0 -1
  640. package/node_modules/typebox/build/system/locale/hi_IN.mjs +0 -1
  641. package/node_modules/typebox/build/system/locale/hu_HU.mjs +0 -1
  642. package/node_modules/typebox/build/system/locale/id_ID.mjs +0 -1
  643. package/node_modules/typebox/build/system/locale/it_IT.mjs +0 -1
  644. package/node_modules/typebox/build/system/locale/ja_JP.mjs +0 -1
  645. package/node_modules/typebox/build/system/locale/ko_KR.mjs +0 -1
  646. package/node_modules/typebox/build/system/locale/ms_MY.mjs +0 -1
  647. package/node_modules/typebox/build/system/locale/nl_NL.mjs +0 -1
  648. package/node_modules/typebox/build/system/locale/pl_PL.mjs +0 -1
  649. package/node_modules/typebox/build/system/locale/pt_BR.mjs +0 -1
  650. package/node_modules/typebox/build/system/locale/pt_PT.mjs +0 -1
  651. package/node_modules/typebox/build/system/locale/ro_RO.mjs +0 -1
  652. package/node_modules/typebox/build/system/locale/ru_RU.mjs +0 -1
  653. package/node_modules/typebox/build/system/locale/sv_SE.mjs +0 -1
  654. package/node_modules/typebox/build/system/locale/sw_TZ.mjs +0 -1
  655. package/node_modules/typebox/build/system/locale/th_TH.mjs +0 -1
  656. package/node_modules/typebox/build/system/locale/tr_TR.mjs +0 -1
  657. package/node_modules/typebox/build/system/locale/uk_UA.mjs +0 -1
  658. package/node_modules/typebox/build/system/locale/ur_PK.mjs +0 -1
  659. package/node_modules/typebox/build/system/locale/vi_VN.mjs +0 -1
  660. package/node_modules/typebox/build/system/locale/yo_NG.mjs +0 -1
  661. package/node_modules/typebox/build/system/locale/zh_Hans.mjs +0 -1
  662. package/node_modules/typebox/build/system/locale/zh_Hant.mjs +0 -1
  663. package/node_modules/typebox/build/system/memory/clone.d.mts +2 -3
  664. package/node_modules/typebox/build/system/memory/clone.mjs +73 -26
  665. package/node_modules/typebox/build/system/settings/settings.d.mts +15 -0
  666. package/node_modules/typebox/build/system/settings/settings.mjs +3 -1
  667. package/node_modules/typebox/build/type/action/_add_immutable.d.mts +11 -0
  668. package/node_modules/typebox/build/type/action/_add_immutable.mjs +11 -0
  669. package/node_modules/typebox/build/type/action/_add_optional.d.mts +11 -0
  670. package/node_modules/typebox/build/type/action/_add_optional.mjs +11 -0
  671. package/node_modules/typebox/build/type/action/_add_readonly.d.mts +11 -0
  672. package/node_modules/typebox/build/type/action/_add_readonly.mjs +11 -0
  673. package/node_modules/typebox/build/type/action/_remove_immutable.d.mts +11 -0
  674. package/node_modules/typebox/build/type/action/_remove_immutable.mjs +11 -0
  675. package/node_modules/typebox/build/type/action/_remove_optional.d.mts +11 -0
  676. package/node_modules/typebox/build/type/action/_remove_optional.mjs +11 -0
  677. package/node_modules/typebox/build/type/action/_remove_readonly.d.mts +11 -0
  678. package/node_modules/typebox/build/type/action/_remove_readonly.mjs +11 -0
  679. package/node_modules/typebox/build/type/action/conditional.d.mts +2 -3
  680. package/node_modules/typebox/build/type/action/conditional.mjs +2 -1
  681. package/node_modules/typebox/build/type/action/index.d.mts +7 -4
  682. package/node_modules/typebox/build/type/action/index.mjs +7 -4
  683. package/node_modules/typebox/build/type/action/mapped.d.mts +2 -3
  684. package/node_modules/typebox/build/type/action/mapped.mjs +2 -1
  685. package/node_modules/typebox/build/type/action/module.d.mts +8 -7
  686. package/node_modules/typebox/build/type/action/module.mjs +7 -6
  687. package/node_modules/typebox/build/type/action/readonly_object.mjs +3 -0
  688. package/node_modules/typebox/build/type/action/with.d.mts +11 -0
  689. package/node_modules/typebox/build/type/action/with.mjs +11 -0
  690. package/node_modules/typebox/build/type/engine/call/distribute_arguments.mjs +1 -1
  691. package/node_modules/typebox/build/type/engine/call/instantiate.d.mts +1 -3
  692. package/node_modules/typebox/build/type/engine/call/instantiate.mjs +3 -2
  693. package/node_modules/typebox/build/type/engine/call/resolve_arguments.mjs +2 -2
  694. package/node_modules/typebox/build/type/engine/constructor_parameters/instantiate.d.mts +3 -4
  695. package/node_modules/typebox/build/type/engine/constructor_parameters/instantiate.mjs +2 -1
  696. package/node_modules/typebox/build/type/engine/cyclic/candidates.d.mts +2 -3
  697. package/node_modules/typebox/build/type/engine/cyclic/candidates.mjs +3 -6
  698. package/node_modules/typebox/build/type/engine/cyclic/check.d.mts +6 -9
  699. package/node_modules/typebox/build/type/engine/cyclic/check.mjs +10 -16
  700. package/node_modules/typebox/build/type/engine/cyclic/dependencies.d.mts +1 -4
  701. package/node_modules/typebox/build/type/engine/cyclic/dependencies.mjs +9 -15
  702. package/node_modules/typebox/build/type/engine/cyclic/extends.d.mts +1 -4
  703. package/node_modules/typebox/build/type/engine/cyclic/extends.mjs +8 -14
  704. package/node_modules/typebox/build/type/engine/cyclic/instantiate.d.mts +2 -5
  705. package/node_modules/typebox/build/type/engine/cyclic/instantiate.mjs +3 -2
  706. package/node_modules/typebox/build/type/engine/enum/index.d.mts +0 -1
  707. package/node_modules/typebox/build/type/engine/enum/index.mjs +0 -1
  708. package/node_modules/typebox/build/type/engine/evaluate/broaden.d.mts +1 -2
  709. package/node_modules/typebox/build/type/engine/evaluate/broaden.mjs +2 -6
  710. package/node_modules/typebox/build/type/engine/evaluate/composite.d.mts +10 -6
  711. package/node_modules/typebox/build/type/engine/evaluate/composite.mjs +10 -6
  712. package/node_modules/typebox/build/type/engine/evaluate/distribute.d.mts +2 -1
  713. package/node_modules/typebox/build/type/engine/evaluate/distribute.mjs +3 -3
  714. package/node_modules/typebox/build/type/engine/evaluate/evaluate.d.mts +17 -5
  715. package/node_modules/typebox/build/type/engine/evaluate/evaluate.mjs +34 -8
  716. package/node_modules/typebox/build/type/engine/exclude/operation.d.mts +5 -6
  717. package/node_modules/typebox/build/type/engine/exclude/operation.mjs +11 -12
  718. package/node_modules/typebox/build/type/engine/extract/operation.d.mts +5 -6
  719. package/node_modules/typebox/build/type/engine/extract/operation.mjs +11 -12
  720. package/node_modules/typebox/build/type/engine/immutable/instantiate_add.d.mts +10 -0
  721. package/node_modules/typebox/build/type/engine/immutable/instantiate_add.mjs +14 -0
  722. package/node_modules/typebox/build/type/engine/immutable/instantiate_remove.d.mts +10 -0
  723. package/node_modules/typebox/build/type/engine/immutable/instantiate_remove.mjs +14 -0
  724. package/node_modules/typebox/build/type/engine/index.d.mts +2 -2
  725. package/node_modules/typebox/build/type/engine/index.mjs +2 -2
  726. package/node_modules/typebox/build/type/engine/indexable/from_dependent.d.mts +5 -0
  727. package/node_modules/typebox/build/type/engine/indexable/from_dependent.mjs +8 -0
  728. package/node_modules/typebox/build/type/engine/indexable/from_enum.d.mts +3 -3
  729. package/node_modules/typebox/build/type/engine/indexable/from_enum.mjs +4 -4
  730. package/node_modules/typebox/build/type/engine/indexable/from_template_literal.d.mts +2 -2
  731. package/node_modules/typebox/build/type/engine/indexable/from_template_literal.mjs +3 -3
  732. package/node_modules/typebox/build/type/engine/indexable/from_type.d.mts +3 -1
  733. package/node_modules/typebox/build/type/engine/indexable/from_type.mjs +9 -6
  734. package/node_modules/typebox/build/type/engine/indexed/instantiate.d.mts +2 -1
  735. package/node_modules/typebox/build/type/engine/indexed/instantiate.mjs +5 -2
  736. package/node_modules/typebox/build/type/engine/instantiate.d.mts +44 -31
  737. package/node_modules/typebox/build/type/engine/instantiate.mjs +82 -83
  738. package/node_modules/typebox/build/type/engine/interface/instantiate.d.mts +3 -6
  739. package/node_modules/typebox/build/type/engine/intrinsics/from_template_literal.d.mts +2 -2
  740. package/node_modules/typebox/build/type/engine/intrinsics/from_template_literal.mjs +3 -3
  741. package/node_modules/typebox/build/type/engine/keyof/instantiate.d.mts +2 -1
  742. package/node_modules/typebox/build/type/engine/keyof/instantiate.mjs +5 -1
  743. package/node_modules/typebox/build/type/engine/mapped/mapped_operation.d.mts +4 -4
  744. package/node_modules/typebox/build/type/engine/mapped/mapped_operation.mjs +3 -3
  745. package/node_modules/typebox/build/type/engine/mapped/mapped_variants.d.mts +5 -4
  746. package/node_modules/typebox/build/type/engine/mapped/mapped_variants.mjs +10 -5
  747. package/node_modules/typebox/build/type/engine/module/instantiate.d.mts +7 -9
  748. package/node_modules/typebox/build/type/engine/module/instantiate.mjs +17 -15
  749. package/node_modules/typebox/build/type/engine/object/from_dependent.d.mts +5 -0
  750. package/node_modules/typebox/build/type/engine/object/from_dependent.mjs +8 -0
  751. package/node_modules/typebox/build/type/engine/object/from_type.d.mts +3 -1
  752. package/node_modules/typebox/build/type/engine/object/from_type.mjs +8 -5
  753. package/node_modules/typebox/build/type/engine/object/from_union.mjs +2 -2
  754. package/node_modules/typebox/build/type/engine/optional/instantiate_add.d.mts +10 -0
  755. package/node_modules/typebox/build/type/engine/optional/instantiate_add.mjs +14 -0
  756. package/node_modules/typebox/build/type/engine/optional/instantiate_remove.d.mts +10 -0
  757. package/node_modules/typebox/build/type/engine/optional/instantiate_remove.mjs +14 -0
  758. package/node_modules/typebox/build/type/engine/parameters/instantiate.d.mts +3 -4
  759. package/node_modules/typebox/build/type/engine/parameters/instantiate.mjs +2 -1
  760. package/node_modules/typebox/build/type/engine/partial/from_dependent.d.mts +5 -0
  761. package/node_modules/typebox/build/type/engine/partial/from_dependent.mjs +8 -0
  762. package/node_modules/typebox/build/type/engine/partial/from_intersect.d.mts +1 -1
  763. package/node_modules/typebox/build/type/engine/partial/from_intersect.mjs +3 -2
  764. package/node_modules/typebox/build/type/engine/partial/from_object.d.mts +2 -2
  765. package/node_modules/typebox/build/type/engine/partial/from_object.mjs +2 -2
  766. package/node_modules/typebox/build/type/engine/partial/from_type.d.mts +3 -1
  767. package/node_modules/typebox/build/type/engine/partial/from_type.mjs +7 -4
  768. package/node_modules/typebox/build/type/engine/priority/index.d.mts +1 -0
  769. package/node_modules/typebox/build/type/engine/priority/index.mjs +1 -0
  770. package/node_modules/typebox/build/type/engine/priority/priority.d.mts +20 -0
  771. package/node_modules/typebox/build/type/engine/priority/priority.mjs +28 -0
  772. package/node_modules/typebox/build/type/engine/readonly/instantiate_add.d.mts +10 -0
  773. package/node_modules/typebox/build/type/engine/readonly/instantiate_add.mjs +14 -0
  774. package/node_modules/typebox/build/type/engine/readonly/instantiate_remove.d.mts +10 -0
  775. package/node_modules/typebox/build/type/engine/readonly/instantiate_remove.mjs +14 -0
  776. package/node_modules/typebox/build/type/engine/readonly_object/from_array.d.mts +2 -2
  777. package/node_modules/typebox/build/type/engine/readonly_object/from_array.mjs +2 -2
  778. package/node_modules/typebox/build/type/engine/readonly_object/from_dependent.d.mts +5 -0
  779. package/node_modules/typebox/build/type/engine/readonly_object/from_dependent.mjs +8 -0
  780. package/node_modules/typebox/build/type/engine/readonly_object/from_intersect.d.mts +1 -1
  781. package/node_modules/typebox/build/type/engine/readonly_object/from_intersect.mjs +3 -2
  782. package/node_modules/typebox/build/type/engine/readonly_object/from_object.d.mts +2 -2
  783. package/node_modules/typebox/build/type/engine/readonly_object/from_object.mjs +2 -2
  784. package/node_modules/typebox/build/type/engine/readonly_object/from_tuple.d.mts +2 -2
  785. package/node_modules/typebox/build/type/engine/readonly_object/from_tuple.mjs +2 -2
  786. package/node_modules/typebox/build/type/engine/readonly_object/from_type.d.mts +3 -1
  787. package/node_modules/typebox/build/type/engine/readonly_object/from_type.mjs +8 -5
  788. package/node_modules/typebox/build/type/engine/record/from_key_enum.d.mts +2 -2
  789. package/node_modules/typebox/build/type/engine/record/from_key_enum.mjs +2 -2
  790. package/node_modules/typebox/build/type/engine/record/from_key_template_literal.d.mts +2 -2
  791. package/node_modules/typebox/build/type/engine/record/from_key_template_literal.mjs +2 -2
  792. package/node_modules/typebox/build/type/engine/ref/instantiate.d.mts +3 -3
  793. package/node_modules/typebox/build/type/engine/ref/instantiate.mjs +6 -6
  794. package/node_modules/typebox/build/type/engine/required/from_dependent.d.mts +5 -0
  795. package/node_modules/typebox/build/type/engine/required/from_dependent.mjs +8 -0
  796. package/node_modules/typebox/build/type/engine/required/from_intersect.d.mts +1 -1
  797. package/node_modules/typebox/build/type/engine/required/from_intersect.mjs +3 -2
  798. package/node_modules/typebox/build/type/engine/required/from_object.d.mts +2 -2
  799. package/node_modules/typebox/build/type/engine/required/from_object.mjs +2 -2
  800. package/node_modules/typebox/build/type/engine/required/from_type.d.mts +3 -1
  801. package/node_modules/typebox/build/type/engine/required/from_type.mjs +7 -4
  802. package/node_modules/typebox/build/type/engine/template_literal/decode.mjs +3 -3
  803. package/node_modules/typebox/build/type/engine/template_literal/encode.d.mts +2 -2
  804. package/node_modules/typebox/build/type/engine/template_literal/encode.mjs +6 -6
  805. package/node_modules/typebox/build/type/engine/template_literal/is_finite.mjs +1 -1
  806. package/node_modules/typebox/build/type/engine/template_literal/is_pattern.mjs +1 -0
  807. package/node_modules/typebox/build/type/engine/this/expand_this.d.mts +1 -4
  808. package/node_modules/typebox/build/type/engine/this/expand_this.mjs +7 -13
  809. package/node_modules/typebox/build/type/engine/with/instantiate.d.mts +8 -0
  810. package/node_modules/typebox/build/type/engine/{options → with}/instantiate.mjs +5 -5
  811. package/node_modules/typebox/build/type/extends/dependent.d.mts +6 -0
  812. package/node_modules/typebox/build/type/extends/dependent.mjs +6 -0
  813. package/node_modules/typebox/build/type/extends/enum.d.mts +4 -4
  814. package/node_modules/typebox/build/type/extends/enum.mjs +3 -2
  815. package/node_modules/typebox/build/type/extends/extends_left.d.mts +5 -7
  816. package/node_modules/typebox/build/type/extends/extends_left.mjs +24 -27
  817. package/node_modules/typebox/build/type/extends/extends_right.d.mts +7 -5
  818. package/node_modules/typebox/build/type/extends/extends_right.mjs +20 -15
  819. package/node_modules/typebox/build/type/extends/inference.mjs +1 -1
  820. package/node_modules/typebox/build/type/extends/object.d.mts +8 -1
  821. package/node_modules/typebox/build/type/extends/object.mjs +25 -3
  822. package/node_modules/typebox/build/type/extends/parameters.mjs +2 -2
  823. package/node_modules/typebox/build/type/extends/record.d.mts +13 -0
  824. package/node_modules/typebox/build/type/extends/record.mjs +23 -0
  825. package/node_modules/typebox/build/type/extends/template_literal.d.mts +3 -3
  826. package/node_modules/typebox/build/type/extends/template_literal.mjs +3 -3
  827. package/node_modules/typebox/build/type/extends/tuple.d.mts +3 -6
  828. package/node_modules/typebox/build/type/extends/tuple.mjs +6 -5
  829. package/node_modules/typebox/build/type/extends/union.mjs +2 -2
  830. package/node_modules/typebox/build/type/script/mapping.d.mts +86 -98
  831. package/node_modules/typebox/build/type/script/mapping.mjs +95 -92
  832. package/node_modules/typebox/build/type/script/parser.d.mts +42 -40
  833. package/node_modules/typebox/build/type/script/parser.mjs +23 -22
  834. package/node_modules/typebox/build/type/script/script.d.mts +3 -4
  835. package/node_modules/typebox/build/type/script/script.mjs +3 -2
  836. package/node_modules/typebox/build/type/script/token/internal/guard.d.mts +1 -1
  837. package/node_modules/typebox/build/type/script/token/internal/guard.mjs +1 -1
  838. package/node_modules/typebox/build/type/script/token/internal/take.mjs +1 -1
  839. package/node_modules/typebox/build/type/script/token/until.mjs +2 -2
  840. package/node_modules/typebox/build/type/types/_codec.d.mts +12 -12
  841. package/node_modules/typebox/build/type/types/_codec.mjs +0 -1
  842. package/node_modules/typebox/build/type/types/_immutable.d.mts +2 -9
  843. package/node_modules/typebox/build/type/types/_immutable.mjs +2 -10
  844. package/node_modules/typebox/build/type/types/_optional.d.mts +2 -9
  845. package/node_modules/typebox/build/type/types/_optional.mjs +2 -11
  846. package/node_modules/typebox/build/type/types/_readonly.d.mts +2 -9
  847. package/node_modules/typebox/build/type/types/_readonly.mjs +2 -10
  848. package/node_modules/typebox/build/type/types/_refine.d.mts +8 -10
  849. package/node_modules/typebox/build/type/types/_refine.mjs +1 -2
  850. package/node_modules/typebox/build/type/types/call.d.mts +3 -3
  851. package/node_modules/typebox/build/type/types/call.mjs +3 -2
  852. package/node_modules/typebox/build/type/types/deferred.d.mts +1 -0
  853. package/node_modules/typebox/build/type/types/deferred.mjs +1 -1
  854. package/node_modules/typebox/build/type/types/dependent.d.mts +17 -0
  855. package/node_modules/typebox/build/type/types/dependent.mjs +24 -0
  856. package/node_modules/typebox/build/type/types/enum.d.mts +3 -1
  857. package/node_modules/typebox/build/type/types/enum.mjs +5 -0
  858. package/node_modules/typebox/build/type/types/index.d.mts +1 -4
  859. package/node_modules/typebox/build/type/types/index.mjs +1 -4
  860. package/node_modules/typebox/build/type/types/number.d.mts +1 -1
  861. package/node_modules/typebox/build/type/types/number.mjs +1 -1
  862. package/node_modules/typebox/build/type/types/record.d.mts +13 -7
  863. package/node_modules/typebox/build/type/types/record.mjs +15 -9
  864. package/node_modules/typebox/build/type/types/static.d.mts +2 -5
  865. package/node_modules/typebox/build/typebox.d.mts +3 -7
  866. package/node_modules/typebox/build/typebox.mjs +3 -7
  867. package/node_modules/typebox/build/value/clean/clean.mjs +4 -2
  868. package/node_modules/typebox/build/value/clean/from_intersect.mjs +2 -2
  869. package/node_modules/typebox/build/value/clean/from_type.mjs +8 -10
  870. package/node_modules/typebox/build/value/clean/from_union.d.mts +1 -1
  871. package/node_modules/typebox/build/value/clean/from_union.mjs +1 -2
  872. package/node_modules/typebox/build/value/clone/clone.mjs +2 -73
  873. package/node_modules/typebox/build/value/codec/decode.mjs +4 -2
  874. package/node_modules/typebox/build/value/codec/encode.mjs +4 -2
  875. package/node_modules/typebox/build/value/codec/from_array.mjs +1 -4
  876. package/node_modules/typebox/build/value/codec/from_object.mjs +1 -4
  877. package/node_modules/typebox/build/value/codec/from_record.mjs +2 -7
  878. package/node_modules/typebox/build/value/codec/from_tuple.mjs +1 -4
  879. package/node_modules/typebox/build/value/codec/from_union.mjs +2 -3
  880. package/node_modules/typebox/build/value/convert/from_enum.mjs +3 -4
  881. package/node_modules/typebox/build/value/convert/from_template_literal.d.mts +1 -1
  882. package/node_modules/typebox/build/value/convert/from_template_literal.mjs +2 -3
  883. package/node_modules/typebox/build/value/convert/from_type.mjs +19 -21
  884. package/node_modules/typebox/build/value/create/from_enum.mjs +2 -2
  885. package/node_modules/typebox/build/value/create/from_type.mjs +23 -31
  886. package/node_modules/typebox/build/value/default/from_object.mjs +1 -1
  887. package/node_modules/typebox/build/value/default/from_type.mjs +8 -10
  888. package/node_modules/typebox/build/value/errors/errors.d.mts +2 -2
  889. package/node_modules/typebox/build/value/errors/errors.mjs +1 -1
  890. package/node_modules/typebox/build/value/index.d.mts +0 -1
  891. package/node_modules/typebox/build/value/index.mjs +0 -1
  892. package/node_modules/typebox/build/value/repair/from_enum.mjs +2 -3
  893. package/node_modules/typebox/build/value/repair/from_type.mjs +24 -22
  894. package/node_modules/typebox/build/value/shared/union_priority_sort.d.mts +6 -2
  895. package/node_modules/typebox/build/value/shared/union_priority_sort.mjs +62 -26
  896. package/node_modules/typebox/build/value/value.d.mts +0 -1
  897. package/node_modules/typebox/build/value/value.mjs +0 -1
  898. package/node_modules/typebox/package.json +33 -33
  899. package/node_modules/typebox/readme.md +117 -103
  900. package/package.json +20 -10
  901. package/dist/core/extensions/builtin/tool-pair-guard/sanitize-anthropic-payload.d.ts +0 -3
  902. package/dist/core/extensions/builtin/tool-pair-guard/sanitize-anthropic-payload.d.ts.map +0 -1
  903. package/dist/core/extensions/builtin/tool-pair-guard/sanitize-anthropic-payload.js.map +0 -1
  904. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-repo.d.ts +0 -26
  905. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-repo.d.ts.map +0 -1
  906. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-repo.js +0 -100
  907. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-repo.js.map +0 -1
  908. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-storage.d.ts +0 -42
  909. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-storage.d.ts.map +0 -1
  910. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-storage.js +0 -286
  911. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-storage.js.map +0 -1
  912. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-repo.d.ts +0 -18
  913. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-repo.d.ts.map +0 -1
  914. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-repo.js +0 -44
  915. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-repo.js.map +0 -1
  916. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-storage.d.ts +0 -33
  917. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-storage.d.ts.map +0 -1
  918. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-storage.js +0 -163
  919. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-storage.js.map +0 -1
  920. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/repo-utils.d.ts +0 -11
  921. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/repo-utils.d.ts.map +0 -1
  922. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/repo-utils.js +0 -39
  923. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/repo-utils.js.map +0 -1
  924. package/node_modules/typebox/build/schema/engine/_guard.d.mts +0 -6
  925. package/node_modules/typebox/build/schema/engine/_guard.mjs +0 -26
  926. package/node_modules/typebox/build/schema/types/_guard.d.mts +0 -10
  927. package/node_modules/typebox/build/schema/types/_guard.mjs +0 -16
  928. package/node_modules/typebox/build/type/action/_optional.d.mts +0 -19
  929. package/node_modules/typebox/build/type/action/_optional.mjs +0 -40
  930. package/node_modules/typebox/build/type/action/_readonly.d.mts +0 -19
  931. package/node_modules/typebox/build/type/action/_readonly.mjs +0 -40
  932. package/node_modules/typebox/build/type/action/awaited.d.mts +0 -15
  933. package/node_modules/typebox/build/type/action/awaited.mjs +0 -15
  934. package/node_modules/typebox/build/type/action/options.d.mts +0 -11
  935. package/node_modules/typebox/build/type/action/options.mjs +0 -11
  936. package/node_modules/typebox/build/type/engine/awaited/instantiate.d.mts +0 -11
  937. package/node_modules/typebox/build/type/engine/awaited/instantiate.mjs +0 -20
  938. package/node_modules/typebox/build/type/engine/enum/enum_to_union.d.mts +0 -14
  939. package/node_modules/typebox/build/type/engine/enum/enum_to_union.mjs +0 -24
  940. package/node_modules/typebox/build/type/engine/options/index.d.mts +0 -1
  941. package/node_modules/typebox/build/type/engine/options/index.mjs +0 -1
  942. package/node_modules/typebox/build/type/engine/options/instantiate.d.mts +0 -8
  943. package/node_modules/typebox/build/type/extends/async_iterator.d.mts +0 -7
  944. package/node_modules/typebox/build/type/extends/async_iterator.mjs +0 -9
  945. package/node_modules/typebox/build/type/extends/iterator.d.mts +0 -7
  946. package/node_modules/typebox/build/type/extends/iterator.mjs +0 -9
  947. package/node_modules/typebox/build/type/extends/promise.d.mts +0 -7
  948. package/node_modules/typebox/build/type/extends/promise.mjs +0 -9
  949. package/node_modules/typebox/build/type/types/async_iterator.d.mts +0 -20
  950. package/node_modules/typebox/build/type/types/async_iterator.mjs +0 -28
  951. package/node_modules/typebox/build/type/types/base.d.mts +0 -50
  952. package/node_modules/typebox/build/type/types/base.mjs +0 -84
  953. package/node_modules/typebox/build/type/types/iterator.d.mts +0 -20
  954. package/node_modules/typebox/build/type/types/iterator.mjs +0 -28
  955. package/node_modules/typebox/build/type/types/promise.d.mts +0 -21
  956. package/node_modules/typebox/build/type/types/promise.mjs +0 -29
  957. package/node_modules/typebox/build/value/clean/from_base.d.mts +0 -2
  958. package/node_modules/typebox/build/value/clean/from_base.mjs +0 -4
  959. package/node_modules/typebox/build/value/convert/from_base.d.mts +0 -2
  960. package/node_modules/typebox/build/value/convert/from_base.mjs +0 -4
  961. package/node_modules/typebox/build/value/create/from_async_iterator.d.mts +0 -2
  962. package/node_modules/typebox/build/value/create/from_async_iterator.mjs +0 -5
  963. package/node_modules/typebox/build/value/create/from_base.d.mts +0 -2
  964. package/node_modules/typebox/build/value/create/from_base.mjs +0 -4
  965. package/node_modules/typebox/build/value/create/from_iterator.d.mts +0 -2
  966. package/node_modules/typebox/build/value/create/from_iterator.mjs +0 -5
  967. package/node_modules/typebox/build/value/create/from_promise.d.mts +0 -2
  968. package/node_modules/typebox/build/value/create/from_promise.mjs +0 -5
  969. package/node_modules/typebox/build/value/default/from_base.d.mts +0 -2
  970. package/node_modules/typebox/build/value/default/from_base.mjs +0 -5
  971. package/node_modules/typebox/build/value/mutate/error.d.mts +0 -3
  972. package/node_modules/typebox/build/value/mutate/error.mjs +0 -6
  973. package/node_modules/typebox/build/value/mutate/from_array.d.mts +0 -2
  974. package/node_modules/typebox/build/value/mutate/from_array.mjs +0 -16
  975. package/node_modules/typebox/build/value/mutate/from_object.d.mts +0 -2
  976. package/node_modules/typebox/build/value/mutate/from_object.mjs +0 -40
  977. package/node_modules/typebox/build/value/mutate/from_unknown.d.mts +0 -2
  978. package/node_modules/typebox/build/value/mutate/from_unknown.mjs +0 -7
  979. package/node_modules/typebox/build/value/mutate/from_value.d.mts +0 -2
  980. package/node_modules/typebox/build/value/mutate/from_value.mjs +0 -12
  981. package/node_modules/typebox/build/value/mutate/index.d.mts +0 -1
  982. package/node_modules/typebox/build/value/mutate/index.mjs +0 -1
  983. package/node_modules/typebox/build/value/mutate/mutate.d.mts +0 -11
  984. package/node_modules/typebox/build/value/mutate/mutate.mjs +0 -41
  985. package/node_modules/typebox/build/value/repair/from_base.d.mts +0 -2
  986. package/node_modules/typebox/build/value/repair/from_base.mjs +0 -8
  987. /package/node_modules/typebox/build/type/engine/{awaited → with}/index.d.mts +0 -0
  988. /package/node_modules/typebox/build/type/engine/{awaited → with}/index.mjs +0 -0
@@ -1,9 +1,6 @@
1
1
  import { createHash } from "node:crypto";
2
- import { EXPIRING_WITHIN_MS } from "./auth-lane.js";
3
- import { isBoundAccountTokenExpiring, SESSION_REGISTRY_IDLE_TTL_MS, } from "./session-registry.js";
4
- import { mapPiToolNameToSdk } from "./tools.js";
2
+ import { HOST_TOOL_POLICY_FINGERPRINT, mapPiToolNameToSdk } from "./tools.js";
5
3
  const sentHashesByEntry = new WeakMap();
6
- let assistantProvenanceHooks;
7
4
  function stableValue(value, seen = new WeakSet()) {
8
5
  if (typeof value === "function")
9
6
  return `[function:${value.name}:${value.toString()}]`;
@@ -14,27 +11,25 @@ function stableValue(value, seen = new WeakSet()) {
14
11
  if (seen.has(value))
15
12
  return "[circular]";
16
13
  seen.add(value);
17
- if (Array.isArray(value))
18
- return value.map((item) => stableValue(item, seen));
19
- return Object.fromEntries(Object.entries(value)
20
- .filter(([, item]) => item !== undefined)
21
- .sort(([left], [right]) => left.localeCompare(right))
22
- .map(([key, item]) => [key, stableValue(item, seen)]));
14
+ const normalized = Array.isArray(value)
15
+ ? value.map((item) => stableValue(item, seen))
16
+ : Object.fromEntries(Object.entries(value)
17
+ .filter(([, item]) => item !== undefined)
18
+ .sort(([left], [right]) => left.localeCompare(right))
19
+ .map(([key, item]) => [key, stableValue(item, seen)]));
20
+ seen.delete(value);
21
+ return normalized;
23
22
  }
24
23
  function digest(value) {
25
24
  return createHash("sha256")
26
25
  .update(JSON.stringify(stableValue(value)))
27
26
  .digest("hex");
28
27
  }
29
- export function installAssistantProvenanceHooks(hooks) {
30
- assistantProvenanceHooks = hooks;
31
- }
32
28
  export function sessionSyncDigest(value) {
33
29
  return digest(value);
34
30
  }
35
31
  export function sentMessages(context) {
36
32
  const messages = context.messages.filter((message) => message.role === "user" || message.role === "toolResult");
37
- assistantProvenanceHooks?.captureMessages(context, messages);
38
33
  return messages;
39
34
  }
40
35
  export function sentMessageHashes(messages) {
@@ -46,105 +41,37 @@ export function sentMessageHashes(messages) {
46
41
  toolName: message.toolName,
47
42
  content: message.content,
48
43
  }));
49
- assistantProvenanceHooks?.captureHashes(messages, hashes);
50
44
  return hashes;
51
45
  }
52
46
  function prefixDigest(hashes, count = hashes.length) {
53
47
  return digest(hashes.slice(0, count));
54
48
  }
55
- function samePrefix(left, right, count) {
56
- if (left.length < count || right.length < count)
57
- return false;
58
- for (let index = 0; index < count; index++) {
59
- if (left[index] !== right[index])
60
- return false;
61
- }
62
- return true;
63
- }
64
- function resumeBoundary(entry, currentCount) {
65
- return [...entry.assistantUuidByIndex.entries()]
66
- .filter(([index]) => index < currentCount)
67
- .sort(([left], [right]) => right - left)
68
- .map(([index, uuid]) => ({ index, uuid }))[0];
69
- }
70
- function idleTtlExpired(entry) {
71
- if (entry.activeTurn !== null || (entry.state !== "IDLE_SYNCED" && entry.state !== "TAINTED"))
72
- return false;
73
- return isBoundAccountTokenExpiring(entry, [
74
- {
75
- name: entry.accountName,
76
- expires: entry.lastUsedAt + SESSION_REGISTRY_IDLE_TTL_MS + EXPIRING_WITHIN_MS,
77
- source: "login",
78
- },
79
- ]);
80
- }
81
49
  /** Pure divergence guard: every non-proven continuation resolves to cold-seed. */
82
- export function decideSessionSync(input) {
83
- const { entry } = input;
84
- if (!entry)
85
- return { kind: "cold-seed", reason: "registry_miss" };
86
- if (idleTtlExpired(entry))
87
- return { kind: "cold-seed", reason: "idle_ttl" };
88
- if (input.tokenExpiring)
89
- return { kind: "cold-seed", reason: "bound_account_token_expiring" };
90
- if (entry.taintedReason)
91
- return { kind: "cold-seed", reason: `tainted:${entry.taintedReason}` };
92
- if (entry.accountName !== input.accountName)
93
- return { kind: "cold-seed", reason: "account_changed" };
94
- if (entry.modelId !== input.modelId)
95
- return { kind: "cold-seed", reason: "model_changed" };
96
- if (entry.toolsetHash !== input.fingerprint.toolsetHash)
97
- return { kind: "cold-seed", reason: "toolset_changed" };
98
- if (entry.systemPromptHash !== input.fingerprint.systemPromptHash) {
99
- return { kind: "cold-seed", reason: "system_prompt_changed" };
100
- }
101
- if (assistantProvenanceHooks &&
102
- !assistantProvenanceHooks.matches(entry, input.currentHashes, entry.branchInfo !== null)) {
103
- return { kind: "cold-seed", reason: "assistant_stream_diverged" };
104
- }
105
- const residentHashes = sentHashesByEntry.get(entry) ?? [];
106
- if (entry.branchInfo) {
107
- const strictPrefix = input.currentHashes.length < entry.sentCount &&
108
- samePrefix(input.currentHashes, residentHashes, input.currentHashes.length);
109
- const boundary = strictPrefix ? resumeBoundary(entry, input.currentHashes.length) : undefined;
110
- return boundary
111
- ? {
112
- kind: "resume",
113
- from: boundary.index,
114
- resumeSessionAt: boundary.uuid,
115
- previousSdkSessionId: entry.sdkSessionId,
116
- }
117
- : { kind: "cold-seed", reason: strictPrefix ? "branch_boundary_unavailable" : "branch_diverged" };
118
- }
119
- const prefixMatches = entry.sentCount <= input.currentHashes.length &&
120
- entry.syncedPrefixHash === prefixDigest(input.currentHashes, entry.sentCount) &&
121
- samePrefix(input.currentHashes, residentHashes, entry.sentCount);
122
- return prefixMatches
123
- ? { kind: "incremental", from: entry.sentCount }
124
- : { kind: "cold-seed", reason: "sent_stream_diverged" };
50
+ export function sentHashesForEntry(entry) {
51
+ return sentHashesByEntry.get(entry);
125
52
  }
126
53
  export function recordSyncedStream(entry, hashes) {
127
54
  const copy = [...hashes];
128
- assistantProvenanceHooks?.record(entry, hashes);
129
55
  sentHashesByEntry.set(entry, copy);
130
56
  entry.sentCount = copy.length;
131
57
  entry.syncedPrefixHash = prefixDigest(copy);
132
58
  entry.branchInfo = null;
133
59
  }
134
- export function primeResumedEntry(entry, previous, from) {
135
- const hashes = (sentHashesByEntry.get(previous) ?? []).slice(0, from);
136
- assistantProvenanceHooks?.prime(entry, previous, from);
137
- sentHashesByEntry.set(entry, hashes);
138
- entry.sentCount = from;
139
- entry.syncedPrefixHash = prefixDigest(hashes);
140
- for (const [index, uuid] of previous.assistantUuidByIndex) {
141
- if (index <= from)
142
- entry.assistantUuidByIndex.set(index, uuid);
143
- }
60
+ const GENERATED_DATE_LINE = /\nCurrent date: \d{4}-\d{2}-\d{2}(?=\nCurrent working directory: [^\n]*$)/;
61
+ /**
62
+ * The generated date line advances at UTC midnight while the conversation is
63
+ * unchanged; hashing it verbatim retires a live session at midnight for no
64
+ * semantic reason. Only that exact terminal line is neutralized - cwd and every
65
+ * other prompt region stay fail-closed.
66
+ */
67
+ function fingerprintSystemPrompt(systemPrompt) {
68
+ if (typeof systemPrompt !== "string")
69
+ return systemPrompt ?? null;
70
+ return systemPrompt.replace(GENERATED_DATE_LINE, "\nCurrent date: <session-date>");
144
71
  }
145
72
  export function configFingerprint(options, context, authLane, accountName) {
146
73
  return {
147
- systemPromptHash: digest(options.systemPrompt ?? null),
74
+ systemPromptHash: digest(fingerprintSystemPrompt(options.systemPrompt)),
148
75
  toolsetHash: digest({
149
76
  tools: options.tools ?? [],
150
77
  reasoning: {
@@ -161,10 +88,11 @@ export function configFingerprint(options, context, authLane, accountName) {
161
88
  authLane,
162
89
  accountName,
163
90
  permissionMode: options.permissionMode,
164
- canUseTool: options.canUseTool,
165
- hooks: options.hooks,
91
+ hostToolPolicy: HOST_TOOL_POLICY_FINGERPRINT,
166
92
  settingSources: options.settingSources,
167
93
  extraArgs: options.extraArgs,
94
+ pathToClaudeCodeExecutable: options.pathToClaudeCodeExecutable,
95
+ includePartialMessages: options.includePartialMessages,
168
96
  }),
169
97
  };
170
98
  }
@@ -1 +1 @@
1
- {"version":3,"file":"session-sync.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/claude-sdk-oauth/session-sync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,kBAAkB,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OAAO,EAAE,CAAC,CAAC;QAC7C,OAAO;IACR,CAAC;IACD,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;QAC7B,MAAM,CAAC,IAAI,CACV,KAAK,CAAC,IAAI,KAAK,MAAM;YACpB,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE;YACpC,CAAC,CAAC;gBACA,IAAI,EAAE,OAAO;gBACb,MAAM,EAAE;oBACP,IAAI,EAAE,QAAQ;oBACd,UAAU,EAAE,KAAK,CAAC,QAA2C;oBAC7D,IAAI,EAAE,KAAK,CAAC,IAAI;iBAChB;aACD,CACH,CAAC;IACH,CAAC;AACF,CAAC;AAED,MAAM,UAAU,sBAAsB,CACrC,QAAgC,EAChC,mBAAiD;IAEjD,MAAM,MAAM,GAAwB,EAAE,CAAC;IACvC,KAAK,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC,IAAI,QAAQ,CAAC,OAAO,EAAE,EAAE,CAAC;QACnD,IAAI,KAAK,GAAG,CAAC;YAAE,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;QAC3D,IAAI,OAAO,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;YACnC,MAAM,CAAC,IAAI,CAAC;gBACX,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,gBAAgB,kBAAkB,CAAC,OAAO,CAAC,QAAQ,EAAE,mBAAmB,CAAC,QAAQ,OAAO,CAAC,UAAU,MAAM;aAC/G,CAAC,CAAC;QACJ,CAAC;QACD,aAAa,CAAC,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IACxC,CAAC;IACD,OAAO,MAAM,CAAC;AACf,CAAC","sourcesContent":["import { createHash } from \"node:crypto\";\nimport type { Context, ImageContent, Message, TextContent } from \"@earendil-works/pi-ai\";\nimport { EXPIRING_WITHIN_MS } from \"./auth-lane.ts\";\nimport type { ClaudeSdkOauthAuthLane } from \"./options.ts\";\nimport type { Base64ImageSource, ContentBlockParam, Options } from \"./sdk-boundary.ts\";\nimport {\n\ttype ClaudeSdkOauthSessionEntry,\n\tisBoundAccountTokenExpiring,\n\tSESSION_REGISTRY_IDLE_TTL_MS,\n} from \"./session-registry.ts\";\nimport { mapPiToolNameToSdk } from \"./tools.ts\";\n\nexport type SentMessage = Extract<Message, { role: \"user\" | \"toolResult\" }>;\n\nexport type SessionConfigFingerprint = {\n\tsystemPromptHash: string;\n\ttoolsetHash: string;\n};\n\nexport type SessionSyncDecision =\n\t| { kind: \"cold-seed\"; reason: string }\n\t| { kind: \"incremental\"; from: number }\n\t| { kind: \"resume\"; from: number; resumeSessionAt: string; previousSdkSessionId: string };\n\nexport type SessionSyncDecisionInput = {\n\tentry: ClaudeSdkOauthSessionEntry | undefined;\n\tcurrentHashes: readonly string[];\n\taccountName: string;\n\tmodelId: string;\n\tfingerprint: SessionConfigFingerprint;\n\ttokenExpiring: boolean;\n};\n\nexport type SessionAssistantProvenanceHooks = {\n\tcaptureMessages(context: Context, messages: readonly SentMessage[]): void;\n\tcaptureHashes(messages: readonly SentMessage[], hashes: readonly string[]): void;\n\tmatches(entry: ClaudeSdkOauthSessionEntry, hashes: readonly string[], branchPrefix: boolean): boolean;\n\trecord(entry: ClaudeSdkOauthSessionEntry, hashes: readonly string[]): void;\n\tprime(entry: ClaudeSdkOauthSessionEntry, previous: ClaudeSdkOauthSessionEntry, from: number): void;\n};\n\nconst sentHashesByEntry = new WeakMap<ClaudeSdkOauthSessionEntry, string[]>();\nlet assistantProvenanceHooks: SessionAssistantProvenanceHooks | undefined;\n\nfunction stableValue(value: unknown, seen = new WeakSet<object>()): unknown {\n\tif (typeof value === \"function\") return `[function:${value.name}:${value.toString()}]`;\n\tif (typeof value === \"bigint\") return value.toString();\n\tif (value === null || typeof value !== \"object\") return value;\n\tif (seen.has(value)) return \"[circular]\";\n\tseen.add(value);\n\tif (Array.isArray(value)) return value.map((item) => stableValue(item, seen));\n\treturn Object.fromEntries(\n\t\tObject.entries(value as Record<string, unknown>)\n\t\t\t.filter(([, item]) => item !== undefined)\n\t\t\t.sort(([left], [right]) => left.localeCompare(right))\n\t\t\t.map(([key, item]) => [key, stableValue(item, seen)]),\n\t);\n}\n\nfunction digest(value: unknown): string {\n\treturn createHash(\"sha256\")\n\t\t.update(JSON.stringify(stableValue(value)))\n\t\t.digest(\"hex\");\n}\n\nexport function installAssistantProvenanceHooks(hooks: SessionAssistantProvenanceHooks): void {\n\tassistantProvenanceHooks = hooks;\n}\n\nexport function sessionSyncDigest(value: unknown): string {\n\treturn digest(value);\n}\n\nexport function sentMessages(context: Context): SentMessage[] {\n\tconst messages = context.messages.filter(\n\t\t(message): message is SentMessage => message.role === \"user\" || message.role === \"toolResult\",\n\t);\n\tassistantProvenanceHooks?.captureMessages(context, messages);\n\treturn messages;\n}\n\nexport function sentMessageHashes(messages: readonly SentMessage[]): string[] {\n\tconst hashes = messages.map((message) =>\n\t\tdigest(\n\t\t\tmessage.role === \"user\"\n\t\t\t\t? { role: message.role, content: message.content }\n\t\t\t\t: {\n\t\t\t\t\t\trole: message.role,\n\t\t\t\t\t\ttoolCallId: message.toolCallId,\n\t\t\t\t\t\ttoolName: message.toolName,\n\t\t\t\t\t\tcontent: message.content,\n\t\t\t\t\t},\n\t\t),\n\t);\n\tassistantProvenanceHooks?.captureHashes(messages, hashes);\n\treturn hashes;\n}\n\nfunction prefixDigest(hashes: readonly string[], count = hashes.length): string {\n\treturn digest(hashes.slice(0, count));\n}\n\nfunction samePrefix(left: readonly string[], right: readonly string[], count: number): boolean {\n\tif (left.length < count || right.length < count) return false;\n\tfor (let index = 0; index < count; index++) {\n\t\tif (left[index] !== right[index]) return false;\n\t}\n\treturn true;\n}\n\nfunction resumeBoundary(\n\tentry: ClaudeSdkOauthSessionEntry,\n\tcurrentCount: number,\n): { index: number; uuid: string } | undefined {\n\treturn [...entry.assistantUuidByIndex.entries()]\n\t\t.filter(([index]) => index < currentCount)\n\t\t.sort(([left], [right]) => right - left)\n\t\t.map(([index, uuid]) => ({ index, uuid }))[0];\n}\n\nfunction idleTtlExpired(entry: ClaudeSdkOauthSessionEntry): boolean {\n\tif (entry.activeTurn !== null || (entry.state !== \"IDLE_SYNCED\" && entry.state !== \"TAINTED\")) return false;\n\treturn isBoundAccountTokenExpiring(entry, [\n\t\t{\n\t\t\tname: entry.accountName,\n\t\t\texpires: entry.lastUsedAt + SESSION_REGISTRY_IDLE_TTL_MS + EXPIRING_WITHIN_MS,\n\t\t\tsource: \"login\",\n\t\t},\n\t]);\n}\n\n/** Pure divergence guard: every non-proven continuation resolves to cold-seed. */\nexport function decideSessionSync(input: SessionSyncDecisionInput): SessionSyncDecision {\n\tconst { entry } = input;\n\tif (!entry) return { kind: \"cold-seed\", reason: \"registry_miss\" };\n\tif (idleTtlExpired(entry)) return { kind: \"cold-seed\", reason: \"idle_ttl\" };\n\tif (input.tokenExpiring) return { kind: \"cold-seed\", reason: \"bound_account_token_expiring\" };\n\tif (entry.taintedReason) return { kind: \"cold-seed\", reason: `tainted:${entry.taintedReason}` };\n\tif (entry.accountName !== input.accountName) return { kind: \"cold-seed\", reason: \"account_changed\" };\n\tif (entry.modelId !== input.modelId) return { kind: \"cold-seed\", reason: \"model_changed\" };\n\tif (entry.toolsetHash !== input.fingerprint.toolsetHash) return { kind: \"cold-seed\", reason: \"toolset_changed\" };\n\tif (entry.systemPromptHash !== input.fingerprint.systemPromptHash) {\n\t\treturn { kind: \"cold-seed\", reason: \"system_prompt_changed\" };\n\t}\n\tif (\n\t\tassistantProvenanceHooks &&\n\t\t!assistantProvenanceHooks.matches(entry, input.currentHashes, entry.branchInfo !== null)\n\t) {\n\t\treturn { kind: \"cold-seed\", reason: \"assistant_stream_diverged\" };\n\t}\n\tconst residentHashes = sentHashesByEntry.get(entry) ?? [];\n\tif (entry.branchInfo) {\n\t\tconst strictPrefix =\n\t\t\tinput.currentHashes.length < entry.sentCount &&\n\t\t\tsamePrefix(input.currentHashes, residentHashes, input.currentHashes.length);\n\t\tconst boundary = strictPrefix ? resumeBoundary(entry, input.currentHashes.length) : undefined;\n\t\treturn boundary\n\t\t\t? {\n\t\t\t\t\tkind: \"resume\",\n\t\t\t\t\tfrom: boundary.index,\n\t\t\t\t\tresumeSessionAt: boundary.uuid,\n\t\t\t\t\tpreviousSdkSessionId: entry.sdkSessionId,\n\t\t\t\t}\n\t\t\t: { kind: \"cold-seed\", reason: strictPrefix ? \"branch_boundary_unavailable\" : \"branch_diverged\" };\n\t}\n\tconst prefixMatches =\n\t\tentry.sentCount <= input.currentHashes.length &&\n\t\tentry.syncedPrefixHash === prefixDigest(input.currentHashes, entry.sentCount) &&\n\t\tsamePrefix(input.currentHashes, residentHashes, entry.sentCount);\n\treturn prefixMatches\n\t\t? { kind: \"incremental\", from: entry.sentCount }\n\t\t: { kind: \"cold-seed\", reason: \"sent_stream_diverged\" };\n}\n\nexport function recordSyncedStream(entry: ClaudeSdkOauthSessionEntry, hashes: readonly string[]): void {\n\tconst copy = [...hashes];\n\tassistantProvenanceHooks?.record(entry, hashes);\n\tsentHashesByEntry.set(entry, copy);\n\tentry.sentCount = copy.length;\n\tentry.syncedPrefixHash = prefixDigest(copy);\n\tentry.branchInfo = null;\n}\n\nexport function primeResumedEntry(\n\tentry: ClaudeSdkOauthSessionEntry,\n\tprevious: ClaudeSdkOauthSessionEntry,\n\tfrom: number,\n): void {\n\tconst hashes = (sentHashesByEntry.get(previous) ?? []).slice(0, from);\n\tassistantProvenanceHooks?.prime(entry, previous, from);\n\tsentHashesByEntry.set(entry, hashes);\n\tentry.sentCount = from;\n\tentry.syncedPrefixHash = prefixDigest(hashes);\n\tfor (const [index, uuid] of previous.assistantUuidByIndex) {\n\t\tif (index <= from) entry.assistantUuidByIndex.set(index, uuid);\n\t}\n}\n\nexport function configFingerprint(\n\toptions: Options,\n\tcontext: Context,\n\tauthLane: ClaudeSdkOauthAuthLane,\n\taccountName: string,\n): SessionConfigFingerprint {\n\treturn {\n\t\tsystemPromptHash: digest(options.systemPrompt ?? null),\n\t\ttoolsetHash: digest({\n\t\t\ttools: options.tools ?? [],\n\t\t\treasoning: {\n\t\t\t\tthinking: options.thinking,\n\t\t\t\teffort: options.effort,\n\t\t\t\tmaxThinkingTokens: options.maxThinkingTokens,\n\t\t\t},\n\t\t\tcontextTools: (context.tools ?? []).map((tool) => ({\n\t\t\t\tname: tool.name,\n\t\t\t\tdescription: tool.description,\n\t\t\t\tparameters: tool.parameters,\n\t\t\t})),\n\t\t\tcwd: options.cwd,\n\t\t\tauthLane,\n\t\t\taccountName,\n\t\t\tpermissionMode: options.permissionMode,\n\t\t\tcanUseTool: options.canUseTool,\n\t\t\thooks: options.hooks,\n\t\t\tsettingSources: options.settingSources,\n\t\t\textraArgs: options.extraArgs,\n\t\t}),\n\t};\n}\n\nfunction appendContent(blocks: ContentBlockParam[], content: string | readonly (TextContent | ImageContent)[]): void {\n\tif (typeof content === \"string\") {\n\t\tblocks.push({ type: \"text\", text: content });\n\t\treturn;\n\t}\n\tfor (const block of content) {\n\t\tblocks.push(\n\t\t\tblock.type === \"text\"\n\t\t\t\t? { type: \"text\", text: block.text }\n\t\t\t\t: {\n\t\t\t\t\t\ttype: \"image\",\n\t\t\t\t\t\tsource: {\n\t\t\t\t\t\t\ttype: \"base64\",\n\t\t\t\t\t\t\tmedia_type: block.mimeType as Base64ImageSource[\"media_type\"],\n\t\t\t\t\t\t\tdata: block.data,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t);\n\t}\n}\n\nexport function buildDeltaPromptBlocks(\n\tmessages: readonly SentMessage[],\n\tcustomToolNameToSdk?: ReadonlyMap<string, string>,\n): ContentBlockParam[] {\n\tconst blocks: ContentBlockParam[] = [];\n\tfor (const [index, message] of messages.entries()) {\n\t\tif (index > 0) blocks.push({ type: \"text\", text: \"\\n\\n\" });\n\t\tif (message.role === \"toolResult\") {\n\t\t\tblocks.push({\n\t\t\t\ttype: \"text\",\n\t\t\t\ttext: `Tool result (${mapPiToolNameToSdk(message.toolName, customToolNameToSdk)}, id=${message.toolCallId}):\\n`,\n\t\t\t});\n\t\t}\n\t\tappendContent(blocks, message.content);\n\t}\n\treturn blocks;\n}\n"]}
1
+ {"version":3,"file":"session-sync.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/claude-sdk-oauth/session-sync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAKzC,OAAO,EAAE,4BAA4B,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAS9E,MAAM,iBAAiB,GAAG,IAAI,OAAO,EAAwC,CAAC;AAE9E,SAAS,WAAW,CAAC,KAAc,EAAE,IAAI,GAAG,IAAI,OAAO,EAAU;IAChE,IAAI,OAAO,KAAK,KAAK,UAAU;QAAE,OAAO,aAAa,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,QAAQ,EAAE,GAAG,CAAC;IACvF,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC,QAAQ,EAAE,CAAC;IACvD,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC9D,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC;QAAE,OAAO,YAAY,CAAC;IACzC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAChB,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QACtC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAC9C,CAAC,CAAC,MAAM,CAAC,WAAW,CAClB,MAAM,CAAC,OAAO,CAAC,KAAgC,CAAC;aAC9C,MAAM,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,IAAI,KAAK,SAAS,CA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,EAAE,KAAK,CAAC,QAA2C;oBAC7D,IAAI,EAAE,KAAK,CAAC,IAAI;iBAChB;aACD,CACH,CAAC;IACH,CAAC;AACF,CAAC;AAED,MAAM,UAAU,sBAAsB,CACrC,QAAgC,EAChC,mBAAiD;IAEjD,MAAM,MAAM,GAAwB,EAAE,CAAC;IACvC,KAAK,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC,IAAI,QAAQ,CAAC,OAAO,EAAE,EAAE,CAAC;QACnD,IAAI,KAAK,GAAG,CAAC;YAAE,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;QAC3D,IAAI,OAAO,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;YACnC,MAAM,CAAC,IAAI,CAAC;gBACX,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,gBAAgB,kBAAkB,CAAC,OAAO,CAAC,QAAQ,EAAE,mBAAmB,CAAC,QAAQ,OAAO,CAAC,UAAU,MAAM;aAC/G,CAAC,CAAC;QACJ,CAAC;QACD,aAAa,CAAC,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IACxC,CAAC;IACD,OAAO,MAAM,CAAC;AACf,CAAC","sourcesContent":["import { createHash } from \"node:crypto\";\nimport type { Context, ImageContent, Message, TextContent } from \"@earendil-works/pi-ai\";\nimport type { ClaudeSdkOauthAuthLane } from \"./options.ts\";\nimport type { Base64ImageSource, ContentBlockParam, Options } from \"./sdk-boundary.ts\";\nimport type { ClaudeSdkOauthSessionEntry } from \"./session-registry.ts\";\nimport { HOST_TOOL_POLICY_FINGERPRINT, mapPiToolNameToSdk } from \"./tools.ts\";\n\nexport type SentMessage = Extract<Message, { role: \"user\" | \"toolResult\" }>;\n\nexport type SessionConfigFingerprint = {\n\tsystemPromptHash: string;\n\ttoolsetHash: string;\n};\n\nconst sentHashesByEntry = new WeakMap<ClaudeSdkOauthSessionEntry, string[]>();\n\nfunction stableValue(value: unknown, seen = new WeakSet<object>()): unknown {\n\tif (typeof value === \"function\") return `[function:${value.name}:${value.toString()}]`;\n\tif (typeof value === \"bigint\") return value.toString();\n\tif (value === null || typeof value !== \"object\") return value;\n\tif (seen.has(value)) return \"[circular]\";\n\tseen.add(value);\n\tconst normalized = Array.isArray(value)\n\t\t? value.map((item) => stableValue(item, seen))\n\t\t: Object.fromEntries(\n\t\t\t\tObject.entries(value as Record<string, unknown>)\n\t\t\t\t\t.filter(([, item]) => item !== undefined)\n\t\t\t\t\t.sort(([left], [right]) => left.localeCompare(right))\n\t\t\t\t\t.map(([key, item]) => [key, stableValue(item, seen)]),\n\t\t\t);\n\tseen.delete(value);\n\treturn normalized;\n}\n\nfunction digest(value: unknown): string {\n\treturn createHash(\"sha256\")\n\t\t.update(JSON.stringify(stableValue(value)))\n\t\t.digest(\"hex\");\n}\n\nexport function sessionSyncDigest(value: unknown): string {\n\treturn digest(value);\n}\n\nexport function sentMessages(context: Context): SentMessage[] {\n\tconst messages = context.messages.filter(\n\t\t(message): message is SentMessage => message.role === \"user\" || message.role === \"toolResult\",\n\t);\n\treturn messages;\n}\n\nexport function sentMessageHashes(messages: readonly SentMessage[]): string[] {\n\tconst hashes = messages.map((message) =>\n\t\tdigest(\n\t\t\tmessage.role === \"user\"\n\t\t\t\t? { role: message.role, content: message.content }\n\t\t\t\t: {\n\t\t\t\t\t\trole: message.role,\n\t\t\t\t\t\ttoolCallId: message.toolCallId,\n\t\t\t\t\t\ttoolName: message.toolName,\n\t\t\t\t\t\tcontent: message.content,\n\t\t\t\t\t},\n\t\t),\n\t);\n\treturn hashes;\n}\n\nfunction prefixDigest(hashes: readonly string[], count = hashes.length): string {\n\treturn digest(hashes.slice(0, count));\n}\n\n/** Pure divergence guard: every non-proven continuation resolves to cold-seed. */\n\nexport function sentHashesForEntry(entry: ClaudeSdkOauthSessionEntry): readonly string[] | undefined {\n\treturn sentHashesByEntry.get(entry);\n}\n\nexport function recordSyncedStream(entry: ClaudeSdkOauthSessionEntry, hashes: readonly string[]): void {\n\tconst copy = [...hashes];\n\tsentHashesByEntry.set(entry, copy);\n\tentry.sentCount = copy.length;\n\tentry.syncedPrefixHash = prefixDigest(copy);\n\tentry.branchInfo = null;\n}\n\nconst GENERATED_DATE_LINE = /\\nCurrent date: \\d{4}-\\d{2}-\\d{2}(?=\\nCurrent working directory: [^\\n]*$)/;\n\n/**\n * The generated date line advances at UTC midnight while the conversation is\n * unchanged; hashing it verbatim retires a live session at midnight for no\n * semantic reason. Only that exact terminal line is neutralized - cwd and every\n * other prompt region stay fail-closed.\n */\nfunction fingerprintSystemPrompt(systemPrompt: Options[\"systemPrompt\"]): unknown {\n\tif (typeof systemPrompt !== \"string\") return systemPrompt ?? null;\n\treturn systemPrompt.replace(GENERATED_DATE_LINE, \"\\nCurrent date: <session-date>\");\n}\n\nexport function configFingerprint(\n\toptions: Options,\n\tcontext: Context,\n\tauthLane: ClaudeSdkOauthAuthLane,\n\taccountName: string,\n): SessionConfigFingerprint {\n\treturn {\n\t\tsystemPromptHash: digest(fingerprintSystemPrompt(options.systemPrompt)),\n\t\ttoolsetHash: digest({\n\t\t\ttools: options.tools ?? [],\n\t\t\treasoning: {\n\t\t\t\tthinking: options.thinking,\n\t\t\t\teffort: options.effort,\n\t\t\t\tmaxThinkingTokens: options.maxThinkingTokens,\n\t\t\t},\n\t\t\tcontextTools: (context.tools ?? []).map((tool) => ({\n\t\t\t\tname: tool.name,\n\t\t\t\tdescription: tool.description,\n\t\t\t\tparameters: tool.parameters,\n\t\t\t})),\n\t\t\tcwd: options.cwd,\n\t\t\tauthLane,\n\t\t\taccountName,\n\t\t\tpermissionMode: options.permissionMode,\n\t\t\thostToolPolicy: HOST_TOOL_POLICY_FINGERPRINT,\n\t\t\tsettingSources: options.settingSources,\n\t\t\textraArgs: options.extraArgs,\n\t\t\tpathToClaudeCodeExecutable: options.pathToClaudeCodeExecutable,\n\t\t\tincludePartialMessages: options.includePartialMessages,\n\t\t}),\n\t};\n}\n\nfunction appendContent(blocks: ContentBlockParam[], content: string | readonly (TextContent | ImageContent)[]): void {\n\tif (typeof content === \"string\") {\n\t\tblocks.push({ type: \"text\", text: content });\n\t\treturn;\n\t}\n\tfor (const block of content) {\n\t\tblocks.push(\n\t\t\tblock.type === \"text\"\n\t\t\t\t? { type: \"text\", text: block.text }\n\t\t\t\t: {\n\t\t\t\t\t\ttype: \"image\",\n\t\t\t\t\t\tsource: {\n\t\t\t\t\t\t\ttype: \"base64\",\n\t\t\t\t\t\t\tmedia_type: block.mimeType as Base64ImageSource[\"media_type\"],\n\t\t\t\t\t\t\tdata: block.data,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t);\n\t}\n}\n\nexport function buildDeltaPromptBlocks(\n\tmessages: readonly SentMessage[],\n\tcustomToolNameToSdk?: ReadonlyMap<string, string>,\n): ContentBlockParam[] {\n\tconst blocks: ContentBlockParam[] = [];\n\tfor (const [index, message] of messages.entries()) {\n\t\tif (index > 0) blocks.push({ type: \"text\", text: \"\\n\\n\" });\n\t\tif (message.role === \"toolResult\") {\n\t\t\tblocks.push({\n\t\t\t\ttype: \"text\",\n\t\t\t\ttext: `Tool result (${mapPiToolNameToSdk(message.toolName, customToolNameToSdk)}, id=${message.toolCallId}):\\n`,\n\t\t\t});\n\t\t}\n\t\tappendContent(blocks, message.content);\n\t}\n\treturn blocks;\n}\n"]}
@@ -0,0 +1,14 @@
1
+ import type { SDKMessage } from "./sdk-boundary.ts";
2
+ import type { ClaudeSdkOauthSessionEntry, ClaudeSdkOauthSessionRegistry } from "./session-registry.ts";
3
+ import type { ActiveTurn } from "./session-turn-types.ts";
4
+ export declare function deliver(entry: ClaudeSdkOauthSessionEntry, turn: ActiveTurn, message: SDKMessage): void;
5
+ export declare function bufferBeforeReplay(registry: ClaudeSdkOauthSessionRegistry, entry: ClaudeSdkOauthSessionEntry, turn: ActiveTurn, message: SDKMessage): void;
6
+ export declare function claimTurn(entry: ClaudeSdkOauthSessionEntry, turn: ActiveTurn): void;
7
+ export declare function isReplayFor(message: SDKMessage, uuid: string): boolean;
8
+ export declare function isAutonomousResult(message: Extract<SDKMessage, {
9
+ type: "result";
10
+ }>): boolean;
11
+ export declare function resultMatchesTurn(message: Extract<SDKMessage, {
12
+ type: "result";
13
+ }>, turn: ActiveTurn): boolean;
14
+ //# sourceMappingURL=session-turn-claim.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-turn-claim.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/claude-sdk-oauth/session-turn-claim.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,KAAK,EAAE,0BAA0B,EAAE,6BAA6B,EAAE,MAAM,uBAAuB,CAAC;AAEvG,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAG1D,wBAAgB,OAAO,CAAC,KAAK,EAAE,0BAA0B,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,UAAU,GAAG,IAAI,CAItG;AAED,wBAAgB,kBAAkB,CACjC,QAAQ,EAAE,6BAA6B,EACvC,KAAK,EAAE,0BAA0B,EACjC,IAAI,EAAE,UAAU,EAChB,OAAO,EAAE,UAAU,GACjB,IAAI,CAON;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,0BAA0B,EAAE,IAAI,EAAE,UAAU,GAAG,IAAI,CAMnF;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAEtE;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,CAAC,UAAU,EAAE;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,CAAC,GAAG,OAAO,CAQ5F;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,CAAC,UAAU,EAAE;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,CAAC,EAAE,IAAI,EAAE,UAAU,GAAG,OAAO,CAK7G"}
@@ -0,0 +1,42 @@
1
+ import { Buffer } from "node:buffer";
2
+ import { transitionToTurnClaimed, transitionToTurnStreaming } from "./session-registry-state.js";
3
+ import { SessionTurnAttributionError } from "./session-turn-types.js";
4
+ export function deliver(entry, turn, message) {
5
+ if (entry.state === "TURN_CLAIMED")
6
+ transitionToTurnStreaming(entry);
7
+ turn.messages.push(message);
8
+ turn.onMessage?.(message);
9
+ }
10
+ export function bufferBeforeReplay(registry, entry, turn, message) {
11
+ turn.preReplay.push(message);
12
+ turn.preReplayBytes += Buffer.byteLength(JSON.stringify(message));
13
+ if (turn.preReplay.length > turn.limits.maxMessages || turn.preReplayBytes > turn.limits.maxBytes) {
14
+ throw new SessionTurnAttributionError("Claude SDK OAuth pre-replay buffer overflow");
15
+ }
16
+ if (!registry.isCurrentGeneration(entry.senpiSessionId, turn.generation))
17
+ turn.preReplay.length = 0;
18
+ }
19
+ export function claimTurn(entry, turn) {
20
+ turn.claimed = true;
21
+ transitionToTurnClaimed(entry);
22
+ for (const buffered of turn.preReplay)
23
+ deliver(entry, turn, buffered);
24
+ turn.preReplay.length = 0;
25
+ turn.preReplayBytes = 0;
26
+ }
27
+ export function isReplayFor(message, uuid) {
28
+ return message.type === "user" && "isReplay" in message && message.isReplay === true && message.uuid === uuid;
29
+ }
30
+ export function isAutonomousResult(message) {
31
+ if (message.origin && message.origin.kind !== "human")
32
+ return true;
33
+ const wire = message;
34
+ return wire.parent_tool_use_id != null || wire.subagent_type != null || wire.isSynthetic === true;
35
+ }
36
+ export function resultMatchesTurn(message, turn) {
37
+ if ("user_message_uuid" in message && message.user_message_uuid !== undefined) {
38
+ return message.user_message_uuid === turn.uuid;
39
+ }
40
+ return turn.claimed && !isAutonomousResult(message);
41
+ }
42
+ //# sourceMappingURL=session-turn-claim.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-turn-claim.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/claude-sdk-oauth/session-turn-cla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AAM,QAAQ,IAAI,IAAI,CAAC,SAAS;QAAE,OAAO,CAAC,KAAK,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;IACtE,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC;IAC1B,IAAI,CAAC,cAAc,GAAG,CAAC,CAAC;AACzB,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,OAAmB,EAAE,IAAY;IAC5D,OAAO,OAAO,CAAC,IAAI,KAAK,MAAM,IAAI,UAAU,IAAI,OAAO,IAAI,OAAO,CAAC,QAAQ,KAAK,IAAI,IAAI,OAAO,CAAC,IAAI,KAAK,IAAI,CAAC;AAC/G,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,OAAgD;IAClF,IAAI,OAAO,CAAC,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,OAAO;QAAE,OAAO,IAAI,CAAC;IACnE,MAAM,IAAI,GAAG,OAIZ,CAAC;IACF,OAAO,IAAI,CAAC,kBAAkB,IAAI,IAAI,IAAI,IAAI,CAAC,aAAa,IAAI,IAAI,IAAI,IAAI,CAAC,WAAW,KAAK,IAAI,CAAC;AACnG,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,OAAgD,EAAE,IAAgB;IACnG,IAAI,mBAAmB,IAAI,OAAO,IAAI,OAAO,CAAC,iBAAiB,KAAK,SAAS,EAAE,CAAC;QAC/E,OAAO,OAAO,CAAC,iBAAiB,KAAK,IAAI,CAAC,IAAI,CAAC;IAChD,CAAC;IACD,OAAO,IAAI,CAAC,OAAO,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC;AACrD,CAAC","sourcesContent":["import { Buffer } from \"node:buffer\";\nimport type { SDKMessage } from \"./sdk-boundary.ts\";\nimport type { ClaudeSdkOauthSessionEntry, ClaudeSdkOauthSessionRegistry } from \"./session-registry.ts\";\nimport { transitionToTurnClaimed, transitionToTurnStreaming } from \"./session-registry-state.ts\";\nimport type { ActiveTurn } from \"./session-turn-types.ts\";\nimport { SessionTurnAttributionError } from \"./session-turn-types.ts\";\n\nexport function deliver(entry: ClaudeSdkOauthSessionEntry, turn: ActiveTurn, message: SDKMessage): void {\n\tif (entry.state === \"TURN_CLAIMED\") transitionToTurnStreaming(entry);\n\tturn.messages.push(message);\n\tturn.onMessage?.(message);\n}\n\nexport function bufferBeforeReplay(\n\tregistry: ClaudeSdkOauthSessionRegistry,\n\tentry: ClaudeSdkOauthSessionEntry,\n\tturn: ActiveTurn,\n\tmessage: SDKMessage,\n): void {\n\tturn.preReplay.push(message);\n\tturn.preReplayBytes += Buffer.byteLength(JSON.stringify(message));\n\tif (turn.preReplay.length > turn.limits.maxMessages || turn.preReplayBytes > turn.limits.maxBytes) {\n\t\tthrow new SessionTurnAttributionError(\"Claude SDK OAuth pre-replay buffer overflow\");\n\t}\n\tif (!registry.isCurrentGeneration(entry.senpiSessionId, turn.generation)) turn.preReplay.length = 0;\n}\n\nexport function claimTurn(entry: ClaudeSdkOauthSessionEntry, turn: ActiveTurn): void {\n\tturn.claimed = true;\n\ttransitionToTurnClaimed(entry);\n\tfor (const buffered of turn.preReplay) deliver(entry, turn, buffered);\n\tturn.preReplay.length = 0;\n\tturn.preReplayBytes = 0;\n}\n\nexport function isReplayFor(message: SDKMessage, uuid: string): boolean {\n\treturn message.type === \"user\" && \"isReplay\" in message && message.isReplay === true && message.uuid === uuid;\n}\n\nexport function isAutonomousResult(message: Extract<SDKMessage, { type: \"result\" }>): boolean {\n\tif (message.origin && message.origin.kind !== \"human\") return true;\n\tconst wire = message as SDKMessage & {\n\t\tparent_tool_use_id?: unknown;\n\t\tsubagent_type?: unknown;\n\t\tisSynthetic?: unknown;\n\t};\n\treturn wire.parent_tool_use_id != null || wire.subagent_type != null || wire.isSynthetic === true;\n}\n\nexport function resultMatchesTurn(message: Extract<SDKMessage, { type: \"result\" }>, turn: ActiveTurn): boolean {\n\tif (\"user_message_uuid\" in message && message.user_message_uuid !== undefined) {\n\t\treturn message.user_message_uuid === turn.uuid;\n\t}\n\treturn turn.claimed && !isAutonomousResult(message);\n}\n"]}
@@ -0,0 +1,32 @@
1
+ import type { SDKMessage } from "./sdk-boundary.ts";
2
+ export interface SessionTurnResult {
3
+ uuid: string;
4
+ messages: SDKMessage[];
5
+ aborted: boolean;
6
+ }
7
+ export interface ActiveTurn {
8
+ uuid: string;
9
+ generation: number;
10
+ messages: SDKMessage[];
11
+ preReplay: SDKMessage[];
12
+ preReplayBytes: number;
13
+ claimed: boolean;
14
+ aborted: boolean;
15
+ interruptReceipt?: unknown;
16
+ onMessage?: (message: SDKMessage) => void;
17
+ signal?: AbortSignal;
18
+ onAbort: () => void;
19
+ cancelAbort?: () => void;
20
+ resolve: (result: SessionTurnResult) => void;
21
+ reject: (error: Error) => void;
22
+ limits: PreReplayBufferLimits;
23
+ }
24
+ export interface PreReplayBufferLimits {
25
+ maxMessages: number;
26
+ maxBytes: number;
27
+ }
28
+ export declare class SessionTurnAttributionError extends Error {
29
+ readonly code = "claude_sdk_oauth_turn_attribution";
30
+ constructor(message: string);
31
+ }
32
+ //# sourceMappingURL=session-turn-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-turn-types.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/claude-sdk-oauth/session-turn-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD,MAAM,WAAW,iBAAiB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,UAAU,EAAE,CAAC;IACvB,OAAO,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,UAAU;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,UAAU,EAAE,CAAC;IACvB,SAAS,EAAE,UAAU,EAAE,CAAC;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,UAAU,KAAK,IAAI,CAAC;IAC1C,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;IACzB,OAAO,EAAE,CAAC,MAAM,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAC7C,MAAM,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IAC/B,MAAM,EAAE,qBAAqB,CAAC;CAC9B;AAED,MAAM,WAAW,qBAAqB;IACrC,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;CACjB;AAED,qBAAa,2BAA4B,SAAQ,KAAK;IACrD,QAAQ,CAAC,IAAI,uCAAuC;IAEpD,YAAY,OAAO,EAAE,MAAM,EAG1B;CACD"}
@@ -0,0 +1,8 @@
1
+ export class SessionTurnAttributionError extends Error {
2
+ constructor(message) {
3
+ super(message);
4
+ this.code = "claude_sdk_oauth_turn_attribution";
5
+ this.name = "SessionTurnAttributionError";
6
+ }
7
+ }
8
+ //# sourceMappingURL=session-turn-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-turn-types.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/claude-sdk-oauth/session-turn-types.ts"],"names":[],"mappings":"AA+BA,MAAM,OAAO,2BAA4B,SAAQ,KAAK;IAGrD,YAAY,OAAe;QAC1B,KAAK,CAAC,OAAO,CAAC,CAAC;QAHP,SAAI,GAAG,mCAAmC,CAAC;QAInD,IAAI,CAAC,IAAI,GAAG,6BAA6B,CAAC;IAC3C,CAAC;CACD","sourcesContent":["import type { SDKMessage } from \"./sdk-boundary.ts\";\n\nexport interface SessionTurnResult {\n\tuuid: string;\n\tmessages: SDKMessage[];\n\taborted: boolean;\n}\n\nexport interface ActiveTurn {\n\tuuid: string;\n\tgeneration: number;\n\tmessages: SDKMessage[];\n\tpreReplay: SDKMessage[];\n\tpreReplayBytes: number;\n\tclaimed: boolean;\n\taborted: boolean;\n\tinterruptReceipt?: unknown;\n\tonMessage?: (message: SDKMessage) => void;\n\tsignal?: AbortSignal;\n\tonAbort: () => void;\n\tcancelAbort?: () => void;\n\tresolve: (result: SessionTurnResult) => void;\n\treject: (error: Error) => void;\n\tlimits: PreReplayBufferLimits;\n}\n\nexport interface PreReplayBufferLimits {\n\tmaxMessages: number;\n\tmaxBytes: number;\n}\n\nexport class SessionTurnAttributionError extends Error {\n\treadonly code = \"claude_sdk_oauth_turn_attribution\";\n\n\tconstructor(message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"SessionTurnAttributionError\";\n\t}\n}\n"]}
@@ -0,0 +1,16 @@
1
+ import type { Api, AssistantMessage, AssistantMessageEventStream, Model } from "@earendil-works/pi-ai";
2
+ import type { SDKMessage } from "./sdk-boundary.ts";
3
+ import { type StreamBlock } from "./stream-protocol.ts";
4
+ export type StreamEventContext = {
5
+ model: Model<Api>;
6
+ output: AssistantMessage;
7
+ blocks: StreamBlock[];
8
+ stream: AssistantMessageEventStream;
9
+ customToolNameToPi: ReadonlyMap<string, string>;
10
+ };
11
+ type StreamEvent = Extract<SDKMessage, {
12
+ type: "stream_event";
13
+ }>["event"];
14
+ export declare function applyStreamEvent(context: StreamEventContext, event: StreamEvent): void;
15
+ export {};
16
+ //# sourceMappingURL=stream-events.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stream-events.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/claude-sdk-oauth/stream-events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,gBAAgB,EAAE,2BAA2B,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAEvG,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAIN,KAAK,WAAW,EAKhB,MAAM,sBAAsB,CAAC;AAG9B,MAAM,MAAM,kBAAkB,GAAG;IAChC,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;IAClB,MAAM,EAAE,gBAAgB,CAAC;IACzB,MAAM,EAAE,WAAW,EAAE,CAAC;IACtB,MAAM,EAAE,2BAA2B,CAAC;IACpC,kBAAkB,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAChD,CAAC;AAEF,KAAK,WAAW,GAAG,OAAO,CAAC,UAAU,EAAE;IAAE,IAAI,EAAE,cAAc,CAAA;CAAE,CAAC,CAAC,OAAO,CAAC,CAAC;AAsE1E,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,kBAAkB,EAAE,KAAK,EAAE,WAAW,GAAG,IAAI,CAatF"}
@@ -0,0 +1,92 @@
1
+ import { parseStreamingJson } from "@earendil-works/pi-ai";
2
+ import { asRecord, mapStopReason, mapToolArguments, updateUsage, } from "./stream-protocol.js";
3
+ import { mapSdkToolNameToPi } from "./tools.js";
4
+ function openBlock(context, block, kind) {
5
+ context.blocks.push(block);
6
+ context.output.content.push(block);
7
+ context.stream.push({
8
+ type: `${kind}_start`,
9
+ contentIndex: context.output.content.length - 1,
10
+ partial: context.output,
11
+ });
12
+ }
13
+ function startContentBlock(context, event) {
14
+ if (event.content_block.type === "text") {
15
+ openBlock(context, { type: "text", text: "", index: event.index }, "text");
16
+ return;
17
+ }
18
+ if (event.content_block.type === "thinking") {
19
+ const block = { type: "thinking", thinking: "", thinkingSignature: "", index: event.index };
20
+ openBlock(context, block, "thinking");
21
+ return;
22
+ }
23
+ if (event.content_block.type === "tool_use") {
24
+ const block = {
25
+ type: "toolCall",
26
+ id: event.content_block.id,
27
+ name: mapSdkToolNameToPi(event.content_block.name, context.customToolNameToPi),
28
+ arguments: asRecord(event.content_block.input),
29
+ partialJson: "",
30
+ index: event.index,
31
+ };
32
+ openBlock(context, block, "toolcall");
33
+ }
34
+ }
35
+ function applyDelta(context, event) {
36
+ const { blocks, stream, output } = context;
37
+ const contentIndex = blocks.findIndex((candidate) => candidate.index === event.index);
38
+ const block = blocks[contentIndex];
39
+ if (event.delta.type === "text_delta" && block?.type === "text") {
40
+ block.text += event.delta.text;
41
+ stream.push({ type: "text_delta", contentIndex, delta: event.delta.text, partial: output });
42
+ }
43
+ else if (event.delta.type === "thinking_delta" && block?.type === "thinking") {
44
+ block.thinking += event.delta.thinking;
45
+ stream.push({ type: "thinking_delta", contentIndex, delta: event.delta.thinking, partial: output });
46
+ }
47
+ else if (event.delta.type === "signature_delta" && block?.type === "thinking") {
48
+ block.thinkingSignature += event.delta.signature;
49
+ }
50
+ else if (event.delta.type === "input_json_delta" && block?.type === "toolCall") {
51
+ block.partialJson = `${block.partialJson ?? ""}${event.delta.partial_json}`;
52
+ block.arguments = parseStreamingJson(block.partialJson);
53
+ stream.push({ type: "toolcall_delta", contentIndex, delta: event.delta.partial_json, partial: output });
54
+ }
55
+ }
56
+ function closeContentBlock(context, event) {
57
+ const { blocks, stream, output } = context;
58
+ const contentIndex = blocks.findIndex((candidate) => candidate.index === event.index);
59
+ const block = blocks[contentIndex];
60
+ if (block?.type === "text") {
61
+ stream.push({ type: "text_end", contentIndex, content: block.text, partial: output });
62
+ }
63
+ else if (block?.type === "thinking") {
64
+ stream.push({ type: "thinking_end", contentIndex, content: block.thinking, partial: output });
65
+ }
66
+ else if (block?.type === "toolCall") {
67
+ block.arguments = mapToolArguments(block.name, parseStreamingJson(block.partialJson));
68
+ delete block.partialJson;
69
+ stream.push({ type: "toolcall_end", contentIndex, toolCall: block, partial: output });
70
+ }
71
+ if (block)
72
+ delete block.index;
73
+ }
74
+ export function applyStreamEvent(context, event) {
75
+ if (event.type === "message_start") {
76
+ updateUsage(context.model, context.output, event.message.usage);
77
+ }
78
+ else if (event.type === "content_block_start") {
79
+ startContentBlock(context, event);
80
+ }
81
+ else if (event.type === "content_block_delta") {
82
+ applyDelta(context, event);
83
+ }
84
+ else if (event.type === "content_block_stop") {
85
+ closeContentBlock(context, event);
86
+ }
87
+ else if (event.type === "message_delta") {
88
+ context.output.stopReason = mapStopReason(event.delta.stop_reason);
89
+ updateUsage(context.model, context.output, event.usage);
90
+ }
91
+ }
92
+ //# sourceMappingURL=stream-events.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stream-events.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/claude-sdk-oauth/stream-events.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAE3D,OAAO,EACN,QAAQ,EACR,aAAa,EACb,gBAAgB,EAKhB,WAAW,GACX,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAYhD,SAAS,SAAS,CAAC,OAA2B,EAAE,KAAkB,EAAE,IAAsC;IACzG,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC3B,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,KAA4C,CAAC,CAAC;IAC1E,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC;QACnB,IAAI,EAAE,GAAG,IAAI,QAAQ;QACrB,YAAY,EAAE,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC;QAC/C,OAAO,EAAE,OAAO,CAAC,MAAM;KAC+B,CAAC,CAAC;AAC1D,CAAC;AAED,SAAS,iBAAiB,CAAC,OAA2B,EAAE,KAA4D;IACnH,IAAI,KAAK,CAAC,aAAa,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;QACzC,SAAS,CAAC,OAAO,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAsB,EAAE,MAAM,CAAC,CAAC;QAC/F,OAAO;IACR,CAAC;IACD,IAAI,KAAK,CAAC,aAAa,CAAC,IAAI,KAAK,UAAU,EAAE,C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AE,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IACjE,CAAC;SAAM,IAAI,KAAK,CAAC,IAAI,KAAK,qBAAqB,EAAE,CAAC;QACjD,iBAAiB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IACnC,CAAC;SAAM,IAAI,KAAK,CAAC,IAAI,KAAK,qBAAqB,EAAE,CAAC;QACjD,UAAU,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IAC5B,CAAC;SAAM,IAAI,KAAK,CAAC,IAAI,KAAK,oBAAoB,EAAE,CAAC;QAChD,iBAAiB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IACnC,CAAC;SAAM,IAAI,KAAK,CAAC,IAAI,KAAK,eAAe,EAAE,CAAC;QAC3C,OAAO,CAAC,MAAM,CAAC,UAAU,GAAG,aAAa,CAAC,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;QACnE,WAAW,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,MAAM,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;IACzD,CAAC;AACF,CAAC","sourcesContent":["import type { Api, AssistantMessage, AssistantMessageEventStream, Model } from \"@earendil-works/pi-ai\";\nimport { parseStreamingJson } from \"@earendil-works/pi-ai\";\nimport type { SDKMessage } from \"./sdk-boundary.ts\";\nimport {\n\tasRecord,\n\tmapStopReason,\n\tmapToolArguments,\n\ttype StreamBlock,\n\ttype TextBlock,\n\ttype ThinkingBlock,\n\ttype ToolBlock,\n\tupdateUsage,\n} from \"./stream-protocol.ts\";\nimport { mapSdkToolNameToPi } from \"./tools.ts\";\n\nexport type StreamEventContext = {\n\tmodel: Model<Api>;\n\toutput: AssistantMessage;\n\tblocks: StreamBlock[];\n\tstream: AssistantMessageEventStream;\n\tcustomToolNameToPi: ReadonlyMap<string, string>;\n};\n\ntype StreamEvent = Extract<SDKMessage, { type: \"stream_event\" }>[\"event\"];\n\nfunction openBlock(context: StreamEventContext, block: StreamBlock, kind: \"text\" | \"thinking\" | \"toolcall\"): void {\n\tcontext.blocks.push(block);\n\tcontext.output.content.push(block as AssistantMessage[\"content\"][number]);\n\tcontext.stream.push({\n\t\ttype: `${kind}_start`,\n\t\tcontentIndex: context.output.content.length - 1,\n\t\tpartial: context.output,\n\t} as Parameters<AssistantMessageEventStream[\"push\"]>[0]);\n}\n\nfunction startContentBlock(context: StreamEventContext, event: Extract<StreamEvent, { type: \"content_block_start\" }>) {\n\tif (event.content_block.type === \"text\") {\n\t\topenBlock(context, { type: \"text\", text: \"\", index: event.index } satisfies TextBlock, \"text\");\n\t\treturn;\n\t}\n\tif (event.content_block.type === \"thinking\") {\n\t\tconst block: ThinkingBlock = { type: \"thinking\", thinking: \"\", thinkingSignature: \"\", index: event.index };\n\t\topenBlock(context, block, \"thinking\");\n\t\treturn;\n\t}\n\tif (event.content_block.type === \"tool_use\") {\n\t\tconst block: ToolBlock = {\n\t\t\ttype: \"toolCall\",\n\t\t\tid: event.content_block.id,\n\t\t\tname: mapSdkToolNameToPi(event.content_block.name, context.customToolNameToPi),\n\t\t\targuments: asRecord(event.content_block.input),\n\t\t\tpartialJson: \"\",\n\t\t\tindex: event.index,\n\t\t};\n\t\topenBlock(context, block, \"toolcall\");\n\t}\n}\n\nfunction applyDelta(context: StreamEventContext, event: Extract<StreamEvent, { type: \"content_block_delta\" }>): void {\n\tconst { blocks, stream, output } = context;\n\tconst contentIndex = blocks.findIndex((candidate) => candidate.index === event.index);\n\tconst block = blocks[contentIndex];\n\tif (event.delta.type === \"text_delta\" && block?.type === \"text\") {\n\t\tblock.text += event.delta.text;\n\t\tstream.push({ type: \"text_delta\", contentIndex, delta: event.delta.text, partial: output });\n\t} else if (event.delta.type === \"thinking_delta\" && block?.type === \"thinking\") {\n\t\tblock.thinking += event.delta.thinking;\n\t\tstream.push({ type: \"thinking_delta\", contentIndex, delta: event.delta.thinking, partial: output });\n\t} else if (event.delta.type === \"signature_delta\" && block?.type === \"thinking\") {\n\t\tblock.thinkingSignature += event.delta.signature;\n\t} else if (event.delta.type === \"input_json_delta\" && block?.type === \"toolCall\") {\n\t\tblock.partialJson = `${block.partialJson ?? \"\"}${event.delta.partial_json}`;\n\t\tblock.arguments = parseStreamingJson<Record<string, unknown>>(block.partialJson);\n\t\tstream.push({ type: \"toolcall_delta\", contentIndex, delta: event.delta.partial_json, partial: output });\n\t}\n}\n\nfunction closeContentBlock(context: StreamEventContext, event: Extract<StreamEvent, { type: \"content_block_stop\" }>) {\n\tconst { blocks, stream, output } = context;\n\tconst contentIndex = blocks.findIndex((candidate) => candidate.index === event.index);\n\tconst block = blocks[contentIndex];\n\tif (block?.type === \"text\") {\n\t\tstream.push({ type: \"text_end\", contentIndex, content: block.text, partial: output });\n\t} else if (block?.type === \"thinking\") {\n\t\tstream.push({ type: \"thinking_end\", contentIndex, content: block.thinking, partial: output });\n\t} else if (block?.type === \"toolCall\") {\n\t\tblock.arguments = mapToolArguments(block.name, parseStreamingJson<Record<string, unknown>>(block.partialJson));\n\t\tdelete block.partialJson;\n\t\tstream.push({ type: \"toolcall_end\", contentIndex, toolCall: block, partial: output });\n\t}\n\tif (block) delete block.index;\n}\n\nexport function applyStreamEvent(context: StreamEventContext, event: StreamEvent): void {\n\tif (event.type === \"message_start\") {\n\t\tupdateUsage(context.model, context.output, event.message.usage);\n\t} else if (event.type === \"content_block_start\") {\n\t\tstartContentBlock(context, event);\n\t} else if (event.type === \"content_block_delta\") {\n\t\tapplyDelta(context, event);\n\t} else if (event.type === \"content_block_stop\") {\n\t\tcloseContentBlock(context, event);\n\t} else if (event.type === \"message_delta\") {\n\t\tcontext.output.stopReason = mapStopReason(event.delta.stop_reason);\n\t\tupdateUsage(context.model, context.output, event.usage);\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/claude-sdk-oauth/stream.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,GAAG,EACR,KAAK,2BAA2B,EAChC,KAAK,OAAO,EAGZ,KAAK,KAAK,EAEV,KAAK,mBAAmB,EACxB,MAAM,uBAAuB,CAAC;AA0B/B,wBAAgB,oBAAoB,CACnC,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,EACjB,OAAO,EAAE,OAAO,EAChB,OAAO,CAAC,EAAE,mBAAmB,GAC3B,2BAA2B,CA0N7B"}
1
+ {"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/claude-sdk-oauth/stream.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,GAAG,EACR,KAAK,2BAA2B,EAChC,KAAK,OAAO,EAGZ,KAAK,KAAK,EACV,KAAK,mBAAmB,EACxB,MAAM,uBAAuB,CAAC;AAiB/B,wBAAgB,oBAAoB,CACnC,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,EACjB,OAAO,EAAE,OAAO,EAChB,OAAO,CAAC,EAAE,mBAAmB,GAC3B,2BAA2B,CA4L7B"}