agent-contracts-runtime 0.5.1 → 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 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** every LLM output against handoff schemas before proceeding to the next step
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, prompt enhancement, custom guardrails)
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 + registries |
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
- ### Run a workflow
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, // override lightweight recovery attempts (default: 2)
199
- maxRetries: 1, // override heavyweight retry attempts (default: from DSL step.max_retries)
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; // approve
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
- ### Prompt customization hooks
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
- Two hooks control what prompt is sent to the SDK agent:
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
- The adapter interface is minimal:
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: { readonly: boolean }): Promise<string>;
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: true
175
- description: ID of the workflow to execute (e.g. feature-implement, issue-fix).
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: true
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,28 +1,22 @@
1
- import { S as SdkAdapter } from '../task-runner-DuZwv4zJ.js';
1
+ import { S as SdkAdapter, A as AdapterSendOptions } from '../task-runner-JLQ-vpHl.js';
2
+ import { G as GuardrailHooks } from '../guardrail-hooks-5MSNWxnl.js';
2
3
  import 'zod';
3
4
 
4
- /**
5
- * Claude Agent SDK Adapter — implements SdkAdapter for Claude Agent SDK
6
- *
7
- * Supports both send() (new session) and followUp() (same session continuation).
8
- * The Claude Agent SDK uses a stateful agent instance, so followUp() sends
9
- * an additional message within the same conversation.
10
- */
11
-
5
+ interface ClaudeAgentSdkAdapterConfig {
6
+ cwd?: string;
7
+ model?: string;
8
+ guardrailHooks?: GuardrailHooks;
9
+ }
12
10
  declare class ClaudeAgentSdkAdapter implements SdkAdapter {
13
11
  private agent;
14
12
  private cwd;
15
13
  private model;
16
14
  private allowedTools;
17
- constructor(config: {
18
- cwd?: string;
19
- model?: string;
20
- });
15
+ private guardrailHooks?;
16
+ constructor(config: ClaudeAgentSdkAdapterConfig);
21
17
  private getOrCreateAgent;
22
- send(prompt: string, options: {
23
- readonly: boolean;
24
- }): Promise<string>;
18
+ send(prompt: string, options: AdapterSendOptions): Promise<string>;
25
19
  followUp(message: string): Promise<string>;
26
20
  }
27
21
 
28
- export { ClaudeAgentSdkAdapter };
22
+ export { ClaudeAgentSdkAdapter, type ClaudeAgentSdkAdapterConfig };
@@ -1,22 +1,56 @@
1
1
  // src/adapters/claude-agent-sdk.ts
