@code-yeongyu/senpi 2026.5.20-4 → 2026.5.21

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 (794) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cli.d.ts.map +1 -1
  3. package/dist/cli.js +4 -10
  4. package/dist/cli.js.map +1 -1
  5. package/dist/config.d.ts.map +1 -1
  6. package/dist/config.js +10 -4
  7. package/dist/config.js.map +1 -1
  8. package/dist/core/agent-session-runtime.d.ts.map +1 -1
  9. package/dist/core/agent-session-runtime.js +2 -3
  10. package/dist/core/agent-session-runtime.js.map +1 -1
  11. package/dist/core/http-dispatcher.d.ts +21 -0
  12. package/dist/core/http-dispatcher.d.ts.map +1 -0
  13. package/dist/core/http-dispatcher.js +48 -0
  14. package/dist/core/http-dispatcher.js.map +1 -0
  15. package/dist/core/package-manager.d.ts.map +1 -1
  16. package/dist/core/package-manager.js +2 -1
  17. package/dist/core/package-manager.js.map +1 -1
  18. package/dist/core/settings-manager.d.ts +3 -0
  19. package/dist/core/settings-manager.d.ts.map +1 -1
  20. package/dist/core/settings-manager.js +20 -0
  21. package/dist/core/settings-manager.js.map +1 -1
  22. package/dist/main.d.ts.map +1 -1
  23. package/dist/main.js +2 -0
  24. package/dist/main.js.map +1 -1
  25. package/dist/modes/interactive/components/settings-selector.d.ts +2 -0
  26. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  27. package/dist/modes/interactive/components/settings-selector.js +15 -0
  28. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  29. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  30. package/dist/modes/interactive/interactive-mode.js +10 -1
  31. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  32. package/dist/senpi +4 -10
  33. package/dist/utils/paths.d.ts +1 -0
  34. package/dist/utils/paths.d.ts.map +1 -1
  35. package/dist/utils/paths.js +16 -0
  36. package/dist/utils/paths.js.map +1 -1
  37. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  38. package/examples/extensions/custom-provider-anthropic/package.json +2 -2
  39. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  40. package/examples/extensions/sandbox/package-lock.json +2 -2
  41. package/examples/extensions/sandbox/package.json +2 -2
  42. package/examples/extensions/with-deps/package-lock.json +2 -2
  43. package/examples/extensions/with-deps/package.json +3 -3
  44. package/node_modules/@earendil-works/pi-agent-core/README.md +488 -0
  45. package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.d.ts +24 -0
  46. package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.d.ts.map +1 -0
  47. package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.js +610 -0
  48. package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.js.map +1 -0
  49. package/node_modules/@earendil-works/pi-agent-core/dist/agent.d.ts +120 -0
  50. package/node_modules/@earendil-works/pi-agent-core/dist/agent.d.ts.map +1 -0
  51. package/node_modules/@earendil-works/pi-agent-core/dist/agent.js +405 -0
  52. package/node_modules/@earendil-works/pi-agent-core/dist/agent.js.map +1 -0
  53. package/node_modules/@earendil-works/pi-agent-core/dist/harness/agent-harness.d.ts +92 -0
  54. package/node_modules/@earendil-works/pi-agent-core/dist/harness/agent-harness.d.ts.map +1 -0
  55. package/node_modules/@earendil-works/pi-agent-core/dist/harness/agent-harness.js +904 -0
  56. package/node_modules/@earendil-works/pi-agent-core/dist/harness/agent-harness.js.map +1 -0
  57. package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/branch-summarization.d.ts +53 -0
  58. package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/branch-summarization.d.ts.map +1 -0
  59. package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/branch-summarization.js +174 -0
  60. package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/branch-summarization.js.map +1 -0
  61. package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/compaction.d.ts +95 -0
  62. package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/compaction.d.ts.map +1 -0
  63. package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/compaction.js +533 -0
  64. package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/compaction.js.map +1 -0
  65. package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/utils.d.ts +25 -0
  66. package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/utils.d.ts.map +1 -0
  67. package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/utils.js +131 -0
  68. package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/utils.js.map +1 -0
  69. package/node_modules/@earendil-works/pi-agent-core/dist/harness/env/nodejs.d.ts +51 -0
  70. package/node_modules/@earendil-works/pi-agent-core/dist/harness/env/nodejs.d.ts.map +1 -0
  71. package/node_modules/@earendil-works/pi-agent-core/dist/harness/env/nodejs.js +486 -0
  72. package/node_modules/@earendil-works/pi-agent-core/dist/harness/env/nodejs.js.map +1 -0
  73. package/node_modules/@earendil-works/pi-agent-core/dist/harness/messages.d.ts +52 -0
  74. package/node_modules/@earendil-works/pi-agent-core/dist/harness/messages.d.ts.map +1 -0
  75. package/node_modules/@earendil-works/pi-agent-core/dist/harness/messages.js +102 -0
  76. package/node_modules/@earendil-works/pi-agent-core/dist/harness/messages.js.map +1 -0
  77. package/node_modules/@earendil-works/pi-agent-core/dist/harness/prompt-templates.d.ts +48 -0
  78. package/node_modules/@earendil-works/pi-agent-core/dist/harness/prompt-templates.d.ts.map +1 -0
  79. package/node_modules/@earendil-works/pi-agent-core/dist/harness/prompt-templates.js +230 -0
  80. package/node_modules/@earendil-works/pi-agent-core/dist/harness/prompt-templates.js.map +1 -0
  81. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-repo.d.ts +26 -0
  82. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-repo.d.ts.map +1 -0
  83. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-repo.js +101 -0
  84. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-repo.js.map +1 -0
  85. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-storage.d.ts +33 -0
  86. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-storage.d.ts.map +1 -0
  87. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-storage.js +231 -0
  88. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-storage.js.map +1 -0
  89. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-repo.d.ts +18 -0
  90. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-repo.d.ts.map +1 -0
  91. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-repo.js +42 -0
  92. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-repo.js.map +1 -0
  93. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-storage.d.ts +25 -0
  94. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-storage.d.ts.map +1 -0
  95. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-storage.js +114 -0
  96. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-storage.js.map +1 -0
  97. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/repo-utils.d.ts +11 -0
  98. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/repo-utils.d.ts.map +1 -0
  99. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/repo-utils.js +39 -0
  100. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/repo-utils.js.map +1 -0
  101. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/session.d.ts +32 -0
  102. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/session.d.ts.map +1 -0
  103. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/session.js +197 -0
  104. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/session.js.map +1 -0
  105. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/uuid.d.ts +2 -0
  106. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/uuid.d.ts.map +1 -0
  107. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/uuid.js +50 -0
  108. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/uuid.js.map +1 -0
  109. package/node_modules/@earendil-works/pi-agent-core/dist/harness/skills.d.ts +44 -0
  110. package/node_modules/@earendil-works/pi-agent-core/dist/harness/skills.d.ts.map +1 -0
  111. package/node_modules/@earendil-works/pi-agent-core/dist/harness/skills.js +311 -0
  112. package/node_modules/@earendil-works/pi-agent-core/dist/harness/skills.js.map +1 -0
  113. package/node_modules/@earendil-works/pi-agent-core/dist/harness/system-prompt.d.ts +3 -0
  114. package/node_modules/@earendil-works/pi-agent-core/dist/harness/system-prompt.d.ts.map +1 -0
  115. package/node_modules/@earendil-works/pi-agent-core/dist/harness/system-prompt.js +30 -0
  116. package/node_modules/@earendil-works/pi-agent-core/dist/harness/system-prompt.js.map +1 -0
  117. package/node_modules/@earendil-works/pi-agent-core/dist/harness/types.d.ts +604 -0
  118. package/node_modules/@earendil-works/pi-agent-core/dist/harness/types.d.ts.map +1 -0
  119. package/node_modules/@earendil-works/pi-agent-core/dist/harness/types.js +103 -0
  120. package/node_modules/@earendil-works/pi-agent-core/dist/harness/types.js.map +1 -0
  121. package/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/shell-output.d.ts +14 -0
  122. package/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/shell-output.d.ts.map +1 -0
  123. package/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/shell-output.js +126 -0
  124. package/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/shell-output.js.map +1 -0
  125. package/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/truncate.d.ts +70 -0
  126. package/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/truncate.d.ts.map +1 -0
  127. package/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/truncate.js +290 -0
  128. package/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/truncate.js.map +1 -0
  129. package/node_modules/@earendil-works/pi-agent-core/dist/index.d.ts +20 -0
  130. package/node_modules/@earendil-works/pi-agent-core/dist/index.d.ts.map +1 -0
  131. package/node_modules/@earendil-works/pi-agent-core/dist/index.js +25 -0
  132. package/node_modules/@earendil-works/pi-agent-core/dist/index.js.map +1 -0
  133. package/node_modules/@earendil-works/pi-agent-core/dist/node.d.ts +3 -0
  134. package/node_modules/@earendil-works/pi-agent-core/dist/node.d.ts.map +1 -0
  135. package/node_modules/@earendil-works/pi-agent-core/dist/node.js +3 -0
  136. package/node_modules/@earendil-works/pi-agent-core/dist/node.js.map +1 -0
  137. package/node_modules/@earendil-works/pi-agent-core/dist/proxy.d.ts +69 -0
  138. package/node_modules/@earendil-works/pi-agent-core/dist/proxy.d.ts.map +1 -0
  139. package/node_modules/@earendil-works/pi-agent-core/dist/proxy.js +278 -0
  140. package/node_modules/@earendil-works/pi-agent-core/dist/proxy.js.map +1 -0
  141. package/node_modules/@earendil-works/pi-agent-core/dist/types.d.ts +394 -0
  142. package/node_modules/@earendil-works/pi-agent-core/dist/types.d.ts.map +1 -0
  143. package/node_modules/@earendil-works/pi-agent-core/dist/types.js +2 -0
  144. package/node_modules/@earendil-works/pi-agent-core/dist/types.js.map +1 -0
  145. package/node_modules/@earendil-works/pi-agent-core/package.json +61 -0
  146. package/node_modules/@earendil-works/pi-ai/README.md +1386 -0
  147. package/node_modules/@earendil-works/pi-ai/dist/api-registry.d.ts +20 -0
  148. package/node_modules/@earendil-works/pi-ai/dist/api-registry.d.ts.map +1 -0
  149. package/node_modules/@earendil-works/pi-ai/dist/api-registry.js +44 -0
  150. package/node_modules/@earendil-works/pi-ai/dist/api-registry.js.map +1 -0
  151. package/node_modules/@earendil-works/pi-ai/dist/bedrock-provider.d.ts +5 -0
  152. package/node_modules/@earendil-works/pi-ai/dist/bedrock-provider.d.ts.map +1 -0
  153. package/node_modules/@earendil-works/pi-ai/dist/bedrock-provider.js +6 -0
  154. package/node_modules/@earendil-works/pi-ai/dist/bedrock-provider.js.map +1 -0
  155. package/node_modules/@earendil-works/pi-ai/dist/cli.d.ts +3 -0
  156. package/node_modules/@earendil-works/pi-ai/dist/cli.d.ts.map +1 -0
  157. package/node_modules/@earendil-works/pi-ai/dist/cli.js +116 -0
  158. package/node_modules/@earendil-works/pi-ai/dist/cli.js.map +1 -0
  159. package/node_modules/@earendil-works/pi-ai/dist/env-api-keys.d.ts +18 -0
  160. package/node_modules/@earendil-works/pi-ai/dist/env-api-keys.d.ts.map +1 -0
  161. package/node_modules/@earendil-works/pi-ai/dist/env-api-keys.js +178 -0
  162. package/node_modules/@earendil-works/pi-ai/dist/env-api-keys.js.map +1 -0
  163. package/node_modules/@earendil-works/pi-ai/dist/image-models.d.ts +10 -0
  164. package/node_modules/@earendil-works/pi-ai/dist/image-models.d.ts.map +1 -0
  165. package/node_modules/@earendil-works/pi-ai/dist/image-models.generated.d.ts +440 -0
  166. package/node_modules/@earendil-works/pi-ai/dist/image-models.generated.d.ts.map +1 -0
  167. package/node_modules/@earendil-works/pi-ai/dist/image-models.generated.js +442 -0
  168. package/node_modules/@earendil-works/pi-ai/dist/image-models.generated.js.map +1 -0
  169. package/node_modules/@earendil-works/pi-ai/dist/image-models.js +23 -0
  170. package/node_modules/@earendil-works/pi-ai/dist/image-models.js.map +1 -0
  171. package/node_modules/@earendil-works/pi-ai/dist/images-api-registry.d.ts +14 -0
  172. package/node_modules/@earendil-works/pi-ai/dist/images-api-registry.d.ts.map +1 -0
  173. package/node_modules/@earendil-works/pi-ai/dist/images-api-registry.js +22 -0
  174. package/node_modules/@earendil-works/pi-ai/dist/images-api-registry.js.map +1 -0
  175. package/node_modules/@earendil-works/pi-ai/dist/images.d.ts +4 -0
  176. package/node_modules/@earendil-works/pi-ai/dist/images.d.ts.map +1 -0
  177. package/node_modules/@earendil-works/pi-ai/dist/images.js +14 -0
  178. package/node_modules/@earendil-works/pi-ai/dist/images.js.map +1 -0
  179. package/node_modules/@earendil-works/pi-ai/dist/index.d.ts +33 -0
  180. package/node_modules/@earendil-works/pi-ai/dist/index.d.ts.map +1 -0
  181. package/node_modules/@earendil-works/pi-ai/dist/index.js +21 -0
  182. package/node_modules/@earendil-works/pi-ai/dist/index.js.map +1 -0
  183. package/node_modules/@earendil-works/pi-ai/dist/models.d.ts +37 -0
  184. package/node_modules/@earendil-works/pi-ai/dist/models.d.ts.map +1 -0
  185. package/node_modules/@earendil-works/pi-ai/dist/models.generated.d.ts +17658 -0
  186. package/node_modules/@earendil-works/pi-ai/dist/models.generated.d.ts.map +1 -0
  187. package/node_modules/@earendil-works/pi-ai/dist/models.generated.js +16510 -0
  188. package/node_modules/@earendil-works/pi-ai/dist/models.generated.js.map +1 -0
  189. package/node_modules/@earendil-works/pi-ai/dist/models.js +114 -0
  190. package/node_modules/@earendil-works/pi-ai/dist/models.js.map +1 -0
  191. package/node_modules/@earendil-works/pi-ai/dist/oauth.d.ts +2 -0
  192. package/node_modules/@earendil-works/pi-ai/dist/oauth.d.ts.map +1 -0
  193. package/node_modules/@earendil-works/pi-ai/dist/oauth.js +2 -0
  194. package/node_modules/@earendil-works/pi-ai/dist/oauth.js.map +1 -0
  195. package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.d.ts +38 -0
  196. package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.d.ts.map +1 -0
  197. package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.js +787 -0
  198. package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.js.map +1 -0
  199. package/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.d.ts +52 -0
  200. package/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.d.ts.map +1 -0
  201. package/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.js +1127 -0
  202. package/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.js.map +1 -0
  203. package/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.d.ts +15 -0
  204. package/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.d.ts.map +1 -0
  205. package/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.js +229 -0
  206. package/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.js.map +1 -0
  207. package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare.d.ts +13 -0
  208. package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare.d.ts.map +1 -0
  209. package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare.js +26 -0
  210. package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare.js.map +1 -0
  211. package/node_modules/@earendil-works/pi-ai/dist/providers/faux.d.ts +66 -0
  212. package/node_modules/@earendil-works/pi-ai/dist/providers/faux.d.ts.map +1 -0
  213. package/node_modules/@earendil-works/pi-ai/dist/providers/faux.js +401 -0
  214. package/node_modules/@earendil-works/pi-ai/dist/providers/faux.js.map +1 -0
  215. package/node_modules/@earendil-works/pi-ai/dist/providers/github-copilot-headers.d.ts +8 -0
  216. package/node_modules/@earendil-works/pi-ai/dist/providers/github-copilot-headers.d.ts.map +1 -0
  217. package/node_modules/@earendil-works/pi-ai/dist/providers/github-copilot-headers.js +29 -0
  218. package/node_modules/@earendil-works/pi-ai/dist/providers/github-copilot-headers.js.map +1 -0
  219. package/node_modules/@earendil-works/pi-ai/dist/providers/google-shared.d.ts +73 -0
  220. package/node_modules/@earendil-works/pi-ai/dist/providers/google-shared.d.ts.map +1 -0
  221. package/node_modules/@earendil-works/pi-ai/dist/providers/google-shared.js +359 -0
  222. package/node_modules/@earendil-works/pi-ai/dist/providers/google-shared.js.map +1 -0
  223. package/node_modules/@earendil-works/pi-ai/dist/providers/google-vertex.d.ts +15 -0
  224. package/node_modules/@earendil-works/pi-ai/dist/providers/google-vertex.d.ts.map +1 -0
  225. package/node_modules/@earendil-works/pi-ai/dist/providers/google-vertex.js +465 -0
  226. package/node_modules/@earendil-works/pi-ai/dist/providers/google-vertex.js.map +1 -0
  227. package/node_modules/@earendil-works/pi-ai/dist/providers/google.d.ts +13 -0
  228. package/node_modules/@earendil-works/pi-ai/dist/providers/google.d.ts.map +1 -0
  229. package/node_modules/@earendil-works/pi-ai/dist/providers/google.js +431 -0
  230. package/node_modules/@earendil-works/pi-ai/dist/providers/google.js.map +1 -0
  231. package/node_modules/@earendil-works/pi-ai/dist/providers/images/openrouter.d.ts +3 -0
  232. package/node_modules/@earendil-works/pi-ai/dist/providers/images/openrouter.d.ts.map +1 -0
  233. package/node_modules/@earendil-works/pi-ai/dist/providers/images/openrouter.js +129 -0
  234. package/node_modules/@earendil-works/pi-ai/dist/providers/images/openrouter.js.map +1 -0
  235. package/node_modules/@earendil-works/pi-ai/dist/providers/images/register-builtins.d.ts +4 -0
  236. package/node_modules/@earendil-works/pi-ai/dist/providers/images/register-builtins.d.ts.map +1 -0
  237. package/node_modules/@earendil-works/pi-ai/dist/providers/images/register-builtins.js +34 -0
  238. package/node_modules/@earendil-works/pi-ai/dist/providers/images/register-builtins.js.map +1 -0
  239. package/node_modules/@earendil-works/pi-ai/dist/providers/mistral.d.ts +25 -0
  240. package/node_modules/@earendil-works/pi-ai/dist/providers/mistral.d.ts.map +1 -0
  241. package/node_modules/@earendil-works/pi-ai/dist/providers/mistral.js +542 -0
  242. package/node_modules/@earendil-works/pi-ai/dist/providers/mistral.js.map +1 -0
  243. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-codex-responses.d.ts +30 -0
  244. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-codex-responses.d.ts.map +1 -0
  245. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-codex-responses.js +1112 -0
  246. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-codex-responses.js.map +1 -0
  247. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-completions.d.ts +22 -0
  248. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-completions.d.ts.map +1 -0
  249. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-completions.js +977 -0
  250. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-completions.js.map +1 -0
  251. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-prompt-cache.d.ts +3 -0
  252. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-prompt-cache.d.ts.map +1 -0
  253. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-prompt-cache.js +10 -0
  254. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-prompt-cache.js.map +1 -0
  255. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-responses-shared.d.ts +19 -0
  256. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-responses-shared.d.ts.map +1 -0
  257. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-responses-shared.js +579 -0
  258. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-responses-shared.js.map +1 -0
  259. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-responses.d.ts +13 -0
  260. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-responses.d.ts.map +1 -0
  261. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-responses.js +651 -0
  262. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-responses.js.map +1 -0
  263. package/node_modules/@earendil-works/pi-ai/dist/providers/register-builtins.d.ts +35 -0
  264. package/node_modules/@earendil-works/pi-ai/dist/providers/register-builtins.d.ts.map +1 -0
  265. package/node_modules/@earendil-works/pi-ai/dist/providers/register-builtins.js +254 -0
  266. package/node_modules/@earendil-works/pi-ai/dist/providers/register-builtins.js.map +1 -0
  267. package/node_modules/@earendil-works/pi-ai/dist/providers/simple-options.d.ts +38 -0
  268. package/node_modules/@earendil-works/pi-ai/dist/providers/simple-options.d.ts.map +1 -0
  269. package/node_modules/@earendil-works/pi-ai/dist/providers/simple-options.js +174 -0
  270. package/node_modules/@earendil-works/pi-ai/dist/providers/simple-options.js.map +1 -0
  271. package/node_modules/@earendil-works/pi-ai/dist/providers/transform-messages.d.ts +16 -0
  272. package/node_modules/@earendil-works/pi-ai/dist/providers/transform-messages.d.ts.map +1 -0
  273. package/node_modules/@earendil-works/pi-ai/dist/providers/transform-messages.js +186 -0
  274. package/node_modules/@earendil-works/pi-ai/dist/providers/transform-messages.js.map +1 -0
  275. package/node_modules/@earendil-works/pi-ai/dist/session-resources.d.ts +4 -0
  276. package/node_modules/@earendil-works/pi-ai/dist/session-resources.d.ts.map +1 -0
  277. package/node_modules/@earendil-works/pi-ai/dist/session-resources.js +22 -0
  278. package/node_modules/@earendil-works/pi-ai/dist/session-resources.js.map +1 -0
  279. package/node_modules/@earendil-works/pi-ai/dist/stream.d.ts +8 -0
  280. package/node_modules/@earendil-works/pi-ai/dist/stream.d.ts.map +1 -0
  281. package/node_modules/@earendil-works/pi-ai/dist/stream.js +42 -0
  282. package/node_modules/@earendil-works/pi-ai/dist/stream.js.map +1 -0
  283. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/context-transformer.d.ts +22 -0
  284. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/context-transformer.d.ts.map +1 -0
  285. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/context-transformer.js +161 -0
  286. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/context-transformer.js.map +1 -0
  287. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/index.d.ts +13 -0
  288. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/index.d.ts.map +1 -0
  289. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/index.js +23 -0
  290. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/index.js.map +1 -0
  291. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/gemma4.d.ts +21 -0
  292. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/gemma4.d.ts.map +1 -0
  293. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/gemma4.js +559 -0
  294. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/gemma4.js.map +1 -0
  295. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/hermes.d.ts +21 -0
  296. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/hermes.d.ts.map +1 -0
  297. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/hermes.js +69 -0
  298. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/hermes.js.map +1 -0
  299. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/json-mix.d.ts +12 -0
  300. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/json-mix.d.ts.map +1 -0
  301. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/json-mix.js +570 -0
  302. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/json-mix.js.map +1 -0
  303. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/morph-xml.d.ts +15 -0
  304. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/morph-xml.d.ts.map +1 -0
  305. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/morph-xml.js +935 -0
  306. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/morph-xml.js.map +1 -0
  307. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/xml-tool-tag-scanner.d.ts +14 -0
  308. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/xml-tool-tag-scanner.d.ts.map +1 -0
  309. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/xml-tool-tag-scanner.js +54 -0
  310. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/xml-tool-tag-scanner.js.map +1 -0
  311. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/yaml-xml.d.ts +8 -0
  312. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/yaml-xml.d.ts.map +1 -0
  313. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/yaml-xml.js +295 -0
  314. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/yaml-xml.js.map +1 -0
  315. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/stream-wrapper.d.ts +4 -0
  316. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/stream-wrapper.d.ts.map +1 -0
  317. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/stream-wrapper.js +336 -0
  318. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/stream-wrapper.js.map +1 -0
  319. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/types.d.ts +103 -0
  320. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/types.d.ts.map +1 -0
  321. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/types.js +2 -0
  322. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/types.js.map +1 -0
  323. package/node_modules/@earendil-works/pi-ai/dist/types.d.ts +543 -0
  324. package/node_modules/@earendil-works/pi-ai/dist/types.d.ts.map +1 -0
  325. package/node_modules/@earendil-works/pi-ai/dist/types.js +2 -0
  326. package/node_modules/@earendil-works/pi-ai/dist/types.js.map +1 -0
  327. package/node_modules/@earendil-works/pi-ai/dist/utils/diagnostics.d.ts +19 -0
  328. package/node_modules/@earendil-works/pi-ai/dist/utils/diagnostics.d.ts.map +1 -0
  329. package/node_modules/@earendil-works/pi-ai/dist/utils/diagnostics.js +25 -0
  330. package/node_modules/@earendil-works/pi-ai/dist/utils/diagnostics.js.map +1 -0
  331. package/node_modules/@earendil-works/pi-ai/dist/utils/event-stream.d.ts +21 -0
  332. package/node_modules/@earendil-works/pi-ai/dist/utils/event-stream.d.ts.map +1 -0
  333. package/node_modules/@earendil-works/pi-ai/dist/utils/event-stream.js +81 -0
  334. package/node_modules/@earendil-works/pi-ai/dist/utils/event-stream.js.map +1 -0
  335. package/node_modules/@earendil-works/pi-ai/dist/utils/hash.d.ts +3 -0
  336. package/node_modules/@earendil-works/pi-ai/dist/utils/hash.d.ts.map +1 -0
  337. package/node_modules/@earendil-works/pi-ai/dist/utils/hash.js +14 -0
  338. package/node_modules/@earendil-works/pi-ai/dist/utils/hash.js.map +1 -0
  339. package/node_modules/@earendil-works/pi-ai/dist/utils/headers.d.ts +2 -0
  340. package/node_modules/@earendil-works/pi-ai/dist/utils/headers.d.ts.map +1 -0
  341. package/node_modules/@earendil-works/pi-ai/dist/utils/headers.js +8 -0
  342. package/node_modules/@earendil-works/pi-ai/dist/utils/headers.js.map +1 -0
  343. package/node_modules/@earendil-works/pi-ai/dist/utils/json-parse.d.ts +16 -0
  344. package/node_modules/@earendil-works/pi-ai/dist/utils/json-parse.d.ts.map +1 -0
  345. package/node_modules/@earendil-works/pi-ai/dist/utils/json-parse.js +113 -0
  346. package/node_modules/@earendil-works/pi-ai/dist/utils/json-parse.js.map +1 -0
  347. package/node_modules/@earendil-works/pi-ai/dist/utils/node-http-proxy.d.ts +10 -0
  348. package/node_modules/@earendil-works/pi-ai/dist/utils/node-http-proxy.d.ts.map +1 -0
  349. package/node_modules/@earendil-works/pi-ai/dist/utils/node-http-proxy.js +97 -0
  350. package/node_modules/@earendil-works/pi-ai/dist/utils/node-http-proxy.js.map +1 -0
  351. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/anthropic.d.ts +25 -0
  352. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/anthropic.d.ts.map +1 -0
  353. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/anthropic.js +335 -0
  354. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/anthropic.js.map +1 -0
  355. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/github-copilot.d.ts +30 -0
  356. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/github-copilot.d.ts.map +1 -0
  357. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/github-copilot.js +292 -0
  358. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/github-copilot.js.map +1 -0
  359. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/index.d.ts +57 -0
  360. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/index.d.ts.map +1 -0
  361. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/index.js +121 -0
  362. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/index.js.map +1 -0
  363. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/oauth-page.d.ts +3 -0
  364. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/oauth-page.d.ts.map +1 -0
  365. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/oauth-page.js +105 -0
  366. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/oauth-page.js.map +1 -0
  367. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/openai-codex.d.ts +34 -0
  368. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/openai-codex.d.ts.map +1 -0
  369. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/openai-codex.js +385 -0
  370. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/openai-codex.js.map +1 -0
  371. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/pkce.d.ts +13 -0
  372. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/pkce.d.ts.map +1 -0
  373. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/pkce.js +31 -0
  374. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/pkce.js.map +1 -0
  375. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/types.d.ts +57 -0
  376. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/types.d.ts.map +1 -0
  377. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/types.js +2 -0
  378. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/types.js.map +1 -0
  379. package/node_modules/@earendil-works/pi-ai/dist/utils/overflow.d.ts +56 -0
  380. package/node_modules/@earendil-works/pi-ai/dist/utils/overflow.d.ts.map +1 -0
  381. package/node_modules/@earendil-works/pi-ai/dist/utils/overflow.js +151 -0
  382. package/node_modules/@earendil-works/pi-ai/dist/utils/overflow.js.map +1 -0
  383. package/node_modules/@earendil-works/pi-ai/dist/utils/sanitize-unicode.d.ts +22 -0
  384. package/node_modules/@earendil-works/pi-ai/dist/utils/sanitize-unicode.d.ts.map +1 -0
  385. package/node_modules/@earendil-works/pi-ai/dist/utils/sanitize-unicode.js +26 -0
  386. package/node_modules/@earendil-works/pi-ai/dist/utils/sanitize-unicode.js.map +1 -0
  387. package/node_modules/@earendil-works/pi-ai/dist/utils/tool-pair-repair.d.ts +5 -0
  388. package/node_modules/@earendil-works/pi-ai/dist/utils/tool-pair-repair.d.ts.map +1 -0
  389. package/node_modules/@earendil-works/pi-ai/dist/utils/tool-pair-repair.js +49 -0
  390. package/node_modules/@earendil-works/pi-ai/dist/utils/tool-pair-repair.js.map +1 -0
  391. package/node_modules/@earendil-works/pi-ai/dist/utils/typebox-helpers.d.ts +17 -0
  392. package/node_modules/@earendil-works/pi-ai/dist/utils/typebox-helpers.d.ts.map +1 -0
  393. package/node_modules/@earendil-works/pi-ai/dist/utils/typebox-helpers.js +21 -0
  394. package/node_modules/@earendil-works/pi-ai/dist/utils/typebox-helpers.js.map +1 -0
  395. package/node_modules/@earendil-works/pi-ai/dist/utils/validation.d.ts +18 -0
  396. package/node_modules/@earendil-works/pi-ai/dist/utils/validation.d.ts.map +1 -0
  397. package/node_modules/@earendil-works/pi-ai/dist/utils/validation.js +281 -0
  398. package/node_modules/@earendil-works/pi-ai/dist/utils/validation.js.map +1 -0
  399. package/node_modules/@earendil-works/pi-ai/package.json +113 -0
  400. package/node_modules/@earendil-works/pi-tui/README.md +779 -0
  401. package/node_modules/@earendil-works/pi-tui/dist/autocomplete.d.ts +54 -0
  402. package/node_modules/@earendil-works/pi-tui/dist/autocomplete.d.ts.map +1 -0
  403. package/node_modules/@earendil-works/pi-tui/dist/autocomplete.js +632 -0
  404. package/node_modules/@earendil-works/pi-tui/dist/autocomplete.js.map +1 -0
  405. package/node_modules/@earendil-works/pi-tui/dist/components/box.d.ts +22 -0
  406. package/node_modules/@earendil-works/pi-tui/dist/components/box.d.ts.map +1 -0
  407. package/node_modules/@earendil-works/pi-tui/dist/components/box.js +104 -0
  408. package/node_modules/@earendil-works/pi-tui/dist/components/box.js.map +1 -0
  409. package/node_modules/@earendil-works/pi-tui/dist/components/cancellable-loader.d.ts +22 -0
  410. package/node_modules/@earendil-works/pi-tui/dist/components/cancellable-loader.d.ts.map +1 -0
  411. package/node_modules/@earendil-works/pi-tui/dist/components/cancellable-loader.js +35 -0
  412. package/node_modules/@earendil-works/pi-tui/dist/components/cancellable-loader.js.map +1 -0
  413. package/node_modules/@earendil-works/pi-tui/dist/components/editor.d.ts +249 -0
  414. package/node_modules/@earendil-works/pi-tui/dist/components/editor.d.ts.map +1 -0
  415. package/node_modules/@earendil-works/pi-tui/dist/components/editor.js +1916 -0
  416. package/node_modules/@earendil-works/pi-tui/dist/components/editor.js.map +1 -0
  417. package/node_modules/@earendil-works/pi-tui/dist/components/image.d.ts +28 -0
  418. package/node_modules/@earendil-works/pi-tui/dist/components/image.d.ts.map +1 -0
  419. package/node_modules/@earendil-works/pi-tui/dist/components/image.js +89 -0
  420. package/node_modules/@earendil-works/pi-tui/dist/components/image.js.map +1 -0
  421. package/node_modules/@earendil-works/pi-tui/dist/components/input.d.ts +37 -0
  422. package/node_modules/@earendil-works/pi-tui/dist/components/input.d.ts.map +1 -0
  423. package/node_modules/@earendil-works/pi-tui/dist/components/input.js +426 -0
  424. package/node_modules/@earendil-works/pi-tui/dist/components/input.js.map +1 -0
  425. package/node_modules/@earendil-works/pi-tui/dist/components/loader.d.ts +40 -0
  426. package/node_modules/@earendil-works/pi-tui/dist/components/loader.d.ts.map +1 -0
  427. package/node_modules/@earendil-works/pi-tui/dist/components/loader.js +95 -0
  428. package/node_modules/@earendil-works/pi-tui/dist/components/loader.js.map +1 -0
  429. package/node_modules/@earendil-works/pi-tui/dist/components/markdown.d.ts +90 -0
  430. package/node_modules/@earendil-works/pi-tui/dist/components/markdown.d.ts.map +1 -0
  431. package/node_modules/@earendil-works/pi-tui/dist/components/markdown.js +634 -0
  432. package/node_modules/@earendil-works/pi-tui/dist/components/markdown.js.map +1 -0
  433. package/node_modules/@earendil-works/pi-tui/dist/components/select-list.d.ts +50 -0
  434. package/node_modules/@earendil-works/pi-tui/dist/components/select-list.d.ts.map +1 -0
  435. package/node_modules/@earendil-works/pi-tui/dist/components/select-list.js +159 -0
  436. package/node_modules/@earendil-works/pi-tui/dist/components/select-list.js.map +1 -0
  437. package/node_modules/@earendil-works/pi-tui/dist/components/settings-list.d.ts +50 -0
  438. package/node_modules/@earendil-works/pi-tui/dist/components/settings-list.d.ts.map +1 -0
  439. package/node_modules/@earendil-works/pi-tui/dist/components/settings-list.js +185 -0
  440. package/node_modules/@earendil-works/pi-tui/dist/components/settings-list.js.map +1 -0
  441. package/node_modules/@earendil-works/pi-tui/dist/components/spacer.d.ts +12 -0
  442. package/node_modules/@earendil-works/pi-tui/dist/components/spacer.d.ts.map +1 -0
  443. package/node_modules/@earendil-works/pi-tui/dist/components/spacer.js +23 -0
  444. package/node_modules/@earendil-works/pi-tui/dist/components/spacer.js.map +1 -0
  445. package/node_modules/@earendil-works/pi-tui/dist/components/text.d.ts +19 -0
  446. package/node_modules/@earendil-works/pi-tui/dist/components/text.d.ts.map +1 -0
  447. package/node_modules/@earendil-works/pi-tui/dist/components/text.js +89 -0
  448. package/node_modules/@earendil-works/pi-tui/dist/components/text.js.map +1 -0
  449. package/node_modules/@earendil-works/pi-tui/dist/components/truncated-text.d.ts +13 -0
  450. package/node_modules/@earendil-works/pi-tui/dist/components/truncated-text.d.ts.map +1 -0
  451. package/node_modules/@earendil-works/pi-tui/dist/components/truncated-text.js +51 -0
  452. package/node_modules/@earendil-works/pi-tui/dist/components/truncated-text.js.map +1 -0
  453. package/node_modules/@earendil-works/pi-tui/dist/editor-component.d.ts +39 -0
  454. package/node_modules/@earendil-works/pi-tui/dist/editor-component.d.ts.map +1 -0
  455. package/node_modules/@earendil-works/pi-tui/dist/editor-component.js +2 -0
  456. package/node_modules/@earendil-works/pi-tui/dist/editor-component.js.map +1 -0
  457. package/node_modules/@earendil-works/pi-tui/dist/fuzzy.d.ts +16 -0
  458. package/node_modules/@earendil-works/pi-tui/dist/fuzzy.d.ts.map +1 -0
  459. package/node_modules/@earendil-works/pi-tui/dist/fuzzy.js +110 -0
  460. package/node_modules/@earendil-works/pi-tui/dist/fuzzy.js.map +1 -0
  461. package/node_modules/@earendil-works/pi-tui/dist/index.d.ts +23 -0
  462. package/node_modules/@earendil-works/pi-tui/dist/index.d.ts.map +1 -0
  463. package/node_modules/@earendil-works/pi-tui/dist/index.js +32 -0
  464. package/node_modules/@earendil-works/pi-tui/dist/index.js.map +1 -0
  465. package/node_modules/@earendil-works/pi-tui/dist/keybindings.d.ts +193 -0
  466. package/node_modules/@earendil-works/pi-tui/dist/keybindings.d.ts.map +1 -0
  467. package/node_modules/@earendil-works/pi-tui/dist/keybindings.js +174 -0
  468. package/node_modules/@earendil-works/pi-tui/dist/keybindings.js.map +1 -0
  469. package/node_modules/@earendil-works/pi-tui/dist/keys.d.ts +184 -0
  470. package/node_modules/@earendil-works/pi-tui/dist/keys.d.ts.map +1 -0
  471. package/node_modules/@earendil-works/pi-tui/dist/keys.js +1173 -0
  472. package/node_modules/@earendil-works/pi-tui/dist/keys.js.map +1 -0
  473. package/node_modules/@earendil-works/pi-tui/dist/kill-ring.d.ts +28 -0
  474. package/node_modules/@earendil-works/pi-tui/dist/kill-ring.d.ts.map +1 -0
  475. package/node_modules/@earendil-works/pi-tui/dist/kill-ring.js +44 -0
  476. package/node_modules/@earendil-works/pi-tui/dist/kill-ring.js.map +1 -0
  477. package/node_modules/@earendil-works/pi-tui/dist/stdin-buffer.d.ts +50 -0
  478. package/node_modules/@earendil-works/pi-tui/dist/stdin-buffer.d.ts.map +1 -0
  479. package/node_modules/@earendil-works/pi-tui/dist/stdin-buffer.js +361 -0
  480. package/node_modules/@earendil-works/pi-tui/dist/stdin-buffer.js.map +1 -0
  481. package/node_modules/@earendil-works/pi-tui/dist/terminal-image.d.ts +90 -0
  482. package/node_modules/@earendil-works/pi-tui/dist/terminal-image.d.ts.map +1 -0
  483. package/node_modules/@earendil-works/pi-tui/dist/terminal-image.js +336 -0
  484. package/node_modules/@earendil-works/pi-tui/dist/terminal-image.js.map +1 -0
  485. package/node_modules/@earendil-works/pi-tui/dist/terminal.d.ts +88 -0
  486. package/node_modules/@earendil-works/pi-tui/dist/terminal.d.ts.map +1 -0
  487. package/node_modules/@earendil-works/pi-tui/dist/terminal.js +329 -0
  488. package/node_modules/@earendil-works/pi-tui/dist/terminal.js.map +1 -0
  489. package/node_modules/@earendil-works/pi-tui/dist/tui.d.ts +231 -0
  490. package/node_modules/@earendil-works/pi-tui/dist/tui.d.ts.map +1 -0
  491. package/node_modules/@earendil-works/pi-tui/dist/tui.js +1230 -0
  492. package/node_modules/@earendil-works/pi-tui/dist/tui.js.map +1 -0
  493. package/node_modules/@earendil-works/pi-tui/dist/undo-stack.d.ts +17 -0
  494. package/node_modules/@earendil-works/pi-tui/dist/undo-stack.d.ts.map +1 -0
  495. package/node_modules/@earendil-works/pi-tui/dist/undo-stack.js +25 -0
  496. package/node_modules/@earendil-works/pi-tui/dist/undo-stack.js.map +1 -0
  497. package/node_modules/@earendil-works/pi-tui/dist/utils.d.ts +79 -0
  498. package/node_modules/@earendil-works/pi-tui/dist/utils.d.ts.map +1 -0
  499. package/node_modules/@earendil-works/pi-tui/dist/utils.js +1031 -0
  500. package/node_modules/@earendil-works/pi-tui/dist/utils.js.map +1 -0
  501. package/node_modules/@earendil-works/pi-tui/package.json +48 -0
  502. package/node_modules/@smithy/node-http-handler/LICENSE +201 -0
  503. package/node_modules/@smithy/node-http-handler/README.md +9 -0
  504. package/node_modules/@smithy/node-http-handler/dist-cjs/index.js +724 -0
  505. package/node_modules/@smithy/node-http-handler/dist-es/constants.js +1 -0
  506. package/node_modules/@smithy/node-http-handler/dist-es/get-transformed-headers.js +9 -0
  507. package/node_modules/@smithy/node-http-handler/dist-es/index.js +3 -0
  508. package/node_modules/@smithy/node-http-handler/dist-es/node-http-handler.js +216 -0
  509. package/node_modules/@smithy/node-http-handler/dist-es/node-http2-connection-manager.js +87 -0
  510. package/node_modules/@smithy/node-http-handler/dist-es/node-http2-connection-pool.js +32 -0
  511. package/node_modules/@smithy/node-http-handler/dist-es/node-http2-handler.js +170 -0
  512. package/node_modules/@smithy/node-http-handler/dist-es/readable.mock.js +21 -0
  513. package/node_modules/@smithy/node-http-handler/dist-es/server.mock.js +88 -0
  514. package/node_modules/@smithy/node-http-handler/dist-es/set-connection-timeout.js +36 -0
  515. package/node_modules/@smithy/node-http-handler/dist-es/set-request-timeout.js +21 -0
  516. package/node_modules/@smithy/node-http-handler/dist-es/set-socket-keep-alive.js +22 -0
  517. package/node_modules/@smithy/node-http-handler/dist-es/set-socket-timeout.js +23 -0
  518. package/node_modules/@smithy/node-http-handler/dist-es/stream-collector/collector.js +8 -0
  519. package/node_modules/@smithy/node-http-handler/dist-es/stream-collector/index.js +41 -0
  520. package/node_modules/@smithy/node-http-handler/dist-es/stream-collector/readable.mock.js +21 -0
  521. package/node_modules/@smithy/node-http-handler/dist-es/timing.js +4 -0
  522. package/node_modules/@smithy/node-http-handler/dist-es/write-request-body.js +56 -0
  523. package/node_modules/@smithy/node-http-handler/dist-types/constants.d.ts +5 -0
  524. package/node_modules/@smithy/node-http-handler/dist-types/get-transformed-headers.d.ts +4 -0
  525. package/node_modules/@smithy/node-http-handler/dist-types/index.d.ts +3 -0
  526. package/node_modules/@smithy/node-http-handler/dist-types/node-http-handler.d.ts +46 -0
  527. package/node_modules/@smithy/node-http-handler/dist-types/node-http2-connection-manager.d.ts +24 -0
  528. package/node_modules/@smithy/node-http-handler/dist-types/node-http2-connection-pool.d.ts +12 -0
  529. package/node_modules/@smithy/node-http-handler/dist-types/node-http2-handler.d.ts +63 -0
  530. package/node_modules/@smithy/node-http-handler/dist-types/readable.mock.d.ts +13 -0
  531. package/node_modules/@smithy/node-http-handler/dist-types/server.mock.d.ts +12 -0
  532. package/node_modules/@smithy/node-http-handler/dist-types/set-connection-timeout.d.ts +2 -0
  533. package/node_modules/@smithy/node-http-handler/dist-types/set-request-timeout.d.ts +6 -0
  534. package/node_modules/@smithy/node-http-handler/dist-types/set-socket-keep-alive.d.ts +6 -0
  535. package/node_modules/@smithy/node-http-handler/dist-types/set-socket-timeout.d.ts +2 -0
  536. package/node_modules/@smithy/node-http-handler/dist-types/stream-collector/collector.d.ts +5 -0
  537. package/node_modules/@smithy/node-http-handler/dist-types/stream-collector/index.d.ts +6 -0
  538. package/node_modules/@smithy/node-http-handler/dist-types/stream-collector/readable.mock.d.ts +13 -0
  539. package/node_modules/@smithy/node-http-handler/dist-types/timing.d.ts +8 -0
  540. package/node_modules/@smithy/node-http-handler/dist-types/ts3.4/constants.d.ts +5 -0
  541. package/node_modules/@smithy/node-http-handler/dist-types/ts3.4/get-transformed-headers.d.ts +4 -0
  542. package/node_modules/@smithy/node-http-handler/dist-types/ts3.4/index.d.ts +3 -0
  543. package/node_modules/@smithy/node-http-handler/dist-types/ts3.4/node-http-handler.d.ts +46 -0
  544. package/node_modules/@smithy/node-http-handler/dist-types/ts3.4/node-http2-connection-manager.d.ts +24 -0
  545. package/node_modules/@smithy/node-http-handler/dist-types/ts3.4/node-http2-connection-pool.d.ts +12 -0
  546. package/node_modules/@smithy/node-http-handler/dist-types/ts3.4/node-http2-handler.d.ts +63 -0
  547. package/node_modules/@smithy/node-http-handler/dist-types/ts3.4/readable.mock.d.ts +13 -0
  548. package/node_modules/@smithy/node-http-handler/dist-types/ts3.4/server.mock.d.ts +12 -0
  549. package/node_modules/@smithy/node-http-handler/dist-types/ts3.4/set-connection-timeout.d.ts +2 -0
  550. package/node_modules/@smithy/node-http-handler/dist-types/ts3.4/set-request-timeout.d.ts +6 -0
  551. package/node_modules/@smithy/node-http-handler/dist-types/ts3.4/set-socket-keep-alive.d.ts +6 -0
  552. package/node_modules/@smithy/node-http-handler/dist-types/ts3.4/set-socket-timeout.d.ts +2 -0
  553. package/node_modules/@smithy/node-http-handler/dist-types/ts3.4/stream-collector/collector.d.ts +5 -0
  554. package/node_modules/@smithy/node-http-handler/dist-types/ts3.4/stream-collector/index.d.ts +6 -0
  555. package/node_modules/@smithy/node-http-handler/dist-types/ts3.4/stream-collector/readable.mock.d.ts +13 -0
  556. package/node_modules/@smithy/node-http-handler/dist-types/ts3.4/timing.d.ts +8 -0
  557. package/node_modules/@smithy/node-http-handler/dist-types/ts3.4/write-request-body.d.ts +11 -0
  558. package/node_modules/@smithy/node-http-handler/dist-types/write-request-body.d.ts +11 -0
  559. package/node_modules/@smithy/node-http-handler/package.json +68 -0
  560. package/node_modules/@smithy/types/LICENSE +201 -0
  561. package/node_modules/@smithy/types/README.md +115 -0
  562. package/node_modules/@smithy/types/dist-cjs/index.js +91 -0
  563. package/node_modules/@smithy/types/dist-es/abort-handler.js +1 -0
  564. package/node_modules/@smithy/types/dist-es/abort.js +1 -0
  565. package/node_modules/@smithy/types/dist-es/auth/HttpApiKeyAuth.js +5 -0
  566. package/node_modules/@smithy/types/dist-es/auth/HttpAuthScheme.js +1 -0
  567. package/node_modules/@smithy/types/dist-es/auth/HttpAuthSchemeProvider.js +1 -0
  568. package/node_modules/@smithy/types/dist-es/auth/HttpSigner.js +1 -0
  569. package/node_modules/@smithy/types/dist-es/auth/IdentityProviderConfig.js +1 -0
  570. package/node_modules/@smithy/types/dist-es/auth/auth.js +5 -0
  571. package/node_modules/@smithy/types/dist-es/auth/index.js +6 -0
  572. package/node_modules/@smithy/types/dist-es/blob/blob-payload-input-types.js +1 -0
  573. package/node_modules/@smithy/types/dist-es/checksum.js +1 -0
  574. package/node_modules/@smithy/types/dist-es/client.js +1 -0
  575. package/node_modules/@smithy/types/dist-es/command.js +1 -0
  576. package/node_modules/@smithy/types/dist-es/connection/config.js +1 -0
  577. package/node_modules/@smithy/types/dist-es/connection/index.js +3 -0
  578. package/node_modules/@smithy/types/dist-es/connection/manager.js +1 -0
  579. package/node_modules/@smithy/types/dist-es/connection/pool.js +1 -0
  580. package/node_modules/@smithy/types/dist-es/crypto.js +1 -0
  581. package/node_modules/@smithy/types/dist-es/downlevel-ts3.4/transform/type-transform.js +1 -0
  582. package/node_modules/@smithy/types/dist-es/encode.js +1 -0
  583. package/node_modules/@smithy/types/dist-es/endpoint.js +5 -0
  584. package/node_modules/@smithy/types/dist-es/endpoints/EndpointRuleObject.js +1 -0
  585. package/node_modules/@smithy/types/dist-es/endpoints/ErrorRuleObject.js +1 -0
  586. package/node_modules/@smithy/types/dist-es/endpoints/RuleSetObject.js +1 -0
  587. package/node_modules/@smithy/types/dist-es/endpoints/TreeRuleObject.js +1 -0
  588. package/node_modules/@smithy/types/dist-es/endpoints/index.js +5 -0
  589. package/node_modules/@smithy/types/dist-es/endpoints/shared.js +1 -0
  590. package/node_modules/@smithy/types/dist-es/eventStream.js +1 -0
  591. package/node_modules/@smithy/types/dist-es/extensions/checksum.js +38 -0
  592. package/node_modules/@smithy/types/dist-es/extensions/defaultClientConfiguration.js +7 -0
  593. package/node_modules/@smithy/types/dist-es/extensions/defaultExtensionConfiguration.js +1 -0
  594. package/node_modules/@smithy/types/dist-es/extensions/index.js +3 -0
  595. package/node_modules/@smithy/types/dist-es/extensions/retry.js +1 -0
  596. package/node_modules/@smithy/types/dist-es/externals-check/browser-externals-check.js +1 -0
  597. package/node_modules/@smithy/types/dist-es/feature-ids.js +1 -0
  598. package/node_modules/@smithy/types/dist-es/http/httpHandlerInitialization.js +1 -0
  599. package/node_modules/@smithy/types/dist-es/http.js +5 -0
  600. package/node_modules/@smithy/types/dist-es/identity/apiKeyIdentity.js +1 -0
  601. package/node_modules/@smithy/types/dist-es/identity/awsCredentialIdentity.js +1 -0
  602. package/node_modules/@smithy/types/dist-es/identity/identity.js +1 -0
  603. package/node_modules/@smithy/types/dist-es/identity/index.js +4 -0
  604. package/node_modules/@smithy/types/dist-es/identity/tokenIdentity.js +1 -0
  605. package/node_modules/@smithy/types/dist-es/index.js +42 -0
  606. package/node_modules/@smithy/types/dist-es/logger.js +1 -0
  607. package/node_modules/@smithy/types/dist-es/middleware.js +1 -0
  608. package/node_modules/@smithy/types/dist-es/pagination.js +1 -0
  609. package/node_modules/@smithy/types/dist-es/profile.js +6 -0
  610. package/node_modules/@smithy/types/dist-es/response.js +1 -0
  611. package/node_modules/@smithy/types/dist-es/retry.js +1 -0
  612. package/node_modules/@smithy/types/dist-es/schema/schema-deprecated.js +1 -0
  613. package/node_modules/@smithy/types/dist-es/schema/schema.js +1 -0
  614. package/node_modules/@smithy/types/dist-es/schema/sentinels.js +1 -0
  615. package/node_modules/@smithy/types/dist-es/schema/static-schemas.js +1 -0
  616. package/node_modules/@smithy/types/dist-es/schema/traits.js +1 -0
  617. package/node_modules/@smithy/types/dist-es/serde.js +1 -0
  618. package/node_modules/@smithy/types/dist-es/shapes.js +1 -0
  619. package/node_modules/@smithy/types/dist-es/signature.js +1 -0
  620. package/node_modules/@smithy/types/dist-es/stream.js +1 -0
  621. package/node_modules/@smithy/types/dist-es/streaming-payload/streaming-blob-common-types.js +1 -0
  622. package/node_modules/@smithy/types/dist-es/streaming-payload/streaming-blob-payload-input-types.js +1 -0
  623. package/node_modules/@smithy/types/dist-es/streaming-payload/streaming-blob-payload-output-types.js +1 -0
  624. package/node_modules/@smithy/types/dist-es/transfer.js +6 -0
  625. package/node_modules/@smithy/types/dist-es/transform/client-method-transforms.js +1 -0
  626. package/node_modules/@smithy/types/dist-es/transform/client-payload-blob-type-narrow.js +1 -0
  627. package/node_modules/@smithy/types/dist-es/transform/exact.js +1 -0
  628. package/node_modules/@smithy/types/dist-es/transform/mutable.js +1 -0
  629. package/node_modules/@smithy/types/dist-es/transform/no-undefined.js +1 -0
  630. package/node_modules/@smithy/types/dist-es/transform/type-transform.js +1 -0
  631. package/node_modules/@smithy/types/dist-es/uri.js +1 -0
  632. package/node_modules/@smithy/types/dist-es/util.js +1 -0
  633. package/node_modules/@smithy/types/dist-es/waiter.js +1 -0
  634. package/node_modules/@smithy/types/dist-types/abort-handler.d.ts +7 -0
  635. package/node_modules/@smithy/types/dist-types/abort.d.ts +50 -0
  636. package/node_modules/@smithy/types/dist-types/auth/HttpApiKeyAuth.d.ts +7 -0
  637. package/node_modules/@smithy/types/dist-types/auth/HttpAuthScheme.d.ts +49 -0
  638. package/node_modules/@smithy/types/dist-types/auth/HttpAuthSchemeProvider.d.ts +20 -0
  639. package/node_modules/@smithy/types/dist-types/auth/HttpSigner.d.ts +41 -0
  640. package/node_modules/@smithy/types/dist-types/auth/IdentityProviderConfig.d.ts +14 -0
  641. package/node_modules/@smithy/types/dist-types/auth/auth.d.ts +57 -0
  642. package/node_modules/@smithy/types/dist-types/auth/index.d.ts +6 -0
  643. package/node_modules/@smithy/types/dist-types/blob/blob-payload-input-types.d.ts +40 -0
  644. package/node_modules/@smithy/types/dist-types/checksum.d.ts +63 -0
  645. package/node_modules/@smithy/types/dist-types/client.d.ts +57 -0
  646. package/node_modules/@smithy/types/dist-types/command.d.ts +28 -0
  647. package/node_modules/@smithy/types/dist-types/connection/config.d.ts +10 -0
  648. package/node_modules/@smithy/types/dist-types/connection/index.d.ts +3 -0
  649. package/node_modules/@smithy/types/dist-types/connection/manager.d.ts +34 -0
  650. package/node_modules/@smithy/types/dist-types/connection/pool.d.ts +32 -0
  651. package/node_modules/@smithy/types/dist-types/crypto.d.ts +60 -0
  652. package/node_modules/@smithy/types/dist-types/downlevel-ts3.4/transform/type-transform.d.ts +25 -0
  653. package/node_modules/@smithy/types/dist-types/encode.d.ts +31 -0
  654. package/node_modules/@smithy/types/dist-types/endpoint.d.ts +77 -0
  655. package/node_modules/@smithy/types/dist-types/endpoints/EndpointRuleObject.d.ts +27 -0
  656. package/node_modules/@smithy/types/dist-types/endpoints/ErrorRuleObject.d.ts +10 -0
  657. package/node_modules/@smithy/types/dist-types/endpoints/RuleSetObject.d.ts +28 -0
  658. package/node_modules/@smithy/types/dist-types/endpoints/TreeRuleObject.d.ts +16 -0
  659. package/node_modules/@smithy/types/dist-types/endpoints/index.d.ts +5 -0
  660. package/node_modules/@smithy/types/dist-types/endpoints/shared.d.ts +55 -0
  661. package/node_modules/@smithy/types/dist-types/eventStream.d.ts +137 -0
  662. package/node_modules/@smithy/types/dist-types/extensions/checksum.d.ts +58 -0
  663. package/node_modules/@smithy/types/dist-types/extensions/defaultClientConfiguration.d.ts +33 -0
  664. package/node_modules/@smithy/types/dist-types/extensions/defaultExtensionConfiguration.d.ts +9 -0
  665. package/node_modules/@smithy/types/dist-types/extensions/index.d.ts +4 -0
  666. package/node_modules/@smithy/types/dist-types/extensions/retry.d.ts +18 -0
  667. package/node_modules/@smithy/types/dist-types/externals-check/browser-externals-check.d.ts +35 -0
  668. package/node_modules/@smithy/types/dist-types/feature-ids.d.ts +16 -0
  669. package/node_modules/@smithy/types/dist-types/http/httpHandlerInitialization.d.ts +128 -0
  670. package/node_modules/@smithy/types/dist-types/http.d.ts +112 -0
  671. package/node_modules/@smithy/types/dist-types/identity/apiKeyIdentity.d.ts +14 -0
  672. package/node_modules/@smithy/types/dist-types/identity/awsCredentialIdentity.d.ts +31 -0
  673. package/node_modules/@smithy/types/dist-types/identity/identity.d.ts +15 -0
  674. package/node_modules/@smithy/types/dist-types/identity/index.d.ts +4 -0
  675. package/node_modules/@smithy/types/dist-types/identity/tokenIdentity.d.ts +14 -0
  676. package/node_modules/@smithy/types/dist-types/index.d.ts +42 -0
  677. package/node_modules/@smithy/types/dist-types/logger.d.ts +13 -0
  678. package/node_modules/@smithy/types/dist-types/middleware.d.ts +534 -0
  679. package/node_modules/@smithy/types/dist-types/pagination.d.ts +33 -0
  680. package/node_modules/@smithy/types/dist-types/profile.d.ts +30 -0
  681. package/node_modules/@smithy/types/dist-types/response.d.ts +40 -0
  682. package/node_modules/@smithy/types/dist-types/retry.d.ts +133 -0
  683. package/node_modules/@smithy/types/dist-types/schema/schema-deprecated.d.ts +136 -0
  684. package/node_modules/@smithy/types/dist-types/schema/schema.d.ts +230 -0
  685. package/node_modules/@smithy/types/dist-types/schema/sentinels.d.ts +65 -0
  686. package/node_modules/@smithy/types/dist-types/schema/static-schemas.d.ts +82 -0
  687. package/node_modules/@smithy/types/dist-types/schema/traits.d.ts +46 -0
  688. package/node_modules/@smithy/types/dist-types/serde.d.ts +114 -0
  689. package/node_modules/@smithy/types/dist-types/shapes.d.ts +82 -0
  690. package/node_modules/@smithy/types/dist-types/signature.d.ts +155 -0
  691. package/node_modules/@smithy/types/dist-types/stream.d.ts +22 -0
  692. package/node_modules/@smithy/types/dist-types/streaming-payload/streaming-blob-common-types.d.ts +32 -0
  693. package/node_modules/@smithy/types/dist-types/streaming-payload/streaming-blob-payload-input-types.d.ts +60 -0
  694. package/node_modules/@smithy/types/dist-types/streaming-payload/streaming-blob-payload-output-types.d.ts +51 -0
  695. package/node_modules/@smithy/types/dist-types/transfer.d.ts +41 -0
  696. package/node_modules/@smithy/types/dist-types/transform/client-method-transforms.d.ts +26 -0
  697. package/node_modules/@smithy/types/dist-types/transform/client-payload-blob-type-narrow.d.ts +77 -0
  698. package/node_modules/@smithy/types/dist-types/transform/exact.d.ts +6 -0
  699. package/node_modules/@smithy/types/dist-types/transform/mutable.d.ts +6 -0
  700. package/node_modules/@smithy/types/dist-types/transform/no-undefined.d.ts +68 -0
  701. package/node_modules/@smithy/types/dist-types/transform/type-transform.d.ts +34 -0
  702. package/node_modules/@smithy/types/dist-types/ts3.4/abort-handler.d.ts +7 -0
  703. package/node_modules/@smithy/types/dist-types/ts3.4/abort.d.ts +50 -0
  704. package/node_modules/@smithy/types/dist-types/ts3.4/auth/HttpApiKeyAuth.d.ts +7 -0
  705. package/node_modules/@smithy/types/dist-types/ts3.4/auth/HttpAuthScheme.d.ts +49 -0
  706. package/node_modules/@smithy/types/dist-types/ts3.4/auth/HttpAuthSchemeProvider.d.ts +20 -0
  707. package/node_modules/@smithy/types/dist-types/ts3.4/auth/HttpSigner.d.ts +41 -0
  708. package/node_modules/@smithy/types/dist-types/ts3.4/auth/IdentityProviderConfig.d.ts +14 -0
  709. package/node_modules/@smithy/types/dist-types/ts3.4/auth/auth.d.ts +57 -0
  710. package/node_modules/@smithy/types/dist-types/ts3.4/auth/index.d.ts +6 -0
  711. package/node_modules/@smithy/types/dist-types/ts3.4/blob/blob-payload-input-types.d.ts +40 -0
  712. package/node_modules/@smithy/types/dist-types/ts3.4/checksum.d.ts +63 -0
  713. package/node_modules/@smithy/types/dist-types/ts3.4/client.d.ts +57 -0
  714. package/node_modules/@smithy/types/dist-types/ts3.4/command.d.ts +28 -0
  715. package/node_modules/@smithy/types/dist-types/ts3.4/connection/config.d.ts +10 -0
  716. package/node_modules/@smithy/types/dist-types/ts3.4/connection/index.d.ts +3 -0
  717. package/node_modules/@smithy/types/dist-types/ts3.4/connection/manager.d.ts +34 -0
  718. package/node_modules/@smithy/types/dist-types/ts3.4/connection/pool.d.ts +32 -0
  719. package/node_modules/@smithy/types/dist-types/ts3.4/crypto.d.ts +60 -0
  720. package/node_modules/@smithy/types/dist-types/ts3.4/downlevel-ts3.4/transform/type-transform.d.ts +41 -0
  721. package/node_modules/@smithy/types/dist-types/ts3.4/encode.d.ts +31 -0
  722. package/node_modules/@smithy/types/dist-types/ts3.4/endpoint.d.ts +77 -0
  723. package/node_modules/@smithy/types/dist-types/ts3.4/endpoints/EndpointRuleObject.d.ts +27 -0
  724. package/node_modules/@smithy/types/dist-types/ts3.4/endpoints/ErrorRuleObject.d.ts +10 -0
  725. package/node_modules/@smithy/types/dist-types/ts3.4/endpoints/RuleSetObject.d.ts +28 -0
  726. package/node_modules/@smithy/types/dist-types/ts3.4/endpoints/TreeRuleObject.d.ts +16 -0
  727. package/node_modules/@smithy/types/dist-types/ts3.4/endpoints/index.d.ts +5 -0
  728. package/node_modules/@smithy/types/dist-types/ts3.4/endpoints/shared.d.ts +55 -0
  729. package/node_modules/@smithy/types/dist-types/ts3.4/eventStream.d.ts +137 -0
  730. package/node_modules/@smithy/types/dist-types/ts3.4/extensions/checksum.d.ts +58 -0
  731. package/node_modules/@smithy/types/dist-types/ts3.4/extensions/defaultClientConfiguration.d.ts +33 -0
  732. package/node_modules/@smithy/types/dist-types/ts3.4/extensions/defaultExtensionConfiguration.d.ts +9 -0
  733. package/node_modules/@smithy/types/dist-types/ts3.4/extensions/index.d.ts +4 -0
  734. package/node_modules/@smithy/types/dist-types/ts3.4/extensions/retry.d.ts +18 -0
  735. package/node_modules/@smithy/types/dist-types/ts3.4/externals-check/browser-externals-check.d.ts +35 -0
  736. package/node_modules/@smithy/types/dist-types/ts3.4/feature-ids.d.ts +16 -0
  737. package/node_modules/@smithy/types/dist-types/ts3.4/http/httpHandlerInitialization.d.ts +128 -0
  738. package/node_modules/@smithy/types/dist-types/ts3.4/http.d.ts +112 -0
  739. package/node_modules/@smithy/types/dist-types/ts3.4/identity/apiKeyIdentity.d.ts +14 -0
  740. package/node_modules/@smithy/types/dist-types/ts3.4/identity/awsCredentialIdentity.d.ts +31 -0
  741. package/node_modules/@smithy/types/dist-types/ts3.4/identity/identity.d.ts +15 -0
  742. package/node_modules/@smithy/types/dist-types/ts3.4/identity/index.d.ts +4 -0
  743. package/node_modules/@smithy/types/dist-types/ts3.4/identity/tokenIdentity.d.ts +14 -0
  744. package/node_modules/@smithy/types/dist-types/ts3.4/index.d.ts +42 -0
  745. package/node_modules/@smithy/types/dist-types/ts3.4/logger.d.ts +13 -0
  746. package/node_modules/@smithy/types/dist-types/ts3.4/middleware.d.ts +534 -0
  747. package/node_modules/@smithy/types/dist-types/ts3.4/pagination.d.ts +33 -0
  748. package/node_modules/@smithy/types/dist-types/ts3.4/profile.d.ts +30 -0
  749. package/node_modules/@smithy/types/dist-types/ts3.4/response.d.ts +40 -0
  750. package/node_modules/@smithy/types/dist-types/ts3.4/retry.d.ts +133 -0
  751. package/node_modules/@smithy/types/dist-types/ts3.4/schema/schema-deprecated.d.ts +142 -0
  752. package/node_modules/@smithy/types/dist-types/ts3.4/schema/schema.d.ts +245 -0
  753. package/node_modules/@smithy/types/dist-types/ts3.4/schema/sentinels.d.ts +65 -0
  754. package/node_modules/@smithy/types/dist-types/ts3.4/schema/static-schemas.d.ts +101 -0
  755. package/node_modules/@smithy/types/dist-types/ts3.4/schema/traits.d.ts +46 -0
  756. package/node_modules/@smithy/types/dist-types/ts3.4/serde.d.ts +114 -0
  757. package/node_modules/@smithy/types/dist-types/ts3.4/shapes.d.ts +82 -0
  758. package/node_modules/@smithy/types/dist-types/ts3.4/signature.d.ts +155 -0
  759. package/node_modules/@smithy/types/dist-types/ts3.4/stream.d.ts +22 -0
  760. package/node_modules/@smithy/types/dist-types/ts3.4/streaming-payload/streaming-blob-common-types.d.ts +32 -0
  761. package/node_modules/@smithy/types/dist-types/ts3.4/streaming-payload/streaming-blob-payload-input-types.d.ts +60 -0
  762. package/node_modules/@smithy/types/dist-types/ts3.4/streaming-payload/streaming-blob-payload-output-types.d.ts +51 -0
  763. package/node_modules/@smithy/types/dist-types/ts3.4/transfer.d.ts +41 -0
  764. package/node_modules/@smithy/types/dist-types/ts3.4/transform/client-method-transforms.d.ts +26 -0
  765. package/node_modules/@smithy/types/dist-types/ts3.4/transform/client-payload-blob-type-narrow.d.ts +81 -0
  766. package/node_modules/@smithy/types/dist-types/ts3.4/transform/exact.d.ts +14 -0
  767. package/node_modules/@smithy/types/dist-types/ts3.4/transform/mutable.d.ts +6 -0
  768. package/node_modules/@smithy/types/dist-types/ts3.4/transform/no-undefined.d.ts +88 -0
  769. package/node_modules/@smithy/types/dist-types/ts3.4/transform/type-transform.d.ts +41 -0
  770. package/node_modules/@smithy/types/dist-types/ts3.4/uri.d.ts +17 -0
  771. package/node_modules/@smithy/types/dist-types/ts3.4/util.d.ts +192 -0
  772. package/node_modules/@smithy/types/dist-types/ts3.4/waiter.d.ts +35 -0
  773. package/node_modules/@smithy/types/dist-types/uri.d.ts +17 -0
  774. package/node_modules/@smithy/types/dist-types/util.d.ts +176 -0
  775. package/node_modules/@smithy/types/dist-types/waiter.d.ts +35 -0
  776. package/node_modules/@smithy/types/package.json +61 -0
  777. package/node_modules/marked/LICENSE.md +44 -0
  778. package/node_modules/marked/README.md +106 -0
  779. package/node_modules/marked/bin/main.js +282 -0
  780. package/node_modules/marked/bin/marked.js +15 -0
  781. package/node_modules/marked/lib/marked.cjs +2211 -0
  782. package/node_modules/marked/lib/marked.cjs.map +7 -0
  783. package/node_modules/marked/lib/marked.d.cts +728 -0
  784. package/node_modules/marked/lib/marked.d.ts +728 -0
  785. package/node_modules/marked/lib/marked.esm.js +2189 -0
  786. package/node_modules/marked/lib/marked.esm.js.map +7 -0
  787. package/node_modules/marked/lib/marked.umd.js +2213 -0
  788. package/node_modules/marked/lib/marked.umd.js.map +7 -0
  789. package/node_modules/marked/man/marked.1 +111 -0
  790. package/node_modules/marked/man/marked.1.md +92 -0
  791. package/node_modules/marked/marked.min.js +69 -0
  792. package/node_modules/marked/package.json +111 -0
  793. package/npm-shrinkwrap.json +1841 -0
  794. package/package.json +49 -31
