@shumai-one/shumai 0.3.2 → 0.3.4
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/bin/{chunk-qmtvy2j4.js → chunk-03pw611p.js} +2 -2
- package/bin/{chunk-1nh6xgek.js → chunk-05m8w09t.js} +1 -1
- package/bin/chunk-0ark0qrm.js +1 -0
- package/bin/{chunk-arpna31w.js → chunk-1apsnd7e.js} +1 -1
- package/bin/{chunk-g2dk56e7.js → chunk-1bfrnc6b.js} +1 -1
- package/bin/chunk-21h9kgp5.js +1 -0
- package/bin/{chunk-na2nympm.js → chunk-2967rnmn.js} +1 -1
- package/bin/chunk-2errtbmb.js +2 -0
- package/bin/{chunk-hrzm70wg.js → chunk-2jnyk045.js} +1 -1
- package/bin/{chunk-etces6ff.js → chunk-2mr99scd.js} +2 -2
- package/bin/chunk-2pxev94x.js +2 -0
- package/bin/chunk-2y9t0qxp.js +45 -0
- package/bin/{chunk-s7qpj715.js → chunk-2ydhnafa.js} +2 -2
- package/bin/chunk-38hp9gfh.js +2 -0
- package/bin/chunk-3t7v2de9.js +307 -0
- package/bin/{chunk-20y3wte3.js → chunk-3vbx3x11.js} +2 -2
- package/bin/{chunk-d3s00sn0.js → chunk-3xfhbvar.js} +2 -2
- package/bin/chunk-4153rke8.js +12 -0
- package/bin/{chunk-7jjc175m.js → chunk-4a185tez.js} +3 -3
- package/bin/{chunk-zxpef55w.js → chunk-4rexdetz.js} +3 -3
- package/bin/{chunk-1dawjfk8.js → chunk-58y9bagr.js} +2 -2
- package/bin/chunk-5dqn7egd.js +11 -0
- package/bin/{chunk-9p2d0mk1.js → chunk-5e48saab.js} +1 -1
- package/bin/{chunk-vnfmh5ke.js → chunk-5qwzveck.js} +2 -2
- package/bin/chunk-61hfhfce.js +2 -0
- package/bin/chunk-6ab9eftx.js +3 -0
- package/bin/chunk-6b0f3d07.js +2 -0
- package/bin/chunk-6gjn8trh.js +3 -0
- package/bin/{chunk-gn8snrnk.js → chunk-75x3w5hx.js} +1 -1
- package/bin/chunk-7e39zmss.js +1 -0
- package/bin/chunk-7h1m1e0b.js +1 -0
- package/bin/chunk-7kdz1eng.js +3 -0
- package/bin/chunk-7pcba64w.js +1 -0
- package/bin/{chunk-s05f0v9t.js → chunk-7xfx7741.js} +1 -1
- package/bin/chunk-898hrxwq.js +2 -0
- package/bin/{chunk-ph3e1bpp.js → chunk-89chaa11.js} +2 -2
- package/bin/chunk-8btfb5g6.js +2 -0
- package/bin/{chunk-gvn079hy.js → chunk-8pa1n500.js} +2 -2
- package/bin/{chunk-vy24ncn2.js → chunk-8qe7cpbr.js} +1 -1
- package/bin/{chunk-ws07a9kv.js → chunk-8tnq43k9.js} +1 -1
- package/bin/{chunk-1d22tysv.js → chunk-8wzepzp3.js} +2 -2
- package/bin/chunk-9deae0n7.js +3 -0
- package/bin/{chunk-3rcc5s99.js → chunk-ankkm2wz.js} +2 -2
- package/bin/chunk-ardp3pze.js +2 -0
- package/bin/chunk-axe5rq99.js +7 -0
- package/bin/chunk-bagxeg82.js +2 -0
- package/bin/{chunk-ss45w8ks.js → chunk-bhqrqt97.js} +2 -2
- package/bin/chunk-bn1sts8x.js +3 -0
- package/bin/{chunk-31mjcykb.js → chunk-bpb0szs5.js} +2 -2
- package/bin/{chunk-tsncwscz.js → chunk-c1j58ekb.js} +2 -2
- package/bin/chunk-c4nenmry.js +2 -0
- package/bin/chunk-c9f6n4sf.js +3 -0
- package/bin/chunk-cwh21vfb.js +2 -0
- package/bin/chunk-cwpmf8tx.js +2 -0
- package/bin/{chunk-ejfmxjw6.js → chunk-d2xrh0vv.js} +2 -2
- package/bin/chunk-d4sg0z3y.js +2 -0
- package/bin/chunk-d4sjezbk.js +8 -0
- package/bin/{chunk-vgb8bzcg.js → chunk-ddfx823h.js} +2 -2
- package/bin/chunk-dtjx1097.js +2 -0
- package/bin/chunk-e32bzfza.js +1 -0
- package/bin/chunk-e6rmqgzv.js +2 -0
- package/bin/chunk-ersxsrz8.js +62 -0
- package/bin/chunk-gg1wfpm8.js +3 -0
- package/bin/{chunk-qc6dmzn0.js → chunk-gg8dmkwd.js} +2 -2
- package/bin/chunk-gnx9g8px.js +2 -0
- package/bin/{chunk-xawwxdq9.js → chunk-h0k9zw29.js} +2 -2
- package/bin/chunk-htrzgs2a.css +1 -0
- package/bin/chunk-j2jdrmaa.js +2 -0
- package/bin/{chunk-v2kfr8fx.js → chunk-j5dejr3e.js} +2 -2
- package/bin/{chunk-wap08p4j.js → chunk-j5q3t199.js} +2 -2
- package/bin/chunk-jgxhv36z.js +3 -0
- package/bin/{chunk-dwswqq3g.js → chunk-jnx8p6kj.js} +1 -1
- package/bin/chunk-k41vt2gq.js +1 -0
- package/bin/chunk-k78m3rar.js +2 -0
- package/bin/chunk-kfbztymc.js +4 -0
- package/bin/chunk-kgr3ytpb.js +5 -0
- package/bin/chunk-khc3dydj.js +2 -0
- package/bin/chunk-krpr6g8a.js +1 -0
- package/bin/chunk-m8tnsds1.js +2 -0
- package/bin/chunk-mfmcsdd7.js +1 -0
- package/bin/chunk-msjv1ykh.js +2 -0
- package/bin/chunk-n73dbqps.js +1 -0
- package/bin/{chunk-5vqan9c4.js → chunk-n7cmya8k.js} +2 -2
- package/bin/{chunk-hfp4hpca.js → chunk-nabagpah.js} +2 -2
- package/bin/chunk-nn5qpr0q.js +1 -0
- package/bin/{chunk-ve7v8wtv.js → chunk-pew69nxg.js} +2 -2
- package/bin/{chunk-7eycsyk6.js → chunk-q2shr586.js} +1 -1
- package/bin/chunk-q7v8sj72.js +1 -0
- package/bin/chunk-q9tm2d21.js +8 -0
- package/bin/{chunk-mcxsk75h.js → chunk-qw5yjhab.js} +3 -3
- package/bin/{chunk-j0p1peav.js → chunk-r9thyg31.js} +2 -2
- package/bin/{chunk-h2wsm7h3.js → chunk-s584wxzj.js} +2 -2
- package/bin/{chunk-wr5byz6r.js → chunk-s5s1rk4n.js} +1 -1
- package/bin/{chunk-zs9b0f3z.js → chunk-scfbmsy7.js} +2 -2
- package/bin/{chunk-k20bhxed.js → chunk-sddrv3ep.js} +1 -1
- package/bin/{chunk-amsb41z5.js → chunk-sfmhbk59.js} +1 -1
- package/bin/chunk-tbdgkpgw.js +2 -0
- package/bin/chunk-twhj7h73.js +1 -0
- package/bin/{chunk-mahxw48e.js → chunk-v5zdafv4.js} +2 -2
- package/bin/{chunk-3t7mjvdv.js → chunk-vzx1r87y.js} +2 -2
- package/bin/{chunk-a76c5r3c.js → chunk-w3xzd86e.js} +2 -2
- package/bin/{chunk-nzy3pjjm.js → chunk-xkh6b42h.js} +2 -2
- package/bin/chunk-yn7mxpmb.js +7 -0
- package/bin/{chunk-yahb7wan.js → chunk-z544s59c.js} +2 -2
- package/bin/{chunk-f8cn9m28.js → chunk-zned6mj8.js} +1 -1
- package/bin/{chunk-08mxv0sm.js → chunk-zpq34g0w.js} +2 -2
- package/bin/shumai-app.html +1 -1
- package/bin/shumai-app.js +495 -372
- package/package.json +7 -7
- package/prisma/migrations/20260801065040_add_audit_log/migration.sql +33 -0
- package/prisma/migrations/20260805021613_add_asset_autofill_context/migration.sql +2 -0
- package/prisma/migrations/20260806082136_add_sharelink_watermark/migration.sql +69 -0
- package/prisma/migrations/20260806085643_add_watermark_file_status/migration.sql +7 -0
- package/prisma/migrations/20260807140837_clean_media_remove_raw_transcodes_and_original_download_url/migration.sql +86 -0
- package/prisma/migrations/20260808014542_add_sharelink_allow_download/migration.sql +2 -0
- package/prisma/schema.prisma +93 -0
- package/bin/chunk-08dr94gp.js +0 -2
- package/bin/chunk-0t4z17qr.js +0 -2
- package/bin/chunk-2ynx0den.js +0 -8
- package/bin/chunk-31a3k77j.js +0 -2
- package/bin/chunk-3jdef7n4.js +0 -6
- package/bin/chunk-4ahve1nf.js +0 -2
- package/bin/chunk-4hdnrwh1.js +0 -1
- package/bin/chunk-4hdx2tv0.js +0 -2
- package/bin/chunk-4htdb0xp.js +0 -1
- package/bin/chunk-4p7xpfey.js +0 -2
- package/bin/chunk-5f81c951.js +0 -1
- package/bin/chunk-5zntjzxw.js +0 -3
- package/bin/chunk-6a2eb3b5.js +0 -3
- package/bin/chunk-6t3gdd7e.js +0 -2
- package/bin/chunk-7d5kep8c.js +0 -2
- package/bin/chunk-7kzqkp5z.js +0 -1
- package/bin/chunk-7sh6409h.js +0 -1
- package/bin/chunk-7y8dng8t.js +0 -2
- package/bin/chunk-8e5zvy88.js +0 -307
- package/bin/chunk-8m6zg15c.js +0 -4
- package/bin/chunk-8qyke29r.js +0 -7
- package/bin/chunk-90et6bwm.js +0 -3
- package/bin/chunk-9c7fxjej.js +0 -2
- package/bin/chunk-a10tf0d8.js +0 -3
- package/bin/chunk-b10meywb.js +0 -2
- package/bin/chunk-b1e3tec3.js +0 -62
- package/bin/chunk-bdjhb77e.js +0 -2
- package/bin/chunk-beay9amy.js +0 -1
- package/bin/chunk-c3fvs0bv.js +0 -4
- package/bin/chunk-c5my1b3k.js +0 -7
- package/bin/chunk-dhekxndw.js +0 -3
- package/bin/chunk-dwaj1yn4.js +0 -2
- package/bin/chunk-er1rb6yj.js +0 -1
- package/bin/chunk-etqpzc9e.js +0 -3
- package/bin/chunk-fdpjw17x.js +0 -7
- package/bin/chunk-gqh4ttjh.js +0 -3
- package/bin/chunk-hz31j0hk.js +0 -4
- package/bin/chunk-jm6bxtzt.js +0 -41
- package/bin/chunk-jstc7pka.js +0 -2
- package/bin/chunk-k0a35mg9.js +0 -2
- package/bin/chunk-k9w6mk9d.js +0 -3
- package/bin/chunk-kgb16ggd.css +0 -1
- package/bin/chunk-m4py21f3.js +0 -2
- package/bin/chunk-mm1j72a8.js +0 -7
- package/bin/chunk-nr89225z.js +0 -2
- package/bin/chunk-nrf5r23d.js +0 -1
- package/bin/chunk-nt9tfjx6.js +0 -12
- package/bin/chunk-p396vw9h.js +0 -8
- package/bin/chunk-p9xfyqh1.js +0 -2
- package/bin/chunk-pj0fgb2x.js +0 -6
- package/bin/chunk-pp072ksj.js +0 -2
- package/bin/chunk-q5cdjzbv.js +0 -3
- package/bin/chunk-qn96vbke.js +0 -2
- package/bin/chunk-qvgc9e08.js +0 -3
- package/bin/chunk-rrxjvewm.js +0 -2
- package/bin/chunk-s5rfya1p.js +0 -1
- package/bin/chunk-scsy69bp.js +0 -1
- package/bin/chunk-sf6fwvrs.js +0 -8
- package/bin/chunk-t2txvzkp.js +0 -3
- package/bin/chunk-td54rdfj.js +0 -8
- package/bin/chunk-vb9m47z9.js +0 -1
- package/bin/chunk-vf066xwh.js +0 -3
- package/bin/chunk-w3a50kz8.js +0 -3
- package/bin/chunk-w9w5301f.js +0 -4
- package/bin/chunk-wny0qagx.js +0 -3
- package/bin/chunk-wqhk76de.js +0 -14
- package/bin/chunk-wrz9e73c.js +0 -2
- package/bin/chunk-x5dcgk62.js +0 -6
- package/bin/chunk-xwmsxg5x.js +0 -1
- package/bin/chunk-y2nw8rbx.js +0 -4
- package/bin/chunk-y9ttm07y.js +0 -3
- package/bin/chunk-z0ej44ak.js +0 -3
- package/bin/chunk-zemgtnk0.js +0 -1
- package/bin/chunk-zg0vm233.js +0 -2
- package/bin/chunk-zhd2mkbr.js +0 -1
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Yj as F}from"./chunk-bhqrqt97.js";import{$j as B,ak as A,bk as b,ck as h,dk as x,ek as f,fk as g}from"./chunk-kfbztymc.js";import{hk as N,jk as v,kk as H}from"./chunk-4rexdetz.js";import{lk as K,mk as y}from"./chunk-9deae0n7.js";import{tk as I}from"./chunk-6gjn8trh.js";import{wk as C}from"./chunk-sfmhbk59.js";import{yk as T}from"./chunk-75x3w5hx.js";import{Dk as L,Ek as P}from"./chunk-7kdz1eng.js";import{Fk as U}from"./chunk-6ab9eftx.js";import"./chunk-8tnq43k9.js";var k="v1",u="gcp-vertex-credentials",c={THINKING_LEVEL_UNSPECIFIED:N.THINKING_LEVEL_UNSPECIFIED,MINIMAL:N.MINIMAL,LOW:N.LOW,MEDIUM:N.MEDIUM,HIGH:N.HIGH},s=0,V=(q,w,J)=>{let X=new U;return(async()=>{let Q={role:"assistant",content:[],api:"google-vertex",provider:q.provider,model:q.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"stop",timestamp:Date.now()};try{let z=e(J),$=z?l(q,z,J?.headers):p(q,o(J),qq(J),J?.headers,J?.env),R=wq(q,w,J),_=await J?.onPayload?.(R,q);if(_!==void 0)R=_;let d=await $.models.generateContentStream(R);X.push({type:"start",partial:Q});let Y=null,M=Q.content,D=()=>M.length-1;for await(let W of d){Q.responseId||=W.responseId;let G=W.candidates?.[0];if(G?.content?.parts)for(let Z of G.content.parts){if(Z.text!==void 0){let S=B(Z);if(!Y||S&&Y.type!=="thinking"||!S&&Y.type!=="text"){if(Y)if(Y.type==="text")X.push({type:"text_end",contentIndex:M.length-1,content:Y.text,partial:Q});else X.push({type:"thinking_end",contentIndex:D(),content:Y.thinking,partial:Q});if(S)Y={type:"thinking",thinking:"",thinkingSignature:void 0},Q.content.push(Y),X.push({type:"thinking_start",contentIndex:D(),partial:Q});else Y={type:"text",text:""},Q.content.push(Y),X.push({type:"text_start",contentIndex:D(),partial:Q})}if(Y.type==="thinking")Y.thinking+=Z.text,Y.thinkingSignature=A(Y.thinkingSignature,Z.thoughtSignature),X.push({type:"thinking_delta",contentIndex:D(),delta:Z.text,partial:Q});else Y.text+=Z.text,Y.textSignature=A(Y.textSignature,Z.thoughtSignature),X.push({type:"text_delta",contentIndex:D(),delta:Z.text,partial:Q})}if(Z.functionCall){if(Y){if(Y.type==="text")X.push({type:"text_end",contentIndex:D(),content:Y.text,partial:Q});else X.push({type:"thinking_end",contentIndex:D(),content:Y.thinking,partial:Q});Y=null}let S=Z.functionCall.id,j={type:"toolCall",id:!S||Q.content.some((O)=>O.type==="toolCall"&&O.id===S)?`${Z.functionCall.name}_${Date.now()}_${++s}`:S,name:Z.functionCall.name||"",arguments:Z.functionCall.args??{},...Z.thoughtSignature&&{thoughtSignature:Z.thoughtSignature}};Q.content.push(j),X.push({type:"toolcall_start",contentIndex:D(),partial:Q}),X.push({type:"toolcall_delta",contentIndex:D(),delta:JSON.stringify(j.arguments),partial:Q}),X.push({type:"toolcall_end",contentIndex:D(),toolCall:j,partial:Q})}}if(G?.finishReason){if(Q.stopReason=g(G.finishReason),Q.content.some((Z)=>Z.type==="toolCall"))Q.stopReason="toolUse"}if(W.usageMetadata)Q.usage={input:(W.usageMetadata.promptTokenCount||0)-(W.usageMetadata.cachedContentTokenCount||0),output:(W.usageMetadata.candidatesTokenCount||0)+(W.usageMetadata.thoughtsTokenCount||0),cacheRead:W.usageMetadata.cachedContentTokenCount||0,cacheWrite:0,reasoning:W.usageMetadata.thoughtsTokenCount||0,totalTokens:W.usageMetadata.totalTokenCount||0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},L(q,Q.usage)}if(Y)if(Y.type==="text")X.push({type:"text_end",contentIndex:D(),content:Y.text,partial:Q});else X.push({type:"thinking_end",contentIndex:D(),content:Y.thinking,partial:Q});if(J?.signal?.aborted)throw Error("Request was aborted");if(Q.stopReason==="aborted"||Q.stopReason==="error")throw Error("An unknown error occurred");X.push({type:"done",reason:Q.stopReason,message:Q}),X.end()}catch(z){for(let $ of Q.content)if("index"in $)delete $.index;Q.stopReason=J?.signal?.aborted?"aborted":"error",Q.errorMessage=y(K(z)),X.push({type:"error",reason:Q.stopReason,error:Q}),X.end()}})(),X},Gq=(q,w,J)=>{let X=I(q,w,J,void 0);if(!J?.reasoning)return V(q,w,{...X,thinking:{enabled:!1}});let Q=P(q,J.reasoning),z=Q==="off"?"high":Q,$=q;if(E($)||a($))return V(q,w,{...X,thinking:{enabled:!0,level:Qq(z,$)}});return V(q,w,{...X,thinking:{enabled:!0,budgetTokens:Xq($,z,J.thinkingBudgets)}})};function p(q,w,J,X,Q){let z=n(Q);return new H({vertexai:!0,project:w,location:J,apiVersion:k,...z?{googleAuthOptions:z}:{},httpOptions:m(q,X)})}function l(q,w,J){return new H({vertexai:!0,apiKey:w,apiVersion:k,httpOptions:m(q,J)})}function m(q,w){let J={},X=r(q.baseUrl);if(X){if(J.baseUrl=X,J.baseUrlResourceScope=v.COLLECTION,i(X))J.apiVersion=""}let Q=T({...q.headers,...w});if(Q)J.headers=Q;return Object.keys(J).length>0?J:void 0}function r(q){let w=q.trim();if(!w||w.includes("{location}"))return;return w}function i(q){try{return new URL(q).pathname.split("/").some((J)=>/^v\d+(?:beta\d*)?$/.test(J))}catch{return/(?:^|\/)v\d+(?:beta\d*)?(?:\/|$)/.test(q)}}function n(q){let w=F("GOOGLE_APPLICATION_CREDENTIALS",q);return w?{keyFilename:w}:void 0}function e(q){let w=q?.apiKey?.trim();if(!w||w===u||t(w))return;return w}function t(q){return/^<[^>]+>$/.test(q)}function o(q){let w=q?.project||F("GOOGLE_CLOUD_PROJECT",q?.env)||F("GCLOUD_PROJECT",q?.env);if(!w)throw Error("Vertex AI requires a project ID. Set GOOGLE_CLOUD_PROJECT/GCLOUD_PROJECT or pass project in options.");return w}function qq(q){let w=q?.location||F("GOOGLE_CLOUD_LOCATION",q?.env);if(!w)throw Error("Vertex AI requires a location. Set GOOGLE_CLOUD_LOCATION or pass location in options.");return w}function wq(q,w,J={}){let X=b(q,w),Q={};if(J.temperature!==void 0)Q.temperature=J.temperature;if(J.maxTokens!==void 0)Q.maxOutputTokens=J.maxTokens;let z=w.tools?.length?f(w.tools,J.toolChoice,x(q.id)):void 0,$={...Object.keys(Q).length>0&&Q,...w.systemPrompt&&{systemInstruction:C(w.systemPrompt)},...w.tools&&w.tools.length>0&&{tools:h(w.tools)},...z!==void 0&&{toolConfig:{functionCallingConfig:{mode:z}}}};if(J.thinking?.enabled&&q.reasoning){let _={includeThoughts:!0};if(J.thinking.level!==void 0)_.thinkingLevel=c[J.thinking.level];else if(J.thinking.budgetTokens!==void 0)_.thinkingBudget=J.thinking.budgetTokens;$.thinkingConfig=_}else if(q.reasoning&&J.thinking&&!J.thinking.enabled)$.thinkingConfig=Jq(q);if(J.signal){if(J.signal.aborted)throw Error("Request aborted");$.abortSignal=J.signal}return{model:q.id,contents:X,config:$}}function E(q){return/gemini-3(?:\.\d+)?-pro/.test(q.id.toLowerCase())}function a(q){let w=q.id.toLowerCase();return/gemini-3(?:\.\d+)?-flash/.test(w)||w==="gemini-flash-latest"||w==="gemini-flash-lite-latest"}function Jq(q){let w=q;if(E(w))return{thinkingLevel:N.LOW};if(a(w))return{thinkingLevel:N.MINIMAL};return{thinkingBudget:0}}function Qq(q,w){if(E(w))switch(q){case"minimal":case"low":return"LOW";case"medium":case"high":return"HIGH"}switch(q){case"minimal":return"MINIMAL";case"low":return"LOW";case"medium":return"MEDIUM";case"high":return"HIGH"}}function Xq(q,w,J){if(J?.[w]!==void 0)return J[w];if(q.id.includes("2.5-pro"))return{minimal:128,low:2048,medium:8192,high:32768}[w];if(q.id.includes("2.5-flash"))return{minimal:128,low:2048,medium:8192,high:24576}[w];return-1}export{Gq as streamSimple,V as stream};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
var E=new Set;function H(k){return E.add(k),()=>{E.delete(k)}}var w=-1/0,z=0;function G(k){if(globalThis.crypto?.getRandomValues){globalThis.crypto.getRandomValues(k);return}for(let A=0;A<k.length;A++)k[A]=Math.floor(Math.random()*256)}function K(){let k=new Uint8Array(16);G(k);let A=Date.now();if(A>w)z=k[6]*16777216+k[7]*65536+k[8]*256+k[9],w=A;else if(z=z+1>>>0,z===0)w++;let v=new Uint8Array(16);v[0]=w/1099511627776&255,v[1]=w/4294967296&255,v[2]=w/16777216&255,v[3]=w/65536&255,v[4]=w/256&255,v[5]=w&255,v[6]=112|z>>>28&15,v[7]=z>>>20&255,v[8]=128|z>>>14&63,v[9]=z>>>6&255,v[10]=(z&63)<<2|k[10]&3,v[11]=k[11],v[12]=k[12],v[13]=k[13],v[14]=k[14],v[15]=k[15];let D=Array.from(v,(F)=>F.toString(16).padStart(2,"0"));return`${D.slice(0,4).join("")}-${D.slice(4,6).join("")}-${D.slice(6,8).join("")}-${D.slice(8,10).join("")}-${D.slice(10,16).join("")}`}
|
|
3
|
+
export{H as Sd,K as Td};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{h as t,j as e,k as y}from"./chunk-3t7v2de9.js";import{jg as _G,lg as $G,mg as QG,ng as XG}from"./chunk-38hp9gfh.js";import{Ag as r,Bg as H,Cg as O,Fj as v,Gg as NG,Jh as HG,Kh as JG,_h as WG,cj as YG,dh as l,oh as S,ti as a,xj as p,yi as s,zg as gG}from"./chunk-ersxsrz8.js";import{Jk as SG}from"./chunk-8tnq43k9.js";function cG({file:Y,mediaControllerRef:X,onPlay:K,onPause:N,onTimeUpdate:V,annotations:_,startTime:U,shareId:Z,allowDownload:L,children:B}){let M=y(Y).viewer;return H(M,{ref:X,file:Y,onPlay:K,onPause:N,onTimeUpdate:V,annotations:_,startTime:U,shareId:Z,allowDownload:L,children:B},Y.id)}var J=SG(gG(),1);function GG({activeState:Y,activeAsset:X,previewUrl:K,isFullScreen:N,onTogglePlay:V,onToggleLoop:_,onSeek:U,onVolumeChange:Z,onToggleMute:L,onChangePlaybackRate:B,onChangeResolution:F,onZoomIn:M,onZoomOut:R,onFit:z,onDownload:b,onToggleFullScreen:w,allowDownload:T=!0}){if(Y?.kind==="video"&&Y.video&&X){let $=Y.video,f=$.totalFrames/$.frameRate,x=$.currentFrame/$.frameRate,g={isPlaying:$.isPlaying,progress:f>0?x/f*100:0,currentTime:x,duration:f,volume:$.volume,isMuted:$.isMuted,isLooping:$.isLooping,playbackRate:$.playbackRate,isFullScreen:N,showFrames:!1,currentResolution:$.currentResolution},u=K&&!X.media?.videoPreview?{...X,media:{...X.media,videoPreview:{url:K}}}:X;return H(t,{state:g,zoom:Y.zoom,isControlsVisible:!0,floatOverlayInFullScreen:!1,buffered:$.buffered,data:u,resolutions:$.resolutions,togglePlay:V,toggleLoop:_,toggleMute:L,handleVolumeChange:Z,changePlaybackRate:B,changeResolution:(k)=>F(k.resolution),handleDownload:(k)=>b(k),toggleFullScreen:w,onZoomChange:(k)=>k>=Y.zoom?M():R(),onZoomReset:z,frameRate:$.frameRate,totalFrames:$.totalFrames,currentFrame:$.currentFrame,seekToFrame:U,allowDownload:T})}if(Y?.kind==="image")return H(e,{zoom:Y.zoom,onZoomIn:M,onZoomOut:R,onFit:z,onDownload:()=>b(),canDownload:!!X?.media?.original?.key,fullscreen:{isFullScreen:N,onToggle:w},allowDownload:T});return H("div",{className:"relative z-10 flex items-center justify-end gap-2 border-t border-border bg-card px-4 py-3",children:H("button",{onClick:w,className:"text-foreground transition-colors hover:text-primary",title:"Fullscreen",children:N?H(s,{className:"h-5 w-5"}):H(a,{className:"h-5 w-5"})})})}function c({side:Y,fileName:X,version:K,activeVersionId:N,versions:V,isActive:_,onActivate:U,onSwitchVersion:Z,onExit:L}){let B=p("flex-shrink-0 rounded p-1 transition-colors hover:bg-muted",_?"text-foreground":"text-muted-foreground hover:text-foreground"),F=H("button",{onClick:L,title:v.exit_compare(),className:B,children:H(YG,{className:"h-4 w-4"})}),M=O("button",{onClick:U,className:p("flex min-w-0 items-center gap-1 rounded px-2 py-1 text-sm font-medium transition-colors hover:bg-muted",_?"text-foreground":"text-muted-foreground hover:text-foreground"),children:[H("span",{className:"truncate",children:X}),K!==void 0&&O("span",{className:p("flex-shrink-0 rounded border px-1 py-0 text-xs",_?"border-foreground/40":"border-border"),children:["v",K]})]}),R=O(_G,{children:[H($G,{onClick:U,title:v.switch_version(),className:B,children:H(JG,{className:"h-4 w-4"})}),H(QG,{align:Y==="left"?"start":"end",className:"w-80 p-1",children:H("div",{className:"flex max-h-96 flex-col gap-1 overflow-y-auto",children:V.map((z)=>{let b=z.id===N;return O(XG,{onClick:()=>Z(z.id),className:"flex cursor-pointer items-center gap-3 rounded-md px-3 py-2",children:[O("div",{className:"flex min-w-[2rem] flex-shrink-0 items-center justify-center rounded-full bg-muted px-2 py-0.5 text-xs font-semibold text-muted-foreground select-none",children:["v",z.version]}),H("div",{className:"flex h-10 w-16 flex-shrink-0 items-center justify-center overflow-hidden rounded-md border border-border bg-muted",children:z.previewUrl?H("img",{src:z.previewUrl,alt:z.name||void 0,className:"h-full w-full object-cover"}):H(WG,{className:"h-4 w-4 text-muted-foreground"})}),O("div",{className:"flex min-w-0 flex-1 flex-col text-left",children:[H("span",{className:"truncate text-sm font-semibold text-foreground",children:z.name}),H("span",{className:"truncate text-xs text-muted-foreground",children:z.creator?.name||"Unknown"})]}),b&&H(HG,{className:"ml-auto h-4 w-4 flex-shrink-0 text-primary"})]},z.id)})})})]});return H("div",{onMouseDown:U,className:p("dark flex h-10 flex-shrink-0 items-center gap-1 border-b bg-background px-2 transition-colors",_?"border-b-2 border-primary":"border-border"),children:Y==="left"?O(r,{children:[F,M,R]}):O(r,{children:[M,R,H("div",{className:"ml-auto"}),F]})})}function KG(Y,X,K){return NG({queryKey:X?["public-share-file",K,Y,localStorage.getItem(`share_pwd_${K}`)||""]:["files",Y],queryFn:async()=>{if(X){let V=localStorage.getItem(`share_pwd_${K}`)||"",_=await l.api.shares[":shareId"].files[":fileId"].$get({param:{shareId:K,fileId:Y}},{headers:{"x-share-password":V}});if(!_.ok)throw Error("Failed to fetch version asset");return await _.json()}let N=await l.api.files[":fileId"].$get({param:{fileId:Y}});if(!N.ok)throw Error("Failed to fetch version asset");return await N.json()},enabled:!!Y&&(!X||!!K)})}function zH({isPublic:Y=!1,shareId:X,versions:K,leftId:N,rightId:V,activeSide:_,annotations:U,seekRequest:Z,onActiveSideChange:L,onSwitchVersion:B,onExit:F,onActiveAssetChange:M,onPlay:R,onTimeUpdate:z,allowDownload:b=!0}){let w=J.useRef(null),T=J.useRef(null),$=J.useRef(null),[f,x]=J.useState(null),[g,u]=J.useState(null),[k,zG]=J.useState(1),[OG,n]=J.useState(!1),[qG,VG]=J.useState(!1),{data:E,isLoading:ZG}=KG(N,Y,X),{data:P,isLoading:MG}=KG(V,Y,X),UG=y(E),LG=y(P),I=!!E&&!!P&&UG.id===LG.id,m=_==="left"?E:P,h=_==="left"?f:g,D=J.useCallback(()=>_==="left"?T.current:$.current,[_]),d=J.useCallback(()=>_==="left"?$.current:T.current,[_]);J.useEffect(()=>{M(m??null)},[m,M]),J.useEffect(()=>{if(!Z)return;let G=D();if(G?.seekToSecond(Z.second),G?.pause(),I){let W=d();W?.seekToSecond(Z.second),W?.pause()}},[Z?.nonce]),J.useEffect(()=>{let G=()=>VG(!!document.fullscreenElement);return document.addEventListener("fullscreenchange",G),()=>document.removeEventListener("fullscreenchange",G)},[]);let BG=J.useCallback((G)=>x(G),[]),DG=J.useCallback((G)=>u(G),[]),q=J.useCallback((G)=>{let W=D();if(W)G(W);if(I){let Q=d();if(Q)G(Q)}},[D,d,I]),j=J.useCallback(()=>{let G=!h?.video?.isPlaying;q((W)=>G?W.play():W.pause())},[h?.video?.isPlaying,q]);J.useEffect(()=>{let G=(W)=>{let Q=document.activeElement;if(Q&&(Q.tagName==="INPUT"||Q.tagName==="TEXTAREA"||Q instanceof HTMLElement&&Q.isContentEditable))return;let A=W.key===" ",C=Q&&(Q.tagName==="BUTTON"||Q.tagName==="A"||Q.tagName==="SELECT"||Q.tagName==="OPTION"||Q.getAttribute("role")==="button"||Q.getAttribute("role")==="link"||Q.getAttribute("role")==="checkbox"||Q.getAttribute("role")==="radio"||Q.getAttribute("role")==="menuitem");if(A&&C)return;if(W.key===" "||W.key.toLowerCase()==="k")W.preventDefault(),j()};return window.addEventListener("keydown",G),()=>{window.removeEventListener("keydown",G)}},[j]);let FG=J.useCallback((G)=>q((W)=>W.seekToFrame(G)),[q]),EG=J.useCallback(()=>D()?.toggleLoop(),[D]),PG=J.useCallback((G)=>{zG(G),n(G===0)},[]),RG=J.useCallback(()=>n((G)=>!G),[]),wG=J.useCallback((G)=>q((W)=>W.setPlaybackRate(G)),[q]),TG=J.useCallback((G)=>D()?.changeResolution(G),[D]),kG=J.useCallback(()=>q((G)=>G.zoomBy(1.2)),[q]),IG=J.useCallback(()=>q((G)=>G.zoomBy(0.8)),[q]),bG=J.useCallback(()=>q((G)=>G.fit()),[q]),yG=J.useCallback((G)=>{D()?.download(G)},[D]),fG=J.useCallback(()=>{if(!w.current)return;if(!document.fullscreenElement)w.current.requestFullscreen();else document.exitFullscreen()},[]),mG=J.useCallback((G,W)=>{if(I)$.current?.panBy(G,W)},[I]),jG=J.useCallback((G,W)=>{if(I)T.current?.panBy(G,W)},[I]),CG=J.useCallback(()=>j(),[j]),o=J.useCallback((G)=>K.find((W)=>W.id===G)?.version,[K]),pG=J.useMemo(()=>m?.media?.videoPreview?.url,[m?.media?.videoPreview?.url]),i=(G,W)=>{let A=y(W)?.comparePane;if(!A)return H("div",{className:"flex flex-1 items-center justify-center bg-gray-100 dark:bg-gray-950",children:H("p",{className:"text-muted-foreground",children:"Preview unavailable"})});let C=_===G;return H(A,{ref:G==="left"?T:$,file:W,shareId:X,isActive:C,annotations:C?U:[],onStateChange:G==="left"?BG:DG,onUserPan:G==="left"?mG:jG,onActivate:()=>L(G),muted:C?OG:!0,volume:k,onPlay:R,onTimeUpdate:z,onRequestTogglePlay:CG},W.id)},xG=!!E&&!!P,AG=ZG||MG;return O("div",{ref:w,className:"flex h-full flex-1 flex-col bg-background",children:[O("div",{className:"flex min-h-0 flex-1",children:[O("div",{className:"flex min-w-0 flex-1 flex-col border-r border-zinc-800",children:[E&&H(c,{side:"left",fileName:E.name,version:o(N),activeVersionId:N,versions:K,isActive:_==="left",onActivate:()=>L("left"),onSwitchVersion:(G)=>B("left",G),onExit:F}),H("div",{className:"relative flex min-h-0 flex-1",children:E?i("left",E):H("div",{className:"flex flex-1 items-center justify-center",children:H(S,{className:"h-6 w-6 animate-spin text-foreground"})})})]}),O("div",{className:"flex min-w-0 flex-1 flex-col",children:[P&&H(c,{side:"right",fileName:P.name,version:o(V),activeVersionId:V,versions:K,isActive:_==="right",onActivate:()=>L("right"),onSwitchVersion:(G)=>B("right",G),onExit:F}),H("div",{className:"relative flex min-h-0 flex-1",children:P?i("right",P):H("div",{className:"flex flex-1 items-center justify-center",children:H(S,{className:"h-6 w-6 animate-spin text-foreground"})})})]})]}),AG&&!xG&&H("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-background/30",children:H(S,{className:"h-8 w-8 animate-spin text-foreground"})}),H(GG,{activeState:h,activeAsset:m??null,previewUrl:pG,isFullScreen:qG,onTogglePlay:j,onToggleLoop:EG,onSeek:FG,onVolumeChange:PG,onToggleMute:RG,onChangePlaybackRate:wG,onChangeResolution:TG,onZoomIn:kG,onZoomOut:IG,onFit:bG,onDownload:yG,onToggleFullScreen:fG,allowDownload:b})]})}
|
|
2
|
+
export{cG as b,zH as c};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{Bg as e,Cg as n,Jh as c,Kh as s,Nh as d,qj as o,xj as i}from"./chunk-ersxsrz8.js";function S({...t}){return e(o.Root,{"data-slot":"select",...t})}function P({...t}){return e(o.Value,{"data-slot":"select-value",...t})}function b({className:t,size:a="default",children:r,...l}){return n(o.Trigger,{"data-slot":"select-trigger","data-size":a,className:i("flex w-fit items-center justify-between gap-2 rounded-md border border-input bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[placeholder]:text-muted-foreground data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground",t),...l,children:[r,e(o.Icon,{asChild:!0,children:e(s,{className:"size-4 opacity-50"})})]})}function h({className:t,children:a,position:r="item-aligned",align:l="center",...p}){return e(o.Portal,{children:n(o.Content,{"data-slot":"select-content",className:i("relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border bg-popover text-popover-foreground shadow-md data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95",r==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",t),position:r,align:l,...p,children:[e(m,{}),e(o.Viewport,{className:i("p-1",r==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:a}),e(u,{})]})})}function y({className:t,children:a,...r}){return n(o.Item,{"data-slot":"select-item",className:i("relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",t),...r,children:[e("span",{"data-slot":"select-item-indicator",className:"absolute right-2 flex size-3.5 items-center justify-center",children:e(o.ItemIndicator,{children:e(c,{className:"size-4"})})}),e(o.ItemText,{children:a})]})}function m({className:t,...a}){return e(o.ScrollUpButton,{"data-slot":"select-scroll-up-button",className:i("flex cursor-default items-center justify-center py-1",t),...a,children:e(d,{className:"size-4"})})}function u({className:t,...a}){return e(o.ScrollDownButton,{"data-slot":"select-scroll-down-button",className:i("flex cursor-default items-center justify-center py-1",t),...a,children:e(s,{className:"size-4"})})}
|
|
2
|
+
export{S as Qa,P as Ra,b as Sa,h as Ta,y as Ua};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
2
|
-
export{d as
|
|
1
|
+
import{Bg as o,xj as r}from"./chunk-ersxsrz8.js";function d({className:t,...a}){return o("div",{"data-slot":"card",className:r("flex flex-col gap-6 rounded-xl border bg-card py-6 text-card-foreground shadow-sm",t),...a})}function n({className:t,...a}){return o("div",{"data-slot":"card-header",className:r("@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-2 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",t),...a})}function c({className:t,...a}){return o("div",{"data-slot":"card-title",className:r("leading-none font-semibold",t),...a})}function s({className:t,...a}){return o("div",{"data-slot":"card-description",className:r("text-sm text-muted-foreground",t),...a})}function i({className:t,...a}){return o("div",{"data-slot":"card-content",className:r("px-6",t),...a})}function l({className:t,...a}){return o("div",{"data-slot":"card-footer",className:r("flex items-center px-6 [.border-t]:pt-6",t),...a})}
|
|
2
|
+
export{d as Yf,n as Zf,c as _f,s as $f,i as ag,l as bg};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{Bg as e,Jh as r,jj as i,xj as t}from"./chunk-ersxsrz8.js";function s({className:o,...a}){return e(i.Root,{"data-slot":"checkbox",className:t("peer size-4 shrink-0 rounded-[4px] border border-input shadow-xs transition-shadow outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[state=checked]:border-primary data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:bg-input/30 dark:aria-invalid:ring-destructive/40 dark:data-[state=checked]:bg-primary",o),...a,children:e(i.Indicator,{"data-slot":"checkbox-indicator",className:"grid place-content-center text-current transition-none",children:e(r,{className:"size-3.5"})})})}
|
|
2
|
+
export{s as Q};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Yj as K}from"./chunk-bhqrqt97.js";import{_j as C}from"./chunk-kgr3ytpb.js";import{xk as T,yk as j}from"./chunk-75x3w5hx.js";import{Fk as _,Hk as $,Ik as V}from"./chunk-6ab9eftx.js";import"./chunk-8tnq43k9.js";class W extends Error{code;diagnosticDetails;constructor(F,q,z){super(F);this.name="PiMessagesResponseError",this.code=q,this.diagnosticDetails=z}}function A(F){try{let q=JSON.parse(F),z=q?.error;return q&&typeof z==="object"&&z!==null&&!Array.isArray(z)?q:void 0}catch{return}}function D(F){return F.length>8192?`${F.slice(0,8192)}\u2026`:F}function h(F,q,z){let k=typeof z?.error?.message==="string"?z.error.message:void 0,G=typeof z?.error?.code==="string"?z.error.code:void 0,H=k??q,I=G?` (${G})`:"";return`${F.status} ${F.statusText}: ${H}${I}`}function J(F,q,z,k){let G=A(k),H=typeof G?.error?.code==="string"?G.error.code:void 0;return new W(h(z,k,G),H,{version:1,provider:F.provider,model:F.id,url:q.toString(),status:z.status,statusText:z.statusText,error:G?.error,body:G?void 0:D(k),timestampMs:Date.now()})}function U(){return{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}}}function Y(F,q){if(!q)return;V(F,{type:"pi_messages_rewrite",timestamp:Date.now(),details:{...q}})}function w(F){let q={role:"assistant",content:[],api:F.api,provider:F.provider,model:F.id,usage:U(),stopReason:"stop",timestamp:Date.now()},z=new Map;return(k)=>{switch(k.type){case"done":return Object.assign(q,{stopReason:k.reason,usage:k.usage,responseId:k.responseId}),Y(q,k.rewrite),{type:"done",reason:k.reason,message:q};case"error":return Object.assign(q,{stopReason:k.reason,usage:k.usage,errorMessage:k.errorMessage,responseId:k.responseId}),Y(q,k.rewrite),{type:"error",reason:k.reason,error:q};case"start":break;case"text_start":q.content[k.contentIndex]={type:"text",text:""};break;case"text_delta":q.content[k.contentIndex].text+=k.delta;break;case"text_end":Object.assign(q.content[k.contentIndex],{text:k.content,textSignature:k.contentSignature});break;case"thinking_start":q.content[k.contentIndex]={type:"thinking",thinking:""};break;case"thinking_delta":q.content[k.contentIndex].thinking+=k.delta;break;case"thinking_end":Object.assign(q.content[k.contentIndex],{thinking:k.content,thinkingSignature:k.contentSignature,redacted:k.redacted});break;case"toolcall_start":q.content[k.contentIndex]={type:"toolCall",id:k.id,name:k.toolName,arguments:{}},z.set(k.contentIndex,"");break;case"toolcall_delta":{let G=`${z.get(k.contentIndex)??""}${k.delta}`;z.set(k.contentIndex,G),q.content[k.contentIndex].arguments=C(G);break}case"toolcall_end":return Object.assign(q.content[k.contentIndex],k.toolCall),z.delete(k.contentIndex),{type:"toolcall_end",contentIndex:k.contentIndex,toolCall:q.content[k.contentIndex],partial:q}}return{...k,partial:q}}}async function*S(F){let q=new TextDecoder,z=F.getReader(),k="";try{while(!0){let{done:G,value:H}=await z.read();k+=G?q.decode():q.decode(H,{stream:!0}),k=k.replace(/\r\n/g,`
|
|
3
|
+
`);let I=k.indexOf(`
|
|
4
|
+
|
|
5
|
+
`);while(I!==-1){let N=Z(k.slice(0,I));if(N)yield N;k=k.slice(I+2),I=k.indexOf(`
|
|
6
|
+
|
|
7
|
+
`)}if(G)break}if(k.trim()){let G=Z(k);if(G)yield G}}finally{z.releaseLock()}}function Z(F){let q=F.split(`
|
|
8
|
+
`).find((z)=>z.startsWith("data:"))?.slice(5).trim();return q&&q!=="[DONE]"?JSON.parse(q):void 0}function P(F,q,z){let k=z?"aborted":"error",G={role:"assistant",content:[],api:F.api,provider:F.provider,model:F.id,usage:U(),stopReason:k,errorMessage:q instanceof Error?q.message:String(q),timestamp:Date.now()};if(!z&&q instanceof W)V(G,$("pi_messages_response_failure",q,q.diagnosticDetails));return{type:"error",reason:k,error:G}}function R(F,q){if(F)return F;return K("PI_CACHE_RETENTION",q)==="long"?"long":void 0}var x=(F,q,z)=>{let k=new _,G=w(F);return(async()=>{try{let H=z?.apiKey;if(!H)throw Error(`No API key provided for provider "${F.provider}"`);let I=new URL(`${F.baseUrl.replace(/\/+$/u,"")}/messages`);if(z?.debug)I.searchParams.set("debug","1");let N={model:F.id,context:q,options:{temperature:z?.temperature,maxTokens:z?.maxTokens,reasoning:z?.reasoning,cacheRetention:R(z?.cacheRetention,z?.env),sessionId:z?.sessionId,toolChoice:z?.toolChoice}},X=await z?.onPayload?.(N,F);if(X!==void 0)N=X;let L=await fetch(I,{method:"POST",headers:{authorization:`Bearer ${H}`,accept:"text/event-stream","content-type":"application/json",...j(z?.headers)},body:JSON.stringify(N),signal:z?.signal});if(await z?.onResponse?.({status:L.status,headers:T(L.headers)},F),!L.ok){let O=await L.text();throw J(F,I,L,O)}if(!L.body)throw Error(`${F.provider} response has no body`);for await(let O of S(L.body)){let Q=G(O);if(k.push(Q),Q.type==="done"||Q.type==="error")return}throw Error(`${F.provider} stream ended without a terminal event`)}catch(H){k.push(P(F,H,z?.signal?.aborted??!1))}})(),k},u=(F,q,z)=>{let k=z;return x(F,q,{...z,reasoning:z?.reasoning,toolChoice:k?.toolChoice,debug:k?.debug})};export{u as streamSimple,x as stream,W as PiMessagesResponseError};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{Ad as k,Dd as E,Fd as J,Hd as I,Id as V,Kd as X,Nd as _,od as JG,pd as r,qd as u,sd as H,xd as W,yd as l,zd as N}from"./chunk-03pw611p.js";function q(G,Q){let Y={};if(!Object.keys(Q).length)return Y=G,Y;for(let[K,B]of Object.entries(G)){let O=Q[K];if(O===null)continue;Y[O??K]=B}return Y}function UG(G){let Q={};for(let[Y,K]of Object.entries(G))if(typeof K<"u")Q[Y]=K;return Q}class C extends Error{rawValue;rawMessage;static[Symbol.hasInstance](G){if(!(G instanceof Error))return!1;if(!("rawValue"in G))return!1;if(!("rawMessage"in G))return!1;if(!("pretty"in G))return!1;if(typeof G.pretty!=="function")return!1;return!0}constructor(G,Q,Y){super(`${G}: ${Q}`);this.name="SDKValidationError",this.cause=Q,this.rawValue=Y,this.rawMessage=G}pretty(){if(this.cause instanceof r)return`${this.rawMessage}
|
|
3
3
|
${yG(this.cause)}`;else return this.toString()}}function yG(G){return u(G)}function t(G){return{ok:!0,value:G}}function s(G){return{ok:!1,error:G}}async function vG(G){let Q=await G;if(!Q.ok)throw Q.error;return Q.value}function i(G,Q,Y){try{return t(Q(G))}catch(K){return s(new C(Y,K,G))}}var o=J({prompt_tokens:W().default(0),completion_tokens:W().default(0),total_tokens:W().default(0),prompt_audio_seconds:_(W()).optional()}).catchall(N()).transform((G)=>{return q(G,{prompt_tokens:"promptTokens",completion_tokens:"completionTokens",total_tokens:"totalTokens",prompt_audio_seconds:"promptAudioSeconds"})}),hG=J({promptTokens:W().default(0),completionTokens:W().default(0),totalTokens:W().default(0),promptAudioSeconds:_(W()).optional()}).catchall(N()).transform((G)=>{return{...q(G,{promptTokens:"prompt_tokens",completionTokens:"completion_tokens",totalTokens:"total_tokens",promptAudioSeconds:"prompt_audio_seconds"})}});function j(G){return z++,G}var z=0,a=0;function P(){a++;let G=z;return{end:(Q)=>{let Y=z-G;if(z=G+(Q??Y),--a===0)z=0;return Y}}}function M(G){let Q=Object.values(G);return I([...Q.map((Y)=>X(Y)),H().transform((Y)=>j(Y))])}function lG(G){let Q=Object.values(G).filter((Y)=>typeof Y==="number");return I([...Q.map((Y)=>X(Y)),W().transform((Y)=>j(Y))])}function f(G){return H()}function cG(G){return W()}var e=Symbol("UNKNOWN");function n(G){return typeof G==="object"&&G!==null&&e in G}function GG(G,Q,Y={}){let{unknownValue:K="UNKNOWN",outputPropertyName:B}=Y;return k().transform((O)=>{let w=Object.defineProperties({raw:O,[B??G]:K,isUnknown:!0},{[e]:{value:!0,enumerable:!1,configurable:!1}});if(!(typeof O==="object"&&O!==null))return w;let F=O[G];if(typeof F!=="string")return w;if(!(F in Q))return w;let $=Q[F];if(!$)return w;let T=P(),y=$.safeParse(O);if(!y.success)return T.end(0),w;if(T.end(),B)y.data[B]=F;return y.data})}var HG=/^\d{4}-\d{2}-\d{2}$/;class v{serialized;static today(){return new v(new Date)}constructor(G){if(typeof G==="string"&&!HG.test(G))throw RangeError("RFCDate: date strings must be in the format YYYY-MM-DD: "+G);let Q=new Date(G);if(isNaN(+Q))throw RangeError("RFCDate: invalid date provided: "+G);if(this.serialized=Q.toISOString().slice(0,10),!HG.test(this.serialized))throw TypeError(`RFCDate: failed to build valid date with given value: ${G} serialized to ${this.serialized}`)}toJSON(){return this.toString()}toString(){return this.serialized}}function Z(G){return k().transform((Q,Y)=>{let K=[],B=G.map(()=>[]),O=P();for(let[D,F]of G.entries()){let $=P(),T=F.safeParse(Q),y=$.end(),xG=0;if(T.success){K.push({data:T.data,inexactCount:y,zeroDefaultCount:0,fieldCount:-1});continue}B[D].push(...T.error.issues)}if(K.length===0)return O.end(0),Y.addIssue({input:Q,code:"invalid_union",errors:B}),JG;let w=K[0];for(let D of K){if(K.length>1)D.fieldCount=PG(D.data);w=zG(D,w)}return O.end(w.inexactCount),w.data})}function zG(G,Q){let Y=G.inexactCount===0,K=Q.inexactCount===0;if(Y!==K)return Y?G:Q;let B=G.fieldCount-G.zeroDefaultCount,O=Q.fieldCount-Q.zeroDefaultCount;if(B!==O)return B>O?G:Q;return G.inexactCount<Q.inexactCount?G:Q}function PG(G){let Q=0,Y=[G],K=0;while(K<Y.length){let B=Y[K++];if(B===void 0||n(B))continue;let O=typeof B;if(B===null||O==="number"||O==="string"||O==="boolean"||O==="bigint"||B instanceof Date||B instanceof v){Q++;continue}if(Array.isArray(B)){Y.push(...B);continue}if(O==="object")Y.push(...Object.values(B))}return Q}var QG=J({type:X("input_audio"),input_audio:H()}).transform((G)=>{return q(G,{input_audio:"inputAudio"})}),XG=J({type:X("input_audio"),inputAudio:H()}).transform((G)=>{return q(G,{inputAudio:"input_audio"})});var YG=J({type:X("document_url").default("document_url"),document_url:H(),document_name:_(H()).optional()}).transform((G)=>{return q(G,{document_url:"documentUrl",document_name:"documentName"})}),_G=J({type:X("document_url").default("document_url"),documentUrl:H(),documentName:_(H()).optional()}).transform((G)=>{return q(G,{documentUrl:"document_url",documentName:"document_name"})});var ZG=J({type:X("file").default("file"),file_id:H()}).transform((G)=>{return q(G,{file_id:"fileId"})}),WG=J({type:X("file").default("file"),fileId:H()}).transform((G)=>{return q(G,{fileId:"file_id"})});var qG={Low:"low",Auto:"auto",High:"high"},BG=M(qG),KG=f(qG);var b=J({url:H(),detail:_(BG).optional()}),p=J({url:H(),detail:_(KG).optional()});var BH=Z([b,H()]),KH=Z([p,H()]);var OG=J({type:X("image_url").default("image_url"),image_url:Z([b,H()])}).transform((G)=>{return q(G,{image_url:"imageUrl"})}),AG=J({type:X("image_url").default("image_url"),imageUrl:Z([p,H()])}).transform((G)=>{return q(G,{imageUrl:"image_url"})});var wH=Z([W(),H()]),NH=Z([W(),H()]);var L=J({type:X("reference").default("reference"),reference_ids:E(Z([W(),H()]))}).transform((G)=>{return q(G,{reference_ids:"referenceIds"})}),R=J({type:X("reference").default("reference"),referenceIds:E(Z([W(),H()]))}).transform((G)=>{return q(G,{referenceIds:"reference_ids"})});var x=J({type:X("text").default("text"),text:H()}),U=J({type:X("text").default("text"),text:H()});var EG={WebSearch:"web_search",WebSearchPremium:"web_search_premium",CodeInterpreter:"code_interpreter",ImageGeneration:"image_generation",DocumentLibrary:"document_library"},h=M(EG),g=f(EG);var yH=Z([h,H()]),zH=Z([g,H()]);var d=J({type:X("tool_reference").default("tool_reference"),tool:Z([h,H()]),title:H(),url:_(H()).optional(),favicon:_(H()).optional(),description:_(H()).optional()}),m=J({type:X("tool_reference").default("tool_reference"),tool:Z([g,H()]),title:H(),url:_(H()).optional(),favicon:_(H()).optional(),description:_(H()).optional()});var UH=Z([d,x,L]),$H=Z([m,U,R]);var wG=J({type:X("thinking").default("thinking"),thinking:E(Z([d,x,L])),signature:_(H()).optional(),closed:l().optional()}),NG=J({type:X("thinking").default("thinking"),thinking:E(Z([m,U,R])),signature:_(H()).optional(),closed:l().optional()});var c=GG("type",{image_url:OG.and(J({type:X("image_url")})),document_url:YG.and(J({type:X("document_url")})),text:x.and(J({type:X("text")})),reference:L.and(J({type:X("reference")})),file:ZG.and(J({type:X("file")})),thinking:wG.and(J({type:X("thinking")})),input_audio:QG}),gH=I([AG.and(J({type:X("image_url")})),_G.and(J({type:X("document_url")})),U.and(J({type:X("text")})),R.and(J({type:X("reference")})),WG.and(J({type:X("file")})),NG.and(J({type:X("thinking")})),XG]);var lH=Z([V(H(),N()),H()]),cH=Z([V(H(),N()),H()]);var VG=J({name:H(),arguments:Z([V(H(),N()),H()])}),DG=J({name:H(),arguments:Z([V(H(),N()),H()])});var FG=J({id:H().default("null"),type:H().optional(),function:VG,index:W().default(0)}),tH=J({id:H().default("null"),type:H().optional(),function:DG,index:W().default(0)});var nH=Z([H(),E(c)]);var TG=J({role:_(H()).optional(),content:_(Z([H(),E(c)])).optional(),tool_calls:_(E(FG)).optional(),tool_call_id:_(H()).optional(),index:_(W()).optional(),metadata:_(V(H(),N())).optional()}).transform((G)=>{return q(G,{tool_calls:"toolCalls",tool_call_id:"toolCallId"})});var IG={Stop:"stop",Length:"length",Error:"error",ToolCalls:"tool_calls"},LG=M(IG),MG=J({index:W(),delta:TG,finish_reason:_(LG)}).transform((G)=>{return q(G,{finish_reason:"finishReason"})});var RG=J({id:H(),object:H().optional(),created:W().optional(),model:H(),usage:o.optional(),choices:E(MG)});function ZJ(G){return i(G,(Q)=>RG.parse(JSON.parse(Q)),"Failed to parse 'CompletionChunk' from JSON")}
|
|
4
|
-
export{yG as
|
|
4
|
+
export{yG as nb,t as ob,s as pb,vG as qb,i as rb,q as sb,UG as tb,M as ub,lG as vb,f as wb,cG as xb,GG as yb,Z as zb,YG as Ab,_G as Bb,WG as Cb,OG as Db,AG as Eb,x as Fb,U as Gb,h as Hb,g as Ib,d as Jb,m as Kb,wG as Lb,NG as Mb,c as Nb,gH as Ob,FG as Pb,tH as Qb,TG as Rb,o as Sb,hG as Tb,RG as Ub,ZJ as Vb};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{b as WG,c as VG}from"./chunk-cwh21vfb.js";import{i as qG,l as BG}from"./chunk-3t7v2de9.js";import{o as zG}from"./chunk-yn7mxpmb.js";import{Ia as HG}from"./chunk-bpb0szs5.js";import{Le as _G}from"./chunk-msjv1ykh.js";import{sf as ZG}from"./chunk-gg1wfpm8.js";import{Yf as v,Zf as g,_f as F,ag as u}from"./chunk-d2xrh0vv.js";import{Ag as JG,Bg as U,Cg as z,Fj as YG,Gg as N,Gj as $G,Jg as w,Og as KG,dh as B,hh as OG,oh as P,pi as UG,zg as oG,zj as XG}from"./chunk-ersxsrz8.js";import{Jk as nG}from"./chunk-8tnq43k9.js";var X=nG(oG(),1);function $J({shareId:K,initialFolderId:QG,initialFileId:f,startTime:TG,versionId:V,compare:MG,compareLeftId:b,compareRightId:A,compareActiveSide:p="left"}){let H=KG(),W=!!MG&&!!b&&!!A,[Z,m]=X.useState(()=>{return localStorage.getItem(`share_pwd_${K}`)||""}),[D,NG]=X.useState(""),{data:O,error:Q,isLoading:yG}=N({queryKey:["share-info",K,Z],queryFn:async()=>{let G=await B.api.shares[":shareId"].info.$get({param:{shareId:K}},{headers:{"x-share-password":Z}});if(G.status===401)throw Error("Unauthorized");if(G.status===403){let J=await G.json();throw Error(J.error||"Forbidden")}if(!G.ok)throw Error("Failed to fetch share info");return await G.json()},retry:!1}),Y=QG||O?.rootFolderId,_=f||null,h=V||_,[c,l]=X.useState([]),{data:R}=N({queryKey:["public-share-folder",K,Y,Z],queryFn:async()=>{let G=await B.api.shares[":shareId"].files[":fileId"].$get({param:{shareId:K,fileId:Y}},{headers:{"x-share-password":Z}});if(G.status===401)throw Error("Unauthorized");return await G.json()},enabled:!!O&&!!Y});X.useEffect(()=>{if(R?.ancestorFolders&&O){let G=R.ancestorFolders.findIndex((J)=>J.id===O.rootFolderId);if(G!==-1)l(R.ancestorFolders.slice(0,G));else if(Y===O.rootFolderId)l([])}},[R,O,Y]);let[y,E]=X.useState(new Set),[EG,LG]=X.useState(360),[j,kG]=X.useState(()=>!f),L=X.useRef(null),[I,C]=X.useState([]),[bG,n]=X.useState(0),[AG,o]=X.useState(null),[d,RG]=X.useState(null),[PG,DG]=X.useState(void 0),{data:i,fetchNextPage:jG,hasNextPage:CG,isFetchingNextPage:SG,error:t}=w({queryKey:["public-share-children",K,Y,"folder",Z],queryFn:async({pageParam:G})=>{let J=await B.api.shares[":shareId"].folders[":folderId"].children.$get({param:{shareId:K,folderId:Y},query:{assetType:"folder",after:G}},{headers:{"x-share-password":Z}});if(J.status===401)throw Error("Unauthorized");if(J.status===403)throw Error("Expired");return await J.json()},enabled:!!O&&!!Y,initialPageParam:"",getNextPageParam:(G)=>G.pageInfo?.cursor||void 0,retry:!1}),{data:a,fetchNextPage:xG,hasNextPage:wG,isFetchingNextPage:vG}=w({queryKey:["public-share-children",K,Y,"file",Z],queryFn:async({pageParam:G})=>{let J=await B.api.shares[":shareId"].folders[":folderId"].children.$get({param:{shareId:K,folderId:Y},query:{assetType:"file",after:G}},{headers:{"x-share-password":Z}});if(J.status===401)throw Error("Unauthorized");if(J.status===403)throw Error("Expired");return await J.json()},enabled:!!O&&!!Y,initialPageParam:"",getNextPageParam:(G)=>G.pageInfo?.cursor||void 0,retry:!1}),{data:gG}=N({queryKey:["public-share-fields",K,Z],queryFn:async()=>{let G=await B.api.shares[":shareId"].fields.$get({param:{shareId:K}},{headers:{"x-share-password":Z}});if(G.status===401)throw Error("Unauthorized");return await G.json()},enabled:!!O}),{data:q,isLoading:FG}=N({queryKey:["public-share-file",K,_,Z],queryFn:async()=>{let G=await B.api.shares[":shareId"].files[":fileId"].$get({param:{shareId:K,fileId:_}},{headers:{"x-share-password":Z}});if(G.status===401)throw Error("Unauthorized");return await G.json()},enabled:!!_&&!!O}),{data:uG,isLoading:fG}=N({queryKey:["public-share-file",K,V,Z],queryFn:async()=>{let G=await B.api.shares[":shareId"].files[":fileId"].$get({param:{shareId:K,fileId:V}},{headers:{"x-share-password":Z}});if(G.status===401)throw Error("Unauthorized");return await G.json()},enabled:!!V&&!!O}),$=V?uG:q,pG=FG||!!V&&fG;X.useEffect(()=>{if(t?.message==="Unauthorized")m(""),localStorage.removeItem(`share_pwd_${K}`)},[t,K]);let k=X.useMemo(()=>i?.pages.flatMap((G)=>G.data??[])??[],[i]),S=X.useMemo(()=>a?.pages.flatMap((G)=>G.data??[])??[],[a]),s=X.useMemo(()=>{if($)return $;if(y.size!==1)return null;let G=Array.from(y)[0];return[...k,...S].find((J)=>J.id===G)||null},[y,k,S,$]),mG=(G)=>{G.preventDefault(),m(D),localStorage.setItem(`share_pwd_${K}`,D)},hG=(G)=>{if(G.type==="folder"||G.targetType==="folder")H({to:"/share/$shareId/folders/$folderId",params:{shareId:K,folderId:G.id}});else H({to:"/share/$shareId/files/$fileId",params:{shareId:K,fileId:G.versionStack?G.versionStack.id:G.id}});E(new Set)},cG=(G)=>{if(!O)return;let J=G==="root"?O.rootFolderId:G;if(J===O.rootFolderId)H({to:"/share/$shareId",params:{shareId:K}});else H({to:"/share/$shareId/folders/$folderId",params:{shareId:K,folderId:J}});E(new Set)},lG=(G)=>{o(G.id||null);let J=G.annotations;if(J&&J.length>0)C(J);else C([]);if(W){if(G.second!==null&&G.second!==void 0)DG({second:G.second,nonce:Date.now()});return}if(G.second!==null&&G.second!==void 0)L.current?.seekTo(G.second),L.current?.pause();else if(J&&J.length>0)L.current?.pause()},r=()=>{C([]),o(null)},x=(G)=>{if(!_)return;H({to:"/share/$shareId/files/$fileId",params:{shareId:K,fileId:_},search:(J)=>({...J,...G})})},IG=()=>{x({compare:void 0,cmpLeft:void 0,cmpRight:void 0,cmpActive:void 0,version:p==="left"?b:A})},{setProjectState:e,clearProjectState:GG}=ZG();X.useEffect(()=>{if(O&&Y){let G=Y===O.rootFolderId?O.name:k.find((J)=>J.id===Y)?.name||O.name;e({teamId:"",projectId:O.projectId,projectName:O.name,ancestorFolders:c,currentAsset:{name:$?.name||G,type:_?"file":"folder",version:q?.versionStack?q.versionStack.versions.find((J)=>J.id===h)?.version??q.versionStack.versions.length:void 0,proxyType:$?.proxyType||null},isRootFolder:Y===O.rootFolderId&&!_,isPublic:!0,shareId:K,fileId:_||void 0,allowDownload:O.allowDownload,downloadInfo:$?{originalKey:$.media?.original?.key,videoTranscodes:$.media?.videoTranscodes?.map((J)=>({key:J.key,width:J.width,height:J.height}))}:void 0,onFolderClick:cG,isRightSidebarCollapsed:j,onRightSidebarToggle:()=>kG((J)=>!J),versions:q?.versionStack?.versions,compareMode:W,canCompareVersions:(q?.versionStack?.versions?.length??0)>=2,onCompareVersions:()=>{let J=qG(q?.versionStack?.versions);if(!J||!_)return;H({to:"/share/$shareId/files/$fileId",params:{shareId:K,fileId:_},search:(M)=>({...M,compare:!0,cmpLeft:J.left.id,cmpRight:J.right.id,cmpActive:"left"})})}})}return()=>GG()},[O,Y,k,$,q,h,_,c,e,GG,j,W,H,K]);let T;if(yG&&!Q)T=U("div",{className:"flex flex-1 items-center justify-center bg-background",children:U(P,{className:"h-8 w-8 animate-spin text-foreground"})});else if(Q)if(Q.message==="Unauthorized"){let G=Z!=="";T=U("div",{className:"flex flex-1 items-center justify-center p-4",children:z(v,{className:"w-full max-w-md",children:[z(g,{className:"text-center",children:[U("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-primary/10",children:U(UG,{className:"h-6 w-6 text-primary"})}),U(F,{children:YG.password_protected()})]}),U(u,{children:z("form",{onSubmit:mG,className:"space-y-4",children:[z("div",{className:"space-y-2",children:[U($G,{type:"password",placeholder:"Enter password",value:D,onChange:(J)=>NG(J.target.value),autoFocus:!0}),G&&U("p",{className:"text-sm font-medium text-destructive",children:"Incorrect password. Please try again."})]}),U(XG,{type:"submit",className:"w-full",children:"Access Share"})]})})]})})}else{let G=Q.message.includes("expired"),J=Q.message.includes("disabled");T=U("div",{className:"flex flex-1 items-center justify-center p-4",children:z(v,{className:"w-full max-w-md",children:[z(g,{className:"text-center",children:[U("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-destructive/10",children:U(OG,{className:"h-6 w-6 text-destructive"})}),U(F,{children:G?"Share Expired":J?"Share Disabled":"Error"})]}),U(u,{className:"text-center text-muted-foreground",children:Q.message})]})})}else if(!O)T=U("div",{className:"flex flex-1 items-center justify-center bg-background",children:U(P,{className:"h-8 w-8 animate-spin text-foreground"})});else T=z("div",{className:"flex flex-1 overflow-hidden relative",children:[_?z("div",{className:"flex-1 relative bg-muted/30",children:[pG&&!W&&U("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-background/50",children:U(P,{className:"h-8 w-8 animate-spin text-foreground"})}),W&&b&&A?U(VG,{isPublic:!0,shareId:K,versions:$?.versionStack?.versions??[],leftId:b,rightId:A,activeSide:p,annotations:I,seekRequest:PG,allowDownload:O.allowDownload,onActiveSideChange:(G)=>x({cmpActive:G}),onSwitchVersion:(G,J)=>x(G==="left"?{cmpLeft:J}:{cmpRight:J}),onExit:IG,onActiveAssetChange:RG,onPlay:r,onTimeUpdate:n}):$&&U(WG,{file:$,mediaControllerRef:L,onPlay:r,onTimeUpdate:n,annotations:I,startTime:TG,shareId:K,allowDownload:O.allowDownload})]}):Y&&U(zG,{teamId:"",projectId:O.projectId,assetId:Y,folders:k,files:S,selectedItem:null,selectedIds:y,onItemSelect:(G,J)=>{if(J.metaKey||J.ctrlKey){let M=new Set(y);if(M.has(G.id))M.delete(G.id);else M.add(G.id);E(M)}else E(new Set([G.id]))},onItemDoubleClick:hG,onSaveField:()=>{},displayStyle:O.viewMode??"card",onClearSelection:()=>E(new Set),fetchNextFoldersPage:jG,hasNextFoldersPage:CG,isFetchingNextFoldersPage:SG,fetchNextFilesPage:xG,hasNextFilesPage:wG,isFetchingNextFilesPage:vG,isShareView:!0,isPublic:!0,shareId:K,allowDownload:O.allowDownload}),!j&&z(JG,{children:[U(HG,{onResize:(G)=>LG((J)=>Math.max(240,Math.min(600,J-G)))}),U("div",{style:{width:EG},className:"flex-shrink-0 border-l",children:U(BG,{teamId:"",projectId:O.projectId,file:W?d:s,onSaveField:()=>{},members:[],readOnly:!0,publicFields:gG,onCommentSelect:lG,isPublic:!0,shareId:K,currentTime:bG,onTyping:()=>{L.current?.pause()},selectedCommentId:AG,hideAnnotationControl:(W?d:s)?.proxyType==="audio"})})]})]});return z("div",{className:"flex h-screen flex-col bg-background",children:[U(_G,{}),T]})}
|
|
2
|
+
export{$J as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as v}from"./chunk-dtjx1097.js";import"./chunk-cwh21vfb.js";import"./chunk-3t7v2de9.js";import"./chunk-xkh6b42h.js";import"./chunk-yn7mxpmb.js";import"./chunk-8btfb5g6.js";import"./chunk-d4sg0z3y.js";import"./chunk-k78m3rar.js";import"./chunk-m8tnsds1.js";import"./chunk-bpb0szs5.js";import"./chunk-6b0f3d07.js";import"./chunk-cwpmf8tx.js";import"./chunk-2pxev94x.js";import"./chunk-nabagpah.js";import"./chunk-05m8w09t.js";import"./chunk-ankkm2wz.js";import"./chunk-3vbx3x11.js";import"./chunk-msjv1ykh.js";import"./chunk-bagxeg82.js";import"./chunk-vzx1r87y.js";import"./chunk-gg1wfpm8.js";import"./chunk-2mr99scd.js";import"./chunk-z544s59c.js";import"./chunk-898hrxwq.js";import"./chunk-j5q3t199.js";import"./chunk-d2xrh0vv.js";import"./chunk-s584wxzj.js";import"./chunk-c1j58ekb.js";import"./chunk-v5zdafv4.js";import"./chunk-38hp9gfh.js";import{Bg as k,Tg as q}from"./chunk-ersxsrz8.js";import"./chunk-8tnq43k9.js";function B(){let{shareId:w,folderId:A}=C.useParams();return k(v,{shareId:w,initialFolderId:A})}var C=q("/share/$shareId/folders/$folderId")({component:B});export{C as Route};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{$j as C,ak as E,bk as I,ck as b,dk as h,ek as B,fk as x}from"./chunk-kfbztymc.js";import{kk as M}from"./chunk-4rexdetz.js";import{lk as G,mk as K}from"./chunk-9deae0n7.js";import{tk as T}from"./chunk-6gjn8trh.js";import{wk as S}from"./chunk-sfmhbk59.js";import{yk as O}from"./chunk-75x3w5hx.js";import{Dk as v,Ek as y}from"./chunk-7kdz1eng.js";import{Fk as P}from"./chunk-6ab9eftx.js";import"./chunk-8tnq43k9.js";var k=0,D=(q,N,w)=>{let J=new P;return(async()=>{let j={role:"assistant",content:[],api:"google-generative-ai",provider:q.provider,model:q.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"stop",timestamp:Date.now()};try{let X=w?.apiKey;if(!X)throw Error(`No API key for provider: ${q.provider}`);let V=a(q,X,w?.headers),Y=m(q,N,w),$=await w?.onPayload?.(Y,q);if($!==void 0)Y=$;let g=await V.models.generateContentStream(Y);J.push({type:"start",partial:j});let Q=null,H=j.content,W=()=>H.length-1;for await(let Z of g){j.responseId||=Z.responseId;let z=Z.candidates?.[0];if(z?.content?.parts)for(let U of z.content.parts){if(U.text!==void 0){let _=C(U);if(!Q||_&&Q.type!=="thinking"||!_&&Q.type!=="text"){if(Q)if(Q.type==="text")J.push({type:"text_end",contentIndex:H.length-1,content:Q.text,partial:j});else J.push({type:"thinking_end",contentIndex:W(),content:Q.thinking,partial:j});if(_)Q={type:"thinking",thinking:"",thinkingSignature:void 0},j.content.push(Q),J.push({type:"thinking_start",contentIndex:W(),partial:j});else Q={type:"text",text:""},j.content.push(Q),J.push({type:"text_start",contentIndex:W(),partial:j})}if(Q.type==="thinking")Q.thinking+=U.text,Q.thinkingSignature=E(Q.thinkingSignature,U.thoughtSignature),J.push({type:"thinking_delta",contentIndex:W(),delta:U.text,partial:j});else Q.text+=U.text,Q.textSignature=E(Q.textSignature,U.thoughtSignature),J.push({type:"text_delta",contentIndex:W(),delta:U.text,partial:j})}if(U.functionCall){if(Q){if(Q.type==="text")J.push({type:"text_end",contentIndex:W(),content:Q.text,partial:j});else J.push({type:"thinking_end",contentIndex:W(),content:Q.thinking,partial:j});Q=null}let _=U.functionCall.id,A={type:"toolCall",id:!_||j.content.some((R)=>R.type==="toolCall"&&R.id===_)?`${U.functionCall.name}_${Date.now()}_${++k}`:_,name:U.functionCall.name||"",arguments:U.functionCall.args??{},...U.thoughtSignature&&{thoughtSignature:U.thoughtSignature}};j.content.push(A),J.push({type:"toolcall_start",contentIndex:W(),partial:j}),J.push({type:"toolcall_delta",contentIndex:W(),delta:JSON.stringify(A.arguments),partial:j}),J.push({type:"toolcall_end",contentIndex:W(),toolCall:A,partial:j})}}if(z?.finishReason){if(j.stopReason=x(z.finishReason),j.content.some((U)=>U.type==="toolCall"))j.stopReason="toolUse"}if(Z.usageMetadata)j.usage={input:(Z.usageMetadata.promptTokenCount||0)-(Z.usageMetadata.cachedContentTokenCount||0),output:(Z.usageMetadata.candidatesTokenCount||0)+(Z.usageMetadata.thoughtsTokenCount||0),cacheRead:Z.usageMetadata.cachedContentTokenCount||0,cacheWrite:0,reasoning:Z.usageMetadata.thoughtsTokenCount||0,totalTokens:Z.usageMetadata.totalTokenCount||0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},v(q,j.usage)}if(Q)if(Q.type==="text")J.push({type:"text_end",contentIndex:W(),content:Q.text,partial:j});else J.push({type:"thinking_end",contentIndex:W(),content:Q.thinking,partial:j});if(w?.signal?.aborted)throw Error("Request was aborted");if(j.stopReason==="aborted"||j.stopReason==="error")throw Error("An unknown error occurred");J.push({type:"done",reason:j.stopReason,message:j}),J.end()}catch(X){for(let V of j.content)if("index"in V)delete V.index;j.stopReason=w?.signal?.aborted?"aborted":"error",j.errorMessage=K(G(X)),J.push({type:"error",reason:j.stopReason,error:j}),J.end()}})(),J},qj=(q,N,w)=>{let J=w?.apiKey;if(!J)throw Error(`No API key for provider: ${q.provider}`);let j=T(q,N,w,J);if(!w?.reasoning)return D(q,N,{...j,thinking:{enabled:!1}});let X=y(q,w.reasoning),V=X==="off"?"high":X,Y=q;if(F(Y)||f(Y)||L(Y))return D(q,N,{...j,thinking:{enabled:!0,level:d(V,Y)}});return D(q,N,{...j,thinking:{enabled:!0,budgetTokens:c(Y,V,w.thinkingBudgets)}})};function a(q,N,w){let J={};if(q.baseUrl)J.baseUrl=q.baseUrl,J.apiVersion="";let j=O({...q.headers,...w});if(j)J.headers=j;return new M({apiKey:N,httpOptions:Object.keys(J).length>0?J:void 0})}function m(q,N,w={}){let J=I(q,N),j={};if(w.temperature!==void 0)j.temperature=w.temperature;if(w.maxTokens!==void 0)j.maxOutputTokens=w.maxTokens;let X=N.tools?.length?B(N.tools,w.toolChoice,h(q.id)):void 0,V={...Object.keys(j).length>0&&j,...N.systemPrompt&&{systemInstruction:S(N.systemPrompt)},...N.tools&&N.tools.length>0&&{tools:b(N.tools)},...X!==void 0&&{toolConfig:{functionCallingConfig:{mode:X}}}};if(w.thinking?.enabled&&q.reasoning){let $={includeThoughts:!0};if(w.thinking.level!==void 0)$.thinkingLevel=w.thinking.level;else if(w.thinking.budgetTokens!==void 0)$.thinkingBudget=w.thinking.budgetTokens;V.thinkingConfig=$}else if(q.reasoning&&w.thinking&&!w.thinking.enabled)V.thinkingConfig=u(q);if(w.signal){if(w.signal.aborted)throw Error("Request aborted");V.abortSignal=w.signal}return{model:q.id,contents:J,config:V}}function L(q){return/gemma-?4/.test(q.id.toLowerCase())}function F(q){return/gemini-3(?:\.\d+)?-pro/.test(q.id.toLowerCase())}function f(q){let N=q.id.toLowerCase();return/gemini-3(?:\.\d+)?-flash/.test(N)||N==="gemini-flash-latest"||N==="gemini-flash-lite-latest"}function u(q){if(F(q))return{thinkingLevel:"LOW"};if(f(q))return{thinkingLevel:"MINIMAL"};if(L(q))return{thinkingLevel:"MINIMAL"};return{thinkingBudget:0}}function d(q,N){if(F(N))switch(q){case"minimal":case"low":return"LOW";case"medium":case"high":return"HIGH"}if(L(N))switch(q){case"minimal":case"low":return"MINIMAL";case"medium":case"high":return"HIGH"}switch(q){case"minimal":return"MINIMAL";case"low":return"LOW";case"medium":return"MEDIUM";case"high":return"HIGH"}}function c(q,N,w){if(w?.[N]!==void 0)return w[N];if(q.id.includes("2.5-pro"))return{minimal:128,low:2048,medium:8192,high:32768}[N];if(q.id.includes("2.5-flash-lite"))return{minimal:512,low:2048,medium:8192,high:24576}[N];if(q.id.includes("2.5-flash"))return{minimal:128,low:2048,medium:8192,high:24576}[N];return-1}export{qj as streamSimple,D as stream};
|