@companyhelm/cli 0.0.6 → 0.0.7

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.
@@ -1,13 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.registerCommands = registerCommands;
4
- const root_js_1 = require("./root.js");
4
+ const register_runner_commands_js_1 = require("./runner/register-runner-commands.js");
5
5
  const shell_js_1 = require("./shell.js");
6
6
  const register_sdk_commands_js_1 = require("./sdk/register-sdk-commands.js");
7
7
  const status_js_1 = require("./status.js");
8
8
  const register_thread_commands_js_1 = require("./thread/register-thread-commands.js");
9
9
  function registerCommands(program) {
10
- (0, root_js_1.registerRootCommand)(program);
10
+ (0, register_runner_commands_js_1.registerRunnerCommands)(program);
11
11
  (0, status_js_1.registerStatusCommand)(program);
12
12
  (0, register_thread_commands_js_1.registerThreadCommands)(program);
13
13
  (0, shell_js_1.registerShellCommand)(program);
@@ -33,6 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.toErrorMessage = toErrorMessage;
36
37
  exports.isRetryableApiConnectionError = isRetryableApiConnectionError;
37
38
  exports.formatApiConnectionFailureMessage = formatApiConnectionFailureMessage;
38
39
  exports.formatApiConnectionFailureDiagnostics = formatApiConnectionFailureDiagnostics;
@@ -42,9 +43,11 @@ exports.isNoRunningTurnInterruptError = isNoRunningTurnInterruptError;
42
43
  exports.normalizeThreadAgentApiUrlForRuntime = normalizeThreadAgentApiUrlForRuntime;
43
44
  exports.extractThreadNameUpdateFromNotification = extractThreadNameUpdateFromNotification;
44
45
  exports.extractServerMessageRequestId = extractServerMessageRequestId;
46
+ exports.isInternalDaemonChildProcess = isInternalDaemonChildProcess;
47
+ exports.runDetachedDaemonProcess = runDetachedDaemonProcess;
48
+ exports.sendDaemonParentMessage = sendDaemonParentMessage;
45
49
  exports.runRootCommand = runRootCommand;
46
50
  exports.buildRootConfig = buildRootConfig;
47
- exports.registerRootCommand = registerRootCommand;
48
51
  const protobuf_1 = require("@bufbuild/protobuf");
49
52
  const protos_1 = require("@companyhelm/protos");
50
53
  const drizzle_orm_1 = require("drizzle-orm");
@@ -2361,38 +2364,3 @@ function buildRootConfig(options) {
2361
2364
  thread_git_skills_directory: options.threadGitSkillsDirectory,
2362
2365
  });
2363
2366
  }
