intentdna 1.9.0 → 1.9.3

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 (131) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/README.md +227 -87
  4. package/dist/cli/commands/run-lifecycle.d.ts +61 -11
  5. package/dist/cli/commands/run-lifecycle.js +184 -50
  6. package/dist/cli/commands/run-observer.d.ts +15 -0
  7. package/dist/cli/commands/run-observer.js +210 -0
  8. package/dist/cli/commands/run.d.ts +16 -20
  9. package/dist/cli/commands/run.js +461 -659
  10. package/dist/cli/commands/sync.js +16 -12
  11. package/dist/cli/index.js +14 -5
  12. package/dist/compiler/compile.d.ts +1 -0
  13. package/dist/compiler/compile.js +1 -1
  14. package/dist/compiler/controller.d.ts +16 -0
  15. package/dist/compiler/controller.js +693 -0
  16. package/dist/compiler/input-resolver.d.ts +2 -0
  17. package/dist/compiler/input-resolver.js +22 -6
  18. package/dist/hooks/cli.d.ts +45 -0
  19. package/dist/hooks/cli.js +263 -31
  20. package/dist/hooks/host-event.d.ts +57 -0
  21. package/dist/hooks/host-event.js +187 -0
  22. package/dist/hooks/index.d.ts +1 -0
  23. package/dist/hooks/index.js +1 -0
  24. package/dist/hooks/protocol.d.ts +7 -0
  25. package/dist/hooks/schema.d.ts +1 -0
  26. package/dist/hooks/schema.js +89 -1
  27. package/dist/hooks/state.d.ts +23 -1
  28. package/dist/hooks/state.js +9 -0
  29. package/dist/index.d.ts +1 -0
  30. package/dist/index.js +1 -0
  31. package/dist/mcp/index.js +2 -0
  32. package/dist/mcp/tools-run.d.ts +4 -0
  33. package/dist/mcp/tools-run.js +419 -0
  34. package/dist/mcp/tools-state.d.ts +1 -1
  35. package/dist/mcp/tools-state.js +13 -241
  36. package/dist/runtime/artifact-store.d.ts +146 -0
  37. package/dist/runtime/artifact-store.js +1436 -0
  38. package/dist/runtime/canonical-attempt-outcome.d.ts +12 -0
  39. package/dist/runtime/canonical-attempt-outcome.js +195 -0
  40. package/dist/runtime/canonical-json.d.ts +10 -0
  41. package/dist/runtime/canonical-json.js +105 -0
  42. package/dist/runtime/canonical-run-application.d.ts +93 -0
  43. package/dist/runtime/canonical-run-application.js +229 -0
  44. package/dist/runtime/canonical-run-service.d.ts +454 -0
  45. package/dist/runtime/canonical-run-service.js +4760 -0
  46. package/dist/runtime/canonical-runtime-composition.d.ts +22 -0
  47. package/dist/runtime/canonical-runtime-composition.js +34 -0
  48. package/dist/runtime/canonical-runtime-projection.d.ts +3 -0
  49. package/dist/runtime/canonical-runtime-projection.js +4 -0
  50. package/dist/runtime/canonical-target-compiler.d.ts +46 -0
  51. package/dist/runtime/canonical-target-compiler.js +514 -0
  52. package/dist/runtime/claude-agent-identity.d.ts +2 -0
  53. package/dist/runtime/claude-agent-identity.js +21 -0
  54. package/dist/runtime/executable-run-plan.d.ts +328 -0
  55. package/dist/runtime/executable-run-plan.js +1485 -0
  56. package/dist/runtime/execution-authority.d.ts +83 -0
  57. package/dist/runtime/execution-authority.js +98 -0
  58. package/dist/runtime/handoff-resolver.js +4 -1
  59. package/dist/runtime/harness-pull-adapter.d.ts +146 -0
  60. package/dist/runtime/harness-pull-adapter.js +315 -0
  61. package/dist/runtime/index.d.ts +39 -14
  62. package/dist/runtime/index.js +29 -7
  63. package/dist/runtime/local-execution-authority.d.ts +194 -0
  64. package/dist/runtime/local-execution-authority.js +2897 -0
  65. package/dist/runtime/local-execution-reconciliation.d.ts +20 -0
  66. package/dist/runtime/local-execution-reconciliation.js +107 -0
  67. package/dist/runtime/local-execution-supervisor-script.d.ts +7 -0
  68. package/dist/runtime/local-execution-supervisor-script.js +793 -0
  69. package/dist/runtime/local-provider-sandbox.d.ts +42 -0
  70. package/dist/runtime/local-provider-sandbox.js +154 -0
  71. package/dist/runtime/local-verifier-execution.d.ts +24 -0
  72. package/dist/runtime/local-verifier-execution.js +290 -0
  73. package/dist/runtime/local-windows-execution-supervisor-script.d.ts +6 -0
  74. package/dist/runtime/local-windows-execution-supervisor-script.js +788 -0
  75. package/dist/runtime/plan-store.d.ts +30 -0
  76. package/dist/runtime/plan-store.js +231 -0
  77. package/dist/runtime/process-tree.d.ts +9 -0
  78. package/dist/runtime/process-tree.js +97 -24
  79. package/dist/runtime/providers/codex.js +2 -2
  80. package/dist/runtime/push-driver.d.ts +184 -0
  81. package/dist/runtime/push-driver.js +1002 -0
  82. package/dist/runtime/result-store.d.ts +34 -3
  83. package/dist/runtime/result-store.js +1073 -2
  84. package/dist/runtime/run-binding.d.ts +68 -0
  85. package/dist/runtime/run-binding.js +278 -0
  86. package/dist/runtime/run-contracts.d.ts +575 -0
  87. package/dist/runtime/run-contracts.js +58 -7
  88. package/dist/runtime/run-controller.d.ts +1 -6
  89. package/dist/runtime/run-controller.js +0 -41
  90. package/dist/runtime/run-store.d.ts +85 -7
  91. package/dist/runtime/run-store.js +2528 -186
  92. package/dist/runtime/skill-adapter.d.ts +18 -7
  93. package/dist/runtime/skill-adapter.js +100 -742
  94. package/dist/runtime/structured-output-validator.d.ts +44 -0
  95. package/dist/runtime/structured-output-validator.js +171 -0
  96. package/dist/runtime/verifier-command-binding.d.ts +22 -0
  97. package/dist/runtime/verifier-command-binding.js +162 -0
  98. package/dist/runtime/verifier.d.ts +46 -6
  99. package/dist/runtime/verifier.js +355 -53
  100. package/dist/runtime/windows-job-keeper.d.ts +47 -0
  101. package/dist/runtime/windows-job-keeper.js +231 -0
  102. package/dist/runtime/worker-executor.d.ts +17 -1
  103. package/dist/runtime/worker-executor.js +26 -5
  104. package/dist/runtime/workflow-plan-adapter.d.ts +19 -0
  105. package/dist/runtime/workflow-plan-adapter.js +502 -6
  106. package/dist/runtime/workflow-runtime-manifest.d.ts +1 -0
  107. package/dist/runtime/workflow-runtime-manifest.js +5 -0
  108. package/dist/runtime/workspace-isolation.d.ts +29 -2
  109. package/dist/runtime/workspace-isolation.js +488 -11
  110. package/dist/runtime/workspace-observation.d.ts +44 -0
  111. package/dist/runtime/workspace-observation.js +216 -0
  112. package/dist/schema/controller-registry.d.ts +0 -7
  113. package/dist/schema/controller-registry.js +0 -8
  114. package/dist/schema/types.d.ts +84 -10
  115. package/dist/schema/types.js +2 -0
  116. package/dist/schema/validate.js +151 -1
  117. package/dist/schema/validators/controllers.d.ts +1 -1
  118. package/dist/schema/validators/controllers.js +126 -41
  119. package/dist/schema/workflow-authoring-contract.js +2 -0
  120. package/dist/schema/yaml-parser.js +1 -1
  121. package/dist/templates/flutter-rewrite-new.dna.yaml +1 -0
  122. package/dist/templates/flutter-rewrite.dna.yaml +87 -60
  123. package/dist/templates/safe-refactoring.dna.yaml +1 -0
  124. package/native/windows-job-keeper/README.md +80 -0
  125. package/native/windows-job-keeper/bin/aarch64/intentdna-windows-job-keeper.exe +0 -0
  126. package/native/windows-job-keeper/bin/x86_64/intentdna-windows-job-keeper.exe +0 -0
  127. package/native/windows-job-keeper/keeper.c +979 -0
  128. package/native/windows-job-keeper/manifest.json +33 -0
  129. package/package.json +6 -2
  130. package/scripts/build-windows-job-keeper.mjs +172 -0
  131. package/scripts/verify-windows-job-keeper.mjs +184 -0
