@bkm016/basalt 0.1.11 → 0.1.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{chunk-7jezts2n.js → chunk-06s9pr82.js} +2 -2
- package/{chunk-msm9hmk9.js → chunk-095adzn5.js} +2 -2
- package/chunk-0a7ft50x.js +18 -0
- package/{chunk-tevejprz.js → chunk-0nedq669.js} +4 -4
- package/chunk-0x9netvr.js +5 -0
- package/{chunk-9as0p561.js → chunk-15ve3nmv.js} +11 -11
- package/chunk-1dbfmejf.js +2 -0
- package/{chunk-hbnmymaq.js → chunk-1q6e3mj7.js} +2 -2
- package/{chunk-wnzvnskb.js → chunk-22az84sh.js} +2 -2
- package/{chunk-ax04trym.js → chunk-2q56egb8.js} +1 -1
- package/{chunk-r4ttdkrz.js → chunk-2tf7qfbx.js} +2 -2
- package/{chunk-a1352w87.js → chunk-2zbj8ny6.js} +2 -2
- package/chunk-302n9g7p.js +2 -0
- package/{chunk-bk4rpnm8.js → chunk-37ndxehw.js} +2 -2
- package/chunk-41das1ty.js +2 -0
- package/{chunk-c71173py.js → chunk-44a7f5ta.js} +6 -6
- package/{chunk-jn5pqy5v.js → chunk-46vy2m29.js} +1 -1
- package/{chunk-1zj3zvw5.js → chunk-4k9t9jvx.js} +4 -4
- package/{chunk-c4qr1f41.js → chunk-4rnmxtpx.js} +2 -2
- package/{chunk-fgwda4m0.js → chunk-4w9zqv0k.js} +1 -1
- package/chunk-6d9r9p91.js +20 -0
- package/chunk-6f4ht2hw.js +2 -0
- package/{chunk-jj4hqbrx.js → chunk-6sea12mw.js} +3 -3
- package/chunk-74wwdx3y.js +3 -0
- package/{chunk-gkf5jwvj.js → chunk-77c2cqp2.js} +1 -1
- package/chunk-7chv3knf.js +2 -0
- package/chunk-86yr2c0r.js +3 -0
- package/{chunk-d0a1jxk5.js → chunk-8cgz8xv7.js} +2 -2
- package/{chunk-tvm4zmgj.js → chunk-959z9efn.js} +2 -2
- package/{chunk-zc9ar0r4.js → chunk-9e8vhzy7.js} +1 -1
- package/chunk-b516bp7n.js +3 -0
- package/chunk-bja7p3em.js +25 -0
- package/chunk-bng72094.js +2 -0
- package/{chunk-a98wma9j.js → chunk-bp61xdsc.js} +1 -1
- package/chunk-bq54argx.js +2 -0
- package/chunk-ct77cdg7.js +2 -0
- package/{chunk-02d3x4mj.js → chunk-dk6fgprw.js} +3 -3
- package/chunk-drett6hb.js +2 -0
- package/{chunk-4gtgqcct.js → chunk-edbq461k.js} +3 -3
- package/{chunk-xh444pfn.js → chunk-f0h2bv11.js} +12 -12
- package/{chunk-8mezk0cb.js → chunk-g2etemv5.js} +2 -2
- package/{chunk-n0ybj4h9.js → chunk-g5p9mj1r.js} +2 -2
- package/{chunk-zyyzk5ha.js → chunk-gpnqmtbk.js} +1 -1
- package/{chunk-q9f4xb0w.js → chunk-h9zxqeqr.js} +3 -3
- package/{chunk-hb4f2v34.js → chunk-jjtt9aq8.js} +3 -3
- package/{chunk-29qrxygd.js → chunk-kbpbrr11.js} +2 -2
- package/chunk-m71pj3g1.js +2 -0
- package/chunk-mdkfm1ak.js +7 -0
- package/chunk-mf04h0yy.js +7 -0
- package/chunk-n22vd4at.js +2 -0
- package/{chunk-c0zfefq8.js → chunk-nbjnwd54.js} +1 -1
- package/{chunk-d5j74pcp.js → chunk-pryvvs96.js} +22 -22
- package/{chunk-13gvs0ax.js → chunk-r1jn77q6.js} +2 -2
- package/{chunk-ypqjfv3a.js → chunk-rn3jwyh1.js} +2 -2
- package/chunk-sgrrxsnz.js +482 -0
- package/chunk-sgz87ht5.js +2 -0
- package/{chunk-stj493dn.js → chunk-snz19yc2.js} +2 -2
- package/{chunk-n2jcx65v.js → chunk-szj85dqe.js} +2 -2
- package/{chunk-nrsd810j.js → chunk-tfhp09nj.js} +2 -2
- package/{chunk-xtq1xpq0.js → chunk-tfhze1vq.js} +2 -2
- package/{chunk-755sy11p.js → chunk-tjg0gcks.js} +1 -1
- package/{chunk-en218k4y.js → chunk-tnj2kqb8.js} +1 -1
- package/{chunk-h1kb8b49.js → chunk-vqm94hz2.js} +2 -2
- package/{chunk-82v8jh1h.js → chunk-xvm0y99b.js} +2 -2
- package/{chunk-asyr3gnq.js → chunk-y23dpz5e.js} +2 -2
- package/{chunk-1n7dat03.js → chunk-y4pvhes1.js} +6 -6
- package/{chunk-bwawt15q.js → chunk-ydzag81d.js} +2 -2
- package/chunk-ymg7mtcx.js +3 -0
- package/chunk-yy1f9jxc.js +4044 -0
- package/{chunk-30rjf7my.js → chunk-z0c8ek0j.js} +5 -5
- package/chunk-zk91579b.js +3 -0
- package/{chunk-jtsve11b.js → chunk-zx75vnw8.js} +18 -18
- package/compiled.js +85 -12
- package/package.json +1 -1
- package/ui-test-worker.js +53 -53
- package/web/{chunk-3a57m7xm.js → chunk-0jbf73pr.js} +3 -3
- package/web/{chunk-dk0fnj87.js → chunk-0rhx7qb8.js} +1 -1
- package/web/{chunk-q8v5j963.js → chunk-0rvwj2wh.js} +2 -2
- package/web/chunk-12qf1r6m.js +1 -0
- package/web/{chunk-2ds0a2z1.js → chunk-14vmr99v.js} +3 -3
- package/web/{chunk-v3dn9bfw.js → chunk-16jc5m0f.js} +1 -1
- package/web/{chunk-f79ajymt.js → chunk-1m6fx2h7.js} +2 -2
- package/web/{chunk-793m5jjh.js → chunk-1xm9x7d6.js} +2 -2
- package/web/{chunk-j4gvtszc.js → chunk-1zwc09e8.js} +2 -2
- package/web/{chunk-mykbcvqz.js → chunk-20jxvmbw.js} +1 -1
- package/web/chunk-2n5xbnrt.js +1 -0
- package/web/{chunk-57pyz29y.js → chunk-2sef2wft.js} +2 -2
- package/web/{chunk-9kkzmss7.js → chunk-2x7vmhm0.js} +3 -3
- package/web/{chunk-cbwvfedy.js → chunk-2y1avvqj.js} +8 -8
- package/web/chunk-36s08nye.js +1 -0
- package/web/chunk-3ctmehg4.js +1 -0
- package/web/{chunk-cpshsp24.js → chunk-3jjksgze.js} +1 -1
- package/web/{chunk-94denx9h.js → chunk-3p9w8sg5.js} +3 -3
- package/web/{chunk-47mbbmst.js → chunk-3wpxymxa.js} +3 -3
- package/web/{chunk-2tsxj613.js → chunk-4py9sndw.js} +9 -9
- package/web/chunk-4swea9sn.js +1 -0
- package/web/chunk-4zz5a483.js +1 -0
- package/web/{chunk-hjyev38w.js → chunk-5cwxhhae.js} +5 -5
- package/web/chunk-5ym5ffd5.js +4 -0
- package/web/{chunk-gten0rpx.js → chunk-6e87m0nm.js} +2 -2
- package/web/{chunk-5ahx98zj.js → chunk-6rsr2cyw.js} +8 -8
- package/web/chunk-6y55gk1n.js +1 -0
- package/web/chunk-7aep7k4v.js +1 -0
- package/web/{chunk-tggja45g.js → chunk-8j4tzff5.js} +4 -4
- package/web/chunk-8tgavnwx.js +1 -0
- package/web/{chunk-zdhyq3ch.js → chunk-97t3ngqf.js} +12 -12
- package/web/{chunk-0hvxb5d5.js → chunk-980zhtht.js} +1 -1
- package/web/chunk-9k7fkx80.js +1 -0
- package/web/{chunk-yrh86m0n.js → chunk-9wz8jne3.js} +1 -1
- package/web/chunk-a00vg115.js +1 -0
- package/web/chunk-a4gbxnm3.js +1 -0
- package/web/{chunk-nhx8pw7p.js → chunk-a6g3nqp0.js} +2 -2
- package/web/{chunk-xjc5fmcr.js → chunk-a9er7a7c.js} +24 -24
- package/web/chunk-atppv8fk.js +1 -0
- package/web/{chunk-xbyrgyy0.js → chunk-awkdw9rw.js} +2 -2
- package/web/{chunk-2f2agfpj.js → chunk-b4gcpsbg.js} +11 -11
- package/web/{chunk-n33753da.js → chunk-b9jry5a3.js} +1 -1
- package/web/chunk-ba9qy65y.js +2 -0
- package/web/chunk-bq6mep6p.js +2 -0
- package/web/chunk-bwy3e58v.js +1 -0
- package/web/{chunk-drchr3yn.js → chunk-c57f714b.js} +2 -2
- package/web/{chunk-e763h2px.js → chunk-c6m4vfn5.js} +118 -118
- package/web/{chunk-mpdeqzc9.js → chunk-cr04125j.js} +9 -9
- package/web/{chunk-dsbyfvwz.js → chunk-cr05dttm.js} +1 -1
- package/web/{chunk-a3pye9ag.js → chunk-ct7z7bea.js} +3 -3
- package/web/{chunk-2weaa3gn.js → chunk-ct90yf8z.js} +2 -2
- package/web/{chunk-gyhr27dm.js → chunk-ddg8rz82.js} +3 -3
- package/web/{chunk-wbwets5x.js → chunk-dmha2y9c.js} +28 -28
- package/web/{chunk-4gc663j0.js → chunk-e57h40qa.js} +6 -6
- package/web/chunk-eeesa5q1.js +1 -0
- package/web/{chunk-4wwd3pfz.js → chunk-eqndhs21.js} +2 -2
- package/web/{chunk-zv73g4qq.js → chunk-eqxy6535.js} +2 -2
- package/web/{chunk-hm8thq7c.js → chunk-et1rsgmp.js} +3 -3
- package/web/chunk-f7jpakwh.js +1 -0
- package/web/{chunk-enryqmj7.js → chunk-fnvgdvrg.js} +5 -5
- package/web/chunk-fp62avjh.js +1 -0
- package/web/{chunk-6jb2zyp6.js → chunk-frnh4zqf.js} +2 -2
- package/web/chunk-g0be12na.js +1 -0
- package/web/{chunk-1zfxaafq.js → chunk-g7hqafb8.js} +1 -1
- package/web/{chunk-kfbgvh0c.js → chunk-ga07tv37.js} +1 -1
- package/web/chunk-gr163fex.js +1 -0
- package/web/chunk-gx340asc.js +1 -0
- package/web/chunk-gxtz10wf.js +1 -0
- package/web/chunk-h0c42zy3.js +1 -0
- package/web/{chunk-b3j07x0n.js → chunk-h1k2kqbs.js} +6 -6
- package/web/{chunk-pq56b3mq.js → chunk-h6k1x096.js} +2 -2
- package/web/{chunk-885kpj14.js → chunk-jccz14ye.js} +2 -2
- package/web/{chunk-1t38sgrk.js → chunk-jh33m2mq.js} +4 -4
- package/web/{chunk-g0rtcedn.js → chunk-jh3k7xex.js} +3 -3
- package/web/{chunk-nafe18y9.js → chunk-jpem3qvs.js} +10 -10
- package/web/{chunk-s0xy00v5.js → chunk-k0cg4n2k.js} +2 -2
- package/web/chunk-k9qnvx86.js +2 -0
- package/web/chunk-kcnj0gan.js +1 -0
- package/web/{chunk-8csw0mvf.js → chunk-ke8dffnk.js} +2 -2
- package/web/chunk-kpp5xqsb.js +1 -0
- package/web/chunk-m33yted6.js +1 -0
- package/web/chunk-me5jqqn6.js +1 -0
- package/web/{chunk-tpdcrrf1.js → chunk-mkxeenph.js} +1 -1
- package/web/chunk-mnf4ngj9.js +2 -0
- package/web/{chunk-30aeb767.js → chunk-mykrm8ba.js} +2 -2
- package/web/chunk-mzqqwbmr.js +1 -0
- package/web/chunk-mzzaet63.js +1 -0
- package/web/chunk-npyrdsf8.css +1 -0
- package/web/chunk-p6e2vr51.js +34 -0
- package/web/chunk-p7pa02k9.js +2 -0
- package/web/chunk-q34as3v6.js +1 -0
- package/web/{chunk-27812gqr.js → chunk-q4vy3dkk.js} +3 -3
- package/web/chunk-q6c8p73w.js +1 -0
- package/web/{chunk-m24yb8md.js → chunk-qb8mbptk.js} +1 -1
- package/web/{chunk-b6sqwmq7.js → chunk-qbmtah1x.js} +1 -1
- package/web/{chunk-ydtrc1ay.js → chunk-qh62nkem.js} +2 -2
- package/web/chunk-qn93we3a.js +1 -0
- package/web/{chunk-3ftb27f3.js → chunk-qq06x2ce.js} +8 -8
- package/web/{chunk-fj753yzt.js → chunk-qq6m2my8.js} +2 -2
- package/web/chunk-r1f1egve.js +1 -0
- package/web/chunk-s935z8er.js +2 -0
- package/web/{chunk-90fkdzx3.js → chunk-sq75q603.js} +21 -21
- package/web/{chunk-05mvzx00.js → chunk-ss96cz1f.js} +1 -1
- package/web/{chunk-3b4wqmnh.js → chunk-t82sngk9.js} +7 -7
- package/web/chunk-tt9410zw.js +8 -0
- package/web/{chunk-8151c970.js → chunk-v4cqc9f9.js} +1 -1
- package/web/chunk-ve8gy05p.js +1142 -0
- package/web/chunk-vg1ebkce.js +1 -0
- package/web/{chunk-g31dbnzm.js → chunk-vk7ch6fh.js} +5 -5
- package/web/chunk-vnt34mkb.js +1 -0
- package/web/{chunk-59nk506k.js → chunk-w28dn4dw.js} +1 -1
- package/web/{chunk-ppjw1mps.js → chunk-w4tfad6c.js} +4 -4
- package/web/{chunk-36dc7tcg.js → chunk-wpxtkxjt.js} +2 -2
- package/web/chunk-xcyqd7cn.js +1 -0
- package/web/chunk-xe121vg7.js +1 -0
- package/web/chunk-xh4xn1az.js +1 -0
- package/web/{chunk-d4519smc.js → chunk-xk1vkcj4.js} +15 -15
- package/web/chunk-xrk5ewsn.js +1 -0
- package/web/{chunk-96xhmmqz.js → chunk-xvm66b7v.js} +5 -5
- package/web/chunk-xxmaqj1m.js +2 -0
- package/web/chunk-xzwxcxb4.js +1 -0
- package/web/{chunk-7dycbjxn.js → chunk-y9waq403.js} +4 -4
- package/web/chunk-ydhnkws0.js +1 -0
- package/web/{chunk-3020mmp1.js → chunk-yn4t5s9r.js} +1 -1
- package/web/chunk-ys2tns0p.js +1 -0
- package/web/chunk-zb61mf0a.js +1 -0
- package/web/{chunk-g4as4zzd.js → chunk-ze6azq7z.js} +4 -4
- package/web/chunk-zh7193nq.js +2 -0
- package/web/chunk-zqcg6frm.js +1 -0
- package/web/{chunk-qykt7avq.js → chunk-zxrbbbtp.js} +2 -2
- package/web/index.html +1 -1
- package/worker.js +1 -1
- package/chunk-38g3gctw.js +0 -3
- package/chunk-3k627vf2.js +0 -3
- package/chunk-4dw43syb.js +0 -2
- package/chunk-7zkswxvk.js +0 -2
- package/chunk-95964592.js +0 -25
- package/chunk-a1rb1a48.js +0 -20
- package/chunk-b2bxqeb4.js +0 -2
- package/chunk-bdjr0kfr.js +0 -7
- package/chunk-bpw6q7g0.js +0 -3
- package/chunk-c6q04xrd.js +0 -3
- package/chunk-cmwdjes8.js +0 -18
- package/chunk-dfh9m9n7.js +0 -7
- package/chunk-dq01v5eq.js +0 -2
- package/chunk-e1x629v0.js +0 -5
- package/chunk-gbjn6d81.js +0 -2
- package/chunk-jymx3a77.js +0 -3951
- package/chunk-m1eam0s5.js +0 -2
- package/chunk-mbpb5c7w.js +0 -2
- package/chunk-pnspvnyd.js +0 -2
- package/chunk-pz2afna8.js +0 -2
- package/chunk-qaeyhe65.js +0 -2
- package/chunk-qnkrrwmg.js +0 -2
- package/chunk-v3ee9z3f.js +0 -2
- package/chunk-vtqr7dm8.js +0 -3
- package/chunk-zq32mwxj.js +0 -479
- package/web/chunk-086dshck.js +0 -1
- package/web/chunk-0fy590s0.js +0 -1
- package/web/chunk-0mdf1qja.js +0 -1
- package/web/chunk-0y971zgq.js +0 -2
- package/web/chunk-32zmk3f5.js +0 -1
- package/web/chunk-3d3wnh8a.js +0 -2
- package/web/chunk-48479gnx.js +0 -1
- package/web/chunk-4rwwtfnd.js +0 -2
- package/web/chunk-6cjm2yr7.js +0 -1
- package/web/chunk-7ycxz39p.js +0 -1
- package/web/chunk-8z7texmv.js +0 -1
- package/web/chunk-9jy8nc4r.js +0 -1
- package/web/chunk-9wr33d0t.js +0 -1
- package/web/chunk-a4tdrxdh.js +0 -1
- package/web/chunk-a9fvsyc1.js +0 -1
- package/web/chunk-apvbvg4d.js +0 -1
- package/web/chunk-bkxcc7v5.js +0 -1
- package/web/chunk-bve354k7.js +0 -1
- package/web/chunk-cwpxakby.js +0 -1
- package/web/chunk-d3f763n7.js +0 -2
- package/web/chunk-dtrh40vr.js +0 -1
- package/web/chunk-e68jw0bg.js +0 -1
- package/web/chunk-jd7npyv9.js +0 -8
- package/web/chunk-jhpg2kcf.js +0 -1
- package/web/chunk-jqqbkdtw.js +0 -4
- package/web/chunk-jzz5htxp.js +0 -1
- package/web/chunk-ka3q31t1.js +0 -1
- package/web/chunk-kahab58k.js +0 -1139
- package/web/chunk-krgvx75q.js +0 -1
- package/web/chunk-kxeaj44h.js +0 -1
- package/web/chunk-m1rdyvb5.js +0 -1
- package/web/chunk-m7k4wr3k.js +0 -1
- package/web/chunk-mdj3r75b.js +0 -1
- package/web/chunk-nbcpbqq4.js +0 -1
- package/web/chunk-nkpdd9hw.js +0 -1
- package/web/chunk-p1yc8hwn.js +0 -2
- package/web/chunk-p29brxyt.js +0 -1
- package/web/chunk-p8fbes0t.js +0 -1
- package/web/chunk-pbp1p5ex.js +0 -1
- package/web/chunk-q65zxczs.js +0 -34
- package/web/chunk-r6q1301x.js +0 -1
- package/web/chunk-r8kghrkb.js +0 -1
- package/web/chunk-rhxn7mxg.js +0 -1
- package/web/chunk-rqympya7.js +0 -2
- package/web/chunk-svqshmpg.js +0 -1
- package/web/chunk-swzxq7r3.css +0 -1
- package/web/chunk-t18tn37m.js +0 -2
- package/web/chunk-tbsaseer.js +0 -1
- package/web/chunk-tgkdyxbn.js +0 -1
- package/web/chunk-v0zfnvc1.js +0 -1
- package/web/chunk-vj31fs16.js +0 -1
- package/web/chunk-vr79r8vh.js +0 -1
- package/web/chunk-wb9tax0m.js +0 -1
- package/web/chunk-x9eghjjd.js +0 -1
- package/web/chunk-z3ky5ews.js +0 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{It,Xt,Jt,Yt,Zt,vr,_r,Mt,Ar,Er,Pr,Tr,kr,Rr}from"./chunk-zx75vnw8.js";import{ne}from"./chunk-959z9efn.js";import{X}from"./chunk-2tf7qfbx.js";import{w}from"./chunk-b516bp7n.js";import{j,J}from"./chunk-rn3jwyh1.js";import{we}from"./chunk-tfhp09nj.js";import{W,ge,ae,Ue,Y,V}from"./chunk-y4pvhes1.js";import{D}from"./chunk-szj85dqe.js";var b=0,y=(n,a,t)=>{let o=new D,g=Ue(a);return(async()=>{let e={role:"assistant",content:[],api:"google-generative-ai",provider:n.provider,model:n.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"pending",timestamp:Date.now()};try{if(t?.fetch&&t.fetch!==globalThis.fetch)throw Error("Custom fetch is not supported by the Google Generative AI adapter");let l=t?.apiKey;if(!l)throw Error(`No API key for provider: ${n.provider}`);let c=T(n,l,t?.headers),h=S(n,g,t),k=await t?.onPayload?.(h,n);if(k!==void 0)h=k;let p=await Rr(()=>c.models.generateContentStream(h),t);o.push({type:"start",partial:e});let i=null,f=e.content,u=()=>f.length-1;for await(let s of p){await t?.onProviderStreamEvent?.(s,n),e.responseId||=s.responseId;let m=s.candidates?.[0];if(m?.content?.parts)for(let r of m.content.parts){if(r.text!==void 0){let d=_r(r);if(!i||d&&i.type!=="thinking"||!d&&i.type!=="text"){if(i)if(i.type==="text")o.push({type:"text_end",contentIndex:f.length-1,content:i.text,partial:e});else o.push({type:"thinking_end",contentIndex:u(),content:i.thinking,partial:e});if(d)i={type:"thinking",thinking:"",thinkingSignature:void 0},e.content.push(i),o.push({type:"thinking_start",contentIndex:u(),partial:e});else i={type:"text",text:""},e.content.push(i),o.push({type:"text_start",contentIndex:u(),partial:e})}if(i.type==="thinking")i.thinking+=r.text,i.thinkingSignature=Mt(i.thinkingSignature,r.thoughtSignature),o.push({type:"thinking_delta",contentIndex:u(),delta:r.text,partial:e});else i.text+=r.text,i.textSignature=Mt(i.textSignature,r.thoughtSignature),o.push({type:"text_delta",contentIndex:u(),delta:r.text,partial:e})}if(r.functionCall){if(i){if(i.type==="text")o.push({type:"text_end",contentIndex:u(),content:i.text,partial:e});else o.push({type:"thinking_end",contentIndex:u(),content:i.thinking,partial:e});i=null}let d=r.functionCall.id,C={type:"toolCall",id:!d||e.content.some((x)=>x.type==="toolCall"&&x.id===d)?`${r.functionCall.name}_${Date.now()}_${++b}`:d,name:r.functionCall.name||"",arguments:r.functionCall.args??{},...r.thoughtSignature&&{thoughtSignature:r.thoughtSignature}};e.content.push(C),o.push({type:"toolcall_start",contentIndex:u(),partial:e}),o.push({type:"toolcall_delta",contentIndex:u(),delta:JSON.stringify(C.arguments),partial:e}),o.push({type:"toolcall_end",contentIndex:u(),toolCall:C,partial:e})}}if(m?.finishReason){if(e.rawStopReason=m.finishReason,e.stopReason=kr(m.finishReason),e.content.some((r)=>r.type==="toolCall")&&e.stopReason==="stop")e.stopReason="toolUse"}if(s.usageMetadata)e.usage={input:(s.usageMetadata.promptTokenCount||0)-(s.usageMetadata.cachedContentTokenCount||0),output:(s.usageMetadata.candidatesTokenCount||0)+(s.usageMetadata.thoughtsTokenCount||0),cacheRead:s.usageMetadata.cachedContentTokenCount||0,cacheWrite:0,reasoning:s.usageMetadata.thoughtsTokenCount||0,totalTokens:s.usageMetadata.totalTokenCount||0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},Y(n,e.usage)}if(i)if(i.type==="text")o.push({type:"text_end",contentIndex:u(),content:i.text,partial:e});else o.push({type:"thinking_end",contentIndex:u(),content:i.thinking,partial:e});if(t?.signal?.aborted)throw Error("Request was aborted");if(e.stopReason==="pending")throw Error("Google stream ended without a finish reason");if(e.stopReason==="aborted"||e.stopReason==="error"){let s=e.rawStopReason?`Provider stopped with: ${e.rawStopReason}`:"An unknown error occurred";throw Error(s)}o.push({type:"done",reason:e.stopReason,message:e}),o.end()}catch(l){for(let c of e.content)if("index"in c)delete c.index;e.stopReason=t?.signal?.aborted?"aborted":"error",e.errorMessage=J(j(l)),o.push({type:"error",reason:e.stopReason,error:e}),o.end()}})(),o},K=(n,a,t)=>{let o=t?.apiKey;if(!o)throw Error(`No API key for provider: ${n.provider}`);let g={...X(n,a,t,o),toolChoice:t?.toolChoice};if(!t?.reasoning)return y(n,a,{...g,thinking:{enabled:!1}});let e=V(n,t.reasoning);if(e==="off")return y(n,a,{...g,thinking:{enabled:!1}});let l=Xt(n,e);if(Jt(n))return y(n,a,{...g,thinking:{enabled:!0,level:Yt(l)}});return y(n,a,{...g,thinking:{enabled:!0,budgetTokens:I(n,l,t.thinkingBudgets)}})};function T(n,a,t){let o={};if(n.baseUrl)o.baseUrl=n.baseUrl,o.apiVersion="";let g=we({"User-Agent":ne(),...n.headers,...t});if(g)o.headers=g;return new It({apiKey:a,httpOptions:Object.keys(o).length>0?o:void 0})}function S(n,a,t={}){let o=Ar(n,a),g=ge(a.messages),e=ae(a.messages),l={};if(t.temperature!==void 0)l.temperature=t.temperature;if(t.maxTokens!==void 0)l.maxOutputTokens=t.maxTokens;let c=Pr(n.id),h=e.length>0?Tr(e,t.toolChoice,c):void 0,k=g?W(g):"",p={...Object.keys(l).length>0&&l,...k&&{systemInstruction:w(k)},...e.length>0&&{tools:Er(e,!1,c)},...h!==void 0&&{toolConfig:{functionCallingConfig:{mode:h}}}};if(t.thinking?.enabled&&n.reasoning){let f={includeThoughts:!0};if(t.thinking.level!==void 0)f.thinkingLevel=Zt(t.thinking.level);else if(t.thinking.budgetTokens!==void 0)f.thinkingBudget=t.thinking.budgetTokens;p.thinkingConfig=f}else if(n.reasoning&&t.thinking&&!t.thinking.enabled)p.thinkingConfig=vr(n);if(t.signal){if(t.signal.aborted)throw Error("Request aborted");p.abortSignal=t.signal}return{model:n.id,contents:o,config:p}}function I(n,a,t){if(t?.[a]!==void 0)return t[a];if(n.id.includes("2.5-pro"))return{minimal:128,low:2048,medium:8192,high:32768}[a];if(n.id.includes("2.5-flash-lite"))return{minimal:512,low:2048,medium:8192,high:24576}[a];if(n.id.includes("2.5-flash"))return{minimal:128,low:2048,medium:8192,high:24576}[a];return-1}export{y as stream,K as streamSimple};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{He,at}from"./chunk-6d9r9p91.js";import{qe}from"./chunk-0x9netvr.js";import{je,Te,U}from"./chunk-0nedq669.js";import{_e,Z,x,Ae,ee,Ye,z}from"./chunk-0a7ft50x.js";var{awsEndpointFunctions:Ve,emitWarningIfUnsupportedVersion:ze,createDefaultUserAgentProvider:We,NODE_APP_ID_CONFIG_OPTIONS:Le,getAwsRegionExtensionConfiguration:Be,resolveAwsRegionExtensionConfiguration:Ge,resolveUserAgentConfig:Ke,resolveHostHeaderConfig:Xe,getUserAgentPlugin:Qe,getHostHeaderPlugin:Je,getLoggerPlugin:Ze,getRecursionDetectionPlugin:et}=U(),{NoAuthSigner:tt,getHttpAuthSchemeEndpointRuleSetPlugin:st,DefaultIdentityProviderConfig:nt,getHttpSigningPlugin:ot}=Te(),{normalizeProvider:ae,getSmithyContext:rt,ServiceException:it,NoOpLogger:ct,emitWarningIfUnsupportedVersion:ut,loadConfigsForDefaultMode:pt,getDefaultExtensionConfiguration:dt,resolveDefaultRuntimeConfig:ht,Client:ce,makeBuilder:gt,createAggregatedClient:lt}=Z(),{Command:mt}=Z();var Ls=mt,Bs=ce;var{resolveDefaultsModeConfig:Et,loadConfig:m,NODE_USE_FIPS_ENDPOINT_CONFIG_OPTIONS:At,NODE_USE_DUALSTACK_ENDPOINT_CONFIG_OPTIONS:_t,NODE_REGION_CONFIG_OPTIONS:It,NODE_REGION_CONFIG_FILE_OPTIONS:St,resolveRegionConfig:Ot}=x(),{BinaryDecisionDiagram:Ct,EndpointCache:Rt,decideEndpoint:vt,customEndpointFunctions:Pt,resolveEndpointConfig:Tt,getEndpointPlugin:ft}=Ae(),{parseUrl:kt,getHttpHandlerExtensionConfiguration:xt,resolveHttpHandlerRuntimeConfig:yt,getContentLengthPlugin:Dt}=z(),{DEFAULT_RETRY_MODE:wt,NODE_RETRY_MODE_CONFIG_OPTIONS:Nt,NODE_MAX_ATTEMPT_CONFIG_OPTIONS:$t,resolveRetryConfig:Ut,getRetryPlugin:Ft}=je(),{TypeRegistry:ue,getSchemaSerdePlugin:bt}=_e(),{resolveAwsSdkSigV4Config:qt,AwsSdkSigV4Signer:Mt,NODE_AUTH_SCHEME_PREFERENCE_OPTIONS:Ht}=He(),{toUtf8:Vt,fromUtf8:zt,toBase64:Wt,fromBase64:Lt,calculateBodyLength:Bt}=ee(),{streamCollector:jt,NodeHttpHandler:Gt}=qe(),{AwsRestJsonProtocol:Kt}=at(),{Sha256:Xt}=Ye(),Qt=async(e,s,n)=>({operation:rt(s).operation,region:await ae(e.region)()||(()=>{throw Error("expected `region` to be configured for `aws.auth#sigv4`")})()});function Yt(e){return{schemeId:"aws.auth#sigv4",signingProperties:{name:"signin",region:e.region},propertiesExtractor:(s,n)=>({signingProperties:{config:s,context:n}})}}function Jt(e){return{schemeId:"smithy.api#noAuth"}}var Zt=(e)=>{let s=[];switch(e.operation){case"CreateOAuth2Token":{s.push(Jt());break}default:s.push(Yt(e))}return s},es=(e)=>{let s=qt(e);return Object.assign(s,{authSchemePreference:ae(e.authSchemePreference??[])})},ts=(e)=>Object.assign(e,{useDualstackEndpoint:e.useDualstackEndpoint??!1,useFipsEndpoint:e.useFipsEndpoint??!1,defaultSigningName:"signin"}),ss={UseFIPS:{type:"builtInParams",name:"useFipsEndpoint"},Endpoint:{type:"builtInParams",name:"endpoint"},Region:{type:"builtInParams",name:"region"},UseDualStack:{type:"builtInParams",name:"useDualstackEndpoint"}},ns="3.997.47",os={version:ns},h="ref",p=-1,L=!1,E=!0,B="isSet",A="booleanEquals",j="coalesce",F="PartitionResult",u="stringEquals",k="getAttr",G="https://signin.{Region}.{PartitionResult#dualStackDnsSuffix}",K={[h]:"Endpoint"},d={fn:k,argv:[{[h]:F},"name"]},pe={[h]:"Region"},X={[h]:F},S={authSchemes:[{name:"sigv4",signingName:"signin",signingRegion:"{Region}"}]},r={},Q=[pe],Y={conditions:[[B,Q],[A,[{fn:j,argv:[{[h]:"IsControlPlane"},L]},E]],[B,[K]],["aws.partition",Q,F],[A,[{[h]:"UseFIPS"},E]],[u,[d,"aws"]],[A,[{fn:j,argv:[{[h]:"IsOAuthEndpoint"},L]},E]],[A,[{[h]:"UseDualStack"},E]],[u,[d,"aws-cn"]],[u,[pe,"us-gov-west-1"]],[u,[d,"aws-us-gov"]],[A,[{fn:k,argv:[X,"supportsFIPS"]},E]],[u,[d,"aws-iso"]],[u,[d,"aws-iso-b"]],[u,[d,"aws-iso-f"]],[u,[d,"aws-iso-e"]],[u,[d,"aws-eusc"]],[A,[{fn:k,argv:[X,"supportsDualStack"]},E]]],results:[[p],["https://signin.{Region}.api.aws",S],["https://signin.{Region}.api.amazonwebservices.com.cn",S],[G,S],[p,"FIPS endpoints are not supported for OAuth operations. Disable FIPS or use a non-OAuth operation."],["https://{Region}.oauth.signin.aws",S],["https://{Region}.signin.aws.amazon.com",r],["https://{Region}.signin.amazonaws.cn",r],["https://{Region}.signin.amazonaws-us-gov.com",r],["https://{Region}.signin.c2shome.ic.gov",r],["https://{Region}.signin.sc2shome.sgov.gov",r],["https://{Region}.signin.csphome.hci.ic.gov",r],["https://{Region}.signin.csphome.adc-e.uk",r],["https://{Region}.signin.amazonaws-eusc.eu",r],["https://signin-fips.amazonaws-us-gov.com",r],["https://{Region}.signin-fips.amazonaws-us-gov.com",r],["https://{Region}.signin.{PartitionResult#dnsSuffix}",r],[p,"Invalid Configuration: FIPS and custom endpoint are not supported"],[p,"Invalid Configuration: Dualstack and custom endpoint are not supported"],[K,r],["https://signin-fips.{Region}.{PartitionResult#dualStackDnsSuffix}",r],[p,"FIPS and DualStack are enabled, but this partition does not support one or both"],["https://signin-fips.{Region}.{PartitionResult#dnsSuffix}",r],[p,"FIPS is enabled but this partition does not support FIPS"],[G,r],[p,"DualStack is enabled but this partition does not support DualStack"],["https://signin.{Region}.{PartitionResult#dnsSuffix}",r],[p,"Invalid Configuration: Missing Region"]]},rs=2,t=1e8,is=new Int32Array([-1,1,-1,0,6,3,2,36,4,4,5,t+27,6,t+4,t+27,1,29,7,2,36,8,3,9,31,4,22,10,5,19,11,7,21,12,8,t+7,13,10,t+8,14,12,t+9,15,13,t+10,16,14,t+11,17,15,t+12,18,16,t+13,t+16,6,t+5,20,7,21,t+6,17,t+24,t+25,6,t+4,23,7,27,24,9,t+14,25,10,t+15,26,11,t+22,t+23,11,28,t+21,17,t+20,t+21,2,35,30,3,39,31,4,32,t+27,6,t+4,33,7,t+27,34,9,t+14,t+27,3,39,36,4,38,37,7,t+18,t+19,6,t+4,t+17,5,t+1,40,8,t+2,t+3]),as=Ct.from(is,rs,Y.conditions,Y.results),cs=new Rt({size:50,params:["Endpoint","IsControlPlane","IsOAuthEndpoint","Region","UseDualStack","UseFIPS"]}),us=(e,s={})=>cs.get(e,()=>vt(as,{endpointParams:e,logger:s.logger}));Pt.aws=Ve;class l extends it{static shapeId="smithy.ts.sdk.synthetic.com.amazonaws.signin#SigninServiceException";constructor(e){super(e);Object.setPrototypeOf(this,l.prototype)}}class C extends l{static shapeId="com.amazonaws.signin#AccessDeniedException";name="AccessDeniedException";$fault="client";error;constructor(e){super({name:"AccessDeniedException",$fault:"client",...e});Object.setPrototypeOf(this,C.prototype),this.error=e.error}}class R extends l{static shapeId="com.amazonaws.signin#InternalServerException";name="InternalServerException";$fault="server";error;constructor(e){super({name:"InternalServerException",$fault:"server",...e});Object.setPrototypeOf(this,R.prototype),this.error=e.error}}class v extends l{static shapeId="com.amazonaws.signin#TooManyRequestsError";name="TooManyRequestsError";$fault="client";error;constructor(e){super({name:"TooManyRequestsError",$fault:"client",...e});Object.setPrototypeOf(this,v.prototype),this.error=e.error}}class P extends l{static shapeId="com.amazonaws.signin#ValidationException";name="ValidationException";$fault="client";error;constructor(e){super({name:"ValidationException",$fault:"client",...e});Object.setPrototypeOf(this,P.prototype),this.error=e.error}}var ps="AccessDeniedException",ds="AccessToken",hs="CreateOAuth2Token",gs="CreateOAuth2TokenRequest",ls="CreateOAuth2TokenRequestBody",ms="CreateOAuth2TokenResponseBody",Es="CreateOAuth2TokenResponse",As="CreateOAuth2TokenWithIAM",_s="CreateOAuth2TokenWithIAMRequest",Is="CreateOAuth2TokenWithIAMResponse",Ss="InternalServerException",Os="OAuthAccessToken",Cs="RefreshToken",Rs="TooManyRequestsError",vs="ValidationException",J="accessKeyId",y="accessToken",Ps="access_token",b="client",te="clientId",se="codeVerifier",Ts="code",g="error",D="expiresIn",fs="expires_in",w="grantType",ks="grant_type",de="http",q="httpError",ne="idToken",o="jsonName",T="message",xs="resource",O="refreshToken",oe="redirectUri",he="smithy.ts.sdk.synthetic.com.amazonaws.signin",re="secretAccessKey",ie="sessionToken",ys="server",Ds="tokenInput",ws="tokenOutput",N="tokenType",Ns="token_type",i="com.amazonaws.signin",ge=new ue(he),le=[-3,he,"SigninServiceException",0,[],[]];ge.registerError(le,l);var _=new ue(i),me=[-3,i,ps,{[g]:b},[g,T],[0,0],2];_.registerError(me,C);var Ee=[-3,i,Ss,{[g]:ys,[q]:500},[g,T],[0,0],2];_.registerError(Ee,R);var Ie=[-3,i,Rs,{[g]:b,[q]:429},[g,T],[0,0],2];_.registerError(Ie,v);var Se=[-3,i,vs,{[g]:b,[q]:400},[g,T],[0,0],2];_.registerError(Se,P);var Oe=[ge,_],$s=[0,i,Os,8,0],Ce=[0,i,Cs,8,0],Re=[3,i,ds,8,[J,re,ie],[[0,{[o]:J}],[0,{[o]:re}],[0,{[o]:ie}]],3],ve=[3,i,gs,0,[Ds],[[()=>Pe,16]],1],Pe=[3,i,ls,0,[te,w,Ts,oe,se,O],[[0,{[o]:te}],[0,{[o]:w}],0,[0,{[o]:oe}],[0,{[o]:se}],[()=>Ce,{[o]:O}]],2],fe=[3,i,Es,0,[ws],[[()=>ke,16]],1],ke=[3,i,ms,0,[y,N,D,O,ne],[[()=>Re,{[o]:y}],[0,{[o]:N}],[1,{[o]:D}],[()=>Ce,{[o]:O}],[0,{[o]:ne}]],4],xe=[3,i,_s,0,[w,xs],[[0,{[o]:ks}],0],2],ye=[3,i,Is,0,[y,N,D],[[()=>$s,{[o]:Ps}],[0,{[o]:Ns}],[1,{[o]:fs}]],3],De=[9,i,hs,{[de]:["POST","/v1/token",200]},()=>ve,()=>fe],we=[9,i,As,{[de]:["POST","/v1/token?x-amz-client-auth-method=iam",200]},()=>xe,()=>ye],Us=(e)=>({apiVersion:"2023-01-01",base64Decoder:e?.base64Decoder??Lt,base64Encoder:e?.base64Encoder??Wt,disableHostPrefix:e?.disableHostPrefix??!1,endpointProvider:e?.endpointProvider??us,extensions:e?.extensions??[],httpAuthSchemeProvider:e?.httpAuthSchemeProvider??Zt,httpAuthSchemes:e?.httpAuthSchemes??[{schemeId:"aws.auth#sigv4",identityProvider:(s)=>s.getIdentityProvider("aws.auth#sigv4"),signer:new Mt},{schemeId:"smithy.api#noAuth",identityProvider:(s)=>s.getIdentityProvider("smithy.api#noAuth")||(async()=>({})),signer:new tt}],logger:e?.logger??new ct,protocol:e?.protocol??Kt,protocolSettings:e?.protocolSettings??{defaultNamespace:"com.amazonaws.signin",errorTypeRegistries:Oe,version:"2023-01-01",serviceTarget:"Signin"},serviceId:e?.serviceId??"Signin",sha256:e?.sha256??Xt,urlParser:e?.urlParser??kt,utf8Decoder:e?.utf8Decoder??zt,utf8Encoder:e?.utf8Encoder??Vt}),Fs=(e)=>{ut(process.version);let s=Et(e),n=()=>s().then(pt),c=Us(e);ze(process.version);let a={profile:e?.profile,logger:c.logger};return{...c,...e,runtime:"node",defaultsMode:s,authSchemePreference:e?.authSchemePreference??m(Ht,a),bodyLengthChecker:e?.bodyLengthChecker??Bt,defaultUserAgentProvider:e?.defaultUserAgentProvider??We({serviceId:c.serviceId,clientVersion:os.version}),maxAttempts:e?.maxAttempts??m($t,e),region:e?.region??m(It,{...St,...a}),requestHandler:Gt.create(e?.requestHandler??n),retryMode:e?.retryMode??m({...Nt,default:async()=>(await n()).retryMode||wt},e),streamCollector:e?.streamCollector??jt,useDualstackEndpoint:e?.useDualstackEndpoint??m(_t,a),useFipsEndpoint:e?.useFipsEndpoint??m(At,a),userAgentAppId:e?.userAgentAppId??m(Le,a)}},bs=(e)=>{let{httpAuthSchemes:s,httpAuthSchemeProvider:n,credentials:c}=e;return{setHttpAuthScheme(a){let I=s.findIndex((f)=>f.schemeId===a.schemeId);if(I===-1)s.push(a);else s.splice(I,1,a)},httpAuthSchemes(){return s},setHttpAuthSchemeProvider(a){n=a},httpAuthSchemeProvider(){return n},setCredentials(a){c=a},credentials(){return c}}},qs=(e)=>({httpAuthSchemes:e.httpAuthSchemes(),httpAuthSchemeProvider:e.httpAuthSchemeProvider(),credentials:e.credentials()}),Ms=(e,s)=>{let n=Object.assign(Be(e),dt(e),xt(e),bs(e));return s.forEach((c)=>c.configure(n)),Object.assign(e,Ge(n),ht(n),yt(n),qs(n))};class M extends ce{config;constructor(...[e]){let s=Fs(e||{});super(s);this.initConfig=s;let n=ts(s),c=Ke(n),a=Ut(c),I=Ot(a),f=Xe(I),Ue=Tt(f),Fe=es(Ue),be=Ms(Fe,e?.extensions||[]);this.config=be,this.middlewareStack.use(bt(this.config)),this.middlewareStack.use(Qe(this.config)),this.middlewareStack.use(Ft(this.config)),this.middlewareStack.use(Dt(this.config)),this.middlewareStack.use(Je(this.config)),this.middlewareStack.use(Ze(this.config)),this.middlewareStack.use(et(this.config)),this.middlewareStack.use(st(this.config,{httpAuthSchemeParametersProvider:Qt,identityProviderConfigProvider:async(Me)=>new nt({"aws.auth#sigv4":Me.credentials})})),this.middlewareStack.use(ot(this.config))}destroy(){super.destroy()}}var Ne=gt(ss,"Signin","SigninClient",ft),Hs={IsControlPlane:{type:"staticContextParams",value:!1}},Vs={IsOAuthEndpoint:{type:"staticContextParams",value:!0}},$e=(e,s,n,c)=>[];class H extends Ne(Hs,$e,"CreateOAuth2Token",De){}class V extends Ne(Vs,$e,"CreateOAuth2TokenWithIAM",we){}var zs={CreateOAuth2TokenCommand:H,CreateOAuth2TokenWithIAMCommand:V};class W extends M{}lt(zs,W);var Ws={AUTHCODE_EXPIRED:"AUTHCODE_EXPIRED",CONFLICT:"CONFLICT",INSUFFICIENT_PERMISSIONS:"INSUFFICIENT_PERMISSIONS",INVALID_REQUEST:"INVALID_REQUEST",RESOURCE_NOT_FOUND:"RESOURCE_NOT_FOUND",SERVER_ERROR:"server_error",SERVICE_QUOTA_EXCEEDED:"SERVICE_QUOTA_EXCEEDED",TOKEN_EXPIRED:"TOKEN_EXPIRED",USER_CREDENTIALS_CHANGED:"USER_CREDENTIALS_CHANGED"};var js=C,Gs=me,Ks=Re,Xs=De,Qs=H,Ys=ve,Js=Pe,Zs=fe,en=ke,tn=we,sn=V,nn=xe,on=ye,rn=R,an=Ee,cn=Ws,un=W,pn=M,dn=l,hn=le,gn=v,ln=Ie,mn=P,En=Se,An=Oe;export{Ls as $Command,Bs as __Client,js as AccessDeniedException,Gs as AccessDeniedException$,Ks as AccessToken$,Xs as CreateOAuth2Token$,Qs as CreateOAuth2TokenCommand,Ys as CreateOAuth2TokenRequest$,Js as CreateOAuth2TokenRequestBody$,Zs as CreateOAuth2TokenResponse$,en as CreateOAuth2TokenResponseBody$,tn as CreateOAuth2TokenWithIAM$,sn as CreateOAuth2TokenWithIAMCommand,nn as CreateOAuth2TokenWithIAMRequest$,on as CreateOAuth2TokenWithIAMResponse$,rn as InternalServerException,an as InternalServerException$,cn as OAuth2ErrorCode,un as Signin,pn as SigninClient,dn as SigninServiceException,hn as SigninServiceException$,gn as TooManyRequestsError,ln as TooManyRequestsError$,mn as ValidationException,En as ValidationException$,An as errorTypeRegistries};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{He,at}from"./chunk-6d9r9p91.js";import{qe}from"./chunk-0x9netvr.js";import{je,Te,U}from"./chunk-0nedq669.js";import{_e,Z,x,Ae,ee,Ye,z}from"./chunk-0a7ft50x.js";var{awsEndpointFunctions:Y,emitWarningIfUnsupportedVersion:J,createDefaultUserAgentProvider:X,NODE_APP_ID_CONFIG_OPTIONS:te,getAwsRegionExtensionConfiguration:se,resolveAwsRegionExtensionConfiguration:oe,resolveUserAgentConfig:ne,resolveHostHeaderConfig:re,getUserAgentPlugin:ie,getHostHeaderPlugin:ae,getLoggerPlugin:ce,getRecursionDetectionPlugin:ue}=U(),{NoAuthSigner:de,getHttpAuthSchemeEndpointRuleSetPlugin:pe,DefaultIdentityProviderConfig:le,getHttpSigningPlugin:he}=Te(),{normalizeProvider:F,getSmithyContext:ge,ServiceException:me,NoOpLogger:Se,emitWarningIfUnsupportedVersion:Ee,loadConfigsForDefaultMode:fe,getDefaultExtensionConfiguration:Pe,resolveDefaultRuntimeConfig:ve,Client:Re,makeBuilder:xe,createAggregatedClient:Ce}=Z(),{Command:Es}=Z();var{resolveDefaultsModeConfig:Ie,loadConfig:a,NODE_USE_FIPS_ENDPOINT_CONFIG_OPTIONS:ye,NODE_USE_DUALSTACK_ENDPOINT_CONFIG_OPTIONS:Oe,NODE_REGION_CONFIG_OPTIONS:we,NODE_REGION_CONFIG_FILE_OPTIONS:Ne,resolveRegionConfig:De}=x(),{BinaryDecisionDiagram:ke,EndpointCache:be,decideEndpoint:Fe,customEndpointFunctions:$e,resolveEndpointConfig:Ue,getEndpointPlugin:Ge}=Ae(),{parseUrl:Me,getHttpHandlerExtensionConfiguration:ze,resolveHttpHandlerRuntimeConfig:Le,getContentLengthPlugin:Ke}=z(),{DEFAULT_RETRY_MODE:Ve,NODE_RETRY_MODE_CONFIG_OPTIONS:Be,NODE_MAX_ATTEMPT_CONFIG_OPTIONS:We,resolveRetryConfig:Qe,getRetryPlugin:Je}=je(),{TypeRegistry:q,getSchemaSerdePlugin:Xe}=_e(),{resolveAwsSdkSigV4Config:Ze,AwsSdkSigV4Signer:et,NODE_AUTH_SCHEME_PREFERENCE_OPTIONS:tt}=He(),{toUtf8:st,fromUtf8:ot,toBase64:nt,fromBase64:rt,calculateBodyLength:it}=ee(),{streamCollector:ct,NodeHttpHandler:ut}=qe(),{AwsRestJsonProtocol:dt}=at(),{Sha256:pt}=Ye(),lt=async(e,t,s)=>({operation:ge(t).operation,region:await F(e.region)()||(()=>{throw Error("expected `region` to be configured for `aws.auth#sigv4`")})()});function ht(e){return{schemeId:"aws.auth#sigv4",signingProperties:{name:"awsssoportal",region:e.region},propertiesExtractor:(t,s)=>({signingProperties:{config:t,context:s}})}}function gt(e){return{schemeId:"smithy.api#noAuth"}}var mt=(e)=>{let t=[];switch(e.operation){case"GetRoleCredentials":{t.push(gt());break}default:t.push(ht(e))}return t},St=(e)=>{let t=Ze(e);return Object.assign(t,{authSchemePreference:F(e.authSchemePreference??[])})},_t=(e)=>Object.assign(e,{useDualstackEndpoint:e.useDualstackEndpoint??!1,useFipsEndpoint:e.useFipsEndpoint??!1,defaultSigningName:"awsssoportal"}),Et={UseFIPS:{type:"builtInParams",name:"useFipsEndpoint"},Endpoint:{type:"builtInParams",name:"endpoint"},Region:{type:"builtInParams",name:"region"},UseDualStack:{type:"builtInParams",name:"useDualstackEndpoint"}},ft="3.997.47",Pt={version:ft},p="ref",c=-1,g=!0,T="isSet",H="PartitionResult",m="booleanEquals",v="getAttr",N={[p]:"Endpoint"},R={[p]:H},d={},D=[{[p]:"Region"}],k={conditions:[[T,[N]],[T,D],["aws.partition",D,H],[m,[{[p]:"UseFIPS"},g]],[m,[{[p]:"UseDualStack"},g]],[m,[{fn:v,argv:[R,"supportsDualStack"]},g]],[m,[{fn:v,argv:[R,"supportsFIPS"]},g]],["stringEquals",[{fn:v,argv:[R,"name"]},"aws-us-gov"]]],results:[[c],[c,"Invalid Configuration: FIPS and custom endpoint are not supported"],[c,"Invalid Configuration: Dualstack and custom endpoint are not supported"],[N,d],["https://portal.sso-fips.{Region}.{PartitionResult#dualStackDnsSuffix}",d],[c,"FIPS and DualStack are enabled, but this partition does not support one or both"],["https://portal.sso.{Region}.amazonaws.com",d],["https://portal.sso-fips.{Region}.{PartitionResult#dnsSuffix}",d],[c,"FIPS is enabled but this partition does not support FIPS"],["https://portal.sso.{Region}.{PartitionResult#dualStackDnsSuffix}",d],[c,"DualStack is enabled but this partition does not support DualStack"],["https://portal.sso.{Region}.{PartitionResult#dnsSuffix}",d],[c,"Invalid Configuration: Missing Region"]]},vt=2,n=1e8,Rt=new Int32Array([-1,1,-1,0,13,3,1,4,n+12,2,5,n+12,3,8,6,4,7,n+11,5,n+9,n+10,4,11,9,6,10,n+8,7,n+6,n+7,5,12,n+5,6,n+4,n+5,3,n+1,14,4,n+2,n+3]),xt=ke.from(Rt,vt,k.conditions,k.results),Ct=new be({size:50,params:["Endpoint","Region","UseDualStack","UseFIPS"]}),It=(e,t={})=>Ct.get(e,()=>Fe(xt,{endpointParams:e,logger:t.logger}));$e.aws=Y;class u extends me{static shapeId="smithy.ts.sdk.synthetic.com.amazonaws.sso#SSOServiceException";constructor(e){super(e);Object.setPrototypeOf(this,u.prototype)}}class C extends u{static shapeId="com.amazonaws.sso#InvalidRequestException";name="InvalidRequestException";$fault="client";constructor(e){super({name:"InvalidRequestException",$fault:"client",...e});Object.setPrototypeOf(this,C.prototype)}}class I extends u{static shapeId="com.amazonaws.sso#ResourceNotFoundException";name="ResourceNotFoundException";$fault="client";constructor(e){super({name:"ResourceNotFoundException",$fault:"client",...e});Object.setPrototypeOf(this,I.prototype)}}class y extends u{static shapeId="com.amazonaws.sso#TooManyRequestsException";name="TooManyRequestsException";$fault="client";constructor(e){super({name:"TooManyRequestsException",$fault:"client",...e});Object.setPrototypeOf(this,y.prototype)}}class A extends u{static shapeId="com.amazonaws.sso#UnauthorizedException";name="UnauthorizedException";$fault="client";constructor(e){super({name:"UnauthorizedException",$fault:"client",...e});Object.setPrototypeOf(this,A.prototype)}}var yt="AccessTokenType",At="GetRoleCredentials",Ot="GetRoleCredentialsRequest",wt="GetRoleCredentialsResponse",Tt="InvalidRequestException",Nt="RoleCredentials",Dt="ResourceNotFoundException",kt="SecretAccessKeyType",bt="SessionTokenType",Ft="TooManyRequestsException",qt="UnauthorizedException",$t="accountId",Ht="accessKeyId",Ut="accessToken",Gt="account_id",S="client",_="error",Mt="expiration",zt="http",E="httpError",jt="httpHeader",b="httpQuery",f="message",Lt="roleCredentials",Kt="roleName",Vt="role_name",G="smithy.ts.sdk.synthetic.com.amazonaws.sso",Bt="secretAccessKey",Wt="sessionToken",Qt="x-amz-sso_bearer_token",r="com.amazonaws.sso",M=new q(G),Yt=[-3,G,"SSOServiceException",0,[],[]];M.registerError(Yt,u);var l=new q(r),Jt=[-3,r,Tt,{[_]:S,[E]:400},[f],[0]];l.registerError(Jt,C);var Xt=[-3,r,Dt,{[_]:S,[E]:404},[f],[0]];l.registerError(Xt,I);var Zt=[-3,r,Ft,{[_]:S,[E]:429},[f],[0]];l.registerError(Zt,y);var es=[-3,r,qt,{[_]:S,[E]:401},[f],[0]];l.registerError(es,A);var ts=[M,l],ss=[0,r,yt,8,0],os=[0,r,kt,8,0],ns=[0,r,bt,8,0],rs=[3,r,Ot,0,[Kt,$t,Ut],[[0,{[b]:Vt}],[0,{[b]:Gt}],[()=>ss,{[jt]:Qt}]],3],is=[3,r,wt,0,[Lt],[[()=>as,0]]],as=[3,r,Nt,0,[Ht,Bt,Wt,Mt],[0,[()=>os,0],[()=>ns,0],1]],cs=[9,r,At,{[zt]:["GET","/federation/credentials",200]},()=>rs,()=>is],us=(e)=>({apiVersion:"2019-06-10",base64Decoder:e?.base64Decoder??rt,base64Encoder:e?.base64Encoder??nt,disableHostPrefix:e?.disableHostPrefix??!1,endpointProvider:e?.endpointProvider??It,extensions:e?.extensions??[],httpAuthSchemeProvider:e?.httpAuthSchemeProvider??mt,httpAuthSchemes:e?.httpAuthSchemes??[{schemeId:"aws.auth#sigv4",identityProvider:(t)=>t.getIdentityProvider("aws.auth#sigv4"),signer:new et},{schemeId:"smithy.api#noAuth",identityProvider:(t)=>t.getIdentityProvider("smithy.api#noAuth")||(async()=>({})),signer:new de}],logger:e?.logger??new Se,protocol:e?.protocol??dt,protocolSettings:e?.protocolSettings??{defaultNamespace:"com.amazonaws.sso",errorTypeRegistries:ts,version:"2019-06-10",serviceTarget:"SWBPortalService"},serviceId:e?.serviceId??"SSO",sha256:e?.sha256??pt,urlParser:e?.urlParser??Me,utf8Decoder:e?.utf8Decoder??ot,utf8Encoder:e?.utf8Encoder??st}),ds=(e)=>{Ee(process.version);let t=Ie(e),s=()=>t().then(fe),i=us(e);J(process.version);let o={profile:e?.profile,logger:i.logger};return{...i,...e,runtime:"node",defaultsMode:t,authSchemePreference:e?.authSchemePreference??a(tt,o),bodyLengthChecker:e?.bodyLengthChecker??it,defaultUserAgentProvider:e?.defaultUserAgentProvider??X({serviceId:i.serviceId,clientVersion:Pt.version}),maxAttempts:e?.maxAttempts??a(We,e),region:e?.region??a(we,{...Ne,...o}),requestHandler:ut.create(e?.requestHandler??s),retryMode:e?.retryMode??a({...Be,default:async()=>(await s()).retryMode||Ve},e),streamCollector:e?.streamCollector??ct,useDualstackEndpoint:e?.useDualstackEndpoint??a(Oe,o),useFipsEndpoint:e?.useFipsEndpoint??a(ye,o),userAgentAppId:e?.userAgentAppId??a(te,o)}},ps=(e)=>{let{httpAuthSchemes:t,httpAuthSchemeProvider:s,credentials:i}=e;return{setHttpAuthScheme(o){let h=t.findIndex((P)=>P.schemeId===o.schemeId);if(h===-1)t.push(o);else t.splice(h,1,o)},httpAuthSchemes(){return t},setHttpAuthSchemeProvider(o){s=o},httpAuthSchemeProvider(){return s},setCredentials(o){i=o},credentials(){return i}}},ls=(e)=>({httpAuthSchemes:e.httpAuthSchemes(),httpAuthSchemeProvider:e.httpAuthSchemeProvider(),credentials:e.credentials()}),hs=(e,t)=>{let s=Object.assign(se(e),Pe(e),ze(e),ps(e));return t.forEach((i)=>i.configure(s)),Object.assign(e,oe(s),ve(s),Le(s),ls(s))};class O extends Re{config;constructor(...[e]){let t=ds(e||{});super(t);this.initConfig=t;let s=_t(t),i=ne(s),o=Qe(i),h=De(o),P=re(h),V=Ue(P),B=St(V),W=hs(B,e?.extensions||[]);this.config=W,this.middlewareStack.use(Xe(this.config)),this.middlewareStack.use(ie(this.config)),this.middlewareStack.use(Je(this.config)),this.middlewareStack.use(Ke(this.config)),this.middlewareStack.use(ae(this.config)),this.middlewareStack.use(ce(this.config)),this.middlewareStack.use(ue(this.config)),this.middlewareStack.use(pe(this.config,{httpAuthSchemeParametersProvider:lt,identityProviderConfigProvider:async(Q)=>new le({"aws.auth#sigv4":Q.credentials})})),this.middlewareStack.use(he(this.config))}destroy(){super.destroy()}}var gs=xe(Et,"SWBPortalService","SSOClient",Ge),ms={},Ss=(e,t,s,i)=>[];class w extends gs(ms,Ss,"GetRoleCredentials",cs){}var _s={GetRoleCredentialsCommand:w};class j extends O{}Ce(_s,j);var L=w;var K=O;export{L as GetRoleCredentialsCommand,K as SSOClient};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
3
|
-
`).some((n)=>n.indexOf("(https.js:")!==-1||n.indexOf("node:https:")!==-1)}incrementSockets(e){if(this.maxSockets===1/0&&this.maxTotalSockets===1/0)return null;if(!this.sockets[e])this.sockets[e]=[];let t=new ue.Socket({writable:!1});return this.sockets[e].push(t),this.totalSocketCount++,t}decrementSockets(e,t){if(!this.sockets[e]||t===null)return;let n=this.sockets[e],o=n.indexOf(t);if(o!==-1){if(n.splice(o,1),this.totalSocketCount--,n.length===0)delete this.sockets[e]}}getName(e){if(this.isSecureEndpoint(e))return R.Agent.prototype.getName.call(this,e);return super.getName(e)}createSocket(e,t,n){let o={...t,secureEndpoint:this.isSecureEndpoint(t)},s=this.getName(o),a=this.incrementSockets(s);Promise.resolve().then(()=>this.connect(e,o)).then((i)=>{if(this.decrementSockets(s,a),i instanceof H.Agent)try{return i.addRequest(e,o)}catch(_){return n(_)}this[d].currentSocket=i,super.createSocket(e,t,n)},(i)=>{this.decrementSockets(s,a),n(i)})}createConnection(){let e=this[d].currentSocket;if(this[d].currentSocket=void 0,!e)throw Error("No socket was returned in the `connect()` function");return e}get defaultPort(){return this[d].defaultPort??(this.protocol==="https:"?443:80)}set defaultPort(e){if(this[d])this[d].defaultPort=e}get protocol(){return this[d].protocol??(this.isSecureEndpoint()?"https:":"http:")}set protocol(e){if(this[d])this[d].protocol=e}}u.Agent=k});var z=r(function(g){var ae=g&&g.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(g,"__esModule",{value:!0});g.parseProxyResponse=void 0;var fe=ae(
|
|
2
|
+
import{Wt}from"./chunk-6sea12mw.js";import{r,p}from"./chunk-ydzag81d.js";var T=r(function(c){var ee=c&&c.__createBinding||(Object.create?function(e,t,n,o){if(o===void 0)o=n;var s=Object.getOwnPropertyDescriptor(t,n);if(!s||("get"in s?!t.__esModule:s.writable||s.configurable))s={enumerable:!0,get:function(){return t[n]}};Object.defineProperty(e,o,s)}:function(e,t,n,o){if(o===void 0)o=n;e[o]=t[n]}),te=c&&c.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),B=c&&c.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null){for(var n in e)if(n!=="default"&&Object.prototype.hasOwnProperty.call(e,n))ee(t,e,n)}return te(t,e),t};Object.defineProperty(c,"__esModule",{value:!0});c.req=c.json=c.toBuffer=void 0;var re=B(p("http")),ne=B(p("https"));async function D(e){let t=0,n=[];for await(let o of e)t+=o.length,n.push(o);return Buffer.concat(n,t)}c.toBuffer=D;async function oe(e){let n=(await D(e)).toString("utf8");try{return JSON.parse(n)}catch(o){let s=o;throw s.message+=` (input: ${n})`,s}}c.json=oe;function se(e,t={}){let o=((typeof e==="string"?e:e.href).startsWith("https:")?ne:re).request(e,t),s=new Promise((a,i)=>{o.once("response",a).once("error",i).end()});return o.then=s.then.bind(s),o}c.req=se});var U=r(function(u){var I=u&&u.__createBinding||(Object.create?function(e,t,n,o){if(o===void 0)o=n;var s=Object.getOwnPropertyDescriptor(t,n);if(!s||("get"in s?!t.__esModule:s.writable||s.configurable))s={enumerable:!0,get:function(){return t[n]}};Object.defineProperty(e,o,s)}:function(e,t,n,o){if(o===void 0)o=n;e[o]=t[n]}),ie=u&&u.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),L=u&&u.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null){for(var n in e)if(n!=="default"&&Object.prototype.hasOwnProperty.call(e,n))I(t,e,n)}return ie(t,e),t},ce=u&&u.__exportStar||function(e,t){for(var n in e)if(n!=="default"&&!Object.prototype.hasOwnProperty.call(t,n))I(t,e,n)};Object.defineProperty(u,"__esModule",{value:!0});u.Agent=void 0;var ue=L(p("net")),H=L(p("http")),R=p("https");ce(T(),u);var d=Symbol("AgentBaseInternalState");class k extends H.Agent{constructor(e){super(e);this[d]={}}isSecureEndpoint(e){if(e){if(typeof e.secureEndpoint==="boolean")return e.secureEndpoint;if(typeof e.protocol==="string")return e.protocol==="https:"}let{stack:t}=Error();if(typeof t!=="string")return!1;return t.split(`
|
|
3
|
+
`).some((n)=>n.indexOf("(https.js:")!==-1||n.indexOf("node:https:")!==-1)}incrementSockets(e){if(this.maxSockets===1/0&&this.maxTotalSockets===1/0)return null;if(!this.sockets[e])this.sockets[e]=[];let t=new ue.Socket({writable:!1});return this.sockets[e].push(t),this.totalSocketCount++,t}decrementSockets(e,t){if(!this.sockets[e]||t===null)return;let n=this.sockets[e],o=n.indexOf(t);if(o!==-1){if(n.splice(o,1),this.totalSocketCount--,n.length===0)delete this.sockets[e]}}getName(e){if(this.isSecureEndpoint(e))return R.Agent.prototype.getName.call(this,e);return super.getName(e)}createSocket(e,t,n){let o={...t,secureEndpoint:this.isSecureEndpoint(t)},s=this.getName(o),a=this.incrementSockets(s);Promise.resolve().then(()=>this.connect(e,o)).then((i)=>{if(this.decrementSockets(s,a),i instanceof H.Agent)try{return i.addRequest(e,o)}catch(_){return n(_)}this[d].currentSocket=i,super.createSocket(e,t,n)},(i)=>{this.decrementSockets(s,a),n(i)})}createConnection(){let e=this[d].currentSocket;if(this[d].currentSocket=void 0,!e)throw Error("No socket was returned in the `connect()` function");return e}get defaultPort(){return this[d].defaultPort??(this.protocol==="https:"?443:80)}set defaultPort(e){if(this[d])this[d].defaultPort=e}get protocol(){return this[d].protocol??(this.isSecureEndpoint()?"https:":"http:")}set protocol(e){if(this[d])this[d].protocol=e}}u.Agent=k});var z=r(function(g){var ae=g&&g.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(g,"__esModule",{value:!0});g.parseProxyResponse=void 0;var fe=ae(Wt()),S=(0,fe.default)("https-proxy-agent:parse-proxy-response");function le(e){return new Promise((t,n)=>{let o=0,s=[];function a(){let h=e.read();if(h)j(h);else e.once("readable",a)}function i(){e.removeListener("end",_),e.removeListener("error",y),e.removeListener("readable",a)}function _(){i(),S("onend"),n(Error("Proxy connection ended before receiving CONNECT response"))}function y(h){i(),S("onerror %o",h),n(h)}function j(h){s.push(h),o+=h.length;let f=Buffer.concat(s,o),M=f.indexOf(`\r
|
|
4
4
|
\r
|
|
5
5
|
`);if(M===-1){S("have not received end of HTTP headers yet..."),a();return}let q=f.slice(0,M).toString("ascii").split(`\r
|
|
6
|
-
`),C=q.shift();if(!C)return e.destroy(),n(Error("No header received from proxy CONNECT response"));let A=C.split(" "),Y=+A[1],Z=A.slice(2).join(" "),b={};for(let v of q){if(!v)continue;let E=v.indexOf(":");if(E===-1)return e.destroy(),n(Error(`Invalid header from proxy CONNECT response: "${v}"`));let m=v.slice(0,E).toLowerCase(),N=v.slice(E+1).trimStart(),P=b[m];if(typeof P==="string")b[m]=[P,N];else if(Array.isArray(P))P.push(N);else b[m]=N}S("got proxy server response: %o %o",C,b),i(),t({connect:{statusCode:Y,statusText:Z,headers:b},buffered:f})}e.on("error",y),e.on("end",_),a()})}g.parseProxyResponse=le});var ge=r(function(l){var he=l&&l.__createBinding||(Object.create?function(e,t,n,o){if(o===void 0)o=n;var s=Object.getOwnPropertyDescriptor(t,n);if(!s||("get"in s?!t.__esModule:s.writable||s.configurable))s={enumerable:!0,get:function(){return t[n]}};Object.defineProperty(e,o,s)}:function(e,t,n,o){if(o===void 0)o=n;e[o]=t[n]}),de=l&&l.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),W=l&&l.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null){for(var n in e)if(n!=="default"&&Object.prototype.hasOwnProperty.call(e,n))he(t,e,n)}return de(t,e),t},G=l&&l.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(l,"__esModule",{value:!0});l.HttpsProxyAgent=void 0;var w=W(p("net")),F=W(p("tls")),pe=G(p("assert")),_e=G(
|
|
6
|
+
`),C=q.shift();if(!C)return e.destroy(),n(Error("No header received from proxy CONNECT response"));let A=C.split(" "),Y=+A[1],Z=A.slice(2).join(" "),b={};for(let v of q){if(!v)continue;let E=v.indexOf(":");if(E===-1)return e.destroy(),n(Error(`Invalid header from proxy CONNECT response: "${v}"`));let m=v.slice(0,E).toLowerCase(),N=v.slice(E+1).trimStart(),P=b[m];if(typeof P==="string")b[m]=[P,N];else if(Array.isArray(P))P.push(N);else b[m]=N}S("got proxy server response: %o %o",C,b),i(),t({connect:{statusCode:Y,statusText:Z,headers:b},buffered:f})}e.on("error",y),e.on("end",_),a()})}g.parseProxyResponse=le});var ge=r(function(l){var he=l&&l.__createBinding||(Object.create?function(e,t,n,o){if(o===void 0)o=n;var s=Object.getOwnPropertyDescriptor(t,n);if(!s||("get"in s?!t.__esModule:s.writable||s.configurable))s={enumerable:!0,get:function(){return t[n]}};Object.defineProperty(e,o,s)}:function(e,t,n,o){if(o===void 0)o=n;e[o]=t[n]}),de=l&&l.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),W=l&&l.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null){for(var n in e)if(n!=="default"&&Object.prototype.hasOwnProperty.call(e,n))he(t,e,n)}return de(t,e),t},G=l&&l.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(l,"__esModule",{value:!0});l.HttpsProxyAgent=void 0;var w=W(p("net")),F=W(p("tls")),pe=G(p("assert")),_e=G(Wt()),Q=U(),V=p("url"),X=z(),O=(0,_e.default)("https-proxy-agent"),J=(e)=>{if(e.servername===void 0&&e.host&&!w.isIP(e.host))return{...e,servername:e.host};return e};class x extends Q.Agent{constructor(e,t){super(t);this.options={path:void 0},this.proxy=typeof e==="string"?new V.URL(e):e,this.proxyHeaders=t?.headers??{},O("Creating new HttpsProxyAgent instance: %o",this.proxy.href);let n=(this.proxy.hostname||this.proxy.host).replace(/^\[|\]$/g,""),o=this.proxy.port?parseInt(this.proxy.port,10):this.proxy.protocol==="https:"?443:80;this.connectOpts={ALPNProtocols:["http/1.1"],...t?K(t,"headers"):null,host:n,port:o}}async connect(e,t){let{proxy:n}=this;if(!t.host)throw TypeError('No "host" provided');let o;if(n.protocol==="https:")O("Creating `tls.Socket`: %o",this.connectOpts),o=F.connect(J(this.connectOpts));else O("Creating `net.Socket`: %o",this.connectOpts),o=w.connect(this.connectOpts);let s=typeof this.proxyHeaders==="function"?this.proxyHeaders():{...this.proxyHeaders},a=w.isIPv6(t.host)?`[${t.host}]`:t.host,i=`CONNECT ${a}:${t.port} HTTP/1.1\r
|
|
7
7
|
`;if(n.username||n.password){let f=`${decodeURIComponent(n.username)}:${decodeURIComponent(n.password)}`;s["Proxy-Authorization"]=`Basic ${Buffer.from(f).toString("base64")}`}if(s.Host=`${a}:${t.port}`,!s["Proxy-Connection"])s["Proxy-Connection"]=this.keepAlive?"Keep-Alive":"close";for(let f of Object.keys(s))i+=`${f}: ${s[f]}\r
|
|
8
8
|
`;let _=X.parseProxyResponse(o);o.write(`${i}\r
|
|
9
9
|
`);let{connect:y,buffered:j}=await _;if(e.emit("proxyConnect",y),this.emit("proxyConnect",y,e),y.statusCode===200){if(e.once("socket",ye),t.secureEndpoint)return O("Upgrading socket connection to TLS"),F.connect({...K(J(t),"host","path","port"),socket:o});return o}o.destroy();let h=new w.Socket({writable:!1});return h.readable=!0,e.once("socket",(f)=>{O("Replaying proxy buffer for failed request"),(0,pe.default)(f.listenerCount("data")>0),f.push(j),f.push(null)}),h}}x.protocols=["http","https"];l.HttpsProxyAgent=x;function ye(e){e.resume()}function K(e,...t){let n={},o;for(o in e)if(!t.includes(o))n[o]=e[o];return n}});export default ge();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{i,r}from"./chunk-
|
|
2
|
+
import{i,r}from"./chunk-ydzag81d.js";var R=r(function(U){Object.defineProperty(U,"__esModule",{value:!0});U.Allow=U.ALL=U.COLLECTION=U.ATOM=U.SPECIAL=U.INF=U._INFINITY=U.INFINITY=U.NAN=U.BOOL=U.NULL=U.OBJ=U.ARR=U.NUM=U.STR=void 0;U.STR=1;U.NUM=2;U.ARR=4;U.OBJ=8;U.NULL=16;U.BOOL=32;U.NAN=64;U.INFINITY=128;U._INFINITY=256;U.INF=U.INFINITY|U._INFINITY;U.SPECIAL=U.NULL|U.BOOL|U.INF|U.NAN;U.ATOM=U.STR|U.NUM|U.SPECIAL;U.COLLECTION=U.ARR|U.OBJ;U.ALL=U.ATOM|U.COLLECTION;U.Allow={STR:U.STR,NUM:U.NUM,ARR:U.ARR,OBJ:U.OBJ,NULL:U.NULL,BOOL:U.BOOL,NAN:U.NAN,INFINITY:U.INFINITY,_INFINITY:U._INFINITY,INF:U.INF,SPECIAL:U.SPECIAL,ATOM:U.ATOM,COLLECTION:U.COLLECTION,ALL:U.ALL};U.default=U.Allow});var v=r(function(o){var z=o&&o.__createBinding||(Object.create?function(t,s,u,e){if(e===void 0)e=u;var c=Object.getOwnPropertyDescriptor(s,u);if(!c||("get"in c?!s.__esModule:c.writable||c.configurable))c={enumerable:!0,get:function(){return s[u]}};Object.defineProperty(t,e,c)}:function(t,s,u,e){if(e===void 0)e=u;t[e]=s[u]}),H=o&&o.__exportStar||function(t,s){for(var u in t)if(u!=="default"&&!Object.prototype.hasOwnProperty.call(s,u))z(s,t,u)};Object.defineProperty(o,"__esModule",{value:!0});o.Allow=o.MalformedJSON=o.PartialJSON=o.parseJSON=o.parse=void 0;var n=R();Object.defineProperty(o,"Allow",{enumerable:!0,get:function(){return n.Allow}});H(R(),o);class B extends Error{}o.PartialJSON=B;class F extends Error{}o.MalformedJSON=F;function Y(t,s=n.Allow.ALL){if(typeof t!=="string")throw TypeError(`expecting str, got ${typeof t}`);if(!t.trim())throw Error(`${t} is empty`);return K(t.trim(),s)}o.parseJSON=Y;var K=(t,s)=>{let u=t.length,e=0,c=(a)=>{throw new B(`${a} at position ${e}`)},p=(a)=>{throw new F(`${a} at position ${e}`)},l=()=>{if(O(),e>=u)c("Unexpected end of input");if(t[e]==='"')return M();if(t[e]==="{")return W();if(t[e]==="[")return D();if(t.substring(e,e+4)==="null"||n.Allow.NULL&s&&u-e<4&&"null".startsWith(t.substring(e)))return e+=4,null;if(t.substring(e,e+4)==="true"||n.Allow.BOOL&s&&u-e<4&&"true".startsWith(t.substring(e)))return e+=4,!0;if(t.substring(e,e+5)==="false"||n.Allow.BOOL&s&&u-e<5&&"false".startsWith(t.substring(e)))return e+=5,!1;if(t.substring(e,e+8)==="Infinity"||n.Allow.INFINITY&s&&u-e<8&&"Infinity".startsWith(t.substring(e)))return e+=8,1/0;if(t.substring(e,e+9)==="-Infinity"||n.Allow._INFINITY&s&&1<u-e&&u-e<9&&"-Infinity".startsWith(t.substring(e)))return e+=9,-1/0;if(t.substring(e,e+3)==="NaN"||n.Allow.NAN&s&&u-e<3&&"NaN".startsWith(t.substring(e)))return e+=3,NaN;return q()},M=()=>{let a=e,f=!1;e++;while(e<u&&(t[e]!=='"'||f&&t[e-1]==="\\"))f=t[e]==="\\"?!f:!1,e++;if(t.charAt(e)=='"')try{return JSON.parse(t.substring(a,++e-Number(f)))}catch(N){p(String(N))}else if(n.Allow.STR&s)try{return JSON.parse(t.substring(a,e-Number(f))+'"')}catch(N){return JSON.parse(t.substring(a,t.lastIndexOf("\\"))+'"')}c("Unterminated string literal")},W=()=>{e++,O();let a={};try{while(t[e]!=="}"){if(O(),e>=u&&n.Allow.OBJ&s)return a;let f=M();O(),e++;try{let N=l();a[f]=N}catch(N){if(n.Allow.OBJ&s)return a;else throw N}if(O(),t[e]===",")e++}}catch(f){if(n.Allow.OBJ&s)return a;else c("Expected '}' at end of object")}return e++,a},D=()=>{e++;let a=[];try{while(t[e]!=="]")if(a.push(l()),O(),t[e]===",")e++}catch(f){if(n.Allow.ARR&s)return a;c("Expected ']' at end of array")}return e++,a},q=()=>{if(e===0){if(t==="-")p("Not sure what '-' is");try{return JSON.parse(t)}catch(f){if(n.Allow.NUM&s)try{return JSON.parse(t.substring(0,t.lastIndexOf("e")))}catch(N){}p(String(f))}}let a=e;if(t[e]==="-")e++;while(t[e]&&",]}".indexOf(t[e])===-1)e++;if(e==u&&!(n.Allow.NUM&s))c("Unterminated number literal");try{return JSON.parse(t.substring(a,e))}catch(f){if(t.substring(a,e)==="-")c("Not sure what '-' is");try{return JSON.parse(t.substring(a,t.lastIndexOf("e")))}catch(N){p(String(N))}}},O=()=>{while(e<u&&`
|
|
3
3
|
\r `.includes(t[e]))e++};return l()},Q=Y;o.parse=Q});var P=i(v(),1),X=new Set(['"',"\\","/","b","f","n","r","t","u"]);function Z(t){let s=t.codePointAt(0);return s!==void 0&&s>=0&&s<=31}function S(t){switch(t){case"\b":return"\\b";case"\f":return"\\f";case`
|
|
4
|
-
`:return"\\n";case"\r":return"\\r";case"\t":return"\\t";default:return`\\u${t.codePointAt(0)?.toString(16).padStart(4,"0")??"0000"}`}}function
|
|
5
|
-
export{
|
|
4
|
+
`:return"\\n";case"\r":return"\\r";case"\t":return"\\t";default:return`\\u${t.codePointAt(0)?.toString(16).padStart(4,"0")??"0000"}`}}function ei(t){let s="",u=!1;for(let e=0;e<t.length;e++){let c=t[e];if(!u){if(s+=c,c==='"')u=!0;continue}if(c==='"'){s+=c,u=!1;continue}if(c==="\\"){let p=t[e+1];if(p===void 0){s+="\\\\";continue}if(p==="u"){let l=t.slice(e+2,e+6);if(/^[0-9a-fA-F]{4}$/.test(l)){s+=`\\u${l}`,e+=5;continue}}if(X.has(p)){s+=`\\${p}`,e+=1;continue}s+="\\\\";continue}s+=Z(c)?S(c):c}return s}function nn(t){try{return JSON.parse(t)}catch(s){let u=ei(t);if(u!==t)return JSON.parse(u);throw s}}function G(t){if(!t||t.trim()==="")return{};try{return nn(t)}catch{try{return P.parse(t)??{}}catch{try{return P.parse(ei(t))??{}}catch{return{}}}}}
|
|
5
|
+
export{ei,nn,G};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
3
|
-
`);if(r[r.length-1]==="")r.pop();return r}function
|
|
2
|
+
import{Do,Et,ct,A,Un,Uo}from"./chunk-m71pj3g1.js";import{o,e,u,Bt,At,I,he,R,No,Dr,$t}from"./chunk-ymg7mtcx.js";import*as S from"fs/promises";import*as ne from"fs";import*as O from"path";import*as $e from"child_process";import*as at from"crypto";import*as lt from"readline";function C(a){if(a.inputSchema.type!=="object")throw Error(`JSON schema for tool "${a.name}" must be an object, but got ${a.inputSchema.type}`);return{type:"custom",name:a.name,input_schema:a.inputSchema,description:a.description,run:a.run,parse:(r)=>r,...a.close?{close:a.close}:{}}}var F=ct.promises,J=448,yt=384;function ae(a,r){let t=A.relative(a,r);return t===""||!t.startsWith(".."+A.sep)&&t!==".."&&!A.isAbsolute(t)}async function Ee(a,r){for(let t of a)if(ae(await X(A.resolve(t)),r))return t;return}var wt=40;function Z(a){let r=a?.code;return typeof r==="string"?r:void 0}async function X(a){let r=[],t=a,i=0;for(;;){let n;try{n=await F.realpath(t)}catch(s){let c;try{c=(await F.lstat(t)).isSymbolicLink()}catch(l){let f=Z(l);if(f!=="ENOENT"&&f!=="ENOTDIR")throw l;let h=A.dirname(t);if(h===t)throw l;r.push(A.basename(t)),t=h;continue}if(!c)throw s;if(++i>wt)throw Object.assign(Error("too many levels of symbolic links"),{code:"ELOOP"});t=A.resolve(A.dirname(t),await F.readlink(t));continue}return r.length?A.join(n,...r.reverse()):n}}async function Ae(a,r,t){let i=t?.allowedRoots??[],n=await X(A.resolve(a)),s;try{s=await X(A.resolve(n,r))}catch(l){throw new R(q(l,`path ${JSON.stringify(r)}`))}if(ae(n,s)||await Ee(i,s)!==void 0)return s;let c=i.length?"the session's working directory and its other permitted directories":"the session's working directory";throw new R(`path ${JSON.stringify(r)} is outside ${c}`)}async function be(a,r){let t=A.dirname(a),i=A.join(t,`.tmp-${process.pid}-${Et.randomUUID()}`),n=await F.stat(a).then((c)=>c.mode&511,()=>{return}),s;try{if(s=await F.open(i,"wx",yt),n!==void 0)await s.chmod(n);await s.writeFile(r,"utf-8"),await s.sync(),await s.close(),s=void 0,await F.rename(i,a)}catch(c){if(s)await s.close().catch(()=>{});throw await F.unlink(i).catch(()=>{}),c}}function q(a,r){let t=Z(a);switch(t){case"ENOENT":return`${r}: no such file or directory`;case"EACCES":case"EPERM":return`${r}: permission denied`;case"ENOTDIR":return`${r}: not a directory`;case"EISDIR":return`${r}: is a directory`;case"ELOOP":return`${r}: too many levels of symbolic links`;case"ENAMETOOLONG":return`${r}: file name too long`;case"ENOSPC":return`${r}: no space left on device`;case"EMFILE":case"ENFILE":return`${r}: too many open files`;default:return`${r}: ${t!==void 0?`i/o error (${t})`:"i/o error"}`}}var k=ct.promises,_t=Uo.promisify(Do.execFile);async function gt(a){let{client:r,sessionId:t}=a;if(!r)return async()=>{};let i=I(r),n=a.session;if(!n){if(t===void 0)return async()=>{};i.warn("AgentToolContext.sessionId is deprecated and costs an extra session fetch; fetch the session once and set `session` instead",{component:"agent-tool-context"}),n=await r.beta.sessions.retrieve(t)}let s=A.resolve(a.workdir,"skills"),c=[];for(let l of n.agent.skills)try{let f=await r.beta.skills.versions.retrieve(l.version,{skill_id:l.skill_id}),h=A.basename(f.name.trim());if(h===""||h==="."||h==="..")h=l.skill_id;let d=A.resolve(s,h);if(d!==s&&!d.startsWith(s+A.sep)){i.warn("skill name escapes the skills dir; skipping",{component:"agent-tool-context",name:f.name});continue}let m=await r.beta.skills.versions.download(f.id,{skill_id:l.skill_id});await k.rm(d,{recursive:!0,force:!0}),await k.mkdir(d,{recursive:!0,mode:J}),c.push(d),await Ce(m,d),i.info("downloaded skill",{component:"agent-tool-context",skill_id:l.skill_id,version:f.id,dest:d})}catch(f){i.warn("failed to download skill",{component:"agent-tool-context",skill_id:l.skill_id,error:String(f)})}return async()=>{for(let l of c)await k.rm(l,{recursive:!0,force:!0}).catch((f)=>{i.warn("failed to clean up skill",{component:"agent-tool-context",dest:l,error:String(f)})})}}function St(a){for(let r of a){let t=r.trim();if(!t)continue;if(A.isAbsolute(t)||t.split(/[\\/]/).includes(".."))throw new u(`refusing to extract unsafe archive member: ${t}`)}}var Me="skill archive listing is inconsistent; refusing to extract",bt={unzip:new Set(["-","d","?"]),tar:new Set(["-","d","C"])};function xe(a){let r=a.split(`
|
|
3
|
+
`);if(r[r.length-1]==="")r.pop();return r}function Ot(a,r){return/^[\x20-\x7E]+$/.test(r)&&!/[\\^#]/.test(r)&&!(a==="unzip"&&r.startsWith("-"))}function Mt(a,r,t){let i=xe(r),n=xe(t);if(i.length!==n.length)throw new u(Me);let s=[],c=[];return i.forEach((l,f)=>{if(bt[a].has(n[f].charAt(0))){s.push(l);return}if(!Ot(a,l))throw new u(`refusing to extract archive: cannot safely exclude member ${JSON.stringify(l)}`);c.push(l)}),{plain:s,special:c}}async function De(a){for(let r of await k.readdir(a,{withFileTypes:!0}))if(r.isDirectory())await De(A.join(a,r.name));else if(!r.isFile())throw new u(Me)}async function Oe(a,r){try{let{stdout:t}=await _t(a,r);return t}catch(t){if(Z(t)==="ENOENT")throw new u(`skill extraction requires the \`${a}\` command, but it was not found on PATH`);throw t}}function vt(a){let r,t=!1;for(let i of a){let n=i.trim().split("/").filter((c)=>c!==""&&c!==".");if(n.length===0)continue;let s=n[0];if(r===void 0)r=s;else if(s!==r)return"";if(n.length>1)t=!0}return r!==void 0&&t?r:""}async function Ce(a,r){let t=A.join(r,`.skill-archive-${process.pid}-${Date.now()}`);if(!a.body)throw new u("skill download response had no body");await Un.promises.pipeline(Un.Readable.fromWeb(a.body),ct.createWriteStream(t));let i=A.join(A.dirname(r),`.skill-stage-${process.pid}-${Date.now()}`),n=A.join(A.dirname(r),`.skill-exclude-${process.pid}-${Date.now()}`);try{let s=await It(t,4),c=s.length>=4&&s[0]===80&&s[1]===75&&s[2]===3&&s[3]===4,l=c?"unzip":"tar",f=await Oe(l,c?["-Z1",t]:["-tf",t]),h=await Oe(l,c?["-Z","--h","--t",t]:["-tvf",t]),{plain:d,special:m}=Mt(l,f,h);St([...d,...m]);let _=vt(d);if(await k.mkdir(i,{recursive:!0,mode:J}),d.length>0)await Oe(l,await kt(l,t,i,m,n));await De(i);let E=_?A.join(i,_):i,D=await k.readdir(E).catch((M)=>{throw Z(M)==="ENOENT"?new u(Me):M});for(let M of D)await k.rename(A.join(E,M),A.join(r,M))}finally{await k.rm(t,{force:!0}),await k.rm(n,{force:!0}),await k.rm(i,{recursive:!0,force:!0})}}async function kt(a,r,t,i,n){let s=i.map((c)=>c.replace(/[*?[\\]/g,"\\$&"));if(a==="unzip")return["-oq",r,"-d",t,...s.length>0?["-x",...s]:[]];if(s.length===0)return["-xf",r,"-C",t];return await k.writeFile(n,s.join(`
|
|
4
4
|
`)+`
|
|
5
|
-
`,{flag:"wx",mode:384}),["-xf",r,"-C",t,"-X",n]}async function
|
|
6
|
-
${a}`,"utf-8").digest("hex")}var qt=30000,zt=100,Gt=20,Ht=16,Kt=32,Vt=8,Xt=50;class P extends u{constructor(a,r){super(a);if(this.name="SessionMemoryError",r!==void 0)this.cause=r}}class tt{constructor(a,r,t){this.mode=a,this.cap=r,this.waiveWindow=t,this.attempted=0,this.capped=0,this.suppressed=0}takeSlot(){if(this.attempted>=this.cap)return this.capped++,!1;return this.attempted++,!0}}var Jt=(()=>{class a{constructor(r,t){
|
|
7
|
-
${t.memoryStoreId}`);for await(let[i,n]of e(this,
|
|
8
|
-
`),ie=102400,tr=2000,rr=200;class dt extends u{constructor(a){super(`bash command timed out after ${a}ms`);this.name="BashTimeoutError",this.timeoutMs=a}}var ir=/\x1b\[[0-9;?]*[ -/]*[@-~]/g,nr=
|
|
5
|
+
`,{flag:"wx",mode:384}),["-xf",r,"-C",t,"-X",n]}async function It(a,r){let t=await k.open(a,"r");try{let i=Buffer.alloc(r),{bytesRead:n}=await t.read(i,0,r,0);return i.subarray(0,n)}finally{await t.close()}}var g=ct.promises,z=ct.constants,Ue=448,Rt=384,Nt=448,ke=z.O_NOFOLLOW??0,Tt=z.O_NONBLOCK??0,y=(()=>{class a extends Error{constructor(r,t){super(`path ${JSON.stringify(t)} ${r}`);this.name="FileStoreError",this.reason=r,this.relPath=t}}return a.ESCAPES_ROOT="escapes the store root",a.IS_A_SYMLINK="is a symlink",a.NOT_A_FILE="is not a regular file",a.NOT_A_DIRECTORY="is not a directory",a.NOT_UTF8="is not valid utf-8",a.MOVE_DESTINATION_EXISTS="already exists",a})();function Ie(a){return a.startsWith("/")&&!a.split("/").includes("..")}var ve=(()=>{class a{constructor(r,t,i=!1){this.hashes=new Map,this.rootPath=r,this.removedOnDispose=t,this.decoder=i?new TextDecoder("utf-8",{fatal:!0}):void 0}static async open(r,t){if(!Lt())throw Error("FileStore requires O_NOFOLLOW support on this platform");let i=!1;try{await g.lstat(r)}catch(n){if(n.code!=="ENOENT")throw n;i=!0}return new a(A.resolve(r),i,t?.utf8??!1)}async createRoot(){await xt(this.rootPath)}root(){return{path:this.rootPath,removedOnDispose:this.removedOnDispose}}async dispose(){if(!this.removedOnDispose)return;await g.rm(this.rootPath,{recursive:!0,force:!0})}async put(r,t,i){let n=r.replace(/\\/g,"/");if(n.endsWith("/")||n.endsWith("/.")||n===""||n===".")throw new y(y.NOT_A_FILE,r);let s=this.resolveUnderRoot(r),c=typeof t==="string"?Bt(t):t;this.requireUtf8(r,c),await Fe(this.rootPath,A.dirname(s)),await Dt(s,c,i?.executable??!1)}async get(r){let t=this.resolveUnderRoot(r),i;try{i=await je(r,t)}catch(s){if(s.code==="ENOENT")return null;throw s}let n;try{let s=await i.readFile();n=new Uint8Array(s.buffer,s.byteOffset,s.byteLength)}finally{await i.close()}return this.requireUtf8(r,n),n}async ls(r="/"){let t=this.resolveUnderRoot(r);return new Set((await Pe(this.rootPath,r,t)).map(([i])=>i))}async findSymlinks(r="/"){let t=this.resolveUnderRoot(r);return Ft(this.rootPath,r,t)}async hashtree(r="/"){let t=this.resolveUnderRoot(r),i=ce.nowNs(),n=Object.create(null);for(let[s,c]of await Pe(this.rootPath,r,t)){let l=await this.hashViaCache(s,c,i);if(l!==null)n[s]=l}return n}async hashFile(r){let t=this.resolveUnderRoot(r),i;try{i=await g.lstat(t,{bigint:!0})}catch(s){if(s.code==="ENOENT")return null;throw s}if(i.isSymbolicLink())throw new y(y.IS_A_SYMLINK,r);if(!i.isFile())throw new y(y.NOT_A_FILE,r);let n=A.relative(this.rootPath,t).split(A.sep).join("/");return this.hashViaCache(n,t,ce.nowNs())}async move(r,t){let i=this.resolveUnderRoot(r),n=this.resolveUnderRoot(t);if(i===this.rootPath||n===this.rootPath)return;if(await g.stat(n).then(()=>!0,()=>!1))throw new y(y.MOVE_DESTINATION_EXISTS,t);await Fe(this.rootPath,A.dirname(n)),await g.rename(i,n)}async remove(r){let t=this.resolveUnderRoot(r);if(t===this.rootPath)return;let i;try{i=await g.lstat(t,{bigint:!0})}catch(n){if(n.code==="ENOENT")return;throw n}if(i.isDirectory())await g.rm(t,{recursive:!0,force:!0});else try{await g.unlink(t)}catch(n){if(n.code!=="ENOENT")throw n}}resolveUnderRoot(r){let t=r.replace(/\\/g,"/").replace(/^\/+/,""),i=t.split("/").filter((n)=>n!==""&&n!==".");if(A.posix.isAbsolute(t)||i.includes(".."))throw new y(y.ESCAPES_ROOT,r);return i.length===0?this.rootPath:A.join(this.rootPath,...i)}requireUtf8(r,t){if(!this.decoder)return;try{this.decoder.decode(t)}catch{throw new y(y.NOT_UTF8,r)}}async hashViaCache(r,t,i){let n;try{n=await g.lstat(t,{bigint:!0})}catch(l){if(l.code==="ENOENT")return null;throw l}if(!n.isFile())return null;let s=this.hashes.get(r),c;if(s!==void 0&&Wt(s,n))c=s.sha;else try{c=await ce.hashFile(t)}catch(l){let f=l.code;if(f==="ENOENT"||l instanceof y)return null;if(f==="ELOOP"||f==="EMLINK")return null;throw l}if(Ut(n,i))this.hashes.set(r,{mtimeNs:n.mtimeNs,ctimeNs:n.ctimeNs,size:n.size,sha:c});return c}}return a.isPathLegal=Ie,a})();function Lt(){return ke!==0}async function xt(a){let r=[],t=a;for(;;){try{await g.stat(t);break}catch(n){let s=n.code;if(s!=="ENOENT"&&s!=="ENOTDIR"&&s!=="ELOOP")throw n}r.push(t);let i=A.dirname(t);if(i===t)break;t=i}for(let i of r.reverse())try{await g.mkdir(i,{mode:Ue})}catch(n){if(n.code!=="EEXIST")throw n}}async function Fe(a,r){let t=A.relative(a,r);if(t==="")return;let i=a;for(let n of t.split(A.sep)){i=A.join(i,n);try{await g.mkdir(i,{mode:Ue})}catch(s){if(s.code!=="EEXIST")throw s}}}async function Dt(a,r,t){let i=t?Nt:Rt,n=A.join(A.dirname(a),`.fs-${Et.randomBytes(8).toString("hex")}.tmp`),s;try{s=await g.open(n,z.O_WRONLY|z.O_CREAT|z.O_EXCL|ke,i),await s.writeFile(r),await s.close(),s=void 0,await g.rename(n,a)}catch(c){if(s)await s.close().catch(()=>{});throw await g.unlink(n).catch(()=>{}),c}}async function je(a,r){let t;try{t=await g.open(r,z.O_RDONLY|ke|Tt)}catch(i){let n=i.code;if(n==="ELOOP"||n==="EMLINK")throw new y(y.IS_A_SYMLINK,a);throw i}try{if(!(await t.stat()).isFile())throw new y(y.NOT_A_FILE,a)}catch(i){throw await t.close().catch(()=>{}),i}return t}async function Ct(a){let r=Et.createHash("sha256"),t=await je(A.basename(a),a),i=new Uint8Array(1048576);try{for(;;){let{bytesRead:n}=await t.read(i,0,i.length);if(n===0)break;r.update(i.subarray(0,n))}}finally{await t.close()}return r.digest("hex")}async function Pe(a,r,t){if(!await Pt(r,t))return[];let i=[];return await Be(t,(n,s)=>{if(s.isFile())i.push([A.relative(a,n).split(A.sep).join("/"),n])}),i.sort(),i}async function Ft(a,r,t){let i=(c)=>A.relative(a,c).split(A.sep).join("/"),n;try{n=await g.lstat(t,{bigint:!0})}catch(c){let l=c.code;if(l==="ENOENT"||l==="ENOTDIR")return new Set;throw c}if(n.isSymbolicLink())return new Set([i(t)]);if(!n.isDirectory())throw new y(y.NOT_A_DIRECTORY,r);let s=new Set;return await Be(t,(c,l)=>{if(l.isSymbolicLink())s.add(i(c))}),s}async function Pt(a,r){let t;try{t=await g.lstat(r,{bigint:!0})}catch(i){let n=i.code;if(n==="ENOENT"||n==="ENOTDIR")return!1;throw i}if(!t.isDirectory())throw new y(y.NOT_A_DIRECTORY,a);return!0}async function Be(a,r){let t=[a];while(t.length){let i=t.pop(),n;try{n=await g.readdir(i,{withFileTypes:!0})}catch(s){if(s.code==="ENOENT")continue;throw s}for(let s of n){let c=A.join(i,s.name);if(r(c,s),s.isDirectory()&&!s.isSymbolicLink())t.push(c)}}}function Wt(a,r){return r.mtimeNs===a.mtimeNs&&r.ctimeNs===a.ctimeNs&&r.size===a.size}function Ut(a,r){return(a.mtimeNs>a.ctimeNs?a.mtimeNs:a.ctimeNs)<r-ce.timestampTrustMarginNs}var jt=2000000000n,ce={hashFile:Ct,timestampTrustMarginNs:jt,nowNs:()=>BigInt(Date.now())*1000000n},Ye=ve,We=Symbol.asyncDispose;if(We)Object.defineProperty(ve.prototype,We,{value:ve.prototype.dispose,configurable:!0,writable:!0});var w,T,le,Q,fe,p,G,de,L,qe,me,ze,Ge,Re,Ne,He,Ke,Te,Ve,Xe,ue,pe,Je,Ze,Yt=30000,K=".anthropic-memory-store",et=1;function Qe(a){return Et.createHash("sha256").update(`version ${et}
|
|
6
|
+
${a}`,"utf-8").digest("hex")}var qt=30000,zt=100,Gt=20,Ht=16,Kt=32,Vt=8,Xt=50;class P extends u{constructor(a,r){super(a);if(this.name="SessionMemoryError",r!==void 0)this.cause=r}}class tt{constructor(a,r,t){this.mode=a,this.cap=r,this.waiveWindow=t,this.attempted=0,this.capped=0,this.suppressed=0}takeSlot(){if(this.attempted>=this.cap)return this.capped++,!1;return this.attempted++,!0}}var Jt=(()=>{class a{constructor(r,t){w.add(this),T.set(this,void 0),le.set(this,void 0),Q.set(this,void 0),fe.set(this,void 0),p.set(this,void 0),G.set(this,void 0),de.set(this,!1),L.set(this,[]),o(this,T,r,"f"),o(this,le,t.workdir,"f"),o(this,Q,t.syncIntervalMs??No,"f"),Dr(e(this,Q,"f"),"syncIntervalMs"),o(this,fe,t.syncDeletions??"enabled","f"),o(this,p,I(r),"f"),o(this,G,Date.now(),"f")}get roots(){return e(this,L,"f").map((r)=>r.files.root().path)}get readOnlyRoots(){return e(this,L,"f").filter((r)=>r.readOnly).map((r)=>r.files.root().path)}async download(r){for(let t of r.resources){if(t.type!=="memory_store")continue;let i=e(this,w,"m",qe).call(this,t),n;try{if(n={memoryStoreId:t.memory_store_id,files:await Ye.open(i,{utf8:!0}),readOnly:t.access==="read_only",baseline:new Map,refusedShas:new Map,pendingDeletes:new Map},!n.files.root().removedOnDispose)throw new P(`something already exists at the memory store's path: ${i} (memory_store_id=${t.memory_store_id}); it must not exist when the session starts`);try{await n.files.createRoot()}catch(s){if(!H(s))throw s;throw new P(`cannot create the memory store's folder: ${i} (memory_store_id=${t.memory_store_id}): ${s}; the worker host must make this mount path writable`,s)}await e(this,w,"m",Ne).call(this,n),e(this,p,"f").info("downloaded memories",{count:n.baseline.size,memory_store_id:n.memoryStoreId,dest:n.files.root().path}),e(this,L,"f").push(n)}catch(s){if(n)await n.files.dispose().catch(()=>{});if(s instanceof P)throw s;throw new P(`failed to download memory store memory_store_id=${t.memory_store_id}: ${s}`,s)}}o(this,G,Date.now(),"f")}async finish(){if(e(this,de,"f"))throw new u("finish() was already called: it is the session's last sync and runs once");o(this,de,!0,"f"),await this.syncAll(!0)}async syncAll(r){await Promise.all(e(this,L,"f").map((t)=>e(this,w,"m",ze).call(this,t,r))),o(this,G,Date.now(),"f")}async syncIfDue(){if(Date.now()-e(this,G,"f")<e(this,Q,"f"))return;await this.syncAll(!1)}async flushWrites(r){await Promise.all(e(this,L,"f").map((t)=>e(this,w,"m",Ge).call(this,t,r)))}async dispose(){for(let r of e(this,L,"f")){let t=r.files.root();try{let i=await e(this,w,"m",me).call(this,r);if(!i.markerOk&&Object.keys(i.files).length>0){e(this,p,"f").warn(`${i.distrustReason}; leaving the memory store folder on disk`,{root:t.path,memory_store_id:r.memoryStoreId});continue}await r.files.dispose()}catch(i){if(!(i instanceof y)&&!H(i))throw i;e(this,p,"f").warn("failed to remove the memory store folder",{root:r.files.root().path,memory_store_id:r.memoryStoreId,error:String(i)});continue}if(t.removedOnDispose)e(this,p,"f").info("removed memory store dir",{dest:t.path,memory_store_id:r.memoryStoreId})}}}return T=new WeakMap,le=new WeakMap,Q=new WeakMap,fe=new WeakMap,p=new WeakMap,G=new WeakMap,de=new WeakMap,L=new WeakMap,w=new WeakSet,qe=function(t){if(t.mount_path){if(!Ie(t.mount_path))throw new P(`memory store mount_path is not a clean absolute path: ${JSON.stringify(t.mount_path)} (memory_store_id=${t.memory_store_id})`);return t.mount_path}return A.join(e(this,le,"f"),"memory",t.name||t.memory_store_id)},me=async function(t){let i=await t.files.hashtree(),n=i[K];if(delete i[K],n===Qe(t.memoryStoreId))return{files:i,markerOk:!0,distrustReason:null};return{files:i,markerOk:!1,distrustReason:n!==void 0?"the marker file does not match this store":"the marker file is gone"}},ze=async function(t,i){try{let n=await e(this,w,"m",me).call(this,t),s=n.files;if(!n.markerOk){if(Object.keys(s).length>0){e(this,p,"f").warn(`${n.distrustReason}; leaving the memory store folder as found and not syncing`,{root:t.files.root().path,memory_store_id:t.memoryStoreId});return}await e(this,w,"m",Re).call(this,t,"the folder or its marker is gone");return}if(Object.keys(s).length===0&&t.baseline.size>1){await e(this,w,"m",Re).call(this,t,"every memory file is gone at once");return}let c=new Map;for await(let[m,_]of e(this,w,"m",ue).call(this,t.memoryStoreId))c.set(m,_);let l=new tt(e(this,fe,"f"),Math.max(Vt,Math.min(Xt,Math.floor(t.baseline.size/4))),i),f=[],h=new Map,d=[...new Set([...c.keys(),...Object.keys(s),...t.baseline.keys()])].sort();for(let m of d){let _=c.get(m),E=s[m],D=t.baseline.get(m),M;if(E===void 0&&D!==void 0&&_!==void 0&&_.content_sha256===D&&!t.readOnly)M=await e(this,w,"m",Je).call(this,t,m,_,D,l);else M=await e(this,w,"m",He).call(this,t,m,_,E,f);if(M!==void 0)h.set(m,M)}if(t.baseline=h,await e(this,w,"m",Ve).call(this,t,f),l.suppressed>0)e(this,p,"f").debug("remote deletes are disabled; locally deleted memories stay on the server",{count:l.suppressed,memory_store_id:t.memoryStoreId});if(l.capped>0)e(this,p,"f").warn(`delete cap reached: ${l.mode==="log_only"?"would send":"sent"} ${l.attempted} deletes, held ${l.capped} for later syncs`,{memory_store_id:t.memoryStoreId})}catch(n){e(this,p,"f").warn("memory sync failed",{memory_store_id:t.memoryStoreId,error:String(n)})}},Ge=async function(t,i){let n=new Map,s=new Set,c=async()=>{if(t.readOnly)return;let l=await e(this,w,"m",me).call(this,t);if(!l.markerOk){e(this,p,"f").warn(`${l.distrustReason}; not uploading anything from the memory store folder`,{root:t.files.root().path,memory_store_id:t.memoryStoreId});return}for(let[d,m]of Object.entries(l.files))if(m!==t.baseline.get(d)&&t.refusedShas.get(d)!==m)n.set(d,m),s.add(d);if(n.size===0||i?.aborted)return;let f=new Map;for await(let[d,m]of e(this,w,"m",ue).call(this,t.memoryStoreId)){if(i?.aborted)return;f.set(d,m)}let h=[];for(let d of[...n.keys()].sort()){let m=n.get(d),_=t.baseline.get(d),E=f.get(d);if(E!==void 0&&E.content_sha256===m){t.baseline.set(d,E.content_sha256),s.delete(d);continue}if(E!==void 0&&E.content_sha256!==_){e(this,p,"f").warn("memory changed both locally and remotely; the flush leaves the remote version",{path:d,memory_store_id:t.memoryStoreId}),s.delete(d);continue}h.push([d,m,E])}await e(this,w,"m",Xe).call(this,t,h,s,i)};try{if(await Zt(c(),i),i?.aborted&&s.size>0)e(this,p,"f").warn(`memory flush cut off part-way; ${s.size} of ${n.size} changed files had not finished uploading`,{memory_store_id:t.memoryStoreId})}catch(l){e(this,p,"f").warn("memory flush failed",{memory_store_id:t.memoryStoreId,error:String(l)})}},Re=async function(t,i){e(this,p,"f").warn(`${i}; re-downloading the memory store folder instead of syncing`,{root:t.files.root().path,memory_store_id:t.memoryStoreId}),await t.files.createRoot(),await e(this,w,"m",Ne).call(this,t)},Ne=async function(t){t.baseline=new Map,t.pendingDeletes.clear(),await t.files.put(K,`version ${et}
|
|
7
|
+
${t.memoryStoreId}`);for await(let[i,n]of e(this,w,"m",ue).call(this,t.memoryStoreId,"full"))if(await e(this,w,"m",Te).call(this,t,i,n.content??""))t.baseline.set(i,n.content_sha256)},He=async function(t,i,n,s,c){let l=t.baseline.get(i);if(s!==void 0)t.pendingDeletes.delete(i);if(!n){if(s===void 0){t.pendingDeletes.delete(i);return}if(l!==void 0){if(s===l){let _=await e(this,w,"m",Ke).call(this,t,i,l);if(_===void 0)return;if(_===l)return l;s=_}if(t.readOnly)e(this,p,"f").warn("memory deleted remotely but edited locally; keeping the file, which a read-only store cannot push",{path:i,memory_store_id:t.memoryStoreId});else if(t.refusedShas.get(i)!==s)e(this,p,"f").info("memory deleted remotely but edited locally; re-creating it from the file",{path:i,memory_store_id:t.memoryStoreId})}if(t.readOnly)return;if(t.refusedShas.get(i)===s)return;return await e(this,w,"m",pe).call(this,t,i,s,void 0)}let f=n.content_sha256,h=f!==l,d=s!==void 0&&s!==l&&s!==f,m=!t.readOnly&&d;if(s===void 0&&l!==void 0){if(h)e(this,p,"f").warn("memory deleted locally but changed remotely; restoring the remote version",{path:i,memory_store_id:t.memoryStoreId}),t.pendingDeletes.delete(i),c.push([i,n]);return l}if(h){if(s===f)return f;if(d)e(this,p,"f").warn("memory changed both locally and remotely; keeping the remote version",{path:i,memory_store_id:t.memoryStoreId});return c.push([i,n]),l}if(m){if(t.refusedShas.get(i)===s)return f;return await e(this,w,"m",pe).call(this,t,i,s,n)??f}return f},Ke=async function(t,i,n){let s;try{s=await t.files.hashFile(i)}catch(c){if(!(c instanceof y)&&!H(c))throw c;return n}if(s===null)return;if(s!==n)return s;try{await t.files.remove(i)}catch(c){if(!(c instanceof y)&&!H(c))throw c;return e(this,p,"f").warn("failed to remove memory deleted remotely",{path:i,memory_store_id:t.memoryStoreId,error:String(c)}),n}return},Te=async function(t,i,n){try{await t.files.put(i,n)}catch(s){if(!(s instanceof y)&&!H(s))throw s;return e(this,p,"f").warn("failed to write memory",{path:i,memory_store_id:t.memoryStoreId,error:String(s)}),!1}return!0},Ve=async function(t,i){if(i.length===0)return;let n=async(l,f)=>{let h;try{h=await e(this,T,"f").beta.memoryStores.memories.retrieve(f.id,{memory_store_id:t.memoryStoreId,view:"full"})}catch(d){if(he(d,404))return;e(this,p,"f").warn("failed to fetch memory content",{path:l,memory_store_id:t.memoryStoreId,error:String(d)});return}if(await e(this,w,"m",Te).call(this,t,l,h.content??""))t.baseline.set(l,h.content_sha256)},s=i[Symbol.iterator](),c=async()=>{for(let[l,f]of s)await n(l,f)};await Promise.all(Array.from({length:Math.min(Ht,i.length)},c))},Xe=async function(t,i,n,s){let c=i[Symbol.iterator](),l=async()=>{for(let[f,h,d]of c){if(s?.aborted)return;let m=await e(this,w,"m",pe).call(this,t,f,h,d);if(n.delete(f),m!==void 0)t.baseline.set(f,m)}};await Promise.all(Array.from({length:Math.min(Kt,i.length)},l))},ue=async function*(t,i="basic"){let n=i==="basic"?zt:Gt;for await(let s of e(this,T,"f").beta.memoryStores.memories.list(t,{view:i,limit:n})){if(s.type!=="memory")continue;let c=s.path.replace(/^\/+/,"");if(c===K){e(this,p,"f").warn("the server listed the reserved marker path; skipping",{path:s.path,memory_store_id:t});continue}yield[c,s]}},pe=async function r(t,i,n,s){try{let c=await t.files.get(i);if(c===null)return;let l=At(c),f=s?await e(this,T,"f").beta.memoryStores.memories.update(s.id,{memory_store_id:t.memoryStoreId,content:l,precondition:{type:"content_sha256",content_sha256:s.content_sha256}}):await e(this,T,"f").beta.memoryStores.memories.create(t.memoryStoreId,{path:"/"+i,content:l});return t.refusedShas.delete(i),f.content_sha256}catch(c){if(s&&he(c,404))return await e(this,w,"m",r).call(this,t,i,n,void 0);let l=c instanceof y||he(c,400)||he(c,413);if(s&&he(c,409))e(this,p,"f").warn("memory changed both locally and remotely; the upload was refused and the local edit loses",{path:i,memory_store_id:t.memoryStoreId});else if(l&&n!==void 0)t.refusedShas.set(i,n),e(this,p,"f").warn("the server rejected this memory file, so it stays un-synced until its content changes",{path:i,memory_store_id:t.memoryStoreId,rejection:String(c)});else e(this,p,"f").warn("failed to upload memory",{path:i,memory_store_id:t.memoryStoreId,error:String(c)});return}},Je=async function(t,i,n,s,c){if(c.mode==="disabled")return c.suppressed++,s;let l=t.pendingDeletes.get(i);if(l===void 0)l=Date.now(),t.pendingDeletes.set(i,l);if(!c.waiveWindow&&Date.now()-l<qt)return s;let f,h;try{f=await t.files.hashFile(K)===Qe(t.memoryStoreId),h=await t.files.hashFile(i)===null}catch(m){if(!(m instanceof y)&&!H(m))throw m;f=h=!1}if(!f)return s;if(!h)return t.pendingDeletes.delete(i),s;if(!c.takeSlot())return s;if(c.mode==="log_only")return e(this,p,"f").info("log-only: sync would delete this memory on the server",{path:i,memory_store_id:t.memoryStoreId}),s;let d=await e(this,w,"m",Ze).call(this,t,i,n,s);if(d===void 0)t.pendingDeletes.delete(i);return d},Ze=async function(t,i,n,s){try{await e(this,T,"f").beta.memoryStores.memories.delete(n.id,{memory_store_id:t.memoryStoreId,expected_content_sha256:s})}catch(c){if(he(c,404))return;if(he(c,409)||he(c,412))e(this,p,"f").warn("memory deleted locally but changed remotely; keeping the remote version",{path:i,memory_store_id:t.memoryStoreId});else e(this,p,"f").warn("failed to delete memory",{path:i,memory_store_id:t.memoryStoreId,error:String(c)});return s}e(this,p,"f").info("propagated local deletion",{path:i,memory_store_id:t.memoryStoreId});return},a})();function H(a){return typeof a==="object"&&a!==null&&typeof a.code==="string"}async function Zt(a,r){if(!r){await a;return}let t,i=new Promise((n)=>{if(t=n,r.aborted)n()});r.addEventListener("abort",t,{once:!0});try{await Promise.race([a,i])}finally{r.removeEventListener("abort",t)}}var ye,b,v,ee,W,N,Le,we,te,_e,ge,U,j,V,B,re,x,rt,it,nt=102400,ft=120000,Qt=262144,er=65536,ot=Buffer.from(`
|
|
8
|
+
`),ie=102400,tr=2000,rr=200;class dt extends u{constructor(a){super(`bash command timed out after ${a}ms`);this.name="BashTimeoutError",this.timeoutMs=a}}var ir=/\x1b\[[0-9;?]*[ -/]*[@-~]/g,nr=S.glob;function ht(a){return a===void 0?Qt:a}function Y(a){if(a===void 0)return;throw new u("The `unrestrictedPaths` option you passed to the agent toolset (AgentToolContext) is no longer supported. The toolset's file tools (read, write, edit, glob, grep) are now always confined to the working directory plus the directories listed in `allowedRoots`. Remove `unrestrictedPaths` from your context; to let the file tools reach any other directory, add it to `allowedRoots`.")}function Xr(a){return[ar(a),cr(a),dr(a),hr(a),ur(a),pr(a)]}async function oe(a,r){return Y(a.unrestrictedPaths),Ae(a.workdir,r,{allowedRoots:a.allowedRoots??[]})}function mt(a,r){return Ee(a.readOnlyRoots??[],r)}function or(){let a={};for(let[r,t]of Object.entries(process.env)){if(r.startsWith("ANTHROPIC_"))continue;a[r]=t}return a}var sr=(()=>{class a{constructor(r,t=or()){ye.add(this),b.set(this,void 0),v.set(this,""),ee.set(this,!1),W.set(this,!1),N.set(this,null),o(this,b,$e.spawn("/bin/bash",["--noprofile","--norc"],{cwd:r,env:{...t,PS1:"",PS2:"",TERM:"dumb"},stdio:["pipe","pipe","pipe"],detached:!0}),"f"),e(this,b,"f").stdout.setEncoding("utf8"),e(this,b,"f").stderr.setEncoding("utf8"),e(this,b,"f").stdout.on("data",(i)=>e(this,ye,"m",Le).call(this,i)),e(this,b,"f").stderr.on("data",(i)=>e(this,ye,"m",Le).call(this,i)),e(this,b,"f").once("close",()=>{o(this,W,!0,"f");let i=e(this,N,"f");o(this,N,null,"f"),i?.resolve()})}get closed(){return e(this,W,"f")}async exec(r,t={}){if(e(this,W,"f"))throw new u("bash session terminated");let i=t.timeoutMs??ft,n=t.signal;n?.throwIfAborted(),o(this,v,"","f"),o(this,ee,!1,"f");let s=`__ANT_CMD_${at.randomUUID()}_DONE__`,c=`${s.slice(0,8)}''${s.slice(8)}`,l=`{ ${r}
|
|
9
9
|
} </dev/null 2>&1; printf '\\n${c}%d\\n' $?
|
|
10
|
-
`;if(e(this,
|
|
11
|
-
${
|
|
10
|
+
`;if(e(this,b,"f").stdin.write(l),e(this,v,"f").indexOf(s)<0){let{promise:E,resolve:D}=$t();o(this,N,{sentinel:s,resolve:D},"f");let M,se;try{await Promise.race([E,new Promise((pt,Se)=>{M=setTimeout(()=>Se(new dt(i)),i)}),new Promise((pt,Se)=>{if(!n)return;se=()=>Se(n.reason),n.addEventListener("abort",se,{once:!0})})])}finally{if(M)clearTimeout(M);if(se&&n)n.removeEventListener("abort",se);o(this,N,null,"f")}}let f=e(this,v,"f").indexOf(s);if(f<0)throw new u("bash session terminated");let d=e(this,v,"f").slice(f+s.length).match(/^(-?\d+)/),m=d?parseInt(d[1],10):-1,_=e(this,v,"f").slice(0,f).replace(ir,"").replace(/\n+$/,"");if(e(this,ee,"f"))_=`[output truncated]
|
|
11
|
+
${_}`;return{output:_,exitCode:m}}close(){if(e(this,W,"f"))return;o(this,W,!0,"f");let r=e(this,N,"f");o(this,N,null,"f"),r?.resolve(),e(this,b,"f").stdout.destroy(),e(this,b,"f").stderr.destroy(),e(this,b,"f").stdin.destroy();try{process.kill(-e(this,b,"f").pid,"SIGKILL")}catch{e(this,b,"f").kill("SIGKILL")}e(this,b,"f").unref()}}return b=new WeakMap,v=new WeakMap,ee=new WeakMap,W=new WeakMap,N=new WeakMap,ye=new WeakSet,Le=function(t){if(o(this,v,e(this,v,"f")+t,"f"),e(this,v,"f").length>nt)o(this,v,e(this,v,"f").slice(e(this,v,"f").length-nt),"f"),o(this,ee,!0,"f");if(e(this,N,"f")&&e(this,v,"f").indexOf(e(this,N,"f").sentinel)>=0){let i=e(this,N,"f");o(this,N,null,"f"),i.resolve()}},a})();function ar(a){Y(a.unrestrictedPaths);let r,t=Promise.resolve();return C({name:"bash",description:"Run a bash command in a persistent shell. State (cwd, env vars) persists across calls.",inputSchema:{type:"object",properties:{command:{type:"string",description:"The command to run"},restart:{type:"boolean",description:"Restart the persistent shell before running"},timeout_ms:{type:"integer",description:"Per-call timeout in milliseconds"}}},run:async({command:i,restart:n,timeout_ms:s},c)=>{let l=t,f=$t();t=f.promise;try{await l}catch{}try{if(n)r?.close(),r=void 0;if(!i){if(n)return"bash session restarted";throw new R("bash: command is required")}r??(r=new sr(a.workdir,a.env));try{let{output:h,exitCode:d}=await r.exec(i,{timeoutMs:s??ft,signal:c?.signal});if(d!==0)throw new R(h||`exit ${d}`);return h}catch(h){if(h instanceof R)throw h;throw r.close(),r=void 0,new R(`bash: ${h instanceof Error?h.message:String(h)}`)}}finally{f.resolve()}},close:()=>{r?.close(),r=void 0}})}function cr(a){return Y(a.unrestrictedPaths),C({name:"read",description:"Read a UTF-8 text file relative to the workdir.",inputSchema:{type:"object",properties:{file_path:{type:"string"},view_range:{type:"array",items:{type:"integer"},description:"[start_line, end_line] 1-indexed inclusive"}},required:["file_path"]},run:async({file_path:r,view_range:t})=>{if(!r)throw new R("read: file_path is required");let i=await oe(a,r);if(t?.length&&t.length!==2)throw new R("read: view_range must be [start_line, end_line]");let n;try{let d=await S.stat(i);if(!d.isFile())throw new R(`read: ${r} is not a regular file`);let m=ht(a.maxFileBytes);if(m!==null&&d.size>m){if(!t?.length)throw new R(`read: ${r} is ${d.size} bytes, exceeds ${m}-byte limit. Use the view_range parameter to read specific line ranges, e.g. view_range: [1, 500].`);let[_,E]=t;return await lr(i,r,_,E,m)}n=await S.readFile(i,"utf8")}catch(d){if(d instanceof R)throw d;throw new R(`read: ${q(d,r)}`)}if(!t?.length)return n;let[s,c]=t,l=n.split(`
|
|
12
12
|
`),f=Math.max(0,s-1),h=c>0?c:l.length;return l.slice(f,h).join(`
|
|
13
|
-
`)}})}async function lr(a,r,t,i,n){let s=new fr(r,t,i,n);if(s.rangeIsEmpty())return"";let c=ne.createReadStream(a,{highWaterMark:er});try{for await(let l of c)if(s.collectFrom(l),s.rangeIsCollected())break}finally{c.destroy()}return s.text()}var fr=(()=>{class a{constructor(r,t,i,n){we.add(this),te.set(this,void 0),_e.set(this,void 0),ge.set(this,void 0),U.set(this,void 0),j.set(this,void 0),V.set(this,void 0),B.set(this,0),re.set(this,[]),x.set(this,0),o(this,te,r,"f"),o(this,_e,t,"f"),o(this,ge,i,"f"),o(this,U,Math.max(0,t-1),"f"),o(this,j,i>0?i:1/0,"f"),o(this,V,n,"f")}rangeIsEmpty(){return e(this,j,"f")<=e(this,U,"f")}rangeIsCollected(){return e(this,B,"f")>=e(this,j,"f")}collectFrom(r){var t;let i=0;while(i<r.length&&!this.rangeIsCollected()){let n=r.indexOf(10,i),s=n<0?r.length:n;if(e(this,B,"f")>=e(this,U,"f"))e(this,we,"m",rt).call(this,r.subarray(i,s),n>=0);if(n<0)break;o(this,B,(t=e(this,B,"f"),t++,t),"f"),i=n+1}}text(){return Buffer.concat(e(this,re,"f"),e(this,x,"f")).toString("utf8")}}return te=new WeakMap,_e=new WeakMap,ge=new WeakMap,U=new WeakMap,j=new WeakMap,V=new WeakMap,B=new WeakMap,re=new WeakMap,x=new WeakMap,we=new WeakSet,rt=function(t,i){if(e(this,re,"f").push(t),o(this,x,e(this,x,"f")+t.length,"f"),i&&e(this,B,"f")+1<e(this,j,"f"))e(this,re,"f").push(ot),o(this,x,e(this,x,"f")+ot.length,"f");if(e(this,x,"f")>e(this,V,"f"))throw e(this,we,"m",it).call(this)},it=function(){if(e(this,j,"f")-e(this,U,"f")===1)return new
|
|
14
|
-
`)}})}function pr(a){return Y(a.unrestrictedPaths),C({name:"grep",description:"Search file contents for a regex. Uses ripgrep if available, otherwise a built-in walker.",inputSchema:{type:"object",properties:{pattern:{type:"string"},path:{type:"string"}},required:["pattern"]},run:async({pattern:r,path:t},i)=>{if(!r)throw new
|
|
15
|
-
[output truncated at ${ie} bytes]`);if(d===0)return n(l);if(d===1)return n("no matches");s(new
|
|
16
|
-
`)}async function
|
|
13
|
+
`)}})}async function lr(a,r,t,i,n){let s=new fr(r,t,i,n);if(s.rangeIsEmpty())return"";let c=ne.createReadStream(a,{highWaterMark:er});try{for await(let l of c)if(s.collectFrom(l),s.rangeIsCollected())break}finally{c.destroy()}return s.text()}var fr=(()=>{class a{constructor(r,t,i,n){we.add(this),te.set(this,void 0),_e.set(this,void 0),ge.set(this,void 0),U.set(this,void 0),j.set(this,void 0),V.set(this,void 0),B.set(this,0),re.set(this,[]),x.set(this,0),o(this,te,r,"f"),o(this,_e,t,"f"),o(this,ge,i,"f"),o(this,U,Math.max(0,t-1),"f"),o(this,j,i>0?i:1/0,"f"),o(this,V,n,"f")}rangeIsEmpty(){return e(this,j,"f")<=e(this,U,"f")}rangeIsCollected(){return e(this,B,"f")>=e(this,j,"f")}collectFrom(r){var t;let i=0;while(i<r.length&&!this.rangeIsCollected()){let n=r.indexOf(10,i),s=n<0?r.length:n;if(e(this,B,"f")>=e(this,U,"f"))e(this,we,"m",rt).call(this,r.subarray(i,s),n>=0);if(n<0)break;o(this,B,(t=e(this,B,"f"),t++,t),"f"),i=n+1}}text(){return Buffer.concat(e(this,re,"f"),e(this,x,"f")).toString("utf8")}}return te=new WeakMap,_e=new WeakMap,ge=new WeakMap,U=new WeakMap,j=new WeakMap,V=new WeakMap,B=new WeakMap,re=new WeakMap,x=new WeakMap,we=new WeakSet,rt=function(t,i){if(e(this,re,"f").push(t),o(this,x,e(this,x,"f")+t.length,"f"),i&&e(this,B,"f")+1<e(this,j,"f"))e(this,re,"f").push(ot),o(this,x,e(this,x,"f")+ot.length,"f");if(e(this,x,"f")>e(this,V,"f"))throw e(this,we,"m",it).call(this)},it=function(){if(e(this,j,"f")-e(this,U,"f")===1)return new R(`read: line ${e(this,U,"f")+1} of ${e(this,te,"f")} alone exceeds ${e(this,V,"f")}-byte limit. The read tool cannot return part of a line, so view_range cannot narrow this further.`);return new R(`read: view_range [${e(this,_e,"f")}, ${e(this,ge,"f")}] of ${e(this,te,"f")} exceeds ${e(this,V,"f")}-byte limit. Narrow the view_range to read a smaller portion.`)},a})();function dr(a){return Y(a.unrestrictedPaths),C({name:"write",description:"Write a UTF-8 text file relative to the workdir, creating parent directories as needed.",inputSchema:{type:"object",properties:{file_path:{type:"string"},content:{type:"string"}},required:["file_path","content"]},run:async({file_path:r,content:t})=>{if(!r)throw new R("write: file_path is required");let i=await oe(a,r),n=await mt(a,i);if(n!==void 0)throw new R(`write: ${r} is inside read-only directory ${n}`);try{await S.mkdir(O.dirname(i),{recursive:!0,mode:J}),await be(i,t??"")}catch(s){throw new R(`write: ${q(s,r)}`)}return`wrote ${Buffer.byteLength(t??"")} bytes to ${r}`}})}function hr(a){return Y(a.unrestrictedPaths),C({name:"edit",description:"Replace old_string with new_string in a file. old_string must be unique unless replace_all.",inputSchema:{type:"object",properties:{file_path:{type:"string"},old_string:{type:"string"},new_string:{type:"string"},replace_all:{type:"boolean"}},required:["file_path","old_string","new_string"]},run:async({file_path:r,old_string:t,new_string:i,replace_all:n})=>{if(!r)throw new R("edit: file_path is required");if(!t)throw new R("edit: old_string is required");let s=await oe(a,r),c=await mt(a,s);if(c!==void 0)throw new R(`edit: ${r} is inside read-only directory ${c}`);let l;try{let d=await S.stat(s);if(!d.isFile())throw new R(`edit: ${r} is not a regular file`);let m=ht(a.maxFileBytes);if(m!==null&&d.size>m)throw new R(`edit: ${r} is ${d.size} bytes, exceeds ${m}-byte limit. The edit tool loads the whole file and cannot modify a file this large.`);l=await S.readFile(s,"utf8")}catch(d){if(d instanceof R)throw d;throw new R(`edit: ${q(d,r)}`)}let f=l.split(t).length-1;if(f===0)throw new R(`edit: old_string not found in ${r}`);let h;if(n)h=l.split(t).join(i);else{if(f>1)throw new R(`edit: old_string appears ${f} times in ${r} (must be unique)`);h=l.replace(t,()=>i)}try{await be(s,h)}catch(d){throw new R(`edit: write: ${q(d,r)}`)}return`edited ${r} (${n?f:1} replacement(s))`}})}function mr(a){return a.split(/[\\/{},]/).includes("..")}function ur(a){return Y(a.unrestrictedPaths),C({name:"glob",description:"Match files under the workdir against a glob pattern. Results are mtime-sorted, newest first.",inputSchema:{type:"object",properties:{pattern:{type:"string"},path:{type:"string",description:"Directory to search in. Defaults to the workdir."}},required:["pattern"]},run:async({pattern:r,path:t})=>{if(!r)throw new R("glob: pattern is required");if(O.isAbsolute(r))throw new R("glob: absolute pattern not permitted; pass a relative pattern (and optionally path)");if(mr(r))throw new R('glob: ".." is not permitted in the pattern');let i=t?await oe(a,t):O.resolve(a.workdir),n=t?i:await X(i),s=[],c=ut;try{for await(let l of nr(r,{cwd:i,withFileTypes:!0,exclude:(f)=>f.name===".git"||f.name==="node_modules"})){if(c--<=0)break;if(!l.isFile())continue;let f=O.join(l.parentPath,l.name),h;try{h=await S.realpath(f)}catch{continue}if(!ae(n,h))continue;let d=0;try{d=(await S.stat(f)).mtimeMs}catch{}s.push({path:f,mtime:d})}}catch(l){throw new R(`glob: ${l instanceof Error?l.message:String(l)}`)}if(s.length===0)return"no matches";return s.sort((l,f)=>f.mtime-l.mtime),s.slice(0,rr).map((l)=>l.path).join(`
|
|
14
|
+
`)}})}function pr(a){return Y(a.unrestrictedPaths),C({name:"grep",description:"Search file contents for a regex. Uses ripgrep if available, otherwise a built-in walker.",inputSchema:{type:"object",properties:{pattern:{type:"string"},path:{type:"string"}},required:["pattern"]},run:async({pattern:r,path:t},i)=>{if(!r)throw new R("grep: pattern is required");let n=O.resolve(a.workdir);if(t)n=await oe(a,t);let s=await Sr();return s?yr(s,r,n,i?.signal):wr(r,n,i?.signal)}})}function yr(a,r,t,i){return new Promise((n,s)=>{let c=$e.spawn(a,["-n","--no-heading","-e",r,"--",t],{...i?{signal:i}:{}}),l="",f="",h=!1;c.stdout.on("data",(d)=>{if(h)return;if(l+=d,l.length>ie)h=!0,l=l.slice(0,ie),c.kill("SIGKILL")}),c.stderr.on("data",(d)=>f+=d),c.on("close",(d)=>{if(i?.aborted)return s(new R("grep: aborted"));if(h)return n(l+`
|
|
15
|
+
[output truncated at ${ie} bytes]`);if(d===0)return n(l);if(d===1)return n("no matches");s(new R(`grep: rg failed: ${f||`exit ${d}`}`))}),c.on("error",(d)=>{if(i?.aborted)return s(new R("grep: aborted"));s(new R(`grep: rg failed: ${d.message}`))})})}async function wr(a,r,t){let i;try{i=new RegExp(a)}catch(f){throw new R(`grep: invalid regex: ${f instanceof Error?f.message:String(f)}`)}let n=[],s=ie,c=(f)=>{if(s-=f.length+1,s<0)return n.push(`[output truncated at ${ie} bytes]`),!1;return n.push(f),!0};if((await S.stat(r).catch(()=>null))?.isFile())await st(r,i,c);else await gr(r,"",(f)=>st(O.join(r,f),i,c),t);if(t?.aborted)throw new R("grep: aborted");if(n.length===0)return"no matches";return n.join(`
|
|
16
|
+
`)}async function st(a,r,t){let i=ne.createReadStream(a,{encoding:"utf8"}),n=lt.createInterface({input:i,crlfDelay:1/0}),s=0;try{for await(let c of n){if(s++,c.length>tr)continue;if(r.test(c)&&!t(`${a}:${s}:${c}`))return!1}}catch{}finally{i.destroy()}return!0}var _r=40,ut=50000;async function gr(a,r,t,i){let n=ut;async function s(c,l){if(l>_r)return!0;if(i?.aborted)return!1;let f;try{f=await S.readdir(O.join(a,c),{withFileTypes:!0})}catch{return!0}for(let h of f){if(h.name===".git"||h.name==="node_modules")continue;if(n--<=0)return!1;if(i?.aborted)return!1;let d=c?O.join(c,h.name):h.name;if(h.isDirectory()){if(!await s(d,l+1))return!1}else if(h.isFile()){if(await t(d)===!1)return!1}}return!0}await s(r,0)}async function Sr(){let a=(process.env.PATH??"").split(O.delimiter);for(let r of a){let t=O.join(r,"rg");try{return await S.access(t,ne.constants.X_OK),t}catch{}}return null}export{Yt as MEMORY_FLUSH_TIMEOUT_MS,P as SessionMemoryError,Jt as SessionMemoryStores,Xr as betaAgentToolset20260401,gt as setupSkills};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var A=["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"],I=["content-type","cache-control","allow"];function p(e){let r=e.path;if(!r?.startsWith("/api/")||/[\\\r\n#]/.test(r))throw Error("request path must start with /api/");let n=new URL(r,"http://basalt.internal");if(n.origin!=="http://basalt.internal"||!n.pathname.startsWith("/api/"))throw Error("request path must stay within /api/");let o=e.method??"GET";if(!A.includes(o))throw Error("Unsupported request method");if(e.body!==void 0&&(!e.body||typeof e.body!=="object"||Array.isArray(e.body)))throw Error("request body must be a JSON object");if(e.body!==void 0&&(o==="GET"||o==="HEAD"))throw Error("GET and HEAD requests cannot have a body");let s=e.timeoutMs??1e4;if(!Number.isSafeInteger(s)||s<1||s>60000)throw Error("timeoutMs must be an integer between 1 and 60000");return{url:n,method:o,timeoutMs:s}}function g(e){let r={};for(let n of I){let o=e.headers.get(n);if(o)r[n]=o.slice(0,500)}return r}async function M(e,r){let n=e.getReader();r(()=>n.cancel());let o=[],s=0,i=!1;while(!0){let t=await n.read();if(t.done)break;let d=20480-s;if(o.push(t.value.subarray(0,d)),s+=Math.min(t.value.length,d),t.value.length>d){i=!0,await n.cancel();break}}let u=new Uint8Array(s),c=0;for(let t of o)u.set(t,c),c+=t.length;return{text:new TextDecoder().decode(u,{stream:i}),truncated:i}}async function
|
|
3
|
-
export{
|
|
2
|
+
var A=["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"],I=["content-type","cache-control","allow"];function p(e){let r=e.path;if(!r?.startsWith("/api/")||/[\\\r\n#]/.test(r))throw Error("request path must start with /api/");let n=new URL(r,"http://basalt.internal");if(n.origin!=="http://basalt.internal"||!n.pathname.startsWith("/api/"))throw Error("request path must stay within /api/");let o=e.method??"GET";if(!A.includes(o))throw Error("Unsupported request method");if(e.body!==void 0&&(!e.body||typeof e.body!=="object"||Array.isArray(e.body)))throw Error("request body must be a JSON object");if(e.body!==void 0&&(o==="GET"||o==="HEAD"))throw Error("GET and HEAD requests cannot have a body");let s=e.timeoutMs??1e4;if(!Number.isSafeInteger(s)||s<1||s>60000)throw Error("timeoutMs must be an integer between 1 and 60000");return{url:n,method:o,timeoutMs:s}}function g(e){let r={};for(let n of I){let o=e.headers.get(n);if(o)r[n]=o.slice(0,500)}return r}async function M(e,r){let n=e.getReader();r(()=>n.cancel());let o=[],s=0,i=!1;while(!0){let t=await n.read();if(t.done)break;let d=20480-s;if(o.push(t.value.subarray(0,d)),s+=Math.min(t.value.length,d),t.value.length>d){i=!0,await n.cancel();break}}let u=new Uint8Array(s),c=0;for(let t of o)u.set(t,c),c+=t.length;return{text:new TextDecoder().decode(u,{stream:i}),truncated:i}}async function tr(e,r,n){let{url:o,method:s,timeoutMs:i}=p(r),u=e.http;if(!u)throw Error("HTTP API is not attached; start the Basalt server first");let c=new AbortController,t=n?AbortSignal.any([n,c.signal]):c.signal;t.throwIfAborted();let d,b=()=>{d?.().catch(()=>{})},E=async()=>{let h=r.body!==void 0,a=await u.request(new Request(o.toString(),{method:s,headers:h?{"content-type":"application/json"}:void 0,body:h?JSON.stringify(r.body):void 0,signal:t}));if(t.aborted)throw await a.body?.cancel(),Error("API request cancelled");let m=a.body?await M(a.body,(T)=>{d=T}):{text:"",truncated:!1};return{status:a.status,headers:g(a),body:m.text,truncated:m.truncated}},f,l,y=new Promise((h,a)=>{if(l=()=>{a(Error("API request cancelled")),b()},t.addEventListener("abort",l,{once:!0}),t.aborted)l()}),w=new Promise((h,a)=>{f=setTimeout(()=>{a(Error(`API request timed out after ${i}ms`)),c.abort(),b()},i)});try{return await Promise.race([E(),y,w])}finally{if(clearTimeout(f),l)t.removeEventListener("abort",l)}}
|
|
3
|
+
export{tr};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var f=new Set;function
|
|
3
|
-
export{
|
|
2
|
+
var f=new Set;function eo(r){return f.add(r),()=>{f.delete(r)}}function ts(r){let t=[];for(let s of f)try{s(r)}catch(e){t.push(e)}if(t.length>0)throw AggregateError(t,"Failed to cleanup session resources")}var a=(1n<<41n)-1n,u=-1,n;function rn(r){let t=r??Date.now();if(!Number.isInteger(t)||t<0||t>281474976710655)throw RangeError("UUIDv7 timestamp must be an integer between 0 and 281474976710655");let s=r===void 0?Math.max(t,u):r;if(r===void 0)u=s;let e=new Uint8Array(16);if(globalThis.crypto.getRandomValues(e),n===void 0)n=BigInt(e[1])<<32n|BigInt(e[2])<<24n|BigInt(e[3])<<16n|BigInt(e[4])<<8n|BigInt(e[5]);else{if(n===a)throw RangeError("UUIDv7 generator sequence exhausted");n++}let c=BigInt(s);for(let o=5;o>=0;o--)e[o]=Number(c>>BigInt((5-o)*8))&255;e[6]=112|Number(n>>37n&0x0fn),e[7]=Number(n>>29n&0xffn),e[8]=128|Number(n>>23n&0x3fn),e[9]=Number(n>>15n&0xffn),e[10]=Number(n>>7n&0xffn),e[11]=Number((n&0x7fn)<<1n)|e[11]&1;let i=Array.from(e,(o)=>o.toString(16).padStart(2,"0"));return`${i.slice(0,4).join("")}-${i.slice(4,6).join("")}-${i.slice(6,8).join("")}-${i.slice(8,10).join("")}-${i.slice(10).join("")}`}
|
|
3
|
+
export{eo,ts,rn};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{xr,It,Xt,Jt,Yt,Zt,vr,_r,Mt,Ar,Er,Pr,Tr,kr,Rr}from"./chunk-zx75vnw8.js";import{v}from"./chunk-4rnmxtpx.js";import{ne}from"./chunk-959z9efn.js";import{X}from"./chunk-2tf7qfbx.js";import{w}from"./chunk-b516bp7n.js";import{j,J}from"./chunk-rn3jwyh1.js";import{we}from"./chunk-tfhp09nj.js";import{W,ge,ae,Ue,Y,V}from"./chunk-y4pvhes1.js";import{D}from"./chunk-szj85dqe.js";var T="v1",O="gcp-vertex-credentials",R=0,C=(e,o,t)=>{let i=new D,u=Ue(o);return(async()=>{let n={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:"pending",timestamp:Date.now()};try{if(t?.fetch&&t.fetch!==globalThis.fetch)throw Error("Custom fetch is not supported by the Google Vertex adapter");let c=L(t),g=c?S(e,c,t?.headers):I(e,M(t),P(t),t?.headers,t?.env),h=U(e,u,t),m=await t?.onPayload?.(h,e);if(m!==void 0)h=m;let p=await Rr(()=>g.models.generateContentStream(h),t);i.push({type:"start",partial:n});let r=null,f=n.content,l=()=>f.length-1;for await(let s of p){await t?.onProviderStreamEvent?.(s,e),n.responseId||=s.responseId;let k=s.candidates?.[0];if(k?.content?.parts)for(let a of k.content.parts){if(a.text!==void 0){let d=_r(a);if(!r||d&&r.type!=="thinking"||!d&&r.type!=="text"){if(r)if(r.type==="text")i.push({type:"text_end",contentIndex:f.length-1,content:r.text,partial:n});else i.push({type:"thinking_end",contentIndex:l(),content:r.thinking,partial:n});if(d)r={type:"thinking",thinking:"",thinkingSignature:void 0},n.content.push(r),i.push({type:"thinking_start",contentIndex:l(),partial:n});else r={type:"text",text:""},n.content.push(r),i.push({type:"text_start",contentIndex:l(),partial:n})}if(r.type==="thinking")r.thinking+=a.text,r.thinkingSignature=Mt(r.thinkingSignature,a.thoughtSignature),i.push({type:"thinking_delta",contentIndex:l(),delta:a.text,partial:n});else r.text+=a.text,r.textSignature=Mt(r.textSignature,a.thoughtSignature),i.push({type:"text_delta",contentIndex:l(),delta:a.text,partial:n})}if(a.functionCall){if(r){if(r.type==="text")i.push({type:"text_end",contentIndex:l(),content:r.text,partial:n});else i.push({type:"thinking_end",contentIndex:l(),content:r.thinking,partial:n});r=null}let d=a.functionCall.id,y={type:"toolCall",id:!d||n.content.some((x)=>x.type==="toolCall"&&x.id===d)?`${a.functionCall.name}_${Date.now()}_${++R}`:d,name:a.functionCall.name||"",arguments:a.functionCall.args??{},...a.thoughtSignature&&{thoughtSignature:a.thoughtSignature}};n.content.push(y),i.push({type:"toolcall_start",contentIndex:l(),partial:n}),i.push({type:"toolcall_delta",contentIndex:l(),delta:JSON.stringify(y.arguments),partial:n}),i.push({type:"toolcall_end",contentIndex:l(),toolCall:y,partial:n})}}if(k?.finishReason){if(n.rawStopReason=k.finishReason,n.stopReason=kr(k.finishReason),n.content.some((a)=>a.type==="toolCall")&&n.stopReason==="stop")n.stopReason="toolUse"}if(s.usageMetadata)n.usage={input:(s.usageMetadata.promptTokenCount||0)-(s.usageMetadata.cachedContentTokenCount||0),output:(s.usageMetadata.candidatesTokenCount||0)+(s.usageMetadata.thoughtsTokenCount||0),cacheRead:s.usageMetadata.cachedContentTokenCount||0,cacheWrite:0,reasoning:s.usageMetadata.thoughtsTokenCount||0,totalTokens:s.usageMetadata.totalTokenCount||0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},Y(e,n.usage)}if(r)if(r.type==="text")i.push({type:"text_end",contentIndex:l(),content:r.text,partial:n});else i.push({type:"thinking_end",contentIndex:l(),content:r.thinking,partial:n});if(t?.signal?.aborted)throw Error("Request was aborted");if(n.stopReason==="pending")throw Error("Google Vertex stream ended without a finish reason");if(n.stopReason==="aborted"||n.stopReason==="error"){let s=n.rawStopReason?`Provider stopped with: ${n.rawStopReason}`:"An unknown error occurred";throw Error(s)}i.push({type:"done",reason:n.stopReason,message:n}),i.end()}catch(c){for(let g of n.content)if("index"in g)delete g.index;n.stopReason=t?.signal?.aborted?"aborted":"error",n.errorMessage=J(j(c)),i.push({type:"error",reason:n.stopReason,error:n}),i.end()}})(),i},ue=(e,o,t)=>{let i={...X(e,o,t,void 0),toolChoice:t?.toolChoice};if(!t?.reasoning)return C(e,o,{...i,thinking:{enabled:!1}});let u=V(e,t.reasoning);if(u==="off")return C(e,o,{...i,thinking:{enabled:!1}});let n=Xt(e,u);if(Jt(e))return C(e,o,{...i,thinking:{enabled:!0,level:Yt(n)}});return C(e,o,{...i,thinking:{enabled:!0,budgetTokens:N(e,n,t.thinkingBudgets)}})};function I(e,o,t,i,u){let n=G(u);return new It({vertexai:!0,project:o,location:t,apiVersion:T,...n?{googleAuthOptions:n}:{},httpOptions:b(e,i)})}function S(e,o,t){return new It({vertexai:!0,apiKey:o,apiVersion:T,httpOptions:b(e,t)})}function b(e,o){let t={},i=_(e.baseUrl);if(i){if(t.baseUrl=i,t.baseUrlResourceScope=xr.COLLECTION,E(i))t.apiVersion=""}let u=we({"User-Agent":ne(),...e.headers,...o});if(u)t.headers=u;return Object.keys(t).length>0?t:void 0}function _(e){let o=e.trim();if(!o||o.includes("{location}"))return;return o}function E(e){try{return new URL(e).pathname.split("/").some((t)=>/^v\d+(?:beta\d*)?$/.test(t))}catch{return/(?:^|\/)v\d+(?:beta\d*)?(?:\/|$)/.test(e)}}function G(e){let o=v("GOOGLE_APPLICATION_CREDENTIALS",e);return o?{keyFilename:o}:void 0}function L(e){let o=e?.apiKey?.trim();if(!o||o===O||A(o))return;return o}function A(e){return/^<[^>]+>$/.test(e)}function M(e){let o=e?.project||v("GOOGLE_CLOUD_PROJECT",e?.env)||v("GCLOUD_PROJECT",e?.env);if(!o)throw Error("Vertex AI requires a project ID. Set GOOGLE_CLOUD_PROJECT/GCLOUD_PROJECT or pass project in options.");return o}function P(e){let o=e?.location||v("GOOGLE_CLOUD_LOCATION",e?.env);if(!o)throw Error("Vertex AI requires a location. Set GOOGLE_CLOUD_LOCATION or pass location in options.");return o}function U(e,o,t={}){let i=Ar(e,o),u=ge(o.messages),n=ae(o.messages),c={};if(t.temperature!==void 0)c.temperature=t.temperature;if(t.maxTokens!==void 0)c.maxOutputTokens=t.maxTokens;let g=Pr(e.id),h=n.length>0?Tr(n,t.toolChoice,g):void 0,m=u?W(u):"",p={...Object.keys(c).length>0&&c,...m&&{systemInstruction:w(m)},...n.length>0&&{tools:Er(n,!1,g)},...h!==void 0&&{toolConfig:{functionCallingConfig:{mode:h}}}};if(t.thinking?.enabled&&e.reasoning){let f={includeThoughts:!0};if(t.thinking.level!==void 0)f.thinkingLevel=Zt(t.thinking.level);else if(t.thinking.budgetTokens!==void 0)f.thinkingBudget=t.thinking.budgetTokens;p.thinkingConfig=f}else if(e.reasoning&&t.thinking&&!t.thinking.enabled)p.thinkingConfig=vr(e);if(t.signal){if(t.signal.aborted)throw Error("Request aborted");p.abortSignal=t.signal}return{model:e.id,contents:i,config:p}}function N(e,o,t){if(t?.[o]!==void 0)return t[o];if(e.id.includes("2.5-pro"))return{minimal:128,low:2048,medium:8192,high:32768}[o];if(e.id.includes("2.5-flash"))return{minimal:128,low:2048,medium:8192,high:24576}[o];return-1}export{C as stream,ue as streamSimple};
|