@aaac/runtime 0.1.10 → 0.1.12
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 +1 -1
- 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/mock.js +4 -1
- package/dist/adapters/mock.js.map +1 -1
- package/dist/adapters/openai-agents-sdk.d.ts +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +134 -6
- package/dist/index.js.map +1 -1
- package/dist/{task-runner-CZScv9Yb.d.ts → task-runner-C1hxIJTd.d.ts} +32 -3
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @aaac/runtime
|
|
2
2
|
|
|
3
|
-
Runtime SDK for the
|
|
3
|
+
Runtime SDK for the AaaC (Agent-Assisted Architecture Contracts) toolchain. Bridges agent-contracts DSL workflows to multiple Agent SDKs and provides AaaC-specific component binding.
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as SdkAdapter, G as GuardrailHooks, C as CacheConfig, A as AdapterSendOptions, a as AgentExecutionRequest, M as MemoryRef } from '../task-runner-
|
|
1
|
+
import { S as SdkAdapter, G as GuardrailHooks, C as CacheConfig, A as AdapterSendOptions, a as AgentExecutionRequest, M as MemoryRef } from '../task-runner-C1hxIJTd.js';
|
|
2
2
|
import 'zod';
|
|
3
3
|
import '../context-DKkamYX_.js';
|
|
4
4
|
import '@aaac/observability';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as SdkAdapter, G as GuardrailHooks, C as CacheConfig, A as AdapterSendOptions, a as AgentExecutionRequest, M as MemoryRef } from '../task-runner-
|
|
1
|
+
import { S as SdkAdapter, G as GuardrailHooks, C as CacheConfig, A as AdapterSendOptions, a as AgentExecutionRequest, M as MemoryRef } from '../task-runner-C1hxIJTd.js';
|
|
2
2
|
import 'zod';
|
|
3
3
|
import '../context-DKkamYX_.js';
|
|
4
4
|
import '@aaac/observability';
|
package/dist/adapters/mock.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as SdkAdapter, A as AdapterSendOptions, M as MemoryRef } from '../task-runner-
|
|
1
|
+
import { S as SdkAdapter, A as AdapterSendOptions, M as MemoryRef } from '../task-runner-C1hxIJTd.js';
|
|
2
2
|
import 'zod';
|
|
3
3
|
import '../context-DKkamYX_.js';
|
|
4
4
|
import '@aaac/observability';
|
package/dist/adapters/mock.js
CHANGED
|
@@ -9,7 +9,10 @@ var MockAdapter = class {
|
|
|
9
9
|
}
|
|
10
10
|
async send(prompt, _options) {
|
|
11
11
|
const match = prompt.match(/## Task: (\S+)/);
|
|
12
|
-
|
|
12
|
+
if (!match) {
|
|
13
|
+
throw new Error(`MockAdapter: no "## Task: <id>" marker found in prompt`);
|
|
14
|
+
}
|
|
15
|
+
const taskId = match[1];
|
|
13
16
|
const reqMatch = prompt.match(/## User Request\n\n([\s\S]*?)(?:\n\n---|$)/);
|
|
14
17
|
const userRequest = reqMatch?.[1]?.trim() ?? "";
|
|
15
18
|
if (this.defaultLatencyMs > 0) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/adapters/mock.ts"],"sourcesContent":["/**\n * Mock SDK Adapter — for testing and demo purposes\n */\n\nimport type { SdkAdapter } from \"../lib/task-runner.js\";\nimport type { MemoryRef } from \"../lib/memory-store.js\";\n\nexport class MockAdapter implements SdkAdapter {\n private responses: Record<string, (userRequest: string) => string>;\n private defaultLatencyMs: number;\n private lastMemoryRef: MemoryRef | null = null;\n\n constructor(options?: {\n responses?: Record<string, (userRequest: string) => string>;\n defaultLatencyMs?: number;\n }) {\n this.responses = options?.responses ?? {};\n this.defaultLatencyMs = options?.defaultLatencyMs ?? 0;\n }\n\n async send(prompt: string, _options: import(\"../lib/task-runner.js\").AdapterSendOptions): Promise<string> {\n const match = prompt.match(/## Task: (\\S+)/);\n const taskId = match
|
|
1
|
+
{"version":3,"sources":["../../src/adapters/mock.ts"],"sourcesContent":["/**\n * Mock SDK Adapter — for testing and demo purposes\n */\n\nimport type { SdkAdapter } from \"../lib/task-runner.js\";\nimport type { MemoryRef } from \"../lib/memory-store.js\";\n\nexport class MockAdapter implements SdkAdapter {\n private responses: Record<string, (userRequest: string) => string>;\n private defaultLatencyMs: number;\n private lastMemoryRef: MemoryRef | null = null;\n\n constructor(options?: {\n responses?: Record<string, (userRequest: string) => string>;\n defaultLatencyMs?: number;\n }) {\n this.responses = options?.responses ?? {};\n this.defaultLatencyMs = options?.defaultLatencyMs ?? 0;\n }\n\n async send(prompt: string, _options: import(\"../lib/task-runner.js\").AdapterSendOptions): Promise<string> {\n const match = prompt.match(/## Task: (\\S+)/);\n if (!match) {\n throw new Error(`MockAdapter: no \"## Task: <id>\" marker found in prompt`);\n }\n const taskId = match[1];\n\n const reqMatch = prompt.match(/## User Request\\n\\n([\\s\\S]*?)(?:\\n\\n---|$)/);\n const userRequest = reqMatch?.[1]?.trim() ?? \"\";\n\n if (this.defaultLatencyMs > 0) {\n await new Promise((r) => setTimeout(r, this.defaultLatencyMs));\n }\n\n const responseFn = this.responses[taskId];\n if (!responseFn) {\n return `Task \"${taskId}\" completed but no structured output available.`;\n }\n\n const result = responseFn(userRequest);\n this.lastMemoryRef = {\n id: `mock-ref-${Date.now()}`,\n provider: \"mock\",\n compat: \"mock@1\",\n created_at: new Date().toISOString(),\n };\n return result;\n }\n\n getLastMemoryRef(): MemoryRef | null {\n return this.lastMemoryRef;\n }\n\n isCompatible(compat: string): boolean {\n return compat.startsWith(\"mock@\");\n }\n}\n"],"mappings":";AAOO,IAAM,cAAN,MAAwC;AAAA,EACrC;AAAA,EACA;AAAA,EACA,gBAAkC;AAAA,EAE1C,YAAY,SAGT;AACD,SAAK,YAAY,SAAS,aAAa,CAAC;AACxC,SAAK,mBAAmB,SAAS,oBAAoB;AAAA,EACvD;AAAA,EAEA,MAAM,KAAK,QAAgB,UAA+E;AACxG,UAAM,QAAQ,OAAO,MAAM,gBAAgB;AAC3C,QAAI,CAAC,OAAO;AACV,YAAM,IAAI,MAAM,wDAAwD;AAAA,IAC1E;AACA,UAAM,SAAS,MAAM,CAAC;AAEtB,UAAM,WAAW,OAAO,MAAM,4CAA4C;AAC1E,UAAM,cAAc,WAAW,CAAC,GAAG,KAAK,KAAK;AAE7C,QAAI,KAAK,mBAAmB,GAAG;AAC7B,YAAM,IAAI,QAAQ,CAAC,MAAM,WAAW,GAAG,KAAK,gBAAgB,CAAC;AAAA,IAC/D;AAEA,UAAM,aAAa,KAAK,UAAU,MAAM;AACxC,QAAI,CAAC,YAAY;AACf,aAAO,SAAS,MAAM;AAAA,IACxB;AAEA,UAAM,SAAS,WAAW,WAAW;AACrC,SAAK,gBAAgB;AAAA,MACnB,IAAI,YAAY,KAAK,IAAI,CAAC;AAAA,MAC1B,UAAU;AAAA,MACV,QAAQ;AAAA,MACR,aAAY,oBAAI,KAAK,GAAE,YAAY;AAAA,IACrC;AACA,WAAO;AAAA,EACT;AAAA,EAEA,mBAAqC;AACnC,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,aAAa,QAAyB;AACpC,WAAO,OAAO,WAAW,OAAO;AAAA,EAClC;AACF;","names":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as SdkAdapter, G as GuardrailHooks, C as CacheConfig, A as AdapterSendOptions, a as AgentExecutionRequest, M as MemoryRef } from '../task-runner-
|
|
1
|
+
import { S as SdkAdapter, G as GuardrailHooks, C as CacheConfig, A as AdapterSendOptions, a as AgentExecutionRequest, M as MemoryRef } from '../task-runner-C1hxIJTd.js';
|
|
2
2
|
import 'zod';
|
|
3
3
|
import '../context-DKkamYX_.js';
|
|
4
4
|
import '@aaac/observability';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
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-
|
|
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,
|
|
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-C1hxIJTd.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, r as ConvergenceEnvelope, s as ConvergenceEnvelopePayload, E as EnvelopeParams, t as EvaluateStep, u as GateStep, v as GuardrailCheckFunctions, w as GuardrailCheckResult, x as GuardrailRule, y as HookContext, z as HookResponse, I as InMemoryStore, F as ModelAwareSdkAdapterFactory, J as ModelClass, K as ModelMappingConfig, N as ModelResolver, Q as ModelResolverOptions, U as ReceiveSpec, V as ResolvedModel, X as RetryDecision, Y as SdkAdapterFactory, Z as SplitPrompt, _ as TaskRunOptions, $ as WorkflowContractLike, a0 as WorkflowInvocation, a1 as WorkflowRunOptions, a2 as WorkflowStep, a3 as buildCandidateAgents, a4 as buildGateEvaluationPrompt, a5 as buildPerAgentGuardrails, a6 as buildRetryFollowUp, a7 as buildSplitTaskPrompt, a8 as buildTaskPrompt, a9 as createExecutionEnvelope, aa as createGuardrailHooks, ab as createGuardrailHooksForAgent, ac as createGuardrailHooksFromRules, ad as createLibraryToolRegistry, ae as createModelResolver, af as deriveToolchainsForAgents, ag as emitSessionClose, ah as emitSessionOpen, ai as emitSubagentClose, aj as emitSubagentOpen, ak as emitToolchainClose, al as emitToolchainOpen, am as extractStructuredResult, an as getBlockingViolations, ao as getEffectiveGuardrailIds, ap as getGuardrailRulesForAgent, aq as getWarnings, ar as guardrailContextToRuleData, as as hasBlockingViolation, at as parseGateEvaluationResponse, au as renderAgentSystemPrompt, av as runTask, aw as runWorkflow, ax as zodSchemaToPromptDescription, ay as zodSchemaToYamlExample } from './task-runner-C1hxIJTd.js';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
import { OperationIR, ComponentIR } from '@aaac/contracts';
|
|
5
5
|
import { ResolvedConfig } from './generator/index.js';
|
package/dist/index.js
CHANGED
|
@@ -524,6 +524,12 @@ ${context.relevant_paths.map((p) => `- ${p}`).join("\n")}`
|
|
|
524
524
|
${context.acceptance_criteria.map((c) => `- ${c}`).join("\n")}`
|
|
525
525
|
);
|
|
526
526
|
}
|
|
527
|
+
if (context.variables && Object.keys(context.variables).length > 0) {
|
|
528
|
+
const varLines = Object.entries(context.variables).map(([k, v]) => `- ${k}: ${typeof v === "string" ? v : JSON.stringify(v)}`).join("\n");
|
|
529
|
+
userSections.push(`## Context Variables
|
|
530
|
+
|
|
531
|
+
${varLines}`);
|
|
532
|
+
}
|
|
527
533
|
return {
|
|
528
534
|
system,
|
|
529
535
|
user: userSections.join("\n\n---\n\n")
|
|
@@ -948,7 +954,8 @@ async function runWorkflow(adapterOrFactory, workflowIdOrInvocation, optionsOrRe
|
|
|
948
954
|
const workflowStart = Date.now();
|
|
949
955
|
const stepId = (i) => {
|
|
950
956
|
const s = workflow.steps[i];
|
|
951
|
-
|
|
957
|
+
if (s.type === "delegate" || s.type === "evaluate") return s.task;
|
|
958
|
+
return `gate:${s.gate_kind}`;
|
|
952
959
|
};
|
|
953
960
|
const depsByIndex = workflow.steps.map((step, i) => {
|
|
954
961
|
if (step.depends_on !== void 0) {
|
|
@@ -967,6 +974,8 @@ async function runWorkflow(adapterOrFactory, workflowIdOrInvocation, optionsOrRe
|
|
|
967
974
|
const stepContexts = new Array(workflow.steps.length).fill("");
|
|
968
975
|
const stepOutputs = new Array(workflow.steps.length).fill(void 0);
|
|
969
976
|
let abortResult;
|
|
977
|
+
const evaluateExecCount = /* @__PURE__ */ new Map();
|
|
978
|
+
const loopInjectedVars = {};
|
|
970
979
|
function extractPath(obj, path) {
|
|
971
980
|
const cleanPath = path.startsWith("$.") ? path.slice(2) : path;
|
|
972
981
|
const segments = cleanPath.split(".");
|
|
@@ -1005,10 +1014,43 @@ async function runWorkflow(adapterOrFactory, workflowIdOrInvocation, optionsOrRe
|
|
|
1005
1014
|
if (step.type === "gate") {
|
|
1006
1015
|
return handleGateStep(step, Object.values(stepResults).filter(Boolean), options, i, stepAdapter);
|
|
1007
1016
|
}
|
|
1017
|
+
if (step.type === "evaluate") {
|
|
1018
|
+
const evaluateStep = step;
|
|
1019
|
+
const effectiveVariables = mergeVariables(options.variables, loopInjectedVars);
|
|
1020
|
+
const context2 = {
|
|
1021
|
+
user_request: evaluateStep.description ?? options.user_request,
|
|
1022
|
+
prior_context: contextFor(i),
|
|
1023
|
+
...effectiveVariables ? { variables: effectiveVariables } : {}
|
|
1024
|
+
};
|
|
1025
|
+
const taskResult2 = await runTask(stepAdapter, evaluateStep.task, context2, {
|
|
1026
|
+
maxFollowUps: options.maxFollowUps ?? 2,
|
|
1027
|
+
maxRetries: 0,
|
|
1028
|
+
// evaluate steps do not retry
|
|
1029
|
+
taskRegistry: registries?.taskRegistry,
|
|
1030
|
+
agentRegistry: registries?.agentRegistry,
|
|
1031
|
+
handoffSchemas: registries?.handoffSchemas,
|
|
1032
|
+
progressOutput: options.progressOutput,
|
|
1033
|
+
observer: options.observer,
|
|
1034
|
+
parentSpanId: sessionSpanId
|
|
1035
|
+
});
|
|
1036
|
+
return {
|
|
1037
|
+
step_index: i,
|
|
1038
|
+
task_id: evaluateStep.task,
|
|
1039
|
+
outcome: taskResult2.outcome,
|
|
1040
|
+
follow_ups_used: taskResult2.follow_ups_used,
|
|
1041
|
+
retries_used: taskResult2.retries_used,
|
|
1042
|
+
elapsed_ms: Date.now() - stepStart
|
|
1043
|
+
};
|
|
1044
|
+
}
|
|
1008
1045
|
const delegateStep = step;
|
|
1009
1046
|
if (step.optional) {
|
|
1010
1047
|
const stepUserRequest2 = delegateStep.instruction ?? options.user_request;
|
|
1011
|
-
const
|
|
1048
|
+
const ctxVars = mergeVariables(options.variables, loopInjectedVars);
|
|
1049
|
+
const ctx = {
|
|
1050
|
+
user_request: stepUserRequest2,
|
|
1051
|
+
prior_context: contextFor(i),
|
|
1052
|
+
...ctxVars ? { variables: ctxVars } : {}
|
|
1053
|
+
};
|
|
1012
1054
|
const shouldRun = options.onOptionalStep ? await options.onOptionalStep(step, ctx) : false;
|
|
1013
1055
|
if (!shouldRun) {
|
|
1014
1056
|
return {
|
|
@@ -1033,10 +1075,11 @@ async function runWorkflow(adapterOrFactory, workflowIdOrInvocation, optionsOrRe
|
|
|
1033
1075
|
handoffInput = invocationHandoff;
|
|
1034
1076
|
}
|
|
1035
1077
|
const useLegacyContext = !delegateStep.receives;
|
|
1078
|
+
const delegateVars = mergeVariables(options.variables, loopInjectedVars);
|
|
1036
1079
|
const context = {
|
|
1037
1080
|
user_request: stepUserRequest,
|
|
1038
1081
|
...useLegacyContext ? { prior_context: contextFor(i) } : {},
|
|
1039
|
-
variables:
|
|
1082
|
+
...delegateVars ? { variables: delegateVars } : {},
|
|
1040
1083
|
...handoffInput ? { handoff_input: handoffInput } : {}
|
|
1041
1084
|
};
|
|
1042
1085
|
const taskResult = await runTask(stepAdapter, step.task, context, {
|
|
@@ -1082,7 +1125,7 @@ async function runWorkflow(adapterOrFactory, workflowIdOrInvocation, optionsOrRe
|
|
|
1082
1125
|
}
|
|
1083
1126
|
const batchResults = await Promise.all(ready.map(async (i) => {
|
|
1084
1127
|
const step = workflow.steps[i];
|
|
1085
|
-
const modelClass = step.type === "delegate" ? registries?.taskRegistry?.[step.task]?.model_class : void 0;
|
|
1128
|
+
const modelClass = step.type === "delegate" || step.type === "evaluate" ? registries?.taskRegistry?.[step.task]?.model_class : void 0;
|
|
1086
1129
|
let stepAdapter;
|
|
1087
1130
|
if (ready.length > 1 && adapterFactory) {
|
|
1088
1131
|
const result = adapterFactory(modelClass);
|
|
@@ -1099,6 +1142,77 @@ async function runWorkflow(adapterOrFactory, workflowIdOrInvocation, optionsOrRe
|
|
|
1099
1142
|
const i = ready[b];
|
|
1100
1143
|
const result = batchResults[b];
|
|
1101
1144
|
const step = workflow.steps[i];
|
|
1145
|
+
if (step.type === "evaluate") {
|
|
1146
|
+
const evaluateStep = step;
|
|
1147
|
+
const data = result.outcome.status === "success" ? result.outcome.data : void 0;
|
|
1148
|
+
const verdict = typeof data?.verdict === "string" ? data.verdict : "fail";
|
|
1149
|
+
const execCount = (evaluateExecCount.get(i) ?? 0) + 1;
|
|
1150
|
+
if (verdict === "pass") {
|
|
1151
|
+
stepResults[i] = result;
|
|
1152
|
+
completed.add(i);
|
|
1153
|
+
emitStepEvent(options, workflow.id, i, step, result);
|
|
1154
|
+
if (data !== void 0) {
|
|
1155
|
+
stepOutputs[i] = data;
|
|
1156
|
+
stepContexts[i] = `
|
|
1157
|
+
|
|
1158
|
+
--- Step ${i + 1}: ${stepId(i)} ---
|
|
1159
|
+
${JSON.stringify(data, null, 2)}`;
|
|
1160
|
+
}
|
|
1161
|
+
} else if (execCount < evaluateStep.max_iterations) {
|
|
1162
|
+
evaluateExecCount.set(i, execCount);
|
|
1163
|
+
if (evaluateStep.inject_as) {
|
|
1164
|
+
const feedback = typeof data?.feedback === "string" ? data.feedback : data !== void 0 ? JSON.stringify(data) : "Evaluate step returned no feedback";
|
|
1165
|
+
loopInjectedVars[evaluateStep.inject_as] = feedback;
|
|
1166
|
+
}
|
|
1167
|
+
const loopToIdx = workflow.steps.findIndex((s, j) => j < i && stepId(j) === evaluateStep.loop_to);
|
|
1168
|
+
if (loopToIdx === -1) {
|
|
1169
|
+
stepResults[i] = result;
|
|
1170
|
+
completed.add(i);
|
|
1171
|
+
abortResult = {
|
|
1172
|
+
workflow_id: workflow.id,
|
|
1173
|
+
status: "error",
|
|
1174
|
+
steps: stepResults.filter(Boolean),
|
|
1175
|
+
total_elapsed_ms: Date.now() - workflowStart,
|
|
1176
|
+
error_message: `Evaluate step "${evaluateStep.task}" references unknown loop_to "${evaluateStep.loop_to}"`
|
|
1177
|
+
};
|
|
1178
|
+
} else {
|
|
1179
|
+
for (let k = loopToIdx; k <= i; k++) {
|
|
1180
|
+
completed.delete(k);
|
|
1181
|
+
stepOutputs[k] = void 0;
|
|
1182
|
+
stepContexts[k] = "";
|
|
1183
|
+
}
|
|
1184
|
+
}
|
|
1185
|
+
} else {
|
|
1186
|
+
evaluateExecCount.set(i, execCount);
|
|
1187
|
+
stepResults[i] = result;
|
|
1188
|
+
completed.add(i);
|
|
1189
|
+
switch (evaluateStep.on_exhausted ?? "escalate") {
|
|
1190
|
+
case "abort":
|
|
1191
|
+
abortResult = {
|
|
1192
|
+
workflow_id: workflow.id,
|
|
1193
|
+
status: "error",
|
|
1194
|
+
steps: stepResults.filter(Boolean),
|
|
1195
|
+
total_elapsed_ms: Date.now() - workflowStart,
|
|
1196
|
+
error_message: `Evaluate step "${evaluateStep.task}" exhausted ${evaluateStep.max_iterations} iterations without passing`
|
|
1197
|
+
};
|
|
1198
|
+
break;
|
|
1199
|
+
case "fail_partial":
|
|
1200
|
+
emitStepEvent(options, workflow.id, i, step, result);
|
|
1201
|
+
break;
|
|
1202
|
+
case "escalate":
|
|
1203
|
+
default:
|
|
1204
|
+
abortResult = {
|
|
1205
|
+
workflow_id: workflow.id,
|
|
1206
|
+
status: "escalated",
|
|
1207
|
+
steps: stepResults.filter(Boolean),
|
|
1208
|
+
total_elapsed_ms: Date.now() - workflowStart,
|
|
1209
|
+
escalation_reason: `Evaluate step "${evaluateStep.task}" exhausted ${evaluateStep.max_iterations} iterations without passing`
|
|
1210
|
+
};
|
|
1211
|
+
break;
|
|
1212
|
+
}
|
|
1213
|
+
}
|
|
1214
|
+
continue;
|
|
1215
|
+
}
|
|
1102
1216
|
stepResults[i] = result;
|
|
1103
1217
|
completed.add(i);
|
|
1104
1218
|
emitStepEvent(options, workflow.id, i, step, result);
|
|
@@ -1157,6 +1271,10 @@ async function runWorkflow(adapterOrFactory, workflowIdOrInvocation, optionsOrRe
|
|
|
1157
1271
|
}
|
|
1158
1272
|
return wfResult;
|
|
1159
1273
|
}
|
|
1274
|
+
function mergeVariables(base, injected) {
|
|
1275
|
+
const merged = { ...base, ...injected };
|
|
1276
|
+
return Object.keys(merged).length > 0 ? merged : void 0;
|
|
1277
|
+
}
|
|
1160
1278
|
async function handleGateStep(step, priorResults, options, stepIndex, adapter) {
|
|
1161
1279
|
const start = Date.now();
|
|
1162
1280
|
if (options.onGate) {
|
|
@@ -2545,7 +2663,9 @@ async function dispatchOperation(operationName, op, options, input, ctx, handler
|
|
|
2545
2663
|
|
|
2546
2664
|
// src/lib/project-runtime.ts
|
|
2547
2665
|
import { existsSync as existsSync2 } from "fs";
|
|
2666
|
+
import { readFile as readFile5 } from "fs/promises";
|
|
2548
2667
|
import { resolve as resolve3, dirname as dirname2 } from "path";
|
|
2668
|
+
import YAML3 from "yaml";
|
|
2549
2669
|
var PROJECT_CONFIG_FILENAME = "project.yaml";
|
|
2550
2670
|
var DEFAULT_ADAPTER = "claude";
|
|
2551
2671
|
function findProjectConfig(startDir, filename = PROJECT_CONFIG_FILENAME) {
|
|
@@ -2573,6 +2693,14 @@ async function createProjectRuntime(options) {
|
|
|
2573
2693
|
}
|
|
2574
2694
|
const config = await loadProjectConfig(configPath);
|
|
2575
2695
|
const env = options.env ?? process.env;
|
|
2696
|
+
const rawManifest = YAML3.parse(await readFile5(configPath, "utf8"));
|
|
2697
|
+
const overlayExplicit = typeof rawManifest?.agents === "string" || typeof rawManifest?.dsl === "string";
|
|
2698
|
+
if (overlayExplicit && !existsSync2(config.dslPath)) {
|
|
2699
|
+
throw new Error(
|
|
2700
|
+
`Project agents DSL not found: ${config.dslPath} (referenced by ${configPath}).`
|
|
2701
|
+
);
|
|
2702
|
+
}
|
|
2703
|
+
const projectDslPath = overlayExplicit ? config.dslPath : void 0;
|
|
2576
2704
|
function resolveAdapter2() {
|
|
2577
2705
|
const explicit = options.adapter ?? env.AGENT_RUNTIME_ADAPTER;
|
|
2578
2706
|
if (explicit) {
|
|
@@ -2593,7 +2721,7 @@ async function createProjectRuntime(options) {
|
|
|
2593
2721
|
adapter,
|
|
2594
2722
|
model,
|
|
2595
2723
|
dsl: options.embeddedDsl,
|
|
2596
|
-
projectDslPath
|
|
2724
|
+
projectDslPath,
|
|
2597
2725
|
bindingPaths: config.bindingPaths,
|
|
2598
2726
|
activeGuardrailPolicy: config.active_guardrail_policy,
|
|
2599
2727
|
artifactBinding: config.artifactsPath ? { source: config.artifactsPath } : void 0,
|
|
@@ -2621,7 +2749,7 @@ async function createProjectRuntime(options) {
|
|
|
2621
2749
|
context: { runtime },
|
|
2622
2750
|
config,
|
|
2623
2751
|
configPath,
|
|
2624
|
-
dslSource:
|
|
2752
|
+
dslSource: projectDslPath ?? "/$embedded/",
|
|
2625
2753
|
resolveAdapter: resolveAdapter2
|
|
2626
2754
|
};
|
|
2627
2755
|
}
|