@bkm016/basalt 0.1.7 → 0.1.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.
- package/README.md +1 -1
- package/{chunk-0039s4jt.js → chunk-02d3x4mj.js} +3 -3
- package/{chunk-sjjtxpg2.js → chunk-0xd9mnc2.js} +394 -341
- package/{chunk-npez1492.js → chunk-13gvs0ax.js} +2 -2
- package/{chunk-n981vx1t.js → chunk-1n7dat03.js} +6 -6
- package/{chunk-6ptv4g5e.js → chunk-1zj3zvw5.js} +3 -3
- package/{chunk-zxkq9m8e.js → chunk-29qrxygd.js} +2 -2
- package/{chunk-y8dkfpmj.js → chunk-30rjf7my.js} +4 -4
- package/{chunk-39vwrg8n.js → chunk-38g3gctw.js} +2 -2
- package/{chunk-benrzwea.js → chunk-4dw43syb.js} +1 -1
- package/{chunk-w67dvqtb.js → chunk-4gtgqcct.js} +2 -2
- package/chunk-66h5qpc6.js +479 -0
- package/{chunk-8wj32837.js → chunk-755sy11p.js} +1 -1
- package/chunk-7zkswxvk.js +2 -0
- package/{chunk-ebpyvs1d.js → chunk-82v8jh1h.js} +2 -2
- package/chunk-95964592.js +25 -0
- package/{chunk-gv7wqkey.js → chunk-9as0p561.js} +2 -2
- package/{chunk-fx7f4m3c.js → chunk-a1352w87.js} +1 -1
- package/{chunk-8wv5t0w6.js → chunk-a1rb1a48.js} +6 -6
- package/{chunk-bdy4jksd.js → chunk-a98wma9j.js} +1 -1
- package/{chunk-peja51xv.js → chunk-asyr3gnq.js} +2 -2
- package/{chunk-7hr6zw2m.js → chunk-ax04trym.js} +1 -1
- package/chunk-b2bxqeb4.js +2 -0
- package/{chunk-6kdgk70p.js → chunk-bdjr0kfr.js} +4 -4
- package/{chunk-dnx91jrd.js → chunk-bk4rpnm8.js} +2 -2
- package/{chunk-8x21n7y9.js → chunk-c0zfefq8.js} +1 -1
- package/{chunk-pg5nkf1y.js → chunk-c6q04xrd.js} +2 -2
- package/chunk-c71173py.js +25 -0
- package/{chunk-c7rcw9fb.js → chunk-cmwdjes8.js} +5 -5
- package/{chunk-j7yvh0ae.js → chunk-d0a1jxk5.js} +1 -1
- package/{chunk-0javrjcm.js → chunk-d5j74pcp.js} +22 -22
- package/{chunk-ca982n62.js → chunk-dfh9m9n7.js} +1 -1
- package/{chunk-s6dejhfj.js → chunk-dq01v5eq.js} +1 -1
- package/{chunk-ecf896fz.js → chunk-e1x629v0.js} +2 -2
- package/{chunk-053vb71h.js → chunk-en218k4y.js} +1 -1
- package/{chunk-ey15ye2h.js → chunk-fgwda4m0.js} +1 -1
- package/chunk-gbjn6d81.js +2 -0
- package/{chunk-n85qs7cs.js → chunk-gkf5jwvj.js} +1 -1
- package/{chunk-d48bfd2e.js → chunk-h1kb8b49.js} +2 -2
- package/{chunk-whj87h4r.js → chunk-hb4f2v34.js} +3 -3
- package/{chunk-10p3mb40.js → chunk-hbnmymaq.js} +1 -1
- package/{chunk-818nd6s1.js → chunk-jj4hqbrx.js} +2 -2
- package/{chunk-r8vvcp6c.js → chunk-jn5pqy5v.js} +1 -1
- package/{chunk-f544p9rh.js → chunk-jtsve11b.js} +10 -10
- package/chunk-m1eam0s5.js +2 -0
- package/{chunk-g0t9c3gv.js → chunk-mbpb5c7w.js} +1 -1
- package/{chunk-prgm07j4.js → chunk-msm9hmk9.js} +2 -2
- package/{chunk-dpz4hwqb.js → chunk-n0ybj4h9.js} +2 -2
- package/{chunk-z02sj1je.js → chunk-n2jcx65v.js} +2 -2
- package/{chunk-x4874m8e.js → chunk-nrsd810j.js} +2 -2
- package/chunk-pnspvnyd.js +2 -0
- package/chunk-pz2afna8.js +2 -0
- package/{chunk-f156y565.js → chunk-q9f4xb0w.js} +3 -3
- package/{chunk-arcqjt91.js → chunk-qaeyhe65.js} +1 -1
- package/chunk-qnkrrwmg.js +2 -0
- package/{chunk-063vbmtp.js → chunk-r4ttdkrz.js} +2 -2
- package/{chunk-r9aatvwm.js → chunk-stj493dn.js} +2 -2
- package/{chunk-q9dd6fhj.js → chunk-tevejprz.js} +4 -4
- package/{chunk-75434aay.js → chunk-v3ee9z3f.js} +1 -1
- package/chunk-vtqr7dm8.js +3 -0
- package/chunk-xh444pfn.js +16 -0
- package/{chunk-y69ewdn2.js → chunk-ypqjfv3a.js} +2 -2
- package/{chunk-d6p2hgxh.js → chunk-zc9ar0r4.js} +1 -1
- package/{chunk-s7skpgm2.js → chunk-zyyzk5ha.js} +1 -1
- package/compiled.js +9 -9
- package/package.json +1 -1
- package/ui-test-worker.js +19 -19
- package/web/chunk-08sq3cwm.js +1 -0
- package/web/chunk-0pghpg4y.js +2 -0
- package/web/{chunk-z1geewdf.js → chunk-0zwc2rvh.js} +2 -2
- package/web/chunk-12qf1r6m.js +1 -0
- package/web/chunk-24fjnnee.js +1 -0
- package/web/chunk-24jhbz82.js +24 -0
- package/web/{chunk-5wbnjjhg.js → chunk-2dvbeqt0.js} +1 -1
- package/web/chunk-2hrswh3d.js +2 -0
- package/web/chunk-2j2atyjw.js +1 -0
- package/web/{chunk-n754s8xd.js → chunk-2x4g9t37.js} +8 -8
- package/web/{chunk-tfn0rqg9.js → chunk-3ak5dg10.js} +25 -25
- package/web/chunk-3ecrkvr3.js +106 -0
- package/web/chunk-3h3g3ca3.js +1 -0
- package/web/chunk-3hr3ew9w.js +1 -0
- package/web/chunk-3pcrxg6m.js +1 -0
- package/web/{chunk-xckxtfp8.js → chunk-3pd0qt83.js} +72 -72
- package/web/chunk-3txxt0a7.js +1 -0
- package/web/chunk-43g4wd7a.js +1 -0
- package/web/chunk-4a6gdrbs.js +1 -0
- package/web/{chunk-twdy2f67.js → chunk-5a4mj3qz.js} +1 -1
- package/web/{chunk-q97hn4j5.js → chunk-5baeh8q7.js} +38 -38
- package/web/{chunk-4fm55fgb.js → chunk-5dr4tkem.js} +7 -7
- package/web/{chunk-wqsczy57.js → chunk-5jdrev9p.js} +9 -9
- package/web/{chunk-dg3p8db5.js → chunk-5v2c0aqk.js} +1 -1
- package/web/chunk-5z2n4z9x.css +1 -0
- package/web/{chunk-pjz30xcp.js → chunk-601k823s.js} +23 -23
- package/web/{chunk-2cem4sv7.js → chunk-60axh4sa.js} +25 -25
- package/web/chunk-66wb0p6e.js +62 -0
- package/web/{chunk-qcge7d6s.js → chunk-6e87m0nm.js} +2 -2
- package/web/chunk-6y55gk1n.js +1 -0
- package/web/chunk-79e08rk1.js +2 -0
- package/web/chunk-7qkav30b.js +2 -0
- package/web/chunk-7qq1ypvj.js +1 -0
- package/web/{chunk-h6k1x096.js → chunk-7tkgbbf9.js} +2 -2
- package/web/chunk-814kkkmq.js +8 -0
- package/web/chunk-8jcvdd5d.js +2 -0
- package/web/{chunk-gksf7cek.js → chunk-8w7fyb3v.js} +7 -7
- package/web/chunk-8w8atrdh.js +1 -0
- package/web/{chunk-czjk218p.js → chunk-8z0r0wtk.js} +62 -62
- package/web/chunk-935mjq1c.js +39 -0
- package/web/chunk-942g3eqn.js +1 -0
- package/web/{chunk-ht4mx2dt.js → chunk-98y92vmh.js} +9 -9
- package/web/chunk-9ctg0f30.js +3 -0
- package/web/chunk-9fnr00kv.js +4 -0
- package/web/{chunk-5nda24gv.js → chunk-9yfftz38.js} +1 -1
- package/web/chunk-a0ryzdnp.js +7 -0
- package/web/chunk-a61zrp66.js +1 -0
- package/web/{chunk-nfvqjzz5.js → chunk-af9evdza.js} +1 -1
- package/web/chunk-arnzrqnm.js +1 -0
- package/web/chunk-avxk6jpc.js +2 -0
- package/web/{chunk-c01176kn.js → chunk-awkdw9rw.js} +2 -2
- package/web/{chunk-sy7e4dmq.js → chunk-b5h52neg.js} +1 -1
- package/web/chunk-bwy3e58v.js +1 -0
- package/web/{chunk-ja7w629n.js → chunk-c57f714b.js} +2 -2
- package/web/chunk-c6yacwbc.js +30 -0
- package/web/chunk-ctzkqx2g.js +169 -0
- package/web/chunk-db3twjvk.js +21 -0
- package/web/{chunk-femhej5w.js → chunk-ddyyc20r.js} +57 -57
- package/web/chunk-dnv8dx72.js +1 -0
- package/web/chunk-dwjmr0zj.js +2 -0
- package/web/chunk-dz7g1gnv.js +2 -0
- package/web/chunk-eadfxfkw.js +1 -0
- package/web/{chunk-d9wdsjkk.js → chunk-eqndhs21.js} +2 -2
- package/web/chunk-ewx42c11.js +55 -0
- package/web/chunk-f7jpakwh.js +1 -0
- package/web/{chunk-4sve9xrj.js → chunk-ff1pmd3g.js} +1 -1
- package/web/chunk-fjb3ksfd.js +78 -0
- package/web/chunk-fpb2dd2d.js +2 -0
- package/web/{chunk-fv6vm14n.js → chunk-frnh4zqf.js} +2 -2
- package/web/chunk-gn8kyz76.js +7 -0
- package/web/chunk-gv99c8zv.js +1 -0
- package/web/chunk-h0767tjv.js +1 -0
- package/web/chunk-hqynf99g.js +1 -0
- package/web/{chunk-jam45rqg.js → chunk-jccz14ye.js} +2 -2
- package/web/chunk-kcjz03h5.js +2 -0
- package/web/chunk-ket6g0yd.js +1 -0
- package/web/chunk-m9q5nr8f.js +1 -0
- package/web/chunk-mbwwj216.js +1 -0
- package/web/chunk-mdfksj61.js +1 -0
- package/web/chunk-me7dza1c.js +1 -0
- package/web/{chunk-gyp6v7jd.js → chunk-myd6sc76.js} +2 -2
- package/web/{chunk-sf101c23.js → chunk-mykrm8ba.js} +2 -2
- package/web/chunk-mzzaet63.js +1 -0
- package/web/chunk-n0wazxgz.js +1 -0
- package/web/chunk-nnyc889n.js +292 -0
- package/web/{chunk-e8yj05t1.js → chunk-nvpp0ghj.js} +6 -6
- package/web/chunk-nvt9tkt4.js +1139 -0
- package/web/{chunk-sn3tkwme.js → chunk-p9hfcamx.js} +37 -37
- package/web/chunk-ph1dgffm.js +1 -0
- package/web/chunk-q34as3v6.js +1 -0
- package/web/{chunk-sd3cdqcm.js → chunk-qh62nkem.js} +2 -2
- package/web/{chunk-j1bw5v1g.js → chunk-qq6m2my8.js} +2 -2
- package/web/{chunk-tmndcktk.js → chunk-qsqtwf34.js} +15 -15
- package/web/chunk-qz6r9v1z.js +1 -0
- package/web/chunk-rad2s9ha.js +1 -0
- package/web/{chunk-y99ed8rd.js → chunk-rasjtvsb.js} +16 -16
- package/web/chunk-rayf24gy.js +370 -0
- package/web/chunk-rrpn5r5w.js +2 -0
- package/web/chunk-s37beysw.js +1 -0
- package/web/chunk-s60s09mb.js +1 -0
- package/web/chunk-sk1wkgjw.js +4 -0
- package/web/chunk-spbs56wz.js +34 -0
- package/web/chunk-t893141g.js +2 -0
- package/web/chunk-tftc5v89.js +24 -0
- package/web/chunk-tfvcs2xx.js +1 -0
- package/web/chunk-tj1fn8v2.js +1 -0
- package/web/chunk-ts6jsfdk.js +41 -0
- package/web/chunk-v1exk5wd.js +324 -0
- package/web/chunk-veam6vk4.js +303 -0
- package/web/chunk-vqmj6peg.js +1 -0
- package/web/{chunk-t6sq85s6.js → chunk-vsjpnwsr.js} +2 -2
- package/web/{chunk-0whceqes.js → chunk-vvvd3grf.js} +2 -2
- package/web/{chunk-svh4n157.js → chunk-w3w18stt.js} +5 -5
- package/web/chunk-wdq2tp9e.js +1 -0
- package/web/chunk-wkf5xfyr.js +1 -0
- package/web/{chunk-4q7wf0wd.js → chunk-wzd2a4k5.js} +9 -9
- package/web/chunk-xa43ndfj.js +2 -0
- package/web/chunk-xh4xn1az.js +1 -0
- package/web/chunk-xx11yv61.js +89 -0
- package/web/chunk-xzwxcxb4.js +1 -0
- package/web/chunk-y1qty77a.js +1 -0
- package/web/{chunk-da7m1kva.js → chunk-y2rzeb4v.js} +2 -2
- package/web/chunk-ys2tns0p.js +1 -0
- package/web/chunk-z05x9cbm.js +1 -0
- package/web/chunk-zb2bkr7f.js +2 -0
- package/web/{chunk-aangfjqc.js → chunk-zdyys4ar.js} +38 -38
- package/web/chunk-zgavhnt8.js +1 -0
- package/web/index.html +1 -1
- package/worker.js +1 -1
- package/chunk-654cny9a.js +0 -480
- package/chunk-8gw5bvh3.js +0 -25
- package/chunk-8saewt61.js +0 -3
- package/chunk-a0c989ky.js +0 -2
- package/chunk-a5apjjcn.js +0 -16
- package/chunk-a81p46j7.js +0 -2
- package/chunk-agsfy9w7.js +0 -2
- package/chunk-d20p02ny.js +0 -2
- package/chunk-ejsneb6f.js +0 -2
- package/chunk-fmq3zwzk.js +0 -2
- package/chunk-rfb85nj7.js +0 -2
- package/chunk-rfdt992v.js +0 -25
- package/web/chunk-079091ar.js +0 -39
- package/web/chunk-083r4f80.js +0 -1
- package/web/chunk-0cng7r2x.js +0 -2
- package/web/chunk-0k0ande6.js +0 -1
- package/web/chunk-14deqqhr.js +0 -2
- package/web/chunk-1s53190z.js +0 -303
- package/web/chunk-2b63adsj.js +0 -89
- package/web/chunk-3baypnwn.js +0 -4
- package/web/chunk-4067nwjp.js +0 -19
- package/web/chunk-4vjnrz87.js +0 -34
- package/web/chunk-59678wmg.js +0 -1
- package/web/chunk-5k8sv4f5.js +0 -1
- package/web/chunk-5vjhvw1m.js +0 -2
- package/web/chunk-6bwgdvf6.js +0 -1
- package/web/chunk-6ft5pz3c.js +0 -1
- package/web/chunk-7c8rwqtx.js +0 -1
- package/web/chunk-7qzz025k.js +0 -1
- package/web/chunk-7xbaqqd7.css +0 -1
- package/web/chunk-80eyv2mk.js +0 -1
- package/web/chunk-89paytbk.js +0 -4
- package/web/chunk-8ceej2g7.js +0 -1
- package/web/chunk-8nyhy122.js +0 -1
- package/web/chunk-8r0s8tx7.js +0 -1
- package/web/chunk-989jq2h8.js +0 -2
- package/web/chunk-9w5tf22s.js +0 -1
- package/web/chunk-ahztazsg.js +0 -1
- package/web/chunk-bdydzbqk.js +0 -324
- package/web/chunk-c3nn0vvc.js +0 -1
- package/web/chunk-cpwtt6ny.js +0 -1
- package/web/chunk-d22wq71s.js +0 -1
- package/web/chunk-dsw5t58p.js +0 -1
- package/web/chunk-dv72fat3.js +0 -1
- package/web/chunk-dvvs1jjq.js +0 -3
- package/web/chunk-e131rg6p.js +0 -2
- package/web/chunk-ekw54h1q.js +0 -1
- package/web/chunk-geh05ghh.js +0 -55
- package/web/chunk-hwsvhst3.js +0 -1
- package/web/chunk-jfvxxp5c.js +0 -1
- package/web/chunk-k02b36g1.js +0 -62
- package/web/chunk-kjacapzd.js +0 -7
- package/web/chunk-kkfrs7d1.js +0 -41
- package/web/chunk-kkyn8yhj.js +0 -106
- package/web/chunk-mh4rx5cf.js +0 -1
- package/web/chunk-mz9b5bsa.js +0 -1
- package/web/chunk-n448vaba.js +0 -1
- package/web/chunk-n8j88qxy.js +0 -1
- package/web/chunk-nmpbsvwb.js +0 -2
- package/web/chunk-nws1s56b.js +0 -1
- package/web/chunk-p7126wwy.js +0 -7
- package/web/chunk-phnqnhj9.js +0 -1
- package/web/chunk-q3jevm51.js +0 -292
- package/web/chunk-qg31p6cn.js +0 -1
- package/web/chunk-qhm3cfq9.js +0 -1
- package/web/chunk-qsd595b9.js +0 -1
- package/web/chunk-r7frwjqx.js +0 -2
- package/web/chunk-rddft5ce.js +0 -1139
- package/web/chunk-rgbdf2m9.js +0 -370
- package/web/chunk-rsbkbg6x.js +0 -78
- package/web/chunk-s2bs5vxh.js +0 -2
- package/web/chunk-sgwccs54.js +0 -1
- package/web/chunk-sjh8gtm9.js +0 -30
- package/web/chunk-t3658ehb.js +0 -2
- package/web/chunk-t81p4wqc.js +0 -24
- package/web/chunk-tewmsd7t.js +0 -1
- package/web/chunk-tf57s7ry.js +0 -1
- package/web/chunk-thbqwq6b.js +0 -1
- package/web/chunk-tqr80b5w.js +0 -2
- package/web/chunk-tz4twwmw.js +0 -2
- package/web/chunk-v282r683.js +0 -24
- package/web/chunk-v4vjjtn7.js +0 -1
- package/web/chunk-vbwdwcdp.js +0 -1
- package/web/chunk-vjngfh0q.js +0 -1
- package/web/chunk-vnt34mkb.js +0 -1
- package/web/chunk-wbgkwxrc.js +0 -1
- package/web/chunk-wjbk50hn.js +0 -2
- package/web/chunk-wjy848e2.js +0 -1
- package/web/chunk-wvfmmw1v.js +0 -8
- package/web/chunk-x1jm4zsg.js +0 -1
- package/web/chunk-xbpc6x9m.js +0 -169
- package/web/chunk-xce8n339.js +0 -1
- package/web/chunk-xmsb2g71.js +0 -1
- package/web/chunk-xtss82z2.js +0 -1
package/chunk-8gw5bvh3.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{Database as l}from"bun:sqlite";import{chmodSync as I,closeSync as h,existsSync as f,openSync as N,rmSync as L}from"fs";var x=2,O=1,Ho="basalt-search.db",He=0,Tt=1;function c(e){let t=new l(":memory:");try{for(let r of e)t.run(r);return!0}catch{return!1}finally{t.close()}}var E;function qo(){if(E)return E;let e=c(["CREATE VIRTUAL TABLE f USING fts5(text)"]),t=e&&c(["CREATE VIRTUAL TABLE f USING fts5(text, tokenize='trigram')"]);return E={fts5:e,trigram:t,trigramDiacritics:t&&c(["CREATE VIRTUAL TABLE f USING fts5(text, tokenize='trigram remove_diacritics 1')"]),contentlessDelete:e&&c(["CREATE VIRTUAL TABLE f USING fts5(text, content='', contentless_delete=1)","INSERT INTO f (rowid, text) VALUES (1, 'probe')","DELETE FROM f WHERE rowid = 1"]),secureDelete:e&&c(["CREATE VIRTUAL TABLE f USING fts5(text)","INSERT INTO f (f, rank) VALUES ('secure-delete', 1)"])},E}function _(e){return{msg:e.trigram?"trigram":"unicode61",contentless:e.contentlessDelete}}function R(e){return JSON.stringify({schema:x,extractor:O,...e})}function p(e,t){return`text, ${e.contentless?"content='', contentless_delete=1, ":""}detail=full, tokenize="${t}"`}function k(e,t,r){let s=r.msg==="trigram"?t.trigramDiacritics?"trigram remove_diacritics 1":"trigram":"unicode61 remove_diacritics 2";e.transaction(()=>{if(e.run("CREATE TABLE IF NOT EXISTS meta (k TEXT PRIMARY KEY, v) WITHOUT ROWID"),e.run(`CREATE TABLE IF NOT EXISTS doc (
|
|
3
|
-
id INTEGER PRIMARY KEY,
|
|
4
|
-
hash INTEGER NOT NULL UNIQUE,
|
|
5
|
-
refs INTEGER NOT NULL,
|
|
6
|
-
len INTEGER NOT NULL,
|
|
7
|
-
bulk INTEGER NOT NULL
|
|
8
|
-
)`),e.run(`CREATE TABLE IF NOT EXISTS ref (
|
|
9
|
-
session_id TEXT NOT NULL,
|
|
10
|
-
seq INTEGER NOT NULL,
|
|
11
|
-
part INTEGER NOT NULL,
|
|
12
|
-
doc INTEGER NOT NULL,
|
|
13
|
-
kind INTEGER NOT NULL,
|
|
14
|
-
tool TEXT,
|
|
15
|
-
err INTEGER NOT NULL DEFAULT 0,
|
|
16
|
-
model TEXT,
|
|
17
|
-
time INTEGER NOT NULL,
|
|
18
|
-
PRIMARY KEY (session_id, seq, part)
|
|
19
|
-
) WITHOUT ROWID`),e.run("CREATE INDEX IF NOT EXISTS ref_doc ON ref(doc,time,kind,tool,err,model)"),e.run("CREATE INDEX IF NOT EXISTS ref_time ON ref(time,session_id,seq,part,doc,kind,tool,err,model)"),e.run("CREATE TABLE IF NOT EXISTS term (t TEXT PRIMARY KEY, n INTEGER NOT NULL) WITHOUT ROWID"),e.run("CREATE TABLE IF NOT EXISTS evicted (session_id TEXT PRIMARY KEY) WITHOUT ROWID"),e.run("CREATE TABLE IF NOT EXISTS backfill_todo (ord INTEGER PRIMARY KEY, session_id TEXT NOT NULL)"),e.run(`CREATE VIRTUAL TABLE IF NOT EXISTS fts USING fts5(${p(r,s)})`),e.run(`CREATE VIRTUAL TABLE IF NOT EXISTS fts_out USING fts5(${p(r,"unicode61 remove_diacritics 2")})`),e.run("CREATE VIRTUAL TABLE IF NOT EXISTS fts_vocab USING fts5vocab(fts, 'row')"),e.run("CREATE VIRTUAL TABLE IF NOT EXISTS fts_out_vocab USING fts5vocab(fts_out, 'row')"),t.secureDelete)e.run("INSERT INTO fts (fts, rank) VALUES ('secure-delete', 1)"),e.run("INSERT INTO fts_out (fts_out, rank) VALUES ('secure-delete', 1)");e.query("INSERT OR REPLACE INTO meta (k, v) VALUES ('fingerprint', ?)").run(R(r)),e.query("INSERT OR REPLACE INTO meta (k, v) VALUES ('layout', ?)").run(JSON.stringify(r))})()}function Jn(e){for(let t of["","-wal","-shm","-journal"])L(e+t,{force:!0})}function D(e){for(let t of["","-wal","-shm"])if(f(e+t))I(e+t,384)}function Xr(e,t){return e.query("SELECT v FROM main.meta WHERE k = ?").get(t)?.v??void 0}function qt(e,t,r){e.query("INSERT OR REPLACE INTO main.meta (k, v) VALUES (?, ?)").run(t,r)}function _i(e,t,r){let s=_(r),n=!1;if(f(e)){let o=!1;try{let u=new l(e);try{o=u.query("SELECT v FROM meta WHERE k = 'fingerprint'").get()?.v===R(s)}finally{u.close()}}catch{o=!1}if(!o)Jn(e),n=!0}if(!f(e))h(N(e,"a",384));let i=new l(e,{create:!0,strict:!0});return i.run("PRAGMA journal_mode = WAL"),i.run("PRAGMA synchronous = NORMAL"),i.run("PRAGMA busy_timeout = 5000"),k(i,r,s),D(e),i.query("ATTACH ? AS store").run(t),{db:i,layout:s,reset:n}}function Go(e,t){if(!f(e))return;let r;try{return r=new l(e,{readonly:!0,strict:!0}),r.run("PRAGMA busy_timeout = 5000"),r.query("ATTACH ? AS store").run(t),r.query("SELECT v FROM meta WHERE k = 'layout'").get(),r}catch{r?.close();return}}var Ai=49152,Ei=16384,g=64;function d(e){if(e.length<=65536)return e;return`${e.slice(0,49152)}
|
|
20
|
-
\u2026
|
|
21
|
-
${e.slice(-16384)}`}var b=/[\u3040-\u30FF\u3400-\u9FFF\uF900-\uFAFF\uAC00-\uD7AF]+/g,F=/[A-Za-z][a-z0-9]*(?:[A-Z][a-z0-9]+)+|[A-Z]{2,}[a-z0-9]+[A-Za-z0-9]*/g,U=/([a-z0-9])([A-Z])|([A-Z])([A-Z][a-z])/g;function m(e){return e.replace(b,(t)=>{if(t.length===1)return` ${t} `;let r=[];for(let s=0;s<t.length-1;s++)r.push(t.slice(s,s+2));return` ${r.join(" ")} `}).replace(F,(t)=>`${t} ${t.replace(U,"$1$3 $2$4")}`)}function S(e){return`${e} `}function gt(e){return e.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]+/g,"").normalize("NFC")}var C=/[\p{L}\p{N}\p{Co}]+/gu;function zo(e){return gt(m(e)).match(C)??[]}var Oe={user:1,assistant:2,thinking:3,tool_input:4,tool_output:5,error:6,extension:7,notice:8,attachment:9,title:10},Jr=Object.fromEntries(Object.entries(Oe).map(([e,t])=>[t,e])),M=1e4,v=-1,w=2048;function A(e){return e==="tool_output"||e==="attachment"}function T(e,t=[],r=0){if(r>6)return t;if(typeof e==="string")t.push(e);else if(typeof e==="number"||typeof e==="boolean")t.push(String(e));else if(Array.isArray(e))for(let s of e)T(s,t,r+1);else if(e&&typeof e==="object")for(let s of Object.values(e))T(s,t,r+1);return t}function Ke(e,t=!1){let r=[],s=e;switch(e.type){case"user":{if(typeof e.text==="string")r.push({part:0,kind:e.notices?"notice":"user",text:e.text});(Array.isArray(e.attachments)?e.attachments:[]).forEach((i,o)=>{let u=String(i?.name??""),a=i?.kind==="image"?u:`${u}
|
|
22
|
-
${String(i?.data??"")}`;r.push({part:1+o,kind:"attachment",text:a})});break}case"notice_pending":if(typeof e.notice?.text==="string")r.push({part:0,kind:"notice",text:e.notice.text});break;case"assistant":{let n=typeof e.model==="string"?e.model:void 0;if((Array.isArray(e.parts)?e.parts:[]).forEach((o,u)=>{if(o?.type==="text"||o?.type==="thinking"){if(typeof o.text==="string")r.push({part:u,kind:o.type==="text"?"assistant":"thinking",text:o.text,model:n})}else if(o?.type==="tool_call"){let a=typeof o.name==="string"?o.name:void 0;if(r.push({part:u,kind:"tool_input",tool:a,model:n,text:[a??"",...T(o.input)].join(`
|
|
23
|
-
`)}),typeof o.output==="string")r.push({part:M+u,kind:"tool_output",tool:a,model:n,text:o.output})}}),typeof e.error==="string")r.push({part:v,kind:"error",err:!0,model:n,text:e.error});break}case"tool_result":{let n=typeof e.name==="string"?e.name:void 0,i=typeof e.output==="string"?e.output:"",o=e.isError===!0;if(r.push({part:0,kind:"tool_output",tool:n,err:o,text:i}),o)r.push({part:1,kind:"error",tool:n,err:o,text:i.slice(0,w)});break}case"run":if(typeof s.error==="string")r.push({part:0,kind:"error",err:!0,text:s.error});break;case"extension":{let n=e.display;if(n&&typeof n.text==="string")r.push({part:0,kind:"extension",text:`${n.title??""}
|
|
24
|
-
${n.text}`});break}}if(!t)for(let n of r)n.text=d(n.text);return r.filter((n)=>n.text.trim())}function y(e){return e.trim()?[{part:0,kind:"title",text:d(e)}]:[]}function H(e,t){return BigInt.asIntN(64,Bun.hash.wyhash(`${e?"B":"M"}${t}`))}class jo{db;layout;readEntry;readTitle;previousModel;selectRefs;deleteRefs;insertRef;findDoc;insertDoc;increment;decrement;docRefs;deleteDoc;insertMsg;insertOut;deleteMsg;deleteOut;stats={entries:0,fields:0,bytes:0,newDocs:0,newBytes:0};outChanges=0;constructor(e,t){this.db=e;this.layout=t;this.readEntry=e.query("SELECT time, body FROM store.entries WHERE session_id = ? AND seq = ?"),this.readTitle=e.query("SELECT title, created FROM store.sessions WHERE id = ?"),this.previousModel=e.query("SELECT json_extract(body, '$.model') AS model FROM store.entries WHERE session_id = ? AND seq < ? AND json_extract(body, '$.type') = 'assistant' ORDER BY seq DESC LIMIT 1"),this.selectRefs=e.query("SELECT doc FROM main.ref WHERE session_id = ? AND seq = ?"),this.deleteRefs=e.query("DELETE FROM main.ref WHERE session_id = ? AND seq = ?"),this.insertRef=e.query("INSERT INTO main.ref (session_id, seq, part, doc, kind, tool, err, model, time) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"),this.findDoc=e.query("SELECT id FROM main.doc WHERE hash = ?"),this.insertDoc=e.query("INSERT INTO main.doc (hash, refs, len, bulk) VALUES (?, 1, ?, ?)"),this.increment=e.query("UPDATE main.doc SET refs = refs + 1 WHERE id = ?"),this.decrement=e.query("UPDATE main.doc SET refs = refs - 1 WHERE id = ?"),this.docRefs=e.query("SELECT refs, bulk FROM main.doc WHERE id = ?"),this.deleteDoc=e.query("DELETE FROM main.doc WHERE id = ?"),this.insertMsg=e.query("INSERT INTO main.fts (rowid, text) VALUES (?, ?)"),this.insertOut=e.query("INSERT INTO main.fts_out (rowid, text) VALUES (?, ?)"),this.deleteMsg=e.query("DELETE FROM main.fts WHERE rowid = ?"),this.deleteOut=e.query("DELETE FROM main.fts_out WHERE rowid = ?")}reindex(e,t){let r=0,s=[];if(t===0){let n=this.readTitle.get(e);if(n)r=n.created,s=y(n.title)}else{let n=this.readEntry.get(e,t);if(n)r=n.time,s=this.fields(e,t,n.body)}this.apply(e,t,r,s)}indexRow(e,t,r,s){this.apply(e,t,r,this.fields(e,t,s))}fields(e,t,r){let s;try{s=JSON.parse(r)}catch{return[]}if(!s||typeof s!=="object")return[];let n=Ke(s);if(s.type==="tool_result"&&n.length){let i=this.previousModel.get(e,t)?.model??void 0;if(i)for(let o of n)o.model=i}return n}apply(e,t,r,s){let n=this.selectRefs.all(e,t);if(n.length)this.deleteRefs.run(e,t);this.stats.entries++;for(let i of s){let o=A(i.kind),u=H(o,i.text);this.stats.fields++,this.stats.bytes+=i.text.length;let a=this.findDoc.get(u)?.id;if(a===void 0){if(a=Number(this.insertDoc.run(u,i.text.length,o?1:0).lastInsertRowid),o)this.insertOut.run(a,m(i.text)),this.outChanges++;else this.insertMsg.run(a,this.layout.msg==="trigram"?S(i.text):m(i.text));this.stats.newDocs++,this.stats.newBytes+=i.text.length}else this.increment.run(a);this.insertRef.run(e,t,i.part,a,Oe[i.kind],i.tool??null,i.err?1:0,i.model??null,r)}for(let{doc:i}of n)this.release(i)}release(e){this.decrement.run(e);let t=this.docRefs.get(e);if(!t||t.refs>0)return;if(this.deleteDoc.run(e),t.bulk)this.deleteOut.run(e),this.outChanges++;else this.deleteMsg.run(e)}}class Vo{db;page;clearRange;clearTail;upsert;constructor(e){this.db=e;this.page=e.query("SELECT term, doc FROM main.fts_out_vocab WHERE term > ? ORDER BY term LIMIT ?"),this.clearRange=e.query("DELETE FROM main.term WHERE t > ? AND t <= ?"),this.clearTail=e.query("DELETE FROM main.term WHERE t > ?"),this.upsert=e.query("INSERT OR REPLACE INTO main.term (t, n) VALUES (?, ?)")}step(e,t){let r=this.page.all(e,t),s=r.at(-1)?.term;if(r.length<t||s===void 0)this.clearTail.run(e);else this.clearRange.run(e,s);for(let{term:n,doc:i}of r)if(n.length<=g)this.upsert.run(n,i);return r.length<t?void 0:s}}
|
|
25
|
-
export{Ho,He,Tt,qo,Jn,Xr,qt,_i,Go,Ai,Ei,gt,zo,Oe,Jr,Ke,jo,Vo};
|
package/chunk-8saewt61.js
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
function n(t,r,o,i,s){if(i==="m")throw TypeError("Private method is not writable");if(i==="a"&&!s)throw TypeError("Private accessor was defined without a setter");if(typeof r==="function"?t!==r||!s:!r.has(t))throw TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(t,o):s?s.value=o:r.set(t,o),o}function e(t,r,o,i){if(o==="a"&&!i)throw TypeError("Private accessor was defined without a getter");if(typeof r==="function"?t!==r||!i:!r.has(t))throw TypeError("Cannot read private member from an object whose class did not declare it");return o==="m"?i:o==="a"?i.call(t):i?i.value:r.get(t)}function ze(t){return typeof t==="object"&&t!==null&&(("name"in t)&&t.name==="AbortError"||("message"in t)&&String(t.message).includes("FetchRequestCanceledException"))}var Ot=(t)=>{if(t instanceof Error)return t;if(typeof t==="object"&&t!==null){try{let r=Object.prototype.toString.call(t);if(r==="[object Error]"||r==="[object DOMException]"){let o=Error(t.message,t.cause?{cause:t.cause}:{});if(t.stack)o.stack=t.stack;if(t.cause&&!o.cause)o.cause=t.cause;if(t.name)o.name=t.name;return o}}catch{}try{return Error(JSON.stringify(t))}catch{}}return Error(t)};var c=(()=>{class t extends Error{}return t})();class Z extends c{constructor(t,r,o,i,s){super(`${Z.makeMessage(t,r,o)}`);this.status=t,this.headers=i,this.requestID=i?.get("request-id"),this.workspaceID=i?.get("anthropic-workspace-id"),this.error=r,this.type=s??null}static makeMessage(t,r,o){let i=r?.message?typeof r.message==="string"?r.message:JSON.stringify(r.message):r?JSON.stringify(r):o;if(t&&i)return`${t} ${i}`;if(t)return`${t} status code (no body)`;if(i)return i;return"(no status code or body)"}static generate(t,r,o,i){if(!t||!i)return new wt({message:o,cause:Ot(r)});let s=r,u=s?.error?.type;if(t===400)return new yn(t,s,o,i,u);if(t===401)return new bn(t,s,o,i,u);if(t===403)return new Sn(t,s,o,i,u);if(t===404)return new xn(t,s,o,i,u);if(t===409)return new wn(t,s,o,i,u);if(t===422)return new vn(t,s,o,i,u);if(t===429)return new _n(t,s,o,i,u);if(t>=500)return new An(t,s,o,i,u);return new Z(t,s,o,i,u)}}class _e extends Z{constructor({message:t}={}){super(void 0,void 0,t||"Request was aborted.",void 0)}}class wt extends Z{constructor({message:t,cause:r}){super(void 0,void 0,t||"Connection error.",void 0);if(r)this.cause=r}}class gn extends wt{constructor({message:t}={}){super({message:t??"Request timed out."})}}class xo extends c{constructor(t,{cause:r}={}){super(t??"Retryable error.");if(r!==void 0)this.cause=r}}class yn extends Z{}class bn extends Z{}class Sn extends Z{}class xn extends Z{}class wn extends Z{}class vn extends Z{}class _n extends Z{}class An extends Z{}var b=/^[a-z][a-z0-9+.-]*:/i,ii=(t)=>b.test(t),xe=(t)=>(xe=Array.isArray,xe(t)),wo=xe;function Cr(t){if(typeof t!=="object")return{};return t??{}}function vo(t){if(!t)return!0;for(let r in t)return!1;return!0}function l(t,r){return Object.prototype.hasOwnProperty.call(t,r)}function _o(t){return t!=null&&typeof t==="object"&&!Array.isArray(t)}var En=(t,r)=>{if(typeof r!=="number"||!Number.isInteger(r))throw new c(`${t} must be an integer`);if(r<0)throw new c(`${t} must be a positive integer`);return r};var Pn=(t)=>{try{return JSON.parse(t)}catch(r){return}};function vt(t){}var R=(t)=>{if(typeof globalThis.process<"u")return globalThis.process.env?.[t]?.trim()||void 0;if(typeof globalThis.Deno<"u")return globalThis.Deno.env?.get?.(t)?.trim()||void 0;return};function si(t){let r=0;for(let s of t)r+=s.length;let o=new Uint8Array(r),i=0;for(let s of t)o.set(s,i),i+=s.length;return o}var y;function Nt(t){let r;return(y??(r=new globalThis.TextEncoder,y=r.encode.bind(r)))(t)}var w;function _t(t){let r;return(w??(r=new globalThis.TextDecoder,w=r.decode.bind(r)))(t)}var Ir="warn",a={off:0,error:200,warn:300,info:400,debug:500},Tn=(t,r,o)=>{if(!t)return;if(l(a,t))return t;o.warn(`${r} was set to ${JSON.stringify(t)}, expected one of ${JSON.stringify(Object.keys(a))}`);return};function f(){}function p(t,r,o){if(!r||a[t]>a[o])return f;else return r[t].bind(r)}var O={error:f,warn:f,info:f,debug:f},h=new WeakMap;function x(t,r){let o=h.get(t);if(o&&o[0]===r)return o[1];let i={error:p("error",t,r),warn:p("warn",t,r),info:p("info",t,r),debug:p("debug",t,r)};return h.set(t,[r,i]),i}function T(t){let r=t.logger,o=t.logLevel??"off";if(!r)return O;return x(r,o)}var m,d;function ai(){let t=R("ANTHROPIC_LOG");if(!d||t!==m)m=t,d=x(console,Tn(t,"process.env['ANTHROPIC_LOG']",x(console,Ir))??Ir);return d}function Ze(t,r,o){if(t.debug===f)return;t.debug(r,E(o))}var E=(t)=>{if(t.options)t.options={...t.options},delete t.options.headers;if(t.headers)t.headers=Object.fromEntries((t.headers instanceof Headers?[...t.headers]:Object.entries(t.headers)).map(([r,o])=>[r,r.toLowerCase()==="authorization"||r.toLowerCase()==="api-key"||r.toLowerCase()==="x-api-key"||r.toLowerCase()==="cookie"||r.toLowerCase()==="set-cookie"?"***":o]));if("retryOfRequestLogID"in t){if(t.retryOfRequestLogID)t.retryOf=t.retryOfRequestLogID;delete t.retryOfRequestLogID}return t};function le(t,r){return t instanceof Z&&t.status===r}function L(t){return t instanceof Z&&typeof t.status==="number"&&t.status>=400&&t.status<500}function Dt(t){return L(t)&&!le(t,408)&&!le(t,409)&&!le(t,429)}function kn(t,r,o){return Math.min(r*2**t,o)}function li(t,r){return t+Math.random()*(r-t)}function Rn(t){return t*(1-Math.random()*0.25)}var A=(()=>{class t extends Error{constructor(r){let o=typeof r==="string"?r:r.map((i)=>{if(i.type==="text")return i.text;return`[${i.type}]`}).join(" ");super(o);this.name="ToolError",this.content=r}}return t})();var Ao=15000,g=5000;function Mr(t,r){if(!(t>=g))throw new c(`${r} must be at least ${g}ms (got ${t}); to run without memory sync, pass \`memorySyncIntervalMs: null\` to the worker instead`)}function Ut(){let t,r;return{promise:new Promise((i,s)=>{t=i,r=s}),resolve:t,reject:r}}
|
|
3
|
-
export{n,e,ze,Ot,c,Z,_e,wt,gn,xo,yn,bn,Sn,xn,wn,vn,_n,An,ii,xe,wo,Cr,vo,_o,En,Pn,vt,R,si,Nt,_t,Ir,Tn,T,ai,Ze,le,Dt,kn,li,Rn,A,Ao,Mr,Ut};
|
package/chunk-a0c989ky.js
DELETED
package/chunk-a5apjjcn.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{go,xt,at,x,cn,yo}from"./chunk-d20p02ny.js";import{n,e,c,Nt,_t,T,le,A,Ao,Mr,Ut}from"./chunk-8saewt61.js";import*as S from"fs/promises";import*as ne from"fs";import*as O from"path";import*as $e from"child_process";import*as ct from"crypto";import*as lt from"readline";function C(a){if(a.inputSchema.type!=="object")throw Error(`JSON schema for tool "${a.name}" must be an object, but got ${a.inputSchema.type}`);return{type:"custom",name:a.name,input_schema:a.inputSchema,description:a.description,run:a.run,parse:(r)=>r,...a.close?{close:a.close}:{}}}var F=at.promises,J=448,yt=384;function ae(a,r){let t=x.relative(a,r);return t===""||!t.startsWith(".."+x.sep)&&t!==".."&&!x.isAbsolute(t)}async function Ee(a,r){for(let t of a)if(ae(await X(x.resolve(t)),r))return t;return}var wt=40;function Z(a){let r=a?.code;return typeof r==="string"?r:void 0}async function X(a){let r=[],t=a,i=0;for(;;){let o;try{o=await F.realpath(t)}catch(s){let l;try{l=(await F.lstat(t)).isSymbolicLink()}catch(f){let d=Z(f);if(d!=="ENOENT"&&d!=="ENOTDIR")throw f;let m=x.dirname(t);if(m===t)throw f;r.push(x.basename(t)),t=m;continue}if(!l)throw s;if(++i>wt)throw Object.assign(Error("too many levels of symbolic links"),{code:"ELOOP"});t=x.resolve(x.dirname(t),await F.readlink(t));continue}return r.length?x.join(o,...r.reverse()):o}}async function Ae(a,r,t){let i=t?.allowedRoots??[],o=await X(x.resolve(a)),s;try{s=await X(x.resolve(o,r))}catch(f){throw new A(q(f,`path ${JSON.stringify(r)}`))}if(ae(o,s)||await Ee(i,s)!==void 0)return s;let l=i.length?"the session's working directory and its other permitted directories":"the session's working directory";throw new A(`path ${JSON.stringify(r)} is outside ${l}`)}async function be(a,r){let t=x.dirname(a),i=x.join(t,`.tmp-${process.pid}-${xt.randomUUID()}`),o=await F.stat(a).then((l)=>l.mode&511,()=>{return}),s;try{if(s=await F.open(i,"wx",yt),o!==void 0)await s.chmod(o);await s.writeFile(r,"utf-8"),await s.sync(),await s.close(),s=void 0,await F.rename(i,a)}catch(l){if(s)await s.close().catch(()=>{});throw await F.unlink(i).catch(()=>{}),l}}function q(a,r){let t=Z(a);switch(t){case"ENOENT":return`${r}: no such file or directory`;case"EACCES":case"EPERM":return`${r}: permission denied`;case"ENOTDIR":return`${r}: not a directory`;case"EISDIR":return`${r}: is a directory`;case"ELOOP":return`${r}: too many levels of symbolic links`;case"ENAMETOOLONG":return`${r}: file name too long`;case"ENOSPC":return`${r}: no space left on device`;case"EMFILE":case"ENFILE":return`${r}: too many open files`;default:return`${r}: ${t!==void 0?`i/o error (${t})`:"i/o error"}`}}var k=at.promises,gt=yo.promisify(go.execFile);async function St(a){let{client:r,sessionId:t}=a;if(!r)return async()=>{};let i=T(r),o=a.session;if(!o){if(t===void 0)return async()=>{};i.warn("AgentToolContext.sessionId is deprecated and costs an extra session fetch; fetch the session once and set `session` instead",{component:"agent-tool-context"}),o=await r.beta.sessions.retrieve(t)}let s=x.resolve(a.workdir,"skills"),l=[];for(let f of o.agent.skills)try{let d=await r.beta.skills.versions.retrieve(f.version,{skill_id:f.skill_id}),m=x.basename(d.name.trim());if(m===""||m==="."||m==="..")m=f.skill_id;let h=x.resolve(s,m);if(h!==s&&!h.startsWith(s+x.sep)){i.warn("skill name escapes the skills dir; skipping",{component:"agent-tool-context",name:d.name});continue}let u=await r.beta.skills.versions.download(d.id,{skill_id:f.skill_id});await k.rm(h,{recursive:!0,force:!0}),await k.mkdir(h,{recursive:!0,mode:J}),l.push(h),await Ce(u,h),i.info("downloaded skill",{component:"agent-tool-context",skill_id:f.skill_id,version:d.id,dest:h})}catch(d){i.warn("failed to download skill",{component:"agent-tool-context",skill_id:f.skill_id,error:String(d)})}return async()=>{for(let f of l)await k.rm(f,{recursive:!0,force:!0}).catch((d)=>{i.warn("failed to clean up skill",{component:"agent-tool-context",dest:f,error:String(d)})})}}function Et(a){for(let r of a){let t=r.trim();if(!t)continue;if(x.isAbsolute(t)||t.split(/[\\/]/).includes(".."))throw new c(`refusing to extract unsafe archive member: ${t}`)}}var Me="skill archive listing is inconsistent; refusing to extract",bt={unzip:new Set(["-","d","?"]),tar:new Set(["-","d","C"])};function xe(a){let r=a.split(`
|
|
3
|
-
`);if(r[r.length-1]==="")r.pop();return r}function Ot(a,r){return/^[\x20-\x7E]+$/.test(r)&&!/[\\^#]/.test(r)&&!(a==="unzip"&&r.startsWith("-"))}function Mt(a,r,t){let i=xe(r),o=xe(t);if(i.length!==o.length)throw new c(Me);let s=[],l=[];return i.forEach((f,d)=>{if(bt[a].has(o[d].charAt(0))){s.push(f);return}if(!Ot(a,f))throw new c(`refusing to extract archive: cannot safely exclude member ${JSON.stringify(f)}`);l.push(f)}),{plain:s,special:l}}async function De(a){for(let r of await k.readdir(a,{withFileTypes:!0}))if(r.isDirectory())await De(x.join(a,r.name));else if(!r.isFile())throw new c(Me)}async function Oe(a,r){try{let{stdout:t}=await gt(a,r);return t}catch(t){if(Z(t)==="ENOENT")throw new c(`skill extraction requires the \`${a}\` command, but it was not found on PATH`);throw t}}function vt(a){let r,t=!1;for(let i of a){let o=i.trim().split("/").filter((l)=>l!==""&&l!==".");if(o.length===0)continue;let s=o[0];if(r===void 0)r=s;else if(s!==r)return"";if(o.length>1)t=!0}return r!==void 0&&t?r:""}async function Ce(a,r){let t=x.join(r,`.skill-archive-${process.pid}-${Date.now()}`);if(!a.body)throw new c("skill download response had no body");await cn.promises.pipeline(cn.Readable.fromWeb(a.body),at.createWriteStream(t));let i=x.join(x.dirname(r),`.skill-stage-${process.pid}-${Date.now()}`),o=x.join(x.dirname(r),`.skill-exclude-${process.pid}-${Date.now()}`);try{let s=await It(t,4),l=s.length>=4&&s[0]===80&&s[1]===75&&s[2]===3&&s[3]===4,f=l?"unzip":"tar",d=await Oe(f,l?["-Z1",t]:["-tf",t]),m=await Oe(f,l?["-Z","--h","--t",t]:["-tvf",t]),{plain:h,special:u}=Mt(f,d,m);Et([...h,...u]);let _=vt(h);if(await k.mkdir(i,{recursive:!0,mode:J}),h.length>0)await Oe(f,await kt(f,t,i,u,o));await De(i);let E=_?x.join(i,_):i,D=await k.readdir(E).catch((M)=>{throw Z(M)==="ENOENT"?new c(Me):M});for(let M of D)await k.rename(x.join(E,M),x.join(r,M))}finally{await k.rm(t,{force:!0}),await k.rm(o,{force:!0}),await k.rm(i,{recursive:!0,force:!0})}}async function kt(a,r,t,i,o){let s=i.map((l)=>l.replace(/[*?[\\]/g,"\\$&"));if(a==="unzip")return["-oq",r,"-d",t,...s.length>0?["-x",...s]:[]];if(s.length===0)return["-xf",r,"-C",t];return await k.writeFile(o,s.join(`
|
|
4
|
-
`)+`
|
|
5
|
-
`,{flag:"wx",mode:384}),["-xf",r,"-C",t,"-X",o]}async function It(a,r){let t=await k.open(a,"r");try{let i=Buffer.alloc(r),{bytesRead:o}=await t.read(i,0,r,0);return i.subarray(0,o)}finally{await t.close()}}var g=at.promises,z=at.constants,Ue=448,Rt=384,Tt=448,ke=z.O_NOFOLLOW??0,Lt=z.O_NONBLOCK??0,y=(()=>{class a extends Error{constructor(r,t){super(`path ${JSON.stringify(t)} ${r}`);this.name="FileStoreError",this.reason=r,this.relPath=t}}return a.ESCAPES_ROOT="escapes the store root",a.IS_A_SYMLINK="is a symlink",a.NOT_A_FILE="is not a regular file",a.NOT_A_DIRECTORY="is not a directory",a.NOT_UTF8="is not valid utf-8",a.MOVE_DESTINATION_EXISTS="already exists",a})();function Ie(a){return a.startsWith("/")&&!a.split("/").includes("..")}var ve=(()=>{class a{constructor(r,t,i=!1){this.hashes=new Map,this.rootPath=r,this.removedOnDispose=t,this.decoder=i?new TextDecoder("utf-8",{fatal:!0}):void 0}static async open(r,t){if(!$t())throw Error("FileStore requires O_NOFOLLOW support on this platform");let i=!1;try{await g.lstat(r)}catch(o){if(o.code!=="ENOENT")throw o;i=!0}return new a(x.resolve(r),i,t?.utf8??!1)}async createRoot(){await At(this.rootPath)}root(){return{path:this.rootPath,removedOnDispose:this.removedOnDispose}}async dispose(){if(!this.removedOnDispose)return;await g.rm(this.rootPath,{recursive:!0,force:!0})}async put(r,t,i){let o=r.replace(/\\/g,"/");if(o.endsWith("/")||o.endsWith("/.")||o===""||o===".")throw new y(y.NOT_A_FILE,r);let s=this.resolveUnderRoot(r),l=typeof t==="string"?Nt(t):t;this.requireUtf8(r,l),await Fe(this.rootPath,x.dirname(s)),await Dt(s,l,i?.executable??!1)}async get(r){let t=this.resolveUnderRoot(r),i;try{i=await je(r,t)}catch(s){if(s.code==="ENOENT")return null;throw s}let o;try{let s=await i.readFile();o=new Uint8Array(s.buffer,s.byteOffset,s.byteLength)}finally{await i.close()}return this.requireUtf8(r,o),o}async ls(r="/"){let t=this.resolveUnderRoot(r);return new Set((await Pe(this.rootPath,r,t)).map(([i])=>i))}async findSymlinks(r="/"){let t=this.resolveUnderRoot(r);return Ft(this.rootPath,r,t)}async hashtree(r="/"){let t=this.resolveUnderRoot(r),i=ce.nowNs(),o=Object.create(null);for(let[s,l]of await Pe(this.rootPath,r,t)){let f=await this.hashViaCache(s,l,i);if(f!==null)o[s]=f}return o}async hashFile(r){let t=this.resolveUnderRoot(r),i;try{i=await g.lstat(t,{bigint:!0})}catch(s){if(s.code==="ENOENT")return null;throw s}if(i.isSymbolicLink())throw new y(y.IS_A_SYMLINK,r);if(!i.isFile())throw new y(y.NOT_A_FILE,r);let o=x.relative(this.rootPath,t).split(x.sep).join("/");return this.hashViaCache(o,t,ce.nowNs())}async move(r,t){let i=this.resolveUnderRoot(r),o=this.resolveUnderRoot(t);if(i===this.rootPath||o===this.rootPath)return;if(await g.stat(o).then(()=>!0,()=>!1))throw new y(y.MOVE_DESTINATION_EXISTS,t);await Fe(this.rootPath,x.dirname(o)),await g.rename(i,o)}async remove(r){let t=this.resolveUnderRoot(r);if(t===this.rootPath)return;let i;try{i=await g.lstat(t,{bigint:!0})}catch(o){if(o.code==="ENOENT")return;throw o}if(i.isDirectory())await g.rm(t,{recursive:!0,force:!0});else try{await g.unlink(t)}catch(o){if(o.code!=="ENOENT")throw o}}resolveUnderRoot(r){let t=r.replace(/\\/g,"/").replace(/^\/+/,""),i=t.split("/").filter((o)=>o!==""&&o!==".");if(x.posix.isAbsolute(t)||i.includes(".."))throw new y(y.ESCAPES_ROOT,r);return i.length===0?this.rootPath:x.join(this.rootPath,...i)}requireUtf8(r,t){if(!this.decoder)return;try{this.decoder.decode(t)}catch{throw new y(y.NOT_UTF8,r)}}async hashViaCache(r,t,i){let o;try{o=await g.lstat(t,{bigint:!0})}catch(f){if(f.code==="ENOENT")return null;throw f}if(!o.isFile())return null;let s=this.hashes.get(r),l;if(s!==void 0&&Wt(s,o))l=s.sha;else try{l=await ce.hashFile(t)}catch(f){let d=f.code;if(d==="ENOENT"||f instanceof y)return null;if(d==="ELOOP"||d==="EMLINK")return null;throw f}if(jt(o,i))this.hashes.set(r,{mtimeNs:o.mtimeNs,ctimeNs:o.ctimeNs,size:o.size,sha:l});return l}}return a.isPathLegal=Ie,a})();function $t(){return ke!==0}async function At(a){let r=[],t=a;for(;;){try{await g.stat(t);break}catch(o){let s=o.code;if(s!=="ENOENT"&&s!=="ENOTDIR"&&s!=="ELOOP")throw o}r.push(t);let i=x.dirname(t);if(i===t)break;t=i}for(let i of r.reverse())try{await g.mkdir(i,{mode:Ue})}catch(o){if(o.code!=="EEXIST")throw o}}async function Fe(a,r){let t=x.relative(a,r);if(t==="")return;let i=a;for(let o of t.split(x.sep)){i=x.join(i,o);try{await g.mkdir(i,{mode:Ue})}catch(s){if(s.code!=="EEXIST")throw s}}}async function Dt(a,r,t){let i=t?Tt:Rt,o=x.join(x.dirname(a),`.fs-${xt.randomBytes(8).toString("hex")}.tmp`),s;try{s=await g.open(o,z.O_WRONLY|z.O_CREAT|z.O_EXCL|ke,i),await s.writeFile(r),await s.close(),s=void 0,await g.rename(o,a)}catch(l){if(s)await s.close().catch(()=>{});throw await g.unlink(o).catch(()=>{}),l}}async function je(a,r){let t;try{t=await g.open(r,z.O_RDONLY|ke|Lt)}catch(i){let o=i.code;if(o==="ELOOP"||o==="EMLINK")throw new y(y.IS_A_SYMLINK,a);throw i}try{if(!(await t.stat()).isFile())throw new y(y.NOT_A_FILE,a)}catch(i){throw await t.close().catch(()=>{}),i}return t}async function Ct(a){let r=xt.createHash("sha256"),t=await je(x.basename(a),a),i=new Uint8Array(1048576);try{for(;;){let{bytesRead:o}=await t.read(i,0,i.length);if(o===0)break;r.update(i.subarray(0,o))}}finally{await t.close()}return r.digest("hex")}async function Pe(a,r,t){if(!await Pt(r,t))return[];let i=[];return await Be(t,(o,s)=>{if(s.isFile())i.push([x.relative(a,o).split(x.sep).join("/"),o])}),i.sort(),i}async function Ft(a,r,t){let i=(l)=>x.relative(a,l).split(x.sep).join("/"),o;try{o=await g.lstat(t,{bigint:!0})}catch(l){let f=l.code;if(f==="ENOENT"||f==="ENOTDIR")return new Set;throw l}if(o.isSymbolicLink())return new Set([i(t)]);if(!o.isDirectory())throw new y(y.NOT_A_DIRECTORY,r);let s=new Set;return await Be(t,(l,f)=>{if(f.isSymbolicLink())s.add(i(l))}),s}async function Pt(a,r){let t;try{t=await g.lstat(r,{bigint:!0})}catch(i){let o=i.code;if(o==="ENOENT"||o==="ENOTDIR")return!1;throw i}if(!t.isDirectory())throw new y(y.NOT_A_DIRECTORY,a);return!0}async function Be(a,r){let t=[a];while(t.length){let i=t.pop(),o;try{o=await g.readdir(i,{withFileTypes:!0})}catch(s){if(s.code==="ENOENT")continue;throw s}for(let s of o){let l=x.join(i,s.name);if(r(l,s),s.isDirectory()&&!s.isSymbolicLink())t.push(l)}}}function Wt(a,r){return r.mtimeNs===a.mtimeNs&&r.ctimeNs===a.ctimeNs&&r.size===a.size}function jt(a,r){return(a.mtimeNs>a.ctimeNs?a.mtimeNs:a.ctimeNs)<r-ce.timestampTrustMarginNs}var Bt=2000000000n,ce={hashFile:Ct,timestampTrustMarginNs:Bt,nowNs:()=>BigInt(Date.now())*1000000n},Ye=ve,We=Symbol.asyncDispose;if(We)Object.defineProperty(ve.prototype,We,{value:ve.prototype.dispose,configurable:!0,writable:!0});var w,R,fe,Q,de,p,G,he,N,qe,me,ze,Ge,Re,Ne,He,Ke,Te,Ve,Xe,ue,pe,Je,Ze,Yt=30000,K=".anthropic-memory-store",et=1;function Qe(a){return xt.createHash("sha256").update(`version ${et}
|
|
6
|
-
${a}`,"utf-8").digest("hex")}var qt=30000,zt=100,Gt=20,Ht=16,Kt=32,Vt=8,Xt=50;class P extends c{constructor(a,r){super(a);if(this.name="SessionMemoryError",r!==void 0)this.cause=r}}class tt{constructor(a,r,t){this.mode=a,this.cap=r,this.waiveWindow=t,this.attempted=0,this.capped=0,this.suppressed=0}takeSlot(){if(this.attempted>=this.cap)return this.capped++,!1;return this.attempted++,!0}}var Jt=(()=>{class a{constructor(r,t){w.add(this),R.set(this,void 0),fe.set(this,void 0),Q.set(this,void 0),de.set(this,void 0),p.set(this,void 0),G.set(this,void 0),he.set(this,!1),N.set(this,[]),n(this,R,r,"f"),n(this,fe,t.workdir,"f"),n(this,Q,t.syncIntervalMs??Ao,"f"),Mr(e(this,Q,"f"),"syncIntervalMs"),n(this,de,t.syncDeletions??"enabled","f"),n(this,p,T(r),"f"),n(this,G,Date.now(),"f")}get roots(){return e(this,N,"f").map((r)=>r.files.root().path)}get readOnlyRoots(){return e(this,N,"f").filter((r)=>r.readOnly).map((r)=>r.files.root().path)}async download(r){for(let t of r.resources){if(t.type!=="memory_store")continue;let i=e(this,w,"m",qe).call(this,t),o;try{if(o={memoryStoreId:t.memory_store_id,files:await Ye.open(i,{utf8:!0}),readOnly:t.access==="read_only",baseline:new Map,refusedShas:new Map,pendingDeletes:new Map},!o.files.root().removedOnDispose)throw new P(`something already exists at the memory store's path: ${i} (memory_store_id=${t.memory_store_id}); it must not exist when the session starts`);try{await o.files.createRoot()}catch(s){if(!H(s))throw s;throw new P(`cannot create the memory store's folder: ${i} (memory_store_id=${t.memory_store_id}): ${s}; the worker host must make this mount path writable`,s)}await e(this,w,"m",Ne).call(this,o),e(this,p,"f").info("downloaded memories",{count:o.baseline.size,memory_store_id:o.memoryStoreId,dest:o.files.root().path}),e(this,N,"f").push(o)}catch(s){if(o)await o.files.dispose().catch(()=>{});if(s instanceof P)throw s;throw new P(`failed to download memory store memory_store_id=${t.memory_store_id}: ${s}`,s)}}n(this,G,Date.now(),"f")}async finish(){if(e(this,he,"f"))throw new c("finish() was already called: it is the session's last sync and runs once");n(this,he,!0,"f"),await this.syncAll(!0)}async syncAll(r){await Promise.all(e(this,N,"f").map((t)=>e(this,w,"m",ze).call(this,t,r))),n(this,G,Date.now(),"f")}async syncIfDue(){if(Date.now()-e(this,G,"f")<e(this,Q,"f"))return;await this.syncAll(!1)}async flushWrites(r){await Promise.all(e(this,N,"f").map((t)=>e(this,w,"m",Ge).call(this,t,r)))}async dispose(){for(let r of e(this,N,"f")){let t=r.files.root();try{let i=await e(this,w,"m",me).call(this,r);if(!i.markerOk&&Object.keys(i.files).length>0){e(this,p,"f").warn(`${i.distrustReason}; leaving the memory store folder on disk`,{root:t.path,memory_store_id:r.memoryStoreId});continue}await r.files.dispose()}catch(i){if(!(i instanceof y)&&!H(i))throw i;e(this,p,"f").warn("failed to remove the memory store folder",{root:r.files.root().path,memory_store_id:r.memoryStoreId,error:String(i)});continue}if(t.removedOnDispose)e(this,p,"f").info("removed memory store dir",{dest:t.path,memory_store_id:r.memoryStoreId})}}}return R=new WeakMap,fe=new WeakMap,Q=new WeakMap,de=new WeakMap,p=new WeakMap,G=new WeakMap,he=new WeakMap,N=new WeakMap,w=new WeakSet,qe=function(t){if(t.mount_path){if(!Ie(t.mount_path))throw new P(`memory store mount_path is not a clean absolute path: ${JSON.stringify(t.mount_path)} (memory_store_id=${t.memory_store_id})`);return t.mount_path}return x.join(e(this,fe,"f"),"memory",t.name||t.memory_store_id)},me=async function(t){let i=await t.files.hashtree(),o=i[K];if(delete i[K],o===Qe(t.memoryStoreId))return{files:i,markerOk:!0,distrustReason:null};return{files:i,markerOk:!1,distrustReason:o!==void 0?"the marker file does not match this store":"the marker file is gone"}},ze=async function(t,i){try{let o=await e(this,w,"m",me).call(this,t),s=o.files;if(!o.markerOk){if(Object.keys(s).length>0){e(this,p,"f").warn(`${o.distrustReason}; leaving the memory store folder as found and not syncing`,{root:t.files.root().path,memory_store_id:t.memoryStoreId});return}await e(this,w,"m",Re).call(this,t,"the folder or its marker is gone");return}if(Object.keys(s).length===0&&t.baseline.size>1){await e(this,w,"m",Re).call(this,t,"every memory file is gone at once");return}let l=new Map;for await(let[u,_]of e(this,w,"m",ue).call(this,t.memoryStoreId))l.set(u,_);let f=new tt(e(this,de,"f"),Math.max(Vt,Math.min(Xt,Math.floor(t.baseline.size/4))),i),d=[],m=new Map,h=[...new Set([...l.keys(),...Object.keys(s),...t.baseline.keys()])].sort();for(let u of h){let _=l.get(u),E=s[u],D=t.baseline.get(u),M;if(E===void 0&&D!==void 0&&_!==void 0&&_.content_sha256===D&&!t.readOnly)M=await e(this,w,"m",Je).call(this,t,u,_,D,f);else M=await e(this,w,"m",He).call(this,t,u,_,E,d);if(M!==void 0)m.set(u,M)}if(t.baseline=m,await e(this,w,"m",Ve).call(this,t,d),f.suppressed>0)e(this,p,"f").debug("remote deletes are disabled; locally deleted memories stay on the server",{count:f.suppressed,memory_store_id:t.memoryStoreId});if(f.capped>0)e(this,p,"f").warn(`delete cap reached: ${f.mode==="log_only"?"would send":"sent"} ${f.attempted} deletes, held ${f.capped} for later syncs`,{memory_store_id:t.memoryStoreId})}catch(o){e(this,p,"f").warn("memory sync failed",{memory_store_id:t.memoryStoreId,error:String(o)})}},Ge=async function(t,i){let o=new Map,s=new Set,l=async()=>{if(t.readOnly)return;let f=await e(this,w,"m",me).call(this,t);if(!f.markerOk){e(this,p,"f").warn(`${f.distrustReason}; not uploading anything from the memory store folder`,{root:t.files.root().path,memory_store_id:t.memoryStoreId});return}for(let[h,u]of Object.entries(f.files))if(u!==t.baseline.get(h)&&t.refusedShas.get(h)!==u)o.set(h,u),s.add(h);if(o.size===0||i?.aborted)return;let d=new Map;for await(let[h,u]of e(this,w,"m",ue).call(this,t.memoryStoreId)){if(i?.aborted)return;d.set(h,u)}let m=[];for(let h of[...o.keys()].sort()){let u=o.get(h),_=t.baseline.get(h),E=d.get(h);if(E!==void 0&&E.content_sha256===u){t.baseline.set(h,E.content_sha256),s.delete(h);continue}if(E!==void 0&&E.content_sha256!==_){e(this,p,"f").warn("memory changed both locally and remotely; the flush leaves the remote version",{path:h,memory_store_id:t.memoryStoreId}),s.delete(h);continue}m.push([h,u,E])}await e(this,w,"m",Xe).call(this,t,m,s,i)};try{if(await Zt(l(),i),i?.aborted&&s.size>0)e(this,p,"f").warn(`memory flush cut off part-way; ${s.size} of ${o.size} changed files had not finished uploading`,{memory_store_id:t.memoryStoreId})}catch(f){e(this,p,"f").warn("memory flush failed",{memory_store_id:t.memoryStoreId,error:String(f)})}},Re=async function(t,i){e(this,p,"f").warn(`${i}; re-downloading the memory store folder instead of syncing`,{root:t.files.root().path,memory_store_id:t.memoryStoreId}),await t.files.createRoot(),await e(this,w,"m",Ne).call(this,t)},Ne=async function(t){t.baseline=new Map,t.pendingDeletes.clear(),await t.files.put(K,`version ${et}
|
|
7
|
-
${t.memoryStoreId}`);for await(let[i,o]of e(this,w,"m",ue).call(this,t.memoryStoreId,"full"))if(await e(this,w,"m",Te).call(this,t,i,o.content??""))t.baseline.set(i,o.content_sha256)},He=async function(t,i,o,s,l){let f=t.baseline.get(i);if(s!==void 0)t.pendingDeletes.delete(i);if(!o){if(s===void 0){t.pendingDeletes.delete(i);return}if(f!==void 0){if(s===f){let _=await e(this,w,"m",Ke).call(this,t,i,f);if(_===void 0)return;if(_===f)return f;s=_}if(t.readOnly)e(this,p,"f").warn("memory deleted remotely but edited locally; keeping the file, which a read-only store cannot push",{path:i,memory_store_id:t.memoryStoreId});else if(t.refusedShas.get(i)!==s)e(this,p,"f").info("memory deleted remotely but edited locally; re-creating it from the file",{path:i,memory_store_id:t.memoryStoreId})}if(t.readOnly)return;if(t.refusedShas.get(i)===s)return;return await e(this,w,"m",pe).call(this,t,i,s,void 0)}let d=o.content_sha256,m=d!==f,h=s!==void 0&&s!==f&&s!==d,u=!t.readOnly&&h;if(s===void 0&&f!==void 0){if(m)e(this,p,"f").warn("memory deleted locally but changed remotely; restoring the remote version",{path:i,memory_store_id:t.memoryStoreId}),t.pendingDeletes.delete(i),l.push([i,o]);return f}if(m){if(s===d)return d;if(h)e(this,p,"f").warn("memory changed both locally and remotely; keeping the remote version",{path:i,memory_store_id:t.memoryStoreId});return l.push([i,o]),f}if(u){if(t.refusedShas.get(i)===s)return d;return await e(this,w,"m",pe).call(this,t,i,s,o)??d}return d},Ke=async function(t,i,o){let s;try{s=await t.files.hashFile(i)}catch(l){if(!(l instanceof y)&&!H(l))throw l;return o}if(s===null)return;if(s!==o)return s;try{await t.files.remove(i)}catch(l){if(!(l instanceof y)&&!H(l))throw l;return e(this,p,"f").warn("failed to remove memory deleted remotely",{path:i,memory_store_id:t.memoryStoreId,error:String(l)}),o}return},Te=async function(t,i,o){try{await t.files.put(i,o)}catch(s){if(!(s instanceof y)&&!H(s))throw s;return e(this,p,"f").warn("failed to write memory",{path:i,memory_store_id:t.memoryStoreId,error:String(s)}),!1}return!0},Ve=async function(t,i){if(i.length===0)return;let o=async(f,d)=>{let m;try{m=await e(this,R,"f").beta.memoryStores.memories.retrieve(d.id,{memory_store_id:t.memoryStoreId,view:"full"})}catch(h){if(le(h,404))return;e(this,p,"f").warn("failed to fetch memory content",{path:f,memory_store_id:t.memoryStoreId,error:String(h)});return}if(await e(this,w,"m",Te).call(this,t,f,m.content??""))t.baseline.set(f,m.content_sha256)},s=i[Symbol.iterator](),l=async()=>{for(let[f,d]of s)await o(f,d)};await Promise.all(Array.from({length:Math.min(Ht,i.length)},l))},Xe=async function(t,i,o,s){let l=i[Symbol.iterator](),f=async()=>{for(let[d,m,h]of l){if(s?.aborted)return;let u=await e(this,w,"m",pe).call(this,t,d,m,h);if(o.delete(d),u!==void 0)t.baseline.set(d,u)}};await Promise.all(Array.from({length:Math.min(Kt,i.length)},f))},ue=async function*(t,i="basic"){let o=i==="basic"?zt:Gt;for await(let s of e(this,R,"f").beta.memoryStores.memories.list(t,{view:i,limit:o})){if(s.type!=="memory")continue;let l=s.path.replace(/^\/+/,"");if(l===K){e(this,p,"f").warn("the server listed the reserved marker path; skipping",{path:s.path,memory_store_id:t});continue}yield[l,s]}},pe=async function r(t,i,o,s){try{let l=await t.files.get(i);if(l===null)return;let f=_t(l),d=s?await e(this,R,"f").beta.memoryStores.memories.update(s.id,{memory_store_id:t.memoryStoreId,content:f,precondition:{type:"content_sha256",content_sha256:s.content_sha256}}):await e(this,R,"f").beta.memoryStores.memories.create(t.memoryStoreId,{path:"/"+i,content:f});return t.refusedShas.delete(i),d.content_sha256}catch(l){if(s&&le(l,404))return await e(this,w,"m",r).call(this,t,i,o,void 0);let f=l instanceof y||le(l,400)||le(l,413);if(s&&le(l,409))e(this,p,"f").warn("memory changed both locally and remotely; the upload was refused and the local edit loses",{path:i,memory_store_id:t.memoryStoreId});else if(f&&o!==void 0)t.refusedShas.set(i,o),e(this,p,"f").warn("the server rejected this memory file, so it stays un-synced until its content changes",{path:i,memory_store_id:t.memoryStoreId,rejection:String(l)});else e(this,p,"f").warn("failed to upload memory",{path:i,memory_store_id:t.memoryStoreId,error:String(l)});return}},Je=async function(t,i,o,s,l){if(l.mode==="disabled")return l.suppressed++,s;let f=t.pendingDeletes.get(i);if(f===void 0)f=Date.now(),t.pendingDeletes.set(i,f);if(!l.waiveWindow&&Date.now()-f<qt)return s;let d,m;try{d=await t.files.hashFile(K)===Qe(t.memoryStoreId),m=await t.files.hashFile(i)===null}catch(u){if(!(u instanceof y)&&!H(u))throw u;d=m=!1}if(!d)return s;if(!m)return t.pendingDeletes.delete(i),s;if(!l.takeSlot())return s;if(l.mode==="log_only")return e(this,p,"f").info("log-only: sync would delete this memory on the server",{path:i,memory_store_id:t.memoryStoreId}),s;let h=await e(this,w,"m",Ze).call(this,t,i,o,s);if(h===void 0)t.pendingDeletes.delete(i);return h},Ze=async function(t,i,o,s){try{await e(this,R,"f").beta.memoryStores.memories.delete(o.id,{memory_store_id:t.memoryStoreId,expected_content_sha256:s})}catch(l){if(le(l,404))return;if(le(l,409)||le(l,412))e(this,p,"f").warn("memory deleted locally but changed remotely; keeping the remote version",{path:i,memory_store_id:t.memoryStoreId});else e(this,p,"f").warn("failed to delete memory",{path:i,memory_store_id:t.memoryStoreId,error:String(l)});return s}e(this,p,"f").info("propagated local deletion",{path:i,memory_store_id:t.memoryStoreId});return},a})();function H(a){return typeof a==="object"&&a!==null&&typeof a.code==="string"}async function Zt(a,r){if(!r){await a;return}let t,i=new Promise((o)=>{if(t=o,r.aborted)o()});r.addEventListener("abort",t,{once:!0});try{await Promise.race([a,i])}finally{r.removeEventListener("abort",t)}}var ye,b,v,ee,W,I,Le,we,te,_e,ge,U,j,V,B,re,L,rt,it,nt=102400,ft=120000,Qt=262144,er=65536,ot=Buffer.from(`
|
|
8
|
-
`),ie=102400,tr=2000,rr=200;class dt extends c{constructor(a){super(`bash command timed out after ${a}ms`);this.name="BashTimeoutError",this.timeoutMs=a}}var ir=/\x1b\[[0-9;?]*[ -/]*[@-~]/g,nr=S.glob;function ht(a){return a===void 0?Qt:a}function Y(a){if(a===void 0)return;throw new c("The `unrestrictedPaths` option you passed to the agent toolset (AgentToolContext) is no longer supported. The toolset's file tools (read, write, edit, glob, grep) are now always confined to the working directory plus the directories listed in `allowedRoots`. Remove `unrestrictedPaths` from your context; to let the file tools reach any other directory, add it to `allowedRoots`.")}function Xr(a){return[ar(a),cr(a),dr(a),hr(a),ur(a),pr(a)]}async function oe(a,r){return Y(a.unrestrictedPaths),Ae(a.workdir,r,{allowedRoots:a.allowedRoots??[]})}function mt(a,r){return Ee(a.readOnlyRoots??[],r)}function or(){let a={};for(let[r,t]of Object.entries(process.env)){if(r.startsWith("ANTHROPIC_"))continue;a[r]=t}return a}var sr=(()=>{class a{constructor(r,t=or()){ye.add(this),b.set(this,void 0),v.set(this,""),ee.set(this,!1),W.set(this,!1),I.set(this,null),n(this,b,$e.spawn("/bin/bash",["--noprofile","--norc"],{cwd:r,env:{...t,PS1:"",PS2:"",TERM:"dumb"},stdio:["pipe","pipe","pipe"],detached:!0}),"f"),e(this,b,"f").stdout.setEncoding("utf8"),e(this,b,"f").stderr.setEncoding("utf8"),e(this,b,"f").stdout.on("data",(i)=>e(this,ye,"m",Le).call(this,i)),e(this,b,"f").stderr.on("data",(i)=>e(this,ye,"m",Le).call(this,i)),e(this,b,"f").once("close",()=>{n(this,W,!0,"f");let i=e(this,I,"f");n(this,I,null,"f"),i?.resolve()})}get closed(){return e(this,W,"f")}async exec(r,t={}){if(e(this,W,"f"))throw new c("bash session terminated");let i=t.timeoutMs??ft,o=t.signal;o?.throwIfAborted(),n(this,v,"","f"),n(this,ee,!1,"f");let s=`__ANT_CMD_${ct.randomUUID()}_DONE__`,l=`${s.slice(0,8)}''${s.slice(8)}`,f=`{ ${r}
|
|
9
|
-
} </dev/null 2>&1; printf '\\n${l}%d\\n' $?
|
|
10
|
-
`;if(e(this,b,"f").stdin.write(f),e(this,v,"f").indexOf(s)<0){let{promise:E,resolve:D}=Ut();n(this,I,{sentinel:s,resolve:D},"f");let M,se;try{await Promise.race([E,new Promise((pt,Se)=>{M=setTimeout(()=>Se(new dt(i)),i)}),new Promise((pt,Se)=>{if(!o)return;se=()=>Se(o.reason),o.addEventListener("abort",se,{once:!0})})])}finally{if(M)clearTimeout(M);if(se&&o)o.removeEventListener("abort",se);n(this,I,null,"f")}}let d=e(this,v,"f").indexOf(s);if(d<0)throw new c("bash session terminated");let h=e(this,v,"f").slice(d+s.length).match(/^(-?\d+)/),u=h?parseInt(h[1],10):-1,_=e(this,v,"f").slice(0,d).replace(ir,"").replace(/\n+$/,"");if(e(this,ee,"f"))_=`[output truncated]
|
|
11
|
-
${_}`;return{output:_,exitCode:u}}close(){if(e(this,W,"f"))return;n(this,W,!0,"f");let r=e(this,I,"f");n(this,I,null,"f"),r?.resolve(),e(this,b,"f").stdout.destroy(),e(this,b,"f").stderr.destroy(),e(this,b,"f").stdin.destroy();try{process.kill(-e(this,b,"f").pid,"SIGKILL")}catch{e(this,b,"f").kill("SIGKILL")}e(this,b,"f").unref()}}return b=new WeakMap,v=new WeakMap,ee=new WeakMap,W=new WeakMap,I=new WeakMap,ye=new WeakSet,Le=function(t){if(n(this,v,e(this,v,"f")+t,"f"),e(this,v,"f").length>nt)n(this,v,e(this,v,"f").slice(e(this,v,"f").length-nt),"f"),n(this,ee,!0,"f");if(e(this,I,"f")&&e(this,v,"f").indexOf(e(this,I,"f").sentinel)>=0){let i=e(this,I,"f");n(this,I,null,"f"),i.resolve()}},a})();function ar(a){Y(a.unrestrictedPaths);let r,t=Promise.resolve();return C({name:"bash",description:"Run a bash command in a persistent shell. State (cwd, env vars) persists across calls.",inputSchema:{type:"object",properties:{command:{type:"string",description:"The command to run"},restart:{type:"boolean",description:"Restart the persistent shell before running"},timeout_ms:{type:"integer",description:"Per-call timeout in milliseconds"}}},run:async({command:i,restart:o,timeout_ms:s},l)=>{let f=t,d=Ut();t=d.promise;try{await f}catch{}try{if(o)r?.close(),r=void 0;if(!i){if(o)return"bash session restarted";throw new A("bash: command is required")}r??(r=new sr(a.workdir,a.env));try{let{output:m,exitCode:h}=await r.exec(i,{timeoutMs:s??ft,signal:l?.signal});if(h!==0)throw new A(m||`exit ${h}`);return m}catch(m){if(m instanceof A)throw m;throw r.close(),r=void 0,new A(`bash: ${m instanceof Error?m.message:String(m)}`)}}finally{d.resolve()}},close:()=>{r?.close(),r=void 0}})}function cr(a){return Y(a.unrestrictedPaths),C({name:"read",description:"Read a UTF-8 text file relative to the workdir.",inputSchema:{type:"object",properties:{file_path:{type:"string"},view_range:{type:"array",items:{type:"integer"},description:"[start_line, end_line] 1-indexed inclusive"}},required:["file_path"]},run:async({file_path:r,view_range:t})=>{if(!r)throw new A("read: file_path is required");let i=await oe(a,r);if(t?.length&&t.length!==2)throw new A("read: view_range must be [start_line, end_line]");let o;try{let h=await S.stat(i);if(!h.isFile())throw new A(`read: ${r} is not a regular file`);let u=ht(a.maxFileBytes);if(u!==null&&h.size>u){if(!t?.length)throw new A(`read: ${r} is ${h.size} bytes, exceeds ${u}-byte limit. Use the view_range parameter to read specific line ranges, e.g. view_range: [1, 500].`);let[_,E]=t;return await lr(i,r,_,E,u)}o=await S.readFile(i,"utf8")}catch(h){if(h instanceof A)throw h;throw new A(`read: ${q(h,r)}`)}if(!t?.length)return o;let[s,l]=t,f=o.split(`
|
|
12
|
-
`),d=Math.max(0,s-1),m=l>0?l:f.length;return f.slice(d,m).join(`
|
|
13
|
-
`)}})}async function lr(a,r,t,i,o){let s=new fr(r,t,i,o);if(s.rangeIsEmpty())return"";let l=ne.createReadStream(a,{highWaterMark:er});try{for await(let f of l)if(s.collectFrom(f),s.rangeIsCollected())break}finally{l.destroy()}return s.text()}var fr=(()=>{class a{constructor(r,t,i,o){we.add(this),te.set(this,void 0),_e.set(this,void 0),ge.set(this,void 0),U.set(this,void 0),j.set(this,void 0),V.set(this,void 0),B.set(this,0),re.set(this,[]),L.set(this,0),n(this,te,r,"f"),n(this,_e,t,"f"),n(this,ge,i,"f"),n(this,U,Math.max(0,t-1),"f"),n(this,j,i>0?i:1/0,"f"),n(this,V,o,"f")}rangeIsEmpty(){return e(this,j,"f")<=e(this,U,"f")}rangeIsCollected(){return e(this,B,"f")>=e(this,j,"f")}collectFrom(r){var t;let i=0;while(i<r.length&&!this.rangeIsCollected()){let o=r.indexOf(10,i),s=o<0?r.length:o;if(e(this,B,"f")>=e(this,U,"f"))e(this,we,"m",rt).call(this,r.subarray(i,s),o>=0);if(o<0)break;n(this,B,(t=e(this,B,"f"),t++,t),"f"),i=o+1}}text(){return Buffer.concat(e(this,re,"f"),e(this,L,"f")).toString("utf8")}}return te=new WeakMap,_e=new WeakMap,ge=new WeakMap,U=new WeakMap,j=new WeakMap,V=new WeakMap,B=new WeakMap,re=new WeakMap,L=new WeakMap,we=new WeakSet,rt=function(t,i){if(e(this,re,"f").push(t),n(this,L,e(this,L,"f")+t.length,"f"),i&&e(this,B,"f")+1<e(this,j,"f"))e(this,re,"f").push(ot),n(this,L,e(this,L,"f")+ot.length,"f");if(e(this,L,"f")>e(this,V,"f"))throw e(this,we,"m",it).call(this)},it=function(){if(e(this,j,"f")-e(this,U,"f")===1)return new A(`read: line ${e(this,U,"f")+1} of ${e(this,te,"f")} alone exceeds ${e(this,V,"f")}-byte limit. The read tool cannot return part of a line, so view_range cannot narrow this further.`);return new A(`read: view_range [${e(this,_e,"f")}, ${e(this,ge,"f")}] of ${e(this,te,"f")} exceeds ${e(this,V,"f")}-byte limit. Narrow the view_range to read a smaller portion.`)},a})();function dr(a){return Y(a.unrestrictedPaths),C({name:"write",description:"Write a UTF-8 text file relative to the workdir, creating parent directories as needed.",inputSchema:{type:"object",properties:{file_path:{type:"string"},content:{type:"string"}},required:["file_path","content"]},run:async({file_path:r,content:t})=>{if(!r)throw new A("write: file_path is required");let i=await oe(a,r),o=await mt(a,i);if(o!==void 0)throw new A(`write: ${r} is inside read-only directory ${o}`);try{await S.mkdir(O.dirname(i),{recursive:!0,mode:J}),await be(i,t??"")}catch(s){throw new A(`write: ${q(s,r)}`)}return`wrote ${Buffer.byteLength(t??"")} bytes to ${r}`}})}function hr(a){return Y(a.unrestrictedPaths),C({name:"edit",description:"Replace old_string with new_string in a file. old_string must be unique unless replace_all.",inputSchema:{type:"object",properties:{file_path:{type:"string"},old_string:{type:"string"},new_string:{type:"string"},replace_all:{type:"boolean"}},required:["file_path","old_string","new_string"]},run:async({file_path:r,old_string:t,new_string:i,replace_all:o})=>{if(!r)throw new A("edit: file_path is required");if(!t)throw new A("edit: old_string is required");let s=await oe(a,r),l=await mt(a,s);if(l!==void 0)throw new A(`edit: ${r} is inside read-only directory ${l}`);let f;try{let h=await S.stat(s);if(!h.isFile())throw new A(`edit: ${r} is not a regular file`);let u=ht(a.maxFileBytes);if(u!==null&&h.size>u)throw new A(`edit: ${r} is ${h.size} bytes, exceeds ${u}-byte limit. The edit tool loads the whole file and cannot modify a file this large.`);f=await S.readFile(s,"utf8")}catch(h){if(h instanceof A)throw h;throw new A(`edit: ${q(h,r)}`)}let d=f.split(t).length-1;if(d===0)throw new A(`edit: old_string not found in ${r}`);let m;if(o)m=f.split(t).join(i);else{if(d>1)throw new A(`edit: old_string appears ${d} times in ${r} (must be unique)`);m=f.replace(t,()=>i)}try{await be(s,m)}catch(h){throw new A(`edit: write: ${q(h,r)}`)}return`edited ${r} (${o?d:1} replacement(s))`}})}function mr(a){return a.split(/[\\/{},]/).includes("..")}function ur(a){return Y(a.unrestrictedPaths),C({name:"glob",description:"Match files under the workdir against a glob pattern. Results are mtime-sorted, newest first.",inputSchema:{type:"object",properties:{pattern:{type:"string"},path:{type:"string",description:"Directory to search in. Defaults to the workdir."}},required:["pattern"]},run:async({pattern:r,path:t})=>{if(!r)throw new A("glob: pattern is required");if(O.isAbsolute(r))throw new A("glob: absolute pattern not permitted; pass a relative pattern (and optionally path)");if(mr(r))throw new A('glob: ".." is not permitted in the pattern');let i=t?await oe(a,t):O.resolve(a.workdir),o=t?i:await X(i),s=[],l=ut;try{for await(let f of nr(r,{cwd:i,withFileTypes:!0,exclude:(d)=>d.name===".git"||d.name==="node_modules"})){if(l--<=0)break;if(!f.isFile())continue;let d=O.join(f.parentPath,f.name),m;try{m=await S.realpath(d)}catch{continue}if(!ae(o,m))continue;let h=0;try{h=(await S.stat(d)).mtimeMs}catch{}s.push({path:d,mtime:h})}}catch(f){throw new A(`glob: ${f instanceof Error?f.message:String(f)}`)}if(s.length===0)return"no matches";return s.sort((f,d)=>d.mtime-f.mtime),s.slice(0,rr).map((f)=>f.path).join(`
|
|
14
|
-
`)}})}function pr(a){return Y(a.unrestrictedPaths),C({name:"grep",description:"Search file contents for a regex. Uses ripgrep if available, otherwise a built-in walker.",inputSchema:{type:"object",properties:{pattern:{type:"string"},path:{type:"string"}},required:["pattern"]},run:async({pattern:r,path:t},i)=>{if(!r)throw new A("grep: pattern is required");let o=O.resolve(a.workdir);if(t)o=await oe(a,t);let s=await Sr();return s?yr(s,r,o,i?.signal):wr(r,o,i?.signal)}})}function yr(a,r,t,i){return new Promise((o,s)=>{let l=$e.spawn(a,["-n","--no-heading","-e",r,"--",t],{...i?{signal:i}:{}}),f="",d="",m=!1;l.stdout.on("data",(h)=>{if(m)return;if(f+=h,f.length>ie)m=!0,f=f.slice(0,ie),l.kill("SIGKILL")}),l.stderr.on("data",(h)=>d+=h),l.on("close",(h)=>{if(i?.aborted)return s(new A("grep: aborted"));if(m)return o(f+`
|
|
15
|
-
[output truncated at ${ie} bytes]`);if(h===0)return o(f);if(h===1)return o("no matches");s(new A(`grep: rg failed: ${d||`exit ${h}`}`))}),l.on("error",(h)=>{if(i?.aborted)return s(new A("grep: aborted"));s(new A(`grep: rg failed: ${h.message}`))})})}async function wr(a,r,t){let i;try{i=new RegExp(a)}catch(d){throw new A(`grep: invalid regex: ${d instanceof Error?d.message:String(d)}`)}let o=[],s=ie,l=(d)=>{if(s-=d.length+1,s<0)return o.push(`[output truncated at ${ie} bytes]`),!1;return o.push(d),!0};if((await S.stat(r).catch(()=>null))?.isFile())await st(r,i,l);else await gr(r,"",(d)=>st(O.join(r,d),i,l),t);if(t?.aborted)throw new A("grep: aborted");if(o.length===0)return"no matches";return o.join(`
|
|
16
|
-
`)}async function st(a,r,t){let i=ne.createReadStream(a,{encoding:"utf8"}),o=lt.createInterface({input:i,crlfDelay:1/0}),s=0;try{for await(let l of o){if(s++,l.length>tr)continue;if(r.test(l)&&!t(`${a}:${s}:${l}`))return!1}}catch{}finally{i.destroy()}return!0}var _r=40,ut=50000;async function gr(a,r,t,i){let o=ut;async function s(l,f){if(f>_r)return!0;if(i?.aborted)return!1;let d;try{d=await S.readdir(O.join(a,l),{withFileTypes:!0})}catch{return!0}for(let m of d){if(m.name===".git"||m.name==="node_modules")continue;if(o--<=0)return!1;if(i?.aborted)return!1;let h=l?O.join(l,m.name):m.name;if(m.isDirectory()){if(!await s(h,f+1))return!1}else if(m.isFile()){if(await t(h)===!1)return!1}}return!0}await s(r,0)}async function Sr(){let a=(process.env.PATH??"").split(O.delimiter);for(let r of a){let t=O.join(r,"rg");try{return await S.access(t,ne.constants.X_OK),t}catch{}}return null}export{Yt as MEMORY_FLUSH_TIMEOUT_MS,P as SessionMemoryError,Jt as SessionMemoryStores,Xr as betaAgentToolset20260401,St as setupSkills};
|
package/chunk-a81p46j7.js
DELETED
package/chunk-agsfy9w7.js
DELETED
package/chunk-d20p02ny.js
DELETED
package/chunk-ejsneb6f.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{hr}from"./chunk-fx7f4m3c.js";import{se}from"./chunk-zxkq9m8e.js";var t={api:"typesafe-system-one",label:"System One API",url:(e)=>new URL("systemone",`${e.baseUrl.replace(/\/+$/u,"")}/`),payload:(e,r)=>({model:e.id,...r}),output:(e)=>{if(!se(e))throw Error("System One API returned an unexpected response");return e}},a=(e,r,s)=>hr(t,e,r,s);export{a as classify};
|
package/chunk-fmq3zwzk.js
DELETED
package/chunk-rfb85nj7.js
DELETED