@@ -1,3 +1,4 @@
1
+ import { CONTROLLER_RUNTIME_PROGRAM_SCHEMA_VERSION, } from "../types.js";
1
2
  import { CONTROLLER_ROLE_KEYS, getControllerKindMetadata, isSupportedControllerKind } from "../controller-registry.js";
2
3
  function isSafeControllerArtifactPath(path) {
3
4
  return path.startsWith(".dna/") &&
@@ -14,46 +15,6 @@ function isSafeGeneratedIdentifier(value) {
14
15
  function isSafeGeneratedDisplayName(value) {
15
16
  return /^[A-Za-z0-9][A-Za-z0-9 _-]*$/.test(value) && !value.includes("..");
16
17
  }
17
- function validateStringList(value, path, errors) {
18
- if (!Array.isArray(value)) {
19
- errors.push({ path, message: "must be an array of non-empty strings" });
20
- return;
21
- }
22
- value.forEach((item, index) => {
23
- if (typeof item !== "string" || item.trim() === "") {
24
- errors.push({ path: `${path}.${index}`, message: "must be a non-empty string" });
25
- }
26
- });
27
- }
28
- function validateControllerPolicy(policy, path, errors) {
29
- if (typeof policy !== "object" || policy === null || Array.isArray(policy)) {
30
- errors.push({ path, message: "policy must be an object" });
31
- return;
32
- }
33
- const record = policy;
34
- const listFields = [
35
- "diagnosis_reuse_criteria",
36
- "progress_provenance_checks",
37
- "verdict_branches",
38
- "verdict_mapping",
39
- "stop_report",
40
- "constraints",
41
- ];
42
- const allowedFields = new Set([...listFields, "progress_provenance_failure"]);
43
- for (const field of Object.keys(record)) {
44
- if (!allowedFields.has(field)) {
45
- errors.push({ path: `${path}.${field}`, message: "unknown controller policy field" });
46
- }
47
- }
48
- for (const field of listFields) {
49
- if (record[field] !== undefined)
50
- validateStringList(record[field], `${path}.${field}`, errors);
51
- }
52
- if (record.progress_provenance_failure !== undefined &&
53
- (typeof record.progress_provenance_failure !== "string" || record.progress_provenance_failure.trim() === "")) {
54
- errors.push({ path: `${path}.progress_provenance_failure`, message: "must be a non-empty string" });
55
- }
56
- }
57
18
  function validateControllerWorkflowRoles(workflow, roleEntries, path, errors) {
58
19
  if (!workflow)
59
20
  return;
@@ -69,6 +30,120 @@ function validateControllerWorkflowRoles(workflow, roleEntries, path, errors) {
69
30
  }
70
31
  }
71
32
  }
33
+ function validateRuntimeDecision(decision, workflow, path, errors) {
34
+ if (!decision || typeof decision !== "object" || Array.isArray(decision)) {
35
+ errors.push({ path, message: "must be a typed controller decision" });
36
+ return;
37
+ }
38
+ for (const field of ["step_id", "output_name", "schema_ref", "json_pointer"]) {
39
+ if (typeof decision[field] !== "string" || decision[field].trim() === "") {
40
+ errors.push({ path: `${path}.${field}`, message: "must be a non-empty string" });
41
+ }
42
+ }
43
+ if (decision.json_pointer && !decision.json_pointer.startsWith("/")) {
44
+ errors.push({ path: `${path}.json_pointer`, message: "must be an RFC 6901 JSON pointer" });
45
+ }
46
+ const step = workflow?.steps.find((candidate) => candidate.id === decision.step_id);
47
+ if (workflow && !step) {
48
+ errors.push({ path: `${path}.step_id`, message: `references unknown workflow step '${decision.step_id}'` });
49
+ return;
50
+ }
51
+ const output = [
52
+ ...(step?.handoff?.produces ?? []),
53
+ ...(step?.canonical_runtime?.outputs ?? []),
54
+ ].find((candidate) => ((candidate.artifact_id ?? candidate.name ?? candidate.path) === decision.output_name));
55
+ if (step && (!output || output.type !== "state")) {
56
+ errors.push({ path: `${path}.output_name`, message: "must reference one structured state output produced by the decision step" });
57
+ }
58
+ else if (output && output.schema_ref !== decision.schema_ref) {
59
+ errors.push({ path: `${path}.schema_ref`, message: "must match the structured state output schema_ref" });
60
+ }
61
+ }
62
+ function validateRuntimeProgram(controller, diagnosisWorkflow, fixWorkflow, path, errors) {
63
+ const program = controller.runtime_program;
64
+ if (program === undefined)
65
+ return;
66
+ if (typeof program !== "object" || program === null || Array.isArray(program)) {
67
+ errors.push({ path, message: "runtime_program must be an object" });
68
+ return;
69
+ }
70
+ if (program.schema_version !== CONTROLLER_RUNTIME_PROGRAM_SCHEMA_VERSION) {
71
+ errors.push({ path: `${path}.schema_version`, message: `must equal '${CONTROLLER_RUNTIME_PROGRAM_SCHEMA_VERSION}'` });
72
+ }
73
+ const validateStep = (workflow, stepId, stepPath) => {
74
+ if (typeof stepId !== "string" || stepId.trim() === "") {
75
+ errors.push({ path: stepPath, message: "must be a non-empty string" });
76
+ }
77
+ else if (workflow && !workflow.steps.some((step) => step.id === stepId)) {
78
+ errors.push({ path: stepPath, message: `references unknown workflow step '${stepId}'` });
79
+ }
80
+ };
81
+ validateStep(diagnosisWorkflow, program.diagnosis?.analyzer_step_id, `${path}.diagnosis.analyzer_step_id`);
82
+ validateStep(diagnosisWorkflow, program.diagnosis?.reviewer_step_id, `${path}.diagnosis.reviewer_step_id`);
83
+ validateRuntimeDecision(program.diagnosis?.decision, diagnosisWorkflow, `${path}.diagnosis.decision`, errors);
84
+ validateStep(fixWorkflow, program.fix?.surgeon_step_id, `${path}.fix.surgeon_step_id`);
85
+ validateStep(fixWorkflow, program.fix?.reviewer_step_id, `${path}.fix.reviewer_step_id`);
86
+ validateStep(fixWorkflow, program.fix?.verifier_step_id, `${path}.fix.verifier_step_id`);
87
+ validateRuntimeDecision(program.fix?.decision, fixWorkflow, `${path}.fix.decision`, errors);
88
+ const verdictFields = [
89
+ [program.diagnosis?.approved_value, `${path}.diagnosis.approved_value`],
90
+ [program.diagnosis?.request_changes_value, `${path}.diagnosis.request_changes_value`],
91
+ [program.fix?.pass_value, `${path}.fix.pass_value`],
92
+ [program.fix?.continue_value, `${path}.fix.continue_value`],
93
+ [program.fix?.request_changes_value, `${path}.fix.request_changes_value`],
94
+ [program.fix?.blocked_value, `${path}.fix.blocked_value`],
95
+ [program.fix?.diagnosis_contract_invalid_value, `${path}.fix.diagnosis_contract_invalid_value`],
96
+ [program.fix?.provenance_invalid_value, `${path}.fix.provenance_invalid_value`],
97
+ ];
98
+ for (const [value, valuePath] of verdictFields) {
99
+ if (typeof value !== "string" || value.trim() === "") {
100
+ errors.push({ path: valuePath, message: "must be a non-empty string" });
101
+ }
102
+ }
103
+ if (program.reuse !== undefined) {
104
+ const validateIdentifier = (value, valuePath) => {
105
+ if (typeof value !== "string" || !isSafeGeneratedIdentifier(value)) {
106
+ errors.push({ path: valuePath, message: "must be a safe non-empty identifier" });
107
+ }
108
+ };
109
+ const reuse = program.reuse;
110
+ validateIdentifier(reuse.mode_input, `${path}.reuse.mode_input`);
111
+ for (const field of [
112
+ "diagnosis_spec_reference_input",
113
+ "diagnosis_spec_digest_input",
114
+ "diagnosis_contract_reference_input",
115
+ "diagnosis_contract_digest_input",
116
+ ]) {
117
+ validateIdentifier(reuse.legacy?.[field], `${path}.reuse.legacy.${field}`);
118
+ }
119
+ for (const field of [
120
+ "source_plan_input",
121
+ "diagnosis_result_input",
122
+ "review_result_input",
123
+ ]) {
124
+ validateIdentifier(reuse.canonical?.[field], `${path}.reuse.canonical.${field}`);
125
+ }
126
+ const approval = reuse.canonical?.approval_reuse;
127
+ if (approval?.enabled !== true) {
128
+ errors.push({ path: `${path}.reuse.canonical.approval_reuse.enabled`, message: "must be true when canonical approval reuse is declared" });
129
+ }
130
+ validateIdentifier(approval?.policy_id, `${path}.reuse.canonical.approval_reuse.policy_id`);
131
+ if (approval?.require_exact_artifact_ids !== true) {
132
+ errors.push({ path: `${path}.reuse.canonical.approval_reuse.require_exact_artifact_ids`, message: "must be true" });
133
+ }
134
+ if (approval?.require_exact_artifact_digests !== true) {
135
+ errors.push({ path: `${path}.reuse.canonical.approval_reuse.require_exact_artifact_digests`, message: "must be true" });
136
+ }
137
+ for (const field of [
138
+ "diagnosis_spec",
139
+ "diagnosis_contract",
140
+ "diagnosis_review",
141
+ "diagnosis_review_verdict",
142
+ ]) {
143
+ validateIdentifier(reuse.outputs?.[field], `${path}.reuse.outputs.${field}`);
144
+ }
145
+ }
146
+ }
72
147
  export function validateController(controller, roleNames, workflows, path) {
73
148
  const errors = [];
74
149
  if (!controller.name) {
@@ -168,7 +243,17 @@ export function validateController(controller, roleNames, workflows, path) {
168
243
  errors.push({ path: `${path}.stop_format`, message: "stop_format must be 'configured_stop_report' or legacy 'zh_three_part'" });
169
244
  }
170
245
  if (controller.policy !== undefined) {
171
- validateControllerPolicy(controller.policy, `${path}.policy`, errors);
246
+ errors.push({
247
+ path: `${path}.policy`,
248
+ message: "legacy string policy is unsupported; use runtime_program",
249
+ });
250
+ }
251
+ if (kindMetadata?.kind === "fix_loop" && controller.runtime_program === undefined) {
252
+ errors.push({
253
+ path: `${path}.runtime_program`,
254
+ message: "fix_loop controller requires a typed runtime_program",
255
+ });
172
256
  }
257
+ validateRuntimeProgram(controller, diagnosisWorkflow, fixWorkflow, `${path}.runtime_program`, errors);
173
258
  return errors;
174
259
  }
@@ -26,6 +26,7 @@ const STEP_FIELDS = {
26
26
  run_if: { required: false, type: "string" },
27
27
  prompt: { required: false, type: "string" },
28
28
  completion: { required: false, type: "CompletionCheck[]" },
29
+ canonical_runtime: { required: false, type: "CanonicalRuntimeStepDef" },
29
30
  checkpoints: { required: false, type: "StepCheckpoint[]" },
30
31
  handoff: { required: false, type: "StepHandoff" },
31
32
  isolation: { required: false, type: "WorkflowIsolation", allowed_values: WORKFLOW_ISOLATION_VALUES },
@@ -63,6 +64,7 @@ const HANDOFF_FIELDS = {
63
64
  path: { required: false, type: "string" },
64
65
  name: { required: false, type: "string" },
65
66
  artifact_id: { required: false, type: "string" },
67
+ schema_ref: { required: false, type: "string" },
66
68
  from: { required: false, type: "string" },
67
69
  required: { required: false, type: "boolean", notes: "Defaults to true." },
68
70
  description: { required: true, type: "string" },
@@ -9,7 +9,7 @@
9
9
  * Zero external dependencies.
10
10
  */
11
11
  export function parseYAML(input) {
12
- const lines = input.split("\n");
12
+ const lines = input.replace(/\r\n?/g, "\n").split("\n");
13
13
  const result = parseBlock(lines, 0, 0);
14
14
  return result.value;
15
15
  }
@@ -55,6 +55,7 @@ variables:
55
55
  test_command:
56
56
  description: "Command that verifies the target module"
57
57
  default: "flutter test"
58
+ runtime_type: trusted_verifier_command
58
59
  target_scope:
59
60
  description: "Allowed write scope for the rewrite step"
60
61
  default: "v2/**"