kubeagent 0.1.36 → 0.1.44

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 (80) hide show
  1. package/README.md +32 -0
  2. package/dist/auth.js +15 -0
  3. package/dist/check/index.js +77 -0
  4. package/dist/check/run.js +114 -0
  5. package/dist/cli.js +25 -2
  6. package/dist/detector/sources.js +1 -1
  7. package/dist/diagnoser/index.js +37 -11
  8. package/dist/monitor/index.js +45 -14
  9. package/dist/notify/discord.js +6 -9
  10. package/dist/notify/ssrf-guard.js +150 -0
  11. package/dist/notify/teams.js +6 -9
  12. package/dist/notify/webhook.js +7 -9
  13. package/dist/orchestrator.js +2 -1
  14. package/dist/telemetry.js +27 -1
  15. package/package.json +10 -1
  16. package/dist/auth.d.ts +0 -29
  17. package/dist/cli.d.ts +0 -2
  18. package/dist/config.d.ts +0 -75
  19. package/dist/debug.d.ts +0 -10
  20. package/dist/detector/cache.d.ts +0 -6
  21. package/dist/detector/cache.test.d.ts +0 -1
  22. package/dist/detector/cache.test.js +0 -54
  23. package/dist/detector/catalog.d.ts +0 -17
  24. package/dist/detector/catalog.test.d.ts +0 -1
  25. package/dist/detector/catalog.test.js +0 -33
  26. package/dist/detector/eol.d.ts +0 -13
  27. package/dist/detector/eol.test.d.ts +0 -1
  28. package/dist/detector/eol.test.js +0 -78
  29. package/dist/detector/image-parser.d.ts +0 -11
  30. package/dist/detector/image-parser.test.d.ts +0 -1
  31. package/dist/detector/image-parser.test.js +0 -87
  32. package/dist/detector/index.d.ts +0 -33
  33. package/dist/detector/index.test.d.ts +0 -1
  34. package/dist/detector/index.test.js +0 -210
  35. package/dist/detector/osv.d.ts +0 -12
  36. package/dist/detector/osv.test.d.ts +0 -1
  37. package/dist/detector/osv.test.js +0 -86
  38. package/dist/detector/report.d.ts +0 -6
  39. package/dist/detector/sources.d.ts +0 -42
  40. package/dist/diagnoser/index.d.ts +0 -17
  41. package/dist/diagnoser/tools.d.ts +0 -119
  42. package/dist/kb/loader.d.ts +0 -1
  43. package/dist/kb/writer.d.ts +0 -12
  44. package/dist/kubectl-config.d.ts +0 -7
  45. package/dist/kubectl.d.ts +0 -13
  46. package/dist/monitor/checks.d.ts +0 -71
  47. package/dist/monitor/index.d.ts +0 -17
  48. package/dist/monitor/resolve.test.d.ts +0 -1
  49. package/dist/monitor/resolve.test.js +0 -21
  50. package/dist/monitor/types.d.ts +0 -11
  51. package/dist/notify/discord.d.ts +0 -4
  52. package/dist/notify/index.d.ts +0 -6
  53. package/dist/notify/pagerduty.d.ts +0 -9
  54. package/dist/notify/pagerduty.test.d.ts +0 -1
  55. package/dist/notify/pagerduty.test.js +0 -97
  56. package/dist/notify/setup.d.ts +0 -9
  57. package/dist/notify/slack.d.ts +0 -4
  58. package/dist/notify/teams.d.ts +0 -3
  59. package/dist/notify/telegram.d.ts +0 -9
  60. package/dist/notify/webhook.d.ts +0 -3
  61. package/dist/notify/webhook.test.d.ts +0 -1
  62. package/dist/notify/webhook.test.js +0 -53
  63. package/dist/onboard/cluster-scan.d.ts +0 -42
  64. package/dist/onboard/code-scan.d.ts +0 -9
  65. package/dist/onboard/index.d.ts +0 -3
  66. package/dist/onboard/interview.d.ts +0 -12
  67. package/dist/onboard/project-matcher.d.ts +0 -25
  68. package/dist/orchestrator.d.ts +0 -3
  69. package/dist/proxy-client.d.ts +0 -27
  70. package/dist/render.d.ts +0 -5
  71. package/dist/telemetry.d.ts +0 -1
  72. package/dist/telemetry.test.d.ts +0 -1
  73. package/dist/telemetry.test.js +0 -18
  74. package/dist/update-notifier.d.ts +0 -1
  75. package/dist/update-notifier.test.d.ts +0 -1
  76. package/dist/update-notifier.test.js +0 -50
  77. package/dist/verifier.d.ts +0 -9
  78. package/dist/version-check.d.ts +0 -14
  79. package/dist/version-check.test.d.ts +0 -1
  80. package/dist/version-check.test.js +0 -179
