import { analyzeRepository } from './kernel/analyze.mjs'; import { BacklogService } from './backlog/service.mjs'; import { ArtifactService } from './artifacts/service.mjs'; import { createClaudeAdapter } from './adapters/claude.mjs'; import { createRuntimeAdapterRegistry } from './adapters/registry.mjs'; import { planProviderUpdates, updateProviders } from './adapters/updates.mjs'; import { profileCapabilityIssues, resolveLaunchPolicy } from './adapters/runtime.mjs'; import { inspectRuntimePluginTrust, planRuntimePluginRevoke, planRuntimePluginTrust, revokeRuntimePlugin, runtimePluginTrustPath, trustRuntimePlugin, } from './adapters/plugins.mjs'; import { CheckService } from './checks/service.mjs'; import { startConsole } from './console/server.mjs'; import { classifyRecoverability, createLocalCanonical, planLocalCanonical } from './canonical/local.mjs'; import { openControlPlane } from './control-plane/service.mjs'; import { fetchCanonicalObjects, planCanonicalFetch } from './canonical/fetch.mjs'; import { spawn as spawnProcess, spawnSync } from 'node:child_process'; import { randomUUID } from 'node:crypto'; import { mkdirSync, mkdtempSync, renameSync, rmSync, statSync, writeFileSync, } from 'node:fs'; import { tmpdir } from 'node:os'; import { diagnoseProject } from './kernel/doctor.mjs'; import { loadProjectConfig, validateProjectConfig } from './kernel/config.mjs'; import { asErrorRecord, TorchError } from './kernel/errors.mjs'; import { inspectRepository } from './kernel/git.mjs'; import { resolveInstalledProjectRoot } from './kernel/project-root.mjs'; import { setupProject, restoreProject } from './kernel/setup.mjs'; import { inspectSpecifications } from './kernel/specifications.mjs'; import { installProject, planInstall, uninstallProject } from './kernel/install.mjs'; import { IntegrationService } from './integration/service.mjs'; import { analyzeCombatrigFleet } from './importers/combatrig.mjs'; import { proposeDomains } from './kernel/domains.mjs'; import { readFileSync } from 'node:fs'; import { fileURLToPath } from 'node:url'; import { join, resolve } from 'node:path'; import { fileHash, writeNewFile } from './kernel/files.mjs'; import { createWorktrees, planWorktrees } from './kernel/worktrees.mjs'; import { captureFleet, createFleetBrief, detachFleet, planAreaUp, planFleetDetach, planFleetDown, planFleetUp, startFleet, stopFleet, } from './runtime/lifecycle.mjs'; import { ResourceService } from './resources/service.mjs'; import { CANDIDATE_ACCEPTANCE_SCENARIOS, createVersionService } from './self-host/service.mjs'; import { observeProject } from './observability/snapshot.mjs'; // Provider output is evidence, not an unbounded artifact channel. startFleet // classifies ENOBUFS as an interrupted outcome instead of a completed turn. const MAX_RUNTIME_EXECUTOR_OUTPUT_BYTES = 1024 * 1024; const CODEX_PROTOCOL_REDUCER = fileURLToPath(new URL('./runtime/codex-protocol-reducer.mjs', import.meta.url)); export function executeRuntimeLaunch(spawn, launch, options = {}) { // Tests and adapter qualification inject a deterministic executor. The real // synchronous CLI boundary alone needs protocol reduction before buffering. // A tagged guard may delegate to native spawnSync after asserting hermetic // launch preconditions; it must opt in rather than changing fake executors. const usesNativeSpawn = spawn === spawnSync || spawn?.torchNativeSpawnGuard === true; if (launch.runtime === 'codex' && usesNativeSpawn) { return spawn(process.execPath, [CODEX_PROTOCOL_REDUCER, launch.command, ...launch.args], options); } return spawn(launch.command, launch.args, options); } import { OwnerDigestService } from './observability/owner-digest.mjs'; import { ContextTelemetryService } from './telemetry/context.mjs'; import { ScheduleService } from './schedules/service.mjs'; import { assertLauncherDigest, ScheduleLauncherService } from './schedules/launcher.mjs'; import { createFleetDesignBrief } from './design/brief.mjs'; import { createArchitectRunPlan, loadArchitectArtifact, runSessionArchitect, validateArchitectProposal, } from './design/architect.mjs'; import { FleetEvolutionService } from './evolution/service.mjs'; import { HierarchyEvolutionService } from './evolution/hierarchy.mjs'; import { issueStoppedExecutorEvidence } from './runtime/stopped-executor-evidence.mjs'; import { configureContinuation, planContinuation, runContinuation } from './runtime/continuation.mjs'; import { ConvergenceService } from './convergence/service.mjs'; import { attachForge, detachForge, forgeStatus, planForgeAttach, planForgeDetach, planForgeSync, syncForgeRemote, } from './forge/service.mjs'; import { configureDelivery, DeliveryService, planDeliveryConfiguration, } from './delivery/service.mjs'; const HELP = `TORCH — portable agent fleet Usage: torch init [--repo ] [--spec ] [--json] torch analyze [--repo ] [--spec ] [--json] torch design [--repo ] [--spec ] [--output ] [--json] torch bootstrap [--repo ] [--spec ] [--output ] [--json] torch architect plan --brief --provider [--model ] [--max-budget-usd ] [--json] torch architect validate --brief --response [--json] torch architect run --brief --provider --output [--model ] [--max-budget-usd ] --yes [--json] torch domains [--repo ] [--spec ] [--output ] [--json] torch install --proposal [--runtime ] [--default-runtime ] [--update-runtimes] [--dry-run] [--yes] [--json] torch worktrees [--parent ] [--dry-run] [--yes] [--json] torch install --restore [--dry-run] [--yes] [--json] torch setup [--parent ] [--dry-run] [--yes] [--json] torch up [--fresh] [--only ] [--dry-run] [--yes] [--json] torch recover-runtime --area --unit --invocation [--expected-session --expected-updated-at