@aaac/runtime 0.1.26 → 0.1.28
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/adk-sdk.js +9 -9
- package/dist/adapters/adk-sdk.js.map +1 -1
- package/dist/adapters/claude-agent-sdk.d.ts +1 -1
- package/dist/adapters/claude-agent-sdk.js +8 -8
- package/dist/adapters/claude-agent-sdk.js.map +1 -1
- package/dist/adapters/mock.d.ts +1 -1
- package/dist/adapters/openai-agents-sdk.d.ts +1 -1
- package/dist/adapters/openai-agents-sdk.js +10 -10
- package/dist/adapters/openai-agents-sdk.js.map +1 -1
- package/dist/{chunk-LWMRO7RR.js → chunk-S7JQJAZS.js} +16 -7
- package/dist/chunk-S7JQJAZS.js.map +1 -0
- package/dist/generator/index.d.ts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +159 -63
- package/dist/index.js.map +1 -1
- package/dist/{task-runner-CVh7Luc_.d.ts → task-runner-D_hvuTLM.d.ts} +38 -7
- package/package.json +1 -1
- package/dist/chunk-LWMRO7RR.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
emitToolExecOpen,
|
|
27
27
|
emitToolchainClose,
|
|
28
28
|
emitToolchainOpen
|
|
29
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-S7JQJAZS.js";
|
|
30
30
|
import {
|
|
31
31
|
buildGuardrailContext,
|
|
32
32
|
loadProjectConfig
|
|
@@ -578,6 +578,46 @@ function renderYamlObject(schema, indent, maxDepth) {
|
|
|
578
578
|
}
|
|
579
579
|
return lines.join("\n");
|
|
580
580
|
}
|
|
581
|
+
function isNavigationIndex(value) {
|
|
582
|
+
if (typeof value !== "object" || value === null) return false;
|
|
583
|
+
const obj = value;
|
|
584
|
+
return typeof obj.system === "object" && obj.system !== null && typeof obj.artifacts === "object" && obj.artifacts !== null;
|
|
585
|
+
}
|
|
586
|
+
function renderNavigationIndexPrompt(navigationIndex) {
|
|
587
|
+
const system = navigationIndex.system;
|
|
588
|
+
const artifacts = navigationIndex.artifacts ?? {};
|
|
589
|
+
const ids = Object.keys(artifacts);
|
|
590
|
+
const sections = ["## Project Navigation Index"];
|
|
591
|
+
const systemLabel = system?.name ? `${system.name}${system.id ? ` (${system.id})` : ""}` : system?.id ?? "unknown";
|
|
592
|
+
sections.push(
|
|
593
|
+
`System: ${systemLabel}
|
|
594
|
+
Artifacts: ${ids.length}`
|
|
595
|
+
);
|
|
596
|
+
if (ids.length > 0) {
|
|
597
|
+
const lines = [];
|
|
598
|
+
for (const id of ids) {
|
|
599
|
+
const node = artifacts[id] ?? {};
|
|
600
|
+
const props = node.properties ?? {};
|
|
601
|
+
const tags = [props.type, props.authority].filter((v) => typeof v === "string" && v.length > 0).join(", ");
|
|
602
|
+
const editPolicy = typeof props.manual_edit === "string" ? `, edit:${props.manual_edit}` : "";
|
|
603
|
+
lines.push(`- ${id}${tags || editPolicy ? ` [${tags}${editPolicy}]` : ""}`);
|
|
604
|
+
const patterns = node.files?.path_patterns;
|
|
605
|
+
if (Array.isArray(patterns) && patterns.length > 0) {
|
|
606
|
+
lines.push(` files: ${patterns.join(", ")}`);
|
|
607
|
+
}
|
|
608
|
+
const derived = node.relations?.derived_artifacts;
|
|
609
|
+
if (Array.isArray(derived) && derived.length > 0) {
|
|
610
|
+
lines.push(` derived \u2192 ${derived.join(", ")}`);
|
|
611
|
+
}
|
|
612
|
+
const owners = node.agents?.owners;
|
|
613
|
+
if (Array.isArray(owners) && owners.length > 0) {
|
|
614
|
+
lines.push(` owners: ${owners.join(", ")}`);
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
sections.push(lines.join("\n"));
|
|
618
|
+
}
|
|
619
|
+
return sections.join("\n\n");
|
|
620
|
+
}
|
|
581
621
|
function buildSplitTaskPrompt(agent, task, context, options) {
|
|
582
622
|
const system = [];
|
|
583
623
|
system.push(renderAgentSystemPrompt(agent));
|
|
@@ -669,8 +709,12 @@ ${context.acceptance_criteria.map((c) => `- ${c}`).join("\n")}`
|
|
|
669
709
|
if (isContextPack(contextPack)) {
|
|
670
710
|
userSections.push(renderContextPackPrompt(contextPack));
|
|
671
711
|
}
|
|
712
|
+
const navigationIndex = context.variables.navigationIndex;
|
|
713
|
+
if (isNavigationIndex(navigationIndex)) {
|
|
714
|
+
userSections.push(renderNavigationIndexPrompt(navigationIndex));
|
|
715
|
+
}
|
|
672
716
|
const otherVars = Object.entries(context.variables).filter(
|
|
673
|
-
([k]) => k !== "analyzerContextPack"
|
|
717
|
+
([k]) => k !== "analyzerContextPack" && k !== "navigationIndex"
|
|
674
718
|
);
|
|
675
719
|
if (otherVars.length > 0) {
|
|
676
720
|
const varLines = otherVars.map(([k, v]) => `- ${k}: ${typeof v === "string" ? v : JSON.stringify(v)}`).join("\n");
|
|
@@ -898,12 +942,14 @@ async function runTask(adapter, taskId, context, options) {
|
|
|
898
942
|
memoryRef = void 0;
|
|
899
943
|
}
|
|
900
944
|
const taskExecStart = Date.now();
|
|
945
|
+
const effectiveSessionId = options?.sessionId ?? options?.parentSpanId ?? taskEnvelope.run_id;
|
|
901
946
|
const subagentSpanId = emitSubagentOpen(
|
|
902
947
|
options?.observer,
|
|
903
948
|
taskEnvelope,
|
|
904
949
|
options?.parentSpanId,
|
|
905
950
|
taskId,
|
|
906
|
-
agentContract.role_name
|
|
951
|
+
agentContract.role_name,
|
|
952
|
+
effectiveSessionId
|
|
907
953
|
);
|
|
908
954
|
let closeStatus = "error";
|
|
909
955
|
let closeCause;
|
|
@@ -933,7 +979,8 @@ async function runTask(adapter, taskId, context, options) {
|
|
|
933
979
|
durationMs,
|
|
934
980
|
closeStatus,
|
|
935
981
|
agentContract.role_name,
|
|
936
|
-
closeCause
|
|
982
|
+
closeCause,
|
|
983
|
+
effectiveSessionId
|
|
937
984
|
);
|
|
938
985
|
};
|
|
939
986
|
try {
|
|
@@ -954,10 +1001,10 @@ async function runTask(adapter, taskId, context, options) {
|
|
|
954
1001
|
memoryRef,
|
|
955
1002
|
splitPrompt,
|
|
956
1003
|
agents,
|
|
957
|
-
options: { readonly: isReadonly, onProgress, splitPrompt, agents, allowDynamicWorkflow, libraryTools: options?.libraryTools, observer: options?.observer, parentSpanId: subagentSpanId, maxFollowUps, attempt: 0 }
|
|
1004
|
+
options: { readonly: isReadonly, onProgress, splitPrompt, agents, allowDynamicWorkflow, libraryTools: options?.libraryTools, observer: options?.observer, parentSpanId: subagentSpanId, sessionId: effectiveSessionId, maxFollowUps, attempt: 0 }
|
|
958
1005
|
});
|
|
959
1006
|
} else {
|
|
960
|
-
fullOutput = await adapter.send(prompt, { readonly: isReadonly, onProgress, splitPrompt, agents, allowDynamicWorkflow, libraryTools: options?.libraryTools, observer: options?.observer, parentSpanId: subagentSpanId });
|
|
1007
|
+
fullOutput = await adapter.send(prompt, { readonly: isReadonly, onProgress, splitPrompt, agents, allowDynamicWorkflow, libraryTools: options?.libraryTools, observer: options?.observer, parentSpanId: subagentSpanId, sessionId: effectiveSessionId });
|
|
961
1008
|
}
|
|
962
1009
|
} catch (err) {
|
|
963
1010
|
closeStatus = "error";
|
|
@@ -1367,6 +1414,7 @@ async function runWorkflow(adapterOrFactory, workflowIdOrInvocation, optionsOrRe
|
|
|
1367
1414
|
progressOutput: options.progressOutput,
|
|
1368
1415
|
observer: options.observer,
|
|
1369
1416
|
parentSpanId: iterationSpanId ?? sessionSpanId,
|
|
1417
|
+
sessionId: sessionSpanId ?? sessionEnvelope.run_id,
|
|
1370
1418
|
libraryTools: options.libraryTools
|
|
1371
1419
|
});
|
|
1372
1420
|
return {
|
|
@@ -1429,6 +1477,7 @@ async function runWorkflow(adapterOrFactory, workflowIdOrInvocation, optionsOrRe
|
|
|
1429
1477
|
progressOutput: options.progressOutput,
|
|
1430
1478
|
observer: options.observer,
|
|
1431
1479
|
parentSpanId: sessionSpanId,
|
|
1480
|
+
sessionId: sessionSpanId ?? sessionEnvelope.run_id,
|
|
1432
1481
|
libraryTools: options.libraryTools
|
|
1433
1482
|
});
|
|
1434
1483
|
return {
|
|
@@ -2867,6 +2916,59 @@ Install it with: npm install ${pkg2}`
|
|
|
2867
2916
|
|
|
2868
2917
|
// src/lib/execute.ts
|
|
2869
2918
|
import { resolve as resolve3 } from "path";
|
|
2919
|
+
|
|
2920
|
+
// src/lib/navigation-context.ts
|
|
2921
|
+
async function buildNavigationContext(options) {
|
|
2922
|
+
const diagnostics = [];
|
|
2923
|
+
let dsl;
|
|
2924
|
+
if (options.embeddedDsl != null) {
|
|
2925
|
+
if (options.projectDslPath) {
|
|
2926
|
+
const ctx = await loadDslContext({
|
|
2927
|
+
embeddedDsl: options.embeddedDsl,
|
|
2928
|
+
projectDslPath: options.projectDslPath
|
|
2929
|
+
});
|
|
2930
|
+
dsl = ctx.dsl;
|
|
2931
|
+
} else {
|
|
2932
|
+
dsl = options.embeddedDsl;
|
|
2933
|
+
}
|
|
2934
|
+
} else if (options.projectDslPath) {
|
|
2935
|
+
const { resolve: resolve5 } = await import("agent-contracts");
|
|
2936
|
+
const result = await resolve5(options.projectDslPath);
|
|
2937
|
+
dsl = result.data;
|
|
2938
|
+
} else {
|
|
2939
|
+
throw new Error("buildNavigationContext requires embeddedDsl or projectDslPath");
|
|
2940
|
+
}
|
|
2941
|
+
if (options.artifactBinding) {
|
|
2942
|
+
const { resolveBound } = await import("agent-contracts");
|
|
2943
|
+
const boundResult = await resolveBound(dsl, {
|
|
2944
|
+
artifactBinding: options.artifactBinding,
|
|
2945
|
+
paths: options.paths
|
|
2946
|
+
});
|
|
2947
|
+
dsl = boundResult.data;
|
|
2948
|
+
for (const d of boundResult.diagnostics) {
|
|
2949
|
+
diagnostics.push({
|
|
2950
|
+
path: d.rule,
|
|
2951
|
+
message: d.message,
|
|
2952
|
+
severity: d.severity
|
|
2953
|
+
});
|
|
2954
|
+
}
|
|
2955
|
+
}
|
|
2956
|
+
const { validateSchema, buildNavigationIndex } = await import("agent-contracts");
|
|
2957
|
+
const validation = validateSchema(dsl);
|
|
2958
|
+
for (const d of validation.diagnostics) {
|
|
2959
|
+
diagnostics.push({
|
|
2960
|
+
path: d.path,
|
|
2961
|
+
message: d.message,
|
|
2962
|
+
severity: d.severity ?? "error"
|
|
2963
|
+
});
|
|
2964
|
+
}
|
|
2965
|
+
const navigationIndex = buildNavigationIndex(
|
|
2966
|
+
validation.data ?? dsl
|
|
2967
|
+
);
|
|
2968
|
+
return { dsl, navigationIndex, diagnostics };
|
|
2969
|
+
}
|
|
2970
|
+
|
|
2971
|
+
// src/lib/execute.ts
|
|
2870
2972
|
async function resolveExecutionContext(options, requiredEntities) {
|
|
2871
2973
|
const useBoundResolver = options.resolvedComponent || options.bindingPaths && options.bindingPaths.length > 0 || options.artifactBinding;
|
|
2872
2974
|
if (useBoundResolver) {
|
|
@@ -2924,11 +3026,35 @@ function injectGuardrailHooks(adapterOptions, execCtx, targetAgentId) {
|
|
|
2924
3026
|
adapterOptions.guardrailHooks = createGuardrailHooksFromRules(rules);
|
|
2925
3027
|
}
|
|
2926
3028
|
}
|
|
2927
|
-
function buildAnalyzerToolRegistry() {
|
|
2928
|
-
const bridge = createAnalyzerBridge({
|
|
3029
|
+
function buildAnalyzerToolRegistry(options = {}) {
|
|
3030
|
+
const bridge = createAnalyzerBridge({
|
|
3031
|
+
projectRoot: options.projectRoot ?? process.cwd(),
|
|
3032
|
+
navigationIndex: options.navigationIndex,
|
|
3033
|
+
artifactPatterns: options.artifactPatterns
|
|
3034
|
+
});
|
|
2929
3035
|
const tools = bridge.buildAnalyzerTools();
|
|
2930
3036
|
return createRegistryFromSdkTools(tools);
|
|
2931
3037
|
}
|
|
3038
|
+
function deriveArtifactPatterns(navigationIndex) {
|
|
3039
|
+
const patterns = /* @__PURE__ */ new Map();
|
|
3040
|
+
const artifacts = navigationIndex?.artifacts;
|
|
3041
|
+
if (!artifacts) return patterns;
|
|
3042
|
+
for (const [id, node] of Object.entries(artifacts)) {
|
|
3043
|
+
const pp = node?.files?.path_patterns;
|
|
3044
|
+
if (Array.isArray(pp) && pp.length > 0) {
|
|
3045
|
+
patterns.set(id, pp);
|
|
3046
|
+
}
|
|
3047
|
+
}
|
|
3048
|
+
return patterns;
|
|
3049
|
+
}
|
|
3050
|
+
async function buildNavigationContextSafely(execCtx) {
|
|
3051
|
+
if (!execCtx.dsl) return void 0;
|
|
3052
|
+
try {
|
|
3053
|
+
return await buildNavigationContext({ embeddedDsl: execCtx.dsl });
|
|
3054
|
+
} catch {
|
|
3055
|
+
return void 0;
|
|
3056
|
+
}
|
|
3057
|
+
}
|
|
2932
3058
|
async function executeTask(taskId, options) {
|
|
2933
3059
|
const execCtx = await resolveExecutionContext(options, { tasks: [taskId] });
|
|
2934
3060
|
const targetAgentId = execCtx.registries.taskRegistry?.[taskId]?.target_agent;
|
|
@@ -2941,12 +3067,20 @@ async function executeTask(taskId, options) {
|
|
|
2941
3067
|
const progressSink = createProgressSink(
|
|
2942
3068
|
options.logFile ? { stderr: true, file: resolve3(options.logFile), naming: "single" } : { stderr: true }
|
|
2943
3069
|
);
|
|
2944
|
-
const
|
|
3070
|
+
const navContext = await buildNavigationContextSafely(execCtx);
|
|
3071
|
+
const analyzerTools = buildAnalyzerToolRegistry({
|
|
3072
|
+
navigationIndex: navContext?.navigationIndex,
|
|
3073
|
+
artifactPatterns: deriveArtifactPatterns(navContext?.navigationIndex)
|
|
3074
|
+
});
|
|
3075
|
+
const taskContext = { user_request: options.request };
|
|
3076
|
+
if (navContext?.navigationIndex) {
|
|
3077
|
+
taskContext.variables = { navigationIndex: navContext.navigationIndex };
|
|
3078
|
+
}
|
|
2945
3079
|
try {
|
|
2946
3080
|
if (options.hooks?.beforeTask) {
|
|
2947
3081
|
await options.hooks.beforeTask({ adapter, registries: execCtx.registries, taskId });
|
|
2948
3082
|
}
|
|
2949
|
-
const result = await runTask(adapter, taskId,
|
|
3083
|
+
const result = await runTask(adapter, taskId, taskContext, {
|
|
2950
3084
|
maxFollowUps: options.maxFollowUps ?? 2,
|
|
2951
3085
|
maxRetries: options.maxRetries ?? 0,
|
|
2952
3086
|
progressOutput: progressSink,
|
|
@@ -2973,7 +3107,18 @@ async function executeWorkflow(workflowId, options) {
|
|
|
2973
3107
|
const progressSink = createProgressSink(
|
|
2974
3108
|
options.logFile ? { stderr: true, file: resolve3(options.logFile), naming: "single" } : { stderr: true }
|
|
2975
3109
|
);
|
|
2976
|
-
const
|
|
3110
|
+
const navContext = await buildNavigationContextSafely(execCtx);
|
|
3111
|
+
const analyzerTools = buildAnalyzerToolRegistry({
|
|
3112
|
+
navigationIndex: navContext?.navigationIndex,
|
|
3113
|
+
artifactPatterns: deriveArtifactPatterns(navContext?.navigationIndex)
|
|
3114
|
+
});
|
|
3115
|
+
const workflowContext = navContext?.navigationIndex ? {
|
|
3116
|
+
...options.context,
|
|
3117
|
+
variables: {
|
|
3118
|
+
...options.context?.variables,
|
|
3119
|
+
navigationIndex: navContext.navigationIndex
|
|
3120
|
+
}
|
|
3121
|
+
} : options.context;
|
|
2977
3122
|
try {
|
|
2978
3123
|
if (options.hooks?.beforeWorkflow) {
|
|
2979
3124
|
await options.hooks.beforeWorkflow({ adapter, registries: execCtx.registries, workflowId });
|
|
@@ -2995,7 +3140,7 @@ async function executeWorkflow(workflowId, options) {
|
|
|
2995
3140
|
onGate: options.hooks?.onGate ?? (options.autoApproveGates ? async () => true : void 0),
|
|
2996
3141
|
onOptionalStep: options.hooks?.onOptionalStep
|
|
2997
3142
|
},
|
|
2998
|
-
context:
|
|
3143
|
+
context: workflowContext
|
|
2999
3144
|
};
|
|
3000
3145
|
const result = await runWorkflow(adapter, invocation, execCtx.registries);
|
|
3001
3146
|
if (options.hooks?.afterWorkflow) {
|
|
@@ -3340,57 +3485,6 @@ function createComponentScope(componentIR, binding, options) {
|
|
|
3340
3485
|
};
|
|
3341
3486
|
}
|
|
3342
3487
|
|
|
3343
|
-
// src/lib/navigation-context.ts
|
|
3344
|
-
async function buildNavigationContext(options) {
|
|
3345
|
-
const diagnostics = [];
|
|
3346
|
-
let dsl;
|
|
3347
|
-
if (options.embeddedDsl != null) {
|
|
3348
|
-
if (options.projectDslPath) {
|
|
3349
|
-
const ctx = await loadDslContext({
|
|
3350
|
-
embeddedDsl: options.embeddedDsl,
|
|
3351
|
-
projectDslPath: options.projectDslPath
|
|
3352
|
-
});
|
|
3353
|
-
dsl = ctx.dsl;
|
|
3354
|
-
} else {
|
|
3355
|
-
dsl = options.embeddedDsl;
|
|
3356
|
-
}
|
|
3357
|
-
} else if (options.projectDslPath) {
|
|
3358
|
-
const { resolve: resolve5 } = await import("agent-contracts");
|
|
3359
|
-
const result = await resolve5(options.projectDslPath);
|
|
3360
|
-
dsl = result.data;
|
|
3361
|
-
} else {
|
|
3362
|
-
throw new Error("buildNavigationContext requires embeddedDsl or projectDslPath");
|
|
3363
|
-
}
|
|
3364
|
-
if (options.artifactBinding) {
|
|
3365
|
-
const { resolveBound } = await import("agent-contracts");
|
|
3366
|
-
const boundResult = await resolveBound(dsl, {
|
|
3367
|
-
artifactBinding: options.artifactBinding,
|
|
3368
|
-
paths: options.paths
|
|
3369
|
-
});
|
|
3370
|
-
dsl = boundResult.data;
|
|
3371
|
-
for (const d of boundResult.diagnostics) {
|
|
3372
|
-
diagnostics.push({
|
|
3373
|
-
path: d.rule,
|
|
3374
|
-
message: d.message,
|
|
3375
|
-
severity: d.severity
|
|
3376
|
-
});
|
|
3377
|
-
}
|
|
3378
|
-
}
|
|
3379
|
-
const { validateSchema, buildNavigationIndex } = await import("agent-contracts");
|
|
3380
|
-
const validation = validateSchema(dsl);
|
|
3381
|
-
for (const d of validation.diagnostics) {
|
|
3382
|
-
diagnostics.push({
|
|
3383
|
-
path: d.path,
|
|
3384
|
-
message: d.message,
|
|
3385
|
-
severity: d.severity ?? "error"
|
|
3386
|
-
});
|
|
3387
|
-
}
|
|
3388
|
-
const navigationIndex = buildNavigationIndex(
|
|
3389
|
-
validation.data ?? dsl
|
|
3390
|
-
);
|
|
3391
|
-
return { dsl, navigationIndex, diagnostics };
|
|
3392
|
-
}
|
|
3393
|
-
|
|
3394
3488
|
// src/lib/artifact-resolver.ts
|
|
3395
3489
|
async function resolveArtifacts(options) {
|
|
3396
3490
|
if (!options.artifactBinding) {
|
|
@@ -3749,6 +3843,7 @@ export {
|
|
|
3749
3843
|
guardrailContextToRuleData,
|
|
3750
3844
|
hasBlockingViolation,
|
|
3751
3845
|
isContextPack,
|
|
3846
|
+
isNavigationIndex,
|
|
3752
3847
|
jsonSchemaToZod,
|
|
3753
3848
|
listGuardrails,
|
|
3754
3849
|
loadDslContext,
|
|
@@ -3761,6 +3856,7 @@ export {
|
|
|
3761
3856
|
pluginRegistry,
|
|
3762
3857
|
renderAgentSystemPrompt,
|
|
3763
3858
|
renderContextPackPrompt,
|
|
3859
|
+
renderNavigationIndexPrompt,
|
|
3764
3860
|
resolveArtifacts,
|
|
3765
3861
|
runTask,
|
|
3766
3862
|
runToolchainChecks,
|