@interf/compiler 0.9.5 → 0.16.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/README.md +135 -91
- package/TRADEMARKS.md +2 -13
- package/agent-skills/interf-actions/SKILL.md +143 -38
- package/agent-skills/interf-actions/references/cli.md +134 -67
- package/builtin-methods/interf-default/README.md +3 -4
- package/builtin-methods/interf-default/compile/stages/shape/SKILL.md +2 -2
- package/builtin-methods/interf-default/compile/stages/summarize/SKILL.md +2 -1
- package/builtin-methods/interf-default/improve/SKILL.md +1 -1
- package/builtin-methods/interf-default/method.json +10 -4
- package/builtin-methods/interf-default/method.schema.json +0 -9
- package/builtin-methods/interf-default/use/query/SKILL.md +5 -5
- package/dist/cli/commands/agents.d.ts +2 -0
- package/dist/cli/commands/agents.js +213 -0
- package/dist/cli/commands/compile.d.ts +8 -25
- package/dist/cli/commands/compile.js +83 -359
- package/dist/cli/commands/doctor.js +2 -2
- package/dist/cli/commands/login.d.ts +7 -0
- package/dist/cli/commands/login.js +39 -0
- package/dist/cli/commands/logout.d.ts +2 -0
- package/dist/cli/commands/logout.js +16 -0
- package/dist/cli/commands/mcp.d.ts +42 -0
- package/dist/cli/commands/mcp.js +239 -0
- package/dist/cli/commands/method.d.ts +2 -0
- package/dist/cli/commands/method.js +113 -0
- package/dist/cli/commands/prep.d.ts +2 -0
- package/dist/cli/commands/prep.js +152 -0
- package/dist/cli/commands/reset.d.ts +8 -1
- package/dist/cli/commands/reset.js +47 -26
- package/dist/cli/commands/runs.d.ts +2 -0
- package/dist/cli/commands/runs.js +120 -0
- package/dist/cli/commands/status.d.ts +6 -1
- package/dist/cli/commands/status.js +68 -111
- package/dist/cli/commands/verify.d.ts +7 -1
- package/dist/cli/commands/verify.js +69 -85
- package/dist/cli/commands/web.d.ts +0 -9
- package/dist/cli/commands/web.js +201 -121
- package/dist/cli/commands/wizard.d.ts +9 -0
- package/dist/cli/commands/wizard.js +689 -0
- package/dist/cli/index.d.ts +10 -7
- package/dist/cli/index.js +19 -12
- 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/{177mvn4rse235.js → 0jipmpez3_ehh.js} +16 -16
- package/dist/compiler-ui/_next/static/chunks/{18a8f2jkv3z.c.css → 13awzu4tooflw.css} +1 -1
- 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/preparation-paths.d.ts +117 -0
- package/dist/packages/contracts/lib/preparation-paths.js +177 -0
- package/dist/packages/contracts/lib/schema.d.ts +187 -13
- package/dist/packages/contracts/lib/schema.js +148 -3
- package/dist/packages/contracts/utils/filesystem.d.ts +9 -0
- package/dist/packages/contracts/utils/filesystem.js +142 -0
- package/dist/packages/{local-service → engine}/action-definitions.d.ts +14 -14
- package/dist/packages/{local-service → engine}/action-definitions.js +35 -29
- package/dist/packages/{local-service → engine}/action-planner.d.ts +1 -1
- package/dist/packages/{local-service → engine}/action-planner.js +3 -2
- 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 +5 -5
- package/dist/packages/{agents → engine/agents}/lib/shells.js +117 -58
- package/dist/packages/{agents → engine/agents}/lib/user-config.d.ts +4 -2
- package/dist/packages/engine/agents/lib/user-config.js +24 -0
- 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 +59 -60
- package/dist/packages/{local-service → engine}/client.js +137 -145
- package/dist/packages/{compiler → engine/compile}/artifact-counts.js +1 -1
- package/dist/packages/{compiler → engine/compile}/compiled-paths.d.ts +9 -2
- package/dist/packages/{compiler → engine/compile}/compiled-paths.js +30 -15
- package/dist/packages/{compiler → engine/compile}/compiled-pipeline.d.ts +12 -1
- package/dist/packages/{compiler → engine/compile}/compiled-pipeline.js +39 -9
- package/dist/packages/{compiler → engine/compile}/compiled-schema.d.ts +2 -2
- package/dist/packages/{compiler → engine/compile}/compiled-schema.js +4 -4
- package/dist/packages/{compiler → engine/compile}/compiled-stage-plan.d.ts +1 -1
- package/dist/packages/{compiler → engine/compile}/compiled-stage-plan.js +8 -4
- package/dist/packages/{compiler → engine/compile}/compiled-stage-runner.d.ts +1 -1
- package/dist/packages/{compiler → engine/compile}/compiled-stage-runner.js +3 -3
- package/dist/packages/{compiler → engine/compile}/compiled-target.d.ts +3 -3
- package/dist/packages/{compiler → engine/compile}/compiled-target.js +3 -3
- package/dist/packages/{compiler → engine/compile}/discovery.js +1 -1
- package/dist/packages/{compiler → engine/compile}/index.d.ts +1 -0
- package/dist/packages/{compiler → engine/compile}/index.js +1 -0
- package/dist/packages/{compiler → engine/compile}/lib/schema.d.ts +26 -31
- package/dist/packages/{compiler → engine/compile}/lib/schema.js +2 -13
- package/dist/packages/engine/compile/method-runs.d.ts +14 -0
- package/dist/packages/{compiler → engine/compile}/method-runs.js +5 -6
- package/dist/packages/{compiler → engine/compile}/reset.js +3 -1
- package/dist/packages/{compiler → engine/compile}/runtime-acceptance.js +17 -14
- package/dist/packages/{compiler → engine/compile}/runtime-contracts.js +0 -3
- package/dist/packages/{compiler → engine/compile}/runtime-prompt.js +1 -1
- package/dist/packages/{compiler → engine/compile}/runtime-reconcile.d.ts +1 -1
- package/dist/packages/{compiler → engine/compile}/runtime-reconcile.js +12 -10
- package/dist/packages/{compiler → engine/compile}/runtime-runs.d.ts +1 -2
- package/dist/packages/{compiler → engine/compile}/runtime-runs.js +3 -43
- package/dist/packages/{compiler → engine/compile}/runtime-types.d.ts +1 -5
- package/dist/packages/{compiler → engine/compile}/runtime.d.ts +2 -2
- package/dist/packages/{compiler → engine/compile}/runtime.js +1 -1
- package/dist/packages/engine/compile/source-files.d.ts +46 -0
- package/dist/packages/engine/compile/source-files.js +149 -0
- package/dist/packages/engine/compile/state-artifacts.d.ts +9 -0
- package/dist/packages/{compiler → engine/compile}/state-artifacts.js +4 -3
- package/dist/packages/{compiler → engine/compile}/state-health.js +2 -2
- package/dist/packages/{compiler → engine/compile}/state-io.d.ts +3 -2
- package/dist/packages/{compiler → engine/compile}/state-io.js +13 -7
- package/dist/packages/{compiler → engine/compile}/state-paths.d.ts +2 -1
- package/dist/packages/engine/compile/state-paths.js +16 -0
- package/dist/packages/engine/compile/state-view.d.ts +5 -0
- package/dist/packages/{compiler → engine/compile}/state-view.js +20 -30
- package/dist/packages/engine/compile/state.d.ts +7 -0
- package/dist/packages/{compiler → engine/compile}/state.js +3 -3
- package/dist/packages/{compiler → engine/compile}/validate-compiled.js +2 -2
- package/dist/packages/{compiler → engine/compile}/validate.d.ts +1 -1
- package/dist/packages/{compiler → engine/compile}/validate.js +3 -3
- package/dist/packages/engine/connection-config.d.ts +38 -0
- package/dist/packages/engine/connection-config.js +75 -0
- package/dist/packages/{execution → engine/execution}/lib/schema.d.ts +52 -72
- package/dist/packages/{execution → engine/execution}/lib/schema.js +3 -3
- package/dist/packages/engine/index.d.ts +22 -0
- package/dist/packages/engine/index.js +15 -0
- package/dist/packages/engine/instance-paths.d.ts +100 -0
- package/dist/packages/engine/instance-paths.js +165 -0
- package/dist/packages/{local-service → engine}/lib/schema.d.ts +392 -2408
- package/dist/packages/{local-service → engine}/lib/schema.js +164 -76
- package/dist/packages/{local-service → engine}/native-run-handlers.d.ts +7 -5
- package/dist/packages/{local-service → engine}/native-run-handlers.js +71 -27
- package/dist/packages/engine/preparation-store.d.ts +104 -0
- package/dist/packages/engine/preparation-store.js +194 -0
- package/dist/packages/{local-service → engine}/readiness-check-draft.d.ts +2 -2
- package/dist/packages/engine/routes.d.ts +78 -0
- package/dist/packages/engine/routes.js +92 -0
- package/dist/packages/{local-service → engine}/run-observability.d.ts +3 -3
- package/dist/packages/{local-service → engine}/run-observability.js +25 -24
- package/dist/packages/engine/runtime-caches.d.ts +76 -0
- package/dist/packages/engine/runtime-caches.js +191 -0
- package/dist/packages/engine/runtime-event-applier.d.ts +12 -0
- package/dist/packages/engine/runtime-event-applier.js +177 -0
- package/dist/packages/engine/runtime-persistence.d.ts +47 -0
- package/dist/packages/engine/runtime-persistence.js +137 -0
- package/dist/packages/engine/runtime-proposal-helpers.d.ts +35 -0
- package/dist/packages/engine/runtime-proposal-helpers.js +251 -0
- package/dist/packages/engine/runtime-resource-builders.d.ts +52 -0
- package/dist/packages/engine/runtime-resource-builders.js +149 -0
- package/dist/packages/engine/runtime.d.ts +318 -0
- package/dist/packages/{local-service → engine}/runtime.js +835 -1011
- package/dist/packages/{local-service → engine}/server.d.ts +15 -0
- package/dist/packages/engine/server.js +1257 -0
- package/dist/packages/engine/service-registry.d.ts +47 -0
- package/dist/packages/engine/service-registry.js +137 -0
- package/dist/packages/{testing → engine/verify}/lib/schema.d.ts +11 -11
- package/dist/packages/{testing → engine/verify}/lib/schema.js +3 -3
- package/dist/packages/{testing → engine/verify}/readiness-check-run.d.ts +9 -16
- package/dist/packages/{testing → engine/verify}/readiness-check-run.js +38 -94
- package/dist/packages/{testing → engine/verify}/test-execution.js +6 -6
- package/dist/packages/{testing → engine/verify}/test-paths.js +5 -4
- package/dist/packages/{testing → engine/verify}/test-sandbox.d.ts +0 -1
- package/dist/packages/{testing → engine/verify}/test-sandbox.js +17 -33
- package/dist/packages/{testing → engine/verify}/test-specs.js +1 -1
- package/dist/packages/{testing → engine/verify}/test-targets.d.ts +1 -1
- package/dist/packages/{testing → engine/verify}/test-targets.js +9 -9
- package/dist/packages/{testing → engine/verify}/test.d.ts +1 -1
- package/dist/packages/{testing → engine/verify}/test.js +1 -1
- package/dist/packages/{method-authoring → methods/authoring}/method-authoring.d.ts +12 -4
- package/dist/packages/{method-authoring → methods/authoring}/method-authoring.js +70 -7
- package/dist/packages/{method-authoring → methods/authoring}/method-edit-session.d.ts +2 -2
- 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 +4 -5
- package/dist/packages/{method-package → methods/package}/builtin-compiled-method.js +10 -16
- package/dist/packages/{method-package → methods/package}/context-interface.d.ts +5 -41
- package/dist/packages/{method-package → methods/package}/context-interface.js +3 -25
- package/dist/packages/{method-package → methods/package}/interf-method-package.d.ts +4 -4
- package/dist/packages/{method-package → methods/package}/interf-method-package.js +24 -35
- package/dist/packages/{method-package → methods/package}/lib/package-root.js +2 -2
- package/dist/packages/{method-package → methods/package}/local-methods.d.ts +18 -8
- package/dist/packages/{method-package → methods/package}/local-methods.js +64 -45
- package/dist/packages/{method-package → methods/package}/method-definitions.d.ts +16 -36
- package/dist/packages/{method-package → methods/package}/method-definitions.js +53 -40
- package/dist/packages/{method-package → methods/package}/method-helpers.d.ts +2 -14
- package/dist/packages/{method-package → methods/package}/method-helpers.js +12 -46
- 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 +3 -31
- package/dist/packages/methods/package/user-methods.d.ts +17 -0
- package/dist/packages/methods/package/user-methods.js +77 -0
- package/dist/packages/{project-model → project}/index.d.ts +0 -1
- package/dist/packages/{project-model → project}/index.js +0 -1
- 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.d.ts +8 -3
- package/dist/packages/{project-model → project}/interf-detect.js +38 -38
- package/dist/packages/project/interf-scaffold.d.ts +3 -0
- package/dist/packages/{project-model → project}/interf-scaffold.js +30 -39
- package/dist/packages/{project-model → project}/lib/schema.d.ts +2 -2
- package/dist/packages/{project-model → project}/lib/schema.js +39 -2
- package/dist/packages/project/preparation-entries.d.ts +11 -0
- package/dist/packages/{project-model → project}/preparation-entries.js +14 -14
- package/dist/packages/{project-model → project}/source-config.d.ts +12 -12
- package/dist/packages/{project-model → project}/source-config.js +81 -53
- package/dist/packages/{project-model → project}/source-folders.d.ts +5 -5
- package/dist/packages/{project-model → project}/source-folders.js +16 -16
- package/package.json +8 -8
- package/CHANGELOG.md +0 -93
- package/LICENSE +0 -183
- package/dist/cli/commands/action-input-cli.d.ts +0 -25
- package/dist/cli/commands/action-input-cli.js +0 -73
- package/dist/cli/commands/control-path.d.ts +0 -11
- package/dist/cli/commands/control-path.js +0 -72
- package/dist/cli/commands/create-method-wizard.d.ts +0 -64
- package/dist/cli/commands/create-method-wizard.js +0 -434
- package/dist/cli/commands/create.d.ts +0 -6
- package/dist/cli/commands/create.js +0 -183
- package/dist/cli/commands/default.d.ts +0 -2
- package/dist/cli/commands/default.js +0 -39
- package/dist/cli/commands/executor-flow.d.ts +0 -29
- package/dist/cli/commands/executor-flow.js +0 -163
- package/dist/cli/commands/init.d.ts +0 -26
- package/dist/cli/commands/init.js +0 -771
- package/dist/cli/commands/list.d.ts +0 -2
- package/dist/cli/commands/list.js +0 -30
- package/dist/cli/commands/preparation-action.d.ts +0 -8
- package/dist/cli/commands/preparation-action.js +0 -29
- package/dist/cli/commands/preparation-picker.d.ts +0 -5
- package/dist/cli/commands/preparation-picker.js +0 -36
- package/dist/cli/commands/preparation-selection.d.ts +0 -6
- package/dist/cli/commands/preparation-selection.js +0 -11
- package/dist/cli/commands/service-action-flow.d.ts +0 -9
- package/dist/cli/commands/service-action-flow.js +0 -19
- package/dist/cli/commands/source-config-wizard.d.ts +0 -51
- package/dist/cli/commands/source-config-wizard.js +0 -670
- package/dist/cli/commands/test.d.ts +0 -17
- package/dist/cli/commands/test.js +0 -188
- package/dist/packages/agents/lib/detection.d.ts +0 -7
- package/dist/packages/agents/lib/user-config.js +0 -16
- package/dist/packages/compiler/method-runs.d.ts +0 -15
- package/dist/packages/compiler/raw-snapshot.d.ts +0 -49
- package/dist/packages/compiler/raw-snapshot.js +0 -101
- package/dist/packages/compiler/state-artifacts.d.ts +0 -8
- package/dist/packages/compiler/state-paths.js +0 -13
- package/dist/packages/compiler/state-view.d.ts +0 -4
- package/dist/packages/compiler/state.d.ts +0 -7
- package/dist/packages/local-service/index.d.ts +0 -18
- package/dist/packages/local-service/index.js +0 -13
- package/dist/packages/local-service/routes.d.ts +0 -32
- package/dist/packages/local-service/routes.js +0 -37
- package/dist/packages/local-service/runtime.d.ts +0 -133
- package/dist/packages/local-service/server.js +0 -627
- package/dist/packages/method-package/index.d.ts +0 -11
- package/dist/packages/method-package/index.js +0 -11
- package/dist/packages/method-package/method-stage-policy.d.ts +0 -5
- package/dist/packages/method-package/method-stage-policy.js +0 -31
- package/dist/packages/project-model/interf-scaffold.d.ts +0 -3
- package/dist/packages/project-model/preparation-entries.d.ts +0 -11
- package/dist/packages/project-model/project-paths.d.ts +0 -12
- package/dist/packages/project-model/project-paths.js +0 -33
- package/dist/packages/shared/filesystem.d.ts +0 -2
- package/dist/packages/shared/filesystem.js +0 -55
- /package/dist/compiler-ui/_next/static/{84FaeF3EzBF9kKTMjSEVN → a3UiUF0DiMEbfWy_0gihg}/_buildManifest.js +0 -0
- /package/dist/compiler-ui/_next/static/{84FaeF3EzBF9kKTMjSEVN → a3UiUF0DiMEbfWy_0gihg}/_clientMiddlewareManifest.js +0 -0
- /package/dist/compiler-ui/_next/static/{84FaeF3EzBF9kKTMjSEVN → a3UiUF0DiMEbfWy_0gihg}/_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}/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-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/{compiler → engine/compile}/artifact-counts.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}/discovery.d.ts +0 -0
- /package/dist/packages/{compiler → engine/compile}/method-primitives.d.ts +0 -0
- /package/dist/packages/{compiler → engine/compile}/method-primitives.js +0 -0
- /package/dist/packages/{compiler → engine/compile}/reset.d.ts +0 -0
- /package/dist/packages/{compiler → engine/compile}/runtime-acceptance.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-health.d.ts +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/{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}/readiness-check-draft.js +0 -0
- /package/dist/packages/{testing → engine/verify}/index.d.ts +0 -0
- /package/dist/packages/{testing → engine/verify}/index.js +0 -0
- /package/dist/packages/{testing → engine/verify}/test-execution.d.ts +0 -0
- /package/dist/packages/{testing → engine/verify}/test-paths.d.ts +0 -0
- /package/dist/packages/{testing → engine/verify}/test-profile-presets.d.ts +0 -0
- /package/dist/packages/{testing → engine/verify}/test-profile-presets.js +0 -0
- /package/dist/packages/{testing → engine/verify}/test-specs.d.ts +0 -0
- /package/dist/packages/{testing → engine/verify}/test-types.d.ts +0 -0
- /package/dist/packages/{testing → engine/verify}/test-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-authoring → methods/authoring}/method-edit-session.js +0 -0
- /package/dist/packages/{method-package → methods/package}/lib/package-root.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
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agents registry — `~/.interf/agents.json`.
|
|
3
|
+
*
|
|
4
|
+
* Reads / writes the persisted user-registered agents and the role-map.
|
|
5
|
+
* Built-in agents (Claude Code, Codex, Cursor) are NOT persisted; they
|
|
6
|
+
* are detected dynamically at read time and merged with the persisted
|
|
7
|
+
* custom agents. The role-map IS persisted.
|
|
8
|
+
*
|
|
9
|
+
* 0.15 contract:
|
|
10
|
+
* {
|
|
11
|
+
* "agents": [
|
|
12
|
+
* { "name": "opencode", "display_name": "OpenCode", "command": "opencode --prompt", "source": "user" }
|
|
13
|
+
* ],
|
|
14
|
+
* "role_map": {
|
|
15
|
+
* "extractor": "claude-code",
|
|
16
|
+
* "summarizer": "claude-code",
|
|
17
|
+
* "structurer": "claude-code",
|
|
18
|
+
* "verifier": "claude-code",
|
|
19
|
+
* "general": "claude-code"
|
|
20
|
+
* }
|
|
21
|
+
* }
|
|
22
|
+
*/
|
|
23
|
+
import { existsSync, mkdirSync, writeFileSync } from "node:fs";
|
|
24
|
+
import { join } from "node:path";
|
|
25
|
+
import { AgentRecordSchema, AgentsRegistrySchema, CANONICAL_ROLES, } from "../../contracts/lib/schema.js";
|
|
26
|
+
import { readJsonFileWithSchema } from "../../contracts/utils/parse.js";
|
|
27
|
+
import { interfHomeRoot } from "../instance-paths.js";
|
|
28
|
+
import { agentCommandAvailable, detectAgents, supportsAutomatedRuns } from "./lib/detection.js";
|
|
29
|
+
import { AGENTS } from "./lib/constants.js";
|
|
30
|
+
export const AGENTS_REGISTRY_FILENAME = "agents.json";
|
|
31
|
+
/** `~/.interf/agents.json` — persisted custom agents + role-map. */
|
|
32
|
+
export function agentsRegistryPath() {
|
|
33
|
+
return join(interfHomeRoot(), AGENTS_REGISTRY_FILENAME);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Load just the persisted on-disk part of the registry. Built-in agents
|
|
37
|
+
* are NOT included — call `loadAgentsRegistry()` for the merged view.
|
|
38
|
+
*
|
|
39
|
+
* Returns `{ agents: [], role_map: {} }` when the file is missing or
|
|
40
|
+
* unreadable; persisted custom agents always have `source: "user"`.
|
|
41
|
+
*/
|
|
42
|
+
export function loadPersistedRegistry() {
|
|
43
|
+
const path = agentsRegistryPath();
|
|
44
|
+
if (!existsSync(path)) {
|
|
45
|
+
return AgentsRegistrySchema.parse({});
|
|
46
|
+
}
|
|
47
|
+
const value = readJsonFileWithSchema(path, "agents registry", AgentsRegistrySchema);
|
|
48
|
+
return value ?? AgentsRegistrySchema.parse({});
|
|
49
|
+
}
|
|
50
|
+
/** Persist the on-disk part of the registry (custom agents + role-map). */
|
|
51
|
+
export function savePersistedRegistry(registry) {
|
|
52
|
+
const home = interfHomeRoot();
|
|
53
|
+
mkdirSync(home, { recursive: true });
|
|
54
|
+
const sanitized = {
|
|
55
|
+
agents: registry.agents.map(({ available: _available, ...agent }) => AgentRecordSchema.parse({ ...agent, source: "user" })),
|
|
56
|
+
role_map: { ...registry.role_map },
|
|
57
|
+
};
|
|
58
|
+
writeFileSync(agentsRegistryPath(), `${JSON.stringify(sanitized, null, 2)}\n`);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Detect built-in agents present on this machine. Filtered to agents
|
|
62
|
+
* whose marker home directory exists; we do NOT require the command
|
|
63
|
+
* to be on PATH at registry read time — that's a runtime concern.
|
|
64
|
+
*/
|
|
65
|
+
export function detectBuiltinAgentRecords() {
|
|
66
|
+
return detectAgents().map((agent) => AgentRecordSchema.parse({
|
|
67
|
+
name: agent.name,
|
|
68
|
+
display_name: agent.displayName,
|
|
69
|
+
command: agent.command,
|
|
70
|
+
source: "builtin",
|
|
71
|
+
}));
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Same as `detectBuiltinAgentRecords()` but only includes agents the
|
|
75
|
+
* current Interf build can fully drive (Claude Code, Codex). Used by
|
|
76
|
+
* the role-router and the CLI / UI listing as the "available agents"
|
|
77
|
+
* set.
|
|
78
|
+
*/
|
|
79
|
+
export function detectAutomatableBuiltinAgentRecords() {
|
|
80
|
+
return detectAgents()
|
|
81
|
+
.filter(supportsAutomatedRuns)
|
|
82
|
+
.map((agent) => AgentRecordSchema.parse({
|
|
83
|
+
name: agent.name,
|
|
84
|
+
display_name: agent.displayName,
|
|
85
|
+
command: agent.command,
|
|
86
|
+
source: "builtin",
|
|
87
|
+
}));
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Full advertisement set — all built-in agents Interf knows about,
|
|
91
|
+
* regardless of whether they are installed locally. Used by the
|
|
92
|
+
* "install cards" zero-state surface so the UI / wizard can offer
|
|
93
|
+
* the user choices to install.
|
|
94
|
+
*/
|
|
95
|
+
export function listKnownBuiltinAgents() {
|
|
96
|
+
return AGENTS.map((agent) => AgentRecordSchema.parse({
|
|
97
|
+
name: agent.name,
|
|
98
|
+
display_name: agent.displayName,
|
|
99
|
+
command: agent.command,
|
|
100
|
+
source: "builtin",
|
|
101
|
+
}));
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Merge persisted custom agents with the built-in agents currently
|
|
105
|
+
* detected on this machine. Detected built-ins are listed first; any
|
|
106
|
+
* persisted custom entry whose name collides with a built-in is
|
|
107
|
+
* dropped (built-ins are immutable / cannot be overridden).
|
|
108
|
+
*
|
|
109
|
+
* Each merged record carries an `available` flag — true when the
|
|
110
|
+
* agent's command resolves on PATH. Built-ins are detected by their
|
|
111
|
+
* marker directory and assumed available; custom agents are checked
|
|
112
|
+
* against `which` so a stale `~/.interf/agents.json` entry does not
|
|
113
|
+
* appear as a usable choice.
|
|
114
|
+
*/
|
|
115
|
+
function mergeAgents(builtin, persisted) {
|
|
116
|
+
const seen = new Set(builtin.map((agent) => agent.name));
|
|
117
|
+
const merged = builtin.map((agent) => ({ ...agent, available: true }));
|
|
118
|
+
for (const agent of persisted) {
|
|
119
|
+
if (seen.has(agent.name))
|
|
120
|
+
continue;
|
|
121
|
+
seen.add(agent.name);
|
|
122
|
+
merged.push({
|
|
123
|
+
...agent,
|
|
124
|
+
source: "user",
|
|
125
|
+
available: agentCommandAvailable(agent.command),
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
return merged;
|
|
129
|
+
}
|
|
130
|
+
function pickActiveAgent(agents, roleMap) {
|
|
131
|
+
const generalName = roleMap["general"];
|
|
132
|
+
const generalAgent = generalName
|
|
133
|
+
? agents.find((agent) => agent.name === generalName)
|
|
134
|
+
: null;
|
|
135
|
+
if (generalAgent && generalAgent.available !== false)
|
|
136
|
+
return generalAgent;
|
|
137
|
+
return agents.find((agent) => agent.available !== false) ?? null;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Default role-map for a fresh install: every canonical role maps to
|
|
141
|
+
* the first available agent. If nothing is detected, returns an empty
|
|
142
|
+
* object (callers must handle "no agents available" upstream).
|
|
143
|
+
*/
|
|
144
|
+
function buildDefaultRoleMap(agents) {
|
|
145
|
+
const first = agents.find((agent) => agent.available !== false) ?? agents[0];
|
|
146
|
+
if (!first)
|
|
147
|
+
return {};
|
|
148
|
+
const map = {};
|
|
149
|
+
for (const role of CANONICAL_ROLES) {
|
|
150
|
+
map[role] = first.name;
|
|
151
|
+
}
|
|
152
|
+
return map;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Public entry point — read the persisted registry, merge with detected
|
|
156
|
+
* built-ins, and seed the default role-map on first read if needed.
|
|
157
|
+
*
|
|
158
|
+
* Does NOT write back to disk. Callers that mutate the registry should
|
|
159
|
+
* call `savePersistedRegistry()` explicitly with the persisted slice.
|
|
160
|
+
*/
|
|
161
|
+
export function loadAgentsRegistry() {
|
|
162
|
+
const persisted = loadPersistedRegistry();
|
|
163
|
+
const builtinDetected = detectAutomatableBuiltinAgentRecords();
|
|
164
|
+
const agents = mergeAgents(builtinDetected, persisted.agents);
|
|
165
|
+
// Seed the default role-map on first read when the persisted file
|
|
166
|
+
// has no role-map entries AND we have at least one detectable agent.
|
|
167
|
+
// (We do not write to disk yet; the seeded map is computed on the
|
|
168
|
+
// fly for each reader so a fresh install behaves identically before
|
|
169
|
+
// and after the first user edit.)
|
|
170
|
+
const persistedRoleMap = persisted.role_map;
|
|
171
|
+
const hasPersistedEntries = Object.keys(persistedRoleMap).length > 0;
|
|
172
|
+
const roleMap = hasPersistedEntries
|
|
173
|
+
? { ...persistedRoleMap }
|
|
174
|
+
: buildDefaultRoleMap(agents);
|
|
175
|
+
// Derive the "active" agent: role-map's `general` entry, falling
|
|
176
|
+
// back to the first available agent. Skips the general entry if it
|
|
177
|
+
// points at an agent whose command is no longer on PATH.
|
|
178
|
+
const activeAgent = pickActiveAgent(agents, roleMap);
|
|
179
|
+
return { agents, roleMap, activeAgent };
|
|
180
|
+
}
|
|
181
|
+
/** Pure helper — like `loadAgentsRegistry()` but works off in-memory data. */
|
|
182
|
+
export function resolveRegistry(persisted, builtinDetected) {
|
|
183
|
+
const agents = mergeAgents(builtinDetected, persisted.agents);
|
|
184
|
+
const hasPersistedEntries = Object.keys(persisted.role_map).length > 0;
|
|
185
|
+
const roleMap = hasPersistedEntries
|
|
186
|
+
? { ...persisted.role_map }
|
|
187
|
+
: buildDefaultRoleMap(agents);
|
|
188
|
+
const activeAgent = pickActiveAgent(agents, roleMap);
|
|
189
|
+
return { agents, roleMap, activeAgent };
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Update the role-map (full replace). Returns the persisted slice that
|
|
193
|
+
* was written.
|
|
194
|
+
*/
|
|
195
|
+
export function updateRoleMap(nextRoleMap) {
|
|
196
|
+
const current = loadPersistedRegistry();
|
|
197
|
+
const next = {
|
|
198
|
+
agents: current.agents,
|
|
199
|
+
role_map: { ...nextRoleMap },
|
|
200
|
+
};
|
|
201
|
+
savePersistedRegistry(next);
|
|
202
|
+
return next;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Patch the role-map with a partial update. Empty-string values clear
|
|
206
|
+
* the role (it falls back to `general` / active agent at run time).
|
|
207
|
+
*/
|
|
208
|
+
export function patchRoleMap(patch) {
|
|
209
|
+
const current = loadPersistedRegistry();
|
|
210
|
+
const next = { ...current.role_map };
|
|
211
|
+
for (const [role, agentName] of Object.entries(patch)) {
|
|
212
|
+
if (typeof agentName !== "string" || agentName.trim().length === 0) {
|
|
213
|
+
delete next[role];
|
|
214
|
+
continue;
|
|
215
|
+
}
|
|
216
|
+
next[role] = agentName.trim();
|
|
217
|
+
}
|
|
218
|
+
const updated = {
|
|
219
|
+
agents: current.agents,
|
|
220
|
+
role_map: next,
|
|
221
|
+
};
|
|
222
|
+
savePersistedRegistry(updated);
|
|
223
|
+
return updated;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Register a new custom agent. Throws if `name` collides with a known
|
|
227
|
+
* built-in or with an already-persisted custom agent.
|
|
228
|
+
*/
|
|
229
|
+
export function registerCustomAgent(input) {
|
|
230
|
+
const trimmedName = input.name.trim();
|
|
231
|
+
const trimmedDisplayName = input.display_name.trim();
|
|
232
|
+
const trimmedCommand = input.command.trim();
|
|
233
|
+
if (!trimmedName)
|
|
234
|
+
throw new Error("Agent name is required.");
|
|
235
|
+
if (!trimmedDisplayName)
|
|
236
|
+
throw new Error("Agent display name is required.");
|
|
237
|
+
if (!trimmedCommand)
|
|
238
|
+
throw new Error("Agent command is required.");
|
|
239
|
+
if (AGENTS.some((agent) => agent.name === trimmedName)) {
|
|
240
|
+
throw new Error(`Cannot register custom agent "${trimmedName}": that name is reserved for a built-in agent.`);
|
|
241
|
+
}
|
|
242
|
+
const current = loadPersistedRegistry();
|
|
243
|
+
if (current.agents.some((agent) => agent.name === trimmedName)) {
|
|
244
|
+
throw new Error(`Custom agent "${trimmedName}" is already registered.`);
|
|
245
|
+
}
|
|
246
|
+
const record = AgentRecordSchema.parse({
|
|
247
|
+
name: trimmedName,
|
|
248
|
+
display_name: trimmedDisplayName,
|
|
249
|
+
command: trimmedCommand,
|
|
250
|
+
source: "user",
|
|
251
|
+
});
|
|
252
|
+
const next = {
|
|
253
|
+
agents: [...current.agents, record],
|
|
254
|
+
role_map: { ...current.role_map },
|
|
255
|
+
};
|
|
256
|
+
savePersistedRegistry(next);
|
|
257
|
+
return next;
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Unregister a custom agent. Throws if `name` matches a built-in or no
|
|
261
|
+
* custom record exists. Removes any role-map entry pointing at the
|
|
262
|
+
* removed agent.
|
|
263
|
+
*/
|
|
264
|
+
export function unregisterCustomAgent(name) {
|
|
265
|
+
const trimmedName = name.trim();
|
|
266
|
+
if (AGENTS.some((agent) => agent.name === trimmedName)) {
|
|
267
|
+
throw new Error(`Cannot unregister built-in agent "${trimmedName}". Built-in agents are detected dynamically.`);
|
|
268
|
+
}
|
|
269
|
+
const current = loadPersistedRegistry();
|
|
270
|
+
const remaining = current.agents.filter((agent) => agent.name !== trimmedName);
|
|
271
|
+
if (remaining.length === current.agents.length) {
|
|
272
|
+
throw new Error(`Custom agent "${trimmedName}" is not registered.`);
|
|
273
|
+
}
|
|
274
|
+
const trimmedRoleMap = {};
|
|
275
|
+
for (const [role, agentName] of Object.entries(current.role_map)) {
|
|
276
|
+
if (agentName === trimmedName)
|
|
277
|
+
continue;
|
|
278
|
+
trimmedRoleMap[role] = agentName;
|
|
279
|
+
}
|
|
280
|
+
const next = {
|
|
281
|
+
agents: remaining,
|
|
282
|
+
role_map: trimmedRoleMap,
|
|
283
|
+
};
|
|
284
|
+
savePersistedRegistry(next);
|
|
285
|
+
return next;
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Set the "active" agent — i.e. the agent the role-map's `general` row
|
|
289
|
+
* points at. Also updates any role still pointing at the previous
|
|
290
|
+
* active agent so existing single-active-agent setups don't need
|
|
291
|
+
* per-role edits when switching agents.
|
|
292
|
+
*
|
|
293
|
+
* Throws if `name` is not in the merged agents list.
|
|
294
|
+
*/
|
|
295
|
+
export function setActiveAgent(name) {
|
|
296
|
+
const trimmedName = name.trim();
|
|
297
|
+
if (!trimmedName)
|
|
298
|
+
throw new Error("Agent name is required.");
|
|
299
|
+
const persisted = loadPersistedRegistry();
|
|
300
|
+
const builtinDetected = detectAutomatableBuiltinAgentRecords();
|
|
301
|
+
const agents = mergeAgents(builtinDetected, persisted.agents);
|
|
302
|
+
if (!agents.some((agent) => agent.name === trimmedName)) {
|
|
303
|
+
throw new Error(`Agent "${trimmedName}" is not detected or registered. Install or register it before making it active.`);
|
|
304
|
+
}
|
|
305
|
+
// The previous active is whatever `general` currently maps to (or the
|
|
306
|
+
// first agent in the merged list when `general` is unset).
|
|
307
|
+
const previousActive = persisted.role_map["general"] ?? agents[0]?.name ?? null;
|
|
308
|
+
const nextRoleMap = { ...persisted.role_map };
|
|
309
|
+
for (const [role, currentName] of Object.entries(nextRoleMap)) {
|
|
310
|
+
if (currentName === previousActive) {
|
|
311
|
+
nextRoleMap[role] = trimmedName;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
nextRoleMap["general"] = trimmedName;
|
|
315
|
+
const next = {
|
|
316
|
+
agents: persisted.agents,
|
|
317
|
+
role_map: nextRoleMap,
|
|
318
|
+
};
|
|
319
|
+
savePersistedRegistry(next);
|
|
320
|
+
return next;
|
|
321
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { AgentRecord, RoleMap } from "../../contracts/lib/schema.js";
|
|
2
|
+
import type { MethodExecutionProfile, MethodExecutor } from "./lib/executors.js";
|
|
3
|
+
import { type ResolvedAgent, type RoleResolutionContext } from "./role-router.js";
|
|
4
|
+
export interface RoleExecutorBundle {
|
|
5
|
+
/** Map agent name → method executor. */
|
|
6
|
+
executors: Map<string, MethodExecutor>;
|
|
7
|
+
/** Default fallback executor — usually the active agent. */
|
|
8
|
+
defaultExecutor: MethodExecutor;
|
|
9
|
+
/** The registry context we built this bundle from. */
|
|
10
|
+
context: RoleResolutionContext;
|
|
11
|
+
/**
|
|
12
|
+
* Resolve a stage's role to an executor + provenance. Falls back
|
|
13
|
+
* through `general` and the default executor before raising.
|
|
14
|
+
*/
|
|
15
|
+
resolveExecutorForRole(role: string): {
|
|
16
|
+
executor: MethodExecutor;
|
|
17
|
+
resolved: ResolvedAgent;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
export interface BuildRoleExecutorBundleInput {
|
|
21
|
+
agents: AgentRecord[];
|
|
22
|
+
roleMap: RoleMap;
|
|
23
|
+
/** The agent the role-map's `general` row points at, or fallback. */
|
|
24
|
+
activeAgent: AgentRecord | null;
|
|
25
|
+
/** The fallback executor — used when role resolution yields the active. */
|
|
26
|
+
defaultExecutor: MethodExecutor;
|
|
27
|
+
executionProfile?: MethodExecutionProfile;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Build a per-role executor bundle from a registry snapshot. The
|
|
31
|
+
* `defaultExecutor` is what the pipeline already passes for the
|
|
32
|
+
* single-active-agent case (so role lookups that fall through to
|
|
33
|
+
* `fallback-active` resolve to the same executor).
|
|
34
|
+
*/
|
|
35
|
+
export declare function buildRoleExecutorBundle(input: BuildRoleExecutorBundleInput): RoleExecutorBundle;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Role-aware executor factory.
|
|
3
|
+
*
|
|
4
|
+
* Bridges the registry layer (`AgentRecord` / `RoleMap`) to the runtime
|
|
5
|
+
* layer (`MethodExecutor`). Builds a per-agent-name `MethodExecutor`
|
|
6
|
+
* map up front and exposes a `resolveExecutorForRole(role)` helper that
|
|
7
|
+
* the compile / verify pipelines can call per-stage.
|
|
8
|
+
*
|
|
9
|
+
* Falls back gracefully: when a role isn't mapped, or the mapped agent
|
|
10
|
+
* is missing, we fall through to `general` and ultimately to the
|
|
11
|
+
* default executor (the active agent at job start).
|
|
12
|
+
*/
|
|
13
|
+
import { join } from "node:path";
|
|
14
|
+
import { homedir } from "node:os";
|
|
15
|
+
import { createLocalAgentExecutor } from "./lib/executors.js";
|
|
16
|
+
import { AGENTS } from "./lib/constants.js";
|
|
17
|
+
import { resolveAgentForRole, } from "./role-router.js";
|
|
18
|
+
/**
|
|
19
|
+
* Hydrate an `AgentRecord` (registry shape) into an `Agent` (runtime
|
|
20
|
+
* shape with `skillsDir`). For built-in agents we copy the canonical
|
|
21
|
+
* `skillsDir`; for custom user agents we synthesize a path under
|
|
22
|
+
* `~/.<name>` so any future skill loader has somewhere to look.
|
|
23
|
+
*/
|
|
24
|
+
function agentRecordToAgent(record) {
|
|
25
|
+
const builtin = AGENTS.find((agent) => agent.name === record.name);
|
|
26
|
+
if (builtin)
|
|
27
|
+
return { ...builtin };
|
|
28
|
+
return {
|
|
29
|
+
name: record.name,
|
|
30
|
+
displayName: record.display_name,
|
|
31
|
+
skillsDir: join(homedir(), `.${record.name}`),
|
|
32
|
+
command: record.command,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Build a per-role executor bundle from a registry snapshot. The
|
|
37
|
+
* `defaultExecutor` is what the pipeline already passes for the
|
|
38
|
+
* single-active-agent case (so role lookups that fall through to
|
|
39
|
+
* `fallback-active` resolve to the same executor).
|
|
40
|
+
*/
|
|
41
|
+
export function buildRoleExecutorBundle(input) {
|
|
42
|
+
const executors = new Map();
|
|
43
|
+
for (const record of input.agents) {
|
|
44
|
+
const agent = agentRecordToAgent(record);
|
|
45
|
+
executors.set(record.name, createLocalAgentExecutor(agent, input.executionProfile));
|
|
46
|
+
}
|
|
47
|
+
// Make sure the active / default executor is reachable by name
|
|
48
|
+
// even when the active agent isn't formally in the registry yet
|
|
49
|
+
// (e.g. legacy single-active setups during the 0.14 → 0.15 transition).
|
|
50
|
+
if (input.activeAgent && !executors.has(input.activeAgent.name)) {
|
|
51
|
+
executors.set(input.activeAgent.name, input.defaultExecutor);
|
|
52
|
+
}
|
|
53
|
+
const context = {
|
|
54
|
+
roleMap: input.roleMap,
|
|
55
|
+
agents: input.agents,
|
|
56
|
+
activeAgent: input.activeAgent,
|
|
57
|
+
};
|
|
58
|
+
return {
|
|
59
|
+
executors,
|
|
60
|
+
defaultExecutor: input.defaultExecutor,
|
|
61
|
+
context,
|
|
62
|
+
resolveExecutorForRole(role) {
|
|
63
|
+
const result = resolveAgentForRole(role, context);
|
|
64
|
+
if ("error" in result) {
|
|
65
|
+
// Role-router refused — fall back to the default executor and
|
|
66
|
+
// synthesize a `fallback-active` resolution. This keeps prepare
|
|
67
|
+
// runs alive when the registry is empty / mid-edit.
|
|
68
|
+
const synthetic = {
|
|
69
|
+
agent: input.activeAgent
|
|
70
|
+
?? {
|
|
71
|
+
name: input.defaultExecutor.name,
|
|
72
|
+
display_name: input.defaultExecutor.displayName,
|
|
73
|
+
command: input.defaultExecutor.command ?? input.defaultExecutor.name,
|
|
74
|
+
source: "user",
|
|
75
|
+
},
|
|
76
|
+
role,
|
|
77
|
+
source: "fallback-active",
|
|
78
|
+
};
|
|
79
|
+
return {
|
|
80
|
+
executor: input.defaultExecutor,
|
|
81
|
+
resolved: synthetic,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
const executor = executors.get(result.agent.name) ?? input.defaultExecutor;
|
|
85
|
+
return { executor, resolved: result };
|
|
86
|
+
},
|
|
87
|
+
};
|
|
88
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Role router — picks which connected agent runs a given stage role.
|
|
3
|
+
*
|
|
4
|
+
* The compile pipeline calls `resolveAgentForRole` for each agent-typed
|
|
5
|
+
* stage, passing the stage's declared role and the current registry +
|
|
6
|
+
* active agent. The verify pipeline always passes role `"verifier"`.
|
|
7
|
+
*
|
|
8
|
+
* Resolution priority (lean / explicit):
|
|
9
|
+
* 1. Explicit role-map entry for the requested role.
|
|
10
|
+
* 2. Role-map's `general` row (when the requested role isn't mapped).
|
|
11
|
+
* 3. The active agent (when `general` isn't mapped either).
|
|
12
|
+
*
|
|
13
|
+
* If the role-map points at an agent name that no longer exists in the
|
|
14
|
+
* merged agents list (e.g. user uninstalled it), we fall through to
|
|
15
|
+
* `general` then `activeAgent`. Only when ALL three are missing does the
|
|
16
|
+
* router return an error.
|
|
17
|
+
*/
|
|
18
|
+
import type { AgentRecord, RoleMap } from "../../contracts/lib/schema.js";
|
|
19
|
+
export type RoleResolutionSource = "explicit" | "fallback-general" | "fallback-active";
|
|
20
|
+
export interface ResolvedAgent {
|
|
21
|
+
agent: AgentRecord;
|
|
22
|
+
/** The role the caller asked for (kept for audit / logging). */
|
|
23
|
+
role: string;
|
|
24
|
+
/** Which fallback rung the agent came from. */
|
|
25
|
+
source: RoleResolutionSource;
|
|
26
|
+
}
|
|
27
|
+
export interface RoleResolutionContext {
|
|
28
|
+
roleMap: RoleMap;
|
|
29
|
+
agents: AgentRecord[];
|
|
30
|
+
/**
|
|
31
|
+
* The agent the role-map's `general` row points at — or, when no
|
|
32
|
+
* role-map exists yet, the first detected agent. Pass `null` when
|
|
33
|
+
* there is no agent available; the router then returns an error.
|
|
34
|
+
*/
|
|
35
|
+
activeAgent: AgentRecord | null;
|
|
36
|
+
}
|
|
37
|
+
export type RoleResolutionError = {
|
|
38
|
+
error: "no-agents";
|
|
39
|
+
detail: string;
|
|
40
|
+
} | {
|
|
41
|
+
error: "mapped-agent-missing";
|
|
42
|
+
detail: string;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Resolve a stage role to an agent + provenance trail. Returns
|
|
46
|
+
* `{ agent, role, source }` on success or `{ error, detail }` on
|
|
47
|
+
* failure.
|
|
48
|
+
*/
|
|
49
|
+
export declare function resolveAgentForRole(role: string, context: RoleResolutionContext): ResolvedAgent | RoleResolutionError;
|
|
50
|
+
/**
|
|
51
|
+
* Resolve every role declared by a Method's stages. Useful for
|
|
52
|
+
* pre-flight: returns either `{ resolutions }` (one entry per stage)
|
|
53
|
+
* or `{ error, role }` if any stage cannot resolve.
|
|
54
|
+
*/
|
|
55
|
+
export declare function resolveAgentsForStages(stages: ReadonlyArray<{
|
|
56
|
+
id: string;
|
|
57
|
+
role: string;
|
|
58
|
+
}>, context: RoleResolutionContext): {
|
|
59
|
+
resolutions: Array<{
|
|
60
|
+
stageId: string;
|
|
61
|
+
resolved: ResolvedAgent;
|
|
62
|
+
}>;
|
|
63
|
+
} | (RoleResolutionError & {
|
|
64
|
+
stageId: string;
|
|
65
|
+
role: string;
|
|
66
|
+
});
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolve a stage role to an agent + provenance trail. Returns
|
|
3
|
+
* `{ agent, role, source }` on success or `{ error, detail }` on
|
|
4
|
+
* failure.
|
|
5
|
+
*/
|
|
6
|
+
export function resolveAgentForRole(role, context) {
|
|
7
|
+
if (context.agents.length === 0) {
|
|
8
|
+
return {
|
|
9
|
+
error: "no-agents",
|
|
10
|
+
detail: "No agents are available. Install Claude Code, Codex, or another agent CLI, " +
|
|
11
|
+
"or register a custom CLI with `interf agents register`.",
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
const trimmedRole = role && role.trim().length > 0 ? role.trim() : "general";
|
|
15
|
+
// 1. Explicit role-map entry for the requested role.
|
|
16
|
+
const explicitName = context.roleMap[trimmedRole];
|
|
17
|
+
if (explicitName) {
|
|
18
|
+
const found = context.agents.find((agent) => agent.name === explicitName);
|
|
19
|
+
if (found) {
|
|
20
|
+
return { agent: found, role: trimmedRole, source: "explicit" };
|
|
21
|
+
}
|
|
22
|
+
// Map exists but points at a missing agent. Fall through to
|
|
23
|
+
// `general` and ultimately `activeAgent`. We do NOT return
|
|
24
|
+
// `mapped-agent-missing` here because the resolution priority
|
|
25
|
+
// explicitly allows fallback through `general` and active —
|
|
26
|
+
// returning an error would block a usable agent.
|
|
27
|
+
}
|
|
28
|
+
// 2. Role-map's `general` row, if the requested role isn't `general`.
|
|
29
|
+
if (trimmedRole !== "general") {
|
|
30
|
+
const generalName = context.roleMap["general"];
|
|
31
|
+
if (generalName) {
|
|
32
|
+
const found = context.agents.find((agent) => agent.name === generalName);
|
|
33
|
+
if (found) {
|
|
34
|
+
return { agent: found, role: trimmedRole, source: "fallback-general" };
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
// 3. Active agent.
|
|
39
|
+
if (context.activeAgent) {
|
|
40
|
+
return {
|
|
41
|
+
agent: context.activeAgent,
|
|
42
|
+
role: trimmedRole,
|
|
43
|
+
source: "fallback-active",
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
// Map points at an agent we cannot find AND there is no active fallback.
|
|
47
|
+
if (explicitName) {
|
|
48
|
+
return {
|
|
49
|
+
error: "mapped-agent-missing",
|
|
50
|
+
detail: `Role "${trimmedRole}" maps to agent "${explicitName}", which is not detected or registered.`,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
error: "no-agents",
|
|
55
|
+
detail: `No agent is mapped to role "${trimmedRole}" and no active agent fallback is available.`,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Resolve every role declared by a Method's stages. Useful for
|
|
60
|
+
* pre-flight: returns either `{ resolutions }` (one entry per stage)
|
|
61
|
+
* or `{ error, role }` if any stage cannot resolve.
|
|
62
|
+
*/
|
|
63
|
+
export function resolveAgentsForStages(stages, context) {
|
|
64
|
+
const resolutions = [];
|
|
65
|
+
for (const stage of stages) {
|
|
66
|
+
const result = resolveAgentForRole(stage.role, context);
|
|
67
|
+
if ("error" in result) {
|
|
68
|
+
return { ...result, stageId: stage.id, role: stage.role };
|
|
69
|
+
}
|
|
70
|
+
resolutions.push({ stageId: stage.id, resolved: result });
|
|
71
|
+
}
|
|
72
|
+
return { resolutions };
|
|
73
|
+
}
|