@shumai-one/shumai 0.2.1 → 0.2.2
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-qag3w2dd.js → chunk-0aj303as.js} +1 -1
- package/bin/{chunk-976v5s8y.js → chunk-0qkj838r.js} +1 -1
- package/bin/{chunk-mg6fce5x.js → chunk-0rxhc7ka.js} +1 -1
- package/bin/chunk-0xbf8bcg.js +2 -0
- package/bin/{chunk-t1mxqskx.js → chunk-15sefy5t.js} +1 -1
- package/bin/{chunk-jfjcxyhf.js → chunk-1wm57c6y.js} +3 -3
- package/bin/{chunk-7ktvhtp1.js → chunk-1xpec5r8.js} +1 -1
- package/bin/chunk-23d3968z.js +2 -0
- package/bin/{chunk-y4s3xr4n.js → chunk-262hkppb.js} +2 -2
- package/bin/{chunk-qj2kpkje.js → chunk-29tx9qe2.js} +1 -1
- package/bin/{chunk-a5s5ny4z.js → chunk-2aamsc5v.js} +1 -1
- package/bin/{chunk-gd5xwgp6.js → chunk-2aascrtb.js} +1 -1
- package/bin/chunk-2g12s6mc.js +2 -0
- package/bin/{chunk-pv76qkym.js → chunk-31baz5n0.js} +1 -1
- package/bin/{chunk-hmsb7ehr.js → chunk-46ar48f9.js} +1 -1
- package/bin/chunk-4e3jbp84.js +1 -0
- package/bin/chunk-4jk0y1w1.js +1 -0
- package/bin/{chunk-ga0drqj7.js → chunk-4qpa7b5t.js} +1 -1
- package/bin/{chunk-99db4j0k.js → chunk-54tr7y2x.js} +1 -1
- package/bin/{chunk-9n783gva.js → chunk-5d2q46mx.js} +1 -1
- package/bin/{chunk-qf7n519d.js → chunk-5m9be8an.js} +2 -2
- package/bin/{chunk-1w9dnk5p.js → chunk-5r8858hx.js} +1 -1
- package/bin/{chunk-ydagqpny.js → chunk-5t6c3038.js} +1 -1
- package/bin/chunk-6z65xd0w.js +3 -0
- package/bin/{chunk-qjjr3fff.js → chunk-77r8w95d.js} +1 -1
- package/bin/chunk-7e06b2zb.js +2 -0
- package/bin/{chunk-58aabg1f.js → chunk-7hsgmjpa.js} +2 -2
- package/bin/{chunk-7mnezagc.js → chunk-88fg1sw7.js} +1 -1
- package/bin/{chunk-m11g9hx7.js → chunk-8mkfgcvb.js} +2 -2
- package/bin/chunk-8tf6kgdj.js +2 -0
- package/bin/{chunk-b9hb5jzt.js → chunk-8wqfkm4c.js} +1 -1
- package/bin/{chunk-ag35pxnb.js → chunk-922nnh39.js} +1 -1
- package/bin/{chunk-ymyyap80.js → chunk-925q4paa.js} +1 -1
- package/bin/{chunk-wfex9jw0.js → chunk-92xxys10.js} +6 -6
- package/bin/{chunk-0a5k9avd.js → chunk-97jzve52.js} +1 -1
- package/bin/{chunk-dzm2f82x.js → chunk-9ab6k4rq.js} +1 -1
- package/bin/{chunk-mwh2n8yt.js → chunk-9avkn3x1.js} +1 -1
- package/bin/{chunk-pmx9760x.js → chunk-9h027f50.js} +1 -1
- package/bin/chunk-av71yjaa.js +1 -0
- package/bin/{chunk-mjncyjwf.js → chunk-b8js74jk.js} +1 -1
- package/bin/{chunk-861dz0bf.js → chunk-bd71dp4j.js} +1 -1
- package/bin/{chunk-v3j7acwn.js → chunk-bs0fjz3w.js} +2 -2
- package/bin/chunk-byqc8tzq.js +1 -0
- package/bin/chunk-ccw7mjgq.js +5 -0
- package/bin/{chunk-kj751zje.js → chunk-cxhmr356.js} +1 -1
- package/bin/{chunk-hcz4snm7.js → chunk-d3wmdjze.js} +1 -1
- package/bin/{chunk-82w2419d.js → chunk-de99643r.js} +2 -2
- package/bin/{chunk-dwf5e5g3.js → chunk-dghtwyq1.js} +1 -1
- package/bin/{chunk-5k03xpzq.js → chunk-dqgv5yy1.js} +1 -1
- package/bin/{chunk-q72ax3m8.js → chunk-e3s3rz2e.js} +1 -1
- package/bin/{chunk-79n633wf.js → chunk-e52nga6c.js} +1 -1
- package/bin/{chunk-8abs8d48.js → chunk-e7ndw3hg.js} +2 -2
- package/bin/chunk-f14sqw1d.js +1 -0
- package/bin/chunk-f7sbkfmk.js +2 -0
- package/bin/{chunk-2xnys7v4.js → chunk-fa2g2wge.js} +1 -1
- package/bin/{chunk-044xt1se.js → chunk-fbte2rmd.js} +1 -1
- package/bin/{chunk-k1r17nfa.js → chunk-fcvtgx1y.js} +1 -1
- package/bin/chunk-fd5a3pdd.js +1 -0
- package/bin/{chunk-hqptebzb.js → chunk-fepymbka.js} +1 -1
- package/bin/{chunk-cpr05qng.js → chunk-fz88kkk1.js} +1 -1
- package/bin/chunk-g6zzg6v2.js +1 -0
- package/bin/{chunk-6724dtsx.js → chunk-g8th86na.js} +1 -1
- package/bin/chunk-gswbc6y9.js +2 -0
- package/bin/{chunk-pvy0gccg.js → chunk-gtrc5ka2.js} +1 -1
- package/bin/chunk-h0ytx8zc.js +2 -0
- package/bin/{chunk-mv8c5fky.js → chunk-hkbybhww.js} +1 -1
- package/bin/{chunk-e3c6hyz8.js → chunk-hr97a5j5.js} +1 -1
- package/bin/{chunk-7h75r7ep.js → chunk-j8qtab70.js} +1 -1
- package/bin/{chunk-jyjnt0s9.js → chunk-jf3vn5c3.js} +2 -2
- package/bin/{chunk-azfgjqjx.js → chunk-kfhtk3eh.js} +1 -1
- package/bin/chunk-kr06nrbx.js +2 -0
- package/bin/{chunk-nceqrqey.js → chunk-m4zpf9gg.js} +1 -1
- package/bin/{chunk-1ae8csk6.js → chunk-mqjzmn0e.js} +1 -1
- package/bin/{chunk-sp75qe28.js → chunk-mzg1h07d.js} +1 -1
- package/bin/{chunk-cj5qwc9c.js → chunk-nrwna4ha.js} +1 -1
- package/bin/chunk-nyhqy6q2.js +62 -0
- package/bin/{chunk-4zq8vxcy.css → chunk-pmswtfe3.css} +1 -1
- package/bin/chunk-pq18zenh.js +2 -0
- package/bin/{chunk-p3emandj.js → chunk-q24epdh8.js} +2 -2
- package/bin/{chunk-2djd6pq1.js → chunk-qksb0v3c.js} +2 -2
- package/bin/chunk-qqk51620.js +2 -0
- package/bin/chunk-r0w920zb.js +1 -0
- package/bin/{chunk-2dz8nn9v.js → chunk-re0b7sj7.js} +1 -1
- package/bin/{chunk-x9q2vzn8.js → chunk-rtngbgpk.js} +1 -1
- package/bin/{chunk-zn9jbc6t.js → chunk-ry33f2qk.js} +1 -1
- package/bin/{chunk-k5bekrrp.js → chunk-s46zwr4p.js} +1 -1
- package/bin/chunk-s8t74q9m.js +1 -0
- package/bin/chunk-sd86v1e6.js +1 -0
- package/bin/{chunk-v98yavtp.js → chunk-srn8t0v7.js} +1 -1
- package/bin/chunk-szzff7gd.js +1 -0
- package/bin/{chunk-46c5xkmn.js → chunk-t3t6021k.js} +1 -1
- package/bin/{chunk-jbde7evp.js → chunk-thsbcbay.js} +1 -1
- package/bin/chunk-tspps87j.js +1 -0
- package/bin/{chunk-v05d1aeq.js → chunk-w7dn1m95.js} +1 -1
- package/bin/{chunk-w1d5vmtc.js → chunk-wc8sc9r9.js} +1 -1
- package/bin/chunk-wg98cacx.js +2 -0
- package/bin/chunk-wsyg4rwg.js +2 -0
- package/bin/{chunk-ga3mh3cd.js → chunk-xcwbg4w9.js} +1 -1
- package/bin/{chunk-9bpjfkjf.js → chunk-xyjw8w3r.js} +1 -1
- package/bin/chunk-y2qp11v9.js +1 -0
- package/bin/{chunk-ngd23mtc.js → chunk-ybhgmvxa.js} +1 -1
- package/bin/{chunk-phw4ne8b.js → chunk-ygz6pawn.js} +1 -1
- package/bin/{chunk-hy50c4pw.js → chunk-ymeycphq.js} +2 -2
- package/bin/{chunk-c1v946wb.js → chunk-zemrvz79.js} +2 -2
- package/bin/{chunk-29pkpmvy.js → chunk-zzx99j8t.js} +1 -1
- package/bin/shumai-app.html +1 -1
- package/bin/shumai-app.js +248 -224
- package/package.json +7 -7
- package/prisma/migrations/20260723025234_add_ai_usage_table/migration.sql +28 -0
- package/prisma/migrations/20260723032755_add_ai_usage_unique_constraint/migration.sql +8 -0
- package/prisma/schema.prisma +25 -0
- package/bin/chunk-211y81mp.js +0 -1
- package/bin/chunk-25d1g086.js +0 -2
- package/bin/chunk-4fnak2zn.js +0 -2
- package/bin/chunk-50ebjdkv.js +0 -2
- package/bin/chunk-5j7axztv.js +0 -2
- package/bin/chunk-6h4ay2p8.js +0 -2
- package/bin/chunk-6w5cn6p3.js +0 -3
- package/bin/chunk-75jka5v9.js +0 -5
- package/bin/chunk-9evm8x70.js +0 -1
- package/bin/chunk-bepnbw1g.js +0 -2
- package/bin/chunk-bg24g9kk.js +0 -1
- package/bin/chunk-dqtq9t8e.js +0 -1
- package/bin/chunk-fgnxtqtk.js +0 -1
- package/bin/chunk-fxvb6g2r.js +0 -1
- package/bin/chunk-kjkmh26f.js +0 -1
- package/bin/chunk-m3dwydr3.js +0 -2
- package/bin/chunk-mk1jewvw.js +0 -2
- package/bin/chunk-q9sgjs4d.js +0 -1
- package/bin/chunk-s2725w64.js +0 -1
- package/bin/chunk-saq5797j.js +0 -1
- package/bin/chunk-sy8rqacm.js +0 -2
- package/bin/chunk-t84t3v6q.js +0 -1
- package/bin/chunk-ttsqdsxr.js +0 -2
- package/bin/chunk-vreq89j6.js +0 -1
- package/bin/chunk-wbhsmhgp.js +0 -2
- package/bin/chunk-wf4d1anc.js +0 -62
- package/bin/chunk-xv4mfppt.js +0 -2
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
function q(k){let b=3735928559,d=1103547991;for(let f=0;f<k.length;f++){let l=k.charCodeAt(f);b=Math.imul(b^l,2654435761),d=Math.imul(d^l,1597334677)}return b=Math.imul(b^b>>>16,2246822507)^Math.imul(d^d>>>13,3266489909),d=Math.imul(d^d>>>16,2246822507)^Math.imul(b^b>>>13,3266489909),(d>>>0).toString(36)+(b>>>0).toString(36)}
|
|
3
|
-
export{q as
|
|
3
|
+
export{q as vk};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{zf as A}from"./chunk-
|
|
2
|
-
export{B as
|
|
1
|
+
import{zf as A}from"./chunk-ry33f2qk.js";import{Fh as w,Sh as z,oh as v}from"./chunk-nyhqy6q2.js";var B=(b)=>({queryKey:["projects",b],queryFn:async()=>{let h=await z.api.projects[":projectId"].$get({param:{projectId:b}});if(!h.ok)throw Error("Failed to fetch project");return await h.json()}}),H=w("/projects/$projectId/folders/$folderId")({loader:({context:{queryClient:b},params:{projectId:h}})=>b.ensureQueryData(B(h)),pendingComponent:()=>v(A,{})});
|
|
2
|
+
export{B as cf,H as df};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{_j as o,gk as t,oh as r,ph as i}from"./chunk-nyhqy6q2.js";function m({className:e,children:l,...a}){return i(o.Root,{"data-slot":"scroll-area",className:t("relative",e),...a,children:[r(o.Viewport,{"data-slot":"scroll-area-viewport",className:"size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1",children:l}),r(c,{}),r(o.Corner,{})]})}function c({className:e,orientation:l="vertical",...a}){return r(o.ScrollAreaScrollbar,{"data-slot":"scroll-area-scrollbar",orientation:l,className:t("flex touch-none p-px transition-colors select-none",l==="vertical"&&"h-full w-2.5 border-l border-l-transparent",l==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent",e),...a,children:r(o.ScrollAreaThumb,{"data-slot":"scroll-area-thumb",className:"relative flex-1 rounded-full bg-border"})})}
|
|
2
2
|
export{m as Wa,c as Xa};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{$a as o,_a as s,ab as r,bb as m,cb as e,db as qq,eb as Eq,fb as Jq}from"./chunk-0xbf8bcg.js";import{Qg as Q,Rg as H,Tg as z,Ug as y,Wg as F,Xg as X,dh as d,eh as b,fh as a,gh as t,ih as n}from"./chunk-gswbc6y9.js";import{Cj as i,Gi as l,Qh as P,ai as $,hk as c,ik as T,jk as w,mh as yq,mk as J,nh as j,oh as E,ph as K,wi as f}from"./chunk-nyhqy6q2.js";import{Vk as zq}from"./chunk-0qkj838r.js";var V=zq(yq(),1);function Cq({open:Kq,onOpenChange:Nq,title:Pq,members:A,isOwner:B,onInvite:S,onUpdateRole:D,onRemoveMember:R,currentUserId:Qq,availableMembersToAdd:k,onAddMember:I,type:Vq="team"}){let[G,g]=V.useState("editor"),[Z,M]=V.useState(null),[v,u]=V.useState(!1),[L,_]=V.useState(null),[Y,h]=V.useState(null),[Wq,p]=V.useState({}),[U,O]=V.useState(null),C=(q)=>{if(!q)return"";switch(q.toLowerCase()){case"owner":return J.owner();case"editor":return J.editor();case"reviewer":return J.reviewer();default:return q}},Xq=(q,N)=>{p((W)=>({...W,[q]:N}))},Yq=async(q,N)=>{if(!D)return;_(q);try{await D(q,N),P.success(J.member_role_updated())}catch(W){console.error(W),P.error(J.failed_to_update_member_role())}finally{_(null)}},Zq=async()=>{if(!R||!Y?.id)return;_(Y.id);try{await R(Y.id),P.success(J.member_removed()),h(null)}catch(q){console.error(q),P.error(J.failed_to_remove_member())}finally{_(null)}},_q=async()=>{if(!S)return;u(!0);try{let q=await S(G),N=`${window.location.origin}/signup?inviteCode=${q}`;M(N)}catch(q){console.error(q),P.error(J.failed_to_generate_invite_link())}finally{u(!1)}},$q=()=>{if(Z)navigator.clipboard.writeText(Z),P.success(J.invite_link_copied())},x=(q)=>{if(!q)return"??";return q.split(" ").map((N)=>N[0]).slice(0,2).join("").toUpperCase()},fq=(q)=>{if(!q)M(null),g("editor"),p({}),O(null);Nq(q)},Hq=Array.isArray(A)?A:[];return E(b,{open:Kq,onOpenChange:fq,children:K(a,{className:"sm:max-w-md",onOpenAutoFocus:(q)=>q.preventDefault(),children:[E(t,{children:E(n,{children:Pq})}),K("div",{className:"space-y-4",children:[E("div",{className:"max-h-[300px] overflow-y-auto space-y-2",children:Hq.map((q)=>K("div",{className:"flex items-center justify-between p-2 rounded-lg hover:bg-muted/50",children:[K("div",{className:"flex items-center gap-3",children:[K(c,{children:[q.image&&E(T,{src:q.image,alt:q.name,className:"object-cover"}),E(w,{children:x(q.name)})]}),K("div",{className:"flex flex-col",children:[E("span",{className:"text-sm font-medium",children:q.name}),K("div",{className:"flex items-center gap-2",children:[E("span",{className:"text-xs text-muted-foreground capitalize",children:C(q.role)}),q.scope&&K(j,{children:[E("span",{className:"text-[10px] text-muted-foreground/70",children:"•"}),E("span",{className:"text-xs text-muted-foreground capitalize",children:q.scope==="team"?J.team_member():J.project_member()})]})]})]})]}),B&&q.role!=="owner"&&q.id!==Qq&&K("div",{className:"flex items-center gap-2",children:[K(H,{children:[E(z,{asChild:!0,children:K(Q,{variant:"outline",size:"sm",className:"h-8 px-2 text-xs capitalize w-26",disabled:L===q.id,children:[C(q.role),E(f,{className:"ml-1 h-3 w-3 opacity-50"})]})}),E(y,{children:K(F,{value:q.role,onValueChange:(N)=>Yq(q.id,N),children:[E(X,{value:"editor",className:"text-xs",children:J.editor()}),E(X,{value:"reviewer",className:"text-xs",children:J.reviewer()})]})})]}),E(Q,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive hover:text-destructive hover:bg-destructive/10",onClick:()=>h(q),disabled:L===q.id,children:L===q.id?E($,{className:"h-3 w-3 animate-spin"}):E(i,{className:"h-3 w-3"})})]})]},q.id))}),E(s,{open:!!Y,onOpenChange:(q)=>!q&&h(null),children:K(o,{children:[K(r,{children:[E(e,{children:J.remove_member()}),E(qq,{children:J.remove_member_confirmation({name:Y?.name||"",type:Vq==="project"?J.project():J.team()})})]}),K(m,{children:[E(Jq,{children:J.cancel()}),E(Eq,{onClick:Zq,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:J.remove()})]})]})})," ",B&&I&&k&&k.length>0&&K("div",{className:"border-t pt-4",children:[E("h4",{className:"text-sm font-medium mb-3",children:J.add_team_member_to_project()}),E("div",{className:"max-h-[200px] overflow-y-auto space-y-2 pr-1",children:k.map((q)=>{let N=Wq[q.id]||"editor";return K("div",{className:"flex items-center justify-between p-2 rounded-lg hover:bg-muted/50",children:[K("div",{className:"flex items-center gap-3",children:[K(c,{children:[q.image&&E(T,{src:q.image,alt:q.name,className:"object-cover"}),E(w,{children:x(q.name)})]}),K("div",{className:"flex flex-col",children:[E("span",{className:"text-sm font-medium",children:q.name}),E("span",{className:"text-xs text-muted-foreground capitalize",children:q.scope==="team"?J.team_member():J.project_member()})]})]}),K("div",{className:"flex items-center gap-2",children:[K(H,{children:[E(z,{asChild:!0,children:K(Q,{variant:"outline",size:"sm",className:"h-8 px-2 text-xs capitalize w-26",disabled:U===q.id,children:[C(N),E(f,{className:"ml-1 h-3 w-3 opacity-50"})]})}),E(y,{children:K(F,{value:N,onValueChange:(W)=>Xq(q.id,W),children:[E(X,{value:"editor",className:"text-xs",children:J.editor()}),E(X,{value:"reviewer",className:"text-xs",children:J.reviewer()})]})})]}),E(Q,{onClick:async()=>{O(q.id);try{await I(q.id,N),P.success(J.added_member_successfully({name:q.name||""}))}catch(W){console.error(W),P.error(J.failed_to_add_member({name:q.name||""}))}finally{O(null)}},disabled:U!==null,size:"sm",className:"h-8 text-xs px-3 w-[60px]",children:U===q.id?E($,{className:"h-3 w-3 animate-spin"}):J.add()})]})]},q.id)})})]}),B&&S&&K("div",{className:"border-t pt-4",children:[E("h4",{className:"text-sm font-medium mb-3",children:J.invite_new_member()}),K("div",{className:"space-y-3",children:[K("div",{className:"flex gap-2",children:[K(H,{children:[E(z,{asChild:!0,children:K(Q,{variant:"outline",className:"w-[120px] justify-between",children:[G==="editor"?J.editor():J.reviewer(),E(f,{className:"h-4 w-4 opacity-50"})]})}),E(y,{children:K(F,{value:G,onValueChange:(q)=>g(q),children:[E(X,{value:"editor",children:J.editor()}),E(X,{value:"reviewer",children:J.reviewer()})]})})]}),K(Q,{onClick:_q,disabled:v,className:"flex-1",children:[v&&E($,{className:"mr-2 h-4 w-4 animate-spin"}),J.generate_link()]})]}),Z&&K("div",{className:"flex gap-2",children:[E(d,{value:Z,readOnly:!0}),E(Q,{variant:"outline",size:"icon",onClick:$q,children:E(l,{className:"h-4 w-4"})})]})]})]})]})]})})}
|
|
2
|
+
export{Cq as Ya};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{jc as Z}from"./chunk-2dsmsa6a.js";import{kc as J}from"./chunk-ta7bfdrn.js";import{
|
|
2
|
+
import{jc as Z}from"./chunk-2dsmsa6a.js";import{kc as J}from"./chunk-ta7bfdrn.js";import{Jk as L,Lk as w}from"./chunk-1wm57c6y.js";function d(b){return b.thought===!0}function B(b,j){if(typeof j==="string"&&j.length>0)return j;return b}var x=/^[A-Za-z0-9+/]+={0,2}$/;function T(b){if(!b)return!1;if(b.length%4!==0)return!1;return x.test(b)}function Q(b,j){return b&&T(j)?j:void 0}function U(b){return b.startsWith("claude-")||b.startsWith("gpt-oss-")}function f(b){let j=b.toLowerCase().match(/^gemini(?:-live)?-(\d+)/);if(!j)return;return Number.parseInt(j[1],10)}function y(b){let j=f(b);if(j!==void 0)return j>=3;return!0}function R(b,j){let A=[],N=(z)=>{if(!U(b.id))return z;return z.replace(/[^a-zA-Z0-9_-]/g,"_").slice(0,64)},$=Z(j.messages,b,N);for(let z of $)if(z.role==="user")if(typeof z.content==="string")A.push({role:"user",parts:[{text:J(z.content)}]});else{let E=z.content.map((D)=>{if(D.type==="text")return{text:J(D.text)};else return{inlineData:{mimeType:D.mimeType,data:D.data}}});if(E.length===0)continue;A.push({role:"user",parts:E})}else if(z.role==="assistant"){let E=[],D=z.provider===b.provider&&z.model===b.id;for(let q of z.content)if(q.type==="text"){if(!q.text||q.text.trim()==="")continue;let G=Q(D,q.textSignature);E.push({text:J(q.text),...G&&{thoughtSignature:G}})}else if(q.type==="thinking"){if(!q.thinking||q.thinking.trim()==="")continue;if(D){let G=Q(D,q.thinkingSignature);E.push({thought:!0,text:J(q.thinking),...G&&{thoughtSignature:G}})}else E.push({text:J(q.thinking)})}else if(q.type==="toolCall"){let G=Q(D,q.thoughtSignature),K={functionCall:{name:q.name,args:q.arguments??{},...U(b.id)?{id:q.id}:{}},...G&&{thoughtSignature:G}};E.push(K)}if(E.length===0)continue;A.push({role:"model",parts:E})}else if(z.role==="toolResult"){let D=z.content.filter((H)=>H.type==="text").map((H)=>H.text).join(`
|
|
3
3
|
`),q=b.input.includes("image")?z.content.filter((H)=>H.type==="image"):[],G=D.length>0,K=q.length>0,V=y(b.id),W=G?J(D):K?"(see attached image)":"",X=q.map((H)=>({inlineData:{mimeType:H.mimeType,data:H.data}})),v=U(b.id),Y={functionResponse:{name:z.toolName,response:z.isError?{error:W}:{output:W},...K&&V&&{parts:X},...v?{id:z.toolCallId}:{}}},O=A[A.length-1];if(O?.role==="user"&&O.parts?.some((H)=>H.functionResponse))O.parts.push(Y);else A.push({role:"user",parts:[Y]});if(K&&!V)A.push({role:"user",parts:[{text:"Tool result image:"},...X]})}return A}var F=new Set(["$schema","$id","$anchor","$dynamicAnchor","$vocabulary","$comment","$defs","definitions"]);function _(b){if(typeof b!=="object"||b===null||Array.isArray(b))return b;let j={};for(let[A,N]of Object.entries(b)){if(F.has(A))continue;j[A]=_(N)}return j}function C(b,j=!1){if(b.length===0)return;return[{functionDeclarations:b.map((A)=>({name:A.name,description:A.description,...j?{parameters:_(A.parameters)}:{parametersJsonSchema:A.parameters}}))}]}function k(b){switch(b){case"auto":return L.AUTO;case"none":return L.NONE;case"any":return L.ANY;default:return L.AUTO}}function P(b){switch(b){case w.STOP:return"stop";case w.MAX_TOKENS:return"length";case w.BLOCKLIST:case w.PROHIBITED_CONTENT:case w.SPII:case w.SAFETY:case w.IMAGE_SAFETY:case w.IMAGE_PROHIBITED_CONTENT:case w.IMAGE_RECITATION:case w.IMAGE_OTHER:case w.RECITATION:case w.FINISH_REASON_UNSPECIFIED:case w.OTHER:case w.LANGUAGE:case w.MALFORMED_FUNCTION_CALL:case w.UNEXPECTED_TOOL_CALL:case w.NO_IMAGE:return"error";default:throw Error(`Unhandled stop reason: ${b}`)}}
|
|
4
4
|
export{d as _b,B as $b,R as ac,C as bc,k as cc,P as dc};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{qd as P,rd as J}from"./chunk-14fh4s1a.js";import{ee as V,fe as W,ge as X}from"./chunk-n4meg9wb.js";import"./chunk-
|
|
2
|
+
import{qd as P,rd as J}from"./chunk-14fh4s1a.js";import{ee as V,fe as W,ge as X}from"./chunk-n4meg9wb.js";import"./chunk-0qkj838r.js";var Y=class{get supportsCreateIfNotExists(){return!0}get supportsTransactionalDdl(){return!1}get supportsReturning(){return!0}async acquireMigrationLock(){}async releaseMigrationLock(){}get supportsOutput(){return!0}},Z=class{#h;#j=new k;#z;#H;constructor(h){this.#h={...h}}async init(){if(this.#z=this.#h.database,this.#H=new $(this.#z),this.#h.onCreateConnection)await this.#h.onCreateConnection(this.#H)}async acquireConnection(){return await this.#j.lock(),this.#H}async beginTransaction(h){await h.executeQuery(J.raw("begin"))}async commitTransaction(h){await h.executeQuery(J.raw("commit"))}async rollbackTransaction(h){await h.executeQuery(J.raw("rollback"))}async releaseConnection(){this.#j.unlock()}async destroy(){this.#z?.close()}},$=class{#h;constructor(h){this.#h=h}executeQuery(h){let{sql:z,parameters:H}=h,j=this.#h.prepare(z).all(...H);return Promise.resolve({rows:j})}async*streamQuery(){throw Error("Streaming query is not supported by SQLite driver.")}},k=class{#h;#j;async lock(){while(this.#h!==void 0)await this.#h;this.#h=new Promise((h)=>{this.#j=h})}unlock(){let h=this.#j;this.#h=void 0,this.#j=void 0,h?.()}},w=class{#h;constructor(h){this.#h=h}async getSchemas(){return[]}async getTables(h={withInternalKyselyTables:!1}){let z=this.#h.selectFrom("sqlite_schema").where("type","=","table").where("name","not like","sqlite_%").select("name").$castTo();if(!h.withInternalKyselyTables)z=z.where("name","!=",W).where("name","!=",X);let H=await z.execute();return Promise.all(H.map(({name:j})=>this.#j(j)))}async getMetadata(h){return{tables:await this.getTables(h)}}async#j(h){let z=this.#h,H=(await z.selectFrom("sqlite_master").where("name","=",h).select("sql").$castTo().execute())[0]?.sql?.split(/[\(\),]/)?.find((j)=>j.toLowerCase().includes("autoincrement"))?.split(/\s+/)?.[0]?.replace(/["`]/g,"");return{name:h,columns:(await z.selectFrom(P`pragma_table_info(${h})`.as("table_info")).select(["name","type","notnull","dflt_value"]).execute()).map((j)=>({name:j.name,dataType:j.type,isNullable:!j.notnull,isAutoIncrementing:j.name===H,hasDefaultValue:j.dflt_value!=null})),isView:!0}}},K=class extends V{getCurrentParameterPlaceholder(){return"?"}getLeftIdentifierWrapper(){return'"'}getRightIdentifierWrapper(){return'"'}getAutoIncrement(){return"autoincrement"}},F=class{#h;constructor(h){this.#h={...h}}createDriver(){return new Z(this.#h)}createQueryCompiler(){return new K}createAdapter(){return new Y}createIntrospector(h){return new w(h)}};export{F as NodeSqliteDialect};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{xk as b}from"./chunk-9ab6k4rq.js";import{Ck as q}from"./chunk-4qpa7b5t.js";import{Uk as A}from"./chunk-9h027f50.js";import"./chunk-0qkj838r.js";var j=async(f,E,v)=>{let B={api:f.api,provider:f.provider,model:f.id,output:[],stopReason:"stop",timestamp:Date.now()};try{let D=v?.apiKey;if(!D)throw Error(`No API key for provider: ${f.provider}`);let J=L(f,D,v?.headers),G=M(f,E),N=await v?.onPayload?.(G,f);if(N!==void 0)G=N;let F={...v?.signal?{signal:v.signal}:{},...v?.timeoutMs!==void 0?{timeout:v.timeoutMs}:{},maxRetries:v?.maxRetries??0},{data:I,response:_}=await J.chat.completions.create(G,F).withResponse();await v?.onResponse?.({status:_.status,headers:q(_.headers)},f);let Q=I;if(B.responseId=Q.id,Q.usage)B.usage=S(Q.usage,f);let V=Q.choices[0];if(V){let X=V.message.content;if(typeof X==="string"&&X.length>0)B.output.push({type:"text",text:X});for(let Y of V.message.images??[]){let $=typeof Y.image_url==="string"?Y.image_url:Y.image_url?.url;if(!$?.startsWith("data:"))continue;let Z=$.match(/^data:([^;]+);base64,(.+)$/);if(!Z)continue;B.output.push({type:"image",mimeType:Z[1],data:Z[2]})}}return B}catch(D){return B.stopReason=v?.signal?.aborted?"aborted":"error",B.errorMessage=D instanceof Error?D.message:JSON.stringify(D),B}};function L(f,E,v){return new b({apiKey:E,baseURL:f.baseUrl,dangerouslyAllowBrowser:!0,defaultHeaders:{...f.headers,...v}})}function M(f,E){let v=E.input.map((B)=>{if(B.type==="text")return{type:"text",text:A(B.text)};return{type:"image_url",image_url:{url:`data:${B.mimeType};base64,${B.data}`}}});return{model:f.id,messages:[{role:"user",content:v}],stream:!1,modalities:f.output.includes("text")?["image","text"]:["image"]}}function S(f,E){let v=f.prompt_tokens||0,B=f.prompt_tokens_details?.cached_tokens||0,D=f.prompt_tokens_details?.cache_write_tokens||0,J=D>0?Math.max(0,B-D):B,G=Math.max(0,v-J-D),N=f.completion_tokens||0,F={input:G,output:N,cacheRead:J,cacheWrite:D,totalTokens:G+N+J+D,cost:{input:E.cost.input/1e6*G,output:E.cost.output/1e6*N,cacheRead:E.cost.cacheRead/1e6*J,cacheWrite:E.cost.cacheWrite/1e6*D,total:0}};return F.cost.total=F.cost.input+F.cost.output+F.cost.cacheRead+F.cost.cacheWrite,F}export{j as generateImagesOpenRouter};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{Dk as T,Ek as A,Fk as G,Gk as C,Hk as I,Ik as M}from"./chunk-qksb0v3c.js";import{Nk as v}from"./chunk-1wm57c6y.js";import{Ok as P}from"./chunk-re0b7sj7.js";import{Rk as K,Sk as O,Tk as S}from"./chunk-922nnh39.js";import{Uk as y}from"./chunk-9h027f50.js";import"./chunk-0qkj838r.js";var B=0,z=(q,V,J)=>{let N=new S;return(async()=>{let w={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=J?.apiKey;if(!X)throw Error(`No API key for provider: ${q.provider}`);let $=x(q,X,J?.headers),Y=f(q,V,J),H=await J?.onPayload?.(Y,q);if(H!==void 0)Y=H;let h=await $.models.generateContentStream(Y);N.push({type:"start",partial:w});let Q=null,R=w.content,Z=()=>R.length-1;for await(let _ of h){w.responseId||=_.responseId;let E=_.candidates?.[0];if(E?.content?.parts)for(let W of E.content.parts){if(W.text!==void 0){let D=T(W);if(!Q||D&&Q.type!=="thinking"||!D&&Q.type!=="text"){if(Q)if(Q.type==="text")N.push({type:"text_end",contentIndex:R.length-1,content:Q.text,partial:w});else N.push({type:"thinking_end",contentIndex:Z(),content:Q.thinking,partial:w});if(D)Q={type:"thinking",thinking:"",thinkingSignature:void 0},w.content.push(Q),N.push({type:"thinking_start",contentIndex:Z(),partial:w});else Q={type:"text",text:""},w.content.push(Q),N.push({type:"text_start",contentIndex:Z(),partial:w})}if(Q.type==="thinking")Q.thinking+=W.text,Q.thinkingSignature=A(Q.thinkingSignature,W.thoughtSignature),N.push({type:"thinking_delta",contentIndex:Z(),delta:W.text,partial:w});else Q.text+=W.text,Q.textSignature=A(Q.textSignature,W.thoughtSignature),N.push({type:"text_delta",contentIndex:Z(),delta:W.text,partial:w})}if(W.functionCall){if(Q){if(Q.type==="text")N.push({type:"text_end",contentIndex:Z(),content:Q.text,partial:w});else N.push({type:"thinking_end",contentIndex:Z(),content:Q.thinking,partial:w});Q=null}let D=W.functionCall.id,U={type:"toolCall",id:!D||w.content.some((j)=>j.type==="toolCall"&&j.id===D)?`${W.functionCall.name}_${Date.now()}_${++B}`:D,name:W.functionCall.name||"",arguments:W.functionCall.args??{},...W.thoughtSignature&&{thoughtSignature:W.thoughtSignature}};w.content.push(U),N.push({type:"toolcall_start",contentIndex:Z(),partial:w}),N.push({type:"toolcall_delta",contentIndex:Z(),delta:JSON.stringify(U.arguments),partial:w}),N.push({type:"toolcall_end",contentIndex:Z(),toolCall:U,partial:w})}}if(E?.finishReason){if(w.stopReason=M(E.finishReason),w.content.some((W)=>W.type==="toolCall"))w.stopReason="toolUse"}if(_.usageMetadata)w.usage={input:(_.usageMetadata.promptTokenCount||0)-(_.usageMetadata.cachedContentTokenCount||0),output:(_.usageMetadata.candidatesTokenCount||0)+(_.usageMetadata.thoughtsTokenCount||0),cacheRead:_.usageMetadata.cachedContentTokenCount||0,cacheWrite:0,totalTokens:_.usageMetadata.totalTokenCount||0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},K(q,w.usage)}if(Q)if(Q.type==="text")N.push({type:"text_end",contentIndex:Z(),content:Q.text,partial:w});else N.push({type:"thinking_end",contentIndex:Z(),content:Q.thinking,partial:w});if(J?.signal?.aborted)throw Error("Request was aborted");if(w.stopReason==="aborted"||w.stopReason==="error")throw Error("An unknown error occurred");N.push({type:"done",reason:w.stopReason,message:w}),N.end()}catch(X){for(let $ of w.content)if("index"in $)delete $.index;w.stopReason=J?.signal?.aborted?"aborted":"error",w.errorMessage=X instanceof Error?X.message:JSON.stringify(X),N.push({type:"error",reason:w.stopReason,error:w}),N.end()}})(),N},l=(q,V,J)=>{let N=J?.apiKey;if(!N)throw Error(`No API key for provider: ${q.provider}`);let w=P(q,J,N);if(!J?.reasoning)return z(q,V,{...w,thinking:{enabled:!1}});let X=O(q,J.reasoning),$=X==="off"?"high":X,Y=q;if(L(Y)||b(Y)||F(Y))return z(q,V,{...w,thinking:{enabled:!0,level:g($,Y)}});return z(q,V,{...w,thinking:{enabled:!0,budgetTokens:a(Y,$,J.thinkingBudgets)}})};function x(q,V,J){let N={};if(q.baseUrl)N.baseUrl=q.baseUrl,N.apiVersion="";if(q.headers||J)N.headers={...q.headers,...J};return new v({apiKey:V,httpOptions:Object.keys(N).length>0?N:void 0})}function f(q,V,J={}){let N=G(q,V),w={};if(J.temperature!==void 0)w.temperature=J.temperature;if(J.maxTokens!==void 0)w.maxOutputTokens=J.maxTokens;let X={...Object.keys(w).length>0&&w,...V.systemPrompt&&{systemInstruction:y(V.systemPrompt)},...V.tools&&V.tools.length>0&&{tools:C(V.tools)}};if(V.tools&&V.tools.length>0&&J.toolChoice)X.toolConfig={functionCallingConfig:{mode:I(J.toolChoice)}};else X.toolConfig=void 0;if(J.thinking?.enabled&&q.reasoning){let Y={includeThoughts:!0};if(J.thinking.level!==void 0)Y.thinkingLevel=J.thinking.level;else if(J.thinking.budgetTokens!==void 0)Y.thinkingBudget=J.thinking.budgetTokens;X.thinkingConfig=Y}else if(q.reasoning&&J.thinking&&!J.thinking.enabled)X.thinkingConfig=k(q);if(J.signal){if(J.signal.aborted)throw Error("Request aborted");X.abortSignal=J.signal}return{model:q.id,contents:N,config:X}}function F(q){return/gemma-?4/.test(q.id.toLowerCase())}function L(q){return/gemini-3(?:\.\d+)?-pro/.test(q.id.toLowerCase())}function b(q){return/gemini-3(?:\.\d+)?-flash/.test(q.id.toLowerCase())}function k(q){if(L(q))return{thinkingLevel:"LOW"};if(b(q))return{thinkingLevel:"MINIMAL"};if(F(q))return{thinkingLevel:"MINIMAL"};return{thinkingBudget:0}}function g(q,V){if(L(V))switch(q){case"minimal":case"low":return"LOW";case"medium":case"high":return"HIGH"}if(F(V))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 a(q,V,J){if(J?.[V]!==void 0)return J[V];if(q.id.includes("2.5-pro"))return{minimal:128,low:2048,medium:8192,high:32768}[V];if(q.id.includes("2.5-flash-lite"))return{minimal:512,low:2048,medium:8192,high:24576}[V];if(q.id.includes("2.5-flash"))return{minimal:128,low:2048,medium:8192,high:24576}[V];return-1}export{l as streamSimpleGoogle,z as streamGoogle};
|