stableclaw 2026.4.21 → 2026.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (21) hide show
  1. package/dist/.buildstamp +1 -1
  2. package/dist/build-info.json +3 -3
  3. package/dist/cli-startup-metadata.json +1 -1
  4. package/dist/control-ui/assets/{agents-CouEImnJ.js → agents-BQThDjmV.js} +2 -2
  5. package/dist/control-ui/assets/{anthropic-D2gWjM8y.js → anthropic-DgG8lDlL.js} +2 -2
  6. package/dist/control-ui/assets/{azure-openai-responses-rSA0t6IS.js → azure-openai-responses-CBgrXqWI.js} +2 -2
  7. package/dist/control-ui/assets/{channels-BgJBIl8z.js → channels-Dpq8rmYk.js} +2 -2
  8. package/dist/control-ui/assets/{cron-CESIxOYW.js → cron-Cc7oz4VO.js} +2 -2
  9. package/dist/control-ui/assets/{debug-BAZT8Cur.js → debug-CwAvIw7x.js} +2 -2
  10. package/dist/control-ui/assets/{google-B2pGWEiN.js → google-D-Vqc1qj.js} +2 -2
  11. package/dist/control-ui/assets/{index-C0UxQzEn.js → index-CUmjeRtH.js} +426 -398
  12. package/dist/control-ui/assets/{instances-ClbVvaQy.js → instances-BwyJkk_4.js} +2 -2
  13. package/dist/control-ui/assets/{mistral-imHzDZ_7.js → mistral-C-PkU019.js} +2 -2
  14. package/dist/control-ui/assets/{openai-codex-responses-DRaOkrRO.js → openai-codex-responses-Cr7J2fxH.js} +2 -2
  15. package/dist/control-ui/assets/{openai-completions-0yOZERna.js → openai-completions-ZUYR4bUM.js} +2 -2
  16. package/dist/control-ui/assets/{openai-responses-8vqADgIw.js → openai-responses-D5cbpSni.js} +2 -2
  17. package/dist/control-ui/assets/{openai-responses-shared-Q7jopnLp.js → openai-responses-shared-BzAz6CNs.js} +2 -2
  18. package/dist/control-ui/assets/{sessions-CiBN6LBg.js → sessions-_scr02pD.js} +2 -2
  19. package/dist/control-ui/assets/{skills-yhlO3Ote.js → skills-DCt5NidQ.js} +2 -2
  20. package/dist/control-ui/index.html +1 -1
  21. package/package.json +1 -1
package/dist/.buildstamp CHANGED
@@ -1 +1 @@
1
- {"builtAt":1775485032963,"head":"19357dd8af232a7313e7abae9c8627f0c806558d"}
1
+ {"builtAt":1775488488409,"head":"b7aec7e101f57c99f5318a9536b8cf6a7b42b778"}
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2026.4.21",
3
- "commit": "19357dd8af232a7313e7abae9c8627f0c806558d",
4
- "builtAt": "2026-04-06T14:17:39.968Z"
2
+ "version": "2026.5.1",
3
+ "commit": "b7aec7e101f57c99f5318a9536b8cf6a7b42b778",
4
+ "builtAt": "2026-04-06T15:15:14.887Z"
5
5
  }
@@ -10,5 +10,5 @@
10
10
  "signal",
11
11
  "imessage"
12
12
  ],
13
- "rootHelpText": "\n🦞 StableClaw 2026.4.21 (19357dd)\n\nUsage: stableclaw [options] [command]\n\nOptions:\n --container <name> Run the CLI inside a running Podman/Docker container\n named <name> (default: env OPENCLAW_CONTAINER)\n --dev Dev profile: isolate state under ~/.openclaw-dev, default\n gateway port 19001, and shift derived ports\n (browser/canvas)\n -h, --help Display help for command\n --log-level <level> Global log level override for file + console\n (silent|fatal|error|warn|info|debug|trace)\n --no-color Disable ANSI colors\n --profile <name> Use a named profile (isolates\n OPENCLAW_STATE_DIR/OPENCLAW_CONFIG_PATH under\n ~/.openclaw-<name>)\n -V, --version output the version number\n\nCommands:\n Hint: commands suffixed with * have subcommands. Run <command> --help for details.\n acp * Agent Control Protocol tools\n agent Run one agent turn via the Gateway\n agents * Manage isolated agents (workspaces, auth, routing)\n approvals * Manage exec approvals (gateway or node host)\n backup * Create and verify local backup archives for OpenClaw\n state\n channels * Manage connected chat channels (Telegram, Discord, etc.)\n clawbot * Legacy clawbot command aliases\n completion Generate shell completion script\n config * Non-interactive config helpers\n (get/set/unset/file/validate). Default: starts guided\n setup.\n configure Interactive configuration for credentials, channels,\n gateway, and agent defaults\n cron * Manage cron jobs via the Gateway scheduler\n daemon * Gateway service (legacy alias)\n dashboard Open the Control UI with your current token\n devices * Device pairing + token management\n directory * Lookup contact and group IDs (self, peers, groups) for\n supported chat channels\n dns * DNS helpers for wide-area discovery (Tailscale + CoreDNS)\n docs Search the live OpenClaw docs\n doctor Health checks + quick fixes for the gateway and channels\n gateway * Run, inspect, and query the WebSocket Gateway\n health Fetch health from the running gateway\n help Display help for command\n hooks * Manage internal agent hooks\n logs Tail gateway file logs via RPC\n memory Search, inspect, and reindex memory files\n message * Send, read, and manage messages\n models * Discover, scan, and configure models\n node * Run and manage the headless node host service\n nodes * Manage gateway-owned node pairing and node commands\n onboard Interactive onboarding for gateway, workspace, and skills\n pairing * Secure DM pairing (approve inbound requests)\n plugins * Manage OpenClaw plugins and extensions\n qr Generate iOS pairing QR/setup code\n reset Reset local config/state (keeps the CLI installed)\n sandbox * Manage sandbox containers for agent isolation\n secrets * Secrets runtime reload controls\n security * Security tools and local config audits\n sessions * List stored conversation sessions\n setup Initialize local config and agent workspace\n skills * List and inspect available skills\n status Show channel health and recent session recipients\n system * System events, heartbeat, and presence\n tasks * Inspect durable background task state\n tui Open a terminal UI connected to the Gateway\n uninstall Uninstall the gateway service + local data (CLI remains)\n update * Update OpenClaw and inspect update channel status\n webhooks * Webhook helpers and integrations\n\nExamples:\n stableclaw models --help\n Show detailed help for the models command.\n stableclaw channels login --verbose\n Link personal WhatsApp Web and show QR + connection logs.\n stableclaw message send --target +15555550123 --message \"Hi\" --json\n Send via your web session and print JSON result.\n stableclaw gateway --port 18789\n Run the WebSocket Gateway locally.\n stableclaw --dev gateway\n Run a dev Gateway (isolated state/config) on ws://127.0.0.1:19001.\n stableclaw gateway --force\n Kill anything bound to the default gateway port, then start it.\n stableclaw gateway ...\n Gateway control via WebSocket.\n stableclaw agent --to +15555550123 --message \"Run summary\" --deliver\n Talk directly to the agent using the Gateway; optionally send the WhatsApp reply.\n stableclaw message send --channel telegram --target @mychat --message \"Hi\"\n Send via your Telegram bot.\n\nDocs: https://docs.stableclaw.ai/cli\n\n"
13
+ "rootHelpText": "\n🦞 StableClaw 2026.5.1 (b7aec7e)\n\nUsage: stableclaw [options] [command]\n\nOptions:\n --container <name> Run the CLI inside a running Podman/Docker container\n named <name> (default: env OPENCLAW_CONTAINER)\n --dev Dev profile: isolate state under ~/.openclaw-dev, default\n gateway port 19001, and shift derived ports\n (browser/canvas)\n -h, --help Display help for command\n --log-level <level> Global log level override for file + console\n (silent|fatal|error|warn|info|debug|trace)\n --no-color Disable ANSI colors\n --profile <name> Use a named profile (isolates\n OPENCLAW_STATE_DIR/OPENCLAW_CONFIG_PATH under\n ~/.openclaw-<name>)\n -V, --version output the version number\n\nCommands:\n Hint: commands suffixed with * have subcommands. Run <command> --help for details.\n acp * Agent Control Protocol tools\n agent Run one agent turn via the Gateway\n agents * Manage isolated agents (workspaces, auth, routing)\n approvals * Manage exec approvals (gateway or node host)\n backup * Create and verify local backup archives for OpenClaw\n state\n channels * Manage connected chat channels (Telegram, Discord, etc.)\n clawbot * Legacy clawbot command aliases\n completion Generate shell completion script\n config * Non-interactive config helpers\n (get/set/unset/file/validate). Default: starts guided\n setup.\n configure Interactive configuration for credentials, channels,\n gateway, and agent defaults\n cron * Manage cron jobs via the Gateway scheduler\n daemon * Gateway service (legacy alias)\n dashboard Open the Control UI with your current token\n devices * Device pairing + token management\n directory * Lookup contact and group IDs (self, peers, groups) for\n supported chat channels\n dns * DNS helpers for wide-area discovery (Tailscale + CoreDNS)\n docs Search the live OpenClaw docs\n doctor Health checks + quick fixes for the gateway and channels\n gateway * Run, inspect, and query the WebSocket Gateway\n health Fetch health from the running gateway\n help Display help for command\n hooks * Manage internal agent hooks\n logs Tail gateway file logs via RPC\n memory Search, inspect, and reindex memory files\n message * Send, read, and manage messages\n models * Discover, scan, and configure models\n node * Run and manage the headless node host service\n nodes * Manage gateway-owned node pairing and node commands\n onboard Interactive onboarding for gateway, workspace, and skills\n pairing * Secure DM pairing (approve inbound requests)\n plugins * Manage OpenClaw plugins and extensions\n qr Generate iOS pairing QR/setup code\n reset Reset local config/state (keeps the CLI installed)\n sandbox * Manage sandbox containers for agent isolation\n secrets * Secrets runtime reload controls\n security * Security tools and local config audits\n sessions * List stored conversation sessions\n setup Initialize local config and agent workspace\n skills * List and inspect available skills\n status Show channel health and recent session recipients\n system * System events, heartbeat, and presence\n tasks * Inspect durable background task state\n tui Open a terminal UI connected to the Gateway\n uninstall Uninstall the gateway service + local data (CLI remains)\n update * Update OpenClaw and inspect update channel status\n webhooks * Webhook helpers and integrations\n\nExamples:\n stableclaw models --help\n Show detailed help for the models command.\n stableclaw channels login --verbose\n Link personal WhatsApp Web and show QR + connection logs.\n stableclaw message send --target +15555550123 --message \"Hi\" --json\n Send via your web session and print JSON result.\n stableclaw gateway --port 18789\n Run the WebSocket Gateway locally.\n stableclaw --dev gateway\n Run a dev Gateway (isolated state/config) on ws://127.0.0.1:19001.\n stableclaw gateway --force\n Kill anything bound to the default gateway port, then start it.\n stableclaw gateway ...\n Gateway control via WebSocket.\n stableclaw agent --to +15555550123 --message \"Run summary\" --deliver\n Talk directly to the agent using the Gateway; optionally send the WhatsApp reply.\n stableclaw message send --channel telegram --target @mychat --message \"Hi\"\n Send via your Telegram bot.\n\nDocs: https://docs.stableclaw.ai/cli\n\n"
14
14
  }
