@companyhelm/cli 0.4.1 → 0.4.2

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.
Files changed (124) hide show
  1. package/dist/cli_io_interface.d.ts +10 -0
  2. package/dist/cli_io_interface.js +2 -0
  3. package/dist/cli_io_interface.js.map +1 -0
  4. package/dist/companyhelm_cli.d.ts +20 -0
  5. package/dist/companyhelm_cli.js +73 -0
  6. package/dist/companyhelm_cli.js.map +1 -0
  7. package/dist/console_io.d.ts +9 -0
  8. package/dist/console_io.js +13 -0
  9. package/dist/console_io.js.map +1 -0
  10. package/dist/index.d.ts +2 -0
  11. package/dist/index.js +4 -0
  12. package/dist/index.js.map +1 -0
  13. package/package.json +20 -29
  14. package/LICENSE +0 -21
  15. package/README.md +0 -66
  16. package/dist/cli.d.ts +0 -2
  17. package/dist/cli.js +0 -39
  18. package/dist/commands/dependencies.d.ts +0 -28
  19. package/dist/commands/dependencies.js +0 -292
  20. package/dist/commands/down.d.ts +0 -3
  21. package/dist/commands/down.js +0 -5
  22. package/dist/commands/interactive.d.ts +0 -7
  23. package/dist/commands/interactive.js +0 -25
  24. package/dist/commands/logs.d.ts +0 -3
  25. package/dist/commands/logs.js +0 -14
  26. package/dist/commands/register-commands.d.ts +0 -3
  27. package/dist/commands/register-commands.js +0 -23
  28. package/dist/commands/reset.d.ts +0 -7
  29. package/dist/commands/reset.js +0 -51
  30. package/dist/commands/set-image-version.d.ts +0 -31
  31. package/dist/commands/set-image-version.js +0 -87
  32. package/dist/commands/setup-github-app.d.ts +0 -13
  33. package/dist/commands/setup-github-app.js +0 -233
  34. package/dist/commands/startup-preferences.d.ts +0 -3
  35. package/dist/commands/startup-preferences.js +0 -39
  36. package/dist/commands/status.d.ts +0 -3
  37. package/dist/commands/status.js +0 -7
  38. package/dist/commands/up.d.ts +0 -3
  39. package/dist/commands/up.js +0 -39
  40. package/dist/config/image_config.d.ts +0 -4
  41. package/dist/config/image_config.js +0 -4
  42. package/dist/core/bootstrap/DeploymentBootstrapper.d.ts +0 -15
  43. package/dist/core/bootstrap/DeploymentBootstrapper.js +0 -118
  44. package/dist/core/bootstrap/SeedSqlRenderer.d.ts +0 -12
  45. package/dist/core/bootstrap/SeedSqlRenderer.js +0 -44
  46. package/dist/core/config/ApiEnvFileWriter.d.ts +0 -8
  47. package/dist/core/config/ApiEnvFileWriter.js +0 -33
  48. package/dist/core/config/GithubAppConfig.d.ts +0 -6
  49. package/dist/core/config/GithubAppConfig.js +0 -26
  50. package/dist/core/config/GithubAppConfigStore.d.ts +0 -11
  51. package/dist/core/config/GithubAppConfigStore.js +0 -57
  52. package/dist/core/docker/ComposeTemplateRenderer.d.ts +0 -22
  53. package/dist/core/docker/ComposeTemplateRenderer.js +0 -66
  54. package/dist/core/docker/DockerStackManager.d.ts +0 -29
  55. package/dist/core/docker/DockerStackManager.js +0 -163
  56. package/dist/core/local/ApiLocalService.d.ts +0 -22
  57. package/dist/core/local/ApiLocalService.js +0 -65
  58. package/dist/core/local/LocalRepoSourceResolver.d.ts +0 -24
  59. package/dist/core/local/LocalRepoSourceResolver.js +0 -33
  60. package/dist/core/local/LocalServiceProcessManager.d.ts +0 -18
  61. package/dist/core/local/LocalServiceProcessManager.js +0 -83
  62. package/dist/core/local/WebLocalService.d.ts +0 -23
  63. package/dist/core/local/WebLocalService.js +0 -101
  64. package/dist/core/logs/LogsService.d.ts +0 -6
  65. package/dist/core/logs/LogsService.js +0 -14
  66. package/dist/core/process/CommandRunner.d.ts +0 -4
  67. package/dist/core/process/CommandRunner.js +0 -51
  68. package/dist/core/runner/RunnerSupervisor.d.ts +0 -29
  69. package/dist/core/runner/RunnerSupervisor.js +0 -90
  70. package/dist/core/runner/runner-bootstrap.d.ts +0 -2
  71. package/dist/core/runner/runner-bootstrap.js +0 -48
  72. package/dist/core/runtime/CliPackageMetadata.d.ts +0 -3
  73. package/dist/core/runtime/CliPackageMetadata.js +0 -8
  74. package/dist/core/runtime/CliRoot.d.ts +0 -2
  75. package/dist/core/runtime/CliRoot.js +0 -23
  76. package/dist/core/runtime/ImageCatalog.d.ts +0 -11
  77. package/dist/core/runtime/ImageCatalog.js +0 -16
  78. package/dist/core/runtime/ImageConfigStore.d.ts +0 -15
  79. package/dist/core/runtime/ImageConfigStore.js +0 -51
  80. package/dist/core/runtime/LocalConfigStore.d.ts +0 -16
  81. package/dist/core/runtime/LocalConfigStore.js +0 -50
  82. package/dist/core/runtime/ManagedImages.d.ts +0 -10
  83. package/dist/core/runtime/ManagedImages.js +0 -27
  84. package/dist/core/runtime/PortAllocator.d.ts +0 -9
  85. package/dist/core/runtime/PortAllocator.js +0 -20
  86. package/dist/core/runtime/PublicImageTagRegistry.d.ts +0 -17
  87. package/dist/core/runtime/PublicImageTagRegistry.js +0 -168
  88. package/dist/core/runtime/RuntimePaths.d.ts +0 -16
  89. package/dist/core/runtime/RuntimePaths.js +0 -43
  90. package/dist/core/runtime/RuntimeState.d.ts +0 -38
  91. package/dist/core/runtime/RuntimeState.js +0 -1
  92. package/dist/core/runtime/RuntimeStateStore.d.ts +0 -11
  93. package/dist/core/runtime/RuntimeStateStore.js +0 -81
  94. package/dist/core/runtime/Secrets.d.ts +0 -10
  95. package/dist/core/runtime/Secrets.js +0 -26
  96. package/dist/core/runtime/VersionCatalog.d.ts +0 -10
  97. package/dist/core/runtime/VersionCatalog.js +0 -21
  98. package/dist/core/services/ManagedServiceNames.d.ts +0 -5
  99. package/dist/core/services/ManagedServiceNames.js +0 -12
  100. package/dist/core/status/StatusService.d.ts +0 -19
  101. package/dist/core/status/StatusService.js +0 -30
  102. package/dist/core/ui/TerminalRenderer.d.ts +0 -17
  103. package/dist/core/ui/TerminalRenderer.js +0 -71
  104. package/dist/preflight/ApiPortPreflightCheck.d.ts +0 -6
  105. package/dist/preflight/ApiPortPreflightCheck.js +0 -10
  106. package/dist/preflight/DockerInstalledPreflightCheck.d.ts +0 -7
  107. package/dist/preflight/DockerInstalledPreflightCheck.js +0 -15
  108. package/dist/preflight/PortAvailabilityPreflightCheck.d.ts +0 -7
  109. package/dist/preflight/PortAvailabilityPreflightCheck.js +0 -31
  110. package/dist/preflight/PostgresPortPreflightCheck.d.ts +0 -6
  111. package/dist/preflight/PostgresPortPreflightCheck.js +0 -10
  112. package/dist/preflight/PreflightCheck.d.ts +0 -3
  113. package/dist/preflight/PreflightCheck.js +0 -1
  114. package/dist/preflight/WebPortPreflightCheck.d.ts +0 -6
  115. package/dist/preflight/WebPortPreflightCheck.js +0 -10
  116. package/dist/preflight/runStartupPreflightChecks.d.ts +0 -18
  117. package/dist/preflight/runStartupPreflightChecks.js +0 -42
  118. package/dist/templates/api.env.tpl +0 -3
  119. package/dist/templates/docker-compose.yaml.tpl +0 -24
  120. package/dist/templates/seed.sql.tpl +0 -76
  121. package/src/config/image_config.ts +0 -4
  122. package/src/templates/api.env.tpl +0 -3
  123. package/src/templates/docker-compose.yaml.tpl +0 -24
  124. package/src/templates/seed.sql.tpl +0 -76
