@aaac/runtime 0.2.7 → 0.2.9

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/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
@@ -12,9 +12,10 @@ import {
12
12
  loadDslContext,
13
13
  resolveArtifacts,
14
14
  resolveGuardrailContext,
15
+ resolveHandoffSchemas,
15
16
  resolveNavigationDsl,
16
17
  resolveNavigationSources
17
- } from "./chunk-DEBCJKRX.js";
18
+ } from "./chunk-CJLKKDKN.js";
18
19
  import {
19
20
  jsonSchemaToZod
20
21
  } from "./chunk-ET6TGQRT.js";
@@ -7702,7 +7703,7 @@ async function runWorkflow(adapterOrFactory, workflowIdOrInvocation, optionsOrRe
7702
7703
  const batchResults = await Promise.all(ready.map(async (i) => {
7703
7704
  const step = workflow.steps[i];
7704
7705
  const stepTask = step.type === "delegate" || step.type === "evaluate" ? registries?.taskRegistry?.[step.task] : void 0;
7705
- const modelClass = stepTask?.model_class;
7706
+ const modelClass = step.type === "gate" ? step.model_class : stepTask?.model_class;
7706
7707
  const stepAgentId = options.perAgentAdapters ? stepTask?.target_agent : void 0;
7707
7708
  let stepAdapter;
7708
7709
  if (adapterFactory && (ready.length > 1 || modelClass || stepAgentId)) {
@@ -9510,11 +9511,7 @@ function mergeSourceFiles(rendered, conflict) {
9510
9511
 
9511
9512
  // src/lib/claude-materialize/workflow-render.ts
9512
9513
  var GENERATED_MARKER = "// Auto-generated by @aaac/runtime claude-materialize (#235). Do not edit; run `claude sync` instead.";
9513
- var MODEL_CLASS_MAP = {
9514
- fast: { model: "haiku" },
9515
- standard: { model: "sonnet" },
9516
- thinking: { model: "opus", effort: "high" }
9517
- };
9514
+ var CLAUDE_CODE_ADAPTER = "claude";
9518
9515
  var WorkflowCodegenError = class extends Error {
9519
9516
  constructor(message) {
9520
9517
  super(message);
@@ -9608,12 +9605,10 @@ var GATE_SCHEMA = {
9608
9605
  },
9609
9606
  required: ["approved"]
9610
9607
  };
9611
- function resolveHandoffSchema(task, handoffTypes, components) {
9608
+ function resultHandoffSchema(task, reg) {
9612
9609
  const id = task.result_handoff;
9613
- if (!id) return void 0;
9614
- const ht = handoffTypes[id];
9615
- if (!ht?.schema) return void 0;
9616
- return resolveSchemaRefs(ht.schema, components);
9610
+ if (!id || !Object.prototype.hasOwnProperty.call(reg.handoffSchemas, id)) return void 0;
9611
+ return reg.handoffSchemas[id];
9617
9612
  }
9618
9613
  function toTaskContract(id, raw) {
9619
9614
  return {
@@ -9625,18 +9620,25 @@ function toTaskContract(id, raw) {
9625
9620
  model_class: raw.model_class
9626
9621
  };
9627
9622
  }
9628
- function buildRegistries(dsl) {
9623
+ function buildRegistries(dsl, modelMapping) {
9629
9624
  const rawTasks = dsl.tasks ?? {};
9630
9625
  const agents = buildAgentRegistry(dsl);
9631
9626
  const tasks = {};
9632
9627
  for (const [id, t] of Object.entries(rawTasks)) tasks[id] = toTaskContract(id, t);
9633
- const componentsRoot = dsl.components ?? {};
9634
- const components = componentsRoot.schemas ?? componentsRoot;
9635
9628
  return {
9636
9629
  agents,
9637
9630
  tasks,
9638
- handoffTypes: dsl.handoff_types ?? {},
9639
- components
9631
+ handoffSchemas: resolveHandoffSchemas(dsl, resolveSchemaRefs),
9632
+ // The runtime's resolver, so a class resolves to the model it runs on when
9633
+ // the runtime executes the same step. No environment: `AGENT_RUNTIME_MODEL*`
9634
+ // override a run, and a committed artifact that depended on the generating
9635
+ // shell would differ between machines. The harness is the fallback adapter,
9636
+ // so a class `model_mapping` does not route resolves to the harness default.
9637
+ models: createModelResolver({
9638
+ modelMapping,
9639
+ fallbackAdapter: CLAUDE_CODE_ADAPTER,
9640
+ env: {}
9641
+ })
9640
9642
  };
9641
9643
  }
9642
9644
  function phaseTitle(step) {
@@ -9661,16 +9663,22 @@ function buildMeta(id, wf, steps) {
9661
9663
  if (phases.length > 0) meta.phases = phases;
9662
9664
  return meta;
9663
9665
  }
9664
- function agentOpts(task, step, handoffSchema, indent) {
9666
+ function modelOpt(modelClass, reg, owner) {
9667
+ if (!modelClass) return {};
9668
+ const resolved = reg.models.resolve(modelClass);
9669
+ if (resolved.adapter !== CLAUDE_CODE_ADAPTER) {
9670
+ throw new WorkflowCodegenError(
9671
+ `${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`
9672
+ );
9673
+ }
9674
+ return resolved.model ? { model: resolved.model } : {};
9675
+ }
9676
+ function agentOpts(task, step, reg, handoffSchema, indent) {
9665
9677
  const opts = {};
9666
9678
  if (handoffSchema) opts.schema = handoffSchema;
9667
9679
  opts.label = task.id;
9668
9680
  opts.phase = phaseTitle(step);
9669
- const mc = task.model_class ? MODEL_CLASS_MAP[task.model_class] : void 0;
9670
- if (mc) {
9671
- opts.model = mc.model;
9672
- if (mc.effort) opts.effort = mc.effort;
9673
- }
9681
+ Object.assign(opts, modelOpt(task.model_class, reg, `task "${task.id}"`));
9674
9682
  return jsLiteral(opts, indent);
9675
9683
  }
9676
9684
  function resultVar(i) {
@@ -9691,28 +9699,125 @@ function priorContextExpr(i, steps, deps) {
9691
9699
  if (fragments.length === 0) return "";
9692
9700
  return fragments.join(" + ");
9693
9701
  }
9694
- function emitWorkflowInputHelper(pad) {
9702
+ function emitWorkflowInputOutputHelper(pad) {
9695
9703
  const id = WORKFLOW_INPUT_STEP_ID;
9696
9704
  return [
9697
- `${pad}const _wfInput = (args) => {`,
9698
- `${pad} if (args === undefined || args === null) return ''`,
9699
- `${pad} let output`,
9700
- `${pad} if (typeof args === 'string') {`,
9701
- `${pad} output = { user_request: args }`,
9702
- `${pad} } else if (typeof args === 'object' && ('user_request' in args || 'handoff' in args)) {`,
9705
+ `${pad}const _wfInputOutput = (args) => {`,
9706
+ `${pad} if (args === undefined || args === null) return undefined`,
9707
+ `${pad} if (typeof args === 'string') return { user_request: args }`,
9708
+ `${pad} if (typeof args === 'object' && ('user_request' in args || 'handoff' in args)) {`,
9703
9709
  `${pad} const h = args.handoff`,
9704
9710
  `${pad} const userRequest = typeof args.user_request === 'string'`,
9705
9711
  `${pad} ? args.user_request`,
9706
9712
  `${pad} : h`,
9707
9713
  `${pad} ? (typeof h.payload === 'string' ? h.payload : JSON.stringify(h.payload, null, 2))`,
9708
9714
  `${pad} : ''`,
9709
- `${pad} output = h`,
9715
+ `${pad} return h`,
9710
9716
  `${pad} ? { user_request: userRequest, handoff: (h.version !== undefined ? { type: h.type, version: h.version, payload: h.payload } : { type: h.type, payload: h.payload }) }`,
9711
9717
  `${pad} : { user_request: userRequest }`,
9712
- `${pad} } else {`,
9713
- `${pad} output = { user_request: JSON.stringify(args, null, 2), handoff: { type: ${jsString(id)}, payload: args } }`,
9714
9718
  `${pad} }`,
9715
- `${pad} return '\\n\\n--- Step: ${id} ---\\n' + JSON.stringify(output, null, 2)`,
9719
+ `${pad} return { user_request: JSON.stringify(args, null, 2), handoff: { type: ${jsString(id)}, payload: args } }`,
9720
+ `${pad}}`
9721
+ ];
9722
+ }
9723
+ function emitWorkflowInputHelper(pad) {
9724
+ const id = WORKFLOW_INPUT_STEP_ID;
9725
+ return [
9726
+ `${pad}const _wfInput = (args) => {`,
9727
+ `${pad} const output = _wfInputOutput(args)`,
9728
+ `${pad} return output === undefined ? '' : '\\n\\n--- Step: ${id} ---\\n' + JSON.stringify(output, null, 2)`,
9729
+ `${pad}}`
9730
+ ];
9731
+ }
9732
+ function emitInputValidation(pad, schemas) {
9733
+ const schemasLiteral = jsLiteral(schemas, 0).replace(/\n/g, `
9734
+ ${pad}`);
9735
+ return [
9736
+ `${pad}const _HANDOFF_SCHEMAS = ${schemasLiteral}`,
9737
+ `${pad}const _isObject = (v) => typeof v === 'object' && v !== null && !Array.isArray(v)`,
9738
+ `${pad}const _shapeOf = (s) => {`,
9739
+ `${pad} if (!_isObject(s) || s.enum || s.const !== undefined) return null`,
9740
+ `${pad} if (s.type === 'object') {`,
9741
+ `${pad} if (!s.properties) return null`,
9742
+ `${pad} const req = new Set(s.required ?? [])`,
9743
+ `${pad} const shape = {}`,
9744
+ `${pad} for (const [k, ps] of Object.entries(s.properties)) shape[k] = { s: ps, required: req.has(k) }`,
9745
+ `${pad} return shape`,
9746
+ `${pad} }`,
9747
+ `${pad} if (['string', 'integer', 'number', 'boolean', 'array'].includes(s.type) || !s.allOf || s.allOf.length === 0) return null`,
9748
+ `${pad} let shape = _shapeOf(s.allOf[0])`,
9749
+ `${pad} if (!shape) return null`,
9750
+ `${pad} for (const part of s.allOf.slice(1)) {`,
9751
+ `${pad} const next = _shapeOf(part)`,
9752
+ `${pad} if (next) shape = { ...shape, ...next }`,
9753
+ `${pad} }`,
9754
+ `${pad} return shape`,
9755
+ `${pad}}`,
9756
+ `${pad}const _conformShape = (shape, v, p) => {`,
9757
+ `${pad} if (!_isObject(v)) return p + ': expected object'`,
9758
+ `${pad} for (const [k, f] of Object.entries(shape)) {`,
9759
+ `${pad} const has = Object.prototype.hasOwnProperty.call(v, k)`,
9760
+ `${pad} if (f.required ? !has : (!has || v[k] === undefined)) {`,
9761
+ `${pad} if (f.required) return p + '.' + k + ': required'`,
9762
+ `${pad} continue`,
9763
+ `${pad} }`,
9764
+ `${pad} const e = _conform(f.s, v[k], p + '.' + k)`,
9765
+ `${pad} if (e) return e`,
9766
+ `${pad} }`,
9767
+ `${pad} return ''`,
9768
+ `${pad}}`,
9769
+ `${pad}const _conform = (s, v, p) => {`,
9770
+ `${pad} if (!_isObject(s)) return ''`,
9771
+ `${pad} if (s.enum) {`,
9772
+ `${pad} if (s.enum.length === 0) return ''`,
9773
+ `${pad} return typeof v === 'string' && s.enum.includes(v) ? '' : p + ': expected one of ' + JSON.stringify(s.enum)`,
9774
+ `${pad} }`,
9775
+ `${pad} if (s.const !== undefined) {`,
9776
+ `${pad} const c = s.const`,
9777
+ `${pad} if (typeof c !== 'string' && typeof c !== 'number' && typeof c !== 'boolean') return ''`,
9778
+ `${pad} return v === c ? '' : p + ': expected ' + JSON.stringify(c)`,
9779
+ `${pad} }`,
9780
+ `${pad} const t = s.type`,
9781
+ `${pad} if (t === 'string') {`,
9782
+ `${pad} if (typeof v !== 'string') return p + ': expected string'`,
9783
+ `${pad} if (typeof s.minLength === 'number' && v.length < s.minLength) return p + ': shorter than ' + s.minLength`,
9784
+ `${pad} if (typeof s.maxLength === 'number' && v.length > s.maxLength) return p + ': longer than ' + s.maxLength`,
9785
+ `${pad} if (typeof s.pattern === 'string' && !new RegExp(s.pattern).test(v)) return p + ': does not match ' + s.pattern`,
9786
+ `${pad} return ''`,
9787
+ `${pad} }`,
9788
+ `${pad} if (t === 'integer' || t === 'number') {`,
9789
+ `${pad} if (typeof v !== 'number' || !Number.isFinite(v) || (t === 'integer' && !Number.isSafeInteger(v))) return p + ': expected ' + t`,
9790
+ `${pad} if (typeof s.minimum === 'number' && v < s.minimum) return p + ': less than ' + s.minimum`,
9791
+ `${pad} if (typeof s.maximum === 'number' && v > s.maximum) return p + ': greater than ' + s.maximum`,
9792
+ `${pad} return ''`,
9793
+ `${pad} }`,
9794
+ `${pad} if (t === 'boolean') return typeof v === 'boolean' ? '' : p + ': expected boolean'`,
9795
+ `${pad} if (t === 'array') {`,
9796
+ `${pad} if (!Array.isArray(v)) return p + ': expected array'`,
9797
+ `${pad} if (s.items) {`,
9798
+ `${pad} for (let i = 0; i < v.length; i++) {`,
9799
+ `${pad} const e = _conform(s.items, v[i], p + '[' + i + ']')`,
9800
+ `${pad} if (e) return e`,
9801
+ `${pad} }`,
9802
+ `${pad} }`,
9803
+ `${pad} if (typeof s.minItems === 'number' && v.length < s.minItems) return p + ': fewer than ' + s.minItems + ' items'`,
9804
+ `${pad} if (typeof s.maxItems === 'number' && v.length > s.maxItems) return p + ': more than ' + s.maxItems + ' items'`,
9805
+ `${pad} return ''`,
9806
+ `${pad} }`,
9807
+ `${pad} if (t === 'object') {`,
9808
+ `${pad} if (!_isObject(v)) return p + ': expected object'`,
9809
+ `${pad} return s.properties ? _conformShape(_shapeOf(s), v, p) : ''`,
9810
+ `${pad} }`,
9811
+ `${pad} if (!s.allOf || s.allOf.length === 0) return ''`,
9812
+ `${pad} const shape = _shapeOf(s)`,
9813
+ `${pad} return shape ? _conformShape(shape, v, p) : _conform(s.allOf[0], v, p)`,
9814
+ `${pad}}`,
9815
+ `${pad}{`,
9816
+ `${pad} const h = _wfInputOutput(args)?.handoff`,
9817
+ `${pad} if (h && Object.prototype.hasOwnProperty.call(_HANDOFF_SCHEMAS, h.type)) {`,
9818
+ `${pad} const e = _conform(_HANDOFF_SCHEMAS[h.type], h.payload, 'payload')`,
9819
+ `${pad} if (e) throw new Error('Input handoff validation failed for "' + h.type + '": ' + e)`,
9820
+ `${pad} }`,
9716
9821
  `${pad}}`
9717
9822
  ];
9718
9823
  }
@@ -9750,12 +9855,12 @@ function resolveStepAgentTask(step, reg, kind) {
9750
9855
  function emitDelegateExpr(step, reg, i, steps, deps, indent, feedback) {
9751
9856
  const { agent, task } = resolveStepAgentTask(step, reg, "delegate");
9752
9857
  const prompt = renderDelegatePrompt(agent, task, step);
9753
- const schema = resolveHandoffSchema(task, reg.handoffTypes, reg.components);
9858
+ const schema = resultHandoffSchema(task, reg);
9754
9859
  const promptExpr = withPriorContext(jsLiteral(prompt), priorContextExpr(i, steps, deps), feedback);
9755
- const opts = agentOpts(task, step, schema, indent);
9860
+ const opts = agentOpts(task, step, reg, schema, indent);
9756
9861
  return `agent(${promptExpr}, ${opts})`;
9757
9862
  }
9758
- function emitGateStatements(step, i, steps, deps, pad, feedback) {
9863
+ function emitGateStatements(step, reg, i, steps, deps, pad, feedback) {
9759
9864
  const gateStep = {
9760
9865
  type: "gate",
9761
9866
  gate_kind: step.gate_kind ?? "",
@@ -9777,6 +9882,7 @@ function emitGateStatements(step, i, steps, deps, pad, feedback) {
9777
9882
  promptExpr = `${promptExpr} + (${feedback.feedbackVar} !== undefined ? ${varSection} : '')`;
9778
9883
  }
9779
9884
  const label = `gate:${gateStep.gate_kind}`;
9885
+ const { model } = modelOpt(step.model_class, reg, `gate "${gateStep.gate_kind}"`);
9780
9886
  const verdict = gateVar(i);
9781
9887
  const lines = [];
9782
9888
  lines.push(`${pad}const ${verdict} = await agent(${promptExpr}, {`);
@@ -9784,6 +9890,7 @@ function emitGateStatements(step, i, steps, deps, pad, feedback) {
9784
9890
  ${pad} `)},`);
9785
9891
  lines.push(`${pad} label: ${jsString(label)},`);
9786
9892
  lines.push(`${pad} phase: 'Gate',`);
9893
+ if (model) lines.push(`${pad} model: ${jsString(model)},`);
9787
9894
  lines.push(`${pad}})`);
9788
9895
  lines.push(`${pad}if (!${verdict}.approved) {`);
9789
9896
  lines.push(`${pad} return { blocked: true, gate: ${jsString(gateStep.gate_kind)}, reason: ${verdict}.reason }`);
@@ -9793,17 +9900,13 @@ ${pad} `)},`);
9793
9900
  function emitEvaluateAgentCall(step, reg, i, steps, deps, pad, feedback) {
9794
9901
  const { agent, task } = resolveStepAgentTask(step, reg, "evaluate");
9795
9902
  const prompt = renderDelegatePrompt(agent, task, step);
9796
- const schema = resolveHandoffSchema(task, reg.handoffTypes, reg.components);
9903
+ const schema = resultHandoffSchema(task, reg);
9797
9904
  const promptExpr = withPriorContext(jsLiteral(prompt), priorContextExpr(i, steps, deps), feedback);
9798
9905
  const opts = {};
9799
9906
  if (schema) opts.schema = schema;
9800
9907
  opts.label = task.id;
9801
9908
  opts.phase = phaseTitle(step);
9802
- const mc = task.model_class ? MODEL_CLASS_MAP[task.model_class] : void 0;
9803
- if (mc) {
9804
- opts.model = mc.model;
9805
- if (mc.effort) opts.effort = mc.effort;
9806
- }
9909
+ Object.assign(opts, modelOpt(task.model_class, reg, `task "${task.id}"`));
9807
9910
  const optsLiteral = jsLiteral(opts, 0).replace(/\n/g, `
9808
9911
  ${pad}`);
9809
9912
  return `await agent(${promptExpr}, ${optsLiteral})`;
@@ -9817,7 +9920,7 @@ function emitStepStatements(i, reg, steps, deps, pad, opts) {
9817
9920
  return [`${pad}${lhs} = await ${expr}`];
9818
9921
  }
9819
9922
  if (step.type === "gate") {
9820
- return emitGateStatements(step, i, steps, deps, pad, feedback);
9923
+ return emitGateStatements(step, reg, i, steps, deps, pad, feedback);
9821
9924
  }
9822
9925
  throw new WorkflowCodegenError(`emitStepStatements called with non-simple step type "${step.type}"`);
9823
9926
  }
@@ -9886,8 +9989,8 @@ function assertInScope(step) {
9886
9989
  throw new WorkflowCodegenError(`Unknown workflow step type "${step.type}"`);
9887
9990
  }
9888
9991
  }
9889
- function renderWorkflowScript(id, wf, dsl) {
9890
- const reg = buildRegistries(dsl);
9992
+ function renderWorkflowScript(id, wf, dsl, modelMapping) {
9993
+ const reg = buildRegistries(dsl, modelMapping);
9891
9994
  const steps = wf.steps ?? [];
9892
9995
  for (const step of steps) assertInScope(step);
9893
9996
  const deps = resolveDeps(steps);
@@ -9913,15 +10016,22 @@ function renderWorkflowScript(id, wf, dsl) {
9913
10016
  const usesWorkflowInput = steps.some(
9914
10017
  (step) => stepDependsOnWorkflowInput(step.depends_on)
9915
10018
  );
10019
+ const validatesInput = Object.keys(reg.handoffSchemas).length > 0;
9916
10020
  const body = [];
9917
10021
  if (usesStepContext) {
9918
10022
  body.push(
9919
10023
  " const _ctx = (n, id, r) => '\\n\\n--- Step ' + n + ': ' + id + ' ---\\n' + (typeof r === 'string' ? r : JSON.stringify(r, null, 2))"
9920
10024
  );
9921
10025
  }
10026
+ if (usesWorkflowInput || validatesInput) {
10027
+ body.push(...emitWorkflowInputOutputHelper(" "));
10028
+ }
9922
10029
  if (usesWorkflowInput) {
9923
10030
  body.push(...emitWorkflowInputHelper(" "));
9924
10031
  }
10032
+ if (validatesInput) {
10033
+ body.push(...emitInputValidation(" ", reg.handoffSchemas));
10034
+ }
9925
10035
  const emittedWaves = /* @__PURE__ */ new Set();
9926
10036
  for (let i = 0; i < steps.length; i++) {
9927
10037
  if (spanOwner.has(i) && spanOwner.get(i) !== i) continue;
@@ -9949,7 +10059,7 @@ function renderWorkflowScript(id, wf, dsl) {
9949
10059
  if (step.type === "delegate") {
9950
10060
  body.push(...emitStepStatements(i, reg, steps, deps, " "));
9951
10061
  } else if (step.type === "gate") {
9952
- body.push(...emitGateStatements(step, i, steps, deps, " "));
10062
+ body.push(...emitGateStatements(step, reg, i, steps, deps, " "));
9953
10063
  }
9954
10064
  }
9955
10065
  }
@@ -9963,7 +10073,7 @@ export const meta = ${metaLiteral}
9963
10073
  ${topLevelBody}
9964
10074
  `;
9965
10075
  }
9966
- function renderWorkflowFiles(sources, outputDir) {
10076
+ function renderWorkflowFiles(sources, outputDir, modelMapping) {
9967
10077
  const dir = workflowsDirFor(outputDir);
9968
10078
  return mergeSourceFiles(
9969
10079
  sources.map((source) => ({
@@ -9972,7 +10082,7 @@ function renderWorkflowFiles(sources, outputDir) {
9972
10082
  source.dsl.workflow ?? {}
9973
10083
  ).map(([id, wf]) => ({
9974
10084
  path: `${dir}/${pathSegmentForId4("workflow id", id)}${WORKFLOW_FILE_EXT}`,
9975
- content: renderWorkflowScript(id, wf, source.dsl)
10085
+ content: renderWorkflowScript(id, wf, source.dsl, modelMapping)
9976
10086
  }))
9977
10087
  })),
9978
10088
  (message) => new WorkflowCodegenError(message)
@@ -10600,9 +10710,9 @@ function checkContent(file, existing) {
10600
10710
  if (existing !== file.content) return "changed";
10601
10711
  return null;
10602
10712
  }
10603
- function workflowFiles(sources, config) {
10713
+ function workflowFiles(sources, config, modelMapping) {
10604
10714
  if (!config.emit.workflows) return [];
10605
- return renderWorkflowFiles(sources, config.output_dir);
10715
+ return renderWorkflowFiles(sources, config.output_dir, modelMapping);
10606
10716
  }
10607
10717
  function commandOutputTemplate(config) {
10608
10718
  const commands = config.emit.commands;
@@ -10713,15 +10823,19 @@ function checkHookBin(file, existing) {
10713
10823
  const onDisk = recomputeMarkerFromDisk(existing);
10714
10824
  return stored !== expected || stored !== onDisk ? "changed" : null;
10715
10825
  }
10716
- function effectiveClaudeConfig(root, raw) {
10826
+ function effectiveClaudeInputs(root, raw) {
10717
10827
  const config = parseClaudeConfig(raw);
10718
10828
  const manifestPath = join7(root, PROJECT_CONFIG_FILENAME);
10719
- if (!existsSync5(manifestPath)) return config;
10720
- return applyProjectEmit(config, readProjectManifest(manifestPath).bindings?.claude?.emit);
10829
+ if (!existsSync5(manifestPath)) return { config, modelMapping: {} };
10830
+ const manifest = readProjectManifest(manifestPath);
10831
+ return {
10832
+ config: applyProjectEmit(config, manifest.bindings?.claude?.emit),
10833
+ modelMapping: manifest.model_mapping
10834
+ };
10721
10835
  }
10722
10836
  async function syncClaude(opts) {
10723
10837
  const root = resolve6(opts.projectRoot);
10724
- const config = effectiveClaudeConfig(root, opts.config);
10838
+ const { config, modelMapping } = effectiveClaudeInputs(root, opts.config);
10725
10839
  const result = { files: [] };
10726
10840
  const sources = await resolveDslSources(root, opts.dsl, config);
10727
10841
  const rendered = await renderFiles(root, opts.dsl, config, entryAgentPromptFor(sources, config));
@@ -10756,7 +10870,7 @@ async function syncClaude(opts) {
10756
10870
  })
10757
10871
  });
10758
10872
  }
10759
- const workflows = workflowFiles(sources, config);
10873
+ const workflows = workflowFiles(sources, config, modelMapping);
10760
10874
  const commands = await commandFiles(sources, config, root);
10761
10875
  const agents = agentFiles(sources, config);
10762
10876
  const additive = [...workflows, ...commands, ...agents];
@@ -10786,7 +10900,7 @@ async function syncClaude(opts) {
10786
10900
  }
10787
10901
  async function checkClaude(opts) {
10788
10902
  const root = resolve6(opts.projectRoot);
10789
- const config = effectiveClaudeConfig(root, opts.config);
10903
+ const { config, modelMapping } = effectiveClaudeInputs(root, opts.config);
10790
10904
  const drift = [];
10791
10905
  const sources = await resolveDslSources(root, opts.dsl, config);
10792
10906
  const rendered = await renderFiles(root, opts.dsl, config, entryAgentPromptFor(sources, config));
@@ -10801,7 +10915,7 @@ async function checkClaude(opts) {
10801
10915
  drift.push({ path: rel, reason });
10802
10916
  }
10803
10917
  }
10804
- const workflows = workflowFiles(sources, config);
10918
+ const workflows = workflowFiles(sources, config, modelMapping);
10805
10919
  const commands = await commandFiles(sources, config, root);
10806
10920
  const agents = agentFiles(sources, config);
10807
10921
  const additive = [...workflows, ...commands, ...agents];