@yhong91/vibetime 0.1.26 → 0.1.28
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/bin/vibetime.mjs +1291 -95
- package/package.json +2 -1
package/bin/vibetime.mjs
CHANGED
|
@@ -157,11 +157,736 @@ var init_fs = __esm({
|
|
|
157
157
|
}
|
|
158
158
|
});
|
|
159
159
|
|
|
160
|
+
// ../../node_modules/.pnpm/fzstd@0.1.1/node_modules/fzstd/esm/index.mjs
|
|
161
|
+
var esm_exports = {};
|
|
162
|
+
__export(esm_exports, {
|
|
163
|
+
Decompress: () => Decompress,
|
|
164
|
+
ZstdErrorCode: () => ZstdErrorCode,
|
|
165
|
+
decompress: () => decompress
|
|
166
|
+
});
|
|
167
|
+
function decompress(dat, buf) {
|
|
168
|
+
var bufs = [], nb = +!buf;
|
|
169
|
+
var bt = 0, ol = 0;
|
|
170
|
+
for (; dat.length; ) {
|
|
171
|
+
var st = rzfh(dat, nb || buf);
|
|
172
|
+
if (typeof st == "object") {
|
|
173
|
+
if (nb) {
|
|
174
|
+
buf = null;
|
|
175
|
+
if (st.w.length == st.u) {
|
|
176
|
+
bufs.push(buf = st.w);
|
|
177
|
+
ol += st.u;
|
|
178
|
+
}
|
|
179
|
+
} else {
|
|
180
|
+
bufs.push(buf);
|
|
181
|
+
st.e = 0;
|
|
182
|
+
}
|
|
183
|
+
for (; !st.l; ) {
|
|
184
|
+
var blk = rzb(dat, st, buf);
|
|
185
|
+
if (!blk)
|
|
186
|
+
err(5);
|
|
187
|
+
if (buf)
|
|
188
|
+
st.e = st.y;
|
|
189
|
+
else {
|
|
190
|
+
bufs.push(blk);
|
|
191
|
+
ol += blk.length;
|
|
192
|
+
cpw(st.w, 0, blk.length);
|
|
193
|
+
st.w.set(blk, st.w.length - blk.length);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
bt = st.b + st.c * 4;
|
|
197
|
+
} else
|
|
198
|
+
bt = st;
|
|
199
|
+
dat = dat.subarray(bt);
|
|
200
|
+
}
|
|
201
|
+
return cct(bufs, ol);
|
|
202
|
+
}
|
|
203
|
+
var ab, u8, u16, i16, i32, slc, fill, cpw, ZstdErrorCode, ec, err, rb, b4, rzfh, msb, rfse, rhu, dllt, dmlt, doct, b2bl, llb, llbl, mlb, mlbl, dhu, dhu4, rzb, cct, Decompress;
|
|
204
|
+
var init_esm = __esm({
|
|
205
|
+
"../../node_modules/.pnpm/fzstd@0.1.1/node_modules/fzstd/esm/index.mjs"() {
|
|
206
|
+
ab = ArrayBuffer;
|
|
207
|
+
u8 = Uint8Array;
|
|
208
|
+
u16 = Uint16Array;
|
|
209
|
+
i16 = Int16Array;
|
|
210
|
+
i32 = Int32Array;
|
|
211
|
+
slc = function(v, s, e) {
|
|
212
|
+
if (u8.prototype.slice)
|
|
213
|
+
return u8.prototype.slice.call(v, s, e);
|
|
214
|
+
if (s == null || s < 0)
|
|
215
|
+
s = 0;
|
|
216
|
+
if (e == null || e > v.length)
|
|
217
|
+
e = v.length;
|
|
218
|
+
var n = new u8(e - s);
|
|
219
|
+
n.set(v.subarray(s, e));
|
|
220
|
+
return n;
|
|
221
|
+
};
|
|
222
|
+
fill = function(v, n, s, e) {
|
|
223
|
+
if (u8.prototype.fill)
|
|
224
|
+
return u8.prototype.fill.call(v, n, s, e);
|
|
225
|
+
if (s == null || s < 0)
|
|
226
|
+
s = 0;
|
|
227
|
+
if (e == null || e > v.length)
|
|
228
|
+
e = v.length;
|
|
229
|
+
for (; s < e; ++s)
|
|
230
|
+
v[s] = n;
|
|
231
|
+
return v;
|
|
232
|
+
};
|
|
233
|
+
cpw = function(v, t, s, e) {
|
|
234
|
+
if (u8.prototype.copyWithin)
|
|
235
|
+
return u8.prototype.copyWithin.call(v, t, s, e);
|
|
236
|
+
if (s == null || s < 0)
|
|
237
|
+
s = 0;
|
|
238
|
+
if (e == null || e > v.length)
|
|
239
|
+
e = v.length;
|
|
240
|
+
while (s < e) {
|
|
241
|
+
v[t++] = v[s++];
|
|
242
|
+
}
|
|
243
|
+
};
|
|
244
|
+
ZstdErrorCode = {
|
|
245
|
+
InvalidData: 0,
|
|
246
|
+
WindowSizeTooLarge: 1,
|
|
247
|
+
InvalidBlockType: 2,
|
|
248
|
+
FSEAccuracyTooHigh: 3,
|
|
249
|
+
DistanceTooFarBack: 4,
|
|
250
|
+
UnexpectedEOF: 5
|
|
251
|
+
};
|
|
252
|
+
ec = [
|
|
253
|
+
"invalid zstd data",
|
|
254
|
+
"window size too large (>2046MB)",
|
|
255
|
+
"invalid block type",
|
|
256
|
+
"FSE accuracy too high",
|
|
257
|
+
"match distance too far back",
|
|
258
|
+
"unexpected EOF"
|
|
259
|
+
];
|
|
260
|
+
err = function(ind, msg, nt) {
|
|
261
|
+
var e = new Error(msg || ec[ind]);
|
|
262
|
+
e.code = ind;
|
|
263
|
+
if (Error.captureStackTrace)
|
|
264
|
+
Error.captureStackTrace(e, err);
|
|
265
|
+
if (!nt)
|
|
266
|
+
throw e;
|
|
267
|
+
return e;
|
|
268
|
+
};
|
|
269
|
+
rb = function(d, b, n) {
|
|
270
|
+
var i = 0, o = 0;
|
|
271
|
+
for (; i < n; ++i)
|
|
272
|
+
o |= d[b++] << (i << 3);
|
|
273
|
+
return o;
|
|
274
|
+
};
|
|
275
|
+
b4 = function(d, b) {
|
|
276
|
+
return (d[b] | d[b + 1] << 8 | d[b + 2] << 16 | d[b + 3] << 24) >>> 0;
|
|
277
|
+
};
|
|
278
|
+
rzfh = function(dat, w) {
|
|
279
|
+
var n3 = dat[0] | dat[1] << 8 | dat[2] << 16;
|
|
280
|
+
if (n3 == 3126568 && dat[3] == 253) {
|
|
281
|
+
var flg = dat[4];
|
|
282
|
+
var ss = flg >> 5 & 1, cc = flg >> 2 & 1, df = flg & 3, fcf = flg >> 6;
|
|
283
|
+
if (flg & 8)
|
|
284
|
+
err(0);
|
|
285
|
+
var bt = 6 - ss;
|
|
286
|
+
var db = df == 3 ? 4 : df;
|
|
287
|
+
var di = rb(dat, bt, db);
|
|
288
|
+
bt += db;
|
|
289
|
+
var fsb = fcf ? 1 << fcf : ss;
|
|
290
|
+
var fss = rb(dat, bt, fsb) + (fcf == 1 && 256);
|
|
291
|
+
var ws = fss;
|
|
292
|
+
if (!ss) {
|
|
293
|
+
var wb = 1 << 10 + (dat[5] >> 3);
|
|
294
|
+
ws = wb + (wb >> 3) * (dat[5] & 7);
|
|
295
|
+
}
|
|
296
|
+
if (ws > 2145386496)
|
|
297
|
+
err(1);
|
|
298
|
+
var buf = new u8((w == 1 ? fss || ws : w ? 0 : ws) + 12);
|
|
299
|
+
buf[0] = 1, buf[4] = 4, buf[8] = 8;
|
|
300
|
+
return {
|
|
301
|
+
b: bt + fsb,
|
|
302
|
+
y: 0,
|
|
303
|
+
l: 0,
|
|
304
|
+
d: di,
|
|
305
|
+
w: w && w != 1 ? w : buf.subarray(12),
|
|
306
|
+
e: ws,
|
|
307
|
+
o: new i32(buf.buffer, 0, 3),
|
|
308
|
+
u: fss,
|
|
309
|
+
c: cc,
|
|
310
|
+
m: Math.min(131072, ws)
|
|
311
|
+
};
|
|
312
|
+
} else if ((n3 >> 4 | dat[3] << 20) == 25481893) {
|
|
313
|
+
return b4(dat, 4) + 8;
|
|
314
|
+
}
|
|
315
|
+
err(0);
|
|
316
|
+
};
|
|
317
|
+
msb = function(val) {
|
|
318
|
+
var bits = 0;
|
|
319
|
+
for (; 1 << bits <= val; ++bits)
|
|
320
|
+
;
|
|
321
|
+
return bits - 1;
|
|
322
|
+
};
|
|
323
|
+
rfse = function(dat, bt, mal) {
|
|
324
|
+
var tpos = (bt << 3) + 4;
|
|
325
|
+
var al = (dat[bt] & 15) + 5;
|
|
326
|
+
if (al > mal)
|
|
327
|
+
err(3);
|
|
328
|
+
var sz = 1 << al;
|
|
329
|
+
var probs = sz, sym = -1, re = -1, i = -1, ht = sz;
|
|
330
|
+
var buf = new ab(512 + (sz << 2));
|
|
331
|
+
var freq = new i16(buf, 0, 256);
|
|
332
|
+
var dstate = new u16(buf, 0, 256);
|
|
333
|
+
var nstate = new u16(buf, 512, sz);
|
|
334
|
+
var bb1 = 512 + (sz << 1);
|
|
335
|
+
var syms = new u8(buf, bb1, sz);
|
|
336
|
+
var nbits = new u8(buf, bb1 + sz);
|
|
337
|
+
while (sym < 255 && probs > 0) {
|
|
338
|
+
var bits = msb(probs + 1);
|
|
339
|
+
var cbt = tpos >> 3;
|
|
340
|
+
var msk = (1 << bits + 1) - 1;
|
|
341
|
+
var val = (dat[cbt] | dat[cbt + 1] << 8 | dat[cbt + 2] << 16) >> (tpos & 7) & msk;
|
|
342
|
+
var msk1fb = (1 << bits) - 1;
|
|
343
|
+
var msv = msk - probs - 1;
|
|
344
|
+
var sval = val & msk1fb;
|
|
345
|
+
if (sval < msv)
|
|
346
|
+
tpos += bits, val = sval;
|
|
347
|
+
else {
|
|
348
|
+
tpos += bits + 1;
|
|
349
|
+
if (val > msk1fb)
|
|
350
|
+
val -= msv;
|
|
351
|
+
}
|
|
352
|
+
freq[++sym] = --val;
|
|
353
|
+
if (val == -1) {
|
|
354
|
+
probs += val;
|
|
355
|
+
syms[--ht] = sym;
|
|
356
|
+
} else
|
|
357
|
+
probs -= val;
|
|
358
|
+
if (!val) {
|
|
359
|
+
do {
|
|
360
|
+
var rbt = tpos >> 3;
|
|
361
|
+
re = (dat[rbt] | dat[rbt + 1] << 8) >> (tpos & 7) & 3;
|
|
362
|
+
tpos += 2;
|
|
363
|
+
sym += re;
|
|
364
|
+
} while (re == 3);
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
if (sym > 255 || probs)
|
|
368
|
+
err(0);
|
|
369
|
+
var sympos = 0;
|
|
370
|
+
var sstep = (sz >> 1) + (sz >> 3) + 3;
|
|
371
|
+
var smask = sz - 1;
|
|
372
|
+
for (var s = 0; s <= sym; ++s) {
|
|
373
|
+
var sf = freq[s];
|
|
374
|
+
if (sf < 1) {
|
|
375
|
+
dstate[s] = -sf;
|
|
376
|
+
continue;
|
|
377
|
+
}
|
|
378
|
+
for (i = 0; i < sf; ++i) {
|
|
379
|
+
syms[sympos] = s;
|
|
380
|
+
do {
|
|
381
|
+
sympos = sympos + sstep & smask;
|
|
382
|
+
} while (sympos >= ht);
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
if (sympos)
|
|
386
|
+
err(0);
|
|
387
|
+
for (i = 0; i < sz; ++i) {
|
|
388
|
+
var ns = dstate[syms[i]]++;
|
|
389
|
+
var nb = nbits[i] = al - msb(ns);
|
|
390
|
+
nstate[i] = (ns << nb) - sz;
|
|
391
|
+
}
|
|
392
|
+
return [tpos + 7 >> 3, {
|
|
393
|
+
b: al,
|
|
394
|
+
s: syms,
|
|
395
|
+
n: nbits,
|
|
396
|
+
t: nstate
|
|
397
|
+
}];
|
|
398
|
+
};
|
|
399
|
+
rhu = function(dat, bt) {
|
|
400
|
+
var i = 0, wc = -1;
|
|
401
|
+
var buf = new u8(292), hb = dat[bt];
|
|
402
|
+
var hw = buf.subarray(0, 256);
|
|
403
|
+
var rc = buf.subarray(256, 268);
|
|
404
|
+
var ri = new u16(buf.buffer, 268);
|
|
405
|
+
if (hb < 128) {
|
|
406
|
+
var _a = rfse(dat, bt + 1, 6), ebt = _a[0], fdt = _a[1];
|
|
407
|
+
bt += hb;
|
|
408
|
+
var epos = ebt << 3;
|
|
409
|
+
var lb = dat[bt];
|
|
410
|
+
if (!lb)
|
|
411
|
+
err(0);
|
|
412
|
+
var st1 = 0, st2 = 0, btr1 = fdt.b, btr2 = btr1;
|
|
413
|
+
var fpos = (++bt << 3) - 8 + msb(lb);
|
|
414
|
+
for (; ; ) {
|
|
415
|
+
fpos -= btr1;
|
|
416
|
+
if (fpos < epos)
|
|
417
|
+
break;
|
|
418
|
+
var cbt = fpos >> 3;
|
|
419
|
+
st1 += (dat[cbt] | dat[cbt + 1] << 8) >> (fpos & 7) & (1 << btr1) - 1;
|
|
420
|
+
hw[++wc] = fdt.s[st1];
|
|
421
|
+
fpos -= btr2;
|
|
422
|
+
if (fpos < epos)
|
|
423
|
+
break;
|
|
424
|
+
cbt = fpos >> 3;
|
|
425
|
+
st2 += (dat[cbt] | dat[cbt + 1] << 8) >> (fpos & 7) & (1 << btr2) - 1;
|
|
426
|
+
hw[++wc] = fdt.s[st2];
|
|
427
|
+
btr1 = fdt.n[st1];
|
|
428
|
+
st1 = fdt.t[st1];
|
|
429
|
+
btr2 = fdt.n[st2];
|
|
430
|
+
st2 = fdt.t[st2];
|
|
431
|
+
}
|
|
432
|
+
if (++wc > 255)
|
|
433
|
+
err(0);
|
|
434
|
+
} else {
|
|
435
|
+
wc = hb - 127;
|
|
436
|
+
for (; i < wc; i += 2) {
|
|
437
|
+
var byte = dat[++bt];
|
|
438
|
+
hw[i] = byte >> 4;
|
|
439
|
+
hw[i + 1] = byte & 15;
|
|
440
|
+
}
|
|
441
|
+
++bt;
|
|
442
|
+
}
|
|
443
|
+
var wes = 0;
|
|
444
|
+
for (i = 0; i < wc; ++i) {
|
|
445
|
+
var wt = hw[i];
|
|
446
|
+
if (wt > 11)
|
|
447
|
+
err(0);
|
|
448
|
+
wes += wt && 1 << wt - 1;
|
|
449
|
+
}
|
|
450
|
+
var mb = msb(wes) + 1;
|
|
451
|
+
var ts = 1 << mb;
|
|
452
|
+
var rem = ts - wes;
|
|
453
|
+
if (rem & rem - 1)
|
|
454
|
+
err(0);
|
|
455
|
+
hw[wc++] = msb(rem) + 1;
|
|
456
|
+
for (i = 0; i < wc; ++i) {
|
|
457
|
+
var wt = hw[i];
|
|
458
|
+
++rc[hw[i] = wt && mb + 1 - wt];
|
|
459
|
+
}
|
|
460
|
+
var hbuf = new u8(ts << 1);
|
|
461
|
+
var syms = hbuf.subarray(0, ts), nb = hbuf.subarray(ts);
|
|
462
|
+
ri[mb] = 0;
|
|
463
|
+
for (i = mb; i > 0; --i) {
|
|
464
|
+
var pv = ri[i];
|
|
465
|
+
fill(nb, i, pv, ri[i - 1] = pv + rc[i] * (1 << mb - i));
|
|
466
|
+
}
|
|
467
|
+
if (ri[0] != ts)
|
|
468
|
+
err(0);
|
|
469
|
+
for (i = 0; i < wc; ++i) {
|
|
470
|
+
var bits = hw[i];
|
|
471
|
+
if (bits) {
|
|
472
|
+
var code = ri[bits];
|
|
473
|
+
fill(syms, i, code, ri[bits] = code + (1 << mb - bits));
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
return [bt, {
|
|
477
|
+
n: nb,
|
|
478
|
+
b: mb,
|
|
479
|
+
s: syms
|
|
480
|
+
}];
|
|
481
|
+
};
|
|
482
|
+
dllt = rfse(/* @__PURE__ */ new u8([
|
|
483
|
+
81,
|
|
484
|
+
16,
|
|
485
|
+
99,
|
|
486
|
+
140,
|
|
487
|
+
49,
|
|
488
|
+
198,
|
|
489
|
+
24,
|
|
490
|
+
99,
|
|
491
|
+
12,
|
|
492
|
+
33,
|
|
493
|
+
196,
|
|
494
|
+
24,
|
|
495
|
+
99,
|
|
496
|
+
102,
|
|
497
|
+
102,
|
|
498
|
+
134,
|
|
499
|
+
70,
|
|
500
|
+
146,
|
|
501
|
+
4
|
|
502
|
+
]), 0, 6)[1];
|
|
503
|
+
dmlt = rfse(/* @__PURE__ */ new u8([
|
|
504
|
+
33,
|
|
505
|
+
20,
|
|
506
|
+
196,
|
|
507
|
+
24,
|
|
508
|
+
99,
|
|
509
|
+
140,
|
|
510
|
+
33,
|
|
511
|
+
132,
|
|
512
|
+
16,
|
|
513
|
+
66,
|
|
514
|
+
8,
|
|
515
|
+
33,
|
|
516
|
+
132,
|
|
517
|
+
16,
|
|
518
|
+
66,
|
|
519
|
+
8,
|
|
520
|
+
33,
|
|
521
|
+
68,
|
|
522
|
+
68,
|
|
523
|
+
68,
|
|
524
|
+
68,
|
|
525
|
+
68,
|
|
526
|
+
68,
|
|
527
|
+
68,
|
|
528
|
+
68,
|
|
529
|
+
36,
|
|
530
|
+
9
|
|
531
|
+
]), 0, 6)[1];
|
|
532
|
+
doct = rfse(/* @__PURE__ */ new u8([
|
|
533
|
+
32,
|
|
534
|
+
132,
|
|
535
|
+
16,
|
|
536
|
+
66,
|
|
537
|
+
102,
|
|
538
|
+
70,
|
|
539
|
+
68,
|
|
540
|
+
68,
|
|
541
|
+
68,
|
|
542
|
+
68,
|
|
543
|
+
36,
|
|
544
|
+
73,
|
|
545
|
+
2
|
|
546
|
+
]), 0, 5)[1];
|
|
547
|
+
b2bl = function(b, s) {
|
|
548
|
+
var len = b.length, bl = new i32(len);
|
|
549
|
+
for (var i = 0; i < len; ++i) {
|
|
550
|
+
bl[i] = s;
|
|
551
|
+
s += 1 << b[i];
|
|
552
|
+
}
|
|
553
|
+
return bl;
|
|
554
|
+
};
|
|
555
|
+
llb = /* @__PURE__ */ new u8((/* @__PURE__ */ new i32([
|
|
556
|
+
0,
|
|
557
|
+
0,
|
|
558
|
+
0,
|
|
559
|
+
0,
|
|
560
|
+
16843009,
|
|
561
|
+
50528770,
|
|
562
|
+
134678020,
|
|
563
|
+
202050057,
|
|
564
|
+
269422093
|
|
565
|
+
])).buffer, 0, 36);
|
|
566
|
+
llbl = /* @__PURE__ */ b2bl(llb, 0);
|
|
567
|
+
mlb = /* @__PURE__ */ new u8((/* @__PURE__ */ new i32([
|
|
568
|
+
0,
|
|
569
|
+
0,
|
|
570
|
+
0,
|
|
571
|
+
0,
|
|
572
|
+
0,
|
|
573
|
+
0,
|
|
574
|
+
0,
|
|
575
|
+
0,
|
|
576
|
+
16843009,
|
|
577
|
+
50528770,
|
|
578
|
+
117769220,
|
|
579
|
+
185207048,
|
|
580
|
+
252579084,
|
|
581
|
+
16
|
|
582
|
+
])).buffer, 0, 53);
|
|
583
|
+
mlbl = /* @__PURE__ */ b2bl(mlb, 3);
|
|
584
|
+
dhu = function(dat, out, hu) {
|
|
585
|
+
var len = dat.length, ss = out.length, lb = dat[len - 1], msk = (1 << hu.b) - 1, eb = -hu.b;
|
|
586
|
+
if (!lb)
|
|
587
|
+
err(0);
|
|
588
|
+
var st = 0, btr = hu.b, pos = (len << 3) - 8 + msb(lb) - btr, i = -1;
|
|
589
|
+
for (; pos > eb && i < ss; ) {
|
|
590
|
+
var cbt = pos >> 3;
|
|
591
|
+
var val = (dat[cbt] | dat[cbt + 1] << 8 | dat[cbt + 2] << 16) >> (pos & 7);
|
|
592
|
+
st = (st << btr | val) & msk;
|
|
593
|
+
out[++i] = hu.s[st];
|
|
594
|
+
pos -= btr = hu.n[st];
|
|
595
|
+
}
|
|
596
|
+
if (pos != eb || i + 1 != ss)
|
|
597
|
+
err(0);
|
|
598
|
+
};
|
|
599
|
+
dhu4 = function(dat, out, hu) {
|
|
600
|
+
var bt = 6;
|
|
601
|
+
var ss = out.length, sz1 = ss + 3 >> 2, sz2 = sz1 << 1, sz3 = sz1 + sz2;
|
|
602
|
+
dhu(dat.subarray(bt, bt += dat[0] | dat[1] << 8), out.subarray(0, sz1), hu);
|
|
603
|
+
dhu(dat.subarray(bt, bt += dat[2] | dat[3] << 8), out.subarray(sz1, sz2), hu);
|
|
604
|
+
dhu(dat.subarray(bt, bt += dat[4] | dat[5] << 8), out.subarray(sz2, sz3), hu);
|
|
605
|
+
dhu(dat.subarray(bt), out.subarray(sz3), hu);
|
|
606
|
+
};
|
|
607
|
+
rzb = function(dat, st, out) {
|
|
608
|
+
var _a;
|
|
609
|
+
var bt = st.b;
|
|
610
|
+
var b0 = dat[bt], btype = b0 >> 1 & 3;
|
|
611
|
+
st.l = b0 & 1;
|
|
612
|
+
var sz = b0 >> 3 | dat[bt + 1] << 5 | dat[bt + 2] << 13;
|
|
613
|
+
var ebt = (bt += 3) + sz;
|
|
614
|
+
if (btype == 1) {
|
|
615
|
+
if (bt >= dat.length)
|
|
616
|
+
return;
|
|
617
|
+
st.b = bt + 1;
|
|
618
|
+
if (out) {
|
|
619
|
+
fill(out, dat[bt], st.y, st.y += sz);
|
|
620
|
+
return out;
|
|
621
|
+
}
|
|
622
|
+
return fill(new u8(sz), dat[bt]);
|
|
623
|
+
}
|
|
624
|
+
if (ebt > dat.length)
|
|
625
|
+
return;
|
|
626
|
+
if (btype == 0) {
|
|
627
|
+
st.b = ebt;
|
|
628
|
+
if (out) {
|
|
629
|
+
out.set(dat.subarray(bt, ebt), st.y);
|
|
630
|
+
st.y += sz;
|
|
631
|
+
return out;
|
|
632
|
+
}
|
|
633
|
+
return slc(dat, bt, ebt);
|
|
634
|
+
}
|
|
635
|
+
if (btype == 2) {
|
|
636
|
+
var b3 = dat[bt], lbt = b3 & 3, sf = b3 >> 2 & 3;
|
|
637
|
+
var lss = b3 >> 4, lcs = 0, s4 = 0;
|
|
638
|
+
if (lbt < 2) {
|
|
639
|
+
if (sf & 1)
|
|
640
|
+
lss |= dat[++bt] << 4 | (sf & 2 && dat[++bt] << 12);
|
|
641
|
+
else
|
|
642
|
+
lss = b3 >> 3;
|
|
643
|
+
} else {
|
|
644
|
+
s4 = sf;
|
|
645
|
+
if (sf < 2)
|
|
646
|
+
lss |= (dat[++bt] & 63) << 4, lcs = dat[bt] >> 6 | dat[++bt] << 2;
|
|
647
|
+
else if (sf == 2)
|
|
648
|
+
lss |= dat[++bt] << 4 | (dat[++bt] & 3) << 12, lcs = dat[bt] >> 2 | dat[++bt] << 6;
|
|
649
|
+
else
|
|
650
|
+
lss |= dat[++bt] << 4 | (dat[++bt] & 63) << 12, lcs = dat[bt] >> 6 | dat[++bt] << 2 | dat[++bt] << 10;
|
|
651
|
+
}
|
|
652
|
+
++bt;
|
|
653
|
+
var buf = out ? out.subarray(st.y, st.y + st.m) : new u8(st.m);
|
|
654
|
+
var spl = buf.length - lss;
|
|
655
|
+
if (lbt == 0)
|
|
656
|
+
buf.set(dat.subarray(bt, bt += lss), spl);
|
|
657
|
+
else if (lbt == 1)
|
|
658
|
+
fill(buf, dat[bt++], spl);
|
|
659
|
+
else {
|
|
660
|
+
var hu = st.h;
|
|
661
|
+
if (lbt == 2) {
|
|
662
|
+
var hud = rhu(dat, bt);
|
|
663
|
+
lcs += bt - (bt = hud[0]);
|
|
664
|
+
st.h = hu = hud[1];
|
|
665
|
+
} else if (!hu)
|
|
666
|
+
err(0);
|
|
667
|
+
(s4 ? dhu4 : dhu)(dat.subarray(bt, bt += lcs), buf.subarray(spl), hu);
|
|
668
|
+
}
|
|
669
|
+
var ns = dat[bt++];
|
|
670
|
+
if (ns) {
|
|
671
|
+
if (ns == 255)
|
|
672
|
+
ns = (dat[bt++] | dat[bt++] << 8) + 32512;
|
|
673
|
+
else if (ns > 127)
|
|
674
|
+
ns = ns - 128 << 8 | dat[bt++];
|
|
675
|
+
var scm = dat[bt++];
|
|
676
|
+
if (scm & 3)
|
|
677
|
+
err(0);
|
|
678
|
+
var dts = [dmlt, doct, dllt];
|
|
679
|
+
for (var i = 2; i > -1; --i) {
|
|
680
|
+
var md = scm >> (i << 1) + 2 & 3;
|
|
681
|
+
if (md == 1) {
|
|
682
|
+
var rbuf = new u8([0, 0, dat[bt++]]);
|
|
683
|
+
dts[i] = {
|
|
684
|
+
s: rbuf.subarray(2, 3),
|
|
685
|
+
n: rbuf.subarray(0, 1),
|
|
686
|
+
t: new u16(rbuf.buffer, 0, 1),
|
|
687
|
+
b: 0
|
|
688
|
+
};
|
|
689
|
+
} else if (md == 2) {
|
|
690
|
+
_a = rfse(dat, bt, 9 - (i & 1)), bt = _a[0], dts[i] = _a[1];
|
|
691
|
+
} else if (md == 3) {
|
|
692
|
+
if (!st.t)
|
|
693
|
+
err(0);
|
|
694
|
+
dts[i] = st.t[i];
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
var _b = st.t = dts, mlt = _b[0], oct = _b[1], llt = _b[2];
|
|
698
|
+
var lb = dat[ebt - 1];
|
|
699
|
+
if (!lb)
|
|
700
|
+
err(0);
|
|
701
|
+
var spos = (ebt << 3) - 8 + msb(lb) - llt.b, cbt = spos >> 3, oubt = 0;
|
|
702
|
+
var lst = (dat[cbt] | dat[cbt + 1] << 8) >> (spos & 7) & (1 << llt.b) - 1;
|
|
703
|
+
cbt = (spos -= oct.b) >> 3;
|
|
704
|
+
var ost = (dat[cbt] | dat[cbt + 1] << 8) >> (spos & 7) & (1 << oct.b) - 1;
|
|
705
|
+
cbt = (spos -= mlt.b) >> 3;
|
|
706
|
+
var mst = (dat[cbt] | dat[cbt + 1] << 8) >> (spos & 7) & (1 << mlt.b) - 1;
|
|
707
|
+
for (++ns; --ns; ) {
|
|
708
|
+
var llc = llt.s[lst];
|
|
709
|
+
var lbtr = llt.n[lst];
|
|
710
|
+
var mlc = mlt.s[mst];
|
|
711
|
+
var mbtr = mlt.n[mst];
|
|
712
|
+
var ofc = oct.s[ost];
|
|
713
|
+
var obtr = oct.n[ost];
|
|
714
|
+
cbt = (spos -= ofc) >> 3;
|
|
715
|
+
var ofp = 1 << ofc;
|
|
716
|
+
var off = ofp + ((dat[cbt] | dat[cbt + 1] << 8 | dat[cbt + 2] << 16 | dat[cbt + 3] << 24) >>> (spos & 7) & ofp - 1);
|
|
717
|
+
cbt = (spos -= mlb[mlc]) >> 3;
|
|
718
|
+
var ml = mlbl[mlc] + ((dat[cbt] | dat[cbt + 1] << 8 | dat[cbt + 2] << 16) >> (spos & 7) & (1 << mlb[mlc]) - 1);
|
|
719
|
+
cbt = (spos -= llb[llc]) >> 3;
|
|
720
|
+
var ll = llbl[llc] + ((dat[cbt] | dat[cbt + 1] << 8 | dat[cbt + 2] << 16) >> (spos & 7) & (1 << llb[llc]) - 1);
|
|
721
|
+
cbt = (spos -= lbtr) >> 3;
|
|
722
|
+
lst = llt.t[lst] + ((dat[cbt] | dat[cbt + 1] << 8) >> (spos & 7) & (1 << lbtr) - 1);
|
|
723
|
+
cbt = (spos -= mbtr) >> 3;
|
|
724
|
+
mst = mlt.t[mst] + ((dat[cbt] | dat[cbt + 1] << 8) >> (spos & 7) & (1 << mbtr) - 1);
|
|
725
|
+
cbt = (spos -= obtr) >> 3;
|
|
726
|
+
ost = oct.t[ost] + ((dat[cbt] | dat[cbt + 1] << 8) >> (spos & 7) & (1 << obtr) - 1);
|
|
727
|
+
if (off > 3) {
|
|
728
|
+
st.o[2] = st.o[1];
|
|
729
|
+
st.o[1] = st.o[0];
|
|
730
|
+
st.o[0] = off -= 3;
|
|
731
|
+
} else {
|
|
732
|
+
var idx = off - (ll != 0);
|
|
733
|
+
if (idx) {
|
|
734
|
+
off = idx == 3 ? st.o[0] - 1 : st.o[idx];
|
|
735
|
+
if (idx > 1)
|
|
736
|
+
st.o[2] = st.o[1];
|
|
737
|
+
st.o[1] = st.o[0];
|
|
738
|
+
st.o[0] = off;
|
|
739
|
+
} else
|
|
740
|
+
off = st.o[0];
|
|
741
|
+
}
|
|
742
|
+
for (var i = 0; i < ll; ++i) {
|
|
743
|
+
buf[oubt + i] = buf[spl + i];
|
|
744
|
+
}
|
|
745
|
+
oubt += ll, spl += ll;
|
|
746
|
+
var stin = oubt - off;
|
|
747
|
+
if (stin < 0) {
|
|
748
|
+
var len = -stin;
|
|
749
|
+
var bs = st.e + stin;
|
|
750
|
+
if (len > ml)
|
|
751
|
+
len = ml;
|
|
752
|
+
for (var i = 0; i < len; ++i) {
|
|
753
|
+
buf[oubt + i] = st.w[bs + i];
|
|
754
|
+
}
|
|
755
|
+
oubt += len, ml -= len, stin = 0;
|
|
756
|
+
}
|
|
757
|
+
for (var i = 0; i < ml; ++i) {
|
|
758
|
+
buf[oubt + i] = buf[stin + i];
|
|
759
|
+
}
|
|
760
|
+
oubt += ml;
|
|
761
|
+
}
|
|
762
|
+
if (oubt != spl) {
|
|
763
|
+
while (spl < buf.length) {
|
|
764
|
+
buf[oubt++] = buf[spl++];
|
|
765
|
+
}
|
|
766
|
+
} else
|
|
767
|
+
oubt = buf.length;
|
|
768
|
+
if (out)
|
|
769
|
+
st.y += oubt;
|
|
770
|
+
else
|
|
771
|
+
buf = slc(buf, 0, oubt);
|
|
772
|
+
} else if (out) {
|
|
773
|
+
st.y += lss;
|
|
774
|
+
if (spl) {
|
|
775
|
+
for (var i = 0; i < lss; ++i) {
|
|
776
|
+
buf[i] = buf[spl + i];
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
} else if (spl)
|
|
780
|
+
buf = slc(buf, spl);
|
|
781
|
+
st.b = ebt;
|
|
782
|
+
return buf;
|
|
783
|
+
}
|
|
784
|
+
err(2);
|
|
785
|
+
};
|
|
786
|
+
cct = function(bufs, ol) {
|
|
787
|
+
if (bufs.length == 1)
|
|
788
|
+
return bufs[0];
|
|
789
|
+
var buf = new u8(ol);
|
|
790
|
+
for (var i = 0, b = 0; i < bufs.length; ++i) {
|
|
791
|
+
var chk = bufs[i];
|
|
792
|
+
buf.set(chk, b);
|
|
793
|
+
b += chk.length;
|
|
794
|
+
}
|
|
795
|
+
return buf;
|
|
796
|
+
};
|
|
797
|
+
Decompress = /* @__PURE__ */ (function() {
|
|
798
|
+
function Decompress2(ondata) {
|
|
799
|
+
this.ondata = ondata;
|
|
800
|
+
this.c = [];
|
|
801
|
+
this.l = 0;
|
|
802
|
+
this.z = 0;
|
|
803
|
+
}
|
|
804
|
+
Decompress2.prototype.push = function(chunk, final) {
|
|
805
|
+
if (typeof this.s == "number") {
|
|
806
|
+
var sub = Math.min(chunk.length, this.s);
|
|
807
|
+
chunk = chunk.subarray(sub);
|
|
808
|
+
this.s -= sub;
|
|
809
|
+
}
|
|
810
|
+
var sl = chunk.length;
|
|
811
|
+
var ncs = sl + this.l;
|
|
812
|
+
if (!this.s) {
|
|
813
|
+
if (final) {
|
|
814
|
+
if (!ncs) {
|
|
815
|
+
this.ondata(new u8(0), true);
|
|
816
|
+
return;
|
|
817
|
+
}
|
|
818
|
+
if (ncs < 5)
|
|
819
|
+
err(5);
|
|
820
|
+
} else if (ncs < 18) {
|
|
821
|
+
this.c.push(chunk);
|
|
822
|
+
this.l = ncs;
|
|
823
|
+
return;
|
|
824
|
+
}
|
|
825
|
+
if (this.l) {
|
|
826
|
+
this.c.push(chunk);
|
|
827
|
+
chunk = cct(this.c, ncs);
|
|
828
|
+
this.c = [];
|
|
829
|
+
this.l = 0;
|
|
830
|
+
}
|
|
831
|
+
if (typeof (this.s = rzfh(chunk)) == "number")
|
|
832
|
+
return this.push(chunk, final);
|
|
833
|
+
}
|
|
834
|
+
if (typeof this.s != "number") {
|
|
835
|
+
if (ncs < (this.z || 3)) {
|
|
836
|
+
if (final)
|
|
837
|
+
err(5);
|
|
838
|
+
this.c.push(chunk);
|
|
839
|
+
this.l = ncs;
|
|
840
|
+
return;
|
|
841
|
+
}
|
|
842
|
+
if (this.l) {
|
|
843
|
+
this.c.push(chunk);
|
|
844
|
+
chunk = cct(this.c, ncs);
|
|
845
|
+
this.c = [];
|
|
846
|
+
this.l = 0;
|
|
847
|
+
}
|
|
848
|
+
if (!this.z && ncs < (this.z = chunk[this.s.b] & 2 ? 4 : 3 + (chunk[this.s.b] >> 3 | chunk[this.s.b + 1] << 5 | chunk[this.s.b + 2] << 13))) {
|
|
849
|
+
if (final)
|
|
850
|
+
err(5);
|
|
851
|
+
this.c.push(chunk);
|
|
852
|
+
this.l = ncs;
|
|
853
|
+
return;
|
|
854
|
+
} else
|
|
855
|
+
this.z = 0;
|
|
856
|
+
for (; ; ) {
|
|
857
|
+
var blk = rzb(chunk, this.s);
|
|
858
|
+
if (!blk) {
|
|
859
|
+
if (final)
|
|
860
|
+
err(5);
|
|
861
|
+
var adc = chunk.subarray(this.s.b);
|
|
862
|
+
this.s.b = 0;
|
|
863
|
+
this.c.push(adc), this.l += adc.length;
|
|
864
|
+
return;
|
|
865
|
+
} else {
|
|
866
|
+
this.ondata(blk, false);
|
|
867
|
+
cpw(this.s.w, 0, blk.length);
|
|
868
|
+
this.s.w.set(blk, this.s.w.length - blk.length);
|
|
869
|
+
}
|
|
870
|
+
if (this.s.l) {
|
|
871
|
+
var rest = chunk.subarray(this.s.b);
|
|
872
|
+
this.s = this.s.c * 4;
|
|
873
|
+
this.push(rest, final);
|
|
874
|
+
return;
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
} else if (final)
|
|
878
|
+
err(5);
|
|
879
|
+
};
|
|
880
|
+
return Decompress2;
|
|
881
|
+
})();
|
|
882
|
+
}
|
|
883
|
+
});
|
|
884
|
+
|
|
160
885
|
// src/cli.ts
|
|
161
886
|
import { spawn as spawn2, spawnSync } from "node:child_process";
|
|
162
887
|
import { mkdir as mkdir5, open, rm, stat as stat13, writeFile as writeFile4 } from "node:fs/promises";
|
|
163
|
-
import
|
|
164
|
-
import
|
|
888
|
+
import os10 from "node:os";
|
|
889
|
+
import path23 from "node:path";
|
|
165
890
|
import { fileURLToPath } from "node:url";
|
|
166
891
|
|
|
167
892
|
// ../shared/src/index.ts
|
|
@@ -199,7 +924,7 @@ var TELEMETRY_EVENT_TYPES = [
|
|
|
199
924
|
"agent.operation"
|
|
200
925
|
];
|
|
201
926
|
var FILE_ACTIVITY_OPERATIONS = ["read", "search", "create", "write", "edit", "delete"];
|
|
202
|
-
var BACKFILL_SOURCE_IDS = ["codex", "claude-code", "claude-cowork", "copilot", "opencode", "pi", "agy", "codebuddy", "qoder", "qoder-cn", "workbuddy", "zcode", "grok-build"];
|
|
927
|
+
var BACKFILL_SOURCE_IDS = ["codex", "claude-code", "claude-cowork", "copilot", "opencode", "pi", "agy", "codebuddy", "qoder", "qoder-cn", "workbuddy", "zcode", "grok-build", "zed"];
|
|
203
928
|
function createWorkspaceId(input) {
|
|
204
929
|
const basis = input.repoUrl || input.repoRoot || input.projectName || "unknown";
|
|
205
930
|
return `workspace_${fnv1a(basis)}`;
|
|
@@ -1203,7 +1928,7 @@ function countTextLines(text) {
|
|
|
1203
1928
|
}
|
|
1204
1929
|
|
|
1205
1930
|
// src/lib/constants.ts
|
|
1206
|
-
var PACKAGE_VERSION = true ? "0.1.
|
|
1931
|
+
var PACKAGE_VERSION = true ? "0.1.28" : "0.1.1";
|
|
1207
1932
|
var DEFAULT_API_URL = "http://121.196.224.82:3001";
|
|
1208
1933
|
var DEFAULT_BACKFILL_BATCH_SIZE = 50;
|
|
1209
1934
|
var DEFAULT_BACKFILL_BATCH_BYTES = 800 * 1024;
|
|
@@ -1228,6 +1953,12 @@ function objectField(object, key) {
|
|
|
1228
1953
|
}
|
|
1229
1954
|
return object[key];
|
|
1230
1955
|
}
|
|
1956
|
+
function arrayField(object, key) {
|
|
1957
|
+
if (!isPlainObject(object) || !Array.isArray(object[key])) {
|
|
1958
|
+
return [];
|
|
1959
|
+
}
|
|
1960
|
+
return object[key];
|
|
1961
|
+
}
|
|
1231
1962
|
function isPlainObject(value) {
|
|
1232
1963
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
1233
1964
|
}
|
|
@@ -2907,7 +3638,7 @@ function fileActivitiesFromClaudeToolUse(tool, input, ts, cwd) {
|
|
|
2907
3638
|
const metrics = fileMetricsFromClaudeToolInput(tool, input);
|
|
2908
3639
|
addResolvedPathActivity(changes, filePath, operation, ts, cwd, workdir, metrics);
|
|
2909
3640
|
}
|
|
2910
|
-
for (const edit of
|
|
3641
|
+
for (const edit of arrayField2(input, "edits")) {
|
|
2911
3642
|
if (!isPlainObject(edit)) {
|
|
2912
3643
|
continue;
|
|
2913
3644
|
}
|
|
@@ -2951,17 +3682,17 @@ function fileMetricsFromClaudeToolInput(tool, input) {
|
|
|
2951
3682
|
}
|
|
2952
3683
|
return {};
|
|
2953
3684
|
}
|
|
2954
|
-
function
|
|
3685
|
+
function arrayField2(object, key) {
|
|
2955
3686
|
if (!isPlainObject(object) || !Array.isArray(object[key])) {
|
|
2956
3687
|
return [];
|
|
2957
3688
|
}
|
|
2958
3689
|
return object[key];
|
|
2959
3690
|
}
|
|
2960
3691
|
function claudeToolUseItems(message) {
|
|
2961
|
-
return
|
|
3692
|
+
return arrayField2(message, "content").filter((item) => isPlainObject(item) && item.type === "tool_use");
|
|
2962
3693
|
}
|
|
2963
3694
|
function claudeToolResultItems(message) {
|
|
2964
|
-
return
|
|
3695
|
+
return arrayField2(message, "content").filter((item) => isPlainObject(item) && item.type === "tool_result");
|
|
2965
3696
|
}
|
|
2966
3697
|
function isClaudeToolResultMessage(message) {
|
|
2967
3698
|
return claudeToolResultItems(message).length > 0;
|
|
@@ -4163,7 +4894,8 @@ async function parseCodexSessionFile(filePath, options) {
|
|
|
4163
4894
|
let lastTurnIdForComplete;
|
|
4164
4895
|
let turnIdAtLastUserMessage;
|
|
4165
4896
|
let sessionMetaLocked = false;
|
|
4166
|
-
let
|
|
4897
|
+
let lastTotalTokenUsage;
|
|
4898
|
+
let lastPerCallUsageKey;
|
|
4167
4899
|
const pendingToolCalls = /* @__PURE__ */ new Map();
|
|
4168
4900
|
for (const [index, line] of lines.entries()) {
|
|
4169
4901
|
const lineNumber = index + 1;
|
|
@@ -4311,32 +5043,79 @@ async function parseCodexSessionFile(filePath, options) {
|
|
|
4311
5043
|
}
|
|
4312
5044
|
const usage = tokenUsageFromPayload(payload);
|
|
4313
5045
|
if (usage) {
|
|
4314
|
-
const
|
|
4315
|
-
const
|
|
4316
|
-
|
|
4317
|
-
|
|
4318
|
-
|
|
4319
|
-
|
|
4320
|
-
|
|
4321
|
-
|
|
4322
|
-
|
|
5046
|
+
const input = usage.tokensInput ?? 0;
|
|
5047
|
+
const cached = usage.tokensCachedInput ?? 0;
|
|
5048
|
+
const output = usage.tokensOutput ?? 0;
|
|
5049
|
+
const reasoning = usage.tokensReasoningOutput ?? 0;
|
|
5050
|
+
const total = usage.tokensTotal ?? 0;
|
|
5051
|
+
const hasCumulativeUsage = Object.keys(objectField(info, "total_token_usage")).length > 0;
|
|
5052
|
+
const usageKey = [input, cached, output, reasoning, total].join(":");
|
|
5053
|
+
if (!hasCumulativeUsage) {
|
|
5054
|
+
if (usageKey !== lastPerCallUsageKey) {
|
|
5055
|
+
events.push(withBackfillRefs(baseCodexEvent({
|
|
5056
|
+
ts,
|
|
5057
|
+
type: "model.usage",
|
|
5058
|
+
sessionId,
|
|
5059
|
+
turnId: currentTurnId,
|
|
5060
|
+
cwd,
|
|
5061
|
+
project,
|
|
5062
|
+
model: rewriteCodexModelForTier(model, serviceTier),
|
|
5063
|
+
confidence: "partial",
|
|
5064
|
+
metrics: usage
|
|
5065
|
+
}), { filePath, sourcePathHash, lineNumber, topType, payloadType, options }));
|
|
5066
|
+
lastPerCallUsageKey = usageKey;
|
|
5067
|
+
}
|
|
4323
5068
|
break;
|
|
4324
5069
|
}
|
|
4325
|
-
|
|
4326
|
-
|
|
4327
|
-
|
|
4328
|
-
|
|
4329
|
-
|
|
4330
|
-
|
|
4331
|
-
|
|
4332
|
-
|
|
4333
|
-
|
|
4334
|
-
|
|
4335
|
-
|
|
4336
|
-
|
|
4337
|
-
|
|
4338
|
-
|
|
4339
|
-
|
|
5070
|
+
if (lastTotalTokenUsage && total >= lastTotalTokenUsage.total) {
|
|
5071
|
+
const deltaInput = input - lastTotalTokenUsage.input;
|
|
5072
|
+
const deltaCached = cached - lastTotalTokenUsage.cached;
|
|
5073
|
+
const deltaOutput = output - lastTotalTokenUsage.output;
|
|
5074
|
+
const deltaReasoning = reasoning - lastTotalTokenUsage.reasoning;
|
|
5075
|
+
const deltaTotal = total - lastTotalTokenUsage.total;
|
|
5076
|
+
if (deltaInput > 0 || deltaOutput > 0 || deltaTotal > 0) {
|
|
5077
|
+
events.push(withBackfillRefs(baseCodexEvent({
|
|
5078
|
+
ts,
|
|
5079
|
+
type: "model.usage",
|
|
5080
|
+
sessionId,
|
|
5081
|
+
turnId: currentTurnId,
|
|
5082
|
+
cwd,
|
|
5083
|
+
project,
|
|
5084
|
+
model: rewriteCodexModelForTier(model, serviceTier),
|
|
5085
|
+
confidence: "partial",
|
|
5086
|
+
metrics: {
|
|
5087
|
+
tokensInput: deltaInput > 0 ? deltaInput : void 0,
|
|
5088
|
+
tokensCachedInput: deltaCached > 0 ? deltaCached : void 0,
|
|
5089
|
+
tokensOutput: deltaOutput > 0 ? deltaOutput : void 0,
|
|
5090
|
+
tokensReasoningOutput: deltaReasoning > 0 ? deltaReasoning : void 0,
|
|
5091
|
+
tokensTotal: deltaTotal > 0 ? deltaTotal : void 0,
|
|
5092
|
+
modelContextWindow: usage.modelContextWindow,
|
|
5093
|
+
reasoningEffort
|
|
5094
|
+
}
|
|
5095
|
+
}), { filePath, sourcePathHash, lineNumber, topType, payloadType, options }));
|
|
5096
|
+
}
|
|
5097
|
+
} else {
|
|
5098
|
+
events.push(withBackfillRefs(baseCodexEvent({
|
|
5099
|
+
ts,
|
|
5100
|
+
type: "model.usage",
|
|
5101
|
+
sessionId,
|
|
5102
|
+
turnId: currentTurnId,
|
|
5103
|
+
cwd,
|
|
5104
|
+
project,
|
|
5105
|
+
model: rewriteCodexModelForTier(model, serviceTier),
|
|
5106
|
+
confidence: "partial",
|
|
5107
|
+
metrics: {
|
|
5108
|
+
tokensInput: input,
|
|
5109
|
+
tokensCachedInput: cached,
|
|
5110
|
+
tokensOutput: output,
|
|
5111
|
+
tokensReasoningOutput: reasoning,
|
|
5112
|
+
tokensTotal: total,
|
|
5113
|
+
modelContextWindow: usage.modelContextWindow,
|
|
5114
|
+
reasoningEffort
|
|
5115
|
+
}
|
|
5116
|
+
}), { filePath, sourcePathHash, lineNumber, topType, payloadType, options }));
|
|
5117
|
+
}
|
|
5118
|
+
lastTotalTokenUsage = { input, cached, output, reasoning, total };
|
|
4340
5119
|
}
|
|
4341
5120
|
break;
|
|
4342
5121
|
}
|
|
@@ -4553,7 +5332,7 @@ function headlessCodexUsage(raw) {
|
|
|
4553
5332
|
const cached = numberField(usage, "cached_input_tokens") ?? numberField(usage, "cache_read_input_tokens") ?? numberField(usage, "cached_tokens") ?? 0;
|
|
4554
5333
|
const reasoning = numberField(usage, "reasoning_output_tokens") ?? numberField(usage, "reasoning_tokens") ?? 0;
|
|
4555
5334
|
const totalField = numberField(usage, "total_tokens");
|
|
4556
|
-
const total = totalField !== void 0 && (totalField > 0 || input + output
|
|
5335
|
+
const total = totalField !== void 0 && (totalField > 0 || input + output === 0) ? totalField : input + output;
|
|
4557
5336
|
if (input === 0 && cached === 0 && output === 0 && reasoning === 0 && total === 0) {
|
|
4558
5337
|
return;
|
|
4559
5338
|
}
|
|
@@ -4562,7 +5341,7 @@ function headlessCodexUsage(raw) {
|
|
|
4562
5341
|
tokensCachedInput: cached || void 0,
|
|
4563
5342
|
tokensOutput: output || void 0,
|
|
4564
5343
|
tokensReasoningOutput: reasoning || void 0,
|
|
4565
|
-
tokensTotal: total,
|
|
5344
|
+
tokensTotal: total || void 0,
|
|
4566
5345
|
modelCalls: 1
|
|
4567
5346
|
};
|
|
4568
5347
|
}
|
|
@@ -4589,16 +5368,26 @@ function headlessCodexTimestamp(raw) {
|
|
|
4589
5368
|
}
|
|
4590
5369
|
function tokenUsageFromPayload(payload) {
|
|
4591
5370
|
const info = objectField(payload, "info");
|
|
4592
|
-
const
|
|
5371
|
+
const totalUsage = objectField(info, "total_token_usage");
|
|
5372
|
+
const usage = Object.keys(totalUsage).length > 0 ? totalUsage : objectField(info, "last_token_usage");
|
|
4593
5373
|
if (Object.keys(usage).length === 0) {
|
|
4594
5374
|
return;
|
|
4595
5375
|
}
|
|
5376
|
+
const input = numberField(usage, "input_tokens") ?? 0;
|
|
5377
|
+
const cached = numberField(usage, "cached_input_tokens") ?? 0;
|
|
5378
|
+
const output = numberField(usage, "output_tokens") ?? 0;
|
|
5379
|
+
const reasoning = numberField(usage, "reasoning_output_tokens") ?? 0;
|
|
5380
|
+
const totalField = numberField(usage, "total_tokens");
|
|
5381
|
+
const total = totalField !== void 0 && (totalField > 0 || input + output === 0) ? totalField : input + output;
|
|
5382
|
+
if (input === 0 && cached === 0 && output === 0 && reasoning === 0 && total === 0) {
|
|
5383
|
+
return;
|
|
5384
|
+
}
|
|
4596
5385
|
return {
|
|
4597
|
-
tokensInput:
|
|
4598
|
-
tokensCachedInput:
|
|
4599
|
-
tokensOutput:
|
|
4600
|
-
tokensReasoningOutput:
|
|
4601
|
-
tokensTotal:
|
|
5386
|
+
tokensInput: input || void 0,
|
|
5387
|
+
tokensCachedInput: cached || void 0,
|
|
5388
|
+
tokensOutput: output || void 0,
|
|
5389
|
+
tokensReasoningOutput: reasoning || void 0,
|
|
5390
|
+
tokensTotal: total || void 0,
|
|
4602
5391
|
modelContextWindow: numberField(info, "model_context_window")
|
|
4603
5392
|
};
|
|
4604
5393
|
}
|
|
@@ -4617,7 +5406,7 @@ function fileActivitiesFromFunctionCall(payload, payloadType, ts, cwd) {
|
|
|
4617
5406
|
for (const key of ["file_path", "path", "notebook_path"]) {
|
|
4618
5407
|
addResolvedPathActivity(changes, stringField(args, key), operation, ts, cwd, workdir);
|
|
4619
5408
|
}
|
|
4620
|
-
for (const file of
|
|
5409
|
+
for (const file of arrayField3(args, "files")) {
|
|
4621
5410
|
if (typeof file === "string") {
|
|
4622
5411
|
addResolvedPathActivity(changes, file, operation, ts, cwd, workdir);
|
|
4623
5412
|
}
|
|
@@ -4630,7 +5419,7 @@ function fileActivitiesFromFunctionCall(payload, payloadType, ts, cwd) {
|
|
|
4630
5419
|
}
|
|
4631
5420
|
return [...changes.values()];
|
|
4632
5421
|
}
|
|
4633
|
-
function
|
|
5422
|
+
function arrayField3(object, key) {
|
|
4634
5423
|
if (!isPlainObject(object) || !Array.isArray(object[key])) {
|
|
4635
5424
|
return [];
|
|
4636
5425
|
}
|
|
@@ -4935,8 +5724,7 @@ async function parseCopilotSessionFile(filePath, options) {
|
|
|
4935
5724
|
const cacheReadTokens = numberField(usage, "cacheReadTokens") || 0;
|
|
4936
5725
|
const cacheWriteTokens = numberField(usage, "cacheWriteTokens") || 0;
|
|
4937
5726
|
const reasoningTokens = numberField(usage, "reasoningTokens") || 0;
|
|
4938
|
-
const
|
|
4939
|
-
const total = totalInput + outputTokens + reasoningTokens;
|
|
5727
|
+
const total = inputTokens + outputTokens;
|
|
4940
5728
|
if (total <= 0) {
|
|
4941
5729
|
continue;
|
|
4942
5730
|
}
|
|
@@ -4951,7 +5739,7 @@ async function parseCopilotSessionFile(filePath, options) {
|
|
|
4951
5739
|
model: modelName,
|
|
4952
5740
|
confidence: "exact",
|
|
4953
5741
|
metrics: {
|
|
4954
|
-
tokensInput:
|
|
5742
|
+
tokensInput: inputTokens || void 0,
|
|
4955
5743
|
tokensOutput: outputTokens || void 0,
|
|
4956
5744
|
tokensCachedInput: cacheReadTokens + cacheWriteTokens || void 0,
|
|
4957
5745
|
tokensCacheReadInput: cacheReadTokens || void 0,
|
|
@@ -5468,20 +6256,15 @@ async function loadToolInputsFromUpdates(updatesPath) {
|
|
|
5468
6256
|
return map;
|
|
5469
6257
|
}
|
|
5470
6258
|
function metricsFromSignals(signals) {
|
|
5471
|
-
const contextTokens = numberField(signals, "contextTokensUsed");
|
|
5472
6259
|
const toolCallCount = numberField(signals, "toolCallCount");
|
|
5473
6260
|
const turnCount = numberField(signals, "turnCount");
|
|
5474
6261
|
const durationSec = numberField(signals, "sessionDurationSeconds");
|
|
5475
6262
|
const linesAdded = numberField(signals, "agentLinesAdded");
|
|
5476
6263
|
const linesRemoved = numberField(signals, "agentLinesRemoved");
|
|
5477
|
-
if (
|
|
6264
|
+
if (toolCallCount === void 0 && turnCount === void 0 && durationSec === void 0) {
|
|
5478
6265
|
return void 0;
|
|
5479
6266
|
}
|
|
5480
6267
|
const metrics = {};
|
|
5481
|
-
if (contextTokens !== void 0 && contextTokens > 0) {
|
|
5482
|
-
metrics.tokensTotal = contextTokens;
|
|
5483
|
-
metrics.tokensInput = contextTokens;
|
|
5484
|
-
}
|
|
5485
6268
|
if (toolCallCount !== void 0) {
|
|
5486
6269
|
metrics.toolCalls = toolCallCount;
|
|
5487
6270
|
}
|
|
@@ -5920,13 +6703,14 @@ function opencodeUsageFromInfo(info) {
|
|
|
5920
6703
|
const cacheRead = Math.max(0, numberField(cache, "read") || 0);
|
|
5921
6704
|
const cacheWrite = Math.max(0, numberField(cache, "write") || 0);
|
|
5922
6705
|
const totalInput = input + cacheRead + cacheWrite;
|
|
5923
|
-
const
|
|
6706
|
+
const totalOutput = output + reasoning;
|
|
6707
|
+
const total = Math.max(0, numberField(tokensObj, "total") || totalInput + totalOutput);
|
|
5924
6708
|
if (total <= 0) {
|
|
5925
6709
|
return void 0;
|
|
5926
6710
|
}
|
|
5927
6711
|
return {
|
|
5928
6712
|
tokensInput: totalInput || void 0,
|
|
5929
|
-
tokensOutput:
|
|
6713
|
+
tokensOutput: totalOutput || void 0,
|
|
5930
6714
|
tokensReasoningOutput: reasoning || void 0,
|
|
5931
6715
|
tokensCachedInput: cacheRead + cacheWrite || void 0,
|
|
5932
6716
|
tokensCacheReadInput: cacheRead || void 0,
|
|
@@ -6972,7 +7756,7 @@ function fileActivitiesFromQoderCnToolUse(tool, input, ts, cwd) {
|
|
|
6972
7756
|
const metrics = fileMetricsFromQoderCnToolInput(tool, input);
|
|
6973
7757
|
addResolvedPathActivity(changes, filePath, operation, ts, cwd, workdir, metrics);
|
|
6974
7758
|
}
|
|
6975
|
-
for (const edit of
|
|
7759
|
+
for (const edit of arrayField4(input, "edits")) {
|
|
6976
7760
|
if (!isPlainObject(edit)) {
|
|
6977
7761
|
continue;
|
|
6978
7762
|
}
|
|
@@ -7016,17 +7800,17 @@ function fileMetricsFromQoderCnToolInput(tool, input) {
|
|
|
7016
7800
|
}
|
|
7017
7801
|
return {};
|
|
7018
7802
|
}
|
|
7019
|
-
function
|
|
7803
|
+
function arrayField4(object, key) {
|
|
7020
7804
|
if (!isPlainObject(object) || !Array.isArray(object[key])) {
|
|
7021
7805
|
return [];
|
|
7022
7806
|
}
|
|
7023
7807
|
return object[key];
|
|
7024
7808
|
}
|
|
7025
7809
|
function qoderCnToolUseItems(message) {
|
|
7026
|
-
return
|
|
7810
|
+
return arrayField4(message, "content").filter((item) => isPlainObject(item) && item.type === "tool_use");
|
|
7027
7811
|
}
|
|
7028
7812
|
function qoderCnToolResultItems(message) {
|
|
7029
|
-
return
|
|
7813
|
+
return arrayField4(message, "content").filter((item) => isPlainObject(item) && item.type === "tool_result");
|
|
7030
7814
|
}
|
|
7031
7815
|
function isQoderCnToolResultMessage(message) {
|
|
7032
7816
|
return qoderCnToolResultItems(message).length > 0;
|
|
@@ -7715,7 +8499,7 @@ function fileActivitiesFromQoderToolUse(tool, input, ts, cwd) {
|
|
|
7715
8499
|
const metrics = fileMetricsFromQoderToolInput(tool, input);
|
|
7716
8500
|
addResolvedPathActivity(changes, filePath, operation, ts, cwd, workdir, metrics);
|
|
7717
8501
|
}
|
|
7718
|
-
for (const edit of
|
|
8502
|
+
for (const edit of arrayField5(input, "edits")) {
|
|
7719
8503
|
if (!isPlainObject(edit)) {
|
|
7720
8504
|
continue;
|
|
7721
8505
|
}
|
|
@@ -7759,17 +8543,17 @@ function fileMetricsFromQoderToolInput(tool, input) {
|
|
|
7759
8543
|
}
|
|
7760
8544
|
return {};
|
|
7761
8545
|
}
|
|
7762
|
-
function
|
|
8546
|
+
function arrayField5(object, key) {
|
|
7763
8547
|
if (!isPlainObject(object) || !Array.isArray(object[key])) {
|
|
7764
8548
|
return [];
|
|
7765
8549
|
}
|
|
7766
8550
|
return object[key];
|
|
7767
8551
|
}
|
|
7768
8552
|
function qoderToolUseItems(message) {
|
|
7769
|
-
return
|
|
8553
|
+
return arrayField5(message, "content").filter((item) => isPlainObject(item) && item.type === "tool_use");
|
|
7770
8554
|
}
|
|
7771
8555
|
function qoderToolResultItems(message) {
|
|
7772
|
-
return
|
|
8556
|
+
return arrayField5(message, "content").filter((item) => isPlainObject(item) && item.type === "tool_result");
|
|
7773
8557
|
}
|
|
7774
8558
|
function isQoderToolResultMessage(message) {
|
|
7775
8559
|
return qoderToolResultItems(message).length > 0;
|
|
@@ -8094,28 +8878,29 @@ function workbuddyUsageMetrics(record) {
|
|
|
8094
8878
|
if (!input && !output && !total && !cacheRead && !cacheCreate && !reasoning) {
|
|
8095
8879
|
return void 0;
|
|
8096
8880
|
}
|
|
8881
|
+
const alignedTotal = total || input + output;
|
|
8097
8882
|
return {
|
|
8098
|
-
tokensInput: input,
|
|
8883
|
+
tokensInput: input || void 0,
|
|
8099
8884
|
tokensOutput: output,
|
|
8100
8885
|
tokensCachedInput: cacheRead + cacheCreate,
|
|
8101
8886
|
tokensCacheCreationInput: cacheCreate,
|
|
8102
8887
|
tokensCacheReadInput: cacheRead,
|
|
8103
8888
|
tokensReasoningOutput: reasoning,
|
|
8104
|
-
tokensTotal:
|
|
8889
|
+
tokensTotal: alignedTotal,
|
|
8105
8890
|
modelCalls: 1
|
|
8106
8891
|
};
|
|
8107
8892
|
}
|
|
8108
8893
|
function workbuddyCachedTokens(usage, rawUsage) {
|
|
8109
|
-
const rawCache = numberField(rawUsage, "cache_read_input_tokens") ?? numberField(rawUsage, "prompt_cache_hit_tokens") ?? numberField(rawUsage, "cached_tokens");
|
|
8110
|
-
if (rawCache !== void 0) {
|
|
8111
|
-
return rawCache;
|
|
8112
|
-
}
|
|
8113
8894
|
const details = usage.inputTokensDetails;
|
|
8114
|
-
if (Array.isArray(details) && isPlainObject(details[0])) {
|
|
8115
|
-
return numberField(details[0], "cached_tokens") || 0;
|
|
8116
|
-
}
|
|
8117
8895
|
const rawDetails = objectField(rawUsage, "prompt_tokens_details");
|
|
8118
|
-
return
|
|
8896
|
+
return Math.max(
|
|
8897
|
+
0,
|
|
8898
|
+
numberField(rawUsage, "cache_read_input_tokens") || 0,
|
|
8899
|
+
numberField(rawUsage, "prompt_cache_hit_tokens") || 0,
|
|
8900
|
+
numberField(rawUsage, "cached_tokens") || 0,
|
|
8901
|
+
Array.isArray(details) && isPlainObject(details[0]) ? numberField(details[0], "cached_tokens") || 0 : 0,
|
|
8902
|
+
numberField(rawDetails, "cached_tokens") || 0
|
|
8903
|
+
);
|
|
8119
8904
|
}
|
|
8120
8905
|
function workbuddyReasoningTokens(usage, rawUsage) {
|
|
8121
8906
|
const completionDetails = objectField(rawUsage, "completion_tokens_details");
|
|
@@ -8518,6 +9303,7 @@ async function readZCodeRows(dbPath) {
|
|
|
8518
9303
|
'reasoning_tokens',reasoning_tokens,
|
|
8519
9304
|
'cache_creation_input_tokens',cache_creation_input_tokens,
|
|
8520
9305
|
'cache_read_input_tokens',cache_read_input_tokens,
|
|
9306
|
+
'provider_total_tokens',provider_total_tokens,
|
|
8521
9307
|
'computed_total_tokens',computed_total_tokens,
|
|
8522
9308
|
'tool_call_count',tool_call_count
|
|
8523
9309
|
) from model_usage order by started_at, id;`,
|
|
@@ -8549,16 +9335,24 @@ function modelMetrics(row) {
|
|
|
8549
9335
|
const reasoning = numberField(row, "reasoning_tokens") || 0;
|
|
8550
9336
|
const cacheCreation = numberField(row, "cache_creation_input_tokens") || 0;
|
|
8551
9337
|
const cacheRead = numberField(row, "cache_read_input_tokens") || 0;
|
|
8552
|
-
const
|
|
9338
|
+
const cached = cacheCreation + cacheRead;
|
|
9339
|
+
const providerTotal = numberField(row, "provider_total_tokens");
|
|
9340
|
+
const computedTotal = numberField(row, "computed_total_tokens");
|
|
9341
|
+
const totalWithoutSeparateCache = input + output;
|
|
9342
|
+
const totalWithSeparateCache = input + cached + output;
|
|
9343
|
+
const comparisonTotal = providerTotal ?? computedTotal ?? 0;
|
|
9344
|
+
const cacheIsSeparate = comparisonTotal > 0 && Math.abs(comparisonTotal - totalWithSeparateCache) < Math.abs(comparisonTotal - totalWithoutSeparateCache);
|
|
9345
|
+
const alignedInput = input > 0 ? input + (cacheIsSeparate ? cached : 0) : cached;
|
|
9346
|
+
const alignedTotal = alignedInput + output;
|
|
8553
9347
|
const durationMs = numberField(row, "duration_ms");
|
|
8554
9348
|
return {
|
|
8555
|
-
tokensInput:
|
|
9349
|
+
tokensInput: alignedInput || void 0,
|
|
8556
9350
|
tokensOutput: output,
|
|
8557
9351
|
tokensReasoningOutput: reasoning,
|
|
8558
|
-
tokensCachedInput:
|
|
9352
|
+
tokensCachedInput: cached,
|
|
8559
9353
|
tokensCacheCreationInput: cacheCreation,
|
|
8560
9354
|
tokensCacheReadInput: cacheRead,
|
|
8561
|
-
tokensTotal:
|
|
9355
|
+
tokensTotal: alignedTotal,
|
|
8562
9356
|
modelDurationMs: durationMs,
|
|
8563
9357
|
durationMs,
|
|
8564
9358
|
modelCalls: 1,
|
|
@@ -8842,6 +9636,404 @@ function createZCodeAdapter() {
|
|
|
8842
9636
|
};
|
|
8843
9637
|
}
|
|
8844
9638
|
|
|
9639
|
+
// src/adapters/zed.ts
|
|
9640
|
+
import os9 from "node:os";
|
|
9641
|
+
import path20 from "node:path";
|
|
9642
|
+
function zedThreadsCandidates(home, env) {
|
|
9643
|
+
const candidates = [];
|
|
9644
|
+
const platform2 = process.platform;
|
|
9645
|
+
if (platform2 === "darwin") {
|
|
9646
|
+
candidates.push(path20.join(home, "Library", "Application Support", "Zed", "threads", "threads.db"));
|
|
9647
|
+
} else if (platform2 === "win32") {
|
|
9648
|
+
const appdata = env?.APPDATA;
|
|
9649
|
+
if (appdata && appdata.trim()) {
|
|
9650
|
+
candidates.push(path20.join(path20.resolve(appdata), "Zed", "threads", "threads.db"));
|
|
9651
|
+
}
|
|
9652
|
+
candidates.push(path20.join(home, "AppData", "Roaming", "Zed", "threads", "threads.db"));
|
|
9653
|
+
} else {
|
|
9654
|
+
const xdgData = env?.XDG_DATA_HOME;
|
|
9655
|
+
if (xdgData && xdgData.trim()) {
|
|
9656
|
+
candidates.push(path20.join(path20.resolve(xdgData), "zed", "threads", "threads.db"));
|
|
9657
|
+
}
|
|
9658
|
+
candidates.push(path20.join(home, ".local", "share", "zed", "threads", "threads.db"));
|
|
9659
|
+
const xdgConfig = env?.XDG_CONFIG_HOME;
|
|
9660
|
+
if (xdgConfig && xdgConfig.trim()) {
|
|
9661
|
+
candidates.push(path20.join(path20.resolve(xdgConfig), "zed", "threads", "threads.db"));
|
|
9662
|
+
}
|
|
9663
|
+
candidates.push(path20.join(home, ".config", "zed", "threads", "threads.db"));
|
|
9664
|
+
}
|
|
9665
|
+
return candidates;
|
|
9666
|
+
}
|
|
9667
|
+
function zedConfigDir(home, env) {
|
|
9668
|
+
const platform2 = process.platform;
|
|
9669
|
+
if (platform2 === "darwin") {
|
|
9670
|
+
return path20.join(home, "Library", "Application Support", "Zed");
|
|
9671
|
+
}
|
|
9672
|
+
if (platform2 === "win32") {
|
|
9673
|
+
const appdata = env?.APPDATA;
|
|
9674
|
+
if (appdata && appdata.trim()) {
|
|
9675
|
+
return path20.join(path20.resolve(appdata), "Zed");
|
|
9676
|
+
}
|
|
9677
|
+
return path20.join(home, "AppData", "Roaming", "Zed");
|
|
9678
|
+
}
|
|
9679
|
+
const xdgConfig = env?.XDG_CONFIG_HOME;
|
|
9680
|
+
if (xdgConfig && xdgConfig.trim()) {
|
|
9681
|
+
return path20.join(path20.resolve(xdgConfig), "zed");
|
|
9682
|
+
}
|
|
9683
|
+
return path20.join(home, ".config", "zed");
|
|
9684
|
+
}
|
|
9685
|
+
function baseZedEvent(event) {
|
|
9686
|
+
return {
|
|
9687
|
+
schemaVersion: AGENT_TIME_SCHEMA_VERSION,
|
|
9688
|
+
source: "zed",
|
|
9689
|
+
agent: "zed",
|
|
9690
|
+
workspaceId: createWorkspaceId({ projectName: event.project, repoRoot: event.cwd }),
|
|
9691
|
+
...event
|
|
9692
|
+
};
|
|
9693
|
+
}
|
|
9694
|
+
function zedUsageFromRequest(entry) {
|
|
9695
|
+
const input = Math.max(0, numberField(entry, "input_tokens") || 0);
|
|
9696
|
+
const output = Math.max(0, numberField(entry, "output_tokens") || 0);
|
|
9697
|
+
if (input <= 0 && output <= 0) {
|
|
9698
|
+
return void 0;
|
|
9699
|
+
}
|
|
9700
|
+
return {
|
|
9701
|
+
tokensInput: input || void 0,
|
|
9702
|
+
tokensOutput: output || void 0,
|
|
9703
|
+
tokensTotal: input + output
|
|
9704
|
+
};
|
|
9705
|
+
}
|
|
9706
|
+
function filePathFromToolInput(tool, input) {
|
|
9707
|
+
if (!isPlainObject(input)) {
|
|
9708
|
+
return void 0;
|
|
9709
|
+
}
|
|
9710
|
+
const direct = stringField(input, "path") || stringField(input, "file_path") || stringField(input, "filePath");
|
|
9711
|
+
if (direct) {
|
|
9712
|
+
return direct;
|
|
9713
|
+
}
|
|
9714
|
+
if (tool === "save_file") {
|
|
9715
|
+
const paths = arrayField(input, "paths");
|
|
9716
|
+
if (paths && paths.length > 0) {
|
|
9717
|
+
const first = paths[0];
|
|
9718
|
+
if (typeof first === "string") {
|
|
9719
|
+
return first;
|
|
9720
|
+
}
|
|
9721
|
+
}
|
|
9722
|
+
}
|
|
9723
|
+
return void 0;
|
|
9724
|
+
}
|
|
9725
|
+
async function parseZedSessionFile(dbPath, options) {
|
|
9726
|
+
const { DatabaseSync } = await import("node:sqlite");
|
|
9727
|
+
const fzstd = await Promise.resolve().then(() => (init_esm(), esm_exports));
|
|
9728
|
+
const decompress2 = fzstd.decompress;
|
|
9729
|
+
if (!dbPath.endsWith(".db")) {
|
|
9730
|
+
return [];
|
|
9731
|
+
}
|
|
9732
|
+
const db = new DatabaseSync(dbPath, { readOnly: true });
|
|
9733
|
+
const events = [];
|
|
9734
|
+
try {
|
|
9735
|
+
const rows = db.prepare(
|
|
9736
|
+
"SELECT id, data, data_type, updated_at, created_at, summary, folder_paths FROM threads ORDER BY updated_at"
|
|
9737
|
+
).all();
|
|
9738
|
+
for (const row of rows) {
|
|
9739
|
+
const sessionId = row.id;
|
|
9740
|
+
const threadTs = row.updated_at;
|
|
9741
|
+
if (!threadTs) {
|
|
9742
|
+
continue;
|
|
9743
|
+
}
|
|
9744
|
+
const folderRaw = row.folder_paths || "";
|
|
9745
|
+
const folder = folderRaw.split(/[\n,]/).map((s) => s.trim()).find(Boolean);
|
|
9746
|
+
const cwd = folder || void 0;
|
|
9747
|
+
const project = cwd ? path20.basename(cwd) : row.summary ? row.summary.slice(0, 40) : void 0;
|
|
9748
|
+
let json;
|
|
9749
|
+
try {
|
|
9750
|
+
const bytes = row.data_type === "zstd" ? decompress2(new Uint8Array(row.data)) : new Uint8Array(row.data);
|
|
9751
|
+
json = JSON.parse(new TextDecoder().decode(bytes));
|
|
9752
|
+
} catch {
|
|
9753
|
+
continue;
|
|
9754
|
+
}
|
|
9755
|
+
if (!isPlainObject(json)) {
|
|
9756
|
+
continue;
|
|
9757
|
+
}
|
|
9758
|
+
const modelObj = objectField(json, "model");
|
|
9759
|
+
const model = modelObj ? stringField(modelObj, "model") : void 0;
|
|
9760
|
+
const provider = modelObj ? stringField(modelObj, "provider") : void 0;
|
|
9761
|
+
const requestUsage = objectField(json, "request_token_usage");
|
|
9762
|
+
const messages = arrayField(json, "messages") || [];
|
|
9763
|
+
events.push(baseZedEvent({
|
|
9764
|
+
ts: row.created_at || threadTs,
|
|
9765
|
+
type: "session.started",
|
|
9766
|
+
sessionId,
|
|
9767
|
+
cwd,
|
|
9768
|
+
project,
|
|
9769
|
+
model,
|
|
9770
|
+
provider,
|
|
9771
|
+
operation: "session start",
|
|
9772
|
+
confidence: "partial"
|
|
9773
|
+
}));
|
|
9774
|
+
let currentTurnId;
|
|
9775
|
+
let turnStarted = false;
|
|
9776
|
+
let msgIndex = 0;
|
|
9777
|
+
for (const msg of messages) {
|
|
9778
|
+
msgIndex++;
|
|
9779
|
+
if (!isPlainObject(msg)) {
|
|
9780
|
+
continue;
|
|
9781
|
+
}
|
|
9782
|
+
const userPayload = objectField(msg, "User");
|
|
9783
|
+
const agentPayload = objectField(msg, "Agent");
|
|
9784
|
+
if (userPayload) {
|
|
9785
|
+
if (turnStarted && currentTurnId) {
|
|
9786
|
+
events.push(baseZedEvent({
|
|
9787
|
+
ts: threadTs,
|
|
9788
|
+
type: "turn.completed",
|
|
9789
|
+
sessionId,
|
|
9790
|
+
turnId: currentTurnId,
|
|
9791
|
+
cwd,
|
|
9792
|
+
project,
|
|
9793
|
+
model,
|
|
9794
|
+
provider,
|
|
9795
|
+
operation: "turn completed",
|
|
9796
|
+
confidence: "partial"
|
|
9797
|
+
}));
|
|
9798
|
+
}
|
|
9799
|
+
const requestId = stringField(userPayload, "id") || `${sessionId}:${msgIndex}`;
|
|
9800
|
+
currentTurnId = `turn_${createStableHash([sessionId, requestId]).slice(0, 24)}`;
|
|
9801
|
+
turnStarted = true;
|
|
9802
|
+
events.push(baseZedEvent({
|
|
9803
|
+
ts: threadTs,
|
|
9804
|
+
type: "turn.started",
|
|
9805
|
+
sessionId,
|
|
9806
|
+
turnId: currentTurnId,
|
|
9807
|
+
cwd,
|
|
9808
|
+
project,
|
|
9809
|
+
model,
|
|
9810
|
+
provider,
|
|
9811
|
+
operation: "turn start",
|
|
9812
|
+
confidence: "partial"
|
|
9813
|
+
}));
|
|
9814
|
+
const content = arrayField(userPayload, "content") || [];
|
|
9815
|
+
let promptText = "";
|
|
9816
|
+
for (const part of content) {
|
|
9817
|
+
if (!isPlainObject(part)) {
|
|
9818
|
+
continue;
|
|
9819
|
+
}
|
|
9820
|
+
const text = stringField(part, "Text");
|
|
9821
|
+
if (text) {
|
|
9822
|
+
promptText += text;
|
|
9823
|
+
}
|
|
9824
|
+
}
|
|
9825
|
+
if (promptText) {
|
|
9826
|
+
events.push(baseZedEvent({
|
|
9827
|
+
ts: threadTs,
|
|
9828
|
+
type: "prompt.submitted",
|
|
9829
|
+
sessionId,
|
|
9830
|
+
turnId: currentTurnId,
|
|
9831
|
+
cwd,
|
|
9832
|
+
project,
|
|
9833
|
+
model,
|
|
9834
|
+
provider,
|
|
9835
|
+
operation: "prompt submitted",
|
|
9836
|
+
confidence: "partial",
|
|
9837
|
+
metrics: { prompts: 1, promptChars: promptText.length },
|
|
9838
|
+
refs: stringRefs({ promptHash: `sha256:${createStableHash(promptText)}` })
|
|
9839
|
+
}));
|
|
9840
|
+
}
|
|
9841
|
+
const usageEntry = requestUsage ? objectField(requestUsage, requestId) : void 0;
|
|
9842
|
+
if (usageEntry) {
|
|
9843
|
+
const usage = zedUsageFromRequest(usageEntry);
|
|
9844
|
+
if (usage) {
|
|
9845
|
+
const metrics = {
|
|
9846
|
+
tokensInput: usage.tokensInput,
|
|
9847
|
+
tokensOutput: usage.tokensOutput,
|
|
9848
|
+
tokensTotal: usage.tokensTotal
|
|
9849
|
+
};
|
|
9850
|
+
events.push(baseZedEvent({
|
|
9851
|
+
ts: threadTs,
|
|
9852
|
+
type: "model.usage",
|
|
9853
|
+
sessionId,
|
|
9854
|
+
turnId: currentTurnId,
|
|
9855
|
+
cwd,
|
|
9856
|
+
project,
|
|
9857
|
+
model,
|
|
9858
|
+
provider,
|
|
9859
|
+
operation: "model usage",
|
|
9860
|
+
confidence: "partial",
|
|
9861
|
+
metrics
|
|
9862
|
+
}));
|
|
9863
|
+
}
|
|
9864
|
+
}
|
|
9865
|
+
}
|
|
9866
|
+
if (agentPayload) {
|
|
9867
|
+
const content = arrayField(agentPayload, "content") || [];
|
|
9868
|
+
for (const part of content) {
|
|
9869
|
+
if (!isPlainObject(part)) {
|
|
9870
|
+
continue;
|
|
9871
|
+
}
|
|
9872
|
+
const toolUse = objectField(part, "ToolUse");
|
|
9873
|
+
if (!toolUse) {
|
|
9874
|
+
continue;
|
|
9875
|
+
}
|
|
9876
|
+
const tool = stringField(toolUse, "name") || "unknown";
|
|
9877
|
+
const callId = stringField(toolUse, "id") || `call_${createStableHash([sessionId, currentTurnId || "", tool, msgIndex]).slice(0, 16)}`;
|
|
9878
|
+
const input = objectField(toolUse, "input");
|
|
9879
|
+
events.push(baseZedEvent({
|
|
9880
|
+
ts: threadTs,
|
|
9881
|
+
type: "tool.started",
|
|
9882
|
+
sessionId,
|
|
9883
|
+
turnId: currentTurnId,
|
|
9884
|
+
cwd,
|
|
9885
|
+
project,
|
|
9886
|
+
model,
|
|
9887
|
+
provider,
|
|
9888
|
+
tool,
|
|
9889
|
+
operation: `${tool} started`,
|
|
9890
|
+
metrics: { toolCalls: 1 },
|
|
9891
|
+
refs: stringRefs({ sourceId: callId }),
|
|
9892
|
+
confidence: "exact"
|
|
9893
|
+
}));
|
|
9894
|
+
const toolResults = objectField(agentPayload, "tool_results");
|
|
9895
|
+
const resultEntry = toolResults ? objectField(toolResults, callId) : void 0;
|
|
9896
|
+
const isError = resultEntry ? Boolean(numberField(resultEntry, "is_error")) : false;
|
|
9897
|
+
const success = !isError;
|
|
9898
|
+
events.push(baseZedEvent({
|
|
9899
|
+
ts: threadTs,
|
|
9900
|
+
type: success ? "tool.completed" : "tool.failed",
|
|
9901
|
+
sessionId,
|
|
9902
|
+
turnId: currentTurnId,
|
|
9903
|
+
cwd,
|
|
9904
|
+
project,
|
|
9905
|
+
model,
|
|
9906
|
+
provider,
|
|
9907
|
+
tool,
|
|
9908
|
+
success,
|
|
9909
|
+
operation: success ? `${tool} completed` : `${tool} failed`,
|
|
9910
|
+
refs: stringRefs({ sourceId: callId }),
|
|
9911
|
+
confidence: "exact"
|
|
9912
|
+
}));
|
|
9913
|
+
if (tool === "terminal") {
|
|
9914
|
+
const command = input ? stringField(input, "command") : void 0;
|
|
9915
|
+
events.push(baseZedEvent({
|
|
9916
|
+
ts: threadTs,
|
|
9917
|
+
type: success ? "command.completed" : "command.failed",
|
|
9918
|
+
sessionId,
|
|
9919
|
+
turnId: currentTurnId,
|
|
9920
|
+
cwd,
|
|
9921
|
+
project,
|
|
9922
|
+
model,
|
|
9923
|
+
provider,
|
|
9924
|
+
tool: "terminal",
|
|
9925
|
+
success,
|
|
9926
|
+
operation: success ? "command completed" : "command failed",
|
|
9927
|
+
metrics: { commandCalls: 1 },
|
|
9928
|
+
refs: stringRefs({
|
|
9929
|
+
sourceId: callId,
|
|
9930
|
+
commandHash: command ? `sha256:${createStableHash(String(command))}` : void 0
|
|
9931
|
+
}),
|
|
9932
|
+
confidence: "partial"
|
|
9933
|
+
}));
|
|
9934
|
+
}
|
|
9935
|
+
const filePath = filePathFromToolInput(tool, input);
|
|
9936
|
+
if (filePath) {
|
|
9937
|
+
events.push(baseZedEvent({
|
|
9938
|
+
ts: threadTs,
|
|
9939
|
+
type: toolFileActivityType(tool),
|
|
9940
|
+
sessionId,
|
|
9941
|
+
turnId: currentTurnId,
|
|
9942
|
+
cwd,
|
|
9943
|
+
project,
|
|
9944
|
+
model,
|
|
9945
|
+
provider,
|
|
9946
|
+
tool,
|
|
9947
|
+
success,
|
|
9948
|
+
operation: `${tool} file activity`,
|
|
9949
|
+
fileActivities: [{
|
|
9950
|
+
ts: threadTs,
|
|
9951
|
+
path: filePath,
|
|
9952
|
+
operation: operationForTool(tool)
|
|
9953
|
+
}],
|
|
9954
|
+
refs: stringRefs({ sourceId: callId }),
|
|
9955
|
+
confidence: "partial"
|
|
9956
|
+
}));
|
|
9957
|
+
}
|
|
9958
|
+
}
|
|
9959
|
+
}
|
|
9960
|
+
}
|
|
9961
|
+
if (turnStarted && currentTurnId) {
|
|
9962
|
+
events.push(baseZedEvent({
|
|
9963
|
+
ts: threadTs,
|
|
9964
|
+
type: "turn.completed",
|
|
9965
|
+
sessionId,
|
|
9966
|
+
turnId: currentTurnId,
|
|
9967
|
+
cwd,
|
|
9968
|
+
project,
|
|
9969
|
+
model,
|
|
9970
|
+
provider,
|
|
9971
|
+
operation: "turn completed",
|
|
9972
|
+
confidence: "partial"
|
|
9973
|
+
}));
|
|
9974
|
+
}
|
|
9975
|
+
events.push(baseZedEvent({
|
|
9976
|
+
ts: threadTs,
|
|
9977
|
+
type: "session.ended",
|
|
9978
|
+
sessionId,
|
|
9979
|
+
cwd,
|
|
9980
|
+
project,
|
|
9981
|
+
model,
|
|
9982
|
+
provider,
|
|
9983
|
+
operation: "session end",
|
|
9984
|
+
confidence: "partial"
|
|
9985
|
+
}));
|
|
9986
|
+
}
|
|
9987
|
+
} finally {
|
|
9988
|
+
db.close();
|
|
9989
|
+
}
|
|
9990
|
+
return events.filter((event) => matchesBackfillFilters(event, options));
|
|
9991
|
+
}
|
|
9992
|
+
async function zedBackfillFiles(sourceRoot, home = os9.homedir(), env) {
|
|
9993
|
+
const { stat: stat14 } = await import("node:fs/promises");
|
|
9994
|
+
if (sourceRoot) {
|
|
9995
|
+
if (!sourceRoot.endsWith(".db")) {
|
|
9996
|
+
return [];
|
|
9997
|
+
}
|
|
9998
|
+
const info = await stat14(sourceRoot).catch(() => null);
|
|
9999
|
+
if (!info) {
|
|
10000
|
+
return [];
|
|
10001
|
+
}
|
|
10002
|
+
return [{ path: sourceRoot, modifiedAt: info.mtime.toISOString() }];
|
|
10003
|
+
}
|
|
10004
|
+
for (const candidatePath of zedThreadsCandidates(home, env)) {
|
|
10005
|
+
const info = await stat14(candidatePath).catch(() => null);
|
|
10006
|
+
if (info) {
|
|
10007
|
+
return [{ path: candidatePath, modifiedAt: info.mtime.toISOString() }];
|
|
10008
|
+
}
|
|
10009
|
+
}
|
|
10010
|
+
return [];
|
|
10011
|
+
}
|
|
10012
|
+
function createZedAdapter() {
|
|
10013
|
+
return {
|
|
10014
|
+
id: "zed",
|
|
10015
|
+
label: "Zed",
|
|
10016
|
+
agentName: "zed",
|
|
10017
|
+
kind: "ide",
|
|
10018
|
+
detectPath(home, env) {
|
|
10019
|
+
return zedConfigDir(home, env);
|
|
10020
|
+
},
|
|
10021
|
+
installedPath(home, env) {
|
|
10022
|
+
return path20.join(zedConfigDir(home, env), "vibetime-marker");
|
|
10023
|
+
},
|
|
10024
|
+
async isInstalled() {
|
|
10025
|
+
return false;
|
|
10026
|
+
},
|
|
10027
|
+
installEntries(_home, _env) {
|
|
10028
|
+
return [];
|
|
10029
|
+
},
|
|
10030
|
+
sourcePaths(home, env) {
|
|
10031
|
+
return zedThreadsCandidates(home, env);
|
|
10032
|
+
},
|
|
10033
|
+
parseSessionFile: parseZedSessionFile
|
|
10034
|
+
};
|
|
10035
|
+
}
|
|
10036
|
+
|
|
8845
10037
|
// src/lib/pricing.ts
|
|
8846
10038
|
function estimateEventCostUsd(event) {
|
|
8847
10039
|
if (event.type !== "model.usage") {
|
|
@@ -9155,7 +10347,7 @@ function totalTokensFromEvent(event) {
|
|
|
9155
10347
|
if (typeof explicit === "number" && explicit > 0) {
|
|
9156
10348
|
return explicit;
|
|
9157
10349
|
}
|
|
9158
|
-
return Math.max(0, event.metrics?.tokensInput || 0) + Math.max(0, event.metrics?.tokensOutput || 0)
|
|
10350
|
+
return Math.max(0, event.metrics?.tokensInput || 0) + Math.max(0, event.metrics?.tokensOutput || 0);
|
|
9159
10351
|
}
|
|
9160
10352
|
function lineStatsFromEvent(event) {
|
|
9161
10353
|
const files = event.fileActivities || [];
|
|
@@ -9286,15 +10478,15 @@ function hookCommandFromGroup(group) {
|
|
|
9286
10478
|
import { randomUUID } from "node:crypto";
|
|
9287
10479
|
import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
9288
10480
|
import { homedir, hostname } from "node:os";
|
|
9289
|
-
import
|
|
10481
|
+
import path21 from "node:path";
|
|
9290
10482
|
function configDir(home = homedir()) {
|
|
9291
|
-
return
|
|
10483
|
+
return path21.join(home, ".vibetime");
|
|
9292
10484
|
}
|
|
9293
10485
|
function configPath(home = homedir()) {
|
|
9294
|
-
return
|
|
10486
|
+
return path21.join(configDir(home), "config.json");
|
|
9295
10487
|
}
|
|
9296
10488
|
function machineIdPath(home = homedir()) {
|
|
9297
|
-
return
|
|
10489
|
+
return path21.join(configDir(home), "machine-id");
|
|
9298
10490
|
}
|
|
9299
10491
|
function readConfig(home = homedir()) {
|
|
9300
10492
|
const file = configPath(home);
|
|
@@ -9343,13 +10535,13 @@ init_fs();
|
|
|
9343
10535
|
// src/lib/logger.ts
|
|
9344
10536
|
import { appendFile, mkdir as mkdir4, rename, stat as stat12 } from "node:fs/promises";
|
|
9345
10537
|
import { homedir as homedir2 } from "node:os";
|
|
9346
|
-
import
|
|
10538
|
+
import path22 from "node:path";
|
|
9347
10539
|
var MAX_BYTES = 1 * 1024 * 1024;
|
|
9348
10540
|
function logDir(home = homedir2()) {
|
|
9349
|
-
return
|
|
10541
|
+
return path22.join(home, ".vibetime", "logs");
|
|
9350
10542
|
}
|
|
9351
10543
|
function logPath(home = homedir2(), name = "cli.log") {
|
|
9352
|
-
return
|
|
10544
|
+
return path22.join(logDir(home), name);
|
|
9353
10545
|
}
|
|
9354
10546
|
function serializeError(error) {
|
|
9355
10547
|
if (error instanceof Error) {
|
|
@@ -9524,8 +10716,8 @@ function buildHeaders(token, machine) {
|
|
|
9524
10716
|
...machine?.platform ? { "x-machine-platform": machine.platform } : {}
|
|
9525
10717
|
};
|
|
9526
10718
|
}
|
|
9527
|
-
function joinUrl(base,
|
|
9528
|
-
return new URL(
|
|
10719
|
+
function joinUrl(base, path24) {
|
|
10720
|
+
return new URL(path24, base.endsWith("/") ? base : `${base}/`).toString();
|
|
9529
10721
|
}
|
|
9530
10722
|
async function postRollupBatch(remote, rollups, options = {}) {
|
|
9531
10723
|
const response = await remote.fetchImpl(joinUrl(remote.baseUrl, "/v3/agent/ingest"), {
|
|
@@ -9608,6 +10800,7 @@ function createRegistry() {
|
|
|
9608
10800
|
registry.register(createWorkbuddyAdapter());
|
|
9609
10801
|
registry.register(createZCodeAdapter());
|
|
9610
10802
|
registry.register(createGrokBuildAdapter());
|
|
10803
|
+
registry.register(createZedAdapter());
|
|
9611
10804
|
return registry;
|
|
9612
10805
|
}
|
|
9613
10806
|
var defaultContext = {
|
|
@@ -10123,6 +11316,9 @@ async function listBackfillSourceFiles(source, options, ctx) {
|
|
|
10123
11316
|
if (source.id === "grok-build") {
|
|
10124
11317
|
return grokBackfillFiles(stringOption(options["source-root"]), resolveHome3(options, ctx), ctx.env);
|
|
10125
11318
|
}
|
|
11319
|
+
if (source.id === "zed") {
|
|
11320
|
+
return zedBackfillFiles(stringOption(options["source-root"]), resolveHome3(options, ctx), ctx.env);
|
|
11321
|
+
}
|
|
10126
11322
|
const roots = stringOption(options["source-root"]) ? [requiredOption(options, "source-root")] : source.paths;
|
|
10127
11323
|
const fileLists = await Promise.all(roots.map((r) => listJsonlFiles(r)));
|
|
10128
11324
|
const files = fileLists.flat().sort().slice(0, numberOption(options.limit) || void 0);
|
|
@@ -10440,13 +11636,13 @@ function selectBackfillFilesForImport(files, watermarkTs) {
|
|
|
10440
11636
|
});
|
|
10441
11637
|
}
|
|
10442
11638
|
function backfillIncrementalStatePath(home) {
|
|
10443
|
-
return
|
|
11639
|
+
return path23.join(home, ".vibetime", "backfill-state.json");
|
|
10444
11640
|
}
|
|
10445
11641
|
function syncLocalTriggerStatePath(home) {
|
|
10446
|
-
return
|
|
11642
|
+
return path23.join(home, ".vibetime", "sync-local-trigger.json");
|
|
10447
11643
|
}
|
|
10448
11644
|
function syncLocalTriggerLockPath(home) {
|
|
10449
|
-
return
|
|
11645
|
+
return path23.join(home, ".vibetime", "sync-local-trigger.lock");
|
|
10450
11646
|
}
|
|
10451
11647
|
function backfillRemoteKey(baseUrl) {
|
|
10452
11648
|
try {
|
|
@@ -10508,7 +11704,7 @@ async function readBackfillIncrementalStateFile(home, ctx) {
|
|
|
10508
11704
|
}
|
|
10509
11705
|
async function writeBackfillIncrementalStateFile(home, file) {
|
|
10510
11706
|
const statePath = backfillIncrementalStatePath(home);
|
|
10511
|
-
await mkdir5(
|
|
11707
|
+
await mkdir5(path23.dirname(statePath), { recursive: true });
|
|
10512
11708
|
await writeFile4(statePath, `${JSON.stringify(file, null, 2)}
|
|
10513
11709
|
`, "utf8");
|
|
10514
11710
|
}
|
|
@@ -10557,7 +11753,7 @@ async function readSyncLocalTriggerState(statePath) {
|
|
|
10557
11753
|
return nextState;
|
|
10558
11754
|
}
|
|
10559
11755
|
async function writeSyncLocalTriggerState(statePath, state) {
|
|
10560
|
-
await mkdir5(
|
|
11756
|
+
await mkdir5(path23.dirname(statePath), { recursive: true });
|
|
10561
11757
|
await writeFile4(statePath, `${JSON.stringify(state, null, 2)}
|
|
10562
11758
|
`, "utf8");
|
|
10563
11759
|
}
|
|
@@ -10572,12 +11768,12 @@ async function readSyncLocalLock(lockPath) {
|
|
|
10572
11768
|
return { pid: lock.pid, startedAt: lock.startedAt };
|
|
10573
11769
|
}
|
|
10574
11770
|
async function writeSyncLocalLock(lockPath, lock) {
|
|
10575
|
-
await mkdir5(
|
|
11771
|
+
await mkdir5(path23.dirname(lockPath), { recursive: true });
|
|
10576
11772
|
await writeFile4(lockPath, `${JSON.stringify(lock, null, 2)}
|
|
10577
11773
|
`, "utf8");
|
|
10578
11774
|
}
|
|
10579
11775
|
async function acquireSyncLocalLock(lockPath, lock) {
|
|
10580
|
-
await mkdir5(
|
|
11776
|
+
await mkdir5(path23.dirname(lockPath), { recursive: true });
|
|
10581
11777
|
try {
|
|
10582
11778
|
const handle = await open(lockPath, "wx");
|
|
10583
11779
|
try {
|
|
@@ -10657,10 +11853,10 @@ function syncLocalRunnerEntryArgs(cliPath) {
|
|
|
10657
11853
|
if (cliPath.endsWith(".ts")) {
|
|
10658
11854
|
return ["--import", "tsx", cliPath];
|
|
10659
11855
|
}
|
|
10660
|
-
return [
|
|
11856
|
+
return [path23.resolve(path23.dirname(cliPath), "../bin/vibetime.mjs")];
|
|
10661
11857
|
}
|
|
10662
11858
|
function resolveHome3(options, ctx) {
|
|
10663
|
-
return
|
|
11859
|
+
return path23.resolve(stringOption(options.home) || ctx.env.HOME || os10.homedir());
|
|
10664
11860
|
}
|
|
10665
11861
|
function requestedTargets(options) {
|
|
10666
11862
|
const value = options.target || options.targets;
|