@shumai-one/shumai 0.5.2 → 0.6.0

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 (146) hide show
  1. package/bin/{chunk-qxscgcn9.js → chunk-01ym2agz.js} +1 -1
  2. package/bin/{chunk-ae6zgjhd.js → chunk-047n9gfs.js} +2 -2
  3. package/bin/chunk-0a4ahz7r.js +2 -0
  4. package/bin/{chunk-v5hz09a1.js → chunk-0awcpx0a.js} +2 -2
  5. package/bin/{chunk-19q13a80.js → chunk-0fbgfgxv.js} +5 -5
  6. package/bin/{chunk-jt6v15wx.js → chunk-0nnqha4f.js} +1 -1
  7. package/bin/chunk-0tvggyy4.js +1 -0
  8. package/bin/{chunk-zckxc8m6.js → chunk-113baw0m.js} +2 -2
  9. package/bin/{chunk-mneeg71d.js → chunk-1dbjyarc.js} +2 -2
  10. package/bin/{chunk-951r2rx1.js → chunk-1qre79kf.js} +1 -1
  11. package/bin/chunk-27v3yepb.js +1 -0
  12. package/bin/{chunk-5vqbzsjv.js → chunk-2rq3w8sg.js} +1 -1
  13. package/bin/{chunk-v034sfw8.js → chunk-3020am4q.js} +2 -2
  14. package/bin/{chunk-zdzkjp4q.js → chunk-3fjgf7eb.js} +2 -2
  15. package/bin/chunk-3pwwg1xm.js +1 -0
  16. package/bin/{chunk-19jpn3r6.js → chunk-3sfb63fp.js} +1 -1
  17. package/bin/{chunk-wwkhskce.js → chunk-3tg10kwz.js} +2 -2
  18. package/bin/{chunk-0y4zq3y4.js → chunk-4g4pxmef.js} +1 -1
  19. package/bin/{chunk-2pw7xcrn.js → chunk-4jj92zwa.js} +1 -1
  20. package/bin/{chunk-bpxw19ez.js → chunk-4yhvexzk.js} +1 -1
  21. package/bin/chunk-58cbk6e8.js +1 -0
  22. package/bin/{chunk-eqr0znmc.js → chunk-59t9s2jh.js} +1 -1
  23. package/bin/{chunk-n76w2wcr.js → chunk-5e7r7a9d.js} +1 -1
  24. package/bin/{chunk-8tzfcqtb.js → chunk-5m51b7af.js} +1 -1
  25. package/bin/{chunk-m6v8vt2b.js → chunk-65t6rm5d.js} +2 -2
  26. package/bin/chunk-6bed0rz4.js +1 -0
  27. package/bin/{chunk-1nvj833s.js → chunk-6smn0q1n.js} +5 -5
  28. package/bin/{chunk-r249n1xe.js → chunk-6zerk0em.js} +2 -2
  29. package/bin/{chunk-gvas3xkp.js → chunk-7bbsv8g0.js} +1 -1
  30. package/bin/chunk-83bdgs2c.js +1 -0
  31. package/bin/{chunk-93p27bbm.js → chunk-86qtjd30.js} +5 -5
  32. package/bin/{chunk-b5r0be06.js → chunk-8rekh4h9.js} +1 -1
  33. package/bin/{chunk-d2dgazjj.js → chunk-8s9fehda.js} +1 -1
  34. package/bin/{chunk-r776bhsg.js → chunk-8sf2hf31.js} +1 -1
  35. package/bin/{chunk-mn108p93.js → chunk-9d3w678j.js} +1 -1
  36. package/bin/{chunk-xr2v0d6y.js → chunk-9gftd4f7.js} +4 -4
  37. package/bin/{chunk-n9vp9nbg.js → chunk-9rcg8zgs.js} +32 -32
  38. package/bin/{chunk-6jkjx0n2.js → chunk-a23q1kc4.js} +3 -3
  39. package/bin/{chunk-81dawvn4.js → chunk-a6cdt85k.js} +2 -2
  40. package/bin/chunk-a76h3ehe.js +1 -0
  41. package/bin/{chunk-rmvhyqyb.js → chunk-b1bkd2p4.js} +8 -8
  42. package/bin/{chunk-wnqxyqrg.js → chunk-bf5m8f6t.js} +2 -2
  43. package/bin/chunk-cf57fk11.js +2 -0
  44. package/bin/{chunk-0v9srsdz.js → chunk-cv5xx81e.js} +1 -1
  45. package/bin/{chunk-3q5qkfkc.js → chunk-czybv3vy.js} +1 -1
  46. package/bin/{chunk-ggfx2b0f.js → chunk-d4sbcvpa.js} +1 -1
  47. package/bin/{chunk-9ggwc289.js → chunk-d6xezgrg.js} +1 -1
  48. package/bin/{chunk-bbcmhcvc.js → chunk-da86fpjt.js} +2 -2
  49. package/bin/chunk-dzjmwat0.js +14 -0
  50. package/bin/{chunk-rza95y4z.js → chunk-eex8sjfs.js} +2 -2
  51. package/bin/{chunk-9zgqjdx1.js → chunk-emgyjhmx.js} +2 -2
  52. package/bin/{chunk-k3prp6c6.js → chunk-exmwerag.js} +5 -5
  53. package/bin/{chunk-kzr6ecke.js → chunk-f38xyahm.js} +1 -1
  54. package/bin/{chunk-ffj9cq9y.js → chunk-fb1bes2h.js} +1 -1
  55. package/bin/chunk-fbvak7q2.js +1 -0
  56. package/bin/{chunk-15w79661.js → chunk-fg9sr6r9.js} +1 -1
  57. package/bin/{chunk-dppfek34.js → chunk-fyb6t7ct.js} +2 -2
  58. package/bin/chunk-g2ptqqm3.js +3 -0
  59. package/bin/{chunk-t1yamxgk.js → chunk-ggwqxn95.js} +1 -1
  60. package/bin/chunk-ghk54h71.js +13 -0
  61. package/bin/{chunk-kvwec0p3.js → chunk-h1fbev9c.js} +2 -2
  62. package/bin/{chunk-f5z3096k.js → chunk-h9akn41s.js} +2 -2
  63. package/bin/{chunk-asy868kq.js → chunk-hdansxny.js} +1 -1
  64. package/bin/{chunk-grjek810.js → chunk-hjwpd09v.js} +2 -2
  65. package/bin/{chunk-zf5cyxnt.js → chunk-hjzbw975.js} +1 -1
  66. package/bin/{chunk-jgfye6nf.js → chunk-j4p3eqtd.js} +1 -1
  67. package/bin/chunk-jtkxeat4.js +2 -0
  68. package/bin/{chunk-8zgq5sav.js → chunk-jw4g9628.js} +3 -3
  69. package/bin/{chunk-0ge2mm8j.js → chunk-jxebakyq.js} +1 -1
  70. package/bin/{chunk-0asthrjf.js → chunk-kfewyax2.js} +2 -2
  71. package/bin/chunk-kk3m4za5.js +1 -0
  72. package/bin/{chunk-vzdgsfkf.js → chunk-m7tnj47b.js} +1 -1
  73. package/bin/{chunk-w73v578p.js → chunk-maw5ah8t.js} +2 -2
  74. package/bin/{chunk-8ny7wvzb.js → chunk-n0wwtjwv.js} +1 -1
  75. package/bin/{chunk-e439kt05.js → chunk-nahdd2t9.js} +1 -1
  76. package/bin/{chunk-04avc4fn.js → chunk-nv7tztvh.js} +32 -32
  77. package/bin/{chunk-mn208vrv.js → chunk-nyjwdxyj.js} +2 -2
  78. package/bin/{chunk-qmrg2jhs.js → chunk-p0yfxt5e.js} +5 -5
  79. package/bin/{chunk-p0j4wpa5.js → chunk-q27qn367.js} +2 -2
  80. package/bin/{chunk-j53sjkxt.js → chunk-q36sdt2w.js} +1 -1
  81. package/bin/{chunk-vm2pz2hm.js → chunk-q7t5zs7n.js} +2 -2
  82. package/bin/{chunk-cpj562n6.js → chunk-qbj5pe8t.js} +1 -1
  83. package/bin/chunk-qj0bxb1m.js +2 -0
  84. package/bin/{chunk-9bakwac0.js → chunk-qk5hsn6e.js} +4 -4
  85. package/bin/{chunk-6rn094yj.js → chunk-qnyqtaf0.js} +1 -1
  86. package/bin/{chunk-ypkkfwfb.js → chunk-qqkr6h07.js} +2 -2
  87. package/bin/chunk-qyqc5j3a.css +1 -0
  88. package/bin/chunk-qzaf6bre.js +2 -0
  89. package/bin/{chunk-cx32wsa1.js → chunk-r1e59gf0.js} +1 -1
  90. package/bin/chunk-ra5csbkr.js +2 -0
  91. package/bin/{chunk-rtaya5wc.js → chunk-rh8dy99a.js} +2 -2
  92. package/bin/{chunk-ryepy5er.js → chunk-rx9g95wk.js} +4 -4
  93. package/bin/{chunk-2w6gve12.js → chunk-rxyy37wa.js} +3 -3
  94. package/bin/{chunk-7qvvf0yd.js → chunk-scez7ppq.js} +2 -2
  95. package/bin/{chunk-twpc640e.js → chunk-t2a1vq34.js} +1 -1
  96. package/bin/chunk-t879v3b7.js +1 -0
  97. package/bin/{chunk-a8bymrv1.js → chunk-tjavzarz.js} +2 -2
  98. package/bin/{chunk-ce0bhc72.js → chunk-treyx8em.js} +1 -1
  99. package/bin/{chunk-dche0gy0.js → chunk-v3z4z04s.js} +1 -1
  100. package/bin/{chunk-5bk16qdp.js → chunk-v3z63tpw.js} +2 -2
  101. package/bin/{chunk-5rzxekn4.js → chunk-v9bes1fv.js} +1 -1
  102. package/bin/{chunk-d5hbzp7t.js → chunk-vjyget8s.js} +1 -1
  103. package/bin/{chunk-4zksqvwj.js → chunk-vmm9m3nv.js} +2 -2
  104. package/bin/chunk-vvr8tnse.js +211 -0
  105. package/bin/{chunk-tvkekn4z.js → chunk-w3stry4v.js} +1 -1
  106. package/bin/{chunk-3pm6q6kg.js → chunk-w89czwjj.js} +1 -1
  107. package/bin/{chunk-rw5h0n0s.js → chunk-wk0hk00z.js} +1 -1
  108. package/bin/{chunk-15vsw36h.js → chunk-ww9qq8yq.js} +5 -5
  109. package/bin/chunk-x4q082e6.js +2 -0
  110. package/bin/{chunk-98mg3dpd.js → chunk-x6rf77jm.js} +4 -4
  111. package/bin/chunk-x7dyj53k.js +2 -0
  112. package/bin/{chunk-y2dhf3p0.js → chunk-xbw7ffrz.js} +2 -2
  113. package/bin/{chunk-5nqvqvqp.js → chunk-xcrd0y8v.js} +3 -3
  114. package/bin/{chunk-0j22699g.js → chunk-z0z0jn5h.js} +2 -2
  115. package/bin/{chunk-w9z27p0m.js → chunk-zasjhrwc.js} +1 -1
  116. package/bin/chunk-zefds5gg.js +1 -0
  117. package/bin/{chunk-8ayz61rc.js → chunk-zzzgk1d5.js} +3 -3
  118. package/bin/shumai-app.html +1 -1
  119. package/bin/shumai-app.js +390 -373
  120. package/package.json +8 -11
  121. package/prisma/migrations/20261014054332_add_embedding_768/migration.sql +8 -0
  122. package/prisma/schema.prisma +10 -8
  123. package/bin/chunk-2gf95tj0.js +0 -1
  124. package/bin/chunk-2tk5w3jc.js +0 -1
  125. package/bin/chunk-301e7g3z.js +0 -2
  126. package/bin/chunk-3kmjbc3m.js +0 -2
  127. package/bin/chunk-3td60k1m.js +0 -2
  128. package/bin/chunk-42hrvk6k.js +0 -211
  129. package/bin/chunk-8abhmarc.js +0 -2
  130. package/bin/chunk-965102pf.js +0 -3
  131. package/bin/chunk-acn3r2m2.js +0 -1
  132. package/bin/chunk-ce75dw3k.css +0 -1
  133. package/bin/chunk-d9qpgkek.js +0 -2
  134. package/bin/chunk-dv6p6n5e.js +0 -1
  135. package/bin/chunk-gnt9gewm.js +0 -2
  136. package/bin/chunk-k97axrc4.js +0 -13
  137. package/bin/chunk-qb178ntp.js +0 -2
  138. package/bin/chunk-s4r6e6ms.js +0 -1
  139. package/bin/chunk-syjjke3f.js +0 -1
  140. package/bin/chunk-tgfxe0sb.js +0 -1
  141. package/bin/chunk-tjretpx8.js +0 -1
  142. package/bin/chunk-w4yjgez6.js +0 -14
  143. package/bin/chunk-wjcebkpb.js +0 -1
  144. package/bin/chunk-ws71fg50.js +0 -2
  145. package/bin/chunk-yfp3q4da.js +0 -1
  146. package/bin/chunk-z8e4wc59.js +0 -1
