@aaac/runtime 0.1.6 → 0.1.9

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,66 @@
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 { O as ObserverEmitFn, 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, 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';
6
+ import './context-B_bekYiE.js';
9
7
 
10
8
  /**
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
9
+ * Process axis emit helpers for runtime integration.
10
+ * These wrap @aaac/observability's EventCollector for structured process axis events.
18
11
  */
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;
12
+
13
+ interface ProcessWorkflowOptions {
14
+ workflowId: string;
15
+ sessionId: string;
16
+ parentSpanId?: string;
17
+ /** Optional observer — no-op when undefined. */
18
+ observer?: ObserverEmitFn;
26
19
  }
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
- };
20
+ interface ProcessTaskOptions {
21
+ taskId: string;
22
+ targetAgent: string;
23
+ sessionId: string;
24
+ parentSpanId?: string;
25
+ /** Optional observer — no-op when undefined. */
26
+ observer?: ObserverEmitFn;
40
27
  }
41
- interface ModelResolverOptions {
42
- modelMapping?: ModelMappingConfig;
43
- fallbackAdapter: string;
44
- fallbackModel?: string;
45
- env?: Record<string, string | undefined>;
28
+ interface ProcessEditOptions {
29
+ filePath: string;
30
+ artifactId?: string;
31
+ sessionId: string;
32
+ parentSpanId?: string;
33
+ /** Optional observer — no-op when undefined. */
34
+ observer?: ObserverEmitFn;
46
35
  }
47
- declare function createModelResolver(options: ModelResolverOptions): ModelResolver;
48
-
49
36
  /**
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
37
+ * Emit process.workflow open span.
62
38
  */
63
-
39
+ declare function emitProcessWorkflowOpen(options: ProcessWorkflowOptions): string | undefined;
64
40
  /**
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.
41
+ * Emit process.workflow close span.
68
42
  */
69
- type SdkAdapterFactory = () => SdkAdapter;
43
+ declare function emitProcessWorkflowClose(spanId: string, options: {
44
+ status: string;
45
+ durationMs?: number;
46
+ observer?: ObserverEmitFn;
47
+ }): void;
70
48
  /**
71
- * Model-aware adapter factory. Accepts a model_class and returns an adapter
72
- * configured for that capability level (possibly a different provider/model).
49
+ * Emit process.task open span.
73
50
  */
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
- }
51
+ declare function emitProcessTaskOpen(options: ProcessTaskOptions): string | undefined;
145
52
  /**
146
- * Standard runtime invocation envelope. SDK-specific options (openaiThreadId,
147
- * sessionId, etc.) belong on the adapter constructor — not here.
53
+ * Emit process.task close span.
148
54
  */
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
- */
55
+ declare function emitProcessTaskClose(spanId: string, options: {
56
+ status: string;
57
+ durationMs?: number;
186
58
  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;
59
+ }): void;
60
+ /**
61
+ * Emit process.edit instant span.
62
+ */
63
+ declare function emitProcessEdit(options: ProcessEditOptions): string | undefined;
234
64
 
235
65
  /**
236
66
  * Plugin Interface — extension points for user code injection
@@ -300,88 +130,6 @@ declare class PluginRegistry {
300
130
  }
301
131
  declare const pluginRegistry: PluginRegistry;
302
132
 
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
133
  /**
386
134
  * Fluent Builder API for workflow invocation.
387
135
  *
@@ -790,6 +538,7 @@ interface ComponentScope {
790
538
  toolsByAgent: Map<string, string[]>;
791
539
  guardrailsByAgent: Map<string, unknown[]>;
792
540
  libraryTools?: LibraryToolRegistry;
541
+ toolchainsByAgent?: Map<string, ResolvedToolchain[]>;
793
542
  }
794
543
  interface CreateComponentScopeOptions {
795
544
  resolvedComponent?: ResolvedComponent;
@@ -844,4 +593,4 @@ declare function resolveArtifacts(options: ArtifactResolveOptions): Promise<Arti
844
593
  /** Package version string. */
845
594
  declare const version: string;
846
595
 
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 };
596
+ 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 ProcessEditOptions, type ProcessTaskOptions, type ProcessWorkflowOptions, 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, emitProcessEdit, emitProcessTaskClose, emitProcessTaskOpen, emitProcessWorkflowClose, emitProcessWorkflowOpen, 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;
@@ -1247,6 +1255,98 @@ function emitStepEvent(options, workflowId, stepIndex, step, result) {
1247
1255
  });
1248
1256
  }
1249
1257
 
