@outerlayer/cli 0.36.0-next.20261102135508 → 0.36.0-next.20261102211600
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/dist/agent-setup-OYOTPYAR.js +39 -0
- package/dist/{agent-subcommand-Z6SOLWZW.js → agent-subcommand-3VJ6PKAT.js} +6 -5
- package/dist/{artifact-link-cmd-ZCMQIT5Y.js → artifact-link-cmd-ZPQXVG5O.js} +2 -2
- package/dist/{bridge-4KPODDN7.js → bridge-RECR25EL.js} +8 -7
- package/dist/{build-KYXFZQ33.js → build-NIKF353A.js} +14 -14
- package/dist/{build-disk-W6AL5WHI.js → build-disk-GKLJQNYQ.js} +12 -12
- package/dist/build-info.json +1 -1
- package/dist/{builder-IMNOEYV7.js → builder-THQ62YNF.js} +11 -11
- package/dist/caller-6EKJ6C43.js +22 -0
- package/dist/{check-WWX32IGY.js → check-WODTIKPR.js} +59 -59
- package/dist/{chunk-GFZ7PELR.js → chunk-2ICED253.js} +5 -5
- package/dist/{chunk-DTCTXDJP.js → chunk-2QXA7T6F.js} +5 -2
- package/dist/{chunk-6JLYU322.js → chunk-32GBZ7HD.js} +3 -3
- package/dist/{chunk-YJQ7YA7J.js → chunk-3FZVQRTC.js} +4 -4
- package/dist/{chunk-URHS76GV.js → chunk-3PDRASIP.js} +9 -9
- package/dist/{chunk-TKY3SDXH.js → chunk-44B523ZQ.js} +28 -20
- package/dist/{chunk-KRCU66AM.js → chunk-4K3VEJEE.js} +8 -8
- package/dist/{chunk-TJIFYV2Z.js → chunk-4UADHJ6P.js} +7 -7
- package/dist/{chunk-DTQPDMHG.js → chunk-5QMSZFA2.js} +2 -2
- package/dist/{chunk-B5SWBFVE.js → chunk-66UG5SL4.js} +3 -3
- package/dist/{chunk-ENMX3VQ7.js → chunk-6IDMWODX.js} +6 -6
- package/dist/{chunk-ULBYRPAP.js → chunk-77MUGWQT.js} +1 -1
- package/dist/{chunk-B2P72DAE.js → chunk-7AVQ67PS.js} +1 -1
- package/dist/{chunk-ZSRMJOAK.js → chunk-BF7P3J2H.js} +3 -3
- package/dist/{chunk-FRMAQ3C4.js → chunk-D2SEASHI.js} +6 -6
- package/dist/{chunk-K2G3VB7W.js → chunk-DLHOKPNF.js} +1 -1
- package/dist/{chunk-QKOJ22OV.js → chunk-DUGZCKCF.js} +18 -18
- package/dist/{chunk-VUH7KKVD.js → chunk-FB7HGLRK.js} +3 -3
- package/dist/{chunk-WVAXJOWG.js → chunk-FCMEWS3G.js} +5 -5
- package/dist/{chunk-PMA67TIN.js → chunk-FH4CX3CS.js} +3 -3
- package/dist/{chunk-LSLK4RS4.js → chunk-G3BUOMCF.js} +1 -0
- package/dist/{chunk-3YEPLVNW.js → chunk-GQ4GMFHO.js} +8 -8
- package/dist/{chunk-ATKCHMFD.js → chunk-H5QZSOBB.js} +1 -1
- package/dist/{chunk-BUYXEU7J.js → chunk-HHD5P4TU.js} +8 -8
- package/dist/{chunk-PIZA7OG2.js → chunk-HKJCNBUB.js} +1 -1
- package/dist/{chunk-2YC3TXWX.js → chunk-HOHY6ORJ.js} +1 -1
- package/dist/{chunk-VAYVTUU4.js → chunk-HYDNEYVD.js} +5 -5
- package/dist/{chunk-IKFAJTLZ.js → chunk-I6GHP6U7.js} +1 -1
- package/dist/{chunk-J2OMKFYB.js → chunk-IBFBBUBJ.js} +3 -3
- package/dist/{chunk-BSPJI5T7.js → chunk-IEFSDAVW.js} +1 -1
- package/dist/{chunk-CSBW4LGL.js → chunk-IJC4JL6B.js} +5 -5
- package/dist/{chunk-YYQ5NOT5.js → chunk-JFPDRFAR.js} +3 -3
- package/dist/{chunk-T5QBWM6M.js → chunk-KG5BQFSO.js} +1 -1
- package/dist/{chunk-B36NSEUM.js → chunk-KIY2AUHY.js} +1 -1
- package/dist/{chunk-4DLJ343I.js → chunk-KTL7GFQ3.js} +1 -1
- package/dist/{chunk-FTP7SE6Y.js → chunk-L6GYPZEV.js} +3 -3
- package/dist/{chunk-RF4JHGGB.js → chunk-L6OJH3E5.js} +7 -7
- package/dist/{chunk-O3MJAHLI.js → chunk-LJNFUD3U.js} +6 -6
- package/dist/{chunk-I4DM7SNX.js → chunk-LTAMZ36E.js} +1 -1
- package/dist/{chunk-6KH3NMIT.js → chunk-M7AIU22N.js} +124 -1099
- package/dist/{chunk-SJJXDU2J.js → chunk-MDP3QN7U.js} +7 -7
- package/dist/{chunk-DG3M5DZU.js → chunk-MFLIYXNY.js} +1 -1
- package/dist/{chunk-6HDXRDC5.js → chunk-MSEDA6A2.js} +2 -2
- package/dist/{chunk-ENBOAE2W.js → chunk-MZQAYZY4.js} +66 -25
- package/dist/{chunk-NXQK2I3G.js → chunk-NAQWMYQ2.js} +1 -1
- package/dist/{chunk-WACPWYMH.js → chunk-NJMJHUJL.js} +22 -7
- package/dist/{chunk-D5I5SSPU.js → chunk-OATJFN2P.js} +7 -7
- package/dist/{chunk-PBGNX3PS.js → chunk-OQZ2B5AN.js} +1 -1
- package/dist/{chunk-CXJC3JLN.js → chunk-P7W7SXX7.js} +3 -3
- package/dist/{chunk-YMVRCSKD.js → chunk-PJ3KUE3L.js} +7 -5
- package/dist/{chunk-E3TP4QTM.js → chunk-PLB2IBJV.js} +1 -1
- package/dist/{chunk-L2BA2HXM.js → chunk-PN4LWT5F.js} +1 -1
- package/dist/{chunk-AQE6E54X.js → chunk-QU4FBCRH.js} +9 -9
- package/dist/{chunk-LO4CK734.js → chunk-REXQKAY7.js} +1 -1
- package/dist/{chunk-K7N6LAPC.js → chunk-S3GZ74UE.js} +4 -4
- package/dist/{chunk-4XXBV37R.js → chunk-SFPDEBBO.js} +6 -6
- package/dist/{chunk-CSVJGW3I.js → chunk-STNWA5ZZ.js} +2 -2
- 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-6B3V6EGQ.js → chunk-UJD3DINB.js} +8 -8
- package/dist/{chunk-BZSJ77MO.js → chunk-UKQCIZ3R.js} +1 -1
- package/dist/{chunk-LHHDX7FB.js → chunk-UQ2YFDGP.js} +5 -5
- package/dist/{chunk-FWSVWPMS.js → chunk-V6V3NN5G.js} +1 -1
- package/dist/{chunk-HRHWA6TZ.js → chunk-V7ZAPEVS.js} +1 -1
- package/dist/{chunk-D4VGJQY7.js → chunk-VK4MMRYC.js} +1 -1
- package/dist/{chunk-LSZUTI6O.js → chunk-VNXITMKE.js} +1 -1
- package/dist/{chunk-FOSYM7TQ.js → chunk-X4QHDRXT.js} +2 -2
- package/dist/{chunk-XEWG4AB2.js → chunk-XCXBR74S.js} +739 -253
- package/dist/{chunk-Y4E7IS7H.js → chunk-YPVJ46Y3.js} +2 -2
- package/dist/{chunk-MVPOYQQY.js → chunk-Z4ASKZKN.js} +1 -1
- package/dist/{chunk-H2NJG3TE.js → chunk-ZFDUXKTM.js} +4 -4
- package/dist/{chunk-D6EXW4EB.js → chunk-ZM2SKQJD.js} +2 -2
- package/dist/{chunk-CDG475ZP.js → chunk-ZPFBNCXW.js} +10 -9
- package/dist/{chunk-3UFX6KH2.js → chunk-ZSHBICCL.js} +34 -37
- package/dist/{claude-launcher-LGKJZH33.js → claude-launcher-Z6WBFSRK.js} +10 -9
- package/dist/{cli-Q5L64EEG.js → cli-KBXHOMUN.js} +148 -148
- package/dist/{command-CGEFJZNC.js → command-FPLHTT7R.js} +53 -53
- package/dist/config-RKV7FRY5.js +21 -0
- package/dist/{connect-cmd-RUBP466E.js → connect-cmd-ZG7BPIXQ.js} +14 -14
- package/dist/{container-start-JRF3SBUA.js → container-start-3NWIL4A3.js} +51 -51
- package/dist/{context-cleanup-3K2AOECJ.js → context-cleanup-ZKAL6X5I.js} +6 -5
- package/dist/{context-show-cmd-4UXO5WQJ.js → context-show-cmd-AM46ZKCT.js} +15 -15
- package/dist/{control-plane-launch-AAH4YH56.js → control-plane-launch-HW2Y53YI.js} +16 -15
- package/dist/{demo-record-cmd-2OKCGST7.js → demo-record-cmd-T4227FWF.js} +9 -8
- package/dist/{demo-voice-cmd-GEPX7GIG.js → demo-voice-cmd-YSESUTE5.js} +23 -23
- package/dist/dist-64LM4JF4.js +7 -0
- package/dist/{docker-5VWK335X.js → docker-JC6S6KH3.js} +11 -11
- package/dist/{doctor-EQM3JRZI.js → doctor-U3MU6GP5.js} +53 -53
- package/dist/emit-artifact-cmd-J643XZ46.js +43 -0
- package/dist/{emit-cmd-RO4L4PFZ.js → emit-cmd-PTOSSDQK.js} +9 -8
- package/dist/emit-criteria-cmd-BARZ3MBZ.js +34 -0
- package/dist/{emit-demo-cmd-Y2Y6LEL7.js → emit-demo-cmd-OAC6RTSK.js} +23 -23
- package/dist/{emit-finding-cmd-VECM64UR.js → emit-finding-cmd-BUTFI2GD.js} +17 -17
- package/dist/{emit-result-cmd-2ERWFDUN.js → emit-result-cmd-4E4KX3QZ.js} +21 -21
- package/dist/{emit-step-cmd-V2ET66N4.js → emit-step-cmd-7CAJHMEQ.js} +17 -17
- package/dist/{exec-client-54XKNPTI.js → exec-client-G6B7G3IN.js} +9 -8
- package/dist/find-unit-MX6XITYC.js +23 -0
- package/dist/{findings-cmd-QJPPF6BY.js → findings-cmd-N66FJR3J.js} +17 -17
- package/dist/{fleet-readiness-DKAPHAZN.js → fleet-readiness-KFTMEUAI.js} +16 -15
- package/dist/governing-source-TO6RRWYS.js +40 -0
- package/dist/{guest-init-5QZRGP62.js → guest-init-J3TELWJG.js} +10 -9
- package/dist/{hook-fast-VXROB4KF.js → hook-fast-Y4LO3YE7.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-AGWZAK4R.js +78 -0
- package/dist/{host-key-HLLV37NV.js → host-key-EOTN4362.js} +9 -8
- package/dist/{image-tag-PBWQBATH.js → image-tag-VHP22FMX.js} +9 -8
- package/dist/index.js +6 -6
- package/dist/{init-Y2URPVVY.js → init-B575TM3R.js} +49 -49
- package/dist/init-LADDJ3MR.js +78 -0
- package/dist/{init-cmd-XNANUDIW.js → init-cmd-5Q2ICZBK.js} +31 -31
- package/dist/{init-update-EFCTKF6D.js → init-update-AJF4YJ6I.js} +26 -26
- package/dist/{install-cmd-RHFUZFV4.js → install-cmd-GO3D5F6X.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-E7MGQINH.js → logs-QV3LNNUJ.js} +8 -7
- package/dist/loop-5CEZVTIU.js +89 -0
- package/dist/machine-CSH5K23R.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-XXERT673.js → mcp-serve-cmd-7USDWMS4.js} +10 -9
- package/dist/{paths-F2ZR2EKC.js → paths-L3SEA2QQ.js} +8 -7
- package/dist/pending-3EMMPNC7.js +17 -0
- package/dist/{pidfile-7M7O2M7T.js → pidfile-ROXIFSGN.js} +9 -8
- package/dist/{record-YCJ6DZOY.js → record-7OMLXGTG.js} +9 -8
- package/dist/{relay-I2T43PPB.js → relay-663SG53Q.js} +6 -5
- package/dist/{relay-protocol-GI2GC2AM.js → relay-protocol-4V3F6HSZ.js} +6 -5
- package/dist/runner-env-YMBCAQXO.js +23 -0
- package/dist/{runner-identity-Y5ZFCC7V.js → runner-identity-QBFVMEXN.js} +11 -11
- package/dist/{runner-key-R47C6374.js → runner-key-SUZKSV54.js} +49 -49
- package/dist/{session-sender-UPACLRGG.js → session-sender-RI5VITPP.js} +22 -22
- package/dist/{shell-function-GYD2ZQQG.js → shell-function-D2T55XFG.js} +2 -2
- package/dist/{spec-cmd-7QRE2SZK.js → spec-cmd-IPFZNBCZ.js} +18 -18
- package/dist/{starter-pack-IMKIUA56.js → starter-pack-OLH6O4YX.js} +7 -6
- package/dist/state-ZWCWEDKQ.js +17 -0
- package/dist/{status-BQEYEG2V.js → status-KSO5RNWL.js} +49 -49
- package/dist/{statusline-fast-NUVHCNRX.js → statusline-fast-36U3TOCL.js} +3 -3
- package/dist/{sync-cmd-NBLYEPQG.js → sync-cmd-DML4SI6Y.js} +21 -21
- package/dist/update-steps-OVKM7RAH.js +79 -0
- package/dist/{watch-IHV4V3HZ.js → watch-X3AKYTTF.js} +29 -26
- package/dist/{work-claim-cmd-WGTSU5IT.js → work-claim-cmd-SIHUKNW4.js} +24 -24
- package/dist/{work-cmd-HKOJU5FJ.js → work-cmd-Z2JX53KE.js} +17 -17
- package/dist/work-comment-cmd-D2OQTFBW.js +37 -0
- package/dist/{work-demo-cmd-J4AZAIVP.js → work-demo-cmd-Z2PRJSY3.js} +17 -17
- package/dist/{work-logs-cmd-UOO4JVLG.js → work-logs-cmd-4UICP6PY.js} +17 -17
- package/dist/{work-open-pr-cmd-QFRDDBAM.js → work-open-pr-cmd-BZOYVVM6.js} +18 -18
- package/dist/{work-pr-cmd-3Q2D5RQT.js → work-pr-cmd-6PQLQD66.js} +17 -17
- package/dist/{work-proofs-cmd-7Y3HGT7C.js → work-proofs-cmd-SWESTSKA.js} +19 -19
- package/dist/{work-proofs-record-QPUM6DY4.js → work-proofs-record-55B24QNH.js} +27 -27
- package/dist/{work-stop-cmd-SD2ZRMSY.js → work-stop-cmd-6JXCQ277.js} +17 -17
- package/package.json +3 -3
- package/dist/agent-setup-Q3HDN23U.js +0 -39
- package/dist/caller-NLRE272L.js +0 -22
- package/dist/config-T22KVOOT.js +0 -21
- package/dist/dist-VVZIGSAF.js +0 -7
- package/dist/emit-artifact-cmd-TA3MPHLU.js +0 -43
- package/dist/emit-criteria-cmd-NMTUV2KM.js +0 -34
- package/dist/find-unit-CNAPU7XQ.js +0 -23
- package/dist/governing-source-7PZ6DAJU.js +0 -40
- package/dist/host-checks-WAPO5X7X.js +0 -78
- package/dist/init-EK3PUU6W.js +0 -78
- package/dist/loop-L6TX6OR4.js +0 -89
- package/dist/machine-VJKAY2GX.js +0 -78
- package/dist/pending-VOFQRXP4.js +0 -16
- package/dist/runner-env-YW55JVU7.js +0 -23
- package/dist/state-VAHBIMS5.js +0 -16
- package/dist/update-steps-VGKNGWTZ.js +0 -79
- package/dist/work-comment-cmd-H3JCWQ2J.js +0 -37
- package/dist/{chunk-TPMLB3VZ.js → chunk-A6RI6KTI.js} +1 -1
- package/dist/{chunk-P6PHY33P.js → chunk-F3T5QJ24.js} +1 -1
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire } from 'node:module';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { CLAUDE_CODE, NATIVE_AGENTS, LEGACY_AGENT } from './chunk-LSLK4RS4.js';
|
|
3
|
+
import { CLAUDE_CODE_HOOKS } from './chunk-KG5BQFSO.js';
|
|
4
|
+
import { CLAUDE_CODE, NATIVE_AGENTS, LEGACY_AGENT } from './chunk-G3BUOMCF.js';
|
|
6
5
|
import { MAINTAINED_SKILLS } from './chunk-CDDED64E.js';
|
|
7
6
|
import { resolvePackageVersion } from './chunk-RA3O54FC.js';
|
|
8
7
|
import { homeFromEnv } from './chunk-352DHUTP.js';
|
|
8
|
+
import { forkFor, RAW_MIRROR_SEGMENTS, WarningCollector, WARNING_CODES, isNewerThanSupported, bucketsFromTurns, costOfUsage } from './chunk-M7AIU22N.js';
|
|
9
|
+
import { RESERVED_EMIT_NAMES, EVENT_TYPES, isHumanUserTurn, INPUT_BAND_BOUNDARIES, parseAgentSession, SCHEMA_VERSION, ARTIFACT_KINDS, ArtifactCriterionIdSchema, SPEED_MAX_LENGTH } from './chunk-WUKLQWGY.js';
|
|
9
10
|
import { __commonJS, __require, __toESM } from './chunk-Z5GEFMRW.js';
|
|
10
11
|
import { existsSync, readFileSync, mkdirSync, writeFileSync, readdirSync, rmSync, renameSync, realpathSync, readlinkSync, symlinkSync, copyFileSync, statSync, accessSync, constants, lstatSync } from 'fs';
|
|
11
|
-
import { join as join$1, dirname } from 'path';
|
|
12
|
+
import { join as join$1, dirname, sep, basename, relative } from 'path';
|
|
12
13
|
import { fileURLToPath } from 'url';
|
|
13
14
|
import { spawnSync } from 'child_process';
|
|
15
|
+
import { createHash } from 'crypto';
|
|
14
16
|
import { homedir } from 'os';
|
|
15
17
|
|
|
16
18
|
createRequire(import.meta.url);
|
|
@@ -2331,9 +2333,9 @@ var require_stringifyNumber = __commonJS({
|
|
|
2331
2333
|
function stringifyNumber({ format, minFractionDigits, tag, value }) {
|
|
2332
2334
|
if (typeof value === "bigint")
|
|
2333
2335
|
return String(value);
|
|
2334
|
-
const
|
|
2335
|
-
if (!isFinite(
|
|
2336
|
-
return isNaN(
|
|
2336
|
+
const num2 = typeof value === "number" ? value : Number(value);
|
|
2337
|
+
if (!isFinite(num2))
|
|
2338
|
+
return isNaN(num2) ? ".nan" : num2 < 0 ? "-.inf" : ".inf";
|
|
2337
2339
|
let n = Object.is(value, -0) ? "-0" : JSON.stringify(value);
|
|
2338
2340
|
if (!format && minFractionDigits && (!tag || tag === "tag:yaml.org,2002:float") && /^-?\d/.test(n) && !n.includes("e")) {
|
|
2339
2341
|
let i = n.indexOf(".");
|
|
@@ -2372,8 +2374,8 @@ var require_float = __commonJS({
|
|
|
2372
2374
|
test: /^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,
|
|
2373
2375
|
resolve: (str) => parseFloat(str),
|
|
2374
2376
|
stringify(node) {
|
|
2375
|
-
const
|
|
2376
|
-
return isFinite(
|
|
2377
|
+
const num2 = Number(node.value);
|
|
2378
|
+
return isFinite(num2) ? num2.toExponential() : stringifyNumber.stringifyNumber(node);
|
|
2377
2379
|
}
|
|
2378
2380
|
};
|
|
2379
2381
|
var float = {
|
|
@@ -2804,8 +2806,8 @@ var require_float2 = __commonJS({
|
|
|
2804
2806
|
test: /^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,
|
|
2805
2807
|
resolve: (str) => parseFloat(str.replace(/_/g, "")),
|
|
2806
2808
|
stringify(node) {
|
|
2807
|
-
const
|
|
2808
|
-
return isFinite(
|
|
2809
|
+
const num2 = Number(node.value);
|
|
2810
|
+
return isFinite(num2) ? num2.toExponential() : stringifyNumber.stringifyNumber(node);
|
|
2809
2811
|
}
|
|
2810
2812
|
};
|
|
2811
2813
|
var float = {
|
|
@@ -3004,23 +3006,23 @@ var require_timestamp = __commonJS({
|
|
|
3004
3006
|
function parseSexagesimal(str, asBigInt) {
|
|
3005
3007
|
const sign = str[0];
|
|
3006
3008
|
const parts = sign === "-" || sign === "+" ? str.substring(1) : str;
|
|
3007
|
-
const
|
|
3008
|
-
const res = parts.replace(/_/g, "").split(":").reduce((res2, p) => res2 *
|
|
3009
|
-
return sign === "-" ?
|
|
3009
|
+
const num2 = (n) => asBigInt ? BigInt(n) : Number(n);
|
|
3010
|
+
const res = parts.replace(/_/g, "").split(":").reduce((res2, p) => res2 * num2(60) + num2(p), num2(0));
|
|
3011
|
+
return sign === "-" ? num2(-1) * res : res;
|
|
3010
3012
|
}
|
|
3011
3013
|
function stringifySexagesimal(node) {
|
|
3012
3014
|
let { value } = node;
|
|
3013
|
-
let
|
|
3015
|
+
let num2 = (n) => n;
|
|
3014
3016
|
if (typeof value === "bigint")
|
|
3015
|
-
|
|
3017
|
+
num2 = (n) => BigInt(n);
|
|
3016
3018
|
else if (isNaN(value) || !isFinite(value))
|
|
3017
3019
|
return stringifyNumber.stringifyNumber(node);
|
|
3018
3020
|
let sign = "";
|
|
3019
3021
|
if (value < 0) {
|
|
3020
3022
|
sign = "-";
|
|
3021
|
-
value *=
|
|
3023
|
+
value *= num2(-1);
|
|
3022
3024
|
}
|
|
3023
|
-
const _60 =
|
|
3025
|
+
const _60 = num2(60);
|
|
3024
3026
|
const parts = [value % _60];
|
|
3025
3027
|
if (value < 60) {
|
|
3026
3028
|
parts.unshift(0);
|
|
@@ -3926,10 +3928,10 @@ var require_resolve_block_map = __commonJS({
|
|
|
3926
3928
|
let offset = bm.offset;
|
|
3927
3929
|
let commentEnd = null;
|
|
3928
3930
|
for (const collItem of bm.items) {
|
|
3929
|
-
const { start, key, sep, value } = collItem;
|
|
3931
|
+
const { start, key, sep: sep2, value } = collItem;
|
|
3930
3932
|
const keyProps = resolveProps.resolveProps(start, {
|
|
3931
3933
|
indicator: "explicit-key-ind",
|
|
3932
|
-
next: key ??
|
|
3934
|
+
next: key ?? sep2?.[0],
|
|
3933
3935
|
offset,
|
|
3934
3936
|
onError,
|
|
3935
3937
|
parentIndent: bm.indent,
|
|
@@ -3943,7 +3945,7 @@ var require_resolve_block_map = __commonJS({
|
|
|
3943
3945
|
else if ("indent" in key && key.indent !== bm.indent)
|
|
3944
3946
|
onError(offset, "BAD_INDENT", startColMsg);
|
|
3945
3947
|
}
|
|
3946
|
-
if (!keyProps.anchor && !keyProps.tag && !
|
|
3948
|
+
if (!keyProps.anchor && !keyProps.tag && !sep2) {
|
|
3947
3949
|
commentEnd = keyProps.end;
|
|
3948
3950
|
if (keyProps.comment) {
|
|
3949
3951
|
if (map.comment)
|
|
@@ -3967,7 +3969,7 @@ var require_resolve_block_map = __commonJS({
|
|
|
3967
3969
|
ctx.atKey = false;
|
|
3968
3970
|
if (utilMapIncludes.mapIncludes(ctx, map.items, keyNode))
|
|
3969
3971
|
onError(keyStart, "DUPLICATE_KEY", "Map keys must be unique");
|
|
3970
|
-
const valueProps = resolveProps.resolveProps(
|
|
3972
|
+
const valueProps = resolveProps.resolveProps(sep2 ?? [], {
|
|
3971
3973
|
indicator: "map-value-ind",
|
|
3972
3974
|
next: value,
|
|
3973
3975
|
offset: keyNode.range[2],
|
|
@@ -3983,7 +3985,7 @@ var require_resolve_block_map = __commonJS({
|
|
|
3983
3985
|
if (ctx.options.strict && keyProps.start < valueProps.found.offset - 1024)
|
|
3984
3986
|
onError(keyNode.range, "KEY_OVER_1024_CHARS", "The : indicator must be at most 1024 chars after the start of an implicit block mapping key");
|
|
3985
3987
|
}
|
|
3986
|
-
const valueNode = value ? composeNode(ctx, value, valueProps, onError) : composeEmptyNode(ctx, offset,
|
|
3988
|
+
const valueNode = value ? composeNode(ctx, value, valueProps, onError) : composeEmptyNode(ctx, offset, sep2, null, valueProps, onError);
|
|
3987
3989
|
if (ctx.schema.compat)
|
|
3988
3990
|
utilFlowIndentCheck.flowIndentCheck(bm.indent, value, onError);
|
|
3989
3991
|
offset = valueNode.range[2];
|
|
@@ -4072,7 +4074,7 @@ var require_resolve_end = __commonJS({
|
|
|
4072
4074
|
let comment = "";
|
|
4073
4075
|
if (end) {
|
|
4074
4076
|
let hasSpace = false;
|
|
4075
|
-
let
|
|
4077
|
+
let sep2 = "";
|
|
4076
4078
|
for (const token of end) {
|
|
4077
4079
|
const { source, type } = token;
|
|
4078
4080
|
switch (type) {
|
|
@@ -4086,13 +4088,13 @@ var require_resolve_end = __commonJS({
|
|
|
4086
4088
|
if (!comment)
|
|
4087
4089
|
comment = cb;
|
|
4088
4090
|
else
|
|
4089
|
-
comment +=
|
|
4090
|
-
|
|
4091
|
+
comment += sep2 + cb;
|
|
4092
|
+
sep2 = "";
|
|
4091
4093
|
break;
|
|
4092
4094
|
}
|
|
4093
4095
|
case "newline":
|
|
4094
4096
|
if (comment)
|
|
4095
|
-
|
|
4097
|
+
sep2 += source;
|
|
4096
4098
|
hasSpace = true;
|
|
4097
4099
|
break;
|
|
4098
4100
|
default:
|
|
@@ -4134,18 +4136,18 @@ var require_resolve_flow_collection = __commonJS({
|
|
|
4134
4136
|
let offset = fc.offset + fc.start.source.length;
|
|
4135
4137
|
for (let i = 0; i < fc.items.length; ++i) {
|
|
4136
4138
|
const collItem = fc.items[i];
|
|
4137
|
-
const { start, key, sep, value } = collItem;
|
|
4139
|
+
const { start, key, sep: sep2, value } = collItem;
|
|
4138
4140
|
const props = resolveProps.resolveProps(start, {
|
|
4139
4141
|
flow: fcName,
|
|
4140
4142
|
indicator: "explicit-key-ind",
|
|
4141
|
-
next: key ??
|
|
4143
|
+
next: key ?? sep2?.[0],
|
|
4142
4144
|
offset,
|
|
4143
4145
|
onError,
|
|
4144
4146
|
parentIndent: fc.indent,
|
|
4145
4147
|
startOnNewline: false
|
|
4146
4148
|
});
|
|
4147
4149
|
if (!props.found) {
|
|
4148
|
-
if (!props.anchor && !props.tag && !
|
|
4150
|
+
if (!props.anchor && !props.tag && !sep2 && !value) {
|
|
4149
4151
|
if (i === 0 && props.comma)
|
|
4150
4152
|
onError(props.comma, "UNEXPECTED_TOKEN", `Unexpected , in ${fcName}`);
|
|
4151
4153
|
else if (i < fc.items.length - 1)
|
|
@@ -4199,8 +4201,8 @@ var require_resolve_flow_collection = __commonJS({
|
|
|
4199
4201
|
}
|
|
4200
4202
|
}
|
|
4201
4203
|
}
|
|
4202
|
-
if (!isMap && !
|
|
4203
|
-
const valueNode = value ? composeNode(ctx, value, props, onError) : composeEmptyNode(ctx, props.end,
|
|
4204
|
+
if (!isMap && !sep2 && !props.found) {
|
|
4205
|
+
const valueNode = value ? composeNode(ctx, value, props, onError) : composeEmptyNode(ctx, props.end, sep2, null, props, onError);
|
|
4204
4206
|
coll.items.push(valueNode);
|
|
4205
4207
|
offset = valueNode.range[2];
|
|
4206
4208
|
if (isBlock(value))
|
|
@@ -4212,7 +4214,7 @@ var require_resolve_flow_collection = __commonJS({
|
|
|
4212
4214
|
if (isBlock(key))
|
|
4213
4215
|
onError(keyNode.range, "BLOCK_IN_FLOW", blockMsg);
|
|
4214
4216
|
ctx.atKey = false;
|
|
4215
|
-
const valueProps = resolveProps.resolveProps(
|
|
4217
|
+
const valueProps = resolveProps.resolveProps(sep2 ?? [], {
|
|
4216
4218
|
flow: fcName,
|
|
4217
4219
|
indicator: "map-value-ind",
|
|
4218
4220
|
next: value,
|
|
@@ -4223,8 +4225,8 @@ var require_resolve_flow_collection = __commonJS({
|
|
|
4223
4225
|
});
|
|
4224
4226
|
if (valueProps.found) {
|
|
4225
4227
|
if (!isMap && !props.found && ctx.options.strict) {
|
|
4226
|
-
if (
|
|
4227
|
-
for (const st of
|
|
4228
|
+
if (sep2)
|
|
4229
|
+
for (const st of sep2) {
|
|
4228
4230
|
if (st === valueProps.found)
|
|
4229
4231
|
break;
|
|
4230
4232
|
if (st.type === "newline") {
|
|
@@ -4241,7 +4243,7 @@ var require_resolve_flow_collection = __commonJS({
|
|
|
4241
4243
|
else
|
|
4242
4244
|
onError(valueProps.start, "MISSING_CHAR", `Missing , or : between ${fcName} items`);
|
|
4243
4245
|
}
|
|
4244
|
-
const valueNode = value ? composeNode(ctx, value, valueProps, onError) : valueProps.found ? composeEmptyNode(ctx, valueProps.end,
|
|
4246
|
+
const valueNode = value ? composeNode(ctx, value, valueProps, onError) : valueProps.found ? composeEmptyNode(ctx, valueProps.end, sep2, null, valueProps, onError) : null;
|
|
4245
4247
|
if (valueNode) {
|
|
4246
4248
|
if (isBlock(value))
|
|
4247
4249
|
onError(valueNode.range, "BLOCK_IN_FLOW", blockMsg);
|
|
@@ -4419,7 +4421,7 @@ var require_resolve_block_scalar = __commonJS({
|
|
|
4419
4421
|
chompStart = i + 1;
|
|
4420
4422
|
}
|
|
4421
4423
|
let value = "";
|
|
4422
|
-
let
|
|
4424
|
+
let sep2 = "";
|
|
4423
4425
|
let prevMoreIndented = false;
|
|
4424
4426
|
for (let i = 0; i < contentStart; ++i)
|
|
4425
4427
|
value += lines[i][0].slice(trimIndent) + "\n";
|
|
@@ -4436,24 +4438,24 @@ var require_resolve_block_scalar = __commonJS({
|
|
|
4436
4438
|
indent = "";
|
|
4437
4439
|
}
|
|
4438
4440
|
if (type === Scalar.Scalar.BLOCK_LITERAL) {
|
|
4439
|
-
value +=
|
|
4440
|
-
|
|
4441
|
+
value += sep2 + indent.slice(trimIndent) + content;
|
|
4442
|
+
sep2 = "\n";
|
|
4441
4443
|
} else if (indent.length > trimIndent || content[0] === " ") {
|
|
4442
|
-
if (
|
|
4443
|
-
|
|
4444
|
-
else if (!prevMoreIndented &&
|
|
4445
|
-
|
|
4446
|
-
value +=
|
|
4447
|
-
|
|
4444
|
+
if (sep2 === " ")
|
|
4445
|
+
sep2 = "\n";
|
|
4446
|
+
else if (!prevMoreIndented && sep2 === "\n")
|
|
4447
|
+
sep2 = "\n\n";
|
|
4448
|
+
value += sep2 + indent.slice(trimIndent) + content;
|
|
4449
|
+
sep2 = "\n";
|
|
4448
4450
|
prevMoreIndented = true;
|
|
4449
4451
|
} else if (content === "") {
|
|
4450
|
-
if (
|
|
4452
|
+
if (sep2 === "\n")
|
|
4451
4453
|
value += "\n";
|
|
4452
4454
|
else
|
|
4453
|
-
|
|
4455
|
+
sep2 = "\n";
|
|
4454
4456
|
} else {
|
|
4455
|
-
value +=
|
|
4456
|
-
|
|
4457
|
+
value += sep2 + content;
|
|
4458
|
+
sep2 = " ";
|
|
4457
4459
|
prevMoreIndented = false;
|
|
4458
4460
|
}
|
|
4459
4461
|
}
|
|
@@ -4635,25 +4637,25 @@ var require_resolve_flow_scalar = __commonJS({
|
|
|
4635
4637
|
trimBoth = /^[ \t]+|[ \t]+$/g;
|
|
4636
4638
|
}
|
|
4637
4639
|
let res = match[1].replace(trimEnd, "");
|
|
4638
|
-
let
|
|
4640
|
+
let sep2 = " ";
|
|
4639
4641
|
let pos = line.lastIndex;
|
|
4640
4642
|
while (match = line.exec(source)) {
|
|
4641
4643
|
const lm = match[1].replace(trimBoth, "");
|
|
4642
4644
|
if (lm === "") {
|
|
4643
|
-
if (
|
|
4644
|
-
res +=
|
|
4645
|
+
if (sep2 === "\n")
|
|
4646
|
+
res += sep2;
|
|
4645
4647
|
else
|
|
4646
|
-
|
|
4648
|
+
sep2 = "\n";
|
|
4647
4649
|
} else {
|
|
4648
|
-
res +=
|
|
4649
|
-
|
|
4650
|
+
res += sep2 + lm;
|
|
4651
|
+
sep2 = " ";
|
|
4650
4652
|
}
|
|
4651
4653
|
pos = line.lastIndex;
|
|
4652
4654
|
}
|
|
4653
4655
|
const last = /[ \t]*(.*)/sy;
|
|
4654
4656
|
last.lastIndex = pos;
|
|
4655
4657
|
match = last.exec(source);
|
|
4656
|
-
return res +
|
|
4658
|
+
return res + sep2 + (match?.[1] ?? "");
|
|
4657
4659
|
}
|
|
4658
4660
|
function doubleQuotedValue(source, onError) {
|
|
4659
4661
|
let res = "";
|
|
@@ -5456,14 +5458,14 @@ var require_cst_stringify = __commonJS({
|
|
|
5456
5458
|
}
|
|
5457
5459
|
}
|
|
5458
5460
|
}
|
|
5459
|
-
function stringifyItem({ start, key, sep, value }) {
|
|
5461
|
+
function stringifyItem({ start, key, sep: sep2, value }) {
|
|
5460
5462
|
let res = "";
|
|
5461
5463
|
for (const st of start)
|
|
5462
5464
|
res += st.source;
|
|
5463
5465
|
if (key)
|
|
5464
5466
|
res += stringifyToken(key);
|
|
5465
|
-
if (
|
|
5466
|
-
for (const st of
|
|
5467
|
+
if (sep2)
|
|
5468
|
+
for (const st of sep2)
|
|
5467
5469
|
res += st.source;
|
|
5468
5470
|
if (value)
|
|
5469
5471
|
res += stringifyToken(value);
|
|
@@ -6625,18 +6627,18 @@ var require_parser = __commonJS({
|
|
|
6625
6627
|
if (this.type === "map-value-ind") {
|
|
6626
6628
|
const prev = getPrevProps(this.peek(2));
|
|
6627
6629
|
const start = getFirstKeyStartProps(prev);
|
|
6628
|
-
let
|
|
6630
|
+
let sep2;
|
|
6629
6631
|
if (scalar.end) {
|
|
6630
|
-
|
|
6631
|
-
|
|
6632
|
+
sep2 = scalar.end;
|
|
6633
|
+
sep2.push(this.sourceToken);
|
|
6632
6634
|
delete scalar.end;
|
|
6633
6635
|
} else
|
|
6634
|
-
|
|
6636
|
+
sep2 = [this.sourceToken];
|
|
6635
6637
|
const map = {
|
|
6636
6638
|
type: "block-map",
|
|
6637
6639
|
offset: scalar.offset,
|
|
6638
6640
|
indent: scalar.indent,
|
|
6639
|
-
items: [{ start, key: scalar, sep }]
|
|
6641
|
+
items: [{ start, key: scalar, sep: sep2 }]
|
|
6640
6642
|
};
|
|
6641
6643
|
this.onKeyLine = true;
|
|
6642
6644
|
this.stack[this.stack.length - 1] = map;
|
|
@@ -6789,15 +6791,15 @@ var require_parser = __commonJS({
|
|
|
6789
6791
|
} else if (isFlowToken(it.key) && !includesToken(it.sep, "newline")) {
|
|
6790
6792
|
const start2 = getFirstKeyStartProps(it.start);
|
|
6791
6793
|
const key = it.key;
|
|
6792
|
-
const
|
|
6793
|
-
|
|
6794
|
+
const sep2 = it.sep;
|
|
6795
|
+
sep2.push(this.sourceToken);
|
|
6794
6796
|
delete it.key;
|
|
6795
6797
|
delete it.sep;
|
|
6796
6798
|
this.stack.push({
|
|
6797
6799
|
type: "block-map",
|
|
6798
6800
|
offset: this.offset,
|
|
6799
6801
|
indent: this.indent,
|
|
6800
|
-
items: [{ start: start2, key, sep }]
|
|
6802
|
+
items: [{ start: start2, key, sep: sep2 }]
|
|
6801
6803
|
});
|
|
6802
6804
|
} else if (start.length > 0) {
|
|
6803
6805
|
it.sep = it.sep.concat(start, this.sourceToken);
|
|
@@ -6991,13 +6993,13 @@ var require_parser = __commonJS({
|
|
|
6991
6993
|
const prev = getPrevProps(parent);
|
|
6992
6994
|
const start = getFirstKeyStartProps(prev);
|
|
6993
6995
|
fixFlowSeqItems(fc);
|
|
6994
|
-
const
|
|
6995
|
-
|
|
6996
|
+
const sep2 = fc.end.splice(1, fc.end.length);
|
|
6997
|
+
sep2.push(this.sourceToken);
|
|
6996
6998
|
const map = {
|
|
6997
6999
|
type: "block-map",
|
|
6998
7000
|
offset: fc.offset,
|
|
6999
7001
|
indent: fc.indent,
|
|
7000
|
-
items: [{ start, key: fc, sep }]
|
|
7002
|
+
items: [{ start, key: fc, sep: sep2 }]
|
|
7001
7003
|
};
|
|
7002
7004
|
this.onKeyLine = true;
|
|
7003
7005
|
this.stack[this.stack.length - 1] = map;
|
|
@@ -8524,6 +8526,1036 @@ function parseProofsConfig(text) {
|
|
|
8524
8526
|
return problems.length > 0 ? { ok: false, problems } : { ok: true, value: { setup, teardown, runners } };
|
|
8525
8527
|
}
|
|
8526
8528
|
|
|
8529
|
+
// ../agents/src/claude-code/capture/discover.ts
|
|
8530
|
+
function defaultProjectsDir(io) {
|
|
8531
|
+
return io.path.join(io.home(), CLAUDE_CODE.capture.sessionFolder.replace(/^~\//, ""));
|
|
8532
|
+
}
|
|
8533
|
+
function defaultRawDir(io) {
|
|
8534
|
+
return io.path.join(io.home(), ...RAW_MIRROR_SEGMENTS);
|
|
8535
|
+
}
|
|
8536
|
+
function sessionIdFromPath(file) {
|
|
8537
|
+
const base = file.split(/[/\\]/).pop() ?? file;
|
|
8538
|
+
return base.replace(/\.jsonl$/, "");
|
|
8539
|
+
}
|
|
8540
|
+
function findTranscripts(io, root = defaultProjectsDir(io)) {
|
|
8541
|
+
const found = [];
|
|
8542
|
+
const walk = (dir) => {
|
|
8543
|
+
let names;
|
|
8544
|
+
try {
|
|
8545
|
+
names = io.fs.list(dir);
|
|
8546
|
+
} catch {
|
|
8547
|
+
return;
|
|
8548
|
+
}
|
|
8549
|
+
for (const name of names) {
|
|
8550
|
+
const p = io.path.join(dir, name);
|
|
8551
|
+
const st = io.fs.stat(p);
|
|
8552
|
+
if (st.kind === "missing") continue;
|
|
8553
|
+
if (isFolder(io, p)) walk(p);
|
|
8554
|
+
else if (name.endsWith(".jsonl") && st.size > 0) {
|
|
8555
|
+
const segments = p.split(/[/\\]/);
|
|
8556
|
+
const subagentsIdx = segments.lastIndexOf("subagents");
|
|
8557
|
+
const isSubagent = subagentsIdx > 0;
|
|
8558
|
+
const workflowRunId = isSubagent && segments[subagentsIdx + 1] === "workflows" ? segments[subagentsIdx + 2] : void 0;
|
|
8559
|
+
const meta = isSubagent ? readSpawnSidecar(io, p) : null;
|
|
8560
|
+
found.push({
|
|
8561
|
+
file: p,
|
|
8562
|
+
mtimeMs: st.mtimeMs,
|
|
8563
|
+
bytes: st.size,
|
|
8564
|
+
isSubagent,
|
|
8565
|
+
...isSubagent ? {
|
|
8566
|
+
parentSessionId: segments[subagentsIdx - 1] || void 0,
|
|
8567
|
+
ownId: sessionIdFromPath(name),
|
|
8568
|
+
...workflowRunId ? { workflowRunId } : {},
|
|
8569
|
+
...meta?.description ? { metaDescription: meta.description } : {},
|
|
8570
|
+
...meta?.name ? { metaName: meta.name } : {},
|
|
8571
|
+
...meta?.agentType ? { metaAgentType: meta.agentType } : {}
|
|
8572
|
+
} : {}
|
|
8573
|
+
});
|
|
8574
|
+
}
|
|
8575
|
+
}
|
|
8576
|
+
};
|
|
8577
|
+
walk(root);
|
|
8578
|
+
found.sort((a, b) => b.mtimeMs - a.mtimeMs);
|
|
8579
|
+
return found;
|
|
8580
|
+
}
|
|
8581
|
+
function isFolder(io, path) {
|
|
8582
|
+
const kind = io.fs.kind(path);
|
|
8583
|
+
if (kind === "directory") return true;
|
|
8584
|
+
if (kind !== "link") return false;
|
|
8585
|
+
try {
|
|
8586
|
+
return io.fs.kind(io.fs.realPath(path)) === "directory";
|
|
8587
|
+
} catch {
|
|
8588
|
+
return false;
|
|
8589
|
+
}
|
|
8590
|
+
}
|
|
8591
|
+
function readSpawnSidecar(io, transcriptPath) {
|
|
8592
|
+
const sidecarPath = transcriptPath.replace(/\.jsonl$/, ".meta.json");
|
|
8593
|
+
let raw;
|
|
8594
|
+
try {
|
|
8595
|
+
raw = io.fs.readRawText(sidecarPath);
|
|
8596
|
+
} catch {
|
|
8597
|
+
return null;
|
|
8598
|
+
}
|
|
8599
|
+
if (raw === void 0) return null;
|
|
8600
|
+
try {
|
|
8601
|
+
const parsed = JSON.parse(raw);
|
|
8602
|
+
return {
|
|
8603
|
+
...typeof parsed.description === "string" ? { description: parsed.description } : {},
|
|
8604
|
+
...typeof parsed.name === "string" ? { name: parsed.name } : {},
|
|
8605
|
+
...typeof parsed.agentType === "string" ? { agentType: parsed.agentType } : {}
|
|
8606
|
+
};
|
|
8607
|
+
} catch {
|
|
8608
|
+
return null;
|
|
8609
|
+
}
|
|
8610
|
+
}
|
|
8611
|
+
|
|
8612
|
+
// ../agents/src/claude-code/capture/base64.ts
|
|
8613
|
+
var ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
8614
|
+
var VALUES = new Map([...ALPHABET].map((char, index) => [char, index]));
|
|
8615
|
+
VALUES.set("-", 62);
|
|
8616
|
+
VALUES.set("_", 63);
|
|
8617
|
+
function decodeBase64(text) {
|
|
8618
|
+
const out = [];
|
|
8619
|
+
let buffer = 0;
|
|
8620
|
+
let bits = 0;
|
|
8621
|
+
for (const char of text) {
|
|
8622
|
+
if (char === "=") break;
|
|
8623
|
+
const value = VALUES.get(char);
|
|
8624
|
+
if (value === void 0) continue;
|
|
8625
|
+
buffer = buffer << 6 | value;
|
|
8626
|
+
bits += 6;
|
|
8627
|
+
if (bits >= 8) {
|
|
8628
|
+
bits -= 8;
|
|
8629
|
+
out.push(buffer >> bits & 255);
|
|
8630
|
+
buffer &= (1 << bits) - 1;
|
|
8631
|
+
}
|
|
8632
|
+
}
|
|
8633
|
+
return Uint8Array.from(out);
|
|
8634
|
+
}
|
|
8635
|
+
|
|
8636
|
+
// ../agents/src/claude-code/capture/parse.ts
|
|
8637
|
+
var EDIT_TOOLS = /* @__PURE__ */ new Set(["Edit", "Write", "MultiEdit", "NotebookEdit"]);
|
|
8638
|
+
var REJECTION_MARKERS = [
|
|
8639
|
+
"The user doesn't want to proceed",
|
|
8640
|
+
"[Request interrupted by user",
|
|
8641
|
+
"user doesn't want to take this action"
|
|
8642
|
+
];
|
|
8643
|
+
var TEXT_CAP = 4e3;
|
|
8644
|
+
var HOOK_INFOS_CAP = 50;
|
|
8645
|
+
var HOOK_COMMAND_CAP = 300;
|
|
8646
|
+
var HOOK_ERRORS_CAP = 3;
|
|
8647
|
+
var HOOK_ERROR_TEXT_CAP = 500;
|
|
8648
|
+
function isValidHookDurationMs(v) {
|
|
8649
|
+
return typeof v === "number" && Number.isInteger(v) && v >= 0;
|
|
8650
|
+
}
|
|
8651
|
+
var PEER_MARKERS = [
|
|
8652
|
+
/<teammate-message/,
|
|
8653
|
+
/<agent-message/,
|
|
8654
|
+
/^Another Claude session sent a message:/
|
|
8655
|
+
];
|
|
8656
|
+
var NOTIFICATION_MARKERS = [
|
|
8657
|
+
/<task-notification/,
|
|
8658
|
+
/^\[SYSTEM NOTIFICATION/,
|
|
8659
|
+
/This is an automated background-task event/,
|
|
8660
|
+
/^Caveat: The messages below/,
|
|
8661
|
+
/<command-name>|<local-command-stdout>|<command-message>|<local-command-caveat>/,
|
|
8662
|
+
/^Base directory for this skill:/,
|
|
8663
|
+
/^Path to the skill:/,
|
|
8664
|
+
/^You are (?:the|an?)\s/
|
|
8665
|
+
];
|
|
8666
|
+
function classifyUserSource(line, text) {
|
|
8667
|
+
const kind = line.origin?.kind;
|
|
8668
|
+
if (typeof kind === "string") {
|
|
8669
|
+
if (kind === "human") return "human";
|
|
8670
|
+
if (kind === "peer") return "peer";
|
|
8671
|
+
return "notification";
|
|
8672
|
+
}
|
|
8673
|
+
if (line.isMeta === true) return "notification";
|
|
8674
|
+
if (PEER_MARKERS.some((re) => re.test(text))) return "peer";
|
|
8675
|
+
if (NOTIFICATION_MARKERS.some((re) => re.test(text))) return "notification";
|
|
8676
|
+
return "human";
|
|
8677
|
+
}
|
|
8678
|
+
var KNOWN_UNMAPPED = /* @__PURE__ */ new Set([
|
|
8679
|
+
"attachment",
|
|
8680
|
+
"last-prompt",
|
|
8681
|
+
"file-history-snapshot",
|
|
8682
|
+
"bridge-session",
|
|
8683
|
+
"started",
|
|
8684
|
+
"result",
|
|
8685
|
+
"frame-link",
|
|
8686
|
+
"diff-summary",
|
|
8687
|
+
"agent-name"
|
|
8688
|
+
]);
|
|
8689
|
+
function parseTranscript(content, opts, sha256) {
|
|
8690
|
+
const warnings = new WarningCollector();
|
|
8691
|
+
const versions = /* @__PURE__ */ new Set();
|
|
8692
|
+
const lines = content.split("\n");
|
|
8693
|
+
const stats = { lines: 0, parsed: 0, skipped: 0, unmapped: 0 };
|
|
8694
|
+
let sessionId = opts.fork?.sessionId ?? "";
|
|
8695
|
+
const forkLaunchedMs = opts.fork === void 0 ? void 0 : Date.parse(opts.fork.launchedAt);
|
|
8696
|
+
let forkKept = false;
|
|
8697
|
+
let cwd;
|
|
8698
|
+
let gitBranch;
|
|
8699
|
+
const cwdHistogram = /* @__PURE__ */ new Map();
|
|
8700
|
+
let version;
|
|
8701
|
+
let entrypoint;
|
|
8702
|
+
let title;
|
|
8703
|
+
let sawSdkPromptSource = false;
|
|
8704
|
+
let subagentAgentId;
|
|
8705
|
+
const parentSessionId = opts.parentSessionId;
|
|
8706
|
+
const turns = [];
|
|
8707
|
+
const events = [];
|
|
8708
|
+
const models = /* @__PURE__ */ new Set();
|
|
8709
|
+
const toolCallsById = /* @__PURE__ */ new Map();
|
|
8710
|
+
const seenSubagents = /* @__PURE__ */ new Set();
|
|
8711
|
+
const unmappedTypes = /* @__PURE__ */ new Map();
|
|
8712
|
+
const unknownModels = /* @__PURE__ */ new Set();
|
|
8713
|
+
const blobs = /* @__PURE__ */ new Map();
|
|
8714
|
+
let open = null;
|
|
8715
|
+
const usageTurnByMessageId = /* @__PURE__ */ new Map();
|
|
8716
|
+
const addToTotals = (usage, sign) => {
|
|
8717
|
+
totals.in += sign * usage.in;
|
|
8718
|
+
totals.out += sign * usage.out;
|
|
8719
|
+
totals.cacheRead += sign * usage.cacheRead;
|
|
8720
|
+
totals.cacheCreate += sign * usage.cacheCreate;
|
|
8721
|
+
};
|
|
8722
|
+
const addCost = (costUsd, sign) => {
|
|
8723
|
+
if (typeof costUsd !== "number") return;
|
|
8724
|
+
totalCost += sign * costUsd;
|
|
8725
|
+
anyCostKnown = true;
|
|
8726
|
+
};
|
|
8727
|
+
const flushOpen = () => {
|
|
8728
|
+
if (!open) return;
|
|
8729
|
+
const turn = finalizeAssistant(open, turnIndex, toolCallsById, models, unknownModels);
|
|
8730
|
+
const usageTurn = turn.messageId ? usageTurnByMessageId.get(turn.messageId) : void 0;
|
|
8731
|
+
if (usageTurn?.usage && turn.usage) {
|
|
8732
|
+
const merged = maxUsage(usageTurn.usage, turn.usage);
|
|
8733
|
+
addToTotals(usageTurn.usage, -1);
|
|
8734
|
+
addToTotals(merged, 1);
|
|
8735
|
+
usageTurn.usage = merged;
|
|
8736
|
+
if (usageTurn.model) {
|
|
8737
|
+
addCost(usageTurn.costUsd, -1);
|
|
8738
|
+
usageTurn.costUsd = costOfUsage(usageTurn.model, merged);
|
|
8739
|
+
addCost(usageTurn.costUsd, 1);
|
|
8740
|
+
}
|
|
8741
|
+
turn.usage = { in: 0, out: 0, cacheRead: 0, cacheCreate: 0, ...merged.speed ? { speed: merged.speed } : {} };
|
|
8742
|
+
turn.costUsd = turn.model ? costOfUsage(turn.model, turn.usage) : null;
|
|
8743
|
+
} else if (turn.usage) {
|
|
8744
|
+
if (turn.messageId) usageTurnByMessageId.set(turn.messageId, turn);
|
|
8745
|
+
addToTotals(turn.usage, 1);
|
|
8746
|
+
addCost(turn.costUsd, 1);
|
|
8747
|
+
}
|
|
8748
|
+
turns.push(turn);
|
|
8749
|
+
turnIndex += 1;
|
|
8750
|
+
open = null;
|
|
8751
|
+
};
|
|
8752
|
+
let startMs = Number.POSITIVE_INFINITY;
|
|
8753
|
+
let endMs = 0;
|
|
8754
|
+
let wallClockMs = 0;
|
|
8755
|
+
let seq = 0;
|
|
8756
|
+
let turnIndex = 0;
|
|
8757
|
+
let attributedSkill;
|
|
8758
|
+
const totals = { in: 0, out: 0, cacheRead: 0, cacheCreate: 0 };
|
|
8759
|
+
let totalCost = 0;
|
|
8760
|
+
let anyCostKnown = false;
|
|
8761
|
+
const outcome = {};
|
|
8762
|
+
const prLinks = [];
|
|
8763
|
+
const prLinksByNumber = /* @__PURE__ */ new Map();
|
|
8764
|
+
const shas = { pending: [], all: [], seen: /* @__PURE__ */ new Set() };
|
|
8765
|
+
const noteTs = (ts) => {
|
|
8766
|
+
if (typeof ts !== "string") return void 0;
|
|
8767
|
+
const ms = Date.parse(ts);
|
|
8768
|
+
if (!Number.isFinite(ms)) return void 0;
|
|
8769
|
+
if (!/[zZ]|[+-]\d{2}:?\d{2}$/.test(ts)) warnings.add(WARNING_CODES.ambiguousTimezone, ts);
|
|
8770
|
+
if (ms < startMs) startMs = ms;
|
|
8771
|
+
if (ms > endMs) endMs = ms;
|
|
8772
|
+
return new Date(ms).toISOString();
|
|
8773
|
+
};
|
|
8774
|
+
for (let i = 0; i < lines.length; i++) {
|
|
8775
|
+
const raw = lines[i];
|
|
8776
|
+
const trimmed = raw.trim();
|
|
8777
|
+
if (!trimmed) continue;
|
|
8778
|
+
stats.lines += 1;
|
|
8779
|
+
let line;
|
|
8780
|
+
try {
|
|
8781
|
+
line = JSON.parse(trimmed);
|
|
8782
|
+
} catch {
|
|
8783
|
+
const isFinal = i >= lines.length - 2;
|
|
8784
|
+
warnings.add(isFinal ? WARNING_CODES.truncatedFinalLine : WARNING_CODES.malformedLine, trimmed.slice(0, 80));
|
|
8785
|
+
stats.skipped += 1;
|
|
8786
|
+
continue;
|
|
8787
|
+
}
|
|
8788
|
+
if (opts.fork !== void 0) {
|
|
8789
|
+
const at = typeof line.timestamp === "string" ? Date.parse(line.timestamp) : Number.NaN;
|
|
8790
|
+
const copied = Number.isFinite(at) && forkLaunchedMs !== void 0 && Number.isFinite(forkLaunchedMs) && at < forkLaunchedMs || !Number.isFinite(at) && !forkKept;
|
|
8791
|
+
if (copied) continue;
|
|
8792
|
+
if (Number.isFinite(at)) forkKept = true;
|
|
8793
|
+
}
|
|
8794
|
+
stats.parsed += 1;
|
|
8795
|
+
if (typeof line.sessionId === "string" && !sessionId) sessionId = line.sessionId;
|
|
8796
|
+
if (typeof line.cwd === "string" && !cwd) cwd = line.cwd;
|
|
8797
|
+
if (typeof line.cwd === "string" && (cwdHistogram.has(line.cwd) || cwdHistogram.size < 32)) {
|
|
8798
|
+
cwdHistogram.set(line.cwd, (cwdHistogram.get(line.cwd) ?? 0) + 1);
|
|
8799
|
+
}
|
|
8800
|
+
if (typeof line.gitBranch === "string" && !gitBranch) gitBranch = line.gitBranch;
|
|
8801
|
+
if (typeof line.entrypoint === "string" && !entrypoint) entrypoint = line.entrypoint;
|
|
8802
|
+
if (line.promptSource === "sdk") sawSdkPromptSource = true;
|
|
8803
|
+
if (typeof line.version === "string") {
|
|
8804
|
+
version = version ?? line.version;
|
|
8805
|
+
versions.add(line.version);
|
|
8806
|
+
if (isNewerThanSupported(line.version)) warnings.add(WARNING_CODES.versionNewer, line.version);
|
|
8807
|
+
}
|
|
8808
|
+
if (opts.isSubagent && typeof line.agentId === "string" && !subagentAgentId) {
|
|
8809
|
+
subagentAgentId = line.agentId;
|
|
8810
|
+
}
|
|
8811
|
+
const tsIso = noteTs(line.timestamp);
|
|
8812
|
+
if (typeof line.attributionSkill === "string") {
|
|
8813
|
+
if (line.attributionSkill !== attributedSkill) {
|
|
8814
|
+
const msgId = typeof line.message?.id === "string" ? line.message.id : line.uuid ?? `line-${i}`;
|
|
8815
|
+
const activationTurnIndex = line.type === "assistant" && open !== null && open.messageId !== msgId ? turnIndex + 1 : turnIndex;
|
|
8816
|
+
events.push({
|
|
8817
|
+
type: EVENT_TYPES.skillActivated,
|
|
8818
|
+
seq: seq++,
|
|
8819
|
+
...tsIso ? { ts: tsIso } : {},
|
|
8820
|
+
turnIndex: activationTurnIndex,
|
|
8821
|
+
data: { skill: line.attributionSkill }
|
|
8822
|
+
});
|
|
8823
|
+
attributedSkill = line.attributionSkill;
|
|
8824
|
+
}
|
|
8825
|
+
}
|
|
8826
|
+
if (line.isSidechain === true && typeof line.agentId === "string" && !seenSubagents.has(line.agentId)) {
|
|
8827
|
+
seenSubagents.add(line.agentId);
|
|
8828
|
+
events.push({ type: EVENT_TYPES.subagent, seq: seq++, ...tsIso ? { ts: tsIso } : {}, data: { agentId: line.agentId } });
|
|
8829
|
+
}
|
|
8830
|
+
switch (line.type) {
|
|
8831
|
+
case "assistant": {
|
|
8832
|
+
if (line.isApiErrorMessage === true) {
|
|
8833
|
+
const code = apiErrorCode(line.message?.content);
|
|
8834
|
+
events.push({
|
|
8835
|
+
type: EVENT_TYPES.apiError,
|
|
8836
|
+
seq: seq++,
|
|
8837
|
+
...tsIso ? { ts: tsIso } : {},
|
|
8838
|
+
...code ? { data: { code } } : {}
|
|
8839
|
+
});
|
|
8840
|
+
}
|
|
8841
|
+
const msgId = typeof line.message?.id === "string" ? line.message.id : line.uuid ?? `line-${i}`;
|
|
8842
|
+
if (open && open.messageId !== msgId) flushOpen();
|
|
8843
|
+
if (!open) {
|
|
8844
|
+
open = {
|
|
8845
|
+
messageId: msgId,
|
|
8846
|
+
ts: tsIso,
|
|
8847
|
+
texts: [],
|
|
8848
|
+
thinkings: [],
|
|
8849
|
+
toolCalls: /* @__PURE__ */ new Map(),
|
|
8850
|
+
toolOrder: []
|
|
8851
|
+
};
|
|
8852
|
+
}
|
|
8853
|
+
mergeAssistantLine(open, line, tsIso);
|
|
8854
|
+
break;
|
|
8855
|
+
}
|
|
8856
|
+
case "user": {
|
|
8857
|
+
flushOpen();
|
|
8858
|
+
if (line.isCompactSummary === true) {
|
|
8859
|
+
if (events[events.length - 1]?.type !== EVENT_TYPES.compaction) {
|
|
8860
|
+
events.push({ type: EVENT_TYPES.compaction, seq: seq++, ...tsIso ? { ts: tsIso } : {} });
|
|
8861
|
+
}
|
|
8862
|
+
break;
|
|
8863
|
+
}
|
|
8864
|
+
const turn = buildUserTurn(line, turnIndex, tsIso, toolCallsById, blobs, shas, sha256);
|
|
8865
|
+
if (turn) {
|
|
8866
|
+
turns.push(turn);
|
|
8867
|
+
turnIndex += 1;
|
|
8868
|
+
}
|
|
8869
|
+
break;
|
|
8870
|
+
}
|
|
8871
|
+
case "summary":
|
|
8872
|
+
countUnmapped(unmappedTypes, "summary");
|
|
8873
|
+
stats.unmapped += 1;
|
|
8874
|
+
break;
|
|
8875
|
+
case "ai-title":
|
|
8876
|
+
if (typeof line.aiTitle === "string") {
|
|
8877
|
+
title = line.aiTitle;
|
|
8878
|
+
}
|
|
8879
|
+
break;
|
|
8880
|
+
case "queue-operation":
|
|
8881
|
+
events.push({ type: EVENT_TYPES.queueOperation, seq: seq++, ...tsIso ? { ts: tsIso } : {}, ...line.operation ? { data: { operation: line.operation } } : {} });
|
|
8882
|
+
break;
|
|
8883
|
+
case "mode":
|
|
8884
|
+
case "permission-mode":
|
|
8885
|
+
events.push({ type: EVENT_TYPES.permissionModeChanged, seq: seq++, ...tsIso ? { ts: tsIso } : {}, data: { mode: line.permissionMode ?? line.mode ?? "unknown" } });
|
|
8886
|
+
break;
|
|
8887
|
+
case "pr-link":
|
|
8888
|
+
events.push({ type: EVENT_TYPES.prLinked, seq: seq++, ...tsIso ? { ts: tsIso } : {}, ...typeof line.prNumber === "number" ? { data: { prNumber: line.prNumber } } : {} });
|
|
8889
|
+
break;
|
|
8890
|
+
case "system":
|
|
8891
|
+
handleSystem(line, tsIso, events, () => seq++, (ms) => {
|
|
8892
|
+
wallClockMs += ms;
|
|
8893
|
+
});
|
|
8894
|
+
if (line.isCompactSummary === true && events[events.length - 1]?.type !== EVENT_TYPES.compaction) {
|
|
8895
|
+
events.push({ type: EVENT_TYPES.compaction, seq: seq++, ...tsIso ? { ts: tsIso } : {} });
|
|
8896
|
+
}
|
|
8897
|
+
break;
|
|
8898
|
+
case "attachment":
|
|
8899
|
+
if (line.attachment?.type === "hook_blocking_error") {
|
|
8900
|
+
events.push({
|
|
8901
|
+
type: EVENT_TYPES.hookBlocked,
|
|
8902
|
+
seq: seq++,
|
|
8903
|
+
...tsIso ? { ts: tsIso } : {},
|
|
8904
|
+
data: {
|
|
8905
|
+
...line.attachment.hookEvent ? { hookEvent: line.attachment.hookEvent } : {},
|
|
8906
|
+
...line.attachment.hookName ? { hookName: line.attachment.hookName } : {},
|
|
8907
|
+
...line.attachment.toolUseID ? { toolUseId: line.attachment.toolUseID } : {}
|
|
8908
|
+
}
|
|
8909
|
+
});
|
|
8910
|
+
} else {
|
|
8911
|
+
countUnmapped(unmappedTypes, "attachment");
|
|
8912
|
+
stats.unmapped += 1;
|
|
8913
|
+
}
|
|
8914
|
+
break;
|
|
8915
|
+
case void 0:
|
|
8916
|
+
countUnmapped(unmappedTypes, "(typeless)");
|
|
8917
|
+
stats.unmapped += 1;
|
|
8918
|
+
break;
|
|
8919
|
+
default:
|
|
8920
|
+
if (line.isCompactSummary === true) {
|
|
8921
|
+
if (events[events.length - 1]?.type !== EVENT_TYPES.compaction) {
|
|
8922
|
+
events.push({ type: EVENT_TYPES.compaction, seq: seq++, ...tsIso ? { ts: tsIso } : {} });
|
|
8923
|
+
}
|
|
8924
|
+
} else {
|
|
8925
|
+
countUnmapped(unmappedTypes, line.type);
|
|
8926
|
+
stats.unmapped += 1;
|
|
8927
|
+
if (!KNOWN_UNMAPPED.has(line.type)) {
|
|
8928
|
+
warnings.add(WARNING_CODES.unknownLineType, line.type);
|
|
8929
|
+
}
|
|
8930
|
+
}
|
|
8931
|
+
}
|
|
8932
|
+
if (line.type === "pr-link" && typeof line.prNumber === "number" && Number.isInteger(line.prNumber) && line.prNumber > 0) {
|
|
8933
|
+
outcome.prNumber = line.prNumber;
|
|
8934
|
+
if (typeof line.prUrl === "string") outcome.prUrl = line.prUrl;
|
|
8935
|
+
let entry = prLinksByNumber.get(line.prNumber);
|
|
8936
|
+
if (!entry) {
|
|
8937
|
+
entry = { prNumber: line.prNumber };
|
|
8938
|
+
prLinksByNumber.set(line.prNumber, entry);
|
|
8939
|
+
prLinks.push(entry);
|
|
8940
|
+
}
|
|
8941
|
+
if (typeof line.prUrl === "string") entry.prUrl = line.prUrl;
|
|
8942
|
+
if (shas.pending.length > 0) {
|
|
8943
|
+
entry.commitShas = [...entry.commitShas ?? [], ...shas.pending];
|
|
8944
|
+
shas.pending = [];
|
|
8945
|
+
}
|
|
8946
|
+
}
|
|
8947
|
+
}
|
|
8948
|
+
flushOpen();
|
|
8949
|
+
if (stats.parsed === 0 || turns.length === 0 && events.length === 0) {
|
|
8950
|
+
return { session: null, warnings: warnings.histogram(), stats, versions: [...versions].sort(), blobs: [...blobs.values()] };
|
|
8951
|
+
}
|
|
8952
|
+
for (const model of unknownModels) warnings.add(WARNING_CODES.unknownModelCost, model);
|
|
8953
|
+
const vendor = {};
|
|
8954
|
+
if (unmappedTypes.size > 0) {
|
|
8955
|
+
vendor.unmappedLineTypes = Object.fromEntries([...unmappedTypes.entries()].sort(([a], [b]) => a.localeCompare(b)));
|
|
8956
|
+
}
|
|
8957
|
+
const ownId = opts.isSubagent ? opts.ownId || subagentAgentId || opts.fallbackId || sessionId || "unknown-subagent" : sessionId || opts.fallbackId || "unknown-session";
|
|
8958
|
+
const parentLink = opts.isSubagent ? parentSessionId || sessionId || void 0 : void 0;
|
|
8959
|
+
if (!title && opts.isSubagent && opts.spawnDescription) {
|
|
8960
|
+
title = opts.spawnDescription;
|
|
8961
|
+
}
|
|
8962
|
+
if (!title && opts.isSubagent) {
|
|
8963
|
+
const firstTurn = turns.find((t) => t.role === "user" && typeof t.text === "string" && t.text.trim());
|
|
8964
|
+
const text = firstTurn?.text?.trim();
|
|
8965
|
+
const spawnTag = text ? /^<teammate-message([^>]*)>/.exec(text) : null;
|
|
8966
|
+
if (spawnTag) {
|
|
8967
|
+
const summary = /\bsummary="([^"]*)"/.exec(spawnTag[1] ?? "")?.[1]?.trim();
|
|
8968
|
+
if (summary) {
|
|
8969
|
+
title = decodeXmlEntities(summary);
|
|
8970
|
+
} else {
|
|
8971
|
+
const body = text.slice(spawnTag[0].length).trim();
|
|
8972
|
+
const firstLine = body.split("\n").find((line) => line.trim().length > 0);
|
|
8973
|
+
if (firstLine) title = firstLine.trim().slice(0, 80);
|
|
8974
|
+
}
|
|
8975
|
+
}
|
|
8976
|
+
}
|
|
8977
|
+
if (!title) {
|
|
8978
|
+
const firstAsk = turns.find(
|
|
8979
|
+
(t) => isHumanUserTurn(t) && typeof t.text === "string" && t.text.trim() && !/^<(command-name|command-message|command-args|local-command|system-reminder)/.test(t.text.trim())
|
|
8980
|
+
);
|
|
8981
|
+
if (firstAsk?.text) title = firstAsk.text.trim().split("\n")[0].slice(0, 80);
|
|
8982
|
+
}
|
|
8983
|
+
const origin = opts.isSubagent || sawSdkPromptSource || entrypoint?.startsWith("sdk") ? "agent" : "interactive";
|
|
8984
|
+
const startedAt = Number.isFinite(startMs) ? new Date(startMs).toISOString() : new Date(endMs).toISOString();
|
|
8985
|
+
const buckets = bucketsFromTurns(turns);
|
|
8986
|
+
const session = {
|
|
8987
|
+
schemaVersion: SCHEMA_VERSION,
|
|
8988
|
+
id: ownId,
|
|
8989
|
+
agent: { type: opts.agentType ?? CLAUDE_CODE.id, ...version ? { version } : {}, ...entrypoint ? { entrypoint } : {}, origin },
|
|
8990
|
+
env: { ...cwd ? { cwd } : {}, ...gitBranch ? { gitBranch } : {} },
|
|
8991
|
+
...opts.isSubagent ? {
|
|
8992
|
+
subagent: {
|
|
8993
|
+
...subagentAgentId ? { agentId: subagentAgentId } : {},
|
|
8994
|
+
...parentLink ? { parentSessionId: parentLink } : {},
|
|
8995
|
+
...opts.workflowRunId ? { workflowRunId: opts.workflowRunId } : {},
|
|
8996
|
+
...opts.spawnDescription ? { spawnDescription: opts.spawnDescription } : {},
|
|
8997
|
+
...opts.spawnName ? { spawnName: opts.spawnName } : {},
|
|
8998
|
+
...opts.spawnAgentType ? { spawnAgentType: opts.spawnAgentType } : {}
|
|
8999
|
+
}
|
|
9000
|
+
} : {},
|
|
9001
|
+
startedAt,
|
|
9002
|
+
...endMs > 0 ? { endedAt: new Date(endMs).toISOString() } : {},
|
|
9003
|
+
models: [...models].sort(),
|
|
9004
|
+
turns,
|
|
9005
|
+
events,
|
|
9006
|
+
totals: {
|
|
9007
|
+
inputTokens: totals.in,
|
|
9008
|
+
outputTokens: totals.out,
|
|
9009
|
+
cacheReadTokens: totals.cacheRead,
|
|
9010
|
+
cacheCreationTokens: totals.cacheCreate,
|
|
9011
|
+
costUsd: anyCostKnown ? round(totalCost) : null,
|
|
9012
|
+
...wallClockMs > 0 ? { wallClockMs } : {},
|
|
9013
|
+
...buckets.length > 0 ? { buckets, bandBoundaries: [...INPUT_BAND_BOUNDARIES] } : {}
|
|
9014
|
+
},
|
|
9015
|
+
...outcome.prNumber || shas.all.length > 0 ? {
|
|
9016
|
+
outcome: {
|
|
9017
|
+
...outcome,
|
|
9018
|
+
...shas.all.length > 0 ? { commitShas: shas.all } : {},
|
|
9019
|
+
...prLinks.length > 0 ? { prs: prLinks } : {}
|
|
9020
|
+
}
|
|
9021
|
+
} : {},
|
|
9022
|
+
...title ? { title } : {},
|
|
9023
|
+
...Object.keys(vendor).length > 0 ? { vendor } : {},
|
|
9024
|
+
captureTier: opts.captureTier ?? "full",
|
|
9025
|
+
warnings: warnings.toArray(),
|
|
9026
|
+
// CAPTURE-INTERNAL: consumed by `enrichSessionRepo` to attribute the
|
|
9027
|
+
// session to where the work happened, then deleted before the session is
|
|
9028
|
+
// synced — it is not tier-classified and must never leave the machine.
|
|
9029
|
+
...cwdHistogram.size > 1 ? { cwdHistogram: Object.fromEntries(cwdHistogram) } : {}
|
|
9030
|
+
};
|
|
9031
|
+
const validated = parseAgentSession(session);
|
|
9032
|
+
return { session: validated, warnings: warnings.histogram(), stats, versions: [...versions].sort(), blobs: [...blobs.values()] };
|
|
9033
|
+
}
|
|
9034
|
+
function extractImage(block, blobs, hash) {
|
|
9035
|
+
const source = block.source;
|
|
9036
|
+
if (!source || source.type !== "base64" || typeof source.data !== "string") return null;
|
|
9037
|
+
const mediaType = typeof source.media_type === "string" ? source.media_type : "image/png";
|
|
9038
|
+
const data = source.data;
|
|
9039
|
+
const decoded = decodeBase64(data);
|
|
9040
|
+
const sha256 = hash(decoded);
|
|
9041
|
+
const bytes = decoded.byteLength;
|
|
9042
|
+
if (!blobs.has(sha256)) blobs.set(sha256, { sha256, mediaType, data, bytes });
|
|
9043
|
+
return { mediaType, sha256, bytes };
|
|
9044
|
+
}
|
|
9045
|
+
function extractInlineImages(value, blobs, images, hash) {
|
|
9046
|
+
if (Array.isArray(value)) {
|
|
9047
|
+
let changed2 = false;
|
|
9048
|
+
const out2 = value.map((v) => {
|
|
9049
|
+
const r = extractInlineImages(v, blobs, images, hash);
|
|
9050
|
+
if (r !== v) changed2 = true;
|
|
9051
|
+
return r;
|
|
9052
|
+
});
|
|
9053
|
+
return changed2 ? out2 : value;
|
|
9054
|
+
}
|
|
9055
|
+
if (!value || typeof value !== "object") return value;
|
|
9056
|
+
const obj = value;
|
|
9057
|
+
if (obj.type === "image" && obj.source && typeof obj.source === "object") {
|
|
9058
|
+
const ref = extractImage(obj, blobs, hash);
|
|
9059
|
+
if (!ref) return obj;
|
|
9060
|
+
images.push(ref);
|
|
9061
|
+
return { type: "image", mediaType: ref.mediaType, sha256: ref.sha256, bytes: ref.bytes };
|
|
9062
|
+
}
|
|
9063
|
+
let changed = false;
|
|
9064
|
+
const out = {};
|
|
9065
|
+
for (const k in obj) {
|
|
9066
|
+
const r = extractInlineImages(obj[k], blobs, images, hash);
|
|
9067
|
+
if (r !== obj[k]) changed = true;
|
|
9068
|
+
out[k] = r;
|
|
9069
|
+
}
|
|
9070
|
+
return changed ? out : obj;
|
|
9071
|
+
}
|
|
9072
|
+
function maxUsage(a, b) {
|
|
9073
|
+
const merged = {
|
|
9074
|
+
in: Math.max(a.in, b.in),
|
|
9075
|
+
out: Math.max(a.out, b.out),
|
|
9076
|
+
cacheRead: Math.max(a.cacheRead, b.cacheRead),
|
|
9077
|
+
cacheCreate: Math.max(a.cacheCreate, b.cacheCreate),
|
|
9078
|
+
// Same max-merge as the total it is a share of. Left unset when neither
|
|
9079
|
+
// reading carried the split, so the request still prices as all-5-minute
|
|
9080
|
+
// rather than as a zero-length 1-hour write.
|
|
9081
|
+
...a.cacheCreate1h !== void 0 || b.cacheCreate1h !== void 0 ? { cacheCreate1h: Math.max(a.cacheCreate1h ?? 0, b.cacheCreate1h ?? 0) } : {},
|
|
9082
|
+
...(a.speed ?? b.speed) !== void 0 ? { speed: a.speed ?? b.speed } : {}
|
|
9083
|
+
};
|
|
9084
|
+
merged.cacheCreate5m = merged.cacheCreate - Math.min(merged.cacheCreate1h ?? 0, merged.cacheCreate);
|
|
9085
|
+
return merged;
|
|
9086
|
+
}
|
|
9087
|
+
function mergeAssistantLine(open, line, tsIso) {
|
|
9088
|
+
if (!open.ts && tsIso) open.ts = tsIso;
|
|
9089
|
+
const message = line.message;
|
|
9090
|
+
const isSyntheticStub = line.isApiErrorMessage === true || message?.model === "<synthetic>";
|
|
9091
|
+
if (!isSyntheticStub && typeof message?.model === "string" && !open.model) open.model = message.model;
|
|
9092
|
+
const usage = readUsage(message?.usage);
|
|
9093
|
+
if (usage) open.usage = open.usage ? maxUsage(open.usage, usage) : usage;
|
|
9094
|
+
const content = message?.content;
|
|
9095
|
+
if (typeof content === "string") {
|
|
9096
|
+
if (content && !open.texts.includes(content)) open.texts.push(content);
|
|
9097
|
+
return;
|
|
9098
|
+
}
|
|
9099
|
+
if (!Array.isArray(content)) return;
|
|
9100
|
+
for (const block of content) {
|
|
9101
|
+
if (!block || typeof block !== "object") continue;
|
|
9102
|
+
const b = block;
|
|
9103
|
+
switch (b.type) {
|
|
9104
|
+
case "text":
|
|
9105
|
+
if (typeof b.text === "string" && b.text && !open.texts.includes(b.text)) open.texts.push(b.text);
|
|
9106
|
+
break;
|
|
9107
|
+
case "thinking":
|
|
9108
|
+
if (typeof b.thinking === "string" && b.thinking && !open.thinkings.includes(b.thinking)) {
|
|
9109
|
+
open.thinkings.push(b.thinking);
|
|
9110
|
+
}
|
|
9111
|
+
break;
|
|
9112
|
+
case "tool_use":
|
|
9113
|
+
case "server_tool_use":
|
|
9114
|
+
case "mcp_tool_use": {
|
|
9115
|
+
const name = typeof b.name === "string" ? b.name : "unknown";
|
|
9116
|
+
const call = {
|
|
9117
|
+
name,
|
|
9118
|
+
status: "ok",
|
|
9119
|
+
isEdit: EDIT_TOOLS.has(name),
|
|
9120
|
+
...tsIso ? { startTs: tsIso } : {},
|
|
9121
|
+
...b.input !== void 0 ? { input: b.input } : {},
|
|
9122
|
+
...typeof b.id === "string" ? { toolUseId: b.id } : {}
|
|
9123
|
+
};
|
|
9124
|
+
const file = extractFile(b.input);
|
|
9125
|
+
if (file) call.file = file;
|
|
9126
|
+
if (typeof b.id === "string") {
|
|
9127
|
+
if (!open.toolCalls.has(b.id)) {
|
|
9128
|
+
open.toolCalls.set(b.id, call);
|
|
9129
|
+
open.toolOrder.push(b.id);
|
|
9130
|
+
}
|
|
9131
|
+
} else {
|
|
9132
|
+
(open.anonCalls ??= []).push(call);
|
|
9133
|
+
}
|
|
9134
|
+
break;
|
|
9135
|
+
}
|
|
9136
|
+
}
|
|
9137
|
+
}
|
|
9138
|
+
}
|
|
9139
|
+
function finalizeAssistant(open, index, toolCallsById, models, unknownModels) {
|
|
9140
|
+
const toolCalls = [];
|
|
9141
|
+
for (const id of open.toolOrder) {
|
|
9142
|
+
const call = open.toolCalls.get(id);
|
|
9143
|
+
toolCalls.push(call);
|
|
9144
|
+
toolCallsById.set(id, { call, startMs: open.ts ? Date.parse(open.ts) : void 0 });
|
|
9145
|
+
}
|
|
9146
|
+
if (open.anonCalls) toolCalls.push(...open.anonCalls);
|
|
9147
|
+
const turn = {
|
|
9148
|
+
index,
|
|
9149
|
+
role: "assistant",
|
|
9150
|
+
toolCalls,
|
|
9151
|
+
messageId: open.messageId,
|
|
9152
|
+
...open.ts ? { ts: open.ts } : {}
|
|
9153
|
+
};
|
|
9154
|
+
if (open.model) {
|
|
9155
|
+
turn.model = open.model;
|
|
9156
|
+
models.add(open.model);
|
|
9157
|
+
}
|
|
9158
|
+
if (open.usage) {
|
|
9159
|
+
turn.usage = open.usage;
|
|
9160
|
+
if (open.model) {
|
|
9161
|
+
const cost = costOfUsage(open.model, open.usage);
|
|
9162
|
+
turn.costUsd = cost;
|
|
9163
|
+
if (cost === null) unknownModels.add(open.model);
|
|
9164
|
+
} else {
|
|
9165
|
+
turn.costUsd = null;
|
|
9166
|
+
}
|
|
9167
|
+
}
|
|
9168
|
+
const text = open.texts.join("\n").trim();
|
|
9169
|
+
if (text) turn.text = text.slice(0, TEXT_CAP);
|
|
9170
|
+
const thinking = open.thinkings.join("\n").trim();
|
|
9171
|
+
if (thinking) turn.thinking = thinking.slice(0, TEXT_CAP);
|
|
9172
|
+
return turn;
|
|
9173
|
+
}
|
|
9174
|
+
function buildUserTurn(line, index, tsIso, toolCallsById, blobs, shas, hash) {
|
|
9175
|
+
const content = line.message?.content;
|
|
9176
|
+
let text = null;
|
|
9177
|
+
const images = [];
|
|
9178
|
+
if (typeof content === "string") {
|
|
9179
|
+
text = content.slice(0, TEXT_CAP);
|
|
9180
|
+
} else if (Array.isArray(content)) {
|
|
9181
|
+
const textParts = [];
|
|
9182
|
+
for (const block of content) {
|
|
9183
|
+
if (!block || typeof block !== "object") continue;
|
|
9184
|
+
const b = block;
|
|
9185
|
+
if (b.type === "text" && typeof b.text === "string") textParts.push(b.text);
|
|
9186
|
+
else if (b.type === "image") {
|
|
9187
|
+
const ref = extractImage(b, blobs, hash);
|
|
9188
|
+
if (ref) images.push(ref);
|
|
9189
|
+
} else if (b.type === "tool_result") resolveToolResult(b, line.toolUseResult, tsIso, toolCallsById, blobs, images, shas, hash);
|
|
9190
|
+
}
|
|
9191
|
+
if (textParts.length > 0) text = textParts.join("\n").slice(0, TEXT_CAP);
|
|
9192
|
+
}
|
|
9193
|
+
const turn = { index, role: "user", toolCalls: [], ...tsIso ? { ts: tsIso } : {} };
|
|
9194
|
+
if (text !== null && text.trim().length > 0) turn.text = text;
|
|
9195
|
+
if (images.length > 0) {
|
|
9196
|
+
const seen = /* @__PURE__ */ new Set();
|
|
9197
|
+
turn.images = images.filter((i) => seen.has(i.sha256) ? false : (seen.add(i.sha256), true));
|
|
9198
|
+
}
|
|
9199
|
+
if (turn.text === void 0 && turn.images === void 0) return null;
|
|
9200
|
+
turn.source = classifyUserSource(line, text ?? "");
|
|
9201
|
+
return turn;
|
|
9202
|
+
}
|
|
9203
|
+
function resolveToolResult(block, toolUseResult, tsIso, toolCallsById, blobs, images, shas, hash) {
|
|
9204
|
+
const id = typeof block.tool_use_id === "string" ? block.tool_use_id : void 0;
|
|
9205
|
+
if (!id) return;
|
|
9206
|
+
const entry = toolCallsById.get(id);
|
|
9207
|
+
if (!entry) return;
|
|
9208
|
+
const { call, startMs } = entry;
|
|
9209
|
+
const bodyText = stringifyResultBody(block.content);
|
|
9210
|
+
const isError = block.is_error === true;
|
|
9211
|
+
const rejected = REJECTION_MARKERS.some((m) => bodyText.includes(m));
|
|
9212
|
+
call.status = rejected ? "rejected" : isError ? "error" : "ok";
|
|
9213
|
+
if (call.status === "error" && bodyText) {
|
|
9214
|
+
call.errorSignature = normalizeErrorSignature(bodyText);
|
|
9215
|
+
}
|
|
9216
|
+
if (call.status === "ok" && call.name === "Bash" && isGitCommitCommand(call.input?.command)) {
|
|
9217
|
+
for (const sha of extractCommitShas(bodyText)) {
|
|
9218
|
+
if (shas.seen.has(sha)) continue;
|
|
9219
|
+
shas.seen.add(sha);
|
|
9220
|
+
shas.all.push(sha);
|
|
9221
|
+
shas.pending.push(sha);
|
|
9222
|
+
}
|
|
9223
|
+
}
|
|
9224
|
+
const output = extractInlineImages(toolUseResult ?? block.content, blobs, images, hash);
|
|
9225
|
+
if (output !== void 0) call.output = output;
|
|
9226
|
+
if (tsIso && startMs !== void 0) {
|
|
9227
|
+
const dur = Date.parse(tsIso) - startMs;
|
|
9228
|
+
if (dur >= 0) call.durationMs = dur;
|
|
9229
|
+
}
|
|
9230
|
+
}
|
|
9231
|
+
function handleSystem(line, tsIso, events, nextSeq, addWallClock) {
|
|
9232
|
+
switch (line.subtype) {
|
|
9233
|
+
case "compact_boundary":
|
|
9234
|
+
events.push({ type: EVENT_TYPES.compaction, seq: nextSeq(), ...tsIso ? { ts: tsIso } : {} });
|
|
9235
|
+
break;
|
|
9236
|
+
case "turn_duration":
|
|
9237
|
+
if (typeof line.durationMs === "number") addWallClock(line.durationMs);
|
|
9238
|
+
break;
|
|
9239
|
+
case "stop_hook_summary": {
|
|
9240
|
+
const data = {};
|
|
9241
|
+
if (typeof line.hookCount === "number") data.hookCount = line.hookCount;
|
|
9242
|
+
if (Array.isArray(line.hookInfos) && line.hookInfos.length > 0) {
|
|
9243
|
+
data.hooks = line.hookInfos.slice(0, HOOK_INFOS_CAP).map((h) => ({
|
|
9244
|
+
...typeof h.command === "string" ? { command: h.command.slice(0, HOOK_COMMAND_CAP) } : {},
|
|
9245
|
+
...isValidHookDurationMs(h.durationMs) ? { durationMs: h.durationMs } : {}
|
|
9246
|
+
}));
|
|
9247
|
+
}
|
|
9248
|
+
let errorText;
|
|
9249
|
+
if (Array.isArray(line.hookErrors) && line.hookErrors.length > 0) {
|
|
9250
|
+
data.errorCount = line.hookErrors.length;
|
|
9251
|
+
errorText = line.hookErrors.slice(0, HOOK_ERRORS_CAP).map((e) => (typeof e === "string" ? e : JSON.stringify(e)).slice(0, HOOK_ERROR_TEXT_CAP));
|
|
9252
|
+
}
|
|
9253
|
+
if (typeof line.toolUseID === "string") data.toolUseId = line.toolUseID;
|
|
9254
|
+
events.push({
|
|
9255
|
+
type: EVENT_TYPES.hookExecuted,
|
|
9256
|
+
seq: nextSeq(),
|
|
9257
|
+
...tsIso ? { ts: tsIso } : {},
|
|
9258
|
+
...Object.keys(data).length > 0 ? { data } : {},
|
|
9259
|
+
...errorText ? { errorText } : {}
|
|
9260
|
+
});
|
|
9261
|
+
break;
|
|
9262
|
+
}
|
|
9263
|
+
case "api_error": {
|
|
9264
|
+
const code = typeof line.error === "object" && line.error ? line.error.code : void 0;
|
|
9265
|
+
events.push({ type: EVENT_TYPES.apiError, seq: nextSeq(), ...tsIso ? { ts: tsIso } : {}, ...code ? { data: { code } } : {} });
|
|
9266
|
+
break;
|
|
9267
|
+
}
|
|
9268
|
+
case "local_command":
|
|
9269
|
+
events.push({ type: EVENT_TYPES.localCommand, seq: nextSeq(), ...tsIso ? { ts: tsIso } : {} });
|
|
9270
|
+
break;
|
|
9271
|
+
}
|
|
9272
|
+
}
|
|
9273
|
+
var API_ERROR_CODES = [
|
|
9274
|
+
[/\b429\b|rate.?limit/i, "rate_limit"],
|
|
9275
|
+
[/\b529\b|overloaded/i, "overloaded"],
|
|
9276
|
+
[/timed?.?out|timeout/i, "timeout"],
|
|
9277
|
+
[/connection (?:closed|error|reset)|network error/i, "connection_closed"],
|
|
9278
|
+
[/unavailable/i, "model_unavailable"],
|
|
9279
|
+
[/\b5\d\d\b|internal server error/i, "server_error"]
|
|
9280
|
+
];
|
|
9281
|
+
function apiErrorCode(content) {
|
|
9282
|
+
let text = "";
|
|
9283
|
+
if (typeof content === "string") {
|
|
9284
|
+
text = content;
|
|
9285
|
+
} else if (Array.isArray(content)) {
|
|
9286
|
+
for (const block of content) {
|
|
9287
|
+
const b = block;
|
|
9288
|
+
if (b && typeof b === "object" && typeof b.text === "string") text += ` ${b.text}`;
|
|
9289
|
+
}
|
|
9290
|
+
}
|
|
9291
|
+
for (const [pattern, code] of API_ERROR_CODES) if (pattern.test(text)) return code;
|
|
9292
|
+
return "unknown";
|
|
9293
|
+
}
|
|
9294
|
+
function readUsage(raw) {
|
|
9295
|
+
if (!raw || typeof raw !== "object") return void 0;
|
|
9296
|
+
const r = raw;
|
|
9297
|
+
const usage = {
|
|
9298
|
+
in: num(r.input_tokens),
|
|
9299
|
+
out: num(r.output_tokens),
|
|
9300
|
+
cacheRead: num(r.cache_read_input_tokens),
|
|
9301
|
+
cacheCreate: num(r.cache_creation_input_tokens)
|
|
9302
|
+
};
|
|
9303
|
+
if (usage.in === 0 && usage.out === 0 && usage.cacheRead === 0 && usage.cacheCreate === 0) {
|
|
9304
|
+
return void 0;
|
|
9305
|
+
}
|
|
9306
|
+
const split = r.cache_creation;
|
|
9307
|
+
if (split && typeof split === "object") {
|
|
9308
|
+
const oneHour = num(split.ephemeral_1h_input_tokens);
|
|
9309
|
+
if (oneHour > 0) usage.cacheCreate1h = Math.min(oneHour, usage.cacheCreate);
|
|
9310
|
+
}
|
|
9311
|
+
usage.cacheCreate5m = usage.cacheCreate - (usage.cacheCreate1h ?? 0);
|
|
9312
|
+
if (typeof r.speed === "string" && r.speed) usage.speed = r.speed.slice(0, SPEED_MAX_LENGTH);
|
|
9313
|
+
return usage;
|
|
9314
|
+
}
|
|
9315
|
+
function extractFile(input) {
|
|
9316
|
+
if (!input || typeof input !== "object") return void 0;
|
|
9317
|
+
const r = input;
|
|
9318
|
+
for (const key of ["file_path", "notebook_path", "path", "filePath"]) {
|
|
9319
|
+
if (typeof r[key] === "string") return r[key];
|
|
9320
|
+
}
|
|
9321
|
+
return void 0;
|
|
9322
|
+
}
|
|
9323
|
+
function stringifyResultBody(content) {
|
|
9324
|
+
if (typeof content === "string") return content;
|
|
9325
|
+
if (Array.isArray(content)) {
|
|
9326
|
+
return content.map((c) => c && typeof c === "object" && typeof c.text === "string" ? c.text : "").join(" ");
|
|
9327
|
+
}
|
|
9328
|
+
return "";
|
|
9329
|
+
}
|
|
9330
|
+
function normalizeErrorSignature(text) {
|
|
9331
|
+
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);
|
|
9332
|
+
}
|
|
9333
|
+
function extractCommitShas(text) {
|
|
9334
|
+
const out = [];
|
|
9335
|
+
const re = /^\[[^\n\]]+ ([0-9a-f]{7,40})\]/gm;
|
|
9336
|
+
let m;
|
|
9337
|
+
while ((m = re.exec(text)) !== null) out.push(m[1]);
|
|
9338
|
+
return out;
|
|
9339
|
+
}
|
|
9340
|
+
function isGitCommitCommand(command) {
|
|
9341
|
+
return typeof command === "string" && command.includes("git commit");
|
|
9342
|
+
}
|
|
9343
|
+
function num(v) {
|
|
9344
|
+
return typeof v === "number" && Number.isFinite(v) ? v : 0;
|
|
9345
|
+
}
|
|
9346
|
+
function round(n) {
|
|
9347
|
+
return Math.round(n * 1e6) / 1e6;
|
|
9348
|
+
}
|
|
9349
|
+
function countUnmapped(map, type) {
|
|
9350
|
+
map.set(type, (map.get(type) ?? 0) + 1);
|
|
9351
|
+
}
|
|
9352
|
+
function decodeXmlEntities(value) {
|
|
9353
|
+
return value.replace(/&(apos|quot|amp|lt|gt);/g, (_, name) => {
|
|
9354
|
+
switch (name) {
|
|
9355
|
+
case "apos":
|
|
9356
|
+
return "'";
|
|
9357
|
+
case "quot":
|
|
9358
|
+
return '"';
|
|
9359
|
+
case "lt":
|
|
9360
|
+
return "<";
|
|
9361
|
+
case "gt":
|
|
9362
|
+
return ">";
|
|
9363
|
+
default:
|
|
9364
|
+
return "&";
|
|
9365
|
+
}
|
|
9366
|
+
});
|
|
9367
|
+
}
|
|
9368
|
+
|
|
9369
|
+
// ../agents/src/claude-code/capture/subagent-rollup.ts
|
|
9370
|
+
var PR_URL_PATH = /^(?:https?:\/\/)?(?:www\.)?github\.com\/([A-Za-z0-9._-]+\/[A-Za-z0-9._-]+)\/pull\/\d+(?:\/.*)?$/i;
|
|
9371
|
+
function repoKeyFromPrUrl(url) {
|
|
9372
|
+
if (!url) return null;
|
|
9373
|
+
const match = PR_URL_PATH.exec(url.trim());
|
|
9374
|
+
return match ? match[1].replace(/\.git$/i, "").toLowerCase() : null;
|
|
9375
|
+
}
|
|
9376
|
+
function prLinkKey(link) {
|
|
9377
|
+
return `${repoKeyFromPrUrl(link.prUrl) ?? ""}#${link.prNumber}`;
|
|
9378
|
+
}
|
|
9379
|
+
var SUBAGENT_SHA_CACHE_MAX = 4096;
|
|
9380
|
+
function subagentOutcome(io, cache, file, mtimeMs, bytes) {
|
|
9381
|
+
const hit = cache.get(file);
|
|
9382
|
+
if (hit && hit.mtimeMs === mtimeMs && hit.bytes === bytes) return hit;
|
|
9383
|
+
let content;
|
|
9384
|
+
try {
|
|
9385
|
+
content = io.fs.readRawText(file);
|
|
9386
|
+
} catch {
|
|
9387
|
+
return { shas: [], prs: [] };
|
|
9388
|
+
}
|
|
9389
|
+
if (content === void 0) return { shas: [], prs: [] };
|
|
9390
|
+
const { session } = parseTranscript(
|
|
9391
|
+
content,
|
|
9392
|
+
{
|
|
9393
|
+
fallbackId: sessionIdFromPath(file),
|
|
9394
|
+
isSubagent: true,
|
|
9395
|
+
ownId: sessionIdFromPath(file)
|
|
9396
|
+
},
|
|
9397
|
+
io.sha256
|
|
9398
|
+
);
|
|
9399
|
+
const shas = session?.outcome?.commitShas ?? [];
|
|
9400
|
+
const prs = session?.outcome?.prs ?? [];
|
|
9401
|
+
const entry = { mtimeMs, bytes, shas, prs };
|
|
9402
|
+
if (cache.size >= SUBAGENT_SHA_CACHE_MAX) cache.clear();
|
|
9403
|
+
cache.set(file, entry);
|
|
9404
|
+
return entry;
|
|
9405
|
+
}
|
|
9406
|
+
function defaultTwinMainFile(io, mainFile) {
|
|
9407
|
+
const pairs = [
|
|
9408
|
+
[defaultProjectsDir(io), defaultRawDir(io)],
|
|
9409
|
+
[defaultRawDir(io), defaultProjectsDir(io)]
|
|
9410
|
+
];
|
|
9411
|
+
for (const [from, to] of pairs) {
|
|
9412
|
+
if (mainFile.startsWith(from + io.path.sep)) return io.path.join(to, mainFile.slice(from.length + 1));
|
|
9413
|
+
}
|
|
9414
|
+
return null;
|
|
9415
|
+
}
|
|
9416
|
+
function createSubagentRollup(io) {
|
|
9417
|
+
const cache = /* @__PURE__ */ new Map();
|
|
9418
|
+
function rollUpSubagentCommitShas(mainFiles) {
|
|
9419
|
+
return rollUpSubagentOutcomes(mainFiles).shas;
|
|
9420
|
+
}
|
|
9421
|
+
function rollUpSubagentOutcomes(mainFiles) {
|
|
9422
|
+
const shas = [];
|
|
9423
|
+
const seenShas = /* @__PURE__ */ new Set();
|
|
9424
|
+
const prs = [];
|
|
9425
|
+
const prsByKey = /* @__PURE__ */ new Map();
|
|
9426
|
+
for (const mainFile of new Set(mainFiles)) {
|
|
9427
|
+
const subagentsRoot = io.path.join(mainFile.replace(/\.jsonl$/, ""), "subagents");
|
|
9428
|
+
for (const entry of findTranscripts(io, subagentsRoot)) {
|
|
9429
|
+
const outcome = subagentOutcome(io, cache, entry.file, entry.mtimeMs, entry.bytes);
|
|
9430
|
+
for (const sha of outcome.shas) {
|
|
9431
|
+
if (seenShas.has(sha)) continue;
|
|
9432
|
+
seenShas.add(sha);
|
|
9433
|
+
shas.push(sha);
|
|
9434
|
+
}
|
|
9435
|
+
for (const link of outcome.prs) {
|
|
9436
|
+
const key = prLinkKey(link);
|
|
9437
|
+
const existing = prsByKey.get(key);
|
|
9438
|
+
if (!existing) {
|
|
9439
|
+
const copy = { ...link };
|
|
9440
|
+
prsByKey.set(key, copy);
|
|
9441
|
+
prs.push(copy);
|
|
9442
|
+
continue;
|
|
9443
|
+
}
|
|
9444
|
+
existing.commitShas = mergeCommitShas(existing.commitShas, link.commitShas ?? []);
|
|
9445
|
+
}
|
|
9446
|
+
}
|
|
9447
|
+
}
|
|
9448
|
+
return { shas, prs };
|
|
9449
|
+
}
|
|
9450
|
+
function applySubagentCommitRollup(session, mainFile, alternateMainFile) {
|
|
9451
|
+
const candidates = [mainFile];
|
|
9452
|
+
if (alternateMainFile) candidates.push(alternateMainFile);
|
|
9453
|
+
const twin = defaultTwinMainFile(io, mainFile);
|
|
9454
|
+
if (twin) candidates.push(twin);
|
|
9455
|
+
const { shas: subShas, prs: subPrs } = rollUpSubagentOutcomes(candidates);
|
|
9456
|
+
if (subShas.length === 0 && subPrs.length === 0) return session;
|
|
9457
|
+
const commitShas = mergeCommitShas(session.outcome?.commitShas, subShas);
|
|
9458
|
+
const prs = mergePrLinks(session.outcome?.prs, subPrs);
|
|
9459
|
+
const outcome = { ...session.outcome, ...commitShas ? { commitShas } : {}, ...prs ? { prs } : {} };
|
|
9460
|
+
if (outcome.prNumber === void 0 && prs && prs.length > 0) {
|
|
9461
|
+
const last = prs[prs.length - 1];
|
|
9462
|
+
outcome.prNumber = last.prNumber;
|
|
9463
|
+
if (last.prUrl !== void 0) outcome.prUrl = last.prUrl;
|
|
9464
|
+
}
|
|
9465
|
+
return { ...session, outcome };
|
|
9466
|
+
}
|
|
9467
|
+
return { rollUpSubagentCommitShas, applySubagentCommitRollup };
|
|
9468
|
+
}
|
|
9469
|
+
function mergePrLinks(parentPrs, subagentPrs) {
|
|
9470
|
+
if (subagentPrs.length === 0) return parentPrs;
|
|
9471
|
+
const byKey = /* @__PURE__ */ new Map();
|
|
9472
|
+
for (const link of parentPrs ?? []) byKey.set(prLinkKey(link), { ...link });
|
|
9473
|
+
const order = [...(parentPrs ?? []).map((l) => prLinkKey(l))];
|
|
9474
|
+
for (const link of subagentPrs) {
|
|
9475
|
+
const key = prLinkKey(link);
|
|
9476
|
+
const existing = byKey.get(key);
|
|
9477
|
+
if (!existing) {
|
|
9478
|
+
byKey.set(key, { ...link });
|
|
9479
|
+
order.push(key);
|
|
9480
|
+
continue;
|
|
9481
|
+
}
|
|
9482
|
+
existing.commitShas = mergeCommitShas(existing.commitShas, link.commitShas ?? []);
|
|
9483
|
+
}
|
|
9484
|
+
return order.map((k) => byKey.get(k));
|
|
9485
|
+
}
|
|
9486
|
+
function mergeCommitShas(parentShas, subagentShas) {
|
|
9487
|
+
if (subagentShas.length === 0) return parentShas;
|
|
9488
|
+
const seen = new Set(parentShas ?? []);
|
|
9489
|
+
const merged = [...parentShas ?? []];
|
|
9490
|
+
for (const sha of subagentShas) {
|
|
9491
|
+
if (seen.has(sha)) continue;
|
|
9492
|
+
seen.add(sha);
|
|
9493
|
+
merged.push(sha);
|
|
9494
|
+
}
|
|
9495
|
+
return merged;
|
|
9496
|
+
}
|
|
9497
|
+
|
|
9498
|
+
// ../agents/src/claude-code/capture/index.ts
|
|
9499
|
+
function forkOptions(record, entry) {
|
|
9500
|
+
const fork = forkFor(record, { sessionId: sessionIdFromPath(entry.file), parentSessionId: entry.parentSessionId });
|
|
9501
|
+
return fork === void 0 ? {} : { fork };
|
|
9502
|
+
}
|
|
9503
|
+
function createClaudeCodeCapture(io) {
|
|
9504
|
+
const rollup = createSubagentRollup(io);
|
|
9505
|
+
const parseText = (text, options) => parseTranscript(text, { agentType: CLAUDE_CODE.id, ...options }, io.sha256);
|
|
9506
|
+
return {
|
|
9507
|
+
discover(roots) {
|
|
9508
|
+
const liveRoot = roots.root ?? defaultProjectsDir(io);
|
|
9509
|
+
const rawRoot = roots.rawRoot === "" ? void 0 : roots.rawRoot ?? defaultRawDir(io);
|
|
9510
|
+
const keyOf = (entry, root) => entry.isSubagent ? `subagent:${io.path.relative(root, entry.file)}` : sessionIdFromPath(entry.file);
|
|
9511
|
+
const byId = /* @__PURE__ */ new Map();
|
|
9512
|
+
for (const entry of findTranscripts(io, liveRoot)) {
|
|
9513
|
+
const key = keyOf(entry, liveRoot);
|
|
9514
|
+
if (!byId.has(key)) byId.set(key, entry);
|
|
9515
|
+
}
|
|
9516
|
+
for (const entry of rawRoot === void 0 ? [] : findTranscripts(io, rawRoot)) {
|
|
9517
|
+
const key = keyOf(entry, rawRoot);
|
|
9518
|
+
const existing = byId.get(key);
|
|
9519
|
+
if (!existing) byId.set(key, { ...entry, fromRawOnly: true });
|
|
9520
|
+
else if (!existing.isSubagent && existing.altFile === void 0) byId.set(key, { ...existing, altFile: entry.file });
|
|
9521
|
+
}
|
|
9522
|
+
return [...byId.values()];
|
|
9523
|
+
},
|
|
9524
|
+
parse(entry, opts) {
|
|
9525
|
+
const text = io.fs.readRawText(entry.file);
|
|
9526
|
+
if (text === void 0) throw new Error(`cannot read the transcript ${entry.file}`);
|
|
9527
|
+
const result = parseText(text, {
|
|
9528
|
+
fallbackId: sessionIdFromPath(entry.file),
|
|
9529
|
+
isSubagent: entry.isSubagent,
|
|
9530
|
+
...entry.parentSessionId ? { parentSessionId: entry.parentSessionId } : {},
|
|
9531
|
+
...entry.ownId ? { ownId: entry.ownId } : {},
|
|
9532
|
+
...entry.workflowRunId ? { workflowRunId: entry.workflowRunId } : {},
|
|
9533
|
+
...entry.metaDescription ? { spawnDescription: entry.metaDescription } : {},
|
|
9534
|
+
...entry.metaName ? { spawnName: entry.metaName } : {},
|
|
9535
|
+
...entry.metaAgentType ? { spawnAgentType: entry.metaAgentType } : {},
|
|
9536
|
+
...opts.captureTier ? { captureTier: opts.captureTier } : {},
|
|
9537
|
+
...forkOptions(opts.fork, entry)
|
|
9538
|
+
});
|
|
9539
|
+
if (!entry.isSubagent && result.session) {
|
|
9540
|
+
result.session = rollup.applySubagentCommitRollup(result.session, entry.file, entry.altFile);
|
|
9541
|
+
}
|
|
9542
|
+
return result;
|
|
9543
|
+
},
|
|
9544
|
+
parseText,
|
|
9545
|
+
tail(file, completeText, options) {
|
|
9546
|
+
const { session } = parseText(completeText, { fallbackId: sessionIdFromPath(file), ...options });
|
|
9547
|
+
return !options.isSubagent && session ? rollup.applySubagentCommitRollup(session, file) : session;
|
|
9548
|
+
},
|
|
9549
|
+
identify(file) {
|
|
9550
|
+
const sessionId = sessionIdFromPath(file);
|
|
9551
|
+
const segments = file.split(/[/\\]/);
|
|
9552
|
+
const at = segments.lastIndexOf("subagents");
|
|
9553
|
+
if (at <= 0) return { sessionId, isSubagent: false };
|
|
9554
|
+
return { sessionId, isSubagent: true, parentSessionId: segments[at - 1] || void 0, ownId: sessionId };
|
|
9555
|
+
}
|
|
9556
|
+
};
|
|
9557
|
+
}
|
|
9558
|
+
|
|
8527
9559
|
// ../agents/src/claude-code/credentials.ts
|
|
8528
9560
|
var { forwarded, kinds, placeholders } = CLAUDE_CODE.credentials;
|
|
8529
9561
|
var FORWARDED = forwarded;
|
|
@@ -9519,6 +10551,7 @@ function createClaudeCodeAdapter(io) {
|
|
|
9519
10551
|
install: CLAUDE_CODE_HOOK_INSTALL
|
|
9520
10552
|
},
|
|
9521
10553
|
deliver: { kind: "hook-reply", cap: CLAUDE_CODE.hooks.contextCap, format: CLAUDE_CODE_HOOKS.reply },
|
|
10554
|
+
capture: createClaudeCodeCapture(io),
|
|
9522
10555
|
credentials: createClaudeCodeCredentials(),
|
|
9523
10556
|
image: createClaudeCodeImage(),
|
|
9524
10557
|
diagnostics: createDiagnostics(io, context)
|
|
@@ -9534,6 +10567,17 @@ var ADAPTER_FACTORIES = {
|
|
|
9534
10567
|
var TREE_ROOT = "/work/control-plane";
|
|
9535
10568
|
var PATHS = [".outerlayer/AGENTS.md", ".outerlayer/skills/build/SKILL.md", ".outerlayer/commands/ship.md", ".outerlayer/mcp.json"];
|
|
9536
10569
|
({
|
|
10570
|
+
capture: {
|
|
10571
|
+
text: `${JSON.stringify({
|
|
10572
|
+
sessionId: "session-1",
|
|
10573
|
+
type: "assistant",
|
|
10574
|
+
version: "2.1.193",
|
|
10575
|
+
cwd: "/work",
|
|
10576
|
+
timestamp: "2026-07-01T10:00:00.000Z",
|
|
10577
|
+
message: { role: "assistant", model: "claude-opus-4-8", content: [{ type: "text", text: "done" }], usage: { input_tokens: 1, output_tokens: 1 } }
|
|
10578
|
+
})}
|
|
10579
|
+
`
|
|
10580
|
+
},
|
|
9537
10581
|
hooks: {
|
|
9538
10582
|
payloads: Object.fromEntries(
|
|
9539
10583
|
["SessionStart", "SessionEnd", "Stop", "PostToolUse"].map((name) => [
|
|
@@ -9680,6 +10724,15 @@ function isMaintainedCopy(repoRoot, skill, base = OUTERLAYER_SKILLS_BASE) {
|
|
|
9680
10724
|
function formerNameExists(repoRoot, skill, base) {
|
|
9681
10725
|
return Object.entries(FORMER_MAINTAINED_NAMES).some(([former, current]) => current === skill && isMaintainedCopy(repoRoot, former, base));
|
|
9682
10726
|
}
|
|
10727
|
+
function readBytes(path) {
|
|
10728
|
+
try {
|
|
10729
|
+
return readFileSync(path);
|
|
10730
|
+
} catch (err) {
|
|
10731
|
+
const code = err.code;
|
|
10732
|
+
if (code === "ENOENT" || code === "ENOTDIR") return void 0;
|
|
10733
|
+
throw err;
|
|
10734
|
+
}
|
|
10735
|
+
}
|
|
9683
10736
|
function createNodeAgentFs() {
|
|
9684
10737
|
return {
|
|
9685
10738
|
kind(path) {
|
|
@@ -9710,16 +10763,10 @@ function createNodeAgentFs() {
|
|
|
9710
10763
|
}
|
|
9711
10764
|
},
|
|
9712
10765
|
readText(path) {
|
|
9713
|
-
|
|
9714
|
-
|
|
9715
|
-
content = readFileSync(path);
|
|
9716
|
-
} catch (err) {
|
|
9717
|
-
const code = err.code;
|
|
9718
|
-
if (code === "ENOENT" || code === "ENOTDIR") return void 0;
|
|
9719
|
-
throw err;
|
|
9720
|
-
}
|
|
9721
|
-
return content.includes(0) ? void 0 : content.toString("utf8");
|
|
10766
|
+
const content = readBytes(path);
|
|
10767
|
+
return content === void 0 || content.includes(0) ? void 0 : content.toString("utf8");
|
|
9722
10768
|
},
|
|
10769
|
+
readRawText: (path) => readBytes(path)?.toString("utf8"),
|
|
9723
10770
|
write: (path, text) => writeFileSync(path, text),
|
|
9724
10771
|
copy: (from, to) => copyFileSync(from, to),
|
|
9725
10772
|
makeDir: (path) => void mkdirSync(path, { recursive: true }),
|
|
@@ -9734,6 +10781,8 @@ function createNodeAgentFs() {
|
|
|
9734
10781
|
function createNodeAgentIO() {
|
|
9735
10782
|
return {
|
|
9736
10783
|
fs: createNodeAgentFs(),
|
|
10784
|
+
path: { join: join$1, relative, dirname: dirname, basename, sep },
|
|
10785
|
+
sha256: (bytes) => createHash("sha256").update(bytes).digest("hex"),
|
|
9737
10786
|
async run(program, args, options) {
|
|
9738
10787
|
const { execFile } = await import('child_process');
|
|
9739
10788
|
return new Promise((resolve) => {
|
|
@@ -9780,12 +10829,21 @@ function legacyAgent(agents = defaultAgents()) {
|
|
|
9780
10829
|
function contextAgents(agents = defaultAgents()) {
|
|
9781
10830
|
return agents.flatMap((agent) => agent.adapter.context === void 0 ? [] : [{ descriptor: agent.descriptor, context: agent.adapter.context }]);
|
|
9782
10831
|
}
|
|
10832
|
+
function captureAgents(agents = defaultAgents()) {
|
|
10833
|
+
return agents.flatMap((agent) => agent.adapter.capture === void 0 ? [] : [{ descriptor: agent.descriptor, capture: agent.adapter.capture }]);
|
|
10834
|
+
}
|
|
10835
|
+
function captureAdapters(agents = defaultAgents()) {
|
|
10836
|
+
return captureAgents(agents).map((agent) => ({ id: agent.descriptor.id, discover: agent.capture.discover, parse: agent.capture.parse }));
|
|
10837
|
+
}
|
|
9783
10838
|
function legacySubcommand(agents = defaultAgents()) {
|
|
9784
10839
|
return legacyAgent(agents).descriptor.legacy?.subcommand ?? LEGACY_AGENT;
|
|
9785
10840
|
}
|
|
9786
10841
|
function userSkillFolderIn(home, descriptor) {
|
|
9787
10842
|
return join$1(home, descriptor.context.userSkillFolder.replace(/^~\//, ""));
|
|
9788
10843
|
}
|
|
10844
|
+
function sessionFolderIn(home, descriptor) {
|
|
10845
|
+
return join$1(home, descriptor.capture.sessionFolder.replace(/^~\//, ""));
|
|
10846
|
+
}
|
|
9789
10847
|
function agentRootFolders(agents = defaultAgents()) {
|
|
9790
10848
|
return [...new Set(contextAgents(agents).flatMap((agent) => agent.descriptor.context.repoSkillFolders.map((folder) => folder.split("/")[0])))];
|
|
9791
10849
|
}
|
|
@@ -9799,4 +10857,4 @@ function skillBases(agents = defaultAgents()) {
|
|
|
9799
10857
|
return [AGENTS_SKILLS_BASE, ...contextAgents(agents).flatMap((agent) => agent.descriptor.context.repoSkillFolders)];
|
|
9800
10858
|
}
|
|
9801
10859
|
|
|
9802
|
-
export { ADAPTER_FACTORIES, AGENTS_SKILLS_BASE, CONTEXT_PIN_FILENAME, FORMER_MAINTAINED_NAMES, HookTextError, MACHINE_SKILL_PATH, McpFileError, OUTERLAYER_SKILLS_BASE, TEMPLATE_SKILLS, agentById, agentRootFolders, classifyTree, contextAgents, createNodeAgentIO, defaultAgents, emitBuilders, emitTree, extractFacts, generatedHeaderSource, isMaintainedCopy, legacyAgent, legacySubcommand, loadMachineSkillFiles, loadMaintainedFiles, loadTemplateFiles, maintainedFilesForExistingSkills, namesCore, normalizePath, normalizeRepoName, orderSessions, parseOuterlayerConfig, parsePolicy, parseProofsConfig, resolvePackRoot, restoreSkillPaths, rewriteSkillPaths, sessionsToTimeline, skillBases, skillDir, splitRawFile, targetIds, userSkillFolderIn, writeMaintainedFiles };
|
|
10860
|
+
export { ADAPTER_FACTORIES, AGENTS_SKILLS_BASE, CONTEXT_PIN_FILENAME, FORMER_MAINTAINED_NAMES, HookTextError, MACHINE_SKILL_PATH, McpFileError, OUTERLAYER_SKILLS_BASE, TEMPLATE_SKILLS, agentById, agentRootFolders, captureAdapters, captureAgents, classifyTree, contextAgents, createNodeAgentIO, defaultAgents, emitBuilders, emitTree, extractFacts, generatedHeaderSource, isMaintainedCopy, legacyAgent, legacySubcommand, loadMachineSkillFiles, loadMaintainedFiles, loadTemplateFiles, maintainedFilesForExistingSkills, namesCore, normalizePath, normalizeRepoName, orderSessions, parseOuterlayerConfig, parsePolicy, parseProofsConfig, resolvePackRoot, restoreSkillPaths, rewriteSkillPaths, sessionFolderIn, sessionsToTimeline, skillBases, skillDir, splitRawFile, targetIds, userSkillFolderIn, writeMaintainedFiles };
|