everything-dev
Version:
A consolidated product package for building Module Federation apps with oRPC APIs.
1 lines • 97.6 kB
Source Map (JSON)
{"version":3,"file":"plugin.cjs","names":["EventEmitter","getPluginRef","fetchBosConfigFromFastKv","resolveExtendsRef","parseBosUrl","mergeBosConfigWithExtends","resolveConfigComposableEntries","BosConfigSchema","process","z","bosContract","Effect","loadResolvedConfig","getProjectRoot","loadLocalConfig","saveBosConfig","generateCodeArtifacts","fileExists","readJsonFile","run","parseDeployLines","extractPublishedUrl","computeSriHashForUrl","fetchRemotePluginManifest","detectLocalPackages","syncResolvedSharedDeps","buildEverythingDevQuietly","buildEveryPluginQuietly","buildRuntimeConfig","planInfra","PortAllocatorLive","preflightLocalInfra","buildServiceDescriptorMapFromPlan","buildDescription","buildRegistryConfigUrl","getHostDevelopmentPort","buildRuntimePluginsForConfig","buildServiceDescriptorMap","findConfigPath","selectWorkspaceTargets","buildWorkspaceTargets","publishToFastKv","colors","getNetworkIdForAccount","getRegistryNamespaceForAccount","ensureNearCli","listPublishKeys","addFunctionCallAccessKey","deleteAccessKeys","fetchParentConfig","detectGitRemoteUrl","resolveSourceDir","scaffoldMinimalProject","personalizeConfig","buildInitPatterns","buildPluginRouteExclusions","copyFilteredFiles","writeInitSnapshot","personalizeAgentsMd","runBunInstall","runTypesGen","generateDatabaseMigrations","syncTemplate","upgradeTemplate","getStatus","pruneDeadEffect","readRegistry"],"sources":["../src/plugin.ts"],"sourcesContent":["import { EventEmitter } from \"node:events\";\nimport { existsSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { basename, dirname, join, relative, resolve } from \"node:path\";\nimport process from \"node:process\";\nimport { createInterface } from \"node:readline/promises\";\nimport { Effect } from \"effect\";\nimport { buildRuntimeConfig, detectLocalPackages, PortAllocatorLive } from \"./app\";\nimport {\n buildEveryPluginQuietly,\n buildEverythingDevQuietly,\n buildWorkspaceTargets,\n fileExists,\n getPluginRef,\n readJsonFile,\n selectWorkspaceTargets,\n} from \"./build\";\nimport {\n ensureEnvFile,\n loadProjectEnv,\n syncGeneratedInfra,\n writeGeneratedInfra,\n} from \"./cli/infra\";\nimport {\n buildInitPatterns,\n buildPluginRouteExclusions,\n copyFilteredFiles,\n detectGitRemoteUrl,\n fetchParentConfig,\n generateDatabaseMigrations,\n personalizeAgentsMd,\n personalizeConfig,\n removeInitLockfile,\n resolveSourceDir,\n runBunInstall,\n runTypesGen,\n scaffoldMinimalProject,\n stripOrphanedWorkspacesFromLockfile,\n writeInitSnapshot,\n} from \"./cli/init\";\nimport { getStatus } from \"./cli/status\";\nimport { syncTemplate } from \"./cli/sync\";\nimport { upgradeTemplate } from \"./cli/upgrade\";\nimport { generateCodeArtifacts } from \"./code-artifacts\";\nimport {\n buildRuntimePluginsForConfig,\n drainConfigWarnings,\n findConfigPath,\n getHostDevelopmentPort,\n getProjectRoot,\n loadLocalConfig,\n loadResolvedConfig,\n resolveConfigComposableEntries,\n resumeWarnings,\n suppressWarnings,\n} from \"./config\";\nimport {\n type BosConfigResult,\n bosContract,\n type OverrideSection,\n type PhaseTiming,\n type PluginListResult,\n} from \"./contract\";\nimport {\n buildRegistryConfigUrl,\n fetchBosConfigFromFastKv,\n fetchRemotePluginManifest,\n getRegistryNamespaceForAccount,\n type PluginManifest,\n parseBosUrl,\n} from \"./fastkv\";\nimport { planInfra } from \"./infra/planner\";\nimport { preflightLocalInfra } from \"./infra/preflight\";\nimport type { InfraPlan } from \"./infra/types\";\nimport { computeSriHashForUrl, parseDeployLines } from \"./integrity\";\nimport { type BosEnv, mergeBosConfigWithExtends, resolveExtendsRef } from \"./merge\";\nimport {\n addFunctionCallAccessKey,\n deleteAccessKeys,\n ensureNearCli,\n listPublishKeys,\n} from \"./near-cli\";\nimport { getNetworkIdForAccount } from \"./network\";\nimport { pruneDeadEffect, readRegistry, unregisterPid } from \"./process-registry\";\nimport { extractPublishedUrl, publishToFastKv } from \"./publish\";\nimport { createPlugin, z } from \"./sdk\";\nimport {\n type AppOrchestrator,\n buildDescription,\n buildServiceDescriptorMap,\n buildServiceDescriptorMapFromPlan,\n type ServiceDescriptor,\n} from \"./service-descriptor\";\nimport { syncResolvedSharedDeps } from \"./shared-deps\";\nimport type { BosConfig, BosConfigInput, ExtendsConfig, RuntimeConfig, SourceMode } from \"./types\";\nimport { BosConfigSchema } from \"./types\";\nimport { run } from \"./utils/run\";\nimport { saveBosConfig } from \"./utils/save-config\";\nimport { colors } from \"./utils/theme\";\n\nexport interface DevSessionData {\n orchestrator: AppOrchestrator;\n services: Map<string, ServiceDescriptor>;\n runtimeConfig: RuntimeConfig;\n}\n\nexport interface StartSummary {\n configSource: string;\n configSourceHttp?: string;\n account: string;\n domain?: string;\n modules: { host?: string; ui?: string; api?: string; auth?: string };\n warnings: string[];\n}\n\nexport type ProgressEvent = {\n phase: string;\n status: \"running\" | \"done\" | \"error\";\n durationMs?: number;\n message?: string;\n};\n\nexport const pluginEvents = new EventEmitter();\n\nlet pendingSession: DevSessionData | null = null;\nlet pendingStartSummary: StartSummary | null = null;\n\nexport function consumeDevSession(): (DevSessionData & { summary?: StartSummary }) | null {\n const data = pendingSession;\n const summary = pendingStartSummary;\n pendingSession = null;\n pendingStartSummary = null;\n if (!data) return null;\n return summary ? { ...data, summary } : data;\n}\n\nasync function timePhase<T>(\n timings: PhaseTiming[],\n name: string,\n fn: () => Promise<T>,\n): Promise<T> {\n pluginEvents.emit(\"progress\", { phase: name, status: \"running\" } satisfies ProgressEvent);\n const startedAt = Date.now();\n try {\n const result = await fn();\n timings.push({ name, durationMs: Date.now() - startedAt });\n pluginEvents.emit(\"progress\", {\n phase: name,\n status: \"done\",\n durationMs: Date.now() - startedAt,\n } satisfies ProgressEvent);\n return result;\n } catch (error) {\n pluginEvents.emit(\"progress\", {\n phase: name,\n status: \"error\",\n durationMs: Date.now() - startedAt,\n } satisfies ProgressEvent);\n throw error;\n }\n}\n\nconst PUBLISH_FUNCTION_NAMES = [\"__fastdata_kv\"];\n\ntype BosDeps = {\n bosConfig: BosConfig | null;\n runtimeConfig: RuntimeConfig | null;\n configDir: string;\n};\n\ntype PluginAttachmentConfig = NonNullable<BosConfig[\"plugins\"]>[string];\n\nfunction parseSourceMode(value: string | undefined, defaultValue: SourceMode): SourceMode {\n if (value === \"local\" || value === \"remote\") return value;\n return defaultValue;\n}\n\nfunction buildConfigResult(\n bosConfig: BosConfigInput | BosConfig | null,\n full = false,\n): BosConfigResult {\n const packages =\n bosConfig?.app && typeof bosConfig.app === \"object\" ? Object.keys(bosConfig.app) : [];\n const remotes = packages.filter((name) => name !== \"host\");\n\n return {\n config: bosConfig ?? null,\n packages,\n remotes,\n full,\n };\n}\n\nfunction isValidProxyUrl(url: string): boolean {\n try {\n const parsed = new URL(url);\n return parsed.protocol === \"http:\" || parsed.protocol === \"https:\";\n } catch {\n return false;\n }\n}\n\nfunction resolveProxyUrl(bosConfig: BosConfig | null): string | null {\n if (!bosConfig) return null;\n const apiConfig = bosConfig.app.api;\n if (!apiConfig) return null;\n if (apiConfig.proxy && isValidProxyUrl(apiConfig.proxy)) return apiConfig.proxy;\n if (apiConfig.production && isValidProxyUrl(apiConfig.production)) return apiConfig.production;\n return null;\n}\n\nfunction sanitizePluginKey(value: string): string {\n return value\n .replace(/[^A-Za-z0-9/_-]/g, \"-\")\n .replace(/\\/+/g, \"/\")\n .split(\"/\")\n .filter(Boolean)\n .map((segment) => segment.replace(/[^A-Za-z0-9_-]/g, \"-\"))\n .join(\"/\")\n .replace(/^\\/+|\\/+$/g, \"\");\n}\n\nfunction defaultPluginKey(source: string): string {\n const normalized = source.replace(/^local:/, \"\").replace(/\\/$/, \"\");\n if (source.startsWith(\"local:\")) {\n return sanitizePluginKey(basename(normalized)) || \"plugin\";\n }\n\n try {\n const url = new URL(source);\n return sanitizePluginKey(basename(url.pathname) || url.hostname) || \"plugin\";\n } catch {\n return sanitizePluginKey(source) || \"plugin\";\n }\n}\n\nfunction pluginLocalPath(configDir: string, attachment: PluginAttachmentConfig): string | null {\n const ref = getPluginRef(attachment);\n const source = ref?.development ?? ref?.production;\n if (!source?.startsWith(\"local:\")) {\n return null;\n }\n\n return join(configDir, source.slice(\"local:\".length));\n}\n\nfunction listPluginAttachments(config: BosConfig | null) {\n return (Object.entries(config?.plugins ?? {}) as Array<[string, PluginAttachmentConfig]>)\n .map(([key, attachment]) => {\n const ref = getPluginRef(attachment);\n return {\n key,\n development: ref?.development,\n production: ref?.production,\n localPath: ref?.development?.startsWith(\"local:\")\n ? ref.development.slice(\"local:\".length)\n : undefined,\n source: ref?.development?.startsWith(\"local:\") ? (\"local\" as const) : (\"remote\" as const),\n integrity: ref?.integrity,\n version: ref?.version,\n name: ref?.name,\n };\n })\n .sort((a, b) => a.key.localeCompare(b.key));\n}\n\nexport async function resolveRemoteConfigChain(\n accountId: string,\n gatewayId: string,\n visited: Set<string>,\n): Promise<BosConfig> {\n const selfRef = `bos://${accountId}/${gatewayId}`;\n if (visited.has(selfRef)) {\n throw new Error(`Circular extends detected: ${selfRef}`);\n }\n\n const nextVisited = new Set(visited);\n nextVisited.add(selfRef);\n\n const config = await fetchBosConfigFromFastKv<BosConfigInput>(selfRef);\n const parentRef = config.extends\n ? resolveExtendsRef(config.extends as string | ExtendsConfig, \"production\")\n : undefined;\n\n let merged: BosConfigInput;\n if (!parentRef) {\n merged = config;\n } else {\n const { accountId: parentAccountId, gatewayId: parentGatewayId } = parseBosUrl(parentRef);\n const parentResolved = await resolveRemoteConfigChain(\n parentAccountId,\n parentGatewayId,\n nextVisited,\n );\n merged = mergeBosConfigWithExtends(parentResolved as BosConfigInput, config);\n }\n\n return resolveConfigComposableEntries(BosConfigSchema.parse(merged), process.cwd(), \"production\");\n}\n\nasync function fetchPublishedConfig(\n accountId: string,\n gatewayId: string,\n): Promise<BosConfig | null> {\n try {\n return await resolveRemoteConfigChain(accountId, gatewayId, new Set());\n } catch (error) {\n if (error instanceof Error && error.message.startsWith(\"No config found\")) {\n return null;\n }\n throw error;\n }\n}\n\nexport default createPlugin({\n variables: z.object({\n configPath: z.string().optional(),\n }),\n secrets: z.object({}),\n contract: bosContract,\n initialize: (config) =>\n Effect.promise(async () => {\n const configResult = await loadResolvedConfig({ path: config.variables.configPath });\n return {\n bosConfig: configResult?.config ?? null,\n runtimeConfig: configResult?.runtime ?? null,\n configDir: getProjectRoot(),\n } satisfies BosDeps;\n }),\n shutdown: () => Effect.void,\n createRouter: (deps, builder) => ({\n config: builder.config.handler(async ({ input }) => {\n if (input.full) {\n return buildConfigResult(deps.bosConfig, true);\n }\n\n const localConfig = await loadLocalConfig({ cwd: deps.configDir });\n return buildConfigResult(localConfig?.config ?? null, false);\n }),\n\n pluginAdd: builder.pluginAdd.handler(async ({ input }) => {\n if (!deps.bosConfig) {\n return {\n status: \"error\" as const,\n key: \"\",\n error: \"No bos.config.json found\",\n };\n }\n\n const isBosRef = input.source.startsWith(\"bos://\");\n const isLocal = input.source.startsWith(\"local:\");\n const key = sanitizePluginKey(\n input.as ??\n (isBosRef ? (input.source.split(\"/\").pop() ?? \"plugin\") : defaultPluginKey(input.source)),\n );\n const existing = deps.bosConfig.plugins?.[key];\n const existingEntry = existing && typeof existing === \"object\" ? existing : {};\n const nextPlugins = { ...(deps.bosConfig.plugins ?? {}) };\n\n if (isBosRef) {\n nextPlugins[key] = {\n ...existingEntry,\n extends: input.source,\n };\n } else if (isLocal) {\n nextPlugins[key] = {\n ...existingEntry,\n development: input.source,\n ...(existingEntry.extends ? {} : {}),\n };\n } else {\n nextPlugins[key] = {\n ...existingEntry,\n production: input.production ?? input.source,\n };\n }\n\n deps.bosConfig = {\n ...deps.bosConfig,\n plugins: nextPlugins,\n };\n\n await saveBosConfig(deps.configDir, deps.bosConfig);\n await generateCodeArtifacts(deps.configDir, deps.bosConfig);\n\n const stored = deps.bosConfig.plugins?.[key];\n const storedObj = stored && typeof stored === \"object\" ? stored : {};\n\n return {\n status: \"added\" as const,\n key,\n development: storedObj.development,\n production: storedObj.production,\n integrity: storedObj.integrity,\n version: storedObj.version,\n };\n }),\n\n pluginRemove: builder.pluginRemove.handler(async ({ input }) => {\n if (!deps.bosConfig) {\n return {\n status: \"error\" as const,\n key: input.key,\n error: \"No bos.config.json found\",\n };\n }\n\n if (!deps.bosConfig.plugins?.[input.key]) {\n return {\n status: \"error\" as const,\n key: input.key,\n error: `Plugin '${input.key}' is not configured`,\n };\n }\n\n const nextPlugins = { ...(deps.bosConfig.plugins ?? {}) };\n delete nextPlugins[input.key];\n deps.bosConfig = {\n ...deps.bosConfig,\n plugins: Object.keys(nextPlugins).length > 0 ? nextPlugins : undefined,\n };\n\n await saveBosConfig(deps.configDir, deps.bosConfig);\n await generateCodeArtifacts(deps.configDir, deps.bosConfig);\n\n return {\n status: \"removed\" as const,\n key: input.key,\n };\n }),\n\n pluginList: builder.pluginList.handler(async () => {\n const plugins: PluginListResult[\"plugins\"] = listPluginAttachments(deps.bosConfig);\n return {\n status: \"listed\" as const,\n plugins,\n };\n }),\n\n pluginPublish: builder.pluginPublish.handler(async ({ input }) => {\n if (!deps.bosConfig) {\n return {\n status: \"error\" as const,\n key: input.key,\n error: \"No bos.config.json found\",\n };\n }\n\n const attachment = deps.bosConfig.plugins?.[input.key];\n if (!attachment) {\n return {\n status: \"error\" as const,\n key: input.key,\n error: `Plugin '${input.key}' is not configured`,\n };\n }\n\n const attachmentRef = getPluginRef(attachment);\n\n const localPath = pluginLocalPath(deps.configDir, attachment);\n if (!localPath) {\n return {\n status: \"error\" as const,\n key: input.key,\n error: `Plugin '${input.key}' does not have a local development path`,\n };\n }\n\n const pkgPath = join(localPath, \"package.json\");\n if (!(await fileExists(pkgPath))) {\n return {\n status: \"error\" as const,\n key: input.key,\n error: `Missing package.json at ${localPath}`,\n };\n }\n\n const pkgJson = await readJsonFile<{\n scripts?: Record<string, string>;\n name?: string;\n version?: string;\n }>(pkgPath);\n const script = pkgJson.scripts?.deploy ? \"deploy\" : \"build\";\n\n const { stdout, stderr, exitCode } = (await run(\"bun\", [\"run\", script], {\n cwd: localPath,\n capture: true,\n })) as { stdout: string; stderr: string; exitCode: number };\n\n if (exitCode !== 0) {\n if (stdout.trim()) process.stdout.write(stdout);\n if (stderr.trim()) process.stderr.write(stderr);\n return {\n status: \"error\" as const,\n key: input.key,\n error: `Publish failed with exit code ${exitCode}`,\n };\n }\n\n if (stdout.trim()) process.stdout.write(stdout);\n if (stderr.trim()) process.stderr.write(stderr);\n\n const output = `${stdout}\\n${stderr}`;\n const deployEntries = parseDeployLines(output);\n const deployEntry = deployEntries.find(\n (e) => e.urlField === `plugins.${input.key}.production`,\n );\n\n let publishedUrl: string | undefined;\n let integrity: string | undefined;\n if (deployEntry) {\n publishedUrl = deployEntry.url;\n integrity = deployEntry.integrity;\n } else {\n publishedUrl = extractPublishedUrl(output) ?? undefined;\n integrity = publishedUrl\n ? ((await computeSriHashForUrl(publishedUrl)) ?? undefined)\n : undefined;\n }\n\n let manifest: PluginManifest | null = null;\n if (publishedUrl) {\n manifest = await fetchRemotePluginManifest(publishedUrl);\n } else if (attachmentRef?.production) {\n manifest = await fetchRemotePluginManifest(attachmentRef.production);\n if (manifest) {\n publishedUrl = attachmentRef.production;\n }\n }\n\n const version = manifest?.plugin.version ?? pkgJson.version;\n\n if (publishedUrl) {\n const rootConfigPath = join(deps.configDir, \"bos.config.json\");\n try {\n const rootConfig = JSON.parse(readFileSync(rootConfigPath, \"utf-8\")) as Record<\n string,\n unknown\n >;\n if (!rootConfig.plugins || typeof rootConfig.plugins !== \"object\") {\n rootConfig.plugins = {};\n }\n const plugins = rootConfig.plugins as Record<string, unknown>;\n if (!plugins[input.key] || typeof plugins[input.key] !== \"object\") {\n plugins[input.key] = {};\n }\n const entry = plugins[input.key] as Record<string, unknown>;\n entry.production = publishedUrl;\n if (integrity) {\n entry.integrity = integrity;\n } else {\n delete entry.integrity;\n }\n writeFileSync(rootConfigPath, `${JSON.stringify(rootConfig, null, 2)}\\n`);\n console.log(` ✅ Updated bos.config.json: plugins.${input.key}.production`);\n } catch (err) {\n console.error(\n ` ❌ Failed to update bos.config.json:`,\n err instanceof Error ? err.message : err,\n );\n }\n\n await generateCodeArtifacts(deps.configDir, deps.bosConfig);\n }\n\n return {\n status: \"published\" as const,\n key: input.key,\n path: localPath,\n script,\n production: publishedUrl ?? attachmentRef?.production,\n integrity: integrity ?? undefined,\n version: version ?? undefined,\n };\n }),\n\n dev: builder.dev.handler(async ({ input }) => {\n const devTimings: PhaseTiming[] = [];\n\n ensureEnvFile(deps.configDir);\n loadProjectEnv(deps.configDir);\n\n const localPackages = detectLocalPackages(\n deps.bosConfig ?? undefined,\n deps.runtimeConfig ?? undefined,\n );\n\n const hostSource: SourceMode = localPackages.includes(\"host\")\n ? parseSourceMode(input.host, \"local\")\n : \"remote\";\n const uiSource: SourceMode = localPackages.includes(\"ui\")\n ? parseSourceMode(input.ui, \"local\")\n : \"remote\";\n const apiSource: SourceMode = localPackages.includes(\"api\")\n ? parseSourceMode(input.api, \"local\")\n : \"remote\";\n const authSource: SourceMode = localPackages.includes(\"auth\")\n ? parseSourceMode(input.auth, \"local\")\n : \"remote\";\n const ssr = input.ssr ?? false;\n const proxy = input.proxy ?? false;\n\n const sharedSync = await timePhase(devTimings, \"shared deps\", () =>\n syncResolvedSharedDeps({\n configDir: deps.configDir,\n hostMode: hostSource,\n bosConfig: deps.bosConfig ?? undefined,\n extendsChain: [],\n }),\n );\n let configMayHaveChanged = false;\n if (sharedSync.catalogChanged) {\n await timePhase(devTimings, \"install\", () =>\n run(\"bun\", [\"install\"], { cwd: deps.configDir }),\n );\n configMayHaveChanged = true;\n }\n const shouldBuildPlugin =\n (apiSource === \"local\" && !proxy) || localPackages.some((pkg) => pkg.startsWith(\"plugin:\"));\n\n await timePhase(devTimings, \"build\", async () => {\n const buildTasks: Promise<void>[] = [buildEverythingDevQuietly(deps.configDir)];\n if (shouldBuildPlugin) {\n buildTasks.push(buildEveryPluginQuietly(deps.configDir));\n }\n await Promise.all(buildTasks);\n });\n\n let devExtendsChain: string[] | undefined;\n if (configMayHaveChanged || input.remotePlugins !== undefined) {\n const refreshed = await timePhase(devTimings, \"resolve config\", () =>\n loadResolvedConfig({\n cwd: deps.configDir,\n remotePlugins: input.remotePlugins,\n }),\n );\n deps.bosConfig = refreshed?.config ?? deps.bosConfig;\n deps.runtimeConfig = refreshed?.runtime ?? deps.runtimeConfig;\n devExtendsChain = refreshed?.source.extended;\n }\n\n if (!deps.bosConfig) {\n return {\n status: \"error\" as const,\n description: \"No bos.config.json found\",\n processes: [],\n timings: devTimings,\n };\n }\n\n if (proxy && !resolveProxyUrl(deps.bosConfig)) {\n return {\n status: \"error\" as const,\n description: \"No valid proxy URL configured in bos.config.json\",\n processes: [],\n timings: devTimings,\n };\n }\n\n suppressWarnings();\n const developmentRuntime = await buildRuntimeConfig(deps.bosConfig, {\n uiSource,\n apiSource,\n authSource,\n hostSource,\n env: \"development\",\n plugins: deps.runtimeConfig?.plugins,\n });\n drainConfigWarnings();\n resumeWarnings();\n\n const plan: InfraPlan = await timePhase(devTimings, \"ports\", () =>\n Effect.runPromise(\n planInfra({\n configDir: deps.configDir,\n bosConfig: developmentRuntime,\n cli: {\n port: input.port,\n apiPort: input.apiPort,\n authPort: input.authPort,\n uiPort: input.uiPort,\n pluginPortStart: input.pluginPortStart,\n ssr,\n proxy,\n hostSource,\n uiSource,\n apiSource,\n authSource,\n interactive: input.interactive,\n },\n }).pipe(Effect.provide(PortAllocatorLive)),\n ),\n );\n\n const mergedEnv: Record<string, string> = { ...plan.envGenerated };\n for (const [k, v] of Object.entries(process.env)) {\n if (v != null && !(k in plan.envGenerated)) {\n mergedEnv[k] = v;\n }\n }\n const preflightFailures = await Effect.runPromise(\n preflightLocalInfra(plan.envGenerated, mergedEnv),\n );\n if (preflightFailures.length > 0) {\n const messages = preflightFailures.map((f) => f.error).join(\"; \");\n return {\n status: \"error\" as const,\n description: `Infra preflight failed: ${messages}`,\n processes: [],\n timings: devTimings,\n };\n }\n\n const services = buildServiceDescriptorMapFromPlan(plan, { ssr, proxy });\n writeGeneratedInfra(deps.configDir, plan.runtimeConfig);\n ensureEnvFile(deps.configDir);\n loadProjectEnv(deps.configDir);\n\n const packages = [...plan.serviceDescriptors.keys()];\n if (process.env.DEBUG === \"true\" || process.env.DEBUG === \"1\") {\n console.error(\"[DEBUG dev] services keys:\", packages.join(\", \"));\n }\n const apiSvc = services.get(\"api\");\n if (apiSvc?.proxy) {\n const proxyUrl = resolveProxyUrl(deps.bosConfig);\n if (proxyUrl) plan.orchestrator.env.API_PROXY = proxyUrl;\n }\n\n pendingSession = {\n orchestrator: plan.orchestrator,\n services,\n runtimeConfig: plan.runtimeConfig,\n };\n\n await timePhase(devTimings, \"generate artifacts\", () =>\n generateCodeArtifacts(deps.configDir, deps.bosConfig!, {\n env: \"development\",\n extendsChain: devExtendsChain,\n runtimeConfig: plan.runtimeConfig,\n }),\n );\n\n return {\n status: \"started\" as const,\n description: buildDescription(services) || plan.description,\n processes: packages,\n timings: devTimings,\n };\n }),\n\n start: builder.start.handler(async ({ input }) => {\n ensureEnvFile(deps.configDir);\n loadProjectEnv(deps.configDir);\n\n pluginEvents.emit(\"progress\", { phase: \"config\", status: \"running\" } satisfies ProgressEvent);\n\n const bosEnv = input.env ?? (process.env.BOS_ENV === \"staging\" ? \"staging\" : \"production\");\n const account = input.account ?? process.env.BOS_ACCOUNT;\n const domain = input.domain ?? process.env.BOS_GATEWAY;\n\n let config: BosConfig | null = null;\n let remoteConfig: BosConfig | null = null;\n\n if (account && domain) {\n try {\n remoteConfig = await fetchPublishedConfig(account, domain);\n if (remoteConfig) {\n config = remoteConfig;\n } else {\n return {\n status: \"error\" as const,\n url: \"\",\n error: `No config found at bos://${account}/${domain}. Verify the account and gateway are correct and the config has been published.\\nExpected URL: ${buildRegistryConfigUrl(account, domain)}`,\n };\n }\n } catch (error) {\n return {\n status: \"error\" as const,\n url: \"\",\n error: `Failed to fetch config for bos://${account}/${domain}: ${error instanceof Error ? error.message : \"Unknown error\"}\\nExpected URL: ${buildRegistryConfigUrl(account, domain)}`,\n };\n }\n } else {\n config = deps.bosConfig;\n }\n\n if (!config) {\n return {\n status: \"error\" as const,\n url: \"\",\n error:\n \"No configuration found. Provide --account and --gateway flags, or create a local bos.config.json.\",\n };\n }\n\n // Apply runtime overrides from CLI flags / env vars\n if (account) {\n config = { ...config, account };\n }\n if (domain) {\n config = { ...config, domain };\n }\n\n const port = input.port ?? getHostDevelopmentPort(config.app.host.development);\n const isStaging = bosEnv === \"staging\";\n const runtimePlugins = await buildRuntimePluginsForConfig(\n config,\n deps.configDir,\n \"production\",\n );\n suppressWarnings();\n const runtimeConfig = await buildRuntimeConfig(config, {\n uiSource: \"remote\",\n apiSource: \"remote\",\n authSource: \"remote\",\n hostSource: \"remote\",\n env: \"production\",\n plugins: runtimePlugins,\n });\n drainConfigWarnings();\n resumeWarnings();\n\n if (isStaging && config.staging?.domain) {\n runtimeConfig.domain = config.staging.domain;\n }\n\n if (isStaging) {\n runtimeConfig.env = \"staging\";\n }\n\n syncGeneratedInfra(deps.configDir, runtimeConfig);\n ensureEnvFile(deps.configDir);\n loadProjectEnv(deps.configDir);\n\n pluginEvents.emit(\"progress\", {\n phase: \"generate artifacts\",\n status: \"running\",\n } satisfies ProgressEvent);\n await generateCodeArtifacts(deps.configDir, config, {\n env: \"production\",\n runtimeConfig,\n });\n pluginEvents.emit(\"progress\", {\n phase: \"generate artifacts\",\n status: \"done\",\n } satisfies ProgressEvent);\n\n // ── Production Readiness Validation ──\n const productionEnv: Record<string, string> = {};\n const warnings: string[] = [];\n\n // Default CORS_ORIGIN to the configured domain if not set\n if (!process.env.CORS_ORIGIN && config.domain) {\n const effectiveDomain = isStaging\n ? (config.staging?.domain ?? config.domain)\n : config.domain;\n const defaultOrigin = `https://${effectiveDomain}`;\n productionEnv.CORS_ORIGIN = defaultOrigin;\n warnings.push(`CORS_ORIGIN defaulting to ${defaultOrigin}`);\n }\n\n // Validate required secrets\n const requiredSecrets = new Set<string>();\n const missingSecrets: string[] = [];\n\n if (runtimeConfig.host.secrets) {\n for (const s of runtimeConfig.host.secrets) requiredSecrets.add(s);\n }\n if (runtimeConfig.auth?.secrets) {\n for (const s of runtimeConfig.auth.secrets) requiredSecrets.add(s);\n }\n if (runtimeConfig.api?.secrets) {\n for (const s of runtimeConfig.api.secrets) requiredSecrets.add(s);\n }\n for (const plugin of Object.values(runtimeConfig.plugins ?? {})) {\n if (plugin.secrets) {\n for (const s of plugin.secrets) requiredSecrets.add(s);\n }\n }\n\n for (const secret of requiredSecrets) {\n const value = process.env[secret];\n if (!value || value.length === 0) {\n missingSecrets.push(secret);\n }\n }\n\n if (missingSecrets.length > 0) {\n warnings.push(`Missing ${missingSecrets.length} secret(s): ${missingSecrets.join(\", \")}`);\n }\n\n const stagingEnvVars: Record<string, string> = isStaging\n ? { BOS_GATEWAY: config.staging?.domain ?? config.domain ?? \"\" }\n : {};\n\n const plan: InfraPlan = await Effect.runPromise(\n planInfra({\n configDir: deps.configDir,\n bosConfig: runtimeConfig,\n cli: {\n port: input.port,\n ssr: false,\n proxy: false,\n hostSource: \"remote\",\n uiSource: \"remote\",\n apiSource: \"remote\",\n authSource: \"remote\",\n interactive: input.interactive,\n },\n }).pipe(Effect.provide(PortAllocatorLive)),\n );\n\n const services = buildServiceDescriptorMap(plan.runtimeConfig);\n\n const configSource = remoteConfig\n ? `bos://${account}/${domain}`\n : (findConfigPath() ?? \"bos.config.json\");\n\n const configSourceHttp =\n remoteConfig && account && domain ? buildRegistryConfigUrl(account, domain) : undefined;\n\n const summary: StartSummary = {\n configSource,\n configSourceHttp,\n account: config.account,\n domain: config.domain ?? undefined,\n modules: {\n host: plan.runtimeConfig.host.remoteUrl ?? plan.runtimeConfig.host.url ?? \"local\",\n ui: plan.runtimeConfig.ui.url ?? \"local\",\n api: plan.runtimeConfig.api.url ?? \"local\",\n auth: plan.runtimeConfig.auth?.url ?? undefined,\n },\n warnings,\n };\n\n const orchestrator: AppOrchestrator = {\n packages: [\"host\"],\n env: {\n NODE_ENV: \"production\",\n ...productionEnv,\n ...stagingEnvVars,\n ...plan.launch.env,\n },\n description: `${isStaging ? \"Staging\" : \"Production\"} Mode (${config.account})`,\n port: plan.resolvedPorts.host ?? port,\n interactive: input.interactive,\n noLogs: true,\n };\n\n pendingSession = { orchestrator, services, runtimeConfig: plan.runtimeConfig };\n pendingStartSummary = summary;\n\n pluginEvents.emit(\"progress\", { phase: \"config\", status: \"done\" } satisfies ProgressEvent);\n\n return {\n status: \"running\" as const,\n url: plan.launch.hostUrl ?? `http://localhost:${plan.resolvedPorts.host ?? port}`,\n };\n }),\n\n build: builder.build.handler(async ({ input }) => {\n if (!deps.bosConfig) {\n return {\n status: \"error\" as const,\n built: [],\n skipped: [],\n };\n }\n\n const buildEnv: BosEnv = input.deploy ? \"production\" : \"development\";\n\n const targets = selectWorkspaceTargets(input.packages, deps.bosConfig);\n if (targets.length === 0) {\n return {\n status: \"error\" as const,\n built: [],\n skipped: [],\n };\n }\n\n suppressWarnings();\n const runtimeConfig = await buildRuntimeConfig(deps.bosConfig, {\n uiSource: deps.bosConfig.app.ui?.development ? \"local\" : \"remote\",\n apiSource: deps.bosConfig.app.api?.development ? \"local\" : \"remote\",\n authSource: deps.bosConfig.app.auth?.development ? \"local\" : \"remote\",\n hostSource: deps.bosConfig.app.host?.development ? \"local\" : \"remote\",\n env: buildEnv,\n plugins: deps.runtimeConfig?.plugins,\n });\n drainConfigWarnings();\n resumeWarnings();\n\n await generateCodeArtifacts(deps.configDir, deps.bosConfig, {\n env: buildEnv,\n runtimeConfig,\n });\n\n const { built, skipped } = await buildWorkspaceTargets({\n configDir: deps.configDir,\n bosConfig: deps.bosConfig,\n runtimeConfig: runtimeConfig,\n targets,\n deploy: input.deploy,\n });\n\n if (built.length === 0) {\n return {\n status: \"error\" as const,\n built: [],\n skipped,\n };\n }\n\n return {\n status: \"success\" as const,\n built,\n skipped,\n deployed: input.deploy,\n };\n }),\n\n publish: builder.publish.handler(async ({ input }) => {\n if (!deps.bosConfig) {\n return {\n status: \"error\" as const,\n registryUrl: \"\",\n error: \"No bos.config.json found\",\n };\n }\n\n const result = await publishToFastKv({\n bosConfig: deps.bosConfig,\n runtimeConfig: deps.runtimeConfig,\n configDir: deps.configDir,\n env: input.env,\n build: input.deploy,\n dryRun: input.dryRun,\n verbose: input.verbose,\n packages: input.packages,\n network: input.network,\n privateKey: input.privateKey,\n });\n\n if (result.publishConfig) {\n const refreshed = await loadResolvedConfig({ cwd: deps.configDir });\n if (refreshed?.config) {\n deps.bosConfig = refreshed.config;\n deps.runtimeConfig = refreshed.runtime;\n }\n }\n\n return {\n status: result.status,\n registryUrl: result.registryUrl,\n txHash: result.txHash,\n error: result.error,\n built: result.built,\n skipped: result.skipped,\n deployResults: result.deployResults,\n };\n }),\n\n deploy: builder.deploy.handler(async ({ input }) => {\n if (!deps.bosConfig) {\n return {\n status: \"error\" as const,\n registryUrl: \"\",\n redeployed: false,\n error: \"No bos.config.json found\",\n };\n }\n\n const result = await publishToFastKv({\n bosConfig: deps.bosConfig,\n runtimeConfig: deps.runtimeConfig,\n configDir: deps.configDir,\n env: input.env,\n build: input.build,\n dryRun: input.dryRun,\n verbose: input.verbose,\n packages: input.packages,\n network: input.network,\n privateKey: input.privateKey,\n });\n\n if (result.status === \"error\") {\n return {\n status: \"error\" as const,\n registryUrl: result.registryUrl,\n txHash: result.txHash,\n built: result.built,\n skipped: result.skipped,\n redeployed: false,\n error: result.error,\n deployResults: result.deployResults,\n };\n }\n\n if (result.status === \"dry-run\") {\n return {\n status: \"dry-run\" as const,\n registryUrl: result.registryUrl,\n built: result.built,\n skipped: result.skipped,\n redeployed: false,\n };\n }\n\n if (result.publishConfig) {\n const refreshed = await loadResolvedConfig({ cwd: deps.configDir });\n if (refreshed?.config) {\n deps.bosConfig = refreshed.config;\n deps.runtimeConfig = refreshed.runtime;\n }\n }\n\n let redeployed = false;\n let service: string | undefined;\n\n if (process.env.RAILWAY_TOKEN) {\n const railwayService = input.service ?? deps.bosConfig.ci?.railway?.service;\n if (!railwayService) {\n console.log();\n console.log(\n colors.yellow(\n \" Railway redeploy skipped: ci.railway.service is not configured in bos.config.json\",\n ),\n );\n return {\n status: \"published\" as const,\n registryUrl: result.registryUrl,\n txHash: result.txHash,\n built: result.built,\n skipped: result.skipped,\n redeployed: false,\n deployResults: result.deployResults,\n error:\n \"Config published but Railway redeploy failed: ci.railway.service is not configured in bos.config.json\",\n };\n }\n\n service = railwayService;\n console.log();\n console.log(` Redeploying Railway service ${colors.cyan(railwayService)}...`);\n try {\n const railResult = await run(\n \"railway\",\n [\"redeploy\", \"--service\", railwayService, \"--yes\"],\n {\n capture: true,\n },\n );\n if (railResult?.stdout) {\n for (const line of railResult.stdout.split(\"\\n\")) {\n if (line.trim()) console.log(` ${colors.dim(line.trim())}`);\n }\n }\n redeployed = true;\n console.log(colors.green(` Railway redeploy complete`));\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n const railError =\n message.includes(\"not found\") || message.includes(\"ENOENT\")\n ? \"Railway CLI not found. Install it: npm i -g @railway/cli\"\n : `Railway redeploy failed: ${message}`;\n console.log(colors.yellow(` ${railError}`));\n return {\n status: \"published\" as const,\n registryUrl: result.registryUrl,\n txHash: result.txHash,\n built: result.built,\n skipped: result.skipped,\n redeployed: false,\n service,\n deployResults: result.deployResults,\n error: `Config published but ${railError}`,\n };\n }\n } else {\n console.log();\n console.log(colors.yellow(\" Railway redeploy skipped (RAILWAY_TOKEN not set)\"));\n }\n\n return {\n status: \"deployed\" as const,\n registryUrl: result.registryUrl,\n txHash: result.txHash,\n built: result.built,\n skipped: result.skipped,\n redeployed,\n service,\n deployResults: result.deployResults,\n };\n }),\n\n keyPublish: builder.keyPublish.handler(async ({ input }) => {\n if (!deps.bosConfig) {\n return {\n status: \"error\" as const,\n account: \"\",\n network: \"mainnet\" as const,\n contract: \"\",\n allowance: input.allowance,\n functionNames: PUBLISH_FUNCTION_NAMES,\n error: \"No bos.config.json found\",\n };\n }\n\n const account = deps.bosConfig.account;\n const network = getNetworkIdForAccount(account);\n const contract = getRegistryNamespaceForAccount(account);\n try {\n await Effect.runPromise(ensureNearCli);\n\n const oldKeys = await listPublishKeys({ account, contract, network });\n\n const keyPair = await addFunctionCallAccessKey({\n account,\n contract,\n allowance: input.allowance,\n functionNames: PUBLISH_FUNCTION_NAMES,\n network,\n });\n\n if (oldKeys.length > 0) {\n console.log();\n console.log(\n ` Found ${oldKeys.length} existing publish key${oldKeys.length > 1 ? \"s\" : \"\"}:`,\n );\n for (const k of oldKeys) {\n console.log(` ${colors.dim(k)}`);\n }\n\n const rl = createInterface({\n input: process.stdin,\n output: process.stdout,\n });\n const answer = await rl.question(\" Remove old key(s)? [Y/n] \");\n rl.close();\n\n if (answer.toLowerCase() !== \"n\" && answer.toLowerCase() !== \"no\") {\n try {\n await deleteAccessKeys(account, oldKeys, network);\n console.log(\n ` ${colors.green(\"✓\")} Removed ${oldKeys.length} old key${oldKeys.length > 1 ? \"s\" : \"\"}`,\n );\n } catch {\n console.log(\n ` ${colors.yellow(\"⚠\")} Failed to remove old key${oldKeys.length > 1 ? \"s\" : \"\"} (new key still active)`,\n );\n }\n } else {\n console.log(` ${colors.dim(\"Old key(s) retained.\")}`);\n }\n }\n\n return {\n status: \"published\" as const,\n account,\n network,\n contract,\n allowance: input.allowance,\n functionNames: PUBLISH_FUNCTION_NAMES,\n publicKey: keyPair.publicKey,\n privateKey: keyPair.privateKey,\n };\n } catch (error) {\n return {\n status: \"error\" as const,\n account,\n network,\n contract,\n allowance: input.allowance,\n functionNames: PUBLISH_FUNCTION_NAMES,\n error: error instanceof Error ? error.message : \"Unknown error\",\n };\n }\n }),\n\n init: builder.init.handler(async ({ input }) => {\n try {\n const timings: PhaseTiming[] = [];\n let extendsAccount = \"\";\n let extendsGateway = \"\";\n let directory = input.directory;\n const account = input.account;\n const domain = input.domain;\n let overrides = input.overrides as OverrideSection[] | undefined;\n let plugins = input.plugins;\n\n if (input.extends) {\n const normalized = input.extends.startsWith(\"bos://\")\n ? input.extends\n : `bos://${input.extends}`;\n const match = normalized.match(/^bos:\\/\\/([^/]+)\\/(.+)$/);\n if (match) {\n extendsAccount = match[1];\n extendsGateway = match[2];\n }\n }\n\n extendsAccount = extendsAccount || \"dev.everything.near\";\n extendsGateway = extendsGateway || \"everything.dev\";\n\n let parentPluginKeys: string[] = [];\n let parentConfig: BosConfig | null = null;\n try {\n parentConfig = await timePhase(timings, \"parent config\", () =>\n fetchParentConfig(extendsAccount, extendsGateway),\n );\n if (parentConfig?.plugins && typeof parentConfig.plugins === \"object\") {\n parentPluginKeys = Object.keys(parentConfig.plugins);\n }\n } catch (e) {\n console.warn(\n `[init] Failed to fetch parent config from ${extendsAccount}/${extendsGateway}: ${e instanceof Error ? e.message : e}`,\n );\n }\n\n overrides = overrides?.length ? overrides : ([\"ui\", \"api\"] as OverrideSection[]);\n if (overrides.includes(\"plugins\") && plugins === undefined) {\n plugins = parentPluginKeys;\n }\n plugins = plugins ?? [];\n\n const pluginDirMap: Record<string, string> = {};\n if (parentConfig?.plugins) {\n for (const plugin of plugins) {\n const entry = (parentConfig.plugins as Record<string, unknown>)?.[plugin];\n if (entry && typeof entry === \"object\") {\n const dev = (entry as Record<string, unknown>).development;\n if (typeof dev === \"string\") {\n const match = dev.match(/^local:plugins\\/(.+)$/);\n if (match?.[1] && match[1] !== plugin) pluginDirMap[plugin] = match[1];\n }\n }\n }\n }\n\n directory = directory || domain || extendsGateway;\n const targetDir = resolve(directory);\n const extendsRef = `bos://${extendsAccount}/${extendsGateway}`;\n\n const repository =\n (await detectGitRemoteUrl(process.cwd()).catch(() => undefined)) ??\n parentConfig?.repository;\n\n if (!parentConfig) {\n try {\n parentConfig = await timePhase(timings, \"parent config\", () =>\n fetchParentConfig(extendsAccount, extendsGateway),\n );\n } catch {\n return {\n status: \"error\" as const,\n directory,\n extendsRef,\n account,\n domain,\n extends: extendsRef,\n plugins,\n overrides,\n filesCopied: 0,\n timings,\n error: `No config found at ${extendsRef} — are you sure this is the right parent?`,\n };\n }\n }\n\n const {\n sourceDir,\n parentConfig: resolvedParentConfig,\n cleanup,\n } = await timePhase(timings, \"template source\", () =>\n resolveSourceDir({\n extendsAccount,\n extendsGateway,\n source: input.source,\n }),\n );\n\n parentConfig = resolvedParentConfig;\n\n const isMinimalScaffold = sourceDir === \"\";\n\n try {\n let filesCopied: number;\n\n if (isMinimalScaffold) {\n filesCopied = await timePhase(timings, \"scaffold project\", () =>\n scaffoldMinimalProject(targetDir, parentConfig as unknown as BosConfigInput, {\n extendsAccount,\n extendsGateway,\n account: account || extendsAccount,\n domain,\n plugins,\n overrides,\n repository,\n title: parentConfig?.title,\n description: parentConfig?.description,\n }),\n );\n\n await timePhase(timings, \"personalize config\", () =>\n personalizeConfig(targetDir, {\n extendsAccount,\n extendsGateway,\n account: account || extendsAccount,\n domain: domain || extendsGateway,\n plugins,\n overrides,\n mode: \"init\",\n repository,\n title: parentConfig?.title,\n description: parentConfig?.description,\n testnet: parentConfig?.testnet,\n staging: parentConfig?.staging,\n }),\n );\n } else {\n const patterns = buildInitPatterns(overrides, plugins, pluginDirMap);\n const routeExclusions = overrides.includes(\"ui\")\n ? buildPluginRouteExclusions(parentConfig, plugins)\n : [];\n\n filesCopied = await timePhase(timings, \"copy files\", () =>\n copyFilteredFiles(sourceDir, targetDir, patterns, {\n overrides,\n plugins,\n ignore: routeExclusions,\n }),\n );\n\n await timePhase(timings, \"personalize config\", () =>\n personalizeConfig(targetDir, {\n extendsAccount,\n extendsGateway,\n account: account || extendsAccount,\n domain: domain || extendsGateway,\n plugins,\n overrides,\n workspaceOpts: { sourceDir },\n repository,\n title: parentConfig?.title,\n description: parentConfig?.description,\n testnet: parentConfig?.testnet,\n staging: parentConfig?.staging,\n }),\n );\n\n await timePhase(timings, \"write snapshot\", () =>\n writeInitSnapshot(targetDir, extendsAccount, extendsGateway, sourceDir, patterns, {\n overrides,\n plugins,\n ignore: routeExclusions,\n }),\n );\n\n await timePhase(timings, \"personalize agents\", () =>\n personalizeAgentsMd(targetDir, { overrides, plugins }),\n );\n }\n\n await timePhase(timings, \"sync shared deps\", () =>\n syncResolvedSharedDeps({\n configDir: targetDir,\n hostMode: \"local\",\n }),\n );\n\n const lockfilePath = join(targetDir, \"bun.lock\");\n const allowedWorkspaces = computeAllowedWorkspaces(overrides, plugins);\n stripOrphanedWorkspacesFromLockfile(lockfilePath, allowedWorkspaces);\n removeInitLockfile(lockfilePath);\n\n const initConfig = await timePhase(timings, \"resolve config\", () =>\n loadResolvedConfig({ cwd: targetDir }),\n );\n if (initConfig?.runtime) {\n await timePhase(timings, \"generate env/docker\", async () => {\n writeGeneratedInfra(targetDir, initConfig.runtime);\n });\n }\n await timePhase(timings, \"create env file\", async () => {\n ensureEnvFile(targetDir);\n });\n\n if (!input.noInstall) {\n await timePhase(timings, \"install dependencies\", () => runBunInstall(targetDir));\n await timePhase(timings, \"generate types\", () => runTypesGen(targetDir));\n await timePhase(timings, \"generate migrations\", () =>\n generateDatabaseMigrations(targetDir),\n );\n }\n\n if (input.noInstall && initConfig?.config) {\n await timePhase(timings, \"generate code artifacts\", () =>\n generateCodeArtifacts(targetDir, initConfig.config),\n );\n }\n\n return {\n status: \"initialized\" as const,\n directory,\n extendsRef,\n account,\n domain,\n extends: extendsRef,\n plugins,\n overrides,\n filesCopied,\n timings,\n targetDir,\n };\n } finally {\n await cleanup();\n }\n } catch (error) {\n const extendsRef = input.extends\n ? input.extends.startsWith(\"bos://\")\n ? input.extends\n : `bos://${input.extends}`\n : \"bos://dev.everything.near/everything.dev\";\n return {\n status: \"error\" as const,\n directory: input.directory ?? \"\",\n extendsRef,\n account: input.account,\n domain: input.domain,\n extends: extendsRef,\n plugins: input.plugins ?? [],\n overrides: input.overrides,\n filesCopied: 0,\n timings: [],\n error: error instanceof Error ? error.message : \"Unknown error\",\n };\n }\n }),\n\n sync: builder.sync.handler(async ({ input }) => {\n try {\n const configPath = findConfigPath();\n if (!configPath) {\n return {\n status: \"error\" as const,\n updated: [],\n skipped: [],\n added: [],\n error: \"No bos.config.json found in current directory\",\n };\n }\n\n const projectDir = resolve(dirname(configPath));\n const result = await syncTemplate(projectDir, input);\n\n if (result.status === \"synced\" || result.status === \"dry-run\") {\n const syncedConfig = await loadResolvedConfig({ cwd: projectDir });\n if (syncedConfig?.config) {\n await generateCodeArtifacts(projectDir, syncedConfig.config);\n }\n }\n\n return result;\n } catch (error) {\n return {\n status: \"error\" as const,\n updated: [],\n skipped: [],\n added: [],\n error: error instanceof Error ? error.message : \"Unknown error\",\n };\n }\n }),\n\n upgrade: builder.upgrade.handler(async ({ input }) => {\n try {\n const configPath = findConfigPath();\n if (!configPath) {\n return {\n status: \"error\" as const,\n packages: [],\n error: \"No bos.config.json found in current directory\",\n };\n }\n\n const projectDir = resolve(dirname(configPath));\n return await upgradeTemplate(projectDir, input);\n } catch (error) {\n return {\n status: \"error\" as const,\n packages: [],\n error: error instanceof Error ? error.message : \"Unknown error\",\n };\n }\n }),\n\n typesGen: builder.typesGen.handler(async ({ input }) => {\n try {\n const configPath = findConfigPath();\n if (!configPath) {\n return {\n status: \"error\" as const,\n generated: [],\n fetched: [],\n skipped: [],\n failed: [],\n error: \"No bos.config.json found in current directory\",\n };\n }\n\n const projectDir = resolve(dirname(configPath));\n const env =\n input.env ?? (process.env.NODE_ENV === \"production\" ? \"production\" : \"development\");\n\n const refreshed = await loadResolvedConfig({\n cwd: projectDir,\n env,\n remotePlugins: input.remotePlugins,\n });\n if (!refreshed) {\n return {\n status: \"error\" as const,\n generated: [],\n fetched: [],\n skipped: [],\n failed: [],\n error: \"Failed to load bos.config.json\",\n };\n }\n\n if (input.dryRun) {\n const pluginEntries = Object.entries(refreshed.runtime.plugins ?? {});\n const fetched: string[] = [];\n const skipped: string[] = [];\n const hasLocalApiWorkspace = existsSync(join(projectDir, \"api\", \"src\"));\n\n if (refreshed.runtime.api.source !== \"local\") {\n fetched.push(`api remote (${refreshed.runtime.api.url})`);\n } else {\n const path = refreshed.runtime.api.localPath\n ? ` (${relative(projectDir, refreshed.runtime.api.localPath)})`\n : \"\";\n skipped.push(`api local${path}`);\n }\n\n if (refreshed.runtime.auth) {\n if (refreshed.runtime.auth.source !== \"local\") {\n fetched.push(`auth remote (${refreshed.runtime.auth.url})`);\n } else {\n const path = refreshed.runtime.auth.localPath\n ? ` (${relative(projectDir, refreshed.runtime.auth.localPath)})`\n : \"\";\n skipped.push(`auth local${path}`);\n }\n }\n\n for (const [key, plugin] of pluginEntries) {\n if (plugin.url && plugin.source !== \"local\") {\n fetched.push(`${key} remote (${plugin.url})`);\n } else if (plugin.localPath) {\n skipped.push(`${key} local (${relative(projectDir, plugin.localPath)})`);\n } else {\n skipped.push(`${key} no URL resolved`);\n }\n }\n\n const generated = [\"ui/src/lib/api-types.gen.ts\", \"ui/src/lib/auth-types.gen.ts\"];\n if (hasLocalApiWorkspace) {\n generated.push(\"api/src/lib/plugins-types.gen.ts\", \"api/src/lib/auth-types.gen.ts\");\n }\n if (existsSync(join(projectDir, \"host\", \"src\"))) {\n generated.push(\"host/src/lib/auth-types.gen.ts\");\n }\n for (const [key, _plugin] of pluginEntries) {\n const pluginSrc = join(\n projectDir,\n \"plugins\",\n key,\n \"src\",\n \"lib\",\n \"plugins-client.gen.ts\",\n );\n if (existsSync(pluginSrc)) {\n generated.push(`plugins/${key}/src/lib/plugins-client.gen.ts`);\n }\n }\n\n return {\n status: \"success\" as const,\n generated,\n fetched,\n skipped,\n failed: [],\n };\n }\n\n const artifacts = await generateCodeArtifacts(projectDir, refreshed.config, {\n runtimeConfig: refreshed.runtime,\n });\n\n const hasLocalApiWorkspace = existsSync(join(projectDir, \"api\", \"src\"));\n const generated = [\"ui/src/lib/api-types.gen.ts\"];\n if (hasLocalApiWorkspace) {\n generated.push(\"api/src/lib/plugins-types.gen.ts\", \"api/src/lib/auth-types.gen.ts\");\n }\n if (\n refreshed.runtime.auth &&\n (refreshed.runtime.auth.source !== \"local\" || refreshed.runtime.auth.localPath)\n ) {\n generated.push(\"ui/src/lib/auth-types.gen.ts\");\n }\n if (existsSync(join(projectDir, \"host\", \"src\"))) {\n generated.push(\"host/src/lib/auth-types.gen.ts\");\n }\n for (const [key, _plugin] of Object.entries(refreshed.runtime.plugins ?? {})) {\n const pluginSrc = join(projectDir, \"plugins\", key, \"src\", \"lib\", \"plugins-client.gen.ts\");\n if (existsSync(pluginSrc)) {\n generated.push(`plugins/${key}/src/lib/plugins-client.gen.ts`);\n }\n }\n\n const contractStatus = artifacts?.contractStatus ?? [];\n const fetched: string[] = [];\n const skipped: string[] = [];\n const failed: string[] = [];\n for (const entry of contractStatus) {\n if (entry.source === \"remote\") {\n fetched.push(entry.url ? `${entry.key} remote (${entry.url})` : entry.key);\n } else if (entry.source === \"local\") {\n const path = entry.localPath ? ` (${relative(projectDir, entry.localPath)})` : \"\";\n skipped.push(`${entry.key} local${path}`);\n } else if (entry.source === \"skipped\") {\n skipped.push(`${entry.key} no URL resolved`);\n } else if (entry.source === \"failed\") {\n const detail = entry.error ? `: ${entry.error}` : \"\";\n failed.push(`${entry.key}${detail}`);\n }\n }\n\n return {\n status: \"success\" as const,\n generated,\n fetched,\n skipped,\n failed,\n };\n } catch (error) {\n return {\n status: \"error\" as const,\n generated: [],\n fetched: [],\n skipped: [],\n failed: [],\n error: error instanceof Error ? error.message : \"Unknown error\",\n };\n }\n }),\n\n dbStudio: builder.dbStudio.handler(async ({ input }) => {\n try {\n const configPath = findConfigPath();\n if (!configPath) {\n return {\n status: \"error\" as const,\n plugin: input.plugin,\n source: \"remote\" as const,\n section: \"\",\n error: \"No bos.config.json found in current directory\",\n };\n }\n\n const projectDir = resolve(dirname(configPath));\n loadProjectEnv(projectDir);\n const refreshed = await loadResolvedConfig({ cwd: projectDir });\n if (!refreshed) {\n return {\n status: \"error\" as const,\n plugin: input.plugin,\n source: \"remote\" as const,\n section: \"\",\n error: \"Failed to load bos.config.json\",\n };\n }\n\n const { resolvePluginDbInfo } = await import(\"./cli/db-studio\");\n const info = resolvePluginDbInfo(input.plugin, refreshed.runtime, projectDir);\n\n return {\n status: \"success\" as const,\n plugin: info.key,\n source: info.source,\n section: info.section,\n databaseSecret: info.databaseSecret,\n databaseUrl: info.databaseUrl,\n workspaceDir: info.workspaceDir,\n };\n } catch (error) {\n return {\n status: \"error\" as const,\n plugin: input.plugin,\n source: \"remote\" as const,\n section: \"\",\n error: error instanceof Error ? error.message : \"Unknown error\",\n };\n }\n }),\n\n dbDoctor: builder.dbDoctor.handler(async ({ input }) => {\n try {\n const configPath = findConfigPath();\n if (!configPath) {\n return {\n status: \"error\" as const,\n plugin: input.plugin,\n slug: \"\",\n journalTable: \"\",\n journalSchema: \"\",\n diagnosis: \"error\",\n localMigrationCount: 0,\n appliedHashCount: 0,\n expectedTables: [],\n missingTables: [],\n error: \"No bos.config.json\",\n };\n }\n\n const projectDir = resolve(dirname(configPath));\n loadProjectEnv(projectDir);\n const refreshed = await loadResolvedConfig({ cwd: projectDir });\n if (!refreshed) {\n return {\n status: \"error\" as const,\n plugin: input.plugin,\n slug: \"\",\n journalTable: \"\",\n journalSchema: \"\",\n diagnosis: \"error\",\n localMigrationCount: 0,\n appliedHashCount: 0,\n expectedTables: [],\n missingTables: [],\n error: \"Failed to load config\",\n };\n }\n\n const { resolvePluginDbInfo } = await import(\"./cli/db-studio\");\n const info = resolvePluginDbInfo(input.plugin, refreshed.runtime, projectDir);\n\n const { diagnosePlugin } = await import(\"./cli/db-doctor\");\n const report = await diagnosePlugin(info);\n\n return {\n status: \"success\" as const,\n ...report,\n };\n } catch (error) {\n return {\n status: \"error\" as const,\n plugin: input.plugin,\n slug: \"\",\n journalTable: \"\",\n journalSchema: \"\",\n diagnosis: \"error\",\n localMigrationCount: 0,\n appliedHashCount: 0,\n expectedTables: [],\n missingTables: [],\n error: error instanceof Error ? error.message : \"Unknown error\",\n };\n }\n }),\n\n dbRepair: builder.dbRepair.handler(async ({ input }) => {\n try {\n const configPath = findConfigPath();\n if (!configPath) {\n return {\n status: \"error\" as const,\n message: \"No bos.config.json found\",\n diagnosis: null,\n error: \"No config\",\n };\n }\n\n const projectDir = resolve(dirname(configPath));\n loadProjectEnv(projectDir);\n const refreshed = await loadResolvedConfig({ cwd: projectDir });\n if (!refreshed) {\n return {\n status: \"error\" as const,\n message: \"Failed to load config\",\n diagnosis: null,\n error: \"Config load failed\",\n };\n }\n\n const { resolvePluginDbInfo } = await import(\"./cli/db-studio\");\n const info = resolvePluginDbInfo(input.plugin, refreshed.runtime, projectDir);\n\n const { repairPlugin } = await import(\"./cli/db-repair\");\n const result = await repairPlugin(info, input.mode ?? \"history-reset\");\n\n return {\n ...result,\n error: result.status === \"error\" ? result.message : undefined,\n };\n } catch (error) {\n return {\n status: \"error\" as const,\n message: error instanceof Error ? error.message : \"Unknown error\",\n diagnosis: null,\n error: error instanceof Error ? error.message : \"Unknown error\",\n };\n }\n }),\n\n status: builder.status.handler(async () => {\n try {\n const configPath = findConfigPath();\n if (!configPath) {\n return {\n status: \"error\" as const,\n packages: [],\n envFile: \"missing\" as const,\n error: \"No bos.config.json found in current directory\",\n };\n }\n\n const projectDir = resolve(dirname(configPath));\n return await getStatus(projectDir);\n } catch (error) {\n return {\n status: \"error\" as const,\n packages: [],\n envFile: \"missing\" as const,\n error: error instanceof Error ? error.message : \"Unknown error\",\n };\n }\n }),\n\n ps: builder.ps.handler(async () => {\n try {\n const entries = await Effect.runPromise(pruneDeadEffect(readRegistry()));\n return {\n status: \"ok\" as const,\n entries,\n };\n } catch (error) {\n return {\n status: \"error\" as const,\n entries: [],\n error: error instanceof Error ? error.message : \"Unknown error\",\n };\n }\n }),\n\n kill: builder.kill.handler(async ({ input }) => {\n try {\n const entries = await Effect.runPromise(pruneDeadEffect(readRegistry()));\n const configPath = findConfigPath();\n const targetConfigDir = input.all\n ? undefined\n : (input.configDir ?? (configPath ? resolve(dirname(configPath)) : undefined));\n\n const targets = targetConfigDir\n ? entries.filter((entry) => entry.configDir === targetConfigDir)\n : entries;\n\n const killed: Array<{ pid: number; configDir: string }> = [];\n const skipped: Array<{ pid: number; reason: string }> = [];\n\n for (const entry of targets) {\n try {\n process.kill(entry.pid, input.signal === \"SIGKILL\" ? \"SIGKILL\" : \"SIGTERM\");\n killed.push({ pid: entry.pid, configDir: entry.configDir });\n unregisterPid(entry.pid);\n } catch (err) {\n const code = (err as NodeJS.ErrnoException).code;\n if (code === \"ESRCH\") {\n skipped.push({ pid: entry.pid, reason: \"process already exited\" });\n unregisterPid(entry.pid);\n } else {\n skipped.push({\n pid: entry.pid,\n reason: (err as Error).message ?? \"kill failed\",\n });\n }\n }\n }\n\n return {\n status: \"killed\" as const,\n killed,\n skipped,\n };\n } catch (error) {\n return {\n status: \"error\" as const,\n killed: [],\n skipped: [],\n error: error instanceof Error ? error.message : \"Unknown error\",\n };\n }\n }),\n }),\n});\n\nfunction computeAllowedWorkspaces(overrides: string[], plugins?: string[]): string[] {\n const workspaces: string[] = [];\n for (const section of overrides) {\n if (section === \"host\") workspaces.push(\"host\");\n if (section === \"ui\") workspaces.push(\"ui\");\n if (section === \"api\") workspaces.push(\"api\");\n }\n if (plugins && plugins.length > 0) {\n workspaces.push(\"plugins/*\");\n }\n return workspaces;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyHA,MAAa,eAAe,IAAIA,yBAAa;AAE7C,IAAI,iBAAwC;AAC5C,IAAI,sBAA2C;AAE/C,SAAgB,oBAA0E;CACxF,MAAM,OAAO;CACb,MAAM,UAAU;CAChB,iBAAiB;CACjB,sBAAsB;CACtB,IAAI,CAAC,MAAM,OAAO;CAClB,OAAO,UAAU;EAAE,GAAG;EAAM;CAAQ,IAAI;AAC1C;AAEA,eAAe,UACb,SACA,MACA,IACY;CACZ,aAAa,KAAK,YAAY;EAAE,OAAO;EAAM,QAAQ;CAAU,CAAyB;CACxF,MAAM,YAAY,KAAK,IAAI;CAC3B,IAAI;EACF,MAAM,SAAS,MAAM,GAAG;EACxB,QAAQ,KAAK;GAAE;GAAM,YAAY,KAAK,IAAI,IAAI;EAAU,CAAC;EACzD,aAAa,KAAK,YAAY;GAC5B,OAAO;GACP,QAAQ;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