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/index.js CHANGED
@@ -54170,8 +54170,22 @@ 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(new RegExp(`\\{${context}\\.id\\}`, "g"), entityId);
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
+ );
54183
+ }
54184
+ var CONTEXT_TYPE_PATTERN = new RegExp(
54185
+ `\\{(${CONTEXT_TYPES.join("|")})\\.[^}]+\\}`
54186
+ );
54187
+ function hasUnresolvedPathVars(path) {
54188
+ return CONTEXT_TYPE_PATTERN.test(path);
54175
54189
  }
54176
54190
  function buildEntityContext(dsl, context, entityId) {
54177
54191
  switch (context) {
@@ -54236,7 +54250,9 @@ async function renderFromConfig(dsl, renderTargets, options) {
54236
54250
  for (const entityId of ids) {
54237
54251
  const ctx = buildEntityContext(dsl, target.context, entityId);
54238
54252
  const output = compiled(ctx);
54239
- const outputPath = expandOutputPath(target.output, target.context, entityId);
54253
+ const entity = section[entityId];
54254
+ const outputPath = expandOutputPath(target.output, target.context, entityId, entity);
54255
+ if (hasUnresolvedPathVars(outputPath)) continue;
54240
54256
  if (target.skip_empty && isEffectivelyEmpty(output)) {
54241
54257
  await removeIfExists(outputPath);
54242
54258
  continue;
@@ -54285,7 +54301,9 @@ async function checkDriftFromConfig(dsl, renderTargets, options) {
54285
54301
  for (const entityId of ids) {
54286
54302
  const ctx = buildEntityContext(dsl, target.context, entityId);
54287
54303
  const expected = compiled(ctx);
54288
- const outputPath = expandOutputPath(target.output, target.context, entityId);
54304
+ const entity = section[entityId];
54305
+ const outputPath = expandOutputPath(target.output, target.context, entityId, entity);
54306
+ if (hasUnresolvedPathVars(outputPath)) continue;
54289
54307
  await checkExpectedVsExisting(expected, outputPath, target.skip_empty, diffs);
54290
54308
  }
54291
54309
  }
@@ -54955,7 +54973,8 @@ async function loadRenderedFiles(dsl, renderTargets) {
54955
54973
  const section = getDslSection(dsl, target.context);
54956
54974
  const ids = filterIds(Object.keys(section), target.include, target.exclude);
54957
54975
  for (const entityId of ids) {
54958
- const outputPath = expandOutputPath(target.output, target.context, entityId);
54976
+ const entity = section[entityId];
54977
+ const outputPath = expandOutputPath(target.output, target.context, entityId, entity);
54959
54978
  try {
54960
54979
  const content = await readFile5(outputPath, "utf8");
54961
54980
  entries.push({ agent_id: entityId, path: outputPath, content });
@@ -56282,10 +56301,10 @@ async function generateGuardrails(options) {
56282
56301
  const entityCtx = buildEntityContext(dsl, context, entityId);
56283
56302
  const mergedCtx = { ...entityCtx, vars, paths, binding, resolved_checks: checkResult.resolved };
56284
56303
  const rendered = compiled(mergedCtx);
56285
- const resolvedOutput = resolveBindingRenderOutputPath(
56286
- expandOutputPath(renderTarget.output, context, entityId),
56287
- paths
56288
- );
56304
+ const entity = section[entityId];
56305
+ const expandedOutput = expandOutputPath(renderTarget.output, context, entityId, entity);
56306
+ if (hasUnresolvedPathVars(expandedOutput)) continue;
56307
+ const resolvedOutput = resolveBindingRenderOutputPath(expandedOutput, paths);
56289
56308
  const outputPath = resolve6(config.configDir, resolvedOutput);
56290
56309
  if (shouldSkipEmpty && rendered.trim().length === 0) {
56291
56310
  if (!dryRun) {