agent-contracts 0.22.9 → 0.23.1
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.js +175 -158
- package/dist/cli.js.map +1 -1
- package/dist/index.js +98 -81
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -49856,12 +49856,18 @@ var MergeError = class extends Error {
|
|
|
49856
49856
|
function isRecord2(v2) {
|
|
49857
49857
|
return typeof v2 === "object" && v2 !== null && !Array.isArray(v2);
|
|
49858
49858
|
}
|
|
49859
|
-
function hasOperator(obj) {
|
|
49859
|
+
function hasOperator(obj, path) {
|
|
49860
49860
|
const ops = ["$append", "$prepend", "$insert_after", "$replace", "$remove"];
|
|
49861
|
+
const found = [];
|
|
49861
49862
|
for (const op of ops) {
|
|
49862
|
-
if (op in obj)
|
|
49863
|
+
if (op in obj) found.push(op);
|
|
49863
49864
|
}
|
|
49864
|
-
|
|
49865
|
+
if (found.length > 1) {
|
|
49866
|
+
throw new MergeError(
|
|
49867
|
+
`Multiple merge operators in the same object at ${path ?? "unknown"}: ${found.join(", ")}`
|
|
49868
|
+
);
|
|
49869
|
+
}
|
|
49870
|
+
return found.length === 1 ? found[0] : null;
|
|
49865
49871
|
}
|
|
49866
49872
|
function findIndexByIdOrValue(arr, target) {
|
|
49867
49873
|
return arr.findIndex((item) => {
|
|
@@ -49872,7 +49878,7 @@ function findIndexByIdOrValue(arr, target) {
|
|
|
49872
49878
|
});
|
|
49873
49879
|
}
|
|
49874
49880
|
function applyArrayMergeOperator(baseArray, operatorObj, path) {
|
|
49875
|
-
const op = hasOperator(operatorObj);
|
|
49881
|
+
const op = hasOperator(operatorObj, path);
|
|
49876
49882
|
if (!op) return baseArray;
|
|
49877
49883
|
switch (op) {
|
|
49878
49884
|
case "$append": {
|
|
@@ -49946,9 +49952,13 @@ function applyArrayMergeOperator(baseArray, operatorObj, path) {
|
|
|
49946
49952
|
}
|
|
49947
49953
|
}
|
|
49948
49954
|
function orderedInsertAfter(base, afterKey, entries) {
|
|
49955
|
+
const entryKeys = new Set(Object.keys(entries));
|
|
49949
49956
|
const result = {};
|
|
49950
49957
|
let inserted = false;
|
|
49951
49958
|
for (const key of Object.keys(base)) {
|
|
49959
|
+
if (inserted && entryKeys.has(key)) {
|
|
49960
|
+
continue;
|
|
49961
|
+
}
|
|
49952
49962
|
result[key] = base[key];
|
|
49953
49963
|
if (key === afterKey) {
|
|
49954
49964
|
for (const [ek, ev] of Object.entries(entries)) {
|
|
@@ -49957,13 +49967,10 @@ function orderedInsertAfter(base, afterKey, entries) {
|
|
|
49957
49967
|
inserted = true;
|
|
49958
49968
|
}
|
|
49959
49969
|
}
|
|
49960
|
-
if (!inserted) {
|
|
49961
|
-
return result;
|
|
49962
|
-
}
|
|
49963
49970
|
return result;
|
|
49964
49971
|
}
|
|
49965
49972
|
function applyMapMergeOperator(baseMap, operatorObj, path) {
|
|
49966
|
-
const op = hasOperator(operatorObj);
|
|
49973
|
+
const op = hasOperator(operatorObj, path);
|
|
49967
49974
|
if (!op) return baseMap;
|
|
49968
49975
|
switch (op) {
|
|
49969
49976
|
case "$append": {
|
|
@@ -50014,7 +50021,7 @@ function deepMergeEntities(base, project, path, hasExtends) {
|
|
|
50014
50021
|
for (const key of Object.keys(project)) {
|
|
50015
50022
|
const baseVal = result[key];
|
|
50016
50023
|
const projVal = project[key];
|
|
50017
|
-
if (isRecord2(projVal) && hasOperator(projVal)) {
|
|
50024
|
+
if (isRecord2(projVal) && hasOperator(projVal, `${path}.${key}`)) {
|
|
50018
50025
|
if (!hasExtends) {
|
|
50019
50026
|
throw new MergeError(
|
|
50020
50027
|
`Merge operator used without extends at ${path}.${key}`
|
|
@@ -50025,7 +50032,12 @@ function deepMergeEntities(base, project, path, hasExtends) {
|
|
|
50025
50032
|
} else if (isRecord2(baseVal)) {
|
|
50026
50033
|
result[key] = applyMapMergeOperator(baseVal, projVal, `${path}.${key}`);
|
|
50027
50034
|
} else {
|
|
50028
|
-
|
|
50035
|
+
const op = hasOperator(projVal, `${path}.${key}`);
|
|
50036
|
+
if (op === "$replace") {
|
|
50037
|
+
result[key] = projVal["$replace"];
|
|
50038
|
+
} else {
|
|
50039
|
+
result[key] = applyArrayMergeOperator([], projVal, `${path}.${key}`);
|
|
50040
|
+
}
|
|
50029
50041
|
}
|
|
50030
50042
|
} else if (isRecord2(projVal) && isRecord2(baseVal) && !Array.isArray(projVal) && !Array.isArray(baseVal)) {
|
|
50031
50043
|
result[key] = deepMergeEntities(
|
|
@@ -50041,10 +50053,44 @@ function deepMergeEntities(base, project, path, hasExtends) {
|
|
|
50041
50053
|
return result;
|
|
50042
50054
|
}
|
|
50043
50055
|
var OPERATOR_KEYS = /* @__PURE__ */ new Set(["$append", "$prepend", "$insert_after", "$replace", "$remove"]);
|
|
50056
|
+
function mergeSection(base, project, path, hasExtends, mode) {
|
|
50057
|
+
switch (mode) {
|
|
50058
|
+
case "map": {
|
|
50059
|
+
const baseMap = isRecord2(base) ? base : {};
|
|
50060
|
+
return mergeEntityMaps(baseMap, project, path, hasExtends);
|
|
50061
|
+
}
|
|
50062
|
+
case "array": {
|
|
50063
|
+
const baseArr = Array.isArray(base) ? base : [];
|
|
50064
|
+
if (isRecord2(project) && hasOperator(project, path)) {
|
|
50065
|
+
if (!hasExtends) {
|
|
50066
|
+
throw new MergeError(
|
|
50067
|
+
`Merge operator used without extends at ${path}`
|
|
50068
|
+
);
|
|
50069
|
+
}
|
|
50070
|
+
return applyArrayMergeOperator(baseArr, project, path);
|
|
50071
|
+
}
|
|
50072
|
+
const projArr = Array.isArray(project) ? project : [];
|
|
50073
|
+
return [...baseArr, ...projArr];
|
|
50074
|
+
}
|
|
50075
|
+
case "object": {
|
|
50076
|
+
const baseObj = isRecord2(base) ? base : {};
|
|
50077
|
+
const projObj = isRecord2(project) ? project : {};
|
|
50078
|
+
if (hasOperator(projObj, path)) {
|
|
50079
|
+
if (!hasExtends) {
|
|
50080
|
+
throw new MergeError(
|
|
50081
|
+
`Merge operator used without extends at ${path}`
|
|
50082
|
+
);
|
|
50083
|
+
}
|
|
50084
|
+
return applyMapMergeOperator(baseObj, projObj, path);
|
|
50085
|
+
}
|
|
50086
|
+
return deepMergeEntities(baseObj, projObj, path, hasExtends);
|
|
50087
|
+
}
|
|
50088
|
+
}
|
|
50089
|
+
}
|
|
50044
50090
|
function mergeEntityMaps(baseMap, projectMap, path, hasExtends) {
|
|
50045
50091
|
let result;
|
|
50046
50092
|
if (isRecord2(projectMap) && !Array.isArray(projectMap)) {
|
|
50047
|
-
const op = hasOperator(projectMap);
|
|
50093
|
+
const op = hasOperator(projectMap, path);
|
|
50048
50094
|
if (op) {
|
|
50049
50095
|
if (!hasExtends) {
|
|
50050
50096
|
throw new MergeError(
|
|
@@ -50061,9 +50107,10 @@ function mergeEntityMaps(baseMap, projectMap, path, hasExtends) {
|
|
|
50061
50107
|
for (const [key, projVal] of Object.entries(projectMap)) {
|
|
50062
50108
|
if (OPERATOR_KEYS.has(key)) continue;
|
|
50063
50109
|
const baseVal = result[key];
|
|
50064
|
-
if (
|
|
50110
|
+
if (isRecord2(projVal) && !Array.isArray(projVal)) {
|
|
50111
|
+
const baseObj = isRecord2(baseVal) ? baseVal : {};
|
|
50065
50112
|
result[key] = deepMergeEntities(
|
|
50066
|
-
|
|
50113
|
+
baseObj,
|
|
50067
50114
|
projVal,
|
|
50068
50115
|
`${path}.${key}`,
|
|
50069
50116
|
hasExtends
|
|
@@ -50074,44 +50121,33 @@ function mergeEntityMaps(baseMap, projectMap, path, hasExtends) {
|
|
|
50074
50121
|
}
|
|
50075
50122
|
return result;
|
|
50076
50123
|
}
|
|
50077
|
-
var
|
|
50078
|
-
|
|
50079
|
-
|
|
50080
|
-
|
|
50081
|
-
|
|
50082
|
-
|
|
50083
|
-
|
|
50084
|
-
|
|
50085
|
-
|
|
50086
|
-
|
|
50087
|
-
|
|
50088
|
-
|
|
50089
|
-
|
|
50090
|
-
|
|
50091
|
-
|
|
50124
|
+
var DSL_SECTIONS = {
|
|
50125
|
+
agents: "map",
|
|
50126
|
+
tasks: "map",
|
|
50127
|
+
artifacts: "map",
|
|
50128
|
+
tools: "map",
|
|
50129
|
+
validations: "map",
|
|
50130
|
+
handoff_types: "map",
|
|
50131
|
+
imports: "map",
|
|
50132
|
+
workflow: "map",
|
|
50133
|
+
policies: "map",
|
|
50134
|
+
guardrails: "map",
|
|
50135
|
+
guardrail_policies: "map",
|
|
50136
|
+
components: "map",
|
|
50137
|
+
extensions: "map",
|
|
50138
|
+
system: "object"
|
|
50139
|
+
};
|
|
50092
50140
|
function mergeDsl(base, project) {
|
|
50093
50141
|
const hasExtends = typeof project["extends"] === "string";
|
|
50094
50142
|
const result = { ...base, ...project };
|
|
50095
|
-
|
|
50096
|
-
|
|
50097
|
-
|
|
50098
|
-
|
|
50099
|
-
|
|
50100
|
-
hasExtends
|
|
50101
|
-
);
|
|
50102
|
-
}
|
|
50103
|
-
for (const section of MERGE_SECTIONS) {
|
|
50104
|
-
const baseVal = base[section];
|
|
50105
|
-
const projVal = project[section];
|
|
50106
|
-
if (projVal === void 0) {
|
|
50107
|
-
continue;
|
|
50108
|
-
}
|
|
50109
|
-
const baseMap = isRecord2(baseVal) ? baseVal : {};
|
|
50110
|
-
result[section] = mergeEntityMaps(
|
|
50111
|
-
baseMap,
|
|
50112
|
-
projVal,
|
|
50143
|
+
for (const [section, mode] of Object.entries(DSL_SECTIONS)) {
|
|
50144
|
+
if (project[section] === void 0) continue;
|
|
50145
|
+
result[section] = mergeSection(
|
|
50146
|
+
base[section],
|
|
50147
|
+
project[section],
|
|
50113
50148
|
section,
|
|
50114
|
-
hasExtends
|
|
50149
|
+
hasExtends,
|
|
50150
|
+
mode
|
|
50115
50151
|
);
|
|
50116
50152
|
}
|
|
50117
50153
|
delete result["extends"];
|
|
@@ -54464,42 +54500,23 @@ function resolveDslPath(dirArg, dirArgDefault, config) {
|
|
|
54464
54500
|
}
|
|
54465
54501
|
|
|
54466
54502
|
// src/config/binding-merger.ts
|
|
54467
|
-
|
|
54468
|
-
|
|
54469
|
-
|
|
54470
|
-
|
|
54471
|
-
|
|
54503
|
+
var BINDING_SECTIONS = {
|
|
54504
|
+
guardrail_impl: "map",
|
|
54505
|
+
outputs: "map",
|
|
54506
|
+
renders: "array",
|
|
54507
|
+
reporting: "object"
|
|
54508
|
+
};
|
|
54472
54509
|
function mergeBinding(base, project) {
|
|
54473
54510
|
const hasExtends = typeof project["extends"] === "string";
|
|
54474
54511
|
const result = { ...base, ...project };
|
|
54475
|
-
for (const section of
|
|
54476
|
-
|
|
54477
|
-
|
|
54478
|
-
|
|
54479
|
-
|
|
54480
|
-
}
|
|
54481
|
-
const baseMap = isRecord5(baseVal) ? baseVal : {};
|
|
54482
|
-
result[section] = mergeEntityMaps(
|
|
54483
|
-
baseMap,
|
|
54484
|
-
projVal,
|
|
54512
|
+
for (const [section, mode] of Object.entries(BINDING_SECTIONS)) {
|
|
54513
|
+
if (project[section] === void 0) continue;
|
|
54514
|
+
result[section] = mergeSection(
|
|
54515
|
+
base[section],
|
|
54516
|
+
project[section],
|
|
54485
54517
|
section,
|
|
54486
|
-
hasExtends
|
|
54487
|
-
|
|
54488
|
-
}
|
|
54489
|
-
for (const section of BINDING_ARRAY_MERGE_SECTIONS) {
|
|
54490
|
-
const baseVal = base[section];
|
|
54491
|
-
const projVal = project[section];
|
|
54492
|
-
if (projVal === void 0) continue;
|
|
54493
|
-
const baseArr = Array.isArray(baseVal) ? baseVal : [];
|
|
54494
|
-
const projArr = Array.isArray(projVal) ? projVal : [];
|
|
54495
|
-
result[section] = [...baseArr, ...projArr];
|
|
54496
|
-
}
|
|
54497
|
-
if (project["reporting"] !== void 0 && isRecord5(base["reporting"]) && isRecord5(project["reporting"])) {
|
|
54498
|
-
result["reporting"] = deepMergeEntities(
|
|
54499
|
-
base["reporting"],
|
|
54500
|
-
project["reporting"],
|
|
54501
|
-
"reporting",
|
|
54502
|
-
hasExtends
|
|
54518
|
+
hasExtends,
|
|
54519
|
+
mode
|
|
54503
54520
|
);
|
|
54504
54521
|
}
|
|
54505
54522
|
delete result["extends"];
|
|
@@ -54990,7 +55007,7 @@ function formatDslOverview(dsl) {
|
|
|
54990
55007
|
`- Validations: ${Object.keys(dsl.validations).join(", ")}`
|
|
54991
55008
|
].join("\n");
|
|
54992
55009
|
}
|
|
54993
|
-
function
|
|
55010
|
+
function isRecord5(v2) {
|
|
54994
55011
|
return typeof v2 === "object" && v2 !== null && !Array.isArray(v2);
|
|
54995
55012
|
}
|
|
54996
55013
|
function collectAllXUsages(dsl) {
|
|
@@ -55003,7 +55020,7 @@ function collectAllXUsages(dsl) {
|
|
|
55003
55020
|
}
|
|
55004
55021
|
}
|
|
55005
55022
|
walk(dsl, "", "root");
|
|
55006
|
-
if (
|
|
55023
|
+
if (isRecord5(dsl.system)) walk(dsl.system, "system", "system");
|
|
55007
55024
|
for (const [id, a3] of Object.entries(dsl.agents))
|
|
55008
55025
|
walk(a3, `agents.${id}`, "agent");
|
|
55009
55026
|
for (const [id, t3] of Object.entries(dsl.tasks))
|