bangonit 0.5.7 → 0.5.9
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.
- package/README.md +22 -0
- package/app/webapp/.next/standalone/app/webapp/.next/BUILD_ID +1 -1
- package/app/webapp/.next/standalone/app/webapp/.next/app-path-routes-manifest.json +1 -1
- package/app/webapp/.next/standalone/app/webapp/.next/build-manifest.json +2 -2
- package/app/webapp/.next/standalone/app/webapp/.next/prerender-manifest.json +1 -1
- package/app/webapp/.next/standalone/app/webapp/.next/server/app/_not-found.html +1 -1
- package/app/webapp/.next/standalone/app/webapp/.next/server/app/_not-found.rsc +1 -1
- package/app/webapp/.next/standalone/app/webapp/.next/server/app/api/chat/route.js +1 -1
- package/app/webapp/.next/standalone/app/webapp/.next/server/app/api/chat/route.js.nft.json +1 -1
- package/app/webapp/.next/standalone/app/webapp/.next/server/app/api/screenshot/route.js +1 -1
- package/app/webapp/.next/standalone/app/webapp/.next/server/app/api/screenshot/route.js.nft.json +1 -1
- package/app/webapp/.next/standalone/app/webapp/.next/server/app/app.html +1 -1
- package/app/webapp/.next/standalone/app/webapp/.next/server/app/app.rsc +1 -1
- package/app/webapp/.next/standalone/app/webapp/.next/server/app/index.html +1 -1
- package/app/webapp/.next/standalone/app/webapp/.next/server/app/index.rsc +1 -1
- package/app/webapp/.next/standalone/app/webapp/.next/server/app-paths-manifest.json +2 -2
- package/app/webapp/.next/standalone/app/webapp/.next/server/chunks/151.js +1 -1
- package/app/webapp/.next/standalone/app/webapp/.next/server/chunks/{124.js → 373.js} +15 -15
- package/app/webapp/.next/standalone/app/webapp/.next/server/pages/404.html +1 -1
- package/app/webapp/.next/standalone/app/webapp/.next/server/pages/500.html +1 -1
- package/app/webapp/.next/standalone/app/webapp/.next/server/server-reference-manifest.json +1 -1
- package/app/webapp/.next/standalone/node_modules/@img/colour/color.cjs +1596 -0
- package/app/webapp/.next/standalone/node_modules/@img/colour/index.cjs +1 -0
- package/app/webapp/.next/standalone/node_modules/@img/colour/package.json +58 -0
- package/app/webapp/.next/standalone/node_modules/@img/sharp-libvips-linux-x64/lib/index.js +1 -0
- package/app/webapp/.next/standalone/node_modules/@img/sharp-libvips-linux-x64/lib/libvips-cpp.so.8.17.3 +0 -0
- package/app/webapp/.next/standalone/node_modules/@img/sharp-libvips-linux-x64/package.json +42 -0
- package/app/webapp/.next/standalone/node_modules/@img/sharp-libvips-linux-x64/versions.json +30 -0
- package/app/webapp/.next/standalone/node_modules/@img/sharp-libvips-linuxmusl-x64/lib/index.js +1 -0
- package/app/webapp/.next/standalone/node_modules/@img/sharp-libvips-linuxmusl-x64/lib/libvips-cpp.so.8.17.3 +0 -0
- package/app/webapp/.next/standalone/node_modules/@img/sharp-libvips-linuxmusl-x64/package.json +42 -0
- package/app/webapp/.next/standalone/node_modules/@img/sharp-libvips-linuxmusl-x64/versions.json +30 -0
- package/app/webapp/.next/standalone/node_modules/@img/sharp-linux-x64/LICENSE +191 -0
- package/app/webapp/.next/standalone/node_modules/@img/sharp-linux-x64/lib/sharp-linux-x64.node +0 -0
- package/app/webapp/.next/standalone/node_modules/@img/sharp-linux-x64/package.json +46 -0
- package/app/webapp/.next/standalone/node_modules/@img/sharp-linuxmusl-x64/LICENSE +191 -0
- package/app/webapp/.next/standalone/node_modules/@img/sharp-linuxmusl-x64/lib/sharp-linuxmusl-x64.node +0 -0
- package/app/webapp/.next/standalone/node_modules/@img/sharp-linuxmusl-x64/package.json +46 -0
- package/app/webapp/.next/standalone/node_modules/detect-libc/lib/detect-libc.js +313 -0
- package/app/webapp/.next/standalone/node_modules/detect-libc/lib/elf.js +39 -0
- package/app/webapp/.next/standalone/node_modules/detect-libc/lib/filesystem.js +51 -0
- package/app/webapp/.next/standalone/node_modules/detect-libc/lib/process.js +24 -0
- package/app/webapp/.next/standalone/node_modules/detect-libc/package.json +44 -0
- package/app/webapp/.next/standalone/node_modules/sharp/lib/channel.js +177 -0
- package/app/webapp/.next/standalone/node_modules/sharp/lib/colour.js +195 -0
- package/app/webapp/.next/standalone/node_modules/sharp/lib/composite.js +212 -0
- package/app/webapp/.next/standalone/node_modules/sharp/lib/constructor.js +499 -0
- package/app/webapp/.next/standalone/node_modules/sharp/lib/index.js +16 -0
- package/app/webapp/.next/standalone/node_modules/sharp/lib/input.js +809 -0
- package/app/webapp/.next/standalone/node_modules/sharp/lib/is.js +143 -0
- package/app/webapp/.next/standalone/node_modules/sharp/lib/libvips.js +207 -0
- package/app/webapp/.next/standalone/node_modules/sharp/lib/operation.js +1016 -0
- package/app/webapp/.next/standalone/node_modules/sharp/lib/output.js +1666 -0
- package/app/webapp/.next/standalone/node_modules/sharp/lib/resize.js +595 -0
- package/app/webapp/.next/standalone/node_modules/sharp/lib/sharp.js +121 -0
- package/app/webapp/.next/standalone/node_modules/sharp/lib/utility.js +291 -0
- package/app/webapp/.next/standalone/node_modules/sharp/node_modules/semver/classes/comparator.js +143 -0
- package/app/webapp/.next/standalone/node_modules/sharp/node_modules/semver/classes/range.js +557 -0
- package/app/webapp/.next/standalone/node_modules/sharp/node_modules/semver/classes/semver.js +333 -0
- package/app/webapp/.next/standalone/node_modules/sharp/node_modules/semver/functions/cmp.js +54 -0
- package/app/webapp/.next/standalone/node_modules/sharp/node_modules/semver/functions/coerce.js +62 -0
- package/app/webapp/.next/standalone/node_modules/sharp/node_modules/semver/functions/compare.js +7 -0
- package/app/webapp/.next/standalone/node_modules/sharp/node_modules/semver/functions/eq.js +5 -0
- package/app/webapp/.next/standalone/node_modules/sharp/node_modules/semver/functions/gt.js +5 -0
- package/app/webapp/.next/standalone/node_modules/sharp/node_modules/semver/functions/gte.js +5 -0
- package/app/webapp/.next/standalone/node_modules/sharp/node_modules/semver/functions/lt.js +5 -0
- package/app/webapp/.next/standalone/node_modules/sharp/node_modules/semver/functions/lte.js +5 -0
- package/app/webapp/.next/standalone/node_modules/sharp/node_modules/semver/functions/neq.js +5 -0
- package/app/webapp/.next/standalone/node_modules/sharp/node_modules/semver/functions/parse.js +18 -0
- package/app/webapp/.next/standalone/node_modules/sharp/node_modules/semver/functions/satisfies.js +12 -0
- package/app/webapp/.next/standalone/node_modules/sharp/node_modules/semver/internal/constants.js +37 -0
- package/app/webapp/.next/standalone/node_modules/sharp/node_modules/semver/internal/debug.js +11 -0
- package/app/webapp/.next/standalone/node_modules/sharp/node_modules/semver/internal/identifiers.js +29 -0
- package/app/webapp/.next/standalone/node_modules/sharp/node_modules/semver/internal/lrucache.js +42 -0
- package/app/webapp/.next/standalone/node_modules/sharp/node_modules/semver/internal/parse-options.js +17 -0
- package/app/webapp/.next/standalone/node_modules/sharp/node_modules/semver/internal/re.js +223 -0
- package/app/webapp/.next/standalone/node_modules/sharp/node_modules/semver/package.json +78 -0
- package/app/webapp/.next/standalone/node_modules/sharp/package.json +202 -0
- package/app/webapp/.next/standalone/package.json +12 -8
- package/bin/boi.js +22 -0
- package/package.json +12 -8
- package/bin/app/desktopapp/src/shared/args.js +0 -22
- package/bin/src/cli/bangonit.js +0 -1035
- /package/app/webapp/.next/standalone/app/webapp/.next/static/{Ovp2DYnS7hdkdiH-qvRCj → ZoXPKe-6bpxSAS83EaRH6}/_buildManifest.js +0 -0
- /package/app/webapp/.next/standalone/app/webapp/.next/static/{Ovp2DYnS7hdkdiH-qvRCj → ZoXPKe-6bpxSAS83EaRH6}/_ssgManifest.js +0 -0
- /package/app/webapp/.next/static/{Ovp2DYnS7hdkdiH-qvRCj → ZoXPKe-6bpxSAS83EaRH6}/_buildManifest.js +0 -0
- /package/app/webapp/.next/static/{Ovp2DYnS7hdkdiH-qvRCj → ZoXPKe-6bpxSAS83EaRH6}/_ssgManifest.js +0 -0
|
@@ -1,17 +1,5 @@
|
|
|
1
|
-
"use strict";exports.id=
|
|
2
|
-
${r.message}`),t)throw new u.VercelOidcTokenError(t);throw r}return t}function c(){let e=l.getContext().headers?.["x-vercel-oidc-token"]??process.env.VERCEL_OIDC_TOKEN;if(!e)throw Error("The 'x-vercel-oidc-token' header is missing from the request. Do you have the OIDC option enabled in the Vercel project settings?");return e}},489:(e,t,r)=>{var a=Object.defineProperty,n=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,i=Object.prototype.hasOwnProperty,s={};((e,t)=>{for(var r in t)a(e,r,{get:t[r],enumerable:!0})})(s,{getContext:()=>u.getContext,getVercelOidcToken:()=>l.getVercelOidcToken,getVercelOidcTokenSync:()=>l.getVercelOidcTokenSync}),e.exports=((e,t,r,s)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let l of o(t))i.call(e,l)||l===r||a(e,l,{get:()=>t[l],enumerable:!(s=n(t,l))||s.enumerable});return e})(a({},"__esModule",{value:!0}),s);var l=r(1552),u=r(6939)},1403:e=>{var t=Object.defineProperty,r=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,n=Object.prototype.hasOwnProperty,o={};((e,r)=>{for(var a in r)t(e,a,{get:r[a],enumerable:!0})})(o,{VercelOidcTokenError:()=>i}),e.exports=((e,o,i,s)=>{if(o&&"object"==typeof o||"function"==typeof o)for(let l of a(o))n.call(e,l)||l===i||t(e,l,{get:()=>o[l],enumerable:!(s=r(o,l))||s.enumerable});return e})(t({},"__esModule",{value:!0}),o);class i extends Error{constructor(e,t){super(e),this.name="VercelOidcTokenError",this.cause=t}toString(){return this.cause?`${this.name}: ${this.message}: ${this.cause}`:`${this.name}: ${this.message}`}}},3036:(e,t,r)=>{e.exports=r(517)},4523:(e,t,r)=>{r.d(t,{D3:()=>ek});var a=r(9519),n=r(6365),o=r(2943),i=(0,n.DG)(()=>(0,n.r0)(o.Ry({type:o.i0("error"),error:o.Ry({type:o.Z_(),message:o.Z_()})}))),s=(0,n.Sq)({errorSchema:i,errorToMessage:e=>e.error.message}),l=(0,n.DG)(()=>(0,n.r0)(o.Ry({type:o.i0("message"),id:o.Z_().nullish(),model:o.Z_().nullish(),content:o.IX(o.VK("type",[o.Ry({type:o.i0("text"),text:o.Z_(),citations:o.IX(o.VK("type",[o.Ry({type:o.i0("web_search_result_location"),cited_text:o.Z_(),url:o.Z_(),title:o.Z_(),encrypted_index:o.Z_()}),o.Ry({type:o.i0("page_location"),cited_text:o.Z_(),document_index:o.Rx(),document_title:o.Z_().nullable(),start_page_number:o.Rx(),end_page_number:o.Rx()}),o.Ry({type:o.i0("char_location"),cited_text:o.Z_(),document_index:o.Rx(),document_title:o.Z_().nullable(),start_char_index:o.Rx(),end_char_index:o.Rx()})])).optional()}),o.Ry({type:o.i0("thinking"),thinking:o.Z_(),signature:o.Z_()}),o.Ry({type:o.i0("redacted_thinking"),data:o.Z_()}),o.Ry({type:o.i0("compaction"),content:o.Z_()}),o.Ry({type:o.i0("tool_use"),id:o.Z_(),name:o.Z_(),input:o._4(),caller:o.G0([o.Ry({type:o.i0("code_execution_20250825"),tool_id:o.Z_()}),o.Ry({type:o.i0("code_execution_20260120"),tool_id:o.Z_()}),o.Ry({type:o.i0("direct")})]).optional()}),o.Ry({type:o.i0("server_tool_use"),id:o.Z_(),name:o.Z_(),input:o.IM(o.Z_(),o._4()).nullish(),caller:o.G0([o.Ry({type:o.i0("code_execution_20260120"),tool_id:o.Z_()}),o.Ry({type:o.i0("direct")})]).optional()}),o.Ry({type:o.i0("mcp_tool_use"),id:o.Z_(),name:o.Z_(),input:o._4(),server_name:o.Z_()}),o.Ry({type:o.i0("mcp_tool_result"),tool_use_id:o.Z_(),is_error:o.O7(),content:o.IX(o.G0([o.Z_(),o.Ry({type:o.i0("text"),text:o.Z_()})]))}),o.Ry({type:o.i0("web_fetch_tool_result"),tool_use_id:o.Z_(),content:o.G0([o.Ry({type:o.i0("web_fetch_result"),url:o.Z_(),retrieved_at:o.Z_(),content:o.Ry({type:o.i0("document"),title:o.Z_().nullable(),citations:o.Ry({enabled:o.O7()}).optional(),source:o.G0([o.Ry({type:o.i0("base64"),media_type:o.i0("application/pdf"),data:o.Z_()}),o.Ry({type:o.i0("text"),media_type:o.i0("text/plain"),data:o.Z_()})])})}),o.Ry({type:o.i0("web_fetch_tool_result_error"),error_code:o.Z_()})])}),o.Ry({type:o.i0("web_search_tool_result"),tool_use_id:o.Z_(),content:o.G0([o.IX(o.Ry({type:o.i0("web_search_result"),url:o.Z_(),title:o.Z_(),encrypted_content:o.Z_(),page_age:o.Z_().nullish()})),o.Ry({type:o.i0("web_search_tool_result_error"),error_code:o.Z_()})])}),o.Ry({type:o.i0("code_execution_tool_result"),tool_use_id:o.Z_(),content:o.G0([o.Ry({type:o.i0("code_execution_result"),stdout:o.Z_(),stderr:o.Z_(),return_code:o.Rx(),content:o.IX(o.Ry({type:o.i0("code_execution_output"),file_id:o.Z_()})).optional().default([])}),o.Ry({type:o.i0("encrypted_code_execution_result"),encrypted_stdout:o.Z_(),stderr:o.Z_(),return_code:o.Rx(),content:o.IX(o.Ry({type:o.i0("code_execution_output"),file_id:o.Z_()})).optional().default([])}),o.Ry({type:o.i0("code_execution_tool_result_error"),error_code:o.Z_()})])}),o.Ry({type:o.i0("bash_code_execution_tool_result"),tool_use_id:o.Z_(),content:o.VK("type",[o.Ry({type:o.i0("bash_code_execution_result"),content:o.IX(o.Ry({type:o.i0("bash_code_execution_output"),file_id:o.Z_()})),stdout:o.Z_(),stderr:o.Z_(),return_code:o.Rx()}),o.Ry({type:o.i0("bash_code_execution_tool_result_error"),error_code:o.Z_()})])}),o.Ry({type:o.i0("text_editor_code_execution_tool_result"),tool_use_id:o.Z_(),content:o.VK("type",[o.Ry({type:o.i0("text_editor_code_execution_tool_result_error"),error_code:o.Z_()}),o.Ry({type:o.i0("text_editor_code_execution_view_result"),content:o.Z_(),file_type:o.Z_(),num_lines:o.Rx().nullable(),start_line:o.Rx().nullable(),total_lines:o.Rx().nullable()}),o.Ry({type:o.i0("text_editor_code_execution_create_result"),is_file_update:o.O7()}),o.Ry({type:o.i0("text_editor_code_execution_str_replace_result"),lines:o.IX(o.Z_()).nullable(),new_lines:o.Rx().nullable(),new_start:o.Rx().nullable(),old_lines:o.Rx().nullable(),old_start:o.Rx().nullable()})])}),o.Ry({type:o.i0("tool_search_tool_result"),tool_use_id:o.Z_(),content:o.G0([o.Ry({type:o.i0("tool_search_tool_search_result"),tool_references:o.IX(o.Ry({type:o.i0("tool_reference"),tool_name:o.Z_()}))}),o.Ry({type:o.i0("tool_search_tool_result_error"),error_code:o.Z_()})])})])),stop_reason:o.Z_().nullish(),stop_sequence:o.Z_().nullish(),usage:o.d7({input_tokens:o.Rx(),output_tokens:o.Rx(),cache_creation_input_tokens:o.Rx().nullish(),cache_read_input_tokens:o.Rx().nullish(),iterations:o.IX(o.Ry({type:o.G0([o.i0("compaction"),o.i0("message")]),input_tokens:o.Rx(),output_tokens:o.Rx()})).nullish()}),container:o.Ry({expires_at:o.Z_(),id:o.Z_(),skills:o.IX(o.Ry({type:o.G0([o.i0("anthropic"),o.i0("custom")]),skill_id:o.Z_(),version:o.Z_()})).nullish()}).nullish(),context_management:o.Ry({applied_edits:o.IX(o.G0([o.Ry({type:o.i0("clear_tool_uses_20250919"),cleared_tool_uses:o.Rx(),cleared_input_tokens:o.Rx()}),o.Ry({type:o.i0("clear_thinking_20251015"),cleared_thinking_turns:o.Rx(),cleared_input_tokens:o.Rx()}),o.Ry({type:o.i0("compact_20260112")})]))}).nullish()}))),u=(0,n.DG)(()=>(0,n.r0)(o.VK("type",[o.Ry({type:o.i0("message_start"),message:o.Ry({id:o.Z_().nullish(),model:o.Z_().nullish(),role:o.Z_().nullish(),usage:o.d7({input_tokens:o.Rx(),cache_creation_input_tokens:o.Rx().nullish(),cache_read_input_tokens:o.Rx().nullish()}),content:o.IX(o.VK("type",[o.Ry({type:o.i0("tool_use"),id:o.Z_(),name:o.Z_(),input:o._4(),caller:o.G0([o.Ry({type:o.i0("code_execution_20250825"),tool_id:o.Z_()}),o.Ry({type:o.i0("code_execution_20260120"),tool_id:o.Z_()}),o.Ry({type:o.i0("direct")})]).optional()})])).nullish(),stop_reason:o.Z_().nullish(),container:o.Ry({expires_at:o.Z_(),id:o.Z_()}).nullish()})}),o.Ry({type:o.i0("content_block_start"),index:o.Rx(),content_block:o.VK("type",[o.Ry({type:o.i0("text"),text:o.Z_()}),o.Ry({type:o.i0("thinking"),thinking:o.Z_()}),o.Ry({type:o.i0("tool_use"),id:o.Z_(),name:o.Z_(),input:o.IM(o.Z_(),o._4()).optional(),caller:o.G0([o.Ry({type:o.i0("code_execution_20250825"),tool_id:o.Z_()}),o.Ry({type:o.i0("code_execution_20260120"),tool_id:o.Z_()}),o.Ry({type:o.i0("direct")})]).optional()}),o.Ry({type:o.i0("redacted_thinking"),data:o.Z_()}),o.Ry({type:o.i0("compaction"),content:o.Z_().nullish()}),o.Ry({type:o.i0("server_tool_use"),id:o.Z_(),name:o.Z_(),input:o.IM(o.Z_(),o._4()).nullish(),caller:o.G0([o.Ry({type:o.i0("code_execution_20260120"),tool_id:o.Z_()}),o.Ry({type:o.i0("direct")})]).optional()}),o.Ry({type:o.i0("mcp_tool_use"),id:o.Z_(),name:o.Z_(),input:o._4(),server_name:o.Z_()}),o.Ry({type:o.i0("mcp_tool_result"),tool_use_id:o.Z_(),is_error:o.O7(),content:o.IX(o.G0([o.Z_(),o.Ry({type:o.i0("text"),text:o.Z_()})]))}),o.Ry({type:o.i0("web_fetch_tool_result"),tool_use_id:o.Z_(),content:o.G0([o.Ry({type:o.i0("web_fetch_result"),url:o.Z_(),retrieved_at:o.Z_(),content:o.Ry({type:o.i0("document"),title:o.Z_().nullable(),citations:o.Ry({enabled:o.O7()}).optional(),source:o.G0([o.Ry({type:o.i0("base64"),media_type:o.i0("application/pdf"),data:o.Z_()}),o.Ry({type:o.i0("text"),media_type:o.i0("text/plain"),data:o.Z_()})])})}),o.Ry({type:o.i0("web_fetch_tool_result_error"),error_code:o.Z_()})])}),o.Ry({type:o.i0("web_search_tool_result"),tool_use_id:o.Z_(),content:o.G0([o.IX(o.Ry({type:o.i0("web_search_result"),url:o.Z_(),title:o.Z_(),encrypted_content:o.Z_(),page_age:o.Z_().nullish()})),o.Ry({type:o.i0("web_search_tool_result_error"),error_code:o.Z_()})])}),o.Ry({type:o.i0("code_execution_tool_result"),tool_use_id:o.Z_(),content:o.G0([o.Ry({type:o.i0("code_execution_result"),stdout:o.Z_(),stderr:o.Z_(),return_code:o.Rx(),content:o.IX(o.Ry({type:o.i0("code_execution_output"),file_id:o.Z_()})).optional().default([])}),o.Ry({type:o.i0("encrypted_code_execution_result"),encrypted_stdout:o.Z_(),stderr:o.Z_(),return_code:o.Rx(),content:o.IX(o.Ry({type:o.i0("code_execution_output"),file_id:o.Z_()})).optional().default([])}),o.Ry({type:o.i0("code_execution_tool_result_error"),error_code:o.Z_()})])}),o.Ry({type:o.i0("bash_code_execution_tool_result"),tool_use_id:o.Z_(),content:o.VK("type",[o.Ry({type:o.i0("bash_code_execution_result"),content:o.IX(o.Ry({type:o.i0("bash_code_execution_output"),file_id:o.Z_()})),stdout:o.Z_(),stderr:o.Z_(),return_code:o.Rx()}),o.Ry({type:o.i0("bash_code_execution_tool_result_error"),error_code:o.Z_()})])}),o.Ry({type:o.i0("text_editor_code_execution_tool_result"),tool_use_id:o.Z_(),content:o.VK("type",[o.Ry({type:o.i0("text_editor_code_execution_tool_result_error"),error_code:o.Z_()}),o.Ry({type:o.i0("text_editor_code_execution_view_result"),content:o.Z_(),file_type:o.Z_(),num_lines:o.Rx().nullable(),start_line:o.Rx().nullable(),total_lines:o.Rx().nullable()}),o.Ry({type:o.i0("text_editor_code_execution_create_result"),is_file_update:o.O7()}),o.Ry({type:o.i0("text_editor_code_execution_str_replace_result"),lines:o.IX(o.Z_()).nullable(),new_lines:o.Rx().nullable(),new_start:o.Rx().nullable(),old_lines:o.Rx().nullable(),old_start:o.Rx().nullable()})])}),o.Ry({type:o.i0("tool_search_tool_result"),tool_use_id:o.Z_(),content:o.G0([o.Ry({type:o.i0("tool_search_tool_search_result"),tool_references:o.IX(o.Ry({type:o.i0("tool_reference"),tool_name:o.Z_()}))}),o.Ry({type:o.i0("tool_search_tool_result_error"),error_code:o.Z_()})])})])}),o.Ry({type:o.i0("content_block_delta"),index:o.Rx(),delta:o.VK("type",[o.Ry({type:o.i0("input_json_delta"),partial_json:o.Z_()}),o.Ry({type:o.i0("text_delta"),text:o.Z_()}),o.Ry({type:o.i0("thinking_delta"),thinking:o.Z_()}),o.Ry({type:o.i0("signature_delta"),signature:o.Z_()}),o.Ry({type:o.i0("compaction_delta"),content:o.Z_().nullish()}),o.Ry({type:o.i0("citations_delta"),citation:o.VK("type",[o.Ry({type:o.i0("web_search_result_location"),cited_text:o.Z_(),url:o.Z_(),title:o.Z_(),encrypted_index:o.Z_()}),o.Ry({type:o.i0("page_location"),cited_text:o.Z_(),document_index:o.Rx(),document_title:o.Z_().nullable(),start_page_number:o.Rx(),end_page_number:o.Rx()}),o.Ry({type:o.i0("char_location"),cited_text:o.Z_(),document_index:o.Rx(),document_title:o.Z_().nullable(),start_char_index:o.Rx(),end_char_index:o.Rx()})])})])}),o.Ry({type:o.i0("content_block_stop"),index:o.Rx()}),o.Ry({type:o.i0("error"),error:o.Ry({type:o.Z_(),message:o.Z_()})}),o.Ry({type:o.i0("message_delta"),delta:o.Ry({stop_reason:o.Z_().nullish(),stop_sequence:o.Z_().nullish(),container:o.Ry({expires_at:o.Z_(),id:o.Z_(),skills:o.IX(o.Ry({type:o.G0([o.i0("anthropic"),o.i0("custom")]),skill_id:o.Z_(),version:o.Z_()})).nullish()}).nullish()}),usage:o.d7({input_tokens:o.Rx().nullish(),output_tokens:o.Rx(),cache_creation_input_tokens:o.Rx().nullish(),cache_read_input_tokens:o.Rx().nullish(),iterations:o.IX(o.Ry({type:o.G0([o.i0("compaction"),o.i0("message")]),input_tokens:o.Rx(),output_tokens:o.Rx()})).nullish()}),context_management:o.Ry({applied_edits:o.IX(o.G0([o.Ry({type:o.i0("clear_tool_uses_20250919"),cleared_tool_uses:o.Rx(),cleared_input_tokens:o.Rx()}),o.Ry({type:o.i0("clear_thinking_20251015"),cleared_thinking_turns:o.Rx(),cleared_input_tokens:o.Rx()}),o.Ry({type:o.i0("compact_20260112")})]))}).nullish()}),o.Ry({type:o.i0("message_stop")}),o.Ry({type:o.i0("ping")})]))),d=(0,n.DG)(()=>(0,n.r0)(o.Ry({signature:o.Z_().optional(),redactedData:o.Z_().optional()}))),c=o.Ry({citations:o.Ry({enabled:o.O7()}).optional(),title:o.Z_().optional(),context:o.Z_().optional()}),p=o.Ry({sendReasoning:o.O7().optional(),structuredOutputMode:o.Km(["outputFormat","jsonTool","auto"]).optional(),thinking:o.VK("type",[o.Ry({type:o.i0("adaptive")}),o.Ry({type:o.i0("enabled"),budgetTokens:o.Rx().optional()}),o.Ry({type:o.i0("disabled")})]).optional(),disableParallelToolUse:o.O7().optional(),cacheControl:o.Ry({type:o.i0("ephemeral"),ttl:o.G0([o.i0("5m"),o.i0("1h")]).optional()}).optional(),mcpServers:o.IX(o.Ry({type:o.i0("url"),name:o.Z_(),url:o.Z_(),authorizationToken:o.Z_().nullish(),toolConfiguration:o.Ry({enabled:o.O7().nullish(),allowedTools:o.IX(o.Z_()).nullish()}).nullish()})).optional(),container:o.Ry({id:o.Z_().optional(),skills:o.IX(o.Ry({type:o.G0([o.i0("anthropic"),o.i0("custom")]),skillId:o.Z_(),version:o.Z_().optional()})).optional()}).optional(),toolStreaming:o.O7().optional(),effort:o.Km(["low","medium","high","max"]).optional(),speed:o.Km(["fast","standard"]).optional(),anthropicBeta:o.IX(o.Z_()).optional(),contextManagement:o.Ry({edits:o.IX(o.VK("type",[o.Ry({type:o.i0("clear_tool_uses_20250919"),trigger:o.VK("type",[o.Ry({type:o.i0("input_tokens"),value:o.Rx()}),o.Ry({type:o.i0("tool_uses"),value:o.Rx()})]).optional(),keep:o.Ry({type:o.i0("tool_uses"),value:o.Rx()}).optional(),clearAtLeast:o.Ry({type:o.i0("input_tokens"),value:o.Rx()}).optional(),clearToolInputs:o.O7().optional(),excludeTools:o.IX(o.Z_()).optional()}),o.Ry({type:o.i0("clear_thinking_20251015"),keep:o.G0([o.i0("all"),o.Ry({type:o.i0("thinking_turns"),value:o.Rx()})]).optional()}),o.Ry({type:o.i0("compact_20260112"),trigger:o.Ry({type:o.i0("input_tokens"),value:o.Rx()}).optional(),pauseAfterCompaction:o.O7().optional(),instructions:o.Z_().optional()})]))}).optional()}),h=class{constructor(){this.breakpointCount=0,this.warnings=[]}getCacheControl(e,t){let r=function(e){var t;let r=null==e?void 0:e.anthropic;return null!=(t=null==r?void 0:r.cacheControl)?t:null==r?void 0:r.cache_control}(e);if(r){if(!t.canCache){this.warnings.push({type:"unsupported",feature:"cache_control on non-cacheable context",details:`cache_control cannot be set on ${t.type}. It will be ignored.`});return}if(this.breakpointCount++,this.breakpointCount>4){this.warnings.push({type:"unsupported",feature:"cacheControl breakpoint limit",details:`Maximum 4 cache breakpoints exceeded (found ${this.breakpointCount}). This breakpoint will be ignored.`});return}return r}}getWarnings(){return this.warnings}},m=(0,n.DG)(()=>(0,n.r0)(o.Ry({maxCharacters:o.Rx().optional()}))),f=(0,n.DG)(()=>(0,n.r0)(o.Ry({command:o.Km(["view","create","str_replace","insert"]),path:o.Z_(),file_text:o.Z_().optional(),insert_line:o.Rx().int().optional(),new_str:o.Z_().optional(),insert_text:o.Z_().optional(),old_str:o.Z_().optional(),view_range:o.IX(o.Rx().int()).optional()}))),y=(0,n.W0)({id:"anthropic.text_editor_20250728",inputSchema:f}),_=(0,n.DG)(()=>(0,n.r0)(o.Ry({maxUses:o.Rx().optional(),allowedDomains:o.IX(o.Z_()).optional(),blockedDomains:o.IX(o.Z_()).optional(),userLocation:o.Ry({type:o.i0("approximate"),city:o.Z_().optional(),region:o.Z_().optional(),country:o.Z_().optional(),timezone:o.Z_().optional()}).optional()}))),g=(0,n.DG)(()=>(0,n.r0)(o.IX(o.Ry({url:o.Z_(),title:o.Z_().nullable(),pageAge:o.Z_().nullable(),encryptedContent:o.Z_(),type:o.i0("web_search_result")})))),v=(0,n.DG)(()=>(0,n.r0)(o.Ry({query:o.Z_()}))),b=(0,n.ql)({id:"anthropic.web_search_20260209",inputSchema:v,outputSchema:g,supportsDeferredResults:!0}),w=(0,n.DG)(()=>(0,n.r0)(o.Ry({maxUses:o.Rx().optional(),allowedDomains:o.IX(o.Z_()).optional(),blockedDomains:o.IX(o.Z_()).optional(),userLocation:o.Ry({type:o.i0("approximate"),city:o.Z_().optional(),region:o.Z_().optional(),country:o.Z_().optional(),timezone:o.Z_().optional()}).optional()}))),x=(0,n.DG)(()=>(0,n.r0)(o.IX(o.Ry({url:o.Z_(),title:o.Z_().nullable(),pageAge:o.Z_().nullable(),encryptedContent:o.Z_(),type:o.i0("web_search_result")})))),k=(0,n.DG)(()=>(0,n.r0)(o.Ry({query:o.Z_()}))),I=(0,n.ql)({id:"anthropic.web_search_20250305",inputSchema:k,outputSchema:x,supportsDeferredResults:!0}),T=(0,n.DG)(()=>(0,n.r0)(o.Ry({maxUses:o.Rx().optional(),allowedDomains:o.IX(o.Z_()).optional(),blockedDomains:o.IX(o.Z_()).optional(),citations:o.Ry({enabled:o.O7()}).optional(),maxContentTokens:o.Rx().optional()}))),R=(0,n.DG)(()=>(0,n.r0)(o.Ry({type:o.i0("web_fetch_result"),url:o.Z_(),content:o.Ry({type:o.i0("document"),title:o.Z_().nullable(),citations:o.Ry({enabled:o.O7()}).optional(),source:o.G0([o.Ry({type:o.i0("base64"),mediaType:o.i0("application/pdf"),data:o.Z_()}),o.Ry({type:o.i0("text"),mediaType:o.i0("text/plain"),data:o.Z_()})])}),retrievedAt:o.Z_().nullable()}))),S=(0,n.DG)(()=>(0,n.r0)(o.Ry({url:o.Z_()}))),Z=(0,n.ql)({id:"anthropic.web_fetch_20260209",inputSchema:S,outputSchema:R,supportsDeferredResults:!0}),C=(0,n.DG)(()=>(0,n.r0)(o.Ry({maxUses:o.Rx().optional(),allowedDomains:o.IX(o.Z_()).optional(),blockedDomains:o.IX(o.Z_()).optional(),citations:o.Ry({enabled:o.O7()}).optional(),maxContentTokens:o.Rx().optional()}))),E=(0,n.DG)(()=>(0,n.r0)(o.Ry({type:o.i0("web_fetch_result"),url:o.Z_(),content:o.Ry({type:o.i0("document"),title:o.Z_().nullable(),citations:o.Ry({enabled:o.O7()}).optional(),source:o.G0([o.Ry({type:o.i0("base64"),mediaType:o.i0("application/pdf"),data:o.Z_()}),o.Ry({type:o.i0("text"),mediaType:o.i0("text/plain"),data:o.Z_()})])}),retrievedAt:o.Z_().nullable()}))),O=(0,n.DG)(()=>(0,n.r0)(o.Ry({url:o.Z_()}))),A=(0,n.ql)({id:"anthropic.web_fetch_20250910",inputSchema:O,outputSchema:E,supportsDeferredResults:!0});async function N({tools:e,toolChoice:t,disableParallelToolUse:r,cacheControlValidator:o,supportsStructuredOutput:i}){var s;e=(null==e?void 0:e.length)?e:void 0;let l=[],u=new Set,d=o||new h;if(null==e)return{tools:void 0,toolChoice:void 0,toolWarnings:l,betas:u};let c=[];for(let t of e)switch(t.type){case"function":{let e=d.getCacheControl(t.providerOptions,{type:"tool definition",canCache:!0}),r=null==(s=t.providerOptions)?void 0:s.anthropic,a=null==r?void 0:r.eagerInputStreaming,n=null==r?void 0:r.deferLoading,o=null==r?void 0:r.allowedCallers;c.push({name:t.name,description:t.description,input_schema:t.inputSchema,cache_control:e,...a?{eager_input_streaming:!0}:{},...!0===i&&null!=t.strict?{strict:t.strict}:{},...null!=n?{defer_loading:n}:{},...null!=o?{allowed_callers:o}:{},...null!=t.inputExamples?{input_examples:t.inputExamples.map(e=>e.input)}:{}}),!0===i&&u.add("structured-outputs-2025-11-13"),(null!=t.inputExamples||null!=o)&&u.add("advanced-tool-use-2025-11-20");break}case"provider":switch(t.id){case"anthropic.code_execution_20250522":u.add("code-execution-2025-05-22"),c.push({type:"code_execution_20250522",name:"code_execution",cache_control:void 0});break;case"anthropic.code_execution_20250825":u.add("code-execution-2025-08-25"),c.push({type:"code_execution_20250825",name:"code_execution"});break;case"anthropic.code_execution_20260120":c.push({type:"code_execution_20260120",name:"code_execution"});break;case"anthropic.computer_20250124":u.add("computer-use-2025-01-24"),c.push({name:"computer",type:"computer_20250124",display_width_px:t.args.displayWidthPx,display_height_px:t.args.displayHeightPx,display_number:t.args.displayNumber,cache_control:void 0});break;case"anthropic.computer_20251124":u.add("computer-use-2025-11-24"),c.push({name:"computer",type:"computer_20251124",display_width_px:t.args.displayWidthPx,display_height_px:t.args.displayHeightPx,display_number:t.args.displayNumber,enable_zoom:t.args.enableZoom,cache_control:void 0});break;case"anthropic.computer_20241022":u.add("computer-use-2024-10-22"),c.push({name:"computer",type:"computer_20241022",display_width_px:t.args.displayWidthPx,display_height_px:t.args.displayHeightPx,display_number:t.args.displayNumber,cache_control:void 0});break;case"anthropic.text_editor_20250124":u.add("computer-use-2025-01-24"),c.push({name:"str_replace_editor",type:"text_editor_20250124",cache_control:void 0});break;case"anthropic.text_editor_20241022":u.add("computer-use-2024-10-22"),c.push({name:"str_replace_editor",type:"text_editor_20241022",cache_control:void 0});break;case"anthropic.text_editor_20250429":u.add("computer-use-2025-01-24"),c.push({name:"str_replace_based_edit_tool",type:"text_editor_20250429",cache_control:void 0});break;case"anthropic.text_editor_20250728":{let e=await (0,n.rJ)({value:t.args,schema:m});c.push({name:"str_replace_based_edit_tool",type:"text_editor_20250728",max_characters:e.maxCharacters,cache_control:void 0});break}case"anthropic.bash_20250124":u.add("computer-use-2025-01-24"),c.push({name:"bash",type:"bash_20250124",cache_control:void 0});break;case"anthropic.bash_20241022":u.add("computer-use-2024-10-22"),c.push({name:"bash",type:"bash_20241022",cache_control:void 0});break;case"anthropic.memory_20250818":u.add("context-management-2025-06-27"),c.push({name:"memory",type:"memory_20250818"});break;case"anthropic.web_fetch_20250910":{u.add("web-fetch-2025-09-10");let e=await (0,n.rJ)({value:t.args,schema:C});c.push({type:"web_fetch_20250910",name:"web_fetch",max_uses:e.maxUses,allowed_domains:e.allowedDomains,blocked_domains:e.blockedDomains,citations:e.citations,max_content_tokens:e.maxContentTokens,cache_control:void 0});break}case"anthropic.web_fetch_20260209":{u.add("code-execution-web-tools-2026-02-09");let e=await (0,n.rJ)({value:t.args,schema:T});c.push({type:"web_fetch_20260209",name:"web_fetch",max_uses:e.maxUses,allowed_domains:e.allowedDomains,blocked_domains:e.blockedDomains,citations:e.citations,max_content_tokens:e.maxContentTokens,cache_control:void 0});break}case"anthropic.web_search_20250305":{let e=await (0,n.rJ)({value:t.args,schema:w});c.push({type:"web_search_20250305",name:"web_search",max_uses:e.maxUses,allowed_domains:e.allowedDomains,blocked_domains:e.blockedDomains,user_location:e.userLocation,cache_control:void 0});break}case"anthropic.web_search_20260209":{u.add("code-execution-web-tools-2026-02-09");let e=await (0,n.rJ)({value:t.args,schema:_});c.push({type:"web_search_20260209",name:"web_search",max_uses:e.maxUses,allowed_domains:e.allowedDomains,blocked_domains:e.blockedDomains,user_location:e.userLocation,cache_control:void 0});break}case"anthropic.tool_search_regex_20251119":u.add("advanced-tool-use-2025-11-20"),c.push({type:"tool_search_tool_regex_20251119",name:"tool_search_tool_regex"});break;case"anthropic.tool_search_bm25_20251119":u.add("advanced-tool-use-2025-11-20"),c.push({type:"tool_search_tool_bm25_20251119",name:"tool_search_tool_bm25"});break;default:l.push({type:"unsupported",feature:`provider-defined tool ${t.id}`})}break;default:l.push({type:"unsupported",feature:`tool ${t}`})}if(null==t)return{tools:c,toolChoice:r?{type:"auto",disable_parallel_tool_use:r}:void 0,toolWarnings:l,betas:u};let p=t.type;switch(p){case"auto":return{tools:c,toolChoice:{type:"auto",disable_parallel_tool_use:r},toolWarnings:l,betas:u};case"required":return{tools:c,toolChoice:{type:"any",disable_parallel_tool_use:r},toolWarnings:l,betas:u};case"none":return{tools:void 0,toolChoice:void 0,toolWarnings:l,betas:u};case"tool":return{tools:c,toolChoice:{type:"tool",name:t.toolName,disable_parallel_tool_use:r},toolWarnings:l,betas:u};default:throw new a.A_({functionality:`tool choice type: ${p}`})}}function M({usage:e,rawUsage:t}){var r,a;let n,o;let i=null!=(r=e.cache_creation_input_tokens)?r:0,s=null!=(a=e.cache_read_input_tokens)?a:0;if(e.iterations&&e.iterations.length>0){let t=e.iterations.reduce((e,t)=>({input:e.input+t.input_tokens,output:e.output+t.output_tokens}),{input:0,output:0});n=t.input,o=t.output}else n=e.input_tokens,o=e.output_tokens;return{inputTokens:{total:n+i+s,noCache:n,cacheRead:s,cacheWrite:i},outputTokens:{total:o,text:void 0,reasoning:void 0},raw:null!=t?t:e}}var $=(0,n.DG)(()=>(0,n.r0)(o.Ry({type:o.i0("code_execution_result"),stdout:o.Z_(),stderr:o.Z_(),return_code:o.Rx(),content:o.IX(o.Ry({type:o.i0("code_execution_output"),file_id:o.Z_()})).optional().default([])}))),P=(0,n.DG)(()=>(0,n.r0)(o.Ry({code:o.Z_()}))),j=(0,n.ql)({id:"anthropic.code_execution_20250522",inputSchema:P,outputSchema:$}),F=(0,n.DG)(()=>(0,n.r0)(o.VK("type",[o.Ry({type:o.i0("code_execution_result"),stdout:o.Z_(),stderr:o.Z_(),return_code:o.Rx(),content:o.IX(o.Ry({type:o.i0("code_execution_output"),file_id:o.Z_()})).optional().default([])}),o.Ry({type:o.i0("bash_code_execution_result"),content:o.IX(o.Ry({type:o.i0("bash_code_execution_output"),file_id:o.Z_()})),stdout:o.Z_(),stderr:o.Z_(),return_code:o.Rx()}),o.Ry({type:o.i0("bash_code_execution_tool_result_error"),error_code:o.Z_()}),o.Ry({type:o.i0("text_editor_code_execution_tool_result_error"),error_code:o.Z_()}),o.Ry({type:o.i0("text_editor_code_execution_view_result"),content:o.Z_(),file_type:o.Z_(),num_lines:o.Rx().nullable(),start_line:o.Rx().nullable(),total_lines:o.Rx().nullable()}),o.Ry({type:o.i0("text_editor_code_execution_create_result"),is_file_update:o.O7()}),o.Ry({type:o.i0("text_editor_code_execution_str_replace_result"),lines:o.IX(o.Z_()).nullable(),new_lines:o.Rx().nullable(),new_start:o.Rx().nullable(),old_lines:o.Rx().nullable(),old_start:o.Rx().nullable()})]))),z=(0,n.DG)(()=>(0,n.r0)(o.VK("type",[o.Ry({type:o.i0("programmatic-tool-call"),code:o.Z_()}),o.Ry({type:o.i0("bash_code_execution"),command:o.Z_()}),o.VK("command",[o.Ry({type:o.i0("text_editor_code_execution"),command:o.i0("view"),path:o.Z_()}),o.Ry({type:o.i0("text_editor_code_execution"),command:o.i0("create"),path:o.Z_(),file_text:o.Z_().nullish()}),o.Ry({type:o.i0("text_editor_code_execution"),command:o.i0("str_replace"),path:o.Z_(),old_str:o.Z_(),new_str:o.Z_()})])]))),D=(0,n.ql)({id:"anthropic.code_execution_20250825",inputSchema:z,outputSchema:F,supportsDeferredResults:!0}),q=(0,n.DG)(()=>(0,n.r0)(o.VK("type",[o.Ry({type:o.i0("code_execution_result"),stdout:o.Z_(),stderr:o.Z_(),return_code:o.Rx(),content:o.IX(o.Ry({type:o.i0("code_execution_output"),file_id:o.Z_()})).optional().default([])}),o.Ry({type:o.i0("encrypted_code_execution_result"),encrypted_stdout:o.Z_(),stderr:o.Z_(),return_code:o.Rx(),content:o.IX(o.Ry({type:o.i0("code_execution_output"),file_id:o.Z_()})).optional().default([])}),o.Ry({type:o.i0("bash_code_execution_result"),content:o.IX(o.Ry({type:o.i0("bash_code_execution_output"),file_id:o.Z_()})),stdout:o.Z_(),stderr:o.Z_(),return_code:o.Rx()}),o.Ry({type:o.i0("bash_code_execution_tool_result_error"),error_code:o.Z_()}),o.Ry({type:o.i0("text_editor_code_execution_tool_result_error"),error_code:o.Z_()}),o.Ry({type:o.i0("text_editor_code_execution_view_result"),content:o.Z_(),file_type:o.Z_(),num_lines:o.Rx().nullable(),start_line:o.Rx().nullable(),total_lines:o.Rx().nullable()}),o.Ry({type:o.i0("text_editor_code_execution_create_result"),is_file_update:o.O7()}),o.Ry({type:o.i0("text_editor_code_execution_str_replace_result"),lines:o.IX(o.Z_()).nullable(),new_lines:o.Rx().nullable(),new_start:o.Rx().nullable(),old_lines:o.Rx().nullable(),old_start:o.Rx().nullable()})]))),U=(0,n.DG)(()=>(0,n.r0)(o.VK("type",[o.Ry({type:o.i0("programmatic-tool-call"),code:o.Z_()}),o.Ry({type:o.i0("bash_code_execution"),command:o.Z_()}),o.VK("command",[o.Ry({type:o.i0("text_editor_code_execution"),command:o.i0("view"),path:o.Z_()}),o.Ry({type:o.i0("text_editor_code_execution"),command:o.i0("create"),path:o.Z_(),file_text:o.Z_().nullish()}),o.Ry({type:o.i0("text_editor_code_execution"),command:o.i0("str_replace"),path:o.Z_(),old_str:o.Z_(),new_str:o.Z_()})])]))),L=(0,n.ql)({id:"anthropic.code_execution_20260120",inputSchema:U,outputSchema:q,supportsDeferredResults:!0}),V=(0,n.DG)(()=>(0,n.r0)(o.IX(o.Ry({type:o.i0("tool_reference"),toolName:o.Z_()})))),G=(0,n.DG)(()=>(0,n.r0)(o.Ry({pattern:o.Z_(),limit:o.Rx().optional()}))),W=(0,n.ql)({id:"anthropic.tool_search_regex_20251119",inputSchema:G,outputSchema:V,supportsDeferredResults:!0});function X(e){return e instanceof URL||"string"==typeof e&&/^https?:\/\//i.test(e)}function B(e){return e instanceof URL?e.toString():e}async function K({prompt:e,sendReasoning:t,warnings:r,cacheControlValidator:o,toolNameMapping:i}){var s,l,u,p,m,f,y,_,g,v,b,w,k,I,T,R,S,Z,C;let O;let A=new Set,N=function(e){let t;let r=[];for(let a of e){let{role:e}=a;switch(e){case"system":(null==t?void 0:t.type)!=="system"&&(t={type:"system",messages:[]},r.push(t)),t.messages.push(a);break;case"assistant":(null==t?void 0:t.type)!=="assistant"&&(t={type:"assistant",messages:[]},r.push(t)),t.messages.push(a);break;case"user":case"tool":(null==t?void 0:t.type)!=="user"&&(t={type:"user",messages:[]},r.push(t)),t.messages.push(a);break;default:throw Error(`Unsupported role: ${e}`)}}return r}(e),M=o||new h,P=[];async function j(e){var t,r;let a=await (0,n.c1)({provider:"anthropic",providerOptions:e,schema:c});return null!=(r=null==(t=null==a?void 0:a.citations)?void 0:t.enabled)&&r}async function z(e){let t=await (0,n.c1)({provider:"anthropic",providerOptions:e,schema:c});return{title:null==t?void 0:t.title,context:null==t?void 0:t.context}}for(let e=0;e<N.length;e++){let o=N[e],c=e===N.length-1,h=o.type;switch(h){case"system":if(null!=O)throw new a.A_({functionality:"Multiple system messages that are separated by user/assistant messages"});O=o.messages.map(({content:e,providerOptions:t})=>({type:"text",text:e,cache_control:M.getCacheControl(t,{type:"system message",canCache:!0})}));break;case"user":{let e=[];for(let t of o.messages){let{role:o,content:i}=t;switch(o){case"user":for(let r=0;r<i.length;r++){let o=i[r],d=r===i.length-1,c=null!=(s=M.getCacheControl(o.providerOptions,{type:"user message part",canCache:!0}))?s:d?M.getCacheControl(t.providerOptions,{type:"user message",canCache:!0}):void 0;switch(o.type){case"text":e.push({type:"text",text:o.text,cache_control:c});break;case"file":if(o.mediaType.startsWith("image/"))e.push({type:"image",source:X(o.data)?{type:"url",url:B(o.data)}:{type:"base64",media_type:"image/*"===o.mediaType?"image/jpeg":o.mediaType,data:(0,n.QF)(o.data)},cache_control:c});else if("application/pdf"===o.mediaType){A.add("pdfs-2024-09-25");let t=await j(o.providerOptions),r=await z(o.providerOptions);e.push({type:"document",source:X(o.data)?{type:"url",url:B(o.data)}:{type:"base64",media_type:"application/pdf",data:(0,n.QF)(o.data)},title:null!=(l=r.title)?l:o.filename,...r.context&&{context:r.context},...t&&{citations:{enabled:!0}},cache_control:c})}else if("text/plain"===o.mediaType){let t=await j(o.providerOptions),r=await z(o.providerOptions);e.push({type:"document",source:X(o.data)?{type:"url",url:B(o.data)}:{type:"text",media_type:"text/plain",data:function(e){if("string"==typeof e)return new TextDecoder().decode((0,n.MS)(e));if(e instanceof Uint8Array)return new TextDecoder().decode(e);if(e instanceof URL)throw new a.A_({functionality:"URL-based text documents are not supported for citations"});throw new a.A_({functionality:`unsupported data type for text documents: ${typeof e}`})}(o.data)},title:null!=(u=r.title)?u:o.filename,...r.context&&{context:r.context},...t&&{citations:{enabled:!0}},cache_control:c})}else throw new a.A_({functionality:`media type: ${o.mediaType}`})}}break;case"tool":for(let a=0;a<i.length;a++){let o;let s=i[a];if("tool-approval-response"===s.type)continue;let l=a===i.length-1,u=null!=(p=M.getCacheControl(s.providerOptions,{type:"tool result part",canCache:!0}))?p:l?M.getCacheControl(t.providerOptions,{type:"tool result message",canCache:!0}):void 0,d=s.output;switch(d.type){case"content":o=d.value.map(e=>{var t;switch(e.type){case"text":return{type:"text",text:e.text};case"image-data":return{type:"image",source:{type:"base64",media_type:e.mediaType,data:e.data}};case"image-url":return{type:"image",source:{type:"url",url:e.url}};case"file-url":return{type:"document",source:{type:"url",url:e.url}};case"file-data":if("application/pdf"===e.mediaType)return A.add("pdfs-2024-09-25"),{type:"document",source:{type:"base64",media_type:e.mediaType,data:e.data}};r.push({type:"other",message:`unsupported tool content part type: ${e.type} with media type: ${e.mediaType}`});return;case"custom":{let a=null==(t=e.providerOptions)?void 0:t.anthropic;if((null==a?void 0:a.type)==="tool-reference")return{type:"tool_reference",tool_name:a.toolName};r.push({type:"other",message:"unsupported custom tool content part"});return}default:r.push({type:"other",message:`unsupported tool content part type: ${e.type}`});return}}).filter(n.C_);break;case"text":case"error-text":o=d.value;break;case"execution-denied":o=null!=(m=d.reason)?m:"Tool execution denied.";break;default:o=JSON.stringify(d.value)}e.push({type:"tool_result",tool_use_id:s.toolCallId,content:o,is_error:"error-text"===d.type||"error-json"===d.type||void 0,cache_control:u})}break;default:throw Error(`Unsupported role: ${o}`)}}P.push({role:"user",content:e});break}case"assistant":{let e=[],a=new Set;for(let s=0;s<o.messages.length;s++){let l=o.messages[s],u=s===o.messages.length-1,{content:p}=l;for(let o=0;o<p.length;o++){let s=p[o],h=o===p.length-1,m=null!=(f=M.getCacheControl(s.providerOptions,{type:"assistant message part",canCache:!0}))?f:h?M.getCacheControl(l.providerOptions,{type:"assistant message",canCache:!0}):void 0;switch(s.type){case"text":{let t=null==(y=s.providerOptions)?void 0:y.anthropic;(null==t?void 0:t.type)==="compaction"?e.push({type:"compaction",content:s.text,cache_control:m}):e.push({type:"text",text:c&&u&&h?s.text.trim():s.text,cache_control:m});break}case"reasoning":if(t){let t=await (0,n.c1)({provider:"anthropic",providerOptions:s.providerOptions,schema:d});null!=t?null!=t.signature?(M.getCacheControl(s.providerOptions,{type:"thinking block",canCache:!1}),e.push({type:"thinking",thinking:s.text,signature:t.signature})):null!=t.redactedData?(M.getCacheControl(s.providerOptions,{type:"redacted thinking block",canCache:!1}),e.push({type:"redacted_thinking",data:t.redactedData})):r.push({type:"other",message:"unsupported reasoning metadata"}):r.push({type:"other",message:"unsupported reasoning metadata"})}else r.push({type:"other",message:"sending reasoning content is disabled for this model"});break;case"tool-call":{if(s.providerExecuted){let t=i.toProviderToolName(s.toolName);if((null==(g=null==(_=s.providerOptions)?void 0:_.anthropic)?void 0:g.type)==="mcp-tool-use"){a.add(s.toolCallId);let t=null==(b=null==(v=s.providerOptions)?void 0:v.anthropic)?void 0:b.serverName;if(null==t||"string"!=typeof t){r.push({type:"other",message:"mcp tool use server name is required and must be a string"});break}e.push({type:"mcp_tool_use",id:s.toolCallId,name:s.toolName,input:s.input,server_name:t,cache_control:m})}else if("code_execution"===t&&null!=s.input&&"object"==typeof s.input&&"type"in s.input&&"string"==typeof s.input.type&&("bash_code_execution"===s.input.type||"text_editor_code_execution"===s.input.type))e.push({type:"server_tool_use",id:s.toolCallId,name:s.input.type,input:s.input,cache_control:m});else if("code_execution"===t&&null!=s.input&&"object"==typeof s.input&&"type"in s.input&&"programmatic-tool-call"===s.input.type){let{type:t,...r}=s.input;e.push({type:"server_tool_use",id:s.toolCallId,name:"code_execution",input:r,cache_control:m})}else"code_execution"===t||"web_fetch"===t||"web_search"===t?e.push({type:"server_tool_use",id:s.toolCallId,name:t,input:s.input,cache_control:m}):"tool_search_tool_regex"===t||"tool_search_tool_bm25"===t?e.push({type:"server_tool_use",id:s.toolCallId,name:t,input:s.input,cache_control:m}):r.push({type:"other",message:`provider executed tool call for tool ${s.toolName} is not supported`});break}let t=null==(w=s.providerOptions)?void 0:w.anthropic,n=(null==t?void 0:t.caller)?("code_execution_20250825"===t.caller.type||"code_execution_20260120"===t.caller.type)&&t.caller.toolId?{type:t.caller.type,tool_id:t.caller.toolId}:"direct"===t.caller.type?{type:"direct"}:void 0:void 0;e.push({type:"tool_use",id:s.toolCallId,name:s.toolName,input:s.input,...n&&{caller:n},cache_control:m});break}case"tool-result":{let t=i.toProviderToolName(s.toolName);if(a.has(s.toolCallId)){let t=s.output;if("json"!==t.type&&"error-json"!==t.type){r.push({type:"other",message:`provider executed tool result output type ${t.type} for tool ${s.toolName} is not supported`});break}e.push({type:"mcp_tool_result",tool_use_id:s.toolCallId,is_error:"error-json"===t.type,content:t.value,cache_control:m})}else if("code_execution"===t){let t=s.output;if("error-text"===t.type||"error-json"===t.type){let r={};try{"string"==typeof t.value?r=JSON.parse(t.value):"object"==typeof t.value&&null!==t.value&&(r=t.value)}catch(e){}"code_execution_tool_result_error"===r.type?e.push({type:"code_execution_tool_result",tool_use_id:s.toolCallId,content:{type:"code_execution_tool_result_error",error_code:null!=(k=r.errorCode)?k:"unknown"},cache_control:m}):e.push({type:"bash_code_execution_tool_result",tool_use_id:s.toolCallId,cache_control:m,content:{type:"bash_code_execution_tool_result_error",error_code:null!=(I=r.errorCode)?I:"unknown"}});break}if("json"!==t.type){r.push({type:"other",message:`provider executed tool result output type ${t.type} for tool ${s.toolName} is not supported`});break}if(null==t.value||"object"!=typeof t.value||!("type"in t.value)||"string"!=typeof t.value.type){r.push({type:"other",message:`provider executed tool result output value is not a valid code execution result for tool ${s.toolName}`});break}if("code_execution_result"===t.value.type){let r=await (0,n.rJ)({value:t.value,schema:$});e.push({type:"code_execution_tool_result",tool_use_id:s.toolCallId,content:{type:r.type,stdout:r.stdout,stderr:r.stderr,return_code:r.return_code,content:null!=(T=r.content)?T:[]},cache_control:m})}else if("encrypted_code_execution_result"===t.value.type){let r=await (0,n.rJ)({value:t.value,schema:q});"encrypted_code_execution_result"===r.type&&e.push({type:"code_execution_tool_result",tool_use_id:s.toolCallId,content:{type:r.type,encrypted_stdout:r.encrypted_stdout,stderr:r.stderr,return_code:r.return_code,content:null!=(R=r.content)?R:[]},cache_control:m})}else{let r=await (0,n.rJ)({value:t.value,schema:F});"code_execution_result"===r.type?e.push({type:"code_execution_tool_result",tool_use_id:s.toolCallId,content:{type:r.type,stdout:r.stdout,stderr:r.stderr,return_code:r.return_code,content:null!=(S=r.content)?S:[]},cache_control:m}):"bash_code_execution_result"===r.type||"bash_code_execution_tool_result_error"===r.type?e.push({type:"bash_code_execution_tool_result",tool_use_id:s.toolCallId,cache_control:m,content:r}):e.push({type:"text_editor_code_execution_tool_result",tool_use_id:s.toolCallId,cache_control:m,content:r})}break}if("web_fetch"===t){let t=s.output;if("error-json"===t.type){let r={};try{"string"==typeof t.value?r=JSON.parse(t.value):"object"==typeof t.value&&null!==t.value&&(r=t.value)}catch(a){let e=null==(Z=t.value)?void 0:Z.errorCode;r={errorCode:"string"==typeof e?e:"unknown"}}e.push({type:"web_fetch_tool_result",tool_use_id:s.toolCallId,content:{type:"web_fetch_tool_result_error",error_code:null!=(C=r.errorCode)?C:"unknown"},cache_control:m});break}if("json"!==t.type){r.push({type:"other",message:`provider executed tool result output type ${t.type} for tool ${s.toolName} is not supported`});break}let a=await (0,n.rJ)({value:t.value,schema:E});e.push({type:"web_fetch_tool_result",tool_use_id:s.toolCallId,content:{type:"web_fetch_result",url:a.url,retrieved_at:a.retrievedAt,content:{type:"document",title:a.content.title,citations:a.content.citations,source:{type:a.content.source.type,media_type:a.content.source.mediaType,data:a.content.source.data}}},cache_control:m});break}if("web_search"===t){let t=s.output;if("json"!==t.type){r.push({type:"other",message:`provider executed tool result output type ${t.type} for tool ${s.toolName} is not supported`});break}let a=await (0,n.rJ)({value:t.value,schema:x});e.push({type:"web_search_tool_result",tool_use_id:s.toolCallId,content:a.map(e=>({url:e.url,title:e.title,page_age:e.pageAge,encrypted_content:e.encryptedContent,type:e.type})),cache_control:m});break}if("tool_search_tool_regex"===t||"tool_search_tool_bm25"===t){let t=s.output;if("json"!==t.type){r.push({type:"other",message:`provider executed tool result output type ${t.type} for tool ${s.toolName} is not supported`});break}let a=(await (0,n.rJ)({value:t.value,schema:V})).map(e=>({type:"tool_reference",tool_name:e.toolName}));e.push({type:"tool_search_tool_result",tool_use_id:s.toolCallId,content:{type:"tool_search_tool_search_result",tool_references:a},cache_control:m});break}r.push({type:"other",message:`provider executed tool result for tool ${s.toolName} is not supported`})}}}}P.push({role:"assistant",content:e});break}default:throw Error(`content type: ${h}`)}}return{prompt:{system:O,messages:P},betas:A}}function J({finishReason:e,isJsonResponseFromTool:t}){switch(e){case"pause_turn":case"end_turn":case"stop_sequence":return"stop";case"refusal":return"content-filter";case"tool_use":return t?"stop":"tool-calls";case"max_tokens":case"model_context_window_exceeded":return"length";default:return"other"}}function H(e,t,r){var a;if("web_search_result_location"===e.type)return{type:"source",sourceType:"url",id:r(),url:e.url,title:e.title,providerMetadata:{anthropic:{citedText:e.cited_text,encryptedIndex:e.encrypted_index}}};if("page_location"!==e.type&&"char_location"!==e.type)return;let n=t[e.document_index];if(n)return{type:"source",sourceType:"document",id:r(),mediaType:n.mediaType,title:null!=(a=e.document_title)?a:n.title,filename:n.filename,providerMetadata:{anthropic:"page_location"===e.type?{citedText:e.cited_text,startPageNumber:e.start_page_number,endPageNumber:e.end_page_number}:{citedText:e.cited_text,startCharIndex:e.start_char_index,endCharIndex:e.end_char_index}}}}var Y=class{constructor(e,t){var r;this.specificationVersion="v3",this.modelId=e,this.config=t,this.generateId=null!=(r=t.generateId)?r:n.Ox}supportsUrl(e){return"https:"===e.protocol}get provider(){return this.config.provider}get providerOptionsName(){let e=this.config.provider,t=e.indexOf(".");return -1===t?e:e.substring(0,t)}get supportedUrls(){var e,t,r;return null!=(r=null==(t=(e=this.config).supportedUrls)?void 0:t.call(e))?r:{}}async getArgs({userSuppliedBetas:e,prompt:t,maxOutputTokens:r,temperature:a,topP:o,topK:i,frequencyPenalty:s,presencePenalty:l,stopSequences:u,responseFormat:d,seed:c,tools:m,toolChoice:f,providerOptions:y,stream:_}){var g,v,b,w,x,k,I,T;let R=[];null!=s&&R.push({type:"unsupported",feature:"frequencyPenalty"}),null!=l&&R.push({type:"unsupported",feature:"presencePenalty"}),null!=c&&R.push({type:"unsupported",feature:"seed"}),null!=a&&a>1?(R.push({type:"unsupported",feature:"temperature",details:`${a} exceeds anthropic maximum of 1.0. clamped to 1.0`}),a=1):null!=a&&a<0&&(R.push({type:"unsupported",feature:"temperature",details:`${a} is below anthropic minimum of 0. clamped to 0`}),a=0),(null==d?void 0:d.type)==="json"&&null==d.schema&&R.push({type:"unsupported",feature:"responseFormat",details:"JSON response format requires a schema. The response format is ignored."});let S=this.providerOptionsName,Z=await (0,n.c1)({provider:"anthropic",providerOptions:y,schema:p}),C="anthropic"!==S?await (0,n.c1)({provider:S,providerOptions:y,schema:p}):null,E=null!=C,O=Object.assign({},null!=Z?Z:{},null!=C?C:{}),{maxOutputTokens:A,supportsStructuredOutput:M,isKnownModel:$}=(T=this.modelId).includes("claude-sonnet-4-6")||T.includes("claude-opus-4-6")?{maxOutputTokens:128e3,supportsStructuredOutput:!0,isKnownModel:!0}:T.includes("claude-sonnet-4-5")||T.includes("claude-opus-4-5")||T.includes("claude-haiku-4-5")?{maxOutputTokens:64e3,supportsStructuredOutput:!0,isKnownModel:!0}:T.includes("claude-opus-4-1")?{maxOutputTokens:32e3,supportsStructuredOutput:!0,isKnownModel:!0}:T.includes("claude-sonnet-4-")?{maxOutputTokens:64e3,supportsStructuredOutput:!1,isKnownModel:!0}:T.includes("claude-opus-4-")?{maxOutputTokens:32e3,supportsStructuredOutput:!1,isKnownModel:!0}:T.includes("claude-3-haiku")?{maxOutputTokens:4096,supportsStructuredOutput:!1,isKnownModel:!0}:{maxOutputTokens:4096,supportsStructuredOutput:!1,isKnownModel:!1},P=(null==(g=this.config.supportsNativeStructuredOutput)||g)&&M,j=null!=(v=null==O?void 0:O.structuredOutputMode)?v:"auto",F="outputFormat"===j||"auto"===j&&P,z=(null==d?void 0:d.type)!=="json"||null==d.schema||F?void 0:{type:"function",name:"json",description:"Respond with a JSON object.",inputSchema:d.schema},D=null==O?void 0:O.contextManagement,q=new h,U=(0,n.U_)({tools:m,providerToolNames:{"anthropic.code_execution_20250522":"code_execution","anthropic.code_execution_20250825":"code_execution","anthropic.code_execution_20260120":"code_execution","anthropic.computer_20241022":"computer","anthropic.computer_20250124":"computer","anthropic.text_editor_20241022":"str_replace_editor","anthropic.text_editor_20250124":"str_replace_editor","anthropic.text_editor_20250429":"str_replace_based_edit_tool","anthropic.text_editor_20250728":"str_replace_based_edit_tool","anthropic.bash_20241022":"bash","anthropic.bash_20250124":"bash","anthropic.memory_20250818":"memory","anthropic.web_search_20250305":"web_search","anthropic.web_search_20260209":"web_search","anthropic.web_fetch_20250910":"web_fetch","anthropic.web_fetch_20260209":"web_fetch","anthropic.tool_search_regex_20251119":"tool_search_tool_regex","anthropic.tool_search_bm25_20251119":"tool_search_tool_bm25"}}),{prompt:L,betas:V}=await K({prompt:t,sendReasoning:null==(b=null==O?void 0:O.sendReasoning)||b,warnings:R,cacheControlValidator:q,toolNameMapping:U}),G=null==(w=null==O?void 0:O.thinking)?void 0:w.type,W="enabled"===G||"adaptive"===G,X="enabled"===G?null==(x=null==O?void 0:O.thinking)?void 0:x.budgetTokens:void 0,B=null!=r?r:A,J={model:this.modelId,max_tokens:B,temperature:a,top_k:i,top_p:o,stop_sequences:u,...W&&{thinking:{type:G,...null!=X&&{budget_tokens:X}}},...((null==O?void 0:O.effort)||F&&(null==d?void 0:d.type)==="json"&&null!=d.schema)&&{output_config:{...(null==O?void 0:O.effort)&&{effort:O.effort},...F&&(null==d?void 0:d.type)==="json"&&null!=d.schema&&{format:{type:"json_schema",schema:d.schema}}}},...(null==O?void 0:O.speed)&&{speed:O.speed},...(null==O?void 0:O.cacheControl)&&{cache_control:O.cacheControl},...(null==O?void 0:O.mcpServers)&&O.mcpServers.length>0&&{mcp_servers:O.mcpServers.map(e=>({type:e.type,name:e.name,url:e.url,authorization_token:e.authorizationToken,tool_configuration:e.toolConfiguration?{allowed_tools:e.toolConfiguration.allowedTools,enabled:e.toolConfiguration.enabled}:void 0}))},...(null==O?void 0:O.container)&&{container:O.container.skills&&O.container.skills.length>0?{id:O.container.id,skills:O.container.skills.map(e=>({type:e.type,skill_id:e.skillId,version:e.version}))}:O.container.id},system:L.system,messages:L.messages,...D&&{context_management:{edits:D.edits.map(e=>{let t=e.type;switch(t){case"clear_tool_uses_20250919":return{type:e.type,...void 0!==e.trigger&&{trigger:e.trigger},...void 0!==e.keep&&{keep:e.keep},...void 0!==e.clearAtLeast&&{clear_at_least:e.clearAtLeast},...void 0!==e.clearToolInputs&&{clear_tool_inputs:e.clearToolInputs},...void 0!==e.excludeTools&&{exclude_tools:e.excludeTools}};case"clear_thinking_20251015":return{type:e.type,...void 0!==e.keep&&{keep:e.keep}};case"compact_20260112":return{type:e.type,...void 0!==e.trigger&&{trigger:e.trigger},...void 0!==e.pauseAfterCompaction&&{pause_after_compaction:e.pauseAfterCompaction},...void 0!==e.instructions&&{instructions:e.instructions}};default:R.push({type:"other",message:`Unknown context management strategy: ${t}`});return}}).filter(e=>void 0!==e)}}};W?("enabled"===G&&null==X&&(R.push({type:"compatibility",feature:"extended thinking",details:"thinking budget is required when thinking is enabled. using default budget of 1024 tokens."}),J.thinking={type:"enabled",budget_tokens:1024},X=1024),null!=J.temperature&&(J.temperature=void 0,R.push({type:"unsupported",feature:"temperature",details:"temperature is not supported when thinking is enabled"})),null!=i&&(J.top_k=void 0,R.push({type:"unsupported",feature:"topK",details:"topK is not supported when thinking is enabled"})),null!=o&&(J.top_p=void 0,R.push({type:"unsupported",feature:"topP",details:"topP is not supported when thinking is enabled"})),J.max_tokens=B+(null!=X?X:0)):null!=o&&null!=a&&(R.push({type:"unsupported",feature:"topP",details:"topP is not supported when temperature is set. topP is ignored."}),J.top_p=void 0),$&&J.max_tokens>A&&(null!=r&&R.push({type:"unsupported",feature:"maxOutputTokens",details:`${J.max_tokens} (maxOutputTokens + thinkingBudget) is greater than ${this.modelId} ${A} max output tokens. The max output tokens have been limited to ${A}.`}),J.max_tokens=A),(null==O?void 0:O.mcpServers)&&O.mcpServers.length>0&&V.add("mcp-client-2025-04-04"),D&&(V.add("context-management-2025-06-27"),D.edits.some(e=>"compact_20260112"===e.type)&&V.add("compact-2026-01-12")),(null==O?void 0:O.container)&&O.container.skills&&O.container.skills.length>0&&(V.add("code-execution-2025-08-25"),V.add("skills-2025-10-02"),V.add("files-api-2025-04-14"),(null==m?void 0:m.some(e=>"provider"===e.type&&("anthropic.code_execution_20250825"===e.id||"anthropic.code_execution_20260120"===e.id)))||R.push({type:"other",message:"code execution tool is required when using skills"})),(null==O?void 0:O.effort)&&V.add("effort-2025-11-24"),(null==O?void 0:O.speed)==="fast"&&V.add("fast-mode-2026-02-01"),_&&(null==(k=null==O?void 0:O.toolStreaming)||k)&&V.add("fine-grained-tool-streaming-2025-05-14");let{tools:H,toolChoice:Y,toolWarnings:Q,betas:ee}=await N(null!=z?{tools:[...null!=m?m:[],z],toolChoice:{type:"required"},disableParallelToolUse:!0,cacheControlValidator:q,supportsStructuredOutput:!1}:{tools:null!=m?m:[],toolChoice:f,disableParallelToolUse:null==O?void 0:O.disableParallelToolUse,cacheControlValidator:q,supportsStructuredOutput:P}),et=q.getWarnings();return{args:{...J,tools:H,tool_choice:Y,stream:!0===_||void 0},warnings:[...R,...Q,...et],betas:new Set([...V,...ee,...e,...null!=(I=null==O?void 0:O.anthropicBeta)?I:[]]),usesJsonResponseTool:null!=z,toolNameMapping:U,providerOptionsName:S,usedCustomProviderKey:E}}async getHeaders({betas:e,headers:t}){return(0,n.NF)(await (0,n.DB)(this.config.headers),t,e.size>0?{"anthropic-beta":Array.from(e).join(",")}:{})}async getBetasFromHeaders(e){var t,r;let a=null!=(t=(await (0,n.DB)(this.config.headers))["anthropic-beta"])?t:"",o=null!=(r=null==e?void 0:e["anthropic-beta"])?r:"";return new Set([...a.toLowerCase().split(","),...o.toLowerCase().split(",")].map(e=>e.trim()).filter(e=>""!==e))}buildRequestUrl(e){var t,r,a;return null!=(a=null==(r=(t=this.config).buildRequestUrl)?void 0:r.call(t,this.config.baseURL,e))?a:`${this.config.baseURL}/messages`}transformRequestBody(e,t){var r,a,n;return null!=(n=null==(a=(r=this.config).transformRequestBody)?void 0:a.call(r,e,t))?n:e}extractCitationDocuments(e){return e.filter(e=>"user"===e.role).flatMap(e=>e.content).filter(e=>{var t,r;if("file"!==e.type||"application/pdf"!==e.mediaType&&"text/plain"!==e.mediaType)return!1;let a=null==(t=e.providerOptions)?void 0:t.anthropic,n=null==a?void 0:a.citations;return null!=(r=null==n?void 0:n.enabled)&&r}).map(e=>{var t;return{title:null!=(t=e.filename)?t:"Untitled Document",filename:e.filename,mediaType:e.mediaType}})}async doGenerate(e){var t,r,a,o,i,u,d;let{args:c,warnings:p,betas:h,usesJsonResponseTool:m,toolNameMapping:f,providerOptionsName:y,usedCustomProviderKey:_}=await this.getArgs({...e,stream:!1,userSuppliedBetas:await this.getBetasFromHeaders(e.headers)}),g=[...this.extractCitationDocuments(e.prompt)],v=Q(c.tools),{responseHeaders:b,value:w,rawValue:x}=await (0,n.A8)({url:this.buildRequestUrl(!1),headers:await this.getHeaders({betas:h,headers:e.headers}),body:this.transformRequestBody(c,h),failedResponseHandler:s,successfulResponseHandler:(0,n.tc)(l),abortSignal:e.abortSignal,fetch:this.config.fetch}),k=[],I={},T={},R=!1;for(let e of w.content)switch(e.type){case"text":if(!m&&(k.push({type:"text",text:e.text}),e.citations))for(let t of e.citations){let e=H(t,g,this.generateId);e&&k.push(e)}break;case"thinking":k.push({type:"reasoning",text:e.thinking,providerMetadata:{anthropic:{signature:e.signature}}});break;case"redacted_thinking":k.push({type:"reasoning",text:"",providerMetadata:{anthropic:{redactedData:e.data}}});break;case"compaction":k.push({type:"text",text:e.content,providerMetadata:{anthropic:{type:"compaction"}}});break;case"tool_use":if(m&&"json"===e.name)R=!0,k.push({type:"text",text:JSON.stringify(e.input)});else{let t=e.caller,r=t?{type:t.type,toolId:"tool_id"in t?t.tool_id:void 0}:void 0;k.push({type:"tool-call",toolCallId:e.id,toolName:e.name,input:JSON.stringify(e.input),...r&&{providerMetadata:{anthropic:{caller:r}}}})}break;case"server_tool_use":if("text_editor_code_execution"===e.name||"bash_code_execution"===e.name)k.push({type:"tool-call",toolCallId:e.id,toolName:f.toCustomToolName("code_execution"),input:JSON.stringify({type:e.name,...e.input}),providerExecuted:!0});else if("web_search"===e.name||"code_execution"===e.name||"web_fetch"===e.name){let t="code_execution"===e.name&&null!=e.input&&"object"==typeof e.input&&"code"in e.input&&!("type"in e.input)?{type:"programmatic-tool-call",...e.input}:e.input;k.push({type:"tool-call",toolCallId:e.id,toolName:f.toCustomToolName(e.name),input:JSON.stringify(t),providerExecuted:!0,...v&&"code_execution"===e.name?{dynamic:!0}:{}})}else("tool_search_tool_regex"===e.name||"tool_search_tool_bm25"===e.name)&&(T[e.id]=e.name,k.push({type:"tool-call",toolCallId:e.id,toolName:f.toCustomToolName(e.name),input:JSON.stringify(e.input),providerExecuted:!0}));break;case"mcp_tool_use":I[e.id]={type:"tool-call",toolCallId:e.id,toolName:e.name,input:JSON.stringify(e.input),providerExecuted:!0,dynamic:!0,providerMetadata:{anthropic:{type:"mcp-tool-use",serverName:e.server_name}}},k.push(I[e.id]);break;case"mcp_tool_result":k.push({type:"tool-result",toolCallId:e.tool_use_id,toolName:I[e.tool_use_id].toolName,isError:e.is_error,result:e.content,dynamic:!0,providerMetadata:I[e.tool_use_id].providerMetadata});break;case"web_fetch_tool_result":"web_fetch_result"===e.content.type?(g.push({title:null!=(t=e.content.content.title)?t:e.content.url,mediaType:e.content.content.source.media_type}),k.push({type:"tool-result",toolCallId:e.tool_use_id,toolName:f.toCustomToolName("web_fetch"),result:{type:"web_fetch_result",url:e.content.url,retrievedAt:e.content.retrieved_at,content:{type:e.content.content.type,title:e.content.content.title,citations:e.content.content.citations,source:{type:e.content.content.source.type,mediaType:e.content.content.source.media_type,data:e.content.content.source.data}}}})):"web_fetch_tool_result_error"===e.content.type&&k.push({type:"tool-result",toolCallId:e.tool_use_id,toolName:f.toCustomToolName("web_fetch"),isError:!0,result:{type:"web_fetch_tool_result_error",errorCode:e.content.error_code}});break;case"web_search_tool_result":if(Array.isArray(e.content))for(let t of(k.push({type:"tool-result",toolCallId:e.tool_use_id,toolName:f.toCustomToolName("web_search"),result:e.content.map(e=>{var t;return{url:e.url,title:e.title,pageAge:null!=(t=e.page_age)?t:null,encryptedContent:e.encrypted_content,type:e.type}})}),e.content))k.push({type:"source",sourceType:"url",id:this.generateId(),url:t.url,title:t.title,providerMetadata:{anthropic:{pageAge:null!=(r=t.page_age)?r:null}}});else k.push({type:"tool-result",toolCallId:e.tool_use_id,toolName:f.toCustomToolName("web_search"),isError:!0,result:{type:"web_search_tool_result_error",errorCode:e.content.error_code}});break;case"code_execution_tool_result":"code_execution_result"===e.content.type?k.push({type:"tool-result",toolCallId:e.tool_use_id,toolName:f.toCustomToolName("code_execution"),result:{type:e.content.type,stdout:e.content.stdout,stderr:e.content.stderr,return_code:e.content.return_code,content:null!=(a=e.content.content)?a:[]}}):"encrypted_code_execution_result"===e.content.type?k.push({type:"tool-result",toolCallId:e.tool_use_id,toolName:f.toCustomToolName("code_execution"),result:{type:e.content.type,encrypted_stdout:e.content.encrypted_stdout,stderr:e.content.stderr,return_code:e.content.return_code,content:null!=(o=e.content.content)?o:[]}}):"code_execution_tool_result_error"===e.content.type&&k.push({type:"tool-result",toolCallId:e.tool_use_id,toolName:f.toCustomToolName("code_execution"),isError:!0,result:{type:"code_execution_tool_result_error",errorCode:e.content.error_code}});break;case"bash_code_execution_tool_result":case"text_editor_code_execution_tool_result":k.push({type:"tool-result",toolCallId:e.tool_use_id,toolName:f.toCustomToolName("code_execution"),result:e.content});break;case"tool_search_tool_result":{let t=T[e.tool_use_id];if(null==t){let e=f.toCustomToolName("tool_search_tool_bm25");f.toCustomToolName("tool_search_tool_regex"),t="tool_search_tool_bm25"!==e?"tool_search_tool_bm25":"tool_search_tool_regex"}"tool_search_tool_search_result"===e.content.type?k.push({type:"tool-result",toolCallId:e.tool_use_id,toolName:f.toCustomToolName(t),result:e.content.tool_references.map(e=>({type:e.type,toolName:e.tool_name}))}):k.push({type:"tool-result",toolCallId:e.tool_use_id,toolName:f.toCustomToolName(t),isError:!0,result:{type:"tool_search_tool_result_error",errorCode:e.content.error_code}})}}return{content:k,finishReason:{unified:J({finishReason:w.stop_reason,isJsonResponseFromTool:R}),raw:null!=(i=w.stop_reason)?i:void 0},usage:M({usage:w.usage}),request:{body:c},response:{id:null!=(u=w.id)?u:void 0,modelId:null!=(d=w.model)?d:void 0,headers:b,body:x},warnings:p,providerMetadata:(()=>{var e,t,r,a,n;let o={usage:w.usage,cacheCreationInputTokens:null!=(e=w.usage.cache_creation_input_tokens)?e:null,stopSequence:null!=(t=w.stop_sequence)?t:null,iterations:w.usage.iterations?w.usage.iterations.map(e=>({type:e.type,inputTokens:e.input_tokens,outputTokens:e.output_tokens})):null,container:w.container?{expiresAt:w.container.expires_at,id:w.container.id,skills:null!=(a=null==(r=w.container.skills)?void 0:r.map(e=>({type:e.type,skillId:e.skill_id,version:e.version})))?a:null}:null,contextManagement:null!=(n=ee(w.context_management))?n:null},i={anthropic:o};return _&&"anthropic"!==y&&(i[y]=o),i})()}}async doStream(e){var t,r;let o,i;let{args:l,warnings:d,betas:c,usesJsonResponseTool:p,toolNameMapping:h,providerOptionsName:m,usedCustomProviderKey:f}=await this.getArgs({...e,stream:!0,userSuppliedBetas:await this.getBetasFromHeaders(e.headers)}),y=[...this.extractCitationDocuments(e.prompt)],_=Q(l.tools),g=this.buildRequestUrl(!0),{responseHeaders:v,value:b}=await (0,n.A8)({url:g,headers:await this.getHeaders({betas:c,headers:e.headers}),body:this.transformRequestBody(l,c),failedResponseHandler:s,successfulResponseHandler:(0,n.cP)(u),abortSignal:e.abortSignal,fetch:this.config.fetch}),w={unified:"other",raw:void 0},x={input_tokens:0,output_tokens:0,cache_creation_input_tokens:0,cache_read_input_tokens:0,iterations:null},k={},I={},T={},R=null,S=null,Z=null,C=null,E=!1,O=this.generateId,[A,N]=b.pipeThrough(new TransformStream({start(e){e.enqueue({type:"stream-start",warnings:d})},transform(t,r){var a,n,s,l,u,d,c,g,v,b,A,N,$,P;if(e.includeRawChunks&&r.enqueue({type:"raw",rawValue:t.rawValue}),!t.success){r.enqueue({type:"error",error:t.error});return}let j=t.value;switch(j.type){case"ping":return;case"content_block_start":{let e=j.content_block,t=e.type;switch(i=t,t){case"text":if(p)return;k[j.index]={type:"text"},r.enqueue({type:"text-start",id:String(j.index)});return;case"thinking":k[j.index]={type:"reasoning"},r.enqueue({type:"reasoning-start",id:String(j.index)});return;case"redacted_thinking":k[j.index]={type:"reasoning"},r.enqueue({type:"reasoning-start",id:String(j.index),providerMetadata:{anthropic:{redactedData:e.data}}});return;case"compaction":k[j.index]={type:"text"},r.enqueue({type:"text-start",id:String(j.index),providerMetadata:{anthropic:{type:"compaction"}}});return;case"tool_use":if(p&&"json"===e.name)E=!0,k[j.index]={type:"text"},r.enqueue({type:"text-start",id:String(j.index)});else{let t=e.caller,a=t?{type:t.type,toolId:"tool_id"in t?t.tool_id:void 0}:void 0,n=e.input&&Object.keys(e.input).length>0?JSON.stringify(e.input):"";k[j.index]={type:"tool-call",toolCallId:e.id,toolName:e.name,input:n,firstDelta:0===n.length,...a&&{caller:a}},r.enqueue({type:"tool-input-start",id:e.id,toolName:e.name})}return;case"server_tool_use":if(["web_fetch","web_search","code_execution","text_editor_code_execution","bash_code_execution"].includes(e.name)){let t="text_editor_code_execution"===e.name||"bash_code_execution"===e.name?"code_execution":e.name,a=h.toCustomToolName(t),n=null!=e.input&&"object"==typeof e.input&&Object.keys(e.input).length>0?JSON.stringify(e.input):"";k[j.index]={type:"tool-call",toolCallId:e.id,toolName:a,input:n,providerExecuted:!0,..._&&"code_execution"===t?{dynamic:!0}:{},firstDelta:!0,providerToolName:e.name},r.enqueue({type:"tool-input-start",id:e.id,toolName:a,providerExecuted:!0,..._&&"code_execution"===t?{dynamic:!0}:{}})}else if("tool_search_tool_regex"===e.name||"tool_search_tool_bm25"===e.name){T[e.id]=e.name;let t=h.toCustomToolName(e.name);k[j.index]={type:"tool-call",toolCallId:e.id,toolName:t,input:"",providerExecuted:!0,firstDelta:!0,providerToolName:e.name},r.enqueue({type:"tool-input-start",id:e.id,toolName:t,providerExecuted:!0})}return;case"web_fetch_tool_result":"web_fetch_result"===e.content.type?(y.push({title:null!=(a=e.content.content.title)?a:e.content.url,mediaType:e.content.content.source.media_type}),r.enqueue({type:"tool-result",toolCallId:e.tool_use_id,toolName:h.toCustomToolName("web_fetch"),result:{type:"web_fetch_result",url:e.content.url,retrievedAt:e.content.retrieved_at,content:{type:e.content.content.type,title:e.content.content.title,citations:e.content.content.citations,source:{type:e.content.content.source.type,mediaType:e.content.content.source.media_type,data:e.content.content.source.data}}}})):"web_fetch_tool_result_error"===e.content.type&&r.enqueue({type:"tool-result",toolCallId:e.tool_use_id,toolName:h.toCustomToolName("web_fetch"),isError:!0,result:{type:"web_fetch_tool_result_error",errorCode:e.content.error_code}});return;case"web_search_tool_result":if(Array.isArray(e.content))for(let t of(r.enqueue({type:"tool-result",toolCallId:e.tool_use_id,toolName:h.toCustomToolName("web_search"),result:e.content.map(e=>{var t;return{url:e.url,title:e.title,pageAge:null!=(t=e.page_age)?t:null,encryptedContent:e.encrypted_content,type:e.type}})}),e.content))r.enqueue({type:"source",sourceType:"url",id:O(),url:t.url,title:t.title,providerMetadata:{anthropic:{pageAge:null!=(n=t.page_age)?n:null}}});else r.enqueue({type:"tool-result",toolCallId:e.tool_use_id,toolName:h.toCustomToolName("web_search"),isError:!0,result:{type:"web_search_tool_result_error",errorCode:e.content.error_code}});return;case"code_execution_tool_result":"code_execution_result"===e.content.type?r.enqueue({type:"tool-result",toolCallId:e.tool_use_id,toolName:h.toCustomToolName("code_execution"),result:{type:e.content.type,stdout:e.content.stdout,stderr:e.content.stderr,return_code:e.content.return_code,content:null!=(s=e.content.content)?s:[]}}):"encrypted_code_execution_result"===e.content.type?r.enqueue({type:"tool-result",toolCallId:e.tool_use_id,toolName:h.toCustomToolName("code_execution"),result:{type:e.content.type,encrypted_stdout:e.content.encrypted_stdout,stderr:e.content.stderr,return_code:e.content.return_code,content:null!=(l=e.content.content)?l:[]}}):"code_execution_tool_result_error"===e.content.type&&r.enqueue({type:"tool-result",toolCallId:e.tool_use_id,toolName:h.toCustomToolName("code_execution"),isError:!0,result:{type:"code_execution_tool_result_error",errorCode:e.content.error_code}});return;case"bash_code_execution_tool_result":case"text_editor_code_execution_tool_result":r.enqueue({type:"tool-result",toolCallId:e.tool_use_id,toolName:h.toCustomToolName("code_execution"),result:e.content});return;case"tool_search_tool_result":{let t=T[e.tool_use_id];if(null==t){let e=h.toCustomToolName("tool_search_tool_bm25");h.toCustomToolName("tool_search_tool_regex"),t="tool_search_tool_bm25"!==e?"tool_search_tool_bm25":"tool_search_tool_regex"}"tool_search_tool_search_result"===e.content.type?r.enqueue({type:"tool-result",toolCallId:e.tool_use_id,toolName:h.toCustomToolName(t),result:e.content.tool_references.map(e=>({type:e.type,toolName:e.tool_name}))}):r.enqueue({type:"tool-result",toolCallId:e.tool_use_id,toolName:h.toCustomToolName(t),isError:!0,result:{type:"tool_search_tool_result_error",errorCode:e.content.error_code}});return}case"mcp_tool_use":I[e.id]={type:"tool-call",toolCallId:e.id,toolName:e.name,input:JSON.stringify(e.input),providerExecuted:!0,dynamic:!0,providerMetadata:{anthropic:{type:"mcp-tool-use",serverName:e.server_name}}},r.enqueue(I[e.id]);return;case"mcp_tool_result":r.enqueue({type:"tool-result",toolCallId:e.tool_use_id,toolName:I[e.tool_use_id].toolName,isError:e.is_error,result:e.content,dynamic:!0,providerMetadata:I[e.tool_use_id].providerMetadata});return;default:throw Error(`Unsupported content block type: ${t}`)}}case"content_block_stop":if(null!=k[j.index]){let e=k[j.index];switch(e.type){case"text":r.enqueue({type:"text-end",id:String(j.index)});break;case"reasoning":r.enqueue({type:"reasoning-end",id:String(j.index)});break;case"tool-call":if(!(p&&"json"===e.toolName)){r.enqueue({type:"tool-input-end",id:e.toolCallId});let t=""===e.input?"{}":e.input;if("code_execution"===e.providerToolName)try{let e=JSON.parse(t);null!=e&&"object"==typeof e&&"code"in e&&!("type"in e)&&(t=JSON.stringify({type:"programmatic-tool-call",...e}))}catch(e){}r.enqueue({type:"tool-call",toolCallId:e.toolCallId,toolName:e.toolName,input:t,providerExecuted:e.providerExecuted,..._&&"code_execution"===e.providerToolName?{dynamic:!0}:{},...e.caller&&{providerMetadata:{anthropic:{caller:e.caller}}}})}}delete k[j.index]}i=void 0;return;case"content_block_delta":{let e=j.delta.type;switch(e){case"text_delta":if(p)return;r.enqueue({type:"text-delta",id:String(j.index),delta:j.delta.text});return;case"thinking_delta":r.enqueue({type:"reasoning-delta",id:String(j.index),delta:j.delta.thinking});return;case"signature_delta":"thinking"===i&&r.enqueue({type:"reasoning-delta",id:String(j.index),delta:"",providerMetadata:{anthropic:{signature:j.delta.signature}}});return;case"compaction_delta":null!=j.delta.content&&r.enqueue({type:"text-delta",id:String(j.index),delta:j.delta.content});return;case"input_json_delta":{let e=k[j.index],t=j.delta.partial_json;if(0===t.length)return;if(E){if((null==e?void 0:e.type)!=="text")return;r.enqueue({type:"text-delta",id:String(j.index),delta:t})}else{if((null==e?void 0:e.type)!=="tool-call")return;e.firstDelta&&("bash_code_execution"===e.providerToolName||"text_editor_code_execution"===e.providerToolName)&&(t=`{"type": "${e.providerToolName}",${t.substring(1)}`),r.enqueue({type:"tool-input-delta",id:e.toolCallId,delta:t}),e.input+=t,e.firstDelta=!1}return}case"citations_delta":{let e=H(j.delta.citation,y,O);e&&r.enqueue(e);return}default:throw Error(`Unsupported delta type: ${e}`)}}case"message_start":if(x.input_tokens=j.message.usage.input_tokens,x.cache_read_input_tokens=null!=(u=j.message.usage.cache_read_input_tokens)?u:0,x.cache_creation_input_tokens=null!=(d=j.message.usage.cache_creation_input_tokens)?d:0,o={...j.message.usage},S=null!=(c=j.message.usage.cache_creation_input_tokens)?c:null,null!=j.message.container&&(C={expiresAt:j.message.container.expires_at,id:j.message.container.id,skills:null}),null!=j.message.stop_reason&&(w={unified:J({finishReason:j.message.stop_reason,isJsonResponseFromTool:E}),raw:j.message.stop_reason}),r.enqueue({type:"response-metadata",id:null!=(g=j.message.id)?g:void 0,modelId:null!=(v=j.message.model)?v:void 0}),null!=j.message.content)for(let e=0;e<j.message.content.length;e++){let t=j.message.content[e];if("tool_use"===t.type){let e=t.caller,a=e?{type:e.type,toolId:"tool_id"in e?e.tool_id:void 0}:void 0;r.enqueue({type:"tool-input-start",id:t.id,toolName:t.name});let n=JSON.stringify(null!=(b=t.input)?b:{});r.enqueue({type:"tool-input-delta",id:t.id,delta:n}),r.enqueue({type:"tool-input-end",id:t.id}),r.enqueue({type:"tool-call",toolCallId:t.id,toolName:t.name,input:n,...a&&{providerMetadata:{anthropic:{caller:a}}}})}}return;case"message_delta":null!=j.usage.input_tokens&&x.input_tokens!==j.usage.input_tokens&&(x.input_tokens=j.usage.input_tokens),x.output_tokens=j.usage.output_tokens,null!=j.usage.cache_read_input_tokens&&(x.cache_read_input_tokens=j.usage.cache_read_input_tokens),null!=j.usage.cache_creation_input_tokens&&(x.cache_creation_input_tokens=j.usage.cache_creation_input_tokens,S=j.usage.cache_creation_input_tokens),null!=j.usage.iterations&&(x.iterations=j.usage.iterations),w={unified:J({finishReason:j.delta.stop_reason,isJsonResponseFromTool:E}),raw:null!=(A=j.delta.stop_reason)?A:void 0},Z=null!=(N=j.delta.stop_sequence)?N:null,C=null!=j.delta.container?{expiresAt:j.delta.container.expires_at,id:j.delta.container.id,skills:null!=(P=null==($=j.delta.container.skills)?void 0:$.map(e=>({type:e.type,skillId:e.skill_id,version:e.version})))?P:null}:null,j.context_management&&(R=ee(j.context_management)),o={...o,...j.usage};return;case"message_stop":{let e={usage:null!=o?o:null,cacheCreationInputTokens:S,stopSequence:Z,iterations:x.iterations?x.iterations.map(e=>({type:e.type,inputTokens:e.input_tokens,outputTokens:e.output_tokens})):null,container:C,contextManagement:R},t={anthropic:e};f&&"anthropic"!==m&&(t[m]=e),r.enqueue({type:"finish",finishReason:w,usage:M({usage:x,rawUsage:o}),providerMetadata:t});return}case"error":r.enqueue({type:"error",error:j.error});return;default:throw Error(`Unsupported chunk type: ${j}`)}}})).tee(),$=A.getReader();try{await $.read();let e=await $.read();if((null==(t=e.value)?void 0:t.type)==="raw"&&(e=await $.read()),(null==(r=e.value)?void 0:r.type)==="error"){let t=e.value.error;throw new a.w({message:t.message,url:g,requestBodyValues:l,statusCode:"overloaded_error"===t.type?529:500,responseHeaders:v,responseBody:JSON.stringify(t),isRetryable:"overloaded_error"===t.type})}}finally{$.cancel().catch(()=>{}),$.releaseLock()}return{stream:N,request:{body:l},response:{headers:v}}}};function Q(e){if(!e)return!1;let t=!1,r=!1;for(let a of e){if("type"in a&&("web_fetch_20260209"===a.type||"web_search_20260209"===a.type)){t=!0;continue}if("code_execution"===a.name){r=!0;break}}return t&&!r}function ee(e){return e?{appliedEdits:e.applied_edits.map(e=>{switch(e.type){case"clear_tool_uses_20250919":return{type:e.type,clearedToolUses:e.cleared_tool_uses,clearedInputTokens:e.cleared_input_tokens};case"clear_thinking_20251015":return{type:e.type,clearedThinkingTurns:e.cleared_thinking_turns,clearedInputTokens:e.cleared_input_tokens};case"compact_20260112":return{type:e.type}}}).filter(e=>void 0!==e)}:null}var et=(0,n.DG)(()=>(0,n.r0)(o.Ry({command:o.Z_(),restart:o.O7().optional()}))),er=(0,n.W0)({id:"anthropic.bash_20241022",inputSchema:et}),ea=(0,n.DG)(()=>(0,n.r0)(o.Ry({command:o.Z_(),restart:o.O7().optional()}))),en=(0,n.W0)({id:"anthropic.bash_20250124",inputSchema:ea}),eo=(0,n.DG)(()=>(0,n.r0)(o.Ry({action:o.Km(["key","type","mouse_move","left_click","left_click_drag","right_click","middle_click","double_click","screenshot","cursor_position"]),coordinate:o.IX(o.Rx().int()).optional(),text:o.Z_().optional()}))),ei=(0,n.W0)({id:"anthropic.computer_20241022",inputSchema:eo}),es=(0,n.DG)(()=>(0,n.r0)(o.Ry({action:o.Km(["key","hold_key","type","cursor_position","mouse_move","left_mouse_down","left_mouse_up","left_click","left_click_drag","right_click","middle_click","double_click","triple_click","scroll","wait","screenshot"]),coordinate:o.bc([o.Rx().int(),o.Rx().int()]).optional(),duration:o.Rx().optional(),scroll_amount:o.Rx().optional(),scroll_direction:o.Km(["up","down","left","right"]).optional(),start_coordinate:o.bc([o.Rx().int(),o.Rx().int()]).optional(),text:o.Z_().optional()}))),el=(0,n.W0)({id:"anthropic.computer_20250124",inputSchema:es}),eu=(0,n.DG)(()=>(0,n.r0)(o.Ry({action:o.Km(["key","hold_key","type","cursor_position","mouse_move","left_mouse_down","left_mouse_up","left_click","left_click_drag","right_click","middle_click","double_click","triple_click","scroll","wait","screenshot","zoom"]),coordinate:o.bc([o.Rx().int(),o.Rx().int()]).optional(),duration:o.Rx().optional(),region:o.bc([o.Rx().int(),o.Rx().int(),o.Rx().int(),o.Rx().int()]).optional(),scroll_amount:o.Rx().optional(),scroll_direction:o.Km(["up","down","left","right"]).optional(),start_coordinate:o.bc([o.Rx().int(),o.Rx().int()]).optional(),text:o.Z_().optional()}))),ed=(0,n.W0)({id:"anthropic.computer_20251124",inputSchema:eu}),ec=(0,n.DG)(()=>(0,n.r0)(o.VK("command",[o.Ry({command:o.i0("view"),path:o.Z_(),view_range:o.bc([o.Rx(),o.Rx()]).optional()}),o.Ry({command:o.i0("create"),path:o.Z_(),file_text:o.Z_()}),o.Ry({command:o.i0("str_replace"),path:o.Z_(),old_str:o.Z_(),new_str:o.Z_()}),o.Ry({command:o.i0("insert"),path:o.Z_(),insert_line:o.Rx(),insert_text:o.Z_()}),o.Ry({command:o.i0("delete"),path:o.Z_()}),o.Ry({command:o.i0("rename"),old_path:o.Z_(),new_path:o.Z_()})]))),ep=(0,n.W0)({id:"anthropic.memory_20250818",inputSchema:ec}),eh=(0,n.DG)(()=>(0,n.r0)(o.Ry({command:o.Km(["view","create","str_replace","insert","undo_edit"]),path:o.Z_(),file_text:o.Z_().optional(),insert_line:o.Rx().int().optional(),new_str:o.Z_().optional(),insert_text:o.Z_().optional(),old_str:o.Z_().optional(),view_range:o.IX(o.Rx().int()).optional()}))),em=(0,n.W0)({id:"anthropic.text_editor_20241022",inputSchema:eh}),ef=(0,n.DG)(()=>(0,n.r0)(o.Ry({command:o.Km(["view","create","str_replace","insert","undo_edit"]),path:o.Z_(),file_text:o.Z_().optional(),insert_line:o.Rx().int().optional(),new_str:o.Z_().optional(),insert_text:o.Z_().optional(),old_str:o.Z_().optional(),view_range:o.IX(o.Rx().int()).optional()}))),ey=(0,n.W0)({id:"anthropic.text_editor_20250124",inputSchema:ef}),e_=(0,n.DG)(()=>(0,n.r0)(o.Ry({command:o.Km(["view","create","str_replace","insert"]),path:o.Z_(),file_text:o.Z_().optional(),insert_line:o.Rx().int().optional(),new_str:o.Z_().optional(),insert_text:o.Z_().optional(),old_str:o.Z_().optional(),view_range:o.IX(o.Rx().int()).optional()}))),eg=(0,n.W0)({id:"anthropic.text_editor_20250429",inputSchema:e_}),ev=(0,n.DG)(()=>(0,n.r0)(o.IX(o.Ry({type:o.i0("tool_reference"),toolName:o.Z_()})))),eb=(0,n.DG)(()=>(0,n.r0)(o.Ry({query:o.Z_(),limit:o.Rx().optional()}))),ew=(0,n.ql)({id:"anthropic.tool_search_bm25_20251119",inputSchema:eb,outputSchema:ev,supportsDeferredResults:!0}),ex={bash_20241022:er,bash_20250124:en,codeExecution_20250522:(e={})=>j(e),codeExecution_20250825:(e={})=>D(e),codeExecution_20260120:(e={})=>L(e),computer_20241022:ei,computer_20250124:el,computer_20251124:ed,memory_20250818:ep,textEditor_20241022:em,textEditor_20250124:ey,textEditor_20250429:eg,textEditor_20250728:(e={})=>y(e),webFetch_20250910:(e={})=>A(e),webFetch_20260209:(e={})=>Z(e),webSearch_20250305:(e={})=>I(e),webSearch_20260209:(e={})=>b(e),toolSearchRegex_20251119:(e={})=>W(e),toolSearchBm25_20251119:(e={})=>ew(e)};function ek(e={}){var t,r;let o=null!=(t=(0,n.QT)((0,n.P6)({settingValue:e.baseURL,environmentVariableName:"ANTHROPIC_BASE_URL"})))?t:"https://api.anthropic.com/v1",i=null!=(r=e.name)?r:"anthropic.messages";if(e.apiKey&&e.authToken)throw new a.RU({argument:"apiKey/authToken",message:"Both apiKey and authToken were provided. Please use only one authentication method."});let s=()=>{let t=e.authToken?{Authorization:`Bearer ${e.authToken}`}:{"x-api-key":(0,n.pd)({apiKey:e.apiKey,environmentVariableName:"ANTHROPIC_API_KEY",description:"Anthropic"})};return(0,n.CR)({"anthropic-version":"2023-06-01",...t,...e.headers},"ai-sdk/anthropic/3.0.58")},l=t=>{var r;return new Y(t,{provider:i,baseURL:o,headers:s,fetch:e.fetch,generateId:null!=(r=e.generateId)?r:n.Ox,supportedUrls:()=>({"image/*":[/^https?:\/\/.*$/],"application/pdf":[/^https?:\/\/.*$/]})})},u=function(e){if(new.target)throw Error("The Anthropic model function cannot be called with the new keyword.");return l(e)};return u.specificationVersion="v3",u.languageModel=l,u.chat=l,u.messages=l,u.embeddingModel=e=>{throw new a.JJ({modelId:e,modelType:"embeddingModel"})},u.textEmbeddingModel=u.embeddingModel,u.imageModel=e=>{throw new a.JJ({modelId:e,modelType:"imageModel"})},u.tools=ex,u}ek()},6365:(e,t,r)=>{r.d(t,{N$:()=>C,eh:()=>g,Bx:()=>Z,C3:()=>eM,NF:()=>m,MS:()=>x,QF:()=>I,k0:()=>k,cP:()=>eJ,bF:()=>M,Sq:()=>eK,tc:()=>eH,W0:()=>eW,ql:()=>eX,U_:()=>f,gw:()=>y,aN:()=>eQ,Ox:()=>$,e$:()=>P,hb:()=>W,gJ:()=>q,D_:()=>j,C_:()=>X,MT:()=>B,fB:()=>eN,DG:()=>eA,pd:()=>K,P6:()=>J,kh:()=>U,RF:()=>eD,c1:()=>eq,A8:()=>eL,SN:()=>E,DB:()=>eB,NX:()=>ez,pW:()=>ej,w3:()=>eG,SA:()=>O,rJ:()=>eP,CR:()=>L,QT:()=>eY,r0:()=>e$});var a,n,o=r(9519),i=r(6496),s=r(8510);class l{constructor(e){this.counter=0,this.metadataRegistry=e?.metadata??i.$Z,this.target=e?.target??"draft-2020-12",this.unrepresentable=e?.unrepresentable??"throw",this.override=e?.override??(()=>{}),this.io=e?.io??"output",this.seen=new Map}process(e,t={path:[],schemaPath:[]}){var r;let a=e._zod.def,n=this.seen.get(e);if(n)return n.count++,t.schemaPath.includes(e)&&(n.cycle=t.path),n.schema;let o={schema:{},count:1,cycle:void 0,path:t.path};this.seen.set(e,o);let i=e._zod.toJSONSchema?.();if(i)o.schema=i;else{let r={...t,schemaPath:[...t.schemaPath,e],path:t.path},n=e._zod.parent;if(n)o.ref=n,this.process(n,r),this.seen.get(n).isParent=!0;else{let t=o.schema;switch(a.type){case"string":{t.type="string";let{minimum:r,maximum:a,format:n,patterns:i,contentEncoding:s}=e._zod.bag;if("number"==typeof r&&(t.minLength=r),"number"==typeof a&&(t.maxLength=a),n&&(t.format=({guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""})[n]??n,""===t.format&&delete t.format),s&&(t.contentEncoding=s),i&&i.size>0){let e=[...i];1===e.length?t.pattern=e[0].source:e.length>1&&(o.schema.allOf=[...e.map(e=>({..."draft-7"===this.target?{type:"string"}:{},pattern:e.source}))])}break}case"number":{let{minimum:r,maximum:a,format:n,multipleOf:o,exclusiveMaximum:i,exclusiveMinimum:s}=e._zod.bag;"string"==typeof n&&n.includes("int")?t.type="integer":t.type="number","number"==typeof s&&(t.exclusiveMinimum=s),"number"==typeof r&&(t.minimum=r,"number"==typeof s&&(s>=r?delete t.minimum:delete t.exclusiveMinimum)),"number"==typeof i&&(t.exclusiveMaximum=i),"number"==typeof a&&(t.maximum=a,"number"==typeof i&&(i<=a?delete t.maximum:delete t.exclusiveMaximum)),"number"==typeof o&&(t.multipleOf=o);break}case"boolean":case"success":t.type="boolean";break;case"bigint":if("throw"===this.unrepresentable)throw Error("BigInt cannot be represented in JSON Schema");break;case"symbol":if("throw"===this.unrepresentable)throw Error("Symbols cannot be represented in JSON Schema");break;case"null":t.type="null";break;case"any":case"unknown":break;case"undefined":if("throw"===this.unrepresentable)throw Error("Undefined cannot be represented in JSON Schema");break;case"void":if("throw"===this.unrepresentable)throw Error("Void cannot be represented in JSON Schema");break;case"never":t.not={};break;case"date":if("throw"===this.unrepresentable)throw Error("Date cannot be represented in JSON Schema");break;case"array":{let{minimum:n,maximum:o}=e._zod.bag;"number"==typeof n&&(t.minItems=n),"number"==typeof o&&(t.maxItems=o),t.type="array",t.items=this.process(a.element,{...r,path:[...r.path,"items"]});break}case"object":{t.type="object",t.properties={};let e=a.shape;for(let a in e)t.properties[a]=this.process(e[a],{...r,path:[...r.path,"properties",a]});let n=new Set([...new Set(Object.keys(e))].filter(e=>{let t=a.shape[e]._zod;return"input"===this.io?void 0===t.optin:void 0===t.optout}));n.size>0&&(t.required=Array.from(n)),a.catchall?._zod.def.type==="never"?t.additionalProperties=!1:a.catchall?a.catchall&&(t.additionalProperties=this.process(a.catchall,{...r,path:[...r.path,"additionalProperties"]})):"output"===this.io&&(t.additionalProperties=!1);break}case"union":t.anyOf=a.options.map((e,t)=>this.process(e,{...r,path:[...r.path,"anyOf",t]}));break;case"intersection":{let e=this.process(a.left,{...r,path:[...r.path,"allOf",0]}),n=this.process(a.right,{...r,path:[...r.path,"allOf",1]}),o=[..."allOf"in e&&1===Object.keys(e).length?e.allOf:[e],..."allOf"in n&&1===Object.keys(n).length?n.allOf:[n]];t.allOf=o;break}case"tuple":{t.type="array";let n=a.items.map((e,t)=>this.process(e,{...r,path:[...r.path,"prefixItems",t]}));if("draft-2020-12"===this.target?t.prefixItems=n:t.items=n,a.rest){let e=this.process(a.rest,{...r,path:[...r.path,"items"]});"draft-2020-12"===this.target?t.items=e:t.additionalItems=e}a.rest&&(t.items=this.process(a.rest,{...r,path:[...r.path,"items"]}));let{minimum:o,maximum:i}=e._zod.bag;"number"==typeof o&&(t.minItems=o),"number"==typeof i&&(t.maxItems=i);break}case"record":t.type="object",t.propertyNames=this.process(a.keyType,{...r,path:[...r.path,"propertyNames"]}),t.additionalProperties=this.process(a.valueType,{...r,path:[...r.path,"additionalProperties"]});break;case"map":if("throw"===this.unrepresentable)throw Error("Map cannot be represented in JSON Schema");break;case"set":if("throw"===this.unrepresentable)throw Error("Set cannot be represented in JSON Schema");break;case"enum":{let e=(0,s.B8)(a.entries);e.every(e=>"number"==typeof e)&&(t.type="number"),e.every(e=>"string"==typeof e)&&(t.type="string"),t.enum=e;break}case"literal":{let e=[];for(let t of a.values)if(void 0===t){if("throw"===this.unrepresentable)throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if("bigint"==typeof t){if("throw"===this.unrepresentable)throw Error("BigInt literals cannot be represented in JSON Schema");e.push(Number(t))}else e.push(t);if(0===e.length);else if(1===e.length){let r=e[0];t.type=null===r?"null":typeof r,t.const=r}else e.every(e=>"number"==typeof e)&&(t.type="number"),e.every(e=>"string"==typeof e)&&(t.type="string"),e.every(e=>"boolean"==typeof e)&&(t.type="string"),e.every(e=>null===e)&&(t.type="null"),t.enum=e;break}case"file":{let r={type:"string",format:"binary",contentEncoding:"binary"},{minimum:a,maximum:n,mime:o}=e._zod.bag;void 0!==a&&(r.minLength=a),void 0!==n&&(r.maxLength=n),o?1===o.length?(r.contentMediaType=o[0],Object.assign(t,r)):t.anyOf=o.map(e=>({...r,contentMediaType:e})):Object.assign(t,r);break}case"transform":if("throw"===this.unrepresentable)throw Error("Transforms cannot be represented in JSON Schema");break;case"nullable":{let e=this.process(a.innerType,r);t.anyOf=[e,{type:"null"}];break}case"nonoptional":case"promise":case"optional":this.process(a.innerType,r),o.ref=a.innerType;break;case"default":this.process(a.innerType,r),o.ref=a.innerType,t.default=JSON.parse(JSON.stringify(a.defaultValue));break;case"prefault":this.process(a.innerType,r),o.ref=a.innerType,"input"===this.io&&(t._prefault=JSON.parse(JSON.stringify(a.defaultValue)));break;case"catch":{let e;this.process(a.innerType,r),o.ref=a.innerType;try{e=a.catchValue(void 0)}catch{throw Error("Dynamic catch values are not supported in JSON Schema")}t.default=e;break}case"nan":if("throw"===this.unrepresentable)throw Error("NaN cannot be represented in JSON Schema");break;case"template_literal":{let r=e._zod.pattern;if(!r)throw Error("Pattern not found in template literal");t.type="string",t.pattern=r.source;break}case"pipe":{let e="input"===this.io?"transform"===a.in._zod.def.type?a.out:a.in:a.out;this.process(e,r),o.ref=e;break}case"readonly":this.process(a.innerType,r),o.ref=a.innerType,t.readOnly=!0;break;case"lazy":{let t=e._zod.innerType;this.process(t,r),o.ref=t;break}case"custom":if("throw"===this.unrepresentable)throw Error("Custom types cannot be represented in JSON Schema")}}}let l=this.metadataRegistry.get(e);return l&&Object.assign(o.schema,l),"input"===this.io&&function e(t,r){let a=r??{seen:new Set};if(a.seen.has(t))return!1;a.seen.add(t);let n=t._zod.def;switch(n.type){case"string":case"number":case"bigint":case"boolean":case"date":case"symbol":case"undefined":case"null":case"any":case"unknown":case"never":case"void":case"literal":case"enum":case"nan":case"file":case"template_literal":case"custom":case"success":case"catch":return!1;case"array":return e(n.element,a);case"object":for(let t in n.shape)if(e(n.shape[t],a))return!0;return!1;case"union":for(let t of n.options)if(e(t,a))return!0;return!1;case"intersection":return e(n.left,a)||e(n.right,a);case"tuple":for(let t of n.items)if(e(t,a))return!0;if(n.rest&&e(n.rest,a))return!0;return!1;case"record":case"map":return e(n.keyType,a)||e(n.valueType,a);case"set":return e(n.valueType,a);case"promise":case"optional":case"nonoptional":case"nullable":case"readonly":case"default":case"prefault":return e(n.innerType,a);case"lazy":return e(n.getter(),a);case"transform":return!0;case"pipe":return e(n.in,a)||e(n.out,a)}throw Error(`Unknown schema type: ${n.type}`)}(e)&&(delete o.schema.examples,delete o.schema.default),"input"===this.io&&o.schema._prefault&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,this.seen.get(e).schema}emit(e,t){let r={cycles:t?.cycles??"ref",reused:t?.reused??"inline",external:t?.external??void 0},a=this.seen.get(e);if(!a)throw Error("Unprocessed schema. This is a bug in Zod.");let n=e=>{let t="draft-2020-12"===this.target?"$defs":"definitions";if(r.external){let a=r.external.registry.get(e[0])?.id,n=r.external.uri??(e=>e);if(a)return{ref:n(a)};let o=e[1].defId??e[1].schema.id??`schema${this.counter++}`;return e[1].defId=o,{defId:o,ref:`${n("__shared")}#/${t}/${o}`}}if(e[1]===a)return{ref:"#"};let n=`#/${t}/`,o=e[1].schema.id??`__schema${this.counter++}`;return{defId:o,ref:n+o}},o=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:r,defId:a}=n(e);t.def={...t.schema},a&&(t.defId=a);let o=t.schema;for(let e in o)delete o[e];o.$ref=r};if("throw"===r.cycles)for(let e of this.seen.entries()){let t=e[1];if(t.cycle)throw Error(`Cycle detected: #/${t.cycle?.join("/")}/<root>
|
|
3
|
-
|
|
4
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let t of this.seen.entries()){let a=t[1];if(e===t[0]){o(t);continue}if(r.external){let a=r.external.registry.get(t[0])?.id;if(e!==t[0]&&a){o(t);continue}}if(this.metadataRegistry.get(t[0])?.id||a.cycle||a.count>1&&"ref"===r.reused){o(t);continue}}let i=(e,t)=>{let r=this.seen.get(e),a=r.def??r.schema,n={...a};if(null===r.ref)return;let o=r.ref;if(r.ref=null,o){i(o,t);let e=this.seen.get(o).schema;e.$ref&&"draft-7"===t.target?(a.allOf=a.allOf??[],a.allOf.push(e)):(Object.assign(a,e),Object.assign(a,n))}r.isParent||this.override({zodSchema:e,jsonSchema:a,path:r.path??[]})};for(let e of[...this.seen.entries()].reverse())i(e[0],{target:this.target});let s={};if("draft-2020-12"===this.target?s.$schema="https://json-schema.org/draft/2020-12/schema":"draft-7"===this.target?s.$schema="http://json-schema.org/draft-07/schema#":console.warn(`Invalid target: ${this.target}`),r.external?.uri){let t=r.external.registry.get(e)?.id;if(!t)throw Error("Schema is missing an `id` property");s.$id=r.external.uri(t)}Object.assign(s,a.def);let l=r.external?.defs??{};for(let e of this.seen.entries()){let t=e[1];t.def&&t.defId&&(l[t.defId]=t.def)}r.external||Object.keys(l).length>0&&("draft-2020-12"===this.target?s.$defs=l:s.definitions=l);try{return JSON.parse(JSON.stringify(s))}catch(e){throw Error("Error converting schema to JSON.")}}}var u=r(3947),d=r(9763);class c extends Error{constructor(e,t){super(e),this.name="ParseError",this.type=t.type,this.field=t.field,this.value=t.value,this.line=t.line}}function p(e){}class h extends TransformStream{constructor({onError:e,onRetry:t,onComment:r}={}){let a;super({start(n){a=function(e){if("function"==typeof e)throw TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");let{onEvent:t=p,onError:r=p,onRetry:a=p,onComment:n}=e,o="",i=!0,s,l="",u="";function d(e){if(""===e){l.length>0&&t({id:s,event:u||void 0,data:l.endsWith(`
|
|
5
|
-
`)?l.slice(0,-1):l}),s=void 0,l="",u="";return}if(e.startsWith(":")){n&&n(e.slice(e.startsWith(": ")?2:1));return}let r=e.indexOf(":");if(-1!==r){let t=e.slice(0,r),a=" "===e[r+1]?2:1;h(t,e.slice(r+a),e);return}h(e,"",e)}function h(e,t,n){switch(e){case"event":u=t;break;case"data":l=`${l}${t}
|
|
6
|
-
`;break;case"id":s=t.includes("\0")?void 0:t;break;case"retry":/^\d+$/.test(t)?a(parseInt(t,10)):r(new c(`Invalid \`retry\` value: "${t}"`,{type:"invalid-retry",value:t,line:n}));break;default:r(new c(`Unknown field "${e.length>20?`${e.slice(0,20)}\u2026`:e}"`,{type:"unknown-field",field:e,value:t,line:n}))}}return{feed:function(e){let t=i?e.replace(/^\xEF\xBB\xBF/,""):e,[r,a]=function(e){let t=[],r="",a=0;for(;a<e.length;){let n=e.indexOf("\r",a),o=e.indexOf(`
|
|
7
|
-
`,a),i=-1;if(-1!==n&&-1!==o?i=Math.min(n,o):-1!==n?i=n===e.length-1?-1:n:-1!==o&&(i=o),-1===i){r=e.slice(a);break}{let r=e.slice(a,i);t.push(r),"\r"===e[(a=i+1)-1]&&e[a]===`
|
|
8
|
-
`&&a++}}return[t,r]}(`${o}${t}`);for(let e of r)d(e);o=a,i=!1},reset:function(e={}){o&&e.consume&&d(o),i=!0,s=void 0,l="",u="",o=""}}}({onEvent:e=>{n.enqueue(e)},onError(t){"terminate"===e?n.error(t):"function"==typeof e&&e(t)},onRetry:t,onComment:r})},transform(e){a.feed(e)}})}}function m(...e){return e.reduce((e,t)=>({...e,...null!=t?t:{}}),{})}function f({tools:e=[],providerToolNames:t,resolveProviderToolName:r}){var a;let n={},o={};for(let i of e)if("provider"===i.type){let e=null!=(a=null==r?void 0:r(i))?a:i.id in t?t[i.id]:void 0;if(null==e)continue;n[i.name]=e,o[e]=i.name}return{toProviderToolName:e=>{var t;return null!=(t=n[e])?t:e},toCustomToolName:e=>{var t;return null!=(t=o[e])?t:e}}}async function y(e,t){if(null==e)return Promise.resolve();let r=null==t?void 0:t.abortSignal;return new Promise((t,a)=>{if(null==r?void 0:r.aborted){a(_());return}let n=setTimeout(()=>{o(),t()},e),o=()=>{clearTimeout(n),null==r||r.removeEventListener("abort",i)},i=()=>{o(),a(_())};null==r||r.addEventListener("abort",i)})}function _(){return new DOMException("Delay was aborted","AbortError")}var g=class{constructor(){this.status={type:"pending"},this._resolve=void 0,this._reject=void 0}get promise(){return this._promise||(this._promise=new Promise((e,t)=>{"resolved"===this.status.type?e(this.status.value):"rejected"===this.status.type&&t(this.status.error),this._resolve=e,this._reject=t})),this._promise}resolve(e){var t;this.status={type:"resolved",value:e},this._promise&&(null==(t=this._resolve)||t.call(this,e))}reject(e){var t;this.status={type:"rejected",error:e},this._promise&&(null==(t=this._reject)||t.call(this,e))}isResolved(){return"resolved"===this.status.type}isRejected(){return"rejected"===this.status.type}isPending(){return"pending"===this.status.type}};function v(e){return Object.fromEntries([...e.headers])}var{btoa:b,atob:w}=globalThis;function x(e){let t=w(e.replace(/-/g,"+").replace(/_/g,"/"));return Uint8Array.from(t,e=>e.codePointAt(0))}function k(e){let t="";for(let r=0;r<e.length;r++)t+=String.fromCodePoint(e[r]);return b(t)}function I(e){return e instanceof Uint8Array?k(e):e}var T="AI_DownloadError",R=`vercel.ai.error.${T}`,S=Symbol.for(R),Z=class extends(n=o.AX,a=S,n){constructor({url:e,statusCode:t,statusText:r,cause:n,message:o=null==n?`Failed to download ${e}: ${t} ${r}`:`Failed to download ${e}: ${n}`}){super({name:T,message:o,cause:n}),this[a]=!0,this.url=e,this.statusCode=t,this.statusText=r}static isInstance(e){return o.AX.hasMarker(e,R)}},C=2147483648;async function E({response:e,url:t,maxBytes:r=C}){let a=e.headers.get("content-length");if(null!=a){let e=parseInt(a,10);if(!isNaN(e)&&e>r)throw new Z({url:t,message:`Download of ${t} exceeded maximum size of ${r} bytes (Content-Length: ${e}).`})}let n=e.body;if(null==n)return new Uint8Array(0);let o=n.getReader(),i=[],s=0;try{for(;;){let{done:e,value:a}=await o.read();if(e)break;if((s+=a.length)>r)throw new Z({url:t,message:`Download of ${t} exceeded maximum size of ${r} bytes.`});i.push(a)}}finally{try{await o.cancel()}finally{o.releaseLock()}}let l=new Uint8Array(s),u=0;for(let e of i)l.set(e,u),u+=e.length;return l}function O(e){let t;try{t=new URL(e)}catch(t){throw new Z({url:e,message:`Invalid URL: ${e}`})}if("http:"!==t.protocol&&"https:"!==t.protocol)throw new Z({url:e,message:`URL scheme must be http or https, got ${t.protocol}`});let r=t.hostname;if(!r)throw new Z({url:e,message:"URL must have a hostname"});if("localhost"===r||r.endsWith(".local")||r.endsWith(".localhost"))throw new Z({url:e,message:`URL with hostname ${r} is not allowed`});if(r.startsWith("[")&&r.endsWith("]")){if(function(e){let t=e.toLowerCase();if("::1"===t||"::"===t)return!0;if(t.startsWith("::ffff:")){let e=t.slice(7);if(A(e))return N(e);let r=e.split(":");if(2===r.length){let e=parseInt(r[0],16),t=parseInt(r[1],16);if(!isNaN(e)&&!isNaN(t))return N(`${e>>8&255}.${255&e}.${t>>8&255}.${255&t}`)}}return!!(t.startsWith("fc")||t.startsWith("fd")||t.startsWith("fe80"))}(r.slice(1,-1)))throw new Z({url:e,message:`URL with IPv6 address ${r} is not allowed`});return}if(A(r)){if(N(r))throw new Z({url:e,message:`URL with IP address ${r} is not allowed`});return}}function A(e){let t=e.split(".");return 4===t.length&&t.every(e=>{let t=Number(e);return Number.isInteger(t)&&t>=0&&t<=255&&String(t)===e})}function N(e){let[t,r]=e.split(".").map(Number);return 0===t||10===t||127===t||169===t&&254===r||172===t&&r>=16&&r<=31||192===t&&168===r}var M=({prefix:e,size:t=16,alphabet:r="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",separator:a="-"}={})=>{let n=()=>{let e=r.length,a=Array(t);for(let n=0;n<t;n++)a[n]=r[Math.random()*e|0];return a.join("")};if(null==e)return n;if(r.includes(a))throw new o.RU({argument:"separator",message:`The separator "${a}" must not be part of the alphabet "${r}".`});return()=>`${e}${a}${n()}`},$=M();function P(e){return null==e?"unknown error":"string"==typeof e?e:e instanceof Error?e.message:JSON.stringify(e)}function j(e){return(e instanceof Error||e instanceof DOMException)&&("AbortError"===e.name||"ResponseAborted"===e.name||"TimeoutError"===e.name)}var F=["fetch failed","failed to fetch"],z=["ConnectionRefused","ConnectionClosed","FailedToOpenSocket","ECONNRESET","ECONNREFUSED","ETIMEDOUT","EPIPE"];function D({error:e,url:t,requestBodyValues:r}){if(j(e))return e;if(e instanceof TypeError&&F.includes(e.message.toLowerCase())){let a=e.cause;if(null!=a)return new o.w({message:`Cannot connect to API: ${a.message}`,cause:a,url:t,requestBodyValues:r,isRetryable:!0})}return!function(e){if(!(e instanceof Error))return!1;let t=e.code;return!!("string"==typeof t&&z.includes(t))}(e)?e:new o.w({message:`Cannot connect to API: ${e.message}`,cause:e,url:t,requestBodyValues:r,isRetryable:!0})}function q(e=globalThis){var t,r,a;return e.window?"runtime/browser":(null==(t=e.navigator)?void 0:t.userAgent)?`runtime/${e.navigator.userAgent.toLowerCase()}`:(null==(a=null==(r=e.process)?void 0:r.versions)?void 0:a.node)?`runtime/node.js/${e.process.version.substring(0)}`:e.EdgeRuntime?"runtime/vercel-edge":"runtime/unknown"}function U(e){if(null==e)return{};let t={};if(e instanceof Headers)e.forEach((e,r)=>{t[r.toLowerCase()]=e});else for(let[r,a]of(Array.isArray(e)||(e=Object.entries(e)),e))null!=a&&(t[r.toLowerCase()]=a);return t}function L(e,...t){let r=new Headers(U(e)),a=r.get("user-agent")||"";return r.set("user-agent",[a,...t].filter(Boolean).join(" ")),Object.fromEntries(r.entries())}var V="4.0.19",G=()=>globalThis.fetch,W=async({url:e,headers:t={},successfulResponseHandler:r,failedResponseHandler:a,abortSignal:n,fetch:i=G()})=>{try{let s=await i(e,{method:"GET",headers:L(t,`ai-sdk/provider-utils/${V}`,q()),signal:n}),l=v(s);if(!s.ok){let t;try{t=await a({response:s,url:e,requestBodyValues:{}})}catch(t){if(j(t)||o.w.isInstance(t))throw t;throw new o.w({message:"Failed to process error response",cause:t,statusCode:s.status,url:e,responseHeaders:l,requestBodyValues:{}})}throw t.value}try{return await r({response:s,url:e,requestBodyValues:{}})}catch(t){if(t instanceof Error&&(j(t)||o.w.isInstance(t)))throw t;throw new o.w({message:"Failed to process successful response",cause:t,statusCode:s.status,url:e,responseHeaders:l,requestBodyValues:{}})}}catch(t){throw D({error:t,url:e,requestBodyValues:{}})}};function X(e){return null!=e}function B({mediaType:e,url:t,supportedUrls:r}){return t=t.toLowerCase(),e=e.toLowerCase(),Object.entries(r).map(([e,t])=>{let r=e.toLowerCase();return"*"===r||"*/*"===r?{mediaTypePrefix:"",regexes:t}:{mediaTypePrefix:r.replace(/\*/,""),regexes:t}}).filter(({mediaTypePrefix:t})=>e.startsWith(t)).flatMap(({regexes:e})=>e).some(e=>e.test(t))}function K({apiKey:e,environmentVariableName:t,apiKeyParameterName:r="apiKey",description:a}){if("string"==typeof e)return e;if(null!=e)throw new o.tZ({message:`${a} API key must be a string.`});if("undefined"==typeof process)throw new o.tZ({message:`${a} API key is missing. Pass it using the '${r}' parameter. Environment variables is not supported in this environment.`});if(null==(e=process.env[t]))throw new o.tZ({message:`${a} API key is missing. Pass it using the '${r}' parameter or the ${t} environment variable.`});if("string"!=typeof e)throw new o.tZ({message:`${a} API key must be a string. The value of the ${t} environment variable is not a string.`});return e}function J({settingValue:e,environmentVariableName:t}){if("string"==typeof e||null==e&&"undefined"!=typeof process&&null!=(e=process.env[t])&&"string"==typeof e)return e}var H=/"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/,Y=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;function Q(e){let t=JSON.parse(e);return null===t||"object"!=typeof t||!1===H.test(e)&&!1===Y.test(e)?t:function(e){let t=[e];for(;t.length;){let e=t;for(let r of(t=[],e)){if(Object.prototype.hasOwnProperty.call(r,"__proto__")||Object.prototype.hasOwnProperty.call(r,"constructor")&&null!==r.constructor&&"object"==typeof r.constructor&&Object.prototype.hasOwnProperty.call(r.constructor,"prototype"))throw SyntaxError("Object contains forbidden prototype property");for(let e in r){let a=r[e];a&&"object"==typeof a&&t.push(a)}}}return e}(t)}function ee(e){let{stackTraceLimit:t}=Error;try{Error.stackTraceLimit=0}catch(t){return Q(e)}try{return Q(e)}finally{Error.stackTraceLimit=t}}function et(e){if("object"===e.type||Array.isArray(e.type)&&e.type.includes("object")){e.additionalProperties=!1;let{properties:t}=e;if(null!=t)for(let e of Object.keys(t))t[e]=er(t[e])}null!=e.items&&(e.items=Array.isArray(e.items)?e.items.map(er):er(e.items)),null!=e.anyOf&&(e.anyOf=e.anyOf.map(er)),null!=e.allOf&&(e.allOf=e.allOf.map(er)),null!=e.oneOf&&(e.oneOf=e.oneOf.map(er));let{definitions:t}=e;if(null!=t)for(let e of Object.keys(t))t[e]=er(t[e]);return e}function er(e){return"boolean"==typeof e?e:et(e)}var ea=Symbol("Let zodToJsonSchema decide on which parser to use"),en={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:"definitions",strictUnions:!1,definitions:{},errorMessages:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref"},eo=e=>"string"==typeof e?{...en,name:e}:{...en,...e};function ei(e,t){return eR(e.type._def,t)}var es=(e,t)=>eR(e.innerType._def,t),el=e=>{let t={type:"integer",format:"unix-time"};for(let r of e.checks)switch(r.kind){case"min":t.minimum=r.value;break;case"max":t.maximum=r.value}return t},eu=e=>(!("type"in e)||"string"!==e.type)&&"allOf"in e,ed=void 0,ec={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>(void 0===ed&&(ed=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),ed),ipv4Cidr:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,ipv6Cidr:/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};function ep(e,t){let r={type:"string"};if(e.checks)for(let a of e.checks)switch(a.kind){case"min":r.minLength="number"==typeof r.minLength?Math.max(r.minLength,a.value):a.value;break;case"max":r.maxLength="number"==typeof r.maxLength?Math.min(r.maxLength,a.value):a.value;break;case"email":switch(t.emailStrategy){case"format:email":ef(r,"email",a.message,t);break;case"format:idn-email":ef(r,"idn-email",a.message,t);break;case"pattern:zod":ey(r,ec.email,a.message,t)}break;case"url":ef(r,"uri",a.message,t);break;case"uuid":ef(r,"uuid",a.message,t);break;case"regex":ey(r,a.regex,a.message,t);break;case"cuid":ey(r,ec.cuid,a.message,t);break;case"cuid2":ey(r,ec.cuid2,a.message,t);break;case"startsWith":ey(r,RegExp(`^${eh(a.value,t)}`),a.message,t);break;case"endsWith":ey(r,RegExp(`${eh(a.value,t)}$`),a.message,t);break;case"datetime":ef(r,"date-time",a.message,t);break;case"date":ef(r,"date",a.message,t);break;case"time":ef(r,"time",a.message,t);break;case"duration":ef(r,"duration",a.message,t);break;case"length":r.minLength="number"==typeof r.minLength?Math.max(r.minLength,a.value):a.value,r.maxLength="number"==typeof r.maxLength?Math.min(r.maxLength,a.value):a.value;break;case"includes":ey(r,RegExp(eh(a.value,t)),a.message,t);break;case"ip":"v6"!==a.version&&ef(r,"ipv4",a.message,t),"v4"!==a.version&&ef(r,"ipv6",a.message,t);break;case"base64url":ey(r,ec.base64url,a.message,t);break;case"jwt":ey(r,ec.jwt,a.message,t);break;case"cidr":"v6"!==a.version&&ey(r,ec.ipv4Cidr,a.message,t),"v4"!==a.version&&ey(r,ec.ipv6Cidr,a.message,t);break;case"emoji":ey(r,ec.emoji(),a.message,t);break;case"ulid":ey(r,ec.ulid,a.message,t);break;case"base64":switch(t.base64Strategy){case"format:binary":ef(r,"binary",a.message,t);break;case"contentEncoding:base64":r.contentEncoding="base64";break;case"pattern:zod":ey(r,ec.base64,a.message,t)}break;case"nanoid":ey(r,ec.nanoid,a.message,t)}return r}function eh(e,t){return"escape"===t.patternStrategy?function(e){let t="";for(let r=0;r<e.length;r++)em.has(e[r])||(t+="\\"),t+=e[r];return t}(e):e}var em=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function ef(e,t,r,a){var n;e.format||(null==(n=e.anyOf)?void 0:n.some(e=>e.format))?(e.anyOf||(e.anyOf=[]),e.format&&(e.anyOf.push({format:e.format}),delete e.format),e.anyOf.push({format:t,...r&&a.errorMessages&&{errorMessage:{format:r}}})):e.format=t}function ey(e,t,r,a){var n;e.pattern||(null==(n=e.allOf)?void 0:n.some(e=>e.pattern))?(e.allOf||(e.allOf=[]),e.pattern&&(e.allOf.push({pattern:e.pattern}),delete e.pattern),e.allOf.push({pattern:e_(t,a),...r&&a.errorMessages&&{errorMessage:{pattern:r}}})):e.pattern=e_(t,a)}function e_(e,t){var r;if(!t.applyRegexFlags||!e.flags)return e.source;let a={i:e.flags.includes("i"),m:e.flags.includes("m"),s:e.flags.includes("s")},n=a.i?e.source.toLowerCase():e.source,o="",i=!1,s=!1,l=!1;for(let e=0;e<n.length;e++){if(i){o+=n[e],i=!1;continue}if(a.i){if(s){if(n[e].match(/[a-z]/)){l?(o+=n[e]+`${n[e-2]}-${n[e]}`.toUpperCase(),l=!1):"-"===n[e+1]&&(null==(r=n[e+2])?void 0:r.match(/[a-z]/))?(o+=n[e],l=!0):o+=`${n[e]}${n[e].toUpperCase()}`;continue}}else if(n[e].match(/[a-z]/)){o+=`[${n[e]}${n[e].toUpperCase()}]`;continue}}if(a.m){if("^"===n[e]){o+=`(^|(?<=[\r
|
|
9
|
-
]))`;continue}if("$"===n[e]){o+=`($|(?=[\r
|
|
10
|
-
]))`;continue}}if(a.s&&"."===n[e]){o+=s?`${n[e]}\r
|
|
11
|
-
`:`[${n[e]}\r
|
|
12
|
-
]`;continue}o+=n[e],"\\"===n[e]?i=!0:s&&"]"===n[e]?s=!1:s||"["!==n[e]||(s=!0)}try{new RegExp(o)}catch(r){return console.warn(`Could not convert regex pattern at ${t.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),e.source}return o}function eg(e,t){var r,a,n,o,i,s;let l={type:"object",additionalProperties:null!=(r=eR(e.valueType._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]}))?r:t.allowedAdditionalProperties};if((null==(a=e.keyType)?void 0:a._def.typeName)===d.pA.ZodString&&(null==(n=e.keyType._def.checks)?void 0:n.length)){let{type:r,...a}=ep(e.keyType._def,t);return{...l,propertyNames:a}}if((null==(o=e.keyType)?void 0:o._def.typeName)===d.pA.ZodEnum)return{...l,propertyNames:{enum:e.keyType._def.values}};if((null==(i=e.keyType)?void 0:i._def.typeName)===d.pA.ZodBranded&&e.keyType._def.type._def.typeName===d.pA.ZodString&&(null==(s=e.keyType._def.type._def.checks)?void 0:s.length)){let{type:r,...a}=ei(e.keyType._def,t);return{...l,propertyNames:a}}return l}var ev={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"},eb=(e,t)=>{let r=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((e,r)=>eR(e._def,{...t,currentPath:[...t.currentPath,"anyOf",`${r}`]})).filter(e=>!!e&&(!t.strictUnions||"object"==typeof e&&Object.keys(e).length>0));return r.length?{anyOf:r}:void 0},ew=(e,t)=>{var r;if(t.currentPath.toString()===(null==(r=t.propertyPath)?void 0:r.toString()))return eR(e.innerType._def,t);let a=eR(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","1"]});return a?{anyOf:[{not:{}},a]}:{}},ex=(e,t)=>{if("input"===t.pipeStrategy)return eR(e.in._def,t);if("output"===t.pipeStrategy)return eR(e.out._def,t);let r=eR(e.in._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),a=eR(e.out._def,{...t,currentPath:[...t.currentPath,"allOf",r?"1":"0"]});return{allOf:[r,a].filter(e=>void 0!==e)}},ek=(e,t)=>eR(e.innerType._def,t),eI=(e,t,r)=>{switch(t){case d.pA.ZodString:return ep(e,r);case d.pA.ZodNumber:return function(e){let t={type:"number"};if(!e.checks)return t;for(let r of e.checks)switch(r.kind){case"int":t.type="integer";break;case"min":r.inclusive?t.minimum=r.value:t.exclusiveMinimum=r.value;break;case"max":r.inclusive?t.maximum=r.value:t.exclusiveMaximum=r.value;break;case"multipleOf":t.multipleOf=r.value}return t}(e);case d.pA.ZodObject:return function(e,t){let r={type:"object",properties:{}},a=[],n=e.shape();for(let e in n){let o=n[e];if(void 0===o||void 0===o._def)continue;let i=function(e){try{return e.isOptional()}catch(e){return!0}}(o),s=eR(o._def,{...t,currentPath:[...t.currentPath,"properties",e],propertyPath:[...t.currentPath,"properties",e]});void 0!==s&&(r.properties[e]=s,i||a.push(e))}a.length&&(r.required=a);let o=function(e,t){if("ZodNever"!==e.catchall._def.typeName)return eR(e.catchall._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]});switch(e.unknownKeys){case"passthrough":return t.allowedAdditionalProperties;case"strict":return t.rejectedAdditionalProperties;case"strip":return"strict"===t.removeAdditionalStrategy?t.allowedAdditionalProperties:t.rejectedAdditionalProperties}}(e,t);return void 0!==o&&(r.additionalProperties=o),r}(e,r);case d.pA.ZodBigInt:return function(e){let t={type:"integer",format:"int64"};if(!e.checks)return t;for(let r of e.checks)switch(r.kind){case"min":r.inclusive?t.minimum=r.value:t.exclusiveMinimum=r.value;break;case"max":r.inclusive?t.maximum=r.value:t.exclusiveMaximum=r.value;break;case"multipleOf":t.multipleOf=r.value}return t}(e);case d.pA.ZodBoolean:return{type:"boolean"};case d.pA.ZodDate:return function e(t,r,a){let n=null!=a?a:r.dateStrategy;if(Array.isArray(n))return{anyOf:n.map((a,n)=>e(t,r,a))};switch(n){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return el(t)}}(e,r);case d.pA.ZodUndefined:return{not:{}};case d.pA.ZodNull:return{type:"null"};case d.pA.ZodArray:return function(e,t){var r,a,n;let o={type:"array"};return(null==(r=e.type)?void 0:r._def)&&(null==(n=null==(a=e.type)?void 0:a._def)?void 0:n.typeName)!==d.pA.ZodAny&&(o.items=eR(e.type._def,{...t,currentPath:[...t.currentPath,"items"]})),e.minLength&&(o.minItems=e.minLength.value),e.maxLength&&(o.maxItems=e.maxLength.value),e.exactLength&&(o.minItems=e.exactLength.value,o.maxItems=e.exactLength.value),o}(e,r);case d.pA.ZodUnion:case d.pA.ZodDiscriminatedUnion:return function(e,t){let r=e.options instanceof Map?Array.from(e.options.values()):e.options;if(r.every(e=>e._def.typeName in ev&&(!e._def.checks||!e._def.checks.length))){let e=r.reduce((e,t)=>{let r=ev[t._def.typeName];return r&&!e.includes(r)?[...e,r]:e},[]);return{type:e.length>1?e:e[0]}}if(r.every(e=>"ZodLiteral"===e._def.typeName&&!e.description)){let e=r.reduce((e,t)=>{let r=typeof t._def.value;switch(r){case"string":case"number":case"boolean":return[...e,r];case"bigint":return[...e,"integer"];case"object":if(null===t._def.value)return[...e,"null"];default:return e}},[]);if(e.length===r.length){let t=e.filter((e,t,r)=>r.indexOf(e)===t);return{type:t.length>1?t:t[0],enum:r.reduce((e,t)=>e.includes(t._def.value)?e:[...e,t._def.value],[])}}}else if(r.every(e=>"ZodEnum"===e._def.typeName))return{type:"string",enum:r.reduce((e,t)=>[...e,...t._def.values.filter(t=>!e.includes(t))],[])};return eb(e,t)}(e,r);case d.pA.ZodIntersection:return function(e,t){let r=[eR(e.left._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),eR(e.right._def,{...t,currentPath:[...t.currentPath,"allOf","1"]})].filter(e=>!!e),a=[];return r.forEach(e=>{if(eu(e))a.push(...e.allOf);else{let t=e;if("additionalProperties"in e&&!1===e.additionalProperties){let{additionalProperties:r,...a}=e;t=a}a.push(t)}}),a.length?{allOf:a}:void 0}(e,r);case d.pA.ZodTuple:return function(e,t){return e.rest?{type:"array",minItems:e.items.length,items:e.items.map((e,r)=>eR(e._def,{...t,currentPath:[...t.currentPath,"items",`${r}`]})).reduce((e,t)=>void 0===t?e:[...e,t],[]),additionalItems:eR(e.rest._def,{...t,currentPath:[...t.currentPath,"additionalItems"]})}:{type:"array",minItems:e.items.length,maxItems:e.items.length,items:e.items.map((e,r)=>eR(e._def,{...t,currentPath:[...t.currentPath,"items",`${r}`]})).reduce((e,t)=>void 0===t?e:[...e,t],[])}}(e,r);case d.pA.ZodRecord:return eg(e,r);case d.pA.ZodLiteral:return function(e){let t=typeof e.value;return"bigint"!==t&&"number"!==t&&"boolean"!==t&&"string"!==t?{type:Array.isArray(e.value)?"array":"object"}:{type:"bigint"===t?"integer":t,const:e.value}}(e);case d.pA.ZodEnum:return{type:"string",enum:Array.from(e.values)};case d.pA.ZodNativeEnum:return function(e){let t=e.values,r=Object.keys(e.values).filter(e=>"number"!=typeof t[t[e]]).map(e=>t[e]),a=Array.from(new Set(r.map(e=>typeof e)));return{type:1===a.length?"string"===a[0]?"string":"number":["string","number"],enum:r}}(e);case d.pA.ZodNullable:return function(e,t){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return{type:[ev[e.innerType._def.typeName],"null"]};let r=eR(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","0"]});return r&&{anyOf:[r,{type:"null"}]}}(e,r);case d.pA.ZodOptional:return ew(e,r);case d.pA.ZodMap:return function(e,t){return"record"===t.mapStrategy?eg(e,t):{type:"array",maxItems:125,items:{type:"array",items:[eR(e.keyType._def,{...t,currentPath:[...t.currentPath,"items","items","0"]})||{},eR(e.valueType._def,{...t,currentPath:[...t.currentPath,"items","items","1"]})||{}],minItems:2,maxItems:2}}}(e,r);case d.pA.ZodSet:return function(e,t){let r={type:"array",uniqueItems:!0,items:eR(e.valueType._def,{...t,currentPath:[...t.currentPath,"items"]})};return e.minSize&&(r.minItems=e.minSize.value),e.maxSize&&(r.maxItems=e.maxSize.value),r}(e,r);case d.pA.ZodLazy:return()=>e.getter()._def;case d.pA.ZodPromise:return eR(e.type._def,r);case d.pA.ZodNaN:case d.pA.ZodNever:return{not:{}};case d.pA.ZodEffects:return function(e,t){return"input"===t.effectStrategy?eR(e.schema._def,t):{}}(e,r);case d.pA.ZodAny:case d.pA.ZodUnknown:return{};case d.pA.ZodDefault:return function(e,t){return{...eR(e.innerType._def,t),default:e.defaultValue()}}(e,r);case d.pA.ZodBranded:return ei(e,r);case d.pA.ZodReadonly:return ek(e,r);case d.pA.ZodCatch:return es(e,r);case d.pA.ZodPipeline:return ex(e,r);case d.pA.ZodFunction:case d.pA.ZodVoid:case d.pA.ZodSymbol:default:return}},eT=(e,t)=>{let r=0;for(;r<e.length&&r<t.length&&e[r]===t[r];r++);return[(e.length-r).toString(),...t.slice(r)].join("/")};function eR(e,t,r=!1){var a;let n=t.seen.get(e);if(t.override){let o=null==(a=t.override)?void 0:a.call(t,e,t,n,r);if(o!==ea)return o}if(n&&!r){let e=eS(n,t);if(void 0!==e)return e}let o={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,o);let i=eI(e,e.typeName,t),s="function"==typeof i?eR(i(),t):i;if(s&&eZ(e,t,s),t.postProcess){let r=t.postProcess(s,e,t);return o.jsonSchema=s,r}return o.jsonSchema=s,s}var eS=(e,t)=>{switch(t.$refStrategy){case"root":return{$ref:e.path.join("/")};case"relative":return{$ref:eT(t.currentPath,e.path)};case"none":case"seen":if(e.path.length<t.currentPath.length&&e.path.every((e,r)=>t.currentPath[r]===e))return console.warn(`Recursive reference detected at ${t.currentPath.join("/")}! Defaulting to any`),{};return"seen"===t.$refStrategy?{}:void 0}},eZ=(e,t,r)=>(e.description&&(r.description=e.description),r),eC=e=>{let t=eo(e),r=void 0!==t.name?[...t.basePath,t.definitionPath,t.name]:t.basePath;return{...t,currentPath:r,propertyPath:void 0,seen:new Map(Object.entries(t.definitions).map(([e,r])=>[r._def,{def:r._def,path:[...t.basePath,t.definitionPath,e],jsonSchema:void 0}]))}},eE=(e,t)=>{var r;let a=eC(t),n="object"==typeof t&&t.definitions?Object.entries(t.definitions).reduce((e,[t,r])=>{var n;return{...e,[t]:null!=(n=eR(r._def,{...a,currentPath:[...a.basePath,a.definitionPath,t]},!0))?n:{}}},{}):void 0,o="string"==typeof t?t:(null==t?void 0:t.nameStrategy)==="title"?void 0:null==t?void 0:t.name,i=null!=(r=eR(e._def,void 0===o?a:{...a,currentPath:[...a.basePath,a.definitionPath,o]},!1))?r:{},s="object"==typeof t&&void 0!==t.name&&"title"===t.nameStrategy?t.name:void 0;void 0!==s&&(i.title=s);let l=void 0===o?n?{...i,[a.definitionPath]:n}:i:{$ref:[..."relative"===a.$refStrategy?[]:a.basePath,a.definitionPath,o].join("/"),[a.definitionPath]:{...n,[o]:i}};return l.$schema="http://json-schema.org/draft-07/schema#",l},eO=Symbol.for("vercel.ai.schema");function eA(e){let t;return()=>(null==t&&(t=e()),t)}function eN(e,{validate:t}={}){return{[eO]:!0,_type:void 0,get jsonSchema(){return"function"==typeof e&&(e=e()),e},validate:t}}function eM(e){return null==e?eN({properties:{},additionalProperties:!1}):"object"==typeof e&&null!==e&&eO in e&&!0===e[eO]&&"jsonSchema"in e&&"validate"in e?e:"~standard"in e?"zod"===e["~standard"].vendor?e$(e):eN(()=>et(e["~standard"].jsonSchema.input({target:"draft-07"})),{validate:async t=>{let r=await e["~standard"].validate(t);return"value"in r?{success:!0,value:r.value}:{success:!1,error:new o.Gz({value:t,cause:r.issues})}}}):e()}function e$(e,t){return"_zod"in e?function(e,t){var r;let a=null!=(r=null==t?void 0:t.useReferences)&&r;return eN(()=>et(function(e,t){if(e instanceof i.EC){let r=new l(t),a={};for(let t of e._idmap.entries()){let[e,a]=t;r.process(a)}let n={},o={registry:e,uri:t?.uri,defs:a};for(let a of e._idmap.entries()){let[e,i]=a;n[e]=r.emit(i,{...t,external:o})}if(Object.keys(a).length>0){let e="draft-2020-12"===r.target?"$defs":"definitions";n.__shared={[e]:a}}return{schemas:n}}let r=new l(t);return r.process(e),r.emit(e,t)}(e,{target:"draft-7",io:"input",reused:a?"ref":"inline"})),{validate:async t=>{let r=await u.X9(e,t);return r.success?{success:!0,value:r.data}:{success:!1,error:r.error}}})}(e,t):function(e,t){var r;let a=null!=(r=null==t?void 0:t.useReferences)&&r;return eN(()=>eE(e,{$refStrategy:a?"root":"none"}),{validate:async t=>{let r=await e.safeParseAsync(t);return r.success?{success:!0,value:r.data}:{success:!1,error:r.error}}})}(e,t)}async function eP({value:e,schema:t,context:r}){let a=await ej({value:e,schema:t,context:r});if(!a.success)throw o.Gz.wrap({value:e,cause:a.error,context:r});return a.value}async function ej({value:e,schema:t,context:r}){let a=eM(t);try{if(null==a.validate)return{success:!0,value:e,rawValue:e};let t=await a.validate(e);if(t.success)return{success:!0,value:t.value,rawValue:e};return{success:!1,error:o.Gz.wrap({value:e,cause:t.error,context:r}),rawValue:e}}catch(t){return{success:!1,error:o.Gz.wrap({value:e,cause:t,context:r}),rawValue:e}}}async function eF({text:e,schema:t}){try{let r=ee(e);if(null==t)return r;return eP({value:r,schema:t})}catch(t){if(o.xU.isInstance(t)||o.Gz.isInstance(t))throw t;throw new o.xU({text:e,cause:t})}}async function ez({text:e,schema:t}){try{let r=ee(e);if(null==t)return{success:!0,value:r,rawValue:r};return await ej({value:r,schema:t})}catch(t){return{success:!1,error:o.xU.isInstance(t)?t:new o.xU({text:e,cause:t}),rawValue:void 0}}}function eD({stream:e,schema:t}){return e.pipeThrough(new TextDecoderStream).pipeThrough(new h).pipeThrough(new TransformStream({async transform({data:e},r){"[DONE]"!==e&&r.enqueue(await ez({text:e,schema:t}))}}))}async function eq({provider:e,providerOptions:t,schema:r}){if((null==t?void 0:t[e])==null)return;let a=await ej({value:t[e],schema:r});if(!a.success)throw new o.RU({argument:"providerOptions",message:`invalid ${e} provider options`,cause:a.error});return a.value}var eU=()=>globalThis.fetch,eL=async({url:e,headers:t,body:r,failedResponseHandler:a,successfulResponseHandler:n,abortSignal:o,fetch:i})=>eV({url:e,headers:{"Content-Type":"application/json",...t},body:{content:JSON.stringify(r),values:r},failedResponseHandler:a,successfulResponseHandler:n,abortSignal:o,fetch:i}),eV=async({url:e,headers:t={},body:r,successfulResponseHandler:a,failedResponseHandler:n,abortSignal:i,fetch:s=eU()})=>{try{let l=await s(e,{method:"POST",headers:L(t,`ai-sdk/provider-utils/${V}`,q()),body:r.content,signal:i}),u=v(l);if(!l.ok){let t;try{t=await n({response:l,url:e,requestBodyValues:r.values})}catch(t){if(j(t)||o.w.isInstance(t))throw t;throw new o.w({message:"Failed to process error response",cause:t,statusCode:l.status,url:e,responseHeaders:u,requestBodyValues:r.values})}throw t.value}try{return await a({response:l,url:e,requestBodyValues:r.values})}catch(t){if(t instanceof Error&&(j(t)||o.w.isInstance(t)))throw t;throw new o.w({message:"Failed to process successful response",cause:t,statusCode:l.status,url:e,responseHeaders:u,requestBodyValues:r.values})}}catch(t){throw D({error:t,url:e,requestBodyValues:r.values})}};function eG(e){return e}function eW({id:e,inputSchema:t}){return({execute:r,outputSchema:a,needsApproval:n,toModelOutput:o,onInputStart:i,onInputDelta:s,onInputAvailable:l,...u})=>({type:"provider",id:e,args:u,inputSchema:t,outputSchema:a,execute:r,needsApproval:n,toModelOutput:o,onInputStart:i,onInputDelta:s,onInputAvailable:l})}function eX({id:e,inputSchema:t,outputSchema:r,supportsDeferredResults:a}){return({execute:n,needsApproval:o,toModelOutput:i,onInputStart:s,onInputDelta:l,onInputAvailable:u,...d})=>({type:"provider",id:e,args:d,inputSchema:t,outputSchema:r,execute:n,needsApproval:o,toModelOutput:i,onInputStart:s,onInputDelta:l,onInputAvailable:u,supportsDeferredResults:a})}async function eB(e){return"function"==typeof e&&(e=e()),Promise.resolve(e)}var eK=({errorSchema:e,errorToMessage:t,isRetryable:r})=>async({response:a,url:n,requestBodyValues:i})=>{let s=await a.text(),l=v(a);if(""===s.trim())return{responseHeaders:l,value:new o.w({message:a.statusText,url:n,requestBodyValues:i,statusCode:a.status,responseHeaders:l,responseBody:s,isRetryable:null==r?void 0:r(a)})};try{let u=await eF({text:s,schema:e});return{responseHeaders:l,value:new o.w({message:t(u),url:n,requestBodyValues:i,statusCode:a.status,responseHeaders:l,responseBody:s,data:u,isRetryable:null==r?void 0:r(a,u)})}}catch(e){return{responseHeaders:l,value:new o.w({message:a.statusText,url:n,requestBodyValues:i,statusCode:a.status,responseHeaders:l,responseBody:s,isRetryable:null==r?void 0:r(a)})}}},eJ=e=>async({response:t})=>{let r=v(t);if(null==t.body)throw new o.g8({});return{responseHeaders:r,value:eD({stream:t.body,schema:e})}},eH=e=>async({response:t,url:r,requestBodyValues:a})=>{let n=await t.text(),i=await ez({text:n,schema:e}),s=v(t);if(!i.success)throw new o.w({message:"Invalid JSON response",cause:i.error,statusCode:t.status,responseHeaders:s,responseBody:n,url:r,requestBodyValues:a});return{responseHeaders:s,value:i.value,rawValue:i.rawValue}};function eY(e){return null==e?void 0:e.replace(/\/$/,"")}async function*eQ({execute:e,input:t,options:r}){let a=e(t,r);if(null!=a&&"function"==typeof a[Symbol.asyncIterator]){let e;for await(let t of a)e=t,yield{type:"preliminary",output:t};yield{type:"final",output:e}}else yield{type:"final",output:await a}}},9519:(e,t,r)=>{r.d(t,{AX:()=>T,A_:()=>el,Gz:()=>en,JJ:()=>ee,Mt:()=>U,RU:()=>F,e$:()=>M,g8:()=>N,tZ:()=>J,w:()=>C,xU:()=>W});var a,n,o,i,s,l,u,d,c,p,h,m,f,y,_,g,v,b,w,x,k="vercel.ai.error",I=Symbol.for(k),T=class e extends(n=Error,a=I,n){constructor({name:e,message:t,cause:r}){super(t),this[a]=!0,this.name=e,this.cause=r}static isInstance(t){return e.hasMarker(t,k)}static hasMarker(e,t){let r=Symbol.for(t);return null!=e&&"object"==typeof e&&r in e&&"boolean"==typeof e[r]&&!0===e[r]}},R="AI_APICallError",S=`vercel.ai.error.${R}`,Z=Symbol.for(S),C=class extends(i=T,o=Z,i){constructor({message:e,url:t,requestBodyValues:r,statusCode:a,responseHeaders:n,responseBody:i,cause:s,isRetryable:l=null!=a&&(408===a||409===a||429===a||a>=500),data:u}){super({name:R,message:e,cause:s}),this[o]=!0,this.url=t,this.requestBodyValues=r,this.statusCode=a,this.responseHeaders=n,this.responseBody=i,this.isRetryable=l,this.data=u}static isInstance(e){return T.hasMarker(e,S)}},E="AI_EmptyResponseBodyError",O=`vercel.ai.error.${E}`,A=Symbol.for(O),N=class extends(l=T,s=A,l){constructor({message:e="Empty response body"}={}){super({name:E,message:e}),this[s]=!0}static isInstance(e){return T.hasMarker(e,O)}};function M(e){return null==e?"unknown error":"string"==typeof e?e:e instanceof Error?e.message:JSON.stringify(e)}var $="AI_InvalidArgumentError",P=`vercel.ai.error.${$}`,j=Symbol.for(P),F=class extends(d=T,u=j,d){constructor({message:e,cause:t,argument:r}){super({name:$,message:e,cause:t}),this[u]=!0,this.argument=r}static isInstance(e){return T.hasMarker(e,P)}},z="AI_InvalidPromptError",D=`vercel.ai.error.${z}`,q=Symbol.for(D),U=class extends(p=T,c=q,p){constructor({prompt:e,message:t,cause:r}){super({name:z,message:`Invalid prompt: ${t}`,cause:r}),this[c]=!0,this.prompt=e}static isInstance(e){return T.hasMarker(e,D)}},L=(Symbol.for("vercel.ai.error.AI_InvalidResponseDataError"),"AI_JSONParseError"),V=`vercel.ai.error.${L}`,G=Symbol.for(V),W=class extends(m=T,h=G,m){constructor({text:e,cause:t}){super({name:L,message:`JSON parsing failed: Text: ${e}.
|
|
13
|
-
Error message: ${M(t)}`,cause:t}),this[h]=!0,this.text=e}static isInstance(e){return T.hasMarker(e,V)}},X="AI_LoadAPIKeyError",B=`vercel.ai.error.${X}`,K=Symbol.for(B),J=class extends(y=T,f=K,y){constructor({message:e}){super({name:X,message:e}),this[f]=!0}static isInstance(e){return T.hasMarker(e,B)}},H=(Symbol.for("vercel.ai.error.AI_LoadSettingError"),Symbol.for("vercel.ai.error.AI_NoContentGeneratedError"),"AI_NoSuchModelError"),Y=`vercel.ai.error.${H}`,Q=Symbol.for(Y),ee=class extends(g=T,_=Q,g){constructor({errorName:e=H,modelId:t,modelType:r,message:a=`No such ${r}: ${t}`}){super({name:e,message:a}),this[_]=!0,this.modelId=t,this.modelType=r}static isInstance(e){return T.hasMarker(e,Y)}},et=(Symbol.for("vercel.ai.error.AI_TooManyEmbeddingValuesForCallError"),"AI_TypeValidationError"),er=`vercel.ai.error.${et}`,ea=Symbol.for(er),en=class e extends(b=T,v=ea,b){constructor({value:e,cause:t,context:r}){let a="Type validation failed";if((null==r?void 0:r.field)&&(a+=` for ${r.field}`),(null==r?void 0:r.entityName)||(null==r?void 0:r.entityId)){a+=" (";let e=[];r.entityName&&e.push(r.entityName),r.entityId&&e.push(`id: "${r.entityId}"`),a+=e.join(", ")+")"}super({name:et,message:`${a}: Value: ${JSON.stringify(e)}.
|
|
14
|
-
Error message: ${M(t)}`,cause:t}),this[v]=!0,this.value=e,this.context=r}static isInstance(e){return T.hasMarker(e,er)}static wrap({value:t,cause:r,context:a}){var n,o,i;return e.isInstance(r)&&r.value===t&&(null==(n=r.context)?void 0:n.field)===(null==a?void 0:a.field)&&(null==(o=r.context)?void 0:o.entityName)===(null==a?void 0:a.entityName)&&(null==(i=r.context)?void 0:i.entityId)===(null==a?void 0:a.entityId)?r:new e({value:t,cause:r,context:a})}},eo="AI_UnsupportedFunctionalityError",ei=`vercel.ai.error.${eo}`,es=Symbol.for(ei),el=class extends(x=T,w=es,x){constructor({functionality:e,message:t=`'${e}' functionality not supported.`}){super({name:eo,message:t}),this[w]=!0,this.functionality=e}static isInstance(e){return T.hasMarker(e,ei)}};function eu(e){return null===e||"string"==typeof e||"number"==typeof e||"boolean"==typeof e||(Array.isArray(e)?e.every(eu):"object"==typeof e&&Object.entries(e).every(([e,t])=>"string"==typeof e&&(void 0===t||eu(t))))}},1379:(e,t,r)=>{var a,n,o,i,s,l,u,d,c,p,h,m,f,y,_,g,v,b,w,x,k,I,T,R,S,Z,C,E,O,A,N,M,$,P,j,F,z,D,q,U,L,V,G,W,X,B,K,J,H,Y,Q,ee,et,er,ea,en,eo,ei,es,el,eu,ed,ec,ep,eh,em,ef,ey;let e_,eg,ev;function eb(e,t,r,a,n){if("m"===a)throw TypeError("Private method is not writable");if("a"===a&&!n)throw TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw TypeError("Cannot write private member to an object whose class did not declare it");return"a"===a?n.call(e,r):n?n.value=r:t.set(e,r),r}function ew(e,t,r,a){if("a"===r&&!a)throw TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!a:!t.has(e))throw TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?a:"a"===r?a.call(e):a?a.value:t.get(e)}r.d(t,{ZP:()=>rv});let ex=function(){let{crypto:e}=globalThis;if(e?.randomUUID)return ex=e.randomUUID.bind(e),e.randomUUID();let t=new Uint8Array(1),r=e?()=>e.getRandomValues(t)[0]:()=>255*Math.random()&255;return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,e=>(+e^r()&15>>+e/4).toString(16))};function ek(e){return"object"==typeof e&&null!==e&&("name"in e&&"AbortError"===e.name||"message"in e&&String(e.message).includes("FetchRequestCanceledException"))}let eI=e=>{if(e instanceof Error)return e;if("object"==typeof e&&null!==e){try{if("[object Error]"===Object.prototype.toString.call(e)){let t=Error(e.message,e.cause?{cause:e.cause}:{});return e.stack&&(t.stack=e.stack),e.cause&&!t.cause&&(t.cause=e.cause),e.name&&(t.name=e.name),t}}catch{}try{return Error(JSON.stringify(e))}catch{}}return Error(e)};class eT extends Error{}class eR extends eT{constructor(e,t,r,a){super(`${eR.makeMessage(e,t,r)}`),this.status=e,this.headers=a,this.requestID=a?.get("request-id"),this.error=t}static makeMessage(e,t,r){let a=t?.message?"string"==typeof t.message?t.message:JSON.stringify(t.message):t?JSON.stringify(t):r;return e&&a?`${e} ${a}`:e?`${e} status code (no body)`:a||"(no status code or body)"}static generate(e,t,r,a){return e&&a?400===e?new eE(e,t,r,a):401===e?new eO(e,t,r,a):403===e?new eA(e,t,r,a):404===e?new eN(e,t,r,a):409===e?new eM(e,t,r,a):422===e?new e$(e,t,r,a):429===e?new eP(e,t,r,a):e>=500?new ej(e,t,r,a):new eR(e,t,r,a):new eZ({message:r,cause:eI(t)})}}class eS extends eR{constructor({message:e}={}){super(void 0,void 0,e||"Request was aborted.",void 0)}}class eZ extends eR{constructor({message:e,cause:t}){super(void 0,void 0,e||"Connection error.",void 0),t&&(this.cause=t)}}class eC extends eZ{constructor({message:e}={}){super({message:e??"Request timed out."})}}class eE extends eR{}class eO extends eR{}class eA extends eR{}class eN extends eR{}class eM extends eR{}class e$ extends eR{}class eP extends eR{}class ej extends eR{}let eF=/^[a-z][a-z0-9+.-]*:/i,ez=e=>eF.test(e),eD=e=>(eD=Array.isArray)(e),eq=eD;function eU(e){return"object"!=typeof e?{}:e??{}}let eL=(e,t)=>{if("number"!=typeof t||!Number.isInteger(t))throw new eT(`${e} must be an integer`);if(t<0)throw new eT(`${e} must be a positive integer`);return t},eV=e=>{try{return JSON.parse(e)}catch(e){return}},eG=e=>new Promise(t=>setTimeout(t,e)),eW="0.78.0",eX=()=>"undefined"!=typeof window&&void 0!==window.document&&"undefined"!=typeof navigator,eB=()=>{let e="undefined"!=typeof Deno&&null!=Deno.build?"deno":"undefined"!=typeof EdgeRuntime?"edge":"[object process]"===Object.prototype.toString.call(void 0!==globalThis.process?globalThis.process:0)?"node":"unknown";if("deno"===e)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":eW,"X-Stainless-OS":eJ(Deno.build.os),"X-Stainless-Arch":eK(Deno.build.arch),"X-Stainless-Runtime":"deno","X-Stainless-Runtime-Version":"string"==typeof Deno.version?Deno.version:Deno.version?.deno??"unknown"};if("undefined"!=typeof EdgeRuntime)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":eW,"X-Stainless-OS":"Unknown","X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":"edge","X-Stainless-Runtime-Version":globalThis.process.version};if("node"===e)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":eW,"X-Stainless-OS":eJ(globalThis.process.platform??"unknown"),"X-Stainless-Arch":eK(globalThis.process.arch??"unknown"),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":globalThis.process.version??"unknown"};let t=function(){if("undefined"==typeof navigator||!navigator)return null;for(let{key:e,pattern:t}of[{key:"edge",pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"chrome",pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"firefox",pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"safari",pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}]){let r=t.exec(navigator.userAgent);if(r){let t=r[1]||0,a=r[2]||0,n=r[3]||0;return{browser:e,version:`${t}.${a}.${n}`}}}return null}();return t?{"X-Stainless-Lang":"js","X-Stainless-Package-Version":eW,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":`browser:${t.browser}`,"X-Stainless-Runtime-Version":t.version}:{"X-Stainless-Lang":"js","X-Stainless-Package-Version":eW,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}},eK=e=>"x32"===e?"x32":"x86_64"===e||"x64"===e?"x64":"arm"===e?"arm":"aarch64"===e||"arm64"===e?"arm64":e?`other:${e}`:"unknown",eJ=e=>(e=e.toLowerCase()).includes("ios")?"iOS":"android"===e?"Android":"darwin"===e?"MacOS":"win32"===e?"Windows":"freebsd"===e?"FreeBSD":"openbsd"===e?"OpenBSD":"linux"===e?"Linux":e?`Other:${e}`:"Unknown",eH=()=>e_??(e_=eB());function eY(...e){let t=globalThis.ReadableStream;if(void 0===t)throw Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new t(...e)}function eQ(e){let t=Symbol.asyncIterator in e?e[Symbol.asyncIterator]():e[Symbol.iterator]();return eY({start(){},async pull(e){let{done:r,value:a}=await t.next();r?e.close():e.enqueue(a)},async cancel(){await t.return?.()}})}function e0(e){if(e[Symbol.asyncIterator])return e;let t=e.getReader();return{async next(){try{let e=await t.read();return e?.done&&t.releaseLock(),e}catch(e){throw t.releaseLock(),e}},async return(){let e=t.cancel();return t.releaseLock(),await e,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}async function e1(e){if(null===e||"object"!=typeof e)return;if(e[Symbol.asyncIterator]){await e[Symbol.asyncIterator]().return?.();return}let t=e.getReader(),r=t.cancel();t.releaseLock(),await r}let e2=({headers:e,body:t})=>({bodyHeaders:{"content-type":"application/json"},body:JSON.stringify(t)});function e4(e){let t;return(eg??(eg=(t=new globalThis.TextEncoder).encode.bind(t)))(e)}function e9(e){let t;return(ev??(ev=(t=new globalThis.TextDecoder).decode.bind(t)))(e)}class e5{constructor(){a.set(this,void 0),n.set(this,void 0),eb(this,a,new Uint8Array,"f"),eb(this,n,null,"f")}decode(e){let t;if(null==e)return[];let r=e instanceof ArrayBuffer?new Uint8Array(e):"string"==typeof e?e4(e):e;eb(this,a,function(e){let t=0;for(let r of e)t+=r.length;let r=new Uint8Array(t),a=0;for(let t of e)r.set(t,a),a+=t.length;return r}([ew(this,a,"f"),r]),"f");let o=[];for(;null!=(t=function(e,t){for(let r=t??0;r<e.length;r++){if(10===e[r])return{preceding:r,index:r+1,carriage:!1};if(13===e[r])return{preceding:r,index:r+1,carriage:!0}}return null}(ew(this,a,"f"),ew(this,n,"f")));){if(t.carriage&&null==ew(this,n,"f")){eb(this,n,t.index,"f");continue}if(null!=ew(this,n,"f")&&(t.index!==ew(this,n,"f")+1||t.carriage)){o.push(e9(ew(this,a,"f").subarray(0,ew(this,n,"f")-1))),eb(this,a,ew(this,a,"f").subarray(ew(this,n,"f")),"f"),eb(this,n,null,"f");continue}let e=null!==ew(this,n,"f")?t.preceding-1:t.preceding,r=e9(ew(this,a,"f").subarray(0,e));o.push(r),eb(this,a,ew(this,a,"f").subarray(t.index),"f"),eb(this,n,null,"f")}return o}flush(){return ew(this,a,"f").length?this.decode("\n"):[]}}a=new WeakMap,n=new WeakMap,e5.NEWLINE_CHARS=new Set(["\n","\r"]),e5.NEWLINE_REGEXP=/\r\n|[\n\r]/g;let e6={off:0,error:200,warn:300,info:400,debug:500},e3=(e,t,r)=>{if(e){if(Object.prototype.hasOwnProperty.call(e6,e))return e;tr(r).warn(`${t} was set to ${JSON.stringify(e)}, expected one of ${JSON.stringify(Object.keys(e6))}`)}};function e7(){}function e8(e,t,r){return!t||e6[e]>e6[r]?e7:t[e].bind(t)}let te={error:e7,warn:e7,info:e7,debug:e7},tt=new WeakMap;function tr(e){let t=e.logger,r=e.logLevel??"off";if(!t)return te;let a=tt.get(t);if(a&&a[0]===r)return a[1];let n={error:e8("error",t,r),warn:e8("warn",t,r),info:e8("info",t,r),debug:e8("debug",t,r)};return tt.set(t,[r,n]),n}let ta=e=>(e.options&&(e.options={...e.options},delete e.options.headers),e.headers&&(e.headers=Object.fromEntries((e.headers instanceof Headers?[...e.headers]:Object.entries(e.headers)).map(([e,t])=>[e,"x-api-key"===e.toLowerCase()||"authorization"===e.toLowerCase()||"cookie"===e.toLowerCase()||"set-cookie"===e.toLowerCase()?"***":t]))),"retryOfRequestLogID"in e&&(e.retryOfRequestLogID&&(e.retryOf=e.retryOfRequestLogID),delete e.retryOfRequestLogID),e);class tn{constructor(e,t,r){this.iterator=e,o.set(this,void 0),this.controller=t,eb(this,o,r,"f")}static fromSSEResponse(e,t,r){let a=!1,n=r?tr(r):console;return new tn(async function*(){if(a)throw new eT("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");a=!0;let r=!1;try{for await(let r of to(e,t)){if("completion"===r.event)try{yield JSON.parse(r.data)}catch(e){throw n.error("Could not parse message into JSON:",r.data),n.error("From chunk:",r.raw),e}if("message_start"===r.event||"message_delta"===r.event||"message_stop"===r.event||"content_block_start"===r.event||"content_block_delta"===r.event||"content_block_stop"===r.event)try{yield JSON.parse(r.data)}catch(e){throw n.error("Could not parse message into JSON:",r.data),n.error("From chunk:",r.raw),e}if("ping"!==r.event&&"error"===r.event)throw new eR(void 0,eV(r.data)??r.data,void 0,e.headers)}r=!0}catch(e){if(ek(e))return;throw e}finally{r||t.abort()}},t,r)}static fromReadableStream(e,t,r){let a=!1;async function*n(){let t=new e5;for await(let r of e0(e))for(let e of t.decode(r))yield e;for(let e of t.flush())yield e}return new tn(async function*(){if(a)throw new eT("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");a=!0;let e=!1;try{for await(let t of n())!e&&t&&(yield JSON.parse(t));e=!0}catch(e){if(ek(e))return;throw e}finally{e||t.abort()}},t,r)}[(o=new WeakMap,Symbol.asyncIterator)](){return this.iterator()}tee(){let e=[],t=[],r=this.iterator(),a=a=>({next:()=>{if(0===a.length){let a=r.next();e.push(a),t.push(a)}return a.shift()}});return[new tn(()=>a(e),this.controller,ew(this,o,"f")),new tn(()=>a(t),this.controller,ew(this,o,"f"))]}toReadableStream(){let e;let t=this;return eY({async start(){e=t[Symbol.asyncIterator]()},async pull(t){try{let{value:r,done:a}=await e.next();if(a)return t.close();let n=e4(JSON.stringify(r)+"\n");t.enqueue(n)}catch(e){t.error(e)}},async cancel(){await e.return?.()}})}}async function*to(e,t){if(!e.body){if(t.abort(),void 0!==globalThis.navigator&&"ReactNative"===globalThis.navigator.product)throw new eT("The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api");throw new eT("Attempted to iterate over a response with no body")}let r=new ts,a=new e5;for await(let t of ti(e0(e.body)))for(let e of a.decode(t)){let t=r.decode(e);t&&(yield t)}for(let e of a.flush()){let t=r.decode(e);t&&(yield t)}}async function*ti(e){let t=new Uint8Array;for await(let r of e){let e;if(null==r)continue;let a=r instanceof ArrayBuffer?new Uint8Array(r):"string"==typeof r?e4(r):r,n=new Uint8Array(t.length+a.length);for(n.set(t),n.set(a,t.length),t=n;-1!==(e=function(e){for(let t=0;t<e.length-1;t++){if(10===e[t]&&10===e[t+1]||13===e[t]&&13===e[t+1])return t+2;if(13===e[t]&&10===e[t+1]&&t+3<e.length&&13===e[t+2]&&10===e[t+3])return t+4}return -1}(t));)yield t.slice(0,e),t=t.slice(e)}t.length>0&&(yield t)}class ts{constructor(){this.event=null,this.data=[],this.chunks=[]}decode(e){if(e.endsWith("\r")&&(e=e.substring(0,e.length-1)),!e){if(!this.event&&!this.data.length)return null;let e={event:this.event,data:this.data.join("\n"),raw:this.chunks};return this.event=null,this.data=[],this.chunks=[],e}if(this.chunks.push(e),e.startsWith(":"))return null;let[t,r,a]=function(e,t){let r=e.indexOf(":");return -1!==r?[e.substring(0,r),":",e.substring(r+t.length)]:[e,"",""]}(e,":");return a.startsWith(" ")&&(a=a.substring(1)),"event"===t?this.event=a:"data"===t&&this.data.push(a),null}}async function tl(e,t){let{response:r,requestLogID:a,retryOfRequestLogID:n,startTime:o}=t,i=await (async()=>{if(t.options.stream)return(tr(e).debug("response",r.status,r.url,r.headers,r.body),t.options.__streamClass)?t.options.__streamClass.fromSSEResponse(r,t.controller):tn.fromSSEResponse(r,t.controller);if(204===r.status)return null;if(t.options.__binaryResponse)return r;let a=r.headers.get("content-type"),n=a?.split(";")[0]?.trim();if(n?.includes("application/json")||n?.endsWith("+json")){if("0"===r.headers.get("content-length"))return;return tu(await r.json(),r)}return await r.text()})();return tr(e).debug(`[${a}] response parsed`,ta({retryOfRequestLogID:n,url:r.url,status:r.status,body:i,durationMs:Date.now()-o})),i}function tu(e,t){return!e||"object"!=typeof e||Array.isArray(e)?e:Object.defineProperty(e,"_request_id",{value:t.headers.get("request-id"),enumerable:!1})}class td extends Promise{constructor(e,t,r=tl){super(e=>{e(null)}),this.responsePromise=t,this.parseResponse=r,i.set(this,void 0),eb(this,i,e,"f")}_thenUnwrap(e){return new td(ew(this,i,"f"),this.responsePromise,async(t,r)=>tu(e(await this.parseResponse(t,r),r),r.response))}asResponse(){return this.responsePromise.then(e=>e.response)}async withResponse(){let[e,t]=await Promise.all([this.parse(),this.asResponse()]);return{data:e,response:t,request_id:t.headers.get("request-id")}}parse(){return this.parsedPromise||(this.parsedPromise=this.responsePromise.then(e=>this.parseResponse(ew(this,i,"f"),e))),this.parsedPromise}then(e,t){return this.parse().then(e,t)}catch(e){return this.parse().catch(e)}finally(e){return this.parse().finally(e)}}i=new WeakMap;class tc{constructor(e,t,r,a){s.set(this,void 0),eb(this,s,e,"f"),this.options=a,this.response=t,this.body=r}hasNextPage(){return!!this.getPaginatedItems().length&&null!=this.nextPageRequestOptions()}async getNextPage(){let e=this.nextPageRequestOptions();if(!e)throw new eT("No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.");return await ew(this,s,"f").requestAPIList(this.constructor,e)}async *iterPages(){let e=this;for(yield e;e.hasNextPage();)e=await e.getNextPage(),yield e}async *[(s=new WeakMap,Symbol.asyncIterator)](){for await(let e of this.iterPages())for(let t of e.getPaginatedItems())yield t}}class tp extends td{constructor(e,t,r){super(e,t,async(e,t)=>new r(e,t.response,await tl(e,t),t.options))}async *[Symbol.asyncIterator](){for await(let e of(await this))yield e}}class th extends tc{constructor(e,t,r,a){super(e,t,r,a),this.data=r.data||[],this.has_more=r.has_more||!1,this.first_id=r.first_id||null,this.last_id=r.last_id||null}getPaginatedItems(){return this.data??[]}hasNextPage(){return!1!==this.has_more&&super.hasNextPage()}nextPageRequestOptions(){if(this.options.query?.before_id){let e=this.first_id;return e?{...this.options,query:{...eU(this.options.query),before_id:e}}:null}let e=this.last_id;return e?{...this.options,query:{...eU(this.options.query),after_id:e}}:null}}class tm extends tc{constructor(e,t,r,a){super(e,t,r,a),this.data=r.data||[],this.has_more=r.has_more||!1,this.next_page=r.next_page||null}getPaginatedItems(){return this.data??[]}hasNextPage(){return!1!==this.has_more&&super.hasNextPage()}nextPageRequestOptions(){let e=this.next_page;return e?{...this.options,query:{...eU(this.options.query),page:e}}:null}}let tf=()=>{if("undefined"==typeof File){let{process:e}=globalThis;throw Error("`File` is not defined as a global, which is required for file uploads."+("string"==typeof e?.versions?.node&&20>parseInt(e.versions.node.split("."))?" Update to Node 20 LTS or newer, or set `globalThis.File` to `import('node:buffer').File`.":""))}};function ty(e,t,r){return tf(),new File(e,t??"unknown_file",r)}function t_(e,t){let r="object"==typeof e&&null!==e&&("name"in e&&e.name&&String(e.name)||"url"in e&&e.url&&String(e.url)||"filename"in e&&e.filename&&String(e.filename)||"path"in e&&e.path&&String(e.path))||"";return t?r.split(/[\\/]/).pop()||void 0:r}let tg=e=>null!=e&&"object"==typeof e&&"function"==typeof e[Symbol.asyncIterator],tv=async(e,t,r=!0)=>({...e,body:await tw(e.body,t,r)}),tb=new WeakMap,tw=async(e,t,r=!0)=>{if(!await function(e){let t="function"==typeof e?e:e.fetch,r=tb.get(t);if(r)return r;let a=(async()=>{try{let e="Response"in t?t.Response:(await t("data:,")).constructor,r=new FormData;if(r.toString()===await new e(r).text())return!1;return!0}catch{return!0}})();return tb.set(t,a),a}(t))throw TypeError("The provided fetch function does not support file uploads with the current global FormData class.");let a=new FormData;return await Promise.all(Object.entries(e||{}).map(([e,t])=>tT(a,e,t,r))),a},tx=e=>e instanceof Blob&&"name"in e,tk=e=>"object"==typeof e&&null!==e&&(e instanceof Response||tg(e)||tx(e)),tI=e=>{if(tk(e))return!0;if(Array.isArray(e))return e.some(tI);if(e&&"object"==typeof e){for(let t in e)if(tI(e[t]))return!0}return!1},tT=async(e,t,r,a)=>{if(void 0!==r){if(null==r)throw TypeError(`Received null for "${t}"; to pass null in FormData, you must use the string 'null'`);if("string"==typeof r||"number"==typeof r||"boolean"==typeof r)e.append(t,String(r));else if(r instanceof Response){let n={},o=r.headers.get("Content-Type");o&&(n={type:o}),e.append(t,ty([await r.blob()],t_(r,a),n))}else if(tg(r))e.append(t,ty([await new Response(eQ(r)).blob()],t_(r,a)));else if(tx(r))e.append(t,ty([r],t_(r,a),{type:r.type}));else if(Array.isArray(r))await Promise.all(r.map(r=>tT(e,t+"[]",r,a)));else if("object"==typeof r)await Promise.all(Object.entries(r).map(([r,n])=>tT(e,`${t}[${r}]`,n,a)));else throw TypeError(`Invalid value given to form, expected a string, number, boolean, object, Array, File or Blob but got ${r} instead`)}},tR=e=>null!=e&&"object"==typeof e&&"number"==typeof e.size&&"string"==typeof e.type&&"function"==typeof e.text&&"function"==typeof e.slice&&"function"==typeof e.arrayBuffer,tS=e=>null!=e&&"object"==typeof e&&"string"==typeof e.name&&"number"==typeof e.lastModified&&tR(e),tZ=e=>null!=e&&"object"==typeof e&&"string"==typeof e.url&&"function"==typeof e.blob;async function tC(e,t,r){if(tf(),e=await e,t||(t=t_(e,!0)),tS(e))return e instanceof File&&null==t&&null==r?e:ty([await e.arrayBuffer()],t??e.name,{type:e.type,lastModified:e.lastModified,...r});if(tZ(e)){let a=await e.blob();return t||(t=new URL(e.url).pathname.split(/[\\/]/).pop()),ty(await tE(a),t,r)}let a=await tE(e);if(!r?.type){let e=a.find(e=>"object"==typeof e&&"type"in e&&e.type);"string"==typeof e&&(r={...r,type:e})}return ty(a,t,r)}async function tE(e){let t=[];if("string"==typeof e||ArrayBuffer.isView(e)||e instanceof ArrayBuffer)t.push(e);else if(tR(e))t.push(e instanceof Blob?e:await e.arrayBuffer());else if(tg(e))for await(let r of e)t.push(...await tE(r));else{let t=e?.constructor?.name;throw Error(`Unexpected data type: ${typeof e}${t?`; constructor: ${t}`:""}${function(e){if("object"!=typeof e||null===e)return"";let t=Object.getOwnPropertyNames(e);return`; props: [${t.map(e=>`"${e}"`).join(", ")}]`}(e)}`)}return t}class tO{constructor(e){this._client=e}}let tA=Symbol.for("brand.privateNullableHeaders"),tN=e=>{let t=new Headers,r=new Set;for(let a of e){let e=new Set;for(let[n,o]of function*(e){let t;if(!e)return;if(tA in e){let{values:t,nulls:r}=e;for(let e of(yield*t.entries(),r))yield[e,null];return}let r=!1;for(let a of(e instanceof Headers?t=e.entries():eq(e)?t=e:(r=!0,t=Object.entries(e??{})),t)){let e=a[0];if("string"!=typeof e)throw TypeError("expected header name to be a string");let t=eq(a[1])?a[1]:[a[1]],n=!1;for(let a of t)void 0!==a&&(r&&!n&&(n=!0,yield[e,null]),yield[e,a])}}(a)){let a=n.toLowerCase();e.has(a)||(t.delete(n),e.add(a)),null===o?(t.delete(n),r.add(a)):(t.append(n,o),r.delete(a))}}return{[tA]:!0,values:t,nulls:r}},tM=Symbol("anthropic.sdk.stainlessHelper");function t$(e){return"object"==typeof e&&null!==e&&tM in e}function tP(e,t){let r=new Set;if(e)for(let t of e)t$(t)&&r.add(t[tM]);if(t){for(let e of t)if(t$(e)&&r.add(e[tM]),Array.isArray(e.content))for(let t of e.content)t$(t)&&r.add(t[tM])}return Array.from(r)}function tj(e,t){let r=tP(e,t);return 0===r.length?{}:{"x-stainless-helper":r.join(", ")}}function tF(e){return e.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g,encodeURIComponent)}let tz=Object.freeze(Object.create(null)),tD=((e=tF)=>function(t,...r){let a;if(1===t.length)return t[0];let n=!1,o=[],i=t.reduce((t,a,i)=>{/[?#]/.test(a)&&(n=!0);let s=r[i],l=(n?encodeURIComponent:e)(""+s);return i!==r.length&&(null==s||"object"==typeof s&&s.toString===Object.getPrototypeOf(Object.getPrototypeOf(s.hasOwnProperty??tz)??tz)?.toString)&&(l=s+"",o.push({start:t.length+a.length,length:l.length,error:`Value of type ${Object.prototype.toString.call(s).slice(8,-1)} is not a valid path parameter`})),t+a+(i===r.length?"":l)},""),s=i.split(/[?#]/,1)[0],l=/(?<=^|\/)(?:\.|%2e){1,2}(?=\/|$)/gi;for(;null!==(a=l.exec(s));)o.push({start:a.index,length:a[0].length,error:`Value "${a[0]}" can't be safely passed as a path parameter`});if(o.sort((e,t)=>e.start-t.start),o.length>0){let e=0,t=o.reduce((t,r)=>{let a=" ".repeat(r.start-e),n="^".repeat(r.length);return e=r.start+r.length,t+a+n},"");throw new eT(`Path parameters result in path with invalid segments:
|
|
1
|
+
"use strict";exports.id=373,exports.ids=[373],exports.modules={6939:e=>{var t=Object.defineProperty,r=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,n=Object.prototype.hasOwnProperty,o={};((e,r)=>{for(var a in r)t(e,a,{get:r[a],enumerable:!0})})(o,{SYMBOL_FOR_REQ_CONTEXT:()=>i,getContext:()=>s}),e.exports=((e,o,i,s)=>{if(o&&"object"==typeof o||"function"==typeof o)for(let l of a(o))n.call(e,l)||l===i||t(e,l,{get:()=>o[l],enumerable:!(s=r(o,l))||s.enumerable});return e})(t({},"__esModule",{value:!0}),o);let i=Symbol.for("@vercel/request-context");function s(){let e=globalThis;return e[i]?.get?.()??{}}},1552:(e,t,r)=>{Object.create;var a=Object.defineProperty,n=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,i=(Object.getPrototypeOf,Object.prototype.hasOwnProperty),s={};((e,t)=>{for(var r in t)a(e,r,{get:t[r],enumerable:!0})})(s,{getVercelOidcToken:()=>d,getVercelOidcTokenSync:()=>c}),e.exports=((e,t,r,s)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let l of o(t))i.call(e,l)||l===r||a(e,l,{get:()=>t[l],enumerable:!(s=n(t,l))||s.enumerable});return e})(a({},"__esModule",{value:!0}),s);var l=r(6939),u=r(1403);async function d(){let e,t="";try{t=c()}catch(t){e=t}try{let[{getTokenPayload:e,isExpired:a},{refreshToken:n}]=await Promise.all([await r.e(361).then(r.t.bind(r,1934,23)),await r.e(136).then(r.t.bind(r,9136,23))]);(!t||a(e(t)))&&(await n(),t=c())}catch(r){let t=e instanceof Error?e.message:"";if(r instanceof Error&&(t=`${t}
|
|
2
|
+
${r.message}`),t)throw new u.VercelOidcTokenError(t);throw r}return t}function c(){let e=l.getContext().headers?.["x-vercel-oidc-token"]??process.env.VERCEL_OIDC_TOKEN;if(!e)throw Error("The 'x-vercel-oidc-token' header is missing from the request. Do you have the OIDC option enabled in the Vercel project settings?");return e}},489:(e,t,r)=>{var a=Object.defineProperty,n=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,i=Object.prototype.hasOwnProperty,s={};((e,t)=>{for(var r in t)a(e,r,{get:t[r],enumerable:!0})})(s,{getContext:()=>u.getContext,getVercelOidcToken:()=>l.getVercelOidcToken,getVercelOidcTokenSync:()=>l.getVercelOidcTokenSync}),e.exports=((e,t,r,s)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let l of o(t))i.call(e,l)||l===r||a(e,l,{get:()=>t[l],enumerable:!(s=n(t,l))||s.enumerable});return e})(a({},"__esModule",{value:!0}),s);var l=r(1552),u=r(6939)},1403:e=>{var t=Object.defineProperty,r=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,n=Object.prototype.hasOwnProperty,o={};((e,r)=>{for(var a in r)t(e,a,{get:r[a],enumerable:!0})})(o,{VercelOidcTokenError:()=>i}),e.exports=((e,o,i,s)=>{if(o&&"object"==typeof o||"function"==typeof o)for(let l of a(o))n.call(e,l)||l===i||t(e,l,{get:()=>o[l],enumerable:!(s=r(o,l))||s.enumerable});return e})(t({},"__esModule",{value:!0}),o);class i extends Error{constructor(e,t){super(e),this.name="VercelOidcTokenError",this.cause=t}toString(){return this.cause?`${this.name}: ${this.message}: ${this.cause}`:`${this.name}: ${this.message}`}}},3036:(e,t,r)=>{e.exports=r(517)},7148:(e,t,r)=>{var a,n,o,i,s,l,u,d,c,p,h,m,f,y,_,g,v,b,w,x,k,I,T,R,S,Z,C,E,O,A,N,M,$,P,j,F,z,D,q,U,L,V,G,W,X,B,K,J,H,Y,Q,ee,et,er,ea,en,eo,ei,es,el,eu,ed,ec,ep,eh,em,ef,ey;let e_,eg,ev;function eb(e,t,r,a,n){if("m"===a)throw TypeError("Private method is not writable");if("a"===a&&!n)throw TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw TypeError("Cannot write private member to an object whose class did not declare it");return"a"===a?n.call(e,r):n?n.value=r:t.set(e,r),r}function ew(e,t,r,a){if("a"===r&&!a)throw TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!a:!t.has(e))throw TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?a:"a"===r?a.call(e):a?a.value:t.get(e)}r.d(t,{ZP:()=>rv});let ex=function(){let{crypto:e}=globalThis;if(e?.randomUUID)return ex=e.randomUUID.bind(e),e.randomUUID();let t=new Uint8Array(1),r=e?()=>e.getRandomValues(t)[0]:()=>255*Math.random()&255;return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,e=>(+e^r()&15>>+e/4).toString(16))};function ek(e){return"object"==typeof e&&null!==e&&("name"in e&&"AbortError"===e.name||"message"in e&&String(e.message).includes("FetchRequestCanceledException"))}let eI=e=>{if(e instanceof Error)return e;if("object"==typeof e&&null!==e){try{if("[object Error]"===Object.prototype.toString.call(e)){let t=Error(e.message,e.cause?{cause:e.cause}:{});return e.stack&&(t.stack=e.stack),e.cause&&!t.cause&&(t.cause=e.cause),e.name&&(t.name=e.name),t}}catch{}try{return Error(JSON.stringify(e))}catch{}}return Error(e)};class eT extends Error{}class eR extends eT{constructor(e,t,r,a){super(`${eR.makeMessage(e,t,r)}`),this.status=e,this.headers=a,this.requestID=a?.get("request-id"),this.error=t}static makeMessage(e,t,r){let a=t?.message?"string"==typeof t.message?t.message:JSON.stringify(t.message):t?JSON.stringify(t):r;return e&&a?`${e} ${a}`:e?`${e} status code (no body)`:a||"(no status code or body)"}static generate(e,t,r,a){return e&&a?400===e?new eE(e,t,r,a):401===e?new eO(e,t,r,a):403===e?new eA(e,t,r,a):404===e?new eN(e,t,r,a):409===e?new eM(e,t,r,a):422===e?new e$(e,t,r,a):429===e?new eP(e,t,r,a):e>=500?new ej(e,t,r,a):new eR(e,t,r,a):new eZ({message:r,cause:eI(t)})}}class eS extends eR{constructor({message:e}={}){super(void 0,void 0,e||"Request was aborted.",void 0)}}class eZ extends eR{constructor({message:e,cause:t}){super(void 0,void 0,e||"Connection error.",void 0),t&&(this.cause=t)}}class eC extends eZ{constructor({message:e}={}){super({message:e??"Request timed out."})}}class eE extends eR{}class eO extends eR{}class eA extends eR{}class eN extends eR{}class eM extends eR{}class e$ extends eR{}class eP extends eR{}class ej extends eR{}let eF=/^[a-z][a-z0-9+.-]*:/i,ez=e=>eF.test(e),eD=e=>(eD=Array.isArray)(e),eq=eD;function eU(e){return"object"!=typeof e?{}:e??{}}let eL=(e,t)=>{if("number"!=typeof t||!Number.isInteger(t))throw new eT(`${e} must be an integer`);if(t<0)throw new eT(`${e} must be a positive integer`);return t},eV=e=>{try{return JSON.parse(e)}catch(e){return}},eG=e=>new Promise(t=>setTimeout(t,e)),eW="0.78.0",eX=()=>"undefined"!=typeof window&&void 0!==window.document&&"undefined"!=typeof navigator,eB=()=>{let e="undefined"!=typeof Deno&&null!=Deno.build?"deno":"undefined"!=typeof EdgeRuntime?"edge":"[object process]"===Object.prototype.toString.call(void 0!==globalThis.process?globalThis.process:0)?"node":"unknown";if("deno"===e)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":eW,"X-Stainless-OS":eJ(Deno.build.os),"X-Stainless-Arch":eK(Deno.build.arch),"X-Stainless-Runtime":"deno","X-Stainless-Runtime-Version":"string"==typeof Deno.version?Deno.version:Deno.version?.deno??"unknown"};if("undefined"!=typeof EdgeRuntime)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":eW,"X-Stainless-OS":"Unknown","X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":"edge","X-Stainless-Runtime-Version":globalThis.process.version};if("node"===e)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":eW,"X-Stainless-OS":eJ(globalThis.process.platform??"unknown"),"X-Stainless-Arch":eK(globalThis.process.arch??"unknown"),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":globalThis.process.version??"unknown"};let t=function(){if("undefined"==typeof navigator||!navigator)return null;for(let{key:e,pattern:t}of[{key:"edge",pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"chrome",pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"firefox",pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"safari",pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}]){let r=t.exec(navigator.userAgent);if(r){let t=r[1]||0,a=r[2]||0,n=r[3]||0;return{browser:e,version:`${t}.${a}.${n}`}}}return null}();return t?{"X-Stainless-Lang":"js","X-Stainless-Package-Version":eW,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":`browser:${t.browser}`,"X-Stainless-Runtime-Version":t.version}:{"X-Stainless-Lang":"js","X-Stainless-Package-Version":eW,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}},eK=e=>"x32"===e?"x32":"x86_64"===e||"x64"===e?"x64":"arm"===e?"arm":"aarch64"===e||"arm64"===e?"arm64":e?`other:${e}`:"unknown",eJ=e=>(e=e.toLowerCase()).includes("ios")?"iOS":"android"===e?"Android":"darwin"===e?"MacOS":"win32"===e?"Windows":"freebsd"===e?"FreeBSD":"openbsd"===e?"OpenBSD":"linux"===e?"Linux":e?`Other:${e}`:"Unknown",eH=()=>e_??(e_=eB());function eY(...e){let t=globalThis.ReadableStream;if(void 0===t)throw Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new t(...e)}function eQ(e){let t=Symbol.asyncIterator in e?e[Symbol.asyncIterator]():e[Symbol.iterator]();return eY({start(){},async pull(e){let{done:r,value:a}=await t.next();r?e.close():e.enqueue(a)},async cancel(){await t.return?.()}})}function e0(e){if(e[Symbol.asyncIterator])return e;let t=e.getReader();return{async next(){try{let e=await t.read();return e?.done&&t.releaseLock(),e}catch(e){throw t.releaseLock(),e}},async return(){let e=t.cancel();return t.releaseLock(),await e,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}async function e1(e){if(null===e||"object"!=typeof e)return;if(e[Symbol.asyncIterator]){await e[Symbol.asyncIterator]().return?.();return}let t=e.getReader(),r=t.cancel();t.releaseLock(),await r}let e2=({headers:e,body:t})=>({bodyHeaders:{"content-type":"application/json"},body:JSON.stringify(t)});function e4(e){let t;return(eg??(eg=(t=new globalThis.TextEncoder).encode.bind(t)))(e)}function e9(e){let t;return(ev??(ev=(t=new globalThis.TextDecoder).decode.bind(t)))(e)}class e5{constructor(){a.set(this,void 0),n.set(this,void 0),eb(this,a,new Uint8Array,"f"),eb(this,n,null,"f")}decode(e){let t;if(null==e)return[];let r=e instanceof ArrayBuffer?new Uint8Array(e):"string"==typeof e?e4(e):e;eb(this,a,function(e){let t=0;for(let r of e)t+=r.length;let r=new Uint8Array(t),a=0;for(let t of e)r.set(t,a),a+=t.length;return r}([ew(this,a,"f"),r]),"f");let o=[];for(;null!=(t=function(e,t){for(let r=t??0;r<e.length;r++){if(10===e[r])return{preceding:r,index:r+1,carriage:!1};if(13===e[r])return{preceding:r,index:r+1,carriage:!0}}return null}(ew(this,a,"f"),ew(this,n,"f")));){if(t.carriage&&null==ew(this,n,"f")){eb(this,n,t.index,"f");continue}if(null!=ew(this,n,"f")&&(t.index!==ew(this,n,"f")+1||t.carriage)){o.push(e9(ew(this,a,"f").subarray(0,ew(this,n,"f")-1))),eb(this,a,ew(this,a,"f").subarray(ew(this,n,"f")),"f"),eb(this,n,null,"f");continue}let e=null!==ew(this,n,"f")?t.preceding-1:t.preceding,r=e9(ew(this,a,"f").subarray(0,e));o.push(r),eb(this,a,ew(this,a,"f").subarray(t.index),"f"),eb(this,n,null,"f")}return o}flush(){return ew(this,a,"f").length?this.decode("\n"):[]}}a=new WeakMap,n=new WeakMap,e5.NEWLINE_CHARS=new Set(["\n","\r"]),e5.NEWLINE_REGEXP=/\r\n|[\n\r]/g;let e6={off:0,error:200,warn:300,info:400,debug:500},e3=(e,t,r)=>{if(e){if(Object.prototype.hasOwnProperty.call(e6,e))return e;tr(r).warn(`${t} was set to ${JSON.stringify(e)}, expected one of ${JSON.stringify(Object.keys(e6))}`)}};function e7(){}function e8(e,t,r){return!t||e6[e]>e6[r]?e7:t[e].bind(t)}let te={error:e7,warn:e7,info:e7,debug:e7},tt=new WeakMap;function tr(e){let t=e.logger,r=e.logLevel??"off";if(!t)return te;let a=tt.get(t);if(a&&a[0]===r)return a[1];let n={error:e8("error",t,r),warn:e8("warn",t,r),info:e8("info",t,r),debug:e8("debug",t,r)};return tt.set(t,[r,n]),n}let ta=e=>(e.options&&(e.options={...e.options},delete e.options.headers),e.headers&&(e.headers=Object.fromEntries((e.headers instanceof Headers?[...e.headers]:Object.entries(e.headers)).map(([e,t])=>[e,"x-api-key"===e.toLowerCase()||"authorization"===e.toLowerCase()||"cookie"===e.toLowerCase()||"set-cookie"===e.toLowerCase()?"***":t]))),"retryOfRequestLogID"in e&&(e.retryOfRequestLogID&&(e.retryOf=e.retryOfRequestLogID),delete e.retryOfRequestLogID),e);class tn{constructor(e,t,r){this.iterator=e,o.set(this,void 0),this.controller=t,eb(this,o,r,"f")}static fromSSEResponse(e,t,r){let a=!1,n=r?tr(r):console;return new tn(async function*(){if(a)throw new eT("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");a=!0;let r=!1;try{for await(let r of to(e,t)){if("completion"===r.event)try{yield JSON.parse(r.data)}catch(e){throw n.error("Could not parse message into JSON:",r.data),n.error("From chunk:",r.raw),e}if("message_start"===r.event||"message_delta"===r.event||"message_stop"===r.event||"content_block_start"===r.event||"content_block_delta"===r.event||"content_block_stop"===r.event)try{yield JSON.parse(r.data)}catch(e){throw n.error("Could not parse message into JSON:",r.data),n.error("From chunk:",r.raw),e}if("ping"!==r.event&&"error"===r.event)throw new eR(void 0,eV(r.data)??r.data,void 0,e.headers)}r=!0}catch(e){if(ek(e))return;throw e}finally{r||t.abort()}},t,r)}static fromReadableStream(e,t,r){let a=!1;async function*n(){let t=new e5;for await(let r of e0(e))for(let e of t.decode(r))yield e;for(let e of t.flush())yield e}return new tn(async function*(){if(a)throw new eT("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");a=!0;let e=!1;try{for await(let t of n())!e&&t&&(yield JSON.parse(t));e=!0}catch(e){if(ek(e))return;throw e}finally{e||t.abort()}},t,r)}[(o=new WeakMap,Symbol.asyncIterator)](){return this.iterator()}tee(){let e=[],t=[],r=this.iterator(),a=a=>({next:()=>{if(0===a.length){let a=r.next();e.push(a),t.push(a)}return a.shift()}});return[new tn(()=>a(e),this.controller,ew(this,o,"f")),new tn(()=>a(t),this.controller,ew(this,o,"f"))]}toReadableStream(){let e;let t=this;return eY({async start(){e=t[Symbol.asyncIterator]()},async pull(t){try{let{value:r,done:a}=await e.next();if(a)return t.close();let n=e4(JSON.stringify(r)+"\n");t.enqueue(n)}catch(e){t.error(e)}},async cancel(){await e.return?.()}})}}async function*to(e,t){if(!e.body){if(t.abort(),void 0!==globalThis.navigator&&"ReactNative"===globalThis.navigator.product)throw new eT("The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api");throw new eT("Attempted to iterate over a response with no body")}let r=new ts,a=new e5;for await(let t of ti(e0(e.body)))for(let e of a.decode(t)){let t=r.decode(e);t&&(yield t)}for(let e of a.flush()){let t=r.decode(e);t&&(yield t)}}async function*ti(e){let t=new Uint8Array;for await(let r of e){let e;if(null==r)continue;let a=r instanceof ArrayBuffer?new Uint8Array(r):"string"==typeof r?e4(r):r,n=new Uint8Array(t.length+a.length);for(n.set(t),n.set(a,t.length),t=n;-1!==(e=function(e){for(let t=0;t<e.length-1;t++){if(10===e[t]&&10===e[t+1]||13===e[t]&&13===e[t+1])return t+2;if(13===e[t]&&10===e[t+1]&&t+3<e.length&&13===e[t+2]&&10===e[t+3])return t+4}return -1}(t));)yield t.slice(0,e),t=t.slice(e)}t.length>0&&(yield t)}class ts{constructor(){this.event=null,this.data=[],this.chunks=[]}decode(e){if(e.endsWith("\r")&&(e=e.substring(0,e.length-1)),!e){if(!this.event&&!this.data.length)return null;let e={event:this.event,data:this.data.join("\n"),raw:this.chunks};return this.event=null,this.data=[],this.chunks=[],e}if(this.chunks.push(e),e.startsWith(":"))return null;let[t,r,a]=function(e,t){let r=e.indexOf(":");return -1!==r?[e.substring(0,r),":",e.substring(r+t.length)]:[e,"",""]}(e,":");return a.startsWith(" ")&&(a=a.substring(1)),"event"===t?this.event=a:"data"===t&&this.data.push(a),null}}async function tl(e,t){let{response:r,requestLogID:a,retryOfRequestLogID:n,startTime:o}=t,i=await (async()=>{if(t.options.stream)return(tr(e).debug("response",r.status,r.url,r.headers,r.body),t.options.__streamClass)?t.options.__streamClass.fromSSEResponse(r,t.controller):tn.fromSSEResponse(r,t.controller);if(204===r.status)return null;if(t.options.__binaryResponse)return r;let a=r.headers.get("content-type"),n=a?.split(";")[0]?.trim();if(n?.includes("application/json")||n?.endsWith("+json")){if("0"===r.headers.get("content-length"))return;return tu(await r.json(),r)}return await r.text()})();return tr(e).debug(`[${a}] response parsed`,ta({retryOfRequestLogID:n,url:r.url,status:r.status,body:i,durationMs:Date.now()-o})),i}function tu(e,t){return!e||"object"!=typeof e||Array.isArray(e)?e:Object.defineProperty(e,"_request_id",{value:t.headers.get("request-id"),enumerable:!1})}class td extends Promise{constructor(e,t,r=tl){super(e=>{e(null)}),this.responsePromise=t,this.parseResponse=r,i.set(this,void 0),eb(this,i,e,"f")}_thenUnwrap(e){return new td(ew(this,i,"f"),this.responsePromise,async(t,r)=>tu(e(await this.parseResponse(t,r),r),r.response))}asResponse(){return this.responsePromise.then(e=>e.response)}async withResponse(){let[e,t]=await Promise.all([this.parse(),this.asResponse()]);return{data:e,response:t,request_id:t.headers.get("request-id")}}parse(){return this.parsedPromise||(this.parsedPromise=this.responsePromise.then(e=>this.parseResponse(ew(this,i,"f"),e))),this.parsedPromise}then(e,t){return this.parse().then(e,t)}catch(e){return this.parse().catch(e)}finally(e){return this.parse().finally(e)}}i=new WeakMap;class tc{constructor(e,t,r,a){s.set(this,void 0),eb(this,s,e,"f"),this.options=a,this.response=t,this.body=r}hasNextPage(){return!!this.getPaginatedItems().length&&null!=this.nextPageRequestOptions()}async getNextPage(){let e=this.nextPageRequestOptions();if(!e)throw new eT("No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.");return await ew(this,s,"f").requestAPIList(this.constructor,e)}async *iterPages(){let e=this;for(yield e;e.hasNextPage();)e=await e.getNextPage(),yield e}async *[(s=new WeakMap,Symbol.asyncIterator)](){for await(let e of this.iterPages())for(let t of e.getPaginatedItems())yield t}}class tp extends td{constructor(e,t,r){super(e,t,async(e,t)=>new r(e,t.response,await tl(e,t),t.options))}async *[Symbol.asyncIterator](){for await(let e of(await this))yield e}}class th extends tc{constructor(e,t,r,a){super(e,t,r,a),this.data=r.data||[],this.has_more=r.has_more||!1,this.first_id=r.first_id||null,this.last_id=r.last_id||null}getPaginatedItems(){return this.data??[]}hasNextPage(){return!1!==this.has_more&&super.hasNextPage()}nextPageRequestOptions(){if(this.options.query?.before_id){let e=this.first_id;return e?{...this.options,query:{...eU(this.options.query),before_id:e}}:null}let e=this.last_id;return e?{...this.options,query:{...eU(this.options.query),after_id:e}}:null}}class tm extends tc{constructor(e,t,r,a){super(e,t,r,a),this.data=r.data||[],this.has_more=r.has_more||!1,this.next_page=r.next_page||null}getPaginatedItems(){return this.data??[]}hasNextPage(){return!1!==this.has_more&&super.hasNextPage()}nextPageRequestOptions(){let e=this.next_page;return e?{...this.options,query:{...eU(this.options.query),page:e}}:null}}let tf=()=>{if("undefined"==typeof File){let{process:e}=globalThis;throw Error("`File` is not defined as a global, which is required for file uploads."+("string"==typeof e?.versions?.node&&20>parseInt(e.versions.node.split("."))?" Update to Node 20 LTS or newer, or set `globalThis.File` to `import('node:buffer').File`.":""))}};function ty(e,t,r){return tf(),new File(e,t??"unknown_file",r)}function t_(e,t){let r="object"==typeof e&&null!==e&&("name"in e&&e.name&&String(e.name)||"url"in e&&e.url&&String(e.url)||"filename"in e&&e.filename&&String(e.filename)||"path"in e&&e.path&&String(e.path))||"";return t?r.split(/[\\/]/).pop()||void 0:r}let tg=e=>null!=e&&"object"==typeof e&&"function"==typeof e[Symbol.asyncIterator],tv=async(e,t,r=!0)=>({...e,body:await tw(e.body,t,r)}),tb=new WeakMap,tw=async(e,t,r=!0)=>{if(!await function(e){let t="function"==typeof e?e:e.fetch,r=tb.get(t);if(r)return r;let a=(async()=>{try{let e="Response"in t?t.Response:(await t("data:,")).constructor,r=new FormData;if(r.toString()===await new e(r).text())return!1;return!0}catch{return!0}})();return tb.set(t,a),a}(t))throw TypeError("The provided fetch function does not support file uploads with the current global FormData class.");let a=new FormData;return await Promise.all(Object.entries(e||{}).map(([e,t])=>tT(a,e,t,r))),a},tx=e=>e instanceof Blob&&"name"in e,tk=e=>"object"==typeof e&&null!==e&&(e instanceof Response||tg(e)||tx(e)),tI=e=>{if(tk(e))return!0;if(Array.isArray(e))return e.some(tI);if(e&&"object"==typeof e){for(let t in e)if(tI(e[t]))return!0}return!1},tT=async(e,t,r,a)=>{if(void 0!==r){if(null==r)throw TypeError(`Received null for "${t}"; to pass null in FormData, you must use the string 'null'`);if("string"==typeof r||"number"==typeof r||"boolean"==typeof r)e.append(t,String(r));else if(r instanceof Response){let n={},o=r.headers.get("Content-Type");o&&(n={type:o}),e.append(t,ty([await r.blob()],t_(r,a),n))}else if(tg(r))e.append(t,ty([await new Response(eQ(r)).blob()],t_(r,a)));else if(tx(r))e.append(t,ty([r],t_(r,a),{type:r.type}));else if(Array.isArray(r))await Promise.all(r.map(r=>tT(e,t+"[]",r,a)));else if("object"==typeof r)await Promise.all(Object.entries(r).map(([r,n])=>tT(e,`${t}[${r}]`,n,a)));else throw TypeError(`Invalid value given to form, expected a string, number, boolean, object, Array, File or Blob but got ${r} instead`)}},tR=e=>null!=e&&"object"==typeof e&&"number"==typeof e.size&&"string"==typeof e.type&&"function"==typeof e.text&&"function"==typeof e.slice&&"function"==typeof e.arrayBuffer,tS=e=>null!=e&&"object"==typeof e&&"string"==typeof e.name&&"number"==typeof e.lastModified&&tR(e),tZ=e=>null!=e&&"object"==typeof e&&"string"==typeof e.url&&"function"==typeof e.blob;async function tC(e,t,r){if(tf(),e=await e,t||(t=t_(e,!0)),tS(e))return e instanceof File&&null==t&&null==r?e:ty([await e.arrayBuffer()],t??e.name,{type:e.type,lastModified:e.lastModified,...r});if(tZ(e)){let a=await e.blob();return t||(t=new URL(e.url).pathname.split(/[\\/]/).pop()),ty(await tE(a),t,r)}let a=await tE(e);if(!r?.type){let e=a.find(e=>"object"==typeof e&&"type"in e&&e.type);"string"==typeof e&&(r={...r,type:e})}return ty(a,t,r)}async function tE(e){let t=[];if("string"==typeof e||ArrayBuffer.isView(e)||e instanceof ArrayBuffer)t.push(e);else if(tR(e))t.push(e instanceof Blob?e:await e.arrayBuffer());else if(tg(e))for await(let r of e)t.push(...await tE(r));else{let t=e?.constructor?.name;throw Error(`Unexpected data type: ${typeof e}${t?`; constructor: ${t}`:""}${function(e){if("object"!=typeof e||null===e)return"";let t=Object.getOwnPropertyNames(e);return`; props: [${t.map(e=>`"${e}"`).join(", ")}]`}(e)}`)}return t}class tO{constructor(e){this._client=e}}let tA=Symbol.for("brand.privateNullableHeaders"),tN=e=>{let t=new Headers,r=new Set;for(let a of e){let e=new Set;for(let[n,o]of function*(e){let t;if(!e)return;if(tA in e){let{values:t,nulls:r}=e;for(let e of(yield*t.entries(),r))yield[e,null];return}let r=!1;for(let a of(e instanceof Headers?t=e.entries():eq(e)?t=e:(r=!0,t=Object.entries(e??{})),t)){let e=a[0];if("string"!=typeof e)throw TypeError("expected header name to be a string");let t=eq(a[1])?a[1]:[a[1]],n=!1;for(let a of t)void 0!==a&&(r&&!n&&(n=!0,yield[e,null]),yield[e,a])}}(a)){let a=n.toLowerCase();e.has(a)||(t.delete(n),e.add(a)),null===o?(t.delete(n),r.add(a)):(t.append(n,o),r.delete(a))}}return{[tA]:!0,values:t,nulls:r}},tM=Symbol("anthropic.sdk.stainlessHelper");function t$(e){return"object"==typeof e&&null!==e&&tM in e}function tP(e,t){let r=new Set;if(e)for(let t of e)t$(t)&&r.add(t[tM]);if(t){for(let e of t)if(t$(e)&&r.add(e[tM]),Array.isArray(e.content))for(let t of e.content)t$(t)&&r.add(t[tM])}return Array.from(r)}function tj(e,t){let r=tP(e,t);return 0===r.length?{}:{"x-stainless-helper":r.join(", ")}}function tF(e){return e.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g,encodeURIComponent)}let tz=Object.freeze(Object.create(null)),tD=((e=tF)=>function(t,...r){let a;if(1===t.length)return t[0];let n=!1,o=[],i=t.reduce((t,a,i)=>{/[?#]/.test(a)&&(n=!0);let s=r[i],l=(n?encodeURIComponent:e)(""+s);return i!==r.length&&(null==s||"object"==typeof s&&s.toString===Object.getPrototypeOf(Object.getPrototypeOf(s.hasOwnProperty??tz)??tz)?.toString)&&(l=s+"",o.push({start:t.length+a.length,length:l.length,error:`Value of type ${Object.prototype.toString.call(s).slice(8,-1)} is not a valid path parameter`})),t+a+(i===r.length?"":l)},""),s=i.split(/[?#]/,1)[0],l=/(?<=^|\/)(?:\.|%2e){1,2}(?=\/|$)/gi;for(;null!==(a=l.exec(s));)o.push({start:a.index,length:a[0].length,error:`Value "${a[0]}" can't be safely passed as a path parameter`});if(o.sort((e,t)=>e.start-t.start),o.length>0){let e=0,t=o.reduce((t,r)=>{let a=" ".repeat(r.start-e),n="^".repeat(r.length);return e=r.start+r.length,t+a+n},"");throw new eT(`Path parameters result in path with invalid segments:
|
|
15
3
|
${o.map(e=>e.error).join("\n")}
|
|
16
4
|
${i}
|
|
17
5
|
${t}`)}return i})(tF);class tq extends tO{list(e={},t){let{betas:r,...a}=e??{};return this._client.getAPIList("/v1/files",th,{query:a,...t,headers:tN([{"anthropic-beta":[...r??[],"files-api-2025-04-14"].toString()},t?.headers])})}delete(e,t={},r){let{betas:a}=t??{};return this._client.delete(tD`/v1/files/${e}`,{...r,headers:tN([{"anthropic-beta":[...a??[],"files-api-2025-04-14"].toString()},r?.headers])})}download(e,t={},r){let{betas:a}=t??{};return this._client.get(tD`/v1/files/${e}/content`,{...r,headers:tN([{"anthropic-beta":[...a??[],"files-api-2025-04-14"].toString(),Accept:"application/binary"},r?.headers]),__binaryResponse:!0})}retrieveMetadata(e,t={},r){let{betas:a}=t??{};return this._client.get(tD`/v1/files/${e}`,{...r,headers:tN([{"anthropic-beta":[...a??[],"files-api-2025-04-14"].toString()},r?.headers])})}upload(e,t){var r;let{betas:a,...n}=e;return this._client.post("/v1/files",tv({body:n,...t,headers:tN([{"anthropic-beta":[...a??[],"files-api-2025-04-14"].toString()},t$(r=n.file)?{"x-stainless-helper":r[tM]}:{},t?.headers])},this._client))}}class tU extends tO{retrieve(e,t={},r){let{betas:a}=t??{};return this._client.get(tD`/v1/models/${e}?beta=true`,{...r,headers:tN([{...a?.toString()!=null?{"anthropic-beta":a?.toString()}:void 0},r?.headers])})}list(e={},t){let{betas:r,...a}=e??{};return this._client.getAPIList("/v1/models?beta=true",th,{query:a,...t,headers:tN([{...r?.toString()!=null?{"anthropic-beta":r?.toString()}:void 0},t?.headers])})}}let tL={"claude-opus-4-20250514":8192,"claude-opus-4-0":8192,"claude-4-opus-20250514":8192,"anthropic.claude-opus-4-20250514-v1:0":8192,"claude-opus-4@20250514":8192,"claude-opus-4-1-20250805":8192,"anthropic.claude-opus-4-1-20250805-v1:0":8192,"claude-opus-4-1@20250805":8192};function tV(e){return e?.output_format??e?.output_config?.format}function tG(e,t,r){let a=tV(t);return t&&"parse"in(a??{})?tW(e,t,r):{...e,content:e.content.map(e=>"text"===e.type?Object.defineProperty(Object.defineProperty({...e},"parsed_output",{value:null,enumerable:!1}),"parsed",{get:()=>(r.logger.warn("The `parsed` property on `text` blocks is deprecated, please use `parsed_output` instead."),null),enumerable:!1}):e),parsed_output:null}}function tW(e,t,r){let a=null,n=e.content.map(e=>{if("text"===e.type){let n=function(e,t){let r=tV(e);if(r?.type!=="json_schema")return null;try{if("parse"in r)return r.parse(t);return JSON.parse(t)}catch(e){throw new eT(`Failed to parse structured output: ${e}`)}}(t,e.text);return null===a&&(a=n),Object.defineProperty(Object.defineProperty({...e},"parsed_output",{value:n,enumerable:!1}),"parsed",{get:()=>(r.logger.warn("The `parsed` property on `text` blocks is deprecated, please use `parsed_output` instead."),n),enumerable:!1})}return e});return{...e,content:n,parsed_output:a}}let tX=e=>{let t=0,r=[];for(;t<e.length;){let a=e[t];if("\\"===a){t++;continue}if("{"===a){r.push({type:"brace",value:"{"}),t++;continue}if("}"===a){r.push({type:"brace",value:"}"}),t++;continue}if("["===a){r.push({type:"paren",value:"["}),t++;continue}if("]"===a){r.push({type:"paren",value:"]"}),t++;continue}if(":"===a){r.push({type:"separator",value:":"}),t++;continue}if(","===a){r.push({type:"delimiter",value:","}),t++;continue}if('"'===a){let n="",o=!1;for(a=e[++t];'"'!==a;){if(t===e.length){o=!0;break}if("\\"===a){if(++t===e.length){o=!0;break}n+=a+e[t],a=e[++t]}else n+=a,a=e[++t]}a=e[++t],o||r.push({type:"string",value:n});continue}let n=/\s/;if(a&&n.test(a)){t++;continue}let o=/[0-9]/;if(a&&o.test(a)||"-"===a||"."===a){let n="";for("-"===a&&(n+=a,a=e[++t]);a&&o.test(a)||"."===a;)n+=a,a=e[++t];r.push({type:"number",value:n});continue}let i=/[a-z]/i;if(a&&i.test(a)){let n="";for(;a&&i.test(a)&&t!==e.length;)n+=a,a=e[++t];"true"==n||"false"==n||"null"===n?r.push({type:"name",value:n}):t++;continue}t++}return r},tB=e=>{if(0===e.length)return e;let t=e[e.length-1];switch(t.type){case"separator":return tB(e=e.slice(0,e.length-1));case"number":let r=t.value[t.value.length-1];if("."===r||"-"===r)return tB(e=e.slice(0,e.length-1));case"string":let a=e[e.length-2];if(a?.type==="delimiter"||a?.type==="brace"&&"{"===a.value)return tB(e=e.slice(0,e.length-1));break;case"delimiter":return tB(e=e.slice(0,e.length-1))}return e},tK=e=>{let t=[];return e.map(e=>{"brace"===e.type&&("{"===e.value?t.push("}"):t.splice(t.lastIndexOf("}"),1)),"paren"===e.type&&("["===e.value?t.push("]"):t.splice(t.lastIndexOf("]"),1))}),t.length>0&&t.reverse().map(t=>{"}"===t?e.push({type:"brace",value:"}"}):"]"===t&&e.push({type:"paren",value:"]"})}),e},tJ=e=>{let t="";return e.map(e=>{"string"===e.type?t+='"'+e.value+'"':t+=e.value}),t},tH=e=>JSON.parse(tJ(tK(tB(tX(e))))),tY="__json_buf";function tQ(e){return"tool_use"===e.type||"server_tool_use"===e.type||"mcp_tool_use"===e.type}class t0{constructor(e,t){l.add(this),this.messages=[],this.receivedMessages=[],u.set(this,void 0),d.set(this,null),this.controller=new AbortController,c.set(this,void 0),p.set(this,()=>{}),h.set(this,()=>{}),m.set(this,void 0),f.set(this,()=>{}),y.set(this,()=>{}),_.set(this,{}),g.set(this,!1),v.set(this,!1),b.set(this,!1),w.set(this,!1),x.set(this,void 0),k.set(this,void 0),I.set(this,void 0),S.set(this,e=>{if(eb(this,v,!0,"f"),ek(e)&&(e=new eS),e instanceof eS)return eb(this,b,!0,"f"),this._emit("abort",e);if(e instanceof eT)return this._emit("error",e);if(e instanceof Error){let t=new eT(e.message);return t.cause=e,this._emit("error",t)}return this._emit("error",new eT(String(e)))}),eb(this,c,new Promise((e,t)=>{eb(this,p,e,"f"),eb(this,h,t,"f")}),"f"),eb(this,m,new Promise((e,t)=>{eb(this,f,e,"f"),eb(this,y,t,"f")}),"f"),ew(this,c,"f").catch(()=>{}),ew(this,m,"f").catch(()=>{}),eb(this,d,e,"f"),eb(this,I,t?.logger??console,"f")}get response(){return ew(this,x,"f")}get request_id(){return ew(this,k,"f")}async withResponse(){eb(this,w,!0,"f");let e=await ew(this,c,"f");if(!e)throw Error("Could not resolve a `Response` object");return{data:this,response:e,request_id:e.headers.get("request-id")}}static fromReadableStream(e){let t=new t0(null);return t._run(()=>t._fromReadableStream(e)),t}static createMessage(e,t,r,{logger:a}={}){let n=new t0(t,{logger:a});for(let e of t.messages)n._addMessageParam(e);return eb(n,d,{...t,stream:!0},"f"),n._run(()=>n._createMessage(e,{...t,stream:!0},{...r,headers:{...r?.headers,"X-Stainless-Helper-Method":"stream"}})),n}_run(e){e().then(()=>{this._emitFinal(),this._emit("end")},ew(this,S,"f"))}_addMessageParam(e){this.messages.push(e)}_addMessage(e,t=!0){this.receivedMessages.push(e),t&&this._emit("message",e)}async _createMessage(e,t,r){let a;let n=r?.signal;n&&(n.aborted&&this.controller.abort(),a=this.controller.abort.bind(this.controller),n.addEventListener("abort",a));try{ew(this,l,"m",Z).call(this);let{response:a,data:n}=await e.create({...t,stream:!0},{...r,signal:this.controller.signal}).withResponse();for await(let e of(this._connected(a),n))ew(this,l,"m",C).call(this,e);if(n.controller.signal?.aborted)throw new eS;ew(this,l,"m",E).call(this)}finally{n&&a&&n.removeEventListener("abort",a)}}_connected(e){this.ended||(eb(this,x,e,"f"),eb(this,k,e?.headers.get("request-id"),"f"),ew(this,p,"f").call(this,e),this._emit("connect"))}get ended(){return ew(this,g,"f")}get errored(){return ew(this,v,"f")}get aborted(){return ew(this,b,"f")}abort(){this.controller.abort()}on(e,t){return(ew(this,_,"f")[e]||(ew(this,_,"f")[e]=[])).push({listener:t}),this}off(e,t){let r=ew(this,_,"f")[e];if(!r)return this;let a=r.findIndex(e=>e.listener===t);return a>=0&&r.splice(a,1),this}once(e,t){return(ew(this,_,"f")[e]||(ew(this,_,"f")[e]=[])).push({listener:t,once:!0}),this}emitted(e){return new Promise((t,r)=>{eb(this,w,!0,"f"),"error"!==e&&this.once("error",r),this.once(e,t)})}async done(){eb(this,w,!0,"f"),await ew(this,m,"f")}get currentMessage(){return ew(this,u,"f")}async finalMessage(){return await this.done(),ew(this,l,"m",T).call(this)}async finalText(){return await this.done(),ew(this,l,"m",R).call(this)}_emit(e,...t){if(ew(this,g,"f"))return;"end"===e&&(eb(this,g,!0,"f"),ew(this,f,"f").call(this));let r=ew(this,_,"f")[e];if(r&&(ew(this,_,"f")[e]=r.filter(e=>!e.once),r.forEach(({listener:e})=>e(...t))),"abort"===e){let e=t[0];ew(this,w,"f")||r?.length||Promise.reject(e),ew(this,h,"f").call(this,e),ew(this,y,"f").call(this,e),this._emit("end");return}if("error"===e){let e=t[0];ew(this,w,"f")||r?.length||Promise.reject(e),ew(this,h,"f").call(this,e),ew(this,y,"f").call(this,e),this._emit("end")}}_emitFinal(){this.receivedMessages.at(-1)&&this._emit("finalMessage",ew(this,l,"m",T).call(this))}async _fromReadableStream(e,t){let r;let a=t?.signal;a&&(a.aborted&&this.controller.abort(),r=this.controller.abort.bind(this.controller),a.addEventListener("abort",r));try{ew(this,l,"m",Z).call(this),this._connected(null);let t=tn.fromReadableStream(e,this.controller);for await(let e of t)ew(this,l,"m",C).call(this,e);if(t.controller.signal?.aborted)throw new eS;ew(this,l,"m",E).call(this)}finally{a&&r&&a.removeEventListener("abort",r)}}[(u=new WeakMap,d=new WeakMap,c=new WeakMap,p=new WeakMap,h=new WeakMap,m=new WeakMap,f=new WeakMap,y=new WeakMap,_=new WeakMap,g=new WeakMap,v=new WeakMap,b=new WeakMap,w=new WeakMap,x=new WeakMap,k=new WeakMap,I=new WeakMap,S=new WeakMap,l=new WeakSet,T=function(){if(0===this.receivedMessages.length)throw new eT("stream ended without producing a Message with role=assistant");return this.receivedMessages.at(-1)},R=function(){if(0===this.receivedMessages.length)throw new eT("stream ended without producing a Message with role=assistant");let e=this.receivedMessages.at(-1).content.filter(e=>"text"===e.type).map(e=>e.text);if(0===e.length)throw new eT("stream ended without producing a content block with type=text");return e.join(" ")},Z=function(){this.ended||eb(this,u,void 0,"f")},C=function(e){if(this.ended)return;let t=ew(this,l,"m",O).call(this,e);switch(this._emit("streamEvent",e,t),e.type){case"content_block_delta":{let r=t.content.at(-1);switch(e.delta.type){case"text_delta":"text"===r.type&&this._emit("text",e.delta.text,r.text||"");break;case"citations_delta":"text"===r.type&&this._emit("citation",e.delta.citation,r.citations??[]);break;case"input_json_delta":tQ(r)&&r.input&&this._emit("inputJson",e.delta.partial_json,r.input);break;case"thinking_delta":"thinking"===r.type&&this._emit("thinking",e.delta.thinking,r.thinking);break;case"signature_delta":"thinking"===r.type&&this._emit("signature",r.signature);break;case"compaction_delta":"compaction"===r.type&&r.content&&this._emit("compaction",r.content);break;default:e.delta}break}case"message_stop":this._addMessageParam(t),this._addMessage(tG(t,ew(this,d,"f"),{logger:ew(this,I,"f")}),!0);break;case"content_block_stop":this._emit("contentBlock",t.content.at(-1));break;case"message_start":eb(this,u,t,"f")}},E=function(){if(this.ended)throw new eT("stream has ended, this shouldn't happen");let e=ew(this,u,"f");if(!e)throw new eT("request ended without sending any chunks");return eb(this,u,void 0,"f"),tG(e,ew(this,d,"f"),{logger:ew(this,I,"f")})},O=function(e){let t=ew(this,u,"f");if("message_start"===e.type){if(t)throw new eT(`Unexpected event order, got ${e.type} before receiving "message_stop"`);return e.message}if(!t)throw new eT(`Unexpected event order, got ${e.type} before "message_start"`);switch(e.type){case"message_stop":case"content_block_stop":return t;case"message_delta":return t.container=e.delta.container,t.stop_reason=e.delta.stop_reason,t.stop_sequence=e.delta.stop_sequence,t.usage.output_tokens=e.usage.output_tokens,t.context_management=e.context_management,null!=e.usage.input_tokens&&(t.usage.input_tokens=e.usage.input_tokens),null!=e.usage.cache_creation_input_tokens&&(t.usage.cache_creation_input_tokens=e.usage.cache_creation_input_tokens),null!=e.usage.cache_read_input_tokens&&(t.usage.cache_read_input_tokens=e.usage.cache_read_input_tokens),null!=e.usage.server_tool_use&&(t.usage.server_tool_use=e.usage.server_tool_use),null!=e.usage.iterations&&(t.usage.iterations=e.usage.iterations),t;case"content_block_start":return t.content.push(e.content_block),t;case"content_block_delta":{let r=t.content.at(e.index);switch(e.delta.type){case"text_delta":r?.type==="text"&&(t.content[e.index]={...r,text:(r.text||"")+e.delta.text});break;case"citations_delta":r?.type==="text"&&(t.content[e.index]={...r,citations:[...r.citations??[],e.delta.citation]});break;case"input_json_delta":if(r&&tQ(r)){let a=r[tY]||"";a+=e.delta.partial_json;let n={...r};if(Object.defineProperty(n,tY,{value:a,enumerable:!1,writable:!0}),a)try{n.input=tH(a)}catch(t){let e=new eT(`Unable to parse tool parameter JSON from model. Please retry your request or adjust your prompt. Error: ${t}. JSON: ${a}`);ew(this,S,"f").call(this,e)}t.content[e.index]=n}break;case"thinking_delta":r?.type==="thinking"&&(t.content[e.index]={...r,thinking:r.thinking+e.delta.thinking});break;case"signature_delta":r?.type==="thinking"&&(t.content[e.index]={...r,signature:e.delta.signature});break;case"compaction_delta":r?.type==="compaction"&&(t.content[e.index]={...r,content:(r.content||"")+e.delta.content});break;default:e.delta}return t}}},Symbol.asyncIterator)](){let e=[],t=[],r=!1;return this.on("streamEvent",r=>{let a=t.shift();a?a.resolve(r):e.push(r)}),this.on("end",()=>{for(let e of(r=!0,t))e.resolve(void 0);t.length=0}),this.on("abort",e=>{for(let a of(r=!0,t))a.reject(e);t.length=0}),this.on("error",e=>{for(let a of(r=!0,t))a.reject(e);t.length=0}),{next:async()=>e.length?{value:e.shift(),done:!1}:r?{value:void 0,done:!0}:new Promise((e,r)=>t.push({resolve:e,reject:r})).then(e=>e?{value:e,done:!1}:{value:void 0,done:!0}),return:async()=>(this.abort(),{value:void 0,done:!0})}}toReadableStream(){return new tn(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}}class t1 extends Error{constructor(e){super("string"==typeof e?e:e.map(e=>"text"===e.type?e.text:`[${e.type}]`).join(" ")),this.name="ToolError",this.content=e}}let t2=`You have been working on the task described above but have not yet completed it. Write a continuation summary that will allow you (or another instance of yourself) to resume work efficiently in a future context window where the conversation history will be replaced with this summary. Your summary should be structured, concise, and actionable. Include:
|
|
@@ -38,7 +26,19 @@ Any promises made to the user
|
|
|
38
26
|
Be concise but complete—err on the side of including information that would prevent duplicate work or repeated mistakes. Write in a way that enables immediate resumption of the task.
|
|
39
27
|
Wrap your summary in <summary></summary> tags.`;function t4(){let e,t;return{promise:new Promise((r,a)=>{e=r,t=a}),resolve:e,reject:t}}class t9{constructor(e,t,r){A.add(this),this.client=e,N.set(this,!1),M.set(this,!1),$.set(this,void 0),P.set(this,void 0),j.set(this,void 0),F.set(this,void 0),z.set(this,void 0),D.set(this,0),eb(this,$,{params:{...t,messages:structuredClone(t.messages)}},"f");let a=["BetaToolRunner",...tP(t.tools,t.messages)].join(", ");eb(this,P,{...r,headers:tN([{"x-stainless-helper":a},r?.headers])},"f"),eb(this,z,t4(),"f")}async *[(N=new WeakMap,M=new WeakMap,$=new WeakMap,P=new WeakMap,j=new WeakMap,F=new WeakMap,z=new WeakMap,D=new WeakMap,A=new WeakSet,q=async function(){let e=ew(this,$,"f").params.compactionControl;if(!e||!e.enabled)return!1;let t=0;if(void 0!==ew(this,j,"f"))try{let e=await ew(this,j,"f");t=e.usage.input_tokens+(e.usage.cache_creation_input_tokens??0)+(e.usage.cache_read_input_tokens??0)+e.usage.output_tokens}catch{return!1}if(t<(e.contextTokenThreshold??1e5))return!1;let r=e.model??ew(this,$,"f").params.model,a=e.summaryPrompt??t2,n=ew(this,$,"f").params.messages;if("assistant"===n[n.length-1].role){let e=n[n.length-1];if(Array.isArray(e.content)){let t=e.content.filter(e=>"tool_use"!==e.type);0===t.length?n.pop():e.content=t}}let o=await this.client.beta.messages.create({model:r,messages:[...n,{role:"user",content:[{type:"text",text:a}]}],max_tokens:ew(this,$,"f").params.max_tokens},{headers:{"x-stainless-helper":"compaction"}});if(o.content[0]?.type!=="text")throw new eT("Expected text response for compaction");return ew(this,$,"f").params.messages=[{role:"user",content:o.content}],!0},Symbol.asyncIterator)](){var e;if(ew(this,N,"f"))throw new eT("Cannot iterate over a consumed stream");eb(this,N,!0,"f"),eb(this,M,!0,"f"),eb(this,F,void 0,"f");try{for(;;){let t;try{if(ew(this,$,"f").params.max_iterations&&ew(this,D,"f")>=ew(this,$,"f").params.max_iterations)break;eb(this,M,!1,"f"),eb(this,F,void 0,"f"),eb(this,D,(e=ew(this,D,"f"),++e),"f"),eb(this,j,void 0,"f");let{max_iterations:r,compactionControl:a,...n}=ew(this,$,"f").params;if(n.stream?(t=this.client.beta.messages.stream({...n},ew(this,P,"f")),eb(this,j,t.finalMessage(),"f"),ew(this,j,"f").catch(()=>{}),yield t):(eb(this,j,this.client.beta.messages.create({...n,stream:!1},ew(this,P,"f")),"f"),yield ew(this,j,"f")),!await ew(this,A,"m",q).call(this)){if(!ew(this,M,"f")){let{role:e,content:t}=await ew(this,j,"f");ew(this,$,"f").params.messages.push({role:e,content:t})}let e=await ew(this,A,"m",U).call(this,ew(this,$,"f").params.messages.at(-1));if(e)ew(this,$,"f").params.messages.push(e);else if(!ew(this,M,"f"))break}}finally{t&&t.abort()}}if(!ew(this,j,"f"))throw new eT("ToolRunner concluded without a message from the server");ew(this,z,"f").resolve(await ew(this,j,"f"))}catch(e){throw eb(this,N,!1,"f"),ew(this,z,"f").promise.catch(()=>{}),ew(this,z,"f").reject(e),eb(this,z,t4(),"f"),e}}setMessagesParams(e){"function"==typeof e?ew(this,$,"f").params=e(ew(this,$,"f").params):ew(this,$,"f").params=e,eb(this,M,!0,"f"),eb(this,F,void 0,"f")}async generateToolResponse(){let e=await ew(this,j,"f")??this.params.messages.at(-1);return e?ew(this,A,"m",U).call(this,e):null}done(){return ew(this,z,"f").promise}async runUntilDone(){if(!ew(this,N,"f"))for await(let e of this);return this.done()}get params(){return ew(this,$,"f").params}pushMessages(...e){this.setMessagesParams(t=>({...t,messages:[...t.messages,...e]}))}then(e,t){return this.runUntilDone().then(e,t)}}async function t5(e,t=e.messages.at(-1)){if(!t||"assistant"!==t.role||!t.content||"string"==typeof t.content)return null;let r=t.content.filter(e=>"tool_use"===e.type);return 0===r.length?null:{role:"user",content:await Promise.all(r.map(async t=>{let r=e.tools.find(e=>("name"in e?e.name:e.mcp_server_name)===t.name);if(!r||!("run"in r))return{type:"tool_result",tool_use_id:t.id,content:`Error: Tool '${t.name}' not found`,is_error:!0};try{let e=t.input;"parse"in r&&r.parse&&(e=r.parse(e));let a=await r.run(e);return{type:"tool_result",tool_use_id:t.id,content:a}}catch(e){return{type:"tool_result",tool_use_id:t.id,content:e instanceof t1?e.content:`Error: ${e instanceof Error?e.message:String(e)}`,is_error:!0}}}))}}U=async function(e){return void 0!==ew(this,F,"f")||eb(this,F,t5(ew(this,$,"f").params,e),"f"),ew(this,F,"f")};class t6{constructor(e,t){this.iterator=e,this.controller=t}async *decoder(){let e=new e5;for await(let t of this.iterator)for(let r of e.decode(t))yield JSON.parse(r);for(let t of e.flush())yield JSON.parse(t)}[Symbol.asyncIterator](){return this.decoder()}static fromResponse(e,t){if(!e.body){if(t.abort(),void 0!==globalThis.navigator&&"ReactNative"===globalThis.navigator.product)throw new eT("The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api");throw new eT("Attempted to iterate over a response with no body")}return new t6(e0(e.body),t)}}class t3 extends tO{create(e,t){let{betas:r,...a}=e;return this._client.post("/v1/messages/batches?beta=true",{body:a,...t,headers:tN([{"anthropic-beta":[...r??[],"message-batches-2024-09-24"].toString()},t?.headers])})}retrieve(e,t={},r){let{betas:a}=t??{};return this._client.get(tD`/v1/messages/batches/${e}?beta=true`,{...r,headers:tN([{"anthropic-beta":[...a??[],"message-batches-2024-09-24"].toString()},r?.headers])})}list(e={},t){let{betas:r,...a}=e??{};return this._client.getAPIList("/v1/messages/batches?beta=true",th,{query:a,...t,headers:tN([{"anthropic-beta":[...r??[],"message-batches-2024-09-24"].toString()},t?.headers])})}delete(e,t={},r){let{betas:a}=t??{};return this._client.delete(tD`/v1/messages/batches/${e}?beta=true`,{...r,headers:tN([{"anthropic-beta":[...a??[],"message-batches-2024-09-24"].toString()},r?.headers])})}cancel(e,t={},r){let{betas:a}=t??{};return this._client.post(tD`/v1/messages/batches/${e}/cancel?beta=true`,{...r,headers:tN([{"anthropic-beta":[...a??[],"message-batches-2024-09-24"].toString()},r?.headers])})}async results(e,t={},r){let a=await this.retrieve(e);if(!a.results_url)throw new eT(`No batch \`results_url\`; Has it finished processing? ${a.processing_status} - ${a.id}`);let{betas:n}=t??{};return this._client.get(a.results_url,{...r,headers:tN([{"anthropic-beta":[...n??[],"message-batches-2024-09-24"].toString(),Accept:"application/binary"},r?.headers]),stream:!0,__binaryResponse:!0})._thenUnwrap((e,t)=>t6.fromResponse(t.response,t.controller))}}let t7={"claude-1.3":"November 6th, 2024","claude-1.3-100k":"November 6th, 2024","claude-instant-1.1":"November 6th, 2024","claude-instant-1.1-100k":"November 6th, 2024","claude-instant-1.2":"November 6th, 2024","claude-3-sonnet-20240229":"July 21st, 2025","claude-3-opus-20240229":"January 5th, 2026","claude-2.1":"July 21st, 2025","claude-2.0":"July 21st, 2025","claude-3-7-sonnet-latest":"February 19th, 2026","claude-3-7-sonnet-20250219":"February 19th, 2026"},t8=["claude-opus-4-6"];class re extends tO{constructor(){super(...arguments),this.batches=new t3(this._client)}create(e,t){let r=rt(e),{betas:a,...n}=r;n.model in t7&&console.warn(`The model '${n.model}' is deprecated and will reach end-of-life on ${t7[n.model]}
|
|
40
28
|
Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.`),n.model in t8&&n.thinking&&"enabled"===n.thinking.type&&console.warn(`Using Claude with ${n.model} and 'thinking.type=enabled' is deprecated. Use 'thinking.type=adaptive' instead which results in better model performance in our testing: https://platform.claude.com/docs/en/build-with-claude/adaptive-thinking`);let o=this._client._options.timeout;if(!n.stream&&null==o){let e=tL[n.model]??void 0;o=this._client.calculateNonstreamingTimeout(n.max_tokens,e)}let i=tj(n.tools,n.messages);return this._client.post("/v1/messages?beta=true",{body:n,timeout:o??6e5,...t,headers:tN([{...a?.toString()!=null?{"anthropic-beta":a?.toString()}:void 0},i,t?.headers]),stream:r.stream??!1})}parse(e,t){return t={...t,headers:tN([{"anthropic-beta":[...e.betas??[],"structured-outputs-2025-12-15"].toString()},t?.headers])},this.create(e,t).then(t=>tW(t,e,{logger:this._client.logger??console}))}stream(e,t){return t0.createMessage(this,e,t)}countTokens(e,t){let{betas:r,...a}=rt(e);return this._client.post("/v1/messages/count_tokens?beta=true",{body:a,...t,headers:tN([{"anthropic-beta":[...r??[],"token-counting-2024-11-01"].toString()},t?.headers])})}toolRunner(e,t){return new t9(this._client,e,t)}}function rt(e){if(!e.output_format)return e;if(e.output_config?.format)throw new eT("Both output_format and output_config.format were provided. Please use only output_config.format (output_format is deprecated).");let{output_format:t,...r}=e;return{...r,output_config:{...e.output_config,format:t}}}re.Batches=t3,re.BetaToolRunner=t9,re.ToolError=t1;class rr extends tO{create(e,t={},r){let{betas:a,...n}=t??{};return this._client.post(tD`/v1/skills/${e}/versions?beta=true`,tv({body:n,...r,headers:tN([{"anthropic-beta":[...a??[],"skills-2025-10-02"].toString()},r?.headers])},this._client))}retrieve(e,t,r){let{skill_id:a,betas:n}=t;return this._client.get(tD`/v1/skills/${a}/versions/${e}?beta=true`,{...r,headers:tN([{"anthropic-beta":[...n??[],"skills-2025-10-02"].toString()},r?.headers])})}list(e,t={},r){let{betas:a,...n}=t??{};return this._client.getAPIList(tD`/v1/skills/${e}/versions?beta=true`,tm,{query:n,...r,headers:tN([{"anthropic-beta":[...a??[],"skills-2025-10-02"].toString()},r?.headers])})}delete(e,t,r){let{skill_id:a,betas:n}=t;return this._client.delete(tD`/v1/skills/${a}/versions/${e}?beta=true`,{...r,headers:tN([{"anthropic-beta":[...n??[],"skills-2025-10-02"].toString()},r?.headers])})}}class ra extends tO{constructor(){super(...arguments),this.versions=new rr(this._client)}create(e={},t){let{betas:r,...a}=e??{};return this._client.post("/v1/skills?beta=true",tv({body:a,...t,headers:tN([{"anthropic-beta":[...r??[],"skills-2025-10-02"].toString()},t?.headers])},this._client,!1))}retrieve(e,t={},r){let{betas:a}=t??{};return this._client.get(tD`/v1/skills/${e}?beta=true`,{...r,headers:tN([{"anthropic-beta":[...a??[],"skills-2025-10-02"].toString()},r?.headers])})}list(e={},t){let{betas:r,...a}=e??{};return this._client.getAPIList("/v1/skills?beta=true",tm,{query:a,...t,headers:tN([{"anthropic-beta":[...r??[],"skills-2025-10-02"].toString()},t?.headers])})}delete(e,t={},r){let{betas:a}=t??{};return this._client.delete(tD`/v1/skills/${e}?beta=true`,{...r,headers:tN([{"anthropic-beta":[...a??[],"skills-2025-10-02"].toString()},r?.headers])})}}ra.Versions=rr;class rn extends tO{constructor(){super(...arguments),this.models=new tU(this._client),this.messages=new re(this._client),this.files=new tq(this._client),this.skills=new ra(this._client)}}rn.Models=tU,rn.Messages=re,rn.Files=tq,rn.Skills=ra;class ro extends tO{create(e,t){let{betas:r,...a}=e;return this._client.post("/v1/complete",{body:a,timeout:this._client._options.timeout??6e5,...t,headers:tN([{...r?.toString()!=null?{"anthropic-beta":r?.toString()}:void 0},t?.headers]),stream:e.stream??!1})}}function ri(e){return e?.output_config?.format}function rs(e,t,r){let a=ri(t);return t&&"parse"in(a??{})?rl(e,t,r):{...e,content:e.content.map(e=>"text"===e.type?Object.defineProperty({...e},"parsed_output",{value:null,enumerable:!1}):e),parsed_output:null}}function rl(e,t,r){let a=null,n=e.content.map(e=>{if("text"===e.type){let r=function(e,t){let r=ri(e);if(r?.type!=="json_schema")return null;try{if("parse"in r)return r.parse(t);return JSON.parse(t)}catch(e){throw new eT(`Failed to parse structured output: ${e}`)}}(t,e.text);return null===a&&(a=r),Object.defineProperty({...e},"parsed_output",{value:r,enumerable:!1})}return e});return{...e,content:n,parsed_output:a}}let ru="__json_buf";function rd(e){return"tool_use"===e.type||"server_tool_use"===e.type}class rc{constructor(e,t){L.add(this),this.messages=[],this.receivedMessages=[],V.set(this,void 0),G.set(this,null),this.controller=new AbortController,W.set(this,void 0),X.set(this,()=>{}),B.set(this,()=>{}),K.set(this,void 0),J.set(this,()=>{}),H.set(this,()=>{}),Y.set(this,{}),Q.set(this,!1),ee.set(this,!1),et.set(this,!1),er.set(this,!1),ea.set(this,void 0),en.set(this,void 0),eo.set(this,void 0),el.set(this,e=>{if(eb(this,ee,!0,"f"),ek(e)&&(e=new eS),e instanceof eS)return eb(this,et,!0,"f"),this._emit("abort",e);if(e instanceof eT)return this._emit("error",e);if(e instanceof Error){let t=new eT(e.message);return t.cause=e,this._emit("error",t)}return this._emit("error",new eT(String(e)))}),eb(this,W,new Promise((e,t)=>{eb(this,X,e,"f"),eb(this,B,t,"f")}),"f"),eb(this,K,new Promise((e,t)=>{eb(this,J,e,"f"),eb(this,H,t,"f")}),"f"),ew(this,W,"f").catch(()=>{}),ew(this,K,"f").catch(()=>{}),eb(this,G,e,"f"),eb(this,eo,t?.logger??console,"f")}get response(){return ew(this,ea,"f")}get request_id(){return ew(this,en,"f")}async withResponse(){eb(this,er,!0,"f");let e=await ew(this,W,"f");if(!e)throw Error("Could not resolve a `Response` object");return{data:this,response:e,request_id:e.headers.get("request-id")}}static fromReadableStream(e){let t=new rc(null);return t._run(()=>t._fromReadableStream(e)),t}static createMessage(e,t,r,{logger:a}={}){let n=new rc(t,{logger:a});for(let e of t.messages)n._addMessageParam(e);return eb(n,G,{...t,stream:!0},"f"),n._run(()=>n._createMessage(e,{...t,stream:!0},{...r,headers:{...r?.headers,"X-Stainless-Helper-Method":"stream"}})),n}_run(e){e().then(()=>{this._emitFinal(),this._emit("end")},ew(this,el,"f"))}_addMessageParam(e){this.messages.push(e)}_addMessage(e,t=!0){this.receivedMessages.push(e),t&&this._emit("message",e)}async _createMessage(e,t,r){let a;let n=r?.signal;n&&(n.aborted&&this.controller.abort(),a=this.controller.abort.bind(this.controller),n.addEventListener("abort",a));try{ew(this,L,"m",eu).call(this);let{response:a,data:n}=await e.create({...t,stream:!0},{...r,signal:this.controller.signal}).withResponse();for await(let e of(this._connected(a),n))ew(this,L,"m",ed).call(this,e);if(n.controller.signal?.aborted)throw new eS;ew(this,L,"m",ec).call(this)}finally{n&&a&&n.removeEventListener("abort",a)}}_connected(e){this.ended||(eb(this,ea,e,"f"),eb(this,en,e?.headers.get("request-id"),"f"),ew(this,X,"f").call(this,e),this._emit("connect"))}get ended(){return ew(this,Q,"f")}get errored(){return ew(this,ee,"f")}get aborted(){return ew(this,et,"f")}abort(){this.controller.abort()}on(e,t){return(ew(this,Y,"f")[e]||(ew(this,Y,"f")[e]=[])).push({listener:t}),this}off(e,t){let r=ew(this,Y,"f")[e];if(!r)return this;let a=r.findIndex(e=>e.listener===t);return a>=0&&r.splice(a,1),this}once(e,t){return(ew(this,Y,"f")[e]||(ew(this,Y,"f")[e]=[])).push({listener:t,once:!0}),this}emitted(e){return new Promise((t,r)=>{eb(this,er,!0,"f"),"error"!==e&&this.once("error",r),this.once(e,t)})}async done(){eb(this,er,!0,"f"),await ew(this,K,"f")}get currentMessage(){return ew(this,V,"f")}async finalMessage(){return await this.done(),ew(this,L,"m",ei).call(this)}async finalText(){return await this.done(),ew(this,L,"m",es).call(this)}_emit(e,...t){if(ew(this,Q,"f"))return;"end"===e&&(eb(this,Q,!0,"f"),ew(this,J,"f").call(this));let r=ew(this,Y,"f")[e];if(r&&(ew(this,Y,"f")[e]=r.filter(e=>!e.once),r.forEach(({listener:e})=>e(...t))),"abort"===e){let e=t[0];ew(this,er,"f")||r?.length||Promise.reject(e),ew(this,B,"f").call(this,e),ew(this,H,"f").call(this,e),this._emit("end");return}if("error"===e){let e=t[0];ew(this,er,"f")||r?.length||Promise.reject(e),ew(this,B,"f").call(this,e),ew(this,H,"f").call(this,e),this._emit("end")}}_emitFinal(){this.receivedMessages.at(-1)&&this._emit("finalMessage",ew(this,L,"m",ei).call(this))}async _fromReadableStream(e,t){let r;let a=t?.signal;a&&(a.aborted&&this.controller.abort(),r=this.controller.abort.bind(this.controller),a.addEventListener("abort",r));try{ew(this,L,"m",eu).call(this),this._connected(null);let t=tn.fromReadableStream(e,this.controller);for await(let e of t)ew(this,L,"m",ed).call(this,e);if(t.controller.signal?.aborted)throw new eS;ew(this,L,"m",ec).call(this)}finally{a&&r&&a.removeEventListener("abort",r)}}[(V=new WeakMap,G=new WeakMap,W=new WeakMap,X=new WeakMap,B=new WeakMap,K=new WeakMap,J=new WeakMap,H=new WeakMap,Y=new WeakMap,Q=new WeakMap,ee=new WeakMap,et=new WeakMap,er=new WeakMap,ea=new WeakMap,en=new WeakMap,eo=new WeakMap,el=new WeakMap,L=new WeakSet,ei=function(){if(0===this.receivedMessages.length)throw new eT("stream ended without producing a Message with role=assistant");return this.receivedMessages.at(-1)},es=function(){if(0===this.receivedMessages.length)throw new eT("stream ended without producing a Message with role=assistant");let e=this.receivedMessages.at(-1).content.filter(e=>"text"===e.type).map(e=>e.text);if(0===e.length)throw new eT("stream ended without producing a content block with type=text");return e.join(" ")},eu=function(){this.ended||eb(this,V,void 0,"f")},ed=function(e){if(this.ended)return;let t=ew(this,L,"m",ep).call(this,e);switch(this._emit("streamEvent",e,t),e.type){case"content_block_delta":{let r=t.content.at(-1);switch(e.delta.type){case"text_delta":"text"===r.type&&this._emit("text",e.delta.text,r.text||"");break;case"citations_delta":"text"===r.type&&this._emit("citation",e.delta.citation,r.citations??[]);break;case"input_json_delta":rd(r)&&r.input&&this._emit("inputJson",e.delta.partial_json,r.input);break;case"thinking_delta":"thinking"===r.type&&this._emit("thinking",e.delta.thinking,r.thinking);break;case"signature_delta":"thinking"===r.type&&this._emit("signature",r.signature);break;default:e.delta}break}case"message_stop":this._addMessageParam(t),this._addMessage(rs(t,ew(this,G,"f"),{logger:ew(this,eo,"f")}),!0);break;case"content_block_stop":this._emit("contentBlock",t.content.at(-1));break;case"message_start":eb(this,V,t,"f")}},ec=function(){if(this.ended)throw new eT("stream has ended, this shouldn't happen");let e=ew(this,V,"f");if(!e)throw new eT("request ended without sending any chunks");return eb(this,V,void 0,"f"),rs(e,ew(this,G,"f"),{logger:ew(this,eo,"f")})},ep=function(e){let t=ew(this,V,"f");if("message_start"===e.type){if(t)throw new eT(`Unexpected event order, got ${e.type} before receiving "message_stop"`);return e.message}if(!t)throw new eT(`Unexpected event order, got ${e.type} before "message_start"`);switch(e.type){case"message_stop":case"content_block_stop":return t;case"message_delta":return t.stop_reason=e.delta.stop_reason,t.stop_sequence=e.delta.stop_sequence,t.usage.output_tokens=e.usage.output_tokens,null!=e.usage.input_tokens&&(t.usage.input_tokens=e.usage.input_tokens),null!=e.usage.cache_creation_input_tokens&&(t.usage.cache_creation_input_tokens=e.usage.cache_creation_input_tokens),null!=e.usage.cache_read_input_tokens&&(t.usage.cache_read_input_tokens=e.usage.cache_read_input_tokens),null!=e.usage.server_tool_use&&(t.usage.server_tool_use=e.usage.server_tool_use),t;case"content_block_start":return t.content.push({...e.content_block}),t;case"content_block_delta":{let r=t.content.at(e.index);switch(e.delta.type){case"text_delta":r?.type==="text"&&(t.content[e.index]={...r,text:(r.text||"")+e.delta.text});break;case"citations_delta":r?.type==="text"&&(t.content[e.index]={...r,citations:[...r.citations??[],e.delta.citation]});break;case"input_json_delta":if(r&&rd(r)){let a=r[ru]||"";a+=e.delta.partial_json;let n={...r};Object.defineProperty(n,ru,{value:a,enumerable:!1,writable:!0}),a&&(n.input=tH(a)),t.content[e.index]=n}break;case"thinking_delta":r?.type==="thinking"&&(t.content[e.index]={...r,thinking:r.thinking+e.delta.thinking});break;case"signature_delta":r?.type==="thinking"&&(t.content[e.index]={...r,signature:e.delta.signature});break;default:e.delta}return t}}},Symbol.asyncIterator)](){let e=[],t=[],r=!1;return this.on("streamEvent",r=>{let a=t.shift();a?a.resolve(r):e.push(r)}),this.on("end",()=>{for(let e of(r=!0,t))e.resolve(void 0);t.length=0}),this.on("abort",e=>{for(let a of(r=!0,t))a.reject(e);t.length=0}),this.on("error",e=>{for(let a of(r=!0,t))a.reject(e);t.length=0}),{next:async()=>e.length?{value:e.shift(),done:!1}:r?{value:void 0,done:!0}:new Promise((e,r)=>t.push({resolve:e,reject:r})).then(e=>e?{value:e,done:!1}:{value:void 0,done:!0}),return:async()=>(this.abort(),{value:void 0,done:!0})}}toReadableStream(){return new tn(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}}class rp extends tO{create(e,t){return this._client.post("/v1/messages/batches",{body:e,...t})}retrieve(e,t){return this._client.get(tD`/v1/messages/batches/${e}`,t)}list(e={},t){return this._client.getAPIList("/v1/messages/batches",th,{query:e,...t})}delete(e,t){return this._client.delete(tD`/v1/messages/batches/${e}`,t)}cancel(e,t){return this._client.post(tD`/v1/messages/batches/${e}/cancel`,t)}async results(e,t){let r=await this.retrieve(e);if(!r.results_url)throw new eT(`No batch \`results_url\`; Has it finished processing? ${r.processing_status} - ${r.id}`);return this._client.get(r.results_url,{...t,headers:tN([{Accept:"application/binary"},t?.headers]),stream:!0,__binaryResponse:!0})._thenUnwrap((e,t)=>t6.fromResponse(t.response,t.controller))}}class rh extends tO{constructor(){super(...arguments),this.batches=new rp(this._client)}create(e,t){e.model in rm&&console.warn(`The model '${e.model}' is deprecated and will reach end-of-life on ${rm[e.model]}
|
|
41
|
-
Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.`),e.model in rf&&e.thinking&&"enabled"===e.thinking.type&&console.warn(`Using Claude with ${e.model} and 'thinking.type=enabled' is deprecated. Use 'thinking.type=adaptive' instead which results in better model performance in our testing: https://platform.claude.com/docs/en/build-with-claude/adaptive-thinking`);let r=this._client._options.timeout;if(!e.stream&&null==r){let t=tL[e.model]??void 0;r=this._client.calculateNonstreamingTimeout(e.max_tokens,t)}let a=tj(e.tools,e.messages);return this._client.post("/v1/messages",{body:e,timeout:r??6e5,...t,headers:tN([a,t?.headers]),stream:e.stream??!1})}parse(e,t){return this.create(e,t).then(t=>rl(t,e,{logger:this._client.logger??console}))}stream(e,t){return rc.createMessage(this,e,t,{logger:this._client.logger??console})}countTokens(e,t){return this._client.post("/v1/messages/count_tokens",{body:e,...t})}}let rm={"claude-1.3":"November 6th, 2024","claude-1.3-100k":"November 6th, 2024","claude-instant-1.1":"November 6th, 2024","claude-instant-1.1-100k":"November 6th, 2024","claude-instant-1.2":"November 6th, 2024","claude-3-sonnet-20240229":"July 21st, 2025","claude-3-opus-20240229":"January 5th, 2026","claude-2.1":"July 21st, 2025","claude-2.0":"July 21st, 2025","claude-3-7-sonnet-latest":"February 19th, 2026","claude-3-7-sonnet-20250219":"February 19th, 2026","claude-3-5-haiku-latest":"February 19th, 2026","claude-3-5-haiku-20241022":"February 19th, 2026"},rf=["claude-opus-4-6"];rh.Batches=rp;class ry extends tO{retrieve(e,t={},r){let{betas:a}=t??{};return this._client.get(tD`/v1/models/${e}`,{...r,headers:tN([{...a?.toString()!=null?{"anthropic-beta":a?.toString()}:void 0},r?.headers])})}list(e={},t){let{betas:r,...a}=e??{};return this._client.getAPIList("/v1/models",th,{query:a,...t,headers:tN([{...r?.toString()!=null?{"anthropic-beta":r?.toString()}:void 0},t?.headers])})}}let r_=e=>void 0!==globalThis.process?globalThis.process.env?.[e]?.trim()??void 0:void 0!==globalThis.Deno?globalThis.Deno.env?.get?.(e)?.trim():void 0;class rg{constructor({baseURL:e=r_("ANTHROPIC_BASE_URL"),apiKey:t=r_("ANTHROPIC_API_KEY")??null,authToken:r=r_("ANTHROPIC_AUTH_TOKEN")??null,...a}={}){eh.add(this),ef.set(this,void 0);let n={apiKey:t,authToken:r,...a,baseURL:e||"https://api.anthropic.com"};if(!n.dangerouslyAllowBrowser&&eX())throw new eT("It looks like you're running in a browser-like environment.\n\nThis is disabled by default, as it risks exposing your secret API credentials to attackers.\nIf you understand the risks and have appropriate mitigations in place,\nyou can set the `dangerouslyAllowBrowser` option to `true`, e.g.,\n\nnew Anthropic({ apiKey, dangerouslyAllowBrowser: true });\n");this.baseURL=n.baseURL,this.timeout=n.timeout??em.DEFAULT_TIMEOUT,this.logger=n.logger??console;let o="warn";this.logLevel=o,this.logLevel=e3(n.logLevel,"ClientOptions.logLevel",this)??e3(r_("ANTHROPIC_LOG"),"process.env['ANTHROPIC_LOG']",this)??o,this.fetchOptions=n.fetchOptions,this.maxRetries=n.maxRetries??2,this.fetch=n.fetch??function(){if("undefined"!=typeof fetch)return fetch;throw Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new Anthropic({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}(),eb(this,ef,e2,"f"),this._options=n,this.apiKey="string"==typeof t?t:null,this.authToken=r}withOptions(e){return new this.constructor({...this._options,baseURL:this.baseURL,maxRetries:this.maxRetries,timeout:this.timeout,logger:this.logger,logLevel:this.logLevel,fetch:this.fetch,fetchOptions:this.fetchOptions,apiKey:this.apiKey,authToken:this.authToken,...e})}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:e,nulls:t}){if(!(e.get("x-api-key")||e.get("authorization")||this.apiKey&&e.get("x-api-key")||t.has("x-api-key")||this.authToken&&e.get("authorization")||t.has("authorization")))throw Error('Could not resolve authentication method. Expected either apiKey or authToken to be set. Or for one of the "X-Api-Key" or "Authorization" headers to be explicitly omitted')}async authHeaders(e){return tN([await this.apiKeyAuth(e),await this.bearerAuth(e)])}async apiKeyAuth(e){if(null!=this.apiKey)return tN([{"X-Api-Key":this.apiKey}])}async bearerAuth(e){if(null!=this.authToken)return tN([{Authorization:`Bearer ${this.authToken}`}])}stringifyQuery(e){return Object.entries(e).filter(([e,t])=>void 0!==t).map(([e,t])=>{if("string"==typeof t||"number"==typeof t||"boolean"==typeof t)return`${encodeURIComponent(e)}=${encodeURIComponent(t)}`;if(null===t)return`${encodeURIComponent(e)}=`;throw new eT(`Cannot stringify type ${typeof t}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`)}).join("&")}getUserAgent(){return`${this.constructor.name}/JS ${eW}`}defaultIdempotencyKey(){return`stainless-node-retry-${ex()}`}makeStatusError(e,t,r,a){return eR.generate(e,t,r,a)}buildURL(e,t,r){let a=!ew(this,eh,"m",ey).call(this)&&r||this.baseURL,n=new URL(ez(e)?e:a+(a.endsWith("/")&&e.startsWith("/")?e.slice(1):e)),o=this.defaultQuery();return!function(e){if(!e)return!0;for(let t in e)return!1;return!0}(o)&&(t={...o,...t}),"object"==typeof t&&t&&!Array.isArray(t)&&(n.search=this.stringifyQuery(t)),n.toString()}_calculateNonstreamingTimeout(e){if(3600*e/128e3>600)throw new eT("Streaming is required for operations that may take longer than 10 minutes. See https://github.com/anthropics/anthropic-sdk-typescript#streaming-responses for more details");return 6e5}async prepareOptions(e){}async prepareRequest(e,{url:t,options:r}){}get(e,t){return this.methodRequest("get",e,t)}post(e,t){return this.methodRequest("post",e,t)}patch(e,t){return this.methodRequest("patch",e,t)}put(e,t){return this.methodRequest("put",e,t)}delete(e,t){return this.methodRequest("delete",e,t)}methodRequest(e,t,r){return this.request(Promise.resolve(r).then(r=>({method:e,path:t,...r})))}request(e,t=null){return new td(this,this.makeRequest(e,t,void 0))}async makeRequest(e,t,r){let a=await e,n=a.maxRetries??this.maxRetries;null==t&&(t=n),await this.prepareOptions(a);let{req:o,url:i,timeout:s}=await this.buildRequest(a,{retryCount:n-t});await this.prepareRequest(o,{url:i,options:a});let l="log_"+(16777216*Math.random()|0).toString(16).padStart(6,"0"),u=void 0===r?"":`, retryOf: ${r}`,d=Date.now();if(tr(this).debug(`[${l}] sending request`,ta({retryOfRequestLogID:r,method:a.method,url:i,options:a,headers:o.headers})),a.signal?.aborted)throw new eS;let c=new AbortController,p=await this.fetchWithTimeout(i,o,s,c).catch(eI),h=Date.now();if(p instanceof globalThis.Error){let e=`retrying, ${t} attempts remaining`;if(a.signal?.aborted)throw new eS;let n=ek(p)||/timed? ?out/i.test(String(p)+("cause"in p?String(p.cause):""));if(t)return tr(this).info(`[${l}] connection ${n?"timed out":"failed"} - ${e}`),tr(this).debug(`[${l}] connection ${n?"timed out":"failed"} (${e})`,ta({retryOfRequestLogID:r,url:i,durationMs:h-d,message:p.message})),this.retryRequest(a,t,r??l);if(tr(this).info(`[${l}] connection ${n?"timed out":"failed"} - error; no more retries left`),tr(this).debug(`[${l}] connection ${n?"timed out":"failed"} (error; no more retries left)`,ta({retryOfRequestLogID:r,url:i,durationMs:h-d,message:p.message})),n)throw new eC;throw new eZ({cause:p})}let m=[...p.headers.entries()].filter(([e])=>"request-id"===e).map(([e,t])=>", "+e+": "+JSON.stringify(t)).join(""),f=`[${l}${u}${m}] ${o.method} ${i} ${p.ok?"succeeded":"failed"} with status ${p.status} in ${h-d}ms`;if(!p.ok){let e=await this.shouldRetry(p);if(t&&e){let e=`retrying, ${t} attempts remaining`;return await e1(p.body),tr(this).info(`${f} - ${e}`),tr(this).debug(`[${l}] response error (${e})`,ta({retryOfRequestLogID:r,url:p.url,status:p.status,headers:p.headers,durationMs:h-d})),this.retryRequest(a,t,r??l,p.headers)}let n=e?"error; no more retries left":"error; not retryable";tr(this).info(`${f} - ${n}`);let o=await p.text().catch(e=>eI(e).message),i=eV(o),s=i?void 0:o;throw tr(this).debug(`[${l}] response error (${n})`,ta({retryOfRequestLogID:r,url:p.url,status:p.status,headers:p.headers,message:s,durationMs:Date.now()-d})),this.makeStatusError(p.status,i,s,p.headers)}return tr(this).info(f),tr(this).debug(`[${l}] response start`,ta({retryOfRequestLogID:r,url:p.url,status:p.status,headers:p.headers,durationMs:h-d})),{response:p,options:a,controller:c,requestLogID:l,retryOfRequestLogID:r,startTime:d}}getAPIList(e,t,r){return this.requestAPIList(t,r&&"then"in r?r.then(t=>({method:"get",path:e,...t})):{method:"get",path:e,...r})}requestAPIList(e,t){return new tp(this,this.makeRequest(t,null,void 0),e)}async fetchWithTimeout(e,t,r,a){let{signal:n,method:o,...i}=t||{},s=this._makeAbort(a);n&&n.addEventListener("abort",s,{once:!0});let l=setTimeout(s,r),u=globalThis.ReadableStream&&i.body instanceof globalThis.ReadableStream||"object"==typeof i.body&&null!==i.body&&Symbol.asyncIterator in i.body,d={signal:a.signal,...u?{duplex:"half"}:{},method:"GET",...i};o&&(d.method=o.toUpperCase());try{return await this.fetch.call(void 0,e,d)}finally{clearTimeout(l)}}async shouldRetry(e){let t=e.headers.get("x-should-retry");return"true"===t||"false"!==t&&(408===e.status||409===e.status||429===e.status||e.status>=500)}async retryRequest(e,t,r,a){let n;let o=a?.get("retry-after-ms");if(o){let e=parseFloat(o);Number.isNaN(e)||(n=e)}let i=a?.get("retry-after");if(i&&!n){let e=parseFloat(i);n=Number.isNaN(e)?Date.parse(i)-Date.now():1e3*e}if(!(n&&0<=n&&n<6e4)){let r=e.maxRetries??this.maxRetries;n=this.calculateDefaultRetryTimeoutMillis(t,r)}return await eG(n),this.makeRequest(e,t-1,r)}calculateDefaultRetryTimeoutMillis(e,t){return Math.min(.5*Math.pow(2,t-e),8)*(1-.25*Math.random())*1e3}calculateNonstreamingTimeout(e,t){if(36e5*e/128e3>6e5||null!=t&&e>t)throw new eT("Streaming is required for operations that may take longer than 10 minutes. See https://github.com/anthropics/anthropic-sdk-typescript#long-requests for more details");return 6e5}async buildRequest(e,{retryCount:t=0}={}){let r={...e},{method:a,path:n,query:o,defaultBaseURL:i}=r,s=this.buildURL(n,o,i);"timeout"in r&&eL("timeout",r.timeout),r.timeout=r.timeout??this.timeout;let{bodyHeaders:l,body:u}=this.buildBody({options:r}),d=await this.buildHeaders({options:e,method:a,bodyHeaders:l,retryCount:t});return{req:{method:a,headers:d,...r.signal&&{signal:r.signal},...globalThis.ReadableStream&&u instanceof globalThis.ReadableStream&&{duplex:"half"},...u&&{body:u},...this.fetchOptions??{},...r.fetchOptions??{}},url:s,timeout:r.timeout}}async buildHeaders({options:e,method:t,bodyHeaders:r,retryCount:a}){let n={};this.idempotencyHeader&&"get"!==t&&(e.idempotencyKey||(e.idempotencyKey=this.defaultIdempotencyKey()),n[this.idempotencyHeader]=e.idempotencyKey);let o=tN([n,{Accept:"application/json","User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String(a),...e.timeout?{"X-Stainless-Timeout":String(Math.trunc(e.timeout/1e3))}:{},...eH(),...this._options.dangerouslyAllowBrowser?{"anthropic-dangerous-direct-browser-access":"true"}:void 0,"anthropic-version":"2023-06-01"},await this.authHeaders(e),this._options.defaultHeaders,r,e.headers]);return this.validateHeaders(o),o.values}_makeAbort(e){return()=>e.abort()}buildBody({options:{body:e,headers:t}}){if(!e)return{bodyHeaders:void 0,body:void 0};let r=tN([t]);return ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof DataView||"string"==typeof e&&r.values.has("content-type")||globalThis.Blob&&e instanceof globalThis.Blob||e instanceof FormData||e instanceof URLSearchParams||globalThis.ReadableStream&&e instanceof globalThis.ReadableStream?{bodyHeaders:void 0,body:e}:"object"==typeof e&&(Symbol.asyncIterator in e||Symbol.iterator in e&&"next"in e&&"function"==typeof e.next)?{bodyHeaders:void 0,body:eQ(e)}:"object"==typeof e&&"application/x-www-form-urlencoded"===r.values.get("content-type")?{bodyHeaders:{"content-type":"application/x-www-form-urlencoded"},body:this.stringifyQuery(e)}:ew(this,ef,"f").call(this,{body:e,headers:r})}}em=rg,ef=new WeakMap,eh=new WeakSet,ey=function(){return"https://api.anthropic.com"!==this.baseURL},rg.Anthropic=em,rg.HUMAN_PROMPT="\\n\\nHuman:",rg.AI_PROMPT="\\n\\nAssistant:",rg.DEFAULT_TIMEOUT=6e5,rg.AnthropicError=eT,rg.APIError=eR,rg.APIConnectionError=eZ,rg.APIConnectionTimeoutError=eC,rg.APIUserAbortError=eS,rg.NotFoundError=eN,rg.ConflictError=eM,rg.RateLimitError=eP,rg.BadRequestError=eE,rg.AuthenticationError=eO,rg.InternalServerError=ej,rg.PermissionDeniedError=eA,rg.UnprocessableEntityError=e$,rg.toFile=tC;class rv extends rg{constructor(){super(...arguments),this.completions=new ro(this),this.messages=new rh(this),this.models=new ry(this),this.beta=new rn(this)}}rv.Completions=ro,rv.Messages=rh,rv.Models=ry,rv.Beta=rn},1041:(e,t,r)=>{r.d(t,{bS:()=>aa,vk:()=>rG,kP:()=>at});var a,n,o,i,s,l,u,d,c,p,h,m,f,y,_,g,v,b,w,x,k,I,T,R,S,Z,C,E,O,A,N,M=r(6365),$=r(9519),P=r(2943),j=r(9763),F=r(489),z=Symbol.for("vercel.ai.gateway.error"),D=class e extends(n=Error,a=z,n){constructor({message:e,statusCode:t=500,cause:r,generationId:n}){super(n?`${e} [${n}]`:e),this[a]=!0,this.statusCode=t,this.cause=r,this.generationId=n}static isInstance(t){return e.hasMarker(t)}static hasMarker(e){return"object"==typeof e&&null!==e&&z in e&&!0===e[z]}},q="GatewayAuthenticationError",U=Symbol.for(`vercel.ai.gateway.error.${q}`),L=class e extends(i=D,o=U,i){constructor({message:e="Authentication failed",statusCode:t=401,cause:r,generationId:a}={}){super({message:e,statusCode:t,cause:r,generationId:a}),this[o]=!0,this.name=q,this.type="authentication_error"}static isInstance(e){return D.hasMarker(e)&&U in e}static createContextualError({apiKeyProvided:t,oidcTokenProvided:r,message:a="Authentication failed",statusCode:n=401,cause:o,generationId:i}){return new e({message:t?`AI Gateway authentication failed: Invalid API key.
|
|
29
|
+
Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.`),e.model in rf&&e.thinking&&"enabled"===e.thinking.type&&console.warn(`Using Claude with ${e.model} and 'thinking.type=enabled' is deprecated. Use 'thinking.type=adaptive' instead which results in better model performance in our testing: https://platform.claude.com/docs/en/build-with-claude/adaptive-thinking`);let r=this._client._options.timeout;if(!e.stream&&null==r){let t=tL[e.model]??void 0;r=this._client.calculateNonstreamingTimeout(e.max_tokens,t)}let a=tj(e.tools,e.messages);return this._client.post("/v1/messages",{body:e,timeout:r??6e5,...t,headers:tN([a,t?.headers]),stream:e.stream??!1})}parse(e,t){return this.create(e,t).then(t=>rl(t,e,{logger:this._client.logger??console}))}stream(e,t){return rc.createMessage(this,e,t,{logger:this._client.logger??console})}countTokens(e,t){return this._client.post("/v1/messages/count_tokens",{body:e,...t})}}let rm={"claude-1.3":"November 6th, 2024","claude-1.3-100k":"November 6th, 2024","claude-instant-1.1":"November 6th, 2024","claude-instant-1.1-100k":"November 6th, 2024","claude-instant-1.2":"November 6th, 2024","claude-3-sonnet-20240229":"July 21st, 2025","claude-3-opus-20240229":"January 5th, 2026","claude-2.1":"July 21st, 2025","claude-2.0":"July 21st, 2025","claude-3-7-sonnet-latest":"February 19th, 2026","claude-3-7-sonnet-20250219":"February 19th, 2026","claude-3-5-haiku-latest":"February 19th, 2026","claude-3-5-haiku-20241022":"February 19th, 2026"},rf=["claude-opus-4-6"];rh.Batches=rp;class ry extends tO{retrieve(e,t={},r){let{betas:a}=t??{};return this._client.get(tD`/v1/models/${e}`,{...r,headers:tN([{...a?.toString()!=null?{"anthropic-beta":a?.toString()}:void 0},r?.headers])})}list(e={},t){let{betas:r,...a}=e??{};return this._client.getAPIList("/v1/models",th,{query:a,...t,headers:tN([{...r?.toString()!=null?{"anthropic-beta":r?.toString()}:void 0},t?.headers])})}}let r_=e=>void 0!==globalThis.process?globalThis.process.env?.[e]?.trim()??void 0:void 0!==globalThis.Deno?globalThis.Deno.env?.get?.(e)?.trim():void 0;class rg{constructor({baseURL:e=r_("ANTHROPIC_BASE_URL"),apiKey:t=r_("ANTHROPIC_API_KEY")??null,authToken:r=r_("ANTHROPIC_AUTH_TOKEN")??null,...a}={}){eh.add(this),ef.set(this,void 0);let n={apiKey:t,authToken:r,...a,baseURL:e||"https://api.anthropic.com"};if(!n.dangerouslyAllowBrowser&&eX())throw new eT("It looks like you're running in a browser-like environment.\n\nThis is disabled by default, as it risks exposing your secret API credentials to attackers.\nIf you understand the risks and have appropriate mitigations in place,\nyou can set the `dangerouslyAllowBrowser` option to `true`, e.g.,\n\nnew Anthropic({ apiKey, dangerouslyAllowBrowser: true });\n");this.baseURL=n.baseURL,this.timeout=n.timeout??em.DEFAULT_TIMEOUT,this.logger=n.logger??console;let o="warn";this.logLevel=o,this.logLevel=e3(n.logLevel,"ClientOptions.logLevel",this)??e3(r_("ANTHROPIC_LOG"),"process.env['ANTHROPIC_LOG']",this)??o,this.fetchOptions=n.fetchOptions,this.maxRetries=n.maxRetries??2,this.fetch=n.fetch??function(){if("undefined"!=typeof fetch)return fetch;throw Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new Anthropic({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}(),eb(this,ef,e2,"f"),this._options=n,this.apiKey="string"==typeof t?t:null,this.authToken=r}withOptions(e){return new this.constructor({...this._options,baseURL:this.baseURL,maxRetries:this.maxRetries,timeout:this.timeout,logger:this.logger,logLevel:this.logLevel,fetch:this.fetch,fetchOptions:this.fetchOptions,apiKey:this.apiKey,authToken:this.authToken,...e})}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:e,nulls:t}){if(!(e.get("x-api-key")||e.get("authorization")||this.apiKey&&e.get("x-api-key")||t.has("x-api-key")||this.authToken&&e.get("authorization")||t.has("authorization")))throw Error('Could not resolve authentication method. Expected either apiKey or authToken to be set. Or for one of the "X-Api-Key" or "Authorization" headers to be explicitly omitted')}async authHeaders(e){return tN([await this.apiKeyAuth(e),await this.bearerAuth(e)])}async apiKeyAuth(e){if(null!=this.apiKey)return tN([{"X-Api-Key":this.apiKey}])}async bearerAuth(e){if(null!=this.authToken)return tN([{Authorization:`Bearer ${this.authToken}`}])}stringifyQuery(e){return Object.entries(e).filter(([e,t])=>void 0!==t).map(([e,t])=>{if("string"==typeof t||"number"==typeof t||"boolean"==typeof t)return`${encodeURIComponent(e)}=${encodeURIComponent(t)}`;if(null===t)return`${encodeURIComponent(e)}=`;throw new eT(`Cannot stringify type ${typeof t}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`)}).join("&")}getUserAgent(){return`${this.constructor.name}/JS ${eW}`}defaultIdempotencyKey(){return`stainless-node-retry-${ex()}`}makeStatusError(e,t,r,a){return eR.generate(e,t,r,a)}buildURL(e,t,r){let a=!ew(this,eh,"m",ey).call(this)&&r||this.baseURL,n=new URL(ez(e)?e:a+(a.endsWith("/")&&e.startsWith("/")?e.slice(1):e)),o=this.defaultQuery();return!function(e){if(!e)return!0;for(let t in e)return!1;return!0}(o)&&(t={...o,...t}),"object"==typeof t&&t&&!Array.isArray(t)&&(n.search=this.stringifyQuery(t)),n.toString()}_calculateNonstreamingTimeout(e){if(3600*e/128e3>600)throw new eT("Streaming is required for operations that may take longer than 10 minutes. See https://github.com/anthropics/anthropic-sdk-typescript#streaming-responses for more details");return 6e5}async prepareOptions(e){}async prepareRequest(e,{url:t,options:r}){}get(e,t){return this.methodRequest("get",e,t)}post(e,t){return this.methodRequest("post",e,t)}patch(e,t){return this.methodRequest("patch",e,t)}put(e,t){return this.methodRequest("put",e,t)}delete(e,t){return this.methodRequest("delete",e,t)}methodRequest(e,t,r){return this.request(Promise.resolve(r).then(r=>({method:e,path:t,...r})))}request(e,t=null){return new td(this,this.makeRequest(e,t,void 0))}async makeRequest(e,t,r){let a=await e,n=a.maxRetries??this.maxRetries;null==t&&(t=n),await this.prepareOptions(a);let{req:o,url:i,timeout:s}=await this.buildRequest(a,{retryCount:n-t});await this.prepareRequest(o,{url:i,options:a});let l="log_"+(16777216*Math.random()|0).toString(16).padStart(6,"0"),u=void 0===r?"":`, retryOf: ${r}`,d=Date.now();if(tr(this).debug(`[${l}] sending request`,ta({retryOfRequestLogID:r,method:a.method,url:i,options:a,headers:o.headers})),a.signal?.aborted)throw new eS;let c=new AbortController,p=await this.fetchWithTimeout(i,o,s,c).catch(eI),h=Date.now();if(p instanceof globalThis.Error){let e=`retrying, ${t} attempts remaining`;if(a.signal?.aborted)throw new eS;let n=ek(p)||/timed? ?out/i.test(String(p)+("cause"in p?String(p.cause):""));if(t)return tr(this).info(`[${l}] connection ${n?"timed out":"failed"} - ${e}`),tr(this).debug(`[${l}] connection ${n?"timed out":"failed"} (${e})`,ta({retryOfRequestLogID:r,url:i,durationMs:h-d,message:p.message})),this.retryRequest(a,t,r??l);if(tr(this).info(`[${l}] connection ${n?"timed out":"failed"} - error; no more retries left`),tr(this).debug(`[${l}] connection ${n?"timed out":"failed"} (error; no more retries left)`,ta({retryOfRequestLogID:r,url:i,durationMs:h-d,message:p.message})),n)throw new eC;throw new eZ({cause:p})}let m=[...p.headers.entries()].filter(([e])=>"request-id"===e).map(([e,t])=>", "+e+": "+JSON.stringify(t)).join(""),f=`[${l}${u}${m}] ${o.method} ${i} ${p.ok?"succeeded":"failed"} with status ${p.status} in ${h-d}ms`;if(!p.ok){let e=await this.shouldRetry(p);if(t&&e){let e=`retrying, ${t} attempts remaining`;return await e1(p.body),tr(this).info(`${f} - ${e}`),tr(this).debug(`[${l}] response error (${e})`,ta({retryOfRequestLogID:r,url:p.url,status:p.status,headers:p.headers,durationMs:h-d})),this.retryRequest(a,t,r??l,p.headers)}let n=e?"error; no more retries left":"error; not retryable";tr(this).info(`${f} - ${n}`);let o=await p.text().catch(e=>eI(e).message),i=eV(o),s=i?void 0:o;throw tr(this).debug(`[${l}] response error (${n})`,ta({retryOfRequestLogID:r,url:p.url,status:p.status,headers:p.headers,message:s,durationMs:Date.now()-d})),this.makeStatusError(p.status,i,s,p.headers)}return tr(this).info(f),tr(this).debug(`[${l}] response start`,ta({retryOfRequestLogID:r,url:p.url,status:p.status,headers:p.headers,durationMs:h-d})),{response:p,options:a,controller:c,requestLogID:l,retryOfRequestLogID:r,startTime:d}}getAPIList(e,t,r){return this.requestAPIList(t,r&&"then"in r?r.then(t=>({method:"get",path:e,...t})):{method:"get",path:e,...r})}requestAPIList(e,t){return new tp(this,this.makeRequest(t,null,void 0),e)}async fetchWithTimeout(e,t,r,a){let{signal:n,method:o,...i}=t||{},s=this._makeAbort(a);n&&n.addEventListener("abort",s,{once:!0});let l=setTimeout(s,r),u=globalThis.ReadableStream&&i.body instanceof globalThis.ReadableStream||"object"==typeof i.body&&null!==i.body&&Symbol.asyncIterator in i.body,d={signal:a.signal,...u?{duplex:"half"}:{},method:"GET",...i};o&&(d.method=o.toUpperCase());try{return await this.fetch.call(void 0,e,d)}finally{clearTimeout(l)}}async shouldRetry(e){let t=e.headers.get("x-should-retry");return"true"===t||"false"!==t&&(408===e.status||409===e.status||429===e.status||e.status>=500)}async retryRequest(e,t,r,a){let n;let o=a?.get("retry-after-ms");if(o){let e=parseFloat(o);Number.isNaN(e)||(n=e)}let i=a?.get("retry-after");if(i&&!n){let e=parseFloat(i);n=Number.isNaN(e)?Date.parse(i)-Date.now():1e3*e}if(!(n&&0<=n&&n<6e4)){let r=e.maxRetries??this.maxRetries;n=this.calculateDefaultRetryTimeoutMillis(t,r)}return await eG(n),this.makeRequest(e,t-1,r)}calculateDefaultRetryTimeoutMillis(e,t){return Math.min(.5*Math.pow(2,t-e),8)*(1-.25*Math.random())*1e3}calculateNonstreamingTimeout(e,t){if(36e5*e/128e3>6e5||null!=t&&e>t)throw new eT("Streaming is required for operations that may take longer than 10 minutes. See https://github.com/anthropics/anthropic-sdk-typescript#long-requests for more details");return 6e5}async buildRequest(e,{retryCount:t=0}={}){let r={...e},{method:a,path:n,query:o,defaultBaseURL:i}=r,s=this.buildURL(n,o,i);"timeout"in r&&eL("timeout",r.timeout),r.timeout=r.timeout??this.timeout;let{bodyHeaders:l,body:u}=this.buildBody({options:r}),d=await this.buildHeaders({options:e,method:a,bodyHeaders:l,retryCount:t});return{req:{method:a,headers:d,...r.signal&&{signal:r.signal},...globalThis.ReadableStream&&u instanceof globalThis.ReadableStream&&{duplex:"half"},...u&&{body:u},...this.fetchOptions??{},...r.fetchOptions??{}},url:s,timeout:r.timeout}}async buildHeaders({options:e,method:t,bodyHeaders:r,retryCount:a}){let n={};this.idempotencyHeader&&"get"!==t&&(e.idempotencyKey||(e.idempotencyKey=this.defaultIdempotencyKey()),n[this.idempotencyHeader]=e.idempotencyKey);let o=tN([n,{Accept:"application/json","User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String(a),...e.timeout?{"X-Stainless-Timeout":String(Math.trunc(e.timeout/1e3))}:{},...eH(),...this._options.dangerouslyAllowBrowser?{"anthropic-dangerous-direct-browser-access":"true"}:void 0,"anthropic-version":"2023-06-01"},await this.authHeaders(e),this._options.defaultHeaders,r,e.headers]);return this.validateHeaders(o),o.values}_makeAbort(e){return()=>e.abort()}buildBody({options:{body:e,headers:t}}){if(!e)return{bodyHeaders:void 0,body:void 0};let r=tN([t]);return ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof DataView||"string"==typeof e&&r.values.has("content-type")||globalThis.Blob&&e instanceof globalThis.Blob||e instanceof FormData||e instanceof URLSearchParams||globalThis.ReadableStream&&e instanceof globalThis.ReadableStream?{bodyHeaders:void 0,body:e}:"object"==typeof e&&(Symbol.asyncIterator in e||Symbol.iterator in e&&"next"in e&&"function"==typeof e.next)?{bodyHeaders:void 0,body:eQ(e)}:"object"==typeof e&&"application/x-www-form-urlencoded"===r.values.get("content-type")?{bodyHeaders:{"content-type":"application/x-www-form-urlencoded"},body:this.stringifyQuery(e)}:ew(this,ef,"f").call(this,{body:e,headers:r})}}em=rg,ef=new WeakMap,eh=new WeakSet,ey=function(){return"https://api.anthropic.com"!==this.baseURL},rg.Anthropic=em,rg.HUMAN_PROMPT="\\n\\nHuman:",rg.AI_PROMPT="\\n\\nAssistant:",rg.DEFAULT_TIMEOUT=6e5,rg.AnthropicError=eT,rg.APIError=eR,rg.APIConnectionError=eZ,rg.APIConnectionTimeoutError=eC,rg.APIUserAbortError=eS,rg.NotFoundError=eN,rg.ConflictError=eM,rg.RateLimitError=eP,rg.BadRequestError=eE,rg.AuthenticationError=eO,rg.InternalServerError=ej,rg.PermissionDeniedError=eA,rg.UnprocessableEntityError=e$,rg.toFile=tC;class rv extends rg{constructor(){super(...arguments),this.completions=new ro(this),this.messages=new rh(this),this.models=new ry(this),this.beta=new rn(this)}}rv.Completions=ro,rv.Messages=rh,rv.Models=ry,rv.Beta=rn},4523:(e,t,r)=>{r.d(t,{D3:()=>ek});var a=r(9519),n=r(6365),o=r(2943),i=(0,n.DG)(()=>(0,n.r0)(o.Ry({type:o.i0("error"),error:o.Ry({type:o.Z_(),message:o.Z_()})}))),s=(0,n.Sq)({errorSchema:i,errorToMessage:e=>e.error.message}),l=(0,n.DG)(()=>(0,n.r0)(o.Ry({type:o.i0("message"),id:o.Z_().nullish(),model:o.Z_().nullish(),content:o.IX(o.VK("type",[o.Ry({type:o.i0("text"),text:o.Z_(),citations:o.IX(o.VK("type",[o.Ry({type:o.i0("web_search_result_location"),cited_text:o.Z_(),url:o.Z_(),title:o.Z_(),encrypted_index:o.Z_()}),o.Ry({type:o.i0("page_location"),cited_text:o.Z_(),document_index:o.Rx(),document_title:o.Z_().nullable(),start_page_number:o.Rx(),end_page_number:o.Rx()}),o.Ry({type:o.i0("char_location"),cited_text:o.Z_(),document_index:o.Rx(),document_title:o.Z_().nullable(),start_char_index:o.Rx(),end_char_index:o.Rx()})])).optional()}),o.Ry({type:o.i0("thinking"),thinking:o.Z_(),signature:o.Z_()}),o.Ry({type:o.i0("redacted_thinking"),data:o.Z_()}),o.Ry({type:o.i0("compaction"),content:o.Z_()}),o.Ry({type:o.i0("tool_use"),id:o.Z_(),name:o.Z_(),input:o._4(),caller:o.G0([o.Ry({type:o.i0("code_execution_20250825"),tool_id:o.Z_()}),o.Ry({type:o.i0("code_execution_20260120"),tool_id:o.Z_()}),o.Ry({type:o.i0("direct")})]).optional()}),o.Ry({type:o.i0("server_tool_use"),id:o.Z_(),name:o.Z_(),input:o.IM(o.Z_(),o._4()).nullish(),caller:o.G0([o.Ry({type:o.i0("code_execution_20260120"),tool_id:o.Z_()}),o.Ry({type:o.i0("direct")})]).optional()}),o.Ry({type:o.i0("mcp_tool_use"),id:o.Z_(),name:o.Z_(),input:o._4(),server_name:o.Z_()}),o.Ry({type:o.i0("mcp_tool_result"),tool_use_id:o.Z_(),is_error:o.O7(),content:o.IX(o.G0([o.Z_(),o.Ry({type:o.i0("text"),text:o.Z_()})]))}),o.Ry({type:o.i0("web_fetch_tool_result"),tool_use_id:o.Z_(),content:o.G0([o.Ry({type:o.i0("web_fetch_result"),url:o.Z_(),retrieved_at:o.Z_(),content:o.Ry({type:o.i0("document"),title:o.Z_().nullable(),citations:o.Ry({enabled:o.O7()}).optional(),source:o.G0([o.Ry({type:o.i0("base64"),media_type:o.i0("application/pdf"),data:o.Z_()}),o.Ry({type:o.i0("text"),media_type:o.i0("text/plain"),data:o.Z_()})])})}),o.Ry({type:o.i0("web_fetch_tool_result_error"),error_code:o.Z_()})])}),o.Ry({type:o.i0("web_search_tool_result"),tool_use_id:o.Z_(),content:o.G0([o.IX(o.Ry({type:o.i0("web_search_result"),url:o.Z_(),title:o.Z_(),encrypted_content:o.Z_(),page_age:o.Z_().nullish()})),o.Ry({type:o.i0("web_search_tool_result_error"),error_code:o.Z_()})])}),o.Ry({type:o.i0("code_execution_tool_result"),tool_use_id:o.Z_(),content:o.G0([o.Ry({type:o.i0("code_execution_result"),stdout:o.Z_(),stderr:o.Z_(),return_code:o.Rx(),content:o.IX(o.Ry({type:o.i0("code_execution_output"),file_id:o.Z_()})).optional().default([])}),o.Ry({type:o.i0("encrypted_code_execution_result"),encrypted_stdout:o.Z_(),stderr:o.Z_(),return_code:o.Rx(),content:o.IX(o.Ry({type:o.i0("code_execution_output"),file_id:o.Z_()})).optional().default([])}),o.Ry({type:o.i0("code_execution_tool_result_error"),error_code:o.Z_()})])}),o.Ry({type:o.i0("bash_code_execution_tool_result"),tool_use_id:o.Z_(),content:o.VK("type",[o.Ry({type:o.i0("bash_code_execution_result"),content:o.IX(o.Ry({type:o.i0("bash_code_execution_output"),file_id:o.Z_()})),stdout:o.Z_(),stderr:o.Z_(),return_code:o.Rx()}),o.Ry({type:o.i0("bash_code_execution_tool_result_error"),error_code:o.Z_()})])}),o.Ry({type:o.i0("text_editor_code_execution_tool_result"),tool_use_id:o.Z_(),content:o.VK("type",[o.Ry({type:o.i0("text_editor_code_execution_tool_result_error"),error_code:o.Z_()}),o.Ry({type:o.i0("text_editor_code_execution_view_result"),content:o.Z_(),file_type:o.Z_(),num_lines:o.Rx().nullable(),start_line:o.Rx().nullable(),total_lines:o.Rx().nullable()}),o.Ry({type:o.i0("text_editor_code_execution_create_result"),is_file_update:o.O7()}),o.Ry({type:o.i0("text_editor_code_execution_str_replace_result"),lines:o.IX(o.Z_()).nullable(),new_lines:o.Rx().nullable(),new_start:o.Rx().nullable(),old_lines:o.Rx().nullable(),old_start:o.Rx().nullable()})])}),o.Ry({type:o.i0("tool_search_tool_result"),tool_use_id:o.Z_(),content:o.G0([o.Ry({type:o.i0("tool_search_tool_search_result"),tool_references:o.IX(o.Ry({type:o.i0("tool_reference"),tool_name:o.Z_()}))}),o.Ry({type:o.i0("tool_search_tool_result_error"),error_code:o.Z_()})])})])),stop_reason:o.Z_().nullish(),stop_sequence:o.Z_().nullish(),usage:o.d7({input_tokens:o.Rx(),output_tokens:o.Rx(),cache_creation_input_tokens:o.Rx().nullish(),cache_read_input_tokens:o.Rx().nullish(),iterations:o.IX(o.Ry({type:o.G0([o.i0("compaction"),o.i0("message")]),input_tokens:o.Rx(),output_tokens:o.Rx()})).nullish()}),container:o.Ry({expires_at:o.Z_(),id:o.Z_(),skills:o.IX(o.Ry({type:o.G0([o.i0("anthropic"),o.i0("custom")]),skill_id:o.Z_(),version:o.Z_()})).nullish()}).nullish(),context_management:o.Ry({applied_edits:o.IX(o.G0([o.Ry({type:o.i0("clear_tool_uses_20250919"),cleared_tool_uses:o.Rx(),cleared_input_tokens:o.Rx()}),o.Ry({type:o.i0("clear_thinking_20251015"),cleared_thinking_turns:o.Rx(),cleared_input_tokens:o.Rx()}),o.Ry({type:o.i0("compact_20260112")})]))}).nullish()}))),u=(0,n.DG)(()=>(0,n.r0)(o.VK("type",[o.Ry({type:o.i0("message_start"),message:o.Ry({id:o.Z_().nullish(),model:o.Z_().nullish(),role:o.Z_().nullish(),usage:o.d7({input_tokens:o.Rx(),cache_creation_input_tokens:o.Rx().nullish(),cache_read_input_tokens:o.Rx().nullish()}),content:o.IX(o.VK("type",[o.Ry({type:o.i0("tool_use"),id:o.Z_(),name:o.Z_(),input:o._4(),caller:o.G0([o.Ry({type:o.i0("code_execution_20250825"),tool_id:o.Z_()}),o.Ry({type:o.i0("code_execution_20260120"),tool_id:o.Z_()}),o.Ry({type:o.i0("direct")})]).optional()})])).nullish(),stop_reason:o.Z_().nullish(),container:o.Ry({expires_at:o.Z_(),id:o.Z_()}).nullish()})}),o.Ry({type:o.i0("content_block_start"),index:o.Rx(),content_block:o.VK("type",[o.Ry({type:o.i0("text"),text:o.Z_()}),o.Ry({type:o.i0("thinking"),thinking:o.Z_()}),o.Ry({type:o.i0("tool_use"),id:o.Z_(),name:o.Z_(),input:o.IM(o.Z_(),o._4()).optional(),caller:o.G0([o.Ry({type:o.i0("code_execution_20250825"),tool_id:o.Z_()}),o.Ry({type:o.i0("code_execution_20260120"),tool_id:o.Z_()}),o.Ry({type:o.i0("direct")})]).optional()}),o.Ry({type:o.i0("redacted_thinking"),data:o.Z_()}),o.Ry({type:o.i0("compaction"),content:o.Z_().nullish()}),o.Ry({type:o.i0("server_tool_use"),id:o.Z_(),name:o.Z_(),input:o.IM(o.Z_(),o._4()).nullish(),caller:o.G0([o.Ry({type:o.i0("code_execution_20260120"),tool_id:o.Z_()}),o.Ry({type:o.i0("direct")})]).optional()}),o.Ry({type:o.i0("mcp_tool_use"),id:o.Z_(),name:o.Z_(),input:o._4(),server_name:o.Z_()}),o.Ry({type:o.i0("mcp_tool_result"),tool_use_id:o.Z_(),is_error:o.O7(),content:o.IX(o.G0([o.Z_(),o.Ry({type:o.i0("text"),text:o.Z_()})]))}),o.Ry({type:o.i0("web_fetch_tool_result"),tool_use_id:o.Z_(),content:o.G0([o.Ry({type:o.i0("web_fetch_result"),url:o.Z_(),retrieved_at:o.Z_(),content:o.Ry({type:o.i0("document"),title:o.Z_().nullable(),citations:o.Ry({enabled:o.O7()}).optional(),source:o.G0([o.Ry({type:o.i0("base64"),media_type:o.i0("application/pdf"),data:o.Z_()}),o.Ry({type:o.i0("text"),media_type:o.i0("text/plain"),data:o.Z_()})])})}),o.Ry({type:o.i0("web_fetch_tool_result_error"),error_code:o.Z_()})])}),o.Ry({type:o.i0("web_search_tool_result"),tool_use_id:o.Z_(),content:o.G0([o.IX(o.Ry({type:o.i0("web_search_result"),url:o.Z_(),title:o.Z_(),encrypted_content:o.Z_(),page_age:o.Z_().nullish()})),o.Ry({type:o.i0("web_search_tool_result_error"),error_code:o.Z_()})])}),o.Ry({type:o.i0("code_execution_tool_result"),tool_use_id:o.Z_(),content:o.G0([o.Ry({type:o.i0("code_execution_result"),stdout:o.Z_(),stderr:o.Z_(),return_code:o.Rx(),content:o.IX(o.Ry({type:o.i0("code_execution_output"),file_id:o.Z_()})).optional().default([])}),o.Ry({type:o.i0("encrypted_code_execution_result"),encrypted_stdout:o.Z_(),stderr:o.Z_(),return_code:o.Rx(),content:o.IX(o.Ry({type:o.i0("code_execution_output"),file_id:o.Z_()})).optional().default([])}),o.Ry({type:o.i0("code_execution_tool_result_error"),error_code:o.Z_()})])}),o.Ry({type:o.i0("bash_code_execution_tool_result"),tool_use_id:o.Z_(),content:o.VK("type",[o.Ry({type:o.i0("bash_code_execution_result"),content:o.IX(o.Ry({type:o.i0("bash_code_execution_output"),file_id:o.Z_()})),stdout:o.Z_(),stderr:o.Z_(),return_code:o.Rx()}),o.Ry({type:o.i0("bash_code_execution_tool_result_error"),error_code:o.Z_()})])}),o.Ry({type:o.i0("text_editor_code_execution_tool_result"),tool_use_id:o.Z_(),content:o.VK("type",[o.Ry({type:o.i0("text_editor_code_execution_tool_result_error"),error_code:o.Z_()}),o.Ry({type:o.i0("text_editor_code_execution_view_result"),content:o.Z_(),file_type:o.Z_(),num_lines:o.Rx().nullable(),start_line:o.Rx().nullable(),total_lines:o.Rx().nullable()}),o.Ry({type:o.i0("text_editor_code_execution_create_result"),is_file_update:o.O7()}),o.Ry({type:o.i0("text_editor_code_execution_str_replace_result"),lines:o.IX(o.Z_()).nullable(),new_lines:o.Rx().nullable(),new_start:o.Rx().nullable(),old_lines:o.Rx().nullable(),old_start:o.Rx().nullable()})])}),o.Ry({type:o.i0("tool_search_tool_result"),tool_use_id:o.Z_(),content:o.G0([o.Ry({type:o.i0("tool_search_tool_search_result"),tool_references:o.IX(o.Ry({type:o.i0("tool_reference"),tool_name:o.Z_()}))}),o.Ry({type:o.i0("tool_search_tool_result_error"),error_code:o.Z_()})])})])}),o.Ry({type:o.i0("content_block_delta"),index:o.Rx(),delta:o.VK("type",[o.Ry({type:o.i0("input_json_delta"),partial_json:o.Z_()}),o.Ry({type:o.i0("text_delta"),text:o.Z_()}),o.Ry({type:o.i0("thinking_delta"),thinking:o.Z_()}),o.Ry({type:o.i0("signature_delta"),signature:o.Z_()}),o.Ry({type:o.i0("compaction_delta"),content:o.Z_().nullish()}),o.Ry({type:o.i0("citations_delta"),citation:o.VK("type",[o.Ry({type:o.i0("web_search_result_location"),cited_text:o.Z_(),url:o.Z_(),title:o.Z_(),encrypted_index:o.Z_()}),o.Ry({type:o.i0("page_location"),cited_text:o.Z_(),document_index:o.Rx(),document_title:o.Z_().nullable(),start_page_number:o.Rx(),end_page_number:o.Rx()}),o.Ry({type:o.i0("char_location"),cited_text:o.Z_(),document_index:o.Rx(),document_title:o.Z_().nullable(),start_char_index:o.Rx(),end_char_index:o.Rx()})])})])}),o.Ry({type:o.i0("content_block_stop"),index:o.Rx()}),o.Ry({type:o.i0("error"),error:o.Ry({type:o.Z_(),message:o.Z_()})}),o.Ry({type:o.i0("message_delta"),delta:o.Ry({stop_reason:o.Z_().nullish(),stop_sequence:o.Z_().nullish(),container:o.Ry({expires_at:o.Z_(),id:o.Z_(),skills:o.IX(o.Ry({type:o.G0([o.i0("anthropic"),o.i0("custom")]),skill_id:o.Z_(),version:o.Z_()})).nullish()}).nullish()}),usage:o.d7({input_tokens:o.Rx().nullish(),output_tokens:o.Rx(),cache_creation_input_tokens:o.Rx().nullish(),cache_read_input_tokens:o.Rx().nullish(),iterations:o.IX(o.Ry({type:o.G0([o.i0("compaction"),o.i0("message")]),input_tokens:o.Rx(),output_tokens:o.Rx()})).nullish()}),context_management:o.Ry({applied_edits:o.IX(o.G0([o.Ry({type:o.i0("clear_tool_uses_20250919"),cleared_tool_uses:o.Rx(),cleared_input_tokens:o.Rx()}),o.Ry({type:o.i0("clear_thinking_20251015"),cleared_thinking_turns:o.Rx(),cleared_input_tokens:o.Rx()}),o.Ry({type:o.i0("compact_20260112")})]))}).nullish()}),o.Ry({type:o.i0("message_stop")}),o.Ry({type:o.i0("ping")})]))),d=(0,n.DG)(()=>(0,n.r0)(o.Ry({signature:o.Z_().optional(),redactedData:o.Z_().optional()}))),c=o.Ry({citations:o.Ry({enabled:o.O7()}).optional(),title:o.Z_().optional(),context:o.Z_().optional()}),p=o.Ry({sendReasoning:o.O7().optional(),structuredOutputMode:o.Km(["outputFormat","jsonTool","auto"]).optional(),thinking:o.VK("type",[o.Ry({type:o.i0("adaptive")}),o.Ry({type:o.i0("enabled"),budgetTokens:o.Rx().optional()}),o.Ry({type:o.i0("disabled")})]).optional(),disableParallelToolUse:o.O7().optional(),cacheControl:o.Ry({type:o.i0("ephemeral"),ttl:o.G0([o.i0("5m"),o.i0("1h")]).optional()}).optional(),mcpServers:o.IX(o.Ry({type:o.i0("url"),name:o.Z_(),url:o.Z_(),authorizationToken:o.Z_().nullish(),toolConfiguration:o.Ry({enabled:o.O7().nullish(),allowedTools:o.IX(o.Z_()).nullish()}).nullish()})).optional(),container:o.Ry({id:o.Z_().optional(),skills:o.IX(o.Ry({type:o.G0([o.i0("anthropic"),o.i0("custom")]),skillId:o.Z_(),version:o.Z_().optional()})).optional()}).optional(),toolStreaming:o.O7().optional(),effort:o.Km(["low","medium","high","max"]).optional(),speed:o.Km(["fast","standard"]).optional(),anthropicBeta:o.IX(o.Z_()).optional(),contextManagement:o.Ry({edits:o.IX(o.VK("type",[o.Ry({type:o.i0("clear_tool_uses_20250919"),trigger:o.VK("type",[o.Ry({type:o.i0("input_tokens"),value:o.Rx()}),o.Ry({type:o.i0("tool_uses"),value:o.Rx()})]).optional(),keep:o.Ry({type:o.i0("tool_uses"),value:o.Rx()}).optional(),clearAtLeast:o.Ry({type:o.i0("input_tokens"),value:o.Rx()}).optional(),clearToolInputs:o.O7().optional(),excludeTools:o.IX(o.Z_()).optional()}),o.Ry({type:o.i0("clear_thinking_20251015"),keep:o.G0([o.i0("all"),o.Ry({type:o.i0("thinking_turns"),value:o.Rx()})]).optional()}),o.Ry({type:o.i0("compact_20260112"),trigger:o.Ry({type:o.i0("input_tokens"),value:o.Rx()}).optional(),pauseAfterCompaction:o.O7().optional(),instructions:o.Z_().optional()})]))}).optional()}),h=class{constructor(){this.breakpointCount=0,this.warnings=[]}getCacheControl(e,t){let r=function(e){var t;let r=null==e?void 0:e.anthropic;return null!=(t=null==r?void 0:r.cacheControl)?t:null==r?void 0:r.cache_control}(e);if(r){if(!t.canCache){this.warnings.push({type:"unsupported",feature:"cache_control on non-cacheable context",details:`cache_control cannot be set on ${t.type}. It will be ignored.`});return}if(this.breakpointCount++,this.breakpointCount>4){this.warnings.push({type:"unsupported",feature:"cacheControl breakpoint limit",details:`Maximum 4 cache breakpoints exceeded (found ${this.breakpointCount}). This breakpoint will be ignored.`});return}return r}}getWarnings(){return this.warnings}},m=(0,n.DG)(()=>(0,n.r0)(o.Ry({maxCharacters:o.Rx().optional()}))),f=(0,n.DG)(()=>(0,n.r0)(o.Ry({command:o.Km(["view","create","str_replace","insert"]),path:o.Z_(),file_text:o.Z_().optional(),insert_line:o.Rx().int().optional(),new_str:o.Z_().optional(),insert_text:o.Z_().optional(),old_str:o.Z_().optional(),view_range:o.IX(o.Rx().int()).optional()}))),y=(0,n.W0)({id:"anthropic.text_editor_20250728",inputSchema:f}),_=(0,n.DG)(()=>(0,n.r0)(o.Ry({maxUses:o.Rx().optional(),allowedDomains:o.IX(o.Z_()).optional(),blockedDomains:o.IX(o.Z_()).optional(),userLocation:o.Ry({type:o.i0("approximate"),city:o.Z_().optional(),region:o.Z_().optional(),country:o.Z_().optional(),timezone:o.Z_().optional()}).optional()}))),g=(0,n.DG)(()=>(0,n.r0)(o.IX(o.Ry({url:o.Z_(),title:o.Z_().nullable(),pageAge:o.Z_().nullable(),encryptedContent:o.Z_(),type:o.i0("web_search_result")})))),v=(0,n.DG)(()=>(0,n.r0)(o.Ry({query:o.Z_()}))),b=(0,n.ql)({id:"anthropic.web_search_20260209",inputSchema:v,outputSchema:g,supportsDeferredResults:!0}),w=(0,n.DG)(()=>(0,n.r0)(o.Ry({maxUses:o.Rx().optional(),allowedDomains:o.IX(o.Z_()).optional(),blockedDomains:o.IX(o.Z_()).optional(),userLocation:o.Ry({type:o.i0("approximate"),city:o.Z_().optional(),region:o.Z_().optional(),country:o.Z_().optional(),timezone:o.Z_().optional()}).optional()}))),x=(0,n.DG)(()=>(0,n.r0)(o.IX(o.Ry({url:o.Z_(),title:o.Z_().nullable(),pageAge:o.Z_().nullable(),encryptedContent:o.Z_(),type:o.i0("web_search_result")})))),k=(0,n.DG)(()=>(0,n.r0)(o.Ry({query:o.Z_()}))),I=(0,n.ql)({id:"anthropic.web_search_20250305",inputSchema:k,outputSchema:x,supportsDeferredResults:!0}),T=(0,n.DG)(()=>(0,n.r0)(o.Ry({maxUses:o.Rx().optional(),allowedDomains:o.IX(o.Z_()).optional(),blockedDomains:o.IX(o.Z_()).optional(),citations:o.Ry({enabled:o.O7()}).optional(),maxContentTokens:o.Rx().optional()}))),R=(0,n.DG)(()=>(0,n.r0)(o.Ry({type:o.i0("web_fetch_result"),url:o.Z_(),content:o.Ry({type:o.i0("document"),title:o.Z_().nullable(),citations:o.Ry({enabled:o.O7()}).optional(),source:o.G0([o.Ry({type:o.i0("base64"),mediaType:o.i0("application/pdf"),data:o.Z_()}),o.Ry({type:o.i0("text"),mediaType:o.i0("text/plain"),data:o.Z_()})])}),retrievedAt:o.Z_().nullable()}))),S=(0,n.DG)(()=>(0,n.r0)(o.Ry({url:o.Z_()}))),Z=(0,n.ql)({id:"anthropic.web_fetch_20260209",inputSchema:S,outputSchema:R,supportsDeferredResults:!0}),C=(0,n.DG)(()=>(0,n.r0)(o.Ry({maxUses:o.Rx().optional(),allowedDomains:o.IX(o.Z_()).optional(),blockedDomains:o.IX(o.Z_()).optional(),citations:o.Ry({enabled:o.O7()}).optional(),maxContentTokens:o.Rx().optional()}))),E=(0,n.DG)(()=>(0,n.r0)(o.Ry({type:o.i0("web_fetch_result"),url:o.Z_(),content:o.Ry({type:o.i0("document"),title:o.Z_().nullable(),citations:o.Ry({enabled:o.O7()}).optional(),source:o.G0([o.Ry({type:o.i0("base64"),mediaType:o.i0("application/pdf"),data:o.Z_()}),o.Ry({type:o.i0("text"),mediaType:o.i0("text/plain"),data:o.Z_()})])}),retrievedAt:o.Z_().nullable()}))),O=(0,n.DG)(()=>(0,n.r0)(o.Ry({url:o.Z_()}))),A=(0,n.ql)({id:"anthropic.web_fetch_20250910",inputSchema:O,outputSchema:E,supportsDeferredResults:!0});async function N({tools:e,toolChoice:t,disableParallelToolUse:r,cacheControlValidator:o,supportsStructuredOutput:i}){var s;e=(null==e?void 0:e.length)?e:void 0;let l=[],u=new Set,d=o||new h;if(null==e)return{tools:void 0,toolChoice:void 0,toolWarnings:l,betas:u};let c=[];for(let t of e)switch(t.type){case"function":{let e=d.getCacheControl(t.providerOptions,{type:"tool definition",canCache:!0}),r=null==(s=t.providerOptions)?void 0:s.anthropic,a=null==r?void 0:r.eagerInputStreaming,n=null==r?void 0:r.deferLoading,o=null==r?void 0:r.allowedCallers;c.push({name:t.name,description:t.description,input_schema:t.inputSchema,cache_control:e,...a?{eager_input_streaming:!0}:{},...!0===i&&null!=t.strict?{strict:t.strict}:{},...null!=n?{defer_loading:n}:{},...null!=o?{allowed_callers:o}:{},...null!=t.inputExamples?{input_examples:t.inputExamples.map(e=>e.input)}:{}}),!0===i&&u.add("structured-outputs-2025-11-13"),(null!=t.inputExamples||null!=o)&&u.add("advanced-tool-use-2025-11-20");break}case"provider":switch(t.id){case"anthropic.code_execution_20250522":u.add("code-execution-2025-05-22"),c.push({type:"code_execution_20250522",name:"code_execution",cache_control:void 0});break;case"anthropic.code_execution_20250825":u.add("code-execution-2025-08-25"),c.push({type:"code_execution_20250825",name:"code_execution"});break;case"anthropic.code_execution_20260120":c.push({type:"code_execution_20260120",name:"code_execution"});break;case"anthropic.computer_20250124":u.add("computer-use-2025-01-24"),c.push({name:"computer",type:"computer_20250124",display_width_px:t.args.displayWidthPx,display_height_px:t.args.displayHeightPx,display_number:t.args.displayNumber,cache_control:void 0});break;case"anthropic.computer_20251124":u.add("computer-use-2025-11-24"),c.push({name:"computer",type:"computer_20251124",display_width_px:t.args.displayWidthPx,display_height_px:t.args.displayHeightPx,display_number:t.args.displayNumber,enable_zoom:t.args.enableZoom,cache_control:void 0});break;case"anthropic.computer_20241022":u.add("computer-use-2024-10-22"),c.push({name:"computer",type:"computer_20241022",display_width_px:t.args.displayWidthPx,display_height_px:t.args.displayHeightPx,display_number:t.args.displayNumber,cache_control:void 0});break;case"anthropic.text_editor_20250124":u.add("computer-use-2025-01-24"),c.push({name:"str_replace_editor",type:"text_editor_20250124",cache_control:void 0});break;case"anthropic.text_editor_20241022":u.add("computer-use-2024-10-22"),c.push({name:"str_replace_editor",type:"text_editor_20241022",cache_control:void 0});break;case"anthropic.text_editor_20250429":u.add("computer-use-2025-01-24"),c.push({name:"str_replace_based_edit_tool",type:"text_editor_20250429",cache_control:void 0});break;case"anthropic.text_editor_20250728":{let e=await (0,n.rJ)({value:t.args,schema:m});c.push({name:"str_replace_based_edit_tool",type:"text_editor_20250728",max_characters:e.maxCharacters,cache_control:void 0});break}case"anthropic.bash_20250124":u.add("computer-use-2025-01-24"),c.push({name:"bash",type:"bash_20250124",cache_control:void 0});break;case"anthropic.bash_20241022":u.add("computer-use-2024-10-22"),c.push({name:"bash",type:"bash_20241022",cache_control:void 0});break;case"anthropic.memory_20250818":u.add("context-management-2025-06-27"),c.push({name:"memory",type:"memory_20250818"});break;case"anthropic.web_fetch_20250910":{u.add("web-fetch-2025-09-10");let e=await (0,n.rJ)({value:t.args,schema:C});c.push({type:"web_fetch_20250910",name:"web_fetch",max_uses:e.maxUses,allowed_domains:e.allowedDomains,blocked_domains:e.blockedDomains,citations:e.citations,max_content_tokens:e.maxContentTokens,cache_control:void 0});break}case"anthropic.web_fetch_20260209":{u.add("code-execution-web-tools-2026-02-09");let e=await (0,n.rJ)({value:t.args,schema:T});c.push({type:"web_fetch_20260209",name:"web_fetch",max_uses:e.maxUses,allowed_domains:e.allowedDomains,blocked_domains:e.blockedDomains,citations:e.citations,max_content_tokens:e.maxContentTokens,cache_control:void 0});break}case"anthropic.web_search_20250305":{let e=await (0,n.rJ)({value:t.args,schema:w});c.push({type:"web_search_20250305",name:"web_search",max_uses:e.maxUses,allowed_domains:e.allowedDomains,blocked_domains:e.blockedDomains,user_location:e.userLocation,cache_control:void 0});break}case"anthropic.web_search_20260209":{u.add("code-execution-web-tools-2026-02-09");let e=await (0,n.rJ)({value:t.args,schema:_});c.push({type:"web_search_20260209",name:"web_search",max_uses:e.maxUses,allowed_domains:e.allowedDomains,blocked_domains:e.blockedDomains,user_location:e.userLocation,cache_control:void 0});break}case"anthropic.tool_search_regex_20251119":u.add("advanced-tool-use-2025-11-20"),c.push({type:"tool_search_tool_regex_20251119",name:"tool_search_tool_regex"});break;case"anthropic.tool_search_bm25_20251119":u.add("advanced-tool-use-2025-11-20"),c.push({type:"tool_search_tool_bm25_20251119",name:"tool_search_tool_bm25"});break;default:l.push({type:"unsupported",feature:`provider-defined tool ${t.id}`})}break;default:l.push({type:"unsupported",feature:`tool ${t}`})}if(null==t)return{tools:c,toolChoice:r?{type:"auto",disable_parallel_tool_use:r}:void 0,toolWarnings:l,betas:u};let p=t.type;switch(p){case"auto":return{tools:c,toolChoice:{type:"auto",disable_parallel_tool_use:r},toolWarnings:l,betas:u};case"required":return{tools:c,toolChoice:{type:"any",disable_parallel_tool_use:r},toolWarnings:l,betas:u};case"none":return{tools:void 0,toolChoice:void 0,toolWarnings:l,betas:u};case"tool":return{tools:c,toolChoice:{type:"tool",name:t.toolName,disable_parallel_tool_use:r},toolWarnings:l,betas:u};default:throw new a.A_({functionality:`tool choice type: ${p}`})}}function M({usage:e,rawUsage:t}){var r,a;let n,o;let i=null!=(r=e.cache_creation_input_tokens)?r:0,s=null!=(a=e.cache_read_input_tokens)?a:0;if(e.iterations&&e.iterations.length>0){let t=e.iterations.reduce((e,t)=>({input:e.input+t.input_tokens,output:e.output+t.output_tokens}),{input:0,output:0});n=t.input,o=t.output}else n=e.input_tokens,o=e.output_tokens;return{inputTokens:{total:n+i+s,noCache:n,cacheRead:s,cacheWrite:i},outputTokens:{total:o,text:void 0,reasoning:void 0},raw:null!=t?t:e}}var $=(0,n.DG)(()=>(0,n.r0)(o.Ry({type:o.i0("code_execution_result"),stdout:o.Z_(),stderr:o.Z_(),return_code:o.Rx(),content:o.IX(o.Ry({type:o.i0("code_execution_output"),file_id:o.Z_()})).optional().default([])}))),P=(0,n.DG)(()=>(0,n.r0)(o.Ry({code:o.Z_()}))),j=(0,n.ql)({id:"anthropic.code_execution_20250522",inputSchema:P,outputSchema:$}),F=(0,n.DG)(()=>(0,n.r0)(o.VK("type",[o.Ry({type:o.i0("code_execution_result"),stdout:o.Z_(),stderr:o.Z_(),return_code:o.Rx(),content:o.IX(o.Ry({type:o.i0("code_execution_output"),file_id:o.Z_()})).optional().default([])}),o.Ry({type:o.i0("bash_code_execution_result"),content:o.IX(o.Ry({type:o.i0("bash_code_execution_output"),file_id:o.Z_()})),stdout:o.Z_(),stderr:o.Z_(),return_code:o.Rx()}),o.Ry({type:o.i0("bash_code_execution_tool_result_error"),error_code:o.Z_()}),o.Ry({type:o.i0("text_editor_code_execution_tool_result_error"),error_code:o.Z_()}),o.Ry({type:o.i0("text_editor_code_execution_view_result"),content:o.Z_(),file_type:o.Z_(),num_lines:o.Rx().nullable(),start_line:o.Rx().nullable(),total_lines:o.Rx().nullable()}),o.Ry({type:o.i0("text_editor_code_execution_create_result"),is_file_update:o.O7()}),o.Ry({type:o.i0("text_editor_code_execution_str_replace_result"),lines:o.IX(o.Z_()).nullable(),new_lines:o.Rx().nullable(),new_start:o.Rx().nullable(),old_lines:o.Rx().nullable(),old_start:o.Rx().nullable()})]))),z=(0,n.DG)(()=>(0,n.r0)(o.VK("type",[o.Ry({type:o.i0("programmatic-tool-call"),code:o.Z_()}),o.Ry({type:o.i0("bash_code_execution"),command:o.Z_()}),o.VK("command",[o.Ry({type:o.i0("text_editor_code_execution"),command:o.i0("view"),path:o.Z_()}),o.Ry({type:o.i0("text_editor_code_execution"),command:o.i0("create"),path:o.Z_(),file_text:o.Z_().nullish()}),o.Ry({type:o.i0("text_editor_code_execution"),command:o.i0("str_replace"),path:o.Z_(),old_str:o.Z_(),new_str:o.Z_()})])]))),D=(0,n.ql)({id:"anthropic.code_execution_20250825",inputSchema:z,outputSchema:F,supportsDeferredResults:!0}),q=(0,n.DG)(()=>(0,n.r0)(o.VK("type",[o.Ry({type:o.i0("code_execution_result"),stdout:o.Z_(),stderr:o.Z_(),return_code:o.Rx(),content:o.IX(o.Ry({type:o.i0("code_execution_output"),file_id:o.Z_()})).optional().default([])}),o.Ry({type:o.i0("encrypted_code_execution_result"),encrypted_stdout:o.Z_(),stderr:o.Z_(),return_code:o.Rx(),content:o.IX(o.Ry({type:o.i0("code_execution_output"),file_id:o.Z_()})).optional().default([])}),o.Ry({type:o.i0("bash_code_execution_result"),content:o.IX(o.Ry({type:o.i0("bash_code_execution_output"),file_id:o.Z_()})),stdout:o.Z_(),stderr:o.Z_(),return_code:o.Rx()}),o.Ry({type:o.i0("bash_code_execution_tool_result_error"),error_code:o.Z_()}),o.Ry({type:o.i0("text_editor_code_execution_tool_result_error"),error_code:o.Z_()}),o.Ry({type:o.i0("text_editor_code_execution_view_result"),content:o.Z_(),file_type:o.Z_(),num_lines:o.Rx().nullable(),start_line:o.Rx().nullable(),total_lines:o.Rx().nullable()}),o.Ry({type:o.i0("text_editor_code_execution_create_result"),is_file_update:o.O7()}),o.Ry({type:o.i0("text_editor_code_execution_str_replace_result"),lines:o.IX(o.Z_()).nullable(),new_lines:o.Rx().nullable(),new_start:o.Rx().nullable(),old_lines:o.Rx().nullable(),old_start:o.Rx().nullable()})]))),U=(0,n.DG)(()=>(0,n.r0)(o.VK("type",[o.Ry({type:o.i0("programmatic-tool-call"),code:o.Z_()}),o.Ry({type:o.i0("bash_code_execution"),command:o.Z_()}),o.VK("command",[o.Ry({type:o.i0("text_editor_code_execution"),command:o.i0("view"),path:o.Z_()}),o.Ry({type:o.i0("text_editor_code_execution"),command:o.i0("create"),path:o.Z_(),file_text:o.Z_().nullish()}),o.Ry({type:o.i0("text_editor_code_execution"),command:o.i0("str_replace"),path:o.Z_(),old_str:o.Z_(),new_str:o.Z_()})])]))),L=(0,n.ql)({id:"anthropic.code_execution_20260120",inputSchema:U,outputSchema:q,supportsDeferredResults:!0}),V=(0,n.DG)(()=>(0,n.r0)(o.IX(o.Ry({type:o.i0("tool_reference"),toolName:o.Z_()})))),G=(0,n.DG)(()=>(0,n.r0)(o.Ry({pattern:o.Z_(),limit:o.Rx().optional()}))),W=(0,n.ql)({id:"anthropic.tool_search_regex_20251119",inputSchema:G,outputSchema:V,supportsDeferredResults:!0});function X(e){return e instanceof URL||"string"==typeof e&&/^https?:\/\//i.test(e)}function B(e){return e instanceof URL?e.toString():e}async function K({prompt:e,sendReasoning:t,warnings:r,cacheControlValidator:o,toolNameMapping:i}){var s,l,u,p,m,f,y,_,g,v,b,w,k,I,T,R,S,Z,C;let O;let A=new Set,N=function(e){let t;let r=[];for(let a of e){let{role:e}=a;switch(e){case"system":(null==t?void 0:t.type)!=="system"&&(t={type:"system",messages:[]},r.push(t)),t.messages.push(a);break;case"assistant":(null==t?void 0:t.type)!=="assistant"&&(t={type:"assistant",messages:[]},r.push(t)),t.messages.push(a);break;case"user":case"tool":(null==t?void 0:t.type)!=="user"&&(t={type:"user",messages:[]},r.push(t)),t.messages.push(a);break;default:throw Error(`Unsupported role: ${e}`)}}return r}(e),M=o||new h,P=[];async function j(e){var t,r;let a=await (0,n.c1)({provider:"anthropic",providerOptions:e,schema:c});return null!=(r=null==(t=null==a?void 0:a.citations)?void 0:t.enabled)&&r}async function z(e){let t=await (0,n.c1)({provider:"anthropic",providerOptions:e,schema:c});return{title:null==t?void 0:t.title,context:null==t?void 0:t.context}}for(let e=0;e<N.length;e++){let o=N[e],c=e===N.length-1,h=o.type;switch(h){case"system":if(null!=O)throw new a.A_({functionality:"Multiple system messages that are separated by user/assistant messages"});O=o.messages.map(({content:e,providerOptions:t})=>({type:"text",text:e,cache_control:M.getCacheControl(t,{type:"system message",canCache:!0})}));break;case"user":{let e=[];for(let t of o.messages){let{role:o,content:i}=t;switch(o){case"user":for(let r=0;r<i.length;r++){let o=i[r],d=r===i.length-1,c=null!=(s=M.getCacheControl(o.providerOptions,{type:"user message part",canCache:!0}))?s:d?M.getCacheControl(t.providerOptions,{type:"user message",canCache:!0}):void 0;switch(o.type){case"text":e.push({type:"text",text:o.text,cache_control:c});break;case"file":if(o.mediaType.startsWith("image/"))e.push({type:"image",source:X(o.data)?{type:"url",url:B(o.data)}:{type:"base64",media_type:"image/*"===o.mediaType?"image/jpeg":o.mediaType,data:(0,n.QF)(o.data)},cache_control:c});else if("application/pdf"===o.mediaType){A.add("pdfs-2024-09-25");let t=await j(o.providerOptions),r=await z(o.providerOptions);e.push({type:"document",source:X(o.data)?{type:"url",url:B(o.data)}:{type:"base64",media_type:"application/pdf",data:(0,n.QF)(o.data)},title:null!=(l=r.title)?l:o.filename,...r.context&&{context:r.context},...t&&{citations:{enabled:!0}},cache_control:c})}else if("text/plain"===o.mediaType){let t=await j(o.providerOptions),r=await z(o.providerOptions);e.push({type:"document",source:X(o.data)?{type:"url",url:B(o.data)}:{type:"text",media_type:"text/plain",data:function(e){if("string"==typeof e)return new TextDecoder().decode((0,n.MS)(e));if(e instanceof Uint8Array)return new TextDecoder().decode(e);if(e instanceof URL)throw new a.A_({functionality:"URL-based text documents are not supported for citations"});throw new a.A_({functionality:`unsupported data type for text documents: ${typeof e}`})}(o.data)},title:null!=(u=r.title)?u:o.filename,...r.context&&{context:r.context},...t&&{citations:{enabled:!0}},cache_control:c})}else throw new a.A_({functionality:`media type: ${o.mediaType}`})}}break;case"tool":for(let a=0;a<i.length;a++){let o;let s=i[a];if("tool-approval-response"===s.type)continue;let l=a===i.length-1,u=null!=(p=M.getCacheControl(s.providerOptions,{type:"tool result part",canCache:!0}))?p:l?M.getCacheControl(t.providerOptions,{type:"tool result message",canCache:!0}):void 0,d=s.output;switch(d.type){case"content":o=d.value.map(e=>{var t;switch(e.type){case"text":return{type:"text",text:e.text};case"image-data":return{type:"image",source:{type:"base64",media_type:e.mediaType,data:e.data}};case"image-url":return{type:"image",source:{type:"url",url:e.url}};case"file-url":return{type:"document",source:{type:"url",url:e.url}};case"file-data":if("application/pdf"===e.mediaType)return A.add("pdfs-2024-09-25"),{type:"document",source:{type:"base64",media_type:e.mediaType,data:e.data}};r.push({type:"other",message:`unsupported tool content part type: ${e.type} with media type: ${e.mediaType}`});return;case"custom":{let a=null==(t=e.providerOptions)?void 0:t.anthropic;if((null==a?void 0:a.type)==="tool-reference")return{type:"tool_reference",tool_name:a.toolName};r.push({type:"other",message:"unsupported custom tool content part"});return}default:r.push({type:"other",message:`unsupported tool content part type: ${e.type}`});return}}).filter(n.C_);break;case"text":case"error-text":o=d.value;break;case"execution-denied":o=null!=(m=d.reason)?m:"Tool execution denied.";break;default:o=JSON.stringify(d.value)}e.push({type:"tool_result",tool_use_id:s.toolCallId,content:o,is_error:"error-text"===d.type||"error-json"===d.type||void 0,cache_control:u})}break;default:throw Error(`Unsupported role: ${o}`)}}P.push({role:"user",content:e});break}case"assistant":{let e=[],a=new Set;for(let s=0;s<o.messages.length;s++){let l=o.messages[s],u=s===o.messages.length-1,{content:p}=l;for(let o=0;o<p.length;o++){let s=p[o],h=o===p.length-1,m=null!=(f=M.getCacheControl(s.providerOptions,{type:"assistant message part",canCache:!0}))?f:h?M.getCacheControl(l.providerOptions,{type:"assistant message",canCache:!0}):void 0;switch(s.type){case"text":{let t=null==(y=s.providerOptions)?void 0:y.anthropic;(null==t?void 0:t.type)==="compaction"?e.push({type:"compaction",content:s.text,cache_control:m}):e.push({type:"text",text:c&&u&&h?s.text.trim():s.text,cache_control:m});break}case"reasoning":if(t){let t=await (0,n.c1)({provider:"anthropic",providerOptions:s.providerOptions,schema:d});null!=t?null!=t.signature?(M.getCacheControl(s.providerOptions,{type:"thinking block",canCache:!1}),e.push({type:"thinking",thinking:s.text,signature:t.signature})):null!=t.redactedData?(M.getCacheControl(s.providerOptions,{type:"redacted thinking block",canCache:!1}),e.push({type:"redacted_thinking",data:t.redactedData})):r.push({type:"other",message:"unsupported reasoning metadata"}):r.push({type:"other",message:"unsupported reasoning metadata"})}else r.push({type:"other",message:"sending reasoning content is disabled for this model"});break;case"tool-call":{if(s.providerExecuted){let t=i.toProviderToolName(s.toolName);if((null==(g=null==(_=s.providerOptions)?void 0:_.anthropic)?void 0:g.type)==="mcp-tool-use"){a.add(s.toolCallId);let t=null==(b=null==(v=s.providerOptions)?void 0:v.anthropic)?void 0:b.serverName;if(null==t||"string"!=typeof t){r.push({type:"other",message:"mcp tool use server name is required and must be a string"});break}e.push({type:"mcp_tool_use",id:s.toolCallId,name:s.toolName,input:s.input,server_name:t,cache_control:m})}else if("code_execution"===t&&null!=s.input&&"object"==typeof s.input&&"type"in s.input&&"string"==typeof s.input.type&&("bash_code_execution"===s.input.type||"text_editor_code_execution"===s.input.type))e.push({type:"server_tool_use",id:s.toolCallId,name:s.input.type,input:s.input,cache_control:m});else if("code_execution"===t&&null!=s.input&&"object"==typeof s.input&&"type"in s.input&&"programmatic-tool-call"===s.input.type){let{type:t,...r}=s.input;e.push({type:"server_tool_use",id:s.toolCallId,name:"code_execution",input:r,cache_control:m})}else"code_execution"===t||"web_fetch"===t||"web_search"===t?e.push({type:"server_tool_use",id:s.toolCallId,name:t,input:s.input,cache_control:m}):"tool_search_tool_regex"===t||"tool_search_tool_bm25"===t?e.push({type:"server_tool_use",id:s.toolCallId,name:t,input:s.input,cache_control:m}):r.push({type:"other",message:`provider executed tool call for tool ${s.toolName} is not supported`});break}let t=null==(w=s.providerOptions)?void 0:w.anthropic,n=(null==t?void 0:t.caller)?("code_execution_20250825"===t.caller.type||"code_execution_20260120"===t.caller.type)&&t.caller.toolId?{type:t.caller.type,tool_id:t.caller.toolId}:"direct"===t.caller.type?{type:"direct"}:void 0:void 0;e.push({type:"tool_use",id:s.toolCallId,name:s.toolName,input:s.input,...n&&{caller:n},cache_control:m});break}case"tool-result":{let t=i.toProviderToolName(s.toolName);if(a.has(s.toolCallId)){let t=s.output;if("json"!==t.type&&"error-json"!==t.type){r.push({type:"other",message:`provider executed tool result output type ${t.type} for tool ${s.toolName} is not supported`});break}e.push({type:"mcp_tool_result",tool_use_id:s.toolCallId,is_error:"error-json"===t.type,content:t.value,cache_control:m})}else if("code_execution"===t){let t=s.output;if("error-text"===t.type||"error-json"===t.type){let r={};try{"string"==typeof t.value?r=JSON.parse(t.value):"object"==typeof t.value&&null!==t.value&&(r=t.value)}catch(e){}"code_execution_tool_result_error"===r.type?e.push({type:"code_execution_tool_result",tool_use_id:s.toolCallId,content:{type:"code_execution_tool_result_error",error_code:null!=(k=r.errorCode)?k:"unknown"},cache_control:m}):e.push({type:"bash_code_execution_tool_result",tool_use_id:s.toolCallId,cache_control:m,content:{type:"bash_code_execution_tool_result_error",error_code:null!=(I=r.errorCode)?I:"unknown"}});break}if("json"!==t.type){r.push({type:"other",message:`provider executed tool result output type ${t.type} for tool ${s.toolName} is not supported`});break}if(null==t.value||"object"!=typeof t.value||!("type"in t.value)||"string"!=typeof t.value.type){r.push({type:"other",message:`provider executed tool result output value is not a valid code execution result for tool ${s.toolName}`});break}if("code_execution_result"===t.value.type){let r=await (0,n.rJ)({value:t.value,schema:$});e.push({type:"code_execution_tool_result",tool_use_id:s.toolCallId,content:{type:r.type,stdout:r.stdout,stderr:r.stderr,return_code:r.return_code,content:null!=(T=r.content)?T:[]},cache_control:m})}else if("encrypted_code_execution_result"===t.value.type){let r=await (0,n.rJ)({value:t.value,schema:q});"encrypted_code_execution_result"===r.type&&e.push({type:"code_execution_tool_result",tool_use_id:s.toolCallId,content:{type:r.type,encrypted_stdout:r.encrypted_stdout,stderr:r.stderr,return_code:r.return_code,content:null!=(R=r.content)?R:[]},cache_control:m})}else{let r=await (0,n.rJ)({value:t.value,schema:F});"code_execution_result"===r.type?e.push({type:"code_execution_tool_result",tool_use_id:s.toolCallId,content:{type:r.type,stdout:r.stdout,stderr:r.stderr,return_code:r.return_code,content:null!=(S=r.content)?S:[]},cache_control:m}):"bash_code_execution_result"===r.type||"bash_code_execution_tool_result_error"===r.type?e.push({type:"bash_code_execution_tool_result",tool_use_id:s.toolCallId,cache_control:m,content:r}):e.push({type:"text_editor_code_execution_tool_result",tool_use_id:s.toolCallId,cache_control:m,content:r})}break}if("web_fetch"===t){let t=s.output;if("error-json"===t.type){let r={};try{"string"==typeof t.value?r=JSON.parse(t.value):"object"==typeof t.value&&null!==t.value&&(r=t.value)}catch(a){let e=null==(Z=t.value)?void 0:Z.errorCode;r={errorCode:"string"==typeof e?e:"unknown"}}e.push({type:"web_fetch_tool_result",tool_use_id:s.toolCallId,content:{type:"web_fetch_tool_result_error",error_code:null!=(C=r.errorCode)?C:"unknown"},cache_control:m});break}if("json"!==t.type){r.push({type:"other",message:`provider executed tool result output type ${t.type} for tool ${s.toolName} is not supported`});break}let a=await (0,n.rJ)({value:t.value,schema:E});e.push({type:"web_fetch_tool_result",tool_use_id:s.toolCallId,content:{type:"web_fetch_result",url:a.url,retrieved_at:a.retrievedAt,content:{type:"document",title:a.content.title,citations:a.content.citations,source:{type:a.content.source.type,media_type:a.content.source.mediaType,data:a.content.source.data}}},cache_control:m});break}if("web_search"===t){let t=s.output;if("json"!==t.type){r.push({type:"other",message:`provider executed tool result output type ${t.type} for tool ${s.toolName} is not supported`});break}let a=await (0,n.rJ)({value:t.value,schema:x});e.push({type:"web_search_tool_result",tool_use_id:s.toolCallId,content:a.map(e=>({url:e.url,title:e.title,page_age:e.pageAge,encrypted_content:e.encryptedContent,type:e.type})),cache_control:m});break}if("tool_search_tool_regex"===t||"tool_search_tool_bm25"===t){let t=s.output;if("json"!==t.type){r.push({type:"other",message:`provider executed tool result output type ${t.type} for tool ${s.toolName} is not supported`});break}let a=(await (0,n.rJ)({value:t.value,schema:V})).map(e=>({type:"tool_reference",tool_name:e.toolName}));e.push({type:"tool_search_tool_result",tool_use_id:s.toolCallId,content:{type:"tool_search_tool_search_result",tool_references:a},cache_control:m});break}r.push({type:"other",message:`provider executed tool result for tool ${s.toolName} is not supported`})}}}}P.push({role:"assistant",content:e});break}default:throw Error(`content type: ${h}`)}}return{prompt:{system:O,messages:P},betas:A}}function J({finishReason:e,isJsonResponseFromTool:t}){switch(e){case"pause_turn":case"end_turn":case"stop_sequence":return"stop";case"refusal":return"content-filter";case"tool_use":return t?"stop":"tool-calls";case"max_tokens":case"model_context_window_exceeded":return"length";default:return"other"}}function H(e,t,r){var a;if("web_search_result_location"===e.type)return{type:"source",sourceType:"url",id:r(),url:e.url,title:e.title,providerMetadata:{anthropic:{citedText:e.cited_text,encryptedIndex:e.encrypted_index}}};if("page_location"!==e.type&&"char_location"!==e.type)return;let n=t[e.document_index];if(n)return{type:"source",sourceType:"document",id:r(),mediaType:n.mediaType,title:null!=(a=e.document_title)?a:n.title,filename:n.filename,providerMetadata:{anthropic:"page_location"===e.type?{citedText:e.cited_text,startPageNumber:e.start_page_number,endPageNumber:e.end_page_number}:{citedText:e.cited_text,startCharIndex:e.start_char_index,endCharIndex:e.end_char_index}}}}var Y=class{constructor(e,t){var r;this.specificationVersion="v3",this.modelId=e,this.config=t,this.generateId=null!=(r=t.generateId)?r:n.Ox}supportsUrl(e){return"https:"===e.protocol}get provider(){return this.config.provider}get providerOptionsName(){let e=this.config.provider,t=e.indexOf(".");return -1===t?e:e.substring(0,t)}get supportedUrls(){var e,t,r;return null!=(r=null==(t=(e=this.config).supportedUrls)?void 0:t.call(e))?r:{}}async getArgs({userSuppliedBetas:e,prompt:t,maxOutputTokens:r,temperature:a,topP:o,topK:i,frequencyPenalty:s,presencePenalty:l,stopSequences:u,responseFormat:d,seed:c,tools:m,toolChoice:f,providerOptions:y,stream:_}){var g,v,b,w,x,k,I,T;let R=[];null!=s&&R.push({type:"unsupported",feature:"frequencyPenalty"}),null!=l&&R.push({type:"unsupported",feature:"presencePenalty"}),null!=c&&R.push({type:"unsupported",feature:"seed"}),null!=a&&a>1?(R.push({type:"unsupported",feature:"temperature",details:`${a} exceeds anthropic maximum of 1.0. clamped to 1.0`}),a=1):null!=a&&a<0&&(R.push({type:"unsupported",feature:"temperature",details:`${a} is below anthropic minimum of 0. clamped to 0`}),a=0),(null==d?void 0:d.type)==="json"&&null==d.schema&&R.push({type:"unsupported",feature:"responseFormat",details:"JSON response format requires a schema. The response format is ignored."});let S=this.providerOptionsName,Z=await (0,n.c1)({provider:"anthropic",providerOptions:y,schema:p}),C="anthropic"!==S?await (0,n.c1)({provider:S,providerOptions:y,schema:p}):null,E=null!=C,O=Object.assign({},null!=Z?Z:{},null!=C?C:{}),{maxOutputTokens:A,supportsStructuredOutput:M,isKnownModel:$}=(T=this.modelId).includes("claude-sonnet-4-6")||T.includes("claude-opus-4-6")?{maxOutputTokens:128e3,supportsStructuredOutput:!0,isKnownModel:!0}:T.includes("claude-sonnet-4-5")||T.includes("claude-opus-4-5")||T.includes("claude-haiku-4-5")?{maxOutputTokens:64e3,supportsStructuredOutput:!0,isKnownModel:!0}:T.includes("claude-opus-4-1")?{maxOutputTokens:32e3,supportsStructuredOutput:!0,isKnownModel:!0}:T.includes("claude-sonnet-4-")?{maxOutputTokens:64e3,supportsStructuredOutput:!1,isKnownModel:!0}:T.includes("claude-opus-4-")?{maxOutputTokens:32e3,supportsStructuredOutput:!1,isKnownModel:!0}:T.includes("claude-3-haiku")?{maxOutputTokens:4096,supportsStructuredOutput:!1,isKnownModel:!0}:{maxOutputTokens:4096,supportsStructuredOutput:!1,isKnownModel:!1},P=(null==(g=this.config.supportsNativeStructuredOutput)||g)&&M,j=null!=(v=null==O?void 0:O.structuredOutputMode)?v:"auto",F="outputFormat"===j||"auto"===j&&P,z=(null==d?void 0:d.type)!=="json"||null==d.schema||F?void 0:{type:"function",name:"json",description:"Respond with a JSON object.",inputSchema:d.schema},D=null==O?void 0:O.contextManagement,q=new h,U=(0,n.U_)({tools:m,providerToolNames:{"anthropic.code_execution_20250522":"code_execution","anthropic.code_execution_20250825":"code_execution","anthropic.code_execution_20260120":"code_execution","anthropic.computer_20241022":"computer","anthropic.computer_20250124":"computer","anthropic.text_editor_20241022":"str_replace_editor","anthropic.text_editor_20250124":"str_replace_editor","anthropic.text_editor_20250429":"str_replace_based_edit_tool","anthropic.text_editor_20250728":"str_replace_based_edit_tool","anthropic.bash_20241022":"bash","anthropic.bash_20250124":"bash","anthropic.memory_20250818":"memory","anthropic.web_search_20250305":"web_search","anthropic.web_search_20260209":"web_search","anthropic.web_fetch_20250910":"web_fetch","anthropic.web_fetch_20260209":"web_fetch","anthropic.tool_search_regex_20251119":"tool_search_tool_regex","anthropic.tool_search_bm25_20251119":"tool_search_tool_bm25"}}),{prompt:L,betas:V}=await K({prompt:t,sendReasoning:null==(b=null==O?void 0:O.sendReasoning)||b,warnings:R,cacheControlValidator:q,toolNameMapping:U}),G=null==(w=null==O?void 0:O.thinking)?void 0:w.type,W="enabled"===G||"adaptive"===G,X="enabled"===G?null==(x=null==O?void 0:O.thinking)?void 0:x.budgetTokens:void 0,B=null!=r?r:A,J={model:this.modelId,max_tokens:B,temperature:a,top_k:i,top_p:o,stop_sequences:u,...W&&{thinking:{type:G,...null!=X&&{budget_tokens:X}}},...((null==O?void 0:O.effort)||F&&(null==d?void 0:d.type)==="json"&&null!=d.schema)&&{output_config:{...(null==O?void 0:O.effort)&&{effort:O.effort},...F&&(null==d?void 0:d.type)==="json"&&null!=d.schema&&{format:{type:"json_schema",schema:d.schema}}}},...(null==O?void 0:O.speed)&&{speed:O.speed},...(null==O?void 0:O.cacheControl)&&{cache_control:O.cacheControl},...(null==O?void 0:O.mcpServers)&&O.mcpServers.length>0&&{mcp_servers:O.mcpServers.map(e=>({type:e.type,name:e.name,url:e.url,authorization_token:e.authorizationToken,tool_configuration:e.toolConfiguration?{allowed_tools:e.toolConfiguration.allowedTools,enabled:e.toolConfiguration.enabled}:void 0}))},...(null==O?void 0:O.container)&&{container:O.container.skills&&O.container.skills.length>0?{id:O.container.id,skills:O.container.skills.map(e=>({type:e.type,skill_id:e.skillId,version:e.version}))}:O.container.id},system:L.system,messages:L.messages,...D&&{context_management:{edits:D.edits.map(e=>{let t=e.type;switch(t){case"clear_tool_uses_20250919":return{type:e.type,...void 0!==e.trigger&&{trigger:e.trigger},...void 0!==e.keep&&{keep:e.keep},...void 0!==e.clearAtLeast&&{clear_at_least:e.clearAtLeast},...void 0!==e.clearToolInputs&&{clear_tool_inputs:e.clearToolInputs},...void 0!==e.excludeTools&&{exclude_tools:e.excludeTools}};case"clear_thinking_20251015":return{type:e.type,...void 0!==e.keep&&{keep:e.keep}};case"compact_20260112":return{type:e.type,...void 0!==e.trigger&&{trigger:e.trigger},...void 0!==e.pauseAfterCompaction&&{pause_after_compaction:e.pauseAfterCompaction},...void 0!==e.instructions&&{instructions:e.instructions}};default:R.push({type:"other",message:`Unknown context management strategy: ${t}`});return}}).filter(e=>void 0!==e)}}};W?("enabled"===G&&null==X&&(R.push({type:"compatibility",feature:"extended thinking",details:"thinking budget is required when thinking is enabled. using default budget of 1024 tokens."}),J.thinking={type:"enabled",budget_tokens:1024},X=1024),null!=J.temperature&&(J.temperature=void 0,R.push({type:"unsupported",feature:"temperature",details:"temperature is not supported when thinking is enabled"})),null!=i&&(J.top_k=void 0,R.push({type:"unsupported",feature:"topK",details:"topK is not supported when thinking is enabled"})),null!=o&&(J.top_p=void 0,R.push({type:"unsupported",feature:"topP",details:"topP is not supported when thinking is enabled"})),J.max_tokens=B+(null!=X?X:0)):null!=o&&null!=a&&(R.push({type:"unsupported",feature:"topP",details:"topP is not supported when temperature is set. topP is ignored."}),J.top_p=void 0),$&&J.max_tokens>A&&(null!=r&&R.push({type:"unsupported",feature:"maxOutputTokens",details:`${J.max_tokens} (maxOutputTokens + thinkingBudget) is greater than ${this.modelId} ${A} max output tokens. The max output tokens have been limited to ${A}.`}),J.max_tokens=A),(null==O?void 0:O.mcpServers)&&O.mcpServers.length>0&&V.add("mcp-client-2025-04-04"),D&&(V.add("context-management-2025-06-27"),D.edits.some(e=>"compact_20260112"===e.type)&&V.add("compact-2026-01-12")),(null==O?void 0:O.container)&&O.container.skills&&O.container.skills.length>0&&(V.add("code-execution-2025-08-25"),V.add("skills-2025-10-02"),V.add("files-api-2025-04-14"),(null==m?void 0:m.some(e=>"provider"===e.type&&("anthropic.code_execution_20250825"===e.id||"anthropic.code_execution_20260120"===e.id)))||R.push({type:"other",message:"code execution tool is required when using skills"})),(null==O?void 0:O.effort)&&V.add("effort-2025-11-24"),(null==O?void 0:O.speed)==="fast"&&V.add("fast-mode-2026-02-01"),_&&(null==(k=null==O?void 0:O.toolStreaming)||k)&&V.add("fine-grained-tool-streaming-2025-05-14");let{tools:H,toolChoice:Y,toolWarnings:Q,betas:ee}=await N(null!=z?{tools:[...null!=m?m:[],z],toolChoice:{type:"required"},disableParallelToolUse:!0,cacheControlValidator:q,supportsStructuredOutput:!1}:{tools:null!=m?m:[],toolChoice:f,disableParallelToolUse:null==O?void 0:O.disableParallelToolUse,cacheControlValidator:q,supportsStructuredOutput:P}),et=q.getWarnings();return{args:{...J,tools:H,tool_choice:Y,stream:!0===_||void 0},warnings:[...R,...Q,...et],betas:new Set([...V,...ee,...e,...null!=(I=null==O?void 0:O.anthropicBeta)?I:[]]),usesJsonResponseTool:null!=z,toolNameMapping:U,providerOptionsName:S,usedCustomProviderKey:E}}async getHeaders({betas:e,headers:t}){return(0,n.NF)(await (0,n.DB)(this.config.headers),t,e.size>0?{"anthropic-beta":Array.from(e).join(",")}:{})}async getBetasFromHeaders(e){var t,r;let a=null!=(t=(await (0,n.DB)(this.config.headers))["anthropic-beta"])?t:"",o=null!=(r=null==e?void 0:e["anthropic-beta"])?r:"";return new Set([...a.toLowerCase().split(","),...o.toLowerCase().split(",")].map(e=>e.trim()).filter(e=>""!==e))}buildRequestUrl(e){var t,r,a;return null!=(a=null==(r=(t=this.config).buildRequestUrl)?void 0:r.call(t,this.config.baseURL,e))?a:`${this.config.baseURL}/messages`}transformRequestBody(e,t){var r,a,n;return null!=(n=null==(a=(r=this.config).transformRequestBody)?void 0:a.call(r,e,t))?n:e}extractCitationDocuments(e){return e.filter(e=>"user"===e.role).flatMap(e=>e.content).filter(e=>{var t,r;if("file"!==e.type||"application/pdf"!==e.mediaType&&"text/plain"!==e.mediaType)return!1;let a=null==(t=e.providerOptions)?void 0:t.anthropic,n=null==a?void 0:a.citations;return null!=(r=null==n?void 0:n.enabled)&&r}).map(e=>{var t;return{title:null!=(t=e.filename)?t:"Untitled Document",filename:e.filename,mediaType:e.mediaType}})}async doGenerate(e){var t,r,a,o,i,u,d;let{args:c,warnings:p,betas:h,usesJsonResponseTool:m,toolNameMapping:f,providerOptionsName:y,usedCustomProviderKey:_}=await this.getArgs({...e,stream:!1,userSuppliedBetas:await this.getBetasFromHeaders(e.headers)}),g=[...this.extractCitationDocuments(e.prompt)],v=Q(c.tools),{responseHeaders:b,value:w,rawValue:x}=await (0,n.A8)({url:this.buildRequestUrl(!1),headers:await this.getHeaders({betas:h,headers:e.headers}),body:this.transformRequestBody(c,h),failedResponseHandler:s,successfulResponseHandler:(0,n.tc)(l),abortSignal:e.abortSignal,fetch:this.config.fetch}),k=[],I={},T={},R=!1;for(let e of w.content)switch(e.type){case"text":if(!m&&(k.push({type:"text",text:e.text}),e.citations))for(let t of e.citations){let e=H(t,g,this.generateId);e&&k.push(e)}break;case"thinking":k.push({type:"reasoning",text:e.thinking,providerMetadata:{anthropic:{signature:e.signature}}});break;case"redacted_thinking":k.push({type:"reasoning",text:"",providerMetadata:{anthropic:{redactedData:e.data}}});break;case"compaction":k.push({type:"text",text:e.content,providerMetadata:{anthropic:{type:"compaction"}}});break;case"tool_use":if(m&&"json"===e.name)R=!0,k.push({type:"text",text:JSON.stringify(e.input)});else{let t=e.caller,r=t?{type:t.type,toolId:"tool_id"in t?t.tool_id:void 0}:void 0;k.push({type:"tool-call",toolCallId:e.id,toolName:e.name,input:JSON.stringify(e.input),...r&&{providerMetadata:{anthropic:{caller:r}}}})}break;case"server_tool_use":if("text_editor_code_execution"===e.name||"bash_code_execution"===e.name)k.push({type:"tool-call",toolCallId:e.id,toolName:f.toCustomToolName("code_execution"),input:JSON.stringify({type:e.name,...e.input}),providerExecuted:!0});else if("web_search"===e.name||"code_execution"===e.name||"web_fetch"===e.name){let t="code_execution"===e.name&&null!=e.input&&"object"==typeof e.input&&"code"in e.input&&!("type"in e.input)?{type:"programmatic-tool-call",...e.input}:e.input;k.push({type:"tool-call",toolCallId:e.id,toolName:f.toCustomToolName(e.name),input:JSON.stringify(t),providerExecuted:!0,...v&&"code_execution"===e.name?{dynamic:!0}:{}})}else("tool_search_tool_regex"===e.name||"tool_search_tool_bm25"===e.name)&&(T[e.id]=e.name,k.push({type:"tool-call",toolCallId:e.id,toolName:f.toCustomToolName(e.name),input:JSON.stringify(e.input),providerExecuted:!0}));break;case"mcp_tool_use":I[e.id]={type:"tool-call",toolCallId:e.id,toolName:e.name,input:JSON.stringify(e.input),providerExecuted:!0,dynamic:!0,providerMetadata:{anthropic:{type:"mcp-tool-use",serverName:e.server_name}}},k.push(I[e.id]);break;case"mcp_tool_result":k.push({type:"tool-result",toolCallId:e.tool_use_id,toolName:I[e.tool_use_id].toolName,isError:e.is_error,result:e.content,dynamic:!0,providerMetadata:I[e.tool_use_id].providerMetadata});break;case"web_fetch_tool_result":"web_fetch_result"===e.content.type?(g.push({title:null!=(t=e.content.content.title)?t:e.content.url,mediaType:e.content.content.source.media_type}),k.push({type:"tool-result",toolCallId:e.tool_use_id,toolName:f.toCustomToolName("web_fetch"),result:{type:"web_fetch_result",url:e.content.url,retrievedAt:e.content.retrieved_at,content:{type:e.content.content.type,title:e.content.content.title,citations:e.content.content.citations,source:{type:e.content.content.source.type,mediaType:e.content.content.source.media_type,data:e.content.content.source.data}}}})):"web_fetch_tool_result_error"===e.content.type&&k.push({type:"tool-result",toolCallId:e.tool_use_id,toolName:f.toCustomToolName("web_fetch"),isError:!0,result:{type:"web_fetch_tool_result_error",errorCode:e.content.error_code}});break;case"web_search_tool_result":if(Array.isArray(e.content))for(let t of(k.push({type:"tool-result",toolCallId:e.tool_use_id,toolName:f.toCustomToolName("web_search"),result:e.content.map(e=>{var t;return{url:e.url,title:e.title,pageAge:null!=(t=e.page_age)?t:null,encryptedContent:e.encrypted_content,type:e.type}})}),e.content))k.push({type:"source",sourceType:"url",id:this.generateId(),url:t.url,title:t.title,providerMetadata:{anthropic:{pageAge:null!=(r=t.page_age)?r:null}}});else k.push({type:"tool-result",toolCallId:e.tool_use_id,toolName:f.toCustomToolName("web_search"),isError:!0,result:{type:"web_search_tool_result_error",errorCode:e.content.error_code}});break;case"code_execution_tool_result":"code_execution_result"===e.content.type?k.push({type:"tool-result",toolCallId:e.tool_use_id,toolName:f.toCustomToolName("code_execution"),result:{type:e.content.type,stdout:e.content.stdout,stderr:e.content.stderr,return_code:e.content.return_code,content:null!=(a=e.content.content)?a:[]}}):"encrypted_code_execution_result"===e.content.type?k.push({type:"tool-result",toolCallId:e.tool_use_id,toolName:f.toCustomToolName("code_execution"),result:{type:e.content.type,encrypted_stdout:e.content.encrypted_stdout,stderr:e.content.stderr,return_code:e.content.return_code,content:null!=(o=e.content.content)?o:[]}}):"code_execution_tool_result_error"===e.content.type&&k.push({type:"tool-result",toolCallId:e.tool_use_id,toolName:f.toCustomToolName("code_execution"),isError:!0,result:{type:"code_execution_tool_result_error",errorCode:e.content.error_code}});break;case"bash_code_execution_tool_result":case"text_editor_code_execution_tool_result":k.push({type:"tool-result",toolCallId:e.tool_use_id,toolName:f.toCustomToolName("code_execution"),result:e.content});break;case"tool_search_tool_result":{let t=T[e.tool_use_id];if(null==t){let e=f.toCustomToolName("tool_search_tool_bm25");f.toCustomToolName("tool_search_tool_regex"),t="tool_search_tool_bm25"!==e?"tool_search_tool_bm25":"tool_search_tool_regex"}"tool_search_tool_search_result"===e.content.type?k.push({type:"tool-result",toolCallId:e.tool_use_id,toolName:f.toCustomToolName(t),result:e.content.tool_references.map(e=>({type:e.type,toolName:e.tool_name}))}):k.push({type:"tool-result",toolCallId:e.tool_use_id,toolName:f.toCustomToolName(t),isError:!0,result:{type:"tool_search_tool_result_error",errorCode:e.content.error_code}})}}return{content:k,finishReason:{unified:J({finishReason:w.stop_reason,isJsonResponseFromTool:R}),raw:null!=(i=w.stop_reason)?i:void 0},usage:M({usage:w.usage}),request:{body:c},response:{id:null!=(u=w.id)?u:void 0,modelId:null!=(d=w.model)?d:void 0,headers:b,body:x},warnings:p,providerMetadata:(()=>{var e,t,r,a,n;let o={usage:w.usage,cacheCreationInputTokens:null!=(e=w.usage.cache_creation_input_tokens)?e:null,stopSequence:null!=(t=w.stop_sequence)?t:null,iterations:w.usage.iterations?w.usage.iterations.map(e=>({type:e.type,inputTokens:e.input_tokens,outputTokens:e.output_tokens})):null,container:w.container?{expiresAt:w.container.expires_at,id:w.container.id,skills:null!=(a=null==(r=w.container.skills)?void 0:r.map(e=>({type:e.type,skillId:e.skill_id,version:e.version})))?a:null}:null,contextManagement:null!=(n=ee(w.context_management))?n:null},i={anthropic:o};return _&&"anthropic"!==y&&(i[y]=o),i})()}}async doStream(e){var t,r;let o,i;let{args:l,warnings:d,betas:c,usesJsonResponseTool:p,toolNameMapping:h,providerOptionsName:m,usedCustomProviderKey:f}=await this.getArgs({...e,stream:!0,userSuppliedBetas:await this.getBetasFromHeaders(e.headers)}),y=[...this.extractCitationDocuments(e.prompt)],_=Q(l.tools),g=this.buildRequestUrl(!0),{responseHeaders:v,value:b}=await (0,n.A8)({url:g,headers:await this.getHeaders({betas:c,headers:e.headers}),body:this.transformRequestBody(l,c),failedResponseHandler:s,successfulResponseHandler:(0,n.cP)(u),abortSignal:e.abortSignal,fetch:this.config.fetch}),w={unified:"other",raw:void 0},x={input_tokens:0,output_tokens:0,cache_creation_input_tokens:0,cache_read_input_tokens:0,iterations:null},k={},I={},T={},R=null,S=null,Z=null,C=null,E=!1,O=this.generateId,[A,N]=b.pipeThrough(new TransformStream({start(e){e.enqueue({type:"stream-start",warnings:d})},transform(t,r){var a,n,s,l,u,d,c,g,v,b,A,N,$,P;if(e.includeRawChunks&&r.enqueue({type:"raw",rawValue:t.rawValue}),!t.success){r.enqueue({type:"error",error:t.error});return}let j=t.value;switch(j.type){case"ping":return;case"content_block_start":{let e=j.content_block,t=e.type;switch(i=t,t){case"text":if(p)return;k[j.index]={type:"text"},r.enqueue({type:"text-start",id:String(j.index)});return;case"thinking":k[j.index]={type:"reasoning"},r.enqueue({type:"reasoning-start",id:String(j.index)});return;case"redacted_thinking":k[j.index]={type:"reasoning"},r.enqueue({type:"reasoning-start",id:String(j.index),providerMetadata:{anthropic:{redactedData:e.data}}});return;case"compaction":k[j.index]={type:"text"},r.enqueue({type:"text-start",id:String(j.index),providerMetadata:{anthropic:{type:"compaction"}}});return;case"tool_use":if(p&&"json"===e.name)E=!0,k[j.index]={type:"text"},r.enqueue({type:"text-start",id:String(j.index)});else{let t=e.caller,a=t?{type:t.type,toolId:"tool_id"in t?t.tool_id:void 0}:void 0,n=e.input&&Object.keys(e.input).length>0?JSON.stringify(e.input):"";k[j.index]={type:"tool-call",toolCallId:e.id,toolName:e.name,input:n,firstDelta:0===n.length,...a&&{caller:a}},r.enqueue({type:"tool-input-start",id:e.id,toolName:e.name})}return;case"server_tool_use":if(["web_fetch","web_search","code_execution","text_editor_code_execution","bash_code_execution"].includes(e.name)){let t="text_editor_code_execution"===e.name||"bash_code_execution"===e.name?"code_execution":e.name,a=h.toCustomToolName(t),n=null!=e.input&&"object"==typeof e.input&&Object.keys(e.input).length>0?JSON.stringify(e.input):"";k[j.index]={type:"tool-call",toolCallId:e.id,toolName:a,input:n,providerExecuted:!0,..._&&"code_execution"===t?{dynamic:!0}:{},firstDelta:!0,providerToolName:e.name},r.enqueue({type:"tool-input-start",id:e.id,toolName:a,providerExecuted:!0,..._&&"code_execution"===t?{dynamic:!0}:{}})}else if("tool_search_tool_regex"===e.name||"tool_search_tool_bm25"===e.name){T[e.id]=e.name;let t=h.toCustomToolName(e.name);k[j.index]={type:"tool-call",toolCallId:e.id,toolName:t,input:"",providerExecuted:!0,firstDelta:!0,providerToolName:e.name},r.enqueue({type:"tool-input-start",id:e.id,toolName:t,providerExecuted:!0})}return;case"web_fetch_tool_result":"web_fetch_result"===e.content.type?(y.push({title:null!=(a=e.content.content.title)?a:e.content.url,mediaType:e.content.content.source.media_type}),r.enqueue({type:"tool-result",toolCallId:e.tool_use_id,toolName:h.toCustomToolName("web_fetch"),result:{type:"web_fetch_result",url:e.content.url,retrievedAt:e.content.retrieved_at,content:{type:e.content.content.type,title:e.content.content.title,citations:e.content.content.citations,source:{type:e.content.content.source.type,mediaType:e.content.content.source.media_type,data:e.content.content.source.data}}}})):"web_fetch_tool_result_error"===e.content.type&&r.enqueue({type:"tool-result",toolCallId:e.tool_use_id,toolName:h.toCustomToolName("web_fetch"),isError:!0,result:{type:"web_fetch_tool_result_error",errorCode:e.content.error_code}});return;case"web_search_tool_result":if(Array.isArray(e.content))for(let t of(r.enqueue({type:"tool-result",toolCallId:e.tool_use_id,toolName:h.toCustomToolName("web_search"),result:e.content.map(e=>{var t;return{url:e.url,title:e.title,pageAge:null!=(t=e.page_age)?t:null,encryptedContent:e.encrypted_content,type:e.type}})}),e.content))r.enqueue({type:"source",sourceType:"url",id:O(),url:t.url,title:t.title,providerMetadata:{anthropic:{pageAge:null!=(n=t.page_age)?n:null}}});else r.enqueue({type:"tool-result",toolCallId:e.tool_use_id,toolName:h.toCustomToolName("web_search"),isError:!0,result:{type:"web_search_tool_result_error",errorCode:e.content.error_code}});return;case"code_execution_tool_result":"code_execution_result"===e.content.type?r.enqueue({type:"tool-result",toolCallId:e.tool_use_id,toolName:h.toCustomToolName("code_execution"),result:{type:e.content.type,stdout:e.content.stdout,stderr:e.content.stderr,return_code:e.content.return_code,content:null!=(s=e.content.content)?s:[]}}):"encrypted_code_execution_result"===e.content.type?r.enqueue({type:"tool-result",toolCallId:e.tool_use_id,toolName:h.toCustomToolName("code_execution"),result:{type:e.content.type,encrypted_stdout:e.content.encrypted_stdout,stderr:e.content.stderr,return_code:e.content.return_code,content:null!=(l=e.content.content)?l:[]}}):"code_execution_tool_result_error"===e.content.type&&r.enqueue({type:"tool-result",toolCallId:e.tool_use_id,toolName:h.toCustomToolName("code_execution"),isError:!0,result:{type:"code_execution_tool_result_error",errorCode:e.content.error_code}});return;case"bash_code_execution_tool_result":case"text_editor_code_execution_tool_result":r.enqueue({type:"tool-result",toolCallId:e.tool_use_id,toolName:h.toCustomToolName("code_execution"),result:e.content});return;case"tool_search_tool_result":{let t=T[e.tool_use_id];if(null==t){let e=h.toCustomToolName("tool_search_tool_bm25");h.toCustomToolName("tool_search_tool_regex"),t="tool_search_tool_bm25"!==e?"tool_search_tool_bm25":"tool_search_tool_regex"}"tool_search_tool_search_result"===e.content.type?r.enqueue({type:"tool-result",toolCallId:e.tool_use_id,toolName:h.toCustomToolName(t),result:e.content.tool_references.map(e=>({type:e.type,toolName:e.tool_name}))}):r.enqueue({type:"tool-result",toolCallId:e.tool_use_id,toolName:h.toCustomToolName(t),isError:!0,result:{type:"tool_search_tool_result_error",errorCode:e.content.error_code}});return}case"mcp_tool_use":I[e.id]={type:"tool-call",toolCallId:e.id,toolName:e.name,input:JSON.stringify(e.input),providerExecuted:!0,dynamic:!0,providerMetadata:{anthropic:{type:"mcp-tool-use",serverName:e.server_name}}},r.enqueue(I[e.id]);return;case"mcp_tool_result":r.enqueue({type:"tool-result",toolCallId:e.tool_use_id,toolName:I[e.tool_use_id].toolName,isError:e.is_error,result:e.content,dynamic:!0,providerMetadata:I[e.tool_use_id].providerMetadata});return;default:throw Error(`Unsupported content block type: ${t}`)}}case"content_block_stop":if(null!=k[j.index]){let e=k[j.index];switch(e.type){case"text":r.enqueue({type:"text-end",id:String(j.index)});break;case"reasoning":r.enqueue({type:"reasoning-end",id:String(j.index)});break;case"tool-call":if(!(p&&"json"===e.toolName)){r.enqueue({type:"tool-input-end",id:e.toolCallId});let t=""===e.input?"{}":e.input;if("code_execution"===e.providerToolName)try{let e=JSON.parse(t);null!=e&&"object"==typeof e&&"code"in e&&!("type"in e)&&(t=JSON.stringify({type:"programmatic-tool-call",...e}))}catch(e){}r.enqueue({type:"tool-call",toolCallId:e.toolCallId,toolName:e.toolName,input:t,providerExecuted:e.providerExecuted,..._&&"code_execution"===e.providerToolName?{dynamic:!0}:{},...e.caller&&{providerMetadata:{anthropic:{caller:e.caller}}}})}}delete k[j.index]}i=void 0;return;case"content_block_delta":{let e=j.delta.type;switch(e){case"text_delta":if(p)return;r.enqueue({type:"text-delta",id:String(j.index),delta:j.delta.text});return;case"thinking_delta":r.enqueue({type:"reasoning-delta",id:String(j.index),delta:j.delta.thinking});return;case"signature_delta":"thinking"===i&&r.enqueue({type:"reasoning-delta",id:String(j.index),delta:"",providerMetadata:{anthropic:{signature:j.delta.signature}}});return;case"compaction_delta":null!=j.delta.content&&r.enqueue({type:"text-delta",id:String(j.index),delta:j.delta.content});return;case"input_json_delta":{let e=k[j.index],t=j.delta.partial_json;if(0===t.length)return;if(E){if((null==e?void 0:e.type)!=="text")return;r.enqueue({type:"text-delta",id:String(j.index),delta:t})}else{if((null==e?void 0:e.type)!=="tool-call")return;e.firstDelta&&("bash_code_execution"===e.providerToolName||"text_editor_code_execution"===e.providerToolName)&&(t=`{"type": "${e.providerToolName}",${t.substring(1)}`),r.enqueue({type:"tool-input-delta",id:e.toolCallId,delta:t}),e.input+=t,e.firstDelta=!1}return}case"citations_delta":{let e=H(j.delta.citation,y,O);e&&r.enqueue(e);return}default:throw Error(`Unsupported delta type: ${e}`)}}case"message_start":if(x.input_tokens=j.message.usage.input_tokens,x.cache_read_input_tokens=null!=(u=j.message.usage.cache_read_input_tokens)?u:0,x.cache_creation_input_tokens=null!=(d=j.message.usage.cache_creation_input_tokens)?d:0,o={...j.message.usage},S=null!=(c=j.message.usage.cache_creation_input_tokens)?c:null,null!=j.message.container&&(C={expiresAt:j.message.container.expires_at,id:j.message.container.id,skills:null}),null!=j.message.stop_reason&&(w={unified:J({finishReason:j.message.stop_reason,isJsonResponseFromTool:E}),raw:j.message.stop_reason}),r.enqueue({type:"response-metadata",id:null!=(g=j.message.id)?g:void 0,modelId:null!=(v=j.message.model)?v:void 0}),null!=j.message.content)for(let e=0;e<j.message.content.length;e++){let t=j.message.content[e];if("tool_use"===t.type){let e=t.caller,a=e?{type:e.type,toolId:"tool_id"in e?e.tool_id:void 0}:void 0;r.enqueue({type:"tool-input-start",id:t.id,toolName:t.name});let n=JSON.stringify(null!=(b=t.input)?b:{});r.enqueue({type:"tool-input-delta",id:t.id,delta:n}),r.enqueue({type:"tool-input-end",id:t.id}),r.enqueue({type:"tool-call",toolCallId:t.id,toolName:t.name,input:n,...a&&{providerMetadata:{anthropic:{caller:a}}}})}}return;case"message_delta":null!=j.usage.input_tokens&&x.input_tokens!==j.usage.input_tokens&&(x.input_tokens=j.usage.input_tokens),x.output_tokens=j.usage.output_tokens,null!=j.usage.cache_read_input_tokens&&(x.cache_read_input_tokens=j.usage.cache_read_input_tokens),null!=j.usage.cache_creation_input_tokens&&(x.cache_creation_input_tokens=j.usage.cache_creation_input_tokens,S=j.usage.cache_creation_input_tokens),null!=j.usage.iterations&&(x.iterations=j.usage.iterations),w={unified:J({finishReason:j.delta.stop_reason,isJsonResponseFromTool:E}),raw:null!=(A=j.delta.stop_reason)?A:void 0},Z=null!=(N=j.delta.stop_sequence)?N:null,C=null!=j.delta.container?{expiresAt:j.delta.container.expires_at,id:j.delta.container.id,skills:null!=(P=null==($=j.delta.container.skills)?void 0:$.map(e=>({type:e.type,skillId:e.skill_id,version:e.version})))?P:null}:null,j.context_management&&(R=ee(j.context_management)),o={...o,...j.usage};return;case"message_stop":{let e={usage:null!=o?o:null,cacheCreationInputTokens:S,stopSequence:Z,iterations:x.iterations?x.iterations.map(e=>({type:e.type,inputTokens:e.input_tokens,outputTokens:e.output_tokens})):null,container:C,contextManagement:R},t={anthropic:e};f&&"anthropic"!==m&&(t[m]=e),r.enqueue({type:"finish",finishReason:w,usage:M({usage:x,rawUsage:o}),providerMetadata:t});return}case"error":r.enqueue({type:"error",error:j.error});return;default:throw Error(`Unsupported chunk type: ${j}`)}}})).tee(),$=A.getReader();try{await $.read();let e=await $.read();if((null==(t=e.value)?void 0:t.type)==="raw"&&(e=await $.read()),(null==(r=e.value)?void 0:r.type)==="error"){let t=e.value.error;throw new a.w({message:t.message,url:g,requestBodyValues:l,statusCode:"overloaded_error"===t.type?529:500,responseHeaders:v,responseBody:JSON.stringify(t),isRetryable:"overloaded_error"===t.type})}}finally{$.cancel().catch(()=>{}),$.releaseLock()}return{stream:N,request:{body:l},response:{headers:v}}}};function Q(e){if(!e)return!1;let t=!1,r=!1;for(let a of e){if("type"in a&&("web_fetch_20260209"===a.type||"web_search_20260209"===a.type)){t=!0;continue}if("code_execution"===a.name){r=!0;break}}return t&&!r}function ee(e){return e?{appliedEdits:e.applied_edits.map(e=>{switch(e.type){case"clear_tool_uses_20250919":return{type:e.type,clearedToolUses:e.cleared_tool_uses,clearedInputTokens:e.cleared_input_tokens};case"clear_thinking_20251015":return{type:e.type,clearedThinkingTurns:e.cleared_thinking_turns,clearedInputTokens:e.cleared_input_tokens};case"compact_20260112":return{type:e.type}}}).filter(e=>void 0!==e)}:null}var et=(0,n.DG)(()=>(0,n.r0)(o.Ry({command:o.Z_(),restart:o.O7().optional()}))),er=(0,n.W0)({id:"anthropic.bash_20241022",inputSchema:et}),ea=(0,n.DG)(()=>(0,n.r0)(o.Ry({command:o.Z_(),restart:o.O7().optional()}))),en=(0,n.W0)({id:"anthropic.bash_20250124",inputSchema:ea}),eo=(0,n.DG)(()=>(0,n.r0)(o.Ry({action:o.Km(["key","type","mouse_move","left_click","left_click_drag","right_click","middle_click","double_click","screenshot","cursor_position"]),coordinate:o.IX(o.Rx().int()).optional(),text:o.Z_().optional()}))),ei=(0,n.W0)({id:"anthropic.computer_20241022",inputSchema:eo}),es=(0,n.DG)(()=>(0,n.r0)(o.Ry({action:o.Km(["key","hold_key","type","cursor_position","mouse_move","left_mouse_down","left_mouse_up","left_click","left_click_drag","right_click","middle_click","double_click","triple_click","scroll","wait","screenshot"]),coordinate:o.bc([o.Rx().int(),o.Rx().int()]).optional(),duration:o.Rx().optional(),scroll_amount:o.Rx().optional(),scroll_direction:o.Km(["up","down","left","right"]).optional(),start_coordinate:o.bc([o.Rx().int(),o.Rx().int()]).optional(),text:o.Z_().optional()}))),el=(0,n.W0)({id:"anthropic.computer_20250124",inputSchema:es}),eu=(0,n.DG)(()=>(0,n.r0)(o.Ry({action:o.Km(["key","hold_key","type","cursor_position","mouse_move","left_mouse_down","left_mouse_up","left_click","left_click_drag","right_click","middle_click","double_click","triple_click","scroll","wait","screenshot","zoom"]),coordinate:o.bc([o.Rx().int(),o.Rx().int()]).optional(),duration:o.Rx().optional(),region:o.bc([o.Rx().int(),o.Rx().int(),o.Rx().int(),o.Rx().int()]).optional(),scroll_amount:o.Rx().optional(),scroll_direction:o.Km(["up","down","left","right"]).optional(),start_coordinate:o.bc([o.Rx().int(),o.Rx().int()]).optional(),text:o.Z_().optional()}))),ed=(0,n.W0)({id:"anthropic.computer_20251124",inputSchema:eu}),ec=(0,n.DG)(()=>(0,n.r0)(o.VK("command",[o.Ry({command:o.i0("view"),path:o.Z_(),view_range:o.bc([o.Rx(),o.Rx()]).optional()}),o.Ry({command:o.i0("create"),path:o.Z_(),file_text:o.Z_()}),o.Ry({command:o.i0("str_replace"),path:o.Z_(),old_str:o.Z_(),new_str:o.Z_()}),o.Ry({command:o.i0("insert"),path:o.Z_(),insert_line:o.Rx(),insert_text:o.Z_()}),o.Ry({command:o.i0("delete"),path:o.Z_()}),o.Ry({command:o.i0("rename"),old_path:o.Z_(),new_path:o.Z_()})]))),ep=(0,n.W0)({id:"anthropic.memory_20250818",inputSchema:ec}),eh=(0,n.DG)(()=>(0,n.r0)(o.Ry({command:o.Km(["view","create","str_replace","insert","undo_edit"]),path:o.Z_(),file_text:o.Z_().optional(),insert_line:o.Rx().int().optional(),new_str:o.Z_().optional(),insert_text:o.Z_().optional(),old_str:o.Z_().optional(),view_range:o.IX(o.Rx().int()).optional()}))),em=(0,n.W0)({id:"anthropic.text_editor_20241022",inputSchema:eh}),ef=(0,n.DG)(()=>(0,n.r0)(o.Ry({command:o.Km(["view","create","str_replace","insert","undo_edit"]),path:o.Z_(),file_text:o.Z_().optional(),insert_line:o.Rx().int().optional(),new_str:o.Z_().optional(),insert_text:o.Z_().optional(),old_str:o.Z_().optional(),view_range:o.IX(o.Rx().int()).optional()}))),ey=(0,n.W0)({id:"anthropic.text_editor_20250124",inputSchema:ef}),e_=(0,n.DG)(()=>(0,n.r0)(o.Ry({command:o.Km(["view","create","str_replace","insert"]),path:o.Z_(),file_text:o.Z_().optional(),insert_line:o.Rx().int().optional(),new_str:o.Z_().optional(),insert_text:o.Z_().optional(),old_str:o.Z_().optional(),view_range:o.IX(o.Rx().int()).optional()}))),eg=(0,n.W0)({id:"anthropic.text_editor_20250429",inputSchema:e_}),ev=(0,n.DG)(()=>(0,n.r0)(o.IX(o.Ry({type:o.i0("tool_reference"),toolName:o.Z_()})))),eb=(0,n.DG)(()=>(0,n.r0)(o.Ry({query:o.Z_(),limit:o.Rx().optional()}))),ew=(0,n.ql)({id:"anthropic.tool_search_bm25_20251119",inputSchema:eb,outputSchema:ev,supportsDeferredResults:!0}),ex={bash_20241022:er,bash_20250124:en,codeExecution_20250522:(e={})=>j(e),codeExecution_20250825:(e={})=>D(e),codeExecution_20260120:(e={})=>L(e),computer_20241022:ei,computer_20250124:el,computer_20251124:ed,memory_20250818:ep,textEditor_20241022:em,textEditor_20250124:ey,textEditor_20250429:eg,textEditor_20250728:(e={})=>y(e),webFetch_20250910:(e={})=>A(e),webFetch_20260209:(e={})=>Z(e),webSearch_20250305:(e={})=>I(e),webSearch_20260209:(e={})=>b(e),toolSearchRegex_20251119:(e={})=>W(e),toolSearchBm25_20251119:(e={})=>ew(e)};function ek(e={}){var t,r;let o=null!=(t=(0,n.QT)((0,n.P6)({settingValue:e.baseURL,environmentVariableName:"ANTHROPIC_BASE_URL"})))?t:"https://api.anthropic.com/v1",i=null!=(r=e.name)?r:"anthropic.messages";if(e.apiKey&&e.authToken)throw new a.RU({argument:"apiKey/authToken",message:"Both apiKey and authToken were provided. Please use only one authentication method."});let s=()=>{let t=e.authToken?{Authorization:`Bearer ${e.authToken}`}:{"x-api-key":(0,n.pd)({apiKey:e.apiKey,environmentVariableName:"ANTHROPIC_API_KEY",description:"Anthropic"})};return(0,n.CR)({"anthropic-version":"2023-06-01",...t,...e.headers},"ai-sdk/anthropic/3.0.58")},l=t=>{var r;return new Y(t,{provider:i,baseURL:o,headers:s,fetch:e.fetch,generateId:null!=(r=e.generateId)?r:n.Ox,supportedUrls:()=>({"image/*":[/^https?:\/\/.*$/],"application/pdf":[/^https?:\/\/.*$/]})})},u=function(e){if(new.target)throw Error("The Anthropic model function cannot be called with the new keyword.");return l(e)};return u.specificationVersion="v3",u.languageModel=l,u.chat=l,u.messages=l,u.embeddingModel=e=>{throw new a.JJ({modelId:e,modelType:"embeddingModel"})},u.textEmbeddingModel=u.embeddingModel,u.imageModel=e=>{throw new a.JJ({modelId:e,modelType:"imageModel"})},u.tools=ex,u}ek()},6365:(e,t,r)=>{r.d(t,{N$:()=>C,eh:()=>g,Bx:()=>Z,C3:()=>eM,NF:()=>m,MS:()=>x,QF:()=>I,k0:()=>k,cP:()=>eJ,bF:()=>M,Sq:()=>eK,tc:()=>eH,W0:()=>eW,ql:()=>eX,U_:()=>f,gw:()=>y,aN:()=>eQ,Ox:()=>$,e$:()=>P,hb:()=>W,gJ:()=>q,D_:()=>j,C_:()=>X,MT:()=>B,fB:()=>eN,DG:()=>eA,pd:()=>K,P6:()=>J,kh:()=>U,RF:()=>eD,c1:()=>eq,A8:()=>eL,SN:()=>E,DB:()=>eB,NX:()=>ez,pW:()=>ej,w3:()=>eG,SA:()=>O,rJ:()=>eP,CR:()=>L,QT:()=>eY,r0:()=>e$});var a,n,o=r(9519),i=r(6496),s=r(8510);class l{constructor(e){this.counter=0,this.metadataRegistry=e?.metadata??i.$Z,this.target=e?.target??"draft-2020-12",this.unrepresentable=e?.unrepresentable??"throw",this.override=e?.override??(()=>{}),this.io=e?.io??"output",this.seen=new Map}process(e,t={path:[],schemaPath:[]}){var r;let a=e._zod.def,n=this.seen.get(e);if(n)return n.count++,t.schemaPath.includes(e)&&(n.cycle=t.path),n.schema;let o={schema:{},count:1,cycle:void 0,path:t.path};this.seen.set(e,o);let i=e._zod.toJSONSchema?.();if(i)o.schema=i;else{let r={...t,schemaPath:[...t.schemaPath,e],path:t.path},n=e._zod.parent;if(n)o.ref=n,this.process(n,r),this.seen.get(n).isParent=!0;else{let t=o.schema;switch(a.type){case"string":{t.type="string";let{minimum:r,maximum:a,format:n,patterns:i,contentEncoding:s}=e._zod.bag;if("number"==typeof r&&(t.minLength=r),"number"==typeof a&&(t.maxLength=a),n&&(t.format=({guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""})[n]??n,""===t.format&&delete t.format),s&&(t.contentEncoding=s),i&&i.size>0){let e=[...i];1===e.length?t.pattern=e[0].source:e.length>1&&(o.schema.allOf=[...e.map(e=>({..."draft-7"===this.target?{type:"string"}:{},pattern:e.source}))])}break}case"number":{let{minimum:r,maximum:a,format:n,multipleOf:o,exclusiveMaximum:i,exclusiveMinimum:s}=e._zod.bag;"string"==typeof n&&n.includes("int")?t.type="integer":t.type="number","number"==typeof s&&(t.exclusiveMinimum=s),"number"==typeof r&&(t.minimum=r,"number"==typeof s&&(s>=r?delete t.minimum:delete t.exclusiveMinimum)),"number"==typeof i&&(t.exclusiveMaximum=i),"number"==typeof a&&(t.maximum=a,"number"==typeof i&&(i<=a?delete t.maximum:delete t.exclusiveMaximum)),"number"==typeof o&&(t.multipleOf=o);break}case"boolean":case"success":t.type="boolean";break;case"bigint":if("throw"===this.unrepresentable)throw Error("BigInt cannot be represented in JSON Schema");break;case"symbol":if("throw"===this.unrepresentable)throw Error("Symbols cannot be represented in JSON Schema");break;case"null":t.type="null";break;case"any":case"unknown":break;case"undefined":if("throw"===this.unrepresentable)throw Error("Undefined cannot be represented in JSON Schema");break;case"void":if("throw"===this.unrepresentable)throw Error("Void cannot be represented in JSON Schema");break;case"never":t.not={};break;case"date":if("throw"===this.unrepresentable)throw Error("Date cannot be represented in JSON Schema");break;case"array":{let{minimum:n,maximum:o}=e._zod.bag;"number"==typeof n&&(t.minItems=n),"number"==typeof o&&(t.maxItems=o),t.type="array",t.items=this.process(a.element,{...r,path:[...r.path,"items"]});break}case"object":{t.type="object",t.properties={};let e=a.shape;for(let a in e)t.properties[a]=this.process(e[a],{...r,path:[...r.path,"properties",a]});let n=new Set([...new Set(Object.keys(e))].filter(e=>{let t=a.shape[e]._zod;return"input"===this.io?void 0===t.optin:void 0===t.optout}));n.size>0&&(t.required=Array.from(n)),a.catchall?._zod.def.type==="never"?t.additionalProperties=!1:a.catchall?a.catchall&&(t.additionalProperties=this.process(a.catchall,{...r,path:[...r.path,"additionalProperties"]})):"output"===this.io&&(t.additionalProperties=!1);break}case"union":t.anyOf=a.options.map((e,t)=>this.process(e,{...r,path:[...r.path,"anyOf",t]}));break;case"intersection":{let e=this.process(a.left,{...r,path:[...r.path,"allOf",0]}),n=this.process(a.right,{...r,path:[...r.path,"allOf",1]}),o=[..."allOf"in e&&1===Object.keys(e).length?e.allOf:[e],..."allOf"in n&&1===Object.keys(n).length?n.allOf:[n]];t.allOf=o;break}case"tuple":{t.type="array";let n=a.items.map((e,t)=>this.process(e,{...r,path:[...r.path,"prefixItems",t]}));if("draft-2020-12"===this.target?t.prefixItems=n:t.items=n,a.rest){let e=this.process(a.rest,{...r,path:[...r.path,"items"]});"draft-2020-12"===this.target?t.items=e:t.additionalItems=e}a.rest&&(t.items=this.process(a.rest,{...r,path:[...r.path,"items"]}));let{minimum:o,maximum:i}=e._zod.bag;"number"==typeof o&&(t.minItems=o),"number"==typeof i&&(t.maxItems=i);break}case"record":t.type="object",t.propertyNames=this.process(a.keyType,{...r,path:[...r.path,"propertyNames"]}),t.additionalProperties=this.process(a.valueType,{...r,path:[...r.path,"additionalProperties"]});break;case"map":if("throw"===this.unrepresentable)throw Error("Map cannot be represented in JSON Schema");break;case"set":if("throw"===this.unrepresentable)throw Error("Set cannot be represented in JSON Schema");break;case"enum":{let e=(0,s.B8)(a.entries);e.every(e=>"number"==typeof e)&&(t.type="number"),e.every(e=>"string"==typeof e)&&(t.type="string"),t.enum=e;break}case"literal":{let e=[];for(let t of a.values)if(void 0===t){if("throw"===this.unrepresentable)throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if("bigint"==typeof t){if("throw"===this.unrepresentable)throw Error("BigInt literals cannot be represented in JSON Schema");e.push(Number(t))}else e.push(t);if(0===e.length);else if(1===e.length){let r=e[0];t.type=null===r?"null":typeof r,t.const=r}else e.every(e=>"number"==typeof e)&&(t.type="number"),e.every(e=>"string"==typeof e)&&(t.type="string"),e.every(e=>"boolean"==typeof e)&&(t.type="string"),e.every(e=>null===e)&&(t.type="null"),t.enum=e;break}case"file":{let r={type:"string",format:"binary",contentEncoding:"binary"},{minimum:a,maximum:n,mime:o}=e._zod.bag;void 0!==a&&(r.minLength=a),void 0!==n&&(r.maxLength=n),o?1===o.length?(r.contentMediaType=o[0],Object.assign(t,r)):t.anyOf=o.map(e=>({...r,contentMediaType:e})):Object.assign(t,r);break}case"transform":if("throw"===this.unrepresentable)throw Error("Transforms cannot be represented in JSON Schema");break;case"nullable":{let e=this.process(a.innerType,r);t.anyOf=[e,{type:"null"}];break}case"nonoptional":case"promise":case"optional":this.process(a.innerType,r),o.ref=a.innerType;break;case"default":this.process(a.innerType,r),o.ref=a.innerType,t.default=JSON.parse(JSON.stringify(a.defaultValue));break;case"prefault":this.process(a.innerType,r),o.ref=a.innerType,"input"===this.io&&(t._prefault=JSON.parse(JSON.stringify(a.defaultValue)));break;case"catch":{let e;this.process(a.innerType,r),o.ref=a.innerType;try{e=a.catchValue(void 0)}catch{throw Error("Dynamic catch values are not supported in JSON Schema")}t.default=e;break}case"nan":if("throw"===this.unrepresentable)throw Error("NaN cannot be represented in JSON Schema");break;case"template_literal":{let r=e._zod.pattern;if(!r)throw Error("Pattern not found in template literal");t.type="string",t.pattern=r.source;break}case"pipe":{let e="input"===this.io?"transform"===a.in._zod.def.type?a.out:a.in:a.out;this.process(e,r),o.ref=e;break}case"readonly":this.process(a.innerType,r),o.ref=a.innerType,t.readOnly=!0;break;case"lazy":{let t=e._zod.innerType;this.process(t,r),o.ref=t;break}case"custom":if("throw"===this.unrepresentable)throw Error("Custom types cannot be represented in JSON Schema")}}}let l=this.metadataRegistry.get(e);return l&&Object.assign(o.schema,l),"input"===this.io&&function e(t,r){let a=r??{seen:new Set};if(a.seen.has(t))return!1;a.seen.add(t);let n=t._zod.def;switch(n.type){case"string":case"number":case"bigint":case"boolean":case"date":case"symbol":case"undefined":case"null":case"any":case"unknown":case"never":case"void":case"literal":case"enum":case"nan":case"file":case"template_literal":case"custom":case"success":case"catch":return!1;case"array":return e(n.element,a);case"object":for(let t in n.shape)if(e(n.shape[t],a))return!0;return!1;case"union":for(let t of n.options)if(e(t,a))return!0;return!1;case"intersection":return e(n.left,a)||e(n.right,a);case"tuple":for(let t of n.items)if(e(t,a))return!0;if(n.rest&&e(n.rest,a))return!0;return!1;case"record":case"map":return e(n.keyType,a)||e(n.valueType,a);case"set":return e(n.valueType,a);case"promise":case"optional":case"nonoptional":case"nullable":case"readonly":case"default":case"prefault":return e(n.innerType,a);case"lazy":return e(n.getter(),a);case"transform":return!0;case"pipe":return e(n.in,a)||e(n.out,a)}throw Error(`Unknown schema type: ${n.type}`)}(e)&&(delete o.schema.examples,delete o.schema.default),"input"===this.io&&o.schema._prefault&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,this.seen.get(e).schema}emit(e,t){let r={cycles:t?.cycles??"ref",reused:t?.reused??"inline",external:t?.external??void 0},a=this.seen.get(e);if(!a)throw Error("Unprocessed schema. This is a bug in Zod.");let n=e=>{let t="draft-2020-12"===this.target?"$defs":"definitions";if(r.external){let a=r.external.registry.get(e[0])?.id,n=r.external.uri??(e=>e);if(a)return{ref:n(a)};let o=e[1].defId??e[1].schema.id??`schema${this.counter++}`;return e[1].defId=o,{defId:o,ref:`${n("__shared")}#/${t}/${o}`}}if(e[1]===a)return{ref:"#"};let n=`#/${t}/`,o=e[1].schema.id??`__schema${this.counter++}`;return{defId:o,ref:n+o}},o=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:r,defId:a}=n(e);t.def={...t.schema},a&&(t.defId=a);let o=t.schema;for(let e in o)delete o[e];o.$ref=r};if("throw"===r.cycles)for(let e of this.seen.entries()){let t=e[1];if(t.cycle)throw Error(`Cycle detected: #/${t.cycle?.join("/")}/<root>
|
|
30
|
+
|
|
31
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let t of this.seen.entries()){let a=t[1];if(e===t[0]){o(t);continue}if(r.external){let a=r.external.registry.get(t[0])?.id;if(e!==t[0]&&a){o(t);continue}}if(this.metadataRegistry.get(t[0])?.id||a.cycle||a.count>1&&"ref"===r.reused){o(t);continue}}let i=(e,t)=>{let r=this.seen.get(e),a=r.def??r.schema,n={...a};if(null===r.ref)return;let o=r.ref;if(r.ref=null,o){i(o,t);let e=this.seen.get(o).schema;e.$ref&&"draft-7"===t.target?(a.allOf=a.allOf??[],a.allOf.push(e)):(Object.assign(a,e),Object.assign(a,n))}r.isParent||this.override({zodSchema:e,jsonSchema:a,path:r.path??[]})};for(let e of[...this.seen.entries()].reverse())i(e[0],{target:this.target});let s={};if("draft-2020-12"===this.target?s.$schema="https://json-schema.org/draft/2020-12/schema":"draft-7"===this.target?s.$schema="http://json-schema.org/draft-07/schema#":console.warn(`Invalid target: ${this.target}`),r.external?.uri){let t=r.external.registry.get(e)?.id;if(!t)throw Error("Schema is missing an `id` property");s.$id=r.external.uri(t)}Object.assign(s,a.def);let l=r.external?.defs??{};for(let e of this.seen.entries()){let t=e[1];t.def&&t.defId&&(l[t.defId]=t.def)}r.external||Object.keys(l).length>0&&("draft-2020-12"===this.target?s.$defs=l:s.definitions=l);try{return JSON.parse(JSON.stringify(s))}catch(e){throw Error("Error converting schema to JSON.")}}}var u=r(3947),d=r(9763);class c extends Error{constructor(e,t){super(e),this.name="ParseError",this.type=t.type,this.field=t.field,this.value=t.value,this.line=t.line}}function p(e){}class h extends TransformStream{constructor({onError:e,onRetry:t,onComment:r}={}){let a;super({start(n){a=function(e){if("function"==typeof e)throw TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");let{onEvent:t=p,onError:r=p,onRetry:a=p,onComment:n}=e,o="",i=!0,s,l="",u="";function d(e){if(""===e){l.length>0&&t({id:s,event:u||void 0,data:l.endsWith(`
|
|
32
|
+
`)?l.slice(0,-1):l}),s=void 0,l="",u="";return}if(e.startsWith(":")){n&&n(e.slice(e.startsWith(": ")?2:1));return}let r=e.indexOf(":");if(-1!==r){let t=e.slice(0,r),a=" "===e[r+1]?2:1;h(t,e.slice(r+a),e);return}h(e,"",e)}function h(e,t,n){switch(e){case"event":u=t;break;case"data":l=`${l}${t}
|
|
33
|
+
`;break;case"id":s=t.includes("\0")?void 0:t;break;case"retry":/^\d+$/.test(t)?a(parseInt(t,10)):r(new c(`Invalid \`retry\` value: "${t}"`,{type:"invalid-retry",value:t,line:n}));break;default:r(new c(`Unknown field "${e.length>20?`${e.slice(0,20)}\u2026`:e}"`,{type:"unknown-field",field:e,value:t,line:n}))}}return{feed:function(e){let t=i?e.replace(/^\xEF\xBB\xBF/,""):e,[r,a]=function(e){let t=[],r="",a=0;for(;a<e.length;){let n=e.indexOf("\r",a),o=e.indexOf(`
|
|
34
|
+
`,a),i=-1;if(-1!==n&&-1!==o?i=Math.min(n,o):-1!==n?i=n===e.length-1?-1:n:-1!==o&&(i=o),-1===i){r=e.slice(a);break}{let r=e.slice(a,i);t.push(r),"\r"===e[(a=i+1)-1]&&e[a]===`
|
|
35
|
+
`&&a++}}return[t,r]}(`${o}${t}`);for(let e of r)d(e);o=a,i=!1},reset:function(e={}){o&&e.consume&&d(o),i=!0,s=void 0,l="",u="",o=""}}}({onEvent:e=>{n.enqueue(e)},onError(t){"terminate"===e?n.error(t):"function"==typeof e&&e(t)},onRetry:t,onComment:r})},transform(e){a.feed(e)}})}}function m(...e){return e.reduce((e,t)=>({...e,...null!=t?t:{}}),{})}function f({tools:e=[],providerToolNames:t,resolveProviderToolName:r}){var a;let n={},o={};for(let i of e)if("provider"===i.type){let e=null!=(a=null==r?void 0:r(i))?a:i.id in t?t[i.id]:void 0;if(null==e)continue;n[i.name]=e,o[e]=i.name}return{toProviderToolName:e=>{var t;return null!=(t=n[e])?t:e},toCustomToolName:e=>{var t;return null!=(t=o[e])?t:e}}}async function y(e,t){if(null==e)return Promise.resolve();let r=null==t?void 0:t.abortSignal;return new Promise((t,a)=>{if(null==r?void 0:r.aborted){a(_());return}let n=setTimeout(()=>{o(),t()},e),o=()=>{clearTimeout(n),null==r||r.removeEventListener("abort",i)},i=()=>{o(),a(_())};null==r||r.addEventListener("abort",i)})}function _(){return new DOMException("Delay was aborted","AbortError")}var g=class{constructor(){this.status={type:"pending"},this._resolve=void 0,this._reject=void 0}get promise(){return this._promise||(this._promise=new Promise((e,t)=>{"resolved"===this.status.type?e(this.status.value):"rejected"===this.status.type&&t(this.status.error),this._resolve=e,this._reject=t})),this._promise}resolve(e){var t;this.status={type:"resolved",value:e},this._promise&&(null==(t=this._resolve)||t.call(this,e))}reject(e){var t;this.status={type:"rejected",error:e},this._promise&&(null==(t=this._reject)||t.call(this,e))}isResolved(){return"resolved"===this.status.type}isRejected(){return"rejected"===this.status.type}isPending(){return"pending"===this.status.type}};function v(e){return Object.fromEntries([...e.headers])}var{btoa:b,atob:w}=globalThis;function x(e){let t=w(e.replace(/-/g,"+").replace(/_/g,"/"));return Uint8Array.from(t,e=>e.codePointAt(0))}function k(e){let t="";for(let r=0;r<e.length;r++)t+=String.fromCodePoint(e[r]);return b(t)}function I(e){return e instanceof Uint8Array?k(e):e}var T="AI_DownloadError",R=`vercel.ai.error.${T}`,S=Symbol.for(R),Z=class extends(n=o.AX,a=S,n){constructor({url:e,statusCode:t,statusText:r,cause:n,message:o=null==n?`Failed to download ${e}: ${t} ${r}`:`Failed to download ${e}: ${n}`}){super({name:T,message:o,cause:n}),this[a]=!0,this.url=e,this.statusCode=t,this.statusText=r}static isInstance(e){return o.AX.hasMarker(e,R)}},C=2147483648;async function E({response:e,url:t,maxBytes:r=C}){let a=e.headers.get("content-length");if(null!=a){let e=parseInt(a,10);if(!isNaN(e)&&e>r)throw new Z({url:t,message:`Download of ${t} exceeded maximum size of ${r} bytes (Content-Length: ${e}).`})}let n=e.body;if(null==n)return new Uint8Array(0);let o=n.getReader(),i=[],s=0;try{for(;;){let{done:e,value:a}=await o.read();if(e)break;if((s+=a.length)>r)throw new Z({url:t,message:`Download of ${t} exceeded maximum size of ${r} bytes.`});i.push(a)}}finally{try{await o.cancel()}finally{o.releaseLock()}}let l=new Uint8Array(s),u=0;for(let e of i)l.set(e,u),u+=e.length;return l}function O(e){let t;try{t=new URL(e)}catch(t){throw new Z({url:e,message:`Invalid URL: ${e}`})}if("http:"!==t.protocol&&"https:"!==t.protocol)throw new Z({url:e,message:`URL scheme must be http or https, got ${t.protocol}`});let r=t.hostname;if(!r)throw new Z({url:e,message:"URL must have a hostname"});if("localhost"===r||r.endsWith(".local")||r.endsWith(".localhost"))throw new Z({url:e,message:`URL with hostname ${r} is not allowed`});if(r.startsWith("[")&&r.endsWith("]")){if(function(e){let t=e.toLowerCase();if("::1"===t||"::"===t)return!0;if(t.startsWith("::ffff:")){let e=t.slice(7);if(A(e))return N(e);let r=e.split(":");if(2===r.length){let e=parseInt(r[0],16),t=parseInt(r[1],16);if(!isNaN(e)&&!isNaN(t))return N(`${e>>8&255}.${255&e}.${t>>8&255}.${255&t}`)}}return!!(t.startsWith("fc")||t.startsWith("fd")||t.startsWith("fe80"))}(r.slice(1,-1)))throw new Z({url:e,message:`URL with IPv6 address ${r} is not allowed`});return}if(A(r)){if(N(r))throw new Z({url:e,message:`URL with IP address ${r} is not allowed`});return}}function A(e){let t=e.split(".");return 4===t.length&&t.every(e=>{let t=Number(e);return Number.isInteger(t)&&t>=0&&t<=255&&String(t)===e})}function N(e){let[t,r]=e.split(".").map(Number);return 0===t||10===t||127===t||169===t&&254===r||172===t&&r>=16&&r<=31||192===t&&168===r}var M=({prefix:e,size:t=16,alphabet:r="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",separator:a="-"}={})=>{let n=()=>{let e=r.length,a=Array(t);for(let n=0;n<t;n++)a[n]=r[Math.random()*e|0];return a.join("")};if(null==e)return n;if(r.includes(a))throw new o.RU({argument:"separator",message:`The separator "${a}" must not be part of the alphabet "${r}".`});return()=>`${e}${a}${n()}`},$=M();function P(e){return null==e?"unknown error":"string"==typeof e?e:e instanceof Error?e.message:JSON.stringify(e)}function j(e){return(e instanceof Error||e instanceof DOMException)&&("AbortError"===e.name||"ResponseAborted"===e.name||"TimeoutError"===e.name)}var F=["fetch failed","failed to fetch"],z=["ConnectionRefused","ConnectionClosed","FailedToOpenSocket","ECONNRESET","ECONNREFUSED","ETIMEDOUT","EPIPE"];function D({error:e,url:t,requestBodyValues:r}){if(j(e))return e;if(e instanceof TypeError&&F.includes(e.message.toLowerCase())){let a=e.cause;if(null!=a)return new o.w({message:`Cannot connect to API: ${a.message}`,cause:a,url:t,requestBodyValues:r,isRetryable:!0})}return!function(e){if(!(e instanceof Error))return!1;let t=e.code;return!!("string"==typeof t&&z.includes(t))}(e)?e:new o.w({message:`Cannot connect to API: ${e.message}`,cause:e,url:t,requestBodyValues:r,isRetryable:!0})}function q(e=globalThis){var t,r,a;return e.window?"runtime/browser":(null==(t=e.navigator)?void 0:t.userAgent)?`runtime/${e.navigator.userAgent.toLowerCase()}`:(null==(a=null==(r=e.process)?void 0:r.versions)?void 0:a.node)?`runtime/node.js/${e.process.version.substring(0)}`:e.EdgeRuntime?"runtime/vercel-edge":"runtime/unknown"}function U(e){if(null==e)return{};let t={};if(e instanceof Headers)e.forEach((e,r)=>{t[r.toLowerCase()]=e});else for(let[r,a]of(Array.isArray(e)||(e=Object.entries(e)),e))null!=a&&(t[r.toLowerCase()]=a);return t}function L(e,...t){let r=new Headers(U(e)),a=r.get("user-agent")||"";return r.set("user-agent",[a,...t].filter(Boolean).join(" ")),Object.fromEntries(r.entries())}var V="4.0.19",G=()=>globalThis.fetch,W=async({url:e,headers:t={},successfulResponseHandler:r,failedResponseHandler:a,abortSignal:n,fetch:i=G()})=>{try{let s=await i(e,{method:"GET",headers:L(t,`ai-sdk/provider-utils/${V}`,q()),signal:n}),l=v(s);if(!s.ok){let t;try{t=await a({response:s,url:e,requestBodyValues:{}})}catch(t){if(j(t)||o.w.isInstance(t))throw t;throw new o.w({message:"Failed to process error response",cause:t,statusCode:s.status,url:e,responseHeaders:l,requestBodyValues:{}})}throw t.value}try{return await r({response:s,url:e,requestBodyValues:{}})}catch(t){if(t instanceof Error&&(j(t)||o.w.isInstance(t)))throw t;throw new o.w({message:"Failed to process successful response",cause:t,statusCode:s.status,url:e,responseHeaders:l,requestBodyValues:{}})}}catch(t){throw D({error:t,url:e,requestBodyValues:{}})}};function X(e){return null!=e}function B({mediaType:e,url:t,supportedUrls:r}){return t=t.toLowerCase(),e=e.toLowerCase(),Object.entries(r).map(([e,t])=>{let r=e.toLowerCase();return"*"===r||"*/*"===r?{mediaTypePrefix:"",regexes:t}:{mediaTypePrefix:r.replace(/\*/,""),regexes:t}}).filter(({mediaTypePrefix:t})=>e.startsWith(t)).flatMap(({regexes:e})=>e).some(e=>e.test(t))}function K({apiKey:e,environmentVariableName:t,apiKeyParameterName:r="apiKey",description:a}){if("string"==typeof e)return e;if(null!=e)throw new o.tZ({message:`${a} API key must be a string.`});if("undefined"==typeof process)throw new o.tZ({message:`${a} API key is missing. Pass it using the '${r}' parameter. Environment variables is not supported in this environment.`});if(null==(e=process.env[t]))throw new o.tZ({message:`${a} API key is missing. Pass it using the '${r}' parameter or the ${t} environment variable.`});if("string"!=typeof e)throw new o.tZ({message:`${a} API key must be a string. The value of the ${t} environment variable is not a string.`});return e}function J({settingValue:e,environmentVariableName:t}){if("string"==typeof e||null==e&&"undefined"!=typeof process&&null!=(e=process.env[t])&&"string"==typeof e)return e}var H=/"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/,Y=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;function Q(e){let t=JSON.parse(e);return null===t||"object"!=typeof t||!1===H.test(e)&&!1===Y.test(e)?t:function(e){let t=[e];for(;t.length;){let e=t;for(let r of(t=[],e)){if(Object.prototype.hasOwnProperty.call(r,"__proto__")||Object.prototype.hasOwnProperty.call(r,"constructor")&&null!==r.constructor&&"object"==typeof r.constructor&&Object.prototype.hasOwnProperty.call(r.constructor,"prototype"))throw SyntaxError("Object contains forbidden prototype property");for(let e in r){let a=r[e];a&&"object"==typeof a&&t.push(a)}}}return e}(t)}function ee(e){let{stackTraceLimit:t}=Error;try{Error.stackTraceLimit=0}catch(t){return Q(e)}try{return Q(e)}finally{Error.stackTraceLimit=t}}function et(e){if("object"===e.type||Array.isArray(e.type)&&e.type.includes("object")){e.additionalProperties=!1;let{properties:t}=e;if(null!=t)for(let e of Object.keys(t))t[e]=er(t[e])}null!=e.items&&(e.items=Array.isArray(e.items)?e.items.map(er):er(e.items)),null!=e.anyOf&&(e.anyOf=e.anyOf.map(er)),null!=e.allOf&&(e.allOf=e.allOf.map(er)),null!=e.oneOf&&(e.oneOf=e.oneOf.map(er));let{definitions:t}=e;if(null!=t)for(let e of Object.keys(t))t[e]=er(t[e]);return e}function er(e){return"boolean"==typeof e?e:et(e)}var ea=Symbol("Let zodToJsonSchema decide on which parser to use"),en={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:"definitions",strictUnions:!1,definitions:{},errorMessages:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref"},eo=e=>"string"==typeof e?{...en,name:e}:{...en,...e};function ei(e,t){return eR(e.type._def,t)}var es=(e,t)=>eR(e.innerType._def,t),el=e=>{let t={type:"integer",format:"unix-time"};for(let r of e.checks)switch(r.kind){case"min":t.minimum=r.value;break;case"max":t.maximum=r.value}return t},eu=e=>(!("type"in e)||"string"!==e.type)&&"allOf"in e,ed=void 0,ec={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>(void 0===ed&&(ed=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),ed),ipv4Cidr:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,ipv6Cidr:/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};function ep(e,t){let r={type:"string"};if(e.checks)for(let a of e.checks)switch(a.kind){case"min":r.minLength="number"==typeof r.minLength?Math.max(r.minLength,a.value):a.value;break;case"max":r.maxLength="number"==typeof r.maxLength?Math.min(r.maxLength,a.value):a.value;break;case"email":switch(t.emailStrategy){case"format:email":ef(r,"email",a.message,t);break;case"format:idn-email":ef(r,"idn-email",a.message,t);break;case"pattern:zod":ey(r,ec.email,a.message,t)}break;case"url":ef(r,"uri",a.message,t);break;case"uuid":ef(r,"uuid",a.message,t);break;case"regex":ey(r,a.regex,a.message,t);break;case"cuid":ey(r,ec.cuid,a.message,t);break;case"cuid2":ey(r,ec.cuid2,a.message,t);break;case"startsWith":ey(r,RegExp(`^${eh(a.value,t)}`),a.message,t);break;case"endsWith":ey(r,RegExp(`${eh(a.value,t)}$`),a.message,t);break;case"datetime":ef(r,"date-time",a.message,t);break;case"date":ef(r,"date",a.message,t);break;case"time":ef(r,"time",a.message,t);break;case"duration":ef(r,"duration",a.message,t);break;case"length":r.minLength="number"==typeof r.minLength?Math.max(r.minLength,a.value):a.value,r.maxLength="number"==typeof r.maxLength?Math.min(r.maxLength,a.value):a.value;break;case"includes":ey(r,RegExp(eh(a.value,t)),a.message,t);break;case"ip":"v6"!==a.version&&ef(r,"ipv4",a.message,t),"v4"!==a.version&&ef(r,"ipv6",a.message,t);break;case"base64url":ey(r,ec.base64url,a.message,t);break;case"jwt":ey(r,ec.jwt,a.message,t);break;case"cidr":"v6"!==a.version&&ey(r,ec.ipv4Cidr,a.message,t),"v4"!==a.version&&ey(r,ec.ipv6Cidr,a.message,t);break;case"emoji":ey(r,ec.emoji(),a.message,t);break;case"ulid":ey(r,ec.ulid,a.message,t);break;case"base64":switch(t.base64Strategy){case"format:binary":ef(r,"binary",a.message,t);break;case"contentEncoding:base64":r.contentEncoding="base64";break;case"pattern:zod":ey(r,ec.base64,a.message,t)}break;case"nanoid":ey(r,ec.nanoid,a.message,t)}return r}function eh(e,t){return"escape"===t.patternStrategy?function(e){let t="";for(let r=0;r<e.length;r++)em.has(e[r])||(t+="\\"),t+=e[r];return t}(e):e}var em=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function ef(e,t,r,a){var n;e.format||(null==(n=e.anyOf)?void 0:n.some(e=>e.format))?(e.anyOf||(e.anyOf=[]),e.format&&(e.anyOf.push({format:e.format}),delete e.format),e.anyOf.push({format:t,...r&&a.errorMessages&&{errorMessage:{format:r}}})):e.format=t}function ey(e,t,r,a){var n;e.pattern||(null==(n=e.allOf)?void 0:n.some(e=>e.pattern))?(e.allOf||(e.allOf=[]),e.pattern&&(e.allOf.push({pattern:e.pattern}),delete e.pattern),e.allOf.push({pattern:e_(t,a),...r&&a.errorMessages&&{errorMessage:{pattern:r}}})):e.pattern=e_(t,a)}function e_(e,t){var r;if(!t.applyRegexFlags||!e.flags)return e.source;let a={i:e.flags.includes("i"),m:e.flags.includes("m"),s:e.flags.includes("s")},n=a.i?e.source.toLowerCase():e.source,o="",i=!1,s=!1,l=!1;for(let e=0;e<n.length;e++){if(i){o+=n[e],i=!1;continue}if(a.i){if(s){if(n[e].match(/[a-z]/)){l?(o+=n[e]+`${n[e-2]}-${n[e]}`.toUpperCase(),l=!1):"-"===n[e+1]&&(null==(r=n[e+2])?void 0:r.match(/[a-z]/))?(o+=n[e],l=!0):o+=`${n[e]}${n[e].toUpperCase()}`;continue}}else if(n[e].match(/[a-z]/)){o+=`[${n[e]}${n[e].toUpperCase()}]`;continue}}if(a.m){if("^"===n[e]){o+=`(^|(?<=[\r
|
|
36
|
+
]))`;continue}if("$"===n[e]){o+=`($|(?=[\r
|
|
37
|
+
]))`;continue}}if(a.s&&"."===n[e]){o+=s?`${n[e]}\r
|
|
38
|
+
`:`[${n[e]}\r
|
|
39
|
+
]`;continue}o+=n[e],"\\"===n[e]?i=!0:s&&"]"===n[e]?s=!1:s||"["!==n[e]||(s=!0)}try{new RegExp(o)}catch(r){return console.warn(`Could not convert regex pattern at ${t.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),e.source}return o}function eg(e,t){var r,a,n,o,i,s;let l={type:"object",additionalProperties:null!=(r=eR(e.valueType._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]}))?r:t.allowedAdditionalProperties};if((null==(a=e.keyType)?void 0:a._def.typeName)===d.pA.ZodString&&(null==(n=e.keyType._def.checks)?void 0:n.length)){let{type:r,...a}=ep(e.keyType._def,t);return{...l,propertyNames:a}}if((null==(o=e.keyType)?void 0:o._def.typeName)===d.pA.ZodEnum)return{...l,propertyNames:{enum:e.keyType._def.values}};if((null==(i=e.keyType)?void 0:i._def.typeName)===d.pA.ZodBranded&&e.keyType._def.type._def.typeName===d.pA.ZodString&&(null==(s=e.keyType._def.type._def.checks)?void 0:s.length)){let{type:r,...a}=ei(e.keyType._def,t);return{...l,propertyNames:a}}return l}var ev={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"},eb=(e,t)=>{let r=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((e,r)=>eR(e._def,{...t,currentPath:[...t.currentPath,"anyOf",`${r}`]})).filter(e=>!!e&&(!t.strictUnions||"object"==typeof e&&Object.keys(e).length>0));return r.length?{anyOf:r}:void 0},ew=(e,t)=>{var r;if(t.currentPath.toString()===(null==(r=t.propertyPath)?void 0:r.toString()))return eR(e.innerType._def,t);let a=eR(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","1"]});return a?{anyOf:[{not:{}},a]}:{}},ex=(e,t)=>{if("input"===t.pipeStrategy)return eR(e.in._def,t);if("output"===t.pipeStrategy)return eR(e.out._def,t);let r=eR(e.in._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),a=eR(e.out._def,{...t,currentPath:[...t.currentPath,"allOf",r?"1":"0"]});return{allOf:[r,a].filter(e=>void 0!==e)}},ek=(e,t)=>eR(e.innerType._def,t),eI=(e,t,r)=>{switch(t){case d.pA.ZodString:return ep(e,r);case d.pA.ZodNumber:return function(e){let t={type:"number"};if(!e.checks)return t;for(let r of e.checks)switch(r.kind){case"int":t.type="integer";break;case"min":r.inclusive?t.minimum=r.value:t.exclusiveMinimum=r.value;break;case"max":r.inclusive?t.maximum=r.value:t.exclusiveMaximum=r.value;break;case"multipleOf":t.multipleOf=r.value}return t}(e);case d.pA.ZodObject:return function(e,t){let r={type:"object",properties:{}},a=[],n=e.shape();for(let e in n){let o=n[e];if(void 0===o||void 0===o._def)continue;let i=function(e){try{return e.isOptional()}catch(e){return!0}}(o),s=eR(o._def,{...t,currentPath:[...t.currentPath,"properties",e],propertyPath:[...t.currentPath,"properties",e]});void 0!==s&&(r.properties[e]=s,i||a.push(e))}a.length&&(r.required=a);let o=function(e,t){if("ZodNever"!==e.catchall._def.typeName)return eR(e.catchall._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]});switch(e.unknownKeys){case"passthrough":return t.allowedAdditionalProperties;case"strict":return t.rejectedAdditionalProperties;case"strip":return"strict"===t.removeAdditionalStrategy?t.allowedAdditionalProperties:t.rejectedAdditionalProperties}}(e,t);return void 0!==o&&(r.additionalProperties=o),r}(e,r);case d.pA.ZodBigInt:return function(e){let t={type:"integer",format:"int64"};if(!e.checks)return t;for(let r of e.checks)switch(r.kind){case"min":r.inclusive?t.minimum=r.value:t.exclusiveMinimum=r.value;break;case"max":r.inclusive?t.maximum=r.value:t.exclusiveMaximum=r.value;break;case"multipleOf":t.multipleOf=r.value}return t}(e);case d.pA.ZodBoolean:return{type:"boolean"};case d.pA.ZodDate:return function e(t,r,a){let n=null!=a?a:r.dateStrategy;if(Array.isArray(n))return{anyOf:n.map((a,n)=>e(t,r,a))};switch(n){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return el(t)}}(e,r);case d.pA.ZodUndefined:return{not:{}};case d.pA.ZodNull:return{type:"null"};case d.pA.ZodArray:return function(e,t){var r,a,n;let o={type:"array"};return(null==(r=e.type)?void 0:r._def)&&(null==(n=null==(a=e.type)?void 0:a._def)?void 0:n.typeName)!==d.pA.ZodAny&&(o.items=eR(e.type._def,{...t,currentPath:[...t.currentPath,"items"]})),e.minLength&&(o.minItems=e.minLength.value),e.maxLength&&(o.maxItems=e.maxLength.value),e.exactLength&&(o.minItems=e.exactLength.value,o.maxItems=e.exactLength.value),o}(e,r);case d.pA.ZodUnion:case d.pA.ZodDiscriminatedUnion:return function(e,t){let r=e.options instanceof Map?Array.from(e.options.values()):e.options;if(r.every(e=>e._def.typeName in ev&&(!e._def.checks||!e._def.checks.length))){let e=r.reduce((e,t)=>{let r=ev[t._def.typeName];return r&&!e.includes(r)?[...e,r]:e},[]);return{type:e.length>1?e:e[0]}}if(r.every(e=>"ZodLiteral"===e._def.typeName&&!e.description)){let e=r.reduce((e,t)=>{let r=typeof t._def.value;switch(r){case"string":case"number":case"boolean":return[...e,r];case"bigint":return[...e,"integer"];case"object":if(null===t._def.value)return[...e,"null"];default:return e}},[]);if(e.length===r.length){let t=e.filter((e,t,r)=>r.indexOf(e)===t);return{type:t.length>1?t:t[0],enum:r.reduce((e,t)=>e.includes(t._def.value)?e:[...e,t._def.value],[])}}}else if(r.every(e=>"ZodEnum"===e._def.typeName))return{type:"string",enum:r.reduce((e,t)=>[...e,...t._def.values.filter(t=>!e.includes(t))],[])};return eb(e,t)}(e,r);case d.pA.ZodIntersection:return function(e,t){let r=[eR(e.left._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),eR(e.right._def,{...t,currentPath:[...t.currentPath,"allOf","1"]})].filter(e=>!!e),a=[];return r.forEach(e=>{if(eu(e))a.push(...e.allOf);else{let t=e;if("additionalProperties"in e&&!1===e.additionalProperties){let{additionalProperties:r,...a}=e;t=a}a.push(t)}}),a.length?{allOf:a}:void 0}(e,r);case d.pA.ZodTuple:return function(e,t){return e.rest?{type:"array",minItems:e.items.length,items:e.items.map((e,r)=>eR(e._def,{...t,currentPath:[...t.currentPath,"items",`${r}`]})).reduce((e,t)=>void 0===t?e:[...e,t],[]),additionalItems:eR(e.rest._def,{...t,currentPath:[...t.currentPath,"additionalItems"]})}:{type:"array",minItems:e.items.length,maxItems:e.items.length,items:e.items.map((e,r)=>eR(e._def,{...t,currentPath:[...t.currentPath,"items",`${r}`]})).reduce((e,t)=>void 0===t?e:[...e,t],[])}}(e,r);case d.pA.ZodRecord:return eg(e,r);case d.pA.ZodLiteral:return function(e){let t=typeof e.value;return"bigint"!==t&&"number"!==t&&"boolean"!==t&&"string"!==t?{type:Array.isArray(e.value)?"array":"object"}:{type:"bigint"===t?"integer":t,const:e.value}}(e);case d.pA.ZodEnum:return{type:"string",enum:Array.from(e.values)};case d.pA.ZodNativeEnum:return function(e){let t=e.values,r=Object.keys(e.values).filter(e=>"number"!=typeof t[t[e]]).map(e=>t[e]),a=Array.from(new Set(r.map(e=>typeof e)));return{type:1===a.length?"string"===a[0]?"string":"number":["string","number"],enum:r}}(e);case d.pA.ZodNullable:return function(e,t){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return{type:[ev[e.innerType._def.typeName],"null"]};let r=eR(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","0"]});return r&&{anyOf:[r,{type:"null"}]}}(e,r);case d.pA.ZodOptional:return ew(e,r);case d.pA.ZodMap:return function(e,t){return"record"===t.mapStrategy?eg(e,t):{type:"array",maxItems:125,items:{type:"array",items:[eR(e.keyType._def,{...t,currentPath:[...t.currentPath,"items","items","0"]})||{},eR(e.valueType._def,{...t,currentPath:[...t.currentPath,"items","items","1"]})||{}],minItems:2,maxItems:2}}}(e,r);case d.pA.ZodSet:return function(e,t){let r={type:"array",uniqueItems:!0,items:eR(e.valueType._def,{...t,currentPath:[...t.currentPath,"items"]})};return e.minSize&&(r.minItems=e.minSize.value),e.maxSize&&(r.maxItems=e.maxSize.value),r}(e,r);case d.pA.ZodLazy:return()=>e.getter()._def;case d.pA.ZodPromise:return eR(e.type._def,r);case d.pA.ZodNaN:case d.pA.ZodNever:return{not:{}};case d.pA.ZodEffects:return function(e,t){return"input"===t.effectStrategy?eR(e.schema._def,t):{}}(e,r);case d.pA.ZodAny:case d.pA.ZodUnknown:return{};case d.pA.ZodDefault:return function(e,t){return{...eR(e.innerType._def,t),default:e.defaultValue()}}(e,r);case d.pA.ZodBranded:return ei(e,r);case d.pA.ZodReadonly:return ek(e,r);case d.pA.ZodCatch:return es(e,r);case d.pA.ZodPipeline:return ex(e,r);case d.pA.ZodFunction:case d.pA.ZodVoid:case d.pA.ZodSymbol:default:return}},eT=(e,t)=>{let r=0;for(;r<e.length&&r<t.length&&e[r]===t[r];r++);return[(e.length-r).toString(),...t.slice(r)].join("/")};function eR(e,t,r=!1){var a;let n=t.seen.get(e);if(t.override){let o=null==(a=t.override)?void 0:a.call(t,e,t,n,r);if(o!==ea)return o}if(n&&!r){let e=eS(n,t);if(void 0!==e)return e}let o={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,o);let i=eI(e,e.typeName,t),s="function"==typeof i?eR(i(),t):i;if(s&&eZ(e,t,s),t.postProcess){let r=t.postProcess(s,e,t);return o.jsonSchema=s,r}return o.jsonSchema=s,s}var eS=(e,t)=>{switch(t.$refStrategy){case"root":return{$ref:e.path.join("/")};case"relative":return{$ref:eT(t.currentPath,e.path)};case"none":case"seen":if(e.path.length<t.currentPath.length&&e.path.every((e,r)=>t.currentPath[r]===e))return console.warn(`Recursive reference detected at ${t.currentPath.join("/")}! Defaulting to any`),{};return"seen"===t.$refStrategy?{}:void 0}},eZ=(e,t,r)=>(e.description&&(r.description=e.description),r),eC=e=>{let t=eo(e),r=void 0!==t.name?[...t.basePath,t.definitionPath,t.name]:t.basePath;return{...t,currentPath:r,propertyPath:void 0,seen:new Map(Object.entries(t.definitions).map(([e,r])=>[r._def,{def:r._def,path:[...t.basePath,t.definitionPath,e],jsonSchema:void 0}]))}},eE=(e,t)=>{var r;let a=eC(t),n="object"==typeof t&&t.definitions?Object.entries(t.definitions).reduce((e,[t,r])=>{var n;return{...e,[t]:null!=(n=eR(r._def,{...a,currentPath:[...a.basePath,a.definitionPath,t]},!0))?n:{}}},{}):void 0,o="string"==typeof t?t:(null==t?void 0:t.nameStrategy)==="title"?void 0:null==t?void 0:t.name,i=null!=(r=eR(e._def,void 0===o?a:{...a,currentPath:[...a.basePath,a.definitionPath,o]},!1))?r:{},s="object"==typeof t&&void 0!==t.name&&"title"===t.nameStrategy?t.name:void 0;void 0!==s&&(i.title=s);let l=void 0===o?n?{...i,[a.definitionPath]:n}:i:{$ref:[..."relative"===a.$refStrategy?[]:a.basePath,a.definitionPath,o].join("/"),[a.definitionPath]:{...n,[o]:i}};return l.$schema="http://json-schema.org/draft-07/schema#",l},eO=Symbol.for("vercel.ai.schema");function eA(e){let t;return()=>(null==t&&(t=e()),t)}function eN(e,{validate:t}={}){return{[eO]:!0,_type:void 0,get jsonSchema(){return"function"==typeof e&&(e=e()),e},validate:t}}function eM(e){return null==e?eN({properties:{},additionalProperties:!1}):"object"==typeof e&&null!==e&&eO in e&&!0===e[eO]&&"jsonSchema"in e&&"validate"in e?e:"~standard"in e?"zod"===e["~standard"].vendor?e$(e):eN(()=>et(e["~standard"].jsonSchema.input({target:"draft-07"})),{validate:async t=>{let r=await e["~standard"].validate(t);return"value"in r?{success:!0,value:r.value}:{success:!1,error:new o.Gz({value:t,cause:r.issues})}}}):e()}function e$(e,t){return"_zod"in e?function(e,t){var r;let a=null!=(r=null==t?void 0:t.useReferences)&&r;return eN(()=>et(function(e,t){if(e instanceof i.EC){let r=new l(t),a={};for(let t of e._idmap.entries()){let[e,a]=t;r.process(a)}let n={},o={registry:e,uri:t?.uri,defs:a};for(let a of e._idmap.entries()){let[e,i]=a;n[e]=r.emit(i,{...t,external:o})}if(Object.keys(a).length>0){let e="draft-2020-12"===r.target?"$defs":"definitions";n.__shared={[e]:a}}return{schemas:n}}let r=new l(t);return r.process(e),r.emit(e,t)}(e,{target:"draft-7",io:"input",reused:a?"ref":"inline"})),{validate:async t=>{let r=await u.X9(e,t);return r.success?{success:!0,value:r.data}:{success:!1,error:r.error}}})}(e,t):function(e,t){var r;let a=null!=(r=null==t?void 0:t.useReferences)&&r;return eN(()=>eE(e,{$refStrategy:a?"root":"none"}),{validate:async t=>{let r=await e.safeParseAsync(t);return r.success?{success:!0,value:r.data}:{success:!1,error:r.error}}})}(e,t)}async function eP({value:e,schema:t,context:r}){let a=await ej({value:e,schema:t,context:r});if(!a.success)throw o.Gz.wrap({value:e,cause:a.error,context:r});return a.value}async function ej({value:e,schema:t,context:r}){let a=eM(t);try{if(null==a.validate)return{success:!0,value:e,rawValue:e};let t=await a.validate(e);if(t.success)return{success:!0,value:t.value,rawValue:e};return{success:!1,error:o.Gz.wrap({value:e,cause:t.error,context:r}),rawValue:e}}catch(t){return{success:!1,error:o.Gz.wrap({value:e,cause:t,context:r}),rawValue:e}}}async function eF({text:e,schema:t}){try{let r=ee(e);if(null==t)return r;return eP({value:r,schema:t})}catch(t){if(o.xU.isInstance(t)||o.Gz.isInstance(t))throw t;throw new o.xU({text:e,cause:t})}}async function ez({text:e,schema:t}){try{let r=ee(e);if(null==t)return{success:!0,value:r,rawValue:r};return await ej({value:r,schema:t})}catch(t){return{success:!1,error:o.xU.isInstance(t)?t:new o.xU({text:e,cause:t}),rawValue:void 0}}}function eD({stream:e,schema:t}){return e.pipeThrough(new TextDecoderStream).pipeThrough(new h).pipeThrough(new TransformStream({async transform({data:e},r){"[DONE]"!==e&&r.enqueue(await ez({text:e,schema:t}))}}))}async function eq({provider:e,providerOptions:t,schema:r}){if((null==t?void 0:t[e])==null)return;let a=await ej({value:t[e],schema:r});if(!a.success)throw new o.RU({argument:"providerOptions",message:`invalid ${e} provider options`,cause:a.error});return a.value}var eU=()=>globalThis.fetch,eL=async({url:e,headers:t,body:r,failedResponseHandler:a,successfulResponseHandler:n,abortSignal:o,fetch:i})=>eV({url:e,headers:{"Content-Type":"application/json",...t},body:{content:JSON.stringify(r),values:r},failedResponseHandler:a,successfulResponseHandler:n,abortSignal:o,fetch:i}),eV=async({url:e,headers:t={},body:r,successfulResponseHandler:a,failedResponseHandler:n,abortSignal:i,fetch:s=eU()})=>{try{let l=await s(e,{method:"POST",headers:L(t,`ai-sdk/provider-utils/${V}`,q()),body:r.content,signal:i}),u=v(l);if(!l.ok){let t;try{t=await n({response:l,url:e,requestBodyValues:r.values})}catch(t){if(j(t)||o.w.isInstance(t))throw t;throw new o.w({message:"Failed to process error response",cause:t,statusCode:l.status,url:e,responseHeaders:u,requestBodyValues:r.values})}throw t.value}try{return await a({response:l,url:e,requestBodyValues:r.values})}catch(t){if(t instanceof Error&&(j(t)||o.w.isInstance(t)))throw t;throw new o.w({message:"Failed to process successful response",cause:t,statusCode:l.status,url:e,responseHeaders:u,requestBodyValues:r.values})}}catch(t){throw D({error:t,url:e,requestBodyValues:r.values})}};function eG(e){return e}function eW({id:e,inputSchema:t}){return({execute:r,outputSchema:a,needsApproval:n,toModelOutput:o,onInputStart:i,onInputDelta:s,onInputAvailable:l,...u})=>({type:"provider",id:e,args:u,inputSchema:t,outputSchema:a,execute:r,needsApproval:n,toModelOutput:o,onInputStart:i,onInputDelta:s,onInputAvailable:l})}function eX({id:e,inputSchema:t,outputSchema:r,supportsDeferredResults:a}){return({execute:n,needsApproval:o,toModelOutput:i,onInputStart:s,onInputDelta:l,onInputAvailable:u,...d})=>({type:"provider",id:e,args:d,inputSchema:t,outputSchema:r,execute:n,needsApproval:o,toModelOutput:i,onInputStart:s,onInputDelta:l,onInputAvailable:u,supportsDeferredResults:a})}async function eB(e){return"function"==typeof e&&(e=e()),Promise.resolve(e)}var eK=({errorSchema:e,errorToMessage:t,isRetryable:r})=>async({response:a,url:n,requestBodyValues:i})=>{let s=await a.text(),l=v(a);if(""===s.trim())return{responseHeaders:l,value:new o.w({message:a.statusText,url:n,requestBodyValues:i,statusCode:a.status,responseHeaders:l,responseBody:s,isRetryable:null==r?void 0:r(a)})};try{let u=await eF({text:s,schema:e});return{responseHeaders:l,value:new o.w({message:t(u),url:n,requestBodyValues:i,statusCode:a.status,responseHeaders:l,responseBody:s,data:u,isRetryable:null==r?void 0:r(a,u)})}}catch(e){return{responseHeaders:l,value:new o.w({message:a.statusText,url:n,requestBodyValues:i,statusCode:a.status,responseHeaders:l,responseBody:s,isRetryable:null==r?void 0:r(a)})}}},eJ=e=>async({response:t})=>{let r=v(t);if(null==t.body)throw new o.g8({});return{responseHeaders:r,value:eD({stream:t.body,schema:e})}},eH=e=>async({response:t,url:r,requestBodyValues:a})=>{let n=await t.text(),i=await ez({text:n,schema:e}),s=v(t);if(!i.success)throw new o.w({message:"Invalid JSON response",cause:i.error,statusCode:t.status,responseHeaders:s,responseBody:n,url:r,requestBodyValues:a});return{responseHeaders:s,value:i.value,rawValue:i.rawValue}};function eY(e){return null==e?void 0:e.replace(/\/$/,"")}async function*eQ({execute:e,input:t,options:r}){let a=e(t,r);if(null!=a&&"function"==typeof a[Symbol.asyncIterator]){let e;for await(let t of a)e=t,yield{type:"preliminary",output:t};yield{type:"final",output:e}}else yield{type:"final",output:await a}}},9519:(e,t,r)=>{r.d(t,{AX:()=>T,A_:()=>el,Gz:()=>en,JJ:()=>ee,Mt:()=>U,RU:()=>F,e$:()=>M,g8:()=>N,tZ:()=>J,w:()=>C,xU:()=>W});var a,n,o,i,s,l,u,d,c,p,h,m,f,y,_,g,v,b,w,x,k="vercel.ai.error",I=Symbol.for(k),T=class e extends(n=Error,a=I,n){constructor({name:e,message:t,cause:r}){super(t),this[a]=!0,this.name=e,this.cause=r}static isInstance(t){return e.hasMarker(t,k)}static hasMarker(e,t){let r=Symbol.for(t);return null!=e&&"object"==typeof e&&r in e&&"boolean"==typeof e[r]&&!0===e[r]}},R="AI_APICallError",S=`vercel.ai.error.${R}`,Z=Symbol.for(S),C=class extends(i=T,o=Z,i){constructor({message:e,url:t,requestBodyValues:r,statusCode:a,responseHeaders:n,responseBody:i,cause:s,isRetryable:l=null!=a&&(408===a||409===a||429===a||a>=500),data:u}){super({name:R,message:e,cause:s}),this[o]=!0,this.url=t,this.requestBodyValues=r,this.statusCode=a,this.responseHeaders=n,this.responseBody=i,this.isRetryable=l,this.data=u}static isInstance(e){return T.hasMarker(e,S)}},E="AI_EmptyResponseBodyError",O=`vercel.ai.error.${E}`,A=Symbol.for(O),N=class extends(l=T,s=A,l){constructor({message:e="Empty response body"}={}){super({name:E,message:e}),this[s]=!0}static isInstance(e){return T.hasMarker(e,O)}};function M(e){return null==e?"unknown error":"string"==typeof e?e:e instanceof Error?e.message:JSON.stringify(e)}var $="AI_InvalidArgumentError",P=`vercel.ai.error.${$}`,j=Symbol.for(P),F=class extends(d=T,u=j,d){constructor({message:e,cause:t,argument:r}){super({name:$,message:e,cause:t}),this[u]=!0,this.argument=r}static isInstance(e){return T.hasMarker(e,P)}},z="AI_InvalidPromptError",D=`vercel.ai.error.${z}`,q=Symbol.for(D),U=class extends(p=T,c=q,p){constructor({prompt:e,message:t,cause:r}){super({name:z,message:`Invalid prompt: ${t}`,cause:r}),this[c]=!0,this.prompt=e}static isInstance(e){return T.hasMarker(e,D)}},L=(Symbol.for("vercel.ai.error.AI_InvalidResponseDataError"),"AI_JSONParseError"),V=`vercel.ai.error.${L}`,G=Symbol.for(V),W=class extends(m=T,h=G,m){constructor({text:e,cause:t}){super({name:L,message:`JSON parsing failed: Text: ${e}.
|
|
40
|
+
Error message: ${M(t)}`,cause:t}),this[h]=!0,this.text=e}static isInstance(e){return T.hasMarker(e,V)}},X="AI_LoadAPIKeyError",B=`vercel.ai.error.${X}`,K=Symbol.for(B),J=class extends(y=T,f=K,y){constructor({message:e}){super({name:X,message:e}),this[f]=!0}static isInstance(e){return T.hasMarker(e,B)}},H=(Symbol.for("vercel.ai.error.AI_LoadSettingError"),Symbol.for("vercel.ai.error.AI_NoContentGeneratedError"),"AI_NoSuchModelError"),Y=`vercel.ai.error.${H}`,Q=Symbol.for(Y),ee=class extends(g=T,_=Q,g){constructor({errorName:e=H,modelId:t,modelType:r,message:a=`No such ${r}: ${t}`}){super({name:e,message:a}),this[_]=!0,this.modelId=t,this.modelType=r}static isInstance(e){return T.hasMarker(e,Y)}},et=(Symbol.for("vercel.ai.error.AI_TooManyEmbeddingValuesForCallError"),"AI_TypeValidationError"),er=`vercel.ai.error.${et}`,ea=Symbol.for(er),en=class e extends(b=T,v=ea,b){constructor({value:e,cause:t,context:r}){let a="Type validation failed";if((null==r?void 0:r.field)&&(a+=` for ${r.field}`),(null==r?void 0:r.entityName)||(null==r?void 0:r.entityId)){a+=" (";let e=[];r.entityName&&e.push(r.entityName),r.entityId&&e.push(`id: "${r.entityId}"`),a+=e.join(", ")+")"}super({name:et,message:`${a}: Value: ${JSON.stringify(e)}.
|
|
41
|
+
Error message: ${M(t)}`,cause:t}),this[v]=!0,this.value=e,this.context=r}static isInstance(e){return T.hasMarker(e,er)}static wrap({value:t,cause:r,context:a}){var n,o,i;return e.isInstance(r)&&r.value===t&&(null==(n=r.context)?void 0:n.field)===(null==a?void 0:a.field)&&(null==(o=r.context)?void 0:o.entityName)===(null==a?void 0:a.entityName)&&(null==(i=r.context)?void 0:i.entityId)===(null==a?void 0:a.entityId)?r:new e({value:t,cause:r,context:a})}},eo="AI_UnsupportedFunctionalityError",ei=`vercel.ai.error.${eo}`,es=Symbol.for(ei),el=class extends(x=T,w=es,x){constructor({functionality:e,message:t=`'${e}' functionality not supported.`}){super({name:eo,message:t}),this[w]=!0,this.functionality=e}static isInstance(e){return T.hasMarker(e,ei)}};function eu(e){return null===e||"string"==typeof e||"number"==typeof e||"boolean"==typeof e||(Array.isArray(e)?e.every(eu):"object"==typeof e&&Object.entries(e).every(([e,t])=>"string"==typeof e&&(void 0===t||eu(t))))}},1041:(e,t,r)=>{r.d(t,{bS:()=>aa,vk:()=>rG,kP:()=>at});var a,n,o,i,s,l,u,d,c,p,h,m,f,y,_,g,v,b,w,x,k,I,T,R,S,Z,C,E,O,A,N,M=r(6365),$=r(9519),P=r(2943),j=r(9763),F=r(489),z=Symbol.for("vercel.ai.gateway.error"),D=class e extends(n=Error,a=z,n){constructor({message:e,statusCode:t=500,cause:r,generationId:n}){super(n?`${e} [${n}]`:e),this[a]=!0,this.statusCode=t,this.cause=r,this.generationId=n}static isInstance(t){return e.hasMarker(t)}static hasMarker(e){return"object"==typeof e&&null!==e&&z in e&&!0===e[z]}},q="GatewayAuthenticationError",U=Symbol.for(`vercel.ai.gateway.error.${q}`),L=class e extends(i=D,o=U,i){constructor({message:e="Authentication failed",statusCode:t=401,cause:r,generationId:a}={}){super({message:e,statusCode:t,cause:r,generationId:a}),this[o]=!0,this.name=q,this.type="authentication_error"}static isInstance(e){return D.hasMarker(e)&&U in e}static createContextualError({apiKeyProvided:t,oidcTokenProvided:r,message:a="Authentication failed",statusCode:n=401,cause:o,generationId:i}){return new e({message:t?`AI Gateway authentication failed: Invalid API key.
|
|
42
42
|
|
|
43
43
|
Create a new API key: https://vercel.com/d?to=%2F%5Bteam%5D%2F%7E%2Fai%2Fapi-keys
|
|
44
44
|
|