open-agents-ai 0.187.366 → 0.187.368
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/index.js +250 -102
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -539097,6 +539097,7 @@ var init_neovim_mode = __esm({
|
|
|
539097
539097
|
var daemon_exports = {};
|
|
539098
539098
|
__export(daemon_exports, {
|
|
539099
539099
|
ensureDaemon: () => ensureDaemon,
|
|
539100
|
+
forceKillDaemon: () => forceKillDaemon,
|
|
539100
539101
|
getDaemonPid: () => getDaemonPid,
|
|
539101
539102
|
getDaemonStatus: () => getDaemonStatus,
|
|
539102
539103
|
isDaemonRunning: () => isDaemonRunning,
|
|
@@ -539200,6 +539201,67 @@ function stopDaemon() {
|
|
|
539200
539201
|
return false;
|
|
539201
539202
|
}
|
|
539202
539203
|
}
|
|
539204
|
+
async function forceKillDaemon(port) {
|
|
539205
|
+
const p2 = port ?? getDaemonPort();
|
|
539206
|
+
let killed = 0;
|
|
539207
|
+
const pid = getDaemonPid();
|
|
539208
|
+
if (pid) {
|
|
539209
|
+
try {
|
|
539210
|
+
process.kill(pid, "SIGTERM");
|
|
539211
|
+
killed++;
|
|
539212
|
+
} catch {
|
|
539213
|
+
}
|
|
539214
|
+
for (let i2 = 0; i2 < 20; i2++) {
|
|
539215
|
+
await new Promise((r2) => setTimeout(r2, 100));
|
|
539216
|
+
try {
|
|
539217
|
+
process.kill(pid, 0);
|
|
539218
|
+
} catch {
|
|
539219
|
+
break;
|
|
539220
|
+
}
|
|
539221
|
+
}
|
|
539222
|
+
try {
|
|
539223
|
+
process.kill(pid, 0);
|
|
539224
|
+
process.kill(pid, "SIGKILL");
|
|
539225
|
+
killed++;
|
|
539226
|
+
} catch {
|
|
539227
|
+
}
|
|
539228
|
+
try {
|
|
539229
|
+
unlinkSync16(PID_FILE2);
|
|
539230
|
+
} catch {
|
|
539231
|
+
}
|
|
539232
|
+
}
|
|
539233
|
+
try {
|
|
539234
|
+
const { execSync: execSync57 } = await import("node:child_process");
|
|
539235
|
+
const out = execSync57(
|
|
539236
|
+
`lsof -ti :${p2} 2>/dev/null || fuser ${p2}/tcp 2>/dev/null || true`,
|
|
539237
|
+
{ encoding: "utf8", timeout: 3e3 }
|
|
539238
|
+
).trim();
|
|
539239
|
+
const pids = out.split(/[\s\n]+/).map((s2) => parseInt(s2, 10)).filter((n2) => Number.isFinite(n2) && n2 > 0 && n2 !== process.pid);
|
|
539240
|
+
for (const otherPid of pids) {
|
|
539241
|
+
try {
|
|
539242
|
+
process.kill(otherPid, "SIGTERM");
|
|
539243
|
+
killed++;
|
|
539244
|
+
} catch {
|
|
539245
|
+
}
|
|
539246
|
+
}
|
|
539247
|
+
if (pids.length > 0) {
|
|
539248
|
+
await new Promise((r2) => setTimeout(r2, 1e3));
|
|
539249
|
+
for (const otherPid of pids) {
|
|
539250
|
+
try {
|
|
539251
|
+
process.kill(otherPid, 0);
|
|
539252
|
+
process.kill(otherPid, "SIGKILL");
|
|
539253
|
+
} catch {
|
|
539254
|
+
}
|
|
539255
|
+
}
|
|
539256
|
+
}
|
|
539257
|
+
} catch {
|
|
539258
|
+
}
|
|
539259
|
+
for (let i2 = 0; i2 < 50; i2++) {
|
|
539260
|
+
if (!await isDaemonRunning(p2)) return killed;
|
|
539261
|
+
await new Promise((r2) => setTimeout(r2, 100));
|
|
539262
|
+
}
|
|
539263
|
+
return killed;
|
|
539264
|
+
}
|
|
539203
539265
|
async function ensureDaemon() {
|
|
539204
539266
|
const port = getDaemonPort();
|
|
539205
539267
|
if (await isDaemonRunning(port)) {
|
|
@@ -544211,77 +544273,84 @@ async function handleSlashCommand(input, ctx3) {
|
|
|
544211
544273
|
await showColorMenu(ctx3);
|
|
544212
544274
|
return "handled";
|
|
544213
544275
|
}
|
|
544214
|
-
case "apikey":
|
|
544215
|
-
|
|
544216
|
-
|
|
544217
|
-
|
|
544218
|
-
|
|
544219
|
-
|
|
544220
|
-
|
|
544221
|
-
|
|
544222
|
-
|
|
544223
|
-
|
|
544224
|
-
|
|
544225
|
-
|
|
544226
|
-
|
|
544227
|
-
if (existsSync91(p2)) key = readFileSync72(p2, "utf8").trim();
|
|
544228
|
-
} catch {
|
|
544229
|
-
}
|
|
544276
|
+
case "apikey":
|
|
544277
|
+
case "key": {
|
|
544278
|
+
const apiKeyHandler = async ({ arg: a2 }) => {
|
|
544279
|
+
const action = (a2 || "show").trim().toLowerCase();
|
|
544280
|
+
let key = process.env["OA_API_KEY"] || "";
|
|
544281
|
+
if (!key) {
|
|
544282
|
+
try {
|
|
544283
|
+
const { homedir: homedir41 } = await import("node:os");
|
|
544284
|
+
const { readFileSync: readFileSync72, existsSync: existsSync91 } = await import("node:fs");
|
|
544285
|
+
const { join: join110 } = await import("node:path");
|
|
544286
|
+
const p2 = join110(homedir41(), ".open-agents", "api.key");
|
|
544287
|
+
if (existsSync91(p2)) key = readFileSync72(p2, "utf8").trim();
|
|
544288
|
+
} catch {
|
|
544230
544289
|
}
|
|
544231
|
-
|
|
544232
|
-
|
|
544233
|
-
|
|
544234
|
-
|
|
544235
|
-
}
|
|
544236
|
-
renderInfo2(`API key: ${c3.bold(c3.yellow(key))}`);
|
|
544237
|
-
renderInfo2("Use Authorization: Bearer <key> or paste in the Web UI key modal.");
|
|
544290
|
+
}
|
|
544291
|
+
if (action === "show") {
|
|
544292
|
+
if (!key) {
|
|
544293
|
+
renderWarning2("No API key set. Use /access any to generate one.");
|
|
544238
544294
|
return "handled";
|
|
544239
544295
|
}
|
|
544240
|
-
|
|
544241
|
-
|
|
544242
|
-
|
|
544243
|
-
|
|
544244
|
-
|
|
544245
|
-
|
|
544246
|
-
|
|
544247
|
-
const tryCmd = (cmd2, args) => spawnSync6(cmd2, args, { input: key, encoding: "utf8" });
|
|
544248
|
-
let ok2 = false;
|
|
544249
|
-
if (process.platform === "darwin") {
|
|
544250
|
-
ok2 = tryCmd("pbcopy", []).status === 0;
|
|
544251
|
-
} else if (process.platform === "win32") {
|
|
544252
|
-
ok2 = tryCmd("clip", []).status === 0;
|
|
544253
|
-
} else {
|
|
544254
|
-
ok2 = tryCmd("wl-copy", []).status === 0 || tryCmd("xclip", ["-selection", "clipboard"]).status === 0;
|
|
544255
|
-
}
|
|
544256
|
-
renderInfo2(ok2 ? "Copied API key to clipboard." : "Copy failed — printed above, select to copy.");
|
|
544257
|
-
} catch {
|
|
544258
|
-
renderInfo2("Copy failed — printed above, select to copy.");
|
|
544259
|
-
}
|
|
544296
|
+
renderInfo2(`API key: ${c3.bold(c3.yellow(key))}`);
|
|
544297
|
+
renderInfo2("Use Authorization: Bearer <key> or paste in the Web UI key modal.");
|
|
544298
|
+
return "handled";
|
|
544299
|
+
}
|
|
544300
|
+
if (action === "copy") {
|
|
544301
|
+
if (!key) {
|
|
544302
|
+
renderWarning2("No API key set. Use /access any to generate one.");
|
|
544260
544303
|
return "handled";
|
|
544261
544304
|
}
|
|
544262
|
-
|
|
544263
|
-
|
|
544264
|
-
|
|
544265
|
-
|
|
544266
|
-
|
|
544267
|
-
|
|
544268
|
-
|
|
544269
|
-
|
|
544270
|
-
|
|
544271
|
-
|
|
544272
|
-
writeFileSync51(join110(dir, "api.key"), newKey + "\n", "utf8");
|
|
544273
|
-
renderInfo2(`New API key: ${c3.bold(c3.yellow(newKey))}`);
|
|
544274
|
-
renderInfo2("Restart the daemon to apply if needed. Use /access any to restart quickly.");
|
|
544275
|
-
} catch (e2) {
|
|
544276
|
-
renderError2(`Failed to rotate key: ${e2 instanceof Error ? e2.message : String(e2)}`);
|
|
544305
|
+
try {
|
|
544306
|
+
const { spawnSync: spawnSync6 } = await import("node:child_process");
|
|
544307
|
+
const tryCmd = (cmd2, args) => spawnSync6(cmd2, args, { input: key, encoding: "utf8" });
|
|
544308
|
+
let ok2 = false;
|
|
544309
|
+
if (process.platform === "darwin") {
|
|
544310
|
+
ok2 = tryCmd("pbcopy", []).status === 0;
|
|
544311
|
+
} else if (process.platform === "win32") {
|
|
544312
|
+
ok2 = tryCmd("clip", []).status === 0;
|
|
544313
|
+
} else {
|
|
544314
|
+
ok2 = tryCmd("wl-copy", []).status === 0 || tryCmd("xclip", ["-selection", "clipboard"]).status === 0;
|
|
544277
544315
|
}
|
|
544278
|
-
|
|
544316
|
+
renderInfo2(ok2 ? "Copied API key to clipboard." : "Copy failed — printed above, select to copy.");
|
|
544317
|
+
} catch {
|
|
544318
|
+
renderInfo2("Copy failed — printed above, select to copy.");
|
|
544279
544319
|
}
|
|
544280
|
-
renderInfo2("Usage: /apikey [show|copy|new]");
|
|
544281
544320
|
return "handled";
|
|
544282
544321
|
}
|
|
544322
|
+
if (action === "new") {
|
|
544323
|
+
try {
|
|
544324
|
+
const { randomBytes: randomBytes23 } = await import("node:crypto");
|
|
544325
|
+
const { homedir: homedir41 } = await import("node:os");
|
|
544326
|
+
const { mkdirSync: mkdirSync58, writeFileSync: writeFileSync51 } = await import("node:fs");
|
|
544327
|
+
const { join: join110 } = await import("node:path");
|
|
544328
|
+
const newKey = randomBytes23(16).toString("hex");
|
|
544329
|
+
process.env["OA_API_KEY"] = newKey;
|
|
544330
|
+
const dir = join110(homedir41(), ".open-agents");
|
|
544331
|
+
mkdirSync58(dir, { recursive: true });
|
|
544332
|
+
writeFileSync51(join110(dir, "api.key"), newKey + "\n", "utf8");
|
|
544333
|
+
renderInfo2(`New API key: ${c3.bold(c3.yellow(newKey))}`);
|
|
544334
|
+
renderInfo2("Restart the daemon to apply if needed. Use /access any to restart quickly.");
|
|
544335
|
+
} catch (e2) {
|
|
544336
|
+
renderError2(`Failed to rotate key: ${e2 instanceof Error ? e2.message : String(e2)}`);
|
|
544337
|
+
}
|
|
544338
|
+
return "handled";
|
|
544339
|
+
}
|
|
544340
|
+
renderInfo2("Usage: /apikey [show|copy|new] aliases: /key");
|
|
544341
|
+
return "handled";
|
|
544342
|
+
};
|
|
544343
|
+
registerSlashCommand({
|
|
544344
|
+
name: "apikey",
|
|
544345
|
+
description: "Show/copy/rotate API key (show|copy|new)",
|
|
544346
|
+
handler: async (opts) => apiKeyHandler({ arg: opts.arg })
|
|
544283
544347
|
});
|
|
544284
|
-
|
|
544348
|
+
registerSlashCommand({
|
|
544349
|
+
name: "key",
|
|
544350
|
+
description: "Alias for /apikey",
|
|
544351
|
+
handler: async (opts) => apiKeyHandler({ arg: opts.arg })
|
|
544352
|
+
});
|
|
544353
|
+
return apiKeyHandler({ arg });
|
|
544285
544354
|
}
|
|
544286
544355
|
case "sessions":
|
|
544287
544356
|
case "session": {
|
|
@@ -544447,12 +544516,12 @@ async function handleSlashCommand(input, ctx3) {
|
|
|
544447
544516
|
renderInfo2(`Generated API key: ${c3.bold(c3.yellow(apiKey))}`);
|
|
544448
544517
|
renderInfo2("Use the Web UI ‘key’ button to paste this token, or set Authorization: Bearer <key> in your client.");
|
|
544449
544518
|
try {
|
|
544450
|
-
const { homedir:
|
|
544451
|
-
const { mkdirSync:
|
|
544452
|
-
const { join:
|
|
544453
|
-
const dir =
|
|
544454
|
-
|
|
544455
|
-
|
|
544519
|
+
const { homedir: homedir42 } = await import("node:os");
|
|
544520
|
+
const { mkdirSync: mkdirSync59, writeFileSync: writeFileSync52 } = await import("node:fs");
|
|
544521
|
+
const { join: join111 } = await import("node:path");
|
|
544522
|
+
const dir = join111(homedir42(), ".open-agents");
|
|
544523
|
+
mkdirSync59(dir, { recursive: true });
|
|
544524
|
+
writeFileSync52(join111(dir, "api.key"), apiKey + "\n", "utf8");
|
|
544456
544525
|
} catch {
|
|
544457
544526
|
}
|
|
544458
544527
|
}
|
|
@@ -544462,29 +544531,66 @@ async function handleSlashCommand(input, ctx3) {
|
|
|
544462
544531
|
ctx4.saveSettings({ oaAccess: val2 });
|
|
544463
544532
|
}
|
|
544464
544533
|
const port2 = parseInt(process.env["OA_PORT"] || "11435", 10);
|
|
544465
|
-
let switched2 = false;
|
|
544466
544534
|
try {
|
|
544467
|
-
const
|
|
544535
|
+
const { homedir: homedir42 } = await import("node:os");
|
|
544536
|
+
const { mkdirSync: mkdirSync59, writeFileSync: writeFileSync52 } = await import("node:fs");
|
|
544537
|
+
const { join: join111 } = await import("node:path");
|
|
544538
|
+
const dir = join111(homedir42(), ".open-agents");
|
|
544539
|
+
mkdirSync59(dir, { recursive: true });
|
|
544540
|
+
writeFileSync52(join111(dir, "access"), `${val2}
|
|
544541
|
+
`, "utf8");
|
|
544542
|
+
} catch {
|
|
544543
|
+
}
|
|
544544
|
+
const baseUrl2 = `http://127.0.0.1:${port2}`;
|
|
544545
|
+
const authHeaders2 = () => {
|
|
544546
|
+
const token = process.env["OA_API_KEY"] || "";
|
|
544547
|
+
return token ? { Authorization: `Bearer ${token}` } : {};
|
|
544548
|
+
};
|
|
544549
|
+
let liveOk2 = false;
|
|
544550
|
+
try {
|
|
544551
|
+
const resp = await fetch(`${baseUrl2}/v1/admin/access`, {
|
|
544468
544552
|
method: "POST",
|
|
544469
|
-
headers: { "Content-Type": "application/json" },
|
|
544553
|
+
headers: { "Content-Type": "application/json", ...authHeaders2() },
|
|
544470
544554
|
body: JSON.stringify({ mode: val2 }),
|
|
544471
544555
|
signal: AbortSignal.timeout(3e3)
|
|
544472
544556
|
});
|
|
544473
|
-
|
|
544557
|
+
liveOk2 = resp.ok;
|
|
544474
544558
|
} catch {
|
|
544475
544559
|
}
|
|
544476
|
-
|
|
544560
|
+
const readCurrent2 = async () => {
|
|
544561
|
+
try {
|
|
544562
|
+
const r2 = await fetch(`${baseUrl2}/v1/admin/access`, { headers: authHeaders2(), signal: AbortSignal.timeout(2e3) });
|
|
544563
|
+
if (!r2.ok) return null;
|
|
544564
|
+
const j = await r2.json();
|
|
544565
|
+
return typeof j.mode === "string" ? j.mode : null;
|
|
544566
|
+
} catch {
|
|
544567
|
+
return null;
|
|
544568
|
+
}
|
|
544569
|
+
};
|
|
544570
|
+
const current2 = await readCurrent2();
|
|
544571
|
+
if (liveOk2 && current2 === val2) {
|
|
544477
544572
|
renderInfo2(`Access policy now '${val2}' (live, no restart). Persisted to ~/.open-agents/access.`);
|
|
544573
|
+
return "handled";
|
|
544574
|
+
}
|
|
544575
|
+
renderInfo2(`Live switch did not take effect (daemon reports ${current2 ?? "unreachable"}). Force-restarting...`);
|
|
544576
|
+
const { forceKillDaemon: forceKillDaemon3, ensureDaemon: ensureDaemon3 } = await Promise.resolve().then(() => (init_daemon(), daemon_exports));
|
|
544577
|
+
const killed2 = await forceKillDaemon3(port2);
|
|
544578
|
+
if (killed2 > 0) renderInfo2(`Force-killed ${killed2} process(es) bound to port ${port2}.`);
|
|
544579
|
+
const ok3 = await ensureDaemon3();
|
|
544580
|
+
if (!ok3) {
|
|
544581
|
+
renderError2("Failed to start a fresh daemon after force-kill.");
|
|
544582
|
+
return "handled";
|
|
544583
|
+
}
|
|
544584
|
+
let finalMode2 = null;
|
|
544585
|
+
for (let i2 = 0; i2 < 10; i2++) {
|
|
544586
|
+
finalMode2 = await readCurrent2();
|
|
544587
|
+
if (finalMode2) break;
|
|
544588
|
+
await new Promise((r2) => setTimeout(r2, 250));
|
|
544589
|
+
}
|
|
544590
|
+
if (finalMode2 === val2) {
|
|
544591
|
+
renderInfo2(`Access policy now '${val2}' (daemon restarted, verified).`);
|
|
544478
544592
|
} else {
|
|
544479
|
-
|
|
544480
|
-
stopDaemon2();
|
|
544481
|
-
const deadline = Date.now() + 4e3;
|
|
544482
|
-
while (Date.now() < deadline) {
|
|
544483
|
-
if (!await isDaemonRunning2(port2)) break;
|
|
544484
|
-
await new Promise((r2) => setTimeout(r2, 200));
|
|
544485
|
-
}
|
|
544486
|
-
const ok2 = await ensureDaemon2();
|
|
544487
|
-
renderInfo2(ok2 ? "Daemon restarted to apply access policy." : "Failed to restart daemon.");
|
|
544593
|
+
renderWarning2(`Daemon restarted but reports mode='${finalMode2 ?? "unreachable"}'. Expected '${val2}'.`);
|
|
544488
544594
|
}
|
|
544489
544595
|
return "handled";
|
|
544490
544596
|
}
|
|
@@ -544512,12 +544618,12 @@ async function handleSlashCommand(input, ctx3) {
|
|
|
544512
544618
|
renderInfo2(`Generated API key: ${c3.bold(c3.yellow(apiKey))}`);
|
|
544513
544619
|
renderInfo2("Use the Web UI ‘key’ button to paste this token, or set Authorization: Bearer <key> in your client.");
|
|
544514
544620
|
try {
|
|
544515
|
-
const { homedir:
|
|
544516
|
-
const { mkdirSync:
|
|
544517
|
-
const { join:
|
|
544518
|
-
const dir =
|
|
544519
|
-
|
|
544520
|
-
|
|
544621
|
+
const { homedir: homedir42 } = await import("node:os");
|
|
544622
|
+
const { mkdirSync: mkdirSync59, writeFileSync: writeFileSync52 } = await import("node:fs");
|
|
544623
|
+
const { join: join111 } = await import("node:path");
|
|
544624
|
+
const dir = join111(homedir42(), ".open-agents");
|
|
544625
|
+
mkdirSync59(dir, { recursive: true });
|
|
544626
|
+
writeFileSync52(join111(dir, "api.key"), apiKey + "\n", "utf8");
|
|
544521
544627
|
} catch {
|
|
544522
544628
|
}
|
|
544523
544629
|
}
|
|
@@ -544527,34 +544633,72 @@ async function handleSlashCommand(input, ctx3) {
|
|
|
544527
544633
|
ctx3.saveSettings({ oaAccess: val });
|
|
544528
544634
|
}
|
|
544529
544635
|
const port = parseInt(process.env["OA_PORT"] || "11435", 10);
|
|
544530
|
-
|
|
544636
|
+
const { homedir: homedir41 } = await import("node:os");
|
|
544637
|
+
const { mkdirSync: mkdirSync58, writeFileSync: writeFileSync51 } = await import("node:fs");
|
|
544638
|
+
const { join: join110 } = await import("node:path");
|
|
544639
|
+
try {
|
|
544640
|
+
const dir = join110(homedir41(), ".open-agents");
|
|
544641
|
+
mkdirSync58(dir, { recursive: true });
|
|
544642
|
+
writeFileSync51(join110(dir, "access"), `${val}
|
|
544643
|
+
`, "utf8");
|
|
544644
|
+
} catch (e2) {
|
|
544645
|
+
renderWarning2(`Could not persist ~/.open-agents/access: ${e2 instanceof Error ? e2.message : String(e2)}`);
|
|
544646
|
+
}
|
|
544647
|
+
const baseUrl = `http://127.0.0.1:${port}`;
|
|
544648
|
+
const authHeaders = () => {
|
|
544649
|
+
const token = process.env["OA_API_KEY"] || "";
|
|
544650
|
+
return token ? { Authorization: `Bearer ${token}` } : {};
|
|
544651
|
+
};
|
|
544652
|
+
let liveOk = false;
|
|
544531
544653
|
try {
|
|
544532
|
-
const resp = await fetch(
|
|
544654
|
+
const resp = await fetch(`${baseUrl}/v1/admin/access`, {
|
|
544533
544655
|
method: "POST",
|
|
544534
|
-
headers: { "Content-Type": "application/json" },
|
|
544656
|
+
headers: { "Content-Type": "application/json", ...authHeaders() },
|
|
544535
544657
|
body: JSON.stringify({ mode: val }),
|
|
544536
544658
|
signal: AbortSignal.timeout(3e3)
|
|
544537
544659
|
});
|
|
544538
|
-
|
|
544660
|
+
liveOk = resp.ok;
|
|
544539
544661
|
if (!resp.ok) {
|
|
544540
544662
|
const txt = await resp.text().catch(() => "");
|
|
544541
544663
|
renderWarning2(`Live access switch HTTP ${resp.status}: ${txt.slice(0, 120)}`);
|
|
544542
544664
|
}
|
|
544543
544665
|
} catch (e2) {
|
|
544544
|
-
renderWarning2(`Live access switch failed
|
|
544666
|
+
renderWarning2(`Live access switch fetch failed: ${e2 instanceof Error ? e2.message : String(e2)}`);
|
|
544545
544667
|
}
|
|
544546
|
-
|
|
544668
|
+
const readCurrent = async () => {
|
|
544669
|
+
try {
|
|
544670
|
+
const r2 = await fetch(`${baseUrl}/v1/admin/access`, { headers: authHeaders(), signal: AbortSignal.timeout(2e3) });
|
|
544671
|
+
if (!r2.ok) return null;
|
|
544672
|
+
const j = await r2.json();
|
|
544673
|
+
return typeof j.mode === "string" ? j.mode : null;
|
|
544674
|
+
} catch {
|
|
544675
|
+
return null;
|
|
544676
|
+
}
|
|
544677
|
+
};
|
|
544678
|
+
let current = await readCurrent();
|
|
544679
|
+
if (liveOk && current === val) {
|
|
544547
544680
|
renderInfo2(`Access policy now '${val}' (live, no restart). Persisted to ~/.open-agents/access.`);
|
|
544681
|
+
return "handled";
|
|
544682
|
+
}
|
|
544683
|
+
renderInfo2(`Live switch did not take effect (daemon reports ${current ?? "unreachable"}). Force-restarting daemon...`);
|
|
544684
|
+
const { forceKillDaemon: forceKillDaemon2, ensureDaemon: ensureDaemon2 } = await Promise.resolve().then(() => (init_daemon(), daemon_exports));
|
|
544685
|
+
const killed = await forceKillDaemon2(port);
|
|
544686
|
+
if (killed > 0) renderInfo2(`Force-killed ${killed} process(es) bound to port ${port}.`);
|
|
544687
|
+
const ok2 = await ensureDaemon2();
|
|
544688
|
+
if (!ok2) {
|
|
544689
|
+
renderError2("Failed to start a fresh daemon after force-kill. Try: `oa serve --quiet --daemon &` manually.");
|
|
544690
|
+
return "handled";
|
|
544691
|
+
}
|
|
544692
|
+
let finalMode = null;
|
|
544693
|
+
for (let i2 = 0; i2 < 10; i2++) {
|
|
544694
|
+
finalMode = await readCurrent();
|
|
544695
|
+
if (finalMode) break;
|
|
544696
|
+
await new Promise((r2) => setTimeout(r2, 250));
|
|
544697
|
+
}
|
|
544698
|
+
if (finalMode === val) {
|
|
544699
|
+
renderInfo2(`Access policy now '${val}' (daemon restarted, verified via /v1/admin/access).`);
|
|
544548
544700
|
} else {
|
|
544549
|
-
|
|
544550
|
-
stopDaemon2();
|
|
544551
|
-
const deadline = Date.now() + 4e3;
|
|
544552
|
-
while (Date.now() < deadline) {
|
|
544553
|
-
if (!await isDaemonRunning2(port)) break;
|
|
544554
|
-
await new Promise((r2) => setTimeout(r2, 200));
|
|
544555
|
-
}
|
|
544556
|
-
const ok2 = await ensureDaemon2();
|
|
544557
|
-
renderInfo2(ok2 ? "Daemon restarted to apply access policy." : "Failed to restart daemon.");
|
|
544701
|
+
renderWarning2(`Daemon restarted but reports mode='${finalMode ?? "unreachable"}'. Expected '${val}'. Check ~/.open-agents/access.`);
|
|
544558
544702
|
}
|
|
544559
544703
|
return "handled";
|
|
544560
544704
|
}
|
|
@@ -552472,6 +552616,10 @@ var init_render2 = __esm({
|
|
|
552472
552616
|
["/scheduler menu", "Interactive scheduler menu (toggle/kill)"],
|
|
552473
552617
|
["/scheduler list", "List all scheduled tasks and timers"],
|
|
552474
552618
|
["/scheduler kill", "Kill schedulers + active runs (with escalation if needed)"],
|
|
552619
|
+
["/apikey", "Show current API key (for pasting into Web UI / clients)"],
|
|
552620
|
+
["/apikey copy", "Copy the API key to clipboard"],
|
|
552621
|
+
["/apikey new", "Rotate to a new API key (regenerate)"],
|
|
552622
|
+
["/key", "Alias for /apikey"],
|
|
552475
552623
|
["/codegraph", "Code-graph snapshot: stats, top files, recent activity"],
|
|
552476
552624
|
["/codegraph watch [N]", "Subscribe to live code-graph events for N seconds (default 30)"],
|
|
552477
552625
|
["/cg", "Alias for /codegraph"],
|
package/package.json
CHANGED