@otto-code/cli 0.5.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.
Files changed (200) hide show
  1. package/bin/otto +3 -0
  2. package/dist/classify.d.ts +19 -0
  3. package/dist/classify.js +49 -0
  4. package/dist/cli.d.ts +3 -0
  5. package/dist/cli.js +113 -0
  6. package/dist/commands/agent/archive.d.ts +18 -0
  7. package/dist/commands/agent/archive.js +102 -0
  8. package/dist/commands/agent/attach.d.ts +11 -0
  9. package/dist/commands/agent/attach.js +159 -0
  10. package/dist/commands/agent/delete.d.ts +15 -0
  11. package/dist/commands/agent/delete.js +107 -0
  12. package/dist/commands/agent/import.d.ts +14 -0
  13. package/dist/commands/agent/import.js +122 -0
  14. package/dist/commands/agent/index.d.ts +3 -0
  15. package/dist/commands/agent/index.js +48 -0
  16. package/dist/commands/agent/inspect.d.ts +15 -0
  17. package/dist/commands/agent/inspect.js +209 -0
  18. package/dist/commands/agent/logs.d.ts +19 -0
  19. package/dist/commands/agent/logs.js +180 -0
  20. package/dist/commands/agent/ls.d.ts +44 -0
  21. package/dist/commands/agent/ls.js +204 -0
  22. package/dist/commands/agent/mode.d.ts +18 -0
  23. package/dist/commands/agent/mode.js +100 -0
  24. package/dist/commands/agent/reload.d.ts +15 -0
  25. package/dist/commands/agent/reload.js +75 -0
  26. package/dist/commands/agent/run.d.ts +44 -0
  27. package/dist/commands/agent/run.js +464 -0
  28. package/dist/commands/agent/send.d.ts +19 -0
  29. package/dist/commands/agent/send.js +187 -0
  30. package/dist/commands/agent/stop.d.ts +17 -0
  31. package/dist/commands/agent/stop.js +115 -0
  32. package/dist/commands/agent/update.d.ts +18 -0
  33. package/dist/commands/agent/update.js +139 -0
  34. package/dist/commands/agent/wait.d.ts +17 -0
  35. package/dist/commands/agent/wait.js +158 -0
  36. package/dist/commands/chat/create.d.ts +9 -0
  37. package/dist/commands/chat/create.js +23 -0
  38. package/dist/commands/chat/delete.d.ts +6 -0
  39. package/dist/commands/chat/delete.js +20 -0
  40. package/dist/commands/chat/index.d.ts +3 -0
  41. package/dist/commands/chat/index.js +47 -0
  42. package/dist/commands/chat/inspect.d.ts +6 -0
  43. package/dist/commands/chat/inspect.js +20 -0
  44. package/dist/commands/chat/ls.d.ts +6 -0
  45. package/dist/commands/chat/ls.js +20 -0
  46. package/dist/commands/chat/post.d.ts +9 -0
  47. package/dist/commands/chat/post.js +28 -0
  48. package/dist/commands/chat/read.d.ts +11 -0
  49. package/dist/commands/chat/read.js +40 -0
  50. package/dist/commands/chat/schema.d.ts +36 -0
  51. package/dist/commands/chat/schema.js +81 -0
  52. package/dist/commands/chat/shared.d.ts +19 -0
  53. package/dist/commands/chat/shared.js +118 -0
  54. package/dist/commands/chat/wait.d.ts +9 -0
  55. package/dist/commands/chat/wait.js +45 -0
  56. package/dist/commands/daemon/index.d.ts +3 -0
  57. package/dist/commands/daemon/index.js +57 -0
  58. package/dist/commands/daemon/local-daemon.d.ts +78 -0
  59. package/dist/commands/daemon/local-daemon.js +544 -0
  60. package/dist/commands/daemon/pair.d.ts +9 -0
  61. package/dist/commands/daemon/pair.js +76 -0
  62. package/dist/commands/daemon/restart.d.ts +12 -0
  63. package/dist/commands/daemon/restart.js +99 -0
  64. package/dist/commands/daemon/runtime-toolchain.d.ts +6 -0
  65. package/dist/commands/daemon/runtime-toolchain.js +87 -0
  66. package/dist/commands/daemon/set-password.d.ts +17 -0
  67. package/dist/commands/daemon/set-password.js +82 -0
  68. package/dist/commands/daemon/start.d.ts +6 -0
  69. package/dist/commands/daemon/start.js +56 -0
  70. package/dist/commands/daemon/status.d.ts +10 -0
  71. package/dist/commands/daemon/status.js +338 -0
  72. package/dist/commands/daemon/stop.d.ts +15 -0
  73. package/dist/commands/daemon/stop.js +60 -0
  74. package/dist/commands/hooks.d.ts +19 -0
  75. package/dist/commands/hooks.js +89 -0
  76. package/dist/commands/loop/index.d.ts +3 -0
  77. package/dist/commands/loop/index.js +18 -0
  78. package/dist/commands/loop/inspect.d.ts +13 -0
  79. package/dist/commands/loop/inspect.js +100 -0
  80. package/dist/commands/loop/logs.d.ts +8 -0
  81. package/dist/commands/loop/logs.js +69 -0
  82. package/dist/commands/loop/ls.d.ts +18 -0
  83. package/dist/commands/loop/ls.js +62 -0
  84. package/dist/commands/loop/run.d.ts +30 -0
  85. package/dist/commands/loop/run.js +162 -0
  86. package/dist/commands/loop/stop.d.ts +15 -0
  87. package/dist/commands/loop/stop.js +56 -0
  88. package/dist/commands/loop/types.d.ts +138 -0
  89. package/dist/commands/loop/types.js +2 -0
  90. package/dist/commands/onboard.d.ts +10 -0
  91. package/dist/commands/onboard.js +416 -0
  92. package/dist/commands/open.d.ts +2 -0
  93. package/dist/commands/open.js +81 -0
  94. package/dist/commands/permit/allow.d.ts +20 -0
  95. package/dist/commands/permit/allow.js +133 -0
  96. package/dist/commands/permit/deny.d.ts +12 -0
  97. package/dist/commands/permit/deny.js +105 -0
  98. package/dist/commands/permit/index.d.ts +3 -0
  99. package/dist/commands/permit/index.js +27 -0
  100. package/dist/commands/permit/ls.d.ts +18 -0
  101. package/dist/commands/permit/ls.js +66 -0
  102. package/dist/commands/provider/index.d.ts +3 -0
  103. package/dist/commands/provider/index.js +16 -0
  104. package/dist/commands/provider/ls.d.ts +19 -0
  105. package/dist/commands/provider/ls.js +73 -0
  106. package/dist/commands/provider/models.d.ts +20 -0
  107. package/dist/commands/provider/models.js +53 -0
  108. package/dist/commands/schedule/create.d.ts +18 -0
  109. package/dist/commands/schedule/create.js +40 -0
  110. package/dist/commands/schedule/delete.d.ts +10 -0
  111. package/dist/commands/schedule/delete.js +32 -0
  112. package/dist/commands/schedule/index.d.ts +3 -0
  113. package/dist/commands/schedule/index.js +66 -0
  114. package/dist/commands/schedule/inspect.d.ts +6 -0
  115. package/dist/commands/schedule/inspect.js +24 -0
  116. package/dist/commands/schedule/logs.d.ts +6 -0
  117. package/dist/commands/schedule/logs.js +23 -0
  118. package/dist/commands/schedule/ls.d.ts +5 -0
  119. package/dist/commands/schedule/ls.js +23 -0
  120. package/dist/commands/schedule/pause.d.ts +5 -0
  121. package/dist/commands/schedule/pause.js +23 -0
  122. package/dist/commands/schedule/resume.d.ts +5 -0
  123. package/dist/commands/schedule/resume.js +23 -0
  124. package/dist/commands/schedule/run-once.d.ts +5 -0
  125. package/dist/commands/schedule/run-once.js +23 -0
  126. package/dist/commands/schedule/schema.d.ts +21 -0
  127. package/dist/commands/schedule/schema.js +67 -0
  128. package/dist/commands/schedule/shared.d.ts +56 -0
  129. package/dist/commands/schedule/shared.js +346 -0
  130. package/dist/commands/schedule/types.d.ts +168 -0
  131. package/dist/commands/schedule/types.js +2 -0
  132. package/dist/commands/schedule/update.d.ts +21 -0
  133. package/dist/commands/schedule/update.js +39 -0
  134. package/dist/commands/speech/index.d.ts +3 -0
  135. package/dist/commands/speech/index.js +5 -0
  136. package/dist/commands/terminal/capture.d.ts +10 -0
  137. package/dist/commands/terminal/capture.js +68 -0
  138. package/dist/commands/terminal/create.d.ts +10 -0
  139. package/dist/commands/terminal/create.js +38 -0
  140. package/dist/commands/terminal/index.d.ts +3 -0
  141. package/dist/commands/terminal/index.js +43 -0
  142. package/dist/commands/terminal/kill.d.ts +6 -0
  143. package/dist/commands/terminal/kill.js +36 -0
  144. package/dist/commands/terminal/ls.d.ts +10 -0
  145. package/dist/commands/terminal/ls.js +21 -0
  146. package/dist/commands/terminal/schema.d.ts +18 -0
  147. package/dist/commands/terminal/schema.js +23 -0
  148. package/dist/commands/terminal/send-keys.d.ts +7 -0
  149. package/dist/commands/terminal/send-keys.js +76 -0
  150. package/dist/commands/terminal/shared.d.ts +12 -0
  151. package/dist/commands/terminal/shared.js +61 -0
  152. package/dist/commands/worktree/archive.d.ts +20 -0
  153. package/dist/commands/worktree/archive.js +104 -0
  154. package/dist/commands/worktree/create-input.d.ts +15 -0
  155. package/dist/commands/worktree/create-input.js +56 -0
  156. package/dist/commands/worktree/create.d.ts +11 -0
  157. package/dist/commands/worktree/create.js +58 -0
  158. package/dist/commands/worktree/index.d.ts +3 -0
  159. package/dist/commands/worktree/index.js +25 -0
  160. package/dist/commands/worktree/ls.d.ts +19 -0
  161. package/dist/commands/worktree/ls.js +97 -0
  162. package/dist/index.d.ts +2 -0
  163. package/dist/index.js +6 -0
  164. package/dist/output/index.d.ts +45 -0
  165. package/dist/output/index.js +47 -0
  166. package/dist/output/json.d.ts +11 -0
  167. package/dist/output/json.js +37 -0
  168. package/dist/output/quiet.d.ts +9 -0
  169. package/dist/output/quiet.js +22 -0
  170. package/dist/output/render.d.ts +15 -0
  171. package/dist/output/render.js +83 -0
  172. package/dist/output/table.d.ts +13 -0
  173. package/dist/output/table.js +135 -0
  174. package/dist/output/types.d.ts +73 -0
  175. package/dist/output/types.js +8 -0
  176. package/dist/output/with-output.d.ts +41 -0
  177. package/dist/output/with-output.js +87 -0
  178. package/dist/output/yaml.d.ts +11 -0
  179. package/dist/output/yaml.js +38 -0
  180. package/dist/run.d.ts +14 -0
  181. package/dist/run.js +33 -0
  182. package/dist/utils/client-id.d.ts +2 -0
  183. package/dist/utils/client-id.js +37 -0
  184. package/dist/utils/client.d.ts +44 -0
  185. package/dist/utils/client.js +330 -0
  186. package/dist/utils/command-options.d.ts +6 -0
  187. package/dist/utils/command-options.js +17 -0
  188. package/dist/utils/duration.d.ts +7 -0
  189. package/dist/utils/duration.js +38 -0
  190. package/dist/utils/errors.d.ts +5 -0
  191. package/dist/utils/errors.js +10 -0
  192. package/dist/utils/paths.d.ts +12 -0
  193. package/dist/utils/paths.js +22 -0
  194. package/dist/utils/provider-model.d.ts +11 -0
  195. package/dist/utils/provider-model.js +49 -0
  196. package/dist/utils/timeline.d.ts +11 -0
  197. package/dist/utils/timeline.js +11 -0
  198. package/dist/version.d.ts +2 -0
  199. package/dist/version.js +10 -0
  200. package/package.json +48 -0
