@aaac/runtime 0.2.8 → 0.2.10

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.
Files changed (49) hide show
  1. package/dist/adapters/adk-sdk.d.ts +1 -1
  2. package/dist/adapters/adk-sdk.js +1 -1
  3. package/dist/adapters/claude-agent-sdk.d.ts +1 -1
  4. package/dist/adapters/claude-agent-sdk.js +5 -4
  5. package/dist/adapters/claude-agent-sdk.js.map +1 -1
  6. package/dist/adapters/openai-agents-sdk.d.ts +1 -1
  7. package/dist/adapters/openai-agents-sdk.js +1 -1
  8. package/dist/{chunk-D2UXESPT.js → chunk-2SG3TBI3.js} +4 -51
  9. package/dist/chunk-2SG3TBI3.js.map +1 -0
  10. package/dist/{chunk-Y7NORFFM.js → chunk-5ZDW4RP7.js} +2 -2
  11. package/dist/{chunk-GWNXNSGL.js → chunk-BHTHXGA3.js} +12 -9
  12. package/dist/chunk-BHTHXGA3.js.map +1 -0
  13. package/dist/{chunk-HR2Q64AO.js → chunk-EA4V5DVD.js} +29 -4
  14. package/dist/chunk-EA4V5DVD.js.map +1 -0
  15. package/dist/chunk-EBMQHLXY.js +61 -0
  16. package/dist/chunk-EBMQHLXY.js.map +1 -0
  17. package/dist/{chunk-QVMLALPF.js → chunk-GGBNVCPV.js} +5 -3
  18. package/dist/{chunk-QVMLALPF.js.map → chunk-GGBNVCPV.js.map} +1 -1
  19. package/dist/{chunk-CPSXQCNA.js → chunk-N2EA3TGS.js} +42 -14
  20. package/dist/chunk-N2EA3TGS.js.map +1 -0
  21. package/dist/{chunk-MG7WSWJU.js → chunk-RTYJNZGT.js} +1 -1
  22. package/dist/chunk-RTYJNZGT.js.map +1 -0
  23. package/dist/claude-bundles/full.js +157 -157
  24. package/dist/claude-bundles/lean.js +5 -5
  25. package/dist/claude-bundles/prompt.js +2 -2
  26. package/dist/generator/index.d.ts +2 -2
  27. package/dist/generator/index.js +2 -2
  28. package/dist/{guardrail-hooks-B-qe4ebW.d.ts → guardrail-hooks-BgHe8PrP.d.ts} +6 -3
  29. package/dist/{hooks-lite-DvZu9Jhx.d.ts → hooks-lite-BtOGc2F_.d.ts} +12 -1
  30. package/dist/{index-C2DHitGz.d.ts → index-BHlvPqIp.d.ts} +3 -1
  31. package/dist/index.d.ts +13 -5
  32. package/dist/index.js +230 -64
  33. package/dist/index.js.map +1 -1
  34. package/dist/lib/claude-native/hooks-lite.d.ts +2 -2
  35. package/dist/lib/claude-native/hooks-lite.js +6 -4
  36. package/dist/lib/claude-native/hooks-prompt.d.ts +3 -3
  37. package/dist/lib/claude-native/hooks-prompt.js +4 -3
  38. package/dist/lib/claude-native/index.d.ts +5 -5
  39. package/dist/lib/claude-native/index.js +11 -9
  40. package/dist/lib/claude-native/index.js.map +1 -1
  41. package/dist/{navigation-context-D1NbiipT.d.ts → navigation-context-DJjCkrcj.d.ts} +1 -1
  42. package/dist/{workspace-user-prompt-submit-aErGPoX4.d.ts → workspace-user-prompt-submit-GZwUKUHi.d.ts} +1 -1
  43. package/package.json +4 -4
  44. package/dist/chunk-CPSXQCNA.js.map +0 -1
  45. package/dist/chunk-D2UXESPT.js.map +0 -1
  46. package/dist/chunk-GWNXNSGL.js.map +0 -1
  47. package/dist/chunk-HR2Q64AO.js.map +0 -1
  48. package/dist/chunk-MG7WSWJU.js.map +0 -1
  49. /package/dist/{chunk-Y7NORFFM.js.map → chunk-5ZDW4RP7.js.map} +0 -0
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-CPSXQCNA.js";
18
+ } from "./chunk-N2EA3TGS.js";
18
19
  import {
19
20
  jsonSchemaToZod
20
21
  } from "./chunk-ET6TGQRT.js";
@@ -22,7 +23,7 @@ import {
22
23
  AdapterError,
23
24
  adapterErrorKind,
24
25
  toolGrantForAgent
25
- } from "./chunk-MG7WSWJU.js";
26
+ } from "./chunk-RTYJNZGT.js";
26
27
  import {
27
28
  OBSERVABILITY_ENV_VARS,
28
29
  buildObservabilityEnv,
@@ -51,11 +52,14 @@ import {
51
52
  loadProjectConfig,
52
53
  loadWorkspaceMembers,
53
54
  readProjectManifest
54
- } from "./chunk-Y7NORFFM.js";
55
+ } from "./chunk-5ZDW4RP7.js";
55
56
  import {
56
57
  isNavigationIndex,
57
58
  renderNavigationIndexPrompt
58
59
  } from "./chunk-3CLWG72V.js";
