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,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Squad Foundry — Explicit State Machine
|
|
3
|
+
*
|
|
4
|
+
* Manages valid job state transitions. All transitions are declared explicitly —
|
|
5
|
+
* no implicit or magical state changes. Each transition can carry a guard function
|
|
6
|
+
* that must return true for the transition to proceed.
|
|
7
|
+
*
|
|
8
|
+
* Squads can extend the base transitions with custom ones via registerTransition().
|
|
9
|
+
*/
|
|
10
|
+
import type { JobStatus, JobDefinition, GuardrailResult } from './types.js';
|
|
11
|
+
export type TransitionEvent = 'START_CONTEXT_LOADING' | 'CONTEXT_LOADED' | 'START_SQUAD_DESIGN' | 'SQUAD_DESIGN_COMPLETE' | 'CREATE_JOB' | 'REQUEST_USER_INPUT' | 'USER_INPUT_RECEIVED' | 'MARK_READY' | 'START_STEP' | 'STEP_COMPLETE' | 'STEP_NEEDS_APPROVAL' | 'APPROVAL_GRANTED' | 'APPROVAL_REJECTED' | 'GUARDRAIL_BLOCKED' | 'GUARDRAIL_CLEARED' | 'FAIL' | 'COMPLETE' | string;
|
|
12
|
+
export type GuardFn = (job: JobDefinition) => GuardResult;
|
|
13
|
+
export interface GuardResult {
|
|
14
|
+
allowed: boolean;
|
|
15
|
+
reason?: string;
|
|
16
|
+
guardrailResults?: GuardrailResult[];
|
|
17
|
+
}
|
|
18
|
+
export interface TransitionDef {
|
|
19
|
+
from: JobStatus | JobStatus[];
|
|
20
|
+
event: TransitionEvent;
|
|
21
|
+
to: JobStatus;
|
|
22
|
+
guard?: GuardFn;
|
|
23
|
+
description: string;
|
|
24
|
+
}
|
|
25
|
+
export interface TransitionResult {
|
|
26
|
+
success: boolean;
|
|
27
|
+
previousStatus: JobStatus;
|
|
28
|
+
newStatus: JobStatus;
|
|
29
|
+
event: TransitionEvent;
|
|
30
|
+
reason?: string;
|
|
31
|
+
guardrailResults?: GuardrailResult[];
|
|
32
|
+
}
|
|
33
|
+
export declare class StateMachine {
|
|
34
|
+
private transitions;
|
|
35
|
+
/**
|
|
36
|
+
* Register a custom transition (e.g., for squad-specific states).
|
|
37
|
+
*/
|
|
38
|
+
registerTransition(transition: TransitionDef): void;
|
|
39
|
+
/**
|
|
40
|
+
* Attempt a state transition. Returns a result with success/failure and reason.
|
|
41
|
+
*/
|
|
42
|
+
transition(job: JobDefinition, event: TransitionEvent): TransitionResult;
|
|
43
|
+
/**
|
|
44
|
+
* Get all valid events from a given status.
|
|
45
|
+
*/
|
|
46
|
+
validEventsFrom(status: JobStatus): TransitionEvent[];
|
|
47
|
+
/**
|
|
48
|
+
* Check whether a job is in a terminal state.
|
|
49
|
+
*/
|
|
50
|
+
isTerminal(status: JobStatus): boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Check whether a given transition is defined (ignoring guards).
|
|
53
|
+
*/
|
|
54
|
+
canTransition(fromStatus: JobStatus, event: TransitionEvent): boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Get all registered transitions (for diagnostics).
|
|
57
|
+
*/
|
|
58
|
+
getAllTransitions(): Readonly<TransitionDef[]>;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Singleton factory — one machine per process.
|
|
62
|
+
* Squads register custom transitions on startup.
|
|
63
|
+
*/
|
|
64
|
+
export declare function createStateMachine(): StateMachine;
|
|
65
|
+
//# sourceMappingURL=state-machine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state-machine.d.ts","sourceRoot":"","sources":["../../../orchestrator/core/state-machine.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAM3E,MAAM,MAAM,eAAe,GACvB,uBAAuB,GACvB,gBAAgB,GAChB,oBAAoB,GACpB,uBAAuB,GACvB,YAAY,GACZ,oBAAoB,GACpB,qBAAqB,GACrB,YAAY,GACZ,YAAY,GACZ,eAAe,GACf,qBAAqB,GACrB,kBAAkB,GAClB,mBAAmB,GACnB,mBAAmB,GACnB,mBAAmB,GACnB,MAAM,GACN,UAAU,GACV,MAAM,CAAA;AAMV,MAAM,MAAM,OAAO,GAAG,CAAC,GAAG,EAAE,aAAa,KAAK,WAAW,CAAA;AAEzD,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,OAAO,CAAA;IAChB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,gBAAgB,CAAC,EAAE,eAAe,EAAE,CAAA;CACrC;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,SAAS,GAAG,SAAS,EAAE,CAAA;IAC7B,KAAK,EAAE,eAAe,CAAA;IACtB,EAAE,EAAE,SAAS,CAAA;IACb,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,WAAW,EAAE,MAAM,CAAA;CACpB;AAED,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,OAAO,CAAA;IAChB,cAAc,EAAE,SAAS,CAAA;IACzB,SAAS,EAAE,SAAS,CAAA;IACpB,KAAK,EAAE,eAAe,CAAA;IACtB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,gBAAgB,CAAC,EAAE,eAAe,EAAE,CAAA;CACrC;AAqID,qBAAa,YAAY;IACvB,OAAO,CAAC,WAAW,CAAyC;IAE5D;;OAEG;IACH,kBAAkB,CAAC,UAAU,EAAE,aAAa,GAAG,IAAI;IAInD;;OAEG;IACH,UAAU,CACR,GAAG,EAAE,aAAa,EAClB,KAAK,EAAE,eAAe,GACrB,gBAAgB;IA2CnB;;OAEG;IACH,eAAe,CAAC,MAAM,EAAE,SAAS,GAAG,eAAe,EAAE;IASrD;;OAEG;IACH,UAAU,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO;IAItC;;OAEG;IACH,aAAa,CAAC,UAAU,EAAE,SAAS,EAAE,KAAK,EAAE,eAAe,GAAG,OAAO;IAOrE;;OAEG;IACH,iBAAiB,IAAI,QAAQ,CAAC,aAAa,EAAE,CAAC;CAG/C;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,IAAI,YAAY,CAEjD"}
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Squad Foundry — Explicit State Machine
|
|
3
|
+
*
|
|
4
|
+
* Manages valid job state transitions. All transitions are declared explicitly —
|
|
5
|
+
* no implicit or magical state changes. Each transition can carry a guard function
|
|
6
|
+
* that must return true for the transition to proceed.
|
|
7
|
+
*
|
|
8
|
+
* Squads can extend the base transitions with custom ones via registerTransition().
|
|
9
|
+
*/
|
|
10
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
11
|
+
// Base Transitions
|
|
12
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
13
|
+
const BASE_TRANSITIONS = [
|
|
14
|
+
{
|
|
15
|
+
from: 'INTAKE_PENDING',
|
|
16
|
+
event: 'START_CONTEXT_LOADING',
|
|
17
|
+
to: 'CONTEXT_LOADING',
|
|
18
|
+
description: 'Begin loading context files from filesystem',
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
from: 'CONTEXT_LOADING',
|
|
22
|
+
event: 'CONTEXT_LOADED',
|
|
23
|
+
to: 'SQUAD_DESIGNING',
|
|
24
|
+
description: 'Context loaded — begin squad design interview',
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
from: 'CONTEXT_LOADING',
|
|
28
|
+
event: 'CREATE_JOB',
|
|
29
|
+
to: 'JOB_CREATED',
|
|
30
|
+
description: 'Context loaded for existing squad — create job directly',
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
from: 'SQUAD_DESIGNING',
|
|
34
|
+
event: 'SQUAD_DESIGN_COMPLETE',
|
|
35
|
+
to: 'SQUAD_READY',
|
|
36
|
+
description: 'Squad definition generated and approved',
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
from: 'SQUAD_DESIGNING',
|
|
40
|
+
event: 'REQUEST_USER_INPUT',
|
|
41
|
+
to: 'WAITING_USER_INPUT',
|
|
42
|
+
description: 'Need more information from user during design',
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
from: 'SQUAD_READY',
|
|
46
|
+
event: 'CREATE_JOB',
|
|
47
|
+
to: 'JOB_CREATED',
|
|
48
|
+
description: 'Squad ready — create a new job',
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
from: 'JOB_CREATED',
|
|
52
|
+
event: 'MARK_READY',
|
|
53
|
+
to: 'READY_FOR_EXECUTION',
|
|
54
|
+
description: 'Job initialized and all preconditions met',
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
from: 'JOB_CREATED',
|
|
58
|
+
event: 'REQUEST_USER_INPUT',
|
|
59
|
+
to: 'WAITING_USER_INPUT',
|
|
60
|
+
description: 'Job created but needs user clarification before starting',
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
from: 'WAITING_USER_INPUT',
|
|
64
|
+
event: 'USER_INPUT_RECEIVED',
|
|
65
|
+
to: 'READY_FOR_EXECUTION',
|
|
66
|
+
description: 'User provided required input — ready to proceed',
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
from: 'READY_FOR_EXECUTION',
|
|
70
|
+
event: 'START_STEP',
|
|
71
|
+
to: 'RUNNING_STEP',
|
|
72
|
+
description: 'Beginning execution of the next workflow step',
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
from: 'RUNNING_STEP',
|
|
76
|
+
event: 'STEP_COMPLETE',
|
|
77
|
+
to: 'READY_FOR_EXECUTION',
|
|
78
|
+
description: 'Step completed — ready for next step',
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
from: 'RUNNING_STEP',
|
|
82
|
+
event: 'STEP_NEEDS_APPROVAL',
|
|
83
|
+
to: 'WAITING_APPROVAL',
|
|
84
|
+
description: 'Step output requires human approval before proceeding',
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
from: 'RUNNING_STEP',
|
|
88
|
+
event: 'GUARDRAIL_BLOCKED',
|
|
89
|
+
to: 'BLOCKED',
|
|
90
|
+
description: 'A guardrail blocked this step from continuing',
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
from: 'RUNNING_STEP',
|
|
94
|
+
event: 'REQUEST_USER_INPUT',
|
|
95
|
+
to: 'WAITING_USER_INPUT',
|
|
96
|
+
description: 'Agent needs user clarification during execution',
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
from: 'RUNNING_STEP',
|
|
100
|
+
event: 'FAIL',
|
|
101
|
+
to: 'FAILED',
|
|
102
|
+
description: 'Step failed critically',
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
from: 'WAITING_APPROVAL',
|
|
106
|
+
event: 'APPROVAL_GRANTED',
|
|
107
|
+
to: 'READY_FOR_EXECUTION',
|
|
108
|
+
description: 'Human approved — continue workflow',
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
from: 'WAITING_APPROVAL',
|
|
112
|
+
event: 'APPROVAL_REJECTED',
|
|
113
|
+
to: 'BLOCKED',
|
|
114
|
+
description: 'Human rejected — block workflow',
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
from: 'BLOCKED',
|
|
118
|
+
event: 'GUARDRAIL_CLEARED',
|
|
119
|
+
to: 'READY_FOR_EXECUTION',
|
|
120
|
+
description: 'Blocking condition resolved — resume',
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
from: 'BLOCKED',
|
|
124
|
+
event: 'FAIL',
|
|
125
|
+
to: 'FAILED',
|
|
126
|
+
description: 'Block was unresolvable — fail job',
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
from: ['READY_FOR_EXECUTION', 'RUNNING_STEP'],
|
|
130
|
+
event: 'COMPLETE',
|
|
131
|
+
to: 'COMPLETED',
|
|
132
|
+
description: 'All steps done — job complete',
|
|
133
|
+
},
|
|
134
|
+
];
|
|
135
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
136
|
+
// State Machine
|
|
137
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
138
|
+
export class StateMachine {
|
|
139
|
+
transitions = [...BASE_TRANSITIONS];
|
|
140
|
+
/**
|
|
141
|
+
* Register a custom transition (e.g., for squad-specific states).
|
|
142
|
+
*/
|
|
143
|
+
registerTransition(transition) {
|
|
144
|
+
this.transitions.push(transition);
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Attempt a state transition. Returns a result with success/failure and reason.
|
|
148
|
+
*/
|
|
149
|
+
transition(job, event) {
|
|
150
|
+
const currentStatus = job.status;
|
|
151
|
+
const previousStatus = currentStatus;
|
|
152
|
+
// Find a matching transition
|
|
153
|
+
const match = this.transitions.find((t) => {
|
|
154
|
+
const fromStates = Array.isArray(t.from) ? t.from : [t.from];
|
|
155
|
+
return fromStates.includes(currentStatus) && t.event === event;
|
|
156
|
+
});
|
|
157
|
+
if (!match) {
|
|
158
|
+
return {
|
|
159
|
+
success: false,
|
|
160
|
+
previousStatus,
|
|
161
|
+
newStatus: currentStatus,
|
|
162
|
+
event,
|
|
163
|
+
reason: `No transition found for state '${currentStatus}' + event '${event}'`,
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
// Run guard if present
|
|
167
|
+
if (match.guard) {
|
|
168
|
+
const guardResult = match.guard(job);
|
|
169
|
+
if (!guardResult.allowed) {
|
|
170
|
+
return {
|
|
171
|
+
success: false,
|
|
172
|
+
previousStatus,
|
|
173
|
+
newStatus: currentStatus,
|
|
174
|
+
event,
|
|
175
|
+
reason: guardResult.reason ?? 'Guard function blocked transition',
|
|
176
|
+
guardrailResults: guardResult.guardrailResults,
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
return {
|
|
181
|
+
success: true,
|
|
182
|
+
previousStatus,
|
|
183
|
+
newStatus: match.to,
|
|
184
|
+
event,
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Get all valid events from a given status.
|
|
189
|
+
*/
|
|
190
|
+
validEventsFrom(status) {
|
|
191
|
+
return this.transitions
|
|
192
|
+
.filter((t) => {
|
|
193
|
+
const fromStates = Array.isArray(t.from) ? t.from : [t.from];
|
|
194
|
+
return fromStates.includes(status);
|
|
195
|
+
})
|
|
196
|
+
.map((t) => t.event);
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Check whether a job is in a terminal state.
|
|
200
|
+
*/
|
|
201
|
+
isTerminal(status) {
|
|
202
|
+
return status === 'COMPLETED' || status === 'FAILED';
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Check whether a given transition is defined (ignoring guards).
|
|
206
|
+
*/
|
|
207
|
+
canTransition(fromStatus, event) {
|
|
208
|
+
return this.transitions.some((t) => {
|
|
209
|
+
const fromStates = Array.isArray(t.from) ? t.from : [t.from];
|
|
210
|
+
return fromStates.includes(fromStatus) && t.event === event;
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Get all registered transitions (for diagnostics).
|
|
215
|
+
*/
|
|
216
|
+
getAllTransitions() {
|
|
217
|
+
return this.transitions;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Singleton factory — one machine per process.
|
|
222
|
+
* Squads register custom transitions on startup.
|
|
223
|
+
*/
|
|
224
|
+
export function createStateMachine() {
|
|
225
|
+
return new StateMachine();
|
|
226
|
+
}
|
|
227
|
+
//# sourceMappingURL=state-machine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state-machine.js","sourceRoot":"","sources":["../../../orchestrator/core/state-machine.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAyDH,gFAAgF;AAChF,mBAAmB;AACnB,gFAAgF;AAEhF,MAAM,gBAAgB,GAAoB;IACxC;QACE,IAAI,EAAE,gBAAgB;QACtB,KAAK,EAAE,uBAAuB;QAC9B,EAAE,EAAE,iBAAiB;QACrB,WAAW,EAAE,6CAA6C;KAC3D;IACD;QACE,IAAI,EAAE,iBAAiB;QACvB,KAAK,EAAE,gBAAgB;QACvB,EAAE,EAAE,iBAAiB;QACrB,WAAW,EAAE,+CAA+C;KAC7D;IACD;QACE,IAAI,EAAE,iBAAiB;QACvB,KAAK,EAAE,YAAY;QACnB,EAAE,EAAE,aAAa;QACjB,WAAW,EAAE,yDAAyD;KACvE;IACD;QACE,IAAI,EAAE,iBAAiB;QACvB,KAAK,EAAE,uBAAuB;QAC9B,EAAE,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AAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAA;IACxB,CAAC;IAED;;OAEG;IACH,UAAU,CAAC,MAAiB;QAC1B,OAAO,MAAM,KAAK,WAAW,IAAI,MAAM,KAAK,QAAQ,CAAA;IACtD,CAAC;IAED;;OAEG;IACH,aAAa,CAAC,UAAqB,EAAE,KAAsB;QACzD,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE;YACjC,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA;YAC5D,OAAO,UAAU,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,KAAK,KAAK,KAAK,CAAA;QAC7D,CAAC,CAAC,CAAA;IACJ,CAAC;IAED;;OAEG;IACH,iBAAiB;QACf,OAAO,IAAI,CAAC,WAAW,CAAA;IACzB,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,UAAU,kBAAkB;IAChC,OAAO,IAAI,YAAY,EAAE,CAAA;AAC3B,CAAC"}
|
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Squad Foundry — Core Type Definitions
|
|
3
|
+
*
|
|
4
|
+
* These types form the portable, host-agnostic contract for the entire platform.
|
|
5
|
+
* No external dependencies. No IDE-specific concepts. No vendor lock-in.
|
|
6
|
+
*
|
|
7
|
+
* All adapters, runtime components, and builders operate against these types.
|
|
8
|
+
*/
|
|
9
|
+
export type SquadId = string;
|
|
10
|
+
export type AgentId = string;
|
|
11
|
+
export type JobId = string;
|
|
12
|
+
export type StepId = string;
|
|
13
|
+
export type GuardrailId = string;
|
|
14
|
+
export type ArtifactId = string;
|
|
15
|
+
export type HandoffId = string;
|
|
16
|
+
export type SquadDomain = 'software-development' | 'content-marketing' | 'social-media' | 'documentation' | 'research' | 'operations' | 'hr' | 'sales' | 'custom';
|
|
17
|
+
/**
|
|
18
|
+
* Base states available to every job regardless of squad domain.
|
|
19
|
+
* Squads can define additional custom states in their WorkflowDefinition.
|
|
20
|
+
*/
|
|
21
|
+
export type BaseJobStatus = 'INTAKE_PENDING' | 'CONTEXT_LOADING' | 'SQUAD_DESIGNING' | 'SQUAD_READY' | 'JOB_CREATED' | 'WAITING_USER_INPUT' | 'READY_FOR_EXECUTION' | 'RUNNING_STEP' | 'BLOCKED' | 'WAITING_APPROVAL' | 'FAILED' | 'COMPLETED';
|
|
22
|
+
export type JobStatus = BaseJobStatus | (string & Record<never, never>);
|
|
23
|
+
/**
|
|
24
|
+
* A portable definition of an agent. Not tied to any host, model, or tool.
|
|
25
|
+
* The same AgentDefinition can run in Claude Code, OpenCode, Cursor, etc.
|
|
26
|
+
*/
|
|
27
|
+
export interface AgentDefinition {
|
|
28
|
+
/** Unique identifier within the squad */
|
|
29
|
+
id: AgentId;
|
|
30
|
+
/** Human-readable name */
|
|
31
|
+
name: string;
|
|
32
|
+
/** Functional role in the squad */
|
|
33
|
+
role: string;
|
|
34
|
+
/** Domain this agent operates in */
|
|
35
|
+
domain: SquadDomain;
|
|
36
|
+
/** What this agent is responsible for */
|
|
37
|
+
objective: string;
|
|
38
|
+
/** Base system prompt / instructions for this agent */
|
|
39
|
+
instructions: string;
|
|
40
|
+
/** Expected input format/description */
|
|
41
|
+
inputs: AgentIO[];
|
|
42
|
+
/** Expected output format/description */
|
|
43
|
+
outputs: AgentIO[];
|
|
44
|
+
/** Tool IDs this agent is allowed to invoke */
|
|
45
|
+
allowedTools: string[];
|
|
46
|
+
/** Hard constraints / prohibitions */
|
|
47
|
+
constraints: string[];
|
|
48
|
+
/** What constitutes success for this agent's turn */
|
|
49
|
+
successCriteria: string[];
|
|
50
|
+
/** What constitutes failure for this agent's turn */
|
|
51
|
+
failureCriteria: string[];
|
|
52
|
+
/** Which job states this agent can run in */
|
|
53
|
+
allowedStates: JobStatus[];
|
|
54
|
+
/** Conditions that block this agent from running */
|
|
55
|
+
blockingConditions: string[];
|
|
56
|
+
/** Handoff rules: which agent comes next and under which conditions */
|
|
57
|
+
handoffRules: HandoffRule[];
|
|
58
|
+
/** Expected response format */
|
|
59
|
+
responseFormat: 'markdown' | 'json' | 'plain' | 'structured';
|
|
60
|
+
/** Model preference for this agent (optional — uses squad default if absent) */
|
|
61
|
+
modelPreference?: ModelPreference;
|
|
62
|
+
}
|
|
63
|
+
export interface AgentIO {
|
|
64
|
+
name: string;
|
|
65
|
+
description: string;
|
|
66
|
+
required: boolean;
|
|
67
|
+
format?: string;
|
|
68
|
+
}
|
|
69
|
+
export interface HandoffRule {
|
|
70
|
+
condition: string;
|
|
71
|
+
targetAgentId: AgentId;
|
|
72
|
+
description: string;
|
|
73
|
+
requiresApproval?: boolean;
|
|
74
|
+
}
|
|
75
|
+
export interface ModelPreference {
|
|
76
|
+
provider?: string;
|
|
77
|
+
model?: string;
|
|
78
|
+
temperature?: number;
|
|
79
|
+
maxTokens?: number;
|
|
80
|
+
}
|
|
81
|
+
export interface WorkflowDefinition {
|
|
82
|
+
id: string;
|
|
83
|
+
name: string;
|
|
84
|
+
description: string;
|
|
85
|
+
/** Ordered list of steps */
|
|
86
|
+
steps: WorkflowStep[];
|
|
87
|
+
/** Custom states this squad adds beyond the base states */
|
|
88
|
+
customStates?: string[];
|
|
89
|
+
/** Default entry point step */
|
|
90
|
+
entryStepId: StepId;
|
|
91
|
+
}
|
|
92
|
+
export interface WorkflowStep {
|
|
93
|
+
id: StepId;
|
|
94
|
+
name: string;
|
|
95
|
+
agentId: AgentId;
|
|
96
|
+
description: string;
|
|
97
|
+
/** Steps that must be completed before this one */
|
|
98
|
+
dependsOn: StepId[];
|
|
99
|
+
/** Guardrail IDs that apply to this step */
|
|
100
|
+
guardrails: GuardrailId[];
|
|
101
|
+
/** Whether a human must approve before entering this step */
|
|
102
|
+
requiresApprovalBefore: boolean;
|
|
103
|
+
/** Whether a human must approve the output before moving forward */
|
|
104
|
+
requiresApprovalAfter: boolean;
|
|
105
|
+
/** Artifacts that must exist before this step can run */
|
|
106
|
+
requiredArtifacts: string[];
|
|
107
|
+
/** Artifacts this step is expected to produce */
|
|
108
|
+
producedArtifacts: string[];
|
|
109
|
+
/** Precondition expression (evaluated against job context) */
|
|
110
|
+
precondition?: string;
|
|
111
|
+
/** Postcondition expression (evaluated against step output) */
|
|
112
|
+
postcondition?: string;
|
|
113
|
+
/** If true, step can loop back to itself or a previous step */
|
|
114
|
+
allowsLoop?: boolean;
|
|
115
|
+
/** Next step under normal conditions */
|
|
116
|
+
nextStepId?: StepId;
|
|
117
|
+
/** Next step if the agent signals failure */
|
|
118
|
+
failureStepId?: StepId;
|
|
119
|
+
}
|
|
120
|
+
export type GuardrailSeverity = 'warn' | 'block';
|
|
121
|
+
export interface GuardrailRule {
|
|
122
|
+
id: GuardrailId;
|
|
123
|
+
name: string;
|
|
124
|
+
description: string;
|
|
125
|
+
severity: GuardrailSeverity;
|
|
126
|
+
/** The JS function body as string OR a pre-defined rule key */
|
|
127
|
+
ruleKey: BuiltinGuardrailKey | string;
|
|
128
|
+
/** Parameters passed to the rule evaluator */
|
|
129
|
+
params?: Record<string, unknown>;
|
|
130
|
+
}
|
|
131
|
+
export type BuiltinGuardrailKey = 'require_minimum_context' | 'require_artifact_before_step' | 'require_approval_before_publish' | 'require_human_before_deploy' | 'block_invalid_state_transition' | 'require_pr_criteria' | 'no_agent_outside_allowed_states' | 'require_artifact_produced';
|
|
132
|
+
export interface PolicyDefinition {
|
|
133
|
+
id: string;
|
|
134
|
+
name: string;
|
|
135
|
+
description: string;
|
|
136
|
+
guardrails: GuardrailRule[];
|
|
137
|
+
/** Actions that are globally prohibited for this squad */
|
|
138
|
+
prohibitedActions: string[];
|
|
139
|
+
/** Required approvals for specific actions */
|
|
140
|
+
requiredApprovals: ApprovalRequirement[];
|
|
141
|
+
}
|
|
142
|
+
export interface ApprovalRequirement {
|
|
143
|
+
action: string;
|
|
144
|
+
description: string;
|
|
145
|
+
approverRole?: string;
|
|
146
|
+
timeout?: number;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* A Squad is the core, portable, reusable entity.
|
|
150
|
+
* This JSON/object structure can be serialized and loaded by any host.
|
|
151
|
+
*/
|
|
152
|
+
export interface SquadDefinition {
|
|
153
|
+
id: SquadId;
|
|
154
|
+
name: string;
|
|
155
|
+
domain: SquadDomain;
|
|
156
|
+
objective: string;
|
|
157
|
+
description: string;
|
|
158
|
+
/** Free-form context about the squad's operational environment */
|
|
159
|
+
context: string;
|
|
160
|
+
agents: AgentDefinition[];
|
|
161
|
+
workflow: WorkflowDefinition;
|
|
162
|
+
policy: PolicyDefinition;
|
|
163
|
+
/** Artifacts expected at squad completion */
|
|
164
|
+
expectedArtifacts: ExpectedArtifact[];
|
|
165
|
+
/** External tools and integrations this squad may use */
|
|
166
|
+
allowedIntegrations: IntegrationRef[];
|
|
167
|
+
/** Template IDs used by this squad */
|
|
168
|
+
templates: string[];
|
|
169
|
+
/** Criteria for declaring the squad job successful */
|
|
170
|
+
successCriteria: string[];
|
|
171
|
+
/** Criteria for declaring the squad job failed */
|
|
172
|
+
failureCriteria: string[];
|
|
173
|
+
/** Metadata */
|
|
174
|
+
metadata: SquadMetadata;
|
|
175
|
+
}
|
|
176
|
+
export interface ExpectedArtifact {
|
|
177
|
+
id: string;
|
|
178
|
+
name: string;
|
|
179
|
+
description: string;
|
|
180
|
+
path: string;
|
|
181
|
+
required: boolean;
|
|
182
|
+
format: 'json' | 'markdown' | 'text' | 'binary';
|
|
183
|
+
}
|
|
184
|
+
export interface IntegrationRef {
|
|
185
|
+
id: string;
|
|
186
|
+
type: 'vcs' | 'cicd' | 'social-media' | 'deploy' | 'analytics' | 'docs' | 'mcp' | 'custom';
|
|
187
|
+
name: string;
|
|
188
|
+
/** Whether this integration is required or optional */
|
|
189
|
+
required: boolean;
|
|
190
|
+
/** Adapter stub status */
|
|
191
|
+
status: 'real' | 'stub' | 'mock';
|
|
192
|
+
}
|
|
193
|
+
export interface SquadMetadata {
|
|
194
|
+
version: string;
|
|
195
|
+
createdAt: string;
|
|
196
|
+
updatedAt: string;
|
|
197
|
+
author?: string;
|
|
198
|
+
tags: string[];
|
|
199
|
+
hostCompatibility: string[];
|
|
200
|
+
}
|
|
201
|
+
export interface JobDefinition {
|
|
202
|
+
id: JobId;
|
|
203
|
+
squadId: SquadId;
|
|
204
|
+
status: JobStatus;
|
|
205
|
+
objective: string;
|
|
206
|
+
/** Human-provided initial context / request */
|
|
207
|
+
initialInput: string;
|
|
208
|
+
/** Loaded context from files (PROJECT.md, TASKS.md, etc.) */
|
|
209
|
+
loadedContext: LoadedContext;
|
|
210
|
+
artifacts: ArtifactRef[];
|
|
211
|
+
approvals: ApprovalRecord[];
|
|
212
|
+
currentStepId: StepId | null;
|
|
213
|
+
currentAgentId: AgentId | null;
|
|
214
|
+
history: HistoryEntry[];
|
|
215
|
+
startedAt: string;
|
|
216
|
+
updatedAt: string;
|
|
217
|
+
completedAt?: string;
|
|
218
|
+
failureReason?: string;
|
|
219
|
+
}
|
|
220
|
+
export interface LoadedContext {
|
|
221
|
+
projectMd?: string;
|
|
222
|
+
tasksMd?: string;
|
|
223
|
+
agentsMd?: string;
|
|
224
|
+
readmeMd?: string;
|
|
225
|
+
docs: FileContent[];
|
|
226
|
+
specs: FileContent[];
|
|
227
|
+
playbooks: FileContent[];
|
|
228
|
+
policies: FileContent[];
|
|
229
|
+
templates: FileContent[];
|
|
230
|
+
custom: FileContent[];
|
|
231
|
+
}
|
|
232
|
+
export interface FileContent {
|
|
233
|
+
path: string;
|
|
234
|
+
content: string;
|
|
235
|
+
loadedAt: string;
|
|
236
|
+
}
|
|
237
|
+
export interface ArtifactRef {
|
|
238
|
+
id: ArtifactId;
|
|
239
|
+
name: string;
|
|
240
|
+
path: string;
|
|
241
|
+
producedByAgentId: AgentId;
|
|
242
|
+
producedAtStepId: StepId;
|
|
243
|
+
format: 'json' | 'markdown' | 'text' | 'binary';
|
|
244
|
+
createdAt: string;
|
|
245
|
+
}
|
|
246
|
+
export interface ApprovalRecord {
|
|
247
|
+
id: string;
|
|
248
|
+
stepId: StepId;
|
|
249
|
+
requiredFor: string;
|
|
250
|
+
status: 'pending' | 'approved' | 'rejected';
|
|
251
|
+
requestedAt: string;
|
|
252
|
+
resolvedAt?: string;
|
|
253
|
+
resolvedBy?: string;
|
|
254
|
+
notes?: string;
|
|
255
|
+
}
|
|
256
|
+
export interface HistoryEntry {
|
|
257
|
+
timestamp: string;
|
|
258
|
+
type: 'state_transition' | 'agent_run' | 'handoff' | 'approval' | 'blocked' | 'error' | 'info';
|
|
259
|
+
fromStatus?: JobStatus;
|
|
260
|
+
toStatus?: JobStatus;
|
|
261
|
+
agentId?: AgentId;
|
|
262
|
+
stepId?: StepId;
|
|
263
|
+
message: string;
|
|
264
|
+
data?: Record<string, unknown>;
|
|
265
|
+
}
|
|
266
|
+
export interface HandoffEvent {
|
|
267
|
+
id: HandoffId;
|
|
268
|
+
jobId: JobId;
|
|
269
|
+
fromAgentId: AgentId;
|
|
270
|
+
toAgentId: AgentId;
|
|
271
|
+
fromStepId: StepId;
|
|
272
|
+
toStepId: StepId;
|
|
273
|
+
condition: string;
|
|
274
|
+
payload: HandoffPayload;
|
|
275
|
+
timestamp: string;
|
|
276
|
+
requiresApproval: boolean;
|
|
277
|
+
approved?: boolean;
|
|
278
|
+
}
|
|
279
|
+
export interface HandoffPayload {
|
|
280
|
+
summary: string;
|
|
281
|
+
artifacts: ArtifactRef[];
|
|
282
|
+
notes?: string;
|
|
283
|
+
data?: Record<string, unknown>;
|
|
284
|
+
}
|
|
285
|
+
export interface ContextDiscoveryResult {
|
|
286
|
+
rootPath: string;
|
|
287
|
+
foundFiles: DiscoveredFile[];
|
|
288
|
+
missingRecommended: string[];
|
|
289
|
+
loadedAt: string;
|
|
290
|
+
}
|
|
291
|
+
export interface DiscoveredFile {
|
|
292
|
+
relativePath: string;
|
|
293
|
+
absolutePath: string;
|
|
294
|
+
category: ContextFileCategory;
|
|
295
|
+
priority: number;
|
|
296
|
+
sizeBytes: number;
|
|
297
|
+
}
|
|
298
|
+
export type ContextFileCategory = 'project' | 'tasks' | 'agents' | 'readme' | 'docs' | 'specs' | 'playbooks' | 'policies' | 'templates' | 'workflows' | 'brand' | 'custom';
|
|
299
|
+
export interface InterviewQuestion {
|
|
300
|
+
id: string;
|
|
301
|
+
question: string;
|
|
302
|
+
hint?: string;
|
|
303
|
+
category: InterviewCategory;
|
|
304
|
+
required: boolean;
|
|
305
|
+
followUpIds?: string[];
|
|
306
|
+
}
|
|
307
|
+
export type InterviewCategory = 'objective' | 'domain' | 'io' | 'steps' | 'approvals' | 'tools' | 'policies' | 'risks' | 'context';
|
|
308
|
+
export interface InterviewAnswer {
|
|
309
|
+
questionId: string;
|
|
310
|
+
answer: string;
|
|
311
|
+
}
|
|
312
|
+
export interface InterviewSession {
|
|
313
|
+
id: string;
|
|
314
|
+
answers: InterviewAnswer[];
|
|
315
|
+
startedAt: string;
|
|
316
|
+
completedAt?: string;
|
|
317
|
+
}
|
|
318
|
+
export interface SquadBuildResult {
|
|
319
|
+
squadDefinition: SquadDefinition;
|
|
320
|
+
generatedFiles: GeneratedFile[];
|
|
321
|
+
warnings: string[];
|
|
322
|
+
}
|
|
323
|
+
export interface GeneratedFile {
|
|
324
|
+
path: string;
|
|
325
|
+
content: string;
|
|
326
|
+
format: 'json' | 'markdown';
|
|
327
|
+
}
|
|
328
|
+
export interface AgentResponse {
|
|
329
|
+
agentId: AgentId;
|
|
330
|
+
stepId: StepId;
|
|
331
|
+
jobId: JobId;
|
|
332
|
+
content: string;
|
|
333
|
+
artifacts: PendingArtifact[];
|
|
334
|
+
handoffSignal?: HandoffSignal;
|
|
335
|
+
approvalNeeded?: boolean;
|
|
336
|
+
approvalReason?: string;
|
|
337
|
+
status: 'success' | 'failure' | 'needs_input' | 'loop_back';
|
|
338
|
+
metadata?: Record<string, unknown>;
|
|
339
|
+
}
|
|
340
|
+
export interface PendingArtifact {
|
|
341
|
+
name: string;
|
|
342
|
+
content: string;
|
|
343
|
+
format: 'json' | 'markdown' | 'text';
|
|
344
|
+
description?: string;
|
|
345
|
+
}
|
|
346
|
+
export interface HandoffSignal {
|
|
347
|
+
targetAgentId: AgentId;
|
|
348
|
+
condition: string;
|
|
349
|
+
payload: Omit<HandoffPayload, 'artifacts'>;
|
|
350
|
+
}
|
|
351
|
+
export interface GuardrailEvaluationContext {
|
|
352
|
+
job: JobDefinition;
|
|
353
|
+
step: WorkflowStep;
|
|
354
|
+
agent: AgentDefinition;
|
|
355
|
+
response?: AgentResponse;
|
|
356
|
+
}
|
|
357
|
+
export interface GuardrailResult {
|
|
358
|
+
guardrailId: GuardrailId;
|
|
359
|
+
passed: boolean;
|
|
360
|
+
severity: GuardrailSeverity;
|
|
361
|
+
message: string;
|
|
362
|
+
blockedTransition?: boolean;
|
|
363
|
+
}
|
|
364
|
+
//# sourceMappingURL=types.d.ts.map
|