@aaac/contracts 0.1.1 → 0.1.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.
@@ -69,7 +69,7 @@ var ComponentSchema = z.object({
69
69
  }),
70
70
  implementation: z.string().optional(),
71
71
  projections: z.array(
72
- z.enum(["library", "cli", "mcp", "claude", "openai"])
72
+ z.enum(["library", "cli", "claude", "openai"])
73
73
  ),
74
74
  operations: z.record(z.string(), OperationSchema)
75
75
  }).superRefine((component, ctx) => {
@@ -975,96 +975,70 @@ function handlerImportPath(handlerPath, outputDir) {
975
975
  }
976
976
  return importPath.replace(/\.ts$/, ".js");
977
977
  }
978
- function dispatchBody(operationName, op, outputDir) {
979
- const names = operationTypeNames(operationName);
978
+ function serializeComponent(ir) {
979
+ const info = {
980
+ id: ir.info.id,
981
+ version: ir.info.version
982
+ };
983
+ if (ir.info.description) {
984
+ info.description = ir.info.description;
985
+ }
986
+ return JSON.stringify(
987
+ {
988
+ schema: ir.schema,
989
+ info,
990
+ projections: ir.projections,
991
+ operations: ir.operations
992
+ },
993
+ null,
994
+ 2
995
+ );
996
+ }
997
+ function buildHandlerImportsAndMap(ir, outputDir) {
980
998
  const imports = [];
981
- if (op.agentWorkflow) {
982
- return {
983
- imports,
984
- caseBody: ` ctx.policy?.assertAllowed(${JSON.stringify(operationName)});
985
- return ctx.runtime.runWorkflow(${JSON.stringify(op.agentWorkflow)}, {
986
- options,
987
- input,
988
- observer: ctx.observer,
989
- abortSignal: ctx.abortSignal,
990
- });`
991
- };
992
- }
993
- if (op.agentTask) {
994
- return {
995
- imports,
996
- caseBody: ` ctx.policy?.assertAllowed(${JSON.stringify(operationName)});
997
- return ctx.runtime.runTask(${JSON.stringify(op.agentTask)}, {
998
- options,
999
- input,
1000
- observer: ctx.observer,
1001
- abortSignal: ctx.abortSignal,
1002
- });`
1003
- };
1004
- }
1005
- if (op.handler) {
999
+ const handlersEntries = [];
1000
+ for (const [operationName, op] of Object.entries(ir.operations)) {
1001
+ if (!op.handler) {
1002
+ continue;
1003
+ }
1006
1004
  const importPath = handlerImportPath(op.handler, outputDir);
1005
+ const alias = `_handler_${operationName}`;
1007
1006
  imports.push(
1008
- `import { ${operationName} } from ${JSON.stringify(importPath)};`
1007
+ `import { ${operationName} as ${alias} } from ${JSON.stringify(importPath)};`
1008
+ );
1009
+ const names = operationTypeNames(operationName);
1010
+ handlersEntries.push(
1011
+ ` ${JSON.stringify(operationName)}: async (_options, input, _ctx) => ${alias}(input as ${names.input}),`
1009
1012
  );
1010
- return {
1011
- imports,
1012
- caseBody: ` ctx.policy?.assertAllowed(${JSON.stringify(operationName)});
1013
- return ${operationName}(input);`
1014
- };
1015
1013
  }
1016
- return {
1017
- imports,
1018
- caseBody: ` throw new Error("No dispatch target for operation ${operationName}");`
1019
- };
1014
+ return { imports, handlersEntries };
1020
1015
  }
1021
1016
  var runtimeGenerator = {
1022
1017
  generate(ir, options) {
1023
1018
  const componentConst = `${toPascalCase(ir.info.id)}Component`;
1024
- const allImports = [];
1025
- const cases = [];
1026
- for (const [operationName, op] of Object.entries(ir.operations)) {
1027
- const names = operationTypeNames(operationName);
1028
- const { imports, caseBody } = dispatchBody(
1029
- operationName,
1030
- op,
1031
- options.outputDir
1032
- );
1033
- allImports.push(...imports);
1034
- cases.push(` case ${JSON.stringify(operationName)}:
1035
- ${caseBody}
1036
- `);
1037
- }
1038
- const uniqueImports = [...new Set(allImports)];
1039
- const content = `/** Auto-generated by @aaac/contracts. Do not edit. */
1040
- /* eslint-disable */
1041
-
1042
- import { createRuntimeBinding } from "@aaac/runtime";
1043
- import type {
1019
+ const { imports: handlerImports, handlersEntries } = buildHandlerImportsAndMap(ir, options.outputDir);
1020
+ const hasHandlers = handlersEntries.length > 0;
1021
+ const bindingCall = hasHandlers ? `createRuntimeBinding(${componentConst} as any, {
1022
+ ${handlersEntries.join("\n")}
1023
+ })` : `createRuntimeBinding(${componentConst} as any)`;
1024
+ const typeImports = Object.keys(ir.operations).length > 0 ? `import type {
1044
1025
  ${Object.keys(ir.operations).flatMap((name) => {
1045
1026
  const n = operationTypeNames(name);
1046
1027
  return [` ${n.input},`, ` ${n.output},`, ` ${n.options},`];
1047
1028
  }).join("\n")}
1048
1029
  } from "./component.types.js";
1049
- ${uniqueImports.length > 0 ? `${uniqueImports.join("\n")}
1050
- ` : ""}
1051
- export interface AaacInvocationContext {
1052
- runtime: {
1053
- runWorkflow(workflowId: string, args: unknown): Promise<unknown>;
1054
- runTask(taskId: string, args: unknown): Promise<unknown>;
1055
- };
1056
- policy?: {
1057
- assertAllowed(operationName: string): void;
1058
- };
1059
- observer?: unknown;
1060
- abortSignal?: AbortSignal;
1061
- }
1030
+ ` : `import type {} from "./component.types.js";
1031
+ `;
1032
+ const content = `/** Auto-generated by @aaac/contracts. Do not edit. */
1033
+ /* eslint-disable */
1062
1034
 
1063
- const ${componentConst} = ${JSON.stringify(
1064
- { id: ir.info.id, version: ir.info.version },
1065
- null,
1066
- 2
1067
- )} as const;
1035
+ import {
1036
+ createRuntimeBinding,
1037
+ type AaacInvocationContext,
1038
+ } from "@aaac/runtime";
1039
+ ${typeImports}${handlerImports.length > 0 ? `${handlerImports.join("\n")}
1040
+ ` : ""}
1041
+ const ${componentConst} = ${serializeComponent(ir)};
1068
1042
 
1069
1043
  function applyMemoryRef(
1070
1044
  ctx: AaacInvocationContext,
@@ -1084,22 +1058,9 @@ function applyMemoryRef(
1084
1058
  };
1085
1059
  }
1086
1060
 
1087
- async function dispatchExecute(
1088
- operationName: string,
1089
- options: Record<string, unknown>,
1090
- input: unknown,
1091
- ctx: AaacInvocationContext,
1092
- ): Promise<unknown> {
1093
- switch (operationName) {
1094
- ${cases.join("")}
1095
- default:
1096
- throw new Error(\`Unknown operation: \${operationName}\`);
1097
- }
1098
- }
1061
+ const _binding = ${bindingCall};
1099
1062
 
1100
- const _binding = createRuntimeBinding(${componentConst}, {
1101
- execute: dispatchExecute,
1102
- });
1063
+ export { type AaacInvocationContext };
1103
1064
 
1104
1065
  export const runtime = {
1105
1066
  getOperationNames(): string[] {
@@ -1284,4 +1245,4 @@ export {
1284
1245
  generateAll,
1285
1246
  writeGeneratedFiles
1286
1247
  };
1287
- //# sourceMappingURL=chunk-B7OY3RPU.js.map
1248
+ //# sourceMappingURL=chunk-QUUQF3XX.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/schema.ts","../src/parser.ts","../src/errors.ts","../src/ref-resolver.ts","../src/validation.ts","../src/compiler.ts","../src/generators/cli-generator.ts","../src/generators/schema-to-ts.ts","../src/generators/client-generator.ts","../src/generators/handler-generator.ts","../src/generators/runtime-generator.ts","../src/generators/types-generator.ts","../src/generators/index.ts"],"sourcesContent":["import { z } from \"zod\";\n\n/** Supported AaaC schema versions (compiler accepts only these). */\nexport const SUPPORTED_SCHEMA_VERSIONS = [\"aaac/0.1\"] as const;\n\n/** Pattern for schema version field: `aaac/x.y` */\nexport const SCHEMA_VERSION_PATTERN = /^aaac\\/\\d+\\.\\d+$/;\n\nexport const JSONSchemaRefSchema = z.union([\n z.object({ schema: z.record(z.string(), z.unknown()) }),\n z.object({ $ref: z.string() }),\n]);\n\nexport const OptionSchema = z.object({\n name: z.string().min(1),\n schema: z.record(z.string(), z.unknown()),\n required: z.boolean().optional(),\n description: z.string().optional(),\n});\n\nexport const ArtifactSlotValueSchema = z.union([\n z.string(),\n z.object({\n artifact: z.string(),\n direction: z.enum([\"read\", \"write\", \"readwrite\"]),\n }),\n]);\n\nexport const OperationSchema = z\n .object({\n description: z.string().min(1),\n agentWorkflow: z.string().optional(),\n agentTask: z.string().optional(),\n handler: z.string().optional(),\n options: z.array(OptionSchema).optional(),\n input: JSONSchemaRefSchema.optional(),\n output: z.object({\n success: JSONSchemaRefSchema,\n failed: JSONSchemaRefSchema.optional(),\n }),\n artifactSlots: z.record(z.string(), ArtifactSlotValueSchema).optional(),\n riskLevel: z.enum([\"low\", \"medium\", \"high\"]).optional(),\n idempotent: z.boolean().optional(),\n requiresConfirmation: z.boolean().optional(),\n execution: z\n .object({\n timeoutMs: z.number().optional(),\n costCeilingUsd: z.number().optional(),\n })\n .optional(),\n memoryRef: z\n .object({\n input: z.boolean().optional(),\n output: z.boolean().optional(),\n })\n .optional(),\n })\n .superRefine((op, ctx) => {\n const dispatchCount = [op.agentWorkflow, op.agentTask, op.handler].filter(\n (v) => v !== undefined,\n ).length;\n\n if (dispatchCount === 0) {\n ctx.addIssue({\n code: \"custom\",\n message:\n \"Exactly one of agentWorkflow, agentTask, or handler must be specified\",\n path: [\"agentWorkflow\"],\n });\n } else if (dispatchCount > 1) {\n ctx.addIssue({\n code: \"custom\",\n message:\n \"Only one of agentWorkflow, agentTask, or handler may be specified\",\n path: [\"agentWorkflow\"],\n });\n }\n });\n\nexport const ComponentSchema = z\n .object({\n schema: z\n .string()\n .regex(SCHEMA_VERSION_PATTERN, 'schema must match pattern \"aaac/x.y\"'),\n info: z.object({\n id: z.string().min(1),\n version: z.string().min(1),\n description: z.string().optional(),\n }),\n implementation: z.string().optional(),\n projections: z.array(\n z.enum([\"library\", \"cli\", \"claude\", \"openai\"]),\n ),\n operations: z.record(z.string(), OperationSchema),\n })\n .superRefine((component, ctx) => {\n const usesAgentic = Object.values(component.operations).some(\n (op) => op.agentWorkflow !== undefined || op.agentTask !== undefined,\n );\n\n if (usesAgentic && !component.implementation) {\n ctx.addIssue({\n code: \"custom\",\n message:\n \"implementation is required when any operation uses agentWorkflow or agentTask\",\n path: [\"implementation\"],\n });\n }\n });\n\nexport type ComponentDSL = z.infer<typeof ComponentSchema>;\nexport type OperationDSL = z.infer<typeof OperationSchema>;\nexport type OptionDSL = z.infer<typeof OptionSchema>;\nexport type JSONSchemaRefDSL = z.infer<typeof JSONSchemaRefSchema>;\n","import { readFile } from \"node:fs/promises\";\nimport { parse as parseYaml } from \"yaml\";\nimport { ZodError } from \"zod\";\nimport { ComponentSchema, type ComponentDSL } from \"./schema.js\";\n\nexport class ComponentParseError extends Error {\n constructor(\n message: string,\n public readonly filePath?: string,\n public readonly cause?: unknown,\n ) {\n super(filePath ? `${filePath}: ${message}` : message);\n this.name = \"ComponentParseError\";\n }\n}\n\nfunction formatZodError(error: ZodError, filePath?: string): string {\n const prefix = filePath ? `${filePath}: ` : \"\";\n const details = error.issues\n .map((issue) => {\n const path = issue.path.length > 0 ? issue.path.join(\".\") : \"(root)\";\n return `${path}: ${issue.message}`;\n })\n .join(\"; \");\n return `${prefix}Validation failed: ${details}`;\n}\n\nfunction normalizeOperation(\n op: Record<string, unknown>,\n): Record<string, unknown> {\n return {\n description: op.description,\n agentWorkflow: op.agentWorkflow ?? op.agent_workflow,\n agentTask: op.agentTask ?? op.agent_task,\n handler: op.handler,\n options: op.options,\n input: op.input,\n output: op.output,\n artifactSlots: op.artifactSlots ?? op.artifact_slots,\n riskLevel: op.riskLevel ?? op.risk_level,\n idempotent: op.idempotent,\n requiresConfirmation: op.requiresConfirmation ?? op.requires_confirmation,\n execution: op.execution,\n memoryRef: op.memoryRef ?? op.memory_ref,\n };\n}\n\nfunction normalizeComponent(\n raw: Record<string, unknown>,\n): Record<string, unknown> {\n const operations = raw.operations;\n const normalizedOps: Record<string, unknown> = {};\n\n if (operations && typeof operations === \"object\" && !Array.isArray(operations)) {\n for (const [name, op] of Object.entries(operations)) {\n if (op && typeof op === \"object\" && !Array.isArray(op)) {\n normalizedOps[name] = normalizeOperation(op as Record<string, unknown>);\n } else {\n normalizedOps[name] = op;\n }\n }\n }\n\n return {\n schema: raw.schema,\n info: raw.info,\n implementation: raw.implementation,\n projections: raw.projections,\n operations:\n Object.keys(normalizedOps).length > 0 ? normalizedOps : raw.operations,\n };\n}\n\nfunction validateComponent(raw: unknown, filePath?: string): ComponentDSL {\n const normalized =\n raw && typeof raw === \"object\" && !Array.isArray(raw)\n ? normalizeComponent(raw as Record<string, unknown>)\n : raw;\n\n const result = ComponentSchema.safeParse(normalized);\n if (!result.success) {\n throw new ComponentParseError(\n formatZodError(result.error, filePath),\n filePath,\n result.error,\n );\n }\n return result.data;\n}\n\n/**\n * Parse and validate a component YAML string.\n * When `filePath` is provided, `$ref` pointers resolve relative to its directory.\n */\nexport function parseComponentString(\n content: string,\n filePath?: string,\n): ComponentDSL {\n let raw: unknown;\n try {\n raw = parseYaml(content);\n } catch (err) {\n throw new ComponentParseError(\n `Invalid YAML: ${(err as Error).message}`,\n filePath,\n err,\n );\n }\n\n return validateComponent(raw, filePath);\n}\n\n/**\n * Read a component YAML file, resolve `$ref` pointers, and validate.\n */\nexport async function parseComponentFile(\n filePath: string,\n): Promise<ComponentDSL> {\n let content: string;\n try {\n content = await readFile(filePath, \"utf-8\");\n } catch (err) {\n throw new ComponentParseError(\n `Cannot read file: ${(err as Error).message}`,\n filePath,\n err,\n );\n }\n return parseComponentString(content, filePath);\n}\n","export class ComponentCompileError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"ComponentCompileError\";\n }\n}\n\nexport class ComponentValidationError extends ComponentCompileError {\n constructor(message: string) {\n super(message);\n this.name = \"ComponentValidationError\";\n }\n}\n","import { readFileSync } from \"node:fs\";\nimport { resolve, dirname, extname } from \"node:path\";\nimport { parse as parseYaml } from \"yaml\";\n\nexport class RefResolutionError extends Error {\n constructor(\n public readonly ref: string,\n message: string,\n ) {\n super(`Cannot resolve $ref \"${ref}\": ${message}`);\n this.name = \"RefResolutionError\";\n }\n}\n\nexport interface ResolveRefsOptions {\n basePath?: string;\n}\n\nfunction loadFile(filePath: string, fileCache: Map<string, unknown>): unknown {\n const absPath = resolve(filePath);\n const cached = fileCache.get(absPath);\n if (cached !== undefined) {\n return cached;\n }\n\n try {\n const content = readFileSync(absPath, \"utf-8\");\n const ext = extname(absPath).toLowerCase();\n const parsed =\n ext === \".json\" ? (JSON.parse(content) as unknown) : parseYaml(content);\n fileCache.set(absPath, parsed);\n return parsed;\n } catch (err) {\n throw new RefResolutionError(\n filePath,\n `Cannot read external file: ${(err as Error).message}`,\n );\n }\n}\n\nfunction resolveJsonPointer(root: unknown, pointer: string): unknown {\n const segments = pointer\n .split(\"/\")\n .filter((s) => s.length > 0)\n .map((s) => s.replace(/~1/g, \"/\").replace(/~0/g, \"~\"));\n\n let current: unknown = root;\n for (const segment of segments) {\n if (current === null || current === undefined || typeof current !== \"object\") {\n throw new RefResolutionError(\n `#${pointer}`,\n `Cannot traverse into non-object at \"${segment}\"`,\n );\n }\n const obj = current as Record<string, unknown>;\n if (!(segment in obj)) {\n throw new RefResolutionError(`#${pointer}`, `Key \"${segment}\" not found`);\n }\n current = obj[segment];\n }\n return current;\n}\n\nfunction resolveExternalRef(\n ref: string,\n basePath: string,\n fileCache: Map<string, unknown>,\n): unknown {\n const hashIndex = ref.indexOf(\"#/\");\n const filePart = hashIndex >= 0 ? ref.slice(0, hashIndex) : ref;\n const pointer = hashIndex >= 0 ? ref.slice(hashIndex + 1) : null;\n\n const absFilePath = resolve(basePath, filePart);\n const externalDoc = loadFile(absFilePath, fileCache);\n\n if (pointer) {\n return resolveJsonPointer(externalDoc, pointer);\n }\n return externalDoc;\n}\n\n/**\n * Resolves `$ref` pointers within a value tree.\n *\n * - Internal refs (`#/path/to/key`) resolve against `root`.\n * - External file refs (`./path/file.yaml` or `./file.yaml#/pointer`) resolve\n * relative to `basePath`.\n */\nexport function resolveRefs<T>(\n value: T,\n options: ResolveRefsOptions = {},\n): T {\n const resolved = new Set<string>();\n const fileCache = new Map<string, unknown>();\n const basePath = options.basePath ?? process.cwd();\n return deepResolve(value, value, resolved, basePath, fileCache) as T;\n}\n\nfunction deepResolve(\n value: unknown,\n root: unknown,\n resolved: Set<string>,\n basePath: string,\n fileCache: Map<string, unknown>,\n): unknown {\n if (value === null || value === undefined) {\n return value;\n }\n if (typeof value !== \"object\") {\n return value;\n }\n\n if (Array.isArray(value)) {\n return value.map((item) =>\n deepResolve(item, root, resolved, basePath, fileCache),\n );\n }\n\n const obj = value as Record<string, unknown>;\n\n if (\"$ref\" in obj && typeof obj[\"$ref\"] === \"string\") {\n const ref = obj[\"$ref\"] as string;\n\n if (ref.startsWith(\"#/\")) {\n if (resolved.has(ref)) {\n throw new RefResolutionError(ref, \"Circular reference detected\");\n }\n resolved.add(ref);\n const pointer = ref.slice(1);\n const target = resolveJsonPointer(root, pointer);\n const result = deepResolve(target, root, resolved, basePath, fileCache);\n resolved.delete(ref);\n return result;\n }\n\n if (resolved.has(ref)) {\n throw new RefResolutionError(ref, \"Circular reference detected\");\n }\n resolved.add(ref);\n\n const target = resolveExternalRef(ref, basePath, fileCache);\n const hashIndex = ref.indexOf(\"#/\");\n const externalBasePath =\n hashIndex >= 0 ? dirname(resolve(basePath, ref.slice(0, hashIndex))) : dirname(resolve(basePath, ref));\n\n const externalResolved = new Set<string>();\n const result = deepResolve(\n target,\n target,\n externalResolved,\n externalBasePath,\n fileCache,\n );\n resolved.delete(ref);\n return result;\n }\n\n const result: Record<string, unknown> = {};\n for (const [key, val] of Object.entries(obj)) {\n result[key] = deepResolve(val, root, resolved, basePath, fileCache);\n }\n return result;\n}\n","import { access, readFile } from \"node:fs/promises\";\nimport { resolve } from \"node:path\";\nimport { parse as parseYaml } from \"yaml\";\nimport type { ComponentIR } from \"./ir.js\";\nimport { ComponentValidationError } from \"./errors.js\";\n\nexport { ComponentValidationError };\n\nexport interface ValidationOptions {\n /** Base directory for resolving relative implementation paths. */\n basePath: string;\n}\n\nexport interface ImplementationIds {\n workflowIds: string[];\n taskIds: string[];\n}\n\nfunction extractIdsFromSection(section: unknown): string[] {\n if (!section || typeof section !== \"object\" || Array.isArray(section)) {\n return [];\n }\n\n return Object.keys(section as Record<string, unknown>).filter(\n (key) => key.length > 0,\n );\n}\n\n/**\n * Extract workflow and task IDs from a parsed agent-contracts DSL document.\n *\n * Looks for top-level `workflows` / `tasks` keys (map of ID → definition).\n */\nexport function extractImplementationIds(content: unknown): ImplementationIds {\n if (!content || typeof content !== \"object\" || Array.isArray(content)) {\n return { workflowIds: [], taskIds: [] };\n }\n\n const doc = content as Record<string, unknown>;\n return {\n workflowIds: extractIdsFromSection(doc.workflows),\n taskIds: extractIdsFromSection(doc.tasks),\n };\n}\n\nasync function fileExists(absolutePath: string): Promise<boolean> {\n try {\n await access(absolutePath);\n return true;\n } catch {\n return false;\n }\n}\n\nasync function loadImplementationIds(\n implementationPath: string,\n basePath: string,\n): Promise<ImplementationIds> {\n const absolutePath = resolve(basePath, implementationPath);\n\n if (!(await fileExists(absolutePath))) {\n throw new ComponentValidationError(\n `Implementation file not found: ${absolutePath}`,\n );\n }\n\n let content: string;\n try {\n content = await readFile(absolutePath, \"utf-8\");\n } catch (err) {\n throw new ComponentValidationError(\n `Cannot read implementation file ${absolutePath}: ${(err as Error).message}`,\n );\n }\n\n let parsed: unknown;\n try {\n parsed = parseYaml(content);\n } catch (err) {\n throw new ComponentValidationError(\n `Invalid YAML in implementation file ${absolutePath}: ${(err as Error).message}`,\n );\n }\n\n return extractImplementationIds(parsed);\n}\n\nfunction formatAvailableIds(label: string, ids: string[]): string {\n if (ids.length === 0) {\n return `${label}: (none)`;\n }\n return `${label}: ${ids.join(\", \")}`;\n}\n\n/**\n * Validate a compiled Component IR against its implementation DSL.\n *\n * Checks:\n * - implementation file exists (when specified)\n * - agentWorkflow IDs exist in implementation DSL\n * - agentTask IDs exist in implementation DSL\n */\nexport async function validateComponent(\n ir: ComponentIR,\n options: ValidationOptions,\n): Promise<void> {\n const usesAgentic = Object.values(ir.operations).some(\n (op) => op.agentWorkflow !== undefined || op.agentTask !== undefined,\n );\n\n if (!ir.implementation) {\n if (usesAgentic) {\n throw new ComponentValidationError(\n \"implementation is required when any operation uses agentWorkflow or agentTask\",\n );\n }\n return;\n }\n\n const ids = await loadImplementationIds(ir.implementation, options.basePath);\n\n for (const [operationName, op] of Object.entries(ir.operations)) {\n if (op.agentWorkflow !== undefined) {\n if (!ids.workflowIds.includes(op.agentWorkflow)) {\n throw new ComponentValidationError(\n `Operation \"${operationName}\": agentWorkflow \"${op.agentWorkflow}\" not found in implementation DSL. ${formatAvailableIds(\"Available workflows\", ids.workflowIds)}`,\n );\n }\n }\n\n if (op.agentTask !== undefined) {\n if (!ids.taskIds.includes(op.agentTask)) {\n throw new ComponentValidationError(\n `Operation \"${operationName}\": agentTask \"${op.agentTask}\" not found in implementation DSL. ${formatAvailableIds(\"Available tasks\", ids.taskIds)}`,\n );\n }\n }\n }\n}\n","import { dirname } from \"node:path\";\nimport { ComponentCompileError } from \"./errors.js\";\nimport type {\n ArtifactDirection,\n ComponentIR,\n JSONSchema,\n JSONSchemaRef,\n OperationIR,\n OptionIR,\n RiskLevel,\n} from \"./ir.js\";\nimport { parseComponentFile } from \"./parser.js\";\nimport { resolveRefs } from \"./ref-resolver.js\";\nimport {\n SUPPORTED_SCHEMA_VERSIONS,\n type ComponentDSL,\n type JSONSchemaRefDSL,\n type OperationDSL,\n type OptionDSL,\n} from \"./schema.js\";\nimport { validateComponent } from \"./validation.js\";\n\nexport { ComponentCompileError };\n\nfunction assertSupportedSchemaVersion(schema: string): void {\n if (\n !(SUPPORTED_SCHEMA_VERSIONS as readonly string[]).includes(schema)\n ) {\n throw new ComponentCompileError(\n `Unsupported schema version \"${schema}\". Supported: ${SUPPORTED_SCHEMA_VERSIONS.join(\", \")}`,\n );\n }\n}\n\nfunction toJSONSchemaRef(\n ref: JSONSchemaRefDSL,\n basePath?: string,\n): JSONSchemaRef {\n let value: unknown = ref;\n if (basePath) {\n value = resolveRefs(ref, { basePath });\n }\n\n if (value && typeof value === \"object\" && !Array.isArray(value)) {\n const obj = value as Record<string, unknown>;\n if (\"schema\" in obj && obj.schema && typeof obj.schema === \"object\") {\n return { schema: obj.schema as JSONSchema };\n }\n if (\"$ref\" in obj && typeof obj[\"$ref\"] === \"string\") {\n return { $ref: obj[\"$ref\"] };\n }\n return obj as JSONSchema;\n }\n return ref as JSONSchemaRef;\n}\n\nfunction normalizeArtifactSlots(\n slots: OperationDSL[\"artifactSlots\"],\n): OperationIR[\"artifactSlots\"] {\n if (!slots) {\n return {};\n }\n\n const result: OperationIR[\"artifactSlots\"] = {};\n for (const [slotName, value] of Object.entries(slots)) {\n if (typeof value === \"string\") {\n result[slotName] = { artifact: value, direction: \"readwrite\" };\n } else {\n result[slotName] = {\n artifact: value.artifact,\n direction: value.direction as ArtifactDirection,\n };\n }\n }\n return result;\n}\n\nfunction asSchemaObject(ref: JSONSchemaRef | undefined): JSONSchema | undefined {\n if (!ref) {\n return undefined;\n }\n if (\"schema\" in ref && ref.schema && typeof ref.schema === \"object\") {\n return ref.schema as JSONSchema;\n }\n if (!(\"$ref\" in ref)) {\n return ref as JSONSchema;\n }\n return undefined;\n}\n\n/**\n * Extract failure class names from a resolved failed output schema.\n *\n * Checks, in order:\n * 1. Top-level `failure_classes` array\n * 2. `properties.failure_class.enum`\n * 3. `oneOf` entries with `const` or `properties.failure_class.const`\n */\nexport function extractFailureClasses(\n failedRef: JSONSchemaRef | undefined,\n): string[] {\n const schema = asSchemaObject(failedRef);\n if (!schema) {\n return [];\n }\n\n const failureClasses = schema[\"failure_classes\"];\n if (Array.isArray(failureClasses)) {\n return failureClasses.filter((v): v is string => typeof v === \"string\");\n }\n\n const properties = schema[\"properties\"];\n if (properties && typeof properties === \"object\") {\n const failureClass = (properties as Record<string, unknown>)[\"failure_class\"];\n if (failureClass && typeof failureClass === \"object\") {\n const enumValues = (failureClass as Record<string, unknown>)[\"enum\"];\n if (Array.isArray(enumValues)) {\n return enumValues.filter((v): v is string => typeof v === \"string\");\n }\n }\n }\n\n const oneOf = schema[\"oneOf\"];\n if (Array.isArray(oneOf)) {\n const classes: string[] = [];\n for (const variant of oneOf) {\n if (!variant || typeof variant !== \"object\") {\n continue;\n }\n const obj = variant as Record<string, unknown>;\n if (typeof obj[\"const\"] === \"string\") {\n classes.push(obj[\"const\"]);\n continue;\n }\n const props = obj[\"properties\"];\n if (props && typeof props === \"object\") {\n const fc = (props as Record<string, unknown>)[\"failure_class\"];\n if (fc && typeof fc === \"object\") {\n const c = (fc as Record<string, unknown>)[\"const\"];\n if (typeof c === \"string\") {\n classes.push(c);\n }\n }\n }\n }\n if (classes.length > 0) {\n return classes;\n }\n }\n\n return [];\n}\n\nfunction compileOption(opt: OptionDSL): OptionIR {\n return {\n name: opt.name,\n schema: opt.schema,\n required: opt.required ?? false,\n description: opt.description,\n };\n}\n\nfunction compileOperation(op: OperationDSL, basePath?: string): OperationIR {\n const output = {\n success: toJSONSchemaRef(op.output.success, basePath),\n failed: op.output.failed\n ? toJSONSchemaRef(op.output.failed, basePath)\n : undefined,\n };\n\n return {\n description: op.description,\n agentWorkflow: op.agentWorkflow,\n agentTask: op.agentTask,\n handler: op.handler,\n options: (op.options ?? []).map(compileOption),\n input: op.input ? toJSONSchemaRef(op.input, basePath) : undefined,\n output,\n errorModel: {\n failureClasses: extractFailureClasses(output.failed),\n },\n artifactSlots: normalizeArtifactSlots(op.artifactSlots),\n riskLevel: (op.riskLevel ?? \"medium\") as RiskLevel,\n idempotent: op.idempotent ?? false,\n requiresConfirmation: op.requiresConfirmation ?? false,\n execution: {\n timeoutMs: op.execution?.timeoutMs,\n costCeilingUsd: op.execution?.costCeilingUsd,\n },\n memoryRef: op.memoryRef,\n };\n}\n\nexport interface CompileComponentOptions {\n basePath?: string;\n /** When true (default), validate implementation file and agent workflow/task IDs. */\n validate?: boolean;\n}\n\n/**\n * Compile a validated Component DSL into Component IR.\n */\nexport function compileComponent(\n dsl: ComponentDSL,\n options: CompileComponentOptions = {},\n): ComponentIR {\n assertSupportedSchemaVersion(dsl.schema);\n\n const operations: Record<string, OperationIR> = {};\n for (const [name, op] of Object.entries(dsl.operations)) {\n operations[name] = compileOperation(op, options.basePath);\n }\n\n return {\n schema: dsl.schema,\n info: {\n id: dsl.info.id,\n version: dsl.info.version,\n description: dsl.info.description,\n },\n implementation: dsl.implementation,\n projections: [...dsl.projections],\n operations,\n };\n}\n\nasync function maybeValidateComponent(\n ir: ComponentIR,\n options: CompileComponentOptions,\n): Promise<void> {\n if (options.validate === false) {\n return;\n }\n if (!options.basePath) {\n return;\n }\n await validateComponent(ir, { basePath: options.basePath });\n}\n\n/**\n * Compile a validated Component DSL into Component IR, optionally validating\n * implementation references.\n */\nexport async function compileComponentAsync(\n dsl: ComponentDSL,\n options: CompileComponentOptions = {},\n): Promise<ComponentIR> {\n const ir = compileComponent(dsl, options);\n await maybeValidateComponent(ir, options);\n return ir;\n}\n\n/**\n * Parse a component YAML file and compile it to IR.\n */\nexport async function compileComponentFile(\n filePath: string,\n options: Omit<CompileComponentOptions, \"basePath\"> = {},\n): Promise<ComponentIR> {\n const basePath = dirname(filePath);\n const dsl = await parseComponentFile(filePath);\n const ir = compileComponent(dsl, { ...options, basePath });\n await maybeValidateComponent(ir, { ...options, basePath });\n return ir;\n}\n","import { stringify as stringifyYaml } from \"yaml\";\nimport type { ComponentIR, JSONSchemaRef, OperationIR } from \"../ir.js\";\nimport type { GeneratedFile, GenerateOptions, Generator } from \"./types.js\";\n\nfunction unwrapSchema(ref: JSONSchemaRef | undefined): Record<string, unknown> | undefined {\n if (!ref) {\n return undefined;\n }\n if (\"schema\" in ref && ref.schema && typeof ref.schema === \"object\") {\n return ref.schema as Record<string, unknown>;\n }\n if (\"$ref\" in ref) {\n return { $ref: ref.$ref };\n }\n return ref as Record<string, unknown>;\n}\n\nfunction buildEffects(\n artifactSlots: OperationIR[\"artifactSlots\"],\n): { reads?: string[]; writes?: string[] } | undefined {\n const reads: string[] = [];\n const writes: string[] = [];\n\n for (const [slotName, slot] of Object.entries(artifactSlots)) {\n if (slot.direction === \"read\" || slot.direction === \"readwrite\") {\n reads.push(slotName);\n }\n if (slot.direction === \"write\" || slot.direction === \"readwrite\") {\n writes.push(slotName);\n }\n }\n\n if (reads.length === 0 && writes.length === 0) {\n return undefined;\n }\n\n const effects: { reads?: string[]; writes?: string[] } = {};\n if (reads.length > 0) {\n effects.reads = reads;\n }\n if (writes.length > 0) {\n effects.writes = writes;\n }\n return effects;\n}\n\nfunction buildExits(op: OperationIR): Record<string, Record<string, unknown>> {\n const exits: Record<string, Record<string, unknown>> = {\n \"0\": {\n description: \"Success\",\n },\n };\n\n const successSchema = unwrapSchema(op.output.success);\n if (successSchema) {\n exits[\"0\"].stdout = {\n format: \"json\",\n schema: successSchema,\n };\n }\n\n const failedSchema = unwrapSchema(op.output.failed);\n if (failedSchema) {\n const exitCode = op.errorModel.failureClasses.length > 0 ? \"1\" : \"1\";\n exits[exitCode] = {\n description: \"Operation failed\",\n stderr: {\n format: \"json\",\n schema: failedSchema,\n },\n };\n }\n\n for (let i = 0; i < op.errorModel.failureClasses.length; i++) {\n const code = String(i + 1);\n if (!exits[code]) {\n exits[code] = {\n description: `Failure: ${op.errorModel.failureClasses[i]}`,\n };\n if (failedSchema) {\n exits[code].stderr = {\n format: \"json\",\n schema: failedSchema,\n };\n }\n }\n }\n\n return exits;\n}\n\nfunction buildCommand(operationName: string, op: OperationIR): Record<string, unknown> {\n const command: Record<string, unknown> = {\n summary: op.description,\n };\n\n if (Object.keys(op.artifactSlots).length > 0) {\n const slots: Record<string, { direction: string }> = {};\n for (const [name, slot] of Object.entries(op.artifactSlots)) {\n slots[name] = { direction: slot.direction };\n }\n command.artifact_slots = slots;\n }\n\n if (op.options.length > 0) {\n command.options = op.options.map((opt) => {\n const entry: Record<string, unknown> = {\n name: opt.name,\n schema: opt.schema,\n };\n if (opt.description) {\n entry.description = opt.description;\n }\n if (opt.required) {\n entry.required = true;\n }\n return entry;\n });\n }\n\n const inputSchema = unwrapSchema(op.input);\n if (inputSchema) {\n command.streams = {\n stdin: { schema: inputSchema },\n };\n }\n\n command.exits = buildExits(op);\n\n const effects = buildEffects(op.artifactSlots);\n if (effects) {\n command.effects = effects;\n }\n\n const xAgent: Record<string, unknown> = {\n risk_level: op.riskLevel,\n requires_confirmation: op.requiresConfirmation,\n idempotent: op.idempotent,\n };\n if (op.agentWorkflow) {\n xAgent.dsl_workflow = op.agentWorkflow;\n }\n if (op.agentTask) {\n xAgent.dsl_task = op.agentTask;\n }\n if (op.execution.timeoutMs !== undefined) {\n xAgent.expected_duration_ms = op.execution.timeoutMs;\n }\n command[\"x-agent\"] = xAgent;\n\n return command;\n}\n\nfunction buildCliContract(ir: ComponentIR): Record<string, unknown> {\n const commands: Record<string, unknown> = {};\n for (const [name, op] of Object.entries(ir.operations)) {\n commands[name] = buildCommand(name, op);\n }\n\n return {\n cli_contracts: \"0.1.0\",\n info: {\n title: ir.info.id,\n version: ir.info.version,\n description: ir.info.description ?? `${ir.info.id} component CLI`,\n },\n command_sets: {\n [ir.info.id]: {\n summary: ir.info.description ?? ir.info.id,\n global_options: [\n {\n name: \"resume\",\n schema: { type: \"string\" },\n description: \"Resume from a previous memory_ref ID\",\n },\n ],\n commands,\n },\n },\n };\n}\n\nconst CLI_STUB_CONTENT = `extends: ./generated/cli-contract.generated.yaml\n`;\n\nexport const cliGenerator: Generator = {\n generate(ir: ComponentIR, _options: GenerateOptions): GeneratedFile[] {\n const contract = buildCliContract(ir);\n const yamlContent = `# Auto-generated by @aaac/contracts. Do not edit.\\n${stringifyYaml(contract)}`;\n\n const files: GeneratedFile[] = [\n {\n path: \"generated/cli-contract.generated.yaml\",\n content: yamlContent,\n overwrite: true,\n },\n ];\n\n if (ir.projections.includes(\"cli\")) {\n files.push({\n path: \"cli-contract.yaml\",\n content: CLI_STUB_CONTENT,\n overwrite: false,\n });\n }\n\n return files;\n },\n};\n","import type { JSONSchema, JSONSchemaRef } from \"../ir.js\";\n\nfunction unwrapSchema(ref: JSONSchemaRef | undefined): JSONSchema | undefined {\n if (!ref) {\n return undefined;\n }\n if (\"schema\" in ref && ref.schema && typeof ref.schema === \"object\") {\n return ref.schema as JSONSchema;\n }\n if (\"$ref\" in ref) {\n return undefined;\n }\n return ref as JSONSchema;\n}\n\nfunction isValidIdentifier(name: string): boolean {\n return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(name);\n}\n\nfunction quoteKey(name: string): string {\n return isValidIdentifier(name) ? name : JSON.stringify(name);\n}\n\nfunction schemaTypeName(\n schema: JSONSchema | undefined,\n fallback: string,\n): string {\n if (!schema) {\n return fallback;\n }\n const title = schema[\"title\"];\n if (typeof title === \"string\" && title.length > 0) {\n return title;\n }\n return fallback;\n}\n\n/**\n * Convert a kebab-case or snake_case name to PascalCase.\n */\nexport function toPascalCase(name: string): string {\n return name\n .split(/[-_]/)\n .filter((part) => part.length > 0)\n .map((part) => part.charAt(0).toUpperCase() + part.slice(1))\n .join(\"\");\n}\n\n/**\n * Convert a kebab-case or snake_case name to camelCase.\n */\nexport function toCamelCase(name: string): string {\n const pascal = toPascalCase(name);\n if (pascal.length === 0) {\n return name;\n }\n return pascal.charAt(0).toLowerCase() + pascal.slice(1);\n}\n\nfunction jsonSchemaToTs(\n schema: JSONSchema | undefined,\n indent: string,\n generated: Set<string>,\n): string {\n if (!schema) {\n return \"unknown\";\n }\n\n const enumValues = schema[\"enum\"];\n if (Array.isArray(enumValues) && enumValues.length > 0) {\n return enumValues\n .map((v) => (typeof v === \"string\" ? JSON.stringify(v) : String(v)))\n .join(\" | \");\n }\n\n const type = schema[\"type\"];\n if (type === \"string\") {\n return \"string\";\n }\n if (type === \"number\" || type === \"integer\") {\n return \"number\";\n }\n if (type === \"boolean\") {\n return \"boolean\";\n }\n if (type === \"array\") {\n const items = schema[\"items\"];\n if (items && typeof items === \"object\" && !Array.isArray(items)) {\n return `${jsonSchemaToTs(items as JSONSchema, indent, generated)}[]`;\n }\n return \"unknown[]\";\n }\n if (type === \"object\" || schema[\"properties\"]) {\n const properties = schema[\"properties\"];\n if (!properties || typeof properties !== \"object\") {\n return \"Record<string, unknown>\";\n }\n\n const required = Array.isArray(schema[\"required\"])\n ? (schema[\"required\"] as string[])\n : [];\n const lines: string[] = [];\n\n for (const [propName, propSchema] of Object.entries(\n properties as Record<string, unknown>,\n )) {\n if (!propSchema || typeof propSchema !== \"object\") {\n continue;\n }\n const optional = required.includes(propName) ? \"\" : \"?\";\n const tsType = jsonSchemaToTs(\n propSchema as JSONSchema,\n indent + \" \",\n generated,\n );\n lines.push(`${indent} ${quoteKey(propName)}${optional}: ${tsType};`);\n }\n\n if (lines.length === 0) {\n return \"Record<string, unknown>\";\n }\n return `{\\n${lines.join(\"\\n\")}\\n${indent}}`;\n }\n\n return \"unknown\";\n}\n\nexport function schemaRefToTsType(\n ref: JSONSchemaRef | undefined,\n fallback = \"unknown\",\n): string {\n return jsonSchemaToTs(unwrapSchema(ref), \"\", new Set()) || fallback;\n}\n\nexport function operationTypeNames(operationName: string): {\n input: string;\n output: string;\n options: string;\n failure: string;\n failureClass: string;\n} {\n const base = toPascalCase(operationName);\n return {\n input: `${base}Input`,\n output: `${base}Output`,\n options: `${base}Options`,\n failure: `${base}Failure`,\n failureClass: `${base}FailureClass`,\n };\n}\n\nexport function interfaceFromSchema(\n name: string,\n ref: JSONSchemaRef | undefined,\n fallbackBody: string,\n): string | undefined {\n const schema = unwrapSchema(ref);\n if (!schema) {\n return undefined;\n }\n\n const body = jsonSchemaToTs(schema, \"\", new Set());\n if (body === \"unknown\" && !schema[\"properties\"]) {\n return `export type ${name} = ${fallbackBody};\\n`;\n }\n if (body.startsWith(\"{\")) {\n return `export interface ${name} ${body}\\n`;\n }\n return `export type ${name} = ${body};\\n`;\n}\n\nexport { unwrapSchema, schemaTypeName };\n","import type { ComponentIR } from \"../ir.js\";\nimport type { GeneratedFile, GenerateOptions, Generator } from \"./types.js\";\nimport { operationTypeNames } from \"./schema-to-ts.js\";\n\nexport const clientGenerator: Generator = {\n generate(ir: ComponentIR, _options: GenerateOptions): GeneratedFile[] {\n const functions = Object.keys(ir.operations).map((operationName) => {\n const names = operationTypeNames(operationName);\n return `export async function ${operationName}(\n options: ${names.options},\n input: ${names.input},\n ctx: AaacInvocationContext,\n memoryRef?: string,\n): Promise<${names.output}> {\n return runtime.execute(${JSON.stringify(operationName)}, options, input, ctx, memoryRef);\n}`;\n });\n\n const content = `/** Auto-generated by @aaac/contracts. Do not edit. */\n/* eslint-disable */\n\nimport type {\n${Object.keys(ir.operations)\n .flatMap((name) => {\n const n = operationTypeNames(name);\n const types = [n.input, n.output, n.options];\n return types.map((t) => ` ${t},`);\n })\n .join(\"\\n\")}\n} from \"./component.types.js\";\nimport { runtime, type AaacInvocationContext } from \"./component.runtime.js\";\n\n${functions.join(\"\\n\\n\")}\n`;\n\n return [\n {\n path: \"generated/component.client.ts\",\n content,\n overwrite: true,\n },\n ];\n },\n};\n","import { existsSync } from \"node:fs\";\nimport { join, relative, dirname } from \"node:path\";\nimport type { ComponentIR } from \"../ir.js\";\nimport type { GeneratedFile, GenerateOptions, Generator } from \"./types.js\";\nimport { operationTypeNames } from \"./schema-to-ts.js\";\n\nfunction typesImportPath(handlerPath: string): string {\n const handlerDir = dirname(handlerPath);\n const rel = relative(handlerDir, \"generated/component.types\");\n const importPath = rel.startsWith(\".\") ? rel : `./${rel}`;\n return `${importPath}.js`;\n}\n\nfunction buildHandlerSkeleton(\n operationName: string,\n handlerPath: string,\n): string {\n const names = operationTypeNames(operationName);\n const typesImport = typesImportPath(handlerPath);\n\n return `/** Handler skeleton — implement the logic below. */\n/* eslint-disable */\n\nimport type { ${names.input}, ${names.output} } from \"${typesImport}\";\n\nexport async function ${operationName}(\n input: ${names.input},\n): Promise<${names.output}> {\n // TODO: implement\n throw new Error(\"Not implemented: ${operationName}\");\n}\n`;\n}\n\nexport const handlerGenerator: Generator = {\n generate(ir: ComponentIR, options: GenerateOptions): GeneratedFile[] {\n const files: GeneratedFile[] = [];\n\n for (const [operationName, op] of Object.entries(ir.operations)) {\n if (!op.handler) {\n continue;\n }\n\n const absPath = join(options.outputDir, op.handler);\n if (existsSync(absPath)) {\n files.push({\n path: op.handler,\n content: \"\",\n overwrite: false,\n warning: `Handler file already exists, skipping: ${op.handler}`,\n });\n continue;\n }\n\n files.push({\n path: op.handler,\n content: buildHandlerSkeleton(operationName, op.handler),\n overwrite: false,\n });\n }\n\n return files;\n },\n};\n","import { relative, dirname, join } from \"node:path\";\nimport type { ComponentIR } from \"../ir.js\";\nimport type { GeneratedFile, GenerateOptions, Generator } from \"./types.js\";\nimport { operationTypeNames, toPascalCase } from \"./schema-to-ts.js\";\n\nfunction handlerImportPath(\n handlerPath: string,\n outputDir: string,\n): string {\n const fromGenerated = join(outputDir, \"generated\", \"component.runtime.ts\");\n const absHandler = join(outputDir, handlerPath);\n let importPath = relative(dirname(fromGenerated), absHandler);\n if (!importPath.startsWith(\".\")) {\n importPath = `./${importPath}`;\n }\n return importPath.replace(/\\.ts$/, \".js\");\n}\n\nfunction serializeComponent(ir: ComponentIR): string {\n const info: Record<string, string> = {\n id: ir.info.id,\n version: ir.info.version,\n };\n if (ir.info.description) {\n info.description = ir.info.description;\n }\n\n return JSON.stringify(\n {\n schema: ir.schema,\n info,\n projections: ir.projections,\n operations: ir.operations,\n },\n null,\n 2,\n );\n}\n\nfunction buildHandlerImportsAndMap(\n ir: ComponentIR,\n outputDir: string,\n): { imports: string[]; handlersEntries: string[] } {\n const imports: string[] = [];\n const handlersEntries: string[] = [];\n\n for (const [operationName, op] of Object.entries(ir.operations)) {\n if (!op.handler) {\n continue;\n }\n\n const importPath = handlerImportPath(op.handler, outputDir);\n const alias = `_handler_${operationName}`;\n imports.push(\n `import { ${operationName} as ${alias} } from ${JSON.stringify(importPath)};`,\n );\n const names = operationTypeNames(operationName);\n handlersEntries.push(\n ` ${JSON.stringify(operationName)}: async (_options, input, _ctx) => ${alias}(input as ${names.input}),`,\n );\n }\n\n return { imports, handlersEntries };\n}\n\nexport const runtimeGenerator: Generator = {\n generate(ir: ComponentIR, options: GenerateOptions): GeneratedFile[] {\n const componentConst = `${toPascalCase(ir.info.id)}Component`;\n const { imports: handlerImports, handlersEntries } =\n buildHandlerImportsAndMap(ir, options.outputDir);\n\n const hasHandlers = handlersEntries.length > 0;\n const bindingCall = hasHandlers\n ? `createRuntimeBinding(${componentConst} as any, {\\n${handlersEntries.join(\"\\n\")}\\n})`\n : `createRuntimeBinding(${componentConst} as any)`;\n\n const typeImports =\n Object.keys(ir.operations).length > 0\n ? `import type {\n${Object.keys(ir.operations)\n .flatMap((name) => {\n const n = operationTypeNames(name);\n return [` ${n.input},`, ` ${n.output},`, ` ${n.options},`];\n })\n .join(\"\\n\")}\n} from \"./component.types.js\";\n`\n : `import type {} from \"./component.types.js\";\n`;\n\n const content = `/** Auto-generated by @aaac/contracts. Do not edit. */\n/* eslint-disable */\n\nimport {\n createRuntimeBinding,\n type AaacInvocationContext,\n} from \"@aaac/runtime\";\n${typeImports}${handlerImports.length > 0 ? `${handlerImports.join(\"\\n\")}\\n` : \"\"}\nconst ${componentConst} = ${serializeComponent(ir)};\n\nfunction applyMemoryRef(\n ctx: AaacInvocationContext,\n memoryRef?: string,\n): AaacInvocationContext {\n if (!memoryRef) {\n return ctx;\n }\n return {\n ...ctx,\n memoryRef: {\n id: memoryRef,\n provider: \"aaac\",\n compat: \"v1\",\n created_at: new Date().toISOString(),\n },\n };\n}\n\nconst _binding = ${bindingCall};\n\nexport { type AaacInvocationContext };\n\nexport const runtime = {\n getOperationNames(): string[] {\n return _binding.getOperationNames();\n },\n getOperationIR(name: string) {\n return _binding.getOperationIR(name);\n },\n execute(\n operationName: string,\n options: Record<string, unknown>,\n input: unknown,\n ctx: AaacInvocationContext,\n memoryRef?: string,\n ): Promise<unknown> {\n return _binding.execute(\n operationName,\n options,\n input,\n applyMemoryRef(ctx, memoryRef),\n );\n },\n};\n`;\n\n return [\n {\n path: \"generated/component.runtime.ts\",\n content,\n overwrite: true,\n },\n ];\n },\n};\n","import type { ComponentIR } from \"../ir.js\";\nimport type { GeneratedFile, GenerateOptions, Generator } from \"./types.js\";\nimport {\n interfaceFromSchema,\n operationTypeNames,\n schemaRefToTsType,\n} from \"./schema-to-ts.js\";\n\nfunction generateOperationTypes(\n operationName: string,\n op: ComponentIR[\"operations\"][string],\n): string {\n const names = operationTypeNames(operationName);\n const parts: string[] = [];\n\n if (op.input) {\n const iface = interfaceFromSchema(\n names.input,\n op.input,\n \"Record<string, unknown>\",\n );\n parts.push(iface ?? `export type ${names.input} = Record<string, unknown>;\\n`);\n } else {\n parts.push(`export type ${names.input} = Record<string, unknown>;\\n`);\n }\n\n const outputIface = interfaceFromSchema(\n names.output,\n op.output.success,\n \"unknown\",\n );\n parts.push(outputIface ?? `export type ${names.output} = unknown;\\n`);\n\n if (op.options.length > 0) {\n const fields = op.options.map((opt) => {\n const fieldName = opt.name.includes(\"-\") || opt.name.includes(\"_\")\n ? JSON.stringify(opt.name)\n : opt.name;\n const optional = opt.required ? \"\" : \"?\";\n const tsType = schemaRefToTsType({ schema: opt.schema });\n const desc = opt.description\n ? ` /** ${opt.description} */\\n`\n : \"\";\n return `${desc} ${fieldName}${optional}: ${tsType};`;\n });\n parts.push(`export interface ${names.options} {\\n${fields.join(\"\\n\")}\\n}\\n`);\n } else {\n parts.push(`export type ${names.options} = Record<string, never>;\\n`);\n }\n\n if (op.output.failed) {\n const failureIface = interfaceFromSchema(\n names.failure,\n op.output.failed,\n \"unknown\",\n );\n parts.push(failureIface ?? `export type ${names.failure} = unknown;\\n`);\n }\n\n if (op.errorModel.failureClasses.length > 0) {\n const union = op.errorModel.failureClasses\n .map((c) => JSON.stringify(c))\n .join(\" | \");\n parts.push(`export type ${names.failureClass} = ${union};\\n`);\n }\n\n return parts.join(\"\\n\");\n}\n\nexport const typesGenerator: Generator = {\n generate(ir: ComponentIR, _options: GenerateOptions): GeneratedFile[] {\n const operationBlocks = Object.entries(ir.operations).map(\n ([name, op]) => generateOperationTypes(name, op),\n );\n\n const content = `/** Auto-generated by @aaac/contracts. Do not edit. */\n/* eslint-disable */\n\n${operationBlocks.join(\"\\n\")}\n`;\n\n return [\n {\n path: \"generated/component.types.ts\",\n content,\n overwrite: true,\n },\n ];\n },\n};\n","import { mkdir, writeFile, access } from \"node:fs/promises\";\nimport { dirname, join } from \"node:path\";\nimport type { ComponentIR } from \"../ir.js\";\nimport { cliGenerator } from \"./cli-generator.js\";\nimport { clientGenerator } from \"./client-generator.js\";\nimport { handlerGenerator } from \"./handler-generator.js\";\nimport { runtimeGenerator } from \"./runtime-generator.js\";\nimport { typesGenerator } from \"./types-generator.js\";\nimport type { GeneratedFile, GenerateOptions, Generator } from \"./types.js\";\n\nexport type { GeneratedFile, GenerateOptions, Generator } from \"./types.js\";\nexport { typesGenerator } from \"./types-generator.js\";\nexport { clientGenerator } from \"./client-generator.js\";\nexport { runtimeGenerator } from \"./runtime-generator.js\";\nexport { cliGenerator } from \"./cli-generator.js\";\nexport { handlerGenerator } from \"./handler-generator.js\";\n\nconst ALL_GENERATORS: Generator[] = [\n typesGenerator,\n clientGenerator,\n runtimeGenerator,\n cliGenerator,\n handlerGenerator,\n];\n\n/**\n * Run all code generators for a compiled Component IR.\n */\nexport function generateAll(\n ir: ComponentIR,\n options: GenerateOptions,\n): GeneratedFile[] {\n return ALL_GENERATORS.flatMap((gen) => gen.generate(ir, options));\n}\n\nasync function fileExists(path: string): Promise<boolean> {\n try {\n await access(path);\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * Write generated files to disk, respecting overwrite policy.\n * - `overwrite: true` — always write (generated/ artifacts)\n * - `overwrite: false` — skip if target already exists (handlers, cli stub)\n */\nexport async function writeGeneratedFiles(\n files: GeneratedFile[],\n outputDir: string,\n): Promise<{ written: string[]; skipped: string[]; warnings: string[] }> {\n const written: string[] = [];\n const skipped: string[] = [];\n const warnings: string[] = [];\n\n for (const file of files) {\n const targetPath = join(outputDir, file.path);\n\n if (file.warning) {\n warnings.push(file.warning);\n }\n\n if (!file.overwrite && (await fileExists(targetPath))) {\n skipped.push(file.path);\n continue;\n }\n\n if (!file.content && !file.overwrite) {\n skipped.push(file.path);\n continue;\n }\n\n await mkdir(dirname(targetPath), { recursive: true });\n await writeFile(targetPath, file.content, \"utf-8\");\n written.push(file.path);\n }\n\n return { written, skipped, warnings };\n}\n"],"mappings":";AAAA,SAAS,SAAS;AAGX,IAAM,4BAA4B,CAAC,UAAU;AAG7C,IAAM,yBAAyB;AAE/B,IAAM,sBAAsB,EAAE,MAAM;AAAA,EACzC,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,OA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WAAAC,UAAS,QAAAC,aAAY;AAgB9B,IAAM,iBAA8B;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAKO,SAAS,YACd,IACA,SACiB;AACjB,SAAO,eAAe,QAAQ,CAAC,QAAQ,IAAI,SAAS,IAAI,OAAO,CAAC;AAClE;AAEA,eAAeC,YAAW,MAAgC;AACxD,MAAI;AACF,UAAMC,QAAO,IAAI;AACjB,WAAO;AAAA,EACT,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAOA,eAAsB,oBACpB,OACA,WACuE;AACvE,QAAM,UAAoB,CAAC;AAC3B,QAAM,UAAoB,CAAC;AAC3B,QAAM,WAAqB,CAAC;AAE5B,aAAW,QAAQ,OAAO;AACxB,UAAM,aAAaC,MAAK,WAAW,KAAK,IAAI;AAE5C,QAAI,KAAK,SAAS;AAChB,eAAS,KAAK,KAAK,OAAO;AAAA,IAC5B;AAEA,QAAI,CAAC,KAAK,aAAc,MAAMF,YAAW,UAAU,GAAI;AACrD,cAAQ,KAAK,KAAK,IAAI;AACtB;AAAA,IACF;AAEA,QAAI,CAAC,KAAK,WAAW,CAAC,KAAK,WAAW;AACpC,cAAQ,KAAK,KAAK,IAAI;AACtB;AAAA,IACF;AAEA,UAAM,MAAMG,SAAQ,UAAU,GAAG,EAAE,WAAW,KAAK,CAAC;AACpD,UAAM,UAAU,YAAY,KAAK,SAAS,OAAO;AACjD,YAAQ,KAAK,KAAK,IAAI;AAAA,EACxB;AAEA,SAAO,EAAE,SAAS,SAAS,SAAS;AACtC;","names":["parseYaml","target","result","readFile","resolve","parseYaml","resolve","readFile","parseYaml","validateComponent","dirname","validateComponent","dirname","unwrapSchema","unwrapSchema","dirname","dirname","relative","dirname","join","join","relative","dirname","access","dirname","join","fileExists","access","join","dirname"]}
package/dist/cli/index.js CHANGED
@@ -10,7 +10,7 @@ import {
10
10
  parseComponentFile,
11
11
  validateComponent,
12
12
  writeGeneratedFiles
13
- } from "../chunk-B7OY3RPU.js";
13
+ } from "../chunk-QUUQF3XX.js";
14
14
 
15
15
  // src/cli/index.ts
16
16
  import { readFileSync } from "fs";
@@ -3604,7 +3604,6 @@ var commandDefinitions = {
3604
3604
  "library",
3605
3605
  "cli",
3606
3606
  "runtime",
3607
- "mcp",
3608
3607
  "claude",
3609
3608
  "openai"
3610
3609
  ]
@@ -3668,8 +3667,8 @@ function deriveCommandPolicy(command_id, optionValues) {
3668
3667
  }
3669
3668
 
3670
3669
  // src/generated/contract.ts
3671
- var CONTRACT_YAML = "# yaml-language-server: $schema=./node_modules/cli-contracts/schemas/cli-contract.schema.json\ncli_contracts: 0.1.0\n\ninfo:\n title: AaaC CLI\n version: 0.1.0\n description: Agent as a Component \u2014 Contract compiler and code generator\n\ncommand_sets:\n aaac:\n summary: AaaC CLI \u2014 compile Component Contracts and generate adapters\n executable: aaac\n global_options:\n - name: verbose\n aliases: [v]\n schema: { type: boolean }\n description: Enable verbose output\n - name: quiet\n aliases: [q]\n schema: { type: boolean }\n description: Suppress non-essential output\n - name: resume\n schema: { type: string }\n description: Resume from a previous memory_ref ID\n commands:\n compile:\n summary: Compile a Component Contract YAML to Component IR\n arguments:\n - name: file\n required: true\n schema: { type: string }\n description: Path to the Component Contract YAML file\n options:\n - name: output\n aliases: [o]\n schema: { type: string }\n description: Output path for the compiled IR (JSON)\n exits:\n '0':\n description: Compilation succeeded\n stdout:\n format: json\n schema:\n type: object\n description: Component IR\n '1':\n description: Compilation failed (validation errors)\n stderr:\n format: text\n\n generate:\n summary: Generate adapters from a Component Contract\n arguments:\n - name: file\n required: true\n schema: { type: string }\n description: Path to the Component Contract YAML file\n options:\n - name: output-dir\n aliases: [o]\n schema: { type: string }\n description: Output directory for generated files\n - name: targets\n aliases: [t]\n schema:\n type: array\n items:\n type: string\n enum: [library, cli, runtime, mcp, claude, openai]\n description: Generation targets (defaults to projections in contract)\n - name: dry-run\n schema: { type: boolean }\n description: Show what would be generated without writing files\n effects:\n filesystem: read_write\n exits:\n '0':\n description: Generation succeeded\n stdout:\n format: text\n '1':\n description: Generation failed\n stderr:\n format: text\n\n validate:\n summary: Validate a Component Contract YAML\n arguments:\n - name: file\n required: true\n schema: { type: string }\n description: Path to the Component Contract YAML file\n options:\n - name: strict\n schema: { type: boolean }\n description: Enable strict validation (check implementation refs)\n exits:\n '0':\n description: Validation passed\n stdout:\n format: text\n '1':\n description: Validation failed\n stderr:\n format: text\n\n introspect:\n summary: Dump Component IR information\n arguments:\n - name: file\n required: true\n schema: { type: string }\n description: Path to the Component Contract YAML file\n options:\n - name: format\n aliases: [f]\n schema:\n type: string\n enum: [json, yaml]\n description: Output format (default yaml)\n exits:\n '0':\n description: Success\n stdout:\n format: json\n schema:\n type: object\n description: Component IR dump\n";
3672
- var CONTRACT_JSON_STR = '{\n "cli_contracts": "0.1.0",\n "info": {\n "title": "AaaC CLI",\n "version": "0.1.0",\n "description": "Agent as a Component \u2014 Contract compiler and code generator"\n },\n "command_sets": {\n "aaac": {\n "summary": "AaaC CLI \u2014 compile Component Contracts and generate adapters",\n "executable": "aaac",\n "global_options": [\n {\n "name": "verbose",\n "aliases": [\n "v"\n ],\n "schema": {\n "type": "boolean"\n },\n "description": "Enable verbose output"\n },\n {\n "name": "quiet",\n "aliases": [\n "q"\n ],\n "schema": {\n "type": "boolean"\n },\n "description": "Suppress non-essential output"\n },\n {\n "name": "resume",\n "schema": {\n "type": "string"\n },\n "description": "Resume from a previous memory_ref ID"\n }\n ],\n "commands": {\n "compile": {\n "summary": "Compile a Component Contract YAML to Component IR",\n "arguments": [\n {\n "name": "file",\n "required": true,\n "schema": {\n "type": "string"\n },\n "description": "Path to the Component Contract YAML file"\n }\n ],\n "options": [\n {\n "name": "output",\n "aliases": [\n "o"\n ],\n "schema": {\n "type": "string"\n },\n "description": "Output path for the compiled IR (JSON)"\n }\n ],\n "exits": {\n "0": {\n "description": "Compilation succeeded",\n "stdout": {\n "format": "json",\n "schema": {\n "type": "object",\n "description": "Component IR"\n }\n }\n },\n "1": {\n "description": "Compilation failed (validation errors)",\n "stderr": {\n "format": "text"\n }\n }\n }\n },\n "generate": {\n "summary": "Generate adapters from a Component Contract",\n "arguments": [\n {\n "name": "file",\n "required": true,\n "schema": {\n "type": "string"\n },\n "description": "Path to the Component Contract YAML file"\n }\n ],\n "options": [\n {\n "name": "output-dir",\n "aliases": [\n "o"\n ],\n "schema": {\n "type": "string"\n },\n "description": "Output directory for generated files"\n },\n {\n "name": "targets",\n "aliases": [\n "t"\n ],\n "schema": {\n "type": "array",\n "items": {\n "type": "string",\n "enum": [\n "library",\n "cli",\n "runtime",\n "mcp",\n "claude",\n "openai"\n ]\n }\n },\n "description": "Generation targets (defaults to projections in contract)"\n },\n {\n "name": "dry-run",\n "schema": {\n "type": "boolean"\n },\n "description": "Show what would be generated without writing files"\n }\n ],\n "effects": {\n "filesystem": "read_write"\n },\n "exits": {\n "0": {\n "description": "Generation succeeded",\n "stdout": {\n "format": "text"\n }\n },\n "1": {\n "description": "Generation failed",\n "stderr": {\n "format": "text"\n }\n }\n }\n },\n "validate": {\n "summary": "Validate a Component Contract YAML",\n "arguments": [\n {\n "name": "file",\n "required": true,\n "schema": {\n "type": "string"\n },\n "description": "Path to the Component Contract YAML file"\n }\n ],\n "options": [\n {\n "name": "strict",\n "schema": {\n "type": "boolean"\n },\n "description": "Enable strict validation (check implementation refs)"\n }\n ],\n "exits": {\n "0": {\n "description": "Validation passed",\n "stdout": {\n "format": "text"\n }\n },\n "1": {\n "description": "Validation failed",\n "stderr": {\n "format": "text"\n }\n }\n }\n },\n "introspect": {\n "summary": "Dump Component IR information",\n "arguments": [\n {\n "name": "file",\n "required": true,\n "schema": {\n "type": "string"\n },\n "description": "Path to the Component Contract YAML file"\n }\n ],\n "options": [\n {\n "name": "format",\n "aliases": [\n "f"\n ],\n "schema": {\n "type": "string",\n "enum": [\n "json",\n "yaml"\n ]\n },\n "description": "Output format (default yaml)"\n }\n ],\n "exits": {\n "0": {\n "description": "Success",\n "stdout": {\n "format": "json",\n "schema": {\n "type": "object",\n "description": "Component IR dump"\n }\n }\n }\n }\n }\n }\n }\n }\n}';
3670
+ var CONTRACT_YAML = "# yaml-language-server: $schema=./node_modules/cli-contracts/schemas/cli-contract.schema.json\ncli_contracts: 0.1.0\n\ninfo:\n title: AaaC CLI\n version: 0.1.0\n description: Agent as a Component \u2014 Contract compiler and code generator\n\ncommand_sets:\n aaac:\n summary: AaaC CLI \u2014 compile Component Contracts and generate adapters\n executable: aaac\n global_options:\n - name: verbose\n aliases: [v]\n schema: { type: boolean }\n description: Enable verbose output\n - name: quiet\n aliases: [q]\n schema: { type: boolean }\n description: Suppress non-essential output\n - name: resume\n schema: { type: string }\n description: Resume from a previous memory_ref ID\n commands:\n compile:\n summary: Compile a Component Contract YAML to Component IR\n arguments:\n - name: file\n required: true\n schema: { type: string }\n description: Path to the Component Contract YAML file\n options:\n - name: output\n aliases: [o]\n schema: { type: string }\n description: Output path for the compiled IR (JSON)\n exits:\n '0':\n description: Compilation succeeded\n stdout:\n format: json\n schema:\n type: object\n description: Component IR\n '1':\n description: Compilation failed (validation errors)\n stderr:\n format: text\n\n generate:\n summary: Generate adapters from a Component Contract\n arguments:\n - name: file\n required: true\n schema: { type: string }\n description: Path to the Component Contract YAML file\n options:\n - name: output-dir\n aliases: [o]\n schema: { type: string }\n description: Output directory for generated files\n - name: targets\n aliases: [t]\n schema:\n type: array\n items:\n type: string\n enum: [library, cli, runtime, claude, openai]\n description: Generation targets (defaults to projections in contract)\n - name: dry-run\n schema: { type: boolean }\n description: Show what would be generated without writing files\n effects:\n filesystem: read_write\n exits:\n '0':\n description: Generation succeeded\n stdout:\n format: text\n '1':\n description: Generation failed\n stderr:\n format: text\n\n validate:\n summary: Validate a Component Contract YAML\n arguments:\n - name: file\n required: true\n schema: { type: string }\n description: Path to the Component Contract YAML file\n options:\n - name: strict\n schema: { type: boolean }\n description: Enable strict validation (check implementation refs)\n exits:\n '0':\n description: Validation passed\n stdout:\n format: text\n '1':\n description: Validation failed\n stderr:\n format: text\n\n introspect:\n summary: Dump Component IR information\n arguments:\n - name: file\n required: true\n schema: { type: string }\n description: Path to the Component Contract YAML file\n options:\n - name: format\n aliases: [f]\n schema:\n type: string\n enum: [json, yaml]\n description: Output format (default yaml)\n exits:\n '0':\n description: Success\n stdout:\n format: json\n schema:\n type: object\n description: Component IR dump\n";
3671
+ var CONTRACT_JSON_STR = '{\n "cli_contracts": "0.1.0",\n "info": {\n "title": "AaaC CLI",\n "version": "0.1.0",\n "description": "Agent as a Component \u2014 Contract compiler and code generator"\n },\n "command_sets": {\n "aaac": {\n "summary": "AaaC CLI \u2014 compile Component Contracts and generate adapters",\n "executable": "aaac",\n "global_options": [\n {\n "name": "verbose",\n "aliases": [\n "v"\n ],\n "schema": {\n "type": "boolean"\n },\n "description": "Enable verbose output"\n },\n {\n "name": "quiet",\n "aliases": [\n "q"\n ],\n "schema": {\n "type": "boolean"\n },\n "description": "Suppress non-essential output"\n },\n {\n "name": "resume",\n "schema": {\n "type": "string"\n },\n "description": "Resume from a previous memory_ref ID"\n }\n ],\n "commands": {\n "compile": {\n "summary": "Compile a Component Contract YAML to Component IR",\n "arguments": [\n {\n "name": "file",\n "required": true,\n "schema": {\n "type": "string"\n },\n "description": "Path to the Component Contract YAML file"\n }\n ],\n "options": [\n {\n "name": "output",\n "aliases": [\n "o"\n ],\n "schema": {\n "type": "string"\n },\n "description": "Output path for the compiled IR (JSON)"\n }\n ],\n "exits": {\n "0": {\n "description": "Compilation succeeded",\n "stdout": {\n "format": "json",\n "schema": {\n "type": "object",\n "description": "Component IR"\n }\n }\n },\n "1": {\n "description": "Compilation failed (validation errors)",\n "stderr": {\n "format": "text"\n }\n }\n }\n },\n "generate": {\n "summary": "Generate adapters from a Component Contract",\n "arguments": [\n {\n "name": "file",\n "required": true,\n "schema": {\n "type": "string"\n },\n "description": "Path to the Component Contract YAML file"\n }\n ],\n "options": [\n {\n "name": "output-dir",\n "aliases": [\n "o"\n ],\n "schema": {\n "type": "string"\n },\n "description": "Output directory for generated files"\n },\n {\n "name": "targets",\n "aliases": [\n "t"\n ],\n "schema": {\n "type": "array",\n "items": {\n "type": "string",\n "enum": [\n "library",\n "cli",\n "runtime",\n "claude",\n "openai"\n ]\n }\n },\n "description": "Generation targets (defaults to projections in contract)"\n },\n {\n "name": "dry-run",\n "schema": {\n "type": "boolean"\n },\n "description": "Show what would be generated without writing files"\n }\n ],\n "effects": {\n "filesystem": "read_write"\n },\n "exits": {\n "0": {\n "description": "Generation succeeded",\n "stdout": {\n "format": "text"\n }\n },\n "1": {\n "description": "Generation failed",\n "stderr": {\n "format": "text"\n }\n }\n }\n },\n "validate": {\n "summary": "Validate a Component Contract YAML",\n "arguments": [\n {\n "name": "file",\n "required": true,\n "schema": {\n "type": "string"\n },\n "description": "Path to the Component Contract YAML file"\n }\n ],\n "options": [\n {\n "name": "strict",\n "schema": {\n "type": "boolean"\n },\n "description": "Enable strict validation (check implementation refs)"\n }\n ],\n "exits": {\n "0": {\n "description": "Validation passed",\n "stdout": {\n "format": "text"\n }\n },\n "1": {\n "description": "Validation failed",\n "stderr": {\n "format": "text"\n }\n }\n }\n },\n "introspect": {\n "summary": "Dump Component IR information",\n "arguments": [\n {\n "name": "file",\n "required": true,\n "schema": {\n "type": "string"\n },\n "description": "Path to the Component Contract YAML file"\n }\n ],\n "options": [\n {\n "name": "format",\n "aliases": [\n "f"\n ],\n "schema": {\n "type": "string",\n "enum": [\n "json",\n "yaml"\n ]\n },\n "description": "Output format (default yaml)"\n }\n ],\n "exits": {\n "0": {\n "description": "Success",\n "stdout": {\n "format": "json",\n "schema": {\n "type": "object",\n "description": "Component IR dump"\n }\n }\n }\n }\n }\n }\n }\n }\n}';
3673
3672
 
3674
3673
  // src/generated/program.ts
3675
3674
  function createProgram(handlers2, version) {