@outerlayer/cli 0.36.0-next.20261102195652 → 0.36.0-next.20261102213701
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 +4 -13
- package/dist/agent-setup-2WL54CA2.js +39 -0
- package/dist/{agent-subcommand-4TEUJJNL.js → agent-subcommand-Z4UDDCLB.js} +6 -5
- package/dist/{artifact-link-cmd-ZCMQIT5Y.js → artifact-link-cmd-ZPQXVG5O.js} +2 -2
- package/dist/{bridge-4KPODDN7.js → bridge-LVTX4DVM.js} +8 -7
- package/dist/{build-3CEFKWGY.js → build-W5LRG2AO.js} +14 -14
- package/dist/{build-disk-DLW3WKC5.js → build-disk-3KTQZ6N5.js} +12 -12
- package/dist/build-info.json +1 -1
- package/dist/{builder-ALMQ5AWP.js → builder-UMCVSMDY.js} +11 -11
- package/dist/caller-DYXZCUF2.js +22 -0
- package/dist/{check-AEDFTYH6.js → check-NFLR5CGS.js} +58 -58
- package/dist/{chunk-DTQPDMHG.js → chunk-23SNF2LN.js} +4 -4
- package/dist/{chunk-DL2RYNXQ.js → chunk-2E2WWMRX.js} +28 -60
- package/dist/{chunk-6JLYU322.js → chunk-32GBZ7HD.js} +3 -3
- package/dist/{chunk-LZS5EYZ6.js → chunk-35OBGZYO.js} +1 -1
- package/dist/{chunk-BACWWK3E.js → chunk-36ML3NIO.js} +15 -15
- package/dist/{chunk-73E33ZA2.js → chunk-3EEUQZQU.js} +9 -9
- package/dist/{chunk-BZSJ77MO.js → chunk-46FKHE74.js} +1 -1
- package/dist/{chunk-HRBSEXYC.js → chunk-4Y7IEPQH.js} +6 -6
- package/dist/{chunk-Y5S2G2EZ.js → chunk-4YGPLC5Y.js} +7 -7
- package/dist/{chunk-2YC3TXWX.js → chunk-52RRBTZ5.js} +1 -1
- package/dist/{chunk-B5SWBFVE.js → chunk-66UG5SL4.js} +3 -3
- package/dist/{chunk-Z3MB7SV7.js → chunk-72EOJJVT.js} +7 -7
- package/dist/{chunk-FWKQHKCR.js → chunk-AACYODIT.js} +7 -5
- package/dist/{chunk-7XTLS5PG.js → chunk-AZTTOBJ5.js} +5 -5
- package/dist/{chunk-6QSIK5VA.js → chunk-B5GDCCOZ.js} +1 -1
- package/dist/{chunk-42DBDDHP.js → chunk-CBMEWHAR.js} +1 -1
- package/dist/{chunk-G35Y4LN5.js → chunk-CXMXXRNS.js} +1 -1
- package/dist/{chunk-J6VC3JCG.js → chunk-DCOQWKLK.js} +1 -1
- package/dist/{chunk-A24PDRNU.js → chunk-E2U7BBAT.js} +5 -5
- package/dist/{chunk-IX6CFXSW.js → chunk-EM4QCRI6.js} +9 -9
- package/dist/{chunk-J2OMKFYB.js → chunk-F7ODYKBA.js} +3 -3
- package/dist/{chunk-WVAXJOWG.js → chunk-FCMEWS3G.js} +5 -5
- package/dist/{chunk-7UGMB5VS.js → chunk-FVIDZ3GK.js} +34 -37
- package/dist/{chunk-LSLK4RS4.js → chunk-G3BUOMCF.js} +1 -0
- package/dist/{chunk-CA4OE2QT.js → chunk-GFSS3FRE.js} +4 -4
- package/dist/{chunk-KN3TDNF7.js → chunk-HGOJ67KV.js} +10 -21
- package/dist/{chunk-J6HWRVN2.js → chunk-HHKVXKQI.js} +8 -8
- package/dist/{chunk-PIZA7OG2.js → chunk-HKJCNBUB.js} +1 -1
- package/dist/{chunk-D74RGORK.js → chunk-HXSU4JLV.js} +1 -1
- package/dist/{chunk-BSPJI5T7.js → chunk-IEFSDAVW.js} +1 -1
- package/dist/{chunk-4UUKUOS7.js → chunk-IFLD3WEB.js} +3 -3
- package/dist/{chunk-M4HH2F64.js → chunk-ILP4ABFG.js} +6 -6
- package/dist/{chunk-HRHWA6TZ.js → chunk-IOFEDCTL.js} +1 -1
- package/dist/{chunk-H2NJG3TE.js → chunk-JU5SQNFB.js} +4 -4
- package/dist/{chunk-2XN34EKQ.js → chunk-JUQ52FZI.js} +3 -3
- package/dist/{chunk-JBPVEXHQ.js → chunk-JZBFR6JB.js} +8 -8
- package/dist/{chunk-T5QBWM6M.js → chunk-KG5BQFSO.js} +1 -1
- package/dist/{chunk-B36NSEUM.js → chunk-KIY2AUHY.js} +1 -1
- package/dist/{chunk-JVHWWJ2J.js → chunk-KKI3POPP.js} +6 -6
- package/dist/{chunk-4DLJ343I.js → chunk-KTL7GFQ3.js} +1 -1
- package/dist/{chunk-I4DM7SNX.js → chunk-LTAMZ36E.js} +1 -1
- package/dist/{chunk-6KH3NMIT.js → chunk-M7AIU22N.js} +124 -1099
- package/dist/{chunk-BN5U4RJU.js → chunk-MKGJ7TTH.js} +8 -8
- package/dist/{chunk-HZVS4MGL.js → chunk-NTK7RUVE.js} +7 -7
- package/dist/{chunk-UCMIS74X.js → chunk-OPUJGPPT.js} +2 -2
- package/dist/{chunk-PBGNX3PS.js → chunk-OQZ2B5AN.js} +1 -1
- package/dist/{chunk-PSQEGJPN.js → chunk-OROFFYEM.js} +5 -5
- package/dist/{chunk-Z66CKWOM.js → chunk-PMXVWQ4T.js} +1 -1
- package/dist/{chunk-ZSRMJOAK.js → chunk-QE7L5PJV.js} +3 -3
- package/dist/{chunk-6Z7R24XA.js → chunk-QJHXX2HG.js} +8 -8
- package/dist/{chunk-LO4CK734.js → chunk-REXQKAY7.js} +1 -1
- package/dist/{chunk-NMBXA3AT.js → chunk-RSPTOS4S.js} +3 -3
- package/dist/{chunk-HTRDL42C.js → chunk-TI32Q3VB.js} +1 -1
- package/dist/{chunk-I6U6QPN6.js → chunk-TOP4K2T6.js} +1138 -80
- package/dist/{chunk-XIDDJSQU.js → chunk-U37FB7ER.js} +2 -2
- package/dist/{chunk-F36EKGMP.js → chunk-UASEIXDB.js} +75 -159
- package/dist/{chunk-ML5YKV3B.js → chunk-UKDKM6Y6.js} +1 -1
- package/dist/{chunk-LHHDX7FB.js → chunk-UQ2YFDGP.js} +5 -5
- package/dist/{chunk-CXJC3JLN.js → chunk-V5S6CVGP.js} +5 -12
- package/dist/{chunk-FWSVWPMS.js → chunk-V6V3NN5G.js} +1 -1
- package/dist/{chunk-VKKKVYA4.js → chunk-VHX2C7DU.js} +1 -1
- package/dist/{chunk-LSZUTI6O.js → chunk-VNXITMKE.js} +1 -1
- package/dist/{chunk-T2KBHW6P.js → chunk-VUINLLWP.js} +3 -3
- package/dist/{chunk-5XX75FJ6.js → chunk-VWMQA7FN.js} +8 -8
- package/dist/{chunk-GBGJGYEE.js → chunk-W3CY6H56.js} +6 -6
- package/dist/{chunk-H23JP73I.js → chunk-WGZOLJPP.js} +1 -1
- package/dist/{chunk-A2U7T4ZH.js → chunk-X2M2G376.js} +18 -18
- package/dist/{chunk-FOSYM7TQ.js → chunk-X4QHDRXT.js} +2 -2
- package/dist/{chunk-SBZ545DH.js → chunk-XILGXRHT.js} +2 -2
- package/dist/{chunk-FIUUESD4.js → chunk-YIDWZYDY.js} +4 -4
- package/dist/{chunk-CI5LFLKH.js → chunk-YJQBL6SD.js} +2 -2
- package/dist/{chunk-Y2P3HWUG.js → chunk-YQGYZB6Y.js} +28 -20
- package/dist/{chunk-MVPOYQQY.js → chunk-Z4ASKZKN.js} +1 -1
- package/dist/{chunk-D6EXW4EB.js → chunk-ZM2SKQJD.js} +2 -2
- package/dist/{claude-launcher-NJGZUB3P.js → claude-launcher-LXCRQNU3.js} +10 -9
- package/dist/{cli-POIDBCZA.js → cli-WGFTREIM.js} +153 -165
- package/dist/{command-ZLBFX553.js → command-BZDNRIFI.js} +53 -53
- package/dist/config-VV4J2DMW.js +21 -0
- package/dist/{connect-cmd-6YKNFJJR.js → connect-cmd-UDYTPV2S.js} +14 -14
- package/dist/{container-start-55QELXPJ.js → container-start-BQD6IAKZ.js} +51 -51
- package/dist/{context-cleanup-3K2AOECJ.js → context-cleanup-ZKAL6X5I.js} +6 -5
- package/dist/{context-show-cmd-FGMRJ7IG.js → context-show-cmd-FXIYFC6Q.js} +15 -15
- package/dist/{control-plane-launch-DGPA3ONU.js → control-plane-launch-6HIHBOHF.js} +16 -15
- package/dist/{demo-record-cmd-2OKCGST7.js → demo-record-cmd-JTIK5WI3.js} +9 -8
- package/dist/{demo-voice-cmd-BPTSL7JA.js → demo-voice-cmd-5HV4AHY4.js} +23 -23
- package/dist/dist-64LM4JF4.js +7 -0
- package/dist/{docker-GFEEV42Z.js → docker-RB7YFA52.js} +11 -11
- package/dist/{doctor-ZOQSI3HL.js → doctor-BNL5J2NG.js} +54 -80
- package/dist/emit-artifact-cmd-VF6PO7NJ.js +43 -0
- package/dist/{emit-cmd-RO4L4PFZ.js → emit-cmd-PTOSSDQK.js} +9 -8
- package/dist/emit-criteria-cmd-QGCS6RCB.js +34 -0
- package/dist/{emit-demo-cmd-5KL64L74.js → emit-demo-cmd-O7YLI4ZL.js} +23 -23
- package/dist/{emit-finding-cmd-R4OEWQQR.js → emit-finding-cmd-GO2C5QCS.js} +17 -17
- package/dist/{emit-result-cmd-5YNQDTYG.js → emit-result-cmd-LQ4EW7ML.js} +21 -21
- package/dist/{emit-step-cmd-Z5WC7UEQ.js → emit-step-cmd-JWUNEZ4N.js} +17 -17
- package/dist/{exec-client-54XKNPTI.js → exec-client-725NVWZ5.js} +9 -8
- package/dist/find-unit-U5U52ASA.js +23 -0
- package/dist/{findings-cmd-J5ZCY2AT.js → findings-cmd-JN67G7EG.js} +17 -17
- package/dist/{fleet-readiness-DKCFOUYP.js → fleet-readiness-7P5NN3RT.js} +16 -15
- package/dist/governing-source-NC7N3PKM.js +40 -0
- package/dist/{guest-init-5QZRGP62.js → guest-init-N65WE3XP.js} +10 -9
- package/dist/{hook-fast-ICT2PRQX.js → hook-fast-VZDS3U7L.js} +4 -4
- package/dist/{hook-install-GDNRMML4.js → hook-install-DOEXRPO5.js} +6 -5
- package/dist/{hook-wrap-fast-LWWKKPGK.js → hook-wrap-fast-L5PCBVNI.js} +3 -3
- package/dist/host-checks-5HVG67AR.js +78 -0
- package/dist/host-key-KPUIJK4Q.js +17 -0
- package/dist/{image-tag-RX4WTHJH.js → image-tag-RAVG4ZXU.js} +9 -8
- package/dist/index.js +6 -6
- package/dist/{init-BZXVQO22.js → init-J5XW2VNL.js} +49 -50
- package/dist/init-MN4R6USQ.js +78 -0
- package/dist/{init-cmd-3LWFEKHD.js → init-cmd-INPWUFWW.js} +31 -31
- package/dist/{init-update-THEHC25C.js → init-update-7BA2HEZD.js} +26 -26
- package/dist/{install-cmd-WBVTTE5Z.js → install-cmd-UUEJWTHG.js} +11 -10
- package/dist/{layout-7XMC7S6K.js → layout-KSD373US.js} +6 -5
- package/dist/{login-browser-QH4KYG3F.js → login-browser-NUQQYH5J.js} +2 -2
- package/dist/{logs-7YIXBO2K.js → logs-2NBI76N2.js} +8 -7
- package/dist/loop-G7HCDVIP.js +89 -0
- package/dist/machine-WQCCGKOP.js +78 -0
- package/dist/{machine-skills-HR4RNRNR.js → machine-skills-IMGN27M7.js} +6 -5
- package/dist/{mcp-install-cmd-SMPLT43Q.js → mcp-install-cmd-25PA5RAI.js} +6 -5
- package/dist/{mcp-serve-cmd-HLS24XCG.js → mcp-serve-cmd-JVND6WYT.js} +10 -9
- package/dist/{paths-2YTU4QIO.js → paths-S6KJMQSQ.js} +8 -7
- package/dist/pending-BBPET4YL.js +17 -0
- package/dist/{pidfile-SPBTMTCJ.js → pidfile-QDFTWZP4.js} +9 -8
- package/dist/{record-3KXRFK5C.js → record-AJSJBMOG.js} +9 -8
- package/dist/{relay-I2T43PPB.js → relay-X7EBGNZW.js} +6 -5
- package/dist/{relay-protocol-GI2GC2AM.js → relay-protocol-TAXUFBSM.js} +6 -5
- package/dist/runner-env-XKUW67Y4.js +23 -0
- package/dist/{runner-identity-32MTGA2F.js → runner-identity-7RYI6PS4.js} +11 -11
- package/dist/{runner-key-FXYWHMMO.js → runner-key-R4QPZDDR.js} +49 -49
- package/dist/{session-sender-B6INUY7G.js → session-sender-FQARNO3V.js} +22 -22
- package/dist/{shell-function-GYD2ZQQG.js → shell-function-D2T55XFG.js} +2 -2
- package/dist/{spec-cmd-ZEZFMC4A.js → spec-cmd-WOSYBAKL.js} +18 -18
- package/dist/{starter-pack-IMKIUA56.js → starter-pack-OLH6O4YX.js} +7 -6
- package/dist/state-IGLONCPS.js +17 -0
- package/dist/{status-VPFIIHOZ.js → status-BUHMAGRI.js} +49 -49
- package/dist/{statusline-fast-NUVHCNRX.js → statusline-fast-36U3TOCL.js} +3 -3
- package/dist/{sync-cmd-W756BQWX.js → sync-cmd-2DR7HOVJ.js} +21 -21
- package/dist/update-steps-GDNIKWWH.js +79 -0
- package/dist/{watch-6EDRJZMG.js → watch-3I4ZN52F.js} +29 -26
- package/dist/{work-claim-cmd-7HR4AVCT.js → work-claim-cmd-M6ACVTNM.js} +23 -23
- package/dist/{work-cmd-ZP4UIHBT.js → work-cmd-HLNFJWQQ.js} +17 -17
- package/dist/work-comment-cmd-JTCAB3DG.js +37 -0
- package/dist/{work-demo-cmd-3A7Z3VVS.js → work-demo-cmd-XLNJYGCL.js} +17 -17
- package/dist/{work-logs-cmd-NDPSRSCM.js → work-logs-cmd-Q3UUIOQI.js} +17 -17
- package/dist/{work-open-pr-cmd-Z5B3ERAU.js → work-open-pr-cmd-H74M4ZXC.js} +18 -18
- package/dist/{work-pr-cmd-ZVPGCDWD.js → work-pr-cmd-M3X2D5MC.js} +17 -17
- package/dist/{work-proofs-cmd-VAXJ5UBF.js → work-proofs-cmd-ZRPPBFDL.js} +19 -19
- package/dist/{work-proofs-record-K467JH24.js → work-proofs-record-PF2JRTWE.js} +27 -27
- package/dist/{work-stop-cmd-J45Q2QT7.js → work-stop-cmd-2NO2F2BD.js} +17 -17
- package/package.json +1 -1
- package/dist/agent-setup-5UWZZMZM.js +0 -39
- package/dist/caller-XNBGW4SP.js +0 -22
- package/dist/config-GKSSGMXD.js +0 -21
- package/dist/dist-VVZIGSAF.js +0 -7
- package/dist/emit-artifact-cmd-3LDJ4VRW.js +0 -43
- package/dist/emit-criteria-cmd-V3ERJXHB.js +0 -34
- package/dist/find-unit-OI56YEX5.js +0 -23
- package/dist/governing-source-7PD4ISRN.js +0 -40
- package/dist/host-checks-GADKYJFN.js +0 -78
- package/dist/host-key-FI6KWMJC.js +0 -16
- package/dist/init-EKF4ILHF.js +0 -78
- package/dist/loop-RUQQ4L5A.js +0 -89
- package/dist/machine-IGHZW3IO.js +0 -78
- package/dist/pending-S2SKIBCB.js +0 -16
- package/dist/runner-env-HOWRS6I6.js +0 -23
- package/dist/state-DVKFUWB3.js +0 -16
- package/dist/update-steps-D6L6AG6E.js +0 -79
- package/dist/work-comment-cmd-CYDOEMW3.js +0 -37
- package/dist/{chunk-TPMLB3VZ.js → chunk-A6RI6KTI.js} +1 -1
- package/dist/{chunk-P6PHY33P.js → chunk-F3T5QJ24.js} +1 -1
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire } from 'node:module';
|
|
3
|
-
import {
|
|
4
|
-
import { createHash } from 'crypto';
|
|
3
|
+
import { inputBandOf, BUCKET_MODEL_MAX_LENGTH } from './chunk-WUKLQWGY.js';
|
|
5
4
|
import { readFileSync, mkdirSync, statSync, copyFileSync, renameSync, unlinkSync, writeFileSync, readdirSync, realpathSync, watch as watch$1 } from 'fs';
|
|
6
|
-
import { type, homedir } from 'os';
|
|
7
5
|
import * as sp5 from 'path';
|
|
8
|
-
import { join, relative, dirname,
|
|
6
|
+
import { join, relative, dirname, resolve, sep } from 'path';
|
|
7
|
+
import { type, homedir } from 'os';
|
|
9
8
|
import { EventEmitter } from 'events';
|
|
10
9
|
import { readdir, stat, lstat, readlink, realpath, open } from 'fs/promises';
|
|
11
10
|
import { Readable } from 'stream';
|
|
@@ -71395,1032 +71394,7 @@ function costOfUsage(modelId, usage) {
|
|
|
71395
71394
|
function isPriceKnown(modelId) {
|
|
71396
71395
|
return resolvePrice(modelId).price !== null;
|
|
71397
71396
|
}
|
|
71398
|
-
|
|
71399
|
-
var OVERLONG_MODEL_ID = "(model id over 256 characters)";
|
|
71400
|
-
var bucketModel = (model) => model.length > BUCKET_MODEL_MAX_LENGTH ? OVERLONG_MODEL_ID : model;
|
|
71401
|
-
var cacheCreate1hOf = (u) => {
|
|
71402
|
-
var _a5;
|
|
71403
|
-
return Math.min((_a5 = u.cacheCreate1h) != null ? _a5 : 0, u.cacheCreate);
|
|
71404
|
-
};
|
|
71405
|
-
function bucketsFromTurns(turns) {
|
|
71406
|
-
var _a5, _b;
|
|
71407
|
-
const byKey = /* @__PURE__ */ new Map();
|
|
71408
|
-
for (const turn of turns) {
|
|
71409
|
-
const u = turn.usage;
|
|
71410
|
-
if (turn.role !== "assistant" || !u || !turn.model) continue;
|
|
71411
|
-
const speed = (_a5 = u.speed) != null ? _a5 : DEFAULT_SPEED;
|
|
71412
|
-
const band = inputBandOf(u.in + u.cacheRead + u.cacheCreate);
|
|
71413
|
-
const model = bucketModel(turn.model);
|
|
71414
|
-
const key = `${model}\0${speed}\0${band}`;
|
|
71415
|
-
let b = byKey.get(key);
|
|
71416
|
-
if (!b) {
|
|
71417
|
-
b = { model, speed, band, in: 0, out: 0, cacheRead: 0, cacheCreate5m: 0, cacheCreate1h: 0 };
|
|
71418
|
-
byKey.set(key, b);
|
|
71419
|
-
}
|
|
71420
|
-
const oneHour = cacheCreate1hOf(u);
|
|
71421
|
-
b.in += u.in;
|
|
71422
|
-
b.out += u.out;
|
|
71423
|
-
b.cacheRead += u.cacheRead;
|
|
71424
|
-
b.cacheCreate1h += oneHour;
|
|
71425
|
-
b.cacheCreate5m += (_b = u.cacheCreate5m) != null ? _b : u.cacheCreate - oneHour;
|
|
71426
|
-
}
|
|
71427
|
-
return [...byKey.values()].sort(
|
|
71428
|
-
(a, b) => a.model.localeCompare(b.model) || a.speed.localeCompare(b.speed) || a.band - b.band
|
|
71429
|
-
);
|
|
71430
|
-
}
|
|
71431
|
-
var WARNING_CODES = {
|
|
71432
|
-
unknownLineType: "unknown_line_type",
|
|
71433
|
-
malformedLine: "malformed_line",
|
|
71434
|
-
truncatedFinalLine: "truncated_final_line",
|
|
71435
|
-
versionNewer: "version_newer_than_supported",
|
|
71436
|
-
ambiguousTimezone: "ambiguous_timezone",
|
|
71437
|
-
unknownModelCost: "unknown_model_cost"
|
|
71438
|
-
};
|
|
71439
|
-
var WarningCollector = class {
|
|
71440
|
-
constructor() {
|
|
71441
|
-
this.counts = /* @__PURE__ */ new Map();
|
|
71442
|
-
this.details = /* @__PURE__ */ new Map();
|
|
71443
|
-
}
|
|
71444
|
-
add(code, detail) {
|
|
71445
|
-
var _a5;
|
|
71446
|
-
this.counts.set(code, ((_a5 = this.counts.get(code)) != null ? _a5 : 0) + 1);
|
|
71447
|
-
if (detail && !this.details.has(code)) {
|
|
71448
|
-
this.details.set(code, detail.slice(0, 200));
|
|
71449
|
-
}
|
|
71450
|
-
}
|
|
71451
|
-
has(code) {
|
|
71452
|
-
return this.counts.has(code);
|
|
71453
|
-
}
|
|
71454
|
-
toArray() {
|
|
71455
|
-
return [...this.counts.entries()].sort(([a], [b]) => a.localeCompare(b)).map(([code, count]) => {
|
|
71456
|
-
const detail = this.details.get(code);
|
|
71457
|
-
return detail ? { code, count, detail } : { code, count };
|
|
71458
|
-
});
|
|
71459
|
-
}
|
|
71460
|
-
/** Histogram for `--verbose` reports. */
|
|
71461
|
-
histogram() {
|
|
71462
|
-
return Object.fromEntries([...this.counts.entries()].sort(([a], [b]) => a.localeCompare(b)));
|
|
71463
|
-
}
|
|
71464
|
-
};
|
|
71465
|
-
var SUPPORTED_VERSIONS = {
|
|
71466
|
-
min: "2.1.0",
|
|
71467
|
-
// inclusive upper bound of what we've validated; bump as new versions land
|
|
71468
|
-
max: "2.1.255"
|
|
71469
|
-
};
|
|
71470
|
-
function compareVersions(a, b) {
|
|
71471
|
-
var _a5, _b, _c, _d;
|
|
71472
|
-
const pa = parseVersion(a);
|
|
71473
|
-
const pb = parseVersion(b);
|
|
71474
|
-
for (let i = 0; i < 3; i++) {
|
|
71475
|
-
if (((_a5 = pa[i]) != null ? _a5 : 0) !== ((_b = pb[i]) != null ? _b : 0)) return ((_c = pa[i]) != null ? _c : 0) - ((_d = pb[i]) != null ? _d : 0);
|
|
71476
|
-
}
|
|
71477
|
-
return 0;
|
|
71478
|
-
}
|
|
71479
|
-
function parseVersion(v) {
|
|
71480
|
-
return (v || "").split(".").map((n) => {
|
|
71481
|
-
const parsed = Number.parseInt(n, 10);
|
|
71482
|
-
return Number.isFinite(parsed) ? parsed : 0;
|
|
71483
|
-
});
|
|
71484
|
-
}
|
|
71485
|
-
function isNewerThanSupported(version2) {
|
|
71486
|
-
return compareVersions(version2, SUPPORTED_VERSIONS.max) > 0;
|
|
71487
|
-
}
|
|
71488
|
-
var EDIT_TOOLS = /* @__PURE__ */ new Set(["Edit", "Write", "MultiEdit", "NotebookEdit"]);
|
|
71489
|
-
var REJECTION_MARKERS = [
|
|
71490
|
-
"The user doesn't want to proceed",
|
|
71491
|
-
"[Request interrupted by user",
|
|
71492
|
-
"user doesn't want to take this action"
|
|
71493
|
-
];
|
|
71494
|
-
var TEXT_CAP = 4e3;
|
|
71495
|
-
var HOOK_INFOS_CAP = 50;
|
|
71496
|
-
var HOOK_COMMAND_CAP = 300;
|
|
71497
|
-
var HOOK_ERRORS_CAP = 3;
|
|
71498
|
-
var HOOK_ERROR_TEXT_CAP = 500;
|
|
71499
|
-
function isValidHookDurationMs(v) {
|
|
71500
|
-
return typeof v === "number" && Number.isInteger(v) && v >= 0;
|
|
71501
|
-
}
|
|
71502
|
-
var PEER_MARKERS = [
|
|
71503
|
-
/<teammate-message/,
|
|
71504
|
-
/<agent-message/,
|
|
71505
|
-
/^Another Claude session sent a message:/
|
|
71506
|
-
];
|
|
71507
|
-
var NOTIFICATION_MARKERS = [
|
|
71508
|
-
/<task-notification/,
|
|
71509
|
-
/^\[SYSTEM NOTIFICATION/,
|
|
71510
|
-
/This is an automated background-task event/,
|
|
71511
|
-
/^Caveat: The messages below/,
|
|
71512
|
-
/<command-name>|<local-command-stdout>|<command-message>|<local-command-caveat>/,
|
|
71513
|
-
/^Base directory for this skill:/,
|
|
71514
|
-
/^Path to the skill:/,
|
|
71515
|
-
/^You are (?:the|an?)\s/
|
|
71516
|
-
];
|
|
71517
|
-
function classifyUserSource(line, text) {
|
|
71518
|
-
var _a5;
|
|
71519
|
-
const kind = (_a5 = line.origin) == null ? void 0 : _a5.kind;
|
|
71520
|
-
if (typeof kind === "string") {
|
|
71521
|
-
if (kind === "human") return "human";
|
|
71522
|
-
if (kind === "peer") return "peer";
|
|
71523
|
-
return "notification";
|
|
71524
|
-
}
|
|
71525
|
-
if (line.isMeta === true) return "notification";
|
|
71526
|
-
if (PEER_MARKERS.some((re) => re.test(text))) return "peer";
|
|
71527
|
-
if (NOTIFICATION_MARKERS.some((re) => re.test(text))) return "notification";
|
|
71528
|
-
return "human";
|
|
71529
|
-
}
|
|
71530
|
-
var KNOWN_UNMAPPED = /* @__PURE__ */ new Set([
|
|
71531
|
-
"attachment",
|
|
71532
|
-
"last-prompt",
|
|
71533
|
-
"file-history-snapshot",
|
|
71534
|
-
"bridge-session",
|
|
71535
|
-
"started",
|
|
71536
|
-
"result",
|
|
71537
|
-
"frame-link",
|
|
71538
|
-
"diff-summary",
|
|
71539
|
-
"agent-name"
|
|
71540
|
-
]);
|
|
71541
|
-
function parseTranscript(content, opts = {}) {
|
|
71542
|
-
var _a5, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t;
|
|
71543
|
-
const warnings = new WarningCollector();
|
|
71544
|
-
const versions = /* @__PURE__ */ new Set();
|
|
71545
|
-
const lines = content.split("\n");
|
|
71546
|
-
const stats = { lines: 0, parsed: 0, skipped: 0, unmapped: 0 };
|
|
71547
|
-
let sessionId = (_b = (_a5 = opts.fork) == null ? void 0 : _a5.sessionId) != null ? _b : "";
|
|
71548
|
-
const forkLaunchedMs = opts.fork === void 0 ? void 0 : Date.parse(opts.fork.launchedAt);
|
|
71549
|
-
let forkKept = false;
|
|
71550
|
-
let cwd;
|
|
71551
|
-
let gitBranch;
|
|
71552
|
-
const cwdHistogram = /* @__PURE__ */ new Map();
|
|
71553
|
-
let version2;
|
|
71554
|
-
let entrypoint;
|
|
71555
|
-
let title;
|
|
71556
|
-
let sawSdkPromptSource = false;
|
|
71557
|
-
let subagentAgentId;
|
|
71558
|
-
const parentSessionId = opts.parentSessionId;
|
|
71559
|
-
const turns = [];
|
|
71560
|
-
const events = [];
|
|
71561
|
-
const models = /* @__PURE__ */ new Set();
|
|
71562
|
-
const toolCallsById = /* @__PURE__ */ new Map();
|
|
71563
|
-
const seenSubagents = /* @__PURE__ */ new Set();
|
|
71564
|
-
const unmappedTypes = /* @__PURE__ */ new Map();
|
|
71565
|
-
const unknownModels = /* @__PURE__ */ new Set();
|
|
71566
|
-
const blobs = /* @__PURE__ */ new Map();
|
|
71567
|
-
let open22 = null;
|
|
71568
|
-
const usageTurnByMessageId = /* @__PURE__ */ new Map();
|
|
71569
|
-
const addToTotals = (usage, sign) => {
|
|
71570
|
-
totals.in += sign * usage.in;
|
|
71571
|
-
totals.out += sign * usage.out;
|
|
71572
|
-
totals.cacheRead += sign * usage.cacheRead;
|
|
71573
|
-
totals.cacheCreate += sign * usage.cacheCreate;
|
|
71574
|
-
};
|
|
71575
|
-
const addCost = (costUsd, sign) => {
|
|
71576
|
-
if (typeof costUsd !== "number") return;
|
|
71577
|
-
totalCost += sign * costUsd;
|
|
71578
|
-
anyCostKnown = true;
|
|
71579
|
-
};
|
|
71580
|
-
const flushOpen = () => {
|
|
71581
|
-
if (!open22) return;
|
|
71582
|
-
const turn = finalizeAssistant(open22, turnIndex, toolCallsById, models, unknownModels);
|
|
71583
|
-
const usageTurn = turn.messageId ? usageTurnByMessageId.get(turn.messageId) : void 0;
|
|
71584
|
-
if ((usageTurn == null ? void 0 : usageTurn.usage) && turn.usage) {
|
|
71585
|
-
const merged = maxUsage(usageTurn.usage, turn.usage);
|
|
71586
|
-
addToTotals(usageTurn.usage, -1);
|
|
71587
|
-
addToTotals(merged, 1);
|
|
71588
|
-
usageTurn.usage = merged;
|
|
71589
|
-
if (usageTurn.model) {
|
|
71590
|
-
addCost(usageTurn.costUsd, -1);
|
|
71591
|
-
usageTurn.costUsd = costOfUsage(usageTurn.model, merged);
|
|
71592
|
-
addCost(usageTurn.costUsd, 1);
|
|
71593
|
-
}
|
|
71594
|
-
turn.usage = { in: 0, out: 0, cacheRead: 0, cacheCreate: 0, ...merged.speed ? { speed: merged.speed } : {} };
|
|
71595
|
-
turn.costUsd = turn.model ? costOfUsage(turn.model, turn.usage) : null;
|
|
71596
|
-
} else if (turn.usage) {
|
|
71597
|
-
if (turn.messageId) usageTurnByMessageId.set(turn.messageId, turn);
|
|
71598
|
-
addToTotals(turn.usage, 1);
|
|
71599
|
-
addCost(turn.costUsd, 1);
|
|
71600
|
-
}
|
|
71601
|
-
turns.push(turn);
|
|
71602
|
-
turnIndex += 1;
|
|
71603
|
-
open22 = null;
|
|
71604
|
-
};
|
|
71605
|
-
let startMs = Number.POSITIVE_INFINITY;
|
|
71606
|
-
let endMs = 0;
|
|
71607
|
-
let wallClockMs = 0;
|
|
71608
|
-
let seq = 0;
|
|
71609
|
-
let turnIndex = 0;
|
|
71610
|
-
let attributedSkill;
|
|
71611
|
-
const totals = { in: 0, out: 0, cacheRead: 0, cacheCreate: 0 };
|
|
71612
|
-
let totalCost = 0;
|
|
71613
|
-
let anyCostKnown = false;
|
|
71614
|
-
const outcome = {};
|
|
71615
|
-
const prLinks = [];
|
|
71616
|
-
const prLinksByNumber = /* @__PURE__ */ new Map();
|
|
71617
|
-
const shas = { pending: [], all: [], seen: /* @__PURE__ */ new Set() };
|
|
71618
|
-
const noteTs = (ts) => {
|
|
71619
|
-
if (typeof ts !== "string") return void 0;
|
|
71620
|
-
const ms = Date.parse(ts);
|
|
71621
|
-
if (!Number.isFinite(ms)) return void 0;
|
|
71622
|
-
if (!/[zZ]|[+-]\d{2}:?\d{2}$/.test(ts)) warnings.add(WARNING_CODES.ambiguousTimezone, ts);
|
|
71623
|
-
if (ms < startMs) startMs = ms;
|
|
71624
|
-
if (ms > endMs) endMs = ms;
|
|
71625
|
-
return new Date(ms).toISOString();
|
|
71626
|
-
};
|
|
71627
|
-
for (let i = 0; i < lines.length; i++) {
|
|
71628
|
-
const raw = lines[i];
|
|
71629
|
-
const trimmed = raw.trim();
|
|
71630
|
-
if (!trimmed) continue;
|
|
71631
|
-
stats.lines += 1;
|
|
71632
|
-
let line;
|
|
71633
|
-
try {
|
|
71634
|
-
line = JSON.parse(trimmed);
|
|
71635
|
-
} catch {
|
|
71636
|
-
const isFinal = i >= lines.length - 2;
|
|
71637
|
-
warnings.add(isFinal ? WARNING_CODES.truncatedFinalLine : WARNING_CODES.malformedLine, trimmed.slice(0, 80));
|
|
71638
|
-
stats.skipped += 1;
|
|
71639
|
-
continue;
|
|
71640
|
-
}
|
|
71641
|
-
if (opts.fork !== void 0) {
|
|
71642
|
-
const at = typeof line.timestamp === "string" ? Date.parse(line.timestamp) : Number.NaN;
|
|
71643
|
-
const copied = Number.isFinite(at) && forkLaunchedMs !== void 0 && Number.isFinite(forkLaunchedMs) && at < forkLaunchedMs || !Number.isFinite(at) && !forkKept;
|
|
71644
|
-
if (copied) continue;
|
|
71645
|
-
if (Number.isFinite(at)) forkKept = true;
|
|
71646
|
-
}
|
|
71647
|
-
stats.parsed += 1;
|
|
71648
|
-
if (typeof line.sessionId === "string" && !sessionId) sessionId = line.sessionId;
|
|
71649
|
-
if (typeof line.cwd === "string" && !cwd) cwd = line.cwd;
|
|
71650
|
-
if (typeof line.cwd === "string" && (cwdHistogram.has(line.cwd) || cwdHistogram.size < 32)) {
|
|
71651
|
-
cwdHistogram.set(line.cwd, ((_c = cwdHistogram.get(line.cwd)) != null ? _c : 0) + 1);
|
|
71652
|
-
}
|
|
71653
|
-
if (typeof line.gitBranch === "string" && !gitBranch) gitBranch = line.gitBranch;
|
|
71654
|
-
if (typeof line.entrypoint === "string" && !entrypoint) entrypoint = line.entrypoint;
|
|
71655
|
-
if (line.promptSource === "sdk") sawSdkPromptSource = true;
|
|
71656
|
-
if (typeof line.version === "string") {
|
|
71657
|
-
version2 = version2 != null ? version2 : line.version;
|
|
71658
|
-
versions.add(line.version);
|
|
71659
|
-
if (isNewerThanSupported(line.version)) warnings.add(WARNING_CODES.versionNewer, line.version);
|
|
71660
|
-
}
|
|
71661
|
-
if (opts.isSubagent && typeof line.agentId === "string" && !subagentAgentId) {
|
|
71662
|
-
subagentAgentId = line.agentId;
|
|
71663
|
-
}
|
|
71664
|
-
const tsIso = noteTs(line.timestamp);
|
|
71665
|
-
if (typeof line.attributionSkill === "string") {
|
|
71666
|
-
if (line.attributionSkill !== attributedSkill) {
|
|
71667
|
-
const msgId = typeof ((_d = line.message) == null ? void 0 : _d.id) === "string" ? line.message.id : (_e = line.uuid) != null ? _e : `line-${i}`;
|
|
71668
|
-
const activationTurnIndex = line.type === "assistant" && open22 !== null && open22.messageId !== msgId ? turnIndex + 1 : turnIndex;
|
|
71669
|
-
events.push({
|
|
71670
|
-
type: EVENT_TYPES.skillActivated,
|
|
71671
|
-
seq: seq++,
|
|
71672
|
-
...tsIso ? { ts: tsIso } : {},
|
|
71673
|
-
turnIndex: activationTurnIndex,
|
|
71674
|
-
data: { skill: line.attributionSkill }
|
|
71675
|
-
});
|
|
71676
|
-
attributedSkill = line.attributionSkill;
|
|
71677
|
-
}
|
|
71678
|
-
}
|
|
71679
|
-
if (line.isSidechain === true && typeof line.agentId === "string" && !seenSubagents.has(line.agentId)) {
|
|
71680
|
-
seenSubagents.add(line.agentId);
|
|
71681
|
-
events.push({ type: EVENT_TYPES.subagent, seq: seq++, ...tsIso ? { ts: tsIso } : {}, data: { agentId: line.agentId } });
|
|
71682
|
-
}
|
|
71683
|
-
switch (line.type) {
|
|
71684
|
-
case "assistant": {
|
|
71685
|
-
if (line.isApiErrorMessage === true) {
|
|
71686
|
-
const code = apiErrorCode((_f = line.message) == null ? void 0 : _f.content);
|
|
71687
|
-
events.push({
|
|
71688
|
-
type: EVENT_TYPES.apiError,
|
|
71689
|
-
seq: seq++,
|
|
71690
|
-
...tsIso ? { ts: tsIso } : {},
|
|
71691
|
-
...code ? { data: { code } } : {}
|
|
71692
|
-
});
|
|
71693
|
-
}
|
|
71694
|
-
const msgId = typeof ((_g = line.message) == null ? void 0 : _g.id) === "string" ? line.message.id : (_h = line.uuid) != null ? _h : `line-${i}`;
|
|
71695
|
-
if (open22 && open22.messageId !== msgId) flushOpen();
|
|
71696
|
-
if (!open22) {
|
|
71697
|
-
open22 = {
|
|
71698
|
-
messageId: msgId,
|
|
71699
|
-
ts: tsIso,
|
|
71700
|
-
texts: [],
|
|
71701
|
-
thinkings: [],
|
|
71702
|
-
toolCalls: /* @__PURE__ */ new Map(),
|
|
71703
|
-
toolOrder: []
|
|
71704
|
-
};
|
|
71705
|
-
}
|
|
71706
|
-
mergeAssistantLine(open22, line, tsIso);
|
|
71707
|
-
break;
|
|
71708
|
-
}
|
|
71709
|
-
case "user": {
|
|
71710
|
-
flushOpen();
|
|
71711
|
-
if (line.isCompactSummary === true) {
|
|
71712
|
-
if (((_i = events[events.length - 1]) == null ? void 0 : _i.type) !== EVENT_TYPES.compaction) {
|
|
71713
|
-
events.push({ type: EVENT_TYPES.compaction, seq: seq++, ...tsIso ? { ts: tsIso } : {} });
|
|
71714
|
-
}
|
|
71715
|
-
break;
|
|
71716
|
-
}
|
|
71717
|
-
const turn = buildUserTurn(line, turnIndex, tsIso, toolCallsById, blobs, shas);
|
|
71718
|
-
if (turn) {
|
|
71719
|
-
turns.push(turn);
|
|
71720
|
-
turnIndex += 1;
|
|
71721
|
-
}
|
|
71722
|
-
break;
|
|
71723
|
-
}
|
|
71724
|
-
case "summary":
|
|
71725
|
-
countUnmapped(unmappedTypes, "summary");
|
|
71726
|
-
stats.unmapped += 1;
|
|
71727
|
-
break;
|
|
71728
|
-
case "ai-title":
|
|
71729
|
-
if (typeof line.aiTitle === "string") {
|
|
71730
|
-
title = line.aiTitle;
|
|
71731
|
-
}
|
|
71732
|
-
break;
|
|
71733
|
-
case "queue-operation":
|
|
71734
|
-
events.push({ type: EVENT_TYPES.queueOperation, seq: seq++, ...tsIso ? { ts: tsIso } : {}, ...line.operation ? { data: { operation: line.operation } } : {} });
|
|
71735
|
-
break;
|
|
71736
|
-
case "mode":
|
|
71737
|
-
case "permission-mode":
|
|
71738
|
-
events.push({ type: EVENT_TYPES.permissionModeChanged, seq: seq++, ...tsIso ? { ts: tsIso } : {}, data: { mode: (_k = (_j = line.permissionMode) != null ? _j : line.mode) != null ? _k : "unknown" } });
|
|
71739
|
-
break;
|
|
71740
|
-
case "pr-link":
|
|
71741
|
-
events.push({ type: EVENT_TYPES.prLinked, seq: seq++, ...tsIso ? { ts: tsIso } : {}, ...typeof line.prNumber === "number" ? { data: { prNumber: line.prNumber } } : {} });
|
|
71742
|
-
break;
|
|
71743
|
-
case "system":
|
|
71744
|
-
handleSystem(line, tsIso, events, () => seq++, (ms) => {
|
|
71745
|
-
wallClockMs += ms;
|
|
71746
|
-
});
|
|
71747
|
-
if (line.isCompactSummary === true && ((_l = events[events.length - 1]) == null ? void 0 : _l.type) !== EVENT_TYPES.compaction) {
|
|
71748
|
-
events.push({ type: EVENT_TYPES.compaction, seq: seq++, ...tsIso ? { ts: tsIso } : {} });
|
|
71749
|
-
}
|
|
71750
|
-
break;
|
|
71751
|
-
case "attachment":
|
|
71752
|
-
if (((_m = line.attachment) == null ? void 0 : _m.type) === "hook_blocking_error") {
|
|
71753
|
-
events.push({
|
|
71754
|
-
type: EVENT_TYPES.hookBlocked,
|
|
71755
|
-
seq: seq++,
|
|
71756
|
-
...tsIso ? { ts: tsIso } : {},
|
|
71757
|
-
data: {
|
|
71758
|
-
...line.attachment.hookEvent ? { hookEvent: line.attachment.hookEvent } : {},
|
|
71759
|
-
...line.attachment.hookName ? { hookName: line.attachment.hookName } : {},
|
|
71760
|
-
...line.attachment.toolUseID ? { toolUseId: line.attachment.toolUseID } : {}
|
|
71761
|
-
}
|
|
71762
|
-
});
|
|
71763
|
-
} else {
|
|
71764
|
-
countUnmapped(unmappedTypes, "attachment");
|
|
71765
|
-
stats.unmapped += 1;
|
|
71766
|
-
}
|
|
71767
|
-
break;
|
|
71768
|
-
case void 0:
|
|
71769
|
-
countUnmapped(unmappedTypes, "(typeless)");
|
|
71770
|
-
stats.unmapped += 1;
|
|
71771
|
-
break;
|
|
71772
|
-
default:
|
|
71773
|
-
if (line.isCompactSummary === true) {
|
|
71774
|
-
if (((_n = events[events.length - 1]) == null ? void 0 : _n.type) !== EVENT_TYPES.compaction) {
|
|
71775
|
-
events.push({ type: EVENT_TYPES.compaction, seq: seq++, ...tsIso ? { ts: tsIso } : {} });
|
|
71776
|
-
}
|
|
71777
|
-
} else {
|
|
71778
|
-
countUnmapped(unmappedTypes, line.type);
|
|
71779
|
-
stats.unmapped += 1;
|
|
71780
|
-
if (!KNOWN_UNMAPPED.has(line.type)) {
|
|
71781
|
-
warnings.add(WARNING_CODES.unknownLineType, line.type);
|
|
71782
|
-
}
|
|
71783
|
-
}
|
|
71784
|
-
}
|
|
71785
|
-
if (line.type === "pr-link" && typeof line.prNumber === "number" && Number.isInteger(line.prNumber) && line.prNumber > 0) {
|
|
71786
|
-
outcome.prNumber = line.prNumber;
|
|
71787
|
-
if (typeof line.prUrl === "string") outcome.prUrl = line.prUrl;
|
|
71788
|
-
let entry = prLinksByNumber.get(line.prNumber);
|
|
71789
|
-
if (!entry) {
|
|
71790
|
-
entry = { prNumber: line.prNumber };
|
|
71791
|
-
prLinksByNumber.set(line.prNumber, entry);
|
|
71792
|
-
prLinks.push(entry);
|
|
71793
|
-
}
|
|
71794
|
-
if (typeof line.prUrl === "string") entry.prUrl = line.prUrl;
|
|
71795
|
-
if (shas.pending.length > 0) {
|
|
71796
|
-
entry.commitShas = [...(_o = entry.commitShas) != null ? _o : [], ...shas.pending];
|
|
71797
|
-
shas.pending = [];
|
|
71798
|
-
}
|
|
71799
|
-
}
|
|
71800
|
-
}
|
|
71801
|
-
flushOpen();
|
|
71802
|
-
if (stats.parsed === 0 || turns.length === 0 && events.length === 0) {
|
|
71803
|
-
return { session: null, warnings: warnings.histogram(), stats, versions: [...versions].sort(), blobs: [...blobs.values()] };
|
|
71804
|
-
}
|
|
71805
|
-
for (const model of unknownModels) warnings.add(WARNING_CODES.unknownModelCost, model);
|
|
71806
|
-
const vendor = {};
|
|
71807
|
-
if (unmappedTypes.size > 0) {
|
|
71808
|
-
vendor.unmappedLineTypes = Object.fromEntries([...unmappedTypes.entries()].sort(([a], [b]) => a.localeCompare(b)));
|
|
71809
|
-
}
|
|
71810
|
-
const ownId = opts.isSubagent ? opts.ownId || subagentAgentId || opts.fallbackId || sessionId || "unknown-subagent" : sessionId || opts.fallbackId || "unknown-session";
|
|
71811
|
-
const parentLink = opts.isSubagent ? parentSessionId || sessionId || void 0 : void 0;
|
|
71812
|
-
if (!title && opts.isSubagent && opts.spawnDescription) {
|
|
71813
|
-
title = opts.spawnDescription;
|
|
71814
|
-
}
|
|
71815
|
-
if (!title && opts.isSubagent) {
|
|
71816
|
-
const firstTurn = turns.find((t) => t.role === "user" && typeof t.text === "string" && t.text.trim());
|
|
71817
|
-
const text = (_p = firstTurn == null ? void 0 : firstTurn.text) == null ? void 0 : _p.trim();
|
|
71818
|
-
const spawnTag = text ? /^<teammate-message([^>]*)>/.exec(text) : null;
|
|
71819
|
-
if (spawnTag) {
|
|
71820
|
-
const summary = (_r = (_q = /\bsummary="([^"]*)"/.exec(spawnTag[1])) == null ? void 0 : _q[1]) == null ? void 0 : _r.trim();
|
|
71821
|
-
if (summary) {
|
|
71822
|
-
title = decodeXmlEntities(summary);
|
|
71823
|
-
} else {
|
|
71824
|
-
const body = text.slice(spawnTag[0].length).trim();
|
|
71825
|
-
const firstLine = body.split("\n").find((line) => line.trim().length > 0);
|
|
71826
|
-
if (firstLine) title = firstLine.trim().slice(0, 80);
|
|
71827
|
-
}
|
|
71828
|
-
}
|
|
71829
|
-
}
|
|
71830
|
-
if (!title) {
|
|
71831
|
-
const firstAsk = turns.find(
|
|
71832
|
-
(t) => isHumanUserTurn(t) && typeof t.text === "string" && t.text.trim() && !/^<(command-name|command-message|command-args|local-command|system-reminder)/.test(t.text.trim())
|
|
71833
|
-
);
|
|
71834
|
-
if (firstAsk == null ? void 0 : firstAsk.text) title = firstAsk.text.trim().split("\n")[0].slice(0, 80);
|
|
71835
|
-
}
|
|
71836
|
-
const origin = opts.isSubagent || sawSdkPromptSource || (entrypoint == null ? void 0 : entrypoint.startsWith("sdk")) ? "agent" : "interactive";
|
|
71837
|
-
const startedAt = Number.isFinite(startMs) ? new Date(startMs).toISOString() : new Date(endMs).toISOString();
|
|
71838
|
-
const buckets = bucketsFromTurns(turns);
|
|
71839
|
-
const session = {
|
|
71840
|
-
schemaVersion: SCHEMA_VERSION,
|
|
71841
|
-
id: ownId,
|
|
71842
|
-
agent: { type: (_s = opts.agentType) != null ? _s : "claude-code", ...version2 ? { version: version2 } : {}, ...entrypoint ? { entrypoint } : {}, origin },
|
|
71843
|
-
env: { ...cwd ? { cwd } : {}, ...{}, ...gitBranch ? { gitBranch } : {} },
|
|
71844
|
-
...opts.isSubagent ? {
|
|
71845
|
-
subagent: {
|
|
71846
|
-
...subagentAgentId ? { agentId: subagentAgentId } : {},
|
|
71847
|
-
...parentLink ? { parentSessionId: parentLink } : {},
|
|
71848
|
-
...opts.workflowRunId ? { workflowRunId: opts.workflowRunId } : {},
|
|
71849
|
-
...opts.spawnDescription ? { spawnDescription: opts.spawnDescription } : {},
|
|
71850
|
-
...opts.spawnName ? { spawnName: opts.spawnName } : {},
|
|
71851
|
-
...opts.spawnAgentType ? { spawnAgentType: opts.spawnAgentType } : {}
|
|
71852
|
-
}
|
|
71853
|
-
} : {},
|
|
71854
|
-
startedAt,
|
|
71855
|
-
...endMs > 0 ? { endedAt: new Date(endMs).toISOString() } : {},
|
|
71856
|
-
models: [...models].sort(),
|
|
71857
|
-
turns,
|
|
71858
|
-
events,
|
|
71859
|
-
totals: {
|
|
71860
|
-
inputTokens: totals.in,
|
|
71861
|
-
outputTokens: totals.out,
|
|
71862
|
-
cacheReadTokens: totals.cacheRead,
|
|
71863
|
-
cacheCreationTokens: totals.cacheCreate,
|
|
71864
|
-
costUsd: anyCostKnown ? round(totalCost) : null,
|
|
71865
|
-
...wallClockMs > 0 ? { wallClockMs } : {},
|
|
71866
|
-
...buckets.length > 0 ? { buckets, bandBoundaries: [...INPUT_BAND_BOUNDARIES] } : {}
|
|
71867
|
-
},
|
|
71868
|
-
...outcome.prNumber || shas.all.length > 0 ? {
|
|
71869
|
-
outcome: {
|
|
71870
|
-
...outcome,
|
|
71871
|
-
...shas.all.length > 0 ? { commitShas: shas.all } : {},
|
|
71872
|
-
...prLinks.length > 0 ? { prs: prLinks } : {}
|
|
71873
|
-
}
|
|
71874
|
-
} : {},
|
|
71875
|
-
...title ? { title } : {},
|
|
71876
|
-
...Object.keys(vendor).length > 0 ? { vendor } : {},
|
|
71877
|
-
captureTier: (_t = opts.captureTier) != null ? _t : "full",
|
|
71878
|
-
warnings: warnings.toArray(),
|
|
71879
|
-
// CAPTURE-INTERNAL: consumed by `enrichSessionRepo` to attribute the
|
|
71880
|
-
// session to where the work happened, then deleted before the session is
|
|
71881
|
-
// synced — it is not tier-classified and must never leave the machine.
|
|
71882
|
-
...cwdHistogram.size > 1 ? { cwdHistogram: Object.fromEntries(cwdHistogram) } : {}
|
|
71883
|
-
};
|
|
71884
|
-
const validated = parseAgentSession(session);
|
|
71885
|
-
return { session: validated, warnings: warnings.histogram(), stats, versions: [...versions].sort(), blobs: [...blobs.values()] };
|
|
71886
|
-
}
|
|
71887
|
-
function extractImage(block, blobs) {
|
|
71888
|
-
const source = block.source;
|
|
71889
|
-
if (!source || source.type !== "base64" || typeof source.data !== "string") return null;
|
|
71890
|
-
const mediaType = typeof source.media_type === "string" ? source.media_type : "image/png";
|
|
71891
|
-
const data = source.data;
|
|
71892
|
-
const decoded = Buffer.from(data, "base64");
|
|
71893
|
-
const sha256 = createHash("sha256").update(decoded).digest("hex");
|
|
71894
|
-
const bytes = decoded.byteLength;
|
|
71895
|
-
if (!blobs.has(sha256)) blobs.set(sha256, { sha256, mediaType, data, bytes });
|
|
71896
|
-
return { mediaType, sha256, bytes };
|
|
71897
|
-
}
|
|
71898
|
-
function extractInlineImages(value, blobs, images) {
|
|
71899
|
-
if (Array.isArray(value)) {
|
|
71900
|
-
let changed2 = false;
|
|
71901
|
-
const out2 = value.map((v) => {
|
|
71902
|
-
const r = extractInlineImages(v, blobs, images);
|
|
71903
|
-
if (r !== v) changed2 = true;
|
|
71904
|
-
return r;
|
|
71905
|
-
});
|
|
71906
|
-
return changed2 ? out2 : value;
|
|
71907
|
-
}
|
|
71908
|
-
if (!value || typeof value !== "object") return value;
|
|
71909
|
-
const obj = value;
|
|
71910
|
-
if (obj.type === "image" && obj.source && typeof obj.source === "object") {
|
|
71911
|
-
const ref = extractImage(obj, blobs);
|
|
71912
|
-
if (!ref) return obj;
|
|
71913
|
-
images.push(ref);
|
|
71914
|
-
return { type: "image", mediaType: ref.mediaType, sha256: ref.sha256, bytes: ref.bytes };
|
|
71915
|
-
}
|
|
71916
|
-
let changed = false;
|
|
71917
|
-
const out = {};
|
|
71918
|
-
for (const k in obj) {
|
|
71919
|
-
const r = extractInlineImages(obj[k], blobs, images);
|
|
71920
|
-
if (r !== obj[k]) changed = true;
|
|
71921
|
-
out[k] = r;
|
|
71922
|
-
}
|
|
71923
|
-
return changed ? out : obj;
|
|
71924
|
-
}
|
|
71925
|
-
function maxUsage(a, b) {
|
|
71926
|
-
var _a5, _b, _c, _d, _e;
|
|
71927
|
-
const merged = {
|
|
71928
|
-
in: Math.max(a.in, b.in),
|
|
71929
|
-
out: Math.max(a.out, b.out),
|
|
71930
|
-
cacheRead: Math.max(a.cacheRead, b.cacheRead),
|
|
71931
|
-
cacheCreate: Math.max(a.cacheCreate, b.cacheCreate),
|
|
71932
|
-
// Same max-merge as the total it is a share of. Left unset when neither
|
|
71933
|
-
// reading carried the split, so the request still prices as all-5-minute
|
|
71934
|
-
// rather than as a zero-length 1-hour write.
|
|
71935
|
-
...a.cacheCreate1h !== void 0 || b.cacheCreate1h !== void 0 ? { cacheCreate1h: Math.max((_a5 = a.cacheCreate1h) != null ? _a5 : 0, (_b = b.cacheCreate1h) != null ? _b : 0) } : {},
|
|
71936
|
-
...((_c = a.speed) != null ? _c : b.speed) !== void 0 ? { speed: (_d = a.speed) != null ? _d : b.speed } : {}
|
|
71937
|
-
};
|
|
71938
|
-
merged.cacheCreate5m = merged.cacheCreate - Math.min((_e = merged.cacheCreate1h) != null ? _e : 0, merged.cacheCreate);
|
|
71939
|
-
return merged;
|
|
71940
|
-
}
|
|
71941
|
-
function mergeAssistantLine(open22, line, tsIso) {
|
|
71942
|
-
var _a5;
|
|
71943
|
-
if (!open22.ts && tsIso) open22.ts = tsIso;
|
|
71944
|
-
const message = line.message;
|
|
71945
|
-
const isSyntheticStub = line.isApiErrorMessage === true || (message == null ? void 0 : message.model) === "<synthetic>";
|
|
71946
|
-
if (!isSyntheticStub && typeof (message == null ? void 0 : message.model) === "string" && !open22.model) open22.model = message.model;
|
|
71947
|
-
const usage = readUsage(message == null ? void 0 : message.usage);
|
|
71948
|
-
if (usage) open22.usage = open22.usage ? maxUsage(open22.usage, usage) : usage;
|
|
71949
|
-
const content = message == null ? void 0 : message.content;
|
|
71950
|
-
if (typeof content === "string") {
|
|
71951
|
-
if (content && !open22.texts.includes(content)) open22.texts.push(content);
|
|
71952
|
-
return;
|
|
71953
|
-
}
|
|
71954
|
-
if (!Array.isArray(content)) return;
|
|
71955
|
-
for (const block of content) {
|
|
71956
|
-
if (!block || typeof block !== "object") continue;
|
|
71957
|
-
const b = block;
|
|
71958
|
-
switch (b.type) {
|
|
71959
|
-
case "text":
|
|
71960
|
-
if (typeof b.text === "string" && b.text && !open22.texts.includes(b.text)) open22.texts.push(b.text);
|
|
71961
|
-
break;
|
|
71962
|
-
case "thinking":
|
|
71963
|
-
if (typeof b.thinking === "string" && b.thinking && !open22.thinkings.includes(b.thinking)) {
|
|
71964
|
-
open22.thinkings.push(b.thinking);
|
|
71965
|
-
}
|
|
71966
|
-
break;
|
|
71967
|
-
case "tool_use":
|
|
71968
|
-
case "server_tool_use":
|
|
71969
|
-
case "mcp_tool_use": {
|
|
71970
|
-
const name = typeof b.name === "string" ? b.name : "unknown";
|
|
71971
|
-
const call = {
|
|
71972
|
-
name,
|
|
71973
|
-
status: "ok",
|
|
71974
|
-
isEdit: EDIT_TOOLS.has(name),
|
|
71975
|
-
...tsIso ? { startTs: tsIso } : {},
|
|
71976
|
-
...b.input !== void 0 ? { input: b.input } : {},
|
|
71977
|
-
...typeof b.id === "string" ? { toolUseId: b.id } : {}
|
|
71978
|
-
};
|
|
71979
|
-
const file2 = extractFile(b.input);
|
|
71980
|
-
if (file2) call.file = file2;
|
|
71981
|
-
if (typeof b.id === "string") {
|
|
71982
|
-
if (!open22.toolCalls.has(b.id)) {
|
|
71983
|
-
open22.toolCalls.set(b.id, call);
|
|
71984
|
-
open22.toolOrder.push(b.id);
|
|
71985
|
-
}
|
|
71986
|
-
} else {
|
|
71987
|
-
((_a5 = open22.anonCalls) != null ? _a5 : open22.anonCalls = []).push(call);
|
|
71988
|
-
}
|
|
71989
|
-
break;
|
|
71990
|
-
}
|
|
71991
|
-
}
|
|
71992
|
-
}
|
|
71993
|
-
}
|
|
71994
|
-
function finalizeAssistant(open22, index, toolCallsById, models, unknownModels) {
|
|
71995
|
-
const toolCalls = [];
|
|
71996
|
-
for (const id of open22.toolOrder) {
|
|
71997
|
-
const call = open22.toolCalls.get(id);
|
|
71998
|
-
toolCalls.push(call);
|
|
71999
|
-
toolCallsById.set(id, { call, startMs: open22.ts ? Date.parse(open22.ts) : void 0 });
|
|
72000
|
-
}
|
|
72001
|
-
if (open22.anonCalls) toolCalls.push(...open22.anonCalls);
|
|
72002
|
-
const turn = {
|
|
72003
|
-
index,
|
|
72004
|
-
role: "assistant",
|
|
72005
|
-
toolCalls,
|
|
72006
|
-
messageId: open22.messageId,
|
|
72007
|
-
...open22.ts ? { ts: open22.ts } : {}
|
|
72008
|
-
};
|
|
72009
|
-
if (open22.model) {
|
|
72010
|
-
turn.model = open22.model;
|
|
72011
|
-
models.add(open22.model);
|
|
72012
|
-
}
|
|
72013
|
-
if (open22.usage) {
|
|
72014
|
-
turn.usage = open22.usage;
|
|
72015
|
-
if (open22.model) {
|
|
72016
|
-
const cost = costOfUsage(open22.model, open22.usage);
|
|
72017
|
-
turn.costUsd = cost;
|
|
72018
|
-
if (cost === null) unknownModels.add(open22.model);
|
|
72019
|
-
} else {
|
|
72020
|
-
turn.costUsd = null;
|
|
72021
|
-
}
|
|
72022
|
-
}
|
|
72023
|
-
const text = open22.texts.join("\n").trim();
|
|
72024
|
-
if (text) turn.text = text.slice(0, TEXT_CAP);
|
|
72025
|
-
const thinking = open22.thinkings.join("\n").trim();
|
|
72026
|
-
if (thinking) turn.thinking = thinking.slice(0, TEXT_CAP);
|
|
72027
|
-
return turn;
|
|
72028
|
-
}
|
|
72029
|
-
function buildUserTurn(line, index, tsIso, toolCallsById, blobs, shas) {
|
|
72030
|
-
var _a5;
|
|
72031
|
-
const content = (_a5 = line.message) == null ? void 0 : _a5.content;
|
|
72032
|
-
let text = null;
|
|
72033
|
-
const images = [];
|
|
72034
|
-
if (typeof content === "string") {
|
|
72035
|
-
text = content.slice(0, TEXT_CAP);
|
|
72036
|
-
} else if (Array.isArray(content)) {
|
|
72037
|
-
const textParts = [];
|
|
72038
|
-
for (const block of content) {
|
|
72039
|
-
if (!block || typeof block !== "object") continue;
|
|
72040
|
-
const b = block;
|
|
72041
|
-
if (b.type === "text" && typeof b.text === "string") textParts.push(b.text);
|
|
72042
|
-
else if (b.type === "image") {
|
|
72043
|
-
const ref = extractImage(b, blobs);
|
|
72044
|
-
if (ref) images.push(ref);
|
|
72045
|
-
} else if (b.type === "tool_result") resolveToolResult(b, line.toolUseResult, tsIso, toolCallsById, blobs, images, shas);
|
|
72046
|
-
}
|
|
72047
|
-
if (textParts.length > 0) text = textParts.join("\n").slice(0, TEXT_CAP);
|
|
72048
|
-
}
|
|
72049
|
-
const turn = { index, role: "user", toolCalls: [], ...tsIso ? { ts: tsIso } : {} };
|
|
72050
|
-
if (text !== null && text.trim().length > 0) turn.text = text;
|
|
72051
|
-
if (images.length > 0) {
|
|
72052
|
-
const seen = /* @__PURE__ */ new Set();
|
|
72053
|
-
turn.images = images.filter((i) => seen.has(i.sha256) ? false : (seen.add(i.sha256), true));
|
|
72054
|
-
}
|
|
72055
|
-
if (turn.text === void 0 && turn.images === void 0) return null;
|
|
72056
|
-
turn.source = classifyUserSource(line, text != null ? text : "");
|
|
72057
|
-
return turn;
|
|
72058
|
-
}
|
|
72059
|
-
function resolveToolResult(block, toolUseResult, tsIso, toolCallsById, blobs, images, shas) {
|
|
72060
|
-
var _a5;
|
|
72061
|
-
const id = typeof block.tool_use_id === "string" ? block.tool_use_id : void 0;
|
|
72062
|
-
if (!id) return;
|
|
72063
|
-
const entry = toolCallsById.get(id);
|
|
72064
|
-
if (!entry) return;
|
|
72065
|
-
const { call, startMs } = entry;
|
|
72066
|
-
const bodyText = stringifyResultBody(block.content);
|
|
72067
|
-
const isError = block.is_error === true;
|
|
72068
|
-
const rejected = REJECTION_MARKERS.some((m) => bodyText.includes(m));
|
|
72069
|
-
call.status = rejected ? "rejected" : isError ? "error" : "ok";
|
|
72070
|
-
if (call.status === "error" && bodyText) {
|
|
72071
|
-
call.errorSignature = normalizeErrorSignature(bodyText);
|
|
72072
|
-
}
|
|
72073
|
-
if (call.status === "ok" && call.name === "Bash" && isGitCommitCommand((_a5 = call.input) == null ? void 0 : _a5.command)) {
|
|
72074
|
-
for (const sha of extractCommitShas(bodyText)) {
|
|
72075
|
-
if (shas.seen.has(sha)) continue;
|
|
72076
|
-
shas.seen.add(sha);
|
|
72077
|
-
shas.all.push(sha);
|
|
72078
|
-
shas.pending.push(sha);
|
|
72079
|
-
}
|
|
72080
|
-
}
|
|
72081
|
-
const output2 = extractInlineImages(toolUseResult != null ? toolUseResult : block.content, blobs, images);
|
|
72082
|
-
if (output2 !== void 0) call.output = output2;
|
|
72083
|
-
if (tsIso && startMs !== void 0) {
|
|
72084
|
-
const dur = Date.parse(tsIso) - startMs;
|
|
72085
|
-
if (dur >= 0) call.durationMs = dur;
|
|
72086
|
-
}
|
|
72087
|
-
}
|
|
72088
|
-
function handleSystem(line, tsIso, events, nextSeq, addWallClock) {
|
|
72089
|
-
switch (line.subtype) {
|
|
72090
|
-
case "compact_boundary":
|
|
72091
|
-
events.push({ type: EVENT_TYPES.compaction, seq: nextSeq(), ...tsIso ? { ts: tsIso } : {} });
|
|
72092
|
-
break;
|
|
72093
|
-
case "turn_duration":
|
|
72094
|
-
if (typeof line.durationMs === "number") addWallClock(line.durationMs);
|
|
72095
|
-
break;
|
|
72096
|
-
case "stop_hook_summary": {
|
|
72097
|
-
const data = {};
|
|
72098
|
-
if (typeof line.hookCount === "number") data.hookCount = line.hookCount;
|
|
72099
|
-
if (Array.isArray(line.hookInfos) && line.hookInfos.length > 0) {
|
|
72100
|
-
data.hooks = line.hookInfos.slice(0, HOOK_INFOS_CAP).map((h) => ({
|
|
72101
|
-
...typeof h.command === "string" ? { command: h.command.slice(0, HOOK_COMMAND_CAP) } : {},
|
|
72102
|
-
...isValidHookDurationMs(h.durationMs) ? { durationMs: h.durationMs } : {}
|
|
72103
|
-
}));
|
|
72104
|
-
}
|
|
72105
|
-
let errorText;
|
|
72106
|
-
if (Array.isArray(line.hookErrors) && line.hookErrors.length > 0) {
|
|
72107
|
-
data.errorCount = line.hookErrors.length;
|
|
72108
|
-
errorText = line.hookErrors.slice(0, HOOK_ERRORS_CAP).map((e) => (typeof e === "string" ? e : JSON.stringify(e)).slice(0, HOOK_ERROR_TEXT_CAP));
|
|
72109
|
-
}
|
|
72110
|
-
if (typeof line.toolUseID === "string") data.toolUseId = line.toolUseID;
|
|
72111
|
-
events.push({
|
|
72112
|
-
type: EVENT_TYPES.hookExecuted,
|
|
72113
|
-
seq: nextSeq(),
|
|
72114
|
-
...tsIso ? { ts: tsIso } : {},
|
|
72115
|
-
...Object.keys(data).length > 0 ? { data } : {},
|
|
72116
|
-
...errorText ? { errorText } : {}
|
|
72117
|
-
});
|
|
72118
|
-
break;
|
|
72119
|
-
}
|
|
72120
|
-
case "api_error": {
|
|
72121
|
-
const code = typeof line.error === "object" && line.error ? line.error.code : void 0;
|
|
72122
|
-
events.push({ type: EVENT_TYPES.apiError, seq: nextSeq(), ...tsIso ? { ts: tsIso } : {}, ...code ? { data: { code } } : {} });
|
|
72123
|
-
break;
|
|
72124
|
-
}
|
|
72125
|
-
case "local_command":
|
|
72126
|
-
events.push({ type: EVENT_TYPES.localCommand, seq: nextSeq(), ...tsIso ? { ts: tsIso } : {} });
|
|
72127
|
-
break;
|
|
72128
|
-
}
|
|
72129
|
-
}
|
|
72130
|
-
var API_ERROR_CODES = [
|
|
72131
|
-
[/\b429\b|rate.?limit/i, "rate_limit"],
|
|
72132
|
-
[/\b529\b|overloaded/i, "overloaded"],
|
|
72133
|
-
[/timed?.?out|timeout/i, "timeout"],
|
|
72134
|
-
[/connection (?:closed|error|reset)|network error/i, "connection_closed"],
|
|
72135
|
-
[/unavailable/i, "model_unavailable"],
|
|
72136
|
-
[/\b5\d\d\b|internal server error/i, "server_error"]
|
|
72137
|
-
];
|
|
72138
|
-
function apiErrorCode(content) {
|
|
72139
|
-
let text = "";
|
|
72140
|
-
if (typeof content === "string") {
|
|
72141
|
-
text = content;
|
|
72142
|
-
} else if (Array.isArray(content)) {
|
|
72143
|
-
for (const block of content) {
|
|
72144
|
-
const b = block;
|
|
72145
|
-
if (b && typeof b === "object" && typeof b.text === "string") text += ` ${b.text}`;
|
|
72146
|
-
}
|
|
72147
|
-
}
|
|
72148
|
-
for (const [pattern, code] of API_ERROR_CODES) if (pattern.test(text)) return code;
|
|
72149
|
-
return "unknown";
|
|
72150
|
-
}
|
|
72151
|
-
function readUsage(raw) {
|
|
72152
|
-
var _a5;
|
|
72153
|
-
if (!raw || typeof raw !== "object") return void 0;
|
|
72154
|
-
const r = raw;
|
|
72155
|
-
const usage = {
|
|
72156
|
-
in: num(r.input_tokens),
|
|
72157
|
-
out: num(r.output_tokens),
|
|
72158
|
-
cacheRead: num(r.cache_read_input_tokens),
|
|
72159
|
-
cacheCreate: num(r.cache_creation_input_tokens)
|
|
72160
|
-
};
|
|
72161
|
-
if (usage.in === 0 && usage.out === 0 && usage.cacheRead === 0 && usage.cacheCreate === 0) {
|
|
72162
|
-
return void 0;
|
|
72163
|
-
}
|
|
72164
|
-
const split = r.cache_creation;
|
|
72165
|
-
if (split && typeof split === "object") {
|
|
72166
|
-
const oneHour = num(split.ephemeral_1h_input_tokens);
|
|
72167
|
-
if (oneHour > 0) usage.cacheCreate1h = Math.min(oneHour, usage.cacheCreate);
|
|
72168
|
-
}
|
|
72169
|
-
usage.cacheCreate5m = usage.cacheCreate - ((_a5 = usage.cacheCreate1h) != null ? _a5 : 0);
|
|
72170
|
-
if (typeof r.speed === "string" && r.speed) usage.speed = r.speed.slice(0, SPEED_MAX_LENGTH);
|
|
72171
|
-
return usage;
|
|
72172
|
-
}
|
|
72173
|
-
function extractFile(input2) {
|
|
72174
|
-
if (!input2 || typeof input2 !== "object") return void 0;
|
|
72175
|
-
const r = input2;
|
|
72176
|
-
for (const key of ["file_path", "notebook_path", "path", "filePath"]) {
|
|
72177
|
-
if (typeof r[key] === "string") return r[key];
|
|
72178
|
-
}
|
|
72179
|
-
return void 0;
|
|
72180
|
-
}
|
|
72181
|
-
function stringifyResultBody(content) {
|
|
72182
|
-
if (typeof content === "string") return content;
|
|
72183
|
-
if (Array.isArray(content)) {
|
|
72184
|
-
return content.map((c) => c && typeof c === "object" && typeof c.text === "string" ? c.text : "").join(" ");
|
|
72185
|
-
}
|
|
72186
|
-
return "";
|
|
72187
|
-
}
|
|
72188
|
-
function normalizeErrorSignature(text) {
|
|
72189
|
-
return text.replace(/[A-Za-z]:\\[^\s"']+|\/[^\s"':]+/g, "<path>").replace(/\b[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\b/gi, "<uuid>").replace(/\b0x[0-9a-f]+\b/gi, "<hex>").replace(/:\d+:\d+|\bline \d+|\b\d{3,}\b/gi, (m) => m.startsWith("line") ? "line <n>" : m.includes(":") ? ":<n>:<n>" : "<n>").replace(/\s+/g, " ").trim().slice(0, 200);
|
|
72190
|
-
}
|
|
72191
|
-
function extractCommitShas(text) {
|
|
72192
|
-
const out = [];
|
|
72193
|
-
const re = /^\[[^\n\]]+ ([0-9a-f]{7,40})\]/gm;
|
|
72194
|
-
let m;
|
|
72195
|
-
while ((m = re.exec(text)) !== null) out.push(m[1]);
|
|
72196
|
-
return out;
|
|
72197
|
-
}
|
|
72198
|
-
function isGitCommitCommand(command) {
|
|
72199
|
-
return typeof command === "string" && command.includes("git commit");
|
|
72200
|
-
}
|
|
72201
|
-
function num(v) {
|
|
72202
|
-
return typeof v === "number" && Number.isFinite(v) ? v : 0;
|
|
72203
|
-
}
|
|
72204
|
-
function round(n) {
|
|
72205
|
-
return Math.round(n * 1e6) / 1e6;
|
|
72206
|
-
}
|
|
72207
|
-
function countUnmapped(map2, type) {
|
|
72208
|
-
var _a5;
|
|
72209
|
-
map2.set(type, ((_a5 = map2.get(type)) != null ? _a5 : 0) + 1);
|
|
72210
|
-
}
|
|
72211
|
-
function decodeXmlEntities(value) {
|
|
72212
|
-
return value.replace(/&(apos|quot|amp|lt|gt);/g, (_, name) => {
|
|
72213
|
-
switch (name) {
|
|
72214
|
-
case "apos":
|
|
72215
|
-
return "'";
|
|
72216
|
-
case "quot":
|
|
72217
|
-
return '"';
|
|
72218
|
-
case "lt":
|
|
72219
|
-
return "<";
|
|
72220
|
-
case "gt":
|
|
72221
|
-
return ">";
|
|
72222
|
-
default:
|
|
72223
|
-
return "&";
|
|
72224
|
-
}
|
|
72225
|
-
});
|
|
72226
|
-
}
|
|
72227
|
-
function defaultProjectsDir() {
|
|
72228
|
-
return join(homedir(), ".claude", "projects");
|
|
72229
|
-
}
|
|
72230
|
-
function defaultRawDir() {
|
|
72231
|
-
return join(homedir(), ".outerlayer", "raw");
|
|
72232
|
-
}
|
|
72233
|
-
function findTranscripts(root = defaultProjectsDir()) {
|
|
72234
|
-
const found = [];
|
|
72235
|
-
const walk = (dir, depth) => {
|
|
72236
|
-
let names;
|
|
72237
|
-
try {
|
|
72238
|
-
names = readdirSync(dir);
|
|
72239
|
-
} catch {
|
|
72240
|
-
return;
|
|
72241
|
-
}
|
|
72242
|
-
for (const name of names) {
|
|
72243
|
-
const p = join(dir, name);
|
|
72244
|
-
let st;
|
|
72245
|
-
try {
|
|
72246
|
-
st = statSync(p);
|
|
72247
|
-
} catch {
|
|
72248
|
-
continue;
|
|
72249
|
-
}
|
|
72250
|
-
if (st.isDirectory()) walk(p);
|
|
72251
|
-
else if (name.endsWith(".jsonl") && st.size > 0) {
|
|
72252
|
-
const segments = p.split(/[/\\]/);
|
|
72253
|
-
const subagentsIdx = segments.lastIndexOf("subagents");
|
|
72254
|
-
const isSubagent = subagentsIdx > 0;
|
|
72255
|
-
const workflowRunId = isSubagent && segments[subagentsIdx + 1] === "workflows" ? segments[subagentsIdx + 2] : void 0;
|
|
72256
|
-
const meta3 = isSubagent ? readSpawnSidecar(p) : null;
|
|
72257
|
-
found.push({
|
|
72258
|
-
file: p,
|
|
72259
|
-
mtimeMs: st.mtimeMs,
|
|
72260
|
-
bytes: st.size,
|
|
72261
|
-
isSubagent,
|
|
72262
|
-
...isSubagent ? {
|
|
72263
|
-
parentSessionId: segments[subagentsIdx - 1] || void 0,
|
|
72264
|
-
ownId: sessionIdFromPath(name),
|
|
72265
|
-
...workflowRunId ? { workflowRunId } : {},
|
|
72266
|
-
...(meta3 == null ? void 0 : meta3.description) ? { metaDescription: meta3.description } : {},
|
|
72267
|
-
...(meta3 == null ? void 0 : meta3.name) ? { metaName: meta3.name } : {},
|
|
72268
|
-
...(meta3 == null ? void 0 : meta3.agentType) ? { metaAgentType: meta3.agentType } : {}
|
|
72269
|
-
} : {}
|
|
72270
|
-
});
|
|
72271
|
-
}
|
|
72272
|
-
}
|
|
72273
|
-
};
|
|
72274
|
-
walk(root);
|
|
72275
|
-
found.sort((a, b) => b.mtimeMs - a.mtimeMs);
|
|
72276
|
-
return found;
|
|
72277
|
-
}
|
|
72278
|
-
function sessionIdFromPath(file2) {
|
|
72279
|
-
var _a5;
|
|
72280
|
-
const base = (_a5 = file2.split(/[/\\]/).pop()) != null ? _a5 : file2;
|
|
72281
|
-
return base.replace(/\.jsonl$/, "");
|
|
72282
|
-
}
|
|
72283
|
-
function readSpawnSidecar(transcriptPath) {
|
|
72284
|
-
const sidecarPath = transcriptPath.replace(/\.jsonl$/, ".meta.json");
|
|
72285
|
-
let raw;
|
|
72286
|
-
try {
|
|
72287
|
-
raw = readFileSync(sidecarPath, "utf8");
|
|
72288
|
-
} catch {
|
|
72289
|
-
return null;
|
|
72290
|
-
}
|
|
72291
|
-
try {
|
|
72292
|
-
const parsed = JSON.parse(raw);
|
|
72293
|
-
return {
|
|
72294
|
-
...typeof parsed.description === "string" ? { description: parsed.description } : {},
|
|
72295
|
-
...typeof parsed.name === "string" ? { name: parsed.name } : {},
|
|
72296
|
-
...typeof parsed.agentType === "string" ? { agentType: parsed.agentType } : {}
|
|
72297
|
-
};
|
|
72298
|
-
} catch {
|
|
72299
|
-
return null;
|
|
72300
|
-
}
|
|
72301
|
-
}
|
|
72302
|
-
var PR_URL_PATH = /^(?:https?:\/\/)?(?:www\.)?github\.com\/([A-Za-z0-9._-]+\/[A-Za-z0-9._-]+)\/pull\/\d+(?:\/.*)?$/i;
|
|
72303
|
-
function repoKeyFromPrUrl(url2) {
|
|
72304
|
-
if (!url2) return null;
|
|
72305
|
-
const match = PR_URL_PATH.exec(url2.trim());
|
|
72306
|
-
return match ? match[1].replace(/\.git$/i, "").toLowerCase() : null;
|
|
72307
|
-
}
|
|
72308
|
-
function prLinkKey(link) {
|
|
72309
|
-
var _a5;
|
|
72310
|
-
return `${(_a5 = repoKeyFromPrUrl(link.prUrl)) != null ? _a5 : ""}#${link.prNumber}`;
|
|
72311
|
-
}
|
|
72312
|
-
var subagentOutcomeCache = /* @__PURE__ */ new Map();
|
|
72313
|
-
var SUBAGENT_SHA_CACHE_MAX = 4096;
|
|
72314
|
-
function subagentOutcome(file2, mtimeMs, bytes) {
|
|
72315
|
-
var _a5, _b, _c, _d;
|
|
72316
|
-
const hit = subagentOutcomeCache.get(file2);
|
|
72317
|
-
if (hit && hit.mtimeMs === mtimeMs && hit.bytes === bytes) return hit;
|
|
72318
|
-
let content;
|
|
72319
|
-
try {
|
|
72320
|
-
content = readFileSync(file2, "utf8");
|
|
72321
|
-
} catch {
|
|
72322
|
-
return { shas: [], prs: [] };
|
|
72323
|
-
}
|
|
72324
|
-
const { session } = parseTranscript(content, {
|
|
72325
|
-
fallbackId: sessionIdFromPath(file2),
|
|
72326
|
-
isSubagent: true,
|
|
72327
|
-
ownId: sessionIdFromPath(file2)
|
|
72328
|
-
});
|
|
72329
|
-
const shas = (_b = (_a5 = session == null ? void 0 : session.outcome) == null ? void 0 : _a5.commitShas) != null ? _b : [];
|
|
72330
|
-
const prs = (_d = (_c = session == null ? void 0 : session.outcome) == null ? void 0 : _c.prs) != null ? _d : [];
|
|
72331
|
-
const entry = { mtimeMs, bytes, shas, prs };
|
|
72332
|
-
if (subagentOutcomeCache.size >= SUBAGENT_SHA_CACHE_MAX) subagentOutcomeCache.clear();
|
|
72333
|
-
subagentOutcomeCache.set(file2, entry);
|
|
72334
|
-
return entry;
|
|
72335
|
-
}
|
|
72336
|
-
function defaultTwinMainFile(mainFile) {
|
|
72337
|
-
const pairs = [
|
|
72338
|
-
[defaultProjectsDir(), defaultRawDir()],
|
|
72339
|
-
[defaultRawDir(), defaultProjectsDir()]
|
|
72340
|
-
];
|
|
72341
|
-
for (const [from, to] of pairs) {
|
|
72342
|
-
if (mainFile.startsWith(from + sep)) return join(to, mainFile.slice(from.length + 1));
|
|
72343
|
-
}
|
|
72344
|
-
return null;
|
|
72345
|
-
}
|
|
72346
|
-
function rollUpSubagentOutcomes(mainFiles) {
|
|
72347
|
-
var _a5;
|
|
72348
|
-
const shas = [];
|
|
72349
|
-
const seenShas = /* @__PURE__ */ new Set();
|
|
72350
|
-
const prs = [];
|
|
72351
|
-
const prsByKey = /* @__PURE__ */ new Map();
|
|
72352
|
-
for (const mainFile of new Set(mainFiles)) {
|
|
72353
|
-
const subagentsRoot = join(mainFile.replace(/\.jsonl$/, ""), "subagents");
|
|
72354
|
-
for (const entry of findTranscripts(subagentsRoot)) {
|
|
72355
|
-
const outcome = subagentOutcome(entry.file, entry.mtimeMs, entry.bytes);
|
|
72356
|
-
for (const sha of outcome.shas) {
|
|
72357
|
-
if (seenShas.has(sha)) continue;
|
|
72358
|
-
seenShas.add(sha);
|
|
72359
|
-
shas.push(sha);
|
|
72360
|
-
}
|
|
72361
|
-
for (const link of outcome.prs) {
|
|
72362
|
-
const key = prLinkKey(link);
|
|
72363
|
-
const existing = prsByKey.get(key);
|
|
72364
|
-
if (!existing) {
|
|
72365
|
-
const copy = { ...link };
|
|
72366
|
-
prsByKey.set(key, copy);
|
|
72367
|
-
prs.push(copy);
|
|
72368
|
-
continue;
|
|
72369
|
-
}
|
|
72370
|
-
existing.commitShas = mergeCommitShas(existing.commitShas, (_a5 = link.commitShas) != null ? _a5 : []);
|
|
72371
|
-
}
|
|
72372
|
-
}
|
|
72373
|
-
}
|
|
72374
|
-
return { shas, prs };
|
|
72375
|
-
}
|
|
72376
|
-
function applySubagentCommitRollup(session, mainFile, alternateMainFile) {
|
|
72377
|
-
var _a5, _b;
|
|
72378
|
-
const candidates = [mainFile];
|
|
72379
|
-
if (alternateMainFile) candidates.push(alternateMainFile);
|
|
72380
|
-
const twin = defaultTwinMainFile(mainFile);
|
|
72381
|
-
if (twin) candidates.push(twin);
|
|
72382
|
-
const { shas: subShas, prs: subPrs } = rollUpSubagentOutcomes(candidates);
|
|
72383
|
-
if (subShas.length === 0 && subPrs.length === 0) return session;
|
|
72384
|
-
const commitShas = mergeCommitShas((_a5 = session.outcome) == null ? void 0 : _a5.commitShas, subShas);
|
|
72385
|
-
const prs = mergePrLinks((_b = session.outcome) == null ? void 0 : _b.prs, subPrs);
|
|
72386
|
-
const outcome = { ...session.outcome, ...commitShas ? { commitShas } : {}, ...prs ? { prs } : {} };
|
|
72387
|
-
if (outcome.prNumber === void 0 && prs && prs.length > 0) {
|
|
72388
|
-
const last = prs[prs.length - 1];
|
|
72389
|
-
outcome.prNumber = last.prNumber;
|
|
72390
|
-
if (last.prUrl !== void 0) outcome.prUrl = last.prUrl;
|
|
72391
|
-
}
|
|
72392
|
-
return { ...session, outcome };
|
|
72393
|
-
}
|
|
72394
|
-
function mergePrLinks(parentPrs, subagentPrs) {
|
|
72395
|
-
var _a5;
|
|
72396
|
-
if (subagentPrs.length === 0) return parentPrs;
|
|
72397
|
-
const byKey = /* @__PURE__ */ new Map();
|
|
72398
|
-
for (const link of parentPrs != null ? parentPrs : []) byKey.set(prLinkKey(link), { ...link });
|
|
72399
|
-
const order = [...(parentPrs != null ? parentPrs : []).map((l) => prLinkKey(l))];
|
|
72400
|
-
for (const link of subagentPrs) {
|
|
72401
|
-
const key = prLinkKey(link);
|
|
72402
|
-
const existing = byKey.get(key);
|
|
72403
|
-
if (!existing) {
|
|
72404
|
-
byKey.set(key, { ...link });
|
|
72405
|
-
order.push(key);
|
|
72406
|
-
continue;
|
|
72407
|
-
}
|
|
72408
|
-
existing.commitShas = mergeCommitShas(existing.commitShas, (_a5 = link.commitShas) != null ? _a5 : []);
|
|
72409
|
-
}
|
|
72410
|
-
return order.map((k) => byKey.get(k));
|
|
72411
|
-
}
|
|
72412
|
-
function mergeCommitShas(parentShas, subagentShas) {
|
|
72413
|
-
if (subagentShas.length === 0) return parentShas;
|
|
72414
|
-
const seen = new Set(parentShas != null ? parentShas : []);
|
|
72415
|
-
const merged = [...parentShas != null ? parentShas : []];
|
|
72416
|
-
for (const sha of subagentShas) {
|
|
72417
|
-
if (seen.has(sha)) continue;
|
|
72418
|
-
seen.add(sha);
|
|
72419
|
-
merged.push(sha);
|
|
72420
|
-
}
|
|
72421
|
-
return merged;
|
|
72422
|
-
}
|
|
72423
|
-
function tailTranscript(filePath, prior, opts = {}) {
|
|
71397
|
+
function tailTranscript(filePath, prior, tail, opts = {}) {
|
|
72424
71398
|
const content = readFileSync(filePath, "utf8");
|
|
72425
71399
|
const complete = completePrefix(content);
|
|
72426
71400
|
const checkpoint = {
|
|
@@ -72429,11 +71403,7 @@ function tailTranscript(filePath, prior, opts = {}) {
|
|
|
72429
71403
|
lineNo: countLines(complete)
|
|
72430
71404
|
};
|
|
72431
71405
|
const advanced = !prior || checkpoint.byteOffset > prior.byteOffset || checkpoint.lineNo !== prior.lineNo;
|
|
72432
|
-
const
|
|
72433
|
-
let { session } = parseTranscript(complete, parseOpts);
|
|
72434
|
-
if (!parseOpts.isSubagent && session) {
|
|
72435
|
-
session = applySubagentCommitRollup(session, filePath);
|
|
72436
|
-
}
|
|
71406
|
+
const session = tail(filePath, complete, opts);
|
|
72437
71407
|
return { session, checkpoint, advanced };
|
|
72438
71408
|
}
|
|
72439
71409
|
function completePrefix(content) {
|
|
@@ -72461,48 +71431,9 @@ function forkFor(record2, file2) {
|
|
|
72461
71431
|
if (record2 === void 0) return void 0;
|
|
72462
71432
|
return file2.sessionId === record2.sessionId || file2.parentSessionId === record2.sessionId ? record2 : void 0;
|
|
72463
71433
|
}
|
|
72464
|
-
function
|
|
72465
|
-
|
|
72466
|
-
|
|
72467
|
-
}
|
|
72468
|
-
var claudeCodeAdapter = {
|
|
72469
|
-
id: "claude-code",
|
|
72470
|
-
discover(roots) {
|
|
72471
|
-
var _a5, _b;
|
|
72472
|
-
const live = findTranscripts((_a5 = roots.root) != null ? _a5 : defaultProjectsDir());
|
|
72473
|
-
const raw = findTranscripts((_b = roots.rawRoot) != null ? _b : defaultRawDir());
|
|
72474
|
-
const byId = new Map(live.map((e) => [sessionIdFromPath(e.file), e]));
|
|
72475
|
-
for (const entry of raw) {
|
|
72476
|
-
const id = sessionIdFromPath(entry.file);
|
|
72477
|
-
const existing = byId.get(id);
|
|
72478
|
-
if (!existing) byId.set(id, { ...entry, fromRawOnly: true });
|
|
72479
|
-
else if (!existing.isSubagent) byId.set(id, { ...existing, altFile: entry.file });
|
|
72480
|
-
}
|
|
72481
|
-
return [...byId.values()];
|
|
72482
|
-
},
|
|
72483
|
-
parse(entry, opts) {
|
|
72484
|
-
const result = parseTranscript(readFileSync(entry.file, "utf8"), {
|
|
72485
|
-
fallbackId: sessionIdFromPath(entry.file),
|
|
72486
|
-
isSubagent: entry.isSubagent,
|
|
72487
|
-
...entry.parentSessionId ? { parentSessionId: entry.parentSessionId } : {},
|
|
72488
|
-
...entry.ownId ? { ownId: entry.ownId } : {},
|
|
72489
|
-
...entry.workflowRunId ? { workflowRunId: entry.workflowRunId } : {},
|
|
72490
|
-
...entry.metaDescription ? { spawnDescription: entry.metaDescription } : {},
|
|
72491
|
-
...entry.metaName ? { spawnName: entry.metaName } : {},
|
|
72492
|
-
...entry.metaAgentType ? { spawnAgentType: entry.metaAgentType } : {},
|
|
72493
|
-
...opts.captureTier ? { captureTier: opts.captureTier } : {},
|
|
72494
|
-
...forkOptions(opts.fork, entry)
|
|
72495
|
-
});
|
|
72496
|
-
if (!entry.isSubagent && result.session) {
|
|
72497
|
-
result.session = applySubagentCommitRollup(result.session, entry.file, entry.altFile);
|
|
72498
|
-
}
|
|
72499
|
-
return result;
|
|
72500
|
-
}
|
|
72501
|
-
};
|
|
72502
|
-
var SOURCE_ADAPTERS = [claudeCodeAdapter];
|
|
72503
|
-
function scanAll(opts = {}) {
|
|
72504
|
-
var _a5, _b, _c;
|
|
72505
|
-
const adapters = (_a5 = opts.adapters) != null ? _a5 : SOURCE_ADAPTERS;
|
|
71434
|
+
function scanAll(opts) {
|
|
71435
|
+
var _a5, _b;
|
|
71436
|
+
const adapters = opts.adapters;
|
|
72506
71437
|
const roots = { root: opts.root, rawRoot: opts.rawRoot };
|
|
72507
71438
|
let rawOnly = 0;
|
|
72508
71439
|
let candidates = [];
|
|
@@ -72533,7 +71464,7 @@ function scanAll(opts = {}) {
|
|
|
72533
71464
|
continue;
|
|
72534
71465
|
}
|
|
72535
71466
|
for (const [code, count] of Object.entries(result.warnings)) {
|
|
72536
|
-
warnings[code] = ((
|
|
71467
|
+
warnings[code] = ((_a5 = warnings[code]) != null ? _a5 : 0) + count;
|
|
72537
71468
|
}
|
|
72538
71469
|
for (const v of result.versions) versions.add(v);
|
|
72539
71470
|
if (!result.session) {
|
|
@@ -72541,7 +71472,7 @@ function scanAll(opts = {}) {
|
|
|
72541
71472
|
continue;
|
|
72542
71473
|
}
|
|
72543
71474
|
parsed += 1;
|
|
72544
|
-
byAgent[adapter.id] = ((
|
|
71475
|
+
byAgent[adapter.id] = ((_b = byAgent[adapter.id]) != null ? _b : 0) + 1;
|
|
72545
71476
|
if (opts.onSession) opts.onSession(result.session, entry, result.blobs);
|
|
72546
71477
|
else sessions.push(result.session);
|
|
72547
71478
|
}
|
|
@@ -72559,21 +71490,25 @@ function scanAll(opts = {}) {
|
|
|
72559
71490
|
};
|
|
72560
71491
|
return { report, sessions };
|
|
72561
71492
|
}
|
|
71493
|
+
var RAW_MIRROR_SEGMENTS = [".outerlayer", "raw"];
|
|
71494
|
+
function defaultRawDir() {
|
|
71495
|
+
return join(homedir(), ...RAW_MIRROR_SEGMENTS);
|
|
71496
|
+
}
|
|
72562
71497
|
var CaptureDaemon = class {
|
|
72563
|
-
constructor(options
|
|
71498
|
+
constructor(options) {
|
|
72564
71499
|
this.pending = /* @__PURE__ */ new Map();
|
|
72565
71500
|
this.reported = /* @__PURE__ */ new Map();
|
|
72566
|
-
var _a5, _b, _c, _d, _e, _f, _g
|
|
72567
|
-
this.root =
|
|
72568
|
-
this.rawRoot = (
|
|
72569
|
-
this.debounceMs = (
|
|
72570
|
-
this.rescanMs = (
|
|
72571
|
-
this.maxRawBytes = (
|
|
71501
|
+
var _a5, _b, _c, _d, _e, _f, _g;
|
|
71502
|
+
this.root = options.root;
|
|
71503
|
+
this.rawRoot = (_a5 = options.rawRoot) != null ? _a5 : defaultRawDir();
|
|
71504
|
+
this.debounceMs = (_b = options.debounceMs) != null ? _b : 2e3;
|
|
71505
|
+
this.rescanMs = (_c = options.rescanMs) != null ? _c : 10 * 60 * 1e3;
|
|
71506
|
+
this.maxRawBytes = (_d = options.maxRawBytes) != null ? _d : 5 * 1024 * 1024 * 1024;
|
|
72572
71507
|
this.includeProjects = options.includeProjects;
|
|
72573
71508
|
this.excludeProjects = options.excludeProjects;
|
|
72574
|
-
this.log = (
|
|
72575
|
-
this.now = (
|
|
72576
|
-
this.watchOnly = (
|
|
71509
|
+
this.log = (_e = options.onLog) != null ? _e : (() => void 0);
|
|
71510
|
+
this.now = (_f = options.now) != null ? _f : Date.now;
|
|
71511
|
+
this.watchOnly = (_g = options.watchOnly) != null ? _g : false;
|
|
72577
71512
|
}
|
|
72578
71513
|
/** Begin watching. Resolves once the initial scan completes. */
|
|
72579
71514
|
async start() {
|
|
@@ -72783,12 +71718,12 @@ function costSince(session, midnightMs) {
|
|
|
72783
71718
|
if (anyPriced) return sum;
|
|
72784
71719
|
return (_d = session.totals.costUsd) != null ? _d : 0;
|
|
72785
71720
|
}
|
|
72786
|
-
function computeStatuslineState(opts
|
|
72787
|
-
var _a5, _b, _c, _d, _e, _f
|
|
71721
|
+
function computeStatuslineState(opts) {
|
|
71722
|
+
var _a5, _b, _c, _d, _e, _f;
|
|
72788
71723
|
const home = (_a5 = opts.home) != null ? _a5 : homedir();
|
|
72789
71724
|
const now = ((_b = opts.now) != null ? _b : Date.now)();
|
|
72790
|
-
const adapters =
|
|
72791
|
-
const roots = (
|
|
71725
|
+
const adapters = opts.adapters;
|
|
71726
|
+
const roots = (_c = opts.roots) != null ? _c : {};
|
|
72792
71727
|
const midnight = localMidnightMs(now);
|
|
72793
71728
|
const byAgent = {};
|
|
72794
71729
|
const sessions = {};
|
|
@@ -72813,9 +71748,9 @@ function computeStatuslineState(opts = {}) {
|
|
|
72813
71748
|
}
|
|
72814
71749
|
if (!session) continue;
|
|
72815
71750
|
const spentToday = costSince(session, midnight);
|
|
72816
|
-
byAgent[adapter.id] = ((
|
|
72817
|
-
if (!entry.isSubagent && ((
|
|
72818
|
-
sessions[session.id] = { costUsd: (
|
|
71751
|
+
byAgent[adapter.id] = ((_d = byAgent[adapter.id]) != null ? _d : 0) + spentToday;
|
|
71752
|
+
if (!entry.isSubagent && ((_e = session.agent) == null ? void 0 : _e.origin) !== "agent" && spentToday > 0) sessionCount += 1;
|
|
71753
|
+
sessions[session.id] = { costUsd: (_f = session.totals.costUsd) != null ? _f : 0 };
|
|
72819
71754
|
}
|
|
72820
71755
|
}
|
|
72821
71756
|
return {
|
|
@@ -72827,7 +71762,7 @@ function computeStatuslineState(opts = {}) {
|
|
|
72827
71762
|
};
|
|
72828
71763
|
}
|
|
72829
71764
|
var StatuslineAggregator = class {
|
|
72830
|
-
constructor(opts
|
|
71765
|
+
constructor(opts) {
|
|
72831
71766
|
var _a5;
|
|
72832
71767
|
this.opts = opts;
|
|
72833
71768
|
this.debounceMs = (_a5 = opts.debounceMs) != null ? _a5 : 5e3;
|
|
@@ -72855,6 +71790,96 @@ var StatuslineAggregator = class {
|
|
|
72855
71790
|
}
|
|
72856
71791
|
}
|
|
72857
71792
|
};
|
|
71793
|
+
var WARNING_CODES = {
|
|
71794
|
+
unknownLineType: "unknown_line_type",
|
|
71795
|
+
malformedLine: "malformed_line",
|
|
71796
|
+
truncatedFinalLine: "truncated_final_line",
|
|
71797
|
+
versionNewer: "version_newer_than_supported",
|
|
71798
|
+
ambiguousTimezone: "ambiguous_timezone",
|
|
71799
|
+
unknownModelCost: "unknown_model_cost"
|
|
71800
|
+
};
|
|
71801
|
+
var WarningCollector = class {
|
|
71802
|
+
constructor() {
|
|
71803
|
+
this.counts = /* @__PURE__ */ new Map();
|
|
71804
|
+
this.details = /* @__PURE__ */ new Map();
|
|
71805
|
+
}
|
|
71806
|
+
add(code, detail) {
|
|
71807
|
+
var _a5;
|
|
71808
|
+
this.counts.set(code, ((_a5 = this.counts.get(code)) != null ? _a5 : 0) + 1);
|
|
71809
|
+
if (detail && !this.details.has(code)) {
|
|
71810
|
+
this.details.set(code, detail.slice(0, 200));
|
|
71811
|
+
}
|
|
71812
|
+
}
|
|
71813
|
+
has(code) {
|
|
71814
|
+
return this.counts.has(code);
|
|
71815
|
+
}
|
|
71816
|
+
toArray() {
|
|
71817
|
+
return [...this.counts.entries()].sort(([a], [b]) => a.localeCompare(b)).map(([code, count]) => {
|
|
71818
|
+
const detail = this.details.get(code);
|
|
71819
|
+
return detail ? { code, count, detail } : { code, count };
|
|
71820
|
+
});
|
|
71821
|
+
}
|
|
71822
|
+
/** Histogram for `--verbose` reports. */
|
|
71823
|
+
histogram() {
|
|
71824
|
+
return Object.fromEntries([...this.counts.entries()].sort(([a], [b]) => a.localeCompare(b)));
|
|
71825
|
+
}
|
|
71826
|
+
};
|
|
71827
|
+
var DEFAULT_SPEED = "standard";
|
|
71828
|
+
var OVERLONG_MODEL_ID = "(model id over 256 characters)";
|
|
71829
|
+
var bucketModel = (model) => model.length > BUCKET_MODEL_MAX_LENGTH ? OVERLONG_MODEL_ID : model;
|
|
71830
|
+
var cacheCreate1hOf = (u) => {
|
|
71831
|
+
var _a5;
|
|
71832
|
+
return Math.min((_a5 = u.cacheCreate1h) != null ? _a5 : 0, u.cacheCreate);
|
|
71833
|
+
};
|
|
71834
|
+
function bucketsFromTurns(turns) {
|
|
71835
|
+
var _a5, _b;
|
|
71836
|
+
const byKey = /* @__PURE__ */ new Map();
|
|
71837
|
+
for (const turn of turns) {
|
|
71838
|
+
const u = turn.usage;
|
|
71839
|
+
if (turn.role !== "assistant" || !u || !turn.model) continue;
|
|
71840
|
+
const speed = (_a5 = u.speed) != null ? _a5 : DEFAULT_SPEED;
|
|
71841
|
+
const band = inputBandOf(u.in + u.cacheRead + u.cacheCreate);
|
|
71842
|
+
const model = bucketModel(turn.model);
|
|
71843
|
+
const key = `${model}\0${speed}\0${band}`;
|
|
71844
|
+
let b = byKey.get(key);
|
|
71845
|
+
if (!b) {
|
|
71846
|
+
b = { model, speed, band, in: 0, out: 0, cacheRead: 0, cacheCreate5m: 0, cacheCreate1h: 0 };
|
|
71847
|
+
byKey.set(key, b);
|
|
71848
|
+
}
|
|
71849
|
+
const oneHour = cacheCreate1hOf(u);
|
|
71850
|
+
b.in += u.in;
|
|
71851
|
+
b.out += u.out;
|
|
71852
|
+
b.cacheRead += u.cacheRead;
|
|
71853
|
+
b.cacheCreate1h += oneHour;
|
|
71854
|
+
b.cacheCreate5m += (_b = u.cacheCreate5m) != null ? _b : u.cacheCreate - oneHour;
|
|
71855
|
+
}
|
|
71856
|
+
return [...byKey.values()].sort(
|
|
71857
|
+
(a, b) => a.model.localeCompare(b.model) || a.speed.localeCompare(b.speed) || a.band - b.band
|
|
71858
|
+
);
|
|
71859
|
+
}
|
|
71860
|
+
var SUPPORTED_VERSIONS = {
|
|
71861
|
+
min: "2.1.0",
|
|
71862
|
+
// inclusive upper bound of what we've validated; bump as new versions land
|
|
71863
|
+
max: "2.1.255"
|
|
71864
|
+
};
|
|
71865
|
+
function compareVersions(a, b) {
|
|
71866
|
+
var _a5, _b, _c, _d;
|
|
71867
|
+
const pa = parseVersion(a);
|
|
71868
|
+
const pb = parseVersion(b);
|
|
71869
|
+
for (let i = 0; i < 3; i++) {
|
|
71870
|
+
if (((_a5 = pa[i]) != null ? _a5 : 0) !== ((_b = pb[i]) != null ? _b : 0)) return ((_c = pa[i]) != null ? _c : 0) - ((_d = pb[i]) != null ? _d : 0);
|
|
71871
|
+
}
|
|
71872
|
+
return 0;
|
|
71873
|
+
}
|
|
71874
|
+
function parseVersion(v) {
|
|
71875
|
+
return (v || "").split(".").map((n) => {
|
|
71876
|
+
const parsed = Number.parseInt(n, 10);
|
|
71877
|
+
return Number.isFinite(parsed) ? parsed : 0;
|
|
71878
|
+
});
|
|
71879
|
+
}
|
|
71880
|
+
function isNewerThanSupported(version2) {
|
|
71881
|
+
return compareVersions(version2, SUPPORTED_VERSIONS.max) > 0;
|
|
71882
|
+
}
|
|
72858
71883
|
function normalizeRemote(remote) {
|
|
72859
71884
|
let r = remote.trim();
|
|
72860
71885
|
if (!r) return void 0;
|
|
@@ -73085,7 +72110,7 @@ function setRepoRoot(root) {
|
|
|
73085
72110
|
}
|
|
73086
72111
|
function scrubRepoRoot(text) {
|
|
73087
72112
|
if (!repoRootPattern) return text;
|
|
73088
|
-
return text.replace(repoRootPattern, (_m, lead,
|
|
72113
|
+
return text.replace(repoRootPattern, (_m, lead, sep3) => sep3 ? lead : `${lead}.`);
|
|
73089
72114
|
}
|
|
73090
72115
|
function setLocalIdentity(identity) {
|
|
73091
72116
|
localIdentity = [];
|
|
@@ -73169,4 +72194,4 @@ chokidar/index.js:
|
|
|
73169
72194
|
(*! chokidar - MIT License (c) 2012 Paul Miller (paulmillr.com) *)
|
|
73170
72195
|
*/
|
|
73171
72196
|
|
|
73172
|
-
export { CaptureDaemon, MIN_SCRUBBED_LITERAL, PRICE_TABLE_SOURCE,
|
|
72197
|
+
export { CaptureDaemon, MIN_SCRUBBED_LITERAL, OVERLONG_MODEL_ID, PRICE_TABLE_SOURCE, RAW_MIRROR_SEGMENTS, SECRET_PATTERNS, SUPPORTED_VERSIONS, StatuslineAggregator, WARNING_CODES, WarningCollector, bucketsFromTurns, compareVersions, completePrefix, computeStatuslineState, costOfUsage, defaultRawDir, enrichSessionRepo, forkFor, isNewerThanSupported, isPriceKnown, normalizeRemote, readForkRecord, readStatuslineState, readSyncWatermarkMs, remoteLookupFailed, resolvePrice, resolveRepoIdentity, scanAll, scrubDeep, scrubText, setCustomScrubbers, setLocalIdentity, setRepoRoot, statuslineStatePath, tailTranscript, writeStatuslineState };
|