nomoreide 0.1.12 → 0.1.14

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.
@@ -0,0 +1,9 @@
1
+ import type { PortBindingStatus } from "./port-utils.js";
2
+ import type { LogEntry, ServiceDefinition, ServiceHealth, ServiceStatus } from "./types.js";
3
+ export interface ComputeServiceHealthInput {
4
+ service: ServiceDefinition;
5
+ status?: ServiceStatus;
6
+ ports: PortBindingStatus[];
7
+ logs: LogEntry[];
8
+ }
9
+ export declare function computeServiceHealth(input: ComputeServiceHealthInput): ServiceHealth;
@@ -0,0 +1,33 @@
1
+ export function computeServiceHealth(input) {
2
+ const status = input.status;
3
+ const lastErrorLog = [...input.logs]
4
+ .reverse()
5
+ .find((entry) => entry.stream === "stderr" || /error|failed|exception/i.test(entry.text));
6
+ if (!status || status.state === "stopped") {
7
+ return baseHealth(input, "unknown", "Service is not running.", lastErrorLog);
8
+ }
9
+ if (status.state === "exited") {
10
+ return baseHealth(input, "unhealthy", `Service exited with code ${status.exitCode ?? "unknown"}.`, lastErrorLog);
11
+ }
12
+ if (status.processTree && status.processTree.rssMb >= 1000) {
13
+ return baseHealth(input, "warning", `High memory usage: ${status.processTree.rssMb.toFixed(1)} MB RSS.`, lastErrorLog);
14
+ }
15
+ if (lastErrorLog) {
16
+ return baseHealth(input, "warning", `Recent error log: ${lastErrorLog.text}`, lastErrorLog);
17
+ }
18
+ return baseHealth(input, "healthy", "Service is running without detected warnings.", lastErrorLog);
19
+ }
20
+ function baseHealth(input, status, summary, lastErrorLog) {
21
+ return {
22
+ service: input.service.name,
23
+ status,
24
+ summary,
25
+ checkedAt: new Date().toISOString(),
26
+ checks: [],
27
+ processTree: input.status?.processTree,
28
+ ports: input.ports,
29
+ lastErrorLog,
30
+ agentContext: "",
31
+ };
32
+ }
33
+ //# sourceMappingURL=service-health.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service-health.js","sourceRoot":"","sources":["../../src/core/service-health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OAAO;QACL,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,IAAI;QAC3B,MAAM;QACN,OAAO;QACP,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QACnC,MAAM,EAAE,EAAE;QACV,WAAW,EAAE,KAAK,CAAC,MAAM,EAAE,WAAW;QACtC,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,YAAY;QACZ,YAAY,EAAE,EAAE;KACjB,CAAC;AACJ,CAAC"}
@@ -1,4 +1,5 @@
1
1
  import type { ProcessTreeSummary } from "./process-tree.js";
2
+ import type { PortBindingStatus } from "./port-utils.js";
2
3
  export interface ServiceDefinition {
3
4
  name: string;
4
5
  command: string;
@@ -41,6 +42,24 @@ export interface LogEntry {
41
42
  text: string;
42
43
  timestamp: string;
43
44
  }
45
+ export type ServiceHealthStatus = "unknown" | "healthy" | "warning" | "unhealthy";
46
+ export interface HealthCheckResult {
47
+ name: string;
48
+ ok: boolean;
49
+ summary: string;
50
+ latencyMs?: number;
51
+ }
52
+ export interface ServiceHealth {
53
+ service: string;
54
+ status: ServiceHealthStatus;
55
+ summary: string;
56
+ checkedAt: string;
57
+ checks: HealthCheckResult[];
58
+ processTree?: ProcessTreeSummary;
59
+ ports: PortBindingStatus[];
60
+ lastErrorLog?: LogEntry;
61
+ agentContext: string;
62
+ }
44
63
  export interface ToolResult {
45
64
  ok: boolean;
46
65
  message: string;