gemi 0.212.0 → 0.214.0

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 (192) hide show
  1. package/dist/ai/index.js +2 -2
  2. package/dist/ai/index.js.map +1 -1
  3. package/dist/ai/testing/index.js +1 -1
  4. package/dist/app/index.js +1 -1
  5. package/dist/bun/plugin.js +1 -1
  6. package/dist/bun/preload.js +1 -1
  7. package/dist/{chunk-qsf3t0rc.js → chunk-0njs5zqz.js} +3 -3
  8. package/dist/{chunk-qsf3t0rc.js.map → chunk-0njs5zqz.js.map} +1 -1
  9. package/dist/{chunk-njfbfx3k.js → chunk-11wy7gm1.js} +2 -2
  10. package/dist/{chunk-njfbfx3k.js.map → chunk-11wy7gm1.js.map} +1 -1
  11. package/dist/{chunk-j72wr9ck.js → chunk-153m8mfe.js} +2 -2
  12. package/dist/{chunk-j72wr9ck.js.map → chunk-153m8mfe.js.map} +1 -1
  13. package/dist/{chunk-rarqef1m.js → chunk-18aw52vs.js} +2 -2
  14. package/dist/{chunk-rarqef1m.js.map → chunk-18aw52vs.js.map} +1 -1
  15. package/dist/{chunk-vj9f634z.js → chunk-1a0ehbkm.js} +1 -1
  16. package/dist/{chunk-jzspg75a.js → chunk-2e278yhf.js} +2 -2
  17. package/dist/{chunk-jzspg75a.js.map → chunk-2e278yhf.js.map} +1 -1
  18. package/dist/{chunk-s158qvjg.js → chunk-2ek8wpe8.js} +3 -3
  19. package/dist/{chunk-s158qvjg.js.map → chunk-2ek8wpe8.js.map} +1 -1
  20. package/dist/{chunk-6d807fgx.js → chunk-2hcwvkfx.js} +2 -2
  21. package/dist/{chunk-6d807fgx.js.map → chunk-2hcwvkfx.js.map} +1 -1
  22. package/dist/{chunk-ds5adkcf.js → chunk-2mwkjfnd.js} +2 -2
  23. package/dist/{chunk-ds5adkcf.js.map → chunk-2mwkjfnd.js.map} +1 -1
  24. package/dist/{chunk-4g7n30zy.js → chunk-2v7stsgt.js} +2 -2
  25. package/dist/{chunk-4g7n30zy.js.map → chunk-2v7stsgt.js.map} +1 -1
  26. package/dist/{chunk-bf4wqp2f.js → chunk-2w8j265x.js} +2 -2
  27. package/dist/{chunk-bf4wqp2f.js.map → chunk-2w8j265x.js.map} +1 -1
  28. package/dist/{chunk-gg4q59q1.js → chunk-2x4x2qnk.js} +2 -2
  29. package/dist/{chunk-gg4q59q1.js.map → chunk-2x4x2qnk.js.map} +1 -1
  30. package/dist/{chunk-kwvx36xw.js → chunk-3egn4pfk.js} +2 -2
  31. package/dist/{chunk-kwvx36xw.js.map → chunk-3egn4pfk.js.map} +1 -1
  32. package/dist/{chunk-hchyarr4.js → chunk-3vnb6xhz.js} +1 -1
  33. package/dist/{chunk-dp8nmks0.js → chunk-3xrmx5c7.js} +2 -2
  34. package/dist/{chunk-dp8nmks0.js.map → chunk-3xrmx5c7.js.map} +1 -1
  35. package/dist/{chunk-z7r6td69.js → chunk-4q0pxgv6.js} +2 -2
  36. package/dist/{chunk-z7r6td69.js.map → chunk-4q0pxgv6.js.map} +1 -1
  37. package/dist/{chunk-zbm7njvf.js → chunk-5w0kzk4m.js} +2 -2
  38. package/dist/{chunk-zbm7njvf.js.map → chunk-5w0kzk4m.js.map} +1 -1
  39. package/dist/{chunk-q34hyv6y.js → chunk-5yfdrbwv.js} +2 -2
  40. package/dist/{chunk-q34hyv6y.js.map → chunk-5yfdrbwv.js.map} +1 -1
  41. package/dist/{chunk-0nzz7ftq.js → chunk-61sevt6g.js} +2 -2
  42. package/dist/{chunk-0nzz7ftq.js.map → chunk-61sevt6g.js.map} +1 -1
  43. package/dist/chunk-6cdykmvn.js +10 -0
  44. package/dist/chunk-6cdykmvn.js.map +44 -0
  45. package/dist/{chunk-r6e5jwjm.js → chunk-6n54q6wj.js} +14 -14
  46. package/dist/{chunk-r6e5jwjm.js.map → chunk-6n54q6wj.js.map} +3 -3
  47. package/dist/{chunk-h4rmpnkv.js → chunk-78gy3agg.js} +2 -2
  48. package/dist/{chunk-h4rmpnkv.js.map → chunk-78gy3agg.js.map} +1 -1
  49. package/dist/{chunk-pmyw9t15.js → chunk-7czjphwg.js} +2 -2
  50. package/dist/{chunk-pmyw9t15.js.map → chunk-7czjphwg.js.map} +1 -1
  51. package/dist/{chunk-cr9hwkpa.js → chunk-9ph676kt.js} +2 -2
  52. package/dist/{chunk-cr9hwkpa.js.map → chunk-9ph676kt.js.map} +1 -1
  53. package/dist/{chunk-3r8zkpes.js → chunk-9xa5kzaq.js} +2 -2
  54. package/dist/{chunk-3r8zkpes.js.map → chunk-9xa5kzaq.js.map} +1 -1
  55. package/dist/{chunk-frjavybg.js → chunk-9yh4sfac.js} +2 -2
  56. package/dist/{chunk-frjavybg.js.map → chunk-9yh4sfac.js.map} +1 -1
  57. package/dist/{chunk-8r7w8s60.js → chunk-at5ce580.js} +2 -2
  58. package/dist/{chunk-8r7w8s60.js.map → chunk-at5ce580.js.map} +1 -1
  59. package/dist/{chunk-b5v00jn8.js → chunk-bjh3ms04.js} +2 -2
  60. package/dist/{chunk-b5v00jn8.js.map → chunk-bjh3ms04.js.map} +1 -1
  61. package/dist/{chunk-56z4jd8t.js → chunk-bvm2w6ha.js} +2 -2
  62. package/dist/{chunk-56z4jd8t.js.map → chunk-bvm2w6ha.js.map} +1 -1
  63. package/dist/{chunk-n5zq7ckd.js → chunk-c46y8hs0.js} +2 -2
  64. package/dist/{chunk-n5zq7ckd.js.map → chunk-c46y8hs0.js.map} +1 -1
  65. package/dist/{chunk-qymdnzpy.js → chunk-c80xrwep.js} +2 -2
  66. package/dist/{chunk-qymdnzpy.js.map → chunk-c80xrwep.js.map} +1 -1
  67. package/dist/{chunk-7m20yym1.js → chunk-c8sq880v.js} +2 -2
  68. package/dist/{chunk-7m20yym1.js.map → chunk-c8sq880v.js.map} +1 -1
  69. package/dist/{chunk-gzsgc14q.js → chunk-c8sqvhxp.js} +2 -2
  70. package/dist/{chunk-gzsgc14q.js.map → chunk-c8sqvhxp.js.map} +1 -1
  71. package/dist/{chunk-sry4r3kf.js → chunk-chy85f3v.js} +2 -2
  72. package/dist/{chunk-sry4r3kf.js.map → chunk-chy85f3v.js.map} +1 -1
  73. package/dist/{chunk-rs3krbw9.js → chunk-dghymwgp.js} +2 -2
  74. package/dist/{chunk-rs3krbw9.js.map → chunk-dghymwgp.js.map} +1 -1
  75. package/dist/chunk-er6rhs42.js +9 -0
  76. package/dist/chunk-er6rhs42.js.map +10 -0
  77. package/dist/{chunk-c94zdk4r.js → chunk-fdbh87nv.js} +3 -3
  78. package/dist/{chunk-c94zdk4r.js.map → chunk-fdbh87nv.js.map} +1 -1
  79. package/dist/{chunk-rxvp7yeq.js → chunk-frtx87yh.js} +2 -2
  80. package/dist/{chunk-rxvp7yeq.js.map → chunk-frtx87yh.js.map} +1 -1
  81. package/dist/{chunk-d79zfm40.js → chunk-fw7sxgse.js} +1 -1
  82. package/dist/chunk-g4esp7z5.js +5 -0
  83. package/dist/{chunk-kpww16c7.js.map → chunk-g4esp7z5.js.map} +1 -1
  84. package/dist/{chunk-as9cs2bk.js → chunk-ge201pk4.js} +1 -1
  85. package/dist/{chunk-wfpvsgfy.js → chunk-gg97wgy0.js} +2 -2
  86. package/dist/{chunk-wfpvsgfy.js.map → chunk-gg97wgy0.js.map} +1 -1
  87. package/dist/chunk-gk2k76tn.js.map +2 -2
  88. package/dist/{chunk-pce2vqtc.js → chunk-ha3d6zhv.js} +2 -2
  89. package/dist/{chunk-pce2vqtc.js.map → chunk-ha3d6zhv.js.map} +1 -1
  90. package/dist/{chunk-d675g712.js → chunk-hka2sgqz.js} +3 -3
  91. package/dist/{chunk-d675g712.js.map → chunk-hka2sgqz.js.map} +1 -1
  92. package/dist/{chunk-5ra8x6ax.js → chunk-jgb3je66.js} +2 -2
  93. package/dist/{chunk-5ra8x6ax.js.map → chunk-jgb3je66.js.map} +1 -1
  94. package/dist/{chunk-axgpe682.js → chunk-k6532519.js} +2 -2
  95. package/dist/{chunk-axgpe682.js.map → chunk-k6532519.js.map} +1 -1
  96. package/dist/{chunk-jp0d4qhn.js → chunk-ktxf56dm.js} +2 -2
  97. package/dist/{chunk-jp0d4qhn.js.map → chunk-ktxf56dm.js.map} +1 -1
  98. package/dist/{chunk-z0c08ete.js → chunk-m4nn6ne9.js} +2 -2
  99. package/dist/{chunk-z0c08ete.js.map → chunk-m4nn6ne9.js.map} +1 -1
  100. package/dist/{chunk-24mk3gn3.js → chunk-mj857ksa.js} +3 -3
  101. package/dist/{chunk-24mk3gn3.js.map → chunk-mj857ksa.js.map} +1 -1
  102. package/dist/{chunk-fypj6z8t.js → chunk-nc5p41g9.js} +2 -2
  103. package/dist/{chunk-fypj6z8t.js.map → chunk-nc5p41g9.js.map} +1 -1
  104. package/dist/{chunk-18v3qyzp.js → chunk-ntwmz16f.js} +2 -2
  105. package/dist/{chunk-18v3qyzp.js.map → chunk-ntwmz16f.js.map} +1 -1
  106. package/dist/{chunk-f1jq1mp9.js → chunk-nx86gzt1.js} +2 -2
  107. package/dist/{chunk-f1jq1mp9.js.map → chunk-nx86gzt1.js.map} +1 -1
  108. package/dist/{chunk-0exm7bsw.js → chunk-qt80d3fw.js} +2 -2
  109. package/dist/{chunk-0exm7bsw.js.map → chunk-qt80d3fw.js.map} +1 -1
  110. package/dist/{chunk-bxtv9am0.js → chunk-rdzdbd52.js} +4 -4
  111. package/dist/{chunk-bxtv9am0.js.map → chunk-rdzdbd52.js.map} +1 -1
  112. package/dist/{chunk-sgqfg5gg.js → chunk-s7p6w1p2.js} +2 -2
  113. package/dist/{chunk-sgqfg5gg.js.map → chunk-s7p6w1p2.js.map} +1 -1
  114. package/dist/{chunk-6wrk51tb.js → chunk-sqzm1k9q.js} +2 -2
  115. package/dist/{chunk-6wrk51tb.js.map → chunk-sqzm1k9q.js.map} +1 -1
  116. package/dist/{chunk-cdt888qf.js → chunk-sw8012bt.js} +2 -2
  117. package/dist/{chunk-cdt888qf.js.map → chunk-sw8012bt.js.map} +1 -1
  118. package/dist/{chunk-rzmngbn5.js → chunk-tejgrqh7.js} +2 -2
  119. package/dist/{chunk-rzmngbn5.js.map → chunk-tejgrqh7.js.map} +1 -1
  120. package/dist/{chunk-3c45f8f3.js → chunk-tvd39jya.js} +2 -2
  121. package/dist/{chunk-3c45f8f3.js.map → chunk-tvd39jya.js.map} +1 -1
  122. package/dist/{chunk-jcsm6g58.js → chunk-vz2dt9f3.js} +1 -1
  123. package/dist/{chunk-akh97aw9.js → chunk-wee3yrdn.js} +1 -1
  124. package/dist/{chunk-6f11bb3s.js → chunk-wsp30cr6.js} +2 -2
  125. package/dist/{chunk-6f11bb3s.js.map → chunk-wsp30cr6.js.map} +1 -1
  126. package/dist/{chunk-a7svhrg6.js → chunk-xbxdhmh4.js} +3 -3
  127. package/dist/{chunk-a7svhrg6.js.map → chunk-xbxdhmh4.js.map} +1 -1
  128. package/dist/{chunk-b9q72ssw.js → chunk-y0b22kf8.js} +2 -2
  129. package/dist/{chunk-b9q72ssw.js.map → chunk-y0b22kf8.js.map} +1 -1
  130. package/dist/{chunk-g6z6shvz.js → chunk-y54kz6h6.js} +2 -2
  131. package/dist/{chunk-g6z6shvz.js.map → chunk-y54kz6h6.js.map} +1 -1
  132. package/dist/{chunk-5ncc9tn6.js → chunk-zsk4wvrs.js} +2 -2
  133. package/dist/{chunk-5ncc9tn6.js.map → chunk-zsk4wvrs.js.map} +1 -1
  134. package/dist/{chunk-f7bayqs7.js → chunk-zzrmsvqc.js} +2 -2
  135. package/dist/{chunk-f7bayqs7.js.map → chunk-zzrmsvqc.js.map} +1 -1
  136. package/dist/config/index.js +1 -1
  137. package/dist/console/run.js +2 -2
  138. package/dist/console/run.js.map +1 -1
  139. package/dist/container/index.js +2 -2
  140. package/dist/container/index.js.map +1 -1
  141. package/dist/database/index.js +2 -2
  142. package/dist/database/index.js.map +1 -1
  143. package/dist/email/index.js +2 -2
  144. package/dist/email/index.js.map +1 -1
  145. package/dist/facades/DB.d.ts.map +1 -1
  146. package/dist/facades/index.js +1 -1
  147. package/dist/foundation/index.js +2 -2
  148. package/dist/foundation/index.js.map +1 -1
  149. package/dist/http/index.js +1 -1
  150. package/dist/i18n/dictionaryRuntime.js +2 -2
  151. package/dist/i18n/dictionaryRuntime.js.map +1 -1
  152. package/dist/i18n/index.js +2 -2
  153. package/dist/i18n/index.js.map +1 -1
  154. package/dist/kernel/index.js +2 -2
  155. package/dist/kernel/index.js.map +1 -1
  156. package/dist/orm/Model.d.ts.map +1 -1
  157. package/dist/orm/compile/write.d.ts +3 -1
  158. package/dist/orm/compile/write.d.ts.map +1 -1
  159. package/dist/orm/context.d.ts +21 -0
  160. package/dist/orm/context.d.ts.map +1 -1
  161. package/dist/orm/dialect/sqlite.d.ts.map +1 -1
  162. package/dist/orm/index.js +4 -4
  163. package/dist/orm/index.js.map +4 -4
  164. package/dist/probe/index.js +2 -2
  165. package/dist/probe/index.js.map +1 -1
  166. package/dist/server/index.js +2 -2
  167. package/dist/server/index.js.map +1 -1
  168. package/dist/services/index.d.ts +1 -1
  169. package/dist/services/index.d.ts.map +1 -1
  170. package/dist/services/index.js +2 -2
  171. package/dist/services/index.js.map +1 -1
  172. package/dist/services/mcp/McpRegistry.d.ts +14 -0
  173. package/dist/services/mcp/McpRegistry.d.ts.map +1 -1
  174. package/dist/services/mcp/http/McpHttpServer.d.ts.map +1 -1
  175. package/dist/services/queue/work.js +2 -2
  176. package/dist/services/queue/work.js.map +1 -1
  177. package/dist/stats/route-table.js +1 -1
  178. package/dist/support/index.js +2 -2
  179. package/dist/support/index.js.map +1 -1
  180. package/dist/vitest/index.js +1 -1
  181. package/package.json +1 -1
  182. package/dist/chunk-8dh3s272.js +0 -10
  183. package/dist/chunk-8dh3s272.js.map +0 -44
  184. package/dist/chunk-8wxt3v9r.js +0 -9
  185. package/dist/chunk-8wxt3v9r.js.map +0 -10
  186. package/dist/chunk-kpww16c7.js +0 -5
  187. /package/dist/{chunk-vj9f634z.js.map → chunk-1a0ehbkm.js.map} +0 -0
  188. /package/dist/{chunk-hchyarr4.js.map → chunk-3vnb6xhz.js.map} +0 -0
  189. /package/dist/{chunk-d79zfm40.js.map → chunk-fw7sxgse.js.map} +0 -0
  190. /package/dist/{chunk-as9cs2bk.js.map → chunk-ge201pk4.js.map} +0 -0
  191. /package/dist/{chunk-jcsm6g58.js.map → chunk-vz2dt9f3.js.map} +0 -0
  192. /package/dist/{chunk-akh97aw9.js.map → chunk-wee3yrdn.js.map} +0 -0
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{la as g}from"../../chunk-3ejv7fs4.js";import"../../chunk-y10tys3s.js";import{Wj as v,Xj as m}from"../../chunk-xdrnzs3t.js";import"../../chunk-qymdnzpy.js";import{createHash as s}from"crypto";import{createHash as S}from"crypto";import{existsSync as h,readdirSync as l,readFileSync as c,statSync as d}from"fs";import{join as q,relative as p,sep as i}from"path";var P="\u241F",F=6,n=/\{\{>\s*([^}\s]+)\s*\}\}/g,b=(D)=>D.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");function R(D){let $=D.filter((B)=>B.length>=F),z=D.filter((B)=>B.length<F);return(B)=>{let C=B;for(let G of $)if(C.includes(G))C=C.split(G).join(P);for(let G of z)C=C.replace(new RegExp(`${b(G)}\\s*${P}`,"g"),P).replace(new RegExp(`${P}\\s*${b(G)}`,"g"),P);return C.replace(new RegExp(`\\s*${P}[\\s${P}]*`,"g"),P)}}function y(D,$=[]){for(let z of l(D)){if(z==="node_modules")continue;let B=q(D,z);if(d(B).isDirectory())y(B,$);else if(z.endsWith(".md"))$.push(B)}return $}class L{data;root;options;constructor(D,$={}){this.data=D;this.options=$,this.root=$.root??process.cwd()}static blob(D){return S("sha1").update(`blob ${Buffer.byteLength(D)}\x00`).update(D).digest("hex")}static pieces(D){return D.split(/\{\{[^}]*\}\}/).map(($)=>$.trim()).filter(($)=>$.length>0)}static tool(D){return S("sha256").update(JSON.stringify({description:D.description,parameters:D.parameters})).digest("hex")}static prompts(D={}){let $=D.root??process.cwd(),z=new Map;for(let B of D.dirs??["app/agents"]){if(!h(q($,B)))continue;for(let C of y(q($,B)).sort())z.set(p($,C).split(i).join("/"),c(C,"utf8"))}return z}static of(D,$,z={}){let B=[...D].join(`
2
+ import{la as g}from"../../chunk-3ejv7fs4.js";import"../../chunk-y10tys3s.js";import{Wj as v,Xj as m}from"../../chunk-xdrnzs3t.js";import"../../chunk-c80xrwep.js";import{createHash as s}from"crypto";import{createHash as S}from"crypto";import{existsSync as h,readdirSync as l,readFileSync as c,statSync as d}from"fs";import{join as q,relative as p,sep as i}from"path";var P="\u241F",F=6,n=/\{\{>\s*([^}\s]+)\s*\}\}/g,b=(D)=>D.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");function R(D){let $=D.filter((B)=>B.length>=F),z=D.filter((B)=>B.length<F);return(B)=>{let C=B;for(let G of $)if(C.includes(G))C=C.split(G).join(P);for(let G of z)C=C.replace(new RegExp(`${b(G)}\\s*${P}`,"g"),P).replace(new RegExp(`${P}\\s*${b(G)}`,"g"),P);return C.replace(new RegExp(`\\s*${P}[\\s${P}]*`,"g"),P)}}function y(D,$=[]){for(let z of l(D)){if(z==="node_modules")continue;let B=q(D,z);if(d(B).isDirectory())y(B,$);else if(z.endsWith(".md"))$.push(B)}return $}class L{data;root;options;constructor(D,$={}){this.data=D;this.options=$,this.root=$.root??process.cwd()}static blob(D){return S("sha1").update(`blob ${Buffer.byteLength(D)}\x00`).update(D).digest("hex")}static pieces(D){return D.split(/\{\{[^}]*\}\}/).map(($)=>$.trim()).filter(($)=>$.length>0)}static tool(D){return S("sha256").update(JSON.stringify({description:D.description,parameters:D.parameters})).digest("hex")}static prompts(D={}){let $=D.root??process.cwd(),z=new Map;for(let B of D.dirs??["app/agents"]){if(!h(q($,B)))continue;for(let C of y(q($,B)).sort())z.set(p($,C).split(i).join("/"),c(C,"utf8"))}return z}static of(D,$,z={}){let B=[...D].join(`
3
3
  \x00
