@aaac/runtime 0.1.12 → 0.1.14

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.
@@ -1,4 +1,4 @@
1
- import { S as SdkAdapter, G as GuardrailHooks, C as CacheConfig, A as AdapterSendOptions, a as AgentExecutionRequest, M as MemoryRef } from '../task-runner-C1hxIJTd.js';
1
+ import { S as SdkAdapter, G as GuardrailHooks, C as CacheConfig, A as AdapterSendOptions, a as AgentExecutionRequest, M as MemoryRef } from '../task-runner-BPk-PcZA.js';
2
2
  import 'zod';
3
3
  import '../context-DKkamYX_.js';
4
4
  import '@aaac/observability';
@@ -1,4 +1,4 @@
1
- import { S as SdkAdapter, G as GuardrailHooks, C as CacheConfig, A as AdapterSendOptions, a as AgentExecutionRequest, M as MemoryRef } from '../task-runner-C1hxIJTd.js';
1
+ import { S as SdkAdapter, G as GuardrailHooks, C as CacheConfig, A as AdapterSendOptions, a as AgentExecutionRequest, M as MemoryRef } from '../task-runner-BPk-PcZA.js';
2
2
  import 'zod';
3
3
  import '../context-DKkamYX_.js';
4
4
  import '@aaac/observability';
@@ -1,4 +1,4 @@
1
- import { S as SdkAdapter, A as AdapterSendOptions, M as MemoryRef } from '../task-runner-C1hxIJTd.js';
1
+ import { S as SdkAdapter, A as AdapterSendOptions, M as MemoryRef } from '../task-runner-BPk-PcZA.js';
2
2
  import 'zod';
3
3
  import '../context-DKkamYX_.js';
4
4
  import '@aaac/observability';
@@ -1,4 +1,4 @@
1
- import { S as SdkAdapter, G as GuardrailHooks, C as CacheConfig, A as AdapterSendOptions, a as AgentExecutionRequest, M as MemoryRef } from '../task-runner-C1hxIJTd.js';
1
+ import { S as SdkAdapter, G as GuardrailHooks, C as CacheConfig, A as AdapterSendOptions, a as AgentExecutionRequest, M as MemoryRef } from '../task-runner-BPk-PcZA.js';
2
2
  import 'zod';
3
3
  import '../context-DKkamYX_.js';
4
4
  import '@aaac/observability';
@@ -48,13 +48,11 @@ function buildGuardrailContext(dsl, binding, policyName) {
48
48
  }
49
49
 
50
50
  // src/generator/config.ts
51
- import { existsSync } from "fs";
52
51
  import { readFile } from "fs/promises";
53
- import { resolve, dirname, join, basename } from "path";
52
+ import { resolve, dirname } from "path";
54
53
  import { z } from "zod";
55
54
  import YAML from "yaml";
56
55
  var DEFAULT_CONFIG_PATH = "./agents.conf.yaml";
