@code-yeongyu/senpi 2026.8.30 → 2026.8.31

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 (331) hide show
  1. package/CHANGELOG.md +142 -2
  2. package/README.md +3 -0
  3. package/dist/core/agent-session.d.ts +28 -0
  4. package/dist/core/agent-session.d.ts.map +1 -1
  5. package/dist/core/agent-session.js +161 -14
  6. package/dist/core/agent-session.js.map +1 -1
  7. package/dist/core/compaction/compaction-execution.d.ts +14 -0
  8. package/dist/core/compaction/compaction-execution.d.ts.map +1 -0
  9. package/dist/core/compaction/compaction-execution.js +121 -0
  10. package/dist/core/compaction/compaction-execution.js.map +1 -0
  11. package/dist/core/compaction/compaction-settings.d.ts +17 -0
  12. package/dist/core/compaction/compaction-settings.d.ts.map +1 -0
  13. package/dist/core/compaction/compaction-settings.js +17 -0
  14. package/dist/core/compaction/compaction-settings.js.map +1 -0
  15. package/dist/core/compaction/compaction.d.ts +13 -26
  16. package/dist/core/compaction/compaction.d.ts.map +1 -1
  17. package/dist/core/compaction/compaction.js +7 -136
  18. package/dist/core/compaction/compaction.js.map +1 -1
  19. package/dist/core/compaction/ideal-compaction-settings.d.ts +9 -0
  20. package/dist/core/compaction/ideal-compaction-settings.d.ts.map +1 -0
  21. package/dist/core/compaction/ideal-compaction-settings.js +7 -0
  22. package/dist/core/compaction/ideal-compaction-settings.js.map +1 -0
  23. package/dist/core/compaction-settings-access.d.ts +19 -0
  24. package/dist/core/compaction-settings-access.d.ts.map +1 -0
  25. package/dist/core/compaction-settings-access.js +10 -0
  26. package/dist/core/compaction-settings-access.js.map +1 -0
  27. package/dist/core/compaction-settings-resolver.d.ts +22 -0
  28. package/dist/core/compaction-settings-resolver.d.ts.map +1 -0
  29. package/dist/core/compaction-settings-resolver.js +46 -0
  30. package/dist/core/compaction-settings-resolver.js.map +1 -0
  31. package/dist/core/extensions/builtin/claude-sdk-oauth/session-registry.d.ts +9 -1
  32. package/dist/core/extensions/builtin/claude-sdk-oauth/session-registry.d.ts.map +1 -1
  33. package/dist/core/extensions/builtin/claude-sdk-oauth/session-registry.js +10 -3
  34. package/dist/core/extensions/builtin/claude-sdk-oauth/session-registry.js.map +1 -1
  35. package/dist/core/extensions/builtin/compaction/context-pipeline.d.ts +18 -0
  36. package/dist/core/extensions/builtin/compaction/context-pipeline.d.ts.map +1 -0
  37. package/dist/core/extensions/builtin/compaction/context-pipeline.js +32 -0
  38. package/dist/core/extensions/builtin/compaction/context-pipeline.js.map +1 -0
  39. package/dist/core/extensions/builtin/compaction/deterministic-fallback.d.ts +1 -1
  40. package/dist/core/extensions/builtin/compaction/deterministic-fallback.d.ts.map +1 -1
  41. package/dist/core/extensions/builtin/compaction/deterministic-fallback.js +8 -2
  42. package/dist/core/extensions/builtin/compaction/deterministic-fallback.js.map +1 -1
  43. package/dist/core/extensions/builtin/compaction/emergency-prune.d.ts +17 -0
  44. package/dist/core/extensions/builtin/compaction/emergency-prune.d.ts.map +1 -0
  45. package/dist/core/extensions/builtin/compaction/emergency-prune.js +64 -0
  46. package/dist/core/extensions/builtin/compaction/emergency-prune.js.map +1 -0
  47. package/dist/core/extensions/builtin/compaction/extension-wiring.d.ts +27 -0
  48. package/dist/core/extensions/builtin/compaction/extension-wiring.d.ts.map +1 -0
  49. package/dist/core/extensions/builtin/compaction/extension-wiring.js +84 -0
  50. package/dist/core/extensions/builtin/compaction/extension-wiring.js.map +1 -0
  51. package/dist/core/extensions/builtin/compaction/idle-retry.d.ts +1 -1
  52. package/dist/core/extensions/builtin/compaction/idle-retry.d.ts.map +1 -1
  53. package/dist/core/extensions/builtin/compaction/idle-retry.js +1 -1
  54. package/dist/core/extensions/builtin/compaction/idle-retry.js.map +1 -1
  55. package/dist/core/extensions/builtin/compaction/idle.d.ts +1 -0
  56. package/dist/core/extensions/builtin/compaction/idle.d.ts.map +1 -1
  57. package/dist/core/extensions/builtin/compaction/idle.js +13 -2
  58. package/dist/core/extensions/builtin/compaction/idle.js.map +1 -1
  59. package/dist/core/extensions/builtin/compaction/index.d.ts +1 -1
  60. package/dist/core/extensions/builtin/compaction/index.d.ts.map +1 -1
  61. package/dist/core/extensions/builtin/compaction/index.js +148 -150
  62. package/dist/core/extensions/builtin/compaction/index.js.map +1 -1
  63. package/dist/core/extensions/builtin/compaction/log.d.ts +1 -1
  64. package/dist/core/extensions/builtin/compaction/log.d.ts.map +1 -1
  65. package/dist/core/extensions/builtin/compaction/log.js +2 -0
  66. package/dist/core/extensions/builtin/compaction/log.js.map +1 -1
  67. package/dist/core/extensions/builtin/compaction/model-selection.d.ts +14 -0
  68. package/dist/core/extensions/builtin/compaction/model-selection.d.ts.map +1 -0
  69. package/dist/core/extensions/builtin/compaction/model-selection.js +37 -0
  70. package/dist/core/extensions/builtin/compaction/model-selection.js.map +1 -0
  71. package/dist/core/extensions/builtin/compaction/model-usability-budget.d.ts +30 -0
  72. package/dist/core/extensions/builtin/compaction/model-usability-budget.d.ts.map +1 -0
  73. package/dist/core/extensions/builtin/compaction/model-usability-budget.js +74 -0
  74. package/dist/core/extensions/builtin/compaction/model-usability-budget.js.map +1 -0
  75. package/dist/core/extensions/builtin/compaction/openai-remote-dependencies.d.ts +9 -0
  76. package/dist/core/extensions/builtin/compaction/openai-remote-dependencies.d.ts.map +1 -0
  77. package/dist/core/extensions/builtin/compaction/openai-remote-dependencies.js +2 -0
  78. package/dist/core/extensions/builtin/compaction/openai-remote-dependencies.js.map +1 -0
  79. package/dist/core/extensions/builtin/compaction/openai-remote.d.ts +3 -6
  80. package/dist/core/extensions/builtin/compaction/openai-remote.d.ts.map +1 -1
  81. package/dist/core/extensions/builtin/compaction/openai-remote.js.map +1 -1
  82. package/dist/core/extensions/builtin/compaction/orchestration.d.ts +46 -0
  83. package/dist/core/extensions/builtin/compaction/orchestration.d.ts.map +1 -0
  84. package/dist/core/extensions/builtin/compaction/orchestration.js +103 -0
  85. package/dist/core/extensions/builtin/compaction/orchestration.js.map +1 -0
  86. package/dist/core/extensions/builtin/compaction/policy.d.ts +12 -2
  87. package/dist/core/extensions/builtin/compaction/policy.d.ts.map +1 -1
  88. package/dist/core/extensions/builtin/compaction/policy.js +52 -26
  89. package/dist/core/extensions/builtin/compaction/policy.js.map +1 -1
  90. package/dist/core/extensions/builtin/compaction/speculation-lead.d.ts +8 -0
  91. package/dist/core/extensions/builtin/compaction/speculation-lead.d.ts.map +1 -0
  92. package/dist/core/extensions/builtin/compaction/speculation-lead.js +17 -0
  93. package/dist/core/extensions/builtin/compaction/speculation-lead.js.map +1 -0
  94. package/dist/core/extensions/builtin/compaction/speculative-job.d.ts +22 -0
  95. package/dist/core/extensions/builtin/compaction/speculative-job.d.ts.map +1 -0
  96. package/dist/core/extensions/builtin/compaction/speculative-job.js +16 -0
  97. package/dist/core/extensions/builtin/compaction/speculative-job.js.map +1 -0
  98. package/dist/core/extensions/builtin/compaction/speculative-summary.d.ts +23 -0
  99. package/dist/core/extensions/builtin/compaction/speculative-summary.d.ts.map +1 -0
  100. package/dist/core/extensions/builtin/compaction/speculative-summary.js +132 -0
  101. package/dist/core/extensions/builtin/compaction/speculative-summary.js.map +1 -0
  102. package/dist/core/extensions/builtin/compaction/speculative.d.ts +8 -13
  103. package/dist/core/extensions/builtin/compaction/speculative.d.ts.map +1 -1
  104. package/dist/core/extensions/builtin/compaction/speculative.js +21 -197
  105. package/dist/core/extensions/builtin/compaction/speculative.js.map +1 -1
  106. package/dist/core/extensions/builtin/compaction/token-budget-reminder.d.ts +24 -0
  107. package/dist/core/extensions/builtin/compaction/token-budget-reminder.d.ts.map +1 -0
  108. package/dist/core/extensions/builtin/compaction/token-budget-reminder.js +25 -0
  109. package/dist/core/extensions/builtin/compaction/token-budget-reminder.js.map +1 -0
  110. package/dist/core/extensions/builtin/compaction/tool-admission.d.ts +27 -0
  111. package/dist/core/extensions/builtin/compaction/tool-admission.d.ts.map +1 -0
  112. package/dist/core/extensions/builtin/compaction/tool-admission.js +56 -0
  113. package/dist/core/extensions/builtin/compaction/tool-admission.js.map +1 -0
  114. package/dist/core/extensions/builtin/hooks/trust-state-json.d.ts +5 -0
  115. package/dist/core/extensions/builtin/hooks/trust-state-json.d.ts.map +1 -0
  116. package/dist/core/extensions/builtin/hooks/trust-state-json.js +76 -0
  117. package/dist/core/extensions/builtin/hooks/trust-state-json.js.map +1 -0
  118. package/dist/core/extensions/builtin/hooks/trust-storage.d.ts +7 -1
  119. package/dist/core/extensions/builtin/hooks/trust-storage.d.ts.map +1 -1
  120. package/dist/core/extensions/builtin/hooks/trust-storage.js +60 -8
  121. package/dist/core/extensions/builtin/hooks/trust-storage.js.map +1 -1
  122. package/dist/core/extensions/builtin/hooks/trust.d.ts +1 -2
  123. package/dist/core/extensions/builtin/hooks/trust.d.ts.map +1 -1
  124. package/dist/core/extensions/builtin/hooks/trust.js +1 -72
  125. package/dist/core/extensions/builtin/hooks/trust.js.map +1 -1
  126. package/dist/core/extensions/builtin/terminal/runtime-session.d.ts +11 -0
  127. package/dist/core/extensions/builtin/terminal/runtime-session.d.ts.map +1 -1
  128. package/dist/core/extensions/builtin/terminal/runtime-session.js +18 -2
  129. package/dist/core/extensions/builtin/terminal/runtime-session.js.map +1 -1
  130. package/dist/core/extensions/builtin/ttsr/index.d.ts.map +1 -1
  131. package/dist/core/extensions/builtin/ttsr/index.js +4 -0
  132. package/dist/core/extensions/builtin/ttsr/index.js.map +1 -1
  133. package/dist/core/extensions/builtin/ttsr/manager.d.ts +2 -0
  134. package/dist/core/extensions/builtin/ttsr/manager.d.ts.map +1 -1
  135. package/dist/core/extensions/builtin/ttsr/manager.js +28 -1
  136. package/dist/core/extensions/builtin/ttsr/manager.js.map +1 -1
  137. package/dist/core/extensions/runner.d.ts +5 -0
  138. package/dist/core/extensions/runner.d.ts.map +1 -1
  139. package/dist/core/extensions/runner.js +7 -0
  140. package/dist/core/extensions/runner.js.map +1 -1
  141. package/dist/core/retry-fallback/controller.d.ts +14 -0
  142. package/dist/core/retry-fallback/controller.d.ts.map +1 -1
  143. package/dist/core/retry-fallback/controller.js +33 -3
  144. package/dist/core/retry-fallback/controller.js.map +1 -1
  145. package/dist/core/retry-fallback/log.js +1 -1
  146. package/dist/core/retry-fallback/log.js.map +1 -1
  147. package/dist/core/sdk.d.ts.map +1 -1
  148. package/dist/core/sdk.js +5 -0
  149. package/dist/core/sdk.js.map +1 -1
  150. package/dist/core/session-activity.d.ts +47 -0
  151. package/dist/core/session-activity.d.ts.map +1 -0
  152. package/dist/core/session-activity.js +58 -0
  153. package/dist/core/session-activity.js.map +1 -0
  154. package/dist/core/session-manager.d.ts +8 -12
  155. package/dist/core/session-manager.d.ts.map +1 -1
  156. package/dist/core/session-manager.js +118 -7
  157. package/dist/core/session-manager.js.map +1 -1
  158. package/dist/core/session-resident-store.d.ts +8 -1
  159. package/dist/core/session-resident-store.d.ts.map +1 -1
  160. package/dist/core/session-resident-store.js +12 -5
  161. package/dist/core/session-resident-store.js.map +1 -1
  162. package/dist/core/settings-manager.d.ts +8 -85
  163. package/dist/core/settings-manager.d.ts.map +1 -1
  164. package/dist/core/settings-manager.js +9 -17
  165. package/dist/core/settings-manager.js.map +1 -1
  166. package/dist/core/settings-public-types.d.ts +11 -0
  167. package/dist/core/settings-public-types.d.ts.map +1 -0
  168. package/dist/core/settings-public-types.js +2 -0
  169. package/dist/core/settings-public-types.js.map +1 -0
  170. package/dist/core/settings-shapes.d.ts +36 -0
  171. package/dist/core/settings-shapes.d.ts.map +1 -0
  172. package/dist/core/settings-shapes.js +2 -0
  173. package/dist/core/settings-shapes.js.map +1 -0
  174. package/dist/core/shared-host-policy.d.ts +6 -0
  175. package/dist/core/shared-host-policy.d.ts.map +1 -0
  176. package/dist/core/shared-host-policy.js +7 -0
  177. package/dist/core/shared-host-policy.js.map +1 -0
  178. package/dist/core/terminal-settings.d.ts +22 -0
  179. package/dist/core/terminal-settings.d.ts.map +1 -0
  180. package/dist/core/terminal-settings.js +2 -0
  181. package/dist/core/terminal-settings.js.map +1 -0
  182. package/dist/index.d.ts +1 -1
  183. package/dist/index.d.ts.map +1 -1
  184. package/dist/index.js +1 -1
  185. package/dist/index.js.map +1 -1
  186. package/dist/main.d.ts.map +1 -1
  187. package/dist/main.js +17 -5
  188. package/dist/main.js.map +1 -1
  189. package/dist/modes/app-server/daemon.js +3 -3
  190. package/dist/modes/app-server/daemon.js.map +1 -1
  191. package/dist/modes/index.d.ts +1 -1
  192. package/dist/modes/index.d.ts.map +1 -1
  193. package/dist/modes/index.js +1 -1
  194. package/dist/modes/index.js.map +1 -1
  195. package/dist/modes/interactive/interactive-host-runtime.d.ts +84 -1
  196. package/dist/modes/interactive/interactive-host-runtime.d.ts.map +1 -1
  197. package/dist/modes/interactive/interactive-host-runtime.js +435 -112
  198. package/dist/modes/interactive/interactive-host-runtime.js.map +1 -1
  199. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  200. package/dist/modes/interactive/interactive-mode.js +24 -0
  201. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  202. package/dist/modes/rpc/connection-handler.d.ts +12 -5
  203. package/dist/modes/rpc/connection-handler.d.ts.map +1 -1
  204. package/dist/modes/rpc/connection-handler.js +173 -23
  205. package/dist/modes/rpc/connection-handler.js.map +1 -1
  206. package/dist/modes/rpc/custom-capability.d.ts +1 -0
  207. package/dist/modes/rpc/custom-capability.d.ts.map +1 -1
  208. package/dist/modes/rpc/custom-capability.js +1 -0
  209. package/dist/modes/rpc/custom-capability.js.map +1 -1
  210. package/dist/modes/rpc/host-ensure.d.ts +17 -0
  211. package/dist/modes/rpc/host-ensure.d.ts.map +1 -1
  212. package/dist/modes/rpc/host-ensure.js +67 -16
  213. package/dist/modes/rpc/host-ensure.js.map +1 -1
  214. package/dist/modes/rpc/host-lifecycle.d.ts +39 -0
  215. package/dist/modes/rpc/host-lifecycle.d.ts.map +1 -1
  216. package/dist/modes/rpc/host-lifecycle.js +80 -15
  217. package/dist/modes/rpc/host-lifecycle.js.map +1 -1
  218. package/dist/modes/rpc/multi-session-host.d.ts +38 -0
  219. package/dist/modes/rpc/multi-session-host.d.ts.map +1 -1
  220. package/dist/modes/rpc/multi-session-host.js +55 -5
  221. package/dist/modes/rpc/multi-session-host.js.map +1 -1
  222. package/dist/modes/rpc/ownership-safe-lock.d.ts +14 -0
  223. package/dist/modes/rpc/ownership-safe-lock.d.ts.map +1 -0
  224. package/dist/modes/rpc/ownership-safe-lock.js +87 -0
  225. package/dist/modes/rpc/ownership-safe-lock.js.map +1 -0
  226. package/dist/modes/rpc/rpc-client.d.ts +13 -2
  227. package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
  228. package/dist/modes/rpc/rpc-client.js +38 -11
  229. package/dist/modes/rpc/rpc-client.js.map +1 -1
  230. package/dist/modes/rpc/rpc-types.d.ts +21 -3
  231. package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
  232. package/dist/modes/rpc/rpc-types.js +1 -0
  233. package/dist/modes/rpc/rpc-types.js.map +1 -1
  234. package/dist/modes/rpc/session-binding.d.ts +2 -1
  235. package/dist/modes/rpc/session-binding.d.ts.map +1 -1
  236. package/dist/modes/rpc/session-binding.js +1 -0
  237. package/dist/modes/rpc/session-binding.js.map +1 -1
  238. package/dist/modes/rpc/session-command-router.d.ts +54 -1
  239. package/dist/modes/rpc/session-command-router.d.ts.map +1 -1
  240. package/dist/modes/rpc/session-command-router.js +174 -2
  241. package/dist/modes/rpc/session-command-router.js.map +1 -1
  242. package/dist/modes/rpc/session-event-writer.d.ts +18 -0
  243. package/dist/modes/rpc/session-event-writer.d.ts.map +1 -1
  244. package/dist/modes/rpc/session-event-writer.js +88 -8
  245. package/dist/modes/rpc/session-event-writer.js.map +1 -1
  246. package/dist/modes/rpc/session-registry.d.ts +11 -1
  247. package/dist/modes/rpc/session-registry.d.ts.map +1 -1
  248. package/dist/modes/rpc/session-registry.js +25 -0
  249. package/dist/modes/rpc/session-registry.js.map +1 -1
  250. package/dist/modes/rpc/widget-line-renderer.d.ts +17 -0
  251. package/dist/modes/rpc/widget-line-renderer.d.ts.map +1 -0
  252. package/dist/modes/rpc/widget-line-renderer.js +73 -0
  253. package/dist/modes/rpc/widget-line-renderer.js.map +1 -0
  254. package/dist/utils/fs-watch.d.ts.map +1 -1
  255. package/dist/utils/fs-watch.js +11 -2
  256. package/dist/utils/fs-watch.js.map +1 -1
  257. package/docs/app-server.md +2 -2
  258. package/docs/containerization.md +2 -2
  259. package/docs/development.md +7 -7
  260. package/docs/extensions.md +4 -4
  261. package/docs/grok-neo.md +1 -1
  262. package/docs/index.md +1 -1
  263. package/docs/packages.md +2 -2
  264. package/docs/quickstart.md +4 -4
  265. package/docs/release-guide.md +21 -21
  266. package/docs/rpc.md +78 -5
  267. package/docs/sdk.md +1 -1
  268. package/docs/skills.md +2 -2
  269. package/docs/terminal-tools.md +1 -1
  270. package/docs/termux.md +1 -1
  271. package/docs/tui.md +1 -1
  272. package/examples/AGENTS.md +1 -1
  273. package/examples/sdk/README.md +1 -1
  274. package/node_modules/@code-yeongyu/senpi-codemode/CHANGELOG.md +40 -0
  275. package/node_modules/@code-yeongyu/senpi-codemode/README.md +2 -2
  276. package/node_modules/@code-yeongyu/senpi-codemode/package.json +4 -4
  277. package/node_modules/@code-yeongyu/senpi-codemode/src/extension/skill-contribution.ts +71 -0
  278. package/node_modules/@code-yeongyu/senpi-codemode/src/index.ts +3 -1
  279. package/node_modules/@code-yeongyu/senpi-codemode/src/skill/bun-1-4/SKILL.md +44 -0
  280. package/node_modules/@code-yeongyu/senpi-codemode/src/skill/bun-1-4/references/breaking-changes.md +75 -0
  281. package/node_modules/@code-yeongyu/senpi-codemode/src/skill/bun-1-4/references/build.md +114 -0
  282. package/node_modules/@code-yeongyu/senpi-codemode/src/skill/bun-1-4/references/dev-tooling.md +34 -0
  283. package/node_modules/@code-yeongyu/senpi-codemode/src/skill/bun-1-4/references/http-networking.md +113 -0
  284. package/node_modules/@code-yeongyu/senpi-codemode/src/skill/bun-1-4/references/install.md +93 -0
  285. package/node_modules/@code-yeongyu/senpi-codemode/src/skill/bun-1-4/references/node-compat-platforms.md +36 -0
  286. package/node_modules/@code-yeongyu/senpi-codemode/src/skill/bun-1-4/references/performance.md +33 -0
  287. package/node_modules/@code-yeongyu/senpi-codemode/src/skill/bun-1-4/references/runtime-apis.md +156 -0
  288. package/node_modules/@code-yeongyu/senpi-codemode/src/skill/bun-1-4/references/security.md +52 -0
  289. package/node_modules/@code-yeongyu/senpi-codemode/src/skill/bun-1-4/references/test.md +103 -0
  290. package/node_modules/@earendil-works/pi-agent-core/README.md +3 -0
  291. package/node_modules/@earendil-works/pi-agent-core/package.json +3 -3
  292. package/node_modules/@earendil-works/pi-ai/README.md +6 -3
  293. package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.d.ts.map +1 -1
  294. package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js +24 -7
  295. package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js.map +1 -1
  296. package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent.d.ts +7 -0
  297. package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent.d.ts.map +1 -1
  298. package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent.js +316 -2
  299. package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent.js.map +1 -1
  300. package/node_modules/@earendil-works/pi-ai/dist/api/cursor-conversation-rotation.d.ts +4 -0
  301. package/node_modules/@earendil-works/pi-ai/dist/api/cursor-conversation-rotation.d.ts.map +1 -1
  302. package/node_modules/@earendil-works/pi-ai/dist/api/cursor-conversation-rotation.js +23 -0
  303. package/node_modules/@earendil-works/pi-ai/dist/api/cursor-conversation-rotation.js.map +1 -1
  304. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.d.ts +24 -0
  305. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.d.ts.map +1 -1
  306. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.js +20 -2
  307. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.js.map +1 -1
  308. package/node_modules/@earendil-works/pi-ai/dist/providers/data/.manifest.json +1 -1
  309. package/node_modules/@earendil-works/pi-ai/dist/providers/data/openrouter.json +1 -1
  310. package/node_modules/@earendil-works/pi-ai/dist/providers/data/vercel-ai-gateway.json +1 -1
  311. package/node_modules/@earendil-works/pi-ai/package.json +2 -2
  312. package/node_modules/@earendil-works/pi-pty/dist/screen-operations.d.ts +42 -0
  313. package/node_modules/@earendil-works/pi-pty/dist/screen-operations.d.ts.map +1 -0
  314. package/node_modules/@earendil-works/pi-pty/dist/screen-operations.js +34 -0
  315. package/node_modules/@earendil-works/pi-pty/dist/screen-operations.js.map +1 -0
  316. package/node_modules/@earendil-works/pi-pty/dist/screen-text.d.ts +8 -0
  317. package/node_modules/@earendil-works/pi-pty/dist/screen-text.d.ts.map +1 -0
  318. package/node_modules/@earendil-works/pi-pty/dist/screen-text.js +51 -0
  319. package/node_modules/@earendil-works/pi-pty/dist/screen-text.js.map +1 -0
  320. package/node_modules/@earendil-works/pi-pty/dist/screen.d.ts +45 -0
  321. package/node_modules/@earendil-works/pi-pty/dist/screen.d.ts.map +1 -1
  322. package/node_modules/@earendil-works/pi-pty/dist/screen.js +178 -55
  323. package/node_modules/@earendil-works/pi-pty/dist/screen.js.map +1 -1
  324. package/node_modules/@earendil-works/pi-pty/package.json +1 -1
  325. package/node_modules/@earendil-works/pi-telemetry/README.md +6 -3
  326. package/node_modules/@earendil-works/pi-telemetry/package.json +1 -1
  327. package/node_modules/@earendil-works/pi-tui/README.md +5 -4
  328. package/node_modules/@earendil-works/pi-tui/native/darwin/README.md +2 -2
  329. package/node_modules/@earendil-works/pi-tui/native/win32/README.md +2 -2
  330. package/node_modules/@earendil-works/pi-tui/package.json +1 -1
  331. package/package.json +7 -7