60
+ import {
61
+ editProtection
62
+ } from "./chunk-EBMQHLXY.js";
59
63
  import {
60
64
  UNRESOLVED_GUARDRAIL_ACTION,
61
65
  createGuardrailHooks,
@@ -63,8 +67,9 @@ import {
63
67
  getBlockingViolations,
64
68
  getWarnings,
65
69
  hasBlockingViolation,
66
- toolTargetPath
67
- } from "./chunk-HR2Q64AO.js";
70
+ toolTargetPath,
71
+ toolWriteTarget
72
+ } from "./chunk-EA4V5DVD.js";
68
73
  import {
69
74
  __commonJS,
70
75
  __require,
@@ -9275,8 +9280,12 @@ async function evaluateGuardrail(opts) {
9275
9280
  response = hooks.beforeShellExecution(shell);
9276
9281
  checks = hooks.checkShellCommand(shell);
9277
9282
  } else if (toolName !== void 0 || toolInput !== void 0) {
9278
- response = hooks.preToolUse({ tool_name: toolName, tool_input: toolInput });
9279
- const checkFilePath = toolTargetPath(toolInput);
9283
+ response = hooks.preToolUse({
9284
+ tool_name: toolName,
9285
+ tool_input: toolInput,
9286
+ root: opts.projectRoot
9287
+ });
9288
+ const checkFilePath = toolWriteTarget(toolName, toolInput, opts.projectRoot);
9280
9289
  if (checkFilePath) {
9281
9290
  checks = hooks.runChecks({ filePath: checkFilePath });
9282
9291
  }
@@ -9436,27 +9445,56 @@ var ClaudeConfigSchema = z3.object({
9436
9445
  * Reserved for future hook integration; validated for config parity.
9437
9446
  */
9438
9447
  guard_command: z3.string().optional(),
9448
+ /**
9449
+ * The command that runs `syncClaude` for this project (e.g.
9450
+ * "npx dev-team claude sync"). The CLAUDE.md block and the banner on every
9451
+ * generated subagent and workflow file name it as the way to regenerate
9452
+ * them. Without it they name `syncClaude` itself: the component id is not a
9453
+ * command, so nothing else here says which executable runs the sync. The
9454
+ * project manifest's `bindings.claude.sync_command` wins over it
9455
+ * (`applyProjectBinding`).
9456
+ */
9457
+ sync_command: z3.string().optional(),
9458
+ /**
9459
+ * The command that runs `checkClaude` for this project (e.g.
9460
+ * "npx dev-team claude check"), named in the CLAUDE.md block as the drift
9461
+ * check. Without it the block names `checkClaude` itself. The project
9462
+ * manifest's `bindings.claude.check_command` wins over it.
9463
+ */
9464
+ check_command: z3.string().optional(),
9439
9465
  /** Override component id; defaults to `dsl.system.id`. */
9440
9466
  component_id: z3.string().optional()
9441
9467
  }).strip();
9442
9468
  function parseClaudeConfig(raw) {
9443
9469
  return ClaudeConfigSchema.parse(raw ?? {});
9444
9470
  }
9445
- function applyProjectEmit(config, project) {
9471
+ function harnessCommandsFor(config) {
9472
+ return { sync: config.sync_command, check: config.check_command };
9473
+ }
9474
+ function applyProjectBinding(config, project) {
9446
9475
  if (!project) return config;
9447
9476
  const emit = { ...config.emit };
9448
- if (project.workflows !== void 0) emit.workflows = project.workflows;
9449
- if (project.agents !== void 0) emit.agents = project.agents;
9450
- if (project.harness !== void 0) emit.harness = project.harness;
9451
- if (project.commands !== void 0) {
9452
- emit.commands = project.commands ? config.emit.commands ?? {} : void 0;
9477
+ if (project.emit?.workflows !== void 0) emit.workflows = project.emit.workflows;
9478
+ if (project.emit?.agents !== void 0) emit.agents = project.emit.agents;
9479
+ if (project.emit?.harness !== void 0) emit.harness = project.emit.harness;
9480
+ if (project.emit?.commands !== void 0) {
9481
+ emit.commands = project.emit.commands ? config.emit.commands ?? {} : void 0;
9453
9482
  }
9454
- return { ...config, emit };
9483
+ return {
9484
+ ...config,
9485
+ emit,
9486
+ sync_command: project.sync_command ?? config.sync_command,
9487
+ check_command: project.check_command ?? config.check_command
9488
+ };
9455
9489
  }
9456
9490
 
9457
9491
  // src/lib/claude-materialize/workflow-render.ts
9458
9492
  import { resolveSchemaRefs } from "agent-contracts";
9459
- import { pathSegmentForId as pathSegmentForId4, readDslExtension } from "@aaac/contracts";
9493
+ import {
9494
+ claudeSyncReference,
9495
+ pathSegmentForId as pathSegmentForId4,
9496
+ readDslExtension
9497
+ } from "@aaac/contracts";
9460
9498
 
9461
9499
  // src/lib/claude-materialize/dsl-sources.ts
9462
9500
  import { existsSync as existsSync4 } from "fs";
@@ -9484,7 +9522,7 @@ async function resolveDslSources(root, embeddedDsl, config) {
9484
9522
  embeddedDsl,
9485
9523
  dslPath: config.config_path
9486
9524
  });
9487
- const dsl = await resolveNavigationDsl(navigationOptions);
9525
+ const { dsl } = await resolveNavigationDsl(navigationOptions);
9488
9526
  return member === void 0 ? { dsl } : { member, dsl };
9489
9527
  })
9490
9528
  );
