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/index.js
CHANGED
|
@@ -54170,8 +54170,16 @@ function filterIds(allIds, include, exclude) {
|
|
|
54170
54170
|
if (exclude) return allIds.filter((id) => !exclude.includes(id));
|
|
54171
54171
|
return allIds;
|
|
54172
54172
|
}
|
|
54173
|
-
function expandOutputPath(pattern, context, entityId) {
|
|
54174
|
-
return pattern.replace(
|
|
54173
|
+
function expandOutputPath(pattern, context, entityId, entity) {
|
|
54174
|
+
return pattern.replace(
|
|
54175
|
+
new RegExp(`\\{${context}\\.([^}]+)\\}`, "g"),
|
|
54176
|
+
(_match, field) => {
|
|
54177
|
+
if (field === "id") return entityId;
|
|
54178
|
+
if (entity === void 0) return _match;
|
|
54179
|
+
const value = entity[field];
|
|
54180
|
+
return typeof value === "string" ? value : _match;
|
|
54181
|
+
}
|
|
54182
|
+
);
|
|
54175
54183
|
}
|
|
54176
54184
|
function buildEntityContext(dsl, context, entityId) {
|
|
54177
54185
|
switch (context) {
|
|
@@ -54236,7 +54244,8 @@ async function renderFromConfig(dsl, renderTargets, options) {
|
|
|
54236
54244
|
for (const entityId of ids) {
|
|
54237
54245
|
const ctx = buildEntityContext(dsl, target.context, entityId);
|
|
54238
54246
|
const output = compiled(ctx);
|
|
54239
|
-
const
|
|
54247
|
+
const entity = section[entityId];
|
|
54248
|
+
const outputPath = expandOutputPath(target.output, target.context, entityId, entity);
|
|
54240
54249
|
if (target.skip_empty && isEffectivelyEmpty(output)) {
|
|
54241
54250
|
await removeIfExists(outputPath);
|
|
54242
54251
|
continue;
|
|
@@ -54285,7 +54294,8 @@ async function checkDriftFromConfig(dsl, renderTargets, options) {
|
|
|
54285
54294
|
for (const entityId of ids) {
|
|
54286
54295
|
const ctx = buildEntityContext(dsl, target.context, entityId);
|
|
54287
54296
|
const expected = compiled(ctx);
|
|
54288
|
-
const
|
|
54297
|
+
const entity = section[entityId];
|
|
54298
|
+
const outputPath = expandOutputPath(target.output, target.context, entityId, entity);
|
|
54289
54299
|
await checkExpectedVsExisting(expected, outputPath, target.skip_empty, diffs);
|
|
54290
54300
|
}
|
|
54291
54301
|
}
|
|
@@ -54955,7 +54965,8 @@ async function loadRenderedFiles(dsl, renderTargets) {
|
|
|
54955
54965
|
const section = getDslSection(dsl, target.context);
|
|
54956
54966
|
const ids = filterIds(Object.keys(section), target.include, target.exclude);
|
|
54957
54967
|
for (const entityId of ids) {
|
|
54958
|
-
const
|
|
54968
|
+
const entity = section[entityId];
|
|
54969
|
+
const outputPath = expandOutputPath(target.output, target.context, entityId, entity);
|
|
54959
54970
|
try {
|
|
54960
54971
|
const content = await readFile5(outputPath, "utf8");
|
|
54961
54972
|
entries.push({ agent_id: entityId, path: outputPath, content });
|
|
@@ -56282,8 +56293,9 @@ async function generateGuardrails(options) {
|
|
|
56282
56293
|
const entityCtx = buildEntityContext(dsl, context, entityId);
|
|
56283
56294
|
const mergedCtx = { ...entityCtx, vars, paths, binding, resolved_checks: checkResult.resolved };
|
|
56284
56295
|
const rendered = compiled(mergedCtx);
|
|
56296
|
+
const entity = section[entityId];
|
|
56285
56297
|
const resolvedOutput = resolveBindingRenderOutputPath(
|
|
56286
|
-
expandOutputPath(renderTarget.output, context, entityId),
|
|
56298
|
+
expandOutputPath(renderTarget.output, context, entityId, entity),
|
|
56287
56299
|
paths
|
|
56288
56300
|
);
|
|
56289
56301
|
const outputPath = resolve6(config.configDir, resolvedOutput);
|