@aaac/runtime 0.1.6 → 0.1.8

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/dist/index.d.ts CHANGED
@@ -1,236 +1,9 @@
1
- import { S as SdkAdapter, T as TaskOutcome, b as TaskContractLike, c as AgentContractLike, d as TaskContext, O as ObserverEmitFn, P as PromptBuilderOptions, e as MemoryStore, M as MemoryRef, L as LibraryToolRegistry, f as TaskRunResult, g as LibraryToolDefinition } from './task-runner-R-_kW3U6.js';
2
- export { A as AdapterSendOptions, a as AgentExecutionRequest, h as AgentProgressEvent, C as CacheConfig, i as CandidateAgent, E as EnvelopeParams, I as InMemoryStore, R as RetryDecision, j as SplitPrompt, k as TaskRunOptions, l as buildCandidateAgents, m as buildRetryFollowUp, n as buildSplitTaskPrompt, o as buildTaskPrompt, p as createExecutionEnvelope, q as createLibraryToolRegistry, r as emitSessionClose, s as emitSessionOpen, t as emitSubagentClose, u as emitSubagentOpen, v as emitToolchainClose, w as emitToolchainOpen, x as extractStructuredResult, y as renderAgentSystemPrompt, z as runTask, B as zodSchemaToPromptDescription, D as zodSchemaToYamlExample } from './task-runner-R-_kW3U6.js';
1
+ import { T as TaskContext, b as TaskOutcome, c as AgentContractLike, d as TaskContractLike, P as PromptBuilderOptions, W as WorkflowResult, S as SdkAdapter, e as WorkflowRegistries, H as HandoffInput, f as StepCompleteEvent, g as StepResult, D as DelegateStep, h as GuardrailRuleData, i as MemoryStore, M as MemoryRef, L as LibraryToolRegistry, G as GuardrailHooks, R as ResolvedComponent, j as ArtifactBindingConfig, k as TaskRunResult, O as ObserverEmitFn, l as ResolvedToolchain, m as LibraryToolDefinition } from './task-runner-Dw8oWJD6.js';
2
+ export { n as AdapterOrFactory, A as AdapterSendOptions, a as AgentExecutionRequest, o as AgentProgressEvent, B as BoundResolveOptions, p as BoundResolver, C as CacheConfig, q as CandidateAgent, E as EnvelopeParams, r as GateStep, s as GuardrailCheckFunctions, t as GuardrailCheckResult, u as GuardrailRule, v as HookContext, w as HookResponse, I as InMemoryStore, x as ModelAwareSdkAdapterFactory, y as ModelClass, z as ModelMappingConfig, F as ModelResolver, J as ModelResolverOptions, K as ReceiveSpec, N as ResolvedModel, Q as RetryDecision, U as SdkAdapterFactory, V as SplitPrompt, X as TaskRunOptions, Y as WorkflowContractLike, Z as WorkflowInvocation, _ as WorkflowRunOptions, $ as WorkflowStep, a0 as buildCandidateAgents, a1 as buildGateEvaluationPrompt, a2 as buildPerAgentGuardrails, a3 as buildRetryFollowUp, a4 as buildSplitTaskPrompt, a5 as buildTaskPrompt, a6 as createExecutionEnvelope, a7 as createGuardrailHooks, a8 as createGuardrailHooksForAgent, a9 as createGuardrailHooksFromRules, aa as createLibraryToolRegistry, ab as createModelResolver, ac as deriveToolchainsForAgents, ad as emitSessionClose, ae as emitSessionOpen, af as emitSubagentClose, ag as emitSubagentOpen, ah as emitToolchainClose, ai as emitToolchainOpen, aj as extractStructuredResult, ak as getBlockingViolations, al as getEffectiveGuardrailIds, am as getGuardrailRulesForAgent, an as getWarnings, ao as guardrailContextToRuleData, ap as hasBlockingViolation, aq as parseGateEvaluationResponse, ar as renderAgentSystemPrompt, as as runTask, at as runWorkflow, au as zodSchemaToPromptDescription, av as zodSchemaToYamlExample } from './task-runner-Dw8oWJD6.js';
3
3
  import { z } from 'zod';