1258
+ // src/lib/process-axis-bridge.ts
1259
+ import { generateId as generateId2 } from "@aaac/observability";
1260
+ function attrs2(base) {
1261
+ const out = {};
1262
+ for (const [k, v] of Object.entries(base)) {
1263
+ if (v !== void 0 && v !== "") out[k] = v;
1264
+ }
1265
+ return out;
1266
+ }
1267
+ function emitProcessWorkflowOpen(options) {
1268
+ if (!options.observer) return void 0;
1269
+ const spanId = generateId2();
1270
+ options.observer({
1271
+ source: "aaac-runtime",
1272
+ eventType: "process.workflow",
1273
+ lifecycle: "open",
1274
+ spanId,
1275
+ parentSpanId: options.parentSpanId,
1276
+ attributes: attrs2({
1277
+ axis: "process",
1278
+ "agent.session_id": options.sessionId,
1279
+ "workflow.id": options.workflowId
1280
+ })
1281
+ });
1282
+ return spanId;
1283
+ }
1284
+ function emitProcessWorkflowClose(spanId, options) {
1285
+ if (!options.observer) return;
1286
+ options.observer({
1287
+ source: "aaac-runtime",
1288
+ eventType: "process.workflow",
1289
+ lifecycle: "close",
1290
+ spanId,
1291
+ attributes: attrs2({
1292
+ axis: "process",
1293
+ "workflow.status": options.status,
1294
+ ...options.durationMs !== void 0 ? { "workflow.duration_ms": options.durationMs } : {}
1295
+ })
1296
+ });
1297
+ }
1298
+ function emitProcessTaskOpen(options) {
1299
+ if (!options.observer) return void 0;
1300
+ const spanId = generateId2();
1301
+ options.observer({
1302
+ source: "aaac-runtime",
1303
+ eventType: "process.task",
1304
+ lifecycle: "open",
1305
+ spanId,
1306
+ parentSpanId: options.parentSpanId,
1307
+ attributes: attrs2({
1308
+ axis: "process",
1309
+ "agent.session_id": options.sessionId,
1310
+ "task.id": options.taskId,
1311
+ "task.type": "implement",
1312
+ "task.target_agent": options.targetAgent
1313
+ })
1314
+ });
1315
+ return spanId;
1316
+ }
1317
+ function emitProcessTaskClose(spanId, options) {
1318
+ if (!options.observer) return;
1319
+ options.observer({
1320
+ source: "aaac-runtime",
1321
+ eventType: "process.task",
1322
+ lifecycle: "close",
1323
+ spanId,
1324
+ attributes: attrs2({
1325
+ axis: "process",
1326
+ "task.status": options.status,
1327
+ ...options.durationMs !== void 0 ? { "task.duration_ms": options.durationMs } : {}
1328
+ })
1329
+ });
1330
+ }
1331
+ function emitProcessEdit(options) {
1332
+ if (!options.observer) return void 0;
1333
+ const spanId = generateId2();
1334
+ options.observer({
1335
+ source: "aaac-runtime",
1336
+ eventType: "process.edit",
1337
+ lifecycle: "instant",
1338
+ spanId,
1339
+ parentSpanId: options.parentSpanId,
1340
+ attributes: attrs2({
1341
+ axis: "process",
1342
+ "agent.session_id": options.sessionId,
1343
+ "edit.path": options.filePath,
1344
+ "edit.artifact_id": options.artifactId
1345
+ })
1346
+ });
1347
+ return spanId;
1348
+ }
1349
+
1250
1350
  // src/lib/bound-resolver.ts
1251
1351
  import { readFile as readFile2 } from "fs/promises";
1252
1352
  import YAML2 from "yaml";
@@ -2460,6 +2560,19 @@ function buildToolsByAgent(componentIR, resolved) {
2460
2560
  }
2461
2561
  }
2462
2562
  }
2563
+ if (resolved.toolchainsByAgent) {
2564
+ for (const [agentId, toolchains] of resolved.toolchainsByAgent) {
2565
+ for (const tc of toolchains) {
2566
+ if (tc.operations) {
2567
+ for (const op of tc.operations) {
2568
+ if (operationNames.has(op)) {
2569
+ appendToolForAgent(toolsByAgent, agentId, op);
2570
+ }
2571
+ }
2572
+ }
2573
+ }
2574
+ }
2575
+ }
2463
2576
  return toolsByAgent;
2464
2577
  }
2465
2578
  function appendToolForAgent(toolsByAgent, agentId, operationName) {
@@ -2497,7 +2610,8 @@ function createComponentScope(componentIR, binding, options) {
2497
2610
  binding,
2498
2611
  toolsByAgent: buildToolsByAgent(componentIR, resolved),
2499
2612
  guardrailsByAgent: buildGuardrailsByAgent(resolved),
2500
- libraryTools: buildLibraryTools(options?.libraryToolDefs)
2613
+ libraryTools: buildLibraryTools(options?.libraryToolDefs),
2614
+ ...resolved?.toolchainsByAgent ? { toolchainsByAgent: resolved.toolchainsByAgent } : {}
2501
2615
  };
2502
2616
  }
2503
2617
 
@@ -2606,6 +2720,11 @@ export {
2606
2720
  createRuntime,
2607
2721
  createRuntimeBinding,
2608
2722
  deriveToolchainsForAgents,
2723
+ emitProcessEdit,
2724
+ emitProcessTaskClose,
2725
+ emitProcessTaskOpen,
2726
+ emitProcessWorkflowClose,
2727
+ emitProcessWorkflowOpen,
2609
2728
  emitSessionClose,
2610
2729
  emitSessionOpen,
2611
2730
  emitSubagentClose,