{"version":3,"file":"vetra-s8gWslse.mjs","sources":["../src/utils/configure-vetra-github-url.ts","../src/utils/resolve-switchboard-port.ts","../src/utils/vetra-runtime.ts","../src/services/vetra.ts"],"sourcesContent":["import {\n  createVetraDocument,\n  getVetraDocuments,\n  setPackageGithubUrl,\n} from \"@powerhousedao/common/utils\";\nimport { red } from \"colorette\";\nimport { execSync } from \"node:child_process\";\nimport { createInterface } from \"node:readline\";\n\n/**\n * Get git remote URL (origin)\n * @returns Git remote URL or null if not configured\n */\nfunction getGitRemoteUrl(): string | null {\n  try {\n    const url = execSync(\"git remote get-url origin\", {\n      encoding: \"utf-8\",\n      stdio: [\"pipe\", \"pipe\", \"pipe\"],\n    }).trim();\n    return url || null;\n  } catch {\n    return null;\n  }\n}\n\n/**\n * Prompt user to enter a custom GitHub URL\n */\nasync function promptForCustomUrl(): Promise<string | null> {\n  return new Promise((resolve) => {\n    const rl = createInterface({\n      input: process.stdin,\n      output: process.stdout,\n    });\n\n    process.stdout.write(\"\\nEnter GitHub URL (or press Enter to skip): \");\n\n    rl.on(\"line\", (answer: string) => {\n      rl.close();\n      const url = answer.trim();\n      resolve(url || null);\n    });\n  });\n}\n\n/**\n * Prompt yes/no question\n */\nasync function promptYesNo(question: string): Promise<boolean> {\n  return new Promise((resolve) => {\n    const rl = createInterface({\n      input: process.stdin,\n      output: process.stdout,\n    });\n\n    process.stdout.write(`\\n${question} (y/n): `);\n\n    rl.on(\"line\", (answer: string) => {\n      rl.close();\n      const response = answer.trim().toLowerCase();\n      resolve(response === \"y\" || response === \"yes\");\n    });\n  });\n}\n\n/**\n * Prompt user to select or enter GitHub URL\n * @param gitRemoteUrl - Git remote URL if available\n * @returns Selected URL or null if skipped\n */\nasync function promptForGithubUrl(\n  gitRemoteUrl: string | null,\n): Promise<string | null> {\n  return new Promise((resolve) => {\n    const rl = createInterface({\n      input: process.stdin,\n      output: process.stdout,\n    });\n\n    console.log(\"\\n\" + \"=\".repeat(50));\n    console.log(\"🔍 Vetra Package Configuration\");\n    console.log(\"=\".repeat(50));\n    console.log(\n      \"\\nWe detected a Vetra package document in your remote drive without a GitHub URL configured.\",\n    );\n    console.log(\"\\nWould you like to configure the GitHub URL now?\");\n\n    if (gitRemoteUrl) {\n      console.log(`\\nGit remote URL detected: ${gitRemoteUrl}`);\n      console.log(\"\\nOptions:\");\n      console.log(\"1. Use detected URL\");\n      console.log(\"2. Enter a different URL\");\n      console.log(\"3. Skip configuration\");\n\n      process.stdout.write(\"\\nSelect an option (1-3): \");\n\n      const handleAnswer = (answer: string) => {\n        const choice = answer.trim();\n\n        if (choice === \"1\") {\n          rl.close();\n          resolve(gitRemoteUrl);\n        } else if (choice === \"2\") {\n          rl.close();\n          promptForCustomUrl()\n            .then(resolve)\n            .catch(() => resolve(null));\n        } else if (choice === \"3\") {\n          rl.close();\n          resolve(null);\n        } else {\n          process.stdout.write(\"Invalid choice. Select an option (1-3): \");\n        }\n      };\n\n      rl.on(\"line\", handleAnswer);\n    } else {\n      console.log(\"\\nNo git remote URL detected.\");\n      console.log(\"\\nOptions:\");\n      console.log(\"1. Enter GitHub URL manually\");\n      console.log(\"2. Skip configuration\");\n\n      process.stdout.write(\"\\nSelect an option (1-2): \");\n\n      const handleAnswer = (answer: string) => {\n        const choice = answer.trim();\n\n        if (choice === \"1\") {\n          rl.close();\n          promptForCustomUrl()\n            .then(resolve)\n            .catch(() => resolve(null));\n        } else if (choice === \"2\") {\n          rl.close();\n          resolve(null);\n        } else {\n          process.stdout.write(\"Invalid choice. Select an option (1-2): \");\n        }\n      };\n\n      rl.on(\"line\", handleAnswer);\n    }\n  });\n}\n\n/**\n * Set git remote URL (origin)\n */\nfunction setGitRemoteUrl(url: string): void {\n  try {\n    execSync(`git remote add origin ${url}`, {\n      stdio: \"inherit\",\n    });\n    console.log(`✅ Git remote origin set to: ${url}`);\n  } catch {\n    try {\n      execSync(`git remote set-url origin ${url}`, {\n        stdio: \"inherit\",\n      });\n      console.log(`✅ Git remote origin updated to: ${url}`);\n    } catch {\n      console.error(red(`❌ Failed to set git remote URL`));\n    }\n  }\n}\n\n/**\n * Validates documents and returns the target document to use\n * Warns if multiple documents found\n */\nfunction validateAndSelectDocument<T>(documents: T[]): T | null {\n  if (documents.length === 0) {\n    return null;\n  }\n\n  if (documents.length > 1) {\n    console.warn(\n      `⚠️  Warning: Multiple Vetra documents found (${documents.length}). Using first document.`,\n    );\n  }\n\n  return documents[0];\n}\n\nasync function applyGithubUrlConfiguration(\n  graphqlEndpoint: string,\n  vetraDriveId: string,\n  documentId: string,\n  selectedUrl: string,\n  shouldSetRemote: boolean,\n): Promise<void> {\n  // Set package GitHub URL\n  await setPackageGithubUrl(\n    graphqlEndpoint,\n    vetraDriveId,\n    documentId,\n    selectedUrl,\n  );\n\n  console.log(`✅ GitHub URL configured: ${selectedUrl}`);\n\n  // Set git remote URL if requested\n  if (shouldSetRemote) {\n    setGitRemoteUrl(selectedUrl);\n  }\n}\n\nfunction logVerbose(message: string, verbose?: boolean): void {\n  if (verbose) {\n    console.log(message);\n  }\n}\n\n/**\n * Sleep for a specified number of milliseconds\n */\nexport function sleep(ms: number): Promise<void> {\n  return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\n/**\n * Configure GitHub URL for Vetra documents\n * @param switchboardPort - Port where switchboard is running\n * @param vetraDriveUrl - Remote drive URL\n * @param verbose - Enable verbose logging\n */\nexport async function configureVetraGithubUrl(\n  switchboardPort: number,\n  vetraDriveUrl: string,\n  verbose?: boolean,\n): Promise<void> {\n  logVerbose(\"Checking GitHub URL configuration...\", verbose);\n\n  try {\n    const graphqlEndpoint = `http://localhost:${switchboardPort}/graphql`;\n    const vetraDriveId = vetraDriveUrl.split(\"/\").pop();\n    if (!vetraDriveId) {\n      throw new Error(\"Invalid vetraDriveUrl: unable to extract drive ID\");\n    }\n\n    const documents = await getVetraDocuments(graphqlEndpoint, vetraDriveId);\n\n    // Skip if already configured\n    if (documents.some((doc) => doc.githubUrl)) {\n      logVerbose(\"GitHub URL already configured, skipping setup\", verbose);\n      return;\n    }\n\n    // Get or create target document\n    let targetDocumentId: string;\n    const targetDocument = validateAndSelectDocument(documents);\n\n    // Collect user input\n    const gitRemoteUrl = getGitRemoteUrl();\n    const selectedUrl = await promptForGithubUrl(gitRemoteUrl);\n\n    if (!selectedUrl) {\n      logVerbose(\"GitHub URL configuration skipped\", verbose);\n      return;\n    }\n\n    let shouldSetRemote = false;\n    if (selectedUrl !== gitRemoteUrl && !gitRemoteUrl) {\n      shouldSetRemote = await promptYesNo(\"Set this as your git remote URL?\");\n    }\n\n    if (!targetDocument) {\n      logVerbose(\"No Vetra documents found, creating new document...\", verbose);\n\n      targetDocumentId = await createVetraDocument(\n        graphqlEndpoint,\n        vetraDriveId,\n        \"vetra-package\",\n      );\n\n      logVerbose(`Created new document: ${targetDocumentId}`, verbose);\n    } else {\n      targetDocumentId = targetDocument.id;\n    }\n\n    await applyGithubUrlConfiguration(\n      graphqlEndpoint,\n      vetraDriveId,\n      targetDocumentId,\n      selectedUrl,\n      shouldSetRemote,\n    );\n  } catch (error) {\n    console.error(\n      red(\n        `⚠️  GitHub URL configuration failed: ${error instanceof Error ? error.message : String(error)}`,\n      ),\n    );\n    logVerbose(String(error), verbose);\n  }\n}\n","import { isPortAvailable } from \"@powerhousedao/switchboard/server\";\nimport { yellow } from \"colorette\";\n\nconst MAX_FALLBACK_ATTEMPTS = 20;\n\nfunction isInteractive(): boolean {\n  return Boolean(process.stdin.isTTY) && !process.env.CI;\n}\n\nasync function findFreePort(start: number): Promise<number | null> {\n  for (let i = 0; i < MAX_FALLBACK_ATTEMPTS; i++) {\n    const candidate = start + i;\n    if (await isPortAvailable(candidate)) return candidate;\n  }\n  return null;\n}\n\n/**\n * Resolve the port switchboard should bind to. If the requested port is free,\n * returns it unchanged. If it's in use, walks forward for the next free port\n * and — in an interactive terminal — asks the user to confirm the fallback.\n * In CI / piped contexts the fallback is applied automatically so scripts\n * don't hang on an unanswered prompt.\n *\n * Throws a process.exit(1) when the user declines the prompt or when no free\n * port is available in the search window.\n */\nexport async function resolveSwitchboardPort(\n  requested: number,\n): Promise<number> {\n  if (await isPortAvailable(requested)) return requested;\n\n  const candidate = await findFreePort(requested + 1);\n  if (candidate === null) {\n    console.error(\n      `Port ${requested} is in use and no free port was found in the range ${requested}-${requested + MAX_FALLBACK_ATTEMPTS - 1}.`,\n    );\n    process.exit(1);\n  }\n\n  if (!isInteractive()) {\n    console.log(\n      yellow(\n        `Port ${requested} is in use. Falling back to port ${candidate} (non-interactive; skipping confirmation).`,\n      ),\n    );\n    return candidate;\n  }\n\n  const enquirer = await import(\"enquirer\");\n\n  let confirmed: boolean;\n  try {\n    const answer = await enquirer.default.prompt<{ confirmed: boolean }>({\n      type: \"confirm\",\n      name: \"confirmed\",\n      message: `Port ${requested} is in use. Use port ${candidate} instead?`,\n      initial: true,\n    });\n    confirmed = answer.confirmed;\n  } catch {\n    // user aborted the prompt (Ctrl-C); treat as decline\n    confirmed = false;\n  }\n\n  if (!confirmed) {\n    console.error(\n      `Aborted. Free port ${requested} or pass --switchboard-port <port> to choose a different port.`,\n    );\n    process.exit(1);\n  }\n\n  return candidate;\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\n\nexport type VetraRuntimeRecord = {\n  pid: number;\n  projectName: string;\n  switchboardPort: number;\n  connectPort: number;\n  mcpUrl: string;\n  startedAt: string;\n};\n\nexport type VetraProbe =\n  | { status: \"none\" }\n  | { status: \"stale\" }\n  | { status: \"live\"; record: VetraRuntimeRecord }\n  | { status: \"foreign\"; record: VetraRuntimeRecord };\n\nconst RECORD_REL = path.join(\".ph\", \"vetra-runtime.json\");\nconst READY_TIMEOUT_MS = 2000;\n\nconst recordPath = (projectDir: string) => path.join(projectDir, RECORD_REL);\n\nexport function readVetraRuntime(\n  projectDir: string,\n): VetraRuntimeRecord | undefined {\n  try {\n    return JSON.parse(\n      fs.readFileSync(recordPath(projectDir), \"utf8\"),\n    ) as VetraRuntimeRecord;\n  } catch {\n    // Missing or corrupt: either way there is no usable record.\n    return undefined;\n  }\n}\n\nexport function writeVetraRuntime(\n  projectDir: string,\n  record: VetraRuntimeRecord,\n): void {\n  const target = recordPath(projectDir);\n  fs.mkdirSync(path.dirname(target), { recursive: true });\n  fs.writeFileSync(target, `${JSON.stringify(record, null, 2)}\\n`);\n}\n\nexport function clearVetraRuntime(projectDir: string): void {\n  try {\n    fs.rmSync(recordPath(projectDir));\n  } catch {\n    // Already gone.\n  }\n}\n\nfunction isPidAlive(pid: number): boolean {\n  try {\n    process.kill(pid, 0);\n    return true;\n  } catch (error) {\n    // EPERM means the process exists but belongs to another user.\n    return (error as NodeJS.ErrnoException).code === \"EPERM\";\n  }\n}\n\nasync function isReady(port: number): Promise<boolean> {\n  try {\n    const response = await fetch(`http://localhost:${port}/ready`, {\n      signal: AbortSignal.timeout(READY_TIMEOUT_MS),\n    });\n    return response.ok;\n  } catch {\n    return false;\n  }\n}\n\n/**\n * Decide whether the recorded instance is actually serving this project.\n *\n * All three checks are load-bearing. A pid can be reused by an unrelated\n * process, so a live pid proves nothing on its own. Another project's\n * switchboard would answer `/ready` on its own port, so a healthy `/ready`\n * proves nothing either. And the recorded `projectName` is what separates\n * \"my instance\" from \"someone else's instance that happens to hold this\n * port\" — which is precisely the confusion that let an agent write document\n * models into a different project's drive.\n *\n * A stale record is deleted so the next start is unblocked. A foreign one is\n * left alone: it describes something that is alive.\n */\nexport async function probeVetraRuntime(\n  projectDir: string,\n  projectName: string,\n): Promise<VetraProbe> {\n  const record = readVetraRuntime(projectDir);\n  if (!record) return { status: \"none\" };\n\n  if (!isPidAlive(record.pid) || !(await isReady(record.switchboardPort))) {\n    clearVetraRuntime(projectDir);\n    return { status: \"stale\" };\n  }\n\n  if (record.projectName !== projectName) {\n    return { status: \"foreign\", record };\n  }\n  return { status: \"live\", record };\n}\n\nconst MCP_FILES = [\".mcp.json\", path.join(\".cursor\", \"mcp.json\")];\n\n/**\n * Point every generated MCP config at `port`, returning the files changed.\n *\n * An MCP client resolves these files at session start and cannot read the\n * project config or `.env`, so when an override moves the port the literal\n * has to be corrected on disk. Rewrites in place rather than regenerating,\n * so any other servers or hand-added keys survive.\n */\nexport function syncMcpPort(projectDir: string, port: number): string[] {\n  const changed: string[] = [];\n  for (const rel of MCP_FILES) {\n    const target = path.join(projectDir, rel);\n    if (!fs.existsSync(target)) continue;\n\n    let parsed: { mcpServers?: Record<string, { url?: string }> };\n    try {\n      parsed = JSON.parse(fs.readFileSync(target, \"utf8\")) as typeof parsed;\n    } catch {\n      // Hand-broken JSON is the author's to fix; don't clobber it.\n      continue;\n    }\n\n    const server = parsed.mcpServers?.[\"reactor-mcp\"];\n    if (!server?.url) continue;\n\n    const wanted = `http://localhost:${port}/mcp`;\n    if (server.url === wanted) continue;\n\n    server.url = wanted;\n    fs.writeFileSync(target, `${JSON.stringify(parsed, null, 2)}\\n`);\n    changed.push(rel);\n  }\n  return changed;\n}\n","import type { VetraProcessorConfigType } from \"@powerhousedao/config\";\nimport { VETRA_PROCESSOR_CONFIG_KEY } from \"@powerhousedao/config\";\nimport type { IReactorClient } from \"@powerhousedao/reactor\";\nimport { getConfig } from \"@powerhousedao/shared/clis\";\nimport { addDefaultDrive } from \"@powerhousedao/switchboard/utils\";\nimport { join } from \"node:path\";\nimport { blue, green, red, yellow, type Color } from \"colorette\";\nimport type { ILogger } from \"document-model\";\nimport { childLogger, setLogLevel } from \"document-model\";\nimport { createLogger } from \"vite\";\nimport type { VetraArgs } from \"../types.js\";\nimport { generateProjectDriveId, POWERHOUSE_CONFIG_FILE } from \"../utils.js\";\nimport { wasFlagExplicitlyPassed } from \"../utils/cli-connect-override.js\";\nimport {\n  configureVetraGithubUrl,\n  sleep,\n} from \"../utils/configure-vetra-github-url.js\";\nimport { mergeDefaultDrives } from \"../utils/merge-default-drives.js\";\nimport { parseDefaultDrivesUrl } from \"../utils/parse-default-drives.js\";\nimport { resolveSwitchboardPort } from \"../utils/resolve-switchboard-port.js\";\nimport {\n  clearVetraRuntime,\n  probeVetraRuntime,\n  syncMcpPort,\n  writeVetraRuntime,\n} from \"../utils/vetra-runtime.js\";\nimport { runConnectStudio } from \"./connect-studio.js\";\nimport { startSwitchboard } from \"./switchboard.js\";\n\nconst VETRA_DRIVE_NAME = \"vetra\";\n\nconst getDefaultVetraUrl = (port: number) =>\n  `http://localhost:${port}/d/${generateProjectDriveId(VETRA_DRIVE_NAME)}`;\n\nconst getDriveId = (driveUrl: string | undefined): string =>\n  driveUrl?.split(\"/\").pop() ?? generateProjectDriveId(VETRA_DRIVE_NAME);\n\n// Rebase a local drive URL onto --drives-public-base: keeps the /d/<slug>\n// path, swaps the loopback origin for the public base. Browser clients\n// behind a reverse proxy can't reach http://localhost:<port>. Non-loopback\n// URLs (e.g. a remote drive) are already public and pass through unchanged.\nconst rebaseDriveUrl = (driveUrl: string, publicBase: string): string => {\n  // Unparseable URLs pass through unchanged, like non-loopback ones.\n  let url: URL;\n  try {\n    url = new URL(driveUrl);\n  } catch {\n    return driveUrl;\n  }\n  if (![\"localhost\", \"127.0.0.1\", \"[::1]\"].includes(url.hostname)) {\n    return driveUrl;\n  }\n  return `${publicBase.replace(/\\/+$/, \"\")}${url.pathname}`;\n};\n\nfunction createViteLogger(color: Color) {\n  const customLogger = createLogger(\"info\");\n  const loggerInfo = customLogger.info.bind(customLogger);\n  customLogger.info = (msg, options) => {\n    loggerInfo(color(msg), options);\n  };\n  const loggerWarn = customLogger.warn.bind(customLogger);\n  customLogger.warn = (msg, options) => {\n    loggerWarn(yellow(msg), options);\n  };\n  const loggerError = customLogger.error.bind(customLogger);\n  customLogger.error = (msg, options) => {\n    loggerError(red(msg), options);\n  };\n\n  const loggerWarnOnce = customLogger.warnOnce.bind(customLogger);\n  customLogger.warnOnce = (msg, options) => {\n    loggerWarnOnce(yellow(msg), options);\n  };\n  return customLogger;\n}\n\nasync function startVetraPreviewDrive(\n  reactor: IReactorClient,\n  port: number,\n  verbose?: boolean,\n): Promise<string> {\n  const previewDriveId = generateProjectDriveId(\"preview\");\n\n  const previewDrive = {\n    id: previewDriveId,\n    slug: previewDriveId,\n    global: {\n      name: \"Vetra Preview\",\n      icon: \"https://azure-elderly-tortoise-212.mypinata.cloud/ipfs/bafkreifddkbopiyvcirf7vaqar74th424r5phlxkdxniirdyg3qgu2ajha\",\n      nodes: [],\n    },\n    local: {\n      availableOffline: true,\n      listeners: [],\n      sharingType: \"public\" as const,\n      triggers: [],\n    },\n  };\n\n  const driveUrl = await addDefaultDrive(reactor, previewDrive, port);\n\n  if (verbose) {\n    console.log(blue(`Vetra Switchboard: Preview drive: ${driveUrl}`));\n  }\n  return driveUrl;\n}\n\n// Opens in Workflow Studio; only seeded when the switchboard runs workflows.\nasync function startVetraWorkflowsDrive(\n  reactor: IReactorClient,\n  port: number,\n  verbose?: boolean,\n): Promise<string> {\n  const workflowsDrive = {\n    id: generateProjectDriveId(\"workflows\"),\n    slug: \"workflows\",\n    global: { name: \"Workflows\" },\n    preferredEditor: \"workflow-studio\",\n    local: {\n      availableOffline: true,\n      listeners: [],\n      sharingType: \"public\" as const,\n      triggers: [],\n    },\n  };\n\n  const driveUrl = await addDefaultDrive(reactor, workflowsDrive, port);\n\n  if (verbose) {\n    console.log(blue(`Vetra Switchboard: Workflows drive: ${driveUrl}`));\n  }\n  return driveUrl;\n}\nasync function startLocalVetraSwitchboard(args: VetraArgs, logger?: ILogger) {\n  const {\n    connectPort,\n    switchboardPort,\n    dev,\n    packages,\n    disableLocalPackages,\n    debug,\n    httpsKeyFile,\n    httpsCertFile,\n    remoteDrive,\n    interactive,\n    watch,\n    verbose,\n  } = args;\n\n  // Convert single remote drive to array if provided\n  const remoteDrives = remoteDrive ? [remoteDrive] : [];\n\n  const vetraProcessorConfig: VetraProcessorConfigType = {\n    interactive,\n    driveUrl: remoteDrive ?? getDefaultVetraUrl(connectPort),\n    driveId: getDriveId(remoteDrive),\n  };\n\n  const processorConfig = new Map<string, unknown>();\n  processorConfig.set(VETRA_PROCESSOR_CONFIG_KEY, vetraProcessorConfig);\n\n  const vetraDriveId = generateProjectDriveId(VETRA_DRIVE_NAME);\n\n  // When the user didn't opt into strict-port semantics, check for a port\n  // conflict up front and ask for confirmation before binding a fallback.\n  // Doing this in the CLI layer keeps the interactive prompt out of the\n  // switchboard server package and aligns with the existing prerelease-tag\n  // confirmation flow in `ph publish`.\n  const resolvedSwitchboardPort = args.strictPort\n    ? switchboardPort\n    : await resolveSwitchboardPort(switchboardPort);\n\n  try {\n    const switchboard = await startSwitchboard(\n      {\n        ...args,\n        useVetraDrive: true, // Use Vetra drive instead of Powerhouse drive\n        mcp: true,\n        port: resolvedSwitchboardPort,\n        // We've already probed and (when interactive) confirmed the port with\n        // the user, so keep the server from running its own fallback on top.\n        strictPort: true,\n        dev,\n        packages,\n        remoteDrives,\n        vetraDriveId,\n        disableLocalPackages,\n        debug,\n        httpsKeyFile,\n        httpsCertFile,\n        processorConfig,\n        basePath: undefined,\n        keypairPath: undefined,\n        dbPath: args.dbPath,\n        useIdentity: undefined,\n        migrate: undefined,\n        migrateStatus: undefined,\n        reset: undefined,\n        yes: undefined,\n        requireIdentity: undefined,\n      },\n      logger,\n    );\n\n    const actualSwitchboardPort = switchboard.port;\n\n    // Add preview drive (only in watch mode)\n    let previewDriveUrl: string | null = null;\n    if (watch) {\n      try {\n        previewDriveUrl = await startVetraPreviewDrive(\n          switchboard.reactor,\n          actualSwitchboardPort,\n          verbose,\n        );\n      } catch (error) {\n        console.error(error);\n      }\n    }\n\n    let workflowsDriveUrl: string | null = null;\n    if (switchboard.workflowsEnabled) {\n      try {\n        workflowsDriveUrl = await startVetraWorkflowsDrive(\n          switchboard.reactor,\n          actualSwitchboardPort,\n          verbose,\n        );\n      } catch (error) {\n        console.error(error);\n      }\n    }\n\n    if (verbose) {\n      console.log(blue(`Vetra Switchboard: Started successfully`));\n      if (remoteDrive) {\n        console.log(\n          blue(`Vetra Switchboard: Syncing with remote drive: ${remoteDrive}`),\n        );\n      }\n    } else {\n      console.log();\n      console.log(\n        blue(\n          `Vetra Switchboard: http://localhost:${actualSwitchboardPort}/graphql`,\n        ),\n      );\n      console.log(blue(`   ➜ Drive URL: ${switchboard.defaultDriveUrl}`));\n      if (previewDriveUrl) {\n        console.log(blue(`   ➜ Preview Drive URL: ${previewDriveUrl}`));\n      }\n      if (workflowsDriveUrl) {\n        console.log(blue(`   ➜ Workflows Drive URL: ${workflowsDriveUrl}`));\n      }\n    }\n    return {\n      driveUrl: switchboard.defaultDriveUrl || \"\",\n      previewDriveUrl: previewDriveUrl,\n      workflowsDriveUrl,\n      switchboardPort: actualSwitchboardPort,\n    };\n  } catch (error) {\n    console.error(\n      red(\n        `Vetra Switchboard: ${error instanceof Error ? error.message : String(error)}`,\n      ),\n    );\n    throw error instanceof Error ? error : new Error(String(error));\n  }\n}\n\nexport async function startVetra(args: VetraArgs) {\n  const {\n    connectPort,\n    verbose,\n    remoteDrive,\n    disableConnect,\n    debug,\n    httpsCertFile,\n    httpsKeyFile,\n    disableLocalPackages,\n    host,\n    open,\n    cors,\n    strictPort,\n    printUrls,\n    bindCLIShortcuts,\n    watchTimeout,\n  } = args;\n\n  const switchboardLogger = childLogger([\"vetra\", \"switchboard\"]);\n\n  // One Vetra per project. Two instances over one working tree would contend\n  // for the same `.ph/read-model.db` and `.ph/reactor-storage`, and leave the\n  // project with two drives that diverge.\n  const projectDir = process.cwd();\n  const { readPackageSync } = await import(\"read-pkg\");\n  const projectName = readPackageSync({ cwd: projectDir }).name;\n  const probe = await probeVetraRuntime(projectDir, projectName);\n\n  if (probe.status === \"live\") {\n    console.log();\n    console.log(green(\"Vetra is already running for this project.\"));\n    console.log(\n      green(`   ➜ Connect:     http://localhost:${probe.record.connectPort}`),\n    );\n    console.log(\n      green(\n        `   ➜ Switchboard: http://localhost:${probe.record.switchboardPort}/graphql`,\n      ),\n    );\n    console.log(\n      `Stop that instance (pid ${probe.record.pid}) if you need to restart it.`,\n    );\n    return;\n  }\n\n  if (probe.status === \"foreign\") {\n    console.error(\n      red(\n        `.ph/vetra-runtime.json describes a live Vetra for \"${probe.record.projectName}\", ` +\n          `but this project is \"${projectName}\". Refusing to start a second instance. ` +\n          `Delete .ph/vetra-runtime.json if that record is wrong.`,\n      ),\n    );\n    process.exit(1);\n  }\n\n  try {\n    // Set default log level to info if not already specified\n    if (!process.env.LOG_LEVEL) {\n      setLogLevel(\"info\");\n    }\n\n    if (verbose) {\n      switchboardLogger.info(\"Starting Vetra Switchboard...\");\n      if (remoteDrive) {\n        const source = remoteDrive\n          ? \"command line argument\"\n          : \"powerhouse.config.json\";\n        switchboardLogger.info(`Using vetraUrl from ${source}: ${remoteDrive}`);\n      }\n    }\n    const switchboardResult = await startLocalVetraSwitchboard(\n      {\n        ...args,\n        dev: true, // Vetra always runs in dev mode to load local packages\n        httpsKeyFile,\n        httpsCertFile,\n        disableLocalPackages,\n        debug,\n      },\n      switchboardLogger,\n    );\n    const driveUrl: string = switchboardResult.driveUrl || remoteDrive || \"\";\n    const previewDriveUrl = switchboardResult.previewDriveUrl;\n    const workflowsDriveUrl = switchboardResult.workflowsDriveUrl;\n    const actualSwitchboardPort = switchboardResult.switchboardPort;\n\n    // Record what we actually bound, so a second `ph vetra` can tell a live\n    // instance from a stale file, and so an agent can see the real ports.\n    writeVetraRuntime(projectDir, {\n      pid: process.pid,\n      projectName,\n      switchboardPort: actualSwitchboardPort,\n      connectPort,\n      mcpUrl: `http://localhost:${actualSwitchboardPort}/mcp`,\n      startedAt: new Date().toISOString(),\n    });\n    const releaseRuntimeRecord = () => clearVetraRuntime(projectDir);\n    process.on(\"exit\", releaseRuntimeRecord);\n    process.on(\"SIGINT\", () => {\n      releaseRuntimeRecord();\n      process.exit(130);\n    });\n    process.on(\"SIGTERM\", () => {\n      releaseRuntimeRecord();\n      process.exit(143);\n    });\n\n    // An MCP client resolved `.mcp.json` before this process started and\n    // cannot re-read it, so a drifted literal means the agent is pointed at\n    // the wrong port — possibly another project's reactor. Correct the file\n    // and say so plainly; we cannot fix the already-open client ourselves.\n    const driftedMcpFiles = syncMcpPort(projectDir, actualSwitchboardPort);\n    if (driftedMcpFiles.length > 0) {\n      console.log(\n        yellow(\n          `Updated ${driftedMcpFiles.join(\" and \")} to port ${actualSwitchboardPort}. ` +\n            `Reconnect your MCP client (/mcp) to pick it up. ` +\n            `This edit is local — do not commit it.`,\n        ),\n      );\n    }\n\n    // Configure GitHub URL if remote drive is set\n    if (remoteDrive) {\n      // give some time for the drive to process initial strands\n      await sleep(3000);\n\n      await configureVetraGithubUrl(\n        actualSwitchboardPort,\n        remoteDrive,\n        verbose,\n      );\n\n      // give some time for the user to read log messages\n      await sleep(2000);\n    }\n\n    if (verbose) {\n      console.log(\"Starting Codegen Reactor...\");\n    }\n\n    // Start Connect pointing to the drive (unless disabled)\n    if (!disableConnect) {\n      // --drives-public-base: advertise proxy-reachable drive URLs to the\n      // browser instead of the switchboard's localhost origin.\n      const publicBase = args.drivesPublicBase;\n      const browserDriveUrl = publicBase\n        ? rebaseDriveUrl(driveUrl, publicBase)\n        : driveUrl;\n      const browserPreviewDriveUrl =\n        previewDriveUrl && publicBase\n          ? rebaseDriveUrl(previewDriveUrl, publicBase)\n          : previewDriveUrl;\n      const browserWorkflowsDriveUrl =\n        workflowsDriveUrl && publicBase\n          ? rebaseDriveUrl(workflowsDriveUrl, publicBase)\n          : workflowsDriveUrl;\n\n      // The resolved default-drive list: vetra's own drives first (the\n      // Vetra drive, the preview drive in watch mode, and the Workflows\n      // drive when workflows are on), then the\n      // project's configured `connect.drives.defaultDrives` from\n      // powerhouse.config.json (issue #3023). A drive vetra also starts is\n      // listed only once. An explicit `--default-drives-url` is appended on\n      // top of this list by buildStudioConnectOverride — it never replaces\n      // the vetra drives.\n      const vetraDriveEntries = [\n        ...(browserDriveUrl\n          ? [{ url: browserDriveUrl, name: null, icon: null }]\n          : []),\n        ...(browserPreviewDriveUrl\n          ? [{ url: browserPreviewDriveUrl, name: null, icon: null }]\n          : []),\n        ...(browserWorkflowsDriveUrl\n          ? [{ url: browserWorkflowsDriveUrl, name: null, icon: null }]\n          : []),\n      ];\n      const configuredDefaultDrives =\n        getConfig(join(projectDir, POWERHOUSE_CONFIG_FILE)).connect?.drives\n          ?.defaultDrives ?? [];\n      const resolvedDefaultDrives = mergeDefaultDrives(\n        vetraDriveEntries,\n        configuredDefaultDrives,\n      );\n\n      if (verbose) {\n        console.log(\"Starting Connect...\");\n        // Mirror buildStudioConnectOverride: an explicit\n        // --default-drives-url is appended to the resolved list.\n        const flagDefaultDrives = wasFlagExplicitlyPassed(\"default-drives-url\")\n          ? parseDefaultDrivesUrl(args.defaultDrivesUrl ?? \"\")\n          : [];\n        const printedDefaultDrives = mergeDefaultDrives(\n          resolvedDefaultDrives,\n          flagDefaultDrives,\n        );\n        console.log(\n          `   ➜ Connect will use default drives: ${printedDefaultDrives\n            .map((d) => (\"url\" in d ? d.url : `local:${d.id}`))\n            .join(\", \")}`,\n        );\n      }\n      console.log();\n      console.log(green(`Vetra Connect: http://localhost:${connectPort}`));\n\n      const customViteLogger = createViteLogger(green);\n\n      // Programmatic override forwarded to the Connect runtime config —\n      // vetra always sets these regardless of what the user typed on the\n      // command line. We pass it as the explicit third arg to\n      // runConnectStudio so it survives the `wasFlagExplicitlyPassed`\n      // gating (the user didn't pass --default-drives-url; vetra is setting\n      // it itself).\n      const vetraDrivesOverride = {\n        drives: {\n          defaultDrives: resolvedDefaultDrives,\n          preserveStrategy: \"preserve-all\" as const,\n        },\n      };\n\n      await runConnectStudio(\n        {\n          ...args,\n          port: connectPort,\n          disableLocalPackages,\n          debug,\n          host: host,\n          open: open,\n          cors: cors,\n          strictPort: strictPort,\n          printUrls: printUrls,\n          bindCLIShortcuts: bindCLIShortcuts,\n          watchTimeout: watchTimeout,\n        },\n        customViteLogger,\n        vetraDrivesOverride,\n      );\n    }\n  } catch (error) {\n    console.error(error);\n  }\n}\n"],"names":["startSwitchboard"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAaA,SAAS,kBAAiC;CACxC,IAAI;EAKF,OAJY,SAAS,6BAA6B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