agent-contracts 0.23.1 → 0.23.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +28 -9
- package/dist/cli.js.map +1 -1
- package/dist/index.js +28 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -55299,8 +55299,22 @@ function filterIds(allIds, include, exclude) {
|
|
|
55299
55299
|
if (exclude) return allIds.filter((id) => !exclude.includes(id));
|
|
55300
55300
|
return allIds;
|
|
55301
55301
|
}
|
|
55302
|
-
function expandOutputPath(pattern, context, entityId) {
|
|
55303
|
-
return pattern.replace(
|
|
55302
|
+
function expandOutputPath(pattern, context, entityId, entity) {
|
|
55303
|
+
return pattern.replace(
|
|
55304
|
+
new RegExp(`\\{${context}\\.([^}]+)\\}`, "g"),
|
|
55305
|
+
(_match, field) => {
|
|
55306
|
+
if (field === "id") return entityId;
|
|
55307
|
+
if (entity === void 0) return _match;
|
|
55308
|
+
const value = entity[field];
|
|
55309
|
+
return typeof value === "string" ? value : _match;
|
|
55310
|
+
}
|
|
55311
|
+
);
|
|
55312
|
+
}
|
|
55313
|
+
var CONTEXT_TYPE_PATTERN = new RegExp(
|
|
55314
|
+
`\\{(${CONTEXT_TYPES.join("|")})\\.[^}]+\\}`
|
|
55315
|
+
);
|
|
55316
|
+
function hasUnresolvedPathVars(path) {
|
|
55317
|
+
return CONTEXT_TYPE_PATTERN.test(path);
|
|
55304
55318
|
}
|
|
55305
55319
|
function buildEntityContext(dsl, context, entityId) {
|
|
55306
55320
|
switch (context) {
|
|
@@ -55365,7 +55379,9 @@ async function renderFromConfig(dsl, renderTargets, options) {
|
|
|
55365
55379
|
for (const entityId of ids) {
|
|
55366
55380
|
const ctx = buildEntityContext(dsl, target.context, entityId);
|
|
55367
55381
|
const output = compiled(ctx);
|
|
55368
|
-
const
|
|
55382
|
+
const entity = section[entityId];
|
|
55383
|
+
const outputPath = expandOutputPath(target.output, target.context, entityId, entity);
|
|
55384
|
+
if (hasUnresolvedPathVars(outputPath)) continue;
|
|
55369
55385
|
if (target.skip_empty && isEffectivelyEmpty(output)) {
|
|
55370
55386
|
await removeIfExists(outputPath);
|
|
55371
55387
|
continue;
|
|
@@ -55414,7 +55430,9 @@ async function checkDriftFromConfig(dsl, renderTargets, options) {
|
|
|
55414
55430
|
for (const entityId of ids) {
|
|
55415
55431
|
const ctx = buildEntityContext(dsl, target.context, entityId);
|
|
55416
55432
|
const expected = compiled(ctx);
|
|
55417
|
-
const
|
|
55433
|
+
const entity = section[entityId];
|
|
55434
|
+
const outputPath = expandOutputPath(target.output, target.context, entityId, entity);
|
|
55435
|
+
if (hasUnresolvedPathVars(outputPath)) continue;
|
|
55418
55436
|
await checkExpectedVsExisting(expected, outputPath, target.skip_empty, diffs);
|
|
55419
55437
|
}
|
|
55420
55438
|
}
|
|
@@ -56136,10 +56154,10 @@ async function generateGuardrails(options) {
|
|
|
56136
56154
|
const entityCtx = buildEntityContext(dsl, context, entityId);
|
|
56137
56155
|
const mergedCtx = { ...entityCtx, vars, paths, binding, resolved_checks: checkResult.resolved };
|
|
56138
56156
|
const rendered = compiled(mergedCtx);
|
|
56139
|
-
const
|
|
56140
|
-
|
|
56141
|
-
|
|
56142
|
-
);
|
|
56157
|
+
const entity = section[entityId];
|
|
56158
|
+
const expandedOutput = expandOutputPath(renderTarget.output, context, entityId, entity);
|
|
56159
|
+
if (hasUnresolvedPathVars(expandedOutput)) continue;
|
|
56160
|
+
const resolvedOutput = resolveBindingRenderOutputPath(expandedOutput, paths);
|
|
56143
56161
|
const outputPath = resolve6(config.configDir, resolvedOutput);
|
|
56144
56162
|
if (shouldSkipEmpty && rendered.trim().length === 0) {
|
|
56145
56163
|
if (!dryRun) {
|
|
@@ -56264,7 +56282,8 @@ async function loadRenderedFiles(dsl, renderTargets) {
|
|
|
56264
56282
|
const section = getDslSection(dsl, target.context);
|
|
56265
56283
|
const ids = filterIds(Object.keys(section), target.include, target.exclude);
|
|
56266
56284
|
for (const entityId of ids) {
|
|
56267
|
-
const
|
|
56285
|
+
const entity = section[entityId];
|
|
56286
|
+
const outputPath = expandOutputPath(target.output, target.context, entityId, entity);
|
|
56268
56287
|
try {
|
|
56269
56288
|
const content = await readFile6(outputPath, "utf8");
|
|
56270
56289
|
entries.push({ agent_id: entityId, path: outputPath, content });
|