refactor: group agent launch contracts under concrete owners (#37915)

This commit is contained in:
Neil
2026-11-03 14:45:49 -08:00
committed by GitHub
parent ad5657a57f
commit d5f2a17cd2
1238 changed files with 2460 additions and 2319 deletions
@@ -1,4 +1,4 @@
import { restoreOrStripOverlayEnv } from '../../shared/agent-overlay-env'
import { restoreOrStripOverlayEnv } from '../../shared/agent-launch/startup/agent-overlay-env'
import { getAppEnvironment } from '../../shared/app-environment'
import { isOpenCodeLegacySharedConfigDir } from './legacy-shared-config-dir'
@@ -3,14 +3,14 @@ import {
getOpenCodeCliCapabilities,
type OpenCodeCliCapabilities
} from '../../shared/opencode-cli-version'
import type { TuiAgent } from '../../shared/tui-agent'
import type { TuiAgent } from '../../shared/agent-launch/catalog/tui-agent'
import { resolveCommandOnLocalPath } from '../ipc/command-path/command-path-resolver'
import { runWslProcess } from '../wsl/execution/wsl-runner'
import { probeOpenCodeCliVersion } from './opencode-cli-version'
import {
getAgentLaunchCommandToken,
getAgentLaunchExecutableName
} from '../../shared/agent-command-line-intent'
} from '../../shared/agent-launch/startup/agent-command-line-intent'
export function getOpenCodeLaunchExecutable(
command: string | undefined,
@@ -1,4 +1,7 @@
import { resolveStartupShell, tokenizeStartupCommand } from '../../shared/tui-agent-startup-shell'
import {
resolveStartupShell,
tokenizeStartupCommand
} from '../../shared/agent-launch/startup/tui-agent-startup-shell'
import { resolveCommandOnLocalPath } from '../ipc/command-path/command-path-resolver'
export async function resolveOpenCodeDirectModelExecutable(options: {
@@ -1,5 +1,5 @@
import { beforeEach, describe, expect, it, vi } from 'vitest'
import { resolveAgentStartupPlanInputs } from '../../shared/agent-startup-plan-inputs'
import { resolveAgentStartupPlanInputs } from '../../shared/agent-launch/startup/agent-startup-plan-inputs'
import { applyManagedDataAccountEnvironment } from '../managed-data-accounts/launch-environment'
import { probeOpenCodeLaunchCapabilities } from './opencode-launch-capabilities'
import { resolveOpenCodeDirectModelExecutable } from './opencode-model-executable'
@@ -9,7 +9,7 @@ import {
OPENCODE_MODEL_CONFIG_REFUSAL,
OPENCODE_MODEL_TRANSPORT_REFUSAL,
OPENCODE_MODEL_VERSION_REFUSAL
} from '../../shared/agent-launch-model-preferences'
} from '../../shared/agent-launch/choices/agent-launch-model-preferences'
vi.mock('../managed-data-accounts/launch-environment', () => ({
applyManagedDataAccountEnvironment: vi.fn()
@@ -1,20 +1,23 @@
import type { AgentStartupPlanInputs } from '../../shared/agent-startup-plan-inputs'
import type { AgentStartupPlanInputs } from '../../shared/agent-launch/startup/agent-startup-plan-inputs'
import {
buildAgentDraftLaunchPlan,
buildAgentStartupPlan,
type AgentStartupPlan
} from '../../shared/tui-agent-startup'
} from '../../shared/agent-launch/startup/tui-agent-startup'
import { planStartupWithPromptCandidate } from '../../shared/startup-line-prompt-carry'
import { buildSleepingAgentLaunchConfig } from '../../shared/sleeping-agent-launch-config'
import type { SleepingAgentLaunchConfig } from '../../shared/agent-session/lifecycle/agent-session-resume'
import type { TuiAgent } from '../../shared/tui-agent'
import type { TuiAgent } from '../../shared/agent-launch/catalog/tui-agent'
import { probeOpenCodeLaunchModelContext } from './opencode-launch-model-context'
import { resolveOpenCodeLaunchModelConfig } from './opencode-launch-model-config'
import {
isVerifiedOpenCodeConfigModelVersion,
isVerifiedOpenCodeLegacyModelVersion
} from './opencode-model-version-policy'
import { getTuiAgentLaunchCommand, TUI_AGENT_CONFIG } from '../../shared/tui-agent-config'
import {
getTuiAgentLaunchCommand,
TUI_AGENT_CONFIG
} from '../../shared/agent-launch/catalog/tui-agent-config'
import { applyManagedDataAccountEnvironment } from '../managed-data-accounts/launch-environment'
import { OrchestrationError } from '../runtime/orchestration/orchestration-error'
import { probeOpenCodeLaunchCapabilities } from './opencode-launch-capabilities'
@@ -23,7 +26,7 @@ import {
OPENCODE_MODEL_CONFIG_REFUSAL,
OPENCODE_MODEL_TRANSPORT_REFUSAL,
OPENCODE_MODEL_VERSION_REFUSAL
} from '../../shared/agent-launch-model-preferences'
} from '../../shared/agent-launch/choices/agent-launch-model-preferences'
type StartupScope = {
inputs: AgentStartupPlanInputs
+1 -1
View File
@@ -8,7 +8,7 @@ import { findOpenCodeRunCommand } from '../../shared/opencode-headless-command'
import {
tokenizeStartupCommand,
type AgentStartupShell
} from '../../shared/tui-agent-startup-shell'
} from '../../shared/agent-launch/startup/tui-agent-startup-shell'
import { managedAccountLaunchEnvironment } from '../managed-data-accounts/launch-environment'
import { getManagedDataAccountService } from '../managed-data-accounts/service'
@@ -10,7 +10,7 @@ import {
OPENCODE_STARTUP_PROMPT_SHA256_ENV,
OPENCODE_STARTUP_PROMPT_BODY_ENV,
OPENCODE_STARTUP_PROMPT_SHELL_ENV
} from '../../shared/opencode-startup-prompt'
} from '../../shared/agent-launch/startup/opencode-startup-prompt'
import {
buildLocalPtySpawnEnvironment,
enforceLocalPtySpawnEnvironmentOverrides
+3 -3
View File
@@ -1,11 +1,11 @@
import { addWslEnvKeys } from '../../shared/wsl-env'
import type { TuiAgent } from '../../shared/tui-agent'
import type { TuiAgent } from '../../shared/agent-launch/catalog/tui-agent'
import { randomUUID, createHash } from 'node:crypto'
import { agentHookServer } from '../agent-hooks/server'
import {
tokenizeStartupCommand,
type AgentStartupShell
} from '../../shared/tui-agent-startup-shell'
} from '../../shared/agent-launch/startup/tui-agent-startup-shell'
import { isOpenCodeRunCommand } from '../../shared/opencode-headless-command'
import {
OPENCODE_STARTUP_PROMPT_SHA256_ENV,
@@ -13,7 +13,7 @@ import {
OPENCODE_STARTUP_PROMPT_ENDPOINT_ENV,
OPENCODE_STARTUP_PROMPT_BODY_ENV,
OPENCODE_STARTUP_PROMPT_SHELL_ENV
} from '../../shared/opencode-startup-prompt'
} from '../../shared/agent-launch/startup/opencode-startup-prompt'
const intentKeys = [
OPENCODE_STARTUP_PROMPT_SHA256_ENV,
@@ -10,7 +10,7 @@ import {
OPENCODE_STARTUP_PROMPT_SHA256_ENV,
OPENCODE_STARTUP_PROMPT_BODY_ENV,
OPENCODE_STARTUP_PROMPT_ENDPOINT_ENV
} from '../../shared/opencode-startup-prompt'
} from '../../shared/agent-launch/startup/opencode-startup-prompt'
export function createOpenCodeStartupPromptInstaller(source: () => string): OpenCodeHookService {
return new OpenCodeHookService({
@@ -8,7 +8,7 @@ import { isPtyIncarnationId } from '../../shared/pty-incarnation'
import {
OPENCODE_STARTUP_PROMPT_NONCE_ENV,
OPENCODE_STARTUP_PROMPT_SHA256_ENV
} from '../../shared/opencode-startup-prompt'
} from '../../shared/agent-launch/startup/opencode-startup-prompt'
import { OpenCodeStartupPromptClaims } from './opencode-startup-prompt-claims'
type OpenCodePromptRuntime = Pick<
@@ -11,7 +11,7 @@ import {
OPENCODE_STARTUP_PROMPT_NONCE_ENV,
OPENCODE_STARTUP_PROMPT_BODY_ENV,
OPENCODE_STARTUP_PROMPT_ENDPOINT_ENV
} from '../../shared/opencode-startup-prompt'
} from '../../shared/agent-launch/startup/opencode-startup-prompt'
import { getOpenCodeStartupPromptSource } from './opencode-startup-prompt-source'
import { OpenCodeStartupPromptClaims } from './opencode-startup-prompt-claims'
@@ -7,7 +7,7 @@ import {
OPENCODE_STARTUP_PROMPT_ENDPOINT_ENV,
OPENCODE_STARTUP_PROMPT_CLAIM_PATH,
OPENCODE_STARTUP_PROMPT_BODY_ENV
} from '../../shared/opencode-startup-prompt'
} from '../../shared/agent-launch/startup/opencode-startup-prompt'
export function getOpenCodeStartupPromptSource(): string {
return String.raw`