2364
- function registerRootCommand(program) {
2365
- program
2366
- .option("--config-path <path>", "Config directory override (defaults to ~/.config/companyhelm).")
2367
- .option("--server-url <url>", "CompanyHelm gRPC API URL override.")
2368
- .option("--agent-api-url <url>", "Agent gRPC API URL for companyhelm-agent in runtime containers (localhost is rewritten to http://host.docker.internal).")
2369
- .option("--secret <secret>", "Bearer secret used as gRPC Authorization header.")
2370
- .option("--state-db-path <path>", "State database path override (defaults to ~/.local/share/companyhelm/state.db).")
2371
- .option("--use-host-docker-runtime", "Mount host Docker socket into runtime containers instead of creating DinD sidecars.")
2372
- .option("--host-docker-path <path>", "Host Docker endpoint when --use-host-docker-runtime is enabled (unix:///<socket-path> or tcp://localhost:<port>).")
2373
- .option("--thread-git-skills-directory <path>", "Container path where thread git skill repositories are cloned before linking into ~/.codex/skills.")
2374
- .option("-d, --daemon", "Run in daemon mode and fail fast when no SDK is configured.")
2375
- .option("--log-level <level>", "Log level (DEBUG, INFO, WARN, ERROR).", "INFO")
2376
- .action(async () => {
2377
- const options = program.opts();
2378
- if (options.daemon && !isInternalDaemonChildProcess()) {
2379
- await runDetachedDaemonProcess(options);
2380
- return;
2381
- }
2382
- try {
2383
- await runRootCommand(options, isInternalDaemonChildProcess()
2384
- ? {
2385
- onDaemonReady: () => {
2386
- sendDaemonParentMessage({ type: "daemon-ready" });
2387
- },
2388
- }
2389
- : undefined);
2390
- }
2391
- catch (error) {
2392
- if (isInternalDaemonChildProcess()) {
2393
- sendDaemonParentMessage({ type: "daemon-error", message: toErrorMessage(error) });
2394
- }
2395
- throw error;
2396
- }
2397
- });
2398
- }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addRunnerStartOptions = addRunnerStartOptions;
4
+ function addRunnerStartOptions(command) {
5
+ return command
6
+ .option("--config-path <path>", "Config directory override (defaults to ~/.config/companyhelm).")
7
+ .option("--server-url <url>", "CompanyHelm gRPC API URL override.")
8
+ .option("--agent-api-url <url>", "Agent gRPC API URL for companyhelm-agent in runtime containers (localhost is rewritten to http://host.docker.internal).")
9
+ .option("--secret <secret>", "Bearer secret used as gRPC Authorization header.")
10
+ .option("--state-db-path <path>", "State database path override (defaults to ~/.local/share/companyhelm/state.db).")
11
+ .option("--use-host-docker-runtime", "Mount host Docker socket into runtime containers instead of creating DinD sidecars.")
12
+ .option("--host-docker-path <path>", "Host Docker endpoint when --use-host-docker-runtime is enabled (unix:///<socket-path> or tcp://localhost:<port>).")
13
+ .option("--thread-git-skills-directory <path>", "Container path where thread git skill repositories are cloned before linking into ~/.codex/skills.")
14
+ .option("-d, --daemon", "Run in daemon mode and fail fast when no SDK is configured.")
15
+ .option("--log-level <level>", "Log level (DEBUG, INFO, WARN, ERROR).", "INFO");
16
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.registerRunnerCommands = registerRunnerCommands;
4
+ const start_js_1 = require("./start.js");
5
+ const stop_js_1 = require("./stop.js");
6
+ function registerRunnerCommands(program) {
7
+ const runnerCommand = program
8
+ .command("runner")
9
+ .description("Manage the local CompanyHelm runner daemon.");
10
+ (0, start_js_1.registerRunnerStartCommand)(runnerCommand);
11
+ (0, stop_js_1.registerRunnerStopCommand)(runnerCommand);
12
+ }
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.registerRunnerStartCommand = registerRunnerStartCommand;
4
+ const root_js_1 = require("../root.js");
5
+ const common_js_1 = require("./common.js");
6
+ function registerRunnerStartCommand(runnerCommand) {
7
+ (0, common_js_1.addRunnerStartOptions)(runnerCommand
8
+ .command("start")
9
+ .description("Start the local CompanyHelm runner daemon.")).action(async (options) => {
10
+ if (options.daemon && !(0, root_js_1.isInternalDaemonChildProcess)()) {
11
+ await (0, root_js_1.runDetachedDaemonProcess)(options);
12
+ return;
13
+ }
14
+ try {
15
+ await (0, root_js_1.runRootCommand)(options, (0, root_js_1.isInternalDaemonChildProcess)()
16
+ ? {
17
+ onDaemonReady: () => {
18
+ (0, root_js_1.sendDaemonParentMessage)({ type: "daemon-ready" });
19
+ },
20
+ }
21
+ : undefined);
22
+ }
23
+ catch (error) {
24
+ if ((0, root_js_1.isInternalDaemonChildProcess)()) {
25
+ (0, root_js_1.sendDaemonParentMessage)({ type: "daemon-error", message: (0, root_js_1.toErrorMessage)(error) });
26
+ }
27
+ throw error;
28
+ }
29
+ });
30
+ }
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.runRunnerStopCommand = runRunnerStopCommand;
4
+ exports.registerRunnerStopCommand = registerRunnerStopCommand;
5
+ const config_js_1 = require("../../config.js");
6
+ const daemon_state_js_1 = require("../../state/daemon_state.js");
7
+ const process_js_1 = require("../../utils/process.js");
8
+ const root_js_1 = require("../root.js");
9
+ const RUNNER_STOP_TIMEOUT_MS = 15000;
10
+ async function waitForProcessExit(pid, timeoutMs) {
11
+ const deadline = Date.now() + timeoutMs;
12
+ while (Date.now() < deadline) {
13
+ if (!(0, process_js_1.isProcessRunning)(pid)) {
14
+ return true;
15
+ }
16
+ await new Promise((resolve) => setTimeout(resolve, 100));
17
+ }
18
+ return !(0, process_js_1.isProcessRunning)(pid);
19
+ }
20
+ async function runRunnerStopCommand(options) {
21
+ const cfg = config_js_1.config.parse({
22
+ state_db_path: options.stateDbPath,
23
+ });
24
+ const state = await (0, daemon_state_js_1.readCurrentDaemonState)(cfg.state_db_path);
25
+ if (!state?.pid) {
26
+ console.log("CompanyHelm runner is not running.");
27
+ return;
28
+ }
29
+ if (!(0, process_js_1.isProcessRunning)(state.pid)) {
30
+ await (0, daemon_state_js_1.clearCurrentDaemonState)(cfg.state_db_path, state.pid);
31
+ console.log(`CompanyHelm runner was not running. Cleared stale pid ${state.pid}.`);
32
+ return;
33
+ }
34
+ try {
35
+ process.kill(state.pid, "SIGTERM");
36
+ }
37
+ catch (error) {
38
+ throw new Error(`Failed to stop CompanyHelm runner pid ${state.pid}: ${(0, root_js_1.toErrorMessage)(error)}`);
39
+ }
40
+ const stopped = await waitForProcessExit(state.pid, RUNNER_STOP_TIMEOUT_MS);
41
+ if (!stopped) {
42
+ throw new Error(`Timed out waiting for CompanyHelm runner pid ${state.pid} to stop.`);
43
+ }
44
+ await (0, daemon_state_js_1.clearCurrentDaemonState)(cfg.state_db_path, state.pid);
45
+ console.log(`CompanyHelm runner stopped (pid ${state.pid}).`);
46
+ }
47
+ function registerRunnerStopCommand(runnerCommand) {
48
+ runnerCommand
49
+ .command("stop")
50
+ .description("Stop the local CompanyHelm runner daemon.")
51
+ .option("--state-db-path <path>", "State database path override (defaults to ~/.local/share/companyhelm/state.db).")
52
+ .action(async (options) => {
53
+ await runRunnerStopCommand(options);
54
+ });
55
+ }
@@ -7,6 +7,7 @@ exports.registerShellCommand = registerShellCommand;
7
7
  const config_js_1 = require("../config.js");
8
8
  const db_js_1 = require("../state/db.js");
9
9
  const schema_js_1 = require("../state/schema.js");
10
+ const common_js_1 = require("./runner/common.js");
10
11
  const NON_OVERRIDABLE_DAEMON_OPTION_NAMES = new Set(["daemon", "serverUrl", "secret", "help"]);
11
12
  function resolveDaemonOptionValue(option, values) {
12
13
  const explicit = values[option.name];
@@ -22,7 +23,8 @@ function resolveDaemonOptionValue(option, values) {
22
23
  return undefined;
23
24
  }
24
25
  function getShellConfigurableDaemonOptions(program) {
25
- return program.options
26
+ const runnerStartCommand = (0, common_js_1.addRunnerStartOptions)(program.createCommand("start"));
27
+ return runnerStartCommand.options
26
28
  .filter((option) => {
27
29
  if (!option.long || option.hidden) {
28
30
  return false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@companyhelm/cli",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "description": "Run coding agents in fully isolated Docker sandboxes, locally.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {