alchemylab-opencode 2.0.1 → 2.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (232) hide show
  1. package/NODE_COMPAT.md +8 -1
  2. package/dist/20260127222353_familiar_lady_ursula-YYOFSQD5.js +18 -0
  3. package/dist/20260211171708_add_project_commands-3GKQTPBZ.js +18 -0
  4. package/dist/20260213144116_wakeful_the_professor-ROO7OAVL.js +18 -0
  5. package/dist/20260225215848_workspace-V2OZTNFF.js +18 -0
  6. package/dist/20260227213759_add_session_workspace_id-GVDWAXKM.js +18 -0
  7. package/dist/20260228203230_blue_harpoon-Z5QP2II5.js +18 -0
  8. package/dist/20260303231226_add_workspace_fields-QOVAFN7W.js +18 -0
  9. package/dist/20260309230000_move_org_to_state-RQURSDZD.js +18 -0
  10. package/dist/20260312043431_session_message_cursor-VBISKDXL.js +18 -0
  11. package/dist/20260323234822_events-PILJHLNA.js +18 -0
  12. package/dist/20260410174513_workspace-name-63YCZ5NS.js +18 -0
  13. package/dist/20260413175956_chief_energizer-NMAZYGDO.js +18 -0
  14. package/dist/20260423070820_add_icon_url_override-RAJCVNEP.js +18 -0
  15. package/dist/20260427172553_slow_nightmare-ULYYZLR4.js +18 -0
  16. package/dist/20260428004200_add_session_path-U4WO2TGE.js +18 -0
  17. package/dist/20260501142318_next_venus-6BCYATSC.js +18 -0
  18. package/dist/20260504145000_add_sync_owner-RGVHV6LN.js +18 -0
  19. package/dist/20260507164347_add_workspace_time-GE6UHNPM.js +18 -0
  20. package/dist/{20260510033149_session_usage-UGBVOXZB.js → 20260510033149_session_usage-7XHCFVKY.js} +5 -1
  21. package/dist/20260511000411_data_migration_state-2EGZKFLB.js +18 -0
  22. package/dist/20260511173437_session-metadata-K322YY33.js +18 -0
  23. package/dist/20260601010001_normalize_storage_paths-VZDTY366.js +18 -0
  24. package/dist/{20260225215848_workspace-ZMSOZSPA.js → 20260601202201_amazing_prowler-YT6PLK3L.js} +5 -1
  25. package/dist/{20260228203230_blue_harpoon-IW3Z4TQZ.js → 20260602002951_lowly_union_jack-6VLQTBVB.js} +5 -1
  26. package/dist/20260602182828_add_project_directories-TVSRD25A.js +18 -0
  27. package/dist/20260603001617_session_message_projection_indexes-PHKTF6HK.js +18 -0
  28. package/dist/{20260622170816_reset_v2_session_state-5JPHJTZG.js → 20260603040000_session_message_projection_order-7RTV2POG.js} +5 -1
  29. package/dist/20260603141458_session_input_inbox-RSBWABG7.js +18 -0
  30. package/dist/20260603160727_jittery_ezekiel_stane-DXBLLRVV.js +18 -0
  31. package/dist/20260604172448_event_sourced_session_input-H6Z3JEBD.js +18 -0
  32. package/dist/20260605003541_add_session_context_snapshot-6FDPM2TK.js +18 -0
  33. package/dist/20260605042240_add_context_epoch_agent-C2OF2UKR.js +18 -0
  34. package/dist/20260611035744_credential-YNZ47FSH.js +18 -0
  35. package/dist/20260611192811_lush_chimera-E357VI6P.js +18 -0
  36. package/dist/20260612174303_project_dir_strategy-VUGGK42O.js +18 -0
  37. package/dist/20260622142730_simplify_session_context_epoch-UYGXZ5BX.js +18 -0
  38. package/dist/20260622170816_reset_v2_session_state-EILLPCJQ.js +18 -0
  39. package/dist/20260622202450_simplify_session_input-Y65GDGBO.js +18 -0
  40. package/dist/NodeSdk-AGMQWBHH.js +18 -0
  41. package/dist/anthropic-45OFTLAW.js +18 -0
  42. package/dist/anthropic-ND6UHXWL.js +18 -0
  43. package/dist/app-runtime-ZWWQ4JTM.js +18 -0
  44. package/dist/chunk-2MRHL4B2.js +18 -0
  45. package/dist/chunk-2XWBNI3L.js +1490 -0
  46. package/dist/chunk-4MBUHJHY.js +22 -0
  47. package/dist/chunk-6MAPFAXY.js +190 -0
  48. package/dist/chunk-7XX6TY62.js +259 -0
  49. package/dist/chunk-ANF3QA3Z.js +48 -0
  50. package/dist/chunk-AUB2TEYJ.js +55 -0
  51. package/dist/chunk-AZUMH3TO.js +18 -0
  52. package/dist/chunk-BQ4IEPN3.js +19 -0
  53. package/dist/chunk-CYRZU5QM.js +33 -0
  54. package/dist/chunk-DGJQZN2Q.js +18 -0
  55. package/dist/chunk-DO2UZ6NY.js +18 -0
  56. package/dist/chunk-DZ6G4VSD.js +19 -0
  57. package/dist/chunk-EK6FQQHY.js +20 -0
  58. package/dist/chunk-ELPXQ32J.js +90 -0
  59. package/dist/chunk-F5PY52BY.js +18 -0
  60. package/dist/chunk-FGLPSSRK.js +19 -0
  61. package/dist/chunk-FV7U6PVP.js +18 -0
  62. package/dist/chunk-FYYAOZPU.js +18 -0
  63. package/dist/chunk-GDWO6EXN.js +22 -0
  64. package/dist/chunk-GW3ZRKAI.js +20 -0
  65. package/dist/chunk-IQSFXWDQ.js +18 -0
  66. package/dist/chunk-IYUSBBGY.js +35 -0
  67. package/dist/chunk-JPOFLMNH.js +18 -0
  68. package/dist/{chunk-VURLSDCB.js → chunk-K5LKDIVU.js} +4 -0
  69. package/dist/chunk-KS4WLVK5.js +19 -0
  70. package/dist/chunk-L3CE2Y3L.js +55 -0
  71. package/dist/chunk-LIXP4TPL.js +18 -0
  72. package/dist/chunk-LSC4RT5V.js +36 -0
  73. package/dist/chunk-M5A6NFHQ.js +28 -0
  74. package/dist/chunk-M6E6KNLV.js +30 -0
  75. package/dist/chunk-MLFZXUGQ.js +18 -0
  76. package/dist/chunk-NDI67DRG.js +31 -0
  77. package/dist/chunk-OCWGUTZJ.js +36 -0
  78. package/dist/chunk-OGDRUXMJ.js +18 -0
  79. package/dist/chunk-OGJKLJC7.js +29 -0
  80. package/dist/chunk-P5RLCJUV.js +18 -0
  81. package/dist/chunk-Q3WIUQXB.js +18 -0
  82. package/dist/{20260227213759_add_session_workspace_id-ROENWPKA.js → chunk-QCRIXKIC.js} +5 -1
  83. package/dist/chunk-QD24DLUD.js +18 -0
  84. package/dist/chunk-R2GWBJEP.js +18 -0
  85. package/dist/chunk-RIA6SDOY.js +780 -0
  86. package/dist/chunk-RPAXSOGH.js +18 -0
  87. package/dist/chunk-TK5R7QUN.js +18 -0
  88. package/dist/chunk-TNQWZFIZ.js +28 -0
  89. package/dist/chunk-UCLPBO4I.js +18 -0
  90. package/dist/chunk-V6FDDNGV.js +117 -0
  91. package/dist/chunk-V6HERYFV.js +18 -0
  92. package/dist/chunk-V7XKKJ7X.js +24 -0
  93. package/dist/chunk-VHDYUBBS.js +23 -0
  94. package/dist/chunk-VWLJXTZ5.js +18 -0
  95. package/dist/chunk-VXAPFOIL.js +22 -0
  96. package/dist/chunk-WKZYINC7.js +29 -0
  97. package/dist/chunk-WL33KE3H.js +920 -0
  98. package/dist/chunk-WPMP2ZFE.js +40 -0
  99. package/dist/chunk-WRTNIOI3.js +18 -0
  100. package/dist/chunk-WZ4237YY.js +19 -0
  101. package/dist/chunk-X5F46HR5.js +18 -0
  102. package/dist/chunk-XPS7TQZG.js +22 -0
  103. package/dist/chunk-XSKT4AXR.js +878 -0
  104. package/dist/chunk-YJPP6IQ3.js +23 -0
  105. package/dist/chunk-ZYQWFC55.js +22 -0
  106. package/dist/code-mode-H3HRSD24.js +502 -0
  107. package/dist/copilot-provider-QVMLQZZC.js +18 -0
  108. package/dist/dist-5NQOHNPL.js +18 -0
  109. package/dist/dist-7CT3XCNN.js +32 -0
  110. package/dist/dist-CL46WFZG.js +18 -0
  111. package/dist/dist-HXJTF22W.js +32 -0
  112. package/dist/dist-JFXI53ZF.js +22 -0
  113. package/dist/dist-KBYKWVT5.js +22 -0
  114. package/dist/dist-KGNO5AP7.js +35 -0
  115. package/dist/dist-KTNLTEHB.js +18 -0
  116. package/dist/dist-KZ5R5QM5.js +24 -0
  117. package/dist/{20260605042240_add_context_epoch_agent-W6IQYZXE.js → dist-LOXU6IEM.js} +5 -1
  118. package/dist/dist-NLXUYBW7.js +32 -0
  119. package/dist/dist-O4DF72J2.js +22 -0
  120. package/dist/dist-PH4MEGVR.js +22 -0
  121. package/dist/{20260511000411_data_migration_state-FB4LBFSE.js → dist-QJPOJCLB.js} +5 -1
  122. package/dist/dist-QYH62TCJ.js +22 -0
  123. package/dist/{20260303231226_add_workspace_fields-OUVZMNAG.js → dist-RIC4WKHC.js} +5 -1
  124. package/dist/dist-T776XKTM.js +22 -0
  125. package/dist/dist-TCE5MKZQ.js +23 -0
  126. package/dist/dist-TH2Q44RX.js +50 -0
  127. package/dist/dist-VV5FV5RT.js +101 -0
  128. package/dist/dist-WZJ3LNRG.js +28 -0
  129. package/dist/dist-XAFENVUS.js +22 -0
  130. package/dist/dist-XPFB35TX.js +32 -0
  131. package/dist/dist-es-43ZM44MP.js +18 -0
  132. package/dist/dist-es-CH2YKBKX.js +18 -0
  133. package/dist/{20260428004200_add_session_path-LGW75WYA.js → dist-es-DHCTZZ2E.js} +5 -1
  134. package/dist/dist-es-EVVG3KDV.js +26 -0
  135. package/dist/dist-es-HRCONNGK.js +18 -0
  136. package/dist/dist-es-L2GU465G.js +18 -0
  137. package/dist/dist-es-RGEIM2BP.js +18 -0
  138. package/dist/dist-es-RZ25XEH6.js +18 -0
  139. package/dist/dist-es-SITTNOGV.js +18 -0
  140. package/dist/esm-NN5W7YCL.js +18 -0
  141. package/dist/esm-XWJSHYHG.js +18 -0
  142. package/dist/getMachineId-bsd-L5I5TZ5I.js +18 -0
  143. package/dist/getMachineId-darwin-YB7KG37W.js +19 -0
  144. package/dist/getMachineId-linux-EL47KXX7.js +18 -0
  145. package/dist/getMachineId-unsupported-QOWPEBPN.js +18 -0
  146. package/dist/getMachineId-win-HCRYRDFJ.js +18 -0
  147. package/dist/lib-7VH6D2QJ.js +199 -0
  148. package/dist/loadCognitoIdentity-EWT55EI7.js +18 -0
  149. package/dist/loadSso-AGOUE6RL.js +18 -0
  150. package/dist/{20260213144116_wakeful_the_professor-ZVDD54AK.js → loadSts-RH5L3PIX.js} +5 -1
  151. package/dist/mantle-IJXDXT4M.js +25 -0
  152. package/dist/mime-types-GSWEOYZ5.js +18 -0
  153. package/dist/multipart-parser-KZWMKXA4.js +19 -0
  154. package/dist/{20260211171708_add_project_commands-GDOHPDPF.js → open-7KXTRM37.js} +5 -1
  155. package/dist/openai-ZOJI6I5R.js +18 -0
  156. package/dist/p-map-CYL6ILJW.js +18 -0
  157. package/dist/photon-W56QZY4L.js +18 -0
  158. package/dist/{20260423070820_add_icon_url_override-X5SHFGTI.js → pkce-VT4ITJTB.js} +5 -1
  159. package/dist/{pty.node-Y3N2XKYG.js → pty.node-IWULXXG6.js} +5 -1
  160. package/dist/run.js +5 -1
  161. package/dist/serve.js +143 -1
  162. package/dist/server-XRUYBM7W.js +21 -0
  163. package/dist/session-4BXV4JJH.js +18 -0
  164. package/dist/signin-DKBWDEYP.js +18 -0
  165. package/dist/src-JODD73WX.js +18 -0
  166. package/dist/src-QJHT5SCV.js +18 -0
  167. package/dist/src-SMM4U63G.js +18 -0
  168. package/dist/src-WDYKISPD.js +20 -0
  169. package/dist/sso-oidc-S3P64MCY.js +18 -0
  170. package/dist/sts-RG44NMOQ.js +18 -0
  171. package/dist/token-2V62AM3G.js +18 -0
  172. package/dist/token-util-VXONHEUD.js +18 -0
  173. package/dist/unified-W3ZKZ4HG.js +18 -0
  174. package/dist/worktree-B2LROS2B.js +18 -0
  175. package/package.json +40 -40
  176. package/postinstall.cjs +4 -2
  177. package/dist/20260127222353_familiar_lady_ursula-KV747FJX.js +0 -14
  178. package/dist/20260309230000_move_org_to_state-NOXAPU5V.js +0 -14
  179. package/dist/20260312043431_session_message_cursor-DJ4T3T4R.js +0 -14
  180. package/dist/20260323234822_events-72GIKJ2A.js +0 -14
  181. package/dist/20260410174513_workspace-name-JXSWFBJN.js +0 -14
  182. package/dist/20260413175956_chief_energizer-4HEWZ6U3.js +0 -14
  183. package/dist/20260427172553_slow_nightmare-PS5T2AH2.js +0 -14
  184. package/dist/20260501142318_next_venus-J3TLVXZ6.js +0 -14
  185. package/dist/20260504145000_add_sync_owner-3R52GB4C.js +0 -14
  186. package/dist/20260507164347_add_workspace_time-JHDRCZAR.js +0 -14
  187. package/dist/20260511173437_session-metadata-T2XHGWHS.js +0 -14
  188. package/dist/20260601010001_normalize_storage_paths-5MAY5GT3.js +0 -14
  189. package/dist/20260601202201_amazing_prowler-PET224YG.js +0 -14
  190. package/dist/20260602002951_lowly_union_jack-PG6XDMGL.js +0 -14
  191. package/dist/20260602182828_add_project_directories-ZCH2ACGG.js +0 -14
  192. package/dist/20260603001617_session_message_projection_indexes-XVLJTUF2.js +0 -14
  193. package/dist/20260603040000_session_message_projection_order-XG6RACZQ.js +0 -14
  194. package/dist/20260603141458_session_input_inbox-K2VQ7V6E.js +0 -14
  195. package/dist/20260603160727_jittery_ezekiel_stane-WKJLRDO7.js +0 -14
  196. package/dist/20260604172448_event_sourced_session_input-NTXOECR7.js +0 -14
  197. package/dist/20260605003541_add_session_context_snapshot-DXMQEXMT.js +0 -14
  198. package/dist/20260611035744_credential-XTMSYTJD.js +0 -14
  199. package/dist/20260611192811_lush_chimera-XPLIQMJD.js +0 -14
  200. package/dist/20260612174303_project_dir_strategy-FR2NGQKK.js +0 -14
  201. package/dist/20260622142730_simplify_session_context_epoch-NTQZR3RE.js +0 -14
  202. package/dist/20260622202450_simplify_session_input-2EXF2HMV.js +0 -14
  203. package/dist/app-runtime-HQBOCDV5.js +0 -14
  204. package/dist/chunk-4FEBIOI5.js +0 -865
  205. package/dist/chunk-4K2RXRZL.js +0 -14
  206. package/dist/chunk-4RFMKEKM.js +0 -1455
  207. package/dist/chunk-BM2C7NHL.js +0 -41
  208. package/dist/chunk-MKEMZFJI.js +0 -393
  209. package/dist/chunk-OMDJ6ZZ2.js +0 -684
  210. package/dist/chunk-OWMG4NNF.js +0 -186
  211. package/dist/chunk-QRABYJKL.js +0 -14
  212. package/dist/chunk-RHIWAYN5.js +0 -14
  213. package/dist/chunk-Z5TLIUAI.js +0 -28
  214. package/dist/code-mode-7BQJUARW.js +0 -40
  215. package/dist/copilot-provider-TX4YFKJZ.js +0 -14
  216. package/dist/photon-VQS5F5BI.js +0 -14
  217. package/dist/server-BFUQR7MX.js +0 -17
  218. package/dist/session-6RNXZNG6.js +0 -14
  219. package/dist/worktree-QHQHX3SG.js +0 -14
  220. package/patches/@ai-sdk%2Famazon-bedrock@4.0.166.patch +0 -164
  221. package/patches/@ai-sdk%2Fanthropic@3.0.111.patch +0 -528
  222. package/patches/@ai-sdk%2Fgoogle@3.0.73.patch +0 -69
  223. package/patches/@ai-sdk%2Fgroq@3.0.31.patch +0 -79
  224. package/patches/@ai-sdk%2Fmistral@3.0.51.patch +0 -714
  225. package/patches/@ai-sdk%2Fopenai-compatible@2.0.41.patch +0 -39
  226. package/patches/@ai-sdk%2Fopenai@3.0.88.patch +0 -280
  227. package/patches/@ai-sdk%2Fxai@3.0.139.patch +0 -296
  228. package/patches/@modelcontextprotocol%2Fsdk@1.29.0.patch +0 -647
  229. package/patches/@npmcli%2Fagent@4.0.2.patch +0 -13
  230. package/patches/effect@4.0.0-beta.83.patch +0 -57
  231. package/patches/gcp-metadata@8.1.2.patch +0 -14
  232. package/patches/pacote@21.5.0.patch +0 -18
