@shumai-one/shumai 0.1.8 → 0.1.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (145) hide show
  1. package/bin/chunk-06zbzvw5.js +1 -0
  2. package/bin/{chunk-8e4d80kp.js → chunk-08m8mzfa.js} +1 -1
  3. package/bin/chunk-0a32czvc.js +1 -0
  4. package/bin/{chunk-qggykya7.js → chunk-0at8vxt5.js} +1 -1
  5. package/bin/{chunk-4g68cqhk.js → chunk-0zv7f9ca.js} +1 -1
  6. package/bin/{chunk-map94w8n.js → chunk-11jh64vm.js} +2 -2
  7. package/bin/{chunk-30jjvb4k.js → chunk-1fpqq6ed.js} +2 -2
  8. package/bin/{chunk-8swcdgg3.js → chunk-1wq9hjjr.js} +1 -1
  9. package/bin/{chunk-6ftb22yh.js → chunk-22dje1f5.js} +1 -1
  10. package/bin/{chunk-8g69rftv.js → chunk-29ectt6g.js} +2 -2
  11. package/bin/{chunk-7qm716wz.js → chunk-2k4vp654.js} +1 -1
  12. package/bin/{chunk-v159ppmt.js → chunk-2tbya52d.js} +1 -1
  13. package/bin/{chunk-kc7vcfch.js → chunk-2vs3evc7.js} +2 -2
  14. package/bin/{chunk-wp51h5mn.js → chunk-33169en9.js} +1 -1
  15. package/bin/{chunk-1saz0r74.js → chunk-34sj5czd.js} +2 -2
  16. package/bin/{chunk-eqjxqzxw.js → chunk-3n1k9qt5.js} +1 -1
  17. package/bin/{chunk-redk7r63.js → chunk-3qdn3pty.js} +1 -1
  18. package/bin/{chunk-7yh2nbmq.js → chunk-3rajscaz.js} +1 -1
  19. package/bin/{chunk-vfn5aygx.js → chunk-3rt9mnj3.js} +1 -1
  20. package/bin/{chunk-fseg9mh8.js → chunk-3x62t1m0.js} +1 -1
  21. package/bin/chunk-4w8yjya6.js +2 -0
  22. package/bin/chunk-52gbhy6p.js +1 -0
  23. package/bin/{chunk-ww62rpxv.js → chunk-5a2maxwp.js} +2 -2
  24. package/bin/{chunk-yz7fdcqe.js → chunk-5an9f2kg.js} +2 -2
  25. package/bin/{chunk-wdg3m7ck.js → chunk-5erm1x1z.js} +60 -60
  26. package/bin/chunk-5rhkwshw.js +2 -0
  27. package/bin/{chunk-wndb0rc7.js → chunk-5w4gh748.js} +2 -2
  28. package/bin/{chunk-9z155z22.js → chunk-5yrxmw1f.js} +2 -2
  29. package/bin/{chunk-kv62xcad.js → chunk-61kvwa0f.js} +2 -2
  30. package/bin/chunk-6bzscrnw.js +2 -0
  31. package/bin/chunk-6yk235qv.js +1 -0
  32. package/bin/{chunk-c8t4yzjs.js → chunk-7aj7b7cc.js} +2 -2
  33. package/bin/{chunk-0hp6t0q3.js → chunk-7ddaxdpf.js} +1 -1
  34. package/bin/chunk-7etmd1tw.js +1 -0
  35. package/bin/{chunk-5mvvjqcp.js → chunk-7rhjej0x.js} +1 -1
  36. package/bin/chunk-7tkpx9n9.js +2 -0
  37. package/bin/{chunk-h6qkpxtj.js → chunk-7wvgtw25.js} +1 -1
  38. package/bin/{chunk-ypada0jh.js → chunk-7yvr7g7e.js} +2 -2
  39. package/bin/chunk-8k8c7a74.js +1 -0
  40. package/bin/{chunk-cmv4axyg.js → chunk-8xvtksy3.js} +2 -2
  41. package/bin/{chunk-5wppe329.js → chunk-94h8644q.js} +1 -1
  42. package/bin/{chunk-b6ay38ns.js → chunk-9n0etqsy.js} +1 -1
  43. package/bin/{chunk-k9m47xba.js → chunk-9rw65s3e.js} +2 -2
  44. package/bin/chunk-9tebgane.js +1 -0
  45. package/bin/{chunk-g460bbnk.js → chunk-a4ykr91z.js} +2 -2
  46. package/bin/{chunk-1dvam047.js → chunk-a5kfa0k9.js} +1 -1
  47. package/bin/{chunk-7a2gg16x.js → chunk-aakzq0w1.js} +1 -1
  48. package/bin/{chunk-a70x1w8e.js → chunk-ac2ky3q0.js} +2 -2
  49. package/bin/{chunk-24bbrqy7.js → chunk-acxm86fh.js} +1 -1
  50. package/bin/{chunk-rz9pz59y.js → chunk-av86q7yw.js} +2 -2
  51. package/bin/{chunk-xs7cpj25.js → chunk-azab07c8.js} +2 -2
  52. package/bin/{chunk-x1178p5d.js → chunk-b934pecv.js} +2 -2
  53. package/bin/chunk-brv6mby6.js +2 -0
  54. package/bin/{chunk-5qtqgx87.js → chunk-bt4b8gjg.js} +2 -2
  55. package/bin/{chunk-x9q1k4kw.js → chunk-ca2pfad4.js} +2 -2
  56. package/bin/{chunk-3cre4tc5.js → chunk-cthpdt54.js} +2 -2
  57. package/bin/{chunk-qb5qfw71.js → chunk-d0earxhc.js} +1 -1
  58. package/bin/{chunk-xy33vxtv.js → chunk-d1ka11hc.js} +1 -1
  59. package/bin/{chunk-sqpaynb6.js → chunk-d2y3rbjm.js} +1 -1
  60. package/bin/{chunk-q1zr85gb.js → chunk-dmgjse02.js} +1 -1
  61. package/bin/chunk-dpchr1gx.js +1 -0
  62. package/bin/{chunk-d9haskf5.js → chunk-dypsm6m2.js} +1 -1
  63. package/bin/{chunk-vqfm1spm.js → chunk-dyybbn07.js} +1 -1
  64. package/bin/chunk-e29zp01c.js +1 -0
  65. package/bin/{chunk-gda70q5n.js → chunk-eadb78m8.js} +1 -1
  66. package/bin/{chunk-32ptm61p.js → chunk-ec88pb09.js} +2 -2
  67. package/bin/{chunk-eagsj1vb.js → chunk-ehfk24cf.js} +1 -1
  68. package/bin/{chunk-rp5kkkb2.js → chunk-ey7t17sy.js} +2 -2
  69. package/bin/{chunk-yadp1e44.js → chunk-fcb14agg.js} +1 -1
  70. package/bin/chunk-fck88m5g.js +3 -0
  71. package/bin/{chunk-0b7pt74x.js → chunk-fdqpn3b2.js} +2 -2
  72. package/bin/{chunk-dvgxj01x.js → chunk-fwe9g818.js} +1 -1
  73. package/bin/{chunk-ehgc7x4w.js → chunk-gdm6y33a.js} +1 -1
  74. package/bin/chunk-gf7a2n6f.js +62 -0
  75. package/bin/chunk-hdwc05sx.js +1 -0
  76. package/bin/chunk-jhcfs9rq.css +1 -0
  77. package/bin/{chunk-t6ettw1q.js → chunk-k5w64spz.js} +2 -2
  78. package/bin/chunk-k712q1zj.js +2 -0
  79. package/bin/{chunk-nz95b2c5.js → chunk-kbzm1pwx.js} +1 -1
  80. package/bin/{chunk-wyp6md07.js → chunk-kv5zpkb9.js} +2 -2
  81. package/bin/{chunk-f3vj8mrh.js → chunk-mjan6b09.js} +3 -3
  82. package/bin/{chunk-3xqy7myz.js → chunk-mv79zk8q.js} +3 -3
  83. package/bin/{chunk-k4pa97ny.js → chunk-n296vcfw.js} +1 -1
  84. package/bin/{chunk-8fe6c473.js → chunk-n5hfy93f.js} +2 -2
  85. package/bin/{chunk-08hwazz9.js → chunk-n6jgyv4y.js} +2 -2
  86. package/bin/{chunk-8jmnfqt9.js → chunk-nar4s9v9.js} +1 -1
  87. package/bin/{chunk-5wcyvbqg.js → chunk-qqesrgjk.js} +1 -1
  88. package/bin/{chunk-mfmry62q.js → chunk-qz9xht6d.js} +1 -1
  89. package/bin/{chunk-qvkqjgtt.js → chunk-s11wkhjx.js} +1 -1
  90. package/bin/{chunk-f35s32xy.js → chunk-s8d2045p.js} +1 -1
  91. package/bin/chunk-sgpj8364.js +3 -0
  92. package/bin/{chunk-tqtms9ft.js → chunk-srjn98yq.js} +2 -2
  93. package/bin/{chunk-f8xx6rcr.js → chunk-ta87ayeh.js} +2 -2
  94. package/bin/chunk-v03c5xck.js +2 -0
  95. package/bin/chunk-vh7vaysq.js +2 -0
  96. package/bin/chunk-vk9bwgjx.js +1 -0
  97. package/bin/{chunk-xj8ss02x.js → chunk-w3ym3t40.js} +2 -2
  98. package/bin/{chunk-qk2ff4nz.js → chunk-w4t9n9te.js} +1 -1
  99. package/bin/{chunk-23ps0bkk.js → chunk-w4y97tzy.js} +1 -1
  100. package/bin/chunk-wdpyvymn.js +1 -0
  101. package/bin/chunk-wfjtv14g.js +2 -0
  102. package/bin/{chunk-5ev6gvcw.js → chunk-wv4fe1fj.js} +2 -2
  103. package/bin/{chunk-2r9dzbmv.js → chunk-wzs9kfef.js} +2 -2
  104. package/bin/{chunk-9x12d447.js → chunk-xh2ntgmk.js} +2 -2
  105. package/bin/{chunk-8k17tr3j.js → chunk-xv0tj9cw.js} +2 -2
  106. package/bin/{chunk-2nvc9af3.js → chunk-xv3jdnqa.js} +2 -2
  107. package/bin/{chunk-4fsbzhr2.js → chunk-y1xs4c5j.js} +1 -1
  108. package/bin/{chunk-0zpc9pkt.js → chunk-yhj8c5re.js} +2 -2
  109. package/bin/{chunk-qbtsq2mp.js → chunk-ysq64j13.js} +1 -1
  110. package/bin/{chunk-w3t6tpgg.js → chunk-z14hh99h.js} +1 -1
  111. package/bin/shumai-app.html +1 -1
  112. package/bin/shumai-app.js +193 -181
  113. package/package.json +7 -7
  114. package/prisma/migrations/20260711121142_add_agent_session_type/migration.sql +8 -0
  115. package/prisma/migrations/20260711123731_add_agent_session_name/migration.sql +2 -0
  116. package/prisma/migrations/20260711124459_add_naming_session_type/migration.sql +2 -0
  117. package/prisma/migrations/20260714024940_add_session_id_to_workflow_tasks/migration.sql +5 -0
  118. package/prisma/migrations/20260714025034_backfill_session_id_in_workflow_tasks/migration.sql +4 -0
  119. package/prisma/schema.prisma +11 -0
  120. package/bin/chunk-0kkyb1qj.js +0 -2
  121. package/bin/chunk-1w2ewnxj.js +0 -2
  122. package/bin/chunk-2hbxxtna.js +0 -3
  123. package/bin/chunk-3f8h4ny6.js +0 -1
  124. package/bin/chunk-4jnv6j35.js +0 -2
  125. package/bin/chunk-5fcq8frp.js +0 -2
  126. package/bin/chunk-5mfrg15w.js +0 -2
  127. package/bin/chunk-5n525czh.js +0 -1
  128. package/bin/chunk-7ypz776w.js +0 -2
  129. package/bin/chunk-8re7vwwx.js +0 -1
  130. package/bin/chunk-cr4jkqng.js +0 -1
  131. package/bin/chunk-d3bx7aew.js +0 -1
  132. package/bin/chunk-h2v02d67.js +0 -1
  133. package/bin/chunk-h90tm6j4.js +0 -2
  134. package/bin/chunk-jk0x7225.css +0 -1
  135. package/bin/chunk-jkhyp3kp.js +0 -1
  136. package/bin/chunk-kb7egkm8.js +0 -2
  137. package/bin/chunk-p2xqn9ks.js +0 -1
  138. package/bin/chunk-p8hzvaqv.js +0 -1
  139. package/bin/chunk-qsbmjs1a.js +0 -2
  140. package/bin/chunk-r673a3wt.js +0 -62
  141. package/bin/chunk-rfx3y5re.js +0 -1
  142. package/bin/chunk-tjzrhp6f.js +0 -2
  143. package/bin/chunk-vw02zbwa.js +0 -1
  144. package/bin/chunk-vwgb2q3b.js +0 -1
  145. package/bin/chunk-zqbsbxz7.js +0 -2
@@ -0,0 +1 @@
1
+ import{d as _}from"./chunk-wfjtv14g.js";import"./chunk-7tkpx9n9.js";import"./chunk-6bzscrnw.js";import"./chunk-7aj7b7cc.js";import"./chunk-5erm1x1z.js";import"./chunk-wzs9kfef.js";import"./chunk-11jh64vm.js";import"./chunk-v03c5xck.js";import"./chunk-4w8yjya6.js";import"./chunk-a4ykr91z.js";import"./chunk-8xvtksy3.js";import"./chunk-34sj5czd.js";import"./chunk-av86q7yw.js";import{se as Y,te as Z}from"./chunk-azab07c8.js";import"./chunk-kv5zpkb9.js";import"./chunk-5rhkwshw.js";import"./chunk-fck88m5g.js";import"./chunk-7yvr7g7e.js";import"./chunk-5an9f2kg.js";import"./chunk-w3ym3t40.js";import"./chunk-5a2maxwp.js";import"./chunk-xv3jdnqa.js";import"./chunk-b934pecv.js";import{$f as O,Eg as B,bg as w,fg as A,gg as N,hg as U,hj as W,ij as X,sg as V}from"./chunk-gf7a2n6f.js";import{Zj as M}from"./chunk-kbzm1pwx.js";var h=M(O(),1);function R(){let{projectId:k,collectionId:D}=P.useParams(),{teamId:G,ensureTeamIdForProject:H}=X();h.useEffect(()=>{H(k)},[k,H]);let{data:J}=N(Y(k)),{data:v,refetch:z}=A({...Z(D)}),{mutate:E}=U({mutationFn:async(q)=>{let K=await B.api.collections[":collectionId"].$patch({param:{collectionId:D},json:q});if(!K.ok)throw Error("Failed to update collection");return await K.json()},onSuccess:()=>{z()}}),b=J?.rootFolder,{data:L}=A({queryKey:["folders",b],queryFn:async()=>{let q=await B.api.folders[":folderId"].$get({param:{folderId:b}});if(!q.ok)throw Error("Failed to fetch folder");return await q.json()},enabled:!!b});if(!G||!b||!L||!v)return w("div",{children:W.loading_collection()});let $=v.filter.sourceFolderId||b;return w(_,{teamId:G,projectId:k,projectName:J.name??"",assetId:$,rootFolderId:b,collection:v,onUpdateCollection:E})}var P=V("/projects/$projectId/collections/$collectionId")({component:R});export{P as Route};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
2
  function L(G,q,D){return{temperature:q?.temperature,maxTokens:q?.maxTokens,signal:q?.signal,apiKey:D||q?.apiKey,transport:q?.transport,cacheRetention:q?.cacheRetention,sessionId:q?.sessionId,headers:q?.headers,onPayload:q?.onPayload,onResponse:q?.onResponse,timeoutMs:q?.timeoutMs,websocketConnectTimeoutMs:q?.websocketConnectTimeoutMs,maxRetries:q?.maxRetries,maxRetryDelayMs:q?.maxRetryDelayMs,metadata:q?.metadata}}function K(G){return G==="xhigh"?"high":G}function y(G,q,D,N){let _={...{minimal:1024,low:2048,medium:8192,high:16384},...N},O=1024,V=K(D),J=_[V],Q=G===void 0?q:Math.min(G+J,q);if(Q<=J)J=Math.max(0,Q-1024);return{maxTokens:Q,thinkingBudget:J}}function j(G,q){let D=[],N=!1;for(let Y of G){if(Y.type==="image"){if(!N)D.push({type:"text",text:q});N=!0;continue}D.push(Y),N=Y.text===q}return D}function U(G,q){if(q.input.includes("image"))return G;return G.map((D)=>{if(D.role==="user"&&Array.isArray(D.content))return{...D,content:j(D.content,"(image omitted: model does not support images)")};if(D.role==="toolResult")return{...D,content:j(D.content,"(tool image omitted: model does not support images)")};return D})}function W(G,q,D){let N=new Map,_=U(G,q).map((E)=>{if(E.role==="user")return E;if(E.role==="toolResult"){let A=N.get(E.toolCallId);if(A&&A!==E.toolCallId)return{...E,toolCallId:A};return E}if(E.role==="assistant"){let A=E,H=A.provider===q.provider&&A.api===q.api&&A.model===q.id,$=A.content.flatMap((F)=>{if(F.type==="thinking"){if(F.redacted)return H?F:[];if(H&&F.thinkingSignature)return F;if(!F.thinking||F.thinking.trim()==="")return[];if(H)return F;return{type:"text",text:F.thinking}}if(F.type==="text"){if(H)return F;return{type:"text",text:F.text}}if(F.type==="toolCall"){let X=F,Z=X;if(!H&&X.thoughtSignature)Z={...X},delete Z.thoughtSignature;if(!H&&D){let w=D(X.id,q,A);if(w!==X.id)N.set(X.id,w),Z={...Z,id:w}}return Z}return F});return{...A,content:$}}return E}),O=[],V=[],J=new Set,Q=()=>{if(V.length>0){for(let E of V)if(!J.has(E.id))O.push({role:"toolResult",toolCallId:E.id,toolName:E.name,content:[{type:"text",text:"No result provided"}],isError:!0,timestamp:Date.now()});V=[],J=new Set}};for(let E=0;E<_.length;E++){let A=_[E];if(A.role==="assistant"){Q();let H=A;if(H.stopReason==="error"||H.stopReason==="aborted")continue;let $=H.content.filter((F)=>F.type==="toolCall");if($.length>0)V=$,J=new Set;O.push(A)}else if(A.role==="toolResult")J.add(A.toolCallId),O.push(A);else if(A.role==="user")Q(),O.push(A);else O.push(A)}return Q(),O}
