agent-contracts-runtime 0.5.2 → 0.6.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 +249 -16
- package/cli-contract.yaml +15 -4
- package/dist/adapters/claude-agent-sdk.d.ts +2 -16
- package/dist/adapters/claude-agent-sdk.js.map +1 -1
- package/dist/adapters/cursor-sdk.d.ts +2 -15
- package/dist/adapters/cursor-sdk.js.map +1 -1
- package/dist/adapters/mock.d.ts +2 -8
- package/dist/adapters/mock.js.map +1 -1
- package/dist/{chunk-UEHOLHZV.js → chunk-74HEBMGQ.js} +165 -8
- package/dist/chunk-74HEBMGQ.js.map +1 -0
- package/dist/cli/index.js +62 -21
- package/dist/cli/index.js.map +1 -1
- package/dist/index.d.ts +89 -5
- package/dist/index.js +5 -1
- package/dist/{task-runner-DuZwv4zJ.d.ts → task-runner-JLQ-vpHl.d.ts} +49 -4
- package/package.json +1 -1
- package/templates/contracts-index.ts.hbs +2 -2
- package/templates/handoffs.ts.hbs +30 -0
- package/dist/chunk-UEHOLHZV.js.map +0 -1
package/README.md
CHANGED
|
@@ -5,15 +5,15 @@ Runtime bridge for executing [`agent-contracts`](https://github.com/foo-ogawa/ag
|
|
|
5
5
|
`agent-contracts` defines your multi-agent system as contracts.
|
|
6
6
|
`agent-contracts-runtime` turns those contracts into an executable SDK runtime.
|
|
7
7
|
|
|
8
|
-
It generates typed contracts, handoff validators, and guardrail hooks from your DSL, then runs workflows through pluggable SDK adapters such as Cursor, Claude, or OpenAI Agents SDK.
|
|
8
|
+
It generates typed contracts, handoff validators, handoff factories, and guardrail hooks from your DSL, then runs workflows through pluggable SDK adapters such as Cursor, Claude, or OpenAI Agents SDK.
|
|
9
9
|
|
|
10
10
|
## What it does
|
|
11
11
|
|
|
12
|
-
- **Generate** typed TypeScript contracts, Zod handoff schemas, and guardrail hooks from `agent-contracts.yaml`
|
|
12
|
+
- **Generate** typed TypeScript contracts, Zod handoff schemas, handoff factory functions, and guardrail hooks from `agent-contracts.yaml`
|
|
13
13
|
- **Run** multi-step agent workflows with mechanical orchestration (followUp, retry, gate, escalation)
|
|
14
|
-
- **Validate**
|
|
14
|
+
- **Validate** both input and output handoffs against Zod schemas before proceeding
|
|
15
15
|
- **Enforce** guardrails (command, file path, file content) via binding-defined checks
|
|
16
|
-
- **Extend** with project-specific plugins (lifecycle hooks,
|
|
16
|
+
- **Extend** with project-specific plugins (lifecycle hooks, context enhancement, prompt customization, custom guardrails)
|
|
17
17
|
- **Adapt** to any SDK through a pluggable adapter interface
|
|
18
18
|
|
|
19
19
|
## Architecture
|
|
@@ -27,7 +27,7 @@ agent-contracts.yaml (DSL) bindings/runtime.yaml (guardrail impl)
|
|
|
27
27
|
├── agent/generated/agents.ts (AgentContract + registry)
|
|
28
28
|
├── agent/generated/tasks.ts (TaskContract + registry)
|
|
29
29
|
├── agent/generated/workflows.ts (WorkflowContract + registry)
|
|
30
|
-
├── agent/generated/handoffs.ts (Zod schemas + registry)
|
|
30
|
+
├── agent/generated/handoffs.ts (Zod schemas + registry + factories)
|
|
31
31
|
├── agent/generated/index.ts (barrel re-export)
|
|
32
32
|
├── agent/generated/hooks/guardrails.ts (check functions)
|
|
33
33
|
├── agent/generated/hooks/index.ts (unified hook adapter)
|
|
@@ -41,6 +41,7 @@ agent-contracts.yaml (DSL) bindings/runtime.yaml (guardrail impl)
|
|
|
41
41
|
├── Plugin: beforeWorkflow
|
|
42
42
|
├── For each step:
|
|
43
43
|
│ ├── Plugin: beforeTask
|
|
44
|
+
│ ├── Plugin: contextEnhancer (enrich structured context)
|
|
44
45
|
│ ├── Plugin: promptBuilder (full override) or default buildTaskPrompt
|
|
45
46
|
│ ├── Plugin: promptEnhancer (post-process)
|
|
46
47
|
│ ├── SDK Adapter: send prompt to LLM
|
|
@@ -53,11 +54,27 @@ agent-contracts.yaml (DSL) bindings/runtime.yaml (guardrail impl)
|
|
|
53
54
|
└── Plugin: afterWorkflow
|
|
54
55
|
```
|
|
55
56
|
|
|
57
|
+
### Invocation flow
|
|
58
|
+
|
|
59
|
+
```
|
|
60
|
+
Program / CLI / CI
|
|
61
|
+
↓
|
|
62
|
+
WorkflowInvocation (SDK-independent envelope)
|
|
63
|
+
↓
|
|
64
|
+
agent-contracts-runtime
|
|
65
|
+
↓
|
|
66
|
+
AgentExecutionRequest (resolved contract + context)
|
|
67
|
+
↓
|
|
68
|
+
SdkAdapter (Cursor / Claude / OpenAI)
|
|
69
|
+
↓
|
|
70
|
+
SDK-specific request
|
|
71
|
+
```
|
|
72
|
+
|
|
56
73
|
### Layer separation
|
|
57
74
|
|
|
58
75
|
| Layer | Path | Owner | Description |
|
|
59
76
|
|-------|------|-------|-------------|
|
|
60
|
-
| **Generated** | `agent/generated/` | Auto-generated | DSL-derived contracts and hooks. Never edit manually. |
|
|
77
|
+
| **Generated** | `agent/generated/` | Auto-generated | DSL-derived contracts, handoff factories, and hooks. Never edit manually. |
|
|
61
78
|
| **User code** | `agent/src/` | You | Plugins, project guardrails, interceptors. |
|
|
62
79
|
| **Runtime** | `node_modules/agent-contracts-runtime/` | npm package | Workflow runner, task runner, SDK adapters, generator. |
|
|
63
80
|
|
|
@@ -95,6 +112,7 @@ agent-runtime doctor
|
|
|
95
112
|
| `agent-runtime init` | Initialize runtime scaffolding |
|
|
96
113
|
| `agent-runtime generate` | Generate contracts and hooks from DSL |
|
|
97
114
|
| `agent-runtime run <workflow> <request>` | Execute a workflow |
|
|
115
|
+
| `agent-runtime run --file <path>` | Execute from a YAML invocation file |
|
|
98
116
|
| `agent-runtime list <resource>` | List workflows, tasks, or agents |
|
|
99
117
|
| `agent-runtime show-prompt <task>` | Display the generated prompt for a task |
|
|
100
118
|
| `agent-runtime doctor` | Verify configuration and connectivity |
|
|
@@ -108,12 +126,39 @@ agent-runtime generate --clean # Delete and regenerate
|
|
|
108
126
|
agent-runtime generate -t ./my-tpl # Use custom Handlebars templates
|
|
109
127
|
agent-runtime run ... --dry-run # Simulate without calling SDK
|
|
110
128
|
agent-runtime run ... --adapter mock # Use mock adapter for testing
|
|
129
|
+
agent-runtime run --file ./invocation.yaml # Run from YAML manifest
|
|
111
130
|
agent-runtime show-prompt plan-and-implement # Preview prompt
|
|
112
131
|
agent-runtime show-prompt audit-tests -u "Check test quality" # With custom request
|
|
113
132
|
agent-runtime show-prompt plan-and-implement --format json # JSON output
|
|
114
133
|
agent-runtime show-prompt plan-and-implement --with-plugins # Apply plugin enhancers
|
|
115
134
|
```
|
|
116
135
|
|
|
136
|
+
### YAML invocation file
|
|
137
|
+
|
|
138
|
+
For CI or programmatic invocation, define the full request as a YAML file:
|
|
139
|
+
|
|
140
|
+
```yaml
|
|
141
|
+
# invocation.yaml
|
|
142
|
+
workflow: feature-implement
|
|
143
|
+
handoff:
|
|
144
|
+
type: feature-implementation-request
|
|
145
|
+
payload:
|
|
146
|
+
objective: Add login endpoint with JWT
|
|
147
|
+
inputs:
|
|
148
|
+
repository: .
|
|
149
|
+
expected_outputs:
|
|
150
|
+
- implementation-diff
|
|
151
|
+
completion_criteria:
|
|
152
|
+
- tests_passed
|
|
153
|
+
runtime:
|
|
154
|
+
max_follow_ups: 3
|
|
155
|
+
max_retries: 1
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
agent-runtime run --file ./invocation.yaml --adapter cursor
|
|
160
|
+
```
|
|
161
|
+
|
|
117
162
|
For full CLI reference with exit codes and output schemas, see [docs/cli-reference.md](docs/cli-reference.md).
|
|
118
163
|
|
|
119
164
|
The CLI specification is managed contract-first via [`cli-contracts`](https://www.npmjs.com/package/cli-contracts) in [`cli-contract.yaml`](cli-contract.yaml).
|
|
@@ -126,11 +171,29 @@ The `generate` command reads your `agent-contracts.yaml` DSL and optional bindin
|
|
|
126
171
|
|
|
127
172
|
| Phase | Input | Output | Description |
|
|
128
173
|
|-------|-------|--------|-------------|
|
|
129
|
-
| **1. Contracts** | DSL (`agents`, `tasks`, `workflow`, `handoff_types`) | `agents.ts`, `tasks.ts`, `workflows.ts`, `handoffs.ts`, `index.ts` | Typed contract interfaces
|
|
174
|
+
| **1. Contracts** | DSL (`agents`, `tasks`, `workflow`, `handoff_types`) | `agents.ts`, `tasks.ts`, `workflows.ts`, `handoffs.ts`, `index.ts` | Typed contract interfaces, registries, and handoff factories |
|
|
130
175
|
| **2. Guardrails** | DSL guardrails + binding `guardrail_impl` + active policy | `hooks/guardrails.ts`, `hooks/index.ts` | Check functions for command, file path, file content |
|
|
131
176
|
|
|
132
177
|
Phase 2 requires a binding YAML (following the `agent-contracts` `SoftwareBinding` schema). If no bindings are configured, guardrail hooks are skipped.
|
|
133
178
|
|
|
179
|
+
### Generated handoff factories
|
|
180
|
+
|
|
181
|
+
In addition to Zod schemas and type aliases, `handoffs.ts` generates type-safe factory functions for each handoff type:
|
|
182
|
+
|
|
183
|
+
```typescript
|
|
184
|
+
import { handoffs } from "./agent/generated";
|
|
185
|
+
|
|
186
|
+
const envelope = handoffs.featureImplementationRequest({
|
|
187
|
+
objective: "Add login endpoint with JWT",
|
|
188
|
+
inputs: { repository: "." },
|
|
189
|
+
expected_outputs: ["implementation-diff"],
|
|
190
|
+
completion_criteria: ["tests_passed"],
|
|
191
|
+
});
|
|
192
|
+
// => { type: "feature-implementation-request", version: 1, payload: { ... } }
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
The factory validates the payload against the Zod schema at construction time, catching type errors before the workflow starts.
|
|
196
|
+
|
|
134
197
|
### Custom templates
|
|
135
198
|
|
|
136
199
|
Override any built-in Handlebars template by placing a file with the same name in a custom templates directory:
|
|
@@ -181,7 +244,15 @@ const isFresh = await checkFreshness("./agent-runtime.config.yaml");
|
|
|
181
244
|
|
|
182
245
|
## Programmatic API
|
|
183
246
|
|
|
184
|
-
|
|
247
|
+
The runtime provides three API levels for different use cases:
|
|
248
|
+
|
|
249
|
+
| API | Use case | Input |
|
|
250
|
+
|-----|----------|-------|
|
|
251
|
+
| **Simple API** | CLI, PoC, quick scripts | `user_request: string` |
|
|
252
|
+
| **Structured API** | Application integration, CI | `WorkflowInvocation` with typed handoff |
|
|
253
|
+
| **Builder API** | Fluent programmatic usage | `createRuntime` → chained methods |
|
|
254
|
+
|
|
255
|
+
### 1. Simple API
|
|
185
256
|
|
|
186
257
|
```typescript
|
|
187
258
|
import { runWorkflow } from "agent-contracts-runtime";
|
|
@@ -195,21 +266,110 @@ const adapter = await CursorSdkAdapter.create({
|
|
|
195
266
|
|
|
196
267
|
const result = await runWorkflow(adapter, "feature-implement", {
|
|
197
268
|
user_request: "Add login endpoint with JWT",
|
|
198
|
-
maxFollowUps: 3,
|
|
199
|
-
maxRetries: 1,
|
|
269
|
+
maxFollowUps: 3,
|
|
270
|
+
maxRetries: 1,
|
|
200
271
|
|
|
201
272
|
onStepComplete: (event) => {
|
|
202
273
|
console.log(`Step ${event.step_index + 1}: ${event.task_id} -> ${event.outcome_status}`);
|
|
203
274
|
},
|
|
204
275
|
|
|
205
276
|
onGate: async (gateKind, description) => {
|
|
206
|
-
return true;
|
|
277
|
+
return true;
|
|
207
278
|
},
|
|
208
279
|
});
|
|
209
280
|
|
|
210
281
|
console.log(`${result.workflow_id}: ${result.status} (${result.total_elapsed_ms}ms)`);
|
|
211
282
|
```
|
|
212
283
|
|
|
284
|
+
### 2. Structured API
|
|
285
|
+
|
|
286
|
+
Use `WorkflowInvocation` for typed handoff input with Zod validation on both input and output:
|
|
287
|
+
|
|
288
|
+
```typescript
|
|
289
|
+
import { runWorkflow } from "agent-contracts-runtime";
|
|
290
|
+
import { handoffs } from "./agent/generated";
|
|
291
|
+
|
|
292
|
+
const result = await runWorkflow(adapter, {
|
|
293
|
+
workflow: "feature-implement",
|
|
294
|
+
|
|
295
|
+
handoff: handoffs.featureImplementationRequest({
|
|
296
|
+
objective: "Add login endpoint with JWT",
|
|
297
|
+
inputs: {
|
|
298
|
+
repository: ".",
|
|
299
|
+
apiSpec: "./docs/openapi.yaml",
|
|
300
|
+
},
|
|
301
|
+
constraints: {
|
|
302
|
+
allowedPaths: ["src/**", "test/**"],
|
|
303
|
+
deniedPaths: ["infra/**"],
|
|
304
|
+
},
|
|
305
|
+
expectedOutputs: ["implementation-diff", "test-report"],
|
|
306
|
+
completionCriteria: ["tests_passed", "review_approved"],
|
|
307
|
+
}),
|
|
308
|
+
|
|
309
|
+
runtime: {
|
|
310
|
+
maxFollowUps: 3,
|
|
311
|
+
maxRetries: 1,
|
|
312
|
+
},
|
|
313
|
+
|
|
314
|
+
hooks: {
|
|
315
|
+
onGate: async (gateKind, description) => true,
|
|
316
|
+
},
|
|
317
|
+
});
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
The `WorkflowInvocation` envelope is SDK-independent. SDK-specific options (model, session mode, etc.) belong on the adapter constructor:
|
|
321
|
+
|
|
322
|
+
```typescript
|
|
323
|
+
const adapter = await CursorSdkAdapter.create({
|
|
324
|
+
apiKey: process.env.CURSOR_API_KEY!,
|
|
325
|
+
model: "composer-2",
|
|
326
|
+
cwd: process.cwd(),
|
|
327
|
+
});
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
### 3. Builder API
|
|
331
|
+
|
|
332
|
+
For the most natural programmatic experience, use `createRuntime` with method chaining:
|
|
333
|
+
|
|
334
|
+
```typescript
|
|
335
|
+
import { createRuntime } from "agent-contracts-runtime";
|
|
336
|
+
import { CursorSdkAdapter } from "agent-contracts-runtime/adapters/cursor-sdk";
|
|
337
|
+
import { handoffs } from "./agent/generated";
|
|
338
|
+
|
|
339
|
+
const adapter = await CursorSdkAdapter.create({
|
|
340
|
+
apiKey: process.env.CURSOR_API_KEY!,
|
|
341
|
+
model: "composer-2",
|
|
342
|
+
cwd: process.cwd(),
|
|
343
|
+
});
|
|
344
|
+
|
|
345
|
+
const runtime = createRuntime({ adapter });
|
|
346
|
+
|
|
347
|
+
const result = await runtime
|
|
348
|
+
.workflow("feature-implement")
|
|
349
|
+
.handoff(handoffs.featureImplementationRequest({
|
|
350
|
+
objective: "Add login endpoint with JWT",
|
|
351
|
+
inputs: { repository: "." },
|
|
352
|
+
expectedOutputs: ["implementation-diff"],
|
|
353
|
+
completionCriteria: ["tests_passed"],
|
|
354
|
+
}))
|
|
355
|
+
.maxFollowUps(3)
|
|
356
|
+
.maxRetries(1)
|
|
357
|
+
.onStepComplete((event) => {
|
|
358
|
+
console.log(event.task_id, event.outcome_status);
|
|
359
|
+
})
|
|
360
|
+
.onGate(async () => true)
|
|
361
|
+
.run();
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
The builder can also accept a plain string for quick usage:
|
|
365
|
+
|
|
366
|
+
```typescript
|
|
367
|
+
const result = await runtime
|
|
368
|
+
.workflow("feature-implement")
|
|
369
|
+
.request("Add login endpoint with JWT")
|
|
370
|
+
.run();
|
|
371
|
+
```
|
|
372
|
+
|
|
213
373
|
### Run a single task
|
|
214
374
|
|
|
215
375
|
```typescript
|
|
@@ -266,6 +426,12 @@ const myPlugin: AgentPlugin = {
|
|
|
266
426
|
async beforeTask(taskId, context) {
|
|
267
427
|
return context; // return null to skip
|
|
268
428
|
},
|
|
429
|
+
contextEnhancer(taskId, context) {
|
|
430
|
+
return {
|
|
431
|
+
...context,
|
|
432
|
+
variables: { ...context.variables, projectFramework: "NestJS" },
|
|
433
|
+
};
|
|
434
|
+
},
|
|
269
435
|
async afterTask(taskId, outcome) {
|
|
270
436
|
return outcome;
|
|
271
437
|
},
|
|
@@ -285,6 +451,7 @@ Plugins inject mechanical logic into DSL-defined workflows without modifying the
|
|
|
285
451
|
interface AgentPlugin {
|
|
286
452
|
readonly id: string;
|
|
287
453
|
beforeTask?(taskId: string, context: TaskContext): Promise<TaskContext | null>;
|
|
454
|
+
contextEnhancer?(taskId: string, context: TaskContext): TaskContext;
|
|
288
455
|
afterTask?(taskId: string, outcome: TaskOutcome): Promise<TaskOutcome>;
|
|
289
456
|
promptEnhancer?(taskId: string, prompt: string, context: TaskContext): string;
|
|
290
457
|
promptBuilder?(args: PromptBuilderArgs): string | null;
|
|
@@ -294,9 +461,48 @@ interface AgentPlugin {
|
|
|
294
461
|
}
|
|
295
462
|
```
|
|
296
463
|
|
|
297
|
-
###
|
|
464
|
+
### Hook execution order
|
|
465
|
+
|
|
466
|
+
```
|
|
467
|
+
beforeWorkflow
|
|
468
|
+
↓
|
|
469
|
+
beforeTask ← skip task (return null) or modify context
|
|
470
|
+
↓
|
|
471
|
+
contextEnhancer ← enrich structured context (variables, handoff_input, etc.)
|
|
472
|
+
↓
|
|
473
|
+
promptBuilder ← full prompt override, or null to use default
|
|
474
|
+
↓
|
|
475
|
+
promptEnhancer ← lightweight post-processing on prompt string
|
|
476
|
+
↓
|
|
477
|
+
SDK Adapter send
|
|
478
|
+
↓
|
|
479
|
+
afterTask
|
|
480
|
+
↓
|
|
481
|
+
afterWorkflow
|
|
482
|
+
```
|
|
483
|
+
|
|
484
|
+
### Context vs prompt
|
|
485
|
+
|
|
486
|
+
The runtime treats prompt as a **derived artifact** from structured context. Plugins should prefer modifying `TaskContext` via `contextEnhancer` over string manipulation in `promptEnhancer` when the data is structured:
|
|
487
|
+
|
|
488
|
+
```typescript
|
|
489
|
+
const contextPlugin: AgentPlugin = {
|
|
490
|
+
id: "context-enricher",
|
|
491
|
+
contextEnhancer(taskId, context) {
|
|
492
|
+
return {
|
|
493
|
+
...context,
|
|
494
|
+
relevant_paths: ["src/auth/**", "src/middleware/**"],
|
|
495
|
+
variables: {
|
|
496
|
+
...context.variables,
|
|
497
|
+
dbType: "PostgreSQL",
|
|
498
|
+
orm: "TypeORM",
|
|
499
|
+
},
|
|
500
|
+
};
|
|
501
|
+
},
|
|
502
|
+
};
|
|
503
|
+
```
|
|
298
504
|
|
|
299
|
-
|
|
505
|
+
### Prompt customization hooks
|
|
300
506
|
|
|
301
507
|
| Hook | Purpose | Execution order |
|
|
302
508
|
|------|---------|-----------------|
|
|
@@ -329,14 +535,40 @@ const customPromptPlugin: AgentPlugin = {
|
|
|
329
535
|
| `openai` | OpenAI Agents SDK | Planned |
|
|
330
536
|
| `mock` | Simulated responses for testing/demo | Implemented |
|
|
331
537
|
|
|
332
|
-
|
|
538
|
+
### Adapter interface
|
|
539
|
+
|
|
540
|
+
The minimal adapter interface requires only `send`:
|
|
541
|
+
|
|
542
|
+
```typescript
|
|
543
|
+
interface SdkAdapter {
|
|
544
|
+
send(prompt: string, options: AdapterSendOptions): Promise<string>;
|
|
545
|
+
followUp?(message: string): Promise<string>;
|
|
546
|
+
}
|
|
547
|
+
```
|
|
548
|
+
|
|
549
|
+
For adapters that need full contract context, implement `sendExecution`:
|
|
333
550
|
|
|
334
551
|
```typescript
|
|
335
552
|
interface SdkAdapter {
|
|
336
|
-
send(prompt: string, options:
|
|
553
|
+
send(prompt: string, options: AdapterSendOptions): Promise<string>;
|
|
554
|
+
followUp?(message: string): Promise<string>;
|
|
555
|
+
sendExecution?(request: AgentExecutionRequest): Promise<string>;
|
|
337
556
|
}
|
|
338
557
|
```
|
|
339
558
|
|
|
559
|
+
When `sendExecution` is implemented, the runtime prefers it over `send` and passes the full `AgentExecutionRequest` containing agent/task IDs, handoff info, Zod schema metadata, and task context. Adapters that only need a prompt string can omit it entirely.
|
|
560
|
+
|
|
561
|
+
SDK-specific options belong on the adapter constructor, not on the shared interface:
|
|
562
|
+
|
|
563
|
+
```typescript
|
|
564
|
+
const adapter = await CursorSdkAdapter.create({
|
|
565
|
+
apiKey: process.env.CURSOR_API_KEY!,
|
|
566
|
+
model: "composer-2",
|
|
567
|
+
cwd: process.cwd(),
|
|
568
|
+
guardrailHooks,
|
|
569
|
+
});
|
|
570
|
+
```
|
|
571
|
+
|
|
340
572
|
## Guardrails
|
|
341
573
|
|
|
342
574
|
Guardrails evaluate commands, file paths, and file content before execution.
|
|
@@ -382,7 +614,8 @@ templates_dir: ./custom-templates # optional, overrides built-in templa
|
|
|
382
614
|
|
|
383
615
|
| Import path | Description |
|
|
384
616
|
|-------------|-------------|
|
|
385
|
-
| `agent-contracts-runtime` | Core runtime API (`runWorkflow`, `runTask`, `buildTaskPrompt`, `pluginRegistry`, `zodSchemaToPromptDescription`) |
|
|
617
|
+
| `agent-contracts-runtime` | Core runtime API (`runWorkflow`, `runTask`, `createRuntime`, `buildTaskPrompt`, `pluginRegistry`, `zodSchemaToPromptDescription`) |
|
|
618
|
+
| `agent-contracts-runtime` | Types (`WorkflowInvocation`, `HandoffInput`, `AgentExecutionRequest`, `WorkflowRegistries`, `SdkAdapter`, `AdapterSendOptions`, `TaskContext`, `TaskOutcome`, etc.) |
|
|
386
619
|
| `agent-contracts-runtime/generator` | Generator API (`generate`, `checkFreshness`, `buildContractContext`) |
|
|
387
620
|
| `agent-contracts-runtime/adapters/cursor-sdk` | Cursor SDK adapter |
|
|
388
621
|
| `agent-contracts-runtime/adapters/claude-agent-sdk` | Claude Agent SDK adapter |
|
package/cli-contract.yaml
CHANGED
|
@@ -171,14 +171,14 @@ commandSets:
|
|
|
171
171
|
and handoff validation mechanically.
|
|
172
172
|
arguments:
|
|
173
173
|
- name: workflow-id
|
|
174
|
-
required:
|
|
175
|
-
description: ID of the workflow to execute
|
|
174
|
+
required: false
|
|
175
|
+
description: ID of the workflow to execute. Required unless --file is used.
|
|
176
176
|
schema:
|
|
177
177
|
type: string
|
|
178
178
|
|
|
179
179
|
- name: user-request
|
|
180
|
-
required:
|
|
181
|
-
description: Natural language description of what to do.
|
|
180
|
+
required: false
|
|
181
|
+
description: Natural language description of what to do. Required unless --file is used.
|
|
182
182
|
schema:
|
|
183
183
|
type: string
|
|
184
184
|
|
|
@@ -219,6 +219,17 @@ commandSets:
|
|
|
219
219
|
type: boolean
|
|
220
220
|
default: false
|
|
221
221
|
|
|
222
|
+
- name: file
|
|
223
|
+
description: |
|
|
224
|
+
Path to a YAML invocation file. When provided, workflow-id and
|
|
225
|
+
user-request arguments are read from the file instead of CLI args.
|
|
226
|
+
schema:
|
|
227
|
+
type: string
|
|
228
|
+
file:
|
|
229
|
+
mode: read
|
|
230
|
+
exists: true
|
|
231
|
+
mediaType: application/yaml
|
|
232
|
+
|
|
222
233
|
exits:
|
|
223
234
|
"0":
|
|
224
235
|
description: Workflow completed successfully.
|
|
@@ -1,19 +1,7 @@
|
|
|
1
|
-
import { S as SdkAdapter } from '../task-runner-
|
|
1
|
+
import { S as SdkAdapter, A as AdapterSendOptions } from '../task-runner-JLQ-vpHl.js';
|
|
2
2
|
import { G as GuardrailHooks } from '../guardrail-hooks-5MSNWxnl.js';
|
|
3
3
|
import 'zod';
|
|
4
4
|
|
|
5
|
-
/**
|
|
6
|
-
* Claude Agent SDK Adapter — implements SdkAdapter for Claude Agent SDK
|
|
7
|
-
*
|
|
8
|
-
* Supports both send() (new session) and followUp() (same session continuation).
|
|
9
|
-
* The Claude Agent SDK uses a stateful agent instance, so followUp() sends
|
|
10
|
-
* an additional message within the same conversation.
|
|
11
|
-
*
|
|
12
|
-
* When guardrailHooks are provided, wraps each tool call with guardrail
|
|
13
|
-
* evaluation. Shell commands are checked via checkCommand, file operations
|
|
14
|
-
* via checkFilePath, and file edits via checkContent.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
5
|
interface ClaudeAgentSdkAdapterConfig {
|
|
18
6
|
cwd?: string;
|
|
19
7
|
model?: string;
|
|
@@ -27,9 +15,7 @@ declare class ClaudeAgentSdkAdapter implements SdkAdapter {
|
|
|
27
15
|
private guardrailHooks?;
|
|
28
16
|
constructor(config: ClaudeAgentSdkAdapterConfig);
|
|
29
17
|
private getOrCreateAgent;
|
|
30
|
-
send(prompt: string, options:
|
|
31
|
-
readonly: boolean;
|
|
32
|
-
}): Promise<string>;
|
|
18
|
+
send(prompt: string, options: AdapterSendOptions): Promise<string>;
|
|
33
19
|
followUp(message: string): Promise<string>;
|
|
34
20
|
}
|
|
35
21
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/adapters/claude-agent-sdk.ts"],"sourcesContent":["/**\n * Claude Agent SDK Adapter — implements SdkAdapter for Claude Agent SDK\n *\n * Supports both send() (new session) and followUp() (same session continuation).\n * The Claude Agent SDK uses a stateful agent instance, so followUp() sends\n * an additional message within the same conversation.\n *\n * When guardrailHooks are provided, wraps each tool call with guardrail\n * evaluation. Shell commands are checked via checkCommand, file operations\n * via checkFilePath, and file edits via checkContent.\n */\n\nimport type { SdkAdapter } from \"../lib/task-runner.js\";\nimport type { GuardrailHooks, HookResponse } from \"../lib/guardrail-hooks.js\";\n\ntype ClaudeAgentInstance = {\n sendMessage(prompt: string): Promise<{ text: string }>;\n};\n\nexport interface ClaudeAgentSdkAdapterConfig {\n cwd?: string;\n model?: string;\n guardrailHooks?: GuardrailHooks;\n}\n\nfunction buildClaudeHooks(hooks: GuardrailHooks): Record<string, unknown> {\n return {\n beforeShellExecution: (input: { command?: string }) => {\n const result = hooks.beforeShellExecution(input);\n return claudeHookResult(result);\n },\n preToolUse: (input: { tool_name?: string; tool_input?: { file_path?: string; path?: string } }) => {\n const result = hooks.preToolUse(input);\n return claudeHookResult(result);\n },\n afterFileEdit: (input: { file_path?: string; content?: string }) => {\n const result = hooks.afterFileEdit(input);\n return claudeHookResult(result);\n },\n };\n}\n\nfunction claudeHookResult(response: HookResponse): Record<string, unknown> {\n if (response.permission === \"deny\") {\n return {\n decision: \"deny\",\n message: response.user_message ?? response.agent_message,\n };\n }\n if (response.additionalContext) {\n return { additionalContext: response.additionalContext };\n }\n return {};\n}\n\nexport class ClaudeAgentSdkAdapter implements SdkAdapter {\n private agent: ClaudeAgentInstance | null = null;\n private cwd: string;\n private model: string;\n private allowedTools: string[] = [];\n private guardrailHooks?: GuardrailHooks;\n\n constructor(config: ClaudeAgentSdkAdapterConfig) {\n this.cwd = config.cwd ?? process.cwd();\n this.model = config.model ?? \"claude-sonnet-4-20250514\";\n this.guardrailHooks = config.guardrailHooks;\n }\n\n private async getOrCreateAgent(readonly: boolean): Promise<ClaudeAgentInstance> {\n if (this.agent) return this.agent;\n\n this.allowedTools = readonly\n ? [\"Read\", \"Glob\", \"Grep\"]\n : [\"Read\", \"Glob\", \"Grep\", \"Edit\", \"Write\", \"Bash\"];\n\n // @ts-expect-error — @anthropic-ai/claude-agent-sdk is an optional peer dependency\n const { ClaudeAgent } = await import(\"@anthropic-ai/claude-agent-sdk\") as {\n ClaudeAgent: { create(opts: Record<string, unknown>): Promise<ClaudeAgentInstance> };\n };\n\n const opts: Record<string, unknown> = {\n model: this.model,\n cwd: this.cwd,\n allowedTools: this.allowedTools,\n };\n\n if (this.guardrailHooks) {\n Object.assign(opts, buildClaudeHooks(this.guardrailHooks));\n }\n\n this.agent = await ClaudeAgent.create(opts);\n return this.agent;\n }\n\n async send(prompt: string, options:
|
|
1
|
+
{"version":3,"sources":["../../src/adapters/claude-agent-sdk.ts"],"sourcesContent":["/**\n * Claude Agent SDK Adapter — implements SdkAdapter for Claude Agent SDK\n *\n * Supports both send() (new session) and followUp() (same session continuation).\n * The Claude Agent SDK uses a stateful agent instance, so followUp() sends\n * an additional message within the same conversation.\n *\n * When guardrailHooks are provided, wraps each tool call with guardrail\n * evaluation. Shell commands are checked via checkCommand, file operations\n * via checkFilePath, and file edits via checkContent.\n */\n\nimport type { SdkAdapter } from \"../lib/task-runner.js\";\nimport type { GuardrailHooks, HookResponse } from \"../lib/guardrail-hooks.js\";\n\ntype ClaudeAgentInstance = {\n sendMessage(prompt: string): Promise<{ text: string }>;\n};\n\nexport interface ClaudeAgentSdkAdapterConfig {\n cwd?: string;\n model?: string;\n guardrailHooks?: GuardrailHooks;\n}\n\nfunction buildClaudeHooks(hooks: GuardrailHooks): Record<string, unknown> {\n return {\n beforeShellExecution: (input: { command?: string }) => {\n const result = hooks.beforeShellExecution(input);\n return claudeHookResult(result);\n },\n preToolUse: (input: { tool_name?: string; tool_input?: { file_path?: string; path?: string } }) => {\n const result = hooks.preToolUse(input);\n return claudeHookResult(result);\n },\n afterFileEdit: (input: { file_path?: string; content?: string }) => {\n const result = hooks.afterFileEdit(input);\n return claudeHookResult(result);\n },\n };\n}\n\nfunction claudeHookResult(response: HookResponse): Record<string, unknown> {\n if (response.permission === \"deny\") {\n return {\n decision: \"deny\",\n message: response.user_message ?? response.agent_message,\n };\n }\n if (response.additionalContext) {\n return { additionalContext: response.additionalContext };\n }\n return {};\n}\n\nexport class ClaudeAgentSdkAdapter implements SdkAdapter {\n private agent: ClaudeAgentInstance | null = null;\n private cwd: string;\n private model: string;\n private allowedTools: string[] = [];\n private guardrailHooks?: GuardrailHooks;\n\n constructor(config: ClaudeAgentSdkAdapterConfig) {\n this.cwd = config.cwd ?? process.cwd();\n this.model = config.model ?? \"claude-sonnet-4-20250514\";\n this.guardrailHooks = config.guardrailHooks;\n }\n\n private async getOrCreateAgent(readonly: boolean): Promise<ClaudeAgentInstance> {\n if (this.agent) return this.agent;\n\n this.allowedTools = readonly\n ? [\"Read\", \"Glob\", \"Grep\"]\n : [\"Read\", \"Glob\", \"Grep\", \"Edit\", \"Write\", \"Bash\"];\n\n // @ts-expect-error — @anthropic-ai/claude-agent-sdk is an optional peer dependency\n const { ClaudeAgent } = await import(\"@anthropic-ai/claude-agent-sdk\") as {\n ClaudeAgent: { create(opts: Record<string, unknown>): Promise<ClaudeAgentInstance> };\n };\n\n const opts: Record<string, unknown> = {\n model: this.model,\n cwd: this.cwd,\n allowedTools: this.allowedTools,\n };\n\n if (this.guardrailHooks) {\n Object.assign(opts, buildClaudeHooks(this.guardrailHooks));\n }\n\n this.agent = await ClaudeAgent.create(opts);\n return this.agent;\n }\n\n async send(prompt: string, options: import(\"../lib/task-runner.js\").AdapterSendOptions): Promise<string> {\n this.agent = null;\n const agent = await this.getOrCreateAgent(options.readonly);\n const result = await agent.sendMessage(prompt);\n return result.text;\n }\n\n async followUp(message: string): Promise<string> {\n if (!this.agent) {\n throw new Error(\"followUp() called before send() — no active session\");\n }\n const result = await this.agent.sendMessage(message);\n return result.text;\n }\n}\n"],"mappings":";AAyBA,SAAS,iBAAiB,OAAgD;AACxE,SAAO;AAAA,IACL,sBAAsB,CAAC,UAAgC;AACrD,YAAM,SAAS,MAAM,qBAAqB,KAAK;AAC/C,aAAO,iBAAiB,MAAM;AAAA,IAChC;AAAA,IACA,YAAY,CAAC,UAAsF;AACjG,YAAM,SAAS,MAAM,WAAW,KAAK;AACrC,aAAO,iBAAiB,MAAM;AAAA,IAChC;AAAA,IACA,eAAe,CAAC,UAAoD;AAClE,YAAM,SAAS,MAAM,cAAc,KAAK;AACxC,aAAO,iBAAiB,MAAM;AAAA,IAChC;AAAA,EACF;AACF;AAEA,SAAS,iBAAiB,UAAiD;AACzE,MAAI,SAAS,eAAe,QAAQ;AAClC,WAAO;AAAA,MACL,UAAU;AAAA,MACV,SAAS,SAAS,gBAAgB,SAAS;AAAA,IAC7C;AAAA,EACF;AACA,MAAI,SAAS,mBAAmB;AAC9B,WAAO,EAAE,mBAAmB,SAAS,kBAAkB;AAAA,EACzD;AACA,SAAO,CAAC;AACV;AAEO,IAAM,wBAAN,MAAkD;AAAA,EAC/C,QAAoC;AAAA,EACpC;AAAA,EACA;AAAA,EACA,eAAyB,CAAC;AAAA,EAC1B;AAAA,EAER,YAAY,QAAqC;AAC/C,SAAK,MAAM,OAAO,OAAO,QAAQ,IAAI;AACrC,SAAK,QAAQ,OAAO,SAAS;AAC7B,SAAK,iBAAiB,OAAO;AAAA,EAC/B;AAAA,EAEA,MAAc,iBAAiB,UAAiD;AAC9E,QAAI,KAAK,MAAO,QAAO,KAAK;AAE5B,SAAK,eAAe,WAChB,CAAC,QAAQ,QAAQ,MAAM,IACvB,CAAC,QAAQ,QAAQ,QAAQ,QAAQ,SAAS,MAAM;AAGpD,UAAM,EAAE,YAAY,IAAI,MAAM,OAAO,gCAAgC;AAIrE,UAAM,OAAgC;AAAA,MACpC,OAAO,KAAK;AAAA,MACZ,KAAK,KAAK;AAAA,MACV,cAAc,KAAK;AAAA,IACrB;AAEA,QAAI,KAAK,gBAAgB;AACvB,aAAO,OAAO,MAAM,iBAAiB,KAAK,cAAc,CAAC;AAAA,IAC3D;AAEA,SAAK,QAAQ,MAAM,YAAY,OAAO,IAAI;AAC1C,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,MAAM,KAAK,QAAgB,SAA8E;AACvG,SAAK,QAAQ;AACb,UAAM,QAAQ,MAAM,KAAK,iBAAiB,QAAQ,QAAQ;AAC1D,UAAM,SAAS,MAAM,MAAM,YAAY,MAAM;AAC7C,WAAO,OAAO;AAAA,EAChB;AAAA,EAEA,MAAM,SAAS,SAAkC;AAC/C,QAAI,CAAC,KAAK,OAAO;AACf,YAAM,IAAI,MAAM,0DAAqD;AAAA,IACvE;AACA,UAAM,SAAS,MAAM,KAAK,MAAM,YAAY,OAAO;AACnD,WAAO,OAAO;AAAA,EAChB;AACF;","names":[]}
|
|
@@ -1,18 +1,7 @@
|
|
|
1
|
-
import { S as SdkAdapter } from '../task-runner-
|
|
1
|
+
import { S as SdkAdapter, A as AdapterSendOptions } from '../task-runner-JLQ-vpHl.js';
|
|
2
2
|
import { G as GuardrailHooks } from '../guardrail-hooks-5MSNWxnl.js';
|
|
3
3
|
import 'zod';
|
|
4
4
|
|
|
5
|
-
/**
|
|
6
|
-
* Cursor SDK Adapter — implements SdkAdapter for Cursor Cloud Agents API
|
|
7
|
-
*
|
|
8
|
-
* Supports both send() (new session) and followUp() (same session continuation)
|
|
9
|
-
* for lightweight output-format corrections without re-executing the entire task.
|
|
10
|
-
*
|
|
11
|
-
* When guardrailHooks are provided, registers beforeShellExecution / preToolUse /
|
|
12
|
-
* afterFileEdit hooks with the SDK agent so guardrail violations are enforced
|
|
13
|
-
* during LLM sessions.
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
5
|
type CursorAgentRun = {
|
|
17
6
|
stream(): AsyncIterable<{
|
|
18
7
|
type: string;
|
|
@@ -37,9 +26,7 @@ declare class CursorSdkAdapter implements SdkAdapter {
|
|
|
37
26
|
private agent;
|
|
38
27
|
constructor(agent: CursorAgentInstance);
|
|
39
28
|
private collectStream;
|
|
40
|
-
send(prompt: string, _options:
|
|
41
|
-
readonly: boolean;
|
|
42
|
-
}): Promise<string>;
|
|
29
|
+
send(prompt: string, _options: AdapterSendOptions): Promise<string>;
|
|
43
30
|
followUp(message: string): Promise<string>;
|
|
44
31
|
static create(config: CursorSdkAdapterConfig): Promise<CursorSdkAdapter>;
|
|
45
32
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/adapters/cursor-sdk.ts"],"sourcesContent":["/**\n * Cursor SDK Adapter — implements SdkAdapter for Cursor Cloud Agents API\n *\n * Supports both send() (new session) and followUp() (same session continuation)\n * for lightweight output-format corrections without re-executing the entire task.\n *\n * When guardrailHooks are provided, registers beforeShellExecution / preToolUse /\n * afterFileEdit hooks with the SDK agent so guardrail violations are enforced\n * during LLM sessions.\n */\n\nimport type { SdkAdapter } from \"../lib/task-runner.js\";\nimport type { GuardrailHooks, HookResponse } from \"../lib/guardrail-hooks.js\";\n\ntype CursorAgentRun = {\n stream(): AsyncIterable<{\n type: string;\n message?: { content?: Array<{ type: string; text?: string }> };\n }>;\n};\n\ntype CursorAgentInstance = {\n send(prompt: string): Promise<CursorAgentRun>;\n};\n\nexport interface CursorSdkAdapterConfig {\n apiKey: string;\n model?: string;\n cwd?: string;\n guardrailHooks?: GuardrailHooks;\n}\n\n/**\n * Convert runtime GuardrailHooks into the shape the Cursor SDK expects.\n * The SDK uses `permissionDecision: \"deny\"` to block actions.\n */\nfunction buildSdkHooks(hooks: GuardrailHooks): Record<string, unknown> {\n return {\n beforeShellExecution: (input: { command?: string }) => {\n const result = hooks.beforeShellExecution(input);\n return hookResponseToSdkDecision(result);\n },\n preToolUse: (input: { tool_name?: string; tool_input?: { file_path?: string; path?: string } }) => {\n const result = hooks.preToolUse(input);\n return hookResponseToSdkDecision(result);\n },\n afterFileEdit: (input: { file_path?: string; content?: string }) => {\n const result = hooks.afterFileEdit(input);\n return hookResponseToSdkDecision(result);\n },\n };\n}\n\nfunction hookResponseToSdkDecision(response: HookResponse): Record<string, unknown> {\n if (response.permission === \"deny\") {\n return {\n permissionDecision: \"deny\",\n userMessage: response.user_message,\n agentMessage: response.agent_message,\n };\n }\n if (response.additionalContext) {\n return { additionalContext: response.additionalContext };\n }\n return {};\n}\n\nexport class CursorSdkAdapter implements SdkAdapter {\n private agent: CursorAgentInstance;\n\n constructor(agent: CursorAgentInstance) {\n this.agent = agent;\n }\n\n private async collectStream(run: CursorAgentRun): Promise<string> {\n let fullOutput = \"\";\n for await (const event of run.stream()) {\n if (event.type === \"assistant\" && event.message?.content) {\n for (const part of event.message.content) {\n if (part.type === \"text\" && part.text) {\n fullOutput += part.text;\n }\n }\n }\n }\n return fullOutput;\n }\n\n async send(prompt: string, _options:
|
|
1
|
+
{"version":3,"sources":["../../src/adapters/cursor-sdk.ts"],"sourcesContent":["/**\n * Cursor SDK Adapter — implements SdkAdapter for Cursor Cloud Agents API\n *\n * Supports both send() (new session) and followUp() (same session continuation)\n * for lightweight output-format corrections without re-executing the entire task.\n *\n * When guardrailHooks are provided, registers beforeShellExecution / preToolUse /\n * afterFileEdit hooks with the SDK agent so guardrail violations are enforced\n * during LLM sessions.\n */\n\nimport type { SdkAdapter } from \"../lib/task-runner.js\";\nimport type { GuardrailHooks, HookResponse } from \"../lib/guardrail-hooks.js\";\n\ntype CursorAgentRun = {\n stream(): AsyncIterable<{\n type: string;\n message?: { content?: Array<{ type: string; text?: string }> };\n }>;\n};\n\ntype CursorAgentInstance = {\n send(prompt: string): Promise<CursorAgentRun>;\n};\n\nexport interface CursorSdkAdapterConfig {\n apiKey: string;\n model?: string;\n cwd?: string;\n guardrailHooks?: GuardrailHooks;\n}\n\n/**\n * Convert runtime GuardrailHooks into the shape the Cursor SDK expects.\n * The SDK uses `permissionDecision: \"deny\"` to block actions.\n */\nfunction buildSdkHooks(hooks: GuardrailHooks): Record<string, unknown> {\n return {\n beforeShellExecution: (input: { command?: string }) => {\n const result = hooks.beforeShellExecution(input);\n return hookResponseToSdkDecision(result);\n },\n preToolUse: (input: { tool_name?: string; tool_input?: { file_path?: string; path?: string } }) => {\n const result = hooks.preToolUse(input);\n return hookResponseToSdkDecision(result);\n },\n afterFileEdit: (input: { file_path?: string; content?: string }) => {\n const result = hooks.afterFileEdit(input);\n return hookResponseToSdkDecision(result);\n },\n };\n}\n\nfunction hookResponseToSdkDecision(response: HookResponse): Record<string, unknown> {\n if (response.permission === \"deny\") {\n return {\n permissionDecision: \"deny\",\n userMessage: response.user_message,\n agentMessage: response.agent_message,\n };\n }\n if (response.additionalContext) {\n return { additionalContext: response.additionalContext };\n }\n return {};\n}\n\nexport class CursorSdkAdapter implements SdkAdapter {\n private agent: CursorAgentInstance;\n\n constructor(agent: CursorAgentInstance) {\n this.agent = agent;\n }\n\n private async collectStream(run: CursorAgentRun): Promise<string> {\n let fullOutput = \"\";\n for await (const event of run.stream()) {\n if (event.type === \"assistant\" && event.message?.content) {\n for (const part of event.message.content) {\n if (part.type === \"text\" && part.text) {\n fullOutput += part.text;\n }\n }\n }\n }\n return fullOutput;\n }\n\n async send(prompt: string, _options: import(\"../lib/task-runner.js\").AdapterSendOptions): Promise<string> {\n const run = await this.agent.send(prompt);\n return this.collectStream(run);\n }\n\n async followUp(message: string): Promise<string> {\n const run = await this.agent.send(message);\n return this.collectStream(run);\n }\n\n static async create(config: CursorSdkAdapterConfig): Promise<CursorSdkAdapter> {\n // @ts-expect-error — @cursor/sdk is an optional peer dependency\n const { Agent } = await import(\"@cursor/sdk\") as { Agent: { create(opts: Record<string, unknown>): Promise<CursorAgentInstance> } };\n\n const agentOpts: Record<string, unknown> = {\n apiKey: config.apiKey,\n model: { id: config.model ?? \"composer-2\" },\n local: { cwd: config.cwd ?? process.cwd() },\n };\n\n if (config.guardrailHooks) {\n Object.assign(agentOpts, buildSdkHooks(config.guardrailHooks));\n }\n\n const agent = await Agent.create(agentOpts);\n return new CursorSdkAdapter(agent);\n }\n}\n"],"mappings":";AAoCA,SAAS,cAAc,OAAgD;AACrE,SAAO;AAAA,IACL,sBAAsB,CAAC,UAAgC;AACrD,YAAM,SAAS,MAAM,qBAAqB,KAAK;AAC/C,aAAO,0BAA0B,MAAM;AAAA,IACzC;AAAA,IACA,YAAY,CAAC,UAAsF;AACjG,YAAM,SAAS,MAAM,WAAW,KAAK;AACrC,aAAO,0BAA0B,MAAM;AAAA,IACzC;AAAA,IACA,eAAe,CAAC,UAAoD;AAClE,YAAM,SAAS,MAAM,cAAc,KAAK;AACxC,aAAO,0BAA0B,MAAM;AAAA,IACzC;AAAA,EACF;AACF;AAEA,SAAS,0BAA0B,UAAiD;AAClF,MAAI,SAAS,eAAe,QAAQ;AAClC,WAAO;AAAA,MACL,oBAAoB;AAAA,MACpB,aAAa,SAAS;AAAA,MACtB,cAAc,SAAS;AAAA,IACzB;AAAA,EACF;AACA,MAAI,SAAS,mBAAmB;AAC9B,WAAO,EAAE,mBAAmB,SAAS,kBAAkB;AAAA,EACzD;AACA,SAAO,CAAC;AACV;AAEO,IAAM,mBAAN,MAAM,kBAAuC;AAAA,EAC1C;AAAA,EAER,YAAY,OAA4B;AACtC,SAAK,QAAQ;AAAA,EACf;AAAA,EAEA,MAAc,cAAc,KAAsC;AAChE,QAAI,aAAa;AACjB,qBAAiB,SAAS,IAAI,OAAO,GAAG;AACtC,UAAI,MAAM,SAAS,eAAe,MAAM,SAAS,SAAS;AACxD,mBAAW,QAAQ,MAAM,QAAQ,SAAS;AACxC,cAAI,KAAK,SAAS,UAAU,KAAK,MAAM;AACrC,0BAAc,KAAK;AAAA,UACrB;AAAA,QACF;AAAA,MACF;AAAA,IACF;AACA,WAAO;AAAA,EACT;AAAA,EAEA,MAAM,KAAK,QAAgB,UAA+E;AACxG,UAAM,MAAM,MAAM,KAAK,MAAM,KAAK,MAAM;AACxC,WAAO,KAAK,cAAc,GAAG;AAAA,EAC/B;AAAA,EAEA,MAAM,SAAS,SAAkC;AAC/C,UAAM,MAAM,MAAM,KAAK,MAAM,KAAK,OAAO;AACzC,WAAO,KAAK,cAAc,GAAG;AAAA,EAC/B;AAAA,EAEA,aAAa,OAAO,QAA2D;AAE7E,UAAM,EAAE,MAAM,IAAI,MAAM,OAAO,aAAa;AAE5C,UAAM,YAAqC;AAAA,MACzC,QAAQ,OAAO;AAAA,MACf,OAAO,EAAE,IAAI,OAAO,SAAS,aAAa;AAAA,MAC1C,OAAO,EAAE,KAAK,OAAO,OAAO,QAAQ,IAAI,EAAE;AAAA,IAC5C;AAEA,QAAI,OAAO,gBAAgB;AACzB,aAAO,OAAO,WAAW,cAAc,OAAO,cAAc,CAAC;AAAA,IAC/D;AAEA,UAAM,QAAQ,MAAM,MAAM,OAAO,SAAS;AAC1C,WAAO,IAAI,kBAAiB,KAAK;AAAA,EACnC;AACF;","names":[]}
|
package/dist/adapters/mock.d.ts
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
import { S as SdkAdapter } from '../task-runner-
|
|
1
|
+
import { S as SdkAdapter, A as AdapterSendOptions } from '../task-runner-JLQ-vpHl.js';
|
|
2
2
|
import 'zod';
|
|
3
3
|
|
|
4
|
-
/**
|
|
5
|
-
* Mock SDK Adapter — for testing and demo purposes
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
4
|
declare class MockAdapter implements SdkAdapter {
|
|
9
5
|
private responses;
|
|
10
6
|
private defaultLatencyMs;
|
|
@@ -12,9 +8,7 @@ declare class MockAdapter implements SdkAdapter {
|
|
|
12
8
|
responses?: Record<string, (userRequest: string) => string>;
|
|
13
9
|
defaultLatencyMs?: number;
|
|
14
10
|
});
|
|
15
|
-
send(prompt: string, _options:
|
|
16
|
-
readonly: boolean;
|
|
17
|
-
}): Promise<string>;
|
|
11
|
+
send(prompt: string, _options: AdapterSendOptions): Promise<string>;
|
|
18
12
|
}
|
|
19
13
|
|
|
20
14
|
export { MockAdapter };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/adapters/mock.ts"],"sourcesContent":["/**\n * Mock SDK Adapter — for testing and demo purposes\n */\n\nimport type { SdkAdapter } from \"../lib/task-runner.js\";\n\nexport class MockAdapter implements SdkAdapter {\n private responses: Record<string, (userRequest: string) => string>;\n private defaultLatencyMs: number;\n\n constructor(options?: {\n responses?: Record<string, (userRequest: string) => string>;\n defaultLatencyMs?: number;\n }) {\n this.responses = options?.responses ?? {};\n this.defaultLatencyMs = options?.defaultLatencyMs ?? 0;\n }\n\n async send(prompt: string, _options:
|
|
1
|
+
{"version":3,"sources":["../../src/adapters/mock.ts"],"sourcesContent":["/**\n * Mock SDK Adapter — for testing and demo purposes\n */\n\nimport type { SdkAdapter } from \"../lib/task-runner.js\";\n\nexport class MockAdapter implements SdkAdapter {\n private responses: Record<string, (userRequest: string) => string>;\n private defaultLatencyMs: number;\n\n constructor(options?: {\n responses?: Record<string, (userRequest: string) => string>;\n defaultLatencyMs?: number;\n }) {\n this.responses = options?.responses ?? {};\n this.defaultLatencyMs = options?.defaultLatencyMs ?? 0;\n }\n\n async send(prompt: string, _options: import(\"../lib/task-runner.js\").AdapterSendOptions): Promise<string> {\n const match = prompt.match(/## Task: (\\S+)/);\n const taskId = match?.[1] ?? \"unknown\";\n\n const reqMatch = prompt.match(/## User Request\\n\\n([\\s\\S]*?)(?:\\n\\n---|$)/);\n const userRequest = reqMatch?.[1]?.trim() ?? \"\";\n\n if (this.defaultLatencyMs > 0) {\n await new Promise((r) => setTimeout(r, this.defaultLatencyMs));\n }\n\n const responseFn = this.responses[taskId];\n if (!responseFn) {\n return `Task \"${taskId}\" completed but no structured output available.`;\n }\n\n return responseFn(userRequest);\n }\n}\n"],"mappings":";AAMO,IAAM,cAAN,MAAwC;AAAA,EACrC;AAAA,EACA;AAAA,EAER,YAAY,SAGT;AACD,SAAK,YAAY,SAAS,aAAa,CAAC;AACxC,SAAK,mBAAmB,SAAS,oBAAoB;AAAA,EACvD;AAAA,EAEA,MAAM,KAAK,QAAgB,UAA+E;AACxG,UAAM,QAAQ,OAAO,MAAM,gBAAgB;AAC3C,UAAM,SAAS,QAAQ,CAAC,KAAK;AAE7B,UAAM,WAAW,OAAO,MAAM,4CAA4C;AAC1E,UAAM,cAAc,WAAW,CAAC,GAAG,KAAK,KAAK;AAE7C,QAAI,KAAK,mBAAmB,GAAG;AAC7B,YAAM,IAAI,QAAQ,CAAC,MAAM,WAAW,GAAG,KAAK,gBAAgB,CAAC;AAAA,IAC/D;AAEA,UAAM,aAAa,KAAK,UAAU,MAAM;AACxC,QAAI,CAAC,YAAY;AACf,aAAO,SAAS,MAAM;AAAA,IACxB;AAEA,WAAO,WAAW,WAAW;AAAA,EAC/B;AACF;","names":[]}
|