4
- import { a as GuardrailRuleData, G as GuardrailHooks } from './guardrail-hooks-C8G5NGsj.js';
5
- export { b as GuardrailCheckFunctions, c as GuardrailCheckResult, d as GuardrailRule, H as HookContext, e as HookResponse, f as createGuardrailHooks, g as createGuardrailHooksForAgent, h as createGuardrailHooksFromRules, i as getBlockingViolations, j as getWarnings, k as hasBlockingViolation } from './guardrail-hooks-C8G5NGsj.js';
6
- import { G as GuardrailContext } from './context-B_bekYiE.js';
7
4
  import { OperationIR, ComponentIR } from '@aaac/contracts';
8
5
  export { ExecutionEnvelope } from '@aaac/observability';
9
-
10
- /**
11
- * ModelResolver — resolves a model_class to a concrete adapter + model pair.
12
- *
13
- * Resolution priority (highest wins):
14
- * 1. AGENT_RUNTIME_MODEL_{FAST|STANDARD|THINKING} env var
15
- * 2. AGENT_RUNTIME_MODEL env var (catch-all fallback)
16
- * 3. agent-runtime.config.yaml model_mapping.<class>
17
- * 4. CLI --adapter + adapter default model
18
- */
19
- type ModelClass = "fast" | "standard" | "thinking";
20
- interface ResolvedModel {
21
- adapter: string;
22
- model?: string;
23
- }
24
- interface ModelResolver {
25
- resolve(modelClass: ModelClass | undefined): ResolvedModel;
26
- }
27
- interface ModelMappingConfig {
28
- fast?: {
29
- adapter: string;
30
- model?: string;
31
- };
32
- standard?: {
33
- adapter: string;
34
- model?: string;
35
- };
36
- thinking?: {
37
- adapter: string;
38
- model?: string;
39
- };
40
- }
41
- interface ModelResolverOptions {
42
- modelMapping?: ModelMappingConfig;
43
- fallbackAdapter: string;
44
- fallbackModel?: string;
45
- env?: Record<string, string | undefined>;
46
- }
47
- declare function createModelResolver(options: ModelResolverOptions): ModelResolver;
48
-
49
- /**
50
- * Workflow Runner — orchestrates a DSL workflow as a sequence of task executions
51
- *
52
- * Programmatic control flow that replaces LLM-driven step interpretation:
53
- *
54
- * 1. Load workflow contract (ordered steps)
55
- * 2. Run plugin beforeWorkflow hooks
56
- * 3. For each step:
57
- * - delegate → call task-runner with followUp/retry recovery
58
- * - gate → pause and wait for user input
59
- * 4. Validate each result against handoff schema
60
- * 5. Accumulate context between steps
61
- * 6. Run plugin afterWorkflow hooks
62
- */
63
-
64
- /**
65
- * A factory that creates independent SdkAdapter instances.
66
- * Used by runWorkflow to allocate one adapter per parallel step,
67
- * avoiding session-level serialization in stateful SDK adapters.
68
- */
69
- type SdkAdapterFactory = () => SdkAdapter;
70
- /**
71
- * Model-aware adapter factory. Accepts a model_class and returns an adapter
72
- * configured for that capability level (possibly a different provider/model).
73
- */
74
- type ModelAwareSdkAdapterFactory = (modelClass?: ModelClass) => SdkAdapter | Promise<SdkAdapter>;
75
- /** Accepts either a single adapter (serial/shared) or a factory (parallel-safe). */
76
- type AdapterOrFactory = SdkAdapter | SdkAdapterFactory | ModelAwareSdkAdapterFactory;
77
- /** Specification for what a step receives from a dependency. */
78
- interface ReceiveSpec {
79
- /** The task id of the dependency step to receive from. If omitted, alias is used as task id. */
80
- readonly from?: string;
81
- /** JSONPath-like dotted path to extract from the step result (e.g. "$.changed_files"). Simplified: just use dot notation like "changed_files" or "checks_performed". If omitted, entire result is received. */
82
- readonly path?: string;
83
- }
84
- interface DelegateStep {
85
- readonly type: "delegate";
86
- readonly task: string;
87
- readonly from_agent: string;
88
- readonly description: string;
89
- readonly optional: boolean;
90
- readonly max_retries: number;
91
- readonly max_follow_ups?: number;
92
- readonly depends_on?: readonly string[];
93
- readonly instruction?: string;
94
- readonly receives?: Record<string, ReceiveSpec>;
95
- readonly retry?: {
96
- readonly condition: string;
97
- readonly fix_task: string;
98
- readonly revalidate_task?: string;
99
- };
100
- }
101
- interface GateStep {
102
- readonly type: "gate";
103
- readonly gate_kind: string;
104
- readonly description: string;
105
- readonly depends_on?: readonly string[];
106
- }
107
- type WorkflowStep = DelegateStep | GateStep;
108
- interface WorkflowContractLike {
109
- readonly id: string;
110
- readonly description: string;
111
- readonly steps: readonly WorkflowStep[];
112
- }
113
- interface WorkflowRunOptions {
114
- user_request: string;
115
- /** Override max follow-up attempts per step (lightweight output-format correction). Default: 2 */
116
- maxFollowUps?: number;
117
- /** Override max full retry attempts per step. Default: from DSL step.max_retries */
118
- maxRetries?: number;
119
- /** Variables propagated to every TaskContext in the workflow (from WorkflowInvocation.context). */
120
- variables?: Record<string, unknown>;
121
- onGate?: (gateKind: string, description: string, stepResults: StepResult[]) => Promise<boolean>;
122
- onStepComplete?: (event: StepCompleteEvent) => void;
123
- onOptionalStep?: (step: DelegateStep, context: TaskContext) => Promise<boolean>;
124
- /**
125
- * Writable stream for real-time progress output during agent execution.
126
- * Intermediate events from adapters are formatted and written here.
127
- * Typical value: process.stderr.
128
- */
129
- progressOutput?: {
130
- write(chunk: string): unknown;
131
- };
132
- /**
133
- * Optional observer emit function for agent-axis spans (agent.session, agent.subagent).
134
- * When undefined, no spans are emitted (observer is optional — no-op).
135
- * Pass EventCollector.emit.bind(collector) to wire up the full observability pipeline.
136
- */
137
- observer?: ObserverEmitFn;
138
- }
139
- /** Typed handoff envelope for workflow input. */
140
- interface HandoffInput<TType extends string = string, TPayload = unknown> {
141
- readonly type: TType;
142
- readonly version?: number;
143
- readonly payload: TPayload;
144
- }
145
- /**
146
- * Standard runtime invocation envelope. SDK-specific options (openaiThreadId,
147
- * sessionId, etc.) belong on the adapter constructor — not here.
148
- */
149
- interface WorkflowInvocation<THandoffType extends string = string, TPayload = unknown> {
150
- workflow: string;
151
- /** Structured typed handoff input. Takes precedence over user_request if both are set. */
152
- handoff?: HandoffInput<THandoffType, TPayload>;
153
- /** Simple string input (convenience shorthand). */
154
- user_request?: string;
155
- runtime?: {
156
- maxFollowUps?: number;
157
- maxRetries?: number;
158
- timeoutMs?: number;
159
- readonly?: boolean;
160
- dryRun?: boolean;
161
- };
162
- hooks?: {
163
- onStepComplete?: (event: StepCompleteEvent) => void;
164
- onGate?: (gateKind: string, description: string, stepResults: StepResult[]) => Promise<boolean>;
165
- onOptionalStep?: (step: DelegateStep, context: TaskContext) => Promise<boolean>;
166
- };
167
- /**
168
- * Writable stream for real-time progress output during agent execution.
169
- * Intermediate events from adapters are formatted and written here.
170
- * Typical value: process.stderr.
171
- */
172
- progressOutput?: {
173
- write(chunk: string): unknown;
174
- };
175
- context?: {
176
- cwd?: string;
177
- environment?: "local" | "ci" | "remote";
178
- artifacts?: Record<string, string>;
179
- variables?: Record<string, unknown>;
180
- };
181
- /**
182
- * Optional observer emit function for agent-axis spans (agent.session, agent.subagent).
183
- * When undefined, no spans are emitted (observer is optional — no-op).
184
- * Pass EventCollector.emit.bind(collector) to wire up the full observability pipeline.
185
- */
186
- observer?: ObserverEmitFn;
187
- }
188
- interface StepResult {
189
- step_index: number;
190
- task_id?: string;
191
- gate_kind?: string;
192
- outcome: TaskOutcome | {
193
- status: "gate_approved";
194
- } | {
195
- status: "gate_rejected";
196
- } | {
197
- status: "skipped";
198
- };
199
- follow_ups_used: number;
200
- retries_used: number;
201
- elapsed_ms: number;
202
- }
203
- interface StepCompleteEvent {
204
- workflow_id: string;
205
- step_index: number;
206
- step_type: "delegate" | "gate";
207
- task_id?: string;
208
- gate_kind?: string;
209
- outcome_status: string;
210
- follow_ups_used: number;
211
- retries_used: number;
212
- elapsed_ms: number;
213
- }
214
- interface WorkflowResult {
215
- workflow_id: string;
216
- status: "completed" | "escalated" | "gate_rejected" | "error";
217
- steps: StepResult[];
218
- total_elapsed_ms: number;
219
- escalation_reason?: string;
220
- error_message?: string;
221
- }
222
- interface WorkflowRegistries {
223
- workflowRegistry?: Record<string, WorkflowContractLike>;
224
- taskRegistry?: Record<string, TaskContractLike>;
225
- agentRegistry?: Record<string, AgentContractLike>;
226
- handoffSchemas?: Record<string, z.ZodType>;
227
- }
228
- /** @deprecated Use the WorkflowInvocation overload for typed handoff input. */
229
- declare function runWorkflow(adapter: AdapterOrFactory, workflowId: string, options: WorkflowRunOptions, registries?: WorkflowRegistries): Promise<WorkflowResult>;
230
- /** Structured invocation with typed handoff envelope. */
231
- declare function runWorkflow(adapter: AdapterOrFactory, invocation: WorkflowInvocation, registries?: WorkflowRegistries): Promise<WorkflowResult>;
232
- declare function buildGateEvaluationPrompt(step: GateStep, priorContext: string): string;
233
- declare function parseGateEvaluationResponse(response: string): boolean;
6
+ import './context-B_bekYiE.js';
234
7
 
