kubeagent 0.1.32 → 0.1.34
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/dist/cli.js +5 -1
- package/dist/monitor/index.d.ts +1 -1
- package/dist/monitor/index.js +7 -1
- package/dist/onboard/index.js +15 -0
- package/dist/proxy-client.d.ts +1 -0
- package/dist/proxy-client.js +13 -0
- package/package.json +1 -1
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", () => {
|
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/onboard/index.js
CHANGED
|
@@ -8,9 +8,20 @@ import { writeClusterKb, writeProjectKb, ensureKbDir } from "../kb/writer.js";
|
|
|
8
8
|
import { saveConfig, loadConfig, configDir, ALL_ACTIONS, DEFAULT_SAFE_ACTIONS } from "../config.js";
|
|
9
9
|
import { interactiveAddChannel } from "../notify/setup.js";
|
|
10
10
|
import { pickContext } from "../kubectl-config.js";
|
|
11
|
+
import { loadAuth } from "../auth.js";
|
|
11
12
|
import { join } from "node:path";
|
|
12
13
|
import { homedir } from "node:os";
|
|
13
14
|
import readline from "node:readline";
|
|
15
|
+
function pingOnboardComplete() {
|
|
16
|
+
const auth = loadAuth();
|
|
17
|
+
if (!auth?.apiKey)
|
|
18
|
+
return;
|
|
19
|
+
fetch(`${auth.serverUrl}/v1/onboard/complete`, {
|
|
20
|
+
method: "POST",
|
|
21
|
+
headers: { Authorization: `ApiKey ${auth.apiKey}` },
|
|
22
|
+
signal: AbortSignal.timeout(5000),
|
|
23
|
+
}).catch(() => { });
|
|
24
|
+
}
|
|
14
25
|
function expandPath(p) {
|
|
15
26
|
return p.startsWith("~/") ? homedir() + p.slice(1) : p;
|
|
16
27
|
}
|
|
@@ -147,6 +158,8 @@ export async function onboard(opts = {}) {
|
|
|
147
158
|
notifications: { ...existingConfig.notifications, channels: newChannels },
|
|
148
159
|
clusters: existingConfig.clusters.map((c) => c.context === contextName ? { ...c, codepaths: codePaths.map((p) => p.path) } : c),
|
|
149
160
|
});
|
|
161
|
+
// fallow-ignore-next-line code-duplication
|
|
162
|
+
pingOnboardComplete();
|
|
150
163
|
console.log(chalk.green(`\nKnowledge base written to ${kbDir}`));
|
|
151
164
|
console.log(chalk.green(`Config saved to ${configDir()}/config.yaml`));
|
|
152
165
|
console.log(chalk.dim("\nRun `kubeagent watch` to start monitoring."));
|
|
@@ -341,6 +354,8 @@ export async function onboard(opts = {}) {
|
|
|
341
354
|
config.clusters.push(clusterConfig);
|
|
342
355
|
}
|
|
343
356
|
saveConfig(config);
|
|
357
|
+
// fallow-ignore-next-line code-duplication
|
|
358
|
+
pingOnboardComplete();
|
|
344
359
|
console.log(chalk.green(`\nKnowledge base written to ${kbDir}`));
|
|
345
360
|
console.log(chalk.green(`Config saved to ${configDir()}/config.yaml`));
|
|
346
361
|
console.log(chalk.dim("\nRun `kubeagent watch` to start monitoring."));
|
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
|
+
}
|