agent-contracts-runtime 0.13.4 → 0.30.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/cli-contract.yaml +37 -37
- package/dist/{chunk-3IN467AB.js → chunk-26LMGCWS.js} +18 -18
- package/dist/chunk-26LMGCWS.js.map +1 -0
- package/dist/cli/index.js +31 -15
- package/dist/cli/index.js.map +1 -1
- package/dist/generator/index.d.ts +5 -5
- package/dist/generator/index.js +1 -1
- package/docs/cli-reference.md +1444 -0
- package/package.json +5 -4
- package/dist/chunk-3IN467AB.js.map +0 -1
package/README.md
CHANGED
|
@@ -242,7 +242,7 @@ const result = await generate({
|
|
|
242
242
|
configPath: "./agent-runtime.config.yaml",
|
|
243
243
|
clean: true,
|
|
244
244
|
});
|
|
245
|
-
console.log(result.
|
|
245
|
+
console.log(result.files_generated);
|
|
246
246
|
|
|
247
247
|
const isFresh = await checkFreshness("./agent-runtime.config.yaml");
|
|
248
248
|
```
|
|
@@ -951,6 +951,7 @@ templates_dir: ./custom-templates # optional, overrides built-in templa
|
|
|
951
951
|
|
|
952
952
|
- Node.js 20+
|
|
953
953
|
- TypeScript 5.x (ESM, strict mode)
|
|
954
|
+
- `tsx` (bundled as a dependency — used by the CLI to load generated `.ts` contracts and plugins at runtime)
|
|
954
955
|
- `agent-contracts` (optional peer dependency for DSL resolution)
|
|
955
956
|
- `@anthropic-ai/claude-agent-sdk` (optional, for Claude adapter — requires zod ^4.0.0)
|
|
956
957
|
- `@cursor/sdk` (optional, for Cursor adapter)
|
package/cli-contract.yaml
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
cli_contracts: 0.1.0
|
|
2
2
|
|
|
3
3
|
info:
|
|
4
4
|
title: agent-runtime CLI
|
|
@@ -10,10 +10,10 @@ info:
|
|
|
10
10
|
license:
|
|
11
11
|
name: MIT
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
command_sets:
|
|
14
14
|
agent-runtime:
|
|
15
15
|
summary: CLI for agent-contracts-runtime — generate, run, and manage agent workflows.
|
|
16
|
-
|
|
16
|
+
global_options:
|
|
17
17
|
- name: config
|
|
18
18
|
aliases: [c]
|
|
19
19
|
description: Path to agent-runtime.config.yaml.
|
|
@@ -23,7 +23,7 @@ commandSets:
|
|
|
23
23
|
file:
|
|
24
24
|
mode: read
|
|
25
25
|
exists: true
|
|
26
|
-
|
|
26
|
+
media_type: application/yaml
|
|
27
27
|
|
|
28
28
|
- name: verbose
|
|
29
29
|
aliases: [v]
|
|
@@ -86,12 +86,12 @@ commandSets:
|
|
|
86
86
|
format: text
|
|
87
87
|
|
|
88
88
|
x-agent:
|
|
89
|
-
|
|
90
|
-
|
|
89
|
+
risk_level: low
|
|
90
|
+
requires_confirmation: false
|
|
91
91
|
idempotent: false
|
|
92
|
-
|
|
92
|
+
side_effects:
|
|
93
93
|
- filesystem_write
|
|
94
|
-
|
|
94
|
+
safe_dry_run_option: ""
|
|
95
95
|
|
|
96
96
|
# -----------------------------------------------------------------------
|
|
97
97
|
# generate
|
|
@@ -151,12 +151,12 @@ commandSets:
|
|
|
151
151
|
$ref: "#/components/schemas/ValidationError"
|
|
152
152
|
|
|
153
153
|
x-agent:
|
|
154
|
-
|
|
155
|
-
|
|
154
|
+
risk_level: low
|
|
155
|
+
requires_confirmation: false
|
|
156
156
|
idempotent: true
|
|
157
|
-
|
|
157
|
+
side_effects:
|
|
158
158
|
- filesystem_write
|
|
159
|
-
|
|
159
|
+
safe_dry_run_option: check
|
|
160
160
|
|
|
161
161
|
# -----------------------------------------------------------------------
|
|
162
162
|
# run
|
|
@@ -228,7 +228,7 @@ commandSets:
|
|
|
228
228
|
file:
|
|
229
229
|
mode: read
|
|
230
230
|
exists: true
|
|
231
|
-
|
|
231
|
+
media_type: application/yaml
|
|
232
232
|
|
|
233
233
|
exits:
|
|
234
234
|
"0":
|
|
@@ -258,14 +258,14 @@ commandSets:
|
|
|
258
258
|
format: text
|
|
259
259
|
|
|
260
260
|
x-agent:
|
|
261
|
-
|
|
262
|
-
|
|
261
|
+
risk_level: high
|
|
262
|
+
requires_confirmation: true
|
|
263
263
|
idempotent: false
|
|
264
|
-
|
|
264
|
+
side_effects:
|
|
265
265
|
- sdk_call
|
|
266
266
|
- filesystem_write
|
|
267
|
-
|
|
268
|
-
|
|
267
|
+
safe_dry_run_option: dry-run
|
|
268
|
+
recommended_before_use:
|
|
269
269
|
- Run `agent-runtime generate --check` to ensure contracts are up to date.
|
|
270
270
|
- Run `agent-runtime doctor` to verify SDK configuration.
|
|
271
271
|
|
|
@@ -308,10 +308,10 @@ commandSets:
|
|
|
308
308
|
format: text
|
|
309
309
|
|
|
310
310
|
x-agent:
|
|
311
|
-
|
|
312
|
-
|
|
311
|
+
risk_level: low
|
|
312
|
+
requires_confirmation: false
|
|
313
313
|
idempotent: true
|
|
314
|
-
|
|
314
|
+
side_effects: []
|
|
315
315
|
|
|
316
316
|
# -----------------------------------------------------------------------
|
|
317
317
|
# show-prompt
|
|
@@ -367,10 +367,10 @@ commandSets:
|
|
|
367
367
|
format: text
|
|
368
368
|
|
|
369
369
|
x-agent:
|
|
370
|
-
|
|
371
|
-
|
|
370
|
+
risk_level: low
|
|
371
|
+
requires_confirmation: false
|
|
372
372
|
idempotent: true
|
|
373
|
-
|
|
373
|
+
side_effects: []
|
|
374
374
|
|
|
375
375
|
# -----------------------------------------------------------------------
|
|
376
376
|
# doctor
|
|
@@ -399,10 +399,10 @@ commandSets:
|
|
|
399
399
|
$ref: "#/components/schemas/DoctorResult"
|
|
400
400
|
|
|
401
401
|
x-agent:
|
|
402
|
-
|
|
403
|
-
|
|
402
|
+
risk_level: low
|
|
403
|
+
requires_confirmation: false
|
|
404
404
|
idempotent: true
|
|
405
|
-
|
|
405
|
+
side_effects: []
|
|
406
406
|
|
|
407
407
|
|
|
408
408
|
# =============================================================================
|
|
@@ -416,9 +416,9 @@ components:
|
|
|
416
416
|
# -------------------------------------------------------------------------
|
|
417
417
|
InitResult:
|
|
418
418
|
type: object
|
|
419
|
-
required: [
|
|
419
|
+
required: [files_created]
|
|
420
420
|
properties:
|
|
421
|
-
|
|
421
|
+
files_created:
|
|
422
422
|
type: array
|
|
423
423
|
items:
|
|
424
424
|
type: string
|
|
@@ -429,26 +429,26 @@ components:
|
|
|
429
429
|
# -------------------------------------------------------------------------
|
|
430
430
|
GenerateResult:
|
|
431
431
|
type: object
|
|
432
|
-
required: [
|
|
432
|
+
required: [files_generated, dsl_hash, generation_input_hash]
|
|
433
433
|
properties:
|
|
434
|
-
|
|
434
|
+
files_generated:
|
|
435
435
|
type: array
|
|
436
436
|
items:
|
|
437
437
|
type: string
|
|
438
438
|
description: List of generated file paths.
|
|
439
|
-
|
|
439
|
+
dsl_hash:
|
|
440
440
|
type: string
|
|
441
441
|
description: SHA-256 hash of the resolved DSL (canonical stringify).
|
|
442
|
-
|
|
442
|
+
generation_input_hash:
|
|
443
443
|
type: string
|
|
444
444
|
description: SHA-256 hash of all generation inputs.
|
|
445
445
|
cleaned:
|
|
446
446
|
type: boolean
|
|
447
447
|
description: Whether --clean was used.
|
|
448
|
-
|
|
448
|
+
check_mode:
|
|
449
449
|
type: boolean
|
|
450
450
|
description: Whether --check was used.
|
|
451
|
-
|
|
451
|
+
has_differences:
|
|
452
452
|
type: boolean
|
|
453
453
|
description: In --check mode, whether differences were found.
|
|
454
454
|
|
|
@@ -568,13 +568,13 @@ components:
|
|
|
568
568
|
# -------------------------------------------------------------------------
|
|
569
569
|
DoctorResult:
|
|
570
570
|
type: object
|
|
571
|
-
required: [checks,
|
|
571
|
+
required: [checks, all_passed]
|
|
572
572
|
properties:
|
|
573
573
|
checks:
|
|
574
574
|
type: array
|
|
575
575
|
items:
|
|
576
576
|
$ref: "#/components/schemas/DoctorCheck"
|
|
577
|
-
|
|
577
|
+
all_passed:
|
|
578
578
|
type: boolean
|
|
579
579
|
|
|
580
580
|
DoctorCheck:
|
|
@@ -355,12 +355,12 @@ async function generate(options = {}) {
|
|
|
355
355
|
const dslCanonical = canonicalStringify(dsl);
|
|
356
356
|
const dslHash = computeHash(dslCanonical);
|
|
357
357
|
const contractCtx = buildContractContext(dsl);
|
|
358
|
-
const
|
|
358
|
+
const files_generated = [];
|
|
359
359
|
const generatedContents = /* @__PURE__ */ new Map();
|
|
360
360
|
for (const { template, output } of CONTRACT_TEMPLATES) {
|
|
361
361
|
const rendered = DO_NOT_EDIT_HEADER + await renderTemplate(template, contractCtx, templatesDir);
|
|
362
362
|
const outPath = join2(config.generatedDir, output);
|
|
363
|
-
|
|
363
|
+
files_generated.push(relative(config.configDir, outPath));
|
|
364
364
|
generatedContents.set(outPath, rendered);
|
|
365
365
|
}
|
|
366
366
|
if (config.bindingPaths.length > 0) {
|
|
@@ -379,7 +379,7 @@ async function generate(options = {}) {
|
|
|
379
379
|
templatesDir
|
|
380
380
|
);
|
|
381
381
|
const outPath = join2(config.generatedDir, output);
|
|
382
|
-
|
|
382
|
+
files_generated.push(relative(config.configDir, outPath));
|
|
383
383
|
generatedContents.set(outPath, rendered);
|
|
384
384
|
}
|
|
385
385
|
}
|
|
@@ -392,18 +392,18 @@ async function generate(options = {}) {
|
|
|
392
392
|
} catch {
|
|
393
393
|
}
|
|
394
394
|
}
|
|
395
|
-
const
|
|
396
|
-
let
|
|
395
|
+
const generation_input_hash = computeHash(generationInputParts.join("\n---\n"));
|
|
396
|
+
let has_differences = false;
|
|
397
397
|
if (checkMode) {
|
|
398
398
|
for (const [outPath, content] of generatedContents) {
|
|
399
399
|
try {
|
|
400
400
|
const existing = await readFile3(outPath, "utf8");
|
|
401
401
|
if (existing !== content) {
|
|
402
|
-
|
|
402
|
+
has_differences = true;
|
|
403
403
|
break;
|
|
404
404
|
}
|
|
405
405
|
} catch {
|
|
406
|
-
|
|
406
|
+
has_differences = true;
|
|
407
407
|
break;
|
|
408
408
|
}
|
|
409
409
|
}
|
|
@@ -414,22 +414,22 @@ async function generate(options = {}) {
|
|
|
414
414
|
await writeFile(outPath, content, "utf8");
|
|
415
415
|
}
|
|
416
416
|
const manifest = {
|
|
417
|
-
|
|
418
|
-
dslHash,
|
|
419
|
-
|
|
420
|
-
files:
|
|
417
|
+
generated_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
418
|
+
dsl_hash: dslHash,
|
|
419
|
+
generation_input_hash,
|
|
420
|
+
files: files_generated
|
|
421
421
|
};
|
|
422
422
|
const manifestPath = join2(config.generatedDir, ".manifest.json");
|
|
423
423
|
await mkdir(resolve3(manifestPath, ".."), { recursive: true });
|
|
424
424
|
await writeFile(manifestPath, JSON.stringify(manifest, null, 2) + "\n", "utf8");
|
|
425
425
|
}
|
|
426
426
|
return {
|
|
427
|
-
|
|
428
|
-
dslHash,
|
|
429
|
-
|
|
427
|
+
files_generated,
|
|
428
|
+
dsl_hash: dslHash,
|
|
429
|
+
generation_input_hash,
|
|
430
430
|
cleaned,
|
|
431
|
-
checkMode,
|
|
432
|
-
|
|
431
|
+
check_mode: checkMode,
|
|
432
|
+
has_differences
|
|
433
433
|
};
|
|
434
434
|
}
|
|
435
435
|
async function checkFreshness(configPath) {
|
|
@@ -441,7 +441,7 @@ async function checkFreshness(configPath) {
|
|
|
441
441
|
const dsl = await loadDsl(config.dslPath);
|
|
442
442
|
const dslCanonical = canonicalStringify(dsl);
|
|
443
443
|
const currentHash = computeHash(dslCanonical);
|
|
444
|
-
return manifest.
|
|
444
|
+
return manifest.dsl_hash === currentHash;
|
|
445
445
|
} catch {
|
|
446
446
|
return false;
|
|
447
447
|
}
|
|
@@ -454,4 +454,4 @@ export {
|
|
|
454
454
|
generate,
|
|
455
455
|
checkFreshness
|
|
456
456
|
};
|
|
457
|
-
//# sourceMappingURL=chunk-
|
|
457
|
+
//# sourceMappingURL=chunk-26LMGCWS.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/generator/index.ts","../src/generator/config.ts","../src/generator/template-engine.ts","../src/generator/context.ts"],"sourcesContent":["/**\n * Generator — orchestrates DSL-to-TypeScript code generation\n */\n\nimport { readFile, writeFile, mkdir, rm, stat } from \"node:fs/promises\";\nimport { resolve, join, relative } from \"node:path\";\nimport { createHash } from \"node:crypto\";\nimport YAML from \"yaml\";\nimport { loadConfig, type ResolvedConfig } from \"./config.js\";\nimport { renderTemplate } from \"./template-engine.js\";\nimport { buildContractContext, buildGuardrailContext } from \"./context.js\";\n\nexport interface GenerateOptions {\n clean?: boolean;\n check?: boolean;\n templates?: string;\n configPath?: string;\n}\n\nexport interface GenerateResult {\n files_generated: string[];\n dsl_hash: string;\n generation_input_hash: string;\n cleaned: boolean;\n check_mode: boolean;\n has_differences: boolean;\n}\n\nconst DO_NOT_EDIT_HEADER = `/**\n * AUTO-GENERATED by agent-contracts-runtime. DO NOT EDIT.\n *\n * Regenerate via: npx agent-runtime generate\n */\n\n`;\n\nasync function loadYaml(filePath: string): Promise<unknown> {\n const raw = await readFile(filePath, \"utf8\");\n return YAML.parse(raw);\n}\n\nfunction computeHash(data: string): string {\n return createHash(\"sha256\").update(data).digest(\"hex\");\n}\n\nfunction sortDeep(value: unknown): unknown {\n if (Array.isArray(value)) return value.map(sortDeep);\n if (value !== null && typeof value === \"object\") {\n return Object.fromEntries(\n Object.entries(value as Record<string, unknown>)\n .sort(([a], [b]) => a.localeCompare(b))\n .map(([k, v]) => [k, sortDeep(v)]),\n );\n }\n return value;\n}\n\nfunction canonicalStringify(obj: unknown): string {\n return JSON.stringify(sortDeep(obj));\n}\n\n/**\n * Load DSL via agent-contracts resolve() which handles extends, merge\n * operators ($replace/$append), and $ref resolution including\n * file.yaml#/json-pointer fragments.\n */\nasync function loadDsl(dslPath: string): Promise<Record<string, unknown>> {\n const { resolve: resolveDsl } = await import(\"agent-contracts\");\n const result = await resolveDsl(dslPath);\n return result.data;\n}\n\nconst CONTRACT_TEMPLATES = [\n { template: \"agents.ts.hbs\", output: \"agents.ts\" },\n { template: \"tasks.ts.hbs\", output: \"tasks.ts\" },\n { template: \"workflows.ts.hbs\", output: \"workflows.ts\" },\n { template: \"handoffs.ts.hbs\", output: \"handoffs.ts\" },\n { template: \"contracts-index.ts.hbs\", output: \"index.ts\" },\n];\n\nconst GUARDRAIL_TEMPLATES = [\n { template: \"guardrails.ts.hbs\", output: \"hooks/guardrails.ts\" },\n { template: \"hooks-index.ts.hbs\", output: \"hooks/index.ts\" },\n];\n\nexport async function generate(options: GenerateOptions = {}): Promise<GenerateResult> {\n const configPath = options.configPath ?? \"./agent-runtime.config.yaml\";\n const config = await loadConfig(configPath);\n\n const templatesDir = options.templates ?? config.templatesDir;\n const checkMode = options.check ?? false;\n const cleaned = options.clean ?? false;\n\n if (cleaned && !checkMode) {\n try {\n await rm(config.generatedDir, { recursive: true, force: true });\n } catch {\n // directory may not exist\n }\n }\n\n const dsl = await loadDsl(config.dslPath);\n const dslCanonical = canonicalStringify(dsl);\n const dslHash = computeHash(dslCanonical);\n\n const contractCtx = buildContractContext(dsl);\n\n const files_generated: string[] = [];\n const generatedContents: Map<string, string> = new Map();\n\n // Phase 1: Contract files\n for (const { template, output } of CONTRACT_TEMPLATES) {\n const rendered = DO_NOT_EDIT_HEADER + await renderTemplate(template, contractCtx as unknown as Record<string, unknown>, templatesDir);\n const outPath = join(config.generatedDir, output);\n files_generated.push(relative(config.configDir, outPath));\n generatedContents.set(outPath, rendered);\n }\n\n // Phase 2: Guardrail hooks (only if bindings are configured)\n if (config.bindingPaths.length > 0) {\n for (const bindingPath of config.bindingPaths) {\n const binding = await loadYaml(bindingPath);\n const guardrailCtx = buildGuardrailContext(\n dsl,\n binding,\n config.active_guardrail_policy,\n );\n\n if (guardrailCtx.hasGuardrails) {\n for (const { template, output } of GUARDRAIL_TEMPLATES) {\n const rendered = DO_NOT_EDIT_HEADER + await renderTemplate(\n template,\n guardrailCtx as unknown as Record<string, unknown>,\n templatesDir,\n );\n const outPath = join(config.generatedDir, output);\n files_generated.push(relative(config.configDir, outPath));\n generatedContents.set(outPath, rendered);\n }\n }\n }\n }\n\n // Compute generation input hash (DSL + binding + generator version)\n const generationInputParts = [dslCanonical];\n for (const bp of config.bindingPaths) {\n try {\n generationInputParts.push(await readFile(bp, \"utf8\"));\n } catch {\n // binding may not exist\n }\n }\n const generation_input_hash = computeHash(generationInputParts.join(\"\\n---\\n\"));\n\n // Check mode — compare without writing\n let has_differences = false;\n if (checkMode) {\n for (const [outPath, content] of generatedContents) {\n try {\n const existing = await readFile(outPath, \"utf8\");\n if (existing !== content) {\n has_differences = true;\n break;\n }\n } catch {\n has_differences = true;\n break;\n }\n }\n } else {\n // Write files\n for (const [outPath, content] of generatedContents) {\n const dir = resolve(outPath, \"..\");\n await mkdir(dir, { recursive: true });\n await writeFile(outPath, content, \"utf8\");\n }\n\n // Write manifest\n const manifest = {\n generated_at: new Date().toISOString(),\n dsl_hash: dslHash,\n generation_input_hash,\n files: files_generated,\n };\n const manifestPath = join(config.generatedDir, \".manifest.json\");\n await mkdir(resolve(manifestPath, \"..\"), { recursive: true });\n await writeFile(manifestPath, JSON.stringify(manifest, null, 2) + \"\\n\", \"utf8\");\n }\n\n return {\n files_generated,\n dsl_hash: dslHash,\n generation_input_hash,\n cleaned,\n check_mode: checkMode,\n has_differences,\n };\n}\n\nexport async function checkFreshness(configPath?: string): Promise<boolean> {\n const config = await loadConfig(configPath ?? \"./agent-runtime.config.yaml\");\n const manifestPath = join(config.generatedDir, \".manifest.json\");\n\n try {\n const raw = await readFile(manifestPath, \"utf8\");\n const manifest = JSON.parse(raw) as { dsl_hash: string };\n\n const dsl = await loadDsl(config.dslPath);\n const dslCanonical = canonicalStringify(dsl);\n const currentHash = computeHash(dslCanonical);\n\n return manifest.dsl_hash === currentHash;\n } catch {\n return false;\n }\n}\n\nexport { loadConfig, type ResolvedConfig } from \"./config.js\";\nexport { buildContractContext, buildGuardrailContext } from \"./context.js\";\n","/**\n * Generator configuration — loads and validates agent-runtime.config.yaml\n */\n\nimport { readFile } from \"node:fs/promises\";\nimport { resolve, dirname } from \"node:path\";\nimport { z } from \"zod\";\nimport YAML from \"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\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});\n\nexport type RuntimeConfig = z.infer<typeof RuntimeConfigSchema>;\n\nexport interface ResolvedConfig extends RuntimeConfig {\n configDir: string;\n dslPath: string;\n generatedDir: string;\n bindingPaths: string[];\n templatesDir: string | undefined;\n pluginPaths: string[];\n}\n\nexport async function loadConfig(configPath: string): Promise<ResolvedConfig> {\n const absPath = resolve(configPath);\n const raw = await readFile(absPath, \"utf8\");\n const parsed = YAML.parse(raw);\n const config = RuntimeConfigSchema.parse(parsed);\n const configDir = dirname(absPath);\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 templatesDir: config.templates_dir\n ? resolve(configDir, config.templates_dir)\n : undefined,\n pluginPaths: config.plugins,\n };\n}\n","/**\n * Handlebars template engine with custom helpers for TypeScript code generation\n */\n\nimport { readFile } from \"node:fs/promises\";\nimport { resolve, join } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport Handlebars from \"handlebars\";\n\nimport { existsSync } from \"node:fs\";\n\nconst __dirname = fileURLToPath(new URL(\".\", import.meta.url));\n\nfunction findPackageRoot(): string {\n let dir = __dirname;\n for (let i = 0; i < 5; i++) {\n if (existsSync(join(dir, \"package.json\"))) return dir;\n dir = resolve(dir, \"..\");\n }\n return resolve(__dirname, \"..\");\n}\n\nconst BUILTIN_TEMPLATES_DIR = join(findPackageRoot(), \"templates\");\n\nfunction toCamelCase(str: string): string {\n return str.replace(/-([a-z])/g, (_, c: string) => c.toUpperCase());\n}\n\nfunction toPascalCase(str: string): string {\n const camel = toCamelCase(str);\n return camel.charAt(0).toUpperCase() + camel.slice(1);\n}\n\nconst hbs = Handlebars.create();\n\nhbs.registerHelper(\"camelCase\", (str: string) => toCamelCase(str));\nhbs.registerHelper(\"PascalCase\", (str: string) => toPascalCase(str));\n\nhbs.registerHelper(\"eq\", (a: unknown, b: unknown) => a === b);\nhbs.registerHelper(\"notEmpty\", (arr: unknown) =>\n Array.isArray(arr) ? arr.length > 0 : !!arr,\n);\n\nhbs.registerHelper(\"json\", (value: unknown) =>\n new Handlebars.SafeString(JSON.stringify(value, null, 2)),\n);\n\nhbs.registerHelper(\"jsonInline\", (value: unknown) =>\n new Handlebars.SafeString(JSON.stringify(value)),\n);\n\nhbs.registerHelper(\"indent\", (text: string, spaces: number) => {\n if (typeof text !== \"string\") return text;\n const pad = \" \".repeat(spaces);\n return text\n .split(\"\\n\")\n .map((line, i) => (i === 0 ? line : pad + line))\n .join(\"\\n\");\n});\n\nhbs.registerHelper(\"zodType\", function zodType(schema: Record<string, unknown>): string {\n if (!schema || typeof schema !== \"object\") return \"z.unknown()\";\n\n if (schema.enum) {\n const vals = (schema.enum as string[]).map((v) => `\"${v}\"`).join(\", \");\n return `z.enum([${vals}])`;\n }\n\n if (schema.const !== undefined) {\n return `z.literal(${JSON.stringify(schema.const)})`;\n }\n\n const type = schema.type as string | undefined;\n\n if (type === \"string\") return \"z.string()\";\n if (type === \"number\" || type === \"integer\") return \"z.number()\";\n if (type === \"boolean\") return \"z.boolean()\";\n\n if (type === \"array\") {\n const items = schema.items as Record<string, unknown> | undefined;\n const inner = items ? zodType(items) : \"z.unknown()\";\n return `z.array(${inner})`;\n }\n\n if (type === \"object\") {\n const props = schema.properties as Record<string, Record<string, unknown>> | undefined;\n if (!props) return \"z.record(z.string(), z.unknown())\";\n\n const required = (schema.required as string[]) ?? [];\n const fields = Object.entries(props)\n .map(([key, val]) => {\n const base = zodType(val);\n const opt = required.includes(key) ? \"\" : \".optional()\";\n return ` ${key}: ${base}${opt},`;\n })\n .join(\"\\n\");\n return `z.object({\\n${fields}\\n})`;\n }\n\n if (schema.allOf) {\n const parts = (schema.allOf as Record<string, unknown>[]).map(zodType);\n if (parts.length === 1) return parts[0];\n return parts.reduce((acc, part) => `${acc}.extend(${part}.shape)`);\n }\n\n return \"z.unknown()\";\n});\n\nhbs.registerHelper(\"regexEscape\", (str: string) => {\n if (typeof str !== \"string\") return str;\n return str.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n});\n\nhbs.registerHelper(\"stringArray\", (arr: unknown) => {\n if (!Array.isArray(arr)) return \"[]\";\n return \"[\" + arr.map((s) => `\"${s}\"`).join(\", \") + \"]\";\n});\n\n/**\n * Load a template by name, with custom dir override fallback to built-in.\n */\nasync function loadTemplate(\n name: string,\n customDir?: string,\n): Promise<string> {\n if (customDir) {\n try {\n return await readFile(join(customDir, name), \"utf8\");\n } catch {\n // fallback to built-in\n }\n }\n return readFile(join(BUILTIN_TEMPLATES_DIR, name), \"utf8\");\n}\n\nexport async function renderTemplate(\n name: string,\n context: Record<string, unknown>,\n customDir?: string,\n): Promise<string> {\n const source = await loadTemplate(name, customDir);\n const compiled = hbs.compile(source, { noEscape: true });\n return compiled(context);\n}\n\nexport { hbs, toCamelCase, toPascalCase };\n","/**\n * Build template contexts from resolved DSL data\n */\n\nimport { toCamelCase, toPascalCase } from \"./template-engine.js\";\n\nexport interface AgentEntry {\n id: string;\n varName: string;\n role_name: string;\n purpose: string;\n mode: string;\n dispatch_only: boolean;\n can_read_artifacts: string[];\n can_write_artifacts: string[];\n can_execute_tools: string[];\n can_invoke_agents: string[];\n can_return_handoffs: string[];\n responsibilities: string[];\n constraints: string[];\n rules: Array<{ id: string; description: string; severity: string }>;\n escalation_criteria: Array<{ condition: string; action: string }>;\n}\n\nexport interface TaskEntry {\n id: string;\n varName: string;\n description: string;\n target_agent: string;\n allowed_from_agents: string[];\n workflow: string;\n invocation_handoff: string;\n result_handoff: string;\n input_artifacts: string[];\n responsibilities: string[];\n completion_criteria: string[];\n optional: boolean;\n}\n\nexport interface WorkflowStepEntry {\n type: string;\n task?: string;\n from_agent?: string;\n description?: string;\n optional?: boolean;\n max_retries?: number;\n max_follow_ups?: number;\n depends_on?: string[];\n gate_kind?: string;\n retry?: { condition: string; fix_task: string; revalidate_task?: string };\n}\n\nexport interface WorkflowEntry {\n id: string;\n varName: string;\n description: string;\n trigger: string;\n entry_conditions: string[];\n steps: WorkflowStepEntry[];\n}\n\nexport interface HandoffEntry {\n id: string;\n varName: string;\n pascalName: string;\n schemaName: string;\n description: string;\n schema: Record<string, unknown>;\n}\n\nexport interface ContractContext {\n agentEntries: AgentEntry[];\n taskEntries: TaskEntry[];\n workflowEntries: WorkflowEntry[];\n handoffEntries: HandoffEntry[];\n}\n\n/**\n * Determine if a task is optional by checking if any workflow step referencing it is optional.\n */\nfunction isTaskOptional(\n taskId: string,\n workflows: Record<string, { steps: Array<{ type: string; task?: string; optional?: boolean }> }>,\n): boolean {\n for (const wf of Object.values(workflows)) {\n for (const step of wf.steps) {\n if (step.type === \"delegate\" && step.task === taskId && step.optional) {\n return true;\n }\n }\n }\n return false;\n}\n\n/**\n * Compute max_retries from workflow step or fallback to 0.\n */\nfunction getMaxRetries(\n taskId: string,\n workflows: Record<string, { steps: Array<Record<string, unknown>> }>,\n): number {\n for (const wf of Object.values(workflows)) {\n for (const step of wf.steps) {\n if (step.type === \"delegate\" && step.task === taskId) {\n const retry = step.retry as { condition: string } | undefined;\n return retry ? 1 : 0;\n }\n }\n }\n return 0;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function buildContractContext(dsl: any): ContractContext {\n const agents = (dsl.agents ?? {}) as Record<string, Record<string, unknown>>;\n const tasks = (dsl.tasks ?? {}) as Record<string, Record<string, unknown>>;\n const workflows = (dsl.workflow ?? {}) as Record<string, Record<string, unknown>>;\n const handoffTypes = (dsl.handoff_types ?? {}) as Record<string, Record<string, unknown>>;\n\n const agentEntries: AgentEntry[] = Object.entries(agents).map(([id, agent]) => ({\n id,\n varName: toCamelCase(id),\n role_name: (agent.role_name as string) ?? id,\n purpose: (agent.purpose as string) ?? \"\",\n mode: (agent.mode as string) ?? \"read-write\",\n dispatch_only: (agent.dispatch_only as boolean) ?? false,\n can_read_artifacts: (agent.can_read_artifacts as string[]) ?? [],\n can_write_artifacts: (agent.can_write_artifacts as string[]) ?? [],\n can_execute_tools: (agent.can_execute_tools as string[]) ?? [],\n can_invoke_agents: (agent.can_invoke_agents as string[]) ?? [],\n can_return_handoffs: (agent.can_return_handoffs as string[]) ?? [],\n responsibilities: (agent.responsibilities as string[]) ?? [],\n constraints: (agent.constraints as string[]) ?? [],\n rules: (agent.rules as AgentEntry[\"rules\"]) ?? [],\n escalation_criteria: (agent.escalation_criteria as AgentEntry[\"escalation_criteria\"]) ?? [],\n }));\n\n const taskEntries: TaskEntry[] = Object.entries(tasks).map(([id, task]) => ({\n id,\n varName: toCamelCase(id),\n description: (task.description as string) ?? \"\",\n target_agent: (task.target_agent as string) ?? \"\",\n allowed_from_agents: (task.allowed_from_agents as string[]) ?? [],\n workflow: (task.workflow as string) ?? \"\",\n invocation_handoff: (task.invocation_handoff as string) ?? \"\",\n result_handoff: (task.result_handoff as string) ?? \"\",\n input_artifacts: (task.input_artifacts as string[]) ?? [],\n responsibilities: (task.responsibilities as string[]) ?? [],\n completion_criteria: (task.completion_criteria as string[]) ?? [],\n optional: isTaskOptional(id, workflows as Record<string, { steps: Array<{ type: string; task?: string; optional?: boolean }> }>),\n }));\n\n const workflowEntries: WorkflowEntry[] = Object.entries(workflows).map(\n ([id, wf]) => {\n const steps = ((wf.steps as Array<Record<string, unknown>>) ?? []).map((step) => {\n const entry: WorkflowStepEntry = { type: step.type as string };\n if (step.type === \"delegate\") {\n entry.task = step.task as string;\n entry.from_agent = step.from_agent as string;\n entry.description = (step.description as string | undefined) ?? \"\";\n const wfStep = step as Record<string, unknown>;\n entry.optional = isTaskOptional(\n step.task as string,\n workflows as Record<string, { steps: Array<{ type: string; task?: string; optional?: boolean }> }>,\n );\n entry.max_retries = (wfStep.max_retries as number | undefined) ?? (wfStep.retry ? 1 : 0);\n entry.max_follow_ups = wfStep.max_follow_ups as number | undefined;\n if (wfStep.depends_on) {\n entry.depends_on = wfStep.depends_on as string[];\n }\n if (wfStep.retry) {\n const r = wfStep.retry as Record<string, unknown>;\n entry.retry = {\n condition: r.condition as string,\n fix_task: r.fix_task as string,\n revalidate_task: r.revalidate_task as string | undefined,\n };\n }\n } else if (step.type === \"gate\") {\n entry.gate_kind = step.gate_kind as string;\n entry.description = (step.description as string | undefined) ?? \"\";\n if (step.depends_on) {\n entry.depends_on = step.depends_on as string[];\n }\n }\n return entry;\n });\n\n return {\n id,\n varName: toCamelCase(id),\n description: (wf.description as string) ?? \"\",\n trigger: (wf.trigger as string) ?? \"\",\n entry_conditions: (wf.entry_conditions as string[]) ?? [],\n steps,\n };\n },\n );\n\n const handoffEntries: HandoffEntry[] = Object.entries(handoffTypes).map(\n ([id, ht]) => ({\n id,\n varName: toCamelCase(id),\n pascalName: toPascalCase(id),\n schemaName: toPascalCase(id) + \"Schema\",\n description: (ht.description as string) ?? \"\",\n schema: (ht.schema as Record<string, unknown>) ?? {},\n }),\n );\n\n return { agentEntries, taskEntries, workflowEntries, handoffEntries };\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"],"mappings":";AAIA,SAAS,YAAAA,WAAU,WAAW,OAAO,UAAgB;AACrD,SAAS,WAAAC,UAAS,QAAAC,OAAM,gBAAgB;AACxC,SAAS,kBAAkB;AAC3B,OAAOC,WAAU;;;ACHjB,SAAS,gBAAgB;AACzB,SAAS,SAAS,eAAe;AAC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L;AAAA,IACA,UAAU;AAAA,IACV;AAAA,IACA;AAAA,IACA,YAAY;AAAA,IACZ;AAAA,EACF;AACF;AAEA,eAAsB,eAAe,YAAuC;AAC1E,QAAM,SAAS,MAAM,WAAW,cAAc,6BAA6B;AAC3E,QAAM,eAAeD,MAAK,OAAO,cAAc,gBAAgB;AAE/D,MAAI;AACF,UAAM,MAAM,MAAMF,UAAS,cAAc,MAAM;AAC/C,UAAM,WAAW,KAAK,MAAM,GAAG;AAE/B,UAAM,MAAM,MAAM,QAAQ,OAAO,OAAO;AACxC,UAAM,eAAe,mBAAmB,GAAG;AAC3C,UAAM,cAAc,YAAY,YAAY;AAE5C,WAAO,SAAS,aAAa;AAAA,EAC/B,QAAQ;AACN,WAAO;AAAA,EACT;AACF;","names":["readFile","resolve","join","YAML","readFile","resolve","readFile","YAML","join","resolve"]}
|
package/dist/cli/index.js
CHANGED
|
@@ -9,11 +9,12 @@ import {
|
|
|
9
9
|
checkFreshness,
|
|
10
10
|
generate,
|
|
11
11
|
loadConfig
|
|
12
|
-
} from "../chunk-
|
|
12
|
+
} from "../chunk-26LMGCWS.js";
|
|
13
13
|
|
|
14
14
|
// src/cli/index.ts
|
|
15
15
|
import { existsSync as existsSync3, readFileSync } from "fs";
|
|
16
16
|
import { resolve as resolve2 } from "path";
|
|
17
|
+
import { register } from "tsx/esm/api";
|
|
17
18
|
|
|
18
19
|
// src/generated/cli/program.ts
|
|
19
20
|
import { Command } from "commander";
|
|
@@ -141,6 +142,18 @@ function checkAdapterConfigured() {
|
|
|
141
142
|
message: `No SDK adapter API keys found. Set one of: ${Object.entries(ADAPTER_ENV_VARS).map(([a, e]) => `${e} (${a})`).join(", ")}`
|
|
142
143
|
};
|
|
143
144
|
}
|
|
145
|
+
async function checkTsxAvailable() {
|
|
146
|
+
try {
|
|
147
|
+
await import("tsx/esm");
|
|
148
|
+
return { name: "tsx_available", status: "pass", message: "tsx is installed" };
|
|
149
|
+
} catch {
|
|
150
|
+
return {
|
|
151
|
+
name: "tsx_available",
|
|
152
|
+
status: "fail",
|
|
153
|
+
message: "tsx is not installed. Required for loading generated .ts files. Run: npm install tsx"
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
}
|
|
144
157
|
function checkPluginEntrypoints(config) {
|
|
145
158
|
if (config.pluginPaths.length === 0) {
|
|
146
159
|
return { name: "plugin_entrypoint", status: "pass", message: "No plugins configured" };
|
|
@@ -203,22 +216,24 @@ async function runDoctor(configPath) {
|
|
|
203
216
|
const configResult = await checkConfigExists(configPath);
|
|
204
217
|
checks.push(configResult.check);
|
|
205
218
|
if (!configResult.config) {
|
|
206
|
-
return { checks,
|
|
219
|
+
return { checks, all_passed: false };
|
|
207
220
|
}
|
|
208
221
|
const config = configResult.config;
|
|
209
|
-
const [dslCheck, manifestCheck, pluginCheck, bindingsCheck] = await Promise.all([
|
|
222
|
+
const [dslCheck, manifestCheck, pluginCheck, bindingsCheck, tsxCheck] = await Promise.all([
|
|
210
223
|
checkDslExists(config),
|
|
211
224
|
checkManifestFresh(configPath, config),
|
|
212
225
|
Promise.resolve(checkPluginEntrypoints(config)),
|
|
213
|
-
checkBindingsValid(config)
|
|
226
|
+
checkBindingsValid(config),
|
|
227
|
+
checkTsxAvailable()
|
|
214
228
|
]);
|
|
215
229
|
checks.push(dslCheck);
|
|
216
230
|
checks.push(manifestCheck);
|
|
217
231
|
checks.push(checkAdapterConfigured());
|
|
218
232
|
checks.push(pluginCheck);
|
|
219
233
|
checks.push(bindingsCheck);
|
|
220
|
-
|
|
221
|
-
|
|
234
|
+
checks.push(tsxCheck);
|
|
235
|
+
const all_passed = checks.every((c) => c.status !== "fail");
|
|
236
|
+
return { checks, all_passed };
|
|
222
237
|
}
|
|
223
238
|
|
|
224
239
|
// src/lib/init.ts
|
|
@@ -332,7 +347,7 @@ function buildScaffoldFiles(adapter) {
|
|
|
332
347
|
}
|
|
333
348
|
async function runInit(options) {
|
|
334
349
|
const { adapter, outputDir, force } = options;
|
|
335
|
-
const
|
|
350
|
+
const files_created = [];
|
|
336
351
|
const entries = buildScaffoldFiles(adapter);
|
|
337
352
|
for (const entry of entries) {
|
|
338
353
|
const absPath = join2(outputDir, entry.relativePath);
|
|
@@ -347,24 +362,25 @@ async function runInit(options) {
|
|
|
347
362
|
const dir = join2(absPath, "..");
|
|
348
363
|
await mkdir(dir, { recursive: true });
|
|
349
364
|
await writeFile(absPath, entry.content, "utf8");
|
|
350
|
-
|
|
365
|
+
files_created.push(entry.relativePath);
|
|
351
366
|
}
|
|
352
367
|
const gitignorePath = join2(outputDir, ".gitignore");
|
|
353
368
|
if (existsSync2(gitignorePath)) {
|
|
354
369
|
const existing = await readFile2(gitignorePath, "utf8");
|
|
355
370
|
if (!existing.includes("agent/generated/")) {
|
|
356
371
|
await appendFile(gitignorePath, GITIGNORE_ENTRIES.join("\n") + "\n", "utf8");
|
|
357
|
-
|
|
372
|
+
files_created.push(".gitignore");
|
|
358
373
|
}
|
|
359
374
|
} else {
|
|
360
375
|
await writeFile(gitignorePath, GITIGNORE_ENTRIES.join("\n").trimStart() + "\n", "utf8");
|
|
361
|
-
|
|
376
|
+
files_created.push(".gitignore");
|
|
362
377
|
}
|
|
363
|
-
return {
|
|
378
|
+
return { files_created };
|
|
364
379
|
}
|
|
365
380
|
|
|
366
381
|
// src/cli/index.ts
|
|
367
382
|
import YAML3 from "yaml";
|
|
383
|
+
register();
|
|
368
384
|
var VERSION = "0.11.0";
|
|
369
385
|
async function loadGeneratedContracts(configPath) {
|
|
370
386
|
const config = await loadConfig(configPath);
|
|
@@ -462,8 +478,8 @@ var handlers = {
|
|
|
462
478
|
templates: options.templates,
|
|
463
479
|
configPath
|
|
464
480
|
});
|
|
465
|
-
if (result.
|
|
466
|
-
if (result.
|
|
481
|
+
if (result.check_mode) {
|
|
482
|
+
if (result.has_differences) {
|
|
467
483
|
console.error("Generated files are out of date. Run `agent-runtime generate` to update.");
|
|
468
484
|
process.exit(1);
|
|
469
485
|
}
|
|
@@ -721,13 +737,13 @@ var handlers = {
|
|
|
721
737
|
console.log(` ${icon} ${check.name.padEnd(20)} ${check.status.toUpperCase()}${msg}`);
|
|
722
738
|
}
|
|
723
739
|
console.log("");
|
|
724
|
-
if (result.
|
|
740
|
+
if (result.all_passed) {
|
|
725
741
|
console.log("All checks passed.");
|
|
726
742
|
} else {
|
|
727
743
|
console.log("Some checks failed.");
|
|
728
744
|
}
|
|
729
745
|
console.log(JSON.stringify(result));
|
|
730
|
-
if (!result.
|
|
746
|
+
if (!result.all_passed) {
|
|
731
747
|
process.exitCode = 1;
|
|
732
748
|
}
|
|
733
749
|
}
|