agent-contracts 0.23.1 → 0.23.2
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 +18 -6
- package/dist/cli.js.map +1 -1
- package/dist/index.js +18 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -55299,8 +55299,16 @@ 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
|
+
);
|
|
55304
55312
|
}
|
|
55305
55313
|
function buildEntityContext(dsl, context, entityId) {
|
|
55306
55314
|
switch (context) {
|
|
@@ -55365,7 +55373,8 @@ async function renderFromConfig(dsl, renderTargets, options) {
|
|
|
55365
55373
|
for (const entityId of ids) {
|
|
55366
55374
|
const ctx = buildEntityContext(dsl, target.context, entityId);
|
|
55367
55375
|
const output = compiled(ctx);
|
|
55368
|
-
const
|
|
55376
|
+
const entity = section[entityId];
|
|
55377
|
+
const outputPath = expandOutputPath(target.output, target.context, entityId, entity);
|
|
55369
55378
|
if (target.skip_empty && isEffectivelyEmpty(output)) {
|
|
55370
55379
|
await removeIfExists(outputPath);
|
|
55371
55380
|
continue;
|
|
@@ -55414,7 +55423,8 @@ async function checkDriftFromConfig(dsl, renderTargets, options) {
|
|
|
55414
55423
|
for (const entityId of ids) {
|
|
55415
55424
|
const ctx = buildEntityContext(dsl, target.context, entityId);
|
|
55416
55425
|
const expected = compiled(ctx);
|
|
55417
|
-
const
|
|
55426
|
+
const entity = section[entityId];
|
|
55427
|
+
const outputPath = expandOutputPath(target.output, target.context, entityId, entity);
|
|
55418
55428
|
await checkExpectedVsExisting(expected, outputPath, target.skip_empty, diffs);
|
|
55419
55429
|
}
|
|
55420
55430
|
}
|
|
@@ -56136,8 +56146,9 @@ async function generateGuardrails(options) {
|
|
|
56136
56146
|
const entityCtx = buildEntityContext(dsl, context, entityId);
|
|
56137
56147
|
const mergedCtx = { ...entityCtx, vars, paths, binding, resolved_checks: checkResult.resolved };
|
|
56138
56148
|
const rendered = compiled(mergedCtx);
|
|
56149
|
+
const entity = section[entityId];
|
|
56139
56150
|
const resolvedOutput = resolveBindingRenderOutputPath(
|
|
56140
|
-
expandOutputPath(renderTarget.output, context, entityId),
|
|
56151
|
+
expandOutputPath(renderTarget.output, context, entityId, entity),
|
|
56141
56152
|
paths
|
|
56142
56153
|
);
|
|
56143
56154
|
const outputPath = resolve6(config.configDir, resolvedOutput);
|
|
@@ -56264,7 +56275,8 @@ async function loadRenderedFiles(dsl, renderTargets) {
|
|
|
56264
56275
|
const section = getDslSection(dsl, target.context);
|
|
56265
56276
|
const ids = filterIds(Object.keys(section), target.include, target.exclude);
|
|
56266
56277
|
for (const entityId of ids) {
|
|
56267
|
-
const
|
|
56278
|
+
const entity = section[entityId];
|
|
56279
|
+
const outputPath = expandOutputPath(target.output, target.context, entityId, entity);
|
|
56268
56280
|
try {
|
|
56269
56281
|
const content = await readFile6(outputPath, "utf8");
|
|
56270
56282
|
entries.push({ agent_id: entityId, path: outputPath, content });
|