@@ -1,2 +1,2 @@
1
- import{t,o,Rr,I,E}from"./chunk-42hrvk6k.js";var Lr=Rr((n,s)=>({isDrawing:!1,currentTool:"arrow",currentColor:"#ef4444",annotations:[],history:[[]],historyIndex:0,setIsDrawing:(r)=>n({isDrawing:r}),setTool:(r)=>n({currentTool:r}),setColor:(r)=>n({currentColor:r}),addAnnotation:(r)=>{let{annotations:a,history:e,historyIndex:m}=s(),c=[...a,r],d=e.slice(0,m+1);d.push(c),n({annotations:c,history:d,historyIndex:d.length-1})},setAnnotations:(r)=>{n({annotations:r,history:[r],historyIndex:0})},undo:()=>{let{historyIndex:r,history:a}=s();if(r>0){let e=r-1;n({annotations:a[e],historyIndex:e})}},redo:()=>{let{historyIndex:r,history:a}=s();if(r<a.length-1){let e=r+1;n({annotations:a[e],historyIndex:e})}},reset:()=>n({isDrawing:!1,currentTool:"arrow",annotations:[],history:[[]],historyIndex:0})}));var Ni=(n)=>{if(isNaN(n))return"00:00";let s=new Date(n*1000),r=s.getUTCHours(),a=s.getUTCMinutes().toString().padStart(2,"0"),e=s.getUTCSeconds().toString().padStart(2,"0");if(r)return`${r}:${a}:${e}`;return`${a}:${e}`},vn=(n,s,r,a)=>{if(r==="frames")return`${n} fr`;if(r==="standard")return Ni(n/s);let e=Math.round(s),m=s!==e,c=!1;if(m&&(e===30||e===60))c=!0;let d=0;if(a){let i=a.match(/^([012]\d):(\d\d):(\d\d)(:|;|\.)(\d+)$/);if(i){let f=parseInt(i[1],10),u=parseInt(i[2],10),M=parseInt(i[3],10),w=parseInt(i[5],10);if(c=i[4]!==":",d=(f*3600+u*60+M)*e+w,c){let h=f*60+u,S=s<30?2:4;d-=S*(h-Math.floor(h/10))}}}let l=n+d;if(c){let i=s<30?2:4,f=Math.floor(l/(17982*i/2)),u=l%(17982*i/2);if(u<i)u=u+i;l+=9*i*f+i*Math.floor((u-i)/(1798*i/2))}let p=l%e,g=Math.floor(l/e)%60,x=Math.floor(l/(e*60))%60,y=Math.floor(l/(e*3600))%24,b=c?";":":";return`${y.toString().padStart(2,"0")}:${x.toString().padStart(2,"0")}:${g.toString().padStart(2,"0")}${b}${p.toString().padStart(2,"0")}`};var Di=(n,s)=>{if(!s)return 0;let r=1/s;return n*r+r/2},yu=(n)=>Math.max(100,3000/(n||30)),bu=({dbTotalFrames:n,containerDuration:s,frameRate:r})=>{let a=r||30,e=Math.round(s*a);if(n<=0)return e;let m=n/a,c=s-m,d=yu(a)/1000;return c>d?e:n};var T=[["path",{d:"M5 12h14",key:"1ays0h"}]],To=I("minus",T);var ma=({progress:n,className:s})=>{let a=2*Math.PI*20,e=a-Math.min(100,Math.max(0,n))/100*a;return o("svg",{viewBox:"0 0 50 50",className:E("w-12 h-12",s),children:[t("circle",{cx:"25",cy:"25",r:20,className:"stroke-muted",strokeWidth:"4",fill:"transparent"}),t("circle",{cx:"25",cy:"25",r:20,className:"stroke-primary transition-all duration-300 ease-out",strokeWidth:"4",fill:"transparent",strokeDasharray:a,strokeDashoffset:e,transform:"rotate(-90 25 25)"}),t("text",{x:"50%",y:"50%",textAnchor:"middle",dy:".3em",className:"fill-foreground text-[10px] font-bold",children:`${Math.round(n)}%`})]})};
2
- export{To,Ni,vn,Di,yu,bu,Lr,ma};
1
+ import{t,o,Rr,I,E}from"./chunk-vvr8tnse.js";var Lr=Rr((n,s)=>({isDrawing:!1,currentTool:"arrow",currentColor:"#ef4444",annotations:[],history:[[]],historyIndex:0,setIsDrawing:(r)=>n({isDrawing:r}),setTool:(r)=>n({currentTool:r}),setColor:(r)=>n({currentColor:r}),addAnnotation:(r)=>{let{annotations:a,history:e,historyIndex:m}=s(),c=[...a,r],d=e.slice(0,m+1);d.push(c),n({annotations:c,history:d,historyIndex:d.length-1})},setAnnotations:(r)=>{n({annotations:r,history:[r],historyIndex:0})},undo:()=>{let{historyIndex:r,history:a}=s();if(r>0){let e=r-1;n({annotations:a[e],historyIndex:e})}},redo:()=>{let{historyIndex:r,history:a}=s();if(r<a.length-1){let e=r+1;n({annotations:a[e],historyIndex:e})}},reset:()=>n({isDrawing:!1,currentTool:"arrow",annotations:[],history:[[]],historyIndex:0})}));var Is=(n)=>{if(isNaN(n))return"00:00";let s=new Date(n*1000),r=s.getUTCHours(),a=s.getUTCMinutes().toString().padStart(2,"0"),e=s.getUTCSeconds().toString().padStart(2,"0");if(r)return`${r}:${a}:${e}`;return`${a}:${e}`},vn=(n,s,r,a)=>{if(r==="frames")return`${n} fr`;if(r==="standard")return Is(n/s);let e=Math.round(s),m=s!==e,c=!1;if(m&&(e===30||e===60))c=!0;let d=0;if(a){let i=a.match(/^([012]\d):(\d\d):(\d\d)(:|;|\.)(\d+)$/);if(i){let f=parseInt(i[1],10),u=parseInt(i[2],10),M=parseInt(i[3],10),w=parseInt(i[5],10);if(c=i[4]!==":",d=(f*3600+u*60+M)*e+w,c){let h=f*60+u,S=s<30?2:4;d-=S*(h-Math.floor(h/10))}}}let l=n+d;if(c){let i=s<30?2:4,f=Math.floor(l/(17982*i/2)),u=l%(17982*i/2);if(u<i)u=u+i;l+=9*i*f+i*Math.floor((u-i)/(1798*i/2))}let p=l%e,g=Math.floor(l/e)%60,x=Math.floor(l/(e*60))%60,y=Math.floor(l/(e*3600))%24,b=c?";":":";return`${y.toString().padStart(2,"0")}:${x.toString().padStart(2,"0")}:${g.toString().padStart(2,"0")}${b}${p.toString().padStart(2,"0")}`};var Di=(n,s)=>{if(!s)return 0;let r=1/s;return n*r+r/2},yu=(n)=>Math.max(100,3000/(n||30)),bu=({dbTotalFrames:n,containerDuration:s,frameRate:r})=>{let a=r||30,e=Math.round(s*a);if(n<=0)return e;let m=n/a,c=s-m,d=yu(a)/1000;return c>d?e:n};var T=[["path",{d:"M5 12h14",key:"1ays0h"}]],To=I("minus",T);var ma=({progress:n,className:s})=>{let a=2*Math.PI*20,e=a-Math.min(100,Math.max(0,n))/100*a;return o("svg",{viewBox:"0 0 50 50",className:E("w-12 h-12",s),children:[t("circle",{cx:"25",cy:"25",r:20,className:"stroke-muted",strokeWidth:"4",fill:"transparent"}),t("circle",{cx:"25",cy:"25",r:20,className:"stroke-primary transition-all duration-300 ease-out",strokeWidth:"4",fill:"transparent",strokeDasharray:a,strokeDashoffset:e,transform:"rotate(-90 25 25)"}),t("text",{x:"50%",y:"50%",textAnchor:"middle",dy:".3em",className:"fill-foreground text-[10px] font-bold",children:`${Math.round(n)}%`})]})};
2
+ export{To,Is,vn,Di,yu,bu,Lr,ma};
@@ -0,0 +1,2 @@
1
+ import{I}from"./chunk-vvr8tnse.js";var o=[["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}],["path",{d:"M11 12h4",key:"q8tih4"}],["path",{d:"M11 16h7",key:"uosisv"}],["path",{d:"M11 20h10",key:"jvxblo"}]],Hl=I("arrow-up-narrow-wide",o);
2
+ export{Hl};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Aa,rc,_a,nc,oc,sc,ic,ac}from"./chunk-98mg3dpd.js";import{xn,Sn}from"./chunk-sbyyn9yw.js";import{He,Tr}from"./chunk-dppfek34.js";import{qi}from"./chunk-zdzkjp4q.js";import{hn,Gr}from"./chunk-ae6zgjhd.js";import{Jt}from"./chunk-vm2pz2hm.js";var w=0,m=(e,a,n)=>{let i=new Jt;return(async()=>{let t={role:"assistant",content:[],api:"google-generative-ai",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 l=n?.apiKey;if(!l)throw Error(`No API key for provider: ${e.provider}`);let s=M(e,l,n?.headers),g=T(e,a,n),h=await n?.onPayload?.(g,e);if(h!==void 0)g=h;let b=await s.models.generateContentStream(g);i.push({type:"start",partial:t});let o=null,C=t.content,u=()=>C.length-1;for await(let c of b){t.responseId||=c.responseId;let p=c.candidates?.[0];if(p?.content?.parts)for(let r of p.content.parts){if(r.text!==void 0){let d=rc(r);if(!o||d&&o.type!=="thinking"||!d&&o.type!=="text"){if(o)if(o.type==="text")i.push({type:"text_end",contentIndex:C.length-1,content:o.text,partial:t});else i.push({type:"thinking_end",contentIndex:u(),content:o.thinking,partial:t});if(d)o={type:"thinking",thinking:"",thinkingSignature:void 0},t.content.push(o),i.push({type:"thinking_start",contentIndex:u(),partial:t});else o={type:"text",text:""},t.content.push(o),i.push({type:"text_start",contentIndex:u(),partial:t})}if(o.type==="thinking")o.thinking+=r.text,o.thinkingSignature=_a(o.thinkingSignature,r.thoughtSignature),i.push({type:"thinking_delta",contentIndex:u(),delta:r.text,partial:t});else o.text+=r.text,o.textSignature=_a(o.textSignature,r.thoughtSignature),i.push({type:"text_delta",contentIndex:u(),delta:r.text,partial:t})}if(r.functionCall){if(o){if(o.type==="text")i.push({type:"text_end",contentIndex:u(),content:o.text,partial:t});else i.push({type:"thinking_end",contentIndex:u(),content:o.thinking,partial:t});o=null}let d=r.functionCall.id,f={type:"toolCall",id:!d||t.content.some((I)=>I.type==="toolCall"&&I.id===d)?`${r.functionCall.name}_${Date.now()}_${++w}`:d,name:r.functionCall.name||"",arguments:r.functionCall.args??{},...r.thoughtSignature&&{thoughtSignature:r.thoughtSignature}};t.content.push(f),i.push({type:"toolcall_start",contentIndex:u(),partial:t}),i.push({type:"toolcall_delta",contentIndex:u(),delta:JSON.stringify(f.arguments),partial:t}),i.push({type:"toolcall_end",contentIndex:u(),toolCall:f,partial:t})}}if(p?.finishReason){if(t.stopReason=ac(p.finishReason),t.content.some((r)=>r.type==="toolCall"))t.stopReason="toolUse"}if(c.usageMetadata)t.usage={input:(c.usageMetadata.promptTokenCount||0)-(c.usageMetadata.cachedContentTokenCount||0),output:(c.usageMetadata.candidatesTokenCount||0)+(c.usageMetadata.thoughtsTokenCount||0),cacheRead:c.usageMetadata.cachedContentTokenCount||0,cacheWrite:0,reasoning:c.usageMetadata.thoughtsTokenCount||0,totalTokens:c.usageMetadata.totalTokenCount||0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},hn(e,t.usage)}if(o)if(o.type==="text")i.push({type:"text_end",contentIndex:u(),content:o.text,partial:t});else i.push({type:"thinking_end",contentIndex:u(),content:o.thinking,partial:t});if(n?.signal?.aborted)throw Error("Request was aborted");if(t.stopReason==="aborted"||t.stopReason==="error")throw Error("An unknown error occurred");i.push({type:"done",reason:t.stopReason,message:t}),i.end()}catch(l){for(let s of t.content)if("index"in s)delete s.index;t.stopReason=n?.signal?.aborted?"aborted":"error",t.errorMessage=Sn(xn(l)),i.push({type:"error",reason:t.stopReason,error:t}),i.end()}})(),i},B=(e,a,n)=>{let i=n?.apiKey;if(!i)throw Error(`No API key for provider: ${e.provider}`);let t=Tr(e,a,n,i);if(!n?.reasoning)return m(e,a,{...t,thinking:{enabled:!1}});let l=Gr(e,n.reasoning),s=l==="off"?"high":l,g=e;if(y(g)||x(g)||k(g))return m(e,a,{...t,thinking:{enabled:!0,level:S(s,g)}});return m(e,a,{...t,thinking:{enabled:!0,budgetTokens:R(g,s,n.thinkingBudgets)}})};function M(e,a,n){let i={};if(e.baseUrl)i.baseUrl=e.baseUrl,i.apiVersion="";let t=qi({...e.headers,...n});if(t)i.headers=t;return new Aa({apiKey:a,httpOptions:Object.keys(i).length>0?i:void 0})}function T(e,a,n={}){let i=nc(e,a),t={};if(n.temperature!==void 0)t.temperature=n.temperature;if(n.maxTokens!==void 0)t.maxOutputTokens=n.maxTokens;let l=a.tools?.length?ic(a.tools,n.toolChoice,sc(e.id)):void 0,s={...Object.keys(t).length>0&&t,...a.systemPrompt&&{systemInstruction:He(a.systemPrompt)},...a.tools&&a.tools.length>0&&{tools:oc(a.tools)},...l!==void 0&&{toolConfig:{functionCallingConfig:{mode:l}}}};if(n.thinking?.enabled&&e.reasoning){let h={includeThoughts:!0};if(n.thinking.level!==void 0)h.thinkingLevel=n.thinking.level;else if(n.thinking.budgetTokens!==void 0)h.thinkingBudget=n.thinking.budgetTokens;s.thinkingConfig=h}else if(e.reasoning&&n.thinking&&!n.thinking.enabled)s.thinkingConfig=v(e);if(n.signal){if(n.signal.aborted)throw Error("Request aborted");s.abortSignal=n.signal}return{model:e.id,contents:i,config:s}}function k(e){return/gemma-?4/.test(e.id.toLowerCase())}function y(e){return/gemini-3(?:\.\d+)?-pro/.test(e.id.toLowerCase())}function x(e){let a=e.id.toLowerCase();return/gemini-3(?:\.\d+)?-flash/.test(a)||a==="gemini-flash-latest"||a==="gemini-flash-lite-latest"}function v(e){if(y(e))return{thinkingLevel:"LOW"};if(x(e))return{thinkingLevel:"MINIMAL"};if(k(e))return{thinkingLevel:"MINIMAL"};return{thinkingBudget:0}}function S(e,a){if(y(a))switch(e){case"minimal":case"low":return"LOW";case"medium":case"high":return"HIGH"}if(k(a))switch(e){case"minimal":case"low":return"MINIMAL";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 R(e,a,n){if(n?.[a]!==void 0)return n[a];if(e.id.includes("2.5-pro"))return{minimal:128,low:2048,medium:8192,high:32768}[a];if(e.id.includes("2.5-flash-lite"))return{minimal:512,low:2048,medium:8192,high:24576}[a];if(e.id.includes("2.5-flash"))return{minimal:128,low:2048,medium:8192,high:24576}[a];return-1}export{m as stream,B as streamSimple};
2
+ import{Aa,sc,_a,ic,ac,lc,cc,uc}from"./chunk-x6rf77jm.js";import{xn,Sn}from"./chunk-sbyyn9yw.js";import{He,Tr}from"./chunk-fyb6t7ct.js";import{qi}from"./chunk-3fjgf7eb.js";import{mn,Gr}from"./chunk-047n9gfs.js";import{Jt}from"./chunk-q7t5zs7n.js";var w=0,m=(e,a,n)=>{let i=new Jt;return(async()=>{let t={role:"assistant",content:[],api:"google-generative-ai",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 l=n?.apiKey;if(!l)throw Error(`No API key for provider: ${e.provider}`);let s=M(e,l,n?.headers),g=T(e,a,n),h=await n?.onPayload?.(g,e);if(h!==void 0)g=h;let b=await s.models.generateContentStream(g);i.push({type:"start",partial:t});let o=null,C=t.content,u=()=>C.length-1;for await(let c of b){t.responseId||=c.responseId;let p=c.candidates?.[0];if(p?.content?.parts)for(let r of p.content.parts){if(r.text!==void 0){let d=sc(r);if(!o||d&&o.type!=="thinking"||!d&&o.type!=="text"){if(o)if(o.type==="text")i.push({type:"text_end",contentIndex:C.length-1,content:o.text,partial:t});else i.push({type:"thinking_end",contentIndex:u(),content:o.thinking,partial:t});if(d)o={type:"thinking",thinking:"",thinkingSignature:void 0},t.content.push(o),i.push({type:"thinking_start",contentIndex:u(),partial:t});else o={type:"text",text:""},t.content.push(o),i.push({type:"text_start",contentIndex:u(),partial:t})}if(o.type==="thinking")o.thinking+=r.text,o.thinkingSignature=_a(o.thinkingSignature,r.thoughtSignature),i.push({type:"thinking_delta",contentIndex:u(),delta:r.text,partial:t});else o.text+=r.text,o.textSignature=_a(o.textSignature,r.thoughtSignature),i.push({type:"text_delta",contentIndex:u(),delta:r.text,partial:t})}if(r.functionCall){if(o){if(o.type==="text")i.push({type:"text_end",contentIndex:u(),content:o.text,partial:t});else i.push({type:"thinking_end",contentIndex:u(),content:o.thinking,partial:t});o=null}let d=r.functionCall.id,f={type:"toolCall",id:!d||t.content.some((I)=>I.type==="toolCall"&&I.id===d)?`${r.functionCall.name}_${Date.now()}_${++w}`:d,name:r.functionCall.name||"",arguments:r.functionCall.args??{},...r.thoughtSignature&&{thoughtSignature:r.thoughtSignature}};t.content.push(f),i.push({type:"toolcall_start",contentIndex:u(),partial:t}),i.push({type:"toolcall_delta",contentIndex:u(),delta:JSON.stringify(f.arguments),partial:t}),i.push({type:"toolcall_end",contentIndex:u(),toolCall:f,partial:t})}}if(p?.finishReason){if(t.stopReason=uc(p.finishReason),t.content.some((r)=>r.type==="toolCall"))t.stopReason="toolUse"}if(c.usageMetadata)t.usage={input:(c.usageMetadata.promptTokenCount||0)-(c.usageMetadata.cachedContentTokenCount||0),output:(c.usageMetadata.candidatesTokenCount||0)+(c.usageMetadata.thoughtsTokenCount||0),cacheRead:c.usageMetadata.cachedContentTokenCount||0,cacheWrite:0,reasoning:c.usageMetadata.thoughtsTokenCount||0,totalTokens:c.usageMetadata.totalTokenCount||0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},mn(e,t.usage)}if(o)if(o.type==="text")i.push({type:"text_end",contentIndex:u(),content:o.text,partial:t});else i.push({type:"thinking_end",contentIndex:u(),content:o.thinking,partial:t});if(n?.signal?.aborted)throw Error("Request was aborted");if(t.stopReason==="aborted"||t.stopReason==="error")throw Error("An unknown error occurred");i.push({type:"done",reason:t.stopReason,message:t}),i.end()}catch(l){for(let s of t.content)if("index"in s)delete s.index;t.stopReason=n?.signal?.aborted?"aborted":"error",t.errorMessage=Sn(xn(l)),i.push({type:"error",reason:t.stopReason,error:t}),i.end()}})(),i},B=(e,a,n)=>{let i=n?.apiKey;if(!i)throw Error(`No API key for provider: ${e.provider}`);let t=Tr(e,a,n,i);if(!n?.reasoning)return m(e,a,{...t,thinking:{enabled:!1}});let l=Gr(e,n.reasoning),s=l==="off"?"high":l,g=e;if(y(g)||x(g)||k(g))return m(e,a,{...t,thinking:{enabled:!0,level:S(s,g)}});return m(e,a,{...t,thinking:{enabled:!0,budgetTokens:R(g,s,n.thinkingBudgets)}})};function M(e,a,n){let i={};if(e.baseUrl)i.baseUrl=e.baseUrl,i.apiVersion="";let t=qi({...e.headers,...n});if(t)i.headers=t;return new Aa({apiKey:a,httpOptions:Object.keys(i).length>0?i:void 0})}function T(e,a,n={}){let i=ic(e,a),t={};if(n.temperature!==void 0)t.temperature=n.temperature;if(n.maxTokens!==void 0)t.maxOutputTokens=n.maxTokens;let l=a.tools?.length?cc(a.tools,n.toolChoice,lc(e.id)):void 0,s={...Object.keys(t).length>0&&t,...a.systemPrompt&&{systemInstruction:He(a.systemPrompt)},...a.tools&&a.tools.length>0&&{tools:ac(a.tools)},...l!==void 0&&{toolConfig:{functionCallingConfig:{mode:l}}}};if(n.thinking?.enabled&&e.reasoning){let h={includeThoughts:!0};if(n.thinking.level!==void 0)h.thinkingLevel=n.thinking.level;else if(n.thinking.budgetTokens!==void 0)h.thinkingBudget=n.thinking.budgetTokens;s.thinkingConfig=h}else if(e.reasoning&&n.thinking&&!n.thinking.enabled)s.thinkingConfig=v(e);if(n.signal){if(n.signal.aborted)throw Error("Request aborted");s.abortSignal=n.signal}return{model:e.id,contents:i,config:s}}function k(e){return/gemma-?4/.test(e.id.toLowerCase())}function y(e){return/gemini-3(?:\.\d+)?-pro/.test(e.id.toLowerCase())}function x(e){let a=e.id.toLowerCase();return/gemini-3(?:\.\d+)?-flash/.test(a)||a==="gemini-flash-latest"||a==="gemini-flash-lite-latest"}function v(e){if(y(e))return{thinkingLevel:"LOW"};if(x(e))return{thinkingLevel:"MINIMAL"};if(k(e))return{thinkingLevel:"MINIMAL"};return{thinkingBudget:0}}function S(e,a){if(y(a))switch(e){case"minimal":case"low":return"LOW";case"medium":case"high":return"HIGH"}if(k(a))switch(e){case"minimal":case"low":return"MINIMAL";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 R(e,a,n){if(n?.[a]!==void 0)return n[a];if(e.id.includes("2.5-pro"))return{minimal:128,low:2048,medium:8192,high:32768}[a];if(e.id.includes("2.5-flash-lite"))return{minimal:512,low:2048,medium:8192,high:24576}[a];if(e.id.includes("2.5-flash"))return{minimal:128,low:2048,medium:8192,high:24576}[a];return-1}export{m as stream,B as streamSimple};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{xu}from"./chunk-cdk8vqeg.js";import{dr}from"./chunk-b5r0be06.js";import"./chunk-8zgq5sav.js";import{ti,ri,ni}from"./chunk-15vsw36h.js";import{as}from"./chunk-23780yj6.js";import{xn,Sn}from"./chunk-sbyyn9yw.js";import{ls}from"./chunk-6hzktewz.js";import{Wn,Tr}from"./chunk-dppfek34.js";import{mn}from"./chunk-zdzkjp4q.js";import{Gr}from"./chunk-ae6zgjhd.js";import{Jt}from"./chunk-vm2pz2hm.js";var d="v1",A=new Set(["openai","openai-codex","opencode","azure-openai-responses"]),E=16;function R(r){let a=new Map;if(!r)return a;for(let e of r.split(",")){let n=e.trim();if(!n)continue;let[s,t]=n.split("=",2);if(!s||!t)continue;a.set(s.trim(),t.trim())}return a}function h(r,a){if(a?.azureDeploymentName)return a.azureDeploymentName;return R(dr("AZURE_OPENAI_DEPLOYMENT_NAME_MAP",a?.env)).get(r.id)||r.id}function g(r){return Sn(xn(r),"Azure OpenAI API error")}var y=(r,a,e)=>{let n=new Jt;return(async()=>{let s=h(r,e),t={role:"assistant",content:[],api:"azure-openai-responses",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 o=e?.apiKey;if(!o)throw Error(`No API key for provider: ${r.provider}`);let i=O(r,o,e),m=Wn(a.tools,r.compat?.supportsOpenAIGrammarTools??!1),p=U(r,a,e,s,m),u=await e?.onPayload?.(p,r);if(u!==void 0)p=u;let f={...e?.signal?{signal:e.signal}:{},...e?.timeoutMs!==void 0?{timeout:e.timeoutMs}:{},maxRetries:0},{data:l,response:c}=await ls(()=>i.responses.create(p,f).withResponse(),{maxRetries:e?.maxRetries,maxRetryDelayMs:e?.maxRetryDelayMs,signal:e?.signal});if(await e?.onResponse?.({status:c.status,headers:mn(c.headers)},r),n.push({type:"start",partial:t}),await ni(l,t,n,r,{grammarToolInputProperties:m}),e?.signal?.aborted)throw Error("Request was aborted");if(t.stopReason==="aborted"||t.stopReason==="error")throw Error("An unknown error occurred");n.push({type:"done",reason:t.stopReason,message:t}),n.end()}catch(o){for(let i of t.content)delete i.index,delete i.partialJson,delete i.customInput;t.stopReason=e?.signal?.aborted?"aborted":"error",t.errorMessage=g(o),n.push({type:"error",reason:t.stopReason,error:t}),n.end()}})(),n},B=(r,a,e)=>{let n=e?.apiKey;if(!n)throw Error(`No API key for provider: ${r.provider}`);let s=Tr(r,a,e,n),t=e?.reasoning?Gr(r,e.reasoning):void 0;return y(r,a,{...s,reasoningEffort:t==="off"?void 0:t})};function _(r){let a=r.trim().replace(/\/+$/,""),e;try{e=new URL(a)}catch{throw Error(`Invalid Azure OpenAI base URL: ${r}`)}let n=e.hostname.endsWith(".openai.azure.com")||e.hostname.endsWith(".cognitiveservices.azure.com")||e.hostname.endsWith(".ai.azure.com"),s=e.pathname.replace(/\/+$/,"");if(n&&(s===""||s==="/"||s==="/openai"||s==="/openai/v1/responses"))e.pathname="/openai/v1",e.search="";return e.toString().replace(/\/+$/,"")}function I(r){return`https://${r}.openai.azure.com/openai/v1`}function v(r,a){let e=a?.azureApiVersion||dr("AZURE_OPENAI_API_VERSION",a?.env)||d,n=a?.azureBaseUrl?.trim()||dr("AZURE_OPENAI_BASE_URL",a?.env)?.trim()||void 0,s=a?.azureResourceName||dr("AZURE_OPENAI_RESOURCE_NAME",a?.env),t=n;if(!t&&s)t=I(s);if(!t&&r.baseUrl)t=r.baseUrl;if(!t)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:_(t),apiVersion:e}}function O(r,a,e){let n={...r.headers};if(e?.headers)Object.assign(n,e.headers);let{baseUrl:s,apiVersion:t}=v(r,e);return new xu({apiKey:a,apiVersion:t,dangerouslyAllowBrowser:!0,defaultHeaders:n,baseURL:s})}function U(r,a,e,n,s=Wn(a.tools,r.compat?.supportsOpenAIGrammarTools??!1)){let t=ti(r,a,A,{grammarToolInputProperties:s}),o={model:n,input:t,stream:!0,prompt_cache_key:as(e?.sessionId),store:!1};if(e?.maxTokens)o.max_output_tokens=Math.max(e.maxTokens,E);if(e?.temperature!==void 0)o.temperature=e?.temperature;if(a.tools&&a.tools.length>0)o.tools=ri(a.tools,{supportsStrictMode:r.compat?.supportsStrictMode??!0,supportsOpenAIGrammarTools:r.compat?.supportsOpenAIGrammarTools??!1});if(r.reasoning){if(e?.reasoningEffort||e?.reasoningSummary){let i=e?.reasoningEffort?r.thinkingLevelMap?.[e.reasoningEffort]??e.reasoningEffort:"medium";o.reasoning={effort:i,summary:e?.reasoningSummary||"auto"},o.include=["reasoning.encrypted_content"]}else if(r.thinkingLevelMap?.off!==null)o.reasoning={effort:r.thinkingLevelMap?.off??"none"}}return o}export{y as stream,B as streamSimple};
2
+ import{xu}from"./chunk-cdk8vqeg.js";import{dr}from"./chunk-8rekh4h9.js";import"./chunk-jw4g9628.js";import{ri,ni,oi}from"./chunk-ww9qq8yq.js";import{as}from"./chunk-23780yj6.js";import{xn,Sn}from"./chunk-sbyyn9yw.js";import{ls}from"./chunk-6hzktewz.js";import{Wn,Tr}from"./chunk-fyb6t7ct.js";import{pn}from"./chunk-3fjgf7eb.js";import{Gr}from"./chunk-047n9gfs.js";import{Jt}from"./chunk-q7t5zs7n.js";var d="v1",A=new Set(["openai","openai-codex","opencode","azure-openai-responses"]),E=16;function R(r){let a=new Map;if(!r)return a;for(let e of r.split(",")){let n=e.trim();if(!n)continue;let[s,t]=n.split("=",2);if(!s||!t)continue;a.set(s.trim(),t.trim())}return a}function h(r,a){if(a?.azureDeploymentName)return a.azureDeploymentName;return R(dr("AZURE_OPENAI_DEPLOYMENT_NAME_MAP",a?.env)).get(r.id)||r.id}function g(r){return Sn(xn(r),"Azure OpenAI API error")}var y=(r,a,e)=>{let n=new Jt;return(async()=>{let s=h(r,e),t={role:"assistant",content:[],api:"azure-openai-responses",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 o=e?.apiKey;if(!o)throw Error(`No API key for provider: ${r.provider}`);let i=O(r,o,e),m=Wn(a.tools,r.compat?.supportsOpenAIGrammarTools??!1),p=U(r,a,e,s,m),u=await e?.onPayload?.(p,r);if(u!==void 0)p=u;let f={...e?.signal?{signal:e.signal}:{},...e?.timeoutMs!==void 0?{timeout:e.timeoutMs}:{},maxRetries:0},{data:l,response:c}=await ls(()=>i.responses.create(p,f).withResponse(),{maxRetries:e?.maxRetries,maxRetryDelayMs:e?.maxRetryDelayMs,signal:e?.signal});if(await e?.onResponse?.({status:c.status,headers:pn(c.headers)},r),n.push({type:"start",partial:t}),await oi(l,t,n,r,{grammarToolInputProperties:m}),e?.signal?.aborted)throw Error("Request was aborted");if(t.stopReason==="aborted"||t.stopReason==="error")throw Error("An unknown error occurred");n.push({type:"done",reason:t.stopReason,message:t}),n.end()}catch(o){for(let i of t.content)delete i.index,delete i.partialJson,delete i.customInput;t.stopReason=e?.signal?.aborted?"aborted":"error",t.errorMessage=g(o),n.push({type:"error",reason:t.stopReason,error:t}),n.end()}})(),n},B=(r,a,e)=>{let n=e?.apiKey;if(!n)throw Error(`No API key for provider: ${r.provider}`);let s=Tr(r,a,e,n),t=e?.reasoning?Gr(r,e.reasoning):void 0;return y(r,a,{...s,reasoningEffort:t==="off"?void 0:t})};function _(r){let a=r.trim().replace(/\/+$/,""),e;try{e=new URL(a)}catch{throw Error(`Invalid Azure OpenAI base URL: ${r}`)}let n=e.hostname.endsWith(".openai.azure.com")||e.hostname.endsWith(".cognitiveservices.azure.com")||e.hostname.endsWith(".ai.azure.com"),s=e.pathname.replace(/\/+$/,"");if(n&&(s===""||s==="/"||s==="/openai"||s==="/openai/v1/responses"))e.pathname="/openai/v1",e.search="";return e.toString().replace(/\/+$/,"")}function I(r){return`https://${r}.openai.azure.com/openai/v1`}function v(r,a){let e=a?.azureApiVersion||dr("AZURE_OPENAI_API_VERSION",a?.env)||d,n=a?.azureBaseUrl?.trim()||dr("AZURE_OPENAI_BASE_URL",a?.env)?.trim()||void 0,s=a?.azureResourceName||dr("AZURE_OPENAI_RESOURCE_NAME",a?.env),t=n;if(!t&&s)t=I(s);if(!t&&r.baseUrl)t=r.baseUrl;if(!t)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:_(t),apiVersion:e}}function O(r,a,e){let n={...r.headers};if(e?.headers)Object.assign(n,e.headers);let{baseUrl:s,apiVersion:t}=v(r,e);return new xu({apiKey:a,apiVersion:t,dangerouslyAllowBrowser:!0,defaultHeaders:n,baseURL:s})}function U(r,a,e,n,s=Wn(a.tools,r.compat?.supportsOpenAIGrammarTools??!1)){let t=ri(r,a,A,{grammarToolInputProperties:s}),o={model:n,input:t,stream:!0,prompt_cache_key:as(e?.sessionId),store:!1};if(e?.maxTokens)o.max_output_tokens=Math.max(e.maxTokens,E);if(e?.temperature!==void 0)o.temperature=e?.temperature;if(a.tools&&a.tools.length>0)o.tools=ni(a.tools,{supportsStrictMode:r.compat?.supportsStrictMode??!0,supportsOpenAIGrammarTools:r.compat?.supportsOpenAIGrammarTools??!1});if(r.reasoning){if(e?.reasoningEffort||e?.reasoningSummary){let i=e?.reasoningEffort?r.thinkingLevelMap?.[e.reasoningEffort]??e.reasoningEffort:"medium";o.reasoning={effort:i,summary:e?.reasoningSummary||"auto"},o.include=["reasoning.encrypted_content"]}else if(r.thinkingLevelMap?.off!==null)o.reasoning={effort:r.thinkingLevelMap?.off??"none"}}return o}export{y as stream,B as streamSimple};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Dt}from"./chunk-ypkkfwfb.js";import{Ge}from"./chunk-k3prp6c6.js";import{H}from"./chunk-a8bymrv1.js";var f=H(Ge());var N=H(Ge());var m=H(Dt()),l=H(Ge());var E=H(Dt()),d=H(Ge()),P=(e,t,r)=>{let o={EcsContainer:async(s)=>{let{fromHttp:i}=await import("./chunk-twpc640e.js"),{fromContainerMetadata:n}=await import("./chunk-vzdgsfkf.js");return r?.debug("@aws-sdk/credential-provider-ini - credential_source is EcsContainer"),async()=>d.chain(i(s??{}),n(s))().then(_)},Ec2InstanceMetadata:async(s)=>{r?.debug("@aws-sdk/credential-provider-ini - credential_source is Ec2InstanceMetadata");let{fromInstanceMetadata:i}=await import("./chunk-vzdgsfkf.js");return async()=>i(s)().then(_)},Environment:async(s)=>{r?.debug("@aws-sdk/credential-provider-ini - credential_source is Environment");let{fromEnv:i}=await import("./chunk-ws71fg50.js");return async()=>i(s)().then(_)}};if(e in o)return o[e];else throw new d.CredentialsProviderError(`Unsupported credential source in profile ${t}. Got ${e}, expected EcsContainer or Ec2InstanceMetadata or Environment.`,{logger:r})},_=(e)=>E.setCredentialFeature(e,"CREDENTIALS_PROFILE_NAMED_PROVIDER","p");var v=(e,{profile:t="default",logger:r}={})=>Boolean(e)&&typeof e==="object"&&typeof e.role_arn==="string"&&["undefined","string"].indexOf(typeof e.role_session_name)>-1&&["undefined","string"].indexOf(typeof e.external_id)>-1&&["undefined","string"].indexOf(typeof e.mfa_serial)>-1&&(K(e,{profile:t,logger:r})||G(e,{profile:t,logger:r})),K=(e,{profile:t,logger:r})=>{let o=typeof e.source_profile==="string"&&typeof e.credential_source>"u";if(o)r?.debug?.(` ${t} isAssumeRoleWithSourceProfile source_profile=${e.source_profile}`);return o},G=(e,{profile:t,logger:r})=>{let o=typeof e.credential_source==="string"&&typeof e.source_profile>"u";if(o)r?.debug?.(` ${t} isCredentialSourceProfile credential_source=${e.credential_source}`);return o},I=async(e,t,r,o,s={},i)=>{r.logger?.debug("@aws-sdk/credential-provider-ini - resolveAssumeRoleCredentials (STS)");let n=t[e],{source_profile:a,region:j}=n;if(!r.roleAssumer){let{getDefaultRoleAssumer:c}=await import("./chunk-eqr0znmc.js");r.roleAssumer=c({...r.clientConfig,credentialProviderLogger:r.logger,parentClientConfig:{...o,...r?.parentClientConfig,region:j??r?.parentClientConfig?.region??o?.region}},r.clientPlugins)}if(a&&a in s)throw new l.CredentialsProviderError(`Detected a cycle attempting to resolve credentials for profile ${l.getProfileName(r)}. Profiles visited: `+Object.keys(s).join(", "),{logger:r.logger});r.logger?.debug(`@aws-sdk/credential-provider-ini - finding credential resolver using ${a?`source_profile=[${a}]`:`profile=[${e}]`}`);let w=a?i(a,t,r,o,{...s,[a]:!0},S(t[a]??{})):(await P(n.credential_source,e,r.logger)(r))();if(S(n))return w.then((c)=>m.setCredentialFeature(c,"CREDENTIALS_PROFILE_SOURCE_PROFILE","o"));else{let c={RoleArn:n.role_arn,RoleSessionName:n.role_session_name||`aws-sdk-js-${Date.now()}`,ExternalId:n.external_id,DurationSeconds:parseInt(n.duration_seconds||"3600",10)},{mfa_serial:u}=n;if(u){if(!r.mfaCodeProvider)throw new l.CredentialsProviderError(`Profile ${e} requires multi-factor authentication, but no MFA code callback was provided.`,{logger:r.logger,tryNextLink:!1});c.SerialNumber=u,c.TokenCode=await r.mfaCodeProvider(u)}let M=await w;return r.roleAssumer(M,c).then((B)=>m.setCredentialFeature(B,"CREDENTIALS_PROFILE_SOURCE_PROFILE","o"))}},S=(e)=>!e.role_arn&&!!e.credential_source;var R=H(Dt()),A=(e)=>Boolean(e&&e.login_session),L=async(e,t,r)=>{let{fromLoginCredentials:o}=await import("./chunk-cx32wsa1.js"),s=await o({...t,profile:e})({callerClientConfig:r});return R.setCredentialFeature(s,"CREDENTIALS_PROFILE_LOGIN","AC")};var O=H(Dt()),b=(e)=>Boolean(e)&&typeof e==="object"&&typeof e.credential_process==="string",x=async(e,t)=>{let{fromProcess:r}=await import("./chunk-r776bhsg.js"),o=await r({...e,profile:t})();return O.setCredentialFeature(o,"CREDENTIALS_PROFILE_PROCESS","v")};var p=H(Dt()),k=async(e,t,r={},o)=>{let{fromSSO:s}=await import("./chunk-0y4zq3y4.js");return s({profile:e,logger:r.logger,parentClientConfig:r.parentClientConfig,clientConfig:r.clientConfig})({callerClientConfig:o}).then((i)=>{if(t.sso_session)return p.setCredentialFeature(i,"CREDENTIALS_PROFILE_SSO","r");else return p.setCredentialFeature(i,"CREDENTIALS_PROFILE_SSO_LEGACY","t")})},F=(e)=>e&&(typeof e.sso_start_url==="string"||typeof e.sso_account_id==="string"||typeof e.sso_session==="string"||typeof e.sso_region==="string"||typeof e.sso_role_name==="string");var h=H(Dt()),C=(e)=>Boolean(e)&&typeof e==="object"&&typeof e.aws_access_key_id==="string"&&typeof e.aws_secret_access_key==="string"&&["undefined","string"].indexOf(typeof e.aws_session_token)>-1&&["undefined","string"].indexOf(typeof e.aws_account_id)>-1,y=async(e,t)=>{t?.logger?.debug("@aws-sdk/credential-provider-ini - resolveStaticCredentials");let r={accessKeyId:e.aws_access_key_id,secretAccessKey:e.aws_secret_access_key,sessionToken:e.aws_session_token,...e.aws_credential_scope&&{credentialScope:e.aws_credential_scope},...e.aws_account_id&&{accountId:e.aws_account_id}};return h.setCredentialFeature(r,"CREDENTIALS_PROFILE","n")};var D=H(Dt()),T=(e)=>Boolean(e)&&typeof e==="object"&&typeof e.web_identity_token_file==="string"&&typeof e.role_arn==="string"&&["undefined","string"].indexOf(typeof e.role_session_name)>-1,W=async(e,t,r)=>{let{fromTokenFile:o}=await import("./chunk-19jpn3r6.js"),s=await o({webIdentityTokenFile:e.web_identity_token_file,roleArn:e.role_arn,roleSessionName:e.role_session_name,roleAssumerWithWebIdentity:t.roleAssumerWithWebIdentity,logger:t.logger,parentClientConfig:t.parentClientConfig})({callerClientConfig:r});return D.setCredentialFeature(s,"CREDENTIALS_PROFILE_STS_WEB_ID_TOKEN","q")};var g=async(e,t,r,o,s={},i=!1)=>{let n=t[e];if(Object.keys(s).length>0&&C(n))return y(n,r);if(i||v(n,{profile:e,logger:r.logger}))return I(e,t,r,o,s,g);if(C(n))return y(n,r);if(T(n))return W(n,r,o);if(b(n))return x(r,e);if(F(n))return await k(e,n,r,o);if(A(n))return L(e,r,o);throw new N.CredentialsProviderError(`Could not resolve credentials using profile: [${e}] in configuration/credentials file(s).`,{logger:r.logger})};var U=(e={})=>async({callerClientConfig:t}={})=>{e.logger?.debug("@aws-sdk/credential-provider-ini - fromIni");let r=await f.parseKnownFiles(e);return g(f.getProfileName({profile:e.profile??t?.profile}),r,e,t)};export{U as fromIni};
2
+ import{Dt}from"./chunk-qqkr6h07.js";import{Ge}from"./chunk-exmwerag.js";import{H}from"./chunk-tjavzarz.js";var f=H(Ge());var N=H(Ge());var m=H(Dt()),l=H(Ge());var E=H(Dt()),d=H(Ge()),P=(e,t,r)=>{let o={EcsContainer:async(s)=>{let{fromHttp:i}=await import("./chunk-t2a1vq34.js"),{fromContainerMetadata:n}=await import("./chunk-m7tnj47b.js");return r?.debug("@aws-sdk/credential-provider-ini - credential_source is EcsContainer"),async()=>d.chain(i(s??{}),n(s))().then(_)},Ec2InstanceMetadata:async(s)=>{r?.debug("@aws-sdk/credential-provider-ini - credential_source is Ec2InstanceMetadata");let{fromInstanceMetadata:i}=await import("./chunk-m7tnj47b.js");return async()=>i(s)().then(_)},Environment:async(s)=>{r?.debug("@aws-sdk/credential-provider-ini - credential_source is Environment");let{fromEnv:i}=await import("./chunk-qj0bxb1m.js");return async()=>i(s)().then(_)}};if(e in o)return o[e];else throw new d.CredentialsProviderError(`Unsupported credential source in profile ${t}. Got ${e}, expected EcsContainer or Ec2InstanceMetadata or Environment.`,{logger:r})},_=(e)=>E.setCredentialFeature(e,"CREDENTIALS_PROFILE_NAMED_PROVIDER","p");var v=(e,{profile:t="default",logger:r}={})=>Boolean(e)&&typeof e==="object"&&typeof e.role_arn==="string"&&["undefined","string"].indexOf(typeof e.role_session_name)>-1&&["undefined","string"].indexOf(typeof e.external_id)>-1&&["undefined","string"].indexOf(typeof e.mfa_serial)>-1&&(K(e,{profile:t,logger:r})||G(e,{profile:t,logger:r})),K=(e,{profile:t,logger:r})=>{let o=typeof e.source_profile==="string"&&typeof e.credential_source>"u";if(o)r?.debug?.(` ${t} isAssumeRoleWithSourceProfile source_profile=${e.source_profile}`);return o},G=(e,{profile:t,logger:r})=>{let o=typeof e.credential_source==="string"&&typeof e.source_profile>"u";if(o)r?.debug?.(` ${t} isCredentialSourceProfile credential_source=${e.credential_source}`);return o},I=async(e,t,r,o,s={},i)=>{r.logger?.debug("@aws-sdk/credential-provider-ini - resolveAssumeRoleCredentials (STS)");let n=t[e],{source_profile:a,region:j}=n;if(!r.roleAssumer){let{getDefaultRoleAssumer:c}=await import("./chunk-59t9s2jh.js");r.roleAssumer=c({...r.clientConfig,credentialProviderLogger:r.logger,parentClientConfig:{...o,...r?.parentClientConfig,region:j??r?.parentClientConfig?.region??o?.region}},r.clientPlugins)}if(a&&a in s)throw new l.CredentialsProviderError(`Detected a cycle attempting to resolve credentials for profile ${l.getProfileName(r)}. Profiles visited: `+Object.keys(s).join(", "),{logger:r.logger});r.logger?.debug(`@aws-sdk/credential-provider-ini - finding credential resolver using ${a?`source_profile=[${a}]`:`profile=[${e}]`}`);let w=a?i(a,t,r,o,{...s,[a]:!0},S(t[a]??{})):(await P(n.credential_source,e,r.logger)(r))();if(S(n))return w.then((c)=>m.setCredentialFeature(c,"CREDENTIALS_PROFILE_SOURCE_PROFILE","o"));else{let c={RoleArn:n.role_arn,RoleSessionName:n.role_session_name||`aws-sdk-js-${Date.now()}`,ExternalId:n.external_id,DurationSeconds:parseInt(n.duration_seconds||"3600",10)},{mfa_serial:u}=n;if(u){if(!r.mfaCodeProvider)throw new l.CredentialsProviderError(`Profile ${e} requires multi-factor authentication, but no MFA code callback was provided.`,{logger:r.logger,tryNextLink:!1});c.SerialNumber=u,c.TokenCode=await r.mfaCodeProvider(u)}let M=await w;return r.roleAssumer(M,c).then((B)=>m.setCredentialFeature(B,"CREDENTIALS_PROFILE_SOURCE_PROFILE","o"))}},S=(e)=>!e.role_arn&&!!e.credential_source;var R=H(Dt()),A=(e)=>Boolean(e&&e.login_session),L=async(e,t,r)=>{let{fromLoginCredentials:o}=await import("./chunk-r1e59gf0.js"),s=await o({...t,profile:e})({callerClientConfig:r});return R.setCredentialFeature(s,"CREDENTIALS_PROFILE_LOGIN","AC")};var O=H(Dt()),b=(e)=>Boolean(e)&&typeof e==="object"&&typeof e.credential_process==="string",x=async(e,t)=>{let{fromProcess:r}=await import("./chunk-8sf2hf31.js"),o=await r({...e,profile:t})();return O.setCredentialFeature(o,"CREDENTIALS_PROFILE_PROCESS","v")};var p=H(Dt()),k=async(e,t,r={},o)=>{let{fromSSO:s}=await import("./chunk-4g4pxmef.js");return s({profile:e,logger:r.logger,parentClientConfig:r.parentClientConfig,clientConfig:r.clientConfig})({callerClientConfig:o}).then((i)=>{if(t.sso_session)return p.setCredentialFeature(i,"CREDENTIALS_PROFILE_SSO","r");else return p.setCredentialFeature(i,"CREDENTIALS_PROFILE_SSO_LEGACY","t")})},F=(e)=>e&&(typeof e.sso_start_url==="string"||typeof e.sso_account_id==="string"||typeof e.sso_session==="string"||typeof e.sso_region==="string"||typeof e.sso_role_name==="string");var h=H(Dt()),C=(e)=>Boolean(e)&&typeof e==="object"&&typeof e.aws_access_key_id==="string"&&typeof e.aws_secret_access_key==="string"&&["undefined","string"].indexOf(typeof e.aws_session_token)>-1&&["undefined","string"].indexOf(typeof e.aws_account_id)>-1,y=async(e,t)=>{t?.logger?.debug("@aws-sdk/credential-provider-ini - resolveStaticCredentials");let r={accessKeyId:e.aws_access_key_id,secretAccessKey:e.aws_secret_access_key,sessionToken:e.aws_session_token,...e.aws_credential_scope&&{credentialScope:e.aws_credential_scope},...e.aws_account_id&&{accountId:e.aws_account_id}};return h.setCredentialFeature(r,"CREDENTIALS_PROFILE","n")};var D=H(Dt()),T=(e)=>Boolean(e)&&typeof e==="object"&&typeof e.web_identity_token_file==="string"&&typeof e.role_arn==="string"&&["undefined","string"].indexOf(typeof e.role_session_name)>-1,W=async(e,t,r)=>{let{fromTokenFile:o}=await import("./chunk-3sfb63fp.js"),s=await o({webIdentityTokenFile:e.web_identity_token_file,roleArn:e.role_arn,roleSessionName:e.role_session_name,roleAssumerWithWebIdentity:t.roleAssumerWithWebIdentity,logger:t.logger,parentClientConfig:t.parentClientConfig})({callerClientConfig:r});return D.setCredentialFeature(s,"CREDENTIALS_PROFILE_STS_WEB_ID_TOKEN","q")};var g=async(e,t,r,o,s={},i=!1)=>{let n=t[e];if(Object.keys(s).length>0&&C(n))return y(n,r);if(i||v(n,{profile:e,logger:r.logger}))return I(e,t,r,o,s,g);if(C(n))return y(n,r);if(T(n))return W(n,r,o);if(b(n))return x(r,e);if(F(n))return await k(e,n,r,o);if(A(n))return L(e,r,o);throw new N.CredentialsProviderError(`Could not resolve credentials using profile: [${e}] in configuration/credentials file(s).`,{logger:r.logger})};var U=(e={})=>async({callerClientConfig:t}={})=>{e.logger?.debug("@aws-sdk/credential-provider-ini - fromIni");let r=await f.parseKnownFiles(e);return g(f.getProfileName({profile:e.profile??t?.profile}),r,e,t)};export{U as fromIni};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Is,tc,Aa,rc,_a,nc,oc,sc,ic,ac}from"./chunk-98mg3dpd.js";import{dr}from"./chunk-b5r0be06.js";import{xn,Sn}from"./chunk-sbyyn9yw.js";import{He,Tr}from"./chunk-dppfek34.js";import{qi}from"./chunk-zdzkjp4q.js";import{hn,Gr}from"./chunk-ae6zgjhd.js";import{Jt}from"./chunk-vm2pz2hm.js";var y="v1",E="gcp-vertex-credentials",T={THINKING_LEVEL_UNSPECIFIED:Is.THINKING_LEVEL_UNSPECIFIED,MINIMAL:Is.MINIMAL,LOW:Is.LOW,MEDIUM:Is.MEDIUM,HIGH:Is.HIGH},_=0,m=(e,t,n)=>{let o=new Jt;return(async()=>{let i={role:"assistant",content:[],api:"google-vertex",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 u=S(n),s=u?v(e,u,n?.headers):b(e,A(n),P(n),n?.headers,n?.env),h=N(e,t,n),g=await n?.onPayload?.(h,e);if(g!==void 0)h=g;let x=await s.models.generateContentStream(h);o.push({type:"start",partial:i});let r=null,I=i.content,l=()=>I.length-1;for await(let c of x){i.responseId||=c.responseId;let p=c.candidates?.[0];if(p?.content?.parts)for(let a of p.content.parts){if(a.text!==void 0){let d=rc(a);if(!r||d&&r.type!=="thinking"||!d&&r.type!=="text"){if(r)if(r.type==="text")o.push({type:"text_end",contentIndex:I.length-1,content:r.text,partial:i});else o.push({type:"thinking_end",contentIndex:l(),content:r.thinking,partial:i});if(d)r={type:"thinking",thinking:"",thinkingSignature:void 0},i.content.push(r),o.push({type:"thinking_start",contentIndex:l(),partial:i});else r={type:"text",text:""},i.content.push(r),o.push({type:"text_start",contentIndex:l(),partial:i})}if(r.type==="thinking")r.thinking+=a.text,r.thinkingSignature=_a(r.thinkingSignature,a.thoughtSignature),o.push({type:"thinking_delta",contentIndex:l(),delta:a.text,partial:i});else r.text+=a.text,r.textSignature=_a(r.textSignature,a.thoughtSignature),o.push({type:"text_delta",contentIndex:l(),delta:a.text,partial:i})}if(a.functionCall){if(r){if(r.type==="text")o.push({type:"text_end",contentIndex:l(),content:r.text,partial:i});else o.push({type:"thinking_end",contentIndex:l(),content:r.thinking,partial:i});r=null}let d=a.functionCall.id,f={type:"toolCall",id:!d||i.content.some((C)=>C.type==="toolCall"&&C.id===d)?`${a.functionCall.name}_${Date.now()}_${++_}`:d,name:a.functionCall.name||"",arguments:a.functionCall.args??{},...a.thoughtSignature&&{thoughtSignature:a.thoughtSignature}};i.content.push(f),o.push({type:"toolcall_start",contentIndex:l(),partial:i}),o.push({type:"toolcall_delta",contentIndex:l(),delta:JSON.stringify(f.arguments),partial:i}),o.push({type:"toolcall_end",contentIndex:l(),toolCall:f,partial:i})}}if(p?.finishReason){if(i.stopReason=ac(p.finishReason),i.content.some((a)=>a.type==="toolCall"))i.stopReason="toolUse"}if(c.usageMetadata)i.usage={input:(c.usageMetadata.promptTokenCount||0)-(c.usageMetadata.cachedContentTokenCount||0),output:(c.usageMetadata.candidatesTokenCount||0)+(c.usageMetadata.thoughtsTokenCount||0),cacheRead:c.usageMetadata.cachedContentTokenCount||0,cacheWrite:0,reasoning:c.usageMetadata.thoughtsTokenCount||0,totalTokens:c.usageMetadata.totalTokenCount||0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},hn(e,i.usage)}if(r)if(r.type==="text")o.push({type:"text_end",contentIndex:l(),content:r.text,partial:i});else o.push({type:"thinking_end",contentIndex:l(),content:r.thinking,partial:i});if(n?.signal?.aborted)throw Error("Request was aborted");if(i.stopReason==="aborted"||i.stopReason==="error")throw Error("An unknown error occurred");o.push({type:"done",reason:i.stopReason,message:i}),o.end()}catch(u){for(let s of i.content)if("index"in s)delete s.index;i.stopReason=n?.signal?.aborted?"aborted":"error",i.errorMessage=Sn(xn(u)),o.push({type:"error",reason:i.stopReason,error:i}),o.end()}})(),o},Y=(e,t,n)=>{let o=Tr(e,t,n,void 0);if(!n?.reasoning)return m(e,t,{...o,thinking:{enabled:!1}});let i=Gr(e,n.reasoning),u=i==="off"?"high":i,s=e;if(k(s)||L(s))return m(e,t,{...o,thinking:{enabled:!0,level:D(u,s)}});return m(e,t,{...o,thinking:{enabled:!0,budgetTokens:H(s,u,n.thinkingBudgets)}})};function b(e,t,n,o,i){let u=w(i);return new Aa({vertexai:!0,project:t,location:n,apiVersion:y,...u?{googleAuthOptions:u}:{},httpOptions:O(e,o)})}function v(e,t,n){return new Aa({vertexai:!0,apiKey:t,apiVersion:y,httpOptions:O(e,n)})}function O(e,t){let n={},o=M(e.baseUrl);if(o){if(n.baseUrl=o,n.baseUrlResourceScope=tc.COLLECTION,R(o))n.apiVersion=""}let i=qi({...e.headers,...t});if(i)n.headers=i;return Object.keys(n).length>0?n:void 0}function M(e){let t=e.trim();if(!t||t.includes("{location}"))return;return t}function R(e){try{return new URL(e).pathname.split("/").some((n)=>/^v\d+(?:beta\d*)?$/.test(n))}catch{return/(?:^|\/)v\d+(?:beta\d*)?(?:\/|$)/.test(e)}}function w(e){let t=dr("GOOGLE_APPLICATION_CREDENTIALS",e);return t?{keyFilename:t}:void 0}function S(e){let t=e?.apiKey?.trim();if(!t||t===E||G(t))return;return t}function G(e){return/^<[^>]+>$/.test(e)}function A(e){let t=e?.project||dr("GOOGLE_CLOUD_PROJECT",e?.env)||dr("GCLOUD_PROJECT",e?.env);if(!t)throw Error("Vertex AI requires a project ID. Set GOOGLE_CLOUD_PROJECT/GCLOUD_PROJECT or pass project in options.");return t}function P(e){let t=e?.location||dr("GOOGLE_CLOUD_LOCATION",e?.env);if(!t)throw Error("Vertex AI requires a location. Set GOOGLE_CLOUD_LOCATION or pass location in options.");return t}function N(e,t,n={}){let o=nc(e,t),i={};if(n.temperature!==void 0)i.temperature=n.temperature;if(n.maxTokens!==void 0)i.maxOutputTokens=n.maxTokens;let u=t.tools?.length?ic(t.tools,n.toolChoice,sc(e.id)):void 0,s={...Object.keys(i).length>0&&i,...t.systemPrompt&&{systemInstruction:He(t.systemPrompt)},...t.tools&&t.tools.length>0&&{tools:oc(t.tools)},...u!==void 0&&{toolConfig:{functionCallingConfig:{mode:u}}}};if(n.thinking?.enabled&&e.reasoning){let g={includeThoughts:!0};if(n.thinking.level!==void 0)g.thinkingLevel=T[n.thinking.level];else if(n.thinking.budgetTokens!==void 0)g.thinkingBudget=n.thinking.budgetTokens;s.thinkingConfig=g}else if(e.reasoning&&n.thinking&&!n.thinking.enabled)s.thinkingConfig=U(e);if(n.signal){if(n.signal.aborted)throw Error("Request aborted");s.abortSignal=n.signal}return{model:e.id,contents:o,config:s}}function k(e){return/gemini-3(?:\.\d+)?-pro/.test(e.id.toLowerCase())}function L(e){let t=e.id.toLowerCase();return/gemini-3(?:\.\d+)?-flash/.test(t)||t==="gemini-flash-latest"||t==="gemini-flash-lite-latest"}function U(e){let t=e;if(k(t))return{thinkingLevel:Is.LOW};if(L(t))return{thinkingLevel:Is.MINIMAL};return{thinkingBudget:0}}function D(e,t){if(k(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 H(e,t,n){if(n?.[t]!==void 0)return n[t];if(e.id.includes("2.5-pro"))return{minimal:128,low:2048,medium:8192,high:32768}[t];if(e.id.includes("2.5-flash"))return{minimal:128,low:2048,medium:8192,high:24576}[t];return-1}export{m as stream,Y as streamSimple};
2
+ import{Ts,oc,Aa,sc,_a,ic,ac,lc,cc,uc}from"./chunk-x6rf77jm.js";import{dr}from"./chunk-8rekh4h9.js";import{xn,Sn}from"./chunk-sbyyn9yw.js";import{He,Tr}from"./chunk-fyb6t7ct.js";import{qi}from"./chunk-3fjgf7eb.js";import{mn,Gr}from"./chunk-047n9gfs.js";import{Jt}from"./chunk-q7t5zs7n.js";var y="v1",E="gcp-vertex-credentials",T={THINKING_LEVEL_UNSPECIFIED:Ts.THINKING_LEVEL_UNSPECIFIED,MINIMAL:Ts.MINIMAL,LOW:Ts.LOW,MEDIUM:Ts.MEDIUM,HIGH:Ts.HIGH},_=0,m=(e,t,n)=>{let o=new Jt;return(async()=>{let i={role:"assistant",content:[],api:"google-vertex",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 u=S(n),s=u?v(e,u,n?.headers):b(e,A(n),P(n),n?.headers,n?.env),h=N(e,t,n),g=await n?.onPayload?.(h,e);if(g!==void 0)h=g;let x=await s.models.generateContentStream(h);o.push({type:"start",partial:i});let r=null,I=i.content,l=()=>I.length-1;for await(let c of x){i.responseId||=c.responseId;let p=c.candidates?.[0];if(p?.content?.parts)for(let a of p.content.parts){if(a.text!==void 0){let d=sc(a);if(!r||d&&r.type!=="thinking"||!d&&r.type!=="text"){if(r)if(r.type==="text")o.push({type:"text_end",contentIndex:I.length-1,content:r.text,partial:i});else o.push({type:"thinking_end",contentIndex:l(),content:r.thinking,partial:i});if(d)r={type:"thinking",thinking:"",thinkingSignature:void 0},i.content.push(r),o.push({type:"thinking_start",contentIndex:l(),partial:i});else r={type:"text",text:""},i.content.push(r),o.push({type:"text_start",contentIndex:l(),partial:i})}if(r.type==="thinking")r.thinking+=a.text,r.thinkingSignature=_a(r.thinkingSignature,a.thoughtSignature),o.push({type:"thinking_delta",contentIndex:l(),delta:a.text,partial:i});else r.text+=a.text,r.textSignature=_a(r.textSignature,a.thoughtSignature),o.push({type:"text_delta",contentIndex:l(),delta:a.text,partial:i})}if(a.functionCall){if(r){if(r.type==="text")o.push({type:"text_end",contentIndex:l(),content:r.text,partial:i});else o.push({type:"thinking_end",contentIndex:l(),content:r.thinking,partial:i});r=null}let d=a.functionCall.id,f={type:"toolCall",id:!d||i.content.some((C)=>C.type==="toolCall"&&C.id===d)?`${a.functionCall.name}_${Date.now()}_${++_}`:d,name:a.functionCall.name||"",arguments:a.functionCall.args??{},...a.thoughtSignature&&{thoughtSignature:a.thoughtSignature}};i.content.push(f),o.push({type:"toolcall_start",contentIndex:l(),partial:i}),o.push({type:"toolcall_delta",contentIndex:l(),delta:JSON.stringify(f.arguments),partial:i}),o.push({type:"toolcall_end",contentIndex:l(),toolCall:f,partial:i})}}if(p?.finishReason){if(i.stopReason=uc(p.finishReason),i.content.some((a)=>a.type==="toolCall"))i.stopReason="toolUse"}if(c.usageMetadata)i.usage={input:(c.usageMetadata.promptTokenCount||0)-(c.usageMetadata.cachedContentTokenCount||0),output:(c.usageMetadata.candidatesTokenCount||0)+(c.usageMetadata.thoughtsTokenCount||0),cacheRead:c.usageMetadata.cachedContentTokenCount||0,cacheWrite:0,reasoning:c.usageMetadata.thoughtsTokenCount||0,totalTokens:c.usageMetadata.totalTokenCount||0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},mn(e,i.usage)}if(r)if(r.type==="text")o.push({type:"text_end",contentIndex:l(),content:r.text,partial:i});else o.push({type:"thinking_end",contentIndex:l(),content:r.thinking,partial:i});if(n?.signal?.aborted)throw Error("Request was aborted");if(i.stopReason==="aborted"||i.stopReason==="error")throw Error("An unknown error occurred");o.push({type:"done",reason:i.stopReason,message:i}),o.end()}catch(u){for(let s of i.content)if("index"in s)delete s.index;i.stopReason=n?.signal?.aborted?"aborted":"error",i.errorMessage=Sn(xn(u)),o.push({type:"error",reason:i.stopReason,error:i}),o.end()}})(),o},Y=(e,t,n)=>{let o=Tr(e,t,n,void 0);if(!n?.reasoning)return m(e,t,{...o,thinking:{enabled:!1}});let i=Gr(e,n.reasoning),u=i==="off"?"high":i,s=e;if(k(s)||L(s))return m(e,t,{...o,thinking:{enabled:!0,level:D(u,s)}});return m(e,t,{...o,thinking:{enabled:!0,budgetTokens:H(s,u,n.thinkingBudgets)}})};function b(e,t,n,o,i){let u=w(i);return new Aa({vertexai:!0,project:t,location:n,apiVersion:y,...u?{googleAuthOptions:u}:{},httpOptions:O(e,o)})}function v(e,t,n){return new Aa({vertexai:!0,apiKey:t,apiVersion:y,httpOptions:O(e,n)})}function O(e,t){let n={},o=M(e.baseUrl);if(o){if(n.baseUrl=o,n.baseUrlResourceScope=oc.COLLECTION,R(o))n.apiVersion=""}let i=qi({...e.headers,...t});if(i)n.headers=i;return Object.keys(n).length>0?n:void 0}function M(e){let t=e.trim();if(!t||t.includes("{location}"))return;return t}function R(e){try{return new URL(e).pathname.split("/").some((n)=>/^v\d+(?:beta\d*)?$/.test(n))}catch{return/(?:^|\/)v\d+(?:beta\d*)?(?:\/|$)/.test(e)}}function w(e){let t=dr("GOOGLE_APPLICATION_CREDENTIALS",e);return t?{keyFilename:t}:void 0}function S(e){let t=e?.apiKey?.trim();if(!t||t===E||G(t))return;return t}function G(e){return/^<[^>]+>$/.test(e)}function A(e){let t=e?.project||dr("GOOGLE_CLOUD_PROJECT",e?.env)||dr("GCLOUD_PROJECT",e?.env);if(!t)throw Error("Vertex AI requires a project ID. Set GOOGLE_CLOUD_PROJECT/GCLOUD_PROJECT or pass project in options.");return t}function P(e){let t=e?.location||dr("GOOGLE_CLOUD_LOCATION",e?.env);if(!t)throw Error("Vertex AI requires a location. Set GOOGLE_CLOUD_LOCATION or pass location in options.");return t}function N(e,t,n={}){let o=ic(e,t),i={};if(n.temperature!==void 0)i.temperature=n.temperature;if(n.maxTokens!==void 0)i.maxOutputTokens=n.maxTokens;let u=t.tools?.length?cc(t.tools,n.toolChoice,lc(e.id)):void 0,s={...Object.keys(i).length>0&&i,...t.systemPrompt&&{systemInstruction:He(t.systemPrompt)},...t.tools&&t.tools.length>0&&{tools:ac(t.tools)},...u!==void 0&&{toolConfig:{functionCallingConfig:{mode:u}}}};if(n.thinking?.enabled&&e.reasoning){let g={includeThoughts:!0};if(n.thinking.level!==void 0)g.thinkingLevel=T[n.thinking.level];else if(n.thinking.budgetTokens!==void 0)g.thinkingBudget=n.thinking.budgetTokens;s.thinkingConfig=g}else if(e.reasoning&&n.thinking&&!n.thinking.enabled)s.thinkingConfig=U(e);if(n.signal){if(n.signal.aborted)throw Error("Request aborted");s.abortSignal=n.signal}return{model:e.id,contents:o,config:s}}function k(e){return/gemini-3(?:\.\d+)?-pro/.test(e.id.toLowerCase())}function L(e){let t=e.id.toLowerCase();return/gemini-3(?:\.\d+)?-flash/.test(t)||t==="gemini-flash-latest"||t==="gemini-flash-lite-latest"}function U(e){let t=e;if(k(t))return{thinkingLevel:Ts.LOW};if(L(t))return{thinkingLevel:Ts.MINIMAL};return{thinkingBudget:0}}function D(e,t){if(k(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 H(e,t,n){if(n?.[t]!==void 0)return n[t];if(e.id.includes("2.5-pro"))return{minimal:128,low:2048,medium:8192,high:32768}[t];if(e.id.includes("2.5-flash"))return{minimal:128,low:2048,medium:8192,high:24576}[t];return-1}export{m as stream,Y as streamSimple};
@@ -1,2 +1,2 @@
1
- import{I}from"./chunk-42hrvk6k.js";var c=[["path",{d:"M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z",key:"e79jfc"}],["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}]],Wl=I("palette",c);var e=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],Yl=I("shield",e);
2
- export{Wl,Yl};
1
+ import{I}from"./chunk-vvr8tnse.js";var c=[["path",{d:"M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z",key:"e79jfc"}],["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}]],Xl=I("palette",c);var e=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],ec=I("shield",e);
2
+ export{Xl,ec};