@@ -0,0 +1,1127 @@
1
+ import Anthropic from "@anthropic-ai/sdk";
2
+ import { getEnvApiKey } from "../env-api-keys.js";
3
+ import { calculateCost } from "../models.js";
4
+ import { AssistantMessageEventStream } from "../utils/event-stream.js";
5
+ import { headersToRecord } from "../utils/headers.js";
6
+ import { parseJsonWithRepair, parseStreamingJson } from "../utils/json-parse.js";
7
+ import { sanitizeSurrogates } from "../utils/sanitize-unicode.js";
8
+ import { resolveCloudflareBaseUrl } from "./cloudflare.js";
9
+ import { buildCopilotDynamicHeaders, hasCopilotVisionInput } from "./github-copilot-headers.js";
10
+ import { ANTHROPIC_RESERVED_BODY_KEYS, adjustMaxTokensForThinking, buildBaseOptions } from "./simple-options.js";
11
+ import { transformMessages } from "./transform-messages.js";
12
+ /**
13
+ * Resolve cache retention preference.
14
+ * Defaults to "short" and uses PI_CACHE_RETENTION for backward compatibility.
15
+ */
16
+ function resolveCacheRetention(cacheRetention) {
17
+ if (cacheRetention) {
18
+ return cacheRetention;
19
+ }
20
+ if (typeof process !== "undefined" && process.env.PI_CACHE_RETENTION === "long") {
21
+ return "long";
22
+ }
23
+ return "short";
24
+ }
25
+ function getCacheControl(model, cacheRetention) {
26
+ const retention = resolveCacheRetention(cacheRetention);
27
+ if (retention === "none") {
28
+ return { retention };
29
+ }
30
+ const ttl = retention === "long" && getAnthropicCompat(model).supportsLongCacheRetention ? "1h" : undefined;
31
+ return {
32
+ retention,
33
+ cacheControl: { type: "ephemeral", ...(ttl && { ttl }) },
34
+ };
35
+ }
36
+ // Stealth mode: Mimic Claude Code's tool naming exactly
37
+ const claudeCodeVersion = "2.1.75";
38
+ // Claude Code 2.x tool names (canonical casing)
39
+ // Source: https://cchistory.mariozechner.at/data/prompts-2.1.11.md
40
+ // To update: https://github.com/badlogic/cchistory
41
+ const claudeCodeTools = [
42
+ "Read",
43
+ "Write",
44
+ "Edit",
45
+ "Bash",
46
+ "Grep",
47
+ "Glob",
48
+ "AskUserQuestion",
49
+ "EnterPlanMode",
50
+ "ExitPlanMode",
51
+ "KillShell",
52
+ "NotebookEdit",
53
+ "Skill",
54
+ "Task",
55
+ "TaskOutput",
56
+ "TodoWrite",
57
+ "WebFetch",
58
+ "WebSearch",
59
+ ];
60
+ const ccToolLookup = new Map(claudeCodeTools.map((t) => [t.toLowerCase(), t]));
61
+ // Convert tool name to CC canonical casing if it matches (case-insensitive)
62
+ const toClaudeCodeName = (name) => ccToolLookup.get(name.toLowerCase()) ?? name;
63
+ const fromClaudeCodeName = (name, tools) => {
64
+ if (tools && tools.length > 0) {
65
+ const lowerName = name.toLowerCase();
66
+ const matchedTool = tools.find((tool) => tool.name.toLowerCase() === lowerName);
67
+ if (matchedTool)
68
+ return matchedTool.name;
69
+ }
70
+ return name;
71
+ };
72
+ /**
73
+ * Convert content blocks to Anthropic API format
74
+ */
75
+ function convertContentBlocks(content) {
76
+ // If only text blocks, return as concatenated string for simplicity
77
+ const hasImages = content.some((c) => c.type === "image");
78
+ if (!hasImages) {
79
+ return sanitizeSurrogates(content.map((c) => c.text).join("\n"));
80
+ }
81
+ // If we have images, convert to content block array
82
+ const blocks = content.map((block) => {
83
+ if (block.type === "text") {
84
+ return {
85
+ type: "text",
86
+ text: sanitizeSurrogates(block.text),
87
+ };
88
+ }
89
+ return {
90
+ type: "image",
91
+ source: {
92
+ type: "base64",
93
+ media_type: block.mimeType,
94
+ data: block.data,
95
+ },
96
+ };
97
+ });
98
+ // If only images (no text), add placeholder text block
99
+ const hasText = blocks.some((b) => b.type === "text");
100
+ if (!hasText) {
101
+ blocks.unshift({
102
+ type: "text",
103
+ text: "(see attached image)",
104
+ });
105
+ }
106
+ return blocks;
107
+ }
108
+ const FINE_GRAINED_TOOL_STREAMING_BETA = "fine-grained-tool-streaming-2025-05-14";
109
+ const INTERLEAVED_THINKING_BETA = "interleaved-thinking-2025-05-14";
110
+ const COMPUTER_USE_BETA_PREFIX = "computer-use-";
111
+ const NATIVE_COMPUTER_TOOL_TYPE = "computer_20250124";
112
+ function getAnthropicCompat(model) {
113
+ // Auto-detect session affinity and cache control support from provider
114
+ const isFireworks = model.provider === "fireworks";
115
+ const isCloudflareAiGatewayAnthropic = model.provider === "cloudflare-ai-gateway" && model.baseUrl.includes("anthropic");
116
+ const isXiaomi = model.provider === "xiaomi" || model.provider.startsWith("xiaomi-token-plan-");
117
+ return {
118
+ supportsEagerToolInputStreaming: model.compat?.supportsEagerToolInputStreaming ?? !isFireworks,
119
+ supportsLongCacheRetention: model.compat?.supportsLongCacheRetention ?? !isFireworks,
120
+ sendSessionAffinityHeaders: model.compat?.sendSessionAffinityHeaders ?? !!(isFireworks || isCloudflareAiGatewayAnthropic),
121
+ supportsCacheControlOnTools: model.compat?.supportsCacheControlOnTools ?? !isFireworks,
122
+ supportsDisabledThinking: model.compat?.supportsDisabledThinking ?? !isXiaomi,
123
+ };
124
+ }
125
+ function mergeHeaders(...headerSources) {
126
+ const merged = {};
127
+ for (const headers of headerSources) {
128
+ if (headers) {
129
+ Object.assign(merged, headers);
130
+ }
131
+ }
132
+ return merged;
133
+ }
134
+ function isRecord(value) {
135
+ return typeof value === "object" && value !== null;
136
+ }
137
+ function stringRecord(value) {
138
+ if (!isRecord(value)) {
139
+ return undefined;
140
+ }
141
+ const entries = Object.entries(value);
142
+ if (entries.some(([, item]) => typeof item !== "string")) {
143
+ return undefined;
144
+ }
145
+ return Object.fromEntries(entries);
146
+ }
147
+ function extractPayloadRequestMetadata(params) {
148
+ const payload = params;
149
+ const headers = stringRecord(payload.headers);
150
+ if (!("headers" in payload) && !("extra_body" in payload)) {
151
+ return headers ? { params, headers } : { params };
152
+ }
153
+ const stripped = { ...payload };
154
+ delete stripped.headers;
155
+ delete stripped.extra_body;
156
+ return headers ? { params: stripped, headers } : { params: stripped };
157
+ }
158
+ function removeComputerUseBetaHeader(headers) {
159
+ if (!headers) {
160
+ return { changed: false };
161
+ }
162
+ const nextHeaders = {};
163
+ let changed = false;
164
+ for (const [key, value] of Object.entries(headers)) {
165
+ if (key.toLowerCase() !== "anthropic-beta") {
166
+ nextHeaders[key] = value;
167
+ continue;
168
+ }
169
+ const betas = value
170
+ .split(",")
171
+ .map((beta) => beta.trim())
172
+ .filter((beta) => beta.length > 0);
173
+ const supportedBetas = betas.filter((beta) => !beta.startsWith(COMPUTER_USE_BETA_PREFIX));
174
+ changed = changed || supportedBetas.length !== betas.length;
175
+ if (supportedBetas.length > 0) {
176
+ nextHeaders[key] = supportedBetas.join(", ");
177
+ }
178
+ }
179
+ if (!changed) {
180
+ return { changed: false, headers };
181
+ }
182
+ return {
183
+ changed: true,
184
+ headers: Object.keys(nextHeaders).length > 0 ? nextHeaders : undefined,
185
+ };
186
+ }
187
+ function rejectsNativeComputerTool(model, toolType) {
188
+ if (model.provider === "cloudflare-ai-gateway" && model.baseUrl.includes("anthropic")) {
189
+ return toolType.startsWith("computer_");
190
+ }
191
+ return (isOpus46(model.id) || isOpus47(model.id)) && toolType === NATIVE_COMPUTER_TOOL_TYPE;
192
+ }
193
+ function rejectsComputerUseBeta(model) {
194
+ return ((model.provider === "cloudflare-ai-gateway" && model.baseUrl.includes("anthropic")) ||
195
+ isOpus46(model.id) ||
196
+ isOpus47(model.id));
197
+ }
198
+ function sanitizeUnsupportedNativeTools(model, params) {
199
+ const payload = params;
200
+ const headers = stringRecord(payload.headers);
201
+ const headerSanitization = rejectsComputerUseBeta(model)
202
+ ? removeComputerUseBetaHeader(headers)
203
+ : { changed: false };
204
+ const tools = payload.tools;
205
+ const sanitized = { ...payload };
206
+ let changed = false;
207
+ const removedToolNames = new Set();
208
+ if (Array.isArray(tools)) {
209
+ const supportedTools = [];
210
+ for (const tool of tools) {
211
+ const hookTool = tool;
212
+ if (isRecord(hookTool) &&
213
+ typeof hookTool.type === "string" &&
214
+ rejectsNativeComputerTool(model, hookTool.type)) {
215
+ changed = true;
216
+ if (typeof hookTool.name === "string") {
217
+ removedToolNames.add(hookTool.name);
218
+ }
219
+ continue;
220
+ }
221
+ supportedTools.push(tool);
222
+ }
223
+ if (changed) {
224
+ if (supportedTools.length > 0) {
225
+ sanitized.tools = supportedTools;
226
+ }
227
+ else {
228
+ delete sanitized.tools;
229
+ }
230
+ }
231
+ }
232
+ if (headerSanitization.changed) {
233
+ changed = true;
234
+ if (headerSanitization.headers) {
235
+ sanitized.headers = headerSanitization.headers;
236
+ }
237
+ else {
238
+ delete sanitized.headers;
239
+ }
240
+ }
241
+ if (changed && isRecord(sanitized.tool_choice)) {
242
+ const toolChoiceName = sanitized.tool_choice.name;
243
+ const shouldRemoveToolChoice = (typeof toolChoiceName === "string" && removedToolNames.has(toolChoiceName)) || sanitized.tools === undefined;
244
+ if (shouldRemoveToolChoice) {
245
+ delete sanitized.tool_choice;
246
+ }
247
+ }
248
+ return changed ? sanitized : params;
249
+ }
250
+ function isCacheableUserContentBlock(block) {
251
+ return block?.type === "text" || block?.type === "image" || block?.type === "tool_result";
252
+ }
253
+ const ANTHROPIC_MESSAGE_EVENTS = new Set([
254
+ "message_start",
255
+ "message_delta",
256
+ "message_stop",
257
+ "content_block_start",
258
+ "content_block_delta",
259
+ "content_block_stop",
260
+ ]);
261
+ function flushSseEvent(state) {
262
+ if (!state.event && state.data.length === 0) {
263
+ return null;
264
+ }
265
+ const event = {
266
+ event: state.event,
267
+ data: state.data.join("\n"),
268
+ raw: [...state.raw],
269
+ };
270
+ state.event = null;
271
+ state.data = [];
272
+ state.raw = [];
273
+ return event;
274
+ }
275
+ function decodeSseLine(line, state) {
276
+ if (line === "") {
277
+ return flushSseEvent(state);
278
+ }
279
+ state.raw.push(line);
280
+ if (line.startsWith(":")) {
281
+ return null;
282
+ }
283
+ const delimiterIndex = line.indexOf(":");
284
+ const fieldName = delimiterIndex === -1 ? line : line.slice(0, delimiterIndex);
285
+ let value = delimiterIndex === -1 ? "" : line.slice(delimiterIndex + 1);
286
+ if (value.startsWith(" ")) {
287
+ value = value.slice(1);
288
+ }
289
+ if (fieldName === "event") {
290
+ state.event = value;
291
+ }
292
+ else if (fieldName === "data") {
293
+ state.data.push(value);
294
+ }
295
+ return null;
296
+ }
297
+ function nextLineBreakIndex(text) {
298
+ const carriageReturnIndex = text.indexOf("\r");
299
+ const newlineIndex = text.indexOf("\n");
300
+ if (carriageReturnIndex === -1) {
301
+ return newlineIndex;
302
+ }
303
+ if (newlineIndex === -1) {
304
+ return carriageReturnIndex;
305
+ }
306
+ return Math.min(carriageReturnIndex, newlineIndex);
307
+ }
308
+ function consumeLine(text) {
309
+ const lineBreakIndex = nextLineBreakIndex(text);
310
+ if (lineBreakIndex === -1) {
311
+ return null;
312
+ }
313
+ let nextIndex = lineBreakIndex + 1;
314
+ if (text[lineBreakIndex] === "\r" && text[nextIndex] === "\n") {
315
+ nextIndex += 1;
316
+ }
317
+ return {
318
+ line: text.slice(0, lineBreakIndex),
319
+ rest: text.slice(nextIndex),
320
+ };
321
+ }
322
+ async function* iterateSseMessages(body, signal) {
323
+ const reader = body.getReader();
324
+ const decoder = new TextDecoder();
325
+ const state = { event: null, data: [], raw: [] };
326
+ let buffer = "";
327
+ try {
328
+ while (true) {
329
+ if (signal?.aborted) {
330
+ throw new Error("Request was aborted");
331
+ }
332
+ const { value, done } = await reader.read();
333
+ if (done) {
334
+ break;
335
+ }
336
+ buffer += decoder.decode(value, { stream: true });
337
+ let consumed = consumeLine(buffer);
338
+ while (consumed) {
339
+ buffer = consumed.rest;
340
+ const event = decodeSseLine(consumed.line, state);
341
+ if (event) {
342
+ yield event;
343
+ }
344
+ consumed = consumeLine(buffer);
345
+ }
346
+ }
347
+ buffer += decoder.decode();
348
+ let consumed = consumeLine(buffer);
349
+ while (consumed) {
350
+ buffer = consumed.rest;
351
+ const event = decodeSseLine(consumed.line, state);
352
+ if (event) {
353
+ yield event;
354
+ }
355
+ consumed = consumeLine(buffer);
356
+ }
357
+ if (buffer.length > 0) {
358
+ const event = decodeSseLine(buffer, state);
359
+ if (event) {
360
+ yield event;
361
+ }
362
+ }
363
+ const trailingEvent = flushSseEvent(state);
364
+ if (trailingEvent) {
365
+ yield trailingEvent;
366
+ }
367
+ }
368
+ finally {
369
+ reader.releaseLock();
370
+ }
371
+ }
372
+ async function* iterateAnthropicEvents(response, signal) {
373
+ if (!response.body) {
374
+ throw new Error("Attempted to iterate over an Anthropic response with no body");
375
+ }
376
+ let sawMessageStart = false;
377
+ let sawMessageEnd = false;
378
+ for await (const sse of iterateSseMessages(response.body, signal)) {
379
+ if (sse.event === "error") {
380
+ throw new Error(sse.data);
381
+ }
382
+ if (!ANTHROPIC_MESSAGE_EVENTS.has(sse.event ?? "")) {
383
+ continue;
384
+ }
385
+ try {
386
+ const event = parseJsonWithRepair(sse.data);
387
+ if (event.type === "message_start") {
388
+ sawMessageStart = true;
389
+ }
390
+ else if (event.type === "message_stop") {
391
+ sawMessageEnd = true;
392
+ }
393
+ yield event;
394
+ }
395
+ catch (error) {
396
+ const message = error instanceof Error ? error.message : String(error);
397
+ throw new Error(`Could not parse Anthropic SSE event ${sse.event}: ${message}; data=${sse.data}; raw=${sse.raw.join("\\n")}`);
398
+ }
399
+ }
400
+ if (sawMessageStart && !sawMessageEnd) {
401
+ throw new Error("Anthropic stream ended before message_stop");
402
+ }
403
+ }
404
+ export const streamAnthropic = (model, context, options) => {
405
+ const stream = new AssistantMessageEventStream();
406
+ (async () => {
407
+ const output = {
408
+ role: "assistant",
409
+ content: [],
410
+ api: model.api,
411
+ provider: model.provider,
412
+ model: model.id,
413
+ usage: {
414
+ input: 0,
415
+ output: 0,
416
+ cacheRead: 0,
417
+ cacheWrite: 0,
418
+ totalTokens: 0,
419
+ cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },
420
+ },
421
+ stopReason: "stop",
422
+ timestamp: Date.now(),
423
+ };
424
+ try {
425
+ let client;
426
+ let isOAuth;
427
+ if (options?.client) {
428
+ client = options.client;
429
+ isOAuth = false;
430
+ }
431
+ else {
432
+ const apiKey = options?.apiKey ?? getEnvApiKey(model.provider) ?? "";
433
+ let copilotDynamicHeaders;
434
+ if (model.provider === "github-copilot") {
435
+ const hasImages = hasCopilotVisionInput(context.messages);
436
+ copilotDynamicHeaders = buildCopilotDynamicHeaders({
437
+ messages: context.messages,
438
+ hasImages,
439
+ });
440
+ }
441
+ const cacheRetention = options?.cacheRetention ?? resolveCacheRetention();
442
+ const cacheSessionId = cacheRetention === "none" ? undefined : options?.sessionId;
443
+ const created = createClient(model, apiKey, options?.interleavedThinking ?? true, shouldUseFineGrainedToolStreamingBeta(model, context), options?.headers, copilotDynamicHeaders, cacheSessionId);
444
+ client = created.client;
445
+ isOAuth = created.isOAuthToken;
446
+ }
447
+ let params = buildParams(model, context, isOAuth, options);
448
+ const nextParams = await options?.onPayload?.(params, model);
449
+ if (nextParams !== undefined) {
450
+ params = nextParams;
451
+ }
452
+ params = sanitizeUnsupportedNativeTools(model, params);
453
+ const payloadRequestMetadata = extractPayloadRequestMetadata(params);
454
+ params = payloadRequestMetadata.params;
455
+ const requestOptions = {
456
+ ...(options?.signal ? { signal: options.signal } : {}),
457
+ ...(options?.timeoutMs !== undefined ? { timeout: options.timeoutMs } : {}),
458
+ ...(options?.maxRetries !== undefined ? { maxRetries: options.maxRetries } : {}),
459
+ ...(payloadRequestMetadata.headers ? { headers: payloadRequestMetadata.headers } : {}),
460
+ };
461
+ const response = await client.messages.create({ ...params, stream: true }, requestOptions).asResponse();
462
+ await options?.onResponse?.({ status: response.status, headers: headersToRecord(response.headers) }, model);
463
+ stream.push({ type: "start", partial: output });
464
+ const blocks = output.content;
465
+ for await (const event of iterateAnthropicEvents(response, options?.signal)) {
466
+ if (event.type === "message_start") {
467
+ output.responseId = event.message.id;
468
+ // Capture initial token usage from message_start event
469
+ // This ensures we have input token counts even if the stream is aborted early
470
+ output.usage.input = event.message.usage.input_tokens || 0;
471
+ output.usage.output = event.message.usage.output_tokens || 0;
472
+ output.usage.cacheRead = event.message.usage.cache_read_input_tokens || 0;
473
+ output.usage.cacheWrite = event.message.usage.cache_creation_input_tokens || 0;
474
+ // Anthropic doesn't provide total_tokens, compute from components
475
+ output.usage.totalTokens =
476
+ output.usage.input + output.usage.output + output.usage.cacheRead + output.usage.cacheWrite;
477
+ calculateCost(model, output.usage);
478
+ }
479
+ else if (event.type === "content_block_start") {
480
+ if (event.content_block.type === "text") {
481
+ const block = {
482
+ type: "text",
483
+ text: "",
484
+ index: event.index,
485
+ };
486
+ output.content.push(block);
487
+ stream.push({ type: "text_start", contentIndex: output.content.length - 1, partial: output });
488
+ }
489
+ else if (event.content_block.type === "thinking") {
490
+ const block = {
491
+ type: "thinking",
492
+ thinking: "",
493
+ thinkingSignature: "",
494
+ index: event.index,
495
+ };
496
+ output.content.push(block);
497
+ stream.push({ type: "thinking_start", contentIndex: output.content.length - 1, partial: output });
498
+ }
499
+ else if (event.content_block.type === "redacted_thinking") {
500
+ const block = {
501
+ type: "thinking",
502
+ thinking: "[Reasoning redacted]",
503
+ thinkingSignature: event.content_block.data,
504
+ redacted: true,
505
+ index: event.index,
506
+ };
507
+ output.content.push(block);
508
+ stream.push({ type: "thinking_start", contentIndex: output.content.length - 1, partial: output });
509
+ }
510
+ else if (event.content_block.type === "tool_use") {
511
+ const block = {
512
+ type: "toolCall",
513
+ id: event.content_block.id,
514
+ name: isOAuth
515
+ ? fromClaudeCodeName(event.content_block.name, context.tools)
516
+ : event.content_block.name,
517
+ arguments: isRecord(event.content_block.input) ? event.content_block.input : {},
518
+ partialJson: "",
519
+ index: event.index,
520
+ };
521
+ output.content.push(block);
522
+ stream.push({ type: "toolcall_start", contentIndex: output.content.length - 1, partial: output });
523
+ }
524
+ else {
525
+ const block = {
526
+ type: "providerNative",
527
+ subtype: event.content_block.type,
528
+ raw: event.content_block,
529
+ index: event.index,
530
+ };
531
+ output.content.push(block);
532
+ // Native blocks are represented in output.content but have no dedicated stream event variant.
533
+ }
534
+ }
535
+ else if (event.type === "content_block_delta") {
536
+ if (event.delta.type === "text_delta") {
537
+ const index = blocks.findIndex((b) => b.index === event.index);
538
+ const block = blocks[index];
539
+ if (block && block.type === "text") {
540
+ block.text += event.delta.text;
541
+ stream.push({
542
+ type: "text_delta",
543
+ contentIndex: index,
544
+ delta: event.delta.text,
545
+ partial: output,
546
+ });
547
+ }
548
+ }
549
+ else if (event.delta.type === "thinking_delta") {
550
+ const index = blocks.findIndex((b) => b.index === event.index);
551
+ const block = blocks[index];
552
+ if (block && block.type === "thinking") {
553
+ block.thinking += event.delta.thinking;
554
+ stream.push({
555
+ type: "thinking_delta",
556
+ contentIndex: index,
557
+ delta: event.delta.thinking,
558
+ partial: output,
559
+ });
560
+ }
561
+ }
562
+ else if (event.delta.type === "input_json_delta") {
563
+ const index = blocks.findIndex((b) => b.index === event.index);
564
+ const block = blocks[index];
565
+ if (block && block.type === "toolCall") {
566
+ block.partialJson += event.delta.partial_json;
567
+ block.arguments = parseStreamingJson(block.partialJson);
568
+ stream.push({
569
+ type: "toolcall_delta",
570
+ contentIndex: index,
571
+ delta: event.delta.partial_json,
572
+ partial: output,
573
+ });
574
+ }
575
+ }
576
+ else if (event.delta.type === "signature_delta") {
577
+ const index = blocks.findIndex((b) => b.index === event.index);
578
+ const block = blocks[index];
579
+ if (block && block.type === "thinking") {
580
+ block.thinkingSignature = block.thinkingSignature || "";
581
+ block.thinkingSignature += event.delta.signature;
582
+ }
583
+ }
584
+ }
585
+ else if (event.type === "content_block_stop") {
586
+ const index = blocks.findIndex((b) => b.index === event.index);
587
+ const block = blocks[index];
588
+ if (block) {
589
+ delete block.index;
590
+ if (block.type === "text") {
591
+ stream.push({
592
+ type: "text_end",
593
+ contentIndex: index,
594
+ content: block.text,
595
+ partial: output,
596
+ });
597
+ }
598
+ else if (block.type === "thinking") {
599
+ stream.push({
600
+ type: "thinking_end",
601
+ contentIndex: index,
602
+ content: block.thinking,
603
+ partial: output,
604
+ });
605
+ }
606
+ else if (block.type === "toolCall") {
607
+ block.arguments = parseStreamingJson(block.partialJson);
608
+ // Finalize in-place and strip the scratch buffer so replay only
609
+ // carries parsed arguments.
610
+ delete block.partialJson;
611
+ stream.push({
612
+ type: "toolcall_end",
613
+ contentIndex: index,
614
+ toolCall: block,
615
+ partial: output,
616
+ });
617
+ }
618
+ }
619
+ }
620
+ else if (event.type === "message_delta") {
621
+ if (event.delta.stop_reason) {
622
+ output.stopReason = mapStopReason(event.delta.stop_reason);
623
+ }
624
+ // Only update usage fields if present (not null).
625
+ // Preserves input_tokens from message_start when proxies omit it in message_delta.
626
+ if (event.usage.input_tokens != null) {
627
+ output.usage.input = event.usage.input_tokens;
628
+ }
629
+ if (event.usage.output_tokens != null) {
630
+ output.usage.output = event.usage.output_tokens;
631
+ }
632
+ if (event.usage.cache_read_input_tokens != null) {
633
+ output.usage.cacheRead = event.usage.cache_read_input_tokens;
634
+ }
635
+ if (event.usage.cache_creation_input_tokens != null) {
636
+ output.usage.cacheWrite = event.usage.cache_creation_input_tokens;
637
+ }
638
+ // Anthropic doesn't provide total_tokens, compute from components
639
+ output.usage.totalTokens =
640
+ output.usage.input + output.usage.output + output.usage.cacheRead + output.usage.cacheWrite;
641
+ calculateCost(model, output.usage);
642
+ }
643
+ }
644
+ if (options?.signal?.aborted) {
645
+ throw new Error("Request was aborted");
646
+ }
647
+ if (output.stopReason === "aborted" || output.stopReason === "error") {
648
+ throw new Error("An unknown error occurred");
649
+ }
650
+ stream.push({ type: "done", reason: output.stopReason, message: output });
651
+ stream.end();
652
+ }
653
+ catch (error) {
654
+ for (const block of output.content) {
655
+ delete block.index;
656
+ // partialJson is only a streaming scratch buffer; never persist it.
657
+ delete block.partialJson;
658
+ }
659
+ output.stopReason = options?.signal?.aborted ? "aborted" : "error";
660
+ output.errorMessage = error instanceof Error ? error.message : JSON.stringify(error);
661
+ stream.push({ type: "error", reason: output.stopReason, error: output });
662
+ stream.end();
663
+ }
664
+ })();
665
+ return stream;
666
+ };
667
+ /**
668
+ * Check if a model supports adaptive thinking (Opus 4.6, Sonnet 4.6, Opus 4.7 and later).
669
+ */
670
+ function supportsAdaptiveThinking(modelId) {
671
+ return isOpus46(modelId) || isOpus47(modelId) || modelId.includes("sonnet-4-6") || modelId.includes("sonnet-4.6");
672
+ }
673
+ function isOpus46(modelId) {
674
+ return modelId.includes("opus-4-6") || modelId.includes("opus-4.6");
675
+ }
676
+ function isOpus47(modelId) {
677
+ return modelId.includes("opus-4-7") || modelId.includes("opus-4.7");
678
+ }
679
+ /**
680
+ * Map ThinkingLevel to Anthropic effort levels for adaptive thinking.
681
+ *
682
+ * Model-specific effort tiers:
683
+ * - Opus 4.7: supports "low" | "medium" | "high" | "xhigh" | "max"
684
+ * - Opus 4.6: supports "low" | "medium" | "high" | "max" ("xhigh" maps to "max")
685
+ * - Sonnet 4.6 and other adaptive models: "low" | "medium" | "high" ("xhigh"/"max" clamp to "high")
686
+ */
687
+ function mapThinkingLevelToEffort(model, level) {
688
+ const mapped = level ? model.thinkingLevelMap?.[level] : undefined;
689
+ if (typeof mapped === "string")
690
+ return mapped;
691
+ switch (level) {
692
+ case "minimal":
693
+ case "low":
694
+ return "low";
695
+ case "medium":
696
+ return "medium";
697
+ case "high":
698
+ return "high";
699
+ case "xhigh":
700
+ if (isOpus47(model.id))
701
+ return "xhigh";
702
+ if (isOpus46(model.id))
703
+ return "max";
704
+ return "high";
705
+ case "max":
706
+ if (isOpus47(model.id) || isOpus46(model.id))
707
+ return "max";
708
+ return "high";
709
+ default:
710
+ return "high";
711
+ }
712
+ }
713
+ export const streamSimpleAnthropic = (model, context, options) => {
714
+ const apiKey = options?.apiKey || getEnvApiKey(model.provider);
715
+ if (!apiKey) {
716
+ throw new Error(`No API key for provider: ${model.provider}`);
717
+ }
718
+ const base = buildBaseOptions(model, options, apiKey);
719
+ if (!options?.reasoning) {
720
+ return streamAnthropic(model, context, { ...base, thinkingEnabled: false });
721
+ }
722
+ // For Opus 4.6 and Sonnet 4.6: use adaptive thinking with effort level
723
+ // For older models: use budget-based thinking
724
+ if (supportsAdaptiveThinking(model.id)) {
725
+ const effort = mapThinkingLevelToEffort(model, options.reasoning);
726
+ return streamAnthropic(model, context, {
727
+ ...base,
728
+ thinkingEnabled: true,
729
+ effort,
730
+ });
731
+ }
732
+ // Undefined means the caller did not request an output cap; let the helper use the model cap.
733
+ // Do not coerce to 0 here, or the thinking budget would become the entire max_tokens value.
734
+ const adjusted = adjustMaxTokensForThinking(base.maxTokens, model.maxTokens, options.reasoning, options.thinkingBudgets);
735
+ return streamAnthropic(model, context, {
736
+ ...base,
737
+ maxTokens: adjusted.maxTokens,
738
+ thinkingEnabled: true,
739
+ thinkingBudgetTokens: adjusted.thinkingBudget,
740
+ });
741
+ };
742
+ function isOAuthToken(apiKey) {
743
+ return apiKey.includes("sk-ant-oat");
744
+ }
745
+ function createClient(model, apiKey, interleavedThinking, useFineGrainedToolStreamingBeta, optionsHeaders, dynamicHeaders, sessionId) {
746
+ // Adaptive thinking models (Opus 4.6, Sonnet 4.6) have interleaved thinking built-in.
747
+ // The beta header is deprecated on Opus 4.6 and redundant on Sonnet 4.6, so skip it.
748
+ const needsInterleavedBeta = interleavedThinking && !supportsAdaptiveThinking(model.id);
749
+ const betaFeatures = [];
750
+ if (useFineGrainedToolStreamingBeta) {
751
+ betaFeatures.push(FINE_GRAINED_TOOL_STREAMING_BETA);
752
+ }
753
+ if (needsInterleavedBeta) {
754
+ betaFeatures.push(INTERLEAVED_THINKING_BETA);
755
+ }
756
+ if (model.provider === "cloudflare-ai-gateway") {
757
+ const client = new Anthropic({
758
+ apiKey: null,
759
+ authToken: null,
760
+ baseURL: resolveCloudflareBaseUrl(model),
761
+ dangerouslyAllowBrowser: true,
762
+ defaultHeaders: mergeHeaders({
763
+ accept: "application/json",
764
+ "anthropic-dangerous-direct-browser-access": "true",
765
+ "cf-aig-authorization": `Bearer ${apiKey}`,
766
+ "x-api-key": null,
767
+ Authorization: null,
768
+ ...(betaFeatures.length > 0 ? { "anthropic-beta": betaFeatures.join(",") } : {}),
769
+ }, model.headers, optionsHeaders),
770
+ });
771
+ return { client, isOAuthToken: false };
772
+ }
773
+ // Copilot: Bearer auth, selective betas.
774
+ if (model.provider === "github-copilot") {
775
+ const client = new Anthropic({
776
+ apiKey: null,
777
+ authToken: apiKey,
778
+ baseURL: model.baseUrl,
779
+ dangerouslyAllowBrowser: true,
780
+ defaultHeaders: mergeHeaders({
781
+ accept: "application/json",
782
+ "anthropic-dangerous-direct-browser-access": "true",
783
+ ...(betaFeatures.length > 0 ? { "anthropic-beta": betaFeatures.join(",") } : {}),
784
+ }, model.headers, dynamicHeaders, optionsHeaders),
785
+ });
786
+ return { client, isOAuthToken: false };
787
+ }
788
+ // OAuth: Bearer auth, Claude Code identity headers
789
+ if (isOAuthToken(apiKey)) {
790
+ const client = new Anthropic({
791
+ apiKey: null,
792
+ authToken: apiKey,
793
+ baseURL: model.baseUrl,
794
+ dangerouslyAllowBrowser: true,
795
+ defaultHeaders: mergeHeaders({
796
+ accept: "application/json",
797
+ "anthropic-dangerous-direct-browser-access": "true",
798
+ "anthropic-beta": ["claude-code-20250219", "oauth-2025-04-20", ...betaFeatures].join(","),
799
+ "user-agent": `claude-cli/${claudeCodeVersion}`,
800
+ "x-app": "cli",
801
+ }, model.headers, optionsHeaders),
802
+ });
803
+ return { client, isOAuthToken: true };
804
+ }
805
+ // API key auth
806
+ const sessionAffinityHeaders = sessionId && getAnthropicCompat(model).sendSessionAffinityHeaders ? { "x-session-affinity": sessionId } : {};
807
+ const client = new Anthropic({
808
+ apiKey,
809
+ authToken: null,
810
+ baseURL: model.baseUrl,
811
+ dangerouslyAllowBrowser: true,
812
+ defaultHeaders: mergeHeaders({
813
+ accept: "application/json",
814
+ "anthropic-dangerous-direct-browser-access": "true",
815
+ ...(betaFeatures.length > 0 ? { "anthropic-beta": betaFeatures.join(",") } : {}),
816
+ }, sessionAffinityHeaders, model.headers, optionsHeaders),
817
+ });
818
+ return { client, isOAuthToken: false };
819
+ }
820
+ function buildParams(model, context, isOAuthToken, options) {
821
+ const compat = getAnthropicCompat(model);
822
+ const { cacheControl } = getCacheControl(model, options?.cacheRetention);
823
+ const params = {
824
+ model: model.id,
825
+ messages: convertMessages(context.messages, model, isOAuthToken, cacheControl, options?.thinkingEnabled === true),
826
+ max_tokens: options?.maxTokens ?? model.maxTokens,
827
+ stream: true,
828
+ };
829
+ // For OAuth tokens, we MUST include Claude Code identity
830
+ if (isOAuthToken) {
831
+ params.system = [
832
+ {
833
+ type: "text",
834
+ text: "You are Claude Code, Anthropic's official CLI for Claude.",
835
+ ...(cacheControl ? { cache_control: cacheControl } : {}),
836
+ },
837
+ ];
838
+ if (context.systemPrompt) {
839
+ params.system.push({
840
+ type: "text",
841
+ text: sanitizeSurrogates(context.systemPrompt),
842
+ ...(cacheControl ? { cache_control: cacheControl } : {}),
843
+ });
844
+ }
845
+ }
846
+ else if (context.systemPrompt) {
847
+ // Add cache control to system prompt for non-OAuth tokens
848
+ params.system = [
849
+ {
850
+ type: "text",
851
+ text: sanitizeSurrogates(context.systemPrompt),
852
+ ...(cacheControl ? { cache_control: cacheControl } : {}),
853
+ },
854
+ ];
855
+ }
856
+ // Temperature is incompatible with extended thinking (adaptive or budget-based).
857
+ if (options?.temperature !== undefined && !options?.thinkingEnabled) {
858
+ Object.defineProperty(params, "temperature", {
859
+ value: options.temperature,
860
+ writable: true,
861
+ enumerable: true,
862
+ configurable: true,
863
+ });
864
+ }
865
+ if (context.tools && context.tools.length > 0) {
866
+ params.tools = convertTools(context.tools, isOAuthToken, compat.supportsEagerToolInputStreaming, compat.supportsCacheControlOnTools ? cacheControl : undefined);
867
+ }
868
+ // Configure thinking mode: adaptive (Opus 4.6+ and Sonnet 4.6),
869
+ // budget-based (older models), or explicitly disabled.
870
+ if (model.reasoning) {
871
+ if (options?.thinkingEnabled) {
872
+ // Default to "summarized" so Opus 4.7 and Mythos Preview behave like
873
+ // older Claude 4 models (whose API default is also "summarized").
874
+ const display = options.thinkingDisplay ?? "summarized";
875
+ if (supportsAdaptiveThinking(model.id)) {
876
+ // Adaptive thinking: Claude decides when and how much to think.
877
+ params.thinking = { type: "adaptive", display };
878
+ if (options.effort) {
879
+ // The Anthropic SDK types can lag newly supported effort values such as "xhigh" and "max".
880
+ params.output_config = { effort: options.effort };
881
+ }
882
+ }
883
+ else {
884
+ // Budget-based thinking for older models
885
+ params.thinking = {
886
+ type: "enabled",
887
+ budget_tokens: options.thinkingBudgetTokens || 1024,
888
+ display,
889
+ };
890
+ }
891
+ }
892
+ else if (options?.thinkingEnabled === false && compat.supportsDisabledThinking) {
893
+ params.thinking = { type: "disabled" };
894
+ }
895
+ }
896
+ if (options?.metadata) {
897
+ const userId = options.metadata.user_id;
898
+ if (typeof userId === "string") {
899
+ params.metadata = { user_id: userId };
900
+ }
901
+ }
902
+ if (options?.toolChoice) {
903
+ if (typeof options.toolChoice === "string") {
904
+ params.tool_choice = { type: options.toolChoice };
905
+ }
906
+ else {
907
+ params.tool_choice = options.toolChoice;
908
+ }
909
+ }
910
+ applyExtraBodyToAnthropicParams(params, options?.extraBody);
911
+ return params;
912
+ }
913
+ function applyExtraBodyToAnthropicParams(params, extraBody) {
914
+ if (!extraBody)
915
+ return;
916
+ for (const [key, value] of Object.entries(extraBody)) {
917
+ if (ANTHROPIC_RESERVED_BODY_KEYS.has(key))
918
+ continue;
919
+ Object.defineProperty(params, key, { value, writable: true, enumerable: true, configurable: true });
920
+ }
921
+ }
922
+ // Normalize tool call IDs to match Anthropic's required pattern and length
923
+ function normalizeToolCallId(id) {
924
+ return id.replace(/[^a-zA-Z0-9_-]/g, "_").slice(0, 64);
925
+ }
926
+ function convertMessages(messages, model, isOAuthToken, cacheControl, preserveThinking = true) {
927
+ const params = [];
928
+ // Transform messages for cross-provider compatibility
929
+ const transformedMessages = transformMessages(messages, model, normalizeToolCallId, { preserveThinking });
930
+ for (let i = 0; i < transformedMessages.length; i++) {
931
+ const msg = transformedMessages[i];
932
+ if (msg.role === "user") {
933
+ if (typeof msg.content === "string") {
934
+ if (msg.content.trim().length > 0) {
935
+ params.push({
936
+ role: "user",
937
+ content: sanitizeSurrogates(msg.content),
938
+ });
939
+ }
940
+ }
941
+ else {
942
+ const blocks = msg.content.map((item) => {
943
+ if (item.type === "text") {
944
+ return {
945
+ type: "text",
946
+ text: sanitizeSurrogates(item.text),
947
+ };
948
+ }
949
+ else {
950
+ return {
951
+ type: "image",
952
+ source: {
953
+ type: "base64",
954
+ media_type: item.mimeType,
955
+ data: item.data,
956
+ },
957
+ };
958
+ }
959
+ });
960
+ const filteredBlocks = blocks.filter((b) => {
961
+ if (b.type === "text") {
962
+ return b.text.trim().length > 0;
963
+ }
964
+ return true;
965
+ });
966
+ if (filteredBlocks.length === 0)
967
+ continue;
968
+ params.push({
969
+ role: "user",
970
+ content: filteredBlocks,
971
+ });
972
+ }
973
+ }
974
+ else if (msg.role === "assistant") {
975
+ const blocks = [];
976
+ for (const block of msg.content) {
977
+ if (block.type === "text") {
978
+ if (block.text.trim().length === 0)
979
+ continue;
980
+ blocks.push({
981
+ type: "text",
982
+ text: sanitizeSurrogates(block.text),
983
+ });
984
+ }
985
+ else if (block.type === "thinking") {
986
+ // Redacted thinking: pass the opaque payload back as redacted_thinking
987
+ if (block.redacted) {
988
+ blocks.push({
989
+ type: "redacted_thinking",
990
+ data: block.thinkingSignature,
991
+ });
992
+ continue;
993
+ }
994
+ if (block.thinking.trim().length === 0)
995
+ continue;
996
+ // If thinking signature is missing/empty (e.g., from aborted stream),
997
+ // convert to plain text block without <thinking> tags to avoid API rejection
998
+ // and prevent Claude from mimicking the tags in responses
999
+ if (!block.thinkingSignature || block.thinkingSignature.trim().length === 0) {
1000
+ blocks.push({
1001
+ type: "text",
1002
+ text: sanitizeSurrogates(block.thinking),
1003
+ });
1004
+ }
1005
+ else {
1006
+ blocks.push({
1007
+ type: "thinking",
1008
+ thinking: block.thinking,
1009
+ signature: block.thinkingSignature,
1010
+ });
1011
+ }
1012
+ }
1013
+ else if (block.type === "toolCall") {
1014
+ blocks.push({
1015
+ type: "tool_use",
1016
+ id: block.id,
1017
+ name: isOAuthToken ? toClaudeCodeName(block.name) : block.name,
1018
+ input: block.arguments ?? {},
1019
+ });
1020
+ }
1021
+ else if (block.type === "providerNative") {
1022
+ }
1023
+ }
1024
+ if (blocks.length === 0)
1025
+ continue;
1026
+ params.push({
1027
+ role: "assistant",
1028
+ content: blocks,
1029
+ });
1030
+ }
1031
+ else if (msg.role === "toolResult") {
1032
+ // Collect all consecutive toolResult messages, needed for z.ai Anthropic endpoint
1033
+ const toolResults = [];
1034
+ // Add the current tool result
1035
+ toolResults.push({
1036
+ type: "tool_result",
1037
+ tool_use_id: msg.toolCallId,
1038
+ content: convertContentBlocks(msg.content),
1039
+ is_error: msg.isError,
1040
+ });
1041
+ // Look ahead for consecutive toolResult messages
1042
+ let j = i + 1;
1043
+ while (j < transformedMessages.length && transformedMessages[j].role === "toolResult") {
1044
+ const nextMsg = transformedMessages[j]; // We know it's a toolResult
1045
+ toolResults.push({
1046
+ type: "tool_result",
1047
+ tool_use_id: nextMsg.toolCallId,
1048
+ content: convertContentBlocks(nextMsg.content),
1049
+ is_error: nextMsg.isError,
1050
+ });
1051
+ j++;
1052
+ }
1053
+ // Skip the messages we've already processed
1054
+ i = j - 1;
1055
+ // Add a single user message with all tool results
1056
+ params.push({
1057
+ role: "user",
1058
+ content: toolResults,
1059
+ });
1060
+ }
1061
+ }
1062
+ // Add cache_control to the last user message to cache conversation history
1063
+ if (cacheControl && params.length > 0) {
1064
+ const lastMessage = params[params.length - 1];
1065
+ if (lastMessage.role === "user") {
1066
+ if (Array.isArray(lastMessage.content)) {
1067
+ const lastBlock = lastMessage.content[lastMessage.content.length - 1];
1068
+ if (isCacheableUserContentBlock(lastBlock)) {
1069
+ lastBlock.cache_control = cacheControl;
1070
+ }
1071
+ }
1072
+ else if (typeof lastMessage.content === "string") {
1073
+ lastMessage.content = [
1074
+ {
1075
+ type: "text",
1076
+ text: lastMessage.content,
1077
+ cache_control: cacheControl,
1078
+ },
1079
+ ];
1080
+ }
1081
+ }
1082
+ }
1083
+ return params;
1084
+ }
1085
+ function shouldUseFineGrainedToolStreamingBeta(model, context) {
1086
+ return !!context.tools?.length && !getAnthropicCompat(model).supportsEagerToolInputStreaming;
1087
+ }
1088
+ function convertTools(tools, isOAuthToken, supportsEagerToolInputStreaming, cacheControl) {
1089
+ if (!tools)
1090
+ return [];
1091
+ return tools.map((tool, index) => {
1092
+ const schema = tool.parameters;
1093
+ return {
1094
+ name: isOAuthToken ? toClaudeCodeName(tool.name) : tool.name,
1095
+ description: tool.description,
1096
+ ...(supportsEagerToolInputStreaming ? { eager_input_streaming: true } : {}),
1097
+ input_schema: {
1098
+ type: "object",
1099
+ properties: schema.properties ?? {},
1100
+ required: schema.required ?? [],
1101
+ },
1102
+ ...(cacheControl && index === tools.length - 1 ? { cache_control: cacheControl } : {}),
1103
+ };
1104
+ });
1105
+ }
1106
+ function mapStopReason(reason) {
1107
+ switch (reason) {
1108
+ case "end_turn":
1109
+ return "stop";
1110
+ case "max_tokens":
1111
+ return "length";
1112
+ case "tool_use":
1113
+ return "toolUse";
1114
+ case "refusal":
1115
+ return "error";
1116
+ case "pause_turn": // Stop is good enough -> resubmit
1117
+ return "stop";
1118
+ case "stop_sequence":
1119
+ return "stop"; // We don't supply stop sequences, so this should never happen
1120
+ case "sensitive": // Content flagged by safety filters (not yet in SDK types)
1121
+ return "error";
1122
+ default:
1123
+ // Handle unknown stop reasons gracefully (API may add new values)
1124
+ throw new Error(`Unhandled stop reason: ${reason}`);
1125
+ }
1126
+ }
1127
+ //# sourceMappingURL=anthropic.js.map