3
- export{L as Mj,y as Nj,W as Oj};
3
+ export{L as Sj,y as Tj,W as Uj};
@@ -0,0 +1 @@
1
+ import{P as lz}from"./chunk-11jh64vm.js";import{Za as a}from"./chunk-34sj5czd.js";import{$a as Dz,_a as yz,ab as bz,bb as Cz,cb as fz,db as Iz,eb as gz,fb as uz}from"./chunk-av86q7yw.js";import{Kf as hz}from"./chunk-7yvr7g7e.js";import{Rf as c}from"./chunk-xv3jdnqa.js";import{$f as Xz,$g as Tz,Cg as Yz,Eg as X,Fg as Jz,Gg as Uz,Mg as Bz,Ng as zz,Pg as Wz,Pi as _z,Qg as $z,Ri as E,Si as Sz,Ti as Mz,Ui as vz,Vi as b,Xi as C,Yi as f,Zi as M,_h as Zz,ag as N,bg as z,cg as J,dg as x,fg as Vz,gg as Oz,gh as i,hg as k,hj as V,jj as wz,kj as n,lj as Rz,mj as Kz,ng as m,nj as kz,oj as qz,pi as Gz,pj as Az,qj as Ez,sg as Pz,wi as Lz}from"./chunk-gf7a2n6f.js";import{Zj as Qz}from"./chunk-kbzm1pwx.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};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
2
  function L(G,q,D){return{temperature:q?.temperature,maxTokens:q?.maxTokens,signal:q?.signal,apiKey:D||q?.apiKey,transport:q?.transport,cacheRetention:q?.cacheRetention,sessionId:q?.sessionId,headers:q?.headers,onPayload:q?.onPayload,onResponse:q?.onResponse,timeoutMs:q?.timeoutMs,maxRetries:q?.maxRetries,maxRetryDelayMs:q?.maxRetryDelayMs,metadata:q?.metadata}}function K(G){return G==="xhigh"?"high":G}function y(G,q,D,N){let _={...{minimal:1024,low:2048,medium:8192,high:16384},...N},O=1024,V=K(D),J=_[V],Q=G===void 0?q:Math.min(G+J,q);if(Q<=J)J=Math.max(0,Q-1024);return{maxTokens:Q,thinkingBudget:J}}function j(G,q){let D=[],N=!1;for(let Y of G){if(Y.type==="image"){if(!N)D.push({type:"text",text:q});N=!0;continue}D.push(Y),N=Y.text===q}return D}function U(G,q){if(q.input.includes("image"))return G;return G.map((D)=>{if(D.role==="user"&&Array.isArray(D.content))return{...D,content:j(D.content,"(image omitted: model does not support images)")};if(D.role==="toolResult")return{...D,content:j(D.content,"(tool image omitted: model does not support images)")};return D})}function W(G,q,D){let N=new Map,_=U(G,q).map((E)=>{if(E.role==="user")return E;if(E.role==="toolResult"){let A=N.get(E.toolCallId);if(A&&A!==E.toolCallId)return{...E,toolCallId:A};return E}if(E.role==="assistant"){let A=E,H=A.provider===q.provider&&A.api===q.api&&A.model===q.id,$=A.content.flatMap((F)=>{if(F.type==="thinking"){if(F.redacted)return H?F:[];if(H&&F.thinkingSignature)return F;if(!F.thinking||F.thinking.trim()==="")return[];if(H)return F;return{type:"text",text:F.thinking}}if(F.type==="text"){if(H)return F;return{type:"text",text:F.text}}if(F.type==="toolCall"){let X=F,Z=X;if(!H&&X.thoughtSignature)Z={...X},delete Z.thoughtSignature;if(!H&&D){let w=D(X.id,q,A);if(w!==X.id)N.set(X.id,w),Z={...Z,id:w}}return Z}return F});return{...A,content:$}}return E}),O=[],V=[],J=new Set,Q=()=>{if(V.length>0){for(let E of V)if(!J.has(E.id))O.push({role:"toolResult",toolCallId:E.id,toolName:E.name,content:[{type:"text",text:"No result provided"}],isError:!0,timestamp:Date.now()});V=[],J=new Set}};for(let E=0;E<_.length;E++){let A=_[E];if(A.role==="assistant"){Q();let H=A;if(H.stopReason==="error"||H.stopReason==="aborted")continue;let $=H.content.filter((F)=>F.type==="toolCall");if($.length>0)V=$,J=new Set;O.push(A)}else if(A.role==="toolResult")J.add(A.toolCallId),O.push(A);else if(A.role==="user")Q(),O.push(A);else O.push(A)}return Q(),O}
3
- export{L as vb,y as wb,W as xb};
3
+ export{L as xb,y as yb,W as zb};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{pb as C,qb as j,rb as v,sb as T,tb as I,ub as B}from"./chunk-t6ettw1q.js";import{vb as M}from"./chunk-qggykya7.js";import{yb as P}from"./chunk-gda70q5n.js";import{ge as L,he as K,ie as G}from"./chunk-5mvvjqcp.js";import{Ij as F,Kj as y,Lj as H}from"./chunk-f3vj8mrh.js";import"./chunk-nz95b2c5.js";var b="v1",k="gcp-vertex-credentials",g={THINKING_LEVEL_UNSPECIFIED:F.THINKING_LEVEL_UNSPECIFIED,MINIMAL:F.MINIMAL,LOW:F.LOW,MEDIUM:F.MEDIUM,HIGH:F.HIGH},m=0,S=(q,w,J)=>{let Y=new G;return(async()=>{let Q={role:"assistant",content:[],api:"google-vertex",provider:q.provider,model:q.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"stop",timestamp:Date.now()};try{let W=p(J),z=W?u(q,W,J?.headers):d(q,r(J),s(J),J?.headers),N=i(q,w,J),R=await J?.onPayload?.(N,q);if(R!==void 0)N=R;let x=await z.models.generateContentStream(N);Y.push({type:"start",partial:Q});let Z=null,A=Q.content,X=()=>A.length-1;for await(let D of x){Q.responseId||=D.responseId;let V=D.candidates?.[0];if(V?.content?.parts)for(let $ of V.content.parts){if($.text!==void 0){let _=C($);if(!Z||_&&Z.type!=="thinking"||!_&&Z.type!=="text"){if(Z)if(Z.type==="text")Y.push({type:"text_end",contentIndex:A.length-1,content:Z.text,partial:Q});else Y.push({type:"thinking_end",contentIndex:X(),content:Z.thinking,partial:Q});if(_)Z={type:"thinking",thinking:"",thinkingSignature:void 0},Q.content.push(Z),Y.push({type:"thinking_start",contentIndex:X(),partial:Q});else Z={type:"text",text:""},Q.content.push(Z),Y.push({type:"text_start",contentIndex:X(),partial:Q})}if(Z.type==="thinking")Z.thinking+=$.text,Z.thinkingSignature=j(Z.thinkingSignature,$.thoughtSignature),Y.push({type:"thinking_delta",contentIndex:X(),delta:$.text,partial:Q});else Z.text+=$.text,Z.textSignature=j(Z.textSignature,$.thoughtSignature),Y.push({type:"text_delta",contentIndex:X(),delta:$.text,partial:Q})}if($.functionCall){if(Z){if(Z.type==="text")Y.push({type:"text_end",contentIndex:X(),content:Z.text,partial:Q});else Y.push({type:"thinking_end",contentIndex:X(),content:Z.thinking,partial:Q});Z=null}let _=$.functionCall.id,E={type:"toolCall",id:!_||Q.content.some((U)=>U.type==="toolCall"&&U.id===_)?`${$.functionCall.name}_${Date.now()}_${++m}`:_,name:$.functionCall.name||"",arguments:$.functionCall.args??{},...$.thoughtSignature&&{thoughtSignature:$.thoughtSignature}};Q.content.push(E),Y.push({type:"toolcall_start",contentIndex:X(),partial:Q}),Y.push({type:"toolcall_delta",contentIndex:X(),delta:JSON.stringify(E.arguments),partial:Q}),Y.push({type:"toolcall_end",contentIndex:X(),toolCall:E,partial:Q})}}if(V?.finishReason){if(Q.stopReason=B(V.finishReason),Q.content.some(($)=>$.type==="toolCall"))Q.stopReason="toolUse"}if(D.usageMetadata)Q.usage={input:(D.usageMetadata.promptTokenCount||0)-(D.usageMetadata.cachedContentTokenCount||0),output:(D.usageMetadata.candidatesTokenCount||0)+(D.usageMetadata.thoughtsTokenCount||0),cacheRead:D.usageMetadata.cachedContentTokenCount||0,cacheWrite:0,totalTokens:D.usageMetadata.totalTokenCount||0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},L(q,Q.usage)}if(Z)if(Z.type==="text")Y.push({type:"text_end",contentIndex:X(),content:Z.text,partial:Q});else Y.push({type:"thinking_end",contentIndex:X(),content:Z.thinking,partial:Q});if(J?.signal?.aborted)throw Error("Request was aborted");if(Q.stopReason==="aborted"||Q.stopReason==="error")throw Error("An unknown error occurred");Y.push({type:"done",reason:Q.stopReason,message:Q}),Y.end()}catch(W){for(let z of Q.content)if("index"in z)delete z.index;Q.stopReason=J?.signal?.aborted?"aborted":"error",Q.errorMessage=W instanceof Error?W.message:JSON.stringify(W),Y.push({type:"error",reason:Q.stopReason,error:Q}),Y.end()}})(),Y},Wq=(q,w,J)=>{let Y=M(q,J,void 0);if(!J?.reasoning)return S(q,w,{...Y,thinking:{enabled:!1}});let Q=K(q,J.reasoning),W=Q==="off"?"high":Q,z=q;if(O(z)||h(z))return S(q,w,{...Y,thinking:{enabled:!0,level:e(W,z)}});return S(q,w,{...Y,thinking:{enabled:!0,budgetTokens:t(z,W,J.thinkingBudgets)}})};function d(q,w,J,Y){return new H({vertexai:!0,project:w,location:J,apiVersion:b,httpOptions:f(q,Y)})}function u(q,w,J){return new H({vertexai:!0,apiKey:w,apiVersion:b,httpOptions:f(q,J)})}function f(q,w){let J={},Y=a(q.baseUrl);if(Y){if(J.baseUrl=Y,J.baseUrlResourceScope=y.COLLECTION,c(Y))J.apiVersion=""}if(q.headers||w)J.headers={...q.headers,...w};return Object.keys(J).length>0?J:void 0}function a(q){let w=q.trim();if(!w||w.includes("{location}"))return;return w}function c(q){try{return new URL(q).pathname.split("/").some((J)=>/^v\d+(?:beta\d*)?$/.test(J))}catch{return/(?:^|\/)v\d+(?:beta\d*)?(?:\/|$)/.test(q)}}function p(q){let w=q?.apiKey?.trim()||process.env.GOOGLE_CLOUD_API_KEY?.trim();if(!w||w===k||l(w))return;return w}function l(q){return/^<[^>]+>$/.test(q)}function r(q){let w=q?.project||process.env.GOOGLE_CLOUD_PROJECT||process.env.GCLOUD_PROJECT;if(!w)throw Error("Vertex AI requires a project ID. Set GOOGLE_CLOUD_PROJECT/GCLOUD_PROJECT or pass project in options.");return w}function s(q){let w=q?.location||process.env.GOOGLE_CLOUD_LOCATION;if(!w)throw Error("Vertex AI requires a location. Set GOOGLE_CLOUD_LOCATION or pass location in options.");return w}function i(q,w,J={}){let Y=v(q,w),Q={};if(J.temperature!==void 0)Q.temperature=J.temperature;if(J.maxTokens!==void 0)Q.maxOutputTokens=J.maxTokens;let W={...Object.keys(Q).length>0&&Q,...w.systemPrompt&&{systemInstruction:P(w.systemPrompt)},...w.tools&&w.tools.length>0&&{tools:T(w.tools)}};if(w.tools&&w.tools.length>0&&J.toolChoice)W.toolConfig={functionCallingConfig:{mode:I(J.toolChoice)}};else W.toolConfig=void 0;if(J.thinking?.enabled&&q.reasoning){let N={includeThoughts:!0};if(J.thinking.level!==void 0)N.thinkingLevel=g[J.thinking.level];else if(J.thinking.budgetTokens!==void 0)N.thinkingBudget=J.thinking.budgetTokens;W.thinkingConfig=N}else if(q.reasoning&&J.thinking&&!J.thinking.enabled)W.thinkingConfig=n(q);if(J.signal){if(J.signal.aborted)throw Error("Request aborted");W.abortSignal=J.signal}return{model:q.id,contents:Y,config:W}}function O(q){return/gemini-3(?:\.\d+)?-pro/.test(q.id.toLowerCase())}function h(q){return/gemini-3(?:\.\d+)?-flash/.test(q.id.toLowerCase())}function n(q){let w=q;if(O(w))return{thinkingLevel:F.LOW};if(h(w))return{thinkingLevel:F.MINIMAL};return{thinkingBudget:0}}function e(q,w){if(O(w))switch(q){case"minimal":case"low":return"LOW";case"medium":case"high":return"HIGH"}switch(q){case"minimal":return"MINIMAL";case"low":return"LOW";case"medium":return"MEDIUM";case"high":return"HIGH"}}function t(q,w,J){if(J?.[w]!==void 0)return J[w];if(q.id.includes("2.5-pro"))return{minimal:128,low:2048,medium:8192,high:32768}[w];if(q.id.includes("2.5-flash"))return{minimal:128,low:2048,medium:8192,high:24576}[w];return-1}export{Wq as streamSimpleGoogleVertex,S as streamGoogleVertex};
2
+ import{rb as C,sb as j,tb as v,ub as T,vb as I,wb as B}from"./chunk-k5w64spz.js";import{xb as M}from"./chunk-0at8vxt5.js";import{Ab as P}from"./chunk-22dje1f5.js";import{ie as L,je as K,ke as G}from"./chunk-7rhjej0x.js";import{Oj as F,Qj as y,Rj as H}from"./chunk-mjan6b09.js";import"./chunk-kbzm1pwx.js";var b="v1",k="gcp-vertex-credentials",g={THINKING_LEVEL_UNSPECIFIED:F.THINKING_LEVEL_UNSPECIFIED,MINIMAL:F.MINIMAL,LOW:F.LOW,MEDIUM:F.MEDIUM,HIGH:F.HIGH},m=0,S=(q,w,J)=>{let Y=new G;return(async()=>{let Q={role:"assistant",content:[],api:"google-vertex",provider:q.provider,model:q.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"stop",timestamp:Date.now()};try{let W=p(J),z=W?u(q,W,J?.headers):d(q,r(J),s(J),J?.headers),N=i(q,w,J),R=await J?.onPayload?.(N,q);if(R!==void 0)N=R;let x=await z.models.generateContentStream(N);Y.push({type:"start",partial:Q});let Z=null,A=Q.content,X=()=>A.length-1;for await(let D of x){Q.responseId||=D.responseId;let V=D.candidates?.[0];if(V?.content?.parts)for(let $ of V.content.parts){if($.text!==void 0){let _=C($);if(!Z||_&&Z.type!=="thinking"||!_&&Z.type!=="text"){if(Z)if(Z.type==="text")Y.push({type:"text_end",contentIndex:A.length-1,content:Z.text,partial:Q});else Y.push({type:"thinking_end",contentIndex:X(),content:Z.thinking,partial:Q});if(_)Z={type:"thinking",thinking:"",thinkingSignature:void 0},Q.content.push(Z),Y.push({type:"thinking_start",contentIndex:X(),partial:Q});else Z={type:"text",text:""},Q.content.push(Z),Y.push({type:"text_start",contentIndex:X(),partial:Q})}if(Z.type==="thinking")Z.thinking+=$.text,Z.thinkingSignature=j(Z.thinkingSignature,$.thoughtSignature),Y.push({type:"thinking_delta",contentIndex:X(),delta:$.text,partial:Q});else Z.text+=$.text,Z.textSignature=j(Z.textSignature,$.thoughtSignature),Y.push({type:"text_delta",contentIndex:X(),delta:$.text,partial:Q})}if($.functionCall){if(Z){if(Z.type==="text")Y.push({type:"text_end",contentIndex:X(),content:Z.text,partial:Q});else Y.push({type:"thinking_end",contentIndex:X(),content:Z.thinking,partial:Q});Z=null}let _=$.functionCall.id,E={type:"toolCall",id:!_||Q.content.some((U)=>U.type==="toolCall"&&U.id===_)?`${$.functionCall.name}_${Date.now()}_${++m}`:_,name:$.functionCall.name||"",arguments:$.functionCall.args??{},...$.thoughtSignature&&{thoughtSignature:$.thoughtSignature}};Q.content.push(E),Y.push({type:"toolcall_start",contentIndex:X(),partial:Q}),Y.push({type:"toolcall_delta",contentIndex:X(),delta:JSON.stringify(E.arguments),partial:Q}),Y.push({type:"toolcall_end",contentIndex:X(),toolCall:E,partial:Q})}}if(V?.finishReason){if(Q.stopReason=B(V.finishReason),Q.content.some(($)=>$.type==="toolCall"))Q.stopReason="toolUse"}if(D.usageMetadata)Q.usage={input:(D.usageMetadata.promptTokenCount||0)-(D.usageMetadata.cachedContentTokenCount||0),output:(D.usageMetadata.candidatesTokenCount||0)+(D.usageMetadata.thoughtsTokenCount||0),cacheRead:D.usageMetadata.cachedContentTokenCount||0,cacheWrite:0,totalTokens:D.usageMetadata.totalTokenCount||0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},L(q,Q.usage)}if(Z)if(Z.type==="text")Y.push({type:"text_end",contentIndex:X(),content:Z.text,partial:Q});else Y.push({type:"thinking_end",contentIndex:X(),content:Z.thinking,partial:Q});if(J?.signal?.aborted)throw Error("Request was aborted");if(Q.stopReason==="aborted"||Q.stopReason==="error")throw Error("An unknown error occurred");Y.push({type:"done",reason:Q.stopReason,message:Q}),Y.end()}catch(W){for(let z of Q.content)if("index"in z)delete z.index;Q.stopReason=J?.signal?.aborted?"aborted":"error",Q.errorMessage=W instanceof Error?W.message:JSON.stringify(W),Y.push({type:"error",reason:Q.stopReason,error:Q}),Y.end()}})(),Y},Wq=(q,w,J)=>{let Y=M(q,J,void 0);if(!J?.reasoning)return S(q,w,{...Y,thinking:{enabled:!1}});let Q=K(q,J.reasoning),W=Q==="off"?"high":Q,z=q;if(O(z)||h(z))return S(q,w,{...Y,thinking:{enabled:!0,level:e(W,z)}});return S(q,w,{...Y,thinking:{enabled:!0,budgetTokens:t(z,W,J.thinkingBudgets)}})};function d(q,w,J,Y){return new H({vertexai:!0,project:w,location:J,apiVersion:b,httpOptions:f(q,Y)})}function u(q,w,J){return new H({vertexai:!0,apiKey:w,apiVersion:b,httpOptions:f(q,J)})}function f(q,w){let J={},Y=a(q.baseUrl);if(Y){if(J.baseUrl=Y,J.baseUrlResourceScope=y.COLLECTION,c(Y))J.apiVersion=""}if(q.headers||w)J.headers={...q.headers,...w};return Object.keys(J).length>0?J:void 0}function a(q){let w=q.trim();if(!w||w.includes("{location}"))return;return w}function c(q){try{return new URL(q).pathname.split("/").some((J)=>/^v\d+(?:beta\d*)?$/.test(J))}catch{return/(?:^|\/)v\d+(?:beta\d*)?(?:\/|$)/.test(q)}}function p(q){let w=q?.apiKey?.trim()||process.env.GOOGLE_CLOUD_API_KEY?.trim();if(!w||w===k||l(w))return;return w}function l(q){return/^<[^>]+>$/.test(q)}function r(q){let w=q?.project||process.env.GOOGLE_CLOUD_PROJECT||process.env.GCLOUD_PROJECT;if(!w)throw Error("Vertex AI requires a project ID. Set GOOGLE_CLOUD_PROJECT/GCLOUD_PROJECT or pass project in options.");return w}function s(q){let w=q?.location||process.env.GOOGLE_CLOUD_LOCATION;if(!w)throw Error("Vertex AI requires a location. Set GOOGLE_CLOUD_LOCATION or pass location in options.");return w}function i(q,w,J={}){let Y=v(q,w),Q={};if(J.temperature!==void 0)Q.temperature=J.temperature;if(J.maxTokens!==void 0)Q.maxOutputTokens=J.maxTokens;let W={...Object.keys(Q).length>0&&Q,...w.systemPrompt&&{systemInstruction:P(w.systemPrompt)},...w.tools&&w.tools.length>0&&{tools:T(w.tools)}};if(w.tools&&w.tools.length>0&&J.toolChoice)W.toolConfig={functionCallingConfig:{mode:I(J.toolChoice)}};else W.toolConfig=void 0;if(J.thinking?.enabled&&q.reasoning){let N={includeThoughts:!0};if(J.thinking.level!==void 0)N.thinkingLevel=g[J.thinking.level];else if(J.thinking.budgetTokens!==void 0)N.thinkingBudget=J.thinking.budgetTokens;W.thinkingConfig=N}else if(q.reasoning&&J.thinking&&!J.thinking.enabled)W.thinkingConfig=n(q);if(J.signal){if(J.signal.aborted)throw Error("Request aborted");W.abortSignal=J.signal}return{model:q.id,contents:Y,config:W}}function O(q){return/gemini-3(?:\.\d+)?-pro/.test(q.id.toLowerCase())}function h(q){return/gemini-3(?:\.\d+)?-flash/.test(q.id.toLowerCase())}function n(q){let w=q;if(O(w))return{thinkingLevel:F.LOW};if(h(w))return{thinkingLevel:F.MINIMAL};return{thinkingBudget:0}}function e(q,w){if(O(w))switch(q){case"minimal":case"low":return"LOW";case"medium":case"high":return"HIGH"}switch(q){case"minimal":return"MINIMAL";case"low":return"LOW";case"medium":return"MEDIUM";case"high":return"HIGH"}}function t(q,w,J){if(J?.[w]!==void 0)return J[w];if(q.id.includes("2.5-pro"))return{minimal:128,low:2048,medium:8192,high:32768}[w];if(q.id.includes("2.5-flash"))return{minimal:128,low:2048,medium:8192,high:24576}[w];return-1}export{Wq as streamSimpleGoogleVertex,S as streamGoogleVertex};
@@ -1,2 +1,2 @@
1
- import{$a as e,Xa as s,Ya as o,Za as r,_a as m,ab as qq,bb as Eq,cb as Jq}from"./chunk-rz9pz59y.js";import{$f as E,Ag as P,Lg as $,Ni as Q,Oi as c,Pi as T,Qi as w,Ri as H,Ti as z,Ui as y,Wi as F,Xi as X,Zf as yq,_f as j,ag as K,dj as J,eh as f,ej as d,fj as b,gj as a,hj as t,ji as i,jj as n,nh as l}from"./chunk-r673a3wt.js";import{Tj as zq}from"./chunk-nz95b2c5.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 N};
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-av86q7yw.js";import{$f as yq,$i as X,Cg as P,Ng as $,Ri as Q,Si as c,Ti as T,Ui as w,Vi as H,Xi as z,Yi as y,_i as F,ag as j,bg as E,cg as K,hh as f,hj as J,kj as d,lj as b,mi as i,mj as a,nj as t,pj as n,qh as l}from"./chunk-gf7a2n6f.js";import{Zj as zq}from"./chunk-kbzm1pwx.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 P};
@@ -1,4 +1,4 @@
1
1
  // @bun
