agent-contracts-runtime 0.31.3 → 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 +5 -3
- 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/dsl/tasks.yaml
ADDED
|
@@ -0,0 +1,635 @@
|
|
|
1
|
+
implement-llm-feature:
|
|
2
|
+
description: |
|
|
3
|
+
Implement LLM-powered commands in a target CLI tool using the
|
|
4
|
+
agent-contracts + agent-contracts-runtime + cli-contracts stack.
|
|
5
|
+
|
|
6
|
+
## Implementation Procedure
|
|
7
|
+
|
|
8
|
+
### Step 1: Project Analysis
|
|
9
|
+
|
|
10
|
+
Read these files from the target project:
|
|
11
|
+
- cli-contract.yaml — existing commands, components/schemas, x-agent usage
|
|
12
|
+
- package.json — dependencies, scripts, bin entries, type:"module" check
|
|
13
|
+
- tsconfig.json — module resolution, paths, outDir
|
|
14
|
+
- src/ directory structure — understand existing command handler pattern
|
|
15
|
+
|
|
16
|
+
Determine:
|
|
17
|
+
- Which LLM commands to add (audit / propose / explain)
|
|
18
|
+
- What domain-specific context each command needs
|
|
19
|
+
- What structured output schema each command returns
|
|
20
|
+
- Whether the project already has agent-contracts integration
|
|
21
|
+
|
|
22
|
+
### Step 2: Install Dependencies
|
|
23
|
+
|
|
24
|
+
Add to package.json devDependencies:
|
|
25
|
+
- agent-contracts: ^0.32.0
|
|
26
|
+
- agent-contracts-runtime: ^0.31.0
|
|
27
|
+
- zod: ^4.0.0
|
|
28
|
+
|
|
29
|
+
Add optional peerDependencies for SDK packages:
|
|
30
|
+
- @anthropic-ai/claude-agent-sdk: >=0.2.0
|
|
31
|
+
- @openai/agents: >=0.10.0
|
|
32
|
+
- @google/genai: >=2.0.0
|
|
33
|
+
- @cursor/sdk (no version constraint)
|
|
34
|
+
|
|
35
|
+
### Step 3: Create DSL Definitions
|
|
36
|
+
|
|
37
|
+
Create directory structure:
|
|
38
|
+
|
|
39
|
+
dsl/
|
|
40
|
+
├── {project}-dsl.yaml
|
|
41
|
+
├── agent-runtime.config.yaml
|
|
42
|
+
├── agents/
|
|
43
|
+
│ └── {agent-name}.yaml
|
|
44
|
+
├── tasks.yaml
|
|
45
|
+
└── handoff-types.yaml
|
|
46
|
+
|
|
47
|
+
**Main DSL entry** (`dsl/{project}-dsl.yaml`):
|
|
48
|
+
|
|
49
|
+
version: 1
|
|
50
|
+
system:
|
|
51
|
+
id: {project}
|
|
52
|
+
name: "{Project} Agent System"
|
|
53
|
+
default_workflow_order:
|
|
54
|
+
- {workflow-ids}
|
|
55
|
+
agents: { $ref: "./agents/" }
|
|
56
|
+
tasks: { $ref: "./tasks.yaml" }
|
|
57
|
+
handoff_types: { $ref: "./handoff-types.yaml" }
|
|
58
|
+
guardrails:
|
|
59
|
+
output-schema-conformance:
|
|
60
|
+
description: ...
|
|
61
|
+
scope: { agents: [...], tasks: [...] }
|
|
62
|
+
rationale: ...
|
|
63
|
+
guardrail_policies:
|
|
64
|
+
{domain}-safety-policy:
|
|
65
|
+
rules:
|
|
66
|
+
- guardrail: output-schema-conformance
|
|
67
|
+
severity: critical
|
|
68
|
+
action: block
|
|
69
|
+
workflow:
|
|
70
|
+
{workflow-id}:
|
|
71
|
+
description: ...
|
|
72
|
+
trigger: cli-command
|
|
73
|
+
entry_conditions: [...]
|
|
74
|
+
steps:
|
|
75
|
+
- type: delegate
|
|
76
|
+
task: {task-id}
|
|
77
|
+
from_agent: {agent-id}
|
|
78
|
+
|
|
79
|
+
**Agent definition** (`dsl/agents/{agent-name}.yaml`):
|
|
80
|
+
|
|
81
|
+
{agent-name}:
|
|
82
|
+
role_name: "{Role Name}"
|
|
83
|
+
purpose: >-
|
|
84
|
+
Domain-specific purpose describing what the agent knows
|
|
85
|
+
and what it can do that static rules cannot.
|
|
86
|
+
mode: read-only
|
|
87
|
+
can_read_artifacts: []
|
|
88
|
+
can_write_artifacts: []
|
|
89
|
+
can_invoke_agents: []
|
|
90
|
+
can_execute_tools: []
|
|
91
|
+
can_return_handoffs: [{result-handoff-ids}]
|
|
92
|
+
responsibilities: [...]
|
|
93
|
+
constraints: [...]
|
|
94
|
+
rules:
|
|
95
|
+
- id: "R-{PREFIX}-001"
|
|
96
|
+
description: ...
|
|
97
|
+
severity: mandatory
|
|
98
|
+
escalation_criteria:
|
|
99
|
+
- condition: ...
|
|
100
|
+
action: stop_and_report
|
|
101
|
+
|
|
102
|
+
**Tasks** (`dsl/tasks.yaml`):
|
|
103
|
+
|
|
104
|
+
{task-id}:
|
|
105
|
+
description: ...
|
|
106
|
+
target_agent: {agent-name}
|
|
107
|
+
allowed_from_agents: [{agent-name}]
|
|
108
|
+
workflow: {workflow-id}
|
|
109
|
+
input_artifacts: []
|
|
110
|
+
invocation_handoff: {request-handoff}
|
|
111
|
+
result_handoff: {result-handoff}
|
|
112
|
+
responsibilities: [...]
|
|
113
|
+
completion_criteria: [...]
|
|
114
|
+
|
|
115
|
+
**Handoff types** (`dsl/handoff-types.yaml`):
|
|
116
|
+
Use AgentAuditResult shape as the base for result types:
|
|
117
|
+
|
|
118
|
+
{result-handoff}:
|
|
119
|
+
version: 1
|
|
120
|
+
description: ...
|
|
121
|
+
schema:
|
|
122
|
+
type: object
|
|
123
|
+
required: [summary, riskLevel, findings]
|
|
124
|
+
properties:
|
|
125
|
+
summary: { type: string }
|
|
126
|
+
riskLevel:
|
|
127
|
+
type: string
|
|
128
|
+
enum: [low, medium, high, critical]
|
|
129
|
+
findings:
|
|
130
|
+
type: array
|
|
131
|
+
items:
|
|
132
|
+
type: object
|
|
133
|
+
required: [severity, category, message]
|
|
134
|
+
properties:
|
|
135
|
+
id: { type: string }
|
|
136
|
+
severity:
|
|
137
|
+
type: string
|
|
138
|
+
enum: [info, warning, error, critical]
|
|
139
|
+
category: { type: string }
|
|
140
|
+
target: { type: string }
|
|
141
|
+
location: { type: string }
|
|
142
|
+
message: { type: string }
|
|
143
|
+
recommendation: { type: string }
|
|
144
|
+
confidence: { type: number, minimum: 0, maximum: 1 }
|
|
145
|
+
recommendedActions:
|
|
146
|
+
type: array
|
|
147
|
+
items:
|
|
148
|
+
type: object
|
|
149
|
+
required: [kind, title]
|
|
150
|
+
properties:
|
|
151
|
+
kind:
|
|
152
|
+
type: string
|
|
153
|
+
enum: [run_command, edit_file, review, confirm, block, ignore]
|
|
154
|
+
title: { type: string }
|
|
155
|
+
command: { type: string }
|
|
156
|
+
target: { type: string }
|
|
157
|
+
rationale: { type: string }
|
|
158
|
+
metadata:
|
|
159
|
+
type: object
|
|
160
|
+
properties:
|
|
161
|
+
tool: { type: string }
|
|
162
|
+
command: { type: string }
|
|
163
|
+
version: { type: string }
|
|
164
|
+
generatedAt: { type: string }
|
|
165
|
+
adapter: { type: string }
|
|
166
|
+
model: { type: string }
|
|
167
|
+
|
|
168
|
+
Domain-specific result types add properties alongside the base fields.
|
|
169
|
+
|
|
170
|
+
**Runtime config** (`dsl/agent-runtime.config.yaml`):
|
|
171
|
+
|
|
172
|
+
dsl: ./{project}-dsl.yaml
|
|
173
|
+
generated_dir: ../src/generated/dsl
|
|
174
|
+
|
|
175
|
+
### Step 4: Generate TypeScript Contracts
|
|
176
|
+
|
|
177
|
+
Add to package.json scripts:
|
|
178
|
+
|
|
179
|
+
"dsl:generate": "agent-runtime generate --config dsl/agent-runtime.config.yaml"
|
|
180
|
+
|
|
181
|
+
Run: npm run dsl:generate
|
|
182
|
+
|
|
183
|
+
This produces src/generated/dsl/ containing:
|
|
184
|
+
- agents.ts (AgentContract interface + agentRegistry)
|
|
185
|
+
- tasks.ts (TaskContract interface + taskRegistry)
|
|
186
|
+
- workflows.ts (WorkflowContract + workflowRegistry)
|
|
187
|
+
- handoffs.ts (Zod schemas + handoffSchemas + factory functions)
|
|
188
|
+
- index.ts (barrel re-exports)
|
|
189
|
+
|
|
190
|
+
### Step 5: Implement src/agents/ Module
|
|
191
|
+
|
|
192
|
+
**src/agents/types.ts**:
|
|
193
|
+
|
|
194
|
+
import type { {ResultType} } from "../generated/dsl/handoffs.js";
|
|
195
|
+
|
|
196
|
+
export type TaskId = "{task-1}" | "{task-2}" | ...;
|
|
197
|
+
|
|
198
|
+
export interface AgentConfig {
|
|
199
|
+
adapter?: string;
|
|
200
|
+
model?: string;
|
|
201
|
+
temperature?: number;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
export interface AgentOptions {
|
|
205
|
+
dryRun?: boolean;
|
|
206
|
+
failOn?: "warning" | "error" | "critical";
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
export interface AgentRunResult {
|
|
210
|
+
taskId: TaskId;
|
|
211
|
+
data: {ResultType} | null;
|
|
212
|
+
raw: string;
|
|
213
|
+
prompt: string;
|
|
214
|
+
dryRun: boolean;
|
|
215
|
+
status: "success" | "error" | "escalation" | "validation_error";
|
|
216
|
+
errorMessage?: string;
|
|
217
|
+
followUpsUsed: number;
|
|
218
|
+
retriesUsed: number;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
**src/agents/orchestrator.ts**:
|
|
222
|
+
|
|
223
|
+
export const EXIT_RUNTIME_MISSING = 11;
|
|
224
|
+
export const EXIT_ADAPTER_ERROR = 12;
|
|
225
|
+
|
|
226
|
+
async function createAdapter(pkg: string, name: string, config: AgentConfig) {
|
|
227
|
+
switch (name) {
|
|
228
|
+
case "mock": {
|
|
229
|
+
const m = await import(`${pkg}/adapters/mock`);
|
|
230
|
+
return new m.MockAdapter();
|
|
231
|
+
}
|
|
232
|
+
case "cursor": {
|
|
233
|
+
const m = await import(`${pkg}/adapters/cursor-sdk`);
|
|
234
|
+
return m.CursorSdkAdapter.create({ apiKey: process.env.CURSOR_API_KEY, model: config.model });
|
|
235
|
+
}
|
|
236
|
+
case "claude": {
|
|
237
|
+
const m = await import(`${pkg}/adapters/claude-agent-sdk`);
|
|
238
|
+
return new m.ClaudeAgentSdkAdapter({ model: config.model });
|
|
239
|
+
}
|
|
240
|
+
case "openai": {
|
|
241
|
+
const m = await import(`${pkg}/adapters/openai-agents-sdk`);
|
|
242
|
+
return new m.OpenAIAgentsSdkAdapter({ model: config.model });
|
|
243
|
+
}
|
|
244
|
+
case "gemini": {
|
|
245
|
+
const m = await import(`${pkg}/adapters/gemini-sdk`);
|
|
246
|
+
return new m.GeminiSdkAdapter({ apiKey: process.env.GEMINI_API_KEY, model: config.model });
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
export async function runAgentTask(
|
|
252
|
+
userRequest: string, taskId: TaskId, config: AgentConfig, options: AgentOptions,
|
|
253
|
+
): Promise<AgentRunResult> {
|
|
254
|
+
if (options.dryRun) return { taskId, data:null, raw:"", prompt:userRequest, dryRun:true, status:"success", followUpsUsed:0, retriesUsed:0 };
|
|
255
|
+
|
|
256
|
+
const PKG = "agent-contracts-runtime";
|
|
257
|
+
let runTask;
|
|
258
|
+
try { ({ runTask } = await import(PKG)); }
|
|
259
|
+
catch { throw Object.assign(new Error("agent-contracts-runtime not installed"), { exitCode: EXIT_RUNTIME_MISSING }); }
|
|
260
|
+
|
|
261
|
+
let registries;
|
|
262
|
+
try {
|
|
263
|
+
const dsl = await import("../generated/dsl/index.js");
|
|
264
|
+
registries = { agentRegistry: dsl.agentRegistry, taskRegistry: dsl.taskRegistry, handoffSchemas: dsl.handoffSchemas };
|
|
265
|
+
} catch { registries = { agentRegistry:{}, taskRegistry:{}, handoffSchemas:{} }; }
|
|
266
|
+
|
|
267
|
+
const adapter = await createAdapter(PKG, config.adapter ?? "mock", config);
|
|
268
|
+
const result = await runTask(adapter, taskId, { user_request: userRequest }, { maxFollowUps:3, maxRetries:1, ...registries });
|
|
269
|
+
// map result.outcome to AgentRunResult
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
**src/agents/context-builder.ts**:
|
|
273
|
+
|
|
274
|
+
export function build{Command}Context(target, config): string {
|
|
275
|
+
const sections = [];
|
|
276
|
+
sections.push("# {Command} Request");
|
|
277
|
+
sections.push(`## Target\n\n${target}`);
|
|
278
|
+
sections.push("## Instructions\n\n{domain-specific instructions}");
|
|
279
|
+
// Cap total context at 16KB
|
|
280
|
+
return sections.join("\n\n");
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
**src/agents/formatter.ts**:
|
|
284
|
+
|
|
285
|
+
export function computeExitCode(result, options): number {
|
|
286
|
+
if (result.dryRun) return 0;
|
|
287
|
+
if (result.status !== "success") return 1;
|
|
288
|
+
const order = ["info","warning","error","critical"];
|
|
289
|
+
const threshold = order.indexOf(options.failOn ?? "error");
|
|
290
|
+
return result.data.findings.some(f => order.indexOf(f.severity) >= threshold) ? 10 : 0;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
export function formatResultText(result): string { /* severity icons, structured output */ }
|
|
294
|
+
export function formatResultJson(result): string { return JSON.stringify(result.data, null, 2); }
|
|
295
|
+
|
|
296
|
+
### Step 6: Create CLI Command Handlers
|
|
297
|
+
|
|
298
|
+
For each LLM command, create src/commands/{command}.ts:
|
|
299
|
+
|
|
300
|
+
export async function command{Name}(config, target, opts) {
|
|
301
|
+
const context = build{Name}Context(target, config);
|
|
302
|
+
const result = await runAgentTask(context, "{task-id}", agentConfig, agentOpts);
|
|
303
|
+
if (opts.reportFormat === "json") console.log(formatResultJson(result));
|
|
304
|
+
else console.log(formatResultText(result));
|
|
305
|
+
process.exit(computeExitCode(result, opts));
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
Register in the CLI using Commander or the project's existing pattern.
|
|
309
|
+
|
|
310
|
+
### Step 7: Update cli-contract.yaml
|
|
311
|
+
|
|
312
|
+
Add each LLM command with standard options and x-agent metadata:
|
|
313
|
+
|
|
314
|
+
{command-name}:
|
|
315
|
+
summary: "{Command summary}"
|
|
316
|
+
arguments: [...]
|
|
317
|
+
options:
|
|
318
|
+
- name: adapter
|
|
319
|
+
schema: { type: string, enum: [mock, cursor, claude, openai, gemini] }
|
|
320
|
+
- name: model
|
|
321
|
+
schema: { type: string }
|
|
322
|
+
- name: dry-run
|
|
323
|
+
schema: { type: boolean, default: false }
|
|
324
|
+
- name: fail-on
|
|
325
|
+
schema: { type: string, enum: [warning, error, critical], default: error }
|
|
326
|
+
- name: output
|
|
327
|
+
aliases: [o]
|
|
328
|
+
schema: { type: string }
|
|
329
|
+
file: { mode: write }
|
|
330
|
+
- name: report-format
|
|
331
|
+
schema: { type: string, enum: [json, text, yaml], default: json }
|
|
332
|
+
x-agent:
|
|
333
|
+
riskLevel: low
|
|
334
|
+
requiresConfirmation: false
|
|
335
|
+
idempotent: true
|
|
336
|
+
sideEffects: [network]
|
|
337
|
+
sideEffectNote: >-
|
|
338
|
+
Network calls to LLM provider when adapter is not mock.
|
|
339
|
+
Filesystem write only when --output is specified.
|
|
340
|
+
safeDryRunOption: dry-run
|
|
341
|
+
expectedDurationMs: 120000
|
|
342
|
+
retryableExitCodes: [1, 12]
|
|
343
|
+
exits:
|
|
344
|
+
'0': { description: "No blocking findings.", stdout: { format: json, schema: { $ref: '...' } } }
|
|
345
|
+
'1': { description: "General error.", stderr: { format: text } }
|
|
346
|
+
'3': { description: "Input validation failed.", stderr: { format: json } }
|
|
347
|
+
'10': { description: "Blocking findings detected.", stdout: { format: json, schema: { $ref: '...' } } }
|
|
348
|
+
'11': { description: "Runtime not installed.", stderr: { format: json } }
|
|
349
|
+
'12': { description: "Adapter error.", stderr: { format: json } }
|
|
350
|
+
|
|
351
|
+
Add AgentAuditResult, AgentFinding, AgentRecommendedAction, AgentEvidence
|
|
352
|
+
to components/schemas if not already present.
|
|
353
|
+
|
|
354
|
+
### Step 8: Update README
|
|
355
|
+
|
|
356
|
+
Add "Agent-Native Toolchain" section after mechanical features:
|
|
357
|
+
- Intro: tool encapsulates domain-specific semantic reasoning
|
|
358
|
+
- Deterministic checks first, then semantic audit
|
|
359
|
+
- Structured findings (AgentAuditResult/AgentFinding)
|
|
360
|
+
- LLM Adapter Configuration table
|
|
361
|
+
- Add agent-contracts-runtime, agent-contracts, cli-contracts to Technology Stack
|
|
362
|
+
|
|
363
|
+
target_agent: llm-feature-implementer
|
|
364
|
+
allowed_from_agents:
|
|
365
|
+
- llm-feature-implementer
|
|
366
|
+
workflow: implement-llm-feature
|
|
367
|
+
input_artifacts: []
|
|
368
|
+
invocation_handoff: implement-request
|
|
369
|
+
result_handoff: implementation-result
|
|
370
|
+
|
|
371
|
+
responsibilities:
|
|
372
|
+
- Analyze the target project and determine the right LLM commands to add
|
|
373
|
+
- Create all DSL definition files with correct cross-references
|
|
374
|
+
- Generate TypeScript contracts via agent-runtime generate
|
|
375
|
+
- Implement the complete src/agents/ module following the exact patterns
|
|
376
|
+
- Create CLI command handlers integrating with the project's existing CLI structure
|
|
377
|
+
- Update cli-contract.yaml with proper x-agent metadata and component schemas
|
|
378
|
+
- Ensure the implementation compiles and --dry-run mode works
|
|
379
|
+
|
|
380
|
+
completion_criteria:
|
|
381
|
+
- dsl/ directory contains valid DSL definitions that pass agent-runtime generate
|
|
382
|
+
- agent-runtime.config.yaml points to the DSL with correct generated_dir
|
|
383
|
+
- src/generated/dsl/ contains generated contracts (agentRegistry, taskRegistry, handoffSchemas, workflowRegistry)
|
|
384
|
+
- src/agents/orchestrator.ts uses runTask from agent-contracts-runtime (no direct adapter.send calls)
|
|
385
|
+
- src/agents/orchestrator.ts dynamic-imports the runtime and adapters with correct exit codes (11, 12)
|
|
386
|
+
- src/agents/context-builder.ts caps input at 16KB
|
|
387
|
+
- src/agents/formatter.ts implements computeExitCode with the standard exit code mapping
|
|
388
|
+
- src/commands/ has a handler for each new LLM command
|
|
389
|
+
- cli-contract.yaml has all new commands with --adapter, --model, --dry-run, --fail-on, --output, --report-format options
|
|
390
|
+
- cli-contract.yaml has x-agent metadata on each new command (riskLevel, safeDryRunOption, expectedDurationMs)
|
|
391
|
+
- components/schemas includes AgentAuditResult and related schemas
|
|
392
|
+
- All generated TypeScript compiles without type errors
|
|
393
|
+
- --dry-run returns the constructed prompt without calling the LLM
|
|
394
|
+
|
|
395
|
+
# =============================================================================
|
|
396
|
+
# Audit tasks — parallelized by layer
|
|
397
|
+
# =============================================================================
|
|
398
|
+
|
|
399
|
+
audit-dsl:
|
|
400
|
+
description: |
|
|
401
|
+
Audit the DSL layer of an LLM command integration.
|
|
402
|
+
|
|
403
|
+
Verify these files exist and are well-formed:
|
|
404
|
+
- dsl/{project}-dsl.yaml — must have version:1, system:{id,name},
|
|
405
|
+
agents/tasks/handoff_types via $ref
|
|
406
|
+
- dsl/agents/*.yaml — each agent has role_name, purpose, mode,
|
|
407
|
+
can_read_artifacts:[], can_write_artifacts:[], responsibilities,
|
|
408
|
+
constraints, rules with R-PREFIX-NNN
|
|
409
|
+
- dsl/tasks.yaml — target_agent, workflow, result_handoff all
|
|
410
|
+
cross-reference valid IDs
|
|
411
|
+
- dsl/handoff-types.yaml — version:1, schema with JSON Schema,
|
|
412
|
+
result types follow AgentAuditResult shape
|
|
413
|
+
- dsl/agent-runtime.config.yaml — dsl and generated_dir fields
|
|
414
|
+
|
|
415
|
+
Severity classification:
|
|
416
|
+
- critical: missing version:1 or system block (generator will fail)
|
|
417
|
+
- critical: task references non-existent agent or workflow
|
|
418
|
+
- error: agent missing constraints or rules
|
|
419
|
+
- error: handoff schema not following AgentAuditResult shape
|
|
420
|
+
- warning: missing guardrails or guardrail_policies
|
|
421
|
+
- warning: agent has no escalation_criteria
|
|
422
|
+
|
|
423
|
+
Category vocabulary: dsl-structure, dsl-agent, dsl-task,
|
|
424
|
+
dsl-handoff, dsl-workflow, dsl-guardrail.
|
|
425
|
+
|
|
426
|
+
Output a partial audit-result with findings only from the DSL layer.
|
|
427
|
+
|
|
428
|
+
target_agent: implementation-auditor
|
|
429
|
+
allowed_from_agents:
|
|
430
|
+
- implementation-auditor
|
|
431
|
+
workflow: audit-implementation
|
|
432
|
+
input_artifacts: []
|
|
433
|
+
invocation_handoff: audit-request
|
|
434
|
+
result_handoff: audit-result
|
|
435
|
+
|
|
436
|
+
responsibilities:
|
|
437
|
+
- Check all DSL files for structural correctness
|
|
438
|
+
- Validate cross-references (agent↔task↔workflow↔handoff)
|
|
439
|
+
- Verify guardrails and guardrail_policies
|
|
440
|
+
|
|
441
|
+
completion_criteria:
|
|
442
|
+
- Every dsl/* file checked for required fields
|
|
443
|
+
- Cross-references validated
|
|
444
|
+
- Findings use dsl-* category vocabulary
|
|
445
|
+
|
|
446
|
+
audit-runtime:
|
|
447
|
+
description: |
|
|
448
|
+
Audit the runtime integration layer of an LLM command integration.
|
|
449
|
+
|
|
450
|
+
Scan src/agents/orchestrator.ts (or equivalent runtime module):
|
|
451
|
+
|
|
452
|
+
CRITICAL violations (category: runtime-orchestrator):
|
|
453
|
+
- adapter.send() or adapter.sendExecution() called directly
|
|
454
|
+
- adapter.followUp() called directly
|
|
455
|
+
- Custom adapter class defined (not imported from runtime)
|
|
456
|
+
- runTask/runWorkflow not imported from agent-contracts-runtime
|
|
457
|
+
|
|
458
|
+
ERROR violations (category: runtime-registry):
|
|
459
|
+
- Generated registries not imported from src/generated/dsl/
|
|
460
|
+
- Registries not passed to runTask/runWorkflow options
|
|
461
|
+
- Hard-coded agent/task definitions instead of registry lookup
|
|
462
|
+
|
|
463
|
+
ERROR violations (category: runtime-adapter):
|
|
464
|
+
- Adapter packages imported statically (not dynamic import)
|
|
465
|
+
- Missing exit code 11 when runtime import fails
|
|
466
|
+
- Missing exit code 12 when adapter creation fails
|
|
467
|
+
- CursorSdkAdapter created with constructor (must use static .create())
|
|
468
|
+
|
|
469
|
+
WARNING violations (category: runtime-plugin):
|
|
470
|
+
- Plugin hooks explicitly bypassed or ignored
|
|
471
|
+
|
|
472
|
+
Category vocabulary: runtime-orchestrator, runtime-registry,
|
|
473
|
+
runtime-adapter, runtime-plugin.
|
|
474
|
+
|
|
475
|
+
Output a partial audit-result with findings only from the runtime layer.
|
|
476
|
+
|
|
477
|
+
target_agent: implementation-auditor
|
|
478
|
+
allowed_from_agents:
|
|
479
|
+
- implementation-auditor
|
|
480
|
+
workflow: audit-implementation
|
|
481
|
+
input_artifacts: []
|
|
482
|
+
invocation_handoff: audit-request
|
|
483
|
+
result_handoff: audit-result
|
|
484
|
+
|
|
485
|
+
responsibilities:
|
|
486
|
+
- Scan orchestrator code for direct adapter usage
|
|
487
|
+
- Verify registry imports and passing
|
|
488
|
+
- Check adapter creation patterns and exit codes
|
|
489
|
+
|
|
490
|
+
completion_criteria:
|
|
491
|
+
- All orchestrator files scanned for adapter.send / adapter.followUp
|
|
492
|
+
- Registry usage verified
|
|
493
|
+
- Exit code 11/12 patterns checked
|
|
494
|
+
|
|
495
|
+
audit-cli-contract:
|
|
496
|
+
description: |
|
|
497
|
+
Audit the CLI contract layer of an LLM command integration.
|
|
498
|
+
|
|
499
|
+
Parse cli-contract.yaml and check each LLM command:
|
|
500
|
+
|
|
501
|
+
ERROR: missing standard options (category: cli-contract-options):
|
|
502
|
+
- --adapter, --model, --dry-run, --fail-on, --output, --report-format
|
|
503
|
+
- Using --format instead of --report-format for LLM commands
|
|
504
|
+
|
|
505
|
+
ERROR: missing x-agent metadata (category: cli-contract-xagent):
|
|
506
|
+
- No x-agent block on LLM command
|
|
507
|
+
- Missing riskLevel, safeDryRunOption, or expectedDurationMs
|
|
508
|
+
- Using snake_case instead of camelCase for x-agent fields
|
|
509
|
+
|
|
510
|
+
ERROR: wrong exit codes (category: cli-contract-exits):
|
|
511
|
+
- Missing exit 0/1/3/10/11/12 definitions
|
|
512
|
+
- Exit 10 not defined for finding-based commands
|
|
513
|
+
|
|
514
|
+
WARNING: missing schemas (category: cli-contract-schema):
|
|
515
|
+
- AgentAuditResult not in components/schemas
|
|
516
|
+
- AgentFinding, AgentRecommendedAction, AgentEvidence not defined
|
|
517
|
+
|
|
518
|
+
Category vocabulary: cli-contract-options, cli-contract-xagent,
|
|
519
|
+
cli-contract-exits, cli-contract-schema.
|
|
520
|
+
|
|
521
|
+
Output a partial audit-result with findings only from the CLI contract layer.
|
|
522
|
+
|
|
523
|
+
target_agent: implementation-auditor
|
|
524
|
+
allowed_from_agents:
|
|
525
|
+
- implementation-auditor
|
|
526
|
+
workflow: audit-implementation
|
|
527
|
+
input_artifacts: []
|
|
528
|
+
invocation_handoff: audit-request
|
|
529
|
+
result_handoff: audit-result
|
|
530
|
+
|
|
531
|
+
responsibilities:
|
|
532
|
+
- Check each LLM command for standard options
|
|
533
|
+
- Verify x-agent metadata fields and casing
|
|
534
|
+
- Validate exit code definitions
|
|
535
|
+
- Check components/schemas for canonical types
|
|
536
|
+
|
|
537
|
+
completion_criteria:
|
|
538
|
+
- Every LLM command checked for all 6 standard options
|
|
539
|
+
- x-agent metadata validated on every LLM command
|
|
540
|
+
- Exit codes verified against convention
|
|
541
|
+
- Schema completeness checked
|
|
542
|
+
|
|
543
|
+
audit-architecture:
|
|
544
|
+
description: |
|
|
545
|
+
Audit the architecture and module structure of an LLM command integration.
|
|
546
|
+
|
|
547
|
+
Verify module structure (category: architecture-modules):
|
|
548
|
+
- src/agents/types.ts exists with TaskId, AgentConfig, AgentOptions, AgentRunResult
|
|
549
|
+
- src/agents/orchestrator.ts exists
|
|
550
|
+
- src/agents/context-builder.ts exists
|
|
551
|
+
- src/agents/formatter.ts exists with computeExitCode
|
|
552
|
+
|
|
553
|
+
Verify behavior (category: architecture-dry-run):
|
|
554
|
+
- --dry-run path returns the constructed prompt without calling the adapter
|
|
555
|
+
- buildTaskPrompt is used (not a placeholder string)
|
|
556
|
+
|
|
557
|
+
Verify patterns (category: architecture-context-builder):
|
|
558
|
+
- Context builder has size cap (16KB or similar)
|
|
559
|
+
|
|
560
|
+
Scan for direct SDK imports (category: architecture-modules):
|
|
561
|
+
- @anthropic-ai/sdk or @anthropic-ai/claude-agent-sdk imported
|
|
562
|
+
outside src/agents/orchestrator.ts or adapter files
|
|
563
|
+
- openai or @openai/agents imported outside adapters
|
|
564
|
+
- @google/genai imported outside adapters
|
|
565
|
+
- @cursor/sdk imported outside adapters
|
|
566
|
+
|
|
567
|
+
Category vocabulary: architecture-modules, architecture-dry-run,
|
|
568
|
+
architecture-context-builder, architecture-formatter.
|
|
569
|
+
|
|
570
|
+
Output a partial audit-result with findings only from the architecture layer.
|
|
571
|
+
|
|
572
|
+
target_agent: implementation-auditor
|
|
573
|
+
allowed_from_agents:
|
|
574
|
+
- implementation-auditor
|
|
575
|
+
workflow: audit-implementation
|
|
576
|
+
input_artifacts: []
|
|
577
|
+
invocation_handoff: audit-request
|
|
578
|
+
result_handoff: audit-result
|
|
579
|
+
|
|
580
|
+
responsibilities:
|
|
581
|
+
- Verify module structure
|
|
582
|
+
- Check dry-run behavior
|
|
583
|
+
- Validate context size cap
|
|
584
|
+
- Scan for direct SDK imports
|
|
585
|
+
|
|
586
|
+
completion_criteria:
|
|
587
|
+
- Module structure verified
|
|
588
|
+
- Dry-run behavior confirmed
|
|
589
|
+
- No direct SDK imports outside adapter files
|
|
590
|
+
|
|
591
|
+
# =============================================================================
|
|
592
|
+
# Audit merge — aggregates parallel audit results
|
|
593
|
+
# =============================================================================
|
|
594
|
+
|
|
595
|
+
audit-merge:
|
|
596
|
+
description: |
|
|
597
|
+
Merge the partial audit results from the four parallel layer audits
|
|
598
|
+
(DSL, runtime, CLI contract, architecture) into a single unified
|
|
599
|
+
audit-result.
|
|
600
|
+
|
|
601
|
+
The prior_context contains the JSON output from each completed
|
|
602
|
+
audit step. Parse each one, combine all findings into a single
|
|
603
|
+
array, deduplicate by (target + message), assign sequential IDs
|
|
604
|
+
(F-001, F-002, ...), derive the overall riskLevel from the worst
|
|
605
|
+
finding severity, and produce prioritized recommendedActions.
|
|
606
|
+
|
|
607
|
+
Merging rules:
|
|
608
|
+
- Collect all findings from all layer results
|
|
609
|
+
- Sort: critical first, then error, warning, info
|
|
610
|
+
- Assign sequential IDs: F-001, F-002, ...
|
|
611
|
+
- Deduplicate: if two findings have the same target and message, keep one
|
|
612
|
+
- Derive riskLevel: any critical → critical, any error → high,
|
|
613
|
+
any warning → medium, info only → low
|
|
614
|
+
- Merge recommendedActions from all layers, deduplicate by title
|
|
615
|
+
- Set metadata: { tool: "agent-runtime", command: "audit-implementation" }
|
|
616
|
+
|
|
617
|
+
target_agent: implementation-auditor
|
|
618
|
+
allowed_from_agents:
|
|
619
|
+
- implementation-auditor
|
|
620
|
+
workflow: audit-implementation
|
|
621
|
+
input_artifacts: []
|
|
622
|
+
invocation_handoff: audit-request
|
|
623
|
+
result_handoff: audit-result
|
|
624
|
+
|
|
625
|
+
responsibilities:
|
|
626
|
+
- Parse prior_context JSON from each layer audit step
|
|
627
|
+
- Merge and deduplicate findings
|
|
628
|
+
- Derive overall riskLevel
|
|
629
|
+
- Produce a single coherent summary paragraph
|
|
630
|
+
|
|
631
|
+
completion_criteria:
|
|
632
|
+
- All findings from all layers included
|
|
633
|
+
- No duplicate findings
|
|
634
|
+
- riskLevel correctly derived from worst finding
|
|
635
|
+
- Summary paragraph covers all audited layers
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agent-contracts-runtime",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.32.1",
|
|
4
4
|
"description": "Runtime bridge for executing agent-contracts workflows on Agent SDKs",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
"files": [
|
|
42
42
|
"dist",
|
|
43
43
|
"templates",
|
|
44
|
+
"dsl",
|
|
44
45
|
"docs",
|
|
45
46
|
"cli-contract.yaml",
|
|
46
47
|
"README.md",
|
|
@@ -48,6 +49,7 @@
|
|
|
48
49
|
],
|
|
49
50
|
"scripts": {
|
|
50
51
|
"generate": "cli-contracts generate",
|
|
52
|
+
"generate:builtin": "npx agent-runtime generate -c dsl/agent-runtime.config.yaml",
|
|
51
53
|
"build": "npm run generate && tsup",
|
|
52
54
|
"typecheck": "tsc --noEmit",
|
|
53
55
|
"test": "vitest run",
|
|
@@ -87,7 +89,7 @@
|
|
|
87
89
|
"node": ">=22.0.0"
|
|
88
90
|
},
|
|
89
91
|
"dependencies": {
|
|
90
|
-
"agent-contracts": "^0.
|
|
92
|
+
"agent-contracts": "^0.32.0",
|
|
91
93
|
"commander": "^12.1.0",
|
|
92
94
|
"dotenv": "^17.4.2",
|
|
93
95
|
"handlebars": "^4.7.9",
|
|
@@ -100,7 +102,7 @@
|
|
|
100
102
|
"@google/genai": "^2.0.1",
|
|
101
103
|
"@openai/agents": "^0.11.1",
|
|
102
104
|
"@types/node": "^25.6.0",
|
|
103
|
-
"cli-contracts": "^0.
|
|
105
|
+
"cli-contracts": "^0.31.0",
|
|
104
106
|
"tsup": "^8.5.0",
|
|
105
107
|
"typescript": "^5.8.3",
|
|
106
108
|
"vitest": "^4.1.7"
|