everything-dev 1.8.7 → 1.8.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -62,34 +62,37 @@ function renderStreamingView(initialProcesses, description, env, onExit) {
62
62
  const sectionedProcesses = getSectionedProcesses(initialProcesses);
63
63
  const columnWidths = getColumnWidths(initialProcesses);
64
64
  const lastLogBySource = /* @__PURE__ */ new Map();
65
- console.log();
66
- console.log(require_theme.colors.cyan(`${"".repeat(52)}`));
67
- console.log(` ${require_theme.icons.run} ${require_theme.colors.cyan(description.toUpperCase())}`);
68
- console.log(require_theme.colors.cyan(`${"─".repeat(52)}`));
69
- console.log();
70
- if (proxyTarget) {
71
- console.log(orange(` ${require_theme.icons.arrow} API PROXY → ${proxyTarget}`));
72
- console.log();
73
- }
65
+ const headerLines = [
66
+ "",
67
+ require_theme.colors.cyan(`${"─".repeat(52)}`),
68
+ ` ${require_theme.icons.run} ${require_theme.colors.cyan(description.toUpperCase())}`,
69
+ require_theme.colors.cyan(`${"─".repeat(52)}`),
70
+ ""
71
+ ];
72
+ if (proxyTarget) headerLines.push(orange(` ${require_theme.icons.arrow} API PROXY → ${proxyTarget}`), "");
74
73
  for (const section of sectionedProcesses) {
75
- console.log(require_theme.colors.cyan(` ${section.title}`));
74
+ headerLines.push(require_theme.colors.cyan(` ${section.title}`));
76
75
  for (const proc of section.processes) {
77
76
  const color = getServiceColor(proc.name);
78
77
  const sourceLabel = proc.source ? ` (${proc.source})` : "";
79
- console.log(`${require_theme.colors.dim(`[${getTimestamp()}]`)} ${color(`[${getDisplayName(proc.name).padEnd(columnWidths.name)}]`)} ${require_theme.icons.pending} waiting${sourceLabel.padEnd(columnWidths.source)}`);
78
+ headerLines.push(`${require_theme.colors.dim(`[${getTimestamp()}]`)} ${color(`[${getDisplayName(proc.name).padEnd(columnWidths.name)}]`)} ${require_theme.icons.pending} waiting${sourceLabel.padEnd(columnWidths.source)}`);
80
79
  }
81
- console.log();
80
+ headerLines.push("");
82
81
  }
82
+ console.log(headerLines.join("\n"));
83
83
  const checkAllReady = () => {
84
84
  if (allReadyPrinted) return;
85
85
  if (Array.from(processes.values()).every((p) => p.status === "ready")) {
86
86
  allReadyPrinted = true;
87
- console.log();
88
- console.log(require_theme.colors.dim(`${"".repeat(52)}`));
89
- console.log(require_theme.colors.green(`${require_theme.icons.ok} All ${processes.size} services ready`));
90
- console.log(require_theme.colors.green(`${require_theme.icons.arrow} http://localhost:${hostPort}`));
91
- console.log(require_theme.colors.dim(`${"─".repeat(52)}`));
92
- console.log();
87
+ const readyLines = [
88
+ "",
89
+ require_theme.colors.dim(`${"─".repeat(52)}`),
90
+ require_theme.colors.green(`${require_theme.icons.ok} All ${processes.size} services ready`),
91
+ require_theme.colors.green(`${require_theme.icons.arrow} http://localhost:${hostPort}`),
92
+ require_theme.colors.dim(`${"─".repeat(52)}`),
93
+ ""
94
+ ];
95
+ console.log(readyLines.join("\n"));
93
96
  }
94
97
  };
95
98
  const updateProcess = (name, status, message) => {
@@ -1 +1 @@
1
- {"version":3,"file":"streaming-view.cjs","names":["colors","icons","linkify"],"sources":["../../src/components/streaming-view.ts"],"sourcesContent":["import chalk from \"chalk\";\nimport { linkify } from \"../utils/linkify\";\nimport { colors, icons } from \"../utils/theme\";\nimport type { ProcessState, ProcessStatus } from \"./dev-view\";\n\nconst orange = chalk.hex(\"#ffaa00\");\nconst PLUGIN_PREFIX = \"plugin:\";\n\nexport interface StreamingViewHandle {\n updateProcess: (name: string, status: ProcessStatus, message?: string) => void;\n addLog: (source: string, line: string, isError?: boolean) => void;\n unmount: () => Promise<void> | void;\n}\n\nconst getTimestamp = (): string => {\n const now = new Date();\n return `${now.getHours().toString().padStart(2, \"0\")}:${now.getMinutes().toString().padStart(2, \"0\")}:${now.getSeconds().toString().padStart(2, \"0\")}`;\n};\n\nconst write = (text: string) => process.stdout.write(`${text}\\n`);\n\nconst getServiceColor = (name: string): ((s: string) => string) => {\n if (name.startsWith(PLUGIN_PREFIX)) return orange;\n if (name === \"host\") return colors.cyan;\n if (name === \"ui\" || name === \"ui-ssr\") return colors.magenta;\n if (name === \"api\") return colors.blue;\n return colors.white;\n};\n\nconst getDisplayName = (name: string): string => {\n return name.startsWith(PLUGIN_PREFIX)\n ? name.slice(PLUGIN_PREFIX.length).toUpperCase()\n : name.toUpperCase();\n};\n\nconst isPlugin = (name: string): boolean => name.startsWith(PLUGIN_PREFIX);\n\nconst getSectionedProcesses = (processes: ProcessState[]) => {\n const plugins = processes.filter((p) => isPlugin(p.name));\n const services = processes.filter((p) => !isPlugin(p.name));\n const sections: Array<{ key: string; title: string; processes: ProcessState[] }> = [];\n if (plugins.length > 0) sections.push({ key: \"plugins\", title: \"PLUGINS\", processes: plugins });\n if (services.length > 0)\n sections.push({ key: \"services\", title: \"SERVICES\", processes: services });\n return sections;\n};\n\nconst getColumnWidths = (processes: ProcessState[]) => {\n const name = Math.max(6, ...processes.map((p) => getDisplayName(p.name).length));\n const source = Math.max(10, ...processes.map((p) => (p.source ? ` (${p.source})`.length : 0)));\n return { name, source };\n};\n\nconst getStatusIcon = (status: ProcessStatus): string => {\n switch (status) {\n case \"pending\":\n return icons.pending;\n case \"starting\":\n return icons.scan;\n case \"ready\":\n return icons.ok;\n case \"error\":\n return icons.err;\n }\n};\n\nexport function renderStreamingView(\n initialProcesses: ProcessState[],\n description: string,\n env: Record<string, string>,\n onExit?: () => Promise<void> | void,\n): StreamingViewHandle {\n const processes = new Map<string, ProcessState>();\n for (const p of initialProcesses) {\n processes.set(p.name, { ...p });\n }\n\n let allReadyPrinted = false;\n const hostProcess = initialProcesses.find((p) => p.name === \"host\");\n const hostPort = hostProcess?.port || 3000;\n const proxyTarget = env.API_PROXY;\n const sectionedProcesses = getSectionedProcesses(initialProcesses);\n const columnWidths = getColumnWidths(initialProcesses);\n const lastLogBySource = new Map<string, string>();\n\n console.log();\n console.log(colors.cyan(`${\"─\".repeat(52)}`));\n console.log(` ${icons.run} ${colors.cyan(description.toUpperCase())}`);\n console.log(colors.cyan(`${\"─\".repeat(52)}`));\n console.log();\n\n if (proxyTarget) {\n console.log(orange(` ${icons.arrow} API PROXY → ${proxyTarget}`));\n console.log();\n }\n\n for (const section of sectionedProcesses) {\n console.log(colors.cyan(` ${section.title}`));\n for (const proc of section.processes) {\n const color = getServiceColor(proc.name);\n const sourceLabel = proc.source ? ` (${proc.source})` : \"\";\n console.log(\n `${colors.dim(`[${getTimestamp()}]`)} ${color(`[${getDisplayName(proc.name).padEnd(columnWidths.name)}]`)} ${icons.pending} waiting${sourceLabel.padEnd(columnWidths.source)}`,\n );\n }\n console.log();\n }\n\n const checkAllReady = () => {\n if (allReadyPrinted) return;\n const allReady = Array.from(processes.values()).every((p) => p.status === \"ready\");\n if (allReady) {\n allReadyPrinted = true;\n console.log();\n console.log(colors.dim(`${\"─\".repeat(52)}`));\n console.log(colors.green(`${icons.ok} All ${processes.size} services ready`));\n console.log(colors.green(`${icons.arrow} http://localhost:${hostPort}`));\n console.log(colors.dim(`${\"─\".repeat(52)}`));\n console.log();\n }\n };\n\n const updateProcess = (name: string, status: ProcessStatus, message?: string) => {\n const proc = processes.get(name);\n if (!proc) return;\n\n proc.status = status;\n if (message) proc.message = message;\n\n const color = getServiceColor(name);\n const icon = getStatusIcon(status);\n const displayName = getDisplayName(name).padEnd(columnWidths.name);\n const sourceLabel = proc?.source ? ` (${proc.source})` : \"\";\n const isRemote = proc?.source === \"remote\";\n const isHost = name === \"host\";\n const showPort = proc.port > 0 && (isHost || !isRemote) && status === \"ready\";\n const statusText =\n status === \"ready\"\n ? isRemote && !isHost\n ? \"loaded\"\n : \"running\"\n : status === \"starting\"\n ? \"starting\"\n : status === \"error\"\n ? \"failed\"\n : \"waiting\";\n const portStr = showPort ? ` :${proc.port}` : \"\";\n\n write(\n `${colors.dim(`[${getTimestamp()}]`)} ${color(`[${displayName}]`)} ${status === \"ready\" ? colors.green(icon) : status === \"error\" ? colors.error(icon) : icon} ${statusText}${sourceLabel.padEnd(columnWidths.source)}${portStr}`,\n );\n\n checkAllReady();\n };\n\n const addLog = (source: string, line: string, isError = false) => {\n const lastLine = lastLogBySource.get(source);\n const nextLine = `${isError ? \"ERR\" : \"OUT\"}:${line}`;\n if (lastLine === nextLine) return;\n lastLogBySource.set(source, nextLine);\n\n const color = getServiceColor(source);\n const logColor = isError ? colors.error : colors.dim;\n write(\n `${colors.dim(`[${getTimestamp()}]`)} ${color(`[${source.toUpperCase()}]`)} ${colors.dim(\"│\")} ${logColor(linkify(line))}`,\n );\n };\n\n const unmount = () => onExit?.();\n\n return { updateProcess, addLog, unmount };\n}\n"],"mappings":";;;;;;;AAKA,MAAM,SAAS,cAAM,IAAI,UAAU;AACnC,MAAM,gBAAgB;AAQtB,MAAM,qBAA6B;CACjC,MAAM,sBAAM,IAAI,MAAM;AACtB,QAAO,GAAG,IAAI,UAAU,CAAC,UAAU,CAAC,SAAS,GAAG,IAAI,CAAC,GAAG,IAAI,YAAY,CAAC,UAAU,CAAC,SAAS,GAAG,IAAI,CAAC,GAAG,IAAI,YAAY,CAAC,UAAU,CAAC,SAAS,GAAG,IAAI;;AAGtJ,MAAM,SAAS,SAAiB,QAAQ,OAAO,MAAM,GAAG,KAAK,IAAI;AAEjE,MAAM,mBAAmB,SAA0C;AACjE,KAAI,KAAK,WAAW,cAAc,CAAE,QAAO;AAC3C,KAAI,SAAS,OAAQ,QAAOA,qBAAO;AACnC,KAAI,SAAS,QAAQ,SAAS,SAAU,QAAOA,qBAAO;AACtD,KAAI,SAAS,MAAO,QAAOA,qBAAO;AAClC,QAAOA,qBAAO;;AAGhB,MAAM,kBAAkB,SAAyB;AAC/C,QAAO,KAAK,WAAW,cAAc,GACjC,KAAK,MAAM,EAAqB,CAAC,aAAa,GAC9C,KAAK,aAAa;;AAGxB,MAAM,YAAY,SAA0B,KAAK,WAAW,cAAc;AAE1E,MAAM,yBAAyB,cAA8B;CAC3D,MAAM,UAAU,UAAU,QAAQ,MAAM,SAAS,EAAE,KAAK,CAAC;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AAE;EAAe;EAAQ;EAAS"}
1
+ {"version":3,"file":"streaming-view.cjs","names":["colors","icons","linkify"],"sources":["../../src/components/streaming-view.ts"],"sourcesContent":["import chalk from \"chalk\";\nimport { linkify } from \"../utils/linkify\";\nimport { colors, icons } from \"../utils/theme\";\nimport type { ProcessState, ProcessStatus } from \"./dev-view\";\n\nconst orange = chalk.hex(\"#ffaa00\");\nconst PLUGIN_PREFIX = \"plugin:\";\n\nexport interface StreamingViewHandle {\n updateProcess: (name: string, status: ProcessStatus, message?: string) => void;\n addLog: (source: string, line: string, isError?: boolean) => void;\n unmount: () => Promise<void> | void;\n}\n\nconst getTimestamp = (): string => {\n const now = new Date();\n return `${now.getHours().toString().padStart(2, \"0\")}:${now.getMinutes().toString().padStart(2, \"0\")}:${now.getSeconds().toString().padStart(2, \"0\")}`;\n};\n\nconst write = (text: string) => process.stdout.write(`${text}\\n`);\n\nconst getServiceColor = (name: string): ((s: string) => string) => {\n if (name.startsWith(PLUGIN_PREFIX)) return orange;\n if (name === \"host\") return colors.cyan;\n if (name === \"ui\" || name === \"ui-ssr\") return colors.magenta;\n if (name === \"api\") return colors.blue;\n return colors.white;\n};\n\nconst getDisplayName = (name: string): string => {\n return name.startsWith(PLUGIN_PREFIX)\n ? name.slice(PLUGIN_PREFIX.length).toUpperCase()\n : name.toUpperCase();\n};\n\nconst isPlugin = (name: string): boolean => name.startsWith(PLUGIN_PREFIX);\n\nconst getSectionedProcesses = (processes: ProcessState[]) => {\n const plugins = processes.filter((p) => isPlugin(p.name));\n const services = processes.filter((p) => !isPlugin(p.name));\n const sections: Array<{ key: string; title: string; processes: ProcessState[] }> = [];\n if (plugins.length > 0) sections.push({ key: \"plugins\", title: \"PLUGINS\", processes: plugins });\n if (services.length > 0)\n sections.push({ key: \"services\", title: \"SERVICES\", processes: services });\n return sections;\n};\n\nconst getColumnWidths = (processes: ProcessState[]) => {\n const name = Math.max(6, ...processes.map((p) => getDisplayName(p.name).length));\n const source = Math.max(10, ...processes.map((p) => (p.source ? ` (${p.source})`.length : 0)));\n return { name, source };\n};\n\nconst getStatusIcon = (status: ProcessStatus): string => {\n switch (status) {\n case \"pending\":\n return icons.pending;\n case \"starting\":\n return icons.scan;\n case \"ready\":\n return icons.ok;\n case \"error\":\n return icons.err;\n }\n};\n\nexport function renderStreamingView(\n initialProcesses: ProcessState[],\n description: string,\n env: Record<string, string>,\n onExit?: () => Promise<void> | void,\n): StreamingViewHandle {\n const processes = new Map<string, ProcessState>();\n for (const p of initialProcesses) {\n processes.set(p.name, { ...p });\n }\n\n let allReadyPrinted = false;\n const hostProcess = initialProcesses.find((p) => p.name === \"host\");\n const hostPort = hostProcess?.port || 3000;\n const proxyTarget = env.API_PROXY;\n const sectionedProcesses = getSectionedProcesses(initialProcesses);\n const columnWidths = getColumnWidths(initialProcesses);\n const lastLogBySource = new Map<string, string>();\n\n const headerLines: string[] = [\n \"\",\n colors.cyan(`${\"─\".repeat(52)}`),\n ` ${icons.run} ${colors.cyan(description.toUpperCase())}`,\n colors.cyan(`${\"─\".repeat(52)}`),\n \"\",\n ];\n\n if (proxyTarget) {\n headerLines.push(orange(` ${icons.arrow} API PROXY → ${proxyTarget}`), \"\");\n }\n\n for (const section of sectionedProcesses) {\n headerLines.push(colors.cyan(` ${section.title}`));\n for (const proc of section.processes) {\n const color = getServiceColor(proc.name);\n const sourceLabel = proc.source ? ` (${proc.source})` : \"\";\n headerLines.push(\n `${colors.dim(`[${getTimestamp()}]`)} ${color(`[${getDisplayName(proc.name).padEnd(columnWidths.name)}]`)} ${icons.pending} waiting${sourceLabel.padEnd(columnWidths.source)}`,\n );\n }\n headerLines.push(\"\");\n }\n console.log(headerLines.join(\"\\n\"));\n\n const checkAllReady = () => {\n if (allReadyPrinted) return;\n const allReady = Array.from(processes.values()).every((p) => p.status === \"ready\");\n if (allReady) {\n allReadyPrinted = true;\n const readyLines = [\n \"\",\n colors.dim(`${\"─\".repeat(52)}`),\n colors.green(`${icons.ok} All ${processes.size} services ready`),\n colors.green(`${icons.arrow} http://localhost:${hostPort}`),\n colors.dim(`${\"─\".repeat(52)}`),\n \"\",\n ];\n console.log(readyLines.join(\"\\n\"));\n }\n };\n\n const updateProcess = (name: string, status: ProcessStatus, message?: string) => {\n const proc = processes.get(name);\n if (!proc) return;\n\n proc.status = status;\n if (message) proc.message = message;\n\n const color = getServiceColor(name);\n const icon = getStatusIcon(status);\n const displayName = getDisplayName(name).padEnd(columnWidths.name);\n const sourceLabel = proc?.source ? ` (${proc.source})` : \"\";\n const isRemote = proc?.source === \"remote\";\n const isHost = name === \"host\";\n const showPort = proc.port > 0 && (isHost || !isRemote) && status === \"ready\";\n const statusText =\n status === \"ready\"\n ? isRemote && !isHost\n ? \"loaded\"\n : \"running\"\n : status === \"starting\"\n ? \"starting\"\n : status === \"error\"\n ? \"failed\"\n : \"waiting\";\n const portStr = showPort ? ` :${proc.port}` : \"\";\n\n write(\n `${colors.dim(`[${getTimestamp()}]`)} ${color(`[${displayName}]`)} ${status === \"ready\" ? colors.green(icon) : status === \"error\" ? colors.error(icon) : icon} ${statusText}${sourceLabel.padEnd(columnWidths.source)}${portStr}`,\n );\n\n checkAllReady();\n };\n\n const addLog = (source: string, line: string, isError = false) => {\n const lastLine = lastLogBySource.get(source);\n const nextLine = `${isError ? \"ERR\" : \"OUT\"}:${line}`;\n if (lastLine === nextLine) return;\n lastLogBySource.set(source, nextLine);\n\n const color = getServiceColor(source);\n const logColor = isError ? colors.error : colors.dim;\n write(\n `${colors.dim(`[${getTimestamp()}]`)} ${color(`[${source.toUpperCase()}]`)} ${colors.dim(\"│\")} ${logColor(linkify(line))}`,\n );\n };\n\n const unmount = () => onExit?.();\n\n return { updateProcess, addLog, unmount };\n}\n"],"mappings":";;;;;;;AAKA,MAAM,SAAS,cAAM,IAAI,UAAU;AACnC,MAAM,gBAAgB;AAQtB,MAAM,qBAA6B;CACjC,MAAM,sBAAM,IAAI,MAAM;AACtB,QAAO,GAAG,IAAI,UAAU,CAAC,UAAU,CAAC,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GAAG,WAAW,UAAUA,qBAAO,MAAM,KAAK,GAAG,KAAK,GAAG,aAAa,YAAY,OAAO,aAAa,OAAO,GAAG,UAC1N;AAED,iBAAe;;CAGjB,MAAM,UAAU,QAAgB,MAAc,UAAU,UAAU;EAChE,MAAM,WAAW,gBAAgB,IAAI,OAAO;EAC5C,MAAM,WAAW,GAAG,UAAU,QAAQ,MAAM,GAAG;AAC/C,MAAI,aAAa,SAAU;AAC3B,kBAAgB,IAAI,QAAQ,SAAS;EAErC,MAAM,QAAQ,gBAAgB,OAAO;EACrC,MAAM,WAAW,UAAUA,qBAAO,QAAQA,qBAAO;AACjD,QACE,GAAGA,qBAAO,IAAI,IAAI,cAAc,CAAC,GAAG,CAAC,GAAG,MAAM,IAAI,OAAO,aAAa,CAAC,GAAG,CAAC,IAAIA,qBAAO,IAAI,IAAI,CAAC,GAAG,SAASE,wBAAQ,KAAK,CAAC,GAC1H;;CAGH,MAAM,gBAAgB,UAAU;AAEhC,QAAO;EAAE;EAAe;EAAQ;EAAS"}
@@ -60,34 +60,37 @@ function renderStreamingView(initialProcesses, description, env, onExit) {
60
60
  const sectionedProcesses = getSectionedProcesses(initialProcesses);
61
61
  const columnWidths = getColumnWidths(initialProcesses);
62
62
  const lastLogBySource = /* @__PURE__ */ new Map();
63
- console.log();
64
- console.log(colors.cyan(`${"".repeat(52)}`));
65
- console.log(` ${icons.run} ${colors.cyan(description.toUpperCase())}`);
66
- console.log(colors.cyan(`${"─".repeat(52)}`));
67
- console.log();
68
- if (proxyTarget) {
69
- console.log(orange(` ${icons.arrow} API PROXY → ${proxyTarget}`));
70
- console.log();
71
- }
63
+ const headerLines = [
64
+ "",
65
+ colors.cyan(`${"─".repeat(52)}`),
66
+ ` ${icons.run} ${colors.cyan(description.toUpperCase())}`,
67
+ colors.cyan(`${"─".repeat(52)}`),
68
+ ""
69
+ ];
70
+ if (proxyTarget) headerLines.push(orange(` ${icons.arrow} API PROXY → ${proxyTarget}`), "");
72
71
  for (const section of sectionedProcesses) {
73
- console.log(colors.cyan(` ${section.title}`));
72
+ headerLines.push(colors.cyan(` ${section.title}`));
74
73
  for (const proc of section.processes) {
75
74
  const color = getServiceColor(proc.name);
76
75
  const sourceLabel = proc.source ? ` (${proc.source})` : "";
77
- console.log(`${colors.dim(`[${getTimestamp()}]`)} ${color(`[${getDisplayName(proc.name).padEnd(columnWidths.name)}]`)} ${icons.pending} waiting${sourceLabel.padEnd(columnWidths.source)}`);
76
+ headerLines.push(`${colors.dim(`[${getTimestamp()}]`)} ${color(`[${getDisplayName(proc.name).padEnd(columnWidths.name)}]`)} ${icons.pending} waiting${sourceLabel.padEnd(columnWidths.source)}`);
78
77
  }
79
- console.log();
78
+ headerLines.push("");
80
79
  }
80
+ console.log(headerLines.join("\n"));
81
81
  const checkAllReady = () => {
82
82
  if (allReadyPrinted) return;
83
83
  if (Array.from(processes.values()).every((p) => p.status === "ready")) {
84
84
  allReadyPrinted = true;
85
- console.log();
86
- console.log(colors.dim(`${"".repeat(52)}`));
87
- console.log(colors.green(`${icons.ok} All ${processes.size} services ready`));
88
- console.log(colors.green(`${icons.arrow} http://localhost:${hostPort}`));
89
- console.log(colors.dim(`${"─".repeat(52)}`));
90
- console.log();
85
+ const readyLines = [
86
+ "",
87
+ colors.dim(`${"─".repeat(52)}`),
88
+ colors.green(`${icons.ok} All ${processes.size} services ready`),
89
+ colors.green(`${icons.arrow} http://localhost:${hostPort}`),
90
+ colors.dim(`${"─".repeat(52)}`),
91
+ ""
92
+ ];
93
+ console.log(readyLines.join("\n"));
91
94
  }
92
95
  };
93
96
  const updateProcess = (name, status, message) => {
@@ -1 +1 @@
1
- {"version":3,"file":"streaming-view.mjs","names":[],"sources":["../../src/components/streaming-view.ts"],"sourcesContent":["import chalk from \"chalk\";\nimport { linkify } from \"../utils/linkify\";\nimport { colors, icons } from \"../utils/theme\";\nimport type { ProcessState, ProcessStatus } from \"./dev-view\";\n\nconst orange = chalk.hex(\"#ffaa00\");\nconst PLUGIN_PREFIX = \"plugin:\";\n\nexport interface StreamingViewHandle {\n updateProcess: (name: string, status: ProcessStatus, message?: string) => void;\n addLog: (source: string, line: string, isError?: boolean) => void;\n unmount: () => Promise<void> | void;\n}\n\nconst getTimestamp = (): string => {\n const now = new Date();\n return `${now.getHours().toString().padStart(2, \"0\")}:${now.getMinutes().toString().padStart(2, \"0\")}:${now.getSeconds().toString().padStart(2, \"0\")}`;\n};\n\nconst write = (text: string) => process.stdout.write(`${text}\\n`);\n\nconst getServiceColor = (name: string): ((s: string) => string) => {\n if (name.startsWith(PLUGIN_PREFIX)) return orange;\n if (name === \"host\") return colors.cyan;\n if (name === \"ui\" || name === \"ui-ssr\") return colors.magenta;\n if (name === \"api\") return colors.blue;\n return colors.white;\n};\n\nconst getDisplayName = (name: string): string => {\n return name.startsWith(PLUGIN_PREFIX)\n ? name.slice(PLUGIN_PREFIX.length).toUpperCase()\n : name.toUpperCase();\n};\n\nconst isPlugin = (name: string): boolean => name.startsWith(PLUGIN_PREFIX);\n\nconst getSectionedProcesses = (processes: ProcessState[]) => {\n const plugins = processes.filter((p) => isPlugin(p.name));\n const services = processes.filter((p) => !isPlugin(p.name));\n const sections: Array<{ key: string; title: string; processes: ProcessState[] }> = [];\n if (plugins.length > 0) sections.push({ key: \"plugins\", title: \"PLUGINS\", processes: plugins });\n if (services.length > 0)\n sections.push({ key: \"services\", title: \"SERVICES\", processes: services });\n return sections;\n};\n\nconst getColumnWidths = (processes: ProcessState[]) => {\n const name = Math.max(6, ...processes.map((p) => getDisplayName(p.name).length));\n const source = Math.max(10, ...processes.map((p) => (p.source ? ` (${p.source})`.length : 0)));\n return { name, source };\n};\n\nconst getStatusIcon = (status: ProcessStatus): string => {\n switch (status) {\n case \"pending\":\n return icons.pending;\n case \"starting\":\n return icons.scan;\n case \"ready\":\n return icons.ok;\n case \"error\":\n return icons.err;\n }\n};\n\nexport function renderStreamingView(\n initialProcesses: ProcessState[],\n description: string,\n env: Record<string, string>,\n onExit?: () => Promise<void> | void,\n): StreamingViewHandle {\n const processes = new Map<string, ProcessState>();\n for (const p of initialProcesses) {\n processes.set(p.name, { ...p });\n }\n\n let allReadyPrinted = false;\n const hostProcess = initialProcesses.find((p) => p.name === \"host\");\n const hostPort = hostProcess?.port || 3000;\n const proxyTarget = env.API_PROXY;\n const sectionedProcesses = getSectionedProcesses(initialProcesses);\n const columnWidths = getColumnWidths(initialProcesses);\n const lastLogBySource = new Map<string, string>();\n\n console.log();\n console.log(colors.cyan(`${\"─\".repeat(52)}`));\n console.log(` ${icons.run} ${colors.cyan(description.toUpperCase())}`);\n console.log(colors.cyan(`${\"─\".repeat(52)}`));\n console.log();\n\n if (proxyTarget) {\n console.log(orange(` ${icons.arrow} API PROXY → ${proxyTarget}`));\n console.log();\n }\n\n for (const section of sectionedProcesses) {\n console.log(colors.cyan(` ${section.title}`));\n for (const proc of section.processes) {\n const color = getServiceColor(proc.name);\n const sourceLabel = proc.source ? ` (${proc.source})` : \"\";\n console.log(\n `${colors.dim(`[${getTimestamp()}]`)} ${color(`[${getDisplayName(proc.name).padEnd(columnWidths.name)}]`)} ${icons.pending} waiting${sourceLabel.padEnd(columnWidths.source)}`,\n );\n }\n console.log();\n }\n\n const checkAllReady = () => {\n if (allReadyPrinted) return;\n const allReady = Array.from(processes.values()).every((p) => p.status === \"ready\");\n if (allReady) {\n allReadyPrinted = true;\n console.log();\n console.log(colors.dim(`${\"─\".repeat(52)}`));\n console.log(colors.green(`${icons.ok} All ${processes.size} services ready`));\n console.log(colors.green(`${icons.arrow} http://localhost:${hostPort}`));\n console.log(colors.dim(`${\"─\".repeat(52)}`));\n console.log();\n }\n };\n\n const updateProcess = (name: string, status: ProcessStatus, message?: string) => {\n const proc = processes.get(name);\n if (!proc) return;\n\n proc.status = status;\n if (message) proc.message = message;\n\n const color = getServiceColor(name);\n const icon = getStatusIcon(status);\n const displayName = getDisplayName(name).padEnd(columnWidths.name);\n const sourceLabel = proc?.source ? ` (${proc.source})` : \"\";\n const isRemote = proc?.source === \"remote\";\n const isHost = name === \"host\";\n const showPort = proc.port > 0 && (isHost || !isRemote) && status === \"ready\";\n const statusText =\n status === \"ready\"\n ? isRemote && !isHost\n ? \"loaded\"\n : \"running\"\n : status === \"starting\"\n ? \"starting\"\n : status === \"error\"\n ? \"failed\"\n : \"waiting\";\n const portStr = showPort ? ` :${proc.port}` : \"\";\n\n write(\n `${colors.dim(`[${getTimestamp()}]`)} ${color(`[${displayName}]`)} ${status === \"ready\" ? colors.green(icon) : status === \"error\" ? colors.error(icon) : icon} ${statusText}${sourceLabel.padEnd(columnWidths.source)}${portStr}`,\n );\n\n checkAllReady();\n };\n\n const addLog = (source: string, line: string, isError = false) => {\n const lastLine = lastLogBySource.get(source);\n const nextLine = `${isError ? \"ERR\" : \"OUT\"}:${line}`;\n if (lastLine === nextLine) return;\n lastLogBySource.set(source, nextLine);\n\n const color = getServiceColor(source);\n const logColor = isError ? colors.error : colors.dim;\n write(\n `${colors.dim(`[${getTimestamp()}]`)} ${color(`[${source.toUpperCase()}]`)} ${colors.dim(\"│\")} ${logColor(linkify(line))}`,\n );\n };\n\n const unmount = () => onExit?.();\n\n return { updateProcess, addLog, unmount };\n}\n"],"mappings":";;;;;AAKA,MAAM,SAAS,MAAM,IAAI,UAAU;AACnC,MAAM,gBAAgB;AAQtB,MAAM,qBAA6B;CACjC,MAAM,sBAAM,IAAI,MAAM;AACtB,QAAO,GAAG,IAAI,UAAU,CAAC,UAAU,CAAC,SAAS,GAAG,IAAI,CAAC,GAAG,IAAI,YAAY,CAAC,UAAU,CAAC,SAAS,GAAG,IAAI,CAAC,GAAG,IAAI,YAAY,CAAC,UAAU,CAAC,SAAS,GAAG,IAAI;;AAGtJ,MAAM,SAAS,SAAiB,QAAQ,OAAO,MAAM,GAAG,KAAK,IAAI;AAEjE,MAAM,mBAAmB,SAA0C;AACjE,KAAI,KAAK,WAAW,cAAc,CAAE,QAAO;AAC3C,KAAI,SAAS,OAAQ,QAAO,OAAO;AACnC,KAAI,SAAS,QA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,QAAQ,gBAAgB,OAAO;EACrC,MAAM,WAAW,UAAU,OAAO,QAAQ,OAAO;AACjD,QACE,GAAG,OAAO,IAAI,IAAI,cAAc,CAAC,GAAG,CAAC,GAAG,MAAM,IAAI,OAAO,aAAa,CAAC,GAAG,CAAC,IAAI,OAAO,IAAI,IAAI,CAAC,GAAG,SAAS,QAAQ,KAAK,CAAC,GAC1H;;CAGH,MAAM,gBAAgB,UAAU;AAEhC,QAAO;EAAE;EAAe;EAAQ;EAAS"}
1
+ {"version":3,"file":"streaming-view.mjs","names":[],"sources":["../../src/components/streaming-view.ts"],"sourcesContent":["import chalk from \"chalk\";\nimport { linkify } from \"../utils/linkify\";\nimport { colors, icons } from \"../utils/theme\";\nimport type { ProcessState, ProcessStatus } from \"./dev-view\";\n\nconst orange = chalk.hex(\"#ffaa00\");\nconst PLUGIN_PREFIX = \"plugin:\";\n\nexport interface StreamingViewHandle {\n updateProcess: (name: string, status: ProcessStatus, message?: string) => void;\n addLog: (source: string, line: string, isError?: boolean) => void;\n unmount: () => Promise<void> | void;\n}\n\nconst getTimestamp = (): string => {\n const now = new Date();\n return `${now.getHours().toString().padStart(2, \"0\")}:${now.getMinutes().toString().padStart(2, \"0\")}:${now.getSeconds().toString().padStart(2, \"0\")}`;\n};\n\nconst write = (text: string) => process.stdout.write(`${text}\\n`);\n\nconst getServiceColor = (name: string): ((s: string) => string) => {\n if (name.startsWith(PLUGIN_PREFIX)) return orange;\n if (name === \"host\") return colors.cyan;\n if (name === \"ui\" || name === \"ui-ssr\") return colors.magenta;\n if (name === \"api\") return colors.blue;\n return colors.white;\n};\n\nconst getDisplayName = (name: string): string => {\n return name.startsWith(PLUGIN_PREFIX)\n ? name.slice(PLUGIN_PREFIX.length).toUpperCase()\n : name.toUpperCase();\n};\n\nconst isPlugin = (name: string): boolean => name.startsWith(PLUGIN_PREFIX);\n\nconst getSectionedProcesses = (processes: ProcessState[]) => {\n const plugins = processes.filter((p) => isPlugin(p.name));\n const services = processes.filter((p) => !isPlugin(p.name));\n const sections: Array<{ key: string; title: string; processes: ProcessState[] }> = [];\n if (plugins.length > 0) sections.push({ key: \"plugins\", title: \"PLUGINS\", processes: plugins });\n if (services.length > 0)\n sections.push({ key: \"services\", title: \"SERVICES\", processes: services });\n return sections;\n};\n\nconst getColumnWidths = (processes: ProcessState[]) => {\n const name = Math.max(6, ...processes.map((p) => getDisplayName(p.name).length));\n const source = Math.max(10, ...processes.map((p) => (p.source ? ` (${p.source})`.length : 0)));\n return { name, source };\n};\n\nconst getStatusIcon = (status: ProcessStatus): string => {\n switch (status) {\n case \"pending\":\n return icons.pending;\n case \"starting\":\n return icons.scan;\n case \"ready\":\n return icons.ok;\n case \"error\":\n return icons.err;\n }\n};\n\nexport function renderStreamingView(\n initialProcesses: ProcessState[],\n description: string,\n env: Record<string, string>,\n onExit?: () => Promise<void> | void,\n): StreamingViewHandle {\n const processes = new Map<string, ProcessState>();\n for (const p of initialProcesses) {\n processes.set(p.name, { ...p });\n }\n\n let allReadyPrinted = false;\n const hostProcess = initialProcesses.find((p) => p.name === \"host\");\n const hostPort = hostProcess?.port || 3000;\n const proxyTarget = env.API_PROXY;\n const sectionedProcesses = getSectionedProcesses(initialProcesses);\n const columnWidths = getColumnWidths(initialProcesses);\n const lastLogBySource = new Map<string, string>();\n\n const headerLines: string[] = [\n \"\",\n colors.cyan(`${\"─\".repeat(52)}`),\n ` ${icons.run} ${colors.cyan(description.toUpperCase())}`,\n colors.cyan(`${\"─\".repeat(52)}`),\n \"\",\n ];\n\n if (proxyTarget) {\n headerLines.push(orange(` ${icons.arrow} API PROXY → ${proxyTarget}`), \"\");\n }\n\n for (const section of sectionedProcesses) {\n headerLines.push(colors.cyan(` ${section.title}`));\n for (const proc of section.processes) {\n const color = getServiceColor(proc.name);\n const sourceLabel = proc.source ? ` (${proc.source})` : \"\";\n headerLines.push(\n `${colors.dim(`[${getTimestamp()}]`)} ${color(`[${getDisplayName(proc.name).padEnd(columnWidths.name)}]`)} ${icons.pending} waiting${sourceLabel.padEnd(columnWidths.source)}`,\n );\n }\n headerLines.push(\"\");\n }\n console.log(headerLines.join(\"\\n\"));\n\n const checkAllReady = () => {\n if (allReadyPrinted) return;\n const allReady = Array.from(processes.values()).every((p) => p.status === \"ready\");\n if (allReady) {\n allReadyPrinted = true;\n const readyLines = [\n \"\",\n colors.dim(`${\"─\".repeat(52)}`),\n colors.green(`${icons.ok} All ${processes.size} services ready`),\n colors.green(`${icons.arrow} http://localhost:${hostPort}`),\n colors.dim(`${\"─\".repeat(52)}`),\n \"\",\n ];\n console.log(readyLines.join(\"\\n\"));\n }\n };\n\n const updateProcess = (name: string, status: ProcessStatus, message?: string) => {\n const proc = processes.get(name);\n if (!proc) return;\n\n proc.status = status;\n if (message) proc.message = message;\n\n const color = getServiceColor(name);\n const icon = getStatusIcon(status);\n const displayName = getDisplayName(name).padEnd(columnWidths.name);\n const sourceLabel = proc?.source ? ` (${proc.source})` : \"\";\n const isRemote = proc?.source === \"remote\";\n const isHost = name === \"host\";\n const showPort = proc.port > 0 && (isHost || !isRemote) && status === \"ready\";\n const statusText =\n status === \"ready\"\n ? isRemote && !isHost\n ? \"loaded\"\n : \"running\"\n : status === \"starting\"\n ? \"starting\"\n : status === \"error\"\n ? \"failed\"\n : \"waiting\";\n const portStr = showPort ? ` :${proc.port}` : \"\";\n\n write(\n `${colors.dim(`[${getTimestamp()}]`)} ${color(`[${displayName}]`)} ${status === \"ready\" ? colors.green(icon) : status === \"error\" ? colors.error(icon) : icon} ${statusText}${sourceLabel.padEnd(columnWidths.source)}${portStr}`,\n );\n\n checkAllReady();\n };\n\n const addLog = (source: string, line: string, isError = false) => {\n const lastLine = lastLogBySource.get(source);\n const nextLine = `${isError ? \"ERR\" : \"OUT\"}:${line}`;\n if (lastLine === nextLine) return;\n lastLogBySource.set(source, nextLine);\n\n const color = getServiceColor(source);\n const logColor = isError ? colors.error : colors.dim;\n write(\n `${colors.dim(`[${getTimestamp()}]`)} ${color(`[${source.toUpperCase()}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ACA,YACF,WAAW,aACT,aACA,WAAW,UACT,WACA;EACV,MAAM,UAAU,WAAW,KAAK,KAAK,SAAS;AAE9C,QACE,GAAG,OAAO,IAAI,IAAI,cAAc,CAAC,GAAG,CAAC,GAAG,MAAM,IAAI,YAAY,GAAG,CAAC,IAAI,WAAW,UAAU,OAAO,MAAM,KAAK,GAAG,WAAW,UAAU,OAAO,MAAM,KAAK,GAAG,KAAK,GAAG,aAAa,YAAY,OAAO,aAAa,OAAO,GAAG,UAC1N;AAED,iBAAe;;CAGjB,MAAM,UAAU,QAAgB,MAAc,UAAU,UAAU;EAChE,MAAM,WAAW,gBAAgB,IAAI,OAAO;EAC5C,MAAM,WAAW,GAAG,UAAU,QAAQ,MAAM,GAAG;AAC/C,MAAI,aAAa,SAAU;AAC3B,kBAAgB,IAAI,QAAQ,SAAS;EAErC,MAAM,QAAQ,gBAAgB,OAAO;EACrC,MAAM,WAAW,UAAU,OAAO,QAAQ,OAAO;AACjD,QACE,GAAG,OAAO,IAAI,IAAI,cAAc,CAAC,GAAG,CAAC,GAAG,MAAM,IAAI,OAAO,aAAa,CAAC,GAAG,CAAC,IAAI,OAAO,IAAI,IAAI,CAAC,GAAG,SAAS,QAAQ,KAAK,CAAC,GAC1H;;CAGH,MAAM,gBAAgB,UAAU;AAEhC,QAAO;EAAE;EAAe;EAAQ;EAAS"}
package/dist/plugin.cjs CHANGED
@@ -632,22 +632,16 @@ var plugin_default = (0, every_plugin.createPlugin)({
632
632
  const stagingEnvVars = isStaging ? { GATEWAY_DOMAIN: config.staging?.domain ?? config.domain ?? "" } : {};
633
633
  const configSource = remoteConfig ? `bos://${input.account}/${input.domain}` : require_config.findConfigPath() ?? "bos.config.json";
634
634
  const configSourceHttp = remoteConfig && input.account && input.domain ? require_fastkv.buildRegistryConfigUrl(input.account, input.domain) : void 0;
635
- console.log();
636
- console.log(` ${require_theme.colors.dim("Config Source:")} ${configSource}`);
637
- if (configSourceHttp) console.log(` ${require_theme.colors.dim(configSourceHttp)}`);
638
- console.log(` ${require_theme.colors.dim("Account:")} ${config.account}`);
639
- console.log(` ${require_theme.colors.dim("Domain:")} ${config.domain ?? "not configured"}`);
640
- console.log();
641
- console.log(` ${require_theme.colors.dim("Modules:")}`);
642
- console.log(` ${require_theme.colors.dim("HOST")} → ${runtimeConfig.host.remoteUrl ?? runtimeConfig.host.url ?? "local"}`);
643
- console.log(` ${require_theme.colors.dim("UI")} → ${runtimeConfig.ui.url ?? "local"}`);
644
- console.log(` ${require_theme.colors.dim("API")} → ${runtimeConfig.api.url ?? "local"}`);
645
- if (runtimeConfig.auth) console.log(` ${require_theme.colors.dim("AUTH")} → ${runtimeConfig.auth.url ?? "local"}`);
635
+ const summaryLines = ["", ` ${require_theme.colors.dim("Config Source:")} ${configSource}`];
636
+ if (configSourceHttp) summaryLines.push(` ${require_theme.colors.dim(configSourceHttp)}`);
637
+ summaryLines.push(` ${require_theme.colors.dim("Account:")} ${config.account}`, ` ${require_theme.colors.dim("Domain:")} ${config.domain ?? "not configured"}`, "", ` ${require_theme.colors.dim("Modules:")}`, ` ${require_theme.colors.dim("HOST")} → ${runtimeConfig.host.remoteUrl ?? runtimeConfig.host.url ?? "local"}`, ` ${require_theme.colors.dim("UI")} → ${runtimeConfig.ui.url ?? "local"}`, ` ${require_theme.colors.dim("API")} → ${runtimeConfig.api.url ?? "local"}`);
638
+ if (runtimeConfig.auth) summaryLines.push(` ${require_theme.colors.dim("AUTH")}${runtimeConfig.auth.url ?? "local"}`);
646
639
  if (warnings.length > 0) {
647
- console.log();
648
- for (const w of warnings) console.log(` ${require_theme.colors.yellow(w)}`);
640
+ summaryLines.push("");
641
+ for (const w of warnings) summaryLines.push(` ${require_theme.colors.yellow(w)}`);
649
642
  }
650
- console.log();
643
+ summaryLines.push("");
644
+ console.log(summaryLines.join("\n"));
651
645
  require_dev_session.startApp({
652
646
  packages: ["host"],
653
647
  env: {
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.cjs","names":["resolveLocalDevelopmentPath","loadConfig","syncApiContractBridge","run","fetchBosConfigFromFastKv","syncAndGenerateSharedUi","z","bosContract","Effect","getProjectRoot","parsePluginBosUrl","fetchPluginFromRegistry","fetchRemotePluginManifest","computeSriHashForUrl","getNetworkIdForAccount","ensureNearCli","executeTransaction","getRegistryNamespaceForNetwork","detectLocalPackages","getHostDevelopmentPort","prepareDevelopmentRuntimeConfig","buildRuntimeConfig","buildServiceDescriptorMap","buildDescription","buildRuntimePluginsForConfig","findConfigPath","buildRegistryConfigUrl","colors","buildRegistryConfigUrlForNetwork","getRegistryNamespaceForAccount","addFunctionCallAccessKey","promptInitOptions","fetchParentConfig","resolveSourceDir","readTemplatekeep","p","copyFilteredFiles","personalizeConfig","writeInitSnapshot","runBunInstall","syncTemplate","upgradeTemplate","getStatus"],"sources":["../src/plugin.ts"],"sourcesContent":["import { randomBytes } from \"node:crypto\";\nimport { existsSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { basename, dirname, join, resolve } from \"node:path\";\nimport * as p from \"@clack/prompts\";\nimport { Effect } from \"effect\";\nimport { syncApiContractBridge } from \"./api-contract\";\nimport { buildRuntimeConfig, detectLocalPackages, prepareDevelopmentRuntimeConfig } from \"./app\";\nimport {\n copyFilteredFiles,\n fetchParentConfig,\n personalizeConfig,\n readTemplatekeep,\n resolveSourceDir,\n runBunInstall,\n writeInitSnapshot,\n} from \"./cli/init\";\nimport { promptInitOptions } from \"./cli/prompts\";\nimport { getStatus } from \"./cli/status\";\nimport { syncTemplate } from \"./cli/sync\";\nimport { upgradeTemplate } from \"./cli/upgrade\";\nimport {\n buildRuntimePluginsForConfig,\n findConfigPath,\n getHostDevelopmentPort,\n getProjectRoot,\n loadConfig,\n resolveLocalDevelopmentPath,\n} from \"./config\";\nimport {\n type BosConfigResult,\n type BuildOptions,\n bosContract,\n type DevOptions,\n type InitOptions,\n type KeyPublishOptions,\n type PluginAddOptions,\n type PluginListResult,\n type PluginPublishOptions,\n type PluginRemoveOptions,\n type PublishOptions,\n type StartOptions,\n type SyncOptions,\n type UpgradeOptions,\n} from \"./contract\";\nimport { devApp, startApp } from \"./dev-session\";\nimport {\n buildRegistryConfigUrl,\n buildRegistryConfigUrlForNetwork,\n fetchBosConfigFromFastKv,\n fetchPluginFromRegistry,\n fetchRemotePluginManifest,\n getRegistryNamespaceForAccount,\n getRegistryNamespaceForNetwork,\n type PluginManifest,\n parsePluginBosUrl,\n} from \"./fastkv\";\nimport { computeSriHashForUrl } from \"./integrity\";\nimport { addFunctionCallAccessKey, ensureNearCli, executeTransaction } from \"./near-cli\";\nimport { getNetworkIdForAccount } from \"./network\";\nimport { createPlugin, z } from \"./sdk\";\nimport {\n type AppOrchestrator,\n buildDescription,\n buildServiceDescriptorMap,\n} from \"./service-descriptor\";\nimport { syncAndGenerateSharedUi } from \"./shared\";\nimport type { BosConfig, RuntimeConfig, SourceMode } from \"./types\";\nimport { run } from \"./utils/run\";\nimport { colors } from \"./utils/theme\";\n\nfunction ensureEnvFile(configDir: string): void {\n const envPath = join(configDir, \".env\");\n const examplePath = join(configDir, \".env.example\");\n\n if (existsSync(envPath)) return;\n\n if (!existsSync(examplePath)) return;\n\n const content = readFileSync(examplePath, \"utf-8\");\n const lines = content.split(\"\\n\");\n\n const secret = randomBytes(32).toString(\"base64url\");\n\n const updated = lines\n .map((line) => {\n if (/^BETTER_AUTH_SECRET=/.test(line)) {\n return `BETTER_AUTH_SECRET=${secret}`;\n }\n if (/^BETTER_AUTH_URL=/.test(line)) {\n return `BETTER_AUTH_URL=http://localhost:3000`;\n }\n return line;\n })\n .join(\"\\n\");\n\n writeFileSync(envPath, updated);\n console.log(`[CLI] Created .env from .env.example with generated BETTER_AUTH_SECRET`);\n}\n\nconst buildCommands: Record<string, { cmd: string; args: string[] }> = {\n host: { cmd: \"bun\", args: [\"run\", \"build\"] },\n ui: { cmd: \"bun\", args: [\"run\", \"build\"] },\n api: { cmd: \"bun\", args: [\"run\", \"build\"] },\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(bosConfig: BosConfig | null): BosConfigResult {\n const packages = bosConfig ? Object.keys(bosConfig.app) : [];\n const remotes = packages.filter((name) => name !== \"host\");\n\n return {\n config: bosConfig,\n packages,\n remotes,\n };\n}\n\ntype WorkspaceTarget = {\n key: string;\n kind: \"app\" | \"plugin\";\n path: string;\n};\n\nfunction resolveWorkspaceTarget(\n key: string,\n bosConfig: BosConfig | null,\n runtimeConfig: RuntimeConfig | null,\n configDir: string,\n): WorkspaceTarget | null {\n if (bosConfig?.app && key in bosConfig.app) {\n const appEntry = (bosConfig.app as Record<string, { development?: string }>)[key];\n const devPath = resolveLocalDevelopmentPath(appEntry?.development, configDir);\n if (devPath) {\n return {\n key,\n kind: \"app\",\n path: devPath,\n };\n }\n return {\n key,\n kind: \"app\",\n path: `${configDir}/${key}`,\n };\n }\n\n const runtimePlugin = runtimeConfig?.plugins?.[key];\n const pluginPath =\n runtimePlugin?.localPath ??\n resolveLocalDevelopmentPath(bosConfig?.plugins?.[key]?.development, configDir);\n if (pluginPath) {\n return {\n key,\n kind: \"plugin\",\n path: pluginPath,\n };\n }\n\n return null;\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 source = attachment.development ?? attachment.production;\n if (!source?.startsWith(\"local:\")) {\n return null;\n }\n\n return join(configDir, source.slice(\"local:\".length));\n}\n\nasync function saveBosConfig(configDir: string, config: BosConfig): Promise<void> {\n const filePath = join(configDir, \"bos.config.json\");\n const next = `${JSON.stringify(config, null, 2)}\\n`;\n try {\n if (readFileSync(filePath, \"utf8\") === next) return;\n } catch {\n // file does not exist yet\n }\n\n writeFileSync(filePath, next);\n}\n\nfunction listPluginAttachments(config: BosConfig | null) {\n return (Object.entries(config?.plugins ?? {}) as Array<[string, PluginAttachmentConfig]>)\n .map(([key, attachment]) => ({\n key,\n development: attachment.development,\n production: attachment.production,\n localPath: attachment.development?.startsWith(\"local:\")\n ? attachment.development.slice(\"local:\".length)\n : undefined,\n source: attachment.development?.startsWith(\"local:\")\n ? (\"local\" as const)\n : (\"remote\" as const),\n integrity: attachment.integrity,\n version: attachment.version,\n name: attachment.name,\n }))\n .sort((a, b) => a.key.localeCompare(b.key));\n}\n\nasync function refreshApiContractBridge(configDir: string): Promise<void> {\n const refreshed = await loadConfig({ cwd: configDir, env: \"development\" });\n if (!refreshed) return;\n\n await syncApiContractBridge({\n configDir,\n runtimeConfig: refreshed.runtime,\n apiBaseUrl: refreshed.runtime.api.url,\n });\n}\n\nfunction extractPublishedUrl(output: string): string | null {\n const match = output.match(/https?:\\/\\/[^\\s\"'<>]+/g);\n if (!match || match.length === 0) return null;\n return match[match.length - 1] ?? null;\n}\n\nasync function buildEveryPluginQuietly(cwd: string) {\n const packageDir = `${cwd}/packages/every-plugin`;\n const packageExists = await Bun.file(`${packageDir}/package.json`).exists();\n if (!packageExists) {\n return;\n }\n\n const distPath = `${cwd}/packages/every-plugin/dist/build/rspack/plugin.mjs`;\n const distExists = await Bun.file(distPath).exists();\n\n if (distExists) {\n return;\n }\n\n const result = (await run(\"bun\", [\"run\", \"--cwd\", \"packages/every-plugin\", \"build\"], {\n cwd,\n capture: true,\n })) as { stdout: string; stderr: string; exitCode: number };\n\n if (result.exitCode === 0) {\n console.log(\"[build:ssr] build succeeded\");\n return;\n }\n\n if (result.stdout.trim()) {\n process.stdout.write(result.stdout);\n }\n\n if (result.stderr.trim()) {\n process.stderr.write(result.stderr);\n }\n\n throw new Error(\n `bun run --cwd packages/every-plugin build failed with exit code ${result.exitCode}`,\n );\n}\n\nasync function buildEverythingDevQuietly(cwd: string) {\n const packageDir = `${cwd}/packages/everything-dev`;\n const packageExists = await Bun.file(`${packageDir}/package.json`).exists();\n if (!packageExists) {\n return;\n }\n\n const distPath = `${cwd}/packages/everything-dev/dist/index.mjs`;\n const distExists = await Bun.file(distPath).exists();\n\n if (distExists) {\n return;\n }\n\n const result = (await run(\"bun\", [\"run\", \"--cwd\", \"packages/everything-dev\", \"build\"], {\n cwd,\n capture: true,\n })) as { stdout: string; stderr: string; exitCode: number };\n\n if (result.exitCode === 0) {\n console.log(\"[everything-dev] build succeeded\");\n return;\n }\n\n if (result.stdout.trim()) {\n process.stdout.write(result.stdout);\n }\n\n if (result.stderr.trim()) {\n process.stderr.write(result.stderr);\n }\n\n throw new Error(\n `bun run --cwd packages/everything-dev build failed with exit code ${result.exitCode}`,\n );\n}\n\nasync function fetchPublishedConfig(\n accountId: string,\n gatewayId: string,\n): Promise<BosConfig | null> {\n try {\n return await fetchBosConfigFromFastKv<BosConfig>(`bos://${accountId}/${gatewayId}`);\n } catch {\n return null;\n }\n}\n\nfunction selectWorkspaceTargets(packages: string, bosConfig: BosConfig | null): string[] {\n const allPackages = [\n ...Object.keys(bosConfig?.app ?? {}),\n ...Object.keys(bosConfig?.plugins ?? {}),\n ];\n if (packages === \"all\") {\n return allPackages;\n }\n\n return packages\n .split(\",\")\n .map((pkg) => pkg.trim())\n .filter((pkg) => allPackages.includes(pkg));\n}\n\nasync function buildWorkspaceTargets(opts: {\n configDir: string;\n bosConfig: BosConfig | null;\n runtimeConfig: RuntimeConfig | null;\n targets: string[];\n deploy: boolean;\n}): Promise<{ built: string[]; skipped: string[] }> {\n const existing: WorkspaceTarget[] = [];\n const skipped: string[] = [];\n\n for (const target of opts.targets) {\n const resolved = resolveWorkspaceTarget(\n target,\n opts.bosConfig,\n opts.runtimeConfig,\n opts.configDir,\n );\n if (!resolved) {\n skipped.push(target);\n continue;\n }\n\n const exists = await Bun.file(`${resolved.path}/package.json`).exists();\n if (exists) existing.push(resolved);\n else skipped.push(target);\n }\n\n if (existing.length === 0) {\n return { built: [], skipped };\n }\n\n const sharedSync = await syncAndGenerateSharedUi({\n configDir: opts.configDir,\n hostMode: \"local\",\n bosConfig: opts.bosConfig ?? undefined,\n });\n if (sharedSync.catalogChanged) {\n await run(\"bun\", [\"install\"], { cwd: opts.configDir });\n }\n\n if (existing.some((entry) => entry.key === \"api\")) {\n await buildEveryPluginQuietly(opts.configDir);\n }\n\n await buildEverythingDevQuietly(opts.configDir);\n\n const env: Record<string, string> = {\n ...process.env,\n NODE_ENV: opts.deploy ? \"production\" : \"development\",\n };\n if (opts.deploy) {\n env.DEPLOY = \"true\";\n } else {\n delete env.DEPLOY;\n }\n\n const orderedExisting = opts.deploy\n ? [\n ...existing.filter((entry) => entry.kind === \"app\" && entry.key !== \"host\"),\n ...existing.filter((entry) => entry.kind === \"plugin\"),\n ...existing.filter((entry) => entry.kind === \"app\" && entry.key === \"host\"),\n ]\n : existing;\n const built: string[] = [];\n\n for (const resolved of orderedExisting) {\n const pkgJson = JSON.parse(await Bun.file(`${resolved.path}/package.json`).text()) as {\n scripts?: Record<string, string>;\n };\n const shouldDeployScript = opts.deploy && pkgJson.scripts?.deploy;\n const buildConfig = shouldDeployScript\n ? { cmd: \"bun\", args: [\"run\", \"deploy\"] }\n : (buildCommands[resolved.key] ?? { cmd: \"bun\", args: [\"run\", \"build\"] });\n\n await run(buildConfig.cmd, buildConfig.args, {\n cwd: resolved.path,\n env,\n });\n built.push(resolved.key);\n }\n\n return { built, skipped };\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: any) =>\n Effect.promise(async () => {\n const configResult = await loadConfig({ 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: BosDeps, builder: any) => ({\n config: builder.config.handler(async () => buildConfigResult(deps.bosConfig)),\n\n pluginAdd: builder.pluginAdd.handler(async ({ input }: { input: PluginAddOptions }) => {\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 pluginRef = parsePluginBosUrl(input.source);\n let production = input.production ?? input.source;\n let integrity: string | undefined;\n let version: string | undefined;\n let name: string | undefined;\n\n if (pluginRef) {\n try {\n const entry = await fetchPluginFromRegistry(pluginRef.accountId, pluginRef.pluginName);\n if (!entry) {\n return {\n status: \"error\" as const,\n key: \"\",\n error: `Plugin not found in registry: bos://${pluginRef.accountId}/plugins/${pluginRef.pluginName}`,\n };\n }\n\n const manifest = entry.manifest;\n if (\n manifest.schemaVersion !== 1 ||\n manifest.kind !== \"every-plugin/manifest\" ||\n !manifest.plugin?.name ||\n !manifest.plugin?.version ||\n !manifest.runtime?.remoteEntry\n ) {\n return {\n status: \"error\" as const,\n key: \"\",\n error: `Invalid plugin manifest for bos://${pluginRef.accountId}/plugins/${pluginRef.pluginName}`,\n };\n }\n\n production = entry.metadata.cdnUrl || input.production || input.source;\n name = manifest.plugin.name;\n version = manifest.plugin.version;\n } catch (error) {\n return {\n status: \"error\" as const,\n key: \"\",\n error: `Failed to resolve plugin from registry: ${error instanceof Error ? error.message : error}`,\n };\n }\n }\n\n if (!input.source.startsWith(\"local:\") && !pluginRef && production.startsWith(\"https://\")) {\n try {\n const manifest = await fetchRemotePluginManifest(production);\n if (manifest) {\n name = manifest.plugin.name;\n version = manifest.plugin.version;\n }\n } catch {\n console.warn(`[plugin add] Could not fetch manifest from ${production}`);\n }\n }\n\n if (!input.source.startsWith(\"local:\") && production.startsWith(\"https://\")) {\n try {\n const computed = await computeSriHashForUrl(production);\n if (computed) integrity = computed;\n } catch {\n console.warn(`[plugin add] Could not compute integrity for ${production}`);\n }\n }\n\n const key = sanitizePluginKey(\n input.as ?? (pluginRef ? pluginRef.pluginName : defaultPluginKey(input.source)),\n );\n const existing = deps.bosConfig.plugins?.[key];\n const nextPlugins = { ...(deps.bosConfig.plugins ?? {}) };\n\n nextPlugins[key] = input.source.startsWith(\"local:\")\n ? {\n ...(existing ?? {}),\n development: input.source,\n production: input.production ?? existing?.production,\n }\n : {\n ...(existing ?? {}),\n production,\n ...(integrity ? { integrity } : {}),\n ...(name ? { name } : {}),\n ...(version ? { version } : {}),\n };\n\n deps.bosConfig = {\n ...deps.bosConfig,\n plugins: nextPlugins,\n };\n\n await saveBosConfig(deps.configDir, deps.bosConfig);\n await refreshApiContractBridge(deps.configDir);\n\n return {\n status: \"added\" as const,\n key,\n development: deps.bosConfig.plugins?.[key]?.development,\n production: deps.bosConfig.plugins?.[key]?.production,\n integrity,\n version,\n };\n }),\n\n pluginRemove: builder.pluginRemove.handler(\n async ({ input }: { input: PluginRemoveOptions }) => {\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 refreshApiContractBridge(deps.configDir);\n\n return {\n status: \"removed\" as const,\n key: input.key,\n };\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(\n async ({ input }: { input: PluginPublishOptions }) => {\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 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 Bun.file(pkgPath).exists())) {\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 Bun.file(pkgPath).json()) as {\n scripts?: Record<string, string>;\n name?: string;\n version?: string;\n };\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 let publishedUrl = extractPublishedUrl(`${stdout}\\n${stderr}`);\n\n let manifest: PluginManifest | null = null;\n if (publishedUrl) {\n manifest = await fetchRemotePluginManifest(publishedUrl);\n } else if (attachment.production) {\n manifest = await fetchRemotePluginManifest(attachment.production);\n if (manifest) {\n publishedUrl = attachment.production;\n }\n }\n\n const integrity = publishedUrl ? await computeSriHashForUrl(publishedUrl) : null;\n const version = manifest?.plugin.version ?? pkgJson.version;\n\n if (publishedUrl) {\n deps.bosConfig = {\n ...deps.bosConfig,\n plugins: {\n ...(deps.bosConfig.plugins ?? {}),\n [input.key]: {\n ...(deps.bosConfig.plugins?.[input.key] ?? {}),\n production: publishedUrl,\n ...(integrity ? { integrity } : {}),\n ...(manifest?.plugin.name ? { name: manifest.plugin.name } : {}),\n ...(version ? { version } : {}),\n },\n },\n };\n await saveBosConfig(deps.configDir, deps.bosConfig);\n\n const account = deps.bosConfig.account;\n const network = getNetworkIdForAccount(account);\n if (manifest && version) {\n try {\n const registryEntries: Record<string, string> = {\n [`plugins/${account}/${input.key}/manifest.json`]: JSON.stringify(manifest),\n [`plugins/${account}/${input.key}/metadata`]: JSON.stringify({\n title: null,\n description: null,\n repoUrl: deps.bosConfig.repository ?? null,\n version,\n publishedAt: new Date().toISOString(),\n cdnUrl: publishedUrl,\n integrity,\n }),\n [`plugins/${account}/${input.key}/versions/${version}/manifest.json`]:\n JSON.stringify(manifest),\n };\n const payload = JSON.stringify(registryEntries);\n const argsBase64 = Buffer.from(payload).toString(\"base64\");\n const privateKey = process.env.NEAR_PRIVATE_KEY || process.env.BOS_NEAR_PRIVATE_KEY;\n\n await Effect.runPromise(ensureNearCli);\n try {\n await Effect.runPromise(\n executeTransaction({\n account,\n contract: getRegistryNamespaceForNetwork(network),\n method: \"__fastdata_kv\",\n argsBase64,\n network,\n privateKey,\n gas: \"50Tgas\",\n deposit: \"0NEAR\",\n }),\n );\n } catch (registryError) {\n const txHash = extractTransactionHash(registryError);\n if (!txHash) {\n console.warn(\n `[publish] Plugin registry write failed: ${registryError instanceof Error ? registryError.message : registryError}`,\n );\n }\n }\n } catch (registryError) {\n console.warn(\n `[publish] Plugin registry write skipped: ${registryError instanceof Error ? registryError.message : registryError}`,\n );\n }\n }\n\n await refreshApiContractBridge(deps.configDir);\n }\n\n return {\n status: \"published\" as const,\n key: input.key,\n path: localPath,\n script,\n production: publishedUrl ?? attachment.production,\n integrity: integrity ?? undefined,\n version: version ?? undefined,\n };\n },\n ),\n\n dev: builder.dev.handler(async ({ input }: { input: DevOptions }) => {\n ensureEnvFile(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 as string, \"local\")\n : \"remote\";\n const uiSource: SourceMode = localPackages.includes(\"ui\")\n ? parseSourceMode(input.ui as string, \"local\")\n : \"remote\";\n const apiSource: SourceMode = localPackages.includes(\"api\")\n ? parseSourceMode(input.api as string, \"local\")\n : \"remote\";\n const authSource: SourceMode = localPackages.includes(\"auth\")\n ? parseSourceMode(input.auth as string, \"local\")\n : \"remote\";\n const ssr = input.ssr ?? false;\n const proxy = input.proxy ?? false;\n\n const sharedSync = await syncAndGenerateSharedUi({\n configDir: deps.configDir,\n hostMode: hostSource,\n bosConfig: deps.bosConfig ?? undefined,\n });\n if (sharedSync.catalogChanged) {\n await run(\"bun\", [\"install\"], { cwd: deps.configDir });\n }\n if (\n (apiSource === \"local\" && !proxy) ||\n localPackages.some((pkg) => pkg.startsWith(\"plugin:\"))\n ) {\n await buildEveryPluginQuietly(deps.configDir);\n }\n\n await buildEverythingDevQuietly(deps.configDir);\n\n const refreshed = await loadConfig({ cwd: deps.configDir });\n deps.bosConfig = refreshed?.config ?? deps.bosConfig;\n deps.runtimeConfig = refreshed?.runtime ?? deps.runtimeConfig;\n\n if (!deps.bosConfig) {\n return {\n status: \"error\" as const,\n description: \"No bos.config.json found\",\n processes: [],\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 };\n }\n\n const hostPort = input.port ?? getHostDevelopmentPort(deps.bosConfig.app.host.development);\n const developmentRuntime = buildRuntimeConfig(deps.bosConfig, {\n uiSource,\n apiSource,\n authSource,\n hostSource,\n env: \"development\",\n plugins: deps.runtimeConfig?.plugins,\n });\n const runtimeConfig = await prepareDevelopmentRuntimeConfig(developmentRuntime, {\n hostPort,\n ssr,\n });\n\n const services = buildServiceDescriptorMap(runtimeConfig, { ssr, proxy });\n const packages = [...services.keys()];\n const displayEnv: Record<string, string> = {};\n const apiDescriptor = services.get(\"api\");\n if (apiDescriptor?.proxy) {\n const proxyUrl = resolveProxyUrl(deps.bosConfig);\n if (proxyUrl) displayEnv.API_PROXY = proxyUrl;\n }\n\n await syncApiContractBridge({\n configDir: deps.configDir,\n runtimeConfig: runtimeConfig,\n apiBaseUrl: runtimeConfig.api.url,\n });\n\n const orchestrator: AppOrchestrator = {\n packages,\n env: displayEnv,\n description: buildDescription(services),\n port: runtimeConfig.host.port,\n interactive: input.interactive,\n };\n\n devApp(orchestrator, services, runtimeConfig);\n\n return {\n status: \"started\" as const,\n description: orchestrator.description,\n processes: packages,\n };\n }),\n\n start: builder.start.handler(async ({ input }: { input: StartOptions }) => {\n ensureEnvFile(deps.configDir);\n\n let remoteConfig: BosConfig | null = null;\n\n if (input.account && input.domain) {\n remoteConfig = await fetchPublishedConfig(input.account, input.domain);\n if (!remoteConfig) {\n return {\n status: \"error\" as const,\n url: \"\",\n };\n }\n }\n\n const config = remoteConfig || deps.bosConfig;\n if (!config) {\n return {\n status: \"error\" as const,\n url: \"\",\n };\n }\n\n const port = input.port ?? getHostDevelopmentPort(config.app.host.development);\n const isStaging = input.env === \"staging\";\n const runtimePlugins = remoteConfig\n ? await buildRuntimePluginsForConfig(config, deps.configDir, \"production\")\n : deps.runtimeConfig?.plugins;\n const runtimeConfig = buildRuntimeConfig(config, {\n uiSource: \"remote\",\n apiSource: \"remote\",\n authSource: \"remote\",\n hostSource: \"remote\",\n env: \"production\",\n plugins: runtimePlugins,\n });\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 defaultOrigin = `https://${config.domain}`;\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.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 services = buildServiceDescriptorMap(runtimeConfig);\n\n await syncApiContractBridge({\n configDir: deps.configDir,\n runtimeConfig: runtimeConfig,\n apiBaseUrl: runtimeConfig.api.url,\n });\n\n const stagingEnvVars: Record<string, string> = isStaging\n ? { GATEWAY_DOMAIN: config.staging?.domain ?? config.domain ?? \"\" }\n : {};\n\n const configSource = remoteConfig\n ? `bos://${input.account}/${input.domain}`\n : (findConfigPath() ?? \"bos.config.json\");\n\n const configSourceHttp =\n remoteConfig && input.account && input.domain\n ? buildRegistryConfigUrl(input.account, input.domain)\n : undefined;\n\n console.log();\n console.log(` ${colors.dim(\"Config Source:\")} ${configSource}`);\n if (configSourceHttp) {\n console.log(` ${colors.dim(configSourceHttp)}`);\n }\n console.log(` ${colors.dim(\"Account:\")} ${config.account}`);\n console.log(` ${colors.dim(\"Domain:\")} ${config.domain ?? \"not configured\"}`);\n console.log();\n console.log(` ${colors.dim(\"Modules:\")}`);\n console.log(\n ` ${colors.dim(\"HOST\")} → ${runtimeConfig.host.remoteUrl ?? runtimeConfig.host.url ?? \"local\"}`,\n );\n console.log(` ${colors.dim(\"UI\")} → ${runtimeConfig.ui.url ?? \"local\"}`);\n console.log(` ${colors.dim(\"API\")} → ${runtimeConfig.api.url ?? \"local\"}`);\n if (runtimeConfig.auth) {\n console.log(` ${colors.dim(\"AUTH\")} → ${runtimeConfig.auth.url ?? \"local\"}`);\n }\n if (warnings.length > 0) {\n console.log();\n for (const w of warnings) {\n console.log(` ${colors.yellow(w)}`);\n }\n }\n console.log();\n\n const orchestrator: AppOrchestrator = {\n packages: [\"host\"],\n env: {\n NODE_ENV: \"production\",\n ...productionEnv,\n ...stagingEnvVars,\n },\n description: `${isStaging ? \"Staging\" : \"Production\"} Mode (${config.account})`,\n port,\n interactive: input.interactive,\n noLogs: true,\n };\n\n startApp(orchestrator, services, runtimeConfig);\n return {\n status: \"running\" as const,\n url: `http://localhost:${port}`,\n };\n }),\n\n build: builder.build.handler(async ({ input }: { input: BuildOptions }) => {\n if (!deps.bosConfig) {\n return {\n status: \"error\" as const,\n built: [],\n skipped: [],\n };\n }\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 const runtimeConfig = 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: \"development\",\n plugins: deps.runtimeConfig?.plugins,\n });\n\n await syncApiContractBridge({\n configDir: deps.configDir,\n runtimeConfig,\n apiBaseUrl: runtimeConfig.api.url,\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 }: { input: PublishOptions }) => {\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 account = deps.bosConfig.account;\n const gateway = deps.bosConfig.domain;\n if (!gateway) {\n return {\n status: \"error\" as const,\n registryUrl: \"\",\n error: \"bos.config.json must define domain to publish\",\n };\n }\n\n const network = input.network ?? getNetworkIdForAccount(account);\n const bosUrl = `bos://${account}/${gateway}`;\n const registryUrl = buildRegistryConfigUrlForNetwork(network, account, gateway);\n const targets = selectWorkspaceTargets(input.packages, deps.bosConfig);\n\n let publishConfig = deps.bosConfig;\n let built: string[] | undefined;\n let skipped: string[] | undefined;\n\n if (input.dryRun) {\n return {\n status: \"dry-run\" as const,\n registryUrl,\n built,\n skipped,\n };\n }\n\n if (input.deploy) {\n const result = await buildWorkspaceTargets({\n configDir: deps.configDir,\n bosConfig: deps.bosConfig,\n runtimeConfig: deps.runtimeConfig,\n targets,\n deploy: true,\n });\n built = result.built;\n skipped = result.skipped;\n\n const refreshed = await loadConfig({ cwd: deps.configDir });\n if (refreshed?.config) {\n deps.bosConfig = refreshed.config;\n deps.runtimeConfig = refreshed.runtime;\n publishConfig = refreshed.config;\n }\n }\n\n const payload = JSON.stringify({\n [`apps/${account}/${gateway}/bos.config.json`]: JSON.stringify(publishConfig),\n });\n const argsBase64 = Buffer.from(payload).toString(\"base64\");\n const privateKey =\n input.privateKey || process.env.NEAR_PRIVATE_KEY || process.env.BOS_NEAR_PRIVATE_KEY;\n\n try {\n await Effect.runPromise(ensureNearCli);\n let txHash: string | undefined;\n\n try {\n const tx = await Effect.runPromise(\n executeTransaction({\n account,\n contract: getRegistryNamespaceForNetwork(network),\n method: \"__fastdata_kv\",\n argsBase64,\n network,\n privateKey,\n gas: \"300Tgas\",\n deposit: \"0NEAR\",\n }),\n );\n txHash = tx.txHash;\n } catch (error) {\n txHash = extractTransactionHash(error);\n\n if (!txHash) {\n throw error;\n }\n\n try {\n const verifiedConfig = await fetchBosConfigFromFastKv<BosConfig>(bosUrl);\n if (JSON.stringify(verifiedConfig) !== JSON.stringify(publishConfig)) {\n throw error;\n }\n } catch {\n // Config may not exist yet on first publish or propagation delay;\n // a valid txHash is sufficient proof the transaction was submitted.\n }\n }\n\n return {\n status: \"published\" as const,\n registryUrl,\n txHash,\n built,\n skipped,\n };\n } catch (error) {\n return {\n status: \"error\" as const,\n registryUrl,\n error: error instanceof Error ? error.message : \"Unknown error\",\n built,\n skipped,\n };\n }\n }),\n\n keyPublish: builder.keyPublish.handler(async ({ input }: { input: KeyPublishOptions }) => {\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 const keyPair = await addFunctionCallAccessKey({\n account,\n contract,\n allowance: input.allowance,\n functionNames: PUBLISH_FUNCTION_NAMES,\n network,\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 }: { input: InitOptions }) => {\n try {\n let extendsAccount = input.extendsAccount;\n let extendsGateway = input.extendsGateway;\n let directory = input.directory;\n let account = input.account;\n let domain = input.domain;\n let withHost = input.withHost;\n let plugins = input.plugins;\n\n if (input.extends) {\n const match = input.extends.match(/^(?:bos:\\/\\/)?([^/]+)\\/(.+)$/);\n if (match) {\n if (!extendsAccount) extendsAccount = match[1];\n if (!extendsGateway) extendsGateway = match[2];\n }\n }\n\n if (!input.noInteractive) {\n const prompted = await promptInitOptions({\n extendsAccount,\n extendsGateway,\n extends: input.extends,\n directory,\n account,\n domain,\n plugins,\n withHost,\n });\n extendsAccount = prompted.extendsAccount;\n extendsGateway = prompted.extendsGateway;\n directory = prompted.directory;\n account = prompted.account;\n domain = prompted.domain;\n withHost = prompted.withHost;\n plugins = prompted.plugins;\n }\n\n extendsAccount = extendsAccount || \"dev.everything.near\";\n extendsGateway = extendsGateway || \"everything.dev\";\n directory = directory || domain || extendsGateway;\n plugins = plugins?.length ? plugins : [\"_template\"];\n\n try {\n await fetchParentConfig(extendsAccount, extendsGateway);\n } catch {\n return {\n status: \"error\" as const,\n directory,\n extendsAccount,\n extendsGateway,\n account,\n domain,\n extends: `bos://${extendsAccount}/${extendsGateway}`,\n plugins: plugins ?? [],\n filesCopied: 0,\n error: `No config found at bos://${extendsAccount}/${extendsGateway} — are you sure this is the right parent?`,\n };\n }\n\n const { sourceDir, parentConfig, cleanup } = await resolveSourceDir({\n extendsAccount,\n extendsGateway,\n source: input.source,\n });\n\n try {\n const patterns = await readTemplatekeep(sourceDir);\n if (patterns.length === 0) {\n return {\n status: \"error\" as const,\n directory,\n extendsAccount,\n extendsGateway,\n account,\n domain,\n extends: `bos://${extendsAccount}/${extendsGateway}`,\n plugins: plugins ?? [],\n filesCopied: 0,\n error: \"No .templatekeep found in template source\",\n };\n }\n\n const pluginRoutes: Record<string, string[]> = {};\n if (parentConfig.plugins) {\n for (const [key, ref] of Object.entries(parentConfig.plugins)) {\n if (ref.routes && ref.routes.length > 0) {\n pluginRoutes[key] = ref.routes;\n }\n }\n }\n\n const s = p.spinner();\n s.start(\"Setting up project\");\n\n const filesCopied = await copyFilteredFiles(sourceDir, directory, patterns, {\n withHost,\n plugins,\n pluginRoutes,\n });\n\n await personalizeConfig(directory, {\n extendsAccount,\n extendsGateway,\n account: account || extendsAccount,\n domain: domain || extendsGateway,\n plugins,\n pluginRoutes,\n workspaceOpts: { sourceDir },\n });\n\n await writeInitSnapshot(directory, extendsAccount, extendsGateway, sourceDir, patterns, {\n withHost,\n plugins,\n pluginRoutes,\n });\n\n if (!input.noInstall) {\n await runBunInstall(directory);\n }\n\n ensureEnvFile(directory);\n\n s.stop(\"Project initialized\");\n\n return {\n status: \"initialized\" as const,\n directory,\n extendsAccount,\n extendsGateway,\n account,\n domain,\n extends: `bos://${extendsAccount}/${extendsGateway}`,\n plugins,\n filesCopied,\n };\n } finally {\n await cleanup();\n }\n } catch (error) {\n return {\n status: \"error\" as const,\n directory: input.directory ?? \"\",\n extendsAccount: input.extendsAccount ?? \"\",\n extendsGateway: input.extendsGateway ?? \"\",\n account: input.account,\n domain: input.domain,\n extends:\n input.extendsAccount && input.extendsGateway\n ? `bos://${input.extendsAccount}/${input.extendsGateway}`\n : \"\",\n plugins: input.plugins ?? [],\n filesCopied: 0,\n error: error instanceof Error ? error.message : \"Unknown error\",\n };\n }\n }),\n\n sync: builder.sync.handler(async ({ input }: { input: SyncOptions }) => {\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 return await syncTemplate(projectDir, input);\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 }: { input: UpgradeOptions }) => {\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 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});\n\nfunction extractTransactionHash(error: unknown) {\n const message = error instanceof Error ? error.message : String(error);\n const match =\n message.match(/Transaction ID:\\s*([A-Za-z0-9]+)/i) ||\n message.match(/([A-HJ-NP-Za-km-z1-9]{43,44})/);\n\n return match?.[1];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsEA,SAAS,cAAc,WAAyB;CAC9C,MAAM,8BAAe,WAAW,OAAO;CACvC,MAAM,kCAAmB,WAAW,eAAe;AAEnD,6BAAe,QAAQ,CAAE;AAEzB,KAAI,yBAAY,YAAY,CAAE;CAG9B,MAAM,kCADuB,aAAa,QAAQ,CAC5B,MAAM,KAAK;CAEjC,MAAM,sCAAqB,GAAG,CAAC,SAAS,YAAY;AAcpD,4BAAc,SAZE,MACb,KAAK,SAAS;AACb,MA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AO,iBAAiB,QAAQ,MAAM,UAAU;KACjD;;IAEH;EAEF,QAAQ,QAAQ,OAAO,QAAQ,YAAY;AACzC,OAAI;IACF,MAAM,aAAahB,+BAAgB;AACnC,QAAI,CAAC,WACH,QAAO;KACL,QAAQ;KACR,UAAU,EAAE;KACZ,SAAS;KACT,OAAO;KACR;AAIH,WAAO,MAAMiB,uEADsB,WAAW,CAAC,CACb;YAC3B,OAAO;AACd,WAAO;KACL,QAAQ;KACR,UAAU,EAAE;KACZ,SAAS;KACT,OAAO,iBAAiB,QAAQ,MAAM,UAAU;KACjD;;IAEH;EACH;CACF,CAAC;AAEF,SAAS,uBAAuB,OAAgB;CAC9C,MAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM;AAKtE,SAHE,QAAQ,MAAM,oCAAoC,IAClD,QAAQ,MAAM,gCAAgC,IAEjC"}
1
+ {"version":3,"file":"plugin.cjs","names":["resolveLocalDevelopmentPath","loadConfig","syncApiContractBridge","run","fetchBosConfigFromFastKv","syncAndGenerateSharedUi","z","bosContract","Effect","getProjectRoot","parsePluginBosUrl","fetchPluginFromRegistry","fetchRemotePluginManifest","computeSriHashForUrl","getNetworkIdForAccount","ensureNearCli","executeTransaction","getRegistryNamespaceForNetwork","detectLocalPackages","getHostDevelopmentPort","prepareDevelopmentRuntimeConfig","buildRuntimeConfig","buildServiceDescriptorMap","buildDescription","buildRuntimePluginsForConfig","findConfigPath","buildRegistryConfigUrl","colors","buildRegistryConfigUrlForNetwork","getRegistryNamespaceForAccount","addFunctionCallAccessKey","promptInitOptions","fetchParentConfig","resolveSourceDir","readTemplatekeep","p","copyFilteredFiles","personalizeConfig","writeInitSnapshot","runBunInstall","syncTemplate","upgradeTemplate","getStatus"],"sources":["../src/plugin.ts"],"sourcesContent":["import { randomBytes } from \"node:crypto\";\nimport { existsSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { basename, dirname, join, resolve } from \"node:path\";\nimport * as p from \"@clack/prompts\";\nimport { Effect } from \"effect\";\nimport { syncApiContractBridge } from \"./api-contract\";\nimport { buildRuntimeConfig, detectLocalPackages, prepareDevelopmentRuntimeConfig } from \"./app\";\nimport {\n copyFilteredFiles,\n fetchParentConfig,\n personalizeConfig,\n readTemplatekeep,\n resolveSourceDir,\n runBunInstall,\n writeInitSnapshot,\n} from \"./cli/init\";\nimport { promptInitOptions } from \"./cli/prompts\";\nimport { getStatus } from \"./cli/status\";\nimport { syncTemplate } from \"./cli/sync\";\nimport { upgradeTemplate } from \"./cli/upgrade\";\nimport {\n buildRuntimePluginsForConfig,\n findConfigPath,\n getHostDevelopmentPort,\n getProjectRoot,\n loadConfig,\n resolveLocalDevelopmentPath,\n} from \"./config\";\nimport {\n type BosConfigResult,\n type BuildOptions,\n bosContract,\n type DevOptions,\n type InitOptions,\n type KeyPublishOptions,\n type PluginAddOptions,\n type PluginListResult,\n type PluginPublishOptions,\n type PluginRemoveOptions,\n type PublishOptions,\n type StartOptions,\n type SyncOptions,\n type UpgradeOptions,\n} from \"./contract\";\nimport { devApp, startApp } from \"./dev-session\";\nimport {\n buildRegistryConfigUrl,\n buildRegistryConfigUrlForNetwork,\n fetchBosConfigFromFastKv,\n fetchPluginFromRegistry,\n fetchRemotePluginManifest,\n getRegistryNamespaceForAccount,\n getRegistryNamespaceForNetwork,\n type PluginManifest,\n parsePluginBosUrl,\n} from \"./fastkv\";\nimport { computeSriHashForUrl } from \"./integrity\";\nimport { addFunctionCallAccessKey, ensureNearCli, executeTransaction } from \"./near-cli\";\nimport { getNetworkIdForAccount } from \"./network\";\nimport { createPlugin, z } from \"./sdk\";\nimport {\n type AppOrchestrator,\n buildDescription,\n buildServiceDescriptorMap,\n} from \"./service-descriptor\";\nimport { syncAndGenerateSharedUi } from \"./shared\";\nimport type { BosConfig, RuntimeConfig, SourceMode } from \"./types\";\nimport { run } from \"./utils/run\";\nimport { colors } from \"./utils/theme\";\n\nfunction ensureEnvFile(configDir: string): void {\n const envPath = join(configDir, \".env\");\n const examplePath = join(configDir, \".env.example\");\n\n if (existsSync(envPath)) return;\n\n if (!existsSync(examplePath)) return;\n\n const content = readFileSync(examplePath, \"utf-8\");\n const lines = content.split(\"\\n\");\n\n const secret = randomBytes(32).toString(\"base64url\");\n\n const updated = lines\n .map((line) => {\n if (/^BETTER_AUTH_SECRET=/.test(line)) {\n return `BETTER_AUTH_SECRET=${secret}`;\n }\n if (/^BETTER_AUTH_URL=/.test(line)) {\n return `BETTER_AUTH_URL=http://localhost:3000`;\n }\n return line;\n })\n .join(\"\\n\");\n\n writeFileSync(envPath, updated);\n console.log(`[CLI] Created .env from .env.example with generated BETTER_AUTH_SECRET`);\n}\n\nconst buildCommands: Record<string, { cmd: string; args: string[] }> = {\n host: { cmd: \"bun\", args: [\"run\", \"build\"] },\n ui: { cmd: \"bun\", args: [\"run\", \"build\"] },\n api: { cmd: \"bun\", args: [\"run\", \"build\"] },\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(bosConfig: BosConfig | null): BosConfigResult {\n const packages = bosConfig ? Object.keys(bosConfig.app) : [];\n const remotes = packages.filter((name) => name !== \"host\");\n\n return {\n config: bosConfig,\n packages,\n remotes,\n };\n}\n\ntype WorkspaceTarget = {\n key: string;\n kind: \"app\" | \"plugin\";\n path: string;\n};\n\nfunction resolveWorkspaceTarget(\n key: string,\n bosConfig: BosConfig | null,\n runtimeConfig: RuntimeConfig | null,\n configDir: string,\n): WorkspaceTarget | null {\n if (bosConfig?.app && key in bosConfig.app) {\n const appEntry = (bosConfig.app as Record<string, { development?: string }>)[key];\n const devPath = resolveLocalDevelopmentPath(appEntry?.development, configDir);\n if (devPath) {\n return {\n key,\n kind: \"app\",\n path: devPath,\n };\n }\n return {\n key,\n kind: \"app\",\n path: `${configDir}/${key}`,\n };\n }\n\n const runtimePlugin = runtimeConfig?.plugins?.[key];\n const pluginPath =\n runtimePlugin?.localPath ??\n resolveLocalDevelopmentPath(bosConfig?.plugins?.[key]?.development, configDir);\n if (pluginPath) {\n return {\n key,\n kind: \"plugin\",\n path: pluginPath,\n };\n }\n\n return null;\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 source = attachment.development ?? attachment.production;\n if (!source?.startsWith(\"local:\")) {\n return null;\n }\n\n return join(configDir, source.slice(\"local:\".length));\n}\n\nasync function saveBosConfig(configDir: string, config: BosConfig): Promise<void> {\n const filePath = join(configDir, \"bos.config.json\");\n const next = `${JSON.stringify(config, null, 2)}\\n`;\n try {\n if (readFileSync(filePath, \"utf8\") === next) return;\n } catch {\n // file does not exist yet\n }\n\n writeFileSync(filePath, next);\n}\n\nfunction listPluginAttachments(config: BosConfig | null) {\n return (Object.entries(config?.plugins ?? {}) as Array<[string, PluginAttachmentConfig]>)\n .map(([key, attachment]) => ({\n key,\n development: attachment.development,\n production: attachment.production,\n localPath: attachment.development?.startsWith(\"local:\")\n ? attachment.development.slice(\"local:\".length)\n : undefined,\n source: attachment.development?.startsWith(\"local:\")\n ? (\"local\" as const)\n : (\"remote\" as const),\n integrity: attachment.integrity,\n version: attachment.version,\n name: attachment.name,\n }))\n .sort((a, b) => a.key.localeCompare(b.key));\n}\n\nasync function refreshApiContractBridge(configDir: string): Promise<void> {\n const refreshed = await loadConfig({ cwd: configDir, env: \"development\" });\n if (!refreshed) return;\n\n await syncApiContractBridge({\n configDir,\n runtimeConfig: refreshed.runtime,\n apiBaseUrl: refreshed.runtime.api.url,\n });\n}\n\nfunction extractPublishedUrl(output: string): string | null {\n const match = output.match(/https?:\\/\\/[^\\s\"'<>]+/g);\n if (!match || match.length === 0) return null;\n return match[match.length - 1] ?? null;\n}\n\nasync function buildEveryPluginQuietly(cwd: string) {\n const packageDir = `${cwd}/packages/every-plugin`;\n const packageExists = await Bun.file(`${packageDir}/package.json`).exists();\n if (!packageExists) {\n return;\n }\n\n const distPath = `${cwd}/packages/every-plugin/dist/build/rspack/plugin.mjs`;\n const distExists = await Bun.file(distPath).exists();\n\n if (distExists) {\n return;\n }\n\n const result = (await run(\"bun\", [\"run\", \"--cwd\", \"packages/every-plugin\", \"build\"], {\n cwd,\n capture: true,\n })) as { stdout: string; stderr: string; exitCode: number };\n\n if (result.exitCode === 0) {\n console.log(\"[build:ssr] build succeeded\");\n return;\n }\n\n if (result.stdout.trim()) {\n process.stdout.write(result.stdout);\n }\n\n if (result.stderr.trim()) {\n process.stderr.write(result.stderr);\n }\n\n throw new Error(\n `bun run --cwd packages/every-plugin build failed with exit code ${result.exitCode}`,\n );\n}\n\nasync function buildEverythingDevQuietly(cwd: string) {\n const packageDir = `${cwd}/packages/everything-dev`;\n const packageExists = await Bun.file(`${packageDir}/package.json`).exists();\n if (!packageExists) {\n return;\n }\n\n const distPath = `${cwd}/packages/everything-dev/dist/index.mjs`;\n const distExists = await Bun.file(distPath).exists();\n\n if (distExists) {\n return;\n }\n\n const result = (await run(\"bun\", [\"run\", \"--cwd\", \"packages/everything-dev\", \"build\"], {\n cwd,\n capture: true,\n })) as { stdout: string; stderr: string; exitCode: number };\n\n if (result.exitCode === 0) {\n console.log(\"[everything-dev] build succeeded\");\n return;\n }\n\n if (result.stdout.trim()) {\n process.stdout.write(result.stdout);\n }\n\n if (result.stderr.trim()) {\n process.stderr.write(result.stderr);\n }\n\n throw new Error(\n `bun run --cwd packages/everything-dev build failed with exit code ${result.exitCode}`,\n );\n}\n\nasync function fetchPublishedConfig(\n accountId: string,\n gatewayId: string,\n): Promise<BosConfig | null> {\n try {\n return await fetchBosConfigFromFastKv<BosConfig>(`bos://${accountId}/${gatewayId}`);\n } catch {\n return null;\n }\n}\n\nfunction selectWorkspaceTargets(packages: string, bosConfig: BosConfig | null): string[] {\n const allPackages = [\n ...Object.keys(bosConfig?.app ?? {}),\n ...Object.keys(bosConfig?.plugins ?? {}),\n ];\n if (packages === \"all\") {\n return allPackages;\n }\n\n return packages\n .split(\",\")\n .map((pkg) => pkg.trim())\n .filter((pkg) => allPackages.includes(pkg));\n}\n\nasync function buildWorkspaceTargets(opts: {\n configDir: string;\n bosConfig: BosConfig | null;\n runtimeConfig: RuntimeConfig | null;\n targets: string[];\n deploy: boolean;\n}): Promise<{ built: string[]; skipped: string[] }> {\n const existing: WorkspaceTarget[] = [];\n const skipped: string[] = [];\n\n for (const target of opts.targets) {\n const resolved = resolveWorkspaceTarget(\n target,\n opts.bosConfig,\n opts.runtimeConfig,\n opts.configDir,\n );\n if (!resolved) {\n skipped.push(target);\n continue;\n }\n\n const exists = await Bun.file(`${resolved.path}/package.json`).exists();\n if (exists) existing.push(resolved);\n else skipped.push(target);\n }\n\n if (existing.length === 0) {\n return { built: [], skipped };\n }\n\n const sharedSync = await syncAndGenerateSharedUi({\n configDir: opts.configDir,\n hostMode: \"local\",\n bosConfig: opts.bosConfig ?? undefined,\n });\n if (sharedSync.catalogChanged) {\n await run(\"bun\", [\"install\"], { cwd: opts.configDir });\n }\n\n if (existing.some((entry) => entry.key === \"api\")) {\n await buildEveryPluginQuietly(opts.configDir);\n }\n\n await buildEverythingDevQuietly(opts.configDir);\n\n const env: Record<string, string> = {\n ...process.env,\n NODE_ENV: opts.deploy ? \"production\" : \"development\",\n };\n if (opts.deploy) {\n env.DEPLOY = \"true\";\n } else {\n delete env.DEPLOY;\n }\n\n const orderedExisting = opts.deploy\n ? [\n ...existing.filter((entry) => entry.kind === \"app\" && entry.key !== \"host\"),\n ...existing.filter((entry) => entry.kind === \"plugin\"),\n ...existing.filter((entry) => entry.kind === \"app\" && entry.key === \"host\"),\n ]\n : existing;\n const built: string[] = [];\n\n for (const resolved of orderedExisting) {\n const pkgJson = JSON.parse(await Bun.file(`${resolved.path}/package.json`).text()) as {\n scripts?: Record<string, string>;\n };\n const shouldDeployScript = opts.deploy && pkgJson.scripts?.deploy;\n const buildConfig = shouldDeployScript\n ? { cmd: \"bun\", args: [\"run\", \"deploy\"] }\n : (buildCommands[resolved.key] ?? { cmd: \"bun\", args: [\"run\", \"build\"] });\n\n await run(buildConfig.cmd, buildConfig.args, {\n cwd: resolved.path,\n env,\n });\n built.push(resolved.key);\n }\n\n return { built, skipped };\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: any) =>\n Effect.promise(async () => {\n const configResult = await loadConfig({ 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: BosDeps, builder: any) => ({\n config: builder.config.handler(async () => buildConfigResult(deps.bosConfig)),\n\n pluginAdd: builder.pluginAdd.handler(async ({ input }: { input: PluginAddOptions }) => {\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 pluginRef = parsePluginBosUrl(input.source);\n let production = input.production ?? input.source;\n let integrity: string | undefined;\n let version: string | undefined;\n let name: string | undefined;\n\n if (pluginRef) {\n try {\n const entry = await fetchPluginFromRegistry(pluginRef.accountId, pluginRef.pluginName);\n if (!entry) {\n return {\n status: \"error\" as const,\n key: \"\",\n error: `Plugin not found in registry: bos://${pluginRef.accountId}/plugins/${pluginRef.pluginName}`,\n };\n }\n\n const manifest = entry.manifest;\n if (\n manifest.schemaVersion !== 1 ||\n manifest.kind !== \"every-plugin/manifest\" ||\n !manifest.plugin?.name ||\n !manifest.plugin?.version ||\n !manifest.runtime?.remoteEntry\n ) {\n return {\n status: \"error\" as const,\n key: \"\",\n error: `Invalid plugin manifest for bos://${pluginRef.accountId}/plugins/${pluginRef.pluginName}`,\n };\n }\n\n production = entry.metadata.cdnUrl || input.production || input.source;\n name = manifest.plugin.name;\n version = manifest.plugin.version;\n } catch (error) {\n return {\n status: \"error\" as const,\n key: \"\",\n error: `Failed to resolve plugin from registry: ${error instanceof Error ? error.message : error}`,\n };\n }\n }\n\n if (!input.source.startsWith(\"local:\") && !pluginRef && production.startsWith(\"https://\")) {\n try {\n const manifest = await fetchRemotePluginManifest(production);\n if (manifest) {\n name = manifest.plugin.name;\n version = manifest.plugin.version;\n }\n } catch {\n console.warn(`[plugin add] Could not fetch manifest from ${production}`);\n }\n }\n\n if (!input.source.startsWith(\"local:\") && production.startsWith(\"https://\")) {\n try {\n const computed = await computeSriHashForUrl(production);\n if (computed) integrity = computed;\n } catch {\n console.warn(`[plugin add] Could not compute integrity for ${production}`);\n }\n }\n\n const key = sanitizePluginKey(\n input.as ?? (pluginRef ? pluginRef.pluginName : defaultPluginKey(input.source)),\n );\n const existing = deps.bosConfig.plugins?.[key];\n const nextPlugins = { ...(deps.bosConfig.plugins ?? {}) };\n\n nextPlugins[key] = input.source.startsWith(\"local:\")\n ? {\n ...(existing ?? {}),\n development: input.source,\n production: input.production ?? existing?.production,\n }\n : {\n ...(existing ?? {}),\n production,\n ...(integrity ? { integrity } : {}),\n ...(name ? { name } : {}),\n ...(version ? { version } : {}),\n };\n\n deps.bosConfig = {\n ...deps.bosConfig,\n plugins: nextPlugins,\n };\n\n await saveBosConfig(deps.configDir, deps.bosConfig);\n await refreshApiContractBridge(deps.configDir);\n\n return {\n status: \"added\" as const,\n key,\n development: deps.bosConfig.plugins?.[key]?.development,\n production: deps.bosConfig.plugins?.[key]?.production,\n integrity,\n version,\n };\n }),\n\n pluginRemove: builder.pluginRemove.handler(\n async ({ input }: { input: PluginRemoveOptions }) => {\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 refreshApiContractBridge(deps.configDir);\n\n return {\n status: \"removed\" as const,\n key: input.key,\n };\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(\n async ({ input }: { input: PluginPublishOptions }) => {\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 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 Bun.file(pkgPath).exists())) {\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 Bun.file(pkgPath).json()) as {\n scripts?: Record<string, string>;\n name?: string;\n version?: string;\n };\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 let publishedUrl = extractPublishedUrl(`${stdout}\\n${stderr}`);\n\n let manifest: PluginManifest | null = null;\n if (publishedUrl) {\n manifest = await fetchRemotePluginManifest(publishedUrl);\n } else if (attachment.production) {\n manifest = await fetchRemotePluginManifest(attachment.production);\n if (manifest) {\n publishedUrl = attachment.production;\n }\n }\n\n const integrity = publishedUrl ? await computeSriHashForUrl(publishedUrl) : null;\n const version = manifest?.plugin.version ?? pkgJson.version;\n\n if (publishedUrl) {\n deps.bosConfig = {\n ...deps.bosConfig,\n plugins: {\n ...(deps.bosConfig.plugins ?? {}),\n [input.key]: {\n ...(deps.bosConfig.plugins?.[input.key] ?? {}),\n production: publishedUrl,\n ...(integrity ? { integrity } : {}),\n ...(manifest?.plugin.name ? { name: manifest.plugin.name } : {}),\n ...(version ? { version } : {}),\n },\n },\n };\n await saveBosConfig(deps.configDir, deps.bosConfig);\n\n const account = deps.bosConfig.account;\n const network = getNetworkIdForAccount(account);\n if (manifest && version) {\n try {\n const registryEntries: Record<string, string> = {\n [`plugins/${account}/${input.key}/manifest.json`]: JSON.stringify(manifest),\n [`plugins/${account}/${input.key}/metadata`]: JSON.stringify({\n title: null,\n description: null,\n repoUrl: deps.bosConfig.repository ?? null,\n version,\n publishedAt: new Date().toISOString(),\n cdnUrl: publishedUrl,\n integrity,\n }),\n [`plugins/${account}/${input.key}/versions/${version}/manifest.json`]:\n JSON.stringify(manifest),\n };\n const payload = JSON.stringify(registryEntries);\n const argsBase64 = Buffer.from(payload).toString(\"base64\");\n const privateKey = process.env.NEAR_PRIVATE_KEY || process.env.BOS_NEAR_PRIVATE_KEY;\n\n await Effect.runPromise(ensureNearCli);\n try {\n await Effect.runPromise(\n executeTransaction({\n account,\n contract: getRegistryNamespaceForNetwork(network),\n method: \"__fastdata_kv\",\n argsBase64,\n network,\n privateKey,\n gas: \"50Tgas\",\n deposit: \"0NEAR\",\n }),\n );\n } catch (registryError) {\n const txHash = extractTransactionHash(registryError);\n if (!txHash) {\n console.warn(\n `[publish] Plugin registry write failed: ${registryError instanceof Error ? registryError.message : registryError}`,\n );\n }\n }\n } catch (registryError) {\n console.warn(\n `[publish] Plugin registry write skipped: ${registryError instanceof Error ? registryError.message : registryError}`,\n );\n }\n }\n\n await refreshApiContractBridge(deps.configDir);\n }\n\n return {\n status: \"published\" as const,\n key: input.key,\n path: localPath,\n script,\n production: publishedUrl ?? attachment.production,\n integrity: integrity ?? undefined,\n version: version ?? undefined,\n };\n },\n ),\n\n dev: builder.dev.handler(async ({ input }: { input: DevOptions }) => {\n ensureEnvFile(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 as string, \"local\")\n : \"remote\";\n const uiSource: SourceMode = localPackages.includes(\"ui\")\n ? parseSourceMode(input.ui as string, \"local\")\n : \"remote\";\n const apiSource: SourceMode = localPackages.includes(\"api\")\n ? parseSourceMode(input.api as string, \"local\")\n : \"remote\";\n const authSource: SourceMode = localPackages.includes(\"auth\")\n ? parseSourceMode(input.auth as string, \"local\")\n : \"remote\";\n const ssr = input.ssr ?? false;\n const proxy = input.proxy ?? false;\n\n const sharedSync = await syncAndGenerateSharedUi({\n configDir: deps.configDir,\n hostMode: hostSource,\n bosConfig: deps.bosConfig ?? undefined,\n });\n if (sharedSync.catalogChanged) {\n await run(\"bun\", [\"install\"], { cwd: deps.configDir });\n }\n if (\n (apiSource === \"local\" && !proxy) ||\n localPackages.some((pkg) => pkg.startsWith(\"plugin:\"))\n ) {\n await buildEveryPluginQuietly(deps.configDir);\n }\n\n await buildEverythingDevQuietly(deps.configDir);\n\n const refreshed = await loadConfig({ cwd: deps.configDir });\n deps.bosConfig = refreshed?.config ?? deps.bosConfig;\n deps.runtimeConfig = refreshed?.runtime ?? deps.runtimeConfig;\n\n if (!deps.bosConfig) {\n return {\n status: \"error\" as const,\n description: \"No bos.config.json found\",\n processes: [],\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 };\n }\n\n const hostPort = input.port ?? getHostDevelopmentPort(deps.bosConfig.app.host.development);\n const developmentRuntime = buildRuntimeConfig(deps.bosConfig, {\n uiSource,\n apiSource,\n authSource,\n hostSource,\n env: \"development\",\n plugins: deps.runtimeConfig?.plugins,\n });\n const runtimeConfig = await prepareDevelopmentRuntimeConfig(developmentRuntime, {\n hostPort,\n ssr,\n });\n\n const services = buildServiceDescriptorMap(runtimeConfig, { ssr, proxy });\n const packages = [...services.keys()];\n const displayEnv: Record<string, string> = {};\n const apiDescriptor = services.get(\"api\");\n if (apiDescriptor?.proxy) {\n const proxyUrl = resolveProxyUrl(deps.bosConfig);\n if (proxyUrl) displayEnv.API_PROXY = proxyUrl;\n }\n\n await syncApiContractBridge({\n configDir: deps.configDir,\n runtimeConfig: runtimeConfig,\n apiBaseUrl: runtimeConfig.api.url,\n });\n\n const orchestrator: AppOrchestrator = {\n packages,\n env: displayEnv,\n description: buildDescription(services),\n port: runtimeConfig.host.port,\n interactive: input.interactive,\n };\n\n devApp(orchestrator, services, runtimeConfig);\n\n return {\n status: \"started\" as const,\n description: orchestrator.description,\n processes: packages,\n };\n }),\n\n start: builder.start.handler(async ({ input }: { input: StartOptions }) => {\n ensureEnvFile(deps.configDir);\n\n let remoteConfig: BosConfig | null = null;\n\n if (input.account && input.domain) {\n remoteConfig = await fetchPublishedConfig(input.account, input.domain);\n if (!remoteConfig) {\n return {\n status: \"error\" as const,\n url: \"\",\n };\n }\n }\n\n const config = remoteConfig || deps.bosConfig;\n if (!config) {\n return {\n status: \"error\" as const,\n url: \"\",\n };\n }\n\n const port = input.port ?? getHostDevelopmentPort(config.app.host.development);\n const isStaging = input.env === \"staging\";\n const runtimePlugins = remoteConfig\n ? await buildRuntimePluginsForConfig(config, deps.configDir, \"production\")\n : deps.runtimeConfig?.plugins;\n const runtimeConfig = buildRuntimeConfig(config, {\n uiSource: \"remote\",\n apiSource: \"remote\",\n authSource: \"remote\",\n hostSource: \"remote\",\n env: \"production\",\n plugins: runtimePlugins,\n });\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 defaultOrigin = `https://${config.domain}`;\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.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 services = buildServiceDescriptorMap(runtimeConfig);\n\n await syncApiContractBridge({\n configDir: deps.configDir,\n runtimeConfig: runtimeConfig,\n apiBaseUrl: runtimeConfig.api.url,\n });\n\n const stagingEnvVars: Record<string, string> = isStaging\n ? { GATEWAY_DOMAIN: config.staging?.domain ?? config.domain ?? \"\" }\n : {};\n\n const configSource = remoteConfig\n ? `bos://${input.account}/${input.domain}`\n : (findConfigPath() ?? \"bos.config.json\");\n\n const configSourceHttp =\n remoteConfig && input.account && input.domain\n ? buildRegistryConfigUrl(input.account, input.domain)\n : undefined;\n\n const summaryLines: string[] = [\"\", ` ${colors.dim(\"Config Source:\")} ${configSource}`];\n if (configSourceHttp) {\n summaryLines.push(` ${colors.dim(configSourceHttp)}`);\n }\n summaryLines.push(\n ` ${colors.dim(\"Account:\")} ${config.account}`,\n ` ${colors.dim(\"Domain:\")} ${config.domain ?? \"not configured\"}`,\n \"\",\n ` ${colors.dim(\"Modules:\")}`,\n ` ${colors.dim(\"HOST\")} → ${runtimeConfig.host.remoteUrl ?? runtimeConfig.host.url ?? \"local\"}`,\n ` ${colors.dim(\"UI\")} → ${runtimeConfig.ui.url ?? \"local\"}`,\n ` ${colors.dim(\"API\")} → ${runtimeConfig.api.url ?? \"local\"}`,\n );\n if (runtimeConfig.auth) {\n summaryLines.push(` ${colors.dim(\"AUTH\")} → ${runtimeConfig.auth.url ?? \"local\"}`);\n }\n if (warnings.length > 0) {\n summaryLines.push(\"\");\n for (const w of warnings) {\n summaryLines.push(` ${colors.yellow(w)}`);\n }\n }\n summaryLines.push(\"\");\n console.log(summaryLines.join(\"\\n\"));\n\n const orchestrator: AppOrchestrator = {\n packages: [\"host\"],\n env: {\n NODE_ENV: \"production\",\n ...productionEnv,\n ...stagingEnvVars,\n },\n description: `${isStaging ? \"Staging\" : \"Production\"} Mode (${config.account})`,\n port,\n interactive: input.interactive,\n noLogs: true,\n };\n\n startApp(orchestrator, services, runtimeConfig);\n return {\n status: \"running\" as const,\n url: `http://localhost:${port}`,\n };\n }),\n\n build: builder.build.handler(async ({ input }: { input: BuildOptions }) => {\n if (!deps.bosConfig) {\n return {\n status: \"error\" as const,\n built: [],\n skipped: [],\n };\n }\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 const runtimeConfig = 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: \"development\",\n plugins: deps.runtimeConfig?.plugins,\n });\n\n await syncApiContractBridge({\n configDir: deps.configDir,\n runtimeConfig,\n apiBaseUrl: runtimeConfig.api.url,\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 }: { input: PublishOptions }) => {\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 account = deps.bosConfig.account;\n const gateway = deps.bosConfig.domain;\n if (!gateway) {\n return {\n status: \"error\" as const,\n registryUrl: \"\",\n error: \"bos.config.json must define domain to publish\",\n };\n }\n\n const network = input.network ?? getNetworkIdForAccount(account);\n const bosUrl = `bos://${account}/${gateway}`;\n const registryUrl = buildRegistryConfigUrlForNetwork(network, account, gateway);\n const targets = selectWorkspaceTargets(input.packages, deps.bosConfig);\n\n let publishConfig = deps.bosConfig;\n let built: string[] | undefined;\n let skipped: string[] | undefined;\n\n if (input.dryRun) {\n return {\n status: \"dry-run\" as const,\n registryUrl,\n built,\n skipped,\n };\n }\n\n if (input.deploy) {\n const result = await buildWorkspaceTargets({\n configDir: deps.configDir,\n bosConfig: deps.bosConfig,\n runtimeConfig: deps.runtimeConfig,\n targets,\n deploy: true,\n });\n built = result.built;\n skipped = result.skipped;\n\n const refreshed = await loadConfig({ cwd: deps.configDir });\n if (refreshed?.config) {\n deps.bosConfig = refreshed.config;\n deps.runtimeConfig = refreshed.runtime;\n publishConfig = refreshed.config;\n }\n }\n\n const payload = JSON.stringify({\n [`apps/${account}/${gateway}/bos.config.json`]: JSON.stringify(publishConfig),\n });\n const argsBase64 = Buffer.from(payload).toString(\"base64\");\n const privateKey =\n input.privateKey || process.env.NEAR_PRIVATE_KEY || process.env.BOS_NEAR_PRIVATE_KEY;\n\n try {\n await Effect.runPromise(ensureNearCli);\n let txHash: string | undefined;\n\n try {\n const tx = await Effect.runPromise(\n executeTransaction({\n account,\n contract: getRegistryNamespaceForNetwork(network),\n method: \"__fastdata_kv\",\n argsBase64,\n network,\n privateKey,\n gas: \"300Tgas\",\n deposit: \"0NEAR\",\n }),\n );\n txHash = tx.txHash;\n } catch (error) {\n txHash = extractTransactionHash(error);\n\n if (!txHash) {\n throw error;\n }\n\n try {\n const verifiedConfig = await fetchBosConfigFromFastKv<BosConfig>(bosUrl);\n if (JSON.stringify(verifiedConfig) !== JSON.stringify(publishConfig)) {\n throw error;\n }\n } catch {\n // Config may not exist yet on first publish or propagation delay;\n // a valid txHash is sufficient proof the transaction was submitted.\n }\n }\n\n return {\n status: \"published\" as const,\n registryUrl,\n txHash,\n built,\n skipped,\n };\n } catch (error) {\n return {\n status: \"error\" as const,\n registryUrl,\n error: error instanceof Error ? error.message : \"Unknown error\",\n built,\n skipped,\n };\n }\n }),\n\n keyPublish: builder.keyPublish.handler(async ({ input }: { input: KeyPublishOptions }) => {\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 const keyPair = await addFunctionCallAccessKey({\n account,\n contract,\n allowance: input.allowance,\n functionNames: PUBLISH_FUNCTION_NAMES,\n network,\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 }: { input: InitOptions }) => {\n try {\n let extendsAccount = input.extendsAccount;\n let extendsGateway = input.extendsGateway;\n let directory = input.directory;\n let account = input.account;\n let domain = input.domain;\n let withHost = input.withHost;\n let plugins = input.plugins;\n\n if (input.extends) {\n const match = input.extends.match(/^(?:bos:\\/\\/)?([^/]+)\\/(.+)$/);\n if (match) {\n if (!extendsAccount) extendsAccount = match[1];\n if (!extendsGateway) extendsGateway = match[2];\n }\n }\n\n if (!input.noInteractive) {\n const prompted = await promptInitOptions({\n extendsAccount,\n extendsGateway,\n extends: input.extends,\n directory,\n account,\n domain,\n plugins,\n withHost,\n });\n extendsAccount = prompted.extendsAccount;\n extendsGateway = prompted.extendsGateway;\n directory = prompted.directory;\n account = prompted.account;\n domain = prompted.domain;\n withHost = prompted.withHost;\n plugins = prompted.plugins;\n }\n\n extendsAccount = extendsAccount || \"dev.everything.near\";\n extendsGateway = extendsGateway || \"everything.dev\";\n directory = directory || domain || extendsGateway;\n plugins = plugins?.length ? plugins : [\"_template\"];\n\n try {\n await fetchParentConfig(extendsAccount, extendsGateway);\n } catch {\n return {\n status: \"error\" as const,\n directory,\n extendsAccount,\n extendsGateway,\n account,\n domain,\n extends: `bos://${extendsAccount}/${extendsGateway}`,\n plugins: plugins ?? [],\n filesCopied: 0,\n error: `No config found at bos://${extendsAccount}/${extendsGateway} — are you sure this is the right parent?`,\n };\n }\n\n const { sourceDir, parentConfig, cleanup } = await resolveSourceDir({\n extendsAccount,\n extendsGateway,\n source: input.source,\n });\n\n try {\n const patterns = await readTemplatekeep(sourceDir);\n if (patterns.length === 0) {\n return {\n status: \"error\" as const,\n directory,\n extendsAccount,\n extendsGateway,\n account,\n domain,\n extends: `bos://${extendsAccount}/${extendsGateway}`,\n plugins: plugins ?? [],\n filesCopied: 0,\n error: \"No .templatekeep found in template source\",\n };\n }\n\n const pluginRoutes: Record<string, string[]> = {};\n if (parentConfig.plugins) {\n for (const [key, ref] of Object.entries(parentConfig.plugins)) {\n if (ref.routes && ref.routes.length > 0) {\n pluginRoutes[key] = ref.routes;\n }\n }\n }\n\n const s = p.spinner();\n s.start(\"Setting up project\");\n\n const filesCopied = await copyFilteredFiles(sourceDir, directory, patterns, {\n withHost,\n plugins,\n pluginRoutes,\n });\n\n await personalizeConfig(directory, {\n extendsAccount,\n extendsGateway,\n account: account || extendsAccount,\n domain: domain || extendsGateway,\n plugins,\n pluginRoutes,\n workspaceOpts: { sourceDir },\n });\n\n await writeInitSnapshot(directory, extendsAccount, extendsGateway, sourceDir, patterns, {\n withHost,\n plugins,\n pluginRoutes,\n });\n\n if (!input.noInstall) {\n await runBunInstall(directory);\n }\n\n ensureEnvFile(directory);\n\n s.stop(\"Project initialized\");\n\n return {\n status: \"initialized\" as const,\n directory,\n extendsAccount,\n extendsGateway,\n account,\n domain,\n extends: `bos://${extendsAccount}/${extendsGateway}`,\n plugins,\n filesCopied,\n };\n } finally {\n await cleanup();\n }\n } catch (error) {\n return {\n status: \"error\" as const,\n directory: input.directory ?? \"\",\n extendsAccount: input.extendsAccount ?? \"\",\n extendsGateway: input.extendsGateway ?? \"\",\n account: input.account,\n domain: input.domain,\n extends:\n input.extendsAccount && input.extendsGateway\n ? `bos://${input.extendsAccount}/${input.extendsGateway}`\n : \"\",\n plugins: input.plugins ?? [],\n filesCopied: 0,\n error: error instanceof Error ? error.message : \"Unknown error\",\n };\n }\n }),\n\n sync: builder.sync.handler(async ({ input }: { input: SyncOptions }) => {\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 return await syncTemplate(projectDir, input);\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 }: { input: UpgradeOptions }) => {\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 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});\n\nfunction extractTransactionHash(error: unknown) {\n const message = error instanceof Error ? error.message : String(error);\n const match =\n message.match(/Transaction ID:\\s*([A-Za-z0-9]+)/i) ||\n message.match(/([A-HJ-NP-Za-km-z1-9]{43,44})/);\n\n return match?.[1];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsEA,SAAS,cAAc,WAAyB;CAC9C,MAAM,8BAAe,WAAW,OAAO;CACvC,MAAM,kCAAmB,WAAW,eAAe;AAEnD,6BAAe,QAAQ,CAAE;AAEzB,KAAI,yBAAY,YAAY,CAAE;CAG9B,MAAM,kCADuB,aAAa,QAAQ,CAC5B,MAAM,KAAK;CAEjC,MAAM,sCAAqB,GAAG,CAAC,SAAS,YAAY;AAcpD,4BAAc,SAZE,MACb,KAAK,SAAS;AACb,MAAI,uBAAuB,KAAK,KAAK,CACnC,QAAO,sBAAsB;AAE/B,MAAI,oBAAoB,KAAK,KAAK,CAChC,QAAO;AAET,SAAO;GACP,CACD,KAAK,KAAK,CAEkB;AAC/B,SAAQ,IAAI,yEAAyE;;AAGvF,MAAM,gBAAiE;CACrE,MAAM;EAAE,KAAK;EAAO,MAAM,CAAC,OAAO,QAAQ;EAAE;CAC5C,IAAI;EAAE,KAAK;EAAO,MAAM,CAAC,OAAO,QAAQ;EAAE;CAC1C,KAAK;EAAE,KAAK;EAAO,MAAM,CAAC,OAAO,QAAQ;EAAE;CAC5C;AAED,MAAM,yBAAyB,CAAC,gBAAgB;AAUhD,SAAS,gBAAgB,OAA2B,cAAsC;AACxF,KAAI,UAAU,WAAW,UAAU,SAAU,QAAO;AACpD,QAAO;;AAGT,SAAS,kBAAkB,WAA8C;CACvE,MAAM,WAAW,YAAY,OAAO,KAAK,UAAU,IAAI,GAAG,EAA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,+BAAgB;AACnC,QAAI,CAAC,WACH,QAAO;KACL,QAAQ;KACR,SAAS,EAAE;KACX,SAAS,EAAE;KACX,OAAO,EAAE;KACT,OAAO;KACR;AAIH,WAAO,MAAMe,wEADsB,WAAW,CAAC,EACT,MAAM;YACrC,OAAO;AACd,WAAO;KACL,QAAQ;KACR,SAAS,EAAE;KACX,SAAS,EAAE;KACX,OAAO,EAAE;KACT,OAAO,iBAAiB,QAAQ,MAAM,UAAU;KACjD;;IAEH;EAEF,SAAS,QAAQ,QAAQ,QAAQ,OAAO,EAAE,YAAuC;AAC/E,OAAI;IACF,MAAM,aAAaf,+BAAgB;AACnC,QAAI,CAAC,WACH,QAAO;KACL,QAAQ;KACR,UAAU,EAAE;KACZ,OAAO;KACR;AAIH,WAAO,MAAMgB,8EADsB,WAAW,CAAC,EACN,MAAM;YACxC,OAAO;AACd,WAAO;KACL,QAAQ;KACR,UAAU,EAAE;KACZ,OAAO,iBAAiB,QAAQ,MAAM,UAAU;KACjD;;IAEH;EAEF,QAAQ,QAAQ,OAAO,QAAQ,YAAY;AACzC,OAAI;IACF,MAAM,aAAahB,+BAAgB;AACnC,QAAI,CAAC,WACH,QAAO;KACL,QAAQ;KACR,UAAU,EAAE;KACZ,SAAS;KACT,OAAO;KACR;AAIH,WAAO,MAAMiB,uEADsB,WAAW,CAAC,CACb;YAC3B,OAAO;AACd,WAAO;KACL,QAAQ;KACR,UAAU,EAAE;KACZ,SAAS;KACT,OAAO,iBAAiB,QAAQ,MAAM,UAAU;KACjD;;IAEH;EACH;CACF,CAAC;AAEF,SAAS,uBAAuB,OAAgB;CAC9C,MAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM;AAKtE,SAHE,QAAQ,MAAM,oCAAoC,IAClD,QAAQ,MAAM,gCAAgC,IAEjC"}
package/dist/plugin.d.cts CHANGED
@@ -393,7 +393,7 @@ declare const _default: _$every_plugin0.LoadedPluginWithBinding<{
393
393
  }> | undefined;
394
394
  } | null;
395
395
  runtimeConfig: {
396
- env: "development" | "production";
396
+ env: "production" | "development";
397
397
  account: string;
398
398
  networkId: "testnet" | "mainnet";
399
399
  host: {
package/dist/plugin.d.mts CHANGED
@@ -393,7 +393,7 @@ declare const _default: _$every_plugin0.LoadedPluginWithBinding<{
393
393
  }> | undefined;
394
394
  } | null;
395
395
  runtimeConfig: {
396
- env: "development" | "production";
396
+ env: "production" | "development";
397
397
  account: string;
398
398
  networkId: "testnet" | "mainnet";
399
399
  host: {
package/dist/plugin.mjs CHANGED
@@ -628,22 +628,16 @@ var plugin_default = createPlugin({
628
628
  const stagingEnvVars = isStaging ? { GATEWAY_DOMAIN: config.staging?.domain ?? config.domain ?? "" } : {};
629
629
  const configSource = remoteConfig ? `bos://${input.account}/${input.domain}` : findConfigPath() ?? "bos.config.json";
630
630
  const configSourceHttp = remoteConfig && input.account && input.domain ? buildRegistryConfigUrl(input.account, input.domain) : void 0;
631
- console.log();
632
- console.log(` ${colors.dim("Config Source:")} ${configSource}`);
633
- if (configSourceHttp) console.log(` ${colors.dim(configSourceHttp)}`);
634
- console.log(` ${colors.dim("Account:")} ${config.account}`);
635
- console.log(` ${colors.dim("Domain:")} ${config.domain ?? "not configured"}`);
636
- console.log();
637
- console.log(` ${colors.dim("Modules:")}`);
638
- console.log(` ${colors.dim("HOST")} → ${runtimeConfig.host.remoteUrl ?? runtimeConfig.host.url ?? "local"}`);
639
- console.log(` ${colors.dim("UI")} → ${runtimeConfig.ui.url ?? "local"}`);
640
- console.log(` ${colors.dim("API")} → ${runtimeConfig.api.url ?? "local"}`);
641
- if (runtimeConfig.auth) console.log(` ${colors.dim("AUTH")} → ${runtimeConfig.auth.url ?? "local"}`);
631
+ const summaryLines = ["", ` ${colors.dim("Config Source:")} ${configSource}`];
632
+ if (configSourceHttp) summaryLines.push(` ${colors.dim(configSourceHttp)}`);
633
+ summaryLines.push(` ${colors.dim("Account:")} ${config.account}`, ` ${colors.dim("Domain:")} ${config.domain ?? "not configured"}`, "", ` ${colors.dim("Modules:")}`, ` ${colors.dim("HOST")} → ${runtimeConfig.host.remoteUrl ?? runtimeConfig.host.url ?? "local"}`, ` ${colors.dim("UI")} → ${runtimeConfig.ui.url ?? "local"}`, ` ${colors.dim("API")} → ${runtimeConfig.api.url ?? "local"}`);
634
+ if (runtimeConfig.auth) summaryLines.push(` ${colors.dim("AUTH")}${runtimeConfig.auth.url ?? "local"}`);
642
635
  if (warnings.length > 0) {
643
- console.log();
644
- for (const w of warnings) console.log(` ${colors.yellow(w)}`);
636
+ summaryLines.push("");
637
+ for (const w of warnings) summaryLines.push(` ${colors.yellow(w)}`);
645
638
  }
646
- console.log();
639
+ summaryLines.push("");
640
+ console.log(summaryLines.join("\n"));
647
641
  startApp({
648
642
  packages: ["host"],
649
643
  env: {
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.mjs","names":[],"sources":["../src/plugin.ts"],"sourcesContent":["import { randomBytes } from \"node:crypto\";\nimport { existsSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { basename, dirname, join, resolve } from \"node:path\";\nimport * as p from \"@clack/prompts\";\nimport { Effect } from \"effect\";\nimport { syncApiContractBridge } from \"./api-contract\";\nimport { buildRuntimeConfig, detectLocalPackages, prepareDevelopmentRuntimeConfig } from \"./app\";\nimport {\n copyFilteredFiles,\n fetchParentConfig,\n personalizeConfig,\n readTemplatekeep,\n resolveSourceDir,\n runBunInstall,\n writeInitSnapshot,\n} from \"./cli/init\";\nimport { promptInitOptions } from \"./cli/prompts\";\nimport { getStatus } from \"./cli/status\";\nimport { syncTemplate } from \"./cli/sync\";\nimport { upgradeTemplate } from \"./cli/upgrade\";\nimport {\n buildRuntimePluginsForConfig,\n findConfigPath,\n getHostDevelopmentPort,\n getProjectRoot,\n loadConfig,\n resolveLocalDevelopmentPath,\n} from \"./config\";\nimport {\n type BosConfigResult,\n type BuildOptions,\n bosContract,\n type DevOptions,\n type InitOptions,\n type KeyPublishOptions,\n type PluginAddOptions,\n type PluginListResult,\n type PluginPublishOptions,\n type PluginRemoveOptions,\n type PublishOptions,\n type StartOptions,\n type SyncOptions,\n type UpgradeOptions,\n} from \"./contract\";\nimport { devApp, startApp } from \"./dev-session\";\nimport {\n buildRegistryConfigUrl,\n buildRegistryConfigUrlForNetwork,\n fetchBosConfigFromFastKv,\n fetchPluginFromRegistry,\n fetchRemotePluginManifest,\n getRegistryNamespaceForAccount,\n getRegistryNamespaceForNetwork,\n type PluginManifest,\n parsePluginBosUrl,\n} from \"./fastkv\";\nimport { computeSriHashForUrl } from \"./integrity\";\nimport { addFunctionCallAccessKey, ensureNearCli, executeTransaction } from \"./near-cli\";\nimport { getNetworkIdForAccount } from \"./network\";\nimport { createPlugin, z } from \"./sdk\";\nimport {\n type AppOrchestrator,\n buildDescription,\n buildServiceDescriptorMap,\n} from \"./service-descriptor\";\nimport { syncAndGenerateSharedUi } from \"./shared\";\nimport type { BosConfig, RuntimeConfig, SourceMode } from \"./types\";\nimport { run } from \"./utils/run\";\nimport { colors } from \"./utils/theme\";\n\nfunction ensureEnvFile(configDir: string): void {\n const envPath = join(configDir, \".env\");\n const examplePath = join(configDir, \".env.example\");\n\n if (existsSync(envPath)) return;\n\n if (!existsSync(examplePath)) return;\n\n const content = readFileSync(examplePath, \"utf-8\");\n const lines = content.split(\"\\n\");\n\n const secret = randomBytes(32).toString(\"base64url\");\n\n const updated = lines\n .map((line) => {\n if (/^BETTER_AUTH_SECRET=/.test(line)) {\n return `BETTER_AUTH_SECRET=${secret}`;\n }\n if (/^BETTER_AUTH_URL=/.test(line)) {\n return `BETTER_AUTH_URL=http://localhost:3000`;\n }\n return line;\n })\n .join(\"\\n\");\n\n writeFileSync(envPath, updated);\n console.log(`[CLI] Created .env from .env.example with generated BETTER_AUTH_SECRET`);\n}\n\nconst buildCommands: Record<string, { cmd: string; args: string[] }> = {\n host: { cmd: \"bun\", args: [\"run\", \"build\"] },\n ui: { cmd: \"bun\", args: [\"run\", \"build\"] },\n api: { cmd: \"bun\", args: [\"run\", \"build\"] },\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(bosConfig: BosConfig | null): BosConfigResult {\n const packages = bosConfig ? Object.keys(bosConfig.app) : [];\n const remotes = packages.filter((name) => name !== \"host\");\n\n return {\n config: bosConfig,\n packages,\n remotes,\n };\n}\n\ntype WorkspaceTarget = {\n key: string;\n kind: \"app\" | \"plugin\";\n path: string;\n};\n\nfunction resolveWorkspaceTarget(\n key: string,\n bosConfig: BosConfig | null,\n runtimeConfig: RuntimeConfig | null,\n configDir: string,\n): WorkspaceTarget | null {\n if (bosConfig?.app && key in bosConfig.app) {\n const appEntry = (bosConfig.app as Record<string, { development?: string }>)[key];\n const devPath = resolveLocalDevelopmentPath(appEntry?.development, configDir);\n if (devPath) {\n return {\n key,\n kind: \"app\",\n path: devPath,\n };\n }\n return {\n key,\n kind: \"app\",\n path: `${configDir}/${key}`,\n };\n }\n\n const runtimePlugin = runtimeConfig?.plugins?.[key];\n const pluginPath =\n runtimePlugin?.localPath ??\n resolveLocalDevelopmentPath(bosConfig?.plugins?.[key]?.development, configDir);\n if (pluginPath) {\n return {\n key,\n kind: \"plugin\",\n path: pluginPath,\n };\n }\n\n return null;\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 source = attachment.development ?? attachment.production;\n if (!source?.startsWith(\"local:\")) {\n return null;\n }\n\n return join(configDir, source.slice(\"local:\".length));\n}\n\nasync function saveBosConfig(configDir: string, config: BosConfig): Promise<void> {\n const filePath = join(configDir, \"bos.config.json\");\n const next = `${JSON.stringify(config, null, 2)}\\n`;\n try {\n if (readFileSync(filePath, \"utf8\") === next) return;\n } catch {\n // file does not exist yet\n }\n\n writeFileSync(filePath, next);\n}\n\nfunction listPluginAttachments(config: BosConfig | null) {\n return (Object.entries(config?.plugins ?? {}) as Array<[string, PluginAttachmentConfig]>)\n .map(([key, attachment]) => ({\n key,\n development: attachment.development,\n production: attachment.production,\n localPath: attachment.development?.startsWith(\"local:\")\n ? attachment.development.slice(\"local:\".length)\n : undefined,\n source: attachment.development?.startsWith(\"local:\")\n ? (\"local\" as const)\n : (\"remote\" as const),\n integrity: attachment.integrity,\n version: attachment.version,\n name: attachment.name,\n }))\n .sort((a, b) => a.key.localeCompare(b.key));\n}\n\nasync function refreshApiContractBridge(configDir: string): Promise<void> {\n const refreshed = await loadConfig({ cwd: configDir, env: \"development\" });\n if (!refreshed) return;\n\n await syncApiContractBridge({\n configDir,\n runtimeConfig: refreshed.runtime,\n apiBaseUrl: refreshed.runtime.api.url,\n });\n}\n\nfunction extractPublishedUrl(output: string): string | null {\n const match = output.match(/https?:\\/\\/[^\\s\"'<>]+/g);\n if (!match || match.length === 0) return null;\n return match[match.length - 1] ?? null;\n}\n\nasync function buildEveryPluginQuietly(cwd: string) {\n const packageDir = `${cwd}/packages/every-plugin`;\n const packageExists = await Bun.file(`${packageDir}/package.json`).exists();\n if (!packageExists) {\n return;\n }\n\n const distPath = `${cwd}/packages/every-plugin/dist/build/rspack/plugin.mjs`;\n const distExists = await Bun.file(distPath).exists();\n\n if (distExists) {\n return;\n }\n\n const result = (await run(\"bun\", [\"run\", \"--cwd\", \"packages/every-plugin\", \"build\"], {\n cwd,\n capture: true,\n })) as { stdout: string; stderr: string; exitCode: number };\n\n if (result.exitCode === 0) {\n console.log(\"[build:ssr] build succeeded\");\n return;\n }\n\n if (result.stdout.trim()) {\n process.stdout.write(result.stdout);\n }\n\n if (result.stderr.trim()) {\n process.stderr.write(result.stderr);\n }\n\n throw new Error(\n `bun run --cwd packages/every-plugin build failed with exit code ${result.exitCode}`,\n );\n}\n\nasync function buildEverythingDevQuietly(cwd: string) {\n const packageDir = `${cwd}/packages/everything-dev`;\n const packageExists = await Bun.file(`${packageDir}/package.json`).exists();\n if (!packageExists) {\n return;\n }\n\n const distPath = `${cwd}/packages/everything-dev/dist/index.mjs`;\n const distExists = await Bun.file(distPath).exists();\n\n if (distExists) {\n return;\n }\n\n const result = (await run(\"bun\", [\"run\", \"--cwd\", \"packages/everything-dev\", \"build\"], {\n cwd,\n capture: true,\n })) as { stdout: string; stderr: string; exitCode: number };\n\n if (result.exitCode === 0) {\n console.log(\"[everything-dev] build succeeded\");\n return;\n }\n\n if (result.stdout.trim()) {\n process.stdout.write(result.stdout);\n }\n\n if (result.stderr.trim()) {\n process.stderr.write(result.stderr);\n }\n\n throw new Error(\n `bun run --cwd packages/everything-dev build failed with exit code ${result.exitCode}`,\n );\n}\n\nasync function fetchPublishedConfig(\n accountId: string,\n gatewayId: string,\n): Promise<BosConfig | null> {\n try {\n return await fetchBosConfigFromFastKv<BosConfig>(`bos://${accountId}/${gatewayId}`);\n } catch {\n return null;\n }\n}\n\nfunction selectWorkspaceTargets(packages: string, bosConfig: BosConfig | null): string[] {\n const allPackages = [\n ...Object.keys(bosConfig?.app ?? {}),\n ...Object.keys(bosConfig?.plugins ?? {}),\n ];\n if (packages === \"all\") {\n return allPackages;\n }\n\n return packages\n .split(\",\")\n .map((pkg) => pkg.trim())\n .filter((pkg) => allPackages.includes(pkg));\n}\n\nasync function buildWorkspaceTargets(opts: {\n configDir: string;\n bosConfig: BosConfig | null;\n runtimeConfig: RuntimeConfig | null;\n targets: string[];\n deploy: boolean;\n}): Promise<{ built: string[]; skipped: string[] }> {\n const existing: WorkspaceTarget[] = [];\n const skipped: string[] = [];\n\n for (const target of opts.targets) {\n const resolved = resolveWorkspaceTarget(\n target,\n opts.bosConfig,\n opts.runtimeConfig,\n opts.configDir,\n );\n if (!resolved) {\n skipped.push(target);\n continue;\n }\n\n const exists = await Bun.file(`${resolved.path}/package.json`).exists();\n if (exists) existing.push(resolved);\n else skipped.push(target);\n }\n\n if (existing.length === 0) {\n return { built: [], skipped };\n }\n\n const sharedSync = await syncAndGenerateSharedUi({\n configDir: opts.configDir,\n hostMode: \"local\",\n bosConfig: opts.bosConfig ?? undefined,\n });\n if (sharedSync.catalogChanged) {\n await run(\"bun\", [\"install\"], { cwd: opts.configDir });\n }\n\n if (existing.some((entry) => entry.key === \"api\")) {\n await buildEveryPluginQuietly(opts.configDir);\n }\n\n await buildEverythingDevQuietly(opts.configDir);\n\n const env: Record<string, string> = {\n ...process.env,\n NODE_ENV: opts.deploy ? \"production\" : \"development\",\n };\n if (opts.deploy) {\n env.DEPLOY = \"true\";\n } else {\n delete env.DEPLOY;\n }\n\n const orderedExisting = opts.deploy\n ? [\n ...existing.filter((entry) => entry.kind === \"app\" && entry.key !== \"host\"),\n ...existing.filter((entry) => entry.kind === \"plugin\"),\n ...existing.filter((entry) => entry.kind === \"app\" && entry.key === \"host\"),\n ]\n : existing;\n const built: string[] = [];\n\n for (const resolved of orderedExisting) {\n const pkgJson = JSON.parse(await Bun.file(`${resolved.path}/package.json`).text()) as {\n scripts?: Record<string, string>;\n };\n const shouldDeployScript = opts.deploy && pkgJson.scripts?.deploy;\n const buildConfig = shouldDeployScript\n ? { cmd: \"bun\", args: [\"run\", \"deploy\"] }\n : (buildCommands[resolved.key] ?? { cmd: \"bun\", args: [\"run\", \"build\"] });\n\n await run(buildConfig.cmd, buildConfig.args, {\n cwd: resolved.path,\n env,\n });\n built.push(resolved.key);\n }\n\n return { built, skipped };\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: any) =>\n Effect.promise(async () => {\n const configResult = await loadConfig({ 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: BosDeps, builder: any) => ({\n config: builder.config.handler(async () => buildConfigResult(deps.bosConfig)),\n\n pluginAdd: builder.pluginAdd.handler(async ({ input }: { input: PluginAddOptions }) => {\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 pluginRef = parsePluginBosUrl(input.source);\n let production = input.production ?? input.source;\n let integrity: string | undefined;\n let version: string | undefined;\n let name: string | undefined;\n\n if (pluginRef) {\n try {\n const entry = await fetchPluginFromRegistry(pluginRef.accountId, pluginRef.pluginName);\n if (!entry) {\n return {\n status: \"error\" as const,\n key: \"\",\n error: `Plugin not found in registry: bos://${pluginRef.accountId}/plugins/${pluginRef.pluginName}`,\n };\n }\n\n const manifest = entry.manifest;\n if (\n manifest.schemaVersion !== 1 ||\n manifest.kind !== \"every-plugin/manifest\" ||\n !manifest.plugin?.name ||\n !manifest.plugin?.version ||\n !manifest.runtime?.remoteEntry\n ) {\n return {\n status: \"error\" as const,\n key: \"\",\n error: `Invalid plugin manifest for bos://${pluginRef.accountId}/plugins/${pluginRef.pluginName}`,\n };\n }\n\n production = entry.metadata.cdnUrl || input.production || input.source;\n name = manifest.plugin.name;\n version = manifest.plugin.version;\n } catch (error) {\n return {\n status: \"error\" as const,\n key: \"\",\n error: `Failed to resolve plugin from registry: ${error instanceof Error ? error.message : error}`,\n };\n }\n }\n\n if (!input.source.startsWith(\"local:\") && !pluginRef && production.startsWith(\"https://\")) {\n try {\n const manifest = await fetchRemotePluginManifest(production);\n if (manifest) {\n name = manifest.plugin.name;\n version = manifest.plugin.version;\n }\n } catch {\n console.warn(`[plugin add] Could not fetch manifest from ${production}`);\n }\n }\n\n if (!input.source.startsWith(\"local:\") && production.startsWith(\"https://\")) {\n try {\n const computed = await computeSriHashForUrl(production);\n if (computed) integrity = computed;\n } catch {\n console.warn(`[plugin add] Could not compute integrity for ${production}`);\n }\n }\n\n const key = sanitizePluginKey(\n input.as ?? (pluginRef ? pluginRef.pluginName : defaultPluginKey(input.source)),\n );\n const existing = deps.bosConfig.plugins?.[key];\n const nextPlugins = { ...(deps.bosConfig.plugins ?? {}) };\n\n nextPlugins[key] = input.source.startsWith(\"local:\")\n ? {\n ...(existing ?? {}),\n development: input.source,\n production: input.production ?? existing?.production,\n }\n : {\n ...(existing ?? {}),\n production,\n ...(integrity ? { integrity } : {}),\n ...(name ? { name } : {}),\n ...(version ? { version } : {}),\n };\n\n deps.bosConfig = {\n ...deps.bosConfig,\n plugins: nextPlugins,\n };\n\n await saveBosConfig(deps.configDir, deps.bosConfig);\n await refreshApiContractBridge(deps.configDir);\n\n return {\n status: \"added\" as const,\n key,\n development: deps.bosConfig.plugins?.[key]?.development,\n production: deps.bosConfig.plugins?.[key]?.production,\n integrity,\n version,\n };\n }),\n\n pluginRemove: builder.pluginRemove.handler(\n async ({ input }: { input: PluginRemoveOptions }) => {\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 refreshApiContractBridge(deps.configDir);\n\n return {\n status: \"removed\" as const,\n key: input.key,\n };\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(\n async ({ input }: { input: PluginPublishOptions }) => {\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 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 Bun.file(pkgPath).exists())) {\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 Bun.file(pkgPath).json()) as {\n scripts?: Record<string, string>;\n name?: string;\n version?: string;\n };\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 let publishedUrl = extractPublishedUrl(`${stdout}\\n${stderr}`);\n\n let manifest: PluginManifest | null = null;\n if (publishedUrl) {\n manifest = await fetchRemotePluginManifest(publishedUrl);\n } else if (attachment.production) {\n manifest = await fetchRemotePluginManifest(attachment.production);\n if (manifest) {\n publishedUrl = attachment.production;\n }\n }\n\n const integrity = publishedUrl ? await computeSriHashForUrl(publishedUrl) : null;\n const version = manifest?.plugin.version ?? pkgJson.version;\n\n if (publishedUrl) {\n deps.bosConfig = {\n ...deps.bosConfig,\n plugins: {\n ...(deps.bosConfig.plugins ?? {}),\n [input.key]: {\n ...(deps.bosConfig.plugins?.[input.key] ?? {}),\n production: publishedUrl,\n ...(integrity ? { integrity } : {}),\n ...(manifest?.plugin.name ? { name: manifest.plugin.name } : {}),\n ...(version ? { version } : {}),\n },\n },\n };\n await saveBosConfig(deps.configDir, deps.bosConfig);\n\n const account = deps.bosConfig.account;\n const network = getNetworkIdForAccount(account);\n if (manifest && version) {\n try {\n const registryEntries: Record<string, string> = {\n [`plugins/${account}/${input.key}/manifest.json`]: JSON.stringify(manifest),\n [`plugins/${account}/${input.key}/metadata`]: JSON.stringify({\n title: null,\n description: null,\n repoUrl: deps.bosConfig.repository ?? null,\n version,\n publishedAt: new Date().toISOString(),\n cdnUrl: publishedUrl,\n integrity,\n }),\n [`plugins/${account}/${input.key}/versions/${version}/manifest.json`]:\n JSON.stringify(manifest),\n };\n const payload = JSON.stringify(registryEntries);\n const argsBase64 = Buffer.from(payload).toString(\"base64\");\n const privateKey = process.env.NEAR_PRIVATE_KEY || process.env.BOS_NEAR_PRIVATE_KEY;\n\n await Effect.runPromise(ensureNearCli);\n try {\n await Effect.runPromise(\n executeTransaction({\n account,\n contract: getRegistryNamespaceForNetwork(network),\n method: \"__fastdata_kv\",\n argsBase64,\n network,\n privateKey,\n gas: \"50Tgas\",\n deposit: \"0NEAR\",\n }),\n );\n } catch (registryError) {\n const txHash = extractTransactionHash(registryError);\n if (!txHash) {\n console.warn(\n `[publish] Plugin registry write failed: ${registryError instanceof Error ? registryError.message : registryError}`,\n );\n }\n }\n } catch (registryError) {\n console.warn(\n `[publish] Plugin registry write skipped: ${registryError instanceof Error ? registryError.message : registryError}`,\n );\n }\n }\n\n await refreshApiContractBridge(deps.configDir);\n }\n\n return {\n status: \"published\" as const,\n key: input.key,\n path: localPath,\n script,\n production: publishedUrl ?? attachment.production,\n integrity: integrity ?? undefined,\n version: version ?? undefined,\n };\n },\n ),\n\n dev: builder.dev.handler(async ({ input }: { input: DevOptions }) => {\n ensureEnvFile(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 as string, \"local\")\n : \"remote\";\n const uiSource: SourceMode = localPackages.includes(\"ui\")\n ? parseSourceMode(input.ui as string, \"local\")\n : \"remote\";\n const apiSource: SourceMode = localPackages.includes(\"api\")\n ? parseSourceMode(input.api as string, \"local\")\n : \"remote\";\n const authSource: SourceMode = localPackages.includes(\"auth\")\n ? parseSourceMode(input.auth as string, \"local\")\n : \"remote\";\n const ssr = input.ssr ?? false;\n const proxy = input.proxy ?? false;\n\n const sharedSync = await syncAndGenerateSharedUi({\n configDir: deps.configDir,\n hostMode: hostSource,\n bosConfig: deps.bosConfig ?? undefined,\n });\n if (sharedSync.catalogChanged) {\n await run(\"bun\", [\"install\"], { cwd: deps.configDir });\n }\n if (\n (apiSource === \"local\" && !proxy) ||\n localPackages.some((pkg) => pkg.startsWith(\"plugin:\"))\n ) {\n await buildEveryPluginQuietly(deps.configDir);\n }\n\n await buildEverythingDevQuietly(deps.configDir);\n\n const refreshed = await loadConfig({ cwd: deps.configDir });\n deps.bosConfig = refreshed?.config ?? deps.bosConfig;\n deps.runtimeConfig = refreshed?.runtime ?? deps.runtimeConfig;\n\n if (!deps.bosConfig) {\n return {\n status: \"error\" as const,\n description: \"No bos.config.json found\",\n processes: [],\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 };\n }\n\n const hostPort = input.port ?? getHostDevelopmentPort(deps.bosConfig.app.host.development);\n const developmentRuntime = buildRuntimeConfig(deps.bosConfig, {\n uiSource,\n apiSource,\n authSource,\n hostSource,\n env: \"development\",\n plugins: deps.runtimeConfig?.plugins,\n });\n const runtimeConfig = await prepareDevelopmentRuntimeConfig(developmentRuntime, {\n hostPort,\n ssr,\n });\n\n const services = buildServiceDescriptorMap(runtimeConfig, { ssr, proxy });\n const packages = [...services.keys()];\n const displayEnv: Record<string, string> = {};\n const apiDescriptor = services.get(\"api\");\n if (apiDescriptor?.proxy) {\n const proxyUrl = resolveProxyUrl(deps.bosConfig);\n if (proxyUrl) displayEnv.API_PROXY = proxyUrl;\n }\n\n await syncApiContractBridge({\n configDir: deps.configDir,\n runtimeConfig: runtimeConfig,\n apiBaseUrl: runtimeConfig.api.url,\n });\n\n const orchestrator: AppOrchestrator = {\n packages,\n env: displayEnv,\n description: buildDescription(services),\n port: runtimeConfig.host.port,\n interactive: input.interactive,\n };\n\n devApp(orchestrator, services, runtimeConfig);\n\n return {\n status: \"started\" as const,\n description: orchestrator.description,\n processes: packages,\n };\n }),\n\n start: builder.start.handler(async ({ input }: { input: StartOptions }) => {\n ensureEnvFile(deps.configDir);\n\n let remoteConfig: BosConfig | null = null;\n\n if (input.account && input.domain) {\n remoteConfig = await fetchPublishedConfig(input.account, input.domain);\n if (!remoteConfig) {\n return {\n status: \"error\" as const,\n url: \"\",\n };\n }\n }\n\n const config = remoteConfig || deps.bosConfig;\n if (!config) {\n return {\n status: \"error\" as const,\n url: \"\",\n };\n }\n\n const port = input.port ?? getHostDevelopmentPort(config.app.host.development);\n const isStaging = input.env === \"staging\";\n const runtimePlugins = remoteConfig\n ? await buildRuntimePluginsForConfig(config, deps.configDir, \"production\")\n : deps.runtimeConfig?.plugins;\n const runtimeConfig = buildRuntimeConfig(config, {\n uiSource: \"remote\",\n apiSource: \"remote\",\n authSource: \"remote\",\n hostSource: \"remote\",\n env: \"production\",\n plugins: runtimePlugins,\n });\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 defaultOrigin = `https://${config.domain}`;\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.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 services = buildServiceDescriptorMap(runtimeConfig);\n\n await syncApiContractBridge({\n configDir: deps.configDir,\n runtimeConfig: runtimeConfig,\n apiBaseUrl: runtimeConfig.api.url,\n });\n\n const stagingEnvVars: Record<string, string> = isStaging\n ? { GATEWAY_DOMAIN: config.staging?.domain ?? config.domain ?? \"\" }\n : {};\n\n const configSource = remoteConfig\n ? `bos://${input.account}/${input.domain}`\n : (findConfigPath() ?? \"bos.config.json\");\n\n const configSourceHttp =\n remoteConfig && input.account && input.domain\n ? buildRegistryConfigUrl(input.account, input.domain)\n : undefined;\n\n console.log();\n console.log(` ${colors.dim(\"Config Source:\")} ${configSource}`);\n if (configSourceHttp) {\n console.log(` ${colors.dim(configSourceHttp)}`);\n }\n console.log(` ${colors.dim(\"Account:\")} ${config.account}`);\n console.log(` ${colors.dim(\"Domain:\")} ${config.domain ?? \"not configured\"}`);\n console.log();\n console.log(` ${colors.dim(\"Modules:\")}`);\n console.log(\n ` ${colors.dim(\"HOST\")} → ${runtimeConfig.host.remoteUrl ?? runtimeConfig.host.url ?? \"local\"}`,\n );\n console.log(` ${colors.dim(\"UI\")} → ${runtimeConfig.ui.url ?? \"local\"}`);\n console.log(` ${colors.dim(\"API\")} → ${runtimeConfig.api.url ?? \"local\"}`);\n if (runtimeConfig.auth) {\n console.log(` ${colors.dim(\"AUTH\")} → ${runtimeConfig.auth.url ?? \"local\"}`);\n }\n if (warnings.length > 0) {\n console.log();\n for (const w of warnings) {\n console.log(` ${colors.yellow(w)}`);\n }\n }\n console.log();\n\n const orchestrator: AppOrchestrator = {\n packages: [\"host\"],\n env: {\n NODE_ENV: \"production\",\n ...productionEnv,\n ...stagingEnvVars,\n },\n description: `${isStaging ? \"Staging\" : \"Production\"} Mode (${config.account})`,\n port,\n interactive: input.interactive,\n noLogs: true,\n };\n\n startApp(orchestrator, services, runtimeConfig);\n return {\n status: \"running\" as const,\n url: `http://localhost:${port}`,\n };\n }),\n\n build: builder.build.handler(async ({ input }: { input: BuildOptions }) => {\n if (!deps.bosConfig) {\n return {\n status: \"error\" as const,\n built: [],\n skipped: [],\n };\n }\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 const runtimeConfig = 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: \"development\",\n plugins: deps.runtimeConfig?.plugins,\n });\n\n await syncApiContractBridge({\n configDir: deps.configDir,\n runtimeConfig,\n apiBaseUrl: runtimeConfig.api.url,\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 }: { input: PublishOptions }) => {\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 account = deps.bosConfig.account;\n const gateway = deps.bosConfig.domain;\n if (!gateway) {\n return {\n status: \"error\" as const,\n registryUrl: \"\",\n error: \"bos.config.json must define domain to publish\",\n };\n }\n\n const network = input.network ?? getNetworkIdForAccount(account);\n const bosUrl = `bos://${account}/${gateway}`;\n const registryUrl = buildRegistryConfigUrlForNetwork(network, account, gateway);\n const targets = selectWorkspaceTargets(input.packages, deps.bosConfig);\n\n let publishConfig = deps.bosConfig;\n let built: string[] | undefined;\n let skipped: string[] | undefined;\n\n if (input.dryRun) {\n return {\n status: \"dry-run\" as const,\n registryUrl,\n built,\n skipped,\n };\n }\n\n if (input.deploy) {\n const result = await buildWorkspaceTargets({\n configDir: deps.configDir,\n bosConfig: deps.bosConfig,\n runtimeConfig: deps.runtimeConfig,\n targets,\n deploy: true,\n });\n built = result.built;\n skipped = result.skipped;\n\n const refreshed = await loadConfig({ cwd: deps.configDir });\n if (refreshed?.config) {\n deps.bosConfig = refreshed.config;\n deps.runtimeConfig = refreshed.runtime;\n publishConfig = refreshed.config;\n }\n }\n\n const payload = JSON.stringify({\n [`apps/${account}/${gateway}/bos.config.json`]: JSON.stringify(publishConfig),\n });\n const argsBase64 = Buffer.from(payload).toString(\"base64\");\n const privateKey =\n input.privateKey || process.env.NEAR_PRIVATE_KEY || process.env.BOS_NEAR_PRIVATE_KEY;\n\n try {\n await Effect.runPromise(ensureNearCli);\n let txHash: string | undefined;\n\n try {\n const tx = await Effect.runPromise(\n executeTransaction({\n account,\n contract: getRegistryNamespaceForNetwork(network),\n method: \"__fastdata_kv\",\n argsBase64,\n network,\n privateKey,\n gas: \"300Tgas\",\n deposit: \"0NEAR\",\n }),\n );\n txHash = tx.txHash;\n } catch (error) {\n txHash = extractTransactionHash(error);\n\n if (!txHash) {\n throw error;\n }\n\n try {\n const verifiedConfig = await fetchBosConfigFromFastKv<BosConfig>(bosUrl);\n if (JSON.stringify(verifiedConfig) !== JSON.stringify(publishConfig)) {\n throw error;\n }\n } catch {\n // Config may not exist yet on first publish or propagation delay;\n // a valid txHash is sufficient proof the transaction was submitted.\n }\n }\n\n return {\n status: \"published\" as const,\n registryUrl,\n txHash,\n built,\n skipped,\n };\n } catch (error) {\n return {\n status: \"error\" as const,\n registryUrl,\n error: error instanceof Error ? error.message : \"Unknown error\",\n built,\n skipped,\n };\n }\n }),\n\n keyPublish: builder.keyPublish.handler(async ({ input }: { input: KeyPublishOptions }) => {\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 const keyPair = await addFunctionCallAccessKey({\n account,\n contract,\n allowance: input.allowance,\n functionNames: PUBLISH_FUNCTION_NAMES,\n network,\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 }: { input: InitOptions }) => {\n try {\n let extendsAccount = input.extendsAccount;\n let extendsGateway = input.extendsGateway;\n let directory = input.directory;\n let account = input.account;\n let domain = input.domain;\n let withHost = input.withHost;\n let plugins = input.plugins;\n\n if (input.extends) {\n const match = input.extends.match(/^(?:bos:\\/\\/)?([^/]+)\\/(.+)$/);\n if (match) {\n if (!extendsAccount) extendsAccount = match[1];\n if (!extendsGateway) extendsGateway = match[2];\n }\n }\n\n if (!input.noInteractive) {\n const prompted = await promptInitOptions({\n extendsAccount,\n extendsGateway,\n extends: input.extends,\n directory,\n account,\n domain,\n plugins,\n withHost,\n });\n extendsAccount = prompted.extendsAccount;\n extendsGateway = prompted.extendsGateway;\n directory = prompted.directory;\n account = prompted.account;\n domain = prompted.domain;\n withHost = prompted.withHost;\n plugins = prompted.plugins;\n }\n\n extendsAccount = extendsAccount || \"dev.everything.near\";\n extendsGateway = extendsGateway || \"everything.dev\";\n directory = directory || domain || extendsGateway;\n plugins = plugins?.length ? plugins : [\"_template\"];\n\n try {\n await fetchParentConfig(extendsAccount, extendsGateway);\n } catch {\n return {\n status: \"error\" as const,\n directory,\n extendsAccount,\n extendsGateway,\n account,\n domain,\n extends: `bos://${extendsAccount}/${extendsGateway}`,\n plugins: plugins ?? [],\n filesCopied: 0,\n error: `No config found at bos://${extendsAccount}/${extendsGateway} — are you sure this is the right parent?`,\n };\n }\n\n const { sourceDir, parentConfig, cleanup } = await resolveSourceDir({\n extendsAccount,\n extendsGateway,\n source: input.source,\n });\n\n try {\n const patterns = await readTemplatekeep(sourceDir);\n if (patterns.length === 0) {\n return {\n status: \"error\" as const,\n directory,\n extendsAccount,\n extendsGateway,\n account,\n domain,\n extends: `bos://${extendsAccount}/${extendsGateway}`,\n plugins: plugins ?? [],\n filesCopied: 0,\n error: \"No .templatekeep found in template source\",\n };\n }\n\n const pluginRoutes: Record<string, string[]> = {};\n if (parentConfig.plugins) {\n for (const [key, ref] of Object.entries(parentConfig.plugins)) {\n if (ref.routes && ref.routes.length > 0) {\n pluginRoutes[key] = ref.routes;\n }\n }\n }\n\n const s = p.spinner();\n s.start(\"Setting up project\");\n\n const filesCopied = await copyFilteredFiles(sourceDir, directory, patterns, {\n withHost,\n plugins,\n pluginRoutes,\n });\n\n await personalizeConfig(directory, {\n extendsAccount,\n extendsGateway,\n account: account || extendsAccount,\n domain: domain || extendsGateway,\n plugins,\n pluginRoutes,\n workspaceOpts: { sourceDir },\n });\n\n await writeInitSnapshot(directory, extendsAccount, extendsGateway, sourceDir, patterns, {\n withHost,\n plugins,\n pluginRoutes,\n });\n\n if (!input.noInstall) {\n await runBunInstall(directory);\n }\n\n ensureEnvFile(directory);\n\n s.stop(\"Project initialized\");\n\n return {\n status: \"initialized\" as const,\n directory,\n extendsAccount,\n extendsGateway,\n account,\n domain,\n extends: `bos://${extendsAccount}/${extendsGateway}`,\n plugins,\n filesCopied,\n };\n } finally {\n await cleanup();\n }\n } catch (error) {\n return {\n status: \"error\" as const,\n directory: input.directory ?? \"\",\n extendsAccount: input.extendsAccount ?? \"\",\n extendsGateway: input.extendsGateway ?? \"\",\n account: input.account,\n domain: input.domain,\n extends:\n input.extendsAccount && input.extendsGateway\n ? `bos://${input.extendsAccount}/${input.extendsGateway}`\n : \"\",\n plugins: input.plugins ?? [],\n filesCopied: 0,\n error: error instanceof Error ? error.message : \"Unknown error\",\n };\n }\n }),\n\n sync: builder.sync.handler(async ({ input }: { input: SyncOptions }) => {\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 return await syncTemplate(projectDir, input);\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 }: { input: UpgradeOptions }) => {\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 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});\n\nfunction extractTransactionHash(error: unknown) {\n const message = error instanceof Error ? error.message : String(error);\n const match =\n message.match(/Transaction ID:\\s*([A-Za-z0-9]+)/i) ||\n message.match(/([A-HJ-NP-Za-km-z1-9]{43,44})/);\n\n return match?.[1];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAsEA,SAAS,cAAc,WAAyB;CAC9C,MAAM,UAAU,KAAK,WAAW,OAAO;CACvC,MAAM,cAAc,KAAK,WAAW,eAAe;AAEnD,KAAI,WAAW,QAAQ,CAAE;AAEzB,KAAI,CAAC,WAAW,YAAY,CAAE;CAG9B,MAAM,QADU,aAAa,aAAa,QAAQ,CAC5B,MAAM,KAAK;CAEjC,MAAM,SAAS,YAAY,GAAG,C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jD;;IAEH;EAEF,QAAQ,QAAQ,OAAO,QAAQ,YAAY;AACzC,OAAI;IACF,MAAM,aAAa,gBAAgB;AACnC,QAAI,CAAC,WACH,QAAO;KACL,QAAQ;KACR,UAAU,EAAE;KACZ,SAAS;KACT,OAAO;KACR;AAIH,WAAO,MAAM,UADM,QAAQ,QAAQ,WAAW,CAAC,CACb;YAC3B,OAAO;AACd,WAAO;KACL,QAAQ;KACR,UAAU,EAAE;KACZ,SAAS;KACT,OAAO,iBAAiB,QAAQ,MAAM,UAAU;KACjD;;IAEH;EACH;CACF,CAAC;AAEF,SAAS,uBAAuB,OAAgB;CAC9C,MAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM;AAKtE,SAHE,QAAQ,MAAM,oCAAoC,IAClD,QAAQ,MAAM,gCAAgC,IAEjC"}
1
+ {"version":3,"file":"plugin.mjs","names":[],"sources":["../src/plugin.ts"],"sourcesContent":["import { randomBytes } from \"node:crypto\";\nimport { existsSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { basename, dirname, join, resolve } from \"node:path\";\nimport * as p from \"@clack/prompts\";\nimport { Effect } from \"effect\";\nimport { syncApiContractBridge } from \"./api-contract\";\nimport { buildRuntimeConfig, detectLocalPackages, prepareDevelopmentRuntimeConfig } from \"./app\";\nimport {\n copyFilteredFiles,\n fetchParentConfig,\n personalizeConfig,\n readTemplatekeep,\n resolveSourceDir,\n runBunInstall,\n writeInitSnapshot,\n} from \"./cli/init\";\nimport { promptInitOptions } from \"./cli/prompts\";\nimport { getStatus } from \"./cli/status\";\nimport { syncTemplate } from \"./cli/sync\";\nimport { upgradeTemplate } from \"./cli/upgrade\";\nimport {\n buildRuntimePluginsForConfig,\n findConfigPath,\n getHostDevelopmentPort,\n getProjectRoot,\n loadConfig,\n resolveLocalDevelopmentPath,\n} from \"./config\";\nimport {\n type BosConfigResult,\n type BuildOptions,\n bosContract,\n type DevOptions,\n type InitOptions,\n type KeyPublishOptions,\n type PluginAddOptions,\n type PluginListResult,\n type PluginPublishOptions,\n type PluginRemoveOptions,\n type PublishOptions,\n type StartOptions,\n type SyncOptions,\n type UpgradeOptions,\n} from \"./contract\";\nimport { devApp, startApp } from \"./dev-session\";\nimport {\n buildRegistryConfigUrl,\n buildRegistryConfigUrlForNetwork,\n fetchBosConfigFromFastKv,\n fetchPluginFromRegistry,\n fetchRemotePluginManifest,\n getRegistryNamespaceForAccount,\n getRegistryNamespaceForNetwork,\n type PluginManifest,\n parsePluginBosUrl,\n} from \"./fastkv\";\nimport { computeSriHashForUrl } from \"./integrity\";\nimport { addFunctionCallAccessKey, ensureNearCli, executeTransaction } from \"./near-cli\";\nimport { getNetworkIdForAccount } from \"./network\";\nimport { createPlugin, z } from \"./sdk\";\nimport {\n type AppOrchestrator,\n buildDescription,\n buildServiceDescriptorMap,\n} from \"./service-descriptor\";\nimport { syncAndGenerateSharedUi } from \"./shared\";\nimport type { BosConfig, RuntimeConfig, SourceMode } from \"./types\";\nimport { run } from \"./utils/run\";\nimport { colors } from \"./utils/theme\";\n\nfunction ensureEnvFile(configDir: string): void {\n const envPath = join(configDir, \".env\");\n const examplePath = join(configDir, \".env.example\");\n\n if (existsSync(envPath)) return;\n\n if (!existsSync(examplePath)) return;\n\n const content = readFileSync(examplePath, \"utf-8\");\n const lines = content.split(\"\\n\");\n\n const secret = randomBytes(32).toString(\"base64url\");\n\n const updated = lines\n .map((line) => {\n if (/^BETTER_AUTH_SECRET=/.test(line)) {\n return `BETTER_AUTH_SECRET=${secret}`;\n }\n if (/^BETTER_AUTH_URL=/.test(line)) {\n return `BETTER_AUTH_URL=http://localhost:3000`;\n }\n return line;\n })\n .join(\"\\n\");\n\n writeFileSync(envPath, updated);\n console.log(`[CLI] Created .env from .env.example with generated BETTER_AUTH_SECRET`);\n}\n\nconst buildCommands: Record<string, { cmd: string; args: string[] }> = {\n host: { cmd: \"bun\", args: [\"run\", \"build\"] },\n ui: { cmd: \"bun\", args: [\"run\", \"build\"] },\n api: { cmd: \"bun\", args: [\"run\", \"build\"] },\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(bosConfig: BosConfig | null): BosConfigResult {\n const packages = bosConfig ? Object.keys(bosConfig.app) : [];\n const remotes = packages.filter((name) => name !== \"host\");\n\n return {\n config: bosConfig,\n packages,\n remotes,\n };\n}\n\ntype WorkspaceTarget = {\n key: string;\n kind: \"app\" | \"plugin\";\n path: string;\n};\n\nfunction resolveWorkspaceTarget(\n key: string,\n bosConfig: BosConfig | null,\n runtimeConfig: RuntimeConfig | null,\n configDir: string,\n): WorkspaceTarget | null {\n if (bosConfig?.app && key in bosConfig.app) {\n const appEntry = (bosConfig.app as Record<string, { development?: string }>)[key];\n const devPath = resolveLocalDevelopmentPath(appEntry?.development, configDir);\n if (devPath) {\n return {\n key,\n kind: \"app\",\n path: devPath,\n };\n }\n return {\n key,\n kind: \"app\",\n path: `${configDir}/${key}`,\n };\n }\n\n const runtimePlugin = runtimeConfig?.plugins?.[key];\n const pluginPath =\n runtimePlugin?.localPath ??\n resolveLocalDevelopmentPath(bosConfig?.plugins?.[key]?.development, configDir);\n if (pluginPath) {\n return {\n key,\n kind: \"plugin\",\n path: pluginPath,\n };\n }\n\n return null;\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 source = attachment.development ?? attachment.production;\n if (!source?.startsWith(\"local:\")) {\n return null;\n }\n\n return join(configDir, source.slice(\"local:\".length));\n}\n\nasync function saveBosConfig(configDir: string, config: BosConfig): Promise<void> {\n const filePath = join(configDir, \"bos.config.json\");\n const next = `${JSON.stringify(config, null, 2)}\\n`;\n try {\n if (readFileSync(filePath, \"utf8\") === next) return;\n } catch {\n // file does not exist yet\n }\n\n writeFileSync(filePath, next);\n}\n\nfunction listPluginAttachments(config: BosConfig | null) {\n return (Object.entries(config?.plugins ?? {}) as Array<[string, PluginAttachmentConfig]>)\n .map(([key, attachment]) => ({\n key,\n development: attachment.development,\n production: attachment.production,\n localPath: attachment.development?.startsWith(\"local:\")\n ? attachment.development.slice(\"local:\".length)\n : undefined,\n source: attachment.development?.startsWith(\"local:\")\n ? (\"local\" as const)\n : (\"remote\" as const),\n integrity: attachment.integrity,\n version: attachment.version,\n name: attachment.name,\n }))\n .sort((a, b) => a.key.localeCompare(b.key));\n}\n\nasync function refreshApiContractBridge(configDir: string): Promise<void> {\n const refreshed = await loadConfig({ cwd: configDir, env: \"development\" });\n if (!refreshed) return;\n\n await syncApiContractBridge({\n configDir,\n runtimeConfig: refreshed.runtime,\n apiBaseUrl: refreshed.runtime.api.url,\n });\n}\n\nfunction extractPublishedUrl(output: string): string | null {\n const match = output.match(/https?:\\/\\/[^\\s\"'<>]+/g);\n if (!match || match.length === 0) return null;\n return match[match.length - 1] ?? null;\n}\n\nasync function buildEveryPluginQuietly(cwd: string) {\n const packageDir = `${cwd}/packages/every-plugin`;\n const packageExists = await Bun.file(`${packageDir}/package.json`).exists();\n if (!packageExists) {\n return;\n }\n\n const distPath = `${cwd}/packages/every-plugin/dist/build/rspack/plugin.mjs`;\n const distExists = await Bun.file(distPath).exists();\n\n if (distExists) {\n return;\n }\n\n const result = (await run(\"bun\", [\"run\", \"--cwd\", \"packages/every-plugin\", \"build\"], {\n cwd,\n capture: true,\n })) as { stdout: string; stderr: string; exitCode: number };\n\n if (result.exitCode === 0) {\n console.log(\"[build:ssr] build succeeded\");\n return;\n }\n\n if (result.stdout.trim()) {\n process.stdout.write(result.stdout);\n }\n\n if (result.stderr.trim()) {\n process.stderr.write(result.stderr);\n }\n\n throw new Error(\n `bun run --cwd packages/every-plugin build failed with exit code ${result.exitCode}`,\n );\n}\n\nasync function buildEverythingDevQuietly(cwd: string) {\n const packageDir = `${cwd}/packages/everything-dev`;\n const packageExists = await Bun.file(`${packageDir}/package.json`).exists();\n if (!packageExists) {\n return;\n }\n\n const distPath = `${cwd}/packages/everything-dev/dist/index.mjs`;\n const distExists = await Bun.file(distPath).exists();\n\n if (distExists) {\n return;\n }\n\n const result = (await run(\"bun\", [\"run\", \"--cwd\", \"packages/everything-dev\", \"build\"], {\n cwd,\n capture: true,\n })) as { stdout: string; stderr: string; exitCode: number };\n\n if (result.exitCode === 0) {\n console.log(\"[everything-dev] build succeeded\");\n return;\n }\n\n if (result.stdout.trim()) {\n process.stdout.write(result.stdout);\n }\n\n if (result.stderr.trim()) {\n process.stderr.write(result.stderr);\n }\n\n throw new Error(\n `bun run --cwd packages/everything-dev build failed with exit code ${result.exitCode}`,\n );\n}\n\nasync function fetchPublishedConfig(\n accountId: string,\n gatewayId: string,\n): Promise<BosConfig | null> {\n try {\n return await fetchBosConfigFromFastKv<BosConfig>(`bos://${accountId}/${gatewayId}`);\n } catch {\n return null;\n }\n}\n\nfunction selectWorkspaceTargets(packages: string, bosConfig: BosConfig | null): string[] {\n const allPackages = [\n ...Object.keys(bosConfig?.app ?? {}),\n ...Object.keys(bosConfig?.plugins ?? {}),\n ];\n if (packages === \"all\") {\n return allPackages;\n }\n\n return packages\n .split(\",\")\n .map((pkg) => pkg.trim())\n .filter((pkg) => allPackages.includes(pkg));\n}\n\nasync function buildWorkspaceTargets(opts: {\n configDir: string;\n bosConfig: BosConfig | null;\n runtimeConfig: RuntimeConfig | null;\n targets: string[];\n deploy: boolean;\n}): Promise<{ built: string[]; skipped: string[] }> {\n const existing: WorkspaceTarget[] = [];\n const skipped: string[] = [];\n\n for (const target of opts.targets) {\n const resolved = resolveWorkspaceTarget(\n target,\n opts.bosConfig,\n opts.runtimeConfig,\n opts.configDir,\n );\n if (!resolved) {\n skipped.push(target);\n continue;\n }\n\n const exists = await Bun.file(`${resolved.path}/package.json`).exists();\n if (exists) existing.push(resolved);\n else skipped.push(target);\n }\n\n if (existing.length === 0) {\n return { built: [], skipped };\n }\n\n const sharedSync = await syncAndGenerateSharedUi({\n configDir: opts.configDir,\n hostMode: \"local\",\n bosConfig: opts.bosConfig ?? undefined,\n });\n if (sharedSync.catalogChanged) {\n await run(\"bun\", [\"install\"], { cwd: opts.configDir });\n }\n\n if (existing.some((entry) => entry.key === \"api\")) {\n await buildEveryPluginQuietly(opts.configDir);\n }\n\n await buildEverythingDevQuietly(opts.configDir);\n\n const env: Record<string, string> = {\n ...process.env,\n NODE_ENV: opts.deploy ? \"production\" : \"development\",\n };\n if (opts.deploy) {\n env.DEPLOY = \"true\";\n } else {\n delete env.DEPLOY;\n }\n\n const orderedExisting = opts.deploy\n ? [\n ...existing.filter((entry) => entry.kind === \"app\" && entry.key !== \"host\"),\n ...existing.filter((entry) => entry.kind === \"plugin\"),\n ...existing.filter((entry) => entry.kind === \"app\" && entry.key === \"host\"),\n ]\n : existing;\n const built: string[] = [];\n\n for (const resolved of orderedExisting) {\n const pkgJson = JSON.parse(await Bun.file(`${resolved.path}/package.json`).text()) as {\n scripts?: Record<string, string>;\n };\n const shouldDeployScript = opts.deploy && pkgJson.scripts?.deploy;\n const buildConfig = shouldDeployScript\n ? { cmd: \"bun\", args: [\"run\", \"deploy\"] }\n : (buildCommands[resolved.key] ?? { cmd: \"bun\", args: [\"run\", \"build\"] });\n\n await run(buildConfig.cmd, buildConfig.args, {\n cwd: resolved.path,\n env,\n });\n built.push(resolved.key);\n }\n\n return { built, skipped };\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: any) =>\n Effect.promise(async () => {\n const configResult = await loadConfig({ 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: BosDeps, builder: any) => ({\n config: builder.config.handler(async () => buildConfigResult(deps.bosConfig)),\n\n pluginAdd: builder.pluginAdd.handler(async ({ input }: { input: PluginAddOptions }) => {\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 pluginRef = parsePluginBosUrl(input.source);\n let production = input.production ?? input.source;\n let integrity: string | undefined;\n let version: string | undefined;\n let name: string | undefined;\n\n if (pluginRef) {\n try {\n const entry = await fetchPluginFromRegistry(pluginRef.accountId, pluginRef.pluginName);\n if (!entry) {\n return {\n status: \"error\" as const,\n key: \"\",\n error: `Plugin not found in registry: bos://${pluginRef.accountId}/plugins/${pluginRef.pluginName}`,\n };\n }\n\n const manifest = entry.manifest;\n if (\n manifest.schemaVersion !== 1 ||\n manifest.kind !== \"every-plugin/manifest\" ||\n !manifest.plugin?.name ||\n !manifest.plugin?.version ||\n !manifest.runtime?.remoteEntry\n ) {\n return {\n status: \"error\" as const,\n key: \"\",\n error: `Invalid plugin manifest for bos://${pluginRef.accountId}/plugins/${pluginRef.pluginName}`,\n };\n }\n\n production = entry.metadata.cdnUrl || input.production || input.source;\n name = manifest.plugin.name;\n version = manifest.plugin.version;\n } catch (error) {\n return {\n status: \"error\" as const,\n key: \"\",\n error: `Failed to resolve plugin from registry: ${error instanceof Error ? error.message : error}`,\n };\n }\n }\n\n if (!input.source.startsWith(\"local:\") && !pluginRef && production.startsWith(\"https://\")) {\n try {\n const manifest = await fetchRemotePluginManifest(production);\n if (manifest) {\n name = manifest.plugin.name;\n version = manifest.plugin.version;\n }\n } catch {\n console.warn(`[plugin add] Could not fetch manifest from ${production}`);\n }\n }\n\n if (!input.source.startsWith(\"local:\") && production.startsWith(\"https://\")) {\n try {\n const computed = await computeSriHashForUrl(production);\n if (computed) integrity = computed;\n } catch {\n console.warn(`[plugin add] Could not compute integrity for ${production}`);\n }\n }\n\n const key = sanitizePluginKey(\n input.as ?? (pluginRef ? pluginRef.pluginName : defaultPluginKey(input.source)),\n );\n const existing = deps.bosConfig.plugins?.[key];\n const nextPlugins = { ...(deps.bosConfig.plugins ?? {}) };\n\n nextPlugins[key] = input.source.startsWith(\"local:\")\n ? {\n ...(existing ?? {}),\n development: input.source,\n production: input.production ?? existing?.production,\n }\n : {\n ...(existing ?? {}),\n production,\n ...(integrity ? { integrity } : {}),\n ...(name ? { name } : {}),\n ...(version ? { version } : {}),\n };\n\n deps.bosConfig = {\n ...deps.bosConfig,\n plugins: nextPlugins,\n };\n\n await saveBosConfig(deps.configDir, deps.bosConfig);\n await refreshApiContractBridge(deps.configDir);\n\n return {\n status: \"added\" as const,\n key,\n development: deps.bosConfig.plugins?.[key]?.development,\n production: deps.bosConfig.plugins?.[key]?.production,\n integrity,\n version,\n };\n }),\n\n pluginRemove: builder.pluginRemove.handler(\n async ({ input }: { input: PluginRemoveOptions }) => {\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 refreshApiContractBridge(deps.configDir);\n\n return {\n status: \"removed\" as const,\n key: input.key,\n };\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(\n async ({ input }: { input: PluginPublishOptions }) => {\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 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 Bun.file(pkgPath).exists())) {\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 Bun.file(pkgPath).json()) as {\n scripts?: Record<string, string>;\n name?: string;\n version?: string;\n };\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 let publishedUrl = extractPublishedUrl(`${stdout}\\n${stderr}`);\n\n let manifest: PluginManifest | null = null;\n if (publishedUrl) {\n manifest = await fetchRemotePluginManifest(publishedUrl);\n } else if (attachment.production) {\n manifest = await fetchRemotePluginManifest(attachment.production);\n if (manifest) {\n publishedUrl = attachment.production;\n }\n }\n\n const integrity = publishedUrl ? await computeSriHashForUrl(publishedUrl) : null;\n const version = manifest?.plugin.version ?? pkgJson.version;\n\n if (publishedUrl) {\n deps.bosConfig = {\n ...deps.bosConfig,\n plugins: {\n ...(deps.bosConfig.plugins ?? {}),\n [input.key]: {\n ...(deps.bosConfig.plugins?.[input.key] ?? {}),\n production: publishedUrl,\n ...(integrity ? { integrity } : {}),\n ...(manifest?.plugin.name ? { name: manifest.plugin.name } : {}),\n ...(version ? { version } : {}),\n },\n },\n };\n await saveBosConfig(deps.configDir, deps.bosConfig);\n\n const account = deps.bosConfig.account;\n const network = getNetworkIdForAccount(account);\n if (manifest && version) {\n try {\n const registryEntries: Record<string, string> = {\n [`plugins/${account}/${input.key}/manifest.json`]: JSON.stringify(manifest),\n [`plugins/${account}/${input.key}/metadata`]: JSON.stringify({\n title: null,\n description: null,\n repoUrl: deps.bosConfig.repository ?? null,\n version,\n publishedAt: new Date().toISOString(),\n cdnUrl: publishedUrl,\n integrity,\n }),\n [`plugins/${account}/${input.key}/versions/${version}/manifest.json`]:\n JSON.stringify(manifest),\n };\n const payload = JSON.stringify(registryEntries);\n const argsBase64 = Buffer.from(payload).toString(\"base64\");\n const privateKey = process.env.NEAR_PRIVATE_KEY || process.env.BOS_NEAR_PRIVATE_KEY;\n\n await Effect.runPromise(ensureNearCli);\n try {\n await Effect.runPromise(\n executeTransaction({\n account,\n contract: getRegistryNamespaceForNetwork(network),\n method: \"__fastdata_kv\",\n argsBase64,\n network,\n privateKey,\n gas: \"50Tgas\",\n deposit: \"0NEAR\",\n }),\n );\n } catch (registryError) {\n const txHash = extractTransactionHash(registryError);\n if (!txHash) {\n console.warn(\n `[publish] Plugin registry write failed: ${registryError instanceof Error ? registryError.message : registryError}`,\n );\n }\n }\n } catch (registryError) {\n console.warn(\n `[publish] Plugin registry write skipped: ${registryError instanceof Error ? registryError.message : registryError}`,\n );\n }\n }\n\n await refreshApiContractBridge(deps.configDir);\n }\n\n return {\n status: \"published\" as const,\n key: input.key,\n path: localPath,\n script,\n production: publishedUrl ?? attachment.production,\n integrity: integrity ?? undefined,\n version: version ?? undefined,\n };\n },\n ),\n\n dev: builder.dev.handler(async ({ input }: { input: DevOptions }) => {\n ensureEnvFile(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 as string, \"local\")\n : \"remote\";\n const uiSource: SourceMode = localPackages.includes(\"ui\")\n ? parseSourceMode(input.ui as string, \"local\")\n : \"remote\";\n const apiSource: SourceMode = localPackages.includes(\"api\")\n ? parseSourceMode(input.api as string, \"local\")\n : \"remote\";\n const authSource: SourceMode = localPackages.includes(\"auth\")\n ? parseSourceMode(input.auth as string, \"local\")\n : \"remote\";\n const ssr = input.ssr ?? false;\n const proxy = input.proxy ?? false;\n\n const sharedSync = await syncAndGenerateSharedUi({\n configDir: deps.configDir,\n hostMode: hostSource,\n bosConfig: deps.bosConfig ?? undefined,\n });\n if (sharedSync.catalogChanged) {\n await run(\"bun\", [\"install\"], { cwd: deps.configDir });\n }\n if (\n (apiSource === \"local\" && !proxy) ||\n localPackages.some((pkg) => pkg.startsWith(\"plugin:\"))\n ) {\n await buildEveryPluginQuietly(deps.configDir);\n }\n\n await buildEverythingDevQuietly(deps.configDir);\n\n const refreshed = await loadConfig({ cwd: deps.configDir });\n deps.bosConfig = refreshed?.config ?? deps.bosConfig;\n deps.runtimeConfig = refreshed?.runtime ?? deps.runtimeConfig;\n\n if (!deps.bosConfig) {\n return {\n status: \"error\" as const,\n description: \"No bos.config.json found\",\n processes: [],\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 };\n }\n\n const hostPort = input.port ?? getHostDevelopmentPort(deps.bosConfig.app.host.development);\n const developmentRuntime = buildRuntimeConfig(deps.bosConfig, {\n uiSource,\n apiSource,\n authSource,\n hostSource,\n env: \"development\",\n plugins: deps.runtimeConfig?.plugins,\n });\n const runtimeConfig = await prepareDevelopmentRuntimeConfig(developmentRuntime, {\n hostPort,\n ssr,\n });\n\n const services = buildServiceDescriptorMap(runtimeConfig, { ssr, proxy });\n const packages = [...services.keys()];\n const displayEnv: Record<string, string> = {};\n const apiDescriptor = services.get(\"api\");\n if (apiDescriptor?.proxy) {\n const proxyUrl = resolveProxyUrl(deps.bosConfig);\n if (proxyUrl) displayEnv.API_PROXY = proxyUrl;\n }\n\n await syncApiContractBridge({\n configDir: deps.configDir,\n runtimeConfig: runtimeConfig,\n apiBaseUrl: runtimeConfig.api.url,\n });\n\n const orchestrator: AppOrchestrator = {\n packages,\n env: displayEnv,\n description: buildDescription(services),\n port: runtimeConfig.host.port,\n interactive: input.interactive,\n };\n\n devApp(orchestrator, services, runtimeConfig);\n\n return {\n status: \"started\" as const,\n description: orchestrator.description,\n processes: packages,\n };\n }),\n\n start: builder.start.handler(async ({ input }: { input: StartOptions }) => {\n ensureEnvFile(deps.configDir);\n\n let remoteConfig: BosConfig | null = null;\n\n if (input.account && input.domain) {\n remoteConfig = await fetchPublishedConfig(input.account, input.domain);\n if (!remoteConfig) {\n return {\n status: \"error\" as const,\n url: \"\",\n };\n }\n }\n\n const config = remoteConfig || deps.bosConfig;\n if (!config) {\n return {\n status: \"error\" as const,\n url: \"\",\n };\n }\n\n const port = input.port ?? getHostDevelopmentPort(config.app.host.development);\n const isStaging = input.env === \"staging\";\n const runtimePlugins = remoteConfig\n ? await buildRuntimePluginsForConfig(config, deps.configDir, \"production\")\n : deps.runtimeConfig?.plugins;\n const runtimeConfig = buildRuntimeConfig(config, {\n uiSource: \"remote\",\n apiSource: \"remote\",\n authSource: \"remote\",\n hostSource: \"remote\",\n env: \"production\",\n plugins: runtimePlugins,\n });\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 defaultOrigin = `https://${config.domain}`;\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.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 services = buildServiceDescriptorMap(runtimeConfig);\n\n await syncApiContractBridge({\n configDir: deps.configDir,\n runtimeConfig: runtimeConfig,\n apiBaseUrl: runtimeConfig.api.url,\n });\n\n const stagingEnvVars: Record<string, string> = isStaging\n ? { GATEWAY_DOMAIN: config.staging?.domain ?? config.domain ?? \"\" }\n : {};\n\n const configSource = remoteConfig\n ? `bos://${input.account}/${input.domain}`\n : (findConfigPath() ?? \"bos.config.json\");\n\n const configSourceHttp =\n remoteConfig && input.account && input.domain\n ? buildRegistryConfigUrl(input.account, input.domain)\n : undefined;\n\n const summaryLines: string[] = [\"\", ` ${colors.dim(\"Config Source:\")} ${configSource}`];\n if (configSourceHttp) {\n summaryLines.push(` ${colors.dim(configSourceHttp)}`);\n }\n summaryLines.push(\n ` ${colors.dim(\"Account:\")} ${config.account}`,\n ` ${colors.dim(\"Domain:\")} ${config.domain ?? \"not configured\"}`,\n \"\",\n ` ${colors.dim(\"Modules:\")}`,\n ` ${colors.dim(\"HOST\")} → ${runtimeConfig.host.remoteUrl ?? runtimeConfig.host.url ?? \"local\"}`,\n ` ${colors.dim(\"UI\")} → ${runtimeConfig.ui.url ?? \"local\"}`,\n ` ${colors.dim(\"API\")} → ${runtimeConfig.api.url ?? \"local\"}`,\n );\n if (runtimeConfig.auth) {\n summaryLines.push(` ${colors.dim(\"AUTH\")} → ${runtimeConfig.auth.url ?? \"local\"}`);\n }\n if (warnings.length > 0) {\n summaryLines.push(\"\");\n for (const w of warnings) {\n summaryLines.push(` ${colors.yellow(w)}`);\n }\n }\n summaryLines.push(\"\");\n console.log(summaryLines.join(\"\\n\"));\n\n const orchestrator: AppOrchestrator = {\n packages: [\"host\"],\n env: {\n NODE_ENV: \"production\",\n ...productionEnv,\n ...stagingEnvVars,\n },\n description: `${isStaging ? \"Staging\" : \"Production\"} Mode (${config.account})`,\n port,\n interactive: input.interactive,\n noLogs: true,\n };\n\n startApp(orchestrator, services, runtimeConfig);\n return {\n status: \"running\" as const,\n url: `http://localhost:${port}`,\n };\n }),\n\n build: builder.build.handler(async ({ input }: { input: BuildOptions }) => {\n if (!deps.bosConfig) {\n return {\n status: \"error\" as const,\n built: [],\n skipped: [],\n };\n }\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 const runtimeConfig = 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: \"development\",\n plugins: deps.runtimeConfig?.plugins,\n });\n\n await syncApiContractBridge({\n configDir: deps.configDir,\n runtimeConfig,\n apiBaseUrl: runtimeConfig.api.url,\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 }: { input: PublishOptions }) => {\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 account = deps.bosConfig.account;\n const gateway = deps.bosConfig.domain;\n if (!gateway) {\n return {\n status: \"error\" as const,\n registryUrl: \"\",\n error: \"bos.config.json must define domain to publish\",\n };\n }\n\n const network = input.network ?? getNetworkIdForAccount(account);\n const bosUrl = `bos://${account}/${gateway}`;\n const registryUrl = buildRegistryConfigUrlForNetwork(network, account, gateway);\n const targets = selectWorkspaceTargets(input.packages, deps.bosConfig);\n\n let publishConfig = deps.bosConfig;\n let built: string[] | undefined;\n let skipped: string[] | undefined;\n\n if (input.dryRun) {\n return {\n status: \"dry-run\" as const,\n registryUrl,\n built,\n skipped,\n };\n }\n\n if (input.deploy) {\n const result = await buildWorkspaceTargets({\n configDir: deps.configDir,\n bosConfig: deps.bosConfig,\n runtimeConfig: deps.runtimeConfig,\n targets,\n deploy: true,\n });\n built = result.built;\n skipped = result.skipped;\n\n const refreshed = await loadConfig({ cwd: deps.configDir });\n if (refreshed?.config) {\n deps.bosConfig = refreshed.config;\n deps.runtimeConfig = refreshed.runtime;\n publishConfig = refreshed.config;\n }\n }\n\n const payload = JSON.stringify({\n [`apps/${account}/${gateway}/bos.config.json`]: JSON.stringify(publishConfig),\n });\n const argsBase64 = Buffer.from(payload).toString(\"base64\");\n const privateKey =\n input.privateKey || process.env.NEAR_PRIVATE_KEY || process.env.BOS_NEAR_PRIVATE_KEY;\n\n try {\n await Effect.runPromise(ensureNearCli);\n let txHash: string | undefined;\n\n try {\n const tx = await Effect.runPromise(\n executeTransaction({\n account,\n contract: getRegistryNamespaceForNetwork(network),\n method: \"__fastdata_kv\",\n argsBase64,\n network,\n privateKey,\n gas: \"300Tgas\",\n deposit: \"0NEAR\",\n }),\n );\n txHash = tx.txHash;\n } catch (error) {\n txHash = extractTransactionHash(error);\n\n if (!txHash) {\n throw error;\n }\n\n try {\n const verifiedConfig = await fetchBosConfigFromFastKv<BosConfig>(bosUrl);\n if (JSON.stringify(verifiedConfig) !== JSON.stringify(publishConfig)) {\n throw error;\n }\n } catch {\n // Config may not exist yet on first publish or propagation delay;\n // a valid txHash is sufficient proof the transaction was submitted.\n }\n }\n\n return {\n status: \"published\" as const,\n registryUrl,\n txHash,\n built,\n skipped,\n };\n } catch (error) {\n return {\n status: \"error\" as const,\n registryUrl,\n error: error instanceof Error ? error.message : \"Unknown error\",\n built,\n skipped,\n };\n }\n }),\n\n keyPublish: builder.keyPublish.handler(async ({ input }: { input: KeyPublishOptions }) => {\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 const keyPair = await addFunctionCallAccessKey({\n account,\n contract,\n allowance: input.allowance,\n functionNames: PUBLISH_FUNCTION_NAMES,\n network,\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 }: { input: InitOptions }) => {\n try {\n let extendsAccount = input.extendsAccount;\n let extendsGateway = input.extendsGateway;\n let directory = input.directory;\n let account = input.account;\n let domain = input.domain;\n let withHost = input.withHost;\n let plugins = input.plugins;\n\n if (input.extends) {\n const match = input.extends.match(/^(?:bos:\\/\\/)?([^/]+)\\/(.+)$/);\n if (match) {\n if (!extendsAccount) extendsAccount = match[1];\n if (!extendsGateway) extendsGateway = match[2];\n }\n }\n\n if (!input.noInteractive) {\n const prompted = await promptInitOptions({\n extendsAccount,\n extendsGateway,\n extends: input.extends,\n directory,\n account,\n domain,\n plugins,\n withHost,\n });\n extendsAccount = prompted.extendsAccount;\n extendsGateway = prompted.extendsGateway;\n directory = prompted.directory;\n account = prompted.account;\n domain = prompted.domain;\n withHost = prompted.withHost;\n plugins = prompted.plugins;\n }\n\n extendsAccount = extendsAccount || \"dev.everything.near\";\n extendsGateway = extendsGateway || \"everything.dev\";\n directory = directory || domain || extendsGateway;\n plugins = plugins?.length ? plugins : [\"_template\"];\n\n try {\n await fetchParentConfig(extendsAccount, extendsGateway);\n } catch {\n return {\n status: \"error\" as const,\n directory,\n extendsAccount,\n extendsGateway,\n account,\n domain,\n extends: `bos://${extendsAccount}/${extendsGateway}`,\n plugins: plugins ?? [],\n filesCopied: 0,\n error: `No config found at bos://${extendsAccount}/${extendsGateway} — are you sure this is the right parent?`,\n };\n }\n\n const { sourceDir, parentConfig, cleanup } = await resolveSourceDir({\n extendsAccount,\n extendsGateway,\n source: input.source,\n });\n\n try {\n const patterns = await readTemplatekeep(sourceDir);\n if (patterns.length === 0) {\n return {\n status: \"error\" as const,\n directory,\n extendsAccount,\n extendsGateway,\n account,\n domain,\n extends: `bos://${extendsAccount}/${extendsGateway}`,\n plugins: plugins ?? [],\n filesCopied: 0,\n error: \"No .templatekeep found in template source\",\n };\n }\n\n const pluginRoutes: Record<string, string[]> = {};\n if (parentConfig.plugins) {\n for (const [key, ref] of Object.entries(parentConfig.plugins)) {\n if (ref.routes && ref.routes.length > 0) {\n pluginRoutes[key] = ref.routes;\n }\n }\n }\n\n const s = p.spinner();\n s.start(\"Setting up project\");\n\n const filesCopied = await copyFilteredFiles(sourceDir, directory, patterns, {\n withHost,\n plugins,\n pluginRoutes,\n });\n\n await personalizeConfig(directory, {\n extendsAccount,\n extendsGateway,\n account: account || extendsAccount,\n domain: domain || extendsGateway,\n plugins,\n pluginRoutes,\n workspaceOpts: { sourceDir },\n });\n\n await writeInitSnapshot(directory, extendsAccount, extendsGateway, sourceDir, patterns, {\n withHost,\n plugins,\n pluginRoutes,\n });\n\n if (!input.noInstall) {\n await runBunInstall(directory);\n }\n\n ensureEnvFile(directory);\n\n s.stop(\"Project initialized\");\n\n return {\n status: \"initialized\" as const,\n directory,\n extendsAccount,\n extendsGateway,\n account,\n domain,\n extends: `bos://${extendsAccount}/${extendsGateway}`,\n plugins,\n filesCopied,\n };\n } finally {\n await cleanup();\n }\n } catch (error) {\n return {\n status: \"error\" as const,\n directory: input.directory ?? \"\",\n extendsAccount: input.extendsAccount ?? \"\",\n extendsGateway: input.extendsGateway ?? \"\",\n account: input.account,\n domain: input.domain,\n extends:\n input.extendsAccount && input.extendsGateway\n ? `bos://${input.extendsAccount}/${input.extendsGateway}`\n : \"\",\n plugins: input.plugins ?? [],\n filesCopied: 0,\n error: error instanceof Error ? error.message : \"Unknown error\",\n };\n }\n }),\n\n sync: builder.sync.handler(async ({ input }: { input: SyncOptions }) => {\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 return await syncTemplate(projectDir, input);\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 }: { input: UpgradeOptions }) => {\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 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});\n\nfunction extractTransactionHash(error: unknown) {\n const message = error instanceof Error ? error.message : String(error);\n const match =\n message.match(/Transaction ID:\\s*([A-Za-z0-9]+)/i) ||\n message.match(/([A-HJ-NP-Za-km-z1-9]{43,44})/);\n\n return match?.[1];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAsEA,SAAS,cAAc,WAAyB;CAC9C,MAAM,UAAU,KAAK,WAAW,OAAO;CACvC,MAAM,cAAc,KAAK,WAAW,eAAe;AAEnD,KAAI,WAAW,QAAQ,CAAE;AAEzB,KAAI,CAAC,WAAW,YAAY,CAAE;CAG9B,MAAM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AM,UAAU;KACjD;;IAEH;EAEF,QAAQ,QAAQ,OAAO,QAAQ,YAAY;AACzC,OAAI;IACF,MAAM,aAAa,gBAAgB;AACnC,QAAI,CAAC,WACH,QAAO;KACL,QAAQ;KACR,UAAU,EAAE;KACZ,SAAS;KACT,OAAO;KACR;AAIH,WAAO,MAAM,UADM,QAAQ,QAAQ,WAAW,CAAC,CACb;YAC3B,OAAO;AACd,WAAO;KACL,QAAQ;KACR,UAAU,EAAE;KACZ,SAAS;KACT,OAAO,iBAAiB,QAAQ,MAAM,UAAU;KACjD;;IAEH;EACH;CACF,CAAC;AAEF,SAAS,uBAAuB,OAAgB;CAC9C,MAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM;AAKtE,SAHE,QAAQ,MAAM,oCAAoC,IAClD,QAAQ,MAAM,gCAAgC,IAEjC"}
@@ -26,7 +26,7 @@ interface ServiceDescriptor {
26
26
  declare const ServiceDescriptorMap_base: Context.TagClass<ServiceDescriptorMap, "ServiceDescriptorMap", Map<string, ServiceDescriptor>>;
27
27
  declare class ServiceDescriptorMap extends ServiceDescriptorMap_base {}
28
28
  declare const DevRuntimeConfig_base: Context.TagClass<DevRuntimeConfig, "DevRuntimeConfig", {
29
- env: "development" | "production";
29
+ env: "production" | "development";
30
30
  account: string;
31
31
  networkId: "testnet" | "mainnet";
32
32
  host: {
@@ -26,7 +26,7 @@ interface ServiceDescriptor {
26
26
  declare const ServiceDescriptorMap_base: Context.TagClass<ServiceDescriptorMap, "ServiceDescriptorMap", Map<string, ServiceDescriptor>>;
27
27
  declare class ServiceDescriptorMap extends ServiceDescriptorMap_base {}
28
28
  declare const DevRuntimeConfig_base: Context.TagClass<DevRuntimeConfig, "DevRuntimeConfig", {
29
- env: "development" | "production";
29
+ env: "production" | "development";
30
30
  account: string;
31
31
  networkId: "testnet" | "mainnet";
32
32
  host: {
package/dist/types.d.cts CHANGED
@@ -192,8 +192,8 @@ declare const BosConfigSchema: z.ZodObject<{
192
192
  type BosConfig = z.infer<typeof BosConfigSchema>;
193
193
  declare const RuntimeConfigSchema: z.ZodObject<{
194
194
  env: z.ZodEnum<{
195
- development: "development";
196
195
  production: "production";
196
+ development: "development";
197
197
  }>;
198
198
  account: z.ZodString;
199
199
  domain: z.ZodOptional<z.ZodString>;
@@ -299,8 +299,8 @@ type RuntimeConfig = z.infer<typeof RuntimeConfigSchema>;
299
299
  declare const ClientRuntimeConfigSchema: z.ZodObject<{
300
300
  cspNonce: z.ZodOptional<z.ZodString>;
301
301
  env: z.ZodEnum<{
302
- development: "development";
303
302
  production: "production";
303
+ development: "development";
304
304
  }>;
305
305
  account: z.ZodString;
306
306
  networkId: z.ZodEnum<{
package/dist/types.d.mts CHANGED
@@ -192,8 +192,8 @@ declare const BosConfigSchema: z.ZodObject<{
192
192
  type BosConfig = z.infer<typeof BosConfigSchema>;
193
193
  declare const RuntimeConfigSchema: z.ZodObject<{
194
194
  env: z.ZodEnum<{
195
- development: "development";
196
195
  production: "production";
196
+ development: "development";
197
197
  }>;
198
198
  account: z.ZodString;
199
199
  domain: z.ZodOptional<z.ZodString>;
@@ -299,8 +299,8 @@ type RuntimeConfig = z.infer<typeof RuntimeConfigSchema>;
299
299
  declare const ClientRuntimeConfigSchema: z.ZodObject<{
300
300
  cspNonce: z.ZodOptional<z.ZodString>;
301
301
  env: z.ZodEnum<{
302
- development: "development";
303
302
  production: "production";
303
+ development: "development";
304
304
  }>;
305
305
  account: z.ZodString;
306
306
  networkId: z.ZodEnum<{
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "everything-dev",
3
- "version": "1.8.7",
3
+ "version": "1.8.8",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -83,40 +83,45 @@ export function renderStreamingView(
83
83
  const columnWidths = getColumnWidths(initialProcesses);
84
84
  const lastLogBySource = new Map<string, string>();
85
85
 
86
- console.log();
87
- console.log(colors.cyan(`${"".repeat(52)}`));
88
- console.log(` ${icons.run} ${colors.cyan(description.toUpperCase())}`);
89
- console.log(colors.cyan(`${"─".repeat(52)}`));
90
- console.log();
86
+ const headerLines: string[] = [
87
+ "",
88
+ colors.cyan(`${"─".repeat(52)}`),
89
+ ` ${icons.run} ${colors.cyan(description.toUpperCase())}`,
90
+ colors.cyan(`${"─".repeat(52)}`),
91
+ "",
92
+ ];
91
93
 
92
94
  if (proxyTarget) {
93
- console.log(orange(` ${icons.arrow} API PROXY → ${proxyTarget}`));
94
- console.log();
95
+ headerLines.push(orange(` ${icons.arrow} API PROXY → ${proxyTarget}`), "");
95
96
  }
96
97
 
97
98
  for (const section of sectionedProcesses) {
98
- console.log(colors.cyan(` ${section.title}`));
99
+ headerLines.push(colors.cyan(` ${section.title}`));
99
100
  for (const proc of section.processes) {
100
101
  const color = getServiceColor(proc.name);
101
102
  const sourceLabel = proc.source ? ` (${proc.source})` : "";
102
- console.log(
103
+ headerLines.push(
103
104
  `${colors.dim(`[${getTimestamp()}]`)} ${color(`[${getDisplayName(proc.name).padEnd(columnWidths.name)}]`)} ${icons.pending} waiting${sourceLabel.padEnd(columnWidths.source)}`,
104
105
  );
105
106
  }
106
- console.log();
107
+ headerLines.push("");
107
108
  }
109
+ console.log(headerLines.join("\n"));
108
110
 
109
111
  const checkAllReady = () => {
110
112
  if (allReadyPrinted) return;
111
113
  const allReady = Array.from(processes.values()).every((p) => p.status === "ready");
112
114
  if (allReady) {
113
115
  allReadyPrinted = true;
114
- console.log();
115
- console.log(colors.dim(`${"".repeat(52)}`));
116
- console.log(colors.green(`${icons.ok} All ${processes.size} services ready`));
117
- console.log(colors.green(`${icons.arrow} http://localhost:${hostPort}`));
118
- console.log(colors.dim(`${"─".repeat(52)}`));
119
- console.log();
116
+ const readyLines = [
117
+ "",
118
+ colors.dim(`${"─".repeat(52)}`),
119
+ colors.green(`${icons.ok} All ${processes.size} services ready`),
120
+ colors.green(`${icons.arrow} http://localhost:${hostPort}`),
121
+ colors.dim(`${"─".repeat(52)}`),
122
+ "",
123
+ ];
124
+ console.log(readyLines.join("\n"));
120
125
  }
121
126
  };
122
127
 
package/src/plugin.ts CHANGED
@@ -992,30 +992,30 @@ export default createPlugin({
992
992
  ? buildRegistryConfigUrl(input.account, input.domain)
993
993
  : undefined;
994
994
 
995
- console.log();
996
- console.log(` ${colors.dim("Config Source:")} ${configSource}`);
995
+ const summaryLines: string[] = ["", ` ${colors.dim("Config Source:")} ${configSource}`];
997
996
  if (configSourceHttp) {
998
- console.log(` ${colors.dim(configSourceHttp)}`);
997
+ summaryLines.push(` ${colors.dim(configSourceHttp)}`);
999
998
  }
1000
- console.log(` ${colors.dim("Account:")} ${config.account}`);
1001
- console.log(` ${colors.dim("Domain:")} ${config.domain ?? "not configured"}`);
1002
- console.log();
1003
- console.log(` ${colors.dim("Modules:")}`);
1004
- console.log(
999
+ summaryLines.push(
1000
+ ` ${colors.dim("Account:")} ${config.account}`,
1001
+ ` ${colors.dim("Domain:")} ${config.domain ?? "not configured"}`,
1002
+ "",
1003
+ ` ${colors.dim("Modules:")}`,
1005
1004
  ` ${colors.dim("HOST")} → ${runtimeConfig.host.remoteUrl ?? runtimeConfig.host.url ?? "local"}`,
1005
+ ` ${colors.dim("UI")} → ${runtimeConfig.ui.url ?? "local"}`,
1006
+ ` ${colors.dim("API")} → ${runtimeConfig.api.url ?? "local"}`,
1006
1007
  );
1007
- console.log(` ${colors.dim("UI")} → ${runtimeConfig.ui.url ?? "local"}`);
1008
- console.log(` ${colors.dim("API")} → ${runtimeConfig.api.url ?? "local"}`);
1009
1008
  if (runtimeConfig.auth) {
1010
- console.log(` ${colors.dim("AUTH")} → ${runtimeConfig.auth.url ?? "local"}`);
1009
+ summaryLines.push(` ${colors.dim("AUTH")} → ${runtimeConfig.auth.url ?? "local"}`);
1011
1010
  }
1012
1011
  if (warnings.length > 0) {
1013
- console.log();
1012
+ summaryLines.push("");
1014
1013
  for (const w of warnings) {
1015
- console.log(` ${colors.yellow(w)}`);
1014
+ summaryLines.push(` ${colors.yellow(w)}`);
1016
1015
  }
1017
1016
  }
1018
- console.log();
1017
+ summaryLines.push("");
1018
+ console.log(summaryLines.join("\n"));
1019
1019
 
1020
1020
  const orchestrator: AppOrchestrator = {
1021
1021
  packages: ["host"],