@shumai-one/shumai 0.3.1 → 0.3.3
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-dwswqq3g.js → chunk-0a0sdyta.js} +1 -1
- package/bin/{chunk-qmtvy2j4.js → chunk-0dcv6kpk.js} +2 -2
- package/bin/chunk-1cjgpspz.js +2 -0
- package/bin/chunk-1pgtq4rc.js +2 -0
- package/bin/chunk-1rsp4hc5.js +1 -0
- package/bin/{chunk-7eycsyk6.js → chunk-2475z7vk.js} +1 -1
- package/bin/chunk-25qj10ny.js +1 -0
- package/bin/{chunk-gn8snrnk.js → chunk-2fc5hk8r.js} +1 -1
- package/bin/{chunk-qc6dmzn0.js → chunk-2jvqhps9.js} +2 -2
- package/bin/{chunk-ve7v8wtv.js → chunk-3823qzr0.js} +2 -2
- package/bin/{chunk-zxpef55w.js → chunk-3g9g2c7h.js} +3 -3
- package/bin/chunk-3gcnj1eq.js +2 -0
- package/bin/chunk-41m51y08.js +2 -0
- package/bin/chunk-4g7h9qhr.js +8 -0
- package/bin/chunk-4v5ykazp.js +1 -0
- package/bin/{chunk-k20bhxed.js → chunk-525eypdk.js} +1 -1
- package/bin/{chunk-h2wsm7h3.js → chunk-57kgmgfs.js} +2 -2
- package/bin/{chunk-gvn079hy.js → chunk-5cm4vge8.js} +2 -2
- package/bin/{chunk-31mjcykb.js → chunk-5vwkfxy7.js} +2 -2
- package/bin/chunk-5x3vzer8.js +1 -0
- package/bin/chunk-67rr836p.js +3 -0
- package/bin/chunk-6jgq154r.js +2 -0
- package/bin/chunk-7436fyrg.js +2 -0
- package/bin/{chunk-s05f0v9t.js → chunk-749c09cw.js} +1 -1
- package/bin/{chunk-9p2d0mk1.js → chunk-7anqxx1z.js} +1 -1
- package/bin/{chunk-s7qpj715.js → chunk-7pjes19z.js} +2 -2
- package/bin/{chunk-f8cn9m28.js → chunk-7x7jtkh8.js} +1 -1
- package/bin/chunk-804ndet8.js +2 -0
- package/bin/chunk-8a75zqbz.js +2 -0
- package/bin/{chunk-tsncwscz.js → chunk-9a7a1p1j.js} +2 -2
- package/bin/chunk-9e99n265.js +12 -0
- package/bin/chunk-9g6vy76b.js +2 -0
- package/bin/{chunk-wap08p4j.js → chunk-9sdhdhv4.js} +2 -2
- package/bin/{chunk-g2dk56e7.js → chunk-9vgjhemh.js} +1 -1
- package/bin/{chunk-1dawjfk8.js → chunk-9zvteyz0.js} +2 -2
- package/bin/chunk-a8daqpfh.js +7 -0
- package/bin/{chunk-na2nympm.js → chunk-am1m29pv.js} +1 -1
- package/bin/{chunk-xawwxdq9.js → chunk-bd6x5ns9.js} +2 -2
- package/bin/{chunk-wr5byz6r.js → chunk-bn4ewsy8.js} +1 -1
- package/bin/{chunk-ss45w8ks.js → chunk-bw6wyw7k.js} +2 -2
- package/bin/{chunk-8yz1expv.js → chunk-c0c88nje.js} +48 -48
- package/bin/chunk-c7rj0f5r.js +3 -0
- package/bin/chunk-cdqvg03f.js +3 -0
- package/bin/{chunk-zs9b0f3z.js → chunk-d3kpqay2.js} +2 -2
- package/bin/chunk-d6v81kjj.js +1 -0
- package/bin/chunk-dfcrtdk2.js +1 -0
- package/bin/chunk-eczsk2xd.js +62 -0
- package/bin/{chunk-yahb7wan.js → chunk-ey7vty63.js} +2 -2
- package/bin/{chunk-nzy3pjjm.js → chunk-fwqpq2sy.js} +2 -2
- package/bin/{chunk-vnfmh5ke.js → chunk-g097058z.js} +2 -2
- package/bin/{chunk-a76c5r3c.js → chunk-g224r7mc.js} +2 -2
- package/bin/chunk-g5e93f59.js +2 -0
- package/bin/chunk-g5xkj9p3.js +2 -0
- package/bin/chunk-gaemak59.js +4 -0
- package/bin/{chunk-hrzm70wg.js → chunk-gh4w2bdg.js} +1 -1
- package/bin/chunk-gpeyctxd.js +2 -0
- package/bin/{chunk-nqh128dt.js → chunk-gpmaaca1.js} +2 -2
- package/bin/{chunk-1d22tysv.js → chunk-h4a3ms2b.js} +2 -2
- package/bin/chunk-h73653yp.js +1 -0
- package/bin/chunk-hp139z0j.js +2 -0
- package/bin/chunk-hz6s7by4.js +11 -0
- package/bin/chunk-j4y8c864.js +1 -0
- package/bin/chunk-jkh04dka.js +8 -0
- package/bin/chunk-m268vcdm.js +2 -0
- package/bin/{chunk-vy24ncn2.js → chunk-m6sssvg3.js} +1 -1
- package/bin/chunk-mggfc9ya.js +2 -0
- package/bin/chunk-mhwp74hh.js +3 -0
- package/bin/{chunk-vgb8bzcg.js → chunk-mm810jv7.js} +2 -2
- package/bin/chunk-p1bcbtmg.js +3 -0
- package/bin/chunk-p86w1eaw.js +45 -0
- package/bin/{chunk-1nh6xgek.js → chunk-p8enen2a.js} +1 -1
- package/bin/chunk-pbb1tdwt.js +1 -0
- package/bin/chunk-pbfkw90e.js +1 -0
- package/bin/chunk-pdajhyqm.js +2 -0
- package/bin/{chunk-ph3e1bpp.js → chunk-pqxh0cg7.js} +2 -2
- package/bin/chunk-q8me9zev.js +1 -0
- package/bin/chunk-qshm5vcn.js +2 -0
- package/bin/chunk-qx2mzv89.js +2 -0
- package/bin/{chunk-amsb41z5.js → chunk-r5jmnsqj.js} +1 -1
- package/bin/{chunk-arpna31w.js → chunk-rt0pvhdf.js} +1 -1
- package/bin/{chunk-kgb16ggd.css → chunk-s10v4b01.css} +1 -1
- package/bin/{chunk-vt4zpasm.js → chunk-s1b5kf34.js} +2 -2
- package/bin/{chunk-ws07a9kv.js → chunk-t15a1vp6.js} +1 -1
- package/bin/{chunk-3rcc5s99.js → chunk-tc7q988r.js} +2 -2
- package/bin/chunk-ts9f4zqh.js +5 -0
- package/bin/chunk-tzmzqmcg.js +7 -0
- package/bin/chunk-v0xbr5e6.js +2 -0
- package/bin/{chunk-08mxv0sm.js → chunk-v0yhkcj5.js} +2 -2
- package/bin/{chunk-3t7mjvdv.js → chunk-v75fanse.js} +2 -2
- package/bin/chunk-va6hxm7n.js +3 -0
- package/bin/chunk-vf3bg920.js +3 -0
- package/bin/{chunk-ejfmxjw6.js → chunk-vg6mkdj1.js} +2 -2
- package/bin/{chunk-j0p1peav.js → chunk-wkth5xwr.js} +2 -2
- package/bin/chunk-wpntb95k.js +2 -0
- package/bin/{chunk-mahxw48e.js → chunk-wtzkfwmx.js} +2 -2
- package/bin/{chunk-hfp4hpca.js → chunk-x0r8dcq0.js} +2 -2
- package/bin/{chunk-etces6ff.js → chunk-xcbb21j9.js} +2 -2
- package/bin/{chunk-mcxsk75h.js → chunk-xgb533n0.js} +3 -3
- package/bin/{chunk-7jjc175m.js → chunk-xn9cpax1.js} +3 -3
- package/bin/{chunk-5vqan9c4.js → chunk-xsw3pb5p.js} +2 -2
- package/bin/chunk-yedr4r8a.js +2 -0
- package/bin/chunk-yfjn4qn2.js +1 -0
- package/bin/chunk-yfkcv10v.js +2 -0
- package/bin/{chunk-20y3wte3.js → chunk-yj6tmjsc.js} +2 -2
- package/bin/chunk-z9560a6e.js +1 -0
- package/bin/chunk-zgsy3k3h.js +3 -0
- package/bin/shumai-app.html +1 -1
- package/bin/shumai-app.js +381 -330
- 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/schema.prisma +25 -0
- package/bin/chunk-08dr94gp.js +0 -2
- package/bin/chunk-0ed7h2xm.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-4hdx2tv0.js +0 -2
- package/bin/chunk-4p7xpfey.js +0 -2
- package/bin/chunk-5e1xqaj4.js +0 -2
- package/bin/chunk-5f81c951.js +0 -1
- package/bin/chunk-5s7c0qww.js +0 -1
- package/bin/chunk-5zntjzxw.js +0 -3
- package/bin/chunk-6a2eb3b5.js +0 -3
- package/bin/chunk-6gy7c4d7.js +0 -1
- package/bin/chunk-7d4scsf6.js +0 -1
- package/bin/chunk-7d5kep8c.js +0 -2
- package/bin/chunk-7y8dng8t.js +0 -2
- package/bin/chunk-8m6zg15c.js +0 -4
- package/bin/chunk-8n60m9x3.js +0 -1
- package/bin/chunk-8qyke29r.js +0 -7
- package/bin/chunk-90et6bwm.js +0 -3
- package/bin/chunk-a10tf0d8.js +0 -3
- package/bin/chunk-a9t667xv.js +0 -1
- package/bin/chunk-b10meywb.js +0 -2
- package/bin/chunk-b1e3tec3.js +0 -62
- package/bin/chunk-bdjhb77e.js +0 -2
- package/bin/chunk-bmqw3j2d.js +0 -2
- 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-h270n69j.js +0 -7
- package/bin/chunk-hz31j0hk.js +0 -4
- package/bin/chunk-jm6bxtzt.js +0 -41
- package/bin/chunk-k9w6mk9d.js +0 -3
- package/bin/chunk-m4py21f3.js +0 -2
- package/bin/chunk-mqbxagfd.js +0 -2
- 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-pgae67hk.js +0 -3
- package/bin/chunk-ph11924k.js +0 -1
- package/bin/chunk-pj0fgb2x.js +0 -6
- package/bin/chunk-pp072ksj.js +0 -2
- package/bin/chunk-q5cdjzbv.js +0 -3
- package/bin/chunk-qgq96tbp.js +0 -2
- package/bin/chunk-qvgc9e08.js +0 -3
- package/bin/chunk-rfh4ppaa.js +0 -1
- package/bin/chunk-rrhq3t4s.js +0 -1
- package/bin/chunk-sf6fwvrs.js +0 -8
- package/bin/chunk-sr9bty78.js +0 -1
- 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-y2nw8rbx.js +0 -4
- package/bin/chunk-y9ttm07y.js +0 -3
- package/bin/chunk-zg0vm233.js +0 -2
- package/bin/chunk-zhd2mkbr.js +0 -1
- package/bin/chunk-zx9cv3t8.js +0 -2
package/bin/chunk-bdjhb77e.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{Wj as t,ak as a,ih as o}from"./chunk-b1e3tec3.js";function m({className:r,orientation:i="horizontal",decorative:e=!0,...n}){return o(t.Root,{"data-slot":"separator",decorative:e,orientation:i,className:a("shrink-0 bg-border data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px",r),...n})}
|
|
2
|
-
export{m as fa};
|
package/bin/chunk-bmqw3j2d.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{s as p}from"./chunk-nzy3pjjm.js";import{W as Yz,X as Zz,Y as _z,Z as $z,_ as Kz}from"./chunk-zhd2mkbr.js";import{Va as Uz}from"./chunk-31mjcykb.js";import{Xa as S}from"./chunk-hfp4hpca.js";import{kg as v}from"./chunk-pgae67hk.js";import{Pg as Jz}from"./chunk-wap08p4j.js";import{bh as Xz}from"./chunk-nr89225z.js";import{Gj as Gz,Mh as r,Ni as h,Wh as o,ak as T,di as t,fi as e,gh as Bz,hh as B,ih as z,ik as Y,jh as J,jj as zz,kh as a,ki as M,li as s,nh as n,qi as b,xj as A}from"./chunk-b1e3tec3.js";import{Xk as Rz}from"./chunk-ws07a9kv.js";var Z=Rz(Bz(),1);function uz({projectId:O,contextAssetId:R}){let{isHistoryMode:W,setIsHistoryMode:I,currentSessionId:Vz,chatAssets:u,removeAsset:Wz,messages:E,historySessions:g,isStreaming:D,fetchHistorySessions:m,loadSession:Lz,deleteSession:Nz,startNewSession:Qz,sendMessage:Pz,abortActiveSession:Oz,selectedAgentId:H,setSelectedAgentId:w}=v(),{teamId:_,ensureTeamIdForProject:l}=Xz();Z.useEffect(()=>{if(O)l(O)},[O,l]);let{data:Dz=[]}=n({queryKey:["agents",_],queryFn:async()=>{if(!_)return[];let G=await r.api.teams[":teamId"].agents.$get({param:{teamId:_}});if(!G.ok)throw Error("failed to fetch agents");return G.json()},enabled:!!_}),F=Dz.filter((G)=>G.type==="chat"&&G.enabled);Z.useEffect(()=>{if(F.length>0){if(!F.some((X)=>X.id===H))w(F[0].id)}},[F,H,w]);let[C,j]=Z.useState(""),d=Z.useRef(null),y=Z.useRef(null),k=Z.useRef(!0),f=Z.useRef(!0);Z.useEffect(()=>{f.current=!0,k.current=!0},[O,R,W]),Z.useEffect(()=>{let G=y.current?.querySelector('[data-slot="scroll-area-viewport"]');if(!G)return;let{scrollTop:X,isAtBottom:$}=v.getState(),V=setTimeout(()=>{if($)G.scrollTop=G.scrollHeight;else G.scrollTop=X;let Q=setTimeout(()=>{f.current=!1},50);return()=>clearTimeout(Q)},0);return()=>clearTimeout(V)},[O,R,W]),Z.useEffect(()=>{let G=y.current?.querySelector('[data-slot="scroll-area-viewport"]');if(!G)return;let X=()=>{if(f.current)return;let $=G.scrollTop,V=G.scrollHeight-$-G.clientHeight<10;v.getState().setScrollState($,V)};return G.addEventListener("scroll",X),()=>{G.removeEventListener("scroll",X)}},[O,R,W]);let{ref:qz,isDropTarget:Ez}=Uz({id:"chatbot-sidebar",data:{type:"chatbot-sidebar"}});Z.useEffect(()=>{if(!W){let{isAtBottom:G}=v.getState();if(G||D){let X=k.current?"auto":"smooth";d.current?.scrollIntoView({behavior:X})}k.current=!1}},[E,D,W]),Z.useEffect(()=>{if(W&&_)m(_)},[W,m,_]);let q=a(),Fz=Z.useCallback(()=>{q.invalidateQueries({queryKey:["search"]}),q.invalidateQueries({queryKey:["folders"]}),q.invalidateQueries({queryKey:["files"]}),q.invalidateQueries({queryKey:["file"]}),q.invalidateQueries({queryKey:["version_stacks"]}),q.invalidateQueries({queryKey:["projects"]})},[q]),x=()=>{if(!C.trim()||D||!_)return;Pz(_,C,O,R,Fz),j("")},Hz=(G)=>{if(G.nativeEvent.isComposing)return;if(G.key==="Enter"&&!G.shiftKey)G.preventDefault(),x()},c=(G)=>{if(typeof G==="string")return G;if(Array.isArray(G))return G.map((X)=>{if(typeof X==="string")return X;if(X&&typeof X==="object"&&"type"in X&&X.type==="text"&&"text"in X)return String(X.text);return""}).join("");return""},i=(G)=>{return G.replace(/<@([a-zA-Z0-9_-]+)>/g,"@$1").replace(/^\[([^\]]+)\]:/gm,"\\[$1\\]:")},Cz=(G)=>{switch(G.role){case"user":return z("div",{className:"flex justify-end w-full",children:z("div",{className:"bg-primary text-primary-foreground rounded-lg px-3 py-2 max-w-[85%] text-sm whitespace-pre-wrap shadow-xs break-words",children:c(G.content)})},G.id);case"assistant":{let $=G.content;if(!$)return null;let V=[];if($.forEach((K,L)=>{if(!K||typeof K!=="object")return;let N=K;switch(N.type){case"text":{let U=N.text;if(typeof U!=="string"||!U.trim())return;V.push(z("div",{className:"text-sm leading-[1.8] prose prose-sm dark:prose-invert max-w-none break-words",children:z(p,{components:{pre:({node:P,...vz})=>z("pre",{className:"whitespace-pre-wrap break-all break-words bg-muted text-foreground p-4 rounded-md border border-border/50 font-mono text-sm",...vz})},children:i(U)})},`txt-${L}`));break}case"thinking":{let U=N.thinking;if(typeof U!=="string"||!U.trim())return;V.push(J("details",{className:"group border border-border/50 rounded-lg bg-muted/20 my-2 overflow-hidden",children:[J("summary",{className:"flex items-center gap-2 p-2.5 text-xs font-medium text-muted-foreground select-none cursor-pointer hover:bg-muted/40 transition-colors list-none [&::-webkit-details-marker]:hidden",children:[z(s,{className:"h-3.5 w-3.5 text-primary/70 animate-pulse"}),z("span",{children:Y.role_thinking()||"Thinking"}),z(b,{className:"h-3 w-3 ml-auto transition-transform group-open:rotate-180"})]}),z("div",{className:"p-3 pt-0 text-xs text-muted-foreground/90 border-t border-border/40 bg-muted/10 leading-relaxed prose prose-sm dark:prose-invert max-w-none whitespace-pre-wrap font-sans",children:z(p,{children:i(U)})})]},`think-${L}`));break}case"toolCall":{let U=String(N.name||N.toolName||Y.unknown()),P=N.arguments||N.args;V.push(J("details",{className:"group border border-border/50 rounded-lg bg-violet-500/5 my-2 overflow-hidden",children:[J("summary",{className:"flex items-center gap-2 p-2.5 text-xs font-semibold text-violet-600 dark:text-violet-400 select-none cursor-pointer hover:bg-violet-500/10 transition-colors list-none [&::-webkit-details-marker]:hidden",children:[z(Gz,{className:"h-3.5 w-3.5"}),z("span",{children:Y.calling_tool()}),z("span",{className:"font-mono bg-violet-500/10 px-1.5 py-0.5 rounded text-[11px] text-violet-700 dark:text-violet-300",children:U}),z(b,{className:"h-3 w-3 ml-auto transition-transform group-open:rotate-180"})]}),!!P&&J("div",{className:"p-3 pt-0 text-[10px] text-muted-foreground/90 border-t border-border/40 bg-violet-500/5 font-sans",children:[z("div",{className:"text-[9px] text-muted-foreground/60 uppercase font-bold tracking-wider mb-1.5",children:Y.tool_arguments()||"Arguments"}),z("pre",{className:"font-mono bg-muted/30 p-2 rounded border border-border/30 overflow-x-auto max-h-32",children:JSON.stringify(P,null,2)})]})]},`tool-${L}`));break}case"image":{let U=String(N.mimeType||"image/png"),P=String(N.data||"");V.push(z("div",{className:"my-2 max-w-full",children:P?z("img",{src:P.startsWith("data:")?P:`data:${U};base64,${P}`,alt:"Attached asset",className:"max-h-60 rounded border border-border/50 object-contain shadow-xs"}):z("div",{className:"text-xs text-muted-foreground italic flex items-center gap-1.5 py-1",children:Y.image_object()})},`img-${L}`));break}default:{let U=JSON.stringify(K,null,2);if(U==="{}")return;V.push(z("pre",{className:"text-xs text-foreground/80 font-mono whitespace-pre-wrap break-words bg-muted/20 p-2 rounded",children:U},`other-${L}`))}}}),V.length===0)return null;let Q=!1;if($.length>0){let K=$[$.length-1];if(typeof K==="string"&&K.trim().length>0)Q=!0;else if(K&&typeof K==="object"){let L=K;if(L.type==="text"&&typeof L.text==="string"&&L.text.trim().length>0)Q=!0}}return J("div",{className:"flex flex-col w-full space-y-1",children:[z("div",{className:"space-y-2 w-full",children:V}),Q&&z("div",{className:"text-[10px] text-muted-foreground self-start italic pt-1",children:Y.created_by_agent()})]},G.id)}case"toolResult":return z("div",{className:"flex items-center gap-2 text-xs text-muted-foreground bg-muted/40 p-2 rounded-md border border-border/50",children:z("span",{className:"font-semibold",children:Y.tool_result_with_name({name:G.toolName||"tool"})})},G.id);case"thinking_level_change":case"custom":{let X=G;if(X.customType==="context_display_info"){let Q=X.details?.assets||[];if(Q.length===0)return null;return J("div",{className:"text-xs text-muted-foreground bg-muted/40 p-2.5 rounded-lg border border-border/50 space-y-1 my-1",children:[z("div",{className:"font-semibold",children:Y.assets_added_to_context()}),z("ul",{className:"list-disc list-inside space-y-0.5",children:Q.map((K)=>J("li",{className:"truncate",children:[K.name," ",J("span",{className:"text-muted-foreground/70",children:["(",K.type,")"]})]},K.id))})]},G.id)}let $=X.content||"";return z("div",{className:"text-center text-xs text-muted-foreground italic bg-muted/20 py-1.5 rounded",children:c($)},G.id)}default:return null}};return J("div",{ref:qz,className:T("relative flex flex-col h-full bg-background transition-colors duration-200 min-h-0"),children:[Ez&&z("div",{className:"absolute inset-0 bg-accent/30 border-2 border-primary z-50 pointer-events-none flex items-center justify-center p-6 text-center animate-in fade-in duration-150",children:J("div",{className:"bg-background/95 text-foreground px-4 py-3 rounded-xl border border-border/80 flex flex-col items-center gap-2 shadow-lg max-w-[80%] animate-in zoom-in-95 duration-150",children:[z(M,{className:"h-6 w-6 text-primary animate-bounce"}),z("span",{className:"text-sm font-semibold text-foreground",children:Y.chatbot_drag_drop_hint()||"Drop assets here"})]})}),z("div",{className:"flex items-center justify-between p-4 pt-[0.7rem] flex-shrink-0",children:W?J(B,{children:[z("div",{className:"flex items-center gap-2 font-semibold",children:z("span",{children:Y.history()})}),z("button",{onClick:()=>I(!1),className:"p-1.5 hover:bg-accent rounded-md text-muted-foreground hover:text-foreground transition-colors",title:"Close History",children:z(t,{className:"h-4 w-4"})})]}):J(B,{children:[z("div",{className:"flex items-center gap-2 font-semibold",children:z("span",{children:Y.shumai_agent()})}),J("div",{className:"flex items-center gap-1",children:[z("button",{onClick:Qz,className:"p-1.5 hover:bg-accent rounded-md text-muted-foreground hover:text-foreground transition-colors",title:Y.new_chat(),children:z(zz,{className:"h-4 w-4"})}),z("button",{onClick:()=>I(!0),className:"p-1.5 hover:bg-accent rounded-md text-muted-foreground hover:text-foreground transition-colors",title:Y.history(),children:z(h,{className:"h-4 w-4"})})]})]})}),W?z(S,{className:"flex-1 p-4 min-h-0",children:g.length===0?J("div",{className:"flex flex-col items-center justify-center h-48 text-muted-foreground p-4 text-center",children:[z(h,{className:"h-8 w-8 mb-2 opacity-50 text-muted-foreground"}),z("p",{className:"text-sm",children:Y.no_history_sessions()})]}):z("div",{className:"space-y-2 pb-4",children:g.map((G)=>{let X=G.id===Vz;return J("div",{className:T("group relative flex items-center justify-between p-3 border rounded-lg transition-all cursor-pointer bg-card",X?"border-primary":"border-border hover:bg-accent/30"),children:[J("div",{onClick:()=>_&&Lz(_,G.id),className:"flex-1 min-w-0 pr-6",children:[z("div",{className:"text-sm font-semibold text-foreground truncate",children:G.name||Y.new_chat()}),z("div",{className:"text-xs text-muted-foreground mt-0.5",children:Jz(G.createdAt)})]}),z("button",{onClick:($)=>{if($.stopPropagation(),_&&confirm(Y.delete_session_confirm()))Nz(_,G.id)},className:"absolute right-3 opacity-0 group-hover:opacity-100 focus:opacity-100 transition-opacity text-muted-foreground hover:text-destructive p-1 rounded hover:bg-muted",title:"Delete Session",children:z(A,{className:"h-4 w-4"})})]},G.id)})})}):J(B,{children:[z(S,{ref:y,className:"flex-1 p-4 min-h-0 [&>div>div]:!block",children:E.length===0?J("div",{className:"flex flex-col items-center justify-center h-48 border-2 border-dashed border-border rounded-lg text-muted-foreground p-4 text-center",children:[z(M,{className:"h-8 w-8 mb-2 opacity-50 text-muted-foreground"}),z("p",{className:"text-sm",children:Y.chatbot_drag_drop_hint()})]}):J("div",{className:"space-y-4 pb-4",children:[E.map(Cz),D&&E.length>0&&E[E.length-1].role==="user"&&J("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground italic",children:[z(o,{className:"h-3 w-3 animate-spin text-primary"}),z("span",{children:"Thinking..."})]}),z("div",{ref:d})]})}),z("div",{className:"p-2 flex-shrink-0 bg-background",children:J("div",{className:"relative flex flex-col w-full border border-foreground/20 rounded-2xl shadow-xs transition-all duration-200 focus-within:ring-2 focus-within:ring-primary focus-within:border-transparent bg-background overflow-hidden",children:[u.length>0&&z("div",{className:"flex flex-col gap-1.5 min-h-0 max-h-[160px] overflow-y-auto border-b border-border bg-muted/5 p-3 divide-y divide-border/50",children:u.map((G)=>J("div",{className:"flex items-center justify-between py-1.5 text-xs group",children:[J("div",{className:"flex items-baseline gap-1.5 min-w-0 pr-2",children:[z("span",{className:"truncate font-medium text-foreground",children:G.name}),z("span",{className:"text-[9px] text-muted-foreground uppercase flex-shrink-0",children:G.type})]}),z("button",{onClick:()=>Wz(G.id),className:"text-muted-foreground hover:text-destructive transition-colors p-0.5",title:Y.remove_from_context(),children:z(A,{className:"h-3.5 w-3.5"})})]},G.id))}),z("textarea",{value:C,onChange:(G)=>j(G.target.value),onKeyDown:Hz,placeholder:"Type a message...",rows:2,className:"w-full bg-transparent border-none focus:ring-0 focus:outline-hidden resize-none min-h-[44px] max-h-[120px] px-3 py-2 text-sm focus-visible:outline-hidden focus:ring-transparent focus:border-transparent focus-visible:ring-0",disabled:D}),J("div",{className:"flex justify-between items-center px-3 pb-2 pt-1",children:[z("div",{className:"flex items-center gap-1.5 min-w-0 max-w-[70%]",children:F.length>0?J(Yz,{value:H||"",onValueChange:(G)=>w(G),disabled:D,children:[z(_z,{className:"h-8 border-none bg-transparent hover:bg-muted text-muted-foreground hover:text-foreground focus:ring-0 focus:ring-offset-0 px-2 py-0 gap-1.5 text-xs shrink-0 select-none shadow-none max-w-full",children:z(Zz,{placeholder:Y.select_agent()})}),z($z,{children:F.map((G)=>z(Kz,{value:G.id,children:J("div",{className:"flex items-center gap-2",children:[G.avatar?z("img",{src:G.avatar,alt:G.name,className:"w-4 h-4 rounded-full object-cover"}):z(M,{className:"w-4 h-4 text-muted-foreground"}),z("span",{className:"text-xs",children:G.name})]})},G.id))})]}):z("div",{className:"flex items-center gap-1.5 px-2 py-1 text-[11px] text-muted-foreground/60 italic select-none",children:z("span",{children:Y.no_chat_agents_warning()})})}),D?z("button",{onClick:()=>{if(_)Oz(_)},className:"p-2 rounded-full transition-all duration-200 flex items-center justify-center shrink-0 shadow-sm bg-destructive text-destructive-foreground hover:bg-destructive/90 transform hover:-translate-y-0.5",title:"Stop generation",children:z("div",{className:"h-4 w-4 flex items-center justify-center",children:z("div",{className:"h-3 w-3 bg-current rounded-[2px] bg-white"})})}):z("button",{onClick:x,disabled:!C.trim()||!H,className:T("p-2 rounded-full transition-all duration-200 flex items-center justify-center shrink-0 shadow-sm",C.trim()&&H?"bg-primary text-primary-foreground hover:bg-primary/95 transform hover:-translate-y-0.5":"bg-muted text-muted-foreground cursor-not-allowed opacity-50"),children:z(e,{className:"h-4 w-4"})})]})]})})]})]})}
|
|
2
|
-
export{uz as k};
|
package/bin/chunk-c3fvs0bv.js
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{Dk as G}from"./chunk-hz31j0hk.js";import{Xk as F}from"./chunk-ws07a9kv.js";var y=F(G(),1),H=new Set(['"',"\\","/","b","f","n","r","t","u"]);function K(b){let f=b.codePointAt(0);return f!==void 0&&f>=0&&f<=31}function Q(b){switch(b){case"\b":return"\\b";case"\f":return"\\f";case`
|
|
3
|
-
`:return"\\n";case"\r":return"\\r";case"\t":return"\\t";default:return`\\u${b.codePointAt(0)?.toString(16).padStart(4,"0")??"0000"}`}}function B(b){let f="",v=!1;for(let k=0;k<b.length;k++){let q=b[k];if(!v){if(f+=q,q==='"')v=!0;continue}if(q==='"'){f+=q,v=!1;continue}if(q==="\\"){let w=b[k+1];if(w===void 0){f+="\\\\";continue}if(w==="u"){let z=b.slice(k+2,k+6);if(/^[0-9a-fA-F]{4}$/.test(z)){f+=`\\u${z}`,k+=5;continue}}if(H.has(w)){f+=`\\${w}`,k+=1;continue}f+="\\\\";continue}f+=K(q)?Q(q):q}return f}function T(b){try{return JSON.parse(b)}catch(f){let v=B(b);if(v!==b)return JSON.parse(v);throw f}}function X(b){if(!b||b.trim()==="")return{};try{return T(b)}catch{try{return y.parse(b)??{}}catch{try{return y.parse(B(b))??{}}catch{return{}}}}}
|
|
4
|
-
export{T as Bk,X as Ck};
|
package/bin/chunk-c5my1b3k.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{pk as r,qk as p,rk as d,sk as i}from"./chunk-y9ttm07y.js";import{yk as n}from"./chunk-etqpzc9e.js";import{zk as b}from"./chunk-k20bhxed.js";import{Ck as I}from"./chunk-c3fvs0bv.js";import"./chunk-hz31j0hk.js";import{Ek as u}from"./chunk-90et6bwm.js";import{Qk as m,Sk as c}from"./chunk-5zntjzxw.js";import{Tk as h,Uk as k,Vk as g}from"./chunk-vf066xwh.js";import{Wk as w}from"./chunk-qvgc9e08.js";import"./chunk-ws07a9kv.js";function JJ(J){for(let X of J){if(X.role==="toolResult")return!0;if(X.role==="assistant"){if(X.content.some((Q)=>Q.type==="toolCall"))return!0}}return!1}function x(J){return J.type==="text"}function QJ(J){return J.type==="thinking"}function XJ(J){return J.type==="toolCall"}function YJ(J){return J.type==="image"}function a(J){if(J)return J;if(typeof process<"u"&&process.env.PI_CACHE_RETENTION==="long")return"long";return"short"}var _J=(J,X,Q)=>{let Y=new g;return(async()=>{let $={role:"assistant",content:[],api:J.api,provider:J.provider,model:J.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 N=Q?.apiKey;if(!N)throw Error(`No API key for provider: ${J.provider}`);let V=T(J),_=a(Q?.cacheRetention),q=_==="none"?void 0:Q?.sessionId,j=$J(J,X,N,Q?.headers,q,V),W=qJ(J,X,Q,V,_),H=await Q?.onPayload?.(W,J);if(H!==void 0)W=H;let K={...Q?.signal?{signal:Q.signal}:{},...Q?.timeoutMs!==void 0?{timeout:Q.timeoutMs}:{},maxRetries:Q?.maxRetries??0},{data:P,response:A}=await j.chat.completions.create(W,K).withResponse();await Q?.onResponse?.({status:A.status,headers:u(A.headers)},J),Y.push({type:"start",partial:$});let S=null,L=null,O=!1,M=new Map,f=new Map,U=$.content,v=(z)=>U.indexOf(z),s=(z)=>{let Z=v(z);if(Z===-1)return;if(z.type==="text")Y.push({type:"text_end",contentIndex:Z,content:z.text,partial:$});else if(z.type==="thinking")Y.push({type:"thinking_end",contentIndex:Z,content:z.thinking,partial:$});else if(z.type==="toolCall")z.arguments=I(z.partialArgs),delete z.partialArgs,delete z.streamIndex,Y.push({type:"toolcall_end",contentIndex:Z,toolCall:z,partial:$})},t=()=>{if(!S)S={type:"text",text:""},U.push(S),Y.push({type:"text_start",contentIndex:v(S),partial:$});return S},e=(z)=>{if(!L)L={type:"thinking",thinking:"",thinkingSignature:z},U.push(L),Y.push({type:"thinking_start",contentIndex:v(L),partial:$});return L},o=(z)=>{let Z=typeof z.index==="number"?z.index:void 0,G=Z!==void 0?M.get(Z):void 0;if(!G&&z.id)G=f.get(z.id);if(!G){if(G={type:"toolCall",id:z.id||"",name:z.function?.name||"",arguments:{},partialArgs:"",streamIndex:Z},Z!==void 0)M.set(Z,G);if(z.id)f.set(z.id,G);U.push(G),Y.push({type:"toolcall_start",contentIndex:v(G),partial:$})}if(Z!==void 0&&G.streamIndex===void 0)G.streamIndex=Z,M.set(Z,G);if(z.id)f.set(z.id,G);return G};for await(let z of P){if(!z||typeof z!=="object")continue;if($.responseId||=z.id,typeof z.model==="string"&&z.model.length>0&&z.model!==J.id)$.responseModel||=z.model;if(z.usage)$.usage=C(z.usage,J);let Z=Array.isArray(z.choices)?z.choices[0]:void 0;if(!Z)continue;if(!z.usage&&Z.usage)$.usage=C(Z.usage,J);if(Z.finish_reason){let G=DJ(Z.finish_reason);if($.stopReason=G.stopReason,G.errorMessage)$.errorMessage=G.errorMessage;O=!0}if(Z.delta){if(Z.delta.content!==null&&Z.delta.content!==void 0&&Z.delta.content.length>0){let E=t();E.text+=Z.delta.content,Y.push({type:"text_delta",contentIndex:v(E),delta:Z.delta.content,partial:$})}let G=["reasoning_content","reasoning","reasoning_text"],R=Z.delta,y=null;for(let E of G){let D=R[E];if(typeof D==="string"&&D.length>0){y=E;break}}if(y){let E=R[y];if(typeof E==="string"&&E.length>0){let D=J.provider==="opencode-go"&&y==="reasoning"?"reasoning_content":y,F=e(D);F.thinking+=E,Y.push({type:"thinking_delta",contentIndex:v(F),delta:E,partial:$})}}if(Z?.delta?.tool_calls)for(let E of Z.delta.tool_calls){let D=o(E);if(!D.id&&E.id)D.id=E.id,f.set(E.id,D);if(!D.name&&E.function?.name)D.name=E.function.name;let F="";if(E.function?.arguments)F=E.function.arguments,D.partialArgs=(D.partialArgs??"")+E.function.arguments,D.arguments=I(D.partialArgs);Y.push({type:"toolcall_delta",contentIndex:v(D),delta:F,partial:$})}let B=Z.delta.reasoning_details;if(B&&Array.isArray(B)){for(let E of B)if(E.type==="reasoning.encrypted"&&E.id&&E.data){let D=$.content.find((F)=>F.type==="toolCall"&&F.id===E.id);if(D)D.thoughtSignature=JSON.stringify(E)}}}}for(let z of U)s(z);if(Q?.signal?.aborted)throw Error("Request was aborted");if($.stopReason==="aborted")throw Error("Request was aborted");if($.stopReason==="error")throw Error($.errorMessage||"Provider returned an error stop reason");if(!O)throw Error("Stream ended without finish_reason");Y.push({type:"done",reason:$.stopReason,message:$}),Y.end()}catch(N){for(let _ of $.content)delete _.index,delete _.partialArgs,delete _.streamIndex;$.stopReason=Q?.signal?.aborted?"aborted":"error",$.errorMessage=N instanceof Error?N.message:JSON.stringify(N);let V=N?.error?.metadata?.raw;if(V)$.errorMessage+=`
|
|
3
|
-
${V}`;Y.push({type:"error",reason:$.stopReason,error:$}),Y.end()}})(),Y},MJ=(J,X,Q)=>{let Y=Q?.apiKey;if(!Y)throw Error(`No API key for provider: ${J.provider}`);let $=m(J,Q,Y),N=Q?.reasoning?k(J,Q.reasoning):void 0,V=N==="off"?void 0:N,_=Q?.toolChoice;return _J(J,X,{...$,reasoningEffort:V,toolChoice:_})};function $J(J,X,Q,Y,$,N=T(J)){let V={...J.headers};if(J.provider==="github-copilot"){let q=d(X.messages),j=i({messages:X.messages,hasImages:q});Object.assign(V,j)}if($&&N.sendSessionAffinityHeaders)V.session_id=$,V["x-client-request-id"]=$,V["x-session-affinity"]=$;if(Y)Object.assign(V,Y);let _=J.provider==="cloudflare-ai-gateway"?{...V,Authorization:V.Authorization??null,"cf-aig-authorization":`Bearer ${Q}`}:V;return new b({apiKey:Q,baseURL:r(J.provider)?p(J):J.baseUrl,dangerouslyAllowBrowser:!0,defaultHeaders:_})}function qJ(J,X,Q,Y=T(J),$=a(Q?.cacheRetention)){let N=WJ(J,X,Y),V=zJ(Y,$),_={model:J.id,messages:N,stream:!0,prompt_cache_key:J.baseUrl.includes("api.openai.com")&&$!=="none"||$==="long"&&Y.supportsLongCacheRetention?n(Q?.sessionId):void 0,prompt_cache_retention:$==="long"&&Y.supportsLongCacheRetention?"24h":void 0};if(Y.supportsUsageInStreaming!==!1)_.stream_options={include_usage:!0};if(Y.supportsStore)_.store=!1;if(Q?.maxTokens)if(Y.maxTokensField==="max_tokens")_.max_tokens=Q.maxTokens;else _.max_completion_tokens=Q.maxTokens;if(Q?.temperature!==void 0)_.temperature=Q.temperature;if(X.tools&&X.tools.length>0){if(_.tools=GJ(X.tools,Y),Y.zaiToolStream)_.tool_stream=!0}else if(JJ(X.messages))_.tools=[];if(V)LJ(N,_.tools,V);if(Q?.toolChoice)_.tool_choice=Q.toolChoice;if(Y.thinkingFormat==="zai"&&J.reasoning)_.enable_thinking=!!Q?.reasoningEffort;else if(Y.thinkingFormat==="qwen"&&J.reasoning)_.enable_thinking=!!Q?.reasoningEffort;else if(Y.thinkingFormat==="qwen-chat-template"&&J.reasoning)_.chat_template_kwargs={enable_thinking:!!Q?.reasoningEffort,preserve_thinking:!0};else if(Y.thinkingFormat==="deepseek"&&J.reasoning){if(_.thinking={type:Q?.reasoningEffort?"enabled":"disabled"},Q?.reasoningEffort&&Y.supportsReasoningEffort)_.reasoning_effort=J.thinkingLevelMap?.[Q.reasoningEffort]??Q.reasoningEffort}else if(Y.thinkingFormat==="openrouter"&&J.reasoning){let q=_;if(Q?.reasoningEffort)q.reasoning={effort:J.thinkingLevelMap?.[Q.reasoningEffort]??Q.reasoningEffort};else if(J.thinkingLevelMap?.off!==null)q.reasoning={effort:J.thinkingLevelMap?.off??"none"}}else if(Y.thinkingFormat==="together"&&J.reasoning){let q=_;if(q.reasoning={enabled:!!Q?.reasoningEffort},Q?.reasoningEffort&&Y.supportsReasoningEffort)q.reasoning_effort=J.thinkingLevelMap?.[Q.reasoningEffort]??Q.reasoningEffort}else if(Y.thinkingFormat==="string-thinking"&&J.reasoning){let q=_;if(Q?.reasoningEffort)q.thinking=J.thinkingLevelMap?.[Q.reasoningEffort]??Q.reasoningEffort;else if(J.thinkingLevelMap?.off!==null)q.thinking=J.thinkingLevelMap?.off??"none"}else if(Q?.reasoningEffort&&J.reasoning&&Y.supportsReasoningEffort)_.reasoning_effort=J.thinkingLevelMap?.[Q.reasoningEffort]??Q.reasoningEffort;else if(!Q?.reasoningEffort&&J.reasoning&&Y.supportsReasoningEffort){let q=J.thinkingLevelMap?.off;if(typeof q==="string")_.reasoning_effort=q}if(J.baseUrl.includes("openrouter.ai")&&J.compat?.openRouterRouting)_.provider=J.compat.openRouterRouting;if(J.baseUrl.includes("ai-gateway.vercel.sh")&&J.compat?.vercelGatewayRouting){let q=J.compat.vercelGatewayRouting;if(q.only||q.order){let j={};if(q.only)j.only=q.only;if(q.order)j.order=q.order;_.providerOptions={gateway:j}}}return _}function zJ(J,X){if(J.cacheControlFormat!=="anthropic"||X==="none")return;let Q=X==="long"&&J.supportsLongCacheRetention?"1h":void 0;return{type:"ephemeral",...Q?{ttl:Q}:{}}}function LJ(J,X,Q){NJ(J,Q),ZJ(X,Q),VJ(J,Q)}function NJ(J,X){for(let Q of J)if(Q.role==="system"||Q.role==="developer"){jJ(Q,X);return}}function VJ(J,X){for(let Q=J.length-1;Q>=0;Q--){let Y=J[Q];if(Y.role==="user"||Y.role==="assistant"){if(EJ(Y,X))return}}}function ZJ(J,X){if(!J||J.length===0)return;let Q=J[J.length-1];Q.cache_control=X}function jJ(J,X){return l(J,X)}function EJ(J,X){if(J.role==="user"||J.role==="assistant")return l(J,X);return!1}function l(J,X){let Q=J.content;if(typeof Q==="string"){if(Q.length===0)return!1;return J.content=[{type:"text",text:Q,cache_control:X}],!0}if(!Array.isArray(Q))return!1;for(let Y=Q.length-1;Y>=0;Y--){let $=Q[Y];if($?.type==="text"){let N=$;return N.cache_control=X,!0}}return!1}function WJ(J,X,Q){let Y=[],$=(_)=>{if(_.includes("|")){let[q]=_.split("|");return q.replace(/[^a-zA-Z0-9_-]/g,"_").slice(0,40)}if(J.provider==="openai")return _.length>40?_.slice(0,40):_;return _},N=c(X.messages,J,(_)=>$(_));if(X.systemPrompt){let q=J.reasoning&&Q.supportsDeveloperRole?"developer":"system";Y.push({role:q,content:w(X.systemPrompt)})}let V=null;for(let _=0;_<N.length;_++){let q=N[_];if(Q.requiresAssistantAfterToolResult&&V==="toolResult"&&q.role==="user")Y.push({role:"assistant",content:"I have processed the tool results."});if(q.role==="user")if(typeof q.content==="string")Y.push({role:"user",content:w(q.content)});else{let j=q.content.map((W)=>{if(W.type==="text")return{type:"text",text:w(W.text)};else return{type:"image_url",image_url:{url:`data:${W.mimeType};base64,${W.data}`}}});if(j.length===0)continue;Y.push({role:"user",content:j})}else if(q.role==="assistant"){let j={role:"assistant",content:Q.requiresAssistantAfterToolResult?"":null},W=q.content.filter(x).filter((L)=>L.text.trim().length>0).map((L)=>({type:"text",text:w(L.text)})),H=W.map((L)=>L.text).join(""),K=q.content.filter(QJ).filter((L)=>L.thinking.trim().length>0);if(K.length>0)if(Q.requiresThinkingAsText){let L=K.map((O)=>w(O.thinking)).join(`
|
|
4
|
-
|
|
5
|
-
`);j.content=[{type:"text",text:L},...W]}else{if(H.length>0)j.content=H;let L=K[0].thinkingSignature;if(J.provider==="opencode-go"&&L==="reasoning")L="reasoning_content";if(L&&L.length>0)j[L]=K.map((O)=>O.thinking).join(`
|
|
6
|
-
`)}else if(H.length>0)j.content=H;let P=q.content.filter(XJ);if(P.length>0){j.tool_calls=P.map((O)=>({id:O.id,type:"function",function:{name:O.name,arguments:JSON.stringify(O.arguments)}}));let L=P.filter((O)=>O.thoughtSignature).map((O)=>{try{return JSON.parse(O.thoughtSignature)}catch{return null}}).filter(Boolean);if(L.length>0)j.reasoning_details=L}if(Q.requiresReasoningContentOnAssistantMessages&&J.reasoning&&j.reasoning_content===void 0)j.reasoning_content="";let A=j.content;if(!(A!==null&&A!==void 0&&(typeof A==="string"?A.length>0:A.length>0))&&!j.tool_calls)continue;Y.push(j)}else if(q.role==="toolResult"){let j=[],W=_;for(;W<N.length&&N[W].role==="toolResult";W++){let H=N[W],K=H.content.filter(x).map((L)=>L.text).join(`
|
|
7
|
-
`),P=H.content.some((L)=>L.type==="image"),A=K.length>0,S={role:"tool",content:w(A?K:"(see attached image)"),tool_call_id:H.toolCallId};if(Q.requiresToolResultName&&H.toolName)S.name=H.toolName;if(Y.push(S),P&&J.input.includes("image")){for(let L of H.content)if(YJ(L))j.push({type:"image_url",image_url:{url:`data:${L.mimeType};base64,${L.data}`}})}}if(_=W-1,j.length>0){if(Q.requiresAssistantAfterToolResult)Y.push({role:"assistant",content:"I have processed the tool results."});Y.push({role:"user",content:[{type:"text",text:"Attached image(s) from tool result:"},...j]}),V="user"}else V="toolResult";continue}V=q.role}return Y}function GJ(J,X){return J.map((Q)=>({type:"function",function:{name:Q.name,description:Q.description,parameters:Q.parameters,...X.supportsStrictMode!==!1&&{strict:!1}}}))}function C(J,X){let Q=J.prompt_tokens||0,Y=J.prompt_tokens_details?.cached_tokens??J.prompt_cache_hit_tokens??0,$=J.prompt_tokens_details?.cache_write_tokens||0,N=Math.max(0,Q-Y-$),V=J.completion_tokens||0,_={input:N,output:V,cacheRead:Y,cacheWrite:$,totalTokens:N+V+Y+$,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}};return h(X,_),_}function DJ(J){if(J===null)return{stopReason:"stop"};switch(J){case"stop":case"end":return{stopReason:"stop"};case"length":return{stopReason:"length"};case"function_call":case"tool_calls":return{stopReason:"toolUse"};case"content_filter":return{stopReason:"error",errorMessage:"Provider finish_reason: content_filter"};case"network_error":return{stopReason:"error",errorMessage:"Provider finish_reason: network_error"};default:return{stopReason:"error",errorMessage:`Provider finish_reason: ${J}`}}}function HJ(J){let{provider:X,baseUrl:Q}=J,Y=X==="zai"||Q.includes("api.z.ai"),$=X==="together"||Q.includes("api.together.ai")||Q.includes("api.together.xyz"),N=X==="moonshotai"||X==="moonshotai-cn"||Q.includes("api.moonshot."),V=X==="cloudflare-workers-ai"||Q.includes("api.cloudflare.com"),_=X==="cloudflare-ai-gateway"||Q.includes("gateway.ai.cloudflare.com"),q=X==="cerebras"||Q.includes("cerebras.ai")||X==="xai"||Q.includes("api.x.ai")||$||Q.includes("chutes.ai")||Q.includes("deepseek.com")||Y||N||X==="opencode"||Q.includes("opencode.ai")||V||_,j=Q.includes("chutes.ai")||N||_||$,W=X==="xai"||Q.includes("api.x.ai"),H=X==="deepseek"||Q.includes("deepseek.com"),K=X==="openrouter"&&J.id.startsWith("anthropic/")?"anthropic":void 0;return{supportsStore:!q,supportsDeveloperRole:!q,supportsReasoningEffort:!W&&!Y&&!N&&!$&&!_,supportsUsageInStreaming:!0,maxTokensField:j?"max_tokens":"max_completion_tokens",requiresToolResultName:!1,requiresAssistantAfterToolResult:!1,requiresThinkingAsText:!1,requiresReasoningContentOnAssistantMessages:H,thinkingFormat:H?"deepseek":Y?"zai":$?"together":X==="openrouter"||Q.includes("openrouter.ai")?"openrouter":"openai",openRouterRouting:{},vercelGatewayRouting:{},zaiToolStream:!1,supportsStrictMode:!N&&!$&&!_,cacheControlFormat:K,sendSessionAffinityHeaders:!1,supportsLongCacheRetention:!($||V||_)}}function T(J){let X=HJ(J);if(!J.compat)return X;return{supportsStore:J.compat.supportsStore??X.supportsStore,supportsDeveloperRole:J.compat.supportsDeveloperRole??X.supportsDeveloperRole,supportsReasoningEffort:J.compat.supportsReasoningEffort??X.supportsReasoningEffort,supportsUsageInStreaming:J.compat.supportsUsageInStreaming??X.supportsUsageInStreaming,maxTokensField:J.compat.maxTokensField??X.maxTokensField,requiresToolResultName:J.compat.requiresToolResultName??X.requiresToolResultName,requiresAssistantAfterToolResult:J.compat.requiresAssistantAfterToolResult??X.requiresAssistantAfterToolResult,requiresThinkingAsText:J.compat.requiresThinkingAsText??X.requiresThinkingAsText,requiresReasoningContentOnAssistantMessages:J.compat.requiresReasoningContentOnAssistantMessages??X.requiresReasoningContentOnAssistantMessages,thinkingFormat:J.compat.thinkingFormat??X.thinkingFormat,openRouterRouting:J.compat.openRouterRouting??{},vercelGatewayRouting:J.compat.vercelGatewayRouting??X.vercelGatewayRouting,zaiToolStream:J.compat.zaiToolStream??X.zaiToolStream,supportsStrictMode:J.compat.supportsStrictMode??X.supportsStrictMode,cacheControlFormat:J.compat.cacheControlFormat??X.cacheControlFormat,sendSessionAffinityHeaders:J.compat.sendSessionAffinityHeaders??X.sendSessionAffinityHeaders,supportsLongCacheRetention:J.compat.supportsLongCacheRetention??X.supportsLongCacheRetention}}export{MJ as streamSimpleOpenAICompletions,_J as streamOpenAICompletions,WJ as convertMessages};
|
package/bin/chunk-dhekxndw.js
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
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 xk};
|
package/bin/chunk-dwaj1yn4.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{Wb as g,Xb as T,Yb as R}from"./chunk-nt9tfjx6.js";import"./chunk-vy24ncn2.js";import{_b as V}from"./chunk-wr5byz6r.js";import{$b as Y}from"./chunk-ss45w8ks.js";import{gc as k,hc as M}from"./chunk-w3a50kz8.js";import{jc as f}from"./chunk-6a2eb3b5.js";import"./chunk-amsb41z5.js";import{nc as L}from"./chunk-gn8snrnk.js";import"./chunk-w9w5301f.js";import{cf as D}from"./chunk-k9w6mk9d.js";import{df as Z}from"./chunk-wny0qagx.js";import{Ak as H}from"./chunk-k20bhxed.js";import"./chunk-hz31j0hk.js";import"./chunk-ws07a9kv.js";var h="v1",z=new Set(["openai","openai-codex","opencode","azure-openai-responses"]),E=16;function I(w){let J=new Map;if(!w)return J;for(let j of w.split(",")){let Q=j.trim();if(!Q)continue;let[W,G]=Q.split("=",2);if(!W||!G)continue;J.set(W.trim(),G.trim())}return J}function K(w,J){if(J?.azureDeploymentName)return J.azureDeploymentName;return I(Y("AZURE_OPENAI_DEPLOYMENT_NAME_MAP",J?.env)).get(w.id)||w.id}function B(w){return M(k(w),"Azure OpenAI API error")}var O=(w,J,j)=>{let Q=new Z;return(async()=>{let W=K(w,j),G={role:"assistant",content:[],api:"azure-openai-responses",provider:w.provider,model:w.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: ${w.provider}`);let $=y(w,X,j),q=v(w,J,j,W),C=await j?.onPayload?.(q,w);if(C!==void 0)q=C;let S={...j?.signal?{signal:j.signal}:{},...j?.timeoutMs!==void 0?{timeout:j.timeoutMs}:{},maxRetries:j?.maxRetries??0},{data:_,response:F}=await $.responses.create(q,S).withResponse();if(await j?.onResponse?.({status:F.status,headers:L(F.headers)},w),Q.push({type:"start",partial:G}),await R(_,G,Q,w),j?.signal?.aborted)throw Error("Request was aborted");if(G.stopReason==="aborted"||G.stopReason==="error")throw Error("An unknown error occurred");Q.push({type:"done",reason:G.stopReason,message:G}),Q.end()}catch(X){for(let $ of G.content)delete $.index,delete $.partialJson;G.stopReason=j?.signal?.aborted?"aborted":"error",G.errorMessage=B(X),Q.push({type:"error",reason:G.stopReason,error:G}),Q.end()}})(),Q},m=(w,J,j)=>{let Q=j?.apiKey;if(!Q)throw Error(`No API key for provider: ${w.provider}`);let W=f(w,J,j,Q),G=j?.reasoning?D(w,j.reasoning):void 0;return O(w,J,{...W,reasoningEffort:G==="off"?void 0:G})};function A(w){let J=w.trim().replace(/\/+$/,""),j;try{j=new URL(J)}catch{throw Error(`Invalid Azure OpenAI base URL: ${w}`)}let Q=j.hostname.endsWith(".openai.azure.com")||j.hostname.endsWith(".cognitiveservices.azure.com")||j.hostname.endsWith(".ai.azure.com"),W=j.pathname.replace(/\/+$/,"");if(Q&&(W===""||W==="/"||W==="/openai"||W==="/openai/v1/responses"))j.pathname="/openai/v1",j.search="";return j.toString().replace(/\/+$/,"")}function b(w){return`https://${w}.openai.azure.com/openai/v1`}function P(w,J){let j=J?.azureApiVersion||Y("AZURE_OPENAI_API_VERSION",J?.env)||h,Q=J?.azureBaseUrl?.trim()||Y("AZURE_OPENAI_BASE_URL",J?.env)?.trim()||void 0,W=J?.azureResourceName||Y("AZURE_OPENAI_RESOURCE_NAME",J?.env),G=Q;if(!G&&W)G=b(W);if(!G&&w.baseUrl)G=w.baseUrl;if(!G)throw Error("Azure OpenAI base URL is required. Set AZURE_OPENAI_BASE_URL or AZURE_OPENAI_RESOURCE_NAME, or pass azureBaseUrl, azureResourceName, or model.baseUrl.");return{baseUrl:A(G),apiVersion:j}}function y(w,J,j){let Q={...w.headers};if(j?.headers)Object.assign(Q,j.headers);let{baseUrl:W,apiVersion:G}=P(w,j);return new H({apiKey:J,apiVersion:G,dangerouslyAllowBrowser:!0,defaultHeaders:Q,baseURL:W})}function v(w,J,j,Q){let W=g(w,J,z),G={model:Q,input:W,stream:!0,prompt_cache_key:V(j?.sessionId),store:!1};if(j?.maxTokens)G.max_output_tokens=Math.max(j.maxTokens,E);if(j?.temperature!==void 0)G.temperature=j?.temperature;if(J.tools&&J.tools.length>0)G.tools=T(J.tools);if(w.reasoning){if(j?.reasoningEffort||j?.reasoningSummary){let X=j?.reasoningEffort?w.thinkingLevelMap?.[j.reasoningEffort]??j.reasoningEffort:"medium";G.reasoning={effort:X,summary:j?.reasoningSummary||"auto"},G.include=["reasoning.encrypted_content"]}else if(w.thinkingLevelMap?.off!==null)G.reasoning={effort:w.thinkingLevelMap?.off??"none"}}return G}export{m as streamSimple,O as stream};
|
package/bin/chunk-er1rb6yj.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Za as lz}from"./chunk-wrz9e73c.js";import"./chunk-1nh6xgek.js";import{$a as a}from"./chunk-3rcc5s99.js";import{ab as yz,bb as Dz,cb as bz,db as Cz,eb as fz,fb as Iz,gb as gz,hb as uz}from"./chunk-20y3wte3.js";import{tg as c}from"./chunk-mahxw48e.js";import{Qg as hz}from"./chunk-wap08p4j.js";import{Rg as b,Tg as C,Ug as f,Vg as M,ch as wz,dh as n}from"./chunk-nr89225z.js";import{Ah as Pz,Aj as Gz,Hj as Lz,Kh as Yz,Mh as X,Nh as Jz,Oh as Uz,Vh as Bz,Wh as zz,Yh as Wz,Zh as $z,ak as _z,ck as E,dk as Sz,ek as Mz,fk as vz,gh as Xz,hh as N,ih as z,ii as Tz,ik as V,jh as J,jj as Zz,jk as Rz,kh as x,kk as Kz,lk as kz,mk as qz,nh as Vz,nk as Az,oh as Oz,ok as Ez,ph as k,pi as i,vh as m}from"./chunk-b1e3tec3.js";import{Xk as Qz}from"./chunk-ws07a9kv.js";var K=Qz(Xz(),1);function Fz({open:Z,onOpenChange:$,mode:T,teamId:F,project:W}){let q=x(),R=m(),[H,O]=K.useState(""),[v,B]=K.useState(!0),[I,P]=K.useState(void 0),[h,U]=K.useState(void 0),[A,w]=K.useState(!1),S=K.useRef(null);K.useEffect(()=>{if(Z)if(T==="edit"&&W)O(W.name||""),P(W.coverImageKey),U(W.coverImage),B(W.enableNotification!==!1);else O(""),P(void 0),U(void 0),B(!0)},[Z,T,W]);let g=X.api.teams[":teamId"].projects.$post,{mutate:j}=k({mutationFn:async(Q)=>{let _=await g({param:{teamId:F},json:Q});if(!_.ok)throw Error(V.failed_create_project());return await _.json()},onSuccess:(Q)=>{q.invalidateQueries({queryKey:["teams",F,"projects"]}),$(!1);let _=Q;if(_&&typeof _.id==="string")R({to:"/projects/$projectId",params:{projectId:_.id}})}}),u=X.api.projects[":projectId"].$put,{mutate:y}=k({mutationFn:async(Q)=>{let _=await u({param:{projectId:W.id},json:Q});if(!_.ok)throw Error(V.failed_update_project());return await _.json()},onSuccess:()=>{q.invalidateQueries({queryKey:["teams",F,"projects"]}),$(!1)}}),r=X.api.teams[":teamId"].files.$post,{mutate:D}=k({mutationFn:async({file:Q})=>{let _=await r({param:{teamId:F},form:{file:Q}});if(!_.ok)throw Error(V.failed_upload_file());return await _.json()},onSuccess:(Q)=>{let _=Q;if(_&&typeof _.key==="string")P(_.key);w(!1)},onError:()=>{w(!1)}}),o=(Q)=>{let _=Q.target.files?.[0];if(_){w(!0);let e=URL.createObjectURL(_);U(e),D({file:_})}},t=()=>{S.current?.click()},s=(Q)=>{Q.stopPropagation(),P(void 0),U(void 0)},l=()=>{if(!H.trim())return;if(T==="create")j({name:H.trim(),coverImageKey:I,enableNotification:v});else if(T==="edit"&&W?.id)y({name:H.trim(),coverImageKey:I,enableNotification:v})};return z(Rz,{open:Z,onOpenChange:$,children:J(Kz,{className:"sm:max-w-[550px] overflow-hidden rounded-2xl border border-border/60 bg-background/95 backdrop-blur-md shadow-2xl p-0 gap-0",children:[J(kz,{className:"relative overflow-hidden bg-gradient-to-br from-primary/5 to-transparent p-6 border-b border-border/40",children:[z("div",{className:"absolute top-0 right-0 w-24 h-24 bg-primary/10 rounded-full blur-2xl pointer-events-none"}),z("div",{className:"absolute bottom-0 left-10 w-32 h-12 bg-primary/5 rounded-full blur-xl pointer-events-none"}),z("div",{className:"flex items-center gap-3",children:J("div",{children:[z(Az,{className:"text-xl font-semibold tracking-tight text-foreground",children:T==="create"?V.create_new_project():V.project_settings()}),z(Ez,{className:"text-xs text-muted-foreground/80 mt-1",children:T==="create"?V.configure_new_project_description():V.manage_project_description()})]})})]}),J("div",{className:"space-y-6 p-6 max-h-[75vh] overflow-y-auto",children:[J("div",{className:"space-y-2",children:[z(c,{htmlFor:"name",className:"text-sm font-semibold tracking-tight text-foreground",children:V.project_name()}),J("div",{className:"relative",children:[z(n,{id:"name",value:H,onChange:(Q)=>O(Q.target.value),placeholder:V.project_name_placeholder(),className:"h-11 px-4 rounded-xl border-border/80 focus-visible:ring-ring/25 focus-visible:border-primary transition-all shadow-xs pr-10"}),H.trim()&&z("div",{className:"absolute inset-y-0 right-3 flex items-center",children:z(i,{className:"w-4 h-4 text-primary"})})]}),z("p",{className:"text-[11px] text-muted-foreground",children:V.project_name_hint()})]}),J("div",{className:"space-y-3 border-t border-border/40 pt-5",children:[J("div",{className:"flex items-center justify-between",children:[J(c,{className:"text-sm font-semibold tracking-tight text-foreground flex items-center gap-1.5",children:[z($z,{className:"w-4 h-4 text-primary"}),V.project_cover()]}),h&&J("button",{type:"button",onClick:s,className:"text-xs text-muted-foreground hover:text-destructive hover:bg-destructive/5 px-2.5 py-1 rounded-lg transition-all flex items-center gap-1 font-medium",children:[z(Lz,{className:"w-3.5 h-3.5"}),V.remove_cover()]})]}),J("div",{className:"relative aspect-square w-48 mx-auto rounded-2xl border border-dashed border-border flex items-center justify-center cursor-pointer overflow-hidden group shadow-inner bg-muted/20 transition-all duration-300 hover:border-primary/50 hover:bg-muted/40",onClick:t,children:[z("input",{type:"file",ref:S,className:"hidden",accept:"image/*",onChange:o}),A&&z("div",{className:"absolute inset-0 bg-background/70 backdrop-blur-xs flex flex-col items-center justify-center gap-2 z-20",children:J("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-background border rounded-full shadow-lg",children:[z(zz,{className:"w-4 h-4 animate-spin text-primary"}),z("span",{className:"text-xs font-semibold text-foreground",children:V.uploading()})]})}),h?J(N,{children:[z("img",{src:h,alt:V.cover_preview(),className:"w-full h-full object-cover transition-transform duration-500 group-hover:scale-105"}),J("div",{className:"absolute inset-0 bg-black/45 opacity-0 group-hover:opacity-100 transition-opacity duration-300 flex flex-col items-center justify-center gap-1.5 text-white z-10",children:[z(Gz,{className:"w-5 h-5 transform translate-y-1 group-hover:translate-y-0 transition-transform duration-300"}),z("span",{className:"text-xs font-semibold",children:V.upload_image()})]})]}):J("div",{className:"flex flex-col items-center gap-2 text-center p-4",children:[z("div",{className:"p-2.5 rounded-full bg-background border shadow-xs group-hover:scale-110 transition-transform duration-300",children:z(Gz,{className:"w-4 h-4 text-muted-foreground"})}),J("div",{children:[z("p",{className:"text-xs font-medium text-foreground",children:V.upload_cover()}),z("p",{className:"text-[11px] text-muted-foreground mt-0.5 max-w-[140px] mx-auto leading-normal",children:V.upload_cover_hint()})]})]})]})]}),J("div",{className:"space-y-3 border-t border-border/40 pt-5",children:[J(c,{className:"text-sm font-semibold tracking-tight text-foreground flex items-center gap-1.5",children:[z(Wz,{className:"w-4 h-4 text-primary"}),V.project_preferences()]}),J("div",{className:"flex items-start justify-between rounded-xl border border-border/50 bg-muted/10 p-4 transition-all duration-300 hover:bg-muted/20",children:[J("div",{className:"space-y-1 pr-4",children:[J("div",{className:"text-sm font-semibold flex items-center gap-2 text-foreground",children:[z(Tz,{className:"w-4 h-4 text-primary"}),V.activity_notifications()]}),z("p",{className:"text-xs text-muted-foreground leading-normal",children:V.activity_notifications_description()})]}),z(a,{checked:v,onCheckedChange:B,disabled:A,className:"mt-0.5"})]})]})]}),J(qz,{className:"flex items-center justify-end gap-3 px-6 py-4 bg-muted/20 border-t border-border/40",children:[z(E,{type:"button",variant:"ghost",onClick:()=>$(!1),disabled:A,className:"rounded-xl h-10 px-4 hover:bg-muted font-medium text-sm text-muted-foreground hover:text-foreground transition-colors",children:V.cancel()}),z(E,{type:"submit",onClick:l,disabled:!H.trim()||A,className:"rounded-xl h-10 px-5 bg-primary text-primary-foreground hover:bg-primary/90 font-semibold text-sm shadow-lg shadow-primary/10 hover:shadow-primary/20 active:scale-98 transition-all flex items-center gap-2",children:A?J(N,{children:[z(zz,{className:"w-4 h-4 animate-spin"}),V.processing()]}):T==="create"?V.create_project():V.save_changes()})]})]})})}function Nz({sortBy:Z,sortDirection:$,onSortChange:T}){let F=(H)=>{T(H,$)},W=()=>{T(Z,$==="asc"?"desc":"asc")},q=(H)=>{switch(H){case"name":return V.sort_name();case"created_at":return V.sort_created();case"updated_at":return V.sort_updated();default:return H}},R=$==="asc";return J(b,{children:[z(C,{asChild:!0,children:J(E,{variant:"outline",className:"gap-2 bg-muted/50",children:[z("span",{className:"text-muted-foreground",children:V.sorted_by_label()}),z("span",{className:"font-medium text-foreground",children:q(Z)})]})}),J(f,{align:"end",className:"w-56 p-2",children:[z("div",{className:"text-xs font-semibold text-muted-foreground mb-2 px-2",children:V.sort_by()}),J(b,{children:[z(C,{asChild:!0,children:J(E,{variant:"ghost",className:"w-full justify-between font-normal px-2 h-10 bg-muted/50 hover:bg-muted mb-2 border",children:[z("span",{children:q(Z)}),z(Jz,{className:"h-4 w-4 opacity-50"})]})}),z(f,{className:"w-52",children:["name","created_at","updated_at"].map((H)=>J(M,{onClick:()=>F(H),className:"justify-between",children:[q(H),Z===H&&z(i,{className:"h-4 w-4"})]},H))})]}),J(E,{variant:"ghost",className:"w-full justify-between font-normal px-2 h-10 bg-muted/50 hover:bg-muted border",onClick:W,children:[z("span",{className:"text-muted-foreground",children:Z==="name"?R?z(N,{children:V.sort_a_to_z()}):z(N,{children:V.sort_z_to_a()}):R?z(N,{children:V.sort_oldest_to_newest()}):z(N,{children:V.sort_newest_to_oldest()})}),R?z(Uz,{className:"h-4 w-4 opacity-50"}):z(Jz,{className:"h-4 w-4 opacity-50"})]})]})]})}var L=Qz(Xz(),1);function tz(){let{teamId:Z}=sz.useParams(),{canEdit:$,canAdmin:T}=wz(),F=m(),W=x(),[q,R]=L.useState(null),[H,O]=L.useState(!1),[v,B]=L.useState("create"),[I,P]=L.useState(void 0),[h,U]=L.useState(!1),[A,w]=L.useState(void 0),[S,g]=L.useState(""),[j,u]=L.useState(!1),[y,r]=L.useState("name"),[D,o]=L.useState("asc"),t=X.api.teams[":teamId"].projects.$get,{data:s}=Oz({queryKey:["teams",Z,"projects",y,D],queryFn:async()=>{let G=await t({param:{teamId:Z},query:{sortBy:y,sortDirection:D}});if(!G.ok)throw Error("Failed to fetch projects");return await G.json()}}),{data:l}=Vz({queryKey:["teams",Z,"members"],queryFn:async()=>{let G=await X.api.teams[":teamId"].members.$get({param:{teamId:Z},query:{}});if(!G.ok)throw Error("Failed to fetch members");return await G.json()}}),{data:Q}=Vz({queryKey:["teams",Z,"me"],queryFn:async()=>{let G=await X.api.teams[":teamId"].me.$get({param:{teamId:Z}});if(!G.ok)throw Error("Failed to fetch me");return await G.json()}}),_=X.api.teams[":teamId"].invite.$post,e=k({mutationFn:async(G)=>{let Y=await _(G);if(!Y.ok)throw Error("Failed to invite");return await Y.json()}}),d=k({mutationFn:async(G)=>{if(!(await X.api.projects[":projectId"].$delete({param:{projectId:G}})).ok)throw Error("Failed to delete project")},onSuccess:()=>{W.invalidateQueries({queryKey:["teams",Z,"projects"]})}}),dz=k({mutationFn:async(G)=>{let Y=await X.api.projects[":projectId"].$put({param:{projectId:G.id},json:{enableNotification:!G.enableNotification}});if(!Y.ok)throw Error("Failed to update project notification settings");return await Y.json()},onSuccess:()=>{W.invalidateQueries({queryKey:["teams",Z,"projects"]}),Yz.success(V.project_notification_updated())},onError:(G)=>{Yz.error(G instanceof Error?G.message:V.failed_update_project_notification())}}),Hz=()=>{B("create"),P(void 0),O(!0)},pz=()=>{R("create"),setTimeout(()=>{R(null)},100),setTimeout(()=>{Hz()},200)},cz=(G)=>{B("edit"),P(G),O(!0)},xz=(G)=>{w(G),g(""),U(!0)},mz=async()=>{if(A&&S==="delete")try{await d.mutateAsync(A.id),U(!1)}catch(G){console.error(G)}},iz=(G,Y)=>{if(Y.detail>1)return;R(G),setTimeout(()=>{R(null)},100),setTimeout(()=>{F({to:"/projects/$projectId",params:{projectId:G}})},200)},nz=async(G)=>{return(await e.mutateAsync({param:{teamId:Z},json:{role:G}})).code},az=k({mutationFn:async({userId:G,role:Y})=>{if(!(await X.api.teams[":teamId"].members[":userId"].$patch({param:{teamId:Z,userId:G},json:{role:Y}})).ok)throw Error("Failed to update member role")},onSuccess:()=>{W.invalidateQueries({queryKey:["teams",Z,"members"]})}}),jz=k({mutationFn:async(G)=>{if(!(await X.api.teams[":teamId"].members[":userId"].$delete({param:{teamId:Z,userId:G}})).ok)throw Error("Failed to remove member")},onSuccess:()=>{W.invalidateQueries({queryKey:["teams",Z,"members"]})}}),rz=(G)=>{if(!G)return"??";return G.split(" ").map((Y)=>Y[0]).slice(0,2).join("").toUpperCase()},oz=(G,Y)=>{r(G),o(Y)},p=Array.isArray(l)?l:[];return J("div",{className:"flex-1 overflow-y-auto p-4",children:[J("div",{className:"flex flex-wrap items-center justify-between mb-4 gap-4",children:[z("h1",{className:"text-2xl font-bold",children:V.projects()}),J("div",{className:"flex flex-wrap items-center gap-4",children:[J("div",{className:"flex items-center -space-x-2 cursor-pointer hover:opacity-90",onClick:()=>u(!0),children:[p.slice(0,3).map((G)=>J(Sz,{className:"border-2 border-background w-8 h-8",children:[G.image&&z(Mz,{src:G.image,alt:G.name,className:"object-cover"}),z(vz,{className:"text-[10px]",children:rz(G.name)})]},G.id)),p.length>3&&J("div",{className:"flex items-center justify-center w-8 h-8 rounded-full border-2 border-background bg-muted text-[10px] font-medium",children:["+",p.length-3]})]}),z(Nz,{sortBy:y,sortDirection:D,onSortChange:oz}),$&&J(E,{className:"bg-orange-600 hover:bg-orange-700 text-white gap-2",onClick:Hz,children:[z(Zz,{className:"w-4 h-4"}),V.create_project()]})]})]}),J("div",{className:"grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-6 gap-4",children:[s.data?.map((G)=>z("div",{className:_z("shadow-md relative border rounded-xl overflow-hidden cursor-pointer transition-transform duration-100 ease-in-out",q===G.id?"scale-95":"scale-100"),onClick:(Y)=>iz(G.id,Y),children:J("div",{className:"flex flex-col",children:[J("div",{className:"relative w-full h-full aspect-square flex items-center justify-center bg-zinc-400/20",children:[G.coverImage?z("img",{src:G.coverImage,alt:G.name,className:"w-full h-full object-cover rounded"}):J("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 180.95 164.7",preserveAspectRatio:"xMidYMid slice",className:"w-full h-full object-cover rounded",children:[z("polygon",{fill:"#FC9F8E",points:"0 18.5 0 76.0 151.69 164.7 180.95 164.7 180.95 113.6"}),z("polygon",{fill:"#FEBAB8",points:"0 0 74.58 61.5 90.53 51.6 110.33 63.9 180.95 18.9 180.95 0"}),z("polyline",{fill:"#FAA5A5",points:"0 18.5 74.58 61.5 90.53 51.6 110.33 63.9 180.95 18.9 180.95 0 0 0"}),z("polygon",{fill:"#EC5B6C",points:"0 76.0 0 164.7 151.69 164.7"}),z("polygon",{fill:"#E85C71",points:"180.95 18.9 110.33 63.9 117.37 68.0 117.26 73.4 180.95 113.6"}),z("polygon",{fill:"#C8405B",points:"117.26 73.4 117.37 99.0 90.53 114.9 174.35 164.7 180.95 164.7 180.95 113.6"}),z("polygon",{fill:"#FFCCBE",points:"90.53 51.6 63.69 68.1 90.53 83.4"}),z("path",{fill:"#FB9991",d:"M 90.53 51.6 L 90.53 61.3 L 100.87 67.4 L 90.53 73.5 L 90.53 83.4 L 117.37 68.0 C 117.15 67.6 90.53 51.6 90.53 51.6 Z"}),z("path",{fill:"#FFEACD",d:"M 63.69 68.1 C 63.47 68.5 64.02 99.3 64.02 99.3 C 64.02 99.3 64.46 99.6 64.9 99.9 L 90.53 83.4 L 63.69 68.1 Z"}),z("polygon",{fill:"#FFCFB5",points:"64.02 99.3 90.53 114.9 90.53 83.4"}),z("path",{fill:"#F67D73",d:"M 90.53 83.4 L 90.53 114.9 L 117.37 99.0 Z"}),z("path",{fill:"#F26560",d:"M 90.53 83.4 L 117.37 99.0 L 117.37 68.0 Z"}),z("polygon",{fill:"#EB5F5B",points:"80.08 67.5 90.53 73.5 90.53 61.3"}),z("polygon",{fill:"#DB4D50",points:"90.53 61.3 90.53 73.5 100.87 67.4"})]}),z("div",{className:"absolute bottom-0 left-0 w-full h-[65%] bg-linear-to-t from-black/35 to-black/0"}),z("p",{className:"absolute left-1 bottom-2 text-white",children:G.name})]}),J("div",{className:"px-2 h-10 flex justify-between items-center",children:[J("p",{className:"truncate pr-1 text-xs text-muted-foreground",children:[V.updated_ago()," ",hz(G.updatedAt??"")]}),z("div",{onClick:(Y)=>Y.stopPropagation(),children:J(b,{modal:!1,children:[z(C,{asChild:!0,children:z("button",{className:"hover:bg-muted outline-none flex px-1",children:z(Bz,{className:"w-5 h-5 text-muted-foreground"})})}),J(f,{align:"end",children:[$&&z(M,{onClick:(Y)=>{Y.stopPropagation(),cz(G)},children:V.project_settings()}),J(M,{className:"flex items-center justify-between gap-4 cursor-pointer",onSelect:(Y)=>{Y.preventDefault(),dz.mutate(G)},children:[z("span",{children:V.notification()}),z(a,{checked:G.enableNotification??!0,className:"pointer-events-none"})]}),T&&z(M,{className:"text-destructive focus:text-destructive",onClick:()=>xz(G),children:V.delete()})]})]})})]})]})},G.id)),$&&z("div",{className:_z("shadow-md relative border rounded-xl overflow-hidden cursor-pointer transition-transform duration-100 ease-in-out border-dashed hover:border-orange-600/50 group",q==="create"?"scale-95":"scale-100"),onClick:pz,children:J("div",{className:"flex flex-col",children:[z("div",{className:"relative w-full aspect-square flex items-center justify-center bg-zinc-400/5 group-hover:bg-orange-600/5 transition-colors",children:z(Zz,{className:"w-8 h-8 text-zinc-400 group-hover:text-orange-600 transition-colors"})}),z("div",{className:"px-2 h-10 flex items-center justify-center bg-zinc-400/10 border-t group-hover:bg-orange-600/10 transition-colors",children:z("p",{className:"text-sm text-muted-foreground group-hover:text-orange-600 transition-colors",children:V.create_project()})})]})})]}),z(Fz,{open:H,onOpenChange:O,mode:v,teamId:Z,project:I}),z(yz,{open:h,onOpenChange:U,children:J(Dz,{children:[J(bz,{children:[z(fz,{children:V.are_you_sure()}),J(Iz,{children:[V.delete_project_warning({name:A?.name??""}),J("div",{className:"mt-4 flex flex-col gap-2 text-foreground",children:[z("span",{className:"text-sm font-medium",children:V.type_delete_to_confirm()}),z(n,{value:S,onChange:(G)=>g(G.target.value),placeholder:V.delete_placeholder(),className:"h-9",autoFocus:!0})]})]})]}),J(Cz,{children:[z(uz,{disabled:d.isPending,children:V.cancel()}),z(gz,{onClick:(G)=>{G.preventDefault(),mz()},disabled:S!=="delete"||d.isPending,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:d.isPending?V.deleting():V.delete()})]})]})}),z(lz,{open:j,onOpenChange:u,title:V.team_members(),type:"team",members:p,isOwner:Q?.role==="owner",onInvite:nz,onUpdateRole:async(G,Y)=>{await az.mutateAsync({userId:G,role:Y})},onRemoveMember:async(G)=>{await jz.mutateAsync(G)},currentUserId:Q?.id})]})}var sz=Pz("/teams/$teamId/")({component:tz});export{sz as Route};
|
package/bin/chunk-etqpzc9e.js
DELETED