agent-contracts 0.10.0 → 0.11.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 +122 -0
- package/dist/cli.js +962 -401
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +297 -5
- package/dist/index.js +726 -233
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -159,11 +159,11 @@ function __metadata(metadataKey, metadataValue) {
|
|
|
159
159
|
}
|
|
160
160
|
function __awaiter(thisArg, _arguments, P2, generator) {
|
|
161
161
|
function adopt(value) {
|
|
162
|
-
return value instanceof P2 ? value : new P2(function(
|
|
163
|
-
|
|
162
|
+
return value instanceof P2 ? value : new P2(function(resolve6) {
|
|
163
|
+
resolve6(value);
|
|
164
164
|
});
|
|
165
165
|
}
|
|
166
|
-
return new (P2 || (P2 = Promise))(function(
|
|
166
|
+
return new (P2 || (P2 = Promise))(function(resolve6, reject) {
|
|
167
167
|
function fulfilled(value) {
|
|
168
168
|
try {
|
|
169
169
|
step(generator.next(value));
|
|
@@ -179,7 +179,7 @@ function __awaiter(thisArg, _arguments, P2, generator) {
|
|
|
179
179
|
}
|
|
180
180
|
}
|
|
181
181
|
function step(result) {
|
|
182
|
-
result.done ?
|
|
182
|
+
result.done ? resolve6(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
183
183
|
}
|
|
184
184
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
185
185
|
});
|
|
@@ -370,14 +370,14 @@ function __asyncValues(o3) {
|
|
|
370
370
|
}, i3);
|
|
371
371
|
function verb(n3) {
|
|
372
372
|
i3[n3] = o3[n3] && function(v2) {
|
|
373
|
-
return new Promise(function(
|
|
374
|
-
v2 = o3[n3](v2), settle(
|
|
373
|
+
return new Promise(function(resolve6, reject) {
|
|
374
|
+
v2 = o3[n3](v2), settle(resolve6, reject, v2.done, v2.value);
|
|
375
375
|
});
|
|
376
376
|
};
|
|
377
377
|
}
|
|
378
|
-
function settle(
|
|
378
|
+
function settle(resolve6, reject, d2, v2) {
|
|
379
379
|
Promise.resolve(v2).then(function(v3) {
|
|
380
|
-
|
|
380
|
+
resolve6({ value: v3, done: d2 });
|
|
381
381
|
}, reject);
|
|
382
382
|
}
|
|
383
383
|
}
|
|
@@ -6293,7 +6293,7 @@ var init_index_es = __esm({
|
|
|
6293
6293
|
return { drive: t4.toLowerCase() + ":" };
|
|
6294
6294
|
}, k2 = function() {
|
|
6295
6295
|
return { drive: null };
|
|
6296
|
-
},
|
|
6296
|
+
}, z17 = function() {
|
|
6297
6297
|
return { drive: null };
|
|
6298
6298
|
}, B2 = function(t4) {
|
|
6299
6299
|
return { protocol: null, origin: null, absolute: false, drive: null, ...t4 };
|
|
@@ -6334,7 +6334,7 @@ var init_index_es = __esm({
|
|
|
6334
6334
|
var t4, n4, r4, e4, o4;
|
|
6335
6335
|
return t4 = K2, (n4 = rt()) !== c2 && (r4 = et()) !== c2 && (e4 = ut()) !== c2 && (o4 = it()) !== c2 ? (n4 = s2(n4, r4, e4, o4), t4 = n4) : (K2 = t4, t4 = c2), t4 === c2 && (t4 = K2, (n4 = rt()) !== c2 && (r4 = et()) !== c2 && (e4 = (function() {
|
|
6336
6336
|
var t5;
|
|
6337
|
-
return (t5 = x3) !== c2 && (t5 =
|
|
6337
|
+
return (t5 = x3) !== c2 && (t5 = z17()), t5;
|
|
6338
6338
|
})()) !== c2 ? (n4 = f2(n4, r4, e4), t4 = n4) : (K2 = t4, t4 = c2)), t4;
|
|
6339
6339
|
})()) === c2 && (n3 = (function() {
|
|
6340
6340
|
var n4, r4, e4, o4;
|
|
@@ -8023,7 +8023,7 @@ __export(index_es_exports2, {
|
|
|
8023
8023
|
resolveExternalRef: () => ye,
|
|
8024
8024
|
resolveExternalRefWithLocation: () => ge,
|
|
8025
8025
|
resolveInlineRef: () => B,
|
|
8026
|
-
resolveInlineRefWithLocation: () =>
|
|
8026
|
+
resolveInlineRefWithLocation: () => z16,
|
|
8027
8027
|
safeParse: () => de,
|
|
8028
8028
|
safeStringify: () => ve,
|
|
8029
8029
|
startsWith: () => be,
|
|
@@ -8067,9 +8067,9 @@ function* L(e3, t3, r3) {
|
|
|
8067
8067
|
for (const [n3, o3] of t3.entries()) O(e3.value, o3, r3), e3.value = e3.value[o3], A(e3.value) && (j(e3.value), yield [n3, e3.value]);
|
|
8068
8068
|
}
|
|
8069
8069
|
function B(e3, t3) {
|
|
8070
|
-
return
|
|
8070
|
+
return z16(e3, t3).value;
|
|
8071
8071
|
}
|
|
8072
|
-
function
|
|
8072
|
+
function z16(e3, t3) {
|
|
8073
8073
|
return (function e4(t4, r3, n3, o3) {
|
|
8074
8074
|
if (null !== V(r3)) throw new ReferenceError("Cannot resolve external references");
|
|
8075
8075
|
const i3 = K(r3);
|
|
@@ -12937,13 +12937,13 @@ var require_yaml2 = __commonJS({
|
|
|
12937
12937
|
function getLocationForJsonPath(result, path) {
|
|
12938
12938
|
return (0, yaml_1.getLocationForJsonPath)(result, path);
|
|
12939
12939
|
}
|
|
12940
|
-
var
|
|
12940
|
+
var parseYaml4 = (input) => (0, yaml_1.parseWithPointers)(input, {
|
|
12941
12941
|
ignoreDuplicateKeys: false,
|
|
12942
12942
|
mergeKeys: true,
|
|
12943
12943
|
preserveKeyOrder: true,
|
|
12944
12944
|
attachComments: false
|
|
12945
12945
|
});
|
|
12946
|
-
exports.parseYaml =
|
|
12946
|
+
exports.parseYaml = parseYaml4;
|
|
12947
12947
|
exports.Yaml = {
|
|
12948
12948
|
parse: exports.parseYaml,
|
|
12949
12949
|
getLocationForJsonPath,
|
|
@@ -13033,11 +13033,11 @@ function __metadata2(metadataKey, metadataValue) {
|
|
|
13033
13033
|
}
|
|
13034
13034
|
function __awaiter2(thisArg, _arguments, P2, generator) {
|
|
13035
13035
|
function adopt(value) {
|
|
13036
|
-
return value instanceof P2 ? value : new P2(function(
|
|
13037
|
-
|
|
13036
|
+
return value instanceof P2 ? value : new P2(function(resolve6) {
|
|
13037
|
+
resolve6(value);
|
|
13038
13038
|
});
|
|
13039
13039
|
}
|
|
13040
|
-
return new (P2 || (P2 = Promise))(function(
|
|
13040
|
+
return new (P2 || (P2 = Promise))(function(resolve6, reject) {
|
|
13041
13041
|
function fulfilled(value) {
|
|
13042
13042
|
try {
|
|
13043
13043
|
step(generator.next(value));
|
|
@@ -13053,7 +13053,7 @@ function __awaiter2(thisArg, _arguments, P2, generator) {
|
|
|
13053
13053
|
}
|
|
13054
13054
|
}
|
|
13055
13055
|
function step(result) {
|
|
13056
|
-
result.done ?
|
|
13056
|
+
result.done ? resolve6(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
13057
13057
|
}
|
|
13058
13058
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
13059
13059
|
});
|
|
@@ -13231,14 +13231,14 @@ function __asyncValues2(o3) {
|
|
|
13231
13231
|
}, i3);
|
|
13232
13232
|
function verb(n3) {
|
|
13233
13233
|
i3[n3] = o3[n3] && function(v2) {
|
|
13234
|
-
return new Promise(function(
|
|
13235
|
-
v2 = o3[n3](v2), settle(
|
|
13234
|
+
return new Promise(function(resolve6, reject) {
|
|
13235
|
+
v2 = o3[n3](v2), settle(resolve6, reject, v2.done, v2.value);
|
|
13236
13236
|
});
|
|
13237
13237
|
};
|
|
13238
13238
|
}
|
|
13239
|
-
function settle(
|
|
13239
|
+
function settle(resolve6, reject, d2, v2) {
|
|
13240
13240
|
Promise.resolve(v2).then(function(v3) {
|
|
13241
|
-
|
|
13241
|
+
resolve6({ value: v3, done: d2 });
|
|
13242
13242
|
}, reject);
|
|
13243
13243
|
}
|
|
13244
13244
|
}
|
|
@@ -15152,7 +15152,7 @@ function consumeBody() {
|
|
|
15152
15152
|
let accum = [];
|
|
15153
15153
|
let accumBytes = 0;
|
|
15154
15154
|
let abort = false;
|
|
15155
|
-
return new Body.Promise(function(
|
|
15155
|
+
return new Body.Promise(function(resolve6, reject) {
|
|
15156
15156
|
let resTimeout;
|
|
15157
15157
|
if (_this4.timeout) {
|
|
15158
15158
|
resTimeout = setTimeout(function() {
|
|
@@ -15186,7 +15186,7 @@ function consumeBody() {
|
|
|
15186
15186
|
}
|
|
15187
15187
|
clearTimeout(resTimeout);
|
|
15188
15188
|
try {
|
|
15189
|
-
|
|
15189
|
+
resolve6(Buffer.concat(accum, accumBytes));
|
|
15190
15190
|
} catch (err) {
|
|
15191
15191
|
reject(new FetchError(`Could not create Buffer from response body for ${_this4.url}: ${err.message}`, "system", err));
|
|
15192
15192
|
}
|
|
@@ -15449,7 +15449,7 @@ function fetch(url, opts) {
|
|
|
15449
15449
|
throw new Error("native promise missing, set fetch.Promise to your favorite alternative");
|
|
15450
15450
|
}
|
|
15451
15451
|
Body.Promise = fetch.Promise;
|
|
15452
|
-
return new fetch.Promise(function(
|
|
15452
|
+
return new fetch.Promise(function(resolve6, reject) {
|
|
15453
15453
|
const request = new Request(url, opts);
|
|
15454
15454
|
const options = getNodeRequestOptions(request);
|
|
15455
15455
|
const send = (options.protocol === "https:" ? https : http).request;
|
|
@@ -15582,7 +15582,7 @@ function fetch(url, opts) {
|
|
|
15582
15582
|
requestOpts.body = void 0;
|
|
15583
15583
|
requestOpts.headers.delete("content-length");
|
|
15584
15584
|
}
|
|
15585
|
-
|
|
15585
|
+
resolve6(fetch(new Request(locationURL, requestOpts)));
|
|
15586
15586
|
finalize();
|
|
15587
15587
|
return;
|
|
15588
15588
|
}
|
|
@@ -15603,7 +15603,7 @@ function fetch(url, opts) {
|
|
|
15603
15603
|
const codings = headers.get("Content-Encoding");
|
|
15604
15604
|
if (!request.compress || request.method === "HEAD" || codings === null || res.statusCode === 204 || res.statusCode === 304) {
|
|
15605
15605
|
response = new Response(body, response_options);
|
|
15606
|
-
|
|
15606
|
+
resolve6(response);
|
|
15607
15607
|
return;
|
|
15608
15608
|
}
|
|
15609
15609
|
const zlibOptions = {
|
|
@@ -15613,7 +15613,7 @@ function fetch(url, opts) {
|
|
|
15613
15613
|
if (codings == "gzip" || codings == "x-gzip") {
|
|
15614
15614
|
body = body.pipe(zlib.createGunzip(zlibOptions));
|
|
15615
15615
|
response = new Response(body, response_options);
|
|
15616
|
-
|
|
15616
|
+
resolve6(response);
|
|
15617
15617
|
return;
|
|
15618
15618
|
}
|
|
15619
15619
|
if (codings == "deflate" || codings == "x-deflate") {
|
|
@@ -15625,12 +15625,12 @@ function fetch(url, opts) {
|
|
|
15625
15625
|
body = body.pipe(zlib.createInflateRaw());
|
|
15626
15626
|
}
|
|
15627
15627
|
response = new Response(body, response_options);
|
|
15628
|
-
|
|
15628
|
+
resolve6(response);
|
|
15629
15629
|
});
|
|
15630
15630
|
raw.on("end", function() {
|
|
15631
15631
|
if (!response) {
|
|
15632
15632
|
response = new Response(body, response_options);
|
|
15633
|
-
|
|
15633
|
+
resolve6(response);
|
|
15634
15634
|
}
|
|
15635
15635
|
});
|
|
15636
15636
|
return;
|
|
@@ -15638,11 +15638,11 @@ function fetch(url, opts) {
|
|
|
15638
15638
|
if (codings == "br" && typeof zlib.createBrotliDecompress === "function") {
|
|
15639
15639
|
body = body.pipe(zlib.createBrotliDecompress());
|
|
15640
15640
|
response = new Response(body, response_options);
|
|
15641
|
-
|
|
15641
|
+
resolve6(response);
|
|
15642
15642
|
return;
|
|
15643
15643
|
}
|
|
15644
15644
|
response = new Response(body, response_options);
|
|
15645
|
-
|
|
15645
|
+
resolve6(response);
|
|
15646
15646
|
});
|
|
15647
15647
|
writeToStream(req, request);
|
|
15648
15648
|
});
|
|
@@ -16355,13 +16355,13 @@ var require_file = __commonJS({
|
|
|
16355
16355
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16356
16356
|
var fs_1 = __require("fs");
|
|
16357
16357
|
function resolveFile(ref) {
|
|
16358
|
-
return new Promise((
|
|
16358
|
+
return new Promise((resolve6, reject) => {
|
|
16359
16359
|
const path = ref.href();
|
|
16360
16360
|
fs_1.readFile(path, "utf8", (err, data) => {
|
|
16361
16361
|
if (err) {
|
|
16362
16362
|
reject(err);
|
|
16363
16363
|
} else {
|
|
16364
|
-
|
|
16364
|
+
resolve6(data);
|
|
16365
16365
|
}
|
|
16366
16366
|
});
|
|
16367
16367
|
});
|
|
@@ -16899,7 +16899,7 @@ var require_immer_cjs_production_min = __commonJS({
|
|
|
16899
16899
|
var t4 = n4[H2];
|
|
16900
16900
|
return (t4 ? s2(t4) : n4)[r4];
|
|
16901
16901
|
}
|
|
16902
|
-
function
|
|
16902
|
+
function z17(n4, r4) {
|
|
16903
16903
|
if (r4 in n4) for (var t4 = Object.getPrototypeOf(n4); t4; ) {
|
|
16904
16904
|
var e4 = Object.getOwnPropertyDescriptor(t4, r4);
|
|
16905
16905
|
if (e4) return e4;
|
|
@@ -17292,7 +17292,7 @@ var require_immer_cjs_production_min = __commonJS({
|
|
|
17292
17292
|
if (r4 === H2) return n4;
|
|
17293
17293
|
var e4 = s2(n4);
|
|
17294
17294
|
if (!u2(e4, r4)) return (function(n5, r5, t4) {
|
|
17295
|
-
var e5, i5 =
|
|
17295
|
+
var e5, i5 = z17(r5, t4);
|
|
17296
17296
|
return i5 ? "value" in i5 ? i5.value : null === (e5 = i5.get) || void 0 === e5 ? void 0 : e5.call(n5.k) : void 0;
|
|
17297
17297
|
})(n4, e4, r4);
|
|
17298
17298
|
var i4 = e4[r4];
|
|
@@ -17302,7 +17302,7 @@ var require_immer_cjs_production_min = __commonJS({
|
|
|
17302
17302
|
}, ownKeys: function(n4) {
|
|
17303
17303
|
return Reflect.ownKeys(s2(n4));
|
|
17304
17304
|
}, set: function(n4, r4, t4) {
|
|
17305
|
-
var e4 =
|
|
17305
|
+
var e4 = z17(s2(n4), r4);
|
|
17306
17306
|
if (null == e4 ? void 0 : e4.set) return e4.set.call(n4.k, t4), true;
|
|
17307
17307
|
if (!n4.g) {
|
|
17308
17308
|
var i4 = A2(s2(n4), r4), o4 = null == i4 ? void 0 : i4[H2];
|
|
@@ -23933,7 +23933,7 @@ var require_reader = __commonJS({
|
|
|
23933
23933
|
var lodash_1 = require_lodash();
|
|
23934
23934
|
var fetch_1 = (0, tslib_1.__importDefault)(require_fetch());
|
|
23935
23935
|
var printError_1 = require_printError();
|
|
23936
|
-
async function
|
|
23936
|
+
async function readFile6(name, opts) {
|
|
23937
23937
|
if ((0, path_1.isURL)(name)) {
|
|
23938
23938
|
let response;
|
|
23939
23939
|
let timeout = null;
|
|
@@ -23964,12 +23964,12 @@ var require_reader = __commonJS({
|
|
|
23964
23964
|
}
|
|
23965
23965
|
} else {
|
|
23966
23966
|
try {
|
|
23967
|
-
return await new Promise((
|
|
23967
|
+
return await new Promise((resolve6, reject) => {
|
|
23968
23968
|
fs.readFile(name, opts.encoding, (err, data) => {
|
|
23969
23969
|
if (err !== null) {
|
|
23970
23970
|
reject(err);
|
|
23971
23971
|
} else {
|
|
23972
|
-
|
|
23972
|
+
resolve6(data);
|
|
23973
23973
|
}
|
|
23974
23974
|
});
|
|
23975
23975
|
});
|
|
@@ -23978,10 +23978,10 @@ var require_reader = __commonJS({
|
|
|
23978
23978
|
}
|
|
23979
23979
|
}
|
|
23980
23980
|
}
|
|
23981
|
-
exports.readFile =
|
|
23981
|
+
exports.readFile = readFile6;
|
|
23982
23982
|
async function readParsable(name, opts) {
|
|
23983
23983
|
try {
|
|
23984
|
-
return await
|
|
23984
|
+
return await readFile6(name, opts);
|
|
23985
23985
|
} catch (ex) {
|
|
23986
23986
|
throw new Error(`Could not parse ${name}: ${(0, printError_1.printError)(ex)}`);
|
|
23987
23987
|
}
|
|
@@ -35641,11 +35641,11 @@ var require_brace_expansion = __commonJS({
|
|
|
35641
35641
|
if (pad) {
|
|
35642
35642
|
var need = width - c2.length;
|
|
35643
35643
|
if (need > 0) {
|
|
35644
|
-
var
|
|
35644
|
+
var z17 = new Array(need + 1).join("0");
|
|
35645
35645
|
if (i3 < 0)
|
|
35646
|
-
c2 = "-" +
|
|
35646
|
+
c2 = "-" + z17 + c2.slice(1);
|
|
35647
35647
|
else
|
|
35648
|
-
c2 =
|
|
35648
|
+
c2 = z17 + c2;
|
|
35649
35649
|
}
|
|
35650
35650
|
}
|
|
35651
35651
|
}
|
|
@@ -40854,14 +40854,14 @@ var require_AsyncFromSyncIteratorContinuation = __commonJS({
|
|
|
40854
40854
|
if (!$Promise) {
|
|
40855
40855
|
throw new $SyntaxError("This environment does not support Promises.");
|
|
40856
40856
|
}
|
|
40857
|
-
return new $Promise(function(
|
|
40857
|
+
return new $Promise(function(resolve6) {
|
|
40858
40858
|
var done = IteratorComplete(result);
|
|
40859
40859
|
var value = IteratorValue(result);
|
|
40860
40860
|
var valueWrapper = PromiseResolve($Promise, value);
|
|
40861
40861
|
var onFulfilled = function(value2) {
|
|
40862
40862
|
return CreateIteratorResultObject(value2, done);
|
|
40863
40863
|
};
|
|
40864
|
-
|
|
40864
|
+
resolve6($then(valueWrapper, onFulfilled));
|
|
40865
40865
|
});
|
|
40866
40866
|
};
|
|
40867
40867
|
}
|
|
@@ -41409,7 +41409,7 @@ var require_CreateAsyncFromSyncIterator = __commonJS({
|
|
|
41409
41409
|
var O2 = this;
|
|
41410
41410
|
SLOT.assert(O2, "[[SyncIteratorRecord]]");
|
|
41411
41411
|
var argsLength = arguments.length;
|
|
41412
|
-
return new $Promise(function(
|
|
41412
|
+
return new $Promise(function(resolve6) {
|
|
41413
41413
|
var syncIteratorRecord = SLOT.get(O2, "[[SyncIteratorRecord]]");
|
|
41414
41414
|
var result;
|
|
41415
41415
|
if (argsLength > 0) {
|
|
@@ -41417,7 +41417,7 @@ var require_CreateAsyncFromSyncIterator = __commonJS({
|
|
|
41417
41417
|
} else {
|
|
41418
41418
|
result = IteratorNext(syncIteratorRecord);
|
|
41419
41419
|
}
|
|
41420
|
-
|
|
41420
|
+
resolve6(AsyncFromSyncIteratorContinuation(result));
|
|
41421
41421
|
});
|
|
41422
41422
|
},
|
|
41423
41423
|
"return": function() {
|
|
@@ -41428,12 +41428,12 @@ var require_CreateAsyncFromSyncIterator = __commonJS({
|
|
|
41428
41428
|
SLOT.assert(O2, "[[SyncIteratorRecord]]");
|
|
41429
41429
|
var valueIsPresent = arguments.length > 0;
|
|
41430
41430
|
var value = valueIsPresent ? arguments[0] : void 0;
|
|
41431
|
-
return new $Promise(function(
|
|
41431
|
+
return new $Promise(function(resolve6, reject) {
|
|
41432
41432
|
var syncIterator = SLOT.get(O2, "[[SyncIteratorRecord]]")["[[Iterator]]"];
|
|
41433
41433
|
var iteratorReturn = GetMethod(syncIterator, "return");
|
|
41434
41434
|
if (typeof iteratorReturn === "undefined") {
|
|
41435
41435
|
var iterResult = CreateIteratorResultObject(value, true);
|
|
41436
|
-
Call(
|
|
41436
|
+
Call(resolve6, void 0, [iterResult]);
|
|
41437
41437
|
return;
|
|
41438
41438
|
}
|
|
41439
41439
|
var result;
|
|
@@ -41446,7 +41446,7 @@ var require_CreateAsyncFromSyncIterator = __commonJS({
|
|
|
41446
41446
|
Call(reject, void 0, [new $TypeError("Iterator `return` method returned a non-object value.")]);
|
|
41447
41447
|
return;
|
|
41448
41448
|
}
|
|
41449
|
-
|
|
41449
|
+
resolve6(AsyncFromSyncIteratorContinuation(result));
|
|
41450
41450
|
});
|
|
41451
41451
|
},
|
|
41452
41452
|
"throw": function() {
|
|
@@ -41457,7 +41457,7 @@ var require_CreateAsyncFromSyncIterator = __commonJS({
|
|
|
41457
41457
|
SLOT.assert(O2, "[[SyncIteratorRecord]]");
|
|
41458
41458
|
var valueIsPresent = arguments.length > 0;
|
|
41459
41459
|
var value = valueIsPresent ? arguments[0] : void 0;
|
|
41460
|
-
return new $Promise(function(
|
|
41460
|
+
return new $Promise(function(resolve6, reject) {
|
|
41461
41461
|
var syncIterator = SLOT.get(O2, "[[SyncIteratorRecord]]")["[[Iterator]]"];
|
|
41462
41462
|
var throwMethod = GetMethod(syncIterator, "throw");
|
|
41463
41463
|
if (typeof throwMethod === "undefined") {
|
|
@@ -41474,7 +41474,7 @@ var require_CreateAsyncFromSyncIterator = __commonJS({
|
|
|
41474
41474
|
Call(reject, void 0, [new $TypeError("Iterator `throw` method returned a non-object value.")]);
|
|
41475
41475
|
return;
|
|
41476
41476
|
}
|
|
41477
|
-
|
|
41477
|
+
resolve6(AsyncFromSyncIteratorContinuation(
|
|
41478
41478
|
result
|
|
41479
41479
|
/* , promiseCapability */
|
|
41480
41480
|
));
|
|
@@ -49169,7 +49169,7 @@ var require_dist10 = __commonJS({
|
|
|
49169
49169
|
var getSiblings = (parent) => (node) => getChildren(parent).filter(not(eq(node)));
|
|
49170
49170
|
var concatAll = (
|
|
49171
49171
|
/*::<T>*/
|
|
49172
|
-
(xs) => (ys) => ys.reduce((zs,
|
|
49172
|
+
(xs) => (ys) => ys.reduce((zs, z17) => zs.concat(z17), xs)
|
|
49173
49173
|
);
|
|
49174
49174
|
function getLastSegment(instancePath) {
|
|
49175
49175
|
const index4 = instancePath.lastIndexOf("/");
|
|
@@ -50425,13 +50425,416 @@ var require_dist13 = __commonJS({
|
|
|
50425
50425
|
});
|
|
50426
50426
|
|
|
50427
50427
|
// src/cli/cli.ts
|
|
50428
|
-
import { Command as
|
|
50428
|
+
import { Command as Command7 } from "commander";
|
|
50429
50429
|
|
|
50430
50430
|
// src/cli/commands/resolve.ts
|
|
50431
50431
|
import { Command } from "commander";
|
|
50432
50432
|
|
|
50433
|
-
// src/config/
|
|
50433
|
+
// src/config/binding-loader.ts
|
|
50434
|
+
import { readFile as readFile2 } from "fs/promises";
|
|
50435
|
+
import { parse as parseYaml2 } from "yaml";
|
|
50436
|
+
|
|
50437
|
+
// src/schema/agent.ts
|
|
50434
50438
|
import { z } from "zod";
|
|
50439
|
+
var RuleSchema = z.object({
|
|
50440
|
+
id: z.string(),
|
|
50441
|
+
name: z.string().optional(),
|
|
50442
|
+
description: z.string(),
|
|
50443
|
+
severity: z.enum(["mandatory", "recommended", "optional"]),
|
|
50444
|
+
detection_method: z.string().optional(),
|
|
50445
|
+
escalation: z.string().optional(),
|
|
50446
|
+
ref: z.string().optional()
|
|
50447
|
+
}).passthrough();
|
|
50448
|
+
var EscalationCriterionSchema = z.object({
|
|
50449
|
+
condition: z.string(),
|
|
50450
|
+
action: z.enum([
|
|
50451
|
+
"stop_and_report",
|
|
50452
|
+
"report_to_architect",
|
|
50453
|
+
"wait_for_approval"
|
|
50454
|
+
])
|
|
50455
|
+
}).passthrough();
|
|
50456
|
+
var PrerequisiteSchema = z.object({
|
|
50457
|
+
action: z.enum(["read", "execute"]),
|
|
50458
|
+
target: z.string(),
|
|
50459
|
+
required: z.boolean()
|
|
50460
|
+
}).passthrough();
|
|
50461
|
+
var AgentSchema = z.object({
|
|
50462
|
+
role_name: z.string(),
|
|
50463
|
+
purpose: z.string(),
|
|
50464
|
+
can_read_artifacts: z.array(z.string()).default([]),
|
|
50465
|
+
can_write_artifacts: z.array(z.string()).default([]),
|
|
50466
|
+
can_execute_tools: z.array(z.string()).default([]),
|
|
50467
|
+
can_perform_validations: z.array(z.string()).default([]),
|
|
50468
|
+
can_invoke_agents: z.array(z.string()).default([]),
|
|
50469
|
+
can_return_handoffs: z.array(z.string()).default([]),
|
|
50470
|
+
dispatch_only: z.boolean().optional(),
|
|
50471
|
+
mode: z.enum(["read-only", "read-write"]).optional(),
|
|
50472
|
+
responsibilities: z.array(z.string()).optional(),
|
|
50473
|
+
constraints: z.array(z.string()).optional(),
|
|
50474
|
+
rules: z.array(RuleSchema).optional(),
|
|
50475
|
+
anti_patterns: z.array(z.string()).optional(),
|
|
50476
|
+
escalation_criteria: z.array(EscalationCriterionSchema).optional(),
|
|
50477
|
+
prerequisites: z.array(PrerequisiteSchema).optional()
|
|
50478
|
+
}).passthrough();
|
|
50479
|
+
|
|
50480
|
+
// src/schema/artifact.ts
|
|
50481
|
+
import { z as z2 } from "zod";
|
|
50482
|
+
var ArtifactSchema = z2.object({
|
|
50483
|
+
type: z2.string(),
|
|
50484
|
+
description: z2.string().optional(),
|
|
50485
|
+
owner: z2.string(),
|
|
50486
|
+
producers: z2.array(z2.string()),
|
|
50487
|
+
editors: z2.array(z2.string()),
|
|
50488
|
+
consumers: z2.array(z2.string()),
|
|
50489
|
+
states: z2.array(z2.string()),
|
|
50490
|
+
required_validations: z2.array(z2.string()).default([]),
|
|
50491
|
+
visibility: z2.string().optional()
|
|
50492
|
+
}).passthrough();
|
|
50493
|
+
|
|
50494
|
+
// src/schema/binding.ts
|
|
50495
|
+
import { z as z3 } from "zod";
|
|
50496
|
+
var CommandRegexMatcherSchema = z3.object({
|
|
50497
|
+
type: z3.literal("command_regex"),
|
|
50498
|
+
pattern: z3.string()
|
|
50499
|
+
});
|
|
50500
|
+
var ContentRegexMatcherSchema = z3.object({
|
|
50501
|
+
type: z3.literal("content_regex"),
|
|
50502
|
+
pattern: z3.string(),
|
|
50503
|
+
file_glob: z3.string().optional(),
|
|
50504
|
+
exclude_glob: z3.string().optional()
|
|
50505
|
+
});
|
|
50506
|
+
var FileGlobMatcherSchema = z3.object({
|
|
50507
|
+
type: z3.literal("file_glob"),
|
|
50508
|
+
pattern: z3.string()
|
|
50509
|
+
});
|
|
50510
|
+
var MatcherSchema = z3.discriminatedUnion("type", [
|
|
50511
|
+
CommandRegexMatcherSchema,
|
|
50512
|
+
ContentRegexMatcherSchema,
|
|
50513
|
+
FileGlobMatcherSchema
|
|
50514
|
+
]);
|
|
50515
|
+
var CheckSchema = z3.object({
|
|
50516
|
+
matcher: MatcherSchema.optional(),
|
|
50517
|
+
script: z3.string().optional(),
|
|
50518
|
+
message: z3.string().optional()
|
|
50519
|
+
}).passthrough();
|
|
50520
|
+
var BindingOutputSchema = z3.object({
|
|
50521
|
+
target: z3.string(),
|
|
50522
|
+
template: z3.string().optional(),
|
|
50523
|
+
inline_template: z3.string().optional(),
|
|
50524
|
+
mode: z3.enum(["write", "patch"]).default("write"),
|
|
50525
|
+
group_by: z3.string().optional(),
|
|
50526
|
+
executable: z3.boolean().optional()
|
|
50527
|
+
}).passthrough().refine(
|
|
50528
|
+
(data) => !(data.template && data.inline_template),
|
|
50529
|
+
{ message: "template and inline_template are mutually exclusive" }
|
|
50530
|
+
);
|
|
50531
|
+
var ReportingSchema = z3.object({
|
|
50532
|
+
commands: z3.record(z3.string(), z3.string()),
|
|
50533
|
+
fail_open: z3.boolean().default(true),
|
|
50534
|
+
timeout_ms: z3.number().default(5e3)
|
|
50535
|
+
}).passthrough();
|
|
50536
|
+
var GuardrailImplSchema = z3.object({
|
|
50537
|
+
checks: z3.array(CheckSchema)
|
|
50538
|
+
});
|
|
50539
|
+
var SoftwareBindingSchema = z3.object({
|
|
50540
|
+
software: z3.string(),
|
|
50541
|
+
version: z3.literal(1),
|
|
50542
|
+
extends: z3.string().optional(),
|
|
50543
|
+
guardrail_impl: z3.record(z3.string(), GuardrailImplSchema).optional(),
|
|
50544
|
+
outputs: z3.record(z3.string(), BindingOutputSchema).optional(),
|
|
50545
|
+
reporting: ReportingSchema.optional()
|
|
50546
|
+
}).passthrough();
|
|
50547
|
+
|
|
50548
|
+
// src/schema/dsl.ts
|
|
50549
|
+
import { z as z12 } from "zod";
|
|
50550
|
+
|
|
50551
|
+
// src/schema/handoff-type.ts
|
|
50552
|
+
import { z as z4 } from "zod";
|
|
50553
|
+
var HandoffTypeSchema = z4.object({
|
|
50554
|
+
version: z4.number(),
|
|
50555
|
+
description: z4.string().optional(),
|
|
50556
|
+
schema: z4.record(z4.string(), z4.any()),
|
|
50557
|
+
example: z4.record(z4.string(), z4.any()).optional()
|
|
50558
|
+
}).passthrough();
|
|
50559
|
+
|
|
50560
|
+
// src/schema/guardrail.ts
|
|
50561
|
+
import { z as z5 } from "zod";
|
|
50562
|
+
var GuardrailScopeSchema = z5.object({
|
|
50563
|
+
agents: z5.array(z5.string()).optional(),
|
|
50564
|
+
tasks: z5.array(z5.string()).optional(),
|
|
50565
|
+
tools: z5.array(z5.string()).optional(),
|
|
50566
|
+
artifacts: z5.array(z5.string()).optional(),
|
|
50567
|
+
workflows: z5.array(z5.string()).optional()
|
|
50568
|
+
}).passthrough();
|
|
50569
|
+
var GuardrailSchema = z5.object({
|
|
50570
|
+
description: z5.string(),
|
|
50571
|
+
scope: GuardrailScopeSchema,
|
|
50572
|
+
rationale: z5.string().optional(),
|
|
50573
|
+
tags: z5.array(z5.string()).default([]),
|
|
50574
|
+
exemptions: z5.array(z5.string()).optional()
|
|
50575
|
+
}).passthrough();
|
|
50576
|
+
var GuardrailPolicyRuleEscalationSchema = z5.object({
|
|
50577
|
+
target: z5.string(),
|
|
50578
|
+
condition: z5.string().optional()
|
|
50579
|
+
}).passthrough();
|
|
50580
|
+
var GuardrailPolicyRuleSchema = z5.object({
|
|
50581
|
+
guardrail: z5.string(),
|
|
50582
|
+
severity: z5.enum(["critical", "mandatory", "warning", "info"]),
|
|
50583
|
+
action: z5.enum(["block", "warn", "shadow", "info"]),
|
|
50584
|
+
allow_override: z5.boolean().default(false),
|
|
50585
|
+
override_requires: z5.array(z5.string()).optional(),
|
|
50586
|
+
escalation: GuardrailPolicyRuleEscalationSchema.optional()
|
|
50587
|
+
}).passthrough();
|
|
50588
|
+
var GuardrailPolicySchema = z5.object({
|
|
50589
|
+
description: z5.string().optional(),
|
|
50590
|
+
rules: z5.array(GuardrailPolicyRuleSchema)
|
|
50591
|
+
}).passthrough();
|
|
50592
|
+
|
|
50593
|
+
// src/schema/policy.ts
|
|
50594
|
+
import { z as z6 } from "zod";
|
|
50595
|
+
var PolicyWhenSchema = z6.object({
|
|
50596
|
+
artifact_type: z6.string().optional(),
|
|
50597
|
+
workflow: z6.string().optional()
|
|
50598
|
+
}).passthrough();
|
|
50599
|
+
var PolicySchema = z6.object({
|
|
50600
|
+
when: PolicyWhenSchema,
|
|
50601
|
+
requires_validations: z6.array(z6.string()).optional(),
|
|
50602
|
+
requires: z6.array(z6.string()).optional()
|
|
50603
|
+
}).passthrough();
|
|
50604
|
+
|
|
50605
|
+
// src/schema/system.ts
|
|
50606
|
+
import { z as z7 } from "zod";
|
|
50607
|
+
var VersionLiteralSchema = z7.literal(1);
|
|
50608
|
+
var ExtendsSchema = z7.string().optional();
|
|
50609
|
+
var SystemSchema = z7.object({
|
|
50610
|
+
id: z7.string(),
|
|
50611
|
+
name: z7.string(),
|
|
50612
|
+
default_workflow_order: z7.array(z7.string())
|
|
50613
|
+
}).passthrough();
|
|
50614
|
+
|
|
50615
|
+
// src/schema/task.ts
|
|
50616
|
+
import { z as z8 } from "zod";
|
|
50617
|
+
var ExecutionStepSchema = z8.object({
|
|
50618
|
+
id: z8.string(),
|
|
50619
|
+
action: z8.string(),
|
|
50620
|
+
description: z8.string().optional(),
|
|
50621
|
+
required: z8.boolean().optional(),
|
|
50622
|
+
abort_on_failure: z8.boolean().optional(),
|
|
50623
|
+
uses_tool: z8.string().optional(),
|
|
50624
|
+
produces_artifact: z8.string().optional(),
|
|
50625
|
+
reads_artifact: z8.string().optional(),
|
|
50626
|
+
depends_on: z8.array(z8.string()).optional(),
|
|
50627
|
+
skip_condition: z8.string().optional(),
|
|
50628
|
+
wait_for_approval: z8.boolean().optional()
|
|
50629
|
+
}).passthrough();
|
|
50630
|
+
var TaskSchema = z8.object({
|
|
50631
|
+
description: z8.string(),
|
|
50632
|
+
target_agent: z8.string(),
|
|
50633
|
+
allowed_from_agents: z8.array(z8.string()),
|
|
50634
|
+
workflow: z8.string(),
|
|
50635
|
+
input_artifacts: z8.array(z8.string()),
|
|
50636
|
+
invocation_handoff: z8.string(),
|
|
50637
|
+
result_handoff: z8.string(),
|
|
50638
|
+
default_priority: z8.string().optional(),
|
|
50639
|
+
responsibilities: z8.array(z8.string()).optional(),
|
|
50640
|
+
constraints: z8.array(z8.string()).optional(),
|
|
50641
|
+
execution_steps: z8.array(ExecutionStepSchema).optional(),
|
|
50642
|
+
completion_criteria: z8.array(z8.string()).optional(),
|
|
50643
|
+
rules: z8.array(RuleSchema).optional(),
|
|
50644
|
+
anti_patterns: z8.array(z8.string()).optional(),
|
|
50645
|
+
escalation_criteria: z8.array(EscalationCriterionSchema).optional(),
|
|
50646
|
+
validations: z8.array(z8.string()).default([])
|
|
50647
|
+
}).passthrough();
|
|
50648
|
+
|
|
50649
|
+
// src/schema/tool.ts
|
|
50650
|
+
import { z as z9 } from "zod";
|
|
50651
|
+
var CommandSchema = z9.object({
|
|
50652
|
+
command: z9.string(),
|
|
50653
|
+
category: z9.string(),
|
|
50654
|
+
reads: z9.array(z9.string()).default([]),
|
|
50655
|
+
writes: z9.array(z9.string()).default([]),
|
|
50656
|
+
purpose: z9.string().optional()
|
|
50657
|
+
});
|
|
50658
|
+
var ToolSchema = z9.object({
|
|
50659
|
+
kind: z9.string(),
|
|
50660
|
+
description: z9.string().optional(),
|
|
50661
|
+
input_artifacts: z9.array(z9.string()).default([]),
|
|
50662
|
+
output_artifacts: z9.array(z9.string()).default([]),
|
|
50663
|
+
invokable_by: z9.array(z9.string()),
|
|
50664
|
+
side_effects: z9.array(z9.string()).default([]),
|
|
50665
|
+
commands: z9.array(CommandSchema).default([])
|
|
50666
|
+
}).passthrough();
|
|
50667
|
+
|
|
50668
|
+
// src/schema/validation.ts
|
|
50669
|
+
import { z as z10 } from "zod";
|
|
50670
|
+
var ValidationSchema = z10.object({
|
|
50671
|
+
target_artifact: z10.string(),
|
|
50672
|
+
kind: z10.enum(["schema", "mechanical", "semantic", "approval"]),
|
|
50673
|
+
executor_type: z10.enum(["tool", "agent"]),
|
|
50674
|
+
executor: z10.string(),
|
|
50675
|
+
blocking: z10.boolean(),
|
|
50676
|
+
produces_evidence: z10.string().optional()
|
|
50677
|
+
}).passthrough();
|
|
50678
|
+
|
|
50679
|
+
// src/schema/workflow.ts
|
|
50680
|
+
import { z as z11 } from "zod";
|
|
50681
|
+
var RetrySchema = z11.object({
|
|
50682
|
+
condition: z11.string(),
|
|
50683
|
+
fix_task: z11.string(),
|
|
50684
|
+
revalidate_task: z11.string().optional()
|
|
50685
|
+
});
|
|
50686
|
+
var ExternalParticipantSchema = z11.object({
|
|
50687
|
+
id: z11.string(),
|
|
50688
|
+
kind: z11.enum(["actor", "participant"]),
|
|
50689
|
+
label: z11.string(),
|
|
50690
|
+
description: z11.string().optional()
|
|
50691
|
+
});
|
|
50692
|
+
var WorkflowDelegateStepSchema = z11.object({
|
|
50693
|
+
type: z11.literal("delegate"),
|
|
50694
|
+
description: z11.string().optional(),
|
|
50695
|
+
task: z11.string(),
|
|
50696
|
+
from_agent: z11.string(),
|
|
50697
|
+
group: z11.string().optional(),
|
|
50698
|
+
retry: RetrySchema.optional()
|
|
50699
|
+
}).passthrough();
|
|
50700
|
+
var WorkflowGateStepSchema = z11.object({
|
|
50701
|
+
type: z11.literal("gate"),
|
|
50702
|
+
description: z11.string().optional(),
|
|
50703
|
+
gate_kind: z11.string(),
|
|
50704
|
+
group: z11.string().optional()
|
|
50705
|
+
}).passthrough();
|
|
50706
|
+
var WorkflowHandoffStepSchema = z11.object({
|
|
50707
|
+
type: z11.literal("handoff"),
|
|
50708
|
+
description: z11.string().optional(),
|
|
50709
|
+
handoff_kind: z11.string(),
|
|
50710
|
+
task: z11.string().optional(),
|
|
50711
|
+
from_agent: z11.string().optional(),
|
|
50712
|
+
group: z11.string().optional(),
|
|
50713
|
+
retry: RetrySchema.optional()
|
|
50714
|
+
}).passthrough();
|
|
50715
|
+
var WorkflowValidationStepSchema = z11.object({
|
|
50716
|
+
type: z11.literal("validation"),
|
|
50717
|
+
description: z11.string().optional(),
|
|
50718
|
+
validation: z11.string(),
|
|
50719
|
+
group: z11.string().optional()
|
|
50720
|
+
}).passthrough();
|
|
50721
|
+
var WorkflowDecisionStepSchema = z11.object({
|
|
50722
|
+
type: z11.literal("decision"),
|
|
50723
|
+
description: z11.string().optional(),
|
|
50724
|
+
on: z11.string(),
|
|
50725
|
+
branches: z11.record(z11.string(), z11.array(z11.string())),
|
|
50726
|
+
group: z11.string().optional()
|
|
50727
|
+
}).passthrough();
|
|
50728
|
+
var WorkflowStepSchema = z11.discriminatedUnion("type", [
|
|
50729
|
+
WorkflowDelegateStepSchema,
|
|
50730
|
+
WorkflowGateStepSchema,
|
|
50731
|
+
WorkflowHandoffStepSchema,
|
|
50732
|
+
WorkflowValidationStepSchema,
|
|
50733
|
+
WorkflowDecisionStepSchema
|
|
50734
|
+
]);
|
|
50735
|
+
var WorkflowSchema = z11.object({
|
|
50736
|
+
description: z11.string().optional(),
|
|
50737
|
+
entry_conditions: z11.array(z11.string()).default([]),
|
|
50738
|
+
trigger: z11.string().optional(),
|
|
50739
|
+
steps: z11.array(WorkflowStepSchema),
|
|
50740
|
+
external_participants: z11.array(ExternalParticipantSchema).default([])
|
|
50741
|
+
}).passthrough();
|
|
50742
|
+
|
|
50743
|
+
// src/schema/dsl.ts
|
|
50744
|
+
var ComponentsSchema = z12.object({
|
|
50745
|
+
schemas: z12.record(z12.string(), z12.record(z12.string(), z12.any())).default({})
|
|
50746
|
+
}).passthrough();
|
|
50747
|
+
var DslSchema = z12.object({
|
|
50748
|
+
version: z12.literal(1),
|
|
50749
|
+
extends: z12.string().optional(),
|
|
50750
|
+
system: SystemSchema,
|
|
50751
|
+
agents: z12.record(z12.string(), AgentSchema).default({}),
|
|
50752
|
+
tasks: z12.record(z12.string(), TaskSchema).default({}),
|
|
50753
|
+
artifacts: z12.record(z12.string(), ArtifactSchema).default({}),
|
|
50754
|
+
tools: z12.record(z12.string(), ToolSchema).default({}),
|
|
50755
|
+
validations: z12.record(z12.string(), ValidationSchema).default({}),
|
|
50756
|
+
handoff_types: z12.record(z12.string(), HandoffTypeSchema).default({}),
|
|
50757
|
+
workflow: z12.record(z12.string(), WorkflowSchema).default({}),
|
|
50758
|
+
policies: z12.record(z12.string(), PolicySchema).default({}),
|
|
50759
|
+
guardrails: z12.record(z12.string(), GuardrailSchema).default({}),
|
|
50760
|
+
guardrail_policies: z12.record(z12.string(), GuardrailPolicySchema).default({}),
|
|
50761
|
+
components: ComponentsSchema.default({ schemas: {} })
|
|
50762
|
+
}).passthrough();
|
|
50763
|
+
|
|
50764
|
+
// src/schema/json-schema-utils.ts
|
|
50765
|
+
function resolveAllOf(schema) {
|
|
50766
|
+
const allOf = schema["allOf"];
|
|
50767
|
+
if (!Array.isArray(allOf)) return schema;
|
|
50768
|
+
let mergedProperties = {};
|
|
50769
|
+
let mergedRequired = [];
|
|
50770
|
+
const mergedTop = {};
|
|
50771
|
+
for (const sub of allOf) {
|
|
50772
|
+
if (typeof sub !== "object" || sub === null || Array.isArray(sub)) continue;
|
|
50773
|
+
const subSchema = sub;
|
|
50774
|
+
if (subSchema["properties"] && typeof subSchema["properties"] === "object") {
|
|
50775
|
+
mergedProperties = {
|
|
50776
|
+
...mergedProperties,
|
|
50777
|
+
...subSchema["properties"]
|
|
50778
|
+
};
|
|
50779
|
+
}
|
|
50780
|
+
if (Array.isArray(subSchema["required"])) {
|
|
50781
|
+
mergedRequired = [
|
|
50782
|
+
...mergedRequired,
|
|
50783
|
+
...subSchema["required"]
|
|
50784
|
+
];
|
|
50785
|
+
}
|
|
50786
|
+
for (const [key, value] of Object.entries(subSchema)) {
|
|
50787
|
+
if (key !== "properties" && key !== "required" && key !== "allOf") {
|
|
50788
|
+
mergedTop[key] = value;
|
|
50789
|
+
}
|
|
50790
|
+
}
|
|
50791
|
+
}
|
|
50792
|
+
for (const [key, value] of Object.entries(schema)) {
|
|
50793
|
+
if (key === "allOf") continue;
|
|
50794
|
+
if (key === "properties" && typeof value === "object") {
|
|
50795
|
+
mergedProperties = { ...mergedProperties, ...value };
|
|
50796
|
+
} else if (key === "required" && Array.isArray(value)) {
|
|
50797
|
+
mergedRequired = [...mergedRequired, ...value];
|
|
50798
|
+
} else {
|
|
50799
|
+
mergedTop[key] = value;
|
|
50800
|
+
}
|
|
50801
|
+
}
|
|
50802
|
+
const result = { ...mergedTop };
|
|
50803
|
+
if (Object.keys(mergedProperties).length > 0) {
|
|
50804
|
+
result["properties"] = mergedProperties;
|
|
50805
|
+
}
|
|
50806
|
+
if (mergedRequired.length > 0) {
|
|
50807
|
+
result["required"] = [...new Set(mergedRequired)];
|
|
50808
|
+
}
|
|
50809
|
+
return result;
|
|
50810
|
+
}
|
|
50811
|
+
|
|
50812
|
+
// src/schema/merge-operators.ts
|
|
50813
|
+
import { z as z13 } from "zod";
|
|
50814
|
+
var AppendOperatorSchema = z13.object({
|
|
50815
|
+
$append: z13.record(z13.string(), z13.any())
|
|
50816
|
+
});
|
|
50817
|
+
var PrependOperatorSchema = z13.object({
|
|
50818
|
+
$prepend: z13.record(z13.string(), z13.any())
|
|
50819
|
+
});
|
|
50820
|
+
var InsertAfterOperatorSchema = z13.object({
|
|
50821
|
+
$insert_after: z13.object({
|
|
50822
|
+
after: z13.string(),
|
|
50823
|
+
entries: z13.record(z13.string(), z13.any())
|
|
50824
|
+
})
|
|
50825
|
+
});
|
|
50826
|
+
var ReplaceOperatorSchema = z13.object({ $replace: z13.any() });
|
|
50827
|
+
var RemoveOperatorSchema = z13.object({
|
|
50828
|
+
$remove: z13.array(z13.string())
|
|
50829
|
+
});
|
|
50830
|
+
|
|
50831
|
+
// src/config/loader.ts
|
|
50832
|
+
import { readFile, access } from "fs/promises";
|
|
50833
|
+
import { resolve, dirname } from "path";
|
|
50834
|
+
import { parse as parseYaml } from "yaml";
|
|
50835
|
+
|
|
50836
|
+
// src/config/types.ts
|
|
50837
|
+
import { z as z14 } from "zod";
|
|
50435
50838
|
var CONTEXT_TYPES = [
|
|
50436
50839
|
"agent",
|
|
50437
50840
|
"task",
|
|
@@ -50441,18 +50844,20 @@ var CONTEXT_TYPES = [
|
|
|
50441
50844
|
"handoff_type",
|
|
50442
50845
|
"workflow",
|
|
50443
50846
|
"policy",
|
|
50847
|
+
"guardrail",
|
|
50848
|
+
"guardrail_policy",
|
|
50444
50849
|
"system"
|
|
50445
50850
|
];
|
|
50446
|
-
var ContextTypeSchema =
|
|
50851
|
+
var ContextTypeSchema = z14.enum(CONTEXT_TYPES);
|
|
50447
50852
|
var ITERABLE_CONTEXT_TYPES = CONTEXT_TYPES.filter(
|
|
50448
50853
|
(t3) => t3 !== "system"
|
|
50449
50854
|
);
|
|
50450
|
-
var RenderTargetSchema =
|
|
50451
|
-
template:
|
|
50855
|
+
var RenderTargetSchema = z14.object({
|
|
50856
|
+
template: z14.string(),
|
|
50452
50857
|
context: ContextTypeSchema,
|
|
50453
|
-
output:
|
|
50454
|
-
include:
|
|
50455
|
-
exclude:
|
|
50858
|
+
output: z14.string(),
|
|
50859
|
+
include: z14.array(z14.string()).optional(),
|
|
50860
|
+
exclude: z14.array(z14.string()).optional()
|
|
50456
50861
|
}).refine(
|
|
50457
50862
|
(data) => !(data.include && data.exclude),
|
|
50458
50863
|
{ message: "include and exclude are mutually exclusive" }
|
|
@@ -50465,16 +50870,16 @@ var RenderTargetSchema = z.object({
|
|
|
50465
50870
|
},
|
|
50466
50871
|
{ message: "include/exclude cannot be used with context: system" }
|
|
50467
50872
|
);
|
|
50468
|
-
var AgentContractsConfigSchema =
|
|
50469
|
-
dsl:
|
|
50470
|
-
vars:
|
|
50471
|
-
renders:
|
|
50873
|
+
var AgentContractsConfigSchema = z14.object({
|
|
50874
|
+
dsl: z14.string(),
|
|
50875
|
+
vars: z14.record(z14.string(), z14.string()).optional(),
|
|
50876
|
+
renders: z14.array(RenderTargetSchema).min(1),
|
|
50877
|
+
bindings: z14.array(z14.string()).default([]),
|
|
50878
|
+
active_guardrail_policy: z14.string().optional(),
|
|
50879
|
+
paths: z14.record(z14.string(), z14.string()).optional()
|
|
50472
50880
|
});
|
|
50473
50881
|
|
|
50474
50882
|
// src/config/loader.ts
|
|
50475
|
-
import { readFile, access } from "fs/promises";
|
|
50476
|
-
import { resolve, dirname } from "path";
|
|
50477
|
-
import { parse as parseYaml } from "yaml";
|
|
50478
50883
|
var DEFAULT_CONFIG_NAME = "agent-contracts.config.yaml";
|
|
50479
50884
|
var ConfigLoadError = class extends Error {
|
|
50480
50885
|
constructor(message, filePath) {
|
|
@@ -50542,7 +50947,10 @@ ${issues}`,
|
|
|
50542
50947
|
template: resolve(configDir, r3.template),
|
|
50543
50948
|
output: resolve(configDir, r3.output)
|
|
50544
50949
|
})),
|
|
50545
|
-
configDir
|
|
50950
|
+
configDir,
|
|
50951
|
+
bindings: (config.bindings ?? []).map((b3) => resolve(configDir, b3)),
|
|
50952
|
+
activeGuardrailPolicy: config.active_guardrail_policy,
|
|
50953
|
+
paths: config.paths
|
|
50546
50954
|
};
|
|
50547
50955
|
}
|
|
50548
50956
|
function resolveDslPath(dirArg, dirArgDefault, config) {
|
|
@@ -50555,14 +50963,51 @@ function resolveDslPath(dirArg, dirArgDefault, config) {
|
|
|
50555
50963
|
return resolve(dirArgDefault);
|
|
50556
50964
|
}
|
|
50557
50965
|
|
|
50966
|
+
// src/config/binding-loader.ts
|
|
50967
|
+
async function loadBindings(bindingPaths) {
|
|
50968
|
+
const results = [];
|
|
50969
|
+
for (const filePath of bindingPaths) {
|
|
50970
|
+
let content;
|
|
50971
|
+
try {
|
|
50972
|
+
content = await readFile2(filePath, "utf8");
|
|
50973
|
+
} catch {
|
|
50974
|
+
throw new ConfigLoadError(
|
|
50975
|
+
`Failed to read binding file: ${filePath}`,
|
|
50976
|
+
filePath
|
|
50977
|
+
);
|
|
50978
|
+
}
|
|
50979
|
+
let raw;
|
|
50980
|
+
try {
|
|
50981
|
+
raw = parseYaml2(content);
|
|
50982
|
+
} catch (err) {
|
|
50983
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
50984
|
+
throw new ConfigLoadError(
|
|
50985
|
+
`Invalid YAML syntax in binding file ${filePath}: ${msg}`,
|
|
50986
|
+
filePath
|
|
50987
|
+
);
|
|
50988
|
+
}
|
|
50989
|
+
const result = SoftwareBindingSchema.safeParse(raw);
|
|
50990
|
+
if (!result.success) {
|
|
50991
|
+
const issues = result.error.issues.map((i3) => ` ${i3.path.join(".")}: ${i3.message}`).join("\n");
|
|
50992
|
+
throw new ConfigLoadError(
|
|
50993
|
+
`Invalid binding schema in ${filePath}:
|
|
50994
|
+
${issues}`,
|
|
50995
|
+
filePath
|
|
50996
|
+
);
|
|
50997
|
+
}
|
|
50998
|
+
results.push({ filePath, binding: result.data });
|
|
50999
|
+
}
|
|
51000
|
+
return results;
|
|
51001
|
+
}
|
|
51002
|
+
|
|
50558
51003
|
// src/resolver/base-resolver.ts
|
|
50559
51004
|
import { resolve as resolve3, join as join2 } from "path";
|
|
50560
51005
|
import { stat } from "fs/promises";
|
|
50561
51006
|
|
|
50562
51007
|
// src/loader/loader.ts
|
|
50563
|
-
import { readFile as
|
|
51008
|
+
import { readFile as readFile3, readdir, stat as fsStat } from "fs/promises";
|
|
50564
51009
|
import { dirname as dirname2, resolve as resolve2, join, extname } from "path";
|
|
50565
|
-
import { parse as
|
|
51010
|
+
import { parse as parseYaml3 } from "yaml";
|
|
50566
51011
|
var DslLoadError = class extends Error {
|
|
50567
51012
|
constructor(message, filePath) {
|
|
50568
51013
|
super(message);
|
|
@@ -50615,7 +51060,7 @@ function hasRefs(value) {
|
|
|
50615
51060
|
async function readYaml(filePath) {
|
|
50616
51061
|
let content;
|
|
50617
51062
|
try {
|
|
50618
|
-
content = await
|
|
51063
|
+
content = await readFile3(filePath, "utf8");
|
|
50619
51064
|
} catch {
|
|
50620
51065
|
throw new DslLoadError(
|
|
50621
51066
|
`File not found: ${filePath}`,
|
|
@@ -50623,7 +51068,7 @@ async function readYaml(filePath) {
|
|
|
50623
51068
|
);
|
|
50624
51069
|
}
|
|
50625
51070
|
try {
|
|
50626
|
-
return
|
|
51071
|
+
return parseYaml3(content);
|
|
50627
51072
|
} catch (err) {
|
|
50628
51073
|
const msg = err instanceof Error ? err.message : String(err);
|
|
50629
51074
|
throw new DslLoadError(
|
|
@@ -51104,6 +51549,8 @@ var MERGE_SECTIONS = [
|
|
|
51104
51549
|
"handoff_types",
|
|
51105
51550
|
"workflow",
|
|
51106
51551
|
"policies",
|
|
51552
|
+
"guardrails",
|
|
51553
|
+
"guardrail_policies",
|
|
51107
51554
|
"components"
|
|
51108
51555
|
];
|
|
51109
51556
|
function mergeDsl(base, project) {
|
|
@@ -51228,323 +51675,16 @@ var resolveCommand = new Command("resolve").description("Resolve DSL (load + mer
|
|
|
51228
51675
|
import { Command as Command2 } from "commander";
|
|
51229
51676
|
|
|
51230
51677
|
// src/validator/schema-validator.ts
|
|
51231
|
-
import { z as
|
|
51232
|
-
|
|
51233
|
-
// src/schema/agent.ts
|
|
51234
|
-
import { z as z2 } from "zod";
|
|
51235
|
-
var RuleSchema = z2.object({
|
|
51236
|
-
id: z2.string(),
|
|
51237
|
-
name: z2.string().optional(),
|
|
51238
|
-
description: z2.string(),
|
|
51239
|
-
severity: z2.enum(["mandatory", "recommended", "optional"]),
|
|
51240
|
-
detection_method: z2.string().optional(),
|
|
51241
|
-
escalation: z2.string().optional(),
|
|
51242
|
-
ref: z2.string().optional()
|
|
51243
|
-
}).passthrough();
|
|
51244
|
-
var EscalationCriterionSchema = z2.object({
|
|
51245
|
-
condition: z2.string(),
|
|
51246
|
-
action: z2.enum([
|
|
51247
|
-
"stop_and_report",
|
|
51248
|
-
"report_to_architect",
|
|
51249
|
-
"wait_for_approval"
|
|
51250
|
-
])
|
|
51251
|
-
}).passthrough();
|
|
51252
|
-
var PrerequisiteSchema = z2.object({
|
|
51253
|
-
action: z2.enum(["read", "execute"]),
|
|
51254
|
-
target: z2.string(),
|
|
51255
|
-
required: z2.boolean()
|
|
51256
|
-
}).passthrough();
|
|
51257
|
-
var AgentSchema = z2.object({
|
|
51258
|
-
role_name: z2.string(),
|
|
51259
|
-
purpose: z2.string(),
|
|
51260
|
-
can_read_artifacts: z2.array(z2.string()).default([]),
|
|
51261
|
-
can_write_artifacts: z2.array(z2.string()).default([]),
|
|
51262
|
-
can_execute_tools: z2.array(z2.string()).default([]),
|
|
51263
|
-
can_perform_validations: z2.array(z2.string()).default([]),
|
|
51264
|
-
can_invoke_agents: z2.array(z2.string()).default([]),
|
|
51265
|
-
can_return_handoffs: z2.array(z2.string()).default([]),
|
|
51266
|
-
dispatch_only: z2.boolean().optional(),
|
|
51267
|
-
mode: z2.enum(["read-only", "read-write"]).optional(),
|
|
51268
|
-
responsibilities: z2.array(z2.string()).optional(),
|
|
51269
|
-
constraints: z2.array(z2.string()).optional(),
|
|
51270
|
-
rules: z2.array(RuleSchema).optional(),
|
|
51271
|
-
anti_patterns: z2.array(z2.string()).optional(),
|
|
51272
|
-
escalation_criteria: z2.array(EscalationCriterionSchema).optional(),
|
|
51273
|
-
prerequisites: z2.array(PrerequisiteSchema).optional()
|
|
51274
|
-
}).passthrough();
|
|
51275
|
-
|
|
51276
|
-
// src/schema/artifact.ts
|
|
51277
|
-
import { z as z3 } from "zod";
|
|
51278
|
-
var ArtifactSchema = z3.object({
|
|
51279
|
-
type: z3.string(),
|
|
51280
|
-
description: z3.string().optional(),
|
|
51281
|
-
owner: z3.string(),
|
|
51282
|
-
producers: z3.array(z3.string()),
|
|
51283
|
-
editors: z3.array(z3.string()),
|
|
51284
|
-
consumers: z3.array(z3.string()),
|
|
51285
|
-
states: z3.array(z3.string()),
|
|
51286
|
-
required_validations: z3.array(z3.string()).default([]),
|
|
51287
|
-
visibility: z3.string().optional()
|
|
51288
|
-
}).passthrough();
|
|
51289
|
-
|
|
51290
|
-
// src/schema/dsl.ts
|
|
51291
|
-
import { z as z11 } from "zod";
|
|
51292
|
-
|
|
51293
|
-
// src/schema/handoff-type.ts
|
|
51294
|
-
import { z as z4 } from "zod";
|
|
51295
|
-
var HandoffTypeSchema = z4.object({
|
|
51296
|
-
version: z4.number(),
|
|
51297
|
-
description: z4.string().optional(),
|
|
51298
|
-
schema: z4.record(z4.string(), z4.any()),
|
|
51299
|
-
example: z4.record(z4.string(), z4.any()).optional()
|
|
51300
|
-
}).passthrough();
|
|
51301
|
-
|
|
51302
|
-
// src/schema/policy.ts
|
|
51303
|
-
import { z as z5 } from "zod";
|
|
51304
|
-
var PolicyWhenSchema = z5.object({
|
|
51305
|
-
artifact_type: z5.string().optional(),
|
|
51306
|
-
workflow: z5.string().optional()
|
|
51307
|
-
}).passthrough();
|
|
51308
|
-
var PolicySchema = z5.object({
|
|
51309
|
-
when: PolicyWhenSchema,
|
|
51310
|
-
requires_validations: z5.array(z5.string()).optional(),
|
|
51311
|
-
requires: z5.array(z5.string()).optional()
|
|
51312
|
-
}).passthrough();
|
|
51313
|
-
|
|
51314
|
-
// src/schema/system.ts
|
|
51315
|
-
import { z as z6 } from "zod";
|
|
51316
|
-
var VersionLiteralSchema = z6.literal(1);
|
|
51317
|
-
var ExtendsSchema = z6.string().optional();
|
|
51318
|
-
var SystemSchema = z6.object({
|
|
51319
|
-
id: z6.string(),
|
|
51320
|
-
name: z6.string(),
|
|
51321
|
-
default_workflow_order: z6.array(z6.string())
|
|
51322
|
-
}).passthrough();
|
|
51323
|
-
|
|
51324
|
-
// src/schema/task.ts
|
|
51325
|
-
import { z as z7 } from "zod";
|
|
51326
|
-
var ExecutionStepSchema = z7.object({
|
|
51327
|
-
id: z7.string(),
|
|
51328
|
-
action: z7.string(),
|
|
51329
|
-
description: z7.string().optional(),
|
|
51330
|
-
required: z7.boolean().optional(),
|
|
51331
|
-
abort_on_failure: z7.boolean().optional(),
|
|
51332
|
-
uses_tool: z7.string().optional(),
|
|
51333
|
-
produces_artifact: z7.string().optional(),
|
|
51334
|
-
reads_artifact: z7.string().optional(),
|
|
51335
|
-
depends_on: z7.array(z7.string()).optional(),
|
|
51336
|
-
skip_condition: z7.string().optional(),
|
|
51337
|
-
wait_for_approval: z7.boolean().optional()
|
|
51338
|
-
}).passthrough();
|
|
51339
|
-
var TaskSchema = z7.object({
|
|
51340
|
-
description: z7.string(),
|
|
51341
|
-
target_agent: z7.string(),
|
|
51342
|
-
allowed_from_agents: z7.array(z7.string()),
|
|
51343
|
-
workflow: z7.string(),
|
|
51344
|
-
input_artifacts: z7.array(z7.string()),
|
|
51345
|
-
invocation_handoff: z7.string(),
|
|
51346
|
-
result_handoff: z7.string(),
|
|
51347
|
-
default_priority: z7.string().optional(),
|
|
51348
|
-
responsibilities: z7.array(z7.string()).optional(),
|
|
51349
|
-
constraints: z7.array(z7.string()).optional(),
|
|
51350
|
-
execution_steps: z7.array(ExecutionStepSchema).optional(),
|
|
51351
|
-
completion_criteria: z7.array(z7.string()).optional(),
|
|
51352
|
-
rules: z7.array(RuleSchema).optional(),
|
|
51353
|
-
anti_patterns: z7.array(z7.string()).optional(),
|
|
51354
|
-
escalation_criteria: z7.array(EscalationCriterionSchema).optional(),
|
|
51355
|
-
validations: z7.array(z7.string()).default([])
|
|
51356
|
-
}).passthrough();
|
|
51357
|
-
|
|
51358
|
-
// src/schema/tool.ts
|
|
51359
|
-
import { z as z8 } from "zod";
|
|
51360
|
-
var CommandSchema = z8.object({
|
|
51361
|
-
command: z8.string(),
|
|
51362
|
-
category: z8.string(),
|
|
51363
|
-
reads: z8.array(z8.string()).default([]),
|
|
51364
|
-
writes: z8.array(z8.string()).default([]),
|
|
51365
|
-
purpose: z8.string().optional()
|
|
51366
|
-
});
|
|
51367
|
-
var ToolSchema = z8.object({
|
|
51368
|
-
kind: z8.string(),
|
|
51369
|
-
description: z8.string().optional(),
|
|
51370
|
-
input_artifacts: z8.array(z8.string()).default([]),
|
|
51371
|
-
output_artifacts: z8.array(z8.string()).default([]),
|
|
51372
|
-
invokable_by: z8.array(z8.string()),
|
|
51373
|
-
side_effects: z8.array(z8.string()).default([]),
|
|
51374
|
-
commands: z8.array(CommandSchema).default([])
|
|
51375
|
-
}).passthrough();
|
|
51376
|
-
|
|
51377
|
-
// src/schema/validation.ts
|
|
51378
|
-
import { z as z9 } from "zod";
|
|
51379
|
-
var ValidationSchema = z9.object({
|
|
51380
|
-
target_artifact: z9.string(),
|
|
51381
|
-
kind: z9.enum(["schema", "mechanical", "semantic", "approval"]),
|
|
51382
|
-
executor_type: z9.enum(["tool", "agent"]),
|
|
51383
|
-
executor: z9.string(),
|
|
51384
|
-
blocking: z9.boolean(),
|
|
51385
|
-
produces_evidence: z9.string().optional()
|
|
51386
|
-
}).passthrough();
|
|
51387
|
-
|
|
51388
|
-
// src/schema/workflow.ts
|
|
51389
|
-
import { z as z10 } from "zod";
|
|
51390
|
-
var RetrySchema = z10.object({
|
|
51391
|
-
condition: z10.string(),
|
|
51392
|
-
fix_task: z10.string(),
|
|
51393
|
-
revalidate_task: z10.string().optional()
|
|
51394
|
-
});
|
|
51395
|
-
var ExternalParticipantSchema = z10.object({
|
|
51396
|
-
id: z10.string(),
|
|
51397
|
-
kind: z10.enum(["actor", "participant"]),
|
|
51398
|
-
label: z10.string(),
|
|
51399
|
-
description: z10.string().optional()
|
|
51400
|
-
});
|
|
51401
|
-
var WorkflowDelegateStepSchema = z10.object({
|
|
51402
|
-
type: z10.literal("delegate"),
|
|
51403
|
-
description: z10.string().optional(),
|
|
51404
|
-
task: z10.string(),
|
|
51405
|
-
from_agent: z10.string(),
|
|
51406
|
-
group: z10.string().optional(),
|
|
51407
|
-
retry: RetrySchema.optional()
|
|
51408
|
-
}).passthrough();
|
|
51409
|
-
var WorkflowGateStepSchema = z10.object({
|
|
51410
|
-
type: z10.literal("gate"),
|
|
51411
|
-
description: z10.string().optional(),
|
|
51412
|
-
gate_kind: z10.string(),
|
|
51413
|
-
group: z10.string().optional()
|
|
51414
|
-
}).passthrough();
|
|
51415
|
-
var WorkflowHandoffStepSchema = z10.object({
|
|
51416
|
-
type: z10.literal("handoff"),
|
|
51417
|
-
description: z10.string().optional(),
|
|
51418
|
-
handoff_kind: z10.string(),
|
|
51419
|
-
task: z10.string().optional(),
|
|
51420
|
-
from_agent: z10.string().optional(),
|
|
51421
|
-
group: z10.string().optional(),
|
|
51422
|
-
retry: RetrySchema.optional()
|
|
51423
|
-
}).passthrough();
|
|
51424
|
-
var WorkflowValidationStepSchema = z10.object({
|
|
51425
|
-
type: z10.literal("validation"),
|
|
51426
|
-
description: z10.string().optional(),
|
|
51427
|
-
validation: z10.string(),
|
|
51428
|
-
group: z10.string().optional()
|
|
51429
|
-
}).passthrough();
|
|
51430
|
-
var WorkflowDecisionStepSchema = z10.object({
|
|
51431
|
-
type: z10.literal("decision"),
|
|
51432
|
-
description: z10.string().optional(),
|
|
51433
|
-
on: z10.string(),
|
|
51434
|
-
branches: z10.record(z10.string(), z10.array(z10.string())),
|
|
51435
|
-
group: z10.string().optional()
|
|
51436
|
-
}).passthrough();
|
|
51437
|
-
var WorkflowStepSchema = z10.discriminatedUnion("type", [
|
|
51438
|
-
WorkflowDelegateStepSchema,
|
|
51439
|
-
WorkflowGateStepSchema,
|
|
51440
|
-
WorkflowHandoffStepSchema,
|
|
51441
|
-
WorkflowValidationStepSchema,
|
|
51442
|
-
WorkflowDecisionStepSchema
|
|
51443
|
-
]);
|
|
51444
|
-
var WorkflowSchema = z10.object({
|
|
51445
|
-
description: z10.string().optional(),
|
|
51446
|
-
entry_conditions: z10.array(z10.string()).default([]),
|
|
51447
|
-
trigger: z10.string().optional(),
|
|
51448
|
-
steps: z10.array(WorkflowStepSchema),
|
|
51449
|
-
external_participants: z10.array(ExternalParticipantSchema).default([])
|
|
51450
|
-
}).passthrough();
|
|
51451
|
-
|
|
51452
|
-
// src/schema/dsl.ts
|
|
51453
|
-
var ComponentsSchema = z11.object({
|
|
51454
|
-
schemas: z11.record(z11.string(), z11.record(z11.string(), z11.any())).default({})
|
|
51455
|
-
}).passthrough();
|
|
51456
|
-
var DslSchema = z11.object({
|
|
51457
|
-
version: z11.literal(1),
|
|
51458
|
-
extends: z11.string().optional(),
|
|
51459
|
-
system: SystemSchema,
|
|
51460
|
-
agents: z11.record(z11.string(), AgentSchema).default({}),
|
|
51461
|
-
tasks: z11.record(z11.string(), TaskSchema).default({}),
|
|
51462
|
-
artifacts: z11.record(z11.string(), ArtifactSchema).default({}),
|
|
51463
|
-
tools: z11.record(z11.string(), ToolSchema).default({}),
|
|
51464
|
-
validations: z11.record(z11.string(), ValidationSchema).default({}),
|
|
51465
|
-
handoff_types: z11.record(z11.string(), HandoffTypeSchema).default({}),
|
|
51466
|
-
workflow: z11.record(z11.string(), WorkflowSchema).default({}),
|
|
51467
|
-
policies: z11.record(z11.string(), PolicySchema).default({}),
|
|
51468
|
-
components: ComponentsSchema.default({ schemas: {} })
|
|
51469
|
-
}).passthrough();
|
|
51470
|
-
|
|
51471
|
-
// src/schema/json-schema-utils.ts
|
|
51472
|
-
function resolveAllOf(schema) {
|
|
51473
|
-
const allOf = schema["allOf"];
|
|
51474
|
-
if (!Array.isArray(allOf)) return schema;
|
|
51475
|
-
let mergedProperties = {};
|
|
51476
|
-
let mergedRequired = [];
|
|
51477
|
-
const mergedTop = {};
|
|
51478
|
-
for (const sub of allOf) {
|
|
51479
|
-
if (typeof sub !== "object" || sub === null || Array.isArray(sub)) continue;
|
|
51480
|
-
const subSchema = sub;
|
|
51481
|
-
if (subSchema["properties"] && typeof subSchema["properties"] === "object") {
|
|
51482
|
-
mergedProperties = {
|
|
51483
|
-
...mergedProperties,
|
|
51484
|
-
...subSchema["properties"]
|
|
51485
|
-
};
|
|
51486
|
-
}
|
|
51487
|
-
if (Array.isArray(subSchema["required"])) {
|
|
51488
|
-
mergedRequired = [
|
|
51489
|
-
...mergedRequired,
|
|
51490
|
-
...subSchema["required"]
|
|
51491
|
-
];
|
|
51492
|
-
}
|
|
51493
|
-
for (const [key, value] of Object.entries(subSchema)) {
|
|
51494
|
-
if (key !== "properties" && key !== "required" && key !== "allOf") {
|
|
51495
|
-
mergedTop[key] = value;
|
|
51496
|
-
}
|
|
51497
|
-
}
|
|
51498
|
-
}
|
|
51499
|
-
for (const [key, value] of Object.entries(schema)) {
|
|
51500
|
-
if (key === "allOf") continue;
|
|
51501
|
-
if (key === "properties" && typeof value === "object") {
|
|
51502
|
-
mergedProperties = { ...mergedProperties, ...value };
|
|
51503
|
-
} else if (key === "required" && Array.isArray(value)) {
|
|
51504
|
-
mergedRequired = [...mergedRequired, ...value];
|
|
51505
|
-
} else {
|
|
51506
|
-
mergedTop[key] = value;
|
|
51507
|
-
}
|
|
51508
|
-
}
|
|
51509
|
-
const result = { ...mergedTop };
|
|
51510
|
-
if (Object.keys(mergedProperties).length > 0) {
|
|
51511
|
-
result["properties"] = mergedProperties;
|
|
51512
|
-
}
|
|
51513
|
-
if (mergedRequired.length > 0) {
|
|
51514
|
-
result["required"] = [...new Set(mergedRequired)];
|
|
51515
|
-
}
|
|
51516
|
-
return result;
|
|
51517
|
-
}
|
|
51518
|
-
|
|
51519
|
-
// src/schema/merge-operators.ts
|
|
51520
|
-
import { z as z12 } from "zod";
|
|
51521
|
-
var AppendOperatorSchema = z12.object({
|
|
51522
|
-
$append: z12.record(z12.string(), z12.any())
|
|
51523
|
-
});
|
|
51524
|
-
var PrependOperatorSchema = z12.object({
|
|
51525
|
-
$prepend: z12.record(z12.string(), z12.any())
|
|
51526
|
-
});
|
|
51527
|
-
var InsertAfterOperatorSchema = z12.object({
|
|
51528
|
-
$insert_after: z12.object({
|
|
51529
|
-
after: z12.string(),
|
|
51530
|
-
entries: z12.record(z12.string(), z12.any())
|
|
51531
|
-
})
|
|
51532
|
-
});
|
|
51533
|
-
var ReplaceOperatorSchema = z12.object({ $replace: z12.any() });
|
|
51534
|
-
var RemoveOperatorSchema = z12.object({
|
|
51535
|
-
$remove: z12.array(z12.string())
|
|
51536
|
-
});
|
|
51537
|
-
|
|
51538
|
-
// src/validator/schema-validator.ts
|
|
51678
|
+
import { z as z15 } from "zod";
|
|
51539
51679
|
function unwrap(schema) {
|
|
51540
|
-
if (schema instanceof
|
|
51541
|
-
if (schema instanceof
|
|
51542
|
-
if (schema instanceof
|
|
51680
|
+
if (schema instanceof z15.ZodOptional) return unwrap(schema.unwrap());
|
|
51681
|
+
if (schema instanceof z15.ZodDefault) return unwrap(schema.removeDefault());
|
|
51682
|
+
if (schema instanceof z15.ZodNullable) return unwrap(schema.unwrap());
|
|
51543
51683
|
return schema;
|
|
51544
51684
|
}
|
|
51545
51685
|
function checkCustomPropsRecursive(data, schema, path) {
|
|
51546
51686
|
const inner = unwrap(schema);
|
|
51547
|
-
if (inner instanceof
|
|
51687
|
+
if (inner instanceof z15.ZodObject) {
|
|
51548
51688
|
if (typeof data !== "object" || data === null || Array.isArray(data)) return [];
|
|
51549
51689
|
const obj = data;
|
|
51550
51690
|
const shape = inner.shape;
|
|
@@ -51565,7 +51705,7 @@ function checkCustomPropsRecursive(data, schema, path) {
|
|
|
51565
51705
|
}
|
|
51566
51706
|
return diagnostics;
|
|
51567
51707
|
}
|
|
51568
|
-
if (inner instanceof
|
|
51708
|
+
if (inner instanceof z15.ZodRecord) {
|
|
51569
51709
|
if (typeof data !== "object" || data === null || Array.isArray(data)) return [];
|
|
51570
51710
|
const valueSchema = inner._def.valueType;
|
|
51571
51711
|
const diagnostics = [];
|
|
@@ -51574,7 +51714,7 @@ function checkCustomPropsRecursive(data, schema, path) {
|
|
|
51574
51714
|
}
|
|
51575
51715
|
return diagnostics;
|
|
51576
51716
|
}
|
|
51577
|
-
if (inner instanceof
|
|
51717
|
+
if (inner instanceof z15.ZodArray) {
|
|
51578
51718
|
if (!Array.isArray(data)) return [];
|
|
51579
51719
|
const diagnostics = [];
|
|
51580
51720
|
for (let i3 = 0; i3 < data.length; i3++) {
|
|
@@ -51582,14 +51722,14 @@ function checkCustomPropsRecursive(data, schema, path) {
|
|
|
51582
51722
|
}
|
|
51583
51723
|
return diagnostics;
|
|
51584
51724
|
}
|
|
51585
|
-
if (inner instanceof
|
|
51725
|
+
if (inner instanceof z15.ZodDiscriminatedUnion) {
|
|
51586
51726
|
if (typeof data !== "object" || data === null) return [];
|
|
51587
51727
|
const obj = data;
|
|
51588
51728
|
const disc = inner._def.discriminator;
|
|
51589
51729
|
const discValue = obj[disc];
|
|
51590
51730
|
const match = inner.options.find((opt) => {
|
|
51591
51731
|
const shape = opt.shape;
|
|
51592
|
-
return shape[disc] instanceof
|
|
51732
|
+
return shape[disc] instanceof z15.ZodLiteral && shape[disc].value === discValue;
|
|
51593
51733
|
});
|
|
51594
51734
|
if (match) return checkCustomPropsRecursive(data, match, path);
|
|
51595
51735
|
return [];
|
|
@@ -51623,12 +51763,13 @@ function checkReferences(dsl) {
|
|
|
51623
51763
|
const handoffKinds = new Set(Object.keys(dsl.handoff_types));
|
|
51624
51764
|
const taskIds = new Set(Object.keys(dsl.tasks));
|
|
51625
51765
|
const workflowIds = new Set(dsl.system.default_workflow_order);
|
|
51626
|
-
|
|
51766
|
+
const guardrailIds = new Set(Object.keys(dsl.guardrails));
|
|
51767
|
+
function checkExists(value, validSet, entityType, path, code = "reference-not-found") {
|
|
51627
51768
|
if (!validSet.has(value)) {
|
|
51628
51769
|
diagnostics.push({
|
|
51629
51770
|
path,
|
|
51630
51771
|
message: `Reference "${value}" not found in ${entityType}`,
|
|
51631
|
-
code
|
|
51772
|
+
code
|
|
51632
51773
|
});
|
|
51633
51774
|
}
|
|
51634
51775
|
}
|
|
@@ -51816,6 +51957,75 @@ function checkReferences(dsl) {
|
|
|
51816
51957
|
}
|
|
51817
51958
|
}
|
|
51818
51959
|
}
|
|
51960
|
+
for (const [id, guardrail] of Object.entries(dsl.guardrails)) {
|
|
51961
|
+
if (guardrail.scope.agents) {
|
|
51962
|
+
for (const ref of guardrail.scope.agents) {
|
|
51963
|
+
checkExists(
|
|
51964
|
+
ref,
|
|
51965
|
+
agentIds,
|
|
51966
|
+
"agents",
|
|
51967
|
+
`guardrails.${id}.scope.agents`,
|
|
51968
|
+
"guardrail-scope-ref-not-found"
|
|
51969
|
+
);
|
|
51970
|
+
}
|
|
51971
|
+
}
|
|
51972
|
+
if (guardrail.scope.tasks) {
|
|
51973
|
+
for (const ref of guardrail.scope.tasks) {
|
|
51974
|
+
checkExists(
|
|
51975
|
+
ref,
|
|
51976
|
+
taskIds,
|
|
51977
|
+
"tasks",
|
|
51978
|
+
`guardrails.${id}.scope.tasks`,
|
|
51979
|
+
"guardrail-scope-ref-not-found"
|
|
51980
|
+
);
|
|
51981
|
+
}
|
|
51982
|
+
}
|
|
51983
|
+
if (guardrail.scope.tools) {
|
|
51984
|
+
for (const ref of guardrail.scope.tools) {
|
|
51985
|
+
checkExists(
|
|
51986
|
+
ref,
|
|
51987
|
+
toolIds,
|
|
51988
|
+
"tools",
|
|
51989
|
+
`guardrails.${id}.scope.tools`,
|
|
51990
|
+
"guardrail-scope-ref-not-found"
|
|
51991
|
+
);
|
|
51992
|
+
}
|
|
51993
|
+
}
|
|
51994
|
+
if (guardrail.scope.artifacts) {
|
|
51995
|
+
for (const ref of guardrail.scope.artifacts) {
|
|
51996
|
+
checkExists(
|
|
51997
|
+
ref,
|
|
51998
|
+
artifactIds,
|
|
51999
|
+
"artifacts",
|
|
52000
|
+
`guardrails.${id}.scope.artifacts`,
|
|
52001
|
+
"guardrail-scope-ref-not-found"
|
|
52002
|
+
);
|
|
52003
|
+
}
|
|
52004
|
+
}
|
|
52005
|
+
if (guardrail.scope.workflows) {
|
|
52006
|
+
for (const ref of guardrail.scope.workflows) {
|
|
52007
|
+
checkExists(
|
|
52008
|
+
ref,
|
|
52009
|
+
workflowIds,
|
|
52010
|
+
"system.default_workflow_order",
|
|
52011
|
+
`guardrails.${id}.scope.workflows`,
|
|
52012
|
+
"guardrail-scope-ref-not-found"
|
|
52013
|
+
);
|
|
52014
|
+
}
|
|
52015
|
+
}
|
|
52016
|
+
}
|
|
52017
|
+
for (const [policyId, policy] of Object.entries(dsl.guardrail_policies)) {
|
|
52018
|
+
for (let i3 = 0; i3 < policy.rules.length; i3++) {
|
|
52019
|
+
const rule = policy.rules[i3];
|
|
52020
|
+
checkExists(
|
|
52021
|
+
rule.guardrail,
|
|
52022
|
+
guardrailIds,
|
|
52023
|
+
"guardrails",
|
|
52024
|
+
`guardrail_policies.${policyId}.rules[${i3}].guardrail`,
|
|
52025
|
+
"guardrail-policy-ref-not-found"
|
|
52026
|
+
);
|
|
52027
|
+
}
|
|
52028
|
+
}
|
|
51819
52029
|
return diagnostics;
|
|
51820
52030
|
}
|
|
51821
52031
|
|
|
@@ -52239,6 +52449,32 @@ var toolCommandsRule = {
|
|
|
52239
52449
|
}
|
|
52240
52450
|
};
|
|
52241
52451
|
|
|
52452
|
+
// src/linter/rules/guardrail-policy-coverage.ts
|
|
52453
|
+
var guardrailPolicyCoverageRule = {
|
|
52454
|
+
id: "guardrail-no-policy-rule",
|
|
52455
|
+
description: "Every guardrail should be referenced by at least one policy rule in guardrail_policies",
|
|
52456
|
+
run(dsl) {
|
|
52457
|
+
const diagnostics = [];
|
|
52458
|
+
const referencedGuardrails = /* @__PURE__ */ new Set();
|
|
52459
|
+
for (const policy of Object.values(dsl.guardrail_policies)) {
|
|
52460
|
+
for (const rule of policy.rules) {
|
|
52461
|
+
referencedGuardrails.add(rule.guardrail);
|
|
52462
|
+
}
|
|
52463
|
+
}
|
|
52464
|
+
for (const guardrailId of Object.keys(dsl.guardrails)) {
|
|
52465
|
+
if (!referencedGuardrails.has(guardrailId)) {
|
|
52466
|
+
diagnostics.push({
|
|
52467
|
+
ruleId: "guardrail-no-policy-rule",
|
|
52468
|
+
severity: "warning",
|
|
52469
|
+
path: `guardrails.${guardrailId}`,
|
|
52470
|
+
message: `Guardrail "${guardrailId}" is not referenced by any policy rule in guardrail_policies`
|
|
52471
|
+
});
|
|
52472
|
+
}
|
|
52473
|
+
}
|
|
52474
|
+
return diagnostics;
|
|
52475
|
+
}
|
|
52476
|
+
};
|
|
52477
|
+
|
|
52242
52478
|
// src/linter/linter.ts
|
|
52243
52479
|
var builtinRules = [
|
|
52244
52480
|
validationCoverageRule,
|
|
@@ -52246,7 +52482,8 @@ var builtinRules = [
|
|
|
52246
52482
|
taskAgentBindingRule,
|
|
52247
52483
|
mergeIntegrityRule,
|
|
52248
52484
|
artifactOwnershipRule,
|
|
52249
|
-
toolCommandsRule
|
|
52485
|
+
toolCommandsRule,
|
|
52486
|
+
guardrailPolicyCoverageRule
|
|
52250
52487
|
];
|
|
52251
52488
|
function lint(dsl, rules = builtinRules) {
|
|
52252
52489
|
const diagnostics = [];
|
|
@@ -52941,7 +53178,7 @@ var lintCommand = new Command3("lint").description("Run semantic lint rules on r
|
|
|
52941
53178
|
import { Command as Command4 } from "commander";
|
|
52942
53179
|
|
|
52943
53180
|
// src/renderer/renderer.ts
|
|
52944
|
-
import { readFile as
|
|
53181
|
+
import { readFile as readFile4, writeFile, mkdir } from "fs/promises";
|
|
52945
53182
|
import { dirname as dirname4 } from "path";
|
|
52946
53183
|
import Handlebars from "handlebars";
|
|
52947
53184
|
|
|
@@ -53154,6 +53391,16 @@ function buildPolicyContext(dsl, policyId) {
|
|
|
53154
53391
|
const policy = { ...policyDef, id: policyId };
|
|
53155
53392
|
return { policy, dsl };
|
|
53156
53393
|
}
|
|
53394
|
+
function buildGuardrailContext(dsl, guardrailId) {
|
|
53395
|
+
const guardrailDef = dsl.guardrails[guardrailId];
|
|
53396
|
+
const guardrail = { ...guardrailDef, id: guardrailId };
|
|
53397
|
+
return { guardrail, dsl };
|
|
53398
|
+
}
|
|
53399
|
+
function buildGuardrailPolicyContext(dsl, policyId) {
|
|
53400
|
+
const policyDef = dsl.guardrail_policies[policyId];
|
|
53401
|
+
const guardrail_policy = { ...policyDef, id: policyId };
|
|
53402
|
+
return { guardrail_policy, dsl };
|
|
53403
|
+
}
|
|
53157
53404
|
function mergeRules(agentRules, taskRules) {
|
|
53158
53405
|
const result = [...agentRules];
|
|
53159
53406
|
const existingIds = new Set(result.map((r3) => r3["id"]));
|
|
@@ -54001,7 +54248,9 @@ function getDslSection(dsl, context) {
|
|
|
54001
54248
|
validation: dsl.validations,
|
|
54002
54249
|
handoff_type: dsl.handoff_types,
|
|
54003
54250
|
workflow: dsl.workflow,
|
|
54004
|
-
policy: dsl.policies
|
|
54251
|
+
policy: dsl.policies,
|
|
54252
|
+
guardrail: dsl.guardrails,
|
|
54253
|
+
guardrail_policy: dsl.guardrail_policies
|
|
54005
54254
|
};
|
|
54006
54255
|
return sectionMap[context] ?? {};
|
|
54007
54256
|
}
|
|
@@ -54034,12 +54283,16 @@ function buildEntityContext(dsl, context, entityId) {
|
|
|
54034
54283
|
return buildWorkflowContext(dsl, entityId);
|
|
54035
54284
|
case "policy":
|
|
54036
54285
|
return buildPolicyContext(dsl, entityId);
|
|
54286
|
+
case "guardrail":
|
|
54287
|
+
return buildGuardrailContext(dsl, entityId);
|
|
54288
|
+
case "guardrail_policy":
|
|
54289
|
+
return buildGuardrailPolicyContext(dsl, entityId);
|
|
54037
54290
|
case "system":
|
|
54038
54291
|
return buildSystemContext(dsl);
|
|
54039
54292
|
}
|
|
54040
54293
|
}
|
|
54041
54294
|
async function loadTemplate(templatePath) {
|
|
54042
|
-
return
|
|
54295
|
+
return readFile4(templatePath, "utf8");
|
|
54043
54296
|
}
|
|
54044
54297
|
async function renderFromConfig(dsl, renderTargets) {
|
|
54045
54298
|
const outputFiles = [];
|
|
@@ -54077,7 +54330,7 @@ async function checkDriftFromConfig(dsl, renderTargets) {
|
|
|
54077
54330
|
const ctx = buildSystemContext(dsl);
|
|
54078
54331
|
const expected = compiled(ctx);
|
|
54079
54332
|
try {
|
|
54080
|
-
const existing = await
|
|
54333
|
+
const existing = await readFile4(target.output, "utf8");
|
|
54081
54334
|
if (existing !== expected) diffs.push(target.output);
|
|
54082
54335
|
} catch {
|
|
54083
54336
|
diffs.push(target.output);
|
|
@@ -54091,7 +54344,7 @@ async function checkDriftFromConfig(dsl, renderTargets) {
|
|
|
54091
54344
|
const expected = compiled(ctx);
|
|
54092
54345
|
const outputPath = expandOutputPath(target.output, target.context, entityId);
|
|
54093
54346
|
try {
|
|
54094
|
-
const existing = await
|
|
54347
|
+
const existing = await readFile4(outputPath, "utf8");
|
|
54095
54348
|
if (existing !== expected) diffs.push(outputPath);
|
|
54096
54349
|
} catch {
|
|
54097
54350
|
diffs.push(outputPath);
|
|
@@ -54249,14 +54502,322 @@ var checkCommand = new Command5("check").description("Run full pipeline: resolve
|
|
|
54249
54502
|
}
|
|
54250
54503
|
);
|
|
54251
54504
|
|
|
54505
|
+
// src/cli/commands/generate-guardrails.ts
|
|
54506
|
+
import { Command as Command6 } from "commander";
|
|
54507
|
+
|
|
54508
|
+
// src/guardrail-generator/generator.ts
|
|
54509
|
+
import { readFile as readFile5, writeFile as writeFile2, mkdir as mkdir2, chmod } from "fs/promises";
|
|
54510
|
+
import { resolve as resolve5, dirname as dirname5 } from "path";
|
|
54511
|
+
import Handlebars2 from "handlebars";
|
|
54512
|
+
|
|
54513
|
+
// src/guardrail-generator/resolve-checks.ts
|
|
54514
|
+
function resolveChecks(dsl, binding, policy) {
|
|
54515
|
+
const resolved = [];
|
|
54516
|
+
const diagnostics = [];
|
|
54517
|
+
const guardrailImpl = binding.guardrail_impl ?? {};
|
|
54518
|
+
for (const [guardrailId, impl] of Object.entries(guardrailImpl)) {
|
|
54519
|
+
const guardrail = dsl.guardrails[guardrailId];
|
|
54520
|
+
if (!guardrail) {
|
|
54521
|
+
diagnostics.push({
|
|
54522
|
+
path: `binding.${binding.software}.guardrail_impl.${guardrailId}`,
|
|
54523
|
+
message: `Binding "${binding.software}" implements guardrail "${guardrailId}" which is not defined in the DSL`,
|
|
54524
|
+
severity: "error"
|
|
54525
|
+
});
|
|
54526
|
+
continue;
|
|
54527
|
+
}
|
|
54528
|
+
const policyRule = policy.rules.find((r3) => r3.guardrail === guardrailId);
|
|
54529
|
+
if (!policyRule) {
|
|
54530
|
+
diagnostics.push({
|
|
54531
|
+
path: `binding.${binding.software}.guardrail_impl.${guardrailId}`,
|
|
54532
|
+
message: `Guardrail "${guardrailId}" has no policy rule in the active policy \u2014 skipping`,
|
|
54533
|
+
severity: "info"
|
|
54534
|
+
});
|
|
54535
|
+
continue;
|
|
54536
|
+
}
|
|
54537
|
+
for (const check of impl.checks) {
|
|
54538
|
+
resolved.push({
|
|
54539
|
+
guardrail_id: guardrailId,
|
|
54540
|
+
guardrail,
|
|
54541
|
+
policy_rule: policyRule,
|
|
54542
|
+
check
|
|
54543
|
+
});
|
|
54544
|
+
}
|
|
54545
|
+
}
|
|
54546
|
+
return { resolved, diagnostics };
|
|
54547
|
+
}
|
|
54548
|
+
|
|
54549
|
+
// src/guardrail-generator/resolve-paths.ts
|
|
54550
|
+
function resolveBindingTargetPath(target, paths, bindingSoftware) {
|
|
54551
|
+
const diagnostics = [];
|
|
54552
|
+
const resolved = target.replace(/\{(\w+)\}/g, (match, varName) => {
|
|
54553
|
+
const value = paths[varName];
|
|
54554
|
+
if (value === void 0) {
|
|
54555
|
+
diagnostics.push({
|
|
54556
|
+
path: `binding.${bindingSoftware}.outputs`,
|
|
54557
|
+
message: `Path variable "${varName}" used in target "${target}" but not defined in config.paths`,
|
|
54558
|
+
severity: "error"
|
|
54559
|
+
});
|
|
54560
|
+
return match;
|
|
54561
|
+
}
|
|
54562
|
+
return value;
|
|
54563
|
+
});
|
|
54564
|
+
return { resolved, diagnostics };
|
|
54565
|
+
}
|
|
54566
|
+
|
|
54567
|
+
// src/guardrail-generator/generator.ts
|
|
54568
|
+
Handlebars2.registerHelper("json", (value) => {
|
|
54569
|
+
return new Handlebars2.SafeString(JSON.stringify(value, null, 2));
|
|
54570
|
+
});
|
|
54571
|
+
Handlebars2.registerHelper(
|
|
54572
|
+
"expand",
|
|
54573
|
+
(pattern, options) => {
|
|
54574
|
+
if (typeof pattern !== "string") return "";
|
|
54575
|
+
const hash = options.hash;
|
|
54576
|
+
let result = pattern;
|
|
54577
|
+
for (const [key, val] of Object.entries(hash)) {
|
|
54578
|
+
result = result.replace(new RegExp(`\\{\\{${key}\\}\\}`, "g"), String(val));
|
|
54579
|
+
}
|
|
54580
|
+
return new Handlebars2.SafeString(result);
|
|
54581
|
+
}
|
|
54582
|
+
);
|
|
54583
|
+
async function generateGuardrails(options) {
|
|
54584
|
+
const { dsl, config, loadedBindings, filterBindings, dryRun } = options;
|
|
54585
|
+
const outputFiles = [];
|
|
54586
|
+
const diagnostics = [];
|
|
54587
|
+
const policyName = config.activeGuardrailPolicy;
|
|
54588
|
+
if (!policyName) {
|
|
54589
|
+
diagnostics.push({
|
|
54590
|
+
path: "config.active_guardrail_policy",
|
|
54591
|
+
message: "No active_guardrail_policy specified in config \u2014 no guardrails will be generated",
|
|
54592
|
+
severity: "warning"
|
|
54593
|
+
});
|
|
54594
|
+
return { outputFiles, diagnostics };
|
|
54595
|
+
}
|
|
54596
|
+
const policy = dsl.guardrail_policies[policyName];
|
|
54597
|
+
if (!policy) {
|
|
54598
|
+
diagnostics.push({
|
|
54599
|
+
path: "config.active_guardrail_policy",
|
|
54600
|
+
message: `Active guardrail policy "${policyName}" not found in DSL guardrail_policies`,
|
|
54601
|
+
severity: "error"
|
|
54602
|
+
});
|
|
54603
|
+
return { outputFiles, diagnostics };
|
|
54604
|
+
}
|
|
54605
|
+
const allBindings = {};
|
|
54606
|
+
for (const lb of loadedBindings) {
|
|
54607
|
+
allBindings[lb.binding.software] = lb.binding;
|
|
54608
|
+
}
|
|
54609
|
+
let reporting = null;
|
|
54610
|
+
for (const lb of loadedBindings) {
|
|
54611
|
+
if (lb.binding.reporting) {
|
|
54612
|
+
reporting = {
|
|
54613
|
+
commands: lb.binding.reporting.commands,
|
|
54614
|
+
fail_open: lb.binding.reporting.fail_open,
|
|
54615
|
+
timeout_ms: lb.binding.reporting.timeout_ms
|
|
54616
|
+
};
|
|
54617
|
+
break;
|
|
54618
|
+
}
|
|
54619
|
+
}
|
|
54620
|
+
const paths = config.paths ?? {};
|
|
54621
|
+
const vars = config.vars ?? {};
|
|
54622
|
+
for (const lb of loadedBindings) {
|
|
54623
|
+
const binding = lb.binding;
|
|
54624
|
+
if (filterBindings && !filterBindings.includes(binding.software)) {
|
|
54625
|
+
continue;
|
|
54626
|
+
}
|
|
54627
|
+
if (!binding.outputs) continue;
|
|
54628
|
+
const checkResult = resolveChecks(dsl, binding, policy);
|
|
54629
|
+
diagnostics.push(...checkResult.diagnostics);
|
|
54630
|
+
const ctx = {
|
|
54631
|
+
system: { id: dsl.system.id, name: dsl.system.name },
|
|
54632
|
+
guardrails: dsl.guardrails,
|
|
54633
|
+
policy,
|
|
54634
|
+
binding,
|
|
54635
|
+
all_bindings: allBindings,
|
|
54636
|
+
vars,
|
|
54637
|
+
paths,
|
|
54638
|
+
reporting,
|
|
54639
|
+
resolved_checks: checkResult.resolved
|
|
54640
|
+
};
|
|
54641
|
+
for (const [outputId, outputDef] of Object.entries(binding.outputs)) {
|
|
54642
|
+
const pathResult = resolveBindingTargetPath(
|
|
54643
|
+
outputDef.target,
|
|
54644
|
+
paths,
|
|
54645
|
+
binding.software
|
|
54646
|
+
);
|
|
54647
|
+
diagnostics.push(...pathResult.diagnostics);
|
|
54648
|
+
if (pathResult.diagnostics.some((d2) => d2.severity === "error")) {
|
|
54649
|
+
continue;
|
|
54650
|
+
}
|
|
54651
|
+
const targetPath = resolve5(config.configDir, pathResult.resolved);
|
|
54652
|
+
let templateContent;
|
|
54653
|
+
if (outputDef.inline_template) {
|
|
54654
|
+
templateContent = outputDef.inline_template;
|
|
54655
|
+
} else if (outputDef.template) {
|
|
54656
|
+
if (outputDef.template.startsWith("builtin:")) {
|
|
54657
|
+
diagnostics.push({
|
|
54658
|
+
path: `binding.${binding.software}.outputs.${outputId}`,
|
|
54659
|
+
message: `Builtin template "${outputDef.template}" is not yet implemented \u2014 skipping`,
|
|
54660
|
+
severity: "info"
|
|
54661
|
+
});
|
|
54662
|
+
continue;
|
|
54663
|
+
}
|
|
54664
|
+
const templatePath = resolve5(config.configDir, outputDef.template);
|
|
54665
|
+
try {
|
|
54666
|
+
templateContent = await readFile5(templatePath, "utf8");
|
|
54667
|
+
} catch {
|
|
54668
|
+
diagnostics.push({
|
|
54669
|
+
path: `binding.${binding.software}.outputs.${outputId}`,
|
|
54670
|
+
message: `Template file not found: ${templatePath}`,
|
|
54671
|
+
severity: "error"
|
|
54672
|
+
});
|
|
54673
|
+
continue;
|
|
54674
|
+
}
|
|
54675
|
+
} else {
|
|
54676
|
+
diagnostics.push({
|
|
54677
|
+
path: `binding.${binding.software}.outputs.${outputId}`,
|
|
54678
|
+
message: "Output has neither template nor inline_template",
|
|
54679
|
+
severity: "error"
|
|
54680
|
+
});
|
|
54681
|
+
continue;
|
|
54682
|
+
}
|
|
54683
|
+
if (outputDef.group_by) {
|
|
54684
|
+
const groupField = outputDef.group_by;
|
|
54685
|
+
const groups = /* @__PURE__ */ new Map();
|
|
54686
|
+
for (const rc of checkResult.resolved) {
|
|
54687
|
+
const key = String(
|
|
54688
|
+
rc.check[groupField] ?? "default"
|
|
54689
|
+
);
|
|
54690
|
+
if (!groups.has(key)) groups.set(key, []);
|
|
54691
|
+
groups.get(key).push(rc);
|
|
54692
|
+
}
|
|
54693
|
+
for (const [groupKey, groupChecks] of groups) {
|
|
54694
|
+
const groupCtx = {
|
|
54695
|
+
...ctx,
|
|
54696
|
+
resolved_checks: groupChecks,
|
|
54697
|
+
current_group: groupKey
|
|
54698
|
+
};
|
|
54699
|
+
const compiled = Handlebars2.compile(templateContent, { noEscape: true });
|
|
54700
|
+
const output = compiled(groupCtx);
|
|
54701
|
+
const groupTarget = resolve5(targetPath, groupKey);
|
|
54702
|
+
if (!dryRun) {
|
|
54703
|
+
await mkdir2(dirname5(groupTarget), { recursive: true });
|
|
54704
|
+
await writeFile2(groupTarget, output, "utf8");
|
|
54705
|
+
if (outputDef.executable) {
|
|
54706
|
+
await chmod(groupTarget, 493);
|
|
54707
|
+
}
|
|
54708
|
+
}
|
|
54709
|
+
outputFiles.push(groupTarget);
|
|
54710
|
+
}
|
|
54711
|
+
} else {
|
|
54712
|
+
const compiled = Handlebars2.compile(templateContent, { noEscape: true });
|
|
54713
|
+
const output = compiled(ctx);
|
|
54714
|
+
if (!dryRun) {
|
|
54715
|
+
await mkdir2(dirname5(targetPath), { recursive: true });
|
|
54716
|
+
await writeFile2(targetPath, output, "utf8");
|
|
54717
|
+
if (outputDef.executable) {
|
|
54718
|
+
await chmod(targetPath, 493);
|
|
54719
|
+
}
|
|
54720
|
+
}
|
|
54721
|
+
outputFiles.push(targetPath);
|
|
54722
|
+
}
|
|
54723
|
+
}
|
|
54724
|
+
}
|
|
54725
|
+
return { outputFiles, diagnostics };
|
|
54726
|
+
}
|
|
54727
|
+
|
|
54728
|
+
// src/cli/commands/generate-guardrails.ts
|
|
54729
|
+
var generateGuardrailsCommand = new Command6("generate").description("Generate guardrail runtime artifacts from DSL, policies, and bindings").argument("[type]", "Type of artifacts to generate", "guardrails").option("-c, --config <path>", "Path to agent-contracts.config.yaml").option("--binding <name...>", "Filter to specific software binding(s)").option("--dry-run", "Print what would be generated without writing files", false).option("--quiet", "Suppress output on success", false).action(
|
|
54730
|
+
async (type, opts) => {
|
|
54731
|
+
if (type !== "guardrails") {
|
|
54732
|
+
process.stderr.write(`Unknown generate type: ${type}
|
|
54733
|
+
`);
|
|
54734
|
+
process.exit(1);
|
|
54735
|
+
}
|
|
54736
|
+
try {
|
|
54737
|
+
const config = await loadConfig(opts.config);
|
|
54738
|
+
if (!config) {
|
|
54739
|
+
process.stderr.write(
|
|
54740
|
+
"Error: agent-contracts.config.yaml not found. Use --config to specify path.\n"
|
|
54741
|
+
);
|
|
54742
|
+
process.exit(1);
|
|
54743
|
+
}
|
|
54744
|
+
const resolved = await resolve4(config.dsl);
|
|
54745
|
+
const data = config.vars ? substituteVars(resolved.data, config.vars) : resolved.data;
|
|
54746
|
+
const schemaResult = validateSchema(data);
|
|
54747
|
+
if (!schemaResult.success) {
|
|
54748
|
+
process.stderr.write(
|
|
54749
|
+
"Schema validation failed. Run 'agent-contracts validate' for details.\n"
|
|
54750
|
+
);
|
|
54751
|
+
process.exit(1);
|
|
54752
|
+
}
|
|
54753
|
+
const loadedBindings = await loadBindings(config.bindings);
|
|
54754
|
+
const result = await generateGuardrails({
|
|
54755
|
+
dsl: schemaResult.data,
|
|
54756
|
+
config,
|
|
54757
|
+
loadedBindings,
|
|
54758
|
+
filterBindings: opts.binding,
|
|
54759
|
+
dryRun: opts.dryRun
|
|
54760
|
+
});
|
|
54761
|
+
const errors = result.diagnostics.filter((d2) => d2.severity === "error");
|
|
54762
|
+
const warnings = result.diagnostics.filter((d2) => d2.severity === "warning");
|
|
54763
|
+
const infos = result.diagnostics.filter((d2) => d2.severity === "info");
|
|
54764
|
+
if (errors.length > 0) {
|
|
54765
|
+
process.stderr.write("Errors:\n");
|
|
54766
|
+
for (const d2 of errors) {
|
|
54767
|
+
process.stderr.write(` error [${d2.path}] ${d2.message}
|
|
54768
|
+
`);
|
|
54769
|
+
}
|
|
54770
|
+
}
|
|
54771
|
+
if (warnings.length > 0 && !opts.quiet) {
|
|
54772
|
+
process.stderr.write("Warnings:\n");
|
|
54773
|
+
for (const d2 of warnings) {
|
|
54774
|
+
process.stderr.write(` warning [${d2.path}] ${d2.message}
|
|
54775
|
+
`);
|
|
54776
|
+
}
|
|
54777
|
+
}
|
|
54778
|
+
if (infos.length > 0 && !opts.quiet) {
|
|
54779
|
+
for (const d2 of infos) {
|
|
54780
|
+
process.stderr.write(` info [${d2.path}] ${d2.message}
|
|
54781
|
+
`);
|
|
54782
|
+
}
|
|
54783
|
+
}
|
|
54784
|
+
if (errors.length > 0) {
|
|
54785
|
+
process.exit(1);
|
|
54786
|
+
}
|
|
54787
|
+
if (!opts.quiet) {
|
|
54788
|
+
const action = opts.dryRun ? "Would generate" : "Generated";
|
|
54789
|
+
process.stdout.write(
|
|
54790
|
+
`${action} ${result.outputFiles.length} file(s):
|
|
54791
|
+
`
|
|
54792
|
+
);
|
|
54793
|
+
for (const f2 of result.outputFiles) {
|
|
54794
|
+
process.stdout.write(` ${f2}
|
|
54795
|
+
`);
|
|
54796
|
+
}
|
|
54797
|
+
}
|
|
54798
|
+
} catch (err) {
|
|
54799
|
+
if (err instanceof ConfigLoadError) {
|
|
54800
|
+
process.stderr.write(`Config error: ${err.message}
|
|
54801
|
+
`);
|
|
54802
|
+
process.exit(1);
|
|
54803
|
+
}
|
|
54804
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
54805
|
+
process.stderr.write(`Error: ${msg}
|
|
54806
|
+
`);
|
|
54807
|
+
process.exit(1);
|
|
54808
|
+
}
|
|
54809
|
+
}
|
|
54810
|
+
);
|
|
54811
|
+
|
|
54252
54812
|
// src/cli/cli.ts
|
|
54253
|
-
var program = new
|
|
54813
|
+
var program = new Command7();
|
|
54254
54814
|
program.name("agent-contracts").description("Agent contracts tooling \u2014 validate, lint, render DSL files").version("0.0.2");
|
|
54255
54815
|
program.addCommand(resolveCommand);
|
|
54256
54816
|
program.addCommand(validateCommand);
|
|
54257
54817
|
program.addCommand(lintCommand);
|
|
54258
54818
|
program.addCommand(renderCommand);
|
|
54259
54819
|
program.addCommand(checkCommand);
|
|
54820
|
+
program.addCommand(generateGuardrailsCommand);
|
|
54260
54821
|
program.parse();
|
|
54261
54822
|
/*! Bundled license information:
|
|
54262
54823
|
|