@@ -0,0 +1,99 @@
1
+ import { startLocalDaemonDetached, stopLocalDaemon, DEFAULT_STOP_TIMEOUT_MS, } from "./local-daemon.js";
2
+ const restartResultSchema = {
3
+ idField: "action",
4
+ columns: [
5
+ {
6
+ header: "STATUS",
7
+ field: "action",
8
+ color: () => "green",
9
+ },
10
+ { header: "HOME", field: "home" },
11
+ { header: "PID", field: "pid" },
12
+ { header: "MESSAGE", field: "message" },
13
+ ],
14
+ };
15
+ function parseTimeoutMs(raw) {
16
+ if (typeof raw !== "string" || raw.trim().length === 0) {
17
+ return DEFAULT_STOP_TIMEOUT_MS;
18
+ }
19
+ const seconds = Number(raw);
20
+ if (!Number.isFinite(seconds) || seconds <= 0) {
21
+ const error = {
22
+ code: "INVALID_TIMEOUT",
23
+ message: `Invalid timeout value: ${raw}`,
24
+ details: "Timeout must be a positive number of seconds",
25
+ };
26
+ throw error;
27
+ }
28
+ return Math.ceil(seconds * 1000);
29
+ }
30
+ function toStartOptions(options) {
31
+ const startOptions = {
32
+ home: typeof options.home === "string" ? options.home : undefined,
33
+ listen: typeof options.listen === "string" ? options.listen : undefined,
34
+ port: typeof options.port === "string" ? options.port : undefined,
35
+ relay: typeof options.relay === "boolean" ? options.relay : undefined,
36
+ mcp: typeof options.mcp === "boolean" ? options.mcp : undefined,
37
+ injectMcp: typeof options.injectMcp === "boolean" ? options.injectMcp : undefined,
38
+ webUi: typeof options.webUi === "boolean" ? options.webUi : undefined,
39
+ hostnames: typeof options.hostnames === "string" ? options.hostnames : undefined,
40
+ };
41
+ if (startOptions.listen && startOptions.port) {
42
+ const error = {
43
+ code: "INVALID_OPTIONS",
44
+ message: "Cannot use --listen and --port together",
45
+ };
46
+ throw error;
47
+ }
48
+ return startOptions;
49
+ }
50
+ export async function runRestartCommand(options, _command) {
51
+ const timeoutMs = parseTimeoutMs(options.timeout);
52
+ const force = options.force === true;
53
+ const startOptions = toStartOptions(options);
54
+ try {
55
+ let stopResult;
56
+ try {
57
+ stopResult = await stopLocalDaemon({
58
+ home: startOptions.home,
59
+ timeoutMs,
60
+ force,
61
+ });
62
+ }
63
+ catch (err) {
64
+ const isTimeout = err instanceof Error && err.message.includes("Timed out waiting for daemon PID");
65
+ if (!force && isTimeout) {
66
+ stopResult = await stopLocalDaemon({
67
+ home: startOptions.home,
68
+ timeoutMs,
69
+ force: true,
70
+ });
71
+ }
72
+ else {
73
+ throw err;
74
+ }
75
+ }
76
+ const startup = await startLocalDaemonDetached(startOptions);
77
+ const before = stopResult.pid === null ? "not running" : `PID ${stopResult.pid}`;
78
+ const after = startup.pid === null ? "unknown PID" : `PID ${startup.pid}`;
79
+ return {
80
+ type: "single",
81
+ data: {
82
+ action: "restarted",
83
+ home: stopResult.home,
84
+ pid: startup.pid === null ? "-" : String(startup.pid),
85
+ message: `Local daemon restarted (${before} -> ${after})`,
86
+ },
87
+ schema: restartResultSchema,
88
+ };
89
+ }
90
+ catch (err) {
91
+ const message = err instanceof Error ? err.message : String(err);
92
+ const error = {
93
+ code: "RESTART_FAILED",
94
+ message: `Failed to restart local daemon: ${message}`,
95
+ };
96
+ throw error;
97
+ }
98
+ }
99
+ //# sourceMappingURL=restart.js.map
@@ -0,0 +1,6 @@
1
+ export interface NodePathFromPidResult {
2
+ nodePath: string | null;
3
+ error?: string;
4
+ }
5
+ export declare function resolveNodePathFromPid(pid: number): Promise<NodePathFromPidResult>;
6
+ //# sourceMappingURL=runtime-toolchain.d.ts.map
@@ -0,0 +1,87 @@
1
+ import { platform } from "node:os";
2
+ import { execCommand } from "@otto-code/server";
3
+ function normalizeError(error) {
4
+ if (error instanceof Error) {
5
+ return error.message;
6
+ }
7
+ return String(error);
8
+ }
9
+ async function resolveNodePathFromPidUnix(pid) {
10
+ try {
11
+ const { stdout } = await execCommand("ps", ["-o", "comm=", "-p", String(pid)]);
12
+ const resolved = stdout.trim();
13
+ return resolved
14
+ ? { nodePath: resolved }
15
+ : { nodePath: null, error: "ps returned an empty command path" };
16
+ }
17
+ catch (error) {
18
+ return { nodePath: null, error: `ps failed: ${normalizeError(error)}` };
19
+ }
20
+ }
21
+ async function runProcessProbe(command, args, options) {
22
+ try {
23
+ const { stdout } = await execCommand(command, args, { shell: options?.shell });
24
+ const resolved = stdout.trim();
25
+ return resolved
26
+ ? { resolved }
27
+ : { resolved: null, error: `${command} returned no executable path` };
28
+ }
29
+ catch (error) {
30
+ return { resolved: null, error: `${command} failed: ${normalizeError(error)}` };
31
+ }
32
+ }
33
+ async function resolveNodePathFromPidWindows(pid) {
34
+ const probes = [
35
+ {
36
+ label: "powershell-cim",
37
+ command: "powershell.exe",
38
+ args: [
39
+ "-NoProfile",
40
+ "-Command",
41
+ `(Get-CimInstance Win32_Process -Filter "ProcessId = ${pid}").ExecutablePath`,
42
+ ],
43
+ },
44
+ {
45
+ label: "powershell-process",
46
+ command: "powershell.exe",
47
+ args: ["-NoProfile", "-Command", `(Get-Process -Id ${pid}).Path`],
48
+ },
49
+ {
50
+ label: "wmic",
51
+ command: "wmic",
52
+ args: ["process", "where", `ProcessId=${pid}`, "get", "ExecutablePath", "/VALUE"],
53
+ parseValue: (stdout) => {
54
+ const match = stdout.match(/ExecutablePath=(.+)/);
55
+ return match?.[1]?.trim() ?? null;
56
+ },
57
+ },
58
+ ];
59
+ const errors = [];
60
+ async function tryProbe(index) {
61
+ if (index >= probes.length) {
62
+ return {
63
+ nodePath: null,
64
+ error: errors.join("; ") || "could not resolve executable path from PID",
65
+ };
66
+ }
67
+ const probe = probes[index];
68
+ const result = await runProcessProbe(probe.command, probe.args, { shell: false });
69
+ if (result.resolved) {
70
+ const resolved = probe.parseValue ? probe.parseValue(result.resolved) : result.resolved;
71
+ if (resolved)
72
+ return { nodePath: resolved };
73
+ errors.push(`${probe.label} returned no executable path`);
74
+ }
75
+ else if (result.error) {
76
+ errors.push(`${probe.label}: ${result.error}`);
77
+ }
78
+ return tryProbe(index + 1);
79
+ }
80
+ return tryProbe(0);
81
+ }
82
+ export async function resolveNodePathFromPid(pid) {
83
+ return platform() === "win32"
84
+ ? await resolveNodePathFromPidWindows(pid)
85
+ : await resolveNodePathFromPidUnix(pid);
86
+ }
87
+ //# sourceMappingURL=runtime-toolchain.js.map
@@ -0,0 +1,17 @@
1
+ import type { Command } from "commander";
2
+ import type { CommandOptions, SingleResult } from "../../output/index.js";
3
+ interface SetPasswordResult {
4
+ action: "password_set";
5
+ configPath: string;
6
+ restartCommand: string;
7
+ message: string;
8
+ }
9
+ export type PromptPassword = (message: string) => Promise<string | symbol>;
10
+ export interface SetPasswordOptions {
11
+ home?: string;
12
+ promptPassword?: PromptPassword;
13
+ }
14
+ export declare function setDaemonPasswordInConfig(newPassword: string, options?: SetPasswordOptions): Promise<SetPasswordResult>;
15
+ export declare function runSetPasswordCommand(options: CommandOptions, _command: Command): Promise<SingleResult<SetPasswordResult>>;
16
+ export {};
17
+ //# sourceMappingURL=set-password.d.ts.map
@@ -0,0 +1,82 @@
1
+ import path from "node:path";
2
+ import { isCancel, password as passwordPrompt } from "@clack/prompts";
3
+ import { hashDaemonPassword, loadPersistedConfig, savePersistedConfig, } from "@otto-code/server";
4
+ import { resolveLocalOttoHome } from "./local-daemon.js";
5
+ const CONFIG_FILENAME = "config.json";
6
+ const setPasswordResultSchema = {
7
+ idField: "action",
8
+ columns: [
9
+ { header: "STATUS", field: "action", color: () => "green" },
10
+ { header: "CONFIG", field: "configPath" },
11
+ { header: "RESTART", field: "restartCommand" },
12
+ ],
13
+ renderHuman: (result, options) => {
14
+ const data = result.data;
15
+ const rows = [
16
+ `Password written to ${data.configPath}`,
17
+ "Restart the daemon for the change to take effect.",
18
+ `Run: ${data.restartCommand}`,
19
+ ];
20
+ if (options.format === "table") {
21
+ return rows.join("\n");
22
+ }
23
+ return data.message;
24
+ },
25
+ };
26
+ function createCommandError(code, message, details) {
27
+ return { code, message, ...(details ? { details } : {}) };
28
+ }
29
+ async function promptForPassword(promptPassword) {
30
+ const first = await promptPassword("New daemon password");
31
+ if (isCancel(first)) {
32
+ throw createCommandError("PASSWORD_CANCELLED", "Password update cancelled");
33
+ }
34
+ if (typeof first !== "string" || first.length === 0) {
35
+ throw createCommandError("PASSWORD_REQUIRED", "Password cannot be empty");
36
+ }
37
+ const second = await promptPassword("Confirm daemon password");
38
+ if (isCancel(second)) {
39
+ throw createCommandError("PASSWORD_CANCELLED", "Password update cancelled");
40
+ }
41
+ if (first !== second) {
42
+ throw createCommandError("PASSWORD_MISMATCH", "Passwords do not match");
43
+ }
44
+ return first;
45
+ }
46
+ export async function setDaemonPasswordInConfig(newPassword, options = {}) {
47
+ const ottoHome = resolveLocalOttoHome(options.home);
48
+ const configPath = path.join(ottoHome, CONFIG_FILENAME);
49
+ const persisted = loadPersistedConfig(ottoHome);
50
+ const nextConfig = {
51
+ ...persisted,
52
+ daemon: {
53
+ ...persisted.daemon,
54
+ auth: {
55
+ ...persisted.daemon?.auth,
56
+ password: hashDaemonPassword(newPassword),
57
+ },
58
+ },
59
+ };
60
+ savePersistedConfig(ottoHome, nextConfig);
61
+ return {
62
+ action: "password_set",
63
+ configPath,
64
+ restartCommand: "otto daemon restart",
65
+ message: `Password written to ${configPath}\nRestart the daemon for the change to take effect.\nRun: otto daemon restart`,
66
+ };
67
+ }
68
+ export async function runSetPasswordCommand(options, _command) {
69
+ const promptPassword = typeof options.promptPassword === "function"
70
+ ? options.promptPassword
71
+ : (message) => passwordPrompt({ message });
72
+ const newPassword = await promptForPassword(promptPassword);
73
+ const result = await setDaemonPasswordInConfig(newPassword, {
74
+ home: typeof options.home === "string" ? options.home : undefined,
75
+ });
76
+ return {
77
+ type: "single",
78
+ data: result,
79
+ schema: setPasswordResultSchema,
80
+ };
81
+ }
82
+ //# sourceMappingURL=set-password.js.map
@@ -0,0 +1,6 @@
1
+ import { Command } from "commander";
2
+ import { type DaemonStartOptions as StartOptions } from "./local-daemon.js";
3
+ export type { DaemonStartOptions as StartOptions } from "./local-daemon.js";
4
+ export declare function startCommand(): Command;
5
+ export declare function runStart(options: StartOptions): Promise<void>;
6
+ //# sourceMappingURL=start.d.ts.map
@@ -0,0 +1,56 @@
1
+ import { Command, Option } from "commander";
2
+ import chalk from "chalk";
3
+ import { startLocalDaemonForeground, startLocalDaemonDetached, } from "./local-daemon.js";
4
+ import { getErrorMessage } from "../../utils/errors.js";
5
+ export function startCommand() {
6
+ return new Command("start")
7
+ .description("Start the local Otto daemon")
8
+ .option("--listen <listen>", "Listen target (host:port, port, or unix socket path)")
9
+ .option("--port <port>", "Port to listen on (default: 6868)")
10
+ .option("--home <path>", "Otto home directory (default: ~/.otto)")
11
+ .option("--foreground", "Run in foreground (don't daemonize)")
12
+ .option("--no-relay", "Disable relay connection")
13
+ .option("--relay-use-tls", "Use wss:// for the relay connection and pairing offers")
14
+ .option("--no-mcp", "Disable the Agent MCP HTTP endpoint")
15
+ .option("--no-inject-mcp", "Disable auto-injecting the Otto MCP into created agents")
16
+ .option("--web-ui", "Enable the bundled daemon web UI")
17
+ .option("--no-web-ui", "Disable the bundled daemon web UI")
18
+ .option("--hostnames <hosts>", 'Daemon hostnames (comma-separated, e.g. "myhost,.example.com" or "true" for any)')
19
+ .addOption(new Option("--allowed-hosts <hosts>").hideHelp())
20
+ .action(async (options) => {
21
+ await runStart({
22
+ ...options,
23
+ hostnames: options.hostnames ?? options.allowedHosts,
24
+ });
25
+ });
26
+ }
27
+ export async function runStart(options) {
28
+ if (options.listen && options.port) {
29
+ console.error(chalk.red("Cannot use --listen and --port together"));
30
+ process.exit(1);
31
+ }
32
+ if (!options.foreground) {
33
+ try {
34
+ const startup = await startLocalDaemonDetached(options);
35
+ console.log(chalk.green(`Daemon starting in background (PID ${startup.pid ?? "unknown"}).`));
36
+ console.log(chalk.dim(`Logs: ${startup.logPath}`));
37
+ }
38
+ catch (err) {
39
+ exitWithError(getErrorMessage(err));
40
+ }
41
+ return;
42
+ }
43
+ try {
44
+ const status = startLocalDaemonForeground(options);
45
+ process.exit(status);
46
+ }
47
+ catch (err) {
48
+ const message = getErrorMessage(err);
49
+ exitWithError(`Failed to start daemon: ${message}`);
50
+ }
51
+ }
52
+ function exitWithError(message) {
53
+ console.error(chalk.red(message));
54
+ process.exit(1);
55
+ }
56
+ //# sourceMappingURL=start.js.map
@@ -0,0 +1,10 @@
1
+ import type { Command } from "commander";
2
+ import type { CommandOptions, ListResult } from "../../output/index.js";
3
+ interface StatusRow {
4
+ key: string;
5
+ value: string;
6
+ }
7
+ export type StatusResult = ListResult<StatusRow>;
8
+ export declare function runStatusCommand(options: CommandOptions, _command: Command): Promise<StatusResult>;
9
+ export {};
10
+ //# sourceMappingURL=status.d.ts.map