harnesstap 1.3.2 → 1.4.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 +2 -0
- package/dist/apply-SUNDXRJ3.js +54 -0
- package/dist/{approve-L7IFSYBO.js → approve-FBGYQGWN.js} +14 -15
- package/dist/{approve-L7IFSYBO.js.map → approve-FBGYQGWN.js.map} +1 -1
- package/dist/{audit-PBJDK7A4.js → audit-VI4QZ6X2.js} +30 -39
- package/dist/{audit-PBJDK7A4.js.map → audit-VI4QZ6X2.js.map} +1 -1
- package/dist/{auth-OM73RLNS.js → auth-4CQCDS2W.js} +17 -19
- package/dist/{auth-OM73RLNS.js.map → auth-4CQCDS2W.js.map} +1 -1
- package/dist/bin.js +3 -3
- package/dist/{chunk-YRGM7RAD.js → chunk-23XSG7LI.js} +7 -11
- package/dist/{chunk-YRGM7RAD.js.map → chunk-23XSG7LI.js.map} +1 -1
- package/dist/{chunk-LDVXYN6F.js → chunk-2A36HWDE.js} +63 -13
- package/dist/chunk-2A36HWDE.js.map +1 -0
- package/dist/{chunk-QNAIDM6W.js → chunk-3FS775NP.js} +51 -4
- package/dist/chunk-3FS775NP.js.map +1 -0
- package/dist/{chunk-XCPWLGPB.js → chunk-3P6BWL5F.js} +2 -2
- package/dist/{chunk-JJJJ2RAD.js → chunk-43BDGVN3.js} +19 -6
- package/dist/chunk-43BDGVN3.js.map +1 -0
- package/dist/{chunk-CZ4T75PP.js → chunk-4ZQ2SCGY.js} +146 -78
- package/dist/chunk-4ZQ2SCGY.js.map +1 -0
- package/dist/{chunk-ZVANUFPF.js → chunk-6LTLYV5D.js} +353 -267
- package/dist/chunk-6LTLYV5D.js.map +1 -0
- package/dist/{chunk-OPVIX7E4.js → chunk-73OJQTBW.js} +6 -2
- package/dist/chunk-73OJQTBW.js.map +1 -0
- package/dist/{chunk-WXRPQICX.js → chunk-7HP6AAI3.js} +2 -2
- package/dist/{chunk-ENHDEB7Z.js → chunk-BPWFQKI5.js} +5 -7
- package/dist/{chunk-ENHDEB7Z.js.map → chunk-BPWFQKI5.js.map} +1 -1
- package/dist/{chunk-64R32MG2.js → chunk-D432JAXV.js} +44 -19
- package/dist/chunk-D432JAXV.js.map +1 -0
- package/dist/chunk-DF4Z7LAD.js +3463 -0
- package/dist/chunk-DF4Z7LAD.js.map +1 -0
- package/dist/{chunk-FUV7QYBS.js → chunk-EOPFER6N.js} +71 -318
- package/dist/chunk-EOPFER6N.js.map +1 -0
- package/dist/chunk-G6WKY2W4.js +389 -0
- package/dist/chunk-G6WKY2W4.js.map +1 -0
- package/dist/{chunk-IHW4PCDT.js → chunk-GRASK6M6.js} +5 -5
- package/dist/{chunk-R4PTE774.js → chunk-IE7B6Q5K.js} +33 -39
- package/dist/chunk-IE7B6Q5K.js.map +1 -0
- package/dist/{chunk-UNRR4KH5.js → chunk-IMROMZ2K.js} +6 -5
- package/dist/{chunk-UNRR4KH5.js.map → chunk-IMROMZ2K.js.map} +1 -1
- package/dist/{chunk-G5RWVZZ7.js → chunk-L6YZE5MY.js} +3 -3
- package/dist/{chunk-SNVAMWB7.js → chunk-M2U3J7UX.js} +7 -1
- package/dist/chunk-M2U3J7UX.js.map +1 -0
- package/dist/{chunk-AFKCNFPP.js → chunk-M4KLHJ6U.js} +16 -13
- package/dist/chunk-M4KLHJ6U.js.map +1 -0
- package/dist/{chunk-XRXFJTAT.js → chunk-MR7IOHSX.js} +16 -19
- package/dist/chunk-MR7IOHSX.js.map +1 -0
- package/dist/{chunk-UEHDEADL.js → chunk-N3VGY3T3.js} +15 -15
- package/dist/chunk-N3VGY3T3.js.map +1 -0
- package/dist/{chunk-IKAGGJEO.js → chunk-N3ZCH64F.js} +496 -10
- package/dist/chunk-N3ZCH64F.js.map +1 -0
- package/dist/{chunk-U472S6IB.js → chunk-OML4HXKT.js} +20 -22
- package/dist/chunk-OML4HXKT.js.map +1 -0
- package/dist/{chunk-3EGM4IUI.js → chunk-P2C7JPLD.js} +3 -3
- package/dist/{chunk-MFCZN253.js → chunk-PCMON7Y2.js} +7 -7
- package/dist/{chunk-FBYAIBHP.js → chunk-PNGF5EV2.js} +2 -2
- package/dist/{chunk-6JMVGKMD.js → chunk-QA5U36JN.js} +187 -203
- package/dist/chunk-QA5U36JN.js.map +1 -0
- package/dist/{chunk-AVZOFMJX.js → chunk-R7ZOYVN3.js} +241 -126
- package/dist/chunk-R7ZOYVN3.js.map +1 -0
- package/dist/{chunk-YVJQ2QDG.js → chunk-RDG5DT7S.js} +45 -49
- package/dist/{chunk-YVJQ2QDG.js.map → chunk-RDG5DT7S.js.map} +1 -1
- package/dist/{chunk-VQVUJYYY.js → chunk-REHRUNBB.js} +8 -3
- package/dist/chunk-REHRUNBB.js.map +1 -0
- package/dist/{chunk-Y2JGMICO.js → chunk-RFQ3N7FB.js} +19 -29
- package/dist/chunk-RFQ3N7FB.js.map +1 -0
- package/dist/{chunk-EY4ES5MG.js → chunk-RVEXPMM3.js} +3 -3
- package/dist/{chunk-6I3RY6R5.js → chunk-TPEJFLV7.js} +13 -15
- package/dist/{chunk-6I3RY6R5.js.map → chunk-TPEJFLV7.js.map} +1 -1
- package/dist/{chunk-IAZNF35S.js → chunk-U6DXASQP.js} +2 -2
- package/dist/{chunk-OQ4KBUN2.js → chunk-ULCD6DJE.js} +30 -8
- package/dist/chunk-ULCD6DJE.js.map +1 -0
- package/dist/{chunk-BXSS2S4W.js → chunk-UVVZHWD2.js} +2 -2
- package/dist/{chunk-24V5ZSIF.js → chunk-WG5A6EAU.js} +269 -13
- package/dist/chunk-WG5A6EAU.js.map +1 -0
- package/dist/{chunk-LGWUTV5Q.js → chunk-WGP4GUYZ.js} +10 -10
- package/dist/{chunk-GWQVYGRD.js → chunk-XTVGCVU4.js} +124 -83
- package/dist/chunk-XTVGCVU4.js.map +1 -0
- package/dist/{chunk-YX7MVSDA.js → chunk-XUJKZQZA.js} +8 -8
- package/dist/chunk-XUJKZQZA.js.map +1 -0
- package/dist/chunk-ZUASVASP.js +30317 -0
- package/dist/chunk-ZUASVASP.js.map +1 -0
- package/dist/{compile-SDOASKGL.js → compile-GXADKGH5.js} +37 -50
- package/dist/{compile-SDOASKGL.js.map → compile-GXADKGH5.js.map} +1 -1
- package/dist/{config-4VZTVZKF.js → config-JMHNA2U5.js} +22 -35
- package/dist/{config-4VZTVZKF.js.map → config-JMHNA2U5.js.map} +1 -1
- package/dist/cursor-local-install-46RWRBDT.js +98 -0
- package/dist/cursor-local-install-46RWRBDT.js.map +1 -0
- package/dist/{doctor-HH6CFBRQ.js → doctor-N7ZULPOL.js} +18 -19
- package/dist/{doctor-HH6CFBRQ.js.map → doctor-N7ZULPOL.js.map} +1 -1
- package/dist/{environment-K7YMJJYN.js → environment-OBB3WU5B.js} +60 -71
- package/dist/{environment-K7YMJJYN.js.map → environment-OBB3WU5B.js.map} +1 -1
- package/dist/{github-A6TYG7WS.js → github-PBYBGOLH.js} +17 -17
- package/dist/{harness-772XBFZQ.js → harness-7KYATIV6.js} +56 -67
- package/dist/{harness-772XBFZQ.js.map → harness-7KYATIV6.js.map} +1 -1
- package/dist/{help-QR4VTJZU.js → help-EE3AJQD4.js} +48 -52
- package/dist/help-EE3AJQD4.js.map +1 -0
- package/dist/{help-TLHNRJJ6.js → help-VXWKLQ6A.js} +55 -15
- package/dist/help-VXWKLQ6A.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +16 -24
- package/dist/{init-AOKFPZHG.js → init-LBTMPDVJ.js} +43 -56
- package/dist/init-LBTMPDVJ.js.map +1 -0
- package/dist/live-read-cache-TUSP7U3D.js +10 -0
- package/dist/{lock-INAXNLMC.js → lock-WLJRXRVK.js} +16 -16
- package/dist/{marketplace-TUVLLPBG.js → marketplace-GXSV6QIY.js} +62 -28
- package/dist/marketplace-GXSV6QIY.js.map +1 -0
- package/dist/{mcp-MMWGRASN.js → mcp-XPDWWU75.js} +35 -48
- package/dist/{mcp-MMWGRASN.js.map → mcp-XPDWWU75.js.map} +1 -1
- package/dist/{migrate-55S4XODX.js → migrate-SBUIWN3U.js} +79 -64
- package/dist/migrate-SBUIWN3U.js.map +1 -0
- package/dist/open-HDGLYYVU.js +24 -0
- package/dist/{pack-VZIBS42E.js → pack-A73LDVOX.js} +16 -22
- package/dist/{pack-VZIBS42E.js.map → pack-A73LDVOX.js.map} +1 -1
- package/dist/plugin-CEO6ZJM5.js +51 -0
- package/dist/plugin-from-project-UK7VJVUP.js +18 -0
- package/dist/{policy-P3HGLEZS.js → policy-6VY3CMSU.js} +13 -14
- package/dist/{policy-P3HGLEZS.js.map → policy-6VY3CMSU.js.map} +1 -1
- package/dist/{profile-STS3CZUK.js → profile-YCKPMRRU.js} +96 -102
- package/dist/profile-YCKPMRRU.js.map +1 -0
- package/dist/{project-R4DGM3ZG.js → project-KHPPBKPN.js} +63 -77
- package/dist/{project-R4DGM3ZG.js.map → project-KHPPBKPN.js.map} +1 -1
- package/dist/{resource-GJVEDXVZ.js → resource-IJU3FAN5.js} +42 -49
- package/dist/{resource-GJVEDXVZ.js.map → resource-IJU3FAN5.js.map} +1 -1
- package/dist/{version-FUHV4O6U.js → version-Z66FWWMQ.js} +2 -2
- package/dist/version-Z66FWWMQ.js.map +1 -0
- package/package.json +3 -2
- package/dist/apply-Q5SFF3FY.js +0 -67
- package/dist/chunk-24V5ZSIF.js.map +0 -1
- 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-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.map +0 -1
- package/dist/chunk-U472S6IB.js.map +0 -1
- package/dist/chunk-UEHDEADL.js.map +0 -1
- package/dist/chunk-VQVUJYYY.js.map +0 -1
- package/dist/chunk-XRXFJTAT.js.map +0 -1
- package/dist/chunk-Y2JGMICO.js.map +0 -1
- 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.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/{apply-Q5SFF3FY.js.map → apply-SUNDXRJ3.js.map} +0 -0
- /package/dist/{chunk-XCPWLGPB.js.map → chunk-3P6BWL5F.js.map} +0 -0
- /package/dist/{chunk-WXRPQICX.js.map → chunk-7HP6AAI3.js.map} +0 -0
- /package/dist/{chunk-IHW4PCDT.js.map → chunk-GRASK6M6.js.map} +0 -0
- /package/dist/{chunk-G5RWVZZ7.js.map → chunk-L6YZE5MY.js.map} +0 -0
- /package/dist/{chunk-3EGM4IUI.js.map → chunk-P2C7JPLD.js.map} +0 -0
- /package/dist/{chunk-MFCZN253.js.map → chunk-PCMON7Y2.js.map} +0 -0
- /package/dist/{chunk-FBYAIBHP.js.map → chunk-PNGF5EV2.js.map} +0 -0
- /package/dist/{chunk-EY4ES5MG.js.map → chunk-RVEXPMM3.js.map} +0 -0
- /package/dist/{chunk-IAZNF35S.js.map → chunk-U6DXASQP.js.map} +0 -0
- /package/dist/{chunk-BXSS2S4W.js.map → chunk-UVVZHWD2.js.map} +0 -0
- /package/dist/{chunk-LGWUTV5Q.js.map → chunk-WGP4GUYZ.js.map} +0 -0
- /package/dist/{github-A6TYG7WS.js.map → github-PBYBGOLH.js.map} +0 -0
- /package/dist/{open-SLFQV45J.js.map → live-read-cache-TUSP7U3D.js.map} +0 -0
- /package/dist/{lock-INAXNLMC.js.map → lock-WLJRXRVK.js.map} +0 -0
- /package/dist/{plugin-WLEFFBRY.js.map → open-HDGLYYVU.js.map} +0 -0
- /package/dist/{plugin-from-project-UV2O364T.js.map → plugin-CEO6ZJM5.js.map} +0 -0
- /package/dist/{version-FUHV4O6U.js.map → plugin-from-project-UK7VJVUP.js.map} +0 -0
package/dist/chunk-PJQAMC6L.js
DELETED
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
PACK_LOCKFILE_NAME,
|
|
3
|
-
normalizeSha256,
|
|
4
|
-
readZipArchive,
|
|
5
|
-
sha256Hex
|
|
6
|
-
} from "./chunk-3JOPDYQD.js";
|
|
7
|
-
import {
|
|
8
|
-
BundleSymlinkError,
|
|
9
|
-
isApEnvelopePath,
|
|
10
|
-
listContainedRegularFiles,
|
|
11
|
-
packageFileFromBytes,
|
|
12
|
-
readApEnvelope
|
|
13
|
-
} from "./chunk-KJIFZLHN.js";
|
|
14
|
-
|
|
15
|
-
// src/services/legacy-toml-transport.ts
|
|
16
|
-
var LEGACY_PLUGIN_SUFFIX = `.harnesstap${".toml"}`;
|
|
17
|
-
var LEGACY_ENVIRONMENT_SUFFIX = `.environment${".toml"}`;
|
|
18
|
-
function isLegacyPluginTomlPath(filePath) {
|
|
19
|
-
return filePath.toLowerCase().endsWith(LEGACY_PLUGIN_SUFFIX);
|
|
20
|
-
}
|
|
21
|
-
function isLegacyEnvironmentTomlPath(filePath) {
|
|
22
|
-
return filePath.toLowerCase().endsWith(LEGACY_ENVIRONMENT_SUFFIX);
|
|
23
|
-
}
|
|
24
|
-
function isLegacyTomlTransportPath(filePath) {
|
|
25
|
-
return isLegacyPluginTomlPath(filePath) || isLegacyEnvironmentTomlPath(filePath);
|
|
26
|
-
}
|
|
27
|
-
function legacyTomlTransportRejection(filePath) {
|
|
28
|
-
return `${filePath} is a HarnessTap TOML transport file, which is no longer supported. Portable artifacts are Agent Plugins packages: a directory with a plugin.json, or a single .ap.json envelope.`;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// src/services/apm-bundle.ts
|
|
32
|
-
import { existsSync, lstatSync, readFileSync, statSync } from "fs";
|
|
33
|
-
import { join, resolve } from "path";
|
|
34
|
-
import { parse as parseYaml } from "yaml";
|
|
35
|
-
var BundleIntegrityError = class extends Error {
|
|
36
|
-
constructor(message) {
|
|
37
|
-
super(message);
|
|
38
|
-
this.name = "BundleIntegrityError";
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
function isRecord(value) {
|
|
42
|
-
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
43
|
-
}
|
|
44
|
-
function readBundleLock(files) {
|
|
45
|
-
const lockBytes = files[PACK_LOCKFILE_NAME];
|
|
46
|
-
if (!lockBytes) return void 0;
|
|
47
|
-
const parsed = parseYaml(lockBytes.toString("utf8"));
|
|
48
|
-
return isRecord(parsed) ? parsed : void 0;
|
|
49
|
-
}
|
|
50
|
-
function bundleFileMap(lock) {
|
|
51
|
-
const pack = lock?.pack;
|
|
52
|
-
if (!isRecord(pack) || !isRecord(pack.bundle_files)) {
|
|
53
|
-
return void 0;
|
|
54
|
-
}
|
|
55
|
-
return Object.fromEntries(
|
|
56
|
-
Object.entries(pack.bundle_files).map(([path, hash]) => [path, String(hash)])
|
|
57
|
-
);
|
|
58
|
-
}
|
|
59
|
-
function verifyPackedBundleBytes(files) {
|
|
60
|
-
const listed = bundleFileMap(readBundleLock(files));
|
|
61
|
-
if (!listed) {
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
const listedPaths = Object.keys(listed).sort();
|
|
65
|
-
const presentPaths = Object.keys(files).filter((path) => path !== PACK_LOCKFILE_NAME).sort();
|
|
66
|
-
for (const relativePath of listedPaths) {
|
|
67
|
-
if (relativePath.split("/").includes("..") || relativePath.startsWith("/")) {
|
|
68
|
-
throw new BundleIntegrityError(
|
|
69
|
-
`Unsafe pack.bundle_files path ${relativePath}: pack aborted closed`
|
|
70
|
-
);
|
|
71
|
-
}
|
|
72
|
-
const bytes = files[relativePath];
|
|
73
|
-
if (!bytes) {
|
|
74
|
-
throw new BundleIntegrityError(
|
|
75
|
-
`Bundle is missing ${relativePath} listed in pack.bundle_files`
|
|
76
|
-
);
|
|
77
|
-
}
|
|
78
|
-
const expected = listed[relativePath];
|
|
79
|
-
if (!expected) continue;
|
|
80
|
-
const actual = sha256Hex(bytes);
|
|
81
|
-
if (normalizeSha256(expected) !== actual) {
|
|
82
|
-
throw new BundleIntegrityError(
|
|
83
|
-
`Bundle hash mismatch for ${relativePath}: lockfile records ${normalizeSha256(expected)}, file is ${actual}`
|
|
84
|
-
);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
for (const relativePath of presentPaths) {
|
|
88
|
-
if (listed[relativePath] === void 0) {
|
|
89
|
-
throw new BundleIntegrityError(
|
|
90
|
-
`Bundle contains extra file ${relativePath} that is not listed in pack.bundle_files`
|
|
91
|
-
);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
function filesFromDirectory(packageDir) {
|
|
96
|
-
if (lstatSync(packageDir).isSymbolicLink()) {
|
|
97
|
-
throw new BundleSymlinkError(".");
|
|
98
|
-
}
|
|
99
|
-
const files = {};
|
|
100
|
-
for (const relativePath of listContainedRegularFiles(packageDir).sort()) {
|
|
101
|
-
files[relativePath] = readFileSync(join(packageDir, relativePath));
|
|
102
|
-
}
|
|
103
|
-
return files;
|
|
104
|
-
}
|
|
105
|
-
function filesFromZip(archivePath) {
|
|
106
|
-
const members = readZipArchive(readFileSync(archivePath));
|
|
107
|
-
const files = {};
|
|
108
|
-
for (const member of members) {
|
|
109
|
-
files[member.path] = member.data;
|
|
110
|
-
}
|
|
111
|
-
return files;
|
|
112
|
-
}
|
|
113
|
-
function toPackageFiles(files) {
|
|
114
|
-
const result = {};
|
|
115
|
-
for (const relativePath of Object.keys(files).sort()) {
|
|
116
|
-
const bytes = files[relativePath];
|
|
117
|
-
if (!bytes) continue;
|
|
118
|
-
result[relativePath] = packageFileFromBytes(bytes);
|
|
119
|
-
}
|
|
120
|
-
return result;
|
|
121
|
-
}
|
|
122
|
-
function bytesFromPackageFiles(files) {
|
|
123
|
-
const result = {};
|
|
124
|
-
for (const [relativePath, entry] of Object.entries(files)) {
|
|
125
|
-
if (!entry) continue;
|
|
126
|
-
result[relativePath] = entry.encoding === "base64" ? Buffer.from(entry.content, "base64") : Buffer.from(entry.content, "utf8");
|
|
127
|
-
}
|
|
128
|
-
return result;
|
|
129
|
-
}
|
|
130
|
-
function isZipBundlePath(source) {
|
|
131
|
-
return source.toLowerCase().endsWith(".zip");
|
|
132
|
-
}
|
|
133
|
-
function looksLikeFilesystemPath(source) {
|
|
134
|
-
return source.includes("/") || source.includes("\\") || source.startsWith(".");
|
|
135
|
-
}
|
|
136
|
-
function isPluginPackageDirectory(source) {
|
|
137
|
-
try {
|
|
138
|
-
const resolved = resolve(source);
|
|
139
|
-
return existsSync(resolved) && statSync(resolved).isDirectory() && existsSync(join(resolved, "plugin.json"));
|
|
140
|
-
} catch {
|
|
141
|
-
return false;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
function loadVerifiedPackageFiles(filePath) {
|
|
145
|
-
const resolved = resolve(filePath);
|
|
146
|
-
if (isLegacyTomlTransportPath(resolved)) {
|
|
147
|
-
throw new Error(legacyTomlTransportRejection(resolved));
|
|
148
|
-
}
|
|
149
|
-
if (isApEnvelopePath(resolved)) {
|
|
150
|
-
const files = readApEnvelope(resolved);
|
|
151
|
-
verifyPackedBundleBytes(bytesFromPackageFiles(files));
|
|
152
|
-
return files;
|
|
153
|
-
}
|
|
154
|
-
if (isZipBundlePath(resolved)) {
|
|
155
|
-
const files = filesFromZip(resolved);
|
|
156
|
-
verifyPackedBundleBytes(files);
|
|
157
|
-
return toPackageFiles(files);
|
|
158
|
-
}
|
|
159
|
-
if (existsSync(resolved) && statSync(resolved).isDirectory()) {
|
|
160
|
-
if (!existsSync(join(resolved, "plugin.json"))) {
|
|
161
|
-
throw new Error(
|
|
162
|
-
`${resolved} is a directory but has no plugin.json: expected an Agent Plugins package.`
|
|
163
|
-
);
|
|
164
|
-
}
|
|
165
|
-
const files = filesFromDirectory(resolved);
|
|
166
|
-
verifyPackedBundleBytes(files);
|
|
167
|
-
return toPackageFiles(files);
|
|
168
|
-
}
|
|
169
|
-
throw new Error(
|
|
170
|
-
`Cannot tell what ${resolved} is. Pass an Agent Plugins package directory, a .zip bundle, or an .ap.json envelope.`
|
|
171
|
-
);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
export {
|
|
175
|
-
isLegacyPluginTomlPath,
|
|
176
|
-
isLegacyTomlTransportPath,
|
|
177
|
-
legacyTomlTransportRejection,
|
|
178
|
-
isZipBundlePath,
|
|
179
|
-
looksLikeFilesystemPath,
|
|
180
|
-
isPluginPackageDirectory,
|
|
181
|
-
loadVerifiedPackageFiles
|
|
182
|
-
};
|
|
183
|
-
//# sourceMappingURL=chunk-PJQAMC6L.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/services/legacy-toml-transport.ts","../src/services/apm-bundle.ts"],"sourcesContent":["/** Suffixes for deleted TOML transport formats (kept for clear rejection errors). */\nconst LEGACY_PLUGIN_SUFFIX = `.harnesstap${\".toml\"}`;\nconst LEGACY_ENVIRONMENT_SUFFIX = `.environment${\".toml\"}`;\n\nexport function isLegacyPluginTomlPath(filePath: string): boolean {\n return filePath.toLowerCase().endsWith(LEGACY_PLUGIN_SUFFIX);\n}\n\nexport function isLegacyEnvironmentTomlPath(filePath: string): boolean {\n return filePath.toLowerCase().endsWith(LEGACY_ENVIRONMENT_SUFFIX);\n}\n\nexport function isLegacyTomlTransportPath(filePath: string): boolean {\n return isLegacyPluginTomlPath(filePath) || isLegacyEnvironmentTomlPath(filePath);\n}\n\nexport function legacyTomlTransportRejection(filePath: string): string {\n return (\n `${filePath} is a HarnessTap TOML transport file, which is no longer supported. ` +\n \"Portable artifacts are Agent Plugins packages: a directory with a plugin.json, \" +\n \"or a single .ap.json envelope.\"\n );\n}\n","import { existsSync, lstatSync, readFileSync, statSync } from \"node:fs\";\nimport { join, resolve } from \"node:path\";\nimport { parse as parseYaml } from \"yaml\";\nimport {\n packageFileFromBytes,\n type ApPackageFiles,\n} from \"./agent-plugins/files.js\";\nimport { isApEnvelopePath, readApEnvelope } from \"./agent-plugins/envelope.js\";\nimport { PACK_LOCKFILE_NAME, normalizeSha256, sha256Hex } from \"./apm-pack.js\";\nimport {\n isLegacyTomlTransportPath,\n legacyTomlTransportRejection,\n} from \"./legacy-toml-transport.js\";\nimport {\n BundleSymlinkError,\n listContainedRegularFiles,\n} from \"../utils/path-containment.js\";\nimport { readZipArchive } from \"../utils/zip-archive.js\";\n\nexport class BundleIntegrityError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"BundleIntegrityError\";\n }\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return value !== null && typeof value === \"object\" && !Array.isArray(value);\n}\n\nfunction readBundleLock(files: Record<string, Buffer>): Record<string, unknown> | undefined {\n const lockBytes = files[PACK_LOCKFILE_NAME];\n if (!lockBytes) return undefined;\n const parsed = parseYaml(lockBytes.toString(\"utf8\"));\n return isRecord(parsed) ? parsed : undefined;\n}\n\nfunction bundleFileMap(lock: Record<string, unknown> | undefined): Record<string, string> | undefined {\n const pack = lock?.pack;\n if (!isRecord(pack) || !isRecord(pack.bundle_files)) {\n return undefined;\n }\n return Object.fromEntries(\n Object.entries(pack.bundle_files).map(([path, hash]) => [path, String(hash)]),\n );\n}\n\nexport function verifyPackedBundleBytes(files: Record<string, Buffer>): void {\n const listed = bundleFileMap(readBundleLock(files));\n if (!listed) {\n return;\n }\n\n const listedPaths = Object.keys(listed).sort();\n const presentPaths = Object.keys(files)\n .filter((path) => path !== PACK_LOCKFILE_NAME)\n .sort();\n\n for (const relativePath of listedPaths) {\n if (relativePath.split(\"/\").includes(\"..\") || relativePath.startsWith(\"/\")) {\n throw new BundleIntegrityError(\n `Unsafe pack.bundle_files path ${relativePath}: pack aborted closed`,\n );\n }\n const bytes = files[relativePath];\n if (!bytes) {\n throw new BundleIntegrityError(\n `Bundle is missing ${relativePath} listed in pack.bundle_files`,\n );\n }\n const expected = listed[relativePath];\n if (!expected) continue;\n const actual = sha256Hex(bytes);\n if (normalizeSha256(expected) !== actual) {\n throw new BundleIntegrityError(\n `Bundle hash mismatch for ${relativePath}: lockfile records ${normalizeSha256(expected)}, file is ${actual}`,\n );\n }\n }\n\n for (const relativePath of presentPaths) {\n if (listed[relativePath] === undefined) {\n throw new BundleIntegrityError(\n `Bundle contains extra file ${relativePath} that is not listed in pack.bundle_files`,\n );\n }\n }\n}\n\nfunction filesFromDirectory(packageDir: string): Record<string, Buffer> {\n if (lstatSync(packageDir).isSymbolicLink()) {\n throw new BundleSymlinkError(\".\");\n }\n const files: Record<string, Buffer> = {};\n for (const relativePath of listContainedRegularFiles(packageDir).sort()) {\n files[relativePath] = readFileSync(join(packageDir, relativePath));\n }\n return files;\n}\n\nfunction filesFromZip(archivePath: string): Record<string, Buffer> {\n const members = readZipArchive(readFileSync(archivePath));\n const files: Record<string, Buffer> = {};\n for (const member of members) {\n files[member.path] = member.data;\n }\n return files;\n}\n\nfunction toPackageFiles(files: Record<string, Buffer>): ApPackageFiles {\n const result: ApPackageFiles = {};\n for (const relativePath of Object.keys(files).sort()) {\n const bytes = files[relativePath];\n if (!bytes) continue;\n result[relativePath] = packageFileFromBytes(bytes);\n }\n return result;\n}\n\nfunction bytesFromPackageFiles(files: ApPackageFiles): Record<string, Buffer> {\n const result: Record<string, Buffer> = {};\n for (const [relativePath, entry] of Object.entries(files)) {\n if (!entry) continue;\n result[relativePath] =\n entry.encoding === \"base64\"\n ? Buffer.from(entry.content, \"base64\")\n : Buffer.from(entry.content, \"utf8\");\n }\n return result;\n}\n\nexport function isZipBundlePath(source: string): boolean {\n return source.toLowerCase().endsWith(\".zip\");\n}\n\nexport function looksLikeFilesystemPath(source: string): boolean {\n return source.includes(\"/\") || source.includes(\"\\\\\") || source.startsWith(\".\");\n}\n\nexport function isPluginPackageDirectory(source: string): boolean {\n try {\n const resolved = resolve(source);\n return (\n existsSync(resolved)\n && statSync(resolved).isDirectory()\n && existsSync(join(resolved, \"plugin.json\"))\n );\n } catch {\n return false;\n }\n}\n\nexport function loadVerifiedPackageFiles(filePath: string): ApPackageFiles {\n const resolved = resolve(filePath);\n if (isLegacyTomlTransportPath(resolved)) {\n throw new Error(legacyTomlTransportRejection(resolved));\n }\n\n if (isApEnvelopePath(resolved)) {\n const files = readApEnvelope(resolved);\n verifyPackedBundleBytes(bytesFromPackageFiles(files));\n return files;\n }\n\n if (isZipBundlePath(resolved)) {\n const files = filesFromZip(resolved);\n verifyPackedBundleBytes(files);\n return toPackageFiles(files);\n }\n\n if (existsSync(resolved) && statSync(resolved).isDirectory()) {\n if (!existsSync(join(resolved, \"plugin.json\"))) {\n throw new Error(\n `${resolved} is a directory but has no plugin.json: expected an Agent Plugins package.`,\n );\n }\n const files = filesFromDirectory(resolved);\n verifyPackedBundleBytes(files);\n return toPackageFiles(files);\n }\n\n throw new Error(\n `Cannot tell what ${resolved} is. Pass an Agent Plugins package directory, a .zip bundle, or an .ap.json envelope.`,\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AACA,IAAM,uBAAuB,cAAc,OAAO;AAClD,IAAM,4BAA4B,eAAe,OAAO;AAEjD,SAAS,uBAAuB,UAA2B;AAChE,SAAO,SAAS,YAAY,EAAE,SAAS,oBAAoB;AAC7D;AAEO,SAAS,4BAA4B,UAA2B;AACrE,SAAO,SAAS,YAAY,EAAE,SAAS,yBAAyB;AAClE;AAEO,SAAS,0BAA0B,UAA2B;AACnE,SAAO,uBAAuB,QAAQ,KAAK,4BAA4B,QAAQ;AACjF;AAEO,SAAS,6BAA6B,UAA0B;AACrE,SACE,GAAG,QAAQ;AAIf;;;ACtBA,SAAS,YAAY,WAAW,cAAc,gBAAgB;AAC9D,SAAS,MAAM,eAAe;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