kubeagent 0.1.33 → 0.1.35
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.
- package/README.md +9 -0
- package/dist/cli.js +10 -3
- package/dist/monitor/index.d.ts +1 -1
- package/dist/monitor/index.js +7 -1
- package/dist/proxy-client.d.ts +1 -0
- package/dist/proxy-client.js +13 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -89,6 +89,15 @@ Supported channels:
|
|
|
89
89
|
| **Microsoft Teams** | Paste a Teams incoming webhook URL |
|
|
90
90
|
| **Custom Webhook** | Any HTTP endpoint that accepts JSON payloads |
|
|
91
91
|
|
|
92
|
+
## Observability
|
|
93
|
+
|
|
94
|
+
The SaaS server exposes:
|
|
95
|
+
|
|
96
|
+
- `GET /health` for Kubernetes readiness/liveness probes
|
|
97
|
+
- `GET /metrics` for Prometheus scraping
|
|
98
|
+
|
|
99
|
+
Kubernetes monitoring manifests live in [`k8s/servicemonitor.yaml`](k8s/servicemonitor.yaml) and [`k8s/prometheusrule.yaml`](k8s/prometheusrule.yaml). Internal rollout notes are in [`docs/MONITORING.md`](docs/MONITORING.md).
|
|
100
|
+
|
|
92
101
|
## Requirements
|
|
93
102
|
|
|
94
103
|
- Node.js >= 22
|
package/dist/cli.js
CHANGED
|
@@ -18,7 +18,7 @@ import { sendResolve } from "./notify/index.js";
|
|
|
18
18
|
import { diagnose } from "./diagnoser/index.js";
|
|
19
19
|
import { join } from "node:path";
|
|
20
20
|
import { loadAuth, loginBrowser, loginDevice, createApiKey, showAccount, clearAuth } from "./auth.js";
|
|
21
|
-
import { fetchSlackWebhook } from "./proxy-client.js";
|
|
21
|
+
import { fetchSlackWebhook, pingWatchCycle } from "./proxy-client.js";
|
|
22
22
|
import { createInterface } from "node:readline";
|
|
23
23
|
import { scanProjectDirectory, matchProjectsToWorkloads, bestMatches } from "./onboard/project-matcher.js";
|
|
24
24
|
import { scanCluster } from "./onboard/cluster-scan.js";
|
|
@@ -156,6 +156,10 @@ program
|
|
|
156
156
|
await handleIssues(issues, config, context, noInteractive);
|
|
157
157
|
}, async (resolvedKeys) => {
|
|
158
158
|
await sendResolve(resolvedKeys, config, context);
|
|
159
|
+
}, () => {
|
|
160
|
+
if (auth?.apiKey) {
|
|
161
|
+
void pingWatchCycle(auth);
|
|
162
|
+
}
|
|
159
163
|
});
|
|
160
164
|
// Handle graceful shutdown
|
|
161
165
|
process.on("SIGINT", () => {
|
|
@@ -458,9 +462,11 @@ program
|
|
|
458
462
|
console.log(` Extra credits: ${balance.extraRemaining.toLocaleString()}`);
|
|
459
463
|
}
|
|
460
464
|
console.log(` Total remaining: ${balance.totalRemaining.toLocaleString()}`);
|
|
465
|
+
const isTrial = balance.plan === "trial";
|
|
461
466
|
if (balance.resetsAt) {
|
|
462
467
|
const resetDate = new Date(balance.resetsAt).toLocaleDateString(undefined, { month: "short", day: "numeric", year: "numeric" });
|
|
463
|
-
|
|
468
|
+
const label = isTrial ? "Trial ends: " : "Resets: ";
|
|
469
|
+
console.log(` ${label} ${resetDate}`);
|
|
464
470
|
}
|
|
465
471
|
// Exhausted balance warning
|
|
466
472
|
if (balance.totalRemaining === 0) {
|
|
@@ -469,7 +475,8 @@ program
|
|
|
469
475
|
}
|
|
470
476
|
else if (balance.monthlyTotal > 0 && balance.monthlyRemaining < balance.monthlyTotal * 0.2) {
|
|
471
477
|
const pct = Math.round((balance.monthlyRemaining / balance.monthlyTotal) * 100);
|
|
472
|
-
|
|
478
|
+
const noun = isTrial ? "trial tokens" : "monthly tokens";
|
|
479
|
+
console.log("\n" + chalk.yellow(` ⚠ Low balance: ${pct}% of ${noun} remaining.`));
|
|
473
480
|
console.log(chalk.dim(` Upgrade or buy extra credits: `) + chalk.cyan(upgradeUrl));
|
|
474
481
|
}
|
|
475
482
|
console.log();
|
package/dist/monitor/index.d.ts
CHANGED
|
@@ -12,6 +12,6 @@ export declare function runChecks(options: KubectlOptions): Promise<Issue[]>;
|
|
|
12
12
|
export declare function runChecks(options: KubectlOptions, withSummary: true): Promise<CheckSummary>;
|
|
13
13
|
export declare function computeResolvedKeys(activeKeys: Set<string>, currentKeys: Set<string>): string[];
|
|
14
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): {
|
|
15
|
+
export declare function startMonitor(options: KubectlOptions, intervalMs: number, onIssues: IssueCallback, onResolved?: ResolveCallback, onFirstCycle?: () => void): {
|
|
16
16
|
stop: () => void;
|
|
17
17
|
};
|
package/dist/monitor/index.js
CHANGED
|
@@ -68,13 +68,15 @@ export function updateActiveKeys(activeKeys, resolvedKeys, currentKeys) {
|
|
|
68
68
|
for (const k of currentKeys)
|
|
69
69
|
activeKeys.add(k);
|
|
70
70
|
}
|
|
71
|
-
export function startMonitor(options, intervalMs, onIssues, onResolved) {
|
|
71
|
+
export function startMonitor(options, intervalMs, onIssues, onResolved, onFirstCycle) {
|
|
72
72
|
let running = true;
|
|
73
73
|
let inFlight = false;
|
|
74
|
+
let firstCycleFired = false;
|
|
74
75
|
// Tracks when each pending pod was first seen: "namespace/name" -> Date
|
|
75
76
|
const pendingSince = new Map();
|
|
76
77
|
const activeIssueKeys = new Set();
|
|
77
78
|
let pendingRecheckTimer = null;
|
|
79
|
+
// fallow-ignore-next-line complexity
|
|
78
80
|
const tick = async () => {
|
|
79
81
|
if (!running || inFlight)
|
|
80
82
|
return;
|
|
@@ -126,6 +128,10 @@ export function startMonitor(options, intervalMs, onIssues, onResolved) {
|
|
|
126
128
|
console.error("Resolve callback failed:", err.message);
|
|
127
129
|
}
|
|
128
130
|
}
|
|
131
|
+
if (!firstCycleFired) {
|
|
132
|
+
firstCycleFired = true;
|
|
133
|
+
onFirstCycle?.();
|
|
134
|
+
}
|
|
129
135
|
if (reportableIssues.length > 0 && running) {
|
|
130
136
|
process.stdout.write("\r\x1b[K");
|
|
131
137
|
await onIssues(reportableIssues);
|
package/dist/proxy-client.d.ts
CHANGED
package/dist/proxy-client.js
CHANGED
|
@@ -126,3 +126,16 @@ export async function notifyViaServer(auth, issues, clusterContext) {
|
|
|
126
126
|
// Silent — don't break the watch loop if server is unreachable
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
|
+
export async function pingWatchCycle(auth) {
|
|
130
|
+
const apiKey = auth.apiKey ?? auth.token;
|
|
131
|
+
try {
|
|
132
|
+
await fetch(`${auth.serverUrl}/watch-cycle`, {
|
|
133
|
+
method: "POST",
|
|
134
|
+
headers: { Authorization: `ApiKey ${apiKey}` },
|
|
135
|
+
signal: AbortSignal.timeout(5_000),
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
catch {
|
|
139
|
+
// Silent — non-blocking telemetry
|
|
140
|
+
}
|
|
141
|
+
}
|