@interf/compiler 0.5.1 → 0.6.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.
- package/README.md +160 -201
- package/builtin-workflows/interf/README.md +22 -10
- package/builtin-workflows/interf/compile/stages/shape/SKILL.md +8 -5
- package/builtin-workflows/interf/compile/stages/structure/SKILL.md +3 -0
- package/builtin-workflows/interf/compile/stages/summarize/SKILL.md +18 -2
- package/builtin-workflows/interf/improve/SKILL.md +4 -4
- package/builtin-workflows/interf/use/query/SKILL.md +1 -1
- package/builtin-workflows/interf/workflow.json +19 -5
- package/builtin-workflows/interf/{compiled.schema.json → workflow.schema.json} +10 -3
- package/dist/bin.js +2 -28
- package/dist/{commands → cli/commands}/check-draft.d.ts +2 -2
- package/dist/{commands → cli/commands}/check-draft.js +13 -13
- package/dist/{commands → cli/commands}/compile-controller.d.ts +3 -3
- package/dist/{commands → cli/commands}/compile-controller.js +39 -44
- package/dist/cli/commands/compile.d.ts +33 -0
- package/dist/{commands → cli/commands}/compile.js +107 -33
- package/dist/{commands → cli/commands}/compiled-flow.d.ts +3 -4
- package/dist/{commands → cli/commands}/compiled-flow.js +9 -14
- package/dist/{commands → cli/commands}/create-workflow-wizard.d.ts +20 -2
- package/dist/cli/commands/create-workflow-wizard.js +288 -0
- package/dist/{commands → cli/commands}/create.d.ts +2 -2
- package/dist/cli/commands/create.js +166 -0
- package/dist/cli/commands/dataset-selection.d.ts +6 -0
- package/dist/cli/commands/dataset-selection.js +11 -0
- package/dist/{commands → cli/commands}/default.js +5 -5
- package/dist/{commands → cli/commands}/doctor.js +12 -13
- package/dist/{commands → cli/commands}/executor-flow.d.ts +2 -2
- package/dist/{commands → cli/commands}/executor-flow.js +17 -17
- package/dist/cli/commands/init.d.ts +11 -0
- package/dist/{commands → cli/commands}/init.js +202 -109
- package/dist/{commands → cli/commands}/list.js +9 -6
- package/dist/{commands → cli/commands}/reset.js +5 -5
- package/dist/{commands → cli/commands}/source-config-wizard.d.ts +10 -5
- package/dist/{commands → cli/commands}/source-config-wizard.js +202 -95
- package/dist/{commands → cli/commands}/status.js +20 -11
- package/dist/{commands → cli/commands}/test-flow.d.ts +13 -4
- package/dist/{commands → cli/commands}/test-flow.js +30 -26
- package/dist/cli/commands/test.d.ts +14 -0
- package/dist/{commands → cli/commands}/test.js +48 -40
- package/dist/{commands → cli/commands}/verify.js +4 -4
- package/dist/cli/index.d.ts +21 -0
- package/dist/cli/index.js +33 -0
- package/dist/index.d.ts +22 -11
- package/dist/index.js +15 -6
- package/dist/lib/agent-args.d.ts +1 -3
- package/dist/lib/agent-args.js +1 -42
- package/dist/lib/agent-constants.d.ts +1 -5
- package/dist/lib/agent-constants.js +1 -28
- package/dist/lib/agent-detection.d.ts +1 -7
- package/dist/lib/agent-detection.js +1 -65
- package/dist/lib/agent-execution.d.ts +1 -2
- package/dist/lib/agent-execution.js +1 -242
- package/dist/lib/agent-logs.d.ts +1 -2
- package/dist/lib/agent-logs.js +1 -17
- package/dist/lib/agent-preflight.d.ts +1 -7
- package/dist/lib/agent-preflight.js +1 -76
- package/dist/lib/agent-render.d.ts +1 -8
- package/dist/lib/agent-render.js +1 -218
- package/dist/lib/agent-shells.d.ts +1 -44
- package/dist/lib/agent-shells.js +1 -847
- package/dist/lib/agent-status.d.ts +1 -3
- package/dist/lib/agent-status.js +1 -58
- package/dist/lib/agent-types.d.ts +1 -30
- package/dist/lib/agent-types.js +1 -1
- package/dist/lib/agents.d.ts +1 -6
- package/dist/lib/agents.js +1 -5
- package/dist/lib/builtin-compiled-workflow.d.ts +1 -129
- package/dist/lib/builtin-compiled-workflow.js +1 -153
- package/dist/lib/compiled-compile.d.ts +1 -52
- package/dist/lib/compiled-compile.js +1 -274
- package/dist/lib/compiled-paths.d.ts +1 -39
- package/dist/lib/compiled-paths.js +3 -103
- package/dist/lib/compiled-raw.d.ts +1 -49
- package/dist/lib/compiled-raw.js +3 -102
- package/dist/lib/compiled-reset.d.ts +1 -1
- package/dist/lib/compiled-reset.js +3 -44
- package/dist/lib/compiled-schema.d.ts +1 -27
- package/dist/lib/compiled-schema.js +1 -110
- package/dist/lib/discovery.d.ts +1 -1
- package/dist/lib/discovery.js +2 -2
- package/dist/lib/execution-profile.d.ts +1 -17
- package/dist/lib/execution-profile.js +1 -84
- package/dist/lib/executors.d.ts +1 -32
- package/dist/lib/executors.js +1 -43
- package/dist/lib/interf-bootstrap.d.ts +1 -3
- package/dist/lib/interf-bootstrap.js +3 -18
- package/dist/lib/interf-detect.d.ts +1 -33
- package/dist/lib/interf-detect.js +3 -176
- package/dist/lib/interf-scaffold.d.ts +1 -2
- package/dist/lib/interf-scaffold.js +3 -121
- package/dist/lib/interf-workflow-package.d.ts +1 -20
- package/dist/lib/interf-workflow-package.js +1 -276
- package/dist/lib/interf.d.ts +1 -5
- package/dist/lib/interf.js +3 -4
- package/dist/lib/local-workflows.d.ts +1 -53
- package/dist/lib/local-workflows.js +1 -399
- package/dist/lib/package-root.d.ts +1 -0
- package/dist/lib/package-root.js +1 -0
- package/dist/lib/project-paths.d.ts +1 -11
- package/dist/lib/project-paths.js +3 -32
- package/dist/lib/runtime-acceptance.d.ts +1 -9
- package/dist/lib/runtime-acceptance.js +1 -257
- package/dist/lib/runtime-contracts.d.ts +1 -2
- package/dist/lib/runtime-contracts.js +1 -47
- package/dist/lib/runtime-inventory.d.ts +1 -7
- package/dist/lib/runtime-inventory.js +1 -29
- package/dist/lib/runtime-paths.d.ts +1 -7
- package/dist/lib/runtime-paths.js +1 -23
- package/dist/lib/runtime-prompt.d.ts +1 -2
- package/dist/lib/runtime-prompt.js +1 -46
- package/dist/lib/runtime-reconcile.d.ts +1 -2
- package/dist/lib/runtime-reconcile.js +1 -156
- package/dist/lib/runtime-runs.d.ts +1 -11
- package/dist/lib/runtime-runs.js +1 -250
- package/dist/lib/runtime-types.d.ts +1 -43
- package/dist/lib/runtime-types.js +1 -1
- package/dist/lib/runtime.d.ts +1 -6
- package/dist/lib/runtime.js +1 -5
- package/dist/lib/schema.d.ts +4 -1016
- package/dist/lib/schema.js +6 -539
- package/dist/lib/source-config.d.ts +1 -39
- package/dist/lib/source-config.js +3 -293
- package/dist/lib/state-artifacts.d.ts +1 -8
- package/dist/lib/state-artifacts.js +1 -13
- package/dist/lib/state-health.d.ts +1 -4
- package/dist/lib/state-health.js +1 -132
- package/dist/lib/state-io.d.ts +1 -10
- package/dist/lib/state-io.js +1 -76
- package/dist/lib/state-paths.d.ts +1 -4
- package/dist/lib/state-paths.js +1 -13
- package/dist/lib/state-view.d.ts +1 -4
- package/dist/lib/state-view.js +1 -103
- package/dist/lib/state.d.ts +1 -6
- package/dist/lib/state.js +1 -5
- package/dist/lib/test-execution.d.ts +1 -14
- package/dist/lib/test-execution.js +3 -525
- package/dist/lib/test-matrices.d.ts +1 -90
- package/dist/lib/test-matrices.js +3 -96
- package/dist/lib/test-paths.d.ts +1 -12
- package/dist/lib/test-paths.js +3 -59
- package/dist/lib/test-profile-presets.d.ts +1 -57
- package/dist/lib/test-profile-presets.js +3 -50
- package/dist/lib/test-sandbox.d.ts +1 -11
- package/dist/lib/test-sandbox.js +3 -105
- package/dist/lib/test-specs.d.ts +1 -7
- package/dist/lib/test-specs.js +3 -114
- package/dist/lib/test-targets.d.ts +1 -5
- package/dist/lib/test-targets.js +3 -38
- package/dist/lib/test-types.d.ts +1 -17
- package/dist/lib/test-types.js +3 -1
- package/dist/lib/test.d.ts +1 -4
- package/dist/lib/test.js +3 -3
- package/dist/lib/validate-compiled.d.ts +1 -27
- package/dist/lib/validate-compiled.js +1 -238
- package/dist/lib/validate-helpers.d.ts +1 -12
- package/dist/lib/validate-helpers.js +1 -41
- package/dist/lib/validate.d.ts +1 -19
- package/dist/lib/validate.js +1 -256
- package/dist/lib/workflow-authoring.d.ts +1 -0
- package/dist/lib/workflow-authoring.js +1 -0
- package/dist/lib/workflow-definitions.d.ts +1 -68
- package/dist/lib/workflow-definitions.js +1 -206
- package/dist/lib/workflow-edit-session.d.ts +1 -0
- package/dist/lib/workflow-edit-session.js +1 -0
- package/dist/lib/workflow-edit-utils.d.ts +1 -0
- package/dist/lib/workflow-edit-utils.js +1 -0
- package/dist/lib/workflow-helpers.d.ts +1 -38
- package/dist/lib/workflow-helpers.js +1 -167
- package/dist/lib/workflow-improvement.d.ts +1 -22
- package/dist/lib/workflow-improvement.js +1 -396
- package/dist/lib/workflow-primitives.d.ts +1 -2
- package/dist/lib/workflow-primitives.js +1 -5
- package/dist/lib/workflow-review-paths.d.ts +1 -10
- package/dist/lib/workflow-review-paths.js +1 -27
- package/dist/lib/workflow-stage-policy.d.ts +1 -0
- package/dist/lib/workflow-stage-policy.js +1 -0
- package/dist/lib/workflow-stage-runner.d.ts +1 -41
- package/dist/lib/workflow-stage-runner.js +1 -109
- package/dist/lib/workflows.d.ts +1 -15
- package/dist/lib/workflows.js +1 -31
- package/dist/packages/agents/index.d.ts +17 -0
- package/dist/packages/agents/index.js +15 -0
- package/dist/packages/agents/lib/agents.d.ts +6 -0
- package/dist/packages/agents/lib/agents.js +5 -0
- package/dist/packages/agents/lib/args.d.ts +4 -0
- package/dist/packages/agents/lib/args.js +52 -0
- package/dist/packages/agents/lib/constants.d.ts +5 -0
- package/dist/packages/agents/lib/constants.js +28 -0
- package/dist/packages/agents/lib/detection.d.ts +7 -0
- package/dist/packages/agents/lib/detection.js +65 -0
- package/dist/packages/agents/lib/execution-profile.d.ts +17 -0
- package/dist/packages/agents/lib/execution-profile.js +84 -0
- package/dist/packages/agents/lib/execution.d.ts +2 -0
- package/dist/packages/agents/lib/execution.js +243 -0
- package/dist/packages/agents/lib/executors.d.ts +32 -0
- package/dist/packages/agents/lib/executors.js +45 -0
- package/dist/packages/agents/lib/logs.d.ts +2 -0
- package/dist/packages/agents/lib/logs.js +17 -0
- package/dist/packages/agents/lib/preflight.d.ts +7 -0
- package/dist/packages/agents/lib/preflight.js +77 -0
- package/dist/packages/agents/lib/render.d.ts +8 -0
- package/dist/packages/agents/lib/render.js +218 -0
- package/dist/packages/agents/lib/schema.d.ts +8 -0
- package/dist/packages/agents/lib/schema.js +7 -0
- package/dist/packages/agents/lib/shells.d.ts +69 -0
- package/dist/packages/agents/lib/shells.js +1021 -0
- package/dist/packages/agents/lib/status.d.ts +3 -0
- package/dist/packages/agents/lib/status.js +58 -0
- package/dist/packages/agents/lib/types.d.ts +30 -0
- package/dist/packages/agents/lib/types.js +1 -0
- package/dist/{lib → packages/agents/lib}/user-config.d.ts +1 -0
- package/dist/{lib → packages/agents/lib}/user-config.js +3 -2
- package/dist/packages/compiler/compiled-compile.d.ts +48 -0
- package/dist/packages/compiler/compiled-compile.js +256 -0
- package/dist/packages/compiler/compiled-schema.d.ts +31 -0
- package/dist/packages/compiler/compiled-schema.js +141 -0
- package/dist/packages/compiler/index.d.ts +24 -0
- package/dist/packages/compiler/index.js +23 -0
- package/dist/packages/compiler/lib/schema.d.ts +684 -0
- package/dist/packages/compiler/lib/schema.js +361 -0
- package/dist/packages/compiler/runtime-acceptance.d.ts +9 -0
- package/dist/packages/compiler/runtime-acceptance.js +269 -0
- package/dist/packages/compiler/runtime-contracts.d.ts +2 -0
- package/dist/packages/compiler/runtime-contracts.js +48 -0
- package/dist/packages/compiler/runtime-inventory.d.ts +7 -0
- package/dist/packages/compiler/runtime-inventory.js +29 -0
- package/dist/packages/compiler/runtime-paths.d.ts +8 -0
- package/dist/packages/compiler/runtime-paths.js +26 -0
- package/dist/packages/compiler/runtime-prompt.d.ts +2 -0
- package/dist/packages/compiler/runtime-prompt.js +48 -0
- package/dist/packages/compiler/runtime-reconcile.d.ts +2 -0
- package/dist/packages/compiler/runtime-reconcile.js +193 -0
- package/dist/packages/compiler/runtime-runs.d.ts +11 -0
- package/dist/packages/compiler/runtime-runs.js +262 -0
- package/dist/packages/compiler/runtime-types.d.ts +43 -0
- package/dist/packages/compiler/runtime-types.js +1 -0
- package/dist/packages/compiler/runtime.d.ts +6 -0
- package/dist/packages/compiler/runtime.js +5 -0
- package/dist/packages/compiler/state-artifacts.d.ts +8 -0
- package/dist/packages/compiler/state-artifacts.js +13 -0
- package/dist/packages/compiler/state-health.d.ts +4 -0
- package/dist/packages/compiler/state-health.js +132 -0
- package/dist/packages/compiler/state-io.d.ts +10 -0
- package/dist/packages/compiler/state-io.js +76 -0
- package/dist/packages/compiler/state-paths.d.ts +4 -0
- package/dist/packages/compiler/state-paths.js +13 -0
- package/dist/packages/compiler/state-view.d.ts +4 -0
- package/dist/packages/compiler/state-view.js +103 -0
- package/dist/packages/compiler/state.d.ts +7 -0
- package/dist/packages/compiler/state.js +12 -0
- package/dist/packages/compiler/validate-compiled.d.ts +27 -0
- package/dist/packages/compiler/validate-compiled.js +241 -0
- package/dist/packages/compiler/validate-helpers.d.ts +12 -0
- package/dist/packages/compiler/validate-helpers.js +41 -0
- package/dist/packages/compiler/validate.d.ts +21 -0
- package/dist/packages/compiler/validate.js +249 -0
- package/dist/packages/compiler/workflow-primitives.d.ts +2 -0
- package/dist/packages/compiler/workflow-primitives.js +5 -0
- package/dist/packages/compiler/workflows.d.ts +15 -0
- package/dist/packages/compiler/workflows.js +31 -0
- package/dist/packages/project-model/compiled-paths.d.ts +40 -0
- package/dist/packages/project-model/compiled-paths.js +106 -0
- package/dist/packages/project-model/compiled-raw.d.ts +49 -0
- package/dist/packages/project-model/compiled-raw.js +102 -0
- package/dist/packages/project-model/compiled-reset.d.ts +2 -0
- package/dist/packages/project-model/compiled-reset.js +72 -0
- package/dist/packages/project-model/index.d.ts +11 -0
- package/dist/packages/project-model/index.js +10 -0
- package/dist/packages/project-model/interf-bootstrap.d.ts +3 -0
- package/dist/packages/project-model/interf-bootstrap.js +18 -0
- package/dist/packages/project-model/interf-detect.d.ts +33 -0
- package/dist/packages/project-model/interf-detect.js +176 -0
- package/dist/packages/project-model/interf-scaffold.d.ts +2 -0
- package/dist/packages/project-model/interf-scaffold.js +124 -0
- package/dist/packages/project-model/interf.d.ts +5 -0
- package/dist/packages/project-model/interf.js +4 -0
- package/dist/packages/project-model/lib/schema.d.ts +125 -0
- package/dist/packages/project-model/lib/schema.js +62 -0
- package/dist/packages/project-model/project-paths.d.ts +11 -0
- package/dist/packages/project-model/project-paths.js +32 -0
- package/dist/packages/project-model/source-config.d.ts +38 -0
- package/dist/packages/project-model/source-config.js +297 -0
- package/dist/packages/testing/index.d.ts +13 -0
- package/dist/packages/testing/index.js +10 -0
- package/dist/packages/testing/lib/schema.d.ts +261 -0
- package/dist/packages/testing/lib/schema.js +119 -0
- package/dist/packages/testing/test-execution.d.ts +14 -0
- package/dist/packages/testing/test-execution.js +525 -0
- package/dist/packages/testing/test-matrices.d.ts +90 -0
- package/dist/packages/testing/test-matrices.js +96 -0
- package/dist/packages/testing/test-paths.d.ts +12 -0
- package/dist/packages/testing/test-paths.js +59 -0
- package/dist/packages/testing/test-profile-presets.d.ts +57 -0
- package/dist/packages/testing/test-profile-presets.js +50 -0
- package/dist/packages/testing/test-sandbox.d.ts +11 -0
- package/dist/packages/testing/test-sandbox.js +105 -0
- package/dist/packages/testing/test-specs.d.ts +7 -0
- package/dist/packages/testing/test-specs.js +114 -0
- package/dist/packages/testing/test-targets.d.ts +5 -0
- package/dist/packages/testing/test-targets.js +38 -0
- package/dist/packages/testing/test-types.d.ts +16 -0
- package/dist/packages/testing/test-types.js +1 -0
- package/dist/packages/testing/test.d.ts +4 -0
- package/dist/packages/testing/test.js +3 -0
- package/dist/packages/workflow-authoring/index.d.ts +4 -0
- package/dist/packages/workflow-authoring/index.js +4 -0
- package/dist/packages/workflow-authoring/lib/workflow-edit-utils.d.ts +10 -0
- package/dist/packages/workflow-authoring/lib/workflow-edit-utils.js +39 -0
- package/dist/packages/workflow-authoring/workflow-authoring.d.ts +26 -0
- package/dist/packages/workflow-authoring/workflow-authoring.js +120 -0
- package/dist/packages/workflow-authoring/workflow-edit-session.d.ts +16 -0
- package/dist/packages/workflow-authoring/workflow-edit-session.js +57 -0
- package/dist/packages/workflow-authoring/workflow-improvement.d.ts +23 -0
- package/dist/packages/workflow-authoring/workflow-improvement.js +209 -0
- package/dist/packages/workflow-package/builtin-compiled-workflow.d.ts +38 -0
- package/dist/packages/workflow-package/builtin-compiled-workflow.js +94 -0
- package/dist/packages/workflow-package/index.d.ts +9 -0
- package/dist/packages/workflow-package/index.js +9 -0
- package/dist/packages/workflow-package/interf-workflow-package.d.ts +25 -0
- package/dist/packages/workflow-package/interf-workflow-package.js +342 -0
- package/dist/{lib/config.d.ts → packages/workflow-package/lib/package-root.d.ts} +0 -1
- package/dist/packages/workflow-package/lib/package-root.js +6 -0
- package/dist/packages/workflow-package/local-workflows.d.ts +54 -0
- package/dist/packages/workflow-package/local-workflows.js +422 -0
- package/dist/packages/workflow-package/workflow-definitions.d.ts +78 -0
- package/dist/packages/workflow-package/workflow-definitions.js +203 -0
- package/dist/packages/workflow-package/workflow-helpers.d.ts +38 -0
- package/dist/packages/workflow-package/workflow-helpers.js +167 -0
- package/dist/packages/workflow-package/workflow-review-paths.d.ts +10 -0
- package/dist/packages/workflow-package/workflow-review-paths.js +27 -0
- package/dist/packages/workflow-package/workflow-stage-policy.d.ts +5 -0
- package/dist/packages/workflow-package/workflow-stage-policy.js +31 -0
- package/dist/packages/workflow-package/workflow-stage-runner.d.ts +41 -0
- package/dist/packages/workflow-package/workflow-stage-runner.js +109 -0
- package/package.json +44 -21
- package/dist/commands/compile.d.ts +0 -15
- package/dist/commands/create-workflow-wizard.js +0 -125
- package/dist/commands/create.js +0 -162
- package/dist/commands/init.d.ts +0 -3
- package/dist/commands/test.d.ts +0 -9
- package/dist/lib/compiled-home.d.ts +0 -5
- package/dist/lib/compiled-home.js +0 -32
- package/dist/lib/config.js +0 -9
- package/dist/lib/obsidian.d.ts +0 -1
- package/dist/lib/obsidian.js +0 -15
- package/dist/lib/summarize-plan.d.ts +0 -17
- package/dist/lib/summarize-plan.js +0 -120
- /package/dist/{commands → cli/commands}/default.d.ts +0 -0
- /package/dist/{commands → cli/commands}/doctor.d.ts +0 -0
- /package/dist/{commands → cli/commands}/list.d.ts +0 -0
- /package/dist/{commands → cli/commands}/reset.d.ts +0 -0
- /package/dist/{commands → cli/commands}/status.d.ts +0 -0
- /package/dist/{commands → cli/commands}/verify.d.ts +0 -0
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare function extractAgentFailureStatus(event: Record<string, unknown>): string | null;
|
|
2
|
+
export declare function classifyTerminalVisibleStatus(text: string | null | undefined): "done" | "failure" | null;
|
|
3
|
+
export declare function hasAgentStalled(lastActivityAt: number, now: number, stallTimeoutMs: number | null | undefined): boolean;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
export function extractAgentFailureStatus(event) {
|
|
2
|
+
const candidates = [];
|
|
3
|
+
const directMessage = pickString(event.message) ??
|
|
4
|
+
pickString(event.text) ??
|
|
5
|
+
pickString(event.content) ??
|
|
6
|
+
pickString(event.output) ??
|
|
7
|
+
pickString(event.summary);
|
|
8
|
+
if (directMessage)
|
|
9
|
+
candidates.push(directMessage);
|
|
10
|
+
const item = event.item;
|
|
11
|
+
if (item && typeof item === "object") {
|
|
12
|
+
const itemRecord = item;
|
|
13
|
+
const itemText = pickString(itemRecord.text);
|
|
14
|
+
if (itemText)
|
|
15
|
+
candidates.push(itemText);
|
|
16
|
+
if (typeof itemRecord.aggregated_output === "string") {
|
|
17
|
+
candidates.push(itemRecord.aggregated_output);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
for (const candidate of candidates) {
|
|
21
|
+
const lines = candidate
|
|
22
|
+
.split(/\r?\n/)
|
|
23
|
+
.map((line) => line.trim())
|
|
24
|
+
.filter((line) => line.length > 0);
|
|
25
|
+
for (const text of lines) {
|
|
26
|
+
if (text.startsWith("BLOCKED:") || text.startsWith("ERROR:")) {
|
|
27
|
+
return text;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
export function classifyTerminalVisibleStatus(text) {
|
|
34
|
+
if (!text)
|
|
35
|
+
return null;
|
|
36
|
+
if (text.startsWith("DONE:"))
|
|
37
|
+
return "done";
|
|
38
|
+
if (text.startsWith("BLOCKED:") || text.startsWith("ERROR:"))
|
|
39
|
+
return "failure";
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
export function hasAgentStalled(lastActivityAt, now, stallTimeoutMs) {
|
|
43
|
+
return typeof stallTimeoutMs === "number" && stallTimeoutMs > 0 && now - lastActivityAt >= stallTimeoutMs;
|
|
44
|
+
}
|
|
45
|
+
function pickString(value) {
|
|
46
|
+
if (typeof value === "string")
|
|
47
|
+
return value;
|
|
48
|
+
if (!Array.isArray(value))
|
|
49
|
+
return null;
|
|
50
|
+
for (const entry of value) {
|
|
51
|
+
if (typeof entry === "string")
|
|
52
|
+
return entry;
|
|
53
|
+
if (entry && typeof entry === "object" && "text" in entry && typeof entry.text === "string") {
|
|
54
|
+
return entry.text;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { WorkflowExecutionProfile } from "./executors.js";
|
|
2
|
+
export interface Agent {
|
|
3
|
+
name: string;
|
|
4
|
+
displayName: string;
|
|
5
|
+
skillsDir: string;
|
|
6
|
+
command: string;
|
|
7
|
+
}
|
|
8
|
+
export interface AgentPreflightResult {
|
|
9
|
+
ok: boolean;
|
|
10
|
+
code: number | null;
|
|
11
|
+
timedOut: boolean;
|
|
12
|
+
stdout: string;
|
|
13
|
+
stderr: string;
|
|
14
|
+
error: string | null;
|
|
15
|
+
}
|
|
16
|
+
export type AgentSpawnSync = typeof import("node:child_process").spawnSync;
|
|
17
|
+
export interface AgentPreflightOptions {
|
|
18
|
+
timeoutMs?: number;
|
|
19
|
+
spawnSyncImpl?: AgentSpawnSync;
|
|
20
|
+
}
|
|
21
|
+
export interface AgentAutomationReadiness {
|
|
22
|
+
ok: boolean;
|
|
23
|
+
error?: string;
|
|
24
|
+
}
|
|
25
|
+
export interface SpawnAgentOptions {
|
|
26
|
+
eventLogPath?: string | null;
|
|
27
|
+
statusLogPath?: string | null;
|
|
28
|
+
executionProfile?: WorkflowExecutionProfile;
|
|
29
|
+
completionCheck?: (() => boolean) | null;
|
|
30
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type InterfUserConfig } from "./schema.js";
|
|
2
2
|
export type { InterfUserConfig } from "./schema.js";
|
|
3
|
+
export declare const INTERF_HOME: string;
|
|
3
4
|
export declare const USER_CONFIG_PATH: string;
|
|
4
5
|
export declare function loadUserConfig(): InterfUserConfig | null;
|
|
5
6
|
export declare function saveUserConfig(config: InterfUserConfig): void;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { existsSync, mkdirSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { homedir } from "node:os";
|
|
2
3
|
import { join } from "node:path";
|
|
3
|
-
import {
|
|
4
|
-
import { readJsonFileWithSchema } from "./parse.js";
|
|
4
|
+
import { readJsonFileWithSchema } from "../../../lib/parse.js";
|
|
5
5
|
import { InterfUserConfigSchema } from "./schema.js";
|
|
6
|
+
export const INTERF_HOME = join(homedir(), ".interf");
|
|
6
7
|
export const USER_CONFIG_PATH = join(INTERF_HOME, "config.json");
|
|
7
8
|
export function loadUserConfig() {
|
|
8
9
|
if (!existsSync(USER_CONFIG_PATH))
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { type WorkflowExecutor } from "../agents/lib/executors.js";
|
|
2
|
+
import { type CompiledWorkflowId, type WorkflowStageDefinition } from "../workflow-package/workflow-definitions.js";
|
|
3
|
+
import { type WorkflowReporter, type WorkflowStageResult } from "../workflow-package/workflow-helpers.js";
|
|
4
|
+
export interface CompiledStageExecutionDefinition extends WorkflowStageDefinition {
|
|
5
|
+
}
|
|
6
|
+
export interface CompiledSummarizeResult extends WorkflowStageResult {
|
|
7
|
+
skipped: boolean;
|
|
8
|
+
plan: {
|
|
9
|
+
sourceCount: number;
|
|
10
|
+
summaryCount: number;
|
|
11
|
+
targetCount: number;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export interface CompiledCompileResult {
|
|
15
|
+
ok: boolean;
|
|
16
|
+
stageResults: Record<string, WorkflowStageResult>;
|
|
17
|
+
failedStage: string | null;
|
|
18
|
+
}
|
|
19
|
+
export type StageShellRetentionMode = "on-failure" | "always";
|
|
20
|
+
export declare function resolveCompiledContext(compiledPath: string): {
|
|
21
|
+
compiledName: string;
|
|
22
|
+
sourcePath: string;
|
|
23
|
+
controlPath: string;
|
|
24
|
+
workflowId: CompiledWorkflowId;
|
|
25
|
+
};
|
|
26
|
+
export declare function compiledExecutionStages(workflowId: CompiledWorkflowId, compiledPath: string): CompiledStageExecutionDefinition[];
|
|
27
|
+
export declare function runCompiledSummarize(options: {
|
|
28
|
+
executor: WorkflowExecutor;
|
|
29
|
+
compiledPath: string;
|
|
30
|
+
reporter?: WorkflowReporter;
|
|
31
|
+
reportSummary?: boolean;
|
|
32
|
+
reportStep?: boolean;
|
|
33
|
+
stageDefinition?: CompiledStageExecutionDefinition;
|
|
34
|
+
fullPass?: boolean;
|
|
35
|
+
}): Promise<CompiledSummarizeResult>;
|
|
36
|
+
export declare function runCompiledCompile(options: {
|
|
37
|
+
executor: WorkflowExecutor;
|
|
38
|
+
compiledPath: string;
|
|
39
|
+
reporter?: WorkflowReporter;
|
|
40
|
+
reportStep?: boolean;
|
|
41
|
+
preserveStageShells?: StageShellRetentionMode;
|
|
42
|
+
}): Promise<WorkflowStageResult>;
|
|
43
|
+
export declare function compileCompiled(options: {
|
|
44
|
+
executor: WorkflowExecutor;
|
|
45
|
+
compiledPath: string;
|
|
46
|
+
reporter?: WorkflowReporter;
|
|
47
|
+
preserveStageShells?: StageShellRetentionMode;
|
|
48
|
+
}): Promise<CompiledCompileResult>;
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
import { join } from "node:path";
|
|
2
|
+
import { createStageExecutionShell, freezeStageExecutionShell, pruneStageExecutionShells, syncStageExecutionShellWrites, } from "../agents/lib/shells.js";
|
|
3
|
+
import { readInterfConfig, resolveSourceFolderPath, resolveSourceControlPath, resolveSourceInputPath, } from "../project-model/interf-detect.js";
|
|
4
|
+
import { refreshCompiledBootstrapGuidance, } from "../project-model/interf-bootstrap.js";
|
|
5
|
+
import { reconcileCompiledStageRun, } from "./runtime-reconcile.js";
|
|
6
|
+
import { refreshCompiledArtifacts, } from "./state.js";
|
|
7
|
+
import { buildRuntimeStageContract, } from "./runtime.js";
|
|
8
|
+
import { validateWorkflowPackage } from "../workflow-package/local-workflows.js";
|
|
9
|
+
import { formatActiveCompiledWorkflowStageStep, getActiveCompiledStagePolicyNotes, getActiveCompiledWorkflow, resolveRequiredCompiledWorkflowFromConfig, resolveActiveCompiledStageAcceptance, } from "../workflow-package/workflow-definitions.js";
|
|
10
|
+
import { validateCompiledStage, validateCompiledWorkflow, } from "./validate.js";
|
|
11
|
+
import { buildLocalSkillContractExtension, buildStageInstructions, reportBlankLine, reportLine, reportValidationFailure, workflowCompileStageDirectory, } from "../workflow-package/workflow-helpers.js";
|
|
12
|
+
import { executeValidatedStage, } from "../workflow-package/workflow-stage-runner.js";
|
|
13
|
+
import { syncCompiledRawSnapshot } from "../project-model/compiled-raw.js";
|
|
14
|
+
import { workflowPackagePathForCompiled, } from "../project-model/compiled-paths.js";
|
|
15
|
+
import { compiledContractArtifactPathsForZoneIds, findCompiledSchemaZone, readCompiledSchemaFile, } from "./compiled-schema.js";
|
|
16
|
+
import { discoverSourceFiles } from "../../lib/discovery.js";
|
|
17
|
+
import { listFilesRecursive } from "../../lib/filesystem.js";
|
|
18
|
+
export function resolveCompiledContext(compiledPath) {
|
|
19
|
+
const config = readInterfConfig(compiledPath);
|
|
20
|
+
const workflowId = resolveRequiredCompiledWorkflowFromConfig(config, `.interf/interf.json for ${compiledPath}`);
|
|
21
|
+
return {
|
|
22
|
+
compiledName: config?.name ?? "compiled",
|
|
23
|
+
sourcePath: resolveSourceFolderPath(compiledPath, config),
|
|
24
|
+
controlPath: resolveSourceControlPath(compiledPath),
|
|
25
|
+
workflowId,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
export function compiledExecutionStages(workflowId, compiledPath) {
|
|
29
|
+
return getActiveCompiledWorkflow(compiledPath, workflowId)
|
|
30
|
+
.stages;
|
|
31
|
+
}
|
|
32
|
+
function zoneArtifactCount(compiledPath, zonePath, kind) {
|
|
33
|
+
const absolutePath = join(compiledPath, zonePath);
|
|
34
|
+
try {
|
|
35
|
+
if (kind === "file") {
|
|
36
|
+
return listFilesRecursive(absolutePath).length > 0 ? 1 : 0;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
if (kind === "file")
|
|
41
|
+
return 0;
|
|
42
|
+
}
|
|
43
|
+
return listFilesRecursive(absolutePath).length;
|
|
44
|
+
}
|
|
45
|
+
function resolveStageContractArtifacts(compiledPath, stageDefinition) {
|
|
46
|
+
const schema = readCompiledSchemaFile(workflowPackagePathForCompiled(compiledPath));
|
|
47
|
+
if (!schema) {
|
|
48
|
+
throw new Error(`Missing workflow schema for stage "${stageDefinition.id}" at ${workflowPackagePathForCompiled(compiledPath)}.`);
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
reads: compiledContractArtifactPathsForZoneIds(schema, stageDefinition.reads),
|
|
52
|
+
writes: compiledContractArtifactPathsForZoneIds(schema, stageDefinition.writes),
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function buildStageCounts(compiledPath, stageDefinition) {
|
|
56
|
+
const context = resolveCompiledContext(compiledPath);
|
|
57
|
+
const sourceTotal = discoverSourceFiles(context.sourcePath, compiledPath).totalCount;
|
|
58
|
+
const schema = readCompiledSchemaFile(workflowPackagePathForCompiled(compiledPath));
|
|
59
|
+
const zoneCounts = {};
|
|
60
|
+
if (schema) {
|
|
61
|
+
for (const zoneId of new Set([...stageDefinition.reads, ...stageDefinition.writes])) {
|
|
62
|
+
const zone = findCompiledSchemaZone(schema, zoneId);
|
|
63
|
+
if (!zone)
|
|
64
|
+
continue;
|
|
65
|
+
zoneCounts[zoneId] = zoneArtifactCount(compiledPath, zone.path, zone.kind);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return {
|
|
69
|
+
source_total: sourceTotal,
|
|
70
|
+
read_zone_total: stageDefinition.reads.length,
|
|
71
|
+
write_zone_total: stageDefinition.writes.length,
|
|
72
|
+
...zoneCounts,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
function buildStageContract(compiledPath, workflowId, stageDefinition) {
|
|
76
|
+
const config = readInterfConfig(compiledPath);
|
|
77
|
+
const localSkills = buildLocalSkillContractExtension(compiledPath, [workflowCompileStageDirectory(stageDefinition.skillDir)], "Use them to refine this workflow stage while still honoring the declared reads, writes, and proof rules.");
|
|
78
|
+
const instructions = buildStageInstructions(stageDefinition.skillDir, localSkills);
|
|
79
|
+
const stageArtifacts = resolveStageContractArtifacts(compiledPath, stageDefinition);
|
|
80
|
+
return buildRuntimeStageContract({
|
|
81
|
+
compiledName: config?.name ?? "compiled",
|
|
82
|
+
stageId: stageDefinition.id,
|
|
83
|
+
stageLabel: stageDefinition.label,
|
|
84
|
+
counts: buildStageCounts(compiledPath, stageDefinition),
|
|
85
|
+
stageReadArtifacts: stageArtifacts.reads,
|
|
86
|
+
stageWriteArtifacts: stageArtifacts.writes,
|
|
87
|
+
workflowNotes: getActiveCompiledStagePolicyNotes(compiledPath, workflowId, stageDefinition.id),
|
|
88
|
+
localSkillDocs: localSkills.reads,
|
|
89
|
+
instructions,
|
|
90
|
+
acceptance: resolveActiveCompiledStageAcceptance(compiledPath, workflowId, stageDefinition.id),
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
async function runCompiledStage(options) {
|
|
94
|
+
const context = resolveCompiledContext(options.compiledPath);
|
|
95
|
+
const stageDefinition = options.stageDefinition;
|
|
96
|
+
const contract = buildStageContract(options.compiledPath, context.workflowId, stageDefinition);
|
|
97
|
+
const localSkills = buildLocalSkillContractExtension(options.compiledPath, [workflowCompileStageDirectory(stageDefinition.skillDir)], "Use them to refine this workflow stage while still honoring the declared reads, writes, and proof rules.");
|
|
98
|
+
const instructions = buildStageInstructions(stageDefinition.skillDir, localSkills);
|
|
99
|
+
if (options.reportStep !== false) {
|
|
100
|
+
reportBlankLine(options.reporter);
|
|
101
|
+
reportLine(options.reporter, `${formatActiveCompiledWorkflowStageStep(options.compiledPath, context.workflowId, stageDefinition.id)} (${stageDefinition.description.toLowerCase()})`);
|
|
102
|
+
}
|
|
103
|
+
const shell = createStageExecutionShell(options.compiledPath, context.compiledName, context.workflowId, stageDefinition, contract.artifacts.writes);
|
|
104
|
+
try {
|
|
105
|
+
return await executeValidatedStage({
|
|
106
|
+
executor: options.executor,
|
|
107
|
+
compiledPath: options.compiledPath,
|
|
108
|
+
executionPath: shell.rootPath,
|
|
109
|
+
targetName: context.compiledName,
|
|
110
|
+
workflow: context.workflowId,
|
|
111
|
+
workflowSourcePath: options.compiledPath,
|
|
112
|
+
stageDefinition,
|
|
113
|
+
instructions,
|
|
114
|
+
summary: `Executing ${stageDefinition.label.toLowerCase()}.`,
|
|
115
|
+
contract,
|
|
116
|
+
statusLines: [
|
|
117
|
+
`Emit exactly one startup line: STATUS: loaded ${stageDefinition.label.toLowerCase()} stage.`,
|
|
118
|
+
"Emit STATUS: reading declared inputs after you confirm the shell contract and local docs.",
|
|
119
|
+
"Emit STATUS: writing declared outputs after the stage starts updating the compiled zones.",
|
|
120
|
+
`Emit DONE: ${stageDefinition.id} complete when the declared outputs and proof are on disk.`,
|
|
121
|
+
],
|
|
122
|
+
reporter: options.reporter,
|
|
123
|
+
completionCheck: () => validateCompiledStage(options.compiledPath, stageDefinition.id).ok,
|
|
124
|
+
syncWrites: () => syncStageExecutionShellWrites(options.compiledPath, shell.rootPath, stageDefinition, contract.artifacts.writes),
|
|
125
|
+
reconcile: () => reconcileCompiledStageRun(options.compiledPath, stageDefinition),
|
|
126
|
+
refreshArtifacts: () => refreshCompiledArtifacts(options.compiledPath, { ensureViewSpec: true }),
|
|
127
|
+
validate: () => validateCompiledStage(options.compiledPath, stageDefinition.id),
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
finally {
|
|
131
|
+
freezeStageExecutionShell(shell.rootPath);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
export async function runCompiledSummarize(options) {
|
|
135
|
+
const context = resolveCompiledContext(options.compiledPath);
|
|
136
|
+
const stageDefinition = options.stageDefinition
|
|
137
|
+
?? compiledExecutionStages(context.workflowId, options.compiledPath).find((stage) => stage.id === "summarize");
|
|
138
|
+
if (!stageDefinition) {
|
|
139
|
+
return {
|
|
140
|
+
ok: false,
|
|
141
|
+
code: 1,
|
|
142
|
+
skipped: true,
|
|
143
|
+
plan: { sourceCount: 0, summaryCount: 0, targetCount: 0 },
|
|
144
|
+
summary: "Workflow does not declare a summarize stage.",
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
const sourceCount = discoverSourceFiles(context.sourcePath, options.compiledPath).totalCount;
|
|
148
|
+
const result = await runCompiledStage({
|
|
149
|
+
executor: options.executor,
|
|
150
|
+
compiledPath: options.compiledPath,
|
|
151
|
+
reporter: options.reporter,
|
|
152
|
+
reportStep: options.reportStep,
|
|
153
|
+
stageDefinition,
|
|
154
|
+
});
|
|
155
|
+
return {
|
|
156
|
+
...result,
|
|
157
|
+
skipped: false,
|
|
158
|
+
plan: {
|
|
159
|
+
sourceCount,
|
|
160
|
+
summaryCount: 0,
|
|
161
|
+
targetCount: sourceCount,
|
|
162
|
+
},
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
export async function runCompiledCompile(options) {
|
|
166
|
+
const preserveMode = options.preserveStageShells ?? "on-failure";
|
|
167
|
+
if (preserveMode !== "always") {
|
|
168
|
+
pruneStageExecutionShells(options.compiledPath);
|
|
169
|
+
}
|
|
170
|
+
let lastResult = { ok: true, code: 0 };
|
|
171
|
+
try {
|
|
172
|
+
const context = resolveCompiledContext(options.compiledPath);
|
|
173
|
+
for (const stageDefinition of compiledExecutionStages(context.workflowId, options.compiledPath)) {
|
|
174
|
+
const result = await runCompiledStage({
|
|
175
|
+
executor: options.executor,
|
|
176
|
+
compiledPath: options.compiledPath,
|
|
177
|
+
reporter: options.reporter,
|
|
178
|
+
reportStep: options.reportStep,
|
|
179
|
+
stageDefinition,
|
|
180
|
+
});
|
|
181
|
+
lastResult = result;
|
|
182
|
+
if (!result.ok)
|
|
183
|
+
return result;
|
|
184
|
+
}
|
|
185
|
+
return lastResult;
|
|
186
|
+
}
|
|
187
|
+
finally {
|
|
188
|
+
if (preserveMode !== "always" && lastResult.ok) {
|
|
189
|
+
pruneStageExecutionShells(options.compiledPath);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
export async function compileCompiled(options) {
|
|
194
|
+
const preserveMode = options.preserveStageShells ?? "on-failure";
|
|
195
|
+
if (preserveMode !== "always") {
|
|
196
|
+
pruneStageExecutionShells(options.compiledPath);
|
|
197
|
+
}
|
|
198
|
+
let result = {
|
|
199
|
+
ok: true,
|
|
200
|
+
stageResults: {},
|
|
201
|
+
failedStage: null,
|
|
202
|
+
};
|
|
203
|
+
try {
|
|
204
|
+
const sourceInputPath = resolveSourceInputPath(options.compiledPath);
|
|
205
|
+
syncCompiledRawSnapshot(options.compiledPath, sourceInputPath);
|
|
206
|
+
refreshCompiledBootstrapGuidance(options.compiledPath);
|
|
207
|
+
const workflowValidation = validateWorkflowPackage(join(options.compiledPath, ".interf", "workflow"));
|
|
208
|
+
if (!workflowValidation.ok) {
|
|
209
|
+
reportValidationFailure(options.reporter, workflowValidation.summary, workflowValidation.errors);
|
|
210
|
+
return {
|
|
211
|
+
...result,
|
|
212
|
+
ok: false,
|
|
213
|
+
failedStage: "workflow",
|
|
214
|
+
stageResults: {
|
|
215
|
+
...result.stageResults,
|
|
216
|
+
workflow: {
|
|
217
|
+
ok: false,
|
|
218
|
+
code: 1,
|
|
219
|
+
summary: workflowValidation.summary,
|
|
220
|
+
},
|
|
221
|
+
},
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
const context = resolveCompiledContext(options.compiledPath);
|
|
225
|
+
const stages = compiledExecutionStages(context.workflowId, options.compiledPath);
|
|
226
|
+
for (const stageDefinition of stages) {
|
|
227
|
+
const stageResult = await runCompiledStage({
|
|
228
|
+
executor: options.executor,
|
|
229
|
+
compiledPath: options.compiledPath,
|
|
230
|
+
reporter: options.reporter,
|
|
231
|
+
reportStep: true,
|
|
232
|
+
stageDefinition,
|
|
233
|
+
});
|
|
234
|
+
result.stageResults[stageDefinition.id] = stageResult;
|
|
235
|
+
if (!stageResult.ok) {
|
|
236
|
+
result.ok = false;
|
|
237
|
+
result.failedStage = stageDefinition.id;
|
|
238
|
+
return result;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
const workflowValidationResult = validateCompiledWorkflow(options.compiledPath);
|
|
242
|
+
result.ok = workflowValidationResult.ok;
|
|
243
|
+
result.failedStage = workflowValidationResult.ok ? null : workflowValidationResult.stage;
|
|
244
|
+
result.stageResults.compiled = {
|
|
245
|
+
ok: workflowValidationResult.ok,
|
|
246
|
+
code: workflowValidationResult.ok ? 0 : 1,
|
|
247
|
+
summary: workflowValidationResult.summary,
|
|
248
|
+
};
|
|
249
|
+
return result;
|
|
250
|
+
}
|
|
251
|
+
finally {
|
|
252
|
+
if (preserveMode !== "always" && result.ok) {
|
|
253
|
+
pruneStageExecutionShells(options.compiledPath);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type BuiltinCompiledZoneId } from "../workflow-package/builtin-compiled-workflow.js";
|
|
2
|
+
import { type WorkflowCompiledSchema, type WorkflowCompiledZone, type WorkflowZoneId } from "./lib/schema.js";
|
|
3
|
+
export interface WorkflowSchemaStageLike {
|
|
4
|
+
id: string;
|
|
5
|
+
writes: readonly string[];
|
|
6
|
+
}
|
|
7
|
+
export { BUILTIN_COMPILED_ZONE_IDS } from "../workflow-package/builtin-compiled-workflow.js";
|
|
8
|
+
export declare const WORKFLOW_SCHEMA_FILE = "workflow.schema.json";
|
|
9
|
+
export declare function workflowSchemaFilePath(rootPath: string): string;
|
|
10
|
+
export declare function resolveWorkflowSchemaPath(rootPath: string): string | null;
|
|
11
|
+
export declare function workflowSchemaExists(rootPath: string): boolean;
|
|
12
|
+
export declare function workflowSchemaRelativePath(): string;
|
|
13
|
+
export declare function listCompiledSchemaZones(schema: WorkflowCompiledSchema): WorkflowCompiledZone[];
|
|
14
|
+
export declare function findCompiledSchemaZone(schema: WorkflowCompiledSchema, zoneId: WorkflowZoneId): WorkflowCompiledZone | null;
|
|
15
|
+
export declare function compiledZoneAbsolutePath(compiledPath: string, zone: Pick<WorkflowCompiledZone, "path">): string;
|
|
16
|
+
export declare function compiledContractArtifactPath(zone: Pick<WorkflowCompiledZone, "path" | "kind">): string;
|
|
17
|
+
export declare function compiledContractArtifactPathsForZoneIds(schema: WorkflowCompiledSchema, zoneIds: readonly WorkflowZoneId[]): string[];
|
|
18
|
+
export declare function builtinCompiledZoneRelativePath(zoneId: BuiltinCompiledZoneId): string;
|
|
19
|
+
export declare function builtinCompiledZoneAbsolutePath(compiledPath: string, zoneId: BuiltinCompiledZoneId): string;
|
|
20
|
+
export declare function compiledSummariesPath(compiledPath: string): string;
|
|
21
|
+
export declare function compiledKnowledgeEntitiesPath(compiledPath: string): string;
|
|
22
|
+
export declare function compiledKnowledgeClaimsPath(compiledPath: string): string;
|
|
23
|
+
export declare function compiledKnowledgeIndexesPath(compiledPath: string): string;
|
|
24
|
+
export declare function compiledKnowledgeRootPath(compiledPath: string): string;
|
|
25
|
+
export declare function compiledHomePath(compiledPath: string): string;
|
|
26
|
+
export declare function ensureCompiledZoneTargets(compiledPath: string, schema: WorkflowCompiledSchema): void;
|
|
27
|
+
export declare function buildWorkflowSchema(stages: WorkflowSchemaStageLike[], label?: string): WorkflowCompiledSchema;
|
|
28
|
+
export declare function writeWorkflowSchemaFile(rootPath: string, stages: WorkflowSchemaStageLike[], label?: string): WorkflowCompiledSchema;
|
|
29
|
+
export declare function writeWorkflowSchemaDocument(rootPath: string, schema: WorkflowCompiledSchema): WorkflowCompiledSchema;
|
|
30
|
+
export declare function readWorkflowSchemaFile(rootPath: string): WorkflowCompiledSchema | null;
|
|
31
|
+
export declare function readCompiledSchemaFile(rootPath: string): WorkflowCompiledSchema | null;
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { dirname, join } from "node:path";
|
|
3
|
+
import { warnInterf } from "../../lib/logger.js";
|
|
4
|
+
import { readJsonFileUnchecked } from "../../lib/parse.js";
|
|
5
|
+
import { BUILTIN_COMPILED_ZONE_IDS, listBuiltinCompiledZoneSpecs, requiredCompiledZoneOwners, } from "../workflow-package/builtin-compiled-workflow.js";
|
|
6
|
+
import { WorkflowCompiledSchemaSchema, } from "./lib/schema.js";
|
|
7
|
+
export { BUILTIN_COMPILED_ZONE_IDS } from "../workflow-package/builtin-compiled-workflow.js";
|
|
8
|
+
export const WORKFLOW_SCHEMA_FILE = "workflow.schema.json";
|
|
9
|
+
const BUILTIN_COMPILED_ZONE_SPEC_BY_ID = new Map(listBuiltinCompiledZoneSpecs().map((zone) => [zone.id, zone]));
|
|
10
|
+
export function workflowSchemaFilePath(rootPath) {
|
|
11
|
+
return join(rootPath, WORKFLOW_SCHEMA_FILE);
|
|
12
|
+
}
|
|
13
|
+
export function resolveWorkflowSchemaPath(rootPath) {
|
|
14
|
+
const path = workflowSchemaFilePath(rootPath);
|
|
15
|
+
return existsSync(path) ? path : null;
|
|
16
|
+
}
|
|
17
|
+
export function workflowSchemaExists(rootPath) {
|
|
18
|
+
return existsSync(workflowSchemaFilePath(rootPath));
|
|
19
|
+
}
|
|
20
|
+
export function workflowSchemaRelativePath() {
|
|
21
|
+
return `workflow/${WORKFLOW_SCHEMA_FILE}`;
|
|
22
|
+
}
|
|
23
|
+
export function listCompiledSchemaZones(schema) {
|
|
24
|
+
return [...schema.zones];
|
|
25
|
+
}
|
|
26
|
+
export function findCompiledSchemaZone(schema, zoneId) {
|
|
27
|
+
return schema.zones.find((zone) => zone.id === zoneId) ?? null;
|
|
28
|
+
}
|
|
29
|
+
export function compiledZoneAbsolutePath(compiledPath, zone) {
|
|
30
|
+
return join(compiledPath, zone.path);
|
|
31
|
+
}
|
|
32
|
+
export function compiledContractArtifactPath(zone) {
|
|
33
|
+
if (zone.kind === "file")
|
|
34
|
+
return zone.path;
|
|
35
|
+
return zone.path.endsWith("/") ? zone.path : `${zone.path}/`;
|
|
36
|
+
}
|
|
37
|
+
export function compiledContractArtifactPathsForZoneIds(schema, zoneIds) {
|
|
38
|
+
return zoneIds.map((zoneId) => {
|
|
39
|
+
const zone = findCompiledSchemaZone(schema, zoneId);
|
|
40
|
+
if (!zone) {
|
|
41
|
+
throw new Error(`Compiled schema is missing declared zone "${zoneId}".`);
|
|
42
|
+
}
|
|
43
|
+
return compiledContractArtifactPath(zone);
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
export function builtinCompiledZoneRelativePath(zoneId) {
|
|
47
|
+
const zone = BUILTIN_COMPILED_ZONE_SPEC_BY_ID.get(zoneId);
|
|
48
|
+
if (!zone) {
|
|
49
|
+
throw new Error(`Missing built-in compiled zone "${zoneId}".`);
|
|
50
|
+
}
|
|
51
|
+
return zone.path;
|
|
52
|
+
}
|
|
53
|
+
export function builtinCompiledZoneAbsolutePath(compiledPath, zoneId) {
|
|
54
|
+
return join(compiledPath, builtinCompiledZoneRelativePath(zoneId));
|
|
55
|
+
}
|
|
56
|
+
export function compiledSummariesPath(compiledPath) {
|
|
57
|
+
return builtinCompiledZoneAbsolutePath(compiledPath, BUILTIN_COMPILED_ZONE_IDS.SUMMARIES);
|
|
58
|
+
}
|
|
59
|
+
export function compiledKnowledgeEntitiesPath(compiledPath) {
|
|
60
|
+
return builtinCompiledZoneAbsolutePath(compiledPath, BUILTIN_COMPILED_ZONE_IDS.KNOWLEDGE_ENTITIES);
|
|
61
|
+
}
|
|
62
|
+
export function compiledKnowledgeClaimsPath(compiledPath) {
|
|
63
|
+
return builtinCompiledZoneAbsolutePath(compiledPath, BUILTIN_COMPILED_ZONE_IDS.KNOWLEDGE_CLAIMS);
|
|
64
|
+
}
|
|
65
|
+
export function compiledKnowledgeIndexesPath(compiledPath) {
|
|
66
|
+
return builtinCompiledZoneAbsolutePath(compiledPath, BUILTIN_COMPILED_ZONE_IDS.KNOWLEDGE_INDEXES);
|
|
67
|
+
}
|
|
68
|
+
export function compiledKnowledgeRootPath(compiledPath) {
|
|
69
|
+
return dirname(compiledKnowledgeEntitiesPath(compiledPath));
|
|
70
|
+
}
|
|
71
|
+
export function compiledHomePath(compiledPath) {
|
|
72
|
+
return builtinCompiledZoneAbsolutePath(compiledPath, BUILTIN_COMPILED_ZONE_IDS.HOME);
|
|
73
|
+
}
|
|
74
|
+
export function ensureCompiledZoneTargets(compiledPath, schema) {
|
|
75
|
+
for (const zone of schema.zones) {
|
|
76
|
+
if (zone.kind === "directory" || zone.kind === "runtime") {
|
|
77
|
+
mkdirSync(compiledZoneAbsolutePath(compiledPath, zone), { recursive: true });
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
mkdirSync(dirname(compiledZoneAbsolutePath(compiledPath, zone)), { recursive: true });
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
function pushZone(zones, zone) {
|
|
84
|
+
if (zones.some((existing) => existing.path === zone.path))
|
|
85
|
+
return;
|
|
86
|
+
zones.push(zone);
|
|
87
|
+
}
|
|
88
|
+
function normalizeWorkflowSchema(schema) {
|
|
89
|
+
return {
|
|
90
|
+
...schema,
|
|
91
|
+
kind: "workflow-schema",
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
export function buildWorkflowSchema(stages, label = "Workflow schema") {
|
|
95
|
+
const zones = [];
|
|
96
|
+
for (const zone of listBuiltinCompiledZoneSpecs()) {
|
|
97
|
+
pushZone(zones, {
|
|
98
|
+
id: zone.id,
|
|
99
|
+
role: zone.role,
|
|
100
|
+
path: zone.path,
|
|
101
|
+
kind: zone.kind,
|
|
102
|
+
required: zone.required,
|
|
103
|
+
owned_by: requiredCompiledZoneOwners(stages, zone.id),
|
|
104
|
+
description: zone.description,
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
return {
|
|
108
|
+
kind: "workflow-schema",
|
|
109
|
+
version: 1,
|
|
110
|
+
target_type: "compiled",
|
|
111
|
+
label,
|
|
112
|
+
zones,
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
export function writeWorkflowSchemaFile(rootPath, stages, label) {
|
|
116
|
+
const schema = buildWorkflowSchema(stages, label);
|
|
117
|
+
writeWorkflowSchemaDocument(rootPath, schema);
|
|
118
|
+
return schema;
|
|
119
|
+
}
|
|
120
|
+
export function writeWorkflowSchemaDocument(rootPath, schema) {
|
|
121
|
+
const normalized = normalizeWorkflowSchema(schema);
|
|
122
|
+
writeFileSync(workflowSchemaFilePath(rootPath), `${JSON.stringify(normalized, null, 2)}\n`);
|
|
123
|
+
return normalized;
|
|
124
|
+
}
|
|
125
|
+
export function readWorkflowSchemaFile(rootPath) {
|
|
126
|
+
const path = workflowSchemaFilePath(rootPath);
|
|
127
|
+
if (!existsSync(path))
|
|
128
|
+
return null;
|
|
129
|
+
const raw = readJsonFileUnchecked(path, "workflow schema");
|
|
130
|
+
if (raw === null)
|
|
131
|
+
return null;
|
|
132
|
+
const parsed = WorkflowCompiledSchemaSchema.safeParse(raw);
|
|
133
|
+
if (!parsed.success) {
|
|
134
|
+
warnInterf(`Warning: failed to validate workflow schema at ${path}: ${parsed.error.issues.map((issue) => issue.message).join("; ")}`);
|
|
135
|
+
return null;
|
|
136
|
+
}
|
|
137
|
+
return normalizeWorkflowSchema(parsed.data);
|
|
138
|
+
}
|
|
139
|
+
export function readCompiledSchemaFile(rootPath) {
|
|
140
|
+
return readWorkflowSchemaFile(rootPath);
|
|
141
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export * as primitives from "./workflow-primitives.js";
|
|
2
|
+
export * as schema from "./lib/schema.js";
|
|
3
|
+
export * as compiledSchema from "./compiled-schema.js";
|
|
4
|
+
export * as compile from "./compiled-compile.js";
|
|
5
|
+
export * as runtime from "./runtime.js";
|
|
6
|
+
export * as runtimeAcceptance from "./runtime-acceptance.js";
|
|
7
|
+
export * as runtimeContracts from "./runtime-contracts.js";
|
|
8
|
+
export * as runtimeInventory from "./runtime-inventory.js";
|
|
9
|
+
export * as runtimePaths from "./runtime-paths.js";
|
|
10
|
+
export * as runtimePrompt from "./runtime-prompt.js";
|
|
11
|
+
export * as runtimeReconcile from "./runtime-reconcile.js";
|
|
12
|
+
export * as runtimeRuns from "./runtime-runs.js";
|
|
13
|
+
export * as runtimeTypes from "./runtime-types.js";
|
|
14
|
+
export * as state from "./state.js";
|
|
15
|
+
export * as stateArtifacts from "./state-artifacts.js";
|
|
16
|
+
export * as stateHealth from "./state-health.js";
|
|
17
|
+
export * as stateIo from "./state-io.js";
|
|
18
|
+
export * as statePaths from "./state-paths.js";
|
|
19
|
+
export * as stateView from "./state-view.js";
|
|
20
|
+
export * as validate from "./validate.js";
|
|
21
|
+
export * as validateCompiled from "./validate-compiled.js";
|
|
22
|
+
export * as validateHelpers from "./validate-helpers.js";
|
|
23
|
+
export * as workflows from "./workflows.js";
|
|
24
|
+
export type { CompiledCompileResult, CompiledSummarizeResult, StageShellRetentionMode, } from "./workflows.js";
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export * as primitives from "./workflow-primitives.js";
|
|
2
|
+
export * as schema from "./lib/schema.js";
|
|
3
|
+
export * as compiledSchema from "./compiled-schema.js";
|
|
4
|
+
export * as compile from "./compiled-compile.js";
|
|
5
|
+
export * as runtime from "./runtime.js";
|
|
6
|
+
export * as runtimeAcceptance from "./runtime-acceptance.js";
|
|
7
|
+
export * as runtimeContracts from "./runtime-contracts.js";
|
|
8
|
+
export * as runtimeInventory from "./runtime-inventory.js";
|
|
9
|
+
export * as runtimePaths from "./runtime-paths.js";
|
|
10
|
+
export * as runtimePrompt from "./runtime-prompt.js";
|
|
11
|
+
export * as runtimeReconcile from "./runtime-reconcile.js";
|
|
12
|
+
export * as runtimeRuns from "./runtime-runs.js";
|
|
13
|
+
export * as runtimeTypes from "./runtime-types.js";
|
|
14
|
+
export * as state from "./state.js";
|
|
15
|
+
export * as stateArtifacts from "./state-artifacts.js";
|
|
16
|
+
export * as stateHealth from "./state-health.js";
|
|
17
|
+
export * as stateIo from "./state-io.js";
|
|
18
|
+
export * as statePaths from "./state-paths.js";
|
|
19
|
+
export * as stateView from "./state-view.js";
|
|
20
|
+
export * as validate from "./validate.js";
|
|
21
|
+
export * as validateCompiled from "./validate-compiled.js";
|
|
22
|
+
export * as validateHelpers from "./validate-helpers.js";
|
|
23
|
+
export * as workflows from "./workflows.js";
|