agent-contracts-runtime 0.31.4 → 0.32.1
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 +77 -96
- package/cli-contract.yaml +411 -22
- package/dist/{chunk-IAIG5VCJ.js → chunk-W5YWUFAH.js} +7 -3
- package/dist/chunk-W5YWUFAH.js.map +1 -0
- package/dist/cli/index.js +1011 -12
- package/dist/cli/index.js.map +1 -1
- package/dist/generator/index.js +1 -1
- package/docs/cli-reference.md +1370 -216
- package/dsl/agent-runtime.config.yaml +2 -0
- package/dsl/agents/implementation-auditor.yaml +195 -0
- package/dsl/agents/llm-feature-implementer.yaml +298 -0
- package/dsl/handoff-types.yaml +184 -0
- package/dsl/implement-dsl.yaml +119 -0
- package/dsl/tasks.yaml +635 -0
- package/package.json +3 -1
- package/templates/implement-reference-templates.md +823 -0
- package/templates/implement-reference.md +240 -0
- package/templates/workflows.ts.hbs +2 -2
- package/dist/chunk-IAIG5VCJ.js.map +0 -1
package/README.md
CHANGED
|
@@ -2,120 +2,102 @@
|
|
|
2
2
|
|
|
3
3
|
Runtime bridge for executing [`agent-contracts`](https://github.com/foo-log-inc/agent-contracts) agent teams from TypeScript programs.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## Built-in Agents: Implement and Audit
|
|
6
6
|
|
|
7
|
-
`agent-contracts-runtime`
|
|
7
|
+
`agent-contracts-runtime` ships with two built-in agents that add LLM-powered commands to any CLI tool using the three-layer stack (`agent-contracts` + `agent-contracts-runtime` + `cli-contracts`).
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
### `agent-runtime implement` — Let the agent build it
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
DSL-derived contracts
|
|
19
|
-
↓
|
|
20
|
-
Agent SDK adapter
|
|
21
|
-
↓
|
|
22
|
-
Cursor / Claude / OpenAI Agents SDK / custom runner
|
|
11
|
+
Instead of hand-writing the integration code yourself, describe what you want and let the implementation agent do it:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
agent-runtime implement \
|
|
15
|
+
--adapter claude \
|
|
16
|
+
--project-dir ./my-tool \
|
|
17
|
+
"Add an audit command for migration safety and a propose command for SQL optimization"
|
|
23
18
|
```
|
|
24
19
|
|
|
25
|
-
|
|
20
|
+
The agent reads your project, then generates:
|
|
26
21
|
|
|
27
|
-
|
|
22
|
+
- DSL definitions (`dsl/agents/`, `dsl/tasks.yaml`, `dsl/handoff-types.yaml`, workflows, guardrails)
|
|
23
|
+
- TypeScript contracts via `agent-runtime generate`
|
|
24
|
+
- Runtime integration (`src/agents/orchestrator.ts`, `context-builder.ts`, `formatter.ts`)
|
|
25
|
+
- CLI command handlers
|
|
26
|
+
- Updated `cli-contract.yaml` with `x-agent` metadata and `components/schemas`
|
|
28
27
|
|
|
29
|
-
|
|
28
|
+
The agent is a domain expert in the three-layer stack. It knows the correct patterns, exit code conventions, adapter usage, and registry wiring. It will not call LLM APIs directly — all invocations go through `runTask`/`runWorkflow`.
|
|
30
29
|
|
|
31
|
-
|
|
30
|
+
```bash
|
|
31
|
+
agent-runtime implement --dry-run "Add an audit command" # Preview the prompt
|
|
32
|
+
agent-runtime implement --report-format json "..." # JSON output
|
|
33
|
+
agent-runtime implement --model claude-sonnet-4 "..." # Specify model
|
|
34
|
+
```
|
|
32
35
|
|
|
33
|
-
|
|
36
|
+
### `agent-runtime audit-implementation` — Verify the integration
|
|
34
37
|
|
|
35
|
-
|
|
38
|
+
After implementation (by the agent or by hand), audit the result:
|
|
36
39
|
|
|
37
|
-
|
|
38
|
-
-
|
|
39
|
-
|
|
40
|
-
- what handoff shape is expected
|
|
41
|
-
- which workflow steps are allowed
|
|
42
|
-
- what validation must happen before the next step
|
|
43
|
-
- which guardrails apply
|
|
40
|
+
```bash
|
|
41
|
+
agent-runtime audit-implementation --adapter claude ./my-tool
|
|
42
|
+
```
|
|
44
43
|
|
|
45
|
-
|
|
44
|
+
The auditor checks all three layers in parallel:
|
|
46
45
|
|
|
47
|
-
|
|
46
|
+
| Layer | What it checks |
|
|
47
|
+
|-------|----------------|
|
|
48
|
+
| **DSL** | version:1, system block, agent/task/workflow cross-references, guardrails |
|
|
49
|
+
| **Runtime** | `runTask`/`runWorkflow` usage (no `adapter.send()`), dynamic imports, exit codes 11/12, registry passing |
|
|
50
|
+
| **CLI contract** | Standard options (--adapter, --model, --dry-run, --fail-on, --output, --report-format), x-agent metadata, exit codes |
|
|
51
|
+
| **Architecture** | Module structure, dry-run behavior, context size cap, no direct SDK imports |
|
|
48
52
|
|
|
49
|
-
|
|
53
|
+
The four layer checks run concurrently via the DAG workflow scheduler, then merge into a single structured report:
|
|
50
54
|
|
|
51
|
-
|
|
55
|
+
```bash
|
|
56
|
+
agent-runtime audit-implementation --focus dsl ./my-tool # Check one layer
|
|
57
|
+
agent-runtime audit-implementation --fail-on warning ./my-tool # Strict mode
|
|
58
|
+
agent-runtime audit-implementation --report-format json ./my-tool # JSON output
|
|
59
|
+
agent-runtime audit-implementation --output report.json ./my-tool # Write to file
|
|
60
|
+
```
|
|
52
61
|
|
|
53
|
-
|
|
54
|
-
- accepts workflow invocations from TypeScript or CLI
|
|
55
|
-
- resolves the DSL-defined workflow, task, agent, and handoff contracts
|
|
56
|
-
- builds an SDK execution request
|
|
57
|
-
- calls an Agent SDK through an adapter
|
|
58
|
-
- validates the returned handoff
|
|
59
|
-
- returns a structured workflow result
|
|
62
|
+
Exit codes: `0` = no findings above threshold, `10` = findings detected, `12` = adapter error.
|
|
60
63
|
|
|
61
|
-
|
|
64
|
+
### Why use the built-in agents?
|
|
62
65
|
|
|
63
|
-
|
|
66
|
+
Hand-writing the integration code for `agent-contracts` + `agent-contracts-runtime` + `cli-contracts` is error-prone. Common mistakes include:
|
|
64
67
|
|
|
65
|
-
|
|
68
|
+
- Calling `adapter.send()` directly instead of `runTask()`/`runWorkflow()`
|
|
69
|
+
- Missing standard CLI options or exit codes
|
|
70
|
+
- Forgetting `x-agent` metadata
|
|
71
|
+
- Incorrect adapter construction (e.g., `new CursorSdkAdapter()` instead of `CursorSdkAdapter.create()`)
|
|
72
|
+
- Static imports instead of dynamic imports for graceful degradation
|
|
66
73
|
|
|
67
|
-
|
|
74
|
+
The implementation agent has all of these patterns embedded in its DSL definition. The audit agent detects violations. Together they form a closed loop: implement correctly, then verify.
|
|
68
75
|
|
|
69
|
-
|
|
76
|
+
---
|
|
70
77
|
|
|
71
|
-
|
|
72
|
-
- handoff schemas should be generated and validated
|
|
73
|
-
- workflow steps should come from DSL, not scattered program code
|
|
74
|
-
- different SDK adapters should run the same contract
|
|
75
|
-
- application code should call business-level workflows, not low-level agent prompts
|
|
78
|
+
## Overview
|
|
76
79
|
|
|
77
|
-
|
|
80
|
+
`agent-contracts` defines business-level agent behavior in DSL: agent roles, task boundaries, workflows, handoff schemas, validations, and guardrails.
|
|
78
81
|
|
|
79
|
-
|
|
80
|
-
// resolve prompt
|
|
81
|
-
// choose agent
|
|
82
|
-
// build context
|
|
83
|
-
// call SDK
|
|
84
|
-
// parse output
|
|
85
|
-
// validate schema
|
|
86
|
-
// retry on malformed output
|
|
87
|
-
// route to next task
|
|
88
|
-
```
|
|
82
|
+
`agent-contracts-runtime` makes those DSL-defined workflows callable from ordinary TypeScript code.
|
|
89
83
|
|
|
90
|
-
|
|
84
|
+
It sits between your program and Agent SDKs:
|
|
91
85
|
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
86
|
+
```
|
|
87
|
+
TypeScript program
|
|
88
|
+
↓
|
|
89
|
+
WorkflowInvocation
|
|
90
|
+
↓
|
|
91
|
+
agent-contracts-runtime
|
|
92
|
+
↓
|
|
93
|
+
DSL-derived contracts
|
|
94
|
+
↓
|
|
95
|
+
Agent SDK adapter
|
|
96
|
+
↓
|
|
97
|
+
Cursor / Claude / OpenAI Agents SDK / custom runner
|
|
102
98
|
```
|
|
103
99
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
Prompts and SDK calls are execution details.
|
|
107
|
-
|
|
108
|
-
The reusable behavior of an agent team belongs in the DSL:
|
|
109
|
-
|
|
110
|
-
- agent roles and responsibilities
|
|
111
|
-
- task boundaries
|
|
112
|
-
- delegation rules
|
|
113
|
-
- workflow steps
|
|
114
|
-
- handoff schemas
|
|
115
|
-
- validations
|
|
116
|
-
- guardrails
|
|
117
|
-
|
|
118
|
-
`agent-contracts-runtime` executes those generated contracts instead of duplicating the workflow logic in application code.
|
|
100
|
+
Agent SDKs execute LLM agents. `agent-contracts-runtime` lets application code invoke reusable, DSL-defined agent workflows without hand-writing SDK-specific orchestration for each workflow.
|
|
119
101
|
|
|
120
102
|
## Install
|
|
121
103
|
|
|
@@ -127,20 +109,17 @@ npm install -D agent-contracts
|
|
|
127
109
|
## Quick start
|
|
128
110
|
|
|
129
111
|
```bash
|
|
130
|
-
# 1.
|
|
131
|
-
agent-runtime
|
|
112
|
+
# 1. Add LLM commands to your CLI tool (the agent does the work)
|
|
113
|
+
agent-runtime implement --adapter claude --project-dir ./my-tool \
|
|
114
|
+
"Add an audit command for code quality"
|
|
132
115
|
|
|
133
|
-
# 2.
|
|
134
|
-
agent-
|
|
135
|
-
agent-contracts lint --strict
|
|
116
|
+
# 2. Audit the generated integration
|
|
117
|
+
agent-runtime audit-implementation --adapter claude ./my-tool
|
|
136
118
|
|
|
137
|
-
# 3.
|
|
119
|
+
# 3. Or set up manually: initialize, generate, run
|
|
120
|
+
agent-runtime init
|
|
138
121
|
agent-runtime generate
|
|
139
|
-
|
|
140
|
-
# 4. Run a workflow
|
|
141
122
|
agent-runtime run feature-implement "Add login endpoint with JWT"
|
|
142
|
-
|
|
143
|
-
# 5. Verify project setup
|
|
144
123
|
agent-runtime doctor
|
|
145
124
|
```
|
|
146
125
|
|
|
@@ -478,6 +457,8 @@ Each step result includes task ID, outcome status, validation errors, follow-up
|
|
|
478
457
|
|
|
479
458
|
| Command | Description |
|
|
480
459
|
|---------|-------------|
|
|
460
|
+
| `agent-runtime implement <description>` | Add LLM-powered commands to a CLI tool (agentic) |
|
|
461
|
+
| `agent-runtime audit-implementation [dir]` | Audit an LLM integration for pattern conformance (agentic) |
|
|
481
462
|
| `agent-runtime init` | Initialize runtime scaffolding |
|
|
482
463
|
| `agent-runtime generate` | Generate contracts and hooks from DSL |
|
|
483
464
|
| `agent-runtime run <workflow> <request>` | Execute a workflow |
|