57
- var LEGACY_CONFIG_FILENAME = "agent-runtime.config.yaml";
58
56
  var RecoverySchema = z.object({
59
57
  max_follow_ups: z.number().int().min(0).default(2),
60
58
  max_retries: z.number().int().min(0).default(0)
@@ -149,19 +147,7 @@ var ProjectConfigSchema = z.object({
149
147
  cli: z.record(z.string(), CliSectionSchema).optional()
150
148
  });
151
149
  function resolveConfigFilePath(configPath) {
152
- const absPath = resolve(configPath);
153
- if (existsSync(absPath)) {
154
- return absPath;
155
- }
156
- const dir = dirname(absPath);
157
- const base = basename(absPath);
158
- if (base === "agents.conf.yaml") {
159
- const legacyPath = join(dir, LEGACY_CONFIG_FILENAME);
160
- if (existsSync(legacyPath)) {
161
- return legacyPath;
162
- }
163
- }
164
- return absPath;
150
+ return resolve(configPath);
165
151
  }
166
152
  function mergeBindingsUnion(root, override) {
167
153
  const base = root ?? [];
@@ -271,14 +257,6 @@ function resolveOverride(projectConfig, target) {
271
257
  }
272
258
  return void 0;
273
259
  }
274
- async function loadConfig(configPath) {
275
- const absPath = resolveConfigFilePath(configPath);
276
- const raw = await readFile(absPath, "utf8");
277
- const parsed = YAML.parse(raw);
278
- const config = RuntimeConfigSchema.parse(parsed);
279
- const configDir = dirname(absPath);
280
- return buildResolvedConfig(config, configDir);
281
- }
282
260
  async function loadProjectConfig(configPath, target) {
283
261
  const absPath = resolveConfigFilePath(configPath);
284
262
  const raw = await readFile(absPath, "utf8");
@@ -306,7 +284,6 @@ export {
306
284
  DEFAULT_CONFIG_PATH,
307
285
  ComponentOverrideSchema,
308
286
  ProjectConfigSchema,
309
- loadConfig,
310
287
  loadProjectConfig
311
288
  };
312
- //# sourceMappingURL=chunk-5FL4NAC5.js.map
289
+ //# sourceMappingURL=chunk-E2UR4TNM.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/generator/context.ts","../src/generator/config.ts"],"sourcesContent":["/**\n * Build the guardrail context from resolved DSL + binding data.\n *\n * (The DSL→TypeScript codegen context builder, `buildContractContext`, was\n * removed alongside the runtime `generate()` codegen path.)\n */\n\nexport interface GuardrailCheckEntry {\n guardrail_id: string;\n description: string;\n severity: string;\n action: string;\n matcher_type: string;\n pattern: string;\n message: string;\n file_glob?: string;\n exclude_glob?: string;\n}\n\nexport interface GuardrailContext {\n commandChecks: GuardrailCheckEntry[];\n fileChecks: GuardrailCheckEntry[];\n contentChecks: GuardrailCheckEntry[];\n allChecks: GuardrailCheckEntry[];\n hasGuardrails: boolean;\n}\n\n/**\n * Build guardrail context from DSL guardrails, binding guardrail_impl, and active policy.\n * Mirrors the agent-contracts resolveChecks pattern.\n */\nexport function buildGuardrailContext(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n dsl: any,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n binding: any,\n policyName?: string,\n): GuardrailContext {\n const empty: GuardrailContext = {\n commandChecks: [],\n fileChecks: [],\n contentChecks: [],\n allChecks: [],\n hasGuardrails: false,\n };\n\n if (!binding?.guardrail_impl) return empty;\n\n const guardrails = dsl.guardrails ?? {};\n const policies = dsl.guardrail_policies ?? {};\n const policy = policyName ? policies[policyName] : undefined;\n\n const allChecks: GuardrailCheckEntry[] = [];\n\n for (const [guardrailId, impl] of Object.entries(\n binding.guardrail_impl as Record<string, { checks: Array<Record<string, unknown>> }>,\n )) {\n const guardrail = guardrails[guardrailId] as Record<string, unknown> | undefined;\n const description = (guardrail?.description as string) ?? guardrailId;\n\n const policyRule = policy?.rules?.find(\n (r: Record<string, unknown>) => r.guardrail === guardrailId,\n );\n const severity = (policyRule?.severity as string) ?? \"warning\";\n const action = (policyRule?.action as string) ?? \"warn\";\n\n for (const check of impl.checks) {\n const matcher = check.matcher as Record<string, unknown> | undefined;\n if (!matcher) continue;\n\n allChecks.push({\n guardrail_id: guardrailId,\n description,\n severity,\n action,\n matcher_type: matcher.type as string,\n pattern: matcher.pattern as string,\n message: (check.message as string) ?? description,\n file_glob: matcher.file_glob as string | undefined,\n exclude_glob: matcher.exclude_glob as string | undefined,\n });\n }\n }\n\n return {\n commandChecks: allChecks.filter((c) => c.matcher_type === \"command_regex\"),\n fileChecks: allChecks.filter((c) => c.matcher_type === \"file_glob\"),\n contentChecks: allChecks.filter((c) => c.matcher_type === \"content_regex\"),\n allChecks,\n hasGuardrails: allChecks.length > 0,\n };\n}\n","/**\n * Generator configuration — loads and validates agents.conf.yaml\n */\n\nimport { readFile } from \"node:fs/promises\";\nimport { resolve, dirname } from \"node:path\";\nimport { z } from \"zod\";\nimport YAML from \"yaml\";\n\nexport const DEFAULT_CONFIG_PATH = \"./agents.conf.yaml\";\n\nconst RecoverySchema = z.object({\n max_follow_ups: z.number().int().min(0).default(2),\n max_retries: z.number().int().min(0).default(0),\n}).default(() => ({ max_follow_ups: 2, max_retries: 0 }));\n\nconst ModelClassEntrySchema = z.object({\n adapter: z.string(),\n model: z.string().optional(),\n});\n\nconst ModelMappingSchema = z.object({\n fast: ModelClassEntrySchema.optional(),\n standard: ModelClassEntrySchema.optional(),\n thinking: ModelClassEntrySchema.optional(),\n}).default({});\n\nconst ProgressLogSchema = z.object({\n destination: z.enum([\"stderr\", \"file\", \"both\", \"none\"]).default(\"stderr\"),\n file: z.string().optional(),\n naming: z.enum([\"single\", \"per-invocation\", \"daily\"]).default(\"single\"),\n}).default(() => ({ destination: \"stderr\" as const, naming: \"single\" as const }))\n .refine(\n (val) => {\n if ((val.destination === \"file\" || val.destination === \"both\") && !val.file) return false;\n return true;\n },\n { message: \"logging.progress_log.file is required when destination is 'file' or 'both'\" },\n );\n\nconst LoggingSchema = z.object({\n progress_log: ProgressLogSchema,\n}).default(() => ({ progress_log: { destination: \"stderr\" as const, naming: \"single\" as const } }));\n\nexport const RuntimeConfigSchema = z.object({\n dsl: z.string().default(\"./agent-contracts.yaml\"),\n generated_dir: z.string().default(\"./agent/generated\"),\n bindings: z.array(z.string()).default([]),\n active_guardrail_policy: z.string().optional(),\n templates_dir: z.string().optional(),\n plugins: z.array(z.string()).default([]),\n recovery: RecoverySchema,\n model_mapping: ModelMappingSchema,\n logging: LoggingSchema,\n});\n\nexport type RuntimeConfig = z.infer<typeof RuntimeConfigSchema>;\n\n/**\n * Unified project bindings object.\n * - guardrail: guardrail_impl matcher files → machine enforcement (BoundResolver)\n * - hooks: git hook bindings → governance materialize (#68; declarative for now)\n * - observability: event-mapping file + external recorder CLI\n */\nconst BindingsSchema = z.object({\n guardrail: z.array(z.string()).optional(),\n hooks: z.array(z.string()).optional(),\n observability: z.object({\n event_mapping: z.string().optional(),\n recorder: z.string().optional(),\n }).optional(),\n}).optional();\n\nconst CliSectionSchema = z.object({\n agents: z.string().optional(),\n dsl: z.string().optional(),\n generated_dir: z.string().optional(),\n plugins: z.array(z.string()).optional(),\n bindings: BindingsSchema,\n}).strict();\n\nexport const ComponentOverrideSchema = z.object({\n agents: z.string().optional(),\n dsl: z.string().optional(),\n component_contract: z.string().optional(),\n generated_dir: z.string().optional(),\n bindings: BindingsSchema,\n plugins: z.array(z.string()).optional(),\n model_mapping: ModelMappingSchema.optional(),\n recovery: RecoverySchema.optional(),\n templates_dir: z.string().optional(),\n}).strict();\n\nexport type ComponentOverride = z.infer<typeof ComponentOverrideSchema>;\n\nconst EnvironmentsSchema = z.object({\n git: z.object({\n hooks: z.array(z.string()).optional(),\n }).optional(),\n cursor: z.object({\n hooks_json: z.string().optional(),\n }).optional(),\n ci: z.object({\n provider: z.string().optional(),\n }).optional(),\n}).optional();\n\nexport const ProjectConfigSchema = z.object({\n schema: z.string().optional(),\n agents: z.string().optional(),\n dsl: z.string().optional(),\n generated_dir: z.string().optional(),\n bindings: BindingsSchema,\n active_guardrail_policy: z.string().optional(),\n templates_dir: z.string().optional(),\n plugins: z.array(z.string()).optional(),\n recovery: RecoverySchema,\n model_mapping: ModelMappingSchema,\n logging: LoggingSchema,\n artifacts: z.string().optional(),\n toolchains: z.string().optional(),\n components: z.record(z.string(), ComponentOverrideSchema).optional(),\n environments: EnvironmentsSchema,\n cli: z.record(z.string(), CliSectionSchema).optional(),\n});\n\nexport type ProjectConfig = z.infer<typeof ProjectConfigSchema>;\n\nexport interface ResolvedProgressLog {\n destination: \"stderr\" | \"file\" | \"both\" | \"none\";\n file: string | undefined;\n naming: \"single\" | \"per-invocation\" | \"daily\";\n}\n\nexport interface ResolvedEnvironments {\n git?: { hooks: string[] };\n cursor?: { hooks_json: string };\n ci?: { provider: string };\n}\n\nexport interface ResolvedObservability {\n eventMappingPath?: string;\n recorder?: string;\n}\n\nexport interface ResolvedConfig extends RuntimeConfig {\n configDir: string;\n dslPath: string;\n generatedDir: string;\n /** Resolved guardrail_impl matcher files (machine enforcement). */\n bindingPaths: string[];\n /** Resolved git-hook binding files (governance materialize, #68). */\n hookBindingPaths: string[];\n /** Observability event mapping + recorder, if configured. */\n observability?: ResolvedObservability;\n templatesDir: string | undefined;\n pluginPaths: string[];\n resolvedLogging: { progressLog: ResolvedProgressLog };\n artifactsPath?: string;\n toolchainsPath?: string;\n environments?: ResolvedEnvironments;\n componentOverrides?: Record<string, ComponentOverride>;\n}\n\ninterface GovernanceFields {\n artifacts?: string;\n toolchains?: string;\n environments?: z.infer<typeof EnvironmentsSchema>;\n componentOverrides?: Record<string, ComponentOverride>;\n hookBindings?: string[];\n observability?: { event_mapping?: string; recorder?: string };\n}\n\n/** Internal runtime base assembled from a project manifest before RuntimeConfigSchema validation. */\ninterface RuntimeConfigInput {\n dsl?: string;\n generated_dir?: string;\n bindings: string[];\n active_guardrail_policy?: string;\n templates_dir?: string;\n plugins?: string[];\n recovery: z.infer<typeof RecoverySchema>;\n model_mapping: z.infer<typeof ModelMappingSchema>;\n logging: z.infer<typeof LoggingSchema>;\n}\n\ntype ConfigOverride = ComponentOverride | z.infer<typeof CliSectionSchema>;\n\nfunction resolveConfigFilePath(configPath: string): string {\n return resolve(configPath);\n}\n\nfunction mergeBindingsUnion(root: string[] | undefined, override: string[] | undefined): string[] {\n const base = root ?? [];\n const extra = override ?? [];\n const seen = new Set(base);\n const result = [...base];\n for (const binding of extra) {\n if (!seen.has(binding)) {\n result.push(binding);\n seen.add(binding);\n }\n }\n return result;\n}\n\nfunction mergeConfigWithOverride(\n base: RuntimeConfigInput,\n override: ConfigOverride,\n): RuntimeConfigInput {\n const merged: RuntimeConfigInput = { ...base };\n\n const overrideDsl = override.agents ?? override.dsl;\n if (overrideDsl !== undefined) merged.dsl = overrideDsl;\n if (override.generated_dir !== undefined) merged.generated_dir = override.generated_dir;\n if (override.bindings?.guardrail !== undefined) {\n merged.bindings = mergeBindingsUnion(base.bindings, override.bindings.guardrail);\n }\n if (override.plugins !== undefined) merged.plugins = override.plugins;\n\n if (\"templates_dir\" in override && override.templates_dir !== undefined) {\n merged.templates_dir = override.templates_dir;\n }\n\n if (\"model_mapping\" in override && override.model_mapping) {\n merged.model_mapping = {\n ...base.model_mapping,\n ...(override.model_mapping.fast ? { fast: override.model_mapping.fast } : {}),\n ...(override.model_mapping.standard ? { standard: override.model_mapping.standard } : {}),\n ...(override.model_mapping.thinking ? { thinking: override.model_mapping.thinking } : {}),\n };\n }\n\n if (\"recovery\" in override && override.recovery) {\n merged.recovery = {\n ...base.recovery,\n ...override.recovery,\n };\n }\n\n return merged;\n}\n\nfunction resolveEnvironments(\n environments: z.infer<typeof EnvironmentsSchema>,\n configDir: string,\n): ResolvedEnvironments | undefined {\n if (!environments) return undefined;\n\n const resolved: ResolvedEnvironments = {};\n\n if (environments.git?.hooks) {\n resolved.git = { hooks: environments.git.hooks };\n }\n\n if (environments.cursor?.hooks_json) {\n resolved.cursor = {\n hooks_json: resolve(configDir, environments.cursor.hooks_json),\n };\n }\n\n if (environments.ci?.provider) {\n resolved.ci = { provider: environments.ci.provider };\n }\n\n return Object.keys(resolved).length > 0 ? resolved : undefined;\n}\n\nfunction buildResolvedConfig(\n config: RuntimeConfig,\n configDir: string,\n governance?: GovernanceFields,\n): ResolvedConfig {\n const pl = config.logging.progress_log;\n\n return {\n ...config,\n configDir,\n dslPath: resolve(configDir, config.dsl),\n generatedDir: resolve(configDir, config.generated_dir),\n bindingPaths: config.bindings.map((b) => resolve(configDir, b)),\n hookBindingPaths: (governance?.hookBindings ?? []).map((b) => resolve(configDir, b)),\n observability: governance?.observability\n ? {\n eventMappingPath: governance.observability.event_mapping\n ? resolve(configDir, governance.observability.event_mapping)\n : undefined,\n recorder: governance.observability.recorder,\n }\n : undefined,\n templatesDir: config.templates_dir\n ? resolve(configDir, config.templates_dir)\n : undefined,\n pluginPaths: config.plugins,\n resolvedLogging: {\n progressLog: {\n destination: pl.destination,\n file: pl.file ? resolve(configDir, pl.file) : undefined,\n naming: pl.naming,\n },\n },\n artifactsPath: governance?.artifacts\n ? resolve(configDir, governance.artifacts)\n : undefined,\n toolchainsPath: governance?.toolchains\n ? resolve(configDir, governance.toolchains)\n : undefined,\n environments: resolveEnvironments(governance?.environments, configDir),\n componentOverrides: governance?.componentOverrides,\n };\n}\n\n/** Assemble the internal runtime base from a parsed project manifest (agents wins over dsl alias). */\nfunction projectToRuntimeBase(projectConfig: ProjectConfig): RuntimeConfigInput {\n return {\n dsl: projectConfig.agents ?? projectConfig.dsl,\n generated_dir: projectConfig.generated_dir,\n bindings: projectConfig.bindings?.guardrail ?? [],\n active_guardrail_policy: projectConfig.active_guardrail_policy,\n templates_dir: projectConfig.templates_dir,\n plugins: projectConfig.plugins,\n recovery: projectConfig.recovery,\n model_mapping: projectConfig.model_mapping,\n logging: projectConfig.logging,\n };\n}\n\nfunction resolveOverride(\n projectConfig: ProjectConfig,\n target?: string,\n): ConfigOverride | undefined {\n if (!target) return undefined;\n\n if (projectConfig.components?.[target]) {\n return projectConfig.components[target];\n }\n\n if (projectConfig.cli?.[target]) {\n return projectConfig.cli[target];\n }\n\n return undefined;\n}\n\nexport async function loadProjectConfig(\n configPath: string,\n target?: string,\n): Promise<ResolvedConfig> {\n const absPath = resolveConfigFilePath(configPath);\n const raw = await readFile(absPath, \"utf8\");\n const parsed = YAML.parse(raw);\n const projectConfig = ProjectConfigSchema.parse(parsed);\n\n let base = projectToRuntimeBase(projectConfig);\n const override = resolveOverride(projectConfig, target);\n\n if (override) {\n base = mergeConfigWithOverride(base, override);\n }\n\n const config = RuntimeConfigSchema.parse(base);\n const configDir = dirname(absPath);\n\n return buildResolvedConfig(config, configDir, {\n artifacts: projectConfig.artifacts,\n toolchains: projectConfig.toolchains,\n environments: projectConfig.environments,\n componentOverrides: projectConfig.components,\n hookBindings: projectConfig.bindings?.hooks,\n observability: projectConfig.bindings?.observability,\n });\n}\n"],"mappings":";AA+BO,SAAS,sBAEd,KAEA,SACA,YACkB;AAClB,QAAM,QAA0B;AAAA,IAC9B,eAAe,CAAC;AAAA,IAChB,YAAY,CAAC;AAAA,IACb,eAAe,CAAC;AAAA,IAChB,WAAW,CAAC;AAAA,IACZ,eAAe;AAAA,EACjB;AAEA,MAAI,CAAC,SAAS,eAAgB,QAAO;AAErC,QAAM,aAAa,IAAI,cAAc,CAAC;AACtC,QAAM,WAAW,IAAI,sBAAsB,CAAC;AAC5C,QAAM,SAAS,aAAa,SAAS,UAAU,IAAI;AAEnD,QAAM,YAAmC,CAAC;AAE1C,aAAW,CAAC,aAAa,IAAI,KAAK,OAAO;AAAA,IACvC,QAAQ;AAAA,EACV,GAAG;AACD,UAAM,YAAY,WAAW,WAAW;AACxC,UAAM,cAAe,WAAW,eAA0B;AAE1D,UAAM,aAAa,QAAQ,OAAO;AAAA,MAChC,CAAC,MAA+B,EAAE,cAAc;AAAA,IAClD;AACA,UAAM,WAAY,YAAY,YAAuB;AACrD,UAAM,SAAU,YAAY,UAAqB;AAEjD,eAAW,SAAS,KAAK,QAAQ;AAC/B,YAAM,UAAU,MAAM;AACtB,UAAI,CAAC,Q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,cAAc,aAAa,MAAM,GAAG;AACtC,WAAO,cAAc,WAAW,MAAM;AAAA,EACxC;AAEA,MAAI,cAAc,MAAM,MAAM,GAAG;AAC/B,WAAO,cAAc,IAAI,MAAM;AAAA,EACjC;AAEA,SAAO;AACT;AAEA,eAAsB,kBACpB,YACA,QACyB;AACzB,QAAM,UAAU,sBAAsB,UAAU;AAChD,QAAM,MAAM,MAAM,SAAS,SAAS,MAAM;AAC1C,QAAM,SAAS,KAAK,MAAM,GAAG;AAC7B,QAAM,gBAAgB,oBAAoB,MAAM,MAAM;AAEtD,MAAI,OAAO,qBAAqB,aAAa;AAC7C,QAAM,WAAW,gBAAgB,eAAe,MAAM;AAEtD,MAAI,UAAU;AACZ,WAAO,wBAAwB,MAAM,QAAQ;AAAA,EAC/C;AAEA,QAAM,SAAS,oBAAoB,MAAM,IAAI;AAC7C,QAAM,YAAY,QAAQ,OAAO;AAEjC,SAAO,oBAAoB,QAAQ,WAAW;AAAA,IAC5C,WAAW,cAAc;AAAA,IACzB,YAAY,cAAc;AAAA,IAC1B,cAAc,cAAc;AAAA,IAC5B,oBAAoB,cAAc;AAAA,IAClC,cAAc,cAAc,UAAU;AAAA,IACtC,eAAe,cAAc,UAAU;AAAA,EACzC,CAAC;AACH;","names":[]}
@@ -2,7 +2,7 @@ import { z } from 'zod';
2
2
  export { b as buildGuardrailContext } from '../context-DKkamYX_.js';
3
3
 
4
4
  /**
5
- * Generator configuration — loads and validates agents.conf.yaml / agent-runtime.config.yaml
5
+ * Generator configuration — loads and validates agents.conf.yaml
6
6
  */
7
7
 
8
8
  declare const DEFAULT_CONFIG_PATH = "./agents.conf.yaml";
@@ -237,7 +237,6 @@ interface ResolvedConfig extends RuntimeConfig {
237
237
  environments?: ResolvedEnvironments;
238
238
  componentOverrides?: Record<string, ComponentOverride>;
239
239
  }
240
- declare function loadConfig(configPath: string): Promise<ResolvedConfig>;
241
240
  declare function loadProjectConfig(configPath: string, target?: string): Promise<ResolvedConfig>;
242
241
 
243
- export { type ComponentOverride, ComponentOverrideSchema, DEFAULT_CONFIG_PATH, type ProjectConfig, ProjectConfigSchema, type ResolvedConfig, type ResolvedEnvironments, loadConfig, loadProjectConfig };
242
+ export { type ComponentOverride, ComponentOverrideSchema, DEFAULT_CONFIG_PATH, type ProjectConfig, ProjectConfigSchema, type ResolvedConfig, type ResolvedEnvironments, loadProjectConfig };
@@ -3,15 +3,13 @@ import {
3
3
  DEFAULT_CONFIG_PATH,
4
4
  ProjectConfigSchema,
5
5
  buildGuardrailContext,
6
- loadConfig,
7
6
  loadProjectConfig
8
- } from "../chunk-5FL4NAC5.js";
7
+ } from "../chunk-E2UR4TNM.js";
9
8
  export {
10
9
  ComponentOverrideSchema,
11
10
  DEFAULT_CONFIG_PATH,
12
11
  ProjectConfigSchema,
13
12
  buildGuardrailContext,
14
- loadConfig,
15
13
  loadProjectConfig
16
14
  };
17
15
  //# sourceMappingURL=index.js.map
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { O as ObserverEmitFn, T as TaskContext, b as TaskOutcome, c as AgentContractLike, d as TaskContractLike, P as PromptBuilderOptions, W as WorkflowResult, S as SdkAdapter, e as WorkflowRegistries, H as HandoffInput, f as StepCompleteEvent, g as StepResult, D as DelegateStep, h as GuardrailRuleData, i as MemoryStore, M as MemoryRef, L as LibraryToolRegistry, G as GuardrailHooks, R as ResolvedComponent, j as ArtifactBindingConfig, k as TaskRunResult, l as ResolvedToolchain, m as LibraryToolDefinition } from './task-runner-C1hxIJTd.js';
2
- export { n as AdapterOrFactory, A as AdapterSendOptions, a as AgentExecutionRequest, o as AgentProgressEvent, B as BoundResolveOptions, p as BoundResolver, C as CacheConfig, q as CandidateAgent, r as ConvergenceEnvelope, s as ConvergenceEnvelopePayload, E as EnvelopeParams, t as EvaluateStep, u as GateStep, v as GuardrailCheckFunctions, w as GuardrailCheckResult, x as GuardrailRule, y as HookContext, z as HookResponse, I as InMemoryStore, F as ModelAwareSdkAdapterFactory, J as ModelClass, K as ModelMappingConfig, N as ModelResolver, Q as ModelResolverOptions, U as ReceiveSpec, V as ResolvedModel, X as RetryDecision, Y as SdkAdapterFactory, Z as SplitPrompt, _ as TaskRunOptions, $ as WorkflowContractLike, a0 as WorkflowInvocation, a1 as WorkflowRunOptions, a2 as WorkflowStep, a3 as buildCandidateAgents, a4 as buildGateEvaluationPrompt, a5 as buildPerAgentGuardrails, a6 as buildRetryFollowUp, a7 as buildSplitTaskPrompt, a8 as buildTaskPrompt, a9 as createExecutionEnvelope, aa as createGuardrailHooks, ab as createGuardrailHooksForAgent, ac as createGuardrailHooksFromRules, ad as createLibraryToolRegistry, ae as createModelResolver, af as deriveToolchainsForAgents, ag as emitSessionClose, ah as emitSessionOpen, ai as emitSubagentClose, aj as emitSubagentOpen, ak as emitToolchainClose, al as emitToolchainOpen, am as extractStructuredResult, an as getBlockingViolations, ao as getEffectiveGuardrailIds, ap as getGuardrailRulesForAgent, aq as getWarnings, ar as guardrailContextToRuleData, as as hasBlockingViolation, at as parseGateEvaluationResponse, au as renderAgentSystemPrompt, av as runTask, aw as runWorkflow, ax as zodSchemaToPromptDescription, ay as zodSchemaToYamlExample } from './task-runner-C1hxIJTd.js';
1
+ import { O as ObserverEmitFn, T as TaskContext, b as TaskOutcome, c as AgentContractLike, d as TaskContractLike, P as PromptBuilderOptions, W as WorkflowResult, S as SdkAdapter, e as WorkflowRegistries, H as HandoffInput, f as StepCompleteEvent, g as StepResult, D as DelegateStep, h as GuardrailRuleData, i as MemoryStore, M as MemoryRef, L as LibraryToolRegistry, G as GuardrailHooks, R as ResolvedComponent, j as ArtifactBindingConfig, k as TaskRunResult, l as ResolvedToolchain, m as LibraryToolDefinition, n as HookResponse, o as GuardrailCheckResult } from './task-runner-BPk-PcZA.js';
2
+ export { p as AdapterOrFactory, A as AdapterSendOptions, a as AgentExecutionRequest, q as AgentProgressEvent, B as BoundResolveOptions, r as BoundResolver, C as CacheConfig, s as CandidateAgent, t as ConvergenceEnvelope, u as ConvergenceEnvelopePayload, E as EnvelopeParams, v as EvaluateStep, w as GateStep, x as GuardrailCheckFunctions, y as GuardrailRule, z as HookContext, I as InMemoryStore, F as ModelAwareSdkAdapterFactory, J as ModelClass, K as ModelMappingConfig, N as ModelResolver, Q as ModelResolverOptions, U as ReceiveSpec, V as ResolvedModel, X as RetryDecision, Y as SdkAdapterFactory, Z as SplitPrompt, _ as TaskRunOptions, $ as WorkflowContractLike, a0 as WorkflowInvocation, a1 as WorkflowRunOptions, a2 as WorkflowStep, a3 as buildCandidateAgents, a4 as buildGateEvaluationPrompt, a5 as buildPerAgentGuardrails, a6 as buildRetryFollowUp, a7 as buildSplitTaskPrompt, a8 as buildTaskPrompt, a9 as createExecutionEnvelope, aa as createGuardrailHooks, ab as createGuardrailHooksForAgent, ac as createGuardrailHooksFromRules, ad as createLibraryToolRegistry, ae as createModelResolver, af as deriveToolchainsForAgents, ag as emitSessionClose, ah as emitSessionOpen, ai as emitSubagentClose, aj as emitSubagentOpen, ak as emitToolchainClose, al as emitToolchainOpen, am as extractStructuredResult, an as getBlockingViolations, ao as getEffectiveGuardrailIds, ap as getGuardrailRulesForAgent, aq as getWarnings, ar as guardrailContextToRuleData, as as hasBlockingViolation, at as parseGateEvaluationResponse, au as renderAgentSystemPrompt, av as runTask, aw as runWorkflow, ax as zodSchemaToPromptDescription, ay as zodSchemaToYamlExample } from './task-runner-BPk-PcZA.js';
3
3
  import { z } from 'zod';
4
4
  import { OperationIR, ComponentIR } from '@aaac/contracts';
5
5
  import { ResolvedConfig } from './generator/index.js';
@@ -177,7 +177,7 @@ declare class WorkflowBuilder {
177
177
  * Plugin Loader — auto-discovers and registers user plugin files
178
178
  *
179
179
  * Discovery strategies (in priority order):
180
- * 1. Config-based: `plugins` array in agent-runtime.config.yaml
180
+ * 1. Config-based: `plugins` array in agents.conf.yaml
181
181
  * 2. Convention-based: scan `src/plugins/` for files exporting AgentPlugin
182
182
  *
183
183
  * Each discovered module is dynamically import()'d. Exports that satisfy the
@@ -651,6 +651,100 @@ interface ArtifactResolveResult {
651
651
  }
652
652
  declare function resolveArtifacts(options: ArtifactResolveOptions): Promise<ArtifactResolveResult>;
653
653
 
654
+ /**
655
+ * Guard CLI commands — evaluate/list/status for guardrail enforcement.
656
+ *
657
+ * These functions back the `guard evaluate`, `guard list`, and `guard status`
658
+ * sub-commands that are auto-injected by @aaac/contracts cli-generator
659
+ * whenever `governance.guardrails: true` is declared in component.yaml.
660
+ *
661
+ * exit code contract (evaluate):
662
+ * 0 = allowed / pass / warn
663
+ * 2 = denied (permission === "deny")
664
+ */
665
+
666
+ interface EvaluateGuardrailOptions {
667
+ /** Raw JSON string read from stdin (HookContext format). */
668
+ hookJson: string;
669
+ /** Component agent-contracts DSL (contains guardrails + guardrail_policies). */
670
+ dsl: Record<string, unknown>;
671
+ /** Paths to software binding YAML files (contain guardrail_impl matchers). */
672
+ bindingPaths: string[];
673
+ /** Active guardrail policy name (from project.yaml active_guardrail_policy). */
674
+ activeGuardrailPolicy?: string;
675
+ }
676
+ interface EvaluateGuardrailResult {
677
+ /** HookResponse to write to stdout. */
678
+ response: HookResponse;
679
+ /**
680
+ * CLI exit code.
681
+ * 0 = allowed (pass or warn)
682
+ * 2 = denied (permission === "deny")
683
+ */
684
+ exitCode: 0 | 2;
685
+ /** All check results from all matchers. */
686
+ checks: GuardrailCheckResult[];
687
+ }
688
+ /**
689
+ * Evaluate a guardrail hook from a JSON string (typically stdin).
690
+ *
691
+ * Detects the hook type from which fields are present in the input:
692
+ * - `command` → beforeShellExecution
693
+ * - `tool_name` / `tool_input` → preToolUse
694
+ * - `file_path` (without command) → afterFileEdit
695
+ */
696
+ declare function evaluateGuardrail(opts: EvaluateGuardrailOptions): Promise<EvaluateGuardrailResult>;
697
+ interface ListGuardrailsOptions {
698
+ /** Component agent-contracts DSL. */
699
+ dsl: Record<string, unknown>;
700
+ /** Paths to software binding YAML files. */
701
+ bindingPaths: string[];
702
+ /** Active guardrail policy name. */
703
+ activeGuardrailPolicy?: string;
704
+ }
705
+ interface GuardrailListEntry {
706
+ guardrail_id: string;
707
+ description: string;
708
+ matcher_type: string;
709
+ action: string;
710
+ severity: string;
711
+ pattern: string;
712
+ }
713
+ interface ListGuardrailsResult {
714
+ policy: string | undefined;
715
+ entries: GuardrailListEntry[];
716
+ }
717
+ /**
718
+ * List all active guardrails and their enforcement settings.
719
+ *
720
+ * Reads DSL + binding files and builds the guardrail context for the active
721
+ * policy, returning a flat list of guardrail_id / matcher_type / action /
722
+ * severity rows for display.
723
+ */
724
+ declare function listGuardrails(opts: ListGuardrailsOptions): Promise<ListGuardrailsResult>;
725
+ interface GuardStatusOptions {
726
+ /** Base directory for agent logs (defaults to ".agent-logs"). */
727
+ baseDir?: string;
728
+ /** Maximum number of recent run events to return (defaults to 10). */
729
+ limit?: number;
730
+ }
731
+ interface GuardStatusResult {
732
+ hasHistory: boolean;
733
+ message: string;
734
+ /** Recent run log events (operation_start/end, etc.). */
735
+ recentEvents: unknown[];
736
+ }
737
+ /**
738
+ * Show recent guardrail evaluation summary.
739
+ *
740
+ * Phase 1 limitation: RunLogEvent does not yet include a `guardrail_evaluate`
741
+ * event type, so this command reports general run history from .agent-logs/runs/.
742
+ * Guard-specific event tracking will be added in a future phase.
743
+ *
744
+ * Gracefully returns "no evaluation history" when .agent-logs/ does not exist.
745
+ */
746
+ declare function guardStatus(opts?: GuardStatusOptions): Promise<GuardStatusResult>;
747
+
654
748
  /**
655
749
  * @aaac/runtime — public API
656
750
  *
@@ -659,4 +753,4 @@ declare function resolveArtifacts(options: ArtifactResolveOptions): Promise<Arti
659
753
  /** Package version string. */
660
754
  declare const version: string;
661
755
 
662
- export { type AaacInvocationContext, type AaacObserver, type AaacPolicy, type AaacRuntime, AgentContractLike, AgentLogWriter, type AgentLogWriterOptions, type AgentPlugin, ArtifactBindingConfig, type ArtifactResolveOptions, type ArtifactResolveResult, type ComponentScope, type CreateAdapterOptions, type CreateComponentScopeOptions, type CreateProjectRuntimeOptions, DelegateStep, type DslContext, DslValidationError, type ExecuteOptions, type ExecuteTaskOptions, type ExecuteWorkflowOptions, FileMemoryStore, GuardrailHooks, type GuardrailResult, GuardrailRuleData, HandoffInput, LibraryToolDefinition, LibraryToolRegistry, type LoadDslOptions, MemoryRef, MemoryStore, type MemoryStoreEntry, type NavigationContext, type NavigationContextOptions, ObserverEmitFn, type OperationHandler, type OperationMemoryRefConfig, PROJECT_CONFIG_FILENAME, type PermissionMode, type PluginLoadResult, PluginRegistry, type ProcessEditOptions, type ProcessTaskOptions, type ProcessWorkflowOptions, type ProgressSink, type ProgressSinkOptions, type ProjectRuntime, type PromptBuilderArgs, PromptBuilderOptions, type RequiredEntities, type ResolvedAdapterSelection, ResolvedComponent, ResolvedToolchain, type RunLogEvent, type Runtime, type RuntimeBinding, type RuntimeConfig, SdkAdapter, type SdkFunctionTool, StepCompleteEvent, StepResult, TaskContext, TaskContractLike, type TaskHookContext, TaskOutcome, TaskRunResult, WorkflowBuilder, type WorkflowHookContext, WorkflowRegistries, WorkflowResult, buildGuardrailRulesFromDsl, buildNavigationContext, buildRegistriesFromDsl, buildSdkFunctionTools, createAdapter, createComponentScope, createProgressSink, createProjectRuntime, createRuntime, createRuntimeBinding, emitProcessEdit, emitProcessTaskClose, emitProcessTaskOpen, emitProcessWorkflowClose, emitProcessWorkflowOpen, executeTask, executeWorkflow, findProjectConfig, jsonSchemaToZod, loadDslContext, loadPlugins, loadPluginsFromDirectory, loadPluginsFromPaths, pluginRegistry, resolveArtifacts, version };
756
+ export { type AaacInvocationContext, type AaacObserver, type AaacPolicy, type AaacRuntime, AgentContractLike, AgentLogWriter, type AgentLogWriterOptions, type AgentPlugin, ArtifactBindingConfig, type ArtifactResolveOptions, type ArtifactResolveResult, type ComponentScope, type CreateAdapterOptions, type CreateComponentScopeOptions, type CreateProjectRuntimeOptions, DelegateStep, type DslContext, DslValidationError, type EvaluateGuardrailOptions, type EvaluateGuardrailResult, type ExecuteOptions, type ExecuteTaskOptions, type ExecuteWorkflowOptions, FileMemoryStore, type GuardStatusOptions, type GuardStatusResult, GuardrailCheckResult, GuardrailHooks, type GuardrailListEntry, type GuardrailResult, GuardrailRuleData, HandoffInput, HookResponse, LibraryToolDefinition, LibraryToolRegistry, type ListGuardrailsOptions, type ListGuardrailsResult, type LoadDslOptions, MemoryRef, MemoryStore, type MemoryStoreEntry, type NavigationContext, type NavigationContextOptions, ObserverEmitFn, type OperationHandler, type OperationMemoryRefConfig, PROJECT_CONFIG_FILENAME, type PermissionMode, type PluginLoadResult, PluginRegistry, type ProcessEditOptions, type ProcessTaskOptions, type ProcessWorkflowOptions, type ProgressSink, type ProgressSinkOptions, type ProjectRuntime, type PromptBuilderArgs, PromptBuilderOptions, type RequiredEntities, type ResolvedAdapterSelection, ResolvedComponent, ResolvedToolchain, type RunLogEvent, type Runtime, type RuntimeBinding, type RuntimeConfig, SdkAdapter, type SdkFunctionTool, StepCompleteEvent, StepResult, TaskContext, TaskContractLike, type TaskHookContext, TaskOutcome, TaskRunResult, WorkflowBuilder, type WorkflowHookContext, WorkflowRegistries, WorkflowResult, buildGuardrailRulesFromDsl, buildNavigationContext, buildRegistriesFromDsl, buildSdkFunctionTools, createAdapter, createComponentScope, createProgressSink, createProjectRuntime, createRuntime, createRuntimeBinding, emitProcessEdit, emitProcessTaskClose, emitProcessTaskOpen, emitProcessWorkflowClose, emitProcessWorkflowOpen, evaluateGuardrail, executeTask, executeWorkflow, findProjectConfig, guardStatus, jsonSchemaToZod, listGuardrails, loadDslContext, loadPlugins, loadPluginsFromDirectory, loadPluginsFromPaths, pluginRegistry, resolveArtifacts, version };
package/dist/index.js CHANGED
@@ -14,7 +14,7 @@ import {
14
14
  import {
15
15
  buildGuardrailContext,
16
16
  loadProjectConfig
17
- } from "./chunk-5FL4NAC5.js";
17
+ } from "./chunk-E2UR4TNM.js";
18
18
  import {
19
19
  jsonSchemaToZod
20
20
  } from "./chunk-ET6TGQRT.js";
@@ -2906,6 +2906,158 @@ async function resolveArtifacts(options) {
2906
2906
  };
2907
2907
  }
2908
2908
 
2909
+ // src/lib/guard-commands.ts
2910
+ import { readFile as readFile6, readdir as readdir3 } from "fs/promises";
2911
+ import YAML4 from "yaml";
2912
+ async function evaluateGuardrail(opts) {
2913
+ let hookInput;
2914
+ try {
2915
+ hookInput = JSON.parse(opts.hookJson);
2916
+ } catch (cause) {
2917
+ throw new Error(
2918
+ `Invalid hook JSON: input must be valid JSON. ${cause.message}`
2919
+ );
2920
+ }
2921
+ let guardrailCtx = {
2922
+ commandChecks: [],
2923
+ fileChecks: [],
2924
+ contentChecks: [],
2925
+ allChecks: [],
2926
+ hasGuardrails: false
2927
+ };
2928
+ for (const bindingPath of opts.bindingPaths) {
2929
+ let raw;
2930
+ try {
2931
+ raw = await readFile6(bindingPath, "utf8");
2932
+ } catch (err) {
2933
+ const code = err.code;
2934
+ if (code === "ENOENT") continue;
2935
+ throw err;
2936
+ }
2937
+ const binding = YAML4.parse(raw);
2938
+ guardrailCtx = buildGuardrailContext(
2939
+ opts.dsl,
2940
+ binding,
2941
+ opts.activeGuardrailPolicy
2942
+ );
2943
+ }
2944
+ const ruleData = guardrailContextToRuleData(guardrailCtx);
2945
+ const hooks = createGuardrailHooksFromRules(ruleData);
2946
+ const command = hookInput.command;
2947
+ const toolName = hookInput.tool_name;
2948
+ const toolInput = hookInput.tool_input;
2949
+ const filePath = hookInput.file_path;
2950
+ const content = hookInput.content;
2951
+ let response = {};
2952
+ let checks = [];
2953
+ if (command !== void 0) {
2954
+ response = hooks.beforeShellExecution({ command });
2955
+ checks = hooks.runChecks({ command });
2956
+ } else if (toolName !== void 0 || toolInput !== void 0) {
2957
+ response = hooks.preToolUse({ tool_name: toolName, tool_input: toolInput });
2958
+ const checkFilePath = toolInput?.file_path ?? toolInput?.path ?? "";
2959
+ if (checkFilePath) {
2960
+ checks = hooks.runChecks({ filePath: checkFilePath });
2961
+ }
2962
+ } else if (filePath !== void 0) {
2963
+ response = hooks.afterFileEdit({ file_path: filePath, content });
2964
+ checks = hooks.runChecks({ filePath, content });
2965
+ }
2966
+ const exitCode = response.permission === "deny" ? 2 : 0;
2967
+ return { response, exitCode, checks };
2968
+ }
2969
+ async function listGuardrails(opts) {
2970
+ let guardrailCtx = {
2971
+ commandChecks: [],
2972
+ fileChecks: [],
2973
+ contentChecks: [],
2974
+ allChecks: [],
2975
+ hasGuardrails: false
2976
+ };
2977
+ for (const bindingPath of opts.bindingPaths) {
2978
+ let raw;
2979
+ try {
2980
+ raw = await readFile6(bindingPath, "utf8");
2981
+ } catch (err) {
2982
+ const code = err.code;
2983
+ if (code === "ENOENT") continue;
2984
+ throw err;
2985
+ }
2986
+ const binding = YAML4.parse(raw);
2987
+ guardrailCtx = buildGuardrailContext(
2988
+ opts.dsl,
2989
+ binding,
2990
+ opts.activeGuardrailPolicy
2991
+ );
2992
+ }
2993
+ const entries = guardrailCtx.allChecks.map(
2994
+ (c) => ({
2995
+ guardrail_id: c.guardrail_id,
2996
+ description: c.description,
2997
+ matcher_type: c.matcher_type,
2998
+ action: c.action,
2999
+ severity: c.severity,
3000
+ pattern: c.pattern
3001
+ })
3002
+ );
3003
+ return {
3004
+ policy: opts.activeGuardrailPolicy,
3005
+ entries
3006
+ };
3007
+ }
3008
+ async function guardStatus(opts = {}) {
3009
+ const baseDir = opts.baseDir ?? ".agent-logs";
3010
+ const runsDir = `${baseDir}/runs`;
3011
+ const limit = opts.limit ?? 10;
3012
+ let files = [];
3013
+ try {
3014
+ files = await readdir3(runsDir);
3015
+ } catch (err) {
3016
+ const code = err.code;
3017
+ if (code === "ENOENT") {
3018
+ return {
3019
+ hasHistory: false,
3020
+ message: "No evaluation history. Note: guardrail_evaluate event type is not yet tracked in Phase 1.",
3021
+ recentEvents: []
3022
+ };
3023
+ }
3024
+ throw err;
3025
+ }
3026
+ const jsonlFiles = files.filter((f) => f.endsWith(".jsonl")).sort().reverse().slice(0, limit);
3027
+ if (jsonlFiles.length === 0) {
3028
+ return {
3029
+ hasHistory: false,
3030
+ message: "No evaluation history.",
3031
+ recentEvents: []
3032
+ };
3033
+ }
3034
+ const recentEvents = [];
3035
+ for (const file of jsonlFiles) {
3036
+ const filePath = `${runsDir}/${file}`;
3037
+ let raw;
3038
+ try {
3039
+ raw = await readFile6(filePath, "utf8");
3040
+ } catch {
3041
+ continue;
3042
+ }
3043
+ const events = raw.split("\n").filter((line) => line.trim().length > 0).map((line) => {
3044
+ try {
3045
+ return JSON.parse(line);
3046
+ } catch {
3047
+ return null;
3048
+ }
3049
+ }).filter(Boolean);
3050
+ recentEvents.push(...events);
3051
+ if (recentEvents.length >= limit) break;
3052
+ }
3053
+ const count = recentEvents.length;
3054
+ return {
3055
+ hasHistory: count > 0,
3056
+ message: count > 0 ? `${count} recent run event(s) found. Note: guardrail_evaluate events are not yet tracked in Phase 1.` : "No evaluation history.",
3057
+ recentEvents: recentEvents.slice(0, limit)
3058
+ };
3059
+ }
3060
+
2909
3061
  // src/index.ts
2910
3062
  var require2 = createRequire(import.meta.url);
2911
3063
  var pkg = require2("../package.json");
@@ -2953,6 +3105,7 @@ export {
2953
3105
  emitSubagentOpen,
2954
3106
  emitToolchainClose,
2955
3107
  emitToolchainOpen,
3108
+ evaluateGuardrail,
2956
3109
  executeTask,
2957
3110
  executeWorkflow,
2958
3111
  extractStructuredResult,
@@ -2961,9 +3114,11 @@ export {
2961
3114
  getEffectiveGuardrailIds,
2962
3115
  getGuardrailRulesForAgent,
2963
3116
  getWarnings,
3117
+ guardStatus,
2964
3118
  guardrailContextToRuleData,
2965
3119
  hasBlockingViolation,
2966
3120
  jsonSchemaToZod,
3121
+ listGuardrails,
2967
3122
  loadDslContext,
2968
3123
  loadPlugins,
2969
3124
  loadPluginsFromDirectory,