@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
@@ -45,12 +45,15 @@ export declare class AuthStorage implements CredentialStore {
45
45
  private readonly extensionOAuthProviders;
46
46
  private errors;
47
47
  private storage;
48
+ private authPath;
49
+ private readState;
48
50
  private constructor();
49
51
  static create(authPath?: string): AuthStorage;
50
52
  static fromStorage(storage: AuthStorageBackend): AuthStorage;
51
53
  static inMemory(data?: AuthStorageData): AuthStorage;
52
54
  private parseStorageData;
53
55
  private recordError;
56
+ private updateReadState;
54
57
  /**
55
58
  * Reload credentials from storage.
56
59
  */
@@ -67,6 +70,8 @@ export declare class AuthStorage implements CredentialStore {
67
70
  getAuthStatus(provider: string): AuthStatus;
68
71
  getAll(): AuthStorageData;
69
72
  drainErrors(): Error[];
73
+ private reloadFromStorageAsync;
74
+ private readLatestData;
70
75
  read(provider: string): Promise<Credential | undefined>;
71
76
  modify(provider: string, fn: (current: Credential | undefined) => Promise<Credential | undefined>): Promise<Credential | undefined>;
72
77
  delete(provider: string): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"auth-storage.d.ts","sourceRoot":"","sources":["../../src/core/auth-storage.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACX,gBAAgB,EAIhB,UAAU,EACV,cAAc,EACd,eAAe,EACf,SAAS,EACT,eAAe,EACf,mBAAmB,EACnB,MAAM,uBAAuB,CAAC;AAU/B,KAAK,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;AAElD,MAAM,MAAM,cAAc,GAAG,UAAU,CAAC;AACxC,YAAY,EAAE,gBAAgB,EAAE,eAAe,EAAE,CAAC;AAClD,MAAM,MAAM,UAAU,GAAG;IACxB,UAAU,EAAE,OAAO,CAAC;IAC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GAAG,SAAS,CAAC,CAkBjC;IAEK,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAU5C;IAED,wEAAwE;IAClE,IAAI,IAAI,OAAO,CAAC,SAAS,cAAc,EAAE,CAAC,CAW/C;IAEK,SAAS,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,GAAE,gBAAqB,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAqB/F;IAED,qBAAqB,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,GAAG,IAAI,CAEhE;IAED,uBAAuB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAEhD;IAED,iBAAiB,IAAI,KAAK,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAWvD;IAEK,KAAK,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CAY7E;IAED,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAG7B;IAED,OAAO,CAAC,kBAAkB;IAe1B,OAAO,CAAC,iBAAiB;CAgBzB;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CACnC,UAAU,EAAE,MAAM,EAClB,QAAQ,GAAE,MAAyC,GACjD,UAAU,GAAG,SAAS,CAOxB"}
@@ -4,13 +4,23 @@
4
4
  */
5
5
  import { findEnvKeys, getEnvApiKey } from "@earendil-works/pi-ai";
6
6
  import { builtinProviders } from "@earendil-works/pi-ai/providers/all";
7
- import { chmodSync, existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
7
+ import { chmodSync, existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from "fs";
8
8
  import { dirname, join } from "path";
9
9
  import lockfile from "proper-lockfile";
10
10
  import { getAgentDir } from "../config.js";
11
11
  import { normalizePath } from "../utils/paths.js";
12
12
  import { resolveConfigValue } from "./resolve-config-value.js";
13
13
  const AUTH_FILE_WRITE_OPTIONS = { encoding: "utf-8", mode: 0o600 };
14
+ let sharedAuthFileReadState;
15
+ function getFileRevision(path) {
16
+ try {
17
+ const stats = statSync(path, { bigint: true });
18
+ return `${stats.dev}:${stats.ino}:${stats.size}:${stats.mtimeNs}:${stats.ctimeNs}`;
19
+ }
20
+ catch {
21
+ return undefined;
22
+ }
23
+ }
14
24
  export class FileAuthStorageBackend {
15
25
  constructor(authPath = join(getAgentDir(), "auth.json")) {
16
26
  this.authPath = normalizePath(authPath);
@@ -140,16 +150,26 @@ export class InMemoryAuthStorageBackend {
140
150
  * Credential storage backed by a JSON file.
141
151
  */
142
152
  export class AuthStorage {
143
- constructor(storage) {
153
+ constructor(storage, authPath) {
144
154
  this.data = {};
145
155
  this.runtimeOverrides = new Map();
146
156
  this.extensionOAuthProviders = new Map();
147
157
  this.errors = [];
148
158
  this.storage = storage;
159
+ this.authPath = authPath;
160
+ this.readState =
161
+ authPath && sharedAuthFileReadState?.authPath === authPath ? sharedAuthFileReadState.readState : { data: {} };
162
+ if (authPath) {
163
+ sharedAuthFileReadState = { authPath, readState: this.readState };
164
+ const revision = getFileRevision(authPath);
165
+ if (revision !== undefined && revision === this.readState.revision)
166
+ return;
167
+ }
149
168
  this.reload();
150
169
  }
151
- static create(authPath) {
152
- return new AuthStorage(new FileAuthStorageBackend(authPath ?? join(getAgentDir(), "auth.json")));
170
+ static create(authPath = join(getAgentDir(), "auth.json")) {
171
+ const normalizedAuthPath = normalizePath(authPath);
172
+ return new AuthStorage(new FileAuthStorageBackend(normalizedAuthPath), normalizedAuthPath);
153
173
  }
154
174
  static fromStorage(storage) {
155
175
  return new AuthStorage(storage);
@@ -168,17 +188,24 @@ export class AuthStorage {
168
188
  recordError(error) {
169
189
  this.errors.push(error instanceof Error ? error : new Error(String(error)));
170
190
  }
191
+ updateReadState(data, revision) {
192
+ this.data = data;
193
+ this.readState.data = data;
194
+ this.readState.revision = revision;
195
+ }
171
196
  /**
172
197
  * Reload credentials from storage.
173
198
  */
174
199
  reload() {
175
200
  let content;
201
+ let revision;
176
202
  try {
177
203
  this.storage.withLock((current) => {
178
204
  content = current;
205
+ revision = this.authPath ? getFileRevision(this.authPath) : undefined;
179
206
  return { result: undefined };
180
207
  });
181
- this.data = this.parseStorageData(content);
208
+ this.updateReadState(this.parseStorageData(content), revision);
182
209
  }
183
210
  catch (error) {
184
211
  // Preserve the last valid in-memory snapshot.
@@ -238,11 +265,38 @@ export class AuthStorage {
238
265
  this.errors = [];
239
266
  return errors;
240
267
  }
268
+ async reloadFromStorageAsync() {
269
+ return this.storage.withLockAsync(async (content) => {
270
+ const currentData = this.parseStorageData(content);
271
+ const revision = this.authPath ? getFileRevision(this.authPath) : undefined;
272
+ this.updateReadState(currentData, revision);
273
+ return { result: currentData };
274
+ });
275
+ }
276
+ async readLatestData() {
277
+ if (this.authPath) {
278
+ const revision = getFileRevision(this.authPath);
279
+ if (revision !== undefined && revision === this.readState.revision)
280
+ return this.readState.data;
281
+ }
282
+ if (!this.readState.reload) {
283
+ this.readState.reload = this.reloadFromStorageAsync().catch((error) => {
284
+ this.recordError(error);
285
+ return this.readState.data;
286
+ });
287
+ }
288
+ try {
289
+ return await this.readState.reload;
290
+ }
291
+ finally {
292
+ this.readState.reload = undefined;
293
+ }
294
+ }
241
295
  async read(provider) {
242
296
  const runtimeKey = this.runtimeOverrides.get(provider);
243
297
  if (runtimeKey)
244
298
  return { type: "api_key", key: runtimeKey };
245
- const credential = this.data[provider];
299
+ const credential = (await this.readLatestData())[provider];
246
300
  if (credential?.type !== "api_key")
247
301
  return credential;
248
302
  if (credential.key === undefined)
@@ -250,30 +304,37 @@ export class AuthStorage {
250
304
  return { ...credential, key: resolveConfigValue(credential.key, credential.env) };
251
305
  }
252
306
  async modify(provider, fn) {
253
- return this.storage.withLockAsync(async (content) => {
307
+ let latestData = this.readState.data;
308
+ let revision;
309
+ const result = await this.storage.withLockAsync(async (content) => {
254
310
  const currentData = this.parseStorageData(content);
255
311
  const next = await fn(currentData[provider]);
256
312
  if (next === undefined) {
257
- this.data = currentData;
313
+ latestData = currentData;
314
+ revision = this.authPath ? getFileRevision(this.authPath) : undefined;
258
315
  return { result: currentData[provider] };
259
316
  }
260
317
  const merged = { ...currentData, [provider]: next };
261
- this.data = merged;
318
+ latestData = merged;
262
319
  return { result: next, next: JSON.stringify(merged, null, 2) };
263
320
  });
321
+ this.updateReadState(latestData, revision);
322
+ return result;
264
323
  }
265
324
  async delete(provider) {
266
325
  this.runtimeOverrides.delete(provider);
326
+ let latestData = this.readState.data;
267
327
  await this.storage.withLockAsync(async (content) => {
268
328
  const currentData = this.parseStorageData(content);
269
329
  delete currentData[provider];
270
- this.data = currentData;
330
+ latestData = currentData;
271
331
  return { result: undefined, next: JSON.stringify(currentData, null, 2) };
272
332
  });
333
+ this.updateReadState(latestData);
273
334
  }
274
335
  /** List credential metadata without resolving configured key values. */
275
336
  async list() {
276
- const entries = new Map(Object.entries(this.data).map(([providerId, credential]) => [
337
+ const entries = new Map(Object.entries(await this.readLatestData()).map(([providerId, credential]) => [
277
338
  providerId,
278
339
  { providerId, type: credential.type },
279
340
  ]));
@@ -1 +1 @@
1
- {"version":3,"file":"auth-storage.js","sourceRoot":"","sources":["../../src/core/auth-storage.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAcH,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AACvE,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AACnF,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,QAAQ,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;A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IAAI,CAAC,CAAC,KAAK,EAAE,EAAE;oBAChD,IAAI,KAAK,KAAK,SAAS;wBAAE,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;oBAC5D,OAAO,KAAK,CAAC;gBACd,CAAC,CAAC,CAAC;YACJ,KAAK,QAAQ,CAAC;YACd,KAAK,MAAM;gBACV,OAAO,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QACpC,CAAC;IACF,CAAC;IAEO,iBAAiB,CAAC,KAAgB,EAAE,SAA8B;QACzE,QAAQ,KAAK,CAAC,IAAI,EAAE,CAAC;YACpB,KAAK,UAAU;gBACd,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;gBACxB,MAAM;YACP,KAAK,aAAa;gBACjB,SAAS,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;gBAC9B,MAAM;YACP,KAAK,MAAM;gBACV,SAAS,CAAC,UAAU,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;gBACtC,MAAM;YACP,KAAK,UAAU;gBACd,SAAS,CAAC,UAAU,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;gBACtC,MAAM;QACR,CAAC;IACF,CAAC;CACD;AAED;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CACnC,UAAkB,EAClB,QAAQ,GAAW,IAAI,CAAC,WAAW,EAAE,EAAE,WAAW,CAAC;IAEnD,IAAI,CAAC;QACJ,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,aAAa,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,CAAoB,CAAC;QAC3F,OAAO,IAAI,CAAC,UAAU,CAAC,CAAC;IACzB,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,SAAS,CAAC;IAClB,CAAC;AACF,CAAC","sourcesContent":["/**\n * CredentialStore implementation backed by auth.json.\n * Provider auth orchestration belongs to ModelRuntime and pi-ai Models.\n */\n\nimport type {\n\tApiKeyCredential,\n\tAuthEvent,\n\tAuthInteraction,\n\tAuthPrompt,\n\tCredential,\n\tCredentialInfo,\n\tCredentialStore,\n\tOAuthAuth,\n\tOAuthCredential,\n\tOAuthLoginCallbacks,\n} from \"@earendil-works/pi-ai\";\nimport { findEnvKeys, getEnvApiKey } from \"@earendil-works/pi-ai\";\nimport { builtinProviders } from \"@earendil-works/pi-ai/providers/all\";\nimport { chmodSync, existsSync, mkdirSync, readFileSync, writeFileSync } from \"fs\";\nimport { dirname, join } from \"path\";\nimport lockfile from \"proper-lockfile\";\nimport { getAgentDir } from \"../config.ts\";\nimport { normalizePath } from \"../utils/paths.ts\";\nimport { resolveConfigValue } from \"./resolve-config-value.ts\";\n\ntype AuthStorageData = Record<string, Credential>;\n\nexport type AuthCredential = Credential;\nexport type { ApiKeyCredential, OAuthCredential };\nexport type AuthStatus = {\n\tconfigured: boolean;\n\tsource?: \"stored\" | \"runtime\" | \"environment\" | \"fallback\" | \"models_json_key\" | \"models_json_command\";\n\tlabel?: string;\n};\n\nexport interface GetApiKeyOptions {\n\tincludeFallback?: boolean;\n}\n\ntype LockResult<T> = {\n\tresult: T;\n\tnext?: string;\n};\n\nconst AUTH_FILE_WRITE_OPTIONS = { encoding: \"utf-8\", mode: 0o600 } as const;\n\nexport interface AuthStorageBackend {\n\twithLock<T>(fn: (current: string | undefined) => LockResult<T>): T;\n\twithLockAsync<T>(fn: (current: string | undefined) => Promise<LockResult<T>>): Promise<T>;\n}\n\nexport class FileAuthStorageBackend implements AuthStorageBackend {\n\tprivate authPath: string;\n\n\tconstructor(authPath: string = join(getAgentDir(), \"auth.json\")) {\n\t\tthis.authPath = normalizePath(authPath);\n\t}\n\n\tprivate ensureParentDir(): void {\n\t\tconst dir = dirname(this.authPath);\n\t\tif (!existsSync(dir)) {\n\t\t\tmkdirSync(dir, { recursive: true, mode: 0o700 });\n\t\t}\n\t}\n\n\tprivate ensureFileExists(): void {\n\t\tif (!existsSync(this.authPath)) {\n\t\t\twriteFileSync(this.authPath, \"{}\", AUTH_FILE_WRITE_OPTIONS);\n\t\t\tchmodSync(this.authPath, 0o600);\n\t\t}\n\t}\n\n\tprivate acquireLockSyncWithRetry(path: string): () => void {\n\t\tconst maxAttempts = 10;\n\t\tconst delayMs = 20;\n\t\tlet lastError: unknown;\n\n\t\tfor (let attempt = 1; attempt <= maxAttempts; attempt++) {\n\t\t\ttry {\n\t\t\t\treturn lockfile.lockSync(path, { realpath: false });\n\t\t\t} catch (error) {\n\t\t\t\tconst code =\n\t\t\t\t\ttypeof error === \"object\" && error !== null && \"code\" in error\n\t\t\t\t\t\t? String((error as { code?: unknown }).code)\n\t\t\t\t\t\t: undefined;\n\t\t\t\tif (code !== \"ELOCKED\" || attempt === maxAttempts) {\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t\tlastError = error;\n\t\t\t\tconst start = Date.now();\n\t\t\t\twhile (Date.now() - start < delayMs) {\n\t\t\t\t\t// Sleep synchronously to avoid changing callers to async.\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tthrow (lastError as Error) ?? new Error(\"Failed to acquire auth storage lock\");\n\t}\n\n\twithLock<T>(fn: (current: string | undefined) => LockResult<T>): T {\n\t\tthis.ensureParentDir();\n\t\tthis.ensureFileExists();\n\n\t\tlet release: (() => void) | undefined;\n\t\ttry {\n\t\t\trelease = this.acquireLockSyncWithRetry(this.authPath);\n\t\t\tconst current = existsSync(this.authPath) ? readFileSync(this.authPath, \"utf-8\") : undefined;\n\t\t\tconst { result, next } = fn(current);\n\t\t\tif (next !== undefined) {\n\t\t\t\twriteFileSync(this.authPath, next, AUTH_FILE_WRITE_OPTIONS);\n\t\t\t\tchmodSync(this.authPath, 0o600);\n\t\t\t}\n\t\t\treturn result;\n\t\t} finally {\n\t\t\tif (release) {\n\t\t\t\trelease();\n\t\t\t}\n\t\t}\n\t}\n\n\tasync withLockAsync<T>(fn: (current: string | undefined) => Promise<LockResult<T>>): Promise<T> {\n\t\tthis.ensureParentDir();\n\t\tthis.ensureFileExists();\n\n\t\tlet release: (() => Promise<void>) | undefined;\n\t\tlet lockCompromised = false;\n\t\tlet lockCompromisedError: Error | undefined;\n\t\tconst throwIfCompromised = () => {\n\t\t\tif (lockCompromised) {\n\t\t\t\tthrow lockCompromisedError ?? new Error(\"Auth storage lock was compromised\");\n\t\t\t}\n\t\t};\n\n\t\ttry {\n\t\t\trelease = await lockfile.lock(this.authPath, {\n\t\t\t\tretries: {\n\t\t\t\t\tretries: 10,\n\t\t\t\t\tfactor: 2,\n\t\t\t\t\tminTimeout: 100,\n\t\t\t\t\tmaxTimeout: 10000,\n\t\t\t\t\trandomize: true,\n\t\t\t\t},\n\t\t\t\tstale: 30000,\n\t\t\t\tonCompromised: (err) => {\n\t\t\t\t\tlockCompromised = true;\n\t\t\t\t\tlockCompromisedError = err;\n\t\t\t\t},\n\t\t\t});\n\n\t\t\tthrowIfCompromised();\n\t\t\tconst current = existsSync(this.authPath) ? readFileSync(this.authPath, \"utf-8\") : undefined;\n\t\t\tconst { result, next } = await fn(current);\n\t\t\tthrowIfCompromised();\n\t\t\tif (next !== undefined) {\n\t\t\t\twriteFileSync(this.authPath, next, AUTH_FILE_WRITE_OPTIONS);\n\t\t\t\tchmodSync(this.authPath, 0o600);\n\t\t\t}\n\t\t\tthrowIfCompromised();\n\t\t\treturn result;\n\t\t} finally {\n\t\t\tif (release) {\n\t\t\t\ttry {\n\t\t\t\t\tawait release();\n\t\t\t\t} catch {\n\t\t\t\t\t// Ignore unlock errors when lock is compromised.\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\nexport class InMemoryAuthStorageBackend implements AuthStorageBackend {\n\tprivate value: string | undefined;\n\n\twithLock<T>(fn: (current: string | undefined) => LockResult<T>): T {\n\t\tconst { result, next } = fn(this.value);\n\t\tif (next !== undefined) {\n\t\t\tthis.value = next;\n\t\t}\n\t\treturn result;\n\t}\n\n\tasync withLockAsync<T>(fn: (current: string | undefined) => Promise<LockResult<T>>): Promise<T> {\n\t\tconst { result, next } = await fn(this.value);\n\t\tif (next !== undefined) {\n\t\t\tthis.value = next;\n\t\t}\n\t\treturn result;\n\t}\n}\n\n/**\n * Credential storage backed by a JSON file.\n */\nexport class AuthStorage implements CredentialStore {\n\tprivate data: AuthStorageData = {};\n\tprivate readonly runtimeOverrides = new Map<string, string>();\n\tprivate readonly extensionOAuthProviders = new Map<string, OAuthAuth>();\n\tprivate errors: Error[] = [];\n\tprivate storage: AuthStorageBackend;\n\n\tprivate constructor(storage: AuthStorageBackend) {\n\t\tthis.storage = storage;\n\t\tthis.reload();\n\t}\n\n\tstatic create(authPath?: string): AuthStorage {\n\t\treturn new AuthStorage(new FileAuthStorageBackend(authPath ?? join(getAgentDir(), \"auth.json\")));\n\t}\n\n\tstatic fromStorage(storage: AuthStorageBackend): AuthStorage {\n\t\treturn new AuthStorage(storage);\n\t}\n\n\tstatic inMemory(data: AuthStorageData = {}): AuthStorage {\n\t\tconst storage = new InMemoryAuthStorageBackend();\n\t\tstorage.withLock(() => ({ result: undefined, next: JSON.stringify(data, null, 2) }));\n\t\treturn AuthStorage.fromStorage(storage);\n\t}\n\n\tprivate parseStorageData(content: string | undefined): AuthStorageData {\n\t\tif (!content) {\n\t\t\treturn {};\n\t\t}\n\t\treturn JSON.parse(content) as AuthStorageData;\n\t}\n\n\tprivate recordError(error: unknown): void {\n\t\tthis.errors.push(error instanceof Error ? error : new Error(String(error)));\n\t}\n\n\t/**\n\t * Reload credentials from storage.\n\t */\n\treload(): void {\n\t\tlet content: string | undefined;\n\t\ttry {\n\t\t\tthis.storage.withLock((current) => {\n\t\t\t\tcontent = current;\n\t\t\t\treturn { result: undefined };\n\t\t\t});\n\t\t\tthis.data = this.parseStorageData(content);\n\t\t} catch (error) {\n\t\t\t// Preserve the last valid in-memory snapshot.\n\t\t\tthis.recordError(error instanceof Error ? error : new Error(String(error)));\n\t\t}\n\t}\n\n\t/** Set a non-persistent API key used ahead of stored credentials. */\n\tsetRuntimeApiKey(provider: string, apiKey: string): void {\n\t\tthis.runtimeOverrides.set(provider, apiKey);\n\t}\n\n\tremoveRuntimeApiKey(provider: string): void {\n\t\tthis.runtimeOverrides.delete(provider);\n\t}\n\n\tget(provider: string): Credential | undefined {\n\t\treturn this.data[provider];\n\t}\n\n\tgetProviderEnv(provider: string): Record<string, string> | undefined {\n\t\tconst credential = this.data[provider];\n\t\treturn credential?.type === \"api_key\" && credential.env ? { ...credential.env } : undefined;\n\t}\n\n\tset(provider: string, credential: Credential): void {\n\t\tthis.storage.withLock((content) => {\n\t\t\tconst nextData = { ...this.parseStorageData(content), [provider]: credential };\n\t\t\tthis.data = nextData;\n\t\t\treturn { result: undefined, next: JSON.stringify(nextData, null, 2) };\n\t\t});\n\t}\n\n\tremove(provider: string): void {\n\t\tthis.storage.withLock((content) => {\n\t\t\tconst nextData = { ...this.parseStorageData(content) };\n\t\t\tdelete nextData[provider];\n\t\t\tthis.data = nextData;\n\t\t\treturn { result: undefined, next: JSON.stringify(nextData, null, 2) };\n\t\t});\n\t}\n\n\thas(provider: string): boolean {\n\t\treturn provider in this.data;\n\t}\n\n\thasAuth(provider: string): boolean {\n\t\treturn this.runtimeOverrides.has(provider) || this.has(provider) || getEnvApiKey(provider) !== undefined;\n\t}\n\n\tgetAuthStatus(provider: string): AuthStatus {\n\t\tif (this.has(provider)) return { configured: true, source: \"stored\" };\n\t\tif (this.runtimeOverrides.has(provider)) return { configured: true, source: \"runtime\", label: \"--api-key\" };\n\t\tconst envName = findEnvKeys(provider)?.[0];\n\t\tif (envName && process.env[envName]) return { configured: true, source: \"environment\", label: envName };\n\t\treturn { configured: false };\n\t}\n\n\tgetAll(): AuthStorageData {\n\t\treturn { ...this.data };\n\t}\n\n\tdrainErrors(): Error[] {\n\t\tconst errors = this.errors;\n\t\tthis.errors = [];\n\t\treturn errors;\n\t}\n\n\tasync read(provider: string): Promise<Credential | undefined> {\n\t\tconst runtimeKey = this.runtimeOverrides.get(provider);\n\t\tif (runtimeKey) return { type: \"api_key\", key: runtimeKey };\n\t\tconst credential = this.data[provider];\n\t\tif (credential?.type !== \"api_key\") return credential;\n\t\tif (credential.key === undefined) return credential;\n\t\treturn { ...credential, key: resolveConfigValue(credential.key, credential.env) };\n\t}\n\n\tasync modify(\n\t\tprovider: string,\n\t\tfn: (current: Credential | undefined) => Promise<Credential | undefined>,\n\t): Promise<Credential | undefined> {\n\t\treturn this.storage.withLockAsync(async (content) => {\n\t\t\tconst currentData = this.parseStorageData(content);\n\t\t\tconst next = await fn(currentData[provider]);\n\t\t\tif (next === undefined) {\n\t\t\t\tthis.data = currentData;\n\t\t\t\treturn { result: currentData[provider] };\n\t\t\t}\n\n\t\t\tconst merged: AuthStorageData = { ...currentData, [provider]: next };\n\t\t\tthis.data = merged;\n\t\t\treturn { result: next, next: JSON.stringify(merged, null, 2) };\n\t\t});\n\t}\n\n\tasync delete(provider: string): Promise<void> {\n\t\tthis.runtimeOverrides.delete(provider);\n\t\tawait this.storage.withLockAsync(async (content) => {\n\t\t\tconst currentData = this.parseStorageData(content);\n\t\t\tdelete currentData[provider];\n\t\t\tthis.data = currentData;\n\t\t\treturn { result: undefined, next: JSON.stringify(currentData, null, 2) };\n\t\t});\n\t}\n\n\t/** List credential metadata without resolving configured key values. */\n\tasync list(): Promise<readonly CredentialInfo[]> {\n\t\tconst entries = new Map(\n\t\t\tObject.entries(this.data).map(([providerId, credential]) => [\n\t\t\t\tproviderId,\n\t\t\t\t{ providerId, type: credential.type },\n\t\t\t]),\n\t\t);\n\t\tfor (const providerId of this.runtimeOverrides.keys()) {\n\t\t\tentries.set(providerId, { providerId, type: \"api_key\" });\n\t\t}\n\t\treturn [...entries.values()];\n\t}\n\n\tasync getApiKey(providerId: string, options: GetApiKeyOptions = {}): Promise<string | undefined> {\n\t\tconst runtimeKey = this.runtimeOverrides.get(providerId);\n\t\tif (runtimeKey) return runtimeKey;\n\t\tconst credential = await this.read(providerId);\n\t\tif (credential?.type === \"api_key\") return credential.key;\n\t\tif (credential?.type === \"oauth\") {\n\t\t\tconst oauth = builtinProviders().find((provider) => provider.id === providerId)?.auth.oauth;\n\t\t\tif (!oauth) return undefined;\n\t\t\tlet current = credential;\n\t\t\tif (Date.now() >= current.expires) {\n\t\t\t\tconst refreshed = await this.modify(providerId, async (stored) => {\n\t\t\t\t\tif (stored?.type !== \"oauth\") return stored;\n\t\t\t\t\treturn Date.now() < stored.expires ? stored : oauth.refresh(stored);\n\t\t\t\t});\n\t\t\t\tif (refreshed?.type !== \"oauth\") return undefined;\n\t\t\t\tcurrent = refreshed;\n\t\t\t}\n\t\t\treturn (await oauth.toAuth(current)).apiKey;\n\t\t}\n\t\tif (options.includeFallback === false) return undefined;\n\t\treturn getEnvApiKey(providerId);\n\t}\n\n\tregisterOAuthProvider(providerId: string, oauth: OAuthAuth): void {\n\t\tthis.extensionOAuthProviders.set(providerId, oauth);\n\t}\n\n\tunregisterOAuthProvider(providerId: string): void {\n\t\tthis.extensionOAuthProviders.delete(providerId);\n\t}\n\n\tgetOAuthProviders(): Array<{ id: string; name: string }> {\n\t\tconst dynamic = [...this.extensionOAuthProviders.entries()].map(([id, oauth]) => ({\n\t\t\tid,\n\t\t\tname: oauth.name,\n\t\t}));\n\t\tconst builtin = builtinProviders().flatMap((provider) =>\n\t\t\tprovider.auth.oauth && !this.extensionOAuthProviders.has(provider.id)\n\t\t\t\t? [{ id: provider.id, name: provider.auth.oauth.name }]\n\t\t\t\t: [],\n\t\t);\n\t\treturn [...dynamic, ...builtin];\n\t}\n\n\tasync login(providerId: string, callbacks: OAuthLoginCallbacks): Promise<void> {\n\t\tconst oauth =\n\t\t\tthis.extensionOAuthProviders.get(providerId) ??\n\t\t\tbuiltinProviders().find((provider) => provider.id === providerId)?.auth.oauth;\n\t\tif (!oauth) throw new Error(`Unknown OAuth provider: ${providerId}`);\n\t\tconst interaction: AuthInteraction = {\n\t\t\tsignal: callbacks.signal,\n\t\t\tprompt: (prompt) => this.handleLegacyPrompt(prompt, callbacks),\n\t\t\tnotify: (event) => this.handleLegacyEvent(event, callbacks),\n\t\t};\n\t\tconst credential = await oauth.login(interaction);\n\t\tthis.set(providerId, credential);\n\t}\n\n\tlogout(provider: string): void {\n\t\tthis.removeRuntimeApiKey(provider);\n\t\tthis.remove(provider);\n\t}\n\n\tprivate handleLegacyPrompt(prompt: AuthPrompt, callbacks: OAuthLoginCallbacks): Promise<string> {\n\t\tswitch (prompt.type) {\n\t\t\tcase \"manual_code\":\n\t\t\t\treturn callbacks.onManualCodeInput?.() ?? callbacks.onPrompt(prompt);\n\t\t\tcase \"select\":\n\t\t\t\treturn callbacks.onSelect(prompt).then((value) => {\n\t\t\t\t\tif (value === undefined) throw new Error(\"Login cancelled\");\n\t\t\t\t\treturn value;\n\t\t\t\t});\n\t\t\tcase \"secret\":\n\t\t\tcase \"text\":\n\t\t\t\treturn callbacks.onPrompt(prompt);\n\t\t}\n\t}\n\n\tprivate handleLegacyEvent(event: AuthEvent, callbacks: OAuthLoginCallbacks): void {\n\t\tswitch (event.type) {\n\t\t\tcase \"auth_url\":\n\t\t\t\tcallbacks.onAuth(event);\n\t\t\t\tbreak;\n\t\t\tcase \"device_code\":\n\t\t\t\tcallbacks.onDeviceCode(event);\n\t\t\t\tbreak;\n\t\t\tcase \"info\":\n\t\t\t\tcallbacks.onProgress?.(event.message);\n\t\t\t\tbreak;\n\t\t\tcase \"progress\":\n\t\t\t\tcallbacks.onProgress?.(event.message);\n\t\t\t\tbreak;\n\t\t}\n\t}\n}\n\n/**\n * One-off synchronous read of a stored credential from an auth.json file,\n * without instantiating a store or resolving configured key values.\n */\nexport function readStoredCredential(\n\tproviderId: string,\n\tauthPath: string = join(getAgentDir(), \"auth.json\"),\n): Credential | undefined {\n\ttry {\n\t\tconst data = JSON.parse(readFileSync(normalizePath(authPath), \"utf-8\")) as AuthStorageData;\n\t\treturn data[providerId];\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n"]}
1
+ {"version":3,"file":"auth-storage.js","sourceRoot":"","sources":["../../src/core/auth-storage.ts"],"names":[],"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CAAC;IACF,CAAC;IAEO,iBAAiB,CAAC,KAAgB,EAAE,SAA8B;QACzE,QAAQ,KAAK,CAAC,IAAI,EAAE,CAAC;YACpB,KAAK,UAAU;gBACd,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;gBACxB,MAAM;YACP,KAAK,aAAa;gBACjB,SAAS,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;gBAC9B,MAAM;YACP,KAAK,MAAM;gBACV,SAAS,CAAC,UAAU,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;gBACtC,MAAM;YACP,KAAK,UAAU;gBACd,SAAS,CAAC,UAAU,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;gBACtC,MAAM;QACR,CAAC;IACF,CAAC;CACD;AAED;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CACnC,UAAkB,EAClB,QAAQ,GAAW,IAAI,CAAC,WAAW,EAAE,EAAE,WAAW,CAAC;IAEnD,IAAI,CAAC;QACJ,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,aAAa,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,CAAoB,CAAC;QAC3F,OAAO,IAAI,CAAC,UAAU,CAAC,CAAC;IACzB,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,SAAS,CAAC;IAClB,CAAC;AACF,CAAC","sourcesContent":["/**\n * CredentialStore implementation backed by auth.json.\n * Provider auth orchestration belongs to ModelRuntime and pi-ai Models.\n */\n\nimport type {\n\tApiKeyCredential,\n\tAuthEvent,\n\tAuthInteraction,\n\tAuthPrompt,\n\tCredential,\n\tCredentialInfo,\n\tCredentialStore,\n\tOAuthAuth,\n\tOAuthCredential,\n\tOAuthLoginCallbacks,\n} from \"@earendil-works/pi-ai\";\nimport { findEnvKeys, getEnvApiKey } from \"@earendil-works/pi-ai\";\nimport { builtinProviders } from \"@earendil-works/pi-ai/providers/all\";\nimport { chmodSync, existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from \"fs\";\nimport { dirname, join } from \"path\";\nimport lockfile from \"proper-lockfile\";\nimport { getAgentDir } from \"../config.ts\";\nimport { normalizePath } from \"../utils/paths.ts\";\nimport { resolveConfigValue } from \"./resolve-config-value.ts\";\n\ntype AuthStorageData = Record<string, Credential>;\n\nexport type AuthCredential = Credential;\nexport type { ApiKeyCredential, OAuthCredential };\nexport type AuthStatus = {\n\tconfigured: boolean;\n\tsource?: \"stored\" | \"runtime\" | \"environment\" | \"fallback\" | \"models_json_key\" | \"models_json_command\";\n\tlabel?: string;\n};\n\nexport interface GetApiKeyOptions {\n\tincludeFallback?: boolean;\n}\n\ntype LockResult<T> = {\n\tresult: T;\n\tnext?: string;\n};\n\nconst AUTH_FILE_WRITE_OPTIONS = { encoding: \"utf-8\", mode: 0o600 } as const;\n\ntype AuthFileReadState = {\n\tdata: AuthStorageData;\n\trevision?: string;\n\treload?: Promise<AuthStorageData>;\n};\n\nlet sharedAuthFileReadState: { authPath: string; readState: AuthFileReadState } | undefined;\n\nfunction getFileRevision(path: string): string | undefined {\n\ttry {\n\t\tconst stats = statSync(path, { bigint: true });\n\t\treturn `${stats.dev}:${stats.ino}:${stats.size}:${stats.mtimeNs}:${stats.ctimeNs}`;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\nexport interface AuthStorageBackend {\n\twithLock<T>(fn: (current: string | undefined) => LockResult<T>): T;\n\twithLockAsync<T>(fn: (current: string | undefined) => Promise<LockResult<T>>): Promise<T>;\n}\n\nexport class FileAuthStorageBackend implements AuthStorageBackend {\n\tprivate authPath: string;\n\n\tconstructor(authPath: string = join(getAgentDir(), \"auth.json\")) {\n\t\tthis.authPath = normalizePath(authPath);\n\t}\n\n\tprivate ensureParentDir(): void {\n\t\tconst dir = dirname(this.authPath);\n\t\tif (!existsSync(dir)) {\n\t\t\tmkdirSync(dir, { recursive: true, mode: 0o700 });\n\t\t}\n\t}\n\n\tprivate ensureFileExists(): void {\n\t\tif (!existsSync(this.authPath)) {\n\t\t\twriteFileSync(this.authPath, \"{}\", AUTH_FILE_WRITE_OPTIONS);\n\t\t\tchmodSync(this.authPath, 0o600);\n\t\t}\n\t}\n\n\tprivate acquireLockSyncWithRetry(path: string): () => void {\n\t\tconst maxAttempts = 10;\n\t\tconst delayMs = 20;\n\t\tlet lastError: unknown;\n\n\t\tfor (let attempt = 1; attempt <= maxAttempts; attempt++) {\n\t\t\ttry {\n\t\t\t\treturn lockfile.lockSync(path, { realpath: false });\n\t\t\t} catch (error) {\n\t\t\t\tconst code =\n\t\t\t\t\ttypeof error === \"object\" && error !== null && \"code\" in error\n\t\t\t\t\t\t? String((error as { code?: unknown }).code)\n\t\t\t\t\t\t: undefined;\n\t\t\t\tif (code !== \"ELOCKED\" || attempt === maxAttempts) {\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t\tlastError = error;\n\t\t\t\tconst start = Date.now();\n\t\t\t\twhile (Date.now() - start < delayMs) {\n\t\t\t\t\t// Sleep synchronously to avoid changing callers to async.\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tthrow (lastError as Error) ?? new Error(\"Failed to acquire auth storage lock\");\n\t}\n\n\twithLock<T>(fn: (current: string | undefined) => LockResult<T>): T {\n\t\tthis.ensureParentDir();\n\t\tthis.ensureFileExists();\n\n\t\tlet release: (() => void) | undefined;\n\t\ttry {\n\t\t\trelease = this.acquireLockSyncWithRetry(this.authPath);\n\t\t\tconst current = existsSync(this.authPath) ? readFileSync(this.authPath, \"utf-8\") : undefined;\n\t\t\tconst { result, next } = fn(current);\n\t\t\tif (next !== undefined) {\n\t\t\t\twriteFileSync(this.authPath, next, AUTH_FILE_WRITE_OPTIONS);\n\t\t\t\tchmodSync(this.authPath, 0o600);\n\t\t\t}\n\t\t\treturn result;\n\t\t} finally {\n\t\t\tif (release) {\n\t\t\t\trelease();\n\t\t\t}\n\t\t}\n\t}\n\n\tasync withLockAsync<T>(fn: (current: string | undefined) => Promise<LockResult<T>>): Promise<T> {\n\t\tthis.ensureParentDir();\n\t\tthis.ensureFileExists();\n\n\t\tlet release: (() => Promise<void>) | undefined;\n\t\tlet lockCompromised = false;\n\t\tlet lockCompromisedError: Error | undefined;\n\t\tconst throwIfCompromised = () => {\n\t\t\tif (lockCompromised) {\n\t\t\t\tthrow lockCompromisedError ?? new Error(\"Auth storage lock was compromised\");\n\t\t\t}\n\t\t};\n\n\t\ttry {\n\t\t\trelease = await lockfile.lock(this.authPath, {\n\t\t\t\tretries: {\n\t\t\t\t\tretries: 10,\n\t\t\t\t\tfactor: 2,\n\t\t\t\t\tminTimeout: 100,\n\t\t\t\t\tmaxTimeout: 10000,\n\t\t\t\t\trandomize: true,\n\t\t\t\t},\n\t\t\t\tstale: 30000,\n\t\t\t\tonCompromised: (err) => {\n\t\t\t\t\tlockCompromised = true;\n\t\t\t\t\tlockCompromisedError = err;\n\t\t\t\t},\n\t\t\t});\n\n\t\t\tthrowIfCompromised();\n\t\t\tconst current = existsSync(this.authPath) ? readFileSync(this.authPath, \"utf-8\") : undefined;\n\t\t\tconst { result, next } = await fn(current);\n\t\t\tthrowIfCompromised();\n\t\t\tif (next !== undefined) {\n\t\t\t\twriteFileSync(this.authPath, next, AUTH_FILE_WRITE_OPTIONS);\n\t\t\t\tchmodSync(this.authPath, 0o600);\n\t\t\t}\n\t\t\tthrowIfCompromised();\n\t\t\treturn result;\n\t\t} finally {\n\t\t\tif (release) {\n\t\t\t\ttry {\n\t\t\t\t\tawait release();\n\t\t\t\t} catch {\n\t\t\t\t\t// Ignore unlock errors when lock is compromised.\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\nexport class InMemoryAuthStorageBackend implements AuthStorageBackend {\n\tprivate value: string | undefined;\n\n\twithLock<T>(fn: (current: string | undefined) => LockResult<T>): T {\n\t\tconst { result, next } = fn(this.value);\n\t\tif (next !== undefined) {\n\t\t\tthis.value = next;\n\t\t}\n\t\treturn result;\n\t}\n\n\tasync withLockAsync<T>(fn: (current: string | undefined) => Promise<LockResult<T>>): Promise<T> {\n\t\tconst { result, next } = await fn(this.value);\n\t\tif (next !== undefined) {\n\t\t\tthis.value = next;\n\t\t}\n\t\treturn result;\n\t}\n}\n\n/**\n * Credential storage backed by a JSON file.\n */\nexport class AuthStorage implements CredentialStore {\n\tprivate data: AuthStorageData = {};\n\tprivate readonly runtimeOverrides = new Map<string, string>();\n\tprivate readonly extensionOAuthProviders = new Map<string, OAuthAuth>();\n\tprivate errors: Error[] = [];\n\tprivate storage: AuthStorageBackend;\n\tprivate authPath: string | undefined;\n\tprivate readState: AuthFileReadState;\n\n\tprivate constructor(storage: AuthStorageBackend, authPath?: string) {\n\t\tthis.storage = storage;\n\t\tthis.authPath = authPath;\n\t\tthis.readState =\n\t\t\tauthPath && sharedAuthFileReadState?.authPath === authPath ? sharedAuthFileReadState.readState : { data: {} };\n\t\tif (authPath) {\n\t\t\tsharedAuthFileReadState = { authPath, readState: this.readState };\n\t\t\tconst revision = getFileRevision(authPath);\n\t\t\tif (revision !== undefined && revision === this.readState.revision) return;\n\t\t}\n\t\tthis.reload();\n\t}\n\n\tstatic create(authPath: string = join(getAgentDir(), \"auth.json\")): AuthStorage {\n\t\tconst normalizedAuthPath = normalizePath(authPath);\n\t\treturn new AuthStorage(new FileAuthStorageBackend(normalizedAuthPath), normalizedAuthPath);\n\t}\n\n\tstatic fromStorage(storage: AuthStorageBackend): AuthStorage {\n\t\treturn new AuthStorage(storage);\n\t}\n\n\tstatic inMemory(data: AuthStorageData = {}): AuthStorage {\n\t\tconst storage = new InMemoryAuthStorageBackend();\n\t\tstorage.withLock(() => ({ result: undefined, next: JSON.stringify(data, null, 2) }));\n\t\treturn AuthStorage.fromStorage(storage);\n\t}\n\n\tprivate parseStorageData(content: string | undefined): AuthStorageData {\n\t\tif (!content) {\n\t\t\treturn {};\n\t\t}\n\t\treturn JSON.parse(content) as AuthStorageData;\n\t}\n\n\tprivate recordError(error: unknown): void {\n\t\tthis.errors.push(error instanceof Error ? error : new Error(String(error)));\n\t}\n\n\tprivate updateReadState(data: AuthStorageData, revision?: string): void {\n\t\tthis.data = data;\n\t\tthis.readState.data = data;\n\t\tthis.readState.revision = revision;\n\t}\n\n\t/**\n\t * Reload credentials from storage.\n\t */\n\treload(): void {\n\t\tlet content: string | undefined;\n\t\tlet revision: string | undefined;\n\t\ttry {\n\t\t\tthis.storage.withLock((current) => {\n\t\t\t\tcontent = current;\n\t\t\t\trevision = this.authPath ? getFileRevision(this.authPath) : undefined;\n\t\t\t\treturn { result: undefined };\n\t\t\t});\n\t\t\tthis.updateReadState(this.parseStorageData(content), revision);\n\t\t} catch (error) {\n\t\t\t// Preserve the last valid in-memory snapshot.\n\t\t\tthis.recordError(error instanceof Error ? error : new Error(String(error)));\n\t\t}\n\t}\n\n\t/** Set a non-persistent API key used ahead of stored credentials. */\n\tsetRuntimeApiKey(provider: string, apiKey: string): void {\n\t\tthis.runtimeOverrides.set(provider, apiKey);\n\t}\n\n\tremoveRuntimeApiKey(provider: string): void {\n\t\tthis.runtimeOverrides.delete(provider);\n\t}\n\n\tget(provider: string): Credential | undefined {\n\t\treturn this.data[provider];\n\t}\n\n\tgetProviderEnv(provider: string): Record<string, string> | undefined {\n\t\tconst credential = this.data[provider];\n\t\treturn credential?.type === \"api_key\" && credential.env ? { ...credential.env } : undefined;\n\t}\n\n\tset(provider: string, credential: Credential): void {\n\t\tthis.storage.withLock((content) => {\n\t\t\tconst nextData = { ...this.parseStorageData(content), [provider]: credential };\n\t\t\tthis.data = nextData;\n\t\t\treturn { result: undefined, next: JSON.stringify(nextData, null, 2) };\n\t\t});\n\t}\n\n\tremove(provider: string): void {\n\t\tthis.storage.withLock((content) => {\n\t\t\tconst nextData = { ...this.parseStorageData(content) };\n\t\t\tdelete nextData[provider];\n\t\t\tthis.data = nextData;\n\t\t\treturn { result: undefined, next: JSON.stringify(nextData, null, 2) };\n\t\t});\n\t}\n\n\thas(provider: string): boolean {\n\t\treturn provider in this.data;\n\t}\n\n\thasAuth(provider: string): boolean {\n\t\treturn this.runtimeOverrides.has(provider) || this.has(provider) || getEnvApiKey(provider) !== undefined;\n\t}\n\n\tgetAuthStatus(provider: string): AuthStatus {\n\t\tif (this.has(provider)) return { configured: true, source: \"stored\" };\n\t\tif (this.runtimeOverrides.has(provider)) return { configured: true, source: \"runtime\", label: \"--api-key\" };\n\t\tconst envName = findEnvKeys(provider)?.[0];\n\t\tif (envName && process.env[envName]) return { configured: true, source: \"environment\", label: envName };\n\t\treturn { configured: false };\n\t}\n\n\tgetAll(): AuthStorageData {\n\t\treturn { ...this.data };\n\t}\n\n\tdrainErrors(): Error[] {\n\t\tconst errors = this.errors;\n\t\tthis.errors = [];\n\t\treturn errors;\n\t}\n\n\tprivate async reloadFromStorageAsync(): Promise<AuthStorageData> {\n\t\treturn this.storage.withLockAsync(async (content) => {\n\t\t\tconst currentData = this.parseStorageData(content);\n\t\t\tconst revision = this.authPath ? getFileRevision(this.authPath) : undefined;\n\t\t\tthis.updateReadState(currentData, revision);\n\t\t\treturn { result: currentData };\n\t\t});\n\t}\n\n\tprivate async readLatestData(): Promise<AuthStorageData> {\n\t\tif (this.authPath) {\n\t\t\tconst revision = getFileRevision(this.authPath);\n\t\t\tif (revision !== undefined && revision === this.readState.revision) return this.readState.data;\n\t\t}\n\t\tif (!this.readState.reload) {\n\t\t\tthis.readState.reload = this.reloadFromStorageAsync().catch((error: unknown) => {\n\t\t\t\tthis.recordError(error);\n\t\t\t\treturn this.readState.data;\n\t\t\t});\n\t\t}\n\t\ttry {\n\t\t\treturn await this.readState.reload;\n\t\t} finally {\n\t\t\tthis.readState.reload = undefined;\n\t\t}\n\t}\n\n\tasync read(provider: string): Promise<Credential | undefined> {\n\t\tconst runtimeKey = this.runtimeOverrides.get(provider);\n\t\tif (runtimeKey) return { type: \"api_key\", key: runtimeKey };\n\t\tconst credential = (await this.readLatestData())[provider];\n\t\tif (credential?.type !== \"api_key\") return credential;\n\t\tif (credential.key === undefined) return credential;\n\t\treturn { ...credential, key: resolveConfigValue(credential.key, credential.env) };\n\t}\n\n\tasync modify(\n\t\tprovider: string,\n\t\tfn: (current: Credential | undefined) => Promise<Credential | undefined>,\n\t): Promise<Credential | undefined> {\n\t\tlet latestData = this.readState.data;\n\t\tlet revision: string | undefined;\n\t\tconst result = await this.storage.withLockAsync(async (content) => {\n\t\t\tconst currentData = this.parseStorageData(content);\n\t\t\tconst next = await fn(currentData[provider]);\n\t\t\tif (next === undefined) {\n\t\t\t\tlatestData = currentData;\n\t\t\t\trevision = this.authPath ? getFileRevision(this.authPath) : undefined;\n\t\t\t\treturn { result: currentData[provider] };\n\t\t\t}\n\n\t\t\tconst merged: AuthStorageData = { ...currentData, [provider]: next };\n\t\t\tlatestData = merged;\n\t\t\treturn { result: next, next: JSON.stringify(merged, null, 2) };\n\t\t});\n\t\tthis.updateReadState(latestData, revision);\n\t\treturn result;\n\t}\n\n\tasync delete(provider: string): Promise<void> {\n\t\tthis.runtimeOverrides.delete(provider);\n\t\tlet latestData = this.readState.data;\n\t\tawait this.storage.withLockAsync(async (content) => {\n\t\t\tconst currentData = this.parseStorageData(content);\n\t\t\tdelete currentData[provider];\n\t\t\tlatestData = currentData;\n\t\t\treturn { result: undefined, next: JSON.stringify(currentData, null, 2) };\n\t\t});\n\t\tthis.updateReadState(latestData);\n\t}\n\n\t/** List credential metadata without resolving configured key values. */\n\tasync list(): Promise<readonly CredentialInfo[]> {\n\t\tconst entries = new Map(\n\t\t\tObject.entries(await this.readLatestData()).map(([providerId, credential]) => [\n\t\t\t\tproviderId,\n\t\t\t\t{ providerId, type: credential.type },\n\t\t\t]),\n\t\t);\n\t\tfor (const providerId of this.runtimeOverrides.keys()) {\n\t\t\tentries.set(providerId, { providerId, type: \"api_key\" });\n\t\t}\n\t\treturn [...entries.values()];\n\t}\n\n\tasync getApiKey(providerId: string, options: GetApiKeyOptions = {}): Promise<string | undefined> {\n\t\tconst runtimeKey = this.runtimeOverrides.get(providerId);\n\t\tif (runtimeKey) return runtimeKey;\n\t\tconst credential = await this.read(providerId);\n\t\tif (credential?.type === \"api_key\") return credential.key;\n\t\tif (credential?.type === \"oauth\") {\n\t\t\tconst oauth = builtinProviders().find((provider) => provider.id === providerId)?.auth.oauth;\n\t\t\tif (!oauth) return undefined;\n\t\t\tlet current = credential;\n\t\t\tif (Date.now() >= current.expires) {\n\t\t\t\tconst refreshed = await this.modify(providerId, async (stored) => {\n\t\t\t\t\tif (stored?.type !== \"oauth\") return stored;\n\t\t\t\t\treturn Date.now() < stored.expires ? stored : oauth.refresh(stored);\n\t\t\t\t});\n\t\t\t\tif (refreshed?.type !== \"oauth\") return undefined;\n\t\t\t\tcurrent = refreshed;\n\t\t\t}\n\t\t\treturn (await oauth.toAuth(current)).apiKey;\n\t\t}\n\t\tif (options.includeFallback === false) return undefined;\n\t\treturn getEnvApiKey(providerId);\n\t}\n\n\tregisterOAuthProvider(providerId: string, oauth: OAuthAuth): void {\n\t\tthis.extensionOAuthProviders.set(providerId, oauth);\n\t}\n\n\tunregisterOAuthProvider(providerId: string): void {\n\t\tthis.extensionOAuthProviders.delete(providerId);\n\t}\n\n\tgetOAuthProviders(): Array<{ id: string; name: string }> {\n\t\tconst dynamic = [...this.extensionOAuthProviders.entries()].map(([id, oauth]) => ({\n\t\t\tid,\n\t\t\tname: oauth.name,\n\t\t}));\n\t\tconst builtin = builtinProviders().flatMap((provider) =>\n\t\t\tprovider.auth.oauth && !this.extensionOAuthProviders.has(provider.id)\n\t\t\t\t? [{ id: provider.id, name: provider.auth.oauth.name }]\n\t\t\t\t: [],\n\t\t);\n\t\treturn [...dynamic, ...builtin];\n\t}\n\n\tasync login(providerId: string, callbacks: OAuthLoginCallbacks): Promise<void> {\n\t\tconst oauth =\n\t\t\tthis.extensionOAuthProviders.get(providerId) ??\n\t\t\tbuiltinProviders().find((provider) => provider.id === providerId)?.auth.oauth;\n\t\tif (!oauth) throw new Error(`Unknown OAuth provider: ${providerId}`);\n\t\tconst interaction: AuthInteraction = {\n\t\t\tsignal: callbacks.signal,\n\t\t\tprompt: (prompt) => this.handleLegacyPrompt(prompt, callbacks),\n\t\t\tnotify: (event) => this.handleLegacyEvent(event, callbacks),\n\t\t};\n\t\tconst credential = await oauth.login(interaction);\n\t\tthis.set(providerId, credential);\n\t}\n\n\tlogout(provider: string): void {\n\t\tthis.removeRuntimeApiKey(provider);\n\t\tthis.remove(provider);\n\t}\n\n\tprivate handleLegacyPrompt(prompt: AuthPrompt, callbacks: OAuthLoginCallbacks): Promise<string> {\n\t\tswitch (prompt.type) {\n\t\t\tcase \"manual_code\":\n\t\t\t\treturn callbacks.onManualCodeInput?.() ?? callbacks.onPrompt(prompt);\n\t\t\tcase \"select\":\n\t\t\t\treturn callbacks.onSelect(prompt).then((value) => {\n\t\t\t\t\tif (value === undefined) throw new Error(\"Login cancelled\");\n\t\t\t\t\treturn value;\n\t\t\t\t});\n\t\t\tcase \"secret\":\n\t\t\tcase \"text\":\n\t\t\t\treturn callbacks.onPrompt(prompt);\n\t\t}\n\t}\n\n\tprivate handleLegacyEvent(event: AuthEvent, callbacks: OAuthLoginCallbacks): void {\n\t\tswitch (event.type) {\n\t\t\tcase \"auth_url\":\n\t\t\t\tcallbacks.onAuth(event);\n\t\t\t\tbreak;\n\t\t\tcase \"device_code\":\n\t\t\t\tcallbacks.onDeviceCode(event);\n\t\t\t\tbreak;\n\t\t\tcase \"info\":\n\t\t\t\tcallbacks.onProgress?.(event.message);\n\t\t\t\tbreak;\n\t\t\tcase \"progress\":\n\t\t\t\tcallbacks.onProgress?.(event.message);\n\t\t\t\tbreak;\n\t\t}\n\t}\n}\n\n/**\n * One-off synchronous read of a stored credential from an auth.json file,\n * without instantiating a store or resolving configured key values.\n */\nexport function readStoredCredential(\n\tproviderId: string,\n\tauthPath: string = join(getAgentDir(), \"auth.json\"),\n): Credential | undefined {\n\ttry {\n\t\tconst data = JSON.parse(readFileSync(normalizePath(authPath), \"utf-8\")) as AuthStorageData;\n\t\treturn data[providerId];\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n"]}
@@ -18,11 +18,11 @@ export declare const TEST_DISCIPLINE_RULES: readonly [{
18
18
  }, {
19
19
  readonly id: "mock-contract-integrity";
20
20
  readonly concern: "mock-contracts";
21
- readonly directive: "Mocks must preserve the contract being asserted; do not isolate so heavily that the integration under test cannot fail.";
21
+ readonly directive: "Mocks must preserve the behavior being asserted; do not isolate so heavily that the integration under test cannot fail.";
22
22
  }, {
23
23
  readonly id: "prompt-behavior-coverage";
24
24
  readonly concern: "prompt-tests";
25
- readonly directive: "Prompt tests must assert behavior, decisions, structure, or parsed rule data rather than merely pinning an exact prompt sentence.";
25
+ readonly directive: "Never pin prose, prompt wording, or doc text with a test; test only machine-consumed values (parsed fields, sentinel tokens, shipped-copy equality). A pure-prose change ships with no new test.";
26
26
  }, {
27
27
  readonly id: "single-pass-runner";
28
28
  readonly concern: "test-runner";
@@ -1 +1 @@
1
- {"version":3,"file":"verification.d.ts","sourceRoot":"","sources":["../../../src/core/dynamic-prompt/verification.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,kBAAkB,GAAG;IAChC,EAAE,EACC,qBAAqB,GACrB,gBAAgB,GAChB,uBAAuB,GACvB,yBAAyB,GACzB,0BAA0B,GAC1B,oBAAoB,CAAC;IACxB,OAAO,EAAE,kBAAkB,GAAG,0BAA0B,GAAG,gBAAgB,GAAG,cAAc,GAAG,aAAa,CAAC;IAC7G,SAAS,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,eAAO,MAAM,qBAAqB;iBAE5B,qBAAqB;sBAChB,kBAAkB;wBAChB,qGAAqG;;iBAG5G,gBAAgB;sBACX,0BAA0B;wBAElC,wHAAwH;;iBAGrH,uBAAuB;sBAClB,0BAA0B;wBAElC,+IAA+I;;iBAG5I,yBAAyB;sBACpB,gBAAgB;wBAExB,yHAAyH;;iBAGtH,0BAA0B;sBACrB,cAAc;wBAEtB,mIAAmI;;iBAGhI,oBAAoB;sBACf,aAAa;wBAErB,2HAA2H;EAE5E,CAAC;AAEnD,wBAAgB,0BAA0B,IAAI,MAAM,CAMnD;AAED,wBAAgB,wBAAwB,IAAI,MAAM,CAYjD"}
1
+ {"version":3,"file":"verification.d.ts","sourceRoot":"","sources":["../../../src/core/dynamic-prompt/verification.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,kBAAkB,GAAG;IAChC,EAAE,EACC,qBAAqB,GACrB,gBAAgB,GAChB,uBAAuB,GACvB,yBAAyB,GACzB,0BAA0B,GAC1B,oBAAoB,CAAC;IACxB,OAAO,EAAE,kBAAkB,GAAG,0BAA0B,GAAG,gBAAgB,GAAG,cAAc,GAAG,aAAa,CAAC;IAC7G,SAAS,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,eAAO,MAAM,qBAAqB;iBAE5B,qBAAqB;sBAChB,kBAAkB;wBAChB,qGAAqG;;iBAG5G,gBAAgB;sBACX,0BAA0B;wBAElC,wHAAwH;;iBAGrH,uBAAuB;sBAClB,0BAA0B;wBAElC,+IAA+I;;iBAG5I,yBAAyB;sBACpB,gBAAgB;wBAExB,yHAAyH;;iBAGtH,0BAA0B;sBACrB,cAAc;wBAEtB,kMAAkM;;iBAG/L,oBAAoB;sBACf,aAAa;wBAErB,2HAA2H;EAE5E,CAAC;AAEnD,wBAAgB,0BAA0B,IAAI,MAAM,CAMnD;AAED,wBAAgB,wBAAwB,IAAI,MAAM,CAYjD"}
@@ -17,12 +17,12 @@ export const TEST_DISCIPLINE_RULES = [
17
17
  {
18
18
  id: "mock-contract-integrity",
19
19
  concern: "mock-contracts",
20
- directive: "Mocks must preserve the contract being asserted; do not isolate so heavily that the integration under test cannot fail.",
20
+ directive: "Mocks must preserve the behavior being asserted; do not isolate so heavily that the integration under test cannot fail.",
21
21
  },
22
22
  {
23
23
  id: "prompt-behavior-coverage",
24
24
  concern: "prompt-tests",
25
- directive: "Prompt tests must assert behavior, decisions, structure, or parsed rule data rather than merely pinning an exact prompt sentence.",
25
+ directive: "Never pin prose, prompt wording, or doc text with a test; test only machine-consumed values (parsed fields, sentinel tokens, shipped-copy equality). A pure-prose change ships with no new test.",
26
26
  },
27
27
  {
28
28
  id: "single-pass-runner",
@@ -1 +1 @@
1
- {"version":3,"file":"verification.js","sourceRoot":"","sources":["../../../src/core/dynamic-prompt/verification.ts"],"names":[],"mappings":"AAYA,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACpC;QACC,EAAE,EAAE,qBAAqB;QACzB,OAAO,EAAE,kBAAkB;QAC3B,SAAS,EAAE,qGAAqG;KAChH;IACD;QACC,EAAE,EAAE,gBAAgB;QACpB,OAAO,EAAE,0BAA0B;QACnC,SAAS,EACR,wHAAwH;KACzH;IACD;QACC,EAAE,EAAE,uBAAuB;QAC3B,OAAO,EAAE,0BAA0B;QACnC,SAAS,EACR,+IAA+I;KAChJ;IACD;QACC,EAAE,EAAE,yBAAyB;QAC7B,OAAO,EAAE,gBAAgB;QACzB,SAAS,EACR,yHAAyH;KAC1H;IACD;QACC,EAAE,EAAE,0BAA0B;QAC9B,OAAO,EAAE,cAAc;QACvB,SAAS,EACR,mIAAmI;KACpI;IACD;QACC,EAAE,EAAE,oBAAoB;QACxB,OAAO,EAAE,aAAa;QACtB,SAAS,EACR,2HAA2H;KAC5H;CACgD,CAAC;AAEnD,MAAM,UAAU,0BAA0B;IACzC,MAAM,KAAK,GAAG,CAAC,qBAAqB,CAAC,CAAC;IACtC,KAAK,MAAM,IAAI,IAAI,qBAAqB,EAAE,CAAC;QAC1C,KAAK,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC;IACnC,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACzB,CAAC;AAED,MAAM,UAAU,wBAAwB;IACvC,OAAO;;;;;;;;EAQN,0BAA0B,EAAE;;oLAEsJ,CAAC;AACrL,CAAC","sourcesContent":["export type TestDisciplineRule = {\n\tid:\n\t\t| \"deterministic-tests\"\n\t\t| \"fixed-wait-ban\"\n\t\t| \"event-timeout-pattern\"\n\t\t| \"mock-contract-integrity\"\n\t\t| \"prompt-behavior-coverage\"\n\t\t| \"single-pass-runner\";\n\tconcern: \"test-determinism\" | \"async-test-orchestration\" | \"mock-contracts\" | \"prompt-tests\" | \"test-runner\";\n\tdirective: string;\n};\n\nexport const TEST_DISCIPLINE_RULES = [\n\t{\n\t\tid: \"deterministic-tests\",\n\t\tconcern: \"test-determinism\",\n\t\tdirective: \"When you read or edit test code, treat nondeterminism as a bug; tests must not pass by timing luck.\",\n\t},\n\t{\n\t\tid: \"fixed-wait-ban\",\n\t\tconcern: \"async-test-orchestration\",\n\t\tdirective:\n\t\t\t\"Unless time itself is the behavior under test, fixed sleeps, polling delays, and wait-for-time patterns are forbidden.\",\n\t},\n\t{\n\t\tid: \"event-timeout-pattern\",\n\t\tconcern: \"async-test-orchestration\",\n\t\tdirective:\n\t\t\t\"For async behavior, subscribe to the exact event or state change before triggering the action, then await that signal with a bounded timeout.\",\n\t},\n\t{\n\t\tid: \"mock-contract-integrity\",\n\t\tconcern: \"mock-contracts\",\n\t\tdirective:\n\t\t\t\"Mocks must preserve the contract being asserted; do not isolate so heavily that the integration under test cannot fail.\",\n\t},\n\t{\n\t\tid: \"prompt-behavior-coverage\",\n\t\tconcern: \"prompt-tests\",\n\t\tdirective:\n\t\t\t\"Prompt tests must assert behavior, decisions, structure, or parsed rule data rather than merely pinning an exact prompt sentence.\",\n\t},\n\t{\n\t\tid: \"single-pass-runner\",\n\t\tconcern: \"test-runner\",\n\t\tdirective:\n\t\t\t\"Run the relevant test command once and make that pass reliable; for Bun test targets, bun test must pass in a single run.\",\n\t},\n] as const satisfies readonly TestDisciplineRule[];\n\nexport function buildTestDisciplineSection(): string {\n\tconst lines = [\"### Test Discipline\"];\n\tfor (const rule of TEST_DISCIPLINE_RULES) {\n\t\tlines.push(`- ${rule.directive}`);\n\t}\n\treturn lines.join(\"\\n\");\n}\n\nexport function buildVerificationSection(): string {\n\treturn `## Verification\n\nTier the scope, never the rigor.\n\n- V1 — single-file non-behavioral edits: diagnostics on that file. Done.\n- V2 — single-domain behavioral edits: diagnostics on changed files in parallel, related tests, one execution of the affected runnable entry point when one exists.\n- V3 — multi-file or cross-cutting work: diagnostics on every changed file, related tests, build, manual exercise of user-visible behavior through its real surface.\n\n${buildTestDisciplineSection()}\n\n\"Should pass\" is not verification. Reporting clean output without running the validator is a violation. Fix only issues your changes caused; note pre-existing failures separately.`;\n}\n"]}
1
+ {"version":3,"file":"verification.js","sourceRoot":"","sources":["../../../src/core/dynamic-prompt/verification.ts"],"names":[],"mappings":"AAYA,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACpC;QACC,EAAE,EAAE,qBAAqB;QACzB,OAAO,EAAE,kBAAkB;QAC3B,SAAS,EAAE,qGAAqG;KAChH;IACD;QACC,EAAE,EAAE,gBAAgB;QACpB,OAAO,EAAE,0BAA0B;QACnC,SAAS,EACR,wHAAwH;KACzH;IACD;QACC,EAAE,EAAE,uBAAuB;QAC3B,OAAO,EAAE,0BAA0B;QACnC,SAAS,EACR,+IAA+I;KAChJ;IACD;QACC,EAAE,EAAE,yBAAyB;QAC7B,OAAO,EAAE,gBAAgB;QACzB,SAAS,EACR,yHAAyH;KAC1H;IACD;QACC,EAAE,EAAE,0BAA0B;QAC9B,OAAO,EAAE,cAAc;QACvB,SAAS,EACR,kMAAkM;KACnM;IACD;QACC,EAAE,EAAE,oBAAoB;QACxB,OAAO,EAAE,aAAa;QACtB,SAAS,EACR,2HAA2H;KAC5H;CACgD,CAAC;AAEnD,MAAM,UAAU,0BAA0B;IACzC,MAAM,KAAK,GAAG,CAAC,qBAAqB,CAAC,CAAC;IACtC,KAAK,MAAM,IAAI,IAAI,qBAAqB,EAAE,CAAC;QAC1C,KAAK,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC;IACnC,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACzB,CAAC;AAED,MAAM,UAAU,wBAAwB;IACvC,OAAO;;;;;;;;EAQN,0BAA0B,EAAE;;oLAEsJ,CAAC;AACrL,CAAC","sourcesContent":["export type TestDisciplineRule = {\n\tid:\n\t\t| \"deterministic-tests\"\n\t\t| \"fixed-wait-ban\"\n\t\t| \"event-timeout-pattern\"\n\t\t| \"mock-contract-integrity\"\n\t\t| \"prompt-behavior-coverage\"\n\t\t| \"single-pass-runner\";\n\tconcern: \"test-determinism\" | \"async-test-orchestration\" | \"mock-contracts\" | \"prompt-tests\" | \"test-runner\";\n\tdirective: string;\n};\n\nexport const TEST_DISCIPLINE_RULES = [\n\t{\n\t\tid: \"deterministic-tests\",\n\t\tconcern: \"test-determinism\",\n\t\tdirective: \"When you read or edit test code, treat nondeterminism as a bug; tests must not pass by timing luck.\",\n\t},\n\t{\n\t\tid: \"fixed-wait-ban\",\n\t\tconcern: \"async-test-orchestration\",\n\t\tdirective:\n\t\t\t\"Unless time itself is the behavior under test, fixed sleeps, polling delays, and wait-for-time patterns are forbidden.\",\n\t},\n\t{\n\t\tid: \"event-timeout-pattern\",\n\t\tconcern: \"async-test-orchestration\",\n\t\tdirective:\n\t\t\t\"For async behavior, subscribe to the exact event or state change before triggering the action, then await that signal with a bounded timeout.\",\n\t},\n\t{\n\t\tid: \"mock-contract-integrity\",\n\t\tconcern: \"mock-contracts\",\n\t\tdirective:\n\t\t\t\"Mocks must preserve the behavior being asserted; do not isolate so heavily that the integration under test cannot fail.\",\n\t},\n\t{\n\t\tid: \"prompt-behavior-coverage\",\n\t\tconcern: \"prompt-tests\",\n\t\tdirective:\n\t\t\t\"Never pin prose, prompt wording, or doc text with a test; test only machine-consumed values (parsed fields, sentinel tokens, shipped-copy equality). A pure-prose change ships with no new test.\",\n\t},\n\t{\n\t\tid: \"single-pass-runner\",\n\t\tconcern: \"test-runner\",\n\t\tdirective:\n\t\t\t\"Run the relevant test command once and make that pass reliable; for Bun test targets, bun test must pass in a single run.\",\n\t},\n] as const satisfies readonly TestDisciplineRule[];\n\nexport function buildTestDisciplineSection(): string {\n\tconst lines = [\"### Test Discipline\"];\n\tfor (const rule of TEST_DISCIPLINE_RULES) {\n\t\tlines.push(`- ${rule.directive}`);\n\t}\n\treturn lines.join(\"\\n\");\n}\n\nexport function buildVerificationSection(): string {\n\treturn `## Verification\n\nTier the scope, never the rigor.\n\n- V1 — single-file non-behavioral edits: diagnostics on that file. Done.\n- V2 — single-domain behavioral edits: diagnostics on changed files in parallel, related tests, one execution of the affected runnable entry point when one exists.\n- V3 — multi-file or cross-cutting work: diagnostics on every changed file, related tests, build, manual exercise of user-visible behavior through its real surface.\n\n${buildTestDisciplineSection()}\n\n\"Should pass\" is not verification. Reporting clean output without running the validator is a violation. Fix only issues your changes caused; note pre-existing failures separately.`;\n}\n"]}
@@ -0,0 +1,17 @@
1
+ /** Single-consumer queue that fails fast instead of buffering an unbounded turn. */
2
+ export declare const SESSION_STREAM_QUEUE_CAPACITY = 256;
3
+ export declare class BoundedAsyncQueue<T> implements AsyncIterableIterator<T> {
4
+ private readonly capacity;
5
+ private readonly values;
6
+ private reader;
7
+ private closed;
8
+ private failed;
9
+ private failure;
10
+ constructor(capacity: number);
11
+ [Symbol.asyncIterator](): AsyncIterableIterator<T>;
12
+ next(): Promise<IteratorResult<T>>;
13
+ push(value: T): void;
14
+ close(): void;
15
+ fail(error: unknown): void;
16
+ }
17
+ //# sourceMappingURL=bounded-queue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bounded-queue.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/claude-sdk-oauth/bounded-queue.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,eAAO,MAAM,6BAA6B,MAAM,CAAC;AAEjD,qBAAa,iBAAiB,CAAC,CAAC,CAAE,YAAW,qBAAqB,CAAC,CAAC,CAAC;IACpE,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAClC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAW;IAClC,OAAO,CAAC,MAAM,CAAiG;IAC/G,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,OAAO,CAAU;IAEzB,YAAY,QAAQ,EAAE,MAAM,EAE3B;IAED,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,qBAAqB,CAAC,CAAC,CAAC,CAEjD;IAED,IAAI,IAAI,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAOjC;IAED,IAAI,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI,CAYnB;IAED,KAAK,IAAI,IAAI,CAMZ;IAED,IAAI,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAOzB;CACD"}
@@ -0,0 +1,56 @@
1
+ /** Single-consumer queue that fails fast instead of buffering an unbounded turn. */
2
+ export const SESSION_STREAM_QUEUE_CAPACITY = 256;
3
+ export class BoundedAsyncQueue {
4
+ constructor(capacity) {
5
+ this.values = [];
6
+ this.closed = false;
7
+ this.failed = false;
8
+ this.capacity = capacity;
9
+ }
10
+ [Symbol.asyncIterator]() {
11
+ return this;
12
+ }
13
+ next() {
14
+ if (this.values.length > 0)
15
+ return Promise.resolve({ value: this.values.shift(), done: false });
16
+ if (this.failed)
17
+ return Promise.reject(this.failure);
18
+ if (this.closed)
19
+ return Promise.resolve({ value: undefined, done: true });
20
+ return new Promise((resolve, reject) => {
21
+ this.reader = { resolve, reject };
22
+ });
23
+ }
24
+ push(value) {
25
+ if (this.closed || this.failed)
26
+ return;
27
+ const reader = this.reader;
28
+ if (reader) {
29
+ this.reader = undefined;
30
+ reader.resolve({ value, done: false });
31
+ return;
32
+ }
33
+ if (this.values.length >= this.capacity) {
34
+ throw new Error(`Claude SDK OAuth session stream queue exceeded ${this.capacity} messages`);
35
+ }
36
+ this.values.push(value);
37
+ }
38
+ close() {
39
+ if (this.closed || this.failed)
40
+ return;
41
+ this.closed = true;
42
+ const reader = this.reader;
43
+ this.reader = undefined;
44
+ reader?.resolve({ value: undefined, done: true });
45
+ }
46
+ fail(error) {
47
+ if (this.closed || this.failed)
48
+ return;
49
+ this.failed = true;
50
+ this.failure = error;
51
+ const reader = this.reader;
52
+ this.reader = undefined;
53
+ reader?.reject(error);
54
+ }
55
+ }
56
+ //# sourceMappingURL=bounded-queue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bounded-queue.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/claude-sdk-oauth/bounded-queue.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,MAAM,CAAC,MAAM,6BAA6B,GAAG,GAAG,CAAC;AAEjD,MAAM,OAAO,iBAAiB;IAQ7B,YAAY,QAAgB;QANX,WAAM,GAAQ,EAAE,CAAC;QAE1B,WAAM,GAAG,KAAK,CAAC;QACf,WAAM,GAAG,KAAK,CAAC;QAItB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC1B,CAAC;IAED,CAAC,MAAM,CAAC,aAAa,CAAC;QACrB,OAAO,IAAI,CAAC;IACb,CAAC;IAED,IAAI;QACH,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC;YAAE,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK,EAAG,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;QACjG,IAAI,IAAI,CAAC,MAAM;YAAE,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACrD,IAAI,IAAI,CAAC,MAAM;YAAE,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;QAC1E,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACtC,IAAI,CAAC,MAAM,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;QACnC,CAAC,CAAC,CAAC;IACJ,CAAC;IAED,IAAI,CAAC,KAAQ;QACZ,IAAI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M_QUEUE_CAPACITY = 256;\n\nexport class BoundedAsyncQueue<T> implements AsyncIterableIterator<T> {\n\tprivate readonly capacity: number;\n\tprivate readonly values: T[] = [];\n\tprivate reader: { resolve: (result: IteratorResult<T>) => void; reject: (error: unknown) => void } | undefined;\n\tprivate closed = false;\n\tprivate failed = false;\n\tprivate failure: unknown;\n\n\tconstructor(capacity: number) {\n\t\tthis.capacity = capacity;\n\t}\n\n\t[Symbol.asyncIterator](): AsyncIterableIterator<T> {\n\t\treturn this;\n\t}\n\n\tnext(): Promise<IteratorResult<T>> {\n\t\tif (this.values.length > 0) return Promise.resolve({ value: this.values.shift()!, done: false });\n\t\tif (this.failed) return Promise.reject(this.failure);\n\t\tif (this.closed) return Promise.resolve({ value: undefined, done: true });\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tthis.reader = { resolve, reject };\n\t\t});\n\t}\n\n\tpush(value: T): void {\n\t\tif (this.closed || this.failed) return;\n\t\tconst reader = this.reader;\n\t\tif (reader) {\n\t\t\tthis.reader = undefined;\n\t\t\treader.resolve({ value, done: false });\n\t\t\treturn;\n\t\t}\n\t\tif (this.values.length >= this.capacity) {\n\t\t\tthrow new Error(`Claude SDK OAuth session stream queue exceeded ${this.capacity} messages`);\n\t\t}\n\t\tthis.values.push(value);\n\t}\n\n\tclose(): void {\n\t\tif (this.closed || this.failed) return;\n\t\tthis.closed = true;\n\t\tconst reader = this.reader;\n\t\tthis.reader = undefined;\n\t\treader?.resolve({ value: undefined, done: true });\n\t}\n\n\tfail(error: unknown): void {\n\t\tif (this.closed || this.failed) return;\n\t\tthis.failed = true;\n\t\tthis.failure = error;\n\t\tconst reader = this.reader;\n\t\tthis.reader = undefined;\n\t\treader?.reject(error);\n\t}\n}\n"]}
@@ -5,6 +5,7 @@ export type { Base64ImageSource, ContentBlockParam, EffortLevel, Options, SDKMes
5
5
  export type SdkQueryInput = Parameters<typeof query>[0];
6
6
  export type SdkQueryHandle = AsyncIterable<SDKMessage> & {
7
7
  interrupt(): Promise<unknown>;
8
+ setModel?: (model?: string) => Promise<void>;
8
9
  close(): void;
9
10
  initializationResult?: () => Promise<unknown>;
10
11
  };
@@ -1 +1 @@
1
- {"version":3,"file":"sdk-boundary.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/claude-sdk-oauth/sdk-boundary.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,WAAW,EACX,OAAO,EACP,UAAU,EACV,cAAc,EACd,aAAa,EACb,cAAc,EACd,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,kBAAkB,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,KAAK,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAExF,YAAY,EACX,iBAAiB,EACjB,iBAAiB,EACjB,WAAW,EACX,OAAO,EACP,UAAU,EACV,cAAc,EACd,aAAa,EACb,cAAc,GACd,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,UAAU,CAAC,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;AACxD,MAAM,MAAM,cAAc,GAAG,aAAa,CAAC,UAAU,CAAC,GAAG;IACxD,SAAS,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IAC9B,KAAK,IAAI,IAAI,CAAC;IACd,oBAAoB,CAAC,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;CAC9C,CAAC;AACF,MAAM,MAAM,QAAQ,GAAG,CAAC,KAAK,EAAE,aAAa,KAAK,cAAc,CAAC;AAEhE,MAAM,MAAM,WAAW,GAAG;IACzB,KAAK,EAAE,QAAQ,CAAC;IAChB,kBAAkB,EAAE,OAAO,kBAAkB,CAAC;CAC9C,CAAC;AAEF,QAAA,MAAM,kBAAkB,EAAE,WAA2C,CAAC;AAGtE,wBAAgB,cAAc,IAAI,WAAW,CAE5C;AAED,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,OAAO,CAAC,WAAW,CAAC,GAAG,IAAI,CAExE;AAED,wBAAgB,gBAAgB,IAAI,IAAI,CAEvC;eAEc,kBAAkB"}
1
+ {"version":3,"file":"sdk-boundary.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/claude-sdk-oauth/sdk-boundary.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,WAAW,EACX,OAAO,EACP,UAAU,EACV,cAAc,EACd,aAAa,EACb,cAAc,EACd,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,kBAAkB,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,KAAK,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAExF,YAAY,EACX,iBAAiB,EACjB,iBAAiB,EACjB,WAAW,EACX,OAAO,EACP,UAAU,EACV,cAAc,EACd,aAAa,EACb,cAAc,GACd,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,UAAU,CAAC,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;AACxD,MAAM,MAAM,cAAc,GAAG,aAAa,CAAC,UAAU,CAAC,GAAG;IACxD,SAAS,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IAC9B,QAAQ,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7C,KAAK,IAAI,IAAI,CAAC;IACd,oBAAoB,CAAC,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;CAC9C,CAAC;AACF,MAAM,MAAM,QAAQ,GAAG,CAAC,KAAK,EAAE,aAAa,KAAK,cAAc,CAAC;AAEhE,MAAM,MAAM,WAAW,GAAG;IACzB,KAAK,EAAE,QAAQ,CAAC;IAChB,kBAAkB,EAAE,OAAO,kBAAkB,CAAC;CAC9C,CAAC;AAEF,QAAA,MAAM,kBAAkB,EAAE,WAA2C,CAAC;AAGtE,wBAAgB,cAAc,IAAI,WAAW,CAE5C;AAED,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,OAAO,CAAC,WAAW,CAAC,GAAG,IAAI,CAExE;AAED,wBAAgB,gBAAgB,IAAI,IAAI,CAEvC;eAEc,kBAAkB"}
@@ -1 +1 @@
1
- {"version":3,"file":"sdk-boundary.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/claude-sdk-oauth/sdk-boundary.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,kBAAkB,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAC;AA2B3E,MAAM,kBAAkB,GAAgB,EAAE,KAAK,EAAE,kBAAkB,EAAE,CAAC;AACtE,IAAI,iBAAiB,GAAG,kBAAkB,CAAC;AAE3C,MAAM,UAAU,cAAc;IAC7B,OAAO,iBAAiB,CAAC;AAC1B,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,QAA8B;IACjE,iBAAiB,GAAG,EAAE,GAAG,kBAAkB,EAAE,GAAG,QAAQ,EAAE,CAAC;AAC5D,CAAC;AAED,MAAM,UAAU,gBAAgB;IAC/B,iBAAiB,GAAG,kBAAkB,CAAC;AACxC,CAAC;AAED,eAAe,kBAAkB,CAAC","sourcesContent":["import type {\n\tEffortLevel,\n\tOptions,\n\tSDKMessage,\n\tSDKUserMessage,\n\tSettingSource,\n\tThinkingConfig,\n} from \"@anthropic-ai/claude-agent-sdk\";\nimport { createSdkMcpServer, query } from \"@anthropic-ai/claude-agent-sdk\";\nimport type { Base64ImageSource, ContentBlockParam } from \"@anthropic-ai/sdk/resources\";\n\nexport type {\n\tBase64ImageSource,\n\tContentBlockParam,\n\tEffortLevel,\n\tOptions,\n\tSDKMessage,\n\tSDKUserMessage,\n\tSettingSource,\n\tThinkingConfig,\n};\n\nexport type SdkQueryInput = Parameters<typeof query>[0];\nexport type SdkQueryHandle = AsyncIterable<SDKMessage> & {\n\tinterrupt(): Promise<unknown>;\n\tclose(): void;\n\tinitializationResult?: () => Promise<unknown>;\n};\nexport type SdkQuery = (input: SdkQueryInput) => SdkQueryHandle;\n\nexport type SdkBoundary = {\n\tquery: SdkQuery;\n\tcreateSdkMcpServer: typeof createSdkMcpServer;\n};\n\nconst defaultSdkBoundary: SdkBoundary = { query, createSdkMcpServer };\nlet activeSdkBoundary = defaultSdkBoundary;\n\nexport function getSdkBoundary(): SdkBoundary {\n\treturn activeSdkBoundary;\n}\n\nexport function overrideSdkBoundary(override: Partial<SdkBoundary>): void {\n\tactiveSdkBoundary = { ...defaultSdkBoundary, ...override };\n}\n\nexport function resetSdkBoundary(): void {\n\tactiveSdkBoundary = defaultSdkBoundary;\n}\n\nexport default defaultSdkBoundary;\n"]}
1
+ {"version":3,"file":"sdk-boundary.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/claude-sdk-oauth/sdk-boundary.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,kBAAkB,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAC;AA4B3E,MAAM,kBAAkB,GAAgB,EAAE,KAAK,EAAE,kBAAkB,EAAE,CAAC;AACtE,IAAI,iBAAiB,GAAG,kBAAkB,CAAC;AAE3C,MAAM,UAAU,cAAc;IAC7B,OAAO,iBAAiB,CAAC;AAC1B,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,QAA8B;IACjE,iBAAiB,GAAG,EAAE,GAAG,kBAAkB,EAAE,GAAG,QAAQ,EAAE,CAAC;AAC5D,CAAC;AAED,MAAM,UAAU,gBAAgB;IAC/B,iBAAiB,GAAG,kBAAkB,CAAC;AACxC,CAAC;AAED,eAAe,kBAAkB,CAAC","sourcesContent":["import type {\n\tEffortLevel,\n\tOptions,\n\tSDKMessage,\n\tSDKUserMessage,\n\tSettingSource,\n\tThinkingConfig,\n} from \"@anthropic-ai/claude-agent-sdk\";\nimport { createSdkMcpServer, query } from \"@anthropic-ai/claude-agent-sdk\";\nimport type { Base64ImageSource, ContentBlockParam } from \"@anthropic-ai/sdk/resources\";\n\nexport type {\n\tBase64ImageSource,\n\tContentBlockParam,\n\tEffortLevel,\n\tOptions,\n\tSDKMessage,\n\tSDKUserMessage,\n\tSettingSource,\n\tThinkingConfig,\n};\n\nexport type SdkQueryInput = Parameters<typeof query>[0];\nexport type SdkQueryHandle = AsyncIterable<SDKMessage> & {\n\tinterrupt(): Promise<unknown>;\n\tsetModel?: (model?: string) => Promise<void>;\n\tclose(): void;\n\tinitializationResult?: () => Promise<unknown>;\n};\nexport type SdkQuery = (input: SdkQueryInput) => SdkQueryHandle;\n\nexport type SdkBoundary = {\n\tquery: SdkQuery;\n\tcreateSdkMcpServer: typeof createSdkMcpServer;\n};\n\nconst defaultSdkBoundary: SdkBoundary = { query, createSdkMcpServer };\nlet activeSdkBoundary = defaultSdkBoundary;\n\nexport function getSdkBoundary(): SdkBoundary {\n\treturn activeSdkBoundary;\n}\n\nexport function overrideSdkBoundary(override: Partial<SdkBoundary>): void {\n\tactiveSdkBoundary = { ...defaultSdkBoundary, ...override };\n}\n\nexport function resetSdkBoundary(): void {\n\tactiveSdkBoundary = defaultSdkBoundary;\n}\n\nexport default defaultSdkBoundary;\n"]}
@@ -0,0 +1,32 @@
1
+ import type { ContinuityDecision } from "./session-continuity.ts";
2
+ export declare const BINDING_ENTRY_TYPE = "claude-sdk-oauth-binding";
3
+ export type BindingCheckpoint = {
4
+ schemaVersion: 1;
5
+ sdkSessionId: string;
6
+ sentCount: number;
7
+ sentPrefixHash: string;
8
+ lastAssistantUuid: string | null;
9
+ accountName: string;
10
+ claudeConfigDir: string;
11
+ modelId: string;
12
+ };
13
+ export type BindingInvalidation = {
14
+ schemaVersion: 1;
15
+ invalidated: true;
16
+ reason: string;
17
+ };
18
+ type BranchEntry = {
19
+ type: string;
20
+ customType?: string;
21
+ data?: unknown;
22
+ };
23
+ export type BindingVerificationInput = {
24
+ binding: BindingCheckpoint;
25
+ transcriptExists: boolean;
26
+ transcriptHasBoundaryUuid: boolean;
27
+ currentSentPrefixHash: string;
28
+ };
29
+ export declare function latestBindingOnBranch(branch: readonly BranchEntry[]): BindingCheckpoint | undefined;
30
+ export declare function verifyBindingAgainstTranscript(input: BindingVerificationInput): ContinuityDecision;
31
+ export {};
32
+ //# sourceMappingURL=session-binding.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-binding.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/claude-sdk-oauth/session-binding.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAElE,eAAO,MAAM,kBAAkB,6BAA6B,CAAC;AAE7D,MAAM,MAAM,iBAAiB,GAAG;IAC/B,aAAa,EAAE,CAAC,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;IACvB,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAAE,aAAa,EAAE,CAAC,CAAC;IAAC,WAAW,EAAE,IAAI,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAE1F,KAAK,WAAW,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAEzE,MAAM,MAAM,wBAAwB,GAAG;IACtC,OAAO,EAAE,iBAAiB,CAAC;IAC3B,gBAAgB,EAAE,OAAO,CAAC;IAC1B,yBAAyB,EAAE,OAAO,CAAC;IACnC,qBAAqB,EAAE,MAAM,CAAC;CAC9B,CAAC;AAUF,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,SAAS,WAAW,EAAE,GAAG,iBAAiB,GAAG,SAAS,CAQnG;AAED,wBAAgB,8BAA8B,CAAC,KAAK,EAAE,wBAAwB,GAAG,kBAAkB,CAqBlG"}