@moldea.ai/core 2.0.2 → 2.1.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 +20 -1
- package/dist/contracts/index.d.ts +11 -0
- package/dist/contracts/index.d.ts.map +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/exceptions/index.d.ts +1 -1
- package/dist/exceptions/index.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +484 -98
- package/dist/index.js.map +1 -1
- package/dist/manifest/index.d.ts +2 -2
- package/dist/manifest/index.d.ts.map +1 -1
- package/dist/scope-matching/index.d.ts +5 -0
- package/dist/scope-matching/index.d.ts.map +1 -0
- package/dist/scope-matching/matching.d.ts +20 -0
- package/dist/scope-matching/matching.d.ts.map +1 -0
- package/dist/scope-matching/scope.d.ts +14 -0
- package/dist/scope-matching/scope.d.ts.map +1 -0
- package/dist/scope-matching/types.d.ts +48 -0
- package/dist/scope-matching/types.d.ts.map +1 -0
- package/dist/scope-matching/validations.d.ts +21 -0
- package/dist/scope-matching/validations.d.ts.map +1 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -745,7 +745,7 @@ var invalidAdapter = (adapterId) => {
|
|
|
745
745
|
operation: "create-core"
|
|
746
746
|
});
|
|
747
747
|
};
|
|
748
|
-
var isRecord$
|
|
748
|
+
var isRecord$4 = (value) => {
|
|
749
749
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
750
750
|
};
|
|
751
751
|
var isStableId = (value) => {
|
|
@@ -760,7 +760,7 @@ var isStableId = (value) => {
|
|
|
760
760
|
*/
|
|
761
761
|
var normalizeLimits = (candidate) => {
|
|
762
762
|
if (candidate === void 0) return DEFAULT_CORE_RESOURCE_LIMITS;
|
|
763
|
-
if (!isRecord$
|
|
763
|
+
if (!isRecord$4(candidate)) throw new CoreConfigurationException({
|
|
764
764
|
code: "INVALID_RESOURCE_LIMIT",
|
|
765
765
|
operation: "create-core"
|
|
766
766
|
});
|
|
@@ -790,7 +790,7 @@ var normalizeLimits = (candidate) => {
|
|
|
790
790
|
* - INVALID_ADAPTER_DEFINITION: A runtime adapter definition is invalid.
|
|
791
791
|
*/
|
|
792
792
|
var normalizeAdapter = (candidate) => {
|
|
793
|
-
if (!isRecord$
|
|
793
|
+
if (!isRecord$4(candidate)) return invalidAdapter();
|
|
794
794
|
const id = candidate["id"];
|
|
795
795
|
if (typeof id !== "string" || !isStableId(id) || WINDOWS_RESERVED_ID_PATTERN.test(id)) return invalidAdapter();
|
|
796
796
|
if (id === "custom") throw new CoreConfigurationException({
|
|
@@ -849,7 +849,7 @@ var normalizeAdapters = (candidate) => {
|
|
|
849
849
|
* - INVALID_RESOURCE_LIMIT: A Core resource limit is invalid.
|
|
850
850
|
*/
|
|
851
851
|
var normalizeCoreOptions = (options) => {
|
|
852
|
-
if (options !== void 0 && !isRecord$
|
|
852
|
+
if (options !== void 0 && !isRecord$4(options)) return invalidAdapter();
|
|
853
853
|
return freezeRecursively({
|
|
854
854
|
adapters: normalizeAdapters(options?.["adapters"]),
|
|
855
855
|
limits: normalizeLimits(options?.["limits"])
|
|
@@ -909,7 +909,7 @@ var decoder = new TextDecoder("utf-8", {
|
|
|
909
909
|
fatal: true,
|
|
910
910
|
ignoreBOM: true
|
|
911
911
|
});
|
|
912
|
-
var isRecord$
|
|
912
|
+
var isRecord$3 = (value) => {
|
|
913
913
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
914
914
|
};
|
|
915
915
|
/**
|
|
@@ -982,7 +982,7 @@ var collectNulDiagnostics = (value, path, diagnostics) => {
|
|
|
982
982
|
offset += 1;
|
|
983
983
|
}
|
|
984
984
|
};
|
|
985
|
-
var invalidArgument$
|
|
985
|
+
var invalidArgument$2 = (operation) => {
|
|
986
986
|
throw new CoreOperationException({
|
|
987
987
|
code: "INVALID_ARGUMENT",
|
|
988
988
|
operation
|
|
@@ -1017,10 +1017,10 @@ var invalidResult = (diagnostics) => {
|
|
|
1017
1017
|
* - RESOURCE_LIMIT_EXCEEDED: A Core resource limit was exceeded.
|
|
1018
1018
|
*/
|
|
1019
1019
|
var readInput = (input, limits, operation, limit, diagnostics) => {
|
|
1020
|
-
if (!isRecord$
|
|
1020
|
+
if (!isRecord$3(input)) return invalidArgument$2(operation);
|
|
1021
1021
|
const pathCandidate = input["path"];
|
|
1022
1022
|
const content = input["content"];
|
|
1023
|
-
if (typeof pathCandidate !== "string" || typeof content !== "string" && !(content instanceof Uint8Array)) return invalidArgument$
|
|
1023
|
+
if (typeof pathCandidate !== "string" || typeof content !== "string" && !(content instanceof Uint8Array)) return invalidArgument$2(operation);
|
|
1024
1024
|
const path = parseRepositoryPath(pathCandidate);
|
|
1025
1025
|
if (typeof content === "string") {
|
|
1026
1026
|
const byteLength = measureScalarUtf8ByteLength(content, limits[limit]);
|
|
@@ -1409,7 +1409,7 @@ var parseDecisionDocument = async (input, options, operation = "parse-decision")
|
|
|
1409
1409
|
};
|
|
1410
1410
|
//#endregion
|
|
1411
1411
|
//#region src/manifest-validation/index.ts
|
|
1412
|
-
var childPointer$
|
|
1412
|
+
var childPointer$2 = (pointer, key) => {
|
|
1413
1413
|
return `${pointer}/${escapeJsonPointerSegment(key)}`;
|
|
1414
1414
|
};
|
|
1415
1415
|
var addInvalidValue = (context, pointer, range, reason, entity = null) => {
|
|
@@ -1439,7 +1439,7 @@ var readMapping = (node, pointer, allowedProperties, context, entity = null) =>
|
|
|
1439
1439
|
code: "MOLDEA_MANIFEST_PROPERTY_UNKNOWN",
|
|
1440
1440
|
entity,
|
|
1441
1441
|
path: context.path,
|
|
1442
|
-
pointer: childPointer$
|
|
1442
|
+
pointer: childPointer$2(pointer, key),
|
|
1443
1443
|
range: entry.key.range
|
|
1444
1444
|
});
|
|
1445
1445
|
continue;
|
|
@@ -1500,7 +1500,7 @@ var readReference = (node, pointer, context, entity = null) => {
|
|
|
1500
1500
|
details: { reason: pathEntry === void 0 ? "missing" : "type" },
|
|
1501
1501
|
entity,
|
|
1502
1502
|
path: context.path,
|
|
1503
|
-
pointer: childPointer$
|
|
1503
|
+
pointer: childPointer$2(pointer, "path"),
|
|
1504
1504
|
range: pathEntry?.value.range ?? null
|
|
1505
1505
|
});
|
|
1506
1506
|
return null;
|
|
@@ -1511,7 +1511,7 @@ var readReference = (node, pointer, context, entity = null) => {
|
|
|
1511
1511
|
code: "MOLDEA_PATH_INVALID",
|
|
1512
1512
|
entity,
|
|
1513
1513
|
path: context.path,
|
|
1514
|
-
pointer: childPointer$
|
|
1514
|
+
pointer: childPointer$2(pointer, "path"),
|
|
1515
1515
|
range: pathEntry.value.range
|
|
1516
1516
|
});
|
|
1517
1517
|
return null;
|
|
@@ -1523,7 +1523,7 @@ var readReference = (node, pointer, context, entity = null) => {
|
|
|
1523
1523
|
code: "MOLDEA_SYMBOL_INVALID",
|
|
1524
1524
|
entity,
|
|
1525
1525
|
path: context.path,
|
|
1526
|
-
pointer: childPointer$
|
|
1526
|
+
pointer: childPointer$2(pointer, "symbol"),
|
|
1527
1527
|
range: symbolEntry.value.range
|
|
1528
1528
|
});
|
|
1529
1529
|
return null;
|
|
@@ -1533,7 +1533,7 @@ var readReference = (node, pointer, context, entity = null) => {
|
|
|
1533
1533
|
code: "MOLDEA_SYMBOL_FORBIDDEN",
|
|
1534
1534
|
entity,
|
|
1535
1535
|
path: context.path,
|
|
1536
|
-
pointer: childPointer$
|
|
1536
|
+
pointer: childPointer$2(pointer, "symbol"),
|
|
1537
1537
|
range: symbolEntry.value.range
|
|
1538
1538
|
});
|
|
1539
1539
|
return null;
|
|
@@ -1551,7 +1551,7 @@ var readReferenceList = (node, pointer, context, entity = null) => {
|
|
|
1551
1551
|
const references = [];
|
|
1552
1552
|
const seen = /* @__PURE__ */ new Set();
|
|
1553
1553
|
node.items.forEach((item, index) => {
|
|
1554
|
-
const reference = readReference(item, childPointer$
|
|
1554
|
+
const reference = readReference(item, childPointer$2(pointer, String(index)), context, entity);
|
|
1555
1555
|
if (reference === null) return;
|
|
1556
1556
|
const key = `${reference.path}\0${reference.symbol ?? ""}`;
|
|
1557
1557
|
if (seen.has(key)) {
|
|
@@ -1559,7 +1559,7 @@ var readReferenceList = (node, pointer, context, entity = null) => {
|
|
|
1559
1559
|
code: "MOLDEA_PATH_DUPLICATE",
|
|
1560
1560
|
entity,
|
|
1561
1561
|
path: context.path,
|
|
1562
|
-
pointer: childPointer$
|
|
1562
|
+
pointer: childPointer$2(pointer, String(index)),
|
|
1563
1563
|
range: item.range
|
|
1564
1564
|
});
|
|
1565
1565
|
return;
|
|
@@ -1577,7 +1577,7 @@ var readAffectedBy = (node, pointer, context, entity = null) => {
|
|
|
1577
1577
|
const values = [];
|
|
1578
1578
|
const seen = /* @__PURE__ */ new Set();
|
|
1579
1579
|
node.items.forEach((item, index) => {
|
|
1580
|
-
const itemPointer = childPointer$
|
|
1580
|
+
const itemPointer = childPointer$2(pointer, String(index));
|
|
1581
1581
|
if (item.kind !== "scalar" || typeof item.value !== "string") {
|
|
1582
1582
|
addInvalidValue(context, itemPointer, item.range, "string-required", entity);
|
|
1583
1583
|
return;
|
|
@@ -1620,8 +1620,8 @@ var readRelationship = (node, pointer, context) => {
|
|
|
1620
1620
|
range: node.range
|
|
1621
1621
|
});
|
|
1622
1622
|
return {
|
|
1623
|
-
...bindingsEntry === void 0 ? {} : { bindings: readReferenceList(bindingsEntry.value, childPointer$
|
|
1624
|
-
...affectedByEntry === void 0 ? {} : { affectedBy: readAffectedBy(affectedByEntry.value, childPointer$
|
|
1623
|
+
...bindingsEntry === void 0 ? {} : { bindings: readReferenceList(bindingsEntry.value, childPointer$2(pointer, "bindings"), context) },
|
|
1624
|
+
...affectedByEntry === void 0 ? {} : { affectedBy: readAffectedBy(affectedByEntry.value, childPointer$2(pointer, "affectedBy"), context) }
|
|
1625
1625
|
};
|
|
1626
1626
|
};
|
|
1627
1627
|
var readRelationshipRecord = (node, pointer, kind, context) => {
|
|
@@ -1634,12 +1634,12 @@ var readRelationshipRecord = (node, pointer, kind, context) => {
|
|
|
1634
1634
|
context.diagnostics.add({
|
|
1635
1635
|
code: kind === "context" ? "MOLDEA_CONTEXT_PATH_INVALID" : "MOLDEA_DECISION_FILENAME_INVALID",
|
|
1636
1636
|
path: context.path,
|
|
1637
|
-
pointer: childPointer$
|
|
1637
|
+
pointer: childPointer$2(pointer, key),
|
|
1638
1638
|
range: entry.key.range
|
|
1639
1639
|
});
|
|
1640
1640
|
continue;
|
|
1641
1641
|
}
|
|
1642
|
-
const relationship = readRelationship(entry.value, childPointer$
|
|
1642
|
+
const relationship = readRelationship(entry.value, childPointer$2(pointer, key), context);
|
|
1643
1643
|
if (relationship !== null) normalized.push([key, relationship]);
|
|
1644
1644
|
}
|
|
1645
1645
|
return createNullPrototypeRecord(normalized);
|
|
@@ -1652,7 +1652,7 @@ var readPathList = (node, pointer, kind, context, entity) => {
|
|
|
1652
1652
|
const paths = [];
|
|
1653
1653
|
const seen = /* @__PURE__ */ new Set();
|
|
1654
1654
|
node.items.forEach((item, index) => {
|
|
1655
|
-
const itemPointer = childPointer$
|
|
1655
|
+
const itemPointer = childPointer$2(pointer, String(index));
|
|
1656
1656
|
if (item.kind !== "scalar" || typeof item.value !== "string") {
|
|
1657
1657
|
addInvalidValue(context, itemPointer, item.range, "string-required", entity);
|
|
1658
1658
|
return;
|
|
@@ -1705,7 +1705,7 @@ var readRuntime = (node, pointer, context, agentId) => {
|
|
|
1705
1705
|
code: "MOLDEA_RUNTIME_ID_INVALID",
|
|
1706
1706
|
entity,
|
|
1707
1707
|
path: context.path,
|
|
1708
|
-
pointer: childPointer$
|
|
1708
|
+
pointer: childPointer$2(pointer, "id"),
|
|
1709
1709
|
range: idEntry?.value.range ?? null
|
|
1710
1710
|
});
|
|
1711
1711
|
return null;
|
|
@@ -1715,14 +1715,14 @@ var readRuntime = (node, pointer, context, agentId) => {
|
|
|
1715
1715
|
code: "MOLDEA_RUNTIME_ID_INVALID",
|
|
1716
1716
|
entity,
|
|
1717
1717
|
path: context.path,
|
|
1718
|
-
pointer: childPointer$
|
|
1718
|
+
pointer: childPointer$2(pointer, "id"),
|
|
1719
1719
|
range: idEntry.value.range
|
|
1720
1720
|
});
|
|
1721
1721
|
else context.runtimeLocations.push({
|
|
1722
1722
|
adapterId: id,
|
|
1723
1723
|
agentId,
|
|
1724
1724
|
path: context.path,
|
|
1725
|
-
pointer: childPointer$
|
|
1725
|
+
pointer: childPointer$2(pointer, "id"),
|
|
1726
1726
|
range: idEntry.value.range
|
|
1727
1727
|
});
|
|
1728
1728
|
const guidanceEntry = entries.get("guidance");
|
|
@@ -1736,7 +1736,7 @@ var readRuntime = (node, pointer, context, agentId) => {
|
|
|
1736
1736
|
details: { reason: "runtime-guidance" },
|
|
1737
1737
|
entity,
|
|
1738
1738
|
path: context.path,
|
|
1739
|
-
pointer: childPointer$
|
|
1739
|
+
pointer: childPointer$2(pointer, "guidance"),
|
|
1740
1740
|
range: guidanceEntry.value.range
|
|
1741
1741
|
});
|
|
1742
1742
|
} else context.diagnostics.add({
|
|
@@ -1744,7 +1744,7 @@ var readRuntime = (node, pointer, context, agentId) => {
|
|
|
1744
1744
|
details: { reason: "runtime-guidance" },
|
|
1745
1745
|
entity,
|
|
1746
1746
|
path: context.path,
|
|
1747
|
-
pointer: childPointer$
|
|
1747
|
+
pointer: childPointer$2(pointer, "guidance"),
|
|
1748
1748
|
range: guidanceEntry.value.range
|
|
1749
1749
|
});
|
|
1750
1750
|
}
|
|
@@ -1766,13 +1766,13 @@ var readVariables = (node, pointer, context, agentId) => {
|
|
|
1766
1766
|
code: "MOLDEA_VARIABLE_ID_INVALID",
|
|
1767
1767
|
entity,
|
|
1768
1768
|
path: context.path,
|
|
1769
|
-
pointer: childPointer$
|
|
1769
|
+
pointer: childPointer$2(pointer, variableId),
|
|
1770
1770
|
range: entry.key.range
|
|
1771
1771
|
});
|
|
1772
|
-
const variablePointer = childPointer$
|
|
1772
|
+
const variablePointer = childPointer$2(pointer, variableId);
|
|
1773
1773
|
const variableEntries = readMapping(entry.value, variablePointer, /* @__PURE__ */ new Set(["description"]), context, entity);
|
|
1774
1774
|
if (variableEntries === null) continue;
|
|
1775
|
-
const description = readString(variableEntries.get("description"), childPointer$
|
|
1775
|
+
const description = readString(variableEntries.get("description"), childPointer$2(variablePointer, "description"), context, {
|
|
1776
1776
|
entity,
|
|
1777
1777
|
required: true
|
|
1778
1778
|
});
|
|
@@ -1792,7 +1792,7 @@ var readBindings = (node, pointer, context, agentId, declaredVariables) => {
|
|
|
1792
1792
|
if (entries === null) return null;
|
|
1793
1793
|
const referenceProperty = (key) => {
|
|
1794
1794
|
const entry = entries.get(key);
|
|
1795
|
-
return entry === void 0 ? null : readReference(entry.value, childPointer$
|
|
1795
|
+
return entry === void 0 ? null : readReference(entry.value, childPointer$2(pointer, key), context, entity);
|
|
1796
1796
|
};
|
|
1797
1797
|
const inputSchema = referenceProperty("inputSchema");
|
|
1798
1798
|
const instructionLoader = referenceProperty("instructionLoader");
|
|
@@ -1801,7 +1801,7 @@ var readBindings = (node, pointer, context, agentId, declaredVariables) => {
|
|
|
1801
1801
|
const providersEntry = entries.get("variableProviders");
|
|
1802
1802
|
let variableProviders = null;
|
|
1803
1803
|
if (providersEntry !== void 0) {
|
|
1804
|
-
const providers = readMapping(providersEntry.value, childPointer$
|
|
1804
|
+
const providers = readMapping(providersEntry.value, childPointer$2(pointer, "variableProviders"), null, context, entity);
|
|
1805
1805
|
if (providers !== null) {
|
|
1806
1806
|
const normalized = [];
|
|
1807
1807
|
for (const [variableId, providerEntry] of [...providers].sort(([left], [right]) => compareExactStrings(left, right))) {
|
|
@@ -1809,7 +1809,7 @@ var readBindings = (node, pointer, context, agentId, declaredVariables) => {
|
|
|
1809
1809
|
agentId,
|
|
1810
1810
|
variableId
|
|
1811
1811
|
};
|
|
1812
|
-
const providerPointer = childPointer$
|
|
1812
|
+
const providerPointer = childPointer$2(childPointer$2(pointer, "variableProviders"), variableId);
|
|
1813
1813
|
if (!isVariableId(variableId)) context.diagnostics.add({
|
|
1814
1814
|
code: "MOLDEA_VARIABLE_ID_INVALID",
|
|
1815
1815
|
entity: variableEntity,
|
|
@@ -1860,7 +1860,7 @@ var readCapability$1 = (node, pointer, context, agentId, capabilityId, kind) =>
|
|
|
1860
1860
|
"registration"
|
|
1861
1861
|
]), context, entity);
|
|
1862
1862
|
if (entries === null) return null;
|
|
1863
|
-
const name = readString(entries.get("name"), childPointer$
|
|
1863
|
+
const name = readString(entries.get("name"), childPointer$2(pointer, "name"), context, {
|
|
1864
1864
|
entity,
|
|
1865
1865
|
required: true,
|
|
1866
1866
|
singleLine: true
|
|
@@ -1871,13 +1871,13 @@ var readCapability$1 = (node, pointer, context, agentId, capabilityId, kind) =>
|
|
|
1871
1871
|
code: "MOLDEA_CAPABILITY_DESCRIPTION_MISSING",
|
|
1872
1872
|
entity,
|
|
1873
1873
|
path: context.path,
|
|
1874
|
-
pointer: childPointer$
|
|
1874
|
+
pointer: childPointer$2(pointer, "description")
|
|
1875
1875
|
});
|
|
1876
1876
|
else if (descriptionEntry.value.kind !== "scalar" || typeof descriptionEntry.value.value !== "string" || !isCapabilityDescription(descriptionEntry.value.value)) context.diagnostics.add({
|
|
1877
1877
|
code: "MOLDEA_CAPABILITY_DESCRIPTION_INVALID",
|
|
1878
1878
|
entity,
|
|
1879
1879
|
path: context.path,
|
|
1880
|
-
pointer: childPointer$
|
|
1880
|
+
pointer: childPointer$2(pointer, "description"),
|
|
1881
1881
|
range: descriptionEntry.value.range
|
|
1882
1882
|
});
|
|
1883
1883
|
else description = descriptionEntry.value.value;
|
|
@@ -1887,18 +1887,18 @@ var readCapability$1 = (node, pointer, context, agentId, capabilityId, kind) =>
|
|
|
1887
1887
|
code: kind === "tool" ? "MOLDEA_TOOL_IMPLEMENTATION_MISSING" : "MOLDEA_SKILL_IMPLEMENTATION_MISSING",
|
|
1888
1888
|
entity,
|
|
1889
1889
|
path: context.path,
|
|
1890
|
-
pointer: childPointer$
|
|
1890
|
+
pointer: childPointer$2(pointer, "implementation")
|
|
1891
1891
|
});
|
|
1892
|
-
else implementation = readReference(implementationEntry.value, childPointer$
|
|
1892
|
+
else implementation = readReference(implementationEntry.value, childPointer$2(pointer, "implementation"), context, entity);
|
|
1893
1893
|
const optionalReference = (key) => {
|
|
1894
1894
|
const entry = entries.get(key);
|
|
1895
|
-
return entry === void 0 ? null : readReference(entry.value, childPointer$
|
|
1895
|
+
return entry === void 0 ? null : readReference(entry.value, childPointer$2(pointer, key), context, entity);
|
|
1896
1896
|
};
|
|
1897
1897
|
const registration = optionalReference("registration");
|
|
1898
1898
|
const inputSchema = kind === "tool" ? optionalReference("inputSchema") : null;
|
|
1899
1899
|
const outputSchema = kind === "tool" ? optionalReference("outputSchema") : null;
|
|
1900
1900
|
const affectedByEntry = entries.get("affectedBy");
|
|
1901
|
-
const affectedBy = affectedByEntry === void 0 ? null : readAffectedBy(affectedByEntry.value, childPointer$
|
|
1901
|
+
const affectedBy = affectedByEntry === void 0 ? null : readAffectedBy(affectedByEntry.value, childPointer$2(pointer, "affectedBy"), context, entity);
|
|
1902
1902
|
if (name === null || description === null || implementation === null) return null;
|
|
1903
1903
|
return {
|
|
1904
1904
|
name,
|
|
@@ -1920,7 +1920,7 @@ var readCapabilities = (node, pointer, context, agentId, kind) => {
|
|
|
1920
1920
|
capabilityId,
|
|
1921
1921
|
capabilityKind: kind
|
|
1922
1922
|
};
|
|
1923
|
-
const capabilityPointer = childPointer$
|
|
1923
|
+
const capabilityPointer = childPointer$2(pointer, capabilityId);
|
|
1924
1924
|
validateStableId(capabilityId, entry.key.range, capabilityPointer, context, entity);
|
|
1925
1925
|
const capability = readCapability$1(entry.value, capabilityPointer, context, agentId, capabilityId, kind);
|
|
1926
1926
|
if (capability !== null) normalized.push([capabilityId, capability]);
|
|
@@ -1933,7 +1933,7 @@ var readUnresolved = (node, pointer, context, agentId) => {
|
|
|
1933
1933
|
const normalized = [];
|
|
1934
1934
|
for (const [requirementId, entry] of [...entries].sort(([left], [right]) => compareExactStrings(left, right))) {
|
|
1935
1935
|
const entity = agentId === void 0 ? null : { agentId };
|
|
1936
|
-
const requirementPointer = childPointer$
|
|
1936
|
+
const requirementPointer = childPointer$2(pointer, requirementId);
|
|
1937
1937
|
validateStableId(requirementId, entry.key.range, requirementPointer, context, entity);
|
|
1938
1938
|
const requirementEntries = readMapping(entry.value, requirementPointer, /* @__PURE__ */ new Set([
|
|
1939
1939
|
"category",
|
|
@@ -1944,7 +1944,7 @@ var readUnresolved = (node, pointer, context, agentId) => {
|
|
|
1944
1944
|
"resolution"
|
|
1945
1945
|
]), context, entity);
|
|
1946
1946
|
if (requirementEntries === null) continue;
|
|
1947
|
-
const category = readString(requirementEntries.get("category"), childPointer$
|
|
1947
|
+
const category = readString(requirementEntries.get("category"), childPointer$2(requirementPointer, "category"), context, {
|
|
1948
1948
|
...entity === null ? {} : { entity },
|
|
1949
1949
|
required: true
|
|
1950
1950
|
});
|
|
@@ -1952,24 +1952,24 @@ var readUnresolved = (node, pointer, context, agentId) => {
|
|
|
1952
1952
|
code: "MOLDEA_ID_INVALID",
|
|
1953
1953
|
entity,
|
|
1954
1954
|
path: context.path,
|
|
1955
|
-
pointer: childPointer$
|
|
1955
|
+
pointer: childPointer$2(requirementPointer, "category"),
|
|
1956
1956
|
range: requirementEntries.get("category")?.value.range ?? null
|
|
1957
1957
|
});
|
|
1958
1958
|
const effectEntry = requirementEntries.get("effect");
|
|
1959
1959
|
let effect = null;
|
|
1960
1960
|
if (effectEntry?.value.kind === "scalar" && (effectEntry.value.value === "blocking" || effectEntry.value.value === "warning" || effectEntry.value.value === "informational")) effect = effectEntry.value.value;
|
|
1961
|
-
else addInvalidValue(context, childPointer$
|
|
1962
|
-
const description = readString(requirementEntries.get("description"), childPointer$
|
|
1961
|
+
else addInvalidValue(context, childPointer$2(requirementPointer, "effect"), effectEntry?.value.range ?? null, effectEntry === void 0 ? "required" : "enum", entity);
|
|
1962
|
+
const description = readString(requirementEntries.get("description"), childPointer$2(requirementPointer, "description"), context, {
|
|
1963
1963
|
...entity === null ? {} : { entity },
|
|
1964
1964
|
required: true
|
|
1965
1965
|
});
|
|
1966
|
-
const resolution = readString(requirementEntries.get("resolution"), childPointer$
|
|
1966
|
+
const resolution = readString(requirementEntries.get("resolution"), childPointer$2(requirementPointer, "resolution"), context, {
|
|
1967
1967
|
...entity === null ? {} : { entity },
|
|
1968
1968
|
required: true
|
|
1969
1969
|
});
|
|
1970
1970
|
const relatedEntry = requirementEntries.get("related");
|
|
1971
|
-
const related = relatedEntry === void 0 ? null : readReferenceList(relatedEntry.value, childPointer$
|
|
1972
|
-
const reference = readString(requirementEntries.get("reference"), childPointer$
|
|
1971
|
+
const related = relatedEntry === void 0 ? null : readReferenceList(relatedEntry.value, childPointer$2(requirementPointer, "related"), context, entity);
|
|
1972
|
+
const reference = readString(requirementEntries.get("reference"), childPointer$2(requirementPointer, "reference"), context, {
|
|
1973
1973
|
...entity === null ? {} : { entity },
|
|
1974
1974
|
singleLine: true
|
|
1975
1975
|
});
|
|
@@ -2014,7 +2014,7 @@ var validateAgentOwnedIdUniqueness = (node, pointer, context, agentId) => {
|
|
|
2014
2014
|
code: "MOLDEA_ID_DUPLICATE",
|
|
2015
2015
|
entity: { agentId },
|
|
2016
2016
|
path: context.path,
|
|
2017
|
-
pointer: childPointer$
|
|
2017
|
+
pointer: childPointer$2(childPointer$2(pointer, property), entry.key.value),
|
|
2018
2018
|
range: entry.key.range
|
|
2019
2019
|
});
|
|
2020
2020
|
seen.add(entry.key.value);
|
|
@@ -2039,27 +2039,27 @@ var readAgent = (node, pointer, context, agentId) => {
|
|
|
2039
2039
|
validateAgentOwnedIdUniqueness(node, pointer, context, agentId);
|
|
2040
2040
|
const runtimeEntry = entries.get("runtime");
|
|
2041
2041
|
let runtime = null;
|
|
2042
|
-
if (runtimeEntry === void 0) addInvalidValue(context, childPointer$
|
|
2043
|
-
else runtime = readRuntime(runtimeEntry.value, childPointer$
|
|
2042
|
+
if (runtimeEntry === void 0) addInvalidValue(context, childPointer$2(pointer, "runtime"), null, "required", entity);
|
|
2043
|
+
else runtime = readRuntime(runtimeEntry.value, childPointer$2(pointer, "runtime"), context, agentId);
|
|
2044
2044
|
const variablesEntry = entries.get("variables");
|
|
2045
|
-
const variables = variablesEntry === void 0 ? null : readVariables(variablesEntry.value, childPointer$
|
|
2045
|
+
const variables = variablesEntry === void 0 ? null : readVariables(variablesEntry.value, childPointer$2(pointer, "variables"), context, agentId);
|
|
2046
2046
|
const declaredVariables = new Set(Object.keys(variables ?? {}));
|
|
2047
2047
|
const bindingsEntry = entries.get("bindings");
|
|
2048
|
-
const bindings = bindingsEntry === void 0 ? null : readBindings(bindingsEntry.value, childPointer$
|
|
2048
|
+
const bindings = bindingsEntry === void 0 ? null : readBindings(bindingsEntry.value, childPointer$2(pointer, "bindings"), context, agentId, declaredVariables);
|
|
2049
2049
|
const contextEntry = entries.get("context");
|
|
2050
|
-
const contextPaths = contextEntry === void 0 ? null : readPathList(contextEntry.value, childPointer$
|
|
2050
|
+
const contextPaths = contextEntry === void 0 ? null : readPathList(contextEntry.value, childPointer$2(pointer, "context"), "context", context, entity);
|
|
2051
2051
|
const decisionsEntry = entries.get("decisions");
|
|
2052
|
-
const decisions = decisionsEntry === void 0 ? null : readPathList(decisionsEntry.value, childPointer$
|
|
2052
|
+
const decisions = decisionsEntry === void 0 ? null : readPathList(decisionsEntry.value, childPointer$2(pointer, "decisions"), "decision", context, entity);
|
|
2053
2053
|
const toolsEntry = entries.get("tools");
|
|
2054
|
-
const tools = toolsEntry === void 0 ? null : readCapabilities(toolsEntry.value, childPointer$
|
|
2054
|
+
const tools = toolsEntry === void 0 ? null : readCapabilities(toolsEntry.value, childPointer$2(pointer, "tools"), context, agentId, "tool");
|
|
2055
2055
|
const skillsEntry = entries.get("skills");
|
|
2056
|
-
const skills = skillsEntry === void 0 ? null : readCapabilities(skillsEntry.value, childPointer$
|
|
2056
|
+
const skills = skillsEntry === void 0 ? null : readCapabilities(skillsEntry.value, childPointer$2(pointer, "skills"), context, agentId, "skill");
|
|
2057
2057
|
const affectedByEntry = entries.get("affectedBy");
|
|
2058
|
-
const affectedBy = affectedByEntry === void 0 ? null : readAffectedBy(affectedByEntry.value, childPointer$
|
|
2058
|
+
const affectedBy = affectedByEntry === void 0 ? null : readAffectedBy(affectedByEntry.value, childPointer$2(pointer, "affectedBy"), context, entity);
|
|
2059
2059
|
const mirrorsEntry = entries.get("mirrors");
|
|
2060
|
-
const mirrors = mirrorsEntry === void 0 ? null : readPathList(mirrorsEntry.value, childPointer$
|
|
2060
|
+
const mirrors = mirrorsEntry === void 0 ? null : readPathList(mirrorsEntry.value, childPointer$2(pointer, "mirrors"), "mirror", context, entity);
|
|
2061
2061
|
const unresolvedEntry = entries.get("unresolved");
|
|
2062
|
-
const unresolved = unresolvedEntry === void 0 ? null : readUnresolved(unresolvedEntry.value, childPointer$
|
|
2062
|
+
const unresolved = unresolvedEntry === void 0 ? null : readUnresolved(unresolvedEntry.value, childPointer$2(pointer, "unresolved"), context, agentId);
|
|
2063
2063
|
if (runtime === null) return null;
|
|
2064
2064
|
return {
|
|
2065
2065
|
runtime,
|
|
@@ -2079,7 +2079,7 @@ var readAgents = (node, pointer, context) => {
|
|
|
2079
2079
|
if (entries === null) return null;
|
|
2080
2080
|
const normalized = [];
|
|
2081
2081
|
for (const [agentId, entry] of [...entries].sort(([left], [right]) => compareExactStrings(left, right))) {
|
|
2082
|
-
const agentPointer = childPointer$
|
|
2082
|
+
const agentPointer = childPointer$2(pointer, agentId);
|
|
2083
2083
|
validateStableId(agentId, entry.key.range, agentPointer, context, { agentId });
|
|
2084
2084
|
const agent = readAgent(entry.value, agentPointer, context, agentId);
|
|
2085
2085
|
if (agent !== null) normalized.push([agentId, agent]);
|
|
@@ -2230,8 +2230,8 @@ var inspectManifestDocument = async (input, options, operation = "parse-manifest
|
|
|
2230
2230
|
* - INVALID_ARGUMENT: The Core operation received an invalid argument.
|
|
2231
2231
|
* - RESOURCE_LIMIT_EXCEEDED: A Core resource limit was exceeded.
|
|
2232
2232
|
*/
|
|
2233
|
-
var parseManifestDocument = async (input, options) => {
|
|
2234
|
-
const inspection = await inspectManifestDocument(input, options);
|
|
2233
|
+
var parseManifestDocument = async (input, options, operation = "parse-manifest") => {
|
|
2234
|
+
const inspection = await inspectManifestDocument(input, options, operation);
|
|
2235
2235
|
return freezeRecursively({
|
|
2236
2236
|
asset: inspection.asset,
|
|
2237
2237
|
diagnostics: inspection.diagnostics,
|
|
@@ -2333,7 +2333,7 @@ var DIAGNOSTIC_KEYS = /* @__PURE__ */ new Set([
|
|
|
2333
2333
|
]);
|
|
2334
2334
|
var ADAPTER_RESULT_KEYS = /* @__PURE__ */ new Set(["evidence", "diagnostics"]);
|
|
2335
2335
|
var ADAPTER_CODE_PATTERN = /^[A-Z][A-Z0-9_]*$/u;
|
|
2336
|
-
var isRecord$
|
|
2336
|
+
var isRecord$2 = (candidate) => {
|
|
2337
2337
|
return typeof candidate === "object" && candidate !== null && !Array.isArray(candidate);
|
|
2338
2338
|
};
|
|
2339
2339
|
var invalidAdapterResult = (adapterId) => {
|
|
@@ -2365,7 +2365,7 @@ var isSafeString = (candidate) => {
|
|
|
2365
2365
|
return typeof candidate === "string" && isUnicodeScalarText(candidate) && !candidate.includes("\0");
|
|
2366
2366
|
};
|
|
2367
2367
|
var normalizeDetails = (candidate, adapterId) => {
|
|
2368
|
-
if (!isRecord$
|
|
2368
|
+
if (!isRecord$2(candidate)) return invalidAdapterResult(adapterId);
|
|
2369
2369
|
const entries = [];
|
|
2370
2370
|
for (const key of Reflect.ownKeys(candidate)) {
|
|
2371
2371
|
if (typeof key !== "string" || !isUnicodeScalarText(key) || key.includes("\0")) return invalidAdapterResult(adapterId);
|
|
@@ -2378,7 +2378,7 @@ var normalizeDetails = (candidate, adapterId) => {
|
|
|
2378
2378
|
return normalizeDiagnosticDetails(createNullPrototypeRecord(entries));
|
|
2379
2379
|
};
|
|
2380
2380
|
var normalizePosition = (candidate, adapterId) => {
|
|
2381
|
-
if (!isRecord$
|
|
2381
|
+
if (!isRecord$2(candidate) || !hasOnlyKeys(candidate, POSITION_KEYS) || !Number.isSafeInteger(candidate["line"]) || !Number.isSafeInteger(candidate["column"]) || !Number.isSafeInteger(candidate["offset"]) || candidate["line"] < 1 || candidate["column"] < 1 || candidate["offset"] < 0) return invalidAdapterResult(adapterId);
|
|
2382
2382
|
return freezeRecursively({
|
|
2383
2383
|
column: candidate["column"],
|
|
2384
2384
|
line: candidate["line"],
|
|
@@ -2387,7 +2387,7 @@ var normalizePosition = (candidate, adapterId) => {
|
|
|
2387
2387
|
};
|
|
2388
2388
|
var normalizeRange = (candidate, adapterId) => {
|
|
2389
2389
|
if (candidate === null) return null;
|
|
2390
|
-
if (!isRecord$
|
|
2390
|
+
if (!isRecord$2(candidate) || !hasOnlyKeys(candidate, RANGE_KEYS)) return invalidAdapterResult(adapterId);
|
|
2391
2391
|
const start = normalizePosition(candidate["start"], adapterId);
|
|
2392
2392
|
const end = normalizePosition(candidate["end"], adapterId);
|
|
2393
2393
|
if (!(end.line > start.line || end.line === start.line && end.column >= start.column) || end.offset < start.offset) return invalidAdapterResult(adapterId);
|
|
@@ -2405,7 +2405,7 @@ var readCapability = (agent, capabilityKind, capabilityId) => {
|
|
|
2405
2405
|
};
|
|
2406
2406
|
var normalizeEntity = (candidate, context) => {
|
|
2407
2407
|
if (candidate === null) return null;
|
|
2408
|
-
if (!isRecord$
|
|
2408
|
+
if (!isRecord$2(candidate) || !hasOnlyKeys(candidate, DIAGNOSTIC_ENTITY_KEYS)) return invalidAdapterResult(context.adapterId);
|
|
2409
2409
|
const entity = {};
|
|
2410
2410
|
for (const key of DIAGNOSTIC_ENTITY_KEYS) {
|
|
2411
2411
|
const candidateValue = candidate[key];
|
|
@@ -2427,7 +2427,7 @@ var normalizeEntity = (candidate, context) => {
|
|
|
2427
2427
|
return normalizeDiagnosticEntity(entity);
|
|
2428
2428
|
};
|
|
2429
2429
|
var normalizeReference = (candidate, adapterId) => {
|
|
2430
|
-
if (!isRecord$
|
|
2430
|
+
if (!isRecord$2(candidate) || !hasOnlyKeys(candidate, REFERENCE_KEYS)) return invalidAdapterResult(adapterId);
|
|
2431
2431
|
const pathCandidate = candidate["path"];
|
|
2432
2432
|
const symbolCandidate = candidate["symbol"];
|
|
2433
2433
|
if (typeof pathCandidate !== "string" || !isRepositoryPath(pathCandidate)) return invalidAdapterResult(adapterId);
|
|
@@ -2450,7 +2450,7 @@ var normalizeReferences = (candidate, adapterId) => {
|
|
|
2450
2450
|
return freezeRecursively(sortRepositoryReferences(references));
|
|
2451
2451
|
};
|
|
2452
2452
|
var normalizeEvidence = (candidate, context) => {
|
|
2453
|
-
if (!isRecord$
|
|
2453
|
+
if (!isRecord$2(candidate) || !hasOnlyKeys(candidate, EVIDENCE_KEYS)) return invalidAdapterResult(context.adapterId);
|
|
2454
2454
|
const source = candidate["source"];
|
|
2455
2455
|
const kind = candidate["kind"];
|
|
2456
2456
|
const agentId = candidate["agentId"];
|
|
@@ -2484,7 +2484,7 @@ var validateEvidenceReferences = async (evidence, context) => {
|
|
|
2484
2484
|
}
|
|
2485
2485
|
};
|
|
2486
2486
|
var normalizeDiagnostic = (candidate, context) => {
|
|
2487
|
-
if (!isRecord$
|
|
2487
|
+
if (!isRecord$2(candidate) || !hasOnlyKeys(candidate, DIAGNOSTIC_KEYS)) return invalidAdapterResult(context.adapterId);
|
|
2488
2488
|
const source = candidate["source"];
|
|
2489
2489
|
const code = candidate["code"];
|
|
2490
2490
|
const message = candidate["message"];
|
|
@@ -2556,7 +2556,7 @@ var validateRuntimeAdapterResult = async (candidate, context, outputCounts) => {
|
|
|
2556
2556
|
let evidence;
|
|
2557
2557
|
let validationState;
|
|
2558
2558
|
try {
|
|
2559
|
-
if (!isRecord$
|
|
2559
|
+
if (!isRecord$2(candidate) || !hasOnlyKeys(candidate, ADAPTER_RESULT_KEYS)) return invalidAdapterResult(context.adapterId);
|
|
2560
2560
|
const evidenceValue = candidate["evidence"];
|
|
2561
2561
|
const diagnosticsValue = candidate["diagnostics"];
|
|
2562
2562
|
if (!Array.isArray(evidenceValue) || !Array.isArray(diagnosticsValue)) return invalidAdapterResult(context.adapterId);
|
|
@@ -4118,7 +4118,7 @@ var createProjectIndex = (input) => {
|
|
|
4118
4118
|
};
|
|
4119
4119
|
//#endregion
|
|
4120
4120
|
//#region src/repository-reference-validation/index.ts
|
|
4121
|
-
var childPointer = (pointer, segment) => {
|
|
4121
|
+
var childPointer$1 = (pointer, segment) => {
|
|
4122
4122
|
return `${pointer}/${escapeJsonPointerSegment(segment)}`;
|
|
4123
4123
|
};
|
|
4124
4124
|
var compareNullableStrings = (left, right) => {
|
|
@@ -4134,7 +4134,7 @@ var addReferenceCandidates = (candidates, references, pointer, entity) => {
|
|
|
4134
4134
|
entity,
|
|
4135
4135
|
kind: "reference",
|
|
4136
4136
|
path: reference.path,
|
|
4137
|
-
pointer: childPointer(pointer, String(index))
|
|
4137
|
+
pointer: childPointer$1(pointer, String(index))
|
|
4138
4138
|
});
|
|
4139
4139
|
};
|
|
4140
4140
|
/** Adds sorted exact impact paths while retaining skipped glob indexes. */
|
|
@@ -4145,26 +4145,26 @@ var addImpactCandidates = (candidates, affectedBy, pointer, entity) => {
|
|
|
4145
4145
|
entity,
|
|
4146
4146
|
kind: "impact",
|
|
4147
4147
|
path: parseRepositoryPath(pattern),
|
|
4148
|
-
pointer: childPointer(pointer, String(index))
|
|
4148
|
+
pointer: childPointer$1(pointer, String(index))
|
|
4149
4149
|
});
|
|
4150
4150
|
}
|
|
4151
4151
|
};
|
|
4152
4152
|
/** Adds repository-backed declarations owned by one context or decision relationship. */
|
|
4153
4153
|
var addRelationshipCandidates = (candidates, relationship, pointer, entity) => {
|
|
4154
|
-
addReferenceCandidates(candidates, relationship.bindings, childPointer(pointer, "bindings"), entity);
|
|
4155
|
-
addImpactCandidates(candidates, relationship.affectedBy, childPointer(pointer, "affectedBy"), entity);
|
|
4154
|
+
addReferenceCandidates(candidates, relationship.bindings, childPointer$1(pointer, "bindings"), entity);
|
|
4155
|
+
addImpactCandidates(candidates, relationship.affectedBy, childPointer$1(pointer, "affectedBy"), entity);
|
|
4156
4156
|
};
|
|
4157
4157
|
/** Adds related repository references from sorted unresolved requirements. */
|
|
4158
4158
|
var addUnresolvedCandidates = (candidates, requirements, pointer, entity) => {
|
|
4159
4159
|
for (const requirementId of Object.keys(requirements ?? {}).sort(compareExactStrings)) {
|
|
4160
4160
|
const requirement = requirements?.[requirementId];
|
|
4161
4161
|
if (requirement === void 0) continue;
|
|
4162
|
-
addReferenceCandidates(candidates, requirement.related, childPointer(childPointer(pointer, requirementId), "related"), entity);
|
|
4162
|
+
addReferenceCandidates(candidates, requirement.related, childPointer$1(childPointer$1(pointer, requirementId), "related"), entity);
|
|
4163
4163
|
}
|
|
4164
4164
|
};
|
|
4165
4165
|
/** Adds one capability's implementation, optional bindings, and exact impact paths. */
|
|
4166
4166
|
var addCapabilityCandidates = (candidates, capability, capabilityKind, capabilityId, agentId, collectionPointer, additionalReferences = []) => {
|
|
4167
|
-
const capabilityPointer = childPointer(collectionPointer, capabilityId);
|
|
4167
|
+
const capabilityPointer = childPointer$1(collectionPointer, capabilityId);
|
|
4168
4168
|
const capabilityEntity = {
|
|
4169
4169
|
agentId,
|
|
4170
4170
|
capabilityId,
|
|
@@ -4174,21 +4174,21 @@ var addCapabilityCandidates = (candidates, capability, capabilityKind, capabilit
|
|
|
4174
4174
|
entity: capabilityEntity,
|
|
4175
4175
|
kind: `${capabilityKind}-implementation`,
|
|
4176
4176
|
path: capability.implementation.path,
|
|
4177
|
-
pointer: childPointer(capabilityPointer, "implementation")
|
|
4177
|
+
pointer: childPointer$1(capabilityPointer, "implementation")
|
|
4178
4178
|
});
|
|
4179
4179
|
for (const [property, reference] of [["registration", capability.registration], ...additionalReferences]) if (reference !== void 0) candidates.push({
|
|
4180
4180
|
entity: capabilityEntity,
|
|
4181
4181
|
kind: "reference",
|
|
4182
4182
|
path: reference.path,
|
|
4183
|
-
pointer: childPointer(capabilityPointer, property)
|
|
4183
|
+
pointer: childPointer$1(capabilityPointer, property)
|
|
4184
4184
|
});
|
|
4185
|
-
addImpactCandidates(candidates, capability.affectedBy, childPointer(capabilityPointer, "affectedBy"), capabilityEntity);
|
|
4185
|
+
addImpactCandidates(candidates, capability.affectedBy, childPointer$1(capabilityPointer, "affectedBy"), capabilityEntity);
|
|
4186
4186
|
};
|
|
4187
4187
|
/** Adds all repository-backed declarations owned by one normalized agent. */
|
|
4188
4188
|
var addAgentCandidates = (candidates, agentId, agent) => {
|
|
4189
4189
|
const pointer = `/agents/${escapeJsonPointerSegment(agentId)}`;
|
|
4190
4190
|
const entity = { agentId };
|
|
4191
|
-
const bindingsPointer = childPointer(pointer, "bindings");
|
|
4191
|
+
const bindingsPointer = childPointer$1(pointer, "bindings");
|
|
4192
4192
|
const bindings = agent.bindings;
|
|
4193
4193
|
for (const property of [
|
|
4194
4194
|
"runtimeAgent",
|
|
@@ -4201,7 +4201,7 @@ var addAgentCandidates = (candidates, agentId, agent) => {
|
|
|
4201
4201
|
entity,
|
|
4202
4202
|
kind: "reference",
|
|
4203
4203
|
path: reference.path,
|
|
4204
|
-
pointer: childPointer(bindingsPointer, property)
|
|
4204
|
+
pointer: childPointer$1(bindingsPointer, property)
|
|
4205
4205
|
});
|
|
4206
4206
|
}
|
|
4207
4207
|
for (const variableId of Object.keys(bindings?.variableProviders ?? {}).sort(compareExactStrings)) {
|
|
@@ -4213,21 +4213,21 @@ var addAgentCandidates = (candidates, agentId, agent) => {
|
|
|
4213
4213
|
},
|
|
4214
4214
|
kind: "reference",
|
|
4215
4215
|
path: reference.path,
|
|
4216
|
-
pointer: childPointer(childPointer(bindingsPointer, "variableProviders"), variableId)
|
|
4216
|
+
pointer: childPointer$1(childPointer$1(bindingsPointer, "variableProviders"), variableId)
|
|
4217
4217
|
});
|
|
4218
4218
|
}
|
|
4219
|
-
addImpactCandidates(candidates, agent.affectedBy, childPointer(pointer, "affectedBy"), entity);
|
|
4220
|
-
const toolsPointer = childPointer(pointer, "tools");
|
|
4219
|
+
addImpactCandidates(candidates, agent.affectedBy, childPointer$1(pointer, "affectedBy"), entity);
|
|
4220
|
+
const toolsPointer = childPointer$1(pointer, "tools");
|
|
4221
4221
|
for (const capabilityId of Object.keys(agent.tools ?? {}).sort(compareExactStrings)) {
|
|
4222
4222
|
const capability = agent.tools?.[capabilityId];
|
|
4223
4223
|
if (capability !== void 0) addCapabilityCandidates(candidates, capability, "tool", capabilityId, agentId, toolsPointer, [["inputSchema", capability.inputSchema], ["outputSchema", capability.outputSchema]]);
|
|
4224
4224
|
}
|
|
4225
|
-
const skillsPointer = childPointer(pointer, "skills");
|
|
4225
|
+
const skillsPointer = childPointer$1(pointer, "skills");
|
|
4226
4226
|
for (const capabilityId of Object.keys(agent.skills ?? {}).sort(compareExactStrings)) {
|
|
4227
4227
|
const capability = agent.skills?.[capabilityId];
|
|
4228
4228
|
if (capability !== void 0) addCapabilityCandidates(candidates, capability, "skill", capabilityId, agentId, skillsPointer);
|
|
4229
4229
|
}
|
|
4230
|
-
addUnresolvedCandidates(candidates, agent.unresolved, childPointer(pointer, "unresolved"), entity);
|
|
4230
|
+
addUnresolvedCandidates(candidates, agent.unresolved, childPointer$1(pointer, "unresolved"), entity);
|
|
4231
4231
|
};
|
|
4232
4232
|
/** Collects every repository-backed manifest declaration in deterministic pointer order. */
|
|
4233
4233
|
var collectCandidates = (manifest) => {
|
|
@@ -4237,7 +4237,7 @@ var collectCandidates = (manifest) => {
|
|
|
4237
4237
|
for (const referencedPath of Object.keys(relationships ?? {}).sort(compareExactStrings)) {
|
|
4238
4238
|
const relationship = relationships?.[referencedPath];
|
|
4239
4239
|
if (relationship === void 0) continue;
|
|
4240
|
-
const pointer = childPointer(`/${property}`, referencedPath);
|
|
4240
|
+
const pointer = childPointer$1(`/${property}`, referencedPath);
|
|
4241
4241
|
const decisionId = property === "decisions" ? parseDecisionIdFromPath(parseRepositoryPath(referencedPath)) : null;
|
|
4242
4242
|
addRelationshipCandidates(candidates, relationship, pointer, decisionId === null ? null : { decisionId });
|
|
4243
4243
|
}
|
|
@@ -4494,34 +4494,34 @@ var inspectUniversalProject = async (context, options) => {
|
|
|
4494
4494
|
};
|
|
4495
4495
|
//#endregion
|
|
4496
4496
|
//#region src/project-inspection/index.ts
|
|
4497
|
-
var isRecord = (candidate) => {
|
|
4497
|
+
var isRecord$1 = (candidate) => {
|
|
4498
4498
|
return typeof candidate === "object" && candidate !== null && !Array.isArray(candidate);
|
|
4499
4499
|
};
|
|
4500
|
-
var invalidArgument = () => {
|
|
4500
|
+
var invalidArgument$1 = () => {
|
|
4501
4501
|
throw new CoreOperationException({
|
|
4502
4502
|
code: "INVALID_ARGUMENT",
|
|
4503
4503
|
operation: "inspect-project"
|
|
4504
4504
|
});
|
|
4505
4505
|
};
|
|
4506
4506
|
var isRepositoryReader = (candidate) => {
|
|
4507
|
-
return isRecord(candidate) && typeof candidate["getEntry"] === "function" && typeof candidate["listEntries"] === "function" && typeof candidate["readFile"] === "function";
|
|
4507
|
+
return isRecord$1(candidate) && typeof candidate["getEntry"] === "function" && typeof candidate["listEntries"] === "function" && typeof candidate["readFile"] === "function";
|
|
4508
4508
|
};
|
|
4509
4509
|
var isAbortSignal = (candidate) => {
|
|
4510
|
-
return isRecord(candidate) && typeof candidate["aborted"] === "boolean" && typeof candidate["addEventListener"] === "function" && typeof candidate["removeEventListener"] === "function";
|
|
4510
|
+
return isRecord$1(candidate) && typeof candidate["aborted"] === "boolean" && typeof candidate["addEventListener"] === "function" && typeof candidate["removeEventListener"] === "function";
|
|
4511
4511
|
};
|
|
4512
4512
|
var validateInput = (candidate) => {
|
|
4513
4513
|
try {
|
|
4514
|
-
if (!isRecord(candidate)) return invalidArgument();
|
|
4514
|
+
if (!isRecord$1(candidate)) return invalidArgument$1();
|
|
4515
4515
|
const repository = candidate["repository"];
|
|
4516
4516
|
const signal = candidate["signal"];
|
|
4517
|
-
if (!isRepositoryReader(repository) || signal !== void 0 && !isAbortSignal(signal)) return invalidArgument();
|
|
4517
|
+
if (!isRepositoryReader(repository) || signal !== void 0 && !isAbortSignal(signal)) return invalidArgument$1();
|
|
4518
4518
|
return {
|
|
4519
4519
|
repository,
|
|
4520
4520
|
...signal === void 0 ? {} : { signal }
|
|
4521
4521
|
};
|
|
4522
4522
|
} catch (error) {
|
|
4523
4523
|
if (error instanceof CoreOperationException) throw error;
|
|
4524
|
-
return invalidArgument();
|
|
4524
|
+
return invalidArgument$1();
|
|
4525
4525
|
}
|
|
4526
4526
|
};
|
|
4527
4527
|
/**
|
|
@@ -4577,6 +4577,391 @@ var inspectProject = async (input, options) => {
|
|
|
4577
4577
|
});
|
|
4578
4578
|
};
|
|
4579
4579
|
//#endregion
|
|
4580
|
+
//#region src/scope-matching/validations.ts
|
|
4581
|
+
var isRecord = (value) => {
|
|
4582
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
4583
|
+
};
|
|
4584
|
+
/** Throws the stable invalid-argument failure for malformed scope input. */
|
|
4585
|
+
var invalidArgument = () => {
|
|
4586
|
+
throw new CoreOperationException({
|
|
4587
|
+
code: "INVALID_ARGUMENT",
|
|
4588
|
+
operation: "match-manifest-scope"
|
|
4589
|
+
});
|
|
4590
|
+
};
|
|
4591
|
+
/** Throws the stable resource failure for an exhausted scope-input budget. */
|
|
4592
|
+
var resourceLimitExceeded = (limit) => {
|
|
4593
|
+
throw new CoreOperationException({
|
|
4594
|
+
code: "RESOURCE_LIMIT_EXCEEDED",
|
|
4595
|
+
limit,
|
|
4596
|
+
operation: "match-manifest-scope"
|
|
4597
|
+
});
|
|
4598
|
+
};
|
|
4599
|
+
/** Measures scalar UTF-8 bytes without allocating an encoded copy. */
|
|
4600
|
+
var measureUtf8ByteLength = (value) => {
|
|
4601
|
+
let byteLength = 0;
|
|
4602
|
+
for (const scalar of value) {
|
|
4603
|
+
const codePoint = scalar.codePointAt(0) ?? 0;
|
|
4604
|
+
byteLength += codePoint <= 127 ? 1 : codePoint <= 2047 ? 2 : codePoint <= 65535 ? 3 : 4;
|
|
4605
|
+
}
|
|
4606
|
+
return byteLength;
|
|
4607
|
+
};
|
|
4608
|
+
/**
|
|
4609
|
+
* Validates and snapshots one public manifest-scope input.
|
|
4610
|
+
* @param input The untrusted manifest document and changed logical paths.
|
|
4611
|
+
* @param limits The immutable Core resource limits.
|
|
4612
|
+
* @returns The detached manifest input and sorted unique repository paths.
|
|
4613
|
+
* @throws
|
|
4614
|
+
* - INVALID_REPOSITORY_PATH: A changed repository path is invalid.
|
|
4615
|
+
* - INVALID_ARGUMENT: The scope operation received an invalid argument.
|
|
4616
|
+
* - RESOURCE_LIMIT_EXCEEDED: The changed-path count or byte budget was exceeded.
|
|
4617
|
+
*/
|
|
4618
|
+
var normalizeManifestScopeInput = (input, limits) => {
|
|
4619
|
+
if (!isRecord(input)) return invalidArgument();
|
|
4620
|
+
const manifest = input["manifest"];
|
|
4621
|
+
const pathCandidates = input["paths"];
|
|
4622
|
+
if (!isRecord(manifest) || !Array.isArray(pathCandidates)) return invalidArgument();
|
|
4623
|
+
if (pathCandidates.length > limits.maxEntries) return resourceLimitExceeded("maxEntries");
|
|
4624
|
+
const uniquePaths = /* @__PURE__ */ new Set();
|
|
4625
|
+
let totalBytes = 0;
|
|
4626
|
+
for (const [index, candidate] of pathCandidates.entries()) {
|
|
4627
|
+
if (typeof candidate !== "string") return invalidArgument();
|
|
4628
|
+
const path = parseRepositoryPath(candidate);
|
|
4629
|
+
totalBytes += measureUtf8ByteLength(path) + (index === 0 ? 0 : 1);
|
|
4630
|
+
if (totalBytes > limits.maxTotalBytesRead) return resourceLimitExceeded("maxTotalBytesRead");
|
|
4631
|
+
uniquePaths.add(path);
|
|
4632
|
+
}
|
|
4633
|
+
return {
|
|
4634
|
+
manifest,
|
|
4635
|
+
paths: [...uniquePaths].sort(compareExactStrings)
|
|
4636
|
+
};
|
|
4637
|
+
};
|
|
4638
|
+
//#endregion
|
|
4639
|
+
//#region src/scope-matching/matching.ts
|
|
4640
|
+
var childPointer = (pointer, segment) => {
|
|
4641
|
+
return `${pointer}/${escapeJsonPointerSegment(segment)}`;
|
|
4642
|
+
};
|
|
4643
|
+
var createOwner = (kind, id, agentId = null) => ({
|
|
4644
|
+
agentId,
|
|
4645
|
+
id,
|
|
4646
|
+
kind
|
|
4647
|
+
});
|
|
4648
|
+
var compareOwners = (left, right) => {
|
|
4649
|
+
return compareExactStrings(left.kind, right.kind) || compareExactStrings(left.agentId ?? "", right.agentId ?? "") || compareExactStrings(left.id, right.id);
|
|
4650
|
+
};
|
|
4651
|
+
var getDeclarationValue = (declaration) => {
|
|
4652
|
+
return declaration.kind === "exact" ? declaration.path : declaration.pattern;
|
|
4653
|
+
};
|
|
4654
|
+
var compareDeclarations = (left, right) => {
|
|
4655
|
+
return compareOwners(left.owner, right.owner) || compareExactStrings(left.field, right.field) || compareExactStrings(getDeclarationValue(left.declaration), getDeclarationValue(right.declaration)) || compareExactStrings(left.pointer, right.pointer);
|
|
4656
|
+
};
|
|
4657
|
+
/** Adds one exact repository relationship to the normalized declaration collection. */
|
|
4658
|
+
var addExactDeclaration = (declarations, owner, field, pointer, reference) => {
|
|
4659
|
+
declarations.push({
|
|
4660
|
+
declaration: typeof reference === "string" ? {
|
|
4661
|
+
kind: "exact",
|
|
4662
|
+
path: reference,
|
|
4663
|
+
symbol: null
|
|
4664
|
+
} : {
|
|
4665
|
+
kind: "exact",
|
|
4666
|
+
path: reference.path,
|
|
4667
|
+
symbol: reference.symbol ?? null
|
|
4668
|
+
},
|
|
4669
|
+
field,
|
|
4670
|
+
owner,
|
|
4671
|
+
pointer
|
|
4672
|
+
});
|
|
4673
|
+
};
|
|
4674
|
+
/** Adds sorted repository references while preserving normalized declaration pointers. */
|
|
4675
|
+
var addReferenceDeclarations = (declarations, references, owner, field, pointer) => {
|
|
4676
|
+
for (const [index, reference] of (references ?? []).entries()) addExactDeclaration(declarations, owner, field, childPointer(pointer, String(index)), reference);
|
|
4677
|
+
};
|
|
4678
|
+
/** Adds exact and simple-glob impact relationships in normalized array order. */
|
|
4679
|
+
var addAffectedByDeclarations = (declarations, affectedBy, owner, pointer) => {
|
|
4680
|
+
for (const [index, pattern] of (affectedBy ?? []).entries()) declarations.push({
|
|
4681
|
+
declaration: pattern.includes("*") ? {
|
|
4682
|
+
kind: "glob",
|
|
4683
|
+
pattern
|
|
4684
|
+
} : {
|
|
4685
|
+
kind: "exact",
|
|
4686
|
+
path: pattern,
|
|
4687
|
+
symbol: null
|
|
4688
|
+
},
|
|
4689
|
+
field: "affectedBy",
|
|
4690
|
+
owner,
|
|
4691
|
+
pointer: childPointer(pointer, String(index))
|
|
4692
|
+
});
|
|
4693
|
+
};
|
|
4694
|
+
/** Adds project-level or agent-level unresolved requirement references. */
|
|
4695
|
+
var addUnresolvedDeclarations = (declarations, requirements, pointer, agentId) => {
|
|
4696
|
+
for (const requirementId of Object.keys(requirements ?? {}).sort(compareExactStrings)) {
|
|
4697
|
+
const requirement = requirements?.[requirementId];
|
|
4698
|
+
if (requirement === void 0) continue;
|
|
4699
|
+
const owner = createOwner("unresolved", requirementId, agentId);
|
|
4700
|
+
addReferenceDeclarations(declarations, requirement.related, owner, "related", childPointer(childPointer(pointer, requirementId), "related"));
|
|
4701
|
+
}
|
|
4702
|
+
};
|
|
4703
|
+
/** Adds exact and impact declarations owned by one tool or skill capability. */
|
|
4704
|
+
var addCapabilityDeclarations = (declarations, capabilityId, capability, agentId, pointer) => {
|
|
4705
|
+
const owner = createOwner(capability.kind, capabilityId, agentId);
|
|
4706
|
+
addExactDeclaration(declarations, owner, "implementation", childPointer(pointer, "implementation"), capability.value.implementation);
|
|
4707
|
+
if (capability.value.registration !== void 0) addExactDeclaration(declarations, owner, "registration", childPointer(pointer, "registration"), capability.value.registration);
|
|
4708
|
+
if (capability.kind === "tool") for (const field of ["inputSchema", "outputSchema"]) {
|
|
4709
|
+
const reference = capability.value[field];
|
|
4710
|
+
if (reference !== void 0) addExactDeclaration(declarations, owner, field, childPointer(pointer, field), reference);
|
|
4711
|
+
}
|
|
4712
|
+
addAffectedByDeclarations(declarations, capability.value.affectedBy, owner, childPointer(pointer, "affectedBy"));
|
|
4713
|
+
};
|
|
4714
|
+
/** Adds all exact and impact relationships owned by one registered agent. */
|
|
4715
|
+
var addAgentDeclarations = (declarations, agentId, agent) => {
|
|
4716
|
+
const pointer = childPointer("/agents", agentId);
|
|
4717
|
+
const owner = createOwner("agent", agentId, agentId);
|
|
4718
|
+
const bindingsPointer = childPointer(pointer, "bindings");
|
|
4719
|
+
for (const field of [
|
|
4720
|
+
"runtimeAgent",
|
|
4721
|
+
"inputSchema",
|
|
4722
|
+
"outputSchema",
|
|
4723
|
+
"instructionLoader"
|
|
4724
|
+
]) {
|
|
4725
|
+
const reference = agent.bindings?.[field];
|
|
4726
|
+
if (reference !== void 0) addExactDeclaration(declarations, owner, field, childPointer(bindingsPointer, field), reference);
|
|
4727
|
+
}
|
|
4728
|
+
for (const variableId of Object.keys(agent.bindings?.variableProviders ?? {}).sort(compareExactStrings)) {
|
|
4729
|
+
const reference = agent.bindings?.variableProviders?.[variableId];
|
|
4730
|
+
if (reference !== void 0) addExactDeclaration(declarations, owner, "variableProvider", childPointer(childPointer(bindingsPointer, "variableProviders"), variableId), reference);
|
|
4731
|
+
}
|
|
4732
|
+
addAffectedByDeclarations(declarations, agent.affectedBy, owner, childPointer(pointer, "affectedBy"));
|
|
4733
|
+
for (const capabilityId of Object.keys(agent.tools ?? {}).sort(compareExactStrings)) {
|
|
4734
|
+
const tool = agent.tools?.[capabilityId];
|
|
4735
|
+
if (tool !== void 0) addCapabilityDeclarations(declarations, capabilityId, {
|
|
4736
|
+
kind: "tool",
|
|
4737
|
+
value: tool
|
|
4738
|
+
}, agentId, childPointer(childPointer(pointer, "tools"), capabilityId));
|
|
4739
|
+
}
|
|
4740
|
+
for (const capabilityId of Object.keys(agent.skills ?? {}).sort(compareExactStrings)) {
|
|
4741
|
+
const skill = agent.skills?.[capabilityId];
|
|
4742
|
+
if (skill !== void 0) addCapabilityDeclarations(declarations, capabilityId, {
|
|
4743
|
+
kind: "skill",
|
|
4744
|
+
value: skill
|
|
4745
|
+
}, agentId, childPointer(childPointer(pointer, "skills"), capabilityId));
|
|
4746
|
+
}
|
|
4747
|
+
for (const [index, mirror] of (agent.mirrors ?? []).entries()) addExactDeclaration(declarations, owner, "mirrors", childPointer(childPointer(pointer, "mirrors"), String(index)), mirror);
|
|
4748
|
+
addUnresolvedDeclarations(declarations, agent.unresolved, childPointer(pointer, "unresolved"), agentId);
|
|
4749
|
+
};
|
|
4750
|
+
/** Collects every version 1 declaration that can establish changed-path relevance. */
|
|
4751
|
+
var collectDeclarations = (manifest) => {
|
|
4752
|
+
const declarations = [];
|
|
4753
|
+
for (const kind of ["context", "decision"]) {
|
|
4754
|
+
const relationships = kind === "context" ? manifest.context : manifest.decisions;
|
|
4755
|
+
for (const ownerId of Object.keys(relationships ?? {}).sort(compareExactStrings)) {
|
|
4756
|
+
const relationship = relationships?.[ownerId];
|
|
4757
|
+
if (relationship === void 0) continue;
|
|
4758
|
+
const owner = createOwner(kind, ownerId);
|
|
4759
|
+
const pointer = childPointer(kind === "context" ? "/context" : "/decisions", ownerId);
|
|
4760
|
+
addReferenceDeclarations(declarations, relationship.bindings, owner, "bindings", childPointer(pointer, "bindings"));
|
|
4761
|
+
addAffectedByDeclarations(declarations, relationship.affectedBy, owner, childPointer(pointer, "affectedBy"));
|
|
4762
|
+
}
|
|
4763
|
+
}
|
|
4764
|
+
addUnresolvedDeclarations(declarations, manifest.unresolved, "/unresolved", null);
|
|
4765
|
+
for (const agentId of Object.keys(manifest.agents ?? {}).sort(compareExactStrings)) {
|
|
4766
|
+
const agent = manifest.agents?.[agentId];
|
|
4767
|
+
if (agent !== void 0) addAgentDeclarations(declarations, agentId, agent);
|
|
4768
|
+
}
|
|
4769
|
+
return declarations.sort(compareDeclarations);
|
|
4770
|
+
};
|
|
4771
|
+
/** Tests a single-segment wildcard without regular-expression interpretation. */
|
|
4772
|
+
var matchesSegment = (pattern, value) => {
|
|
4773
|
+
let patternIndex = 0;
|
|
4774
|
+
let valueIndex = 0;
|
|
4775
|
+
let starIndex = -1;
|
|
4776
|
+
let starValueIndex = -1;
|
|
4777
|
+
while (valueIndex < value.length) {
|
|
4778
|
+
if (pattern[patternIndex] === value[valueIndex]) {
|
|
4779
|
+
patternIndex += 1;
|
|
4780
|
+
valueIndex += 1;
|
|
4781
|
+
continue;
|
|
4782
|
+
}
|
|
4783
|
+
if (pattern[patternIndex] === "*") {
|
|
4784
|
+
starIndex = patternIndex;
|
|
4785
|
+
starValueIndex = valueIndex;
|
|
4786
|
+
patternIndex += 1;
|
|
4787
|
+
continue;
|
|
4788
|
+
}
|
|
4789
|
+
if (starIndex === -1) return false;
|
|
4790
|
+
patternIndex = starIndex + 1;
|
|
4791
|
+
starValueIndex += 1;
|
|
4792
|
+
valueIndex = starValueIndex;
|
|
4793
|
+
}
|
|
4794
|
+
while (pattern[patternIndex] === "*") patternIndex += 1;
|
|
4795
|
+
return patternIndex === pattern.length;
|
|
4796
|
+
};
|
|
4797
|
+
/** Matches validated simple-glob segments with zero-or-more-segment globstars. */
|
|
4798
|
+
var matchesGlob = (patternSegments, path) => {
|
|
4799
|
+
const pathSegments = path.slice(1).split("/");
|
|
4800
|
+
let reachable = new Uint8Array(pathSegments.length + 1);
|
|
4801
|
+
reachable[0] = 1;
|
|
4802
|
+
for (const patternSegment of patternSegments) {
|
|
4803
|
+
const next = new Uint8Array(pathSegments.length + 1);
|
|
4804
|
+
if (patternSegment === "**") {
|
|
4805
|
+
let canReach = false;
|
|
4806
|
+
for (let index = 0; index < reachable.length; index += 1) {
|
|
4807
|
+
canReach ||= reachable[index] === 1;
|
|
4808
|
+
next[index] = canReach ? 1 : 0;
|
|
4809
|
+
}
|
|
4810
|
+
} else for (let index = 0; index < pathSegments.length; index += 1) if (reachable[index] === 1 && matchesSegment(patternSegment, pathSegments[index] ?? "")) next[index + 1] = 1;
|
|
4811
|
+
reachable = next;
|
|
4812
|
+
}
|
|
4813
|
+
return reachable[pathSegments.length] === 1;
|
|
4814
|
+
};
|
|
4815
|
+
/** Builds exact and first-segment glob indexes once for one parsed manifest. */
|
|
4816
|
+
var compileManifestScope = (manifest, limits) => {
|
|
4817
|
+
const declarations = collectDeclarations(manifest);
|
|
4818
|
+
if (declarations.length > limits.maxEntries) throw new CoreOperationException({
|
|
4819
|
+
code: "RESOURCE_LIMIT_EXCEEDED",
|
|
4820
|
+
limit: "maxEntries",
|
|
4821
|
+
operation: "match-manifest-scope"
|
|
4822
|
+
});
|
|
4823
|
+
const exact = /* @__PURE__ */ new Map();
|
|
4824
|
+
const globalGlobs = [];
|
|
4825
|
+
const globsByFirstSegment = /* @__PURE__ */ new Map();
|
|
4826
|
+
for (const declaration of declarations) {
|
|
4827
|
+
if (declaration.declaration.kind === "exact") {
|
|
4828
|
+
const existing = exact.get(declaration.declaration.path) ?? [];
|
|
4829
|
+
existing.push(declaration);
|
|
4830
|
+
exact.set(declaration.declaration.path, existing);
|
|
4831
|
+
continue;
|
|
4832
|
+
}
|
|
4833
|
+
const segments = declaration.declaration.pattern.slice(1).split("/");
|
|
4834
|
+
const compiled = {
|
|
4835
|
+
declaration,
|
|
4836
|
+
segments
|
|
4837
|
+
};
|
|
4838
|
+
const firstSegment = segments[0] ?? "";
|
|
4839
|
+
if (firstSegment === "**" || firstSegment.includes("*")) globalGlobs.push(compiled);
|
|
4840
|
+
else {
|
|
4841
|
+
const existing = globsByFirstSegment.get(firstSegment) ?? [];
|
|
4842
|
+
existing.push(compiled);
|
|
4843
|
+
globsByFirstSegment.set(firstSegment, existing);
|
|
4844
|
+
}
|
|
4845
|
+
}
|
|
4846
|
+
return {
|
|
4847
|
+
declarations,
|
|
4848
|
+
exact,
|
|
4849
|
+
globalGlobs,
|
|
4850
|
+
globsByFirstSegment
|
|
4851
|
+
};
|
|
4852
|
+
};
|
|
4853
|
+
var compareMatches = (left, right) => {
|
|
4854
|
+
return compareOwners(left.owner, right.owner) || compareExactStrings(left.field, right.field) || compareExactStrings(getDeclarationValue(left.declaration), getDeclarationValue(right.declaration)) || compareExactStrings(left.inputPath, right.inputPath) || compareExactStrings(left.pointer, right.pointer);
|
|
4855
|
+
};
|
|
4856
|
+
var createMatch = (inputPath, relationship) => ({
|
|
4857
|
+
declaration: relationship.declaration,
|
|
4858
|
+
field: relationship.field,
|
|
4859
|
+
inputPath,
|
|
4860
|
+
owner: relationship.owner,
|
|
4861
|
+
pointer: relationship.pointer
|
|
4862
|
+
});
|
|
4863
|
+
/** Adds one match without ever allocating beyond the operation entry budget. */
|
|
4864
|
+
var addMatch = (matches, inputPath, relationship, limits) => {
|
|
4865
|
+
if (matches.length >= limits.maxEntries) throw new CoreOperationException({
|
|
4866
|
+
code: "RESOURCE_LIMIT_EXCEEDED",
|
|
4867
|
+
limit: "maxEntries",
|
|
4868
|
+
operation: "match-manifest-scope"
|
|
4869
|
+
});
|
|
4870
|
+
matches.push(createMatch(inputPath, relationship));
|
|
4871
|
+
};
|
|
4872
|
+
/** Appends matches from one precompiled glob bucket without copying the bucket. */
|
|
4873
|
+
var addGlobMatches = (matches, inputPath, declarations, limits) => {
|
|
4874
|
+
for (const compiled of declarations) if (matchesGlob(compiled.segments, inputPath)) addMatch(matches, inputPath, compiled.declaration, limits);
|
|
4875
|
+
};
|
|
4876
|
+
/** Creates the canonical digest of the sorted unique changed-path set. */
|
|
4877
|
+
var calculateManifestScopeInputDigest = async (paths) => {
|
|
4878
|
+
const value = paths.join("\0");
|
|
4879
|
+
return calculateNormalizedTextDigest({
|
|
4880
|
+
scalarLength: countUnicodeScalars$1(value),
|
|
4881
|
+
utf8ByteLength: measureUtf8ByteLength(value),
|
|
4882
|
+
value
|
|
4883
|
+
});
|
|
4884
|
+
};
|
|
4885
|
+
/**
|
|
4886
|
+
* Matches normalized changed paths against one valid version 1 manifest.
|
|
4887
|
+
* @param manifest The parsed and validated manifest value.
|
|
4888
|
+
* @param paths Sorted unique repository-logical changed paths.
|
|
4889
|
+
* @param limits The immutable Core operation limits.
|
|
4890
|
+
* @returns Frozen content-free matches and stable aggregate counts.
|
|
4891
|
+
* @throws
|
|
4892
|
+
* - RESOURCE_LIMIT_EXCEEDED: The declaration or match count exceeded `maxEntries`.
|
|
4893
|
+
*/
|
|
4894
|
+
var matchParsedManifestScope = (manifest, paths, limits) => {
|
|
4895
|
+
const compiled = compileManifestScope(manifest, limits);
|
|
4896
|
+
const matches = [];
|
|
4897
|
+
const matchedOwners = /* @__PURE__ */ new Set();
|
|
4898
|
+
const matchedPaths = /* @__PURE__ */ new Set();
|
|
4899
|
+
for (const path of paths) {
|
|
4900
|
+
const firstSegment = path.slice(1).split("/", 1)[0] ?? "";
|
|
4901
|
+
const exactDeclarations = compiled.exact.get(path) ?? [];
|
|
4902
|
+
for (const relationship of exactDeclarations) addMatch(matches, path, relationship, limits);
|
|
4903
|
+
addGlobMatches(matches, path, compiled.globalGlobs, limits);
|
|
4904
|
+
addGlobMatches(matches, path, compiled.globsByFirstSegment.get(firstSegment) ?? [], limits);
|
|
4905
|
+
}
|
|
4906
|
+
matches.sort(compareMatches);
|
|
4907
|
+
for (const match of matches) {
|
|
4908
|
+
matchedOwners.add(`${match.owner.kind}\0${match.owner.agentId ?? ""}\0${match.owner.id}`);
|
|
4909
|
+
matchedPaths.add(match.inputPath);
|
|
4910
|
+
}
|
|
4911
|
+
return freezeRecursively({
|
|
4912
|
+
counts: {
|
|
4913
|
+
declarations: compiled.declarations.length,
|
|
4914
|
+
inputPaths: paths.length,
|
|
4915
|
+
matchedOwners: matchedOwners.size,
|
|
4916
|
+
matchedPaths: matchedPaths.size,
|
|
4917
|
+
matches: matches.length
|
|
4918
|
+
},
|
|
4919
|
+
matches
|
|
4920
|
+
});
|
|
4921
|
+
};
|
|
4922
|
+
//#endregion
|
|
4923
|
+
//#region src/scope-matching/scope.ts
|
|
4924
|
+
/**
|
|
4925
|
+
* Parses a manifest and matches its repository relationships against changed logical paths.
|
|
4926
|
+
* @param input The canonical manifest document and untrusted changed-path collection.
|
|
4927
|
+
* @param options The immutable Core operation options.
|
|
4928
|
+
* @returns A promise resolving to frozen content-free scope metadata and matches.
|
|
4929
|
+
* @throws
|
|
4930
|
+
* - INVALID_REPOSITORY_PATH: The manifest path or a changed repository path is invalid.
|
|
4931
|
+
* - INVALID_ARGUMENT: The scope operation received an invalid argument.
|
|
4932
|
+
* - RESOURCE_LIMIT_EXCEEDED: A Core resource limit was exceeded.
|
|
4933
|
+
*/
|
|
4934
|
+
var matchManifestScope = async (input, options) => {
|
|
4935
|
+
const normalized = normalizeManifestScopeInput(input, options.limits);
|
|
4936
|
+
const inputDigest = await calculateManifestScopeInputDigest(normalized.paths);
|
|
4937
|
+
const parsed = await parseManifestDocument(normalized.manifest, options, "match-manifest-scope");
|
|
4938
|
+
if (!parsed.valid || parsed.asset === null || parsed.manifest === null) return freezeRecursively({
|
|
4939
|
+
counts: {
|
|
4940
|
+
declarations: 0,
|
|
4941
|
+
inputPaths: normalized.paths.length,
|
|
4942
|
+
matchedOwners: 0,
|
|
4943
|
+
matchedPaths: 0,
|
|
4944
|
+
matches: 0
|
|
4945
|
+
},
|
|
4946
|
+
diagnostics: parsed.diagnostics,
|
|
4947
|
+
inputDigest,
|
|
4948
|
+
manifestDigest: null,
|
|
4949
|
+
matches: [],
|
|
4950
|
+
relevant: false,
|
|
4951
|
+
valid: false
|
|
4952
|
+
});
|
|
4953
|
+
const matched = matchParsedManifestScope(parsed.manifest, normalized.paths, options.limits);
|
|
4954
|
+
return freezeRecursively({
|
|
4955
|
+
counts: matched.counts,
|
|
4956
|
+
diagnostics: [],
|
|
4957
|
+
inputDigest,
|
|
4958
|
+
manifestDigest: parsed.asset.digest,
|
|
4959
|
+
matches: matched.matches,
|
|
4960
|
+
relevant: matched.matches.length > 0,
|
|
4961
|
+
valid: true
|
|
4962
|
+
});
|
|
4963
|
+
};
|
|
4964
|
+
//#endregion
|
|
4580
4965
|
//#region src/core/index.ts
|
|
4581
4966
|
/**
|
|
4582
4967
|
* Creates one immutable Core instance from detached configuration snapshots.
|
|
@@ -4595,6 +4980,7 @@ var createCore = (options) => {
|
|
|
4595
4980
|
return calculateContentDigest(input, createCoreOperationOptionsSnapshot(snapshot).limits);
|
|
4596
4981
|
},
|
|
4597
4982
|
inspectProject: (input) => inspectProject(input, createCoreOperationOptionsSnapshot(snapshot)),
|
|
4983
|
+
matchManifestScope: (input) => matchManifestScope(input, createCoreOperationOptionsSnapshot(snapshot)),
|
|
4598
4984
|
normalizeText: (input) => {
|
|
4599
4985
|
return normalizeTextDocument(input, createCoreOperationOptionsSnapshot(snapshot).limits, "normalize-text");
|
|
4600
4986
|
},
|