@osva-ai/cli 1.1.1 → 1.1.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 (181) hide show
  1. package/README.md +36 -0
  2. package/dist/bin/osva.js +26 -0
  3. package/dist/bin/osva.js.map +1 -1
  4. package/dist/commands/index.js +6 -0
  5. package/dist/commands/index.js.map +1 -1
  6. package/dist/doctor/redact.d.ts.map +1 -1
  7. package/dist/doctor/redact.js +3 -1
  8. package/dist/doctor/redact.js.map +1 -1
  9. package/dist/doctor/run-doctor.d.ts +2 -1
  10. package/dist/doctor/run-doctor.d.ts.map +1 -1
  11. package/dist/doctor/run-doctor.js +1 -1
  12. package/dist/doctor/run-doctor.js.map +1 -1
  13. package/dist/doctor/streaming-redact.d.ts +11 -0
  14. package/dist/doctor/streaming-redact.d.ts.map +1 -0
  15. package/dist/doctor/streaming-redact.js +29 -0
  16. package/dist/doctor/streaming-redact.js.map +1 -0
  17. package/dist/platform/compose-inspect.d.ts +9 -0
  18. package/dist/platform/compose-inspect.d.ts.map +1 -0
  19. package/dist/platform/compose-inspect.js +114 -0
  20. package/dist/platform/compose-inspect.js.map +1 -0
  21. package/dist/platform/doctor.d.ts +10 -0
  22. package/dist/platform/doctor.d.ts.map +1 -0
  23. package/dist/platform/doctor.js +154 -0
  24. package/dist/platform/doctor.js.map +1 -0
  25. package/dist/platform/format.d.ts +10 -0
  26. package/dist/platform/format.d.ts.map +1 -0
  27. package/dist/platform/format.js +73 -0
  28. package/dist/platform/format.js.map +1 -0
  29. package/dist/platform/index.d.ts +9 -0
  30. package/dist/platform/index.d.ts.map +1 -0
  31. package/dist/platform/index.js +143 -0
  32. package/dist/platform/index.js.map +1 -0
  33. package/dist/platform/lifecycle.d.ts +20 -0
  34. package/dist/platform/lifecycle.d.ts.map +1 -0
  35. package/dist/platform/lifecycle.js +136 -0
  36. package/dist/platform/lifecycle.js.map +1 -0
  37. package/dist/platform/logs.d.ts +12 -0
  38. package/dist/platform/logs.d.ts.map +1 -0
  39. package/dist/platform/logs.js +81 -0
  40. package/dist/platform/logs.js.map +1 -0
  41. package/dist/platform/readiness.d.ts +9 -0
  42. package/dist/platform/readiness.d.ts.map +1 -0
  43. package/dist/platform/readiness.js +58 -0
  44. package/dist/platform/readiness.js.map +1 -0
  45. package/dist/platform/resolve-installation.d.ts +5 -0
  46. package/dist/platform/resolve-installation.d.ts.map +1 -0
  47. package/dist/platform/resolve-installation.js +115 -0
  48. package/dist/platform/resolve-installation.js.map +1 -0
  49. package/dist/platform/services.d.ts +7 -0
  50. package/dist/platform/services.d.ts.map +1 -0
  51. package/dist/platform/services.js +21 -0
  52. package/dist/platform/services.js.map +1 -0
  53. package/dist/platform/status.d.ts +7 -0
  54. package/dist/platform/status.d.ts.map +1 -0
  55. package/dist/platform/status.js +60 -0
  56. package/dist/platform/status.js.map +1 -0
  57. package/dist/platform/types.d.ts +37 -0
  58. package/dist/platform/types.d.ts.map +1 -0
  59. package/dist/platform/types.js +8 -0
  60. package/dist/platform/types.js.map +1 -0
  61. package/dist/platform/upgrade/backup-policy.d.ts +4 -0
  62. package/dist/platform/upgrade/backup-policy.d.ts.map +1 -0
  63. package/dist/platform/upgrade/backup-policy.js +20 -0
  64. package/dist/platform/upgrade/backup-policy.js.map +1 -0
  65. package/dist/platform/upgrade/catalog.d.ts +26 -0
  66. package/dist/platform/upgrade/catalog.d.ts.map +1 -0
  67. package/dist/platform/upgrade/catalog.js +56 -0
  68. package/dist/platform/upgrade/catalog.js.map +1 -0
  69. package/dist/platform/upgrade/options.d.ts +8 -0
  70. package/dist/platform/upgrade/options.d.ts.map +1 -0
  71. package/dist/platform/upgrade/options.js +17 -0
  72. package/dist/platform/upgrade/options.js.map +1 -0
  73. package/dist/platform/upgrade/preflight.d.ts +25 -0
  74. package/dist/platform/upgrade/preflight.d.ts.map +1 -0
  75. package/dist/platform/upgrade/preflight.js +91 -0
  76. package/dist/platform/upgrade/preflight.js.map +1 -0
  77. package/dist/platform/upgrade/run-upgrade.d.ts +22 -0
  78. package/dist/platform/upgrade/run-upgrade.d.ts.map +1 -0
  79. package/dist/platform/upgrade/run-upgrade.js +253 -0
  80. package/dist/platform/upgrade/run-upgrade.js.map +1 -0
  81. package/dist/platform/upgrade/state.d.ts +31 -0
  82. package/dist/platform/upgrade/state.d.ts.map +1 -0
  83. package/dist/platform/upgrade/state.js +129 -0
  84. package/dist/platform/upgrade/state.js.map +1 -0
  85. package/dist/platform/upgrade/version.d.ts +11 -0
  86. package/dist/platform/upgrade/version.d.ts.map +1 -0
  87. package/dist/platform/upgrade/version.js +70 -0
  88. package/dist/platform/upgrade/version.js.map +1 -0
  89. package/dist/platform/upgrade-guard.d.ts +2 -0
  90. package/dist/platform/upgrade-guard.d.ts.map +1 -0
  91. package/dist/platform/upgrade-guard.js +12 -0
  92. package/dist/platform/upgrade-guard.js.map +1 -0
  93. package/dist/setup/acceptance-install.d.ts +15 -0
  94. package/dist/setup/acceptance-install.d.ts.map +1 -0
  95. package/dist/setup/acceptance-install.js +44 -0
  96. package/dist/setup/acceptance-install.js.map +1 -0
  97. package/dist/setup/atomic-write.d.ts +4 -0
  98. package/dist/setup/atomic-write.d.ts.map +1 -0
  99. package/dist/setup/atomic-write.js +19 -0
  100. package/dist/setup/atomic-write.js.map +1 -0
  101. package/dist/setup/bootstrap-capture.d.ts +9 -0
  102. package/dist/setup/bootstrap-capture.d.ts.map +1 -0
  103. package/dist/setup/bootstrap-capture.js +64 -0
  104. package/dist/setup/bootstrap-capture.js.map +1 -0
  105. package/dist/setup/compose-exec.d.ts +21 -0
  106. package/dist/setup/compose-exec.d.ts.map +1 -0
  107. package/dist/setup/compose-exec.js +55 -0
  108. package/dist/setup/compose-exec.js.map +1 -0
  109. package/dist/setup/compose-project.d.ts +3 -0
  110. package/dist/setup/compose-project.d.ts.map +1 -0
  111. package/dist/setup/compose-project.js +12 -0
  112. package/dist/setup/compose-project.js.map +1 -0
  113. package/dist/setup/compose-template-root.d.ts +3 -0
  114. package/dist/setup/compose-template-root.d.ts.map +1 -0
  115. package/dist/setup/compose-template-root.js +8 -0
  116. package/dist/setup/compose-template-root.js.map +1 -0
  117. package/dist/setup/distribution.d.ts +13 -0
  118. package/dist/setup/distribution.d.ts.map +1 -0
  119. package/dist/setup/distribution.js +55 -0
  120. package/dist/setup/distribution.js.map +1 -0
  121. package/dist/setup/env-file.d.ts +23 -0
  122. package/dist/setup/env-file.d.ts.map +1 -0
  123. package/dist/setup/env-file.js +141 -0
  124. package/dist/setup/env-file.js.map +1 -0
  125. package/dist/setup/format.d.ts +4 -0
  126. package/dist/setup/format.d.ts.map +1 -0
  127. package/dist/setup/format.js +58 -0
  128. package/dist/setup/format.js.map +1 -0
  129. package/dist/setup/index.d.ts +17 -0
  130. package/dist/setup/index.d.ts.map +1 -0
  131. package/dist/setup/index.js +45 -0
  132. package/dist/setup/index.js.map +1 -0
  133. package/dist/setup/install-path.d.ts +3 -0
  134. package/dist/setup/install-path.d.ts.map +1 -0
  135. package/dist/setup/install-path.js +26 -0
  136. package/dist/setup/install-path.js.map +1 -0
  137. package/dist/setup/installation-state.d.ts +29 -0
  138. package/dist/setup/installation-state.d.ts.map +1 -0
  139. package/dist/setup/installation-state.js +83 -0
  140. package/dist/setup/installation-state.js.map +1 -0
  141. package/dist/setup/installation-status.d.ts +14 -0
  142. package/dist/setup/installation-status.d.ts.map +1 -0
  143. package/dist/setup/installation-status.js +36 -0
  144. package/dist/setup/installation-status.js.map +1 -0
  145. package/dist/setup/materialize-install.d.ts +24 -0
  146. package/dist/setup/materialize-install.d.ts.map +1 -0
  147. package/dist/setup/materialize-install.js +108 -0
  148. package/dist/setup/materialize-install.js.map +1 -0
  149. package/dist/setup/probe-spawn.d.ts +16 -0
  150. package/dist/setup/probe-spawn.d.ts.map +1 -0
  151. package/dist/setup/probe-spawn.js +87 -0
  152. package/dist/setup/probe-spawn.js.map +1 -0
  153. package/dist/setup/read-options.d.ts +15 -0
  154. package/dist/setup/read-options.d.ts.map +1 -0
  155. package/dist/setup/read-options.js +69 -0
  156. package/dist/setup/read-options.js.map +1 -0
  157. package/dist/setup/run-onboarding.d.ts +22 -0
  158. package/dist/setup/run-onboarding.d.ts.map +1 -0
  159. package/dist/setup/run-onboarding.js +273 -0
  160. package/dist/setup/run-onboarding.js.map +1 -0
  161. package/dist/setup/run-provision.d.ts +17 -0
  162. package/dist/setup/run-provision.d.ts.map +1 -0
  163. package/dist/setup/run-provision.js +224 -0
  164. package/dist/setup/run-provision.js.map +1 -0
  165. package/dist/setup/run-setup.d.ts +26 -0
  166. package/dist/setup/run-setup.d.ts.map +1 -0
  167. package/dist/setup/run-setup.js +227 -0
  168. package/dist/setup/run-setup.js.map +1 -0
  169. package/dist/setup/secrets.d.ts +2 -0
  170. package/dist/setup/secrets.d.ts.map +1 -0
  171. package/dist/setup/secrets.js +8 -0
  172. package/dist/setup/secrets.js.map +1 -0
  173. package/dist/setup/setup-report.d.ts +19 -0
  174. package/dist/setup/setup-report.d.ts.map +1 -0
  175. package/dist/setup/setup-report.js +35 -0
  176. package/dist/setup/setup-report.js.map +1 -0
  177. package/dist/tsconfig.tsbuildinfo +1 -1
  178. package/package.json +3 -3
  179. package/templates/compose-install/compose.yml +307 -0
  180. package/templates/compose-install/distribution.json +5 -0
  181. package/templates/compose-install/upgrade-catalog.json +39 -0
