sovkora 0.0.0-stage → 1.1.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 (98) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +9 -0
  3. package/README.md +67 -2
  4. package/dist/commands/agent.command.js +267 -0
  5. package/dist/commands/chat.command.js +214 -0
  6. package/dist/commands/chat.handlers.js +150 -0
  7. package/dist/commands/chat.types.js +44 -0
  8. package/dist/commands/cinema.command.js +643 -0
  9. package/dist/commands/config.command.js +228 -0
  10. package/dist/commands/db.command.js +114 -0
  11. package/dist/commands/demo.command.js +55 -0
  12. package/dist/commands/dev.command.js +462 -0
  13. package/dist/commands/docs.command.js +135 -0
  14. package/dist/commands/doctor.command.js +119 -0
  15. package/dist/commands/forgot.command.js +57 -0
  16. package/dist/commands/generate.command.js +376 -0
  17. package/dist/commands/graph.command.js +54 -0
  18. package/dist/commands/init.command.js +380 -0
  19. package/dist/commands/init.steps.js +115 -0
  20. package/dist/commands/install.command.js +459 -0
  21. package/dist/commands/login.command.js +110 -0
  22. package/dist/commands/logs.command.js +215 -0
  23. package/dist/commands/logs.steps.js +130 -0
  24. package/dist/commands/mcp.command.js +104 -0
  25. package/dist/commands/models.command.js +164 -0
  26. package/dist/commands/onboard.command.js +236 -0
  27. package/dist/commands/pack.command.js +255 -0
  28. package/dist/commands/profile.command.js +51 -0
  29. package/dist/commands/recover.command.js +489 -0
  30. package/dist/commands/register.command.js +94 -0
  31. package/dist/commands/release.command.js +99 -0
  32. package/dist/commands/reset.command.js +79 -0
  33. package/dist/commands/runs.command.js +201 -0
  34. package/dist/commands/settings.command.js +85 -0
  35. package/dist/commands/start.command.js +590 -0
  36. package/dist/commands/status.command.js +167 -0
  37. package/dist/commands/stop.command.js +313 -0
  38. package/dist/commands/studio.command.js +266 -0
  39. package/dist/commands/test.command.js +134 -0
  40. package/dist/commands/verify.command.js +52 -0
  41. package/dist/commands/video.command.js +73 -0
  42. package/dist/commands/workspace-guard.js +72 -0
  43. package/dist/index.js +207 -0
  44. package/dist/renderers.js +250 -0
  45. package/dist/services/api-client.js +150 -0
  46. package/dist/services/auth.api.js +87 -0
  47. package/dist/services/chat.api.js +117 -0
  48. package/dist/services/cinema-estimate.json +42 -0
  49. package/dist/services/cinema.childsafe.js +52 -0
  50. package/dist/services/cinema.director.js +285 -0
  51. package/dist/services/cinema.production.js +417 -0
  52. package/dist/services/cinema.staging.js +323 -0
  53. package/dist/services/cinema.story.js +758 -0
  54. package/dist/services/cinema.treatment.js +393 -0
  55. package/dist/services/composer.run.js +94 -0
  56. package/dist/services/demo/demo.documents.js +108 -0
  57. package/dist/services/demo/demo.guard.js +49 -0
  58. package/dist/services/demo/demo.persona.js +114 -0
  59. package/dist/services/demo/demo.seed.js +281 -0
  60. package/dist/services/diagnostics.js +327 -0
  61. package/dist/services/image-model-recipes.json +93 -0
  62. package/dist/services/image-models.js +152 -0
  63. package/dist/services/local-store.js +145 -0
  64. package/dist/services/mcp.api.js +38 -0
  65. package/dist/services/model-catalog.js +70 -0
  66. package/dist/services/notify.js +55 -0
  67. package/dist/services/pack.api.js +23 -0
  68. package/dist/services/pack.bundle.js +241 -0
  69. package/dist/services/pack.sources.js +101 -0
  70. package/dist/services/release-manifest.js +266 -0
  71. package/dist/services/runs.view.js +80 -0
  72. package/dist/services/runs.wait.js +38 -0
  73. package/dist/services/semver.js +55 -0
  74. package/dist/services/settings.api.js +108 -0
  75. package/dist/services/string-utils.js +70 -0
  76. package/dist/services/studio.api.js +120 -0
  77. package/dist/services/templates.js +893 -0
  78. package/dist/services/tool-installer.js +353 -0
  79. package/dist/services/tool-path.js +72 -0
  80. package/dist/services/version-manager.js +253 -0
  81. package/dist/services/workspace-bootstrap.js +68 -0
  82. package/dist/threads.js +202 -0
  83. package/dist/types/api.types.js +6 -0
  84. package/dist/types/local.types.js +6 -0
  85. package/dist/ui/box.js +46 -0
  86. package/dist/ui/logger.js +28 -0
  87. package/dist/ui/platform.js +32 -0
  88. package/dist/ui/prompts.js +130 -0
  89. package/dist/ui/table.js +33 -0
  90. package/dist/utils/config.js +150 -0
  91. package/dist/utils/development-status.js +22 -0
  92. package/dist/utils/endpoints.js +41 -0
  93. package/dist/utils/health.js +94 -0
  94. package/dist/utils/pid.js +83 -0
  95. package/dist/utils/platform.js +358 -0
  96. package/dist/utils/process.js +139 -0
  97. package/dist/utils/state-dir.js +105 -0
  98. package/package.json +95 -4
