@harrylabsj/kiwi-merchant-cloud 0.12.4 → 0.12.5

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 (1225) hide show
  1. package/app/a2a/node.d.ts +5 -1
  2. package/app/a2a/node.js +68 -30
  3. package/app/a2a/node.js.map +1 -1
  4. package/app/a2a/server/merchant-handler.d.ts +4 -0
  5. package/app/a2a/server/merchant-handler.js +123 -45
  6. package/app/a2a/server/merchant-handler.js.map +1 -1
  7. package/app/a2a/server/merchant-product-facts.d.ts +32 -0
  8. package/app/a2a/server/merchant-product-facts.js +57 -0
  9. package/app/a2a/server/merchant-product-facts.js.map +1 -0
  10. package/app/agent/buyer/buyer-tools.js +285 -3
  11. package/app/agent/buyer/buyer-tools.js.map +1 -1
  12. package/app/agent/merchant/types.d.ts +4 -9
  13. package/app/agent/merchant/types.js +14 -0
  14. package/app/agent/merchant/types.js.map +1 -1
  15. package/app/buyer-core/a2a-knp.d.ts +1 -0
  16. package/app/buyer-core/a2a-knp.js +1 -1
  17. package/app/buyer-core/a2a-knp.js.map +1 -1
  18. package/app/buyer-core/a2a-negotiator.d.ts +2 -0
  19. package/app/buyer-core/a2a-negotiator.js +20 -19
  20. package/app/buyer-core/a2a-negotiator.js.map +1 -1
  21. package/app/buyer-core/a2a-quote-fetcher.d.ts +2 -0
  22. package/app/buyer-core/a2a-quote-fetcher.js +13 -5
  23. package/app/buyer-core/a2a-quote-fetcher.js.map +1 -1
  24. package/app/buyer-core/product-summary.d.ts +4 -0
  25. package/app/buyer-core/product-summary.js +6 -0
  26. package/app/buyer-core/product-summary.js.map +1 -1
  27. package/app/buyer-core/protocol-recovery.d.ts +12 -1
  28. package/app/buyer-core/protocol-recovery.js +59 -19
  29. package/app/buyer-core/protocol-recovery.js.map +1 -1
  30. package/app/buyer-core/receive-gate.d.ts +11 -0
  31. package/app/buyer-core/receive-gate.js +107 -0
  32. package/app/buyer-core/receive-gate.js.map +1 -0
  33. package/app/cloud/bootstrap.d.ts +4 -0
  34. package/app/cloud/bootstrap.js +69 -55
  35. package/app/cloud/bootstrap.js.map +1 -1
  36. package/app/cloud/file-listing-publication.js +6 -0
  37. package/app/cloud/file-listing-publication.js.map +1 -1
  38. package/app/cloud/main.d.ts +3 -0
  39. package/app/cloud/main.js +47 -11
  40. package/app/cloud/main.js.map +1 -1
  41. package/app/cloud/product-import-tabular.d.ts +1 -1
  42. package/app/cloud/product-import-tabular.js +263 -36
  43. package/app/cloud/product-import-tabular.js.map +1 -1
  44. package/app/cloud/product-source.d.ts +6 -1
  45. package/app/cloud/product-source.js +47 -15
  46. package/app/cloud/product-source.js.map +1 -1
  47. package/app/cloud-sample/products.json +3 -3
  48. package/app/commerce/data-source.d.ts +4 -0
  49. package/app/commerce/data-source.js.map +1 -1
  50. package/app/commerce/shopping-cli-source.js +4 -0
  51. package/app/commerce/shopping-cli-source.js.map +1 -1
  52. package/app/discovery/catalog-source/kiwi-source.d.ts +2 -0
  53. package/app/discovery/catalog-source/kiwi-source.js +4 -0
  54. package/app/discovery/catalog-source/kiwi-source.js.map +1 -1
  55. package/app/handoff/index.d.ts +2 -1
  56. package/app/handoff/index.js +1 -0
  57. package/app/handoff/index.js.map +1 -1
  58. package/app/handoff/launch-marketplace-policy.d.ts +149 -0
  59. package/app/handoff/launch-marketplace-policy.js +301 -0
  60. package/app/handoff/launch-marketplace-policy.js.map +1 -0
  61. package/app/handoff/marketplace-product-link.d.ts +18 -0
  62. package/app/handoff/marketplace-product-link.js +71 -0
  63. package/app/handoff/marketplace-product-link.js.map +1 -0
  64. package/app/handoff/transaction.d.ts +30 -0
  65. package/app/handoff/transaction.js +64 -0
  66. package/app/handoff/transaction.js.map +1 -1
  67. package/app/handoff/url-safety.d.ts +3 -0
  68. package/app/handoff/url-safety.js +4 -0
  69. package/app/handoff/url-safety.js.map +1 -1
  70. package/app/http/merchant-management/page.js +176 -45
  71. package/app/http/merchant-management/page.js.map +1 -1
  72. package/app/i18n.d.ts +1 -0
  73. package/app/i18n.js +3 -0
  74. package/app/i18n.js.map +1 -1
  75. package/app/lifecycle/close.d.ts +24 -0
  76. package/app/lifecycle/close.js +131 -0
  77. package/app/lifecycle/close.js.map +1 -0
  78. package/app/mcp/merchant-runtime-assembly.js +6 -4
  79. package/app/mcp/merchant-runtime-assembly.js.map +1 -1
  80. package/app/mcp/tools.js +17 -16
  81. package/app/mcp/tools.js.map +1 -1
  82. package/app/merchant/application/service.d.ts +4 -0
  83. package/app/merchant/application/service.js.map +1 -1
  84. package/app/merchant/stats-store.d.ts +3 -0
  85. package/app/merchant/stats-store.js +15 -1
  86. package/app/merchant/stats-store.js.map +1 -1
  87. package/app/merchant-core/rfq/data-source-adapter.d.ts +2 -10
  88. package/app/merchant-core/rfq/data-source-adapter.js +21 -9
  89. package/app/merchant-core/rfq/data-source-adapter.js.map +1 -1
  90. package/app/merchant-gateway/pinned-fetch.js +5 -2
  91. package/app/merchant-gateway/pinned-fetch.js.map +1 -1
  92. package/build-manifest.json +2901 -1966
  93. package/node_modules/@earendil-works/chord/CHANGELOG.md +20 -0
  94. package/node_modules/@earendil-works/chord/README.md +77 -194
  95. package/node_modules/@earendil-works/chord/dist/cell.d.ts +101 -0
  96. package/node_modules/@earendil-works/chord/dist/cell.d.ts.map +1 -0
  97. package/node_modules/@earendil-works/chord/dist/cell.js +316 -0
  98. package/node_modules/@earendil-works/chord/dist/cell.js.map +1 -0
  99. package/node_modules/@earendil-works/chord/dist/cluster.d.ts +26 -0
  100. package/node_modules/@earendil-works/chord/dist/cluster.d.ts.map +1 -0
  101. package/node_modules/@earendil-works/chord/dist/cluster.js +214 -0
  102. package/node_modules/@earendil-works/chord/dist/cluster.js.map +1 -0
  103. package/node_modules/@earendil-works/chord/dist/connection.d.ts +157 -0
  104. package/node_modules/@earendil-works/chord/dist/connection.d.ts.map +1 -0
  105. package/node_modules/@earendil-works/chord/dist/connection.js +757 -0
  106. package/node_modules/@earendil-works/chord/dist/connection.js.map +1 -0
  107. package/node_modules/@earendil-works/chord/dist/context/index.d.ts +12 -1
  108. package/node_modules/@earendil-works/chord/dist/context/index.d.ts.map +1 -1
  109. package/node_modules/@earendil-works/chord/dist/context/index.js.map +1 -1
  110. package/node_modules/@earendil-works/chord/dist/contract.d.ts +133 -0
  111. package/node_modules/@earendil-works/chord/dist/contract.d.ts.map +1 -0
  112. package/node_modules/@earendil-works/chord/dist/contract.js +157 -0
  113. package/node_modules/@earendil-works/chord/dist/contract.js.map +1 -0
  114. package/node_modules/@earendil-works/chord/dist/declare.d.ts +70 -0
  115. package/node_modules/@earendil-works/chord/dist/declare.d.ts.map +1 -0
  116. package/node_modules/@earendil-works/chord/dist/declare.js +22 -0
  117. package/node_modules/@earendil-works/chord/dist/declare.js.map +1 -0
  118. package/node_modules/@earendil-works/chord/dist/delta/apply-immutable-trusted.js.map +1 -1
  119. package/node_modules/@earendil-works/chord/dist/delta/diff.d.ts +1 -1
  120. package/node_modules/@earendil-works/chord/dist/delta/diff.d.ts.map +1 -1
  121. package/node_modules/@earendil-works/chord/dist/delta/diff.js.map +1 -1
  122. package/node_modules/@earendil-works/chord/dist/delta/index.d.ts +2 -2
  123. package/node_modules/@earendil-works/chord/dist/delta/index.d.ts.map +1 -1
  124. package/node_modules/@earendil-works/chord/dist/delta/index.js +41 -0
  125. package/node_modules/@earendil-works/chord/dist/delta/index.js.map +1 -1
  126. package/node_modules/@earendil-works/chord/dist/delta/revision-validator.d.ts +1 -1
  127. package/node_modules/@earendil-works/chord/dist/delta/revision-validator.d.ts.map +1 -1
  128. package/node_modules/@earendil-works/chord/dist/delta/revision-validator.js.map +1 -1
  129. package/node_modules/@earendil-works/chord/dist/delta/tracker.d.ts +1 -1
  130. package/node_modules/@earendil-works/chord/dist/delta/tracker.d.ts.map +1 -1
  131. package/node_modules/@earendil-works/chord/dist/delta/tracker.js +40 -4
  132. package/node_modules/@earendil-works/chord/dist/delta/tracker.js.map +1 -1
  133. package/node_modules/@earendil-works/chord/dist/errors.d.ts +27 -0
  134. package/node_modules/@earendil-works/chord/dist/errors.d.ts.map +1 -0
  135. package/node_modules/@earendil-works/chord/dist/errors.js +44 -0
  136. package/node_modules/@earendil-works/chord/dist/errors.js.map +1 -0
  137. package/node_modules/@earendil-works/chord/dist/host.d.ts +254 -0
  138. package/node_modules/@earendil-works/chord/dist/host.d.ts.map +1 -0
  139. package/node_modules/@earendil-works/chord/dist/host.js +795 -0
  140. package/node_modules/@earendil-works/chord/dist/host.js.map +1 -0
  141. package/node_modules/@earendil-works/chord/dist/index.d.ts +17 -10
  142. package/node_modules/@earendil-works/chord/dist/index.d.ts.map +1 -1
  143. package/node_modules/@earendil-works/chord/dist/index.js +8 -8
  144. package/node_modules/@earendil-works/chord/dist/index.js.map +1 -1
  145. package/node_modules/@earendil-works/chord/dist/json.d.ts +9 -1
  146. package/node_modules/@earendil-works/chord/dist/json.d.ts.map +1 -1
  147. package/node_modules/@earendil-works/chord/dist/json.js.map +1 -1
  148. package/node_modules/@earendil-works/chord/dist/link.d.ts +72 -0
  149. package/node_modules/@earendil-works/chord/dist/link.d.ts.map +1 -0
  150. package/node_modules/@earendil-works/chord/dist/link.js +169 -0
  151. package/node_modules/@earendil-works/chord/dist/link.js.map +1 -0
  152. package/node_modules/@earendil-works/chord/dist/loader.d.ts +4 -0
  153. package/node_modules/@earendil-works/chord/dist/loader.d.ts.map +1 -0
  154. package/node_modules/@earendil-works/chord/dist/loader.js +68 -0
  155. package/node_modules/@earendil-works/chord/dist/loader.js.map +1 -0
  156. package/node_modules/@earendil-works/chord/dist/manager.d.ts +115 -0
  157. package/node_modules/@earendil-works/chord/dist/manager.d.ts.map +1 -0
  158. package/node_modules/@earendil-works/chord/dist/manager.js +319 -0
  159. package/node_modules/@earendil-works/chord/dist/manager.js.map +1 -0
  160. package/node_modules/@earendil-works/chord/dist/node.d.ts +3 -4
  161. package/node_modules/@earendil-works/chord/dist/node.d.ts.map +1 -1
  162. package/node_modules/@earendil-works/chord/dist/node.js +3 -2
  163. package/node_modules/@earendil-works/chord/dist/node.js.map +1 -1
  164. package/node_modules/@earendil-works/chord/dist/publish.d.ts +5 -0
  165. package/node_modules/@earendil-works/chord/dist/publish.d.ts.map +1 -0
  166. package/node_modules/@earendil-works/chord/dist/publish.js +40 -0
  167. package/node_modules/@earendil-works/chord/dist/publish.js.map +1 -0
  168. package/node_modules/@earendil-works/chord/dist/record.d.ts +320 -0
  169. package/node_modules/@earendil-works/chord/dist/record.d.ts.map +1 -0
  170. package/node_modules/@earendil-works/chord/dist/record.js +1292 -0
  171. package/node_modules/@earendil-works/chord/dist/record.js.map +1 -0
  172. package/node_modules/@earendil-works/chord/dist/registry.d.ts +25 -0
  173. package/node_modules/@earendil-works/chord/dist/registry.d.ts.map +1 -0
  174. package/node_modules/@earendil-works/chord/dist/registry.js +6 -0
  175. package/node_modules/@earendil-works/chord/dist/registry.js.map +1 -0
  176. package/node_modules/@earendil-works/chord/dist/reload.d.ts +118 -0
  177. package/node_modules/@earendil-works/chord/dist/reload.d.ts.map +1 -0
  178. package/node_modules/@earendil-works/chord/dist/reload.js +589 -0
  179. package/node_modules/@earendil-works/chord/dist/reload.js.map +1 -0
  180. package/node_modules/@earendil-works/chord/dist/remote.d.ts +70 -0
  181. package/node_modules/@earendil-works/chord/dist/remote.d.ts.map +1 -0
  182. package/node_modules/@earendil-works/chord/dist/remote.js +308 -0
  183. package/node_modules/@earendil-works/chord/dist/remote.js.map +1 -0
  184. package/node_modules/@earendil-works/chord/dist/schema.d.ts +21 -0
  185. package/node_modules/@earendil-works/chord/dist/schema.d.ts.map +1 -0
  186. package/node_modules/@earendil-works/chord/dist/schema.js +228 -0
  187. package/node_modules/@earendil-works/chord/dist/schema.js.map +1 -0
  188. package/node_modules/@earendil-works/chord/dist/state.d.ts +92 -0
  189. package/node_modules/@earendil-works/chord/dist/state.d.ts.map +1 -0
  190. package/node_modules/@earendil-works/chord/dist/{services/state.js → state.js} +28 -138
  191. package/node_modules/@earendil-works/chord/dist/state.js.map +1 -0
  192. package/node_modules/@earendil-works/chord/dist/types.d.ts +62 -262
  193. package/node_modules/@earendil-works/chord/dist/types.d.ts.map +1 -1
  194. package/node_modules/@earendil-works/chord/dist/types.js.map +1 -1
  195. package/node_modules/@earendil-works/chord/dist/websocket.d.ts +16 -0
  196. package/node_modules/@earendil-works/chord/dist/websocket.d.ts.map +1 -0
  197. package/node_modules/@earendil-works/chord/dist/websocket.js +15 -0
  198. package/node_modules/@earendil-works/chord/dist/websocket.js.map +1 -0
  199. package/node_modules/@earendil-works/chord/dist/wire.d.ts +135 -0
  200. package/node_modules/@earendil-works/chord/dist/wire.d.ts.map +1 -0
  201. package/node_modules/@earendil-works/chord/dist/wire.js +112 -0
  202. package/node_modules/@earendil-works/chord/dist/wire.js.map +1 -0
  203. package/node_modules/@earendil-works/chord/docs/guide.md +750 -0
  204. package/node_modules/@earendil-works/chord/docs/spec.md +261 -0
  205. package/node_modules/@earendil-works/chord/docs/tutorial.md +909 -0
  206. package/node_modules/@earendil-works/chord/package.json +10 -11
  207. package/node_modules/@earendil-works/chord/src/delta/README.md +5 -3
  208. package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.d.ts.map +1 -1
  209. package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.js +9 -1
  210. package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.js.map +1 -1
  211. package/node_modules/@earendil-works/pi-agent-core/dist/proxy.d.ts +2 -5
  212. package/node_modules/@earendil-works/pi-agent-core/dist/proxy.d.ts.map +1 -1
  213. package/node_modules/@earendil-works/pi-agent-core/dist/proxy.js +2 -14
  214. package/node_modules/@earendil-works/pi-agent-core/dist/proxy.js.map +1 -1
  215. package/node_modules/@earendil-works/pi-agent-core/dist/types.d.ts +4 -0
  216. package/node_modules/@earendil-works/pi-agent-core/dist/types.d.ts.map +1 -1
  217. package/node_modules/@earendil-works/pi-agent-core/dist/types.js.map +1 -1
  218. package/node_modules/@earendil-works/pi-agent-core/package.json +2 -2
  219. package/node_modules/@earendil-works/pi-ai/README.md +14 -3
  220. package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.d.ts.map +1 -1
  221. package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js +63 -22
  222. package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js.map +1 -1
  223. package/node_modules/@earendil-works/pi-ai/dist/api/azure-openai-config.d.ts +15 -0
  224. package/node_modules/@earendil-works/pi-ai/dist/api/azure-openai-config.d.ts.map +1 -0
  225. package/node_modules/@earendil-works/pi-ai/dist/api/azure-openai-config.js +76 -0
  226. package/node_modules/@earendil-works/pi-ai/dist/api/azure-openai-config.js.map +1 -0
  227. package/node_modules/@earendil-works/pi-ai/dist/api/azure-openai-responses.d.ts +3 -6
  228. package/node_modules/@earendil-works/pi-ai/dist/api/azure-openai-responses.d.ts.map +1 -1
  229. package/node_modules/@earendil-works/pi-ai/dist/api/azure-openai-responses.js +2 -74
  230. package/node_modules/@earendil-works/pi-ai/dist/api/azure-openai-responses.js.map +1 -1
  231. package/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.js +33 -2
  232. package/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.js.map +1 -1
  233. package/node_modules/@earendil-works/pi-ai/dist/api/classifier-shared.d.ts +21 -0
  234. package/node_modules/@earendil-works/pi-ai/dist/api/classifier-shared.d.ts.map +1 -0
  235. package/node_modules/@earendil-works/pi-ai/dist/api/classifier-shared.js +98 -0
  236. package/node_modules/@earendil-works/pi-ai/dist/api/classifier-shared.js.map +1 -0
  237. package/node_modules/@earendil-works/pi-ai/dist/api/cloudflare-workers-ai-system-one.d.ts.map +1 -1
  238. package/node_modules/@earendil-works/pi-ai/dist/api/cloudflare-workers-ai-system-one.js +2 -1
  239. package/node_modules/@earendil-works/pi-ai/dist/api/cloudflare-workers-ai-system-one.js.map +1 -1
  240. package/node_modules/@earendil-works/pi-ai/dist/api/lazy.d.ts.map +1 -1
  241. package/node_modules/@earendil-works/pi-ai/dist/api/lazy.js +4 -3
  242. package/node_modules/@earendil-works/pi-ai/dist/api/lazy.js.map +1 -1
  243. package/node_modules/@earendil-works/pi-ai/dist/api/llama-cpp-classify.d.ts.map +1 -1
  244. package/node_modules/@earendil-works/pi-ai/dist/api/llama-cpp-classify.js +2 -0
  245. package/node_modules/@earendil-works/pi-ai/dist/api/llama-cpp-classify.js.map +1 -1
  246. package/node_modules/@earendil-works/pi-ai/dist/api/mistral-conversations.d.ts.map +1 -1
  247. package/node_modules/@earendil-works/pi-ai/dist/api/mistral-conversations.js +31 -14
  248. package/node_modules/@earendil-works/pi-ai/dist/api/mistral-conversations.js.map +1 -1
  249. package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.d.ts.map +1 -1
  250. package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.js +7 -4
  251. package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.js.map +1 -1
  252. package/node_modules/@earendil-works/pi-ai/dist/api/openai-decisions.d.ts +4 -0
  253. package/node_modules/@earendil-works/pi-ai/dist/api/openai-decisions.d.ts.map +1 -0
  254. package/node_modules/@earendil-works/pi-ai/dist/api/openai-decisions.js +162 -0
  255. package/node_modules/@earendil-works/pi-ai/dist/api/openai-decisions.js.map +1 -0
  256. package/node_modules/@earendil-works/pi-ai/dist/api/openai-decisions.lazy.d.ts +3 -0
  257. package/node_modules/@earendil-works/pi-ai/dist/api/openai-decisions.lazy.d.ts.map +1 -0
  258. package/node_modules/@earendil-works/pi-ai/dist/api/openai-decisions.lazy.js +4 -0
  259. package/node_modules/@earendil-works/pi-ai/dist/api/openai-decisions.lazy.js.map +1 -0
  260. package/node_modules/@earendil-works/pi-ai/dist/api/system-one-shared.d.ts +0 -1
  261. package/node_modules/@earendil-works/pi-ai/dist/api/system-one-shared.d.ts.map +1 -1
  262. package/node_modules/@earendil-works/pi-ai/dist/api/system-one-shared.js +5 -89
  263. package/node_modules/@earendil-works/pi-ai/dist/api/system-one-shared.js.map +1 -1
  264. package/node_modules/@earendil-works/pi-ai/dist/api/typesafe-system-one.d.ts.map +1 -1
  265. package/node_modules/@earendil-works/pi-ai/dist/api/typesafe-system-one.js +2 -1
  266. package/node_modules/@earendil-works/pi-ai/dist/api/typesafe-system-one.js.map +1 -1
  267. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/anthropic.d.ts.map +1 -1
  268. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/anthropic.js +14 -6
  269. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/anthropic.js.map +1 -1
  270. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/openai-chatgpt.js +1 -1
  271. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/openai-chatgpt.js.map +1 -1
  272. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/openai-codex.d.ts.map +1 -1
  273. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/openai-codex.js +4 -4
  274. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/openai-codex.js.map +1 -1
  275. package/node_modules/@earendil-works/pi-ai/dist/auth/resolve.d.ts +16 -1
  276. package/node_modules/@earendil-works/pi-ai/dist/auth/resolve.d.ts.map +1 -1
  277. package/node_modules/@earendil-works/pi-ai/dist/auth/resolve.js +51 -27
  278. package/node_modules/@earendil-works/pi-ai/dist/auth/resolve.js.map +1 -1
  279. package/node_modules/@earendil-works/pi-ai/dist/auth/types.d.ts +5 -0
  280. package/node_modules/@earendil-works/pi-ai/dist/auth/types.d.ts.map +1 -1
  281. package/node_modules/@earendil-works/pi-ai/dist/auth/types.js.map +1 -1
  282. package/node_modules/@earendil-works/pi-ai/dist/env-api-keys.js +1 -1
  283. package/node_modules/@earendil-works/pi-ai/dist/env-api-keys.js.map +1 -1
  284. package/node_modules/@earendil-works/pi-ai/dist/models.d.ts +5 -0
  285. package/node_modules/@earendil-works/pi-ai/dist/models.d.ts.map +1 -1
  286. package/node_modules/@earendil-works/pi-ai/dist/models.generated.d.ts +4 -4
  287. package/node_modules/@earendil-works/pi-ai/dist/models.generated.d.ts.map +1 -1
  288. package/node_modules/@earendil-works/pi-ai/dist/models.generated.js +4 -4
  289. package/node_modules/@earendil-works/pi-ai/dist/models.generated.js.map +1 -1
  290. package/node_modules/@earendil-works/pi-ai/dist/models.js +7 -8
  291. package/node_modules/@earendil-works/pi-ai/dist/models.js.map +1 -1
  292. package/node_modules/@earendil-works/pi-ai/dist/providers/all.js +2 -2
  293. package/node_modules/@earendil-works/pi-ai/dist/providers/all.js.map +1 -1
  294. package/node_modules/@earendil-works/pi-ai/dist/providers/azure.d.ts +3 -0
  295. package/node_modules/@earendil-works/pi-ai/dist/providers/azure.d.ts.map +1 -0
  296. package/node_modules/@earendil-works/pi-ai/dist/providers/azure.js +46 -0
  297. package/node_modules/@earendil-works/pi-ai/dist/providers/azure.js.map +1 -0
  298. package/node_modules/@earendil-works/pi-ai/dist/providers/azure.models.d.ts +6 -0
  299. package/node_modules/@earendil-works/pi-ai/dist/providers/azure.models.d.ts.map +1 -0
  300. package/node_modules/@earendil-works/pi-ai/dist/providers/azure.models.js +8 -0
  301. package/node_modules/@earendil-works/pi-ai/dist/providers/azure.models.js.map +1 -0
  302. package/node_modules/@earendil-works/pi-ai/dist/providers/compat-schema.d.ts +338 -0
  303. package/node_modules/@earendil-works/pi-ai/dist/providers/compat-schema.d.ts.map +1 -0
  304. package/node_modules/@earendil-works/pi-ai/dist/providers/compat-schema.js +375 -0
  305. package/node_modules/@earendil-works/pi-ai/dist/providers/compat-schema.js.map +1 -0
  306. package/node_modules/@earendil-works/pi-ai/dist/providers/data/.manifest.json +1 -1
  307. package/node_modules/@earendil-works/pi-ai/dist/providers/data/amazon-bedrock.json +1 -1
  308. package/node_modules/@earendil-works/pi-ai/dist/providers/data/anthropic.json +1 -1
  309. package/node_modules/@earendil-works/pi-ai/dist/providers/data/azure.json +1 -0
  310. package/node_modules/@earendil-works/pi-ai/dist/providers/data/baseten.json +1 -1
  311. package/node_modules/@earendil-works/pi-ai/dist/providers/data/cloudflare-ai-gateway.json +1 -1
  312. package/node_modules/@earendil-works/pi-ai/dist/providers/data/cloudflare-workers-ai.json +1 -1
  313. package/node_modules/@earendil-works/pi-ai/dist/providers/data/github-copilot.json +1 -1
  314. package/node_modules/@earendil-works/pi-ai/dist/providers/data/google-vertex.json +1 -1
  315. package/node_modules/@earendil-works/pi-ai/dist/providers/data/google.json +1 -1
  316. package/node_modules/@earendil-works/pi-ai/dist/providers/data/huggingface.json +1 -1
  317. package/node_modules/@earendil-works/pi-ai/dist/providers/data/meta.json +1 -1
  318. package/node_modules/@earendil-works/pi-ai/dist/providers/data/minimax-cn.json +1 -1
  319. package/node_modules/@earendil-works/pi-ai/dist/providers/data/minimax.json +1 -1
  320. package/node_modules/@earendil-works/pi-ai/dist/providers/data/mistral.json +1 -1
  321. package/node_modules/@earendil-works/pi-ai/dist/providers/data/openai.json +1 -1
  322. package/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode-go.json +1 -1
  323. package/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode.json +1 -1
  324. package/node_modules/@earendil-works/pi-ai/dist/providers/data/openrouter.json +1 -1
  325. package/node_modules/@earendil-works/pi-ai/dist/providers/data/radius.json +1 -1
  326. package/node_modules/@earendil-works/pi-ai/dist/providers/data/vercel-ai-gateway.json +1 -1
  327. package/node_modules/@earendil-works/pi-ai/dist/providers/faux.d.ts.map +1 -1
  328. package/node_modules/@earendil-works/pi-ai/dist/providers/faux.js +25 -8
  329. package/node_modules/@earendil-works/pi-ai/dist/providers/faux.js.map +1 -1
  330. package/node_modules/@earendil-works/pi-ai/dist/providers/model-schema.d.ts +91 -0
  331. package/node_modules/@earendil-works/pi-ai/dist/providers/model-schema.d.ts.map +1 -0
  332. package/node_modules/@earendil-works/pi-ai/dist/providers/model-schema.js +55 -0
  333. package/node_modules/@earendil-works/pi-ai/dist/providers/model-schema.js.map +1 -0
  334. package/node_modules/@earendil-works/pi-ai/dist/providers/openai.d.ts.map +1 -1
  335. package/node_modules/@earendil-works/pi-ai/dist/providers/openai.js +12 -3
  336. package/node_modules/@earendil-works/pi-ai/dist/providers/openai.js.map +1 -1
  337. package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter-api.d.ts +40 -0
  338. package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter-api.d.ts.map +1 -0
  339. package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter-api.js +41 -0
  340. package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter-api.js.map +1 -0
  341. package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.d.ts +11 -1
  342. package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.d.ts.map +1 -1
  343. package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.js +52 -1
  344. package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.js.map +1 -1
  345. package/node_modules/@earendil-works/pi-ai/dist/providers/radius.d.ts.map +1 -1
  346. package/node_modules/@earendil-works/pi-ai/dist/providers/radius.js +4 -12
  347. package/node_modules/@earendil-works/pi-ai/dist/providers/radius.js.map +1 -1
  348. package/node_modules/@earendil-works/pi-ai/dist/types.d.ts +22 -305
  349. package/node_modules/@earendil-works/pi-ai/dist/types.d.ts.map +1 -1
  350. package/node_modules/@earendil-works/pi-ai/dist/types.js.map +1 -1
  351. package/node_modules/@earendil-works/pi-ai/dist/utils/estimate.js +1 -1
  352. package/node_modules/@earendil-works/pi-ai/dist/utils/estimate.js.map +1 -1
  353. package/node_modules/@earendil-works/pi-ai/dist/utils/event-stream.d.ts +10 -1
  354. package/node_modules/@earendil-works/pi-ai/dist/utils/event-stream.d.ts.map +1 -1
  355. package/node_modules/@earendil-works/pi-ai/dist/utils/event-stream.js +25 -0
  356. package/node_modules/@earendil-works/pi-ai/dist/utils/event-stream.js.map +1 -1
  357. package/node_modules/@earendil-works/pi-ai/dist/utils/model-operations.d.ts +3 -1
  358. package/node_modules/@earendil-works/pi-ai/dist/utils/model-operations.d.ts.map +1 -1
  359. package/node_modules/@earendil-works/pi-ai/dist/utils/model-operations.js +6 -0
  360. package/node_modules/@earendil-works/pi-ai/dist/utils/model-operations.js.map +1 -1
  361. package/node_modules/@earendil-works/pi-ai/dist/utils/provider-retry.d.ts +2 -0
  362. package/node_modules/@earendil-works/pi-ai/dist/utils/provider-retry.d.ts.map +1 -1
  363. package/node_modules/@earendil-works/pi-ai/dist/utils/provider-retry.js +2 -0
  364. package/node_modules/@earendil-works/pi-ai/dist/utils/provider-retry.js.map +1 -1
  365. package/node_modules/@earendil-works/pi-ai/dist/utils/retry.d.ts.map +1 -1
  366. package/node_modules/@earendil-works/pi-ai/dist/utils/retry.js +8 -2
  367. package/node_modules/@earendil-works/pi-ai/dist/utils/retry.js.map +1 -1
  368. package/node_modules/@earendil-works/pi-ai/package.json +2 -2
  369. package/node_modules/@earendil-works/pi-codemode/README.md +177 -11
  370. package/node_modules/@earendil-works/pi-codemode/dist/cloudflare.d.ts +53 -0
  371. package/node_modules/@earendil-works/pi-codemode/dist/cloudflare.d.ts.map +1 -0
  372. package/node_modules/@earendil-works/pi-codemode/dist/cloudflare.js +64 -0
  373. package/node_modules/@earendil-works/pi-codemode/dist/cloudflare.js.map +1 -0
  374. package/node_modules/@earendil-works/pi-codemode/dist/declarations.d.ts +6 -21
  375. package/node_modules/@earendil-works/pi-codemode/dist/declarations.d.ts.map +1 -1
  376. package/node_modules/@earendil-works/pi-codemode/dist/declarations.js +113 -127
  377. package/node_modules/@earendil-works/pi-codemode/dist/declarations.js.map +1 -1
  378. package/node_modules/@earendil-works/pi-codemode/dist/index.d.ts +5 -2
  379. package/node_modules/@earendil-works/pi-codemode/dist/index.d.ts.map +1 -1
  380. package/node_modules/@earendil-works/pi-codemode/dist/index.js +4 -1
  381. package/node_modules/@earendil-works/pi-codemode/dist/index.js.map +1 -1
  382. package/node_modules/@earendil-works/pi-codemode/dist/portable.d.ts +15 -0
  383. package/node_modules/@earendil-works/pi-codemode/dist/portable.d.ts.map +1 -0
  384. package/node_modules/@earendil-works/pi-codemode/dist/portable.js +12 -0
  385. package/node_modules/@earendil-works/pi-codemode/dist/portable.js.map +1 -0
  386. package/node_modules/@earendil-works/pi-codemode/dist/runtime/execution.d.ts +66 -0
  387. package/node_modules/@earendil-works/pi-codemode/dist/runtime/execution.d.ts.map +1 -0
  388. package/node_modules/@earendil-works/pi-codemode/dist/runtime/execution.js +494 -0
  389. package/node_modules/@earendil-works/pi-codemode/dist/runtime/execution.js.map +1 -0
  390. package/node_modules/@earendil-works/pi-codemode/dist/runtime/host.d.ts +8 -30
  391. package/node_modules/@earendil-works/pi-codemode/dist/runtime/host.d.ts.map +1 -1
  392. package/node_modules/@earendil-works/pi-codemode/dist/runtime/host.js +41 -283
  393. package/node_modules/@earendil-works/pi-codemode/dist/runtime/host.js.map +1 -1
  394. package/node_modules/@earendil-works/pi-codemode/dist/runtime/inline.d.ts +63 -0
  395. package/node_modules/@earendil-works/pi-codemode/dist/runtime/inline.d.ts.map +1 -0
  396. package/node_modules/@earendil-works/pi-codemode/dist/runtime/inline.js +80 -0
  397. package/node_modules/@earendil-works/pi-codemode/dist/runtime/inline.js.map +1 -0
  398. package/node_modules/@earendil-works/pi-codemode/dist/runtime/prelude-source.d.ts +9 -3
  399. package/node_modules/@earendil-works/pi-codemode/dist/runtime/prelude-source.d.ts.map +1 -1
  400. package/node_modules/@earendil-works/pi-codemode/dist/runtime/prelude-source.js +122 -12
  401. package/node_modules/@earendil-works/pi-codemode/dist/runtime/prelude-source.js.map +1 -1
  402. package/node_modules/@earendil-works/pi-codemode/dist/runtime/protocol.d.ts +47 -6
  403. package/node_modules/@earendil-works/pi-codemode/dist/runtime/protocol.d.ts.map +1 -1
  404. package/node_modules/@earendil-works/pi-codemode/dist/runtime/protocol.js +6 -1
  405. package/node_modules/@earendil-works/pi-codemode/dist/runtime/protocol.js.map +1 -1
  406. package/node_modules/@earendil-works/pi-codemode/dist/runtime/remote.d.ts +102 -0
  407. package/node_modules/@earendil-works/pi-codemode/dist/runtime/remote.d.ts.map +1 -0
  408. package/node_modules/@earendil-works/pi-codemode/dist/runtime/remote.js +175 -0
  409. package/node_modules/@earendil-works/pi-codemode/dist/runtime/remote.js.map +1 -0
  410. package/node_modules/@earendil-works/pi-codemode/dist/runtime/vm.d.ts +24 -0
  411. package/node_modules/@earendil-works/pi-codemode/dist/runtime/vm.d.ts.map +1 -0
  412. package/node_modules/@earendil-works/pi-codemode/dist/runtime/vm.js +293 -0
  413. package/node_modules/@earendil-works/pi-codemode/dist/runtime/vm.js.map +1 -0
  414. package/node_modules/@earendil-works/pi-codemode/dist/runtime/worker.js +11 -110
  415. package/node_modules/@earendil-works/pi-codemode/dist/runtime/worker.js.map +1 -1
  416. package/node_modules/@earendil-works/pi-codemode/dist/source.d.ts +2 -1
  417. package/node_modules/@earendil-works/pi-codemode/dist/source.d.ts.map +1 -1
  418. package/node_modules/@earendil-works/pi-codemode/dist/source.js +8 -2
  419. package/node_modules/@earendil-works/pi-codemode/dist/source.js.map +1 -1
  420. package/node_modules/@earendil-works/pi-codemode/dist/types.d.ts +101 -6
  421. package/node_modules/@earendil-works/pi-codemode/dist/types.d.ts.map +1 -1
  422. package/node_modules/@earendil-works/pi-codemode/dist/types.js.map +1 -1
  423. package/node_modules/@earendil-works/pi-codemode/package.json +15 -3
  424. package/node_modules/@earendil-works/pi-coding-agent/CHANGELOG.md +165 -0
  425. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/anthropic-messages-Q7SXESRX.js +6 -0
  426. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/anthropic.js +1 -1
  427. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/azure-openai-responses-LM52U7CK.js +2 -0
  428. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/bedrock-converse-stream.js +2 -2
  429. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/chunk-22CYIUS4.js +2 -0
  430. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/chunk-3ZATHNCK.js +9 -0
  431. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/chunk-5GTPJSRI.js +7 -0
  432. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/chunk-6MWTY2OB.js +130 -0
  433. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/chunk-6QGV3IWD.js +6 -0
  434. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/{chunk-2KAZSACP.js → chunk-AKJ3ZOR3.js} +1 -1
  435. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/{chunk-G7EDXK4D.js → chunk-CQ3XTLTY.js} +1 -1
  436. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/{chunk-SYF2TF6W.js → chunk-D7PHKNBM.js} +29 -92
  437. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/chunk-DOST5PQW.js +82 -0
  438. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/chunk-DVQEBGVL.js +2 -0
  439. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/{chunk-ZSI3BL5Q.js → chunk-GDR5JFDJ.js} +1 -1
  440. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/chunk-HACVPRBJ.js +11 -0
  441. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/chunk-ITZNWD4K.js +2 -0
  442. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/chunk-LPXNMA2W.js +2 -0
  443. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/{chunk-LD2P6SFZ.js → chunk-PMRZO46Y.js} +1 -1
  444. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/chunk-RDZVAGPR.js +2 -0
  445. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/{chunk-ZSBPJAJ2.js → chunk-TJXZSVTD.js} +116 -99
  446. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/{chunk-BYB6ZAAQ.js → chunk-TN4NLWHF.js} +1 -1
  447. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/chunk-WBQBCFWG.js +2 -0
  448. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/chunk-WJUNYZC5.js +2 -0
  449. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/chunk-XIX7LUWI.js +2 -0
  450. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/chunk-ZBURYEWF.js +2 -0
  451. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/{cli-KILDDGW3.js → cli-SWM4FQ6V.js} +4 -4
  452. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/cloudflare-workers-ai-system-one-UTBL2KOF.js +2 -0
  453. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/codemode-worker.js +117 -14
  454. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/easter-egg-3d-OX6RUCIS.js +2 -0
  455. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/execute-3CFUPDLS.js +499 -0
  456. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/github-copilot.js +1 -1
  457. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/{google-generative-ai-ZOK6CV7D.js → google-generative-ai-DXKP72HC.js} +1 -1
  458. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/{google-vertex-VKWZQ3AY.js → google-vertex-W6SIDOVV.js} +1 -1
  459. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/image-resize-worker.js +1 -1
  460. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/{llama-cpp-classify-XT44PI3C.js → llama-cpp-classify-FYN623RH.js} +2 -2
  461. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/mistral-conversations-GBMHTSYF.js +5 -0
  462. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/openai-chatgpt.js +1 -1
  463. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/openai-codex-responses-RN6B5UPP.js +10 -0
  464. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/openai-codex.js +1 -1
  465. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/{openai-completions-GWHGMQ3T.js → openai-completions-QW2B4SML.js} +1 -1
  466. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/openai-decisions-WVPMQ4JD.js +5 -0
  467. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/{openai-responses-EZ7FJ2KL.js → openai-responses-KDJUSIU7.js} +1 -1
  468. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/{openrouter-images-ZVXWCSIM.js → openrouter-images-DUPG5DZO.js} +1 -1
  469. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/{pi-messages-TM5SOOIW.js → pi-messages-YHKPQIHC.js} +1 -1
  470. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/runtime-366HE7CW.js +2 -0
  471. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/typesafe-system-one-ZSK3RN4B.js +2 -0
  472. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/virtual-modules-GI6FRNLG.js +2 -0
  473. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/cli-runtime.js +1 -1
  474. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/index.js +1 -1
  475. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/rpc-entry.js +1 -1
  476. package/node_modules/@earendil-works/pi-coding-agent/dist/cli/args.d.ts +2 -1
  477. package/node_modules/@earendil-works/pi-coding-agent/dist/cli/args.d.ts.map +1 -1
  478. package/node_modules/@earendil-works/pi-coding-agent/dist/cli/args.js +24 -5
  479. package/node_modules/@earendil-works/pi-coding-agent/dist/cli/args.js.map +1 -1
  480. package/node_modules/@earendil-works/pi-coding-agent/dist/config.d.ts +18 -1
  481. package/node_modules/@earendil-works/pi-coding-agent/dist/config.d.ts.map +1 -1
  482. package/node_modules/@earendil-works/pi-coding-agent/dist/config.js +44 -6
  483. package/node_modules/@earendil-works/pi-coding-agent/dist/config.js.map +1 -1
  484. package/node_modules/@earendil-works/pi-coding-agent/dist/core/agent-session.d.ts +47 -5
  485. package/node_modules/@earendil-works/pi-coding-agent/dist/core/agent-session.d.ts.map +1 -1
  486. package/node_modules/@earendil-works/pi-coding-agent/dist/core/agent-session.js +148 -78
  487. package/node_modules/@earendil-works/pi-coding-agent/dist/core/agent-session.js.map +1 -1
  488. package/node_modules/@earendil-works/pi-coding-agent/dist/core/auth-storage.d.ts.map +1 -1
  489. package/node_modules/@earendil-works/pi-coding-agent/dist/core/auth-storage.js +20 -13
  490. package/node_modules/@earendil-works/pi-coding-agent/dist/core/auth-storage.js.map +1 -1
  491. package/node_modules/@earendil-works/pi-coding-agent/dist/core/bash-executor.d.ts.map +1 -1
  492. package/node_modules/@earendil-works/pi-coding-agent/dist/core/bash-executor.js +42 -52
  493. package/node_modules/@earendil-works/pi-coding-agent/dist/core/bash-executor.js.map +1 -1
  494. package/node_modules/@earendil-works/pi-coding-agent/dist/core/bug-report.d.ts +9 -1
  495. package/node_modules/@earendil-works/pi-coding-agent/dist/core/bug-report.d.ts.map +1 -1
  496. package/node_modules/@earendil-works/pi-coding-agent/dist/core/compaction/utils.d.ts +6 -0
  497. package/node_modules/@earendil-works/pi-coding-agent/dist/core/compaction/utils.d.ts.map +1 -1
  498. package/node_modules/@earendil-works/pi-coding-agent/dist/core/compaction/utils.js +7 -8
  499. package/node_modules/@earendil-works/pi-coding-agent/dist/core/compaction/utils.js.map +1 -1
  500. package/node_modules/@earendil-works/pi-coding-agent/dist/core/export-html/tool-renderer.d.ts.map +1 -1
  501. package/node_modules/@earendil-works/pi-coding-agent/dist/core/export-html/tool-renderer.js +2 -0
  502. package/node_modules/@earendil-works/pi-coding-agent/dist/core/export-html/tool-renderer.js.map +1 -1
  503. package/node_modules/@earendil-works/pi-coding-agent/dist/core/extensions/index.d.ts +1 -1
  504. package/node_modules/@earendil-works/pi-coding-agent/dist/core/extensions/index.d.ts.map +1 -1
  505. package/node_modules/@earendil-works/pi-coding-agent/dist/core/extensions/index.js.map +1 -1
  506. package/node_modules/@earendil-works/pi-coding-agent/dist/core/extensions/runner.d.ts +4 -2
  507. package/node_modules/@earendil-works/pi-coding-agent/dist/core/extensions/runner.d.ts.map +1 -1
  508. package/node_modules/@earendil-works/pi-coding-agent/dist/core/extensions/runner.js +2 -3
  509. package/node_modules/@earendil-works/pi-coding-agent/dist/core/extensions/runner.js.map +1 -1
  510. package/node_modules/@earendil-works/pi-coding-agent/dist/core/extensions/types.d.ts +44 -7
  511. package/node_modules/@earendil-works/pi-coding-agent/dist/core/extensions/types.d.ts.map +1 -1
  512. package/node_modules/@earendil-works/pi-coding-agent/dist/core/extensions/types.js.map +1 -1
  513. package/node_modules/@earendil-works/pi-coding-agent/dist/core/key-id-schema.d.ts +6 -0
  514. package/node_modules/@earendil-works/pi-coding-agent/dist/core/key-id-schema.d.ts.map +1 -0
  515. package/node_modules/@earendil-works/pi-coding-agent/dist/core/key-id-schema.js +16 -0
  516. package/node_modules/@earendil-works/pi-coding-agent/dist/core/key-id-schema.js.map +1 -0
  517. package/node_modules/@earendil-works/pi-coding-agent/dist/core/keybindings-schema.d.ts +4 -0
  518. package/node_modules/@earendil-works/pi-coding-agent/dist/core/keybindings-schema.d.ts.map +1 -0
  519. package/node_modules/@earendil-works/pi-coding-agent/dist/core/keybindings-schema.js +16 -0
  520. package/node_modules/@earendil-works/pi-coding-agent/dist/core/keybindings-schema.js.map +1 -0
  521. package/node_modules/@earendil-works/pi-coding-agent/dist/core/keybindings.d.ts +198 -66
  522. package/node_modules/@earendil-works/pi-coding-agent/dist/core/keybindings.d.ts.map +1 -1
  523. package/node_modules/@earendil-works/pi-coding-agent/dist/core/keybindings.js +26 -23
  524. package/node_modules/@earendil-works/pi-coding-agent/dist/core/keybindings.js.map +1 -1
  525. package/node_modules/@earendil-works/pi-coding-agent/dist/core/mcp-servers.d.ts +8 -0
  526. package/node_modules/@earendil-works/pi-coding-agent/dist/core/mcp-servers.d.ts.map +1 -1
  527. package/node_modules/@earendil-works/pi-coding-agent/dist/core/mcp-servers.js +30 -7
  528. package/node_modules/@earendil-works/pi-coding-agent/dist/core/mcp-servers.js.map +1 -1
  529. package/node_modules/@earendil-works/pi-coding-agent/dist/core/model-config.d.ts +695 -74
  530. package/node_modules/@earendil-works/pi-coding-agent/dist/core/model-config.d.ts.map +1 -1
  531. package/node_modules/@earendil-works/pi-coding-agent/dist/core/model-config.js +16 -166
  532. package/node_modules/@earendil-works/pi-coding-agent/dist/core/model-config.js.map +1 -1
  533. package/node_modules/@earendil-works/pi-coding-agent/dist/core/model-resolver.js +1 -1
  534. package/node_modules/@earendil-works/pi-coding-agent/dist/core/model-resolver.js.map +1 -1
  535. package/node_modules/@earendil-works/pi-coding-agent/dist/core/model-runtime.d.ts.map +1 -1
  536. package/node_modules/@earendil-works/pi-coding-agent/dist/core/model-runtime.js +13 -7
  537. package/node_modules/@earendil-works/pi-coding-agent/dist/core/model-runtime.js.map +1 -1
  538. package/node_modules/@earendil-works/pi-coding-agent/dist/core/nested-tool-calls.d.ts +1 -0
  539. package/node_modules/@earendil-works/pi-coding-agent/dist/core/nested-tool-calls.d.ts.map +1 -1
  540. package/node_modules/@earendil-works/pi-coding-agent/dist/core/nested-tool-calls.js +1 -0
  541. package/node_modules/@earendil-works/pi-coding-agent/dist/core/nested-tool-calls.js.map +1 -1
  542. package/node_modules/@earendil-works/pi-coding-agent/dist/core/package-manager.d.ts.map +1 -1
  543. package/node_modules/@earendil-works/pi-coding-agent/dist/core/package-manager.js +3 -3
  544. package/node_modules/@earendil-works/pi-coding-agent/dist/core/package-manager.js.map +1 -1
  545. package/node_modules/@earendil-works/pi-coding-agent/dist/core/project-trust.d.ts.map +1 -1
  546. package/node_modules/@earendil-works/pi-coding-agent/dist/core/project-trust.js +2 -1
  547. package/node_modules/@earendil-works/pi-coding-agent/dist/core/project-trust.js.map +1 -1
  548. package/node_modules/@earendil-works/pi-coding-agent/dist/core/remote-catalog-provider.d.ts +12 -1
  549. package/node_modules/@earendil-works/pi-coding-agent/dist/core/remote-catalog-provider.d.ts.map +1 -1
  550. package/node_modules/@earendil-works/pi-coding-agent/dist/core/remote-catalog-provider.js +82 -24
  551. package/node_modules/@earendil-works/pi-coding-agent/dist/core/remote-catalog-provider.js.map +1 -1
  552. package/node_modules/@earendil-works/pi-coding-agent/dist/core/resource-loader.d.ts +3 -0
  553. package/node_modules/@earendil-works/pi-coding-agent/dist/core/resource-loader.d.ts.map +1 -1
  554. package/node_modules/@earendil-works/pi-coding-agent/dist/core/resource-loader.js +9 -4
  555. package/node_modules/@earendil-works/pi-coding-agent/dist/core/resource-loader.js.map +1 -1
  556. package/node_modules/@earendil-works/pi-coding-agent/dist/core/sdk.d.ts +13 -4
  557. package/node_modules/@earendil-works/pi-coding-agent/dist/core/sdk.d.ts.map +1 -1
  558. package/node_modules/@earendil-works/pi-coding-agent/dist/core/sdk.js +19 -6
  559. package/node_modules/@earendil-works/pi-coding-agent/dist/core/sdk.js.map +1 -1
  560. package/node_modules/@earendil-works/pi-coding-agent/dist/core/settings-defaults.d.ts +65 -0
  561. package/node_modules/@earendil-works/pi-coding-agent/dist/core/settings-defaults.d.ts.map +1 -0
  562. package/node_modules/@earendil-works/pi-coding-agent/dist/core/settings-defaults.js +66 -0
  563. package/node_modules/@earendil-works/pi-coding-agent/dist/core/settings-defaults.js.map +1 -0
  564. package/node_modules/@earendil-works/pi-coding-agent/dist/core/settings-manager.d.ts +15 -145
  565. package/node_modules/@earendil-works/pi-coding-agent/dist/core/settings-manager.d.ts.map +1 -1
  566. package/node_modules/@earendil-works/pi-coding-agent/dist/core/settings-manager.js +85 -57
  567. package/node_modules/@earendil-works/pi-coding-agent/dist/core/settings-manager.js.map +1 -1
  568. package/node_modules/@earendil-works/pi-coding-agent/dist/core/settings-schema.d.ts +228 -0
  569. package/node_modules/@earendil-works/pi-coding-agent/dist/core/settings-schema.d.ts.map +1 -0
  570. package/node_modules/@earendil-works/pi-coding-agent/dist/core/settings-schema.js +287 -0
  571. package/node_modules/@earendil-works/pi-coding-agent/dist/core/settings-schema.js.map +1 -0
  572. package/node_modules/@earendil-works/pi-coding-agent/dist/core/skills.d.ts +4 -1
  573. package/node_modules/@earendil-works/pi-coding-agent/dist/core/skills.d.ts.map +1 -1
  574. package/node_modules/@earendil-works/pi-coding-agent/dist/core/skills.js +6 -1
  575. package/node_modules/@earendil-works/pi-coding-agent/dist/core/skills.js.map +1 -1
  576. package/node_modules/@earendil-works/pi-coding-agent/dist/core/system-prompt.d.ts +6 -0
  577. package/node_modules/@earendil-works/pi-coding-agent/dist/core/system-prompt.d.ts.map +1 -1
  578. package/node_modules/@earendil-works/pi-coding-agent/dist/core/system-prompt.js +9 -4
  579. package/node_modules/@earendil-works/pi-coding-agent/dist/core/system-prompt.js.map +1 -1
  580. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/output-accumulator.d.ts.map +1 -1
  581. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/output-accumulator.js +4 -10
  582. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/output-accumulator.js.map +1 -1
  583. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/read.d.ts +13 -0
  584. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/read.d.ts.map +1 -1
  585. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/read.js +18 -1
  586. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/read.js.map +1 -1
  587. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/render-utils.d.ts +18 -0
  588. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/render-utils.d.ts.map +1 -1
  589. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/render-utils.js +46 -0
  590. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/render-utils.js.map +1 -1
  591. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/renderers/bash.d.ts.map +1 -1
  592. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/renderers/bash.js +7 -35
  593. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/renderers/bash.js.map +1 -1
  594. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/renderers/edit.d.ts.map +1 -1
  595. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/renderers/edit.js +5 -4
  596. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/renderers/edit.js.map +1 -1
  597. package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/codemode/execute.d.ts.map +1 -1
  598. package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/codemode/execute.js +165 -48
  599. package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/codemode/execute.js.map +1 -1
  600. package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/codemode/index.d.ts.map +1 -1
  601. package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/codemode/index.js +3 -1
  602. package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/codemode/index.js.map +1 -1
  603. package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/codemode/renderer.d.ts +2 -2
  604. package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/codemode/renderer.d.ts.map +1 -1
  605. package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/codemode/renderer.js +9 -3
  606. package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/codemode/renderer.js.map +1 -1
  607. package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/codemode/tool.d.ts +15 -14
  608. package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/codemode/tool.d.ts.map +1 -1
  609. package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/codemode/tool.js +58 -38
  610. package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/codemode/tool.js.map +1 -1
  611. package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/llama/provider.d.ts.map +1 -1
  612. package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/llama/provider.js +34 -11
  613. package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/llama/provider.js.map +1 -1
  614. package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/mcp/cli.js +22 -31
  615. package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/mcp/cli.js.map +1 -1
  616. package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/mcp/index.d.ts.map +1 -1
  617. package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/mcp/index.js +188 -84
  618. package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/mcp/index.js.map +1 -1
  619. package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/mcp/oauth.d.ts +5 -3
  620. package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/mcp/oauth.d.ts.map +1 -1
  621. package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/mcp/oauth.js +36 -10
  622. package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/mcp/oauth.js.map +1 -1
  623. package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/mcp/resources.d.ts +3 -10
  624. package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/mcp/resources.d.ts.map +1 -1
  625. package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/mcp/resources.js +4 -5
  626. package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/mcp/resources.js.map +1 -1
  627. package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/mcp/runtime.d.ts +7 -7
  628. package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/mcp/runtime.d.ts.map +1 -1
  629. package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/mcp/runtime.js +26 -44
  630. package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/mcp/runtime.js.map +1 -1
  631. package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/mcp/tools.d.ts +4 -4
  632. package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/mcp/tools.d.ts.map +1 -1
  633. package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/mcp/tools.js +68 -16
  634. package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/mcp/tools.js.map +1 -1
  635. package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/mcp/ui.d.ts +3 -3
  636. package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/mcp/ui.d.ts.map +1 -1
  637. package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/mcp/ui.js +10 -2
  638. package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/mcp/ui.js.map +1 -1
  639. package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/tool-search/tool.d.ts +0 -2
  640. package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/tool-search/tool.d.ts.map +1 -1
  641. package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/tool-search/tool.js +2 -4
  642. package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/tool-search/tool.js.map +1 -1
  643. package/node_modules/@earendil-works/pi-coding-agent/dist/index.d.ts +1 -1
  644. package/node_modules/@earendil-works/pi-coding-agent/dist/index.d.ts.map +1 -1
  645. package/node_modules/@earendil-works/pi-coding-agent/dist/index.js.map +1 -1
  646. package/node_modules/@earendil-works/pi-coding-agent/dist/main.d.ts.map +1 -1
  647. package/node_modules/@earendil-works/pi-coding-agent/dist/main.js +4 -3
  648. package/node_modules/@earendil-works/pi-coding-agent/dist/main.js.map +1 -1
  649. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/bash-execution.d.ts +5 -1
  650. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/bash-execution.d.ts.map +1 -1
  651. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/bash-execution.js +17 -14
  652. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/bash-execution.js.map +1 -1
  653. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/branch-summary-message.d.ts +2 -1
  654. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -1
  655. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/branch-summary-message.js +5 -2
  656. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/branch-summary-message.js.map +1 -1
  657. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/compaction-summary-message.d.ts +2 -1
  658. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -1
  659. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/compaction-summary-message.js +5 -2
  660. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/compaction-summary-message.js.map +1 -1
  661. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/custom-entry.d.ts +3 -1
  662. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/custom-entry.d.ts.map +1 -1
  663. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/custom-entry.js +8 -2
  664. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/custom-entry.js.map +1 -1
  665. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
  666. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/custom-message.js +1 -0
  667. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/custom-message.js.map +1 -1
  668. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  669. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/settings-selector.js +4 -3
  670. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/settings-selector.js.map +1 -1
  671. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/skill-invocation-message.d.ts +2 -1
  672. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -1
  673. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/skill-invocation-message.js +5 -2
  674. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/skill-invocation-message.js.map +1 -1
  675. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/status-indicator.d.ts +1 -1
  676. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/status-indicator.d.ts.map +1 -1
  677. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/status-indicator.js +2 -2
  678. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/status-indicator.js.map +1 -1
  679. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/tool-execution.d.ts +5 -0
  680. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  681. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/tool-execution.js +10 -0
  682. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/tool-execution.js.map +1 -1
  683. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/interactive-mode.d.ts +9 -0
  684. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  685. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/interactive-mode.js +103 -40
  686. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/interactive-mode.js.map +1 -1
  687. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/program-status-reporter.d.ts +34 -0
  688. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/program-status-reporter.d.ts.map +1 -0
  689. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/program-status-reporter.js +110 -0
  690. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/program-status-reporter.js.map +1 -0
  691. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/theme/dark.json +1 -1
  692. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/theme/light.json +1 -1
  693. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/theme/theme-schema.d.ts +28 -0
  694. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/theme/theme-schema.d.ts.map +1 -0
  695. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/theme/theme-schema.js +105 -0
  696. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/theme/theme-schema.js.map +1 -0
  697. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/theme/theme-tokens.d.ts +257 -0
  698. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/theme/theme-tokens.d.ts.map +1 -0
  699. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/theme/theme-tokens.js +94 -0
  700. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/theme/theme-tokens.js.map +1 -0
  701. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/theme/theme.d.ts +13 -16
  702. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  703. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/theme/theme.js +22 -29
  704. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/theme/theme.js.map +1 -1
  705. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/print-mode.d.ts.map +1 -1
  706. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/print-mode.js +4 -0
  707. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/print-mode.js.map +1 -1
  708. package/node_modules/@earendil-works/pi-coding-agent/dist/package-manager-cli.d.ts.map +1 -1
  709. package/node_modules/@earendil-works/pi-coding-agent/dist/package-manager-cli.js +24 -0
  710. package/node_modules/@earendil-works/pi-coding-agent/dist/package-manager-cli.js.map +1 -1
  711. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/ansi.d.ts +8 -0
  712. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/ansi.d.ts.map +1 -1
  713. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/ansi.js +30 -11
  714. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/ansi.js.map +1 -1
  715. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/clipboard.d.ts.map +1 -1
  716. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/clipboard.js +18 -12
  717. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/clipboard.js.map +1 -1
  718. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/image-resize-core.d.ts +12 -0
  719. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/image-resize-core.d.ts.map +1 -1
  720. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/image-resize-core.js +5 -0
  721. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/image-resize-core.js.map +1 -1
  722. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/image-resize-worker.js +3 -2
  723. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/image-resize-worker.js.map +1 -1
  724. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/image-resize.d.ts.map +1 -1
  725. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/image-resize.js +9 -10
  726. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/image-resize.js.map +1 -1
  727. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/output-files.d.ts +15 -0
  728. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/output-files.d.ts.map +1 -0
  729. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/output-files.js +30 -0
  730. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/output-files.js.map +1 -0
  731. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/syntax-highlight.d.ts.map +1 -1
  732. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/syntax-highlight.js +6 -1
  733. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/syntax-highlight.js.map +1 -1
  734. package/node_modules/@earendil-works/pi-coding-agent/docs/cli-integration.md +1 -1
  735. package/node_modules/@earendil-works/pi-coding-agent/docs/cli.md +19 -7
  736. package/node_modules/@earendil-works/pi-coding-agent/docs/codemode.md +30 -9
  737. package/node_modules/@earendil-works/pi-coding-agent/docs/compaction.md +2 -2
  738. package/node_modules/@earendil-works/pi-coding-agent/docs/environment-variables.md +3 -1
  739. package/node_modules/@earendil-works/pi-coding-agent/docs/extensions.md +7 -4
  740. package/node_modules/@earendil-works/pi-coding-agent/docs/json.md +3 -3
  741. package/node_modules/@earendil-works/pi-coding-agent/docs/keybindings.md +5 -4
  742. package/node_modules/@earendil-works/pi-coding-agent/docs/llama-cpp.md +8 -1
  743. package/node_modules/@earendil-works/pi-coding-agent/docs/mcp.md +4 -2
  744. package/node_modules/@earendil-works/pi-coding-agent/docs/message-types.md +22 -4
  745. package/node_modules/@earendil-works/pi-coding-agent/docs/models.md +5 -1
  746. package/node_modules/@earendil-works/pi-coding-agent/docs/providers.md +47 -0
  747. package/node_modules/@earendil-works/pi-coding-agent/docs/settings.md +6 -4
  748. package/node_modules/@earendil-works/pi-coding-agent/docs/terminal-setup.md +14 -0
  749. package/node_modules/@earendil-works/pi-coding-agent/docs/themes.md +4 -2
  750. package/node_modules/@earendil-works/pi-coding-agent/docs/tui.md +1 -1
  751. package/node_modules/@earendil-works/pi-coding-agent/examples/README.md +0 -3
  752. package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  753. package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/custom-provider-anthropic/package.json +1 -1
  754. package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  755. package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/dynamic-resources/dynamic.json +1 -1
  756. package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/gondolin/package-lock.json +2 -2
  757. package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/gondolin/package.json +1 -1
  758. package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/overlay-test.ts +2 -2
  759. package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/plan-mode/index.ts +6 -2
  760. package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/sandbox/package-lock.json +2 -2
  761. package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/sandbox/package.json +1 -1
  762. package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/with-deps/package-lock.json +2 -2
  763. package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/with-deps/package.json +1 -1
  764. package/node_modules/@earendil-works/pi-coding-agent/package.json +10 -21
  765. package/node_modules/@earendil-works/pi-coding-agent/schemas/keybindings.schema.json +393 -0
  766. package/node_modules/@earendil-works/pi-coding-agent/schemas/models.schema.json +1157 -0
  767. package/node_modules/@earendil-works/pi-coding-agent/schemas/settings.schema.json +765 -0
  768. package/node_modules/@earendil-works/pi-coding-agent/schemas/theme.schema.json +365 -0
  769. package/node_modules/@earendil-works/pi-durable/CHANGELOG.md +114 -0
  770. package/node_modules/@earendil-works/pi-durable/README.md +164 -12
  771. package/node_modules/@earendil-works/pi-durable/dist/codemode/codemode.d.ts +173 -0
  772. package/node_modules/@earendil-works/pi-durable/dist/codemode/codemode.d.ts.map +1 -0
  773. package/node_modules/@earendil-works/pi-durable/dist/codemode/codemode.js +886 -0
  774. package/node_modules/@earendil-works/pi-durable/dist/codemode/codemode.js.map +1 -0
  775. package/node_modules/@earendil-works/pi-durable/dist/codemode/describe.d.ts +38 -0
  776. package/node_modules/@earendil-works/pi-durable/dist/codemode/describe.d.ts.map +1 -0
  777. package/node_modules/@earendil-works/pi-durable/dist/codemode/describe.js +119 -0
  778. package/node_modules/@earendil-works/pi-durable/dist/codemode/describe.js.map +1 -0
  779. package/node_modules/@earendil-works/pi-durable/dist/codemode/index.d.ts +3 -0
  780. package/node_modules/@earendil-works/pi-durable/dist/codemode/index.d.ts.map +1 -0
  781. package/node_modules/@earendil-works/pi-durable/dist/codemode/index.js +3 -0
  782. package/node_modules/@earendil-works/pi-durable/dist/codemode/index.js.map +1 -0
  783. package/node_modules/@earendil-works/pi-durable/dist/codemode/models.d.ts +28 -0
  784. package/node_modules/@earendil-works/pi-durable/dist/codemode/models.d.ts.map +1 -0
  785. package/node_modules/@earendil-works/pi-durable/dist/codemode/models.js +231 -0
  786. package/node_modules/@earendil-works/pi-durable/dist/codemode/models.js.map +1 -0
  787. package/node_modules/@earendil-works/pi-durable/dist/codemode/output.d.ts +41 -0
  788. package/node_modules/@earendil-works/pi-durable/dist/codemode/output.d.ts.map +1 -0
  789. package/node_modules/@earendil-works/pi-durable/dist/codemode/output.js +167 -0
  790. package/node_modules/@earendil-works/pi-durable/dist/codemode/output.js.map +1 -0
  791. package/node_modules/@earendil-works/pi-durable/dist/env/decode.d.ts +16 -0
  792. package/node_modules/@earendil-works/pi-durable/dist/env/decode.d.ts.map +1 -0
  793. package/node_modules/@earendil-works/pi-durable/dist/env/decode.js +28 -0
  794. package/node_modules/@earendil-works/pi-durable/dist/env/decode.js.map +1 -0
  795. package/node_modules/@earendil-works/pi-durable/dist/env/index.d.ts +197 -3
  796. package/node_modules/@earendil-works/pi-durable/dist/env/index.d.ts.map +1 -1
  797. package/node_modules/@earendil-works/pi-durable/dist/env/index.js +2 -0
  798. package/node_modules/@earendil-works/pi-durable/dist/env/index.js.map +1 -1
  799. package/node_modules/@earendil-works/pi-durable/dist/env/line-scan.d.ts +13 -0
  800. package/node_modules/@earendil-works/pi-durable/dist/env/line-scan.d.ts.map +1 -0
  801. package/node_modules/@earendil-works/pi-durable/dist/env/line-scan.js +147 -0
  802. package/node_modules/@earendil-works/pi-durable/dist/env/line-scan.js.map +1 -0
  803. package/node_modules/@earendil-works/pi-durable/dist/env/node-watch.d.ts +29 -0
  804. package/node_modules/@earendil-works/pi-durable/dist/env/node-watch.d.ts.map +1 -0
  805. package/node_modules/@earendil-works/pi-durable/dist/env/node-watch.js +485 -0
  806. package/node_modules/@earendil-works/pi-durable/dist/env/node-watch.js.map +1 -0
  807. package/node_modules/@earendil-works/pi-durable/dist/env/node.d.ts +11 -2
  808. package/node_modules/@earendil-works/pi-durable/dist/env/node.d.ts.map +1 -1
  809. package/node_modules/@earendil-works/pi-durable/dist/env/node.js +284 -21
  810. package/node_modules/@earendil-works/pi-durable/dist/env/node.js.map +1 -1
  811. package/node_modules/@earendil-works/pi-durable/dist/errors.d.ts +20 -3
  812. package/node_modules/@earendil-works/pi-durable/dist/errors.d.ts.map +1 -1
  813. package/node_modules/@earendil-works/pi-durable/dist/errors.js +34 -5
  814. package/node_modules/@earendil-works/pi-durable/dist/errors.js.map +1 -1
  815. package/node_modules/@earendil-works/pi-durable/dist/harness/agent.d.ts +7 -3
  816. package/node_modules/@earendil-works/pi-durable/dist/harness/agent.d.ts.map +1 -1
  817. package/node_modules/@earendil-works/pi-durable/dist/harness/agent.js +81 -25
  818. package/node_modules/@earendil-works/pi-durable/dist/harness/agent.js.map +1 -1
  819. package/node_modules/@earendil-works/pi-durable/dist/harness/compaction.d.ts +6 -1
  820. package/node_modules/@earendil-works/pi-durable/dist/harness/compaction.d.ts.map +1 -1
  821. package/node_modules/@earendil-works/pi-durable/dist/harness/compaction.js +11 -8
  822. package/node_modules/@earendil-works/pi-durable/dist/harness/compaction.js.map +1 -1
  823. package/node_modules/@earendil-works/pi-durable/dist/harness/context.d.ts +29 -1
  824. package/node_modules/@earendil-works/pi-durable/dist/harness/context.d.ts.map +1 -1
  825. package/node_modules/@earendil-works/pi-durable/dist/harness/context.js +125 -24
  826. package/node_modules/@earendil-works/pi-durable/dist/harness/context.js.map +1 -1
  827. package/node_modules/@earendil-works/pi-durable/dist/harness/events.d.ts +35 -15
  828. package/node_modules/@earendil-works/pi-durable/dist/harness/events.d.ts.map +1 -1
  829. package/node_modules/@earendil-works/pi-durable/dist/harness/events.js +77 -23
  830. package/node_modules/@earendil-works/pi-durable/dist/harness/events.js.map +1 -1
  831. package/node_modules/@earendil-works/pi-durable/dist/harness/generation.d.ts +2 -0
  832. package/node_modules/@earendil-works/pi-durable/dist/harness/generation.d.ts.map +1 -1
  833. package/node_modules/@earendil-works/pi-durable/dist/harness/generation.js +40 -16
  834. package/node_modules/@earendil-works/pi-durable/dist/harness/generation.js.map +1 -1
  835. package/node_modules/@earendil-works/pi-durable/dist/harness/harness.d.ts +7 -0
  836. package/node_modules/@earendil-works/pi-durable/dist/harness/harness.d.ts.map +1 -1
  837. package/node_modules/@earendil-works/pi-durable/dist/harness/harness.js +56 -28
  838. package/node_modules/@earendil-works/pi-durable/dist/harness/harness.js.map +1 -1
  839. package/node_modules/@earendil-works/pi-durable/dist/harness/inbox.d.ts +16 -4
  840. package/node_modules/@earendil-works/pi-durable/dist/harness/inbox.d.ts.map +1 -1
  841. package/node_modules/@earendil-works/pi-durable/dist/harness/inbox.js +26 -3
  842. package/node_modules/@earendil-works/pi-durable/dist/harness/inbox.js.map +1 -1
  843. package/node_modules/@earendil-works/pi-durable/dist/harness/live.d.ts +74 -17
  844. package/node_modules/@earendil-works/pi-durable/dist/harness/live.d.ts.map +1 -1
  845. package/node_modules/@earendil-works/pi-durable/dist/harness/live.js +66 -14
  846. package/node_modules/@earendil-works/pi-durable/dist/harness/live.js.map +1 -1
  847. package/node_modules/@earendil-works/pi-durable/dist/harness/output.d.ts +13 -6
  848. package/node_modules/@earendil-works/pi-durable/dist/harness/output.d.ts.map +1 -1
  849. package/node_modules/@earendil-works/pi-durable/dist/harness/output.js +75 -18
  850. package/node_modules/@earendil-works/pi-durable/dist/harness/output.js.map +1 -1
  851. package/node_modules/@earendil-works/pi-durable/dist/harness/scheduler.d.ts +18 -5
  852. package/node_modules/@earendil-works/pi-durable/dist/harness/scheduler.d.ts.map +1 -1
  853. package/node_modules/@earendil-works/pi-durable/dist/harness/scheduler.js +794 -168
  854. package/node_modules/@earendil-works/pi-durable/dist/harness/scheduler.js.map +1 -1
  855. package/node_modules/@earendil-works/pi-durable/dist/harness/submissions.d.ts +7 -4
  856. package/node_modules/@earendil-works/pi-durable/dist/harness/submissions.d.ts.map +1 -1
  857. package/node_modules/@earendil-works/pi-durable/dist/harness/submissions.js +32 -13
  858. package/node_modules/@earendil-works/pi-durable/dist/harness/submissions.js.map +1 -1
  859. package/node_modules/@earendil-works/pi-durable/dist/harness/task-graph.d.ts +1 -1
  860. package/node_modules/@earendil-works/pi-durable/dist/harness/task-graph.d.ts.map +1 -1
  861. package/node_modules/@earendil-works/pi-durable/dist/harness/task-graph.js +15 -10
  862. package/node_modules/@earendil-works/pi-durable/dist/harness/task-graph.js.map +1 -1
  863. package/node_modules/@earendil-works/pi-durable/dist/harness/tool.d.ts +45 -5
  864. package/node_modules/@earendil-works/pi-durable/dist/harness/tool.d.ts.map +1 -1
  865. package/node_modules/@earendil-works/pi-durable/dist/harness/tool.js +400 -67
  866. package/node_modules/@earendil-works/pi-durable/dist/harness/tool.js.map +1 -1
  867. package/node_modules/@earendil-works/pi-durable/dist/harness/types.d.ts +194 -17
  868. package/node_modules/@earendil-works/pi-durable/dist/harness/types.d.ts.map +1 -1
  869. package/node_modules/@earendil-works/pi-durable/dist/harness/types.js.map +1 -1
  870. package/node_modules/@earendil-works/pi-durable/dist/harness/util.d.ts +6 -1
  871. package/node_modules/@earendil-works/pi-durable/dist/harness/util.d.ts.map +1 -1
  872. package/node_modules/@earendil-works/pi-durable/dist/harness/util.js +5 -2
  873. package/node_modules/@earendil-works/pi-durable/dist/harness/util.js.map +1 -1
  874. package/node_modules/@earendil-works/pi-durable/dist/harness/view.d.ts +6 -2
  875. package/node_modules/@earendil-works/pi-durable/dist/harness/view.d.ts.map +1 -1
  876. package/node_modules/@earendil-works/pi-durable/dist/harness/view.js +22 -12
  877. package/node_modules/@earendil-works/pi-durable/dist/harness/view.js.map +1 -1
  878. package/node_modules/@earendil-works/pi-durable/dist/images/cloudflare.d.ts +4 -0
  879. package/node_modules/@earendil-works/pi-durable/dist/images/cloudflare.d.ts.map +1 -0
  880. package/node_modules/@earendil-works/pi-durable/dist/images/cloudflare.js +9 -0
  881. package/node_modules/@earendil-works/pi-durable/dist/images/cloudflare.js.map +1 -0
  882. package/node_modules/@earendil-works/pi-durable/dist/images/exif.d.ts +3 -0
  883. package/node_modules/@earendil-works/pi-durable/dist/images/exif.d.ts.map +1 -0
  884. package/node_modules/@earendil-works/pi-durable/dist/images/exif.js +71 -0
  885. package/node_modules/@earendil-works/pi-durable/dist/images/exif.js.map +1 -0
  886. package/node_modules/@earendil-works/pi-durable/dist/images/index.d.ts +18 -0
  887. package/node_modules/@earendil-works/pi-durable/dist/images/index.d.ts.map +1 -0
  888. package/node_modules/@earendil-works/pi-durable/dist/images/index.js +125 -0
  889. package/node_modules/@earendil-works/pi-durable/dist/images/index.js.map +1 -0
  890. package/node_modules/@earendil-works/pi-durable/dist/images/node-worker.d.ts +17 -0
  891. package/node_modules/@earendil-works/pi-durable/dist/images/node-worker.d.ts.map +1 -0
  892. package/node_modules/@earendil-works/pi-durable/dist/images/node-worker.js +16 -0
  893. package/node_modules/@earendil-works/pi-durable/dist/images/node-worker.js.map +1 -0
  894. package/node_modules/@earendil-works/pi-durable/dist/images/node.d.ts +21 -0
  895. package/node_modules/@earendil-works/pi-durable/dist/images/node.d.ts.map +1 -0
  896. package/node_modules/@earendil-works/pi-durable/dist/images/node.js +121 -0
  897. package/node_modules/@earendil-works/pi-durable/dist/images/node.js.map +1 -0
  898. package/node_modules/@earendil-works/pi-durable/dist/index.d.ts +7 -7
  899. package/node_modules/@earendil-works/pi-durable/dist/index.d.ts.map +1 -1
  900. package/node_modules/@earendil-works/pi-durable/dist/index.js +4 -4
  901. package/node_modules/@earendil-works/pi-durable/dist/index.js.map +1 -1
  902. package/node_modules/@earendil-works/pi-durable/dist/search.d.ts +13 -0
  903. package/node_modules/@earendil-works/pi-durable/dist/search.d.ts.map +1 -0
  904. package/node_modules/@earendil-works/pi-durable/dist/search.js +85 -0
  905. package/node_modules/@earendil-works/pi-durable/dist/search.js.map +1 -0
  906. package/node_modules/@earendil-works/pi-durable/dist/session/observation.d.ts +10 -3
  907. package/node_modules/@earendil-works/pi-durable/dist/session/observation.d.ts.map +1 -1
  908. package/node_modules/@earendil-works/pi-durable/dist/session/observation.js +24 -34
  909. package/node_modules/@earendil-works/pi-durable/dist/session/observation.js.map +1 -1
  910. package/node_modules/@earendil-works/pi-durable/dist/session/session.d.ts +71 -6
  911. package/node_modules/@earendil-works/pi-durable/dist/session/session.d.ts.map +1 -1
  912. package/node_modules/@earendil-works/pi-durable/dist/session/session.js +463 -50
  913. package/node_modules/@earendil-works/pi-durable/dist/session/session.js.map +1 -1
  914. package/node_modules/@earendil-works/pi-durable/dist/session/transaction.d.ts +2 -0
  915. package/node_modules/@earendil-works/pi-durable/dist/session/transaction.d.ts.map +1 -1
  916. package/node_modules/@earendil-works/pi-durable/dist/session/transaction.js +19 -1
  917. package/node_modules/@earendil-works/pi-durable/dist/session/transaction.js.map +1 -1
  918. package/node_modules/@earendil-works/pi-durable/dist/storage/jsonl/storage.d.ts +8 -0
  919. package/node_modules/@earendil-works/pi-durable/dist/storage/jsonl/storage.d.ts.map +1 -1
  920. package/node_modules/@earendil-works/pi-durable/dist/storage/jsonl/storage.js +2 -1
  921. package/node_modules/@earendil-works/pi-durable/dist/storage/jsonl/storage.js.map +1 -1
  922. package/node_modules/@earendil-works/pi-durable/dist/storage/memory.d.ts +2 -0
  923. package/node_modules/@earendil-works/pi-durable/dist/storage/memory.d.ts.map +1 -1
  924. package/node_modules/@earendil-works/pi-durable/dist/storage/memory.js +79 -27
  925. package/node_modules/@earendil-works/pi-durable/dist/storage/memory.js.map +1 -1
  926. package/node_modules/@earendil-works/pi-durable/dist/storage/scan.d.ts +18 -0
  927. package/node_modules/@earendil-works/pi-durable/dist/storage/scan.d.ts.map +1 -0
  928. package/node_modules/@earendil-works/pi-durable/dist/storage/scan.js +29 -0
  929. package/node_modules/@earendil-works/pi-durable/dist/storage/scan.js.map +1 -0
  930. package/node_modules/@earendil-works/pi-durable/dist/storage/sqlite/cloudflare.d.ts +46 -0
  931. package/node_modules/@earendil-works/pi-durable/dist/storage/sqlite/cloudflare.d.ts.map +1 -0
  932. package/node_modules/@earendil-works/pi-durable/dist/storage/sqlite/cloudflare.js +106 -0
  933. package/node_modules/@earendil-works/pi-durable/dist/storage/sqlite/cloudflare.js.map +1 -0
  934. package/node_modules/@earendil-works/pi-durable/dist/storage/sqlite/storage.d.ts +2 -0
  935. package/node_modules/@earendil-works/pi-durable/dist/storage/sqlite/storage.d.ts.map +1 -1
  936. package/node_modules/@earendil-works/pi-durable/dist/storage/sqlite/storage.js +77 -27
  937. package/node_modules/@earendil-works/pi-durable/dist/storage/sqlite/storage.js.map +1 -1
  938. package/node_modules/@earendil-works/pi-durable/dist/testing/env-conformance.d.ts +7 -0
  939. package/node_modules/@earendil-works/pi-durable/dist/testing/env-conformance.d.ts.map +1 -0
  940. package/node_modules/@earendil-works/pi-durable/dist/testing/env-conformance.js +531 -0
  941. package/node_modules/@earendil-works/pi-durable/dist/testing/env-conformance.js.map +1 -0
  942. package/node_modules/@earendil-works/pi-durable/dist/testing/index.d.ts +3 -2
  943. package/node_modules/@earendil-works/pi-durable/dist/testing/index.d.ts.map +1 -1
  944. package/node_modules/@earendil-works/pi-durable/dist/testing/index.js +2 -1
  945. package/node_modules/@earendil-works/pi-durable/dist/testing/index.js.map +1 -1
  946. package/node_modules/@earendil-works/pi-durable/dist/testing/runner.d.ts +4 -2
  947. package/node_modules/@earendil-works/pi-durable/dist/testing/runner.d.ts.map +1 -1
  948. package/node_modules/@earendil-works/pi-durable/dist/testing/runner.js +9 -0
  949. package/node_modules/@earendil-works/pi-durable/dist/testing/runner.js.map +1 -1
  950. package/node_modules/@earendil-works/pi-durable/dist/testing/storage-conformance.d.ts.map +1 -1
  951. package/node_modules/@earendil-works/pi-durable/dist/testing/storage-conformance.js +61 -2
  952. package/node_modules/@earendil-works/pi-durable/dist/testing/storage-conformance.js.map +1 -1
  953. package/node_modules/@earendil-works/pi-durable/dist/testing/types.d.ts +20 -0
  954. package/node_modules/@earendil-works/pi-durable/dist/testing/types.d.ts.map +1 -1
  955. package/node_modules/@earendil-works/pi-durable/dist/testing/types.js.map +1 -1
  956. package/node_modules/@earendil-works/pi-durable/dist/tool-search/index.d.ts +2 -0
  957. package/node_modules/@earendil-works/pi-durable/dist/tool-search/index.d.ts.map +1 -0
  958. package/node_modules/@earendil-works/pi-durable/dist/tool-search/index.js +2 -0
  959. package/node_modules/@earendil-works/pi-durable/dist/tool-search/index.js.map +1 -0
  960. package/node_modules/@earendil-works/pi-durable/dist/tool-search/tool-search.d.ts +23 -0
  961. package/node_modules/@earendil-works/pi-durable/dist/tool-search/tool-search.d.ts.map +1 -0
  962. package/node_modules/@earendil-works/pi-durable/dist/tool-search/tool-search.js +84 -0
  963. package/node_modules/@earendil-works/pi-durable/dist/tool-search/tool-search.js.map +1 -0
  964. package/node_modules/@earendil-works/pi-durable/dist/tools/bash.d.ts +30 -3
  965. package/node_modules/@earendil-works/pi-durable/dist/tools/bash.d.ts.map +1 -1
  966. package/node_modules/@earendil-works/pi-durable/dist/tools/bash.js +105 -37
  967. package/node_modules/@earendil-works/pi-durable/dist/tools/bash.js.map +1 -1
  968. package/node_modules/@earendil-works/pi-durable/dist/tools/edit.js +1 -1
  969. package/node_modules/@earendil-works/pi-durable/dist/tools/edit.js.map +1 -1
  970. package/node_modules/@earendil-works/pi-durable/dist/tools/image-processor.d.ts +47 -0
  971. package/node_modules/@earendil-works/pi-durable/dist/tools/image-processor.d.ts.map +1 -0
  972. package/node_modules/@earendil-works/pi-durable/dist/tools/image-processor.js +30 -0
  973. package/node_modules/@earendil-works/pi-durable/dist/tools/image-processor.js.map +1 -0
  974. package/node_modules/@earendil-works/pi-durable/dist/tools/image.d.ts +18 -0
  975. package/node_modules/@earendil-works/pi-durable/dist/tools/image.d.ts.map +1 -1
  976. package/node_modules/@earendil-works/pi-durable/dist/tools/image.js +86 -0
  977. package/node_modules/@earendil-works/pi-durable/dist/tools/image.js.map +1 -1
  978. package/node_modules/@earendil-works/pi-durable/dist/tools/index.d.ts +26 -3
  979. package/node_modules/@earendil-works/pi-durable/dist/tools/index.d.ts.map +1 -1
  980. package/node_modules/@earendil-works/pi-durable/dist/tools/index.js +14 -6
  981. package/node_modules/@earendil-works/pi-durable/dist/tools/index.js.map +1 -1
  982. package/node_modules/@earendil-works/pi-durable/dist/tools/read.d.ts +10 -2
  983. package/node_modules/@earendil-works/pi-durable/dist/tools/read.d.ts.map +1 -1
  984. package/node_modules/@earendil-works/pi-durable/dist/tools/read.js +212 -78
  985. package/node_modules/@earendil-works/pi-durable/dist/tools/read.js.map +1 -1
  986. package/node_modules/@earendil-works/pi-durable/dist/tools/write.js +1 -1
  987. package/node_modules/@earendil-works/pi-durable/dist/tools/write.js.map +1 -1
  988. package/node_modules/@earendil-works/pi-durable/dist/truncate.d.ts +9 -0
  989. package/node_modules/@earendil-works/pi-durable/dist/truncate.d.ts.map +1 -1
  990. package/node_modules/@earendil-works/pi-durable/dist/truncate.js +12 -4
  991. package/node_modules/@earendil-works/pi-durable/dist/truncate.js.map +1 -1
  992. package/node_modules/@earendil-works/pi-durable/dist/types.d.ts +89 -12
  993. package/node_modules/@earendil-works/pi-durable/dist/types.d.ts.map +1 -1
  994. package/node_modules/@earendil-works/pi-durable/dist/types.js.map +1 -1
  995. package/node_modules/@earendil-works/pi-durable/package.json +50 -5
  996. package/node_modules/@earendil-works/pi-mcp/CHANGELOG.md +29 -0
  997. package/node_modules/@earendil-works/pi-mcp/dist/auth-provider.d.ts +4 -0
  998. package/node_modules/@earendil-works/pi-mcp/dist/auth-provider.d.ts.map +1 -1
  999. package/node_modules/@earendil-works/pi-mcp/dist/auth-provider.js.map +1 -1
  1000. package/node_modules/@earendil-works/pi-mcp/dist/client.d.ts.map +1 -1
  1001. package/node_modules/@earendil-works/pi-mcp/dist/client.js +9 -5
  1002. package/node_modules/@earendil-works/pi-mcp/dist/client.js.map +1 -1
  1003. package/node_modules/@earendil-works/pi-mcp/dist/index.d.ts +1 -1
  1004. package/node_modules/@earendil-works/pi-mcp/dist/index.d.ts.map +1 -1
  1005. package/node_modules/@earendil-works/pi-mcp/dist/index.js.map +1 -1
  1006. package/node_modules/@earendil-works/pi-mcp/dist/oauth/discovery.d.ts +3 -0
  1007. package/node_modules/@earendil-works/pi-mcp/dist/oauth/discovery.d.ts.map +1 -1
  1008. package/node_modules/@earendil-works/pi-mcp/dist/oauth/discovery.js +8 -5
  1009. package/node_modules/@earendil-works/pi-mcp/dist/oauth/discovery.js.map +1 -1
  1010. package/node_modules/@earendil-works/pi-mcp/dist/oauth/errors.d.ts +3 -2
  1011. package/node_modules/@earendil-works/pi-mcp/dist/oauth/errors.d.ts.map +1 -1
  1012. package/node_modules/@earendil-works/pi-mcp/dist/oauth/errors.js +3 -1
  1013. package/node_modules/@earendil-works/pi-mcp/dist/oauth/errors.js.map +1 -1
  1014. package/node_modules/@earendil-works/pi-mcp/dist/oauth/flow.d.ts +4 -0
  1015. package/node_modules/@earendil-works/pi-mcp/dist/oauth/flow.d.ts.map +1 -1
  1016. package/node_modules/@earendil-works/pi-mcp/dist/oauth/flow.js +35 -7
  1017. package/node_modules/@earendil-works/pi-mcp/dist/oauth/flow.js.map +1 -1
  1018. package/node_modules/@earendil-works/pi-mcp/dist/oauth/types.d.ts +5 -0
  1019. package/node_modules/@earendil-works/pi-mcp/dist/oauth/types.d.ts.map +1 -1
  1020. package/node_modules/@earendil-works/pi-mcp/dist/oauth/types.js.map +1 -1
  1021. package/node_modules/@earendil-works/pi-mcp/dist/protocol/content.d.ts +2 -1
  1022. package/node_modules/@earendil-works/pi-mcp/dist/protocol/content.d.ts.map +1 -1
  1023. package/node_modules/@earendil-works/pi-mcp/dist/protocol/content.js.map +1 -1
  1024. package/node_modules/@earendil-works/pi-mcp/dist/transports/streamable-http.d.ts +9 -2
  1025. package/node_modules/@earendil-works/pi-mcp/dist/transports/streamable-http.d.ts.map +1 -1
  1026. package/node_modules/@earendil-works/pi-mcp/dist/transports/streamable-http.js +28 -19
  1027. package/node_modules/@earendil-works/pi-mcp/dist/transports/streamable-http.js.map +1 -1
  1028. package/node_modules/@earendil-works/pi-mcp/dist/transports/transport.d.ts +9 -1
  1029. package/node_modules/@earendil-works/pi-mcp/dist/transports/transport.d.ts.map +1 -1
  1030. package/node_modules/@earendil-works/pi-mcp/dist/transports/transport.js.map +1 -1
  1031. package/node_modules/@earendil-works/pi-mcp/package.json +2 -2
  1032. package/node_modules/@earendil-works/pi-telemetry/package.json +1 -1
  1033. package/node_modules/@earendil-works/pi-tui/README.md +5 -3
  1034. package/node_modules/@earendil-works/pi-tui/dist/components/box.d.ts +1 -0
  1035. package/node_modules/@earendil-works/pi-tui/dist/components/box.d.ts.map +1 -1
  1036. package/node_modules/@earendil-works/pi-tui/dist/components/box.js +4 -0
  1037. package/node_modules/@earendil-works/pi-tui/dist/components/box.js.map +1 -1
  1038. package/node_modules/@earendil-works/pi-tui/dist/components/editor.d.ts.map +1 -1
  1039. package/node_modules/@earendil-works/pi-tui/dist/components/editor.js +3 -3
  1040. package/node_modules/@earendil-works/pi-tui/dist/components/editor.js.map +1 -1
  1041. package/node_modules/@earendil-works/pi-tui/dist/components/input.d.ts.map +1 -1
  1042. package/node_modules/@earendil-works/pi-tui/dist/components/input.js +4 -4
  1043. package/node_modules/@earendil-works/pi-tui/dist/components/input.js.map +1 -1
  1044. package/node_modules/@earendil-works/pi-tui/dist/components/text.d.ts +1 -0
  1045. package/node_modules/@earendil-works/pi-tui/dist/components/text.d.ts.map +1 -1
  1046. package/node_modules/@earendil-works/pi-tui/dist/components/text.js +4 -0
  1047. package/node_modules/@earendil-works/pi-tui/dist/components/text.js.map +1 -1
  1048. package/node_modules/@earendil-works/pi-tui/dist/index.d.ts +2 -1
  1049. package/node_modules/@earendil-works/pi-tui/dist/index.d.ts.map +1 -1
  1050. package/node_modules/@earendil-works/pi-tui/dist/index.js +3 -1
  1051. package/node_modules/@earendil-works/pi-tui/dist/index.js.map +1 -1
  1052. package/node_modules/@earendil-works/pi-tui/dist/keybindings.d.ts +4 -4
  1053. package/node_modules/@earendil-works/pi-tui/dist/keybindings.d.ts.map +1 -1
  1054. package/node_modules/@earendil-works/pi-tui/dist/keybindings.js +4 -4
  1055. package/node_modules/@earendil-works/pi-tui/dist/keybindings.js.map +1 -1
  1056. package/node_modules/@earendil-works/pi-tui/dist/keys.d.ts.map +1 -1
  1057. package/node_modules/@earendil-works/pi-tui/dist/keys.js +52 -20
  1058. package/node_modules/@earendil-works/pi-tui/dist/keys.js.map +1 -1
  1059. package/node_modules/@earendil-works/pi-tui/dist/program-status.d.ts +23 -0
  1060. package/node_modules/@earendil-works/pi-tui/dist/program-status.d.ts.map +1 -0
  1061. package/node_modules/@earendil-works/pi-tui/dist/program-status.js +43 -0
  1062. package/node_modules/@earendil-works/pi-tui/dist/program-status.js.map +1 -0
  1063. package/node_modules/@earendil-works/pi-tui/dist/stdin-buffer.d.ts +4 -2
  1064. package/node_modules/@earendil-works/pi-tui/dist/stdin-buffer.d.ts.map +1 -1
  1065. package/node_modules/@earendil-works/pi-tui/dist/stdin-buffer.js +36 -1
  1066. package/node_modules/@earendil-works/pi-tui/dist/stdin-buffer.js.map +1 -1
  1067. package/node_modules/@earendil-works/pi-tui/dist/terminal-image.d.ts.map +1 -1
  1068. package/node_modules/@earendil-works/pi-tui/dist/terminal-image.js +5 -0
  1069. package/node_modules/@earendil-works/pi-tui/dist/terminal-image.js.map +1 -1
  1070. package/node_modules/@earendil-works/pi-tui/dist/terminal.d.ts +17 -0
  1071. package/node_modules/@earendil-works/pi-tui/dist/terminal.d.ts.map +1 -1
  1072. package/node_modules/@earendil-works/pi-tui/dist/terminal.js +46 -2
  1073. package/node_modules/@earendil-works/pi-tui/dist/terminal.js.map +1 -1
  1074. package/node_modules/@earendil-works/pi-tui/dist/tui-alt-screen.d.ts +2 -0
  1075. package/node_modules/@earendil-works/pi-tui/dist/tui-alt-screen.d.ts.map +1 -1
  1076. package/node_modules/@earendil-works/pi-tui/dist/tui-alt-screen.js +8 -4
  1077. package/node_modules/@earendil-works/pi-tui/dist/tui-alt-screen.js.map +1 -1
  1078. package/node_modules/@earendil-works/pi-tui/dist/tui-main-screen.d.ts.map +1 -1
  1079. package/node_modules/@earendil-works/pi-tui/dist/tui-main-screen.js +2 -1
  1080. package/node_modules/@earendil-works/pi-tui/dist/tui-main-screen.js.map +1 -1
  1081. package/node_modules/@earendil-works/pi-tui/dist/tui.d.ts +11 -0
  1082. package/node_modules/@earendil-works/pi-tui/dist/tui.d.ts.map +1 -1
  1083. package/node_modules/@earendil-works/pi-tui/dist/tui.js +23 -1
  1084. package/node_modules/@earendil-works/pi-tui/dist/tui.js.map +1 -1
  1085. package/node_modules/@earendil-works/pi-tui/dist/utils.d.ts.map +1 -1
  1086. package/node_modules/@earendil-works/pi-tui/dist/utils.js +5 -2
  1087. package/node_modules/@earendil-works/pi-tui/dist/utils.js.map +1 -1
  1088. package/node_modules/@earendil-works/pi-tui/package.json +1 -1
  1089. package/node_modules/@silvia-odwyer/photon/LICENSE.md +201 -0
  1090. package/node_modules/@silvia-odwyer/photon/README.md +158 -0
  1091. package/node_modules/@silvia-odwyer/photon/package.json +23 -0
  1092. package/node_modules/@silvia-odwyer/photon/photon_rs.d.ts +3443 -0
  1093. package/node_modules/@silvia-odwyer/photon/photon_rs.js +4572 -0
  1094. package/node_modules/@silvia-odwyer/photon/photon_rs_bg.wasm +0 -0
  1095. package/node_modules/@types/node/README.md +1 -1
  1096. package/node_modules/@types/node/crypto.d.ts +2 -2
  1097. package/node_modules/@types/node/dgram.d.ts +1 -1
  1098. package/node_modules/@types/node/package.json +2 -2
  1099. package/node_modules/@types/node/util.d.ts +6 -3
  1100. package/node_modules/@types/node/zlib.d.ts +6 -0
  1101. package/package.json +7 -8
  1102. package/runtime-package.json +7 -9
  1103. package/scripts/check-install-toolchain.mjs +64 -40
  1104. package/shipping-sbom.cdx.json +126 -160
  1105. package/shipping-source.json +15 -15
  1106. package/node_modules/@earendil-works/chord/dist/api.d.ts +0 -20
  1107. package/node_modules/@earendil-works/chord/dist/api.d.ts.map +0 -1
  1108. package/node_modules/@earendil-works/chord/dist/api.js +0 -77
  1109. package/node_modules/@earendil-works/chord/dist/api.js.map +0 -1
  1110. package/node_modules/@earendil-works/chord/dist/bundler.d.ts +0 -6
  1111. package/node_modules/@earendil-works/chord/dist/bundler.d.ts.map +0 -1
  1112. package/node_modules/@earendil-works/chord/dist/bundler.js +0 -3
  1113. package/node_modules/@earendil-works/chord/dist/bundler.js.map +0 -1
  1114. package/node_modules/@earendil-works/chord/dist/facets/host.d.ts +0 -12
  1115. package/node_modules/@earendil-works/chord/dist/facets/host.d.ts.map +0 -1
  1116. package/node_modules/@earendil-works/chord/dist/facets/host.js +0 -763
  1117. package/node_modules/@earendil-works/chord/dist/facets/host.js.map +0 -1
  1118. package/node_modules/@earendil-works/chord/dist/facets/loader.d.ts +0 -3
  1119. package/node_modules/@earendil-works/chord/dist/facets/loader.d.ts.map +0 -1
  1120. package/node_modules/@earendil-works/chord/dist/facets/loader.js +0 -5
  1121. package/node_modules/@earendil-works/chord/dist/facets/loader.js.map +0 -1
  1122. package/node_modules/@earendil-works/chord/dist/node/bundle-loader.d.ts +0 -30
  1123. package/node_modules/@earendil-works/chord/dist/node/bundle-loader.d.ts.map +0 -1
  1124. package/node_modules/@earendil-works/chord/dist/node/bundle-loader.js +0 -377
  1125. package/node_modules/@earendil-works/chord/dist/node/bundle-loader.js.map +0 -1
  1126. package/node_modules/@earendil-works/chord/dist/node/bundle.d.ts +0 -26
  1127. package/node_modules/@earendil-works/chord/dist/node/bundle.d.ts.map +0 -1
  1128. package/node_modules/@earendil-works/chord/dist/node/bundle.js +0 -183
  1129. package/node_modules/@earendil-works/chord/dist/node/bundle.js.map +0 -1
  1130. package/node_modules/@earendil-works/chord/dist/node/manifest.d.ts +0 -36
  1131. package/node_modules/@earendil-works/chord/dist/node/manifest.d.ts.map +0 -1
  1132. package/node_modules/@earendil-works/chord/dist/node/manifest.js +0 -6
  1133. package/node_modules/@earendil-works/chord/dist/node/manifest.js.map +0 -1
  1134. package/node_modules/@earendil-works/chord/dist/node/package.d.ts +0 -15
  1135. package/node_modules/@earendil-works/chord/dist/node/package.d.ts.map +0 -1
  1136. package/node_modules/@earendil-works/chord/dist/node/package.js +0 -199
  1137. package/node_modules/@earendil-works/chord/dist/node/package.js.map +0 -1
  1138. package/node_modules/@earendil-works/chord/dist/services/consumer.d.ts +0 -11
  1139. package/node_modules/@earendil-works/chord/dist/services/consumer.d.ts.map +0 -1
  1140. package/node_modules/@earendil-works/chord/dist/services/consumer.js +0 -585
  1141. package/node_modules/@earendil-works/chord/dist/services/consumer.js.map +0 -1
  1142. package/node_modules/@earendil-works/chord/dist/services/errors.d.ts +0 -8
  1143. package/node_modules/@earendil-works/chord/dist/services/errors.d.ts.map +0 -1
  1144. package/node_modules/@earendil-works/chord/dist/services/errors.js +0 -22
  1145. package/node_modules/@earendil-works/chord/dist/services/errors.js.map +0 -1
  1146. package/node_modules/@earendil-works/chord/dist/services/handle.d.ts +0 -15
  1147. package/node_modules/@earendil-works/chord/dist/services/handle.d.ts.map +0 -1
  1148. package/node_modules/@earendil-works/chord/dist/services/handle.js +0 -101
  1149. package/node_modules/@earendil-works/chord/dist/services/handle.js.map +0 -1
  1150. package/node_modules/@earendil-works/chord/dist/services/instances.d.ts +0 -26
  1151. package/node_modules/@earendil-works/chord/dist/services/instances.d.ts.map +0 -1
  1152. package/node_modules/@earendil-works/chord/dist/services/instances.js +0 -140
  1153. package/node_modules/@earendil-works/chord/dist/services/instances.js.map +0 -1
  1154. package/node_modules/@earendil-works/chord/dist/services/loopback.d.ts +0 -5
  1155. package/node_modules/@earendil-works/chord/dist/services/loopback.d.ts.map +0 -1
  1156. package/node_modules/@earendil-works/chord/dist/services/loopback.js +0 -15
  1157. package/node_modules/@earendil-works/chord/dist/services/loopback.js.map +0 -1
  1158. package/node_modules/@earendil-works/chord/dist/services/provider.d.ts +0 -37
  1159. package/node_modules/@earendil-works/chord/dist/services/provider.d.ts.map +0 -1
  1160. package/node_modules/@earendil-works/chord/dist/services/provider.js +0 -521
  1161. package/node_modules/@earendil-works/chord/dist/services/provider.js.map +0 -1
  1162. package/node_modules/@earendil-works/chord/dist/services/state-codec.d.ts +0 -15
  1163. package/node_modules/@earendil-works/chord/dist/services/state-codec.d.ts.map +0 -1
  1164. package/node_modules/@earendil-works/chord/dist/services/state-codec.js +0 -133
  1165. package/node_modules/@earendil-works/chord/dist/services/state-codec.js.map +0 -1
  1166. package/node_modules/@earendil-works/chord/dist/services/state-internals.d.ts +0 -13
  1167. package/node_modules/@earendil-works/chord/dist/services/state-internals.d.ts.map +0 -1
  1168. package/node_modules/@earendil-works/chord/dist/services/state-internals.js +0 -10
  1169. package/node_modules/@earendil-works/chord/dist/services/state-internals.js.map +0 -1
  1170. package/node_modules/@earendil-works/chord/dist/services/state.d.ts +0 -28
  1171. package/node_modules/@earendil-works/chord/dist/services/state.d.ts.map +0 -1
  1172. package/node_modules/@earendil-works/chord/dist/services/state.js.map +0 -1
  1173. package/node_modules/@earendil-works/chord/dist/services/wire.d.ts +0 -63
  1174. package/node_modules/@earendil-works/chord/dist/services/wire.d.ts.map +0 -1
  1175. package/node_modules/@earendil-works/chord/dist/services/wire.js +0 -186
  1176. package/node_modules/@earendil-works/chord/dist/services/wire.js.map +0 -1
  1177. package/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.d.ts +0 -3
  1178. package/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.d.ts.map +0 -1
  1179. package/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.js +0 -14
  1180. package/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.js.map +0 -1
  1181. package/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.models.d.ts +0 -6
  1182. package/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.models.d.ts.map +0 -1
  1183. package/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.models.js +0 -8
  1184. package/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.models.js.map +0 -1
  1185. package/node_modules/@earendil-works/pi-ai/dist/providers/data/azure-openai-responses.json +0 -1
  1186. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/anthropic-messages-MVG2FL56.js +0 -6
  1187. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/azure-openai-responses-7AMFUIWJ.js +0 -2
  1188. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/chunk-6FX7UEPL.js +0 -132
  1189. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/chunk-7JGR3GZN.js +0 -11
  1190. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/chunk-A3JYRWB6.js +0 -2
  1191. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/chunk-IKZJX7ZT.js +0 -2
  1192. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/chunk-OSKPX3Z5.js +0 -2
  1193. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/chunk-OYBSLV7Y.js +0 -16
  1194. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/chunk-PDFMCAOZ.js +0 -19
  1195. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/chunk-U7B62NSC.js +0 -2
  1196. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/chunk-VIV3CWXG.js +0 -2
  1197. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/chunk-WCQZGZ6I.js +0 -82
  1198. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/cloudflare-workers-ai-system-one-X5PVWWYJ.js +0 -2
  1199. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/easter-egg-3d-T5FFWIBR.js +0 -2
  1200. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/execute-RYVK27GT.js +0 -388
  1201. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/mistral-conversations-7DAUEE4N.js +0 -5
  1202. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/openai-codex-responses-TC3OK7B4.js +0 -10
  1203. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/runtime-D5I2NTIF.js +0 -2
  1204. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/typesafe-system-one-A4CZTQWZ.js +0 -2
  1205. package/node_modules/@earendil-works/pi-coding-agent/dist/bundle/chunks/virtual-modules-KVWJD3T3.js +0 -2
  1206. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/theme/theme-json.d.ts +0 -85
  1207. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/theme/theme-json.d.ts.map +0 -1
  1208. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/theme/theme-json.js +0 -132
  1209. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/theme/theme-json.js.map +0 -1
  1210. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/theme/theme-schema.json +0 -361
  1211. package/node_modules/@earendil-works/pi-coding-agent/examples/plugins/pi-example-plugin/README.md +0 -38
  1212. package/node_modules/@earendil-works/pi-coding-agent/examples/plugins/pi-example-plugin/package.json +0 -10
  1213. package/node_modules/@earendil-works/pi-coding-agent/examples/plugins/pi-example-plugin/src/contract.ts +0 -13
  1214. package/node_modules/@earendil-works/pi-coding-agent/examples/plugins/pi-example-plugin/src/session.ts +0 -24
  1215. package/node_modules/@earendil-works/pi-coding-agent/examples/plugins/pi-example-plugin/src/tui.ts +0 -31
  1216. package/node_modules/@esbuild/linux-x64/README.md +0 -3
  1217. package/node_modules/@esbuild/linux-x64/bin/esbuild +0 -0
  1218. package/node_modules/@esbuild/linux-x64/package.json +0 -20
  1219. package/node_modules/esbuild/LICENSE.md +0 -21
  1220. package/node_modules/esbuild/README.md +0 -3
  1221. package/node_modules/esbuild/bin/esbuild +0 -223
  1222. package/node_modules/esbuild/install.js +0 -300
  1223. package/node_modules/esbuild/lib/main.d.ts +0 -720
  1224. package/node_modules/esbuild/lib/main.js +0 -2536
  1225. package/node_modules/esbuild/package.json +0 -74
