@shumai-one/shumai 0.4.2 → 0.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (250) hide show
  1. package/bin/{chunk-adekdctx.css → chunk-0ccg9ddn.css} +1 -1
  2. package/bin/chunk-0e4wawpq.js +2 -0
  3. package/bin/chunk-185qefn1.js +2 -0
  4. package/bin/chunk-1kw2mbqb.js +1 -0
  5. package/bin/chunk-1wm6ptdx.js +1 -0
  6. package/bin/chunk-1yacmegc.js +2 -0
  7. package/bin/chunk-2291ehh5.js +3 -0
  8. package/bin/chunk-2520aq8j.js +2 -0
  9. package/bin/chunk-29zdp63z.js +3 -0
  10. package/bin/chunk-2yxj593j.js +2 -0
  11. package/bin/chunk-32pcmaqm.js +3 -0
  12. package/bin/chunk-3a13dcs1.js +1 -0
  13. package/bin/chunk-3cyrcgm5.js +13 -0
  14. package/bin/chunk-3swpwb9v.js +1 -0
  15. package/bin/chunk-3wmcx2bv.js +2 -0
  16. package/bin/chunk-4r81ghg8.js +2 -0
  17. package/bin/chunk-4v5n0ayb.js +2 -0
  18. package/bin/chunk-5a8nt4me.js +1 -0
  19. package/bin/chunk-66hsjnw6.js +2 -0
  20. package/bin/chunk-6bhn1p8v.js +211 -0
  21. package/bin/chunk-6gg1ymer.js +2 -0
  22. package/bin/chunk-70c3xrgd.js +2 -0
  23. package/bin/chunk-7esm0hqb.js +2 -0
  24. package/bin/chunk-7fst8kdw.js +12 -0
  25. package/bin/chunk-83e12sjg.js +3 -0
  26. package/bin/chunk-87zxtf66.js +3 -0
  27. package/bin/chunk-8fmy5jtp.js +2 -0
  28. package/bin/chunk-8zqgaxvv.js +1 -0
  29. package/bin/chunk-9t1ne8xr.js +2 -0
  30. package/bin/chunk-a32vreya.js +2 -0
  31. package/bin/chunk-a3dmtt2j.js +1 -0
  32. package/bin/chunk-abt0azmv.js +2 -0
  33. package/bin/chunk-ag6p3mbf.js +2 -0
  34. package/bin/chunk-aqbrzx9z.js +1 -0
  35. package/bin/chunk-av1a8fqp.js +3 -0
  36. package/bin/chunk-awfwk64v.js +2 -0
  37. package/bin/chunk-b235azv4.js +45 -0
  38. package/bin/chunk-b9yrw9et.js +10 -0
  39. package/bin/chunk-bay038pj.js +2 -0
  40. package/bin/chunk-c007p0t8.js +299 -0
  41. package/bin/chunk-cak32x57.js +2 -0
  42. package/bin/chunk-ce8m4zeg.js +3 -0
  43. package/bin/chunk-ck8azecb.js +12 -0
  44. package/bin/chunk-cnxwmycy.js +6 -0
  45. package/bin/chunk-cqb415s6.js +5 -0
  46. package/bin/chunk-e2mvmq2m.js +1 -0
  47. package/bin/chunk-e7mqtkzn.js +2 -0
  48. package/bin/chunk-e99dv20z.js +3 -0
  49. package/bin/chunk-ea79xnn3.js +2 -0
  50. package/bin/chunk-ehc9adfz.js +2 -0
  51. package/bin/chunk-ejbvfj4r.js +1 -0
  52. package/bin/chunk-ekfem7kf.js +1 -0
  53. package/bin/chunk-etwkk0xh.js +1 -0
  54. package/bin/chunk-evrdd32b.js +2 -0
  55. package/bin/chunk-f15qyp41.js +1 -0
  56. package/bin/chunk-f3ehv01n.js +54 -0
  57. package/bin/chunk-fm6p03ad.js +2 -0
  58. package/bin/chunk-fxswt9hc.js +3 -0
  59. package/bin/chunk-fyha3r13.js +2 -0
  60. package/bin/chunk-g0vs7k2x.js +1 -0
  61. package/bin/chunk-g84z2w7v.js +16 -0
  62. package/bin/chunk-gk3eqd50.js +2 -0
  63. package/bin/chunk-h3tbf521.js +2 -0
  64. package/bin/chunk-h837fyed.js +2 -0
  65. package/bin/chunk-hfh0c082.js +2 -0
  66. package/bin/chunk-j20e0qsw.js +7 -0
  67. package/bin/chunk-j8fxp8ej.js +2 -0
  68. package/bin/chunk-jje8nj8h.js +3 -0
  69. package/bin/chunk-jy006gcv.js +7 -0
  70. package/bin/chunk-k7hss0bd.js +4 -0
  71. package/bin/chunk-m7m9d4fb.js +2 -0
  72. package/bin/chunk-n1jwdb0a.js +1 -0
  73. package/bin/chunk-p5gf1zdm.js +4 -0
  74. package/bin/chunk-pb1zf0vb.js +2 -0
  75. package/bin/chunk-pfgxggaj.js +11 -0
  76. package/bin/chunk-q16490pv.js +2 -0
  77. package/bin/chunk-q2bvyv39.js +8 -0
  78. package/bin/chunk-qf24e71w.js +2 -0
  79. package/bin/chunk-qh81zhg1.js +1 -0
  80. package/bin/chunk-qwp3kwbz.js +2 -0
  81. package/bin/chunk-qwqvt9v6.js +2 -0
  82. package/bin/chunk-qydeqgyj.js +5 -0
  83. package/bin/chunk-r7dty1tg.js +2 -0
  84. package/bin/chunk-rbj4fad9.js +32 -0
  85. package/bin/chunk-rhdxwebf.js +2 -0
  86. package/bin/chunk-rhh716z0.js +42 -0
  87. package/bin/chunk-rpywcvg1.js +3 -0
  88. package/bin/chunk-rza4ae5z.js +3 -0
  89. package/bin/chunk-sfx2588q.js +3 -0
  90. package/bin/chunk-sk4e6rb1.js +1 -0
  91. package/bin/chunk-t2n1dbgx.js +4 -0
  92. package/bin/chunk-tf28796q.js +2 -0
  93. package/bin/chunk-twdxayky.js +3 -0
  94. package/bin/chunk-v9b3w8q5.js +3 -0
  95. package/bin/chunk-v9w25rp2.js +2 -0
  96. package/bin/chunk-vgn5zcpv.js +3 -0
  97. package/bin/chunk-wfzqnpc1.js +3 -0
  98. package/bin/chunk-wry2hvrq.js +24 -0
  99. package/bin/chunk-x8f4defx.js +3 -0
  100. package/bin/chunk-xp59apdb.js +2 -0
  101. package/bin/chunk-xtf3c29c.css +1 -0
  102. package/bin/chunk-z3gkt8w1.js +3 -0
  103. package/bin/chunk-zehyn6vd.js +2 -0
  104. package/bin/chunk-zh6fqq44.js +1 -0
  105. package/bin/chunk-zmv8cg4s.js +8 -0
  106. package/bin/chunk-zqv0zhfb.js +3 -0
  107. package/bin/{pdf.worker.min-szxdj13d.mjs → pdf.worker.min-vf48er29.mjs} +14423 -13889
  108. package/bin/shumai-app.html +1 -1
  109. package/bin/shumai-app.js +626 -460
  110. package/package.json +18 -18
  111. package/prisma/migrations/20260904022457_add_agent_id_to_assets_and_audit_logs/migration.sql +17 -0
  112. package/prisma/migrations/20260906081230_default_denied_tools_delete_asset/migration.sql +15 -0
  113. package/prisma/schema.prisma +9 -0
  114. package/bin/chunk-07h4b77v.js +0 -2
  115. package/bin/chunk-0t4n4d5w.js +0 -4
  116. package/bin/chunk-1611z9jg.js +0 -2
  117. package/bin/chunk-1phqxp6z.js +0 -3
  118. package/bin/chunk-23hckrrz.js +0 -2
  119. package/bin/chunk-30z44j1g.js +0 -2
  120. package/bin/chunk-3j463k1g.js +0 -1
  121. package/bin/chunk-4181tdds.js +0 -14
  122. package/bin/chunk-480jtqng.js +0 -4
  123. package/bin/chunk-4c3g146q.js +0 -2
  124. package/bin/chunk-4ca0zt5e.js +0 -1
  125. package/bin/chunk-4d9bgmf2.js +0 -2
  126. package/bin/chunk-4ev56fss.js +0 -9
  127. package/bin/chunk-4gk52tjq.js +0 -45
  128. package/bin/chunk-4mdqkj4d.js +0 -1
  129. package/bin/chunk-4r91fggc.js +0 -2
  130. package/bin/chunk-50fb1x3w.js +0 -1
  131. package/bin/chunk-59gj1njz.js +0 -1
  132. package/bin/chunk-5pr0t7fb.js +0 -2
  133. package/bin/chunk-5vewxmz7.js +0 -3
  134. package/bin/chunk-62zx96pe.js +0 -2
  135. package/bin/chunk-63y0eb07.js +0 -2
  136. package/bin/chunk-6d5xrgfx.js +0 -2
  137. package/bin/chunk-6gbtz5bf.js +0 -67
  138. package/bin/chunk-6gjg5egq.js +0 -3
  139. package/bin/chunk-6m4jz9s1.js +0 -44
  140. package/bin/chunk-6s4x525w.js +0 -2
  141. package/bin/chunk-6w2wmvqs.js +0 -3
  142. package/bin/chunk-77d23vcn.js +0 -2
  143. package/bin/chunk-77m5p188.js +0 -2
  144. package/bin/chunk-7bvx087f.js +0 -1
  145. package/bin/chunk-7pfjfrjg.js +0 -5
  146. package/bin/chunk-7q10s127.js +0 -4
  147. package/bin/chunk-7thx8ctx.js +0 -3
  148. package/bin/chunk-8t4s91gh.js +0 -2
  149. package/bin/chunk-98ey5p2e.js +0 -3
  150. package/bin/chunk-9amndcyh.js +0 -6
  151. package/bin/chunk-9bk23g9x.js +0 -1
  152. package/bin/chunk-9mkcfy43.js +0 -1
  153. package/bin/chunk-9t3nsq5n.js +0 -2
  154. package/bin/chunk-9tjq99ds.js +0 -2
  155. package/bin/chunk-9wm9rwh1.js +0 -2
  156. package/bin/chunk-ab16fyg4.js +0 -4
  157. package/bin/chunk-arv0g2av.js +0 -1
  158. package/bin/chunk-aytj4zxg.js +0 -3
  159. package/bin/chunk-b1ypjqgp.js +0 -2
  160. package/bin/chunk-bdjv0ykq.js +0 -2
  161. package/bin/chunk-c1k86mfa.js +0 -10
  162. package/bin/chunk-caa96dgd.js +0 -2
  163. package/bin/chunk-ce4v2yjy.js +0 -1
  164. package/bin/chunk-cqh60y54.js +0 -3
  165. package/bin/chunk-cvq7zgw7.js +0 -1
  166. package/bin/chunk-d9mjbtp2.js +0 -2
  167. package/bin/chunk-dn7sbjws.js +0 -3
  168. package/bin/chunk-dxyq9h8n.js +0 -3
  169. package/bin/chunk-e3cabksx.js +0 -3
  170. package/bin/chunk-egcrbj94.js +0 -2
  171. package/bin/chunk-ev17v1mv.js +0 -2
  172. package/bin/chunk-evtpwg71.js +0 -2
  173. package/bin/chunk-f3e0nsv2.js +0 -2
  174. package/bin/chunk-f40gjqpq.js +0 -2
  175. package/bin/chunk-fe7822ak.js +0 -299
  176. package/bin/chunk-g8tkhw9j.js +0 -2
  177. package/bin/chunk-g9r0p4t8.js +0 -2
  178. package/bin/chunk-gbjyh9ms.js +0 -1
  179. package/bin/chunk-gtbsb39v.js +0 -3
  180. package/bin/chunk-gytz1q13.js +0 -13
  181. package/bin/chunk-h0fxysxs.js +0 -7
  182. package/bin/chunk-h8bdvsqt.js +0 -2
  183. package/bin/chunk-hag024w8.js +0 -2
  184. package/bin/chunk-hc6w5nw4.js +0 -7
  185. package/bin/chunk-j69dqc48.js +0 -2
  186. package/bin/chunk-jbtw1zym.js +0 -8
  187. package/bin/chunk-jc1vb7rj.js +0 -5
  188. package/bin/chunk-jdv78w9r.js +0 -2
  189. package/bin/chunk-jjs70y9v.js +0 -3
  190. package/bin/chunk-jmdar2gz.js +0 -2
  191. package/bin/chunk-jvwz10n4.js +0 -2
  192. package/bin/chunk-k47md1g4.js +0 -2
  193. package/bin/chunk-k4v0brcb.js +0 -2
  194. package/bin/chunk-k6n7c07e.js +0 -1
  195. package/bin/chunk-kk2cstsg.js +0 -2
  196. package/bin/chunk-knz4h56q.js +0 -12
  197. package/bin/chunk-kqqtt6bd.js +0 -3
  198. package/bin/chunk-kvyp1t4j.js +0 -7
  199. package/bin/chunk-kxskpgsq.js +0 -5
  200. package/bin/chunk-m6srbjcs.js +0 -2
  201. package/bin/chunk-mcc1scxs.js +0 -12
  202. package/bin/chunk-mq83a0kk.js +0 -2
  203. package/bin/chunk-mxm8g4q0.js +0 -1
  204. package/bin/chunk-nhpgdqq5.js +0 -2
  205. package/bin/chunk-nne496aa.js +0 -2
  206. package/bin/chunk-nqpb0r9h.js +0 -11
  207. package/bin/chunk-ns0zww9g.js +0 -2
  208. package/bin/chunk-ps4xfp23.js +0 -2
  209. package/bin/chunk-pz2ec6xt.js +0 -2
  210. package/bin/chunk-q163k309.js +0 -2
  211. package/bin/chunk-q1da61ps.js +0 -1
  212. package/bin/chunk-qrf0ady6.js +0 -68
  213. package/bin/chunk-qy28f25e.js +0 -2
  214. package/bin/chunk-r7s4ypw1.js +0 -2
  215. package/bin/chunk-ran23vm9.js +0 -1
  216. package/bin/chunk-rfvdc4n0.js +0 -2
  217. package/bin/chunk-rgthkvgx.js +0 -3
  218. package/bin/chunk-s39n3yw3.js +0 -2
  219. package/bin/chunk-s7wdd0g7.js +0 -8
  220. package/bin/chunk-s88ha5kx.js +0 -3
  221. package/bin/chunk-sf91bt9m.js +0 -2
  222. package/bin/chunk-sjwbjf9j.js +0 -2
  223. package/bin/chunk-t62076pv.js +0 -1
  224. package/bin/chunk-tbbwss3v.js +0 -3
  225. package/bin/chunk-tjcc7a6y.js +0 -24
  226. package/bin/chunk-tp6ab26e.js +0 -2
  227. package/bin/chunk-v2wxk9p5.js +0 -4
  228. package/bin/chunk-vbk6y4hk.js +0 -2
  229. package/bin/chunk-vfgfg5fk.js +0 -2
  230. package/bin/chunk-vm6c3xx9.js +0 -2
  231. package/bin/chunk-vsx96mt6.js +0 -3
  232. package/bin/chunk-wbyw1shz.js +0 -6
  233. package/bin/chunk-whh2vh50.css +0 -1
  234. package/bin/chunk-wjkcq65s.js +0 -2
  235. package/bin/chunk-wkefwkfp.js +0 -41
  236. package/bin/chunk-x7bsnk1e.js +0 -2
  237. package/bin/chunk-xbhw6bpz.js +0 -3
  238. package/bin/chunk-xg5yrcj5.js +0 -2
  239. package/bin/chunk-xg9xscqz.js +0 -1
  240. package/bin/chunk-xw2gpcsh.js +0 -3
  241. package/bin/chunk-ycq8ank7.js +0 -2
  242. package/bin/chunk-yp9hvkc5.js +0 -73
  243. package/bin/chunk-ytypyfkc.js +0 -65
  244. package/bin/chunk-z1kjmf60.js +0 -2
  245. package/bin/chunk-z36bx86r.js +0 -2
  246. package/bin/chunk-z7hdnecp.js +0 -3
  247. package/bin/chunk-zeby1cq7.js +0 -2
  248. package/bin/chunk-zs5e8z1w.js +0 -1
  249. package/bin/chunk-zxnyefg5.js +0 -2
  250. /package/bin/{chunk-24ke0th1.css → chunk-kegybs91.css} +0 -0