4
4
  `),C={};for(let[Y,Q]of L.prompts(z))if(L.pieces(Q).filter((Z)=>Z.length>=12).sort((Z,K)=>K.length-Z.length).slice(0,3).some((Z)=>B.includes(Z)))C[Y]=L.blob(Q);let G=[...$.keys()].sort(),X=z.inputs?.(new Set(G));return new L({prompts:C,tools:Object.fromEntries(G.map((Y)=>[Y,[...$.get(Y)].sort()])),...X&&Object.keys(X).length>0?{inputs:a(X)}:{}},z)}same(D){let $=D instanceof L?D.data:D;return JSON.stringify(this.data)===JSON.stringify($)}changed(){let D=this.options.inputs?.(new Set(Object.keys(this.data.tools)))??{};return[...this.changedPrompts().map(([$])=>$),...Object.entries(this.data.inputs??{}).filter(([$,z])=>D[$]!==z).map(([$])=>`input ${$}`)]}cutters(){let D=L.prompts(this.options),$=this.changedPrompts(),z=new Map,B=new Map;for(let[C,G]of $){let X=this.readBlob(G);if(X===void 0)throw Error(`${C} changed since the recording, and the version it was recorded with (${G}) can't be read back from git`);if(z.set(C,X),D.has(C))B.set(C,D.get(C))}return{changed:$.map(([C])=>C),recorded:R(this.piecesWithPartials(z,(C)=>{let G=this.data.prompts[C];return G&&this.readBlob(G)||D.get(C)})),sent:R(this.piecesWithPartials(B,(C)=>D.get(C)))}}changedPrompts(){let D=L.prompts(this.options);return Object.entries(this.data.prompts).filter(([$,z])=>{let B=D.get($);return B===void 0||L.blob(B)!==z})}readBlob(D){if(this.options.readBlob)return this.options.readBlob(D);let $=Bun.spawnSync(["git","cat-file","blob",D],{cwd:this.root});return $.exitCode===0?$.stdout.toString():void 0}piecesWithPartials(D,$){let z=this.options.dirs??["app/agents"],B=this.options.shared??"prompts",C=[...D];while(C.length>0){let[G,X]=C.pop(),Y=z.find((Q)=>G.startsWith(`${Q}/`));if(Y===void 0)continue;for(let[,Q]of X.matchAll(n)){let V=`${Y}/${Q.includes("/")?Q:`${B}/${Q}`}.md`,Z=D.has(V)?void 0:$(V);if(Z===void 0)continue;D.set(V,Z),C.push([V,Z])}}return[...D.values()].flatMap((G)=>L.pieces(G)).sort((G,X)=>X.length-G.length)}}function a(D){return Object.fromEntries(Object.entries(D).sort(([$],[z])=>$.localeCompare(z)))}class N extends Error{constructor(D){super(`${D} Record again.`);this.name="RecordingMismatchError"}}var o=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/g;function T(D,$){if(typeof D==="string")return $(D);if(Array.isArray(D))return D.map((z)=>T(z,$));if(D&&typeof D==="object")return Object.fromEntries(Object.entries(D).map(([z,B])=>[z,T(B,$)]));return D}function f(D){return JSON.parse(JSON.stringify(D,function($,z){if($==="nested")return;if($==="output"&&this.type==="tool-result"&&"modelOutput"in this)return;return z}))}function u(){let D;return{promise:new Promise((z)=>D=z),resolve:D}}var r=(D)=>s("sha256").update(D).digest("hex"),E=(D)=>D.flatMap(($)=>("tools"in $)?$.tools:[$]);function x(D){return D.map(({role:$,content:z})=>({role:$,parts:(Array.isArray(z)?z:[]).flatMap((B)=>{if(B?.type==="tool-call")return[{call:B.name,input:B.input??B.args}];if(B?.type==="tool-result")return[{result:B.name,status:B.status}];if(B?.type==="file")return[{file:!0}];return[]})}))}class M extends g{live;model;capabilities;recordedAt;calls;recordedNested;children=new Map;parent;key;sent=[];uploads;uploadCount=0;read;shared;options;texts=new Set;toolHashes=new Map;toolLists=new Set;recorded;cuts;constructor(D,$,z,B){super();this.live=D;if(this.options={...z,match:z.match??"wording",ids:new RegExp(z.ids??o,"g"),waitMs:z.waitMs??60000},B){let{parent:C}=B;this.parent=C,this.key=B.key,this.model=C.model,this.capabilities=C.capabilities,this.recordedAt=C.recordedAt,this.calls=B.calls,this.recordedNested={},this.uploads=C.uploads,this.shared=C.shared;return}if(this.shared={ids:new Map,stale:new Set,staleCalls:0,started:0,moved:u()},this.uploads=new Map,D){this.model=D.model,this.capabilities=D.capabilities,this.recordedAt=new Date,this.calls=[],this.recordedNested={};return}if(!$||$.version!==1||!Array.isArray($.calls))throw Error("RecordingProvider.replay needs a recording made by RecordingProvider.");if(this.model=$.model,this.capabilities=$.capabilities,this.recordedAt=new Date($.recordedAt),this.calls=structuredClone($.calls),this.recordedNested=structuredClone($.nested??{}),$.fingerprints)this.recorded=new L($.fingerprints,z.fingerprints)}static record(D,$={}){return new M(D,void 0,$)}static replay(D,$={}){return new M(void 0,D,$)}get isRecording(){return this.live!==void 0}get stale(){return this.shared.stale}get staleCalls(){return this.shared.staleCalls}nested(D){if(this.parent)return this.parent.nested(D);let $=this.children.get(D);if(!$){let z=this.recordedNested[D];if(!this.live&&!z)throw new N(`The recording has no sub-run "${D}".`);$=new M(this.live,void 0,this.options,{parent:this,key:D,calls:z??[]}),this.children.set(D,$)}return $}recording(){if(this.parent)return this.parent.recording();if(!this.live)throw Error("Only a recording provider (`record`) has a recording to save.");return{version:1,model:this.model,capabilities:this.capabilities,recordedAt:this.recordedAt.toISOString(),calls:structuredClone(this.calls),...this.options.fingerprints?{fingerprints:this.fingerprints().data}:{},...this.children.size>0?{nested:Object.fromEntries([...this.children].map(([D,$])=>[D,structuredClone($.calls)]))}:{}}}fingerprints(){let D=this.parent??this;return L.of(D.texts,D.toolHashes,this.options.fingerprints)}static changedSince(D,$={}){return D.fingerprints?new L(D.fingerprints,$).changed():[]}replayedInFull(){let D=this.parent??this;return D.calls.length===0&&Object.entries(D.recordedNested).every(([$,z])=>(D.children.get($)?.calls??z).length===0)}async pin(D){if(this.live)return this.read=D,D;let $=this.calls[0]?.read;if($===void 0)return D;return await(this.parent??this).reach($,this.where()),$}async upload(D){let $=++this.uploadCount,z=this.key===void 0?`upload_${$}`:`upload_${this.key}_${$}`;if(this.live)this.uploads.set(z,await this.live.upload(D));return z}normalizeError(D){return this.live?this.live.normalizeError(D):super.normalizeError(D)}async*stream(D){let $=this.requestOf(D);if(this.live){yield*this.recordCall(D,$);return}yield*this.replayCall(D,$)}async*recordCall(D,$){let z=this.parent??this,B=z.shared.started++,C=this.read;this.read=void 0;let G=[],X=D.messages.map((Q)=>({...Q,content:Q.content.map((V)=>V.type==="file"&&V.fileId&&this.uploads.has(V.fileId)?{...V,fileId:this.uploads.get(V.fileId)}:V)}));for await(let Q of this.live.stream({...D,messages:X})){let V=G.at(-1);if(Q.type==="tool-call-discard"){let Z=new Set(Q.toolCallIds),K=G.filter((H)=>H.type!=="tool-call-delta"||!Z.has(H.toolCallId));G.splice(0,G.length,...K)}else if(Q.type==="retry");else if(V&&(Q.type==="text-delta"||Q.type==="output-delta")&&V.type===Q.type)V.delta+=Q.delta;else if(V?.type==="tool-call-delta"&&Q.type==="tool-call-delta"&&V.toolCallId===Q.toolCallId)V.argsDelta+=Q.argsDelta;else G.push({...Q});yield Q}let Y=this.options.position?await this.options.position():void 0;this.calls.push({request:$,events:G,at:B,...C!==void 0?{read:C}:{},...Y!==void 0?{ended:Y}:{}})}async*replayCall(D,$){let z=this.parent??this,B=this.where(),C=this.calls[0];if(this.options.ordered&&C?.at!==void 0)await z.turn(C.at,B);let G=this.calls.shift();if(!G)throw new N(`${B}: call ${this.sentCalls} was not recorded (the recording has no more calls).`);let{promptCacheKey:X,...Y}=G.request;if(!z.matches(JSON.stringify(Y),$))z.tolerate(B,{...G,request:Y},$,D.tools??[]);if(G.ended!==void 0)await z.reach(G.ended,B);let Q=z.shared.ids;for(let V of G.events)yield JSON.parse(JSON.stringify(V).replace(this.options.ids,(Z)=>Q.get(Z)??Z))}where(){return this.key===void 0?"the recording":`sub-run "${this.key}"`}sentCalls=0;requestOf(D){this.sentCalls++;let{signal:$,promptCacheKey:z,messages:B,tools:C,...G}=D,X=B.map(({role:K,content:H})=>({role:K,content:f(H)})),Y=this.sent.length>0&&this.sent.length<=X.length&&JSON.stringify(X.slice(0,this.sent.length))===JSON.stringify(this.sent)?this.sent.length:0;this.sent=X;let Q=C&&C.length>0?JSON.stringify(C):void 0,V=this.parent??this,Z=(K)=>{return V.texts.add(K),K};if(T([G,X.slice(Y)],Z),Q&&!V.toolLists.has(Q)){V.toolLists.add(Q);for(let K of E(C)){T(K,Z);let H=V.toolHashes.get(K.name)??new Set;H.add(L.tool(K)),V.toolHashes.set(K.name,H)}}return{...f(G),...Q?{tools:`sha256:${r(Q)}`,toolNames:E(C).map((K)=>K.name).sort()}:{},...Y>0?{after:Y}:{},messages:X.slice(Y)}}matches(D,$){let z=this.options.ids,B=JSON.stringify($),C=D.match(z)??[],G=B.match(z)??[];if(C.length!==G.length)return!1;let X=new Map(this.shared.ids);for(let[Y,Q]of C.entries()){let V=X.get(Q)??G[Y];if(V!==G[Y])return!1;X.set(Q,V)}if(D.replace(z,(Y)=>X.get(Y))!==B)return!1;for(let[Y,Q]of X)this.shared.ids.set(Y,Q);return!0}tolerate(D,$,z,B){let C=this.options.ids,G=this.options.match,X=$.request,Y=(j,J,I)=>{let A=JSON.stringify(j).replace(C,"<id>"),W=JSON.stringify(J).replace(C,"<id>"),_=0;while(_<A.length&&A[_]===W[_])_++;throw new N(`${D}: the request differs from the recorded one${I}. Recorded: \u2026${A.slice(Math.max(0,_-80),_+120)}\u2026 Sent: \u2026${W.slice(Math.max(0,_-80),_+120)}\u2026`)};if(G==="exact")Y(X,z,"");let{tools:Q,toolNames:V,...Z}=X,{tools:K,toolNames:H,...k}=z,w=[];if(!this.matches(JSON.stringify(Z),k))if(G==="wording"){if(!this.recorded)Y(Z,k,", and the recording has no fingerprints to tell a reworded prompt by");try{this.cuts??=this.recorded.cutters()}catch(I){throw new N(`${D}: ${I.message}.`)}let j=T(Z,this.cuts.recorded),J=T(k,this.cuts.sent);if(this.cuts.changed.length===0||!this.matches(JSON.stringify(j),J))Y(j,J,this.cuts.changed.length>0?", beyond the wording of the prompts changed since":"");w.push(...this.cuts.changed.map((I)=>`${I} changed`))}else{if(!((X.after??0)===(z.after??0)&&this.matches(JSON.stringify(x(X.messages)),x(z.messages))))Y(Z,k," in the conversation itself");let{messages:J,...I}=Z,{messages:A,...W}=k;if(!this.matches(JSON.stringify(J),A))w.push("message text changed");let _=new Set([...Object.keys(I),...Object.keys(W)]);for(let U of[..._].sort()){let O=JSON.stringify(I[U]??null);if(!this.matches(O,W[U]??null))w.push(`${U} changed`)}}if(Q!==K){let j=E(B);for(let J of $.events){if(J.type!=="tool-call")continue;let I=j.find((O)=>O.name===J.name);if(!I)throw new N(`${D}: the recorded answer calls ${J.name}, which is not offered any more.`);let A=Object.fromEntries([...JSON.stringify(I.parameters).matchAll(/"format":"([^"]+)"/g)].map(([,O])=>[O,!0])),W;try{W=JSON.parse(J.args||"{}")}catch{W=void 0}let _;try{_=m.fromJSONSchema(I.parameters,{unknownKeys:"error",formats:A})}catch(O){if(!(O instanceof v))throw O}let U=_?.safeParse(W);if(U&&U.ok===!1)throw new N(`${D}: the recorded call of ${J.name} does not fit its schema any more (${U.errors.join("; ")}).`)}if(this.recorded){let J=j.filter((I)=>!this.recorded.data.tools[I.name]?.includes(L.tool(I))).map((I)=>I.name).sort();w.push(J.length>0?`tools changed: ${J.join(", ")}`:"the tools offered changed")}else{let J=new Set(V??[]),I=new Set(H??[]),A=[...I].filter((_)=>!J.has(_)),W=[...J].filter((_)=>!I.has(_));w.push(A.length>0||W.length>0?`tools offered changed (${[...A.map((_)=>`+${_}`),...W.map((_)=>`-${_}`)].join(", ")})`:"the tools offered changed")}}this.shared.staleCalls++;for(let j of w)this.shared.stale.add(j)}async turn(D,$){let z=this.shared;z.pending??=[...this.calls,...Object.values(this.recordedNested).flat()].map((B)=>B.at).filter((B)=>B!==void 0).sort((B,C)=>B-C);while(z.pending[0]!==void 0&&z.pending[0]<D){let B=z.moved.promise;if(!await Promise.race([B.then(()=>!0),new Promise((G)=>setTimeout(()=>G(!1),this.options.waitMs))]))throw new N(`${$}: call ${D} waits for call ${z.pending[0]}, which the replay does not make.`)}z.pending=z.pending.filter((B)=>B!==D),z.moved.resolve(),z.moved=u()}async reach(D,$){let z=this.options.position;if(!z)return;let B=await z(),C=0;while(B<D){await new Promise((X)=>setTimeout(X,25));let G=await z();if(C=G===B?C+25:0,B=G,C>=this.options.waitMs)throw new N(`${$}: a call waits for the app to reach ${D}; it stays at ${B}.`)}}}function t(D){let $=globalThis.Date,z=new $(D).getTime()-$.now();if(!Number.isFinite(z))throw Error(`pinClock: ${String(D)} is not a date.`);class B extends ${constructor(...C){if(C.length===0)super($.now()+z);else super(...C)}static now(){return $.now()+z}}return globalThis.Date=B,()=>{if(globalThis.Date===B)globalThis.Date=$}}export{t as pinClock,M as RecordingProvider,N as RecordingMismatchError,L as Fingerprints};
