@aaac/runtime 0.2.7 → 0.2.8
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/{chunk-DEBCJKRX.js → chunk-CPSXQCNA.js} +2 -1
- package/dist/{chunk-DEBCJKRX.js.map → chunk-CPSXQCNA.js.map} +1 -1
- package/dist/claude-bundles/full.js +372 -370
- package/dist/index.d.ts +2 -0
- package/dist/index.js +51 -37
- package/dist/index.js.map +1 -1
- package/dist/lib/claude-native/index.js +1 -1
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -285,6 +285,8 @@ interface GateStep {
|
|
|
285
285
|
readonly type: "gate";
|
|
286
286
|
readonly gate_kind: string;
|
|
287
287
|
readonly description: string;
|
|
288
|
+
/** Class of the agent that evaluates the gate; a gate has no task to take it from. */
|
|
289
|
+
readonly model_class?: ModelClass;
|
|
288
290
|
readonly depends_on?: readonly string[];
|
|
289
291
|
}
|
|
290
292
|
/**
|
package/dist/index.js
CHANGED
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
resolveGuardrailContext,
|
|
15
15
|
resolveNavigationDsl,
|
|
16
16
|
resolveNavigationSources
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-CPSXQCNA.js";
|
|
18
18
|
import {
|
|
19
19
|
jsonSchemaToZod
|
|
20
20
|
} from "./chunk-ET6TGQRT.js";
|
|
@@ -7702,7 +7702,7 @@ async function runWorkflow(adapterOrFactory, workflowIdOrInvocation, optionsOrRe
|
|
|
7702
7702
|
const batchResults = await Promise.all(ready.map(async (i) => {
|
|
7703
7703
|
const step = workflow.steps[i];
|
|
7704
7704
|
const stepTask = step.type === "delegate" || step.type === "evaluate" ? registries?.taskRegistry?.[step.task] : void 0;
|
|
7705
|
-
const modelClass = stepTask?.model_class;
|
|
7705
|
+
const modelClass = step.type === "gate" ? step.model_class : stepTask?.model_class;
|
|
7706
7706
|
const stepAgentId = options.perAgentAdapters ? stepTask?.target_agent : void 0;
|
|
7707
7707
|
let stepAdapter;
|
|
7708
7708
|
if (adapterFactory && (ready.length > 1 || modelClass || stepAgentId)) {
|
|
@@ -9510,11 +9510,7 @@ function mergeSourceFiles(rendered, conflict) {
|
|
|
9510
9510
|
|
|
9511
9511
|
// src/lib/claude-materialize/workflow-render.ts
|
|
9512
9512
|
var GENERATED_MARKER = "// Auto-generated by @aaac/runtime claude-materialize (#235). Do not edit; run `claude sync` instead.";
|
|
9513
|
-
var
|
|
9514
|
-
fast: { model: "haiku" },
|
|
9515
|
-
standard: { model: "sonnet" },
|
|
9516
|
-
thinking: { model: "opus", effort: "high" }
|
|
9517
|
-
};
|
|
9513
|
+
var CLAUDE_CODE_ADAPTER = "claude";
|
|
9518
9514
|
var WorkflowCodegenError = class extends Error {
|
|
9519
9515
|
constructor(message) {
|
|
9520
9516
|
super(message);
|
|
@@ -9625,7 +9621,7 @@ function toTaskContract(id, raw) {
|
|
|
9625
9621
|
model_class: raw.model_class
|
|
9626
9622
|
};
|
|
9627
9623
|
}
|
|
9628
|
-
function buildRegistries(dsl) {
|
|
9624
|
+
function buildRegistries(dsl, modelMapping) {
|
|
9629
9625
|
const rawTasks = dsl.tasks ?? {};
|
|
9630
9626
|
const agents = buildAgentRegistry(dsl);
|
|
9631
9627
|
const tasks = {};
|
|
@@ -9636,7 +9632,17 @@ function buildRegistries(dsl) {
|
|
|
9636
9632
|
agents,
|
|
9637
9633
|
tasks,
|
|
9638
9634
|
handoffTypes: dsl.handoff_types ?? {},
|
|
9639
|
-
components
|
|
9635
|
+
components,
|
|
9636
|
+
// The runtime's resolver, so a class resolves to the model it runs on when
|
|
9637
|
+
// the runtime executes the same step. No environment: `AGENT_RUNTIME_MODEL*`
|
|
9638
|
+
// override a run, and a committed artifact that depended on the generating
|
|
9639
|
+
// shell would differ between machines. The harness is the fallback adapter,
|
|
9640
|
+
// so a class `model_mapping` does not route resolves to the harness default.
|
|
9641
|
+
models: createModelResolver({
|
|
9642
|
+
modelMapping,
|
|
9643
|
+
fallbackAdapter: CLAUDE_CODE_ADAPTER,
|
|
9644
|
+
env: {}
|
|
9645
|
+
})
|
|
9640
9646
|
};
|
|
9641
9647
|
}
|
|
9642
9648
|
function phaseTitle(step) {
|
|
@@ -9661,16 +9667,22 @@ function buildMeta(id, wf, steps) {
|
|
|
9661
9667
|
if (phases.length > 0) meta.phases = phases;
|
|
9662
9668
|
return meta;
|
|
9663
9669
|
}
|
|
9664
|
-
function
|
|
9670
|
+
function modelOpt(modelClass, reg, owner) {
|
|
9671
|
+
if (!modelClass) return {};
|
|
9672
|
+
const resolved = reg.models.resolve(modelClass);
|
|
9673
|
+
if (resolved.adapter !== CLAUDE_CODE_ADAPTER) {
|
|
9674
|
+
throw new WorkflowCodegenError(
|
|
9675
|
+
`${owner} has model_class "${modelClass}", which project.yaml model_mapping.${modelClass} routes to adapter "${resolved.adapter}"; a Claude Code workflow runs on the "${CLAUDE_CODE_ADAPTER}" adapter only`
|
|
9676
|
+
);
|
|
9677
|
+
}
|
|
9678
|
+
return resolved.model ? { model: resolved.model } : {};
|
|
9679
|
+
}
|
|
9680
|
+
function agentOpts(task, step, reg, handoffSchema, indent) {
|
|
9665
9681
|
const opts = {};
|
|
9666
9682
|
if (handoffSchema) opts.schema = handoffSchema;
|
|
9667
9683
|
opts.label = task.id;
|
|
9668
9684
|
opts.phase = phaseTitle(step);
|
|
9669
|
-
|
|
9670
|
-
if (mc) {
|
|
9671
|
-
opts.model = mc.model;
|
|
9672
|
-
if (mc.effort) opts.effort = mc.effort;
|
|
9673
|
-
}
|
|
9685
|
+
Object.assign(opts, modelOpt(task.model_class, reg, `task "${task.id}"`));
|
|
9674
9686
|
return jsLiteral(opts, indent);
|
|
9675
9687
|
}
|
|
9676
9688
|
function resultVar(i) {
|
|
@@ -9752,10 +9764,10 @@ function emitDelegateExpr(step, reg, i, steps, deps, indent, feedback) {
|
|
|
9752
9764
|
const prompt = renderDelegatePrompt(agent, task, step);
|
|
9753
9765
|
const schema = resolveHandoffSchema(task, reg.handoffTypes, reg.components);
|
|
9754
9766
|
const promptExpr = withPriorContext(jsLiteral(prompt), priorContextExpr(i, steps, deps), feedback);
|
|
9755
|
-
const opts = agentOpts(task, step, schema, indent);
|
|
9767
|
+
const opts = agentOpts(task, step, reg, schema, indent);
|
|
9756
9768
|
return `agent(${promptExpr}, ${opts})`;
|
|
9757
9769
|
}
|
|
9758
|
-
function emitGateStatements(step, i, steps, deps, pad, feedback) {
|
|
9770
|
+
function emitGateStatements(step, reg, i, steps, deps, pad, feedback) {
|
|
9759
9771
|
const gateStep = {
|
|
9760
9772
|
type: "gate",
|
|
9761
9773
|
gate_kind: step.gate_kind ?? "",
|
|
@@ -9777,6 +9789,7 @@ function emitGateStatements(step, i, steps, deps, pad, feedback) {
|
|
|
9777
9789
|
promptExpr = `${promptExpr} + (${feedback.feedbackVar} !== undefined ? ${varSection} : '')`;
|
|
9778
9790
|
}
|
|
9779
9791
|
const label = `gate:${gateStep.gate_kind}`;
|
|
9792
|
+
const { model } = modelOpt(step.model_class, reg, `gate "${gateStep.gate_kind}"`);
|
|
9780
9793
|
const verdict = gateVar(i);
|
|
9781
9794
|
const lines = [];
|
|
9782
9795
|
lines.push(`${pad}const ${verdict} = await agent(${promptExpr}, {`);
|
|
@@ -9784,6 +9797,7 @@ function emitGateStatements(step, i, steps, deps, pad, feedback) {
|
|
|
9784
9797
|
${pad} `)},`);
|
|
9785
9798
|
lines.push(`${pad} label: ${jsString(label)},`);
|
|
9786
9799
|
lines.push(`${pad} phase: 'Gate',`);
|
|
9800
|
+
if (model) lines.push(`${pad} model: ${jsString(model)},`);
|
|
9787
9801
|
lines.push(`${pad}})`);
|
|
9788
9802
|
lines.push(`${pad}if (!${verdict}.approved) {`);
|
|
9789
9803
|
lines.push(`${pad} return { blocked: true, gate: ${jsString(gateStep.gate_kind)}, reason: ${verdict}.reason }`);
|
|
@@ -9799,11 +9813,7 @@ function emitEvaluateAgentCall(step, reg, i, steps, deps, pad, feedback) {
|
|
|
9799
9813
|
if (schema) opts.schema = schema;
|
|
9800
9814
|
opts.label = task.id;
|
|
9801
9815
|
opts.phase = phaseTitle(step);
|
|
9802
|
-
|
|
9803
|
-
if (mc) {
|
|
9804
|
-
opts.model = mc.model;
|
|
9805
|
-
if (mc.effort) opts.effort = mc.effort;
|
|
9806
|
-
}
|
|
9816
|
+
Object.assign(opts, modelOpt(task.model_class, reg, `task "${task.id}"`));
|
|
9807
9817
|
const optsLiteral = jsLiteral(opts, 0).replace(/\n/g, `
|
|
9808
9818
|
${pad}`);
|
|
9809
9819
|
return `await agent(${promptExpr}, ${optsLiteral})`;
|
|
@@ -9817,7 +9827,7 @@ function emitStepStatements(i, reg, steps, deps, pad, opts) {
|
|
|
9817
9827
|
return [`${pad}${lhs} = await ${expr}`];
|
|
9818
9828
|
}
|
|
9819
9829
|
if (step.type === "gate") {
|
|
9820
|
-
return emitGateStatements(step, i, steps, deps, pad, feedback);
|
|
9830
|
+
return emitGateStatements(step, reg, i, steps, deps, pad, feedback);
|
|
9821
9831
|
}
|
|
9822
9832
|
throw new WorkflowCodegenError(`emitStepStatements called with non-simple step type "${step.type}"`);
|
|
9823
9833
|
}
|
|
@@ -9886,8 +9896,8 @@ function assertInScope(step) {
|
|
|
9886
9896
|
throw new WorkflowCodegenError(`Unknown workflow step type "${step.type}"`);
|
|
9887
9897
|
}
|
|
9888
9898
|
}
|
|
9889
|
-
function renderWorkflowScript(id, wf, dsl) {
|
|
9890
|
-
const reg = buildRegistries(dsl);
|
|
9899
|
+
function renderWorkflowScript(id, wf, dsl, modelMapping) {
|
|
9900
|
+
const reg = buildRegistries(dsl, modelMapping);
|
|
9891
9901
|
const steps = wf.steps ?? [];
|
|
9892
9902
|
for (const step of steps) assertInScope(step);
|
|
9893
9903
|
const deps = resolveDeps(steps);
|
|
@@ -9949,7 +9959,7 @@ function renderWorkflowScript(id, wf, dsl) {
|
|
|
9949
9959
|
if (step.type === "delegate") {
|
|
9950
9960
|
body.push(...emitStepStatements(i, reg, steps, deps, " "));
|
|
9951
9961
|
} else if (step.type === "gate") {
|
|
9952
|
-
body.push(...emitGateStatements(step, i, steps, deps, " "));
|
|
9962
|
+
body.push(...emitGateStatements(step, reg, i, steps, deps, " "));
|
|
9953
9963
|
}
|
|
9954
9964
|
}
|
|
9955
9965
|
}
|
|
@@ -9963,7 +9973,7 @@ export const meta = ${metaLiteral}
|
|
|
9963
9973
|
${topLevelBody}
|
|
9964
9974
|
`;
|
|
9965
9975
|
}
|
|
9966
|
-
function renderWorkflowFiles(sources, outputDir) {
|
|
9976
|
+
function renderWorkflowFiles(sources, outputDir, modelMapping) {
|
|
9967
9977
|
const dir = workflowsDirFor(outputDir);
|
|
9968
9978
|
return mergeSourceFiles(
|
|
9969
9979
|
sources.map((source) => ({
|
|
@@ -9972,7 +9982,7 @@ function renderWorkflowFiles(sources, outputDir) {
|
|
|
9972
9982
|
source.dsl.workflow ?? {}
|
|
9973
9983
|
).map(([id, wf]) => ({
|
|
9974
9984
|
path: `${dir}/${pathSegmentForId4("workflow id", id)}${WORKFLOW_FILE_EXT}`,
|
|
9975
|
-
content: renderWorkflowScript(id, wf, source.dsl)
|
|
9985
|
+
content: renderWorkflowScript(id, wf, source.dsl, modelMapping)
|
|
9976
9986
|
}))
|
|
9977
9987
|
})),
|
|
9978
9988
|
(message) => new WorkflowCodegenError(message)
|
|
@@ -10600,9 +10610,9 @@ function checkContent(file, existing) {
|
|
|
10600
10610
|
if (existing !== file.content) return "changed";
|
|
10601
10611
|
return null;
|
|
10602
10612
|
}
|
|
10603
|
-
function workflowFiles(sources, config) {
|
|
10613
|
+
function workflowFiles(sources, config, modelMapping) {
|
|
10604
10614
|
if (!config.emit.workflows) return [];
|
|
10605
|
-
return renderWorkflowFiles(sources, config.output_dir);
|
|
10615
|
+
return renderWorkflowFiles(sources, config.output_dir, modelMapping);
|
|
10606
10616
|
}
|
|
10607
10617
|
function commandOutputTemplate(config) {
|
|
10608
10618
|
const commands = config.emit.commands;
|
|
@@ -10713,15 +10723,19 @@ function checkHookBin(file, existing) {
|
|
|
10713
10723
|
const onDisk = recomputeMarkerFromDisk(existing);
|
|
10714
10724
|
return stored !== expected || stored !== onDisk ? "changed" : null;
|
|
10715
10725
|
}
|
|
10716
|
-
function
|
|
10726
|
+
function effectiveClaudeInputs(root, raw) {
|
|
10717
10727
|
const config = parseClaudeConfig(raw);
|
|
10718
10728
|
const manifestPath = join7(root, PROJECT_CONFIG_FILENAME);
|
|
10719
|
-
if (!existsSync5(manifestPath)) return config;
|
|
10720
|
-
|
|
10729
|
+
if (!existsSync5(manifestPath)) return { config, modelMapping: {} };
|
|
10730
|
+
const manifest = readProjectManifest(manifestPath);
|
|
10731
|
+
return {
|
|
10732
|
+
config: applyProjectEmit(config, manifest.bindings?.claude?.emit),
|
|
10733
|
+
modelMapping: manifest.model_mapping
|
|
10734
|
+
};
|
|
10721
10735
|
}
|
|
10722
10736
|
async function syncClaude(opts) {
|
|
10723
10737
|
const root = resolve6(opts.projectRoot);
|
|
10724
|
-
const config =
|
|
10738
|
+
const { config, modelMapping } = effectiveClaudeInputs(root, opts.config);
|
|
10725
10739
|
const result = { files: [] };
|
|
10726
10740
|
const sources = await resolveDslSources(root, opts.dsl, config);
|
|
10727
10741
|
const rendered = await renderFiles(root, opts.dsl, config, entryAgentPromptFor(sources, config));
|
|
@@ -10756,7 +10770,7 @@ async function syncClaude(opts) {
|
|
|
10756
10770
|
})
|
|
10757
10771
|
});
|
|
10758
10772
|
}
|
|
10759
|
-
const workflows = workflowFiles(sources, config);
|
|
10773
|
+
const workflows = workflowFiles(sources, config, modelMapping);
|
|
10760
10774
|
const commands = await commandFiles(sources, config, root);
|
|
10761
10775
|
const agents = agentFiles(sources, config);
|
|
10762
10776
|
const additive = [...workflows, ...commands, ...agents];
|
|
@@ -10786,7 +10800,7 @@ async function syncClaude(opts) {
|
|
|
10786
10800
|
}
|
|
10787
10801
|
async function checkClaude(opts) {
|
|
10788
10802
|
const root = resolve6(opts.projectRoot);
|
|
10789
|
-
const config =
|
|
10803
|
+
const { config, modelMapping } = effectiveClaudeInputs(root, opts.config);
|
|
10790
10804
|
const drift = [];
|
|
10791
10805
|
const sources = await resolveDslSources(root, opts.dsl, config);
|
|
10792
10806
|
const rendered = await renderFiles(root, opts.dsl, config, entryAgentPromptFor(sources, config));
|
|
@@ -10801,7 +10815,7 @@ async function checkClaude(opts) {
|
|
|
10801
10815
|
drift.push({ path: rel, reason });
|
|
10802
10816
|
}
|
|
10803
10817
|
}
|
|
10804
|
-
const workflows = workflowFiles(sources, config);
|
|
10818
|
+
const workflows = workflowFiles(sources, config, modelMapping);
|
|
10805
10819
|
const commands = await commandFiles(sources, config, root);
|
|
10806
10820
|
const agents = agentFiles(sources, config);
|
|
10807
10821
|
const additive = [...workflows, ...commands, ...agents];
|