@@ -0,0 +1,150 @@
1
+ "use strict";
2
+ /**
3
+ * @file config.ts
4
+ * @description Single source of truth for runtime configuration. Loads the
5
+ * workspace-root `.env` exactly once (on first import) and exposes typed,
6
+ * env-driven accessors. No port, host or URL is hardcoded anywhere else in the
7
+ * CLI — every command/service reads from here so values stay in sync with `.env`.
8
+ *
9
+ * Each value falls back to a documented default only when the key is absent from
10
+ * `.env`; when present, the `.env` value wins.
11
+ */
12
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
13
+ if (k2 === undefined) k2 = k;
14
+ var desc = Object.getOwnPropertyDescriptor(m, k);
15
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
16
+ desc = { enumerable: true, get: function() { return m[k]; } };
17
+ }
18
+ Object.defineProperty(o, k2, desc);
19
+ }) : (function(o, m, k, k2) {
20
+ if (k2 === undefined) k2 = k;
21
+ o[k2] = m[k];
22
+ }));
23
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
24
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
25
+ }) : function(o, v) {
26
+ o["default"] = v;
27
+ });
28
+ var __importStar = (this && this.__importStar) || (function () {
29
+ var ownKeys = function(o) {
30
+ ownKeys = Object.getOwnPropertyNames || function (o) {
31
+ var ar = [];
32
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
33
+ return ar;
34
+ };
35
+ return ownKeys(o);
36
+ };
37
+ return function (mod) {
38
+ if (mod && mod.__esModule) return mod;
39
+ var result = {};
40
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
41
+ __setModuleDefault(result, mod);
42
+ return result;
43
+ };
44
+ })();
45
+ Object.defineProperty(exports, "__esModule", { value: true });
46
+ exports.TIMEOUTS = exports.OLLAMA_MODEL = exports.ROUTER_URL = exports.ALL_PORTS = exports.PORTS = exports.NODE_MIN_MAJOR = void 0;
47
+ exports.intEnv = intEnv;
48
+ exports.strEnv = strEnv;
49
+ const path = __importStar(require("node:path"));
50
+ const platform_1 = require("./platform");
51
+ // Load .env from the workspace root into process.env — the single source of
52
+ // truth. We use the in-house parser (utils/platform) rather than `dotenv` so
53
+ // this module — which sits on the import path of nearly every command — never
54
+ // hard-crashes with MODULE_NOT_FOUND if an external dep is mid-install/hoist.
55
+ // Existing process.env values win (matching dotenv's non-override semantics).
56
+ for (const [key, value] of Object.entries((0, platform_1.parseEnvFile)(path.join((0, platform_1.resolveWorkspaceRootSmart)(), ".env")))) {
57
+ if (process.env[key] === undefined)
58
+ process.env[key] = value;
59
+ }
60
+ /** Reads an integer env var, falling back through alternative keys then a default. */
61
+ function intEnv(keys, fallback) {
62
+ for (const key of typeof keys === "string" ? [keys] : keys) {
63
+ const raw = process.env[key];
64
+ if (raw?.trim()) {
65
+ const n = Number.parseInt(raw.trim(), 10);
66
+ if (Number.isFinite(n))
67
+ return n;
68
+ }
69
+ }
70
+ return fallback;
71
+ }
72
+ /** Reads a string env var, falling back through alternative keys then a default. */
73
+ function strEnv(keys, fallback) {
74
+ for (const key of typeof keys === "string" ? [keys] : keys) {
75
+ const raw = process.env[key];
76
+ if (raw?.trim())
77
+ return raw.trim();
78
+ }
79
+ return fallback;
80
+ }
81
+ /**
82
+ * Service ports, env-driven. The fallback mirrors `infra/docker-compose.yml`
83
+ * (middleware) and the app conventions (Router 8080, Web 3000, …).
84
+ */
85
+ /** The one Node.js minimum: what CI runs and `package.json` engines declare. */
86
+ exports.NODE_MIN_MAJOR = 22;
87
+ exports.PORTS = {
88
+ edge: intEnv("EDGE_PORT", 8088),
89
+ identity: intEnv("IDENTITY_PORT", 8083),
90
+ router: intEnv("PORT", 8080),
91
+ web: intEnv("WEB_PORT", 3000),
92
+ mobile: intEnv("MOBILE_PORT", 8081),
93
+ ollama: intEnv("OLLAMA_PORT", 11434),
94
+ localai: intEnv(["LOCALAI_PORT", "IMAGE_WORKER_PORT"], 8085),
95
+ imageGen: intEnv("IMAGE_GEN_PORT", 8086),
96
+ mediaWorker: intEnv(["MEDIA_WORKER_PORT", "VIDEO_WORKER_PORT"], 8188),
97
+ automationWorker: intEnv("AUTOMATION_WORKER_PORT", 8082),
98
+ knowledge: intEnv("KNOWLEDGE_PORT", 8084),
99
+ jobService: intEnv("JOB_SERVICE_PORT", 8090),
100
+ billing: intEnv("BILLING_PORT", 8095),
101
+ studio: intEnv("STUDIO_PORT", 8096),
102
+ notifications: intEnv("NOTIFICATIONS_PORT", 8097),
103
+ postgres: intEnv("POSTGRES_PORT", 5432),
104
+ redis: intEnv("REDIS_PORT", 6379),
105
+ // Canonical first, legacy second — the compatibility read kept for one version
106
+ // while a `.env` written before the names were settled still works (ADR-053 §8).
107
+ rabbitmq: intEnv(["RABBITMQ_PORT", "SPRING_RABBITMQ_PORT"], 5672),
108
+ rabbitmqMgmt: intEnv("RABBITMQ_MGMT_PORT", 15672),
109
+ };
110
+ /** Every host port the CLI touches — used by teardown/port-sweeps. */
111
+ exports.ALL_PORTS = [
112
+ exports.PORTS.web,
113
+ exports.PORTS.router,
114
+ exports.PORTS.edge,
115
+ exports.PORTS.identity,
116
+ exports.PORTS.knowledge,
117
+ exports.PORTS.jobService,
118
+ exports.PORTS.billing,
119
+ exports.PORTS.studio,
120
+ exports.PORTS.automationWorker,
121
+ exports.PORTS.localai,
122
+ exports.PORTS.imageGen,
123
+ exports.PORTS.mediaWorker,
124
+ exports.PORTS.ollama,
125
+ exports.PORTS.postgres,
126
+ exports.PORTS.redis,
127
+ exports.PORTS.rabbitmq,
128
+ exports.PORTS.rabbitmqMgmt,
129
+ ];
130
+ /**
131
+ * Base URL for the Sovkora Router (REST, GraphQL, SSE). Reads `ROUTER_URL`,
132
+ * falling back to the legacy `GATEWAY_URL` during the rename transition.
133
+ */
134
+ exports.ROUTER_URL = strEnv(["ROUTER_URL", "GATEWAY_URL"], `http://localhost:${String(exports.PORTS.router)}`);
135
+ /** Default Ollama model, env-driven. */
136
+ exports.OLLAMA_MODEL = strEnv("OLLAMA_MODEL", "phi3:mini");
137
+ /**
138
+ * CLI health/probe timing, env-driven (`CLI_*` keys). Centralized so retry and
139
+ * timeout budgets are tuned from `.env` rather than scattered magic numbers.
140
+ */
141
+ exports.TIMEOUTS = {
142
+ /** Default retry budget when waiting for a service to come up. */
143
+ healthRetries: intEnv("CLI_HEALTH_RETRIES", 30),
144
+ /** Delay between health retries (ms). */
145
+ healthIntervalMs: intEnv("CLI_HEALTH_INTERVAL_MS", 1000),
146
+ /** HTTP probe timeout (ms). */
147
+ httpTimeoutMs: intEnv("CLI_HTTP_TIMEOUT_MS", 3000),
148
+ /** TCP port-probe socket timeout (ms). */
149
+ portProbeMs: intEnv("CLI_PORT_PROBE_MS", 300),
150
+ };
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ /**
3
+ * @file development-status.ts
4
+ * @description The one line every Sovkora surface says about the product's state (krizaka/orazaka#516,
5
+ * CLI parity orazaka-cli#109): in development, still being tested. No « ready » wording. EN/FR, the
6
+ * language read from ORAZAKA_LANG, then LC_ALL / LC_MESSAGES / LANG (English by default).
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.DEVELOPMENT_STATUS = void 0;
10
+ exports.resolveLocale = resolveLocale;
11
+ exports.developmentStatus = developmentStatus;
12
+ exports.DEVELOPMENT_STATUS = {
13
+ en: "In development: Sovkora is still being tested. Expect changes.",
14
+ fr: "En développement : Sovkora est encore en cours de test. Attendez-vous à des changements.",
15
+ };
16
+ function resolveLocale(vars = process.env) {
17
+ const raw = vars.ORAZAKA_LANG ?? vars.LC_ALL ?? vars.LC_MESSAGES ?? vars.LANG ?? "";
18
+ return raw.toLowerCase().startsWith("fr") ? "fr" : "en";
19
+ }
20
+ function developmentStatus(vars = process.env) {
21
+ return exports.DEVELOPMENT_STATUS[resolveLocale(vars)];
22
+ }
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ /**
3
+ * @file endpoints.ts
4
+ * @description Turns what an operator typed for an external service into the base URL the platform is configured with.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.ollamaBaseUrl = ollamaBaseUrl;
8
+ const DEFAULT_OLLAMA_PORT = 11434;
9
+ const SCHEME = /^[a-z][a-z0-9+.-]*:\/\//i;
10
+ /**
11
+ * The Ollama base URL for an operator's answer.
12
+ *
13
+ * A full URL (`https://ollama.corp.internal:8443`) is kept as typed, so a TLS endpoint stays TLS; only
14
+ * http and https are accepted. A bare host or IP keeps the historical meaning: plain http on the default port.
15
+ *
16
+ * @throws Error when the answer is empty, has a scheme other than http(s), or is not a valid URL.
17
+ */
18
+ function ollamaBaseUrl(answer) {
19
+ let value = answer.trim();
20
+ if (value === "") {
21
+ throw new Error("The Ollama endpoint is empty.");
22
+ }
23
+ if (!SCHEME.test(value)) {
24
+ return `http://${value}:${DEFAULT_OLLAMA_PORT}`;
25
+ }
26
+ let url;
27
+ try {
28
+ url = new URL(value);
29
+ }
30
+ catch {
31
+ throw new Error(`The Ollama endpoint is not a valid URL: ${value}`);
32
+ }
33
+ if (url.protocol !== "http:" && url.protocol !== "https:") {
34
+ throw new Error(`The Ollama endpoint must be http or https, not ${url.protocol}`);
35
+ }
36
+ // Strip trailing slashes
37
+ while (value.endsWith("/")) {
38
+ value = value.slice(0, -1);
39
+ }
40
+ return value;
41
+ }
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+ /**
3
+ * @file health.ts
4
+ * @description Network health primitives shared by every command/service that
5
+ * probes a port or HTTP endpoint (start, stop, status, doctor, recover,
6
+ * diagnostics). Centralized so the TCP/HTTP probing logic exists exactly once.
7
+ */
8
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9
+ if (k2 === undefined) k2 = k;
10
+ var desc = Object.getOwnPropertyDescriptor(m, k);
11
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
12
+ desc = { enumerable: true, get: function() { return m[k]; } };
13
+ }
14
+ Object.defineProperty(o, k2, desc);
15
+ }) : (function(o, m, k, k2) {
16
+ if (k2 === undefined) k2 = k;
17
+ o[k2] = m[k];
18
+ }));
19
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
20
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
21
+ }) : function(o, v) {
22
+ o["default"] = v;
23
+ });
24
+ var __importStar = (this && this.__importStar) || (function () {
25
+ var ownKeys = function(o) {
26
+ ownKeys = Object.getOwnPropertyNames || function (o) {
27
+ var ar = [];
28
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
29
+ return ar;
30
+ };
31
+ return ownKeys(o);
32
+ };
33
+ return function (mod) {
34
+ if (mod && mod.__esModule) return mod;
35
+ var result = {};
36
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
37
+ __setModuleDefault(result, mod);
38
+ return result;
39
+ };
40
+ })();
41
+ Object.defineProperty(exports, "__esModule", { value: true });
42
+ exports.checkPortAvailable = checkPortAvailable;
43
+ exports.isPortInUse = isPortInUse;
44
+ exports.checkHttpEndpoint = checkHttpEndpoint;
45
+ exports.waitForPort = waitForPort;
46
+ const net = __importStar(require("node:net"));
47
+ const http = __importStar(require("node:http"));
48
+ const config_1 = require("./config");
49
+ /** Checks if a port is available (i.e. NOT in use). */
50
+ function checkPortAvailable(port, host = "127.0.0.1") {
51
+ return new Promise((resolve) => {
52
+ const socket = new net.Socket();
53
+ socket.setTimeout(config_1.TIMEOUTS.portProbeMs);
54
+ socket.once("connect", () => {
55
+ socket.destroy();
56
+ resolve(false); // in use
57
+ });
58
+ socket.once("error", () => {
59
+ socket.destroy();
60
+ resolve(true); // available
61
+ });
62
+ socket.once("timeout", () => {
63
+ socket.destroy();
64
+ resolve(true);
65
+ });
66
+ socket.connect(port, host);
67
+ });
68
+ }
69
+ /** True when a service is listening on the port (inverse of availability). */
70
+ async function isPortInUse(port, host = "127.0.0.1") {
71
+ return !(await checkPortAvailable(port, host));
72
+ }
73
+ /** Checks if an HTTP endpoint responds with a non-server-error status. */
74
+ function checkHttpEndpoint(url, timeout = config_1.TIMEOUTS.httpTimeoutMs) {
75
+ return new Promise((resolve) => {
76
+ const req = http.get(url, { timeout }, (res) => {
77
+ resolve(res.statusCode ? res.statusCode >= 200 && res.statusCode < 500 : false);
78
+ });
79
+ req.on("error", () => resolve(false));
80
+ req.on("timeout", () => {
81
+ req.destroy();
82
+ resolve(false);
83
+ });
84
+ });
85
+ }
86
+ /** Polls until a service is listening on the port, or the retry budget runs out. */
87
+ async function waitForPort(port, maxRetries = config_1.TIMEOUTS.healthRetries, intervalMs = config_1.TIMEOUTS.healthIntervalMs) {
88
+ for (let i = 0; i < maxRetries; i++) {
89
+ if (await isPortInUse(port))
90
+ return true;
91
+ await new Promise((r) => setTimeout(r, intervalMs));
92
+ }
93
+ return false;
94
+ }
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+ /**
3
+ * @file pid.ts
4
+ * @description PID-file helpers shared by the lifecycle commands. The CLI tracks
5
+ * detached native processes (Ollama, workers, Router JAR…) in a single
6
+ * `var/.orazaka.pid` file written as `name=pid` lines; this module is the one
7
+ * place that reads, writes and liveness-checks those entries.
8
+ */
9
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ var desc = Object.getOwnPropertyDescriptor(m, k);
12
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
13
+ desc = { enumerable: true, get: function() { return m[k]; } };
14
+ }
15
+ Object.defineProperty(o, k2, desc);
16
+ }) : (function(o, m, k, k2) {
17
+ if (k2 === undefined) k2 = k;
18
+ o[k2] = m[k];
19
+ }));
20
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
21
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
22
+ }) : function(o, v) {
23
+ o["default"] = v;
24
+ });
25
+ var __importStar = (this && this.__importStar) || (function () {
26
+ var ownKeys = function(o) {
27
+ ownKeys = Object.getOwnPropertyNames || function (o) {
28
+ var ar = [];
29
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
30
+ return ar;
31
+ };
32
+ return ownKeys(o);
33
+ };
34
+ return function (mod) {
35
+ if (mod && mod.__esModule) return mod;
36
+ var result = {};
37
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
38
+ __setModuleDefault(result, mod);
39
+ return result;
40
+ };
41
+ })();
42
+ Object.defineProperty(exports, "__esModule", { value: true });
43
+ exports.readPidFile = readPidFile;
44
+ exports.appendPid = appendPid;
45
+ exports.isPidAlive = isPidAlive;
46
+ const fs = __importStar(require("node:fs"));
47
+ const path = __importStar(require("node:path"));
48
+ /** Parses a `name=pid` PID file into a map. Missing/invalid lines are skipped. */
49
+ function readPidFile(pidFile) {
50
+ const pids = new Map();
51
+ if (!fs.existsSync(pidFile))
52
+ return pids;
53
+ for (const line of fs.readFileSync(pidFile, "utf-8").split("\n")) {
54
+ const trimmed = line.trim();
55
+ if (!trimmed || trimmed.startsWith("#"))
56
+ continue;
57
+ const eq = trimmed.indexOf("=");
58
+ if (eq === -1)
59
+ continue;
60
+ const name = trimmed.slice(0, eq).trim();
61
+ const pid = Number.parseInt(trimmed.slice(eq + 1).trim(), 10);
62
+ if (name && !Number.isNaN(pid))
63
+ pids.set(name, pid);
64
+ }
65
+ return pids;
66
+ }
67
+ /** Appends a `name=pid` entry to the PID file, creating the parent dir if needed. */
68
+ function appendPid(pidFile, name, pid) {
69
+ if (pid === undefined)
70
+ return;
71
+ fs.mkdirSync(path.dirname(pidFile), { recursive: true });
72
+ fs.appendFileSync(pidFile, `${name}=${String(pid)}\n`, "utf-8");
73
+ }
74
+ /** Checks whether a process with the given PID is currently alive. */
75
+ function isPidAlive(pid) {
76
+ try {
77
+ process.kill(pid, 0);
78
+ return true;
79
+ }
80
+ catch {
81
+ return false;
82
+ }
83
+ }