kubeagent 0.1.14 → 0.1.16
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/auth.js +13 -3
- package/dist/orchestrator.js +10 -0
- package/dist/telemetry.js +6 -2
- package/package.json +1 -1
package/dist/auth.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { readFileSync, writeFileSync, existsSync, mkdirSync, unlinkSync } from "node:fs";
|
|
1
|
+
import { readFileSync, writeFileSync, existsSync, mkdirSync, unlinkSync, chmodSync } from "node:fs";
|
|
2
2
|
import { join } from "node:path";
|
|
3
3
|
import { createServer } from "node:http";
|
|
4
4
|
import { randomBytes } from "node:crypto";
|
|
@@ -31,8 +31,18 @@ export function loadAuth() {
|
|
|
31
31
|
export function saveAuth(auth) {
|
|
32
32
|
const dir = configDir();
|
|
33
33
|
if (!existsSync(dir))
|
|
34
|
-
mkdirSync(dir, { recursive: true });
|
|
35
|
-
|
|
34
|
+
mkdirSync(dir, { recursive: true, mode: 0o700 });
|
|
35
|
+
const path = authPath();
|
|
36
|
+
// Write with mode 0600 so only the owning user can read the file.
|
|
37
|
+
// This is the fallback for platforms where a system keychain is unavailable.
|
|
38
|
+
// To use the OS keychain instead (recommended for production), install `keytar`
|
|
39
|
+
// and store auth.token and auth.apiKey there, keeping only non-secret fields here.
|
|
40
|
+
writeFileSync(path, JSON.stringify(auth, null, 2), { mode: 0o600 });
|
|
41
|
+
// Ensure permissions even if the file already existed with looser permissions.
|
|
42
|
+
try {
|
|
43
|
+
chmodSync(path, 0o600);
|
|
44
|
+
}
|
|
45
|
+
catch { /* non-POSIX platforms ignore this */ }
|
|
36
46
|
}
|
|
37
47
|
export function clearAuth() {
|
|
38
48
|
const path = authPath();
|
package/dist/orchestrator.js
CHANGED
|
@@ -11,6 +11,7 @@ import { renderMarkdown, sectionHeader, commandBox } from "./render.js";
|
|
|
11
11
|
import { broadcastQuestion } from "./notify/index.js";
|
|
12
12
|
import readline from "node:readline";
|
|
13
13
|
const MAX_ATTEMPTS = 3;
|
|
14
|
+
let localChannelWarningShown = false;
|
|
14
15
|
const issueHistory = new Map();
|
|
15
16
|
function issueKey(issue) {
|
|
16
17
|
return `${issue.kind}:${issue.namespace ?? ""}:${issue.resource ?? ""}`;
|
|
@@ -115,6 +116,15 @@ export async function handleIssues(issues, config, clusterContext, noInteractive
|
|
|
115
116
|
}
|
|
116
117
|
if (actionableIssues.length === 0)
|
|
117
118
|
return;
|
|
119
|
+
// Warn once if user still has local notification channels configured
|
|
120
|
+
if (config.notifications.channels.length && !localChannelWarningShown) {
|
|
121
|
+
localChannelWarningShown = true;
|
|
122
|
+
console.log(chalk.yellow("⚠")
|
|
123
|
+
+ " Local notification channels detected in config. "
|
|
124
|
+
+ "These are no longer used — configure notifications on your dashboard instead: "
|
|
125
|
+
+ chalk.cyan("https://app.kubeagent.net/dashboard"));
|
|
126
|
+
}
|
|
127
|
+
// Dispatch via server when authenticated (SaaS-managed integrations)
|
|
118
128
|
const auth = loadAuth();
|
|
119
129
|
if (auth?.apiKey) {
|
|
120
130
|
await notifyViaServer(auth, actionableIssues, clusterContext);
|
package/dist/telemetry.js
CHANGED
|
@@ -8,16 +8,16 @@ export function sendTelemetry(cliVersion) {
|
|
|
8
8
|
// Only fire once per machine
|
|
9
9
|
if (existsSync(SENT_FILE))
|
|
10
10
|
return;
|
|
11
|
-
//
|
|
11
|
+
// Ensure directory exists
|
|
12
12
|
try {
|
|
13
13
|
if (!existsSync(TELEMETRY_DIR))
|
|
14
14
|
mkdirSync(TELEMETRY_DIR, { recursive: true });
|
|
15
|
-
writeFileSync(SENT_FILE, new Date().toISOString());
|
|
16
15
|
}
|
|
17
16
|
catch {
|
|
18
17
|
return;
|
|
19
18
|
}
|
|
20
19
|
// Fire-and-forget — never block the CLI
|
|
20
|
+
// Only mark as sent after successful delivery
|
|
21
21
|
const payload = JSON.stringify({
|
|
22
22
|
event: "cli_first_run",
|
|
23
23
|
cliVersion,
|
|
@@ -30,5 +30,9 @@ export function sendTelemetry(cliVersion) {
|
|
|
30
30
|
headers: { "Content-Type": "application/json" },
|
|
31
31
|
body: payload,
|
|
32
32
|
signal: AbortSignal.timeout(5000),
|
|
33
|
+
}).then((res) => {
|
|
34
|
+
if (res.ok) {
|
|
35
|
+
writeFileSync(SENT_FILE, new Date().toISOString());
|
|
36
|
+
}
|
|
33
37
|
}).catch(() => { });
|
|
34
38
|
}
|