@aaac/runtime 0.1.5 → 0.1.6
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/adapters/adk-sdk.d.ts +1 -1
- package/dist/adapters/claude-agent-sdk.d.ts +1 -1
- package/dist/adapters/mock.d.ts +1 -1
- package/dist/adapters/openai-agents-sdk.d.ts +1 -1
- package/dist/index.d.ts +32 -3
- package/dist/index.js +183 -5
- package/dist/index.js.map +1 -1
- package/dist/{task-runner-szDOYtJV.d.ts → task-runner-R-_kW3U6.d.ts} +13 -1
- package/package.json +2 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as SdkAdapter, C as CacheConfig, A as AdapterSendOptions, a as AgentExecutionRequest, M as MemoryRef } from '../task-runner-
|
|
1
|
+
import { S as SdkAdapter, C as CacheConfig, A as AdapterSendOptions, a as AgentExecutionRequest, M as MemoryRef } from '../task-runner-R-_kW3U6.js';
|
|
2
2
|
import { G as GuardrailHooks } from '../guardrail-hooks-C8G5NGsj.js';
|
|
3
3
|
import 'zod';
|
|
4
4
|
import '@aaac/observability';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as SdkAdapter, C as CacheConfig, A as AdapterSendOptions, a as AgentExecutionRequest, M as MemoryRef } from '../task-runner-
|
|
1
|
+
import { S as SdkAdapter, C as CacheConfig, A as AdapterSendOptions, a as AgentExecutionRequest, M as MemoryRef } from '../task-runner-R-_kW3U6.js';
|
|
2
2
|
import { G as GuardrailHooks } from '../guardrail-hooks-C8G5NGsj.js';
|
|
3
3
|
import 'zod';
|
|
4
4
|
import '@aaac/observability';
|
package/dist/adapters/mock.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as SdkAdapter, C as CacheConfig, A as AdapterSendOptions, a as AgentExecutionRequest, M as MemoryRef } from '../task-runner-
|
|
1
|
+
import { S as SdkAdapter, C as CacheConfig, A as AdapterSendOptions, a as AgentExecutionRequest, M as MemoryRef } from '../task-runner-R-_kW3U6.js';
|
|
2
2
|
import { G as GuardrailHooks } from '../guardrail-hooks-C8G5NGsj.js';
|
|
3
3
|
import 'zod';
|
|
4
4
|
import '@aaac/observability';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
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-
|
|
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
|
|
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';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
import { a as GuardrailRuleData, G as GuardrailHooks } from './guardrail-hooks-C8G5NGsj.js';
|
|
5
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';
|
|
@@ -74,6 +74,13 @@ type SdkAdapterFactory = () => SdkAdapter;
|
|
|
74
74
|
type ModelAwareSdkAdapterFactory = (modelClass?: ModelClass) => SdkAdapter | Promise<SdkAdapter>;
|
|
75
75
|
/** Accepts either a single adapter (serial/shared) or a factory (parallel-safe). */
|
|
76
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
|
+
}
|
|
77
84
|
interface DelegateStep {
|
|
78
85
|
readonly type: "delegate";
|
|
79
86
|
readonly task: string;
|
|
@@ -83,6 +90,8 @@ interface DelegateStep {
|
|
|
83
90
|
readonly max_retries: number;
|
|
84
91
|
readonly max_follow_ups?: number;
|
|
85
92
|
readonly depends_on?: readonly string[];
|
|
93
|
+
readonly instruction?: string;
|
|
94
|
+
readonly receives?: Record<string, ReceiveSpec>;
|
|
86
95
|
readonly retry?: {
|
|
87
96
|
readonly condition: string;
|
|
88
97
|
readonly fix_task: string;
|
|
@@ -318,6 +327,23 @@ interface BoundResolveOptions {
|
|
|
318
327
|
artifactBinding?: ArtifactBindingConfig;
|
|
319
328
|
/** Path substitutions for artifact binding. */
|
|
320
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";
|
|
321
347
|
}
|
|
322
348
|
interface ResolvedComponent {
|
|
323
349
|
id: string;
|
|
@@ -331,6 +357,8 @@ interface ResolvedComponent {
|
|
|
331
357
|
message: string;
|
|
332
358
|
severity?: string;
|
|
333
359
|
}>;
|
|
360
|
+
toolchains?: Record<string, ResolvedToolchain>;
|
|
361
|
+
toolchainsByAgent?: Map<string, ResolvedToolchain[]>;
|
|
334
362
|
}
|
|
335
363
|
/**
|
|
336
364
|
* Effective guardrail IDs for an agent: entity-side bindings ∪ scope-side bindings.
|
|
@@ -338,6 +366,7 @@ interface ResolvedComponent {
|
|
|
338
366
|
declare function getEffectiveGuardrailIds(dsl: Record<string, unknown>, agentId: string): Set<string>;
|
|
339
367
|
declare function guardrailContextToRuleData(ctx: GuardrailContext, effectiveIds?: Set<string>): GuardrailRuleData;
|
|
340
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[]>;
|
|
341
370
|
declare class BoundResolver {
|
|
342
371
|
private readonly cache;
|
|
343
372
|
/**
|
|
@@ -815,4 +844,4 @@ declare function resolveArtifacts(options: ArtifactResolveOptions): Promise<Arti
|
|
|
815
844
|
/** Package version string. */
|
|
816
845
|
declare const version: string;
|
|
817
846
|
|
|
818
|
-
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 RequiredEntities, type ResolvedComponent, type ResolvedModel, 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, executeTask, executeWorkflow, getEffectiveGuardrailIds, getGuardrailRulesForAgent, guardrailContextToRuleData, jsonSchemaToZod, loadDslContext, loadPlugins, loadPluginsFromDirectory, loadPluginsFromPaths, parseGateEvaluationResponse, pluginRegistry, resolveArtifacts, runWorkflow, version };
|
|
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 };
|
package/dist/index.js
CHANGED
|
@@ -205,6 +205,42 @@ function emitSubagentClose(observer, spanId, envelope, durationMs, status, agent
|
|
|
205
205
|
}
|
|
206
206
|
});
|
|
207
207
|
}
|
|
208
|
+
function emitToolchainOpen(observer, parentSpanId, toolchainId, operation, artifactIds, componentId) {
|
|
209
|
+
if (!observer) return void 0;
|
|
210
|
+
const spanId = generateId();
|
|
211
|
+
observer({
|
|
212
|
+
source: "aaac-runtime",
|
|
213
|
+
eventType: "toolchain.execution",
|
|
214
|
+
lifecycle: "open",
|
|
215
|
+
spanId,
|
|
216
|
+
parentSpanId,
|
|
217
|
+
attributes: attrs({
|
|
218
|
+
axis: "toolchain",
|
|
219
|
+
"toolchain.id": toolchainId,
|
|
220
|
+
"toolchain.operation": operation,
|
|
221
|
+
"toolchain.artifact_ids": artifactIds.join(","),
|
|
222
|
+
"agent.component_id": componentId
|
|
223
|
+
})
|
|
224
|
+
});
|
|
225
|
+
return spanId;
|
|
226
|
+
}
|
|
227
|
+
function emitToolchainClose(observer, spanId, toolchainId, operation, durationMs, status, errorMessage) {
|
|
228
|
+
if (!observer) return;
|
|
229
|
+
observer({
|
|
230
|
+
source: "aaac-runtime",
|
|
231
|
+
eventType: "toolchain.execution",
|
|
232
|
+
lifecycle: "close",
|
|
233
|
+
spanId,
|
|
234
|
+
attributes: attrs({
|
|
235
|
+
axis: "toolchain",
|
|
236
|
+
"toolchain.id": toolchainId,
|
|
237
|
+
"toolchain.operation": operation,
|
|
238
|
+
"toolchain.status": status,
|
|
239
|
+
"toolchain.duration_ms": durationMs,
|
|
240
|
+
...errorMessage ? { "toolchain.error": errorMessage } : {}
|
|
241
|
+
})
|
|
242
|
+
});
|
|
243
|
+
}
|
|
208
244
|
|
|
209
245
|
// src/lib/task-runner.ts
|
|
210
246
|
function getZodChecks(schema) {
|
|
@@ -920,7 +956,35 @@ async function runWorkflow(adapterOrFactory, workflowIdOrInvocation, optionsOrRe
|
|
|
920
956
|
const completed = /* @__PURE__ */ new Set();
|
|
921
957
|
const stepResults = new Array(workflow.steps.length);
|
|
922
958
|
const stepContexts = new Array(workflow.steps.length).fill("");
|
|
959
|
+
const stepOutputs = new Array(workflow.steps.length).fill(void 0);
|
|
923
960
|
let abortResult;
|
|
961
|
+
function extractPath(obj, path) {
|
|
962
|
+
const cleanPath = path.startsWith("$.") ? path.slice(2) : path;
|
|
963
|
+
const segments = cleanPath.split(".");
|
|
964
|
+
let current = obj;
|
|
965
|
+
for (const seg of segments) {
|
|
966
|
+
if (current == null || typeof current !== "object") return void 0;
|
|
967
|
+
current = current[seg];
|
|
968
|
+
}
|
|
969
|
+
return current;
|
|
970
|
+
}
|
|
971
|
+
function projectHandoffs(stepIndex, step) {
|
|
972
|
+
if (!step.receives) return void 0;
|
|
973
|
+
const projected = {};
|
|
974
|
+
for (const [alias, spec] of Object.entries(step.receives)) {
|
|
975
|
+
const fromTaskId = spec.from ?? alias;
|
|
976
|
+
const depIdx = workflow.steps.findIndex((s, j) => j < stepIndex && stepId(j) === fromTaskId);
|
|
977
|
+
if (depIdx === -1) continue;
|
|
978
|
+
const output = stepOutputs[depIdx];
|
|
979
|
+
if (output === void 0) continue;
|
|
980
|
+
if (spec.path) {
|
|
981
|
+
projected[alias] = extractPath(output, spec.path);
|
|
982
|
+
} else {
|
|
983
|
+
projected[alias] = output;
|
|
984
|
+
}
|
|
985
|
+
}
|
|
986
|
+
return Object.keys(projected).length > 0 ? projected : void 0;
|
|
987
|
+
}
|
|
924
988
|
function contextFor(stepIndex) {
|
|
925
989
|
const deps = depsByIndex[stepIndex];
|
|
926
990
|
if (deps.length === 0) return "";
|
|
@@ -932,8 +996,10 @@ async function runWorkflow(adapterOrFactory, workflowIdOrInvocation, optionsOrRe
|
|
|
932
996
|
if (step.type === "gate") {
|
|
933
997
|
return handleGateStep(step, Object.values(stepResults).filter(Boolean), options, i, stepAdapter);
|
|
934
998
|
}
|
|
999
|
+
const delegateStep = step;
|
|
935
1000
|
if (step.optional) {
|
|
936
|
-
const
|
|
1001
|
+
const stepUserRequest2 = delegateStep.instruction ?? options.user_request;
|
|
1002
|
+
const ctx = { user_request: stepUserRequest2, prior_context: contextFor(i), variables: options.variables };
|
|
937
1003
|
const shouldRun = options.onOptionalStep ? await options.onOptionalStep(step, ctx) : false;
|
|
938
1004
|
if (!shouldRun) {
|
|
939
1005
|
return {
|
|
@@ -946,11 +1012,23 @@ async function runWorkflow(adapterOrFactory, workflowIdOrInvocation, optionsOrRe
|
|
|
946
1012
|
};
|
|
947
1013
|
}
|
|
948
1014
|
}
|
|
1015
|
+
const stepUserRequest = delegateStep.instruction ?? options.user_request;
|
|
1016
|
+
let handoffInput;
|
|
1017
|
+
const projected = projectHandoffs(i, delegateStep);
|
|
1018
|
+
if (projected) {
|
|
1019
|
+
handoffInput = {
|
|
1020
|
+
type: "step-projection",
|
|
1021
|
+
payload: projected
|
|
1022
|
+
};
|
|
1023
|
+
} else if (i === 0 && invocationHandoff) {
|
|
1024
|
+
handoffInput = invocationHandoff;
|
|
1025
|
+
}
|
|
1026
|
+
const useLegacyContext = !delegateStep.receives;
|
|
949
1027
|
const context = {
|
|
950
|
-
user_request:
|
|
951
|
-
prior_context: contextFor(i),
|
|
1028
|
+
user_request: stepUserRequest,
|
|
1029
|
+
...useLegacyContext ? { prior_context: contextFor(i) } : {},
|
|
952
1030
|
variables: options.variables,
|
|
953
|
-
...
|
|
1031
|
+
...handoffInput ? { handoff_input: handoffInput } : {}
|
|
954
1032
|
};
|
|
955
1033
|
const taskResult = await runTask(stepAdapter, step.task, context, {
|
|
956
1034
|
maxFollowUps: options.maxFollowUps ?? step.max_follow_ups ?? 2,
|
|
@@ -1017,6 +1095,7 @@ async function runWorkflow(adapterOrFactory, workflowIdOrInvocation, optionsOrRe
|
|
|
1017
1095
|
emitStepEvent(options, workflow.id, i, step, result);
|
|
1018
1096
|
if (result.outcome.status === "success") {
|
|
1019
1097
|
const data = result.outcome.data;
|
|
1098
|
+
stepOutputs[i] = data;
|
|
1020
1099
|
stepContexts[i] = `
|
|
1021
1100
|
|
|
1022
1101
|
--- Step ${i + 1}: ${stepId(i)} ---
|
|
@@ -1423,6 +1502,71 @@ function buildPerAgentGuardrails(dsl, guardrailCtx) {
|
|
|
1423
1502
|
function hasGuardrailRules(rules) {
|
|
1424
1503
|
return rules.commandRules.length > 0 || rules.fileRules.length > 0 || rules.contentRules.length > 0;
|
|
1425
1504
|
}
|
|
1505
|
+
function mergeDerivedWithAgentTools(derivedTools, agentToolIds, allToolchains) {
|
|
1506
|
+
const merged = /* @__PURE__ */ new Map();
|
|
1507
|
+
for (const tc of derivedTools) {
|
|
1508
|
+
merged.set(tc.id, tc);
|
|
1509
|
+
}
|
|
1510
|
+
for (const toolId of agentToolIds) {
|
|
1511
|
+
if (!merged.has(toolId)) {
|
|
1512
|
+
if (allToolchains[toolId]) {
|
|
1513
|
+
merged.set(toolId, { ...allToolchains[toolId], source: "merged" });
|
|
1514
|
+
}
|
|
1515
|
+
} else {
|
|
1516
|
+
const existing = merged.get(toolId);
|
|
1517
|
+
merged.set(toolId, { ...existing, source: "merged" });
|
|
1518
|
+
}
|
|
1519
|
+
}
|
|
1520
|
+
return Array.from(merged.values());
|
|
1521
|
+
}
|
|
1522
|
+
function deriveToolchainsForAgents(dsl, toolchains) {
|
|
1523
|
+
const result = /* @__PURE__ */ new Map();
|
|
1524
|
+
const agents = dsl.agents ?? {};
|
|
1525
|
+
for (const [agentId, agent] of Object.entries(agents)) {
|
|
1526
|
+
const derivedTools = [];
|
|
1527
|
+
const canReadArtifacts = agent.can_read_artifacts ?? [];
|
|
1528
|
+
const canWriteArtifacts = agent.can_write_artifacts ?? [];
|
|
1529
|
+
const agentArtifacts = agent.artifacts;
|
|
1530
|
+
const readArtifacts = /* @__PURE__ */ new Set([
|
|
1531
|
+
...canReadArtifacts,
|
|
1532
|
+
...agentArtifacts?.consumes ?? []
|
|
1533
|
+
]);
|
|
1534
|
+
const writeArtifacts = /* @__PURE__ */ new Set([
|
|
1535
|
+
...canWriteArtifacts,
|
|
1536
|
+
...agentArtifacts?.produces ?? []
|
|
1537
|
+
]);
|
|
1538
|
+
for (const tc of Object.values(toolchains)) {
|
|
1539
|
+
let matched = false;
|
|
1540
|
+
for (const artifactId of tc.artifacts.consumes) {
|
|
1541
|
+
if (readArtifacts.has(artifactId) || writeArtifacts.has(artifactId)) {
|
|
1542
|
+
matched = true;
|
|
1543
|
+
break;
|
|
1544
|
+
}
|
|
1545
|
+
}
|
|
1546
|
+
if (!matched) {
|
|
1547
|
+
for (const artifactId of tc.artifacts.produces) {
|
|
1548
|
+
if (writeArtifacts.has(artifactId)) {
|
|
1549
|
+
matched = true;
|
|
1550
|
+
break;
|
|
1551
|
+
}
|
|
1552
|
+
}
|
|
1553
|
+
}
|
|
1554
|
+
if (matched) {
|
|
1555
|
+
derivedTools.push(tc);
|
|
1556
|
+
}
|
|
1557
|
+
}
|
|
1558
|
+
if (derivedTools.length > 0) {
|
|
1559
|
+
const agentTools = agent.can_execute_tools ?? [];
|
|
1560
|
+
const mergedTools = mergeDerivedWithAgentTools(
|
|
1561
|
+
derivedTools,
|
|
1562
|
+
agentTools,
|
|
1563
|
+
toolchains
|
|
1564
|
+
);
|
|
1565
|
+
result.set(agentId, mergedTools);
|
|
1566
|
+
}
|
|
1567
|
+
}
|
|
1568
|
+
return result;
|
|
1569
|
+
}
|
|
1426
1570
|
var BoundResolver = class {
|
|
1427
1571
|
cache = /* @__PURE__ */ new Map();
|
|
1428
1572
|
/**
|
|
@@ -1476,12 +1620,43 @@ var BoundResolver = class {
|
|
|
1476
1620
|
}
|
|
1477
1621
|
}
|
|
1478
1622
|
const perAgent = guardrailCtx.hasGuardrails ? buildPerAgentGuardrails(dsl, guardrailCtx) : /* @__PURE__ */ new Map();
|
|
1623
|
+
let toolchains;
|
|
1624
|
+
let toolchainsByAgent;
|
|
1625
|
+
if (opts.toolchainContractsPath) {
|
|
1626
|
+
const toolchainPkg = "@aaac/toolchain";
|
|
1627
|
+
const mod = await import(
|
|
1628
|
+
/* webpackIgnore: true */
|
|
1629
|
+
toolchainPkg
|
|
1630
|
+
);
|
|
1631
|
+
const tcDoc = await mod.loadToolchainContracts(opts.toolchainContractsPath);
|
|
1632
|
+
toolchains = {};
|
|
1633
|
+
for (const [id, tc] of Object.entries(tcDoc.toolchains)) {
|
|
1634
|
+
toolchains[id] = {
|
|
1635
|
+
id,
|
|
1636
|
+
kind: tc.kind,
|
|
1637
|
+
description: tc.description,
|
|
1638
|
+
module: tc.module,
|
|
1639
|
+
command: tc.command,
|
|
1640
|
+
cli_contract: tc.cli_contract,
|
|
1641
|
+
component_contract: tc.component_contract,
|
|
1642
|
+
artifacts: {
|
|
1643
|
+
consumes: [...tc.artifacts.consumes],
|
|
1644
|
+
produces: [...tc.artifacts.produces]
|
|
1645
|
+
},
|
|
1646
|
+
operations: tc.operations ? [...tc.operations] : void 0,
|
|
1647
|
+
source: "toolchain-contracts"
|
|
1648
|
+
};
|
|
1649
|
+
}
|
|
1650
|
+
toolchainsByAgent = deriveToolchainsForAgents(dsl, toolchains);
|
|
1651
|
+
}
|
|
1479
1652
|
const component = {
|
|
1480
1653
|
id: opts.id,
|
|
1481
1654
|
dsl,
|
|
1482
1655
|
registries: buildRegistriesFromDsl(dsl),
|
|
1483
1656
|
guardrails: { perAgent },
|
|
1484
|
-
diagnostics
|
|
1657
|
+
diagnostics,
|
|
1658
|
+
...toolchains ? { toolchains } : {},
|
|
1659
|
+
...toolchainsByAgent ? { toolchainsByAgent } : {}
|
|
1485
1660
|
};
|
|
1486
1661
|
this.cache.set(opts.id, component);
|
|
1487
1662
|
return component;
|
|
@@ -2430,10 +2605,13 @@ export {
|
|
|
2430
2605
|
createProgressSink,
|
|
2431
2606
|
createRuntime,
|
|
2432
2607
|
createRuntimeBinding,
|
|
2608
|
+
deriveToolchainsForAgents,
|
|
2433
2609
|
emitSessionClose,
|
|
2434
2610
|
emitSessionOpen,
|
|
2435
2611
|
emitSubagentClose,
|
|
2436
2612
|
emitSubagentOpen,
|
|
2613
|
+
emitToolchainClose,
|
|
2614
|
+
emitToolchainOpen,
|
|
2437
2615
|
executeTask,
|
|
2438
2616
|
executeWorkflow,
|
|
2439
2617
|
extractStructuredResult,
|