open-agents-ai 0.187.301 → 0.187.303
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 +105 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -297250,6 +297250,78 @@ async function handleSlashCommand(input, ctx3) {
|
|
|
297250
297250
|
await showColorMenu(ctx3);
|
|
297251
297251
|
return "handled";
|
|
297252
297252
|
}
|
|
297253
|
+
case "apikey": {
|
|
297254
|
+
registerSlashCommand({
|
|
297255
|
+
name: "apikey",
|
|
297256
|
+
description: "Show/copy/rotate API key (show|copy|new)",
|
|
297257
|
+
handler: async ({ arg: arg2 }) => {
|
|
297258
|
+
const action = (arg2 || "show").trim().toLowerCase();
|
|
297259
|
+
let key = process.env["OA_API_KEY"] || "";
|
|
297260
|
+
if (!key) {
|
|
297261
|
+
try {
|
|
297262
|
+
const { homedir: homedir41 } = await import("node:os");
|
|
297263
|
+
const { readFileSync: readFileSync68, existsSync: existsSync87 } = await import("node:fs");
|
|
297264
|
+
const { join: join106 } = await import("node:path");
|
|
297265
|
+
const p2 = join106(homedir41(), ".open-agents", "api.key");
|
|
297266
|
+
if (existsSync87(p2)) key = readFileSync68(p2, "utf8").trim();
|
|
297267
|
+
} catch {
|
|
297268
|
+
}
|
|
297269
|
+
}
|
|
297270
|
+
if (action === "show") {
|
|
297271
|
+
if (!key) {
|
|
297272
|
+
renderWarning2("No API key set. Use /access any to generate one.");
|
|
297273
|
+
return "handled";
|
|
297274
|
+
}
|
|
297275
|
+
renderInfo2(`API key: ${c3.bold(c3.yellow(key))}`);
|
|
297276
|
+
renderInfo2("Use Authorization: Bearer <key> or paste in the Web UI key modal.");
|
|
297277
|
+
return "handled";
|
|
297278
|
+
}
|
|
297279
|
+
if (action === "copy") {
|
|
297280
|
+
if (!key) {
|
|
297281
|
+
renderWarning2("No API key set. Use /access any to generate one.");
|
|
297282
|
+
return "handled";
|
|
297283
|
+
}
|
|
297284
|
+
try {
|
|
297285
|
+
const { spawnSync: spawnSync6 } = await import("node:child_process");
|
|
297286
|
+
const tryCmd = (cmd2, args2) => spawnSync6(cmd2, args2, { input: key, encoding: "utf8" });
|
|
297287
|
+
let ok2 = false;
|
|
297288
|
+
if (process.platform === "darwin") {
|
|
297289
|
+
ok2 = tryCmd("pbcopy", []).status === 0;
|
|
297290
|
+
} else if (process.platform === "win32") {
|
|
297291
|
+
ok2 = tryCmd("clip", []).status === 0;
|
|
297292
|
+
} else {
|
|
297293
|
+
ok2 = tryCmd("wl-copy", []).status === 0 || tryCmd("xclip", ["-selection", "clipboard"]).status === 0;
|
|
297294
|
+
}
|
|
297295
|
+
renderInfo2(ok2 ? "Copied API key to clipboard." : "Copy failed — printed above, select to copy.");
|
|
297296
|
+
} catch {
|
|
297297
|
+
renderInfo2("Copy failed — printed above, select to copy.");
|
|
297298
|
+
}
|
|
297299
|
+
return "handled";
|
|
297300
|
+
}
|
|
297301
|
+
if (action === "new") {
|
|
297302
|
+
try {
|
|
297303
|
+
const { randomBytes: randomBytes23 } = await import("node:crypto");
|
|
297304
|
+
const { homedir: homedir41 } = await import("node:os");
|
|
297305
|
+
const { mkdirSync: mkdirSync55, writeFileSync: writeFileSync49 } = await import("node:fs");
|
|
297306
|
+
const { join: join106 } = await import("node:path");
|
|
297307
|
+
const newKey = randomBytes23(16).toString("hex");
|
|
297308
|
+
process.env["OA_API_KEY"] = newKey;
|
|
297309
|
+
const dir = join106(homedir41(), ".open-agents");
|
|
297310
|
+
mkdirSync55(dir, { recursive: true });
|
|
297311
|
+
writeFileSync49(join106(dir, "api.key"), newKey + "\n", "utf8");
|
|
297312
|
+
renderInfo2(`New API key: ${c3.bold(c3.yellow(newKey))}`);
|
|
297313
|
+
renderInfo2("Restart the daemon to apply if needed. Use /access any to restart quickly.");
|
|
297314
|
+
} catch (e2) {
|
|
297315
|
+
renderError2(`Failed to rotate key: ${e2 instanceof Error ? e2.message : String(e2)}`);
|
|
297316
|
+
}
|
|
297317
|
+
return "handled";
|
|
297318
|
+
}
|
|
297319
|
+
renderInfo2("Usage: /apikey [show|copy|new]");
|
|
297320
|
+
return "handled";
|
|
297321
|
+
}
|
|
297322
|
+
});
|
|
297323
|
+
return "handled";
|
|
297324
|
+
}
|
|
297253
297325
|
case "sessions":
|
|
297254
297326
|
case "session": {
|
|
297255
297327
|
await showSessionsMenu(ctx3);
|
|
@@ -297413,6 +297485,15 @@ async function handleSlashCommand(input, ctx3) {
|
|
|
297413
297485
|
process.env["OA_API_KEY"] = apiKey;
|
|
297414
297486
|
renderInfo2(`Generated API key: ${c3.bold(c3.yellow(apiKey))}`);
|
|
297415
297487
|
renderInfo2("Use the Web UI ‘key’ button to paste this token, or set Authorization: Bearer <key> in your client.");
|
|
297488
|
+
try {
|
|
297489
|
+
const { homedir: homedir41 } = await import("node:os");
|
|
297490
|
+
const { mkdirSync: mkdirSync55, writeFileSync: writeFileSync49 } = await import("node:fs");
|
|
297491
|
+
const { join: join106 } = await import("node:path");
|
|
297492
|
+
const dir = join106(homedir41(), ".open-agents");
|
|
297493
|
+
mkdirSync55(dir, { recursive: true });
|
|
297494
|
+
writeFileSync49(join106(dir, "api.key"), apiKey + "\n", "utf8");
|
|
297495
|
+
} catch {
|
|
297496
|
+
}
|
|
297416
297497
|
}
|
|
297417
297498
|
if (hasLocal2) {
|
|
297418
297499
|
ctx4.saveLocalSettings({ oaAccess: val2 });
|
|
@@ -297449,6 +297530,15 @@ async function handleSlashCommand(input, ctx3) {
|
|
|
297449
297530
|
process.env["OA_API_KEY"] = apiKey;
|
|
297450
297531
|
renderInfo2(`Generated API key: ${c3.bold(c3.yellow(apiKey))}`);
|
|
297451
297532
|
renderInfo2("Use the Web UI ‘key’ button to paste this token, or set Authorization: Bearer <key> in your client.");
|
|
297533
|
+
try {
|
|
297534
|
+
const { homedir: homedir41 } = await import("node:os");
|
|
297535
|
+
const { mkdirSync: mkdirSync55, writeFileSync: writeFileSync49 } = await import("node:fs");
|
|
297536
|
+
const { join: join106 } = await import("node:path");
|
|
297537
|
+
const dir = join106(homedir41(), ".open-agents");
|
|
297538
|
+
mkdirSync55(dir, { recursive: true });
|
|
297539
|
+
writeFileSync49(join106(dir, "api.key"), apiKey + "\n", "utf8");
|
|
297540
|
+
} catch {
|
|
297541
|
+
}
|
|
297452
297542
|
}
|
|
297453
297543
|
if (hasLocal) {
|
|
297454
297544
|
ctx3.saveLocalSettings({ oaAccess: val });
|
|
@@ -326223,6 +326313,21 @@ async function handleV1Update(req2, res, requestId) {
|
|
|
326223
326313
|
stdio: "ignore"
|
|
326224
326314
|
});
|
|
326225
326315
|
follower.unref();
|
|
326316
|
+
const relaunchScript = [
|
|
326317
|
+
`while kill -0 ${installPid} 2>/dev/null; do sleep 1; done`,
|
|
326318
|
+
// Short grace period before restart
|
|
326319
|
+
`sleep 1`,
|
|
326320
|
+
// Use PATH to pick up the freshly installed oa; background and disown
|
|
326321
|
+
`oa serve --quiet --daemon >/dev/null 2>&1 & disown`,
|
|
326322
|
+
// Terminate current daemon so the new one can bind the port
|
|
326323
|
+
`kill -TERM ${process.pid} >/dev/null 2>&1 || true`
|
|
326324
|
+
].join("; ");
|
|
326325
|
+
const relauncher = spawn25("bash", ["-c", relaunchScript], {
|
|
326326
|
+
detached: true,
|
|
326327
|
+
stdio: "ignore",
|
|
326328
|
+
env: cleanEnv
|
|
326329
|
+
});
|
|
326330
|
+
relauncher.unref();
|
|
326226
326331
|
} catch {
|
|
326227
326332
|
}
|
|
326228
326333
|
}
|
package/package.json
CHANGED