@qitqode/qitqode-android-arm64 0.2.8 → 0.2.9

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 (75) hide show
  1. package/bundle/{chunk-7b60whxm.js → chunk-0eh3yc6e.js} +1 -1
  2. package/bundle/{chunk-fge37dke.js → chunk-0mh600tv.js} +1 -1
  3. package/bundle/{chunk-5f0nhthe.js → chunk-0s4cp6q2.js} +1 -1
  4. package/bundle/{chunk-s8z7v1me.js → chunk-13jq2ygc.js} +1 -1
  5. package/bundle/{chunk-kwfe4em6.js → chunk-1a6q1f5n.js} +1 -1
  6. package/bundle/{chunk-he9kpk9r.js → chunk-1acn5me8.js} +3 -3
  7. package/bundle/{chunk-82xrfk5x.js → chunk-29q89bge.js} +1 -1
  8. package/bundle/{chunk-waa1ggtj.js → chunk-2phyc1c0.js} +1 -1
  9. package/bundle/{chunk-njsmma3a.js → chunk-30wp95w1.js} +1 -1
  10. package/bundle/{chunk-wf41m019.js → chunk-32fpqd0n.js} +1 -1
  11. package/bundle/chunk-4y9wbfd2.js +8 -0
  12. package/bundle/{chunk-3cx4p07h.js → chunk-539cw9r0.js} +1 -1
  13. package/bundle/{chunk-epmc4aht.js → chunk-53jstmdp.js} +1 -1
  14. package/bundle/{chunk-nga216dm.js → chunk-6vnqbejg.js} +1 -1
  15. package/bundle/{chunk-3zwma68w.js → chunk-702bt91p.js} +2 -2
  16. package/bundle/{chunk-26cr51wa.js → chunk-705qkpra.js} +1 -1
  17. package/bundle/{chunk-66qmmmdp.js → chunk-76c400ze.js} +1 -1
  18. package/bundle/{chunk-ddx2pcr4.js → chunk-7bxxc4a3.js} +1 -1
  19. package/bundle/{chunk-qxdpgdfk.js → chunk-7pckez5z.js} +1 -1
  20. package/bundle/{chunk-gefx3n08.js → chunk-7r92d7v9.js} +1 -1
  21. package/bundle/{chunk-w0sng8a9.js → chunk-9bw6bx5c.js} +1 -1
  22. package/bundle/{chunk-9009v4d0.js → chunk-b5ym419d.js} +1 -1
  23. package/bundle/{chunk-2qm46qvn.js → chunk-bhg69t69.js} +1 -1
  24. package/bundle/{chunk-gc5rhnht.js → chunk-bkfafcbw.js} +1 -1
  25. package/bundle/{chunk-khpfseej.js → chunk-bnw744ej.js} +2 -2
  26. package/bundle/{chunk-4064rbtp.js → chunk-c987bemn.js} +1 -1
  27. package/bundle/{chunk-4aajzxm9.js → chunk-dcv6wj9x.js} +1 -1
  28. package/bundle/{chunk-rjhvdfn5.js → chunk-dtcvqrmn.js} +1 -1
  29. package/bundle/{chunk-x00hwy3x.js → chunk-dwqvcdmf.js} +1 -1
  30. package/bundle/{chunk-2t5yh25f.js → chunk-e0hha3be.js} +1 -1
  31. package/bundle/{chunk-66wv82vf.js → chunk-fd8x2nb4.js} +1 -1
  32. package/bundle/{chunk-tsmj98yf.js → chunk-fv5mrdyc.js} +1 -1
  33. package/bundle/{chunk-6yhn9syz.js → chunk-fveaq0pb.js} +1 -1
  34. package/bundle/{chunk-k3hgwszx.js → chunk-gkbx6edf.js} +1 -1
  35. package/bundle/{chunk-txkdt4ep.js → chunk-gq9hb2e8.js} +1 -1
  36. package/bundle/{chunk-wb05bp10.js → chunk-gswhjd1h.js} +1 -1
  37. package/bundle/{chunk-b7ncyat6.js → chunk-hq7s4f75.js} +1 -1
  38. package/bundle/{chunk-f30em1wx.js → chunk-j1h64m65.js} +1 -1
  39. package/bundle/{chunk-qq9m8fxv.js → chunk-k1qd8ecm.js} +4 -4
  40. package/bundle/{chunk-bnaj2hh3.js → chunk-k3m7jfdh.js} +1 -1
  41. package/bundle/{chunk-6qwk6z87.js → chunk-k6981ysw.js} +1 -1
  42. package/bundle/{chunk-qxre2gqn.js → chunk-m4g4djss.js} +1 -1
  43. package/bundle/{chunk-qgfbsmsx.js → chunk-maa21rh9.js} +1 -1
  44. package/bundle/{chunk-ayb3bdb7.js → chunk-mrq35ftw.js} +1 -1
  45. package/bundle/{chunk-vfd3azkp.js → chunk-mt2by7rx.js} +1 -1
  46. package/bundle/{chunk-dmkgjf1v.js → chunk-mwkms65j.js} +1 -1
  47. package/bundle/{chunk-f81kk8ra.js → chunk-nas631g2.js} +1 -1
  48. package/bundle/{chunk-h4hs2rhf.js → chunk-nsp1za8t.js} +1 -1
  49. package/bundle/{chunk-c2a74stf.js → chunk-nsw5x43k.js} +1 -1
  50. package/bundle/{chunk-5nmm1kvx.js → chunk-qsme16gk.js} +1 -1
  51. package/bundle/{chunk-nfafk3ts.js → chunk-qwmae3vk.js} +1 -1
  52. package/bundle/{chunk-58f4y4b7.js → chunk-rdreeyv0.js} +1 -1
  53. package/bundle/{chunk-bjv1h2dq.js → chunk-rjcz4kbm.js} +1 -1
  54. package/bundle/{chunk-vkjqy92f.js → chunk-rwwvy89t.js} +1 -1
  55. package/bundle/{chunk-f8cae1ap.js → chunk-s5aefff0.js} +1 -1
  56. package/bundle/{chunk-ezgfhy4e.js → chunk-tax3ecy5.js} +1 -1
  57. package/bundle/{chunk-w9qh2479.js → chunk-tk4z6r09.js} +1 -1
  58. package/bundle/{chunk-qn8tz704.js → chunk-tr0rm1ka.js} +1 -1
  59. package/bundle/{chunk-q3c8mfbq.js → chunk-ty14zznd.js} +1 -1
  60. package/bundle/{chunk-33ebjca6.js → chunk-vd8cmdpv.js} +1 -1
  61. package/bundle/{chunk-c3yjbent.js → chunk-vgt3artc.js} +1 -1
  62. package/bundle/{chunk-ytyzrqev.js → chunk-vkkz40je.js} +1 -1
  63. package/bundle/{chunk-8g4jdqq1.js → chunk-vpjyk76v.js} +1 -1
  64. package/bundle/{chunk-xs6v0r9m.js → chunk-wwvek9zf.js} +1 -1
  65. package/bundle/{chunk-nwj6mcxz.js → chunk-x7a3kqe5.js} +1 -1
  66. package/bundle/{chunk-8csas2jc.js → chunk-xb22grz6.js} +1 -1
  67. package/bundle/{chunk-9cn8cmt0.js → chunk-y31f8k5f.js} +1 -1
  68. package/bundle/{chunk-n6v36np0.js → chunk-y3eeva80.js} +1 -1
  69. package/bundle/{chunk-qc89yj61.js → chunk-zq32jhj1.js} +1 -1
  70. package/bundle/chunk-zxwjxszn.js +2 -0
  71. package/bundle/index.js +3 -3
  72. package/bundle/worker.js +1 -1
  73. package/package.json +1 -1
  74. package/bundle/chunk-37cbrnke.js +0 -8
  75. package/bundle/chunk-e01jgnnm.js +0 -2
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{i as P,j as g,k as b,l as h,m as O}from"./chunk-0z1keh2w.js";import"./chunk-2kh0tg92.js";import"./chunk-52xvhxek.js";import{be as u}from"./chunk-f4mnp6xd.js";import{eg as s}from"./chunk-bwadggys.js";import{Ch as f}from"./chunk-he9kpk9r.js";import{Dh as E}from"./chunk-vs3s49jw.js";import"./chunk-kre93a89.js";import"./chunk-060wbpz4.js";import"./chunk-zrhw1szj.js";import"./chunk-t8fjgkp8.js";import"./chunk-0egrckx0.js";import{Bj as S,Cj as p}from"./chunk-qq9m8fxv.js";import"./chunk-2qm46qvn.js";import"./chunk-tsmj98yf.js";import"./chunk-58f4y4b7.js";import"./chunk-rmsqb6r4.js";import"./chunk-qxdpgdfk.js";import"./chunk-6qwk6z87.js";import"./chunk-sa0rrreh.js";import"./chunk-ydgst3h8.js";import"./chunk-6tqbnxar.js";import"./chunk-0w19vmd7.js";import"./chunk-eewe7tx1.js";import"./chunk-37cbrnke.js";import"./chunk-wm9nh9nb.js";import"./chunk-scnbt714.js";import"./chunk-cqtkxwd8.js";import"./chunk-y3gy62q5.js";import"./chunk-az3nss5m.js";import"./chunk-p2fte9vz.js";import"./chunk-ggncq8w8.js";import"./chunk-t3w43rft.js";import"./chunk-eacpc64g.js";import"./chunk-27saej0r.js";import"./chunk-9009v4d0.js";import"./chunk-82xrfk5x.js";import"./chunk-wqk1v8t0.js";import"./chunk-vkjqy92f.js";import"./chunk-z0kbyr00.js";import"./chunk-sbjymf20.js";import"./chunk-dt3bsmfe.js";import"./chunk-vbfej8ds.js";import"./chunk-0tm6589k.js";import"./chunk-6yhn9syz.js";import"./chunk-wb05bp10.js";import"./chunk-wgkcyqn1.js";import"./chunk-59csnjc3.js";import"./chunk-1bxfzd6r.js";import"./chunk-6p6m5956.js";import"./chunk-a48mx917.js";import"./chunk-3va85mbe.js";import{Ry as I}from"./chunk-w7a33cwa.js";import{BC as D,fH as l,mB as d}from"./chunk-g7v6sp3c.js";import"./chunk-s2tc3qs0.js";import"./chunk-n6tqtk6h.js";import"./chunk-e0vrxetq.js";var A=(o)=>l.promise(()=>E(o)),m=(o)=>l.sync(()=>s.println(o)),v=(o)=>s.Style.TEXT_DIM+o+s.Style.TEXT_NORMAL,L=(o)=>o?v(" (active)"):"",w=(o,e)=>`${o.email} ${v(o.url)}${L(e)}`,x=(o,e,t)=>`${e.name} (${o.email})${L(t)}`,C=(o,e,t)=>{let n=t?s.Style.TEXT_SUCCESS+"\u25CF"+s.Style.TEXT_NORMAL:" ",c=t?s.Style.TEXT_HIGHLIGHT_BOLD+e.name+s.Style.TEXT_NORMAL:e.name;return` ${n} ${c} ${v(o.email)} ${v(o.url)} ${v(e.id)}`},T=(o,e)=>d.isSome(o)&&o.value.id===e.accountID&&o.value.active_org_id===e.orgID,_=l.fn("login")(function*(o){let e=yield*p.Service;yield*P("Log in");let t=yield*e.login(o);yield*b.info("Go to: "+t.url),yield*b.info("Enter code: "+t.user),yield*A(t.url);let n=O();yield*n.start("Waiting for authorization...");let c=(r)=>l.gen(function*(){yield*l.sleep(r);let i=yield*e.poll(t);if(i._tag==="PollPending")return yield*c(r);if(i._tag==="PollSlow")return yield*c(D.sum(r,D.seconds(5)));return i}),a=yield*c(t.interval).pipe(l.timeout(t.expiry),l.catchTag("TimeoutError",()=>l.succeed(new S)));yield*I.valueTags(a,{PollSuccess:(r)=>l.gen(function*(){yield*n.stop("Logged in as "+r.email),yield*g("Done")}),PollExpired:()=>n.stop("Device code expired",1),PollDenied:()=>n.stop("Authorization denied",1),PollError:(r)=>n.stop("Error: "+String(r.cause),1),PollPending:()=>n.stop("Unexpected state",1),PollSlow:()=>n.stop("Unexpected state",1)})}),N=l.fn("logout")(function*(o){let e=yield*p.Service,t=yield*e.list();if(t.length===0)return yield*m("Not logged in");if(o){let i=t.find((y)=>y.email===o);if(!i)return yield*m("Account not found: "+o);yield*e.remove(i.id),yield*g("Logged out from "+o);return}let n=yield*e.active(),c=d.map(n,(i)=>i.id);yield*P("Log out");let a=t.map((i)=>{let y=d.isSome(c)&&c.value===i.id;return{value:i,label:w(i,y)}}),r=yield*h({message:"Select account to log out",options:a});if(d.isNone(r))return;yield*e.remove(r.value.id),yield*g("Logged out from "+r.value.email)}),$=l.fn("switch")(function*(){let o=yield*p.Service,e=yield*o.orgsByAccount();if(e.length===0)return yield*m("Not logged in");let t=yield*o.active(),n=e.flatMap((r)=>r.orgs.map((i)=>{let y=T(t,{accountID:r.account.id,orgID:i.id});return{value:{orgID:i.id,accountID:r.account.id,label:i.name},label:x(r.account,i,y)}}));if(n.length===0)return yield*m("No orgs found");yield*P("Switch org");let c=yield*h({message:"Select org",options:n});if(d.isNone(c))return;let a=c.value;yield*o.use(a.accountID,d.some(a.orgID)),yield*g("Switched to "+a.label)}),R=l.fn("orgs")(function*(){let o=yield*p.Service,e=yield*o.orgsByAccount();if(e.length===0)return yield*m("No accounts found");if(!e.some((n)=>n.orgs.length>0))return yield*m("No orgs found");let t=yield*o.active();for(let n of e)for(let c of n.orgs){let a=T(t,{accountID:n.account.id,orgID:c.id});yield*m(C(n.account,c,a))}}),M=l.fn("open")(function*(){let e=yield*(yield*p.Service).active();if(d.isNone(e))return yield*m("No active account");let t=e.value.url;yield*A(t),yield*g("Opened "+t)}),X=u({command:"login <url>",describe:!1,builder:(o)=>o.positional("url",{describe:"server URL",type:"string",demandOption:!0}),async handler(o){s.empty(),await f.runPromise(_(o.url))}}),B=u({command:"logout [email]",describe:!1,builder:(o)=>o.positional("email",{describe:"account email to log out from",type:"string"}),async handler(o){s.empty(),await f.runPromise(N(o.email))}}),U=u({command:"switch",describe:!1,async handler(){s.empty(),await f.runPromise($())}}),G=u({command:"orgs",describe:!1,async handler(){s.empty(),await f.runPromise(R())}}),H=u({command:"open",describe:!1,async handler(){s.empty(),await f.runPromise(M())}}),Y=u({command:"console",describe:!1,builder:(o)=>o.command({...X,describe:"log in to console"}).command({...B,describe:"log out from console"}).command({...U,describe:"switch active org"}).command({...G,describe:"list orgs"}).command({...H,describe:"open active console account"}).demandCommand(),async handler(){}});export{C as formatOrgLine,w as formatAccountLabel,U as SwitchCommand,G as OrgsCommand,H as OpenCommand,B as LogoutCommand,X as LoginCommand,Y as ConsoleCommand};
2
+ import{i as P,j as g,k as b,l as h,m as O}from"./chunk-0z1keh2w.js";import"./chunk-2kh0tg92.js";import"./chunk-52xvhxek.js";import{be as u}from"./chunk-f4mnp6xd.js";import{eg as s}from"./chunk-bwadggys.js";import{Ch as f}from"./chunk-1acn5me8.js";import{Dh as E}from"./chunk-vs3s49jw.js";import"./chunk-kre93a89.js";import"./chunk-060wbpz4.js";import"./chunk-zrhw1szj.js";import"./chunk-t8fjgkp8.js";import"./chunk-0egrckx0.js";import{Bj as S,Cj as p}from"./chunk-k1qd8ecm.js";import"./chunk-bhg69t69.js";import"./chunk-fv5mrdyc.js";import"./chunk-rdreeyv0.js";import"./chunk-rmsqb6r4.js";import"./chunk-7pckez5z.js";import"./chunk-k6981ysw.js";import"./chunk-sa0rrreh.js";import"./chunk-ydgst3h8.js";import"./chunk-6tqbnxar.js";import"./chunk-0w19vmd7.js";import"./chunk-eewe7tx1.js";import"./chunk-4y9wbfd2.js";import"./chunk-wm9nh9nb.js";import"./chunk-scnbt714.js";import"./chunk-cqtkxwd8.js";import"./chunk-y3gy62q5.js";import"./chunk-az3nss5m.js";import"./chunk-p2fte9vz.js";import"./chunk-ggncq8w8.js";import"./chunk-t3w43rft.js";import"./chunk-eacpc64g.js";import"./chunk-27saej0r.js";import"./chunk-b5ym419d.js";import"./chunk-29q89bge.js";import"./chunk-wqk1v8t0.js";import"./chunk-rwwvy89t.js";import"./chunk-z0kbyr00.js";import"./chunk-sbjymf20.js";import"./chunk-dt3bsmfe.js";import"./chunk-vbfej8ds.js";import"./chunk-0tm6589k.js";import"./chunk-fveaq0pb.js";import"./chunk-gswhjd1h.js";import"./chunk-wgkcyqn1.js";import"./chunk-59csnjc3.js";import"./chunk-1bxfzd6r.js";import"./chunk-6p6m5956.js";import"./chunk-a48mx917.js";import"./chunk-3va85mbe.js";import{Ry as I}from"./chunk-w7a33cwa.js";import{BC as D,fH as l,mB as d}from"./chunk-g7v6sp3c.js";import"./chunk-s2tc3qs0.js";import"./chunk-n6tqtk6h.js";import"./chunk-e0vrxetq.js";var A=(o)=>l.promise(()=>E(o)),m=(o)=>l.sync(()=>s.println(o)),v=(o)=>s.Style.TEXT_DIM+o+s.Style.TEXT_NORMAL,L=(o)=>o?v(" (active)"):"",w=(o,e)=>`${o.email} ${v(o.url)}${L(e)}`,x=(o,e,t)=>`${e.name} (${o.email})${L(t)}`,C=(o,e,t)=>{let n=t?s.Style.TEXT_SUCCESS+"\u25CF"+s.Style.TEXT_NORMAL:" ",c=t?s.Style.TEXT_HIGHLIGHT_BOLD+e.name+s.Style.TEXT_NORMAL:e.name;return` ${n} ${c} ${v(o.email)} ${v(o.url)} ${v(e.id)}`},T=(o,e)=>d.isSome(o)&&o.value.id===e.accountID&&o.value.active_org_id===e.orgID,_=l.fn("login")(function*(o){let e=yield*p.Service;yield*P("Log in");let t=yield*e.login(o);yield*b.info("Go to: "+t.url),yield*b.info("Enter code: "+t.user),yield*A(t.url);let n=O();yield*n.start("Waiting for authorization...");let c=(r)=>l.gen(function*(){yield*l.sleep(r);let i=yield*e.poll(t);if(i._tag==="PollPending")return yield*c(r);if(i._tag==="PollSlow")return yield*c(D.sum(r,D.seconds(5)));return i}),a=yield*c(t.interval).pipe(l.timeout(t.expiry),l.catchTag("TimeoutError",()=>l.succeed(new S)));yield*I.valueTags(a,{PollSuccess:(r)=>l.gen(function*(){yield*n.stop("Logged in as "+r.email),yield*g("Done")}),PollExpired:()=>n.stop("Device code expired",1),PollDenied:()=>n.stop("Authorization denied",1),PollError:(r)=>n.stop("Error: "+String(r.cause),1),PollPending:()=>n.stop("Unexpected state",1),PollSlow:()=>n.stop("Unexpected state",1)})}),N=l.fn("logout")(function*(o){let e=yield*p.Service,t=yield*e.list();if(t.length===0)return yield*m("Not logged in");if(o){let i=t.find((y)=>y.email===o);if(!i)return yield*m("Account not found: "+o);yield*e.remove(i.id),yield*g("Logged out from "+o);return}let n=yield*e.active(),c=d.map(n,(i)=>i.id);yield*P("Log out");let a=t.map((i)=>{let y=d.isSome(c)&&c.value===i.id;return{value:i,label:w(i,y)}}),r=yield*h({message:"Select account to log out",options:a});if(d.isNone(r))return;yield*e.remove(r.value.id),yield*g("Logged out from "+r.value.email)}),$=l.fn("switch")(function*(){let o=yield*p.Service,e=yield*o.orgsByAccount();if(e.length===0)return yield*m("Not logged in");let t=yield*o.active(),n=e.flatMap((r)=>r.orgs.map((i)=>{let y=T(t,{accountID:r.account.id,orgID:i.id});return{value:{orgID:i.id,accountID:r.account.id,label:i.name},label:x(r.account,i,y)}}));if(n.length===0)return yield*m("No orgs found");yield*P("Switch org");let c=yield*h({message:"Select org",options:n});if(d.isNone(c))return;let a=c.value;yield*o.use(a.accountID,d.some(a.orgID)),yield*g("Switched to "+a.label)}),R=l.fn("orgs")(function*(){let o=yield*p.Service,e=yield*o.orgsByAccount();if(e.length===0)return yield*m("No accounts found");if(!e.some((n)=>n.orgs.length>0))return yield*m("No orgs found");let t=yield*o.active();for(let n of e)for(let c of n.orgs){let a=T(t,{accountID:n.account.id,orgID:c.id});yield*m(C(n.account,c,a))}}),M=l.fn("open")(function*(){let e=yield*(yield*p.Service).active();if(d.isNone(e))return yield*m("No active account");let t=e.value.url;yield*A(t),yield*g("Opened "+t)}),X=u({command:"login <url>",describe:!1,builder:(o)=>o.positional("url",{describe:"server URL",type:"string",demandOption:!0}),async handler(o){s.empty(),await f.runPromise(_(o.url))}}),B=u({command:"logout [email]",describe:!1,builder:(o)=>o.positional("email",{describe:"account email to log out from",type:"string"}),async handler(o){s.empty(),await f.runPromise(N(o.email))}}),U=u({command:"switch",describe:!1,async handler(){s.empty(),await f.runPromise($())}}),G=u({command:"orgs",describe:!1,async handler(){s.empty(),await f.runPromise(R())}}),H=u({command:"open",describe:!1,async handler(){s.empty(),await f.runPromise(M())}}),Y=u({command:"console",describe:!1,builder:(o)=>o.command({...X,describe:"log in to console"}).command({...B,describe:"log out from console"}).command({...U,describe:"switch active org"}).command({...G,describe:"list orgs"}).command({...H,describe:"open active console account"}).demandCommand(),async handler(){}});export{C as formatOrgLine,w as formatAccountLabel,U as SwitchCommand,G as OrgsCommand,H as OpenCommand,B as LogoutCommand,X as LoginCommand,Y as ConsoleCommand};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Qd as b}from"./chunk-ytyzrqev.js";import{be as f}from"./chunk-f4mnp6xd.js";import{Ch as S}from"./chunk-he9kpk9r.js";import"./chunk-vs3s49jw.js";import"./chunk-kre93a89.js";import"./chunk-060wbpz4.js";import"./chunk-zrhw1szj.js";import"./chunk-t8fjgkp8.js";import"./chunk-0egrckx0.js";import{dl as v}from"./chunk-qq9m8fxv.js";import"./chunk-2qm46qvn.js";import{El as R,Ol as k,wl as U}from"./chunk-tsmj98yf.js";import"./chunk-58f4y4b7.js";import"./chunk-rmsqb6r4.js";import"./chunk-qxdpgdfk.js";import"./chunk-6qwk6z87.js";import"./chunk-sa0rrreh.js";import"./chunk-ydgst3h8.js";import"./chunk-6tqbnxar.js";import"./chunk-0w19vmd7.js";import"./chunk-eewe7tx1.js";import"./chunk-37cbrnke.js";import"./chunk-wm9nh9nb.js";import"./chunk-scnbt714.js";import"./chunk-cqtkxwd8.js";import"./chunk-y3gy62q5.js";import"./chunk-az3nss5m.js";import"./chunk-p2fte9vz.js";import"./chunk-ggncq8w8.js";import"./chunk-t3w43rft.js";import"./chunk-eacpc64g.js";import"./chunk-27saej0r.js";import"./chunk-9009v4d0.js";import"./chunk-82xrfk5x.js";import"./chunk-wqk1v8t0.js";import{Fr as Z}from"./chunk-vkjqy92f.js";import"./chunk-z0kbyr00.js";import"./chunk-sbjymf20.js";import"./chunk-dt3bsmfe.js";import"./chunk-vbfej8ds.js";import"./chunk-0tm6589k.js";import"./chunk-6yhn9syz.js";import"./chunk-wb05bp10.js";import"./chunk-wgkcyqn1.js";import"./chunk-59csnjc3.js";import"./chunk-1bxfzd6r.js";import"./chunk-6p6m5956.js";import"./chunk-a48mx917.js";import"./chunk-3va85mbe.js";import"./chunk-w7a33cwa.js";import"./chunk-g7v6sp3c.js";import"./chunk-s2tc3qs0.js";import"./chunk-n6tqtk6h.js";import"./chunk-e0vrxetq.js";var i=f({command:"stats",describe:"show token usage and cost statistics",builder:(z)=>{return z.option("days",{describe:"show stats for the last N days (default: all time)",type:"number"}).option("tools",{describe:"number of tools to show (default: all)",type:"number"}).option("models",{describe:"show model statistics (default: hidden). Pass a number to show top N, otherwise shows all"}).option("project",{describe:"filter by project (default: all projects, empty string: current project)",type:"string"})},handler:async(z)=>{await b(process.cwd(),async()=>{let E=await y(z.days,z.project),_;if(z.models===!0)_=1/0;else if(typeof z.models==="number")_=z.models;u(E,z.tools,_)})}});async function w(){return k.project}async function p(){return R.use((E)=>E.select().from(U).all()).map((E)=>v.fromRow(E))}async function y(z,E){let _=await p(),L=86400000,J=(()=>{if(z===void 0)return 0;if(z===0){let V=new Date;return V.setHours(0,0,0,0),V.getTime()}return Date.now()-z*86400000})(),K=(()=>{if(z===void 0)return;if(z===0)return 1;return z})(),Y=J>0?_.filter((V)=>V.time.updated>=J):_;if(E!==void 0)if(E===""){let V=await w();Y=Y.filter((F)=>F.projectID===V.id)}else Y=Y.filter((V)=>V.projectID===E);let G={totalSessions:Y.length,totalMessages:0,totalCost:0,totalTokens:{input:0,output:0,reasoning:0,cache:{read:0,write:0}},toolUsage:{},modelUsage:{},dateRange:{earliest:Date.now(),latest:Date.now()},days:0,costPerDay:0,tokensPerSession:0,medianTokensPerSession:0};if(Y.length>1000)console.log(`Large dataset detected (${Y.length} sessions). This may take a while...`);if(Y.length===0)return G.days=K??0,G;let C=Date.now(),x=0,X=[],h=20;for(let V=0;V<Y.length;V+=h){let D=Y.slice(V,V+h).map(async(Q)=>{let W=await S.runPromise(v.Service.use((O)=>O.messages({sessionID:Q.id,agentID:"*"}))),N=0,H={input:0,output:0,reasoning:0,cache:{read:0,write:0}},j={},A={};for(let O of W){if(O.info.role==="assistant"){N+=O.info.cost||0;let B=`${O.info.providerID}/${O.info.modelID}`;if(!A[B])A[B]={messages:0,tokens:{input:0,output:0,cache:{read:0,write:0}},cost:0};if(A[B].messages++,A[B].cost+=O.info.cost||0,O.info.tokens)H.input+=O.info.tokens.input||0,H.output+=O.info.tokens.output||0,H.reasoning+=O.info.tokens.reasoning||0,H.cache.read+=O.info.tokens.cache?.read||0,H.cache.write+=O.info.tokens.cache?.write||0,A[B].tokens.input+=O.info.tokens.input||0,A[B].tokens.output+=(O.info.tokens.output||0)+(O.info.tokens.reasoning||0),A[B].tokens.cache.read+=O.info.tokens.cache?.read||0,A[B].tokens.cache.write+=O.info.tokens.cache?.write||0}for(let B of O.parts)if(B.type==="tool"&&B.tool)j[B.tool]=(j[B.tool]||0)+1}return{messageCount:W.length,sessionCost:N,sessionTokens:H,sessionTotalTokens:H.input+H.output+H.reasoning+H.cache.read+H.cache.write,sessionToolUsage:j,sessionModelUsage:A,earliestTime:J>0?Q.time.updated:Q.time.created,latestTime:Q.time.updated}}),M=await Promise.all(D);for(let Q of M){C=Math.min(C,Q.earliestTime),x=Math.max(x,Q.latestTime),X.push(Q.sessionTotalTokens),G.totalMessages+=Q.messageCount,G.totalCost+=Q.sessionCost,G.totalTokens.input+=Q.sessionTokens.input,G.totalTokens.output+=Q.sessionTokens.output,G.totalTokens.reasoning+=Q.sessionTokens.reasoning,G.totalTokens.cache.read+=Q.sessionTokens.cache.read,G.totalTokens.cache.write+=Q.sessionTokens.cache.write;for(let[W,N]of Object.entries(Q.sessionToolUsage))G.toolUsage[W]=(G.toolUsage[W]||0)+N;for(let[W,N]of Object.entries(Q.sessionModelUsage)){if(!G.modelUsage[W])G.modelUsage[W]={messages:0,tokens:{input:0,output:0,cache:{read:0,write:0}},cost:0};G.modelUsage[W].messages+=N.messages,G.modelUsage[W].tokens.input+=N.tokens.input,G.modelUsage[W].tokens.output+=N.tokens.output,G.modelUsage[W].tokens.cache.read+=N.tokens.cache.read,G.modelUsage[W].tokens.cache.write+=N.tokens.cache.write,G.modelUsage[W].cost+=N.cost}}}let $=Math.max(1,Math.ceil((x-C)/86400000)),q=K??$;G.dateRange={earliest:C,latest:x},G.days=q,G.costPerDay=G.totalCost/q;let I=G.totalTokens.input+G.totalTokens.output+G.totalTokens.reasoning+G.totalTokens.cache.read+G.totalTokens.cache.write;G.tokensPerSession=Y.length>0?I/Y.length:0,X.sort((V,F)=>V-F);let P=Math.floor(X.length/2);return G.medianTokensPerSession=X.length===0?0:X.length%2===0?(X[P-1]+X[P])/2:X[P],G}function u(z,E,_){function J(x,X){let $=55-x.length-X.length,q=Math.max(0,$);return`\u2502${x}${" ".repeat(q)}${X} \u2502`}console.log("\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510"),console.log("\u2502 OVERVIEW \u2502"),console.log("\u251C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524"),console.log(J("Sessions",z.totalSessions.toLocaleString())),console.log(J("Messages",z.totalMessages.toLocaleString())),console.log(J("Days",z.days.toString())),console.log("\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518"),console.log(),console.log("\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510"),console.log("\u2502 COST & TOKENS \u2502"),console.log("\u251C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524");let K=isNaN(z.totalCost)?0:z.totalCost,Y=isNaN(z.costPerDay)?0:z.costPerDay,G=isNaN(z.tokensPerSession)?0:z.tokensPerSession;console.log(J("Total Cost",`$${K.toFixed(2)}`)),console.log(J("Avg Cost/Day",`$${Y.toFixed(2)}`)),console.log(J("Avg Tokens/Session",Z.number(Math.round(G))));let C=isNaN(z.medianTokensPerSession)?0:z.medianTokensPerSession;if(console.log(J("Median Tokens/Session",Z.number(Math.round(C)))),console.log(J("Input",Z.number(z.totalTokens.input))),console.log(J("Output",Z.number(z.totalTokens.output))),console.log(J("Cache Read",Z.number(z.totalTokens.cache.read))),console.log(J("Cache Write",Z.number(z.totalTokens.cache.write))),console.log("\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518"),console.log(),_!==void 0&&Object.keys(z.modelUsage).length>0){let x=Object.entries(z.modelUsage).sort(([,h],[,$])=>$.messages-h.messages),X=_===1/0?x:x.slice(0,_);console.log("\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510"),console.log("\u2502 MODEL USAGE \u2502"),console.log("\u251C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524");for(let[h,$]of X)console.log(`\u2502 ${h.padEnd(54)} \u2502`),console.log(J(" Messages",$.messages.toLocaleString())),console.log(J(" Input Tokens",Z.number($.tokens.input))),console.log(J(" Output Tokens",Z.number($.tokens.output))),console.log(J(" Cache Read",Z.number($.tokens.cache.read))),console.log(J(" Cache Write",Z.number($.tokens.cache.write))),console.log(J(" Cost",`$${$.cost.toFixed(4)}`)),console.log("\u251C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524");process.stdout.write("\x1B[1A"),console.log("\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518")}if(console.log(),Object.keys(z.toolUsage).length>0){let x=Object.entries(z.toolUsage).sort(([,q],[,I])=>I-q),X=E?x.slice(0,E):x;console.log("\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510"),console.log("\u2502 TOOL USAGE \u2502"),console.log("\u251C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524");let h=Math.max(...X.map(([,q])=>q)),$=Object.values(z.toolUsage).reduce((q,I)=>q+I,0);for(let[q,I]of X){let P=Math.max(1,Math.floor(I/h*20)),V="\u2588".repeat(P),F=(I/$*100).toFixed(1),D=18,W=` ${(q.length>18?q.substring(0,16)+"..":q).padEnd(18)} ${V.padEnd(20)} ${I.toString().padStart(3)} (${F.padStart(4)}%)`,N=Math.max(0,56-W.length-1);console.log(`\u2502${W}${" ".repeat(N)} \u2502`)}console.log("\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518")}console.log()}export{u as displayStats,y as aggregateSessionStats,i as StatsCommand};
2
+ import{Qd as b}from"./chunk-vkkz40je.js";import{be as f}from"./chunk-f4mnp6xd.js";import{Ch as S}from"./chunk-1acn5me8.js";import"./chunk-vs3s49jw.js";import"./chunk-kre93a89.js";import"./chunk-060wbpz4.js";import"./chunk-zrhw1szj.js";import"./chunk-t8fjgkp8.js";import"./chunk-0egrckx0.js";import{dl as v}from"./chunk-k1qd8ecm.js";import"./chunk-bhg69t69.js";import{El as R,Ol as k,wl as U}from"./chunk-fv5mrdyc.js";import"./chunk-rdreeyv0.js";import"./chunk-rmsqb6r4.js";import"./chunk-7pckez5z.js";import"./chunk-k6981ysw.js";import"./chunk-sa0rrreh.js";import"./chunk-ydgst3h8.js";import"./chunk-6tqbnxar.js";import"./chunk-0w19vmd7.js";import"./chunk-eewe7tx1.js";import"./chunk-4y9wbfd2.js";import"./chunk-wm9nh9nb.js";import"./chunk-scnbt714.js";import"./chunk-cqtkxwd8.js";import"./chunk-y3gy62q5.js";import"./chunk-az3nss5m.js";import"./chunk-p2fte9vz.js";import"./chunk-ggncq8w8.js";import"./chunk-t3w43rft.js";import"./chunk-eacpc64g.js";import"./chunk-27saej0r.js";import"./chunk-b5ym419d.js";import"./chunk-29q89bge.js";import"./chunk-wqk1v8t0.js";import{Fr as Z}from"./chunk-rwwvy89t.js";import"./chunk-z0kbyr00.js";import"./chunk-sbjymf20.js";import"./chunk-dt3bsmfe.js";import"./chunk-vbfej8ds.js";import"./chunk-0tm6589k.js";import"./chunk-fveaq0pb.js";import"./chunk-gswhjd1h.js";import"./chunk-wgkcyqn1.js";import"./chunk-59csnjc3.js";import"./chunk-1bxfzd6r.js";import"./chunk-6p6m5956.js";import"./chunk-a48mx917.js";import"./chunk-3va85mbe.js";import"./chunk-w7a33cwa.js";import"./chunk-g7v6sp3c.js";import"./chunk-s2tc3qs0.js";import"./chunk-n6tqtk6h.js";import"./chunk-e0vrxetq.js";var i=f({command:"stats",describe:"show token usage and cost statistics",builder:(z)=>{return z.option("days",{describe:"show stats for the last N days (default: all time)",type:"number"}).option("tools",{describe:"number of tools to show (default: all)",type:"number"}).option("models",{describe:"show model statistics (default: hidden). Pass a number to show top N, otherwise shows all"}).option("project",{describe:"filter by project (default: all projects, empty string: current project)",type:"string"})},handler:async(z)=>{await b(process.cwd(),async()=>{let E=await y(z.days,z.project),_;if(z.models===!0)_=1/0;else if(typeof z.models==="number")_=z.models;u(E,z.tools,_)})}});async function w(){return k.project}async function p(){return R.use((E)=>E.select().from(U).all()).map((E)=>v.fromRow(E))}async function y(z,E){let _=await p(),L=86400000,J=(()=>{if(z===void 0)return 0;if(z===0){let V=new Date;return V.setHours(0,0,0,0),V.getTime()}return Date.now()-z*86400000})(),K=(()=>{if(z===void 0)return;if(z===0)return 1;return z})(),Y=J>0?_.filter((V)=>V.time.updated>=J):_;if(E!==void 0)if(E===""){let V=await w();Y=Y.filter((F)=>F.projectID===V.id)}else Y=Y.filter((V)=>V.projectID===E);let G={totalSessions:Y.length,totalMessages:0,totalCost:0,totalTokens:{input:0,output:0,reasoning:0,cache:{read:0,write:0}},toolUsage:{},modelUsage:{},dateRange:{earliest:Date.now(),latest:Date.now()},days:0,costPerDay:0,tokensPerSession:0,medianTokensPerSession:0};if(Y.length>1000)console.log(`Large dataset detected (${Y.length} sessions). This may take a while...`);if(Y.length===0)return G.days=K??0,G;let C=Date.now(),x=0,X=[],h=20;for(let V=0;V<Y.length;V+=h){let D=Y.slice(V,V+h).map(async(Q)=>{let W=await S.runPromise(v.Service.use((O)=>O.messages({sessionID:Q.id,agentID:"*"}))),N=0,H={input:0,output:0,reasoning:0,cache:{read:0,write:0}},j={},A={};for(let O of W){if(O.info.role==="assistant"){N+=O.info.cost||0;let B=`${O.info.providerID}/${O.info.modelID}`;if(!A[B])A[B]={messages:0,tokens:{input:0,output:0,cache:{read:0,write:0}},cost:0};if(A[B].messages++,A[B].cost+=O.info.cost||0,O.info.tokens)H.input+=O.info.tokens.input||0,H.output+=O.info.tokens.output||0,H.reasoning+=O.info.tokens.reasoning||0,H.cache.read+=O.info.tokens.cache?.read||0,H.cache.write+=O.info.tokens.cache?.write||0,A[B].tokens.input+=O.info.tokens.input||0,A[B].tokens.output+=(O.info.tokens.output||0)+(O.info.tokens.reasoning||0),A[B].tokens.cache.read+=O.info.tokens.cache?.read||0,A[B].tokens.cache.write+=O.info.tokens.cache?.write||0}for(let B of O.parts)if(B.type==="tool"&&B.tool)j[B.tool]=(j[B.tool]||0)+1}return{messageCount:W.length,sessionCost:N,sessionTokens:H,sessionTotalTokens:H.input+H.output+H.reasoning+H.cache.read+H.cache.write,sessionToolUsage:j,sessionModelUsage:A,earliestTime:J>0?Q.time.updated:Q.time.created,latestTime:Q.time.updated}}),M=await Promise.all(D);for(let Q of M){C=Math.min(C,Q.earliestTime),x=Math.max(x,Q.latestTime),X.push(Q.sessionTotalTokens),G.totalMessages+=Q.messageCount,G.totalCost+=Q.sessionCost,G.totalTokens.input+=Q.sessionTokens.input,G.totalTokens.output+=Q.sessionTokens.output,G.totalTokens.reasoning+=Q.sessionTokens.reasoning,G.totalTokens.cache.read+=Q.sessionTokens.cache.read,G.totalTokens.cache.write+=Q.sessionTokens.cache.write;for(let[W,N]of Object.entries(Q.sessionToolUsage))G.toolUsage[W]=(G.toolUsage[W]||0)+N;for(let[W,N]of Object.entries(Q.sessionModelUsage)){if(!G.modelUsage[W])G.modelUsage[W]={messages:0,tokens:{input:0,output:0,cache:{read:0,write:0}},cost:0};G.modelUsage[W].messages+=N.messages,G.modelUsage[W].tokens.input+=N.tokens.input,G.modelUsage[W].tokens.output+=N.tokens.output,G.modelUsage[W].tokens.cache.read+=N.tokens.cache.read,G.modelUsage[W].tokens.cache.write+=N.tokens.cache.write,G.modelUsage[W].cost+=N.cost}}}let $=Math.max(1,Math.ceil((x-C)/86400000)),q=K??$;G.dateRange={earliest:C,latest:x},G.days=q,G.costPerDay=G.totalCost/q;let I=G.totalTokens.input+G.totalTokens.output+G.totalTokens.reasoning+G.totalTokens.cache.read+G.totalTokens.cache.write;G.tokensPerSession=Y.length>0?I/Y.length:0,X.sort((V,F)=>V-F);let P=Math.floor(X.length/2);return G.medianTokensPerSession=X.length===0?0:X.length%2===0?(X[P-1]+X[P])/2:X[P],G}function u(z,E,_){function J(x,X){let $=55-x.length-X.length,q=Math.max(0,$);return`\u2502${x}${" ".repeat(q)}${X} \u2502`}console.log("\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510"),console.log("\u2502 OVERVIEW \u2502"),console.log("\u251C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524"),console.log(J("Sessions",z.totalSessions.toLocaleString())),console.log(J("Messages",z.totalMessages.toLocaleString())),console.log(J("Days",z.days.toString())),console.log("\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518"),console.log(),console.log("\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510"),console.log("\u2502 COST & TOKENS \u2502"),console.log("\u251C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524");let K=isNaN(z.totalCost)?0:z.totalCost,Y=isNaN(z.costPerDay)?0:z.costPerDay,G=isNaN(z.tokensPerSession)?0:z.tokensPerSession;console.log(J("Total Cost",`$${K.toFixed(2)}`)),console.log(J("Avg Cost/Day",`$${Y.toFixed(2)}`)),console.log(J("Avg Tokens/Session",Z.number(Math.round(G))));let C=isNaN(z.medianTokensPerSession)?0:z.medianTokensPerSession;if(console.log(J("Median Tokens/Session",Z.number(Math.round(C)))),console.log(J("Input",Z.number(z.totalTokens.input))),console.log(J("Output",Z.number(z.totalTokens.output))),console.log(J("Cache Read",Z.number(z.totalTokens.cache.read))),console.log(J("Cache Write",Z.number(z.totalTokens.cache.write))),console.log("\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518"),console.log(),_!==void 0&&Object.keys(z.modelUsage).length>0){let x=Object.entries(z.modelUsage).sort(([,h],[,$])=>$.messages-h.messages),X=_===1/0?x:x.slice(0,_);console.log("\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510"),console.log("\u2502 MODEL USAGE \u2502"),console.log("\u251C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524");for(let[h,$]of X)console.log(`\u2502 ${h.padEnd(54)} \u2502`),console.log(J(" Messages",$.messages.toLocaleString())),console.log(J(" Input Tokens",Z.number($.tokens.input))),console.log(J(" Output Tokens",Z.number($.tokens.output))),console.log(J(" Cache Read",Z.number($.tokens.cache.read))),console.log(J(" Cache Write",Z.number($.tokens.cache.write))),console.log(J(" Cost",`$${$.cost.toFixed(4)}`)),console.log("\u251C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524");process.stdout.write("\x1B[1A"),console.log("\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518")}if(console.log(),Object.keys(z.toolUsage).length>0){let x=Object.entries(z.toolUsage).sort(([,q],[,I])=>I-q),X=E?x.slice(0,E):x;console.log("\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510"),console.log("\u2502 TOOL USAGE \u2502"),console.log("\u251C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524");let h=Math.max(...X.map(([,q])=>q)),$=Object.values(z.toolUsage).reduce((q,I)=>q+I,0);for(let[q,I]of X){let P=Math.max(1,Math.floor(I/h*20)),V="\u2588".repeat(P),F=(I/$*100).toFixed(1),D=18,W=` ${(q.length>18?q.substring(0,16)+"..":q).padEnd(18)} ${V.padEnd(20)} ${I.toString().padStart(3)} (${F.padStart(4)}%)`,N=Math.max(0,56-W.length-1);console.log(`\u2502${W}${" ".repeat(N)} \u2502`)}console.log("\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518")}console.log()}export{u as displayStats,y as aggregateSessionStats,i as StatsCommand};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{$j as u,Ij as s,Nj as e,Oj as j,Pj as v,ak as f}from"./chunk-qq9m8fxv.js";import{El as D,Il as b,Jl as a,Kl as t,vl as r,wl as C,xl as k,yl as m}from"./chunk-tsmj98yf.js";import{Bm as K,Dm as c,Km as i,vm as x,wm as q,ym as n,zm as o}from"./chunk-rmsqb6r4.js";import{Xs as Q_}from"./chunk-59csnjc3.js";import{bt as d,gt as g,lt as O_}from"./chunk-1bxfzd6r.js";import{vO as S_}from"./chunk-e0vrxetq.js";var l={};S_(l,{run:()=>h_,encodeDir:()=>k_,ClaudeImport:()=>l});import E_ from"path";import W_ from"path";import{access as X_,readFile as Y_}from"fs/promises";var G=n("external_import",{source:q().$type().notNull(),source_key:q().notNull(),session_id:q().$type().notNull(),source_path:q().notNull(),source_mtime:x().notNull(),time_imported:x().notNull(),message_ids:q({mode:"json"}).$type()},(N)=>[o({columns:[N.source,N.source_key]})]);function Z_(){return{scanned:0,imported:0,resynced:0,skipped:0,errors:[]}}async function L_(N){if(!N||!await g.exists(N))return{id:b.global,worktree:N||"/",vcs:null};if(!await a(N))return{id:b.global,worktree:N,vcs:null};return{id:await t(N),worktree:N,vcs:"git"}}function __(N){return N.split(`
2
+ import{$j as u,Ij as s,Nj as e,Oj as j,Pj as v,ak as f}from"./chunk-k1qd8ecm.js";import{El as D,Il as b,Jl as a,Kl as t,vl as r,wl as C,xl as k,yl as m}from"./chunk-fv5mrdyc.js";import{Bm as K,Dm as c,Km as i,vm as x,wm as q,ym as n,zm as o}from"./chunk-rmsqb6r4.js";import{Xs as Q_}from"./chunk-59csnjc3.js";import{bt as d,gt as g,lt as O_}from"./chunk-1bxfzd6r.js";import{vO as S_}from"./chunk-e0vrxetq.js";var l={};S_(l,{run:()=>h_,encodeDir:()=>k_,ClaudeImport:()=>l});import E_ from"path";import W_ from"path";import{access as X_,readFile as Y_}from"fs/promises";var G=n("external_import",{source:q().$type().notNull(),source_key:q().notNull(),session_id:q().$type().notNull(),source_path:q().notNull(),source_mtime:x().notNull(),time_imported:x().notNull(),message_ids:q({mode:"json"}).$type()},(N)=>[o({columns:[N.source,N.source_key]})]);function Z_(){return{scanned:0,imported:0,resynced:0,skipped:0,errors:[]}}async function L_(N){if(!N||!await g.exists(N))return{id:b.global,worktree:N||"/",vcs:null};if(!await a(N))return{id:b.global,worktree:N,vcs:null};return{id:await t(N),worktree:N,vcs:"git"}}function __(N){return N.split(`
3
3
  `).map((_)=>_.trim()).filter(Boolean).flatMap((_)=>{try{return[JSON.parse(_)]}catch{return[]}})}function N_(N){let _=N.find((H)=>H.trim()&&!H.trim().startsWith("<"));if(!_)return;return _.trim().replace(/\s+/g," ").slice(0,100)}function R_(N,_){return D.use((H)=>H.select().from(G).where(c(K(G.source,N),K(G.source_key,_))).get())}function G_(N,_){if(!_)return{existing:void 0,existingUpdated:void 0};let H=_,O=D.use((Z)=>Z.select({updated:C.time_updated}).from(C).where(K(C.id,H.session_id)).get());if(!O)return D.use((Z)=>Z.delete(G).where(c(K(G.source,N),K(G.source_key,H.source_key))).run()),{existing:void 0,existingUpdated:void 0};return{existing:_,existingUpdated:O.updated}}function J_(N,_,H,O){N.insert(r).values({id:_.id,worktree:_.worktree,vcs:_.vcs,sandboxes:[],time_created:H,time_updated:O}).onConflictDoNothing().run()}function K_(N,_,H){if(_.message_ids?.length)for(let O=0;O<_.message_ids.length;O+=500)N.delete(k).where(i(k.id,_.message_ids.slice(O,O+500))).run();else N.delete(k).where(K(k.session_id,H)).run()}function A_(N,_,H){N.update(C).set({project_id:H.projectId,directory:H.directory,version:H.version,time_updated:Math.max(H.existingUpdated??0,H.timeUpdated)}).where(K(C.id,_)).run()}function $_(N){return async(_)=>F_({...N,force:_?.force})}async function F_(N){let _=Z_();if(!await X_(N.root).then(()=>!0).catch(()=>!1))return _;let H=await d.scan(N.pattern,{cwd:N.root,absolute:!0});for(let O of H){_.scanned++;try{let Z=W_.basename(O,".jsonl"),A=await g.statAsync(O);if(!A){_.skipped++;continue}let F=Math.floor(Number(A.mtimeMs)),Y=R_(N.source,Z);if(Y&&Y.source_mtime===F&&!N.force){_.skipped++;continue}let S=G_(N.source,Y);Y=S.existing;let T=S.existingUpdated,Q=Y?Y.session_id:e.descending(),V=N.parse(await Y_(O,"utf-8"),Q);if(!V||V.messages.length===0){_.skipped++;continue}let E=await L_(V.cwd),U=Date.now(),X=V.messages.map(($)=>$.info.id);if(D.transaction(($)=>{if(J_($,E,V.timeCreated,V.timeUpdated),Y)K_($,Y,Q),A_($,Q,{projectId:E.id,directory:V.cwd,version:V.version,existingUpdated:T,timeUpdated:V.timeUpdated});else $.insert(C).values({id:Q,project_id:E.id,slug:s.create(),directory:V.cwd,title:V.title,version:V.version,time_created:V.timeCreated,time_updated:V.timeUpdated}).run();for(let L of V.messages){let{id:B,sessionID:I,agentID:w,...z}=L.info;$.insert(k).values({id:B,session_id:Q,agent_id:"main",time_created:L.info.time.created,data:z}).onConflictDoUpdate({target:k.id,set:{data:z}}).run();for(let J of L.parts){let{id:y,sessionID:p,messageID:P,...h}=J.part;$.insert(m).values({id:y,message_id:L.info.id,session_id:Q,time_created:J.time,data:h}).onConflictDoUpdate({target:m.id,set:{data:h}}).run()}}$.insert(G).values({source:N.source,source_key:Z,session_id:Q,source_path:O,source_mtime:F,time_imported:U,message_ids:X}).onConflictDoUpdate({target:[G.source,G.source_key],set:{session_id:Q,source_path:O,source_mtime:F,time_imported:U,message_ids:X}}).run()}),Y)_.resynced++;else _.imported++}catch(Z){_.errors.push(`${O}: ${Z}`)}}if(_.imported+_.resynced>0||_.errors.length>0)N.log.info(N.logMessage,{..._,errors:_.errors.length});return _}var B_=Q_.create({service:"claude-import"});function k_(N){return N.replace(/[^a-zA-Z0-9]/g,"-")}function z_(N){if(!N)return{providerID:u.anthropic,modelID:f.make("unknown")};let _=N.indexOf("/");if(_===-1)return{providerID:u.anthropic,modelID:f.make(N)};return{providerID:u.make(N.slice(0,_)),modelID:f.make(N.slice(_+1))}}function H_(N){let _=N??{};return{input:_.input_tokens??0,output:_.output_tokens??0,reasoning:0,cache:{read:_.cache_read_input_tokens??0,write:_.cache_creation_input_tokens??0}}}function C_(N){if(typeof N==="string")return N;if(Array.isArray(N))return N.map((_)=>_&&typeof _==="object"&&("type"in _)&&_.type==="text"?_.text:JSON.stringify(_)).join(`
4
4
  `);return N==null?"":JSON.stringify(N)}function U_(N,_){let H=__(N);if(H.length===0)return;let O,Z,A,F=0,Y,S=[],T=new Map,Q=null,V=null,E=z_(void 0),U=()=>{if(Q)S.push(Q);Q=null};for(let X of H){if(X.type!=="user"&&X.type!=="assistant")continue;let $=X.timestamp?Date.parse(X.timestamp):Date.now();if(!O&&X.cwd)O=X.cwd;if(!Z&&X.version)Z=X.version;if(A===void 0)A=$;F=Math.max(F,$);let L=X.message;if(!L)continue;if(X.type==="user"){let z=L.content,J=typeof z==="string"?[]:Array.isArray(z)?z:[];for(let W of J.filter((R)=>R?.type==="tool_result")){let R=T.get(W.tool_use_id);if(!R)continue;let M=C_(W.content);R.part.state=W.is_error?{status:"error",input:R.part.state.input??{},error:M,time:{start:R.start,end:$}}:{status:"completed",input:R.part.state.input??{},output:M,title:R.part.tool,metadata:{},time:{start:R.start,end:$}}}let y=typeof z==="string"?z.trim()?[z]:[]:J.filter((W)=>W?.type==="text"&&typeof W.text==="string"&&W.text.trim()).map((W)=>W.text),p=J.filter((W)=>W?.type==="image"&&W.source);if(y.length===0&&p.length===0)continue;U();let P=j.ascending(),h=[];for(let W of y)h.push({part:{id:v.ascending(),sessionID:_,messageID:P,type:"text",text:W},time:$});for(let W of p){let R=W.source.media_type??"image/png",M=W.source.type==="base64"?`data:${R};base64,${W.source.data}`:W.source.url??"";if(M)h.push({part:{id:v.ascending(),sessionID:_,messageID:P,type:"file",mime:R,url:M},time:$})}let V_={id:P,sessionID:_,role:"user",agent:"main",time:{created:$},model:{providerID:E.providerID,modelID:E.modelID}};if(S.push({info:V_,parts:h}),V=P,!Y)Y=N_(y);continue}let B=z_(L.model);if(E=B,!V){let z=j.ascending();S.push({info:{id:z,sessionID:_,role:"user",agent:"main",time:{created:$},model:{providerID:B.providerID,modelID:B.modelID}},parts:[]}),V=z}if(!Q||Q.info.role!=="assistant"||Q.info.parentID!==V)U(),Q={info:{id:j.ascending(),sessionID:_,role:"assistant",time:{created:$,completed:$},parentID:V,modelID:B.modelID,providerID:B.providerID,mode:"build",agent:"main",path:{cwd:O??X.cwd??"",root:O??X.cwd??""},cost:0,tokens:H_(L.usage)},parts:[]};let I=Q.info;I.time.completed=$,I.tokens=H_(L.usage);let w=Q.info.id;for(let z of Array.isArray(L.content)?L.content:[])if(z?.type==="thinking"||z?.type==="reasoning")Q.parts.push({part:{id:v.ascending(),sessionID:_,messageID:w,type:"reasoning",text:z.thinking??z.text??"",time:{start:$,end:$}},time:$});else if(z?.type==="text"&&typeof z.text==="string")Q.parts.push({part:{id:v.ascending(),sessionID:_,messageID:w,type:"text",text:z.text},time:$});else if(z?.type==="tool_use"){let J={id:v.ascending(),sessionID:_,messageID:w,type:"tool",callID:z.id,tool:z.name,state:{status:"pending",input:z.input??{},raw:JSON.stringify(z.input??{})}};Q.parts.push({part:J,time:$}),T.set(z.id,{part:J,start:$})}}return U(),{cwd:O??"",version:Z??"claude-code",title:Y??"Claude Code session",timeCreated:A??Date.now(),timeUpdated:F||A||Date.now(),messages:S}}var h_=$_({source:"cc",root:E_.join(O_.Path.home,".claude","projects"),pattern:"*/*.jsonl",log:B_,logMessage:"claude import",parse:U_});
5
5
  export{G as mg,Z_ as ng,L_ as og,__ as pg,N_ as qg,R_ as rg,G_ as sg,J_ as tg,K_ as ug,A_ as vg,$_ as wg,k_ as xg,h_ as yg,l as zg};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{bs as A}from"./chunk-0tm6589k.js";import{ds as B}from"./chunk-6yhn9syz.js";import{Gs as O,Hs as Q,Is as X}from"./chunk-wgkcyqn1.js";function W(j,z){return typeof j==="object"&&j!==null&&"_tag"in j&&j._tag===z}function f(j){let z=O(j),J=typeof j==="object"&&j!==null&&"name"in j&&typeof j.name==="string"?j.name:z?.errorName,K=typeof j==="object"&&j!==null&&"data"in j&&typeof j.data==="object"&&j.data!==null&&"message"in j.data&&typeof j.data.message==="string"?j.data.message:void 0;if(J==="UnknownError"||z){let v=z??Q(j,J??"UnknownError"),G=K&&!K.startsWith("{")?K:"QitQode could not explain this failure.",L=v?` [${v.errorName}, error id ${v.errorID}${v.logFile?`; log: ${v.logFile}`:""}]`:"";return G+L}if(A.hasName(j,"MCPFailed"))return`MCP server "${j.data?.name}" failed. Note, qitqode does not support MCP authentication yet.`;if(W(j,"AccountServiceError")||W(j,"AccountTransportError"))return j.message??"";if(A.hasName(j,"ProviderModelNotFoundError")){let v=j.data,G=Array.isArray(v?.suggestions)?v.suggestions:[];return[`Model not found: ${v?.providerID}/${v?.modelID}`,...G.length?["Did you mean: "+G.join(", ")]:[],"Try: `qitqode models` to list available models","Or check your config (qitqode.json) provider/model names"].join(`
2
+ import{bs as A}from"./chunk-0tm6589k.js";import{ds as B}from"./chunk-fveaq0pb.js";import{Gs as O,Hs as Q,Is as X}from"./chunk-wgkcyqn1.js";function W(j,z){return typeof j==="object"&&j!==null&&"_tag"in j&&j._tag===z}function f(j){let z=O(j),J=typeof j==="object"&&j!==null&&"name"in j&&typeof j.name==="string"?j.name:z?.errorName,K=typeof j==="object"&&j!==null&&"data"in j&&typeof j.data==="object"&&j.data!==null&&"message"in j.data&&typeof j.data.message==="string"?j.data.message:void 0;if(J==="UnknownError"||z){let v=z??Q(j,J??"UnknownError"),G=K&&!K.startsWith("{")?K:"QitQode could not explain this failure.",L=v?` [${v.errorName}, error id ${v.errorID}${v.logFile?`; log: ${v.logFile}`:""}]`:"";return G+L}if(A.hasName(j,"MCPFailed"))return`MCP server "${j.data?.name}" failed. Note, qitqode does not support MCP authentication yet.`;if(W(j,"AccountServiceError")||W(j,"AccountTransportError"))return j.message??"";if(A.hasName(j,"ProviderModelNotFoundError")){let v=j.data,G=Array.isArray(v?.suggestions)?v.suggestions:[];return[`Model not found: ${v?.providerID}/${v?.modelID}`,...G.length?["Did you mean: "+G.join(", ")]:[],"Try: `qitqode models` to list available models","Or check your config (qitqode.json) provider/model names"].join(`
3
3
  `)}if(A.hasName(j,"ProviderInitError"))return`Failed to initialize provider "${j.data?.providerID}". Check credentials and configuration.`;if(A.hasName(j,"ConfigJsonError")){let v=j.data;return`Config file at ${v?.path} is not valid JSON(C)`+(v?.message?`: ${v.message}`:"")}if(A.hasName(j,"ConfigDirectoryTypoError")){let v=j.data;return`Directory "${v?.dir}" in ${v?.path} is not valid. Rename the directory to "${v?.suggestion}" or remove it. This is a common typo.`}if(A.hasName(j,"ConfigFrontmatterError"))return j.data?.message??"";if(A.hasName(j,"ConfigInvalidError")){let v=j.data,G=v?.path,L=v?.message,Y=Array.isArray(v?.issues)?v.issues:[];return[`Configuration is invalid${G&&G!=="config"?` at ${G}`:""}`+(L?`: ${L}`:""),...Y.map((V)=>"\u21B3 "+V.message+" "+V.path.join("."))].join(`
4
4
  `)}if(A.hasName(j,"UICancelledError"))return"";let H=typeof j==="object"&&j!==null&&"name"in j?j.name:void 0;if(H==="QlexNotLoggedInError")return B.copy().notLoggedIn;if(H==="QlexInsufficientBalanceError")return(j.message??B.copy().insufficientBalanceFallback)+B.copy().insufficientBalanceCliSuffix;if(H==="QlexRateLimitError")return B.copy().rateLimit;if(H==="BackendInsufficientBalanceError")return(j.message??B.copy().insufficientBalanceFallback)+B.copy().insufficientBalanceCliSuffix;if(H==="BackendRateLimitError")return j.message??B.copy().rateLimit;if(H==="QlexInvalidCredentialsError")return j.message??B.copy().invalidCredentialsFallback}function q(j){let z=O(j)??Q(j);return`${X(j)}${z?` [${z.errorName}, error id ${z.errorID}; log: ${z.logFile}]`:""}`}function U({onlyFirst:j=!1}={}){return new RegExp("(?:\\u001B\\][\\s\\S]*?(?:\\u0007|\\u001B\\u005C|\\u009C))|[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]",j?void 0:"g")}var Z=U();function _(j){if(typeof j!=="string")throw TypeError(`Expected a \`string\`, got \`${typeof j}\``);return j.replace(Z,"")}
5
5
  export{_ as Uf,f as Vf,q as Wf};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{T as I}from"./chunk-gbkz04ke.js";import{U as i,W as r}from"./chunk-4064rbtp.js";import{Id as c}from"./chunk-0ffmwhw7.js";import{Jd as g}from"./chunk-eyr5ymt8.js";import{Kd as y}from"./chunk-y0h3jfkj.js";import{Ld as k}from"./chunk-1rgt2vmt.js";import{Md as A}from"./chunk-rk0fnvp5.js";import{$d as P,Rd as w,Sd as u,Ud as W,Vd as L,Wd as T,Yd as p,Zd as o,_d as b}from"./chunk-2kh0tg92.js";import"./chunk-52xvhxek.js";import{be as z}from"./chunk-f4mnp6xd.js";import{eg as Y}from"./chunk-bwadggys.js";import{Ch as M}from"./chunk-he9kpk9r.js";import"./chunk-vs3s49jw.js";import"./chunk-kre93a89.js";import"./chunk-060wbpz4.js";import"./chunk-zrhw1szj.js";import"./chunk-t8fjgkp8.js";import"./chunk-0egrckx0.js";import{Rk as a,el as s,yj as R}from"./chunk-qq9m8fxv.js";import{ql as V}from"./chunk-2qm46qvn.js";import{Ol as n}from"./chunk-tsmj98yf.js";import"./chunk-58f4y4b7.js";import"./chunk-rmsqb6r4.js";import"./chunk-qxdpgdfk.js";import"./chunk-6qwk6z87.js";import"./chunk-sa0rrreh.js";import"./chunk-ydgst3h8.js";import"./chunk-6tqbnxar.js";import"./chunk-0w19vmd7.js";import"./chunk-eewe7tx1.js";import"./chunk-37cbrnke.js";import"./chunk-wm9nh9nb.js";import"./chunk-scnbt714.js";import"./chunk-cqtkxwd8.js";import"./chunk-y3gy62q5.js";import"./chunk-az3nss5m.js";import"./chunk-p2fte9vz.js";import"./chunk-ggncq8w8.js";import"./chunk-t3w43rft.js";import"./chunk-eacpc64g.js";import"./chunk-27saej0r.js";import"./chunk-9009v4d0.js";import"./chunk-82xrfk5x.js";import"./chunk-wqk1v8t0.js";import"./chunk-vkjqy92f.js";import{Or as l}from"./chunk-z0kbyr00.js";import"./chunk-sbjymf20.js";import"./chunk-dt3bsmfe.js";import"./chunk-vbfej8ds.js";import"./chunk-0tm6589k.js";import"./chunk-6yhn9syz.js";import{ls as d}from"./chunk-wb05bp10.js";import"./chunk-wgkcyqn1.js";import"./chunk-59csnjc3.js";import{lt as v}from"./chunk-1bxfzd6r.js";import"./chunk-6p6m5956.js";import"./chunk-a48mx917.js";import"./chunk-3va85mbe.js";import"./chunk-w7a33cwa.js";import{fH as O}from"./chunk-g7v6sp3c.js";import"./chunk-s2tc3qs0.js";import"./chunk-n6tqtk6h.js";import{xO as H1}from"./chunk-e0vrxetq.js";import f from"path";import{pathToFileURL as J1}from"url";import Q1 from"os";import{access as S1,readdir as X1}from"fs/promises";var q1={en:A,zh:k,ja:c,fr:y,ru:g},B1=q1[I()]??A;function U($,B){let J=B1[$]??A[$]??$;if(!B)return J;return J.replace(/\{(\w+)\}/g,(X,H)=>(H in B)?String(B[H]):`{${H}}`)}import{text as Z1}from"stream/consumers";var D=($,B)=>M.runPromise(O.gen(function*(){yield*(yield*R.Service).set($,B)}));async function t(){let $=await p({message:"Enter your API key",validate:(B)=>B&&B.length>0?void 0:"Required"});if(w($))throw new Y.CancelledError;return $}async function h($,B){let J=$.provider??B;if("refresh"in $){let{type:X,provider:H,refresh:Z,access:j,expires:q,metadata:S,...G}=$;await D(J,{type:"oauth",refresh:Z,access:j,expires:q,...G})}if("key"in $)await D(J,{type:"api",key:$.key,...$.metadata?{metadata:$.metadata}:{}})}async function x($,B,J){let X=0;if(J){let j=$.auth.methods.findIndex((q)=>q.label.toLowerCase()===J.toLowerCase());if(j===-1)W.error(`Unknown method "${J}" for ${B}. Available: ${$.auth.methods.map((q)=>q.label).join(", ")}`),process.exit(1);X=j}else if($.auth.methods.length>1){let j=await b({message:"Login method",options:$.auth.methods.map((q,S)=>({label:q.label,value:S.toString()}))});if(w(j))throw new Y.CancelledError;X=parseInt(j)}let H=$.auth.methods[X];await new Promise((j)=>setTimeout(j,10));let Z={};if(H.prompts)for(let j of H.prompts){if(j.when){let q=Z[j.when.key];if(q===void 0)continue;if(!(j.when.op==="eq"?q===j.when.value:q!==j.when.value))continue}if(j.condition&&!j.condition(Z))continue;if(j.type==="select"){let q=await b({message:j.message,options:j.options});if(w(q))throw new Y.CancelledError;Z[j.key]=q}else{let q=await P({message:j.message,placeholder:j.placeholder,validate:j.validate?(S)=>j.validate(S??""):void 0});if(w(q))throw new Y.CancelledError;Z[j.key]=q}}if(H.type==="oauth"){let j=await H.authorize(Z);if(j.url)W.info("Go to: "+j.url);if(j.method==="auto"){if(j.instructions)W.info(j.instructions);let q=o();q.start("Waiting for authorization...");let S=await j.callback();if(S.type==="failed")q.stop("Failed to authorize",1);if(S.type==="success")await h(S,B),q.stop("Login successful")}if(j.method==="code"){let q=await P({message:"Paste the authorization code here: ",validate:(G)=>G&&G.length>0?void 0:"Required"});if(w(q))throw new Y.CancelledError;let S=await j.callback(q);if(S.type==="failed")W.error("Failed to authorize");if(S.type==="success")await h(S,B),W.success("Login successful")}return T("Done"),!0}if(H.type==="api"){if(H.authorize){let j=await t(),q=await H.authorize(Z);if(q.type==="failed")W.error("Failed to authorize");if(q.type==="success"){let S=q.provider??B;await D(S,{type:"api",key:q.key??j}),W.success("Login successful")}return T("Done"),!0}}return!1}function G1($){let B=new Set,J=[];for(let X of $.hooks){if(!X.auth)continue;let H=X.auth.provider;if(B.has(H))continue;if(B.add(H),Object.hasOwn($.existingProviders,H))continue;if($.disabled.has(H))continue;if($.enabled&&!$.enabled.has(H))continue;J.push({id:H,name:$.providerNames[H]??H})}return J}function m($){let B=$?.loginExtension;if(!B||typeof B!=="object")return;let J=B;if(typeof J.id!=="string"||typeof J.run!=="function")return;return J}async function W1(){try{let J=await import("./chunk-aenrd7dk.js");for(let X of Object.values(J.modules??{})){let H=m(X);if(H)return H}}catch{}let $=f.join(import.meta.dir,"..","..","ext");await S1($).catch(()=>{return});let B=await X1($).catch(()=>[]);for(let J of B.filter((X)=>X.endsWith(".ts")&&!X.endsWith(".d.ts")))try{let X=m(await import(J1(f.join($,J)).href));if(X)return X}catch{}return}var l1=z({command:"providers",aliases:["auth"],describe:"manage AI providers and credentials",builder:($)=>$.command(Y1).command(_1).command(F1).command(K1).demandCommand(),async handler(){}}),Y1=z({command:"list",aliases:["ls"],describe:"list providers and credentials",async handler($){Y.empty();let B=f.join(v.Path.data,"auth.json"),J=Q1.homedir(),X=B===J||B.startsWith(J+f.sep)?"~"+B.slice(J.length):B;L(`Credentials ${Y.Style.TEXT_DIM}${X}`);let H=await M.runPromise(O.gen(function*(){let q=yield*R.Service;return Object.entries(yield*q.all())})),Z=await V.get();for(let[q,S]of H){let G=Z[q]?.name||q;W.info(`${G} ${Y.Style.TEXT_DIM}${S.type}`)}T(`${H.length} credentials`);let j=[];for(let[q,S]of Object.entries(Z))for(let G of S.env)if(process.env[G])j.push({provider:S.name||q,envVar:G});if(j.length>0){Y.empty(),L("Environment");for(let{provider:q,envVar:S}of j)W.info(`${q} ${Y.Style.TEXT_DIM}${S}`);T(`${j.length} environment variable`+(j.length===1?"":"s"))}}}),_1=z({command:"login [url]",describe:"log in to a provider",builder:($)=>$.positional("url",{describe:"qitqode auth provider",type:"string"}).option("provider",{alias:["p"],describe:"provider id or name to log in to (skips provider selection)",type:"string"}).option("method",{alias:["m"],describe:"login method label (skips method selection)",type:"string"}),async handler($){await n.provide({directory:process.cwd(),async fn(){if(Y.empty(),L("Add credential"),$.url){let Q=$.url.replace(/\/+$/,""),_=await fetch(`${Q}/.well-known/opencode`).then((j1)=>j1.json());W.info(`Running \`${_.auth.command.join(" ")}\``);let F=l.spawn(_.auth.command,{stdout:"pipe"});if(!F.stdout){W.error("Failed"),T("Done");return}let[C,N]=await Promise.all([F.exited,Z1(F.stdout)]);if(C!==0){W.error("Failed"),T("Done");return}await D(Q,{type:"wellknown",key:_.auth.env,token:N.trim()}),W.success("Logged into "+Q),T("Done");return}await V.refresh(!0).catch(()=>{});let B=await M.runPromise(s.Service.use((Q)=>Q.get())),J=new Set(B.disabled_providers??[]),X=B.enabled_providers?new Set(B.enabled_providers):void 0,H=await V.get().then((Q)=>{let _={};for(let[F,C]of Object.entries(Q))if((X?X.has(F):!0)&&!J.has(F))_[F]=C;return _}),Z=await M.runPromise(O.gen(function*(){return yield*(yield*a.Service).list()})),j=i,q=G1({hooks:Z,existingProviders:H,disabled:J,enabled:X,providerNames:Object.fromEntries(Object.entries(B.provider??{}).map(([Q,_])=>[Q,_.name]))}),S=[...r(d(H),j,(Q)=>({openai:"ChatGPT Plus/Pro or API key"})[Q.id]),...q.map((Q)=>({label:Q.name,value:Q.id,hint:"plugin"}))],G=await W1(),e=G?[G.id,...G.aliases??[]]:[],K;if(G&&$.provider&&e.includes($.provider)){await G.run();return}else if($.provider){let Q=$.provider,_=S.find((N)=>N.value===Q),F=S.find((N)=>N.label.toLowerCase()===Q.toLowerCase()),C=_??F;if(!C)W.error(`Unknown provider "${Q}"`),process.exit(1);K=C.value}else{let Q=await b({message:U("cli.providers.select"),options:[...G?.menu?[{label:G.menu.label,value:G.id,hint:G.menu.hint}]:[],{label:U("cli.providers.other"),value:"__other__"}]});if(w(Q))throw new Y.CancelledError;if(G&&Q===G.id){await G.run();return}let _=await u({message:U("cli.providers.select"),maxItems:8,options:[...S,{value:"other",label:"Other"}]});if(w(_))throw new Y.CancelledError;K=_}let E=Z.findLast((Q)=>Q.auth?.provider===K);if(E&&E.auth){if(await x({auth:E.auth},K,$.method))return}if(K==="other"){let Q=await P({message:"Enter provider id",validate:(F)=>F&&F.match(/^[0-9a-z-]+$/)?void 0:"a-z, 0-9 and hyphens only"});if(w(Q))throw new Y.CancelledError;K=Q.replace(/^@ai-sdk\//,"");let _=Z.findLast((F)=>F.auth?.provider===K);if(_&&_.auth){if(await x({auth:_.auth},K,$.method))return}W.warn(`This only stores a credential for ${K} - you will need configure it in qitqode.json, check the docs for examples.`)}if(K==="amazon-bedrock")W.info(`Amazon Bedrock authentication priority:
2
+ import{T as I}from"./chunk-gbkz04ke.js";import{U as i,W as r}from"./chunk-c987bemn.js";import{Id as c}from"./chunk-0ffmwhw7.js";import{Jd as g}from"./chunk-eyr5ymt8.js";import{Kd as y}from"./chunk-y0h3jfkj.js";import{Ld as k}from"./chunk-1rgt2vmt.js";import{Md as A}from"./chunk-rk0fnvp5.js";import{$d as P,Rd as w,Sd as u,Ud as W,Vd as L,Wd as T,Yd as p,Zd as o,_d as b}from"./chunk-2kh0tg92.js";import"./chunk-52xvhxek.js";import{be as z}from"./chunk-f4mnp6xd.js";import{eg as Y}from"./chunk-bwadggys.js";import{Ch as M}from"./chunk-1acn5me8.js";import"./chunk-vs3s49jw.js";import"./chunk-kre93a89.js";import"./chunk-060wbpz4.js";import"./chunk-zrhw1szj.js";import"./chunk-t8fjgkp8.js";import"./chunk-0egrckx0.js";import{Rk as a,el as s,yj as R}from"./chunk-k1qd8ecm.js";import{ql as V}from"./chunk-bhg69t69.js";import{Ol as n}from"./chunk-fv5mrdyc.js";import"./chunk-rdreeyv0.js";import"./chunk-rmsqb6r4.js";import"./chunk-7pckez5z.js";import"./chunk-k6981ysw.js";import"./chunk-sa0rrreh.js";import"./chunk-ydgst3h8.js";import"./chunk-6tqbnxar.js";import"./chunk-0w19vmd7.js";import"./chunk-eewe7tx1.js";import"./chunk-4y9wbfd2.js";import"./chunk-wm9nh9nb.js";import"./chunk-scnbt714.js";import"./chunk-cqtkxwd8.js";import"./chunk-y3gy62q5.js";import"./chunk-az3nss5m.js";import"./chunk-p2fte9vz.js";import"./chunk-ggncq8w8.js";import"./chunk-t3w43rft.js";import"./chunk-eacpc64g.js";import"./chunk-27saej0r.js";import"./chunk-b5ym419d.js";import"./chunk-29q89bge.js";import"./chunk-wqk1v8t0.js";import"./chunk-rwwvy89t.js";import{Or as l}from"./chunk-z0kbyr00.js";import"./chunk-sbjymf20.js";import"./chunk-dt3bsmfe.js";import"./chunk-vbfej8ds.js";import"./chunk-0tm6589k.js";import"./chunk-fveaq0pb.js";import{ls as d}from"./chunk-gswhjd1h.js";import"./chunk-wgkcyqn1.js";import"./chunk-59csnjc3.js";import{lt as v}from"./chunk-1bxfzd6r.js";import"./chunk-6p6m5956.js";import"./chunk-a48mx917.js";import"./chunk-3va85mbe.js";import"./chunk-w7a33cwa.js";import{fH as O}from"./chunk-g7v6sp3c.js";import"./chunk-s2tc3qs0.js";import"./chunk-n6tqtk6h.js";import{xO as H1}from"./chunk-e0vrxetq.js";import f from"path";import{pathToFileURL as J1}from"url";import Q1 from"os";import{access as S1,readdir as X1}from"fs/promises";var q1={en:A,zh:k,ja:c,fr:y,ru:g},B1=q1[I()]??A;function U($,B){let J=B1[$]??A[$]??$;if(!B)return J;return J.replace(/\{(\w+)\}/g,(X,H)=>(H in B)?String(B[H]):`{${H}}`)}import{text as Z1}from"stream/consumers";var D=($,B)=>M.runPromise(O.gen(function*(){yield*(yield*R.Service).set($,B)}));async function t(){let $=await p({message:"Enter your API key",validate:(B)=>B&&B.length>0?void 0:"Required"});if(w($))throw new Y.CancelledError;return $}async function h($,B){let J=$.provider??B;if("refresh"in $){let{type:X,provider:H,refresh:Z,access:j,expires:q,metadata:S,...G}=$;await D(J,{type:"oauth",refresh:Z,access:j,expires:q,...G})}if("key"in $)await D(J,{type:"api",key:$.key,...$.metadata?{metadata:$.metadata}:{}})}async function x($,B,J){let X=0;if(J){let j=$.auth.methods.findIndex((q)=>q.label.toLowerCase()===J.toLowerCase());if(j===-1)W.error(`Unknown method "${J}" for ${B}. Available: ${$.auth.methods.map((q)=>q.label).join(", ")}`),process.exit(1);X=j}else if($.auth.methods.length>1){let j=await b({message:"Login method",options:$.auth.methods.map((q,S)=>({label:q.label,value:S.toString()}))});if(w(j))throw new Y.CancelledError;X=parseInt(j)}let H=$.auth.methods[X];await new Promise((j)=>setTimeout(j,10));let Z={};if(H.prompts)for(let j of H.prompts){if(j.when){let q=Z[j.when.key];if(q===void 0)continue;if(!(j.when.op==="eq"?q===j.when.value:q!==j.when.value))continue}if(j.condition&&!j.condition(Z))continue;if(j.type==="select"){let q=await b({message:j.message,options:j.options});if(w(q))throw new Y.CancelledError;Z[j.key]=q}else{let q=await P({message:j.message,placeholder:j.placeholder,validate:j.validate?(S)=>j.validate(S??""):void 0});if(w(q))throw new Y.CancelledError;Z[j.key]=q}}if(H.type==="oauth"){let j=await H.authorize(Z);if(j.url)W.info("Go to: "+j.url);if(j.method==="auto"){if(j.instructions)W.info(j.instructions);let q=o();q.start("Waiting for authorization...");let S=await j.callback();if(S.type==="failed")q.stop("Failed to authorize",1);if(S.type==="success")await h(S,B),q.stop("Login successful")}if(j.method==="code"){let q=await P({message:"Paste the authorization code here: ",validate:(G)=>G&&G.length>0?void 0:"Required"});if(w(q))throw new Y.CancelledError;let S=await j.callback(q);if(S.type==="failed")W.error("Failed to authorize");if(S.type==="success")await h(S,B),W.success("Login successful")}return T("Done"),!0}if(H.type==="api"){if(H.authorize){let j=await t(),q=await H.authorize(Z);if(q.type==="failed")W.error("Failed to authorize");if(q.type==="success"){let S=q.provider??B;await D(S,{type:"api",key:q.key??j}),W.success("Login successful")}return T("Done"),!0}}return!1}function G1($){let B=new Set,J=[];for(let X of $.hooks){if(!X.auth)continue;let H=X.auth.provider;if(B.has(H))continue;if(B.add(H),Object.hasOwn($.existingProviders,H))continue;if($.disabled.has(H))continue;if($.enabled&&!$.enabled.has(H))continue;J.push({id:H,name:$.providerNames[H]??H})}return J}function m($){let B=$?.loginExtension;if(!B||typeof B!=="object")return;let J=B;if(typeof J.id!=="string"||typeof J.run!=="function")return;return J}async function W1(){try{let J=await import("./chunk-aenrd7dk.js");for(let X of Object.values(J.modules??{})){let H=m(X);if(H)return H}}catch{}let $=f.join(import.meta.dir,"..","..","ext");await S1($).catch(()=>{return});let B=await X1($).catch(()=>[]);for(let J of B.filter((X)=>X.endsWith(".ts")&&!X.endsWith(".d.ts")))try{let X=m(await import(J1(f.join($,J)).href));if(X)return X}catch{}return}var l1=z({command:"providers",aliases:["auth"],describe:"manage AI providers and credentials",builder:($)=>$.command(Y1).command(_1).command(F1).command(K1).demandCommand(),async handler(){}}),Y1=z({command:"list",aliases:["ls"],describe:"list providers and credentials",async handler($){Y.empty();let B=f.join(v.Path.data,"auth.json"),J=Q1.homedir(),X=B===J||B.startsWith(J+f.sep)?"~"+B.slice(J.length):B;L(`Credentials ${Y.Style.TEXT_DIM}${X}`);let H=await M.runPromise(O.gen(function*(){let q=yield*R.Service;return Object.entries(yield*q.all())})),Z=await V.get();for(let[q,S]of H){let G=Z[q]?.name||q;W.info(`${G} ${Y.Style.TEXT_DIM}${S.type}`)}T(`${H.length} credentials`);let j=[];for(let[q,S]of Object.entries(Z))for(let G of S.env)if(process.env[G])j.push({provider:S.name||q,envVar:G});if(j.length>0){Y.empty(),L("Environment");for(let{provider:q,envVar:S}of j)W.info(`${q} ${Y.Style.TEXT_DIM}${S}`);T(`${j.length} environment variable`+(j.length===1?"":"s"))}}}),_1=z({command:"login [url]",describe:"log in to a provider",builder:($)=>$.positional("url",{describe:"qitqode auth provider",type:"string"}).option("provider",{alias:["p"],describe:"provider id or name to log in to (skips provider selection)",type:"string"}).option("method",{alias:["m"],describe:"login method label (skips method selection)",type:"string"}),async handler($){await n.provide({directory:process.cwd(),async fn(){if(Y.empty(),L("Add credential"),$.url){let Q=$.url.replace(/\/+$/,""),_=await fetch(`${Q}/.well-known/opencode`).then((j1)=>j1.json());W.info(`Running \`${_.auth.command.join(" ")}\``);let F=l.spawn(_.auth.command,{stdout:"pipe"});if(!F.stdout){W.error("Failed"),T("Done");return}let[C,N]=await Promise.all([F.exited,Z1(F.stdout)]);if(C!==0){W.error("Failed"),T("Done");return}await D(Q,{type:"wellknown",key:_.auth.env,token:N.trim()}),W.success("Logged into "+Q),T("Done");return}await V.refresh(!0).catch(()=>{});let B=await M.runPromise(s.Service.use((Q)=>Q.get())),J=new Set(B.disabled_providers??[]),X=B.enabled_providers?new Set(B.enabled_providers):void 0,H=await V.get().then((Q)=>{let _={};for(let[F,C]of Object.entries(Q))if((X?X.has(F):!0)&&!J.has(F))_[F]=C;return _}),Z=await M.runPromise(O.gen(function*(){return yield*(yield*a.Service).list()})),j=i,q=G1({hooks:Z,existingProviders:H,disabled:J,enabled:X,providerNames:Object.fromEntries(Object.entries(B.provider??{}).map(([Q,_])=>[Q,_.name]))}),S=[...r(d(H),j,(Q)=>({openai:"ChatGPT Plus/Pro or API key"})[Q.id]),...q.map((Q)=>({label:Q.name,value:Q.id,hint:"plugin"}))],G=await W1(),e=G?[G.id,...G.aliases??[]]:[],K;if(G&&$.provider&&e.includes($.provider)){await G.run();return}else if($.provider){let Q=$.provider,_=S.find((N)=>N.value===Q),F=S.find((N)=>N.label.toLowerCase()===Q.toLowerCase()),C=_??F;if(!C)W.error(`Unknown provider "${Q}"`),process.exit(1);K=C.value}else{let Q=await b({message:U("cli.providers.select"),options:[...G?.menu?[{label:G.menu.label,value:G.id,hint:G.menu.hint}]:[],{label:U("cli.providers.other"),value:"__other__"}]});if(w(Q))throw new Y.CancelledError;if(G&&Q===G.id){await G.run();return}let _=await u({message:U("cli.providers.select"),maxItems:8,options:[...S,{value:"other",label:"Other"}]});if(w(_))throw new Y.CancelledError;K=_}let E=Z.findLast((Q)=>Q.auth?.provider===K);if(E&&E.auth){if(await x({auth:E.auth},K,$.method))return}if(K==="other"){let Q=await P({message:"Enter provider id",validate:(F)=>F&&F.match(/^[0-9a-z-]+$/)?void 0:"a-z, 0-9 and hyphens only"});if(w(Q))throw new Y.CancelledError;K=Q.replace(/^@ai-sdk\//,"");let _=Z.findLast((F)=>F.auth?.provider===K);if(_&&_.auth){if(await x({auth:_.auth},K,$.method))return}W.warn(`This only stores a credential for ${K} - you will need configure it in qitqode.json, check the docs for examples.`)}if(K==="amazon-bedrock")W.info(`Amazon Bedrock authentication priority:
3
3
  1. Bearer token (AWS_BEARER_TOKEN_BEDROCK or /connect)
4
4
  2. AWS credential chain (profile, access keys, IAM roles, EKS IRSA)
5
5
 
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Dh as XC}from"./chunk-vs3s49jw.js";import{vi as _G}from"./chunk-t8fjgkp8.js";import{$j as F8,$k as jV,Ak as x9,Bk as NP,Cj as BY,Ck as V$,Dk as QF,Ej as yB,Ek as XF,Fj as Ag,Fk as VF,Gj as a_,Hj as L9,Hk as vL,Ij as Y4,Lj as L2,Lk as bU,Mj as YZ,Mk as KF,Nj as v0,Nk as RC,Oj as B$,Ok as OV,Pj as d0,Pk as G$,Qk as qY,Rj as EV,Rk as s0,Sj as R$,Sk as G2,Tj as JJ,Uk as o0,Vk as MA,Wj as iY,Wk as X0,Xj as nY,Xk as Dw,Yj as T8,Zj as Lj,Zk as A$,_j as j1,_k as mB,ak as h1,al as JG,bk as MP,bl as f$,ck as pX,cl as D1,dk as oX,dl as k0,ek as CP,el as H0,fk as SQ,gk as TQ,hk as _U,ik as Bd,jk as Hd,kk as mQ,lk as n1,mk as VJ,nk as HW,ok as S7,pk as dQ,qk as lU,rk as rU,sk as aU,tk as tU,uk as eU,vk as QO,wk as yj,xj as e,xk as wP,yj as E1,yk as M0,zk as hD}from"./chunk-qq9m8fxv.js";import{fl as RQ,gl as PA}from"./chunk-2qm46qvn.js";import{Bl as s9,El as C0,Fl as q1,Gl as gJ,Hl as x6,Il as S8,Ll as MN,Ml as j6,Ol as q0,Pl as c,Ql as ZA,Rl as T$,Sl as mD,rl as S3,sl as _O,tl as HP,ul as cN,vl as J4,wl as W$,xl as v$,yl as i1,zl as y9}from"./chunk-tsmj98yf.js";import{Tl as uY,Ul as o8,Vl as p2,Wl as p1,Zl as NN,_l as y0}from"./chunk-58f4y4b7.js";import{Bm as D0,Dm as a$,Em as y7,Gm as AQ,Jm as yC,Km as IC,Mm as XJ,Zm as H8,_m as x8,bm as hU,om as n8,vm as F2,wm as i0,xm as I2,ym as B8,zm as gU}from"./chunk-rmsqb6r4.js";import{rn as $J}from"./chunk-6qwk6z87.js";import{Ln as B7,Mn as Rj,Nn as H7,Pn as W8}from"./chunk-ydgst3h8.js";import{Qn as V9}from"./chunk-6tqbnxar.js";import{Rn as O$}from"./chunk-0w19vmd7.js";import{Ho as V0}from"./chunk-37cbrnke.js";import{kp as g8,lp as bC,wp as b9,xp as AM}from"./chunk-wm9nh9nb.js";import{Zp as HC,_p as $C}from"./chunk-scnbt714.js";import{rq as s7}from"./chunk-eacpc64g.js";import{Bq as DA,Cq as F7,wq as A1}from"./chunk-9009v4d0.js";import{Eq as S1,Fq as I3,Iq as R3}from"./chunk-82xrfk5x.js";import{$q as l1,Uq as A2,Vq as IX,ar as I8}from"./chunk-wqk1v8t0.js";import{Ar as HQ,Br as ZV,Gr as HA,Jr as V2}from"./chunk-vkjqy92f.js";import{Kr as q7,Or as z7}from"./chunk-z0kbyr00.js";import{Pr as sm}from"./chunk-sbjymf20.js";import{bs as q$}from"./chunk-0tm6589k.js";import{ds as G9}from"./chunk-6yhn9syz.js";import{Es as h4,es as x1,hs as xX,is as lX,ls as kD,ms as bD,os as P6,zs as PP}from"./chunk-wb05bp10.js";import{Fs as XQ,Is as Q6}from"./chunk-wgkcyqn1.js";import{Os as c0,Xs as J0}from"./chunk-59csnjc3.js";import{_s as j7,bt as c8,ct as K0,gt as D$,kt as SJ,lt as e0}from"./chunk-1bxfzd6r.js";import{mt as _}from"./chunk-6p6m5956.js";import{At as wG,Bt as NG,Ct as u$,Dt as g1,Et as A0,Ft as H2,Gt as eP,Ht as AG,It as fM,Jt as mM,Kt as H$,nt as tP,pt as m,qt as gM,rt as z$,st as L$,tt as CG,ut as vM,vt as B2,wt as B0,xt as j0,yt as _2,zt as E$}from"./chunk-a48mx917.js";import{Lt as hM,fu as ZB}from"./chunk-3va85mbe.js";import{$y as zG,Qy as y3}from"./chunk-w7a33cwa.js";import{$B as qP,AB as Q0,AJ as nO,BC as K8,BJ as hP,CG as $4,DJ as R6,EE as k,FJ as DQ,GF as PN,GG as Z4,GJ as gP,HI as d8,JI as D7,LE as BP,MD as x0,QJ as V7,RJ as bB,TD as O2,TJ as vP,UJ as IZ,UN as I0,YJ as f0,ZE as k9,_D as p0,dF as zN,fH as V,iK as yX,jB as cX,kF as _N,mB as S$,nI as y8,oE as N$,pF as DN,wJ as zP,xJ as _P,yJ as DP,zJ as I6}from"./chunk-g7v6sp3c.js";import{nO as iK}from"./chunk-s2tc3qs0.js";import{tO as J9,uO as U0,vO as R0,xO as o$,yO as Q7,zO as X7}from"./chunk-e0vrxetq.js";var t4=U0((al,pY)=>{function c4($){return Array.isArray($)?$:[$]}var OL=void 0,VK="",d4=" ",XK="\\",UL=/^\s+$/,FL=/(?:[^\\]|^)\\$/,qL=/^\\!/,zL=/^\\#/,_L=/\r?\n/g,DL=/^\.{0,2}\/|^\.{1,2}$/,PL=/\/$/,J7="/",l4="node-ignore";if(typeof Symbol<"u")l4=Symbol.for("node-ignore");var p4=l4,Y7=($,Z,J)=>{return Object.defineProperty($,Z,{value:J}),J},ML=/([0-z])-([0-z])/g,o4=()=>!1,CL=($)=>$.replace(ML,(Z,J,Y)=>J.charCodeAt(0)<=Y.charCodeAt(0)?Z:VK),wL=($)=>{let{length:Z}=$;return $.slice(0,Z-Z%2)},NL=[[/^\uFEFF/,()=>VK],[/((?:\\\\)*?)(\\?\s+)$/,($,Z,J)=>Z+(J.indexOf("\\")===0?d4:VK)],[/(\\+?)\s/g,($,Z)=>{let{length:J}=Z;return Z.slice(0,J-J%2)+d4}],[/[\\$.|*+(){^]/g,($)=>`\\${$}`],[/(?!\\)\?/g,()=>"[^/]"],[/^\//,()=>"^"],[/\//g,()=>"\\/"],[/^\^*\\\*\\\*\\\//,()=>"^(?:.*\\/)?"],[/^(?=[^^])/,function(){return!/\/(?!$)/.test(this)?"(?:^|\\/)":"^"}],[/\\\/\\\*\\\*(?=\\\/|$)/g,($,Z,J)=>Z+6<J.length?"(?:\\/[^\\/]+)*":"\\/.+"],[/(^|[^\\]+)(\\\*)+(?=.+)/g,($,Z,J)=>{let Y=J.replace(/\\\*/g,"[^\\/]*");return Z+Y}],[/\\\\\\(?=[$.|*+(){^])/g,()=>XK],[/\\\\/g,()=>XK],[/(\\)?\[([^\]/]*?)(\\*)($|\])/g,($,Z,J,Y,Q)=>Z===XK?`\\[${J}${wL(Y)}${Q}`:Q==="]"?Y.length%2===0?`[${CL(J)}${Y}]`:"[]":"[]"],[/(?:[^*])$/,($)=>/\/$/.test($)?`${$}$`:`${$}(?=$|\\/$)`]],AL=/(^|\\\/)?\\\*$/,dZ="regex",cY="checkRegex",u4="_",LL={[dZ]($,Z){return`${Z?`${Z}[^/]+`:"[^/]*"}(?=$|\\/$)`},[cY]($,Z){return`${Z?`${Z}[^/]*`:"[^/]*"}(?=$|\\/$)`}},yL=($)=>NL.reduce((Z,[J,Y])=>Z.replace(J,Y.bind($)),$),lY=($)=>typeof $==="string",IL=($)=>$&&lY($)&&!UL.test($)&&!FL.test($)&&$.indexOf("#")!==0,RL=($)=>$.split(_L).filter(Boolean);class i4{constructor($,Z,J,Y,Q,X){this.pattern=$,this.mark=Z,this.negative=Q,Y7(this,"body",J),Y7(this,"ignoreCase",Y),Y7(this,"regexPrefix",X)}get regex(){let $=u4+dZ;if(this[$])return this[$];return this._make(dZ,$)}get checkRegex(){let $=u4+cY;if(this[$])return this[$];return this._make(cY,$)}_make($,Z){let J=this.regexPrefix.replace(AL,LL[$]),Y=this.ignoreCase?new RegExp(J,"i"):new RegExp(J);return Y7(this,Z,Y)}}var SL=({pattern:$,mark:Z},J)=>{let Y=!1,Q=$;if(Q.indexOf("!")===0)Y=!0,Q=Q.substr(1);Q=Q.replace(qL,"!").replace(zL,"#");let X=yL(Q);return new i4($,Z,Q,J,Y,X)};class n4{constructor($){this._ignoreCase=$,this._rules=[]}_add($){if($&&$[p4]){this._rules=this._rules.concat($._rules._rules),this._added=!0;return}if(lY($))$={pattern:$};if(IL($.pattern)){let Z=SL($,this._ignoreCase);this._added=!0,this._rules.push(Z)}}add($){return this._added=!1,c4(lY($)?RL($):$).forEach(this._add,this),this._added}test($,Z,J){let Y=!1,Q=!1,X;this._rules.forEach((W)=>{let{negative:G}=W;if(Q===G&&Y!==Q||G&&!Y&&!Q&&!Z)return;if(!W[J].test($))return;Y=!G,Q=G,X=G?OL:W});let K={ignored:Y,unignored:Q};if(X)K.rule=X;return K}}var TL=($,Z)=>{throw new Z($)},u8=($,Z,J)=>{if(!lY($))return J(`path must be a string, but got \`${Z}\``,TypeError);if(!$)return J("path must not be empty",TypeError);if(u8.isNotRelative($))return J(`path should be a \`path.relative()\`d string, but got "${Z}"`,RangeError);return!0},s4=($)=>DL.test($);u8.isNotRelative=s4;u8.convert=($)=>$;class r4{constructor({ignorecase:$=!0,ignoreCase:Z=$,allowRelativePaths:J=!1}={}){Y7(this,p4,!0),this._rules=new n4(Z),this._strictPathCheck=!J,this._initCache()}_initCache(){this._ignoreCache=Object.create(null),this._testCache=Object.create(null)}add($){if(this._rules.add($))this._initCache();return this}addPattern($){return this.add($)}_test($,Z,J,Y){let Q=$&&u8.convert($);return u8(Q,$,this._strictPathCheck?TL:o4),this._t(Q,Z,J,Y)}checkIgnore($){if(!PL.test($))return this.test($);let Z=$.split(J7).filter(Boolean);if(Z.pop(),Z.length){let J=this._t(Z.join(J7)+J7,this._testCache,!0,Z);if(J.ignored)return J}return this._rules.test($,!1,cY)}_t($,Z,J,Y){if($ in Z)return Z[$];if(!Y)Y=$.split(J7).filter(Boolean);if(Y.pop(),!Y.length)return Z[$]=this._rules.test($,J,dZ);let Q=this._t(Y.join(J7)+J7,Z,J,Y);return Z[$]=Q.ignored?Q:this._rules.test($,J,dZ)}ignores($){return this._test($,this._ignoreCache,!1).ignored}createFilter(){return($)=>!this.ignores($)}filter($){return c4($).filter(this.createFilter())}test($){return this._test($,this._testCache,!0)}}var KK=($)=>new r4($),xL=($)=>u8($&&u8.convert($),$,o4),a4=()=>{let $=(J)=>/^\\\\\?\\/.test(J)||/["<>|\u0000-\u001F]+/u.test(J)?J:J.replace(/\\/g,"/");u8.convert=$;let Z=/^[a-z]:\//i;u8.isNotRelative=(J)=>Z.test(J)||s4(J)};if(typeof process<"u"&&process.platform==="win32")a4();pY.exports=KK;KK.default=KK;pY.exports.isPathValid=xL;Y7(pY.exports,Symbol.for("setupWindows"),a4)});var sY=U0((Yy)=>{Yy.isInteger=($)=>{if(typeof $==="number")return Number.isInteger($);if(typeof $==="string"&&$.trim()!=="")return Number.isInteger(Number($));return!1};Yy.find=($,Z)=>$.nodes.find((J)=>J.type===Z);Yy.exceedsLimit=($,Z,J=1,Y)=>{if(Y===!1)return!1;if(!Yy.isInteger($)||!Yy.isInteger(Z))return!1;return(Number(Z)-Number($))/Number(J)>=Y};Yy.escapeNode=($,Z=0,J)=>{let Y=$.nodes[Z];if(!Y)return;if(J&&Y.type===J||Y.type==="open"||Y.type==="close"){if(Y.escaped!==!0)Y.value="\\"+Y.value,Y.escaped=!0}};Yy.encloseBrace=($)=>{if($.type!=="brace")return!1;if($.commas>>0+$.ranges>>0===0)return $.invalid=!0,!0;return!1};Yy.isInvalidBrace=($)=>{if($.type!=="brace")return!1;if($.invalid===!0||$.dollar)return!0;if($.commas>>0+$.ranges>>0===0)return $.invalid=!0,!0;if($.open!==!0||$.close!==!0)return $.invalid=!0,!0;return!1};Yy.isOpenOrClose=($)=>{if($.type==="open"||$.type==="close")return!0;return $.open===!0||$.close===!0};Yy.reduce=($)=>$.reduce((Z,J)=>{if(J.type==="text")Z.push(J.value);if(J.type==="range")J.type="text";return Z},[]);Yy.flatten=(...$)=>{let Z=[],J=(Y)=>{for(let Q=0;Q<Y.length;Q++){let X=Y[Q];if(Array.isArray(X)){J(X);continue}if(X!==void 0)Z.push(X)}return Z};return J($),Z}});var rY=U0((Fp,WH)=>{var KH=sY();WH.exports=($,Z={})=>{let J=(Y,Q={})=>{let X=Z.escapeInvalid&&KH.isInvalidBrace(Q),K=Y.invalid===!0&&Z.escapeInvalid===!0,W="";if(Y.value){if((X||K)&&KH.isOpenOrClose(Y))return"\\"+Y.value;return Y.value}if(Y.value)return Y.value;if(Y.nodes)for(let G of Y.nodes)W+=J(G);return W};return J($)}});var BH=U0((qp,GH)=>{/*!
2
+ import{Dh as XC}from"./chunk-vs3s49jw.js";import{vi as _G}from"./chunk-t8fjgkp8.js";import{$j as F8,$k as jV,Ak as x9,Bk as NP,Cj as BY,Ck as V$,Dk as QF,Ej as yB,Ek as XF,Fj as Ag,Fk as VF,Gj as a_,Hj as L9,Hk as vL,Ij as Y4,Lj as L2,Lk as bU,Mj as YZ,Mk as KF,Nj as v0,Nk as RC,Oj as B$,Ok as OV,Pj as d0,Pk as G$,Qk as qY,Rj as EV,Rk as s0,Sj as R$,Sk as G2,Tj as JJ,Uk as o0,Vk as MA,Wj as iY,Wk as X0,Xj as nY,Xk as Dw,Yj as T8,Zj as Lj,Zk as A$,_j as j1,_k as mB,ak as h1,al as JG,bk as MP,bl as f$,ck as pX,cl as D1,dk as oX,dl as k0,ek as CP,el as H0,fk as SQ,gk as TQ,hk as _U,ik as Bd,jk as Hd,kk as mQ,lk as n1,mk as VJ,nk as HW,ok as S7,pk as dQ,qk as lU,rk as rU,sk as aU,tk as tU,uk as eU,vk as QO,wk as yj,xj as e,xk as wP,yj as E1,yk as M0,zk as hD}from"./chunk-k1qd8ecm.js";import{fl as RQ,gl as PA}from"./chunk-bhg69t69.js";import{Bl as s9,El as C0,Fl as q1,Gl as gJ,Hl as x6,Il as S8,Ll as MN,Ml as j6,Ol as q0,Pl as c,Ql as ZA,Rl as T$,Sl as mD,rl as S3,sl as _O,tl as HP,ul as cN,vl as J4,wl as W$,xl as v$,yl as i1,zl as y9}from"./chunk-fv5mrdyc.js";import{Tl as uY,Ul as o8,Vl as p2,Wl as p1,Zl as NN,_l as y0}from"./chunk-rdreeyv0.js";import{Bm as D0,Dm as a$,Em as y7,Gm as AQ,Jm as yC,Km as IC,Mm as XJ,Zm as H8,_m as x8,bm as hU,om as n8,vm as F2,wm as i0,xm as I2,ym as B8,zm as gU}from"./chunk-rmsqb6r4.js";import{rn as $J}from"./chunk-k6981ysw.js";import{Ln as B7,Mn as Rj,Nn as H7,Pn as W8}from"./chunk-ydgst3h8.js";import{Qn as V9}from"./chunk-6tqbnxar.js";import{Rn as O$}from"./chunk-0w19vmd7.js";import{Ho as V0}from"./chunk-4y9wbfd2.js";import{kp as g8,lp as bC,wp as b9,xp as AM}from"./chunk-wm9nh9nb.js";import{Zp as HC,_p as $C}from"./chunk-scnbt714.js";import{rq as s7}from"./chunk-eacpc64g.js";import{Bq as DA,Cq as F7,wq as A1}from"./chunk-b5ym419d.js";import{Eq as S1,Fq as I3,Iq as R3}from"./chunk-29q89bge.js";import{$q as l1,Uq as A2,Vq as IX,ar as I8}from"./chunk-wqk1v8t0.js";import{Ar as HQ,Br as ZV,Gr as HA,Jr as V2}from"./chunk-rwwvy89t.js";import{Kr as q7,Or as z7}from"./chunk-z0kbyr00.js";import{Pr as sm}from"./chunk-sbjymf20.js";import{bs as q$}from"./chunk-0tm6589k.js";import{ds as G9}from"./chunk-fveaq0pb.js";import{Es as h4,es as x1,hs as xX,is as lX,ls as kD,ms as bD,os as P6,zs as PP}from"./chunk-gswhjd1h.js";import{Fs as XQ,Is as Q6}from"./chunk-wgkcyqn1.js";import{Os as c0,Xs as J0}from"./chunk-59csnjc3.js";import{_s as j7,bt as c8,ct as K0,gt as D$,kt as SJ,lt as e0}from"./chunk-1bxfzd6r.js";import{mt as _}from"./chunk-6p6m5956.js";import{At as wG,Bt as NG,Ct as u$,Dt as g1,Et as A0,Ft as H2,Gt as eP,Ht as AG,It as fM,Jt as mM,Kt as H$,nt as tP,pt as m,qt as gM,rt as z$,st as L$,tt as CG,ut as vM,vt as B2,wt as B0,xt as j0,yt as _2,zt as E$}from"./chunk-a48mx917.js";import{Lt as hM,fu as ZB}from"./chunk-3va85mbe.js";import{$y as zG,Qy as y3}from"./chunk-w7a33cwa.js";import{$B as qP,AB as Q0,AJ as nO,BC as K8,BJ as hP,CG as $4,DJ as R6,EE as k,FJ as DQ,GF as PN,GG as Z4,GJ as gP,HI as d8,JI as D7,LE as BP,MD as x0,QJ as V7,RJ as bB,TD as O2,TJ as vP,UJ as IZ,UN as I0,YJ as f0,ZE as k9,_D as p0,dF as zN,fH as V,iK as yX,jB as cX,kF as _N,mB as S$,nI as y8,oE as N$,pF as DN,wJ as zP,xJ as _P,yJ as DP,zJ as I6}from"./chunk-g7v6sp3c.js";import{nO as iK}from"./chunk-s2tc3qs0.js";import{tO as J9,uO as U0,vO as R0,xO as o$,yO as Q7,zO as X7}from"./chunk-e0vrxetq.js";var t4=U0((al,pY)=>{function c4($){return Array.isArray($)?$:[$]}var OL=void 0,VK="",d4=" ",XK="\\",UL=/^\s+$/,FL=/(?:[^\\]|^)\\$/,qL=/^\\!/,zL=/^\\#/,_L=/\r?\n/g,DL=/^\.{0,2}\/|^\.{1,2}$/,PL=/\/$/,J7="/",l4="node-ignore";if(typeof Symbol<"u")l4=Symbol.for("node-ignore");var p4=l4,Y7=($,Z,J)=>{return Object.defineProperty($,Z,{value:J}),J},ML=/([0-z])-([0-z])/g,o4=()=>!1,CL=($)=>$.replace(ML,(Z,J,Y)=>J.charCodeAt(0)<=Y.charCodeAt(0)?Z:VK),wL=($)=>{let{length:Z}=$;return $.slice(0,Z-Z%2)},NL=[[/^\uFEFF/,()=>VK],[/((?:\\\\)*?)(\\?\s+)$/,($,Z,J)=>Z+(J.indexOf("\\")===0?d4:VK)],[/(\\+?)\s/g,($,Z)=>{let{length:J}=Z;return Z.slice(0,J-J%2)+d4}],[/[\\$.|*+(){^]/g,($)=>`\\${$}`],[/(?!\\)\?/g,()=>"[^/]"],[/^\//,()=>"^"],[/\//g,()=>"\\/"],[/^\^*\\\*\\\*\\\//,()=>"^(?:.*\\/)?"],[/^(?=[^^])/,function(){return!/\/(?!$)/.test(this)?"(?:^|\\/)":"^"}],[/\\\/\\\*\\\*(?=\\\/|$)/g,($,Z,J)=>Z+6<J.length?"(?:\\/[^\\/]+)*":"\\/.+"],[/(^|[^\\]+)(\\\*)+(?=.+)/g,($,Z,J)=>{let Y=J.replace(/\\\*/g,"[^\\/]*");return Z+Y}],[/\\\\\\(?=[$.|*+(){^])/g,()=>XK],[/\\\\/g,()=>XK],[/(\\)?\[([^\]/]*?)(\\*)($|\])/g,($,Z,J,Y,Q)=>Z===XK?`\\[${J}${wL(Y)}${Q}`:Q==="]"?Y.length%2===0?`[${CL(J)}${Y}]`:"[]":"[]"],[/(?:[^*])$/,($)=>/\/$/.test($)?`${$}$`:`${$}(?=$|\\/$)`]],AL=/(^|\\\/)?\\\*$/,dZ="regex",cY="checkRegex",u4="_",LL={[dZ]($,Z){return`${Z?`${Z}[^/]+`:"[^/]*"}(?=$|\\/$)`},[cY]($,Z){return`${Z?`${Z}[^/]*`:"[^/]*"}(?=$|\\/$)`}},yL=($)=>NL.reduce((Z,[J,Y])=>Z.replace(J,Y.bind($)),$),lY=($)=>typeof $==="string",IL=($)=>$&&lY($)&&!UL.test($)&&!FL.test($)&&$.indexOf("#")!==0,RL=($)=>$.split(_L).filter(Boolean);class i4{constructor($,Z,J,Y,Q,X){this.pattern=$,this.mark=Z,this.negative=Q,Y7(this,"body",J),Y7(this,"ignoreCase",Y),Y7(this,"regexPrefix",X)}get regex(){let $=u4+dZ;if(this[$])return this[$];return this._make(dZ,$)}get checkRegex(){let $=u4+cY;if(this[$])return this[$];return this._make(cY,$)}_make($,Z){let J=this.regexPrefix.replace(AL,LL[$]),Y=this.ignoreCase?new RegExp(J,"i"):new RegExp(J);return Y7(this,Z,Y)}}var SL=({pattern:$,mark:Z},J)=>{let Y=!1,Q=$;if(Q.indexOf("!")===0)Y=!0,Q=Q.substr(1);Q=Q.replace(qL,"!").replace(zL,"#");let X=yL(Q);return new i4($,Z,Q,J,Y,X)};class n4{constructor($){this._ignoreCase=$,this._rules=[]}_add($){if($&&$[p4]){this._rules=this._rules.concat($._rules._rules),this._added=!0;return}if(lY($))$={pattern:$};if(IL($.pattern)){let Z=SL($,this._ignoreCase);this._added=!0,this._rules.push(Z)}}add($){return this._added=!1,c4(lY($)?RL($):$).forEach(this._add,this),this._added}test($,Z,J){let Y=!1,Q=!1,X;this._rules.forEach((W)=>{let{negative:G}=W;if(Q===G&&Y!==Q||G&&!Y&&!Q&&!Z)return;if(!W[J].test($))return;Y=!G,Q=G,X=G?OL:W});let K={ignored:Y,unignored:Q};if(X)K.rule=X;return K}}var TL=($,Z)=>{throw new Z($)},u8=($,Z,J)=>{if(!lY($))return J(`path must be a string, but got \`${Z}\``,TypeError);if(!$)return J("path must not be empty",TypeError);if(u8.isNotRelative($))return J(`path should be a \`path.relative()\`d string, but got "${Z}"`,RangeError);return!0},s4=($)=>DL.test($);u8.isNotRelative=s4;u8.convert=($)=>$;class r4{constructor({ignorecase:$=!0,ignoreCase:Z=$,allowRelativePaths:J=!1}={}){Y7(this,p4,!0),this._rules=new n4(Z),this._strictPathCheck=!J,this._initCache()}_initCache(){this._ignoreCache=Object.create(null),this._testCache=Object.create(null)}add($){if(this._rules.add($))this._initCache();return this}addPattern($){return this.add($)}_test($,Z,J,Y){let Q=$&&u8.convert($);return u8(Q,$,this._strictPathCheck?TL:o4),this._t(Q,Z,J,Y)}checkIgnore($){if(!PL.test($))return this.test($);let Z=$.split(J7).filter(Boolean);if(Z.pop(),Z.length){let J=this._t(Z.join(J7)+J7,this._testCache,!0,Z);if(J.ignored)return J}return this._rules.test($,!1,cY)}_t($,Z,J,Y){if($ in Z)return Z[$];if(!Y)Y=$.split(J7).filter(Boolean);if(Y.pop(),!Y.length)return Z[$]=this._rules.test($,J,dZ);let Q=this._t(Y.join(J7)+J7,Z,J,Y);return Z[$]=Q.ignored?Q:this._rules.test($,J,dZ)}ignores($){return this._test($,this._ignoreCache,!1).ignored}createFilter(){return($)=>!this.ignores($)}filter($){return c4($).filter(this.createFilter())}test($){return this._test($,this._testCache,!0)}}var KK=($)=>new r4($),xL=($)=>u8($&&u8.convert($),$,o4),a4=()=>{let $=(J)=>/^\\\\\?\\/.test(J)||/["<>|\u0000-\u001F]+/u.test(J)?J:J.replace(/\\/g,"/");u8.convert=$;let Z=/^[a-z]:\//i;u8.isNotRelative=(J)=>Z.test(J)||s4(J)};if(typeof process<"u"&&process.platform==="win32")a4();pY.exports=KK;KK.default=KK;pY.exports.isPathValid=xL;Y7(pY.exports,Symbol.for("setupWindows"),a4)});var sY=U0((Yy)=>{Yy.isInteger=($)=>{if(typeof $==="number")return Number.isInteger($);if(typeof $==="string"&&$.trim()!=="")return Number.isInteger(Number($));return!1};Yy.find=($,Z)=>$.nodes.find((J)=>J.type===Z);Yy.exceedsLimit=($,Z,J=1,Y)=>{if(Y===!1)return!1;if(!Yy.isInteger($)||!Yy.isInteger(Z))return!1;return(Number(Z)-Number($))/Number(J)>=Y};Yy.escapeNode=($,Z=0,J)=>{let Y=$.nodes[Z];if(!Y)return;if(J&&Y.type===J||Y.type==="open"||Y.type==="close"){if(Y.escaped!==!0)Y.value="\\"+Y.value,Y.escaped=!0}};Yy.encloseBrace=($)=>{if($.type!=="brace")return!1;if($.commas>>0+$.ranges>>0===0)return $.invalid=!0,!0;return!1};Yy.isInvalidBrace=($)=>{if($.type!=="brace")return!1;if($.invalid===!0||$.dollar)return!0;if($.commas>>0+$.ranges>>0===0)return $.invalid=!0,!0;if($.open!==!0||$.close!==!0)return $.invalid=!0,!0;return!1};Yy.isOpenOrClose=($)=>{if($.type==="open"||$.type==="close")return!0;return $.open===!0||$.close===!0};Yy.reduce=($)=>$.reduce((Z,J)=>{if(J.type==="text")Z.push(J.value);if(J.type==="range")J.type="text";return Z},[]);Yy.flatten=(...$)=>{let Z=[],J=(Y)=>{for(let Q=0;Q<Y.length;Q++){let X=Y[Q];if(Array.isArray(X)){J(X);continue}if(X!==void 0)Z.push(X)}return Z};return J($),Z}});var rY=U0((Fp,WH)=>{var KH=sY();WH.exports=($,Z={})=>{let J=(Y,Q={})=>{let X=Z.escapeInvalid&&KH.isInvalidBrace(Q),K=Y.invalid===!0&&Z.escapeInvalid===!0,W="";if(Y.value){if((X||K)&&KH.isOpenOrClose(Y))return"\\"+Y.value;return Y.value}if(Y.value)return Y.value;if(Y.nodes)for(let G of Y.nodes)W+=J(G);return W};return J($)}});var BH=U0((qp,GH)=>{/*!
3
3
  * is-number <https://github.com/jonschlinkert/is-number>
4
4
  *
5
5
  * Copyright (c) 2014-present, Jon Schlinkert.
@@ -7541,7 +7541,7 @@ export const tui: TuiPlugin = async (api) => {
7541
7541
  - Use \`.tsx\` extension for JSX support
7542
7542
  - Components use Solid.js JSX (NOT React) \u2014 no useState/useEffect, use signals
7543
7543
  - Keep plugins lightweight \u2014 they run in the main rendering thread
7544
- `}}}catch($){if($ instanceof ReferenceError)return ZD();throw $}}var xg=Tg(),kg=J0.create({service:"skill.builtin"}),YD=V.fn("Skill.extractBuiltinBundle")(function*($){let Z=JD.join(SJ.data,"builtin_skills",x1),J=JD.join(Z,".extracted");return yield*SX({fsys:$,bundle:xg,root:Z,marker:J,markerContent:x1,skipIfPresent:!xX,onExtracted:(Y)=>kg.info("extracted builtin skills",{root:Y})})});var TJ=J0.create({service:"skill"}),hg=[".claude",".agents",".codex",".opencode"],QD="skills/**/SKILL.md",gg="{skill,skills}/**/SKILL.md",kX="**/SKILL.md",XD=_.object({name:_.string(),description:_.string(),location:_.string(),content:_.string(),hidden:_.boolean().optional()}),vg=q$.create("SkillInvalidError",_.object({path:_.string(),message:_.string().optional(),issues:_.custom().optional()})),fg=q$.create("SkillNameMismatchError",_.object({path:_.string(),expected:_.string(),actual:_.string()})),mg=V.fnUntraced(function*($,Z,J){let Y=yield*V.tryPromise({try:()=>L9.parse(Z),catch:(X)=>X}).pipe(V.catch(V.fnUntraced(function*(X){let K=L9.FrontmatterError.isInstance(X)?X.data.message:`Failed to parse skill ${Z}`,{Session:W}=yield*V.promise(()=>import("./chunk-e01jgnnm.js"));yield*J.publish(W.Event.Error,{error:new q$.Unknown({message:K}).toObject()}),TJ.error("failed to load skill",{skill:Z,err:X});return})));if(!Y)return;let Q=XD.pick({name:!0,description:!0,hidden:!0}).safeParse(Y.data);if(!Q.success)return;if($.skills[Q.data.name])TJ.warn("duplicate skill name",{name:Q.data.name,existing:$.skills[Q.data.name].location,duplicate:Z});$.dirs.add(n7.dirname(Z)),$.skills[Q.data.name]={name:Q.data.name,description:Q.data.description,location:Z,content:Y.content,hidden:Q.data.hidden}}),A9=V.fnUntraced(function*($,Z,J,Y){let Q=yield*V.tryPromise({try:()=>c8.scan(J,{cwd:Z,absolute:!0,include:"file",symlink:!0,dot:Y?.dot}),catch:(X)=>X}).pipe(V.catch((X)=>{if(!Y?.scope)return V.die(X);return TJ.error(`failed to scan ${Y.scope} skills`,{dir:Z,error:X}),V.succeed([])}));for(let X of Q)$.matches.add(X),$.dirs.add(n7.dirname(X))}),dg=V.fnUntraced(function*($,Z,J,Y,Q){let X={matches:new Set,dirs:new Set};if(!c0.QITQODE_DISABLE_BUILTIN_SKILLS){let G=yield*YD(J).pipe(V.catch(()=>V.succeed(void 0)));if(G&&(yield*J.isDir(G)))yield*A9(X,G,kX,{scope:"builtin"})}if(!c0.QITQODE_DISABLE_COMPOSE_SKILLS){let G=yield*e_(J).pipe(V.catch(()=>V.succeed(void 0)));if(G&&(yield*J.isDir(G)))yield*A9(X,G,kX,{scope:"compose"})}if(!c0.QITQODE_DISABLE_EXTERNAL_SKILLS){let G=hg.filter((B)=>{if(B===".claude"&&c0.QITQODE_DISABLE_CLAUDE_CODE_SKILLS)return!1;if(B===".codex"&&c0.QITQODE_DISABLE_CODEX_SKILLS)return!1;if(B===".opencode"&&c0.QITQODE_DISABLE_OPENCODE_SKILLS)return!1;return!0});for(let B of G){let j=n7.join(e0.Path.home,B);if(!(yield*J.isDir(j)))continue;yield*A9(X,j,QD,{dot:!0,scope:"global"})}let H=yield*J.up({targets:G,start:Y,stop:Q}).pipe(V.catch(()=>V.succeed([])));for(let B of H)yield*A9(X,B,QD,{dot:!0,scope:"project"})}let K=yield*$.directories();for(let G of K)yield*A9(X,G,gg);let W=yield*$.get();for(let G of W.skills?.paths??[]){let H=G.startsWith("~/")?n7.join(bg.homedir(),G.slice(2)):G,B=n7.isAbsolute(H)?H:n7.join(Y,H);if(!(yield*J.isDir(B))){TJ.warn("skill path not found",{path:B});continue}yield*A9(X,B,kX)}for(let G of W.skills?.urls??[]){let H=yield*Z.pull(G);for(let B of H)yield*A9(X,B,kX)}return{matches:Array.from(X.matches),dirs:Array.from(X.dirs)}}),ug=V.fnUntraced(function*($,Z,J){yield*V.forEach(Z.matches,(Y)=>mg($,Y,J),{concurrency:16,discard:!0}),TJ.info("init",{count:Object.keys($.skills).length})});class bX extends Q0.Service()("@qitqode/Skill"){}var VD=k.effect(bX,V.gen(function*(){let $=yield*y6.Service,Z=yield*H0.Service,J=yield*e.Service,Y=yield*K0.Service,Q=yield*c.make(V.fn("Skill.discovery")(function*(j){return yield*dg(Z,$,Y,j.directory,j.worktree)})),X=yield*c.make(V.fn("Skill.state")(function*(j){let O={skills:{},dirs:new Set};return yield*ug(O,yield*c.get(Q),J),O})),K=V.fn("Skill.get")(function*(j){return(yield*c.get(X)).skills[j]}),W=V.fn("Skill.all")(function*(){let j=yield*c.get(X);return Object.values(j.skills)}),G=V.fn("Skill.dirs")(function*(){return(yield*c.get(Q)).dirs}),H=V.fn("Skill.available")(function*(j){let O=yield*c.get(X),U=Object.values(O.skills).filter((F)=>!F.hidden);if(U=U.toSorted((F,q)=>F.name.localeCompare(q.name)),!j)return U;return U.filter((F)=>M0.evaluate("skill",F.name,j.permission).action!=="deny")}),B=V.fn("Skill.reload")(function*(){yield*c.invalidate(Q),yield*c.invalidate(X)});return bX.of({get:K,all:W,dirs:G,available:H,reload:B})})),cg=VD.pipe(k.provide(y6.defaultLayer),k.provide(H0.defaultLayer),k.provide(e.layer),k.provide(K0.defaultLayer));function lg($,Z){if($.length===0)return"No skills are currently available.";if(Z.verbose)return["<available_skills>",...$.sort((J,Y)=>J.name.localeCompare(Y.name)).flatMap((J)=>[" <skill>",` <name>${J.name}</name>`,` <description>${J.description}</description>`,` <location>${Eg(J.location).href}</location>`," </skill>"]),"</available_skills>"].join(`
7544
+ `}}}catch($){if($ instanceof ReferenceError)return ZD();throw $}}var xg=Tg(),kg=J0.create({service:"skill.builtin"}),YD=V.fn("Skill.extractBuiltinBundle")(function*($){let Z=JD.join(SJ.data,"builtin_skills",x1),J=JD.join(Z,".extracted");return yield*SX({fsys:$,bundle:xg,root:Z,marker:J,markerContent:x1,skipIfPresent:!xX,onExtracted:(Y)=>kg.info("extracted builtin skills",{root:Y})})});var TJ=J0.create({service:"skill"}),hg=[".claude",".agents",".codex",".opencode"],QD="skills/**/SKILL.md",gg="{skill,skills}/**/SKILL.md",kX="**/SKILL.md",XD=_.object({name:_.string(),description:_.string(),location:_.string(),content:_.string(),hidden:_.boolean().optional()}),vg=q$.create("SkillInvalidError",_.object({path:_.string(),message:_.string().optional(),issues:_.custom().optional()})),fg=q$.create("SkillNameMismatchError",_.object({path:_.string(),expected:_.string(),actual:_.string()})),mg=V.fnUntraced(function*($,Z,J){let Y=yield*V.tryPromise({try:()=>L9.parse(Z),catch:(X)=>X}).pipe(V.catch(V.fnUntraced(function*(X){let K=L9.FrontmatterError.isInstance(X)?X.data.message:`Failed to parse skill ${Z}`,{Session:W}=yield*V.promise(()=>import("./chunk-zxwjxszn.js"));yield*J.publish(W.Event.Error,{error:new q$.Unknown({message:K}).toObject()}),TJ.error("failed to load skill",{skill:Z,err:X});return})));if(!Y)return;let Q=XD.pick({name:!0,description:!0,hidden:!0}).safeParse(Y.data);if(!Q.success)return;if($.skills[Q.data.name])TJ.warn("duplicate skill name",{name:Q.data.name,existing:$.skills[Q.data.name].location,duplicate:Z});$.dirs.add(n7.dirname(Z)),$.skills[Q.data.name]={name:Q.data.name,description:Q.data.description,location:Z,content:Y.content,hidden:Q.data.hidden}}),A9=V.fnUntraced(function*($,Z,J,Y){let Q=yield*V.tryPromise({try:()=>c8.scan(J,{cwd:Z,absolute:!0,include:"file",symlink:!0,dot:Y?.dot}),catch:(X)=>X}).pipe(V.catch((X)=>{if(!Y?.scope)return V.die(X);return TJ.error(`failed to scan ${Y.scope} skills`,{dir:Z,error:X}),V.succeed([])}));for(let X of Q)$.matches.add(X),$.dirs.add(n7.dirname(X))}),dg=V.fnUntraced(function*($,Z,J,Y,Q){let X={matches:new Set,dirs:new Set};if(!c0.QITQODE_DISABLE_BUILTIN_SKILLS){let G=yield*YD(J).pipe(V.catch(()=>V.succeed(void 0)));if(G&&(yield*J.isDir(G)))yield*A9(X,G,kX,{scope:"builtin"})}if(!c0.QITQODE_DISABLE_COMPOSE_SKILLS){let G=yield*e_(J).pipe(V.catch(()=>V.succeed(void 0)));if(G&&(yield*J.isDir(G)))yield*A9(X,G,kX,{scope:"compose"})}if(!c0.QITQODE_DISABLE_EXTERNAL_SKILLS){let G=hg.filter((B)=>{if(B===".claude"&&c0.QITQODE_DISABLE_CLAUDE_CODE_SKILLS)return!1;if(B===".codex"&&c0.QITQODE_DISABLE_CODEX_SKILLS)return!1;if(B===".opencode"&&c0.QITQODE_DISABLE_OPENCODE_SKILLS)return!1;return!0});for(let B of G){let j=n7.join(e0.Path.home,B);if(!(yield*J.isDir(j)))continue;yield*A9(X,j,QD,{dot:!0,scope:"global"})}let H=yield*J.up({targets:G,start:Y,stop:Q}).pipe(V.catch(()=>V.succeed([])));for(let B of H)yield*A9(X,B,QD,{dot:!0,scope:"project"})}let K=yield*$.directories();for(let G of K)yield*A9(X,G,gg);let W=yield*$.get();for(let G of W.skills?.paths??[]){let H=G.startsWith("~/")?n7.join(bg.homedir(),G.slice(2)):G,B=n7.isAbsolute(H)?H:n7.join(Y,H);if(!(yield*J.isDir(B))){TJ.warn("skill path not found",{path:B});continue}yield*A9(X,B,kX)}for(let G of W.skills?.urls??[]){let H=yield*Z.pull(G);for(let B of H)yield*A9(X,B,kX)}return{matches:Array.from(X.matches),dirs:Array.from(X.dirs)}}),ug=V.fnUntraced(function*($,Z,J){yield*V.forEach(Z.matches,(Y)=>mg($,Y,J),{concurrency:16,discard:!0}),TJ.info("init",{count:Object.keys($.skills).length})});class bX extends Q0.Service()("@qitqode/Skill"){}var VD=k.effect(bX,V.gen(function*(){let $=yield*y6.Service,Z=yield*H0.Service,J=yield*e.Service,Y=yield*K0.Service,Q=yield*c.make(V.fn("Skill.discovery")(function*(j){return yield*dg(Z,$,Y,j.directory,j.worktree)})),X=yield*c.make(V.fn("Skill.state")(function*(j){let O={skills:{},dirs:new Set};return yield*ug(O,yield*c.get(Q),J),O})),K=V.fn("Skill.get")(function*(j){return(yield*c.get(X)).skills[j]}),W=V.fn("Skill.all")(function*(){let j=yield*c.get(X);return Object.values(j.skills)}),G=V.fn("Skill.dirs")(function*(){return(yield*c.get(Q)).dirs}),H=V.fn("Skill.available")(function*(j){let O=yield*c.get(X),U=Object.values(O.skills).filter((F)=>!F.hidden);if(U=U.toSorted((F,q)=>F.name.localeCompare(q.name)),!j)return U;return U.filter((F)=>M0.evaluate("skill",F.name,j.permission).action!=="deny")}),B=V.fn("Skill.reload")(function*(){yield*c.invalidate(Q),yield*c.invalidate(X)});return bX.of({get:K,all:W,dirs:G,available:H,reload:B})})),cg=VD.pipe(k.provide(y6.defaultLayer),k.provide(H0.defaultLayer),k.provide(e.layer),k.provide(K0.defaultLayer));function lg($,Z){if($.length===0)return"No skills are currently available.";if(Z.verbose)return["<available_skills>",...$.sort((J,Y)=>J.name.localeCompare(Y.name)).flatMap((J)=>[" <skill>",` <name>${J.name}</name>`,` <description>${J.description}</description>`,` <location>${Eg(J.location).href}</location>`," </skill>"]),"</available_skills>"].join(`
7545
7545
  `);return["## Available Skills",...$.toSorted((J,Y)=>J.name.localeCompare(Y.name)).map((J)=>`- **${J.name}**: ${J.description}`)].join(`
7546
7546
  `)}var c5=m0("skill",V.gen(function*(){let $=(yield*V0.toolDescriptionEffect("skill"))??"",Z=yield*W2.Service,J=yield*o2.Service;return{description:$,parameters:uj,execute:(Y,Q)=>V.gen(function*(){let X=yield*Z.get(Y.name);if(!X){let j=(yield*Z.all()).map((O)=>O.name).join(", ");throw Error(`Skill "${Y.name}" not found. Available skills: ${j||"none"}`)}yield*Q.ask({permission:"skill",patterns:[Y.name],always:[Y.name],metadata:{}});let K=KD.dirname(X.location),W=pg(K).href,G=10,H=yield*J.files({cwd:K,follow:!1,hidden:!0,signal:Q.abort}).pipe(R6((B)=>!B.includes("SKILL.md")),I6((B)=>KD.resolve(K,B)),DQ(G),V7,V.map((B)=>[...B].map((j)=>`<file>${j}</file>`).join(`
7547
7547
  `)));return{title:`Loaded skill: ${X.name}`,output:[`<skill_content name="${X.name}">`,`# Skill: ${X.name}`,"",X.content.trim(),"",`Base directory for this skill: ${W}`,"Relative paths in this skill (e.g., scripts/, reference/) are relative to this base directory.","Note: file list is sampled.","","<skill_files>",H,"</skill_files>","</skill_content>"].join(`
@@ -8148,7 +8148,7 @@ If you repeat the same output again, the session will be terminated.
8148
8148
  `):[`Your last ${SZ} steps have been identical \u2014 you appear to be`,"repeating the same action without making progress. Stop and reconsider:","the current approach is not working. Try a different strategy, use a","different tool, or if you are blocked, explain the blocker to the user","instead of repeating the same step again."].join(`
8149
8149
  `)})})}var cB=J0.create({service:"auto-dream"}),lB=86400000,au=7,tu=30,fw=1e4,pB="Auto Dream",oB="Auto Distill",gw=0,vw=0,mw=["Run one automatic dream memory consolidation pass for the current project.","","Use the memory files as the working index and the raw qitqode trajectory database as the source of truth.","Use bash for read-only SQLite and filesystem inspection. Do not modify the database.","Consolidate only durable, verified information into project memory."].join(`
8150
8150
  `),dw=["Run one automatic distill pass for the current project.","","Review the past month of sessions and identify repeated manual workflows worth packaging.","Use the raw qitqode trajectory database as the source of truth and memory files to spot cross-session patterns.","Inventory existing skills, agents, and commands first so you reuse or extend instead of duplicating.","Use bash for read-only SQLite and filesystem inspection. Do not modify the database.","Produce a compact shortlist, then create only the high-confidence missing assets."].join(`
8151
- `);function uw($){return V.gen(function*(){if(!$.enabled)return!1;let Z=$.intervalDays*lB,J=yield*V.sync(()=>C0.use((X)=>X.select({time_created:W$.time_created}).from(W$).where(D0(W$.title,$.title)).orderBy(x8(W$.time_created)).limit(1).get())),Y=Date.now(),Q=J?Y-J.time_created:1/0;if(!J){let X=yield*V.sync(()=>C0.use((K)=>K.select({time_created:W$.time_created}).from(W$).where(XJ(W$.parent_id)).orderBy(H8(W$.time_created)).limit(1).get()));if(!X||Y-X.time_created<Z)return cB.info(`auto-${$.label} skipped \u2014 project too young`,{projectAge:X?Math.round((Y-X.time_created)/lB)+"d":"empty",interval:$.intervalDays+"d"}),!1}if(Q<Z)return cB.info(`auto-${$.label} skipped \u2014 last run too recent`,{lastRunAgo:Math.round(Q/lB)+"d",interval:$.intervalDays+"d"}),!1;return cB.info(`auto-${$.label} triggering`,{lastRun:J?new Date(J.time_created).toISOString():"never",interval:$.intervalDays+"d"}),!0})}function cw($){let Z=$.dream?.auto!==!1;if(!Z)return V.succeed(!1);let J=Date.now();if(J-gw<fw)return V.succeed(!1);gw=J;let Y=$.dream?.interval_days??au;return uw({enabled:Z,intervalDays:Y,title:pB,label:"dream"})}function lw($){let Z=$.distill?.auto!==!1;if(!Z)return V.succeed(!1);let J=Date.now();if(J-vw<fw)return V.succeed(!1);vw=J;let Y=$.distill?.interval_days??tu;return uw({enabled:Z,intervalDays:Y,title:oB,label:"distill"})}var pw=V.fnUntraced(function*($){let Z=yield*$.config.get(),J=yield*cw(Z).pipe(V.catch(()=>V.succeed(!1))),Y=yield*lw(Z).pipe(V.catch(()=>V.succeed(!1))),Q={providerID:$.lastUser.model.providerID,modelID:$.lastUser.model.modelID};if(!J&&!Y)return;let{AppRuntime:X}=yield*V.promise(()=>import("./chunk-wf41m019.js"));if(J)X.runPromise(f$.use((K)=>V.gen(function*(){let W=yield*K.create({title:pB});yield*(yield*$.promptServiceTag).prompt({sessionID:W.id,agent:"dream",model:Q,parts:[{type:"text",text:mw}]})}))).catch((K)=>$.log.error("auto-dream prompt failed",{error:String(K)}));if(Y)X.runPromise(f$.use((K)=>V.gen(function*(){let W=yield*K.create({title:oB});yield*(yield*$.promptServiceTag).prompt({sessionID:W.id,agent:"distill",model:Q,parts:[{type:"text",text:dw}]})}))).catch((K)=>$.log.error("auto-distill prompt failed",{error:String(K)}))});var $c=($)=>$.pipe(V.catchDefect((Z)=>Z instanceof V0.BackendAuthRejectedError?V.succeed(void 0):V.die(Z))),iB=($)=>$c(V.promise(()=>V0.resolvePrompt($))).pipe(V.map((Z)=>Z??"")),ow=V.gen(function*(){let $=yield*iB("session/build-switch"),Z=yield*iB("session/max-steps"),J=yield*iB("session/compose");return{buildSwitch:$,maxSteps:Z,promptCompose:J}});var iw=S1.create({service:"session.prompt"}),Zc=J0.create({service:"session.prompt"}),Jc=/\b(implement|build|create|make|scaffold|generate|fix|repair|add|change|update|refactor|remove)\b/i,Yc=/\b(explain|review|investigate|analy[sz]e|research|inspect|tell me how|how (?:do|would|should|can))\b/i,Qc=/(?:^|\b(?:and|then)\s+)(?:please\s+)?(?:implement|build|create|make|scaffold|generate|fix|repair|add|change|update|refactor|remove)\b/i,Xc=/\b(tell me how|how (?:do|would|should|can)|read[- ]only|(?:explain|review|investigate|analy[sz]e|research|inspect)\s+only|(?:do not|don't)\s+(?:edit|change|modify|write|implement|fix|repair|remove|delete)\s+(?:anything|any\s+(?:code|files?)|the\s+(?:code|files?)|code|files?)|without\s+(?:editing|changing|modifying|writing)\s+(?:anything|any\s+(?:code|files?)|the\s+(?:code|files?)|code|files?)|no\s+(?:code|file)\s+changes?)\b/i;function Vc($,Z){if(!$||$.native!==!0||x9($)!=="interactive-build")return!1;let J=Z.filter((Y)=>Y.type==="text"&&!Y.synthetic).map((Y)=>Y.text).join(`
8151
+ `);function uw($){return V.gen(function*(){if(!$.enabled)return!1;let Z=$.intervalDays*lB,J=yield*V.sync(()=>C0.use((X)=>X.select({time_created:W$.time_created}).from(W$).where(D0(W$.title,$.title)).orderBy(x8(W$.time_created)).limit(1).get())),Y=Date.now(),Q=J?Y-J.time_created:1/0;if(!J){let X=yield*V.sync(()=>C0.use((K)=>K.select({time_created:W$.time_created}).from(W$).where(XJ(W$.parent_id)).orderBy(H8(W$.time_created)).limit(1).get()));if(!X||Y-X.time_created<Z)return cB.info(`auto-${$.label} skipped \u2014 project too young`,{projectAge:X?Math.round((Y-X.time_created)/lB)+"d":"empty",interval:$.intervalDays+"d"}),!1}if(Q<Z)return cB.info(`auto-${$.label} skipped \u2014 last run too recent`,{lastRunAgo:Math.round(Q/lB)+"d",interval:$.intervalDays+"d"}),!1;return cB.info(`auto-${$.label} triggering`,{lastRun:J?new Date(J.time_created).toISOString():"never",interval:$.intervalDays+"d"}),!0})}function cw($){let Z=$.dream?.auto!==!1;if(!Z)return V.succeed(!1);let J=Date.now();if(J-gw<fw)return V.succeed(!1);gw=J;let Y=$.dream?.interval_days??au;return uw({enabled:Z,intervalDays:Y,title:pB,label:"dream"})}function lw($){let Z=$.distill?.auto!==!1;if(!Z)return V.succeed(!1);let J=Date.now();if(J-vw<fw)return V.succeed(!1);vw=J;let Y=$.distill?.interval_days??tu;return uw({enabled:Z,intervalDays:Y,title:oB,label:"distill"})}var pw=V.fnUntraced(function*($){let Z=yield*$.config.get(),J=yield*cw(Z).pipe(V.catch(()=>V.succeed(!1))),Y=yield*lw(Z).pipe(V.catch(()=>V.succeed(!1))),Q={providerID:$.lastUser.model.providerID,modelID:$.lastUser.model.modelID};if(!J&&!Y)return;let{AppRuntime:X}=yield*V.promise(()=>import("./chunk-32fpqd0n.js"));if(J)X.runPromise(f$.use((K)=>V.gen(function*(){let W=yield*K.create({title:pB});yield*(yield*$.promptServiceTag).prompt({sessionID:W.id,agent:"dream",model:Q,parts:[{type:"text",text:mw}]})}))).catch((K)=>$.log.error("auto-dream prompt failed",{error:String(K)}));if(Y)X.runPromise(f$.use((K)=>V.gen(function*(){let W=yield*K.create({title:oB});yield*(yield*$.promptServiceTag).prompt({sessionID:W.id,agent:"distill",model:Q,parts:[{type:"text",text:dw}]})}))).catch((K)=>$.log.error("auto-distill prompt failed",{error:String(K)}))});var $c=($)=>$.pipe(V.catchDefect((Z)=>Z instanceof V0.BackendAuthRejectedError?V.succeed(void 0):V.die(Z))),iB=($)=>$c(V.promise(()=>V0.resolvePrompt($))).pipe(V.map((Z)=>Z??"")),ow=V.gen(function*(){let $=yield*iB("session/build-switch"),Z=yield*iB("session/max-steps"),J=yield*iB("session/compose");return{buildSwitch:$,maxSteps:Z,promptCompose:J}});var iw=S1.create({service:"session.prompt"}),Zc=J0.create({service:"session.prompt"}),Jc=/\b(implement|build|create|make|scaffold|generate|fix|repair|add|change|update|refactor|remove)\b/i,Yc=/\b(explain|review|investigate|analy[sz]e|research|inspect|tell me how|how (?:do|would|should|can))\b/i,Qc=/(?:^|\b(?:and|then)\s+)(?:please\s+)?(?:implement|build|create|make|scaffold|generate|fix|repair|add|change|update|refactor|remove)\b/i,Xc=/\b(tell me how|how (?:do|would|should|can)|read[- ]only|(?:explain|review|investigate|analy[sz]e|research|inspect)\s+only|(?:do not|don't)\s+(?:edit|change|modify|write|implement|fix|repair|remove|delete)\s+(?:anything|any\s+(?:code|files?)|the\s+(?:code|files?)|code|files?)|without\s+(?:editing|changing|modifying|writing)\s+(?:anything|any\s+(?:code|files?)|the\s+(?:code|files?)|code|files?)|no\s+(?:code|file)\s+changes?)\b/i;function Vc($,Z){if(!$||$.native!==!0||x9($)!=="interactive-build")return!1;let J=Z.filter((Y)=>Y.type==="text"&&!Y.synthetic).map((Y)=>Y.text).join(`
8152
8152
  `);if(!J||Xc.test(J))return!1;if(!Jc.test(J))return!1;return!Yc.test(J)||Qc.test(J)}function nw($,Z,J,Y){return V.gen(function*(){let{bus:Q,status:X,sessions:K,agents:W,provider:G,processor:H,prune:B,checkpoint:j,compaction:O,config:U,plugin:F,permission:q,fsys:w,registry:D,scope:z,instruction:C,state:P,goal:y,taskGateState:I,taskRegistry:x,revert:h,summary:S,sys:v,llm:L,actorRegistry:T,inbox:E}=yield*F3,N=yield*ow,R=N.buildSwitch,b=N.maxSteps,r=N.promptCompose,l=(G0,Z0,n)=>Bw(G,Q,G0,Z0,n),d=(G0,Z0)=>jw(K,G0,Z0),u=uB(K),o=1024,W0=new class extends Set{add(G0){if(super.add(G0),this.size>1024){let Z0=this.values().next().value;if(Z0!==void 0)this.delete(Z0)}return this}},a=(G0)=>EB({getOps:$,...G0}),f=zw({agents:W,provider:G,llm:L,sessions:K,elog:iw}),$0=_w({sessions:K,fsys:w,buildSwitch:R,promptCompose:r});return{runLoop:V.fn("SessionPrompt.run")(function*(G0,Z0,n){let _0=yield*c.context,i=iw.with({sessionID:G0}),t,O0=0,w0=yield*K.get(G0),N0,r0,K$=new Map,l$=Z0??"main",b2=Kw({sessionID:G0,agentID:l$,task_id:n,plugin:F,bus:Q,prune:B,scope:z}),{cancellation:P2,agentMetrics:n$,publishAgentRequest:s$,schedulePrune:$$}=b2,Y8=Vw({sessionID:G0,agentID:l$,task_id:n,session:w0,cancellation:P2,plugin:F});return yield*V.gen(function*(){yield*b2.before;let U2=(Y2,g0)=>_3(mC(Y2,g0,X0.parts(g0.id))),Y1=!1,M2=xw({sessionID:G0,bus:Q,appendSyntheticUserTurn:u,slog:i}),C8=Tw({sessionID:G0,sessions:K,bus:Q,appendSyntheticUserTurn:u,slog:i}),{autoContinueOutputLength:CY,autoRecoverOutputBudget:d1,autoContinueStreamCutoff:wY,autoContinueInvalidOutput:NY,autoRetryStructuredOutput:j$,handleTextRepeat:n0,writeContentFilterError:h$,writeModelError:F1}=C8,L1=Ow({sessionID:G0,agentID:Z0,agents:W,taskGateState:I,taskRegistry:x,appendSyntheticUserTurn:u,slog:i}),U6=Uw({sessionID:G0,agentID:Z0,session:w0,goal:y,bus:Q,appendSyntheticUserTurn:u,slog:i});while(!0){if(!Z0||Z0==="main")yield*X.set(G0,{type:"busy"});yield*E.drain(G0,Z0??"main").pipe(V.ignore),yield*i.info("loop",{step:O0});let Y2=yield*X0.filterCompactedEffect(G0,{contextFrom:w0.contextFrom,contextWatermark:w0.contextWatermark,agentID:Z0??"main"}),g0,v8,C2,EZ,w2,N2=[];for(let t0=Y2.length-1;t0>=0;t0--){let g$=Y2[t0];if(!g0&&g$.info.role==="user")g0=g$.info,v8=g$;if(!C2&&g$.info.role==="assistant")C2=g$.info,EZ=g$;if(!w2&&g$.info.role==="assistant"&&g$.info.finish)w2=g$.info;if(g0&&w2)break;if(!w2){let f8=g$.parts.filter((X8)=>X8.type==="subtask");N2.push(...f8)}}if(!g0)throw Error("No user message found in stream. This should never happen.");yield*bw({sessionID:G0,msgs:Y2,checkpoint:j,config:U});let e9=EZ?.parts.some((t0)=>t0.type==="tool"&&!t0.metadata?.providerExecuted)??!1;if(C2?.finish==="length"&&!e9&&g0.id<C2.id&&(yield*CY({lastUser:g0,assistant:C2})))continue;if(C2){if(yield*d1({lastUser:g0,assistant:C2}))continue;if(yield*wY({lastUser:g0,assistant:C2}))continue;let t0=TB({phase:"existing-assistant",lastUser:g0,assistant:C2,parts:EZ?.parts??[]});if(t0.type==="filtered"){yield*h$({assistant:C2}),yield*i.info("exiting loop",{classification:t0.type});break}if(t0.type==="failed"){yield*F1({assistant:C2,reason:t0.reason}),yield*i.info("exiting loop",{classification:t0.type,reason:t0.reason});break}if(t0.type==="think-only"||t0.type==="invalid"){let g$=t0.type==="invalid"?t0.reason:"think-only";if(yield*NY({lastUser:g0,assistant:C2,reason:g$}))continue;yield*i.info("exiting loop",{classification:t0.type});break}if(t0.type==="final"&&t0.degraded)yield*i.warn("degraded final on abnormal finish",{finish:C2.finish});if(t0.type!=="continue"){if(yield*L1(g0))continue;if(yield*U6(g0))continue;yield*i.info("exiting loop",{classification:t0.type});break}}if(O0++,O0===1)yield*f({session:w0,modelID:g0.model.modelID,providerID:g0.model.providerID,history:Y2}).pipe(V.ignore,V.forkIn(z));if(O0===1&&!w0.parentID)yield*pw({config:U,lastUser:g0,promptServiceTag:Y,log:Zc});let y1=yield*l(g0.model.providerID,g0.model.modelID,G0);r0=y1,N0=w2;let AY=N2.pop();if(AY?.type==="subtask"){yield*a({task:AY,model:y1,lastUser:g0,sessionID:G0,session:w0,msgs:Y2});continue}let N8=v8;if(N8?.parts.some((t0)=>t0.type==="compaction")){let t0=N8.parts.find((X8)=>X8.type==="compaction"),g$=yield*K.messages({sessionID:G0,agentID:g0.agentID??"main"});if((yield*O.process({parentID:g0.id,messages:g$,sessionID:G0,auto:t0?.auto??!1,overflow:t0?.overflow,agentID:g0.agentID}))==="stop")break;continue}yield*Ew({sessionID:G0,msgs:Y2,lastFinished:w2,model:y1,config:U});let P0=yield*W.get(g0.agent),a0=P0?.native===!0&&P0?.hidden===!0;if(hw({sessionID:G0,msgs:Y2,lastFinished:w2,allowDiscoveryRecovery:Vc(P0,v8?.parts??[])}),!Y1&&!a0&&w2&&w2.tokens){let t0=yield*$();yield*B.fireCheckpoints({sessionID:G0,model:y1,tokens:w2.tokens,promptOps:t0,agentID:g0.agentID}).pipe(V.ignore)}if(!Y1&&w2&&w2.tokens){if(yield*Qw({config:U,checkpoint:j,compaction:O,prune:B},{sessionID:G0,lastFinished:w2,lastUser:g0,model:y1,msgs:Y2,isBoundedComputation:a0})){Y1=!0;continue}}if(Y1=!1,!P0)throw yield*xB(W,Q,g0.agent,G0);let A8=P0.steps??1/0,s6=O0>=A8;Y2=yield*$0({messages:Y2,agent:P0,session:w0});let Q8=M3({sessionID:G0,parentID:g0.id,agentID:g0.agentID,agent:P0.name,variant:g0.model.variant,cwd:_0.directory,root:_0.worktree,modelID:y1.id,providerID:y1.providerID});yield*K.updateMessage(Q8);let w$=yield*H.create({assistantMessage:Q8,sessionID:G0,model:y1,agentMetrics:n$}),d3=yield*V.gen(function*(){let t0={value:t},g$=yield*dC({sessionID:G0,resolvedAgentID:l$,step:O0,task_id:n,lastUser:g0,lastFinished:w2,msgs:Y2,agent:P0,session:w0,model:y1,handle:w$,structured:t0,resolveTools:Z,createStructuredOutputTool:J,summary:S,scope:z,plugin:F}),{tools:f8,format:X8,query:u3}=g$,{cancelledByPlugin:c3,withUserQueryPost:l3}=uC({sessionID:G0,agentID:l$,step:O0,lastUser:g0,msgs:Y2,query:u3,handle:w$,plugin:F,sessions:K,cancellation:P2,trajectoryForStep:U2}),p3=V.fnUntraced(function*($7){if($7==="continue"&&(yield*CY({lastUser:g0,assistant:w$.message})))return"continue";if($7==="text-repeat"){if(yield*n0({lastUser:g0}))return"continue";return"break"}if(t0.value!==void 0)return t=t0.value,w$.message.structured=t0.value,w$.message.finish=w$.message.finish??"stop",yield*K.updateMessage(w$.message),"break";let Q2=TB({phase:"after-process",lastUser:g0,assistant:w$.message,parts:X0.parts(w$.message.id),processResult:$7});if(Q2.type==="filtered")return yield*h$({assistant:w$.message}),"break";if(Q2.type==="failed"){if(yield*d1({lastUser:g0,assistant:w$.message}))return"continue";if(yield*wY({lastUser:g0,assistant:w$.message}))return"continue";return yield*F1({assistant:w$.message,reason:Q2.reason}),"break"}if(Q2.type!=="continue"&&!w$.message.error&&X8.type==="json_schema"){if(yield*j$({lastUser:g0,assistant:w$.message}))return"continue";return"break"}if((Q2.type==="think-only"||Q2.type==="invalid")&&X8.type!=="json_schema"){let o3=Q2.type==="invalid"?Q2.reason:"think-only";if(yield*NY({lastUser:g0,assistant:w$.message,reason:o3}))return"continue";return"break"}if(Q2.type==="final"&&Q2.degraded)yield*i.warn("degraded final on abnormal finish",{finish:w$.message.finish});if($7==="stop")return"break";return}),r6=yield*Zw({sessionID:G0,lastUser:g0,agent:P0,session:w0,model:y1,msgs:Y2,tools:f8,format:X8,handle:w$,isLastStep:s6,task_id:n,instructionsNotified:W0,maxStepsText:b,actorRegistry:T,bus:Q,config:U,instruction:C,llm:L,provider:G,registry:D,status:X,sys:v,cancelledByPlugin:c3,withUserQueryPost:l3,slog:i,visionAnalysis:K$});if(r6.kind==="break"){if(r6.reason==="vision-unavailable")yield*F1({assistant:w$.message,reason:r6.message});return"break"}let yY=yield*p3(r6.result);if(yY)return yY;if(r6.result==="overflow")yield*Xw({config:U,checkpoint:j,compaction:O,prune:B},{sessionID:G0,lastUser:g0,model:y1,msgs:Y2,isBoundedComputation:a0});return"continue"}).pipe(V.ensuring(C.clear(w$.message.id))),LY=yield*M2.check({lastUser:g0,completedParts:X0.parts(w$.message.id)});if(LY==="terminate")break;if(LY==="recovered")continue;if(d3==="break"){if(P0.name==="build"&&!w$.message.error){let t0=yield*K.messages({sessionID:G0,agentID:l$}),g$=X0.parts(w$.message.id).findLast((X8)=>X8.type==="text"),f8=yield*V.promise(()=>qw(t0,_0.worktree,g$?.text??""));if(f8.length){if(g$&&!g$.text.startsWith("PARTIAL \u2014 automatic verification incomplete"))yield*K.updatePart({...g$,text:`PARTIAL \u2014 automatic verification incomplete. ${f8.join("; ")}. Do not treat source-only checks as proof of a completed styled build.
8153
8153
 
8154
8154
  ${g$.text}`})}}if(yield*L1(g0))continue;if(yield*U6(g0))continue;break}continue}let w8=yield*$();if(r0&&N0)yield*$$({model:r0,lastFinished:N0,promptOps:w8});let h0=yield*d(G0,Z0),a9=h0.info.role==="assistant"&&!!h0.info.error,t9=yield*K.findMessage(G0,(Y2)=>Y2.info.role==="user",{agentID:"*"});return yield*s$(a9?"error":"completed",S$.isSome(t9)?t9.value.info.agent:h0.info.agent),h0}).pipe((U2)=>kB(G0,Q,U2),V.onExit(Y8),V.orDie)}),lastAssistant:d}})}import sw from"path";var Kc=new TextEncoder,nB=new TextDecoder,Wc=($)=>`
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{Jq as mJ,Kq as vJ,Lq as dJ,Mq as lJ,Pq as d,Qq as l,Sq as uJ,Tq as cJ,Wq as pJ,Xq as iJ,Yq as nJ,Zq as aJ,_q as rJ,ar as AQ}from"./chunk-wqk1v8t0.js";import{Ds as FQ,es as CQ,fs as DQ}from"./chunk-wb05bp10.js";import{Os as x,Xs as GJ}from"./chunk-59csnjc3.js";import{$D as BQ,AG as SJ,EE as z,EG as xJ,FD as qQ,FF as EJ,IG as fJ,JF as MJ,KE as b,MD as _J,ME as CJ,MF as oJ,QF as RJ,RL as j,SF as VJ,TG as E,VF as hJ,WE as DJ,XE as FJ,YE as AJ,YG as yJ,ZG as bJ,aE as wQ,aO as g,bO as eJ,cC as GQ,cG as jJ,dE as $J,eE as UJ,eO as HQ,fB as wJ,fH as I,fO as WQ,gM as o,gO as R,iB as HJ,iF as t,iG as NJ,jE as zJ,jF as OJ,lB as WJ,lF as y,mI as gJ,nB as $Q,qC as IJ,sA as tJ,tC as PJ,tG as kJ,uE as ZJ,vB as f,wC as T,xG as LJ,yF as TJ,zC as KJ}from"./chunk-g7v6sp3c.js";import{tO as zQ,vO as u,xO as S}from"./chunk-e0vrxetq.js";var IX={};u(IX,{resource:()=>BJ,layer:()=>EQ,enabled:()=>OQ,Observability:()=>WX});var p={};u(p,{make:()=>IQ,layer:()=>ZX});var VQ=AJ.pipe(FJ,DJ((J)=>{if(lJ(J)&&J.reason._tag==="StatusCodeError"&&J.reason.response.status===429){let Q=HJ(J.reason.response.headers["retry-after"]).pipe(WJ(CJ),wJ(()=>5));return t(T(Q))}return t(T(1))})),sJ=E(function*(J){let Q=yield*jJ(),X=f(Q,b),Y=f(Q,UJ),$=fJ(Q),G=KJ(IJ(J.exportInterval),PJ),B=void 0,C=nJ(f(Q,pJ)).pipe(iJ(NJ(rJ,!1)),aJ({schedule:VQ,times:3})),V=vJ({"user-agent":`effect-opentelemetry-${J.label}/0.0.0`});if(J.headers)V=dJ(mJ(J.headers),V);let r=uJ(J.url,{headers:V}),O=[],s=OJ(()=>{if(B!==void 0&&X.currentTimeMillisUnsafe()<B)return y;else if(B!==void 0)B=void 0;let h=O;if(J.maxBatchSize!=="disabled"){if(O.length===0)return y;O=[]}return C.execute(cJ(r,J.body(h))).pipe(EJ,SJ(!1))}).pipe(MJ((h)=>{if(B!==void 0)return y;return B=X.currentTimeMillisUnsafe()+60000,O=[],yJ("Disabling exporter for 60 seconds",h)}),bJ({package:"@effect/opentelemetry",module:J.label}));return yield*zJ(Y,s.pipe(RJ,kJ,VJ(J.shutdownTimeout))),yield*hJ(G).pipe(TJ(s),LJ,xJ(Y)),{push(h){if(B!==void 0)return;if(O.push(h),J.maxBatchSize!=="disabled"&&O.length>=J.maxBatchSize)gJ($(s),Y)}}});var jQ=(J)=>{let Q=J.attributes?e(Object.entries(J.attributes)):[];if(Q.push({key:"service.name",value:{stringValue:J.serviceName}}),J.serviceVersion)Q.push({key:"service.version",value:{stringValue:J.serviceVersion}});return{attributes:Q,droppedAttributesCount:0}},JQ=E(function*(J){let Q={...yield*g(o(eJ(j,j)),"OTEL_RESOURCE_ATTRIBUTES"),...J?.attributes},X=J?.serviceName??Q["service.name"]??(yield*g(j,"OTEL_SERVICE_NAME"));delete Q["service.name"];let Y=J?.serviceVersion??Q["service.version"]??(yield*g(o(j),"OTEL_SERVICE_VERSION"));return delete Q["service.version"],jQ({serviceName:X,serviceVersion:Y,attributes:Q})},oJ),QQ=(J)=>{let Q=J.attributes.find((X)=>X.key==="service.name");if(!Q||!Q.value.stringValue)throw Error("Resource does not contain a service name");return Q.value.stringValue},e=(J)=>{let Q=[];for(let[X,Y]of J)Q.push({key:X,value:m(Y)});return Q},m=(J)=>{if(Array.isArray(J))return{arrayValue:{values:J.map(m)}};switch(typeof J){case"string":return{stringValue:J};case"bigint":return{intValue:Number(J)};case"number":return Number.isInteger(J)?{intValue:J}:{doubleValue:J};case"boolean":return{boolValue:J};default:return{stringValue:tJ(J)}}};var c={};u(c,{layerProtobuf:()=>YX,layerJson:()=>XX,OtlpSerialization:()=>M});var N={Varint:0,Fixed64:1,LengthDelimited:2,Fixed32:5},k=(J,Q)=>J<<3|Q,D=(J)=>{let Q=[],X=typeof J==="bigint"?J:BigInt(J);while(X>0x7fn)Q.push(Number(X&0x7fn)|128),X>>=7n;return Q.push(Number(X)),new Uint8Array(Q)};var kQ=(J)=>{let Q=new Uint8Array(8);return new DataView(Q.buffer).setBigUint64(0,J,!0),Q},LQ=(J)=>{let Q=new Uint8Array(4);return new DataView(Q.buffer).setUint32(0,J,!0),Q},SQ=(J)=>{let Q=new Uint8Array(8);return new DataView(Q.buffer).setFloat64(0,J,!0),Q},xQ=(J)=>new TextEncoder().encode(J),fQ=(J)=>{let Q=new Uint8Array(J.length/2);for(let X=0;X<J.length;X+=2)Q[X/2]=parseInt(J.slice(X,X+2),16);return Q},Z=(...J)=>{let Q=J.reduce(($,G)=>$+G.length,0),X=new Uint8Array(Q),Y=0;for(let $ of J)X.set($,Y),Y+=$.length;return X},q=(J,Q)=>Z(D(k(J,N.Varint)),D(Q));var JJ=(J,Q)=>q(J,Q?1:0),W=(J,Q)=>Z(D(k(J,N.Fixed64)),kQ(Q)),v=(J,Q)=>Z(D(k(J,N.Fixed32)),LQ(Q)),F=(J,Q)=>Z(D(k(J,N.Fixed64)),SQ(Q)),L=(J,Q)=>Z(D(k(J,N.LengthDelimited)),D(Q.length),Q),K=(J,Q)=>L(J,xQ(Q)),U=(J,Q)=>L(J,fQ(Q)),w=(J,Q)=>L(J,Q),_=(J,Q,X)=>Z(...Q.map((Y)=>w(J,X(Y))));var H=(J,Q)=>Q!==void 0&&Q!==""?K(J,Q):new Uint8Array(0);var QJ=(J)=>{if(J.stringValue!==void 0&&J.stringValue!==null)return K(1,J.stringValue);if(J.boolValue!==void 0&&J.boolValue!==null)return JJ(2,J.boolValue);if(J.intValue!==void 0&&J.intValue!==null)return q(3,BigInt(J.intValue));if(J.doubleValue!==void 0&&J.doubleValue!==null)return F(4,J.doubleValue);if(J.arrayValue!==void 0)return w(5,bQ(J.arrayValue));if(J.kvlistValue!==void 0)return w(6,gQ(J.kvlistValue));if(J.bytesValue!==void 0)return L(7,J.bytesValue);return new Uint8Array(0)},bQ=(J)=>_(1,J.values,QJ),gQ=(J)=>_(1,J.values,P),P=(J)=>Z(K(1,J.key),w(2,QJ(J.value))),XJ=(J)=>Z(K(1,J.name),H(2,J.version),J.attributes?_(3,J.attributes,P):new Uint8Array(0),J.droppedAttributesCount?q(4,J.droppedAttributesCount):new Uint8Array(0)),YJ=(J)=>Z(_(1,J.attributes,P),J.droppedAttributesCount>0?q(2,J.droppedAttributesCount):new Uint8Array(0));var mQ=(J)=>Z(H(2,J.message),q(3,J.code)),vQ=(J)=>Z(W(1,BigInt(J.timeUnixNano)),K(2,J.name),_(3,J.attributes,P),J.droppedAttributesCount>0?q(4,J.droppedAttributesCount):new Uint8Array(0)),dQ=(J)=>Z(U(1,J.traceId),U(2,J.spanId),H(3,J.traceState),_(4,J.attributes,P),J.droppedAttributesCount>0?q(5,J.droppedAttributesCount):new Uint8Array(0),J.flags!==void 0?v(6,J.flags):new Uint8Array(0)),lQ=(J)=>Z(U(1,J.traceId),U(2,J.spanId),H(3,J.traceState),J.parentSpanId!==void 0?U(4,J.parentSpanId):new Uint8Array(0),K(5,J.name),q(6,J.kind),W(7,BigInt(J.startTimeUnixNano)),W(8,BigInt(J.endTimeUnixNano)),_(9,J.attributes,P),J.droppedAttributesCount>0?q(10,J.droppedAttributesCount):new Uint8Array(0),_(11,J.events,vQ),J.droppedEventsCount>0?q(12,J.droppedEventsCount):new Uint8Array(0),_(13,J.links,dQ),J.droppedLinksCount>0?q(14,J.droppedLinksCount):new Uint8Array(0),w(15,mQ(J.status)),J.flags!==void 0?v(16,J.flags):new Uint8Array(0)),uQ=(J)=>Z(w(1,XJ(J.scope)),_(2,J.spans,lQ),H(3,J.schemaUrl)),cQ=(J)=>Z(w(1,YJ(J.resource)),_(2,J.scopeSpans,uQ),H(3,J.schemaUrl)),XQ=(J)=>_(1,J.resourceSpans,cQ);var YQ=(J)=>Z(W(2,BigInt(J.startTimeUnixNano)),W(3,BigInt(J.timeUnixNano)),J.asDouble!==void 0?F(4,J.asDouble):new Uint8Array(0),J.asInt!==void 0?W(6,BigInt(J.asInt)):new Uint8Array(0),_(7,J.attributes,P),J.flags!==void 0?q(8,J.flags):new Uint8Array(0)),pQ=(J)=>{let Q=Z(...J.bucketCounts.map((Y)=>W(6,BigInt(Y)))),X=Z(...J.explicitBounds.map((Y)=>F(7,Y)));return Z(W(2,BigInt(J.startTimeUnixNano)),W(3,BigInt(J.timeUnixNano)),W(4,BigInt(J.count)),J.sum!==void 0?F(5,J.sum):new Uint8Array(0),Q,X,_(9,J.attributes,P),J.flags!==void 0?q(10,J.flags):new Uint8Array(0),J.min!==void 0?F(11,J.min):new Uint8Array(0),J.max!==void 0?F(12,J.max):new Uint8Array(0))},iQ=(J)=>_(1,J.dataPoints,YQ),nQ=(J)=>Z(_(1,J.dataPoints,YQ),q(2,J.aggregationTemporality),JJ(3,J.isMonotonic)),aQ=(J)=>Z(_(1,J.dataPoints,pQ),q(2,J.aggregationTemporality)),rQ=(J)=>Z(K(1,J.name),H(2,J.description),H(3,J.unit),J.gauge!==void 0?w(5,iQ(J.gauge)):new Uint8Array(0),J.sum!==void 0?w(7,nQ(J.sum)):new Uint8Array(0),J.histogram!==void 0?w(9,aQ(J.histogram)):new Uint8Array(0)),sQ=(J)=>Z(w(1,XJ(J.scope)),_(2,J.metrics,rQ),H(3,J.schemaUrl)),tQ=(J)=>Z(w(1,YJ(J.resource)),_(2,J.scopeMetrics,sQ),H(3,J.schemaUrl)),ZQ=(J)=>_(1,J.resourceMetrics,tQ);var oQ=(J)=>Z(W(1,BigInt(J.timeUnixNano)),J.severityNumber!==void 0?q(2,J.severityNumber):new Uint8Array(0),H(3,J.severityText),J.body!==void 0?w(5,QJ(J.body)):new Uint8Array(0),_(6,J.attributes,P),J.droppedAttributesCount!==void 0&&J.droppedAttributesCount>0?q(7,J.droppedAttributesCount):new Uint8Array(0),J.flags!==void 0?v(8,J.flags):new Uint8Array(0),J.traceId!==void 0&&J.traceId!==""?U(9,J.traceId):new Uint8Array(0),J.spanId!==void 0&&J.spanId!==""?U(10,J.spanId):new Uint8Array(0),J.observedTimeUnixNano!==void 0?W(11,BigInt(J.observedTimeUnixNano)):new Uint8Array(0)),eQ=(J)=>Z(w(1,XJ(J.scope)),_(2,J.logRecords,oQ),H(3,J.schemaUrl)),JX=(J)=>Z(w(1,YJ(J.resource)),_(2,J.scopeLogs,eQ),H(3,J.schemaUrl)),_Q=(J)=>_(1,J.resourceLogs,JX);class M extends $Q()("effect/observability/OtlpSerialization"){}var XX=ZJ(M,{traces:(J)=>l(J),metrics:(J)=>l(J),logs:(J)=>l(J)}),YX=ZJ(M,{traces:(J)=>d(XQ(J),"application/x-protobuf"),metrics:(J)=>d(ZQ(J),"application/x-protobuf"),logs:(J)=>d(_Q(J),"application/x-protobuf")});var IQ=E(function*(J){let Q=yield*M,X=yield*JQ(J.resource),Y={name:QQ(X)},$=yield*sJ({label:"OtlpLogger",url:J.url,headers:J.headers,maxBatchSize:J.maxBatchSize??1000,exportInterval:J.exportInterval??T(1),body:(B)=>Q.logs({resourceLogs:[{resource:X,scopeLogs:[{scope:Y,logRecords:B}]}]}),shutdownTimeout:J.shutdownTimeout??T(3)}),G={excludeLogSpans:J.excludeLogSpans??!1,clock:yield*b};return HQ((B)=>{$.push(_X(B,G))})}),ZX=(J)=>WQ([IQ(J)],{mergeWithExisting:J.mergeWithExisting??!0}),_X=(J,Q)=>{let Y=Q.clock.currentTimeNanosUnsafe().toString(),$=J.date.getTime(),G=e(Object.entries(J.fiber.getRef(BQ)));if(G.push({key:"fiberId",value:{intValue:J.fiber.id}}),!Q.excludeLogSpans)for(let[V,r]of J.fiber.getRef(wQ))G.push({key:`logSpan.${V}`,value:{stringValue:`${$-r}ms`}});if(J.cause.reasons.length>0)G.push({key:"log.error",value:{stringValue:qQ(J.cause)}});let B=GQ(J.message),C={severityNumber:$X(J.logLevel),severityText:J.logLevel,timeUnixNano:Y,observedTimeUnixNano:Y,attributes:G,body:m(B.length===1?B[0]:B),droppedAttributesCount:0};if(J.fiber.currentSpan)C.traceId=J.fiber.currentSpan.traceId,C.spanId=J.fiber.currentSpan.spanId;return C},$X=(J)=>{switch(J){case"Trace":return A.SEVERITY_NUMBER_TRACE;case"Debug":return A.SEVERITY_NUMBER_DEBUG;case"Info":return A.SEVERITY_NUMBER_INFO;case"Warn":return A.SEVERITY_NUMBER_WARN;case"Error":return A.SEVERITY_NUMBER_ERROR;case"Fatal":return A.SEVERITY_NUMBER_FATAL;default:return A.SEVERITY_NUMBER_UNSPECIFIED}},A={SEVERITY_NUMBER_UNSPECIFIED:0,SEVERITY_NUMBER_TRACE:1,SEVERITY_NUMBER_TRACE2:2,SEVERITY_NUMBER_TRACE3:3,SEVERITY_NUMBER_TRACE4:4,SEVERITY_NUMBER_DEBUG:5,SEVERITY_NUMBER_DEBUG2:6,SEVERITY_NUMBER_DEBUG3:7,SEVERITY_NUMBER_DEBUG4:8,SEVERITY_NUMBER_INFO:9,SEVERITY_NUMBER_INFO2:10,SEVERITY_NUMBER_INFO3:11,SEVERITY_NUMBER_INFO4:12,SEVERITY_NUMBER_WARN:13,SEVERITY_NUMBER_WARN2:14,SEVERITY_NUMBER_WARN3:15,SEVERITY_NUMBER_WARN4:16,SEVERITY_NUMBER_ERROR:17,SEVERITY_NUMBER_ERROR2:18,SEVERITY_NUMBER_ERROR3:19,SEVERITY_NUMBER_ERROR4:20,SEVERITY_NUMBER_FATAL:21,SEVERITY_NUMBER_FATAL2:22,SEVERITY_NUMBER_FATAL3:23,SEVERITY_NUMBER_FATAL4:24};var UQ={};u(UQ,{logger:()=>n,layer:()=>qJ,create:()=>KQ});var GX=(J)=>J==="sessionID"?"session.id":J,PQ=(J)=>Object.fromEntries(Object.entries(J??{}).filter((Q)=>Q[1]!==void 0&&Q[1]!==null).map(([Q,X])=>[GX(Q),X])),qX=(J)=>{if(Array.isArray(J))return J.map((Q)=>String(Q)).join(" ");return J===void 0?"":String(J)},i=(J,Q,X,Y)=>{let $=PQ({...Q,...Y}),G=J(X);return Object.keys($).length?I.annotateLogs(G,$):G},n=R.make((J)=>{let Q=PQ(J.fiber.getRef($J.CurrentLogAnnotations)),X=J.date.getTime();for(let[B,C]of J.fiber.getRef($J.CurrentLogSpans))Q[`logSpan.${B}`]=`${X-C}ms`;if(J.cause.reasons.length>0)Q.cause=_J.pretty(J.cause);let Y=typeof Q.service==="string"?Q.service:void 0;if(Y)delete Q.service;let $=Y?GJ.create({service:Y}):GJ.Default,G=qX(J.message);switch(J.logLevel){case"Trace":case"Debug":return $.debug(G,Q);case"Warn":return $.warn(G,Q);case"Error":case"Fatal":return $.error(G,Q);default:return $.info(G,Q)}}),qJ=R.layer([n],{mergeWithExisting:!1}),KQ=(J={})=>({debug:(Q,X)=>i((Y)=>I.logDebug(Y),J,Q,X),info:(Q,X)=>i((Y)=>I.logInfo(Y),J,Q,X),warn:(Q,X)=>i((Y)=>I.logWarning(Y),J,Q,X),error:(Q,X)=>i((Y)=>I.logError(Y),J,Q,X),with:(Q)=>KQ({...J,...Q})});var a=x.OTEL_EXPORTER_OTLP_ENDPOINT,OQ=!!a,BX=crypto.randomUUID(),TQ=x.OTEL_EXPORTER_OTLP_HEADERS?x.OTEL_EXPORTER_OTLP_HEADERS.split(",").reduce((J,Q)=>{let[X,...Y]=Q.split("=");return J[X]=Y.join("="),J},{}):void 0;function BJ(){let J=FQ("main"),Q=(()=>{let X=process.env.OTEL_RESOURCE_ATTRIBUTES;if(!X)return{};try{return Object.fromEntries(X.split(",").map((Y)=>{let $=Y.indexOf("=");if($<1)throw Error("Invalid OTEL_RESOURCE_ATTRIBUTES entry");return[decodeURIComponent(Y.slice(0,$)),decodeURIComponent(Y.slice($+1))]}))}catch{return{}}})();return{serviceName:"qitqode",serviceVersion:CQ,attributes:{...Q,"deployment.environment.name":DQ,"qitqode.client":x.QITQODE_CLIENT,"qitqode.process_role":J.processRole,"qitqode.run_id":J.runID,"service.instance.id":BX}}}function wX(){return R.layer([n,p.make({url:`${a}/v1/logs`,resource:BJ(),headers:TQ})],{mergeWithExisting:!1}).pipe(z.provide(c.layerJson),z.provide(AQ.layer))}var HX=async()=>{let J=await import("./chunk-ntr0ezf2.js"),Q=await import("./chunk-cr5tknvb.js"),X=await import("./chunk-48gap82w.js"),{AsyncLocalStorageContextManager:Y}=await import("./chunk-pqg1wjb5.js").then((m)=>zQ(m.default,1)),{context:$}=await import("./chunk-kx88qekb.js").then((m)=>zQ(m.default,1)),G=new Y;return G.enable(),$.setGlobalContextManager(G),J.layer(()=>({resource:BJ(),spanProcessor:new X.BatchSpanProcessor(new Q.OTLPTraceExporter({url:`${a}/v1/traces`,headers:TQ}))}))},EQ=!a?qJ:z.unwrap(I.gen(function*(){let J=yield*I.promise(HX);return z.mergeAll(J,wX())})),WX={enabled:OQ,layer:EQ};var aX=z.makeMemoMapUnsafe();
2
+ import{Jq as mJ,Kq as vJ,Lq as dJ,Mq as lJ,Pq as d,Qq as l,Sq as uJ,Tq as cJ,Wq as pJ,Xq as iJ,Yq as nJ,Zq as aJ,_q as rJ,ar as AQ}from"./chunk-wqk1v8t0.js";import{Ds as FQ,es as CQ,fs as DQ}from"./chunk-gswhjd1h.js";import{Os as x,Xs as GJ}from"./chunk-59csnjc3.js";import{$D as BQ,AG as SJ,EE as z,EG as xJ,FD as qQ,FF as EJ,IG as fJ,JF as MJ,KE as b,MD as _J,ME as CJ,MF as oJ,QF as RJ,RL as j,SF as VJ,TG as E,VF as hJ,WE as DJ,XE as FJ,YE as AJ,YG as yJ,ZG as bJ,aE as wQ,aO as g,bO as eJ,cC as GQ,cG as jJ,dE as $J,eE as UJ,eO as HQ,fB as wJ,fH as I,fO as WQ,gM as o,gO as R,iB as HJ,iF as t,iG as NJ,jE as zJ,jF as OJ,lB as WJ,lF as y,mI as gJ,nB as $Q,qC as IJ,sA as tJ,tC as PJ,tG as kJ,uE as ZJ,vB as f,wC as T,xG as LJ,yF as TJ,zC as KJ}from"./chunk-g7v6sp3c.js";import{tO as zQ,vO as u,xO as S}from"./chunk-e0vrxetq.js";var IX={};u(IX,{resource:()=>BJ,layer:()=>EQ,enabled:()=>OQ,Observability:()=>WX});var p={};u(p,{make:()=>IQ,layer:()=>ZX});var VQ=AJ.pipe(FJ,DJ((J)=>{if(lJ(J)&&J.reason._tag==="StatusCodeError"&&J.reason.response.status===429){let Q=HJ(J.reason.response.headers["retry-after"]).pipe(WJ(CJ),wJ(()=>5));return t(T(Q))}return t(T(1))})),sJ=E(function*(J){let Q=yield*jJ(),X=f(Q,b),Y=f(Q,UJ),$=fJ(Q),G=KJ(IJ(J.exportInterval),PJ),B=void 0,C=nJ(f(Q,pJ)).pipe(iJ(NJ(rJ,!1)),aJ({schedule:VQ,times:3})),V=vJ({"user-agent":`effect-opentelemetry-${J.label}/0.0.0`});if(J.headers)V=dJ(mJ(J.headers),V);let r=uJ(J.url,{headers:V}),O=[],s=OJ(()=>{if(B!==void 0&&X.currentTimeMillisUnsafe()<B)return y;else if(B!==void 0)B=void 0;let h=O;if(J.maxBatchSize!=="disabled"){if(O.length===0)return y;O=[]}return C.execute(cJ(r,J.body(h))).pipe(EJ,SJ(!1))}).pipe(MJ((h)=>{if(B!==void 0)return y;return B=X.currentTimeMillisUnsafe()+60000,O=[],yJ("Disabling exporter for 60 seconds",h)}),bJ({package:"@effect/opentelemetry",module:J.label}));return yield*zJ(Y,s.pipe(RJ,kJ,VJ(J.shutdownTimeout))),yield*hJ(G).pipe(TJ(s),LJ,xJ(Y)),{push(h){if(B!==void 0)return;if(O.push(h),J.maxBatchSize!=="disabled"&&O.length>=J.maxBatchSize)gJ($(s),Y)}}});var jQ=(J)=>{let Q=J.attributes?e(Object.entries(J.attributes)):[];if(Q.push({key:"service.name",value:{stringValue:J.serviceName}}),J.serviceVersion)Q.push({key:"service.version",value:{stringValue:J.serviceVersion}});return{attributes:Q,droppedAttributesCount:0}},JQ=E(function*(J){let Q={...yield*g(o(eJ(j,j)),"OTEL_RESOURCE_ATTRIBUTES"),...J?.attributes},X=J?.serviceName??Q["service.name"]??(yield*g(j,"OTEL_SERVICE_NAME"));delete Q["service.name"];let Y=J?.serviceVersion??Q["service.version"]??(yield*g(o(j),"OTEL_SERVICE_VERSION"));return delete Q["service.version"],jQ({serviceName:X,serviceVersion:Y,attributes:Q})},oJ),QQ=(J)=>{let Q=J.attributes.find((X)=>X.key==="service.name");if(!Q||!Q.value.stringValue)throw Error("Resource does not contain a service name");return Q.value.stringValue},e=(J)=>{let Q=[];for(let[X,Y]of J)Q.push({key:X,value:m(Y)});return Q},m=(J)=>{if(Array.isArray(J))return{arrayValue:{values:J.map(m)}};switch(typeof J){case"string":return{stringValue:J};case"bigint":return{intValue:Number(J)};case"number":return Number.isInteger(J)?{intValue:J}:{doubleValue:J};case"boolean":return{boolValue:J};default:return{stringValue:tJ(J)}}};var c={};u(c,{layerProtobuf:()=>YX,layerJson:()=>XX,OtlpSerialization:()=>M});var N={Varint:0,Fixed64:1,LengthDelimited:2,Fixed32:5},k=(J,Q)=>J<<3|Q,D=(J)=>{let Q=[],X=typeof J==="bigint"?J:BigInt(J);while(X>0x7fn)Q.push(Number(X&0x7fn)|128),X>>=7n;return Q.push(Number(X)),new Uint8Array(Q)};var kQ=(J)=>{let Q=new Uint8Array(8);return new DataView(Q.buffer).setBigUint64(0,J,!0),Q},LQ=(J)=>{let Q=new Uint8Array(4);return new DataView(Q.buffer).setUint32(0,J,!0),Q},SQ=(J)=>{let Q=new Uint8Array(8);return new DataView(Q.buffer).setFloat64(0,J,!0),Q},xQ=(J)=>new TextEncoder().encode(J),fQ=(J)=>{let Q=new Uint8Array(J.length/2);for(let X=0;X<J.length;X+=2)Q[X/2]=parseInt(J.slice(X,X+2),16);return Q},Z=(...J)=>{let Q=J.reduce(($,G)=>$+G.length,0),X=new Uint8Array(Q),Y=0;for(let $ of J)X.set($,Y),Y+=$.length;return X},q=(J,Q)=>Z(D(k(J,N.Varint)),D(Q));var JJ=(J,Q)=>q(J,Q?1:0),W=(J,Q)=>Z(D(k(J,N.Fixed64)),kQ(Q)),v=(J,Q)=>Z(D(k(J,N.Fixed32)),LQ(Q)),F=(J,Q)=>Z(D(k(J,N.Fixed64)),SQ(Q)),L=(J,Q)=>Z(D(k(J,N.LengthDelimited)),D(Q.length),Q),K=(J,Q)=>L(J,xQ(Q)),U=(J,Q)=>L(J,fQ(Q)),w=(J,Q)=>L(J,Q),_=(J,Q,X)=>Z(...Q.map((Y)=>w(J,X(Y))));var H=(J,Q)=>Q!==void 0&&Q!==""?K(J,Q):new Uint8Array(0);var QJ=(J)=>{if(J.stringValue!==void 0&&J.stringValue!==null)return K(1,J.stringValue);if(J.boolValue!==void 0&&J.boolValue!==null)return JJ(2,J.boolValue);if(J.intValue!==void 0&&J.intValue!==null)return q(3,BigInt(J.intValue));if(J.doubleValue!==void 0&&J.doubleValue!==null)return F(4,J.doubleValue);if(J.arrayValue!==void 0)return w(5,bQ(J.arrayValue));if(J.kvlistValue!==void 0)return w(6,gQ(J.kvlistValue));if(J.bytesValue!==void 0)return L(7,J.bytesValue);return new Uint8Array(0)},bQ=(J)=>_(1,J.values,QJ),gQ=(J)=>_(1,J.values,P),P=(J)=>Z(K(1,J.key),w(2,QJ(J.value))),XJ=(J)=>Z(K(1,J.name),H(2,J.version),J.attributes?_(3,J.attributes,P):new Uint8Array(0),J.droppedAttributesCount?q(4,J.droppedAttributesCount):new Uint8Array(0)),YJ=(J)=>Z(_(1,J.attributes,P),J.droppedAttributesCount>0?q(2,J.droppedAttributesCount):new Uint8Array(0));var mQ=(J)=>Z(H(2,J.message),q(3,J.code)),vQ=(J)=>Z(W(1,BigInt(J.timeUnixNano)),K(2,J.name),_(3,J.attributes,P),J.droppedAttributesCount>0?q(4,J.droppedAttributesCount):new Uint8Array(0)),dQ=(J)=>Z(U(1,J.traceId),U(2,J.spanId),H(3,J.traceState),_(4,J.attributes,P),J.droppedAttributesCount>0?q(5,J.droppedAttributesCount):new Uint8Array(0),J.flags!==void 0?v(6,J.flags):new Uint8Array(0)),lQ=(J)=>Z(U(1,J.traceId),U(2,J.spanId),H(3,J.traceState),J.parentSpanId!==void 0?U(4,J.parentSpanId):new Uint8Array(0),K(5,J.name),q(6,J.kind),W(7,BigInt(J.startTimeUnixNano)),W(8,BigInt(J.endTimeUnixNano)),_(9,J.attributes,P),J.droppedAttributesCount>0?q(10,J.droppedAttributesCount):new Uint8Array(0),_(11,J.events,vQ),J.droppedEventsCount>0?q(12,J.droppedEventsCount):new Uint8Array(0),_(13,J.links,dQ),J.droppedLinksCount>0?q(14,J.droppedLinksCount):new Uint8Array(0),w(15,mQ(J.status)),J.flags!==void 0?v(16,J.flags):new Uint8Array(0)),uQ=(J)=>Z(w(1,XJ(J.scope)),_(2,J.spans,lQ),H(3,J.schemaUrl)),cQ=(J)=>Z(w(1,YJ(J.resource)),_(2,J.scopeSpans,uQ),H(3,J.schemaUrl)),XQ=(J)=>_(1,J.resourceSpans,cQ);var YQ=(J)=>Z(W(2,BigInt(J.startTimeUnixNano)),W(3,BigInt(J.timeUnixNano)),J.asDouble!==void 0?F(4,J.asDouble):new Uint8Array(0),J.asInt!==void 0?W(6,BigInt(J.asInt)):new Uint8Array(0),_(7,J.attributes,P),J.flags!==void 0?q(8,J.flags):new Uint8Array(0)),pQ=(J)=>{let Q=Z(...J.bucketCounts.map((Y)=>W(6,BigInt(Y)))),X=Z(...J.explicitBounds.map((Y)=>F(7,Y)));return Z(W(2,BigInt(J.startTimeUnixNano)),W(3,BigInt(J.timeUnixNano)),W(4,BigInt(J.count)),J.sum!==void 0?F(5,J.sum):new Uint8Array(0),Q,X,_(9,J.attributes,P),J.flags!==void 0?q(10,J.flags):new Uint8Array(0),J.min!==void 0?F(11,J.min):new Uint8Array(0),J.max!==void 0?F(12,J.max):new Uint8Array(0))},iQ=(J)=>_(1,J.dataPoints,YQ),nQ=(J)=>Z(_(1,J.dataPoints,YQ),q(2,J.aggregationTemporality),JJ(3,J.isMonotonic)),aQ=(J)=>Z(_(1,J.dataPoints,pQ),q(2,J.aggregationTemporality)),rQ=(J)=>Z(K(1,J.name),H(2,J.description),H(3,J.unit),J.gauge!==void 0?w(5,iQ(J.gauge)):new Uint8Array(0),J.sum!==void 0?w(7,nQ(J.sum)):new Uint8Array(0),J.histogram!==void 0?w(9,aQ(J.histogram)):new Uint8Array(0)),sQ=(J)=>Z(w(1,XJ(J.scope)),_(2,J.metrics,rQ),H(3,J.schemaUrl)),tQ=(J)=>Z(w(1,YJ(J.resource)),_(2,J.scopeMetrics,sQ),H(3,J.schemaUrl)),ZQ=(J)=>_(1,J.resourceMetrics,tQ);var oQ=(J)=>Z(W(1,BigInt(J.timeUnixNano)),J.severityNumber!==void 0?q(2,J.severityNumber):new Uint8Array(0),H(3,J.severityText),J.body!==void 0?w(5,QJ(J.body)):new Uint8Array(0),_(6,J.attributes,P),J.droppedAttributesCount!==void 0&&J.droppedAttributesCount>0?q(7,J.droppedAttributesCount):new Uint8Array(0),J.flags!==void 0?v(8,J.flags):new Uint8Array(0),J.traceId!==void 0&&J.traceId!==""?U(9,J.traceId):new Uint8Array(0),J.spanId!==void 0&&J.spanId!==""?U(10,J.spanId):new Uint8Array(0),J.observedTimeUnixNano!==void 0?W(11,BigInt(J.observedTimeUnixNano)):new Uint8Array(0)),eQ=(J)=>Z(w(1,XJ(J.scope)),_(2,J.logRecords,oQ),H(3,J.schemaUrl)),JX=(J)=>Z(w(1,YJ(J.resource)),_(2,J.scopeLogs,eQ),H(3,J.schemaUrl)),_Q=(J)=>_(1,J.resourceLogs,JX);class M extends $Q()("effect/observability/OtlpSerialization"){}var XX=ZJ(M,{traces:(J)=>l(J),metrics:(J)=>l(J),logs:(J)=>l(J)}),YX=ZJ(M,{traces:(J)=>d(XQ(J),"application/x-protobuf"),metrics:(J)=>d(ZQ(J),"application/x-protobuf"),logs:(J)=>d(_Q(J),"application/x-protobuf")});var IQ=E(function*(J){let Q=yield*M,X=yield*JQ(J.resource),Y={name:QQ(X)},$=yield*sJ({label:"OtlpLogger",url:J.url,headers:J.headers,maxBatchSize:J.maxBatchSize??1000,exportInterval:J.exportInterval??T(1),body:(B)=>Q.logs({resourceLogs:[{resource:X,scopeLogs:[{scope:Y,logRecords:B}]}]}),shutdownTimeout:J.shutdownTimeout??T(3)}),G={excludeLogSpans:J.excludeLogSpans??!1,clock:yield*b};return HQ((B)=>{$.push(_X(B,G))})}),ZX=(J)=>WQ([IQ(J)],{mergeWithExisting:J.mergeWithExisting??!0}),_X=(J,Q)=>{let Y=Q.clock.currentTimeNanosUnsafe().toString(),$=J.date.getTime(),G=e(Object.entries(J.fiber.getRef(BQ)));if(G.push({key:"fiberId",value:{intValue:J.fiber.id}}),!Q.excludeLogSpans)for(let[V,r]of J.fiber.getRef(wQ))G.push({key:`logSpan.${V}`,value:{stringValue:`${$-r}ms`}});if(J.cause.reasons.length>0)G.push({key:"log.error",value:{stringValue:qQ(J.cause)}});let B=GQ(J.message),C={severityNumber:$X(J.logLevel),severityText:J.logLevel,timeUnixNano:Y,observedTimeUnixNano:Y,attributes:G,body:m(B.length===1?B[0]:B),droppedAttributesCount:0};if(J.fiber.currentSpan)C.traceId=J.fiber.currentSpan.traceId,C.spanId=J.fiber.currentSpan.spanId;return C},$X=(J)=>{switch(J){case"Trace":return A.SEVERITY_NUMBER_TRACE;case"Debug":return A.SEVERITY_NUMBER_DEBUG;case"Info":return A.SEVERITY_NUMBER_INFO;case"Warn":return A.SEVERITY_NUMBER_WARN;case"Error":return A.SEVERITY_NUMBER_ERROR;case"Fatal":return A.SEVERITY_NUMBER_FATAL;default:return A.SEVERITY_NUMBER_UNSPECIFIED}},A={SEVERITY_NUMBER_UNSPECIFIED:0,SEVERITY_NUMBER_TRACE:1,SEVERITY_NUMBER_TRACE2:2,SEVERITY_NUMBER_TRACE3:3,SEVERITY_NUMBER_TRACE4:4,SEVERITY_NUMBER_DEBUG:5,SEVERITY_NUMBER_DEBUG2:6,SEVERITY_NUMBER_DEBUG3:7,SEVERITY_NUMBER_DEBUG4:8,SEVERITY_NUMBER_INFO:9,SEVERITY_NUMBER_INFO2:10,SEVERITY_NUMBER_INFO3:11,SEVERITY_NUMBER_INFO4:12,SEVERITY_NUMBER_WARN:13,SEVERITY_NUMBER_WARN2:14,SEVERITY_NUMBER_WARN3:15,SEVERITY_NUMBER_WARN4:16,SEVERITY_NUMBER_ERROR:17,SEVERITY_NUMBER_ERROR2:18,SEVERITY_NUMBER_ERROR3:19,SEVERITY_NUMBER_ERROR4:20,SEVERITY_NUMBER_FATAL:21,SEVERITY_NUMBER_FATAL2:22,SEVERITY_NUMBER_FATAL3:23,SEVERITY_NUMBER_FATAL4:24};var UQ={};u(UQ,{logger:()=>n,layer:()=>qJ,create:()=>KQ});var GX=(J)=>J==="sessionID"?"session.id":J,PQ=(J)=>Object.fromEntries(Object.entries(J??{}).filter((Q)=>Q[1]!==void 0&&Q[1]!==null).map(([Q,X])=>[GX(Q),X])),qX=(J)=>{if(Array.isArray(J))return J.map((Q)=>String(Q)).join(" ");return J===void 0?"":String(J)},i=(J,Q,X,Y)=>{let $=PQ({...Q,...Y}),G=J(X);return Object.keys($).length?I.annotateLogs(G,$):G},n=R.make((J)=>{let Q=PQ(J.fiber.getRef($J.CurrentLogAnnotations)),X=J.date.getTime();for(let[B,C]of J.fiber.getRef($J.CurrentLogSpans))Q[`logSpan.${B}`]=`${X-C}ms`;if(J.cause.reasons.length>0)Q.cause=_J.pretty(J.cause);let Y=typeof Q.service==="string"?Q.service:void 0;if(Y)delete Q.service;let $=Y?GJ.create({service:Y}):GJ.Default,G=qX(J.message);switch(J.logLevel){case"Trace":case"Debug":return $.debug(G,Q);case"Warn":return $.warn(G,Q);case"Error":case"Fatal":return $.error(G,Q);default:return $.info(G,Q)}}),qJ=R.layer([n],{mergeWithExisting:!1}),KQ=(J={})=>({debug:(Q,X)=>i((Y)=>I.logDebug(Y),J,Q,X),info:(Q,X)=>i((Y)=>I.logInfo(Y),J,Q,X),warn:(Q,X)=>i((Y)=>I.logWarning(Y),J,Q,X),error:(Q,X)=>i((Y)=>I.logError(Y),J,Q,X),with:(Q)=>KQ({...J,...Q})});var a=x.OTEL_EXPORTER_OTLP_ENDPOINT,OQ=!!a,BX=crypto.randomUUID(),TQ=x.OTEL_EXPORTER_OTLP_HEADERS?x.OTEL_EXPORTER_OTLP_HEADERS.split(",").reduce((J,Q)=>{let[X,...Y]=Q.split("=");return J[X]=Y.join("="),J},{}):void 0;function BJ(){let J=FQ("main"),Q=(()=>{let X=process.env.OTEL_RESOURCE_ATTRIBUTES;if(!X)return{};try{return Object.fromEntries(X.split(",").map((Y)=>{let $=Y.indexOf("=");if($<1)throw Error("Invalid OTEL_RESOURCE_ATTRIBUTES entry");return[decodeURIComponent(Y.slice(0,$)),decodeURIComponent(Y.slice($+1))]}))}catch{return{}}})();return{serviceName:"qitqode",serviceVersion:CQ,attributes:{...Q,"deployment.environment.name":DQ,"qitqode.client":x.QITQODE_CLIENT,"qitqode.process_role":J.processRole,"qitqode.run_id":J.runID,"service.instance.id":BX}}}function wX(){return R.layer([n,p.make({url:`${a}/v1/logs`,resource:BJ(),headers:TQ})],{mergeWithExisting:!1}).pipe(z.provide(c.layerJson),z.provide(AQ.layer))}var HX=async()=>{let J=await import("./chunk-ntr0ezf2.js"),Q=await import("./chunk-cr5tknvb.js"),X=await import("./chunk-48gap82w.js"),{AsyncLocalStorageContextManager:Y}=await import("./chunk-pqg1wjb5.js").then((m)=>zQ(m.default,1)),{context:$}=await import("./chunk-kx88qekb.js").then((m)=>zQ(m.default,1)),G=new Y;return G.enable(),$.setGlobalContextManager(G),J.layer(()=>({resource:BJ(),spanProcessor:new X.BatchSpanProcessor(new Q.OTLPTraceExporter({url:`${a}/v1/traces`,headers:TQ}))}))},EQ=!a?qJ:z.unwrap(I.gen(function*(){let J=yield*I.promise(HX);return z.mergeAll(J,wX())})),WX={enabled:OQ,layer:EQ};var aX=z.makeMemoMapUnsafe();
3
3
  export{qJ as Dq,UQ as Eq,EQ as Fq,WX as Gq,IX as Hq,aX as Iq};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Qd as y}from"./chunk-ytyzrqev.js";import{be as L}from"./chunk-f4mnp6xd.js";import{$g as N,Ch as w}from"./chunk-he9kpk9r.js";import"./chunk-vs3s49jw.js";import"./chunk-kre93a89.js";import"./chunk-060wbpz4.js";import"./chunk-zrhw1szj.js";import"./chunk-t8fjgkp8.js";import"./chunk-0egrckx0.js";import{Wk as q,dl as v}from"./chunk-qq9m8fxv.js";import"./chunk-2qm46qvn.js";import{El as k,Ol as O,wl as V,xl as A,yl as E}from"./chunk-tsmj98yf.js";import"./chunk-58f4y4b7.js";import"./chunk-rmsqb6r4.js";import"./chunk-qxdpgdfk.js";import"./chunk-6qwk6z87.js";import"./chunk-sa0rrreh.js";import"./chunk-ydgst3h8.js";import"./chunk-6tqbnxar.js";import"./chunk-0w19vmd7.js";import"./chunk-eewe7tx1.js";import"./chunk-37cbrnke.js";import"./chunk-wm9nh9nb.js";import"./chunk-scnbt714.js";import"./chunk-cqtkxwd8.js";import"./chunk-y3gy62q5.js";import"./chunk-az3nss5m.js";import"./chunk-p2fte9vz.js";import"./chunk-ggncq8w8.js";import"./chunk-t3w43rft.js";import"./chunk-eacpc64g.js";import"./chunk-27saej0r.js";import"./chunk-9009v4d0.js";import"./chunk-82xrfk5x.js";import"./chunk-wqk1v8t0.js";import"./chunk-vkjqy92f.js";import"./chunk-z0kbyr00.js";import"./chunk-sbjymf20.js";import"./chunk-dt3bsmfe.js";import"./chunk-vbfej8ds.js";import"./chunk-0tm6589k.js";import"./chunk-6yhn9syz.js";import"./chunk-wb05bp10.js";import"./chunk-wgkcyqn1.js";import"./chunk-59csnjc3.js";import{gt as P}from"./chunk-1bxfzd6r.js";import"./chunk-6p6m5956.js";import"./chunk-a48mx917.js";import"./chunk-3va85mbe.js";import"./chunk-w7a33cwa.js";import"./chunk-g7v6sp3c.js";import"./chunk-s2tc3qs0.js";import"./chunk-n6tqtk6h.js";import"./chunk-e0vrxetq.js";import{EOL as X}from"os";function U(C){let G=C.match(/^https?:\/\/[^/]+\/share\/([a-zA-Z0-9_-]+)$/);return G?G[1]:null}function M(C,G){try{return new URL(C).origin===new URL(G).origin}catch{return!1}}function S(C){let G=C.find((z)=>z.type==="session");if(!G)return null;let Z=new Map,Q=new Map;for(let z of C)if(z.type==="message")Z.set(z.data.id,z.data);else if(z.type==="part"){if(!Q.has(z.data.messageID))Q.set(z.data.messageID,[]);Q.get(z.data.messageID).push(z.data)}if(Z.size===0)return null;return{info:G.data,messages:Array.from(Z.values()).map((z)=>({info:z,parts:Q.get(z.id)??[]}))}}var m=L({command:"import <file>",describe:"import session data from JSON file or URL",builder:(C)=>{return C.positional("file",{describe:"path to JSON file or share URL",type:"string",demandOption:!0})},handler:async(C)=>{await y(process.cwd(),async()=>{let G;if(C.file.startsWith("http://")||C.file.startsWith("https://")){let J=U(C.file);if(!J){let Y=await w.runPromise(N.Service.use((R)=>R.url()));process.stdout.write(`Invalid URL format. Expected: ${Y}/share/<slug>`),process.stdout.write(X);return}let _=new URL(C.file).origin,$=await w.runPromise(N.Service.use((Y)=>Y.request())),j=M(C.file,$.baseUrl)?$.headers:{},W=$.api.data(J),K=await fetch(`${_}${W}`,{headers:j});if(!K.ok&&W!==`/api/share/${J}/data`)K=await fetch(`${_}/api/share/${J}/data`,{headers:j});if(!K.ok){process.stdout.write(`Failed to fetch share data: ${K.statusText}`),process.stdout.write(X);return}let H=await K.json(),B=S(H);if(!B){process.stdout.write(`Share not found or empty: ${J}`),process.stdout.write(X);return}G=B}else if(G=await P.readJson(C.file).catch(()=>{return}),!G){process.stdout.write(`File not found: ${C.file}`),process.stdout.write(X);return}if(!G){process.stdout.write("Failed to read session data"),process.stdout.write(X);return}let Q=v.Info.parse({...G.info,projectID:O.project.id}),z=v.toRow(Q);k.use((J)=>J.insert(V).values(z).onConflictDoUpdate({target:V.id,set:{project_id:z.project_id}}).run());for(let J of G.messages){let F=q.Info.parse(J.info),{id:_,sessionID:$,...j}=F;k.use((W)=>W.insert(A).values({id:_,session_id:z.id,time_created:F.time?.created??Date.now(),data:j}).onConflictDoNothing().run());for(let W of J.parts){let K=q.Part.parse(W),{id:H,sessionID:B,messageID:Y,...R}=K;k.use((T)=>T.insert(E).values({id:H,message_id:Y,session_id:z.id,data:R}).onConflictDoNothing().run())}}process.stdout.write(`Imported session: ${G.info.id}`),process.stdout.write(X)})}});export{S as transformShareData,M as shouldAttachShareAuthHeaders,U as parseShareUrl,m as ImportCommand};
2
+ import{Qd as y}from"./chunk-vkkz40je.js";import{be as L}from"./chunk-f4mnp6xd.js";import{$g as N,Ch as w}from"./chunk-1acn5me8.js";import"./chunk-vs3s49jw.js";import"./chunk-kre93a89.js";import"./chunk-060wbpz4.js";import"./chunk-zrhw1szj.js";import"./chunk-t8fjgkp8.js";import"./chunk-0egrckx0.js";import{Wk as q,dl as v}from"./chunk-k1qd8ecm.js";import"./chunk-bhg69t69.js";import{El as k,Ol as O,wl as V,xl as A,yl as E}from"./chunk-fv5mrdyc.js";import"./chunk-rdreeyv0.js";import"./chunk-rmsqb6r4.js";import"./chunk-7pckez5z.js";import"./chunk-k6981ysw.js";import"./chunk-sa0rrreh.js";import"./chunk-ydgst3h8.js";import"./chunk-6tqbnxar.js";import"./chunk-0w19vmd7.js";import"./chunk-eewe7tx1.js";import"./chunk-4y9wbfd2.js";import"./chunk-wm9nh9nb.js";import"./chunk-scnbt714.js";import"./chunk-cqtkxwd8.js";import"./chunk-y3gy62q5.js";import"./chunk-az3nss5m.js";import"./chunk-p2fte9vz.js";import"./chunk-ggncq8w8.js";import"./chunk-t3w43rft.js";import"./chunk-eacpc64g.js";import"./chunk-27saej0r.js";import"./chunk-b5ym419d.js";import"./chunk-29q89bge.js";import"./chunk-wqk1v8t0.js";import"./chunk-rwwvy89t.js";import"./chunk-z0kbyr00.js";import"./chunk-sbjymf20.js";import"./chunk-dt3bsmfe.js";import"./chunk-vbfej8ds.js";import"./chunk-0tm6589k.js";import"./chunk-fveaq0pb.js";import"./chunk-gswhjd1h.js";import"./chunk-wgkcyqn1.js";import"./chunk-59csnjc3.js";import{gt as P}from"./chunk-1bxfzd6r.js";import"./chunk-6p6m5956.js";import"./chunk-a48mx917.js";import"./chunk-3va85mbe.js";import"./chunk-w7a33cwa.js";import"./chunk-g7v6sp3c.js";import"./chunk-s2tc3qs0.js";import"./chunk-n6tqtk6h.js";import"./chunk-e0vrxetq.js";import{EOL as X}from"os";function U(C){let G=C.match(/^https?:\/\/[^/]+\/share\/([a-zA-Z0-9_-]+)$/);return G?G[1]:null}function M(C,G){try{return new URL(C).origin===new URL(G).origin}catch{return!1}}function S(C){let G=C.find((z)=>z.type==="session");if(!G)return null;let Z=new Map,Q=new Map;for(let z of C)if(z.type==="message")Z.set(z.data.id,z.data);else if(z.type==="part"){if(!Q.has(z.data.messageID))Q.set(z.data.messageID,[]);Q.get(z.data.messageID).push(z.data)}if(Z.size===0)return null;return{info:G.data,messages:Array.from(Z.values()).map((z)=>({info:z,parts:Q.get(z.id)??[]}))}}var m=L({command:"import <file>",describe:"import session data from JSON file or URL",builder:(C)=>{return C.positional("file",{describe:"path to JSON file or share URL",type:"string",demandOption:!0})},handler:async(C)=>{await y(process.cwd(),async()=>{let G;if(C.file.startsWith("http://")||C.file.startsWith("https://")){let J=U(C.file);if(!J){let Y=await w.runPromise(N.Service.use((R)=>R.url()));process.stdout.write(`Invalid URL format. Expected: ${Y}/share/<slug>`),process.stdout.write(X);return}let _=new URL(C.file).origin,$=await w.runPromise(N.Service.use((Y)=>Y.request())),j=M(C.file,$.baseUrl)?$.headers:{},W=$.api.data(J),K=await fetch(`${_}${W}`,{headers:j});if(!K.ok&&W!==`/api/share/${J}/data`)K=await fetch(`${_}/api/share/${J}/data`,{headers:j});if(!K.ok){process.stdout.write(`Failed to fetch share data: ${K.statusText}`),process.stdout.write(X);return}let H=await K.json(),B=S(H);if(!B){process.stdout.write(`Share not found or empty: ${J}`),process.stdout.write(X);return}G=B}else if(G=await P.readJson(C.file).catch(()=>{return}),!G){process.stdout.write(`File not found: ${C.file}`),process.stdout.write(X);return}if(!G){process.stdout.write("Failed to read session data"),process.stdout.write(X);return}let Q=v.Info.parse({...G.info,projectID:O.project.id}),z=v.toRow(Q);k.use((J)=>J.insert(V).values(z).onConflictDoUpdate({target:V.id,set:{project_id:z.project_id}}).run());for(let J of G.messages){let F=q.Info.parse(J.info),{id:_,sessionID:$,...j}=F;k.use((W)=>W.insert(A).values({id:_,session_id:z.id,time_created:F.time?.created??Date.now(),data:j}).onConflictDoNothing().run());for(let W of J.parts){let K=q.Part.parse(W),{id:H,sessionID:B,messageID:Y,...R}=K;k.use((T)=>T.insert(E).values({id:H,message_id:Y,session_id:z.id,data:R}).onConflictDoNothing().run())}}process.stdout.write(`Imported session: ${G.info.id}`),process.stdout.write(X)})}});export{S as transformShareData,M as shouldAttachShareAuthHeaders,U as parseShareUrl,m as ImportCommand};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{N as b,O as y,P as k,Q as S,R as D,S as x}from"./chunk-epmc4aht.js";import{Qd as m}from"./chunk-ytyzrqev.js";import{Rd as f,Sd as w,Vd as h}from"./chunk-2kh0tg92.js";import"./chunk-52xvhxek.js";import{be as u}from"./chunk-f4mnp6xd.js";import{eg as a}from"./chunk-bwadggys.js";import"./chunk-he9kpk9r.js";import"./chunk-vs3s49jw.js";import"./chunk-kre93a89.js";import"./chunk-060wbpz4.js";import"./chunk-zrhw1szj.js";import"./chunk-t8fjgkp8.js";import"./chunk-0egrckx0.js";import{Nj as p,dl as l}from"./chunk-qq9m8fxv.js";import"./chunk-2qm46qvn.js";import"./chunk-tsmj98yf.js";import"./chunk-58f4y4b7.js";import"./chunk-rmsqb6r4.js";import"./chunk-qxdpgdfk.js";import"./chunk-6qwk6z87.js";import"./chunk-sa0rrreh.js";import"./chunk-ydgst3h8.js";import"./chunk-6tqbnxar.js";import"./chunk-0w19vmd7.js";import"./chunk-eewe7tx1.js";import"./chunk-37cbrnke.js";import"./chunk-wm9nh9nb.js";import"./chunk-scnbt714.js";import"./chunk-cqtkxwd8.js";import"./chunk-y3gy62q5.js";import"./chunk-az3nss5m.js";import"./chunk-p2fte9vz.js";import"./chunk-ggncq8w8.js";import"./chunk-t3w43rft.js";import"./chunk-eacpc64g.js";import"./chunk-27saej0r.js";import"./chunk-9009v4d0.js";import"./chunk-82xrfk5x.js";import"./chunk-wqk1v8t0.js";import"./chunk-vkjqy92f.js";import"./chunk-z0kbyr00.js";import"./chunk-sbjymf20.js";import"./chunk-dt3bsmfe.js";import"./chunk-vbfej8ds.js";import"./chunk-0tm6589k.js";import"./chunk-6yhn9syz.js";import"./chunk-wb05bp10.js";import"./chunk-wgkcyqn1.js";import"./chunk-59csnjc3.js";import"./chunk-1bxfzd6r.js";import"./chunk-6p6m5956.js";import"./chunk-a48mx917.js";import"./chunk-3va85mbe.js";import"./chunk-w7a33cwa.js";import"./chunk-g7v6sp3c.js";import"./chunk-s2tc3qs0.js";import"./chunk-n6tqtk6h.js";import"./chunk-e0vrxetq.js";import{EOL as c}from"os";async function I(){a.empty(),h("Export session",{output:process.stderr});let t=[...l.list()];if(t.length===0)return;let o=await w({message:"Select session to export",maxItems:10,options:t.map((e)=>({label:e.title,value:e.id,hint:`${new Date(e.time.updated).toLocaleString()} \u2022 ${e.id.slice(-8)}`})),output:process.stderr});if(f(o))throw new a.CancelledError;return p.make(o)}var z=u({command:"export [sessionID]",describe:"export a complete session transcript as JSON or Markdown",builder:(t)=>t.positional("sessionID",{describe:"session id to export",type:"string"}).option("latest",{describe:"export the most recently updated session without prompting",type:"boolean",default:!1}).option("format",{alias:"f",describe:"output format (JSON defaults to stdout; Markdown defaults to a file in the project root)",choices:["json","markdown"],default:"json"}).option("output",{alias:"o",describe:"destination path, resolved from the current project root",type:"string"}).option("thinking",{describe:"include persisted assistant reasoning in Markdown",type:"boolean",default:!1}).option("tool-details",{describe:"include diagnostic tool inputs, outputs, and errors in Markdown",type:"boolean",default:!0}).option("assistant-metadata",{describe:"include agent, model, and duration metadata in Markdown",type:"boolean",default:!0}).option("sanitize",{describe:"redact sensitive transcript and file data",type:"boolean",default:!1}),handler:async(t)=>{await m(process.cwd(),async()=>{if(t.sessionID&&t.latest)throw Error("Use either a session ID or --latest, not both");let o=t.sessionID?p.make(t.sessionID):void 0;if(!o&&(t.latest||!process.stderr.isTTY))o=y()?.id;if(!o)o=await I();if(!o)throw Error("No sessions found in the current project");let e;try{e=await b(o)}catch{throw Error(`Session not found: ${o}`)}let r=t.sanitize?D(e):e,n=t.format,d=n==="json"?JSON.stringify(r,null,2)+c:x(r.info,r.messages,{thinking:t.thinking,toolDetails:t.toolDetails,assistantMetadata:t.assistantMetadata}),i=t.output??(n==="markdown"?k(r.info.id,n):void 0);if(!i){process.stdout.write(d);return}try{let s=await S(process.cwd(),i,d);process.stderr.write(`Session transcript written to ${s}${c}`)}catch(s){let E=s instanceof Error?s.message:String(s);throw Error(`Unable to write session transcript to ${i}: ${E}`)}})}});export{z as ExportCommand};
2
+ import{N as b,O as y,P as k,Q as S,R as D,S as x}from"./chunk-53jstmdp.js";import{Qd as m}from"./chunk-vkkz40je.js";import{Rd as f,Sd as w,Vd as h}from"./chunk-2kh0tg92.js";import"./chunk-52xvhxek.js";import{be as u}from"./chunk-f4mnp6xd.js";import{eg as a}from"./chunk-bwadggys.js";import"./chunk-1acn5me8.js";import"./chunk-vs3s49jw.js";import"./chunk-kre93a89.js";import"./chunk-060wbpz4.js";import"./chunk-zrhw1szj.js";import"./chunk-t8fjgkp8.js";import"./chunk-0egrckx0.js";import{Nj as p,dl as l}from"./chunk-k1qd8ecm.js";import"./chunk-bhg69t69.js";import"./chunk-fv5mrdyc.js";import"./chunk-rdreeyv0.js";import"./chunk-rmsqb6r4.js";import"./chunk-7pckez5z.js";import"./chunk-k6981ysw.js";import"./chunk-sa0rrreh.js";import"./chunk-ydgst3h8.js";import"./chunk-6tqbnxar.js";import"./chunk-0w19vmd7.js";import"./chunk-eewe7tx1.js";import"./chunk-4y9wbfd2.js";import"./chunk-wm9nh9nb.js";import"./chunk-scnbt714.js";import"./chunk-cqtkxwd8.js";import"./chunk-y3gy62q5.js";import"./chunk-az3nss5m.js";import"./chunk-p2fte9vz.js";import"./chunk-ggncq8w8.js";import"./chunk-t3w43rft.js";import"./chunk-eacpc64g.js";import"./chunk-27saej0r.js";import"./chunk-b5ym419d.js";import"./chunk-29q89bge.js";import"./chunk-wqk1v8t0.js";import"./chunk-rwwvy89t.js";import"./chunk-z0kbyr00.js";import"./chunk-sbjymf20.js";import"./chunk-dt3bsmfe.js";import"./chunk-vbfej8ds.js";import"./chunk-0tm6589k.js";import"./chunk-fveaq0pb.js";import"./chunk-gswhjd1h.js";import"./chunk-wgkcyqn1.js";import"./chunk-59csnjc3.js";import"./chunk-1bxfzd6r.js";import"./chunk-6p6m5956.js";import"./chunk-a48mx917.js";import"./chunk-3va85mbe.js";import"./chunk-w7a33cwa.js";import"./chunk-g7v6sp3c.js";import"./chunk-s2tc3qs0.js";import"./chunk-n6tqtk6h.js";import"./chunk-e0vrxetq.js";import{EOL as c}from"os";async function I(){a.empty(),h("Export session",{output:process.stderr});let t=[...l.list()];if(t.length===0)return;let o=await w({message:"Select session to export",maxItems:10,options:t.map((e)=>({label:e.title,value:e.id,hint:`${new Date(e.time.updated).toLocaleString()} \u2022 ${e.id.slice(-8)}`})),output:process.stderr});if(f(o))throw new a.CancelledError;return p.make(o)}var z=u({command:"export [sessionID]",describe:"export a complete session transcript as JSON or Markdown",builder:(t)=>t.positional("sessionID",{describe:"session id to export",type:"string"}).option("latest",{describe:"export the most recently updated session without prompting",type:"boolean",default:!1}).option("format",{alias:"f",describe:"output format (JSON defaults to stdout; Markdown defaults to a file in the project root)",choices:["json","markdown"],default:"json"}).option("output",{alias:"o",describe:"destination path, resolved from the current project root",type:"string"}).option("thinking",{describe:"include persisted assistant reasoning in Markdown",type:"boolean",default:!1}).option("tool-details",{describe:"include diagnostic tool inputs, outputs, and errors in Markdown",type:"boolean",default:!0}).option("assistant-metadata",{describe:"include agent, model, and duration metadata in Markdown",type:"boolean",default:!0}).option("sanitize",{describe:"redact sensitive transcript and file data",type:"boolean",default:!1}),handler:async(t)=>{await m(process.cwd(),async()=>{if(t.sessionID&&t.latest)throw Error("Use either a session ID or --latest, not both");let o=t.sessionID?p.make(t.sessionID):void 0;if(!o&&(t.latest||!process.stderr.isTTY))o=y()?.id;if(!o)o=await I();if(!o)throw Error("No sessions found in the current project");let e;try{e=await b(o)}catch{throw Error(`Session not found: ${o}`)}let r=t.sanitize?D(e):e,n=t.format,d=n==="json"?JSON.stringify(r,null,2)+c:x(r.info,r.messages,{thinking:t.thinking,toolDetails:t.toolDetails,assistantMetadata:t.assistantMetadata}),i=t.output??(n==="markdown"?k(r.info.id,n):void 0);if(!i){process.stdout.write(d);return}try{let s=await S(process.cwd(),i,d);process.stderr.write(`Session transcript written to ${s}${c}`)}catch(s){let E=s instanceof Error?s.message:String(s);throw Error(`Unable to write session transcript to ${i}: ${E}`)}})}});export{z as ExportCommand};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Bh as a,Ch as b}from"./chunk-he9kpk9r.js";import"./chunk-vs3s49jw.js";import"./chunk-kre93a89.js";import"./chunk-060wbpz4.js";import"./chunk-zrhw1szj.js";import"./chunk-t8fjgkp8.js";import"./chunk-0egrckx0.js";import"./chunk-qq9m8fxv.js";import"./chunk-2qm46qvn.js";import"./chunk-tsmj98yf.js";import"./chunk-58f4y4b7.js";import"./chunk-rmsqb6r4.js";import"./chunk-qxdpgdfk.js";import"./chunk-6qwk6z87.js";import"./chunk-sa0rrreh.js";import"./chunk-ydgst3h8.js";import"./chunk-6tqbnxar.js";import"./chunk-0w19vmd7.js";import"./chunk-eewe7tx1.js";import"./chunk-37cbrnke.js";import"./chunk-wm9nh9nb.js";import"./chunk-scnbt714.js";import"./chunk-cqtkxwd8.js";import"./chunk-y3gy62q5.js";import"./chunk-az3nss5m.js";import"./chunk-p2fte9vz.js";import"./chunk-ggncq8w8.js";import"./chunk-t3w43rft.js";import"./chunk-eacpc64g.js";import"./chunk-27saej0r.js";import"./chunk-9009v4d0.js";import"./chunk-82xrfk5x.js";import"./chunk-wqk1v8t0.js";import"./chunk-vkjqy92f.js";import"./chunk-z0kbyr00.js";import"./chunk-sbjymf20.js";import"./chunk-dt3bsmfe.js";import"./chunk-vbfej8ds.js";import"./chunk-0tm6589k.js";import"./chunk-6yhn9syz.js";import"./chunk-wb05bp10.js";import"./chunk-wgkcyqn1.js";import"./chunk-59csnjc3.js";import"./chunk-1bxfzd6r.js";import"./chunk-6p6m5956.js";import"./chunk-a48mx917.js";import"./chunk-3va85mbe.js";import"./chunk-w7a33cwa.js";import"./chunk-g7v6sp3c.js";import"./chunk-s2tc3qs0.js";import"./chunk-n6tqtk6h.js";import"./chunk-e0vrxetq.js";export{b as AppRuntime,a as AppLayer};
2
+ import{Bh as a,Ch as b}from"./chunk-1acn5me8.js";import"./chunk-vs3s49jw.js";import"./chunk-kre93a89.js";import"./chunk-060wbpz4.js";import"./chunk-zrhw1szj.js";import"./chunk-t8fjgkp8.js";import"./chunk-0egrckx0.js";import"./chunk-k1qd8ecm.js";import"./chunk-bhg69t69.js";import"./chunk-fv5mrdyc.js";import"./chunk-rdreeyv0.js";import"./chunk-rmsqb6r4.js";import"./chunk-7pckez5z.js";import"./chunk-k6981ysw.js";import"./chunk-sa0rrreh.js";import"./chunk-ydgst3h8.js";import"./chunk-6tqbnxar.js";import"./chunk-0w19vmd7.js";import"./chunk-eewe7tx1.js";import"./chunk-4y9wbfd2.js";import"./chunk-wm9nh9nb.js";import"./chunk-scnbt714.js";import"./chunk-cqtkxwd8.js";import"./chunk-y3gy62q5.js";import"./chunk-az3nss5m.js";import"./chunk-p2fte9vz.js";import"./chunk-ggncq8w8.js";import"./chunk-t3w43rft.js";import"./chunk-eacpc64g.js";import"./chunk-27saej0r.js";import"./chunk-b5ym419d.js";import"./chunk-29q89bge.js";import"./chunk-wqk1v8t0.js";import"./chunk-rwwvy89t.js";import"./chunk-z0kbyr00.js";import"./chunk-sbjymf20.js";import"./chunk-dt3bsmfe.js";import"./chunk-vbfej8ds.js";import"./chunk-0tm6589k.js";import"./chunk-fveaq0pb.js";import"./chunk-gswhjd1h.js";import"./chunk-wgkcyqn1.js";import"./chunk-59csnjc3.js";import"./chunk-1bxfzd6r.js";import"./chunk-6p6m5956.js";import"./chunk-a48mx917.js";import"./chunk-3va85mbe.js";import"./chunk-w7a33cwa.js";import"./chunk-g7v6sp3c.js";import"./chunk-s2tc3qs0.js";import"./chunk-n6tqtk6h.js";import"./chunk-e0vrxetq.js";export{b as AppRuntime,a as AppLayer};