agent-contracts-runtime 0.6.1 → 0.7.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 +63 -4
- package/dist/adapters/claude-agent-sdk.d.ts +62 -6
- package/dist/adapters/claude-agent-sdk.js +125 -47
- package/dist/adapters/claude-agent-sdk.js.map +1 -1
- package/dist/adapters/cursor-sdk.d.ts +1 -1
- package/dist/adapters/mock.d.ts +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/{task-runner-JLQ-vpHl.d.ts → task-runner-Bt2XiEUU.d.ts} +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -317,6 +317,23 @@ const result = await runWorkflow(adapter, "feature-implement", {
|
|
|
317
317
|
console.log(`${result.workflow_id}: ${result.status} (${result.total_elapsed_ms}ms)`);
|
|
318
318
|
```
|
|
319
319
|
|
|
320
|
+
Or with the Claude adapter:
|
|
321
|
+
|
|
322
|
+
```typescript
|
|
323
|
+
import { runWorkflow } from "agent-contracts-runtime";
|
|
324
|
+
import { ClaudeAgentSdkAdapter } from "agent-contracts-runtime/adapters/claude-agent-sdk";
|
|
325
|
+
|
|
326
|
+
const adapter = new ClaudeAgentSdkAdapter({
|
|
327
|
+
cwd: process.cwd(),
|
|
328
|
+
});
|
|
329
|
+
|
|
330
|
+
const result = await runWorkflow(adapter, "feature-implement", {
|
|
331
|
+
user_request: "Add login endpoint with JWT",
|
|
332
|
+
maxFollowUps: 3,
|
|
333
|
+
maxRetries: 1,
|
|
334
|
+
});
|
|
335
|
+
```
|
|
336
|
+
|
|
320
337
|
For production integration, prefer the Structured API or Builder API so that input handoffs are validated before execution.
|
|
321
338
|
|
|
322
339
|
### Structured API
|
|
@@ -492,7 +509,8 @@ runtime:
|
|
|
492
509
|
```
|
|
493
510
|
|
|
494
511
|
```bash
|
|
495
|
-
agent-runtime run --file ./invocation.yaml --adapter
|
|
512
|
+
agent-runtime run --file ./invocation.yaml --adapter claude
|
|
513
|
+
# or: --adapter cursor, --adapter mock
|
|
496
514
|
```
|
|
497
515
|
|
|
498
516
|
For full CLI reference with exit codes and output schemas, see [docs/cli-reference.md](docs/cli-reference.md).
|
|
@@ -504,7 +522,7 @@ The CLI specification is managed contract-first via [`cli-contracts`](https://ww
|
|
|
504
522
|
| Adapter | SDK | Status |
|
|
505
523
|
|---------|-----|--------|
|
|
506
524
|
| `cursor` | Cursor Cloud Agents (`@cursor/sdk`) | Implemented |
|
|
507
|
-
| `claude` | Claude Agent SDK (`@anthropic-ai/claude-agent-sdk`) |
|
|
525
|
+
| `claude` | Claude Agent SDK (`@anthropic-ai/claude-agent-sdk`) | Implemented |
|
|
508
526
|
| `openai` | OpenAI Agents SDK | Planned |
|
|
509
527
|
| `mock` | Simulated responses for testing/demo | Implemented |
|
|
510
528
|
|
|
@@ -544,14 +562,53 @@ Adapters may start with `send` and later upgrade to `sendExecution` without chan
|
|
|
544
562
|
SDK-specific options belong on the adapter constructor, not on the shared interface:
|
|
545
563
|
|
|
546
564
|
```typescript
|
|
547
|
-
|
|
565
|
+
// Cursor SDK
|
|
566
|
+
const cursorAdapter = await CursorSdkAdapter.create({
|
|
548
567
|
apiKey: process.env.CURSOR_API_KEY!,
|
|
549
568
|
model: "composer-2",
|
|
550
569
|
cwd: process.cwd(),
|
|
551
570
|
guardrailHooks,
|
|
552
571
|
});
|
|
572
|
+
|
|
573
|
+
// Claude Agent SDK
|
|
574
|
+
const claudeAdapter = new ClaudeAgentSdkAdapter({
|
|
575
|
+
model: "claude-sonnet-4-20250514",
|
|
576
|
+
cwd: process.cwd(),
|
|
577
|
+
guardrailHooks,
|
|
578
|
+
});
|
|
553
579
|
```
|
|
554
580
|
|
|
581
|
+
### Claude Agent SDK adapter
|
|
582
|
+
|
|
583
|
+
The Claude adapter wraps `@anthropic-ai/claude-agent-sdk`, which runs Claude as a stateful coding agent with built-in tool execution (Read, Edit, Bash, etc.).
|
|
584
|
+
|
|
585
|
+
```typescript
|
|
586
|
+
import { ClaudeAgentSdkAdapter } from "agent-contracts-runtime/adapters/claude-agent-sdk";
|
|
587
|
+
|
|
588
|
+
const adapter = new ClaudeAgentSdkAdapter({
|
|
589
|
+
cwd: process.cwd(),
|
|
590
|
+
model: "claude-sonnet-4-20250514", // optional, uses SDK default
|
|
591
|
+
permissionMode: "bypassPermissions", // default for automated workflows
|
|
592
|
+
maxTurns: 20, // optional turn limit
|
|
593
|
+
guardrailHooks, // optional guardrail enforcement
|
|
594
|
+
});
|
|
595
|
+
```
|
|
596
|
+
|
|
597
|
+
Internally the adapter calls the SDK's `query()` function, which returns an AsyncGenerator of SDK events. The adapter iterates the stream and extracts the final result text.
|
|
598
|
+
|
|
599
|
+
`followUp()` resumes the same session via the SDK's `resume` option, so the agent retains full conversation context when correcting output format.
|
|
600
|
+
|
|
601
|
+
| Config option | Description | Default |
|
|
602
|
+
|---------------|-------------|---------|
|
|
603
|
+
| `cwd` | Working directory | `process.cwd()` |
|
|
604
|
+
| `model` | Claude model identifier | SDK default |
|
|
605
|
+
| `tools` | Available tools (string array or `{ type: 'preset', preset: 'claude_code' }`) | Auto-selected based on `readonly` |
|
|
606
|
+
| `permissionMode` | `"default"` / `"acceptEdits"` / `"bypassPermissions"` / `"plan"` | `"bypassPermissions"` |
|
|
607
|
+
| `maxTurns` | Maximum conversation turns | No limit |
|
|
608
|
+
| `guardrailHooks` | Runtime guardrail hooks (mapped to SDK `PreToolUse` hooks) | None |
|
|
609
|
+
|
|
610
|
+
> **Note:** `@anthropic-ai/claude-agent-sdk` requires `zod@^4.0.0` as a peer dependency. If your project uses `zod@^3`, install the SDK in a separate workspace or use npm `--legacy-peer-deps`.
|
|
611
|
+
|
|
555
612
|
## Handoff validation
|
|
556
613
|
|
|
557
614
|
The runtime validates both input and output handoffs against generated Zod schemas.
|
|
@@ -572,7 +629,7 @@ If validation fails, the runtime attempts a followUp (lightweight, same session)
|
|
|
572
629
|
| **Default limit** | `maxFollowUps: 2` | `maxRetries: 0` (opt-in) |
|
|
573
630
|
| **DSL mapping** | Independent (always available) | `step.max_retries` in workflow DSL |
|
|
574
631
|
| **Trigger** | Zod schema validation error | Empty output, or `decideRetryStrategy` |
|
|
575
|
-
| **Session** | Same session continues | New session |
|
|
632
|
+
| **Session** | Same session continues (Cursor: same agent, Claude: `resume` with session ID) | New session |
|
|
576
633
|
|
|
577
634
|
The prompt includes the full handoff schema field table and a YAML example, so the agent can produce valid output on the first attempt without guessing the format.
|
|
578
635
|
|
|
@@ -759,6 +816,8 @@ templates_dir: ./custom-templates # optional, overrides built-in templa
|
|
|
759
816
|
- Node.js 20+
|
|
760
817
|
- TypeScript 5.x (ESM, strict mode)
|
|
761
818
|
- `agent-contracts` (optional peer dependency for DSL resolution)
|
|
819
|
+
- `@anthropic-ai/claude-agent-sdk` (optional, for Claude adapter — requires zod ^4.0.0)
|
|
820
|
+
- `@cursor/sdk` (optional, for Cursor adapter)
|
|
762
821
|
|
|
763
822
|
## License
|
|
764
823
|
|
|
@@ -1,22 +1,78 @@
|
|
|
1
|
-
import { S as SdkAdapter, A as AdapterSendOptions } from '../task-runner-
|
|
1
|
+
import { S as SdkAdapter, A as AdapterSendOptions, a as AgentExecutionRequest } from '../task-runner-Bt2XiEUU.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 @anthropic-ai/claude-agent-sdk
|
|
7
|
+
*
|
|
8
|
+
* Uses the `query()` function from the Claude Agent SDK to run Claude as a
|
|
9
|
+
* stateful coding agent with tool execution (Read, Edit, Bash, etc.).
|
|
10
|
+
*
|
|
11
|
+
* Supports:
|
|
12
|
+
* - send() — start a new query session and return the result text
|
|
13
|
+
* - followUp() — resume the same session for output-format corrections
|
|
14
|
+
* - sendExecution() — rich path using full contract context
|
|
15
|
+
*
|
|
16
|
+
* The SDK returns an AsyncGenerator of SDKMessage events. The adapter iterates
|
|
17
|
+
* the stream, extracts the final result text from the SDKResultSuccess message,
|
|
18
|
+
* and captures the session_id for followUp via `resume`.
|
|
19
|
+
*
|
|
20
|
+
* GuardrailHooks are mapped to the SDK's PreToolUse hook system.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
type SDKMessage = {
|
|
24
|
+
type: string;
|
|
25
|
+
subtype?: string;
|
|
26
|
+
result?: string;
|
|
27
|
+
error?: string;
|
|
28
|
+
session_id?: string;
|
|
29
|
+
};
|
|
30
|
+
type QueryOptions = Record<string, unknown>;
|
|
31
|
+
type QueryFn = (params: {
|
|
32
|
+
prompt: string;
|
|
33
|
+
options?: QueryOptions;
|
|
34
|
+
}) => AsyncGenerator<SDKMessage, void>;
|
|
5
35
|
interface ClaudeAgentSdkAdapterConfig {
|
|
36
|
+
/** Working directory for the agent. Defaults to process.cwd(). */
|
|
6
37
|
cwd?: string;
|
|
38
|
+
/** Model identifier (e.g. "claude-sonnet-4-20250514"). Uses SDK default if omitted. */
|
|
7
39
|
model?: string;
|
|
40
|
+
/**
|
|
41
|
+
* Available tools. Defaults to read-only or read-write set based on AdapterSendOptions.
|
|
42
|
+
* Set to `{ type: 'preset', preset: 'claude_code' }` for all Claude Code tools.
|
|
43
|
+
*/
|
|
44
|
+
tools?: string[] | {
|
|
45
|
+
type: "preset";
|
|
46
|
+
preset: "claude_code";
|
|
47
|
+
};
|
|
48
|
+
/** Permission mode. Defaults to "bypassPermissions" for automated workflows. */
|
|
49
|
+
permissionMode?: "default" | "acceptEdits" | "bypassPermissions" | "plan";
|
|
50
|
+
/** Max turns before stopping. */
|
|
51
|
+
maxTurns?: number;
|
|
52
|
+
/** Runtime guardrail hooks enforced via PreToolUse SDK hooks. */
|
|
8
53
|
guardrailHooks?: GuardrailHooks;
|
|
9
54
|
}
|
|
10
55
|
declare class ClaudeAgentSdkAdapter implements SdkAdapter {
|
|
11
|
-
private agent;
|
|
12
56
|
private cwd;
|
|
13
57
|
private model;
|
|
14
|
-
private
|
|
15
|
-
private
|
|
16
|
-
|
|
17
|
-
private
|
|
58
|
+
private tools;
|
|
59
|
+
private permissionMode;
|
|
60
|
+
private maxTurns;
|
|
61
|
+
private guardrailHooks;
|
|
62
|
+
private lastSessionId;
|
|
63
|
+
private queryFn;
|
|
64
|
+
constructor(config?: ClaudeAgentSdkAdapterConfig);
|
|
65
|
+
private resolveQueryFn;
|
|
66
|
+
private buildOptions;
|
|
67
|
+
private runQuery;
|
|
18
68
|
send(prompt: string, options: AdapterSendOptions): Promise<string>;
|
|
19
69
|
followUp(message: string): Promise<string>;
|
|
70
|
+
sendExecution(request: AgentExecutionRequest): Promise<string>;
|
|
71
|
+
/**
|
|
72
|
+
* Inject a custom query function for testing.
|
|
73
|
+
* Bypasses the dynamic import of @anthropic-ai/claude-agent-sdk.
|
|
74
|
+
*/
|
|
75
|
+
static withQueryFn(queryFn: QueryFn, config?: ClaudeAgentSdkAdapterConfig): ClaudeAgentSdkAdapter;
|
|
20
76
|
}
|
|
21
77
|
|
|
22
78
|
export { ClaudeAgentSdkAdapter, type ClaudeAgentSdkAdapterConfig };
|
|
@@ -1,70 +1,148 @@
|
|
|
1
1
|
// src/adapters/claude-agent-sdk.ts
|
|
2
|
-
function buildClaudeHooks(
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
2
|
+
function buildClaudeHooks(guardrails) {
|
|
3
|
+
const preToolUseHook = {
|
|
4
|
+
hooks: [
|
|
5
|
+
(input) => {
|
|
6
|
+
const toolInput = input.tool_input;
|
|
7
|
+
const toolName = input.tool_name;
|
|
8
|
+
if (toolName === "Bash" || toolName === "Shell") {
|
|
9
|
+
const command = toolInput?.command ?? toolInput?.input;
|
|
10
|
+
if (command) {
|
|
11
|
+
const result = guardrails.beforeShellExecution({ command });
|
|
12
|
+
if (result.permission === "deny") {
|
|
13
|
+
return {
|
|
14
|
+
hookEventName: "PreToolUse",
|
|
15
|
+
permissionDecision: "deny",
|
|
16
|
+
permissionDecisionReason: result.user_message ?? result.agent_message
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
if (result.additionalContext) {
|
|
20
|
+
return { hookEventName: "PreToolUse", additionalContext: result.additionalContext };
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
const filePath = toolInput?.file_path ?? toolInput?.path;
|
|
25
|
+
if (filePath) {
|
|
26
|
+
const pathResult = guardrails.preToolUse({
|
|
27
|
+
tool_name: toolName,
|
|
28
|
+
tool_input: { file_path: filePath }
|
|
29
|
+
});
|
|
30
|
+
if (pathResult.permission === "deny") {
|
|
31
|
+
return {
|
|
32
|
+
hookEventName: "PreToolUse",
|
|
33
|
+
permissionDecision: "deny",
|
|
34
|
+
permissionDecisionReason: pathResult.user_message ?? pathResult.agent_message
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
if (pathResult.additionalContext) {
|
|
38
|
+
return { hookEventName: "PreToolUse", additionalContext: pathResult.additionalContext };
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return { hookEventName: "PreToolUse" };
|
|
42
|
+
}
|
|
43
|
+
]
|
|
16
44
|
};
|
|
45
|
+
return { PreToolUse: [preToolUseHook] };
|
|
17
46
|
}
|
|
18
|
-
|
|
19
|
-
if (response.permission === "deny") {
|
|
20
|
-
return {
|
|
21
|
-
decision: "deny",
|
|
22
|
-
message: response.user_message ?? response.agent_message
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
if (response.additionalContext) {
|
|
26
|
-
return { additionalContext: response.additionalContext };
|
|
27
|
-
}
|
|
28
|
-
return {};
|
|
29
|
-
}
|
|
30
|
-
var ClaudeAgentSdkAdapter = class {
|
|
31
|
-
agent = null;
|
|
47
|
+
var ClaudeAgentSdkAdapter = class _ClaudeAgentSdkAdapter {
|
|
32
48
|
cwd;
|
|
33
49
|
model;
|
|
34
|
-
|
|
50
|
+
tools;
|
|
51
|
+
permissionMode;
|
|
52
|
+
maxTurns;
|
|
35
53
|
guardrailHooks;
|
|
36
|
-
|
|
54
|
+
lastSessionId = null;
|
|
55
|
+
queryFn = null;
|
|
56
|
+
constructor(config = {}) {
|
|
37
57
|
this.cwd = config.cwd ?? process.cwd();
|
|
38
|
-
this.model = config.model
|
|
58
|
+
this.model = config.model;
|
|
59
|
+
this.tools = config.tools;
|
|
60
|
+
this.permissionMode = config.permissionMode ?? "bypassPermissions";
|
|
61
|
+
this.maxTurns = config.maxTurns;
|
|
39
62
|
this.guardrailHooks = config.guardrailHooks;
|
|
40
63
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
64
|
+
// -------------------------------------------------------------------------
|
|
65
|
+
// Internal helpers
|
|
66
|
+
// -------------------------------------------------------------------------
|
|
67
|
+
async resolveQueryFn() {
|
|
68
|
+
if (this.queryFn) return this.queryFn;
|
|
69
|
+
const sdk = await import("@anthropic-ai/claude-agent-sdk");
|
|
70
|
+
this.queryFn = sdk.query;
|
|
71
|
+
return this.queryFn;
|
|
72
|
+
}
|
|
73
|
+
buildOptions(readonly, resume) {
|
|
45
74
|
const opts = {
|
|
46
|
-
model: this.model,
|
|
47
75
|
cwd: this.cwd,
|
|
48
|
-
|
|
76
|
+
permissionMode: this.permissionMode,
|
|
77
|
+
allowDangerouslySkipPermissions: this.permissionMode === "bypassPermissions"
|
|
49
78
|
};
|
|
79
|
+
if (this.model) opts.model = this.model;
|
|
80
|
+
if (this.maxTurns) opts.maxTurns = this.maxTurns;
|
|
81
|
+
if (this.tools) {
|
|
82
|
+
opts.tools = this.tools;
|
|
83
|
+
} else {
|
|
84
|
+
opts.tools = readonly ? ["Read", "Glob", "Grep"] : ["Read", "Glob", "Grep", "Edit", "Write", "Bash"];
|
|
85
|
+
}
|
|
86
|
+
if (resume) opts.resume = resume;
|
|
50
87
|
if (this.guardrailHooks) {
|
|
51
|
-
|
|
88
|
+
opts.hooks = buildClaudeHooks(this.guardrailHooks);
|
|
89
|
+
}
|
|
90
|
+
return opts;
|
|
91
|
+
}
|
|
92
|
+
async runQuery(prompt, options) {
|
|
93
|
+
const queryFn = await this.resolveQueryFn();
|
|
94
|
+
const stream = queryFn({ prompt, options });
|
|
95
|
+
let resultText = "";
|
|
96
|
+
let sessionId = "";
|
|
97
|
+
for await (const message of stream) {
|
|
98
|
+
if (message.type === "result") {
|
|
99
|
+
sessionId = message.session_id ?? sessionId;
|
|
100
|
+
if (message.subtype === "success") {
|
|
101
|
+
resultText = message.result;
|
|
102
|
+
} else if (message.subtype === "error") {
|
|
103
|
+
throw new Error(`Claude Agent SDK error: ${message.error}`);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
52
106
|
}
|
|
53
|
-
|
|
54
|
-
return this.agent;
|
|
107
|
+
return { text: resultText, sessionId };
|
|
55
108
|
}
|
|
109
|
+
// -------------------------------------------------------------------------
|
|
110
|
+
// SdkAdapter interface
|
|
111
|
+
// -------------------------------------------------------------------------
|
|
56
112
|
async send(prompt, options) {
|
|
57
|
-
this.
|
|
58
|
-
const
|
|
59
|
-
const
|
|
60
|
-
|
|
113
|
+
this.lastSessionId = null;
|
|
114
|
+
const opts = this.buildOptions(options.readonly);
|
|
115
|
+
const { text, sessionId } = await this.runQuery(prompt, opts);
|
|
116
|
+
this.lastSessionId = sessionId;
|
|
117
|
+
return text;
|
|
61
118
|
}
|
|
62
119
|
async followUp(message) {
|
|
63
|
-
if (!this.
|
|
120
|
+
if (!this.lastSessionId) {
|
|
64
121
|
throw new Error("followUp() called before send() \u2014 no active session");
|
|
65
122
|
}
|
|
66
|
-
const
|
|
67
|
-
|
|
123
|
+
const opts = this.buildOptions(false, this.lastSessionId);
|
|
124
|
+
const { text, sessionId } = await this.runQuery(message, opts);
|
|
125
|
+
this.lastSessionId = sessionId;
|
|
126
|
+
return text;
|
|
127
|
+
}
|
|
128
|
+
async sendExecution(request) {
|
|
129
|
+
this.lastSessionId = null;
|
|
130
|
+
const opts = this.buildOptions(request.options.readonly);
|
|
131
|
+
const { text, sessionId } = await this.runQuery(request.prompt, opts);
|
|
132
|
+
this.lastSessionId = sessionId;
|
|
133
|
+
return text;
|
|
134
|
+
}
|
|
135
|
+
// -------------------------------------------------------------------------
|
|
136
|
+
// Test support
|
|
137
|
+
// -------------------------------------------------------------------------
|
|
138
|
+
/**
|
|
139
|
+
* Inject a custom query function for testing.
|
|
140
|
+
* Bypasses the dynamic import of @anthropic-ai/claude-agent-sdk.
|
|
141
|
+
*/
|
|
142
|
+
static withQueryFn(queryFn, config) {
|
|
143
|
+
const adapter = new _ClaudeAgentSdkAdapter(config);
|
|
144
|
+
adapter.queryFn = queryFn;
|
|
145
|
+
return adapter;
|
|
68
146
|
}
|
|
69
147
|
};
|
|
70
148
|
export {
|
|
@@ -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: 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
|
+
{"version":3,"sources":["../../src/adapters/claude-agent-sdk.ts"],"sourcesContent":["/**\n * Claude Agent SDK Adapter — implements SdkAdapter for @anthropic-ai/claude-agent-sdk\n *\n * Uses the `query()` function from the Claude Agent SDK to run Claude as a\n * stateful coding agent with tool execution (Read, Edit, Bash, etc.).\n *\n * Supports:\n * - send() — start a new query session and return the result text\n * - followUp() — resume the same session for output-format corrections\n * - sendExecution() — rich path using full contract context\n *\n * The SDK returns an AsyncGenerator of SDKMessage events. The adapter iterates\n * the stream, extracts the final result text from the SDKResultSuccess message,\n * and captures the session_id for followUp via `resume`.\n *\n * GuardrailHooks are mapped to the SDK's PreToolUse hook system.\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 zod v4)\n// ---------------------------------------------------------------------------\n\ntype SDKResultSuccess = {\n type: \"result\";\n subtype: \"success\";\n result: string;\n session_id: string;\n};\n\ntype SDKResultError = {\n type: \"result\";\n subtype: \"error\";\n error: string;\n session_id: string;\n};\n\ntype SDKMessage = {\n type: string;\n subtype?: string;\n result?: string;\n error?: string;\n session_id?: string;\n};\n\ntype HookCallbackInput = {\n hook_event_name: string;\n tool_name: string;\n tool_input: unknown;\n [key: string]: unknown;\n};\n\ntype HookCallbackOutput = {\n hookEventName: string;\n permissionDecision?: \"allow\" | \"deny\" | \"ask\";\n permissionDecisionReason?: string;\n additionalContext?: string;\n};\n\ntype HookCallbackMatcher = {\n tool_name?: string;\n hooks: Array<(input: HookCallbackInput) => HookCallbackOutput | Promise<HookCallbackOutput>>;\n};\n\ntype QueryOptions = Record<string, unknown>;\n\ntype QueryFn = (params: {\n prompt: string;\n options?: QueryOptions;\n}) => AsyncGenerator<SDKMessage, void>;\n\n// ---------------------------------------------------------------------------\n// Guardrail hook bridge\n// ---------------------------------------------------------------------------\n\nfunction buildClaudeHooks(\n guardrails: GuardrailHooks,\n): Partial<Record<string, HookCallbackMatcher[]>> {\n const preToolUseHook: HookCallbackMatcher = {\n hooks: [\n (input: HookCallbackInput): HookCallbackOutput => {\n const toolInput = input.tool_input as Record<string, unknown> | undefined;\n const toolName = input.tool_name;\n\n if (toolName === \"Bash\" || toolName === \"Shell\") {\n const command = (toolInput?.command ?? toolInput?.input) as string | undefined;\n if (command) {\n const result = guardrails.beforeShellExecution({ command });\n if (result.permission === \"deny\") {\n return {\n hookEventName: \"PreToolUse\",\n permissionDecision: \"deny\",\n permissionDecisionReason: result.user_message ?? result.agent_message,\n };\n }\n if (result.additionalContext) {\n return { hookEventName: \"PreToolUse\", additionalContext: result.additionalContext };\n }\n }\n }\n\n const filePath = (toolInput?.file_path ?? toolInput?.path) as string | undefined;\n if (filePath) {\n const pathResult = guardrails.preToolUse({\n tool_name: toolName,\n tool_input: { file_path: filePath },\n });\n if (pathResult.permission === \"deny\") {\n return {\n hookEventName: \"PreToolUse\",\n permissionDecision: \"deny\",\n permissionDecisionReason: pathResult.user_message ?? pathResult.agent_message,\n };\n }\n if (pathResult.additionalContext) {\n return { hookEventName: \"PreToolUse\", additionalContext: pathResult.additionalContext };\n }\n }\n\n return { hookEventName: \"PreToolUse\" };\n },\n ],\n };\n\n return { PreToolUse: [preToolUseHook] };\n}\n\n// ---------------------------------------------------------------------------\n// Config\n// ---------------------------------------------------------------------------\n\nexport interface ClaudeAgentSdkAdapterConfig {\n /** Working directory for the agent. Defaults to process.cwd(). */\n cwd?: string;\n /** Model identifier (e.g. \"claude-sonnet-4-20250514\"). Uses SDK default if omitted. */\n model?: string;\n /**\n * Available tools. Defaults to read-only or read-write set based on AdapterSendOptions.\n * Set to `{ type: 'preset', preset: 'claude_code' }` for all Claude Code tools.\n */\n tools?: string[] | { type: \"preset\"; preset: \"claude_code\" };\n /** Permission mode. Defaults to \"bypassPermissions\" for automated workflows. */\n permissionMode?: \"default\" | \"acceptEdits\" | \"bypassPermissions\" | \"plan\";\n /** Max turns before stopping. */\n maxTurns?: number;\n /** Runtime guardrail hooks enforced via PreToolUse SDK hooks. */\n guardrailHooks?: GuardrailHooks;\n}\n\n// ---------------------------------------------------------------------------\n// Adapter\n// ---------------------------------------------------------------------------\n\nexport class ClaudeAgentSdkAdapter implements SdkAdapter {\n private cwd: string;\n private model: string | undefined;\n private tools: string[] | { type: \"preset\"; preset: \"claude_code\" } | undefined;\n private permissionMode: string;\n private maxTurns: number | undefined;\n private guardrailHooks: GuardrailHooks | undefined;\n private lastSessionId: string | null = null;\n private queryFn: QueryFn | null = null;\n\n constructor(config: ClaudeAgentSdkAdapterConfig = {}) {\n this.cwd = config.cwd ?? process.cwd();\n this.model = config.model;\n this.tools = config.tools;\n this.permissionMode = config.permissionMode ?? \"bypassPermissions\";\n this.maxTurns = config.maxTurns;\n this.guardrailHooks = config.guardrailHooks;\n }\n\n // -------------------------------------------------------------------------\n // Internal helpers\n // -------------------------------------------------------------------------\n\n private async resolveQueryFn(): Promise<QueryFn> {\n if (this.queryFn) return this.queryFn;\n\n // @ts-expect-error — @anthropic-ai/claude-agent-sdk is an optional peer dependency\n const sdk = (await import(\"@anthropic-ai/claude-agent-sdk\")) as {\n query: QueryFn;\n };\n this.queryFn = sdk.query;\n return this.queryFn;\n }\n\n private buildOptions(readonly: boolean, resume?: string): QueryOptions {\n const opts: QueryOptions = {\n cwd: this.cwd,\n permissionMode: this.permissionMode,\n allowDangerouslySkipPermissions: this.permissionMode === \"bypassPermissions\",\n };\n\n if (this.model) opts.model = this.model;\n if (this.maxTurns) opts.maxTurns = this.maxTurns;\n\n if (this.tools) {\n opts.tools = this.tools;\n } else {\n opts.tools = readonly\n ? [\"Read\", \"Glob\", \"Grep\"]\n : [\"Read\", \"Glob\", \"Grep\", \"Edit\", \"Write\", \"Bash\"];\n }\n\n if (resume) opts.resume = resume;\n\n if (this.guardrailHooks) {\n opts.hooks = buildClaudeHooks(this.guardrailHooks);\n }\n\n return opts;\n }\n\n private async runQuery(\n prompt: string,\n options: QueryOptions,\n ): Promise<{ text: string; sessionId: string }> {\n const queryFn = await this.resolveQueryFn();\n const stream = queryFn({ prompt, options });\n\n let resultText = \"\";\n let sessionId = \"\";\n\n for await (const message of stream) {\n if (message.type === \"result\") {\n sessionId = message.session_id ?? sessionId;\n if (message.subtype === \"success\") {\n resultText = (message as SDKResultSuccess).result;\n } else if (message.subtype === \"error\") {\n throw new Error(`Claude Agent SDK error: ${(message as SDKResultError).error}`);\n }\n }\n }\n\n return { text: resultText, sessionId };\n }\n\n // -------------------------------------------------------------------------\n // SdkAdapter interface\n // -------------------------------------------------------------------------\n\n async send(\n prompt: string,\n options: AdapterSendOptions,\n ): Promise<string> {\n this.lastSessionId = null;\n const opts = this.buildOptions(options.readonly);\n const { text, sessionId } = await this.runQuery(prompt, opts);\n this.lastSessionId = sessionId;\n return text;\n }\n\n async followUp(message: string): Promise<string> {\n if (!this.lastSessionId) {\n throw new Error(\"followUp() called before send() — no active session\");\n }\n const opts = this.buildOptions(false, this.lastSessionId);\n const { text, sessionId } = await this.runQuery(message, opts);\n this.lastSessionId = sessionId;\n return text;\n }\n\n async sendExecution(request: AgentExecutionRequest): Promise<string> {\n this.lastSessionId = null;\n const opts = this.buildOptions(request.options.readonly);\n const { text, sessionId } = await this.runQuery(request.prompt, opts);\n this.lastSessionId = sessionId;\n return text;\n }\n\n // -------------------------------------------------------------------------\n // Test support\n // -------------------------------------------------------------------------\n\n /**\n * Inject a custom query function for testing.\n * Bypasses the dynamic import of @anthropic-ai/claude-agent-sdk.\n */\n static withQueryFn(\n queryFn: QueryFn,\n config?: ClaudeAgentSdkAdapterConfig,\n ): ClaudeAgentSdkAdapter {\n const adapter = new ClaudeAgentSdkAdapter(config);\n adapter.queryFn = queryFn;\n return adapter;\n }\n}\n"],"mappings":";AAiFA,SAAS,iBACP,YACgD;AAChD,QAAM,iBAAsC;AAAA,IAC1C,OAAO;AAAA,MACL,CAAC,UAAiD;AAChD,cAAM,YAAY,MAAM;AACxB,cAAM,WAAW,MAAM;AAEvB,YAAI,aAAa,UAAU,aAAa,SAAS;AAC/C,gBAAM,UAAW,WAAW,WAAW,WAAW;AAClD,cAAI,SAAS;AACX,kBAAM,SAAS,WAAW,qBAAqB,EAAE,QAAQ,CAAC;AAC1D,gBAAI,OAAO,eAAe,QAAQ;AAChC,qBAAO;AAAA,gBACL,eAAe;AAAA,gBACf,oBAAoB;AAAA,gBACpB,0BAA0B,OAAO,gBAAgB,OAAO;AAAA,cAC1D;AAAA,YACF;AACA,gBAAI,OAAO,mBAAmB;AAC5B,qBAAO,EAAE,eAAe,cAAc,mBAAmB,OAAO,kBAAkB;AAAA,YACpF;AAAA,UACF;AAAA,QACF;AAEA,cAAM,WAAY,WAAW,aAAa,WAAW;AACrD,YAAI,UAAU;AACZ,gBAAM,aAAa,WAAW,WAAW;AAAA,YACvC,WAAW;AAAA,YACX,YAAY,EAAE,WAAW,SAAS;AAAA,UACpC,CAAC;AACD,cAAI,WAAW,eAAe,QAAQ;AACpC,mBAAO;AAAA,cACL,eAAe;AAAA,cACf,oBAAoB;AAAA,cACpB,0BAA0B,WAAW,gBAAgB,WAAW;AAAA,YAClE;AAAA,UACF;AACA,cAAI,WAAW,mBAAmB;AAChC,mBAAO,EAAE,eAAe,cAAc,mBAAmB,WAAW,kBAAkB;AAAA,UACxF;AAAA,QACF;AAEA,eAAO,EAAE,eAAe,aAAa;AAAA,MACvC;AAAA,IACF;AAAA,EACF;AAEA,SAAO,EAAE,YAAY,CAAC,cAAc,EAAE;AACxC;AA4BO,IAAM,wBAAN,MAAM,uBAA4C;AAAA,EAC/C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,gBAA+B;AAAA,EAC/B,UAA0B;AAAA,EAElC,YAAY,SAAsC,CAAC,GAAG;AACpD,SAAK,MAAM,OAAO,OAAO,QAAQ,IAAI;AACrC,SAAK,QAAQ,OAAO;AACpB,SAAK,QAAQ,OAAO;AACpB,SAAK,iBAAiB,OAAO,kBAAkB;AAC/C,SAAK,WAAW,OAAO;AACvB,SAAK,iBAAiB,OAAO;AAAA,EAC/B;AAAA;AAAA;AAAA;AAAA,EAMA,MAAc,iBAAmC;AAC/C,QAAI,KAAK,QAAS,QAAO,KAAK;AAG9B,UAAM,MAAO,MAAM,OAAO,gCAAgC;AAG1D,SAAK,UAAU,IAAI;AACnB,WAAO,KAAK;AAAA,EACd;AAAA,EAEQ,aAAa,UAAmB,QAA+B;AACrE,UAAM,OAAqB;AAAA,MACzB,KAAK,KAAK;AAAA,MACV,gBAAgB,KAAK;AAAA,MACrB,iCAAiC,KAAK,mBAAmB;AAAA,IAC3D;AAEA,QAAI,KAAK,MAAO,MAAK,QAAQ,KAAK;AAClC,QAAI,KAAK,SAAU,MAAK,WAAW,KAAK;AAExC,QAAI,KAAK,OAAO;AACd,WAAK,QAAQ,KAAK;AAAA,IACpB,OAAO;AACL,WAAK,QAAQ,WACT,CAAC,QAAQ,QAAQ,MAAM,IACvB,CAAC,QAAQ,QAAQ,QAAQ,QAAQ,SAAS,MAAM;AAAA,IACtD;AAEA,QAAI,OAAQ,MAAK,SAAS;AAE1B,QAAI,KAAK,gBAAgB;AACvB,WAAK,QAAQ,iBAAiB,KAAK,cAAc;AAAA,IACnD;AAEA,WAAO;AAAA,EACT;AAAA,EAEA,MAAc,SACZ,QACA,SAC8C;AAC9C,UAAM,UAAU,MAAM,KAAK,eAAe;AAC1C,UAAM,SAAS,QAAQ,EAAE,QAAQ,QAAQ,CAAC;AAE1C,QAAI,aAAa;AACjB,QAAI,YAAY;AAEhB,qBAAiB,WAAW,QAAQ;AAClC,UAAI,QAAQ,SAAS,UAAU;AAC7B,oBAAY,QAAQ,cAAc;AAClC,YAAI,QAAQ,YAAY,WAAW;AACjC,uBAAc,QAA6B;AAAA,QAC7C,WAAW,QAAQ,YAAY,SAAS;AACtC,gBAAM,IAAI,MAAM,2BAA4B,QAA2B,KAAK,EAAE;AAAA,QAChF;AAAA,MACF;AAAA,IACF;AAEA,WAAO,EAAE,MAAM,YAAY,UAAU;AAAA,EACvC;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,KACJ,QACA,SACiB;AACjB,SAAK,gBAAgB;AACrB,UAAM,OAAO,KAAK,aAAa,QAAQ,QAAQ;AAC/C,UAAM,EAAE,MAAM,UAAU,IAAI,MAAM,KAAK,SAAS,QAAQ,IAAI;AAC5D,SAAK,gBAAgB;AACrB,WAAO;AAAA,EACT;AAAA,EAEA,MAAM,SAAS,SAAkC;AAC/C,QAAI,CAAC,KAAK,eAAe;AACvB,YAAM,IAAI,MAAM,0DAAqD;AAAA,IACvE;AACA,UAAM,OAAO,KAAK,aAAa,OAAO,KAAK,aAAa;AACxD,UAAM,EAAE,MAAM,UAAU,IAAI,MAAM,KAAK,SAAS,SAAS,IAAI;AAC7D,SAAK,gBAAgB;AACrB,WAAO;AAAA,EACT;AAAA,EAEA,MAAM,cAAc,SAAiD;AACnE,SAAK,gBAAgB;AACrB,UAAM,OAAO,KAAK,aAAa,QAAQ,QAAQ,QAAQ;AACvD,UAAM,EAAE,MAAM,UAAU,IAAI,MAAM,KAAK,SAAS,QAAQ,QAAQ,IAAI;AACpE,SAAK,gBAAgB;AACrB,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,OAAO,YACL,SACA,QACuB;AACvB,UAAM,UAAU,IAAI,uBAAsB,MAAM;AAChD,YAAQ,UAAU;AAClB,WAAO;AAAA,EACT;AACF;","names":[]}
|
package/dist/adapters/mock.d.ts
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { T as TaskOutcome,
|
|
2
|
-
export { A as AdapterSendOptions,
|
|
1
|
+
import { T as TaskOutcome, b as TaskContractLike, c as AgentContractLike, d as TaskContext, S as SdkAdapter, P as PromptBuilderOptions } from './task-runner-Bt2XiEUU.js';
|
|
2
|
+
export { A as AdapterSendOptions, a as AgentExecutionRequest, R as RetryDecision, e as TaskRunOptions, f as TaskRunResult, g as buildRetryFollowUp, h as buildTaskPrompt, i as extractStructuredResult, r as runTask, z as zodSchemaToPromptDescription, j as zodSchemaToYamlExample } from './task-runner-Bt2XiEUU.js';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
export { a as GuardrailCheckFunctions, b as GuardrailCheckResult, G as GuardrailHooks, H as HookContext, c as HookResponse, d as createGuardrailHooks, g as getBlockingViolations, e as getWarnings, h as hasBlockingViolation } from './guardrail-hooks-5MSNWxnl.js';
|
|
5
5
|
|
|
@@ -168,4 +168,4 @@ declare function runTask(adapter: SdkAdapter, taskId: string, context: TaskConte
|
|
|
168
168
|
};
|
|
169
169
|
}): Promise<TaskRunResult>;
|
|
170
170
|
|
|
171
|
-
export { type AdapterSendOptions as A, type PromptBuilderOptions as P, type RetryDecision as R, type SdkAdapter as S, type TaskOutcome as T, type
|
|
171
|
+
export { type AdapterSendOptions as A, type PromptBuilderOptions as P, type RetryDecision as R, type SdkAdapter as S, type TaskOutcome as T, type AgentExecutionRequest as a, type TaskContractLike as b, type AgentContractLike as c, type TaskContext as d, type TaskRunOptions as e, type TaskRunResult as f, buildRetryFollowUp as g, buildTaskPrompt as h, extractStructuredResult as i, zodSchemaToYamlExample as j, runTask as r, zodSchemaToPromptDescription as z };
|