5
5
 
package/dist/app/index.js CHANGED
@@ -1,4 +1,4 @@
1
1
  // @bun
2
- import{Sa as a}from"../chunk-jzspg75a.js";import"../chunk-5ra8x6ax.js";import"../chunk-qymdnzpy.js";export{a as App};
2
+ import{Sa as a}from"../chunk-2e278yhf.js";import"../chunk-jgb3je66.js";import"../chunk-c80xrwep.js";export{a as App};
3
3
 
4
4
  //# debugId=668BCB797828983E64756E2164756E21
@@ -1,4 +1,4 @@
1
1
  // @bun
2
- import{ta as a}from"../chunk-vj9f634z.js";import"../chunk-a7svhrg6.js";import"../chunk-sgqfg5gg.js";import"../chunk-rarqef1m.js";import"../chunk-qymdnzpy.js";export{a as gemiPlugin};
2
+ import{ta as a}from"../chunk-1a0ehbkm.js";import"../chunk-xbxdhmh4.js";import"../chunk-s7p6w1p2.js";import"../chunk-18aw52vs.js";import"../chunk-c80xrwep.js";export{a as gemiPlugin};
3
3
 
4
4
  //# debugId=BD578B5AA7215BBC64756E2164756E21
@@ -1,4 +1,4 @@
1
1
  // @bun
2
- import{ta as k}from"../chunk-vj9f634z.js";import"../chunk-a7svhrg6.js";import"../chunk-sgqfg5gg.js";import"../chunk-rarqef1m.js";import{Na as j}from"../chunk-0cckwd91.js";import"../chunk-qymdnzpy.js";var{plugin:q}=globalThis.Bun;q(k());var y=await j(process.cwd());for(let x of y.bun?.plugins??[])q(x);
2
+ import{ta as k}from"../chunk-1a0ehbkm.js";import"../chunk-xbxdhmh4.js";import"../chunk-s7p6w1p2.js";import"../chunk-18aw52vs.js";import{Na as j}from"../chunk-0cckwd91.js";import"../chunk-c80xrwep.js";var{plugin:q}=globalThis.Bun;q(k());var y=await j(process.cwd());for(let x of y.bun?.plugins??[])q(x);
3
3
 
4
4
  //# debugId=CF0741C315167B7764756E2164756E21