@@ -10,6 +10,19 @@ import { parseClientInformation, parseOAuthTokens, } from "./types.js";
10
10
  function loopback(hostname) {
11
11
  return hostname === "localhost" || hostname === "127.0.0.1" || hostname === "[::1]" || hostname === "::1";
12
12
  }
13
+ /**
14
+ * The OpenID Connect `application_type` for `redirect_uris` (MCP SEP-837). Without one, OpenID Connect servers
15
+ * assume `web`, which rejects http loopback redirect URIs. Loopback hosts and custom schemes are native (RFC 8252).
16
+ */
17
+ function applicationType(redirectUris) {
18
+ const native = redirectUris.some((uri) => {
19
+ if (!URL.canParse(uri))
20
+ return false;
21
+ const url = new URL(uri);
22
+ return (url.protocol !== "http:" && url.protocol !== "https:") || loopback(url.hostname);
23
+ });
24
+ return native ? "native" : "web";
25
+ }
13
26
  function secureEndpoint(value) {
14
27
  const url = new URL(value);
15
28
  if (url.protocol !== "https:" && !loopback(url.hostname))
@@ -87,7 +100,12 @@ async function tokenRequest(authorizationServerUrl, options, params) {
87
100
  else {
88
101
  applyClientAuthentication(selectClientAuthMethod(options.clientInformation, options.metadata?.token_endpoint_auth_methods_supported ?? []), options.clientInformation, headers, params);
89
102
  }
90
- const response = await (options.fetch ?? globalThis.fetch)(url, { method: "POST", headers, body: params });
103
+ const response = await (options.fetch ?? globalThis.fetch)(url, {
104
+ method: "POST",
105
+ headers,
106
+ body: params,
107
+ signal: options.signal,
108
+ });
91
109
  const text = await response.text();
92
110
  let value;
93
111
  try {
@@ -109,7 +127,12 @@ export async function registerClient(authorizationServerUrl, options) {
109
127
  const response = await (options.fetch ?? globalThis.fetch)(new URL(endpoint ?? new URL("/register", authorizationServerUrl)), {
110
128
  method: "POST",
111
129
  headers: { Accept: "application/json", "content-type": "application/json" },
112
- body: JSON.stringify({ ...options.clientMetadata, ...(options.scope ? { scope: options.scope } : {}) }),
130
+ body: JSON.stringify({
131
+ ...options.clientMetadata,
132
+ application_type: options.clientMetadata.application_type ?? applicationType(options.clientMetadata.redirect_uris),
133
+ ...(options.scope ? { scope: options.scope } : {}),
134
+ }),
135
+ signal: options.signal,
113
136
  });
114
137
  if (!response.ok)
115
138
  throw new OAuthRegistrationError(response.status, await response.text());
@@ -152,6 +175,7 @@ async function runFlow(provider, options) {
152
175
  (await discoverAuthorizationServerMetadata(cached.authorizationServerUrl, {
153
176
  fetch: options.fetch,
154
177
  skipIssuerValidation: options.skipIssuerValidation,
178
+ signal: options.signal,
155
179
  })),
156
180
  resourceMetadata: cached.resourceMetadata,
157
181
  }
@@ -160,6 +184,7 @@ async function runFlow(provider, options) {
160
184
  authorizationServerMetadataUrl: metadataUrl,
161
185
  fetch: options.fetch,
162
186
  skipIssuerValidation: options.skipIssuerValidation,
187
+ signal: options.signal,
163
188
  });
164
189
  if (!metadataUrl) {
165
190
  await provider.saveDiscoveryState?.({
@@ -189,6 +214,7 @@ async function runFlow(provider, options) {
189
214
  clientMetadata: provider.clientMetadata,
190
215
  scope,
191
216
  fetch: options.fetch,
217
+ signal: options.signal,
192
218
  });
193
219
  await provider.saveClientInformation(client);
194
220
  }
@@ -200,13 +226,15 @@ async function runFlow(provider, options) {
200
226
  resource,
201
227
  addClientAuthentication: provider.addClientAuthentication,
202
228
  fetch: options.fetch,
229
+ signal: options.signal,
203
230
  };
204
231
  if (options.authorizationCode) {
205
- // RFC 9207: never send a code from another authorization server to this one.
232
+ // RFC 9207: never send a code from another authorization server to this one. Without metadata there
233
+ // is no issuer to compare with, so any `iss` is rejected.
206
234
  const iss = options.iss;
207
- if (metadata && (iss !== undefined || metadata.authorization_response_iss_parameter_supported)) {
208
- if (iss !== metadata.issuer)
209
- throw new OAuthIssuerMismatchError(metadata.issuer, iss);
235
+ if (iss !== undefined || metadata?.authorization_response_iss_parameter_supported) {
236
+ if (iss !== metadata?.issuer)
237
+ throw new OAuthIssuerMismatchError(metadata?.issuer, iss);
210
238
  }
211
239
  const tokens = await exchangeAuthorizationCode(discovered.authorizationServerUrl, {
212
240
  ...tokenOptions,
@@ -231,7 +259,7 @@ async function runFlow(provider, options) {
231
259
  return "AUTHORIZED";
232
260
  }
233
261
  catch (error) {
234
- if (error instanceof OAuthInsecureEndpointError)
262
+ if (options.signal?.aborted || error instanceof OAuthInsecureEndpointError)
235
263
  throw error;
236
264
  if (error instanceof OAuthError && error.code !== "server_error")
237
265
  throw error;
@@ -1 +1 @@
1
- {"version":3,"file":"flow.js","sourceRoot":"","sources":["../../src/oauth/flow.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EACN,mCAAmC,EACnC,uBAAuB,EACvB,oBAAoB,EACpB,cAAc,GACd,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACN,kCAAkC,EAClC,UAAU,EACV,0BAA0B,EAC1B,wBAAwB,EACxB,sBAAsB,GACtB,MAAM,aAAa,CAAC;AACrB,OAAO,EAQN,sBAAsB,EACtB,gBAAgB,GAChB,MAAM,YAAY,CAAC;AAsEpB,SAAS,QAAQ,CAAC,QAAgB;IACjC,OAAO,QAAQ,KAAK,WAAW,IAAI,QAAQ,KAAK,WAAW,IAAI,QAAQ,KAAK,OAAO,IAAI,QAAQ,KAAK,KAAK,CAAC;AAC3G,CAAC;AAED,SAAS,cAAc,CAAC,KAAmB;IAC1C,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC;IAC3B,IAAI,GAAG,CAAC,QAAQ,KAAK,QAAQ,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC;QAAE,MAAM,IAAI,0BAA0B,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACzG,OAAO,GAAG,CAAC;AACZ,CAAC;AAED,SAAS,sB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AAC,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;iBAC7E,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CACjB,YAAY,CAAC,QAAQ,EAAE;gBACtB,SAAS,EAAE,OAAO,CAAC,SAAS;gBAC5B,mBAAmB,EAAE,SAAS,CAAC,mBAAmB;gBAClD,KAAK,EAAE,iBAAiB,CAAC,CAAC,CAAC,WAAW,CAAC,OAAO,EAAE,KAAK,EAAE,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK;gBACzF,KAAK,EAAE,OAAO,CAAC,KAAK;gBACpB,WAAW,EAAE,iBAAiB;aAC9B,CAAC,CACF;iBACA,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE;gBAChB,IAAI,MAAM,KAAK,UAAU;oBAAE,MAAM,IAAI,kCAAkC,EAAE,CAAC;YAC3E,CAAC,CAAC;iBACD,OAAO,CAAC,GAAG,EAAE;gBACb,QAAQ,GAAG,SAAS,CAAC;YACtB,CAAC,CAAC,CAAC;YACJ,MAAM,QAAQ,CAAC;QAChB,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["/*\n * Adapted from modelcontextprotocol/typescript-sdk v1.29.0 src/client/auth.ts.\n * Copyright (c) 2024 Anthropic, PBC. Licensed under MIT; see LICENSES/.\n * Modified to remove SDK/Zod dependencies and use WebCrypto for PKCE.\n */\n\nimport type { AuthProvider, McpFetch, UnauthorizedContext } from \"../auth-provider.ts\";\nimport { isObject } from \"../protocol/jsonrpc.ts\";\nimport {\n\tdiscoverAuthorizationServerMetadata,\n\tdiscoverOAuthServerInfo,\n\tparseWwwAuthenticate,\n\tselectResource,\n} from \"./discovery.ts\";\nimport {\n\tMcpOAuthAuthorizationRequiredError,\n\tOAuthError,\n\tOAuthInsecureEndpointError,\n\tOAuthIssuerMismatchError,\n\tOAuthRegistrationError,\n} from \"./errors.ts\";\nimport {\n\ttype AuthorizationServerMetadata,\n\ttype OAuthClientInformation,\n\ttype OAuthClientInformationFull,\n\ttype OAuthClientInformationMixed,\n\ttype OAuthClientMetadata,\n\ttype OAuthDiscoveryState,\n\ttype OAuthTokens,\n\tparseClientInformation,\n\tparseOAuthTokens,\n} from \"./types.ts\";\n\nexport type AddClientAuthentication = (\n\theaders: Headers,\n\tparams: URLSearchParams,\n\turl: string | URL,\n\tmetadata?: AuthorizationServerMetadata,\n) => void | Promise<void>;\n\n/** A Client ID Metadata Document: an https URL used as `client_id`, and a redirect URI it lists. */\nexport interface OAuthClientMetadataDocument {\n\turl: string;\n\tredirectUrl: string;\n}\n\nexport interface OAuthClientProvider {\n\treadonly redirectUrl: string | URL;\n\treadonly clientMetadata: OAuthClientMetadata;\n\t/**\n\t * Client ID Metadata Document to identify as instead of registering dynamically, or `undefined` to\n\t * register. Called when no client information is stored; the document is not stored. `metadata` is\n\t * `undefined` when the authorization server has none; check `client_id_metadata_document_supported`.\n\t */\n\tclientMetadataDocument?(metadata: AuthorizationServerMetadata | undefined): OAuthClientMetadataDocument | undefined;\n\tstate?(): string | Promise<string>;\n\tclientInformation(): OAuthClientInformationMixed | undefined | Promise<OAuthClientInformationMixed | undefined>;\n\tsaveClientInformation?(information: OAuthClientInformationMixed): void | Promise<void>;\n\ttokens(): OAuthTokens | undefined | Promise<OAuthTokens | undefined>;\n\tsaveTokens(tokens: OAuthTokens): void | Promise<void>;\n\tredirectToAuthorization(url: URL): void | Promise<void>;\n\tsaveCodeVerifier(verifier: string): void | Promise<void>;\n\tcodeVerifier(): string | Promise<string>;\n\taddClientAuthentication?: AddClientAuthentication;\n\tinvalidateCredentials?(kind: \"all\" | \"client\" | \"tokens\" | \"verifier\" | \"discovery\"): void | Promise<void>;\n\tsaveDiscoveryState?(state: OAuthDiscoveryState): void | Promise<void>;\n\tdiscoveryState?(): OAuthDiscoveryState | undefined | Promise<OAuthDiscoveryState | undefined>;\n}\n\nexport interface OAuthFlowOptions {\n\tserverUrl: string | URL;\n\tauthorizationCode?: string;\n\t/** `iss` parameter of the authorization response that delivered `authorizationCode` (RFC 9207). */\n\tiss?: string;\n\tscope?: string;\n\tresourceMetadataUrl?: URL;\n\t/**\n\t * Authorization server metadata document to use instead of discovery, for servers that advertise a\n\t * wrong authorization server or none. It is trusted as configured. Must use https, except on loopback.\n\t */\n\tauthorizationServerMetadataUrl?: URL;\n\tfetch?: McpFetch;\n\tskipIssuerValidation?: boolean;\n\t/**\n\t * Go straight to the authorization redirect instead of refreshing stored tokens, for example when the\n\t * server asks for scopes the current grant lacks (a refresh keeps the old scope).\n\t */\n\tskipRefresh?: boolean;\n}\n\nexport type OAuthFlowResult = \"AUTHORIZED\" | \"REDIRECT\";\ntype ClientAuthMethod = \"client_secret_basic\" | \"client_secret_post\" | \"none\";\n\nexport interface TokenRequestOptions {\n\tmetadata?: AuthorizationServerMetadata;\n\tclientInformation: OAuthClientInformationMixed;\n\tresource?: string;\n\taddClientAuthentication?: AddClientAuthentication;\n\tfetch?: McpFetch;\n}\n\nfunction loopback(hostname: string): boolean {\n\treturn hostname === \"localhost\" || hostname === \"127.0.0.1\" || hostname === \"[::1]\" || hostname === \"::1\";\n}\n\nfunction secureEndpoint(value: string | URL): URL {\n\tconst url = new URL(value);\n\tif (url.protocol !== \"https:\" && !loopback(url.hostname)) throw new OAuthInsecureEndpointError(url.href);\n\treturn url;\n}\n\nfunction selectClientAuthMethod(information: OAuthClientInformationMixed, supported: string[]): ClientAuthMethod {\n\tconst hinted = \"token_endpoint_auth_method\" in information ? information.token_endpoint_auth_method : undefined;\n\tif (\n\t\thinted &&\n\t\t[\"client_secret_basic\", \"client_secret_post\", \"none\"].includes(hinted) &&\n\t\t(supported.length === 0 || supported.includes(hinted))\n\t) {\n\t\treturn hinted as ClientAuthMethod;\n\t}\n\tif (supported.length === 0) return information.client_secret ? \"client_secret_basic\" : \"none\";\n\tif (information.client_secret && supported.includes(\"client_secret_basic\")) return \"client_secret_basic\";\n\tif (information.client_secret && supported.includes(\"client_secret_post\")) return \"client_secret_post\";\n\tif (supported.includes(\"none\")) return \"none\";\n\treturn information.client_secret ? \"client_secret_post\" : \"none\";\n}\n\nfunction applyClientAuthentication(\n\tmethod: ClientAuthMethod,\n\tinformation: OAuthClientInformation,\n\theaders: Headers,\n\tparams: URLSearchParams,\n): void {\n\tif (method === \"client_secret_basic\") {\n\t\tif (!information.client_secret) throw new Error(\"client_secret_basic requires a client secret\");\n\t\theaders.set(\n\t\t\t\"Authorization\",\n\t\t\t`Basic ${Buffer.from(`${information.client_id}:${information.client_secret}`).toString(\"base64\")}`,\n\t\t);\n\t} else {\n\t\tparams.set(\"client_id\", information.client_id);\n\t\tif (method === \"client_secret_post\" && information.client_secret)\n\t\t\tparams.set(\"client_secret\", information.client_secret);\n\t}\n}\n\nasync function pkce(): Promise<{ verifier: string; challenge: string }> {\n\tconst bytes = crypto.getRandomValues(new Uint8Array(32));\n\tconst verifier = Buffer.from(bytes).toString(\"base64url\");\n\tconst digest = await crypto.subtle.digest(\"SHA-256\", new TextEncoder().encode(verifier));\n\treturn { verifier, challenge: Buffer.from(digest).toString(\"base64url\") };\n}\n\nexport async function startAuthorization(\n\tauthorizationServerUrl: string | URL,\n\toptions: {\n\t\tmetadata?: AuthorizationServerMetadata;\n\t\tclientInformation: OAuthClientInformationMixed;\n\t\tredirectUrl: string | URL;\n\t\tscope?: string;\n\t\tstate?: string;\n\t\tresource?: string;\n\t},\n): Promise<{ authorizationUrl: URL; codeVerifier: string }> {\n\tconst metadata = options.metadata;\n\tif (metadata && !metadata.response_types_supported.includes(\"code\")) {\n\t\tthrow new Error(\"Authorization server does not support authorization codes\");\n\t}\n\tif (metadata?.code_challenge_methods_supported && !metadata.code_challenge_methods_supported.includes(\"S256\")) {\n\t\tthrow new Error(\"Authorization server does not support PKCE S256\");\n\t}\n\tconst url = new URL(metadata?.authorization_endpoint ?? new URL(\"/authorize\", authorizationServerUrl));\n\tconst { verifier, challenge } = await pkce();\n\turl.searchParams.set(\"response_type\", \"code\");\n\turl.searchParams.set(\"client_id\", options.clientInformation.client_id);\n\turl.searchParams.set(\"code_challenge\", challenge);\n\turl.searchParams.set(\"code_challenge_method\", \"S256\");\n\turl.searchParams.set(\"redirect_uri\", String(options.redirectUrl));\n\tif (options.state) url.searchParams.set(\"state\", options.state);\n\tif (options.scope) url.searchParams.set(\"scope\", options.scope);\n\tif (options.scope?.split(/\\s+/).includes(\"offline_access\")) url.searchParams.set(\"prompt\", \"consent\");\n\tif (options.resource) url.searchParams.set(\"resource\", options.resource);\n\treturn { authorizationUrl: url, codeVerifier: verifier };\n}\n\nasync function tokenRequest(\n\tauthorizationServerUrl: string | URL,\n\toptions: TokenRequestOptions,\n\tparams: URLSearchParams,\n): Promise<OAuthTokens> {\n\tconst url = secureEndpoint(options.metadata?.token_endpoint ?? new URL(\"/token\", authorizationServerUrl));\n\tconst headers = new Headers({ Accept: \"application/json\", \"content-type\": \"application/x-www-form-urlencoded\" });\n\tif (options.resource) params.set(\"resource\", options.resource);\n\tif (options.addClientAuthentication) {\n\t\tawait options.addClientAuthentication(headers, params, url, options.metadata);\n\t} else {\n\t\tapplyClientAuthentication(\n\t\t\tselectClientAuthMethod(\n\t\t\t\toptions.clientInformation,\n\t\t\t\toptions.metadata?.token_endpoint_auth_methods_supported ?? [],\n\t\t\t),\n\t\t\toptions.clientInformation,\n\t\t\theaders,\n\t\t\tparams,\n\t\t);\n\t}\n\tconst response = await (options.fetch ?? globalThis.fetch)(url, { method: \"POST\", headers, body: params });\n\tconst text = await response.text();\n\tlet value: unknown;\n\ttry {\n\t\tvalue = JSON.parse(text);\n\t} catch {}\n\t// Servers may report OAuth errors with any status, so check the body before the status.\n\tif (isObject(value) && typeof value.error === \"string\") {\n\t\tthrow new OAuthError(\n\t\t\tvalue.error,\n\t\t\ttypeof value.error_description === \"string\" ? value.error_description : value.error,\n\t\t\ttypeof value.error_uri === \"string\" ? value.error_uri : undefined,\n\t\t);\n\t}\n\tif (!response.ok) throw new OAuthError(\"server_error\", `HTTP ${response.status}: ${text}`);\n\treturn parseOAuthTokens(value);\n}\n\nexport async function registerClient(\n\tauthorizationServerUrl: string | URL,\n\toptions: {\n\t\tmetadata?: AuthorizationServerMetadata;\n\t\tclientMetadata: OAuthClientMetadata;\n\t\tscope?: string;\n\t\tfetch?: McpFetch;\n\t},\n): Promise<OAuthClientInformationFull> {\n\tconst endpoint = options.metadata?.registration_endpoint;\n\tif (options.metadata && !endpoint)\n\t\tthrow new Error(\"Authorization server does not support dynamic client registration\");\n\tconst response = await (options.fetch ?? globalThis.fetch)(\n\t\tnew URL(endpoint ?? new URL(\"/register\", authorizationServerUrl)),\n\t\t{\n\t\t\tmethod: \"POST\",\n\t\t\theaders: { Accept: \"application/json\", \"content-type\": \"application/json\" },\n\t\t\tbody: JSON.stringify({ ...options.clientMetadata, ...(options.scope ? { scope: options.scope } : {}) }),\n\t\t},\n\t);\n\tif (!response.ok) throw new OAuthRegistrationError(response.status, await response.text());\n\treturn parseClientInformation(await response.json());\n}\n\nexport async function exchangeAuthorizationCode(\n\tauthorizationServerUrl: string | URL,\n\toptions: TokenRequestOptions & { code: string; codeVerifier: string; redirectUrl: string | URL },\n): Promise<OAuthTokens> {\n\treturn tokenRequest(\n\t\tauthorizationServerUrl,\n\t\toptions,\n\t\tnew URLSearchParams({\n\t\t\tgrant_type: \"authorization_code\",\n\t\t\tcode: options.code,\n\t\t\tcode_verifier: options.codeVerifier,\n\t\t\tredirect_uri: String(options.redirectUrl),\n\t\t}),\n\t);\n}\n\nexport async function refreshAuthorization(\n\tauthorizationServerUrl: string | URL,\n\toptions: TokenRequestOptions & { refreshToken: string },\n): Promise<OAuthTokens> {\n\tconst tokens = await tokenRequest(\n\t\tauthorizationServerUrl,\n\t\toptions,\n\t\tnew URLSearchParams({ grant_type: \"refresh_token\", refresh_token: options.refreshToken }),\n\t);\n\treturn { refresh_token: options.refreshToken, ...tokens };\n}\n\nfunction withScope(tokens: OAuthTokens, scope: string | undefined): OAuthTokens {\n\treturn tokens.scope === undefined && scope ? { ...tokens, scope } : tokens;\n}\n\n/**\n * Scopes for a step-up authorization: the challenged scopes plus the ones granted so far, since a\n * challenge may list only the missing scopes and a token with just those would lose access the old\n * one had (SEP-2350). Without challenged scopes, `undefined` lets the flow pick its default.\n */\nexport function stepUpScope(granted: string | undefined, challenged: string | undefined): string | undefined {\n\tif (!challenged) return undefined;\n\tconst scopes = [granted, challenged].flatMap((scope) => scope?.split(/\\s+/).filter(Boolean) ?? []);\n\treturn [...new Set(scopes)].join(\" \");\n}\n\nasync function runFlow(provider: OAuthClientProvider, options: OAuthFlowOptions): Promise<OAuthFlowResult> {\n\tconst metadataUrl = options.authorizationServerMetadataUrl && secureEndpoint(options.authorizationServerMetadataUrl);\n\t// With a configured metadata URL, discovery is not cached, so changing the URL applies at once.\n\tconst cached = metadataUrl ? undefined : await provider.discoveryState?.();\n\tconst discovered = cached?.authorizationServerUrl\n\t\t? {\n\t\t\t\tauthorizationServerUrl: cached.authorizationServerUrl,\n\t\t\t\tauthorizationServerMetadata:\n\t\t\t\t\tcached.authorizationServerMetadata ??\n\t\t\t\t\t(await discoverAuthorizationServerMetadata(cached.authorizationServerUrl, {\n\t\t\t\t\t\tfetch: options.fetch,\n\t\t\t\t\t\tskipIssuerValidation: options.skipIssuerValidation,\n\t\t\t\t\t})),\n\t\t\t\tresourceMetadata: cached.resourceMetadata,\n\t\t\t}\n\t\t: await discoverOAuthServerInfo(options.serverUrl, {\n\t\t\t\tresourceMetadataUrl: options.resourceMetadataUrl,\n\t\t\t\tauthorizationServerMetadataUrl: metadataUrl,\n\t\t\t\tfetch: options.fetch,\n\t\t\t\tskipIssuerValidation: options.skipIssuerValidation,\n\t\t\t});\n\tif (!metadataUrl) {\n\t\tawait provider.saveDiscoveryState?.({\n\t\t\t...discovered,\n\t\t\t...(options.resourceMetadataUrl ? { resourceMetadataUrl: options.resourceMetadataUrl.href } : {}),\n\t\t});\n\t}\n\tconst metadata = discovered.authorizationServerMetadata;\n\tconst resource = selectResource(options.serverUrl, discovered.resourceMetadata);\n\t// `||`, not `??`: an empty scope (for example from `scopes_supported: []`) falls through to the next source.\n\tconst scope =\n\t\toptions.scope || discovered.resourceMetadata?.scopes_supported?.join(\" \") || provider.clientMetadata.scope;\n\tconst stored = await provider.clientInformation();\n\tconst clientDocument = stored ? undefined : provider.clientMetadataDocument?.(metadata);\n\tif (clientDocument) {\n\t\tconst url = new URL(clientDocument.url);\n\t\tif (url.protocol !== \"https:\" || url.pathname === \"/\") throw new Error(\"Invalid OAuth client metadata URL\");\n\t}\n\tlet client = stored ?? (clientDocument && { client_id: clientDocument.url });\n\tif (!client) {\n\t\tif (options.authorizationCode) throw new Error(\"OAuth client information is missing during code exchange\");\n\t\tif (!provider.saveClientInformation) throw new Error(\"OAuth client information cannot be persisted\");\n\t\tclient = await registerClient(discovered.authorizationServerUrl, {\n\t\t\tmetadata,\n\t\t\tclientMetadata: provider.clientMetadata,\n\t\t\tscope,\n\t\t\tfetch: options.fetch,\n\t\t});\n\t\tawait provider.saveClientInformation(client);\n\t}\n\t// The document's redirect URI may differ from the provider's, for example by a server-specific path.\n\tconst redirectUrl = clientDocument?.redirectUrl ?? provider.redirectUrl;\n\tconst tokenOptions: TokenRequestOptions = {\n\t\tmetadata,\n\t\tclientInformation: client,\n\t\tresource,\n\t\taddClientAuthentication: provider.addClientAuthentication,\n\t\tfetch: options.fetch,\n\t};\n\tif (options.authorizationCode) {\n\t\t// RFC 9207: never send a code from another authorization server to this one.\n\t\tconst iss = options.iss;\n\t\tif (metadata && (iss !== undefined || metadata.authorization_response_iss_parameter_supported)) {\n\t\t\tif (iss !== metadata.issuer) throw new OAuthIssuerMismatchError(metadata.issuer, iss);\n\t\t}\n\t\tconst tokens = await exchangeAuthorizationCode(discovered.authorizationServerUrl, {\n\t\t\t...tokenOptions,\n\t\t\tcode: options.authorizationCode,\n\t\t\tcodeVerifier: await provider.codeVerifier(),\n\t\t\tredirectUrl,\n\t\t});\n\t\t// A response without `scope` grants the requested scope (RFC 6749 §5.1). Recorded so a step-up can\n\t\t// keep it. Callers pass the options of the authorization request, so `scope` is what was requested.\n\t\tawait provider.saveTokens(withScope(tokens, scope));\n\t\treturn \"AUTHORIZED\";\n\t}\n\tconst existing = options.skipRefresh ? undefined : await provider.tokens();\n\tif (existing?.refresh_token) {\n\t\ttry {\n\t\t\tconst tokens = await refreshAuthorization(discovered.authorizationServerUrl, {\n\t\t\t\t...tokenOptions,\n\t\t\t\trefreshToken: existing.refresh_token,\n\t\t\t});\n\t\t\t// A refresh without `scope` keeps the scope of the grant (RFC 6749 §6).\n\t\t\tawait provider.saveTokens(withScope(tokens, existing.scope));\n\t\t\treturn \"AUTHORIZED\";\n\t\t} catch (error) {\n\t\t\tif (error instanceof OAuthInsecureEndpointError) throw error;\n\t\t\tif (error instanceof OAuthError && error.code !== \"server_error\") throw error;\n\t\t}\n\t}\n\tconst state = await provider.state?.();\n\tconst authorization = await startAuthorization(discovered.authorizationServerUrl, {\n\t\tmetadata,\n\t\tclientInformation: client,\n\t\tredirectUrl,\n\t\tscope,\n\t\tstate,\n\t\tresource,\n\t});\n\tawait provider.saveCodeVerifier(authorization.codeVerifier);\n\tawait provider.redirectToAuthorization(authorization.authorizationUrl);\n\treturn \"REDIRECT\";\n}\n\nexport async function authorizeMcp(provider: OAuthClientProvider, options: OAuthFlowOptions): Promise<OAuthFlowResult> {\n\ttry {\n\t\treturn await runFlow(provider, options);\n\t} catch (error) {\n\t\tif (error instanceof OAuthError && [\"invalid_client\", \"unauthorized_client\"].includes(error.code)) {\n\t\t\tawait provider.invalidateCredentials?.(\"all\");\n\t\t\treturn runFlow(provider, options);\n\t\t}\n\t\tif (error instanceof OAuthError && error.code === \"invalid_grant\") {\n\t\t\tawait provider.invalidateCredentials?.(\"tokens\");\n\t\t\treturn runFlow(provider, options);\n\t\t}\n\t\tthrow error;\n\t}\n}\n\n/**\n * Auth provider for `StreamableHttpTransport`. After a 401 it refreshes the tokens, or throws\n * `McpOAuthAuthorizationRequiredError` when the user has to authorize (again). Concurrent 401s share\n * one refresh, and a request whose token was already replaced is just retried: with rotating refresh\n * tokens, a second refresh with the old refresh token would fail and discard the new grant.\n */\nexport function adaptOAuthProvider(provider: OAuthClientProvider): AuthProvider {\n\tlet inFlight: Promise<void> | undefined;\n\treturn {\n\t\ttoken: async () => (await provider.tokens())?.access_token,\n\t\tonUnauthorized: async (context: UnauthorizedContext) => {\n\t\t\tconst challenge = parseWwwAuthenticate(context.response.headers.get(\"www-authenticate\"));\n\t\t\tconst insufficientScope = challenge.error === \"insufficient_scope\";\n\t\t\tif (!insufficientScope && !inFlight && context.token !== undefined) {\n\t\t\t\tconst current = (await provider.tokens())?.access_token;\n\t\t\t\tif (current !== undefined && current !== context.token) return;\n\t\t\t}\n\t\t\tinFlight ??= Promise.resolve(insufficientScope ? provider.tokens() : undefined)\n\t\t\t\t.then((granted) =>\n\t\t\t\t\tauthorizeMcp(provider, {\n\t\t\t\t\t\tserverUrl: context.serverUrl,\n\t\t\t\t\t\tresourceMetadataUrl: challenge.resourceMetadataUrl,\n\t\t\t\t\t\tscope: insufficientScope ? stepUpScope(granted?.scope, challenge.scope) : challenge.scope,\n\t\t\t\t\t\tfetch: context.fetch,\n\t\t\t\t\t\tskipRefresh: insufficientScope,\n\t\t\t\t\t}),\n\t\t\t\t)\n\t\t\t\t.then((result) => {\n\t\t\t\t\tif (result === \"REDIRECT\") throw new McpOAuthAuthorizationRequiredError();\n\t\t\t\t})\n\t\t\t\t.finally(() => {\n\t\t\t\t\tinFlight = undefined;\n\t\t\t\t});\n\t\t\tawait inFlight;\n\t\t},\n\t};\n}\n"]}
1
+ {"version":3,"file":"flow.js","sourceRoot":"","sources":["../../src/oauth/flow.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EACN,mCAAmC,EACnC,uBAAuB,EACvB,oBAAoB,EACpB,cAAc,GACd,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AAI,CAAC,QAAQ,IAAI,OAAO,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;gBACpE,MAAM,OAAO,GAAG,CAAC,MAAM,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,YAAY,CAAC;gBACxD,IAAI,OAAO,KAAK,SAAS,IAAI,OAAO,KAAK,OAAO,CAAC,KAAK;oBAAE,OAAO;YAChE,CAAC;YACD,QAAQ,KAAK,OAAO,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;iBAC7E,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CACjB,YAAY,CAAC,QAAQ,EAAE;gBACtB,SAAS,EAAE,OAAO,CAAC,SAAS;gBAC5B,mBAAmB,EAAE,SAAS,CAAC,mBAAmB;gBAClD,KAAK,EAAE,iBAAiB,CAAC,CAAC,CAAC,WAAW,CAAC,OAAO,EAAE,KAAK,EAAE,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK;gBACzF,KAAK,EAAE,OAAO,CAAC,KAAK;gBACpB,WAAW,EAAE,iBAAiB;aAC9B,CAAC,CACF;iBACA,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE;gBAChB,IAAI,MAAM,KAAK,UAAU;oBAAE,MAAM,IAAI,kCAAkC,EAAE,CAAC;YAC3E,CAAC,CAAC;iBACD,OAAO,CAAC,GAAG,EAAE;gBACb,QAAQ,GAAG,SAAS,CAAC;YACtB,CAAC,CAAC,CAAC;YACJ,MAAM,QAAQ,CAAC;QAChB,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["/*\n * Adapted from modelcontextprotocol/typescript-sdk v1.29.0 src/client/auth.ts.\n * Copyright (c) 2024 Anthropic, PBC. Licensed under MIT; see LICENSES/.\n * Modified to remove SDK/Zod dependencies and use WebCrypto for PKCE.\n */\n\nimport type { AuthProvider, McpFetch, UnauthorizedContext } from \"../auth-provider.ts\";\nimport { isObject } from \"../protocol/jsonrpc.ts\";\nimport {\n\tdiscoverAuthorizationServerMetadata,\n\tdiscoverOAuthServerInfo,\n\tparseWwwAuthenticate,\n\tselectResource,\n} from \"./discovery.ts\";\nimport {\n\tMcpOAuthAuthorizationRequiredError,\n\tOAuthError,\n\tOAuthInsecureEndpointError,\n\tOAuthIssuerMismatchError,\n\tOAuthRegistrationError,\n} from \"./errors.ts\";\nimport {\n\ttype AuthorizationServerMetadata,\n\ttype OAuthClientInformation,\n\ttype OAuthClientInformationFull,\n\ttype OAuthClientInformationMixed,\n\ttype OAuthClientMetadata,\n\ttype OAuthDiscoveryState,\n\ttype OAuthTokens,\n\tparseClientInformation,\n\tparseOAuthTokens,\n} from \"./types.ts\";\n\nexport type AddClientAuthentication = (\n\theaders: Headers,\n\tparams: URLSearchParams,\n\turl: string | URL,\n\tmetadata?: AuthorizationServerMetadata,\n) => void | Promise<void>;\n\n/** A Client ID Metadata Document: an https URL used as `client_id`, and a redirect URI it lists. */\nexport interface OAuthClientMetadataDocument {\n\turl: string;\n\tredirectUrl: string;\n}\n\nexport interface OAuthClientProvider {\n\treadonly redirectUrl: string | URL;\n\treadonly clientMetadata: OAuthClientMetadata;\n\t/**\n\t * Client ID Metadata Document to identify as instead of registering dynamically, or `undefined` to\n\t * register. Called when no client information is stored; the document is not stored. `metadata` is\n\t * `undefined` when the authorization server has none; check `client_id_metadata_document_supported`.\n\t */\n\tclientMetadataDocument?(metadata: AuthorizationServerMetadata | undefined): OAuthClientMetadataDocument | undefined;\n\tstate?(): string | Promise<string>;\n\tclientInformation(): OAuthClientInformationMixed | undefined | Promise<OAuthClientInformationMixed | undefined>;\n\tsaveClientInformation?(information: OAuthClientInformationMixed): void | Promise<void>;\n\ttokens(): OAuthTokens | undefined | Promise<OAuthTokens | undefined>;\n\tsaveTokens(tokens: OAuthTokens): void | Promise<void>;\n\tredirectToAuthorization(url: URL): void | Promise<void>;\n\tsaveCodeVerifier(verifier: string): void | Promise<void>;\n\tcodeVerifier(): string | Promise<string>;\n\taddClientAuthentication?: AddClientAuthentication;\n\tinvalidateCredentials?(kind: \"all\" | \"client\" | \"tokens\" | \"verifier\" | \"discovery\"): void | Promise<void>;\n\tsaveDiscoveryState?(state: OAuthDiscoveryState): void | Promise<void>;\n\tdiscoveryState?(): OAuthDiscoveryState | undefined | Promise<OAuthDiscoveryState | undefined>;\n}\n\nexport interface OAuthFlowOptions {\n\tserverUrl: string | URL;\n\tauthorizationCode?: string;\n\t/** `iss` parameter of the authorization response that delivered `authorizationCode` (RFC 9207). */\n\tiss?: string;\n\tscope?: string;\n\tresourceMetadataUrl?: URL;\n\t/**\n\t * Authorization server metadata document to use instead of discovery, for servers that advertise a\n\t * wrong authorization server or none. It is trusted as configured. Must use https, except on loopback.\n\t */\n\tauthorizationServerMetadataUrl?: URL;\n\tfetch?: McpFetch;\n\t/** Aborts every request of the flow. Requests have no time limit of their own; combine with a timeout as needed. */\n\tsignal?: AbortSignal;\n\tskipIssuerValidation?: boolean;\n\t/**\n\t * Go straight to the authorization redirect instead of refreshing stored tokens, for example when the\n\t * server asks for scopes the current grant lacks (a refresh keeps the old scope).\n\t */\n\tskipRefresh?: boolean;\n}\n\nexport type OAuthFlowResult = \"AUTHORIZED\" | \"REDIRECT\";\ntype ClientAuthMethod = \"client_secret_basic\" | \"client_secret_post\" | \"none\";\n\nexport interface TokenRequestOptions {\n\tmetadata?: AuthorizationServerMetadata;\n\tclientInformation: OAuthClientInformationMixed;\n\tresource?: string;\n\taddClientAuthentication?: AddClientAuthentication;\n\tfetch?: McpFetch;\n\tsignal?: AbortSignal;\n}\n\nfunction loopback(hostname: string): boolean {\n\treturn hostname === \"localhost\" || hostname === \"127.0.0.1\" || hostname === \"[::1]\" || hostname === \"::1\";\n}\n\n/**\n * The OpenID Connect `application_type` for `redirect_uris` (MCP SEP-837). Without one, OpenID Connect servers\n * assume `web`, which rejects http loopback redirect URIs. Loopback hosts and custom schemes are native (RFC 8252).\n */\nfunction applicationType(redirectUris: readonly string[]): \"native\" | \"web\" {\n\tconst native = redirectUris.some((uri) => {\n\t\tif (!URL.canParse(uri)) return false;\n\t\tconst url = new URL(uri);\n\t\treturn (url.protocol !== \"http:\" && url.protocol !== \"https:\") || loopback(url.hostname);\n\t});\n\treturn native ? \"native\" : \"web\";\n}\n\nfunction secureEndpoint(value: string | URL): URL {\n\tconst url = new URL(value);\n\tif (url.protocol !== \"https:\" && !loopback(url.hostname)) throw new OAuthInsecureEndpointError(url.href);\n\treturn url;\n}\n\nfunction selectClientAuthMethod(information: OAuthClientInformationMixed, supported: string[]): ClientAuthMethod {\n\tconst hinted = \"token_endpoint_auth_method\" in information ? information.token_endpoint_auth_method : undefined;\n\tif (\n\t\thinted &&\n\t\t[\"client_secret_basic\", \"client_secret_post\", \"none\"].includes(hinted) &&\n\t\t(supported.length === 0 || supported.includes(hinted))\n\t) {\n\t\treturn hinted as ClientAuthMethod;\n\t}\n\tif (supported.length === 0) return information.client_secret ? \"client_secret_basic\" : \"none\";\n\tif (information.client_secret && supported.includes(\"client_secret_basic\")) return \"client_secret_basic\";\n\tif (information.client_secret && supported.includes(\"client_secret_post\")) return \"client_secret_post\";\n\tif (supported.includes(\"none\")) return \"none\";\n\treturn information.client_secret ? \"client_secret_post\" : \"none\";\n}\n\nfunction applyClientAuthentication(\n\tmethod: ClientAuthMethod,\n\tinformation: OAuthClientInformation,\n\theaders: Headers,\n\tparams: URLSearchParams,\n): void {\n\tif (method === \"client_secret_basic\") {\n\t\tif (!information.client_secret) throw new Error(\"client_secret_basic requires a client secret\");\n\t\theaders.set(\n\t\t\t\"Authorization\",\n\t\t\t`Basic ${Buffer.from(`${information.client_id}:${information.client_secret}`).toString(\"base64\")}`,\n\t\t);\n\t} else {\n\t\tparams.set(\"client_id\", information.client_id);\n\t\tif (method === \"client_secret_post\" && information.client_secret)\n\t\t\tparams.set(\"client_secret\", information.client_secret);\n\t}\n}\n\nasync function pkce(): Promise<{ verifier: string; challenge: string }> {\n\tconst bytes = crypto.getRandomValues(new Uint8Array(32));\n\tconst verifier = Buffer.from(bytes).toString(\"base64url\");\n\tconst digest = await crypto.subtle.digest(\"SHA-256\", new TextEncoder().encode(verifier));\n\treturn { verifier, challenge: Buffer.from(digest).toString(\"base64url\") };\n}\n\nexport async function startAuthorization(\n\tauthorizationServerUrl: string | URL,\n\toptions: {\n\t\tmetadata?: AuthorizationServerMetadata;\n\t\tclientInformation: OAuthClientInformationMixed;\n\t\tredirectUrl: string | URL;\n\t\tscope?: string;\n\t\tstate?: string;\n\t\tresource?: string;\n\t},\n): Promise<{ authorizationUrl: URL; codeVerifier: string }> {\n\tconst metadata = options.metadata;\n\tif (metadata && !metadata.response_types_supported.includes(\"code\")) {\n\t\tthrow new Error(\"Authorization server does not support authorization codes\");\n\t}\n\tif (metadata?.code_challenge_methods_supported && !metadata.code_challenge_methods_supported.includes(\"S256\")) {\n\t\tthrow new Error(\"Authorization server does not support PKCE S256\");\n\t}\n\tconst url = new URL(metadata?.authorization_endpoint ?? new URL(\"/authorize\", authorizationServerUrl));\n\tconst { verifier, challenge } = await pkce();\n\turl.searchParams.set(\"response_type\", \"code\");\n\turl.searchParams.set(\"client_id\", options.clientInformation.client_id);\n\turl.searchParams.set(\"code_challenge\", challenge);\n\turl.searchParams.set(\"code_challenge_method\", \"S256\");\n\turl.searchParams.set(\"redirect_uri\", String(options.redirectUrl));\n\tif (options.state) url.searchParams.set(\"state\", options.state);\n\tif (options.scope) url.searchParams.set(\"scope\", options.scope);\n\tif (options.scope?.split(/\\s+/).includes(\"offline_access\")) url.searchParams.set(\"prompt\", \"consent\");\n\tif (options.resource) url.searchParams.set(\"resource\", options.resource);\n\treturn { authorizationUrl: url, codeVerifier: verifier };\n}\n\nasync function tokenRequest(\n\tauthorizationServerUrl: string | URL,\n\toptions: TokenRequestOptions,\n\tparams: URLSearchParams,\n): Promise<OAuthTokens> {\n\tconst url = secureEndpoint(options.metadata?.token_endpoint ?? new URL(\"/token\", authorizationServerUrl));\n\tconst headers = new Headers({ Accept: \"application/json\", \"content-type\": \"application/x-www-form-urlencoded\" });\n\tif (options.resource) params.set(\"resource\", options.resource);\n\tif (options.addClientAuthentication) {\n\t\tawait options.addClientAuthentication(headers, params, url, options.metadata);\n\t} else {\n\t\tapplyClientAuthentication(\n\t\t\tselectClientAuthMethod(\n\t\t\t\toptions.clientInformation,\n\t\t\t\toptions.metadata?.token_endpoint_auth_methods_supported ?? [],\n\t\t\t),\n\t\t\toptions.clientInformation,\n\t\t\theaders,\n\t\t\tparams,\n\t\t);\n\t}\n\tconst response = await (options.fetch ?? globalThis.fetch)(url, {\n\t\tmethod: \"POST\",\n\t\theaders,\n\t\tbody: params,\n\t\tsignal: options.signal,\n\t});\n\tconst text = await response.text();\n\tlet value: unknown;\n\ttry {\n\t\tvalue = JSON.parse(text);\n\t} catch {}\n\t// Servers may report OAuth errors with any status, so check the body before the status.\n\tif (isObject(value) && typeof value.error === \"string\") {\n\t\tthrow new OAuthError(\n\t\t\tvalue.error,\n\t\t\ttypeof value.error_description === \"string\" ? value.error_description : value.error,\n\t\t\ttypeof value.error_uri === \"string\" ? value.error_uri : undefined,\n\t\t);\n\t}\n\tif (!response.ok) throw new OAuthError(\"server_error\", `HTTP ${response.status}: ${text}`);\n\treturn parseOAuthTokens(value);\n}\n\nexport async function registerClient(\n\tauthorizationServerUrl: string | URL,\n\toptions: {\n\t\tmetadata?: AuthorizationServerMetadata;\n\t\tclientMetadata: OAuthClientMetadata;\n\t\tscope?: string;\n\t\tfetch?: McpFetch;\n\t\tsignal?: AbortSignal;\n\t},\n): Promise<OAuthClientInformationFull> {\n\tconst endpoint = options.metadata?.registration_endpoint;\n\tif (options.metadata && !endpoint)\n\t\tthrow new Error(\"Authorization server does not support dynamic client registration\");\n\tconst response = await (options.fetch ?? globalThis.fetch)(\n\t\tnew URL(endpoint ?? new URL(\"/register\", authorizationServerUrl)),\n\t\t{\n\t\t\tmethod: \"POST\",\n\t\t\theaders: { Accept: \"application/json\", \"content-type\": \"application/json\" },\n\t\t\tbody: JSON.stringify({\n\t\t\t\t...options.clientMetadata,\n\t\t\t\tapplication_type:\n\t\t\t\t\toptions.clientMetadata.application_type ?? applicationType(options.clientMetadata.redirect_uris),\n\t\t\t\t...(options.scope ? { scope: options.scope } : {}),\n\t\t\t}),\n\t\t\tsignal: options.signal,\n\t\t},\n\t);\n\tif (!response.ok) throw new OAuthRegistrationError(response.status, await response.text());\n\treturn parseClientInformation(await response.json());\n}\n\nexport async function exchangeAuthorizationCode(\n\tauthorizationServerUrl: string | URL,\n\toptions: TokenRequestOptions & { code: string; codeVerifier: string; redirectUrl: string | URL },\n): Promise<OAuthTokens> {\n\treturn tokenRequest(\n\t\tauthorizationServerUrl,\n\t\toptions,\n\t\tnew URLSearchParams({\n\t\t\tgrant_type: \"authorization_code\",\n\t\t\tcode: options.code,\n\t\t\tcode_verifier: options.codeVerifier,\n\t\t\tredirect_uri: String(options.redirectUrl),\n\t\t}),\n\t);\n}\n\nexport async function refreshAuthorization(\n\tauthorizationServerUrl: string | URL,\n\toptions: TokenRequestOptions & { refreshToken: string },\n): Promise<OAuthTokens> {\n\tconst tokens = await tokenRequest(\n\t\tauthorizationServerUrl,\n\t\toptions,\n\t\tnew URLSearchParams({ grant_type: \"refresh_token\", refresh_token: options.refreshToken }),\n\t);\n\treturn { refresh_token: options.refreshToken, ...tokens };\n}\n\nfunction withScope(tokens: OAuthTokens, scope: string | undefined): OAuthTokens {\n\treturn tokens.scope === undefined && scope ? { ...tokens, scope } : tokens;\n}\n\n/**\n * Scopes for a step-up authorization: the challenged scopes plus the ones granted so far, since a\n * challenge may list only the missing scopes and a token with just those would lose access the old\n * one had (SEP-2350). Without challenged scopes, `undefined` lets the flow pick its default.\n */\nexport function stepUpScope(granted: string | undefined, challenged: string | undefined): string | undefined {\n\tif (!challenged) return undefined;\n\tconst scopes = [granted, challenged].flatMap((scope) => scope?.split(/\\s+/).filter(Boolean) ?? []);\n\treturn [...new Set(scopes)].join(\" \");\n}\n\nasync function runFlow(provider: OAuthClientProvider, options: OAuthFlowOptions): Promise<OAuthFlowResult> {\n\tconst metadataUrl = options.authorizationServerMetadataUrl && secureEndpoint(options.authorizationServerMetadataUrl);\n\t// With a configured metadata URL, discovery is not cached, so changing the URL applies at once.\n\tconst cached = metadataUrl ? undefined : await provider.discoveryState?.();\n\tconst discovered = cached?.authorizationServerUrl\n\t\t? {\n\t\t\t\tauthorizationServerUrl: cached.authorizationServerUrl,\n\t\t\t\tauthorizationServerMetadata:\n\t\t\t\t\tcached.authorizationServerMetadata ??\n\t\t\t\t\t(await discoverAuthorizationServerMetadata(cached.authorizationServerUrl, {\n\t\t\t\t\t\tfetch: options.fetch,\n\t\t\t\t\t\tskipIssuerValidation: options.skipIssuerValidation,\n\t\t\t\t\t\tsignal: options.signal,\n\t\t\t\t\t})),\n\t\t\t\tresourceMetadata: cached.resourceMetadata,\n\t\t\t}\n\t\t: await discoverOAuthServerInfo(options.serverUrl, {\n\t\t\t\tresourceMetadataUrl: options.resourceMetadataUrl,\n\t\t\t\tauthorizationServerMetadataUrl: metadataUrl,\n\t\t\t\tfetch: options.fetch,\n\t\t\t\tskipIssuerValidation: options.skipIssuerValidation,\n\t\t\t\tsignal: options.signal,\n\t\t\t});\n\tif (!metadataUrl) {\n\t\tawait provider.saveDiscoveryState?.({\n\t\t\t...discovered,\n\t\t\t...(options.resourceMetadataUrl ? { resourceMetadataUrl: options.resourceMetadataUrl.href } : {}),\n\t\t});\n\t}\n\tconst metadata = discovered.authorizationServerMetadata;\n\tconst resource = selectResource(options.serverUrl, discovered.resourceMetadata);\n\t// `||`, not `??`: an empty scope (for example from `scopes_supported: []`) falls through to the next source.\n\tconst scope =\n\t\toptions.scope || discovered.resourceMetadata?.scopes_supported?.join(\" \") || provider.clientMetadata.scope;\n\tconst stored = await provider.clientInformation();\n\tconst clientDocument = stored ? undefined : provider.clientMetadataDocument?.(metadata);\n\tif (clientDocument) {\n\t\tconst url = new URL(clientDocument.url);\n\t\tif (url.protocol !== \"https:\" || url.pathname === \"/\") throw new Error(\"Invalid OAuth client metadata URL\");\n\t}\n\tlet client = stored ?? (clientDocument && { client_id: clientDocument.url });\n\tif (!client) {\n\t\tif (options.authorizationCode) throw new Error(\"OAuth client information is missing during code exchange\");\n\t\tif (!provider.saveClientInformation) throw new Error(\"OAuth client information cannot be persisted\");\n\t\tclient = await registerClient(discovered.authorizationServerUrl, {\n\t\t\tmetadata,\n\t\t\tclientMetadata: provider.clientMetadata,\n\t\t\tscope,\n\t\t\tfetch: options.fetch,\n\t\t\tsignal: options.signal,\n\t\t});\n\t\tawait provider.saveClientInformation(client);\n\t}\n\t// The document's redirect URI may differ from the provider's, for example by a server-specific path.\n\tconst redirectUrl = clientDocument?.redirectUrl ?? provider.redirectUrl;\n\tconst tokenOptions: TokenRequestOptions = {\n\t\tmetadata,\n\t\tclientInformation: client,\n\t\tresource,\n\t\taddClientAuthentication: provider.addClientAuthentication,\n\t\tfetch: options.fetch,\n\t\tsignal: options.signal,\n\t};\n\tif (options.authorizationCode) {\n\t\t// RFC 9207: never send a code from another authorization server to this one. Without metadata there\n\t\t// is no issuer to compare with, so any `iss` is rejected.\n\t\tconst iss = options.iss;\n\t\tif (iss !== undefined || metadata?.authorization_response_iss_parameter_supported) {\n\t\t\tif (iss !== metadata?.issuer) throw new OAuthIssuerMismatchError(metadata?.issuer, iss);\n\t\t}\n\t\tconst tokens = await exchangeAuthorizationCode(discovered.authorizationServerUrl, {\n\t\t\t...tokenOptions,\n\t\t\tcode: options.authorizationCode,\n\t\t\tcodeVerifier: await provider.codeVerifier(),\n\t\t\tredirectUrl,\n\t\t});\n\t\t// A response without `scope` grants the requested scope (RFC 6749 §5.1). Recorded so a step-up can\n\t\t// keep it. Callers pass the options of the authorization request, so `scope` is what was requested.\n\t\tawait provider.saveTokens(withScope(tokens, scope));\n\t\treturn \"AUTHORIZED\";\n\t}\n\tconst existing = options.skipRefresh ? undefined : await provider.tokens();\n\tif (existing?.refresh_token) {\n\t\ttry {\n\t\t\tconst tokens = await refreshAuthorization(discovered.authorizationServerUrl, {\n\t\t\t\t...tokenOptions,\n\t\t\t\trefreshToken: existing.refresh_token,\n\t\t\t});\n\t\t\t// A refresh without `scope` keeps the scope of the grant (RFC 6749 §6).\n\t\t\tawait provider.saveTokens(withScope(tokens, existing.scope));\n\t\t\treturn \"AUTHORIZED\";\n\t\t} catch (error) {\n\t\t\tif (options.signal?.aborted || error instanceof OAuthInsecureEndpointError) throw error;\n\t\t\tif (error instanceof OAuthError && error.code !== \"server_error\") throw error;\n\t\t}\n\t}\n\tconst state = await provider.state?.();\n\tconst authorization = await startAuthorization(discovered.authorizationServerUrl, {\n\t\tmetadata,\n\t\tclientInformation: client,\n\t\tredirectUrl,\n\t\tscope,\n\t\tstate,\n\t\tresource,\n\t});\n\tawait provider.saveCodeVerifier(authorization.codeVerifier);\n\tawait provider.redirectToAuthorization(authorization.authorizationUrl);\n\treturn \"REDIRECT\";\n}\n\nexport async function authorizeMcp(provider: OAuthClientProvider, options: OAuthFlowOptions): Promise<OAuthFlowResult> {\n\ttry {\n\t\treturn await runFlow(provider, options);\n\t} catch (error) {\n\t\tif (error instanceof OAuthError && [\"invalid_client\", \"unauthorized_client\"].includes(error.code)) {\n\t\t\tawait provider.invalidateCredentials?.(\"all\");\n\t\t\treturn runFlow(provider, options);\n\t\t}\n\t\tif (error instanceof OAuthError && error.code === \"invalid_grant\") {\n\t\t\tawait provider.invalidateCredentials?.(\"tokens\");\n\t\t\treturn runFlow(provider, options);\n\t\t}\n\t\tthrow error;\n\t}\n}\n\n/**\n * Auth provider for `StreamableHttpTransport`. After a 401 it refreshes the tokens, or throws\n * `McpOAuthAuthorizationRequiredError` when the user has to authorize (again). Concurrent 401s share\n * one refresh, and a request whose token was already replaced is just retried: with rotating refresh\n * tokens, a second refresh with the old refresh token would fail and discard the new grant.\n */\nexport function adaptOAuthProvider(provider: OAuthClientProvider): AuthProvider {\n\tlet inFlight: Promise<void> | undefined;\n\treturn {\n\t\ttoken: async () => (await provider.tokens())?.access_token,\n\t\tonUnauthorized: async (context: UnauthorizedContext) => {\n\t\t\tconst challenge = parseWwwAuthenticate(context.response.headers.get(\"www-authenticate\"));\n\t\t\tconst insufficientScope = challenge.error === \"insufficient_scope\";\n\t\t\tif (!insufficientScope && !inFlight && context.token !== undefined) {\n\t\t\t\tconst current = (await provider.tokens())?.access_token;\n\t\t\t\tif (current !== undefined && current !== context.token) return;\n\t\t\t}\n\t\t\tinFlight ??= Promise.resolve(insufficientScope ? provider.tokens() : undefined)\n\t\t\t\t.then((granted) =>\n\t\t\t\t\tauthorizeMcp(provider, {\n\t\t\t\t\t\tserverUrl: context.serverUrl,\n\t\t\t\t\t\tresourceMetadataUrl: challenge.resourceMetadataUrl,\n\t\t\t\t\t\tscope: insufficientScope ? stepUpScope(granted?.scope, challenge.scope) : challenge.scope,\n\t\t\t\t\t\tfetch: context.fetch,\n\t\t\t\t\t\tskipRefresh: insufficientScope,\n\t\t\t\t\t}),\n\t\t\t\t)\n\t\t\t\t.then((result) => {\n\t\t\t\t\tif (result === \"REDIRECT\") throw new McpOAuthAuthorizationRequiredError();\n\t\t\t\t})\n\t\t\t\t.finally(() => {\n\t\t\t\t\tinFlight = undefined;\n\t\t\t\t});\n\t\t\tawait inFlight;\n\t\t},\n\t};\n}\n"]}
@@ -32,6 +32,11 @@ export interface OAuthClientMetadata {
32
32
  token_endpoint_auth_method?: string;
33
33
  grant_types?: string[];
34
34
  response_types?: string[];
35
+ /**
36
+ * OpenID Connect client type, `native` or `web`. Dynamic client registration derives it from
37
+ * `redirect_uris` when absent (MCP SEP-837).
38
+ */
39
+ application_type?: string;
35
40
  client_name?: string;
36
41
  client_uri?: string;
37
42
  logo_uri?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/oauth/types.ts"],"names":[],"mappings":"AAQA,MAAM,WAAW,8BAA8B;IAC9C,QAAQ,EAAE,MAAM,CAAC;IACjB,qBAAqB,C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AK,EAAE,OAAO,CAAC;QAC3C,aAAa,EAAE,cAAc,CAAC,KAAK,CAAC,aAAa,EAAE,eAAe,CAAC;QACnE,QAAQ,EAAE,cAAc,CAAC,KAAK,CAAC,QAAQ,EAAE,UAAU,CAAC;KACpD,CAAC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,KAAc;IACpD,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,EAAE,oCAAoC,CAAC,CAAC;IAClE,OAAO,OAAO,CAAC;QACd,GAAI,KAAwC;QAC5C,SAAS,EAAE,cAAc,CAAC,KAAK,CAAC,SAAS,EAAE,WAAW,CAAC;QACvD,aAAa,EAAE,cAAc,CAAC,KAAK,CAAC,aAAa,EAAE,eAAe,CAAC;QACnE,mBAAmB,EAAE,OAAO,KAAK,CAAC,mBAAmB,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC,CAAC,SAAS;QAC1G,wBAAwB,EACvB,OAAO,KAAK,CAAC,wBAAwB,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAC,CAAC,SAAS;QAChG,aAAa,EAAE,eAAe,CAAC,KAAK,CAAC,aAAa,EAAE,eAAe,CAAC,IAAI,EAAE;KAC1E,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/*\n * Adapted from modelcontextprotocol/typescript-sdk v1.29.0.\n * Copyright (c) 2024 Anthropic, PBC. Licensed under MIT; see LICENSES/.\n * Modified to use dependency-free structural validation.\n */\n\nimport { isObject } from \"../protocol/jsonrpc.ts\";\n\nexport interface OAuthProtectedResourceMetadata {\n\tresource: string;\n\tauthorization_servers?: string[];\n\tscopes_supported?: string[];\n\t[key: string]: unknown;\n}\n\nexport interface AuthorizationServerMetadata {\n\tissuer: string;\n\tauthorization_endpoint: string;\n\ttoken_endpoint: string;\n\tregistration_endpoint?: string;\n\tscopes_supported?: string[];\n\tresponse_types_supported: string[];\n\tgrant_types_supported?: string[];\n\ttoken_endpoint_auth_methods_supported?: string[];\n\tcode_challenge_methods_supported?: string[];\n\tclient_id_metadata_document_supported?: boolean;\n\t/** Whether authorization responses carry an `iss` parameter (RFC 9207). */\n\tauthorization_response_iss_parameter_supported?: boolean;\n\t[key: string]: unknown;\n}\n\nexport interface OAuthTokens {\n\taccess_token: string;\n\ttoken_type: string;\n\texpires_in?: number;\n\tscope?: string;\n\trefresh_token?: string;\n\tid_token?: string;\n}\n\nexport interface OAuthClientMetadata {\n\tredirect_uris: string[];\n\ttoken_endpoint_auth_method?: string;\n\tgrant_types?: string[];\n\tresponse_types?: string[];\n\tclient_name?: string;\n\tclient_uri?: string;\n\tlogo_uri?: string;\n\tscope?: string;\n\tcontacts?: string[];\n\ttos_uri?: string;\n\tpolicy_uri?: string;\n\tjwks_uri?: string;\n\tjwks?: unknown;\n\tsoftware_id?: string;\n\tsoftware_version?: string;\n\tsoftware_statement?: string;\n}\n\nexport interface OAuthClientInformation {\n\tclient_id: string;\n\tclient_secret?: string;\n\tclient_id_issued_at?: number;\n\tclient_secret_expires_at?: number;\n}\n\nexport type OAuthClientInformationFull = OAuthClientInformation & OAuthClientMetadata;\nexport type OAuthClientInformationMixed = OAuthClientInformation | OAuthClientInformationFull;\n\nexport interface OAuthDiscoveryState {\n\tauthorizationServerUrl: string;\n\tauthorizationServerMetadata?: AuthorizationServerMetadata;\n\tresourceMetadata?: OAuthProtectedResourceMetadata;\n\tresourceMetadataUrl?: string;\n}\n\nexport interface OAuthServerInfo {\n\tauthorizationServerUrl: string;\n\tauthorizationServerMetadata?: AuthorizationServerMetadata;\n\tresourceMetadata?: OAuthProtectedResourceMetadata;\n}\n\nexport interface OAuthChallenge {\n\tresourceMetadataUrl?: URL;\n\tscope?: string;\n\terror?: string;\n\terrorDescription?: string;\n}\n\nfunction object(value: unknown, name: string): Record<string, unknown> {\n\tif (!isObject(value)) throw new Error(`Invalid ${name}`);\n\treturn value;\n}\n\n/** Drops `undefined` values so optional fields are absent rather than present-but-undefined. */\nfunction compact<T extends object>(value: T): T {\n\treturn Object.fromEntries(Object.entries(value).filter(([, item]) => item !== undefined)) as T;\n}\n\nfunction requiredString(value: unknown, name: string): string {\n\tif (typeof value !== \"string\" || value.length === 0) throw new Error(`Invalid ${name}`);\n\treturn value;\n}\n\n/** Treats `null` and `\"\"` as absent: servers send them for fields they have no value for, like `scope: \"\"`. */\nfunction absent(value: unknown): value is undefined | null | \"\" {\n\treturn value === undefined || value === null || value === \"\";\n}\n\nfunction optionalString(value: unknown, name: string): string | undefined {\n\tif (absent(value)) return undefined;\n\treturn requiredString(value, name);\n}\n\nfunction optionalStrings(value: unknown, name: string): string[] | undefined {\n\tif (value === undefined || value === null) return undefined;\n\tif (!Array.isArray(value) || value.some((item) => typeof item !== \"string\")) throw new Error(`Invalid ${name}`);\n\treturn [...value];\n}\n\nfunction safeUrl(value: unknown, name: string): string {\n\tconst text = requiredString(value, name);\n\t// URL parsing throws a `TypeError`, which discovery reserves for network failures.\n\tif (!URL.canParse(text)) throw new Error(`Invalid ${name}`);\n\tconst url = new URL(text);\n\tif ([\"javascript:\", \"data:\", \"vbscript:\"].includes(url.protocol)) throw new Error(`Invalid ${name}`);\n\treturn text;\n}\n\nfunction optionalUrl(value: unknown, name: string): string | undefined {\n\treturn absent(value) ? undefined : safeUrl(value, name);\n}\n\nexport function parseProtectedResourceMetadata(value: unknown): OAuthProtectedResourceMetadata {\n\tconst input = object(value, \"OAuth protected resource metadata\");\n\treturn compact({\n\t\t...input,\n\t\tresource: safeUrl(input.resource, \"OAuth protected resource metadata resource\"),\n\t\tauthorization_servers: optionalStrings(input.authorization_servers, \"authorization_servers\")?.map((url) =>\n\t\t\tsafeUrl(url, \"authorization server URL\"),\n\t\t),\n\t\tscopes_supported: optionalStrings(input.scopes_supported, \"scopes_supported\"),\n\t});\n}\n\nexport function parseAuthorizationServerMetadata(value: unknown): AuthorizationServerMetadata {\n\tconst input = object(value, \"authorization server metadata\");\n\tconst responseTypes = optionalStrings(input.response_types_supported, \"response_types_supported\");\n\tif (!responseTypes) throw new Error(\"Invalid response_types_supported\");\n\treturn compact({\n\t\t...input,\n\t\tissuer: safeUrl(input.issuer, \"authorization server issuer\"),\n\t\tauthorization_endpoint: safeUrl(input.authorization_endpoint, \"authorization endpoint\"),\n\t\ttoken_endpoint: safeUrl(input.token_endpoint, \"token endpoint\"),\n\t\tregistration_endpoint: optionalUrl(input.registration_endpoint, \"registration endpoint\"),\n\t\tscopes_supported: optionalStrings(input.scopes_supported, \"scopes_supported\"),\n\t\tresponse_types_supported: responseTypes,\n\t\tgrant_types_supported: optionalStrings(input.grant_types_supported, \"grant_types_supported\"),\n\t\ttoken_endpoint_auth_methods_supported: optionalStrings(\n\t\t\tinput.token_endpoint_auth_methods_supported,\n\t\t\t\"token_endpoint_auth_methods_supported\",\n\t\t),\n\t\tcode_challenge_methods_supported: optionalStrings(\n\t\t\tinput.code_challenge_methods_supported,\n\t\t\t\"code_challenge_methods_supported\",\n\t\t),\n\t\tclient_id_metadata_document_supported:\n\t\t\ttypeof input.client_id_metadata_document_supported === \"boolean\"\n\t\t\t\t? input.client_id_metadata_document_supported\n\t\t\t\t: undefined,\n\t\tauthorization_response_iss_parameter_supported:\n\t\t\ttypeof input.authorization_response_iss_parameter_supported === \"boolean\"\n\t\t\t\t? input.authorization_response_iss_parameter_supported\n\t\t\t\t: undefined,\n\t});\n}\n\nexport function parseOAuthTokens(value: unknown): OAuthTokens {\n\tconst input = object(value, \"OAuth token response\");\n\t// `Number(null)` is 0, which would mark the token as expired at once.\n\tconst expires = absent(input.expires_in) ? undefined : Number(input.expires_in);\n\tif (expires !== undefined && !Number.isFinite(expires)) throw new Error(\"Invalid expires_in\");\n\treturn compact({\n\t\taccess_token: requiredString(input.access_token, \"access_token\"),\n\t\ttoken_type: requiredString(input.token_type, \"token_type\"),\n\t\texpires_in: expires,\n\t\tscope: optionalString(input.scope, \"scope\"),\n\t\trefresh_token: optionalString(input.refresh_token, \"refresh_token\"),\n\t\tid_token: optionalString(input.id_token, \"id_token\"),\n\t});\n}\n\nexport function parseClientInformation(value: unknown): OAuthClientInformationFull {\n\tconst input = object(value, \"OAuth client registration response\");\n\treturn compact({\n\t\t...(input as unknown as OAuthClientMetadata),\n\t\tclient_id: requiredString(input.client_id, \"client_id\"),\n\t\tclient_secret: optionalString(input.client_secret, \"client_secret\"),\n\t\tclient_id_issued_at: typeof input.client_id_issued_at === \"number\" ? input.client_id_issued_at : undefined,\n\t\tclient_secret_expires_at:\n\t\t\ttypeof input.client_secret_expires_at === \"number\" ? input.client_secret_expires_at : undefined,\n\t\tredirect_uris: optionalStrings(input.redirect_uris, \"redirect_uris\") ?? [],\n\t});\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/oauth/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAwFlD,SAAS,MAAM,CAAC,KAAc,EAAE,IAAY;IAC3C,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,WAAW,IAAI,EAAE,CAAC,CAAC;IACzD,OAAO,KAAK,CAAC;AACd,CAAC;AAED,gGAAgG;AAChG,SAAS,OAAO,CAAmB,KAAQ;IAC1C,OAAO,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,IAAI,KAAK,SAAS,CAAC,CAAM,CAAC;AAChG,CAAC;AAED,SAAS,cAAc,CAAC,KAAc,EAAE,IAAY;IACnD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,WAAW,IAAI,EAAE,CAAC,CAAC;IACxF,OAAO,KAAK,CAAC;AACd,CAAC;AAED,+GAA+G;AAC/G,SAAS,MAAM,CAA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,eAAe,CAAC;QACnE,QAAQ,EAAE,cAAc,CAAC,KAAK,CAAC,QAAQ,EAAE,UAAU,CAAC;KACpD,CAAC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,KAAc;IACpD,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,EAAE,oCAAoC,CAAC,CAAC;IAClE,OAAO,OAAO,CAAC;QACd,GAAI,KAAwC;QAC5C,SAAS,EAAE,cAAc,CAAC,KAAK,CAAC,SAAS,EAAE,WAAW,CAAC;QACvD,aAAa,EAAE,cAAc,CAAC,KAAK,CAAC,aAAa,EAAE,eAAe,CAAC;QACnE,mBAAmB,EAAE,OAAO,KAAK,CAAC,mBAAmB,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC,CAAC,SAAS;QAC1G,wBAAwB,EACvB,OAAO,KAAK,CAAC,wBAAwB,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAC,CAAC,SAAS;QAChG,aAAa,EAAE,eAAe,CAAC,KAAK,CAAC,aAAa,EAAE,eAAe,CAAC,IAAI,EAAE;KAC1E,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/*\n * Adapted from modelcontextprotocol/typescript-sdk v1.29.0.\n * Copyright (c) 2024 Anthropic, PBC. Licensed under MIT; see LICENSES/.\n * Modified to use dependency-free structural validation.\n */\n\nimport { isObject } from \"../protocol/jsonrpc.ts\";\n\nexport interface OAuthProtectedResourceMetadata {\n\tresource: string;\n\tauthorization_servers?: string[];\n\tscopes_supported?: string[];\n\t[key: string]: unknown;\n}\n\nexport interface AuthorizationServerMetadata {\n\tissuer: string;\n\tauthorization_endpoint: string;\n\ttoken_endpoint: string;\n\tregistration_endpoint?: string;\n\tscopes_supported?: string[];\n\tresponse_types_supported: string[];\n\tgrant_types_supported?: string[];\n\ttoken_endpoint_auth_methods_supported?: string[];\n\tcode_challenge_methods_supported?: string[];\n\tclient_id_metadata_document_supported?: boolean;\n\t/** Whether authorization responses carry an `iss` parameter (RFC 9207). */\n\tauthorization_response_iss_parameter_supported?: boolean;\n\t[key: string]: unknown;\n}\n\nexport interface OAuthTokens {\n\taccess_token: string;\n\ttoken_type: string;\n\texpires_in?: number;\n\tscope?: string;\n\trefresh_token?: string;\n\tid_token?: string;\n}\n\nexport interface OAuthClientMetadata {\n\tredirect_uris: string[];\n\ttoken_endpoint_auth_method?: string;\n\tgrant_types?: string[];\n\tresponse_types?: string[];\n\t/**\n\t * OpenID Connect client type, `native` or `web`. Dynamic client registration derives it from\n\t * `redirect_uris` when absent (MCP SEP-837).\n\t */\n\tapplication_type?: string;\n\tclient_name?: string;\n\tclient_uri?: string;\n\tlogo_uri?: string;\n\tscope?: string;\n\tcontacts?: string[];\n\ttos_uri?: string;\n\tpolicy_uri?: string;\n\tjwks_uri?: string;\n\tjwks?: unknown;\n\tsoftware_id?: string;\n\tsoftware_version?: string;\n\tsoftware_statement?: string;\n}\n\nexport interface OAuthClientInformation {\n\tclient_id: string;\n\tclient_secret?: string;\n\tclient_id_issued_at?: number;\n\tclient_secret_expires_at?: number;\n}\n\nexport type OAuthClientInformationFull = OAuthClientInformation & OAuthClientMetadata;\nexport type OAuthClientInformationMixed = OAuthClientInformation | OAuthClientInformationFull;\n\nexport interface OAuthDiscoveryState {\n\tauthorizationServerUrl: string;\n\tauthorizationServerMetadata?: AuthorizationServerMetadata;\n\tresourceMetadata?: OAuthProtectedResourceMetadata;\n\tresourceMetadataUrl?: string;\n}\n\nexport interface OAuthServerInfo {\n\tauthorizationServerUrl: string;\n\tauthorizationServerMetadata?: AuthorizationServerMetadata;\n\tresourceMetadata?: OAuthProtectedResourceMetadata;\n}\n\nexport interface OAuthChallenge {\n\tresourceMetadataUrl?: URL;\n\tscope?: string;\n\terror?: string;\n\terrorDescription?: string;\n}\n\nfunction object(value: unknown, name: string): Record<string, unknown> {\n\tif (!isObject(value)) throw new Error(`Invalid ${name}`);\n\treturn value;\n}\n\n/** Drops `undefined` values so optional fields are absent rather than present-but-undefined. */\nfunction compact<T extends object>(value: T): T {\n\treturn Object.fromEntries(Object.entries(value).filter(([, item]) => item !== undefined)) as T;\n}\n\nfunction requiredString(value: unknown, name: string): string {\n\tif (typeof value !== \"string\" || value.length === 0) throw new Error(`Invalid ${name}`);\n\treturn value;\n}\n\n/** Treats `null` and `\"\"` as absent: servers send them for fields they have no value for, like `scope: \"\"`. */\nfunction absent(value: unknown): value is undefined | null | \"\" {\n\treturn value === undefined || value === null || value === \"\";\n}\n\nfunction optionalString(value: unknown, name: string): string | undefined {\n\tif (absent(value)) return undefined;\n\treturn requiredString(value, name);\n}\n\nfunction optionalStrings(value: unknown, name: string): string[] | undefined {\n\tif (value === undefined || value === null) return undefined;\n\tif (!Array.isArray(value) || value.some((item) => typeof item !== \"string\")) throw new Error(`Invalid ${name}`);\n\treturn [...value];\n}\n\nfunction safeUrl(value: unknown, name: string): string {\n\tconst text = requiredString(value, name);\n\t// URL parsing throws a `TypeError`, which discovery reserves for network failures.\n\tif (!URL.canParse(text)) throw new Error(`Invalid ${name}`);\n\tconst url = new URL(text);\n\tif ([\"javascript:\", \"data:\", \"vbscript:\"].includes(url.protocol)) throw new Error(`Invalid ${name}`);\n\treturn text;\n}\n\nfunction optionalUrl(value: unknown, name: string): string | undefined {\n\treturn absent(value) ? undefined : safeUrl(value, name);\n}\n\nexport function parseProtectedResourceMetadata(value: unknown): OAuthProtectedResourceMetadata {\n\tconst input = object(value, \"OAuth protected resource metadata\");\n\treturn compact({\n\t\t...input,\n\t\tresource: safeUrl(input.resource, \"OAuth protected resource metadata resource\"),\n\t\tauthorization_servers: optionalStrings(input.authorization_servers, \"authorization_servers\")?.map((url) =>\n\t\t\tsafeUrl(url, \"authorization server URL\"),\n\t\t),\n\t\tscopes_supported: optionalStrings(input.scopes_supported, \"scopes_supported\"),\n\t});\n}\n\nexport function parseAuthorizationServerMetadata(value: unknown): AuthorizationServerMetadata {\n\tconst input = object(value, \"authorization server metadata\");\n\tconst responseTypes = optionalStrings(input.response_types_supported, \"response_types_supported\");\n\tif (!responseTypes) throw new Error(\"Invalid response_types_supported\");\n\treturn compact({\n\t\t...input,\n\t\tissuer: safeUrl(input.issuer, \"authorization server issuer\"),\n\t\tauthorization_endpoint: safeUrl(input.authorization_endpoint, \"authorization endpoint\"),\n\t\ttoken_endpoint: safeUrl(input.token_endpoint, \"token endpoint\"),\n\t\tregistration_endpoint: optionalUrl(input.registration_endpoint, \"registration endpoint\"),\n\t\tscopes_supported: optionalStrings(input.scopes_supported, \"scopes_supported\"),\n\t\tresponse_types_supported: responseTypes,\n\t\tgrant_types_supported: optionalStrings(input.grant_types_supported, \"grant_types_supported\"),\n\t\ttoken_endpoint_auth_methods_supported: optionalStrings(\n\t\t\tinput.token_endpoint_auth_methods_supported,\n\t\t\t\"token_endpoint_auth_methods_supported\",\n\t\t),\n\t\tcode_challenge_methods_supported: optionalStrings(\n\t\t\tinput.code_challenge_methods_supported,\n\t\t\t\"code_challenge_methods_supported\",\n\t\t),\n\t\tclient_id_metadata_document_supported:\n\t\t\ttypeof input.client_id_metadata_document_supported === \"boolean\"\n\t\t\t\t? input.client_id_metadata_document_supported\n\t\t\t\t: undefined,\n\t\tauthorization_response_iss_parameter_supported:\n\t\t\ttypeof input.authorization_response_iss_parameter_supported === \"boolean\"\n\t\t\t\t? input.authorization_response_iss_parameter_supported\n\t\t\t\t: undefined,\n\t});\n}\n\nexport function parseOAuthTokens(value: unknown): OAuthTokens {\n\tconst input = object(value, \"OAuth token response\");\n\t// `Number(null)` is 0, which would mark the token as expired at once.\n\tconst expires = absent(input.expires_in) ? undefined : Number(input.expires_in);\n\tif (expires !== undefined && !Number.isFinite(expires)) throw new Error(\"Invalid expires_in\");\n\treturn compact({\n\t\taccess_token: requiredString(input.access_token, \"access_token\"),\n\t\ttoken_type: requiredString(input.token_type, \"token_type\"),\n\t\texpires_in: expires,\n\t\tscope: optionalString(input.scope, \"scope\"),\n\t\trefresh_token: optionalString(input.refresh_token, \"refresh_token\"),\n\t\tid_token: optionalString(input.id_token, \"id_token\"),\n\t});\n}\n\nexport function parseClientInformation(value: unknown): OAuthClientInformationFull {\n\tconst input = object(value, \"OAuth client registration response\");\n\treturn compact({\n\t\t...(input as unknown as OAuthClientMetadata),\n\t\tclient_id: requiredString(input.client_id, \"client_id\"),\n\t\tclient_secret: optionalString(input.client_secret, \"client_secret\"),\n\t\tclient_id_issued_at: typeof input.client_id_issued_at === \"number\" ? input.client_id_issued_at : undefined,\n\t\tclient_secret_expires_at:\n\t\t\ttypeof input.client_secret_expires_at === \"number\" ? input.client_secret_expires_at : undefined,\n\t\tredirect_uris: optionalStrings(input.redirect_uris, \"redirect_uris\") ?? [],\n\t});\n}\n"]}
@@ -55,7 +55,8 @@ export interface EmbeddedResourceContent {
55
55
  export type ContentBlock = TextContent | ImageContent | AudioContent | ResourceLinkContent | EmbeddedResourceContent;
56
56
  export interface CallToolResult {
57
57
  content: ContentBlock[];
58
- structuredContent?: Record<string, unknown>;
58
+ /** Any JSON value, including arrays and `null` (MCP 2026-07-28; earlier revisions allowed only objects). */
59
+ structuredContent?: unknown;
59
60
  isError?: boolean;
60
61
  _meta?: Record<string, unknown>;
61
62
  }
@@ -1 +1 @@
1
- {"version":3,"file":"content.d.ts","sourceRoot":"","sources":["../../src/protocol/content.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,kBAAkB;IAClC,QAAQ,CAAC,EAAE,CAAC,MAAM,GAAG,WAAW,CAAC,EAAE,CAAC;IACpC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,WAAW;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,kBAAkB,CAAC;IACjC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC;AAED,MAAM,WAAW,YAAY;IAC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AAM,CAAC,iBAAiB,KAAK,SAAS,EAAE,CAAC;QACpE,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,iBAAiB,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;IACzF,CAAC;IACD,OAAO,OAAO,CAAC;AAChB,CAAC","sourcesContent":["export interface ContentAnnotations {\n\taudience?: (\"user\" | \"assistant\")[];\n\tpriority?: number;\n\tlastModified?: string;\n}\n\nexport interface TextContent {\n\ttype: \"text\";\n\ttext: string;\n\tannotations?: ContentAnnotations;\n\t_meta?: Record<string, unknown>;\n}\n\nexport interface ImageContent {\n\ttype: \"image\";\n\tdata: string;\n\tmimeType: string;\n\tannotations?: ContentAnnotations;\n\t_meta?: Record<string, unknown>;\n}\n\nexport interface AudioContent {\n\ttype: \"audio\";\n\tdata: string;\n\tmimeType: string;\n\tannotations?: ContentAnnotations;\n\t_meta?: Record<string, unknown>;\n}\n\nexport interface ResourceLinkContent {\n\ttype: \"resource_link\";\n\turi: string;\n\tname: string;\n\ttitle?: string;\n\tdescription?: string;\n\tmimeType?: string;\n\tsize?: number;\n\tannotations?: ContentAnnotations;\n\t_meta?: Record<string, unknown>;\n}\n\nexport interface TextResourceContents {\n\turi: string;\n\tmimeType?: string;\n\ttext: string;\n\t_meta?: Record<string, unknown>;\n}\n\nexport interface BlobResourceContents {\n\turi: string;\n\tmimeType?: string;\n\tblob: string;\n\t_meta?: Record<string, unknown>;\n}\n\nexport interface EmbeddedResourceContent {\n\ttype: \"resource\";\n\tresource: TextResourceContents | BlobResourceContents;\n\tannotations?: ContentAnnotations;\n\t_meta?: Record<string, unknown>;\n}\n\nexport type ContentBlock = TextContent | ImageContent | AudioContent | ResourceLinkContent | EmbeddedResourceContent;\n\nexport interface CallToolResult {\n\tcontent: ContentBlock[];\n\tstructuredContent?: Record<string, unknown>;\n\tisError?: boolean;\n\t_meta?: Record<string, unknown>;\n}\n\n/**\n * Tool result content in the shape LLM APIs accept: text and base64 images. Matches the\n * `TextContent` and `ImageContent` types of `@earendil-works/pi-ai`.\n */\nexport type LlmContent = { type: \"text\"; text: string } | { type: \"image\"; data: string; mimeType: string };\n\nfunction blockToLlmContent(block: ContentBlock): LlmContent {\n\tswitch (block.type) {\n\t\tcase \"text\":\n\t\t\treturn { type: \"text\", text: block.text };\n\t\tcase \"image\":\n\t\t\treturn { type: \"image\", data: block.data, mimeType: block.mimeType };\n\t\tcase \"audio\":\n\t\t\treturn { type: \"text\", text: `[audio ${block.mimeType} omitted]` };\n\t\tcase \"resource_link\":\n\t\t\treturn { type: \"text\", text: `${block.name}: ${block.uri}` };\n\t\tcase \"resource\": {\n\t\t\tconst resource = block.resource;\n\t\t\tif (\"text\" in resource) return { type: \"text\", text: resource.text };\n\t\t\tif (resource.mimeType?.startsWith(\"image/\")) {\n\t\t\t\treturn { type: \"image\", data: resource.blob, mimeType: resource.mimeType };\n\t\t\t}\n\t\t\treturn {\n\t\t\t\ttype: \"text\",\n\t\t\t\ttext: `[binary resource ${resource.uri} (${resource.mimeType ?? \"unknown type\"}) omitted]`,\n\t\t\t};\n\t\t}\n\t\tdefault:\n\t\t\treturn { type: \"text\", text: `[unsupported MCP content ${(block as { type: string }).type}]` };\n\t}\n}\n\n/**\n * Convert a tool result to text and image content for a model. Text and images pass through,\n * embedded text resources become text, embedded image resources become images, and other blocks\n * (audio, resource links, binary resources) become a short text placeholder. A result without\n * content blocks but with `structuredContent` becomes its JSON, since servers should, but do not\n * always, mirror structured results as text.\n */\nexport function toLlmContent(result: Pick<CallToolResult, \"content\" | \"structuredContent\">): LlmContent[] {\n\tconst content = (result.content ?? []).map(blockToLlmContent);\n\tif (content.length === 0 && result.structuredContent !== undefined) {\n\t\tcontent.push({ type: \"text\", text: JSON.stringify(result.structuredContent, null, 2) });\n\t}\n\treturn content;\n}\n"]}
1
+ {"version":3,"file":"content.js","sourceRoot":"","sources":["../../src/protocol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0B,CAAC,IAAI,GAAG,EAAE,CAAC;IACjG,CAAC;AACF,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAAC,MAA6D;IACzF,MAAM,OAAO,GAAG,CAAC,MAAM,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;IAC9D,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,IAAI,MAAM,CAAC,iBAAiB,KAAK,SAAS,EAAE,CAAC;QACpE,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,iBAAiB,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;IACzF,CAAC;IACD,OAAO,OAAO,CAAC;AAChB,CAAC","sourcesContent":["export interface ContentAnnotations {\n\taudience?: (\"user\" | \"assistant\")[];\n\tpriority?: number;\n\tlastModified?: string;\n}\n\nexport interface TextContent {\n\ttype: \"text\";\n\ttext: string;\n\tannotations?: ContentAnnotations;\n\t_meta?: Record<string, unknown>;\n}\n\nexport interface ImageContent {\n\ttype: \"image\";\n\tdata: string;\n\tmimeType: string;\n\tannotations?: ContentAnnotations;\n\t_meta?: Record<string, unknown>;\n}\n\nexport interface AudioContent {\n\ttype: \"audio\";\n\tdata: string;\n\tmimeType: string;\n\tannotations?: ContentAnnotations;\n\t_meta?: Record<string, unknown>;\n}\n\nexport interface ResourceLinkContent {\n\ttype: \"resource_link\";\n\turi: string;\n\tname: string;\n\ttitle?: string;\n\tdescription?: string;\n\tmimeType?: string;\n\tsize?: number;\n\tannotations?: ContentAnnotations;\n\t_meta?: Record<string, unknown>;\n}\n\nexport interface TextResourceContents {\n\turi: string;\n\tmimeType?: string;\n\ttext: string;\n\t_meta?: Record<string, unknown>;\n}\n\nexport interface BlobResourceContents {\n\turi: string;\n\tmimeType?: string;\n\tblob: string;\n\t_meta?: Record<string, unknown>;\n}\n\nexport interface EmbeddedResourceContent {\n\ttype: \"resource\";\n\tresource: TextResourceContents | BlobResourceContents;\n\tannotations?: ContentAnnotations;\n\t_meta?: Record<string, unknown>;\n}\n\nexport type ContentBlock = TextContent | ImageContent | AudioContent | ResourceLinkContent | EmbeddedResourceContent;\n\nexport interface CallToolResult {\n\tcontent: ContentBlock[];\n\t/** Any JSON value, including arrays and `null` (MCP 2026-07-28; earlier revisions allowed only objects). */\n\tstructuredContent?: unknown;\n\tisError?: boolean;\n\t_meta?: Record<string, unknown>;\n}\n\n/**\n * Tool result content in the shape LLM APIs accept: text and base64 images. Matches the\n * `TextContent` and `ImageContent` types of `@earendil-works/pi-ai`.\n */\nexport type LlmContent = { type: \"text\"; text: string } | { type: \"image\"; data: string; mimeType: string };\n\nfunction blockToLlmContent(block: ContentBlock): LlmContent {\n\tswitch (block.type) {\n\t\tcase \"text\":\n\t\t\treturn { type: \"text\", text: block.text };\n\t\tcase \"image\":\n\t\t\treturn { type: \"image\", data: block.data, mimeType: block.mimeType };\n\t\tcase \"audio\":\n\t\t\treturn { type: \"text\", text: `[audio ${block.mimeType} omitted]` };\n\t\tcase \"resource_link\":\n\t\t\treturn { type: \"text\", text: `${block.name}: ${block.uri}` };\n\t\tcase \"resource\": {\n\t\t\tconst resource = block.resource;\n\t\t\tif (\"text\" in resource) return { type: \"text\", text: resource.text };\n\t\t\tif (resource.mimeType?.startsWith(\"image/\")) {\n\t\t\t\treturn { type: \"image\", data: resource.blob, mimeType: resource.mimeType };\n\t\t\t}\n\t\t\treturn {\n\t\t\t\ttype: \"text\",\n\t\t\t\ttext: `[binary resource ${resource.uri} (${resource.mimeType ?? \"unknown type\"}) omitted]`,\n\t\t\t};\n\t\t}\n\t\tdefault:\n\t\t\treturn { type: \"text\", text: `[unsupported MCP content ${(block as { type: string }).type}]` };\n\t}\n}\n\n/**\n * Convert a tool result to text and image content for a model. Text and images pass through,\n * embedded text resources become text, embedded image resources become images, and other blocks\n * (audio, resource links, binary resources) become a short text placeholder. A result without\n * content blocks but with `structuredContent` becomes its JSON, since servers should, but do not\n * always, mirror structured results as text.\n */\nexport function toLlmContent(result: Pick<CallToolResult, \"content\" | \"structuredContent\">): LlmContent[] {\n\tconst content = (result.content ?? []).map(blockToLlmContent);\n\tif (content.length === 0 && result.structuredContent !== undefined) {\n\t\tcontent.push({ type: \"text\", text: JSON.stringify(result.structuredContent, null, 2) });\n\t}\n\treturn content;\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  import type { AuthProvider, McpFetch } from "../auth-provider.ts";
2
2
  import { type JsonRpcMessage } from "../protocol/jsonrpc.ts";
3
- import { type McpTransport, TransportEvents } from "./transport.ts";
3
+ import { type McpTransport, type McpTransportSendOptions, TransportEvents } from "./transport.ts";
4
4
  export interface SseEvent {
5
5
  event?: string;
6
6
  data: string;
@@ -56,18 +56,25 @@ export declare class StreamableHttpTransport extends TransportEvents implements
56
56
  private sessionIdValue;
57
57
  private protocolVersion;
58
58
  private getStreamStarted;
59
+ /** Access token of the latest request, which `close()` reuses instead of asking the auth provider. */
60
+ private lastToken;
59
61
  constructor(options: StreamableHttpTransportOptions);
60
62
  get sessionId(): string | undefined;
61
63
  start(): Promise<void>;
62
64
  setProtocolVersion(version: string): void;
63
- send(message: JsonRpcMessage): Promise<void>;
65
+ send(message: JsonRpcMessage, { signal }?: McpTransportSendOptions): Promise<void>;
64
66
  close(): Promise<void>;
65
67
  /**
66
68
  * Fetch with auth headers. A 401 (or a 403 asking for more scope) is handed to the auth provider
67
69
  * once, and the request is retried with whatever credentials it left behind.
70
+ *
71
+ * `signal` only stops dispatch: getting a token or the authorization recovery can take a while, and a
72
+ * request its sender gave up on in the meantime must not reach the server. It does not abort the shared
73
+ * recovery, which other requests may wait for.
68
74
  */
69
75
  private authorizedFetch;
70
76
  private headers;
77
+ private buildHeaders;
71
78
  private captureSession;
72
79
  private checkResponse;
73
80
  private consumeSse;
@@ -1 +1 @@
1
- {"version":3,"file":"streamable-http.d.ts","sourceRoot":"","sources":["../../src/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,eAAe,CAAqB;IAC5C,OAAO,CAAC,gBAAgB,CAAS;IACjC,sGAAsG;IACtG,OAAO,CAAC,SAAS,CAAqB;IAEtC,YAAY,OAAO,EAAE,8BAA8B,EAQlD;IAED,IAAI,SAAS,IAAI,MAAM,GAAG,SAAS,CAElC;IAEK,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAI3B;IAED,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAExC;IAEK,IAAI,CAAC,OAAO,EAAE,cAAc,EAAE,EAAE,MAAM,EAAE,GAAE,uBAA4B,GAAG,OAAO,CAAC,IAAI,CAAC,CAmC3F;IAEK,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAiB3B;IAED;;;;;;;OAOG;YACW,eAAe;YAwBf,OAAO;IAMrB,OAAO,CAAC,YAAY;IASpB,OAAO,CAAC,cAAc;YAKR,aAAa;YAQb,UAAU;IA8BxB;;;;OAIG;YACW,qBAAqB;IAwCnC,OAAO,CAAC,cAAc;IAMtB,sFAAsF;YACxE,YAAY;IA2B1B,gGAAgG;YAClF,aAAa;IAqB3B;;;OAGG;IACH,OAAO,CAAC,WAAW;IAOnB,OAAO,CAAC,cAAc;IAMtB,OAAO,CAAC,QAAQ;IAIhB,OAAO,CAAC,UAAU;IAIlB,8DAA8D;IAC9D,OAAO,CAAC,KAAK;CAiBb"}
@@ -1,5 +1,5 @@
1
- import { isJsonRpcRequest, isJsonRpcResponse, JSON_RPC_ERROR_CODES, McpConnectionClosedError, parseJsonRpcMessage, toError, } from "../protocol/jsonrpc.js";
2
- import { DEFAULT_MAX_MESSAGE_BYTES, TransportEvents } from "./transport.js";
1
+ import { isJsonRpcRequest, isJsonRpcResponse, JSON_RPC_ERROR_CODES, McpAbortError, McpConnectionClosedError, parseJsonRpcMessage, toError, } from "../protocol/jsonrpc.js";
2
+ import { DEFAULT_MAX_MESSAGE_BYTES, TransportEvents, } from "./transport.js";
3
3
  const MAX_ERROR_BODY_BYTES = 8 * 1024;
4
4
  const ERROR_MESSAGE_BODY_CHARS = 500;
5
5
  const DEFAULT_RECONNECT_INITIAL_DELAY_MS = 1_000;
@@ -138,6 +138,8 @@ export class StreamableHttpTransport extends TransportEvents {
138
138
  sessionIdValue;
139
139
  protocolVersion;
140
140
  getStreamStarted = false;
141
+ /** Access token of the latest request, which `close()` reuses instead of asking the auth provider. */
142
+ lastToken;
141
143
  constructor(options) {
142
144
  super();
143
145
  this.options = Object.freeze({ ...options, headers: options.headers ? { ...options.headers } : undefined });
@@ -160,13 +162,13 @@ export class StreamableHttpTransport extends TransportEvents {
160
162
  setProtocolVersion(version) {
161
163
  this.protocolVersion = version;
162
164
  }
163
- async send(message) {
165
+ async send(message, { signal } = {}) {
164
166
  if (!this.started || this.closed)
165
167
  throw new McpConnectionClosedError();
166
168
  const response = await this.authorizedFetch("POST", {
167
169
  headers: { accept: "application/json, text/event-stream", "content-type": "application/json" },
168
170
  body: JSON.stringify(message),
169
- });
171
+ }, signal);
170
172
  await this.checkResponse(response);
171
173
  this.captureSession(response);
172
174
  if (!isJsonRpcRequest(message)) {
@@ -200,31 +202,34 @@ export class StreamableHttpTransport extends TransportEvents {
200
202
  this.closed = true;
201
203
  this.controller.abort();
202
204
  if (this.started && this.sessionIdValue) {
203
- const controller = new AbortController();
204
- const timeout = setTimeout(() => controller.abort(), 1_000);
205
+ // Best effort: the session expires on the server anyway. The auth provider may refresh tokens
206
+ // over the network, so it is not asked here and closing never waits for a refresh.
205
207
  try {
206
- const { headers } = await this.headers();
207
- await this.fetch(this.url, { method: "DELETE", headers, signal: controller.signal })
208
- .then(discard)
209
- .catch(() => undefined);
210
- }
211
- catch {
212
- // Resolving auth headers failed; the session will expire on the server.
213
- }
214
- finally {
215
- clearTimeout(timeout);
208
+ const response = await this.fetch(this.url, {
209
+ method: "DELETE",
210
+ headers: this.buildHeaders({}, this.lastToken),
211
+ signal: AbortSignal.timeout(1_000),
212
+ });
213
+ await discard(response);
216
214
  }
215
+ catch { }
217
216
  }
218
217
  this.emitClose();
219
218
  }
220
219
  /**
221
220
  * Fetch with auth headers. A 401 (or a 403 asking for more scope) is handed to the auth provider
222
221
  * once, and the request is retried with whatever credentials it left behind.
222
+ *
223
+ * `signal` only stops dispatch: getting a token or the authorization recovery can take a while, and a
224
+ * request its sender gave up on in the meantime must not reach the server. It does not abort the shared
225
+ * recovery, which other requests may wait for.
223
226
  */
224
- async authorizedFetch(method, init) {
227
+ async authorizedFetch(method, init, signal) {
225
228
  const onUnauthorized = this.options.authProvider?.onUnauthorized?.bind(this.options.authProvider);
226
229
  for (let attempt = 0;; attempt++) {
227
230
  const { headers, token } = await this.headers(init.headers);
231
+ if (signal?.aborted)
232
+ throw new McpAbortError();
228
233
  const response = await this.fetch(this.url, {
229
234
  method,
230
235
  headers,
@@ -242,6 +247,11 @@ export class StreamableHttpTransport extends TransportEvents {
242
247
  }
243
248
  }
244
249
  async headers(extra = {}) {
250
+ const token = await this.options.authProvider?.token();
251
+ this.lastToken = token;
252
+ return { headers: this.buildHeaders(extra, token), ...(token ? { token } : {}) };
253
+ }
254
+ buildHeaders(extra, token) {
245
255
  const headers = new Headers(this.options.headers);
246
256
  for (const [name, value] of Object.entries(extra))
247
257
  headers.set(name, value);
@@ -249,10 +259,9 @@ export class StreamableHttpTransport extends TransportEvents {
249
259
  headers.set("Mcp-Session-Id", this.sessionIdValue);
250
260
  if (this.protocolVersion)
251
261
  headers.set("MCP-Protocol-Version", this.protocolVersion);
252
- const token = await this.options.authProvider?.token();
253
262
  if (token)
254
263
  headers.set("Authorization", `Bearer ${token}`);
255
- return { headers, ...(token ? { token } : {}) };
264
+ return headers;
256
265
  }
257
266
  captureSession(response) {
258
267
  const sessionId = response.headers.get("mcp-session-id");