2
- import{zj as G}from"./chunk-0zpc9pkt.js";import{Tj as F}from"./chunk-nz95b2c5.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`
2
+ import{Fj as G}from"./chunk-yhj8c5re.js";import{Zj as F}from"./chunk-kbzm1pwx.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
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 xj,X as yj};
4
+ export{T as Dj,X as Ej};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{qj as S,rj as T,sj as C}from"./chunk-8g69rftv.js";import"./chunk-d9haskf5.js";import{uj as D}from"./chunk-b6ay38ns.js";import{wj as Z}from"./chunk-23ps0bkk.js";import"./chunk-30jjvb4k.js";import"./chunk-0zpc9pkt.js";import{Aj as k}from"./chunk-0hp6t0q3.js";import{Mj as f}from"./chunk-8e4d80kp.js";import{Qj as M,Rj as V}from"./chunk-7yh2nbmq.js";import"./chunk-6ftb22yh.js";import"./chunk-nz95b2c5.js";var j="v1",E=new Set(["openai","openai-codex","opencode","azure-openai-responses"]);function K(G){let Q=new Map;if(!G)return Q;for(let w of G.split(",")){let W=w.trim();if(!W)continue;let[X,J]=W.split("=",2);if(!X||!J)continue;Q.set(X.trim(),J.trim())}return Q}function g(G,Q){if(Q?.azureDeploymentName)return Q.azureDeploymentName;return K(process.env.AZURE_OPENAI_DEPLOYMENT_NAME_MAP).get(G.id)||G.id}function B(G){if(G instanceof Error){let Q=G.status,w=typeof Q==="number"?Q:void 0;if(w!==void 0)return`Azure OpenAI API error (${w}): ${G.message}`;return G.message}try{return JSON.stringify(G)}catch{return String(G)}}var I=(G,Q,w)=>{let W=new V;return(async()=>{let X=g(G,w),J={role:"assistant",content:[],api:"azure-openai-responses",provider:G.provider,model:G.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 Y=w?.apiKey;if(!Y)throw Error(`No API key for provider: ${G.provider}`);let $=z(G,Y,w),q=b(G,Q,w,X),F=await w?.onPayload?.(q,G);if(F!==void 0)q=F;let L={...w?.signal?{signal:w.signal}:{},...w?.timeoutMs!==void 0?{timeout:w.timeoutMs}:{},maxRetries:w?.maxRetries??0},{data:_,response:H}=await $.responses.create(q,L).withResponse();if(await w?.onResponse?.({status:H.status,headers:k(H.headers)},G),W.push({type:"start",partial:J}),await C(_,J,W,G),w?.signal?.aborted)throw Error("Request was aborted");if(J.stopReason==="aborted"||J.stopReason==="error")throw Error("An unknown error occurred");W.push({type:"done",reason:J.stopReason,message:J}),W.end()}catch(Y){for(let $ of J.content)delete $.index,delete $.partialJson;J.stopReason=w?.signal?.aborted?"aborted":"error",J.errorMessage=B(Y),W.push({type:"error",reason:J.stopReason,error:J}),W.end()}})(),W},c=(G,Q,w)=>{let W=w?.apiKey;if(!W)throw Error(`No API key for provider: ${G.provider}`);let X=f(G,w,W),J=w?.reasoning?M(G,w.reasoning):void 0;return I(G,Q,{...X,reasoningEffort:J==="off"?void 0:J})};function P(G){let Q=G.trim().replace(/\/+$/,""),w;try{w=new URL(Q)}catch{throw Error(`Invalid Azure OpenAI base URL: ${G}`)}let W=w.hostname.endsWith(".openai.azure.com")||w.hostname.endsWith(".cognitiveservices.azure.com"),X=w.pathname.replace(/\/+$/,"");if(W&&(X===""||X==="/"||X==="/openai"))w.pathname="/openai/v1",w.search="";return w.toString().replace(/\/+$/,"")}function O(G){return`https://${G}.openai.azure.com/openai/v1`}function h(G,Q){let w=Q?.azureApiVersion||process.env.AZURE_OPENAI_API_VERSION||j,W=Q?.azureBaseUrl?.trim()||process.env.AZURE_OPENAI_BASE_URL?.trim()||void 0,X=Q?.azureResourceName||process.env.AZURE_OPENAI_RESOURCE_NAME,J=W;if(!J&&X)J=O(X);if(!J&&G.baseUrl)J=G.baseUrl;if(!J)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:P(J),apiVersion:w}}function z(G,Q,w){let W={...G.headers};if(w?.headers)Object.assign(W,w.headers);let{baseUrl:X,apiVersion:J}=h(G,w);return new Z({apiKey:Q,apiVersion:J,dangerouslyAllowBrowser:!0,defaultHeaders:W,baseURL:X})}function b(G,Q,w,W){let X=S(G,Q,E),J={model:W,input:X,stream:!0,prompt_cache_key:D(w?.sessionId)};if(w?.maxTokens)J.max_output_tokens=w?.maxTokens;if(w?.temperature!==void 0)J.temperature=w?.temperature;if(Q.tools&&Q.tools.length>0)J.tools=T(Q.tools);if(G.reasoning){if(w?.reasoningEffort||w?.reasoningSummary){let Y=w?.reasoningEffort?G.thinkingLevelMap?.[w.reasoningEffort]??w.reasoningEffort:"medium";J.reasoning={effort:Y,summary:w?.reasoningSummary||"auto"},J.include=["reasoning.encrypted_content"]}else if(G.thinkingLevelMap?.off!==null)J.reasoning={effort:G.thinkingLevelMap?.off??"none"}}return J}export{c as streamSimpleAzureOpenAIResponses,I as streamAzureOpenAIResponses};
2
+ import{wj as S,xj as T,yj as C}from"./chunk-29ectt6g.js";import"./chunk-a5kfa0k9.js";import{Aj as D}from"./chunk-fwe9g818.js";import{Cj as Z}from"./chunk-w4y97tzy.js";import"./chunk-1fpqq6ed.js";import"./chunk-yhj8c5re.js";import{Gj as k}from"./chunk-n296vcfw.js";import{Sj as f}from"./chunk-08m8mzfa.js";import{Wj as M,Xj as V}from"./chunk-3rajscaz.js";import"./chunk-eadb78m8.js";import"./chunk-kbzm1pwx.js";var j="v1",E=new Set(["openai","openai-codex","opencode","azure-openai-responses"]);function K(G){let Q=new Map;if(!G)return Q;for(let w of G.split(",")){let W=w.trim();if(!W)continue;let[X,J]=W.split("=",2);if(!X||!J)continue;Q.set(X.trim(),J.trim())}return Q}function g(G,Q){if(Q?.azureDeploymentName)return Q.azureDeploymentName;return K(process.env.AZURE_OPENAI_DEPLOYMENT_NAME_MAP).get(G.id)||G.id}function B(G){if(G instanceof Error){let Q=G.status,w=typeof Q==="number"?Q:void 0;if(w!==void 0)return`Azure OpenAI API error (${w}): ${G.message}`;return G.message}try{return JSON.stringify(G)}catch{return String(G)}}var I=(G,Q,w)=>{let W=new V;return(async()=>{let X=g(G,w),J={role:"assistant",content:[],api:"azure-openai-responses",provider:G.provider,model:G.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 Y=w?.apiKey;if(!Y)throw Error(`No API key for provider: ${G.provider}`);let $=z(G,Y,w),q=b(G,Q,w,X),F=await w?.onPayload?.(q,G);if(F!==void 0)q=F;let L={...w?.signal?{signal:w.signal}:{},...w?.timeoutMs!==void 0?{timeout:w.timeoutMs}:{},maxRetries:w?.maxRetries??0},{data:_,response:H}=await $.responses.create(q,L).withResponse();if(await w?.onResponse?.({status:H.status,headers:k(H.headers)},G),W.push({type:"start",partial:J}),await C(_,J,W,G),w?.signal?.aborted)throw Error("Request was aborted");if(J.stopReason==="aborted"||J.stopReason==="error")throw Error("An unknown error occurred");W.push({type:"done",reason:J.stopReason,message:J}),W.end()}catch(Y){for(let $ of J.content)delete $.index,delete $.partialJson;J.stopReason=w?.signal?.aborted?"aborted":"error",J.errorMessage=B(Y),W.push({type:"error",reason:J.stopReason,error:J}),W.end()}})(),W},c=(G,Q,w)=>{let W=w?.apiKey;if(!W)throw Error(`No API key for provider: ${G.provider}`);let X=f(G,w,W),J=w?.reasoning?M(G,w.reasoning):void 0;return I(G,Q,{...X,reasoningEffort:J==="off"?void 0:J})};function P(G){let Q=G.trim().replace(/\/+$/,""),w;try{w=new URL(Q)}catch{throw Error(`Invalid Azure OpenAI base URL: ${G}`)}let W=w.hostname.endsWith(".openai.azure.com")||w.hostname.endsWith(".cognitiveservices.azure.com"),X=w.pathname.replace(/\/+$/,"");if(W&&(X===""||X==="/"||X==="/openai"))w.pathname="/openai/v1",w.search="";return w.toString().replace(/\/+$/,"")}function O(G){return`https://${G}.openai.azure.com/openai/v1`}function h(G,Q){let w=Q?.azureApiVersion||process.env.AZURE_OPENAI_API_VERSION||j,W=Q?.azureBaseUrl?.trim()||process.env.AZURE_OPENAI_BASE_URL?.trim()||void 0,X=Q?.azureResourceName||process.env.AZURE_OPENAI_RESOURCE_NAME,J=W;if(!J&&X)J=O(X);if(!J&&G.baseUrl)J=G.baseUrl;if(!J)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:P(J),apiVersion:w}}function z(G,Q,w){let W={...G.headers};if(w?.headers)Object.assign(W,w.headers);let{baseUrl:X,apiVersion:J}=h(G,w);return new Z({apiKey:Q,apiVersion:J,dangerouslyAllowBrowser:!0,defaultHeaders:W,baseURL:X})}function b(G,Q,w,W){let X=S(G,Q,E),J={model:W,input:X,stream:!0,prompt_cache_key:D(w?.sessionId)};if(w?.maxTokens)J.max_output_tokens=w?.maxTokens;if(w?.temperature!==void 0)J.temperature=w?.temperature;if(Q.tools&&Q.tools.length>0)J.tools=T(Q.tools);if(G.reasoning){if(w?.reasoningEffort||w?.reasoningSummary){let Y=w?.reasoningEffort?G.thinkingLevelMap?.[w.reasoningEffort]??w.reasoningEffort:"medium";J.reasoning={effort:Y,summary:w?.reasoningSummary||"auto"},J.include=["reasoning.encrypted_content"]}else if(G.thinkingLevelMap?.off!==null)J.reasoning={effort:G.thinkingLevelMap?.off??"none"}}return J}export{c as streamSimpleAzureOpenAIResponses,I as streamAzureOpenAIResponses};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
2
  function f(b){return b.replace(/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g,"")}