@@ -9509,7 +9547,9 @@ function mergeSourceFiles(rendered, conflict) {
9509
9547
  }
9510
9548
 
9511
9549
  // src/lib/claude-materialize/workflow-render.ts
9512
- var GENERATED_MARKER = "// Auto-generated by @aaac/runtime claude-materialize (#235). Do not edit; run `claude sync` instead.";
9550
+ function generatedMarker(commands) {
9551
+ return `// Auto-generated by @aaac/runtime claude-materialize (#235). Do not edit; regenerate with ${claudeSyncReference(commands)} instead.`;
9552
+ }
9513
9553
  var CLAUDE_CODE_ADAPTER = "claude";
9514
9554
  var WorkflowCodegenError = class extends Error {
9515
9555
  constructor(message) {
@@ -9604,12 +9644,10 @@ var GATE_SCHEMA = {
9604
9644
  },
9605
9645
  required: ["approved"]
9606
9646
  };
9607
- function resolveHandoffSchema(task, handoffTypes, components) {
9647
+ function resultHandoffSchema(task, reg) {
9608
9648
  const id = task.result_handoff;
9609
- if (!id) return void 0;
9610
- const ht = handoffTypes[id];
9611
- if (!ht?.schema) return void 0;
9612
- return resolveSchemaRefs(ht.schema, components);
9649
+ if (!id || !Object.prototype.hasOwnProperty.call(reg.handoffSchemas, id)) return void 0;
9650
+ return reg.handoffSchemas[id];
9613
9651
  }
9614
9652
  function toTaskContract(id, raw) {
9615
9653
  return {
@@ -9626,13 +9664,10 @@ function buildRegistries(dsl, modelMapping) {
9626
9664
  const agents = buildAgentRegistry(dsl);
9627
9665
  const tasks = {};
9628
9666
  for (const [id, t] of Object.entries(rawTasks)) tasks[id] = toTaskContract(id, t);
9629
- const componentsRoot = dsl.components ?? {};
9630
- const components = componentsRoot.schemas ?? componentsRoot;
9631
9667
  return {
9632
9668
  agents,
9633
9669
  tasks,
9634
- handoffTypes: dsl.handoff_types ?? {},
9635
- components,
9670
+ handoffSchemas: resolveHandoffSchemas(dsl, resolveSchemaRefs),
9636
9671
  // The runtime's resolver, so a class resolves to the model it runs on when
9637
9672
  // the runtime executes the same step. No environment: `AGENT_RUNTIME_MODEL*`
9638
9673
  // override a run, and a committed artifact that depended on the generating
@@ -9703,28 +9738,125 @@ function priorContextExpr(i, steps, deps) {
9703
9738
  if (fragments.length === 0) return "";
9704
9739
  return fragments.join(" + ");
9705
9740
  }
9706
- function emitWorkflowInputHelper(pad) {
9741
+ function emitWorkflowInputOutputHelper(pad) {
9707
9742
  const id = WORKFLOW_INPUT_STEP_ID;
9708
9743
  return [
9709
- `${pad}const _wfInput = (args) => {`,
9710
- `${pad} if (args === undefined || args === null) return ''`,
9711
- `${pad} let output`,
9712
- `${pad} if (typeof args === 'string') {`,
9713
- `${pad} output = { user_request: args }`,
9714
- `${pad} } else if (typeof args === 'object' && ('user_request' in args || 'handoff' in args)) {`,
9744
+ `${pad}const _wfInputOutput = (args) => {`,
9745
+ `${pad} if (args === undefined || args === null) return undefined`,
9746
+ `${pad} if (typeof args === 'string') return { user_request: args }`,
9747
+ `${pad} if (typeof args === 'object' && ('user_request' in args || 'handoff' in args)) {`,
9715
9748
  `${pad} const h = args.handoff`,
9716
9749
  `${pad} const userRequest = typeof args.user_request === 'string'`,
9717
9750
  `${pad} ? args.user_request`,
9718
9751
  `${pad} : h`,
9719
9752
  `${pad} ? (typeof h.payload === 'string' ? h.payload : JSON.stringify(h.payload, null, 2))`,
9720
9753
  `${pad} : ''`,
9721
- `${pad} output = h`,
9754
+ `${pad} return h`,
9722
9755
  `${pad} ? { user_request: userRequest, handoff: (h.version !== undefined ? { type: h.type, version: h.version, payload: h.payload } : { type: h.type, payload: h.payload }) }`,
9723
9756
  `${pad} : { user_request: userRequest }`,
9724
- `${pad} } else {`,
9725
- `${pad} output = { user_request: JSON.stringify(args, null, 2), handoff: { type: ${jsString(id)}, payload: args } }`,
9726
9757
  `${pad} }`,
9727
- `${pad} return '\\n\\n--- Step: ${id} ---\\n' + JSON.stringify(output, null, 2)`,
9758
+ `${pad} return { user_request: JSON.stringify(args, null, 2), handoff: { type: ${jsString(id)}, payload: args } }`,
9759
+ `${pad}}`
9760
+ ];
9761
+ }
9762
+ function emitWorkflowInputHelper(pad) {
9763
+ const id = WORKFLOW_INPUT_STEP_ID;
9764
+ return [
9765
+ `${pad}const _wfInput = (args) => {`,
9766
+ `${pad} const output = _wfInputOutput(args)`,
9767
+ `${pad} return output === undefined ? '' : '\\n\\n--- Step: ${id} ---\\n' + JSON.stringify(output, null, 2)`,
9768
+ `${pad}}`
9769
+ ];
9770
+ }
9771
+ function emitInputValidation(pad, schemas) {
9772
+ const schemasLiteral = jsLiteral(schemas, 0).replace(/\n/g, `
9773
+ ${pad}`);
9774
+ return [
9775
+ `${pad}const _HANDOFF_SCHEMAS = ${schemasLiteral}`,
9776
+ `${pad}const _isObject = (v) => typeof v === 'object' && v !== null && !Array.isArray(v)`,
9777
+ `${pad}const _shapeOf = (s) => {`,
9778
+ `${pad} if (!_isObject(s) || s.enum || s.const !== undefined) return null`,
9779
+ `${pad} if (s.type === 'object') {`,
9780
+ `${pad} if (!s.properties) return null`,
9781
+ `${pad} const req = new Set(s.required ?? [])`,
9782
+ `${pad} const shape = {}`,
9783
+ `${pad} for (const [k, ps] of Object.entries(s.properties)) shape[k] = { s: ps, required: req.has(k) }`,
9784
+ `${pad} return shape`,
9785
+ `${pad} }`,
9786
+ `${pad} if (['string', 'integer', 'number', 'boolean', 'array'].includes(s.type) || !s.allOf || s.allOf.length === 0) return null`,
9787
+ `${pad} let shape = _shapeOf(s.allOf[0])`,
9788
+ `${pad} if (!shape) return null`,
9789
+ `${pad} for (const part of s.allOf.slice(1)) {`,
9790
+ `${pad} const next = _shapeOf(part)`,
9791
+ `${pad} if (next) shape = { ...shape, ...next }`,
9792
+ `${pad} }`,
9793
+ `${pad} return shape`,
9794
+ `${pad}}`,
9795
+ `${pad}const _conformShape = (shape, v, p) => {`,
9796
+ `${pad} if (!_isObject(v)) return p + ': expected object'`,
9797
+ `${pad} for (const [k, f] of Object.entries(shape)) {`,
9798
+ `${pad} const has = Object.prototype.hasOwnProperty.call(v, k)`,
9799
+ `${pad} if (f.required ? !has : (!has || v[k] === undefined)) {`,
9800
+ `${pad} if (f.required) return p + '.' + k + ': required'`,
9801
+ `${pad} continue`,
9802
+ `${pad} }`,
9803
+ `${pad} const e = _conform(f.s, v[k], p + '.' + k)`,
9804
+ `${pad} if (e) return e`,
9805
+ `${pad} }`,
9806
+ `${pad} return ''`,
9807
+ `${pad}}`,
9808
+ `${pad}const _conform = (s, v, p) => {`,
9809
+ `${pad} if (!_isObject(s)) return ''`,
9810
+ `${pad} if (s.enum) {`,
9811
+ `${pad} if (s.enum.length === 0) return ''`,
9812
+ `${pad} return typeof v === 'string' && s.enum.includes(v) ? '' : p + ': expected one of ' + JSON.stringify(s.enum)`,
9813
+ `${pad} }`,
9814
+ `${pad} if (s.const !== undefined) {`,
9815
+ `${pad} const c = s.const`,
9816
+ `${pad} if (typeof c !== 'string' && typeof c !== 'number' && typeof c !== 'boolean') return ''`,
9817
+ `${pad} return v === c ? '' : p + ': expected ' + JSON.stringify(c)`,
9818
+ `${pad} }`,
9819
+ `${pad} const t = s.type`,
9820
+ `${pad} if (t === 'string') {`,
9821
+ `${pad} if (typeof v !== 'string') return p + ': expected string'`,
9822
+ `${pad} if (typeof s.minLength === 'number' && v.length < s.minLength) return p + ': shorter than ' + s.minLength`,
9823
+ `${pad} if (typeof s.maxLength === 'number' && v.length > s.maxLength) return p + ': longer than ' + s.maxLength`,
9824
+ `${pad} if (typeof s.pattern === 'string' && !new RegExp(s.pattern).test(v)) return p + ': does not match ' + s.pattern`,
9825
+ `${pad} return ''`,
9826
+ `${pad} }`,
9827
+ `${pad} if (t === 'integer' || t === 'number') {`,
9828
+ `${pad} if (typeof v !== 'number' || !Number.isFinite(v) || (t === 'integer' && !Number.isSafeInteger(v))) return p + ': expected ' + t`,
9829
+ `${pad} if (typeof s.minimum === 'number' && v < s.minimum) return p + ': less than ' + s.minimum`,
9830
+ `${pad} if (typeof s.maximum === 'number' && v > s.maximum) return p + ': greater than ' + s.maximum`,
9831
+ `${pad} return ''`,
9832
+ `${pad} }`,
9833
+ `${pad} if (t === 'boolean') return typeof v === 'boolean' ? '' : p + ': expected boolean'`,
9834
+ `${pad} if (t === 'array') {`,
9835
+ `${pad} if (!Array.isArray(v)) return p + ': expected array'`,
9836
+ `${pad} if (s.items) {`,
9837
+ `${pad} for (let i = 0; i < v.length; i++) {`,
9838
+ `${pad} const e = _conform(s.items, v[i], p + '[' + i + ']')`,
9839
+ `${pad} if (e) return e`,
9840
+ `${pad} }`,
9841
+ `${pad} }`,
9842
+ `${pad} if (typeof s.minItems === 'number' && v.length < s.minItems) return p + ': fewer than ' + s.minItems + ' items'`,
9843
+ `${pad} if (typeof s.maxItems === 'number' && v.length > s.maxItems) return p + ': more than ' + s.maxItems + ' items'`,
9844
+ `${pad} return ''`,
9845
+ `${pad} }`,
9846
+ `${pad} if (t === 'object') {`,
9847
+ `${pad} if (!_isObject(v)) return p + ': expected object'`,
9848
+ `${pad} return s.properties ? _conformShape(_shapeOf(s), v, p) : ''`,
9849
+ `${pad} }`,
9850
+ `${pad} if (!s.allOf || s.allOf.length === 0) return ''`,
9851
+ `${pad} const shape = _shapeOf(s)`,
9852
+ `${pad} return shape ? _conformShape(shape, v, p) : _conform(s.allOf[0], v, p)`,
9853
+ `${pad}}`,
9854
+ `${pad}{`,
9855
+ `${pad} const h = _wfInputOutput(args)?.handoff`,
9856
+ `${pad} if (h && Object.prototype.hasOwnProperty.call(_HANDOFF_SCHEMAS, h.type)) {`,
9857
+ `${pad} const e = _conform(_HANDOFF_SCHEMAS[h.type], h.payload, 'payload')`,
9858
+ `${pad} if (e) throw new Error('Input handoff validation failed for "' + h.type + '": ' + e)`,
9859
+ `${pad} }`,
9728
9860
  `${pad}}`
9729
9861
  ];
9730
9862
  }
@@ -9762,7 +9894,7 @@ function resolveStepAgentTask(step, reg, kind) {
9762
9894
  function emitDelegateExpr(step, reg, i, steps, deps, indent, feedback) {
9763
9895
  const { agent, task } = resolveStepAgentTask(step, reg, "delegate");
9764
9896
  const prompt = renderDelegatePrompt(agent, task, step);
9765
- const schema = resolveHandoffSchema(task, reg.handoffTypes, reg.components);
9897
+ const schema = resultHandoffSchema(task, reg);
9766
9898
  const promptExpr = withPriorContext(jsLiteral(prompt), priorContextExpr(i, steps, deps), feedback);
9767
9899
  const opts = agentOpts(task, step, reg, schema, indent);
9768
9900
  return `agent(${promptExpr}, ${opts})`;
@@ -9807,7 +9939,7 @@ ${pad} `)},`);
9807
9939
  function emitEvaluateAgentCall(step, reg, i, steps, deps, pad, feedback) {
9808
9940
  const { agent, task } = resolveStepAgentTask(step, reg, "evaluate");
9809
9941
  const prompt = renderDelegatePrompt(agent, task, step);
9810
- const schema = resolveHandoffSchema(task, reg.handoffTypes, reg.components);
9942
+ const schema = resultHandoffSchema(task, reg);
9811
9943
  const promptExpr = withPriorContext(jsLiteral(prompt), priorContextExpr(i, steps, deps), feedback);
9812
9944
  const opts = {};
9813
9945
  if (schema) opts.schema = schema;
@@ -9896,7 +10028,7 @@ function assertInScope(step) {
9896
10028
  throw new WorkflowCodegenError(`Unknown workflow step type "${step.type}"`);
9897
10029
  }
9898
10030
  }
9899
- function renderWorkflowScript(id, wf, dsl, modelMapping) {
10031
+ function renderWorkflowScript(id, wf, dsl, modelMapping, commands) {
9900
10032
  const reg = buildRegistries(dsl, modelMapping);
9901
10033
  const steps = wf.steps ?? [];
9902
10034
  for (const step of steps) assertInScope(step);
@@ -9923,15 +10055,22 @@ function renderWorkflowScript(id, wf, dsl, modelMapping) {
9923
10055
  const usesWorkflowInput = steps.some(
9924
10056
  (step) => stepDependsOnWorkflowInput(step.depends_on)
9925
10057
  );
10058
+ const validatesInput = Object.keys(reg.handoffSchemas).length > 0;
9926
10059
  const body = [];
9927
10060
  if (usesStepContext) {
9928
10061
  body.push(
9929
10062
  " const _ctx = (n, id, r) => '\\n\\n--- Step ' + n + ': ' + id + ' ---\\n' + (typeof r === 'string' ? r : JSON.stringify(r, null, 2))"
9930
10063
  );
9931
10064
  }
10065
+ if (usesWorkflowInput || validatesInput) {
10066
+ body.push(...emitWorkflowInputOutputHelper(" "));
10067
+ }
9932
10068
  if (usesWorkflowInput) {
9933
10069
  body.push(...emitWorkflowInputHelper(" "));
9934
10070
  }
10071
+ if (validatesInput) {
10072
+ body.push(...emitInputValidation(" ", reg.handoffSchemas));
10073
+ }
9935
10074
  const emittedWaves = /* @__PURE__ */ new Set();
9936
10075
  for (let i = 0; i < steps.length; i++) {
9937
10076
  if (spanOwner.has(i) && spanOwner.get(i) !== i) continue;
@@ -9966,14 +10105,14 @@ function renderWorkflowScript(id, wf, dsl, modelMapping) {
9966
10105
  body.push(" return { completed: true, workflow: " + jsString(id) + " }");
9967
10106
  const metaLiteral = jsLiteral(meta, 0);
9968
10107
  const topLevelBody = body.map((line) => line.startsWith(" ") ? line.slice(2) : line).join("\n");
9969
- return `${GENERATED_MARKER}
10108
+ return `${generatedMarker(commands)}
9970
10109
 
9971
10110
  export const meta = ${metaLiteral}
9972
10111
 
9973
10112
  ${topLevelBody}
9974
10113
  `;
9975
10114
  }
9976
- function renderWorkflowFiles(sources, outputDir, modelMapping) {
10115
+ function renderWorkflowFiles(sources, outputDir, modelMapping, commands) {
9977
10116
  const dir = workflowsDirFor(outputDir);
9978
10117
  return mergeSourceFiles(
9979
10118
  sources.map((source) => ({
@@ -9982,7 +10121,7 @@ function renderWorkflowFiles(sources, outputDir, modelMapping) {
9982
10121
  source.dsl.workflow ?? {}
9983
10122
  ).map(([id, wf]) => ({
9984
10123
  path: `${dir}/${pathSegmentForId4("workflow id", id)}${WORKFLOW_FILE_EXT}`,
9985
- content: renderWorkflowScript(id, wf, source.dsl, modelMapping)
10124
+ content: renderWorkflowScript(id, wf, source.dsl, modelMapping, commands)
9986
10125
  }))
9987
10126
  })),
9988
10127
  (message) => new WorkflowCodegenError(message)
@@ -10078,7 +10217,7 @@ function renderCommandFiles(sources, outputTemplate, templateSource) {
10078
10217
  }
10079
10218
 
10080
10219
  // src/lib/claude-materialize/agent-render.ts
10081
- import { pathSegmentForId as pathSegmentForId6 } from "@aaac/contracts";
10220
+ import { claudeSyncReference as claudeSyncReference2, pathSegmentForId as pathSegmentForId6 } from "@aaac/contracts";
10082
10221
  var AgentCodegenError = class extends Error {
10083
10222
  constructor(message) {
10084
10223
  super(message);
@@ -10088,7 +10227,9 @@ var AgentCodegenError = class extends Error {
10088
10227
  var AGENTS_SUBDIR = "agents";
10089
10228
  var AGENT_FILE_EXT = ".md";
10090
10229
  var AGENT_NAME_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
10091
- var GENERATED_MARKER2 = "<!-- Auto-generated from the agent-contracts DSL. Do not edit; run `claude sync`. -->";
10230
+ function generatedMarker2(commands) {
10231
+ return `<!-- Auto-generated from the agent-contracts DSL. Do not edit; regenerate with ${claudeSyncReference2(commands)}. -->`;
10232
+ }
10092
10233
  function agentsDirFor(outputDir) {
10093
10234
  return `${outputDir.replace(/\/+$/, "")}/${AGENTS_SUBDIR}`;
10094
10235
  }
@@ -10133,7 +10274,7 @@ function agentDescription(agent) {
10133
10274
  function renderAgentBody(agent) {
10134
10275
  return [renderAgentSystemPrompt(agent), ...permissionSections(agent)].join("\n\n").replace(/\s+$/, "");
10135
10276
  }
10136
- function renderAgentFile(name, agent) {
10277
+ function renderAgentFile(name, agent, commands) {
10137
10278
  const frontmatter = renderFrontmatter([
10138
10279
  // `name` is validated against AGENT_NAME_PATTERN, so it is always a plain
10139
10280
  // YAML scalar and needs no quoting. `description` is arbitrary DSL prose.
@@ -10142,7 +10283,7 @@ function renderAgentFile(name, agent) {
10142
10283
  // The Claude Code tool grant follows the contract, never the DSL tool ids.
10143
10284
  ["tools", toolGrantForAgent(agent).join(", ")]
10144
10285
  ]);
10145
- const body = [GENERATED_MARKER2, renderAgentBody(agent)].join("\n\n");
10286
+ const body = [generatedMarker2(commands), renderAgentBody(agent)].join("\n\n");
10146
10287
  return `${frontmatter}
10147
10288
  ${body}
10148
10289
  `;
@@ -10170,7 +10311,7 @@ function mergeAgents(sources, dir) {
10170
10311
  }
10171
10312
  return merged;
10172
10313
  }
10173
- function renderAgentFiles(sources, outputDir) {
10314
+ function renderAgentFiles(sources, outputDir, commands) {
10174
10315
  const dir = agentsDirFor(outputDir);
10175
10316
  const files = [];
10176
10317
  for (const [name, { agent, origin }] of mergeAgents(sources, dir)) {
@@ -10182,7 +10323,7 @@ function renderAgentFiles(sources, outputDir) {
10182
10323
  }
10183
10324
  files.push({
10184
10325
  path: `${dir}/${pathSegmentForId6("agent id", name)}${AGENT_FILE_EXT}`,
10185
- content: renderAgentFile(name, agent)
10326
+ content: renderAgentFile(name, agent, commands)
10186
10327
  });
10187
10328
  }
10188
10329
  return files.sort((a, b) => a.path < b.path ? -1 : a.path > b.path ? 1 : 0);
@@ -10206,6 +10347,7 @@ import {
10206
10347
 
10207
10348
  // src/lib/claude-materialize/bundle-bins.ts
10208
10349
  import {
10350
+ claudeSyncReference as claudeSyncReference3,
10209
10351
  isHookBinChunk
10210
10352
  } from "@aaac/contracts";
10211
10353
  import { createHash } from "crypto";
@@ -10307,7 +10449,7 @@ function withMarker(bodyWithoutMarker) {
10307
10449
  const firstNl = bodyWithoutMarker.indexOf("\n");
10308
10450
  return bodyWithoutMarker.slice(0, firstNl + 1) + markerFor(bodyWithoutMarker) + "\n" + bodyWithoutMarker.slice(firstNl + 1);
10309
10451
  }
10310
- function assembleHookBin(source, kind) {
10452
+ function assembleHookBin(source, kind, commands) {
10311
10453
  const withoutShebang = source.replace(/^#![^\n]*\n/, "");
10312
10454
  const match = requireRuntimeImport(withoutShebang);
10313
10455
  const binBody = withoutShebang.replace(
@@ -10317,21 +10459,21 @@ function assembleHookBin(source, kind) {
10317
10459
  return withMarker(
10318
10460
  [
10319
10461
  "#!/usr/bin/env node",
10320
- "// Auto-generated by @aaac/runtime claude sync (#241). Do not edit \u2014 self-contained bundle.",
10462
+ `// Auto-generated by @aaac/runtime. Do not edit \u2014 self-contained bundle; regenerate with ${claudeSyncReference3(commands)}.`,
10321
10463
  binBody.trimStart()
10322
10464
  ].join("\n")
10323
10465
  );
10324
10466
  }
10325
- function assembleRuntimeChunk(kind) {
10467
+ function assembleRuntimeChunk(kind, commands) {
10326
10468
  return withMarker(
10327
10469
  [
10328
- `// Auto-generated by @aaac/runtime claude sync (#278). Do not edit \u2014 shared ${kind} runtime chunk.`,
10470
+ `// Auto-generated by @aaac/runtime. Do not edit \u2014 shared ${kind} runtime chunk; regenerate with ${claudeSyncReference3(commands)}.`,
10329
10471
  readPrebuiltBundle(kind).trimEnd(),
10330
10472
  ""
10331
10473
  ].join("\n")
10332
10474
  );
10333
10475
  }
10334
- function withAssembledHookBins(files) {
10476
+ function withAssembledHookBins(files, commands) {
10335
10477
  const out = [];
10336
10478
  const needed = /* @__PURE__ */ new Set();
10337
10479
  for (const file of files) {
@@ -10345,13 +10487,13 @@ function withAssembledHookBins(files) {
10345
10487
  }
10346
10488
  const kind = bundleKindFor(file.content);
10347
10489
  needed.add(kind);
10348
- out.push({ ...file, content: assembleHookBin(file.content, kind) });
10490
+ out.push({ ...file, content: assembleHookBin(file.content, kind, commands) });
10349
10491
  }
10350
10492
  for (const kind of BUNDLE_KINDS) {
10351
10493
  if (!needed.has(kind)) continue;
10352
10494
  out.push({
10353
10495
  path: chunkFileName(kind),
10354
- content: assembleRuntimeChunk(kind),
10496
+ content: assembleRuntimeChunk(kind, commands),
10355
10497
  overwrite: true,
10356
10498
  targetDir: HOOK_BIN_DIR
10357
10499
  });
@@ -10517,11 +10659,12 @@ async function readIfExists(path) {
10517
10659
  if (!existsSync5(path)) return void 0;
10518
10660
  return readFile5(path, "utf8");
10519
10661
  }
10520
- async function renderFiles(root, dsl, config, entryAgentPrompt) {
10662
+ async function renderFiles(root, dsl, config, entryAgentPrompt, protectsArtifacts) {
10521
10663
  if (!config.emit.harness) return [];
10522
10664
  const ir = buildComponentIR(dsl, config);
10523
10665
  const members = await workspaceMembersForProject(root);
10524
10666
  const workspaceOptions = members.length > 0 ? { members } : void 0;
10667
+ const harnessCommands = harnessCommandsFor(config);
10525
10668
  return withAssembledHookBins(
10526
10669
  claudeGenerator.generate(ir, {
10527
10670
  outputDir: "",
@@ -10534,8 +10677,12 @@ async function renderFiles(root, dsl, config, entryAgentPrompt) {
10534
10677
  // subagent file, so the CLAUDE.md block is where its prompt reaches
10535
10678
  // Claude (#345). Resolved by the caller from the SAME merge that produced
10536
10679
  // the subagent files.
10537
- entryAgentPrompt
10538
- })
10680
+ entryAgentPrompt,
10681
+ harnessCommands,
10682
+ // Whether the block may say the edit guard protects anything.
10683
+ protectsArtifacts
10684
+ }),
10685
+ harnessCommands
10539
10686
  );
10540
10687
  }
10541
10688
  function mergeClaudeMdBlock(existing, block) {
@@ -10612,7 +10759,7 @@ function checkContent(file, existing) {
10612
10759
  }
10613
10760
  function workflowFiles(sources, config, modelMapping) {
10614
10761
  if (!config.emit.workflows) return [];
10615
- return renderWorkflowFiles(sources, config.output_dir, modelMapping);
10762
+ return renderWorkflowFiles(sources, config.output_dir, modelMapping, harnessCommandsFor(config));
10616
10763
  }
10617
10764
  function commandOutputTemplate(config) {
10618
10765
  const commands = config.emit.commands;
@@ -10632,12 +10779,19 @@ async function commandFiles(sources, config, root) {
10632
10779
  }
10633
10780
  function agentFiles(sources, config) {
10634
10781
  if (!config.emit.agents) return [];
10635
- return renderAgentFiles(sources, config.output_dir);
10782
+ return renderAgentFiles(sources, config.output_dir, harnessCommandsFor(config));
10636
10783
  }
10637
10784
  function entryAgentPromptFor(sources, config) {
10638
10785
  if (!config.emit.agents) return void 0;
10639
10786
  return renderEntryAgentPrompt(sources, config.output_dir);
10640
10787
  }
10788
+ function protectsAnyArtifact(sources) {
10789
+ return sources.some(
10790
+ (source) => Object.values(source.dsl.artifacts ?? {}).some(
10791
+ (artifact) => typeof artifact === "object" && artifact !== null && editProtection(artifact) !== void 0
10792
+ )
10793
+ );
10794
+ }
10641
10795
  async function isOwnedHookBinFile(_name, absPath2) {
10642
10796
  const content = await readIfExists(absPath2).catch(() => void 0);
10643
10797
  return content !== void 0 && readBundleMarker(content) !== void 0;
@@ -10729,7 +10883,7 @@ function effectiveClaudeInputs(root, raw) {
10729
10883
  if (!existsSync5(manifestPath)) return { config, modelMapping: {} };
10730
10884
  const manifest = readProjectManifest(manifestPath);
10731
10885
  return {
10732
- config: applyProjectEmit(config, manifest.bindings?.claude?.emit),
10886
+ config: applyProjectBinding(config, manifest.bindings?.claude),
10733
10887
  modelMapping: manifest.model_mapping
10734
10888
  };
10735
10889
  }
@@ -10738,7 +10892,13 @@ async function syncClaude(opts) {
10738
10892
  const { config, modelMapping } = effectiveClaudeInputs(root, opts.config);
10739
10893
  const result = { files: [] };
10740
10894
  const sources = await resolveDslSources(root, opts.dsl, config);
10741
- const rendered = await renderFiles(root, opts.dsl, config, entryAgentPromptFor(sources, config));
10895
+ const rendered = await renderFiles(
10896
+ root,
10897
+ opts.dsl,
10898
+ config,
10899
+ entryAgentPromptFor(sources, config),
10900
+ protectsAnyArtifact(sources)
10901
+ );
10742
10902
  for (const file of rendered) {
10743
10903
  const rel = generatedFileRelPath(file);
10744
10904
  const abs = absPath(root, file);
@@ -10803,7 +10963,13 @@ async function checkClaude(opts) {
10803
10963
  const { config, modelMapping } = effectiveClaudeInputs(root, opts.config);
10804
10964
  const drift = [];
10805
10965
  const sources = await resolveDslSources(root, opts.dsl, config);
10806
- const rendered = await renderFiles(root, opts.dsl, config, entryAgentPromptFor(sources, config));
10966
+ const rendered = await renderFiles(
10967
+ root,
10968
+ opts.dsl,
10969
+ config,
10970
+ entryAgentPromptFor(sources, config),
10971
+ protectsAnyArtifact(sources)
10972
+ );
10807
10973
  for (const file of rendered) {
10808
10974
  const rel = generatedFileRelPath(file);
10809
10975
  const abs = absPath(root, file);