@@ -0,0 +1,154 @@
1
+ import { loadComposeDistribution } from "../setup/distribution.js";
2
+ import { defaultProbeSpawn } from "../setup/probe-spawn.js";
3
+ import { doctorExitCode } from "../doctor/run-doctor.js";
4
+ import { redactSecrets } from "../doctor/redact.js";
5
+ import { isIncompleteUpgrade, readUpgradeState } from "./upgrade/state.js";
6
+ import { collectPlatformStatus } from "./status.js";
7
+ import { resolveInstallDir } from "../setup/install-path.js";
8
+ import { resolveInstallationForLifecycle } from "./resolve-installation.js";
9
+ import { PlatformCommandError } from "./types.js";
10
+ export const PLATFORM_DOCTOR_SUBPROCESS_TIMEOUT_MS = 5_000;
11
+ export async function runPlatformDoctor(flags, processEnv = process.env, deps = {}) {
12
+ const spawn = deps.spawn ?? defaultProbeSpawn;
13
+ const timeoutMs = PLATFORM_DOCTOR_SUBPROCESS_TIMEOUT_MS;
14
+ const checks = [];
15
+ checks.push(checkDockerCli(spawn, timeoutMs));
16
+ const engine = checkDockerEngine(spawn, timeoutMs);
17
+ checks.push(engine);
18
+ if (engine.status === "PASS") {
19
+ checks.push(checkDockerCompose(spawn, timeoutMs));
20
+ }
21
+ else {
22
+ checks.push(skipCheck("docker_compose", "Skipped because Docker Engine is unavailable."));
23
+ }
24
+ let installation;
25
+ const upgradeState = await readUpgradeState(resolveInstallDir(flags, processEnv, deps.platform));
26
+ if (isIncompleteUpgrade(upgradeState)) {
27
+ checks.push(warnCheck("upgrade_state", `Incomplete platform upgrade recorded (phase ${upgradeState.phase}).`, "See docs/operations/UPGRADE.md and `osva platform status` before retrying."));
28
+ }
29
+ try {
30
+ installation = await resolveInstallationForLifecycle(flags, processEnv, deps.platform);
31
+ checks.push(passCheck("installation_state", `Located OSVA installation at ${installation.installDir} (project ${installation.marker.composeProjectName}).`));
32
+ }
33
+ catch (error) {
34
+ if (error instanceof PlatformCommandError) {
35
+ checks.push(failCheck("installation_state", error.message, "Run `osva setup` or pass --install-dir to an existing installation."));
36
+ return finalizeReport(checks);
37
+ }
38
+ throw error;
39
+ }
40
+ try {
41
+ const distribution = await loadComposeDistribution();
42
+ if (installation.marker.platformVersion !==
43
+ distribution.manifest.platformVersion) {
44
+ checks.push(warnCheck("installation_version", `Installation platform version ${installation.marker.platformVersion} differs from CLI bundle ${distribution.manifest.platformVersion}.`, "Plan an explicit upgrade with `osva platform upgrade --to <version> --dry-run`."));
45
+ }
46
+ else {
47
+ checks.push(passCheck("installation_version", `Installation platform version ${installation.marker.platformVersion} matches the CLI bundle.`));
48
+ }
49
+ }
50
+ catch (error) {
51
+ checks.push(warnCheck("installation_version", error instanceof Error
52
+ ? error.message
53
+ : "Could not load CLI distribution metadata.", "Reinstall or rebuild the OSVA CLI package."));
54
+ }
55
+ if (installation.envValues.OSVA_IMAGE !== installation.marker.imageRef) {
56
+ checks.push(failCheck("installation_image", "Installed image metadata mismatch between marker and .env.", "Repair installation metadata or rerun setup reconciliation."));
57
+ }
58
+ else {
59
+ checks.push(passCheck("installation_image", `Installed image ${installation.marker.imageRef}.`));
60
+ }
61
+ const status = await collectPlatformStatus(installation, {
62
+ fetch: deps.fetch,
63
+ spawn: deps.spawn,
64
+ });
65
+ for (const service of status.services) {
66
+ const id = `service_${service.name.replace(/[^a-z0-9]+/gi, "_")}`;
67
+ if (service.state === "healthy") {
68
+ checks.push(passCheck(id, `${service.name}: healthy (${service.statusText}).`));
69
+ continue;
70
+ }
71
+ if (service.state === "running" || service.state === "starting") {
72
+ checks.push(warnCheck(id, `${service.name}: ${service.state} (${service.statusText}).`, service.name === "web"
73
+ ? "Wait for health checks or inspect logs with `osva platform logs --service web`."
74
+ : "Inspect service logs if the platform remains degraded."));
75
+ continue;
76
+ }
77
+ if (service.state === "stopped") {
78
+ checks.push(warnCheck(id, `${service.name}: stopped.`, "Run `osva platform start` to start the installation."));
79
+ continue;
80
+ }
81
+ checks.push(warnCheck(id, `${service.name}: ${service.state} (${service.statusText}).`, "Inspect Docker state with `osva platform status`."));
82
+ }
83
+ if (status.apiHealthOk) {
84
+ checks.push(passCheck("api_health", "GET /health succeeded."));
85
+ }
86
+ else {
87
+ checks.push(failCheck("api_health", `Control plane /health failed at ${installation.webUrl}.`, "Run `osva platform start` or inspect web logs."));
88
+ }
89
+ if (status.apiReadyOk) {
90
+ checks.push(passCheck("api_ready", "GET /ready succeeded (PostgreSQL and Valkey reachable from web)."));
91
+ }
92
+ else {
93
+ checks.push(failCheck("api_ready", `Control plane /ready failed at ${installation.webUrl}.`, "Ensure postgres and valkey are healthy (`osva platform logs --service postgres`)."));
94
+ }
95
+ if (status.consoleReady) {
96
+ checks.push(passCheck("console_ready", `Console responded at ${installation.consoleUrl}.`));
97
+ }
98
+ else {
99
+ checks.push(failCheck("console_ready", `Console is not reachable at ${installation.consoleUrl}.`, "Inspect `osva platform logs --service console`."));
100
+ }
101
+ for (const problem of status.problems) {
102
+ checks.push(warnCheck("platform_status", problem, "See `osva platform status` for details."));
103
+ }
104
+ return finalizeReport(checks);
105
+ }
106
+ export function platformDoctorExitCode(report) {
107
+ return doctorExitCode(report);
108
+ }
109
+ function checkDockerCli(spawn, timeoutMs) {
110
+ const result = spawn("docker", ["--version"], timeoutMs);
111
+ if (result.error?.code === "ENOENT") {
112
+ return failCheck("docker_cli", "Docker CLI was not found on PATH.", "Install Docker Desktop or Docker Engine.");
113
+ }
114
+ if (result.status !== 0) {
115
+ return failCheck("docker_cli", redactSecrets("Docker CLI is unavailable."), "Install Docker and ensure `docker` is on PATH.");
116
+ }
117
+ return passCheck("docker_cli", "Docker CLI is available.");
118
+ }
119
+ function checkDockerEngine(spawn, timeoutMs) {
120
+ const result = spawn("docker", ["info", "--format", "{{.ServerVersion}}"], timeoutMs);
121
+ if (result.error?.code === "ENOENT") {
122
+ return failCheck("docker_engine", "Docker CLI was not found on PATH.", "Install Docker Desktop or Docker Engine.");
123
+ }
124
+ if (result.status !== 0 || result.stdout.trim().length === 0) {
125
+ return failCheck("docker_engine", "Docker Engine is not reachable.", "Start Docker Desktop or the Docker daemon.");
126
+ }
127
+ return passCheck("docker_engine", `Docker Engine is reachable (server ${result.stdout.trim()}).`);
128
+ }
129
+ function checkDockerCompose(spawn, timeoutMs) {
130
+ const result = spawn("docker", ["compose", "version"], timeoutMs);
131
+ if (result.status !== 0) {
132
+ return failCheck("docker_compose", "Docker Compose v2 plugin is unavailable.", "Install Docker Compose v2 (`docker compose`).");
133
+ }
134
+ return passCheck("docker_compose", "Docker Compose v2 is available.");
135
+ }
136
+ function passCheck(id, message) {
137
+ return { id, status: "PASS", message };
138
+ }
139
+ function warnCheck(id, message, remediation) {
140
+ return { id, status: "WARN", message, remediation };
141
+ }
142
+ function failCheck(id, message, remediation) {
143
+ return { id, status: "FAIL", message, remediation };
144
+ }
145
+ function skipCheck(id, message) {
146
+ return { id, status: "SKIP", message };
147
+ }
148
+ function finalizeReport(checks) {
149
+ const hasFail = checks.some((check) => check.status === "FAIL");
150
+ const hasWarn = checks.some((check) => check.status === "WARN");
151
+ const result = hasFail ? "fail" : hasWarn ? "warn" : "pass";
152
+ return { result, checks };
153
+ }
154
+ //# sourceMappingURL=doctor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"doctor.js","sourceRoot":"","sources":["../../src/platform/doctor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAqB,MAAM,yBAAyB,CAAC;AAC/E,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAEzD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3E,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,+BAA+B,EAAE,MAAM,2BAA2B,CAAC;AAC5E,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAElD,MAAM,CAAC,MAAM,qCAAqC,GAAG,KAAK,CAAC;AAE3D,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,KAAiD,EACjD,aAAgC,OAAO,CAAC,GAAG,EAC3C,OAII,EAAE;IAEN,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,IAAI,iBAAiB,CAAC;IAC9C,MAAM,SAAS,GAAG,qCAAqC,CAAC;IACxD,MAAM,MAAM,GAAkB,EAAE,CAAC;IAEjC,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC;IAC9C,MAAM,MAAM,GAAG,iBAAiB,CAA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EAAE,CAAC;AACzC,CAAC;AAED,SAAS,SAAS,CAChB,EAAU,EACV,OAAe,EACf,WAAmB;IAEnB,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC;AACtD,CAAC;AAED,SAAS,SAAS,CAChB,EAAU,EACV,OAAe,EACf,WAAmB;IAEnB,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC;AACtD,CAAC;AAED,SAAS,SAAS,CAAC,EAAU,EAAE,OAAe;IAC5C,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;AACzC,CAAC;AAED,SAAS,cAAc,CAAC,MAAqB;IAC3C,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,KAAK,MAAM,CAAC,CAAC;IAChE,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,KAAK,MAAM,CAAC,CAAC;IAChE,MAAM,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC;IAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;AAC5B,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { DoctorReport } from "../doctor/types.js";
2
+ import type { LifecycleActionResult } from "./lifecycle.js";
3
+ import type { PlatformStatusReport } from "./types.js";
4
+ export declare function formatPlatformStatusHuman(report: PlatformStatusReport): string;
5
+ export declare function formatPlatformStatusJson(report: PlatformStatusReport): string;
6
+ export declare function formatLifecycleHuman(result: LifecycleActionResult): string;
7
+ export declare function formatLifecycleJson(result: LifecycleActionResult): string;
8
+ export declare function formatPlatformDoctorHuman(report: DoctorReport): string;
9
+ export declare function formatPlatformDoctorJson(report: DoctorReport): string;
10
+ //# sourceMappingURL=format.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../src/platform/format.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAEvD,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,oBAAoB,GAC3B,MAAM,CAqCR;AAED,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,oBAAoB,GAAG,MAAM,CAqB7E;AAED,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,qBAAqB,GAAG,MAAM,CAE1E;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,qBAAqB,GAAG,MAAM,CAEzE;AAED,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,CAWtE;AAED,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,CAErE"}
@@ -0,0 +1,73 @@
1
+ export function formatPlatformStatusHuman(report) {
2
+ const lines = [];
3
+ const { installation } = report;
4
+ lines.push(`Installation: ${installation.installDir}`);
5
+ lines.push(`Image: ${installation.marker.imageRef}`);
6
+ lines.push(`Platform version: ${installation.marker.platformVersion}`);
7
+ lines.push(`Compose project: ${installation.marker.composeProjectName}`);
8
+ lines.push(`Control plane: ${installation.webUrl}`);
9
+ lines.push(`Console: ${installation.consoleUrl}`);
10
+ lines.push(`Platform ready: ${report.platformReady ? "yes" : "no"} (API /ready: ${report.apiReadyOk ? "ok" : "not ok"})`);
11
+ lines.push(`Console ready: ${report.consoleReady ? "yes" : "no"}`);
12
+ lines.push("");
13
+ lines.push("Services:");
14
+ if (report.services.length === 0) {
15
+ lines.push(" (no containers reported — installation may be stopped)");
16
+ }
17
+ else {
18
+ for (const service of report.services) {
19
+ lines.push(` ${service.name.padEnd(22)} ${service.state.padEnd(10)} ${service.statusText}`);
20
+ }
21
+ }
22
+ if (report.upgradeState !== undefined) {
23
+ lines.push(`Upgrade state: ${report.upgradeState.phase} (${report.upgradeState.fromPlatformVersion} → ${report.upgradeState.toPlatformVersion})`);
24
+ }
25
+ if (report.problems.length > 0) {
26
+ lines.push("");
27
+ lines.push("Problems:");
28
+ for (const problem of report.problems) {
29
+ lines.push(` - ${problem}`);
30
+ }
31
+ }
32
+ return `${lines.join("\n")}\n`;
33
+ }
34
+ export function formatPlatformStatusJson(report) {
35
+ return `${JSON.stringify({
36
+ installDir: report.installation.installDir,
37
+ imageRef: report.installation.marker.imageRef,
38
+ platformVersion: report.installation.marker.platformVersion,
39
+ composeProjectName: report.installation.marker.composeProjectName,
40
+ webUrl: report.installation.webUrl,
41
+ mcpUrl: report.installation.mcpUrl,
42
+ consoleUrl: report.installation.consoleUrl,
43
+ platformReady: report.platformReady,
44
+ consoleReady: report.consoleReady,
45
+ apiHealthOk: report.apiHealthOk,
46
+ apiReadyOk: report.apiReadyOk,
47
+ services: report.services,
48
+ problems: report.problems,
49
+ upgradeState: report.upgradeState,
50
+ }, null, 2)}\n`;
51
+ }
52
+ export function formatLifecycleHuman(result) {
53
+ return `${result.message}\n`;
54
+ }
55
+ export function formatLifecycleJson(result) {
56
+ return `${JSON.stringify(result, null, 2)}\n`;
57
+ }
58
+ export function formatPlatformDoctorHuman(report) {
59
+ const lines = ["OSVA platform doctor", ""];
60
+ for (const check of report.checks) {
61
+ lines.push(`[${check.status}] ${check.id}: ${check.message}`);
62
+ if (check.remediation !== undefined) {
63
+ lines.push(` → ${check.remediation}`);
64
+ }
65
+ }
66
+ lines.push("");
67
+ lines.push(`Result: ${report.result}`);
68
+ return `${lines.join("\n")}\n`;
69
+ }
70
+ export function formatPlatformDoctorJson(report) {
71
+ return `${JSON.stringify(report, null, 2)}\n`;
72
+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AAC,MAAM,EAAE,CAAC,CAAC;IACvC,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;AACjC,CAAC;AAED,MAAM,UAAU,wBAAwB,CAAC,MAAoB;IAC3D,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC;AAChD,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { ProbeSpawnFn } from "../setup/probe-spawn.js";
2
+ export type PlatformCommandDependencies = {
3
+ readonly spawn?: ProbeSpawnFn;
4
+ readonly fetch?: typeof fetch;
5
+ readonly processEnv?: NodeJS.ProcessEnv;
6
+ readonly platform?: NodeJS.Platform;
7
+ };
8
+ export declare function runPlatformCommand(subcommand: readonly string[], flags: Readonly<Record<string, string | boolean>>, deps?: PlatformCommandDependencies): Promise<number>;
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/platform/index.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAO5D,MAAM,MAAM,2BAA2B,GAAG;IACxC,QAAQ,CAAC,KAAK,CAAC,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;IAC9B,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IACxC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC;CACrC,CAAC;AAEF,wBAAsB,kBAAkB,CACtC,UAAU,EAAE,SAAS,MAAM,EAAE,EAC7B,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,EACjD,IAAI,GAAE,2BAAgC,GACrC,OAAO,CAAC,MAAM,CAAC,CA8HjB"}
@@ -0,0 +1,143 @@
1
+ import { writeStdout } from "../stdout.js";
2
+ import { ComposeExecError } from "../setup/compose-exec.js";
3
+ import { printError } from "../output.js";
4
+ import { formatLifecycleHuman, formatLifecycleJson, formatPlatformDoctorHuman, formatPlatformDoctorJson, formatPlatformStatusHuman, formatPlatformStatusJson, } from "./format.js";
5
+ import { runPlatformDoctor, platformDoctorExitCode } from "./doctor.js";
6
+ import { runPlatformRestart, runPlatformStart, runPlatformStop, } from "./lifecycle.js";
7
+ import { parsePlatformLogsOptions, runPlatformLogs } from "./logs.js";
8
+ import { resolveInstallationForLifecycle } from "./resolve-installation.js";
9
+ import { collectPlatformStatus } from "./status.js";
10
+ import { PlatformCommandError } from "./types.js";
11
+ import { parsePlatformUpgradeOptions } from "./upgrade/options.js";
12
+ import { PlatformUpgradeDryRunReport, runPlatformUpgrade, } from "./upgrade/run-upgrade.js";
13
+ export async function runPlatformCommand(subcommand, flags, deps = {}) {
14
+ const processEnv = deps.processEnv ?? process.env;
15
+ const json = flags.json === true;
16
+ if (subcommand.length === 0 || subcommand[0] === "help") {
17
+ printPlatformHelp();
18
+ return subcommand.length === 0 ? 1 : 0;
19
+ }
20
+ const action = subcommand[0];
21
+ try {
22
+ if (action === "status") {
23
+ const installation = await resolveInstallationForLifecycle(flags, processEnv, deps.platform);
24
+ const report = await collectPlatformStatus(installation, {
25
+ fetch: deps.fetch,
26
+ spawn: deps.spawn,
27
+ });
28
+ await writeStdout(json
29
+ ? formatPlatformStatusJson(report)
30
+ : formatPlatformStatusHuman(report));
31
+ return report.platformReady && report.problems.length === 0 ? 0 : 1;
32
+ }
33
+ if (action === "start") {
34
+ const installation = await resolveInstallationForLifecycle(flags, processEnv, deps.platform);
35
+ const result = await runPlatformStart(installation, {
36
+ spawn: deps.spawn,
37
+ fetch: deps.fetch,
38
+ });
39
+ await writeStdout(json ? formatLifecycleJson(result) : formatLifecycleHuman(result));
40
+ return 0;
41
+ }
42
+ if (action === "stop") {
43
+ const installation = await resolveInstallationForLifecycle(flags, processEnv, deps.platform);
44
+ const result = await runPlatformStop(installation, { spawn: deps.spawn });
45
+ await writeStdout(json ? formatLifecycleJson(result) : formatLifecycleHuman(result));
46
+ return 0;
47
+ }
48
+ if (action === "restart") {
49
+ const installation = await resolveInstallationForLifecycle(flags, processEnv, deps.platform);
50
+ const result = await runPlatformRestart(installation, {
51
+ spawn: deps.spawn,
52
+ fetch: deps.fetch,
53
+ });
54
+ await writeStdout(json ? formatLifecycleJson(result) : formatLifecycleHuman(result));
55
+ return 0;
56
+ }
57
+ if (action === "logs") {
58
+ const installation = await resolveInstallationForLifecycle(flags, processEnv, deps.platform);
59
+ const logOptions = parsePlatformLogsOptions(flags);
60
+ return await runPlatformLogs(installation, logOptions);
61
+ }
62
+ if (action === "upgrade") {
63
+ const installation = await resolveInstallationForLifecycle(flags, processEnv, deps.platform);
64
+ const upgradeOptions = parsePlatformUpgradeOptions(flags);
65
+ try {
66
+ const result = await runPlatformUpgrade(installation, upgradeOptions, {
67
+ spawn: deps.spawn,
68
+ fetch: deps.fetch,
69
+ processEnv,
70
+ });
71
+ await writeStdout(json ? `${JSON.stringify(result, null, 2)}\n` : `${result.message}\n`);
72
+ return 0;
73
+ }
74
+ catch (error) {
75
+ if (error instanceof PlatformUpgradeDryRunReport) {
76
+ await writeStdout(error.formatted);
77
+ return error.report.blockingIssues.length > 0 ? 1 : 0;
78
+ }
79
+ throw error;
80
+ }
81
+ }
82
+ if (action === "doctor") {
83
+ const report = await runPlatformDoctor(flags, processEnv, deps);
84
+ await writeStdout(json
85
+ ? formatPlatformDoctorJson(report)
86
+ : formatPlatformDoctorHuman(report));
87
+ return platformDoctorExitCode(report);
88
+ }
89
+ printError(`Unknown platform command: ${subcommand.join(" ")}`);
90
+ printPlatformHelp();
91
+ return 1;
92
+ }
93
+ catch (error) {
94
+ return mapPlatformError(error, json);
95
+ }
96
+ }
97
+ function mapPlatformError(error, json) {
98
+ if (error instanceof PlatformCommandError) {
99
+ if (json) {
100
+ void writeStdout(`${JSON.stringify({ error: { code: error.code, message: error.message } }, null, 2)}\n`);
101
+ }
102
+ else {
103
+ printError(error.message);
104
+ }
105
+ return error.code === "usage" ? 1 : 1;
106
+ }
107
+ if (error instanceof ComposeExecError) {
108
+ const message = error.message;
109
+ if (json) {
110
+ void writeStdout(`${JSON.stringify({ error: { code: error.code, message } }, null, 2)}\n`);
111
+ }
112
+ else {
113
+ printError(message);
114
+ }
115
+ return 1;
116
+ }
117
+ if (error instanceof Error) {
118
+ printError(error.message);
119
+ return 1;
120
+ }
121
+ printError("Platform command failed.");
122
+ return 1;
123
+ }
124
+ function printPlatformHelp() {
125
+ process.stdout.write(`OSVA platform lifecycle
126
+
127
+ Usage:
128
+ osva platform <command> [--install-dir PATH] [--json]
129
+
130
+ Commands:
131
+ status Show installation, service, and readiness overview
132
+ start Start an existing installation (no image pull or migration)
133
+ stop Gracefully stop services (preserves volumes and secrets)
134
+ restart Restart services in place (no image pull or migration)
135
+ logs Show recent service logs [--service NAME] [--tail N] [--follow]
136
+ doctor Diagnose Docker, installation, services, API, and Console health
137
+ upgrade Explicit platform upgrade (--to VERSION [--dry-run] [--backup-confirmed] [--yes])
138
+
139
+ Install OSVA with \`osva setup\`. Lifecycle commands never create a new installation.
140
+ \`platform upgrade\` requires --dry-run review, then --backup-confirmed and --yes to execute.
141
+ `);
142
+ }
143
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/platform/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,yBAAyB,EACzB,wBAAwB,EACxB,yBAAyB,EACzB,wBAAwB,GACzB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,iBAAiB,EAAE,s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AU,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAC5B,CAAC;QACD,OAAO,KAAK,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACxC,CAAC;IACD,IAAI,KAAK,YAAY,gBAAgB,EAAE,CAAC;QACtC,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;QAC9B,IAAI,IAAI,EAAE,CAAC;YACT,KAAK,WAAW,CACd,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CACzE,CAAC;QACJ,CAAC;aAAM,CAAC;YACN,UAAU,CAAC,OAAO,CAAC,CAAC;QACtB,CAAC;QACD,OAAO,CAAC,CAAC;IACX,CAAC;IACD,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;QAC3B,UAAU,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAC1B,OAAO,CAAC,CAAC;IACX,CAAC;IACD,UAAU,CAAC,0BAA0B,CAAC,CAAC;IACvC,OAAO,CAAC,CAAC;AACX,CAAC;AAED,SAAS,iBAAiB;IACxB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC;;;;;;;;;;;;;;;;CAgBtB,CAAC,CAAC;AACH,CAAC"}
@@ -0,0 +1,20 @@
1
+ import type { ProbeSpawnFn } from "../setup/probe-spawn.js";
2
+ import { type ResolvedInstallation } from "./types.js";
3
+ export declare const COMPOSE_LIFECYCLE_TIMEOUT_MS = 900000;
4
+ export interface LifecycleActionResult {
5
+ readonly action: "start" | "stop" | "restart";
6
+ readonly servicesAffected: readonly string[];
7
+ readonly message: string;
8
+ }
9
+ export declare function runPlatformStart(installation: ResolvedInstallation, deps?: {
10
+ readonly spawn?: ProbeSpawnFn;
11
+ readonly fetch?: typeof fetch;
12
+ }): Promise<LifecycleActionResult>;
13
+ export declare function runPlatformStop(installation: ResolvedInstallation, deps?: {
14
+ readonly spawn?: ProbeSpawnFn;
15
+ }): Promise<LifecycleActionResult>;
16
+ export declare function runPlatformRestart(installation: ResolvedInstallation, deps?: {
17
+ readonly spawn?: ProbeSpawnFn;
18
+ readonly fetch?: typeof fetch;
19
+ }): Promise<LifecycleActionResult>;
20
+ //# sourceMappingURL=lifecycle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lifecycle.d.ts","sourceRoot":"","sources":["../../src/platform/lifecycle.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAY5D,OAAO,EAAwB,KAAK,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAE7E,eAAO,MAAM,4BAA4B,SAAU,CAAC;AAEpD,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAAC;IAC9C,QAAQ,CAAC,gBAAgB,EAAE,SAAS,MAAM,EAAE,CAAC;IAC7C,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED,wBAAsB,gBAAgB,CACpC,YAAY,EAAE,oBAAoB,EAClC,IAAI,GAAE;IACJ,QAAQ,CAAC,KAAK,CAAC,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;CAC1B,GACL,OAAO,CAAC,qBAAqB,CAAC,CAuChC;AAED,wBAAsB,eAAe,CACnC,YAAY,EAAE,oBAAoB,EAClC,IAAI,GAAE;IAAE,QAAQ,CAAC,KAAK,CAAC,EAAE,YAAY,CAAA;CAAO,GAC3C,OAAO,CAAC,qBAAqB,CAAC,CA4BhC;AAED,wBAAsB,kBAAkB,CACtC,YAAY,EAAE,oBAAoB,EAClC,IAAI,GAAE;IACJ,QAAQ,CAAC,KAAK,CAAC,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;CAC1B,GACL,OAAO,CAAC,qBAAqB,CAAC,CA+ChC"}
@@ -0,0 +1,136 @@
1
+ import { assertComposeSuccess, buildComposeSpawnEnv, composeCommandIncludesDestructiveVolumeRemoval, runComposeCommand, } from "../setup/compose-exec.js";
2
+ import { redactSecrets } from "../doctor/redact.js";
3
+ import { inspectComposeServices, migrateJobCompleted, } from "./compose-inspect.js";
4
+ import { probeInstallationReadiness } from "./readiness.js";
5
+ import { PLATFORM_APPLICATION_SERVICES, PLATFORM_DATA_SERVICES, PLATFORM_LIFECYCLE_SERVICES, } from "./services.js";
6
+ import { assertPlatformLifecycleAllowed } from "./upgrade-guard.js";
7
+ import { PlatformCommandError } from "./types.js";
8
+ export const COMPOSE_LIFECYCLE_TIMEOUT_MS = 900_000;
9
+ export async function runPlatformStart(installation, deps = {}) {
10
+ await assertPlatformLifecycleAllowed(installation.installDir, "start platform services");
11
+ const spawn = deps.spawn;
12
+ const servicesBefore = inspectComposeServices(installation.execCtx, spawn);
13
+ const migrateCompleted = migrateJobCompleted(servicesBefore);
14
+ if (migrateCompleted === false) {
15
+ throw new PlatformCommandError("platform_not_ready", "Database migration has not completed successfully. Run `osva setup --yes` to migrate before starting the platform (lifecycle start does not run migrations).");
16
+ }
17
+ startDataServices(installation, spawn);
18
+ startApplicationServices(installation, spawn);
19
+ const readiness = await probeInstallationReadiness(installation, deps.fetch ?? fetch);
20
+ if (!readiness.apiReadyOk) {
21
+ const detail = readiness.apiReadyDetail === undefined
22
+ ? ""
23
+ : ` (${readiness.apiReadyDetail})`;
24
+ throw new PlatformCommandError("platform_not_ready", `Platform services started but the control plane is not ready${detail}. This can indicate schema drift or unhealthy dependencies. Inspect logs with \`osva platform logs --service web\`; migrations are not run automatically during start.`);
25
+ }
26
+ return {
27
+ action: "start",
28
+ servicesAffected: [...PLATFORM_LIFECYCLE_SERVICES],
29
+ message: "OSVA platform services are running and the control plane reported ready.",
30
+ };
31
+ }
32
+ export async function runPlatformStop(installation, deps = {}) {
33
+ await assertPlatformLifecycleAllowed(installation.installDir, "stop platform services");
34
+ const args = ["stop", ...PLATFORM_LIFECYCLE_SERVICES];
35
+ assertLifecycleArgs(args);
36
+ const result = runComposeCommand(installation.execCtx, args, {
37
+ spawn: deps.spawn,
38
+ timeoutMs: COMPOSE_LIFECYCLE_TIMEOUT_MS,
39
+ processEnv: buildComposeSpawnEnv(installation.execCtx),
40
+ });
41
+ if (result.status !== 0 && result.status !== null) {
42
+ throw new PlatformCommandError("compose_failed", redactSecrets(firstLine(result.stderr) ||
43
+ firstLine(result.stdout) ||
44
+ "docker compose stop failed."));
45
+ }
46
+ return {
47
+ action: "stop",
48
+ servicesAffected: [...PLATFORM_LIFECYCLE_SERVICES],
49
+ message: "Stopped OSVA platform services (volumes and installation files preserved).",
50
+ };
51
+ }
52
+ export async function runPlatformRestart(installation, deps = {}) {
53
+ await assertPlatformLifecycleAllowed(installation.installDir, "restart platform services");
54
+ const args = ["restart", ...PLATFORM_LIFECYCLE_SERVICES];
55
+ assertLifecycleArgs(args);
56
+ const result = runComposeCommand(installation.execCtx, args, {
57
+ spawn: deps.spawn,
58
+ timeoutMs: COMPOSE_LIFECYCLE_TIMEOUT_MS,
59
+ processEnv: buildComposeSpawnEnv(installation.execCtx),
60
+ });
61
+ if (result.status !== 0) {
62
+ throw new PlatformCommandError("compose_failed", redactSecrets(firstLine(result.stderr) ||
63
+ firstLine(result.stdout) ||
64
+ "docker compose restart failed."));
65
+ }
66
+ let apiHealthOk = false;
67
+ for (let attempt = 0; attempt < 30; attempt += 1) {
68
+ const readiness = await probeInstallationReadiness(installation, deps.fetch ?? fetch);
69
+ if (readiness.apiHealthOk) {
70
+ apiHealthOk = true;
71
+ break;
72
+ }
73
+ await delay(2_000);
74
+ }
75
+ if (!apiHealthOk) {
76
+ throw new PlatformCommandError("platform_not_ready", "Services restarted but the control plane health endpoint is not OK yet. Retry `osva platform status` or inspect logs.");
77
+ }
78
+ return {
79
+ action: "restart",
80
+ servicesAffected: [...PLATFORM_LIFECYCLE_SERVICES],
81
+ message: `Restarted: ${PLATFORM_LIFECYCLE_SERVICES.join(", ")}.`,
82
+ };
83
+ }
84
+ function startDataServices(installation, spawn) {
85
+ const args = [
86
+ "up",
87
+ "-d",
88
+ "--no-build",
89
+ "--pull",
90
+ "never",
91
+ "--wait",
92
+ ...PLATFORM_DATA_SERVICES,
93
+ ];
94
+ assertLifecycleArgs(args);
95
+ const result = runComposeCommand(installation.execCtx, args, {
96
+ spawn,
97
+ timeoutMs: COMPOSE_LIFECYCLE_TIMEOUT_MS,
98
+ processEnv: buildComposeSpawnEnv(installation.execCtx),
99
+ });
100
+ assertComposeSuccess(result, "Starting PostgreSQL and Valkey");
101
+ }
102
+ function startApplicationServices(installation, spawn) {
103
+ const args = [
104
+ "up",
105
+ "-d",
106
+ "--no-build",
107
+ "--pull",
108
+ "never",
109
+ "--wait",
110
+ ...PLATFORM_APPLICATION_SERVICES,
111
+ ];
112
+ assertLifecycleArgs(args);
113
+ const result = runComposeCommand(installation.execCtx, args, {
114
+ spawn,
115
+ timeoutMs: COMPOSE_LIFECYCLE_TIMEOUT_MS,
116
+ processEnv: buildComposeSpawnEnv(installation.execCtx),
117
+ });
118
+ assertComposeSuccess(result, "Starting OSVA application services");
119
+ }
120
+ function assertLifecycleArgs(args) {
121
+ if (composeCommandIncludesDestructiveVolumeRemoval(args)) {
122
+ throw new Error("Refusing destructive docker compose down -v.");
123
+ }
124
+ }
125
+ function delay(ms) {
126
+ return new Promise((resolve) => {
127
+ setTimeout(resolve, ms);
128
+ });
129
+ }
130
+ function firstLine(text) {
131
+ return (text
132
+ .split(/\r?\n/)
133
+ .map((line) => line.trim())
134
+ .find((line) => line.length > 0) ?? "");
135
+ }
136
+ //# sourceMappingURL=lifecycle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lifecycle.js","sourceRoot":"","sources":["../../src/platform/lifecycle.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,o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,EAAE,EAAE;QAC7B,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IAC1B,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAS,SAAS,CAAC,IAAY;IAC7B,OAAO,CACL,IAAI;SACD,KAAK,CAAC,OAAO,CAAC;SACd,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;SAC1B,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,CACzC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { type ResolvedInstallation } from "./types.js";
2
+ export declare const DEFAULT_LOG_TAIL = 100;
3
+ export declare const MAX_LOG_TAIL = 10000;
4
+ export declare const COMPOSE_LOGS_TIMEOUT_MS = 120000;
5
+ export interface PlatformLogsOptions {
6
+ readonly service: string | undefined;
7
+ readonly tail: number;
8
+ readonly follow: boolean;
9
+ }
10
+ export declare function parsePlatformLogsOptions(flags: Readonly<Record<string, string | boolean>>): PlatformLogsOptions;
11
+ export declare function runPlatformLogs(installation: ResolvedInstallation, options: PlatformLogsOptions): Promise<number>;
12
+ //# sourceMappingURL=logs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logs.d.ts","sourceRoot":"","sources":["../../src/platform/logs.ts"],"names":[],"mappings":"AAWA,OAAO,EAAwB,KAAK,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAE7E,eAAO,MAAM,gBAAgB,MAAM,CAAC;AACpC,eAAO,MAAM,YAAY,QAAS,CAAC;AACnC,eAAO,MAAM,uBAAuB,SAAU,CAAC;AAE/C,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IACrC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;CAC1B;AAED,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAChD,mBAAmB,CAsCrB;AAED,wBAAsB,eAAe,CACnC,YAAY,EAAE,oBAAoB,EAClC,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC,MAAM,CAAC,CAqEjB"}