@agntk/agent-harness 0.1.3 → 0.1.4
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/cli/index.js +1 -1
- package/dist/index.js +136 -0
- package/dist/index.js.map +1 -1
- package/dist/{universal-installer-EVBDGOWM.js → universal-installer-AAXXYM5A.js} +138 -1
- package/dist/universal-installer-AAXXYM5A.js.map +1 -0
- package/package.json +1 -1
- package/dist/universal-installer-EVBDGOWM.js.map +0 -1
package/dist/cli/index.js
CHANGED
|
@@ -3490,7 +3490,7 @@ Customize the workflows in your workflows/ directory.`);
|
|
|
3490
3490
|
}
|
|
3491
3491
|
return;
|
|
3492
3492
|
}
|
|
3493
|
-
const { universalInstall } = await import("../universal-installer-
|
|
3493
|
+
const { universalInstall } = await import("../universal-installer-AAXXYM5A.js");
|
|
3494
3494
|
const result = await universalInstall(dir, source, {
|
|
3495
3495
|
type: opts.type,
|
|
3496
3496
|
id: opts.id,
|
package/dist/index.js
CHANGED
|
@@ -12496,6 +12496,130 @@ async function resolveGithubCommitSha(url) {
|
|
|
12496
12496
|
clearTimeout(timeout);
|
|
12497
12497
|
}
|
|
12498
12498
|
}
|
|
12499
|
+
var SIBLING_LICENSE_NAMES = [
|
|
12500
|
+
"LICENSE",
|
|
12501
|
+
"LICENSE.txt",
|
|
12502
|
+
"LICENSE.md",
|
|
12503
|
+
"COPYING",
|
|
12504
|
+
"COPYING.txt"
|
|
12505
|
+
];
|
|
12506
|
+
function classifyLicenseText(text) {
|
|
12507
|
+
const lower = text.toLowerCase();
|
|
12508
|
+
if (lower.includes("all rights reserved")) {
|
|
12509
|
+
return "PROPRIETARY";
|
|
12510
|
+
}
|
|
12511
|
+
if (lower.includes("mit license")) return "MIT";
|
|
12512
|
+
if (lower.includes("apache license, version 2.0") || lower.includes("apache-2.0"))
|
|
12513
|
+
return "Apache-2.0";
|
|
12514
|
+
if (lower.includes("mozilla public license version 2.0") || lower.includes("mpl-2.0"))
|
|
12515
|
+
return "MPL-2.0";
|
|
12516
|
+
if (lower.includes("gnu affero general public license")) return "AGPL-3.0";
|
|
12517
|
+
if (lower.includes("gnu lesser general public license")) {
|
|
12518
|
+
if (lower.includes("version 3")) return "LGPL-3.0";
|
|
12519
|
+
if (lower.includes("version 2")) return "LGPL-2.1";
|
|
12520
|
+
}
|
|
12521
|
+
if (lower.includes("gnu general public license")) {
|
|
12522
|
+
if (lower.includes("version 3")) return "GPL-3.0";
|
|
12523
|
+
if (lower.includes("version 2")) return "GPL-2.0";
|
|
12524
|
+
}
|
|
12525
|
+
if (lower.includes("isc license")) return "ISC";
|
|
12526
|
+
if (lower.includes("cc0 1.0 universal") || lower.includes("cc0-1.0")) return "CC0-1.0";
|
|
12527
|
+
if (lower.includes("creative commons attribution-sharealike 4.0")) return "CC-BY-SA-4.0";
|
|
12528
|
+
if (lower.includes("creative commons attribution 4.0") || lower.includes("cc-by-4.0"))
|
|
12529
|
+
return "CC-BY-4.0";
|
|
12530
|
+
if (lower.includes("redistribution and use in source and binary forms") && lower.includes("neither the name of")) {
|
|
12531
|
+
return "BSD-3-Clause";
|
|
12532
|
+
}
|
|
12533
|
+
if (lower.includes("redistribution and use in source and binary forms")) {
|
|
12534
|
+
return "BSD-2-Clause";
|
|
12535
|
+
}
|
|
12536
|
+
if (lower.includes("this is free and unencumbered software released into the public domain")) {
|
|
12537
|
+
return "Unlicense";
|
|
12538
|
+
}
|
|
12539
|
+
return "UNKNOWN";
|
|
12540
|
+
}
|
|
12541
|
+
function extractCopyright(text) {
|
|
12542
|
+
const lines = text.split(/\r?\n/);
|
|
12543
|
+
for (const line of lines) {
|
|
12544
|
+
const trimmed = line.trim();
|
|
12545
|
+
if (/^©\s*\d{4}/.test(trimmed) || /^copyright\b.*\d{4}/i.test(trimmed)) {
|
|
12546
|
+
return trimmed;
|
|
12547
|
+
}
|
|
12548
|
+
}
|
|
12549
|
+
return void 0;
|
|
12550
|
+
}
|
|
12551
|
+
async function fetchSiblingLicense(siblingUrl) {
|
|
12552
|
+
const controller = new AbortController();
|
|
12553
|
+
const timeout = setTimeout(() => controller.abort(), 5e3);
|
|
12554
|
+
try {
|
|
12555
|
+
const response = await fetch(siblingUrl, { signal: controller.signal });
|
|
12556
|
+
if (!response.ok) return null;
|
|
12557
|
+
return await response.text();
|
|
12558
|
+
} catch {
|
|
12559
|
+
return null;
|
|
12560
|
+
} finally {
|
|
12561
|
+
clearTimeout(timeout);
|
|
12562
|
+
}
|
|
12563
|
+
}
|
|
12564
|
+
async function fetchGithubRepoLicense(owner, repo) {
|
|
12565
|
+
const apiUrl = `https://api.github.com/repos/${owner}/${repo}/license`;
|
|
12566
|
+
const controller = new AbortController();
|
|
12567
|
+
const timeout = setTimeout(() => controller.abort(), 5e3);
|
|
12568
|
+
try {
|
|
12569
|
+
const response = await fetch(apiUrl, {
|
|
12570
|
+
signal: controller.signal,
|
|
12571
|
+
headers: { "Accept": "application/vnd.github+json" }
|
|
12572
|
+
});
|
|
12573
|
+
if (!response.ok) return null;
|
|
12574
|
+
const data = await response.json();
|
|
12575
|
+
const spdxId = data.license?.spdx_id;
|
|
12576
|
+
if (!spdxId || spdxId === "NOASSERTION") return null;
|
|
12577
|
+
let body;
|
|
12578
|
+
if (data.content && data.encoding === "base64") {
|
|
12579
|
+
try {
|
|
12580
|
+
body = Buffer.from(data.content, "base64").toString("utf-8");
|
|
12581
|
+
} catch {
|
|
12582
|
+
body = void 0;
|
|
12583
|
+
}
|
|
12584
|
+
}
|
|
12585
|
+
return { spdxId, htmlUrl: data.html_url ?? "", body };
|
|
12586
|
+
} catch {
|
|
12587
|
+
return null;
|
|
12588
|
+
} finally {
|
|
12589
|
+
clearTimeout(timeout);
|
|
12590
|
+
}
|
|
12591
|
+
}
|
|
12592
|
+
async function detectLicense(sourceUrl) {
|
|
12593
|
+
const match2 = sourceUrl.match(
|
|
12594
|
+
/^https?:\/\/raw\.githubusercontent\.com\/([^/]+)\/([^/]+)\/([^/]+)\/(.+)$/
|
|
12595
|
+
);
|
|
12596
|
+
if (!match2) {
|
|
12597
|
+
return { spdxId: "UNKNOWN" };
|
|
12598
|
+
}
|
|
12599
|
+
const [, owner, repo, ref, path] = match2;
|
|
12600
|
+
const lastSlash = path.lastIndexOf("/");
|
|
12601
|
+
const dir = lastSlash >= 0 ? path.slice(0, lastSlash) : "";
|
|
12602
|
+
const dirPrefix = dir ? `${dir}/` : "";
|
|
12603
|
+
for (const siblingName of SIBLING_LICENSE_NAMES) {
|
|
12604
|
+
const siblingUrl = `https://raw.githubusercontent.com/${owner}/${repo}/${ref}/${dirPrefix}${siblingName}`;
|
|
12605
|
+
const text = await fetchSiblingLicense(siblingUrl);
|
|
12606
|
+
if (text) {
|
|
12607
|
+
const spdxId = classifyLicenseText(text);
|
|
12608
|
+
const copyright = extractCopyright(text);
|
|
12609
|
+
return { spdxId, copyright, licenseSource: siblingUrl };
|
|
12610
|
+
}
|
|
12611
|
+
}
|
|
12612
|
+
const repoLicense = await fetchGithubRepoLicense(owner, repo);
|
|
12613
|
+
if (repoLicense) {
|
|
12614
|
+
const copyright = repoLicense.body ? extractCopyright(repoLicense.body) : void 0;
|
|
12615
|
+
return {
|
|
12616
|
+
spdxId: repoLicense.spdxId,
|
|
12617
|
+
copyright,
|
|
12618
|
+
licenseSource: repoLicense.htmlUrl || void 0
|
|
12619
|
+
};
|
|
12620
|
+
}
|
|
12621
|
+
return { spdxId: "UNKNOWN" };
|
|
12622
|
+
}
|
|
12499
12623
|
async function recordProvenance(content, originalSource) {
|
|
12500
12624
|
let parsed;
|
|
12501
12625
|
try {
|
|
@@ -12513,6 +12637,18 @@ async function recordProvenance(content, originalSource) {
|
|
|
12513
12637
|
data.source_commit = sha;
|
|
12514
12638
|
}
|
|
12515
12639
|
}
|
|
12640
|
+
if (!data.license || !data.copyright || !data.license_source) {
|
|
12641
|
+
const license = await detectLicense(originalSource);
|
|
12642
|
+
if (!data.license) {
|
|
12643
|
+
data.license = license.spdxId;
|
|
12644
|
+
}
|
|
12645
|
+
if (!data.copyright && license.copyright) {
|
|
12646
|
+
data.copyright = license.copyright;
|
|
12647
|
+
}
|
|
12648
|
+
if (!data.license_source && license.licenseSource) {
|
|
12649
|
+
data.license_source = license.licenseSource;
|
|
12650
|
+
}
|
|
12651
|
+
}
|
|
12516
12652
|
data.installed_at = (/* @__PURE__ */ new Date()).toISOString();
|
|
12517
12653
|
data.installed_by = `agent-harness@${getHarnessVersion()}`;
|
|
12518
12654
|
return matter4.stringify(parsed.content, data);
|