@@ -0,0 +1,7 @@
1
+ // @bun
2
+ import{Qe}from"./chunk-wry2hvrq.js";import{Qr}from"./chunk-qydeqgyj.js";import{nr}from"./chunk-sfx2588q.js";import{ws,xs}from"./chunk-twdxayky.js";import{Go}from"./chunk-z3gkt8w1.js";import{ca}from"./chunk-wfzqnpc1.js";import{$o}from"./chunk-jje8nj8h.js";import{cn,un}from"./chunk-87zxtf66.js";import{Fe,Jl,Xl,oo,Ui,zn,xr,ao}from"./chunk-zqv0zhfb.js";import{Xr}from"./chunk-29zdp63z.js";import{en,Ur}from"./chunk-2291ehh5.js";import{Vt}from"./chunk-x8f4defx.js";function B(e,n){if(!e)return!1;let t=n.toLowerCase();for(let[r,s]of Object.entries(e))if(r.toLowerCase()===t&&s!==null&&s.trim().length>0)return!0;return!1}function z(e,n,t){if(n)return n;if(B(t,"authorization")||B(t,"cf-aig-authorization"))return"unused";throw Error(`No API key for provider: ${e}`)}function Q(e){for(let n of e){if(n.role==="toolResult")return!0;if(n.role==="assistant"){if(n.content.some((t)=>t.type==="toolCall"))return!0}}return!1}function X(e){let n=new Set;for(let t of e)if(t.role==="toolResult")for(let r of t.addedToolNames??[])n.add(r);return n}function Y(e,n){if(!e)return[];let t=new Map(e.map((r)=>[r.name,r]));return Array.from(n).map((r)=>t.get(r)).filter((r)=>r!==void 0)}function D(e){return e.type==="text"}function ee(e){return e.type==="thinking"}function te(e){return e.type==="toolCall"}function ne(e){return e.type==="image"}function re(e){if(typeof e!=="object"||e===null)return!1;let n=e;return n.type==="reasoning.encrypted"&&typeof n.id==="string"&&n.id.length>0&&typeof n.data==="string"&&n.data.length>0}function G(e,n){if(e)return e;if(nr("PI_CACHE_RETENTION",n)==="long")return"long";return"short"}var se=(e,n,t)=>{let r=new Vt;return(async()=>{let s={role:"assistant",content:[],api:e.api,provider:e.provider,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"stop",timestamp:Date.now()};try{let g=z(e.provider,t?.apiKey,t?.headers),f=P(e),k=zn(n.tools,f.supportsOpenAIGrammarTools),i=G(t?.cacheRetention,t?.env),d=i==="none"?void 0:t?.sessionId,l=oe(e,n,g,t?.headers,d,f),a=ie(e,n,t,f,i,k),m=await t?.onPayload?.(a,e);if(m!==void 0)a=m;let y={...t?.signal?{signal:t.signal}:{},...t?.timeoutMs!==void 0?{timeout:t.timeoutMs}:{},maxRetries:0},{data:v,response:C}=await $o(()=>l.chat.completions.create(a,y).withResponse(),{maxRetries:t?.maxRetries,maxRetryDelayMs:t?.maxRetryDelayMs,signal:t?.signal});await t?.onResponse?.({status:C.status,headers:Xr(C.headers)},e),r.push({type:"start",partial:s});let M=null,h=null,T=!1,x=new Map,E=new Map,O=new Map,F=s.content,w=(o)=>F.indexOf(o),q=(o)=>{let u=o.customInput?.property;if(u===void 0)return"";let _=o.arguments[u];return typeof _==="string"?_:""},L=(o,u,_)=>{let c=o.customInput;if(!c)return;let A=Xl(c.jsonBuffer,c.property,u,_);return o.arguments={[c.property]:u},A},H=(o)=>{let u=w(o);if(u===-1)return;if(o.type==="text")r.push({type:"text_end",contentIndex:u,content:o.text,partial:s});else if(o.type==="thinking")r.push({type:"thinking_end",contentIndex:u,content:o.thinking,partial:s});else if(o.type==="toolCall"){if(o.customInput){let _=L(o,q(o),!0);if(_!==void 0)r.push({type:"toolcall_delta",contentIndex:u,delta:_,partial:s})}else o.arguments=Qr(o.partialArgs);delete o.partialArgs,delete o.customInput,delete o.streamIndex,r.push({type:"toolcall_end",contentIndex:u,toolCall:o,partial:s})}},W=()=>{if(!M)M={type:"text",text:""},F.push(M),r.push({type:"text_start",contentIndex:w(M),partial:s});return M},U=(o)=>{if(!h)h={type:"thinking",thinking:"",thinkingSignature:o},F.push(h),r.push({type:"thinking_start",contentIndex:w(h),partial:s});return h},J=(o)=>{if(!o.id)return;let u=O.get(o.id);if(u)o.thoughtSignature=u,O.delete(o.id)},V=(o)=>{let u=typeof o.index==="number"?o.index:void 0,_=o.function?.name??o.custom?.name??"",c=u!==void 0?x.get(u):void 0;if(!c&&o.id)c=E.get(o.id);if(!c){let A=o.custom?k.get(_)??"input":void 0,S=A!==void 0;if(c={type:"toolCall",id:o.id||"",name:_,arguments:S?{[A]:""}:{},partialArgs:S?void 0:"",customInput:S?{property:A,jsonBuffer:{input:"",started:!1,closed:!1}}:void 0,streamIndex:u},u!==void 0)x.set(u,c);if(o.id)E.set(o.id,c);F.push(c),r.push({type:"toolcall_start",contentIndex:w(c),partial:s})}if(u!==void 0&&c.streamIndex===void 0)c.streamIndex=u,x.set(u,c);if(o.id)E.set(o.id,c);if(!c.name&&_)c.name=_;if(o.custom&&!c.customInput){let A=k.get(c.name)??"input";c.arguments={[A]:""},c.customInput={property:A,jsonBuffer:{input:"",started:!1,closed:!1}},delete c.partialArgs}return J(c),c};for await(let o of v){if(!o||typeof o!=="object")continue;if(s.responseId||=o.id,typeof o.model==="string"&&o.model.length>0&&o.model!==e.id)s.responseModel||=o.model;if(o.usage)s.usage=N(o.usage,e);let u=Array.isArray(o.choices)?o.choices[0]:void 0;if(!u)continue;if(!o.usage&&u.usage)s.usage=N(u.usage,e);if(u.finish_reason){let _=ye(u.finish_reason);if(s.stopReason=_.stopReason,_.errorMessage)s.errorMessage=_.errorMessage;T=!0}if(u.delta){if(u.delta.content!==null&&u.delta.content!==void 0&&u.delta.content.length>0){let p=W();p.text+=u.delta.content,r.push({type:"text_delta",contentIndex:w(p),delta:u.delta.content,partial:s})}let _=["reasoning_content","reasoning","reasoning_text"],c=u.delta,A=null;for(let p of _){let R=c[p];if(typeof R==="string"&&R.length>0){A=p;break}}if(A){let p=c[A];if(typeof p==="string"&&p.length>0){let R=e.provider==="opencode-go"&&A==="reasoning"?"reasoning_content":A,I=U(R);I.thinking+=p,r.push({type:"thinking_delta",contentIndex:w(I),delta:p,partial:s})}}if(u?.delta?.tool_calls)for(let p of u.delta.tool_calls){let R=V(p);if(!R.id&&p.id)R.id=p.id,E.set(p.id,R);let I=p.function?.name??p.custom?.name;if(!R.name&&I)R.name=I;let b="";if(p.function?.arguments)b=p.function.arguments,R.partialArgs=(R.partialArgs??"")+p.function.arguments,R.arguments=Qr(R.partialArgs);else if(p.custom?.input){let Z=q(R)+p.custom.input;b=L(R,Z,!1)??""}r.push({type:"toolcall_delta",contentIndex:w(R),delta:b,partial:s})}let S=u.delta.reasoning_details;if(Array.isArray(S)){for(let p of S)if(re(p)){let R=JSON.stringify(p),I=E.get(p.id);if(I)I.thoughtSignature=R;else O.set(p.id,R)}}}}for(let o of F)H(o);if(t?.signal?.aborted)throw Error("Request was aborted");if(s.stopReason==="aborted")throw Error("Request was aborted");if(s.stopReason==="error")throw Error(s.errorMessage||"Provider returned an error stop reason");if(!T)throw Error("Stream ended without finish_reason");r.push({type:"done",reason:s.stopReason,message:s}),r.end()}catch(g){for(let k of s.content)delete k.index,delete k.partialArgs,delete k.customInput,delete k.streamIndex;s.stopReason=t?.signal?.aborted?"aborted":"error",s.errorMessage=un(cn(g));let f=g?.error?.metadata?.raw;if(f&&!s.errorMessage.includes(String(f)))s.errorMessage+=`
3
+ ${f}`;r.push({type:"error",reason:s.stopReason,error:s}),r.end()}})(),r},qe=(e,n,t)=>{z(e.provider,t?.apiKey,t?.headers);let r=xr(e,n,t,t?.apiKey),s=t?.reasoning?Ur(e,t.reasoning):void 0,g=s==="off"?void 0:s,f=t?.toolChoice;return se(e,n,{...r,reasoningEffort:g,toolChoice:f})};function oe(e,n,t,r,s,g=P(e)){let f={...e.headers};if(e.provider==="github-copilot"){let k=ws(n.messages),i=xs({messages:n.messages,hasImages:k});Object.assign(f,i)}if(s&&g.sendSessionAffinityHeaders)if(g.sessionAffinityFormat==="openrouter")f["x-session-id"]=s;else{if(g.sessionAffinityFormat==="openai")f.session_id=s;f["x-client-request-id"]=s,f["x-session-affinity"]=s}if(r)Object.assign(f,r);return new Qe({apiKey:t,baseURL:e.baseUrl,dangerouslyAllowBrowser:!0,defaultHeaders:f})}function ie(e,n,t,r=P(e),s=G(t?.cacheRetention,t?.env),g=zn(n.tools,r.supportsOpenAIGrammarTools)){let f=me(e,n,r,{grammarToolInputProperties:g}),k=fe(r,s),i={model:e.id,messages:f,stream:!0,prompt_cache_key:e.baseUrl.includes("api.openai.com")&&s!=="none"||s==="long"&&r.supportsLongCacheRetention?Go(t?.sessionId):void 0,prompt_cache_retention:s==="long"&&r.supportsLongCacheRetention?"24h":void 0};if(r.supportsUsageInStreaming!==!1)i.stream_options={include_usage:!0};if(r.supportsStore)i.store=!1;if(t?.maxTokens)if(r.maxTokensField==="max_tokens")i.max_tokens=t.maxTokens;else i.max_completion_tokens=t.maxTokens;if(t?.temperature!==void 0)i.temperature=t.temperature;let d=r.deferredToolsMode==="kimi"?X(n.messages):new Set,l=n.tools?.filter((a)=>!d.has(a.name));if(l&&l.length>0){if(i.tools=K(l,r),r.zaiToolStream)i.tool_stream=!0}else if(Q(n.messages))i.tools=[];if(k)le(f,i.tools,k);if(t?.toolChoice)i.tool_choice=t.toolChoice;if(r.thinkingFormat==="zai"&&e.reasoning){let a=i;if(a.thinking=t?.reasoningEffort?{type:"enabled",clear_thinking:!1}:{type:"disabled"},t?.reasoningEffort&&r.supportsReasoningEffort){let m=e.thinkingLevelMap?.[t.reasoningEffort],y=m===void 0?t.reasoningEffort:m;if(typeof y==="string")a.reasoning_effort=y}}else if(r.thinkingFormat==="qwen"&&e.reasoning)i.enable_thinking=!!t?.reasoningEffort;else if(r.thinkingFormat==="qwen-chat-template"&&e.reasoning)i.chat_template_kwargs={enable_thinking:!!t?.reasoningEffort,preserve_thinking:!0};else if(r.thinkingFormat==="chat-template"&&e.reasoning){let a=ae(e,t,r);if(a)i.chat_template_kwargs=a}else if(r.thinkingFormat==="deepseek"&&e.reasoning){if(t?.reasoningEffort)i.thinking={type:"enabled"};else if(e.thinkingLevelMap?.off!==null)i.thinking={type:"disabled"};if(t?.reasoningEffort&&r.supportsReasoningEffort)i.reasoning_effort=e.thinkingLevelMap?.[t.reasoningEffort]??t.reasoningEffort}else if(r.thinkingFormat==="openrouter"&&e.reasoning){let a=i;if(t?.reasoningEffort)a.reasoning={effort:e.thinkingLevelMap?.[t.reasoningEffort]??t.reasoningEffort};else if(e.thinkingLevelMap?.off!==null)a.reasoning={effort:e.thinkingLevelMap?.off??"none"}}else if(r.thinkingFormat==="ant-ling"&&e.reasoning&&t?.reasoningEffort){let a=e.thinkingLevelMap?.[t.reasoningEffort];if(typeof a==="string")i.reasoning={effort:a}}else if(r.thinkingFormat==="together"&&e.reasoning){let a=i;if(a.reasoning={enabled:!!t?.reasoningEffort},t?.reasoningEffort&&r.supportsReasoningEffort)a.reasoning_effort=e.thinkingLevelMap?.[t.reasoningEffort]??t.reasoningEffort}else if(r.thinkingFormat==="string-thinking"&&e.reasoning){let a=i;if(t?.reasoningEffort)a.thinking=e.thinkingLevelMap?.[t.reasoningEffort]??t.reasoningEffort;else if(e.thinkingLevelMap?.off!==null)a.thinking=e.thinkingLevelMap?.off??"none"}else if(t?.reasoningEffort&&e.reasoning&&r.supportsReasoningEffort)i.reasoning_effort=e.thinkingLevelMap?.[t.reasoningEffort]??t.reasoningEffort;else if(!t?.reasoningEffort&&e.reasoning&&r.supportsReasoningEffort){let a=e.thinkingLevelMap?.off;if(typeof a==="string")i.reasoning_effort=a}if(e.compat?.openRouterRouting)i.provider=e.compat.openRouterRouting;if(e.compat?.vercelGatewayRouting){let a=e.compat.vercelGatewayRouting;if(a.only||a.order){let m={};if(a.only)m.only=a.only;if(a.order)m.order=a.order;i.providerOptions={gateway:m}}}return i}function ae(e,n,t){let r={};for(let[s,g]of Object.entries(t.chatTemplateKwargs)){let f=ue(e,n,g);if(f!==void 0)r[s]=f}return Object.keys(r).length>0?r:void 0}function ue(e,n,t){if(typeof t!=="object"||t===null)return t;let r=n?.reasoningEffort;if(!r&&t.omitWhenOff)return;if(t.$var==="thinking.enabled")return!!r;let s=r?e.thinkingLevelMap?.[r]:e.thinkingLevelMap?.off;return s===void 0?r:typeof s==="string"?s:void 0}function fe(e,n){if(e.cacheControlFormat!=="anthropic"||n==="none")return;let t=n==="long"&&e.supportsLongCacheRetention?"1h":void 0;return{type:"ephemeral",...t?{ttl:t}:{}}}function le(e,n,t){ce(e,t),ge(n,t),pe(e,t)}function ce(e,n){for(let t of e)if(t.role==="system"||t.role==="developer"){de(t,n);return}}function pe(e,n){for(let t=e.length-1;t>=0;t--){let r=e[t];if(r.role==="user"||r.role==="assistant"||r.role==="tool"){if(he(r,n))return}}}function ge(e,n){if(!e||e.length===0)return;let t=e[e.length-1];t.cache_control=n}function de(e,n){return j(e,n)}function he(e,n){if(e.role==="user"||e.role==="assistant"||e.role==="tool")return j(e,n);return!1}function j(e,n){let t=e.content;if(typeof t==="string"){if(t.length===0)return!1;return e.content=[{type:"text",text:t,cache_control:n}],!0}if(!Array.isArray(t))return!1;for(let r=t.length-1;r>=0;r--){let s=t[r];if(s?.type==="text"){let g=s;return g.cache_control=n,!0}}return!1}function me(e,n,t,r){let s=[],g=(i)=>{if(i.includes("|")){let d=i.indexOf("|"),l=i.slice(0,d).replace(/[^a-zA-Z0-9_-]/g,"_"),a=i.slice(d+1).replace(/[^a-zA-Z0-9_-]/g,"_"),m=a.length>0?`${l}_${a}`:l;if(m.length<=40)return m;let y=ca(i).slice(0,8);return`${l.slice(0,Math.max(1,40-y.length-1))}_${y}`}if(e.provider==="openai")return i.length>40?i.slice(0,40):i;return i},f=ao(n.messages,e,(i)=>g(i));if(n.systemPrompt){let d=e.reasoning&&t.supportsDeveloperRole?"developer":"system";s.push({role:d,content:Fe(n.systemPrompt)})}let k=null;for(let i=0;i<f.length;i++){let d=f[i];if(t.requiresAssistantAfterToolResult&&k==="toolResult"&&d.role==="user")s.push({role:"assistant",content:"I have processed the tool results."});if(d.role==="user")if(typeof d.content==="string")s.push({role:"user",content:Fe(d.content)});else{let l=d.content.map((a)=>{if(a.type==="text")return{type:"text",text:Fe(a.text)};else return{type:"image_url",image_url:{url:`data:${a.mimeType};base64,${a.data}`}}});if(l.length===0)continue;s.push({role:"user",content:l})}else if(d.role==="assistant"){let l={role:"assistant",content:t.requiresAssistantAfterToolResult?"":null},a=d.content.filter(D).filter((h)=>h.text.trim().length>0).map((h)=>({type:"text",text:Fe(h.text)})),m=a.map((h)=>h.text).join(""),y=d.content.filter(ee).filter((h)=>h.thinking.trim().length>0);if(y.length>0)if(t.requiresThinkingAsText){let h=y.map((T)=>Fe(T.thinking)).join(`
4
+
5
+ `);l.content=[{type:"text",text:h},...a]}else{if(m.length>0)l.content=m;let h=y[0].thinkingSignature;if(e.provider==="opencode-go"&&h==="reasoning")h="reasoning_content";if(h&&h.length>0)l[h]=y.map((T)=>T.thinking).join(`
6
+ `)}else if(m.length>0)l.content=m;let v=d.content.filter(te);if(v.length>0){l.tool_calls=v.map((T)=>{let x=r?.grammarToolInputProperties?.get(T.name);if(x!==void 0)return{id:T.id,type:"custom",custom:{name:T.name,input:Fe(Jl(T.name,T.arguments,x))}};return{id:T.id,type:"function",function:{name:T.name,arguments:JSON.stringify(T.arguments)}}});let h=v.filter((T)=>T.thoughtSignature).map((T)=>{try{return JSON.parse(T.thoughtSignature)}catch{return null}}).filter(Boolean);if(h.length>0)l.reasoning_details=h}if(t.requiresReasoningContentOnAssistantMessages&&e.reasoning&&l.reasoning_content===void 0)l.reasoning_content="";let C=l.content;if(!(C!==null&&C!==void 0&&(typeof C==="string"?C.length>0:C.length>0))&&!l.tool_calls)continue;s.push(l)}else if(d.role==="toolResult"){let l=[],a=new Set,m=i;for(;m<f.length&&f[m].role==="toolResult";m++){let y=f[m],v=y.content.filter(D).map((x)=>x.text).join(`
7
+ `),C=y.content.some((x)=>x.type==="image"),h=v.length>0?v:C?"(see attached image)":"(no tool output)",T={role:"tool",content:Fe(h),tool_call_id:y.toolCallId};if(t.requiresToolResultName&&y.toolName)T.name=y.toolName;if(s.push(T),t.deferredToolsMode==="kimi")for(let x of y.addedToolNames??[])a.add(x);if(C&&e.input.includes("image")){for(let x of y.content)if(ne(x))l.push({type:"image_url",image_url:{url:`data:${x.mimeType};base64,${x.data}`}})}}if(i=m-1,l.length>0){if(t.requiresAssistantAfterToolResult)s.push({role:"assistant",content:"I have processed the tool results."});s.push({role:"user",content:[{type:"text",text:"Attached image(s) from tool result:"},...l]}),k="user"}else k="toolResult";if(a.size>0){let y=Y(n.tools,a);if(y.length>0){let v={role:"system",tools:K(y,t)};s.push(v)}}continue}k=d.role}return s}function K(e,n){return e.map((t)=>{let r=Ui(t,n.supportsOpenAIGrammarTools);if(r)return{type:"custom",custom:{name:t.name,description:t.description,format:{type:"grammar",grammar:{syntax:r.format,definition:r.definition}}}};let s=oo(t,n.supportsStrictMode!==!1);return{type:"function",function:{name:t.name,description:t.description,parameters:t.parameters,...n.supportsStrictMode!==!1&&{strict:s??!1}}}})}function N(e,n){let t=e.prompt_tokens||0,r=e.prompt_tokens_details?.cached_tokens??e.prompt_cache_hit_tokens??0,s=e.prompt_tokens_details?.cache_write_tokens||0,g=Math.max(0,t-r-s),f=e.completion_tokens||0,k={input:g,output:f,cacheRead:r,cacheWrite:s,reasoning:e.completion_tokens_details?.reasoning_tokens||0,totalTokens:g+f+r+s,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}};return en(n,k),k}function ye(e){if(e===null)return{stopReason:"stop"};switch(e){case"stop":case"end":return{stopReason:"stop"};case"length":return{stopReason:"length"};case"function_call":case"tool_calls":return{stopReason:"toolUse"};case"content_filter":return{stopReason:"error",errorMessage:"Provider finish_reason: content_filter"};case"network_error":return{stopReason:"error",errorMessage:"Provider finish_reason: network_error"};default:return{stopReason:"error",errorMessage:`Provider finish_reason: ${e}`}}}function ke(e){let{provider:n,baseUrl:t}=e,r=n==="zai"||n==="zai-coding-cn"||t.includes("api.z.ai")||t.includes("open.bigmodel.cn"),s=n==="together"||t.includes("api.together.ai")||t.includes("api.together.xyz"),g=n==="moonshotai"||n==="moonshotai-cn"||t.includes("api.moonshot."),f=n==="openrouter"||t.includes("openrouter.ai"),k=n==="cloudflare-workers-ai"||t.includes("api.cloudflare.com"),i=n==="cloudflare-ai-gateway"||t.includes("gateway.ai.cloudflare.com"),d=n==="nvidia"||t.includes("integrate.api.nvidia.com"),l=n==="ant-ling"||t.includes("api.ant-ling.com"),a=d||n==="cerebras"||t.includes("cerebras.ai")||n==="xai"||t.includes("api.x.ai")||s||t.includes("chutes.ai")||t.includes("deepseek.com")||r||g||n==="opencode"||t.includes("opencode.ai")||k||i||l,m=t.includes("chutes.ai")||g||i||s||d||l,y=n==="xai"||t.includes("api.x.ai"),v=n==="deepseek"||t.includes("deepseek.com"),C=f&&(e.id.startsWith("anthropic/")||e.id.startsWith("openai/")),M=n==="openrouter"&&e.id.startsWith("anthropic/")?"anthropic":void 0;return{supportsStore:!a,supportsDeveloperRole:C||!a&&!f,supportsReasoningEffort:!y&&!r&&!g&&!s&&!i&&!d&&!l,supportsUsageInStreaming:!0,maxTokensField:m?"max_tokens":"max_completion_tokens",requiresToolResultName:!1,requiresAssistantAfterToolResult:!1,requiresThinkingAsText:!1,requiresReasoningContentOnAssistantMessages:v,thinkingFormat:v?"deepseek":r?"zai":s?"together":l?"ant-ling":f?"openrouter":"openai",openRouterRouting:{},vercelGatewayRouting:{},chatTemplateKwargs:{},zaiToolStream:!1,supportsStrictMode:!g&&!s&&!i&&!d,supportsOpenAIGrammarTools:!1,cacheControlFormat:M,sendSessionAffinityHeaders:!1,deferredToolsMode:void 0,sessionAffinityFormat:f?"openrouter":"openai",supportsLongCacheRetention:!(s||k||i||d||l)}}function P(e){let n=ke(e);if(!e.compat)return n;return{supportsStore:e.compat.supportsStore??n.supportsStore,supportsDeveloperRole:e.compat.supportsDeveloperRole??n.supportsDeveloperRole,supportsReasoningEffort:e.compat.supportsReasoningEffort??n.supportsReasoningEffort,supportsUsageInStreaming:e.compat.supportsUsageInStreaming??n.supportsUsageInStreaming,maxTokensField:e.compat.maxTokensField??n.maxTokensField,requiresToolResultName:e.compat.requiresToolResultName??n.requiresToolResultName,requiresAssistantAfterToolResult:e.compat.requiresAssistantAfterToolResult??n.requiresAssistantAfterToolResult,requiresThinkingAsText:e.compat.requiresThinkingAsText??n.requiresThinkingAsText,requiresReasoningContentOnAssistantMessages:e.compat.requiresReasoningContentOnAssistantMessages??n.requiresReasoningContentOnAssistantMessages,thinkingFormat:e.compat.thinkingFormat??n.thinkingFormat,openRouterRouting:e.compat.openRouterRouting??{},vercelGatewayRouting:e.compat.vercelGatewayRouting??n.vercelGatewayRouting,chatTemplateKwargs:e.compat.chatTemplateKwargs??n.chatTemplateKwargs,zaiToolStream:e.compat.zaiToolStream??n.zaiToolStream,supportsStrictMode:e.compat.supportsStrictMode??n.supportsStrictMode,supportsOpenAIGrammarTools:e.compat.supportsOpenAIGrammarTools??n.supportsOpenAIGrammarTools,cacheControlFormat:e.compat.cacheControlFormat??n.cacheControlFormat,sendSessionAffinityHeaders:e.compat.sendSessionAffinityHeaders??n.sendSessionAffinityHeaders,deferredToolsMode:e.compat.deferredToolsMode??n.deferredToolsMode,sessionAffinityFormat:e.compat.sessionAffinityFormat??n.sessionAffinityFormat,supportsLongCacheRetention:e.compat.supportsLongCacheRetention??n.supportsLongCacheRetention}}export{me as convertMessages,se as stream,qe as streamSimple};
@@ -0,0 +1,4 @@
1
+ import{dn,C,t,o,L,A,iA,fA,Vd,Fu,ff,jw,sC,$f,Wh,qC,sp,ip,rn,fe,ce,pe,ue,It,yn,Mg,Kn,po,ie}from"./chunk-6bhn1p8v.js";import{ho}from"./chunk-r7dty1tg.js";C();var y=(g)=>g.replace(/<@([a-zA-Z0-9_-]+)>/g,"@$1").replace(/^\[([^\]]+)\]:/gm,"\\[$1\\]:");function Tl({sessionId:g,open:N,onOpenChange:_}){let{data:x,isLoading:S}=L({queryKey:["agent-sessions",g,"entries"],queryFn:async()=>{if(!g)return[];let s=await A.api["agent-sessions"][":sessionId"].entries.$get({param:{sessionId:g}});if(!s.ok)throw Error("Failed to fetch session logs");return await s.json()},enabled:N&&!!g});return t(fe,{open:N,onOpenChange:_,children:o(ce,{className:"sm:max-w-2xl max-h-[80vh] flex flex-col p-6 overflow-hidden bg-background/95 backdrop-blur-md border border-foreground/15 shadow-2xl",children:[o(pe,{className:"pb-4 border-b border-foreground/15",children:[o(ue,{className:"flex items-center gap-2 text-xl font-bold",children:[t(ho,{className:"w-5 h-5 text-violet-500"}),fA()]}),t(It,{children:iA()})]}),t("div",{className:"flex-1 overflow-y-auto pr-1 py-4 space-y-4 min-h-0 select-text",children:S?o("div",{className:"space-y-4",children:[o("div",{className:"flex gap-4",children:[t(ie,{className:"h-5 w-5 rounded-full shrink-0"}),o("div",{className:"flex-1 space-y-2",children:[t(ie,{className:"h-4 w-1/4"}),t(ie,{className:"h-20 w-full"})]})]}),o("div",{className:"flex gap-4",children:[t(ie,{className:"h-5 w-5 rounded-full shrink-0"}),o("div",{className:"flex-1 space-y-2",children:[t(ie,{className:"h-4 w-1/4"}),t(ie,{className:"h-12 w-full"})]})]})]}):x&&x.length>0?t("div",{className:"flex flex-col",children:x.map((s)=>{let a=s.entry,b=a?.timestamp||s.timestamp,f="";if(typeof b==="string"||typeof b==="number"){let e=new Date(b);if(!isNaN(e.getTime()))f=yn(e.toISOString())}if(a&&typeof a==="object"){if(a.type==="custom_message"){if(a.customType==="context")return null;if(a.customType==="shumai_message"){let e=Mg(a.details),m=typeof a.content==="string"?a.content:"",p=e?`${m}
2
+
3
+ ${e}`.trim():m,w="bg-primary/10 text-primary",v=Wh();return o("div",{className:"relative pl-6 pb-6 last:pb-0",children:[t("div",{className:"absolute left-[9px] top-2 bottom-0 w-0.5 bg-foreground/10 last:hidden"}),t("div",{className:"absolute left-0 top-1.5 h-5 w-5 rounded-full border-4 border-background flex items-center justify-center bg-primary"}),o("div",{className:"flex flex-col gap-1.5 bg-muted/30 dark:bg-muted/10 p-3 rounded-lg border border-foreground/5 backdrop-blur-xs w-full",children:[o("div",{className:"flex items-center justify-between gap-2",children:[o("div",{className:"flex items-center gap-2 flex-wrap",children:[t("span",{className:"text-[10px] px-2 py-0.5 rounded-full font-semibold uppercase tracking-wider bg-primary/10 text-primary",children:v}),o("span",{className:"text-[10px] font-mono text-muted-foreground bg-muted/50 px-1.5 py-0.5 rounded border border-foreground/10 select-all",title:Fu(),children:[Fu(),": ",s.id]})]}),t("span",{className:"text-[10px] text-muted-foreground/60 shrink-0",children:f})]}),t("div",{className:"text-xs text-foreground/90 whitespace-pre-wrap leading-relaxed font-sans",children:p})]})]},s.id)}}if(a.type==="message"&&a.message){let e=a.message,m="bg-gray-100 text-gray-800 dark:bg-gray-800 dark:text-gray-200",p=String(e.role||"");if(e.role==="user")m="bg-primary/10 text-primary",p=Wh();else if(e.role==="assistant")m="bg-violet-100 text-violet-800 dark:bg-violet-900/30 dark:text-violet-300",p=sC();else if(e.role==="toolResult")m=e.isError?"bg-red-100 text-red-800 dark:bg-red-900/30 dark:text-red-300":"bg-emerald-100 text-emerald-800 dark:bg-emerald-900/30 dark:text-emerald-300",p=ip({name:String(e.toolName||rn())});else if(e.role==="thought")m="bg-amber-100 text-amber-800 dark:bg-amber-900/30 dark:text-amber-300",p=$f();let w=(n)=>{let r=n;if(typeof n==="string")try{r=JSON.parse(n)}catch{}if(r&&typeof r==="object"&&!Array.isArray(r))return t("div",{className:"mt-1 space-y-1.5 pt-3",children:Object.entries(r).map(([l,i])=>{let c=i&&typeof i==="object"?JSON.stringify(i,null,2):String(i);return o("div",{className:"text-xs leading-relaxed break-words",children:[o("span",{className:"font-semibold text-violet-600 dark:text-violet-400",children:[l,":"]})," ",t("span",{className:"text-foreground/90 font-mono whitespace-pre-wrap",children:c})]},l)})});return t("div",{className:"text-xs font-mono whitespace-pre-wrap",children:String(n)})},v=()=>{let n=e.content;if(!n)return null;if(typeof n==="string"){if(!n.trim())return null;return t("div",{className:"text-xs text-foreground/80 dark:text-foreground/95 leading-relaxed prose prose-sm dark:prose-invert max-w-none break-words",children:t(po,{children:y(n)})})}if(Array.isArray(n)){let r=[];if(n.forEach((d,l)=>{if(!d)return;if(typeof d==="string"){if(!d.trim())return;r.push(t("div",{className:"text-xs text-foreground/80 dark:text-foreground/95 leading-relaxed prose prose-sm dark:prose-invert max-w-none break-words",children:t(po,{children:y(d)})},`str-${l}`));return}if(typeof d==="object"){let i=d,c=i.type;if(c==="text"){let u=i.text;if(typeof u!=="string"||!u.trim())return;r.push(t("div",{className:"text-xs text-foreground/80 dark:text-foreground/95 leading-relaxed prose prose-sm dark:prose-invert max-w-none break-words",children:t(po,{children:y(u)})},`txt-${l}`));return}if(c==="toolCall"){let u=String(i.name||i.toolName||rn()),h=i.arguments||i.args;r.push(o("div",{className:"text-xs space-y-2 py-1",children:[o("div",{className:"font-semibold text-violet-600 dark:text-violet-400 flex items-center gap-1.5",children:[Vd()," ",t("span",{className:"font-mono bg-violet-500/10 px-1 py-0.5 rounded text-[11px]",children:u})]}),!!h&&o("div",{className:"space-y-1 pt-3",children:[t("div",{className:"text-[10px] text-muted-foreground/60 uppercase font-bold tracking-wider",children:sp()}),w(h)]})]},`tool-${l}`));return}if(c==="image"){r.push(t("div",{className:"text-xs text-muted-foreground italic flex items-center gap-1.5 py-1",children:ff()},`img-${l}`));return}let k=JSON.stringify(d,null,2);if(k==="{}")return;r.push(t("pre",{className:"text-xs text-foreground/80 font-mono whitespace-pre-wrap break-words bg-muted/20 p-2 rounded",children:k},`other-${l}`))}}),r.length===0)return null;return t("div",{className:"space-y-3 w-full",children:r.map((d,l)=>o(dn,{children:[l>0&&t(Kn,{className:"my-3 opacity-50"}),d]},l))})}return null};return o("div",{className:"relative pl-6 pb-6 last:pb-0",children:[t("div",{className:"absolute left-[9px] top-2 bottom-0 w-0.5 bg-foreground/10 last:hidden"}),t("div",{className:`absolute left-0 top-1.5 h-5 w-5 rounded-full border-4 border-background flex items-center justify-center ${e.role==="user"?"bg-primary":e.role==="assistant"?"bg-violet-500":e.role==="toolResult"?e.isError?"bg-red-500":"bg-emerald-500":"bg-amber-500"}`}),o("div",{className:"flex flex-col gap-1.5 bg-muted/30 dark:bg-muted/10 p-3 rounded-lg border border-foreground/5 backdrop-blur-xs w-full",children:[o("div",{className:"flex items-center justify-between gap-2",children:[o("div",{className:"flex items-center gap-2 flex-wrap",children:[t("span",{className:`text-[10px] px-2 py-0.5 rounded-full font-semibold uppercase tracking-wider ${m}`,children:p}),o("span",{className:"text-[10px] font-mono text-muted-foreground bg-muted/50 px-1.5 py-0.5 rounded border border-foreground/10 select-all",title:Fu(),children:[Fu(),": ",s.id]})]}),t("span",{className:"text-[10px] text-muted-foreground/60 shrink-0",children:f})]}),v()]})]},s.id)}}return o("div",{className:"relative pl-6 pb-6 last:pb-0",children:[t("div",{className:"absolute left-[9px] top-2 bottom-0 w-0.5 bg-foreground/10 last:hidden"}),t("div",{className:"absolute left-0 top-1.5 h-5 w-5 rounded-full border-4 border-background bg-gray-400"}),o("div",{className:"bg-muted/30 p-3 rounded-lg border border-foreground/5",children:[o("div",{className:"flex items-center justify-between gap-2 mb-1.5 flex-wrap",children:[o("span",{className:"text-[10px] font-mono text-muted-foreground bg-muted/50 px-1.5 py-0.5 rounded border border-foreground/10 select-all",title:"Entry ID",children:["ID: ",s.id]}),t("div",{className:"text-[10px] text-muted-foreground/60",children:f})]}),t("pre",{className:"text-xs text-foreground/80 font-mono whitespace-pre-wrap break-words",children:JSON.stringify(s.entry,null,2)})]})]},s.id)})}):o("div",{className:"flex flex-col items-center justify-center py-12 text-center text-muted-foreground",children:[t(ho,{className:"w-8 h-8 text-muted-foreground/40 mb-2 animate-pulse"}),t("p",{className:"text-sm font-medium",children:jw()}),t("p",{className:"text-xs text-muted-foreground/60 mt-1",children:qC()})]})})]})})}
4
+ export{Tl};
@@ -0,0 +1,2 @@
1
+ import{T}from"./chunk-6bhn1p8v.js";var a=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],Yr=T("sparkles",a);
2
+ export{Yr};
@@ -0,0 +1 @@
1
+ import{h,O,u,C,B,t,o,ct,Me,Ue,A,Z,ks,Pn,Gn,Ce,Ee,Ie,HA,Hy,Jd,pc,Dw,rn,st,Tt,fr,Ht,yt,wp}from"./chunk-6bhn1p8v.js";import{br}from"./chunk-cqb415s6.js";import{bn,vn,wn,hr,_t,pt}from"./chunk-66hsjnw6.js";import{Wt}from"./chunk-rhdxwebf.js";C();var k=(a)=>{if(!a)return"??";return a.split(" ").map((r)=>r[0]).slice(0,2).join("").toUpperCase()};function T(){let{projectId:a}=j.useParams(),{teamId:r,ensureTeamIdForProject:n}=st(),g=Me();h(()=>{n(a)},[a,n]);let{data:i}=Wt(wp(a)),d=i?.rootFolder,[v,N]=u(240),{fileListLeftSidebarCollapsed:m,setFileListLeftSidebarCollapsed:y}=Ht(),{data:c,isLoading:w,fetchNextPage:f,hasNextPage:p,isFetchingNextPage:l}=ct({queryKey:["collections",a],queryFn:async({pageParam:e})=>{let s=await A.api.projects[":projectId"].collections.$get({param:{projectId:a},query:{first:"20",after:e}});if(!s.ok)throw Error("Failed to fetch collections");return await s.json()},initialPageParam:"",getNextPageParam:(e)=>e.pageInfo?.cursor||void 0,enabled:!!a}),{ref:I,inView:b}=Tt();h(()=>{if(b&&p&&!l)f()},[b,p,l,f]);let x=O(()=>c?.pages.flatMap((e)=>e.data)||[],[c]);if(!r||!d||!i)return t(yt,{});return t("div",{className:"flex flex-1 flex-col bg-background min-h-0",children:o("div",{className:"flex flex-1 overflow-hidden relative",children:[!m&&t("div",{className:"md:hidden fixed inset-0 bg-black/50 z-40",onClick:()=>y(!0)}),!m&&o(B,{children:[t("div",{className:"bg-background",style:{width:v},children:t(fr,{teamId:r,projectId:a,projectName:i.name??"",rootFolderId:d})}),t(br,{onResize:(e)=>{N((s)=>Math.max(180,Math.min(400,s+e)))},className:"hidden md:block"})]}),o("div",{className:"flex-1 flex flex-col min-h-0 bg-card overflow-hidden",children:[t("header",{className:"h-14 border-b flex items-center justify-between px-6 shrink-0 bg-background/50 backdrop-blur-sm sticky top-0 z-10",children:o("div",{className:"flex items-center gap-2",children:[t(ks,{className:"h-5 w-5 text-primary"}),t("h1",{className:"font-bold text-lg text-foreground",children:HA()})]})}),t("div",{className:"flex-1 overflow-y-auto p-6",children:w?t("div",{className:"flex justify-center items-center h-64",children:t("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})}):x.length===0?o("div",{className:"flex flex-col items-center justify-center h-64 text-muted-foreground gap-3",children:[t(Gn,{className:"h-10 w-10 text-muted-foreground/50"}),t("p",{children:Dw()})]}):o("div",{className:"border border-border rounded-xl bg-background overflow-hidden shadow-xs",children:[o(bn,{children:[t(vn,{children:o(hr,{className:"hover:bg-transparent bg-muted/20",children:[t(_t,{className:"font-semibold px-4 py-3",children:Hy()}),t(_t,{className:"font-semibold px-4 py-3",children:pc()}),t(_t,{className:"font-semibold px-4 py-3 w-[200px]",children:Jd()})]})}),t(wn,{children:x.map((e)=>o(hr,{className:"hover:bg-muted/10 transition-colors cursor-pointer",onClick:()=>g({to:"/projects/$projectId/collections/$collectionId",params:{projectId:a,collectionId:e.id}}),children:[t(pt,{className:"font-medium px-4 py-3.5",children:o("div",{className:"flex items-center gap-2",children:[t(ks,{className:"h-4 w-4 text-primary shrink-0"}),t("span",{className:"text-foreground font-semibold hover:underline",children:e.name})]})}),t(pt,{className:"px-4 py-3.5",children:o("div",{className:"flex items-center gap-2",children:[o(Ce,{className:"h-6 w-6",children:[e.creator?.image&&t(Ee,{src:e.creator.image,alt:e.creator.name,className:"object-cover"}),t(Ie,{className:"text-[10px]",children:k(e.creator?.name)})]}),t("span",{className:"text-sm font-medium text-foreground truncate max-w-[200px]",children:e.creator?.name||rn()})]})}),t(pt,{className:"px-4 py-3.5 text-muted-foreground text-sm",children:o("div",{className:"flex items-center gap-2",children:[t(Pn,{className:"h-3.5 w-3.5 text-muted-foreground/70"}),t("span",{children:new Date(e.createdAt).toLocaleDateString()})]})})]},e.id))})]}),t("div",{ref:I,className:"h-10 w-full flex items-center justify-center",children:l&&t(Z,{className:"h-6 w-6 animate-spin text-primary"})})]})})]})]})})}var j=Ue("/projects/$projectId/collections/")({component:T});export{j as Route};