@@ -1,101 +0,0 @@
1
- import fs from "node:fs";
2
- import net from "node:net";
3
- import { LocalServiceProcessManager } from "./LocalServiceProcessManager.js";
4
- import { CommandRunner } from "../process/CommandRunner.js";
5
- export class WebLocalService {
6
- processManager;
7
- commandRunner;
8
- static SERVICE_NAME = "companyhelm-web";
9
- constructor(processManager = new LocalServiceProcessManager(), commandRunner = new CommandRunner()) {
10
- this.processManager = processManager;
11
- this.commandRunner = commandRunner;
12
- }
13
- async start(input) {
14
- await this.assertUiPortAvailable(input.uiPort);
15
- await this.ensureNodeModules(input.repoPath);
16
- await this.commandRunner.run("npm", ["run", "config:generate", "--", "--config-path", input.configPath], input.repoPath, {
17
- APP_ENV: "local"
18
- });
19
- const runtime = this.processManager.start({
20
- serviceName: WebLocalService.SERVICE_NAME,
21
- repoPath: input.repoPath,
22
- command: process.execPath,
23
- args: [
24
- "./node_modules/vite/bin/vite.js",
25
- "dev",
26
- "--host",
27
- "0.0.0.0",
28
- "--port",
29
- String(input.uiPort)
30
- ],
31
- logPath: input.logPath,
32
- env: {
33
- APP_ENV: "local",
34
- COMPANYHELM_LOG_LEVEL: input.logLevel,
35
- npm_config_loglevel: input.logLevel
36
- }
37
- });
38
- await this.waitForReadiness(input.url, runtime);
39
- return runtime;
40
- }
41
- async ensureNodeModules(repoPath) {
42
- if (fs.existsSync(`${repoPath}/node_modules`)) {
43
- return;
44
- }
45
- await this.commandRunner.run("npm", ["install"], repoPath);
46
- }
47
- async waitForReadiness(url, runtime) {
48
- const deadline = Date.now() + 60_000;
49
- while (Date.now() < deadline) {
50
- if (!this.processManager.isRunning(runtime)) {
51
- throw new Error(this.buildStartupFailureMessage(runtime, `${WebLocalService.SERVICE_NAME} exited before becoming ready.`));
52
- }
53
- try {
54
- const response = await fetch(url);
55
- if (response.ok) {
56
- return;
57
- }
58
- }
59
- catch {
60
- // Retry until the deadline.
61
- }
62
- await new Promise((resolve) => {
63
- setTimeout(resolve, 1000);
64
- });
65
- }
66
- throw new Error(`companyhelm-web did not become ready: ${url}`);
67
- }
68
- async assertUiPortAvailable(port) {
69
- await new Promise((resolve, reject) => {
70
- const server = net.createServer();
71
- server.once("error", (error) => {
72
- if (error.code === "EADDRINUSE") {
73
- reject(new Error(`companyhelm-web cannot start because port ${port} is already in use.`));
74
- return;
75
- }
76
- reject(new Error(`companyhelm-web cannot verify port ${port}: ${error.message}`));
77
- });
78
- server.once("listening", () => {
79
- server.close((closeError) => {
80
- if (closeError) {
81
- reject(closeError);
82
- return;
83
- }
84
- resolve();
85
- });
86
- });
87
- server.listen(port, "0.0.0.0");
88
- });
89
- }
90
- buildStartupFailureMessage(runtime, summary) {
91
- if (!fs.existsSync(runtime.logPath)) {
92
- return summary;
93
- }
94
- const startupLog = fs.readFileSync(runtime.logPath, "utf8").trim();
95
- if (!startupLog) {
96
- return summary;
97
- }
98
- const tail = startupLog.split(/\r?\n/).slice(-20).join("\n");
99
- return `${summary}\nStartup log:\n${tail}`;
100
- }
101
- }
@@ -1,6 +0,0 @@
1
- import { type ManagedServiceKey } from "../services/ManagedServiceNames.js";
2
- export declare class LogsService {
3
- private readonly streamServiceLogs;
4
- constructor(streamServiceLogs: (service: ManagedServiceKey) => Promise<void>);
5
- stream(service: string): Promise<void>;
6
- }
@@ -1,14 +0,0 @@
1
- import { AVAILABLE_MANAGED_SERVICE_NAMES, resolveManagedServiceKey } from "../services/ManagedServiceNames.js";
2
- export class LogsService {
3
- streamServiceLogs;
4
- constructor(streamServiceLogs) {
5
- this.streamServiceLogs = streamServiceLogs;
6
- }
7
- async stream(service) {
8
- const resolvedService = resolveManagedServiceKey(service);
9
- if (!resolvedService) {
10
- throw new Error(`Unknown service '${service}'. Expected one of: ${AVAILABLE_MANAGED_SERVICE_NAMES.join(", ")}`);
11
- }
12
- await this.streamServiceLogs(resolvedService);
13
- }
14
- }
@@ -1,4 +0,0 @@
1
- export declare class CommandRunner {
2
- run(command: string, args: string[], cwd?: string, env?: NodeJS.ProcessEnv): Promise<void>;
3
- capture(command: string, args: string[], cwd?: string, env?: NodeJS.ProcessEnv): Promise<string>;
4
- }
@@ -1,51 +0,0 @@
1
- import { spawn } from "node:child_process";
2
- export class CommandRunner {
3
- run(command, args, cwd, env) {
4
- return new Promise((resolve, reject) => {
5
- const child = spawn(command, args, {
6
- cwd,
7
- env: {
8
- ...process.env,
9
- ...env
10
- },
11
- stdio: "inherit"
12
- });
13
- child.on("error", reject);
14
- child.on("exit", (code) => {
15
- if (code === 0) {
16
- resolve();
17
- return;
18
- }
19
- reject(new Error(`${command} exited with code ${code ?? "unknown"}`));
20
- });
21
- });
22
- }
23
- capture(command, args, cwd, env) {
24
- return new Promise((resolve, reject) => {
25
- const child = spawn(command, args, {
26
- cwd,
27
- env: {
28
- ...process.env,
29
- ...env
30
- },
31
- stdio: ["ignore", "pipe", "pipe"]
32
- });
33
- let stdout = "";
34
- let stderr = "";
35
- child.stdout.on("data", (chunk) => {
36
- stdout += String(chunk);
37
- });
38
- child.stderr.on("data", (chunk) => {
39
- stderr += String(chunk);
40
- });
41
- child.on("error", reject);
42
- child.on("exit", (code) => {
43
- if (code === 0) {
44
- resolve(stdout);
45
- return;
46
- }
47
- reject(new Error(stderr || `${command} exited with code ${code ?? "unknown"}`));
48
- });
49
- });
50
- }
51
- }
@@ -1,29 +0,0 @@
1
- import type { LogLevel } from "../../commands/dependencies.js";
2
- import type { AgentWorkspaceMode } from "../runtime/LocalConfigStore.js";
3
- export interface RunnerStartInput {
4
- serverUrl: string;
5
- agentApiUrl: string;
6
- logPath: string;
7
- secret: string;
8
- logLevel?: LogLevel;
9
- useHostDockerRuntime?: boolean;
10
- workspaceMode?: AgentWorkspaceMode;
11
- projectRoot?: string;
12
- }
13
- export interface RunnerStartCommand {
14
- command: string;
15
- args: string[];
16
- env?: NodeJS.ProcessEnv;
17
- }
18
- export declare class RunnerSupervisor {
19
- private readonly configPath;
20
- constructor(configPath: string);
21
- buildUseHostAuthArgs(): RunnerStartCommand;
22
- buildStartArgs(input: RunnerStartInput): RunnerStartCommand;
23
- buildStopArgs(): RunnerStartCommand;
24
- buildStatusArgs(): RunnerStartCommand;
25
- private resolveRunnerCliPath;
26
- private resolveRunnerCliOverridePath;
27
- private resolveRunnerEntrypointPath;
28
- private resolveHostDockerPath;
29
- }
@@ -1,90 +0,0 @@
1
- import path from "node:path";
2
- import { createRequire } from "node:module";
3
- import { fileURLToPath } from "node:url";
4
- const require = createRequire(import.meta.url);
5
- const DEFAULT_HOST_DOCKER_PATH = "unix:///var/run/docker.sock";
6
- export class RunnerSupervisor {
7
- configPath;
8
- constructor(configPath) {
9
- this.configPath = configPath;
10
- }
11
- buildUseHostAuthArgs() {
12
- const runnerCliPath = this.resolveRunnerCliPath();
13
- return {
14
- command: process.execPath,
15
- args: [runnerCliPath, "--config-path", this.configPath, "sdk", "codex", "use-host-auth"]
16
- };
17
- }
18
- buildStartArgs(input) {
19
- const logLevel = (input.logLevel ?? "info").toUpperCase();
20
- const hostDockerArgs = input.useHostDockerRuntime
21
- ? ["--use-host-docker-runtime", "--host-docker-path", this.resolveHostDockerPath()]
22
- : [];
23
- const runnerEntrypoint = this.resolveRunnerEntrypointPath();
24
- const runnerCliOverridePath = this.resolveRunnerCliOverridePath();
25
- const env = input.workspaceMode === "current-working-directory" && input.projectRoot
26
- ? {
27
- COMPANYHELM_RUNNER_WORKSPACE_MODE: input.workspaceMode,
28
- COMPANYHELM_RUNNER_PROJECT_ROOT: input.projectRoot,
29
- }
30
- : undefined;
31
- return {
32
- command: process.execPath,
33
- args: [
34
- runnerEntrypoint,
35
- ...(runnerCliOverridePath ? [runnerCliOverridePath] : []),
36
- "--config-path",
37
- this.configPath,
38
- "start",
39
- "--daemon",
40
- "--server-url",
41
- input.serverUrl,
42
- "--agent-api-url",
43
- input.agentApiUrl,
44
- "--log-path",
45
- input.logPath,
46
- ...hostDockerArgs,
47
- "--secret",
48
- input.secret,
49
- "--log-level",
50
- logLevel
51
- ],
52
- env
53
- };
54
- }
55
- buildStopArgs() {
56
- const runnerCliPath = this.resolveRunnerCliPath();
57
- return {
58
- command: process.execPath,
59
- args: [runnerCliPath, "--config-path", this.configPath, "stop"]
60
- };
61
- }
62
- buildStatusArgs() {
63
- const runnerCliPath = this.resolveRunnerCliPath();
64
- return {
65
- command: process.execPath,
66
- args: [runnerCliPath, "--config-path", this.configPath, "status"]
67
- };
68
- }
69
- resolveRunnerCliPath() {
70
- if (process.env.COMPANYHELM_RUNNER_CLI_PATH) {
71
- return process.env.COMPANYHELM_RUNNER_CLI_PATH;
72
- }
73
- const packageJsonPath = require.resolve("@companyhelm/runner/package.json");
74
- return path.resolve(path.dirname(packageJsonPath), "dist/cli.js");
75
- }
76
- resolveRunnerCliOverridePath() {
77
- const overridePath = String(process.env.COMPANYHELM_RUNNER_CLI_PATH || "").trim();
78
- return overridePath || null;
79
- }
80
- resolveRunnerEntrypointPath() {
81
- return path.resolve(path.dirname(fileURLToPath(import.meta.url)), "runner-bootstrap.js");
82
- }
83
- resolveHostDockerPath() {
84
- const dockerHost = String(process.env.DOCKER_HOST || "").trim();
85
- if (dockerHost) {
86
- return dockerHost;
87
- }
88
- return DEFAULT_HOST_DOCKER_PATH;
89
- }
90
- }
@@ -1,2 +0,0 @@
1
- export declare function resolveRunnerCliEntrypointArg(argv: string[]): string | null;
2
- export declare function runRunnerBootstrap(): Promise<void>;
@@ -1,48 +0,0 @@
1
- import path from "node:path";
2
- import { createRequire } from "node:module";
3
- import { pathToFileURL } from "node:url";
4
- const require = createRequire(import.meta.url);
5
- function applyCurrentWorkingDirectoryMode(projectRoot) {
6
- const resolvedProjectRoot = path.resolve(projectRoot);
7
- const fsModule = require("node:fs");
8
- const originalRmSync = fsModule.rmSync.bind(fsModule);
9
- fsModule.rmSync = ((target, options) => {
10
- if (path.resolve(String(target)) === resolvedProjectRoot) {
11
- return;
12
- }
13
- return originalRmSync(target, options);
14
- });
15
- const configModule = require("@companyhelm/runner/dist/config.js");
16
- const originalParse = configModule.config.parse.bind(configModule.config);
17
- configModule.config.parse = ((input = {}) => originalParse({
18
- ...input,
19
- workspaces_directory: resolvedProjectRoot
20
- }));
21
- const threadLifecycle = require("@companyhelm/runner/dist/service/thread_lifecycle.js");
22
- threadLifecycle.resolveThreadDirectory = (() => resolvedProjectRoot);
23
- }
24
- export function resolveRunnerCliEntrypointArg(argv) {
25
- const candidate = String(argv[2] || "").trim();
26
- if (!candidate || candidate.startsWith("-")) {
27
- return null;
28
- }
29
- return candidate;
30
- }
31
- const workspaceMode = String(process.env.COMPANYHELM_RUNNER_WORKSPACE_MODE || "").trim();
32
- const projectRoot = String(process.env.COMPANYHELM_RUNNER_PROJECT_ROOT || "").trim();
33
- export async function runRunnerBootstrap() {
34
- if (workspaceMode === "current-working-directory" && projectRoot) {
35
- applyCurrentWorkingDirectoryMode(projectRoot);
36
- }
37
- const runnerEntrypoint = resolveRunnerCliEntrypointArg(process.argv);
38
- if (runnerEntrypoint) {
39
- process.argv.splice(2, 1);
40
- }
41
- await import(runnerEntrypoint ? pathToFileURL(runnerEntrypoint).href : "@companyhelm/runner/dist/cli.js");
42
- }
43
- const invokedAsEntrypoint = process.argv[1]
44
- ? pathToFileURL(path.resolve(process.argv[1])).href === import.meta.url
45
- : false;
46
- if (invokedAsEntrypoint) {
47
- await runRunnerBootstrap();
48
- }
@@ -1,3 +0,0 @@
1
- export declare class CliPackageMetadata {
2
- version(): string;
3
- }
@@ -1,8 +0,0 @@
1
- import { readFileSync } from "node:fs";
2
- export class CliPackageMetadata {
3
- version() {
4
- const manifestPath = new URL("../../../package.json", import.meta.url);
5
- const manifest = JSON.parse(readFileSync(manifestPath, "utf8"));
6
- return manifest.version;
7
- }
8
- }
@@ -1,2 +0,0 @@
1
- export declare function defaultCliRoot(): string;
2
- export declare function defaultCliConfigRoot(): string;
@@ -1,23 +0,0 @@
1
- import os from "node:os";
2
- import path from "node:path";
3
- function defaultCliBaseRoot() {
4
- return path.join(os.homedir(), ".companyhelm", "cli");
5
- }
6
- export function defaultCliRoot() {
7
- const explicitRoot = String(process.env.COMPANYHELM_HOME || "").trim();
8
- if (explicitRoot) {
9
- return path.resolve(explicitRoot);
10
- }
11
- return path.join(defaultCliBaseRoot(), "runtime");
12
- }
13
- export function defaultCliConfigRoot() {
14
- const explicitRoot = String(process.env.COMPANYHELM_CONFIG_HOME || "").trim();
15
- if (explicitRoot) {
16
- return path.resolve(explicitRoot);
17
- }
18
- const explicitRuntimeRoot = String(process.env.COMPANYHELM_HOME || "").trim();
19
- if (explicitRuntimeRoot) {
20
- return path.resolve(explicitRuntimeRoot);
21
- }
22
- return defaultCliBaseRoot();
23
- }
@@ -1,11 +0,0 @@
1
- import { ImageConfigStore } from "./ImageConfigStore.js";
2
- export interface RuntimeImages {
3
- api: string;
4
- frontend: string;
5
- postgres: string;
6
- }
7
- export declare class ImageCatalog {
8
- private readonly configStore;
9
- constructor(configStore?: ImageConfigStore);
10
- resolve(): RuntimeImages;
11
- }
@@ -1,16 +0,0 @@
1
- import { defaultManagedImageReference } from "./ManagedImages.js";
2
- import { ImageConfigStore } from "./ImageConfigStore.js";
3
- export class ImageCatalog {
4
- configStore;
5
- constructor(configStore = new ImageConfigStore()) {
6
- this.configStore = configStore;
7
- }
8
- resolve() {
9
- const configuredImages = this.configStore.load().images;
10
- return {
11
- api: process.env.COMPANYHELM_API_IMAGE || configuredImages.api || defaultManagedImageReference("api"),
12
- frontend: process.env.COMPANYHELM_WEB_IMAGE || configuredImages.frontend || defaultManagedImageReference("frontend"),
13
- postgres: process.env.COMPANYHELM_POSTGRES_IMAGE || "postgres:16-alpine"
14
- };
15
- }
16
- }
@@ -1,15 +0,0 @@
1
- import { type ManagedImageService } from "./ManagedImages.js";
2
- export interface ImageConfig {
3
- images: Partial<Record<ManagedImageService, string>>;
4
- }
5
- export declare class ImageConfigStore {
6
- private readonly root;
7
- constructor(root?: string);
8
- configPath(): string;
9
- load(): ImageConfig;
10
- setImage(service: ManagedImageService, image: string): {
11
- configPath: string;
12
- image: string;
13
- };
14
- save(config: ImageConfig): void;
15
- }
@@ -1,51 +0,0 @@
1
- import fs from "node:fs";
2
- import path from "node:path";
3
- import { fileURLToPath } from "node:url";
4
- import { MANAGED_IMAGE_SERVICES, defaultManagedImageReference } from "./ManagedImages.js";
5
- const __filename = fileURLToPath(import.meta.url);
6
- const __dirname = path.dirname(__filename);
7
- function defaultPackageRoot() {
8
- return path.resolve(__dirname, "../../..");
9
- }
10
- export class ImageConfigStore {
11
- root;
12
- constructor(root = defaultPackageRoot()) {
13
- this.root = root;
14
- }
15
- configPath() {
16
- return path.join(this.root, "src", "config", "image_config.ts");
17
- }
18
- load() {
19
- const configPath = this.configPath();
20
- if (!fs.existsSync(configPath)) {
21
- return { images: {} };
22
- }
23
- const images = {};
24
- for (const rawLine of fs.readFileSync(configPath, "utf8").split(/\r?\n/)) {
25
- const match = rawLine.match(/^\s+(api|frontend):\s+"([^"]+)",?$/);
26
- if (match) {
27
- images[match[1]] = match[2];
28
- }
29
- }
30
- return { images };
31
- }
32
- setImage(service, image) {
33
- const nextConfig = this.load();
34
- nextConfig.images[service] = image;
35
- this.save(nextConfig);
36
- return { configPath: this.configPath(), image };
37
- }
38
- save(config) {
39
- const lines = [
40
- "export const PACKAGED_IMAGE_CONFIG = {",
41
- ...MANAGED_IMAGE_SERVICES.map((service) => {
42
- const image = config.images[service] ?? defaultManagedImageReference(service);
43
- return ` ${service}: "${image}"`;
44
- }).map((line, index, all) => `${line}${index < all.length - 1 ? "," : ""}`),
45
- "} as const;",
46
- ""
47
- ];
48
- fs.mkdirSync(path.dirname(this.configPath()), { recursive: true });
49
- fs.writeFileSync(this.configPath(), lines.join("\n"), "utf8");
50
- }
51
- }
@@ -1,16 +0,0 @@
1
- export type AgentWorkspaceMode = "dedicated" | "current-working-directory";
2
- export interface LocalConfig {
3
- agentWorkspaceMode?: AgentWorkspaceMode;
4
- }
5
- export declare class LocalConfigStore {
6
- private readonly root;
7
- constructor(root?: string);
8
- configPath(): string;
9
- load(): LocalConfig;
10
- setAgentWorkspaceMode(agentWorkspaceMode: AgentWorkspaceMode): {
11
- configPath: string;
12
- agentWorkspaceMode: AgentWorkspaceMode;
13
- };
14
- save(config: LocalConfig): void;
15
- private parse;
16
- }
@@ -1,50 +0,0 @@
1
- import fs from "node:fs";
2
- import path from "node:path";
3
- import { defaultCliConfigRoot } from "./CliRoot.js";
4
- function defaultLocalConfigRoot() {
5
- return defaultCliConfigRoot();
6
- }
7
- export class LocalConfigStore {
8
- root;
9
- constructor(root = defaultLocalConfigRoot()) {
10
- this.root = root;
11
- }
12
- configPath() {
13
- return path.join(this.root, "config.yaml");
14
- }
15
- load() {
16
- const configPath = this.configPath();
17
- if (!fs.existsSync(configPath)) {
18
- return {};
19
- }
20
- return this.parse(fs.readFileSync(configPath, "utf8"));
21
- }
22
- setAgentWorkspaceMode(agentWorkspaceMode) {
23
- const nextConfig = this.load();
24
- nextConfig.agentWorkspaceMode = agentWorkspaceMode;
25
- this.save(nextConfig);
26
- return { configPath: this.configPath(), agentWorkspaceMode };
27
- }
28
- save(config) {
29
- const lines = [];
30
- if (config.agentWorkspaceMode) {
31
- lines.push(`agent_workspace_mode: ${config.agentWorkspaceMode}`);
32
- }
33
- fs.mkdirSync(path.dirname(this.configPath()), { recursive: true });
34
- fs.writeFileSync(this.configPath(), `${lines.join("\n")}\n`, "utf8");
35
- }
36
- parse(content) {
37
- let agentWorkspaceMode;
38
- for (const rawLine of content.split(/\r?\n/)) {
39
- const line = rawLine.trimEnd();
40
- if (line.trim().length === 0 || line.trimStart().startsWith("#")) {
41
- continue;
42
- }
43
- const workspaceModeMatch = line.match(/^agent_workspace_mode:\s*(dedicated|current-working-directory)$/);
44
- if (workspaceModeMatch) {
45
- agentWorkspaceMode = workspaceModeMatch[1];
46
- }
47
- }
48
- return { agentWorkspaceMode };
49
- }
50
- }
@@ -1,10 +0,0 @@
1
- export declare const MANAGED_IMAGE_SERVICES: readonly ["api", "frontend"];
2
- export type ManagedImageService = (typeof MANAGED_IMAGE_SERVICES)[number];
3
- export interface ManagedImageDefinition {
4
- imageUri: string;
5
- repositoryPath: string;
6
- }
7
- export declare function requireManagedImageService(value: string): ManagedImageService;
8
- export declare function getManagedImageDefinition(service: ManagedImageService): ManagedImageDefinition;
9
- export declare function buildManagedImageReference(service: ManagedImageService, tag: string): string;
10
- export declare function defaultManagedImageReference(service: ManagedImageService): string;
@@ -1,27 +0,0 @@
1
- export const MANAGED_IMAGE_SERVICES = ["api", "frontend"];
2
- const MANAGED_IMAGE_DEFINITIONS = {
3
- api: {
4
- imageUri: "public.ecr.aws/x6n0f2k4/companyhelm-api",
5
- repositoryPath: "x6n0f2k4/companyhelm-api"
6
- },
7
- frontend: {
8
- imageUri: "public.ecr.aws/x6n0f2k4/companyhelm-web",
9
- repositoryPath: "x6n0f2k4/companyhelm-web"
10
- }
11
- };
12
- export function requireManagedImageService(value) {
13
- const normalized = value.trim().toLowerCase();
14
- if (normalized === "api" || normalized === "frontend") {
15
- return normalized;
16
- }
17
- throw new Error(`Unsupported image service "${value}". Expected one of: api, frontend.`);
18
- }
19
- export function getManagedImageDefinition(service) {
20
- return MANAGED_IMAGE_DEFINITIONS[service];
21
- }
22
- export function buildManagedImageReference(service, tag) {
23
- return `${MANAGED_IMAGE_DEFINITIONS[service].imageUri}:${tag}`;
24
- }
25
- export function defaultManagedImageReference(service) {
26
- return buildManagedImageReference(service, "latest");
27
- }
@@ -1,9 +0,0 @@
1
- import type { RuntimePorts } from "./RuntimeState.js";
2
- export declare class PortAllocator {
3
- private readonly apiHttpPort;
4
- private readonly uiPort;
5
- private readonly runnerGrpcPort;
6
- private readonly agentCliGrpcPort;
7
- constructor(apiHttpPort?: number, uiPort?: number, runnerGrpcPort?: number, agentCliGrpcPort?: number);
8
- allocate(): RuntimePorts;
9
- }
@@ -1,20 +0,0 @@
1
- export class PortAllocator {
2
- apiHttpPort;
3
- uiPort;
4
- runnerGrpcPort;
5
- agentCliGrpcPort;
6
- constructor(apiHttpPort = 4000, uiPort = 4173, runnerGrpcPort = 50051, agentCliGrpcPort = 50052) {
7
- this.apiHttpPort = apiHttpPort;
8
- this.uiPort = uiPort;
9
- this.runnerGrpcPort = runnerGrpcPort;
10
- this.agentCliGrpcPort = agentCliGrpcPort;
11
- }
12
- allocate() {
13
- return {
14
- apiHttp: this.apiHttpPort,
15
- ui: this.uiPort,
16
- runnerGrpc: this.runnerGrpcPort,
17
- agentCliGrpc: this.agentCliGrpcPort
18
- };
19
- }
20
- }
@@ -1,17 +0,0 @@
1
- import { type ManagedImageService } from "./ManagedImages.js";
2
- interface PublicRegistryImageTag {
3
- tag: string;
4
- createdAt?: string;
5
- }
6
- export declare class PublicImageTagRegistry {
7
- listAvailableTags(service: ManagedImageService, limit?: number): Promise<PublicRegistryImageTag[]>;
8
- buildImageReference(service: ManagedImageService, tag: string): string;
9
- private fetchToken;
10
- private fetchCreatedAt;
11
- private selectManifestDigest;
12
- private fetchJson;
13
- private parseRetryAfterMs;
14
- private sleep;
15
- private mapWithConcurrency;
16
- }
17
- export {};