everything-dev 1.49.0 → 1.50.0
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.
- package/dist/app.cjs +66 -86
- package/dist/app.cjs.map +1 -1
- package/dist/app.mjs +66 -87
- package/dist/app.mjs.map +1 -1
- package/dist/cli/db-doctor.cjs +6 -23
- package/dist/cli/db-doctor.cjs.map +1 -1
- package/dist/cli/db-doctor.mjs +7 -24
- package/dist/cli/db-doctor.mjs.map +1 -1
- package/dist/cli/db-repair.cjs +25 -20
- package/dist/cli/db-repair.cjs.map +1 -1
- package/dist/cli/db-repair.mjs +25 -20
- package/dist/cli/db-repair.mjs.map +1 -1
- package/dist/cli/db-studio.cjs +4 -2
- package/dist/cli/db-studio.cjs.map +1 -1
- package/dist/cli/db-studio.mjs +5 -3
- package/dist/cli/db-studio.mjs.map +1 -1
- package/dist/cli/framework-version.cjs +45 -9
- package/dist/cli/framework-version.cjs.map +1 -1
- package/dist/cli/framework-version.mjs +45 -10
- package/dist/cli/framework-version.mjs.map +1 -1
- package/dist/cli/infra.cjs +89 -3
- package/dist/cli/infra.cjs.map +1 -1
- package/dist/cli/infra.mjs +83 -4
- package/dist/cli/infra.mjs.map +1 -1
- package/dist/cli/init.cjs +39 -15
- package/dist/cli/init.cjs.map +1 -1
- package/dist/cli/init.d.cts +8 -3
- package/dist/cli/init.d.cts.map +1 -1
- package/dist/cli/init.d.mts +8 -3
- package/dist/cli/init.d.mts.map +1 -1
- package/dist/cli/init.mjs +39 -16
- package/dist/cli/init.mjs.map +1 -1
- package/dist/cli/status.cjs +6 -2
- package/dist/cli/status.cjs.map +1 -1
- package/dist/cli/status.mjs +7 -3
- package/dist/cli/status.mjs.map +1 -1
- package/dist/cli/sync.cjs +1 -3
- package/dist/cli/sync.cjs.map +1 -1
- package/dist/cli/sync.mjs +1 -3
- package/dist/cli/sync.mjs.map +1 -1
- package/dist/cli/upgrade.cjs +8 -4
- package/dist/cli/upgrade.cjs.map +1 -1
- package/dist/cli/upgrade.mjs +8 -4
- package/dist/cli/upgrade.mjs.map +1 -1
- package/dist/cli.cjs +73 -9
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.mjs +74 -10
- package/dist/cli.mjs.map +1 -1
- package/dist/config.cjs +7 -3
- package/dist/config.cjs.map +1 -1
- package/dist/config.d.cts.map +1 -1
- package/dist/config.d.mts.map +1 -1
- package/dist/config.mjs +7 -3
- package/dist/config.mjs.map +1 -1
- package/dist/contract.cjs +76 -4
- package/dist/contract.cjs.map +1 -1
- package/dist/contract.d.cts +164 -19
- package/dist/contract.d.cts.map +1 -1
- package/dist/contract.d.mts +164 -19
- package/dist/contract.d.mts.map +1 -1
- package/dist/contract.meta.cjs +17 -2
- package/dist/contract.meta.cjs.map +1 -1
- package/dist/contract.meta.d.cts +23 -2
- package/dist/contract.meta.d.mts +23 -2
- package/dist/contract.meta.mjs +17 -2
- package/dist/contract.meta.mjs.map +1 -1
- package/dist/contract.mjs +72 -5
- package/dist/contract.mjs.map +1 -1
- package/dist/db.cjs +32 -24
- package/dist/db.cjs.map +1 -1
- package/dist/db.d.cts +16 -9
- package/dist/db.d.cts.map +1 -1
- package/dist/db.d.mts +16 -9
- package/dist/db.d.mts.map +1 -1
- package/dist/db.mjs +32 -23
- package/dist/db.mjs.map +1 -1
- package/dist/dev-session.cjs +28 -0
- package/dist/dev-session.cjs.map +1 -1
- package/dist/dev-session.mjs +29 -1
- package/dist/dev-session.mjs.map +1 -1
- package/dist/index.cjs +5 -0
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +2 -2
- package/dist/infra/planner.cjs +337 -0
- package/dist/infra/planner.cjs.map +1 -0
- package/dist/infra/planner.mjs +336 -0
- package/dist/infra/planner.mjs.map +1 -0
- package/dist/infra/preflight.cjs +131 -0
- package/dist/infra/preflight.cjs.map +1 -0
- package/dist/infra/preflight.mjs +130 -0
- package/dist/infra/preflight.mjs.map +1 -0
- package/dist/infra/types.cjs +9 -0
- package/dist/infra/types.cjs.map +1 -0
- package/dist/infra/types.mjs +8 -0
- package/dist/infra/types.mjs.map +1 -0
- package/dist/near-cli.cjs +37 -0
- package/dist/near-cli.cjs.map +1 -1
- package/dist/near-cli.mjs +36 -1
- package/dist/near-cli.mjs.map +1 -1
- package/dist/orchestrator.cjs +10 -2
- package/dist/orchestrator.cjs.map +1 -1
- package/dist/orchestrator.mjs +10 -2
- package/dist/orchestrator.mjs.map +1 -1
- package/dist/plugin.cjs +160 -43
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.d.cts +64 -8
- package/dist/plugin.d.cts.map +1 -1
- package/dist/plugin.d.mts +64 -8
- package/dist/plugin.d.mts.map +1 -1
- package/dist/plugin.mjs +164 -47
- package/dist/plugin.mjs.map +1 -1
- package/dist/process-registry.cjs +88 -0
- package/dist/process-registry.cjs.map +1 -0
- package/dist/process-registry.mjs +83 -0
- package/dist/process-registry.mjs.map +1 -0
- package/dist/publish.cjs +4 -0
- package/dist/publish.cjs.map +1 -1
- package/dist/publish.mjs +4 -0
- package/dist/publish.mjs.map +1 -1
- package/dist/service-descriptor.cjs +4 -0
- package/dist/service-descriptor.cjs.map +1 -1
- package/dist/service-descriptor.mjs +4 -1
- package/dist/service-descriptor.mjs.map +1 -1
- package/dist/types.d.cts +2 -2
- package/dist/types.d.mts +2 -2
- package/dist/ui/index.cjs +2 -1
- package/dist/ui/index.d.cts +2 -2
- package/dist/ui/index.d.mts +2 -2
- package/dist/ui/index.mjs +2 -2
- package/dist/ui/router.cjs +40 -0
- package/dist/ui/router.cjs.map +1 -1
- package/dist/ui/router.d.cts +6 -1
- package/dist/ui/router.d.cts.map +1 -1
- package/dist/ui/router.d.mts +6 -1
- package/dist/ui/router.d.mts.map +1 -1
- package/dist/ui/router.mjs +40 -1
- package/dist/ui/router.mjs.map +1 -1
- package/package.json +4 -1
- package/skills/cli-reference/SKILL.md +5 -4
- package/skills/dev-workflow/SKILL.md +40 -11
- package/skills/plugin-development/SKILL.md +9 -2
package/dist/index.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { BOS_CONFIG_ORDER, mergeBosConfigWithExtends, rebuildOrderedConfig, reso
|
|
|
3
3
|
import { ApiPluginConfigSchema, BosConfigInputSchema, BosConfigSchema, BosPluginRefSchema, BosStagingSchema, CiConfigSchema, ClientRuntimeConfigSchema, ClientRuntimeInfoSchema, ComposableAppEntrySchema, ExtendsSchema, FederationEntrySchema, HostConfigSchema, JsonObjectSchema, JsonValueSchema, PluginUiConfigSchema, RailwayCiSchema, RuntimeConfigSchema, RuntimeLineageSchema, RuntimePluginConfigSchema, SharedConfigSchema, SharedDepConfigSchema, SharedDepMapSchema, SourceModeSchema, UiConfigSchema } from "./types.mjs";
|
|
4
4
|
import { buildRuntimeConfig, buildRuntimePluginsForConfig, clearConfigCache, drainConfigWarnings, findConfigPath, getConfig, getHostDevelopmentPort, getProjectRoot, getResolvedConfigPath, isLocalDevelopmentTarget, isRuntimeOverrideAllowed, loadBosConfig, loadGeneratedResolvedConfig, loadLocalConfig, loadRemoteConfig, loadResolvedConfig, parsePort, parseRuntimeOverrideTargets, readBosConfigForBuild, resolveBosConfigPath, resolveComposableReference, resolveConfigComposableEntries, resolveDevelopmentHostUrl, resolveLocalDevelopmentPath, resolvePluginRuntimeName, resumeWarnings, suppressWarnings, writeResolvedConfig } from "./config.mjs";
|
|
5
5
|
import { Context, Effect, Layer, PluginRuntime, Scope, createPlugin, createPluginRuntime, oc, z } from "./sdk.mjs";
|
|
6
|
-
import { BuildOptionsSchema, BuildResultSchema, ConfigOptionsSchema, ConfigResultSchema, DbDoctorOptionsSchema, DbDoctorResultSchema, DbRepairOptionsSchema, DbRepairResultSchema, DbStudioOptionsSchema, DbStudioResultSchema, DeployOptionsSchema, DeployResultSchema, DevOptionsSchema, DevResultSchema, InitOptionsSchema, InitResultSchema, KeyPublishOptionsSchema, KeyPublishResultSchema, OverrideSectionSchema, PhaseTimingSchema, PluginAddOptionsSchema, PluginAddResultSchema, PluginListResultSchema, PluginPublishOptionsSchema, PluginPublishResultSchema, PluginRemoveOptionsSchema, PluginRemoveResultSchema, PublishOptionsSchema, PublishResultSchema, RuntimeOverrideTargetBaseSchema, RuntimeOverrideTargetSchema, StartOptionsSchema, StartResultSchema, StatusResultSchema, SyncOptionsSchema, SyncResultSchema, TypesGenOptionsSchema, TypesGenResultSchema, UpgradeOptionsSchema, UpgradeResultSchema, WorkspaceDeployResultSchema, bosContract } from "./contract.mjs";
|
|
6
|
+
import { BuildOptionsSchema, BuildResultSchema, ConfigOptionsSchema, ConfigResultSchema, DbDoctorOptionsSchema, DbDoctorResultSchema, DbRepairOptionsSchema, DbRepairResultSchema, DbStudioOptionsSchema, DbStudioResultSchema, DeployOptionsSchema, DeployResultSchema, DevOptionsSchema, DevResultSchema, InitOptionsSchema, InitResultSchema, KeyPublishOptionsSchema, KeyPublishResultSchema, KillOptionsSchema, KillResultSchema, OverrideSectionSchema, PhaseTimingSchema, PidEntrySchema, PluginAddOptionsSchema, PluginAddResultSchema, PluginListResultSchema, PluginPublishOptionsSchema, PluginPublishResultSchema, PluginRemoveOptionsSchema, PluginRemoveResultSchema, ProcessRoleSchema, PsResultSchema, PublishOptionsSchema, PublishResultSchema, RuntimeOverrideTargetBaseSchema, RuntimeOverrideTargetSchema, StartOptionsSchema, StartResultSchema, StatusResultSchema, SyncOptionsSchema, SyncResultSchema, TypesGenOptionsSchema, TypesGenResultSchema, UpgradeOptionsSchema, UpgradeResultSchema, WorkspaceDeployResultSchema, bosContract } from "./contract.mjs";
|
|
7
7
|
import { cliCommandMeta } from "./contract.meta.mjs";
|
|
8
8
|
|
|
9
|
-
export { ApiPluginConfigSchema, BOS_CONFIG_ORDER, BosConfigInputSchema, BosConfigSchema, BosPluginRefSchema, BosStagingSchema, BuildOptionsSchema, BuildResultSchema, CiConfigSchema, ClientRuntimeConfigSchema, ClientRuntimeInfoSchema, ComposableAppEntrySchema, ConfigOptionsSchema, ConfigResultSchema, Context, DbDoctorOptionsSchema, DbDoctorResultSchema, DbRepairOptionsSchema, DbRepairResultSchema, DbStudioOptionsSchema, DbStudioResultSchema, DeployOptionsSchema, DeployResultSchema, DevOptionsSchema, DevResultSchema, Effect, ExtendsSchema, FederationEntrySchema, HostConfigSchema, InitOptionsSchema, InitResultSchema, JsonObjectSchema, JsonValueSchema, KeyPublishOptionsSchema, KeyPublishResultSchema, Layer, OverrideSectionSchema, PhaseTimingSchema, PluginAddOptionsSchema, PluginAddResultSchema, PluginListResultSchema, PluginPublishOptionsSchema, PluginPublishResultSchema, PluginRemoveOptionsSchema, PluginRemoveResultSchema, PluginRuntime, PluginUiConfigSchema, PublishOptionsSchema, PublishResultSchema, RailwayCiSchema, RuntimeConfigSchema, RuntimeLineageSchema, RuntimeOverrideTargetBaseSchema, RuntimeOverrideTargetSchema, RuntimePluginConfigSchema, Scope, SharedConfigSchema, SharedDepConfigSchema, SharedDepMapSchema, SourceModeSchema, StartOptionsSchema, StartResultSchema, StatusResultSchema, SyncOptionsSchema, SyncResultSchema, TypesGenOptionsSchema, TypesGenResultSchema, UiConfigSchema, UpgradeOptionsSchema, UpgradeResultSchema, WorkspaceDeployResultSchema, bosContract, buildRegistryConfigUrl, buildRegistryConfigUrlForNetwork, buildRuntimeConfig, buildRuntimePluginsForConfig, clearConfigCache, cliCommandMeta, createPlugin, createPluginRuntime, drainConfigWarnings, fetchBosConfigFromFastKv, fetchRemotePluginManifest, findConfigPath, getConfig, getFastKvBaseUrlForNetwork, getHostDevelopmentPort, getProjectRoot, getRegistryNamespaceForAccount, getRegistryNamespaceForNetwork, getResolvedConfigPath, isLocalDevelopmentTarget, isRuntimeOverrideAllowed, loadBosConfig, loadGeneratedResolvedConfig, loadLocalConfig, loadRemoteConfig, loadResolvedConfig, mergeBosConfigWithExtends, oc, parseBosUrl, parsePort, parseRuntimeOverrideTargets, readBosConfigForBuild, rebuildOrderedConfig, resolveBosConfigPath, resolveComposableReference, resolveConfigComposableEntries, resolveDevelopmentHostUrl, resolveExtendsRef, resolveLocalDevelopmentPath, resolvePluginRuntimeName, resumeWarnings, suppressWarnings, writeResolvedConfig, z };
|
|
9
|
+
export { ApiPluginConfigSchema, BOS_CONFIG_ORDER, BosConfigInputSchema, BosConfigSchema, BosPluginRefSchema, BosStagingSchema, BuildOptionsSchema, BuildResultSchema, CiConfigSchema, ClientRuntimeConfigSchema, ClientRuntimeInfoSchema, ComposableAppEntrySchema, ConfigOptionsSchema, ConfigResultSchema, Context, DbDoctorOptionsSchema, DbDoctorResultSchema, DbRepairOptionsSchema, DbRepairResultSchema, DbStudioOptionsSchema, DbStudioResultSchema, DeployOptionsSchema, DeployResultSchema, DevOptionsSchema, DevResultSchema, Effect, ExtendsSchema, FederationEntrySchema, HostConfigSchema, InitOptionsSchema, InitResultSchema, JsonObjectSchema, JsonValueSchema, KeyPublishOptionsSchema, KeyPublishResultSchema, KillOptionsSchema, KillResultSchema, Layer, OverrideSectionSchema, PhaseTimingSchema, PidEntrySchema, PluginAddOptionsSchema, PluginAddResultSchema, PluginListResultSchema, PluginPublishOptionsSchema, PluginPublishResultSchema, PluginRemoveOptionsSchema, PluginRemoveResultSchema, PluginRuntime, PluginUiConfigSchema, ProcessRoleSchema, PsResultSchema, PublishOptionsSchema, PublishResultSchema, RailwayCiSchema, RuntimeConfigSchema, RuntimeLineageSchema, RuntimeOverrideTargetBaseSchema, RuntimeOverrideTargetSchema, RuntimePluginConfigSchema, Scope, SharedConfigSchema, SharedDepConfigSchema, SharedDepMapSchema, SourceModeSchema, StartOptionsSchema, StartResultSchema, StatusResultSchema, SyncOptionsSchema, SyncResultSchema, TypesGenOptionsSchema, TypesGenResultSchema, UiConfigSchema, UpgradeOptionsSchema, UpgradeResultSchema, WorkspaceDeployResultSchema, bosContract, buildRegistryConfigUrl, buildRegistryConfigUrlForNetwork, buildRuntimeConfig, buildRuntimePluginsForConfig, clearConfigCache, cliCommandMeta, createPlugin, createPluginRuntime, drainConfigWarnings, fetchBosConfigFromFastKv, fetchRemotePluginManifest, findConfigPath, getConfig, getFastKvBaseUrlForNetwork, getHostDevelopmentPort, getProjectRoot, getRegistryNamespaceForAccount, getRegistryNamespaceForNetwork, getResolvedConfigPath, isLocalDevelopmentTarget, isRuntimeOverrideAllowed, loadBosConfig, loadGeneratedResolvedConfig, loadLocalConfig, loadRemoteConfig, loadResolvedConfig, mergeBosConfigWithExtends, oc, parseBosUrl, parsePort, parseRuntimeOverrideTargets, readBosConfigForBuild, rebuildOrderedConfig, resolveBosConfigPath, resolveComposableReference, resolveConfigComposableEntries, resolveDevelopmentHostUrl, resolveExtendsRef, resolveLocalDevelopmentPath, resolvePluginRuntimeName, resumeWarnings, suppressWarnings, writeResolvedConfig, z };
|
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
2
|
+
const require_app = require('../app.cjs');
|
|
3
|
+
const require_infra = require('../cli/infra.cjs');
|
|
4
|
+
const require_service_descriptor = require('../service-descriptor.cjs');
|
|
5
|
+
const require_types = require('./types.cjs');
|
|
6
|
+
let node_path = require("node:path");
|
|
7
|
+
let effect = require("effect");
|
|
8
|
+
let node_crypto = require("node:crypto");
|
|
9
|
+
|
|
10
|
+
//#region src/infra/planner.ts
|
|
11
|
+
const DEFAULT_HOST_PORT = 3e3;
|
|
12
|
+
const DEFAULT_API_PORT = 3001;
|
|
13
|
+
const DEFAULT_AUTH_PORT = 3002;
|
|
14
|
+
const DEFAULT_UI_PORT = 3003;
|
|
15
|
+
const DEFAULT_PLUGIN_PORT_START = 3010;
|
|
16
|
+
const POSTGRES_USER = "everythingdev";
|
|
17
|
+
const POSTGRES_PASSWORD = "everythingdev";
|
|
18
|
+
function workspaceKey(configDir) {
|
|
19
|
+
return (0, node_crypto.createHash)("sha256").update((0, node_path.resolve)(configDir)).digest("hex").slice(0, 12);
|
|
20
|
+
}
|
|
21
|
+
function normalizeCliPorts(input) {
|
|
22
|
+
return {
|
|
23
|
+
host: input.port,
|
|
24
|
+
api: input.apiPort,
|
|
25
|
+
auth: input.authPort,
|
|
26
|
+
ui: input.uiPort,
|
|
27
|
+
uiSsr: void 0,
|
|
28
|
+
pluginsStart: input.pluginPortStart,
|
|
29
|
+
plugins: input.plugins
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
function allocateServices(cliPorts, plugins, configDir) {
|
|
33
|
+
return effect.Effect.gen(function* () {
|
|
34
|
+
const wKey = workspaceKey(configDir);
|
|
35
|
+
const persisted = require_infra.loadPortState(configDir).devPorts;
|
|
36
|
+
const allocator = yield* require_app.PortAllocator;
|
|
37
|
+
const hostPort = yield* allocator.pickAvailable(cliPorts.host ?? persisted?.host ?? DEFAULT_HOST_PORT);
|
|
38
|
+
const apiPort = yield* allocator.pickAvailable(cliPorts.api ?? persisted?.api ?? DEFAULT_API_PORT);
|
|
39
|
+
const authPort = yield* allocator.pickAvailable(cliPorts.auth ?? persisted?.auth ?? DEFAULT_AUTH_PORT);
|
|
40
|
+
const uiPort = yield* allocator.pickAvailable(cliPorts.ui ?? persisted?.ui ?? DEFAULT_UI_PORT);
|
|
41
|
+
const uiSsrPort = yield* allocator.pickAvailable(cliPorts.uiSsr ?? uiPort + 1);
|
|
42
|
+
const pluginApiPorts = {};
|
|
43
|
+
const pluginUiPorts = {};
|
|
44
|
+
const pluginKeys = Object.keys(plugins).sort();
|
|
45
|
+
const pluginStart = cliPorts.pluginsStart ?? persisted?.pluginPortStart ?? DEFAULT_PLUGIN_PORT_START;
|
|
46
|
+
let nextPluginPort = pluginStart;
|
|
47
|
+
for (const pluginId of pluginKeys) {
|
|
48
|
+
const pluginCfg = plugins[pluginId];
|
|
49
|
+
const preferred = cliPorts.plugins?.[pluginId]?.api ?? nextPluginPort;
|
|
50
|
+
const pluginPort = yield* allocator.pickAvailable(preferred);
|
|
51
|
+
pluginApiPorts[pluginId] = pluginPort;
|
|
52
|
+
nextPluginPort = pluginPort + 1;
|
|
53
|
+
if (pluginCfg?.source === "local" && pluginCfg?.localPath && pluginCfg?.ui?.source === "local") {
|
|
54
|
+
const uiPreferred = cliPorts.plugins?.[pluginId]?.ui ?? nextPluginPort;
|
|
55
|
+
const pluginUiPort = yield* allocator.pickAvailable(uiPreferred);
|
|
56
|
+
pluginUiPorts[pluginId] = pluginUiPort;
|
|
57
|
+
nextPluginPort = pluginUiPort + 1;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
const resolved = {
|
|
61
|
+
host: hostPort,
|
|
62
|
+
api: apiPort,
|
|
63
|
+
auth: authPort,
|
|
64
|
+
ui: uiPort,
|
|
65
|
+
uiSsr: uiSsrPort,
|
|
66
|
+
plugins: Object.fromEntries(Object.entries(pluginApiPorts).map(([k, v]) => [k, {
|
|
67
|
+
api: v,
|
|
68
|
+
ui: pluginUiPorts[k]
|
|
69
|
+
}])),
|
|
70
|
+
postgres: {},
|
|
71
|
+
redis: {}
|
|
72
|
+
};
|
|
73
|
+
const devPortsState = {
|
|
74
|
+
host: hostPort,
|
|
75
|
+
api: apiPort,
|
|
76
|
+
auth: authPort,
|
|
77
|
+
ui: uiPort,
|
|
78
|
+
pluginPortStart: pluginStart
|
|
79
|
+
};
|
|
80
|
+
const claimPorts = {
|
|
81
|
+
host: hostPort,
|
|
82
|
+
api: apiPort,
|
|
83
|
+
auth: authPort,
|
|
84
|
+
ui: uiPort,
|
|
85
|
+
uiSsr: uiSsrPort
|
|
86
|
+
};
|
|
87
|
+
for (const [id, port] of Object.entries(pluginApiPorts)) claimPorts[`plugin:${id}`] = port;
|
|
88
|
+
for (const [id, port] of Object.entries(pluginUiPorts)) claimPorts[`plugin-ui:${id}`] = port;
|
|
89
|
+
return {
|
|
90
|
+
ports: resolved,
|
|
91
|
+
claims: [{
|
|
92
|
+
resourceKey: `workspace:${wKey}`,
|
|
93
|
+
pid: process.pid,
|
|
94
|
+
configDir,
|
|
95
|
+
ports: claimPorts,
|
|
96
|
+
startedAt: Date.now()
|
|
97
|
+
}],
|
|
98
|
+
devPortsState
|
|
99
|
+
};
|
|
100
|
+
}).pipe(effect.Effect.mapError((portErr) => new require_types.InfraError({
|
|
101
|
+
phase: "allocate-services",
|
|
102
|
+
message: `Port allocation failed: ${String(portErr)}`,
|
|
103
|
+
cause: portErr
|
|
104
|
+
})));
|
|
105
|
+
}
|
|
106
|
+
function allocateDatabases(runtimeConfig, configDir) {
|
|
107
|
+
return effect.Effect.gen(function* () {
|
|
108
|
+
const persisted = require_infra.loadPortState(configDir);
|
|
109
|
+
const allSecrets = require_infra.getSecretGroups(runtimeConfig).flatMap((group) => group.secrets);
|
|
110
|
+
const originMap = require_infra.buildOriginMap(configDir, runtimeConfig);
|
|
111
|
+
const allocator = yield* require_app.PortAllocator;
|
|
112
|
+
const infraDatabases = yield* effect.Effect.sync(() => require_infra.buildDatabaseConfigs(allSecrets, originMap, { ...persisted.postgresPorts }));
|
|
113
|
+
const infraRedis = yield* effect.Effect.sync(() => require_infra.buildRedisConfigs(allSecrets, originMap, { ...persisted.redisPorts }));
|
|
114
|
+
const postgres = {};
|
|
115
|
+
const dbs = [];
|
|
116
|
+
for (const db of infraDatabases) {
|
|
117
|
+
const port = yield* allocator.pickAvailable(db.port);
|
|
118
|
+
postgres[db.slug] = port;
|
|
119
|
+
dbs.push({
|
|
120
|
+
secret: db.secret,
|
|
121
|
+
slug: db.slug,
|
|
122
|
+
port,
|
|
123
|
+
dbName: db.databaseName,
|
|
124
|
+
containerName: db.containerName,
|
|
125
|
+
volumeName: db.volumeName,
|
|
126
|
+
url: `postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@localhost:${port}/${db.slug}_db`
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
const redis = {};
|
|
130
|
+
const redisPlans = [];
|
|
131
|
+
for (const r of infraRedis) {
|
|
132
|
+
const port = yield* allocator.pickAvailable(r.port);
|
|
133
|
+
redis[r.slug] = port;
|
|
134
|
+
redisPlans.push({
|
|
135
|
+
secret: r.secret,
|
|
136
|
+
slug: r.slug,
|
|
137
|
+
port,
|
|
138
|
+
containerName: r.containerName,
|
|
139
|
+
volumeName: r.volumeName,
|
|
140
|
+
url: `redis://localhost:${port}`
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
return {
|
|
144
|
+
postgres,
|
|
145
|
+
redis,
|
|
146
|
+
dbs,
|
|
147
|
+
redisPlans
|
|
148
|
+
};
|
|
149
|
+
}).pipe(effect.Effect.mapError((portErr) => new require_types.InfraError({
|
|
150
|
+
phase: "allocate-databases",
|
|
151
|
+
message: `Database port allocation failed: ${String(portErr)}`,
|
|
152
|
+
cause: portErr
|
|
153
|
+
})));
|
|
154
|
+
}
|
|
155
|
+
function buildServiceDescriptors(runtimeConfig, resolvedPorts) {
|
|
156
|
+
const descriptors = [];
|
|
157
|
+
if (runtimeConfig.host) {
|
|
158
|
+
const isLocal = runtimeConfig.host.source === "local";
|
|
159
|
+
descriptors.push({
|
|
160
|
+
key: "host",
|
|
161
|
+
source: runtimeConfig.host.source,
|
|
162
|
+
url: isLocal ? `http://localhost:${resolvedPorts.host}` : runtimeConfig.host.url,
|
|
163
|
+
port: isLocal ? resolvedPorts.host : void 0,
|
|
164
|
+
localPath: isLocal ? runtimeConfig.host.localPath : void 0
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
if (runtimeConfig.api) {
|
|
168
|
+
const isLocal = runtimeConfig.api.source === "local";
|
|
169
|
+
descriptors.push({
|
|
170
|
+
key: "api",
|
|
171
|
+
source: runtimeConfig.api.source,
|
|
172
|
+
url: isLocal ? `http://localhost:${resolvedPorts.api}` : runtimeConfig.api.url,
|
|
173
|
+
port: isLocal ? resolvedPorts.api : void 0,
|
|
174
|
+
localPath: isLocal ? runtimeConfig.api.localPath : void 0
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
if (runtimeConfig.auth) {
|
|
178
|
+
const isLocal = runtimeConfig.auth.source === "local";
|
|
179
|
+
descriptors.push({
|
|
180
|
+
key: "auth",
|
|
181
|
+
source: runtimeConfig.auth.source,
|
|
182
|
+
url: isLocal ? `http://localhost:${resolvedPorts.auth}` : runtimeConfig.auth.url,
|
|
183
|
+
port: isLocal ? resolvedPorts.auth : void 0,
|
|
184
|
+
localPath: isLocal ? runtimeConfig.auth.localPath : void 0
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
if (runtimeConfig.ui) {
|
|
188
|
+
const isLocal = runtimeConfig.ui.source === "local";
|
|
189
|
+
descriptors.push({
|
|
190
|
+
key: "ui",
|
|
191
|
+
source: runtimeConfig.ui.source,
|
|
192
|
+
url: isLocal ? `http://localhost:${resolvedPorts.ui}` : runtimeConfig.ui.url,
|
|
193
|
+
port: isLocal ? resolvedPorts.ui : void 0,
|
|
194
|
+
localPath: isLocal ? runtimeConfig.ui.localPath : void 0
|
|
195
|
+
});
|
|
196
|
+
if (isLocal && resolvedPorts.uiSsr) descriptors.push({
|
|
197
|
+
key: "ui-ssr",
|
|
198
|
+
source: "local",
|
|
199
|
+
url: `http://localhost:${resolvedPorts.uiSsr}`,
|
|
200
|
+
port: resolvedPorts.uiSsr,
|
|
201
|
+
localPath: runtimeConfig.ui.localPath
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
if (runtimeConfig.plugins) for (const [pluginId, pluginCfg] of Object.entries(runtimeConfig.plugins)) {
|
|
205
|
+
const pluginIsLocal = pluginCfg.source === "local";
|
|
206
|
+
const p = resolvedPorts.plugins[pluginId];
|
|
207
|
+
if (pluginIsLocal && p?.api) descriptors.push({
|
|
208
|
+
key: `plugin:${pluginId}`,
|
|
209
|
+
source: "local",
|
|
210
|
+
url: `http://localhost:${p.api}`,
|
|
211
|
+
port: p.api,
|
|
212
|
+
localPath: pluginCfg.localPath
|
|
213
|
+
});
|
|
214
|
+
if (pluginIsLocal && p?.ui && pluginCfg.ui?.source === "local") descriptors.push({
|
|
215
|
+
key: `plugin-ui:${pluginId}`,
|
|
216
|
+
source: "local",
|
|
217
|
+
url: `http://localhost:${p.ui}`,
|
|
218
|
+
port: p.ui,
|
|
219
|
+
localPath: pluginCfg.ui?.localPath
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
return descriptors;
|
|
223
|
+
}
|
|
224
|
+
function buildLaunchSpec(runtimeConfig, resolvedPorts) {
|
|
225
|
+
const hostPort = runtimeConfig.host?.source === "local" ? resolvedPorts.host : runtimeConfig.host?.port;
|
|
226
|
+
const corsOrigin = hostPort ? `http://localhost:${hostPort}` : `http://localhost:3000`;
|
|
227
|
+
return {
|
|
228
|
+
port: resolvedPorts.host,
|
|
229
|
+
hostUrl: runtimeConfig.host?.url,
|
|
230
|
+
corsOrigin,
|
|
231
|
+
env: {
|
|
232
|
+
...resolvedPorts.host ? { PORT: String(resolvedPorts.host) } : {},
|
|
233
|
+
...resolvedPorts.api ? { API_PORT: String(resolvedPorts.api) } : {},
|
|
234
|
+
...resolvedPorts.ui ? { UI_PORT: String(resolvedPorts.ui) } : {},
|
|
235
|
+
...resolvedPorts.auth ? { AUTH_PORT: String(resolvedPorts.auth) } : {}
|
|
236
|
+
},
|
|
237
|
+
runtimeConfig
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
function buildComposeModel(dbs, redisPlans) {
|
|
241
|
+
return {
|
|
242
|
+
databases: dbs,
|
|
243
|
+
redis: redisPlans
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
function buildEnvGenerated(resolvedPorts, dbs, redisPlans) {
|
|
247
|
+
const env = {};
|
|
248
|
+
if (resolvedPorts.host) env.CORS_ORIGIN = `http://localhost:${resolvedPorts.host}`;
|
|
249
|
+
for (const db of dbs) env[db.secret] = db.url;
|
|
250
|
+
for (const r of redisPlans) env[r.secret] = r.url;
|
|
251
|
+
return env;
|
|
252
|
+
}
|
|
253
|
+
function planInfra(input) {
|
|
254
|
+
return effect.Effect.gen(function* () {
|
|
255
|
+
const cliPorts = normalizeCliPorts(input.cli);
|
|
256
|
+
const wKey = workspaceKey(input.configDir);
|
|
257
|
+
const { ports: svcPorts, claims, devPortsState } = yield* allocateServices(cliPorts, input.bosConfig.plugins ?? {}, input.configDir);
|
|
258
|
+
const { dbs, redisPlans, postgres: pgPorts, redis: rdPorts } = yield* allocateDatabases(input.bosConfig, input.configDir);
|
|
259
|
+
const resolvedPorts = {
|
|
260
|
+
...svcPorts,
|
|
261
|
+
postgres: pgPorts,
|
|
262
|
+
redis: rdPorts
|
|
263
|
+
};
|
|
264
|
+
require_infra.savePortState(input.configDir, {
|
|
265
|
+
postgresPorts: pgPorts,
|
|
266
|
+
redisPorts: rdPorts,
|
|
267
|
+
devPorts: devPortsState
|
|
268
|
+
});
|
|
269
|
+
const hostIsLocal = input.bosConfig.host?.source === "local";
|
|
270
|
+
const apiIsLocal = input.bosConfig.api?.source === "local";
|
|
271
|
+
const uiIsLocal = input.bosConfig.ui?.source === "local";
|
|
272
|
+
const authIsLocal = input.bosConfig.auth?.source === "local";
|
|
273
|
+
const assignedRuntimeConfig = {
|
|
274
|
+
...input.bosConfig,
|
|
275
|
+
host: resolvedPorts.host ? {
|
|
276
|
+
...input.bosConfig.host,
|
|
277
|
+
port: resolvedPorts.host,
|
|
278
|
+
url: `http://localhost:${resolvedPorts.host}`,
|
|
279
|
+
remoteUrl: !hostIsLocal ? input.bosConfig.host.remoteUrl ?? input.bosConfig.host.url : void 0
|
|
280
|
+
} : input.bosConfig.host,
|
|
281
|
+
api: apiIsLocal && resolvedPorts.api ? {
|
|
282
|
+
...input.bosConfig.api,
|
|
283
|
+
port: resolvedPorts.api,
|
|
284
|
+
url: `http://localhost:${resolvedPorts.api}`
|
|
285
|
+
} : input.bosConfig.api,
|
|
286
|
+
ui: uiIsLocal && resolvedPorts.ui ? {
|
|
287
|
+
...input.bosConfig.ui,
|
|
288
|
+
port: resolvedPorts.ui,
|
|
289
|
+
url: `http://localhost:${resolvedPorts.ui}`
|
|
290
|
+
} : input.bosConfig.ui,
|
|
291
|
+
auth: authIsLocal && resolvedPorts.auth && input.bosConfig.auth ? {
|
|
292
|
+
...input.bosConfig.auth,
|
|
293
|
+
port: resolvedPorts.auth,
|
|
294
|
+
url: `http://localhost:${resolvedPorts.auth}`
|
|
295
|
+
} : input.bosConfig.auth,
|
|
296
|
+
plugins: input.bosConfig.plugins ? Object.fromEntries(Object.entries(input.bosConfig.plugins).map(([id, p]) => {
|
|
297
|
+
const pluginPort = resolvedPorts.plugins[id];
|
|
298
|
+
if (p.source === "local" && pluginPort?.api) return [id, {
|
|
299
|
+
...p,
|
|
300
|
+
port: pluginPort.api,
|
|
301
|
+
url: `http://localhost:${pluginPort.api}`
|
|
302
|
+
}];
|
|
303
|
+
return [id, p];
|
|
304
|
+
})) : void 0
|
|
305
|
+
};
|
|
306
|
+
const serviceDescriptors = buildServiceDescriptors(input.bosConfig, resolvedPorts);
|
|
307
|
+
const launch = buildLaunchSpec(input.bosConfig, resolvedPorts);
|
|
308
|
+
const composeModel = buildComposeModel(dbs, redisPlans);
|
|
309
|
+
const envGenerated = buildEnvGenerated(resolvedPorts, dbs, redisPlans);
|
|
310
|
+
const packages = serviceDescriptors.map((d) => d.key);
|
|
311
|
+
const description = require_service_descriptor.buildDescription(new Map(serviceDescriptors.map((d) => [d.key, d])));
|
|
312
|
+
const orchestrator = {
|
|
313
|
+
packages,
|
|
314
|
+
env: {},
|
|
315
|
+
description,
|
|
316
|
+
port: resolvedPorts.host,
|
|
317
|
+
interactive: input.cli.interactive
|
|
318
|
+
};
|
|
319
|
+
return {
|
|
320
|
+
workspaceKey: wKey,
|
|
321
|
+
cliPorts,
|
|
322
|
+
resolvedPorts,
|
|
323
|
+
runtimeConfig: assignedRuntimeConfig,
|
|
324
|
+
launch,
|
|
325
|
+
description,
|
|
326
|
+
serviceDescriptors: new Map(serviceDescriptors.map((d) => [d.key, d])),
|
|
327
|
+
envGenerated,
|
|
328
|
+
composeModel,
|
|
329
|
+
claims,
|
|
330
|
+
orchestrator
|
|
331
|
+
};
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
//#endregion
|
|
336
|
+
exports.planInfra = planInfra;
|
|
337
|
+
//# sourceMappingURL=planner.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"planner.cjs","names":["Effect","loadPortState","PortAllocator","InfraError","getSecretGroups","buildOriginMap","buildDatabaseConfigs","buildRedisConfigs","buildDescription"],"sources":["../../src/infra/planner.ts"],"sourcesContent":["import { createHash } from \"node:crypto\";\nimport { resolve } from \"node:path\";\nimport { Effect } from \"effect\";\nimport { PortAllocator } from \"../app\";\nimport {\n buildDatabaseConfigs,\n buildOriginMap,\n buildRedisConfigs,\n type DatabaseSecretConfig,\n getSecretGroups,\n loadPortState,\n type RedisSecretConfig,\n savePortState,\n} from \"../cli/infra\";\nimport { buildDescription } from \"../service-descriptor\";\nimport type { RuntimeConfig } from \"../types\";\nimport type {\n ClaimRecord,\n CliPorts,\n ComposeModelPlan,\n DatabasePlan,\n InfraInput,\n InfraPlan,\n RedisPlan,\n ResolvedPorts,\n RuntimeLaunchSpec,\n ServiceDescriptorPlan,\n} from \"./types\";\nimport { InfraError } from \"./types\";\n\nconst DEFAULT_HOST_PORT = 3000;\nconst DEFAULT_API_PORT = 3001;\nconst DEFAULT_AUTH_PORT = 3002;\nconst DEFAULT_UI_PORT = 3003;\nconst DEFAULT_PLUGIN_PORT_START = 3010;\nconst POSTGRES_USER = \"everythingdev\";\nconst POSTGRES_PASSWORD = \"everythingdev\";\n\nexport function workspaceKey(configDir: string): string {\n const hash = createHash(\"sha256\").update(resolve(configDir)).digest(\"hex\");\n return hash.slice(0, 12);\n}\n\nfunction normalizeCliPorts(input: InfraInput[\"cli\"]): CliPorts {\n return {\n host: input.port,\n api: input.apiPort,\n auth: input.authPort,\n ui: input.uiPort,\n uiSsr: undefined,\n pluginsStart: input.pluginPortStart,\n plugins: input.plugins,\n };\n}\n\ninterface AllocateServicesResult {\n ports: ResolvedPorts;\n claims: ClaimRecord[];\n devPortsState: { host: number; api: number; auth: number; ui: number; pluginPortStart: number };\n}\n\nfunction allocateServices(\n cliPorts: CliPorts,\n plugins: Record<\n string,\n { source: string; localPath?: string; ui?: { source: string; localPath?: string } }\n >,\n configDir: string,\n): Effect.Effect<AllocateServicesResult, InfraError, PortAllocator> {\n return Effect.gen(function* () {\n const wKey = workspaceKey(configDir);\n const persisted = loadPortState(configDir).devPorts;\n const allocator = yield* PortAllocator;\n\n const hostPort = yield* allocator.pickAvailable(\n cliPorts.host ?? persisted?.host ?? DEFAULT_HOST_PORT,\n );\n\n const apiPort = yield* allocator.pickAvailable(\n cliPorts.api ?? persisted?.api ?? DEFAULT_API_PORT,\n );\n\n const authPort = yield* allocator.pickAvailable(\n cliPorts.auth ?? persisted?.auth ?? DEFAULT_AUTH_PORT,\n );\n\n const uiPort = yield* allocator.pickAvailable(cliPorts.ui ?? persisted?.ui ?? DEFAULT_UI_PORT);\n\n const uiSsrPort = yield* allocator.pickAvailable(cliPorts.uiSsr ?? uiPort + 1);\n\n const pluginApiPorts: Record<string, number> = {};\n const pluginUiPorts: Record<string, number> = {};\n\n const pluginKeys = Object.keys(plugins).sort();\n const pluginStart =\n cliPorts.pluginsStart ?? persisted?.pluginPortStart ?? DEFAULT_PLUGIN_PORT_START;\n let nextPluginPort = pluginStart;\n for (const pluginId of pluginKeys) {\n const pluginCfg = plugins[pluginId];\n const preferred = cliPorts.plugins?.[pluginId]?.api ?? nextPluginPort;\n const pluginPort = yield* allocator.pickAvailable(preferred);\n pluginApiPorts[pluginId] = pluginPort;\n nextPluginPort = pluginPort + 1;\n\n if (\n pluginCfg?.source === \"local\" &&\n pluginCfg?.localPath &&\n pluginCfg?.ui?.source === \"local\"\n ) {\n const uiPreferred = cliPorts.plugins?.[pluginId]?.ui ?? nextPluginPort;\n const pluginUiPort = yield* allocator.pickAvailable(uiPreferred);\n pluginUiPorts[pluginId] = pluginUiPort;\n nextPluginPort = pluginUiPort + 1;\n }\n }\n\n const resolved: ResolvedPorts = {\n host: hostPort,\n api: apiPort,\n auth: authPort,\n ui: uiPort,\n uiSsr: uiSsrPort,\n plugins: Object.fromEntries(\n Object.entries(pluginApiPorts).map(([k, v]) => [k, { api: v, ui: pluginUiPorts[k] }]),\n ),\n postgres: {},\n redis: {},\n };\n\n const devPortsState = {\n host: hostPort,\n api: apiPort,\n auth: authPort,\n ui: uiPort,\n pluginPortStart: pluginStart,\n };\n\n const claimPorts: Record<string, number> = {\n host: hostPort,\n api: apiPort,\n auth: authPort,\n ui: uiPort,\n uiSsr: uiSsrPort,\n };\n for (const [id, port] of Object.entries(pluginApiPorts)) {\n claimPorts[`plugin:${id}`] = port;\n }\n for (const [id, port] of Object.entries(pluginUiPorts)) {\n claimPorts[`plugin-ui:${id}`] = port;\n }\n\n const claim: ClaimRecord = {\n resourceKey: `workspace:${wKey}`,\n pid: process.pid,\n configDir,\n ports: claimPorts,\n startedAt: Date.now(),\n };\n\n return { ports: resolved, claims: [claim], devPortsState };\n }).pipe(\n Effect.mapError(\n (portErr) =>\n new InfraError({\n phase: \"allocate-services\",\n message: `Port allocation failed: ${String(portErr)}`,\n cause: portErr,\n }),\n ),\n );\n}\n\nfunction allocateDatabases(\n runtimeConfig: RuntimeConfig,\n configDir: string,\n): Effect.Effect<\n {\n postgres: Record<string, number>;\n redis: Record<string, number>;\n dbs: DatabasePlan[];\n redisPlans: RedisPlan[];\n },\n InfraError,\n PortAllocator\n> {\n return Effect.gen(function* () {\n const persisted = loadPortState(configDir);\n const groups = getSecretGroups(runtimeConfig);\n const allSecrets = groups.flatMap((group) => group.secrets);\n const originMap = buildOriginMap(configDir, runtimeConfig);\n const allocator = yield* PortAllocator;\n\n const infraDatabases: DatabaseSecretConfig[] = yield* Effect.sync(() =>\n buildDatabaseConfigs(allSecrets, originMap, { ...persisted.postgresPorts }),\n );\n const infraRedis: RedisSecretConfig[] = yield* Effect.sync(() =>\n buildRedisConfigs(allSecrets, originMap, { ...persisted.redisPorts }),\n );\n\n const postgres: Record<string, number> = {};\n const dbs: DatabasePlan[] = [];\n for (const db of infraDatabases) {\n const port = yield* allocator.pickAvailable(db.port);\n postgres[db.slug] = port;\n dbs.push({\n secret: db.secret,\n slug: db.slug,\n port,\n dbName: db.databaseName,\n containerName: db.containerName,\n volumeName: db.volumeName,\n url: `postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@localhost:${port}/${db.slug}_db`,\n });\n }\n\n const redis: Record<string, number> = {};\n const redisPlans: RedisPlan[] = [];\n for (const r of infraRedis) {\n const port = yield* allocator.pickAvailable(r.port);\n redis[r.slug] = port;\n redisPlans.push({\n secret: r.secret,\n slug: r.slug,\n port,\n containerName: r.containerName,\n volumeName: r.volumeName,\n url: `redis://localhost:${port}`,\n });\n }\n\n return { postgres, redis, dbs, redisPlans };\n }).pipe(\n Effect.mapError(\n (portErr) =>\n new InfraError({\n phase: \"allocate-databases\",\n message: `Database port allocation failed: ${String(portErr)}`,\n cause: portErr,\n }),\n ),\n );\n}\n\nexport function buildServiceDescriptors(\n runtimeConfig: RuntimeConfig,\n resolvedPorts: ResolvedPorts,\n): ServiceDescriptorPlan[] {\n const descriptors: ServiceDescriptorPlan[] = [];\n\n if (runtimeConfig.host) {\n const isLocal = runtimeConfig.host.source === \"local\";\n descriptors.push({\n key: \"host\",\n source: runtimeConfig.host.source,\n url: isLocal ? `http://localhost:${resolvedPorts.host}` : runtimeConfig.host.url,\n port: isLocal ? resolvedPorts.host : undefined,\n localPath: isLocal ? runtimeConfig.host.localPath : undefined,\n });\n }\n\n if (runtimeConfig.api) {\n const isLocal = runtimeConfig.api.source === \"local\";\n descriptors.push({\n key: \"api\",\n source: runtimeConfig.api.source,\n url: isLocal ? `http://localhost:${resolvedPorts.api}` : runtimeConfig.api.url,\n port: isLocal ? resolvedPorts.api : undefined,\n localPath: isLocal ? runtimeConfig.api.localPath : undefined,\n });\n }\n\n if (runtimeConfig.auth) {\n const isLocal = runtimeConfig.auth.source === \"local\";\n descriptors.push({\n key: \"auth\",\n source: runtimeConfig.auth.source,\n url: isLocal ? `http://localhost:${resolvedPorts.auth}` : runtimeConfig.auth.url,\n port: isLocal ? resolvedPorts.auth : undefined,\n localPath: isLocal ? runtimeConfig.auth.localPath : undefined,\n });\n }\n\n if (runtimeConfig.ui) {\n const isLocal = runtimeConfig.ui.source === \"local\";\n descriptors.push({\n key: \"ui\",\n source: runtimeConfig.ui.source,\n url: isLocal ? `http://localhost:${resolvedPorts.ui}` : runtimeConfig.ui.url,\n port: isLocal ? resolvedPorts.ui : undefined,\n localPath: isLocal ? runtimeConfig.ui.localPath : undefined,\n });\n if (isLocal && resolvedPorts.uiSsr) {\n descriptors.push({\n key: \"ui-ssr\",\n source: \"local\",\n url: `http://localhost:${resolvedPorts.uiSsr}`,\n port: resolvedPorts.uiSsr,\n localPath: runtimeConfig.ui.localPath,\n });\n }\n }\n\n if (runtimeConfig.plugins) {\n for (const [pluginId, pluginCfg] of Object.entries(runtimeConfig.plugins)) {\n const pluginIsLocal = pluginCfg.source === \"local\";\n const p = resolvedPorts.plugins[pluginId];\n if (pluginIsLocal && p?.api) {\n descriptors.push({\n key: `plugin:${pluginId}`,\n source: \"local\",\n url: `http://localhost:${p.api}`,\n port: p.api,\n localPath: pluginCfg.localPath,\n });\n }\n if (pluginIsLocal && p?.ui && pluginCfg.ui?.source === \"local\") {\n descriptors.push({\n key: `plugin-ui:${pluginId}`,\n source: \"local\",\n url: `http://localhost:${p.ui}`,\n port: p.ui,\n localPath: pluginCfg.ui?.localPath,\n });\n }\n }\n }\n\n return descriptors;\n}\n\nexport function buildLaunchSpec(\n runtimeConfig: RuntimeConfig,\n resolvedPorts: ResolvedPorts,\n): RuntimeLaunchSpec {\n const hostPort =\n runtimeConfig.host?.source === \"local\" ? resolvedPorts.host : runtimeConfig.host?.port;\n const corsOrigin = hostPort ? `http://localhost:${hostPort}` : `http://localhost:3000`;\n\n return {\n port: resolvedPorts.host,\n hostUrl: runtimeConfig.host?.url,\n corsOrigin,\n env: {\n ...(resolvedPorts.host ? { PORT: String(resolvedPorts.host) } : {}),\n ...(resolvedPorts.api ? { API_PORT: String(resolvedPorts.api) } : {}),\n ...(resolvedPorts.ui ? { UI_PORT: String(resolvedPorts.ui) } : {}),\n ...(resolvedPorts.auth ? { AUTH_PORT: String(resolvedPorts.auth) } : {}),\n },\n runtimeConfig,\n };\n}\n\nexport function buildComposeModel(dbs: DatabasePlan[], redisPlans: RedisPlan[]): ComposeModelPlan {\n return { databases: dbs, redis: redisPlans };\n}\n\nexport function buildEnvGenerated(\n resolvedPorts: ResolvedPorts,\n dbs: DatabasePlan[],\n redisPlans: RedisPlan[],\n): Record<string, string> {\n const env: Record<string, string> = {};\n\n if (resolvedPorts.host) {\n env.CORS_ORIGIN = `http://localhost:${resolvedPorts.host}`;\n }\n\n for (const db of dbs) {\n env[db.secret] = db.url;\n }\n for (const r of redisPlans) {\n env[r.secret] = r.url;\n }\n\n return env;\n}\n\nexport function planInfra(input: InfraInput): Effect.Effect<InfraPlan, InfraError, PortAllocator> {\n return Effect.gen(function* () {\n const cliPorts = normalizeCliPorts(input.cli);\n const wKey = workspaceKey(input.configDir);\n\n const plugins = (input.bosConfig.plugins ?? {}) as Record<\n string,\n { source: string; localPath?: string; ui?: { source: string; localPath?: string } }\n >;\n\n const {\n ports: svcPorts,\n claims,\n devPortsState,\n } = yield* allocateServices(cliPorts, plugins, input.configDir);\n\n const {\n dbs,\n redisPlans,\n postgres: pgPorts,\n redis: rdPorts,\n } = yield* allocateDatabases(input.bosConfig, input.configDir);\n\n const resolvedPorts: ResolvedPorts = {\n ...svcPorts,\n postgres: pgPorts,\n redis: rdPorts,\n };\n\n // Write merged state once after all allocations succeed\n savePortState(input.configDir, {\n postgresPorts: pgPorts,\n redisPorts: rdPorts,\n devPorts: devPortsState,\n });\n\n const hostIsLocal = input.bosConfig.host?.source === \"local\";\n const apiIsLocal = input.bosConfig.api?.source === \"local\";\n const uiIsLocal = input.bosConfig.ui?.source === \"local\";\n const authIsLocal = input.bosConfig.auth?.source === \"local\";\n const assignedRuntimeConfig: RuntimeConfig = {\n ...input.bosConfig,\n host: resolvedPorts.host\n ? {\n ...input.bosConfig.host,\n port: resolvedPorts.host,\n url: `http://localhost:${resolvedPorts.host}`,\n remoteUrl: !hostIsLocal\n ? (input.bosConfig.host.remoteUrl ?? input.bosConfig.host.url)\n : undefined,\n }\n : input.bosConfig.host,\n api:\n apiIsLocal && resolvedPorts.api\n ? {\n ...input.bosConfig.api,\n port: resolvedPorts.api,\n url: `http://localhost:${resolvedPorts.api}`,\n }\n : input.bosConfig.api,\n ui:\n uiIsLocal && resolvedPorts.ui\n ? {\n ...input.bosConfig.ui,\n port: resolvedPorts.ui,\n url: `http://localhost:${resolvedPorts.ui}`,\n }\n : input.bosConfig.ui,\n auth:\n authIsLocal && resolvedPorts.auth && input.bosConfig.auth\n ? {\n ...input.bosConfig.auth,\n port: resolvedPorts.auth,\n url: `http://localhost:${resolvedPorts.auth}`,\n }\n : input.bosConfig.auth,\n plugins: input.bosConfig.plugins\n ? Object.fromEntries(\n Object.entries(input.bosConfig.plugins).map(([id, p]) => {\n const pluginPort = resolvedPorts.plugins[id];\n if (p.source === \"local\" && pluginPort?.api) {\n return [\n id,\n { ...p, port: pluginPort.api, url: `http://localhost:${pluginPort.api}` },\n ];\n }\n return [id, p];\n }),\n )\n : undefined,\n };\n\n const serviceDescriptors = buildServiceDescriptors(input.bosConfig, resolvedPorts);\n\n const launch = buildLaunchSpec(input.bosConfig, resolvedPorts);\n const composeModel = buildComposeModel(dbs, redisPlans);\n const envGenerated = buildEnvGenerated(resolvedPorts, dbs, redisPlans);\n\n const packages = serviceDescriptors.map((d) => d.key);\n const descriptionMap = new Map(serviceDescriptors.map((d) => [d.key, d]));\n const description = buildDescription(descriptionMap);\n\n const orchestrator = {\n packages,\n env: {},\n description,\n port: resolvedPorts.host,\n interactive: input.cli.interactive,\n };\n\n return {\n workspaceKey: wKey,\n cliPorts,\n resolvedPorts,\n runtimeConfig: assignedRuntimeConfig,\n launch,\n description,\n serviceDescriptors: new Map(serviceDescriptors.map((d) => [d.key, d])),\n envGenerated,\n composeModel,\n claims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