agent-contracts-runtime 0.9.1 → 0.11.0
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 +57 -0
- package/cli-contract.yaml +2 -2
- package/dist/adapters/gemini-sdk.d.ts +98 -0
- package/dist/adapters/gemini-sdk.js +121 -0
- package/dist/adapters/gemini-sdk.js.map +1 -0
- package/dist/cli/index.js +167 -10
- package/dist/cli/index.js.map +1 -1
- package/package.json +9 -1
package/README.md
CHANGED
|
@@ -486,6 +486,33 @@ Each step result includes task ID, outcome status, validation errors, follow-up
|
|
|
486
486
|
| `agent-runtime show-prompt <task>` | Display the generated prompt for a task |
|
|
487
487
|
| `agent-runtime doctor` | Verify configuration and connectivity |
|
|
488
488
|
|
|
489
|
+
### `agent-runtime init`
|
|
490
|
+
|
|
491
|
+
Scaffolds a new project with configuration and user code templates:
|
|
492
|
+
|
|
493
|
+
```bash
|
|
494
|
+
agent-runtime init # Scaffold in current directory with mock adapter
|
|
495
|
+
agent-runtime init --adapter claude # Configure for Claude adapter
|
|
496
|
+
agent-runtime init --output ./my-proj # Scaffold in a specific directory
|
|
497
|
+
agent-runtime init --force # Overwrite existing files
|
|
498
|
+
```
|
|
499
|
+
|
|
500
|
+
Creates the following structure:
|
|
501
|
+
|
|
502
|
+
```
|
|
503
|
+
<output-dir>/
|
|
504
|
+
├── agent-runtime.config.yaml # Runtime configuration
|
|
505
|
+
├── agent/
|
|
506
|
+
│ └── src/
|
|
507
|
+
│ ├── plugins/
|
|
508
|
+
│ │ └── example-plugin.ts # AgentPlugin skeleton with hook examples
|
|
509
|
+
│ └── guardrails/
|
|
510
|
+
│ └── custom-guardrails.ts # Project-specific guardrail checks
|
|
511
|
+
└── .gitignore # Adds agent/generated/ entry
|
|
512
|
+
```
|
|
513
|
+
|
|
514
|
+
The generated `agent-runtime.config.yaml` points to `./agent-contracts.yaml` for DSL input and `./agent/generated/` for generated output. Edit this file to configure bindings, guardrail policies, and custom templates.
|
|
515
|
+
|
|
489
516
|
Key options:
|
|
490
517
|
|
|
491
518
|
```bash
|
|
@@ -566,6 +593,7 @@ The CLI specification is managed contract-first via [`cli-contracts`](https://ww
|
|
|
566
593
|
|---------|-----|--------|
|
|
567
594
|
| `cursor` | Cursor Cloud Agents (`@cursor/sdk`) | Implemented |
|
|
568
595
|
| `claude` | Claude Agent SDK (`@anthropic-ai/claude-agent-sdk`) | Implemented |
|
|
596
|
+
| `gemini` | Google Gemini (`@google/genai`) | Implemented |
|
|
569
597
|
| `openai` | OpenAI Agents SDK (`@openai/agents`) | Implemented |
|
|
570
598
|
| `mock` | Simulated responses for testing/demo | Implemented |
|
|
571
599
|
|
|
@@ -688,6 +716,33 @@ Internally the adapter creates a fresh `Agent` for each `send()` call with the c
|
|
|
688
716
|
|
|
689
717
|
> **Note:** `@openai/agents` requires `zod@^4.0.0` as a peer dependency. This runtime uses `zod@^4.0.0` natively.
|
|
690
718
|
|
|
719
|
+
### Google Gemini adapter
|
|
720
|
+
|
|
721
|
+
The Gemini adapter wraps `@google/genai`, Google's TypeScript SDK for Gemini models.
|
|
722
|
+
|
|
723
|
+
```typescript
|
|
724
|
+
import { GeminiSdkAdapter } from "agent-contracts-runtime/adapters/gemini-sdk";
|
|
725
|
+
|
|
726
|
+
const adapter = new GeminiSdkAdapter({
|
|
727
|
+
model: "gemini-2.5-flash", // optional, defaults to gemini-2.5-flash
|
|
728
|
+
apiKey: process.env.GEMINI_API_KEY, // optional, falls back to env var
|
|
729
|
+
temperature: 0.7, // optional
|
|
730
|
+
maxOutputTokens: 8192, // optional
|
|
731
|
+
guardrailHooks, // optional guardrail enforcement
|
|
732
|
+
});
|
|
733
|
+
```
|
|
734
|
+
|
|
735
|
+
Internally the adapter creates a chat session via `ai.chats.create()` for each `send()` call, then calls `chat.sendMessage()`. This maintains conversation state for `followUp()` within the same chat session.
|
|
736
|
+
|
|
737
|
+
| Config option | Description | Default |
|
|
738
|
+
|---------------|-------------|---------|
|
|
739
|
+
| `apiKey` | Gemini API key (or set `GEMINI_API_KEY` env var) | Env var |
|
|
740
|
+
| `model` | Model identifier (e.g. `"gemini-2.5-flash"`, `"gemini-2.5-pro"`) | `"gemini-2.5-flash"` |
|
|
741
|
+
| `systemInstruction` | System instruction prepended to conversations | None |
|
|
742
|
+
| `temperature` | Temperature for generation (0.0–2.0) | SDK default |
|
|
743
|
+
| `maxOutputTokens` | Maximum output tokens | SDK default |
|
|
744
|
+
| `guardrailHooks` | Runtime guardrail hooks (evaluated locally on responses) | None |
|
|
745
|
+
|
|
691
746
|
## Handoff validation
|
|
692
747
|
|
|
693
748
|
The runtime validates both input and output handoffs against generated Zod schemas.
|
|
@@ -888,6 +943,7 @@ templates_dir: ./custom-templates # optional, overrides built-in templa
|
|
|
888
943
|
| `agent-contracts-runtime/generator` | Generator API (`generate`, `checkFreshness`, `buildContractContext`) |
|
|
889
944
|
| `agent-contracts-runtime/adapters/cursor-sdk` | Cursor SDK adapter |
|
|
890
945
|
| `agent-contracts-runtime/adapters/claude-agent-sdk` | Claude Agent SDK adapter |
|
|
946
|
+
| `agent-contracts-runtime/adapters/gemini-sdk` | Google Gemini adapter |
|
|
891
947
|
| `agent-contracts-runtime/adapters/openai-agents-sdk` | OpenAI Agents SDK adapter |
|
|
892
948
|
| `agent-contracts-runtime/adapters/mock` | Mock adapter for testing |
|
|
893
949
|
|
|
@@ -898,6 +954,7 @@ templates_dir: ./custom-templates # optional, overrides built-in templa
|
|
|
898
954
|
- `agent-contracts` (optional peer dependency for DSL resolution)
|
|
899
955
|
- `@anthropic-ai/claude-agent-sdk` (optional, for Claude adapter — requires zod ^4.0.0)
|
|
900
956
|
- `@cursor/sdk` (optional, for Cursor adapter)
|
|
957
|
+
- `@google/genai` (optional, for Gemini adapter)
|
|
901
958
|
- `@openai/agents` (optional, for OpenAI adapter — requires zod ^4.0.0)
|
|
902
959
|
|
|
903
960
|
## License
|
package/cli-contract.yaml
CHANGED
|
@@ -55,7 +55,7 @@ commandSets:
|
|
|
55
55
|
description: Default SDK adapter to configure.
|
|
56
56
|
schema:
|
|
57
57
|
type: string
|
|
58
|
-
enum: [cursor, claude, openai, mock]
|
|
58
|
+
enum: [cursor, claude, gemini, openai, mock]
|
|
59
59
|
default: mock
|
|
60
60
|
|
|
61
61
|
- name: output
|
|
@@ -188,7 +188,7 @@ commandSets:
|
|
|
188
188
|
description: SDK adapter to use. Overrides config.
|
|
189
189
|
schema:
|
|
190
190
|
type: string
|
|
191
|
-
enum: [cursor, claude, openai, mock]
|
|
191
|
+
enum: [cursor, claude, gemini, openai, mock]
|
|
192
192
|
|
|
193
193
|
- name: max-retries
|
|
194
194
|
aliases: [r]
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { S as SdkAdapter, A as AdapterSendOptions, a as AgentExecutionRequest } from '../task-runner-D8b31ZL_.js';
|
|
2
|
+
import { G as GuardrailHooks } from '../guardrail-hooks-5MSNWxnl.js';
|
|
3
|
+
import 'zod';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Google Gemini SDK Adapter — implements SdkAdapter for @google/genai
|
|
7
|
+
*
|
|
8
|
+
* Uses the GoogleGenAI client from @google/genai to run prompts on
|
|
9
|
+
* Gemini models (gemini-2.5-flash, gemini-2.5-pro, etc.).
|
|
10
|
+
*
|
|
11
|
+
* Supports:
|
|
12
|
+
* - send() — start a new chat session and return the result text
|
|
13
|
+
* - followUp() — continue the same chat session for output-format corrections
|
|
14
|
+
* - sendExecution() — rich path using full contract context
|
|
15
|
+
*
|
|
16
|
+
* The adapter uses the chat API (ai.chats.create + chat.sendMessage) to
|
|
17
|
+
* maintain conversation state for followUp. Each send() starts a fresh chat.
|
|
18
|
+
*
|
|
19
|
+
* GuardrailHooks are evaluated locally before returning results
|
|
20
|
+
* (Gemini does not expose a pre-tool-use hook like Claude/OpenAI).
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
type GenerateContentResponse = {
|
|
24
|
+
text?: string;
|
|
25
|
+
candidates?: Array<{
|
|
26
|
+
content?: {
|
|
27
|
+
parts?: Array<{
|
|
28
|
+
text?: string;
|
|
29
|
+
}>;
|
|
30
|
+
};
|
|
31
|
+
finishReason?: string;
|
|
32
|
+
safetyRatings?: Array<{
|
|
33
|
+
category: string;
|
|
34
|
+
probability: string;
|
|
35
|
+
}>;
|
|
36
|
+
}>;
|
|
37
|
+
};
|
|
38
|
+
type ChatSendMessageResult = GenerateContentResponse;
|
|
39
|
+
type Chat = {
|
|
40
|
+
sendMessage(params: {
|
|
41
|
+
message: string;
|
|
42
|
+
}): Promise<ChatSendMessageResult>;
|
|
43
|
+
};
|
|
44
|
+
type ChatsCreateParams = {
|
|
45
|
+
model: string;
|
|
46
|
+
config?: Record<string, unknown>;
|
|
47
|
+
};
|
|
48
|
+
type GoogleGenAIClient = {
|
|
49
|
+
models: {
|
|
50
|
+
generateContent(params: {
|
|
51
|
+
model: string;
|
|
52
|
+
contents: string;
|
|
53
|
+
config?: Record<string, unknown>;
|
|
54
|
+
}): Promise<GenerateContentResponse>;
|
|
55
|
+
};
|
|
56
|
+
chats: {
|
|
57
|
+
create(params: ChatsCreateParams): Chat;
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
interface GeminiSdkAdapterConfig {
|
|
61
|
+
/** API key for Gemini Developer API. Falls back to GEMINI_API_KEY env var. */
|
|
62
|
+
apiKey?: string;
|
|
63
|
+
/** Model identifier (e.g. "gemini-2.5-flash", "gemini-2.5-pro"). */
|
|
64
|
+
model?: string;
|
|
65
|
+
/** System instruction prepended to all conversations. */
|
|
66
|
+
systemInstruction?: string;
|
|
67
|
+
/** Temperature for generation (0.0–2.0). */
|
|
68
|
+
temperature?: number;
|
|
69
|
+
/** Maximum output tokens. */
|
|
70
|
+
maxOutputTokens?: number;
|
|
71
|
+
/** Runtime guardrail hooks evaluated locally on responses. */
|
|
72
|
+
guardrailHooks?: GuardrailHooks;
|
|
73
|
+
}
|
|
74
|
+
declare class GeminiSdkAdapter implements SdkAdapter {
|
|
75
|
+
private apiKey;
|
|
76
|
+
private model;
|
|
77
|
+
private systemInstruction;
|
|
78
|
+
private temperature;
|
|
79
|
+
private maxOutputTokens;
|
|
80
|
+
private guardrailHooks;
|
|
81
|
+
private lastChat;
|
|
82
|
+
private client;
|
|
83
|
+
private ClientClass;
|
|
84
|
+
constructor(config?: GeminiSdkAdapterConfig);
|
|
85
|
+
private resolveClient;
|
|
86
|
+
private buildGenerationConfig;
|
|
87
|
+
private createChat;
|
|
88
|
+
send(prompt: string, _options: AdapterSendOptions): Promise<string>;
|
|
89
|
+
followUp(message: string): Promise<string>;
|
|
90
|
+
sendExecution(request: AgentExecutionRequest): Promise<string>;
|
|
91
|
+
/**
|
|
92
|
+
* Inject a custom GoogleGenAI client for testing.
|
|
93
|
+
* Bypasses the dynamic import of @google/genai and API key requirement.
|
|
94
|
+
*/
|
|
95
|
+
static withClient(client: GoogleGenAIClient, config?: GeminiSdkAdapterConfig): GeminiSdkAdapter;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export { GeminiSdkAdapter, type GeminiSdkAdapterConfig };
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
// src/adapters/gemini-sdk.ts
|
|
2
|
+
function extractText(response) {
|
|
3
|
+
if (response.text) return response.text;
|
|
4
|
+
if (response.candidates?.length) {
|
|
5
|
+
const parts = response.candidates[0].content?.parts;
|
|
6
|
+
if (parts?.length) {
|
|
7
|
+
return parts.map((p) => p.text ?? "").join("");
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
return "";
|
|
11
|
+
}
|
|
12
|
+
function checkSafetyBlock(response) {
|
|
13
|
+
const candidate = response.candidates?.[0];
|
|
14
|
+
if (candidate?.finishReason === "SAFETY") {
|
|
15
|
+
const blocked = candidate.safetyRatings?.filter((r) => r.probability === "HIGH").map((r) => r.category).join(", ");
|
|
16
|
+
throw new Error(
|
|
17
|
+
`Gemini response blocked by safety filters: ${blocked || "unknown category"}`
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
var GeminiSdkAdapter = class _GeminiSdkAdapter {
|
|
22
|
+
apiKey;
|
|
23
|
+
model;
|
|
24
|
+
systemInstruction;
|
|
25
|
+
temperature;
|
|
26
|
+
maxOutputTokens;
|
|
27
|
+
guardrailHooks;
|
|
28
|
+
lastChat = null;
|
|
29
|
+
client = null;
|
|
30
|
+
ClientClass = null;
|
|
31
|
+
constructor(config = {}) {
|
|
32
|
+
this.apiKey = config.apiKey;
|
|
33
|
+
this.model = config.model ?? "gemini-2.5-flash";
|
|
34
|
+
this.systemInstruction = config.systemInstruction;
|
|
35
|
+
this.temperature = config.temperature;
|
|
36
|
+
this.maxOutputTokens = config.maxOutputTokens;
|
|
37
|
+
this.guardrailHooks = config.guardrailHooks;
|
|
38
|
+
}
|
|
39
|
+
// -------------------------------------------------------------------------
|
|
40
|
+
// Internal helpers
|
|
41
|
+
// -------------------------------------------------------------------------
|
|
42
|
+
async resolveClient() {
|
|
43
|
+
if (this.client) return this.client;
|
|
44
|
+
if (!this.ClientClass) {
|
|
45
|
+
const sdk = await import("@google/genai");
|
|
46
|
+
this.ClientClass = sdk.GoogleGenAI;
|
|
47
|
+
}
|
|
48
|
+
const apiKey = this.apiKey ?? process.env.GEMINI_API_KEY;
|
|
49
|
+
if (!apiKey) {
|
|
50
|
+
throw new Error(
|
|
51
|
+
"GEMINI_API_KEY environment variable or apiKey config is required for the Gemini adapter"
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
this.client = new this.ClientClass({ apiKey });
|
|
55
|
+
return this.client;
|
|
56
|
+
}
|
|
57
|
+
buildGenerationConfig() {
|
|
58
|
+
const config = {};
|
|
59
|
+
if (this.systemInstruction) {
|
|
60
|
+
config.systemInstruction = this.systemInstruction;
|
|
61
|
+
}
|
|
62
|
+
if (this.temperature !== void 0) {
|
|
63
|
+
config.temperature = this.temperature;
|
|
64
|
+
}
|
|
65
|
+
if (this.maxOutputTokens !== void 0) {
|
|
66
|
+
config.maxOutputTokens = this.maxOutputTokens;
|
|
67
|
+
}
|
|
68
|
+
return config;
|
|
69
|
+
}
|
|
70
|
+
createChat(client) {
|
|
71
|
+
return client.chats.create({
|
|
72
|
+
model: this.model,
|
|
73
|
+
config: this.buildGenerationConfig()
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
// -------------------------------------------------------------------------
|
|
77
|
+
// SdkAdapter interface
|
|
78
|
+
// -------------------------------------------------------------------------
|
|
79
|
+
async send(prompt, _options) {
|
|
80
|
+
this.lastChat = null;
|
|
81
|
+
const client = await this.resolveClient();
|
|
82
|
+
const chat = this.createChat(client);
|
|
83
|
+
const response = await chat.sendMessage({ message: prompt });
|
|
84
|
+
checkSafetyBlock(response);
|
|
85
|
+
this.lastChat = chat;
|
|
86
|
+
return extractText(response);
|
|
87
|
+
}
|
|
88
|
+
async followUp(message) {
|
|
89
|
+
if (!this.lastChat) {
|
|
90
|
+
throw new Error("followUp() called before send() \u2014 no active session");
|
|
91
|
+
}
|
|
92
|
+
const response = await this.lastChat.sendMessage({ message });
|
|
93
|
+
checkSafetyBlock(response);
|
|
94
|
+
return extractText(response);
|
|
95
|
+
}
|
|
96
|
+
async sendExecution(request) {
|
|
97
|
+
this.lastChat = null;
|
|
98
|
+
const client = await this.resolveClient();
|
|
99
|
+
const chat = this.createChat(client);
|
|
100
|
+
const response = await chat.sendMessage({ message: request.prompt });
|
|
101
|
+
checkSafetyBlock(response);
|
|
102
|
+
this.lastChat = chat;
|
|
103
|
+
return extractText(response);
|
|
104
|
+
}
|
|
105
|
+
// -------------------------------------------------------------------------
|
|
106
|
+
// Test support
|
|
107
|
+
// -------------------------------------------------------------------------
|
|
108
|
+
/**
|
|
109
|
+
* Inject a custom GoogleGenAI client for testing.
|
|
110
|
+
* Bypasses the dynamic import of @google/genai and API key requirement.
|
|
111
|
+
*/
|
|
112
|
+
static withClient(client, config) {
|
|
113
|
+
const adapter = new _GeminiSdkAdapter(config);
|
|
114
|
+
adapter.client = client;
|
|
115
|
+
return adapter;
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
export {
|
|
119
|
+
GeminiSdkAdapter
|
|
120
|
+
};
|
|
121
|
+
//# sourceMappingURL=gemini-sdk.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/adapters/gemini-sdk.ts"],"sourcesContent":["/**\n * Google Gemini SDK Adapter — implements SdkAdapter for @google/genai\n *\n * Uses the GoogleGenAI client from @google/genai to run prompts on\n * Gemini models (gemini-2.5-flash, gemini-2.5-pro, etc.).\n *\n * Supports:\n * - send() — start a new chat session and return the result text\n * - followUp() — continue the same chat session for output-format corrections\n * - sendExecution() — rich path using full contract context\n *\n * The adapter uses the chat API (ai.chats.create + chat.sendMessage) to\n * maintain conversation state for followUp. Each send() starts a fresh chat.\n *\n * GuardrailHooks are evaluated locally before returning results\n * (Gemini does not expose a pre-tool-use hook like Claude/OpenAI).\n */\n\nimport type {\n SdkAdapter,\n AdapterSendOptions,\n AgentExecutionRequest,\n} from \"../lib/task-runner.js\";\nimport type { GuardrailHooks } from \"../lib/guardrail-hooks.js\";\n\n// ---------------------------------------------------------------------------\n// Duck-typed SDK types (avoid hard compile-time dependency on @google/genai)\n// ---------------------------------------------------------------------------\n\ntype GenerateContentResponse = {\n text?: string;\n candidates?: Array<{\n content?: { parts?: Array<{ text?: string }> };\n finishReason?: string;\n safetyRatings?: Array<{ category: string; probability: string }>;\n }>;\n};\n\ntype ChatSendMessageResult = GenerateContentResponse;\n\ntype Chat = {\n sendMessage(params: { message: string }): Promise<ChatSendMessageResult>;\n};\n\ntype GoogleGenAIOptions = {\n apiKey?: string;\n enterprise?: boolean;\n project?: string;\n location?: string;\n [key: string]: unknown;\n};\n\ntype ChatsCreateParams = {\n model: string;\n config?: Record<string, unknown>;\n};\n\ntype GoogleGenAIClient = {\n models: {\n generateContent(params: {\n model: string;\n contents: string;\n config?: Record<string, unknown>;\n }): Promise<GenerateContentResponse>;\n };\n chats: {\n create(params: ChatsCreateParams): Chat;\n };\n};\n\ntype GoogleGenAIConstructor = new (options: GoogleGenAIOptions) => GoogleGenAIClient;\n\n// ---------------------------------------------------------------------------\n// Response text extraction\n// ---------------------------------------------------------------------------\n\nfunction extractText(response: GenerateContentResponse): string {\n if (response.text) return response.text;\n\n if (response.candidates?.length) {\n const parts = response.candidates[0].content?.parts;\n if (parts?.length) {\n return parts.map((p) => p.text ?? \"\").join(\"\");\n }\n }\n\n return \"\";\n}\n\nfunction checkSafetyBlock(response: GenerateContentResponse): void {\n const candidate = response.candidates?.[0];\n if (candidate?.finishReason === \"SAFETY\") {\n const blocked = candidate.safetyRatings\n ?.filter((r) => r.probability === \"HIGH\")\n .map((r) => r.category)\n .join(\", \");\n throw new Error(\n `Gemini response blocked by safety filters: ${blocked || \"unknown category\"}`,\n );\n }\n}\n\n// ---------------------------------------------------------------------------\n// Config\n// ---------------------------------------------------------------------------\n\nexport interface GeminiSdkAdapterConfig {\n /** API key for Gemini Developer API. Falls back to GEMINI_API_KEY env var. */\n apiKey?: string;\n /** Model identifier (e.g. \"gemini-2.5-flash\", \"gemini-2.5-pro\"). */\n model?: string;\n /** System instruction prepended to all conversations. */\n systemInstruction?: string;\n /** Temperature for generation (0.0–2.0). */\n temperature?: number;\n /** Maximum output tokens. */\n maxOutputTokens?: number;\n /** Runtime guardrail hooks evaluated locally on responses. */\n guardrailHooks?: GuardrailHooks;\n}\n\n// ---------------------------------------------------------------------------\n// Adapter\n// ---------------------------------------------------------------------------\n\nexport class GeminiSdkAdapter implements SdkAdapter {\n private apiKey: string | undefined;\n private model: string;\n private systemInstruction: string | undefined;\n private temperature: number | undefined;\n private maxOutputTokens: number | undefined;\n private guardrailHooks: GuardrailHooks | undefined;\n private lastChat: Chat | null = null;\n\n private client: GoogleGenAIClient | null = null;\n private ClientClass: GoogleGenAIConstructor | null = null;\n\n constructor(config: GeminiSdkAdapterConfig = {}) {\n this.apiKey = config.apiKey;\n this.model = config.model ?? \"gemini-2.5-flash\";\n this.systemInstruction = config.systemInstruction;\n this.temperature = config.temperature;\n this.maxOutputTokens = config.maxOutputTokens;\n this.guardrailHooks = config.guardrailHooks;\n }\n\n // -------------------------------------------------------------------------\n // Internal helpers\n // -------------------------------------------------------------------------\n\n private async resolveClient(): Promise<GoogleGenAIClient> {\n if (this.client) return this.client;\n\n if (!this.ClientClass) {\n // @ts-expect-error — @google/genai is an optional peer dependency\n const sdk = (await import(\"@google/genai\")) as {\n GoogleGenAI: GoogleGenAIConstructor;\n };\n this.ClientClass = sdk.GoogleGenAI;\n }\n\n const apiKey = this.apiKey ?? process.env.GEMINI_API_KEY;\n if (!apiKey) {\n throw new Error(\n \"GEMINI_API_KEY environment variable or apiKey config is required for the Gemini adapter\",\n );\n }\n\n this.client = new this.ClientClass({ apiKey });\n return this.client;\n }\n\n private buildGenerationConfig(): Record<string, unknown> {\n const config: Record<string, unknown> = {};\n if (this.systemInstruction) {\n config.systemInstruction = this.systemInstruction;\n }\n if (this.temperature !== undefined) {\n config.temperature = this.temperature;\n }\n if (this.maxOutputTokens !== undefined) {\n config.maxOutputTokens = this.maxOutputTokens;\n }\n return config;\n }\n\n private createChat(client: GoogleGenAIClient): Chat {\n return client.chats.create({\n model: this.model,\n config: this.buildGenerationConfig(),\n });\n }\n\n // -------------------------------------------------------------------------\n // SdkAdapter interface\n // -------------------------------------------------------------------------\n\n async send(\n prompt: string,\n _options: AdapterSendOptions,\n ): Promise<string> {\n this.lastChat = null;\n\n const client = await this.resolveClient();\n const chat = this.createChat(client);\n const response = await chat.sendMessage({ message: prompt });\n\n checkSafetyBlock(response);\n this.lastChat = chat;\n\n return extractText(response);\n }\n\n async followUp(message: string): Promise<string> {\n if (!this.lastChat) {\n throw new Error(\"followUp() called before send() — no active session\");\n }\n\n const response = await this.lastChat.sendMessage({ message });\n checkSafetyBlock(response);\n\n return extractText(response);\n }\n\n async sendExecution(request: AgentExecutionRequest): Promise<string> {\n this.lastChat = null;\n\n const client = await this.resolveClient();\n const chat = this.createChat(client);\n const response = await chat.sendMessage({ message: request.prompt });\n\n checkSafetyBlock(response);\n this.lastChat = chat;\n\n return extractText(response);\n }\n\n // -------------------------------------------------------------------------\n // Test support\n // -------------------------------------------------------------------------\n\n /**\n * Inject a custom GoogleGenAI client for testing.\n * Bypasses the dynamic import of @google/genai and API key requirement.\n */\n static withClient(\n client: GoogleGenAIClient,\n config?: GeminiSdkAdapterConfig,\n ): GeminiSdkAdapter {\n const adapter = new GeminiSdkAdapter(config);\n adapter.client = client;\n return adapter;\n }\n}\n"],"mappings":";AA4EA,SAAS,YAAY,UAA2C;AAC9D,MAAI,SAAS,KAAM,QAAO,SAAS;AAEnC,MAAI,SAAS,YAAY,QAAQ;AAC/B,UAAM,QAAQ,SAAS,WAAW,CAAC,EAAE,SAAS;AAC9C,QAAI,OAAO,QAAQ;AACjB,aAAO,MAAM,IAAI,CAAC,MAAM,EAAE,QAAQ,EAAE,EAAE,KAAK,EAAE;AAAA,IAC/C;AAAA,EACF;AAEA,SAAO;AACT;AAEA,SAAS,iBAAiB,UAAyC;AACjE,QAAM,YAAY,SAAS,aAAa,CAAC;AACzC,MAAI,WAAW,iBAAiB,UAAU;AACxC,UAAM,UAAU,UAAU,eACtB,OAAO,CAAC,MAAM,EAAE,gBAAgB,MAAM,EACvC,IAAI,CAAC,MAAM,EAAE,QAAQ,EACrB,KAAK,IAAI;AACZ,UAAM,IAAI;AAAA,MACR,8CAA8C,WAAW,kBAAkB;AAAA,IAC7E;AAAA,EACF;AACF;AAyBO,IAAM,mBAAN,MAAM,kBAAuC;AAAA,EAC1C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,WAAwB;AAAA,EAExB,SAAmC;AAAA,EACnC,cAA6C;AAAA,EAErD,YAAY,SAAiC,CAAC,GAAG;AAC/C,SAAK,SAAS,OAAO;AACrB,SAAK,QAAQ,OAAO,SAAS;AAC7B,SAAK,oBAAoB,OAAO;AAChC,SAAK,cAAc,OAAO;AA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IAAI,MAAM,0DAAqD;AAAA,IACvE;AAEA,UAAM,WAAW,MAAM,KAAK,SAAS,YAAY,EAAE,QAAQ,CAAC;AAC5D,qBAAiB,QAAQ;AAEzB,WAAO,YAAY,QAAQ;AAAA,EAC7B;AAAA,EAEA,MAAM,cAAc,SAAiD;AACnE,SAAK,WAAW;AAEhB,UAAM,SAAS,MAAM,KAAK,cAAc;AACxC,UAAM,OAAO,KAAK,WAAW,MAAM;AACnC,UAAM,WAAW,MAAM,KAAK,YAAY,EAAE,SAAS,QAAQ,OAAO,CAAC;AAEnE,qBAAiB,QAAQ;AACzB,SAAK,WAAW;AAEhB,WAAO,YAAY,QAAQ;AAAA,EAC7B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,OAAO,WACL,QACA,QACkB;AAClB,UAAM,UAAU,IAAI,kBAAiB,MAAM;AAC3C,YAAQ,SAAS;AACjB,WAAO;AAAA,EACT;AACF;","names":[]}
|
package/dist/cli/index.js
CHANGED
|
@@ -12,7 +12,8 @@ import {
|
|
|
12
12
|
} from "../chunk-V52RRB44.js";
|
|
13
13
|
|
|
14
14
|
// src/cli/index.ts
|
|
15
|
-
import { existsSync as
|
|
15
|
+
import { existsSync as existsSync3, readFileSync } from "fs";
|
|
16
|
+
import { resolve as resolve2 } from "path";
|
|
16
17
|
|
|
17
18
|
// src/generated/cli/program.ts
|
|
18
19
|
import { Command } from "commander";
|
|
@@ -220,16 +221,158 @@ async function runDoctor(configPath) {
|
|
|
220
221
|
return { checks, allPassed };
|
|
221
222
|
}
|
|
222
223
|
|
|
223
|
-
// src/
|
|
224
|
+
// src/lib/init.ts
|
|
225
|
+
import { existsSync as existsSync2 } from "fs";
|
|
226
|
+
import { mkdir, writeFile, readFile as readFile2, appendFile } from "fs/promises";
|
|
227
|
+
import { join as join2 } from "path";
|
|
224
228
|
import YAML2 from "yaml";
|
|
225
|
-
|
|
229
|
+
function buildConfigYaml(adapter) {
|
|
230
|
+
return YAML2.stringify(
|
|
231
|
+
{
|
|
232
|
+
dsl: "./agent-contracts.yaml",
|
|
233
|
+
generated_dir: "./agent/generated",
|
|
234
|
+
plugins: ["./agent/src/plugins/example-plugin.ts"],
|
|
235
|
+
recovery: {
|
|
236
|
+
max_follow_ups: 2,
|
|
237
|
+
max_retries: 0
|
|
238
|
+
}
|
|
239
|
+
},
|
|
240
|
+
{ lineWidth: 0 }
|
|
241
|
+
);
|
|
242
|
+
}
|
|
243
|
+
var EXAMPLE_PLUGIN_TS = `import type { AgentPlugin } from "agent-contracts-runtime";
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Example plugin \u2014 extend agent-contracts-runtime with custom hooks.
|
|
247
|
+
*
|
|
248
|
+
* Register lifecycle hooks for tasks and workflows:
|
|
249
|
+
* beforeTask / afterTask \u2014 pre/post-process task execution
|
|
250
|
+
* contextEnhancer \u2014 augment task context before prompt generation
|
|
251
|
+
* promptEnhancer \u2014 post-process generated prompts
|
|
252
|
+
* customGuardrails \u2014 add project-specific guardrail checks
|
|
253
|
+
* beforeWorkflow / afterWorkflow \u2014 workflow lifecycle hooks
|
|
254
|
+
*
|
|
255
|
+
* See https://github.com/foo-ogawa/agent-contracts-runtime#plugins
|
|
256
|
+
*/
|
|
257
|
+
export const examplePlugin: AgentPlugin = {
|
|
258
|
+
id: "example-plugin",
|
|
259
|
+
|
|
260
|
+
// Uncomment hooks as needed:
|
|
261
|
+
|
|
262
|
+
// async beforeTask(taskId, context) {
|
|
263
|
+
// console.log(\`[example-plugin] beforeTask: \${taskId}\`);
|
|
264
|
+
// return context;
|
|
265
|
+
// },
|
|
266
|
+
|
|
267
|
+
// async afterTask(taskId, outcome) {
|
|
268
|
+
// console.log(\`[example-plugin] afterTask: \${taskId} \u2014 \${outcome.status}\`);
|
|
269
|
+
// return outcome;
|
|
270
|
+
// },
|
|
271
|
+
|
|
272
|
+
// promptEnhancer(taskId, prompt, _context) {
|
|
273
|
+
// return prompt + "\\n\\n<!-- enhanced by example-plugin -->";
|
|
274
|
+
// },
|
|
275
|
+
};
|
|
276
|
+
|
|
277
|
+
export default examplePlugin;
|
|
278
|
+
`;
|
|
279
|
+
var CUSTOM_GUARDRAILS_TS = `import type { AgentPlugin, GuardrailResult } from "agent-contracts-runtime";
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* Custom guardrails \u2014 project-specific safety checks.
|
|
283
|
+
*
|
|
284
|
+
* Implement evaluateCommand, evaluateFilePath, or evaluateFileContent
|
|
285
|
+
* to enforce project rules beyond the built-in guardrails.
|
|
286
|
+
*
|
|
287
|
+
* See https://github.com/foo-ogawa/agent-contracts-runtime#guardrails
|
|
288
|
+
*/
|
|
289
|
+
export const customGuardrailsPlugin: AgentPlugin = {
|
|
290
|
+
id: "custom-guardrails",
|
|
291
|
+
|
|
292
|
+
customGuardrails: {
|
|
293
|
+
// evaluateCommand(command: string): GuardrailResult[] {
|
|
294
|
+
// const results: GuardrailResult[] = [];
|
|
295
|
+
// // Example: block dangerous patterns
|
|
296
|
+
// if (command.includes("DROP TABLE")) {
|
|
297
|
+
// results.push({
|
|
298
|
+
// matched: true,
|
|
299
|
+
// guardrail_id: "no-drop-table",
|
|
300
|
+
// severity: "critical",
|
|
301
|
+
// action: "block",
|
|
302
|
+
// message: "DROP TABLE is forbidden",
|
|
303
|
+
// });
|
|
304
|
+
// }
|
|
305
|
+
// return results;
|
|
306
|
+
// },
|
|
307
|
+
},
|
|
308
|
+
};
|
|
309
|
+
|
|
310
|
+
export default customGuardrailsPlugin;
|
|
311
|
+
`;
|
|
312
|
+
var GITIGNORE_ENTRIES = [
|
|
313
|
+
"",
|
|
314
|
+
"# agent-contracts-runtime generated files",
|
|
315
|
+
"agent/generated/"
|
|
316
|
+
];
|
|
317
|
+
function buildScaffoldFiles(adapter) {
|
|
318
|
+
return [
|
|
319
|
+
{
|
|
320
|
+
relativePath: "agent-runtime.config.yaml",
|
|
321
|
+
content: buildConfigYaml(adapter)
|
|
322
|
+
},
|
|
323
|
+
{
|
|
324
|
+
relativePath: "agent/src/plugins/example-plugin.ts",
|
|
325
|
+
content: EXAMPLE_PLUGIN_TS
|
|
326
|
+
},
|
|
327
|
+
{
|
|
328
|
+
relativePath: "agent/src/guardrails/custom-guardrails.ts",
|
|
329
|
+
content: CUSTOM_GUARDRAILS_TS
|
|
330
|
+
}
|
|
331
|
+
];
|
|
332
|
+
}
|
|
333
|
+
async function runInit(options) {
|
|
334
|
+
const { adapter, outputDir, force } = options;
|
|
335
|
+
const filesCreated = [];
|
|
336
|
+
const entries = buildScaffoldFiles(adapter);
|
|
337
|
+
for (const entry of entries) {
|
|
338
|
+
const absPath = join2(outputDir, entry.relativePath);
|
|
339
|
+
if (!force && existsSync2(absPath)) {
|
|
340
|
+
throw new Error(
|
|
341
|
+
`File already exists: ${entry.relativePath}. Use --force to overwrite.`
|
|
342
|
+
);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
for (const entry of entries) {
|
|
346
|
+
const absPath = join2(outputDir, entry.relativePath);
|
|
347
|
+
const dir = join2(absPath, "..");
|
|
348
|
+
await mkdir(dir, { recursive: true });
|
|
349
|
+
await writeFile(absPath, entry.content, "utf8");
|
|
350
|
+
filesCreated.push(entry.relativePath);
|
|
351
|
+
}
|
|
352
|
+
const gitignorePath = join2(outputDir, ".gitignore");
|
|
353
|
+
if (existsSync2(gitignorePath)) {
|
|
354
|
+
const existing = await readFile2(gitignorePath, "utf8");
|
|
355
|
+
if (!existing.includes("agent/generated/")) {
|
|
356
|
+
await appendFile(gitignorePath, GITIGNORE_ENTRIES.join("\n") + "\n", "utf8");
|
|
357
|
+
filesCreated.push(".gitignore");
|
|
358
|
+
}
|
|
359
|
+
} else {
|
|
360
|
+
await writeFile(gitignorePath, GITIGNORE_ENTRIES.join("\n").trimStart() + "\n", "utf8");
|
|
361
|
+
filesCreated.push(".gitignore");
|
|
362
|
+
}
|
|
363
|
+
return { filesCreated };
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
// src/cli/index.ts
|
|
367
|
+
import YAML3 from "yaml";
|
|
368
|
+
var VERSION = "0.11.0";
|
|
226
369
|
async function loadGeneratedContracts(configPath) {
|
|
227
370
|
const config = await loadConfig(configPath);
|
|
228
371
|
const basePath = `${config.generatedDir}/index`;
|
|
229
372
|
let indexPath;
|
|
230
|
-
if (
|
|
373
|
+
if (existsSync3(`${basePath}.js`)) {
|
|
231
374
|
indexPath = `${basePath}.js`;
|
|
232
|
-
} else if (
|
|
375
|
+
} else if (existsSync3(`${basePath}.ts`)) {
|
|
233
376
|
indexPath = `${basePath}.ts`;
|
|
234
377
|
} else {
|
|
235
378
|
throw new Error(
|
|
@@ -239,7 +382,7 @@ async function loadGeneratedContracts(configPath) {
|
|
|
239
382
|
const mod = await import(new URL(`file://${indexPath}`).href);
|
|
240
383
|
let guardrailHooks;
|
|
241
384
|
const hooksBasePath = `${config.generatedDir}/hooks/index`;
|
|
242
|
-
const hooksPath =
|
|
385
|
+
const hooksPath = existsSync3(`${hooksBasePath}.js`) ? `${hooksBasePath}.js` : existsSync3(`${hooksBasePath}.ts`) ? `${hooksBasePath}.ts` : null;
|
|
243
386
|
if (hooksPath) {
|
|
244
387
|
try {
|
|
245
388
|
const hooksMod = await import(new URL(`file://${hooksPath}`).href);
|
|
@@ -267,6 +410,10 @@ async function createAdapter(adapterName, guardrailHooks) {
|
|
|
267
410
|
const { ClaudeAgentSdkAdapter } = await import("../adapters/claude-agent-sdk.js");
|
|
268
411
|
return new ClaudeAgentSdkAdapter({ guardrailHooks });
|
|
269
412
|
}
|
|
413
|
+
case "gemini": {
|
|
414
|
+
const { GeminiSdkAdapter } = await import("../adapters/gemini-sdk.js");
|
|
415
|
+
return new GeminiSdkAdapter({ guardrailHooks });
|
|
416
|
+
}
|
|
270
417
|
case "cursor": {
|
|
271
418
|
const { CursorSdkAdapter } = await import("../adapters/cursor-sdk.js");
|
|
272
419
|
const apiKey = process.env.CURSOR_API_KEY;
|
|
@@ -276,7 +423,7 @@ async function createAdapter(adapterName, guardrailHooks) {
|
|
|
276
423
|
return CursorSdkAdapter.create({ apiKey, guardrailHooks });
|
|
277
424
|
}
|
|
278
425
|
default:
|
|
279
|
-
throw new Error(`Unknown adapter: ${adapterName}. Available: mock, claude, cursor`);
|
|
426
|
+
throw new Error(`Unknown adapter: ${adapterName}. Available: mock, claude, gemini, cursor`);
|
|
280
427
|
}
|
|
281
428
|
}
|
|
282
429
|
function formatTable(headers, rows) {
|
|
@@ -293,8 +440,18 @@ function formatTable(headers, rows) {
|
|
|
293
440
|
}
|
|
294
441
|
var handlers = {
|
|
295
442
|
async init(options, _globalOpts) {
|
|
296
|
-
|
|
297
|
-
|
|
443
|
+
try {
|
|
444
|
+
const outputDir = resolve2(options.output ?? ".");
|
|
445
|
+
const result = await runInit({
|
|
446
|
+
adapter: options.adapter ?? "mock",
|
|
447
|
+
outputDir,
|
|
448
|
+
force: options.force ?? false
|
|
449
|
+
});
|
|
450
|
+
console.log(JSON.stringify(result, null, 2));
|
|
451
|
+
} catch (err) {
|
|
452
|
+
console.error(err.message);
|
|
453
|
+
process.exit(1);
|
|
454
|
+
}
|
|
298
455
|
},
|
|
299
456
|
async generate(options, globalOpts) {
|
|
300
457
|
try {
|
|
@@ -326,7 +483,7 @@ var handlers = {
|
|
|
326
483
|
if (options.file) {
|
|
327
484
|
try {
|
|
328
485
|
const raw = readFileSync(options.file, "utf8");
|
|
329
|
-
const parsed =
|
|
486
|
+
const parsed = YAML3.parse(raw);
|
|
330
487
|
resolvedWorkflowId = parsed.workflow;
|
|
331
488
|
if (!resolvedWorkflowId) {
|
|
332
489
|
console.error(`Error: invocation file "${options.file}" must contain a "workflow" field.`);
|
package/dist/cli/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/cli/index.ts","../../src/generated/cli/program.ts","../../src/lib/doctor.ts"],"sourcesContent":["#!/usr/bin/env node\n\n/**\n * agent-runtime CLI entry point\n *\n * Uses auto-generated program from cli-contract.yaml.\n */\n\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { createProgram, type CommandHandlers } from \"../generated/cli/program.js\";\nimport { generate, loadConfig, checkFreshness } from \"../generator/index.js\";\nimport {\n buildTaskPrompt,\n pluginRegistry,\n runWorkflow,\n type AgentContractLike,\n type TaskContractLike,\n type SdkAdapter,\n type WorkflowContractLike,\n type WorkflowInvocation,\n type GuardrailHooks,\n} from \"../index.js\";\nimport { loadPlugins } from \"../lib/plugin-loader.js\";\nimport { runDoctor } from \"../lib/doctor.js\";\nimport type { z } from \"zod\";\nimport YAML from \"yaml\";\n\nconst VERSION = \"0.9.0\";\n\n/**\n * Dynamically import the generated contracts from the configured generated_dir.\n * Handles both .ts (via tsx/ts-node) and .js (compiled) files,\n * and both flat exports and namespace exports.\n */\nasync function loadGeneratedContracts(configPath: string): Promise<{\n agentRegistry: Record<string, AgentContractLike>;\n taskRegistry: Record<string, TaskContractLike>;\n handoffSchemas: Record<string, z.ZodType>;\n workflowRegistry: Record<string, WorkflowContractLike>;\n guardrailHooks?: GuardrailHooks;\n}> {\n const config = await loadConfig(configPath);\n const basePath = `${config.generatedDir}/index`;\n\n let indexPath: string;\n if (existsSync(`${basePath}.js`)) {\n indexPath = `${basePath}.js`;\n } else if (existsSync(`${basePath}.ts`)) {\n indexPath = `${basePath}.ts`;\n } else {\n throw new Error(\n `Generated index file not found at ${basePath}.{js,ts}. Run \\`agent-runtime generate\\` first.`,\n );\n }\n\n const mod = await import(new URL(`file://${indexPath}`).href);\n\n let guardrailHooks: GuardrailHooks | undefined;\n const hooksBasePath = `${config.generatedDir}/hooks/index`;\n const hooksPath = existsSync(`${hooksBasePath}.js`)\n ? `${hooksBasePath}.js`\n : existsSync(`${hooksBasePath}.ts`)\n ? `${hooksBasePath}.ts`\n : null;\n if (hooksPath) {\n try {\n const hooksMod = await import(new URL(`file://${hooksPath}`).href);\n if (hooksMod.guardrailHooks) {\n guardrailHooks = hooksMod.guardrailHooks;\n }\n } catch {\n // Guardrail hooks not available — continue without them\n }\n }\n\n return {\n agentRegistry: mod.agentRegistry ?? mod.agents?.agentRegistry ?? {},\n taskRegistry: mod.taskRegistry ?? mod.tasks?.taskRegistry ?? {},\n handoffSchemas: mod.handoffSchemas ?? mod.handoffs?.handoffSchemas ?? {},\n workflowRegistry: mod.workflowRegistry ?? mod.workflows?.workflowRegistry ?? {},\n guardrailHooks,\n };\n}\n\nasync function createAdapter(adapterName: string, guardrailHooks?: GuardrailHooks): Promise<SdkAdapter> {\n switch (adapterName) {\n case \"mock\": {\n const { MockAdapter } = await import(\"../adapters/mock.js\");\n return new MockAdapter();\n }\n case \"claude\": {\n const { ClaudeAgentSdkAdapter } = await import(\"../adapters/claude-agent-sdk.js\");\n return new ClaudeAgentSdkAdapter({ guardrailHooks });\n }\n case \"cursor\": {\n const { CursorSdkAdapter } = await import(\"../adapters/cursor-sdk.js\");\n const apiKey = process.env.CURSOR_API_KEY;\n if (!apiKey) {\n throw new Error(\"CURSOR_API_KEY environment variable is required for the cursor adapter\");\n }\n return CursorSdkAdapter.create({ apiKey, guardrailHooks });\n }\n default:\n throw new Error(`Unknown adapter: ${adapterName}. Available: mock, claude, cursor`);\n }\n}\n\nfunction formatTable(headers: string[], rows: string[][]): string {\n const widths = headers.map((h, i) =>\n Math.max(h.length, ...rows.map((r) => (r[i] ?? \"\").length)),\n );\n const sep = widths.map((w) => \"-\".repeat(w)).join(\" \");\n const pad = (s: string, w: number) => s.padEnd(w);\n const headerLine = headers.map((h, i) => pad(h, widths[i])).join(\" \");\n const dataLines = rows.map((r) =>\n r.map((c, i) => pad(c ?? \"\", widths[i])).join(\" \"),\n );\n return [headerLine, sep, ...dataLines].join(\"\\n\");\n}\n\nconst handlers: CommandHandlers = {\n async init(options, _globalOpts) {\n console.log(\"agent-runtime init — not yet implemented\");\n console.log(\"Options:\", JSON.stringify(options));\n },\n\n async generate(options, globalOpts) {\n try {\n const configPath = (globalOpts.config as string) ?? \"./agent-runtime.config.yaml\";\n const result = await generate({\n clean: options.clean,\n check: options.check,\n templates: options.templates,\n configPath,\n });\n\n if (result.checkMode) {\n if (result.hasDifferences) {\n console.error(\"Generated files are out of date. Run `agent-runtime generate` to update.\");\n process.exit(1);\n }\n console.log(JSON.stringify({ ...result, status: \"up-to-date\" }, null, 2));\n } else {\n console.log(JSON.stringify(result, null, 2));\n }\n } catch (err) {\n console.error(\"Generate failed:\", (err as Error).message);\n process.exit(1);\n }\n },\n\n async run(workflowId, userRequest, options, globalOpts) {\n // --- Resolve input: --file takes precedence over positional args ---\n let resolvedWorkflowId = workflowId;\n let resolvedUserRequest = userRequest;\n let fileInvocation: WorkflowInvocation | undefined;\n\n if (options.file) {\n try {\n const raw = readFileSync(options.file, \"utf8\");\n const parsed = YAML.parse(raw) as Record<string, unknown>;\n resolvedWorkflowId = parsed.workflow as string;\n if (!resolvedWorkflowId) {\n console.error(`Error: invocation file \"${options.file}\" must contain a \"workflow\" field.`);\n process.exit(1);\n }\n fileInvocation = {\n workflow: resolvedWorkflowId,\n user_request: parsed.user_request as string | undefined,\n handoff: parsed.handoff as WorkflowInvocation[\"handoff\"],\n runtime: parsed.runtime as WorkflowInvocation[\"runtime\"],\n };\n resolvedUserRequest = fileInvocation.user_request ?? \"\";\n } catch (err) {\n console.error(`Failed to read invocation file: ${(err as Error).message}`);\n process.exit(1);\n }\n }\n\n if (!resolvedWorkflowId) {\n console.error(\"Error: workflow-id is required (provide as argument or via --file)\");\n process.exit(1);\n }\n if (!fileInvocation && !resolvedUserRequest) {\n console.error(\"Error: user-request is required (provide as argument or via --file)\");\n process.exit(1);\n }\n\n const configPath = (globalOpts.config as string) ?? \"./agent-runtime.config.yaml\";\n\n const fresh = await checkFreshness(configPath);\n if (!fresh) {\n console.error(\"Generated files are stale or missing. Run `agent-runtime generate` first.\");\n process.exit(3);\n }\n\n const config = await loadConfig(configPath);\n\n const pluginResult = await loadPlugins({\n pluginPaths: config.pluginPaths.length > 0 ? config.pluginPaths : undefined,\n projectDir: config.configDir,\n });\n if (pluginResult.loaded > 0 && !(globalOpts.quiet as boolean)) {\n console.error(`Loaded ${pluginResult.loaded} plugin(s) from ${pluginResult.files.length} file(s)`);\n }\n for (const err of pluginResult.errors) {\n console.error(`Plugin load error (${err.file}): ${err.error}`);\n }\n\n let contracts: Awaited<ReturnType<typeof loadGeneratedContracts>>;\n try {\n contracts = await loadGeneratedContracts(configPath);\n } catch (err) {\n console.error(`Failed to load generated contracts: ${(err as Error).message}`);\n process.exit(1);\n return;\n }\n\n if (!contracts.workflowRegistry[resolvedWorkflowId]) {\n console.error(`Unknown workflow: ${resolvedWorkflowId}`);\n console.error(`Available workflows: ${Object.keys(contracts.workflowRegistry).join(\", \")}`);\n process.exit(1);\n return;\n }\n\n const adapterName = (options.adapter as string) ?? \"mock\";\n let adapter: SdkAdapter;\n try {\n adapter = await createAdapter(adapterName, contracts.guardrailHooks);\n } catch (err) {\n console.error((err as Error).message);\n process.exit(1);\n return;\n }\n\n const recovery = config.recovery;\n const maxRetries = options.maxRetries\n ? parseInt(options.maxRetries, 10)\n : undefined;\n const maxFollowUps = options.maxFollowUps\n ? parseInt(options.maxFollowUps, 10)\n : undefined;\n\n const registries = {\n workflowRegistry: contracts.workflowRegistry,\n taskRegistry: contracts.taskRegistry,\n agentRegistry: contracts.agentRegistry,\n handoffSchemas: contracts.handoffSchemas,\n };\n\n const onGate = options.autoApproveGates\n ? async () => true\n : async (gateKind: string, description: string) => {\n console.error(`Gate \"${gateKind}\": ${description}`);\n console.error(\"Use --auto-approve-gates to auto-approve. Rejecting by default.\");\n return false;\n };\n\n let result;\n if (fileInvocation) {\n const invocation: WorkflowInvocation = {\n ...fileInvocation,\n runtime: {\n ...fileInvocation.runtime,\n maxFollowUps: maxFollowUps ?? fileInvocation.runtime?.maxFollowUps ?? recovery.max_follow_ups,\n maxRetries: maxRetries ?? fileInvocation.runtime?.maxRetries ?? recovery.max_retries,\n },\n hooks: { onGate },\n };\n result = await runWorkflow(adapter, invocation, registries);\n } else {\n result = await runWorkflow(adapter, resolvedWorkflowId, {\n user_request: resolvedUserRequest!,\n maxRetries: maxRetries ?? recovery.max_retries,\n maxFollowUps: maxFollowUps ?? recovery.max_follow_ups,\n onGate,\n }, registries);\n }\n\n console.log(JSON.stringify(result, null, 2));\n\n if (result.status !== \"completed\") {\n process.exit(1);\n }\n },\n\n async list(resource, options, globalOpts) {\n if (!resource) {\n console.error(\"Error: resource is required (workflows, tasks, agents)\");\n process.exit(1);\n }\n\n const validResources = [\"workflows\", \"tasks\", \"agents\"];\n if (!validResources.includes(resource)) {\n console.error(`Unknown resource: ${resource}`);\n console.error(`Available resources: ${validResources.join(\", \")}`);\n process.exit(1);\n return;\n }\n\n const configPath = (globalOpts.config as string) ?? \"./agent-runtime.config.yaml\";\n\n let contracts: Awaited<ReturnType<typeof loadGeneratedContracts>>;\n try {\n contracts = await loadGeneratedContracts(configPath);\n } catch (err) {\n console.error(`Failed to load generated contracts: ${(err as Error).message}`);\n console.error(\"Run `agent-runtime generate` first.\");\n process.exit(1);\n return;\n }\n\n const format = options.format ?? \"table\";\n\n if (resource === \"agents\") {\n const agents = Object.values(contracts.agentRegistry);\n if (format === \"json\") {\n console.log(JSON.stringify(agents, null, 2));\n } else {\n if (agents.length === 0) {\n console.log(\"No agents defined.\");\n return;\n }\n console.log(formatTable(\n [\"ID\", \"Role\", \"Mode\", \"Purpose\"],\n agents.map((a) => [a.id, a.role_name, a.mode, a.purpose]),\n ));\n }\n } else if (resource === \"tasks\") {\n const tasks = Object.values(contracts.taskRegistry);\n if (format === \"json\") {\n console.log(JSON.stringify(tasks, null, 2));\n } else {\n if (tasks.length === 0) {\n console.log(\"No tasks defined.\");\n return;\n }\n console.log(formatTable(\n [\"ID\", \"Agent\", \"Description\"],\n tasks.map((t) => [t.id, t.target_agent, t.description]),\n ));\n }\n } else {\n const workflows = Object.values(contracts.workflowRegistry);\n if (format === \"json\") {\n console.log(JSON.stringify(workflows, null, 2));\n } else {\n if (workflows.length === 0) {\n console.log(\"No workflows defined.\");\n return;\n }\n console.log(formatTable(\n [\"ID\", \"Steps\", \"Description\"],\n workflows.map((w) => [w.id, String(w.steps.length), w.description]),\n ));\n }\n }\n },\n\n async showPrompt(taskId, options, globalOpts) {\n if (!taskId) {\n console.error(\"Error: task-id is required\");\n process.exit(1);\n }\n\n const configPath = (globalOpts.config as string) ?? \"./agent-runtime.config.yaml\";\n\n let contracts: Awaited<ReturnType<typeof loadGeneratedContracts>>;\n try {\n contracts = await loadGeneratedContracts(configPath);\n } catch (err) {\n console.error(`Failed to load generated contracts: ${(err as Error).message}`);\n console.error(\"Run `agent-runtime generate` first.\");\n process.exit(1);\n return;\n }\n\n const task = contracts.taskRegistry[taskId];\n if (!task) {\n console.error(`Unknown task: ${taskId}`);\n console.error(`Available tasks: ${Object.keys(contracts.taskRegistry).join(\", \")}`);\n process.exit(1);\n return;\n }\n\n const agent = contracts.agentRegistry[task.target_agent];\n if (!agent) {\n console.error(`Unknown agent: ${task.target_agent} (referenced by task ${taskId})`);\n process.exit(1);\n return;\n }\n\n const pluginsApplied = options.withPlugins ?? false;\n if (pluginsApplied) {\n const showPromptConfig = await loadConfig(configPath);\n await loadPlugins({\n pluginPaths: showPromptConfig.pluginPaths.length > 0 ? showPromptConfig.pluginPaths : undefined,\n projectDir: showPromptConfig.configDir,\n });\n }\n\n const userRequest = options.userRequest ?? \"(preview)\";\n let prompt = buildTaskPrompt(agent, task, { user_request: userRequest }, {\n handoffSchemas: contracts.handoffSchemas,\n });\n\n if (pluginsApplied) {\n prompt = pluginRegistry.applyPromptEnhancers(taskId, prompt, { user_request: userRequest });\n }\n\n const format = options.format ?? \"markdown\";\n if (format === \"json\") {\n console.log(JSON.stringify({\n task_id: taskId,\n agent_id: task.target_agent,\n prompt,\n handoff_schema: task.result_handoff,\n plugins_applied: pluginsApplied,\n }, null, 2));\n } else {\n console.log(prompt);\n }\n },\n\n async doctor(globalOpts) {\n const configPath = (globalOpts.config as string) ?? \"./agent-runtime.config.yaml\";\n const result = await runDoctor(configPath);\n\n const statusIcon = (s: string) =>\n s === \"pass\" ? \"✓\" : s === \"warn\" ? \"!\" : \"✗\";\n\n for (const check of result.checks) {\n const icon = statusIcon(check.status);\n const msg = check.message ? ` ${check.message}` : \"\";\n console.log(` ${icon} ${check.name.padEnd(20)} ${check.status.toUpperCase()}${msg}`);\n }\n\n console.log(\"\");\n if (result.allPassed) {\n console.log(\"All checks passed.\");\n } else {\n console.log(\"Some checks failed.\");\n }\n\n console.log(JSON.stringify(result));\n\n if (!result.allPassed) {\n process.exitCode = 1;\n }\n },\n\n};\n\nconst program = createProgram(handlers, VERSION);\nawait program.parseAsync();\n","// Auto-generated by cli-contracts. Do not edit.\nimport { Command } from \"commander\";\n\nexport interface CommandHandlers {\n init: (options: { adapter?: string; output?: string; force?: boolean }, parentOpts: Record<string, unknown>) => Promise<void>;\n generate: (options: { clean?: boolean; check?: boolean; templates?: string }, parentOpts: Record<string, unknown>) => Promise<void>;\n run: (workflowId: string | undefined, userRequest: string | undefined, options: { adapter?: string; maxRetries?: string; maxFollowUps?: string; dryRun?: boolean; autoApproveGates?: boolean; file?: string }, parentOpts: Record<string, unknown>) => Promise<void>;\n list: (resource: string | undefined, options: { format?: string }, parentOpts: Record<string, unknown>) => Promise<void>;\n showPrompt: (taskId: string | undefined, options: { userRequest?: string; format?: string; withPlugins?: boolean }, parentOpts: Record<string, unknown>) => Promise<void>;\n doctor: (parentOpts: Record<string, unknown>) => Promise<void>;\n}\n\nexport function createProgram(\n handlers: CommandHandlers,\n version: string,\n): Command {\n const program = new Command();\n program\n .name(\"agent-runtime\")\n .version(version, \"-V, --version\")\n .description(\"CLI for agent-contracts-runtime — generate, run, and manage agent workflows.\");\n\n program.option(\"-c, --config <value>\", \"Path to agent-runtime.config.yaml.\", \"./agent-runtime.config.yaml\");\n program.option(\"-v, --verbose\", \"Enable verbose output.\", false);\n program.option(\"-q, --quiet\", \"Suppress non-error output.\", false);\n\n program\n .command(\"init\")\n .description(\"Initialize runtime scaffolding for a project.\")\n .option(\"-a, --adapter <value>\", \"Default SDK adapter to configure.\", \"mock\")\n .option(\"-o, --output <value>\", \"Output directory for generated scaffolding.\", \".\")\n .option(\"-f, --force\", \"Overwrite existing files without prompting.\", false)\n .action(async (opts, cmd) => {\n await handlers.init(opts, cmd.optsWithGlobals());\n });\n\n program\n .command(\"generate\")\n .description(\"Generate runtime contracts and hooks from DSL.\")\n .option(\"--clean\", \"Delete generated_dir before regenerating.\\nRemoves stale files that may remain from previous generations.\\n\", false)\n .option(\"--check\", \"Dry-run mode for CI. Does not write files.\\nCompares current generated output with what would be regenerated.\\nExits with code 1 if any differences are found.\\n\", false)\n .option(\"-t, --templates <value>\", \"Custom templates directory. Overrides built-in templates.\")\n .action(async (opts, cmd) => {\n await handlers.generate(opts, cmd.optsWithGlobals());\n });\n\n program\n .command(\"run\")\n .description(\"Execute a workflow.\")\n .argument(\"[workflow-id]\", \"ID of the workflow to execute. Required unless --file is used.\")\n .argument(\"[user-request]\", \"Natural language description of what to do. Required unless --file is used.\")\n .option(\"-a, --adapter <value>\", \"SDK adapter to use. Overrides config.\")\n .option(\"-r, --max-retries <value>\", \"Override default max retries per step.\")\n .option(\"-f, --max-follow-ups <value>\", \"Override default max follow-ups per step.\")\n .option(\"-n, --dry-run\", \"Simulate execution without calling the SDK adapter.\", false)\n .option(\"--auto-approve-gates\", \"Automatically approve all gate steps.\", false)\n .option(\"--file <value>\", \"Path to a YAML invocation file. When provided, workflow-id and\\nuser-request arguments are read from the file instead of CLI args.\\n\")\n .action(async (workflowId, userRequest, opts, cmd) => {\n await handlers.run(workflowId, userRequest, opts, cmd.optsWithGlobals());\n });\n\n program\n .command(\"list\")\n .description(\"List available workflows, tasks, or agents.\")\n .argument(\"<resource>\", \"Type of resource to list.\")\n .option(\"--format <value>\", \"Output format.\", \"table\")\n .action(async (resource, opts, cmd) => {\n await handlers.list(resource, opts, cmd.optsWithGlobals());\n });\n\n program\n .command(\"show-prompt\")\n .description(\"Display the generated prompt for a task.\")\n .argument(\"<task-id>\", \"ID of the task to show the prompt for (e.g. plan-and-implement, audit-tests).\")\n .option(\"-u, --user-request <value>\", \"User request text to include in the prompt preview.\", \"(preview)\")\n .option(\"--format <value>\", \"Output format.\", \"markdown\")\n .option(\"--with-plugins\", \"Apply registered plugin prompt enhancers to the output.\", false)\n .action(async (taskId, opts, cmd) => {\n await handlers.showPrompt(taskId, opts, cmd.optsWithGlobals());\n });\n\n program\n .command(\"doctor\")\n .description(\"Verify configuration, generated files, and SDK connectivity.\")\n .action(async (opts, cmd) => {\n await handlers.doctor({}, cmd.optsWithGlobals());\n });\n\n return program;\n}\n","/**\n * Doctor — diagnostic checks for agent-contracts-runtime configuration health\n *\n * Each check returns a DoctorCheck with pass/fail/warn status.\n * The runner collects all checks and determines overall health.\n */\n\nimport { existsSync } from \"node:fs\";\nimport { readFile } from \"node:fs/promises\";\nimport { resolve, join } from \"node:path\";\nimport YAML from \"yaml\";\nimport { loadConfig, RuntimeConfigSchema, type ResolvedConfig } from \"../generator/config.js\";\nimport { checkFreshness } from \"../generator/index.js\";\n\nexport interface DoctorCheck {\n name: string;\n status: \"pass\" | \"fail\" | \"warn\";\n message?: string;\n}\n\nexport interface DoctorResult {\n checks: DoctorCheck[];\n allPassed: boolean;\n}\n\nconst ADAPTER_ENV_VARS: Record<string, string> = {\n cursor: \"CURSOR_API_KEY\",\n claude: \"ANTHROPIC_API_KEY\",\n openai: \"OPENAI_API_KEY\",\n};\n\nasync function checkConfigExists(configPath: string): Promise<{ check: DoctorCheck; config?: ResolvedConfig }> {\n try {\n const config = await loadConfig(configPath);\n return {\n check: { name: \"config_exists\", status: \"pass\", message: `Loaded ${configPath}` },\n config,\n };\n } catch (err) {\n const absPath = resolve(configPath);\n if (!existsSync(absPath)) {\n return {\n check: { name: \"config_exists\", status: \"fail\", message: `Config file not found: ${absPath}` },\n };\n }\n return {\n check: { name: \"config_exists\", status: \"fail\", message: `Config parse error: ${(err as Error).message}` },\n };\n }\n}\n\nasync function checkDslExists(config: ResolvedConfig): Promise<DoctorCheck> {\n if (!existsSync(config.dslPath)) {\n return { name: \"dsl_exists\", status: \"fail\", message: `DSL file not found: ${config.dslPath}` };\n }\n\n try {\n const raw = await readFile(config.dslPath, \"utf8\");\n const parsed = YAML.parse(raw);\n if (!parsed || typeof parsed !== \"object\") {\n return { name: \"dsl_exists\", status: \"fail\", message: \"DSL file is empty or not a valid YAML object\" };\n }\n const agentCount = Object.keys(parsed.agents ?? {}).length;\n const taskCount = Object.keys(parsed.tasks ?? {}).length;\n const workflowCount = Object.keys(parsed.workflow ?? {}).length;\n return {\n name: \"dsl_exists\",\n status: \"pass\",\n message: `Parsed OK — ${agentCount} agent(s), ${taskCount} task(s), ${workflowCount} workflow(s)`,\n };\n } catch (err) {\n return { name: \"dsl_exists\", status: \"fail\", message: `DSL parse error: ${(err as Error).message}` };\n }\n}\n\nasync function checkManifestFresh(configPath: string, config: ResolvedConfig): Promise<DoctorCheck> {\n const manifestPath = join(config.generatedDir, \".manifest.json\");\n\n if (!existsSync(manifestPath)) {\n return {\n name: \"manifest_fresh\",\n status: \"fail\",\n message: \"Generated manifest not found. Run `agent-runtime generate` first.\",\n };\n }\n\n try {\n const fresh = await checkFreshness(configPath);\n if (fresh) {\n return { name: \"manifest_fresh\", status: \"pass\", message: \"Generated files are up to date\" };\n }\n return {\n name: \"manifest_fresh\",\n status: \"fail\",\n message: \"Generated files are stale. Run `agent-runtime generate` to update.\",\n };\n } catch (err) {\n return { name: \"manifest_fresh\", status: \"fail\", message: `Freshness check error: ${(err as Error).message}` };\n }\n}\n\nfunction checkAdapterConfigured(): DoctorCheck {\n const configured: string[] = [];\n const missing: string[] = [];\n\n for (const [adapter, envVar] of Object.entries(ADAPTER_ENV_VARS)) {\n if (process.env[envVar]) {\n configured.push(adapter);\n } else {\n missing.push(`${adapter} (${envVar})`);\n }\n }\n\n if (configured.length > 0) {\n return {\n name: \"adapter_configured\",\n status: \"pass\",\n message: `Configured: ${configured.join(\", \")}${missing.length > 0 ? ` | Not set: ${missing.join(\", \")}` : \"\"}`,\n };\n }\n\n return {\n name: \"adapter_configured\",\n status: \"warn\",\n message: `No SDK adapter API keys found. Set one of: ${Object.entries(ADAPTER_ENV_VARS).map(([a, e]) => `${e} (${a})`).join(\", \")}`,\n };\n}\n\nfunction checkPluginEntrypoints(config: ResolvedConfig): DoctorCheck {\n if (config.pluginPaths.length === 0) {\n return { name: \"plugin_entrypoint\", status: \"pass\", message: \"No plugins configured\" };\n }\n\n const missing: string[] = [];\n for (const p of config.pluginPaths) {\n const absPath = resolve(config.configDir, p);\n if (!existsSync(absPath)) {\n missing.push(p);\n }\n }\n\n if (missing.length === 0) {\n return {\n name: \"plugin_entrypoint\",\n status: \"pass\",\n message: `All ${config.pluginPaths.length} plugin file(s) found`,\n };\n }\n\n return {\n name: \"plugin_entrypoint\",\n status: \"fail\",\n message: `Missing plugin file(s): ${missing.join(\", \")}`,\n };\n}\n\nasync function checkBindingsValid(config: ResolvedConfig): Promise<DoctorCheck> {\n if (config.bindingPaths.length === 0) {\n return { name: \"bindings_valid\", status: \"pass\", message: \"No bindings configured\" };\n }\n\n const errors: string[] = [];\n for (const bp of config.bindingPaths) {\n if (!existsSync(bp)) {\n errors.push(`Not found: ${bp}`);\n continue;\n }\n try {\n const raw = await readFile(bp, \"utf8\");\n const parsed = YAML.parse(raw);\n if (!parsed || typeof parsed !== \"object\") {\n errors.push(`Invalid YAML object: ${bp}`);\n }\n } catch (err) {\n errors.push(`Parse error in ${bp}: ${(err as Error).message}`);\n }\n }\n\n if (errors.length === 0) {\n return {\n name: \"bindings_valid\",\n status: \"pass\",\n message: `All ${config.bindingPaths.length} binding file(s) valid`,\n };\n }\n\n return {\n name: \"bindings_valid\",\n status: \"fail\",\n message: errors.join(\"; \"),\n };\n}\n\nexport async function runDoctor(configPath: string): Promise<DoctorResult> {\n const checks: DoctorCheck[] = [];\n\n // 1. Config exists and parses\n const configResult = await checkConfigExists(configPath);\n checks.push(configResult.check);\n\n if (!configResult.config) {\n return { checks, allPassed: false };\n }\n\n const config = configResult.config;\n\n // 2–6 can run concurrently since they only read state\n const [dslCheck, manifestCheck, pluginCheck, bindingsCheck] = await Promise.all([\n checkDslExists(config),\n checkManifestFresh(configPath, config),\n Promise.resolve(checkPluginEntrypoints(config)),\n checkBindingsValid(config),\n ]);\n\n checks.push(dslCheck);\n checks.push(manifestCheck);\n checks.push(checkAdapterConfigured());\n checks.push(pluginCheck);\n checks.push(bindingsCheck);\n\n const allPassed = checks.every((c) => c.status !== \"fail\");\n\n return { checks, allPassed };\n}\n"],"mappings":";;;;;;;;;;;;;;AAQA,SAAS,cAAAA,aAAY,oBAAoB;;;ACPzC,SAAS,eAAe;AAWjB,SAAS,cACdC,WACA,SACS;AACT,QAAMC,WAAU,IAAI,QAAQ;AAC5B,EAAAA,SACG,KAAK,eAAe,EACpB,QAAQ,SAAS,eAAe,EAChC,YAAY,mFAA8E;AAE7F,EAAAA,SAAQ,OAAO,wBAAwB,sCAAsC,6BAA6B;AAC1G,EAAAA,SAAQ,OAAO,iBAAiB,0BAA0B,KAAK;AAC/D,EAAAA,SAAQ,OAAO,eAAe,8BAA8B,KAAK;AAEjE,EAAAA,SACG,QAAQ,MAAM,EACd,YAAY,+CAA+C,EAC3D,OAAO,yBAAyB,qCAAqC,MAAM,EAC3E,OAAO,wBAAwB,+CAA+C,GAAG,EACjF,OAAO,eAAe,+CAA+C,KAAK,EAC1E,OAAO,OAAO,MAAM,QAAQ;AAC3B,UAAMD,UAAS,KAAK,MAAM,IAAI,gBAAgB,CAAC;AAAA,EACjD,CAAC;AAEH,EAAAC,SACG,QAAQ,UAAU,EAClB,YAAY,gDAAgD,EAC5D,OAAO,WAAW,+GAA+G,KAAK,EACtI,OAAO,WAAW,oKAAoK,KAAK,EAC3L,OAAO,2BAA2B,2DAA2D,EAC7F,OAAO,OAAO,MAAM,QAAQ;AAC3B,UAAMD,UAAS,SAAS,MAAM,IAAI,gBAAgB,CAAC;AAAA,EACrD,CAAC;AAEH,E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IAAI,qBAAqB;AAAA,IACnC;AAEA,YAAQ,IAAI,KAAK,UAAU,MAAM,CAAC;AAElC,QAAI,CAAC,OAAO,WAAW;AACrB,cAAQ,WAAW;AAAA,IACrB;AAAA,EACF;AAEF;AAEA,IAAM,UAAU,cAAc,UAAU,OAAO;AAC/C,MAAM,QAAQ,WAAW;","names":["existsSync","handlers","program","YAML","existsSync"]}
|
|
1
|
+
{"version":3,"sources":["../../src/cli/index.ts","../../src/generated/cli/program.ts","../../src/lib/doctor.ts","../../src/lib/init.ts"],"sourcesContent":["#!/usr/bin/env node\n\n/**\n * agent-runtime CLI entry point\n *\n * Uses auto-generated program from cli-contract.yaml.\n */\n\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\nimport { createProgram, type CommandHandlers } from \"../generated/cli/program.js\";\nimport { generate, loadConfig, checkFreshness } from \"../generator/index.js\";\nimport {\n buildTaskPrompt,\n pluginRegistry,\n runWorkflow,\n type AgentContractLike,\n type TaskContractLike,\n type SdkAdapter,\n type WorkflowContractLike,\n type WorkflowInvocation,\n type GuardrailHooks,\n} from \"../index.js\";\nimport { loadPlugins } from \"../lib/plugin-loader.js\";\nimport { runDoctor } from \"../lib/doctor.js\";\nimport { runInit } from \"../lib/init.js\";\nimport type { z } from \"zod\";\nimport YAML from \"yaml\";\n\nconst VERSION = \"0.11.0\";\n\n/**\n * Dynamically import the generated contracts from the configured generated_dir.\n * Handles both .ts (via tsx/ts-node) and .js (compiled) files,\n * and both flat exports and namespace exports.\n */\nasync function loadGeneratedContracts(configPath: string): Promise<{\n agentRegistry: Record<string, AgentContractLike>;\n taskRegistry: Record<string, TaskContractLike>;\n handoffSchemas: Record<string, z.ZodType>;\n workflowRegistry: Record<string, WorkflowContractLike>;\n guardrailHooks?: GuardrailHooks;\n}> {\n const config = await loadConfig(configPath);\n const basePath = `${config.generatedDir}/index`;\n\n let indexPath: string;\n if (existsSync(`${basePath}.js`)) {\n indexPath = `${basePath}.js`;\n } else if (existsSync(`${basePath}.ts`)) {\n indexPath = `${basePath}.ts`;\n } else {\n throw new Error(\n `Generated index file not found at ${basePath}.{js,ts}. Run \\`agent-runtime generate\\` first.`,\n );\n }\n\n const mod = await import(new URL(`file://${indexPath}`).href);\n\n let guardrailHooks: GuardrailHooks | undefined;\n const hooksBasePath = `${config.generatedDir}/hooks/index`;\n const hooksPath = existsSync(`${hooksBasePath}.js`)\n ? `${hooksBasePath}.js`\n : existsSync(`${hooksBasePath}.ts`)\n ? `${hooksBasePath}.ts`\n : null;\n if (hooksPath) {\n try {\n const hooksMod = await import(new URL(`file://${hooksPath}`).href);\n if (hooksMod.guardrailHooks) {\n guardrailHooks = hooksMod.guardrailHooks;\n }\n } catch {\n // Guardrail hooks not available — continue without them\n }\n }\n\n return {\n agentRegistry: mod.agentRegistry ?? mod.agents?.agentRegistry ?? {},\n taskRegistry: mod.taskRegistry ?? mod.tasks?.taskRegistry ?? {},\n handoffSchemas: mod.handoffSchemas ?? mod.handoffs?.handoffSchemas ?? {},\n workflowRegistry: mod.workflowRegistry ?? mod.workflows?.workflowRegistry ?? {},\n guardrailHooks,\n };\n}\n\nasync function createAdapter(adapterName: string, guardrailHooks?: GuardrailHooks): Promise<SdkAdapter> {\n switch (adapterName) {\n case \"mock\": {\n const { MockAdapter } = await import(\"../adapters/mock.js\");\n return new MockAdapter();\n }\n case \"claude\": {\n const { ClaudeAgentSdkAdapter } = await import(\"../adapters/claude-agent-sdk.js\");\n return new ClaudeAgentSdkAdapter({ guardrailHooks });\n }\n case \"gemini\": {\n const { GeminiSdkAdapter } = await import(\"../adapters/gemini-sdk.js\");\n return new GeminiSdkAdapter({ guardrailHooks });\n }\n case \"cursor\": {\n const { CursorSdkAdapter } = await import(\"../adapters/cursor-sdk.js\");\n const apiKey = process.env.CURSOR_API_KEY;\n if (!apiKey) {\n throw new Error(\"CURSOR_API_KEY environment variable is required for the cursor adapter\");\n }\n return CursorSdkAdapter.create({ apiKey, guardrailHooks });\n }\n default:\n throw new Error(`Unknown adapter: ${adapterName}. Available: mock, claude, gemini, cursor`);\n }\n}\n\nfunction formatTable(headers: string[], rows: string[][]): string {\n const widths = headers.map((h, i) =>\n Math.max(h.length, ...rows.map((r) => (r[i] ?? \"\").length)),\n );\n const sep = widths.map((w) => \"-\".repeat(w)).join(\" \");\n const pad = (s: string, w: number) => s.padEnd(w);\n const headerLine = headers.map((h, i) => pad(h, widths[i])).join(\" \");\n const dataLines = rows.map((r) =>\n r.map((c, i) => pad(c ?? \"\", widths[i])).join(\" \"),\n );\n return [headerLine, sep, ...dataLines].join(\"\\n\");\n}\n\nconst handlers: CommandHandlers = {\n async init(options, _globalOpts) {\n try {\n const outputDir = resolve(options.output ?? \".\");\n const result = await runInit({\n adapter: options.adapter ?? \"mock\",\n outputDir,\n force: options.force ?? false,\n });\n console.log(JSON.stringify(result, null, 2));\n } catch (err) {\n console.error((err as Error).message);\n process.exit(1);\n }\n },\n\n async generate(options, globalOpts) {\n try {\n const configPath = (globalOpts.config as string) ?? \"./agent-runtime.config.yaml\";\n const result = await generate({\n clean: options.clean,\n check: options.check,\n templates: options.templates,\n configPath,\n });\n\n if (result.checkMode) {\n if (result.hasDifferences) {\n console.error(\"Generated files are out of date. Run `agent-runtime generate` to update.\");\n process.exit(1);\n }\n console.log(JSON.stringify({ ...result, status: \"up-to-date\" }, null, 2));\n } else {\n console.log(JSON.stringify(result, null, 2));\n }\n } catch (err) {\n console.error(\"Generate failed:\", (err as Error).message);\n process.exit(1);\n }\n },\n\n async run(workflowId, userRequest, options, globalOpts) {\n // --- Resolve input: --file takes precedence over positional args ---\n let resolvedWorkflowId = workflowId;\n let resolvedUserRequest = userRequest;\n let fileInvocation: WorkflowInvocation | undefined;\n\n if (options.file) {\n try {\n const raw = readFileSync(options.file, \"utf8\");\n const parsed = YAML.parse(raw) as Record<string, unknown>;\n resolvedWorkflowId = parsed.workflow as string;\n if (!resolvedWorkflowId) {\n console.error(`Error: invocation file \"${options.file}\" must contain a \"workflow\" field.`);\n process.exit(1);\n }\n fileInvocation = {\n workflow: resolvedWorkflowId,\n user_request: parsed.user_request as string | undefined,\n handoff: parsed.handoff as WorkflowInvocation[\"handoff\"],\n runtime: parsed.runtime as WorkflowInvocation[\"runtime\"],\n };\n resolvedUserRequest = fileInvocation.user_request ?? \"\";\n } catch (err) {\n console.error(`Failed to read invocation file: ${(err as Error).message}`);\n process.exit(1);\n }\n }\n\n if (!resolvedWorkflowId) {\n console.error(\"Error: workflow-id is required (provide as argument or via --file)\");\n process.exit(1);\n }\n if (!fileInvocation && !resolvedUserRequest) {\n console.error(\"Error: user-request is required (provide as argument or via --file)\");\n process.exit(1);\n }\n\n const configPath = (globalOpts.config as string) ?? \"./agent-runtime.config.yaml\";\n\n const fresh = await checkFreshness(configPath);\n if (!fresh) {\n console.error(\"Generated files are stale or missing. Run `agent-runtime generate` first.\");\n process.exit(3);\n }\n\n const config = await loadConfig(configPath);\n\n const pluginResult = await loadPlugins({\n pluginPaths: config.pluginPaths.length > 0 ? config.pluginPaths : undefined,\n projectDir: config.configDir,\n });\n if (pluginResult.loaded > 0 && !(globalOpts.quiet as boolean)) {\n console.error(`Loaded ${pluginResult.loaded} plugin(s) from ${pluginResult.files.length} file(s)`);\n }\n for (const err of pluginResult.errors) {\n console.error(`Plugin load error (${err.file}): ${err.error}`);\n }\n\n let contracts: Awaited<ReturnType<typeof loadGeneratedContracts>>;\n try {\n contracts = await loadGeneratedContracts(configPath);\n } catch (err) {\n console.error(`Failed to load generated contracts: ${(err as Error).message}`);\n process.exit(1);\n return;\n }\n\n if (!contracts.workflowRegistry[resolvedWorkflowId]) {\n console.error(`Unknown workflow: ${resolvedWorkflowId}`);\n console.error(`Available workflows: ${Object.keys(contracts.workflowRegistry).join(\", \")}`);\n process.exit(1);\n return;\n }\n\n const adapterName = (options.adapter as string) ?? \"mock\";\n let adapter: SdkAdapter;\n try {\n adapter = await createAdapter(adapterName, contracts.guardrailHooks);\n } catch (err) {\n console.error((err as Error).message);\n process.exit(1);\n return;\n }\n\n const recovery = config.recovery;\n const maxRetries = options.maxRetries\n ? parseInt(options.maxRetries, 10)\n : undefined;\n const maxFollowUps = options.maxFollowUps\n ? parseInt(options.maxFollowUps, 10)\n : undefined;\n\n const registries = {\n workflowRegistry: contracts.workflowRegistry,\n taskRegistry: contracts.taskRegistry,\n agentRegistry: contracts.agentRegistry,\n handoffSchemas: contracts.handoffSchemas,\n };\n\n const onGate = options.autoApproveGates\n ? async () => true\n : async (gateKind: string, description: string) => {\n console.error(`Gate \"${gateKind}\": ${description}`);\n console.error(\"Use --auto-approve-gates to auto-approve. Rejecting by default.\");\n return false;\n };\n\n let result;\n if (fileInvocation) {\n const invocation: WorkflowInvocation = {\n ...fileInvocation,\n runtime: {\n ...fileInvocation.runtime,\n maxFollowUps: maxFollowUps ?? fileInvocation.runtime?.maxFollowUps ?? recovery.max_follow_ups,\n maxRetries: maxRetries ?? fileInvocation.runtime?.maxRetries ?? recovery.max_retries,\n },\n hooks: { onGate },\n };\n result = await runWorkflow(adapter, invocation, registries);\n } else {\n result = await runWorkflow(adapter, resolvedWorkflowId, {\n user_request: resolvedUserRequest!,\n maxRetries: maxRetries ?? recovery.max_retries,\n maxFollowUps: maxFollowUps ?? recovery.max_follow_ups,\n onGate,\n }, registries);\n }\n\n console.log(JSON.stringify(result, null, 2));\n\n if (result.status !== \"completed\") {\n process.exit(1);\n }\n },\n\n async list(resource, options, globalOpts) {\n if (!resource) {\n console.error(\"Error: resource is required (workflows, tasks, agents)\");\n process.exit(1);\n }\n\n const validResources = [\"workflows\", \"tasks\", \"agents\"];\n if (!validResources.includes(resource)) {\n console.error(`Unknown resource: ${resource}`);\n console.error(`Available resources: ${validResources.join(\", \")}`);\n process.exit(1);\n return;\n }\n\n const configPath = (globalOpts.config as string) ?? \"./agent-runtime.config.yaml\";\n\n let contracts: Awaited<ReturnType<typeof loadGeneratedContracts>>;\n try {\n contracts = await loadGeneratedContracts(configPath);\n } catch (err) {\n console.error(`Failed to load generated contracts: ${(err as Error).message}`);\n console.error(\"Run `agent-runtime generate` first.\");\n process.exit(1);\n return;\n }\n\n const format = options.format ?? \"table\";\n\n if (resource === \"agents\") {\n const agents = Object.values(contracts.agentRegistry);\n if (format === \"json\") {\n console.log(JSON.stringify(agents, null, 2));\n } else {\n if (agents.length === 0) {\n console.log(\"No agents defined.\");\n return;\n }\n console.log(formatTable(\n [\"ID\", \"Role\", \"Mode\", \"Purpose\"],\n agents.map((a) => [a.id, a.role_name, a.mode, a.purpose]),\n ));\n }\n } else if (resource === \"tasks\") {\n const tasks = Object.values(contracts.taskRegistry);\n if (format === \"json\") {\n console.log(JSON.stringify(tasks, null, 2));\n } else {\n if (tasks.length === 0) {\n console.log(\"No tasks defined.\");\n return;\n }\n console.log(formatTable(\n [\"ID\", \"Agent\", \"Description\"],\n tasks.map((t) => [t.id, t.target_agent, t.description]),\n ));\n }\n } else {\n const workflows = Object.values(contracts.workflowRegistry);\n if (format === \"json\") {\n console.log(JSON.stringify(workflows, null, 2));\n } else {\n if (workflows.length === 0) {\n console.log(\"No workflows defined.\");\n return;\n }\n console.log(formatTable(\n [\"ID\", \"Steps\", \"Description\"],\n workflows.map((w) => [w.id, String(w.steps.length), w.description]),\n ));\n }\n }\n },\n\n async showPrompt(taskId, options, globalOpts) {\n if (!taskId) {\n console.error(\"Error: task-id is required\");\n process.exit(1);\n }\n\n const configPath = (globalOpts.config as string) ?? \"./agent-runtime.config.yaml\";\n\n let contracts: Awaited<ReturnType<typeof loadGeneratedContracts>>;\n try {\n contracts = await loadGeneratedContracts(configPath);\n } catch (err) {\n console.error(`Failed to load generated contracts: ${(err as Error).message}`);\n console.error(\"Run `agent-runtime generate` first.\");\n process.exit(1);\n return;\n }\n\n const task = contracts.taskRegistry[taskId];\n if (!task) {\n console.error(`Unknown task: ${taskId}`);\n console.error(`Available tasks: ${Object.keys(contracts.taskRegistry).join(\", \")}`);\n process.exit(1);\n return;\n }\n\n const agent = contracts.agentRegistry[task.target_agent];\n if (!agent) {\n console.error(`Unknown agent: ${task.target_agent} (referenced by task ${taskId})`);\n process.exit(1);\n return;\n }\n\n const pluginsApplied = options.withPlugins ?? false;\n if (pluginsApplied) {\n const showPromptConfig = await loadConfig(configPath);\n await loadPlugins({\n pluginPaths: showPromptConfig.pluginPaths.length > 0 ? showPromptConfig.pluginPaths : undefined,\n projectDir: showPromptConfig.configDir,\n });\n }\n\n const userRequest = options.userRequest ?? \"(preview)\";\n let prompt = buildTaskPrompt(agent, task, { user_request: userRequest }, {\n handoffSchemas: contracts.handoffSchemas,\n });\n\n if (pluginsApplied) {\n prompt = pluginRegistry.applyPromptEnhancers(taskId, prompt, { user_request: userRequest });\n }\n\n const format = options.format ?? \"markdown\";\n if (format === \"json\") {\n console.log(JSON.stringify({\n task_id: taskId,\n agent_id: task.target_agent,\n prompt,\n handoff_schema: task.result_handoff,\n plugins_applied: pluginsApplied,\n }, null, 2));\n } else {\n console.log(prompt);\n }\n },\n\n async doctor(globalOpts) {\n const configPath = (globalOpts.config as string) ?? \"./agent-runtime.config.yaml\";\n const result = await runDoctor(configPath);\n\n const statusIcon = (s: string) =>\n s === \"pass\" ? \"✓\" : s === \"warn\" ? \"!\" : \"✗\";\n\n for (const check of result.checks) {\n const icon = statusIcon(check.status);\n const msg = check.message ? ` ${check.message}` : \"\";\n console.log(` ${icon} ${check.name.padEnd(20)} ${check.status.toUpperCase()}${msg}`);\n }\n\n console.log(\"\");\n if (result.allPassed) {\n console.log(\"All checks passed.\");\n } else {\n console.log(\"Some checks failed.\");\n }\n\n console.log(JSON.stringify(result));\n\n if (!result.allPassed) {\n process.exitCode = 1;\n }\n },\n\n};\n\nconst program = createProgram(handlers, VERSION);\nawait program.parseAsync();\n","// Auto-generated by cli-contracts. Do not edit.\nimport { Command } from \"commander\";\n\nexport interface CommandHandlers {\n init: (options: { adapter?: string; output?: string; force?: boolean }, parentOpts: Record<string, unknown>) => Promise<void>;\n generate: (options: { clean?: boolean; check?: boolean; templates?: string }, parentOpts: Record<string, unknown>) => Promise<void>;\n run: (workflowId: string | undefined, userRequest: string | undefined, options: { adapter?: string; maxRetries?: string; maxFollowUps?: string; dryRun?: boolean; autoApproveGates?: boolean; file?: string }, parentOpts: Record<string, unknown>) => Promise<void>;\n list: (resource: string | undefined, options: { format?: string }, parentOpts: Record<string, unknown>) => Promise<void>;\n showPrompt: (taskId: string | undefined, options: { userRequest?: string; format?: string; withPlugins?: boolean }, parentOpts: Record<string, unknown>) => Promise<void>;\n doctor: (parentOpts: Record<string, unknown>) => Promise<void>;\n}\n\nexport function createProgram(\n handlers: CommandHandlers,\n version: string,\n): Command {\n const program = new Command();\n program\n .name(\"agent-runtime\")\n .version(version, \"-V, --version\")\n .description(\"CLI for agent-contracts-runtime — generate, run, and manage agent workflows.\");\n\n program.option(\"-c, --config <value>\", \"Path to agent-runtime.config.yaml.\", \"./agent-runtime.config.yaml\");\n program.option(\"-v, --verbose\", \"Enable verbose output.\", false);\n program.option(\"-q, --quiet\", \"Suppress non-error output.\", false);\n\n program\n .command(\"init\")\n .description(\"Initialize runtime scaffolding for a project.\")\n .option(\"-a, --adapter <value>\", \"Default SDK adapter to configure.\", \"mock\")\n .option(\"-o, --output <value>\", \"Output directory for generated scaffolding.\", \".\")\n .option(\"-f, --force\", \"Overwrite existing files without prompting.\", false)\n .action(async (opts, cmd) => {\n await handlers.init(opts, cmd.optsWithGlobals());\n });\n\n program\n .command(\"generate\")\n .description(\"Generate runtime contracts and hooks from DSL.\")\n .option(\"--clean\", \"Delete generated_dir before regenerating.\\nRemoves stale files that may remain from previous generations.\\n\", false)\n .option(\"--check\", \"Dry-run mode for CI. Does not write files.\\nCompares current generated output with what would be regenerated.\\nExits with code 1 if any differences are found.\\n\", false)\n .option(\"-t, --templates <value>\", \"Custom templates directory. Overrides built-in templates.\")\n .action(async (opts, cmd) => {\n await handlers.generate(opts, cmd.optsWithGlobals());\n });\n\n program\n .command(\"run\")\n .description(\"Execute a workflow.\")\n .argument(\"[workflow-id]\", \"ID of the workflow to execute. Required unless --file is used.\")\n .argument(\"[user-request]\", \"Natural language description of what to do. Required unless --file is used.\")\n .option(\"-a, --adapter <value>\", \"SDK adapter to use. Overrides config.\")\n .option(\"-r, --max-retries <value>\", \"Override default max retries per step.\")\n .option(\"-f, --max-follow-ups <value>\", \"Override default max follow-ups per step.\")\n .option(\"-n, --dry-run\", \"Simulate execution without calling the SDK adapter.\", false)\n .option(\"--auto-approve-gates\", \"Automatically approve all gate steps.\", false)\n .option(\"--file <value>\", \"Path to a YAML invocation file. When provided, workflow-id and\\nuser-request arguments are read from the file instead of CLI args.\\n\")\n .action(async (workflowId, userRequest, opts, cmd) => {\n await handlers.run(workflowId, userRequest, opts, cmd.optsWithGlobals());\n });\n\n program\n .command(\"list\")\n .description(\"List available workflows, tasks, or agents.\")\n .argument(\"<resource>\", \"Type of resource to list.\")\n .option(\"--format <value>\", \"Output format.\", \"table\")\n .action(async (resource, opts, cmd) => {\n await handlers.list(resource, opts, cmd.optsWithGlobals());\n });\n\n program\n .command(\"show-prompt\")\n .description(\"Display the generated prompt for a task.\")\n .argument(\"<task-id>\", \"ID of the task to show the prompt for (e.g. plan-and-implement, audit-tests).\")\n .option(\"-u, --user-request <value>\", \"User request text to include in the prompt preview.\", \"(preview)\")\n .option(\"--format <value>\", \"Output format.\", \"markdown\")\n .option(\"--with-plugins\", \"Apply registered plugin prompt enhancers to the output.\", false)\n .action(async (taskId, opts, cmd) => {\n await handlers.showPrompt(taskId, opts, cmd.optsWithGlobals());\n });\n\n program\n .command(\"doctor\")\n .description(\"Verify configuration, generated files, and SDK connectivity.\")\n .action(async (opts, cmd) => {\n await handlers.doctor({}, cmd.optsWithGlobals());\n });\n\n return program;\n}\n","/**\n * Doctor — diagnostic checks for agent-contracts-runtime configuration health\n *\n * Each check returns a DoctorCheck with pass/fail/warn status.\n * The runner collects all checks and determines overall health.\n */\n\nimport { existsSync } from \"node:fs\";\nimport { readFile } from \"node:fs/promises\";\nimport { resolve, join } from \"node:path\";\nimport YAML from \"yaml\";\nimport { loadConfig, RuntimeConfigSchema, type ResolvedConfig } from \"../generator/config.js\";\nimport { checkFreshness } from \"../generator/index.js\";\n\nexport interface DoctorCheck {\n name: string;\n status: \"pass\" | \"fail\" | \"warn\";\n message?: string;\n}\n\nexport interface DoctorResult {\n checks: DoctorCheck[];\n allPassed: boolean;\n}\n\nconst ADAPTER_ENV_VARS: Record<string, string> = {\n cursor: \"CURSOR_API_KEY\",\n claude: \"ANTHROPIC_API_KEY\",\n openai: \"OPENAI_API_KEY\",\n};\n\nasync function checkConfigExists(configPath: string): Promise<{ check: DoctorCheck; config?: ResolvedConfig }> {\n try {\n const config = await loadConfig(configPath);\n return {\n check: { name: \"config_exists\", status: \"pass\", message: `Loaded ${configPath}` },\n config,\n };\n } catch (err) {\n const absPath = resolve(configPath);\n if (!existsSync(absPath)) {\n return {\n check: { name: \"config_exists\", status: \"fail\", message: `Config file not found: ${absPath}` },\n };\n }\n return {\n check: { name: \"config_exists\", status: \"fail\", message: `Config parse error: ${(err as Error).message}` },\n };\n }\n}\n\nasync function checkDslExists(config: ResolvedConfig): Promise<DoctorCheck> {\n if (!existsSync(config.dslPath)) {\n return { name: \"dsl_exists\", status: \"fail\", message: `DSL file not found: ${config.dslPath}` };\n }\n\n try {\n const raw = await readFile(config.dslPath, \"utf8\");\n const parsed = YAML.parse(raw);\n if (!parsed || typeof parsed !== \"object\") {\n return { name: \"dsl_exists\", status: \"fail\", message: \"DSL file is empty or not a valid YAML object\" };\n }\n const agentCount = Object.keys(parsed.agents ?? {}).length;\n const taskCount = Object.keys(parsed.tasks ?? {}).length;\n const workflowCount = Object.keys(parsed.workflow ?? {}).length;\n return {\n name: \"dsl_exists\",\n status: \"pass\",\n message: `Parsed OK — ${agentCount} agent(s), ${taskCount} task(s), ${workflowCount} workflow(s)`,\n };\n } catch (err) {\n return { name: \"dsl_exists\", status: \"fail\", message: `DSL parse error: ${(err as Error).message}` };\n }\n}\n\nasync function checkManifestFresh(configPath: string, config: ResolvedConfig): Promise<DoctorCheck> {\n const manifestPath = join(config.generatedDir, \".manifest.json\");\n\n if (!existsSync(manifestPath)) {\n return {\n name: \"manifest_fresh\",\n status: \"fail\",\n message: \"Generated manifest not found. Run `agent-runtime generate` first.\",\n };\n }\n\n try {\n const fresh = await checkFreshness(configPath);\n if (fresh) {\n return { name: \"manifest_fresh\", status: \"pass\", message: \"Generated files are up to date\" };\n }\n return {\n name: \"manifest_fresh\",\n status: \"fail\",\n message: \"Generated files are stale. Run `agent-runtime generate` to update.\",\n };\n } catch (err) {\n return { name: \"manifest_fresh\", status: \"fail\", message: `Freshness check error: ${(err as Error).message}` };\n }\n}\n\nfunction checkAdapterConfigured(): DoctorCheck {\n const configured: string[] = [];\n const missing: string[] = [];\n\n for (const [adapter, envVar] of Object.entries(ADAPTER_ENV_VARS)) {\n if (process.env[envVar]) {\n configured.push(adapter);\n } else {\n missing.push(`${adapter} (${envVar})`);\n }\n }\n\n if (configured.length > 0) {\n return {\n name: \"adapter_configured\",\n status: \"pass\",\n message: `Configured: ${configured.join(\", \")}${missing.length > 0 ? ` | Not set: ${missing.join(\", \")}` : \"\"}`,\n };\n }\n\n return {\n name: \"adapter_configured\",\n status: \"warn\",\n message: `No SDK adapter API keys found. Set one of: ${Object.entries(ADAPTER_ENV_VARS).map(([a, e]) => `${e} (${a})`).join(\", \")}`,\n };\n}\n\nfunction checkPluginEntrypoints(config: ResolvedConfig): DoctorCheck {\n if (config.pluginPaths.length === 0) {\n return { name: \"plugin_entrypoint\", status: \"pass\", message: \"No plugins configured\" };\n }\n\n const missing: string[] = [];\n for (const p of config.pluginPaths) {\n const absPath = resolve(config.configDir, p);\n if (!existsSync(absPath)) {\n missing.push(p);\n }\n }\n\n if (missing.length === 0) {\n return {\n name: \"plugin_entrypoint\",\n status: \"pass\",\n message: `All ${config.pluginPaths.length} plugin file(s) found`,\n };\n }\n\n return {\n name: \"plugin_entrypoint\",\n status: \"fail\",\n message: `Missing plugin file(s): ${missing.join(\", \")}`,\n };\n}\n\nasync function checkBindingsValid(config: ResolvedConfig): Promise<DoctorCheck> {\n if (config.bindingPaths.length === 0) {\n return { name: \"bindings_valid\", status: \"pass\", message: \"No bindings configured\" };\n }\n\n const errors: string[] = [];\n for (const bp of config.bindingPaths) {\n if (!existsSync(bp)) {\n errors.push(`Not found: ${bp}`);\n continue;\n }\n try {\n const raw = await readFile(bp, \"utf8\");\n const parsed = YAML.parse(raw);\n if (!parsed || typeof parsed !== \"object\") {\n errors.push(`Invalid YAML object: ${bp}`);\n }\n } catch (err) {\n errors.push(`Parse error in ${bp}: ${(err as Error).message}`);\n }\n }\n\n if (errors.length === 0) {\n return {\n name: \"bindings_valid\",\n status: \"pass\",\n message: `All ${config.bindingPaths.length} binding file(s) valid`,\n };\n }\n\n return {\n name: \"bindings_valid\",\n status: \"fail\",\n message: errors.join(\"; \"),\n };\n}\n\nexport async function runDoctor(configPath: string): Promise<DoctorResult> {\n const checks: DoctorCheck[] = [];\n\n // 1. Config exists and parses\n const configResult = await checkConfigExists(configPath);\n checks.push(configResult.check);\n\n if (!configResult.config) {\n return { checks, allPassed: false };\n }\n\n const config = configResult.config;\n\n // 2–6 can run concurrently since they only read state\n const [dslCheck, manifestCheck, pluginCheck, bindingsCheck] = await Promise.all([\n checkDslExists(config),\n checkManifestFresh(configPath, config),\n Promise.resolve(checkPluginEntrypoints(config)),\n checkBindingsValid(config),\n ]);\n\n checks.push(dslCheck);\n checks.push(manifestCheck);\n checks.push(checkAdapterConfigured());\n checks.push(pluginCheck);\n checks.push(bindingsCheck);\n\n const allPassed = checks.every((c) => c.status !== \"fail\");\n\n return { checks, allPassed };\n}\n","/**\n * init — scaffold a new agent-contracts-runtime project\n */\n\nimport { existsSync } from \"node:fs\";\nimport { mkdir, writeFile, readFile, appendFile } from \"node:fs/promises\";\nimport { join, relative } from \"node:path\";\nimport YAML from \"yaml\";\n\nexport interface InitOptions {\n adapter: string;\n outputDir: string;\n force: boolean;\n}\n\nexport interface InitResult {\n filesCreated: string[];\n}\n\ninterface FileEntry {\n relativePath: string;\n content: string;\n}\n\nfunction buildConfigYaml(adapter: string): string {\n return YAML.stringify(\n {\n dsl: \"./agent-contracts.yaml\",\n generated_dir: \"./agent/generated\",\n plugins: [\"./agent/src/plugins/example-plugin.ts\"],\n recovery: {\n max_follow_ups: 2,\n max_retries: 0,\n },\n },\n { lineWidth: 0 },\n );\n}\n\nconst EXAMPLE_PLUGIN_TS = `\\\nimport type { AgentPlugin } from \"agent-contracts-runtime\";\n\n/**\n * Example plugin — extend agent-contracts-runtime with custom hooks.\n *\n * Register lifecycle hooks for tasks and workflows:\n * beforeTask / afterTask — pre/post-process task execution\n * contextEnhancer — augment task context before prompt generation\n * promptEnhancer — post-process generated prompts\n * customGuardrails — add project-specific guardrail checks\n * beforeWorkflow / afterWorkflow — workflow lifecycle hooks\n *\n * See https://github.com/foo-ogawa/agent-contracts-runtime#plugins\n */\nexport const examplePlugin: AgentPlugin = {\n id: \"example-plugin\",\n\n // Uncomment hooks as needed:\n\n // async beforeTask(taskId, context) {\n // console.log(\\`[example-plugin] beforeTask: \\${taskId}\\`);\n // return context;\n // },\n\n // async afterTask(taskId, outcome) {\n // console.log(\\`[example-plugin] afterTask: \\${taskId} — \\${outcome.status}\\`);\n // return outcome;\n // },\n\n // promptEnhancer(taskId, prompt, _context) {\n // return prompt + \"\\\\n\\\\n<!-- enhanced by example-plugin -->\";\n // },\n};\n\nexport default examplePlugin;\n`;\n\nconst CUSTOM_GUARDRAILS_TS = `\\\nimport type { AgentPlugin, GuardrailResult } from \"agent-contracts-runtime\";\n\n/**\n * Custom guardrails — project-specific safety checks.\n *\n * Implement evaluateCommand, evaluateFilePath, or evaluateFileContent\n * to enforce project rules beyond the built-in guardrails.\n *\n * See https://github.com/foo-ogawa/agent-contracts-runtime#guardrails\n */\nexport const customGuardrailsPlugin: AgentPlugin = {\n id: \"custom-guardrails\",\n\n customGuardrails: {\n // evaluateCommand(command: string): GuardrailResult[] {\n // const results: GuardrailResult[] = [];\n // // Example: block dangerous patterns\n // if (command.includes(\"DROP TABLE\")) {\n // results.push({\n // matched: true,\n // guardrail_id: \"no-drop-table\",\n // severity: \"critical\",\n // action: \"block\",\n // message: \"DROP TABLE is forbidden\",\n // });\n // }\n // return results;\n // },\n },\n};\n\nexport default customGuardrailsPlugin;\n`;\n\nconst GITIGNORE_ENTRIES = [\n \"\",\n \"# agent-contracts-runtime generated files\",\n \"agent/generated/\",\n];\n\nfunction buildScaffoldFiles(adapter: string): FileEntry[] {\n return [\n {\n relativePath: \"agent-runtime.config.yaml\",\n content: buildConfigYaml(adapter),\n },\n {\n relativePath: \"agent/src/plugins/example-plugin.ts\",\n content: EXAMPLE_PLUGIN_TS,\n },\n {\n relativePath: \"agent/src/guardrails/custom-guardrails.ts\",\n content: CUSTOM_GUARDRAILS_TS,\n },\n ];\n}\n\nexport async function runInit(options: InitOptions): Promise<InitResult> {\n const { adapter, outputDir, force } = options;\n const filesCreated: string[] = [];\n\n const entries = buildScaffoldFiles(adapter);\n\n for (const entry of entries) {\n const absPath = join(outputDir, entry.relativePath);\n if (!force && existsSync(absPath)) {\n throw new Error(\n `File already exists: ${entry.relativePath}. Use --force to overwrite.`,\n );\n }\n }\n\n for (const entry of entries) {\n const absPath = join(outputDir, entry.relativePath);\n const dir = join(absPath, \"..\");\n await mkdir(dir, { recursive: true });\n await writeFile(absPath, entry.content, \"utf8\");\n filesCreated.push(entry.relativePath);\n }\n\n const gitignorePath = join(outputDir, \".gitignore\");\n if (existsSync(gitignorePath)) {\n const existing = await readFile(gitignorePath, \"utf8\");\n if (!existing.includes(\"agent/generated/\")) {\n await appendFile(gitignorePath, GITIGNORE_ENTRIES.join(\"\\n\") + \"\\n\", \"utf8\");\n filesCreated.push(\".gitignore\");\n }\n } else {\n await writeFile(gitignorePath, GITIGNORE_ENTRIES.join(\"\\n\").trimStart() + \"\\n\", \"utf8\");\n filesCreated.push(\".gitignore\");\n }\n\n return { filesCreated };\n}\n"],"mappings":";;;;;;;;;;;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AA,IAC5B,CAAC;AAED,QAAI,gBAAgB;AAClB,eAAS,eAAe,qBAAqB,QAAQ,QAAQ,EAAE,cAAc,YAAY,CAAC;AAAA,IAC5F;AAEA,UAAM,SAAS,QAAQ,UAAU;AACjC,QAAI,WAAW,QAAQ;AACrB,cAAQ,IAAI,KAAK,UAAU;AAAA,QACzB,SAAS;AAAA,QACT,UAAU,KAAK;AAAA,QACf;AAAA,QACA,gBAAgB,KAAK;AAAA,QACrB,iBAAiB;AAAA,MACnB,GAAG,MAAM,CAAC,CAAC;AAAA,IACb,OAAO;AACL,cAAQ,IAAI,MAAM;AAAA,IACpB;AAAA,EACF;AAAA,EAEA,MAAM,OAAO,YAAY;AACvB,UAAM,aAAc,WAAW,UAAqB;AACpD,UAAM,SAAS,MAAM,UAAU,UAAU;AAEzC,UAAM,aAAa,CAAC,MAClB,MAAM,SAAS,WAAM,MAAM,SAAS,MAAM;AAE5C,eAAW,SAAS,OAAO,QAAQ;AACjC,YAAM,OAAO,WAAW,MAAM,MAAM;AACpC,YAAM,MAAM,MAAM,UAAU,KAAK,MAAM,OAAO,KAAK;AACnD,cAAQ,IAAI,KAAK,IAAI,IAAI,MAAM,KAAK,OAAO,EAAE,CAAC,IAAI,MAAM,OAAO,YAAY,CAAC,GAAG,GAAG,EAAE;AAAA,IACtF;AAEA,YAAQ,IAAI,EAAE;AACd,QAAI,OAAO,WAAW;AACpB,cAAQ,IAAI,oBAAoB;AAAA,IAClC,OAAO;AACL,cAAQ,IAAI,qBAAqB;AAAA,IACnC;AAEA,YAAQ,IAAI,KAAK,UAAU,MAAM,CAAC;AAElC,QAAI,CAAC,OAAO,WAAW;AACrB,cAAQ,WAAW;AAAA,IACrB;AAAA,EACF;AAEF;AAEA,IAAM,UAAU,cAAc,UAAU,OAAO;AAC/C,MAAM,QAAQ,WAAW;","names":["existsSync","resolve","handlers","program","existsSync","readFile","join","YAML","YAML","existsSync","resolve"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agent-contracts-runtime",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "Runtime bridge for executing agent-contracts workflows on Agent SDKs",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -25,6 +25,10 @@
|
|
|
25
25
|
"types": "./dist/adapters/openai-agents-sdk.d.ts",
|
|
26
26
|
"import": "./dist/adapters/openai-agents-sdk.js"
|
|
27
27
|
},
|
|
28
|
+
"./adapters/gemini-sdk": {
|
|
29
|
+
"types": "./dist/adapters/gemini-sdk.d.ts",
|
|
30
|
+
"import": "./dist/adapters/gemini-sdk.js"
|
|
31
|
+
},
|
|
28
32
|
"./adapters/mock": {
|
|
29
33
|
"types": "./dist/adapters/mock.d.ts",
|
|
30
34
|
"import": "./dist/adapters/mock.js"
|
|
@@ -99,10 +103,14 @@
|
|
|
99
103
|
"peerDependencies": {
|
|
100
104
|
"@anthropic-ai/claude-agent-sdk": ">=0.2.0",
|
|
101
105
|
"@cursor/sdk": ">=1.0.0",
|
|
106
|
+
"@google/genai": ">=2.0.0",
|
|
102
107
|
"@openai/agents": ">=0.10.0",
|
|
103
108
|
"agent-contracts": "^0.17.0"
|
|
104
109
|
},
|
|
105
110
|
"peerDependenciesMeta": {
|
|
111
|
+
"@google/genai": {
|
|
112
|
+
"optional": true
|
|
113
|
+
},
|
|
106
114
|
"agent-contracts": {
|
|
107
115
|
"optional": true
|
|
108
116
|
},
|