@@ -1,4 +1,4 @@
1
- import{i as e,n as t}from"./lit-zdTgzAJI.js";import{t as n}from"./preload-helper-xBbMyY7u.js";import{l as r}from"./format-nUIQxx1z.js";import{A as i,C as a,D as o,E as s,M as c,S as l,T as u,_ as d,a as f,b as p,f as m,g as h,h as g,j as _,k as v,m as y,n as b,p as x,r as S,t as C,v as w,w as T,x as E,y as D}from"./index-C0UxQzEn.js";import{r as O}from"./channel-config-extras-DNCeHtEf.js";import{i as k,n as A,r as j,t as M}from"./skills-shared-DJsJP4-4.js";function N(n){let{agent:r,configForm:i,agentFilesList:o,configLoading:s,configSaving:c,configDirty:u,onConfigReload:d,onConfigSave:f,onModelChange:m,onModelFallbacksChange:h,onSelectPanel:g}=n,_=p(i,r.id),v=r.model,b=(o&&o.agentId===r.id?o.workspace:null)||_.entry?.workspace||_.defaults?.workspace||r.workspace||`default`,x=_.entry?.model?l(_.entry?.model):_.defaults?.model?l(_.defaults?.model):l(v),S=l(_.defaults?.model??v),C=a(_.entry?.model),T=a(_.defaults?.model)||(S===`-`?null:w(S))||(i?null:a(v)),O=C??T??null,k=E(_.entry?.model)??E(_.defaults?.model)??(i?null:E(v))??[],A=Array.isArray(_.entry?.skills)?_.entry?.skills:null,j=A?.length??null,M=!!(n.defaultId&&r.id===n.defaultId),N=!i||s||c,P=e=>{let t=k.filter((t,n)=>n!==e);h(r.id,t)};return e`
1
+ import{i as e,n as t}from"./lit-zdTgzAJI.js";import{t as n}from"./preload-helper-xBbMyY7u.js";import{l as r}from"./format-nUIQxx1z.js";import{A as i,C as a,D as o,E as s,M as c,S as l,T as u,_ as d,a as f,b as p,f as m,g as h,h as g,j as _,k as v,m as y,n as b,p as x,r as S,t as C,v as w,w as T,x as E,y as D}from"./index-CUmjeRtH.js";import{r as O}from"./channel-config-extras-DNCeHtEf.js";import{i as k,n as A,r as j,t as M}from"./skills-shared-DJsJP4-4.js";function N(n){let{agent:r,configForm:i,agentFilesList:o,configLoading:s,configSaving:c,configDirty:u,onConfigReload:d,onConfigSave:f,onModelChange:m,onModelFallbacksChange:h,onSelectPanel:g}=n,_=p(i,r.id),v=r.model,b=(o&&o.agentId===r.id?o.workspace:null)||_.entry?.workspace||_.defaults?.workspace||r.workspace||`default`,x=_.entry?.model?l(_.entry?.model):_.defaults?.model?l(_.defaults?.model):l(v),S=l(_.defaults?.model??v),C=a(_.entry?.model),T=a(_.defaults?.model)||(S===`-`?null:w(S))||(i?null:a(v)),O=C??T??null,k=E(_.entry?.model)??E(_.defaults?.model)??(i?null:E(v))??[],A=Array.isArray(_.entry?.skills)?_.entry?.skills:null,j=A?.length??null,M=!!(n.defaultId&&r.id===n.defaultId),N=!i||s||c,P=e=>{let t=k.filter((t,n)=>n!==e);h(r.id,t)};return e`
2
2
  <section class="card">
3
3
  <div class="card-title">Overview</div>
4
4
  <div class="card-sub">Workspace paths and identity metadata.</div>
@@ -810,4 +810,4 @@ ${e}
810
810
  `)}
811
811
  </div>
812
812
  `}export{ye as renderAgents};