235
8
  /**
236
9
  * Plugin Interface — extension points for user code injection
@@ -300,88 +73,6 @@ declare class PluginRegistry {
300
73
  }
301
74
  declare const pluginRegistry: PluginRegistry;
302
75
 
303
- /**
304
- * BoundResolver — runtime binding + policy resolution with per-agent isolation.
305
- *
306
- * Resolves artifact binding and guardrail/policy in one pass at runtime,
307
- * producing a per-agent scoped ResolvedComponent. Reuses existing
308
- * resolveBound(), buildGuardrailContext(), and agent scope resolution.
309
- */
310
-
311
- interface ArtifactBindingConfig {
312
- source: string;
313
- mappings?: Record<string, string>;
314
- }
315
- interface BoundResolveOptions {
316
- /** Component identifier — used for cache keying. */
317
- id: string;
318
- /** Pre-resolved DSL (e.g. embedded from codegen). */
319
- embeddedDsl?: Record<string, unknown>;
320
- /** Path to DSL file — resolved via agent-contracts when no embeddedDsl. */
321
- dslPath?: string;
322
- /** Paths to software binding YAML files (guardrail_impl, etc.). */
323
- bindingPaths?: string[];
324
- /** Active guardrail policy name from DSL guardrail_policies. */
325
- activeGuardrailPolicy?: string;
326
- /** Artifact binding config — resolved via agent-contracts resolveBound(). */
327
- artifactBinding?: ArtifactBindingConfig;
328
- /** Path substitutions for artifact binding. */
329
- paths?: Record<string, string>;
330
- /** Path to toolchain-contracts.yaml. */
331
- toolchainContractsPath?: string;
332
- }
333
- interface ResolvedToolchain {
334
- id: string;
335
- kind: "library" | "cli" | "component";
336
- description?: string;
337
- module?: string;
338
- command?: string;
339
- cli_contract?: string;
340
- component_contract?: string;
341
- artifacts: {
342
- consumes: string[];
343
- produces: string[];
344
- };
345
- operations?: string[];
346
- source: "toolchain-contracts" | "agent-contracts" | "merged";
347
- }
348
- interface ResolvedComponent {
349
- id: string;
350
- dsl: Record<string, unknown>;
351
- registries: WorkflowRegistries;
352
- guardrails: {
353
- perAgent: Map<string, GuardrailRuleData>;
354
- };
355
- diagnostics: Array<{
356
- path?: string;
357
- message: string;
358
- severity?: string;
359
- }>;
360
- toolchains?: Record<string, ResolvedToolchain>;
361
- toolchainsByAgent?: Map<string, ResolvedToolchain[]>;
362
- }
363
- /**
364
- * Effective guardrail IDs for an agent: entity-side bindings ∪ scope-side bindings.
365
- */
366
- declare function getEffectiveGuardrailIds(dsl: Record<string, unknown>, agentId: string): Set<string>;
367
- declare function guardrailContextToRuleData(ctx: GuardrailContext, effectiveIds?: Set<string>): GuardrailRuleData;
368
- declare function buildPerAgentGuardrails(dsl: Record<string, unknown>, guardrailCtx: GuardrailContext): Map<string, GuardrailRuleData>;
369
- declare function deriveToolchainsForAgents(dsl: Record<string, unknown>, toolchains: Record<string, ResolvedToolchain>): Map<string, ResolvedToolchain[]>;
370
- declare class BoundResolver {
371
- private readonly cache;
372
- /**
373
- * Resolve binding + policy in one pass. Results are cached by component id.
374
- */
375
- resolve(opts: BoundResolveOptions): Promise<ResolvedComponent>;
376
- /** Clear cached components (e.g. for testing). */
377
- clearCache(): void;
378
- }
379
- /**
380
- * Get guardrail rules for a specific agent from a ResolvedComponent.
381
- * Falls back to embedded _guardrailRules when no per-agent rules exist.
382
- */
383
- declare function getGuardrailRulesForAgent(component: ResolvedComponent, agentId: string, fallbackDsl?: Record<string, unknown>): GuardrailRuleData | undefined;
384
-
385
76
  /**
386
77
  * Fluent Builder API for workflow invocation.
387
78
  *
@@ -790,6 +481,7 @@ interface ComponentScope {
790
481
  toolsByAgent: Map<string, string[]>;
791
482
  guardrailsByAgent: Map<string, unknown[]>;
792
483
  libraryTools?: LibraryToolRegistry;
484
+ toolchainsByAgent?: Map<string, ResolvedToolchain[]>;
793
485
  }
794
486
  interface CreateComponentScopeOptions {
795
487
  resolvedComponent?: ResolvedComponent;
@@ -844,4 +536,4 @@ declare function resolveArtifacts(options: ArtifactResolveOptions): Promise<Arti
844
536
  /** Package version string. */