@@ -0,0 +1,156 @@
1
+ # Bun 1.4 Runtime Builtins
2
+
3
+ Every API here ships inside the Bun binary: no install step, no native build, no lockfile entry. Version tags mark the minimum Bun version.
4
+
5
+ ## Bun.Image — image processing (replaces sharp) [v1.3.14]
6
+
7
+ Docs: <https://bun.com/docs/runtime/image> · Blog: [#bun-image](https://bun.com/blog/bun-v1.4#bun-image)
8
+
9
+ ```ts
10
+ await Bun.file("photo.jpg")
11
+ .image()
12
+ .resize(1024, 1024, { fit: "inside" })
13
+ .rotate(90)
14
+ .webp({ quality: 85 })
15
+ .write("thumb.webp");
16
+
17
+ // Stream straight into a Response
18
+ return new Response(new Bun.Image(upload).resize(200).jpeg());
19
+ ```
20
+
21
+ - Decode/resize/rotate/encode JPEG, PNG, WebP, GIF, BMP everywhere; HEIC, AVIF, TIFF on macOS and Windows.
22
+ - API mirrors sharp; 1.19-1.38x faster than sharp; ICC profiles (Display P3) survive transcoding.
23
+
24
+ ## Bun.WebView — headless browser (replaces puppeteer for scraping/screenshots) [v1.3.12, improved v1.4.0]
25
+
26
+ Docs: <https://bun.com/docs/runtime/webview> · Blog: [#bun-webview](https://bun.com/blog/bun-v1.4#bun-webview)
27
+
28
+ ```ts
29
+ await using view = new Bun.WebView({ width: 800, height: 600 });
30
+ await view.navigate("https://bun.sh");
31
+ await view.click("a[href='/docs']");
32
+ const title = await view.evaluate("document.title");
33
+ await Bun.write("page.png", await view.screenshot());
34
+ ```
35
+
36
+ - macOS: system WebKit, nothing to install. macOS/Linux/Windows: can drive installed Chrome/Chromium/Edge.
37
+ - Clicks/scrolls are trusted user input (`event.isTrusted === true`).
38
+ - Extends `EventTarget`; screenshots are `Blob`s; `.cdp(method, params?)` escape hatch for raw Chrome DevTools Protocol.
39
+
40
+ ## Bun.markdown — Markdown parser (replaces marked) [v1.3.8, improved v1.4.0]
41
+
42
+ Docs: <https://bun.com/docs/runtime/markdown> · Blog: [#bun-markdown](https://bun.com/blog/bun-v1.4#bun-markdown)
43
+
44
+ ```ts
45
+ const html = Bun.markdown.html("# Hello **world**"); // HTML string
46
+ const el = Bun.markdown.react(readme); // React elements; swap components per tag
47
+ const ansi = Bun.markdown.render("# Hi\n\n**bold**", { // callback per element (terminal output etc.)
48
+ heading: (children) => `\x1b[1;4m${children}\x1b[0m\n`,
49
+ paragraph: (children) => children + "\n",
50
+ strong: (children) => `\x1b[1m${children}\x1b[22m`,
51
+ });
52
+ ```
53
+
54
+ - GFM tables, strikethrough, task lists, autolinks. `.md` is a bundler loader. Linear time on adversarial input.
55
+ - **HTML output is NOT sanitized** — raw HTML, event handlers, `javascript:` hrefs pass through. Sanitize before serving user content.
56
+ - Bonus: `bun ./README.md` renders Markdown to the terminal (replaces glow).
57
+
58
+ ## Bun.cron() — scheduled jobs (replaces node-cron) [v1.3.11, improved v1.4.0]
59
+
60
+ Docs: <https://bun.com/docs/runtime/cron> · Blog: [#bun-cron](https://bun.com/blog/bun-v1.4#bun-cron)
61
+
62
+ ```ts
63
+ // OS-level job: crontab (Linux), launchd (macOS), Task Scheduler (Windows)
64
+ await Bun.cron("./worker.ts", "30 2 * * MON", "weekly-report");
65
+ // worker.ts exports: export default { async scheduled(controller) { ... } } // Cloudflare Workers shape
66
+
67
+ // In-process job on the event loop, no system cron
68
+ using job = Bun.cron("*/5 * * * *", async () => { await cleanupTempFiles(); });
69
+ job.unref(); job.stop(); // or let `using` dispose
70
+
71
+ Bun.cron.parse("*/15 * * * *"); // → next matching Date
72
+ ```
73
+
74
+ - 5-field syntax incl. named days and `@daily`. Jobs never overlap.
75
+ - **v1.4 change:** `parse()` and in-process schedules use LOCAL time (was UTC). Pass `{ tz: "UTC" }` to keep UTC.
76
+
77
+ ## Bun.Terminal — native PTY (replaces node-pty) [v1.3.5, improved v1.4.0]
78
+
79
+ Docs: <https://bun.com/docs/runtime/child-process#terminal-pty-support> · Blog: [#bun-terminal](https://bun.com/blog/bun-v1.4#bun-terminal)
80
+
81
+ ```ts
82
+ const proc = Bun.spawn(["bash"], {
83
+ terminal: {
84
+ cols: 80, rows: 24,
85
+ data(term, data) { process.stdout.write(data); },
86
+ },
87
+ });
88
+ proc.terminal.write("echo Hello from PTY!\n");
89
+ ```
90
+
91
+ - Drive bash/vim/htop with colored output; resize; works on Linux, macOS, Windows.
92
+ - `write()` returns full input length (whole input buffered); `drain` fires on POSIX.
93
+
94
+ ## bun run --parallel — concurrent scripts (replaces concurrently, npm-run-all) [v1.3.9, improved v1.4.0]
95
+
96
+ Blog: [#bun-run-parallel](https://bun.com/blog/bun-v1.4#bun-run-parallel)
97
+
98
+ ```bash
99
+ bun run --parallel build test # named scripts concurrently
100
+ bun run --parallel "build:*" # glob-matched
101
+ bun run --parallel --filter '*' build # every workspace package
102
+ bun run --parallel --no-exit-on-error --filter '*' test # keep going past failures
103
+ ```
104
+
105
+ - Output lines prefixed with script name (`package:script` under `--filter`); pre/post hooks stay ordered; `--sequential` for one-at-a-time with same prefixing.
106
+
107
+ ## bun:ffi — 3x faster, engine-native [v1.4.0]
108
+
109
+ Docs: <https://bun.com/docs/runtime/ffi> · Blog: [#3x-faster-bun-ffi](https://bun.com/blog/bun-v1.4#3x-faster-bun-ffi)
110
+
111
+ ```ts
112
+ import { dlopen } from "bun:ffi";
113
+ const { symbols } = dlopen("libhash.so", {
114
+ hash: { args: ["buffer", "buffer_length"], returns: "cstring" },
115
+ });
116
+ const digest = symbols.hash(data, data); // typeof digest === "string"
117
+ ```
118
+
119
+ - FFI is built into JavaScriptCore (TinyCC removed): no-op call 0.70ns (3x), `CString` 3.8x faster. Hot call sites JIT into direct C calls.
120
+ - New `buffer_length` arg type passes a TypedArray's length with its pointer.
121
+ - **Breaking:** `cstring` returns are plain strings (`NULL` → `null`); `new CString(ptr)` has no `.ptr` anymore — keep the original pointer to free it. See [breaking-changes](breaking-changes.md).
122
+
123
+ ## Data format parsers
124
+
125
+ Blog: [#also-built-in](https://bun.com/blog/bun-v1.4#also-built-in)
126
+
127
+ | API | Replaces | Notes |
128
+ |---|---|---|
129
+ | `Bun.JSON5.parse()/stringify()` | json5 | `.json5` files importable directly |
130
+ | `Bun.JSONL.parse()` / streaming `parseChunk()` | ndjson | newline-delimited JSON |
131
+ | `Bun.JSONC.parse()` | jsonc-parser | comments + trailing commas (the tsconfig parser); throws `SyntaxError` on invalid input |
132
+ | `Bun.XML.parse()/stringify()` | fast-xml-parser, xml2js | SIMD; `.xml` files importable (v1.4: import returns parsed doc, not path) |
133
+ | `Bun.TOML.parse()/stringify()` | @iarna/toml | TOML v1.1.0, 708/708 toml-test; v1.4 is strict — unquoted strings throw `SyntaxError` |
134
+ | `Bun.YAML.parse()` | — | YAML 1.2: `yes/no/on/off` are strings, not booleans |
135
+ | `Bun.Archive` | tar | create/extract tarballs off the main thread — docs <https://bun.com/docs/runtime/archive> |
136
+
137
+ ## Terminal text utilities (replaces string-width, slice-ansi, cli-truncate, wrap-ansi)
138
+
139
+ Docs: <https://bun.com/docs/runtime/utils>
140
+
141
+ ```ts
142
+ Bun.stringWidth("한글 text"); // terminal columns, ANSI + grapheme aware
143
+ Bun.sliceAnsi(str, 0, 20); // slice by columns, preserving ANSI codes
144
+ Bun.wrapAnsi(str, 80); // wrap by columns
145
+ ```
146
+
147
+ ## Everything else new in the runtime
148
+
149
+ - **`URLPattern`**: the Web API, 408 WPT passing. Replaces path-to-regexp.
150
+ - **`CompressionStream` / `DecompressionStream`**: gzip, deflate, deflate-raw + brotli and zstd.
151
+ - **`Response.textStream()`**: `ReadableStream<string>` of the body decoded as UTF-8.
152
+ - **`process.on("memoryPressure")`**: OS low-memory notification on macOS/Linux/Windows.
153
+ - **ML-DSA and ML-KEM**: NIST post-quantum signatures/KEM in `crypto.subtle` and `node:crypto`.
154
+ - **`Bun.spawn({ cgroup })`**: place a child in a cgroup before it starts (Linux). Docs: <https://bun.com/docs/runtime/child-process#resource-limits-with-cgroups-linux>
155
+ - **`bun repl`** [native]: highlighting, history, tab completion, `-e`/`-p`. Docs: <https://bun.com/docs/runtime/repl>
156
+ - **`Temporal`** is defined by default (JSC implementation). `BUN_JSC_useTemporal=0` disables.
@@ -0,0 +1,52 @@
1
+ # Bun 1.4 Security Tightening
2
+
3
+ Blog: [#security](https://bun.com/blog/bun-v1.4#security)
4
+
5
+ 1.4 tightened TLS/parsing defaults. **A connection that worked on 1.3 can now fail with a verification error — that is usually the fix working, not a bug.** Diagnose before loosening.
6
+
7
+ ## checkServerIdentity runs BEFORE fetch() sends [v1.4.0]
8
+
9
+ ```ts
10
+ await fetch("https://api.example.com/upload", {
11
+ method: "POST",
12
+ body: secretPayload,
13
+ tls: {
14
+ checkServerIdentity(hostname, cert) {
15
+ if (cert.fingerprint256 !== PINNED) return new Error("pin mismatch");
16
+ },
17
+ },
18
+ });
19
+ // nothing is sent until the callback returns undefined; re-runs on each redirect hop
20
+ ```
21
+
22
+ If you pin a cert and the URL redirects through another host, the callback sees that cert too — accept every hop or use `redirect: "manual"`.
23
+
24
+ ## tls.connect defaults servername to host [v1.3.13]
25
+
26
+ `tls.connect({ host, port })` without `servername` uses `host` for SNI + identity check (matches Node). Connecting by IP or `localhost` to a cert issued for another name now fails with `ERR_TLS_CERT_ALTNAME_INVALID` — including through drivers like `pg`/`ioredis`. Fix: pass the cert's name as `servername`, or `checkServerIdentity: () => undefined` if trusting by CA alone.
27
+
28
+ ```ts
29
+ tls.connect({ host: "10.0.0.12", port: 5432, ca, servername: "db.internal" });
30
+ ```
31
+
32
+ ## Bun.connect / Bun.listen enforce rejectUnauthorized [v1.4.0]
33
+
34
+ `Bun.connect({ tls })`, `socket.upgradeTLS()`, and `Bun.listen()` with `requestCert: true` default to `rejectUnauthorized: true`. A self-signed dev server with no `ca` does NOT throw — the `handshake` handler runs with `socket.authorized === false`, writes return `-1`, and the socket closes without data. Pass the CA in `tls`, or `rejectUnauthorized: false` (`NODE_TLS_REJECT_UNAUTHORIZED=0` honored).
35
+
36
+ ## RedisClient verifies TLS hostname [v1.3.14]
37
+
38
+ `rediss://` checks the server cert against the URL host; first command rejects with `ERR_TLS_CERT_ALTNAME_INVALID` on mismatch. Connect by the certificate's name, or pass `tls: { rejectUnauthorized: false }`.
39
+
40
+ ## HTTP request parsing hardening in Bun.serve [v1.3.4]
41
+
42
+ More malformed `Content-Length` / `Transfer-Encoding` / chunked bodies get `400` + connection close, without calling your `fetch` handler or logging. Browsers/curl/proxies never send these; if a hand-written client starts seeing 400s, fix its framing headers.
43
+
44
+ ## Tarball extraction hardening [v1.3.6]
45
+
46
+ `github:`/URL dependencies and `bun create` templates skip tar entries that would land outside the package directory. A post-upgrade `Cannot find module` for such a package usually means the repo has a symlink pointing outside the package — replace it with a real file or relative link.
47
+
48
+ ## Also
49
+
50
+ - Registry credentials stay scoped to their configured host: never sent cross-origin, never downgraded to `http://`, never printed in errors/verbose output.
51
+ - `tls.createServer({ requestCert: true })` now rejects unverified client certs by default; only a literal `rejectUnauthorized: false` disables verification (`null` no longer counts).
52
+ - Full list: [Security hardening](https://bun.com/blog/bun-v1.4#security-hardening) in the changelog; advisories at <https://github.com/oven-sh/bun/security/advisories>.
@@ -0,0 +1,103 @@
1
+ # bun test in 1.4
2
+
3
+ Composable CI recipe:
4
+
5
+ ```bash
6
+ bun test --changed=main # only what your branch touches
7
+ bun test --parallel --timings=timings.json --update-timings
8
+ bun test --parallel --shard=1/3 --timings=timings.json # in CI, per machine
9
+ ```
10
+
11
+ ## --parallel: worker processes [v1.3.13, improved v1.4.0]
12
+
13
+ Blog: [#bun-test-parallel](https://bun.com/blog/bun-v1.4#bun-test-parallel)
14
+
15
+ ```bash
16
+ bun test --parallel # N = CPU count
17
+ bun test --parallel=4
18
+ ```
19
+
20
+ - Files go to whichever worker frees up next. Coverage and JUnit output merged across workers; `--bail` stops every worker.
21
+ - `--parallel` implies `--isolate`; `--no-isolate` opts out.
22
+ - Workers expose 1-indexed `JEST_WORKER_ID` / `BUN_TEST_WORKER_ID`, so Jest setups keying DBs/ports off worker id work unchanged.
23
+ - Preload scripts with top-level `await` complete before any worker runs tests.
24
+
25
+ ## --isolate: fresh global per file [v1.3.13, hardened v1.4.0]
26
+
27
+ Blog: [#bun-test-isolate](https://bun.com/blog/bun-v1.4#bun-test-isolate)
28
+
29
+ ```bash
30
+ bun test --isolate
31
+ ```
32
+
33
+ Between files, Bun creates a new `globalThis`, clears ESM/CJS module registries, closes leaked servers/sockets/watchers/subprocesses, cancels timers, restores fake timers, and re-runs `--preload`. Transpiled source/bytecode stay cached process-wide, so only top-level code re-runs. This is how Jest/Vitest behave by default — use it to kill "passes alone, fails in the full suite" bugs. v1.4 fixed the 1.3.13 stability issues (fake-timer leaks, module-scope subprocess leaks, `process.chdir` bleed, N-API across files, debugger breakpoints).
34
+
35
+ ## --shard: split across CI machines [v1.3.13]
36
+
37
+ Blog: [#bun-test-shard](https://bun.com/blog/bun-v1.4#bun-test-shard)
38
+
39
+ ```bash
40
+ bun test --shard=1/3 # deterministic, round-robin, 1-based (matches Jest/Vitest/Playwright)
41
+ ```
42
+
43
+ Works with `--changed` and `--randomize`; an empty shard exits 0.
44
+
45
+ ## --timings: balance by wall time [v1.4.0]
46
+
47
+ Blog: [#bun-test-timings](https://bun.com/blog/bun-v1.4#bun-test-timings)
48
+
49
+ ```bash
50
+ bun test --timings=timings.json --update-timings # record per-file durations
51
+ bun test --shard=1/3 --timings=timings.json # shards cut by equal time, not file count
52
+ bun test --parallel --timings=timings.json # workers start slowest file first (LPT scheduling)
53
+ ```
54
+
55
+ The timings file is written slowest-first, so it doubles as a slow-test report. Files sharing imports stay together (warm module cache).
56
+
57
+ ## --changed: only affected tests [v1.3.13]
58
+
59
+ Blog: [#bun-test-changed](https://bun.com/blog/bun-v1.4#bun-test-changed)
60
+
61
+ ```bash
62
+ bun test --changed # uncommitted (unstaged + staged + untracked)
63
+ bun test --changed=main # diff against branch/commit/tag
64
+ bun test --changed --watch # re-filters on every restart
65
+ ```
66
+
67
+ Bun scans test imports, asks git what changed, walks the import graph backwards. tsconfig `paths` aliases (`@/*`) work. Vitest-compatible flag.
68
+
69
+ ## --retry and repeats [v1.3.3]
70
+
71
+ Blog: [#bun-test-retry](https://bun.com/blog/bun-v1.4#bun-test-retry)
72
+
73
+ ```ts
74
+ test("flaky network call", async () => { await fetch("https://example.com"); }, { retry: 5 });
75
+ test("stress", () => { if (Math.random() < 0.1) throw new Error("uh oh!"); }, { repeats: 20 });
76
+ ```
77
+
78
+ `bun test --retry <N>` sets a suite-wide default. NOTE: prefer fixing the flake; retry is a containment tool.
79
+
80
+ ## jest.useFakeTimers() [v1.3.4, improved v1.4.0]
81
+
82
+ Blog: [#jest-usefaketimers](https://bun.com/blog/bun-v1.4#jest-usefaketimers)
83
+
84
+ ```ts
85
+ import { jest, test, expect } from "bun:test";
86
+ test("debounce", () => {
87
+ jest.useFakeTimers();
88
+ let called = 0;
89
+ setTimeout(() => called++, 1000);
90
+ jest.advanceTimersByTime(1000);
91
+ expect(called).toBe(1);
92
+ jest.useRealTimers();
93
+ });
94
+ ```
95
+
96
+ - Controls `setTimeout`, `setInterval`, `Date`. `jest.setSystemTime()` works with `advanceTimersByTime()`.
97
+ - `@testing-library/react`'s `waitFor` detects fake timers and advances instead of sleeping. `Bun.cron` schedules can be driven by the fake clock.
98
+
99
+ ## Behavior changes in 1.4 (test-related)
100
+
101
+ - `jest.resetAllMocks()` now drops implementations too (matches Jest); use `clearAllMocks()` for history-only.
102
+ - `expect().toContain()` compares with `===` not `Object.is` (`[NaN]` no longer contains `NaN`).
103
+ - `toEqual()` compares `Temporal` objects by value.
@@ -6,6 +6,9 @@ Stateful agent with tool execution and event streaming. Built on `@earendil-work
6
6
 
7
7
  ```bash
8
8
  npm install @earendil-works/pi-agent-core
9
+
10
+ # Bun alternative
11
+ bun add @earendil-works/pi-agent-core
9
12
  ```
10
13
 
11
14
  ### SQLite session backends
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@earendil-works/pi-agent-core",
3
- "version": "2026.8.30",
3
+ "version": "2026.8.31",
4
4
  "description": "General-purpose agent with transport abstraction, state management, and attachment support",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -35,8 +35,8 @@
35
35
  "prepublishOnly": "npm run build"
36
36
  },
37
37
  "dependencies": {
38
- "@earendil-works/pi-ai": "npm:@code-yeongyu/senpi-ai@2026.8.30",
39
- "@earendil-works/pi-telemetry": "npm:@code-yeongyu/senpi-telemetry@2026.8.30",
38
+ "@earendil-works/pi-ai": "npm:@code-yeongyu/senpi-ai@2026.8.31",
39
+ "@earendil-works/pi-telemetry": "npm:@code-yeongyu/senpi-telemetry@2026.8.31",
40
40
  "diff": "9.0.0",
41
41
  "ignore": "7.0.6",
42
42
  "typebox": "1.3.18",
@@ -97,6 +97,9 @@ Unified LLM API with provider collections, automatic auth resolution, token and
97
97
 
98
98
  ```bash
99
99
  npm install @earendil-works/pi-ai
100
+
101
+ # Bun alternative
102
+ bun add @earendil-works/pi-ai
100
103
  ```
101
104
 
102
105
  TypeBox exports are re-exported from `@earendil-works/pi-ai`: `Type`, `Static`, and `TSchema`.
@@ -1552,9 +1555,9 @@ Official docs: [Application Default Credentials](https://cloud.google.com/docs/a
1552
1555
  The quickest way to authenticate:
1553
1556
 
1554
1557
  ```bash
1555
- npx @earendil-works/pi-ai login # interactive provider selection
1556
- npx @earendil-works/pi-ai login anthropic # login to specific provider
1557
- npx @earendil-works/pi-ai list # list available providers
1558
+ bunx @earendil-works/pi-ai login # interactive provider selection
1559
+ bunx @earendil-works/pi-ai login anthropic # login to specific provider
1560
+ bunx @earendil-works/pi-ai list # list available providers
1558
1561
  ```
1559
1562
 
1560
1563
  Credentials are saved to `auth.json` in the current directory.
@@ -1 +1 @@
1
- {"version":3,"file":"anthropic-messages.d.ts","sourceRoot":"","sources":["../../src/api/anthropic-messages.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,mBAAmB,CAAC;AAC1C,OAAO,KAAK,EAGX,+BAA+B,EAK/B,MAAM,yCAAyC,CAAC;AAEjD,OAAO,KAAK,EACX,wBAAwB,EAKxB,OAAO,EAGP,KAAK,EAGL,mBAAmB,EAEnB,cAAc,EACd,aAAa,EAOb,MAAM,aAAa,CAAC;AAqCrB,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AA6JlE,MAAM,MAAM,eAAe,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,GAAG,KAAK,CAAC;AAE1E,MAAM,MAAM,wBAAwB,GAAG,YAAY,GAAG,SAAS,CAAC;AAyEhE,MAAM,WAAW,gBAAiB,SAAQ,aAAa;IACtD;;;;;;OAMG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;;OAIG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,EAAE,eAAe,CAAC;IACzB;;;;;;;;;;;OAWG;IACH,eAAe,CAAC,EAAE,wBAAwB,CAAC;IAC3C;;;;;OAKG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,wEAAwE;IACxE,gBAAgB,CAAC,EAAE,wBAAwB,CAAC;IAC5C;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,GAAG,KAAK,GAAG,MAAM,GAAG;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IACtE;;;;OAIG;IACH,MAAM,CAAC,EAAE,SAAS,CAAC;CACnB;AAm4BD,eAAO,MAAM,MAAM,EAAE,cAAc,CAAC,oBAAoB,EAAE,gBAAgB,CAqbzE,CAAC;AA0FF,eAAO,MAAM,YAAY,EAAE,cAAc,CAAC,oBAAoB,EAAE,mBAAmB,CA+ClF,CAAC;AA6IF,wBAAgB,mCAAmC,CAClD,KAAK,EAAE,KAAK,CAAC,oBAAoB,CAAC,EAClC,OAAO,EAAE,OAAO,EAChB,OAAO,CAAC,EAAE,gBAAgB,GACxB,+BAA+B,CAkBjC"}
1
+ {"version":3,"file":"anthropic-messages.d.ts","sourceRoot":"","sources":["../../src/api/anthropic-messages.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,mBAAmB,CAAC;AAC1C,OAAO,KAAK,EAGX,+BAA+B,EAK/B,MAAM,yCAAyC,CAAC;AAGjD,OAAO,KAAK,EACX,wBAAwB,EAKxB,OAAO,EAGP,KAAK,EAGL,mBAAmB,EAEnB,cAAc,EACd,aAAa,EAOb,MAAM,aAAa,CAAC;AAqCrB,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AA6JlE,MAAM,MAAM,eAAe,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,GAAG,KAAK,CAAC;AAE1E,MAAM,MAAM,wBAAwB,GAAG,YAAY,GAAG,SAAS,CAAC;AAuFhE,MAAM,WAAW,gBAAiB,SAAQ,aAAa;IACtD;;;;;;OAMG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;;OAIG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,EAAE,eAAe,CAAC;IACzB;;;;;;;;;;;OAWG;IACH,eAAe,CAAC,EAAE,wBAAwB,CAAC;IAC3C;;;;;OAKG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,wEAAwE;IACxE,gBAAgB,CAAC,EAAE,wBAAwB,CAAC;IAC5C;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,GAAG,KAAK,GAAG,MAAM,GAAG;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IACtE;;;;OAIG;IACH,MAAM,CAAC,EAAE,SAAS,CAAC;CACnB;AAo4BD,eAAO,MAAM,MAAM,EAAE,cAAc,CAAC,oBAAoB,EAAE,gBAAgB,CAqbzE,CAAC;AA0FF,eAAO,MAAM,YAAY,EAAE,cAAc,CAAC,oBAAoB,EAAE,mBAAmB,CA+ClF,CAAC;AA6IF,wBAAgB,mCAAmC,CAClD,KAAK,EAAE,KAAK,CAAC,oBAAoB,CAAC,EAClC,OAAO,EAAE,OAAO,EAChB,OAAO,CAAC,EAAE,gBAAgB,GACxB,+BAA+B,CAkBjC"}
@@ -1,5 +1,6 @@
1
1
  import Anthropic from "@anthropic-ai/sdk";
2
2
  import { calculateCost } from "../models.js";
3
+ import { registerSessionResourceCleanup } from "../session-resources.js";
3
4
  import { isVideoMimeType } from "../types.js";
4
5
  import { combineAbortSignals } from "../utils/abort-signals.js";
5
6
  import { splitDeferredTools } from "../utils/deferred-tools.js";
@@ -181,6 +182,20 @@ const SERVER_SIDE_FALLBACK_BETA = "server-side-fallback-2026-07-01";
181
182
  // A provider can reject its own empty signatures. Learn that capability for one
182
183
  // conversation without changing the shared model definition used by other sessions.
183
184
  const unsignedThinkingTextReplayFallbacks = new Set();
185
+ registerSessionResourceCleanup((sessionId) => {
186
+ // One small entry per (session, base URL, model) that ever hit the fallback;
187
+ // drop the session's entries at teardown so long-lived hosts do not collect
188
+ // them for every session that ever ran.
189
+ if (sessionId === undefined) {
190
+ unsignedThinkingTextReplayFallbacks.clear();
191
+ return;
192
+ }
193
+ const prefix = `${sessionId}\u0000`;
194
+ for (const key of unsignedThinkingTextReplayFallbacks) {
195
+ if (key.startsWith(prefix))
196
+ unsignedThinkingTextReplayFallbacks.delete(key);
197
+ }
198
+ });
184
199
  function unsignedThinkingFallbackKey(model, sessionId) {
185
200
  return sessionId === undefined ? undefined : `${sessionId}\u0000${model.baseUrl}\u0000${model.id}`;
186
201
  }
@@ -237,12 +252,13 @@ const REPLAYABLE_ANTHROPIC_PROVIDER_NATIVE_TYPES = new Set([
237
252
  "text_editor_code_execution_tool_result",
238
253
  "tool_search_tool_result",
239
254
  "container_upload",
240
- // Server-side fallback beta (server-side-fallback-2026-06-01) emits a
241
- // `fallback` marker mid-response. The marker itself is replayed as a kept
242
- // audit block. Blocks emitted *before* the final marker are the declined
243
- // attempt and are pruned in convertMessages (see lastAnthropicFallbackBoundary
244
- // and collectDiscardedFallbackToolCallIds); the marker onward replays verbatim.
245
- "fallback",
255
+ // The server-side fallback marker (`fallback`, server-side-fallback-2026-06-01
256
+ // beta) is deliberately absent: the Messages API rejects it as an *input* tag
257
+ // ("Input tag 'fallback' found using 'type' does not match any of the expected
258
+ // tags"), so replaying it 400s every subsequent same-model request. The stored
259
+ // marker is audit metadata and still drives declined-attempt pruning in
260
+ // convertMessages (see lastAnthropicFallbackBoundary and
261
+ // collectDiscardedFallbackToolCallIds); blocks after it replay verbatim.
246
262
  ]);
247
263
  function isReplayableAnthropicProviderNativeBlock(raw) {
248
264
  return isRecord(raw) && typeof raw.type === "string" && REPLAYABLE_ANTHROPIC_PROVIDER_NATIVE_TYPES.has(raw.type);
@@ -1796,7 +1812,8 @@ function convertMessages(transformedMessages, model, isOAuthToken, cacheControl,
1796
1812
  const blocks = [];
1797
1813
  const isSameModel = isSameAnthropicModel(msg, model);
1798
1814
  // Blocks before the final fallback marker are the declined attempt; the
1799
- // marker onward is the serving model's output and replays verbatim.
1815
+ // blocks after it are the serving model's output and replay verbatim. The
1816
+ // marker itself never replays: the API rejects `fallback` as an input tag.
1800
1817
  const fallbackBoundary = isSameModel ? lastAnthropicFallbackBoundary(msg.content) : -1;
1801
1818
  const preBoundaryPairedServerToolUseIds = fallbackBoundary >= 0
1802
1819
  ? pairedServerToolUseIdsBeforeBoundary(msg.content, fallbackBoundary)