@aaac/runtime 0.1.26 → 0.1.27
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-HGI5VP4G.js} +14 -5
- package/dist/chunk-HGI5VP4G.js.map +1 -0
- package/dist/generator/index.d.ts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +153 -61
- package/dist/index.js.map +1 -1
- package/dist/{task-runner-CVh7Luc_.d.ts → task-runner-DewrtF2g.d.ts} +24 -5
- 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-HGI5VP4G.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");
|
|
@@ -905,6 +949,7 @@ async function runTask(adapter, taskId, context, options) {
|
|
|
905
949
|
taskId,
|
|
906
950
|
agentContract.role_name
|
|
907
951
|
);
|
|
952
|
+
const agentSessionId = options?.parentSpanId ?? taskEnvelope.parent_run_id ?? taskEnvelope.run_id;
|
|
908
953
|
let closeStatus = "error";
|
|
909
954
|
let closeCause;
|
|
910
955
|
let spanClosed = false;
|
|
@@ -954,10 +999,10 @@ async function runTask(adapter, taskId, context, options) {
|
|
|
954
999
|
memoryRef,
|
|
955
1000
|
splitPrompt,
|
|
956
1001
|
agents,
|
|
957
|
-
options: { readonly: isReadonly, onProgress, splitPrompt, agents, allowDynamicWorkflow, libraryTools: options?.libraryTools, observer: options?.observer, parentSpanId: subagentSpanId, maxFollowUps, attempt: 0 }
|
|
1002
|
+
options: { readonly: isReadonly, onProgress, splitPrompt, agents, allowDynamicWorkflow, libraryTools: options?.libraryTools, observer: options?.observer, parentSpanId: subagentSpanId, sessionId: agentSessionId, maxFollowUps, attempt: 0 }
|
|
958
1003
|
});
|
|
959
1004
|
} else {
|
|
960
|
-
fullOutput = await adapter.send(prompt, { readonly: isReadonly, onProgress, splitPrompt, agents, allowDynamicWorkflow, libraryTools: options?.libraryTools, observer: options?.observer, parentSpanId: subagentSpanId });
|
|
1005
|
+
fullOutput = await adapter.send(prompt, { readonly: isReadonly, onProgress, splitPrompt, agents, allowDynamicWorkflow, libraryTools: options?.libraryTools, observer: options?.observer, parentSpanId: subagentSpanId, sessionId: agentSessionId });
|
|
961
1006
|
}
|
|
962
1007
|
} catch (err) {
|
|
963
1008
|
closeStatus = "error";
|
|
@@ -2867,6 +2912,59 @@ Install it with: npm install ${pkg2}`
|
|
|
2867
2912
|
|
|
2868
2913
|
// src/lib/execute.ts
|
|
2869
2914
|
import { resolve as resolve3 } from "path";
|
|
2915
|
+
|
|
2916
|
+
// src/lib/navigation-context.ts
|
|
2917
|
+
async function buildNavigationContext(options) {
|
|
2918
|
+
const diagnostics = [];
|
|
2919
|
+
let dsl;
|
|
2920
|
+
if (options.embeddedDsl != null) {
|
|
2921
|
+
if (options.projectDslPath) {
|
|
2922
|
+
const ctx = await loadDslContext({
|
|
2923
|
+
embeddedDsl: options.embeddedDsl,
|
|
2924
|
+
projectDslPath: options.projectDslPath
|
|
2925
|
+
});
|
|
2926
|
+
dsl = ctx.dsl;
|
|
2927
|
+
} else {
|
|
2928
|
+
dsl = options.embeddedDsl;
|
|
2929
|
+
}
|
|
2930
|
+
} else if (options.projectDslPath) {
|
|
2931
|
+
const { resolve: resolve5 } = await import("agent-contracts");
|
|
2932
|
+
const result = await resolve5(options.projectDslPath);
|
|
2933
|
+
dsl = result.data;
|
|
2934
|
+
} else {
|
|
2935
|
+
throw new Error("buildNavigationContext requires embeddedDsl or projectDslPath");
|
|
2936
|
+
}
|
|
2937
|
+
if (options.artifactBinding) {
|
|
2938
|
+
const { resolveBound } = await import("agent-contracts");
|
|
2939
|
+
const boundResult = await resolveBound(dsl, {
|
|
2940
|
+
artifactBinding: options.artifactBinding,
|
|
2941
|
+
paths: options.paths
|
|
2942
|
+
});
|
|
2943
|
+
dsl = boundResult.data;
|
|
2944
|
+
for (const d of boundResult.diagnostics) {
|
|
2945
|
+
diagnostics.push({
|
|
2946
|
+
path: d.rule,
|
|
2947
|
+
message: d.message,
|
|
2948
|
+
severity: d.severity
|
|
2949
|
+
});
|
|
2950
|
+
}
|
|
2951
|
+
}
|
|
2952
|
+
const { validateSchema, buildNavigationIndex } = await import("agent-contracts");
|
|
2953
|
+
const validation = validateSchema(dsl);
|
|
2954
|
+
for (const d of validation.diagnostics) {
|
|
2955
|
+
diagnostics.push({
|
|
2956
|
+
path: d.path,
|
|
2957
|
+
message: d.message,
|
|
2958
|
+
severity: d.severity ?? "error"
|
|
2959
|
+
});
|
|
2960
|
+
}
|
|
2961
|
+
const navigationIndex = buildNavigationIndex(
|
|
2962
|
+
validation.data ?? dsl
|
|
2963
|
+
);
|
|
2964
|
+
return { dsl, navigationIndex, diagnostics };
|
|
2965
|
+
}
|
|
2966
|
+
|
|
2967
|
+
// src/lib/execute.ts
|
|
2870
2968
|
async function resolveExecutionContext(options, requiredEntities) {
|
|
2871
2969
|
const useBoundResolver = options.resolvedComponent || options.bindingPaths && options.bindingPaths.length > 0 || options.artifactBinding;
|
|
2872
2970
|
if (useBoundResolver) {
|
|
@@ -2924,11 +3022,35 @@ function injectGuardrailHooks(adapterOptions, execCtx, targetAgentId) {
|
|
|
2924
3022
|
adapterOptions.guardrailHooks = createGuardrailHooksFromRules(rules);
|
|
2925
3023
|
}
|
|
2926
3024
|
}
|
|
2927
|
-
function buildAnalyzerToolRegistry() {
|
|
2928
|
-
const bridge = createAnalyzerBridge({
|
|
3025
|
+
function buildAnalyzerToolRegistry(options = {}) {
|
|
3026
|
+
const bridge = createAnalyzerBridge({
|
|
3027
|
+
projectRoot: options.projectRoot ?? process.cwd(),
|
|
3028
|
+
navigationIndex: options.navigationIndex,
|
|
3029
|
+
artifactPatterns: options.artifactPatterns
|
|
3030
|
+
});
|
|
2929
3031
|
const tools = bridge.buildAnalyzerTools();
|
|
2930
3032
|
return createRegistryFromSdkTools(tools);
|
|
2931
3033
|
}
|
|
3034
|
+
function deriveArtifactPatterns(navigationIndex) {
|
|
3035
|
+
const patterns = /* @__PURE__ */ new Map();
|
|
3036
|
+
const artifacts = navigationIndex?.artifacts;
|
|
3037
|
+
if (!artifacts) return patterns;
|
|
3038
|
+
for (const [id, node] of Object.entries(artifacts)) {
|
|
3039
|
+
const pp = node?.files?.path_patterns;
|
|
3040
|
+
if (Array.isArray(pp) && pp.length > 0) {
|
|
3041
|
+
patterns.set(id, pp);
|
|
3042
|
+
}
|
|
3043
|
+
}
|
|
3044
|
+
return patterns;
|
|
3045
|
+
}
|
|
3046
|
+
async function buildNavigationContextSafely(execCtx) {
|
|
3047
|
+
if (!execCtx.dsl) return void 0;
|
|
3048
|
+
try {
|
|
3049
|
+
return await buildNavigationContext({ embeddedDsl: execCtx.dsl });
|
|
3050
|
+
} catch {
|
|
3051
|
+
return void 0;
|
|
3052
|
+
}
|
|
3053
|
+
}
|
|
2932
3054
|
async function executeTask(taskId, options) {
|
|
2933
3055
|
const execCtx = await resolveExecutionContext(options, { tasks: [taskId] });
|
|
2934
3056
|
const targetAgentId = execCtx.registries.taskRegistry?.[taskId]?.target_agent;
|
|
@@ -2941,12 +3063,20 @@ async function executeTask(taskId, options) {
|
|
|
2941
3063
|
const progressSink = createProgressSink(
|
|
2942
3064
|
options.logFile ? { stderr: true, file: resolve3(options.logFile), naming: "single" } : { stderr: true }
|
|
2943
3065
|
);
|
|
2944
|
-
const
|
|
3066
|
+
const navContext = await buildNavigationContextSafely(execCtx);
|
|
3067
|
+
const analyzerTools = buildAnalyzerToolRegistry({
|
|
3068
|
+
navigationIndex: navContext?.navigationIndex,
|
|
3069
|
+
artifactPatterns: deriveArtifactPatterns(navContext?.navigationIndex)
|
|
3070
|
+
});
|
|
3071
|
+
const taskContext = { user_request: options.request };
|
|
3072
|
+
if (navContext?.navigationIndex) {
|
|
3073
|
+
taskContext.variables = { navigationIndex: navContext.navigationIndex };
|
|
3074
|
+
}
|
|
2945
3075
|
try {
|
|
2946
3076
|
if (options.hooks?.beforeTask) {
|
|
2947
3077
|
await options.hooks.beforeTask({ adapter, registries: execCtx.registries, taskId });
|
|
2948
3078
|
}
|
|
2949
|
-
const result = await runTask(adapter, taskId,
|
|
3079
|
+
const result = await runTask(adapter, taskId, taskContext, {
|
|
2950
3080
|
maxFollowUps: options.maxFollowUps ?? 2,
|
|
2951
3081
|
maxRetries: options.maxRetries ?? 0,
|
|
2952
3082
|
progressOutput: progressSink,
|
|
@@ -2973,7 +3103,18 @@ async function executeWorkflow(workflowId, options) {
|
|
|
2973
3103
|
const progressSink = createProgressSink(
|
|
2974
3104
|
options.logFile ? { stderr: true, file: resolve3(options.logFile), naming: "single" } : { stderr: true }
|
|
2975
3105
|
);
|
|
2976
|
-
const
|
|
3106
|
+
const navContext = await buildNavigationContextSafely(execCtx);
|
|
3107
|
+
const analyzerTools = buildAnalyzerToolRegistry({
|
|
3108
|
+
navigationIndex: navContext?.navigationIndex,
|
|
3109
|
+
artifactPatterns: deriveArtifactPatterns(navContext?.navigationIndex)
|
|
3110
|
+
});
|
|
3111
|
+
const workflowContext = navContext?.navigationIndex ? {
|
|
3112
|
+
...options.context,
|
|
3113
|
+
variables: {
|
|
3114
|
+
...options.context?.variables,
|
|
3115
|
+
navigationIndex: navContext.navigationIndex
|
|
3116
|
+
}
|
|
3117
|
+
} : options.context;
|
|
2977
3118
|
try {
|
|
2978
3119
|
if (options.hooks?.beforeWorkflow) {
|
|
2979
3120
|
await options.hooks.beforeWorkflow({ adapter, registries: execCtx.registries, workflowId });
|
|
@@ -2995,7 +3136,7 @@ async function executeWorkflow(workflowId, options) {
|
|
|
2995
3136
|
onGate: options.hooks?.onGate ?? (options.autoApproveGates ? async () => true : void 0),
|
|
2996
3137
|
onOptionalStep: options.hooks?.onOptionalStep
|
|
2997
3138
|
},
|
|
2998
|
-
context:
|
|
3139
|
+
context: workflowContext
|
|
2999
3140
|
};
|
|
3000
3141
|
const result = await runWorkflow(adapter, invocation, execCtx.registries);
|
|
3001
3142
|
if (options.hooks?.afterWorkflow) {
|
|
@@ -3340,57 +3481,6 @@ function createComponentScope(componentIR, binding, options) {
|
|
|
3340
3481
|
};
|
|
3341
3482
|
}
|
|
3342
3483
|
|
|
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
3484
|
// src/lib/artifact-resolver.ts
|
|
3395
3485
|
async function resolveArtifacts(options) {
|
|
3396
3486
|
if (!options.artifactBinding) {
|
|
@@ -3749,6 +3839,7 @@ export {
|
|
|
3749
3839
|
guardrailContextToRuleData,
|
|
3750
3840
|
hasBlockingViolation,
|
|
3751
3841
|
isContextPack,
|
|
3842
|
+
isNavigationIndex,
|
|
3752
3843
|
jsonSchemaToZod,
|
|
3753
3844
|
listGuardrails,
|
|
3754
3845
|
loadDslContext,
|
|
@@ -3761,6 +3852,7 @@ export {
|
|
|
3761
3852
|
pluginRegistry,
|
|
3762
3853
|
renderAgentSystemPrompt,
|
|
3763
3854
|
renderContextPackPrompt,
|
|
3855
|
+
renderNavigationIndexPrompt,
|
|
3764
3856
|
resolveArtifacts,
|
|
3765
3857
|
runTask,
|
|
3766
3858
|
runToolchainChecks,
|