2
+ function buildClaudeHooks(hooks) {
3
+ return {
4
+ beforeShellExecution: (input) => {
5
+ const result = hooks.beforeShellExecution(input);
6
+ return claudeHookResult(result);
7
+ },
8
+ preToolUse: (input) => {
9
+ const result = hooks.preToolUse(input);
10
+ return claudeHookResult(result);
11
+ },
12
+ afterFileEdit: (input) => {
13
+ const result = hooks.afterFileEdit(input);
14
+ return claudeHookResult(result);
15
+ }
16
+ };
17
+ }
18
+ function claudeHookResult(response) {
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
+ }
2
30
  var ClaudeAgentSdkAdapter = class {
3
31
  agent = null;
4
32
  cwd;
5
33
  model;
6
34
  allowedTools = [];
35
+ guardrailHooks;
7
36
  constructor(config) {
8
37
  this.cwd = config.cwd ?? process.cwd();
9
38
  this.model = config.model ?? "claude-sonnet-4-20250514";
39
+ this.guardrailHooks = config.guardrailHooks;
10
40
  }
11
41
  async getOrCreateAgent(readonly) {
12
42
  if (this.agent) return this.agent;
13
43
  this.allowedTools = readonly ? ["Read", "Glob", "Grep"] : ["Read", "Glob", "Grep", "Edit", "Write", "Bash"];
14
44
  const { ClaudeAgent } = await import("@anthropic-ai/claude-agent-sdk");
15
- this.agent = await ClaudeAgent.create({
45
+ const opts = {
16
46
  model: this.model,
17
47
  cwd: this.cwd,
18
48
  allowedTools: this.allowedTools
19
- });
49
+ };
50
+ if (this.guardrailHooks) {
51
+ Object.assign(opts, buildClaudeHooks(this.guardrailHooks));
52
+ }
53
+ this.agent = await ClaudeAgent.create(opts);
20
54
  return this.agent;
21
55
  }
22
56
  async send(prompt, options) {
@@ -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\nimport type { SdkAdapter } from \"../lib/task-runner.js\";\n\ntype ClaudeAgentInstance = {\n sendMessage(prompt: string): Promise<{ text: string }>;\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\n constructor(config: { cwd?: string; model?: string }) {\n this.cwd = config.cwd ?? process.cwd();\n this.model = config.model ?? \"claude-sonnet-4-20250514\";\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 this.agent = await ClaudeAgent.create({\n model: this.model,\n cwd: this.cwd,\n allowedTools: this.allowedTools,\n });\n return this.agent;\n }\n\n async send(prompt: string, options: { readonly: boolean }): 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":";AAcO,IAAM,wBAAN,MAAkD;AAAA,EAC/C,QAAoC;AAAA,EACpC;AAAA,EACA;AAAA,EACA,eAAyB,CAAC;AAAA,EAElC,YAAY,QAA0C;AACpD,SAAK,MAAM,OAAO,OAAO,QAAQ,IAAI;AACrC,SAAK,QAAQ,OAAO,SAAS;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;AAGrE,SAAK,QAAQ,MAAM,YAAY,OAAO;AAAA,MACpC,OAAO,KAAK;AAAA,MACZ,KAAK,KAAK;AAAA,MACV,cAAc,KAAK;AAAA,IACrB,CAAC;AACD,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,MAAM,KAAK,QAAgB,SAAiD;AAC1E,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 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,13 +1,7 @@
1
- import { S as SdkAdapter } from '../task-runner-DuZwv4zJ.js';
1
+ import { S as SdkAdapter, A as AdapterSendOptions } from '../task-runner-JLQ-vpHl.js';
2
+ import { G as GuardrailHooks } from '../guardrail-hooks-5MSNWxnl.js';
2
3
  import 'zod';
3
4
 
4
- /**
5
- * Cursor SDK Adapter — implements SdkAdapter for Cursor Cloud Agents API
6
- *
7
- * Supports both send() (new session) and followUp() (same session continuation)
8
- * for lightweight output-format corrections without re-executing the entire task.
9
- */
10
-
11
5
  type CursorAgentRun = {
12
6
  stream(): AsyncIterable<{
13
7
  type: string;
@@ -22,19 +16,19 @@ type CursorAgentRun = {
22
16
  type CursorAgentInstance = {
23
17
  send(prompt: string): Promise<CursorAgentRun>;
24
18
  };
19
+ interface CursorSdkAdapterConfig {
20
+ apiKey: string;
21
+ model?: string;
22
+ cwd?: string;
23
+ guardrailHooks?: GuardrailHooks;
24
+ }
25
25
  declare class CursorSdkAdapter implements SdkAdapter {
26
26
  private agent;
27
27
  constructor(agent: CursorAgentInstance);
28
28
  private collectStream;
29
- send(prompt: string, _options: {
30
- readonly: boolean;
31
- }): Promise<string>;
29
+ send(prompt: string, _options: AdapterSendOptions): Promise<string>;
32
30
  followUp(message: string): Promise<string>;
33
- static create(config: {
34
- apiKey: string;
35
- model?: string;
36
- cwd?: string;
37
- }): Promise<CursorSdkAdapter>;
31
+ static create(config: CursorSdkAdapterConfig): Promise<CursorSdkAdapter>;
38
32
  }
39
33
 
40
- export { CursorSdkAdapter };
34
+ export { CursorSdkAdapter, type CursorSdkAdapterConfig };
@@ -1,4 +1,33 @@
1
1
  // src/adapters/cursor-sdk.ts
2
+ function buildSdkHooks(hooks) {
3
+ return {
4
+ beforeShellExecution: (input) => {
5
+ const result = hooks.beforeShellExecution(input);
6
+ return hookResponseToSdkDecision(result);
7
+ },
8
+ preToolUse: (input) => {
9
+ const result = hooks.preToolUse(input);
10
+ return hookResponseToSdkDecision(result);
11
+ },
12
+ afterFileEdit: (input) => {
13
+ const result = hooks.afterFileEdit(input);
14
+ return hookResponseToSdkDecision(result);
15
+ }
16
+ };
17
+ }
18
+ function hookResponseToSdkDecision(response) {
19
+ if (response.permission === "deny") {
20
+ return {
21
+ permissionDecision: "deny",
22
+ userMessage: response.user_message,
23
+ agentMessage: response.agent_message
24
+ };
25
+ }
26
+ if (response.additionalContext) {
27
+ return { additionalContext: response.additionalContext };
28
+ }
29
+ return {};
30
+ }
2
31
  var CursorSdkAdapter = class _CursorSdkAdapter {
3
32
  agent;
4
33
  constructor(agent) {
@@ -27,11 +56,15 @@ var CursorSdkAdapter = class _CursorSdkAdapter {
27
56
  }
28
57
  static async create(config) {
29
58
  const { Agent } = await import("@cursor/sdk");
30
- const agent = await Agent.create({
59
+ const agentOpts = {
31
60
  apiKey: config.apiKey,
32
61
  model: { id: config.model ?? "composer-2" },
33
62
  local: { cwd: config.cwd ?? process.cwd() }
34
- });
63
+ };
64
+ if (config.guardrailHooks) {
65
+ Object.assign(agentOpts, buildSdkHooks(config.guardrailHooks));
66
+ }
67
+ const agent = await Agent.create(agentOpts);
35
68
  return new _CursorSdkAdapter(agent);
36
69
  }
37
70
  };
@@ -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\nimport type { SdkAdapter } from \"../lib/task-runner.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 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: { readonly: boolean }): 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: {\n apiKey: string;\n model?: string;\n cwd?: string;\n }): 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 const agent = await Agent.create({\n apiKey: config.apiKey,\n model: { id: config.model ?? \"composer-2\" },\n local: { cwd: config.cwd ?? process.cwd() },\n });\n return new CursorSdkAdapter(agent);\n }\n}\n"],"mappings":";AAoBO,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,UAAkD;AAC3E,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,QAIU;AAE5B,UAAM,EAAE,MAAM,IAAI,MAAM,OAAO,aAAa;AAC5C,UAAM,QAAQ,MAAM,MAAM,OAAO;AAAA,MAC/B,QAAQ,OAAO;AAAA,MACf,OAAO,EAAE,IAAI,OAAO,SAAS,aAAa;AAAA,MAC1C,OAAO,EAAE,KAAK,OAAO,OAAO,QAAQ,IAAI,EAAE;AAAA,IAC5C,CAAC;AACD,WAAO,IAAI,kBAAiB,KAAK;AAAA,EACnC;AACF;","names":[]}
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":[]}