squadfoundry 0.1.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/AGENTS.md +76 -0
- package/PROJECT.md +79 -0
- package/README.md +255 -0
- package/dist/orchestrator/adapters/context/IContextAdapter.d.ts +65 -0
- package/dist/orchestrator/adapters/context/IContextAdapter.d.ts.map +1 -0
- package/dist/orchestrator/adapters/context/IContextAdapter.js +12 -0
- package/dist/orchestrator/adapters/context/IContextAdapter.js.map +1 -0
- package/dist/orchestrator/adapters/context/filesystem.context-adapter.d.ts +33 -0
- package/dist/orchestrator/adapters/context/filesystem.context-adapter.d.ts.map +1 -0
- package/dist/orchestrator/adapters/context/filesystem.context-adapter.js +179 -0
- package/dist/orchestrator/adapters/context/filesystem.context-adapter.js.map +1 -0
- package/dist/orchestrator/adapters/deploy/IDeployAdapter.d.ts +78 -0
- package/dist/orchestrator/adapters/deploy/IDeployAdapter.d.ts.map +1 -0
- package/dist/orchestrator/adapters/deploy/IDeployAdapter.js +14 -0
- package/dist/orchestrator/adapters/deploy/IDeployAdapter.js.map +1 -0
- package/dist/orchestrator/adapters/deploy/vercel.adapter.d.ts +31 -0
- package/dist/orchestrator/adapters/deploy/vercel.adapter.d.ts.map +1 -0
- package/dist/orchestrator/adapters/deploy/vercel.adapter.js +83 -0
- package/dist/orchestrator/adapters/deploy/vercel.adapter.js.map +1 -0
- package/dist/orchestrator/adapters/host/IHostAdapter.d.ts +89 -0
- package/dist/orchestrator/adapters/host/IHostAdapter.d.ts.map +1 -0
- package/dist/orchestrator/adapters/host/IHostAdapter.js +10 -0
- package/dist/orchestrator/adapters/host/IHostAdapter.js.map +1 -0
- package/dist/orchestrator/adapters/host/anthropic.adapter.d.ts +27 -0
- package/dist/orchestrator/adapters/host/anthropic.adapter.d.ts.map +1 -0
- package/dist/orchestrator/adapters/host/anthropic.adapter.js +118 -0
- package/dist/orchestrator/adapters/host/anthropic.adapter.js.map +1 -0
- package/dist/orchestrator/adapters/host/antigravity.adapter.d.ts +53 -0
- package/dist/orchestrator/adapters/host/antigravity.adapter.d.ts.map +1 -0
- package/dist/orchestrator/adapters/host/antigravity.adapter.js +148 -0
- package/dist/orchestrator/adapters/host/antigravity.adapter.js.map +1 -0
- package/dist/orchestrator/adapters/host/claude-code.adapter.d.ts +13 -0
- package/dist/orchestrator/adapters/host/claude-code.adapter.d.ts.map +1 -0
- package/dist/orchestrator/adapters/host/claude-code.adapter.js +27 -0
- package/dist/orchestrator/adapters/host/claude-code.adapter.js.map +1 -0
- package/dist/orchestrator/adapters/host/command-model-invoker.d.ts +8 -0
- package/dist/orchestrator/adapters/host/command-model-invoker.d.ts.map +1 -0
- package/dist/orchestrator/adapters/host/command-model-invoker.js +46 -0
- package/dist/orchestrator/adapters/host/command-model-invoker.js.map +1 -0
- package/dist/orchestrator/adapters/host/ide.adapter.d.ts +61 -0
- package/dist/orchestrator/adapters/host/ide.adapter.d.ts.map +1 -0
- package/dist/orchestrator/adapters/host/ide.adapter.js +173 -0
- package/dist/orchestrator/adapters/host/ide.adapter.js.map +1 -0
- package/dist/orchestrator/adapters/host/local.adapter.d.ts +26 -0
- package/dist/orchestrator/adapters/host/local.adapter.d.ts.map +1 -0
- package/dist/orchestrator/adapters/host/local.adapter.js +82 -0
- package/dist/orchestrator/adapters/host/local.adapter.js.map +1 -0
- package/dist/orchestrator/adapters/host/openai.adapter.d.ts +26 -0
- package/dist/orchestrator/adapters/host/openai.adapter.d.ts.map +1 -0
- package/dist/orchestrator/adapters/host/openai.adapter.js +77 -0
- package/dist/orchestrator/adapters/host/openai.adapter.js.map +1 -0
- package/dist/orchestrator/adapters/host/opencode.adapter.d.ts +13 -0
- package/dist/orchestrator/adapters/host/opencode.adapter.d.ts.map +1 -0
- package/dist/orchestrator/adapters/host/opencode.adapter.js +27 -0
- package/dist/orchestrator/adapters/host/opencode.adapter.js.map +1 -0
- package/dist/orchestrator/adapters/model/IModelAdapter.d.ts +68 -0
- package/dist/orchestrator/adapters/model/IModelAdapter.d.ts.map +1 -0
- package/dist/orchestrator/adapters/model/IModelAdapter.js +11 -0
- package/dist/orchestrator/adapters/model/IModelAdapter.js.map +1 -0
- package/dist/orchestrator/adapters/publishing/ISocialMediaAdapter.d.ts +93 -0
- package/dist/orchestrator/adapters/publishing/ISocialMediaAdapter.d.ts.map +1 -0
- package/dist/orchestrator/adapters/publishing/ISocialMediaAdapter.js +10 -0
- package/dist/orchestrator/adapters/publishing/ISocialMediaAdapter.js.map +1 -0
- package/dist/orchestrator/adapters/publishing/instagram.adapter.d.ts +34 -0
- package/dist/orchestrator/adapters/publishing/instagram.adapter.d.ts.map +1 -0
- package/dist/orchestrator/adapters/publishing/instagram.adapter.js +105 -0
- package/dist/orchestrator/adapters/publishing/instagram.adapter.js.map +1 -0
- package/dist/orchestrator/adapters/tools/IToolAdapter.d.ts +52 -0
- package/dist/orchestrator/adapters/tools/IToolAdapter.d.ts.map +1 -0
- package/dist/orchestrator/adapters/tools/IToolAdapter.js +10 -0
- package/dist/orchestrator/adapters/tools/IToolAdapter.js.map +1 -0
- package/dist/orchestrator/adapters/vcs/IVCSAdapter.d.ts +89 -0
- package/dist/orchestrator/adapters/vcs/IVCSAdapter.d.ts.map +1 -0
- package/dist/orchestrator/adapters/vcs/IVCSAdapter.js +11 -0
- package/dist/orchestrator/adapters/vcs/IVCSAdapter.js.map +1 -0
- package/dist/orchestrator/adapters/vcs/github.adapter.d.ts +36 -0
- package/dist/orchestrator/adapters/vcs/github.adapter.d.ts.map +1 -0
- package/dist/orchestrator/adapters/vcs/github.adapter.js +110 -0
- package/dist/orchestrator/adapters/vcs/github.adapter.js.map +1 -0
- package/dist/orchestrator/artifacts/artifact-store.d.ts +47 -0
- package/dist/orchestrator/artifacts/artifact-store.d.ts.map +1 -0
- package/dist/orchestrator/artifacts/artifact-store.js +135 -0
- package/dist/orchestrator/artifacts/artifact-store.js.map +1 -0
- package/dist/orchestrator/builder/domain-classifier.d.ts +24 -0
- package/dist/orchestrator/builder/domain-classifier.d.ts.map +1 -0
- package/dist/orchestrator/builder/domain-classifier.js +156 -0
- package/dist/orchestrator/builder/domain-classifier.js.map +1 -0
- package/dist/orchestrator/builder/interview-questions.d.ts +13 -0
- package/dist/orchestrator/builder/interview-questions.d.ts.map +1 -0
- package/dist/orchestrator/builder/interview-questions.js +127 -0
- package/dist/orchestrator/builder/interview-questions.js.map +1 -0
- package/dist/orchestrator/builder/squad-builder.d.ts +53 -0
- package/dist/orchestrator/builder/squad-builder.d.ts.map +1 -0
- package/dist/orchestrator/builder/squad-builder.js +107 -0
- package/dist/orchestrator/builder/squad-builder.js.map +1 -0
- package/dist/orchestrator/builder/squad-generator.d.ts +33 -0
- package/dist/orchestrator/builder/squad-generator.d.ts.map +1 -0
- package/dist/orchestrator/builder/squad-generator.js +360 -0
- package/dist/orchestrator/builder/squad-generator.js.map +1 -0
- package/dist/orchestrator/cli/index.d.ts +3 -0
- package/dist/orchestrator/cli/index.d.ts.map +1 -0
- package/dist/orchestrator/cli/index.js +8 -0
- package/dist/orchestrator/cli/index.js.map +1 -0
- package/dist/orchestrator/context/context-index.d.ts +48 -0
- package/dist/orchestrator/context/context-index.d.ts.map +1 -0
- package/dist/orchestrator/context/context-index.js +116 -0
- package/dist/orchestrator/context/context-index.js.map +1 -0
- package/dist/orchestrator/context/context-loader.d.ts +49 -0
- package/dist/orchestrator/context/context-loader.d.ts.map +1 -0
- package/dist/orchestrator/context/context-loader.js +111 -0
- package/dist/orchestrator/context/context-loader.js.map +1 -0
- package/dist/orchestrator/core/guardrails.d.ts +33 -0
- package/dist/orchestrator/core/guardrails.d.ts.map +1 -0
- package/dist/orchestrator/core/guardrails.js +272 -0
- package/dist/orchestrator/core/guardrails.js.map +1 -0
- package/dist/orchestrator/core/state-machine.d.ts +65 -0
- package/dist/orchestrator/core/state-machine.d.ts.map +1 -0
- package/dist/orchestrator/core/state-machine.js +227 -0
- package/dist/orchestrator/core/state-machine.js.map +1 -0
- package/dist/orchestrator/core/types.d.ts +364 -0
- package/dist/orchestrator/core/types.d.ts.map +1 -0
- package/dist/orchestrator/core/types.js +10 -0
- package/dist/orchestrator/core/types.js.map +1 -0
- package/dist/orchestrator/index.d.ts +75 -0
- package/dist/orchestrator/index.d.ts.map +1 -0
- package/dist/orchestrator/index.js +64 -0
- package/dist/orchestrator/index.js.map +1 -0
- package/dist/orchestrator/mcp/server.d.ts +35 -0
- package/dist/orchestrator/mcp/server.d.ts.map +1 -0
- package/dist/orchestrator/mcp/server.js +378 -0
- package/dist/orchestrator/mcp/server.js.map +1 -0
- package/dist/orchestrator/runtime/agent-dispatcher.d.ts +25 -0
- package/dist/orchestrator/runtime/agent-dispatcher.d.ts.map +1 -0
- package/dist/orchestrator/runtime/agent-dispatcher.js +82 -0
- package/dist/orchestrator/runtime/agent-dispatcher.js.map +1 -0
- package/dist/orchestrator/runtime/approval-gate.d.ts +55 -0
- package/dist/orchestrator/runtime/approval-gate.d.ts.map +1 -0
- package/dist/orchestrator/runtime/approval-gate.js +104 -0
- package/dist/orchestrator/runtime/approval-gate.js.map +1 -0
- package/dist/orchestrator/runtime/handoff-manager.d.ts +29 -0
- package/dist/orchestrator/runtime/handoff-manager.d.ts.map +1 -0
- package/dist/orchestrator/runtime/handoff-manager.js +80 -0
- package/dist/orchestrator/runtime/handoff-manager.js.map +1 -0
- package/dist/orchestrator/runtime/job-manager.d.ts +39 -0
- package/dist/orchestrator/runtime/job-manager.d.ts.map +1 -0
- package/dist/orchestrator/runtime/job-manager.js +132 -0
- package/dist/orchestrator/runtime/job-manager.js.map +1 -0
- package/dist/orchestrator/runtime/squad-runtime.d.ts +70 -0
- package/dist/orchestrator/runtime/squad-runtime.d.ts.map +1 -0
- package/dist/orchestrator/runtime/squad-runtime.js +249 -0
- package/dist/orchestrator/runtime/squad-runtime.js.map +1 -0
- package/dist/orchestrator/shell/cli.d.ts +4 -0
- package/dist/orchestrator/shell/cli.d.ts.map +1 -0
- package/dist/orchestrator/shell/cli.js +27 -0
- package/dist/orchestrator/shell/cli.js.map +1 -0
- package/dist/orchestrator/shell/commands/create.command.d.ts +3 -0
- package/dist/orchestrator/shell/commands/create.command.d.ts.map +1 -0
- package/dist/orchestrator/shell/commands/create.command.js +41 -0
- package/dist/orchestrator/shell/commands/create.command.js.map +1 -0
- package/dist/orchestrator/shell/commands/edit.command.d.ts +3 -0
- package/dist/orchestrator/shell/commands/edit.command.d.ts.map +1 -0
- package/dist/orchestrator/shell/commands/edit.command.js +49 -0
- package/dist/orchestrator/shell/commands/edit.command.js.map +1 -0
- package/dist/orchestrator/shell/commands/hosts.command.d.ts +3 -0
- package/dist/orchestrator/shell/commands/hosts.command.d.ts.map +1 -0
- package/dist/orchestrator/shell/commands/hosts.command.js +27 -0
- package/dist/orchestrator/shell/commands/hosts.command.js.map +1 -0
- package/dist/orchestrator/shell/commands/init.command.d.ts +3 -0
- package/dist/orchestrator/shell/commands/init.command.d.ts.map +1 -0
- package/dist/orchestrator/shell/commands/init.command.js +13 -0
- package/dist/orchestrator/shell/commands/init.command.js.map +1 -0
- package/dist/orchestrator/shell/commands/list.command.d.ts +3 -0
- package/dist/orchestrator/shell/commands/list.command.d.ts.map +1 -0
- package/dist/orchestrator/shell/commands/list.command.js +18 -0
- package/dist/orchestrator/shell/commands/list.command.js.map +1 -0
- package/dist/orchestrator/shell/commands/run.command.d.ts +3 -0
- package/dist/orchestrator/shell/commands/run.command.d.ts.map +1 -0
- package/dist/orchestrator/shell/commands/run.command.js +71 -0
- package/dist/orchestrator/shell/commands/run.command.js.map +1 -0
- package/dist/orchestrator/shell/commands/status.command.d.ts +3 -0
- package/dist/orchestrator/shell/commands/status.command.d.ts.map +1 -0
- package/dist/orchestrator/shell/commands/status.command.js +29 -0
- package/dist/orchestrator/shell/commands/status.command.js.map +1 -0
- package/dist/orchestrator/shell/services/active-host-detector.service.d.ts +25 -0
- package/dist/orchestrator/shell/services/active-host-detector.service.d.ts.map +1 -0
- package/dist/orchestrator/shell/services/active-host-detector.service.js +128 -0
- package/dist/orchestrator/shell/services/active-host-detector.service.js.map +1 -0
- package/dist/orchestrator/shell/services/host-resolution.service.d.ts +42 -0
- package/dist/orchestrator/shell/services/host-resolution.service.d.ts.map +1 -0
- package/dist/orchestrator/shell/services/host-resolution.service.js +108 -0
- package/dist/orchestrator/shell/services/host-resolution.service.js.map +1 -0
- package/dist/orchestrator/shell/services/host-runtime.service.d.ts +23 -0
- package/dist/orchestrator/shell/services/host-runtime.service.d.ts.map +1 -0
- package/dist/orchestrator/shell/services/host-runtime.service.js +167 -0
- package/dist/orchestrator/shell/services/host-runtime.service.js.map +1 -0
- package/dist/orchestrator/shell/services/interview-host-bridge.service.d.ts +14 -0
- package/dist/orchestrator/shell/services/interview-host-bridge.service.d.ts.map +1 -0
- package/dist/orchestrator/shell/services/interview-host-bridge.service.js +16 -0
- package/dist/orchestrator/shell/services/interview-host-bridge.service.js.map +1 -0
- package/dist/orchestrator/shell/services/job-execution.service.d.ts +22 -0
- package/dist/orchestrator/shell/services/job-execution.service.d.ts.map +1 -0
- package/dist/orchestrator/shell/services/job-execution.service.js +39 -0
- package/dist/orchestrator/shell/services/job-execution.service.js.map +1 -0
- package/dist/orchestrator/shell/services/project-bootstrap.service.d.ts +6 -0
- package/dist/orchestrator/shell/services/project-bootstrap.service.d.ts.map +1 -0
- package/dist/orchestrator/shell/services/project-bootstrap.service.js +111 -0
- package/dist/orchestrator/shell/services/project-bootstrap.service.js.map +1 -0
- package/dist/orchestrator/shell/services/squad-scaffold.service.d.ts +3 -0
- package/dist/orchestrator/shell/services/squad-scaffold.service.d.ts.map +1 -0
- package/dist/orchestrator/shell/services/squad-scaffold.service.js +30 -0
- package/dist/orchestrator/shell/services/squad-scaffold.service.js.map +1 -0
- package/dist/tests/integration/instagram-squad.test.d.ts +8 -0
- package/dist/tests/integration/instagram-squad.test.d.ts.map +1 -0
- package/dist/tests/integration/instagram-squad.test.js +187 -0
- package/dist/tests/integration/instagram-squad.test.js.map +1 -0
- package/dist/tests/integration/shell/cli-run-host-native.test.d.ts +2 -0
- package/dist/tests/integration/shell/cli-run-host-native.test.d.ts.map +1 -0
- package/dist/tests/integration/shell/cli-run-host-native.test.js +42 -0
- package/dist/tests/integration/shell/cli-run-host-native.test.js.map +1 -0
- package/dist/tests/integration/software-squad.test.d.ts +8 -0
- package/dist/tests/integration/software-squad.test.d.ts.map +1 -0
- package/dist/tests/integration/software-squad.test.js +207 -0
- package/dist/tests/integration/software-squad.test.js.map +1 -0
- package/dist/tests/unit/artifact-store.test.d.ts +2 -0
- package/dist/tests/unit/artifact-store.test.d.ts.map +1 -0
- package/dist/tests/unit/artifact-store.test.js +137 -0
- package/dist/tests/unit/artifact-store.test.js.map +1 -0
- package/dist/tests/unit/context-loader.test.d.ts +2 -0
- package/dist/tests/unit/context-loader.test.d.ts.map +1 -0
- package/dist/tests/unit/context-loader.test.js +109 -0
- package/dist/tests/unit/context-loader.test.js.map +1 -0
- package/dist/tests/unit/docs/host-native-docs.test.d.ts +2 -0
- package/dist/tests/unit/docs/host-native-docs.test.d.ts.map +1 -0
- package/dist/tests/unit/docs/host-native-docs.test.js +18 -0
- package/dist/tests/unit/docs/host-native-docs.test.js.map +1 -0
- package/dist/tests/unit/guardrails.test.d.ts +2 -0
- package/dist/tests/unit/guardrails.test.d.ts.map +1 -0
- package/dist/tests/unit/guardrails.test.js +202 -0
- package/dist/tests/unit/guardrails.test.js.map +1 -0
- package/dist/tests/unit/host/host-adapter-contract.test.d.ts +2 -0
- package/dist/tests/unit/host/host-adapter-contract.test.d.ts.map +1 -0
- package/dist/tests/unit/host/host-adapter-contract.test.js +53 -0
- package/dist/tests/unit/host/host-adapter-contract.test.js.map +1 -0
- package/dist/tests/unit/host/ide.adapter.test.d.ts +2 -0
- package/dist/tests/unit/host/ide.adapter.test.d.ts.map +1 -0
- package/dist/tests/unit/host/ide.adapter.test.js +17 -0
- package/dist/tests/unit/host/ide.adapter.test.js.map +1 -0
- package/dist/tests/unit/host/native-ide-adapters.test.d.ts +2 -0
- package/dist/tests/unit/host/native-ide-adapters.test.d.ts.map +1 -0
- package/dist/tests/unit/host/native-ide-adapters.test.js +26 -0
- package/dist/tests/unit/host/native-ide-adapters.test.js.map +1 -0
- package/dist/tests/unit/runtime/squad-runtime-host-metadata.test.d.ts +2 -0
- package/dist/tests/unit/runtime/squad-runtime-host-metadata.test.d.ts.map +1 -0
- package/dist/tests/unit/runtime/squad-runtime-host-metadata.test.js +128 -0
- package/dist/tests/unit/runtime/squad-runtime-host-metadata.test.js.map +1 -0
- package/dist/tests/unit/shell/active-host-detector.test.d.ts +2 -0
- package/dist/tests/unit/shell/active-host-detector.test.d.ts.map +1 -0
- package/dist/tests/unit/shell/active-host-detector.test.js +85 -0
- package/dist/tests/unit/shell/active-host-detector.test.js.map +1 -0
- package/dist/tests/unit/shell/host-resolution.service.test.d.ts +2 -0
- package/dist/tests/unit/shell/host-resolution.service.test.d.ts.map +1 -0
- package/dist/tests/unit/shell/host-resolution.service.test.js +252 -0
- package/dist/tests/unit/shell/host-resolution.service.test.js.map +1 -0
- package/dist/tests/unit/shell/interview-host-bridge.test.d.ts +2 -0
- package/dist/tests/unit/shell/interview-host-bridge.test.d.ts.map +1 -0
- package/dist/tests/unit/shell/interview-host-bridge.test.js +58 -0
- package/dist/tests/unit/shell/interview-host-bridge.test.js.map +1 -0
- package/dist/tests/unit/shell/project-bootstrap.service.test.d.ts +2 -0
- package/dist/tests/unit/shell/project-bootstrap.service.test.d.ts.map +1 -0
- package/dist/tests/unit/shell/project-bootstrap.service.test.js +58 -0
- package/dist/tests/unit/shell/project-bootstrap.service.test.js.map +1 -0
- package/dist/tests/unit/shell/squad-scaffold.service.test.d.ts +2 -0
- package/dist/tests/unit/shell/squad-scaffold.service.test.d.ts.map +1 -0
- package/dist/tests/unit/shell/squad-scaffold.service.test.js +40 -0
- package/dist/tests/unit/shell/squad-scaffold.service.test.js.map +1 -0
- package/dist/tests/unit/squad-builder.test.d.ts +2 -0
- package/dist/tests/unit/squad-builder.test.d.ts.map +1 -0
- package/dist/tests/unit/squad-builder.test.js +126 -0
- package/dist/tests/unit/squad-builder.test.js.map +1 -0
- package/dist/tests/unit/state-machine.test.d.ts +2 -0
- package/dist/tests/unit/state-machine.test.d.ts.map +1 -0
- package/dist/tests/unit/state-machine.test.js +133 -0
- package/dist/tests/unit/state-machine.test.js.map +1 -0
- package/docs/architecture/overview.md +115 -0
- package/docs/development/adding-agents.md +75 -0
- package/docs/development/adding-hosts.md +104 -0
- package/docs/development/adding-integrations.md +83 -0
- package/docs/development/host-detection-and-resolution.md +59 -0
- package/docs/squads/how-to-create.md +85 -0
- package/docs/squads/how-to-execute.md +139 -0
- package/docs/superpowers/plans/2026-04-01-host-native-cli-shell-implementation.md +617 -0
- package/docs/superpowers/specs/2026-04-01-host-native-cli-shell-design.md +253 -0
- package/package.json +103 -0
- package/squads/examples/instagram-content/AGENTS.md +63 -0
- package/squads/examples/instagram-content/POLICIES.md +45 -0
- package/squads/examples/instagram-content/SQUAD.md +63 -0
- package/squads/examples/instagram-content/WORKFLOW.md +58 -0
- package/squads/examples/instagram-content/config/squad.json +474 -0
- package/squads/examples/software-development/AGENTS.md +88 -0
- package/squads/examples/software-development/POLICIES.md +44 -0
- package/squads/examples/software-development/SQUAD.md +65 -0
- package/squads/examples/software-development/WORKFLOW.md +78 -0
- package/squads/examples/software-development/config/squad.json +442 -0
- package/templates/AGENTS.md +46 -0
- package/templates/POLICIES.md +24 -0
- package/templates/PROJECT.md +52 -0
- package/templates/SQUAD.md +52 -0
- package/templates/TASKS.md +31 -0
- package/templates/WORKFLOW.md +35 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { resolve } from 'node:path';
|
|
2
|
+
import { pathToFileURL } from 'node:url';
|
|
3
|
+
import { JobExecutionService } from '../services/job-execution.service.js';
|
|
4
|
+
import { resolveSquadConfigPath } from '../services/squad-scaffold.service.js';
|
|
5
|
+
function isSquadDefinition(value) {
|
|
6
|
+
if (!value || typeof value !== 'object')
|
|
7
|
+
return false;
|
|
8
|
+
const obj = value;
|
|
9
|
+
if (typeof obj['id'] !== 'string' || typeof obj['name'] !== 'string')
|
|
10
|
+
return false;
|
|
11
|
+
if (!Array.isArray(obj['agents']) || obj['agents'].length === 0)
|
|
12
|
+
return false;
|
|
13
|
+
const hasValidAgents = obj['agents'].every((agent) => {
|
|
14
|
+
if (!agent || typeof agent !== 'object')
|
|
15
|
+
return false;
|
|
16
|
+
const a = agent;
|
|
17
|
+
return typeof a['id'] === 'string'
|
|
18
|
+
&& typeof a['name'] === 'string'
|
|
19
|
+
&& typeof a['instructions'] === 'string'
|
|
20
|
+
&& Array.isArray(a['allowedStates']);
|
|
21
|
+
});
|
|
22
|
+
if (!hasValidAgents)
|
|
23
|
+
return false;
|
|
24
|
+
if (!obj['workflow'] || typeof obj['workflow'] !== 'object')
|
|
25
|
+
return false;
|
|
26
|
+
const workflow = obj['workflow'];
|
|
27
|
+
if (!Array.isArray(workflow['steps']) || workflow['steps'].length === 0)
|
|
28
|
+
return false;
|
|
29
|
+
const hasValidSteps = workflow['steps'].every((step) => {
|
|
30
|
+
if (!step || typeof step !== 'object')
|
|
31
|
+
return false;
|
|
32
|
+
const s = step;
|
|
33
|
+
return typeof s['id'] === 'string'
|
|
34
|
+
&& typeof s['agentId'] === 'string'
|
|
35
|
+
&& typeof s['name'] === 'string'
|
|
36
|
+
&& typeof s['type'] === 'string';
|
|
37
|
+
});
|
|
38
|
+
return hasValidSteps;
|
|
39
|
+
}
|
|
40
|
+
export function registerRun(program) {
|
|
41
|
+
program
|
|
42
|
+
.command('run <squad_id>')
|
|
43
|
+
.description('Execute a job for an existing squad')
|
|
44
|
+
.option('--input <text>', 'Initial input / task description', '')
|
|
45
|
+
.option('--objective <text>', 'Job objective', 'Execute squad workflow')
|
|
46
|
+
.option('--cwd <path>', 'Context root path', process.cwd())
|
|
47
|
+
.option('--artifacts <path>', 'Artifacts directory', 'artifacts')
|
|
48
|
+
.action(async (squadId, opts) => {
|
|
49
|
+
const squadConfigPath = resolveSquadConfigPath(opts.cwd, squadId);
|
|
50
|
+
if (!squadConfigPath) {
|
|
51
|
+
throw new Error(`[Error] Squad not found for id '${squadId}' in squads/ or squads/examples/.`);
|
|
52
|
+
}
|
|
53
|
+
const squadConfigUrl = pathToFileURL(resolve(squadConfigPath)).href;
|
|
54
|
+
const { default: squadJson } = await import(squadConfigUrl, { with: { type: 'json' } });
|
|
55
|
+
if (!isSquadDefinition(squadJson)) {
|
|
56
|
+
throw new Error(`[Error] Invalid squad definition: ${squadConfigPath}`);
|
|
57
|
+
}
|
|
58
|
+
const squad = squadJson;
|
|
59
|
+
const execution = new JobExecutionService();
|
|
60
|
+
const result = await execution.runSquad({
|
|
61
|
+
cwd: opts.cwd,
|
|
62
|
+
artifactsDir: opts.artifacts,
|
|
63
|
+
squad,
|
|
64
|
+
objective: opts.objective,
|
|
65
|
+
input: opts.input,
|
|
66
|
+
});
|
|
67
|
+
console.log(`[Squad Foundry] Job ${result.jobId} finished with status: ${result.status}`);
|
|
68
|
+
console.log(`[Squad Foundry] Host: ${result.resolvedHost} | Model: ${result.activeModel} | Path: ${result.fallbackPath}`);
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=run.command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run.command.js","sourceRoot":"","sources":["../../../../orchestrator/shell/commands/run.command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAGxC,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAA;AAC1E,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAA;AAS9E,SAAS,iBAAiB,CAAC,KAAc;IACvC,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAA;IACrD,MAAM,GAAG,GAAG,KAAgC,CAA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C,iBAAiB,CAAC,SAAS,CAAC,EAAE,CAAC;YAClC,MAAM,IAAI,KAAK,CAAC,qCAAqC,eAAe,EAAE,CAAC,CAAA;QACzE,CAAC;QACD,MAAM,KAAK,GAAG,SAAS,CAAA;QAEvB,MAAM,SAAS,GAAG,IAAI,mBAAmB,EAAE,CAAA;QAC3C,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,QAAQ,CAAC;YACtC,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,YAAY,EAAE,IAAI,CAAC,SAAS;YAC5B,KAAK;YACL,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,KAAK,EAAE,IAAI,CAAC,KAAK;SAClB,CAAC,CAAA;QAEF,OAAO,CAAC,GAAG,CAAC,uBAAuB,MAAM,CAAC,KAAK,0BAA0B,MAAM,CAAC,MAAM,EAAE,CAAC,CAAA;QACzF,OAAO,CAAC,GAAG,CAAC,yBAAyB,MAAM,CAAC,YAAY,aAAa,MAAM,CAAC,WAAW,YAAY,MAAM,CAAC,YAAY,EAAE,CAAC,CAAA;IAC3H,CAAC,CAAC,CAAA;AACN,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status.command.d.ts","sourceRoot":"","sources":["../../../../orchestrator/shell/commands/status.command.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAUxC,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CA2BrD"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { createArtifactStore } from '../../artifacts/artifact-store.js';
|
|
4
|
+
export function registerStatus(program) {
|
|
5
|
+
program
|
|
6
|
+
.command('status <squad_id> <job_id>')
|
|
7
|
+
.description('Show the current status of a job')
|
|
8
|
+
.option('--artifacts <path>', 'Artifacts directory', 'artifacts')
|
|
9
|
+
.action((squadId, jobId, opts) => {
|
|
10
|
+
const store = createArtifactStore(opts.artifacts);
|
|
11
|
+
const job = store.loadJob(squadId, jobId);
|
|
12
|
+
if (!job) {
|
|
13
|
+
throw new Error(`Job not found: ${squadId}/${jobId}`);
|
|
14
|
+
}
|
|
15
|
+
console.log(`Job: ${job.id}`);
|
|
16
|
+
console.log(`Squad: ${job.squadId}`);
|
|
17
|
+
console.log(`Status: ${job.status}`);
|
|
18
|
+
const metadataPath = join(opts.artifacts, squadId, job.id, 'reports', 'runtime-metadata.json');
|
|
19
|
+
if (existsSync(metadataPath)) {
|
|
20
|
+
const metadata = JSON.parse(readFileSync(metadataPath, 'utf-8'));
|
|
21
|
+
console.log(`resolvedHost: ${String(metadata['resolvedHost'] ?? 'unknown')}`);
|
|
22
|
+
console.log(`confidence: ${String(metadata['confidence'] ?? 'unknown')}`);
|
|
23
|
+
console.log(`reasons: ${JSON.stringify(metadata['reasons'] ?? [])}`);
|
|
24
|
+
console.log(`activeModel: ${String(metadata['activeModel'] ?? 'host-default')}`);
|
|
25
|
+
console.log(`fallbackPath: ${String(metadata['fallbackPath'] ?? 'unknown')}`);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=status.command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status.command.js","sourceRoot":"","sources":["../../../../orchestrator/shell/commands/status.command.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAA;AAMvE,MAAM,UAAU,cAAc,CAAC,OAAgB;IAC7C,OAAO;SACJ,OAAO,CAAC,4BAA4B,CAAC;SACrC,WAAW,CAAC,kCAAkC,CAAC;SAC/C,MAAM,CAAC,oBAAoB,EAAE,qBAAqB,EAAE,WAAW,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AAC,QAAQ,CAAC,aAAa,CAAC,IAAI,cAAc,CAAC,EAAE,CAAC,CAAA;YAChF,OAAO,CAAC,GAAG,CAAC,iBAAiB,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAC,IAAI,SAAS,CAAC,EAAE,CAAC,CAAA;QAC/E,CAAC;IACH,CAAC,CAAC,CAAA;AACN,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export type SignalStrength = 'strong' | 'medium' | 'weak';
|
|
2
|
+
export type DetectionConfidence = 'high' | 'medium' | 'low';
|
|
3
|
+
export type HostDetectionSignal = {
|
|
4
|
+
hostId: string;
|
|
5
|
+
strength: SignalStrength;
|
|
6
|
+
key: string;
|
|
7
|
+
reason: string;
|
|
8
|
+
};
|
|
9
|
+
export type ActiveHostDetectionInput = {
|
|
10
|
+
cwd: string;
|
|
11
|
+
argv?: string[];
|
|
12
|
+
env?: Record<string, string | undefined>;
|
|
13
|
+
processHints?: string[];
|
|
14
|
+
};
|
|
15
|
+
export type ActiveHostDetectionResult = {
|
|
16
|
+
detectedHostId: string | null;
|
|
17
|
+
confidence: DetectionConfidence;
|
|
18
|
+
reasons: string[];
|
|
19
|
+
scores: Record<string, number>;
|
|
20
|
+
signals: HostDetectionSignal[];
|
|
21
|
+
};
|
|
22
|
+
export declare class ActiveHostDetector {
|
|
23
|
+
detect(input: ActiveHostDetectionInput): Promise<ActiveHostDetectionResult>;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=active-host-detector.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"active-host-detector.service.d.ts","sourceRoot":"","sources":["../../../../orchestrator/shell/services/active-host-detector.service.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,QAAQ,GAAG,MAAM,CAAA;AACzD,MAAM,MAAM,mBAAmB,GAAG,MAAM,GAAG,QAAQ,GAAG,KAAK,CAAA;AAE3D,MAAM,MAAM,mBAAmB,GAAG;IAChC,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,cAAc,CAAA;IACxB,GAAG,EAAE,MAAM,CAAA;IACX,MAAM,EAAE,MAAM,CAAA;CACf,CAAA;AAED,MAAM,MAAM,wBAAwB,GAAG;IACrC,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;IACf,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAA;IACxC,YAAY,CAAC,EAAE,MAAM,EAAE,CAAA;CACxB,CAAA;AAED,MAAM,MAAM,yBAAyB,GAAG;IACtC,cAAc,EAAE,MAAM,GAAG,IAAI,CAAA;IAC7B,UAAU,EAAE,mBAAmB,CAAA;IAC/B,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC9B,OAAO,EAAE,mBAAmB,EAAE,CAAA;CAC/B,CAAA;AA0CD,qBAAa,kBAAkB;IACvB,MAAM,CAAC,KAAK,EAAE,wBAAwB,GAAG,OAAO,CAAC,yBAAyB,CAAC;CA0GlF"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { access } from 'node:fs/promises';
|
|
2
|
+
import { basename, join } from 'node:path';
|
|
3
|
+
const SIGNAL_WEIGHTS = {
|
|
4
|
+
strong: 100,
|
|
5
|
+
medium: 30,
|
|
6
|
+
weak: 10,
|
|
7
|
+
};
|
|
8
|
+
const HOST_PROFILES = [
|
|
9
|
+
{
|
|
10
|
+
id: 'claude-code',
|
|
11
|
+
strongArgvTokens: ['claude', 'claude-code'],
|
|
12
|
+
mediumFiles: ['CLAUDE.md', '.claude/settings.json'],
|
|
13
|
+
weakEnvVars: ['CLAUDECODE', 'CLAUDE_CODE'],
|
|
14
|
+
weakProcessTokens: ['claude'],
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
id: 'opencode',
|
|
18
|
+
strongArgvTokens: ['opencode'],
|
|
19
|
+
mediumFiles: ['OPENCODE.md', '.opencode/config.json'],
|
|
20
|
+
weakEnvVars: ['OPENCODE'],
|
|
21
|
+
weakProcessTokens: ['opencode'],
|
|
22
|
+
},
|
|
23
|
+
];
|
|
24
|
+
async function pathExists(path) {
|
|
25
|
+
try {
|
|
26
|
+
await access(path);
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
export class ActiveHostDetector {
|
|
34
|
+
async detect(input) {
|
|
35
|
+
const argv = (input.argv ?? process.argv).map((value) => value.toLowerCase());
|
|
36
|
+
const normalizedArgv = new Set();
|
|
37
|
+
for (const value of argv) {
|
|
38
|
+
normalizedArgv.add(value);
|
|
39
|
+
const baseName = basename(value).replace(/\.(exe|cmd|bat)$/i, '');
|
|
40
|
+
normalizedArgv.add(baseName);
|
|
41
|
+
}
|
|
42
|
+
const processHints = (input.processHints ?? []).map((value) => value.toLowerCase());
|
|
43
|
+
const env = input.env ?? process.env;
|
|
44
|
+
const scores = {};
|
|
45
|
+
const allSignals = [];
|
|
46
|
+
for (const profile of HOST_PROFILES) {
|
|
47
|
+
scores[profile.id] = 0;
|
|
48
|
+
for (const token of profile.strongArgvTokens) {
|
|
49
|
+
if (normalizedArgv.has(token)) {
|
|
50
|
+
allSignals.push({
|
|
51
|
+
hostId: profile.id,
|
|
52
|
+
strength: 'strong',
|
|
53
|
+
key: `argv:${token}`,
|
|
54
|
+
reason: `${profile.id} strong signal via argv token '${token}'`,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
for (const fileName of profile.mediumFiles) {
|
|
59
|
+
const filePath = join(input.cwd, fileName);
|
|
60
|
+
if (await pathExists(filePath)) {
|
|
61
|
+
allSignals.push({
|
|
62
|
+
hostId: profile.id,
|
|
63
|
+
strength: 'medium',
|
|
64
|
+
key: `file:${fileName}`,
|
|
65
|
+
reason: `${profile.id} medium signal via file '${fileName}'`,
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
for (const envVar of profile.weakEnvVars) {
|
|
70
|
+
if (env[envVar]) {
|
|
71
|
+
allSignals.push({
|
|
72
|
+
hostId: profile.id,
|
|
73
|
+
strength: 'weak',
|
|
74
|
+
key: `env:${envVar}`,
|
|
75
|
+
reason: `${profile.id} weak signal via env '${envVar}'`,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
for (const token of profile.weakProcessTokens) {
|
|
80
|
+
const hasHint = processHints.some((hint) => hint.includes(token));
|
|
81
|
+
if (hasHint) {
|
|
82
|
+
allSignals.push({
|
|
83
|
+
hostId: profile.id,
|
|
84
|
+
strength: 'weak',
|
|
85
|
+
key: `process:${token}`,
|
|
86
|
+
reason: `${profile.id} weak signal via process hint '${token}'`,
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
for (const signal of allSignals) {
|
|
92
|
+
scores[signal.hostId] = (scores[signal.hostId] ?? 0) + SIGNAL_WEIGHTS[signal.strength];
|
|
93
|
+
}
|
|
94
|
+
const rankedHosts = Object.entries(scores)
|
|
95
|
+
.sort((a, b) => (b[1] - a[1]) || a[0].localeCompare(b[0]));
|
|
96
|
+
const [winnerHostId, winnerScore] = rankedHosts[0] ?? [null, 0];
|
|
97
|
+
const [, secondScore] = rankedHosts[1] ?? [null, 0];
|
|
98
|
+
const hasTie = winnerScore > 0 && winnerScore === secondScore;
|
|
99
|
+
const meaningfulWinner = (winnerScore ?? 0) > 0 ? winnerHostId : null;
|
|
100
|
+
const confidence = meaningfulWinner === null
|
|
101
|
+
? 'low'
|
|
102
|
+
: winnerScore >= SIGNAL_WEIGHTS.strong
|
|
103
|
+
? 'high'
|
|
104
|
+
: winnerScore >= SIGNAL_WEIGHTS.medium
|
|
105
|
+
? 'medium'
|
|
106
|
+
: 'low';
|
|
107
|
+
const reasons = meaningfulWinner === null
|
|
108
|
+
? []
|
|
109
|
+
: allSignals
|
|
110
|
+
.filter((signal) => signal.hostId === meaningfulWinner)
|
|
111
|
+
.map((signal) => signal.reason)
|
|
112
|
+
.sort((a, b) => a.localeCompare(b, undefined, { sensitivity: 'base' }));
|
|
113
|
+
if (hasTie && meaningfulWinner !== null) {
|
|
114
|
+
reasons.push(`Tie at score ${winnerScore} resolved to '${meaningfulWinner}' by hostId ordering`);
|
|
115
|
+
reasons.sort((a, b) => a.localeCompare(b, undefined, { sensitivity: 'base' }));
|
|
116
|
+
}
|
|
117
|
+
return {
|
|
118
|
+
detectedHostId: meaningfulWinner,
|
|
119
|
+
confidence,
|
|
120
|
+
reasons,
|
|
121
|
+
scores,
|
|
122
|
+
signals: allSignals
|
|
123
|
+
.slice()
|
|
124
|
+
.sort((a, b) => a.hostId.localeCompare(b.hostId) || a.key.localeCompare(b.key)),
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
//# sourceMappingURL=active-host-detector.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"active-host-detector.service.js","sourceRoot":"","sources":["../../../../orchestrator/shell/services/active-host-detector.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAmC1C,MAAM,cAAc,GAAmC;IACrD,MAAM,EAAE,GAAG;IACX,MAAM,EAAE,EAAE;IACV,IAAI,EAAE,EAAE;CACT,CAAA;AAED,MAAM,aAAa,GAAkB;IACnC;QACE,EAAE,EAAE,aAAa;QACjB,gBAAgB,EAAE,CAAC,QAAQ,EAAE,aAAa,CAAC;QAC3C,WAAW,EAAE,CAAC,WAAW,EAAE,uBAAuB,CAAC;QACnD,WAAW,EAAE,CAAC,YAAY,EAAE,aAAa,CAAC;QAC1C,iBAAiB,EAAE,CAAC,QAA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YACV,OAAO;YACP,MAAM;YACN,OAAO,EAAE,UAAU;iBAChB,KAAK,EAAE;iBACP,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;SAClF,CAAA;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { IHostAdapter } from '../../adapters/host/IHostAdapter.js';
|
|
2
|
+
import type { ActiveHostDetectionResult } from './active-host-detector.service.js';
|
|
3
|
+
export type HostValidationMetadata = {
|
|
4
|
+
timestamp: string;
|
|
5
|
+
matchedSignals: string[];
|
|
6
|
+
};
|
|
7
|
+
export type PersistedHostPreference = {
|
|
8
|
+
preferredHost: string | null;
|
|
9
|
+
validation: HostValidationMetadata | null;
|
|
10
|
+
};
|
|
11
|
+
export type HostResolutionPath = 'detected' | 'persisted' | 'assisted-selection';
|
|
12
|
+
export type HostResolutionInput = {
|
|
13
|
+
detection: ActiveHostDetectionResult;
|
|
14
|
+
commandId: string;
|
|
15
|
+
};
|
|
16
|
+
export type HostResolutionResult = {
|
|
17
|
+
hostId: string;
|
|
18
|
+
path: HostResolutionPath;
|
|
19
|
+
validation: HostValidationMetadata;
|
|
20
|
+
};
|
|
21
|
+
type AssistedSelectionContext = {
|
|
22
|
+
detection: ActiveHostDetectionResult;
|
|
23
|
+
commandId: string;
|
|
24
|
+
};
|
|
25
|
+
type HostResolutionDependencies = {
|
|
26
|
+
loadPersistedPreference: () => Promise<PersistedHostPreference | null>;
|
|
27
|
+
persistPreferredHost: (preference: PersistedHostPreference) => Promise<void>;
|
|
28
|
+
getHostAdapter: (hostId: string) => IHostAdapter | null;
|
|
29
|
+
isCommandSupported: (hostId: string, commandId: string) => Promise<boolean> | boolean;
|
|
30
|
+
assistedSelectHost: (context: AssistedSelectionContext) => Promise<string>;
|
|
31
|
+
now?: () => Date;
|
|
32
|
+
};
|
|
33
|
+
export declare class HostResolutionService {
|
|
34
|
+
private deps;
|
|
35
|
+
constructor(dependencies: HostResolutionDependencies);
|
|
36
|
+
resolve(input: HostResolutionInput): Promise<HostResolutionResult>;
|
|
37
|
+
private getValidPersistedHostId;
|
|
38
|
+
private isHostAvailableForCommand;
|
|
39
|
+
private resolveAssistedSelection;
|
|
40
|
+
}
|
|
41
|
+
export {};
|
|
42
|
+
//# sourceMappingURL=host-resolution.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host-resolution.service.d.ts","sourceRoot":"","sources":["../../../../orchestrator/shell/services/host-resolution.service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAA;AACvE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAA;AAElF,MAAM,MAAM,sBAAsB,GAAG;IACnC,SAAS,EAAE,MAAM,CAAA;IACjB,cAAc,EAAE,MAAM,EAAE,CAAA;CACzB,CAAA;AAED,MAAM,MAAM,uBAAuB,GAAG;IACpC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAA;IAC5B,UAAU,EAAE,sBAAsB,GAAG,IAAI,CAAA;CAC1C,CAAA;AAED,MAAM,MAAM,kBAAkB,GAAG,UAAU,GAAG,WAAW,GAAG,oBAAoB,CAAA;AAEhF,MAAM,MAAM,mBAAmB,GAAG;IAChC,SAAS,EAAE,yBAAyB,CAAA;IACpC,SAAS,EAAE,MAAM,CAAA;CAClB,CAAA;AAED,MAAM,MAAM,oBAAoB,GAAG;IACjC,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,kBAAkB,CAAA;IACxB,UAAU,EAAE,sBAAsB,CAAA;CACnC,CAAA;AAED,KAAK,wBAAwB,GAAG;IAC9B,SAAS,EAAE,yBAAyB,CAAA;IACpC,SAAS,EAAE,MAAM,CAAA;CAClB,CAAA;AAED,KAAK,0BAA0B,GAAG;IAChC,uBAAuB,EAAE,MAAM,OAAO,CAAC,uBAAuB,GAAG,IAAI,CAAC,CAAA;IACtE,oBAAoB,EAAE,CAAC,UAAU,EAAE,uBAAuB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IAC5E,cAAc,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,YAAY,GAAG,IAAI,CAAA;IACvD,kBAAkB,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAA;IACrF,kBAAkB,EAAE,CAAC,OAAO,EAAE,wBAAwB,KAAK,OAAO,CAAC,MAAM,CAAC,CAAA;IAC1E,GAAG,CAAC,EAAE,MAAM,IAAI,CAAA;CACjB,CAAA;AAoBD,qBAAa,qBAAqB;IAChC,OAAO,CAAC,IAAI,CAA4B;gBAE5B,YAAY,EAAE,0BAA0B;IAI9C,OAAO,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,oBAAoB,CAAC;YA2C1D,uBAAuB;YAuBvB,yBAAyB;YAkBzB,wBAAwB;CAqBvC"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
function collectMediumStrongSignalKeys(detection, hostId) {
|
|
2
|
+
return detection.signals
|
|
3
|
+
.filter((signal) => signal.hostId === hostId && (signal.strength === 'medium' || signal.strength === 'strong'))
|
|
4
|
+
.map((signal) => signal.key)
|
|
5
|
+
.sort((a, b) => a.localeCompare(b));
|
|
6
|
+
}
|
|
7
|
+
function buildValidationMetadata(detection, hostId, now) {
|
|
8
|
+
return {
|
|
9
|
+
timestamp: now().toISOString(),
|
|
10
|
+
matchedSignals: collectMediumStrongSignalKeys(detection, hostId),
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export class HostResolutionService {
|
|
14
|
+
deps;
|
|
15
|
+
constructor(dependencies) {
|
|
16
|
+
this.deps = dependencies;
|
|
17
|
+
}
|
|
18
|
+
async resolve(input) {
|
|
19
|
+
const now = this.deps.now ?? (() => new Date());
|
|
20
|
+
const { detection } = input;
|
|
21
|
+
if (detection.confidence === 'high' && detection.detectedHostId !== null) {
|
|
22
|
+
const isValidDetected = await this.isHostAvailableForCommand(detection.detectedHostId, input.commandId);
|
|
23
|
+
if (isValidDetected) {
|
|
24
|
+
const validation = buildValidationMetadata(detection, detection.detectedHostId, now);
|
|
25
|
+
await this.deps.persistPreferredHost({
|
|
26
|
+
preferredHost: detection.detectedHostId,
|
|
27
|
+
validation,
|
|
28
|
+
});
|
|
29
|
+
return {
|
|
30
|
+
hostId: detection.detectedHostId,
|
|
31
|
+
path: 'detected',
|
|
32
|
+
validation,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
if (detection.confidence === 'medium') {
|
|
37
|
+
const persisted = await this.deps.loadPersistedPreference();
|
|
38
|
+
const validPersistedHost = await this.getValidPersistedHostId(input, persisted);
|
|
39
|
+
if (validPersistedHost !== null) {
|
|
40
|
+
const validation = buildValidationMetadata(detection, validPersistedHost, now);
|
|
41
|
+
await this.deps.persistPreferredHost({
|
|
42
|
+
preferredHost: validPersistedHost,
|
|
43
|
+
validation,
|
|
44
|
+
});
|
|
45
|
+
return {
|
|
46
|
+
hostId: validPersistedHost,
|
|
47
|
+
path: 'persisted',
|
|
48
|
+
validation,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return this.resolveAssistedSelection(input, now);
|
|
53
|
+
}
|
|
54
|
+
async getValidPersistedHostId(input, persisted) {
|
|
55
|
+
const persistedHost = persisted?.preferredHost ?? null;
|
|
56
|
+
if (persistedHost === null)
|
|
57
|
+
return null;
|
|
58
|
+
const adapter = this.deps.getHostAdapter(persistedHost);
|
|
59
|
+
if (adapter === null)
|
|
60
|
+
return null;
|
|
61
|
+
const isAvailableForCommand = await this.isHostAvailableForCommand(persistedHost, input.commandId);
|
|
62
|
+
if (!isAvailableForCommand)
|
|
63
|
+
return null;
|
|
64
|
+
const priorMatchedSignals = new Set(persisted?.validation?.matchedSignals ?? []);
|
|
65
|
+
if (priorMatchedSignals.size === 0)
|
|
66
|
+
return null;
|
|
67
|
+
const currentSignalKeys = collectMediumStrongSignalKeys(input.detection, persistedHost);
|
|
68
|
+
const hasSignalMatch = currentSignalKeys.some((key) => priorMatchedSignals.has(key));
|
|
69
|
+
if (!hasSignalMatch)
|
|
70
|
+
return null;
|
|
71
|
+
return persistedHost;
|
|
72
|
+
}
|
|
73
|
+
async isHostAvailableForCommand(hostId, commandId) {
|
|
74
|
+
const adapter = this.deps.getHostAdapter(hostId);
|
|
75
|
+
if (adapter === null)
|
|
76
|
+
return false;
|
|
77
|
+
try {
|
|
78
|
+
await adapter.initialize();
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
try {
|
|
84
|
+
const supportsCommand = await this.deps.isCommandSupported(hostId, commandId);
|
|
85
|
+
return supportsCommand;
|
|
86
|
+
}
|
|
87
|
+
catch {
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
async resolveAssistedSelection(input, now) {
|
|
92
|
+
const selectedHostId = await this.deps.assistedSelectHost({
|
|
93
|
+
detection: input.detection,
|
|
94
|
+
commandId: input.commandId,
|
|
95
|
+
});
|
|
96
|
+
const validation = buildValidationMetadata(input.detection, selectedHostId, now);
|
|
97
|
+
await this.deps.persistPreferredHost({
|
|
98
|
+
preferredHost: selectedHostId,
|
|
99
|
+
validation,
|
|
100
|
+
});
|
|
101
|
+
return {
|
|
102
|
+
hostId: selectedHostId,
|
|
103
|
+
path: 'assisted-selection',
|
|
104
|
+
validation,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=host-resolution.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host-resolution.service.js","sourceRoot":"","sources":["../../../../orch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pC,KAA0B,EAC1B,GAAe;QAEf,MAAM,cAAc,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAAC;YACxD,SAAS,EAAE,KAAK,CAAC,SAAS;YAC1B,SAAS,EAAE,KAAK,CAAC,SAAS;SAC3B,CAAC,CAAA;QACF,MAAM,UAAU,GAAG,uBAAuB,CAAC,KAAK,CAAC,SAAS,EAAE,cAAc,EAAE,GAAG,CAAC,CAAA;QAEhF,MAAM,IAAI,CAAC,IAAI,CAAC,oBAAoB,CAAC;YACnC,aAAa,EAAE,cAAc;YAC7B,UAAU;SACX,CAAC,CAAA;QAEF,OAAO;YACL,MAAM,EAAE,cAAc;YACtB,IAAI,EAAE,oBAAoB;YAC1B,UAAU;SACX,CAAA;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { IHostAdapter } from '../../adapters/host/IHostAdapter.js';
|
|
2
|
+
import { type HostResolutionResult } from './host-resolution.service.js';
|
|
3
|
+
export type ResolvedHostRuntime = {
|
|
4
|
+
hostAdapter: IHostAdapter;
|
|
5
|
+
hostId: string;
|
|
6
|
+
path: HostResolutionResult['path'];
|
|
7
|
+
confidence: 'high' | 'medium' | 'low';
|
|
8
|
+
reasons: string[];
|
|
9
|
+
activeModel: string;
|
|
10
|
+
validation: HostResolutionResult['validation'];
|
|
11
|
+
};
|
|
12
|
+
export declare class HostRuntimeService {
|
|
13
|
+
private cwd;
|
|
14
|
+
private adapterCache;
|
|
15
|
+
constructor(cwd: string);
|
|
16
|
+
private getPreferencesPath;
|
|
17
|
+
private loadPersistedPreference;
|
|
18
|
+
private persistPreferredHost;
|
|
19
|
+
private getHostAdapter;
|
|
20
|
+
private assistedSelectHost;
|
|
21
|
+
resolveForCommand(commandId: string): Promise<ResolvedHostRuntime>;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=host-runtime.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host-runtime.service.d.ts","sourceRoot":"","sources":["../../../../orchestrator/shell/services/host-runtime.service.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAA;AAKvE,OAAO,EAEL,KAAK,oBAAoB,EAE1B,MAAM,8BAA8B,CAAA;AAWrC,MAAM,MAAM,mBAAmB,GAAG;IAChC,WAAW,EAAE,YAAY,CAAA;IACzB,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,oBAAoB,CAAC,MAAM,CAAC,CAAA;IAClC,UAAU,EAAE,MAAM,GAAG,QAAQ,GAAG,KAAK,CAAA;IACrC,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,WAAW,EAAE,MAAM,CAAA;IACnB,UAAU,EAAE,oBAAoB,CAAC,YAAY,CAAC,CAAA;CAC/C,CAAA;AAoCD,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,GAAG,CAAQ;IACnB,OAAO,CAAC,YAAY,CAAkC;gBAE1C,GAAG,EAAE,MAAM;IAIvB,OAAO,CAAC,kBAAkB;YAIZ,uBAAuB;YAwBvB,oBAAoB;IAmBlC,OAAO,CAAC,cAAc;YAUR,kBAAkB;IA0B1B,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;CA2CzE"}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { access, readFile, writeFile } from 'node:fs/promises';
|
|
2
|
+
import { createInterface } from 'node:readline/promises';
|
|
3
|
+
import { stdin as input, stdout as output } from 'node:process';
|
|
4
|
+
import { join } from 'node:path';
|
|
5
|
+
import { AntigravityHostAdapter } from '../../adapters/host/antigravity.adapter.js';
|
|
6
|
+
import { AnthropicHostAdapter } from '../../adapters/host/anthropic.adapter.js';
|
|
7
|
+
import { ClaudeCodeHostAdapter } from '../../adapters/host/claude-code.adapter.js';
|
|
8
|
+
import { LocalHostAdapter } from '../../adapters/host/local.adapter.js';
|
|
9
|
+
import { OpenAIHostAdapter } from '../../adapters/host/openai.adapter.js';
|
|
10
|
+
import { OpenCodeHostAdapter } from '../../adapters/host/opencode.adapter.js';
|
|
11
|
+
import { ActiveHostDetector } from './active-host-detector.service.js';
|
|
12
|
+
import { HostResolutionService, } from './host-resolution.service.js';
|
|
13
|
+
const HOST_PREFS_FILE = 'squad-foundry.hosts.json';
|
|
14
|
+
async function fileExists(path) {
|
|
15
|
+
try {
|
|
16
|
+
await access(path);
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function createAdapter(hostId) {
|
|
24
|
+
if (hostId === 'claude-code') {
|
|
25
|
+
return new ClaudeCodeHostAdapter();
|
|
26
|
+
}
|
|
27
|
+
if (hostId === 'opencode') {
|
|
28
|
+
return new OpenCodeHostAdapter();
|
|
29
|
+
}
|
|
30
|
+
switch (hostId) {
|
|
31
|
+
case 'local':
|
|
32
|
+
return new LocalHostAdapter();
|
|
33
|
+
case 'antigravity':
|
|
34
|
+
return new AntigravityHostAdapter();
|
|
35
|
+
case 'anthropic':
|
|
36
|
+
return new AnthropicHostAdapter();
|
|
37
|
+
case 'openai':
|
|
38
|
+
return new OpenAIHostAdapter();
|
|
39
|
+
default:
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function getAvailableHostIds() {
|
|
44
|
+
return ['claude-code', 'opencode', 'local', 'antigravity', 'anthropic', 'openai'];
|
|
45
|
+
}
|
|
46
|
+
export class HostRuntimeService {
|
|
47
|
+
cwd;
|
|
48
|
+
adapterCache = new Map();
|
|
49
|
+
constructor(cwd) {
|
|
50
|
+
this.cwd = cwd;
|
|
51
|
+
}
|
|
52
|
+
getPreferencesPath() {
|
|
53
|
+
return join(this.cwd, HOST_PREFS_FILE);
|
|
54
|
+
}
|
|
55
|
+
async loadPersistedPreference() {
|
|
56
|
+
const path = this.getPreferencesPath();
|
|
57
|
+
if (!(await fileExists(path)))
|
|
58
|
+
return null;
|
|
59
|
+
let json;
|
|
60
|
+
try {
|
|
61
|
+
const raw = await readFile(path, 'utf-8');
|
|
62
|
+
json = JSON.parse(raw);
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
if (!json || typeof json !== 'object')
|
|
68
|
+
return null;
|
|
69
|
+
const validation = json.validation
|
|
70
|
+
?? (json.lastValidated
|
|
71
|
+
? { timestamp: json.lastValidated, matchedSignals: [] }
|
|
72
|
+
: null);
|
|
73
|
+
return {
|
|
74
|
+
preferredHost: typeof json.preferredHost === 'string' ? json.preferredHost : null,
|
|
75
|
+
validation,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
async persistPreferredHost(preference) {
|
|
79
|
+
const path = this.getPreferencesPath();
|
|
80
|
+
const existing = await this.loadPersistedPreference();
|
|
81
|
+
const knownHosts = new Set([
|
|
82
|
+
...(existing?.preferredHost ? [existing.preferredHost] : []),
|
|
83
|
+
...getAvailableHostIds(),
|
|
84
|
+
...(preference.preferredHost ? [preference.preferredHost] : []),
|
|
85
|
+
]);
|
|
86
|
+
const payload = {
|
|
87
|
+
preferredHost: preference.preferredHost,
|
|
88
|
+
validation: preference.validation,
|
|
89
|
+
lastValidated: preference.validation?.timestamp ?? null,
|
|
90
|
+
hosts: [...knownHosts].sort((a, b) => a.localeCompare(b)),
|
|
91
|
+
};
|
|
92
|
+
await writeFile(path, `${JSON.stringify(payload, null, 2)}\n`, 'utf-8');
|
|
93
|
+
}
|
|
94
|
+
getHostAdapter(hostId) {
|
|
95
|
+
const cached = this.adapterCache.get(hostId);
|
|
96
|
+
if (cached)
|
|
97
|
+
return cached;
|
|
98
|
+
const created = createAdapter(hostId);
|
|
99
|
+
if (!created)
|
|
100
|
+
return null;
|
|
101
|
+
this.adapterCache.set(hostId, created);
|
|
102
|
+
return created;
|
|
103
|
+
}
|
|
104
|
+
async assistedSelectHost() {
|
|
105
|
+
if (!process.stdin.isTTY) {
|
|
106
|
+
throw new Error('Host could not be resolved automatically. Re-run in interactive terminal or set SQUAD_FOUNDRY_ADAPTER explicitly.');
|
|
107
|
+
}
|
|
108
|
+
const available = getAvailableHostIds();
|
|
109
|
+
const rl = createInterface({ input, output });
|
|
110
|
+
try {
|
|
111
|
+
output.write('\nSelect host adapter for this project:\n');
|
|
112
|
+
available.forEach((hostId, idx) => {
|
|
113
|
+
output.write(` ${idx + 1}. ${hostId}\n`);
|
|
114
|
+
});
|
|
115
|
+
const answer = (await rl.question('Host number: ')).trim();
|
|
116
|
+
const index = Number(answer) - 1;
|
|
117
|
+
if (Number.isNaN(index) || index < 0 || index >= available.length) {
|
|
118
|
+
throw new Error('Invalid host selection.');
|
|
119
|
+
}
|
|
120
|
+
return available[index];
|
|
121
|
+
}
|
|
122
|
+
finally {
|
|
123
|
+
rl.close();
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
async resolveForCommand(commandId) {
|
|
127
|
+
const detector = new ActiveHostDetector();
|
|
128
|
+
const detection = await detector.detect({
|
|
129
|
+
cwd: this.cwd,
|
|
130
|
+
argv: process.argv,
|
|
131
|
+
env: process.env,
|
|
132
|
+
processHints: [process.title],
|
|
133
|
+
});
|
|
134
|
+
const resolver = new HostResolutionService({
|
|
135
|
+
loadPersistedPreference: async () => this.loadPersistedPreference(),
|
|
136
|
+
persistPreferredHost: async (pref) => this.persistPreferredHost(pref),
|
|
137
|
+
getHostAdapter: (hostId) => this.getHostAdapter(hostId),
|
|
138
|
+
isCommandSupported: async (hostId, requestedCommandId) => {
|
|
139
|
+
const adapter = this.getHostAdapter(hostId);
|
|
140
|
+
if (!adapter)
|
|
141
|
+
return false;
|
|
142
|
+
if (requestedCommandId === 'list' || requestedCommandId === 'status' || requestedCommandId === 'hosts') {
|
|
143
|
+
return true;
|
|
144
|
+
}
|
|
145
|
+
return true;
|
|
146
|
+
},
|
|
147
|
+
assistedSelectHost: async () => this.assistedSelectHost(),
|
|
148
|
+
});
|
|
149
|
+
const result = await resolver.resolve({ detection, commandId });
|
|
150
|
+
const adapter = this.getHostAdapter(result.hostId);
|
|
151
|
+
if (!adapter) {
|
|
152
|
+
throw new Error(`Resolved host '${result.hostId}' is not supported in this runtime.`);
|
|
153
|
+
}
|
|
154
|
+
await adapter.initialize();
|
|
155
|
+
const activeModel = (await adapter.getActiveModel()) ?? 'host-default';
|
|
156
|
+
return {
|
|
157
|
+
hostAdapter: adapter,
|
|
158
|
+
hostId: result.hostId,
|
|
159
|
+
path: result.path,
|
|
160
|
+
confidence: detection.confidence,
|
|
161
|
+
reasons: detection.reasons,
|
|
162
|
+
activeModel,
|
|
163
|
+
validation: result.validation,
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
//# sourceMappingURL=host-runtime.service.js.map
|