harnesstap 1.3.2 → 1.6.0
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 -0
- package/dist/apply-FTAIL3X3.js +50 -0
- package/dist/{approve-L7IFSYBO.js → approve-R6AWQB3I.js} +12 -16
- package/dist/{approve-L7IFSYBO.js.map → approve-R6AWQB3I.js.map} +1 -1
- package/dist/{audit-PBJDK7A4.js → audit-2HNKFPSU.js} +26 -39
- package/dist/{audit-PBJDK7A4.js.map → audit-2HNKFPSU.js.map} +1 -1
- package/dist/{auth-OM73RLNS.js → auth-C54KRLNF.js} +17 -21
- package/dist/{auth-OM73RLNS.js.map → auth-C54KRLNF.js.map} +1 -1
- package/dist/bin.js +13 -34
- package/dist/bin.js.map +1 -1
- package/dist/{chunk-R4PTE774.js → chunk-2XDYQXP2.js} +34 -41
- package/dist/chunk-2XDYQXP2.js.map +1 -0
- package/dist/{chunk-G5RWVZZ7.js → chunk-3277RVZT.js} +5 -7
- package/dist/{chunk-G5RWVZZ7.js.map → chunk-3277RVZT.js.map} +1 -1
- package/dist/{chunk-6JMVGKMD.js → chunk-3Q72LZPJ.js} +936 -528
- package/dist/chunk-3Q72LZPJ.js.map +1 -0
- package/dist/{chunk-U472S6IB.js → chunk-42E2MPES.js} +19 -27
- package/dist/chunk-42E2MPES.js.map +1 -0
- package/dist/{chunk-CZ4T75PP.js → chunk-5HACBPK2.js} +622 -252
- package/dist/chunk-5HACBPK2.js.map +1 -0
- package/dist/{chunk-IHW4PCDT.js → chunk-6FXJIKEG.js} +6 -6
- package/dist/{chunk-OPVIX7E4.js → chunk-A3TZT4WT.js} +6 -2
- package/dist/chunk-A3TZT4WT.js.map +1 -0
- package/dist/chunk-BUA7WFI4.js +39327 -0
- package/dist/chunk-BUA7WFI4.js.map +1 -0
- package/dist/{chunk-IAZNF35S.js → chunk-CBSDMRMY.js} +2 -2
- package/dist/{chunk-YVJQ2QDG.js → chunk-CR2TYMKC.js} +65 -55
- package/dist/chunk-CR2TYMKC.js.map +1 -0
- package/dist/{chunk-VQVUJYYY.js → chunk-CWXCZBJR.js} +76 -6
- package/dist/chunk-CWXCZBJR.js.map +1 -0
- package/dist/{chunk-AVZOFMJX.js → chunk-D7R577XZ.js} +381 -138
- package/dist/chunk-D7R577XZ.js.map +1 -0
- package/dist/{chunk-3EGM4IUI.js → chunk-EPXAOEBB.js} +6 -6
- package/dist/{chunk-64R32MG2.js → chunk-GZU4LVFF.js} +179 -26
- package/dist/chunk-GZU4LVFF.js.map +1 -0
- package/dist/chunk-HV3ENT2F.js +61 -0
- package/dist/chunk-HV3ENT2F.js.map +1 -0
- package/dist/{chunk-XCPWLGPB.js → chunk-K4UDZUJ2.js} +2 -2
- package/dist/{chunk-OQ4KBUN2.js → chunk-L6BJCRBU.js} +13 -16
- package/dist/chunk-L6BJCRBU.js.map +1 -0
- package/dist/{chunk-AFKCNFPP.js → chunk-M6FEDSHY.js} +16 -15
- package/dist/chunk-M6FEDSHY.js.map +1 -0
- package/dist/chunk-M7PHQ3UC.js +31491 -0
- package/dist/chunk-M7PHQ3UC.js.map +1 -0
- package/dist/{chunk-FBYAIBHP.js → chunk-MHLAIGIM.js} +2 -2
- package/dist/{chunk-ENHDEB7Z.js → chunk-MHMFF6A5.js} +5 -7
- package/dist/{chunk-ENHDEB7Z.js.map → chunk-MHMFF6A5.js.map} +1 -1
- package/dist/chunk-MKLJBW5N.js +14 -0
- package/dist/{chunk-XRXFJTAT.js → chunk-MQCAPCAF.js} +17 -26
- package/dist/chunk-MQCAPCAF.js.map +1 -0
- package/dist/{chunk-UEHDEADL.js → chunk-MQCH3YZ5.js} +15 -13
- package/dist/chunk-MQCH3YZ5.js.map +1 -0
- package/dist/chunk-OHZNDV4A.js +1707 -0
- package/dist/chunk-OHZNDV4A.js.map +1 -0
- package/dist/{chunk-LGWUTV5Q.js → chunk-OWE3OSX6.js} +11 -13
- package/dist/{chunk-LGWUTV5Q.js.map → chunk-OWE3OSX6.js.map} +1 -1
- package/dist/{chunk-EY4ES5MG.js → chunk-PCNHBMBU.js} +3 -5
- package/dist/{chunk-EY4ES5MG.js.map → chunk-PCNHBMBU.js.map} +1 -1
- package/dist/{chunk-YRGM7RAD.js → chunk-QGTDQNVV.js} +7 -11
- package/dist/{chunk-YRGM7RAD.js.map → chunk-QGTDQNVV.js.map} +1 -1
- package/dist/{chunk-BXSS2S4W.js → chunk-R27VZIF6.js} +2 -2
- package/dist/{chunk-TQ2NA4Z4.js → chunk-R4NV3Q7G.js} +8 -2
- package/dist/chunk-R4NV3Q7G.js.map +1 -0
- package/dist/{chunk-FUV7QYBS.js → chunk-R6VFJKZB.js} +86 -319
- package/dist/chunk-R6VFJKZB.js.map +1 -0
- package/dist/{chunk-QNAIDM6W.js → chunk-RQLVXJH2.js} +132 -4
- package/dist/chunk-RQLVXJH2.js.map +1 -0
- package/dist/{chunk-JQOKQKQT.js → chunk-S2D5PWAO.js} +2 -2
- package/dist/{chunk-JJJJ2RAD.js → chunk-T4EKNX2Q.js} +71 -11
- package/dist/chunk-T4EKNX2Q.js.map +1 -0
- package/dist/{chunk-GWQVYGRD.js → chunk-TERYL7JH.js} +118 -78
- package/dist/chunk-TERYL7JH.js.map +1 -0
- package/dist/chunk-UC27MQ3T.js +1920 -0
- package/dist/chunk-UC27MQ3T.js.map +1 -0
- package/dist/chunk-UEA4NCY2.js +106 -0
- package/dist/chunk-UEA4NCY2.js.map +1 -0
- package/dist/{chunk-WXRPQICX.js → chunk-UK2IV2ZQ.js} +2 -2
- package/dist/{chunk-MFCZN253.js → chunk-UZCAYOIQ.js} +8 -10
- package/dist/{chunk-MFCZN253.js.map → chunk-UZCAYOIQ.js.map} +1 -1
- package/dist/{chunk-IKAGGJEO.js → chunk-V4UNYSZO.js} +558 -18
- package/dist/chunk-V4UNYSZO.js.map +1 -0
- package/dist/chunk-VAPCU2FX.js +70 -0
- package/dist/chunk-VAPCU2FX.js.map +1 -0
- package/dist/{chunk-Y2JGMICO.js → chunk-WGVU3LA5.js} +25 -33
- package/dist/chunk-WGVU3LA5.js.map +1 -0
- package/dist/{chunk-UNRR4KH5.js → chunk-WQ3F4O7U.js} +20 -14
- package/dist/chunk-WQ3F4O7U.js.map +1 -0
- package/dist/chunk-XNS4I3W6.js +102 -0
- package/dist/chunk-XNS4I3W6.js.map +1 -0
- package/dist/{chunk-LDVXYN6F.js → chunk-Y4I7ZCAE.js} +178 -135
- package/dist/chunk-Y4I7ZCAE.js.map +1 -0
- package/dist/{chunk-6I3RY6R5.js → chunk-ZKMSHLXP.js} +11 -15
- package/dist/{chunk-6I3RY6R5.js.map → chunk-ZKMSHLXP.js.map} +1 -1
- package/dist/{compile-SDOASKGL.js → compile-B2QG6BAQ.js} +37 -54
- package/dist/{compile-SDOASKGL.js.map → compile-B2QG6BAQ.js.map} +1 -1
- package/dist/{config-4VZTVZKF.js → config-D3F6ICZ2.js} +21 -39
- package/dist/{config-4VZTVZKF.js.map → config-D3F6ICZ2.js.map} +1 -1
- package/dist/cursor-local-install-4HDIBX22.js +94 -0
- package/dist/cursor-local-install-4HDIBX22.js.map +1 -0
- package/dist/cursor-local-install-LL367GZY.js +94 -0
- package/dist/cursor-local-install-LL367GZY.js.map +1 -0
- package/dist/{doctor-HH6CFBRQ.js → doctor-QSGETVDE.js} +19 -23
- package/dist/doctor-QSGETVDE.js.map +1 -0
- package/dist/{environment-K7YMJJYN.js → environment-2JS4RWQA.js} +69 -88
- package/dist/environment-2JS4RWQA.js.map +1 -0
- package/dist/{github-A6TYG7WS.js → github-JXSTHLY2.js} +14 -15
- package/dist/{github-A6TYG7WS.js.map → github-JXSTHLY2.js.map} +1 -1
- package/dist/{harness-772XBFZQ.js → harness-GBI3AMLH.js} +48 -65
- package/dist/{harness-772XBFZQ.js.map → harness-GBI3AMLH.js.map} +1 -1
- package/dist/{help-QR4VTJZU.js → help-EC52ERIE.js} +43 -52
- package/dist/help-EC52ERIE.js.map +1 -0
- package/dist/{help-TLHNRJJ6.js → help-VIRMBOPJ.js} +73 -551
- package/dist/help-VIRMBOPJ.js.map +1 -0
- package/dist/host-plugin-view-kept-XKHD6NGU.js +139 -0
- package/dist/host-plugin-view-kept-XKHD6NGU.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +10 -22
- package/dist/{init-AOKFPZHG.js → init-OK3K6ILG.js} +49 -70
- package/dist/init-OK3K6ILG.js.map +1 -0
- package/dist/live-read-cache-ESQQJBNS.js +13 -0
- package/dist/live-read-cache-WPUFHVMZ.js +12 -0
- package/dist/{lock-INAXNLMC.js → lock-AA2F4I3K.js} +13 -16
- package/dist/{lock-INAXNLMC.js.map → lock-AA2F4I3K.js.map} +1 -1
- package/dist/{marketplace-TUVLLPBG.js → marketplace-QUYCV23F.js} +75 -94
- package/dist/marketplace-QUYCV23F.js.map +1 -0
- package/dist/{mcp-MMWGRASN.js → mcp-CIHSR4DD.js} +35 -52
- package/dist/{mcp-MMWGRASN.js.map → mcp-CIHSR4DD.js.map} +1 -1
- package/dist/{migrate-55S4XODX.js → migrate-TQPEZYS5.js} +148 -74
- package/dist/migrate-TQPEZYS5.js.map +1 -0
- package/dist/notifications-TAELTPDW.js +154 -0
- package/dist/notifications-TAELTPDW.js.map +1 -0
- package/dist/open-D3GWGDSQ.js +20 -0
- package/dist/{pack-VZIBS42E.js → pack-VUO4UBWL.js} +12 -22
- package/dist/{pack-VZIBS42E.js.map → pack-VUO4UBWL.js.map} +1 -1
- package/dist/plugin-L3466DHK.js +47 -0
- package/dist/plugin-from-project-U5UGKTJH.js +15 -0
- package/dist/plugin-from-project-U5UGKTJH.js.map +1 -0
- package/dist/{policy-P3HGLEZS.js → policy-Z5TL4N3V.js} +11 -15
- package/dist/{policy-P3HGLEZS.js.map → policy-Z5TL4N3V.js.map} +1 -1
- package/dist/{profile-STS3CZUK.js → profile-QFI7SL3S.js} +167 -143
- package/dist/profile-QFI7SL3S.js.map +1 -0
- package/dist/{project-R4DGM3ZG.js → project-3KR3EPYR.js} +506 -94
- package/dist/project-3KR3EPYR.js.map +1 -0
- package/dist/{resource-GJVEDXVZ.js → resource-45BPRQ7V.js} +66 -63
- package/dist/resource-45BPRQ7V.js.map +1 -0
- package/dist/status-refresh-worker.js +1155 -0
- package/dist/status-refresh-worker.js.map +1 -0
- package/dist/{version-FUHV4O6U.js → version-QUJZGTZ5.js} +3 -3
- package/dist/version-QUJZGTZ5.js.map +1 -0
- package/package.json +17 -11
- package/dist/apply-Q5SFF3FY.js +0 -67
- package/dist/chunk-24V5ZSIF.js +0 -658
- package/dist/chunk-24V5ZSIF.js.map +0 -1
- package/dist/chunk-2H7UOFLK.js +0 -11
- package/dist/chunk-3JOPDYQD.js +0 -730
- package/dist/chunk-3JOPDYQD.js.map +0 -1
- package/dist/chunk-555XE3NJ.js +0 -60
- package/dist/chunk-555XE3NJ.js.map +0 -1
- package/dist/chunk-64R32MG2.js.map +0 -1
- package/dist/chunk-6JMVGKMD.js.map +0 -1
- package/dist/chunk-6ZWKF3YZ.js +0 -7795
- package/dist/chunk-6ZWKF3YZ.js.map +0 -1
- package/dist/chunk-AFKCNFPP.js.map +0 -1
- package/dist/chunk-AUWWL6KX.js +0 -296
- package/dist/chunk-AUWWL6KX.js.map +0 -1
- package/dist/chunk-AVZOFMJX.js.map +0 -1
- package/dist/chunk-CZ4T75PP.js.map +0 -1
- package/dist/chunk-FUV7QYBS.js.map +0 -1
- package/dist/chunk-GWQVYGRD.js.map +0 -1
- package/dist/chunk-HENOKIBB.js +0 -346
- package/dist/chunk-HENOKIBB.js.map +0 -1
- package/dist/chunk-HWL67OCJ.js +0 -238
- package/dist/chunk-HWL67OCJ.js.map +0 -1
- package/dist/chunk-IKAGGJEO.js.map +0 -1
- package/dist/chunk-JJJJ2RAD.js.map +0 -1
- package/dist/chunk-JRFUTIEH.js +0 -426
- package/dist/chunk-JRFUTIEH.js.map +0 -1
- package/dist/chunk-KJIFZLHN.js +0 -11066
- package/dist/chunk-KJIFZLHN.js.map +0 -1
- package/dist/chunk-LDVXYN6F.js.map +0 -1
- package/dist/chunk-MHOTXMD2.js +0 -430
- package/dist/chunk-MHOTXMD2.js.map +0 -1
- package/dist/chunk-NAGAJ5UM.js +0 -145
- package/dist/chunk-NAGAJ5UM.js.map +0 -1
- package/dist/chunk-NEPUP33Q.js +0 -35
- package/dist/chunk-NEPUP33Q.js.map +0 -1
- package/dist/chunk-OPVIX7E4.js.map +0 -1
- package/dist/chunk-OQ4KBUN2.js.map +0 -1
- package/dist/chunk-OXVCYRZB.js +0 -491
- package/dist/chunk-OXVCYRZB.js.map +0 -1
- package/dist/chunk-PJQAMC6L.js +0 -183
- package/dist/chunk-PJQAMC6L.js.map +0 -1
- package/dist/chunk-PW5QXRBA.js +0 -1173
- package/dist/chunk-PW5QXRBA.js.map +0 -1
- package/dist/chunk-QNAIDM6W.js.map +0 -1
- package/dist/chunk-R4PTE774.js.map +0 -1
- package/dist/chunk-S2E4KSYW.js +0 -610
- package/dist/chunk-S2E4KSYW.js.map +0 -1
- package/dist/chunk-SNVAMWB7.js +0 -40
- package/dist/chunk-SNVAMWB7.js.map +0 -1
- package/dist/chunk-TQ2NA4Z4.js.map +0 -1
- package/dist/chunk-U472S6IB.js.map +0 -1
- package/dist/chunk-UEHDEADL.js.map +0 -1
- package/dist/chunk-UNRR4KH5.js.map +0 -1
- package/dist/chunk-VQVUJYYY.js.map +0 -1
- package/dist/chunk-XGTTOO4R.js +0 -84
- package/dist/chunk-XGTTOO4R.js.map +0 -1
- package/dist/chunk-XRXFJTAT.js.map +0 -1
- package/dist/chunk-Y2JGMICO.js.map +0 -1
- package/dist/chunk-YVJQ2QDG.js.map +0 -1
- package/dist/chunk-YX7MVSDA.js +0 -235
- package/dist/chunk-YX7MVSDA.js.map +0 -1
- package/dist/chunk-ZGRBIBO7.js +0 -681
- package/dist/chunk-ZGRBIBO7.js.map +0 -1
- package/dist/chunk-ZTBAMBAI.js +0 -6448
- package/dist/chunk-ZTBAMBAI.js.map +0 -1
- package/dist/chunk-ZVANUFPF.js +0 -1035
- package/dist/chunk-ZVANUFPF.js.map +0 -1
- package/dist/doctor-HH6CFBRQ.js.map +0 -1
- package/dist/environment-K7YMJJYN.js.map +0 -1
- package/dist/help-QR4VTJZU.js.map +0 -1
- package/dist/help-TLHNRJJ6.js.map +0 -1
- package/dist/init-AOKFPZHG.js.map +0 -1
- package/dist/marketplace-TUVLLPBG.js.map +0 -1
- package/dist/migrate-55S4XODX.js.map +0 -1
- package/dist/open-SLFQV45J.js +0 -32
- package/dist/plugin-WLEFFBRY.js +0 -64
- package/dist/plugin-from-project-UV2O364T.js +0 -16
- package/dist/profile-STS3CZUK.js.map +0 -1
- package/dist/project-R4DGM3ZG.js.map +0 -1
- package/dist/resource-GJVEDXVZ.js.map +0 -1
- /package/dist/{apply-Q5SFF3FY.js.map → apply-FTAIL3X3.js.map} +0 -0
- /package/dist/{chunk-IHW4PCDT.js.map → chunk-6FXJIKEG.js.map} +0 -0
- /package/dist/{chunk-IAZNF35S.js.map → chunk-CBSDMRMY.js.map} +0 -0
- /package/dist/{chunk-3EGM4IUI.js.map → chunk-EPXAOEBB.js.map} +0 -0
- /package/dist/{chunk-XCPWLGPB.js.map → chunk-K4UDZUJ2.js.map} +0 -0
- /package/dist/{chunk-FBYAIBHP.js.map → chunk-MHLAIGIM.js.map} +0 -0
- /package/dist/{chunk-2H7UOFLK.js.map → chunk-MKLJBW5N.js.map} +0 -0
- /package/dist/{chunk-BXSS2S4W.js.map → chunk-R27VZIF6.js.map} +0 -0
- /package/dist/{chunk-JQOKQKQT.js.map → chunk-S2D5PWAO.js.map} +0 -0
- /package/dist/{chunk-WXRPQICX.js.map → chunk-UK2IV2ZQ.js.map} +0 -0
- /package/dist/{open-SLFQV45J.js.map → live-read-cache-ESQQJBNS.js.map} +0 -0
- /package/dist/{plugin-WLEFFBRY.js.map → live-read-cache-WPUFHVMZ.js.map} +0 -0
- /package/dist/{plugin-from-project-UV2O364T.js.map → open-D3GWGDSQ.js.map} +0 -0
- /package/dist/{version-FUHV4O6U.js.map → plugin-L3466DHK.js.map} +0 -0
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
|
-
parseJsonc
|
|
3
|
-
|
|
2
|
+
parseJsonc,
|
|
3
|
+
resolveTelemetryProduct
|
|
4
|
+
} from "./chunk-CWXCZBJR.js";
|
|
4
5
|
import {
|
|
5
6
|
PACKAGE_VERSION,
|
|
6
7
|
fetchWithTimeout,
|
|
7
8
|
getHarnesstapDir
|
|
8
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-OHZNDV4A.js";
|
|
9
10
|
|
|
10
11
|
// src/config/catalog.ts
|
|
11
12
|
import { existsSync, readFileSync, writeFileSync } from "fs";
|
|
@@ -253,14 +254,14 @@ function loadCatalogSettings(harnesstapDir = getHarnesstapDir()) {
|
|
|
253
254
|
if (!entry || typeof entry !== "object") {
|
|
254
255
|
return void 0;
|
|
255
256
|
}
|
|
256
|
-
const
|
|
257
|
-
if (typeof
|
|
257
|
+
const record2 = entry;
|
|
258
|
+
if (typeof record2.org !== "string" || typeof record2.catalog !== "string") {
|
|
258
259
|
return void 0;
|
|
259
260
|
}
|
|
260
261
|
return normalizeRegisteredCatalog({
|
|
261
|
-
org:
|
|
262
|
-
catalog:
|
|
263
|
-
account: typeof
|
|
262
|
+
org: record2.org,
|
|
263
|
+
catalog: record2.catalog,
|
|
264
|
+
account: typeof record2.account === "string" ? record2.account : void 0
|
|
264
265
|
});
|
|
265
266
|
}).filter((entry) => entry !== void 0)
|
|
266
267
|
) : [];
|
|
@@ -533,6 +534,58 @@ async function removeCloudAccount(accountName) {
|
|
|
533
534
|
await writeStore(store);
|
|
534
535
|
}
|
|
535
536
|
|
|
537
|
+
// src/services/cloud-api-error.ts
|
|
538
|
+
function str(value) {
|
|
539
|
+
return typeof value === "string" && value.length > 0 ? value : void 0;
|
|
540
|
+
}
|
|
541
|
+
function record(value) {
|
|
542
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
|
|
543
|
+
}
|
|
544
|
+
function parseCloudErrorBody(body, headers) {
|
|
545
|
+
const headerId = str(headers?.get("x-request-id") ?? void 0);
|
|
546
|
+
if (!body || typeof body !== "object") return headerId ? { requestId: headerId } : {};
|
|
547
|
+
const top = body;
|
|
548
|
+
const nested = top.error && typeof top.error === "object" ? top.error : {};
|
|
549
|
+
const pick = (key) => str(nested[key]) ?? str(top[key]);
|
|
550
|
+
return {
|
|
551
|
+
code: str(nested.code) ?? str(top.error) ?? str(top.code),
|
|
552
|
+
message: pick("message"),
|
|
553
|
+
requestId: pick("requestId") ?? pick("request_id") ?? headerId,
|
|
554
|
+
entry: pick("entry"),
|
|
555
|
+
ref: pick("ref"),
|
|
556
|
+
...record(nested.fields) ? { fields: record(nested.fields) } : {},
|
|
557
|
+
...nested.details !== void 0 ? { details: nested.details } : {}
|
|
558
|
+
};
|
|
559
|
+
}
|
|
560
|
+
function parseCloudErrorText(text) {
|
|
561
|
+
const start = text.indexOf("{");
|
|
562
|
+
if (start < 0) return {};
|
|
563
|
+
try {
|
|
564
|
+
return parseCloudErrorBody(JSON.parse(text.slice(start)));
|
|
565
|
+
} catch {
|
|
566
|
+
return {};
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
var CloudApiError = class extends Error {
|
|
570
|
+
status;
|
|
571
|
+
detail;
|
|
572
|
+
constructor(prefix, status, body, headers) {
|
|
573
|
+
const detail = parseCloudErrorBody(body, headers);
|
|
574
|
+
const text = detail.message ?? detail.code ?? JSON.stringify(body ?? {});
|
|
575
|
+
super(`${prefix}: ${status} ${text}`);
|
|
576
|
+
this.name = "CloudApiError";
|
|
577
|
+
this.status = status;
|
|
578
|
+
this.detail = detail;
|
|
579
|
+
}
|
|
580
|
+
};
|
|
581
|
+
function cloudErrorDetail(error) {
|
|
582
|
+
if (error instanceof CloudApiError) return error.detail;
|
|
583
|
+
return parseCloudErrorText(error instanceof Error ? error.message : String(error));
|
|
584
|
+
}
|
|
585
|
+
function requestIdSuffix(detail) {
|
|
586
|
+
return detail.requestId ? ` (request ${detail.requestId})` : "";
|
|
587
|
+
}
|
|
588
|
+
|
|
536
589
|
// src/services/cloud-api-version.ts
|
|
537
590
|
var CLI_VERSION_HEADER = "X-HarnessTap-CLI-Version";
|
|
538
591
|
var API_VERSION_HEADER = "X-HarnessTap-API-Version";
|
|
@@ -641,15 +694,21 @@ async function readResponseBody(response) {
|
|
|
641
694
|
return { body: {}, text };
|
|
642
695
|
}
|
|
643
696
|
}
|
|
644
|
-
function
|
|
697
|
+
function apiErrorText(body, text) {
|
|
645
698
|
const parsed = parseApiError(body);
|
|
646
699
|
if (parsed !== "{}") {
|
|
647
|
-
return
|
|
700
|
+
return parsed;
|
|
648
701
|
}
|
|
649
702
|
const trimmed = text.trim();
|
|
650
|
-
if (trimmed) {
|
|
651
|
-
|
|
652
|
-
|
|
703
|
+
if (!trimmed) {
|
|
704
|
+
return void 0;
|
|
705
|
+
}
|
|
706
|
+
return trimmed.length > 240 ? `${trimmed.slice(0, 240)}...` : trimmed;
|
|
707
|
+
}
|
|
708
|
+
function describeApiFailure(response, body, text) {
|
|
709
|
+
const detail = apiErrorText(body, text);
|
|
710
|
+
if (detail) {
|
|
711
|
+
return `${response.status} ${detail}`;
|
|
653
712
|
}
|
|
654
713
|
return `${response.status} empty response (try again)`;
|
|
655
714
|
}
|
|
@@ -747,7 +806,7 @@ async function pollDeviceTokenOnce(baseUrl, deviceCode, opts) {
|
|
|
747
806
|
}
|
|
748
807
|
return {
|
|
749
808
|
status: "error",
|
|
750
|
-
message: `Failed to poll device token: ${describeApiFailure(response, body, text)}`
|
|
809
|
+
message: `Failed to poll device token: ${apiErrorText(body, text) ?? describeApiFailure(response, body, text)}`
|
|
751
810
|
};
|
|
752
811
|
}
|
|
753
812
|
async function pollDeviceToken(baseUrl, deviceCode, opts) {
|
|
@@ -823,7 +882,7 @@ function createCloudClient(opts) {
|
|
|
823
882
|
});
|
|
824
883
|
const body = await response.json().catch(() => ({}));
|
|
825
884
|
if (!response.ok) {
|
|
826
|
-
throw new
|
|
885
|
+
throw new CloudApiError("create plugin failed", response.status, body, response.headers);
|
|
827
886
|
}
|
|
828
887
|
return body.plugin;
|
|
829
888
|
}
|
|
@@ -841,11 +900,31 @@ function createCloudClient(opts) {
|
|
|
841
900
|
});
|
|
842
901
|
const body = await response.json().catch(() => ({}));
|
|
843
902
|
if (!response.ok) {
|
|
844
|
-
throw new
|
|
903
|
+
throw new CloudApiError("publish failed", response.status, body, response.headers);
|
|
845
904
|
}
|
|
846
905
|
return body;
|
|
847
906
|
}
|
|
848
907
|
return {
|
|
908
|
+
async duplicateCatalogPlugin(input) {
|
|
909
|
+
const { org, catalog, slug } = input.source;
|
|
910
|
+
const path = `/catalogs/${encodeURIComponent(org)}/${encodeURIComponent(catalog)}/plugins/${encodeURIComponent(slug)}/duplicate`;
|
|
911
|
+
const response = await authFetch(apiUrl(state.baseUrl, path), {
|
|
912
|
+
method: "POST",
|
|
913
|
+
headers: { "content-type": "application/json" },
|
|
914
|
+
body: JSON.stringify({
|
|
915
|
+
mode: input.mode,
|
|
916
|
+
name: input.name,
|
|
917
|
+
targetOrg: input.targetOrg,
|
|
918
|
+
targetCatalog: input.targetCatalog
|
|
919
|
+
})
|
|
920
|
+
});
|
|
921
|
+
const { body } = await readResponseBody(response);
|
|
922
|
+
if (response.ok) return body;
|
|
923
|
+
if ((response.status === 404 || response.status === 405 || response.status === 501) && !parseCloudErrorBody(body).code) {
|
|
924
|
+
return null;
|
|
925
|
+
}
|
|
926
|
+
throw new CloudApiError("duplicate failed", response.status, body, response.headers);
|
|
927
|
+
},
|
|
849
928
|
async whoami() {
|
|
850
929
|
const response = await authFetch(apiUrl(state.baseUrl, "/me"));
|
|
851
930
|
if (!response.ok) throw new Error(`whoami failed: ${response.status}`);
|
|
@@ -1093,7 +1172,456 @@ async function createPersistingCloudClient(accountName) {
|
|
|
1093
1172
|
return { accountName: ensured.accountName, client };
|
|
1094
1173
|
}
|
|
1095
1174
|
|
|
1175
|
+
// src/telemetry/config.ts
|
|
1176
|
+
import { existsSync as existsSync2, readFileSync as readFileSync2 } from "fs";
|
|
1177
|
+
import { join as join3 } from "path";
|
|
1178
|
+
var DEFAULT_POSTHOG_PROJECT_API_KEY = "phc_qNGtvTMWscMjjt9yVoK2kySDnpCyMSNb4nNkkXabRtYv";
|
|
1179
|
+
var DEFAULT_POSTHOG_HOST = "https://eu.i.posthog.com";
|
|
1180
|
+
var FALSEY = /* @__PURE__ */ new Set(["0", "false", "no", "off"]);
|
|
1181
|
+
var TRUTHY = /* @__PURE__ */ new Set(["1", "true", "yes", "on"]);
|
|
1182
|
+
function telemetryEnvFlag(name = "HARNESSTAP_TELEMETRY") {
|
|
1183
|
+
const raw = process.env[name]?.trim().toLowerCase();
|
|
1184
|
+
if (!raw) {
|
|
1185
|
+
return void 0;
|
|
1186
|
+
}
|
|
1187
|
+
if (FALSEY.has(raw)) {
|
|
1188
|
+
return false;
|
|
1189
|
+
}
|
|
1190
|
+
if (TRUTHY.has(raw)) {
|
|
1191
|
+
return true;
|
|
1192
|
+
}
|
|
1193
|
+
return void 0;
|
|
1194
|
+
}
|
|
1195
|
+
function telemetryConfigPath(harnesstapDir) {
|
|
1196
|
+
const jsoncPath = join3(harnesstapDir, "config.jsonc");
|
|
1197
|
+
const jsonPath = join3(harnesstapDir, "config.json");
|
|
1198
|
+
if (existsSync2(jsoncPath) || !existsSync2(jsonPath)) {
|
|
1199
|
+
return jsoncPath;
|
|
1200
|
+
}
|
|
1201
|
+
return jsonPath;
|
|
1202
|
+
}
|
|
1203
|
+
function readTelemetryConfigPreference(harnesstapDir) {
|
|
1204
|
+
const path = telemetryConfigPath(harnesstapDir);
|
|
1205
|
+
if (!existsSync2(path)) {
|
|
1206
|
+
return void 0;
|
|
1207
|
+
}
|
|
1208
|
+
try {
|
|
1209
|
+
const raw = parseJsonc(readFileSync2(path, "utf-8"));
|
|
1210
|
+
if (typeof raw.telemetry?.enabled === "boolean") {
|
|
1211
|
+
return raw.telemetry.enabled;
|
|
1212
|
+
}
|
|
1213
|
+
return void 0;
|
|
1214
|
+
} catch {
|
|
1215
|
+
return void 0;
|
|
1216
|
+
}
|
|
1217
|
+
}
|
|
1218
|
+
function isTelemetryEnabled(harnesstapDir = getHarnesstapDir()) {
|
|
1219
|
+
const env = telemetryEnvFlag();
|
|
1220
|
+
if (env === false) {
|
|
1221
|
+
return false;
|
|
1222
|
+
}
|
|
1223
|
+
if (env === true) {
|
|
1224
|
+
return Boolean(resolvePosthogProjectApiKey());
|
|
1225
|
+
}
|
|
1226
|
+
const preference = readTelemetryConfigPreference(harnesstapDir);
|
|
1227
|
+
if (preference !== true) {
|
|
1228
|
+
return false;
|
|
1229
|
+
}
|
|
1230
|
+
return Boolean(resolvePosthogProjectApiKey());
|
|
1231
|
+
}
|
|
1232
|
+
function resolvePosthogProjectApiKey() {
|
|
1233
|
+
if (Object.hasOwn(process.env, "HARNESSTAP_POSTHOG_PROJECT_API_KEY")) {
|
|
1234
|
+
const override = process.env.HARNESSTAP_POSTHOG_PROJECT_API_KEY?.trim();
|
|
1235
|
+
return override && override.length > 0 ? override : void 0;
|
|
1236
|
+
}
|
|
1237
|
+
return DEFAULT_POSTHOG_PROJECT_API_KEY;
|
|
1238
|
+
}
|
|
1239
|
+
function resolvePosthogHost() {
|
|
1240
|
+
const override = process.env.HARNESSTAP_POSTHOG_HOST?.trim();
|
|
1241
|
+
if (override) {
|
|
1242
|
+
return override.replace(/\/+$/, "");
|
|
1243
|
+
}
|
|
1244
|
+
return DEFAULT_POSTHOG_HOST;
|
|
1245
|
+
}
|
|
1246
|
+
function resolvePosthogCaptureUrl() {
|
|
1247
|
+
return `${resolvePosthogHost()}/capture/`;
|
|
1248
|
+
}
|
|
1249
|
+
|
|
1250
|
+
// src/telemetry/sanitize.ts
|
|
1251
|
+
var SECRET_KEY = /(token|secret|password|passwd|authorization|cookie|api[_-]?key|refresh|bearer|email)/i;
|
|
1252
|
+
var BLOCKED_KEY = /^(plugin_slug|org_id|path|filepath|file_path|content|contents|mcp|mcp_config)$/i;
|
|
1253
|
+
function looksLikeEmail(value) {
|
|
1254
|
+
return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value);
|
|
1255
|
+
}
|
|
1256
|
+
function shortReason(error) {
|
|
1257
|
+
const raw = error instanceof Error ? error.message : String(error);
|
|
1258
|
+
return raw.replace(/Bearer\s+\S+/gi, "Bearer [redacted]").replace(/\s+/g, " ").trim().slice(0, 80);
|
|
1259
|
+
}
|
|
1260
|
+
function sanitizeTelemetryProps(props) {
|
|
1261
|
+
const next = {};
|
|
1262
|
+
for (const [key, value] of Object.entries(props)) {
|
|
1263
|
+
if (SECRET_KEY.test(key) || BLOCKED_KEY.test(key)) {
|
|
1264
|
+
continue;
|
|
1265
|
+
}
|
|
1266
|
+
if (typeof value === "string") {
|
|
1267
|
+
if (looksLikeEmail(value)) {
|
|
1268
|
+
continue;
|
|
1269
|
+
}
|
|
1270
|
+
next[key] = value.slice(0, 200);
|
|
1271
|
+
continue;
|
|
1272
|
+
}
|
|
1273
|
+
next[key] = value;
|
|
1274
|
+
}
|
|
1275
|
+
return next;
|
|
1276
|
+
}
|
|
1277
|
+
function extractCloudUserId(whoami, accountUserId) {
|
|
1278
|
+
if (accountUserId && !looksLikeEmail(accountUserId)) {
|
|
1279
|
+
return accountUserId;
|
|
1280
|
+
}
|
|
1281
|
+
if (!whoami) {
|
|
1282
|
+
return void 0;
|
|
1283
|
+
}
|
|
1284
|
+
const user = typeof whoami.user === "object" && whoami.user !== null ? whoami.user : void 0;
|
|
1285
|
+
const candidates = [user?.id, whoami.user_id, whoami.id, whoami.sub];
|
|
1286
|
+
for (const candidate of candidates) {
|
|
1287
|
+
if (typeof candidate === "string" && candidate.trim() && !looksLikeEmail(candidate)) {
|
|
1288
|
+
return candidate.trim();
|
|
1289
|
+
}
|
|
1290
|
+
}
|
|
1291
|
+
return void 0;
|
|
1292
|
+
}
|
|
1293
|
+
|
|
1294
|
+
// src/telemetry/capture.ts
|
|
1295
|
+
import http from "http";
|
|
1296
|
+
import https from "https";
|
|
1297
|
+
|
|
1298
|
+
// src/telemetry/state.ts
|
|
1299
|
+
import { existsSync as existsSync3, mkdirSync, readFileSync as readFileSync3, writeFileSync as writeFileSync2 } from "fs";
|
|
1300
|
+
import { randomUUID } from "crypto";
|
|
1301
|
+
import { join as join4 } from "path";
|
|
1302
|
+
function statePath(harnesstapDir) {
|
|
1303
|
+
return join4(harnesstapDir, "telemetry-state.json");
|
|
1304
|
+
}
|
|
1305
|
+
function isRecord(value) {
|
|
1306
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1307
|
+
}
|
|
1308
|
+
function stringField(value) {
|
|
1309
|
+
return typeof value === "string" && value.trim().length > 0 ? value.trim() : void 0;
|
|
1310
|
+
}
|
|
1311
|
+
function loadTelemetryState(harnesstapDir = getHarnesstapDir()) {
|
|
1312
|
+
const path = statePath(harnesstapDir);
|
|
1313
|
+
if (!existsSync3(path)) {
|
|
1314
|
+
return { distinct_id: randomUUID() };
|
|
1315
|
+
}
|
|
1316
|
+
try {
|
|
1317
|
+
const parsed = JSON.parse(readFileSync3(path, "utf-8"));
|
|
1318
|
+
if (!isRecord(parsed)) {
|
|
1319
|
+
return { distinct_id: randomUUID() };
|
|
1320
|
+
}
|
|
1321
|
+
return {
|
|
1322
|
+
distinct_id: stringField(parsed.distinct_id) ?? randomUUID(),
|
|
1323
|
+
...stringField(parsed.identified_distinct_id) ? { identified_distinct_id: stringField(parsed.identified_distinct_id) } : {},
|
|
1324
|
+
...stringField(parsed.cli_installed_at) ? { cli_installed_at: stringField(parsed.cli_installed_at) } : {},
|
|
1325
|
+
...stringField(parsed.cli_first_run_at) ? { cli_first_run_at: stringField(parsed.cli_first_run_at) } : {},
|
|
1326
|
+
...stringField(parsed.desktop_installed_at) ? { desktop_installed_at: stringField(parsed.desktop_installed_at) } : {},
|
|
1327
|
+
...stringField(parsed.desktop_first_open_at) ? { desktop_first_open_at: stringField(parsed.desktop_first_open_at) } : {},
|
|
1328
|
+
...stringField(parsed.cli_notice_shown_at) ? { cli_notice_shown_at: stringField(parsed.cli_notice_shown_at) } : {}
|
|
1329
|
+
};
|
|
1330
|
+
} catch {
|
|
1331
|
+
return { distinct_id: randomUUID() };
|
|
1332
|
+
}
|
|
1333
|
+
}
|
|
1334
|
+
function saveTelemetryState(state, harnesstapDir = getHarnesstapDir()) {
|
|
1335
|
+
mkdirSync(harnesstapDir, { recursive: true });
|
|
1336
|
+
writeFileSync2(statePath(harnesstapDir), `${JSON.stringify(state, null, 2)}
|
|
1337
|
+
`);
|
|
1338
|
+
}
|
|
1339
|
+
function updateTelemetryState(patch, harnesstapDir = getHarnesstapDir()) {
|
|
1340
|
+
const current = loadTelemetryState(harnesstapDir);
|
|
1341
|
+
const next = { ...current, ...patch };
|
|
1342
|
+
saveTelemetryState(next, harnesstapDir);
|
|
1343
|
+
return next;
|
|
1344
|
+
}
|
|
1345
|
+
function resolveDistinctId(harnesstapDir = getHarnesstapDir()) {
|
|
1346
|
+
const current = loadTelemetryState(harnesstapDir);
|
|
1347
|
+
if (current.identified_distinct_id) {
|
|
1348
|
+
return current.identified_distinct_id;
|
|
1349
|
+
}
|
|
1350
|
+
saveTelemetryState(current, harnesstapDir);
|
|
1351
|
+
return current.distinct_id;
|
|
1352
|
+
}
|
|
1353
|
+
|
|
1354
|
+
// src/telemetry/capture.ts
|
|
1355
|
+
var CAPTURE_TIMEOUT_MS = 800;
|
|
1356
|
+
var transportOverride;
|
|
1357
|
+
function unrefSocketRequest(url, body) {
|
|
1358
|
+
const parsed = new URL(url);
|
|
1359
|
+
const client = parsed.protocol === "https:" ? https : http;
|
|
1360
|
+
const request = client.request(
|
|
1361
|
+
{
|
|
1362
|
+
protocol: parsed.protocol,
|
|
1363
|
+
hostname: parsed.hostname,
|
|
1364
|
+
port: parsed.port,
|
|
1365
|
+
path: `${parsed.pathname}${parsed.search}`,
|
|
1366
|
+
method: "POST",
|
|
1367
|
+
headers: {
|
|
1368
|
+
"content-type": "application/json",
|
|
1369
|
+
"content-length": Buffer.byteLength(body)
|
|
1370
|
+
},
|
|
1371
|
+
timeout: CAPTURE_TIMEOUT_MS
|
|
1372
|
+
},
|
|
1373
|
+
(response) => {
|
|
1374
|
+
response.resume();
|
|
1375
|
+
}
|
|
1376
|
+
);
|
|
1377
|
+
request.on("error", () => void 0);
|
|
1378
|
+
request.on("timeout", () => {
|
|
1379
|
+
request.destroy();
|
|
1380
|
+
});
|
|
1381
|
+
request.on("socket", (socket) => {
|
|
1382
|
+
socket.unref();
|
|
1383
|
+
});
|
|
1384
|
+
request.end(body);
|
|
1385
|
+
}
|
|
1386
|
+
function defaultTelemetryTransport() {
|
|
1387
|
+
return {
|
|
1388
|
+
send(url, body) {
|
|
1389
|
+
unrefSocketRequest(url, body);
|
|
1390
|
+
}
|
|
1391
|
+
};
|
|
1392
|
+
}
|
|
1393
|
+
function transport() {
|
|
1394
|
+
return transportOverride ?? defaultTelemetryTransport();
|
|
1395
|
+
}
|
|
1396
|
+
function baseTelemetryProperties() {
|
|
1397
|
+
return {
|
|
1398
|
+
product: resolveTelemetryProduct(),
|
|
1399
|
+
app_version: PACKAGE_VERSION,
|
|
1400
|
+
os: process.platform,
|
|
1401
|
+
$lib: "harnesstap",
|
|
1402
|
+
$ip: null
|
|
1403
|
+
};
|
|
1404
|
+
}
|
|
1405
|
+
function captureEvent(event, properties = {}) {
|
|
1406
|
+
try {
|
|
1407
|
+
if (!isTelemetryEnabled()) {
|
|
1408
|
+
return;
|
|
1409
|
+
}
|
|
1410
|
+
const apiKey = resolvePosthogProjectApiKey();
|
|
1411
|
+
if (!apiKey) {
|
|
1412
|
+
return;
|
|
1413
|
+
}
|
|
1414
|
+
const payload = {
|
|
1415
|
+
api_key: apiKey,
|
|
1416
|
+
event,
|
|
1417
|
+
distinct_id: resolveDistinctId(),
|
|
1418
|
+
properties: sanitizeTelemetryProps({
|
|
1419
|
+
...baseTelemetryProperties(),
|
|
1420
|
+
...properties
|
|
1421
|
+
})
|
|
1422
|
+
};
|
|
1423
|
+
transport().send(resolvePosthogCaptureUrl(), JSON.stringify(payload));
|
|
1424
|
+
} catch {
|
|
1425
|
+
}
|
|
1426
|
+
}
|
|
1427
|
+
|
|
1428
|
+
// src/telemetry/install-method.ts
|
|
1429
|
+
var INSTALL_METHODS = /* @__PURE__ */ new Set([
|
|
1430
|
+
"brew",
|
|
1431
|
+
"npm",
|
|
1432
|
+
"bun",
|
|
1433
|
+
"npx",
|
|
1434
|
+
"curl",
|
|
1435
|
+
"unknown"
|
|
1436
|
+
]);
|
|
1437
|
+
function isCliInstallMethod(value) {
|
|
1438
|
+
return INSTALL_METHODS.has(value);
|
|
1439
|
+
}
|
|
1440
|
+
function detectCliInstallMethod() {
|
|
1441
|
+
const override = process.env.HARNESSTAP_INSTALL_METHOD?.trim().toLowerCase();
|
|
1442
|
+
if (override && isCliInstallMethod(override)) {
|
|
1443
|
+
return override;
|
|
1444
|
+
}
|
|
1445
|
+
const haystack = [
|
|
1446
|
+
process.execPath,
|
|
1447
|
+
process.argv[1] ?? "",
|
|
1448
|
+
process.env.npm_execpath ?? "",
|
|
1449
|
+
process.env.npm_command ?? ""
|
|
1450
|
+
].join(" ").toLowerCase();
|
|
1451
|
+
if (haystack.includes("npx")) {
|
|
1452
|
+
return "npx";
|
|
1453
|
+
}
|
|
1454
|
+
if (haystack.includes("/cellar/") || haystack.includes("homebrew")) {
|
|
1455
|
+
return "brew";
|
|
1456
|
+
}
|
|
1457
|
+
if (haystack.includes("bun")) {
|
|
1458
|
+
return "bun";
|
|
1459
|
+
}
|
|
1460
|
+
if (haystack.includes("node_modules") || haystack.includes("npm") || process.execPath.toLowerCase().includes("node") && haystack.includes("harnesstap")) {
|
|
1461
|
+
return "npm";
|
|
1462
|
+
}
|
|
1463
|
+
return "unknown";
|
|
1464
|
+
}
|
|
1465
|
+
|
|
1466
|
+
// src/telemetry/track.ts
|
|
1467
|
+
function trackCliStartup() {
|
|
1468
|
+
try {
|
|
1469
|
+
if (!isTelemetryEnabled()) {
|
|
1470
|
+
return;
|
|
1471
|
+
}
|
|
1472
|
+
const state = loadTelemetryState();
|
|
1473
|
+
const version = PACKAGE_VERSION;
|
|
1474
|
+
if (!state.cli_installed_at) {
|
|
1475
|
+
captureEvent("cli_installed", {
|
|
1476
|
+
install_method: detectCliInstallMethod(),
|
|
1477
|
+
version
|
|
1478
|
+
});
|
|
1479
|
+
}
|
|
1480
|
+
if (!state.cli_first_run_at) {
|
|
1481
|
+
captureEvent("cli_first_run", { version });
|
|
1482
|
+
}
|
|
1483
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
1484
|
+
updateTelemetryState({
|
|
1485
|
+
...state.cli_installed_at ? {} : { cli_installed_at: now },
|
|
1486
|
+
...state.cli_first_run_at ? {} : { cli_first_run_at: now }
|
|
1487
|
+
});
|
|
1488
|
+
} catch {
|
|
1489
|
+
}
|
|
1490
|
+
}
|
|
1491
|
+
function trackCloudConnectStarted() {
|
|
1492
|
+
captureEvent("cloud_connect_started", {});
|
|
1493
|
+
}
|
|
1494
|
+
function trackCloudConnectFailed(reason, errorCode) {
|
|
1495
|
+
captureEvent("cloud_connect_failed", {
|
|
1496
|
+
reason,
|
|
1497
|
+
...errorCode ? { error_code: errorCode } : {}
|
|
1498
|
+
});
|
|
1499
|
+
}
|
|
1500
|
+
function identifyFromCloudWhoami(input) {
|
|
1501
|
+
try {
|
|
1502
|
+
return extractCloudUserId(input.whoami, input.userId);
|
|
1503
|
+
} catch {
|
|
1504
|
+
return void 0;
|
|
1505
|
+
}
|
|
1506
|
+
}
|
|
1507
|
+
function trackCloudConnected(_input) {
|
|
1508
|
+
captureEvent("cloud_connected", {});
|
|
1509
|
+
captureEvent("signed_in", {});
|
|
1510
|
+
}
|
|
1511
|
+
function trackPluginInstalled(input) {
|
|
1512
|
+
void input.pluginSlug;
|
|
1513
|
+
void input.orgId;
|
|
1514
|
+
captureEvent("plugin_installed", { source: input.source });
|
|
1515
|
+
}
|
|
1516
|
+
function trackPluginApplied(input) {
|
|
1517
|
+
void input.pluginSlug;
|
|
1518
|
+
void input.orgId;
|
|
1519
|
+
captureEvent("plugin_applied", {
|
|
1520
|
+
...input.harness ? { harness: input.harness } : {}
|
|
1521
|
+
});
|
|
1522
|
+
}
|
|
1523
|
+
function trackPluginUsed(input) {
|
|
1524
|
+
void input.pluginSlug;
|
|
1525
|
+
void input.orgId;
|
|
1526
|
+
captureEvent("plugin_used", {
|
|
1527
|
+
...input.harness ? { harness: input.harness } : {}
|
|
1528
|
+
});
|
|
1529
|
+
}
|
|
1530
|
+
|
|
1531
|
+
// src/telemetry/copy.ts
|
|
1532
|
+
var TELEMETRY_SCOPE_SUMMARY = "HarnessTap can send anonymous product analytics to our EU PostHog project so we can see how the product is used.";
|
|
1533
|
+
var TELEMETRY_TRACKED_LINES = [
|
|
1534
|
+
"Which product you used (CLI or Desktop), version, and operating system",
|
|
1535
|
+
"How the CLI was installed",
|
|
1536
|
+
"HarnessTap Cloud interactions",
|
|
1537
|
+
"Plugin install, apply, and view occurrences"
|
|
1538
|
+
];
|
|
1539
|
+
var TELEMETRY_NOT_TRACKED_LINES = [
|
|
1540
|
+
"No personal data: names, emails, file paths, code, secrets, or MCP configs",
|
|
1541
|
+
"No resource-related information: plugin names, contents, or organization ids"
|
|
1542
|
+
];
|
|
1543
|
+
var TELEMETRY_CLI_DISABLE_INSTRUCTIONS = 'Disable with HARNESSTAP_TELEMETRY=0 or set "telemetry": { "enabled": false } in ~/.harnesstap/config.jsonc.';
|
|
1544
|
+
var TELEMETRY_CLI_ENABLE_INSTRUCTIONS = 'Enable with HARNESSTAP_TELEMETRY=1 or set "telemetry": { "enabled": true } in ~/.harnesstap/config.jsonc.';
|
|
1545
|
+
function formatTelemetryScopeBody() {
|
|
1546
|
+
return [
|
|
1547
|
+
TELEMETRY_SCOPE_SUMMARY,
|
|
1548
|
+
"",
|
|
1549
|
+
"What we track:",
|
|
1550
|
+
...TELEMETRY_TRACKED_LINES.map((line) => `\u2022 ${line}`),
|
|
1551
|
+
"",
|
|
1552
|
+
"What we do not track:",
|
|
1553
|
+
...TELEMETRY_NOT_TRACKED_LINES.map((line) => `\u2022 ${line}`)
|
|
1554
|
+
].join("\n");
|
|
1555
|
+
}
|
|
1556
|
+
function formatCliTelemetryEnabledWarning() {
|
|
1557
|
+
return [
|
|
1558
|
+
"Anonymous usage telemetry is on.",
|
|
1559
|
+
formatTelemetryScopeBody(),
|
|
1560
|
+
TELEMETRY_CLI_DISABLE_INSTRUCTIONS
|
|
1561
|
+
].join("\n");
|
|
1562
|
+
}
|
|
1563
|
+
function formatCliTelemetryUnsettledWarning() {
|
|
1564
|
+
return [
|
|
1565
|
+
"Anonymous usage telemetry is off until you opt in. No events are sent yet.",
|
|
1566
|
+
formatTelemetryScopeBody(),
|
|
1567
|
+
TELEMETRY_CLI_ENABLE_INSTRUCTIONS,
|
|
1568
|
+
TELEMETRY_CLI_DISABLE_INSTRUCTIONS
|
|
1569
|
+
].join("\n");
|
|
1570
|
+
}
|
|
1571
|
+
|
|
1572
|
+
// src/telemetry/notice.ts
|
|
1573
|
+
var noticePrinter;
|
|
1574
|
+
function argvRequestsJson(argv) {
|
|
1575
|
+
for (let i = 0; i < argv.length; i++) {
|
|
1576
|
+
const arg = argv[i];
|
|
1577
|
+
if (arg === "--json" || arg === "--format=json") {
|
|
1578
|
+
return true;
|
|
1579
|
+
}
|
|
1580
|
+
if (arg === "--format" && argv[i + 1] === "json") {
|
|
1581
|
+
return true;
|
|
1582
|
+
}
|
|
1583
|
+
}
|
|
1584
|
+
return false;
|
|
1585
|
+
}
|
|
1586
|
+
function maybeWarnCliTelemetry(harnesstapDir = getHarnesstapDir(), opts) {
|
|
1587
|
+
try {
|
|
1588
|
+
const argv = opts?.argv ?? process.argv;
|
|
1589
|
+
const stdoutIsTTY = opts?.stdoutIsTTY ?? Boolean(process.stdout.isTTY);
|
|
1590
|
+
const skipForMachineOutput = argvRequestsJson(argv) || !stdoutIsTTY;
|
|
1591
|
+
if (skipForMachineOutput && !noticePrinter) {
|
|
1592
|
+
return;
|
|
1593
|
+
}
|
|
1594
|
+
const env = telemetryEnvFlag();
|
|
1595
|
+
if (env === false) {
|
|
1596
|
+
return;
|
|
1597
|
+
}
|
|
1598
|
+
const preference = readTelemetryConfigPreference(harnesstapDir);
|
|
1599
|
+
const enabled = isTelemetryEnabled(harnesstapDir);
|
|
1600
|
+
const unsettled = env === void 0 && preference === void 0;
|
|
1601
|
+
if (!enabled && !unsettled) {
|
|
1602
|
+
return;
|
|
1603
|
+
}
|
|
1604
|
+
const state = loadTelemetryState(harnesstapDir);
|
|
1605
|
+
if (state.cli_notice_shown_at) {
|
|
1606
|
+
return;
|
|
1607
|
+
}
|
|
1608
|
+
const message = enabled ? formatCliTelemetryEnabledWarning() : formatCliTelemetryUnsettledWarning();
|
|
1609
|
+
(noticePrinter ?? ((text) => {
|
|
1610
|
+
console.error(text);
|
|
1611
|
+
}))(message);
|
|
1612
|
+
updateTelemetryState(
|
|
1613
|
+
{
|
|
1614
|
+
cli_notice_shown_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
1615
|
+
},
|
|
1616
|
+
harnesstapDir
|
|
1617
|
+
);
|
|
1618
|
+
} catch {
|
|
1619
|
+
}
|
|
1620
|
+
}
|
|
1621
|
+
|
|
1096
1622
|
export {
|
|
1623
|
+
cloudErrorDetail,
|
|
1624
|
+
requestIdSuffix,
|
|
1097
1625
|
DEFAULT_CATALOG_SLUG,
|
|
1098
1626
|
parsePluginSelector,
|
|
1099
1627
|
formatPublishedSelector,
|
|
@@ -1135,6 +1663,18 @@ export {
|
|
|
1135
1663
|
createCloudClient,
|
|
1136
1664
|
ensureCloudAccountAccess,
|
|
1137
1665
|
forceRefreshCloudAccountAccess,
|
|
1138
|
-
createPersistingCloudClient
|
|
1666
|
+
createPersistingCloudClient,
|
|
1667
|
+
isTelemetryEnabled,
|
|
1668
|
+
shortReason,
|
|
1669
|
+
extractCloudUserId,
|
|
1670
|
+
maybeWarnCliTelemetry,
|
|
1671
|
+
trackCliStartup,
|
|
1672
|
+
trackCloudConnectStarted,
|
|
1673
|
+
trackCloudConnectFailed,
|
|
1674
|
+
identifyFromCloudWhoami,
|
|
1675
|
+
trackCloudConnected,
|
|
1676
|
+
trackPluginInstalled,
|
|
1677
|
+
trackPluginApplied,
|
|
1678
|
+
trackPluginUsed
|
|
1139
1679
|
};
|
|
1140
|
-
//# sourceMappingURL=chunk-
|
|
1680
|
+
//# sourceMappingURL=chunk-V4UNYSZO.js.map
|