845
537
  declare const version: string;
846
538
 
847
- export { type AaacInvocationContext, type AaacObserver, type AaacPolicy, type AaacRuntime, type AdapterOrFactory, AgentContractLike, AgentLogWriter, type AgentLogWriterOptions, type AgentPlugin, type ArtifactBindingConfig, type ArtifactResolveOptions, type ArtifactResolveResult, type BoundResolveOptions, BoundResolver, type ComponentScope, type CreateAdapterOptions, type CreateComponentScopeOptions, type DelegateStep, type DslContext, DslValidationError, type ExecuteOptions, type ExecuteTaskOptions, type ExecuteWorkflowOptions, FileMemoryStore, type GateStep, GuardrailHooks, type GuardrailResult, GuardrailRuleData, type HandoffInput, LibraryToolDefinition, LibraryToolRegistry, type LoadDslOptions, MemoryRef, MemoryStore, type MemoryStoreEntry, type ModelAwareSdkAdapterFactory, type ModelClass, type ModelMappingConfig, type ModelResolver, type ModelResolverOptions, type NavigationContext, type NavigationContextOptions, ObserverEmitFn, type OperationHandler, type OperationMemoryRefConfig, type PermissionMode, type PluginLoadResult, PluginRegistry, type ProgressSink, type ProgressSinkOptions, type PromptBuilderArgs, PromptBuilderOptions, type ReceiveSpec, type RequiredEntities, type ResolvedComponent, type ResolvedModel, type ResolvedToolchain, type RunLogEvent, type Runtime, type RuntimeBinding, type RuntimeConfig, SdkAdapter, type SdkAdapterFactory, type SdkFunctionTool, type StepCompleteEvent, type StepResult, TaskContext, TaskContractLike, type TaskHookContext, TaskOutcome, TaskRunResult, WorkflowBuilder, type WorkflowContractLike, type WorkflowHookContext, type WorkflowInvocation, type WorkflowRegistries, type WorkflowResult, type WorkflowRunOptions, type WorkflowStep, buildGateEvaluationPrompt, buildGuardrailRulesFromDsl, buildNavigationContext, buildPerAgentGuardrails, buildRegistriesFromDsl, buildSdkFunctionTools, createAdapter, createComponentScope, createModelResolver, createProgressSink, createRuntime, createRuntimeBinding, deriveToolchainsForAgents, executeTask, executeWorkflow, getEffectiveGuardrailIds, getGuardrailRulesForAgent, guardrailContextToRuleData, jsonSchemaToZod, loadDslContext, loadPlugins, loadPluginsFromDirectory, loadPluginsFromPaths, parseGateEvaluationResponse, pluginRegistry, resolveArtifacts, runWorkflow, version };
539
+ export { type AaacInvocationContext, type AaacObserver, type AaacPolicy, type AaacRuntime, AgentContractLike, AgentLogWriter, type AgentLogWriterOptions, type AgentPlugin, ArtifactBindingConfig, type ArtifactResolveOptions, type ArtifactResolveResult, type ComponentScope, type CreateAdapterOptions, type CreateComponentScopeOptions, DelegateStep, type DslContext, DslValidationError, type ExecuteOptions, type ExecuteTaskOptions, type ExecuteWorkflowOptions, FileMemoryStore, GuardrailHooks, type GuardrailResult, GuardrailRuleData, HandoffInput, LibraryToolDefinition, LibraryToolRegistry, type LoadDslOptions, MemoryRef, MemoryStore, type MemoryStoreEntry, type NavigationContext, type NavigationContextOptions, ObserverEmitFn, type OperationHandler, type OperationMemoryRefConfig, type PermissionMode, type PluginLoadResult, PluginRegistry, type ProgressSink, type ProgressSinkOptions, type PromptBuilderArgs, PromptBuilderOptions, type RequiredEntities, ResolvedComponent, ResolvedToolchain, type RunLogEvent, type Runtime, type RuntimeBinding, type RuntimeConfig, SdkAdapter, type SdkFunctionTool, StepCompleteEvent, StepResult, TaskContext, TaskContractLike, type TaskHookContext, TaskOutcome, TaskRunResult, WorkflowBuilder, type WorkflowHookContext, WorkflowRegistries, WorkflowResult, buildGuardrailRulesFromDsl, buildNavigationContext, buildRegistriesFromDsl, buildSdkFunctionTools, createAdapter, createComponentScope, createProgressSink, createRuntime, createRuntimeBinding, executeTask, executeWorkflow, jsonSchemaToZod, loadDslContext, loadPlugins, loadPluginsFromDirectory, loadPluginsFromPaths, pluginRegistry, resolveArtifacts, version };
package/dist/index.js CHANGED
@@ -71,12 +71,20 @@ function buildCandidateAgents(agentRegistry, opts) {
71
71
  for (const [id, agent] of Object.entries(agentRegistry)) {
72
72
  if (id === entryId) continue;
73
73
  if (allowSet && !allowSet.has(id)) continue;
74
- const tools = agent.can_execute_tools;
74
+ const agentTools = agent.can_execute_tools ? [...agent.can_execute_tools] : [];
75
+ const derivedToolchains = opts?.toolchainsByAgent?.get(id);
76
+ if (derivedToolchains) {
77
+ for (const tc of derivedToolchains) {
78
+ if (!agentTools.includes(tc.id)) {
79
+ agentTools.push(tc.id);
80
+ }
81
+ }
82
+ }
75
83
  candidates.push({
76
84
  name: id,
77
85
  description: deriveDescription(agent.purpose),
78
86
  prompt: renderAgentSystemPrompt(agent),
79
- ...tools && tools.length > 0 ? { tools: [...tools] } : {}
87
+ ...agentTools.length > 0 ? { tools: agentTools } : {}
80
88
  });
81
89
  }
82
90
  return candidates;
@@ -2460,6 +2468,19 @@ function buildToolsByAgent(componentIR, resolved) {
2460
2468
  }
2461
2469
  }
