@interf/compiler 0.13.0 → 0.18.0
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/LICENSE.md +1 -0
- package/README.md +50 -7
- package/TRADEMARKS.md +4 -4
- package/agent-skills/interf-actions/SKILL.md +51 -5
- package/agent-skills/interf-actions/references/cli.md +82 -82
- package/builtin-methods/interf-default/README.md +6 -7
- package/builtin-methods/interf-default/method.json +7 -68
- package/builtin-methods/interf-default/method.schema.json +52 -50
- package/dist/cli/commands/agents.d.ts +2 -0
- package/dist/cli/commands/agents.js +213 -0
- package/dist/cli/commands/compile.js +10 -1
- package/dist/cli/commands/doctor.js +1 -1
- package/dist/cli/commands/login.js +1 -1
- package/dist/cli/commands/logout.js +1 -1
- package/dist/cli/commands/mcp.d.ts +42 -0
- package/dist/cli/commands/mcp.js +239 -0
- package/dist/cli/commands/method.js +1 -1
- package/dist/cli/commands/prep.js +81 -7
- package/dist/cli/commands/reset.js +1 -1
- package/dist/cli/commands/runs.js +1 -1
- package/dist/cli/commands/status.js +1 -1
- package/dist/cli/commands/verify.d.ts +10 -0
- package/dist/cli/commands/{test.js → verify.js} +30 -15
- package/dist/cli/commands/web.js +71 -18
- package/dist/cli/commands/wizard.js +462 -107
- package/dist/cli/index.d.ts +4 -2
- package/dist/cli/index.js +7 -3
- package/dist/compiler-ui/404.html +1 -1
- package/dist/compiler-ui/__next.__PAGE__.txt +2 -2
- package/dist/compiler-ui/__next._full.txt +3 -3
- package/dist/compiler-ui/__next._head.txt +1 -1
- package/dist/compiler-ui/__next._index.txt +2 -2
- package/dist/compiler-ui/__next._tree.txt +2 -2
- package/dist/compiler-ui/_next/static/chunks/{045gole2ojo3g.css → 0_c_tvh-cukjz.css} +1 -1
- package/dist/compiler-ui/_next/static/chunks/0f_geuwdesg_c.js +114 -0
- package/dist/compiler-ui/_not-found/__next._full.txt +2 -2
- package/dist/compiler-ui/_not-found/__next._head.txt +1 -1
- package/dist/compiler-ui/_not-found/__next._index.txt +2 -2
- package/dist/compiler-ui/_not-found/__next._not-found.__PAGE__.txt +1 -1
- package/dist/compiler-ui/_not-found/__next._not-found.txt +1 -1
- package/dist/compiler-ui/_not-found/__next._tree.txt +2 -2
- package/dist/compiler-ui/_not-found.html +1 -1
- package/dist/compiler-ui/_not-found.txt +2 -2
- package/dist/compiler-ui/index.html +1 -1
- package/dist/compiler-ui/index.txt +3 -3
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/packages/contracts/index.d.ts +2 -1
- package/dist/packages/contracts/index.js +1 -0
- package/dist/packages/contracts/lib/schema.d.ts +324 -31
- package/dist/packages/contracts/lib/schema.js +281 -21
- package/dist/packages/{local-service → engine}/action-definitions.js +9 -2
- package/dist/packages/{local-service → engine}/action-planner.d.ts +1 -1
- package/dist/packages/{local-service → engine}/action-planner.js +1 -1
- package/dist/packages/{agents → engine/agents}/index.d.ts +3 -0
- package/dist/packages/{agents → engine/agents}/index.js +3 -0
- package/dist/packages/{agents → engine/agents}/lib/compiled-bootstrap.js +2 -2
- package/dist/packages/engine/agents/lib/detection.d.ts +13 -0
- package/dist/packages/{agents → engine/agents}/lib/detection.js +11 -0
- package/dist/packages/{agents → engine/agents}/lib/executors.d.ts +2 -2
- package/dist/packages/{agents → engine/agents}/lib/shells.d.ts +14 -6
- package/dist/packages/{agents → engine/agents}/lib/shells.js +133 -126
- package/dist/packages/{agents → engine/agents}/lib/user-config.js +2 -2
- package/dist/packages/engine/agents/registry.d.ts +91 -0
- package/dist/packages/engine/agents/registry.js +321 -0
- package/dist/packages/engine/agents/role-executors.d.ts +35 -0
- package/dist/packages/engine/agents/role-executors.js +88 -0
- package/dist/packages/engine/agents/role-router.d.ts +66 -0
- package/dist/packages/engine/agents/role-router.js +73 -0
- package/dist/packages/{local-service → engine}/client.d.ts +9 -9
- package/dist/packages/{local-service → engine}/client.js +11 -11
- package/dist/packages/engine/cloud-seams.d.ts +115 -0
- package/dist/packages/engine/cloud-seams.js +84 -0
- package/dist/packages/engine/compile/artifact-counts.d.ts +1 -0
- package/dist/packages/{compiler → engine/compile}/artifact-counts.js +4 -4
- package/dist/packages/engine/compile/artifact-status.d.ts +41 -0
- package/dist/packages/engine/compile/artifact-status.js +166 -0
- package/dist/packages/engine/compile/billing-events.d.ts +89 -0
- package/dist/packages/engine/compile/billing-events.js +74 -0
- package/dist/packages/engine/compile/check-evaluator.d.ts +66 -0
- package/dist/packages/engine/compile/check-evaluator.js +298 -0
- package/dist/packages/{compiler → engine/compile}/compiled-pipeline.d.ts +12 -1
- package/dist/packages/{compiler → engine/compile}/compiled-pipeline.js +16 -6
- package/dist/packages/engine/compile/compiled-schema.d.ts +21 -0
- package/dist/packages/engine/compile/compiled-schema.js +126 -0
- package/dist/packages/{compiler → engine/compile}/compiled-stage-plan.d.ts +2 -1
- package/dist/packages/{compiler → engine/compile}/compiled-stage-plan.js +35 -18
- package/dist/packages/{compiler → engine/compile}/compiled-stage-runner.d.ts +1 -1
- package/dist/packages/{compiler → engine/compile}/compiled-stage-runner.js +4 -4
- package/dist/packages/{compiler → engine/compile}/compiled-target.d.ts +2 -2
- package/dist/packages/{compiler → engine/compile}/compiled-target.js +2 -2
- package/dist/packages/{compiler → engine/compile}/discovery.js +1 -1
- package/dist/packages/{compiler → engine/compile}/index.d.ts +0 -1
- package/dist/packages/{compiler → engine/compile}/index.js +0 -1
- package/dist/packages/{compiler → engine/compile}/lib/schema.d.ts +113 -94
- package/dist/packages/{compiler → engine/compile}/lib/schema.js +35 -39
- package/dist/packages/engine/compile/method-primitives.d.ts +2 -0
- package/dist/packages/{compiler → engine/compile}/method-primitives.js +1 -1
- package/dist/packages/{compiler → engine/compile}/method-runs.d.ts +3 -3
- package/dist/packages/{compiler → engine/compile}/method-runs.js +3 -3
- package/dist/packages/{compiler → engine/compile}/reset.js +4 -4
- package/dist/packages/{compiler → engine/compile}/runtime-contracts.js +2 -1
- package/dist/packages/{compiler → engine/compile}/runtime-prompt.js +3 -2
- package/dist/packages/{compiler → engine/compile}/runtime-reconcile.d.ts +1 -1
- package/dist/packages/{compiler → engine/compile}/runtime-reconcile.js +47 -45
- package/dist/packages/{compiler → engine/compile}/runtime-runs.d.ts +1 -2
- package/dist/packages/{compiler → engine/compile}/runtime-runs.js +3 -44
- package/dist/packages/{compiler → engine/compile}/runtime-types.d.ts +7 -12
- package/dist/packages/engine/compile/runtime.d.ts +5 -0
- package/dist/packages/{compiler → engine/compile}/runtime.js +1 -2
- package/dist/packages/{compiler → engine/compile}/source-files.d.ts +1 -1
- package/dist/packages/{compiler → engine/compile}/source-files.js +3 -3
- package/dist/packages/{compiler → engine/compile}/state-health.js +8 -8
- package/dist/packages/{compiler → engine/compile}/state-io.js +2 -2
- package/dist/packages/{compiler → engine/compile}/state-view.js +9 -8
- package/dist/packages/{compiler → engine/compile}/validate-compiled.js +63 -32
- package/dist/packages/{compiler → engine/compile}/validate.d.ts +1 -1
- package/dist/packages/{compiler → engine/compile}/validate.js +29 -27
- package/dist/packages/{execution → engine/execution}/lib/schema.d.ts +81 -55
- package/dist/packages/{execution → engine/execution}/lib/schema.js +14 -6
- package/dist/packages/engine/index.d.ts +22 -0
- package/dist/packages/engine/index.js +15 -0
- package/dist/packages/{local-service → engine}/lib/schema.d.ts +620 -435
- package/dist/packages/{local-service → engine}/lib/schema.js +103 -63
- package/dist/packages/{local-service → engine}/native-run-handlers.d.ts +7 -5
- package/dist/packages/{local-service → engine}/native-run-handlers.js +81 -29
- package/dist/packages/{local-service → engine}/preparation-store.d.ts +22 -4
- package/dist/packages/{local-service → engine}/preparation-store.js +56 -25
- package/dist/packages/{local-service → engine}/readiness-check-draft.d.ts +2 -2
- package/dist/packages/{local-service → engine}/routes.d.ts +36 -1
- package/dist/packages/{local-service → engine}/routes.js +38 -1
- package/dist/packages/{local-service → engine}/run-observability.d.ts +3 -3
- package/dist/packages/{local-service → engine}/run-observability.js +15 -15
- package/dist/packages/{local-service → engine}/runtime-event-applier.d.ts +1 -1
- package/dist/packages/{local-service → engine}/runtime-event-applier.js +7 -0
- package/dist/packages/{local-service → engine}/runtime-persistence.d.ts +6 -6
- package/dist/packages/{local-service → engine}/runtime-persistence.js +9 -9
- package/dist/packages/{local-service → engine}/runtime-proposal-helpers.d.ts +1 -1
- package/dist/packages/{local-service → engine}/runtime-proposal-helpers.js +5 -5
- package/dist/packages/{local-service → engine}/runtime-resource-builders.d.ts +12 -12
- package/dist/packages/{local-service → engine}/runtime-resource-builders.js +6 -5
- package/dist/packages/{local-service → engine}/runtime.d.ts +147 -56
- package/dist/packages/{local-service → engine}/runtime.js +333 -205
- package/dist/packages/{local-service → engine}/server.d.ts +25 -0
- package/dist/packages/{local-service → engine}/server.js +338 -17
- package/dist/packages/engine/verify/index.d.ts +13 -0
- package/dist/packages/engine/verify/index.js +10 -0
- package/dist/packages/{testing → engine/verify}/lib/schema.d.ts +1 -1
- package/dist/packages/{testing → engine/verify}/lib/schema.js +1 -1
- package/dist/packages/{testing → engine/verify}/readiness-check-run.d.ts +27 -11
- package/dist/packages/{testing → engine/verify}/readiness-check-run.js +72 -60
- package/dist/packages/{testing/test-execution.d.ts → engine/verify/verify-execution.d.ts} +2 -2
- package/dist/packages/{testing/test-execution.js → engine/verify/verify-execution.js} +2 -2
- package/dist/packages/{testing/test-paths.d.ts → engine/verify/verify-paths.d.ts} +1 -1
- package/dist/packages/{testing/test-paths.js → engine/verify/verify-paths.js} +2 -2
- package/dist/packages/{testing/test-sandbox.d.ts → engine/verify/verify-sandbox.d.ts} +1 -1
- package/dist/packages/{testing/test-sandbox.js → engine/verify/verify-sandbox.js} +6 -6
- package/dist/packages/{testing/test-specs.d.ts → engine/verify/verify-specs.d.ts} +1 -1
- package/dist/packages/{testing/test-specs.js → engine/verify/verify-specs.js} +2 -2
- package/dist/packages/{testing/test-targets.d.ts → engine/verify/verify-targets.d.ts} +1 -1
- package/dist/packages/{testing/test-targets.js → engine/verify/verify-targets.js} +3 -3
- package/dist/packages/{testing/test.d.ts → engine/verify/verify.d.ts} +4 -4
- package/dist/packages/{testing/test.js → engine/verify/verify.js} +3 -3
- package/dist/packages/engine/wire-schemas.d.ts +545 -0
- package/dist/packages/engine/wire-schemas.js +59 -0
- package/dist/packages/methods/authoring/method-authoring.d.ts +34 -0
- package/dist/packages/methods/authoring/method-authoring.js +260 -0
- package/dist/packages/{method-authoring → methods/authoring}/method-edit-session.d.ts +2 -2
- package/dist/packages/{method-authoring → methods/authoring}/method-edit-session.js +5 -5
- package/dist/packages/{method-authoring → methods/authoring}/method-improvement.d.ts +4 -4
- package/dist/packages/{method-authoring → methods/authoring}/method-improvement.js +16 -10
- package/dist/packages/{method-package → methods/package}/builtin-compiled-method.d.ts +12 -12
- package/dist/packages/{method-package → methods/package}/builtin-compiled-method.js +27 -24
- package/dist/packages/methods/package/context-interface.d.ts +73 -0
- package/dist/packages/{method-package → methods/package}/context-interface.js +50 -41
- package/dist/packages/{method-package → methods/package}/interf-method-package.js +31 -49
- package/dist/packages/{method-package → methods/package}/lib/package-root.js +2 -2
- package/dist/packages/{method-package → methods/package}/local-methods.d.ts +10 -5
- package/dist/packages/{method-package → methods/package}/local-methods.js +41 -68
- package/dist/packages/{method-package → methods/package}/method-definitions.d.ts +11 -7
- package/dist/packages/{method-package → methods/package}/method-definitions.js +5 -8
- package/dist/packages/{method-package → methods/package}/method-helpers.d.ts +1 -3
- package/dist/packages/{method-package → methods/package}/method-helpers.js +4 -8
- package/dist/packages/{method-package → methods/package}/method-review-paths.d.ts +1 -1
- package/dist/packages/{method-package → methods/package}/method-review-paths.js +1 -1
- package/dist/packages/{method-package → methods/package}/method-stage-runner.d.ts +4 -9
- package/dist/packages/{method-package → methods/package}/method-stage-runner.js +1 -29
- package/dist/packages/{method-package → methods/package}/user-methods.js +2 -2
- package/dist/packages/{project-model → project}/interf-bootstrap.d.ts +1 -1
- package/dist/packages/{project-model → project}/interf-bootstrap.js +1 -1
- package/dist/packages/{project-model → project}/interf-detect.js +4 -4
- package/dist/packages/{project-model → project}/interf-scaffold.js +18 -18
- package/dist/packages/{project-model → project}/lib/schema.d.ts +2 -2
- package/dist/packages/{project-model → project}/lib/schema.js +1 -1
- package/dist/packages/{project-model → project}/source-config.d.ts +1 -1
- package/dist/packages/{project-model → project}/source-config.js +9 -8
- package/dist/packages/{project-model → project}/source-folders.js +2 -2
- package/package.json +7 -16
- package/dist/cli/commands/test.d.ts +0 -9
- package/dist/compiler-ui/_next/static/chunks/17t-lulmyawg5.js +0 -89
- package/dist/packages/agents/lib/detection.d.ts +0 -7
- package/dist/packages/compiler/artifact-counts.d.ts +0 -1
- package/dist/packages/compiler/compiled-schema.d.ts +0 -31
- package/dist/packages/compiler/compiled-schema.js +0 -141
- package/dist/packages/compiler/method-primitives.d.ts +0 -2
- package/dist/packages/compiler/runtime-acceptance.d.ts +0 -9
- package/dist/packages/compiler/runtime-acceptance.js +0 -262
- package/dist/packages/compiler/runtime.d.ts +0 -6
- package/dist/packages/local-service/index.d.ts +0 -22
- package/dist/packages/local-service/index.js +0 -15
- package/dist/packages/method-authoring/method-authoring.d.ts +0 -24
- package/dist/packages/method-authoring/method-authoring.js +0 -116
- package/dist/packages/method-package/context-interface.d.ts +0 -60
- package/dist/packages/testing/index.d.ts +0 -13
- package/dist/packages/testing/index.js +0 -10
- /package/dist/compiler-ui/_next/static/{C6vVfy3aeYuIO3d2AoNvC → 6qyE1u9m_oBUkvAhhoCmO}/_buildManifest.js +0 -0
- /package/dist/compiler-ui/_next/static/{C6vVfy3aeYuIO3d2AoNvC → 6qyE1u9m_oBUkvAhhoCmO}/_clientMiddlewareManifest.js +0 -0
- /package/dist/compiler-ui/_next/static/{C6vVfy3aeYuIO3d2AoNvC → 6qyE1u9m_oBUkvAhhoCmO}/_ssgManifest.js +0 -0
- /package/dist/packages/{shared → contracts/utils}/file-types.d.ts +0 -0
- /package/dist/packages/{shared → contracts/utils}/file-types.js +0 -0
- /package/dist/packages/{shared → contracts/utils}/filesystem.d.ts +0 -0
- /package/dist/packages/{shared → contracts/utils}/filesystem.js +0 -0
- /package/dist/packages/{shared → contracts/utils}/logger.d.ts +0 -0
- /package/dist/packages/{shared → contracts/utils}/logger.js +0 -0
- /package/dist/packages/{shared → contracts/utils}/naming.d.ts +0 -0
- /package/dist/packages/{shared → contracts/utils}/naming.js +0 -0
- /package/dist/packages/{shared → contracts/utils}/parse.d.ts +0 -0
- /package/dist/packages/{shared → contracts/utils}/parse.js +0 -0
- /package/dist/packages/{shared → contracts/utils}/path-guards.d.ts +0 -0
- /package/dist/packages/{shared → contracts/utils}/path-guards.js +0 -0
- /package/dist/packages/{local-service → engine}/action-definitions.d.ts +0 -0
- /package/dist/packages/{local-service → engine}/action-values.d.ts +0 -0
- /package/dist/packages/{local-service → engine}/action-values.js +0 -0
- /package/dist/packages/{agents → engine/agents}/lib/agents.d.ts +0 -0
- /package/dist/packages/{agents → engine/agents}/lib/agents.js +0 -0
- /package/dist/packages/{agents → engine/agents}/lib/args.d.ts +0 -0
- /package/dist/packages/{agents → engine/agents}/lib/args.js +0 -0
- /package/dist/packages/{agents → engine/agents}/lib/chart-guidance.d.ts +0 -0
- /package/dist/packages/{agents → engine/agents}/lib/chart-guidance.js +0 -0
- /package/dist/packages/{agents → engine/agents}/lib/compiled-bootstrap.d.ts +0 -0
- /package/dist/packages/{agents → engine/agents}/lib/constants.d.ts +0 -0
- /package/dist/packages/{agents → engine/agents}/lib/constants.js +0 -0
- /package/dist/packages/{agents → engine/agents}/lib/execution-profile.d.ts +0 -0
- /package/dist/packages/{agents → engine/agents}/lib/execution-profile.js +0 -0
- /package/dist/packages/{agents → engine/agents}/lib/execution.d.ts +0 -0
- /package/dist/packages/{agents → engine/agents}/lib/execution.js +0 -0
- /package/dist/packages/{agents → engine/agents}/lib/executors.js +0 -0
- /package/dist/packages/{agents → engine/agents}/lib/logs.d.ts +0 -0
- /package/dist/packages/{agents → engine/agents}/lib/logs.js +0 -0
- /package/dist/packages/{agents → engine/agents}/lib/preflight.d.ts +0 -0
- /package/dist/packages/{agents → engine/agents}/lib/preflight.js +0 -0
- /package/dist/packages/{agents → engine/agents}/lib/render.d.ts +0 -0
- /package/dist/packages/{agents → engine/agents}/lib/render.js +0 -0
- /package/dist/packages/{agents → engine/agents}/lib/schema.d.ts +0 -0
- /package/dist/packages/{agents → engine/agents}/lib/schema.js +0 -0
- /package/dist/packages/{agents → engine/agents}/lib/status.d.ts +0 -0
- /package/dist/packages/{agents → engine/agents}/lib/status.js +0 -0
- /package/dist/packages/{agents → engine/agents}/lib/types.d.ts +0 -0
- /package/dist/packages/{agents → engine/agents}/lib/types.js +0 -0
- /package/dist/packages/{agents → engine/agents}/lib/user-config.d.ts +0 -0
- /package/dist/packages/{compiler → engine/compile}/compiled-compile.d.ts +0 -0
- /package/dist/packages/{compiler → engine/compile}/compiled-compile.js +0 -0
- /package/dist/packages/{compiler → engine/compile}/compiled-paths.d.ts +0 -0
- /package/dist/packages/{compiler → engine/compile}/compiled-paths.js +0 -0
- /package/dist/packages/{compiler → engine/compile}/discovery.d.ts +0 -0
- /package/dist/packages/{compiler → engine/compile}/reset.d.ts +0 -0
- /package/dist/packages/{compiler → engine/compile}/runtime-contracts.d.ts +0 -0
- /package/dist/packages/{compiler → engine/compile}/runtime-inventory.d.ts +0 -0
- /package/dist/packages/{compiler → engine/compile}/runtime-inventory.js +0 -0
- /package/dist/packages/{compiler → engine/compile}/runtime-paths.d.ts +0 -0
- /package/dist/packages/{compiler → engine/compile}/runtime-paths.js +0 -0
- /package/dist/packages/{compiler → engine/compile}/runtime-prompt.d.ts +0 -0
- /package/dist/packages/{compiler → engine/compile}/runtime-types.js +0 -0
- /package/dist/packages/{compiler → engine/compile}/state-artifacts.d.ts +0 -0
- /package/dist/packages/{compiler → engine/compile}/state-artifacts.js +0 -0
- /package/dist/packages/{compiler → engine/compile}/state-health.d.ts +0 -0
- /package/dist/packages/{compiler → engine/compile}/state-io.d.ts +0 -0
- /package/dist/packages/{compiler → engine/compile}/state-paths.d.ts +0 -0
- /package/dist/packages/{compiler → engine/compile}/state-paths.js +0 -0
- /package/dist/packages/{compiler → engine/compile}/state-view.d.ts +0 -0
- /package/dist/packages/{compiler → engine/compile}/state.d.ts +0 -0
- /package/dist/packages/{compiler → engine/compile}/state.js +0 -0
- /package/dist/packages/{compiler → engine/compile}/validate-compiled.d.ts +0 -0
- /package/dist/packages/{compiler → engine/compile}/validate-helpers.d.ts +0 -0
- /package/dist/packages/{compiler → engine/compile}/validate-helpers.js +0 -0
- /package/dist/packages/{local-service → engine}/connection-config.d.ts +0 -0
- /package/dist/packages/{local-service → engine}/connection-config.js +0 -0
- /package/dist/packages/{execution → engine/execution}/adapters.d.ts +0 -0
- /package/dist/packages/{execution → engine/execution}/adapters.js +0 -0
- /package/dist/packages/{execution → engine/execution}/events.d.ts +0 -0
- /package/dist/packages/{execution → engine/execution}/events.js +0 -0
- /package/dist/packages/{execution → engine/execution}/index.d.ts +0 -0
- /package/dist/packages/{execution → engine/execution}/index.js +0 -0
- /package/dist/packages/{local-service → engine}/instance-paths.d.ts +0 -0
- /package/dist/packages/{local-service → engine}/instance-paths.js +0 -0
- /package/dist/packages/{local-service → engine}/readiness-check-draft.js +0 -0
- /package/dist/packages/{local-service → engine}/runtime-caches.d.ts +0 -0
- /package/dist/packages/{local-service → engine}/runtime-caches.js +0 -0
- /package/dist/packages/{local-service → engine}/service-registry.d.ts +0 -0
- /package/dist/packages/{local-service → engine}/service-registry.js +0 -0
- /package/dist/packages/{testing/test-profile-presets.d.ts → engine/verify/verify-profile-presets.d.ts} +0 -0
- /package/dist/packages/{testing/test-profile-presets.js → engine/verify/verify-profile-presets.js} +0 -0
- /package/dist/packages/{testing/test-types.d.ts → engine/verify/verify-types.d.ts} +0 -0
- /package/dist/packages/{testing/test-types.js → engine/verify/verify-types.js} +0 -0
- /package/dist/packages/{method-authoring → methods/authoring}/index.d.ts +0 -0
- /package/dist/packages/{method-authoring → methods/authoring}/index.js +0 -0
- /package/dist/packages/{method-authoring → methods/authoring}/lib/method-edit-utils.d.ts +0 -0
- /package/dist/packages/{method-authoring → methods/authoring}/lib/method-edit-utils.js +0 -0
- /package/dist/packages/{method-package → methods/package}/interf-method-package.d.ts +0 -0
- /package/dist/packages/{method-package → methods/package}/lib/package-root.d.ts +0 -0
- /package/dist/packages/{method-package → methods/package}/user-methods.d.ts +0 -0
- /package/dist/packages/{project-model → project}/index.d.ts +0 -0
- /package/dist/packages/{project-model → project}/index.js +0 -0
- /package/dist/packages/{project-model → project}/interf-detect.d.ts +0 -0
- /package/dist/packages/{project-model → project}/interf-scaffold.d.ts +0 -0
- /package/dist/packages/{project-model → project}/interf.d.ts +0 -0
- /package/dist/packages/{project-model → project}/interf.js +0 -0
- /package/dist/packages/{project-model → project}/preparation-entries.d.ts +0 -0
- /package/dist/packages/{project-model → project}/preparation-entries.js +0 -0
- /package/dist/packages/{project-model → project}/source-folders.d.ts +0 -0
|
@@ -1,37 +1,43 @@
|
|
|
1
1
|
import { existsSync, mkdirSync, rmSync, statSync, } from "node:fs";
|
|
2
2
|
import { join, resolve } from "node:path";
|
|
3
|
-
import { CompileRunSchema, } from "
|
|
4
|
-
import { createRunEventId, createRunEventTimestamp, } from "
|
|
5
|
-
import { loadState, } from "
|
|
6
|
-
import { actionProposalPath, actionProposalsRoot, byCreatedAtDesc, compileRunPath, compileRunsRoot, listJsonFiles, localJobPath, localJobsRoot, newestFirst, readActionProposalAt, readCompileRunAt, readLocalJobRunAt, readRuntimeRunHistory,
|
|
3
|
+
import { CompileRunSchema, } from "./execution/lib/schema.js";
|
|
4
|
+
import { createRunEventId, createRunEventTimestamp, } from "./execution/events.js";
|
|
5
|
+
import { loadState, } from "./compile/state.js";
|
|
6
|
+
import { actionProposalPath, actionProposalsRoot, byCreatedAtDesc, compileRunPath, compileRunsRoot, listJsonFiles, localJobPath, localJobsRoot, newestFirst, readActionProposalAt, readCompileRunAt, readLocalJobRunAt, readRuntimeRunHistory, readVerifyRunAt, verifyRunPath, verifyRunsRoot, timestampKey, writeJsonFile, } from "./runtime-persistence.js";
|
|
7
7
|
import { MethodListingCache, MtimeListingCache, ReadinessCache, RunListingCache, } from "./runtime-caches.js";
|
|
8
8
|
import { applyEventToCompileRun, applyEventToLocalJob, } from "./runtime-event-applier.js";
|
|
9
9
|
import { buildMethodResource, buildPreparationResource, createRunId, logsForRuntimeRun, logsForStageRun, proofForStage, readinessStateToPreparationReadiness, readinessSummaryForStatus, readinessTargetResult, stageArtifactRefs, } from "./runtime-resource-builders.js";
|
|
10
|
-
import { ACTION_PLANNER_CLARIFICATION_MESSAGE, actionAssistantMessage, actionCommandPreview, actionTypeFromValues, actionValueMethodTaskPrompt, configuredAgentName, createActionProposalId, detachMethodFromPreparation, detectedExecutorOptions, directServiceEndpointForAction, hasCompiledTestTarget, methodAuthoringHintFromPrompt, methodAuthoringPromptFallback, methodIdForProposal, methodLabelFromId, numberValue, requireSelectedMethod, sanitizeActionProposalPlan, stringValue, testModeFromValues,
|
|
11
|
-
import {
|
|
12
|
-
import { discoverSourceFiles, } from "
|
|
13
|
-
import { resetCompiledGeneratedState, } from "
|
|
14
|
-
import { ensurePortableContextScaffold, readInterfConfig, } from "../project
|
|
15
|
-
import { findSourcePreparationConfig, fingerprintReadinessChecks, listSourcePreparationConfigs, loadSourceFolderConfig, DEFAULT_METHOD_ID, methodIdForSourcePreparationConfig, resolveConfiguredSourceFolderPath, resolveSourcePreparationPath, removeSourcePreparationConfig, saveSourceFolderConfig, syncCompiledInterfConfigFromSourcePreparationConfig, upsertSourcePreparationConfig, } from "../project
|
|
16
|
-
import { listSourceFolderChoices, } from "../project
|
|
10
|
+
import { ACTION_PLANNER_CLARIFICATION_MESSAGE, actionAssistantMessage, actionCommandPreview, actionTypeFromValues, actionValueMethodTaskPrompt, configuredAgentName, createActionProposalId, detachMethodFromPreparation, detectedExecutorOptions, directServiceEndpointForAction, hasCompiledTestTarget, methodAuthoringHintFromPrompt, methodAuthoringPromptFallback, methodIdForProposal, methodLabelFromId, numberValue, requireSelectedMethod, sanitizeActionProposalPlan, stringValue, testModeFromValues, } from "./runtime-proposal-helpers.js";
|
|
11
|
+
import { ReadinessSchema, } from "../contracts/lib/schema.js";
|
|
12
|
+
import { discoverSourceFiles, } from "./compile/discovery.js";
|
|
13
|
+
import { resetCompiledGeneratedState, } from "./compile/reset.js";
|
|
14
|
+
import { ensurePortableContextScaffold, readInterfConfig, } from "../project/interf.js";
|
|
15
|
+
import { findSourcePreparationConfig, fingerprintReadinessChecks, listSourcePreparationConfigs, loadSourceFolderConfig, DEFAULT_METHOD_ID, methodIdForSourcePreparationConfig, resolveConfiguredSourceFolderPath, resolveSourcePreparationPath, removeSourcePreparationConfig, saveSourceFolderConfig, syncCompiledInterfConfigFromSourcePreparationConfig, upsertSourcePreparationConfig, } from "../project/source-config.js";
|
|
16
|
+
import { listSourceFolderChoices, } from "../project/source-folders.js";
|
|
17
17
|
import { asPreparationDataDir, preparationPortableContextPath, userMethodsRoot, preparationConfigPath, preparationMethodPackagePath, preparationMethodsRoot, } from "../contracts/lib/preparation-paths.js";
|
|
18
|
-
import { getCompiledMethod, listCompiledMethodChoices, } from "../
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
18
|
+
import { getCompiledMethod, listCompiledMethodChoices, } from "../methods/package/method-definitions.js";
|
|
19
|
+
import { computeArtifactStatuses, } from "./compile/artifact-status.js";
|
|
20
|
+
import { JsonlBillingEventSink, buildCompilationEventsForRun, defaultBillingEventLogPath, } from "./compile/billing-events.js";
|
|
21
|
+
import { methodDefinitionPath, resolveMethodPackageSourcePath, } from "../methods/package/local-methods.js";
|
|
22
|
+
import { seedLocalMethodPackageFromBase, } from "../methods/package/interf-method-package.js";
|
|
23
|
+
import { PACKAGE_ROOT } from "../methods/package/lib/package-root.js";
|
|
24
|
+
import { resolveAgent, detectAgents, supportsAutomatedRuns, } from "./agents/lib/detection.js";
|
|
25
|
+
import { loadUserConfig, saveUserConfig, } from "./agents/lib/user-config.js";
|
|
26
|
+
import { loadAgentsRegistry, registerCustomAgent, unregisterCustomAgent, patchRoleMap, setActiveAgent, } from "./agents/registry.js";
|
|
27
|
+
import { readSavedReadinessCheckRun, } from "./verify/readiness-check-run.js";
|
|
28
|
+
import { createCompiledTestTarget, } from "./verify/verify-targets.js";
|
|
29
|
+
import { ActionProposalApprovalRequestSchema, ActionProposalCreateRequestSchema, ActionProposalPlanSchema, ActionProposalResourceSchema, ActionProposalTypeSchema, CompileRunCreateRequestSchema, CompileRunResourceSchema, LocalExecutorStatusSchema, LocalExecutorSelectRequestSchema, LocalServiceHealthSchema, LocalRunHandlerResultSchema, LocalJobEventAppendRequestSchema, LocalJobRunCreateRequestSchema, LocalJobRunResourceSchema, SourceFileResourceSchema, WorkspaceFileResourceSchema, PortableContextResourceSchema, PreparationSetupCreateRequestSchema, PreparationSetupResultSchema, MethodChangeCreateRequestSchema, MethodChangeResultSchema, PreparationChangeCreateRequestSchema, PreparationChangeResultSchema, ReadinessCheckDraftCreateRequestSchema, ReadinessCheckDraftResultSchema, ResetRequestSchema, ResetResultSchema, ServiceRegistryWorkspaceSchema, VerifyRunCreateRequestSchema, VerifyRunResourceSchema, MethodAuthoringCreateRequestSchema, MethodAuthoringResultSchema, } from "./lib/schema.js";
|
|
28
30
|
import { buildLocalServiceUrl, } from "./routes.js";
|
|
29
31
|
import { MethodAuthoringActionValuesSchema, PreparationSetupActionValuesSchema, } from "./action-values.js";
|
|
30
|
-
import { compileRunToObservability, jobRunToObservability,
|
|
32
|
+
import { compileRunToObservability, jobRunToObservability, verifyRunToObservability, uniqueArtifacts, } from "./run-observability.js";
|
|
31
33
|
/** TTL for `POST /v1/compile-runs` idempotency-key dedupe entries. */
|
|
32
34
|
const IDEMPOTENCY_TTL_MS = 60 * 60 * 1000;
|
|
33
35
|
/** Idempotency cache size at which to schedule an opportunistic prune. */
|
|
34
36
|
const IDEMPOTENCY_PRUNE_THRESHOLD = 64;
|
|
37
|
+
const INTERRUPTED_COMPILE_RUN_MESSAGE = "Compile run interrupted because the Interf engine stopped before the run reached a terminal state.";
|
|
38
|
+
function isTerminalCompileRunStatus(status) {
|
|
39
|
+
return status === "succeeded" || status === "failed" || status === "cancelled";
|
|
40
|
+
}
|
|
35
41
|
export class LocalServiceRuntime {
|
|
36
42
|
host;
|
|
37
43
|
port;
|
|
@@ -51,25 +57,35 @@ export class LocalServiceRuntime {
|
|
|
51
57
|
*/
|
|
52
58
|
authToken;
|
|
53
59
|
/** Map of prepDataDir -> PreparationContext. */
|
|
54
|
-
|
|
55
|
-
/** Hook called whenever a
|
|
60
|
+
preparationContexts = new Map();
|
|
61
|
+
/** Hook called whenever a preparation is registered or deregistered. */
|
|
56
62
|
onRegistryChanged = null;
|
|
57
|
-
/** In-flight runs across all
|
|
63
|
+
/** In-flight runs across all preparations. Used for `idle_for_seconds`. */
|
|
58
64
|
activeRunCount = 0;
|
|
59
65
|
/**
|
|
60
66
|
* Active compile-run cancellation handles, keyed by run id. Populated
|
|
61
67
|
* when a compile run is launched and cleared once the run reaches a
|
|
62
68
|
* terminal state. Each entry remembers where the persisted record lives
|
|
63
69
|
* so cancel can mark it without re-resolving the Preparation.
|
|
70
|
+
*
|
|
71
|
+
* TODO(cloud): when the cloud variant lands, wire `RunLeaseStore`
|
|
72
|
+
* (see `cloud-seams.ts` B4.2) through this map. Multi-replica engines
|
|
73
|
+
* need a shared lease store so a replica can take over a run whose
|
|
74
|
+
* owning replica died.
|
|
64
75
|
*/
|
|
65
76
|
activeCompileRuns = new Map();
|
|
66
77
|
/**
|
|
67
78
|
* Idempotency-key cache for `POST /v1/compile-runs`. Outer key is the
|
|
68
|
-
* resolved
|
|
69
|
-
* value. Namespacing per
|
|
70
|
-
* tenants on the same engine (CSO finding: a malicious
|
|
71
|
-
* otherwise hijack another
|
|
79
|
+
* resolved preparation root; inner key is the client-supplied idempotency
|
|
80
|
+
* value. Namespacing per preparation prevents key collisions across
|
|
81
|
+
* tenants on the same engine (CSO finding: a malicious preparation could
|
|
82
|
+
* otherwise hijack another preparation's run id by reusing its key).
|
|
72
83
|
* Entries expire after `IDEMPOTENCY_TTL_MS`.
|
|
84
|
+
*
|
|
85
|
+
* TODO(cloud): when the cloud variant lands, wire `IdempotencyStore`
|
|
86
|
+
* (see `cloud-seams.ts` B4.1) through this map. Multi-replica engines
|
|
87
|
+
* need a shared store so retries that land on a different replica
|
|
88
|
+
* still hit the same dedupe entry.
|
|
73
89
|
*/
|
|
74
90
|
idempotencyKeyCache = new Map();
|
|
75
91
|
/**
|
|
@@ -80,10 +96,26 @@ export class LocalServiceRuntime {
|
|
|
80
96
|
* matching write path. See {@link runtime-caches} for design notes.
|
|
81
97
|
*/
|
|
82
98
|
compileRunCache = new RunListingCache();
|
|
83
|
-
|
|
99
|
+
verifyRunCache = new RunListingCache();
|
|
84
100
|
readinessCache = new ReadinessCache();
|
|
85
101
|
sourceFilesCache = new MtimeListingCache();
|
|
86
102
|
methodListingCache = new MethodListingCache();
|
|
103
|
+
/**
|
|
104
|
+
* 0.17 — sink for per-Artifact billing events. Set once at construction.
|
|
105
|
+
* Lazy-defaults to a per-run JSONL writer when no override was injected.
|
|
106
|
+
*/
|
|
107
|
+
billingEventSink;
|
|
108
|
+
/**
|
|
109
|
+
* 0.17 — cloud-variant injection points. The local engine accepts
|
|
110
|
+
* these on the options surface but does not consume them yet — the
|
|
111
|
+
* in-process Maps remain authoritative for idempotency and
|
|
112
|
+
* run-lease state. The cloud variant fork will swap to these stores;
|
|
113
|
+
* the option-fields are documented here so the cloud build has a
|
|
114
|
+
* stable target. See `cloud-seams.ts` for the contracts.
|
|
115
|
+
*/
|
|
116
|
+
cloudIdempotencyStore;
|
|
117
|
+
cloudRunLeaseStore;
|
|
118
|
+
cloudTokenValidator = null;
|
|
87
119
|
constructor(options) {
|
|
88
120
|
this.host = options.host;
|
|
89
121
|
this.port = options.port;
|
|
@@ -92,7 +124,10 @@ export class LocalServiceRuntime {
|
|
|
92
124
|
this.handlers = options.handlers ?? {};
|
|
93
125
|
this.authToken = options.authToken ?? null;
|
|
94
126
|
this.rootPath = resolve(options.rootPath);
|
|
95
|
-
|
|
127
|
+
this.billingEventSink = options.billingEventSink ?? null;
|
|
128
|
+
this.cloudIdempotencyStore = options.idempotencyStore ?? null;
|
|
129
|
+
this.cloudRunLeaseStore = options.runLeaseStore ?? null;
|
|
130
|
+
// Auto-register the initial preparation so single-preparation callers
|
|
96
131
|
// (existing tests, the current `interf web` command) work without
|
|
97
132
|
// additional bootstrapping. The constructor seed is the only role
|
|
98
133
|
// `options.rootPath` plays; runtime methods take `prepDataDir`
|
|
@@ -102,18 +137,30 @@ export class LocalServiceRuntime {
|
|
|
102
137
|
setBoundPort(port) {
|
|
103
138
|
this.port = port;
|
|
104
139
|
}
|
|
105
|
-
/**
|
|
140
|
+
/**
|
|
141
|
+
* 0.17 — token validator setter for cloud variants. Stored on the
|
|
142
|
+
* runtime so `isAuthorizedMutation` in `server.ts` can opt into the
|
|
143
|
+
* async per-account check when present. Local default: never set —
|
|
144
|
+
* the static bearer-token check runs.
|
|
145
|
+
*/
|
|
146
|
+
setTokenValidator(validator) {
|
|
147
|
+
this.cloudTokenValidator = validator;
|
|
148
|
+
}
|
|
149
|
+
getTokenValidator() {
|
|
150
|
+
return this.cloudTokenValidator;
|
|
151
|
+
}
|
|
152
|
+
/** Set a hook that fires whenever the registered preparations change. */
|
|
106
153
|
setOnRegistryChanged(handler) {
|
|
107
154
|
this.onRegistryChanged = handler;
|
|
108
155
|
}
|
|
109
156
|
/**
|
|
110
|
-
* Register a
|
|
111
|
-
* Idempotent: re-registering an existing
|
|
157
|
+
* Register a preparation with this runtime. Returns the PreparationContext.
|
|
158
|
+
* Idempotent: re-registering an existing preparation updates `lastActivity`.
|
|
112
159
|
*/
|
|
113
160
|
registerPreparation(prepDataDir) {
|
|
114
161
|
const resolved = resolve(prepDataDir);
|
|
115
162
|
const now = new Date().toISOString();
|
|
116
|
-
const existing = this.
|
|
163
|
+
const existing = this.preparationContexts.get(resolved);
|
|
117
164
|
if (existing) {
|
|
118
165
|
existing.lastActivity = now;
|
|
119
166
|
this.onRegistryChanged?.();
|
|
@@ -124,57 +171,58 @@ export class LocalServiceRuntime {
|
|
|
124
171
|
startedAt: now,
|
|
125
172
|
lastActivity: now,
|
|
126
173
|
};
|
|
127
|
-
this.
|
|
174
|
+
this.preparationContexts.set(resolved, context);
|
|
175
|
+
this.finalizeInterruptedCompileRuns(resolved);
|
|
128
176
|
this.onRegistryChanged?.();
|
|
129
177
|
return context;
|
|
130
178
|
}
|
|
131
179
|
/**
|
|
132
|
-
* Remove a
|
|
180
|
+
* Remove a preparation from the runtime. Returns true if a preparation was
|
|
133
181
|
* removed.
|
|
134
182
|
*/
|
|
135
183
|
deregisterPreparation(prepDataDir) {
|
|
136
184
|
const resolved = resolve(prepDataDir);
|
|
137
|
-
const removed = this.
|
|
185
|
+
const removed = this.preparationContexts.delete(resolved);
|
|
138
186
|
if (removed) {
|
|
139
187
|
this.onRegistryChanged?.();
|
|
140
188
|
}
|
|
141
189
|
return removed;
|
|
142
190
|
}
|
|
143
191
|
/**
|
|
144
|
-
* Most recently active
|
|
192
|
+
* Most recently active preparation, or the first registered if none has
|
|
145
193
|
* activity yet. Server code uses this as the fallback when a request
|
|
146
|
-
*
|
|
194
|
+
* does not specify a preparation. Throws if none are registered.
|
|
147
195
|
*/
|
|
148
196
|
defaultPreparationDataDir() {
|
|
149
|
-
if (this.
|
|
150
|
-
throw new Error("Local service has no registered
|
|
197
|
+
if (this.preparationContexts.size === 0) {
|
|
198
|
+
throw new Error("Local service has no registered preparations.");
|
|
151
199
|
}
|
|
152
200
|
let best = null;
|
|
153
201
|
let bestKey = -Infinity;
|
|
154
|
-
for (const context of this.
|
|
202
|
+
for (const context of this.preparationContexts.values()) {
|
|
155
203
|
const key = Date.parse(context.lastActivity);
|
|
156
204
|
if (Number.isFinite(key) && key > bestKey) {
|
|
157
205
|
best = context;
|
|
158
206
|
bestKey = key;
|
|
159
207
|
}
|
|
160
208
|
}
|
|
161
|
-
return (best ?? this.
|
|
209
|
+
return (best ?? this.preparationContexts.values().next().value).rootPath;
|
|
162
210
|
}
|
|
163
|
-
/** Look up a
|
|
211
|
+
/** Look up a preparation context by rootPath. */
|
|
164
212
|
getPreparationContext(prepDataDir) {
|
|
165
|
-
return this.
|
|
213
|
+
return this.preparationContexts.get(resolve(prepDataDir)) ?? null;
|
|
166
214
|
}
|
|
167
|
-
/** All registered
|
|
215
|
+
/** All registered preparations, ordered by registration time. */
|
|
168
216
|
listRegisteredPreparations() {
|
|
169
|
-
return Array.from(this.
|
|
217
|
+
return Array.from(this.preparationContexts.values()).sort((left, right) => Date.parse(left.startedAt) - Date.parse(right.startedAt));
|
|
170
218
|
}
|
|
171
|
-
/** True when no
|
|
172
|
-
|
|
173
|
-
return this.
|
|
219
|
+
/** True when no preparations are registered. */
|
|
220
|
+
hasNoPreparations() {
|
|
221
|
+
return this.preparationContexts.size === 0;
|
|
174
222
|
}
|
|
175
|
-
/** Number of registered
|
|
223
|
+
/** Number of registered preparations. */
|
|
176
224
|
registeredPreparationCount() {
|
|
177
|
-
return this.
|
|
225
|
+
return this.preparationContexts.size;
|
|
178
226
|
}
|
|
179
227
|
/** Increment in-flight run counter. Call when a long-running run starts. */
|
|
180
228
|
beginActiveRun() {
|
|
@@ -185,22 +233,28 @@ export class LocalServiceRuntime {
|
|
|
185
233
|
if (this.activeRunCount > 0)
|
|
186
234
|
this.activeRunCount -= 1;
|
|
187
235
|
}
|
|
188
|
-
/** Sum of in-flight runs across all
|
|
236
|
+
/** Sum of in-flight runs across all preparations. */
|
|
189
237
|
activeRuns() {
|
|
190
238
|
return this.activeRunCount;
|
|
191
239
|
}
|
|
192
240
|
/**
|
|
193
|
-
* Mark the
|
|
241
|
+
* Mark the preparation as recently active. Routes call this on entry so
|
|
194
242
|
* `idleForSeconds` and the registry snapshots stay in sync with the
|
|
195
243
|
* actual request cadence.
|
|
196
244
|
*/
|
|
197
245
|
touchPreparation(prepDataDir) {
|
|
198
|
-
const context = this.
|
|
246
|
+
const context = this.preparationContexts.get(resolve(prepDataDir));
|
|
199
247
|
if (context) {
|
|
200
248
|
context.lastActivity = new Date().toISOString();
|
|
201
249
|
}
|
|
202
250
|
}
|
|
203
|
-
/**
|
|
251
|
+
/**
|
|
252
|
+
* Snapshot of registered preparations for the registry / status output.
|
|
253
|
+
* Wire shape (`ServiceRegistryWorkspace`) keeps the legacy
|
|
254
|
+
* "workspace" name for backward compatibility with the public health
|
|
255
|
+
* response and `~/.interf/services.json`. Synthetic-workspace bridge
|
|
256
|
+
* code; do not rename without coordinating an API break.
|
|
257
|
+
*/
|
|
204
258
|
registeredPreparationSnapshots() {
|
|
205
259
|
return this.listRegisteredPreparations().map((context) => ServiceRegistryWorkspaceSchema.parse({
|
|
206
260
|
control_path: context.rootPath,
|
|
@@ -208,7 +262,7 @@ export class LocalServiceRuntime {
|
|
|
208
262
|
last_activity: context.lastActivity,
|
|
209
263
|
}));
|
|
210
264
|
}
|
|
211
|
-
/** Seconds since the most recent
|
|
265
|
+
/** Seconds since the most recent preparation activity (0 if active). */
|
|
212
266
|
idleForSeconds() {
|
|
213
267
|
const all = this.listRegisteredPreparations();
|
|
214
268
|
if (all.length === 0)
|
|
@@ -249,9 +303,13 @@ export class LocalServiceRuntime {
|
|
|
249
303
|
const config = loadSourceFolderConfig(prepDataDir);
|
|
250
304
|
return listSourcePreparationConfigs(config).map((preparation) => {
|
|
251
305
|
const compileRuns = this.listCompileRunsForPreparation(prepDataDir, preparation.name);
|
|
252
|
-
const
|
|
306
|
+
const verifyRuns = this.listVerifyRunsForPreparation(prepDataDir, preparation.name);
|
|
253
307
|
const readiness = this.computePreparationReadiness(prepDataDir, preparation);
|
|
254
|
-
return buildPreparationResource(prepDataDir, preparation, readiness, compileRuns[0]?.run_id ?? null,
|
|
308
|
+
return buildPreparationResource(prepDataDir, preparation, readiness, compileRuns[0]?.run_id ?? null, verifyRuns[0]?.run_id ?? null,
|
|
309
|
+
// 0.17 — surface per-Artifact status from the latest compile
|
|
310
|
+
// run so the UI can render artifact rows on the Preparation
|
|
311
|
+
// page without a separate fetch.
|
|
312
|
+
compileRuns[0]?.artifacts ?? []);
|
|
255
313
|
});
|
|
256
314
|
}
|
|
257
315
|
getPreparation(prepDataDir, preparationName) {
|
|
@@ -282,7 +340,7 @@ export class LocalServiceRuntime {
|
|
|
282
340
|
const compiledTarget = createCompiledTestTarget(compiledPath, preparation.name, methodIdForSourcePreparationConfig(preparation) ?? DEFAULT_METHOD_ID);
|
|
283
341
|
const contextReady = compiledTarget.eligible;
|
|
284
342
|
const compileRun = this.listCompileRunsForPreparation(prepDataDir, preparation.name)[0] ?? null;
|
|
285
|
-
const
|
|
343
|
+
const verifyRun = this.listVerifyRunsForPreparation(prepDataDir, preparation.name)[0] ?? null;
|
|
286
344
|
const readinessRun = this.readLatestReadinessRun(prepDataDir, preparation.name);
|
|
287
345
|
const configuredChecks = preparation.checks.length;
|
|
288
346
|
const currentFingerprint = configuredChecks > 0 ? fingerprintReadinessChecks(preparation.checks) : null;
|
|
@@ -369,7 +427,7 @@ export class LocalServiceRuntime {
|
|
|
369
427
|
const status = (() => {
|
|
370
428
|
if (compileRun?.status === "queued" || compileRun?.status === "running")
|
|
371
429
|
return "building";
|
|
372
|
-
if (
|
|
430
|
+
if (verifyRun?.status === "queued" || verifyRun?.status === "running")
|
|
373
431
|
return "checking";
|
|
374
432
|
if (compileRun?.status === "failed" || compileRun?.status === "cancelled")
|
|
375
433
|
return "failed";
|
|
@@ -384,7 +442,7 @@ export class LocalServiceRuntime {
|
|
|
384
442
|
return contextResult.total > 0 && contextResult.passed === contextResult.total ? "ready" : "not-ready";
|
|
385
443
|
})();
|
|
386
444
|
const ready = status === "ready";
|
|
387
|
-
return
|
|
445
|
+
return ReadinessSchema.parse({
|
|
388
446
|
kind: "interf-readiness-state",
|
|
389
447
|
version: 1,
|
|
390
448
|
generated_at: generatedAt,
|
|
@@ -394,7 +452,7 @@ export class LocalServiceRuntime {
|
|
|
394
452
|
summary: readinessSummaryForStatus(status),
|
|
395
453
|
portable_context_path: contextReady ? compiledPath : null,
|
|
396
454
|
latest_compile_run_id: compileRun?.run_id ?? null,
|
|
397
|
-
latest_test_run_id:
|
|
455
|
+
latest_test_run_id: verifyRun?.run_id ?? null,
|
|
398
456
|
compile: compileCheck,
|
|
399
457
|
check_results: {
|
|
400
458
|
configured: configuredChecks,
|
|
@@ -406,10 +464,16 @@ export class LocalServiceRuntime {
|
|
|
406
464
|
});
|
|
407
465
|
}
|
|
408
466
|
listSourceFiles(prepDataDir, preparationName) {
|
|
409
|
-
const
|
|
467
|
+
const config = loadSourceFolderConfig(prepDataDir);
|
|
468
|
+
const preparations = listSourcePreparationConfigs(config)
|
|
410
469
|
.filter((preparation) => !preparationName || preparation.name === preparationName);
|
|
470
|
+
// 0.13+ source binding: the source folder is the user-supplied
|
|
471
|
+
// absolute path on `source_folder.path`. `preparation.path` is the
|
|
472
|
+
// portable-context name inside `prepDataDir` (legacy field; in the
|
|
473
|
+
// synthetic-workspace bridge it equals `preparation.name`). Walk
|
|
474
|
+
// the actual source bytes, not the portable-context subdir.
|
|
475
|
+
const sourceFolderPath = resolveConfiguredSourceFolderPath(prepDataDir, config) ?? prepDataDir;
|
|
411
476
|
return preparations.flatMap((preparation) => {
|
|
412
|
-
const sourceFolderPath = resolveSourcePreparationPath(prepDataDir, preparation);
|
|
413
477
|
const compiledPath = preparationPortableContextPath(asPreparationDataDir(prepDataDir), preparation.name);
|
|
414
478
|
// Cache by source-folder root mtime so identical UI polls do not
|
|
415
479
|
// re-walk and re-stat the entire tree. The cache imposes a short
|
|
@@ -489,19 +553,16 @@ export class LocalServiceRuntime {
|
|
|
489
553
|
source_kind: method.scope === "builtin" ? "builtin" : "local",
|
|
490
554
|
built_in: method.scope === "builtin",
|
|
491
555
|
active_for_preparations: activeForPreparations,
|
|
492
|
-
|
|
493
|
-
.filter((zone) => zone.role === "output")
|
|
494
|
-
.map((zone) => contextInterfaceArtifactPath(zone))
|
|
495
|
-
.sort(),
|
|
556
|
+
artifacts: method.contextInterface?.artifacts ?? [],
|
|
496
557
|
stages: method.stages.map((stage) => ({
|
|
497
558
|
id: stage.id,
|
|
498
559
|
label: stage.label,
|
|
499
560
|
description: stage.description,
|
|
500
561
|
contract_type: stage.contractType,
|
|
501
562
|
skill_dir: stage.skillDir,
|
|
563
|
+
role: stage.role && stage.role.trim().length > 0 ? stage.role : "general",
|
|
502
564
|
reads: stage.reads,
|
|
503
565
|
writes: stage.writes,
|
|
504
|
-
...(stage.acceptance ? { acceptance: stage.acceptance } : {}),
|
|
505
566
|
})),
|
|
506
567
|
});
|
|
507
568
|
});
|
|
@@ -587,8 +648,48 @@ export class LocalServiceRuntime {
|
|
|
587
648
|
skillsInstalled: current?.skillsInstalled ?? false,
|
|
588
649
|
initialized: current?.initialized ?? new Date().toISOString(),
|
|
589
650
|
});
|
|
651
|
+
// Mirror the selection into the 0.15 role-map. `setActiveAgent`
|
|
652
|
+
// also sweeps any role still pointing at the previous active so
|
|
653
|
+
// single-active-agent setups stay coherent across CLIs.
|
|
654
|
+
try {
|
|
655
|
+
setActiveAgent(selected.name);
|
|
656
|
+
}
|
|
657
|
+
catch {
|
|
658
|
+
// Best effort — the registry update is convenience for the new
|
|
659
|
+
// role-aware path. The user_config.json write above is the
|
|
660
|
+
// source of truth for the legacy `getExecutorStatus()`.
|
|
661
|
+
}
|
|
590
662
|
return this.getExecutorStatus();
|
|
591
663
|
}
|
|
664
|
+
// ─── 0.15 connected-agents primitive ─────────────────────────────
|
|
665
|
+
/**
|
|
666
|
+
* Snapshot of the merged agents registry (built-in detected + custom)
|
|
667
|
+
* with the current role-map and resolved active agent.
|
|
668
|
+
*/
|
|
669
|
+
getAgentsRegistry() {
|
|
670
|
+
const registry = loadAgentsRegistry();
|
|
671
|
+
return {
|
|
672
|
+
agents: registry.agents,
|
|
673
|
+
role_map: registry.roleMap,
|
|
674
|
+
active_agent: registry.activeAgent,
|
|
675
|
+
};
|
|
676
|
+
}
|
|
677
|
+
registerCustomAgent(input) {
|
|
678
|
+
registerCustomAgent(input);
|
|
679
|
+
return this.getAgentsRegistry();
|
|
680
|
+
}
|
|
681
|
+
unregisterCustomAgent(name) {
|
|
682
|
+
unregisterCustomAgent(name);
|
|
683
|
+
return this.getAgentsRegistry();
|
|
684
|
+
}
|
|
685
|
+
patchAgentsRoleMap(patch) {
|
|
686
|
+
patchRoleMap(patch);
|
|
687
|
+
const registry = loadAgentsRegistry();
|
|
688
|
+
return {
|
|
689
|
+
role_map: registry.roleMap,
|
|
690
|
+
active_agent: registry.activeAgent,
|
|
691
|
+
};
|
|
692
|
+
}
|
|
592
693
|
listActionProposals(prepDataDir) {
|
|
593
694
|
return byCreatedAtDesc(listJsonFiles(actionProposalsRoot(prepDataDir))
|
|
594
695
|
.map(readActionProposalAt)
|
|
@@ -654,7 +755,7 @@ export class LocalServiceRuntime {
|
|
|
654
755
|
listRunObservability(prepDataDir) {
|
|
655
756
|
return [
|
|
656
757
|
...this.listCompileRuns(prepDataDir).map((resource) => compileRunToObservability(resource.run)),
|
|
657
|
-
...this.
|
|
758
|
+
...this.listVerifyRuns(prepDataDir).map(verifyRunToObservability),
|
|
658
759
|
...this.listJobs(prepDataDir).map(jobRunToObservability),
|
|
659
760
|
].sort((left, right) => {
|
|
660
761
|
const leftTime = timestampKey(left.started_at ?? left.created_at ?? left.finished_at);
|
|
@@ -665,6 +766,20 @@ export class LocalServiceRuntime {
|
|
|
665
766
|
getRunObservability(prepDataDir, runId) {
|
|
666
767
|
return this.listRunObservability(prepDataDir).find((run) => run.run_id === runId) ?? null;
|
|
667
768
|
}
|
|
769
|
+
/**
|
|
770
|
+
* Method-scoped runs: every method-authoring or method-improvement job
|
|
771
|
+
* whose `method` matches `methodId`. Surfaced through
|
|
772
|
+
* `GET /v1/methods/<id>/runs` so Method Detail can show the full audit
|
|
773
|
+
* trail of authoring + improvement work for a Method.
|
|
774
|
+
*/
|
|
775
|
+
listMethodRuns(prepDataDir, methodId) {
|
|
776
|
+
return this.listRunObservability(prepDataDir).filter((run) => {
|
|
777
|
+
if (run.method !== methodId)
|
|
778
|
+
return false;
|
|
779
|
+
return (run.run_type === "method-authoring" ||
|
|
780
|
+
run.run_type === "method-improvement");
|
|
781
|
+
});
|
|
782
|
+
}
|
|
668
783
|
createJobRun(prepDataDir, requestValue) {
|
|
669
784
|
const request = LocalJobRunCreateRequestSchema.parse(requestValue);
|
|
670
785
|
const runId = createRunId("job");
|
|
@@ -848,74 +963,6 @@ export class LocalServiceRuntime {
|
|
|
848
963
|
: `Removed Method ${request.method}.`,
|
|
849
964
|
});
|
|
850
965
|
}
|
|
851
|
-
/**
|
|
852
|
-
* Bootstrap the workspace's source-folder binding and seed the default
|
|
853
|
-
* Method. Idempotent: re-running with the same source folder preserves
|
|
854
|
-
* existing preparations and reports `changed: false`.
|
|
855
|
-
*
|
|
856
|
-
* The CLI calls this in place of writing `interf.json` directly, so the
|
|
857
|
-
* operation is recorded by the service (and visible to other clients).
|
|
858
|
-
*/
|
|
859
|
-
bootstrapWorkspace(prepDataDir, requestValue) {
|
|
860
|
-
const request = WorkspaceBootstrapCreateRequestSchema.parse(requestValue);
|
|
861
|
-
const requestedPath = request.source_folder?.path?.trim() ?? null;
|
|
862
|
-
const existing = loadSourceFolderConfig(prepDataDir);
|
|
863
|
-
const existingSourcePath = existing?.source_folder?.path ?? null;
|
|
864
|
-
const preparations = existing?.preparations ?? [];
|
|
865
|
-
let sourceFolderPath = existingSourcePath;
|
|
866
|
-
let sourceChanged = false;
|
|
867
|
-
if (requestedPath && requestedPath.length > 0) {
|
|
868
|
-
// Validate that the source folder exists relative to the workspace.
|
|
869
|
-
const resolvedSourcePath = resolve(prepDataDir, requestedPath);
|
|
870
|
-
if (!existsSync(resolvedSourcePath) || !statSync(resolvedSourcePath).isDirectory()) {
|
|
871
|
-
throw new Error(`Source folder "${requestedPath}" is not available.`);
|
|
872
|
-
}
|
|
873
|
-
if (existingSourcePath !== requestedPath) {
|
|
874
|
-
sourceFolderPath = requestedPath;
|
|
875
|
-
sourceChanged = true;
|
|
876
|
-
}
|
|
877
|
-
}
|
|
878
|
-
const writeNeeded = !existing || sourceChanged;
|
|
879
|
-
if (writeNeeded) {
|
|
880
|
-
saveSourceFolderConfig(prepDataDir, {
|
|
881
|
-
...(sourceFolderPath ? { source_folder: { path: sourceFolderPath } } : {}),
|
|
882
|
-
preparations,
|
|
883
|
-
});
|
|
884
|
-
// Source folder rebound: drop every cached read for this workspace.
|
|
885
|
-
this.readinessCache.invalidateWorkspace(prepDataDir);
|
|
886
|
-
this.compileRunCache.invalidateWorkspace(prepDataDir);
|
|
887
|
-
this.testRunCache.invalidateWorkspace(prepDataDir);
|
|
888
|
-
this.sourceFilesCache.invalidateAll();
|
|
889
|
-
this.methodListingCache.invalidate(prepDataDir);
|
|
890
|
-
}
|
|
891
|
-
let seededMethodId = null;
|
|
892
|
-
let seededDefaultMethod = false;
|
|
893
|
-
if (request.seed_default_method) {
|
|
894
|
-
const seeded = seedLocalDefaultMethod({ prepDataDir });
|
|
895
|
-
seededMethodId = seeded.methodId;
|
|
896
|
-
seededDefaultMethod = !seeded.alreadyExisted;
|
|
897
|
-
if (seededDefaultMethod) {
|
|
898
|
-
this.methodListingCache.invalidate(prepDataDir);
|
|
899
|
-
}
|
|
900
|
-
}
|
|
901
|
-
const changed = writeNeeded || seededDefaultMethod;
|
|
902
|
-
return WorkspaceBootstrapResultSchema.parse({
|
|
903
|
-
kind: "interf-workspace-bootstrap-result",
|
|
904
|
-
version: 1,
|
|
905
|
-
control_path: prepDataDir,
|
|
906
|
-
config_path: preparationConfigPath(asPreparationDataDir(prepDataDir)),
|
|
907
|
-
source_folder_path: sourceFolderPath,
|
|
908
|
-
preparations: preparations.length,
|
|
909
|
-
seeded_default_method: seededDefaultMethod,
|
|
910
|
-
default_method_id: seededMethodId,
|
|
911
|
-
changed,
|
|
912
|
-
message: changed
|
|
913
|
-
? sourceFolderPath
|
|
914
|
-
? `Workspace ready. Source Folder: ${sourceFolderPath}.`
|
|
915
|
-
: `Workspace ready.`
|
|
916
|
-
: `Workspace already initialized.`,
|
|
917
|
-
});
|
|
918
|
-
}
|
|
919
966
|
applyPreparationSetup(prepDataDir, requestValue) {
|
|
920
967
|
const request = PreparationSetupCreateRequestSchema.parse(requestValue);
|
|
921
968
|
const preparationConfig = request.preparation;
|
|
@@ -934,7 +981,7 @@ export class LocalServiceRuntime {
|
|
|
934
981
|
// caches so the next read reflects the new shape.
|
|
935
982
|
this.readinessCache.invalidatePreparation(prepDataDir, normalizedPreparationConfig.name);
|
|
936
983
|
this.compileRunCache.invalidatePreparation(prepDataDir, normalizedPreparationConfig.name);
|
|
937
|
-
this.
|
|
984
|
+
this.verifyRunCache.invalidatePreparation(prepDataDir, normalizedPreparationConfig.name);
|
|
938
985
|
this.methodListingCache.invalidate(prepDataDir);
|
|
939
986
|
const operation = request.setup_mode === "select-method" ? "select-method" : "create";
|
|
940
987
|
return PreparationSetupResultSchema.parse({
|
|
@@ -964,7 +1011,7 @@ export class LocalServiceRuntime {
|
|
|
964
1011
|
removeSourcePreparationConfig(prepDataDir, request.preparation);
|
|
965
1012
|
this.readinessCache.invalidatePreparation(prepDataDir, request.preparation);
|
|
966
1013
|
this.compileRunCache.invalidatePreparation(prepDataDir, request.preparation);
|
|
967
|
-
this.
|
|
1014
|
+
this.verifyRunCache.invalidatePreparation(prepDataDir, request.preparation);
|
|
968
1015
|
this.methodListingCache.invalidate(prepDataDir);
|
|
969
1016
|
return PreparationChangeResultSchema.parse({
|
|
970
1017
|
kind: "interf-preparation-change-result",
|
|
@@ -991,7 +1038,7 @@ export class LocalServiceRuntime {
|
|
|
991
1038
|
resetCompiledGeneratedState(compiledPath, request.scope);
|
|
992
1039
|
// Reset wipes generated state, including saved compile/test/readiness records.
|
|
993
1040
|
this.compileRunCache.invalidatePreparation(prepDataDir, request.preparation);
|
|
994
|
-
this.
|
|
1041
|
+
this.verifyRunCache.invalidatePreparation(prepDataDir, request.preparation);
|
|
995
1042
|
this.readinessCache.invalidatePreparation(prepDataDir, request.preparation);
|
|
996
1043
|
return ResetResultSchema.parse({
|
|
997
1044
|
kind: "interf-reset-result",
|
|
@@ -1030,6 +1077,7 @@ export class LocalServiceRuntime {
|
|
|
1030
1077
|
method_id: request.method_id,
|
|
1031
1078
|
label: request.label,
|
|
1032
1079
|
task_prompt: request.task_prompt,
|
|
1080
|
+
artifact_requirements: request.artifact_requirements.length,
|
|
1033
1081
|
},
|
|
1034
1082
|
},
|
|
1035
1083
|
{
|
|
@@ -1068,6 +1116,7 @@ export class LocalServiceRuntime {
|
|
|
1068
1116
|
method_id: request.method_id,
|
|
1069
1117
|
label: request.label,
|
|
1070
1118
|
task_prompt: request.task_prompt,
|
|
1119
|
+
artifact_requirements: request.artifact_requirements.length,
|
|
1071
1120
|
},
|
|
1072
1121
|
});
|
|
1073
1122
|
void this.runMethodAuthoringInBackground(prepDataDir, request, job.run_id);
|
|
@@ -1085,7 +1134,7 @@ export class LocalServiceRuntime {
|
|
|
1085
1134
|
const path = preparationPortableContextPath(asPreparationDataDir(prepDataDir), preparation.name);
|
|
1086
1135
|
const config = readInterfConfig(path);
|
|
1087
1136
|
const compileRuns = this.listCompileRunsForPreparation(prepDataDir, preparation.name);
|
|
1088
|
-
const
|
|
1137
|
+
const verifyRuns = this.listVerifyRunsForPreparation(prepDataDir, preparation.name);
|
|
1089
1138
|
const readiness = this.computePreparationReadiness(prepDataDir, preparation);
|
|
1090
1139
|
const method = config?.method ?? methodIdForSourcePreparationConfig(preparation);
|
|
1091
1140
|
return PortableContextResourceSchema.parse({
|
|
@@ -1095,7 +1144,7 @@ export class LocalServiceRuntime {
|
|
|
1095
1144
|
readiness,
|
|
1096
1145
|
method,
|
|
1097
1146
|
latest_compile_run_id: compileRuns[0]?.run_id ?? null,
|
|
1098
|
-
latest_test_run_id:
|
|
1147
|
+
latest_test_run_id: verifyRuns[0]?.run_id ?? null,
|
|
1099
1148
|
artifacts: uniqueArtifacts(compileRuns[0]?.stages.flatMap((stage) => stage.artifacts) ?? []),
|
|
1100
1149
|
});
|
|
1101
1150
|
}
|
|
@@ -1187,7 +1236,6 @@ export class LocalServiceRuntime {
|
|
|
1187
1236
|
stage_total: stageTotal,
|
|
1188
1237
|
reads: stage.reads,
|
|
1189
1238
|
writes: stage.writes,
|
|
1190
|
-
...(stage.acceptance ? { acceptance: stage.acceptance } : {}),
|
|
1191
1239
|
},
|
|
1192
1240
|
artifacts: [],
|
|
1193
1241
|
};
|
|
@@ -1226,7 +1274,7 @@ export class LocalServiceRuntime {
|
|
|
1226
1274
|
}
|
|
1227
1275
|
/**
|
|
1228
1276
|
* Cancel an in-flight compile run. Marks the persisted record as
|
|
1229
|
-
* `cancelled`, emits a `run.
|
|
1277
|
+
* `cancelled`, emits a `run.cancelled` event to capture the cancellation in
|
|
1230
1278
|
* the run timeline, and clears the active handle so retries may start a
|
|
1231
1279
|
* fresh run. If the run already finished, returns
|
|
1232
1280
|
* `{ cancelled: false, reason: "already finished" }` and persists nothing.
|
|
@@ -1246,31 +1294,22 @@ export class LocalServiceRuntime {
|
|
|
1246
1294
|
handle.cancelled = true;
|
|
1247
1295
|
handle.cancelledAt = cancelledAt;
|
|
1248
1296
|
const current = this.readCompileRun(handle.compiledPath, runId);
|
|
1249
|
-
if (current && current.status
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
type: "run.failed",
|
|
1258
|
-
event_id: createRunEventId("event"),
|
|
1259
|
-
run_id: runId,
|
|
1260
|
-
timestamp: cancelledAt,
|
|
1261
|
-
error: "Compile run cancelled by request.",
|
|
1262
|
-
},
|
|
1263
|
-
],
|
|
1264
|
-
};
|
|
1265
|
-
this.writeCompileRun(handle.prepDataDir, handle.compiledPath, cancelledRun);
|
|
1297
|
+
if (current && !isTerminalCompileRunStatus(current.status)) {
|
|
1298
|
+
this.writeCompileRun(handle.prepDataDir, handle.compiledPath, applyEventToCompileRun(current, {
|
|
1299
|
+
type: "run.cancelled",
|
|
1300
|
+
event_id: createRunEventId("event"),
|
|
1301
|
+
run_id: runId,
|
|
1302
|
+
timestamp: cancelledAt,
|
|
1303
|
+
reason: "Compile run cancelled by request.",
|
|
1304
|
+
}));
|
|
1266
1305
|
}
|
|
1267
1306
|
return { cancelled: true };
|
|
1268
1307
|
}
|
|
1269
1308
|
/**
|
|
1270
1309
|
* Look up the run id previously associated with this idempotency key in
|
|
1271
1310
|
* `prepDataDir`. Returns null when the key is unknown or its TTL has
|
|
1272
|
-
* elapsed. The
|
|
1273
|
-
* two different
|
|
1311
|
+
* elapsed. The preparation argument is required so that the same key in
|
|
1312
|
+
* two different preparations always returns two different runs.
|
|
1274
1313
|
*/
|
|
1275
1314
|
findIdempotentCompileRun(prepDataDir, key) {
|
|
1276
1315
|
const resolvedRoot = resolve(prepDataDir);
|
|
@@ -1313,7 +1352,7 @@ export class LocalServiceRuntime {
|
|
|
1313
1352
|
this.pruneIdempotencyKeyCache();
|
|
1314
1353
|
}
|
|
1315
1354
|
}
|
|
1316
|
-
/** Total cached idempotency entries across all
|
|
1355
|
+
/** Total cached idempotency entries across all preparations. */
|
|
1317
1356
|
totalIdempotencyEntries() {
|
|
1318
1357
|
let total = 0;
|
|
1319
1358
|
for (const bucket of this.idempotencyKeyCache.values())
|
|
@@ -1348,46 +1387,45 @@ export class LocalServiceRuntime {
|
|
|
1348
1387
|
entry.expiresAt = Date.now() - 1;
|
|
1349
1388
|
return true;
|
|
1350
1389
|
}
|
|
1351
|
-
|
|
1390
|
+
listVerifyRuns(prepDataDir) {
|
|
1352
1391
|
return newestFirst(listSourcePreparationConfigs(loadSourceFolderConfig(prepDataDir))
|
|
1353
|
-
.flatMap((preparation) => this.
|
|
1392
|
+
.flatMap((preparation) => this.listVerifyRunsForPreparation(prepDataDir, preparation.name)));
|
|
1354
1393
|
}
|
|
1355
|
-
|
|
1356
|
-
return this.
|
|
1394
|
+
listVerifyRunsForPreparation(prepDataDir, preparationName) {
|
|
1395
|
+
return this.verifyRunCache.get(prepDataDir, preparationName, () => {
|
|
1357
1396
|
const compiledPath = preparationPortableContextPath(asPreparationDataDir(prepDataDir), preparationName);
|
|
1358
|
-
return newestFirst(listJsonFiles(
|
|
1359
|
-
.map(
|
|
1397
|
+
return newestFirst(listJsonFiles(verifyRunsRoot(compiledPath))
|
|
1398
|
+
.map(readVerifyRunAt)
|
|
1360
1399
|
.filter((run) => run !== null));
|
|
1361
1400
|
}, (run) => run.run_id);
|
|
1362
1401
|
}
|
|
1363
|
-
|
|
1364
|
-
const known = this.
|
|
1402
|
+
getVerifyRun(prepDataDir, runId) {
|
|
1403
|
+
const known = this.verifyRunCache.preparationFor(prepDataDir, runId);
|
|
1365
1404
|
if (known) {
|
|
1366
|
-
const found = this.
|
|
1405
|
+
const found = this.listVerifyRunsForPreparation(prepDataDir, known).find((run) => run.run_id === runId);
|
|
1367
1406
|
if (found)
|
|
1368
1407
|
return found;
|
|
1369
1408
|
}
|
|
1370
|
-
return this.
|
|
1409
|
+
return this.listVerifyRuns(prepDataDir).find((run) => run.run_id === runId) ?? null;
|
|
1371
1410
|
}
|
|
1372
|
-
async
|
|
1373
|
-
const request =
|
|
1411
|
+
async createVerifyRun(prepDataDir, requestValue) {
|
|
1412
|
+
const request = VerifyRunCreateRequestSchema.parse(requestValue);
|
|
1374
1413
|
const preparationConfig = this.resolvePreparationConfig(prepDataDir, request.preparation);
|
|
1375
1414
|
const compiledPath = preparationPortableContextPath(asPreparationDataDir(prepDataDir), preparationConfig.name);
|
|
1376
1415
|
const compiledTarget = createCompiledTestTarget(compiledPath, preparationConfig.name, methodIdForSourcePreparationConfig(preparationConfig) ?? DEFAULT_METHOD_ID);
|
|
1377
|
-
const runId = createRunId("
|
|
1416
|
+
const runId = createRunId("verify");
|
|
1378
1417
|
const now = new Date().toISOString();
|
|
1379
|
-
const initial =
|
|
1418
|
+
const initial = VerifyRunResourceSchema.parse({
|
|
1380
1419
|
run_id: runId,
|
|
1381
1420
|
status: "running",
|
|
1382
1421
|
preparation: preparationConfig.name,
|
|
1383
|
-
mode: request.mode,
|
|
1384
1422
|
source_path: prepDataDir,
|
|
1385
1423
|
portable_context_path: compiledTarget.eligible ? compiledPath : null,
|
|
1386
1424
|
started_at: now,
|
|
1387
1425
|
readiness_run: null,
|
|
1388
1426
|
events: [],
|
|
1389
1427
|
});
|
|
1390
|
-
this.
|
|
1428
|
+
this.writeVerifyRun(prepDataDir, compiledPath, initial);
|
|
1391
1429
|
void this.runTestInBackground(prepDataDir, request, {
|
|
1392
1430
|
runId,
|
|
1393
1431
|
sourcePath: prepDataDir,
|
|
@@ -1434,6 +1472,9 @@ export class LocalServiceRuntime {
|
|
|
1434
1472
|
});
|
|
1435
1473
|
}
|
|
1436
1474
|
await this.recordCompileRunEvent(prepDataDir, context.compiledPath, context.runId, this.readinessUpdatedEvent(context.runId, context.preparationConfig.name, this.computePreparationReadiness(prepDataDir, context.preparationConfig)));
|
|
1475
|
+
// 0.17 — emit per-Artifact billing events (stub form: JSONL).
|
|
1476
|
+
// Production sink (Metronome HTTP) wires in 0.18+.
|
|
1477
|
+
this.emitBillingEventsForRun(prepDataDir, context);
|
|
1437
1478
|
}
|
|
1438
1479
|
catch (error) {
|
|
1439
1480
|
await this.recordCompileRunEvent(prepDataDir, context.compiledPath, context.runId, {
|
|
@@ -1453,15 +1494,15 @@ export class LocalServiceRuntime {
|
|
|
1453
1494
|
async runTestInBackground(prepDataDir, request, context, initial) {
|
|
1454
1495
|
this.beginActiveRun();
|
|
1455
1496
|
try {
|
|
1456
|
-
if (!this.handlers.
|
|
1457
|
-
throw new Error("No
|
|
1497
|
+
if (!this.handlers.createVerifyRun) {
|
|
1498
|
+
throw new Error("No verify-run handler is configured for this local service.");
|
|
1458
1499
|
}
|
|
1459
|
-
const result = LocalRunHandlerResultSchema.parse(await this.handlers.
|
|
1500
|
+
const result = LocalRunHandlerResultSchema.parse(await this.handlers.createVerifyRun(request, context));
|
|
1460
1501
|
const readinessRun = result.readiness_run ?? this.readLatestReadinessRun(prepDataDir, context.preparationConfig.name);
|
|
1461
1502
|
const resultEvent = readinessRun
|
|
1462
1503
|
? this.checksEvaluatedEvent(context.runId, readinessRun)
|
|
1463
1504
|
: null;
|
|
1464
|
-
const nextWithoutReadiness =
|
|
1505
|
+
const nextWithoutReadiness = VerifyRunResourceSchema.parse({
|
|
1465
1506
|
...initial,
|
|
1466
1507
|
status: result.ok ? "succeeded" : "failed",
|
|
1467
1508
|
finished_at: new Date().toISOString(),
|
|
@@ -1469,9 +1510,9 @@ export class LocalServiceRuntime {
|
|
|
1469
1510
|
events: resultEvent ? [resultEvent] : [],
|
|
1470
1511
|
...(!result.ok ? { error: result.error ?? "Readiness check failed." } : {}),
|
|
1471
1512
|
});
|
|
1472
|
-
this.
|
|
1513
|
+
this.writeVerifyRun(prepDataDir, context.compiledPath, nextWithoutReadiness);
|
|
1473
1514
|
const readiness = this.computePreparationReadiness(prepDataDir, context.preparationConfig);
|
|
1474
|
-
const next =
|
|
1515
|
+
const next = VerifyRunResourceSchema.parse({
|
|
1475
1516
|
...nextWithoutReadiness,
|
|
1476
1517
|
readiness,
|
|
1477
1518
|
events: [
|
|
@@ -1479,23 +1520,23 @@ export class LocalServiceRuntime {
|
|
|
1479
1520
|
this.readinessUpdatedEvent(context.runId, context.preparationConfig.name, readiness),
|
|
1480
1521
|
],
|
|
1481
1522
|
});
|
|
1482
|
-
this.
|
|
1523
|
+
this.writeVerifyRun(prepDataDir, context.compiledPath, next);
|
|
1483
1524
|
}
|
|
1484
1525
|
catch (error) {
|
|
1485
|
-
const failedWithoutReadiness =
|
|
1526
|
+
const failedWithoutReadiness = VerifyRunResourceSchema.parse({
|
|
1486
1527
|
...initial,
|
|
1487
1528
|
status: "failed",
|
|
1488
1529
|
finished_at: new Date().toISOString(),
|
|
1489
1530
|
error: error instanceof Error ? error.message : String(error),
|
|
1490
1531
|
});
|
|
1491
|
-
this.
|
|
1532
|
+
this.writeVerifyRun(prepDataDir, context.compiledPath, failedWithoutReadiness);
|
|
1492
1533
|
const readiness = this.computePreparationReadiness(prepDataDir, context.preparationConfig);
|
|
1493
|
-
const next =
|
|
1534
|
+
const next = VerifyRunResourceSchema.parse({
|
|
1494
1535
|
...failedWithoutReadiness,
|
|
1495
1536
|
readiness,
|
|
1496
1537
|
events: [this.readinessUpdatedEvent(context.runId, context.preparationConfig.name, readiness)],
|
|
1497
1538
|
});
|
|
1498
|
-
this.
|
|
1539
|
+
this.writeVerifyRun(prepDataDir, context.compiledPath, next);
|
|
1499
1540
|
}
|
|
1500
1541
|
finally {
|
|
1501
1542
|
this.endActiveRun();
|
|
@@ -1931,10 +1972,11 @@ export class LocalServiceRuntime {
|
|
|
1931
1972
|
};
|
|
1932
1973
|
}
|
|
1933
1974
|
if (actionType === "test") {
|
|
1934
|
-
|
|
1975
|
+
// 0.15 — verify runs always judge against the compiled
|
|
1976
|
+
// portable context. The legacy `mode` field is gone from the
|
|
1977
|
+
// wire request shape.
|
|
1935
1978
|
return {
|
|
1936
1979
|
preparation: preparationConfig.name,
|
|
1937
|
-
mode: testModeValue(proposalValues, defaultMode),
|
|
1938
1980
|
};
|
|
1939
1981
|
}
|
|
1940
1982
|
if (actionType === "readiness-check-draft") {
|
|
@@ -1984,9 +2026,7 @@ export class LocalServiceRuntime {
|
|
|
1984
2026
|
return "Ask the configured local executor to draft saved readiness checks.";
|
|
1985
2027
|
return "Ask the configured local executor to create a reusable local Method.";
|
|
1986
2028
|
})();
|
|
1987
|
-
const previewValues =
|
|
1988
|
-
? { mode: actionRequest.mode }
|
|
1989
|
-
: proposalValues;
|
|
2029
|
+
const previewValues = proposalValues;
|
|
1990
2030
|
const commandPreview = plan.command_preview ?? actionCommandPreview(proposalActionType, preparationConfig.name, methodId, previewValues);
|
|
1991
2031
|
return ActionProposalResourceSchema.parse({
|
|
1992
2032
|
kind: "interf-action-proposal",
|
|
@@ -2023,10 +2063,10 @@ export class LocalServiceRuntime {
|
|
|
2023
2063
|
};
|
|
2024
2064
|
}
|
|
2025
2065
|
if (proposal.action_type === "test") {
|
|
2026
|
-
const resource = await this.
|
|
2066
|
+
const resource = await this.createVerifyRun(prepDataDir, proposal.request);
|
|
2027
2067
|
return {
|
|
2028
2068
|
runId: resource.run_id,
|
|
2029
|
-
runType: "
|
|
2069
|
+
runType: "verify-run",
|
|
2030
2070
|
};
|
|
2031
2071
|
}
|
|
2032
2072
|
if (proposal.action_type === "readiness-check-draft") {
|
|
@@ -2068,6 +2108,81 @@ export class LocalServiceRuntime {
|
|
|
2068
2108
|
readCompileRun(compiledPath, runId) {
|
|
2069
2109
|
return readCompileRunAt(compileRunPath(compiledPath, runId));
|
|
2070
2110
|
}
|
|
2111
|
+
finalizeInterruptedCompileRuns(prepDataDir) {
|
|
2112
|
+
let preparations;
|
|
2113
|
+
try {
|
|
2114
|
+
preparations = listSourcePreparationConfigs(loadSourceFolderConfig(prepDataDir));
|
|
2115
|
+
}
|
|
2116
|
+
catch {
|
|
2117
|
+
return;
|
|
2118
|
+
}
|
|
2119
|
+
for (const preparation of preparations) {
|
|
2120
|
+
const compiledPath = preparationPortableContextPath(asPreparationDataDir(prepDataDir), preparation.name);
|
|
2121
|
+
for (const run of listJsonFiles(compileRunsRoot(compiledPath))
|
|
2122
|
+
.map(readCompileRunAt)
|
|
2123
|
+
.filter((entry) => entry !== null)) {
|
|
2124
|
+
if (isTerminalCompileRunStatus(run.status) || this.activeCompileRuns.has(run.run_id))
|
|
2125
|
+
continue;
|
|
2126
|
+
const timestamp = createRunEventTimestamp();
|
|
2127
|
+
const interruptedRun = {
|
|
2128
|
+
...run,
|
|
2129
|
+
stages: run.stages.map((stage) => {
|
|
2130
|
+
if (stage.status !== "running")
|
|
2131
|
+
return stage;
|
|
2132
|
+
return {
|
|
2133
|
+
...stage,
|
|
2134
|
+
status: "failed",
|
|
2135
|
+
finished_at: stage.finished_at ?? timestamp,
|
|
2136
|
+
summary: stage.summary ?? INTERRUPTED_COMPILE_RUN_MESSAGE,
|
|
2137
|
+
failure: stage.failure ?? INTERRUPTED_COMPILE_RUN_MESSAGE,
|
|
2138
|
+
};
|
|
2139
|
+
}),
|
|
2140
|
+
};
|
|
2141
|
+
this.writeCompileRun(prepDataDir, compiledPath, applyEventToCompileRun(interruptedRun, {
|
|
2142
|
+
type: "run.cancelled",
|
|
2143
|
+
event_id: createRunEventId("event"),
|
|
2144
|
+
run_id: run.run_id,
|
|
2145
|
+
timestamp,
|
|
2146
|
+
reason: INTERRUPTED_COMPILE_RUN_MESSAGE,
|
|
2147
|
+
}));
|
|
2148
|
+
}
|
|
2149
|
+
}
|
|
2150
|
+
}
|
|
2151
|
+
/**
|
|
2152
|
+
* 0.17 — emit per-Artifact billing events when a compile run reaches
|
|
2153
|
+
* a terminal state. STUB FORM: writes a JSONL file alongside the run
|
|
2154
|
+
* record by default. Production sink (Metronome HTTP) wires in 0.18+.
|
|
2155
|
+
* The JSONL output is observability/dev fixture, NOT production
|
|
2156
|
+
* billing data.
|
|
2157
|
+
*/
|
|
2158
|
+
emitBillingEventsForRun(prepDataDir, context) {
|
|
2159
|
+
try {
|
|
2160
|
+
const run = this.readCompileRun(context.compiledPath, context.runId);
|
|
2161
|
+
if (!run || run.artifacts.length === 0)
|
|
2162
|
+
return;
|
|
2163
|
+
const sink = this.billingEventSink ?? new JsonlBillingEventSink(defaultBillingEventLogPath({
|
|
2164
|
+
preparationDataDir: prepDataDir,
|
|
2165
|
+
preparationName: run.preparation,
|
|
2166
|
+
runId: context.runId,
|
|
2167
|
+
}));
|
|
2168
|
+
const events = buildCompilationEventsForRun({
|
|
2169
|
+
runId: context.runId,
|
|
2170
|
+
preparation: run.preparation,
|
|
2171
|
+
methodId: run.method,
|
|
2172
|
+
accountId: null, // 0.17 — loopback only; cloud variant fills via tokenValidator (B4.3).
|
|
2173
|
+
artifacts: run.artifacts,
|
|
2174
|
+
startedAt: run.started_at ?? null,
|
|
2175
|
+
finishedAt: run.finished_at ?? null,
|
|
2176
|
+
});
|
|
2177
|
+
for (const event of events) {
|
|
2178
|
+
sink.emit(event);
|
|
2179
|
+
}
|
|
2180
|
+
}
|
|
2181
|
+
catch {
|
|
2182
|
+
// Billing is observability-only in 0.17; never let stub failures
|
|
2183
|
+
// block a successful compile.
|
|
2184
|
+
}
|
|
2185
|
+
}
|
|
2071
2186
|
writeCompileRun(prepDataDir, compiledPath, run) {
|
|
2072
2187
|
mkdirSync(compileRunsRoot(compiledPath), { recursive: true });
|
|
2073
2188
|
writeJsonFile(compileRunPath(compiledPath, run.run_id), CompileRunSchema.parse(run));
|
|
@@ -2158,6 +2273,19 @@ export class LocalServiceRuntime {
|
|
|
2158
2273
|
}),
|
|
2159
2274
|
};
|
|
2160
2275
|
next.latest_proof = [...next.stages].reverse().find((stage) => Boolean(stage.latest_proof))?.latest_proof ?? next.latest_proof;
|
|
2276
|
+
// Recompute per-Artifact status whenever the compile run is
|
|
2277
|
+
// refreshed from runtime state.
|
|
2278
|
+
try {
|
|
2279
|
+
const method = getCompiledMethod(current.method, { prepDataDir });
|
|
2280
|
+
next.artifacts = computeArtifactStatuses({
|
|
2281
|
+
method,
|
|
2282
|
+
compiledPath,
|
|
2283
|
+
stageRuns: next.stages,
|
|
2284
|
+
});
|
|
2285
|
+
}
|
|
2286
|
+
catch {
|
|
2287
|
+
next.artifacts = current.artifacts ?? [];
|
|
2288
|
+
}
|
|
2161
2289
|
this.writeCompileRun(prepDataDir, compiledPath, next);
|
|
2162
2290
|
}
|
|
2163
2291
|
async emitRuntimeDerivedEvents(prepDataDir, compiledPath, runId) {
|
|
@@ -2221,10 +2349,10 @@ export class LocalServiceRuntime {
|
|
|
2221
2349
|
readiness,
|
|
2222
2350
|
};
|
|
2223
2351
|
}
|
|
2224
|
-
|
|
2225
|
-
mkdirSync(
|
|
2226
|
-
writeJsonFile(
|
|
2227
|
-
this.
|
|
2352
|
+
writeVerifyRun(prepDataDir, compiledPath, run) {
|
|
2353
|
+
mkdirSync(verifyRunsRoot(compiledPath), { recursive: true });
|
|
2354
|
+
writeJsonFile(verifyRunPath(compiledPath, run.run_id), VerifyRunResourceSchema.parse(run));
|
|
2355
|
+
this.verifyRunCache.invalidatePreparation(prepDataDir, run.preparation);
|
|
2228
2356
|
this.readinessCache.invalidatePreparation(prepDataDir, run.preparation);
|
|
2229
2357
|
}
|
|
2230
2358
|
}
|