'use strict';var chunkQXMXSHYS_cjs=require('./chunk-QXMXSHYS.cjs'),chunkW6MVJKWN_cjs=require('./chunk-W6MVJKWN.cjs');var K={"claude-sonnet-4-5-20250929":{input:3,output:15},"claude-sonnet-4-20250514":{input:3,output:15},"claude-haiku-4-5-20250514":{input:.8,output:4},"claude-haiku-3-5-20241022":{input:.8,output:4},"claude-opus-4-20250514":{input:15,output:75}};function L(h){let{apiKey:i,model:k="claude-sonnet-4-5-20250929",maxTokens:d=4096,baseURL:u="https://api.anthropic.com/v1",fetch:f=globalThis.fetch,timeoutMs:r,hooks:m,temperature:p,topP:c,stopSequences:o}=h;return chunkW6MVJKWN_cjs.d(u),chunkQXMXSHYS_cjs.c(i,"createAnthropicRunner"),chunkW6MVJKWN_cjs.e({fetch:f,hooks:m,buildRequest:(n,s,a)=>({url:`${u}/messages`,init:{method:"POST",headers:{"Content-Type":"application/json","x-api-key":i,"anthropic-version":"2023-06-01"},body:JSON.stringify({model:n.model??k,max_tokens:d,...p!=null?{temperature:p}:{},...c!=null?{top_p:c}:{},...o!=null?{stop_sequences:o}:{},system:n.instructions??"",messages:a.map(e=>({role:e.role,content:e.content}))}),...r!=null?{signal:AbortSignal.timeout(r)}:{}}}),parseResponse:async n=>{let s=await n.json(),a=s.content?.[0]?.text??"",e=s.usage?.input_tokens??0,l=s.usage?.output_tokens??0;return {text:a,totalTokens:e+l,inputTokens:e,outputTokens:l}}})}function N(h){let{apiKey:i,model:k="claude-sonnet-4-5-20250929",maxTokens:d=4096,baseURL:u="https://api.anthropic.com/v1",fetch:f=globalThis.fetch,hooks:r,temperature:m,topP:p,stopSequences:c}=h;return chunkW6MVJKWN_cjs.d(u),chunkQXMXSHYS_cjs.c(i,"createAnthropicStreamingRunner"),async(o,n,s)=>{let a=chunkQXMXSHYS_cjs.e(r,o,n);try{let e=await f(`${u}/messages`,{method:"POST",headers:{"Content-Type":"application/json","x-api-key":i,"anthropic-version":"2023-06-01"},body:JSON.stringify({model:o.model??k,max_tokens:d,...m!=null?{temperature:m}:{},...p!=null?{top_p:p}:{},...c!=null?{stop_sequences:c}:{},system:o.instructions??"",messages:[{role:"user",content:n}],stream:!0}),signal:s.signal});e.ok||await chunkQXMXSHYS_cjs.a(e,"Anthropic");let l=chunkQXMXSHYS_cjs.b(e),{fullText:R,inputTokens:b,outputTokens:S}=await chunkQXMXSHYS_cjs.d(l,s.onToken,t=>{if(t.type==="error")throw new Error(`[Directive] Anthropic stream error: ${t.error?.message??JSON.stringify(t.error)}`);let g={};return t.type==="content_block_delta"&&t.delta?.type==="text_delta"&&(g.text=t.delta.text),t.type==="message_delta"&&t.usage&&(g.outputTokens=t.usage.output_tokens??0),t.type==="message_start"&&t.message?.usage&&(g.inputTokens=t.message.usage.input_tokens??0),g},"Anthropic"),x={inputTokens:b,outputTokens:S},A=b+S;return s.onMessage?.({role:"assistant",content:R}),chunkQXMXSHYS_cjs.f(r,o,n,R,A,x,a),chunkQXMXSHYS_cjs.h(n,R,A,x)}catch(e){throw chunkQXMXSHYS_cjs.g(r,o,n,e,a),e}}}
exports.ANTHROPIC_PRICING=K;exports.createAnthropicRunner=L;exports.createAnthropicStreamingRunner=N;//# sourceMappingURL=anthropic.cjs.map
//# sourceMappingURL=anthropic.cjs.map