2462
2470
  }
2471
+ if (resolved.toolchainsByAgent) {
2472
+ for (const [agentId, toolchains] of resolved.toolchainsByAgent) {
2473
+ for (const tc of toolchains) {
2474
+ if (tc.operations) {
2475
+ for (const op of tc.operations) {
2476
+ if (operationNames.has(op)) {
2477
+ appendToolForAgent(toolsByAgent, agentId, op);
2478
+ }
2479
+ }
2480
+ }
2481
+ }
2482
+ }
2483
+ }
2463
2484
  return toolsByAgent;
2464
2485
  }
2465
2486
  function appendToolForAgent(toolsByAgent, agentId, operationName) {
@@ -2497,7 +2518,8 @@ function createComponentScope(componentIR, binding, options) {
2497
2518
  binding,
2498
2519
  toolsByAgent: buildToolsByAgent(componentIR, resolved),
2499
2520
  guardrailsByAgent: buildGuardrailsByAgent(resolved),
2500
- libraryTools: buildLibraryTools(options?.libraryToolDefs)
2521
+ libraryTools: buildLibraryTools(options?.libraryToolDefs),
2522
+ ...resolved?.toolchainsByAgent ? { toolchainsByAgent: resolved.toolchainsByAgent } : {}
2501
2523
  };
2502
2524
  }
2503
2525