agent-contracts 0.10.0 → 0.11.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/README.md +192 -0
- package/dist/cli.js +1063 -400
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +297 -5
- package/dist/index.js +828 -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(resolve7) {
|
|
163
|
+
resolve7(value);
|
|
164
164
|
});
|
|
165
165
|
}
|
|
166
|
-
return new (P2 || (P2 = Promise))(function(
|
|
166
|
+
return new (P2 || (P2 = Promise))(function(resolve7, 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 ? resolve7(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(resolve7, reject) {
|
|
374
|
+
v2 = o3[n3](v2), settle(resolve7, reject, v2.done, v2.value);
|
|
375
375
|
});
|
|
376
376
|
};
|
|
377
377
|
}
|
|
378
|
-
function settle(
|
|
378
|
+
function settle(resolve7, reject, d2, v2) {
|
|
379
379
|
Promise.resolve(v2).then(function(v3) {
|
|
380
|
-
|
|
380
|
+
resolve7({ 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(resolve7) {
|
|
13037
|
+
resolve7(value);
|
|
13038
13038
|
});
|
|
13039
13039
|
}
|
|
13040
|
-
return new (P2 || (P2 = Promise))(function(
|
|
13040
|
+
return new (P2 || (P2 = Promise))(function(resolve7, 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 ? resolve7(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(resolve7, reject) {
|
|
13235
|
+
v2 = o3[n3](v2), settle(resolve7, reject, v2.done, v2.value);
|
|
13236
13236
|
});
|
|
13237
13237
|
};
|
|
13238
13238
|
}
|
|
13239
|
-
function settle(
|
|
13239
|
+
function settle(resolve7, reject, d2, v2) {
|
|
13240
13240
|
Promise.resolve(v2).then(function(v3) {
|
|
13241
|
-
|
|
13241
|
+
resolve7({ 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(resolve7, 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
|
+
resolve7(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(resolve7, 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
|
+
resolve7(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
|
+
resolve7(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
|
+
resolve7(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
|
+
resolve7(response);
|
|
15629
15629
|
});
|
|
15630
15630
|
raw.on("end", function() {
|
|
15631
15631
|
if (!response) {
|
|
15632
15632
|
response = new Response(body, response_options);
|
|
15633
|
-
|
|
15633
|
+
resolve7(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
|
+
resolve7(response);
|
|
15642
15642
|
return;
|
|
15643
15643
|
}
|
|
15644
15644
|
response = new Response(body, response_options);
|
|
15645
|
-
|
|
15645
|
+
resolve7(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((resolve7, 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
|
+
resolve7(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((resolve7, reject) => {
|
|
23968
23968
|
fs.readFile(name, opts.encoding, (err, data) => {
|
|
23969
23969
|
if (err !== null) {
|
|
23970
23970
|
reject(err);
|
|
23971
23971
|
} else {
|
|
23972
|
-
|
|
23972
|
+
resolve7(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(resolve7) {
|
|
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
|
+
resolve7($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(resolve7) {
|
|
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
|
+
resolve7(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(resolve7, 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(resolve7, 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
|
+
resolve7(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(resolve7, 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
|
+
resolve7(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,418 @@ 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 readFile3 } from "fs/promises";
|
|
50435
|
+
import { dirname as dirname4, resolve as resolve5 } from "path";
|
|
50436
|
+
import { stat as stat2 } from "fs/promises";
|
|
50437
|
+
import { parse as parseYaml3 } from "yaml";
|
|
50438
|
+
|
|
50439
|
+
// src/schema/agent.ts
|
|
50434
50440
|
import { z } from "zod";
|
|
50441
|
+
var RuleSchema = z.object({
|
|
50442
|
+
id: z.string(),
|
|
50443
|
+
name: z.string().optional(),
|
|
50444
|
+
description: z.string(),
|
|
50445
|
+
severity: z.enum(["mandatory", "recommended", "optional"]),
|
|
50446
|
+
detection_method: z.string().optional(),
|
|
50447
|
+
escalation: z.string().optional(),
|
|
50448
|
+
ref: z.string().optional()
|
|
50449
|
+
}).passthrough();
|
|
50450
|
+
var EscalationCriterionSchema = z.object({
|
|
50451
|
+
condition: z.string(),
|
|
50452
|
+
action: z.enum([
|
|
50453
|
+
"stop_and_report",
|
|
50454
|
+
"report_to_architect",
|
|
50455
|
+
"wait_for_approval"
|
|
50456
|
+
])
|
|
50457
|
+
}).passthrough();
|
|
50458
|
+
var PrerequisiteSchema = z.object({
|
|
50459
|
+
action: z.enum(["read", "execute"]),
|
|
50460
|
+
target: z.string(),
|
|
50461
|
+
required: z.boolean()
|
|
50462
|
+
}).passthrough();
|
|
50463
|
+
var AgentSchema = z.object({
|
|
50464
|
+
role_name: z.string(),
|
|
50465
|
+
purpose: z.string(),
|
|
50466
|
+
can_read_artifacts: z.array(z.string()).default([]),
|
|
50467
|
+
can_write_artifacts: z.array(z.string()).default([]),
|
|
50468
|
+
can_execute_tools: z.array(z.string()).default([]),
|
|
50469
|
+
can_perform_validations: z.array(z.string()).default([]),
|
|
50470
|
+
can_invoke_agents: z.array(z.string()).default([]),
|
|
50471
|
+
can_return_handoffs: z.array(z.string()).default([]),
|
|
50472
|
+
dispatch_only: z.boolean().optional(),
|
|
50473
|
+
mode: z.enum(["read-only", "read-write"]).optional(),
|
|
50474
|
+
responsibilities: z.array(z.string()).optional(),
|
|
50475
|
+
constraints: z.array(z.string()).optional(),
|
|
50476
|
+
rules: z.array(RuleSchema).optional(),
|
|
50477
|
+
anti_patterns: z.array(z.string()).optional(),
|
|
50478
|
+
escalation_criteria: z.array(EscalationCriterionSchema).optional(),
|
|
50479
|
+
prerequisites: z.array(PrerequisiteSchema).optional()
|
|
50480
|
+
}).passthrough();
|
|
50481
|
+
|
|
50482
|
+
// src/schema/artifact.ts
|
|
50483
|
+
import { z as z2 } from "zod";
|
|
50484
|
+
var ArtifactSchema = z2.object({
|
|
50485
|
+
type: z2.string(),
|
|
50486
|
+
description: z2.string().optional(),
|
|
50487
|
+
owner: z2.string(),
|
|
50488
|
+
producers: z2.array(z2.string()),
|
|
50489
|
+
editors: z2.array(z2.string()),
|
|
50490
|
+
consumers: z2.array(z2.string()),
|
|
50491
|
+
states: z2.array(z2.string()),
|
|
50492
|
+
required_validations: z2.array(z2.string()).default([]),
|
|
50493
|
+
visibility: z2.string().optional()
|
|
50494
|
+
}).passthrough();
|
|
50495
|
+
|
|
50496
|
+
// src/schema/binding.ts
|
|
50497
|
+
import { z as z3 } from "zod";
|
|
50498
|
+
var CommandRegexMatcherSchema = z3.object({
|
|
50499
|
+
type: z3.literal("command_regex"),
|
|
50500
|
+
pattern: z3.string()
|
|
50501
|
+
});
|
|
50502
|
+
var ContentRegexMatcherSchema = z3.object({
|
|
50503
|
+
type: z3.literal("content_regex"),
|
|
50504
|
+
pattern: z3.string(),
|
|
50505
|
+
file_glob: z3.string().optional(),
|
|
50506
|
+
exclude_glob: z3.string().optional()
|
|
50507
|
+
});
|
|
50508
|
+
var FileGlobMatcherSchema = z3.object({
|
|
50509
|
+
type: z3.literal("file_glob"),
|
|
50510
|
+
pattern: z3.string()
|
|
50511
|
+
});
|
|
50512
|
+
var MatcherSchema = z3.discriminatedUnion("type", [
|
|
50513
|
+
CommandRegexMatcherSchema,
|
|
50514
|
+
ContentRegexMatcherSchema,
|
|
50515
|
+
FileGlobMatcherSchema
|
|
50516
|
+
]);
|
|
50517
|
+
var CheckSchema = z3.object({
|
|
50518
|
+
matcher: MatcherSchema.optional(),
|
|
50519
|
+
script: z3.string().optional(),
|
|
50520
|
+
message: z3.string().optional()
|
|
50521
|
+
}).passthrough();
|
|
50522
|
+
var BindingOutputSchema = z3.object({
|
|
50523
|
+
target: z3.string(),
|
|
50524
|
+
template: z3.string().optional(),
|
|
50525
|
+
inline_template: z3.string().optional(),
|
|
50526
|
+
mode: z3.enum(["write", "patch"]).default("write"),
|
|
50527
|
+
group_by: z3.string().optional(),
|
|
50528
|
+
executable: z3.boolean().optional()
|
|
50529
|
+
}).passthrough().refine(
|
|
50530
|
+
(data) => !(data.template && data.inline_template),
|
|
50531
|
+
{ message: "template and inline_template are mutually exclusive" }
|
|
50532
|
+
);
|
|
50533
|
+
var ReportingSchema = z3.object({
|
|
50534
|
+
commands: z3.record(z3.string(), z3.string()),
|
|
50535
|
+
fail_open: z3.boolean().default(true),
|
|
50536
|
+
timeout_ms: z3.number().default(5e3)
|
|
50537
|
+
}).passthrough();
|
|
50538
|
+
var GuardrailImplSchema = z3.object({
|
|
50539
|
+
checks: z3.array(CheckSchema)
|
|
50540
|
+
});
|
|
50541
|
+
var SoftwareBindingSchema = z3.object({
|
|
50542
|
+
software: z3.string(),
|
|
50543
|
+
version: z3.literal(1),
|
|
50544
|
+
extends: z3.string().optional(),
|
|
50545
|
+
guardrail_impl: z3.record(z3.string(), GuardrailImplSchema).optional(),
|
|
50546
|
+
outputs: z3.record(z3.string(), BindingOutputSchema).optional(),
|
|
50547
|
+
reporting: ReportingSchema.optional()
|
|
50548
|
+
}).passthrough();
|
|
50549
|
+
|
|
50550
|
+
// src/schema/dsl.ts
|
|
50551
|
+
import { z as z12 } from "zod";
|
|
50552
|
+
|
|
50553
|
+
// src/schema/handoff-type.ts
|
|
50554
|
+
import { z as z4 } from "zod";
|
|
50555
|
+
var HandoffTypeSchema = z4.object({
|
|
50556
|
+
version: z4.number(),
|
|
50557
|
+
description: z4.string().optional(),
|
|
50558
|
+
schema: z4.record(z4.string(), z4.any()),
|
|
50559
|
+
example: z4.record(z4.string(), z4.any()).optional()
|
|
50560
|
+
}).passthrough();
|
|
50561
|
+
|
|
50562
|
+
// src/schema/guardrail.ts
|
|
50563
|
+
import { z as z5 } from "zod";
|
|
50564
|
+
var GuardrailScopeSchema = z5.object({
|
|
50565
|
+
agents: z5.array(z5.string()).optional(),
|
|
50566
|
+
tasks: z5.array(z5.string()).optional(),
|
|
50567
|
+
tools: z5.array(z5.string()).optional(),
|
|
50568
|
+
artifacts: z5.array(z5.string()).optional(),
|
|
50569
|
+
workflows: z5.array(z5.string()).optional()
|
|
50570
|
+
}).passthrough();
|
|
50571
|
+
var GuardrailSchema = z5.object({
|
|
50572
|
+
description: z5.string(),
|
|
50573
|
+
scope: GuardrailScopeSchema,
|
|
50574
|
+
rationale: z5.string().optional(),
|
|
50575
|
+
tags: z5.array(z5.string()).default([]),
|
|
50576
|
+
exemptions: z5.array(z5.string()).optional()
|
|
50577
|
+
}).passthrough();
|
|
50578
|
+
var GuardrailPolicyRuleEscalationSchema = z5.object({
|
|
50579
|
+
target: z5.string(),
|
|
50580
|
+
condition: z5.string().optional()
|
|
50581
|
+
}).passthrough();
|
|
50582
|
+
var GuardrailPolicyRuleSchema = z5.object({
|
|
50583
|
+
guardrail: z5.string(),
|
|
50584
|
+
severity: z5.enum(["critical", "mandatory", "warning", "info"]),
|
|
50585
|
+
action: z5.enum(["block", "warn", "shadow", "info"]),
|
|
50586
|
+
allow_override: z5.boolean().default(false),
|
|
50587
|
+
override_requires: z5.array(z5.string()).optional(),
|
|
50588
|
+
escalation: GuardrailPolicyRuleEscalationSchema.optional()
|
|
50589
|
+
}).passthrough();
|
|
50590
|
+
var GuardrailPolicySchema = z5.object({
|
|
50591
|
+
description: z5.string().optional(),
|
|
50592
|
+
rules: z5.array(GuardrailPolicyRuleSchema)
|
|
50593
|
+
}).passthrough();
|
|
50594
|
+
|
|
50595
|
+
// src/schema/policy.ts
|
|
50596
|
+
import { z as z6 } from "zod";
|
|
50597
|
+
var PolicyWhenSchema = z6.object({
|
|
50598
|
+
artifact_type: z6.string().optional(),
|
|
50599
|
+
workflow: z6.string().optional()
|
|
50600
|
+
}).passthrough();
|
|
50601
|
+
var PolicySchema = z6.object({
|
|
50602
|
+
when: PolicyWhenSchema,
|
|
50603
|
+
requires_validations: z6.array(z6.string()).optional(),
|
|
50604
|
+
requires: z6.array(z6.string()).optional()
|
|
50605
|
+
}).passthrough();
|
|
50606
|
+
|
|
50607
|
+
// src/schema/system.ts
|
|
50608
|
+
import { z as z7 } from "zod";
|
|
50609
|
+
var VersionLiteralSchema = z7.literal(1);
|
|
50610
|
+
var ExtendsSchema = z7.string().optional();
|
|
50611
|
+
var SystemSchema = z7.object({
|
|
50612
|
+
id: z7.string(),
|
|
50613
|
+
name: z7.string(),
|
|
50614
|
+
default_workflow_order: z7.array(z7.string())
|
|
50615
|
+
}).passthrough();
|
|
50616
|
+
|
|
50617
|
+
// src/schema/task.ts
|
|
50618
|
+
import { z as z8 } from "zod";
|
|
50619
|
+
var ExecutionStepSchema = z8.object({
|
|
50620
|
+
id: z8.string(),
|
|
50621
|
+
action: z8.string(),
|
|
50622
|
+
description: z8.string().optional(),
|
|
50623
|
+
required: z8.boolean().optional(),
|
|
50624
|
+
abort_on_failure: z8.boolean().optional(),
|
|
50625
|
+
uses_tool: z8.string().optional(),
|
|
50626
|
+
produces_artifact: z8.string().optional(),
|
|
50627
|
+
reads_artifact: z8.string().optional(),
|
|
50628
|
+
depends_on: z8.array(z8.string()).optional(),
|
|
50629
|
+
skip_condition: z8.string().optional(),
|
|
50630
|
+
wait_for_approval: z8.boolean().optional()
|
|
50631
|
+
}).passthrough();
|
|
50632
|
+
var TaskSchema = z8.object({
|
|
50633
|
+
description: z8.string(),
|
|
50634
|
+
target_agent: z8.string(),
|
|
50635
|
+
allowed_from_agents: z8.array(z8.string()),
|
|
50636
|
+
workflow: z8.string(),
|
|
50637
|
+
input_artifacts: z8.array(z8.string()),
|
|
50638
|
+
invocation_handoff: z8.string(),
|
|
50639
|
+
result_handoff: z8.string(),
|
|
50640
|
+
default_priority: z8.string().optional(),
|
|
50641
|
+
responsibilities: z8.array(z8.string()).optional(),
|
|
50642
|
+
constraints: z8.array(z8.string()).optional(),
|
|
50643
|
+
execution_steps: z8.array(ExecutionStepSchema).optional(),
|
|
50644
|
+
completion_criteria: z8.array(z8.string()).optional(),
|
|
50645
|
+
rules: z8.array(RuleSchema).optional(),
|
|
50646
|
+
anti_patterns: z8.array(z8.string()).optional(),
|
|
50647
|
+
escalation_criteria: z8.array(EscalationCriterionSchema).optional(),
|
|
50648
|
+
validations: z8.array(z8.string()).default([])
|
|
50649
|
+
}).passthrough();
|
|
50650
|
+
|
|
50651
|
+
// src/schema/tool.ts
|
|
50652
|
+
import { z as z9 } from "zod";
|
|
50653
|
+
var CommandSchema = z9.object({
|
|
50654
|
+
command: z9.string(),
|
|
50655
|
+
category: z9.string(),
|
|
50656
|
+
reads: z9.array(z9.string()).default([]),
|
|
50657
|
+
writes: z9.array(z9.string()).default([]),
|
|
50658
|
+
purpose: z9.string().optional()
|
|
50659
|
+
});
|
|
50660
|
+
var ToolSchema = z9.object({
|
|
50661
|
+
kind: z9.string(),
|
|
50662
|
+
description: z9.string().optional(),
|
|
50663
|
+
input_artifacts: z9.array(z9.string()).default([]),
|
|
50664
|
+
output_artifacts: z9.array(z9.string()).default([]),
|
|
50665
|
+
invokable_by: z9.array(z9.string()),
|
|
50666
|
+
side_effects: z9.array(z9.string()).default([]),
|
|
50667
|
+
commands: z9.array(CommandSchema).default([])
|
|
50668
|
+
}).passthrough();
|
|
50669
|
+
|
|
50670
|
+
// src/schema/validation.ts
|
|
50671
|
+
import { z as z10 } from "zod";
|
|
50672
|
+
var ValidationSchema = z10.object({
|
|
50673
|
+
target_artifact: z10.string(),
|
|
50674
|
+
kind: z10.enum(["schema", "mechanical", "semantic", "approval"]),
|
|
50675
|
+
executor_type: z10.enum(["tool", "agent"]),
|
|
50676
|
+
executor: z10.string(),
|
|
50677
|
+
blocking: z10.boolean(),
|
|
50678
|
+
produces_evidence: z10.string().optional()
|
|
50679
|
+
}).passthrough();
|
|
50680
|
+
|
|
50681
|
+
// src/schema/workflow.ts
|
|
50682
|
+
import { z as z11 } from "zod";
|
|
50683
|
+
var RetrySchema = z11.object({
|
|
50684
|
+
condition: z11.string(),
|
|
50685
|
+
fix_task: z11.string(),
|
|
50686
|
+
revalidate_task: z11.string().optional()
|
|
50687
|
+
});
|
|
50688
|
+
var ExternalParticipantSchema = z11.object({
|
|
50689
|
+
id: z11.string(),
|
|
50690
|
+
kind: z11.enum(["actor", "participant"]),
|
|
50691
|
+
label: z11.string(),
|
|
50692
|
+
description: z11.string().optional()
|
|
50693
|
+
});
|
|
50694
|
+
var WorkflowDelegateStepSchema = z11.object({
|
|
50695
|
+
type: z11.literal("delegate"),
|
|
50696
|
+
description: z11.string().optional(),
|
|
50697
|
+
task: z11.string(),
|
|
50698
|
+
from_agent: z11.string(),
|
|
50699
|
+
group: z11.string().optional(),
|
|
50700
|
+
retry: RetrySchema.optional()
|
|
50701
|
+
}).passthrough();
|
|
50702
|
+
var WorkflowGateStepSchema = z11.object({
|
|
50703
|
+
type: z11.literal("gate"),
|
|
50704
|
+
description: z11.string().optional(),
|
|
50705
|
+
gate_kind: z11.string(),
|
|
50706
|
+
group: z11.string().optional()
|
|
50707
|
+
}).passthrough();
|
|
50708
|
+
var WorkflowHandoffStepSchema = z11.object({
|
|
50709
|
+
type: z11.literal("handoff"),
|
|
50710
|
+
description: z11.string().optional(),
|
|
50711
|
+
handoff_kind: z11.string(),
|
|
50712
|
+
task: z11.string().optional(),
|
|
50713
|
+
from_agent: z11.string().optional(),
|
|
50714
|
+
group: z11.string().optional(),
|
|
50715
|
+
retry: RetrySchema.optional()
|
|
50716
|
+
}).passthrough();
|
|
50717
|
+
var WorkflowValidationStepSchema = z11.object({
|
|
50718
|
+
type: z11.literal("validation"),
|
|
50719
|
+
description: z11.string().optional(),
|
|
50720
|
+
validation: z11.string(),
|
|
50721
|
+
group: z11.string().optional()
|
|
50722
|
+
}).passthrough();
|
|
50723
|
+
var WorkflowDecisionStepSchema = z11.object({
|
|
50724
|
+
type: z11.literal("decision"),
|
|
50725
|
+
description: z11.string().optional(),
|
|
50726
|
+
on: z11.string(),
|
|
50727
|
+
branches: z11.record(z11.string(), z11.array(z11.string())),
|
|
50728
|
+
group: z11.string().optional()
|
|
50729
|
+
}).passthrough();
|
|
50730
|
+
var WorkflowStepSchema = z11.discriminatedUnion("type", [
|
|
50731
|
+
WorkflowDelegateStepSchema,
|
|
50732
|
+
WorkflowGateStepSchema,
|
|
50733
|
+
WorkflowHandoffStepSchema,
|
|
50734
|
+
WorkflowValidationStepSchema,
|
|
50735
|
+
WorkflowDecisionStepSchema
|
|
50736
|
+
]);
|
|
50737
|
+
var WorkflowSchema = z11.object({
|
|
50738
|
+
description: z11.string().optional(),
|
|
50739
|
+
entry_conditions: z11.array(z11.string()).default([]),
|
|
50740
|
+
trigger: z11.string().optional(),
|
|
50741
|
+
steps: z11.array(WorkflowStepSchema),
|
|
50742
|
+
external_participants: z11.array(ExternalParticipantSchema).default([])
|
|
50743
|
+
}).passthrough();
|
|
50744
|
+
|
|
50745
|
+
// src/schema/dsl.ts
|
|
50746
|
+
var ComponentsSchema = z12.object({
|
|
50747
|
+
schemas: z12.record(z12.string(), z12.record(z12.string(), z12.any())).default({})
|
|
50748
|
+
}).passthrough();
|
|
50749
|
+
var DslSchema = z12.object({
|
|
50750
|
+
version: z12.literal(1),
|
|
50751
|
+
extends: z12.string().optional(),
|
|
50752
|
+
system: SystemSchema,
|
|
50753
|
+
agents: z12.record(z12.string(), AgentSchema).default({}),
|
|
50754
|
+
tasks: z12.record(z12.string(), TaskSchema).default({}),
|
|
50755
|
+
artifacts: z12.record(z12.string(), ArtifactSchema).default({}),
|
|
50756
|
+
tools: z12.record(z12.string(), ToolSchema).default({}),
|
|
50757
|
+
validations: z12.record(z12.string(), ValidationSchema).default({}),
|
|
50758
|
+
handoff_types: z12.record(z12.string(), HandoffTypeSchema).default({}),
|
|
50759
|
+
workflow: z12.record(z12.string(), WorkflowSchema).default({}),
|
|
50760
|
+
policies: z12.record(z12.string(), PolicySchema).default({}),
|
|
50761
|
+
guardrails: z12.record(z12.string(), GuardrailSchema).default({}),
|
|
50762
|
+
guardrail_policies: z12.record(z12.string(), GuardrailPolicySchema).default({}),
|
|
50763
|
+
components: ComponentsSchema.default({ schemas: {} })
|
|
50764
|
+
}).passthrough();
|
|
50765
|
+
|
|
50766
|
+
// src/schema/json-schema-utils.ts
|
|
50767
|
+
function resolveAllOf(schema) {
|
|
50768
|
+
const allOf = schema["allOf"];
|
|
50769
|
+
if (!Array.isArray(allOf)) return schema;
|
|
50770
|
+
let mergedProperties = {};
|
|
50771
|
+
let mergedRequired = [];
|
|
50772
|
+
const mergedTop = {};
|
|
50773
|
+
for (const sub of allOf) {
|
|
50774
|
+
if (typeof sub !== "object" || sub === null || Array.isArray(sub)) continue;
|
|
50775
|
+
const subSchema = sub;
|
|
50776
|
+
if (subSchema["properties"] && typeof subSchema["properties"] === "object") {
|
|
50777
|
+
mergedProperties = {
|
|
50778
|
+
...mergedProperties,
|
|
50779
|
+
...subSchema["properties"]
|
|
50780
|
+
};
|
|
50781
|
+
}
|
|
50782
|
+
if (Array.isArray(subSchema["required"])) {
|
|
50783
|
+
mergedRequired = [
|
|
50784
|
+
...mergedRequired,
|
|
50785
|
+
...subSchema["required"]
|
|
50786
|
+
];
|
|
50787
|
+
}
|
|
50788
|
+
for (const [key, value] of Object.entries(subSchema)) {
|
|
50789
|
+
if (key !== "properties" && key !== "required" && key !== "allOf") {
|
|
50790
|
+
mergedTop[key] = value;
|
|
50791
|
+
}
|
|
50792
|
+
}
|
|
50793
|
+
}
|
|
50794
|
+
for (const [key, value] of Object.entries(schema)) {
|
|
50795
|
+
if (key === "allOf") continue;
|
|
50796
|
+
if (key === "properties" && typeof value === "object") {
|
|
50797
|
+
mergedProperties = { ...mergedProperties, ...value };
|
|
50798
|
+
} else if (key === "required" && Array.isArray(value)) {
|
|
50799
|
+
mergedRequired = [...mergedRequired, ...value];
|
|
50800
|
+
} else {
|
|
50801
|
+
mergedTop[key] = value;
|
|
50802
|
+
}
|
|
50803
|
+
}
|
|
50804
|
+
const result = { ...mergedTop };
|
|
50805
|
+
if (Object.keys(mergedProperties).length > 0) {
|
|
50806
|
+
result["properties"] = mergedProperties;
|
|
50807
|
+
}
|
|
50808
|
+
if (mergedRequired.length > 0) {
|
|
50809
|
+
result["required"] = [...new Set(mergedRequired)];
|
|
50810
|
+
}
|
|
50811
|
+
return result;
|
|
50812
|
+
}
|
|
50813
|
+
|
|
50814
|
+
// src/schema/merge-operators.ts
|
|
50815
|
+
import { z as z13 } from "zod";
|
|
50816
|
+
var AppendOperatorSchema = z13.object({
|
|
50817
|
+
$append: z13.record(z13.string(), z13.any())
|
|
50818
|
+
});
|
|
50819
|
+
var PrependOperatorSchema = z13.object({
|
|
50820
|
+
$prepend: z13.record(z13.string(), z13.any())
|
|
50821
|
+
});
|
|
50822
|
+
var InsertAfterOperatorSchema = z13.object({
|
|
50823
|
+
$insert_after: z13.object({
|
|
50824
|
+
after: z13.string(),
|
|
50825
|
+
entries: z13.record(z13.string(), z13.any())
|
|
50826
|
+
})
|
|
50827
|
+
});
|
|
50828
|
+
var ReplaceOperatorSchema = z13.object({ $replace: z13.any() });
|
|
50829
|
+
var RemoveOperatorSchema = z13.object({
|
|
50830
|
+
$remove: z13.array(z13.string())
|
|
50831
|
+
});
|
|
50832
|
+
|
|
50833
|
+
// src/config/loader.ts
|
|
50834
|
+
import { readFile, access } from "fs/promises";
|
|
50835
|
+
import { resolve, dirname } from "path";
|
|
50836
|
+
import { parse as parseYaml } from "yaml";
|
|
50837
|
+
|
|
50838
|
+
// src/config/types.ts
|
|
50839
|
+
import { z as z14 } from "zod";
|
|
50435
50840
|
var CONTEXT_TYPES = [
|
|
50436
50841
|
"agent",
|
|
50437
50842
|
"task",
|
|
@@ -50441,18 +50846,20 @@ var CONTEXT_TYPES = [
|
|
|
50441
50846
|
"handoff_type",
|
|
50442
50847
|
"workflow",
|
|
50443
50848
|
"policy",
|
|
50849
|
+
"guardrail",
|
|
50850
|
+
"guardrail_policy",
|
|
50444
50851
|
"system"
|
|
50445
50852
|
];
|
|
50446
|
-
var ContextTypeSchema =
|
|
50853
|
+
var ContextTypeSchema = z14.enum(CONTEXT_TYPES);
|
|
50447
50854
|
var ITERABLE_CONTEXT_TYPES = CONTEXT_TYPES.filter(
|
|
50448
50855
|
(t3) => t3 !== "system"
|
|
50449
50856
|
);
|
|
50450
|
-
var RenderTargetSchema =
|
|
50451
|
-
template:
|
|
50857
|
+
var RenderTargetSchema = z14.object({
|
|
50858
|
+
template: z14.string(),
|
|
50452
50859
|
context: ContextTypeSchema,
|
|
50453
|
-
output:
|
|
50454
|
-
include:
|
|
50455
|
-
exclude:
|
|
50860
|
+
output: z14.string(),
|
|
50861
|
+
include: z14.array(z14.string()).optional(),
|
|
50862
|
+
exclude: z14.array(z14.string()).optional()
|
|
50456
50863
|
}).refine(
|
|
50457
50864
|
(data) => !(data.include && data.exclude),
|
|
50458
50865
|
{ message: "include and exclude are mutually exclusive" }
|
|
@@ -50465,16 +50872,16 @@ var RenderTargetSchema = z.object({
|
|
|
50465
50872
|
},
|
|
50466
50873
|
{ message: "include/exclude cannot be used with context: system" }
|
|
50467
50874
|
);
|
|
50468
|
-
var AgentContractsConfigSchema =
|
|
50469
|
-
dsl:
|
|
50470
|
-
vars:
|
|
50471
|
-
renders:
|
|
50875
|
+
var AgentContractsConfigSchema = z14.object({
|
|
50876
|
+
dsl: z14.string(),
|
|
50877
|
+
vars: z14.record(z14.string(), z14.string()).optional(),
|
|
50878
|
+
renders: z14.array(RenderTargetSchema).min(1),
|
|
50879
|
+
bindings: z14.array(z14.string()).default([]),
|
|
50880
|
+
active_guardrail_policy: z14.string().optional(),
|
|
50881
|
+
paths: z14.record(z14.string(), z14.string()).optional()
|
|
50472
50882
|
});
|
|
50473
50883
|
|
|
50474
50884
|
// 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
50885
|
var DEFAULT_CONFIG_NAME = "agent-contracts.config.yaml";
|
|
50479
50886
|
var ConfigLoadError = class extends Error {
|
|
50480
50887
|
constructor(message, filePath) {
|
|
@@ -50542,7 +50949,10 @@ ${issues}`,
|
|
|
50542
50949
|
template: resolve(configDir, r3.template),
|
|
50543
50950
|
output: resolve(configDir, r3.output)
|
|
50544
50951
|
})),
|
|
50545
|
-
configDir
|
|
50952
|
+
configDir,
|
|
50953
|
+
bindings: (config.bindings ?? []).map((b3) => resolve(configDir, b3)),
|
|
50954
|
+
activeGuardrailPolicy: config.active_guardrail_policy,
|
|
50955
|
+
paths: config.paths
|
|
50546
50956
|
};
|
|
50547
50957
|
}
|
|
50548
50958
|
function resolveDslPath(dirArg, dirArgDefault, config) {
|
|
@@ -51104,6 +51514,8 @@ var MERGE_SECTIONS = [
|
|
|
51104
51514
|
"handoff_types",
|
|
51105
51515
|
"workflow",
|
|
51106
51516
|
"policies",
|
|
51517
|
+
"guardrails",
|
|
51518
|
+
"guardrail_policies",
|
|
51107
51519
|
"components"
|
|
51108
51520
|
];
|
|
51109
51521
|
function mergeDsl(base, project) {
|
|
@@ -51202,6 +51614,143 @@ function substituteVars(data, vars) {
|
|
|
51202
51614
|
return walk(data, vars);
|
|
51203
51615
|
}
|
|
51204
51616
|
|
|
51617
|
+
// src/config/binding-merger.ts
|
|
51618
|
+
function isRecord3(v2) {
|
|
51619
|
+
return typeof v2 === "object" && v2 !== null && !Array.isArray(v2);
|
|
51620
|
+
}
|
|
51621
|
+
var BINDING_MERGE_SECTIONS = ["guardrail_impl", "outputs"];
|
|
51622
|
+
function mergeBinding(base, project) {
|
|
51623
|
+
const hasExtends = typeof project["extends"] === "string";
|
|
51624
|
+
const result = { ...base, ...project };
|
|
51625
|
+
for (const section of BINDING_MERGE_SECTIONS) {
|
|
51626
|
+
const baseVal = base[section];
|
|
51627
|
+
const projVal = project[section];
|
|
51628
|
+
if (projVal === void 0) {
|
|
51629
|
+
continue;
|
|
51630
|
+
}
|
|
51631
|
+
const baseMap = isRecord3(baseVal) ? baseVal : {};
|
|
51632
|
+
result[section] = mergeEntityMaps(
|
|
51633
|
+
baseMap,
|
|
51634
|
+
projVal,
|
|
51635
|
+
section,
|
|
51636
|
+
hasExtends
|
|
51637
|
+
);
|
|
51638
|
+
}
|
|
51639
|
+
if (project["reporting"] !== void 0 && isRecord3(base["reporting"]) && isRecord3(project["reporting"])) {
|
|
51640
|
+
result["reporting"] = deepMergeEntities(
|
|
51641
|
+
base["reporting"],
|
|
51642
|
+
project["reporting"],
|
|
51643
|
+
"reporting",
|
|
51644
|
+
hasExtends
|
|
51645
|
+
);
|
|
51646
|
+
}
|
|
51647
|
+
delete result["extends"];
|
|
51648
|
+
return result;
|
|
51649
|
+
}
|
|
51650
|
+
|
|
51651
|
+
// src/config/binding-loader.ts
|
|
51652
|
+
async function loadRawBinding(filePath) {
|
|
51653
|
+
let content;
|
|
51654
|
+
try {
|
|
51655
|
+
content = await readFile3(filePath, "utf8");
|
|
51656
|
+
} catch {
|
|
51657
|
+
throw new ConfigLoadError(
|
|
51658
|
+
`Failed to read binding file: ${filePath}`,
|
|
51659
|
+
filePath
|
|
51660
|
+
);
|
|
51661
|
+
}
|
|
51662
|
+
try {
|
|
51663
|
+
return parseYaml3(content);
|
|
51664
|
+
} catch (err) {
|
|
51665
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
51666
|
+
throw new ConfigLoadError(
|
|
51667
|
+
`Invalid YAML syntax in binding file ${filePath}: ${msg}`,
|
|
51668
|
+
filePath
|
|
51669
|
+
);
|
|
51670
|
+
}
|
|
51671
|
+
}
|
|
51672
|
+
async function resolveBindingExtends(raw, filePath, seen) {
|
|
51673
|
+
const extendsValue = raw["extends"];
|
|
51674
|
+
if (typeof extendsValue !== "string") {
|
|
51675
|
+
return raw;
|
|
51676
|
+
}
|
|
51677
|
+
const bindingDir = dirname4(filePath);
|
|
51678
|
+
let basePath;
|
|
51679
|
+
if (extendsValue.startsWith("./") || extendsValue.startsWith("../")) {
|
|
51680
|
+
basePath = resolve5(bindingDir, extendsValue);
|
|
51681
|
+
} else {
|
|
51682
|
+
try {
|
|
51683
|
+
const resolved = import.meta.resolve(extendsValue);
|
|
51684
|
+
basePath = new URL(resolved).pathname;
|
|
51685
|
+
} catch {
|
|
51686
|
+
throw new ConfigLoadError(
|
|
51687
|
+
`Could not resolve binding extends package: ${extendsValue}`,
|
|
51688
|
+
filePath
|
|
51689
|
+
);
|
|
51690
|
+
}
|
|
51691
|
+
}
|
|
51692
|
+
try {
|
|
51693
|
+
const s2 = await stat2(basePath);
|
|
51694
|
+
if (s2.isDirectory()) {
|
|
51695
|
+
const candidates = ["binding.yaml", "binding.yml"];
|
|
51696
|
+
let found = false;
|
|
51697
|
+
for (const name of candidates) {
|
|
51698
|
+
const candidate = resolve5(basePath, name);
|
|
51699
|
+
try {
|
|
51700
|
+
const cs = await stat2(candidate);
|
|
51701
|
+
if (cs.isFile()) {
|
|
51702
|
+
basePath = candidate;
|
|
51703
|
+
found = true;
|
|
51704
|
+
break;
|
|
51705
|
+
}
|
|
51706
|
+
} catch {
|
|
51707
|
+
continue;
|
|
51708
|
+
}
|
|
51709
|
+
}
|
|
51710
|
+
if (!found) {
|
|
51711
|
+
throw new ConfigLoadError(
|
|
51712
|
+
`No binding.yaml found in directory: ${basePath}`,
|
|
51713
|
+
filePath
|
|
51714
|
+
);
|
|
51715
|
+
}
|
|
51716
|
+
}
|
|
51717
|
+
} catch (err) {
|
|
51718
|
+
if (err instanceof ConfigLoadError) throw err;
|
|
51719
|
+
throw new ConfigLoadError(
|
|
51720
|
+
`Base binding path not found: ${basePath}`,
|
|
51721
|
+
filePath
|
|
51722
|
+
);
|
|
51723
|
+
}
|
|
51724
|
+
if (seen.has(basePath)) {
|
|
51725
|
+
throw new ConfigLoadError(
|
|
51726
|
+
`Circular binding extends detected: ${basePath}`,
|
|
51727
|
+
filePath
|
|
51728
|
+
);
|
|
51729
|
+
}
|
|
51730
|
+
seen.add(basePath);
|
|
51731
|
+
const baseRaw = await loadRawBinding(basePath);
|
|
51732
|
+
const resolvedBase = await resolveBindingExtends(baseRaw, basePath, seen);
|
|
51733
|
+
return mergeBinding(resolvedBase, raw);
|
|
51734
|
+
}
|
|
51735
|
+
async function loadBindings(bindingPaths) {
|
|
51736
|
+
const results = [];
|
|
51737
|
+
for (const filePath of bindingPaths) {
|
|
51738
|
+
const raw = await loadRawBinding(filePath);
|
|
51739
|
+
const merged = await resolveBindingExtends(raw, filePath, /* @__PURE__ */ new Set([filePath]));
|
|
51740
|
+
const result = SoftwareBindingSchema.safeParse(merged);
|
|
51741
|
+
if (!result.success) {
|
|
51742
|
+
const issues = result.error.issues.map((i3) => ` ${i3.path.join(".")}: ${i3.message}`).join("\n");
|
|
51743
|
+
throw new ConfigLoadError(
|
|
51744
|
+
`Invalid binding schema in ${filePath}:
|
|
51745
|
+
${issues}`,
|
|
51746
|
+
filePath
|
|
51747
|
+
);
|
|
51748
|
+
}
|
|
51749
|
+
results.push({ filePath, binding: result.data });
|
|
51750
|
+
}
|
|
51751
|
+
return results;
|
|
51752
|
+
}
|
|
51753
|
+
|
|
51205
51754
|
// src/cli/commands/resolve.ts
|
|
51206
51755
|
import { stringify } from "yaml";
|
|
51207
51756
|
var DIR_DEFAULT = "agent-contracts.yaml";
|
|
@@ -51228,323 +51777,16 @@ var resolveCommand = new Command("resolve").description("Resolve DSL (load + mer
|
|
|
51228
51777
|
import { Command as Command2 } from "commander";
|
|
51229
51778
|
|
|
51230
51779
|
// 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
|
|
51780
|
+
import { z as z15 } from "zod";
|
|
51539
51781
|
function unwrap(schema) {
|
|
51540
|
-
if (schema instanceof
|
|
51541
|
-
if (schema instanceof
|
|
51542
|
-
if (schema instanceof
|
|
51782
|
+
if (schema instanceof z15.ZodOptional) return unwrap(schema.unwrap());
|
|
51783
|
+
if (schema instanceof z15.ZodDefault) return unwrap(schema.removeDefault());
|
|
51784
|
+
if (schema instanceof z15.ZodNullable) return unwrap(schema.unwrap());
|
|
51543
51785
|
return schema;
|
|
51544
51786
|
}
|
|
51545
51787
|
function checkCustomPropsRecursive(data, schema, path) {
|
|
51546
51788
|
const inner = unwrap(schema);
|
|
51547
|
-
if (inner instanceof
|
|
51789
|
+
if (inner instanceof z15.ZodObject) {
|
|
51548
51790
|
if (typeof data !== "object" || data === null || Array.isArray(data)) return [];
|
|
51549
51791
|
const obj = data;
|
|
51550
51792
|
const shape = inner.shape;
|
|
@@ -51565,7 +51807,7 @@ function checkCustomPropsRecursive(data, schema, path) {
|
|
|
51565
51807
|
}
|
|
51566
51808
|
return diagnostics;
|
|
51567
51809
|
}
|
|
51568
|
-
if (inner instanceof
|
|
51810
|
+
if (inner instanceof z15.ZodRecord) {
|
|
51569
51811
|
if (typeof data !== "object" || data === null || Array.isArray(data)) return [];
|
|
51570
51812
|
const valueSchema = inner._def.valueType;
|
|
51571
51813
|
const diagnostics = [];
|
|
@@ -51574,7 +51816,7 @@ function checkCustomPropsRecursive(data, schema, path) {
|
|
|
51574
51816
|
}
|
|
51575
51817
|
return diagnostics;
|
|
51576
51818
|
}
|
|
51577
|
-
if (inner instanceof
|
|
51819
|
+
if (inner instanceof z15.ZodArray) {
|
|
51578
51820
|
if (!Array.isArray(data)) return [];
|
|
51579
51821
|
const diagnostics = [];
|
|
51580
51822
|
for (let i3 = 0; i3 < data.length; i3++) {
|
|
@@ -51582,14 +51824,14 @@ function checkCustomPropsRecursive(data, schema, path) {
|
|
|
51582
51824
|
}
|
|
51583
51825
|
return diagnostics;
|
|
51584
51826
|
}
|
|
51585
|
-
if (inner instanceof
|
|
51827
|
+
if (inner instanceof z15.ZodDiscriminatedUnion) {
|
|
51586
51828
|
if (typeof data !== "object" || data === null) return [];
|
|
51587
51829
|
const obj = data;
|
|
51588
51830
|
const disc = inner._def.discriminator;
|
|
51589
51831
|
const discValue = obj[disc];
|
|
51590
51832
|
const match = inner.options.find((opt) => {
|
|
51591
51833
|
const shape = opt.shape;
|
|
51592
|
-
return shape[disc] instanceof
|
|
51834
|
+
return shape[disc] instanceof z15.ZodLiteral && shape[disc].value === discValue;
|
|
51593
51835
|
});
|
|
51594
51836
|
if (match) return checkCustomPropsRecursive(data, match, path);
|
|
51595
51837
|
return [];
|
|
@@ -51623,12 +51865,13 @@ function checkReferences(dsl) {
|
|
|
51623
51865
|
const handoffKinds = new Set(Object.keys(dsl.handoff_types));
|
|
51624
51866
|
const taskIds = new Set(Object.keys(dsl.tasks));
|
|
51625
51867
|
const workflowIds = new Set(dsl.system.default_workflow_order);
|
|
51626
|
-
|
|
51868
|
+
const guardrailIds = new Set(Object.keys(dsl.guardrails));
|
|
51869
|
+
function checkExists(value, validSet, entityType, path, code = "reference-not-found") {
|
|
51627
51870
|
if (!validSet.has(value)) {
|
|
51628
51871
|
diagnostics.push({
|
|
51629
51872
|
path,
|
|
51630
51873
|
message: `Reference "${value}" not found in ${entityType}`,
|
|
51631
|
-
code
|
|
51874
|
+
code
|
|
51632
51875
|
});
|
|
51633
51876
|
}
|
|
51634
51877
|
}
|
|
@@ -51816,6 +52059,75 @@ function checkReferences(dsl) {
|
|
|
51816
52059
|
}
|
|
51817
52060
|
}
|
|
51818
52061
|
}
|
|
52062
|
+
for (const [id, guardrail] of Object.entries(dsl.guardrails)) {
|
|
52063
|
+
if (guardrail.scope.agents) {
|
|
52064
|
+
for (const ref of guardrail.scope.agents) {
|
|
52065
|
+
checkExists(
|
|
52066
|
+
ref,
|
|
52067
|
+
agentIds,
|
|
52068
|
+
"agents",
|
|
52069
|
+
`guardrails.${id}.scope.agents`,
|
|
52070
|
+
"guardrail-scope-ref-not-found"
|
|
52071
|
+
);
|
|
52072
|
+
}
|
|
52073
|
+
}
|
|
52074
|
+
if (guardrail.scope.tasks) {
|
|
52075
|
+
for (const ref of guardrail.scope.tasks) {
|
|
52076
|
+
checkExists(
|
|
52077
|
+
ref,
|
|
52078
|
+
taskIds,
|
|
52079
|
+
"tasks",
|
|
52080
|
+
`guardrails.${id}.scope.tasks`,
|
|
52081
|
+
"guardrail-scope-ref-not-found"
|
|
52082
|
+
);
|
|
52083
|
+
}
|
|
52084
|
+
}
|
|
52085
|
+
if (guardrail.scope.tools) {
|
|
52086
|
+
for (const ref of guardrail.scope.tools) {
|
|
52087
|
+
checkExists(
|
|
52088
|
+
ref,
|
|
52089
|
+
toolIds,
|
|
52090
|
+
"tools",
|
|
52091
|
+
`guardrails.${id}.scope.tools`,
|
|
52092
|
+
"guardrail-scope-ref-not-found"
|
|
52093
|
+
);
|
|
52094
|
+
}
|
|
52095
|
+
}
|
|
52096
|
+
if (guardrail.scope.artifacts) {
|
|
52097
|
+
for (const ref of guardrail.scope.artifacts) {
|
|
52098
|
+
checkExists(
|
|
52099
|
+
ref,
|
|
52100
|
+
artifactIds,
|
|
52101
|
+
"artifacts",
|
|
52102
|
+
`guardrails.${id}.scope.artifacts`,
|
|
52103
|
+
"guardrail-scope-ref-not-found"
|
|
52104
|
+
);
|
|
52105
|
+
}
|
|
52106
|
+
}
|
|
52107
|
+
if (guardrail.scope.workflows) {
|
|
52108
|
+
for (const ref of guardrail.scope.workflows) {
|
|
52109
|
+
checkExists(
|
|
52110
|
+
ref,
|
|
52111
|
+
workflowIds,
|
|
52112
|
+
"system.default_workflow_order",
|
|
52113
|
+
`guardrails.${id}.scope.workflows`,
|
|
52114
|
+
"guardrail-scope-ref-not-found"
|
|
52115
|
+
);
|
|
52116
|
+
}
|
|
52117
|
+
}
|
|
52118
|
+
}
|
|
52119
|
+
for (const [policyId, policy] of Object.entries(dsl.guardrail_policies)) {
|
|
52120
|
+
for (let i3 = 0; i3 < policy.rules.length; i3++) {
|
|
52121
|
+
const rule = policy.rules[i3];
|
|
52122
|
+
checkExists(
|
|
52123
|
+
rule.guardrail,
|
|
52124
|
+
guardrailIds,
|
|
52125
|
+
"guardrails",
|
|
52126
|
+
`guardrail_policies.${policyId}.rules[${i3}].guardrail`,
|
|
52127
|
+
"guardrail-policy-ref-not-found"
|
|
52128
|
+
);
|
|
52129
|
+
}
|
|
52130
|
+
}
|
|
51819
52131
|
return diagnostics;
|
|
51820
52132
|
}
|
|
51821
52133
|
|
|
@@ -52239,6 +52551,32 @@ var toolCommandsRule = {
|
|
|
52239
52551
|
}
|
|
52240
52552
|
};
|
|
52241
52553
|
|
|
52554
|
+
// src/linter/rules/guardrail-policy-coverage.ts
|
|
52555
|
+
var guardrailPolicyCoverageRule = {
|
|
52556
|
+
id: "guardrail-no-policy-rule",
|
|
52557
|
+
description: "Every guardrail should be referenced by at least one policy rule in guardrail_policies",
|
|
52558
|
+
run(dsl) {
|
|
52559
|
+
const diagnostics = [];
|
|
52560
|
+
const referencedGuardrails = /* @__PURE__ */ new Set();
|
|
52561
|
+
for (const policy of Object.values(dsl.guardrail_policies)) {
|
|
52562
|
+
for (const rule of policy.rules) {
|
|
52563
|
+
referencedGuardrails.add(rule.guardrail);
|
|
52564
|
+
}
|
|
52565
|
+
}
|
|
52566
|
+
for (const guardrailId of Object.keys(dsl.guardrails)) {
|
|
52567
|
+
if (!referencedGuardrails.has(guardrailId)) {
|
|
52568
|
+
diagnostics.push({
|
|
52569
|
+
ruleId: "guardrail-no-policy-rule",
|
|
52570
|
+
severity: "warning",
|
|
52571
|
+
path: `guardrails.${guardrailId}`,
|
|
52572
|
+
message: `Guardrail "${guardrailId}" is not referenced by any policy rule in guardrail_policies`
|
|
52573
|
+
});
|
|
52574
|
+
}
|
|
52575
|
+
}
|
|
52576
|
+
return diagnostics;
|
|
52577
|
+
}
|
|
52578
|
+
};
|
|
52579
|
+
|
|
52242
52580
|
// src/linter/linter.ts
|
|
52243
52581
|
var builtinRules = [
|
|
52244
52582
|
validationCoverageRule,
|
|
@@ -52246,7 +52584,8 @@ var builtinRules = [
|
|
|
52246
52584
|
taskAgentBindingRule,
|
|
52247
52585
|
mergeIntegrityRule,
|
|
52248
52586
|
artifactOwnershipRule,
|
|
52249
|
-
toolCommandsRule
|
|
52587
|
+
toolCommandsRule,
|
|
52588
|
+
guardrailPolicyCoverageRule
|
|
52250
52589
|
];
|
|
52251
52590
|
function lint(dsl, rules = builtinRules) {
|
|
52252
52591
|
const diagnostics = [];
|
|
@@ -52941,8 +53280,8 @@ var lintCommand = new Command3("lint").description("Run semantic lint rules on r
|
|
|
52941
53280
|
import { Command as Command4 } from "commander";
|
|
52942
53281
|
|
|
52943
53282
|
// src/renderer/renderer.ts
|
|
52944
|
-
import { readFile as
|
|
52945
|
-
import { dirname as
|
|
53283
|
+
import { readFile as readFile4, writeFile, mkdir } from "fs/promises";
|
|
53284
|
+
import { dirname as dirname5 } from "path";
|
|
52946
53285
|
import Handlebars from "handlebars";
|
|
52947
53286
|
|
|
52948
53287
|
// src/renderer/context.ts
|
|
@@ -53154,6 +53493,16 @@ function buildPolicyContext(dsl, policyId) {
|
|
|
53154
53493
|
const policy = { ...policyDef, id: policyId };
|
|
53155
53494
|
return { policy, dsl };
|
|
53156
53495
|
}
|
|
53496
|
+
function buildGuardrailContext(dsl, guardrailId) {
|
|
53497
|
+
const guardrailDef = dsl.guardrails[guardrailId];
|
|
53498
|
+
const guardrail = { ...guardrailDef, id: guardrailId };
|
|
53499
|
+
return { guardrail, dsl };
|
|
53500
|
+
}
|
|
53501
|
+
function buildGuardrailPolicyContext(dsl, policyId) {
|
|
53502
|
+
const policyDef = dsl.guardrail_policies[policyId];
|
|
53503
|
+
const guardrail_policy = { ...policyDef, id: policyId };
|
|
53504
|
+
return { guardrail_policy, dsl };
|
|
53505
|
+
}
|
|
53157
53506
|
function mergeRules(agentRules, taskRules) {
|
|
53158
53507
|
const result = [...agentRules];
|
|
53159
53508
|
const existingIds = new Set(result.map((r3) => r3["id"]));
|
|
@@ -54001,7 +54350,9 @@ function getDslSection(dsl, context) {
|
|
|
54001
54350
|
validation: dsl.validations,
|
|
54002
54351
|
handoff_type: dsl.handoff_types,
|
|
54003
54352
|
workflow: dsl.workflow,
|
|
54004
|
-
policy: dsl.policies
|
|
54353
|
+
policy: dsl.policies,
|
|
54354
|
+
guardrail: dsl.guardrails,
|
|
54355
|
+
guardrail_policy: dsl.guardrail_policies
|
|
54005
54356
|
};
|
|
54006
54357
|
return sectionMap[context] ?? {};
|
|
54007
54358
|
}
|
|
@@ -54034,12 +54385,16 @@ function buildEntityContext(dsl, context, entityId) {
|
|
|
54034
54385
|
return buildWorkflowContext(dsl, entityId);
|
|
54035
54386
|
case "policy":
|
|
54036
54387
|
return buildPolicyContext(dsl, entityId);
|
|
54388
|
+
case "guardrail":
|
|
54389
|
+
return buildGuardrailContext(dsl, entityId);
|
|
54390
|
+
case "guardrail_policy":
|
|
54391
|
+
return buildGuardrailPolicyContext(dsl, entityId);
|
|
54037
54392
|
case "system":
|
|
54038
54393
|
return buildSystemContext(dsl);
|
|
54039
54394
|
}
|
|
54040
54395
|
}
|
|
54041
54396
|
async function loadTemplate(templatePath) {
|
|
54042
|
-
return
|
|
54397
|
+
return readFile4(templatePath, "utf8");
|
|
54043
54398
|
}
|
|
54044
54399
|
async function renderFromConfig(dsl, renderTargets) {
|
|
54045
54400
|
const outputFiles = [];
|
|
@@ -54049,7 +54404,7 @@ async function renderFromConfig(dsl, renderTargets) {
|
|
|
54049
54404
|
if (target.context === "system") {
|
|
54050
54405
|
const ctx = buildSystemContext(dsl);
|
|
54051
54406
|
const output = compiled(ctx);
|
|
54052
|
-
await mkdir(
|
|
54407
|
+
await mkdir(dirname5(target.output), { recursive: true });
|
|
54053
54408
|
await writeFile(target.output, output, "utf8");
|
|
54054
54409
|
outputFiles.push(target.output);
|
|
54055
54410
|
} else {
|
|
@@ -54060,7 +54415,7 @@ async function renderFromConfig(dsl, renderTargets) {
|
|
|
54060
54415
|
const ctx = buildEntityContext(dsl, target.context, entityId);
|
|
54061
54416
|
const output = compiled(ctx);
|
|
54062
54417
|
const outputPath = expandOutputPath(target.output, target.context, entityId);
|
|
54063
|
-
await mkdir(
|
|
54418
|
+
await mkdir(dirname5(outputPath), { recursive: true });
|
|
54064
54419
|
await writeFile(outputPath, output, "utf8");
|
|
54065
54420
|
outputFiles.push(outputPath);
|
|
54066
54421
|
}
|
|
@@ -54077,7 +54432,7 @@ async function checkDriftFromConfig(dsl, renderTargets) {
|
|
|
54077
54432
|
const ctx = buildSystemContext(dsl);
|
|
54078
54433
|
const expected = compiled(ctx);
|
|
54079
54434
|
try {
|
|
54080
|
-
const existing = await
|
|
54435
|
+
const existing = await readFile4(target.output, "utf8");
|
|
54081
54436
|
if (existing !== expected) diffs.push(target.output);
|
|
54082
54437
|
} catch {
|
|
54083
54438
|
diffs.push(target.output);
|
|
@@ -54091,7 +54446,7 @@ async function checkDriftFromConfig(dsl, renderTargets) {
|
|
|
54091
54446
|
const expected = compiled(ctx);
|
|
54092
54447
|
const outputPath = expandOutputPath(target.output, target.context, entityId);
|
|
54093
54448
|
try {
|
|
54094
|
-
const existing = await
|
|
54449
|
+
const existing = await readFile4(outputPath, "utf8");
|
|
54095
54450
|
if (existing !== expected) diffs.push(outputPath);
|
|
54096
54451
|
} catch {
|
|
54097
54452
|
diffs.push(outputPath);
|
|
@@ -54249,14 +54604,322 @@ var checkCommand = new Command5("check").description("Run full pipeline: resolve
|
|
|
54249
54604
|
}
|
|
54250
54605
|
);
|
|
54251
54606
|
|
|
54607
|
+
// src/cli/commands/generate-guardrails.ts
|
|
54608
|
+
import { Command as Command6 } from "commander";
|
|
54609
|
+
|
|
54610
|
+
// src/guardrail-generator/generator.ts
|
|
54611
|
+
import { readFile as readFile5, writeFile as writeFile2, mkdir as mkdir2, chmod } from "fs/promises";
|
|
54612
|
+
import { resolve as resolve6, dirname as dirname6 } from "path";
|
|
54613
|
+
import Handlebars2 from "handlebars";
|
|
54614
|
+
|
|
54615
|
+
// src/guardrail-generator/resolve-checks.ts
|
|
54616
|
+
function resolveChecks(dsl, binding, policy) {
|
|
54617
|
+
const resolved = [];
|
|
54618
|
+
const diagnostics = [];
|
|
54619
|
+
const guardrailImpl = binding.guardrail_impl ?? {};
|
|
54620
|
+
for (const [guardrailId, impl] of Object.entries(guardrailImpl)) {
|
|
54621
|
+
const guardrail = dsl.guardrails[guardrailId];
|
|
54622
|
+
if (!guardrail) {
|
|
54623
|
+
diagnostics.push({
|
|
54624
|
+
path: `binding.${binding.software}.guardrail_impl.${guardrailId}`,
|
|
54625
|
+
message: `Binding "${binding.software}" implements guardrail "${guardrailId}" which is not defined in the DSL`,
|
|
54626
|
+
severity: "error"
|
|
54627
|
+
});
|
|
54628
|
+
continue;
|
|
54629
|
+
}
|
|
54630
|
+
const policyRule = policy.rules.find((r3) => r3.guardrail === guardrailId);
|
|
54631
|
+
if (!policyRule) {
|
|
54632
|
+
diagnostics.push({
|
|
54633
|
+
path: `binding.${binding.software}.guardrail_impl.${guardrailId}`,
|
|
54634
|
+
message: `Guardrail "${guardrailId}" has no policy rule in the active policy \u2014 skipping`,
|
|
54635
|
+
severity: "info"
|
|
54636
|
+
});
|
|
54637
|
+
continue;
|
|
54638
|
+
}
|
|
54639
|
+
for (const check of impl.checks) {
|
|
54640
|
+
resolved.push({
|
|
54641
|
+
guardrail_id: guardrailId,
|
|
54642
|
+
guardrail,
|
|
54643
|
+
policy_rule: policyRule,
|
|
54644
|
+
check
|
|
54645
|
+
});
|
|
54646
|
+
}
|
|
54647
|
+
}
|
|
54648
|
+
return { resolved, diagnostics };
|
|
54649
|
+
}
|
|
54650
|
+
|
|
54651
|
+
// src/guardrail-generator/resolve-paths.ts
|
|
54652
|
+
function resolveBindingTargetPath(target, paths, bindingSoftware) {
|
|
54653
|
+
const diagnostics = [];
|
|
54654
|
+
const resolved = target.replace(/\{(\w+)\}/g, (match, varName) => {
|
|
54655
|
+
const value = paths[varName];
|
|
54656
|
+
if (value === void 0) {
|
|
54657
|
+
diagnostics.push({
|
|
54658
|
+
path: `binding.${bindingSoftware}.outputs`,
|
|
54659
|
+
message: `Path variable "${varName}" used in target "${target}" but not defined in config.paths`,
|
|
54660
|
+
severity: "error"
|
|
54661
|
+
});
|
|
54662
|
+
return match;
|
|
54663
|
+
}
|
|
54664
|
+
return value;
|
|
54665
|
+
});
|
|
54666
|
+
return { resolved, diagnostics };
|
|
54667
|
+
}
|
|
54668
|
+
|
|
54669
|
+
// src/guardrail-generator/generator.ts
|
|
54670
|
+
Handlebars2.registerHelper("json", (value) => {
|
|
54671
|
+
return new Handlebars2.SafeString(JSON.stringify(value, null, 2));
|
|
54672
|
+
});
|
|
54673
|
+
Handlebars2.registerHelper(
|
|
54674
|
+
"expand",
|
|
54675
|
+
(pattern, options) => {
|
|
54676
|
+
if (typeof pattern !== "string") return "";
|
|
54677
|
+
const hash = options.hash;
|
|
54678
|
+
let result = pattern;
|
|
54679
|
+
for (const [key, val] of Object.entries(hash)) {
|
|
54680
|
+
result = result.replace(new RegExp(`\\{\\{${key}\\}\\}`, "g"), String(val));
|
|
54681
|
+
}
|
|
54682
|
+
return new Handlebars2.SafeString(result);
|
|
54683
|
+
}
|
|
54684
|
+
);
|
|
54685
|
+
async function generateGuardrails(options) {
|
|
54686
|
+
const { dsl, config, loadedBindings, filterBindings, dryRun } = options;
|
|
54687
|
+
const outputFiles = [];
|
|
54688
|
+
const diagnostics = [];
|
|
54689
|
+
const policyName = config.activeGuardrailPolicy;
|
|
54690
|
+
if (!policyName) {
|
|
54691
|
+
diagnostics.push({
|
|
54692
|
+
path: "config.active_guardrail_policy",
|
|
54693
|
+
message: "No active_guardrail_policy specified in config \u2014 no guardrails will be generated",
|
|
54694
|
+
severity: "warning"
|
|
54695
|
+
});
|
|
54696
|
+
return { outputFiles, diagnostics };
|
|
54697
|
+
}
|
|
54698
|
+
const policy = dsl.guardrail_policies[policyName];
|
|
54699
|
+
if (!policy) {
|
|
54700
|
+
diagnostics.push({
|
|
54701
|
+
path: "config.active_guardrail_policy",
|
|
54702
|
+
message: `Active guardrail policy "${policyName}" not found in DSL guardrail_policies`,
|
|
54703
|
+
severity: "error"
|
|
54704
|
+
});
|
|
54705
|
+
return { outputFiles, diagnostics };
|
|
54706
|
+
}
|
|
54707
|
+
const allBindings = {};
|
|
54708
|
+
for (const lb of loadedBindings) {
|
|
54709
|
+
allBindings[lb.binding.software] = lb.binding;
|
|
54710
|
+
}
|
|
54711
|
+
let reporting = null;
|
|
54712
|
+
for (const lb of loadedBindings) {
|
|
54713
|
+
if (lb.binding.reporting) {
|
|
54714
|
+
reporting = {
|
|
54715
|
+
commands: lb.binding.reporting.commands,
|
|
54716
|
+
fail_open: lb.binding.reporting.fail_open,
|
|
54717
|
+
timeout_ms: lb.binding.reporting.timeout_ms
|
|
54718
|
+
};
|
|
54719
|
+
break;
|
|
54720
|
+
}
|
|
54721
|
+
}
|
|
54722
|
+
const paths = config.paths ?? {};
|
|
54723
|
+
const vars = config.vars ?? {};
|
|
54724
|
+
for (const lb of loadedBindings) {
|
|
54725
|
+
const binding = lb.binding;
|
|
54726
|
+
if (filterBindings && !filterBindings.includes(binding.software)) {
|
|
54727
|
+
continue;
|
|
54728
|
+
}
|
|
54729
|
+
if (!binding.outputs) continue;
|
|
54730
|
+
const checkResult = resolveChecks(dsl, binding, policy);
|
|
54731
|
+
diagnostics.push(...checkResult.diagnostics);
|
|
54732
|
+
const ctx = {
|
|
54733
|
+
system: { id: dsl.system.id, name: dsl.system.name },
|
|
54734
|
+
guardrails: dsl.guardrails,
|
|
54735
|
+
policy,
|
|
54736
|
+
binding,
|
|
54737
|
+
all_bindings: allBindings,
|
|
54738
|
+
vars,
|
|
54739
|
+
paths,
|
|
54740
|
+
reporting,
|
|
54741
|
+
resolved_checks: checkResult.resolved
|
|
54742
|
+
};
|
|
54743
|
+
for (const [outputId, outputDef] of Object.entries(binding.outputs)) {
|
|
54744
|
+
const pathResult = resolveBindingTargetPath(
|
|
54745
|
+
outputDef.target,
|
|
54746
|
+
paths,
|
|
54747
|
+
binding.software
|
|
54748
|
+
);
|
|
54749
|
+
diagnostics.push(...pathResult.diagnostics);
|
|
54750
|
+
if (pathResult.diagnostics.some((d2) => d2.severity === "error")) {
|
|
54751
|
+
continue;
|
|
54752
|
+
}
|
|
54753
|
+
const targetPath = resolve6(config.configDir, pathResult.resolved);
|
|
54754
|
+
let templateContent;
|
|
54755
|
+
if (outputDef.inline_template) {
|
|
54756
|
+
templateContent = outputDef.inline_template;
|
|
54757
|
+
} else if (outputDef.template) {
|
|
54758
|
+
if (outputDef.template.startsWith("builtin:")) {
|
|
54759
|
+
diagnostics.push({
|
|
54760
|
+
path: `binding.${binding.software}.outputs.${outputId}`,
|
|
54761
|
+
message: `Builtin template "${outputDef.template}" is not yet implemented \u2014 skipping`,
|
|
54762
|
+
severity: "info"
|
|
54763
|
+
});
|
|
54764
|
+
continue;
|
|
54765
|
+
}
|
|
54766
|
+
const templatePath = resolve6(config.configDir, outputDef.template);
|
|
54767
|
+
try {
|
|
54768
|
+
templateContent = await readFile5(templatePath, "utf8");
|
|
54769
|
+
} catch {
|
|
54770
|
+
diagnostics.push({
|
|
54771
|
+
path: `binding.${binding.software}.outputs.${outputId}`,
|
|
54772
|
+
message: `Template file not found: ${templatePath}`,
|
|
54773
|
+
severity: "error"
|
|
54774
|
+
});
|
|
54775
|
+
continue;
|
|
54776
|
+
}
|
|
54777
|
+
} else {
|
|
54778
|
+
diagnostics.push({
|
|
54779
|
+
path: `binding.${binding.software}.outputs.${outputId}`,
|
|
54780
|
+
message: "Output has neither template nor inline_template",
|
|
54781
|
+
severity: "error"
|
|
54782
|
+
});
|
|
54783
|
+
continue;
|
|
54784
|
+
}
|
|
54785
|
+
if (outputDef.group_by) {
|
|
54786
|
+
const groupField = outputDef.group_by;
|
|
54787
|
+
const groups = /* @__PURE__ */ new Map();
|
|
54788
|
+
for (const rc of checkResult.resolved) {
|
|
54789
|
+
const key = String(
|
|
54790
|
+
rc.check[groupField] ?? "default"
|
|
54791
|
+
);
|
|
54792
|
+
if (!groups.has(key)) groups.set(key, []);
|
|
54793
|
+
groups.get(key).push(rc);
|
|
54794
|
+
}
|
|
54795
|
+
for (const [groupKey, groupChecks] of groups) {
|
|
54796
|
+
const groupCtx = {
|
|
54797
|
+
...ctx,
|
|
54798
|
+
resolved_checks: groupChecks,
|
|
54799
|
+
current_group: groupKey
|
|
54800
|
+
};
|
|
54801
|
+
const compiled = Handlebars2.compile(templateContent, { noEscape: true });
|
|
54802
|
+
const output = compiled(groupCtx);
|
|
54803
|
+
const groupTarget = resolve6(targetPath, groupKey);
|
|
54804
|
+
if (!dryRun) {
|
|
54805
|
+
await mkdir2(dirname6(groupTarget), { recursive: true });
|
|
54806
|
+
await writeFile2(groupTarget, output, "utf8");
|
|
54807
|
+
if (outputDef.executable) {
|
|
54808
|
+
await chmod(groupTarget, 493);
|
|
54809
|
+
}
|
|
54810
|
+
}
|
|
54811
|
+
outputFiles.push(groupTarget);
|
|
54812
|
+
}
|
|
54813
|
+
} else {
|
|
54814
|
+
const compiled = Handlebars2.compile(templateContent, { noEscape: true });
|
|
54815
|
+
const output = compiled(ctx);
|
|
54816
|
+
if (!dryRun) {
|
|
54817
|
+
await mkdir2(dirname6(targetPath), { recursive: true });
|
|
54818
|
+
await writeFile2(targetPath, output, "utf8");
|
|
54819
|
+
if (outputDef.executable) {
|
|
54820
|
+
await chmod(targetPath, 493);
|
|
54821
|
+
}
|
|
54822
|
+
}
|
|
54823
|
+
outputFiles.push(targetPath);
|
|
54824
|
+
}
|
|
54825
|
+
}
|
|
54826
|
+
}
|
|
54827
|
+
return { outputFiles, diagnostics };
|
|
54828
|
+
}
|
|
54829
|
+
|
|
54830
|
+
// src/cli/commands/generate-guardrails.ts
|
|
54831
|
+
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(
|
|
54832
|
+
async (type, opts) => {
|
|
54833
|
+
if (type !== "guardrails") {
|
|
54834
|
+
process.stderr.write(`Unknown generate type: ${type}
|
|
54835
|
+
`);
|
|
54836
|
+
process.exit(1);
|
|
54837
|
+
}
|
|
54838
|
+
try {
|
|
54839
|
+
const config = await loadConfig(opts.config);
|
|
54840
|
+
if (!config) {
|
|
54841
|
+
process.stderr.write(
|
|
54842
|
+
"Error: agent-contracts.config.yaml not found. Use --config to specify path.\n"
|
|
54843
|
+
);
|
|
54844
|
+
process.exit(1);
|
|
54845
|
+
}
|
|
54846
|
+
const resolved = await resolve4(config.dsl);
|
|
54847
|
+
const data = config.vars ? substituteVars(resolved.data, config.vars) : resolved.data;
|
|
54848
|
+
const schemaResult = validateSchema(data);
|
|
54849
|
+
if (!schemaResult.success) {
|
|
54850
|
+
process.stderr.write(
|
|
54851
|
+
"Schema validation failed. Run 'agent-contracts validate' for details.\n"
|
|
54852
|
+
);
|
|
54853
|
+
process.exit(1);
|
|
54854
|
+
}
|
|
54855
|
+
const loadedBindings = await loadBindings(config.bindings);
|
|
54856
|
+
const result = await generateGuardrails({
|
|
54857
|
+
dsl: schemaResult.data,
|
|
54858
|
+
config,
|
|
54859
|
+
loadedBindings,
|
|
54860
|
+
filterBindings: opts.binding,
|
|
54861
|
+
dryRun: opts.dryRun
|
|
54862
|
+
});
|
|
54863
|
+
const errors = result.diagnostics.filter((d2) => d2.severity === "error");
|
|
54864
|
+
const warnings = result.diagnostics.filter((d2) => d2.severity === "warning");
|
|
54865
|
+
const infos = result.diagnostics.filter((d2) => d2.severity === "info");
|
|
54866
|
+
if (errors.length > 0) {
|
|
54867
|
+
process.stderr.write("Errors:\n");
|
|
54868
|
+
for (const d2 of errors) {
|
|
54869
|
+
process.stderr.write(` error [${d2.path}] ${d2.message}
|
|
54870
|
+
`);
|
|
54871
|
+
}
|
|
54872
|
+
}
|
|
54873
|
+
if (warnings.length > 0 && !opts.quiet) {
|
|
54874
|
+
process.stderr.write("Warnings:\n");
|
|
54875
|
+
for (const d2 of warnings) {
|
|
54876
|
+
process.stderr.write(` warning [${d2.path}] ${d2.message}
|
|
54877
|
+
`);
|
|
54878
|
+
}
|
|
54879
|
+
}
|
|
54880
|
+
if (infos.length > 0 && !opts.quiet) {
|
|
54881
|
+
for (const d2 of infos) {
|
|
54882
|
+
process.stderr.write(` info [${d2.path}] ${d2.message}
|
|
54883
|
+
`);
|
|
54884
|
+
}
|
|
54885
|
+
}
|
|
54886
|
+
if (errors.length > 0) {
|
|
54887
|
+
process.exit(1);
|
|
54888
|
+
}
|
|
54889
|
+
if (!opts.quiet) {
|
|
54890
|
+
const action = opts.dryRun ? "Would generate" : "Generated";
|
|
54891
|
+
process.stdout.write(
|
|
54892
|
+
`${action} ${result.outputFiles.length} file(s):
|
|
54893
|
+
`
|
|
54894
|
+
);
|
|
54895
|
+
for (const f2 of result.outputFiles) {
|
|
54896
|
+
process.stdout.write(` ${f2}
|
|
54897
|
+
`);
|
|
54898
|
+
}
|
|
54899
|
+
}
|
|
54900
|
+
} catch (err) {
|
|
54901
|
+
if (err instanceof ConfigLoadError) {
|
|
54902
|
+
process.stderr.write(`Config error: ${err.message}
|
|
54903
|
+
`);
|
|
54904
|
+
process.exit(1);
|
|
54905
|
+
}
|
|
54906
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
54907
|
+
process.stderr.write(`Error: ${msg}
|
|
54908
|
+
`);
|
|
54909
|
+
process.exit(1);
|
|
54910
|
+
}
|
|
54911
|
+
}
|
|
54912
|
+
);
|
|
54913
|
+
|
|
54252
54914
|
// src/cli/cli.ts
|
|
54253
|
-
var program = new
|
|
54915
|
+
var program = new Command7();
|
|
54254
54916
|
program.name("agent-contracts").description("Agent contracts tooling \u2014 validate, lint, render DSL files").version("0.0.2");
|
|
54255
54917
|
program.addCommand(resolveCommand);
|
|
54256
54918
|
program.addCommand(validateCommand);
|
|
54257
54919
|
program.addCommand(lintCommand);
|
|
54258
54920
|
program.addCommand(renderCommand);
|
|
54259
54921
|
program.addCommand(checkCommand);
|
|
54922
|
+
program.addCommand(generateGuardrailsCommand);
|
|
54260
54923
|
program.parse();
|
|
54261
54924
|
/*! Bundled license information:
|
|
54262
54925
|
|