@@ -1,210 +0,0 @@
1
- import { describe, it, expect, vi, beforeEach } from "vitest";
2
- vi.mock("./sources.js", () => ({
3
- fetchWorkloadCandidates: vi.fn(),
4
- fetchHelmCandidates: vi.fn(),
5
- fetchIngressHostMap: vi.fn(),
6
- workloadKey: (ref) => `${ref.kind}/${ref.namespace}/${ref.name}`,
7
- }));
8
- vi.mock("./osv.js", () => ({
9
- queryOsv: vi.fn(),
10
- }));
11
- vi.mock("./eol.js", () => ({
12
- queryEol: vi.fn(),
13
- }));
14
- import { fetchWorkloadCandidates, fetchHelmCandidates, fetchIngressHostMap } from "./sources.js";
15
- import { queryOsv } from "./osv.js";
16
- import { queryEol } from "./eol.js";
17
- import { detectApplications, formatApplicationsMarkdown } from "./index.js";
18
- const fetchWorkloads = vi.mocked(fetchWorkloadCandidates);
19
- const fetchHelm = vi.mocked(fetchHelmCandidates);
20
- const fetchIngress = vi.mocked(fetchIngressHostMap);
21
- const osv = vi.mocked(queryOsv);
22
- const eol = vi.mocked(queryEol);
23
- describe("detectApplications", () => {
24
- beforeEach(() => {
25
- fetchWorkloads.mockReset();
26
- fetchHelm.mockReset();
27
- fetchIngress.mockReset();
28
- osv.mockReset();
29
- eol.mockReset();
30
- fetchIngress.mockResolvedValue(new Map());
31
- osv.mockResolvedValue([]);
32
- eol.mockResolvedValue(null);
33
- });
34
- it("merges image and label candidates pointing at the same app/version", async () => {
35
- fetchWorkloads.mockResolvedValue([
36
- {
37
- source: "image",
38
- image: "postgres:15.2",
39
- container: "db",
40
- workload: { kind: "StatefulSet", namespace: "prod", name: "db" },
41
- },
42
- {
43
- source: "label",
44
- appName: "postgres",
45
- appVersion: "15.2",
46
- workload: { kind: "StatefulSet", namespace: "prod", name: "db" },
47
- },
48
- ]);
49
- fetchHelm.mockResolvedValue([]);
50
- const result = await detectApplications({ noCache: true });
51
- expect(result.apps).toHaveLength(1);
52
- expect(result.apps[0].canonical).toBe("postgres");
53
- expect(result.apps[0].version).toBe("15.2");
54
- expect(result.apps[0].sources.sort()).toEqual(["image", "label"]);
55
- expect(result.apps[0].workloads).toHaveLength(1);
56
- });
57
- it("tracks images not in the catalog as unknowns", async () => {
58
- fetchWorkloads.mockResolvedValue([
59
- {
60
- source: "image",
61
- image: "acme/internal-app:1.2.3",
62
- container: "app",
63
- workload: { kind: "Deployment", namespace: "team-x", name: "foo" },
64
- },
65
- ]);
66
- fetchHelm.mockResolvedValue([]);
67
- const result = await detectApplications({ noCache: true });
68
- expect(result.apps).toHaveLength(0);
69
- expect(result.unknowns).toHaveLength(1);
70
- expect(result.unknowns[0]).toMatchObject({ name: "internal-app", version: "1.2.3" });
71
- });
72
- it("flags EOL apps via the eol lookup", async () => {
73
- fetchWorkloads.mockResolvedValue([
74
- {
75
- source: "image",
76
- image: "postgres:11.18",
77
- container: "db",
78
- workload: { kind: "StatefulSet", namespace: "prod", name: "db" },
79
- },
80
- ]);
81
- fetchHelm.mockResolvedValue([]);
82
- eol.mockResolvedValue({
83
- product: "postgres",
84
- cycle: "11",
85
- eol: true,
86
- eolDate: "2023-11-09",
87
- latest: "11.22",
88
- lts: false,
89
- });
90
- const result = await detectApplications({ noCache: true });
91
- expect(result.apps[0].eol?.eol).toBe(true);
92
- expect(result.apps[0].eol?.eolDate).toBe("2023-11-09");
93
- });
94
- it("attaches CVE findings from OSV", async () => {
95
- fetchWorkloads.mockResolvedValue([
96
- {
97
- source: "image",
98
- image: "redis:7.0.5",
99
- container: "cache",
100
- workload: { kind: "Deployment", namespace: "infra", name: "redis" },
101
- },
102
- ]);
103
- fetchHelm.mockResolvedValue([]);
104
- osv.mockResolvedValue([
105
- { id: "CVE-2023-9999", summary: "Boom.", severity: "high", fixed: "7.0.12" },
106
- ]);
107
- const result = await detectApplications({ noCache: true });
108
- expect(result.apps[0].cves).toHaveLength(1);
109
- expect(result.apps[0].cves[0].id).toBe("CVE-2023-9999");
110
- });
111
- it("orders apps by severity (EOL → CVEs → healthy)", async () => {
112
- fetchWorkloads.mockResolvedValue([
113
- {
114
- source: "image",
115
- image: "nginx:1.25.3",
116
- container: "web",
117
- workload: { kind: "Deployment", namespace: "edge", name: "nginx" },
118
- },
119
- {
120
- source: "image",
121
- image: "postgres:11.18",
122
- container: "db",
123
- workload: { kind: "StatefulSet", namespace: "prod", name: "db" },
124
- },
125
- {
126
- source: "image",
127
- image: "redis:7.0.5",
128
- container: "cache",
129
- workload: { kind: "Deployment", namespace: "infra", name: "redis" },
130
- },
131
- ]);
132
- fetchHelm.mockResolvedValue([]);
133
- eol.mockImplementation(async (product) => product === "postgres"
134
- ? { product: "postgres", cycle: "11", eol: true, eolDate: "2023-11-09", lts: false }
135
- : null);
136
- osv.mockImplementation(async (lookup) => lookup.name === "redis"
137
- ? [{ id: "CVE-2023-1", summary: "x", severity: "medium" }]
138
- : []);
139
- const result = await detectApplications({ noCache: true });
140
- expect(result.apps.map((a) => a.canonical)).toEqual(["postgres", "redis", "nginx"]);
141
- });
142
- it("uses Helm chart appVersion when available", async () => {
143
- fetchWorkloads.mockResolvedValue([]);
144
- fetchHelm.mockResolvedValue([
145
- {
146
- source: "helm",
147
- chart: "postgresql",
148
- chartVersion: "12.0.0",
149
- appVersion: "15.2.0",
150
- namespace: "data",
151
- releaseName: "primary",
152
- },
153
- ]);
154
- const result = await detectApplications({ noCache: true });
155
- expect(result.apps).toHaveLength(1);
156
- expect(result.apps[0].canonical).toBe("postgres");
157
- expect(result.apps[0].version).toBe("15.2.0");
158
- expect(result.apps[0].sources).toContain("helm");
159
- });
160
- });
161
- describe("formatApplicationsMarkdown", () => {
162
- it("produces sections for EOL, CVEs, healthy, and unknowns", () => {
163
- const md = formatApplicationsMarkdown({
164
- apps: [
165
- {
166
- canonical: "postgres",
167
- display: "PostgreSQL",
168
- version: "11.18",
169
- sources: ["image"],
170
- workloads: [{ kind: "StatefulSet", namespace: "prod", name: "db" }],
171
- cves: [],
172
- eol: { product: "postgres", cycle: "11", eol: true, eolDate: "2023-11-09", latest: "11.22", lts: false },
173
- catalogMatch: true,
174
- },
175
- {
176
- canonical: "redis",
177
- display: "Redis",
178
- version: "7.0.5",
179
- sources: ["image"],
180
- workloads: [{ kind: "Deployment", namespace: "infra", name: "redis" }],
181
- cves: [{ id: "CVE-2023-1", summary: "boom", severity: "high", fixed: "7.0.12" }],
182
- eol: null,
183
- catalogMatch: true,
184
- },
185
- {
186
- canonical: "nginx",
187
- display: "nginx",
188
- version: "1.25.3",
189
- sources: ["image"],
190
- workloads: [{ kind: "Deployment", namespace: "edge", name: "nginx" }],
191
- cves: [],
192
- eol: null,
193
- catalogMatch: true,
194
- },
195
- ],
196
- unknowns: [
197
- { name: "internal-app", version: "1.2.3", workloads: [{ kind: "Deployment", namespace: "team-x", name: "foo" }] },
198
- ],
199
- scanned: { workloads: 4, helmReleases: 0 },
200
- });
201
- expect(md).toContain("## End-of-Life");
202
- expect(md).toContain("PostgreSQL");
203
- expect(md).toContain("## Known Vulnerabilities");
204
- expect(md).toContain("CVE-2023-1");
205
- expect(md).toContain("## Up-to-date");
206
- expect(md).toContain("nginx");
207
- expect(md).toContain("## Other / not in catalog");
208
- expect(md).toContain("internal-app");
209
- });
210
- });
@@ -1,12 +0,0 @@
1
- import type { OsvLookup } from "./catalog.js";
2
- export interface CveFinding {
3
- id: string;
4
- summary: string;
5
- severity?: string;
6
- fixed?: string;
7
- reference?: string;
8
- }
9
- export declare function queryOsv(lookup: OsvLookup, version: string, opts?: {
10
- noCache?: boolean;
11
- timeoutMs?: number;
12
- }): Promise<CveFinding[]>;
@@ -1 +0,0 @@
1
- export {};
@@ -1,86 +0,0 @@
1
- import { describe, it, expect, vi, beforeEach } from "vitest";
2
- vi.mock("./cache.js", () => ({
3
- readCache: vi.fn(),
4
- readStaleCache: vi.fn(),
5
- writeCache: vi.fn(),
6
- }));
7
- import { readCache, readStaleCache, writeCache } from "./cache.js";
8
- import { queryOsv } from "./osv.js";
9
- const mockFetch = vi.fn();
10
- vi.stubGlobal("fetch", mockFetch);
11
- const cacheRead = vi.mocked(readCache);
12
- const cacheStale = vi.mocked(readStaleCache);
13
- const cacheWrite = vi.mocked(writeCache);
14
- describe("queryOsv", () => {
15
- beforeEach(() => {
16
- mockFetch.mockReset();
17
- cacheRead.mockReset();
18
- cacheStale.mockReset();
19
- cacheWrite.mockReset();
20
- cacheRead.mockReturnValue(null);
21
- cacheStale.mockReturnValue(null);
22
- });
23
- it("posts the package + version to api.osv.dev and returns mapped findings", async () => {
24
- mockFetch.mockResolvedValue({
25
- ok: true,
26
- json: async () => ({
27
- vulns: [
28
- {
29
- id: "CVE-2024-1",
30
- summary: "Test vuln",
31
- database_specific: { severity: "high" },
32
- affected: [{ ranges: [{ events: [{ introduced: "0" }, { fixed: "7.0.12" }] }] }],
33
- references: [{ type: "ADVISORY", url: "https://example.com/advisory" }],
34
- },
35
- ],
36
- }),
37
- });
38
- const findings = await queryOsv({ name: "redis" }, "7.0.5", { noCache: true });
39
- expect(mockFetch).toHaveBeenCalledOnce();
40
- expect(mockFetch.mock.calls[0][0]).toBe("https://api.osv.dev/v1/query");
41
- const body = JSON.parse(mockFetch.mock.calls[0][1].body);
42
- expect(body).toEqual({ package: { name: "redis" }, version: "7.0.5" });
43
- expect(findings).toHaveLength(1);
44
- expect(findings[0]).toMatchObject({
45
- id: "CVE-2024-1",
46
- severity: "high",
47
- fixed: "7.0.12",
48
- reference: "https://example.com/advisory",
49
- });
50
- expect(cacheWrite).toHaveBeenCalledOnce();
51
- });
52
- it("includes ecosystem in the OSV body when provided", async () => {
53
- mockFetch.mockResolvedValue({ ok: true, json: async () => ({}) });
54
- await queryOsv({ name: "postgresql", ecosystem: "Debian" }, "15.2", { noCache: true });
55
- const body = JSON.parse(mockFetch.mock.calls[0][1].body);
56
- expect(body.package).toEqual({ name: "postgresql", ecosystem: "Debian" });
57
- });
58
- it("returns empty when version is empty", async () => {
59
- const findings = await queryOsv({ name: "redis" }, "", { noCache: true });
60
- expect(findings).toEqual([]);
61
- expect(mockFetch).not.toHaveBeenCalled();
62
- });
63
- it("returns [] on network error when no stale cache is present", async () => {
64
- mockFetch.mockRejectedValue(new Error("network down"));
65
- const findings = await queryOsv({ name: "redis" }, "7.0.99", { noCache: true });
66
- expect(findings).toEqual([]);
67
- });
68
- it("serves a fresh cached entry without hitting the network", async () => {
69
- cacheRead.mockReturnValue([{ id: "CVE-cached", summary: "from cache" }]);
70
- const findings = await queryOsv({ name: "redis" }, "7.0.5");
71
- expect(mockFetch).not.toHaveBeenCalled();
72
- expect(findings[0].id).toBe("CVE-cached");
73
- });
74
- it("falls back to stale cache on network error", async () => {
75
- cacheStale.mockReturnValue({ data: [{ id: "CVE-stale", summary: "from cache" }], fetchedAt: 1 });
76
- mockFetch.mockRejectedValue(new Error("offline"));
77
- const findings = await queryOsv({ name: "redis" }, "7.0.5", { noCache: true });
78
- expect(findings[0].id).toBe("CVE-stale");
79
- });
80
- it("falls back to stale cache on non-2xx response", async () => {
81
- cacheStale.mockReturnValue({ data: [{ id: "CVE-stale", summary: "x" }], fetchedAt: 1 });
82
- mockFetch.mockResolvedValue({ ok: false, status: 500 });
83
- const findings = await queryOsv({ name: "redis" }, "7.0.5", { noCache: true });
84
- expect(findings[0].id).toBe("CVE-stale");
85
- });
86
- });
@@ -1,6 +0,0 @@
1
- import type { AuthState } from "../auth.js";
2
- import type { DetectionResult } from "./index.js";
3
- export interface ReportOptions {
4
- onProgress?: (step: string) => void;
5
- }
6
- export declare function generateReport(result: DetectionResult, auth: AuthState, opts?: ReportOptions): Promise<string>;
@@ -1,42 +0,0 @@
1
- import { type KubectlOptions } from "../kubectl.js";
2
- export type WorkloadKind = "Deployment" | "StatefulSet" | "DaemonSet";
3
- export interface WorkloadRef {
4
- kind: WorkloadKind;
5
- namespace: string;
6
- name: string;
7
- hosts?: string[];
8
- }
9
- export declare function workloadKey(ref: {
10
- kind: string;
11
- namespace: string;
12
- name: string;
13
- }): string;
14
- export interface ImageCandidate {
15
- source: "image";
16
- image: string;
17
- workload: WorkloadRef;
18
- container: string;
19
- }
20
- export interface LabelCandidate {
21
- source: "label";
22
- appName: string;
23
- appVersion: string;
24
- workload: WorkloadRef;
25
- }
26
- export interface HelmCandidate {
27
- source: "helm";
28
- chart: string;
29
- chartVersion: string;
30
- appVersion?: string;
31
- namespace: string;
32
- releaseName: string;
33
- }
34
- export type Candidate = ImageCandidate | LabelCandidate | HelmCandidate;
35
- export declare function fetchWorkloadCandidates(options: KubectlOptions): Promise<Candidate[]>;
36
- export declare function fetchHelmCandidates(options: KubectlOptions): Promise<HelmCandidate[]>;
37
- /**
38
- * Build a map of workload key (Kind/namespace/name) → ingress hostnames.
39
- * Joins Ingresses → Services → workload pod-template labels best-effort.
40
- * Returns an empty map on failure (ingress visibility is non-essential).
41
- */
42
- export declare function fetchIngressHostMap(options: KubectlOptions): Promise<Map<string, string[]>>;
@@ -1,17 +0,0 @@
1
- import type { Issue } from "../monitor/types.js";
2
- export interface DiagnosisResult {
3
- analysis: string;
4
- action?: {
5
- name: string;
6
- safe: boolean;
7
- params: Record<string, unknown>;
8
- };
9
- verificationContract?: string;
10
- }
11
- export declare function diagnose(issues: Issue[], kbDir: string, clusterContext?: string, options?: {
12
- autoFix?: boolean;
13
- safeActions?: string[];
14
- noInteractive?: boolean;
15
- onApproval?: (action: string, params: Record<string, unknown>) => Promise<boolean>;
16
- onQuestion?: (question: string, choices: string[] | undefined) => Promise<void>;
17
- }): Promise<DiagnosisResult>;
@@ -1,119 +0,0 @@
1
- import { z } from "zod";
2
- export declare const safeActions: Set<string>;
3
- export declare const riskyActions: Set<string>;
4
- export declare function isActionSafe(action: string): boolean;
5
- export declare const kubectlGetLogsSchema: z.ZodObject<{
6
- namespace: z.ZodString;
7
- pod: z.ZodString;
8
- container: z.ZodOptional<z.ZodString>;
9
- tail: z.ZodDefault<z.ZodNumber>;
10
- }, "strip", z.ZodTypeAny, {
11
- namespace: string;
12
- pod: string;
13
- tail: number;
14
- container?: string | undefined;
15
- }, {
16
- namespace: string;
17
- pod: string;
18
- container?: string | undefined;
19
- tail?: number | undefined;
20
- }>;
21
- export declare const kubectlDescribeSchema: z.ZodObject<{
22
- namespace: z.ZodString;
23
- resource_type: z.ZodEnum<["pod", "deployment", "service", "statefulset", "daemonset", "replicaset", "job", "cronjob", "ingress", "node", "persistentvolumeclaim", "configmap", "endpoints"]>;
24
- name: z.ZodString;
25
- }, "strip", z.ZodTypeAny, {
26
- name: string;
27
- namespace: string;
28
- resource_type: "service" | "node" | "pod" | "deployment" | "statefulset" | "daemonset" | "replicaset" | "job" | "cronjob" | "ingress" | "persistentvolumeclaim" | "configmap" | "endpoints";
29
- }, {
30
- name: string;
31
- namespace: string;
32
- resource_type: "service" | "node" | "pod" | "deployment" | "statefulset" | "daemonset" | "replicaset" | "job" | "cronjob" | "ingress" | "persistentvolumeclaim" | "configmap" | "endpoints";
33
- }>;
34
- export declare const restartPodSchema: z.ZodObject<{
35
- namespace: z.ZodString;
36
- pod: z.ZodString;
37
- }, "strip", z.ZodTypeAny, {
38
- namespace: string;
39
- pod: string;
40
- }, {
41
- namespace: string;
42
- pod: string;
43
- }>;
44
- export declare const rolloutRestartSchema: z.ZodObject<{
45
- namespace: z.ZodString;
46
- deployment: z.ZodString;
47
- }, "strip", z.ZodTypeAny, {
48
- namespace: string;
49
- deployment: string;
50
- }, {
51
- namespace: string;
52
- deployment: string;
53
- }>;
54
- export declare const scaleDeploymentSchema: z.ZodObject<{
55
- namespace: z.ZodString;
56
- deployment: z.ZodString;
57
- replicas: z.ZodNumber;
58
- }, "strip", z.ZodTypeAny, {
59
- namespace: string;
60
- deployment: string;
61
- replicas: number;
62
- }, {
63
- namespace: string;
64
- deployment: string;
65
- replicas: number;
66
- }>;
67
- export declare const getEventsSchema: z.ZodObject<{
68
- namespace: z.ZodString;
69
- }, "strip", z.ZodTypeAny, {
70
- namespace: string;
71
- }, {
72
- namespace: string;
73
- }>;
74
- export declare const setResourcesSchema: z.ZodObject<{
75
- namespace: z.ZodString;
76
- deployment: z.ZodString;
77
- container: z.ZodOptional<z.ZodString>;
78
- memory_request: z.ZodOptional<z.ZodString>;
79
- memory_limit: z.ZodOptional<z.ZodString>;
80
- cpu_request: z.ZodOptional<z.ZodString>;
81
- cpu_limit: z.ZodOptional<z.ZodString>;
82
- }, "strip", z.ZodTypeAny, {
83
- namespace: string;
84
- deployment: string;
85
- container?: string | undefined;
86
- memory_request?: string | undefined;
87
- memory_limit?: string | undefined;
88
- cpu_request?: string | undefined;
89
- cpu_limit?: string | undefined;
90
- }, {
91
- namespace: string;
92
- deployment: string;
93
- container?: string | undefined;
94
- memory_request?: string | undefined;
95
- memory_limit?: string | undefined;
96
- cpu_request?: string | undefined;
97
- cpu_limit?: string | undefined;
98
- }>;
99
- export declare function getLogs(input: z.infer<typeof kubectlGetLogsSchema>, context?: {
100
- context?: string;
101
- }): Promise<string>;
102
- export declare function describeResource(input: z.infer<typeof kubectlDescribeSchema>, context?: {
103
- context?: string;
104
- }): Promise<string>;
105
- export declare function restartPod(input: z.infer<typeof restartPodSchema>, context?: {
106
- context?: string;
107
- }): Promise<string>;
108
- export declare function rolloutRestart(input: z.infer<typeof rolloutRestartSchema>, context?: {
109
- context?: string;
110
- }): Promise<string>;
111
- export declare function scaleDeployment(input: z.infer<typeof scaleDeploymentSchema>, context?: {
112
- context?: string;
113
- }): Promise<string>;
114
- export declare function getEvents(input: z.infer<typeof getEventsSchema>, context?: {
115
- context?: string;
116
- }): Promise<string>;
117
- export declare function setResources(input: z.infer<typeof setResourcesSchema>, context?: {
118
- context?: string;
119
- }): Promise<string>;
@@ -1 +0,0 @@
1
- export declare function buildSystemPrompt(kbDir: string): string;
@@ -1,12 +0,0 @@
1
- export declare function ensureKbDir(kbDir: string): void;
2
- export declare function writeClusterKb(kbDir: string, content: string): void;
3
- export declare function writeApplicationsKb(kbDir: string, content: string): void;
4
- export declare function writeProjectKb(kbDir: string, projectName: string, content: string): void;
5
- export declare function writeRunbook(kbDir: string, name: string, content: string): void;
6
- /**
7
- * Write a gave-up issue to the unresolved/ directory.
8
- * Files are named by issue key so repeated give-ups overwrite rather than accumulate.
9
- * The agent reads these as KB context on future runs.
10
- */
11
- export declare function writeUnresolved(kbDir: string, issueKey: string, content: string): void;
12
- export declare function writeIncident(kbDir: string, date: string, name: string, content: string): void;
@@ -1,7 +0,0 @@
1
- export interface KubeContext {
2
- name: string;
3
- cluster: string;
4
- current: boolean;
5
- }
6
- export declare function listContexts(): Promise<KubeContext[]>;
7
- export declare function pickContext(): Promise<string>;
package/dist/kubectl.d.ts DELETED
@@ -1,13 +0,0 @@
1
- export declare class KubectlError extends Error {
2
- readonly stderr?: string | undefined;
3
- readonly exitCode?: number | undefined;
4
- constructor(message: string, stderr?: string | undefined, exitCode?: number | undefined);
5
- }
6
- export declare function parseKubectlJson(raw: string): unknown;
7
- export interface KubectlOptions {
8
- context?: string;
9
- namespace?: string;
10
- timeout?: number;
11
- }
12
- export declare function kubectl(args: string[], options?: KubectlOptions): Promise<string>;
13
- export declare function kubectlJson(args: string[], options?: KubectlOptions): Promise<unknown>;
@@ -1,71 +0,0 @@
1
- import type { Issue } from "./types.js";
2
- interface PodStatus {
3
- metadata: {
4
- name: string;
5
- namespace: string;
6
- };
7
- status: {
8
- phase: string;
9
- reason?: string;
10
- containerStatuses?: Array<{
11
- name: string;
12
- state: {
13
- waiting?: {
14
- reason?: string;
15
- };
16
- terminated?: {
17
- reason?: string;
18
- };
19
- running?: Record<string, unknown>;
20
- };
21
- lastState?: {
22
- terminated?: {
23
- reason?: string;
24
- };
25
- };
26
- restartCount: number;
27
- }>;
28
- };
29
- }
30
- interface NodeStatus {
31
- metadata: {
32
- name: string;
33
- };
34
- status: {
35
- conditions: Array<{
36
- type: string;
37
- status: string;
38
- reason?: string;
39
- }>;
40
- };
41
- }
42
- export declare function findPodIssues(podList: {
43
- items: PodStatus[];
44
- }): Issue[];
45
- interface JobStatus {
46
- metadata: {
47
- name: string;
48
- namespace: string;
49
- };
50
- status: {
51
- failed?: number;
52
- succeeded?: number;
53
- active?: number;
54
- conditions?: Array<{
55
- type: string;
56
- status: string;
57
- reason?: string;
58
- message?: string;
59
- }>;
60
- };
61
- spec?: {
62
- backoffLimit?: number;
63
- };
64
- }
65
- export declare function findJobIssues(jobList: {
66
- items: JobStatus[];
67
- }): Issue[];
68
- export declare function findNodeIssues(nodeList: {
69
- items: NodeStatus[];
70
- }): Issue[];
71
- export {};
@@ -1,17 +0,0 @@
1
- import { type KubectlOptions } from "../kubectl.js";
2
- import type { Issue } from "./types.js";
3
- export type IssueCallback = (issues: Issue[]) => void | Promise<void>;
4
- export type ResolveCallback = (resolvedKeys: string[]) => void | Promise<void>;
5
- export interface CheckSummary {
6
- issues: Issue[];
7
- podCount: number;
8
- nodeCount: number;
9
- namespaceCount: number;
10
- }
11
- export declare function runChecks(options: KubectlOptions): Promise<Issue[]>;
12
- export declare function runChecks(options: KubectlOptions, withSummary: true): Promise<CheckSummary>;
13
- export declare function computeResolvedKeys(activeKeys: Set<string>, currentKeys: Set<string>): string[];
14
- export declare function updateActiveKeys(activeKeys: Set<string>, resolvedKeys: string[], currentKeys: Set<string>): void;
15
- export declare function startMonitor(options: KubectlOptions, intervalMs: number, onIssues: IssueCallback, onResolved?: ResolveCallback, onFirstCycle?: () => void): {
16
- stop: () => void;
17
- };
@@ -1 +0,0 @@
1
- export {};
@@ -1,21 +0,0 @@
1
- import { describe, it, expect } from "vitest";
2
- import { computeResolvedKeys, updateActiveKeys } from "./index.js";
3
- describe("resolve tracking", () => {
4
- it("returns keys that disappeared since last tick", () => {
5
- const active = new Set(["pod_crashloop:prod:web", "pod_oom:prod:worker"]);
6
- const current = new Set(["pod_oom:prod:worker"]);
7
- expect(computeResolvedKeys(active, current)).toEqual(["pod_crashloop:prod:web"]);
8
- });
9
- it("returns empty array when nothing cleared", () => {
10
- const active = new Set(["pod_crashloop:prod:web"]);
11
- const current = new Set(["pod_crashloop:prod:web"]);
12
- expect(computeResolvedKeys(active, current)).toEqual([]);
13
- });
14
- it("updates active set correctly after resolve", () => {
15
- const active = new Set(["pod_crashloop:prod:web", "pod_oom:prod:worker"]);
16
- const current = new Set(["pod_oom:prod:worker", "node_not_ready::node1"]);
17
- const resolved = computeResolvedKeys(active, current);
18
- updateActiveKeys(active, resolved, current);
19
- expect([...active].sort()).toEqual(["node_not_ready::node1", "pod_oom:prod:worker"]);
20
- });
21
- });
@@ -1,11 +0,0 @@
1
- export type Severity = "info" | "warning" | "critical";
2
- export type IssueKind = "pod_crashloop" | "pod_oom" | "pod_image_pull" | "pod_pending" | "pod_failed" | "pod_evicted" | "pod_error" | "node_not_ready" | "node_pressure" | "cert_expiring" | "resource_high" | "job_failed" | "rollout_stuck";
3
- export interface Issue {
4
- kind: IssueKind;
5
- severity: Severity;
6
- namespace: string;
7
- resource: string;
8
- message: string;
9
- details: Record<string, unknown>;
10
- timestamp: Date;
11
- }