@@ -1,647 +0,0 @@
1
- diff --git a/dist/cjs/client/index.d.ts b/dist/cjs/client/index.d.ts
2
- index 1822bf749aec71d2bb295083d832114ee187bb67..58b859a7b32222fb5cb9f2011fdc5d010f3d05fb 100644
3
- --- a/dist/cjs/client/index.d.ts
4
- +++ b/dist/cjs/client/index.d.ts
5
- @@ -428,6 +428,8 @@ export declare class Client<RequestT extends Request = Request, NotificationT ex
6
- *
7
- * For task-based execution with streaming behavior, use client.experimental.tasks.callToolStream() instead.
8
- */
9
- + callTool(params: CallToolRequest['params'], resultSchema?: undefined, options?: RequestOptions): Promise<SchemaOutput<typeof CallToolResultSchema>>;
10
- + callTool<T extends typeof CallToolResultSchema | typeof CompatibilityCallToolResultSchema>(params: CallToolRequest['params'], resultSchema: T, options?: RequestOptions): Promise<SchemaOutput<T>>;
11
- callTool(params: CallToolRequest['params'], resultSchema?: typeof CallToolResultSchema | typeof CompatibilityCallToolResultSchema, options?: RequestOptions): Promise<{
12
- [x: string]: unknown;
13
- content: ({
14
- diff --git a/dist/esm/client/index.d.ts b/dist/esm/client/index.d.ts
15
- index 1822bf749aec71d2bb295083d832114ee187bb67..58b859a7b32222fb5cb9f2011fdc5d010f3d05fb 100644
16
- --- a/dist/esm/client/index.d.ts
17
- +++ b/dist/esm/client/index.d.ts
18
- @@ -428,6 +428,8 @@ export declare class Client<RequestT extends Request = Request, NotificationT ex
19
- *
20
- * For task-based execution with streaming behavior, use client.experimental.tasks.callToolStream() instead.
21
- */
22
- + callTool(params: CallToolRequest['params'], resultSchema?: undefined, options?: RequestOptions): Promise<SchemaOutput<typeof CallToolResultSchema>>;
23
- + callTool<T extends typeof CallToolResultSchema | typeof CompatibilityCallToolResultSchema>(params: CallToolRequest['params'], resultSchema: T, options?: RequestOptions): Promise<SchemaOutput<T>>;
24
- callTool(params: CallToolRequest['params'], resultSchema?: typeof CallToolResultSchema | typeof CompatibilityCallToolResultSchema, options?: RequestOptions): Promise<{
25
- [x: string]: unknown;
26
- content: ({
27
- diff --git a/dist/cjs/client/index.js b/dist/cjs/client/index.js
28
- index 6ac1da14dc7f6211ae70f7711c124b76098816d8..adb5b7bd45514a406a0f7e40b64631c101584c84 100644
29
- --- a/dist/cjs/client/index.js
30
- +++ b/dist/cjs/client/index.js
31
- @@ -288,41 +288,16 @@ class Client extends protocol_js_1.Protocol {
32
- }
33
- async connect(transport, options) {
34
- await super.connect(transport);
35
- + transport.onsessionexpired = async () => {
36
- + await this._initialize(transport);
37
- + };
38
- // When transport sessionId is already set this means we are trying to reconnect.
39
- // In this case we don't need to initialize again.
40
- if (transport.sessionId !== undefined) {
41
- return;
42
- }
43
- try {
44
- - const result = await this.request({
45
- - method: 'initialize',
46
- - params: {
47
- - protocolVersion: types_js_1.LATEST_PROTOCOL_VERSION,
48
- - capabilities: this._capabilities,
49
- - clientInfo: this._clientInfo
50
- - }
51
- - }, types_js_1.InitializeResultSchema, options);
52
- - if (result === undefined) {
53
- - throw new Error(`Server sent invalid initialize result: ${result}`);
54
- - }
55
- - if (!types_js_1.SUPPORTED_PROTOCOL_VERSIONS.includes(result.protocolVersion)) {
56
- - throw new Error(`Server's protocol version is not supported: ${result.protocolVersion}`);
57
- - }
58
- - this._serverCapabilities = result.capabilities;
59
- - this._serverVersion = result.serverInfo;
60
- - // HTTP transports must set the protocol version in each header after initialization.
61
- - if (transport.setProtocolVersion) {
62
- - transport.setProtocolVersion(result.protocolVersion);
63
- - }
64
- - this._instructions = result.instructions;
65
- - await this.notification({
66
- - method: 'notifications/initialized'
67
- - });
68
- - // Set up list changed handlers now that we know server capabilities
69
- - if (this._pendingListChangedConfig) {
70
- - this._setupListChangedHandlers(this._pendingListChangedConfig);
71
- - this._pendingListChangedConfig = undefined;
72
- - }
73
- + await this._initialize(transport, options);
74
- }
75
- catch (error) {
76
- // Disconnect if initialization fails.
77
- @@ -330,6 +305,37 @@ class Client extends protocol_js_1.Protocol {
78
- throw error;
79
- }
80
- }
81
- + async _initialize(transport, options) {
82
- + const result = await this.request({
83
- + method: 'initialize',
84
- + params: {
85
- + protocolVersion: types_js_1.LATEST_PROTOCOL_VERSION,
86
- + capabilities: this._capabilities,
87
- + clientInfo: this._clientInfo
88
- + }
89
- + }, types_js_1.InitializeResultSchema, options);
90
- + if (result === undefined) {
91
- + throw new Error(`Server sent invalid initialize result: ${result}`);
92
- + }
93
- + if (!types_js_1.SUPPORTED_PROTOCOL_VERSIONS.includes(result.protocolVersion)) {
94
- + throw new Error(`Server's protocol version is not supported: ${result.protocolVersion}`);
95
- + }
96
- + this._serverCapabilities = result.capabilities;
97
- + this._serverVersion = result.serverInfo;
98
- + // HTTP transports must set the protocol version in each header after initialization.
99
- + if (transport.setProtocolVersion) {
100
- + transport.setProtocolVersion(result.protocolVersion);
101
- + }
102
- + this._instructions = result.instructions;
103
- + await this.notification({
104
- + method: 'notifications/initialized'
105
- + });
106
- + // Set up list changed handlers now that we know server capabilities
107
- + if (this._pendingListChangedConfig) {
108
- + this._setupListChangedHandlers(this._pendingListChangedConfig);
109
- + this._pendingListChangedConfig = undefined;
110
- + }
111
- + }
112
- /**
113
- * After initialization has completed, this will be populated with the server's reported capabilities.
114
- */
115
- @@ -541,9 +547,11 @@ class Client extends protocol_js_1.Protocol {
116
- * Called after listTools() to pre-compile validators for better performance.
117
- */
118
- - cacheToolMetadata(tools) {
119
- - this._cachedToolOutputValidators.clear();
120
- - this._cachedKnownTaskTools.clear();
121
- - this._cachedRequiredTaskTools.clear();
122
- + cacheToolMetadata(tools, reset = true) {
123
- + if (reset) {
124
- + this._cachedToolOutputValidators.clear();
125
- + this._cachedKnownTaskTools.clear();
126
- + this._cachedRequiredTaskTools.clear();
127
- + }
128
- for (const tool of tools) {
129
- // If the tool has an outputSchema, create and cache the validator
130
- if (tool.outputSchema) {
131
- @@ -569,7 +577,7 @@ class Client extends protocol_js_1.Protocol {
132
- async listTools(params, options) {
133
- const result = await this.request({ method: 'tools/list', params }, types_js_1.ListToolsResultSchema, options);
134
- // Cache the tools and their output schemas for future validation
135
- - this.cacheToolMetadata(result.tools);
136
- + this.cacheToolMetadata(result.tools, params?.cursor === undefined);
137
- return result;
138
- }
139
- /**
140
- diff --git a/dist/cjs/client/streamableHttp.js b/dist/cjs/client/streamableHttp.js
141
- index a29a7d3a0f14d9cd800ef5b296485237350c666f..c362ae5fe6c62c8c8eae7e2e61de1eedff5443c9 100644
142
- --- a/dist/cjs/client/streamableHttp.js
143
- +++ b/dist/cjs/client/streamableHttp.js
144
- @@ -204,7 +204,7 @@ class StreamableHTTPClientTransport {
145
- if (!event.event || event.event === 'message') {
146
- try {
147
- const message = types_js_1.JSONRPCMessageSchema.parse(JSON.parse(event.data));
148
- - if ((0, types_js_1.isJSONRPCResultResponse)(message)) {
149
- + if ((0, types_js_1.isJSONRPCResultResponse)(message) || (0, types_js_1.isJSONRPCErrorResponse)(message)) {
150
- // Mark that we received a response - no need to reconnect for this request
151
- receivedResponse = true;
152
- if (replayMessageId !== undefined) {
153
- @@ -290,7 +290,38 @@ class StreamableHTTPClientTransport {
154
- this.onclose?.();
155
- }
156
- async send(message, options) {
157
- + return this._send(message, options, false);
158
- + }
159
- + async _recoverSession(expiredSessionId) {
160
- + if (this._sessionRecovery) {
161
- + await this._sessionRecovery;
162
- + return true;
163
- + }
164
- + if (this._sessionId !== expiredSessionId)
165
- + return true;
166
- + this._sessionId = undefined;
167
- + this._sessionRecovery = Promise.resolve().then(() => this.onsessionexpired?.());
168
- try {
169
- + await this._sessionRecovery;
170
- + }
171
- + catch (error) {
172
- + this._sessionId = undefined;
173
- + await this.close();
174
- + throw error;
175
- + }
176
- + finally {
177
- + this._sessionRecovery = undefined;
178
- + }
179
- + return true;
180
- + }
181
- + async _send(message, options, isSessionRetry) {
182
- + try {
183
- + if (this._sessionRecovery && !(0, types_js_1.isInitializeRequest)(message) && !(0, types_js_1.isInitializedNotification)(message)) {
184
- + await this._sessionRecovery;
185
- + if (options?.isRequestActive?.() === false) {
186
- + throw new Error('Request is no longer active');
187
- + }
188
- + }
189
- const { resumptionToken, onresumptiontoken } = options || {};
190
- if (resumptionToken) {
191
- // If we have at last event ID, we need to reconnect the SSE stream
192
- @@ -298,6 +329,7 @@ class StreamableHTTPClientTransport {
193
- return;
194
- }
195
- const headers = await this._commonHeaders();
196
- + const requestSessionId = headers.get('mcp-session-id') ?? undefined;
197
- headers.set('content-type', 'application/json');
198
- headers.set('accept', 'application/json, text/event-stream');
199
- const init = {
200
- @@ -310,11 +342,20 @@ class StreamableHTTPClientTransport {
201
- const response = await (this._fetch ?? fetch)(this._url, init);
202
- // Handle session ID received during initialization
203
- const sessionId = response.headers.get('mcp-session-id');
204
- - if (sessionId) {
205
- + if (sessionId && (requestSessionId === undefined || this._sessionId === requestSessionId)) {
206
- this._sessionId = sessionId;
207
- }
208
- if (!response.ok) {
209
- const text = await response.text().catch(() => null);
210
- + if (response.status === 404 && requestSessionId && !isSessionRetry && !(0, types_js_1.isInitializedNotification)(message)) {
211
- + const recovered = await this._recoverSession(requestSessionId);
212
- + if (options?.isRequestActive?.() === false) {
213
- + throw new Error('Request is no longer active');
214
- + }
215
- + if (recovered) {
216
- + return this._send(message, options, true);
217
- + }
218
- + }
219
- if (response.status === 401 && this._authProvider) {
220
- // Prevent infinite recursion when server returns 401 after successful auth
221
- if (this._hasCompletedAuthFlow) {
222
- @@ -335,7 +376,7 @@ class StreamableHTTPClientTransport {
223
- // Mark that we completed auth flow
224
- this._hasCompletedAuthFlow = true;
225
- // Purposely _not_ awaited, so we don't call onerror twice
226
- - return this.send(message);
227
- + return this._send(message, options, isSessionRetry);
228
- }
229
- if (response.status === 403 && this._authProvider) {
230
- const { resourceMetadataUrl, scope, error } = (0, auth_js_1.extractWWWAuthenticateParams)(response);
231
- @@ -362,7 +403,7 @@ class StreamableHTTPClientTransport {
232
- if (result !== 'AUTHORIZED') {
233
- throw new auth_js_1.UnauthorizedError();
234
- }
235
- - return this.send(message);
236
- + return this._send(message, options, isSessionRetry);
237
- }
238
- }
239
- throw new StreamableHTTPError(response.status, `Error POSTing to endpoint: ${text}`);
240
- diff --git a/dist/cjs/shared/protocol.js b/dist/cjs/shared/protocol.js
241
- index 3617e787f0ba70447c99501aee7aa67584d89758..4a96d6a0328fa348b96f3869ab7e0bb77538182b 100644
242
- --- a/dist/cjs/shared/protocol.js
243
- +++ b/dist/cjs/shared/protocol.js
244
- @@ -744,7 +744,12 @@ class Protocol {
245
- }
246
- else {
247
- // No related task - send through transport normally
248
- - this._transport.send(jsonrpcRequest, { relatedRequestId, resumptionToken, onresumptiontoken }).catch(error => {
249
- + this._transport.send(jsonrpcRequest, {
250
- + relatedRequestId,
251
- + resumptionToken,
252
- + onresumptiontoken,
253
- + isRequestActive: () => this._responseHandlers.has(messageId)
254
- + }).catch(error => {
255
- this._cleanupTimeout(messageId);
256
- reject(error);
257
- });
258
- diff --git a/dist/cjs/client/auth.d.ts b/dist/cjs/client/auth.d.ts
259
- index f4363ce7c94fbddf0e1d5943b1b26682bdbaa40e..e7dd57096e4f056bcd735d5081433beea1b32f04 100644
260
- --- a/dist/cjs/client/auth.d.ts
261
- +++ b/dist/cjs/client/auth.d.ts
262
- @@ -205,6 +205,15 @@ export declare function parseErrorResponse(input: Response | string): Promise<OA
263
- * @returns A Promise that resolves to an OAuthError instance
264
- */
265
- export declare function parseErrorResponse(input: Response | string): Promise<OAuthError>;
266
- +/**
267
- + * Selects scopes per the MCP spec and augments them for refresh token support.
268
- + */
269
- +export declare function determineScope(options: {
270
- + requestedScope?: string;
271
- + resourceMetadata?: OAuthProtectedResourceMetadata;
272
- + authServerMetadata?: AuthorizationServerMetadata;
273
- + clientMetadata: OAuthClientMetadata;
274
- +}): string | undefined;
275
- /**
276
- * Orchestrates the full auth flow with a server.
277
- *
278
- diff --git a/dist/cjs/client/auth.js b/dist/cjs/client/auth.js
279
- index c2e4fa91d26f5336889f6afa416147db75fc4872..178d7cfd96412d53bc14bbc13a8f76c11f727ee7 100644
280
- --- a/dist/cjs/client/auth.js
281
- +++ b/dist/cjs/client/auth.js
282
- @@ -7,6 +7,7 @@ exports.UnauthorizedError = void 0;
283
- exports.selectClientAuthMethod = selectClientAuthMethod;
284
- exports.parseErrorResponse = parseErrorResponse;
285
- exports.auth = auth;
286
- +exports.determineScope = determineScope;
287
- exports.isHttpsUrl = isHttpsUrl;
288
- exports.selectResourceURL = selectResourceURL;
289
- exports.extractWWWAuthenticateParams = extractWWWAuthenticateParams;
290
- @@ -186,6 +187,19 @@ async function auth(provider, options) {
291
- throw error;
292
- }
293
- }
294
- +/**
295
- + * Selects scopes per the MCP spec and augments them for refresh token support.
296
- + */
297
- +function determineScope({ requestedScope, resourceMetadata, authServerMetadata, clientMetadata }) {
298
- + let effectiveScope = requestedScope || resourceMetadata?.scopes_supported?.join(' ') || clientMetadata.scope;
299
- + if (effectiveScope &&
300
- + authServerMetadata?.scopes_supported?.includes('offline_access') &&
301
- + !effectiveScope.split(' ').includes('offline_access') &&
302
- + clientMetadata.grant_types?.includes('refresh_token')) {
303
- + effectiveScope = `${effectiveScope} offline_access`;
304
- + }
305
- + return effectiveScope;
306
- +}
307
- async function authInternal(provider, { serverUrl, authorizationCode, scope, resourceMetadataUrl, fetchFn }) {
308
- // Check if the provider has cached discovery state to skip discovery
309
- const cachedState = await provider.discoveryState?.();
310
- @@ -241,12 +255,12 @@ async function authInternal(provider, { serverUrl, authorizationCode, scope, res
311
- });
312
- }
313
- const resource = await selectResourceURL(serverUrl, provider, resourceMetadata);
314
- - // Apply scope selection strategy (SEP-835):
315
- - // 1. WWW-Authenticate scope (passed via `scope` param)
316
- - // 2. PRM scopes_supported
317
- - // 3. Client metadata scope (user-configured fallback)
318
- - // The resolved scope is used consistently for both DCR and the authorization request.
319
- - const resolvedScope = scope || resourceMetadata?.scopes_supported?.join(' ') || provider.clientMetadata.scope;
320
- + const resolvedScope = determineScope({
321
- + requestedScope: scope,
322
- + resourceMetadata,
323
- + authServerMetadata: metadata,
324
- + clientMetadata: provider.clientMetadata
325
- + });
326
- // Handle client registration if needed
327
- let clientInformation = await Promise.resolve(provider.clientInformation());
328
- if (!clientInformation) {
329
- @@ -741,7 +755,7 @@ async function startAuthorization(authorizationServerUrl, { metadata, clientInfo
330
- if (scope) {
331
- authorizationUrl.searchParams.set('scope', scope);
332
- }
333
- - if (scope?.includes('offline_access')) {
334
- + if (scope?.split(' ').includes('offline_access')) {
335
- // if the request includes the OIDC-only "offline_access" scope,
336
- // we need to set the prompt to "consent" to ensure the user is prompted to grant offline access
337
- // https://openid.net/specs/openid-connect-core-1_0.html#OfflineAccess
338
- diff --git a/dist/esm/client/auth.d.ts b/dist/esm/client/auth.d.ts
339
- index f4363ce7c94fbddf0e1d5943b1b26682bdbaa40e..e7dd57096e4f056bcd735d5081433beea1b32f04 100644
340
- --- a/dist/esm/client/auth.d.ts
341
- +++ b/dist/esm/client/auth.d.ts
342
- @@ -205,6 +205,15 @@ export declare function parseErrorResponse(input: Response | string): Promise<OA
343
- * @returns A Promise that resolves to an OAuthError instance
344
- */
345
- export declare function parseErrorResponse(input: Response | string): Promise<OAuthError>;
346
- +/**
347
- + * Selects scopes per the MCP spec and augments them for refresh token support.
348
- + */
349
- +export declare function determineScope(options: {
350
- + requestedScope?: string;
351
- + resourceMetadata?: OAuthProtectedResourceMetadata;
352
- + authServerMetadata?: AuthorizationServerMetadata;
353
- + clientMetadata: OAuthClientMetadata;
354
- +}): string | undefined;
355
- /**
356
- * Orchestrates the full auth flow with a server.
357
- *
358
- diff --git a/dist/esm/client/auth.js b/dist/esm/client/auth.js
359
- index e183040fc2bba22ca1ccc784984f3310854403b7..d367661e580ee61a96654f7af78b2af61dcad98b 100644
360
- --- a/dist/esm/client/auth.js
361
- +++ b/dist/esm/client/auth.js
362
- @@ -161,6 +161,19 @@ export async function auth(provider, options) {
363
- throw error;
364
- }
365
- }
366
- +/**
367
- + * Selects scopes per the MCP spec and augments them for refresh token support.
368
- + */
369
- +export function determineScope({ requestedScope, resourceMetadata, authServerMetadata, clientMetadata }) {
370
- + let effectiveScope = requestedScope || resourceMetadata?.scopes_supported?.join(' ') || clientMetadata.scope;
371
- + if (effectiveScope &&
372
- + authServerMetadata?.scopes_supported?.includes('offline_access') &&
373
- + !effectiveScope.split(' ').includes('offline_access') &&
374
- + clientMetadata.grant_types?.includes('refresh_token')) {
375
- + effectiveScope = `${effectiveScope} offline_access`;
376
- + }
377
- + return effectiveScope;
378
- +}
379
- async function authInternal(provider, { serverUrl, authorizationCode, scope, resourceMetadataUrl, fetchFn }) {
380
- // Check if the provider has cached discovery state to skip discovery
381
- const cachedState = await provider.discoveryState?.();
382
- @@ -216,12 +229,12 @@ async function authInternal(provider, { serverUrl, authorizationCode, scope, res
383
- });
384
- }
385
- const resource = await selectResourceURL(serverUrl, provider, resourceMetadata);
386
- - // Apply scope selection strategy (SEP-835):
387
- - // 1. WWW-Authenticate scope (passed via `scope` param)
388
- - // 2. PRM scopes_supported
389
- - // 3. Client metadata scope (user-configured fallback)
390
- - // The resolved scope is used consistently for both DCR and the authorization request.
391
- - const resolvedScope = scope || resourceMetadata?.scopes_supported?.join(' ') || provider.clientMetadata.scope;
392
- + const resolvedScope = determineScope({
393
- + requestedScope: scope,
394
- + resourceMetadata,
395
- + authServerMetadata: metadata,
396
- + clientMetadata: provider.clientMetadata
397
- + });
398
- // Handle client registration if needed
399
- let clientInformation = await Promise.resolve(provider.clientInformation());
400
- if (!clientInformation) {
401
- @@ -716,7 +729,7 @@ export async function startAuthorization(authorizationServerUrl, { metadata, cli
402
- if (scope) {
403
- authorizationUrl.searchParams.set('scope', scope);
404
- }
405
- - if (scope?.includes('offline_access')) {
406
- + if (scope?.split(' ').includes('offline_access')) {
407
- // if the request includes the OIDC-only "offline_access" scope,
408
- // we need to set the prompt to "consent" to ensure the user is prompted to grant offline access
409
- // https://openid.net/specs/openid-connect-core-1_0.html#OfflineAccess
410
- diff --git a/dist/esm/client/index.js b/dist/esm/client/index.js
411
- index 49b12c6cd918c457420fef7ad5528a9443d1a191..2afe2e22e960f26c9d516ef135d89f8eb9e4caff 100644
412
- --- a/dist/esm/client/index.js
413
- +++ b/dist/esm/client/index.js
414
- @@ -284,41 +284,16 @@ export class Client extends Protocol {
415
- }
416
- async connect(transport, options) {
417
- await super.connect(transport);
418
- + transport.onsessionexpired = async () => {
419
- + await this._initialize(transport);
420
- + };
421
- // When transport sessionId is already set this means we are trying to reconnect.
422
- // In this case we don't need to initialize again.
423
- if (transport.sessionId !== undefined) {
424
- return;
425
- }
426
- try {
427
- - const result = await this.request({
428
- - method: 'initialize',
429
- - params: {
430
- - protocolVersion: LATEST_PROTOCOL_VERSION,
431
- - capabilities: this._capabilities,
432
- - clientInfo: this._clientInfo
433
- - }
434
- - }, InitializeResultSchema, options);
435
- - if (result === undefined) {
436
- - throw new Error(`Server sent invalid initialize result: ${result}`);
437
- - }
438
- - if (!SUPPORTED_PROTOCOL_VERSIONS.includes(result.protocolVersion)) {
439
- - throw new Error(`Server's protocol version is not supported: ${result.protocolVersion}`);
440
- - }
441
- - this._serverCapabilities = result.capabilities;
442
- - this._serverVersion = result.serverInfo;
443
- - // HTTP transports must set the protocol version in each header after initialization.
444
- - if (transport.setProtocolVersion) {
445
- - transport.setProtocolVersion(result.protocolVersion);
446
- - }
447
- - this._instructions = result.instructions;
448
- - await this.notification({
449
- - method: 'notifications/initialized'
450
- - });
451
- - // Set up list changed handlers now that we know server capabilities
452
- - if (this._pendingListChangedConfig) {
453
- - this._setupListChangedHandlers(this._pendingListChangedConfig);
454
- - this._pendingListChangedConfig = undefined;
455
- - }
456
- + await this._initialize(transport, options);
457
- }
458
- catch (error) {
459
- // Disconnect if initialization fails.
460
- @@ -326,6 +301,37 @@ export class Client extends Protocol {
461
- throw error;
462
- }
463
- }
464
- + async _initialize(transport, options) {
465
- + const result = await this.request({
466
- + method: 'initialize',
467
- + params: {
468
- + protocolVersion: LATEST_PROTOCOL_VERSION,
469
- + capabilities: this._capabilities,
470
- + clientInfo: this._clientInfo
471
- + }
472
- + }, InitializeResultSchema, options);
473
- + if (result === undefined) {
474
- + throw new Error(`Server sent invalid initialize result: ${result}`);
475
- + }
476
- + if (!SUPPORTED_PROTOCOL_VERSIONS.includes(result.protocolVersion)) {
477
- + throw new Error(`Server's protocol version is not supported: ${result.protocolVersion}`);
478
- + }
479
- + this._serverCapabilities = result.capabilities;
480
- + this._serverVersion = result.serverInfo;
481
- + // HTTP transports must set the protocol version in each header after initialization.
482
- + if (transport.setProtocolVersion) {
483
- + transport.setProtocolVersion(result.protocolVersion);
484
- + }
485
- + this._instructions = result.instructions;
486
- + await this.notification({
487
- + method: 'notifications/initialized'
488
- + });
489
- + // Set up list changed handlers now that we know server capabilities
490
- + if (this._pendingListChangedConfig) {
491
- + this._setupListChangedHandlers(this._pendingListChangedConfig);
492
- + this._pendingListChangedConfig = undefined;
493
- + }
494
- + }
495
- /**
496
- * After initialization has completed, this will be populated with the server's reported capabilities.
497
- */
498
- @@ -537,9 +543,11 @@ export class Client extends Protocol {
499
- * Called after listTools() to pre-compile validators for better performance.
500
- */
501
- - cacheToolMetadata(tools) {
502
- - this._cachedToolOutputValidators.clear();
503
- - this._cachedKnownTaskTools.clear();
504
- - this._cachedRequiredTaskTools.clear();
505
- + cacheToolMetadata(tools, reset = true) {
506
- + if (reset) {
507
- + this._cachedToolOutputValidators.clear();
508
- + this._cachedKnownTaskTools.clear();
509
- + this._cachedRequiredTaskTools.clear();
510
- + }
511
- for (const tool of tools) {
512
- // If the tool has an outputSchema, create and cache the validator
513
- if (tool.outputSchema) {
514
- @@ -565,7 +573,7 @@ export class Client extends Protocol {
515
- async listTools(params, options) {
516
- const result = await this.request({ method: 'tools/list', params }, ListToolsResultSchema, options);
517
- // Cache the tools and their output schemas for future validation
518
- - this.cacheToolMetadata(result.tools);
519
- + this.cacheToolMetadata(result.tools, params?.cursor === undefined);
520
- return result;
521
- }
522
- /**
523
- diff --git a/dist/esm/client/streamableHttp.js b/dist/esm/client/streamableHttp.js
524
- index 624172aa24ae255a67c083f9c19053343e4a0581..ac75b14545fda44aff7ff4d97cc5da884fcc627a 100644
525
- --- a/dist/esm/client/streamableHttp.js
526
- +++ b/dist/esm/client/streamableHttp.js
527
- @@ -1,5 +1,5 @@
528
- import { createFetchWithInit, normalizeHeaders } from '../shared/transport.js';
529
- -import { isInitializedNotification, isJSONRPCRequest, isJSONRPCResultResponse, JSONRPCMessageSchema } from '../types.js';
530
- +import { isInitializedNotification, isInitializeRequest, isJSONRPCErrorResponse, isJSONRPCRequest, isJSONRPCResultResponse, JSONRPCMessageSchema } from '../types.js';
531
- import { auth, extractWWWAuthenticateParams, UnauthorizedError } from './auth.js';
532
- import { EventSourceParserStream } from 'eventsource-parser/stream';
533
- // Default reconnection options for StreamableHTTP connections
534
- @@ -200,7 +200,7 @@ export class StreamableHTTPClientTransport {
535
- if (!event.event || event.event === 'message') {
536
- try {
537
- const message = JSONRPCMessageSchema.parse(JSON.parse(event.data));
538
- - if (isJSONRPCResultResponse(message)) {
539
- + if (isJSONRPCResultResponse(message) || isJSONRPCErrorResponse(message)) {
540
- // Mark that we received a response - no need to reconnect for this request
541
- receivedResponse = true;
542
- if (replayMessageId !== undefined) {
543
- @@ -286,7 +286,38 @@ export class StreamableHTTPClientTransport {
544
- this.onclose?.();
545
- }
546
- async send(message, options) {
547
- + return this._send(message, options, false);
548
- + }
549
- + async _recoverSession(expiredSessionId) {
550
- + if (this._sessionRecovery) {
551
- + await this._sessionRecovery;
552
- + return true;
553
- + }
554
- + if (this._sessionId !== expiredSessionId)
555
- + return true;
556
- + this._sessionId = undefined;
557
- + this._sessionRecovery = Promise.resolve().then(() => this.onsessionexpired?.());
558
- try {
559
- + await this._sessionRecovery;
560
- + }
561
- + catch (error) {
562
- + this._sessionId = undefined;
563
- + await this.close();
564
- + throw error;
565
- + }
566
- + finally {
567
- + this._sessionRecovery = undefined;
568
- + }
569
- + return true;
570
- + }
571
- + async _send(message, options, isSessionRetry) {
572
- + try {
573
- + if (this._sessionRecovery && !isInitializeRequest(message) && !isInitializedNotification(message)) {
574
- + await this._sessionRecovery;
575
- + if (options?.isRequestActive?.() === false) {
576
- + throw new Error('Request is no longer active');
577
- + }
578
- + }
579
- const { resumptionToken, onresumptiontoken } = options || {};
580
- if (resumptionToken) {
581
- // If we have at last event ID, we need to reconnect the SSE stream
582
- @@ -294,6 +325,7 @@ export class StreamableHTTPClientTransport {
583
- return;
584
- }
585
- const headers = await this._commonHeaders();
586
- + const requestSessionId = headers.get('mcp-session-id') ?? undefined;
587
- headers.set('content-type', 'application/json');
588
- headers.set('accept', 'application/json, text/event-stream');
589
- const init = {
590
- @@ -306,11 +338,20 @@ export class StreamableHTTPClientTransport {
591
- const response = await (this._fetch ?? fetch)(this._url, init);
592
- // Handle session ID received during initialization
593
- const sessionId = response.headers.get('mcp-session-id');
594
- - if (sessionId) {
595
- + if (sessionId && (requestSessionId === undefined || this._sessionId === requestSessionId)) {
596
- this._sessionId = sessionId;
597
- }
598
- if (!response.ok) {
599
- const text = await response.text().catch(() => null);
600
- + if (response.status === 404 && requestSessionId && !isSessionRetry && !isInitializedNotification(message)) {
601
- + const recovered = await this._recoverSession(requestSessionId);
602
- + if (options?.isRequestActive?.() === false) {
603
- + throw new Error('Request is no longer active');
604
- + }
605
- + if (recovered) {
606
- + return this._send(message, options, true);
607
- + }
608
- + }
609
- if (response.status === 401 && this._authProvider) {
610
- // Prevent infinite recursion when server returns 401 after successful auth
611
- if (this._hasCompletedAuthFlow) {
612
- @@ -331,7 +372,7 @@ export class StreamableHTTPClientTransport {
613
- // Mark that we completed auth flow
614
- this._hasCompletedAuthFlow = true;
615
- // Purposely _not_ awaited, so we don't call onerror twice
616
- - return this.send(message);
617
- + return this._send(message, options, isSessionRetry);
618
- }
619
- if (response.status === 403 && this._authProvider) {
620
- const { resourceMetadataUrl, scope, error } = extractWWWAuthenticateParams(response);
621
- @@ -358,7 +399,7 @@ export class StreamableHTTPClientTransport {
622
- if (result !== 'AUTHORIZED') {
623
- throw new UnauthorizedError();
624
- }
625
- - return this.send(message);
626
- + return this._send(message, options, isSessionRetry);
627
- }
628
- }
629
- throw new StreamableHTTPError(response.status, `Error POSTing to endpoint: ${text}`);
630
- diff --git a/dist/esm/shared/protocol.js b/dist/esm/shared/protocol.js
631
- index bfa2b7120a0f50c569364ea5264e6f811076f44f..abd8dfd707c155f71dae7aeeeeaf7547368ac749 100644
632
- --- a/dist/esm/shared/protocol.js
633
- +++ b/dist/esm/shared/protocol.js
634
- @@ -740,7 +740,12 @@ export class Protocol {
635
- }
636
- else {
637
- // No related task - send through transport normally
638
- - this._transport.send(jsonrpcRequest, { relatedRequestId, resumptionToken, onresumptiontoken }).catch(error => {
639
- + this._transport.send(jsonrpcRequest, {
640
- + relatedRequestId,
641
- + resumptionToken,
642
- + onresumptiontoken,
643
- + isRequestActive: () => this._responseHandlers.has(messageId)
644
- + }).catch(error => {
645
- this._cleanupTimeout(messageId);
646
- reject(error);
647
- });
@@ -1,13 +0,0 @@
1
- diff --git a/lib/agents.js b/lib/agents.js
2
- index 45ec59c4c13757379095131c4f0a5ea6f7284f45..0763b031e355a755ec6a26f98461aa3f63b8339b 100644
3
- --- a/lib/agents.js
4
- +++ b/lib/agents.js
5
- @@ -32,7 +32,7 @@ module.exports = class Agent extends AgentBase {
6
- }
7
-
8
- get proxy () {
9
- - return this.#proxy ? { url: this.#proxy } : {}
10
- + return this.#proxy ? { url: this.#proxy.toString() } : {}
11
- }
12
-
13
- #getProxy (options) {