3
- export{f as Sj};
3
+ export{f as Ab};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{tj as J}from"./chunk-d9haskf5.js";import{yj as w}from"./chunk-30jjvb4k.js";import{Oj as R}from"./chunk-8e4d80kp.js";import{Pj as j}from"./chunk-7yh2nbmq.js";import{Sj as V}from"./chunk-6ftb22yh.js";function M(Q,E){let W={v:1,id:Q};if(E)W.phase=E;return JSON.stringify(W)}function C(Q){if(!Q)return;if(Q.startsWith("{"))try{let E=JSON.parse(Q);if(E.v===1&&typeof E.id==="string"){if(E.phase==="commentary"||E.phase==="final_answer")return{id:E.id,phase:E.phase};return{id:E.id}}}catch{}return{id:Q}}function x(Q,E,W,U){let _=[],N=(G)=>{let O=G.replace(/[^a-zA-Z0-9_-]/g,"_");return(O.length>64?O.slice(0,64):O).replace(/_+$/,"")},A=(G)=>{let O=`fc_${J(G)}`;return O.length>64?O.slice(0,64):O},y=(G,O,Y)=>{if(!W.has(Q.provider))return N(G);if(!G.includes("|"))return N(G);let[H,L]=G.split("|"),$=N(H),D=Y.provider!==Q.provider||Y.api!==Q.api?A(L):N(L);if(!D.startsWith("fc_"))D=N(`fc_${D}`);return`${$}|${D}`},Z=R(E.messages,Q,y);if((U?.includeSystemPrompt??!0)&&E.systemPrompt){let G=Q.reasoning?"developer":"system";_.push({role:G,content:V(E.systemPrompt)})}let q=0;for(let G of Z){if(G.role==="user")if(typeof G.content==="string")_.push({role:"user",content:[{type:"input_text",text:V(G.content)}]});else{let O=G.content.map((Y)=>{if(Y.type==="text")return{type:"input_text",text:V(Y.text)};return{type:"input_image",detail:"auto",image_url:`data:${Y.mimeType};base64,${Y.data}`}});if(O.length===0)continue;_.push({role:"user",content:O})}else if(G.role==="assistant"){let O=[],Y=G,H=Y.model!==Q.id&&Y.provider===Q.provider&&Y.api===Q.api,L=0;for(let $ of G.content)if($.type==="thinking"){if($.thinkingSignature){let X=JSON.parse($.thinkingSignature);O.push(X)}}else if($.type==="text"){let X=$,D=C(X.textSignature),f=L===0?`msg_pi_${q}`:`msg_pi_${q}_${L}`;L++;let F=D?.id;if(!F)F=f;else if(F.length>64)F=`msg_${J(F)}`;O.push({type:"message",role:"assistant",content:[{type:"output_text",text:V(X.text),annotations:[]}],status:"completed",id:F,phase:D?.phase})}else if($.type==="toolCall"){let X=$,[D,f]=X.id.split("|"),F=f;if(H&&F?.startsWith("fc_"))F=void 0;O.push({type:"function_call",id:F,call_id:D,name:X.name,arguments:JSON.stringify(X.arguments)})}if(O.length===0)continue;_.push(...O)}else if(G.role==="toolResult"){let O=G.content.filter((X)=>X.type==="text").map((X)=>X.text).join(`
2
+ import{zj as J}from"./chunk-a5kfa0k9.js";import{Ej as w}from"./chunk-1fpqq6ed.js";import{Uj as R}from"./chunk-08m8mzfa.js";import{Vj as j}from"./chunk-3rajscaz.js";import{Yj as V}from"./chunk-eadb78m8.js";function M(Q,E){let W={v:1,id:Q};if(E)W.phase=E;return JSON.stringify(W)}function C(Q){if(!Q)return;if(Q.startsWith("{"))try{let E=JSON.parse(Q);if(E.v===1&&typeof E.id==="string"){if(E.phase==="commentary"||E.phase==="final_answer")return{id:E.id,phase:E.phase};return{id:E.id}}}catch{}return{id:Q}}function x(Q,E,W,U){let _=[],N=(G)=>{let O=G.replace(/[^a-zA-Z0-9_-]/g,"_");return(O.length>64?O.slice(0,64):O).replace(/_+$/,"")},A=(G)=>{let O=`fc_${J(G)}`;return O.length>64?O.slice(0,64):O},y=(G,O,Y)=>{if(!W.has(Q.provider))return N(G);if(!G.includes("|"))return N(G);let[H,L]=G.split("|"),$=N(H),D=Y.provider!==Q.provider||Y.api!==Q.api?A(L):N(L);if(!D.startsWith("fc_"))D=N(`fc_${D}`);return`${$}|${D}`},Z=R(E.messages,Q,y);if((U?.includeSystemPrompt??!0)&&E.systemPrompt){let G=Q.reasoning?"developer":"system";_.push({role:G,content:V(E.systemPrompt)})}let q=0;for(let G of Z){if(G.role==="user")if(typeof G.content==="string")_.push({role:"user",content:[{type:"input_text",text:V(G.content)}]});else{let O=G.content.map((Y)=>{if(Y.type==="text")return{type:"input_text",text:V(Y.text)};return{type:"input_image",detail:"auto",image_url:`data:${Y.mimeType};base64,${Y.data}`}});if(O.length===0)continue;_.push({role:"user",content:O})}else if(G.role==="assistant"){let O=[],Y=G,H=Y.model!==Q.id&&Y.provider===Q.provider&&Y.api===Q.api,L=0;for(let $ of G.content)if($.type==="thinking"){if($.thinkingSignature){let X=JSON.parse($.thinkingSignature);O.push(X)}}else if($.type==="text"){let X=$,D=C(X.textSignature),f=L===0?`msg_pi_${q}`:`msg_pi_${q}_${L}`;L++;let F=D?.id;if(!F)F=f;else if(F.length>64)F=`msg_${J(F)}`;O.push({type:"message",role:"assistant",content:[{type:"output_text",text:V(X.text),annotations:[]}],status:"completed",id:F,phase:D?.phase})}else if($.type==="toolCall"){let X=$,[D,f]=X.id.split("|"),F=f;if(H&&F?.startsWith("fc_"))F=void 0;O.push({type:"function_call",id:F,call_id:D,name:X.name,arguments:JSON.stringify(X.arguments)})}if(O.length===0)continue;_.push(...O)}else if(G.role==="toolResult"){let O=G.content.filter((X)=>X.type==="text").map((X)=>X.text).join(`
3
3
  `),Y=G.content.some((X)=>X.type==="image"),H=O.length>0,[L]=G.toolCallId.split("|"),$;if(Y&&Q.input.includes("image")){let X=[];if(H)X.push({type:"input_text",text:V(O)});for(let D of G.content)if(D.type==="image")X.push({type:"input_image",detail:"auto",image_url:`data:${D.mimeType};base64,${D.data}`});$=X}else $=V(H?O:"(see attached image)");_.push({type:"function_call_output",call_id:L,output:$})}q++}return _}function v(Q,E){let W=E?.strict===void 0?!1:E.strict;return Q.map((U)=>({type:"function",name:U.name,description:U.description,parameters:U.parameters,strict:W}))}async function B(Q,E,W,U,_){let N=null,A=null,y=E.content,Z=()=>y.length-1;for await(let K of Q)if(K.type==="response.created")E.responseId=K.response.id;else if(K.type==="response.output_item.added"){let q=K.item;if(q.type==="reasoning")N=q,A={type:"thinking",thinking:""},E.content.push(A),W.push({type:"thinking_start",contentIndex:Z(),partial:E});else if(q.type==="message")N=q,A={type:"text",text:""},E.content.push(A),W.push({type:"text_start",contentIndex:Z(),partial:E});else if(q.type==="function_call")N=q,A={type:"toolCall",id:`${q.call_id}|${q.id}`,name:q.name,arguments:{},partialJson:q.arguments||""},E.content.push(A),W.push({type:"toolcall_start",contentIndex:Z(),partial:E})}else if(K.type==="response.reasoning_summary_part.added"){if(N&&N.type==="reasoning")N.summary=N.summary||[],N.summary.push(K.part)}else if(K.type==="response.reasoning_summary_text.delta"){if(N?.type==="reasoning"&&A?.type==="thinking"){N.summary=N.summary||[];let q=N.summary[N.summary.length-1];if(q)A.thinking+=K.delta,q.text+=K.delta,W.push({type:"thinking_delta",contentIndex:Z(),delta:K.delta,partial:E})}}else if(K.type==="response.reasoning_summary_part.done"){if(N?.type==="reasoning"&&A?.type==="thinking"){N.summary=N.summary||[];let q=N.summary[N.summary.length-1];if(q)A.thinking+=`
4
4
 
5
5
  `,q.text+=`
@@ -11,4 +11,4 @@ import{tj as J}from"./chunk-d9haskf5.js";import{yj as w}from"./chunk-30jjvb4k.js
11
11
  `)||"",O=q.content?.map((Y)=>Y.text).join(`
12
12
 
13
13
  `)||"";A.thinking=G||O||A.thinking,A.thinkingSignature=JSON.stringify(q),W.push({type:"thinking_end",contentIndex:Z(),content:A.thinking,partial:E}),A=null}else if(q.type==="message"&&A?.type==="text")A.text=q.content.map((G)=>G.type==="output_text"?G.text:G.refusal).join(""),A.textSignature=M(q.id,q.phase??void 0),W.push({type:"text_end",contentIndex:Z(),content:A.text,partial:E}),A=null;else if(q.type==="function_call"){let G=A?.type==="toolCall"&&A.partialJson?w(A.partialJson):w(q.arguments||"{}"),O;if(A?.type==="toolCall")A.arguments=G,delete A.partialJson,O=A;else O={type:"toolCall",id:`${q.call_id}|${q.id}`,name:q.name,arguments:G};A=null,W.push({type:"toolcall_end",contentIndex:Z(),toolCall:O,partial:E})}}else if(K.type==="response.completed"){let q=K.response;if(q?.id)E.responseId=q.id;if(q?.usage){let G=q.usage.input_tokens_details?.cached_tokens||0;E.usage={input:(q.usage.input_tokens||0)-G,output:q.usage.output_tokens||0,cacheRead:G,cacheWrite:0,totalTokens:q.usage.total_tokens||0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}}}if(j(U,E.usage),_?.applyServiceTierPricing){let G=_.resolveServiceTier?_.resolveServiceTier(q?.service_tier,_.serviceTier):q?.service_tier??_.serviceTier;_.applyServiceTierPricing(E.usage,G)}if(E.stopReason=T(q?.status),E.content.some((G)=>G.type==="toolCall")&&E.stopReason==="stop")E.stopReason="toolUse"}else if(K.type==="error")throw Error(`Error Code ${K.code}: ${K.message}`||"Unknown error");else if(K.type==="response.failed"){let q=K.response?.error,G=K.response?.incomplete_details,O=q?`${q.code||"unknown"}: ${q.message||"no message"}`:G?.reason?`incomplete: ${G.reason}`:"Unknown error (no error details in response)";throw Error(O)}}function T(Q){if(!Q)return"stop";switch(Q){case"completed":return"stop";case"incomplete":return"length";case"failed":case"cancelled":return"error";case"in_progress":case"queued":return"stop";default:throw Error(`Unhandled stop reason: ${Q}`)}}
14
- export{x as qj,v as rj,B as sj};
14
+ export{x as wj,v as xj,B as yj};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{jb as T,kb as C,lb as L}from"./chunk-kc7vcfch.js";import"./chunk-1dvam047.js";import{nb as S}from"./chunk-dvgxj01x.js";import{ob as M}from"./chunk-k4pa97ny.js";import{vb as D}from"./chunk-qggykya7.js";import"./chunk-gda70q5n.js";import"./chunk-5ev6gvcw.js";import{he as V,ie as f}from"./chunk-5mvvjqcp.js";import{je as F}from"./chunk-08hwazz9.js";import{wj as k}from"./chunk-23ps0bkk.js";import"./chunk-0zpc9pkt.js";import"./chunk-nz95b2c5.js";var B="v1",E=new Set(["openai","openai-codex","opencode","azure-openai-responses"]);function I(G){let Q=new Map;if(!G)return Q;for(let w of G.split(",")){let W=w.trim();if(!W)continue;let[X,J]=W.split("=",2);if(!X||!J)continue;Q.set(X.trim(),J.trim())}return Q}function P(G,Q){if(Q?.azureDeploymentName)return Q.azureDeploymentName;return I(process.env.AZURE_OPENAI_DEPLOYMENT_NAME_MAP).get(G.id)||G.id}function g(G){if(G instanceof Error){let Q=G.status,w=typeof Q==="number"?Q:void 0;if(w!==void 0)return`Azure OpenAI API error (${w}): ${G.message}`;return G.message}try{return JSON.stringify(G)}catch{return String(G)}}var O=(G,Q,w)=>{let W=new f;return(async()=>{let X=P(G,w),J={role:"assistant",content:[],api:"azure-openai-responses",provider:G.provider,model:G.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 Y=w?.apiKey||F(G.provider)||"",$=K(G,Y,w),q=N(G,Q,w,X),H=await w?.onPayload?.(q,G);if(H!==void 0)q=H;let _={...w?.signal?{signal:w.signal}:{},...w?.timeoutMs!==void 0?{timeout:w.timeoutMs}:{},...w?.maxRetries!==void 0?{maxRetries:w.maxRetries}:{}},{data:j,response:Z}=await $.responses.create(q,_).withResponse();if(await w?.onResponse?.({status:Z.status,headers:M(Z.headers)},G),W.push({type:"start",partial:J}),await L(j,J,W,G),w?.signal?.aborted)throw Error("Request was aborted");if(J.stopReason==="aborted"||J.stopReason==="error")throw Error("An unknown error occurred");W.push({type:"done",reason:J.stopReason,message:J}),W.end()}catch(Y){for(let $ of J.content)delete $.index,delete $.partialJson;J.stopReason=w?.signal?.aborted?"aborted":"error",J.errorMessage=g(Y),W.push({type:"error",reason:J.stopReason,error:J}),W.end()}})(),W},d=(G,Q,w)=>{let W=w?.apiKey||F(G.provider);if(!W)throw Error(`No API key for provider: ${G.provider}`);let X=D(G,w,W),J=w?.reasoning?V(G,w.reasoning):void 0;return O(G,Q,{...X,reasoningEffort:J==="off"?void 0:J})};function h(G){let Q=G.trim().replace(/\/+$/,""),w;try{w=new URL(Q)}catch{throw Error(`Invalid Azure OpenAI base URL: ${G}`)}let W=w.hostname.endsWith(".openai.azure.com")||w.hostname.endsWith(".cognitiveservices.azure.com"),X=w.pathname.replace(/\/+$/,"");if(W&&(X===""||X==="/"||X==="/openai"))w.pathname="/openai/v1",w.search="";return w.toString().replace(/\/+$/,"")}function z(G){return`https://${G}.openai.azure.com/openai/v1`}function b(G,Q){let w=Q?.azureApiVersion||process.env.AZURE_OPENAI_API_VERSION||B,W=Q?.azureBaseUrl?.trim()||process.env.AZURE_OPENAI_BASE_URL?.trim()||void 0,X=Q?.azureResourceName||process.env.AZURE_OPENAI_RESOURCE_NAME,J=W;if(!J&&X)J=z(X);if(!J&&G.baseUrl)J=G.baseUrl;if(!J)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:h(J),apiVersion:w}}function K(G,Q,w){if(!Q){if(!process.env.AZURE_OPENAI_API_KEY)throw Error("Azure OpenAI API key is required. Set AZURE_OPENAI_API_KEY environment variable or pass it as an argument.");Q=process.env.AZURE_OPENAI_API_KEY}let W={...G.headers};if(w?.headers)Object.assign(W,w.headers);let{baseUrl:X,apiVersion:J}=b(G,w);return new k({apiKey:Q,apiVersion:J,dangerouslyAllowBrowser:!0,defaultHeaders:W,baseURL:X})}function N(G,Q,w,W){let X=T(G,Q,E),J={model:W,input:X,stream:!0,prompt_cache_key:S(w?.sessionId)};if(w?.maxTokens)J.max_output_tokens=w?.maxTokens;if(w?.temperature!==void 0)J.temperature=w?.temperature;if(Q.tools&&Q.tools.length>0)J.tools=C(Q.tools);if(G.reasoning){if(w?.reasoningEffort||w?.reasoningSummary){let Y=w?.reasoningEffort?G.thinkingLevelMap?.[w.reasoningEffort]??w.reasoningEffort:"medium";J.reasoning={effort:Y,summary:w?.reasoningSummary||"auto"},J.include=["reasoning.encrypted_content"]}else if(G.thinkingLevelMap?.off!==null)J.reasoning={effort:G.thinkingLevelMap?.off??"none"}}return J}export{d as streamSimpleAzureOpenAIResponses,O as streamAzureOpenAIResponses};
2
+ import{lb as T,mb as C,nb as L}from"./chunk-2vs3evc7.js";import"./chunk-dypsm6m2.js";import{pb as S}from"./chunk-9n0etqsy.js";import{qb as M}from"./chunk-7ddaxdpf.js";import{xb as D}from"./chunk-0at8vxt5.js";import"./chunk-22dje1f5.js";import"./chunk-wv4fe1fj.js";import{je as V,ke as f}from"./chunk-7rhjej0x.js";import{le as F}from"./chunk-n6jgyv4y.js";import{Cj as k}from"./chunk-w4y97tzy.js";import"./chunk-yhj8c5re.js";import"./chunk-kbzm1pwx.js";var B="v1",E=new Set(["openai","openai-codex","opencode","azure-openai-responses"]);function I(G){let Q=new Map;if(!G)return Q;for(let w of G.split(",")){let W=w.trim();if(!W)continue;let[X,J]=W.split("=",2);if(!X||!J)continue;Q.set(X.trim(),J.trim())}return Q}function P(G,Q){if(Q?.azureDeploymentName)return Q.azureDeploymentName;return I(process.env.AZURE_OPENAI_DEPLOYMENT_NAME_MAP).get(G.id)||G.id}function g(G){if(G instanceof Error){let Q=G.status,w=typeof Q==="number"?Q:void 0;if(w!==void 0)return`Azure OpenAI API error (${w}): ${G.message}`;return G.message}try{return JSON.stringify(G)}catch{return String(G)}}var O=(G,Q,w)=>{let W=new f;return(async()=>{let X=P(G,w),J={role:"assistant",content:[],api:"azure-openai-responses",provider:G.provider,model:G.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 Y=w?.apiKey||F(G.provider)||"",$=K(G,Y,w),q=N(G,Q,w,X),H=await w?.onPayload?.(q,G);if(H!==void 0)q=H;let _={...w?.signal?{signal:w.signal}:{},...w?.timeoutMs!==void 0?{timeout:w.timeoutMs}:{},...w?.maxRetries!==void 0?{maxRetries:w.maxRetries}:{}},{data:j,response:Z}=await $.responses.create(q,_).withResponse();if(await w?.onResponse?.({status:Z.status,headers:M(Z.headers)},G),W.push({type:"start",partial:J}),await L(j,J,W,G),w?.signal?.aborted)throw Error("Request was aborted");if(J.stopReason==="aborted"||J.stopReason==="error")throw Error("An unknown error occurred");W.push({type:"done",reason:J.stopReason,message:J}),W.end()}catch(Y){for(let $ of J.content)delete $.index,delete $.partialJson;J.stopReason=w?.signal?.aborted?"aborted":"error",J.errorMessage=g(Y),W.push({type:"error",reason:J.stopReason,error:J}),W.end()}})(),W},d=(G,Q,w)=>{let W=w?.apiKey||F(G.provider);if(!W)throw Error(`No API key for provider: ${G.provider}`);let X=D(G,w,W),J=w?.reasoning?V(G,w.reasoning):void 0;return O(G,Q,{...X,reasoningEffort:J==="off"?void 0:J})};function h(G){let Q=G.trim().replace(/\/+$/,""),w;try{w=new URL(Q)}catch{throw Error(`Invalid Azure OpenAI base URL: ${G}`)}let W=w.hostname.endsWith(".openai.azure.com")||w.hostname.endsWith(".cognitiveservices.azure.com"),X=w.pathname.replace(/\/+$/,"");if(W&&(X===""||X==="/"||X==="/openai"))w.pathname="/openai/v1",w.search="";return w.toString().replace(/\/+$/,"")}function z(G){return`https://${G}.openai.azure.com/openai/v1`}function b(G,Q){let w=Q?.azureApiVersion||process.env.AZURE_OPENAI_API_VERSION||B,W=Q?.azureBaseUrl?.trim()||process.env.AZURE_OPENAI_BASE_URL?.trim()||void 0,X=Q?.azureResourceName||process.env.AZURE_OPENAI_RESOURCE_NAME,J=W;if(!J&&X)J=z(X);if(!J&&G.baseUrl)J=G.baseUrl;if(!J)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:h(J),apiVersion:w}}function K(G,Q,w){if(!Q){if(!process.env.AZURE_OPENAI_API_KEY)throw Error("Azure OpenAI API key is required. Set AZURE_OPENAI_API_KEY environment variable or pass it as an argument.");Q=process.env.AZURE_OPENAI_API_KEY}let W={...G.headers};if(w?.headers)Object.assign(W,w.headers);let{baseUrl:X,apiVersion:J}=b(G,w);return new k({apiKey:Q,apiVersion:J,dangerouslyAllowBrowser:!0,defaultHeaders:W,baseURL:X})}function N(G,Q,w,W){let X=T(G,Q,E),J={model:W,input:X,stream:!0,prompt_cache_key:S(w?.sessionId)};if(w?.maxTokens)J.max_output_tokens=w?.maxTokens;if(w?.temperature!==void 0)J.temperature=w?.temperature;if(Q.tools&&Q.tools.length>0)J.tools=C(Q.tools);if(G.reasoning){if(w?.reasoningEffort||w?.reasoningSummary){let Y=w?.reasoningEffort?G.thinkingLevelMap?.[w.reasoningEffort]??w.reasoningEffort:"medium";J.reasoning={effort:Y,summary:w?.reasoningSummary||"auto"},J.include=["reasoning.encrypted_content"]}else if(G.thinkingLevelMap?.off!==null)J.reasoning={effort:G.thinkingLevelMap?.off??"none"}}return J}export{d as streamSimpleAzureOpenAIResponses,O as streamAzureOpenAIResponses};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import"./chunk-xg9xscqz.js";import{Tb as I,jc as w}from"./chunk-a70x1w8e.js";import"./chunk-nz95b2c5.js";function R(q,$){if(typeof q==="string"&&typeof $==="string")return q.toLowerCase()===$.toLowerCase();return q===$}function y(q,$){if(typeof q!=="string")return $.includes(q);return $.some((E)=>typeof E==="string"&&q.toLowerCase()===E.toLowerCase())}function j(q,$){return!y(q,$)}function g(q,$){if(typeof q!=="string"||typeof $!=="string")return!1;return q.toLowerCase().includes($.toLowerCase())}function f(q,$){if(typeof q!=="string"||typeof $!=="string")return!1;return q.toLowerCase().startsWith($.toLowerCase())}function V(q,$){if(typeof q!=="string"||typeof $!=="string")return!1;return q.toLowerCase().endsWith($.toLowerCase())}var v=(q,$)=>{let E=null,M=w({config:{adapterId:"memory",adapterName:"Memory Adapter",usePlural:!1,debugLogs:$?.debugLogs||!1,supportsArrays:!0,customTransformInput(P){if(P.options.advanced?.database?.generateId==="serial"&&P.field==="id"&&P.action==="create")return q[P.model].length+1;return P.data},transaction:async(P)=>{let A=structuredClone(q);try{return await P(M(E))}catch(_){throw Object.keys(q).forEach((S)=>{q[S]=A[S]}),_}}},adapter:({getFieldName:P,getDefaultFieldName:A,options:_,getModelName:S})=>{let N=(x,K,Y)=>{if(!K)return x;return x.sort((L,Z)=>{let z=P({model:Y,field:K.field}),D=L[z],X=Z[z],Q=0;if(D==null&&X==null)Q=0;else if(D==null)Q=-1;else if(X==null)Q=1;else if(typeof D==="string"&&typeof X==="string")Q=D.localeCompare(X);else if(D instanceof Date&&X instanceof Date)Q=D.getTime()-X.getTime();else if(typeof D==="number"&&typeof X==="number")Q=D-X;else if(typeof D==="boolean"&&typeof X==="boolean")Q=D===X?0:D?1:-1;else Q=String(D).localeCompare(String(X));return K.direction==="asc"?Q:-Q})};function F(x,K,Y,L){let Z=(()=>{let X=q[K];if(!X)throw I.error(`[MemoryAdapter] Model ${K} not found in the DB`,Object.keys(q)),Error(`Model ${K} not found`);let Q=(G,O)=>{let{field:J,value:H,operator:B,mode:k="sensitive"}=O,U=k==="insensitive"&&(typeof H==="string"||Array.isArray(H)&&H.every((W)=>typeof W==="string"));switch(B){case"in":if(!Array.isArray(H))throw Error("Value must be an array");if(U)return y(G[J],H);return H.includes(G[J]);case"not_in":if(!Array.isArray(H))throw Error("Value must be an array");if(U)return j(G[J],H);return!H.includes(G[J]);case"contains":if(U)return g(G[J],H);return G[J]?.includes(H);case"starts_with":if(U)return f(G[J],H);return G[J].startsWith(H);case"ends_with":if(U)return V(G[J],H);return G[J].endsWith(H);case"ne":return U?!R(G[J],H):G[J]!==H;case"gt":return H!=null&&Boolean(G[J]>H);case"gte":return H!=null&&Boolean(G[J]>=H);case"lt":return H!=null&&Boolean(G[J]<H);case"lte":return H!=null&&Boolean(G[J]<=H);default:if(U)return R(G[J],H);if(H===null)return G[J]==null;return G[J]===H}},T=X.filter((G)=>{if(!x.length||x.length===0)return!0;let O=Q(G,x[0]);for(let J of x){let H=Q(G,J);if(J.connector==="OR")O=O||H;else O=O&&H}return O});if(L?.length&&L.length>0)T=T.map((G)=>Object.fromEntries(Object.entries(G).filter(([O])=>L.includes(A({model:K,field:O})))));return T})();if(!Y)return Z;let z=new Map,D=new Map;for(let X of Z){let Q=String(X.id);if(!z.has(Q)){let G={...X};for(let[O,J]of Object.entries(Y)){let H=S(O);if(J.relation==="one-to-one")G[H]=null;else G[H]=[],D.set(`${Q}-${O}`,new Set)}z.set(Q,G)}let T=z.get(Q);for(let[G,O]of Object.entries(Y)){let J=S(G),H=q[J];if(!H)throw I.error(`[MemoryAdapter] JoinOption model ${J} not found in the DB`,Object.keys(q)),Error(`JoinOption model ${J} not found`);let B=H.filter((k)=>k[O.on.to]===X[O.on.from]);if(O.relation==="one-to-one")T[J]=B[0]||null;else{let k=D.get(`${Q}-${G}`),U=O.limit??100,W=0;for(let C of B){if(W>=U)break;if(!k.has(C.id))T[J].push(C),k.add(C.id),W++}}}}return Array.from(z.values())}return{create:async({model:x,data:K})=>{if(_.advanced?.database?.generateId==="serial")K.id=q[S(x)].length+1;if(!q[x])q[x]=[];return q[x].push(K),K},findOne:async({model:x,where:K,select:Y,join:L})=>{let Z=F(K,x,L,Y);if(L){let z=Z;if(!z.length)return null;return z[0]}return Z[0]||null},findMany:async({model:x,where:K,sortBy:Y,limit:L,select:Z,offset:z,join:D})=>{let X=F(K||[],x,D,Z);if(D){let T=X;if(!T.length)return[];N(T,Y,x);let G=T;if(z!==void 0)G=G.slice(z);if(L!==void 0)G=G.slice(0,L);return G}let Q=N(X,Y,x);if(z!==void 0)Q=Q.slice(z);if(L!==void 0)Q=Q.slice(0,L);return Q||[]},count:async({model:x,where:K})=>{if(K)return F(K,x).length;return q[x].length},update:async({model:x,where:K,update:Y})=>{let L=F(K,x);return L.forEach((Z)=>{Object.assign(Z,Y)}),L[0]||null},delete:async({model:x,where:K})=>{let Y=q[x],L=F(K,x);q[x]=Y.filter((Z)=>!L.includes(Z))},deleteMany:async({model:x,where:K})=>{let Y=q[x],L=F(K,x),Z=0;return q[x]=Y.filter((z)=>{if(L.includes(z))return Z++,!1;return!L.includes(z)}),Z},consumeOne:async({model:x,where:K})=>{let Y=q[x],L=F(K,x)[0];if(!L)return null;return q[x]=Y.filter((Z)=>Z!==L),L},updateMany({model:x,where:K,update:Y}){let L=F(K,x);return L.forEach((Z)=>{Object.assign(Z,Y)}),L[0]||null}}}});return(P)=>{return E=P,M(P)}};export{v as memoryAdapter};
2
+ import"./chunk-xg9xscqz.js";import{Vb as I,lc as w}from"./chunk-ac2ky3q0.js";import"./chunk-kbzm1pwx.js";function R(q,$){if(typeof q==="string"&&typeof $==="string")return q.toLowerCase()===$.toLowerCase();return q===$}function y(q,$){if(typeof q!=="string")return $.includes(q);return $.some((E)=>typeof E==="string"&&q.toLowerCase()===E.toLowerCase())}function j(q,$){return!y(q,$)}function g(q,$){if(typeof q!=="string"||typeof $!=="string")return!1;return q.toLowerCase().includes($.toLowerCase())}function f(q,$){if(typeof q!=="string"||typeof $!=="string")return!1;return q.toLowerCase().startsWith($.toLowerCase())}function V(q,$){if(typeof q!=="string"||typeof $!=="string")return!1;return q.toLowerCase().endsWith($.toLowerCase())}var v=(q,$)=>{let E=null,M=w({config:{adapterId:"memory",adapterName:"Memory Adapter",usePlural:!1,debugLogs:$?.debugLogs||!1,supportsArrays:!0,customTransformInput(P){if(P.options.advanced?.database?.generateId==="serial"&&P.field==="id"&&P.action==="create")return q[P.model].length+1;return P.data},transaction:async(P)=>{let A=structuredClone(q);try{return await P(M(E))}catch(_){throw Object.keys(q).forEach((S)=>{q[S]=A[S]}),_}}},adapter:({getFieldName:P,getDefaultFieldName:A,options:_,getModelName:S})=>{let N=(x,K,Y)=>{if(!K)return x;return x.sort((L,Z)=>{let z=P({model:Y,field:K.field}),D=L[z],X=Z[z],Q=0;if(D==null&&X==null)Q=0;else if(D==null)Q=-1;else if(X==null)Q=1;else if(typeof D==="string"&&typeof X==="string")Q=D.localeCompare(X);else if(D instanceof Date&&X instanceof Date)Q=D.getTime()-X.getTime();else if(typeof D==="number"&&typeof X==="number")Q=D-X;else if(typeof D==="boolean"&&typeof X==="boolean")Q=D===X?0:D?1:-1;else Q=String(D).localeCompare(String(X));return K.direction==="asc"?Q:-Q})};function F(x,K,Y,L){let Z=(()=>{let X=q[K];if(!X)throw I.error(`[MemoryAdapter] Model ${K} not found in the DB`,Object.keys(q)),Error(`Model ${K} not found`);let Q=(G,O)=>{let{field:J,value:H,operator:B,mode:k="sensitive"}=O,U=k==="insensitive"&&(typeof H==="string"||Array.isArray(H)&&H.every((W)=>typeof W==="string"));switch(B){case"in":if(!Array.isArray(H))throw Error("Value must be an array");if(U)return y(G[J],H);return H.includes(G[J]);case"not_in":if(!Array.isArray(H))throw Error("Value must be an array");if(U)return j(G[J],H);return!H.includes(G[J]);case"contains":if(U)return g(G[J],H);return G[J]?.includes(H);case"starts_with":if(U)return f(G[J],H);return G[J].startsWith(H);case"ends_with":if(U)return V(G[J],H);return G[J].endsWith(H);case"ne":return U?!R(G[J],H):G[J]!==H;case"gt":return H!=null&&Boolean(G[J]>H);case"gte":return H!=null&&Boolean(G[J]>=H);case"lt":return H!=null&&Boolean(G[J]<H);case"lte":return H!=null&&Boolean(G[J]<=H);default:if(U)return R(G[J],H);if(H===null)return G[J]==null;return G[J]===H}},T=X.filter((G)=>{if(!x.length||x.length===0)return!0;let O=Q(G,x[0]);for(let J of x){let H=Q(G,J);if(J.connector==="OR")O=O||H;else O=O&&H}return O});if(L?.length&&L.length>0)T=T.map((G)=>Object.fromEntries(Object.entries(G).filter(([O])=>L.includes(A({model:K,field:O})))));return T})();if(!Y)return Z;let z=new Map,D=new Map;for(let X of Z){let Q=String(X.id);if(!z.has(Q)){let G={...X};for(let[O,J]of Object.entries(Y)){let H=S(O);if(J.relation==="one-to-one")G[H]=null;else G[H]=[],D.set(`${Q}-${O}`,new Set)}z.set(Q,G)}let T=z.get(Q);for(let[G,O]of Object.entries(Y)){let J=S(G),H=q[J];if(!H)throw I.error(`[MemoryAdapter] JoinOption model ${J} not found in the DB`,Object.keys(q)),Error(`JoinOption model ${J} not found`);let B=H.filter((k)=>k[O.on.to]===X[O.on.from]);if(O.relation==="one-to-one")T[J]=B[0]||null;else{let k=D.get(`${Q}-${G}`),U=O.limit??100,W=0;for(let C of B){if(W>=U)break;if(!k.has(C.id))T[J].push(C),k.add(C.id),W++}}}}return Array.from(z.values())}return{create:async({model:x,data:K})=>{if(_.advanced?.database?.generateId==="serial")K.id=q[S(x)].length+1;if(!q[x])q[x]=[];return q[x].push(K),K},findOne:async({model:x,where:K,select:Y,join:L})=>{let Z=F(K,x,L,Y);if(L){let z=Z;if(!z.length)return null;return z[0]}return Z[0]||null},findMany:async({model:x,where:K,sortBy:Y,limit:L,select:Z,offset:z,join:D})=>{let X=F(K||[],x,D,Z);if(D){let T=X;if(!T.length)return[];N(T,Y,x);let G=T;if(z!==void 0)G=G.slice(z);if(L!==void 0)G=G.slice(0,L);return G}let Q=N(X,Y,x);if(z!==void 0)Q=Q.slice(z);if(L!==void 0)Q=Q.slice(0,L);return Q||[]},count:async({model:x,where:K})=>{if(K)return F(K,x).length;return q[x].length},update:async({model:x,where:K,update:Y})=>{let L=F(K,x);return L.forEach((Z)=>{Object.assign(Z,Y)}),L[0]||null},delete:async({model:x,where:K})=>{let Y=q[x],L=F(K,x);q[x]=Y.filter((Z)=>!L.includes(Z))},deleteMany:async({model:x,where:K})=>{let Y=q[x],L=F(K,x),Z=0;return q[x]=Y.filter((z)=>{if(L.includes(z))return Z++,!1;return!L.includes(z)}),Z},consumeOne:async({model:x,where:K})=>{let Y=q[x],L=F(K,x)[0];if(!L)return null;return q[x]=Y.filter((Z)=>Z!==L),L},updateMany({model:x,where:K,update:Y}){let L=F(K,x);return L.forEach((Z)=>{Object.assign(Z,Y)}),L[0]||null}}}});return(P)=>{return E=P,M(P)}};export{v as memoryAdapter};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{mb as f}from"./chunk-1dvam047.js";import{xb as j}from"./chunk-qggykya7.js";import{yb as U}from"./chunk-gda70q5n.js";import{ee as H}from"./chunk-5ev6gvcw.js";import{ge as J}from"./chunk-5mvvjqcp.js";function M(Q,E){let W={v:1,id:Q};if(E)W.phase=E;return JSON.stringify(W)}function R(Q){if(!Q)return;if(Q.startsWith("{"))try{let E=JSON.parse(Q);if(E.v===1&&typeof E.id==="string"){if(E.phase==="commentary"||E.phase==="final_answer")return{id:E.id,phase:E.phase};return{id:E.id}}}catch{}return{id:Q}}function b(Q,E,W,L){let D=[],N=(G)=>{let O=G.replace(/[^a-zA-Z0-9_-]/g,"_");return(O.length>64?O.slice(0,64):O).replace(/_+$/,"")},A=(G)=>{let O=`fc_${f(G)}`;return O.length>64?O.slice(0,64):O},w=(G,O,X)=>{if(!W.has(Q.provider))return N(G);if(!G.includes("|"))return N(G);let[V,F]=G.split("|"),$=N(V),Y=X.provider!==Q.provider||X.api!==Q.api?A(F):N(F);if(!Y.startsWith("fc_"))Y=N(`fc_${Y}`);return`${$}|${Y}`},Z=j(E.messages,Q,w);if((L?.includeSystemPrompt??!0)&&E.systemPrompt){let G=Q.reasoning?"developer":"system";D.push({role:G,content:U(E.systemPrompt)})}let q=0;for(let G of Z){if(G.role==="user")if(typeof G.content==="string")D.push({role:"user",content:[{type:"input_text",text:U(G.content)}]});else{let O=G.content.map((X)=>{if(X.type==="text")return{type:"input_text",text:U(X.text)};return{type:"input_image",detail:"auto",image_url:`data:${X.mimeType};base64,${X.data}`}});if(O.length===0)continue;D.push({role:"user",content:O})}else if(G.role==="assistant"){let O=[],X=G,V=X.model!==Q.id&&X.provider===Q.provider&&X.api===Q.api;for(let F of G.content)if(F.type==="thinking"){if(F.thinkingSignature){let $=JSON.parse(F.thinkingSignature);O.push($)}}else if(F.type==="text"){let $=F,_=R($.textSignature),Y=_?.id;if(!Y)Y=`msg_${q}`;else if(Y.length>64)Y=`msg_${f(Y)}`;O.push({type:"message",role:"assistant",content:[{type:"output_text",text:U($.text),annotations:[]}],status:"completed",id:Y,phase:_?.phase})}else if(F.type==="toolCall"){let $=F,[_,Y]=$.id.split("|"),y=Y;if(V&&y?.startsWith("fc_"))y=void 0;O.push({type:"function_call",id:y,call_id:_,name:$.name,arguments:JSON.stringify($.arguments)})}if(O.length===0)continue;D.push(...O)}else if(G.role==="toolResult"){let O=G.content.filter((_)=>_.type==="text").map((_)=>_.text).join(`
2
+ import{ob as f}from"./chunk-dypsm6m2.js";import{zb as j}from"./chunk-0at8vxt5.js";import{Ab as U}from"./chunk-22dje1f5.js";import{ge as H}from"./chunk-wv4fe1fj.js";import{ie as J}from"./chunk-7rhjej0x.js";function M(Q,E){let W={v:1,id:Q};if(E)W.phase=E;return JSON.stringify(W)}function R(Q){if(!Q)return;if(Q.startsWith("{"))try{let E=JSON.parse(Q);if(E.v===1&&typeof E.id==="string"){if(E.phase==="commentary"||E.phase==="final_answer")return{id:E.id,phase:E.phase};return{id:E.id}}}catch{}return{id:Q}}function b(Q,E,W,L){let D=[],N=(G)=>{let O=G.replace(/[^a-zA-Z0-9_-]/g,"_");return(O.length>64?O.slice(0,64):O).replace(/_+$/,"")},A=(G)=>{let O=`fc_${f(G)}`;return O.length>64?O.slice(0,64):O},w=(G,O,X)=>{if(!W.has(Q.provider))return N(G);if(!G.includes("|"))return N(G);let[V,F]=G.split("|"),$=N(V),Y=X.provider!==Q.provider||X.api!==Q.api?A(F):N(F);if(!Y.startsWith("fc_"))Y=N(`fc_${Y}`);return`${$}|${Y}`},Z=j(E.messages,Q,w);if((L?.includeSystemPrompt??!0)&&E.systemPrompt){let G=Q.reasoning?"developer":"system";D.push({role:G,content:U(E.systemPrompt)})}let q=0;for(let G of Z){if(G.role==="user")if(typeof G.content==="string")D.push({role:"user",content:[{type:"input_text",text:U(G.content)}]});else{let O=G.content.map((X)=>{if(X.type==="text")return{type:"input_text",text:U(X.text)};return{type:"input_image",detail:"auto",image_url:`data:${X.mimeType};base64,${X.data}`}});if(O.length===0)continue;D.push({role:"user",content:O})}else if(G.role==="assistant"){let O=[],X=G,V=X.model!==Q.id&&X.provider===Q.provider&&X.api===Q.api;for(let F of G.content)if(F.type==="thinking"){if(F.thinkingSignature){let $=JSON.parse(F.thinkingSignature);O.push($)}}else if(F.type==="text"){let $=F,_=R($.textSignature),Y=_?.id;if(!Y)Y=`msg_${q}`;else if(Y.length>64)Y=`msg_${f(Y)}`;O.push({type:"message",role:"assistant",content:[{type:"output_text",text:U($.text),annotations:[]}],status:"completed",id:Y,phase:_?.phase})}else if(F.type==="toolCall"){let $=F,[_,Y]=$.id.split("|"),y=Y;if(V&&y?.startsWith("fc_"))y=void 0;O.push({type:"function_call",id:y,call_id:_,name:$.name,arguments:JSON.stringify($.arguments)})}if(O.length===0)continue;D.push(...O)}else if(G.role==="toolResult"){let O=G.content.filter((_)=>_.type==="text").map((_)=>_.text).join(`
3
3
  `),X=G.content.some((_)=>_.type==="image"),V=O.length>0,[F]=G.toolCallId.split("|"),$;if(X&&Q.input.includes("image")){let _=[];if(V)_.push({type:"input_text",text:U(O)});for(let Y of G.content)if(Y.type==="image")_.push({type:"input_image",detail:"auto",image_url:`data:${Y.mimeType};base64,${Y.data}`});$=_}else $=U(V?O:"(see attached image)");D.push({type:"function_call_output",call_id:F,output:$})}q++}return D}function x(Q,E){let W=E?.strict===void 0?!1:E.strict;return Q.map((L)=>({type:"function",name:L.name,description:L.description,parameters:L.parameters,strict:W}))}async function B(Q,E,W,L,D){let N=null,A=null,w=E.content,Z=()=>w.length-1;for await(let K of Q)if(K.type==="response.created")E.responseId=K.response.id;else if(K.type==="response.output_item.added"){let q=K.item;if(q.type==="reasoning")N=q,A={type:"thinking",thinking:""},E.content.push(A),W.push({type:"thinking_start",contentIndex:Z(),partial:E});else if(q.type==="message")N=q,A={type:"text",text:""},E.content.push(A),W.push({type:"text_start",contentIndex:Z(),partial:E});else if(q.type==="function_call")N=q,A={type:"toolCall",id:`${q.call_id}|${q.id}`,name:q.name,arguments:{},partialJson:q.arguments||""},E.content.push(A),W.push({type:"toolcall_start",contentIndex:Z(),partial:E})}else if(K.type==="response.reasoning_summary_part.added"){if(N&&N.type==="reasoning")N.summary=N.summary||[],N.summary.push(K.part)}else if(K.type==="response.reasoning_summary_text.delta"){if(N?.type==="reasoning"&&A?.type==="thinking"){N.summary=N.summary||[];let q=N.summary[N.summary.length-1];if(q)A.thinking+=K.delta,q.text+=K.delta,W.push({type:"thinking_delta",contentIndex:Z(),delta:K.delta,partial:E})}}else if(K.type==="response.reasoning_summary_part.done"){if(N?.type==="reasoning"&&A?.type==="thinking"){N.summary=N.summary||[];let q=N.summary[N.summary.length-1];if(q)A.thinking+=`
4
4
 
5
5
  `,q.text+=`
@@ -11,4 +11,4 @@ import{mb as f}from"./chunk-1dvam047.js";import{xb as j}from"./chunk-qggykya7.js
11
11
  `)||"",O=q.content?.map((X)=>X.text).join(`
12
12
 
13
13
  `)||"";A.thinking=G||O||A.thinking,A.thinkingSignature=JSON.stringify(q),W.push({type:"thinking_end",contentIndex:Z(),content:A.thinking,partial:E}),A=null}else if(q.type==="message"&&A?.type==="text")A.text=q.content.map((G)=>G.type==="output_text"?G.text:G.refusal).join(""),A.textSignature=M(q.id,q.phase??void 0),W.push({type:"text_end",contentIndex:Z(),content:A.text,partial:E}),A=null;else if(q.type==="function_call"){let G=A?.type==="toolCall"&&A.partialJson?H(A.partialJson):H(q.arguments||"{}"),O;if(A?.type==="toolCall")A.arguments=G,delete A.partialJson,O=A;else O={type:"toolCall",id:`${q.call_id}|${q.id}`,name:q.name,arguments:G};A=null,W.push({type:"toolcall_end",contentIndex:Z(),toolCall:O,partial:E})}}else if(K.type==="response.completed"){let q=K.response;if(q?.id)E.responseId=q.id;if(q?.usage){let G=q.usage.input_tokens_details?.cached_tokens||0;E.usage={input:(q.usage.input_tokens||0)-G,output:q.usage.output_tokens||0,cacheRead:G,cacheWrite:0,totalTokens:q.usage.total_tokens||0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}}}if(J(L,E.usage),D?.applyServiceTierPricing){let G=D.resolveServiceTier?D.resolveServiceTier(q?.service_tier,D.serviceTier):q?.service_tier??D.serviceTier;D.applyServiceTierPricing(E.usage,G)}if(E.stopReason=C(q?.status),E.content.some((G)=>G.type==="toolCall")&&E.stopReason==="stop")E.stopReason="toolUse"}else if(K.type==="error")throw Error(`Error Code ${K.code}: ${K.message}`||"Unknown error");else if(K.type==="response.failed"){let q=K.response?.error,G=K.response?.incomplete_details,O=q?`${q.code||"unknown"}: ${q.message||"no message"}`:G?.reason?`incomplete: ${G.reason}`:"Unknown error (no error details in response)";throw Error(O)}}function C(Q){if(!Q)return"stop";switch(Q){case"completed":return"stop";case"incomplete":return"length";case"failed":case"cancelled":return"error";case"in_progress":case"queued":return"stop";default:throw Error(`Unhandled stop reason: ${Q}`)}}
14
- export{b as jb,x as kb,B as lb};
14
+ export{b as lb,x as mb,B as nb};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{jb as I,kb as s,lb as k}from"./chunk-kc7vcfch.js";import"./chunk-1dvam047.js";import{nb as o}from"./chunk-dvgxj01x.js";import{ob as b}from"./chunk-k4pa97ny.js";import{vb as t}from"./chunk-qggykya7.js";import"./chunk-gda70q5n.js";import{Fb as e,Gb as f,Hb as NN,Ib as QN}from"./chunk-vfn5aygx.js";import"./chunk-5ev6gvcw.js";import{he as r,ie as n}from"./chunk-5mvvjqcp.js";import{je as g}from"./chunk-08hwazz9.js";import"./chunk-0zpc9pkt.js";import"./chunk-nz95b2c5.js";var zN=function(N,Q){if(typeof N==="string"&&/^\.\.?\//.test(N))return N.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(V,X,Y,Z,G){return X?Q?".jsx":".js":Y&&(!Z||!G)?V:Y+Z+"."+G.toLowerCase()+"js"});return N},B=null,VN=(N)=>import(zN(N)),RN="node:os";if(typeof process<"u"&&(process.versions?.node||process.versions?.bun))VN(RN).then((N)=>{B=N});var KN="https://chatgpt.com/backend-api",ON="https://api.openai.com/auth",x=3,l=1000,XN=new Set(["openai","openai-codex","opencode"]),_N=1009,UN=new Set(["completed","incomplete","failed","cancelled","queued","in_progress"]);function jN(N,Q){if(N===429||N===500||N===502||N===503||N===504)return!0;return/rate.?limit|overloaded|service.?unavailable|upstream.?connect|connection.?refused/i.test(Q)}function p(N,Q){return new Promise((V,X)=>{if(Q?.aborted){X(Error("Request was aborted"));return}let Y=setTimeout(V,N);Q?.addEventListener("abort",()=>{clearTimeout(Y),X(Error("Request was aborted"))})})}var WN=(N,Q,V)=>{let X=new n;return(async()=>{let Y={role:"assistant",content:[],api:"openai-codex-responses",provider:N.provider,model:N.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"stop",timestamp:Date.now()};try{let Z=V?.apiKey||g(N.provider)||"";if(!Z)throw Error(`No API key for provider: ${N.provider}`);let G=pN(Z),$=AN(N,Q,V),F=await V?.onPayload?.($,N);if(F!==void 0)$=F;let L=V?.sessionId||iN(),_=dN(N.headers,V?.headers,G,Z,V?.sessionId),j=aN(N.headers,V?.headers,G,Z,L),J=JSON.stringify($),O=V?.transport||"auto",P=O!=="sse"&&DN(V?.sessionId);if(P)i(V?.sessionId);if(O!=="sse"&&!P){let K=!1;try{if(await cN(HN(N.baseUrl),$,j,Y,X,N,()=>{K=!0},V),V?.signal?.aborted)throw Error("Request was aborted");X.push({type:"done",reason:Y.stopReason,message:Y}),X.end();return}catch(z){if(V?.signal?.aborted||qN(z))throw z;if(QN(Y,NN("provider_transport_failure",z,{configuredTransport:O,fallbackTransport:K?void 0:"sse",eventsEmitted:K,phase:K?"after_message_stream_start":"before_message_stream_start",requestBytes:new TextEncoder().encode(J).byteLength})),SN(V?.sessionId,z),K)throw z;i(V?.sessionId)}}let D,R;for(let K=0;K<=x;K++){if(V?.signal?.aborted)throw Error("Request was aborted");try{if(D=await fetch($N(N.baseUrl),{method:"POST",headers:_,body:J,signal:V?.signal}),await V?.onResponse?.({status:D.status,headers:b(D.headers)},N),D.ok)break;let z=await D.text();if(K<x&&jN(D.status,z)){let q=l*2**K,m=D.headers.get("retry-after-ms");if(m!==null){let A=Number(m);if(Number.isFinite(A))q=Math.max(0,A)}else{let A=D.headers.get("retry-after");if(A){let u=Number(A);if(Number.isFinite(u))q=Math.max(0,u*1000);else{let c=Date.parse(A);if(!Number.isNaN(c))q=Math.max(0,c-Date.now())}}}await p(q,V?.signal);continue}let M=new Response(z,{status:D.status,statusText:D.statusText}),y=await lN(M);throw Error(y.friendlyMessage||y.message)}catch(z){if(z instanceof Error){if(z.name==="AbortError"||z.message==="Request was aborted")throw Error("Request was aborted")}if(R=z instanceof Error?z:Error(String(z)),K<x&&!R.message.includes("usage limit")){let M=l*2**K;await p(M,V?.signal);continue}throw R}}if(!D?.ok)throw R??Error("Failed after retries");if(!D.body)throw Error("No response body");if(X.push({type:"start",partial:Y}),await MN(D,Y,X,N,V),V?.signal?.aborted)throw Error("Request was aborted");X.push({type:"done",reason:Y.stopReason,message:Y}),X.end()}catch(Z){for(let G of Y.content)delete G.partialJson;Y.stopReason=V?.signal?.aborted?"aborted":"error",Y.errorMessage=Z instanceof Error?Z.message:String(Z),X.push({type:"error",reason:Y.stopReason,error:Y}),X.end()}})(),X},XQ=(N,Q,V)=>{let X=V?.apiKey||g(N.provider);if(!X)throw Error(`No API key for provider: ${N.provider}`);let Y=t(N,V,X),Z=V?.reasoning?r(N,V.reasoning):void 0;return WN(N,Q,{...Y,reasoningEffort:Z==="off"?void 0:Z})};function AN(N,Q,V){let X=I(N,Q,XN,{includeSystemPrompt:!1}),Y={model:N.id,store:!1,stream:!0,instructions:Q.systemPrompt||"You are a helpful assistant.",input:X,text:{verbosity:V?.textVerbosity||"low"},include:["reasoning.encrypted_content"],prompt_cache_key:o(V?.sessionId),tool_choice:"auto",parallel_tool_calls:!0};if(V?.temperature!==void 0)Y.temperature=V.temperature;if(V?.serviceTier!==void 0)Y.service_tier=V.serviceTier;if(Q.tools&&Q.tools.length>0)Y.tools=s(Q.tools,{strict:null});if(V?.reasoningEffort!==void 0){let Z=V.reasoningEffort==="none"?N.thinkingLevelMap?.off??"none":N.thinkingLevelMap?.[V.reasoningEffort]??V.reasoningEffort;if(Z!==null)Y.reasoning={effort:Z,summary:V.reasoningSummary??"auto"}}return Y}function BN(N,Q){switch(Q){case"flex":return 0.5;case"priority":return N.id==="gpt-5.5"?2.5:2;default:return 1}}function YN(N,Q,V){let X=BN(V,Q);if(X===1)return;N.cost.input*=X,N.cost.output*=X,N.cost.cacheRead*=X,N.cost.cacheWrite*=X,N.cost.total=N.cost.input+N.cost.output+N.cost.cacheRead+N.cost.cacheWrite}function ZN(N,Q){if(N==="default"&&(Q==="flex"||Q==="priority"))return Q;return N??Q}function $N(N){let V=(N&&N.trim().length>0?N:KN).replace(/\/+$/,"");if(V.endsWith("/codex/responses"))return V;if(V.endsWith("/codex"))return`${V}/responses`;return`${V}/codex/responses`}function HN(N){let Q=new URL($N(N));if(Q.protocol==="https:")Q.protocol="wss:";if(Q.protocol==="http:")Q.protocol="ws:";return Q.toString()}async function MN(N,Q,V,X,Y){await k(GN(TN(N)),Q,V,X,{serviceTier:Y?.serviceTier,resolveServiceTier:ZN,applyServiceTierPricing:(Z,G)=>YN(Z,G,X)})}class C extends Error{code;payload;constructor(N,Q){super(N);this.name="CodexApiError",this.code=Q?.code,this.payload=Q?.payload,this.cause=Q?.cause}}class S extends Error{payload;constructor(N,Q){super(N);this.name="CodexProtocolError",this.payload=Q?.payload,this.cause=Q?.cause}}function qN(N){return N instanceof C||N instanceof S}async function*GN(N){for await(let Q of N){let V=typeof Q.type==="string"?Q.type:void 0;if(!V)continue;if(V==="error"){let X=Q.code||"",Y=Q.message||"";throw new C(`Codex error: ${Y||X||JSON.stringify(Q)}`,{code:X||void 0,payload:Q})}if(V==="response.failed"){let X=Q.response,Y=X?.error?.code,Z=X?.error?.message;throw new C(Z||"Codex response failed",{code:Y,payload:Q})}if(V==="response.done"||V==="response.completed"||V==="response.incomplete"){let X=Q.response,Y=X?{...X,status:wN(X.status)}:X;yield{...Q,type:"response.completed",response:Y};return}yield Q}}function wN(N){if(typeof N!=="string")return;return UN.has(N)?N:void 0}async function*TN(N){if(!N.body)return;let Q=N.body.getReader(),V=new TextDecoder,X="";try{while(!0){let{done:Y,value:Z}=await Q.read();if(Y)break;X+=V.decode(Z,{stream:!0});let G=X.indexOf(`
2
+ import{lb as I,mb as s,nb as k}from"./chunk-2vs3evc7.js";import"./chunk-dypsm6m2.js";import{pb as o}from"./chunk-9n0etqsy.js";import{qb as b}from"./chunk-7ddaxdpf.js";import{xb as t}from"./chunk-0at8vxt5.js";import"./chunk-22dje1f5.js";import{Hb as e,Ib as f,Jb as NN,Kb as QN}from"./chunk-3rt9mnj3.js";import"./chunk-wv4fe1fj.js";import{je as r,ke as n}from"./chunk-7rhjej0x.js";import{le as g}from"./chunk-n6jgyv4y.js";import"./chunk-yhj8c5re.js";import"./chunk-kbzm1pwx.js";var zN=function(N,Q){if(typeof N==="string"&&/^\.\.?\//.test(N))return N.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(V,X,Y,Z,G){return X?Q?".jsx":".js":Y&&(!Z||!G)?V:Y+Z+"."+G.toLowerCase()+"js"});return N},B=null,VN=(N)=>import(zN(N)),RN="node:os";if(typeof process<"u"&&(process.versions?.node||process.versions?.bun))VN(RN).then((N)=>{B=N});var KN="https://chatgpt.com/backend-api",ON="https://api.openai.com/auth",x=3,l=1000,XN=new Set(["openai","openai-codex","opencode"]),_N=1009,UN=new Set(["completed","incomplete","failed","cancelled","queued","in_progress"]);function jN(N,Q){if(N===429||N===500||N===502||N===503||N===504)return!0;return/rate.?limit|overloaded|service.?unavailable|upstream.?connect|connection.?refused/i.test(Q)}function p(N,Q){return new Promise((V,X)=>{if(Q?.aborted){X(Error("Request was aborted"));return}let Y=setTimeout(V,N);Q?.addEventListener("abort",()=>{clearTimeout(Y),X(Error("Request was aborted"))})})}var WN=(N,Q,V)=>{let X=new n;return(async()=>{let Y={role:"assistant",content:[],api:"openai-codex-responses",provider:N.provider,model:N.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"stop",timestamp:Date.now()};try{let Z=V?.apiKey||g(N.provider)||"";if(!Z)throw Error(`No API key for provider: ${N.provider}`);let G=pN(Z),$=AN(N,Q,V),F=await V?.onPayload?.($,N);if(F!==void 0)$=F;let L=V?.sessionId||iN(),_=dN(N.headers,V?.headers,G,Z,V?.sessionId),j=aN(N.headers,V?.headers,G,Z,L),J=JSON.stringify($),O=V?.transport||"auto",P=O!=="sse"&&DN(V?.sessionId);if(P)i(V?.sessionId);if(O!=="sse"&&!P){let K=!1;try{if(await cN(HN(N.baseUrl),$,j,Y,X,N,()=>{K=!0},V),V?.signal?.aborted)throw Error("Request was aborted");X.push({type:"done",reason:Y.stopReason,message:Y}),X.end();return}catch(z){if(V?.signal?.aborted||qN(z))throw z;if(QN(Y,NN("provider_transport_failure",z,{configuredTransport:O,fallbackTransport:K?void 0:"sse",eventsEmitted:K,phase:K?"after_message_stream_start":"before_message_stream_start",requestBytes:new TextEncoder().encode(J).byteLength})),SN(V?.sessionId,z),K)throw z;i(V?.sessionId)}}let D,R;for(let K=0;K<=x;K++){if(V?.signal?.aborted)throw Error("Request was aborted");try{if(D=await fetch($N(N.baseUrl),{method:"POST",headers:_,body:J,signal:V?.signal}),await V?.onResponse?.({status:D.status,headers:b(D.headers)},N),D.ok)break;let z=await D.text();if(K<x&&jN(D.status,z)){let q=l*2**K,m=D.headers.get("retry-after-ms");if(m!==null){let A=Number(m);if(Number.isFinite(A))q=Math.max(0,A)}else{let A=D.headers.get("retry-after");if(A){let u=Number(A);if(Number.isFinite(u))q=Math.max(0,u*1000);else{let c=Date.parse(A);if(!Number.isNaN(c))q=Math.max(0,c-Date.now())}}}await p(q,V?.signal);continue}let M=new Response(z,{status:D.status,statusText:D.statusText}),y=await lN(M);throw Error(y.friendlyMessage||y.message)}catch(z){if(z instanceof Error){if(z.name==="AbortError"||z.message==="Request was aborted")throw Error("Request was aborted")}if(R=z instanceof Error?z:Error(String(z)),K<x&&!R.message.includes("usage limit")){let M=l*2**K;await p(M,V?.signal);continue}throw R}}if(!D?.ok)throw R??Error("Failed after retries");if(!D.body)throw Error("No response body");if(X.push({type:"start",partial:Y}),await MN(D,Y,X,N,V),V?.signal?.aborted)throw Error("Request was aborted");X.push({type:"done",reason:Y.stopReason,message:Y}),X.end()}catch(Z){for(let G of Y.content)delete G.partialJson;Y.stopReason=V?.signal?.aborted?"aborted":"error",Y.errorMessage=Z instanceof Error?Z.message:String(Z),X.push({type:"error",reason:Y.stopReason,error:Y}),X.end()}})(),X},XQ=(N,Q,V)=>{let X=V?.apiKey||g(N.provider);if(!X)throw Error(`No API key for provider: ${N.provider}`);let Y=t(N,V,X),Z=V?.reasoning?r(N,V.reasoning):void 0;return WN(N,Q,{...Y,reasoningEffort:Z==="off"?void 0:Z})};function AN(N,Q,V){let X=I(N,Q,XN,{includeSystemPrompt:!1}),Y={model:N.id,store:!1,stream:!0,instructions:Q.systemPrompt||"You are a helpful assistant.",input:X,text:{verbosity:V?.textVerbosity||"low"},include:["reasoning.encrypted_content"],prompt_cache_key:o(V?.sessionId),tool_choice:"auto",parallel_tool_calls:!0};if(V?.temperature!==void 0)Y.temperature=V.temperature;if(V?.serviceTier!==void 0)Y.service_tier=V.serviceTier;if(Q.tools&&Q.tools.length>0)Y.tools=s(Q.tools,{strict:null});if(V?.reasoningEffort!==void 0){let Z=V.reasoningEffort==="none"?N.thinkingLevelMap?.off??"none":N.thinkingLevelMap?.[V.reasoningEffort]??V.reasoningEffort;if(Z!==null)Y.reasoning={effort:Z,summary:V.reasoningSummary??"auto"}}return Y}function BN(N,Q){switch(Q){case"flex":return 0.5;case"priority":return N.id==="gpt-5.5"?2.5:2;default:return 1}}function YN(N,Q,V){let X=BN(V,Q);if(X===1)return;N.cost.input*=X,N.cost.output*=X,N.cost.cacheRead*=X,N.cost.cacheWrite*=X,N.cost.total=N.cost.input+N.cost.output+N.cost.cacheRead+N.cost.cacheWrite}function ZN(N,Q){if(N==="default"&&(Q==="flex"||Q==="priority"))return Q;return N??Q}function $N(N){let V=(N&&N.trim().length>0?N:KN).replace(/\/+$/,"");if(V.endsWith("/codex/responses"))return V;if(V.endsWith("/codex"))return`${V}/responses`;return`${V}/codex/responses`}function HN(N){let Q=new URL($N(N));if(Q.protocol==="https:")Q.protocol="wss:";if(Q.protocol==="http:")Q.protocol="ws:";return Q.toString()}async function MN(N,Q,V,X,Y){await k(GN(TN(N)),Q,V,X,{serviceTier:Y?.serviceTier,resolveServiceTier:ZN,applyServiceTierPricing:(Z,G)=>YN(Z,G,X)})}class C extends Error{code;payload;constructor(N,Q){super(N);this.name="CodexApiError",this.code=Q?.code,this.payload=Q?.payload,this.cause=Q?.cause}}class S extends Error{payload;constructor(N,Q){super(N);this.name="CodexProtocolError",this.payload=Q?.payload,this.cause=Q?.cause}}function qN(N){return N instanceof C||N instanceof S}async function*GN(N){for await(let Q of N){let V=typeof Q.type==="string"?Q.type:void 0;if(!V)continue;if(V==="error"){let X=Q.code||"",Y=Q.message||"";throw new C(`Codex error: ${Y||X||JSON.stringify(Q)}`,{code:X||void 0,payload:Q})}if(V==="response.failed"){let X=Q.response,Y=X?.error?.code,Z=X?.error?.message;throw new C(Z||"Codex response failed",{code:Y,payload:Q})}if(V==="response.done"||V==="response.completed"||V==="response.incomplete"){let X=Q.response,Y=X?{...X,status:wN(X.status)}:X;yield{...Q,type:"response.completed",response:Y};return}yield Q}}function wN(N){if(typeof N!=="string")return;return UN.has(N)?N:void 0}async function*TN(N){if(!N.body)return;let Q=N.body.getReader(),V=new TextDecoder,X="";try{while(!0){let{done:Y,value:Z}=await Q.read();if(Y)break;X+=V.decode(Z,{stream:!0});let G=X.indexOf(`
3
3
 
4
4
  `);while(G!==-1){let $=X.slice(0,G);X=X.slice(G+2);let F=$.split(`
5
5
  `).filter((L)=>L.startsWith("data:")).map((L)=>L.slice(5).trim());if(F.length>0){let L=F.join(`
@@ -1,2 +1,2 @@
1
- import{$f as t,Ii as e,Li as a}from"./chunk-r673a3wt.js";function n({className:i,size:r="default",...s}){return t(e.Root,{"data-slot":"switch","data-size":r,className:a("peer group/switch inline-flex shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-[1.15rem] data-[size=default]:w-8 data-[size=sm]:h-3.5 data-[size=sm]:w-6 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input dark:data-[state=unchecked]:bg-input/80",i),...s,children:t(e.Thumb,{"data-slot":"switch-thumb",className:a("pointer-events-none block rounded-full bg-background ring-0 transition-transform group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0 dark:data-[state=checked]:bg-primary-foreground dark:data-[state=unchecked]:bg-foreground")})})}
2
- export{n as db};
1
+ import{Mi as e,Pi as a,bg as t}from"./chunk-gf7a2n6f.js";function n({className:i,size:r="default",...s}){return t(e.Root,{"data-slot":"switch","data-size":r,className:a("peer group/switch inline-flex shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-[1.15rem] data-[size=default]:w-8 data-[size=sm]:h-3.5 data-[size=sm]:w-6 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input dark:data-[state=unchecked]:bg-input/80",i),...s,children:t(e.Thumb,{"data-slot":"switch-thumb",className:a("pointer-events-none block rounded-full bg-background ring-0 transition-transform group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0 dark:data-[state=checked]:bg-primary-foreground dark:data-[state=unchecked]:bg-foreground")})})}
2
+ export{n as Za};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Jc as J,Kc as H}from"./chunk-9x12d447.js";import{ud as P,vd as V,wd as W}from"./chunk-qbtsq2mp.js";import"./chunk-nz95b2c5.js";var X=class{get supportsCreateIfNotExists(){return!0}get supportsTransactionalDdl(){return!1}get supportsReturning(){return!0}async acquireMigrationLock(){}async releaseMigrationLock(){}get supportsOutput(){return!0}},Y=class{#h;#j=new $;#w;#z;constructor(h){this.#h={...h}}async init(){if(this.#w=this.#h.database,this.#z=new Z(this.#w),this.#h.onCreateConnection)await this.#h.onCreateConnection(this.#z)}async acquireConnection(){return await this.#j.lock(),this.#z}async beginTransaction(h){await h.executeQuery(H.raw("begin"))}async commitTransaction(h){await h.executeQuery(H.raw("commit"))}async rollbackTransaction(h){await h.executeQuery(H.raw("rollback"))}async releaseConnection(){this.#j.unlock()}async destroy(){this.#w?.close()}},Z=class{#h;constructor(h){this.#h=h}executeQuery(h){let{sql:w,parameters:z}=h,j=this.#h.prepare(w);return Promise.resolve({rows:j.all(z)})}async*streamQuery(){throw Error("Streaming query is not supported by SQLite driver.")}},$=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?.()}},k=class{#h;constructor(h){this.#h=h}async getSchemas(){return[]}async getTables(h={withInternalKyselyTables:!1}){let w=this.#h.selectFrom("sqlite_schema").where("type","=","table").where("name","not like","sqlite_%").select("name").$castTo();if(!h.withInternalKyselyTables)w=w.where("name","!=",V).where("name","!=",W);let z=await w.execute();return Promise.all(z.map(({name:j})=>this.#j(j)))}async getMetadata(h){return{tables:await this.getTables(h)}}async#j(h){let w=this.#h,z=(await w.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 w.selectFrom(J`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===z,hasDefaultValue:j.dflt_value!=null})),isView:!0}}},K=class extends P{getCurrentParameterPlaceholder(){return"?"}getLeftIdentifierWrapper(){return'"'}getRightIdentifierWrapper(){return'"'}getAutoIncrement(){return"autoincrement"}},G=class{#h;constructor(h){this.#h={...h}}createDriver(){return new Y(this.#h)}createQueryCompiler(){return new K}createAdapter(){return new X}createIntrospector(h){return new k(h)}};export{G as BunSqliteDialect};
2
+ import{Lc as J,Mc as H}from"./chunk-xh2ntgmk.js";import{wd as P,xd as V,yd as W}from"./chunk-ysq64j13.js";import"./chunk-kbzm1pwx.js";var X=class{get supportsCreateIfNotExists(){return!0}get supportsTransactionalDdl(){return!1}get supportsReturning(){return!0}async acquireMigrationLock(){}async releaseMigrationLock(){}get supportsOutput(){return!0}},Y=class{#h;#j=new $;#w;#z;constructor(h){this.#h={...h}}async init(){if(this.#w=this.#h.database,this.#z=new Z(this.#w),this.#h.onCreateConnection)await this.#h.onCreateConnection(this.#z)}async acquireConnection(){return await this.#j.lock(),this.#z}async beginTransaction(h){await h.executeQuery(H.raw("begin"))}async commitTransaction(h){await h.executeQuery(H.raw("commit"))}async rollbackTransaction(h){await h.executeQuery(H.raw("rollback"))}async releaseConnection(){this.#j.unlock()}async destroy(){this.#w?.close()}},Z=class{#h;constructor(h){this.#h=h}executeQuery(h){let{sql:w,parameters:z}=h,j=this.#h.prepare(w);return Promise.resolve({rows:j.all(z)})}async*streamQuery(){throw Error("Streaming query is not supported by SQLite driver.")}},$=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?.()}},k=class{#h;constructor(h){this.#h=h}async getSchemas(){return[]}async getTables(h={withInternalKyselyTables:!1}){let w=this.#h.selectFrom("sqlite_schema").where("type","=","table").where("name","not like","sqlite_%").select("name").$castTo();if(!h.withInternalKyselyTables)w=w.where("name","!=",V).where("name","!=",W);let z=await w.execute();return Promise.all(z.map(({name:j})=>this.#j(j)))}async getMetadata(h){return{tables:await this.getTables(h)}}async#j(h){let w=this.#h,z=(await w.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 w.selectFrom(J`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===z,hasDefaultValue:j.dflt_value!=null})),isView:!0}}},K=class extends P{getCurrentParameterPlaceholder(){return"?"}getLeftIdentifierWrapper(){return'"'}getRightIdentifierWrapper(){return'"'}getAutoIncrement(){return"autoincrement"}},G=class{#h;constructor(h){this.#h={...h}}createDriver(){return new Y(this.#h)}createQueryCompiler(){return new K}createAdapter(){return new X}createIntrospector(h){return new k(h)}};export{G as BunSqliteDialect};
@@ -38,4 +38,4 @@ If you understand the risks and have appropriate mitigations in place,
38
38
  you can set the \`dangerouslyAllowBrowser\` option to \`true\`, e.g.,
39
39
 
40
40
  new Anthropic({ apiKey, dangerouslyAllowBrowser: true });
41
- `);this.baseURL=W.baseURL,this.timeout=W.timeout??C0.DEFAULT_TIMEOUT,this.logger=W.logger??console;let J="warn";this.logLevel=J,this.logLevel=iZ(W.logLevel,"ClientOptions.logLevel",this)??iZ(GZ("ANTHROPIC_LOG"),"process.env['ANTHROPIC_LOG']",this)??J,this.fetchOptions=W.fetchOptions,this.maxRetries=W.maxRetries??2,this.fetch=W.fetch??D0(),G(this,vZ,P0,"f"),this._options=W,this.apiKey=typeof Z==="string"?Z:null,this.authToken=$}withOptions(X){return new this.constructor({...this._options,baseURL:this.baseURL,maxRetries:this.maxRetries,timeout:this.timeout,logger:this.logger,logLevel:this.logLevel,fetch:this.fetch,fetchOptions:this.fetchOptions,apiKey:this.apiKey,authToken:this.authToken,...X})}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:X,nulls:Z}){if(X.get("x-api-key")||X.get("authorization"))return;if(this.apiKey&&X.get("x-api-key"))return;if(Z.has("x-api-key"))return;if(this.authToken&&X.get("authorization"))return;if(Z.has("authorization"))return;throw Error('Could not resolve authentication method. Expected either apiKey or authToken to be set. Or for one of the "X-Api-Key" or "Authorization" headers to be explicitly omitted')}async authHeaders(X){return w([await this.apiKeyAuth(X),await this.bearerAuth(X)])}async apiKeyAuth(X){if(this.apiKey==null)return;return w([{"X-Api-Key":this.apiKey}])}async bearerAuth(X){if(this.authToken==null)return;return w([{Authorization:`Bearer ${this.authToken}`}])}stringifyQuery(X){return k0(X)}getUserAgent(){return`${this.constructor.name}/JS ${m}`}defaultIdempotencyKey(){return`stainless-node-retry-${cZ()}`}makeStatusError(X,Z,$,z){return A.generate(X,Z,$,z)}buildURL(X,Z,$){let z=!Y(this,U0,"m",Q1).call(this)&&$||this.baseURL,W=E0(X)?new URL(X):new URL(z+(z.endsWith("/")&&X.startsWith("/")?X.slice(1):X)),J=this.defaultQuery(),Q=Object.fromEntries(W.searchParams);if(!uZ(J)||!uZ(Q))Z={...Q,...J,...Z};if(typeof Z==="object"&&Z&&!Array.isArray(Z))W.search=this.stringifyQuery(Z);return W.toString()}_calculateNonstreamingTimeout(X){if(3600*X/128000>600)throw new N("Streaming is required for operations that may take longer than 10 minutes. See https://github.com/anthropics/anthropic-sdk-typescript#streaming-responses for more details");return 600000}async prepareOptions(X){}async prepareRequest(X,{url:Z,options:$}){}get(X,Z){return this.methodRequest("get",X,Z)}post(X,Z){return this.methodRequest("post",X,Z)}patch(X,Z){return this.methodRequest("patch",X,Z)}put(X,Z){return this.methodRequest("put",X,Z)}delete(X,Z){return this.methodRequest("delete",X,Z)}methodRequest(X,Z,$){return this.request(Promise.resolve($).then((z)=>{return{method:X,path:Z,...z}}))}request(X,Z=null){return new r(this,this.makeRequest(X,Z,void 0))}async makeRequest(X,Z,$){let z=await X,W=z.maxRetries??this.maxRetries;if(Z==null)Z=W;await this.prepareOptions(z);let{req:J,url:Q,timeout:K}=await this.buildRequest(z,{retryCount:W-Z});await this.prepareRequest(J,{url:Q,options:z});let x="log_"+(Math.random()*16777216|0).toString(16).padStart(6,"0"),E=$===void 0?"":`, retryOf: ${$}`,O=Date.now();if(T(this).debug(`[${x}] sending request`,g({retryOfRequestLogID:$,method:z.method,url:Q,options:z,headers:J.headers})),z.signal?.aborted)throw new L;let k=new AbortController,C=await this.fetchWithTimeout(Q,J,K,k).catch(MX),F=Date.now();if(C instanceof globalThis.Error){let h=`retrying, ${Z} attempts remaining`;if(z.signal?.aborted)throw new L;let _=b(C)||/timed? ?out/i.test(String(C)+("cause"in C?String(C.cause):""));if(Z)return T(this).info(`[${x}] connection ${_?"timed out":"failed"} - ${h}`),T(this).debug(`[${x}] connection ${_?"timed out":"failed"} (${h})`,g({retryOfRequestLogID:$,url:Q,durationMs:F-O,message:C.message})),this.retryRequest(z,Z,$??x);if(T(this).info(`[${x}] connection ${_?"timed out":"failed"} - error; no more retries left`),T(this).debug(`[${x}] connection ${_?"timed out":"failed"} (error; no more retries left)`,g({retryOfRequestLogID:$,url:Q,durationMs:F-O,message:C.message})),_)throw new EX;throw new o({cause:C})}let a=[...C.headers.entries()].filter(([h])=>h==="request-id").map(([h,_])=>", "+h+": "+JSON.stringify(_)).join(""),OX=`[${x}${E}${a}] ${J.method} ${Q} ${C.ok?"succeeded":"failed"} with status ${C.status} in ${F-O}ms`;if(!C.ok){let h=await this.shouldRetry(C);if(Z&&h){let NZ=`retrying, ${Z} attempts remaining`;return await f0(C.body),T(this).info(`${OX} - ${NZ}`),T(this).debug(`[${x}] response error (${NZ})`,g({retryOfRequestLogID:$,url:C.url,status:C.status,headers:C.headers,durationMs:F-O})),this.retryRequest(z,Z,$??x,C.headers)}let _=h?"error; no more retries left":"error; not retryable";T(this).info(`${OX} - ${_}`);let q0=await C.text().catch((NZ)=>MX(NZ).message),O0=UZ(q0),M0=O0?void 0:q0;throw T(this).debug(`[${x}] response error (${_})`,g({retryOfRequestLogID:$,url:C.url,status:C.status,headers:C.headers,message:M0,durationMs:Date.now()-O})),this.makeStatusError(C.status,O0,M0,C.headers)}return T(this).info(OX),T(this).debug(`[${x}] response start`,g({retryOfRequestLogID:$,url:C.url,status:C.status,headers:C.headers,durationMs:F-O})),{response:C,options:z,controller:k,requestLogID:x,retryOfRequestLogID:$,startTime:O}}getAPIList(X,Z,$){return this.requestAPIList(Z,$&&"then"in $?$.then((z)=>({method:"get",path:X,...z})):{method:"get",path:X,...$})}requestAPIList(X,Z){let $=this.makeRequest(Z,null,void 0);return new AZ(this,$,X)}async fetchWithTimeout(X,Z,$,z){let{signal:W,method:J,...Q}=Z||{},K=this._makeAbort(z);if(W)W.addEventListener("abort",K,{once:!0});let x=setTimeout(K,$),E=globalThis.ReadableStream&&Q.body instanceof globalThis.ReadableStream||typeof Q.body==="object"&&Q.body!==null&&Symbol.asyncIterator in Q.body,O={signal:z.signal,...E?{duplex:"half"}:{},method:"GET",...Q};if(J)O.method=J.toUpperCase();try{return await this.fetch.call(void 0,X,O)}finally{clearTimeout(x)}}async shouldRetry(X){let Z=X.headers.get("x-should-retry");if(Z==="true")return!0;if(Z==="false")return!1;if(X.status===408)return!0;if(X.status===409)return!0;if(X.status===429)return!0;if(X.status>=500)return!0;return!1}async retryRequest(X,Z,$,z){let W,J=z?.get("retry-after-ms");if(J){let K=parseFloat(J);if(!Number.isNaN(K))W=K}let Q=z?.get("retry-after");if(Q&&!W){let K=parseFloat(Q);if(!Number.isNaN(K))W=K*1000;else W=Date.parse(Q)-Date.now()}if(W===void 0){let K=X.maxRetries??this.maxRetries;W=this.calculateDefaultRetryTimeoutMillis(Z,K)}return await F0(W),this.makeRequest(X,Z-1,$)}calculateDefaultRetryTimeoutMillis(X,Z){let W=Z-X,J=Math.min(0.5*Math.pow(2,W),8),Q=1-Math.random()*0.25;return J*Q*1000}calculateNonstreamingTimeout(X,Z){if(3600000*X/128000>600000||Z!=null&&X>Z)throw new N("Streaming is required for operations that may take longer than 10 minutes. See https://github.com/anthropics/anthropic-sdk-typescript#long-requests for more details");return 600000}async buildRequest(X,{retryCount:Z=0}={}){let $={...X},{method:z,path:W,query:J,defaultBaseURL:Q}=$,K=this.buildURL(W,J,Q);if("timeout"in $)H0("timeout",$.timeout);$.timeout=$.timeout??this.timeout;let{bodyHeaders:x,body:E}=this.buildBody({options:$}),O=await this.buildHeaders({options:X,method:z,bodyHeaders:x,retryCount:Z});return{req:{method:z,headers:O,...$.signal&&{signal:$.signal},...globalThis.ReadableStream&&E instanceof globalThis.ReadableStream&&{duplex:"half"},...E&&{body:E},...this.fetchOptions??{},...$.fetchOptions??{}},url:K,timeout:$.timeout}}async buildHeaders({options:X,method:Z,bodyHeaders:$,retryCount:z}){let W={};if(this.idempotencyHeader&&Z!=="get"){if(!X.idempotencyKey)X.idempotencyKey=this.defaultIdempotencyKey();W[this.idempotencyHeader]=X.idempotencyKey}let J=w([W,{Accept:"application/json","User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String(z),...X.timeout?{"X-Stainless-Timeout":String(Math.trunc(X.timeout/1000))}:{},...B0(),...this._options.dangerouslyAllowBrowser?{"anthropic-dangerous-direct-browser-access":"true"}:void 0,"anthropic-version":"2023-06-01"},await this.authHeaders(X),this._options.defaultHeaders,$,X.headers]);return this.validateHeaders(J),J.values}_makeAbort(X){return()=>X.abort()}buildBody({options:{body:X,headers:Z}}){if(!X)return{bodyHeaders:void 0,body:void 0};let $=w([Z]);if(ArrayBuffer.isView(X)||X instanceof ArrayBuffer||X instanceof DataView||typeof X==="string"&&$.values.has("content-type")||globalThis.Blob&&X instanceof globalThis.Blob||X instanceof FormData||X instanceof URLSearchParams||globalThis.ReadableStream&&X instanceof globalThis.ReadableStream)return{bodyHeaders:void 0,body:X};else if(typeof X==="object"&&((Symbol.asyncIterator in X)||(Symbol.iterator in X)&&("next"in X)&&typeof X.next==="function"))return{bodyHeaders:void 0,body:CZ(X)};else if(typeof X==="object"&&$.values.get("content-type")==="application/x-www-form-urlencoded")return{bodyHeaders:{"content-type":"application/x-www-form-urlencoded"},body:this.stringifyQuery(X)};else return Y(this,vZ,"f").call(this,{body:X,headers:$})}}C0=M,vZ=new WeakMap,U0=new WeakSet,Q1=function(){return this.baseURL!=="https://api.anthropic.com"};M.Anthropic=C0;M.HUMAN_PROMPT=V1;M.AI_PROMPT=G1;M.DEFAULT_TIMEOUT=600000;M.AnthropicError=N;M.APIError=A;M.APIConnectionError=o;M.APIConnectionTimeoutError=EX;M.APIUserAbortError=L;M.NotFoundError=TX;M.ConflictError=LX;M.RateLimitError=jX;M.BadRequestError=AX;M.AuthenticationError=HX;M.InternalServerError=BX;M.PermissionDeniedError=FX;M.UnprocessableEntityError=SX;M.toFile=HZ;class WX extends M{constructor(){super(...arguments);this.completions=new UX(this),this.messages=new zX(this),this.models=new qX(this),this.beta=new S(this)}}WX.Completions=UX;WX.Messages=zX;WX.Models=qX;WX.Beta=S;export{WX as pj};
41
+ `);this.baseURL=W.baseURL,this.timeout=W.timeout??C0.DEFAULT_TIMEOUT,this.logger=W.logger??console;let J="warn";this.logLevel=J,this.logLevel=iZ(W.logLevel,"ClientOptions.logLevel",this)??iZ(GZ("ANTHROPIC_LOG"),"process.env['ANTHROPIC_LOG']",this)??J,this.fetchOptions=W.fetchOptions,this.maxRetries=W.maxRetries??2,this.fetch=W.fetch??D0(),G(this,vZ,P0,"f"),this._options=W,this.apiKey=typeof Z==="string"?Z:null,this.authToken=$}withOptions(X){return new this.constructor({...this._options,baseURL:this.baseURL,maxRetries:this.maxRetries,timeout:this.timeout,logger:this.logger,logLevel:this.logLevel,fetch:this.fetch,fetchOptions:this.fetchOptions,apiKey:this.apiKey,authToken:this.authToken,...X})}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:X,nulls:Z}){if(X.get("x-api-key")||X.get("authorization"))return;if(this.apiKey&&X.get("x-api-key"))return;if(Z.has("x-api-key"))return;if(this.authToken&&X.get("authorization"))return;if(Z.has("authorization"))return;throw Error('Could not resolve authentication method. Expected either apiKey or authToken to be set. Or for one of the "X-Api-Key" or "Authorization" headers to be explicitly omitted')}async authHeaders(X){return w([await this.apiKeyAuth(X),await this.bearerAuth(X)])}async apiKeyAuth(X){if(this.apiKey==null)return;return w([{"X-Api-Key":this.apiKey}])}async bearerAuth(X){if(this.authToken==null)return;return w([{Authorization:`Bearer ${this.authToken}`}])}stringifyQuery(X){return k0(X)}getUserAgent(){return`${this.constructor.name}/JS ${m}`}defaultIdempotencyKey(){return`stainless-node-retry-${cZ()}`}makeStatusError(X,Z,$,z){return A.generate(X,Z,$,z)}buildURL(X,Z,$){let z=!Y(this,U0,"m",Q1).call(this)&&$||this.baseURL,W=E0(X)?new URL(X):new URL(z+(z.endsWith("/")&&X.startsWith("/")?X.slice(1):X)),J=this.defaultQuery(),Q=Object.fromEntries(W.searchParams);if(!uZ(J)||!uZ(Q))Z={...Q,...J,...Z};if(typeof Z==="object"&&Z&&!Array.isArray(Z))W.search=this.stringifyQuery(Z);return W.toString()}_calculateNonstreamingTimeout(X){if(3600*X/128000>600)throw new N("Streaming is required for operations that may take longer than 10 minutes. See https://github.com/anthropics/anthropic-sdk-typescript#streaming-responses for more details");return 600000}async prepareOptions(X){}async prepareRequest(X,{url:Z,options:$}){}get(X,Z){return this.methodRequest("get",X,Z)}post(X,Z){return this.methodRequest("post",X,Z)}patch(X,Z){return this.methodRequest("patch",X,Z)}put(X,Z){return this.methodRequest("put",X,Z)}delete(X,Z){return this.methodRequest("delete",X,Z)}methodRequest(X,Z,$){return this.request(Promise.resolve($).then((z)=>{return{method:X,path:Z,...z}}))}request(X,Z=null){return new r(this,this.makeRequest(X,Z,void 0))}async makeRequest(X,Z,$){let z=await X,W=z.maxRetries??this.maxRetries;if(Z==null)Z=W;await this.prepareOptions(z);let{req:J,url:Q,timeout:K}=await this.buildRequest(z,{retryCount:W-Z});await this.prepareRequest(J,{url:Q,options:z});let x="log_"+(Math.random()*16777216|0).toString(16).padStart(6,"0"),E=$===void 0?"":`, retryOf: ${$}`,O=Date.now();if(T(this).debug(`[${x}] sending request`,g({retryOfRequestLogID:$,method:z.method,url:Q,options:z,headers:J.headers})),z.signal?.aborted)throw new L;let k=new AbortController,C=await this.fetchWithTimeout(Q,J,K,k).catch(MX),F=Date.now();if(C instanceof globalThis.Error){let h=`retrying, ${Z} attempts remaining`;if(z.signal?.aborted)throw new L;let _=b(C)||/timed? ?out/i.test(String(C)+("cause"in C?String(C.cause):""));if(Z)return T(this).info(`[${x}] connection ${_?"timed out":"failed"} - ${h}`),T(this).debug(`[${x}] connection ${_?"timed out":"failed"} (${h})`,g({retryOfRequestLogID:$,url:Q,durationMs:F-O,message:C.message})),this.retryRequest(z,Z,$??x);if(T(this).info(`[${x}] connection ${_?"timed out":"failed"} - error; no more retries left`),T(this).debug(`[${x}] connection ${_?"timed out":"failed"} (error; no more retries left)`,g({retryOfRequestLogID:$,url:Q,durationMs:F-O,message:C.message})),_)throw new EX;throw new o({cause:C})}let a=[...C.headers.entries()].filter(([h])=>h==="request-id").map(([h,_])=>", "+h+": "+JSON.stringify(_)).join(""),OX=`[${x}${E}${a}] ${J.method} ${Q} ${C.ok?"succeeded":"failed"} with status ${C.status} in ${F-O}ms`;if(!C.ok){let h=await this.shouldRetry(C);if(Z&&h){let NZ=`retrying, ${Z} attempts remaining`;return await f0(C.body),T(this).info(`${OX} - ${NZ}`),T(this).debug(`[${x}] response error (${NZ})`,g({retryOfRequestLogID:$,url:C.url,status:C.status,headers:C.headers,durationMs:F-O})),this.retryRequest(z,Z,$??x,C.headers)}let _=h?"error; no more retries left":"error; not retryable";T(this).info(`${OX} - ${_}`);let q0=await C.text().catch((NZ)=>MX(NZ).message),O0=UZ(q0),M0=O0?void 0:q0;throw T(this).debug(`[${x}] response error (${_})`,g({retryOfRequestLogID:$,url:C.url,status:C.status,headers:C.headers,message:M0,durationMs:Date.now()-O})),this.makeStatusError(C.status,O0,M0,C.headers)}return T(this).info(OX),T(this).debug(`[${x}] response start`,g({retryOfRequestLogID:$,url:C.url,status:C.status,headers:C.headers,durationMs:F-O})),{response:C,options:z,controller:k,requestLogID:x,retryOfRequestLogID:$,startTime:O}}getAPIList(X,Z,$){return this.requestAPIList(Z,$&&"then"in $?$.then((z)=>({method:"get",path:X,...z})):{method:"get",path:X,...$})}requestAPIList(X,Z){let $=this.makeRequest(Z,null,void 0);return new AZ(this,$,X)}async fetchWithTimeout(X,Z,$,z){let{signal:W,method:J,...Q}=Z||{},K=this._makeAbort(z);if(W)W.addEventListener("abort",K,{once:!0});let x=setTimeout(K,$),E=globalThis.ReadableStream&&Q.body instanceof globalThis.ReadableStream||typeof Q.body==="object"&&Q.body!==null&&Symbol.asyncIterator in Q.body,O={signal:z.signal,...E?{duplex:"half"}:{},method:"GET",...Q};if(J)O.method=J.toUpperCase();try{return await this.fetch.call(void 0,X,O)}finally{clearTimeout(x)}}async shouldRetry(X){let Z=X.headers.get("x-should-retry");if(Z==="true")return!0;if(Z==="false")return!1;if(X.status===408)return!0;if(X.status===409)return!0;if(X.status===429)return!0;if(X.status>=500)return!0;return!1}async retryRequest(X,Z,$,z){let W,J=z?.get("retry-after-ms");if(J){let K=parseFloat(J);if(!Number.isNaN(K))W=K}let Q=z?.get("retry-after");if(Q&&!W){let K=parseFloat(Q);if(!Number.isNaN(K))W=K*1000;else W=Date.parse(Q)-Date.now()}if(W===void 0){let K=X.maxRetries??this.maxRetries;W=this.calculateDefaultRetryTimeoutMillis(Z,K)}return await F0(W),this.makeRequest(X,Z-1,$)}calculateDefaultRetryTimeoutMillis(X,Z){let W=Z-X,J=Math.min(0.5*Math.pow(2,W),8),Q=1-Math.random()*0.25;return J*Q*1000}calculateNonstreamingTimeout(X,Z){if(3600000*X/128000>600000||Z!=null&&X>Z)throw new N("Streaming is required for operations that may take longer than 10 minutes. See https://github.com/anthropics/anthropic-sdk-typescript#long-requests for more details");return 600000}async buildRequest(X,{retryCount:Z=0}={}){let $={...X},{method:z,path:W,query:J,defaultBaseURL:Q}=$,K=this.buildURL(W,J,Q);if("timeout"in $)H0("timeout",$.timeout);$.timeout=$.timeout??this.timeout;let{bodyHeaders:x,body:E}=this.buildBody({options:$}),O=await this.buildHeaders({options:X,method:z,bodyHeaders:x,retryCount:Z});return{req:{method:z,headers:O,...$.signal&&{signal:$.signal},...globalThis.ReadableStream&&E instanceof globalThis.ReadableStream&&{duplex:"half"},...E&&{body:E},...this.fetchOptions??{},...$.fetchOptions??{}},url:K,timeout:$.timeout}}async buildHeaders({options:X,method:Z,bodyHeaders:$,retryCount:z}){let W={};if(this.idempotencyHeader&&Z!=="get"){if(!X.idempotencyKey)X.idempotencyKey=this.defaultIdempotencyKey();W[this.idempotencyHeader]=X.idempotencyKey}let J=w([W,{Accept:"application/json","User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String(z),...X.timeout?{"X-Stainless-Timeout":String(Math.trunc(X.timeout/1000))}:{},...B0(),...this._options.dangerouslyAllowBrowser?{"anthropic-dangerous-direct-browser-access":"true"}:void 0,"anthropic-version":"2023-06-01"},await this.authHeaders(X),this._options.defaultHeaders,$,X.headers]);return this.validateHeaders(J),J.values}_makeAbort(X){return()=>X.abort()}buildBody({options:{body:X,headers:Z}}){if(!X)return{bodyHeaders:void 0,body:void 0};let $=w([Z]);if(ArrayBuffer.isView(X)||X instanceof ArrayBuffer||X instanceof DataView||typeof X==="string"&&$.values.has("content-type")||globalThis.Blob&&X instanceof globalThis.Blob||X instanceof FormData||X instanceof URLSearchParams||globalThis.ReadableStream&&X instanceof globalThis.ReadableStream)return{bodyHeaders:void 0,body:X};else if(typeof X==="object"&&((Symbol.asyncIterator in X)||(Symbol.iterator in X)&&("next"in X)&&typeof X.next==="function"))return{bodyHeaders:void 0,body:CZ(X)};else if(typeof X==="object"&&$.values.get("content-type")==="application/x-www-form-urlencoded")return{bodyHeaders:{"content-type":"application/x-www-form-urlencoded"},body:this.stringifyQuery(X)};else return Y(this,vZ,"f").call(this,{body:X,headers:$})}}C0=M,vZ=new WeakMap,U0=new WeakSet,Q1=function(){return this.baseURL!=="https://api.anthropic.com"};M.Anthropic=C0;M.HUMAN_PROMPT=V1;M.AI_PROMPT=G1;M.DEFAULT_TIMEOUT=600000;M.AnthropicError=N;M.APIError=A;M.APIConnectionError=o;M.APIConnectionTimeoutError=EX;M.APIUserAbortError=L;M.NotFoundError=TX;M.ConflictError=LX;M.RateLimitError=jX;M.BadRequestError=AX;M.AuthenticationError=HX;M.InternalServerError=BX;M.PermissionDeniedError=FX;M.UnprocessableEntityError=SX;M.toFile=HZ;class WX extends M{constructor(){super(...arguments);this.completions=new UX(this),this.messages=new zX(this),this.models=new qX(this),this.beta=new S(this)}}WX.Completions=UX;WX.Messages=zX;WX.Models=qX;WX.Beta=S;export{WX as vj};