@shumai-one/shumai 0.5.2 → 0.5.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 (138) hide show
  1. package/bin/{chunk-zf5cyxnt.js → chunk-03zkxckm.js} +1 -1
  2. package/bin/{chunk-2w6gve12.js → chunk-04nqnkzs.js} +3 -3
  3. package/bin/{chunk-rw5h0n0s.js → chunk-157axqz1.js} +1 -1
  4. package/bin/{chunk-w9z27p0m.js → chunk-1tesbv8w.js} +1 -1
  5. package/bin/{chunk-vzdgsfkf.js → chunk-24da4wg9.js} +1 -1
  6. package/bin/chunk-24nx3krz.js +2 -0
  7. package/bin/{chunk-twpc640e.js → chunk-26am2rzm.js} +1 -1
  8. package/bin/{chunk-8ayz61rc.js → chunk-2pt9h882.js} +3 -3
  9. package/bin/{chunk-mn108p93.js → chunk-2rrcdhkj.js} +1 -1
  10. package/bin/{chunk-ryepy5er.js → chunk-2w2bknn2.js} +4 -4
  11. package/bin/{chunk-ypkkfwfb.js → chunk-3ahax79y.js} +2 -2
  12. package/bin/{chunk-zdzkjp4q.js → chunk-3fjgf7eb.js} +2 -2
  13. package/bin/{chunk-rmvhyqyb.js → chunk-3wcvema0.js} +3 -3
  14. package/bin/{chunk-kvwec0p3.js → chunk-40tmh04g.js} +2 -2
  15. package/bin/chunk-45p7d22e.js +2 -0
  16. package/bin/chunk-461gcgrs.js +2 -0
  17. package/bin/{chunk-p0j4wpa5.js → chunk-4bc3gqmn.js} +1 -1
  18. package/bin/{chunk-8tzfcqtb.js → chunk-4nkwe7dz.js} +1 -1
  19. package/bin/{chunk-eqr0znmc.js → chunk-59ayg5am.js} +1 -1
  20. package/bin/{chunk-8zgq5sav.js → chunk-5ebb2pdf.js} +2 -2
  21. package/bin/{chunk-n76w2wcr.js → chunk-5y3kx4kk.js} +1 -1
  22. package/bin/{chunk-d2dgazjj.js → chunk-68xsb3t8.js} +1 -1
  23. package/bin/{chunk-n9vp9nbg.js → chunk-6hs63sva.js} +30 -30
  24. package/bin/{chunk-bpxw19ez.js → chunk-6pwf7qa6.js} +1 -1
  25. package/bin/{chunk-f5z3096k.js → chunk-6sq6dfa1.js} +2 -2
  26. package/bin/chunk-87secbzy.js +1 -0
  27. package/bin/chunk-8pykp70z.js +1 -0
  28. package/bin/{chunk-3pm6q6kg.js → chunk-8ts3xkme.js} +1 -1
  29. package/bin/{chunk-rza95y4z.js → chunk-909h3qzp.js} +2 -2
  30. package/bin/{chunk-0v9srsdz.js → chunk-929abwgr.js} +1 -1
  31. package/bin/{chunk-j53sjkxt.js → chunk-9ca8a5f2.js} +1 -1
  32. package/bin/{chunk-2pw7xcrn.js → chunk-9fyb95r5.js} +1 -1
  33. package/bin/{chunk-mneeg71d.js → chunk-axeq2pq5.js} +2 -2
  34. package/bin/{chunk-r249n1xe.js → chunk-b3tkvdfk.js} +2 -2
  35. package/bin/{chunk-9ggwc289.js → chunk-b6dbqs39.js} +1 -1
  36. package/bin/{chunk-w73v578p.js → chunk-b88tdt79.js} +2 -2
  37. package/bin/{chunk-19q13a80.js → chunk-bcyvxp1c.js} +4 -4
  38. package/bin/{chunk-7qvvf0yd.js → chunk-bn0taqr3.js} +2 -2
  39. package/bin/chunk-cb37q6t0.js +1 -0
  40. package/bin/chunk-cfqny70c.js +3 -0
  41. package/bin/{chunk-ffj9cq9y.js → chunk-cqnected.js} +1 -1
  42. package/bin/{chunk-98mg3dpd.js → chunk-cvfznrnt.js} +4 -4
  43. package/bin/{chunk-951r2rx1.js → chunk-d1q1tn36.js} +1 -1
  44. package/bin/{chunk-0asthrjf.js → chunk-d1rjpbgv.js} +2 -2
  45. package/bin/{chunk-81dawvn4.js → chunk-eshwjf91.js} +2 -2
  46. package/bin/{chunk-04avc4fn.js → chunk-fa9yq17g.js} +26 -26
  47. package/bin/{chunk-m6v8vt2b.js → chunk-fnkkwna8.js} +2 -2
  48. package/bin/{chunk-3q5qkfkc.js → chunk-fpjvr3qw.js} +1 -1
  49. package/bin/{chunk-ggfx2b0f.js → chunk-fsr83nb1.js} +1 -1
  50. package/bin/{chunk-kzr6ecke.js → chunk-fznchvm7.js} +1 -1
  51. package/bin/chunk-g2z0c39g.js +1 -0
  52. package/bin/{chunk-5vqbzsjv.js → chunk-gvcjqcjf.js} +1 -1
  53. package/bin/{chunk-0ge2mm8j.js → chunk-hbnpx0a5.js} +1 -1
  54. package/bin/{chunk-tvkekn4z.js → chunk-hgy9rqt1.js} +1 -1
  55. package/bin/chunk-hk659cg2.css +1 -0
  56. package/bin/{chunk-8ny7wvzb.js → chunk-hn2g40r6.js} +1 -1
  57. package/bin/{chunk-0y4zq3y4.js → chunk-hsx4pns6.js} +1 -1
  58. package/bin/{chunk-bbcmhcvc.js → chunk-hy5ncvpf.js} +2 -2
  59. package/bin/{chunk-5nqvqvqp.js → chunk-j420aqk8.js} +3 -3
  60. package/bin/{chunk-t1yamxgk.js → chunk-k3ds96cb.js} +1 -1
  61. package/bin/{chunk-dppfek34.js → chunk-m41tbrvt.js} +2 -2
  62. package/bin/chunk-m9f21ye9.js +1 -0
  63. package/bin/chunk-md7pgk86.js +2 -0
  64. package/bin/chunk-me3zmpj5.js +14 -0
  65. package/bin/chunk-mg6sybt0.js +1 -0
  66. package/bin/{chunk-jgfye6nf.js → chunk-mzme3m82.js} +1 -1
  67. package/bin/{chunk-ce0bhc72.js → chunk-n08h1jgx.js} +1 -1
  68. package/bin/{chunk-ae6zgjhd.js → chunk-ncv8v6mj.js} +2 -2
  69. package/bin/{chunk-cx32wsa1.js → chunk-nmd1901j.js} +1 -1
  70. package/bin/{chunk-wnqxyqrg.js → chunk-np39aknv.js} +2 -2
  71. package/bin/{chunk-dche0gy0.js → chunk-p7zw53ep.js} +1 -1
  72. package/bin/{chunk-xr2v0d6y.js → chunk-ppb4aj0y.js} +4 -4
  73. package/bin/{chunk-15vsw36h.js → chunk-pwq6dbb5.js} +5 -5
  74. package/bin/chunk-q1gfypy3.js +2 -0
  75. package/bin/{chunk-0j22699g.js → chunk-q4qqmes7.js} +2 -2
  76. package/bin/{chunk-vm2pz2hm.js → chunk-q7t5zs7n.js} +2 -2
  77. package/bin/{chunk-e439kt05.js → chunk-qcpeefhr.js} +1 -1
  78. package/bin/{chunk-6rn094yj.js → chunk-qjdvs1s5.js} +1 -1
  79. package/bin/{chunk-9zgqjdx1.js → chunk-qqapw198.js} +2 -2
  80. package/bin/chunk-qx553512.js +211 -0
  81. package/bin/chunk-r3s1x5wp.js +1 -0
  82. package/bin/{chunk-rtaya5wc.js → chunk-rh8dy99a.js} +2 -2
  83. package/bin/{chunk-5rzxekn4.js → chunk-s0vfj06y.js} +1 -1
  84. package/bin/{chunk-4zksqvwj.js → chunk-s6g2mzpn.js} +2 -2
  85. package/bin/{chunk-zckxc8m6.js → chunk-s9sf37dv.js} +2 -2
  86. package/bin/{chunk-19jpn3r6.js → chunk-scvepfv8.js} +1 -1
  87. package/bin/chunk-sjbvt3wa.js +2 -0
  88. package/bin/{chunk-mn208vrv.js → chunk-srmx5z3v.js} +2 -2
  89. package/bin/{chunk-r776bhsg.js → chunk-srv5kvm4.js} +1 -1
  90. package/bin/{chunk-qmrg2jhs.js → chunk-t1h12r3q.js} +5 -5
  91. package/bin/{chunk-gvas3xkp.js → chunk-t6myw0jf.js} +1 -1
  92. package/bin/{chunk-z8e4wc59.js → chunk-t8jfp3vx.js} +1 -1
  93. package/bin/{chunk-15w79661.js → chunk-tqdde9bj.js} +1 -1
  94. package/bin/chunk-vk9ecq8n.js +2 -0
  95. package/bin/{chunk-d5hbzp7t.js → chunk-vsnq4381.js} +1 -1
  96. package/bin/{chunk-1nvj833s.js → chunk-w4adkd0a.js} +5 -5
  97. package/bin/{chunk-qxscgcn9.js → chunk-wbmqbpgm.js} +1 -1
  98. package/bin/{chunk-v034sfw8.js → chunk-wperd2h9.js} +2 -2
  99. package/bin/{chunk-y2dhf3p0.js → chunk-xbw7ffrz.js} +2 -2
  100. package/bin/{chunk-9bakwac0.js → chunk-xdrpahym.js} +4 -4
  101. package/bin/{chunk-6jkjx0n2.js → chunk-xfmnfcv2.js} +3 -3
  102. package/bin/chunk-xhngtwn9.js +1 -0
  103. package/bin/chunk-xjnehexk.js +2 -0
  104. package/bin/chunk-xzb0t8mx.js +1 -0
  105. package/bin/{chunk-k3prp6c6.js → chunk-y5h5d5gx.js} +4 -4
  106. package/bin/{chunk-wwkhskce.js → chunk-y6xyc4wp.js} +2 -2
  107. package/bin/{chunk-93p27bbm.js → chunk-zpk87b33.js} +5 -5
  108. package/bin/{chunk-asy868kq.js → chunk-zq5j9wsc.js} +1 -1
  109. package/bin/{chunk-grjek810.js → chunk-zsg61vr0.js} +2 -2
  110. package/bin/chunk-zts21ft7.js +1 -0
  111. package/bin/{chunk-cpj562n6.js → chunk-zzbn0b6c.js} +1 -1
  112. package/bin/shumai-app.html +1 -1
  113. package/bin/shumai-app.js +350 -333
  114. package/package.json +7 -7
  115. package/prisma/migrations/20261014054332_add_embedding_768/migration.sql +8 -0
  116. package/prisma/schema.prisma +10 -8
  117. package/bin/chunk-2gf95tj0.js +0 -1
  118. package/bin/chunk-2tk5w3jc.js +0 -1
  119. package/bin/chunk-301e7g3z.js +0 -2
  120. package/bin/chunk-3kmjbc3m.js +0 -2
  121. package/bin/chunk-3td60k1m.js +0 -2
  122. package/bin/chunk-42hrvk6k.js +0 -211
  123. package/bin/chunk-5bk16qdp.js +0 -2
  124. package/bin/chunk-8abhmarc.js +0 -2
  125. package/bin/chunk-965102pf.js +0 -3
  126. package/bin/chunk-acn3r2m2.js +0 -1
  127. package/bin/chunk-ce75dw3k.css +0 -1
  128. package/bin/chunk-d9qpgkek.js +0 -2
  129. package/bin/chunk-dv6p6n5e.js +0 -1
  130. package/bin/chunk-qb178ntp.js +0 -2
  131. package/bin/chunk-s4r6e6ms.js +0 -1
  132. package/bin/chunk-syjjke3f.js +0 -1
  133. package/bin/chunk-tgfxe0sb.js +0 -1
  134. package/bin/chunk-tjretpx8.js +0 -1
  135. package/bin/chunk-w4yjgez6.js +0 -14
  136. package/bin/chunk-wjcebkpb.js +0 -1
  137. package/bin/chunk-ws71fg50.js +0 -2
  138. package/bin/chunk-yfp3q4da.js +0 -1
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- function Vi(e){if(e instanceof Error)return e.message||e.name;if(typeof e==="string")return e;return String(e)}function n(e){if(!(e instanceof Error))return{name:"ThrownValue",message:Vi(e)};let t=e.code;return{name:e.name||void 0,message:e.message||e.name,stack:e.stack,code:typeof t==="string"||typeof t==="number"?t:void 0}}function Ec(e,t,s){return{type:e,timestamp:Date.now(),error:n(t),details:s}}function ll(e,t){e.diagnostics=[...e.diagnostics??[],t]}class i{queue=[];waiting=[];done=!1;finalResultPromise;resolveFinalResult;isComplete;extractResult;constructor(e,t){this.isComplete=e,this.extractResult=t,this.finalResultPromise=new Promise((s)=>{this.resolveFinalResult=s})}push(e){if(this.done)return;if(this.isComplete(e))this.done=!0,this.resolveFinalResult(this.extractResult(e));let t=this.waiting.shift();if(t)t({value:e,done:!1});else this.queue.push(e)}end(e){if(this.done=!0,e!==void 0)this.resolveFinalResult(e);while(this.waiting.length>0)this.waiting.shift()({value:void 0,done:!0})}async*[Symbol.asyncIterator](){while(!0)if(this.queue.length>0)yield this.queue.shift();else if(this.done)return;else{let e=await new Promise((t)=>this.waiting.push(t));if(e.done)return;yield e.value}}result(){return this.finalResultPromise}}class Jt extends i{constructor(){super((e)=>e.type==="done"||e.type==="error",(e)=>{if(e.type==="done")return e.message;else if(e.type==="error")return e.error;throw Error("Unexpected event type for final result")})}}
3
- export{Vi,Ec,ll,Jt};
2
+ function Vi(e){if(e instanceof Error)return e.message||e.name;if(typeof e==="string")return e;return String(e)}function n(e){if(!(e instanceof Error))return{name:"ThrownValue",message:Vi(e)};let t=e.code;return{name:e.name||void 0,message:e.message||e.name,stack:e.stack,code:typeof t==="string"||typeof t==="number"?t:void 0}}function Tc(e,t,s){return{type:e,timestamp:Date.now(),error:n(t),details:s}}function dl(e,t){e.diagnostics=[...e.diagnostics??[],t]}class i{queue=[];waiting=[];done=!1;finalResultPromise;resolveFinalResult;isComplete;extractResult;constructor(e,t){this.isComplete=e,this.extractResult=t,this.finalResultPromise=new Promise((s)=>{this.resolveFinalResult=s})}push(e){if(this.done)return;if(this.isComplete(e))this.done=!0,this.resolveFinalResult(this.extractResult(e));let t=this.waiting.shift();if(t)t({value:e,done:!1});else this.queue.push(e)}end(e){if(this.done=!0,e!==void 0)this.resolveFinalResult(e);while(this.waiting.length>0)this.waiting.shift()({value:void 0,done:!0})}async*[Symbol.asyncIterator](){while(!0)if(this.queue.length>0)yield this.queue.shift();else if(this.done)return;else{let e=await new Promise((t)=>this.waiting.push(t));if(e.done)return;yield e.value}}result(){return this.finalResultPromise}}class Jt extends i{constructor(){super((e)=>e.type==="done"||e.type==="error",(e)=>{if(e.type==="done")return e.message;else if(e.type==="error")return e.error;throw Error("Unexpected event type for final result")})}}
3
+ export{Vi,Tc,dl,Jt};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{il,al}from"./chunk-f5z3096k.js";import{en,Cn}from"./chunk-w73v578p.js";var m=class extends al{},p=class{#e;#t;constructor(e){this.#e={...e}}async init(){if(this.#t=new w(this.#e.database),this.#e.onCreateConnection)await this.#e.onCreateConnection(this.#t)}async acquireConnection(){return this.#t}async beginTransaction(){throw Error("D1 does not support interactive transactions. Use the D1 batch() API instead.")}async commitTransaction(){throw Error("D1 does not support interactive transactions. Use the D1 batch() API instead.")}async rollbackTransaction(){throw Error("D1 does not support interactive transactions. Use the D1 batch() API instead.")}async releaseConnection(){}async destroy(){}},w=class{#e;constructor(e){this.#e=e}async executeQuery(e){let t=await this.#e.prepare(e.sql).bind(...e.parameters).all(),a=t.meta.changes!=null?BigInt(t.meta.changes):void 0;return{insertId:t.meta.last_row_id===void 0||t.meta.last_row_id===null?void 0:BigInt(t.meta.last_row_id),rows:t?.results||[],numAffectedRows:a}}async*streamQuery(){throw Error("D1 does not support streaming queries.")}},d=class{#e;#t;constructor(e,t){this.#e=e,this.#t=t}async getSchemas(){return[]}async getTables(e={withInternalKyselyTables:!1}){let t=this.#e.selectFrom("sqlite_master").where("type","in",["table","view"]).where("name","not like","sqlite_%").where("name","not like","_cf_%").select(["name","type","sql"]).$castTo();if(!e.withInternalKyselyTables)t=t.where("name","!=",en).where("name","!=",Cn);let a=await t.execute();if(a.length===0)return[];let c=a.map((s)=>this.#t.prepare("SELECT * FROM pragma_table_info(?)").bind(s.name)),l=await this.#t.batch(c);return a.map((s,u)=>{let o=l[u]?.results??[],r=s.sql?.split(/[(),]/)?.find((n)=>n.toLowerCase().includes("autoincrement"))?.split(/\s+/)?.filter(Boolean)?.[0]?.replace(/["`]/g,"");if(!r){let n=o.filter((h)=>h.pk>0),i=n.length===1?n[0]:void 0;if(i&&i.type.toLowerCase()==="integer")r=i.name}return{name:s.name,isView:s.type==="view",columns:o.map((n)=>({name:n.name,dataType:n.type,isNullable:!n.notnull,isAutoIncrementing:n.name===r,hasDefaultValue:n.dflt_value!=null}))}})}async getMetadata(e){return{tables:await this.getTables(e)}}},y=class extends il{},f=class{#e;constructor(e){this.#e={...e}}createDriver(){return new p(this.#e)}createQueryCompiler(){return new y}createAdapter(){return new m}createIntrospector(e){return new d(e,this.#e.database)}};export{f as D1SqliteDialect};
2
+ import{cl,ul}from"./chunk-6sq6dfa1.js";import{Xr,Cn}from"./chunk-b88tdt79.js";var m=class extends ul{},p=class{#e;#t;constructor(e){this.#e={...e}}async init(){if(this.#t=new w(this.#e.database),this.#e.onCreateConnection)await this.#e.onCreateConnection(this.#t)}async acquireConnection(){return this.#t}async beginTransaction(){throw Error("D1 does not support interactive transactions. Use the D1 batch() API instead.")}async commitTransaction(){throw Error("D1 does not support interactive transactions. Use the D1 batch() API instead.")}async rollbackTransaction(){throw Error("D1 does not support interactive transactions. Use the D1 batch() API instead.")}async releaseConnection(){}async destroy(){}},w=class{#e;constructor(e){this.#e=e}async executeQuery(e){let t=await this.#e.prepare(e.sql).bind(...e.parameters).all(),a=t.meta.changes!=null?BigInt(t.meta.changes):void 0;return{insertId:t.meta.last_row_id===void 0||t.meta.last_row_id===null?void 0:BigInt(t.meta.last_row_id),rows:t?.results||[],numAffectedRows:a}}async*streamQuery(){throw Error("D1 does not support streaming queries.")}},d=class{#e;#t;constructor(e,t){this.#e=e,this.#t=t}async getSchemas(){return[]}async getTables(e={withInternalKyselyTables:!1}){let t=this.#e.selectFrom("sqlite_master").where("type","in",["table","view"]).where("name","not like","sqlite_%").where("name","not like","_cf_%").select(["name","type","sql"]).$castTo();if(!e.withInternalKyselyTables)t=t.where("name","!=",Xr).where("name","!=",Cn);let a=await t.execute();if(a.length===0)return[];let c=a.map((s)=>this.#t.prepare("SELECT * FROM pragma_table_info(?)").bind(s.name)),l=await this.#t.batch(c);return a.map((s,u)=>{let o=l[u]?.results??[],r=s.sql?.split(/[(),]/)?.find((n)=>n.toLowerCase().includes("autoincrement"))?.split(/\s+/)?.filter(Boolean)?.[0]?.replace(/["`]/g,"");if(!r){let n=o.filter((h)=>h.pk>0),i=n.length===1?n[0]:void 0;if(i&&i.type.toLowerCase()==="integer")r=i.name}return{name:s.name,isView:s.type==="view",columns:o.map((n)=>({name:n.name,dataType:n.type,isNullable:!n.notnull,isAutoIncrementing:n.name===r,hasDefaultValue:n.dflt_value!=null}))}})}async getMetadata(e){return{tables:await this.getTables(e)}}},y=class extends cl{},f=class{#e;constructor(e){this.#e={...e}}createDriver(){return new p(this.#e)}createQueryCompiler(){return new y}createAdapter(){return new m}createIntrospector(e){return new d(e,this.#e.database)}};export{f as D1SqliteDialect};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Ye}from"./chunk-cdk8vqeg.js";import{dr}from"./chunk-b5r0be06.js";import"./chunk-8zgq5sav.js";import{Ui}from"./chunk-5bpvwv66.js";import{zi,ji}from"./chunk-rq2h2bwt.js";import{ti,ri,ni}from"./chunk-15vsw36h.js";import{as}from"./chunk-23780yj6.js";import{xn,Sn}from"./chunk-sbyyn9yw.js";import{ls}from"./chunk-6hzktewz.js";import{Wn,Tr}from"./chunk-dppfek34.js";import{mn}from"./chunk-zdzkjp4q.js";import{Gr}from"./chunk-ae6zgjhd.js";import{Jt}from"./chunk-vm2pz2hm.js";var O=new Set(["openai","openai-codex","opencode"]),E=16;function h(e,o){if(!e)return!1;let r=o.toLowerCase();for(let[t,s]of Object.entries(e))if(t.toLowerCase()===r&&s!==null&&s.trim().length>0)return!0;return!1}function g(e,o,r){if(o)return o;if(h(r,"authorization")||h(r,"cf-aig-authorization"))return"unused";throw Error(`No API key for provider: ${e}`)}function I(e){return e.provider==="openrouter"||e.baseUrl.includes("openrouter.ai")?"openrouter":"openai"}function R(e,o){if(e)return e;if(dr("PI_CACHE_RETENTION",o)==="long")return"long";return"short"}function m(e){return{supportsDeveloperRole:e.compat?.supportsDeveloperRole??!0,sessionAffinityFormat:e.compat?.sessionAffinityFormat??I(e),supportsLongCacheRetention:e.compat?.supportsLongCacheRetention??!0,supportsStrictMode:e.compat?.supportsStrictMode??!1,supportsOpenAIGrammarTools:e.compat?.supportsOpenAIGrammarTools??!1,supportsToolSearch:e.compat?.supportsToolSearch??!1,supportsExplicitPromptCacheMode:e.compat?.supportsExplicitPromptCacheMode??!1}}function P(e,o){return o==="long"&&e.supportsLongCacheRetention?"24h":void 0}function S(e){return Sn(xn(e),"OpenAI API error")}var C=(e,o,r)=>{let t=new Jt;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 i=g(e.provider,r?.apiKey,r?.headers),c=R(r?.cacheRetention,r?.env)==="none"?void 0:r?.sessionId,p=m(e),a=Wn(o.tools,p.supportsOpenAIGrammarTools),u=w(e,o,i,r?.headers,c),f=M(e,o,r,p,a),l=await r?.onPayload?.(f,e);if(l!==void 0)f=l;let v={...r?.signal?{signal:r.signal}:{},...r?.timeoutMs!==void 0?{timeout:r.timeoutMs}:{},maxRetries:0},{data:y,response:d}=await ls(()=>u.responses.create(f,v).withResponse(),{maxRetries:r?.maxRetries,maxRetryDelayMs:r?.maxRetryDelayMs,signal:r?.signal});if(await r?.onResponse?.({status:d.status,headers:mn(d.headers)},e),t.push({type:"start",partial:s}),await ni(y,s,t,e,{serviceTier:r?.serviceTier,grammarToolInputProperties:a,applyServiceTierPricing:(T,A)=>b(T,A,e)}),r?.signal?.aborted)throw Error("Request was aborted");if(s.stopReason==="aborted"||s.stopReason==="error")throw Error("An unknown error occurred");t.push({type:"done",reason:s.stopReason,message:s}),t.end()}catch(i){for(let n of s.content)delete n.index,delete n.partialJson,delete n.customInput;s.stopReason=r?.signal?.aborted?"aborted":"error",s.errorMessage=S(i),t.push({type:"error",reason:s.stopReason,error:s}),t.end()}})(),t},z=(e,o,r)=>{g(e.provider,r?.apiKey,r?.headers);let t=Tr(e,o,r,r?.apiKey),s=r?.reasoning?Gr(e,r.reasoning):void 0;return C(e,o,{...t,reasoningEffort:s==="off"?void 0:s})};function w(e,o,r,t,s){let i=m(e),n={...e.headers};if(e.provider==="github-copilot"){let c=zi(o.messages),p=ji({messages:o.messages,hasImages:c});Object.assign(n,p)}if(s)if(i.sessionAffinityFormat==="openrouter")n["x-session-id"]=s;else{if(i.sessionAffinityFormat==="openai")n.session_id=s;n["x-client-request-id"]=s}if(t)Object.assign(n,t);return new Ye({apiKey:r,baseURL:e.baseUrl,dangerouslyAllowBrowser:!0,defaultHeaders:n})}function M(e,o,r,t=m(e),s=Wn(o.tools,t.supportsOpenAIGrammarTools)){let i=Ui(o,t.supportsToolSearch),n=ti(e,o,O,{grammarToolInputProperties:s,deferredTools:i.deferred,toolOptions:{supportsStrictMode:t.supportsStrictMode,supportsOpenAIGrammarTools:t.supportsOpenAIGrammarTools}}),c=R(r?.cacheRetention,r?.env),p=c==="none"&&t.supportsExplicitPromptCacheMode,a={model:e.id,input:n,stream:!0,prompt_cache_key:c==="none"?void 0:as(r?.sessionId),prompt_cache_retention:P(t,c),prompt_cache_options:p?{mode:"explicit"}:void 0,store:!1};if(r?.maxTokens)a.max_output_tokens=Math.max(r.maxTokens,E);if(r?.temperature!==void 0)a.temperature=r?.temperature;if(r?.serviceTier!==void 0)a.service_tier=r.serviceTier;if(i.immediate.length>0)a.tools=ri(i.immediate,{supportsStrictMode:t.supportsStrictMode,supportsOpenAIGrammarTools:t.supportsOpenAIGrammarTools});if(r?.toolChoice!==void 0)a.tool_choice=r.toolChoice;if(e.reasoning){if(r?.reasoningEffort||r?.reasoningSummary){let u=r?.reasoningEffort?e.thinkingLevelMap?.[r.reasoningEffort]??r.reasoningEffort:"medium";a.reasoning={effort:u,summary:r?.reasoningSummary||"auto"},a.include=["reasoning.encrypted_content"]}else if(e.provider!=="github-copilot"&&e.thinkingLevelMap?.off!==null)a.reasoning={effort:e.thinkingLevelMap?.off??"none"};if(e.provider==="xai")a.include=["reasoning.encrypted_content"]}return a}function _(e,o){switch(o){case"flex":return 0.5;case"priority":return e.id==="gpt-5.5"?2.5:2;default:return 1}}function b(e,o,r){let t=_(r,o);if(t===1)return;e.cost.input*=t,e.cost.output*=t,e.cost.cacheRead*=t,e.cost.cacheWrite*=t,e.cost.total=e.cost.input+e.cost.output+e.cost.cacheRead+e.cost.cacheWrite}export{C as stream,z as streamSimple};
2
+ import{Ye}from"./chunk-cdk8vqeg.js";import{dr}from"./chunk-b5r0be06.js";import"./chunk-5ebb2pdf.js";import{Ui}from"./chunk-5bpvwv66.js";import{zi,ji}from"./chunk-rq2h2bwt.js";import{ri,ni,oi}from"./chunk-pwq6dbb5.js";import{as}from"./chunk-23780yj6.js";import{xn,Sn}from"./chunk-sbyyn9yw.js";import{ls}from"./chunk-6hzktewz.js";import{Wn,Tr}from"./chunk-m41tbrvt.js";import{pn}from"./chunk-3fjgf7eb.js";import{Gr}from"./chunk-ncv8v6mj.js";import{Jt}from"./chunk-q7t5zs7n.js";var O=new Set(["openai","openai-codex","opencode"]),E=16;function h(e,o){if(!e)return!1;let r=o.toLowerCase();for(let[t,s]of Object.entries(e))if(t.toLowerCase()===r&&s!==null&&s.trim().length>0)return!0;return!1}function g(e,o,r){if(o)return o;if(h(r,"authorization")||h(r,"cf-aig-authorization"))return"unused";throw Error(`No API key for provider: ${e}`)}function I(e){return e.provider==="openrouter"||e.baseUrl.includes("openrouter.ai")?"openrouter":"openai"}function R(e,o){if(e)return e;if(dr("PI_CACHE_RETENTION",o)==="long")return"long";return"short"}function m(e){return{supportsDeveloperRole:e.compat?.supportsDeveloperRole??!0,sessionAffinityFormat:e.compat?.sessionAffinityFormat??I(e),supportsLongCacheRetention:e.compat?.supportsLongCacheRetention??!0,supportsStrictMode:e.compat?.supportsStrictMode??!1,supportsOpenAIGrammarTools:e.compat?.supportsOpenAIGrammarTools??!1,supportsToolSearch:e.compat?.supportsToolSearch??!1,supportsExplicitPromptCacheMode:e.compat?.supportsExplicitPromptCacheMode??!1}}function P(e,o){return o==="long"&&e.supportsLongCacheRetention?"24h":void 0}function S(e){return Sn(xn(e),"OpenAI API error")}var C=(e,o,r)=>{let t=new Jt;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 i=g(e.provider,r?.apiKey,r?.headers),c=R(r?.cacheRetention,r?.env)==="none"?void 0:r?.sessionId,p=m(e),a=Wn(o.tools,p.supportsOpenAIGrammarTools),u=w(e,o,i,r?.headers,c),f=M(e,o,r,p,a),l=await r?.onPayload?.(f,e);if(l!==void 0)f=l;let v={...r?.signal?{signal:r.signal}:{},...r?.timeoutMs!==void 0?{timeout:r.timeoutMs}:{},maxRetries:0},{data:y,response:d}=await ls(()=>u.responses.create(f,v).withResponse(),{maxRetries:r?.maxRetries,maxRetryDelayMs:r?.maxRetryDelayMs,signal:r?.signal});if(await r?.onResponse?.({status:d.status,headers:pn(d.headers)},e),t.push({type:"start",partial:s}),await oi(y,s,t,e,{serviceTier:r?.serviceTier,grammarToolInputProperties:a,applyServiceTierPricing:(T,A)=>b(T,A,e)}),r?.signal?.aborted)throw Error("Request was aborted");if(s.stopReason==="aborted"||s.stopReason==="error")throw Error("An unknown error occurred");t.push({type:"done",reason:s.stopReason,message:s}),t.end()}catch(i){for(let n of s.content)delete n.index,delete n.partialJson,delete n.customInput;s.stopReason=r?.signal?.aborted?"aborted":"error",s.errorMessage=S(i),t.push({type:"error",reason:s.stopReason,error:s}),t.end()}})(),t},z=(e,o,r)=>{g(e.provider,r?.apiKey,r?.headers);let t=Tr(e,o,r,r?.apiKey),s=r?.reasoning?Gr(e,r.reasoning):void 0;return C(e,o,{...t,reasoningEffort:s==="off"?void 0:s})};function w(e,o,r,t,s){let i=m(e),n={...e.headers};if(e.provider==="github-copilot"){let c=zi(o.messages),p=ji({messages:o.messages,hasImages:c});Object.assign(n,p)}if(s)if(i.sessionAffinityFormat==="openrouter")n["x-session-id"]=s;else{if(i.sessionAffinityFormat==="openai")n.session_id=s;n["x-client-request-id"]=s}if(t)Object.assign(n,t);return new Ye({apiKey:r,baseURL:e.baseUrl,dangerouslyAllowBrowser:!0,defaultHeaders:n})}function M(e,o,r,t=m(e),s=Wn(o.tools,t.supportsOpenAIGrammarTools)){let i=Ui(o,t.supportsToolSearch),n=ri(e,o,O,{grammarToolInputProperties:s,deferredTools:i.deferred,toolOptions:{supportsStrictMode:t.supportsStrictMode,supportsOpenAIGrammarTools:t.supportsOpenAIGrammarTools}}),c=R(r?.cacheRetention,r?.env),p=c==="none"&&t.supportsExplicitPromptCacheMode,a={model:e.id,input:n,stream:!0,prompt_cache_key:c==="none"?void 0:as(r?.sessionId),prompt_cache_retention:P(t,c),prompt_cache_options:p?{mode:"explicit"}:void 0,store:!1};if(r?.maxTokens)a.max_output_tokens=Math.max(r.maxTokens,E);if(r?.temperature!==void 0)a.temperature=r?.temperature;if(r?.serviceTier!==void 0)a.service_tier=r.serviceTier;if(i.immediate.length>0)a.tools=ni(i.immediate,{supportsStrictMode:t.supportsStrictMode,supportsOpenAIGrammarTools:t.supportsOpenAIGrammarTools});if(r?.toolChoice!==void 0)a.tool_choice=r.toolChoice;if(e.reasoning){if(r?.reasoningEffort||r?.reasoningSummary){let u=r?.reasoningEffort?e.thinkingLevelMap?.[r.reasoningEffort]??r.reasoningEffort:"medium";a.reasoning={effort:u,summary:r?.reasoningSummary||"auto"},a.include=["reasoning.encrypted_content"]}else if(e.provider!=="github-copilot"&&e.thinkingLevelMap?.off!==null)a.reasoning={effort:e.thinkingLevelMap?.off??"none"};if(e.provider==="xai")a.include=["reasoning.encrypted_content"]}return a}function _(e,o){switch(o){case"flex":return 0.5;case"priority":return e.id==="gpt-5.5"?2.5:2;default:return 1}}function b(e,o,r){let t=_(r,o);if(t===1)return;e.cost.input*=t,e.cost.output*=t,e.cost.cacheRead*=t,e.cost.cacheWrite*=t,e.cost.total=e.cost.input+e.cost.output+e.cost.cacheRead+e.cost.cacheWrite}export{C as stream,z as streamSimple};
@@ -1,2 +1,2 @@
1
- import{I}from"./chunk-42hrvk6k.js";var e=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],sr=I("circle-alert",e);
2
- export{sr};
1
+ import{I}from"./chunk-qx553512.js";var e=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],nr=I("circle-alert",e);
2
+ export{nr};