813
- //# sourceMappingURL=agents-CouEImnJ.js.map
813
+ //# sourceMappingURL=agents-BQThDjmV.js.map
@@ -1,4 +1,4 @@
1
- import{n as e,t}from"./event-stream-B8X6sYaV.js";import{d as n,u as r}from"./index-C0UxQzEn.js";import{a as i,n as a,r as o,t as s}from"./transform-messages-XKqwKV3D.js";import{n as c,t as l}from"./github-copilot-headers-CrI0CIJ7.js";function u(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n}function d(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)}var f=function(){let{crypto:e}=globalThis;if(e?.randomUUID)return f=e.randomUUID.bind(e),e.randomUUID();let t=new Uint8Array(1),n=e?()=>e.getRandomValues(t)[0]:()=>Math.random()*255&255;return`10000000-1000-4000-8000-100000000000`.replace(/[018]/g,e=>(e^n()&15>>e/4).toString(16))};function p(e){return typeof e==`object`&&!!e&&(`name`in e&&e.name===`AbortError`||`message`in e&&String(e.message).includes(`FetchRequestCanceledException`))}var ee=e=>{if(e instanceof Error)return e;if(typeof e==`object`&&e){try{if(Object.prototype.toString.call(e)===`[object Error]`){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)},m=class extends Error{},h=class e extends m{constructor(t,n,r,i,a){super(`${e.makeMessage(t,n,r)}`),this.status=t,this.headers=i,this.requestID=i?.get(`request-id`),this.error=n,this.type=a??null}static makeMessage(e,t,n){let r=t?.message?typeof t.message==`string`?t.message:JSON.stringify(t.message):t?JSON.stringify(t):n;return e&&r?`${e} ${r}`:e?`${e} status code (no body)`:r||`(no status code or body)`}static generate(t,n,r,i){if(!t||!i)return new te({message:r,cause:ee(n)});let a=n,o=a?.error?.type;return t===400?new re(t,a,r,i,o):t===401?new ie(t,a,r,i,o):t===403?new ae(t,a,r,i,o):t===404?new oe(t,a,r,i,o):t===409?new se(t,a,r,i,o):t===422?new ce(t,a,r,i,o):t===429?new le(t,a,r,i,o):t>=500?new ue(t,a,r,i,o):new e(t,a,r,i,o)}},g=class extends h{constructor({message:e}={}){super(void 0,void 0,e||`Request was aborted.`,void 0)}},te=class extends h{constructor({message:e,cause:t}){super(void 0,void 0,e||`Connection error.`,void 0),t&&(this.cause=t)}},ne=class extends te{constructor({message:e}={}){super({message:e??`Request timed out.`})}},re=class extends h{},ie=class extends h{},ae=class extends h{},oe=class extends h{},se=class extends h{},ce=class extends h{},le=class extends h{},ue=class extends h{},de=/^[a-z][a-z0-9+.-]*:/i,fe=e=>de.test(e),pe=e=>(pe=Array.isArray,pe(e)),me=pe;function he(e){return typeof e==`object`?e??{}:{}}function ge(e){if(!e)return!0;for(let t in e)return!1;return!0}function _e(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var ve=(e,t)=>{if(typeof t!=`number`||!Number.isInteger(t))throw new m(`${e} must be an integer`);if(t<0)throw new m(`${e} must be a positive integer`);return t},ye=e=>{try{return JSON.parse(e)}catch{return}},be=e=>new Promise(t=>setTimeout(t,e)),_=`0.81.0`,xe=()=>typeof window<`u`&&window.document!==void 0&&typeof navigator<`u`;function Se(){return typeof Deno<`u`&&Deno.build!=null?`deno`:typeof EdgeRuntime<`u`?`edge`:Object.prototype.toString.call(globalThis.process===void 0?0:globalThis.process)===`[object process]`?`node`:`unknown`}var Ce=()=>{let e=Se();if(e===`deno`)return{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":_,"X-Stainless-OS":Ee(Deno.build.os),"X-Stainless-Arch":Te(Deno.build.arch),"X-Stainless-Runtime":`deno`,"X-Stainless-Runtime-Version":typeof Deno.version==`string`?Deno.version:Deno.version?.deno??`unknown`};if(typeof EdgeRuntime<`u`)return{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":_,"X-Stainless-OS":`Unknown`,"X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":`edge`,"X-Stainless-Runtime-Version":globalThis.process.version};if(e===`node`)return{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":_,"X-Stainless-OS":Ee(globalThis.process.platform??`unknown`),"X-Stainless-Arch":Te(globalThis.process.arch??`unknown`),"X-Stainless-Runtime":`node`,"X-Stainless-Runtime-Version":globalThis.process.version??`unknown`};let t=we();return t?{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":_,"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":_,"X-Stainless-OS":`Unknown`,"X-Stainless-Arch":`unknown`,"X-Stainless-Runtime":`unknown`,"X-Stainless-Runtime-Version":`unknown`}};function we(){if(typeof navigator>`u`||!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 n=t.exec(navigator.userAgent);if(n)return{browser:e,version:`${n[1]||0}.${n[2]||0}.${n[3]||0}`}}return null}var Te=e=>e===`x32`?`x32`:e===`x86_64`||e===`x64`?`x64`:e===`arm`?`arm`:e===`aarch64`||e===`arm64`?`arm64`:e?`other:${e}`:`unknown`,Ee=e=>(e=e.toLowerCase(),e.includes(`ios`)?`iOS`:e===`android`?`Android`:e===`darwin`?`MacOS`:e===`win32`?`Windows`:e===`freebsd`?`FreeBSD`:e===`openbsd`?`OpenBSD`:e===`linux`?`Linux`:e?`Other:${e}`:`Unknown`),De,Oe=()=>De??=Ce();function ke(){if(typeof fetch<`u`)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`")}function Ae(...e){let t=globalThis.ReadableStream;if(t===void 0)throw Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new t(...e)}function je(e){let t=Symbol.asyncIterator in e?e[Symbol.asyncIterator]():e[Symbol.iterator]();return Ae({start(){},async pull(e){let{done:n,value:r}=await t.next();n?e.close():e.enqueue(r)},async cancel(){await t.return?.()}})}function Me(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 Ne(e){if(typeof e!=`object`||!e)return;if(e[Symbol.asyncIterator]){await e[Symbol.asyncIterator]().return?.();return}let t=e.getReader(),n=t.cancel();t.releaseLock(),await n}var Pe=({headers:e,body:t})=>({bodyHeaders:{"content-type":`application/json`},body:JSON.stringify(t)});function Fe(e){return Object.entries(e).filter(([e,t])=>t!==void 0).map(([e,t])=>{if(typeof t==`string`||typeof t==`number`||typeof t==`boolean`)return`${encodeURIComponent(e)}=${encodeURIComponent(t)}`;if(t===null)return`${encodeURIComponent(e)}=`;throw new m(`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(`&`)}function Ie(e){let t=0;for(let n of e)t+=n.length;let n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return n}var Le;function Re(e){let t;return(Le??=(t=new globalThis.TextEncoder,t.encode.bind(t)))(e)}var ze;function Be(e){let t;return(ze??=(t=new globalThis.TextDecoder,t.decode.bind(t)))(e)}var v,y,b=class{constructor(){v.set(this,void 0),y.set(this,void 0),u(this,v,new Uint8Array,`f`),u(this,y,null,`f`)}decode(e){if(e==null)return[];let t=e instanceof ArrayBuffer?new Uint8Array(e):typeof e==`string`?Re(e):e;u(this,v,Ie([d(this,v,`f`),t]),`f`);let n=[],r;for(;(r=Ve(d(this,v,`f`),d(this,y,`f`)))!=null;){if(r.carriage&&d(this,y,`f`)==null){u(this,y,r.index,`f`);continue}if(d(this,y,`f`)!=null&&(r.index!==d(this,y,`f`)+1||r.carriage)){n.push(Be(d(this,v,`f`).subarray(0,d(this,y,`f`)-1))),u(this,v,d(this,v,`f`).subarray(d(this,y,`f`)),`f`),u(this,y,null,`f`);continue}let e=d(this,y,`f`)===null?r.preceding:r.preceding-1,t=Be(d(this,v,`f`).subarray(0,e));n.push(t),u(this,v,d(this,v,`f`).subarray(r.index),`f`),u(this,y,null,`f`)}return n}flush(){return d(this,v,`f`).length?this.decode(`
1
+ import{n as e,t}from"./event-stream-B8X6sYaV.js";import{d as n,u as r}from"./index-CUmjeRtH.js";import{a as i,n as a,r as o,t as s}from"./transform-messages-XKqwKV3D.js";import{n as c,t as l}from"./github-copilot-headers-CrI0CIJ7.js";function u(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n}function d(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)}var f=function(){let{crypto:e}=globalThis;if(e?.randomUUID)return f=e.randomUUID.bind(e),e.randomUUID();let t=new Uint8Array(1),n=e?()=>e.getRandomValues(t)[0]:()=>Math.random()*255&255;return`10000000-1000-4000-8000-100000000000`.replace(/[018]/g,e=>(e^n()&15>>e/4).toString(16))};function p(e){return typeof e==`object`&&!!e&&(`name`in e&&e.name===`AbortError`||`message`in e&&String(e.message).includes(`FetchRequestCanceledException`))}var ee=e=>{if(e instanceof Error)return e;if(typeof e==`object`&&e){try{if(Object.prototype.toString.call(e)===`[object Error]`){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)},m=class extends Error{},h=class e extends m{constructor(t,n,r,i,a){super(`${e.makeMessage(t,n,r)}`),this.status=t,this.headers=i,this.requestID=i?.get(`request-id`),this.error=n,this.type=a??null}static makeMessage(e,t,n){let r=t?.message?typeof t.message==`string`?t.message:JSON.stringify(t.message):t?JSON.stringify(t):n;return e&&r?`${e} ${r}`:e?`${e} status code (no body)`:r||`(no status code or body)`}static generate(t,n,r,i){if(!t||!i)return new te({message:r,cause:ee(n)});let a=n,o=a?.error?.type;return t===400?new re(t,a,r,i,o):t===401?new ie(t,a,r,i,o):t===403?new ae(t,a,r,i,o):t===404?new oe(t,a,r,i,o):t===409?new se(t,a,r,i,o):t===422?new ce(t,a,r,i,o):t===429?new le(t,a,r,i,o):t>=500?new ue(t,a,r,i,o):new e(t,a,r,i,o)}},g=class extends h{constructor({message:e}={}){super(void 0,void 0,e||`Request was aborted.`,void 0)}},te=class extends h{constructor({message:e,cause:t}){super(void 0,void 0,e||`Connection error.`,void 0),t&&(this.cause=t)}},ne=class extends te{constructor({message:e}={}){super({message:e??`Request timed out.`})}},re=class extends h{},ie=class extends h{},ae=class extends h{},oe=class extends h{},se=class extends h{},ce=class extends h{},le=class extends h{},ue=class extends h{},de=/^[a-z][a-z0-9+.-]*:/i,fe=e=>de.test(e),pe=e=>(pe=Array.isArray,pe(e)),me=pe;function he(e){return typeof e==`object`?e??{}:{}}function ge(e){if(!e)return!0;for(let t in e)return!1;return!0}function _e(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var ve=(e,t)=>{if(typeof t!=`number`||!Number.isInteger(t))throw new m(`${e} must be an integer`);if(t<0)throw new m(`${e} must be a positive integer`);return t},ye=e=>{try{return JSON.parse(e)}catch{return}},be=e=>new Promise(t=>setTimeout(t,e)),_=`0.81.0`,xe=()=>typeof window<`u`&&window.document!==void 0&&typeof navigator<`u`;function Se(){return typeof Deno<`u`&&Deno.build!=null?`deno`:typeof EdgeRuntime<`u`?`edge`:Object.prototype.toString.call(globalThis.process===void 0?0:globalThis.process)===`[object process]`?`node`:`unknown`}var Ce=()=>{let e=Se();if(e===`deno`)return{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":_,"X-Stainless-OS":Ee(Deno.build.os),"X-Stainless-Arch":Te(Deno.build.arch),"X-Stainless-Runtime":`deno`,"X-Stainless-Runtime-Version":typeof Deno.version==`string`?Deno.version:Deno.version?.deno??`unknown`};if(typeof EdgeRuntime<`u`)return{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":_,"X-Stainless-OS":`Unknown`,"X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":`edge`,"X-Stainless-Runtime-Version":globalThis.process.version};if(e===`node`)return{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":_,"X-Stainless-OS":Ee(globalThis.process.platform??`unknown`),"X-Stainless-Arch":Te(globalThis.process.arch??`unknown`),"X-Stainless-Runtime":`node`,"X-Stainless-Runtime-Version":globalThis.process.version??`unknown`};let t=we();return t?{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":_,"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":_,"X-Stainless-OS":`Unknown`,"X-Stainless-Arch":`unknown`,"X-Stainless-Runtime":`unknown`,"X-Stainless-Runtime-Version":`unknown`}};function we(){if(typeof navigator>`u`||!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 n=t.exec(navigator.userAgent);if(n)return{browser:e,version:`${n[1]||0}.${n[2]||0}.${n[3]||0}`}}return null}var Te=e=>e===`x32`?`x32`:e===`x86_64`||e===`x64`?`x64`:e===`arm`?`arm`:e===`aarch64`||e===`arm64`?`arm64`:e?`other:${e}`:`unknown`,Ee=e=>(e=e.toLowerCase(),e.includes(`ios`)?`iOS`:e===`android`?`Android`:e===`darwin`?`MacOS`:e===`win32`?`Windows`:e===`freebsd`?`FreeBSD`:e===`openbsd`?`OpenBSD`:e===`linux`?`Linux`:e?`Other:${e}`:`Unknown`),De,Oe=()=>De??=Ce();function ke(){if(typeof fetch<`u`)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`")}function Ae(...e){let t=globalThis.ReadableStream;if(t===void 0)throw Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new t(...e)}function je(e){let t=Symbol.asyncIterator in e?e[Symbol.asyncIterator]():e[Symbol.iterator]();return Ae({start(){},async pull(e){let{done:n,value:r}=await t.next();n?e.close():e.enqueue(r)},async cancel(){await t.return?.()}})}function Me(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 Ne(e){if(typeof e!=`object`||!e)return;if(e[Symbol.asyncIterator]){await e[Symbol.asyncIterator]().return?.();return}let t=e.getReader(),n=t.cancel();t.releaseLock(),await n}var Pe=({headers:e,body:t})=>({bodyHeaders:{"content-type":`application/json`},body:JSON.stringify(t)});function Fe(e){return Object.entries(e).filter(([e,t])=>t!==void 0).map(([e,t])=>{if(typeof t==`string`||typeof t==`number`||typeof t==`boolean`)return`${encodeURIComponent(e)}=${encodeURIComponent(t)}`;if(t===null)return`${encodeURIComponent(e)}=`;throw new m(`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(`&`)}function Ie(e){let t=0;for(let n of e)t+=n.length;let n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return n}var Le;function Re(e){let t;return(Le??=(t=new globalThis.TextEncoder,t.encode.bind(t)))(e)}var ze;function Be(e){let t;return(ze??=(t=new globalThis.TextDecoder,t.decode.bind(t)))(e)}var v,y,b=class{constructor(){v.set(this,void 0),y.set(this,void 0),u(this,v,new Uint8Array,`f`),u(this,y,null,`f`)}decode(e){if(e==null)return[];let t=e instanceof ArrayBuffer?new Uint8Array(e):typeof e==`string`?Re(e):e;u(this,v,Ie([d(this,v,`f`),t]),`f`);let n=[],r;for(;(r=Ve(d(this,v,`f`),d(this,y,`f`)))!=null;){if(r.carriage&&d(this,y,`f`)==null){u(this,y,r.index,`f`);continue}if(d(this,y,`f`)!=null&&(r.index!==d(this,y,`f`)+1||r.carriage)){n.push(Be(d(this,v,`f`).subarray(0,d(this,y,`f`)-1))),u(this,v,d(this,v,`f`).subarray(d(this,y,`f`)),`f`),u(this,y,null,`f`);continue}let e=d(this,y,`f`)===null?r.preceding:r.preceding-1,t=Be(d(this,v,`f`).subarray(0,e));n.push(t),u(this,v,d(this,v,`f`).subarray(r.index),`f`),u(this,y,null,`f`)}return n}flush(){return d(this,v,`f`).length?this.decode(`
2
2
  `):[]}};v=new WeakMap,y=new WeakMap,b.NEWLINE_CHARS=new Set([`
3
3
  `,`\r`]),b.NEWLINE_REGEXP=/\r\n|[\n\r]/g;function Ve(e,t){for(let n=t??0;n<e.length;n++){if(e[n]===10)return{preceding:n,index:n+1,carriage:!1};if(e[n]===13)return{preceding:n,index:n+1,carriage:!0}}return null}function He(e){for(let t=0;t<e.length-1;t++){if(e[t]===10&&e[t+1]===10||e[t]===13&&e[t+1]===13)return t+2;if(e[t]===13&&e[t+1]===10&&t+3<e.length&&e[t+2]===13&&e[t+3]===10)return t+4}return-1}var Ue={off:0,error:200,warn:300,info:400,debug:500},We=(e,t,n)=>{if(e){if(_e(Ue,e))return e;S(n).warn(`${t} was set to ${JSON.stringify(e)}, expected one of ${JSON.stringify(Object.keys(Ue))}`)}};function x(){}function Ge(e,t,n){return!t||Ue[e]>Ue[n]?x:t[e].bind(t)}var Ke={error:x,warn:x,info:x,debug:x},qe=new WeakMap;function S(e){let t=e.logger,n=e.logLevel??`off`;if(!t)return Ke;let r=qe.get(t);if(r&&r[0]===n)return r[1];let i={error:Ge(`error`,t,n),warn:Ge(`warn`,t,n),info:Ge(`info`,t,n),debug:Ge(`debug`,t,n)};return qe.set(t,[n,i]),i}var C=e=>(e.options&&(e.options={...e.options},delete e.options.headers),e.headers&&=Object.fromEntries((e.headers instanceof Headers?[...e.headers]:Object.entries(e.headers)).map(([e,t])=>[e,e.toLowerCase()===`x-api-key`||e.toLowerCase()===`authorization`||e.toLowerCase()===`cookie`||e.toLowerCase()===`set-cookie`?`***`:t])),`retryOfRequestLogID`in e&&(e.retryOfRequestLogID&&(e.retryOf=e.retryOfRequestLogID),delete e.retryOfRequestLogID),e),Je,Ye=class e{constructor(e,t,n){this.iterator=e,Je.set(this,void 0),this.controller=t,u(this,Je,n,`f`)}static fromSSEResponse(t,n,r){let i=!1,a=r?S(r):console;async function*o(){if(i)throw new m("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");i=!0;let e=!1;try{for await(let e of Xe(t,n)){if(e.event===`completion`)try{yield JSON.parse(e.data)}catch(t){throw a.error(`Could not parse message into JSON:`,e.data),a.error(`From chunk:`,e.raw),t}if(e.event===`message_start`||e.event===`message_delta`||e.event===`message_stop`||e.event===`content_block_start`||e.event===`content_block_delta`||e.event===`content_block_stop`)try{yield JSON.parse(e.data)}catch(t){throw a.error(`Could not parse message into JSON:`,e.data),a.error(`From chunk:`,e.raw),t}if(e.event!==`ping`&&e.event===`error`){let n=ye(e.data)??e.data,r=n?.error?.type;throw new h(void 0,n,void 0,t.headers,r)}}e=!0}catch(e){if(p(e))return;throw e}finally{e||n.abort()}}return new e(o,n,r)}static fromReadableStream(t,n,r){let i=!1;async function*a(){let e=new b,n=Me(t);for await(let t of n)for(let n of e.decode(t))yield n;for(let t of e.flush())yield t}async function*o(){if(i)throw new m("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");i=!0;let e=!1;try{for await(let t of a())e||t&&(yield JSON.parse(t));e=!0}catch(e){if(p(e))return;throw e}finally{e||n.abort()}}return new e(o,n,r)}[(Je=new WeakMap,Symbol.asyncIterator)](){return this.iterator()}tee(){let t=[],n=[],r=this.iterator(),i=e=>({next:()=>{if(e.length===0){let e=r.next();t.push(e),n.push(e)}return e.shift()}});return[new e(()=>i(t),this.controller,d(this,Je,`f`)),new e(()=>i(n),this.controller,d(this,Je,`f`))]}toReadableStream(){let e=this,t;return Ae({async start(){t=e[Symbol.asyncIterator]()},async pull(e){try{let{value:n,done:r}=await t.next();if(r)return e.close();let i=Re(JSON.stringify(n)+`
4
4
  `);e.enqueue(i)}catch(t){e.error(t)}},async cancel(){await t.return?.()}})}};async function*Xe(e,t){if(!e.body)throw t.abort(),globalThis.navigator!==void 0&&globalThis.navigator.product===`ReactNative`?new m(`The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api`):new m(`Attempted to iterate over a response with no body`);let n=new Qe,r=new b,i=Me(e.body);for await(let e of Ze(i))for(let t of r.decode(e)){let e=n.decode(t);e&&(yield e)}for(let e of r.flush()){let t=n.decode(e);t&&(yield t)}}async function*Ze(e){let t=new Uint8Array;for await(let n of e){if(n==null)continue;let e=n instanceof ArrayBuffer?new Uint8Array(n):typeof n==`string`?Re(n):n,r=new Uint8Array(t.length+e.length);r.set(t),r.set(e,t.length),t=r;let i;for(;(i=He(t))!==-1;)yield t.slice(0,i),t=t.slice(i)}t.length>0&&(yield t)}var Qe=class{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(`
@@ -34,4 +34,4 @@ you can set the \`dangerouslyAllowBrowser\` option to \`true\`, e.g.,
34
34
  new Anthropic({ apiKey, dangerouslyAllowBrowser: true });
35
35
  `);this.baseURL=i.baseURL,this.timeout=i.timeout??ar.DEFAULT_TIMEOUT,this.logger=i.logger??console;let a=`warn`;this.logLevel=a,this.logLevel=We(i.logLevel,`ClientOptions.logLevel`,this)??We(rr(`ANTHROPIC_LOG`),`process.env['ANTHROPIC_LOG']`,this)??a,this.fetchOptions=i.fetchOptions,this.maxRetries=i.maxRetries??2,this.fetch=i.fetch??ke(),u(this,or,Pe,`f`),this._options=i,this.apiKey=typeof t==`string`?t:null,this.authToken=n}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 E([await this.apiKeyAuth(e),await this.bearerAuth(e)])}async apiKeyAuth(e){if(this.apiKey!=null)return E([{"X-Api-Key":this.apiKey}])}async bearerAuth(e){if(this.authToken!=null)return E([{Authorization:`Bearer ${this.authToken}`}])}stringifyQuery(e){return Fe(e)}getUserAgent(){return`${this.constructor.name}/JS ${_}`}defaultIdempotencyKey(){return`stainless-node-retry-${f()}`}makeStatusError(e,t,n,r){return h.generate(e,t,n,r)}buildURL(e,t,n){let r=!d(this,ir,`m`,sr).call(this)&&n||this.baseURL,i=fe(e)?new URL(e):new URL(r+(r.endsWith(`/`)&&e.startsWith(`/`)?e.slice(1):e)),a=this.defaultQuery(),o=Object.fromEntries(i.searchParams);return(!ge(a)||!ge(o))&&(t={...o,...a,...t}),typeof t==`object`&&t&&!Array.isArray(t)&&(i.search=this.stringifyQuery(t)),i.toString()}_calculateNonstreamingTimeout(e){if(3600*e/128e3>600)throw new m(`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 600*1e3}async prepareOptions(e){}async prepareRequest(e,{url:t,options:n}){}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,n){return this.request(Promise.resolve(n).then(n=>({method:e,path:t,...n})))}request(e,t=null){return new rt(this,this.makeRequest(e,t,void 0))}async makeRequest(e,t,n){let r=await e,i=r.maxRetries??this.maxRetries;t??=i,await this.prepareOptions(r);let{req:a,url:o,timeout:s}=await this.buildRequest(r,{retryCount:i-t});await this.prepareRequest(a,{url:o,options:r});let c=`log_`+(Math.random()*(1<<24)|0).toString(16).padStart(6,`0`),l=n===void 0?``:`, retryOf: ${n}`,u=Date.now();if(S(this).debug(`[${c}] sending request`,C({retryOfRequestLogID:n,method:r.method,url:o,options:r,headers:a.headers})),r.signal?.aborted)throw new g;let d=new AbortController,f=await this.fetchWithTimeout(o,a,s,d).catch(ee),m=Date.now();if(f instanceof globalThis.Error){let e=`retrying, ${t} attempts remaining`;if(r.signal?.aborted)throw new g;let i=p(f)||/timed? ?out/i.test(String(f)+(`cause`in f?String(f.cause):``));if(t)return S(this).info(`[${c}] connection ${i?`timed out`:`failed`} - ${e}`),S(this).debug(`[${c}] connection ${i?`timed out`:`failed`} (${e})`,C({retryOfRequestLogID:n,url:o,durationMs:m-u,message:f.message})),this.retryRequest(r,t,n??c);throw S(this).info(`[${c}] connection ${i?`timed out`:`failed`} - error; no more retries left`),S(this).debug(`[${c}] connection ${i?`timed out`:`failed`} (error; no more retries left)`,C({retryOfRequestLogID:n,url:o,durationMs:m-u,message:f.message})),i?new ne:new te({cause:f})}let h=`[${c}${l}${[...f.headers.entries()].filter(([e])=>e===`request-id`).map(([e,t])=>`, `+e+`: `+JSON.stringify(t)).join(``)}] ${a.method} ${o} ${f.ok?`succeeded`:`failed`} with status ${f.status} in ${m-u}ms`;if(!f.ok){let e=await this.shouldRetry(f);if(t&&e){let e=`retrying, ${t} attempts remaining`;return await Ne(f.body),S(this).info(`${h} - ${e}`),S(this).debug(`[${c}] response error (${e})`,C({retryOfRequestLogID:n,url:f.url,status:f.status,headers:f.headers,durationMs:m-u})),this.retryRequest(r,t,n??c,f.headers)}let i=e?`error; no more retries left`:`error; not retryable`;S(this).info(`${h} - ${i}`);let a=await f.text().catch(e=>ee(e).message),o=ye(a),s=o?void 0:a;throw S(this).debug(`[${c}] response error (${i})`,C({retryOfRequestLogID:n,url:f.url,status:f.status,headers:f.headers,message:s,durationMs:Date.now()-u})),this.makeStatusError(f.status,o,s,f.headers)}return S(this).info(h),S(this).debug(`[${c}] response start`,C({retryOfRequestLogID:n,url:f.url,status:f.status,headers:f.headers,durationMs:m-u})),{response:f,options:r,controller:d,requestLogID:c,retryOfRequestLogID:n,startTime:u}}getAPIList(e,t,n){return this.requestAPIList(t,n&&`then`in n?n.then(t=>({method:`get`,path:e,...t})):{method:`get`,path:e,...n})}requestAPIList(e,t){let n=this.makeRequest(t,null,void 0);return new ot(this,n,e)}async fetchWithTimeout(e,t,n,r){let{signal:i,method:a,...o}=t||{},s=this._makeAbort(r);i&&i.addEventListener(`abort`,s,{once:!0});let c=setTimeout(s,n),l=globalThis.ReadableStream&&o.body instanceof globalThis.ReadableStream||typeof o.body==`object`&&o.body!==null&&Symbol.asyncIterator in o.body,u={signal:r.signal,...l?{duplex:`half`}:{},method:`GET`,...o};a&&(u.method=a.toUpperCase());try{return await this.fetch.call(void 0,e,u)}finally{clearTimeout(c)}}async shouldRetry(e){let t=e.headers.get(`x-should-retry`);return t===`true`?!0:t===`false`?!1:e.status===408||e.status===409||e.status===429||e.status>=500}async retryRequest(e,t,n,r){let i,a=r?.get(`retry-after-ms`);if(a){let e=parseFloat(a);Number.isNaN(e)||(i=e)}let o=r?.get(`retry-after`);if(o&&!i){let e=parseFloat(o);i=Number.isNaN(e)?Date.parse(o)-Date.now():e*1e3}if(i===void 0){let n=e.maxRetries??this.maxRetries;i=this.calculateDefaultRetryTimeoutMillis(t,n)}return await be(i),this.makeRequest(e,t-1,n)}calculateDefaultRetryTimeoutMillis(e,t){let n=t-e;return Math.min(.5*2**n,8)*(1-Math.random()*.25)*1e3}calculateNonstreamingTimeout(e,t){let n=600*1e3;if(36e5*e/128e3>n||t!=null&&e>t)throw new m(`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 n}async buildRequest(e,{retryCount:t=0}={}){let n={...e},{method:r,path:i,query:a,defaultBaseURL:o}=n,s=this.buildURL(i,a,o);`timeout`in n&&ve(`timeout`,n.timeout),n.timeout=n.timeout??this.timeout;let{bodyHeaders:c,body:l}=this.buildBody({options:n});return{req:{method:r,headers:await this.buildHeaders({options:e,method:r,bodyHeaders:c,retryCount:t}),...n.signal&&{signal:n.signal},...globalThis.ReadableStream&&l instanceof globalThis.ReadableStream&&{duplex:`half`},...l&&{body:l},...this.fetchOptions??{},...n.fetchOptions??{}},url:s,timeout:n.timeout}}async buildHeaders({options:e,method:t,bodyHeaders:n,retryCount:r}){let i={};this.idempotencyHeader&&t!==`get`&&(e.idempotencyKey||=this.defaultIdempotencyKey(),i[this.idempotencyHeader]=e.idempotencyKey);let a=E([i,{Accept:`application/json`,"User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String(r),...e.timeout?{"X-Stainless-Timeout":String(Math.trunc(e.timeout/1e3))}:{},...Oe(),...this._options.dangerouslyAllowBrowser?{"anthropic-dangerous-direct-browser-access":`true`}:void 0,"anthropic-version":`2023-06-01`},await this.authHeaders(e),this._options.defaultHeaders,n,e.headers]);return this.validateHeaders(a),a.values}_makeAbort(e){return()=>e.abort()}buildBody({options:{body:e,headers:t}}){if(!e)return{bodyHeaders:void 0,body:void 0};let n=E([t]);return ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof DataView||typeof e==`string`&&n.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}:typeof e==`object`&&(Symbol.asyncIterator in e||Symbol.iterator in e&&`next`in e&&typeof e.next==`function`)?{bodyHeaders:void 0,body:je(e)}:typeof e==`object`&&n.values.get(`content-type`)===`application/x-www-form-urlencoded`?{bodyHeaders:{"content-type":`application/x-www-form-urlencoded`},body:this.stringifyQuery(e)}:d(this,or,`f`).call(this,{body:e,headers:n})}};ar=Q,or=new WeakMap,ir=new WeakSet,sr=function(){return this.baseURL!==`https://api.anthropic.com`},Q.Anthropic=ar,Q.HUMAN_PROMPT=cr,Q.AI_PROMPT=lr,Q.DEFAULT_TIMEOUT=6e5,Q.AnthropicError=m,Q.APIError=h,Q.APIConnectionError=te,Q.APIConnectionTimeoutError=ne,Q.APIUserAbortError=g,Q.NotFoundError=oe,Q.ConflictError=se,Q.RateLimitError=le,Q.BadRequestError=re,Q.AuthenticationError=ie,Q.InternalServerError=ue,Q.PermissionDeniedError=ae,Q.UnprocessableEntityError=ce,Q.toFile=xt;var $=class extends Q{constructor(){super(...arguments),this.completions=new Tn(this),this.messages=new $n(this),this.models=new nr(this),this.beta=new K(this)}};$.Completions=Tn,$.Messages=$n,$.Models=nr,$.Beta=K;function ur(e){return e||(typeof process<`u`&&{}.PI_CACHE_RETENTION===`long`?`long`:`short`)}function dr(e,t){let n=ur(t);if(n===`none`)return{retention:n};let r=n===`long`&&e.includes(`api.anthropic.com`)?`1h`:void 0;return{retention:n,cacheControl:{type:`ephemeral`,...r&&{ttl:r}}}}var fr=`2.1.75`,pr=new Map([`Read`,`Write`,`Edit`,`Bash`,`Grep`,`Glob`,`AskUserQuestion`,`EnterPlanMode`,`ExitPlanMode`,`KillShell`,`NotebookEdit`,`Skill`,`Task`,`TaskOutput`,`TodoWrite`,`WebFetch`,`WebSearch`].map(e=>[e.toLowerCase(),e])),mr=e=>pr.get(e.toLowerCase())??e,hr=(e,t)=>{if(t&&t.length>0){let n=e.toLowerCase(),r=t.find(e=>e.name.toLowerCase()===n);if(r)return r.name}return e};function gr(e){if(!e.some(e=>e.type===`image`))return i(e.map(e=>e.text).join(`
36
36
  `));let t=e.map(e=>e.type===`text`?{type:`text`,text:i(e.text)}:{type:`image`,source:{type:`base64`,media_type:e.mimeType,data:e.data}});return t.some(e=>e.type===`text`)||t.unshift({type:`text`,text:`(see attached image)`}),t}function _r(...e){let t={};for(let n of e)n&&Object.assign(t,n);return t}var vr=(i,a,o)=>{let s=new t;return(async()=>{let t={role:`assistant`,content:[],api:i.api,provider:i.provider,model:i.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:`stop`,timestamp:Date.now()};try{let u,d;if(o?.client)u=o.client,d=!1;else{let e=o?.apiKey??n(i.provider)??``,t;if(i.provider===`github-copilot`){let e=c(a.messages);t=l({messages:a.messages,hasImages:e})}let r=Cr(i,e,o?.interleavedThinking??!0,o?.headers,t);u=r.client,d=r.isOAuthToken}let f=wr(i,a,d,o),p=await o?.onPayload?.(f,i);p!==void 0&&(f=p);let ee=u.messages.stream({...f,stream:!0},{signal:o?.signal});s.push({type:`start`,partial:t});let m=t.content;for await(let n of ee)if(n.type===`message_start`)t.responseId=n.message.id,t.usage.input=n.message.usage.input_tokens||0,t.usage.output=n.message.usage.output_tokens||0,t.usage.cacheRead=n.message.usage.cache_read_input_tokens||0,t.usage.cacheWrite=n.message.usage.cache_creation_input_tokens||0,t.usage.totalTokens=t.usage.input+t.usage.output+t.usage.cacheRead+t.usage.cacheWrite,e(i,t.usage);else if(n.type===`content_block_start`){if(n.content_block.type===`text`){let e={type:`text`,text:``,index:n.index};t.content.push(e),s.push({type:`text_start`,contentIndex:t.content.length-1,partial:t})}else if(n.content_block.type===`thinking`){let e={type:`thinking`,thinking:``,thinkingSignature:``,index:n.index};t.content.push(e),s.push({type:`thinking_start`,contentIndex:t.content.length-1,partial:t})}else if(n.content_block.type===`redacted_thinking`){let e={type:`thinking`,thinking:`[Reasoning redacted]`,thinkingSignature:n.content_block.data,redacted:!0,index:n.index};t.content.push(e),s.push({type:`thinking_start`,contentIndex:t.content.length-1,partial:t})}else if(n.content_block.type===`tool_use`){let e={type:`toolCall`,id:n.content_block.id,name:d?hr(n.content_block.name,a.tools):n.content_block.name,arguments:n.content_block.input??{},partialJson:``,index:n.index};t.content.push(e),s.push({type:`toolcall_start`,contentIndex:t.content.length-1,partial:t})}}else if(n.type===`content_block_delta`){if(n.delta.type===`text_delta`){let e=m.findIndex(e=>e.index===n.index),r=m[e];r&&r.type===`text`&&(r.text+=n.delta.text,s.push({type:`text_delta`,contentIndex:e,delta:n.delta.text,partial:t}))}else if(n.delta.type===`thinking_delta`){let e=m.findIndex(e=>e.index===n.index),r=m[e];r&&r.type===`thinking`&&(r.thinking+=n.delta.thinking,s.push({type:`thinking_delta`,contentIndex:e,delta:n.delta.thinking,partial:t}))}else if(n.delta.type===`input_json_delta`){let e=m.findIndex(e=>e.index===n.index),i=m[e];i&&i.type===`toolCall`&&(i.partialJson+=n.delta.partial_json,i.arguments=r(i.partialJson),s.push({type:`toolcall_delta`,contentIndex:e,delta:n.delta.partial_json,partial:t}))}else if(n.delta.type===`signature_delta`){let e=m[m.findIndex(e=>e.index===n.index)];e&&e.type===`thinking`&&(e.thinkingSignature=e.thinkingSignature||``,e.thinkingSignature+=n.delta.signature)}}else if(n.type===`content_block_stop`){let e=m.findIndex(e=>e.index===n.index),i=m[e];i&&(delete i.index,i.type===`text`?s.push({type:`text_end`,contentIndex:e,content:i.text,partial:t}):i.type===`thinking`?s.push({type:`thinking_end`,contentIndex:e,content:i.thinking,partial:t}):i.type===`toolCall`&&(i.arguments=r(i.partialJson),delete i.partialJson,s.push({type:`toolcall_end`,contentIndex:e,toolCall:i,partial:t})))}else n.type===`message_delta`&&(n.delta.stop_reason&&(t.stopReason=Or(n.delta.stop_reason)),n.usage.input_tokens!=null&&(t.usage.input=n.usage.input_tokens),n.usage.output_tokens!=null&&(t.usage.output=n.usage.output_tokens),n.usage.cache_read_input_tokens!=null&&(t.usage.cacheRead=n.usage.cache_read_input_tokens),n.usage.cache_creation_input_tokens!=null&&(t.usage.cacheWrite=n.usage.cache_creation_input_tokens),t.usage.totalTokens=t.usage.input+t.usage.output+t.usage.cacheRead+t.usage.cacheWrite,e(i,t.usage));if(o?.signal?.aborted)throw Error(`Request was aborted`);if(t.stopReason===`aborted`||t.stopReason===`error`)throw Error(`An unknown error occurred`);s.push({type:`done`,reason:t.stopReason,message:t}),s.end()}catch(e){for(let e of t.content)delete e.index;t.stopReason=o?.signal?.aborted?`aborted`:`error`,t.errorMessage=e instanceof Error?e.message:JSON.stringify(e),s.push({type:`error`,reason:t.stopReason,error:t}),s.end()}})(),s};function yr(e){return e.includes(`opus-4-6`)||e.includes(`opus-4.6`)||e.includes(`sonnet-4-6`)||e.includes(`sonnet-4.6`)}function br(e,t){switch(e){case`minimal`:return`low`;case`low`:return`low`;case`medium`:return`medium`;case`high`:return`high`;case`xhigh`:return t.includes(`opus-4-6`)||t.includes(`opus-4.6`)?`max`:`high`;default:return`high`}}var xr=(e,t,r)=>{let i=r?.apiKey||n(e.provider);if(!i)throw Error(`No API key for provider: ${e.provider}`);let s=o(e,r,i);if(!r?.reasoning)return vr(e,t,{...s,thinkingEnabled:!1});if(yr(e.id)){let n=br(r.reasoning,e.id);return vr(e,t,{...s,thinkingEnabled:!0,effort:n})}let c=a(s.maxTokens||0,e.maxTokens,r.reasoning,r.thinkingBudgets);return vr(e,t,{...s,maxTokens:c.maxTokens,thinkingEnabled:!0,thinkingBudgetTokens:c.thinkingBudget})};function Sr(e){return e.includes(`sk-ant-oat`)}function Cr(e,t,n,r,i){let a=n&&!yr(e.id);if(e.provider===`github-copilot`){let n=[];return a&&n.push(`interleaved-thinking-2025-05-14`),{client:new $({apiKey:null,authToken:t,baseURL:e.baseUrl,dangerouslyAllowBrowser:!0,defaultHeaders:_r({accept:`application/json`,"anthropic-dangerous-direct-browser-access":`true`,...n.length>0?{"anthropic-beta":n.join(`,`)}:{}},e.headers,i,r)}),isOAuthToken:!1}}let o=[`fine-grained-tool-streaming-2025-05-14`];return a&&o.push(`interleaved-thinking-2025-05-14`),Sr(t)?{client:new $({apiKey:null,authToken:t,baseURL:e.baseUrl,dangerouslyAllowBrowser:!0,defaultHeaders:_r({accept:`application/json`,"anthropic-dangerous-direct-browser-access":`true`,"anthropic-beta":`claude-code-20250219,oauth-2025-04-20,${o.join(`,`)}`,"user-agent":`claude-cli/${fr}`,"x-app":`cli`},e.headers,r)}),isOAuthToken:!0}:{client:new $({apiKey:t,baseURL:e.baseUrl,dangerouslyAllowBrowser:!0,defaultHeaders:_r({accept:`application/json`,"anthropic-dangerous-direct-browser-access":`true`,"anthropic-beta":o.join(`,`)},e.headers,r)}),isOAuthToken:!1}}function wr(e,t,n,r){let{cacheControl:a}=dr(e.baseUrl,r?.cacheRetention),o={model:e.id,messages:Er(t.messages,e,n,a),max_tokens:r?.maxTokens||e.maxTokens/3|0,stream:!0};if(n?(o.system=[{type:`text`,text:`You are Claude Code, Anthropic's official CLI for Claude.`,...a?{cache_control:a}:{}}],t.systemPrompt&&o.system.push({type:`text`,text:i(t.systemPrompt),...a?{cache_control:a}:{}})):t.systemPrompt&&(o.system=[{type:`text`,text:i(t.systemPrompt),...a?{cache_control:a}:{}}]),r?.temperature!==void 0&&!r?.thinkingEnabled&&(o.temperature=r.temperature),t.tools&&(o.tools=Dr(t.tools,n)),e.reasoning&&(r?.thinkingEnabled?yr(e.id)?(o.thinking={type:`adaptive`},r.effort&&(o.output_config={effort:r.effort})):o.thinking={type:`enabled`,budget_tokens:r.thinkingBudgetTokens||1024}:r?.thinkingEnabled===!1&&(o.thinking={type:`disabled`})),r?.metadata){let e=r.metadata.user_id;typeof e==`string`&&(o.metadata={user_id:e})}return r?.toolChoice&&(typeof r.toolChoice==`string`?o.tool_choice={type:r.toolChoice}:o.tool_choice=r.toolChoice),o}function Tr(e){return e.replace(/[^a-zA-Z0-9_-]/g,`_`).slice(0,64)}function Er(e,t,n,r){let a=[],o=s(e,t,Tr);for(let e=0;e<o.length;e++){let r=o[e];if(r.role===`user`)if(typeof r.content==`string`)r.content.trim().length>0&&a.push({role:`user`,content:i(r.content)});else{let e=r.content.map(e=>e.type===`text`?{type:`text`,text:i(e.text)}:{type:`image`,source:{type:`base64`,media_type:e.mimeType,data:e.data}}),n=t?.input.includes(`image`)?e:e.filter(e=>e.type!==`image`);if(n=n.filter(e=>e.type===`text`?e.text.trim().length>0:!0),n.length===0)continue;a.push({role:`user`,content:n})}else if(r.role===`assistant`){let e=[];for(let t of r.content)if(t.type===`text`){if(t.text.trim().length===0)continue;e.push({type:`text`,text:i(t.text)})}else if(t.type===`thinking`){if(t.redacted){e.push({type:`redacted_thinking`,data:t.thinkingSignature});continue}if(t.thinking.trim().length===0)continue;!t.thinkingSignature||t.thinkingSignature.trim().length===0?e.push({type:`text`,text:i(t.thinking)}):e.push({type:`thinking`,thinking:i(t.thinking),signature:t.thinkingSignature})}else t.type===`toolCall`&&e.push({type:`tool_use`,id:t.id,name:n?mr(t.name):t.name,input:t.arguments??{}});if(e.length===0)continue;a.push({role:`assistant`,content:e})}else if(r.role===`toolResult`){let t=[];t.push({type:`tool_result`,tool_use_id:r.toolCallId,content:gr(r.content),is_error:r.isError});let n=e+1;for(;n<o.length&&o[n].role===`toolResult`;){let e=o[n];t.push({type:`tool_result`,tool_use_id:e.toolCallId,content:gr(e.content),is_error:e.isError}),n++}e=n-1,a.push({role:`user`,content:t})}}if(r&&a.length>0){let e=a[a.length-1];if(e.role===`user`)if(Array.isArray(e.content)){let t=e.content[e.content.length-1];t&&(t.type===`text`||t.type===`image`||t.type===`tool_result`)&&(t.cache_control=r)}else typeof e.content==`string`&&(e.content=[{type:`text`,text:e.content,cache_control:r}])}return a}function Dr(e,t){return e?e.map(e=>{let n=e.parameters;return{name:t?mr(e.name):e.name,description:e.description,input_schema:{type:`object`,properties:n.properties||{},required:n.required||[]}}}):[]}function Or(e){switch(e){case`end_turn`:return`stop`;case`max_tokens`:return`length`;case`tool_use`:return`toolUse`;case`refusal`:return`error`;case`pause_turn`:return`stop`;case`stop_sequence`:return`stop`;case`sensitive`:return`error`;default:throw Error(`Unhandled stop reason: ${e}`)}}export{vr as streamAnthropic,xr as streamSimpleAnthropic};
37
- //# sourceMappingURL=anthropic-D2gWjM8y.js.map
37
+ //# sourceMappingURL=anthropic-DgG8lDlL.js.map
@@ -1,2 +1,2 @@
1
- import{r as e,t}from"./event-stream-B8X6sYaV.js";import{d as n}from"./index-C0UxQzEn.js";import{i as r,r as i}from"./transform-messages-XKqwKV3D.js";import{t as a}from"./openai-Cn7eGqwa.js";import{n as o,r as s,t as c}from"./openai-responses-shared-Q7jopnLp.js";var l=`v1`,u=new Set([`openai`,`openai-codex`,`opencode`,`azure-openai-responses`]);function d(e){let t=new Map;if(!e)return t;for(let n of e.split(`,`)){let e=n.trim();if(!e)continue;let[r,i]=e.split(`=`,2);!r||!i||t.set(r.trim(),i.trim())}return t}function f(e,t){return t?.azureDeploymentName?t.azureDeploymentName:d({}.AZURE_OPENAI_DEPLOYMENT_NAME_MAP).get(e.id)||e.id}var p=(e,r,i)=>{let a=new t;return(async()=>{let t=f(e,i),o={role:`assistant`,content:[],api:`azure-openai-responses`,provider:e.provider,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:`stop`,timestamp:Date.now()};try{let c=v(e,i?.apiKey||n(e.provider)||``,i),l=y(e,r,i,t),u=await i?.onPayload?.(l,e);u!==void 0&&(l=u);let d=await c.responses.create(l,i?.signal?{signal:i.signal}:void 0);if(a.push({type:`start`,partial:o}),await s(d,o,a,e),i?.signal?.aborted)throw Error(`Request was aborted`);if(o.stopReason===`aborted`||o.stopReason===`error`)throw Error(`An unknown error occurred`);a.push({type:`done`,reason:o.stopReason,message:o}),a.end()}catch(e){for(let e of o.content)delete e.index;o.stopReason=i?.signal?.aborted?`aborted`:`error`,o.errorMessage=e instanceof Error?e.message:JSON.stringify(e),a.push({type:`error`,reason:o.stopReason,error:o}),a.end()}})(),a},m=(t,a,o)=>{let s=o?.apiKey||n(t.provider);if(!s)throw Error(`No API key for provider: ${t.provider}`);let c=i(t,o,s),l=e(t)?o?.reasoning:r(o?.reasoning);return p(t,a,{...c,reasoningEffort:l})};function h(e){return e.replace(/\/+$/,``)}function g(e){return`https://${e}.openai.azure.com/openai/v1`}function _(e,t){let n=t?.azureApiVersion||{}.AZURE_OPENAI_API_VERSION||l,r=t?.azureBaseUrl?.trim()||{}.AZURE_OPENAI_BASE_URL?.trim()||void 0,i=t?.azureResourceName||{}.AZURE_OPENAI_RESOURCE_NAME,a=r;if(!a&&i&&(a=g(i)),!a&&e.baseUrl&&(a=e.baseUrl),!a)throw Error(`Azure OpenAI base URL is required. Set AZURE_OPENAI_BASE_URL or AZURE_OPENAI_RESOURCE_NAME, or pass azureBaseUrl, azureResourceName, or model.baseUrl.`);return{baseUrl:h(a),apiVersion:n}}function v(e,t,n){if(!t){if(!{}.AZURE_OPENAI_API_KEY)throw Error(`Azure OpenAI API key is required. Set AZURE_OPENAI_API_KEY environment variable or pass it as an argument.`);t={}.AZURE_OPENAI_API_KEY}let r={...e.headers};n?.headers&&Object.assign(r,n.headers);let{baseUrl:i,apiVersion:o}=_(e,n);return new a({apiKey:t,apiVersion:o,dangerouslyAllowBrowser:!0,defaultHeaders:r,baseURL:i})}function y(e,t,n,r){let i={model:r,input:c(e,t,u),stream:!0,prompt_cache_key:n?.sessionId};return n?.maxTokens&&(i.max_output_tokens=n?.maxTokens),n?.temperature!==void 0&&(i.temperature=n?.temperature),t.tools&&(i.tools=o(t.tools)),e.reasoning&&(n?.reasoningEffort||n?.reasoningSummary?(i.reasoning={effort:n?.reasoningEffort||`medium`,summary:n?.reasoningSummary||`auto`},i.include=[`reasoning.encrypted_content`]):i.reasoning={effort:`none`}),i}export{p as streamAzureOpenAIResponses,m as streamSimpleAzureOpenAIResponses};
2
- //# sourceMappingURL=azure-openai-responses-rSA0t6IS.js.map
1
+ import{r as e,t}from"./event-stream-B8X6sYaV.js";import{d as n}from"./index-CUmjeRtH.js";import{i as r,r as i}from"./transform-messages-XKqwKV3D.js";import{t as a}from"./openai-Cn7eGqwa.js";import{n as o,r as s,t as c}from"./openai-responses-shared-BzAz6CNs.js";var l=`v1`,u=new Set([`openai`,`openai-codex`,`opencode`,`azure-openai-responses`]);function d(e){let t=new Map;if(!e)return t;for(let n of e.split(`,`)){let e=n.trim();if(!e)continue;let[r,i]=e.split(`=`,2);!r||!i||t.set(r.trim(),i.trim())}return t}function f(e,t){return t?.azureDeploymentName?t.azureDeploymentName:d({}.AZURE_OPENAI_DEPLOYMENT_NAME_MAP).get(e.id)||e.id}var p=(e,r,i)=>{let a=new t;return(async()=>{let t=f(e,i),o={role:`assistant`,content:[],api:`azure-openai-responses`,provider:e.provider,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:`stop`,timestamp:Date.now()};try{let c=v(e,i?.apiKey||n(e.provider)||``,i),l=y(e,r,i,t),u=await i?.onPayload?.(l,e);u!==void 0&&(l=u);let d=await c.responses.create(l,i?.signal?{signal:i.signal}:void 0);if(a.push({type:`start`,partial:o}),await s(d,o,a,e),i?.signal?.aborted)throw Error(`Request was aborted`);if(o.stopReason===`aborted`||o.stopReason===`error`)throw Error(`An unknown error occurred`);a.push({type:`done`,reason:o.stopReason,message:o}),a.end()}catch(e){for(let e of o.content)delete e.index;o.stopReason=i?.signal?.aborted?`aborted`:`error`,o.errorMessage=e instanceof Error?e.message:JSON.stringify(e),a.push({type:`error`,reason:o.stopReason,error:o}),a.end()}})(),a},m=(t,a,o)=>{let s=o?.apiKey||n(t.provider);if(!s)throw Error(`No API key for provider: ${t.provider}`);let c=i(t,o,s),l=e(t)?o?.reasoning:r(o?.reasoning);return p(t,a,{...c,reasoningEffort:l})};function h(e){return e.replace(/\/+$/,``)}function g(e){return`https://${e}.openai.azure.com/openai/v1`}function _(e,t){let n=t?.azureApiVersion||{}.AZURE_OPENAI_API_VERSION||l,r=t?.azureBaseUrl?.trim()||{}.AZURE_OPENAI_BASE_URL?.trim()||void 0,i=t?.azureResourceName||{}.AZURE_OPENAI_RESOURCE_NAME,a=r;if(!a&&i&&(a=g(i)),!a&&e.baseUrl&&(a=e.baseUrl),!a)throw Error(`Azure OpenAI base URL is required. Set AZURE_OPENAI_BASE_URL or AZURE_OPENAI_RESOURCE_NAME, or pass azureBaseUrl, azureResourceName, or model.baseUrl.`);return{baseUrl:h(a),apiVersion:n}}function v(e,t,n){if(!t){if(!{}.AZURE_OPENAI_API_KEY)throw Error(`Azure OpenAI API key is required. Set AZURE_OPENAI_API_KEY environment variable or pass it as an argument.`);t={}.AZURE_OPENAI_API_KEY}let r={...e.headers};n?.headers&&Object.assign(r,n.headers);let{baseUrl:i,apiVersion:o}=_(e,n);return new a({apiKey:t,apiVersion:o,dangerouslyAllowBrowser:!0,defaultHeaders:r,baseURL:i})}function y(e,t,n,r){let i={model:r,input:c(e,t,u),stream:!0,prompt_cache_key:n?.sessionId};return n?.maxTokens&&(i.max_output_tokens=n?.maxTokens),n?.temperature!==void 0&&(i.temperature=n?.temperature),t.tools&&(i.tools=o(t.tools)),e.reasoning&&(n?.reasoningEffort||n?.reasoningSummary?(i.reasoning={effort:n?.reasoningEffort||`medium`,summary:n?.reasoningSummary||`auto`},i.include=[`reasoning.encrypted_content`]):i.reasoning={effort:`none`}),i}export{p as streamAzureOpenAIResponses,m as streamSimpleAzureOpenAIResponses};
2
+ //# sourceMappingURL=azure-openai-responses-CBgrXqWI.js.map
@@ -1,4 +1,4 @@
1
- import{i as e,n as t}from"./lit-zdTgzAJI.js";import{d as n,l as r}from"./format-nUIQxx1z.js";import{F as i,I as a,c as o,l as s}from"./index-C0UxQzEn.js";import{n as c,t as l}from"./channel-config-extras-DNCeHtEf.js";function u(e,t){let n=e;for(let e of t){if(!n)return null;let t=a(n);if(t===`object`){let t=n.properties??{};if(typeof e==`string`&&t[e]){n=t[e];continue}let r=n.additionalProperties;if(typeof e==`string`&&r&&typeof r==`object`){n=r;continue}return null}if(t===`array`){if(typeof e!=`number`)return null;n=(Array.isArray(n.items)?n.items[0]:n.items)??null;continue}return null}return n}function d(e,t){return c(e,t)??{}}var f=[`groupPolicy`,`streamMode`,`dmPolicy`];function p(t){let n=f.flatMap(e=>e in t?[[e,t[e]]]:[]);return n.length===0?null:e`
1
+ import{i as e,n as t}from"./lit-zdTgzAJI.js";import{d as n,l as r}from"./format-nUIQxx1z.js";import{F as i,I as a,c as o,l as s}from"./index-CUmjeRtH.js";import{n as c,t as l}from"./channel-config-extras-DNCeHtEf.js";function u(e,t){let n=e;for(let e of t){if(!n)return null;let t=a(n);if(t===`object`){let t=n.properties??{};if(typeof e==`string`&&t[e]){n=t[e];continue}let r=n.additionalProperties;if(typeof e==`string`&&r&&typeof r==`object`){n=r;continue}return null}if(t===`array`){if(typeof e!=`number`)return null;n=(Array.isArray(n.items)?n.items[0]:n.items)??null;continue}return null}return n}function d(e,t){return c(e,t)??{}}var f=[`groupPolicy`,`streamMode`,`dmPolicy`];function p(t){let n=f.flatMap(e=>e in t?[[e,t[e]]]:[]);return n.length===0?null:e`
2
2
  <div class="status-list" style="margin-top: 12px;">
3
3
  ${n.map(([t,n])=>e`
4
4
  <div>
@@ -346,4 +346,4 @@ ${n.snapshot?JSON.stringify(n.snapshot,null,2):`No snapshot yet.`}
346
346
  </div>
347
347
  </div>
348
348
  `}export{P as renderChannels};
349
- //# sourceMappingURL=channels-BgJBIl8z.js.map
349
+ //# sourceMappingURL=channels-Dpq8rmYk.js.map
@@ -1,4 +1,4 @@
1
- import{i as e,n as t}from"./lit-zdTgzAJI.js";import{i as n,l as r}from"./format-nUIQxx1z.js";import{L as i,P as a,a as o,n as s}from"./index-C0UxQzEn.js";var c=e=>e??t;function l(){return[{value:`ok`,label:i(`cron.runs.runStatusOk`)},{value:`error`,label:i(`cron.runs.runStatusError`)},{value:`skipped`,label:i(`cron.runs.runStatusSkipped`)}]}function u(){return[{value:`delivered`,label:i(`cron.runs.deliveryDelivered`)},{value:`not-delivered`,label:i(`cron.runs.deliveryNotDelivered`)},{value:`unknown`,label:i(`cron.runs.deliveryUnknown`)},{value:`not-requested`,label:i(`cron.runs.deliveryNotRequested`)}]}function d(e,t,n){let r=new Set(e);return n?r.add(t):r.delete(t),Array.from(r)}function f(e,t){return e.length===0?t:e.length<=2?e.join(`, `):`${e[0]} +${e.length-1}`}function p(e){let t=[`last`,...e.channels.filter(Boolean)],n=e.form.deliveryChannel?.trim();n&&!t.includes(n)&&t.push(n);let r=new Set;return t.filter(e=>r.has(e)?!1:(r.add(e),!0))}function m(e,t){if(t===`last`)return`last`;let n=e.channelMeta?.find(e=>e.id===t);return n?.label?n.label:e.channelLabels?.[t]??t}function h(t){return e`
1
+ import{i as e,n as t}from"./lit-zdTgzAJI.js";import{i as n,l as r}from"./format-nUIQxx1z.js";import{L as i,P as a,a as o,n as s}from"./index-CUmjeRtH.js";var c=e=>e??t;function l(){return[{value:`ok`,label:i(`cron.runs.runStatusOk`)},{value:`error`,label:i(`cron.runs.runStatusError`)},{value:`skipped`,label:i(`cron.runs.runStatusSkipped`)}]}function u(){return[{value:`delivered`,label:i(`cron.runs.deliveryDelivered`)},{value:`not-delivered`,label:i(`cron.runs.deliveryNotDelivered`)},{value:`unknown`,label:i(`cron.runs.deliveryUnknown`)},{value:`not-requested`,label:i(`cron.runs.deliveryNotRequested`)}]}function d(e,t,n){let r=new Set(e);return n?r.add(t):r.delete(t),Array.from(r)}function f(e,t){return e.length===0?t:e.length<=2?e.join(`, `):`${e[0]} +${e.length-1}`}function p(e){let t=[`last`,...e.channels.filter(Boolean)],n=e.form.deliveryChannel?.trim();n&&!t.includes(n)&&t.push(n);let r=new Set;return t.filter(e=>r.has(e)?!1:(r.add(e),!0))}function m(e,t){if(t===`last`)return`last`;let n=e.channelMeta?.find(e=>e.id===t);return n?.label?n.label:e.channelLabels?.[t]??t}function h(t){return e`
2
2
  <div class="field cron-filter-dropdown" data-filter=${t.id}>
3
3
  <span>${t.title}</span>
4
4
  <details class="cron-filter-dropdown__details">
@@ -925,4 +925,4 @@ import{i as e,n as t}from"./lit-zdTgzAJI.js";import{i as n,l as r}from"./format-
925
925
  </div>
926
926
  </div>
927
927
  `}export{C as renderCron};
928
- //# sourceMappingURL=cron-CESIxOYW.js.map
928
+ //# sourceMappingURL=cron-Cc7oz4VO.js.map
@@ -1,4 +1,4 @@
1
- import{i as e,n as t}from"./lit-zdTgzAJI.js";import{i as n}from"./index-C0UxQzEn.js";function r(r){let i=(r.status&&typeof r.status==`object`?r.status.securityAudit:null)?.summary??null,a=i?.critical??0,o=i?.warn??0,s=i?.info??0,c=a>0?`danger`:o>0?`warn`:`success`,l=a>0?`${a} critical`:o>0?`${o} warnings`:`No critical issues`;return e`
1
+ import{i as e,n as t}from"./lit-zdTgzAJI.js";import{i as n}from"./index-CUmjeRtH.js";function r(r){let i=(r.status&&typeof r.status==`object`?r.status.securityAudit:null)?.summary??null,a=i?.critical??0,o=i?.warn??0,s=i?.info??0,c=a>0?`danger`:o>0?`warn`:`success`,l=a>0?`${a} critical`:o>0?`${o} warnings`:`No critical issues`;return e`
2
2
  <section class="grid">
3
3
  <div class="card">
4
4
  <div class="row" style="justify-content: space-between;">
@@ -91,4 +91,4 @@ ${n(t.payload)}</pre
91
91
  `}
92
92
  </section>
93
93
  `}export{r as renderDebug};
94
- //# sourceMappingURL=debug-BAZT8Cur.js.map
94
+ //# sourceMappingURL=debug-CwAvIw7x.js.map
@@ -1,2 +1,2 @@
1
- import{n as e,t}from"./event-stream-B8X6sYaV.js";import{d as n}from"./index-C0UxQzEn.js";import{a as r,i,r as a}from"./transform-messages-XKqwKV3D.js";import{c as o,i as s,n as c,o as l,r as u,s as d,t as f}from"./google-shared-CbPHVnPr.js";var p=0,m=(r,i,a)=>{let o=new t;return(async()=>{let t={role:`assistant`,content:[],api:`google-generative-ai`,provider:r.provider,model:r.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:`stop`,timestamp:Date.now()};try{let c=g(r,a?.apiKey||n(r.provider)||``,a?.headers),l=_(r,i,a),f=await a?.onPayload?.(l,r);f!==void 0&&(l=f);let m=await c.models.generateContentStream(l);o.push({type:`start`,partial:t});let h=null,v=t.content,y=()=>v.length-1;for await(let n of m){t.responseId||=n.responseId;let i=n.candidates?.[0];if(i?.content?.parts)for(let e of i.content.parts){if(e.text!==void 0){let n=u(e);(!h||n&&h.type!==`thinking`||!n&&h.type!==`text`)&&(h&&(h.type===`text`?o.push({type:`text_end`,contentIndex:v.length-1,content:h.text,partial:t}):o.push({type:`thinking_end`,contentIndex:y(),content:h.thinking,partial:t})),n?(h={type:`thinking`,thinking:``,thinkingSignature:void 0},t.content.push(h),o.push({type:`thinking_start`,contentIndex:y(),partial:t})):(h={type:`text`,text:``},t.content.push(h),o.push({type:`text_start`,contentIndex:y(),partial:t}))),h.type===`thinking`?(h.thinking+=e.text,h.thinkingSignature=d(h.thinkingSignature,e.thoughtSignature),o.push({type:`thinking_delta`,contentIndex:y(),delta:e.text,partial:t})):(h.text+=e.text,h.textSignature=d(h.textSignature,e.thoughtSignature),o.push({type:`text_delta`,contentIndex:y(),delta:e.text,partial:t}))}if(e.functionCall){h&&=(h.type===`text`?o.push({type:`text_end`,contentIndex:y(),content:h.text,partial:t}):o.push({type:`thinking_end`,contentIndex:y(),content:h.thinking,partial:t}),null);let n=e.functionCall.id,r={type:`toolCall`,id:!n||t.content.some(e=>e.type===`toolCall`&&e.id===n)?`${e.functionCall.name}_${Date.now()}_${++p}`:n,name:e.functionCall.name||``,arguments:e.functionCall.args??{},...e.thoughtSignature&&{thoughtSignature:e.thoughtSignature}};t.content.push(r),o.push({type:`toolcall_start`,contentIndex:y(),partial:t}),o.push({type:`toolcall_delta`,contentIndex:y(),delta:JSON.stringify(r.arguments),partial:t}),o.push({type:`toolcall_end`,contentIndex:y(),toolCall:r,partial:t})}}i?.finishReason&&(t.stopReason=s(i.finishReason),t.content.some(e=>e.type===`toolCall`)&&(t.stopReason=`toolUse`)),n.usageMetadata&&(t.usage={input:(n.usageMetadata.promptTokenCount||0)-(n.usageMetadata.cachedContentTokenCount||0),output:(n.usageMetadata.candidatesTokenCount||0)+(n.usageMetadata.thoughtsTokenCount||0),cacheRead:n.usageMetadata.cachedContentTokenCount||0,cacheWrite:0,totalTokens:n.usageMetadata.totalTokenCount||0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},e(r,t.usage))}if(h&&(h.type===`text`?o.push({type:`text_end`,contentIndex:y(),content:h.text,partial:t}):o.push({type:`thinking_end`,contentIndex:y(),content:h.thinking,partial:t})),a?.signal?.aborted)throw Error(`Request was aborted`);if(t.stopReason===`aborted`||t.stopReason===`error`)throw Error(`An unknown error occurred`);o.push({type:`done`,reason:t.stopReason,message:t}),o.end()}catch(e){for(let e of t.content)`index`in e&&delete e.index;t.stopReason=a?.signal?.aborted?`aborted`:`error`,t.errorMessage=e instanceof Error?e.message:JSON.stringify(e),o.push({type:`error`,reason:t.stopReason,error:t}),o.end()}})(),o},h=(e,t,r)=>{let o=r?.apiKey||n(e.provider);if(!o)throw Error(`No API key for provider: ${e.provider}`);let s=a(e,r,o);if(!r?.reasoning)return m(e,t,{...s,thinking:{enabled:!1}});let c=i(r.reasoning),l=e;return v(l)||y(l)?m(e,t,{...s,thinking:{enabled:!0,level:x(c,l)}}):m(e,t,{...s,thinking:{enabled:!0,budgetTokens:S(l,c,r.thinkingBudgets)}})};function g(e,t,n){let r={};return e.baseUrl&&(r.baseUrl=e.baseUrl,r.apiVersion=``),(e.headers||n)&&(r.headers={...e.headers,...n}),new o({apiKey:t,httpOptions:Object.keys(r).length>0?r:void 0})}function _(e,t,n={}){let i=f(e,t),a={};n.temperature!==void 0&&(a.temperature=n.temperature),n.maxTokens!==void 0&&(a.maxOutputTokens=n.maxTokens);let o={...Object.keys(a).length>0&&a,...t.systemPrompt&&{systemInstruction:r(t.systemPrompt)},...t.tools&&t.tools.length>0&&{tools:c(t.tools)}};if(t.tools&&t.tools.length>0&&n.toolChoice?o.toolConfig={functionCallingConfig:{mode:l(n.toolChoice)}}:o.toolConfig=void 0,n.thinking?.enabled&&e.reasoning){let e={includeThoughts:!0};n.thinking.level===void 0?n.thinking.budgetTokens!==void 0&&(e.thinkingBudget=n.thinking.budgetTokens):e.thinkingLevel=n.thinking.level,o.thinkingConfig=e}else e.reasoning&&n.thinking&&!n.thinking.enabled&&(o.thinkingConfig=b(e));if(n.signal){if(n.signal.aborted)throw Error(`Request aborted`);o.abortSignal=n.signal}return{model:e.id,contents:i,config:o}}function v(e){return/gemini-3(?:\.\d+)?-pro/.test(e.id.toLowerCase())}function y(e){return/gemini-3(?:\.\d+)?-flash/.test(e.id.toLowerCase())}function b(e){return v(e)?{thinkingLevel:`LOW`}:y(e)?{thinkingLevel:`MINIMAL`}:{thinkingBudget:0}}function x(e,t){if(v(t))switch(e){case`minimal`:case`low`:return`LOW`;case`medium`:case`high`:return`HIGH`}switch(e){case`minimal`:return`MINIMAL`;case`low`:return`LOW`;case`medium`:return`MEDIUM`;case`high`:return`HIGH`}}function S(e,t,n){return n?.[t]===void 0?e.id.includes(`2.5-pro`)?{minimal:128,low:2048,medium:8192,high:32768}[t]:e.id.includes(`2.5-flash`)?{minimal:128,low:2048,medium:8192,high:24576}[t]:-1:n[t]}export{m as streamGoogle,h as streamSimpleGoogle};
2
- //# sourceMappingURL=google-B2pGWEiN.js.map
1
+ import{n as e,t}from"./event-stream-B8X6sYaV.js";import{d as n}from"./index-CUmjeRtH.js";import{a as r,i,r as a}from"./transform-messages-XKqwKV3D.js";import{c as o,i as s,n as c,o as l,r as u,s as d,t as f}from"./google-shared-CbPHVnPr.js";var p=0,m=(r,i,a)=>{let o=new t;return(async()=>{let t={role:`assistant`,content:[],api:`google-generative-ai`,provider:r.provider,model:r.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:`stop`,timestamp:Date.now()};try{let c=g(r,a?.apiKey||n(r.provider)||``,a?.headers),l=_(r,i,a),f=await a?.onPayload?.(l,r);f!==void 0&&(l=f);let m=await c.models.generateContentStream(l);o.push({type:`start`,partial:t});let h=null,v=t.content,y=()=>v.length-1;for await(let n of m){t.responseId||=n.responseId;let i=n.candidates?.[0];if(i?.content?.parts)for(let e of i.content.parts){if(e.text!==void 0){let n=u(e);(!h||n&&h.type!==`thinking`||!n&&h.type!==`text`)&&(h&&(h.type===`text`?o.push({type:`text_end`,contentIndex:v.length-1,content:h.text,partial:t}):o.push({type:`thinking_end`,contentIndex:y(),content:h.thinking,partial:t})),n?(h={type:`thinking`,thinking:``,thinkingSignature:void 0},t.content.push(h),o.push({type:`thinking_start`,contentIndex:y(),partial:t})):(h={type:`text`,text:``},t.content.push(h),o.push({type:`text_start`,contentIndex:y(),partial:t}))),h.type===`thinking`?(h.thinking+=e.text,h.thinkingSignature=d(h.thinkingSignature,e.thoughtSignature),o.push({type:`thinking_delta`,contentIndex:y(),delta:e.text,partial:t})):(h.text+=e.text,h.textSignature=d(h.textSignature,e.thoughtSignature),o.push({type:`text_delta`,contentIndex:y(),delta:e.text,partial:t}))}if(e.functionCall){h&&=(h.type===`text`?o.push({type:`text_end`,contentIndex:y(),content:h.text,partial:t}):o.push({type:`thinking_end`,contentIndex:y(),content:h.thinking,partial:t}),null);let n=e.functionCall.id,r={type:`toolCall`,id:!n||t.content.some(e=>e.type===`toolCall`&&e.id===n)?`${e.functionCall.name}_${Date.now()}_${++p}`:n,name:e.functionCall.name||``,arguments:e.functionCall.args??{},...e.thoughtSignature&&{thoughtSignature:e.thoughtSignature}};t.content.push(r),o.push({type:`toolcall_start`,contentIndex:y(),partial:t}),o.push({type:`toolcall_delta`,contentIndex:y(),delta:JSON.stringify(r.arguments),partial:t}),o.push({type:`toolcall_end`,contentIndex:y(),toolCall:r,partial:t})}}i?.finishReason&&(t.stopReason=s(i.finishReason),t.content.some(e=>e.type===`toolCall`)&&(t.stopReason=`toolUse`)),n.usageMetadata&&(t.usage={input:(n.usageMetadata.promptTokenCount||0)-(n.usageMetadata.cachedContentTokenCount||0),output:(n.usageMetadata.candidatesTokenCount||0)+(n.usageMetadata.thoughtsTokenCount||0),cacheRead:n.usageMetadata.cachedContentTokenCount||0,cacheWrite:0,totalTokens:n.usageMetadata.totalTokenCount||0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},e(r,t.usage))}if(h&&(h.type===`text`?o.push({type:`text_end`,contentIndex:y(),content:h.text,partial:t}):o.push({type:`thinking_end`,contentIndex:y(),content:h.thinking,partial:t})),a?.signal?.aborted)throw Error(`Request was aborted`);if(t.stopReason===`aborted`||t.stopReason===`error`)throw Error(`An unknown error occurred`);o.push({type:`done`,reason:t.stopReason,message:t}),o.end()}catch(e){for(let e of t.content)`index`in e&&delete e.index;t.stopReason=a?.signal?.aborted?`aborted`:`error`,t.errorMessage=e instanceof Error?e.message:JSON.stringify(e),o.push({type:`error`,reason:t.stopReason,error:t}),o.end()}})(),o},h=(e,t,r)=>{let o=r?.apiKey||n(e.provider);if(!o)throw Error(`No API key for provider: ${e.provider}`);let s=a(e,r,o);if(!r?.reasoning)return m(e,t,{...s,thinking:{enabled:!1}});let c=i(r.reasoning),l=e;return v(l)||y(l)?m(e,t,{...s,thinking:{enabled:!0,level:x(c,l)}}):m(e,t,{...s,thinking:{enabled:!0,budgetTokens:S(l,c,r.thinkingBudgets)}})};function g(e,t,n){let r={};return e.baseUrl&&(r.baseUrl=e.baseUrl,r.apiVersion=``),(e.headers||n)&&(r.headers={...e.headers,...n}),new o({apiKey:t,httpOptions:Object.keys(r).length>0?r:void 0})}function _(e,t,n={}){let i=f(e,t),a={};n.temperature!==void 0&&(a.temperature=n.temperature),n.maxTokens!==void 0&&(a.maxOutputTokens=n.maxTokens);let o={...Object.keys(a).length>0&&a,...t.systemPrompt&&{systemInstruction:r(t.systemPrompt)},...t.tools&&t.tools.length>0&&{tools:c(t.tools)}};if(t.tools&&t.tools.length>0&&n.toolChoice?o.toolConfig={functionCallingConfig:{mode:l(n.toolChoice)}}:o.toolConfig=void 0,n.thinking?.enabled&&e.reasoning){let e={includeThoughts:!0};n.thinking.level===void 0?n.thinking.budgetTokens!==void 0&&(e.thinkingBudget=n.thinking.budgetTokens):e.thinkingLevel=n.thinking.level,o.thinkingConfig=e}else e.reasoning&&n.thinking&&!n.thinking.enabled&&(o.thinkingConfig=b(e));if(n.signal){if(n.signal.aborted)throw Error(`Request aborted`);o.abortSignal=n.signal}return{model:e.id,contents:i,config:o}}function v(e){return/gemini-3(?:\.\d+)?-pro/.test(e.id.toLowerCase())}function y(e){return/gemini-3(?:\.\d+)?-flash/.test(e.id.toLowerCase())}function b(e){return v(e)?{thinkingLevel:`LOW`}:y(e)?{thinkingLevel:`MINIMAL`}:{thinkingBudget:0}}function x(e,t){if(v(t))switch(e){case`minimal`:case`low`:return`LOW`;case`medium`:case`high`:return`HIGH`}switch(e){case`minimal`:return`MINIMAL`;case`low`:return`LOW`;case`medium`:return`MEDIUM`;case`high`:return`HIGH`}}function S(e,t,n){return n?.[t]===void 0?e.id.includes(`2.5-pro`)?{minimal:128,low:2048,medium:8192,high:32768}[t]:e.id.includes(`2.5-flash`)?{minimal:128,low:2048,medium:8192,high:24576}[t]:-1:n[t]}export{m as streamGoogle,h as streamSimpleGoogle};
2
+ //# sourceMappingURL=google-D-Vqc1qj.js.map