bazilion 0.2.1 → 0.3.0
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 +372 -22
- package/dist/cli.js.map +1 -1
- package/dist/daemon.js +18460 -1801
- package/dist/daemon.js.map +1 -1
- package/dist/migrations/0003_agent_telegram.sql +40 -0
- package/dist/migrations/0004_agent_mirror_mode.sql +17 -0
- package/dist/migrations/0005_group_topic_name_format.sql +15 -0
- package/dist/migrations/0006_telegram_acl.sql +18 -0
- package/dist/worker.js +43 -3
- package/dist/worker.js.map +1 -1
- package/package.json +3 -3
package/dist/cli.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/index.ts
|
|
4
|
-
import { defineCommand as
|
|
4
|
+
import { defineCommand as defineCommand21, runCommand, showUsage } from "citty";
|
|
5
5
|
|
|
6
6
|
// package.json
|
|
7
7
|
var package_default = {
|
|
8
8
|
name: "bazilion",
|
|
9
|
-
version: "0.
|
|
9
|
+
version: "0.3.0",
|
|
10
10
|
description: "Multi-agent runtime CLI \u2014 spawn LLM agents, manage profiles/groups/skills, and run the local daemon.",
|
|
11
11
|
license: "MIT",
|
|
12
12
|
repository: {
|
|
@@ -266,7 +266,7 @@ var spawnCmd = defineCommand({
|
|
|
266
266
|
var editCmd = defineCommand({
|
|
267
267
|
meta: {
|
|
268
268
|
name: "edit",
|
|
269
|
-
description: "Edit agent settings (name, model override, reasoning level)"
|
|
269
|
+
description: "Edit agent settings (name, model override, reasoning level, telegram mirror)"
|
|
270
270
|
},
|
|
271
271
|
args: {
|
|
272
272
|
id: { type: "positional", required: true, description: "Agent id or prefix" },
|
|
@@ -275,11 +275,21 @@ var editCmd = defineCommand({
|
|
|
275
275
|
reasoning: {
|
|
276
276
|
type: "string",
|
|
277
277
|
description: "Reasoning level: off|minimal|low|medium|high|xhigh"
|
|
278
|
+
},
|
|
279
|
+
mirror: {
|
|
280
|
+
type: "string",
|
|
281
|
+
description: "Telegram mirror verbosity: minimal|verbose"
|
|
282
|
+
},
|
|
283
|
+
"topic-icon": {
|
|
284
|
+
type: "string",
|
|
285
|
+
description: 'Telegram topic emoji (e.g. \u{1F4DA}). Use --topic-icon "" to clear.'
|
|
278
286
|
}
|
|
279
287
|
},
|
|
280
288
|
async run({ args }) {
|
|
281
|
-
if (args.name === void 0 && args.model === void 0 && args.reasoning === void 0) {
|
|
282
|
-
console.error(
|
|
289
|
+
if (args.name === void 0 && args.model === void 0 && args.reasoning === void 0 && args.mirror === void 0 && args["topic-icon"] === void 0) {
|
|
290
|
+
console.error(
|
|
291
|
+
"agent edit: specify at least one of --name, --model, --reasoning, --mirror, --topic-icon"
|
|
292
|
+
);
|
|
283
293
|
process.exit(2);
|
|
284
294
|
}
|
|
285
295
|
const client = createClient2();
|
|
@@ -289,6 +299,16 @@ var editCmd = defineCommand({
|
|
|
289
299
|
body.modelOverride = args.model === "" ? null : args.model;
|
|
290
300
|
}
|
|
291
301
|
if (args.reasoning !== void 0) body.reasoningLevel = args.reasoning;
|
|
302
|
+
if (args.mirror !== void 0) {
|
|
303
|
+
if (args.mirror !== "minimal" && args.mirror !== "verbose") {
|
|
304
|
+
console.error(`agent edit: --mirror must be 'minimal' or 'verbose'`);
|
|
305
|
+
process.exit(2);
|
|
306
|
+
}
|
|
307
|
+
body.telegramMirrorMode = args.mirror;
|
|
308
|
+
}
|
|
309
|
+
if (args["topic-icon"] !== void 0) {
|
|
310
|
+
body.telegramIconEmoji = args["topic-icon"] === "" ? null : args["topic-icon"];
|
|
311
|
+
}
|
|
292
312
|
const agent = await client.patch(`/api/agents/${args.id}`, body);
|
|
293
313
|
console.log(`updated agent ${agent.id} (${agent.name})`);
|
|
294
314
|
}
|
|
@@ -1385,13 +1405,64 @@ var userMdCmd = defineCommand7({
|
|
|
1385
1405
|
clear: userMdClearCmd
|
|
1386
1406
|
}
|
|
1387
1407
|
});
|
|
1408
|
+
var topicFormatShowCmd = defineCommand7({
|
|
1409
|
+
meta: { name: "show", description: "Print the group's Telegram topic-name template" },
|
|
1410
|
+
args: { id: { type: "positional", required: true } },
|
|
1411
|
+
async run({ args }) {
|
|
1412
|
+
const client = createClient2();
|
|
1413
|
+
const g = await client.get(`/api/groups/${args.id}`);
|
|
1414
|
+
console.log(g.telegramTopicNameFormat ?? "(default naming)");
|
|
1415
|
+
}
|
|
1416
|
+
});
|
|
1417
|
+
var topicFormatSetCmd = defineCommand7({
|
|
1418
|
+
meta: {
|
|
1419
|
+
name: "set",
|
|
1420
|
+
description: "Set the topic-name template. Tokens: {agent.name} {group.name} {group.slug} (must include {agent.name})"
|
|
1421
|
+
},
|
|
1422
|
+
args: {
|
|
1423
|
+
id: { type: "positional", required: true },
|
|
1424
|
+
format: {
|
|
1425
|
+
type: "positional",
|
|
1426
|
+
required: true,
|
|
1427
|
+
description: 'e.g. "{group.name} / {agent.name}"'
|
|
1428
|
+
}
|
|
1429
|
+
},
|
|
1430
|
+
async run({ args }) {
|
|
1431
|
+
const client = createClient2();
|
|
1432
|
+
const body = { format: args.format };
|
|
1433
|
+
const g = await client.put(`/api/groups/${args.id}/topic-format`, body);
|
|
1434
|
+
console.log(`set topic-name template for group ${args.id}: ${g.telegramTopicNameFormat}`);
|
|
1435
|
+
}
|
|
1436
|
+
});
|
|
1437
|
+
var topicFormatClearCmd = defineCommand7({
|
|
1438
|
+
meta: { name: "clear", description: "Clear the template (revert to built-in naming)" },
|
|
1439
|
+
args: { id: { type: "positional", required: true } },
|
|
1440
|
+
async run({ args }) {
|
|
1441
|
+
const client = createClient2();
|
|
1442
|
+
const body = { format: null };
|
|
1443
|
+
await client.put(`/api/groups/${args.id}/topic-format`, body);
|
|
1444
|
+
console.log(`cleared topic-name template for group ${args.id}`);
|
|
1445
|
+
}
|
|
1446
|
+
});
|
|
1447
|
+
var topicFormatCmd = defineCommand7({
|
|
1448
|
+
meta: {
|
|
1449
|
+
name: "topic-format",
|
|
1450
|
+
description: "View or edit a group's Telegram forum-topic name template"
|
|
1451
|
+
},
|
|
1452
|
+
subCommands: {
|
|
1453
|
+
show: topicFormatShowCmd,
|
|
1454
|
+
set: topicFormatSetCmd,
|
|
1455
|
+
clear: topicFormatClearCmd
|
|
1456
|
+
}
|
|
1457
|
+
});
|
|
1388
1458
|
var groupCommand = defineCommand7({
|
|
1389
1459
|
meta: { name: "group", description: "Manage groups (collaboration contexts)" },
|
|
1390
1460
|
subCommands: {
|
|
1391
1461
|
add: addCmd,
|
|
1392
1462
|
list: listCmd3,
|
|
1393
1463
|
rm: rmCmd2,
|
|
1394
|
-
"user-md": userMdCmd
|
|
1464
|
+
"user-md": userMdCmd,
|
|
1465
|
+
"topic-format": topicFormatCmd
|
|
1395
1466
|
}
|
|
1396
1467
|
});
|
|
1397
1468
|
|
|
@@ -2448,9 +2519,283 @@ var skillCommand = defineCommand16({
|
|
|
2448
2519
|
}
|
|
2449
2520
|
});
|
|
2450
2521
|
|
|
2522
|
+
// src/commands/telegram.ts
|
|
2523
|
+
import { defineCommand as defineCommand17 } from "citty";
|
|
2524
|
+
var setCmd2 = defineCommand17({
|
|
2525
|
+
meta: {
|
|
2526
|
+
name: "set",
|
|
2527
|
+
description: "Save bot token + supergroup chat ID (paired write)"
|
|
2528
|
+
},
|
|
2529
|
+
args: {
|
|
2530
|
+
token: { type: "string", required: true, description: "Bot token from @BotFather" },
|
|
2531
|
+
chat: { type: "string", required: true, description: "Numeric supergroup chat ID" }
|
|
2532
|
+
},
|
|
2533
|
+
async run({ args }) {
|
|
2534
|
+
const client = createClient2();
|
|
2535
|
+
const state = await client.put("/api/config/telegram", {
|
|
2536
|
+
botToken: args.token,
|
|
2537
|
+
chatId: args.chat
|
|
2538
|
+
});
|
|
2539
|
+
console.log(`saved \xB7 token ${state.botTokenPreview} \xB7 chat ${state.chatId}`);
|
|
2540
|
+
}
|
|
2541
|
+
});
|
|
2542
|
+
var clearCmd = defineCommand17({
|
|
2543
|
+
meta: {
|
|
2544
|
+
name: "clear",
|
|
2545
|
+
description: "Remove stored bot token + chat ID"
|
|
2546
|
+
},
|
|
2547
|
+
async run() {
|
|
2548
|
+
const client = createClient2();
|
|
2549
|
+
await client.del("/api/config/telegram");
|
|
2550
|
+
console.log("cleared");
|
|
2551
|
+
}
|
|
2552
|
+
});
|
|
2553
|
+
var showCmd5 = defineCommand17({
|
|
2554
|
+
meta: {
|
|
2555
|
+
name: "show",
|
|
2556
|
+
description: "Show what credentials are stored (token is masked)"
|
|
2557
|
+
},
|
|
2558
|
+
async run() {
|
|
2559
|
+
const client = createClient2();
|
|
2560
|
+
const state = await client.get("/api/config/telegram");
|
|
2561
|
+
if (!state.configured) {
|
|
2562
|
+
console.log("(no credentials saved \u2014 run `bazilion telegram config set --token \u2026 --chat \u2026`)");
|
|
2563
|
+
return;
|
|
2564
|
+
}
|
|
2565
|
+
console.log(`token: ${state.botTokenPreview}`);
|
|
2566
|
+
console.log(`chat: ${state.chatId}`);
|
|
2567
|
+
if (state.migratedChatId) {
|
|
2568
|
+
console.log(
|
|
2569
|
+
`\u26A0 supergroup migrated \u2192 ${state.migratedChatId}. Run \`bazilion telegram reconnect\` to apply.`
|
|
2570
|
+
);
|
|
2571
|
+
}
|
|
2572
|
+
}
|
|
2573
|
+
});
|
|
2574
|
+
var reconnectCmd = defineCommand17({
|
|
2575
|
+
meta: {
|
|
2576
|
+
name: "reconnect",
|
|
2577
|
+
description: "Apply a pending supergroup chat-id migration + re-activate the bot"
|
|
2578
|
+
},
|
|
2579
|
+
async run() {
|
|
2580
|
+
const client = createClient2();
|
|
2581
|
+
const state = await client.post("/api/config/telegram/reconnect");
|
|
2582
|
+
console.log(`reconnected \xB7 chat ${state.chatId}`);
|
|
2583
|
+
}
|
|
2584
|
+
});
|
|
2585
|
+
var configCmd = defineCommand17({
|
|
2586
|
+
meta: {
|
|
2587
|
+
name: "config",
|
|
2588
|
+
description: "Manage Telegram credentials (bot token + chat ID)"
|
|
2589
|
+
},
|
|
2590
|
+
subCommands: {
|
|
2591
|
+
set: setCmd2,
|
|
2592
|
+
clear: clearCmd,
|
|
2593
|
+
show: showCmd5
|
|
2594
|
+
}
|
|
2595
|
+
});
|
|
2596
|
+
var healthCmd = defineCommand17({
|
|
2597
|
+
meta: {
|
|
2598
|
+
name: "health",
|
|
2599
|
+
description: "Run the four-step preflight against the Telegram Bot API"
|
|
2600
|
+
},
|
|
2601
|
+
async run() {
|
|
2602
|
+
const client = createClient2();
|
|
2603
|
+
const h = await client.get("/api/config/telegram/health");
|
|
2604
|
+
if (!h.configured) {
|
|
2605
|
+
console.log("not configured \u2014 run `bazilion telegram config set` first");
|
|
2606
|
+
process.exitCode = 1;
|
|
2607
|
+
return;
|
|
2608
|
+
}
|
|
2609
|
+
if (h.error) {
|
|
2610
|
+
console.error(`error at ${h.error.step}: ${h.error.message}`);
|
|
2611
|
+
process.exitCode = 1;
|
|
2612
|
+
return;
|
|
2613
|
+
}
|
|
2614
|
+
if (!h.preflight) {
|
|
2615
|
+
console.error("preflight returned no data");
|
|
2616
|
+
process.exitCode = 1;
|
|
2617
|
+
return;
|
|
2618
|
+
}
|
|
2619
|
+
const p = h.preflight;
|
|
2620
|
+
const line = (ok, label, detail) => `${ok ? "\u2713" : "\u2715"} ${label.padEnd(30)} ${detail}`;
|
|
2621
|
+
console.log(line(p.botUsername.length > 0, "bot identity", `@${p.botUsername}`));
|
|
2622
|
+
console.log(line(p.chatTitle.length > 0, "supergroup reachable", p.chatTitle));
|
|
2623
|
+
console.log(line(p.isForum, "forum topics enabled", String(p.isForum)));
|
|
2624
|
+
console.log(line(p.hasManageTopics, "can_manage_topics", String(p.hasManageTopics)));
|
|
2625
|
+
console.log(line(p.privacyModeOff, "Privacy Mode is OFF", String(p.privacyModeOff)));
|
|
2626
|
+
const allOk = p.botUsername.length > 0 && p.chatTitle.length > 0 && p.isForum && p.hasManageTopics && p.privacyModeOff;
|
|
2627
|
+
if (!allOk) process.exitCode = 1;
|
|
2628
|
+
}
|
|
2629
|
+
});
|
|
2630
|
+
var botStatusCmd = defineCommand17({
|
|
2631
|
+
meta: {
|
|
2632
|
+
name: "status",
|
|
2633
|
+
description: "Show polling state of the live bot"
|
|
2634
|
+
},
|
|
2635
|
+
async run() {
|
|
2636
|
+
const client = createClient2();
|
|
2637
|
+
const h = await client.get("/api/config/telegram/health");
|
|
2638
|
+
if (!h.polling) {
|
|
2639
|
+
console.log("bot: not running");
|
|
2640
|
+
process.exitCode = 1;
|
|
2641
|
+
return;
|
|
2642
|
+
}
|
|
2643
|
+
const p = h.polling;
|
|
2644
|
+
const startedAt = p.startedAt ? new Date(p.startedAt).toISOString() : "(never)";
|
|
2645
|
+
const lastPoll = p.lastSuccessfulPollAt ? new Date(p.lastSuccessfulPollAt).toISOString() : "(never)";
|
|
2646
|
+
console.log(`running: ${p.running}`);
|
|
2647
|
+
console.log(`activated: ${p.activated}`);
|
|
2648
|
+
console.log(`started at: ${startedAt}`);
|
|
2649
|
+
console.log(`last update id: ${p.lastUpdateId ?? "(none)"}`);
|
|
2650
|
+
console.log(`last successful: ${lastPoll}`);
|
|
2651
|
+
if (p.error) console.log(`error: ${p.error}`);
|
|
2652
|
+
if (!p.running) process.exitCode = 1;
|
|
2653
|
+
}
|
|
2654
|
+
});
|
|
2655
|
+
var botRestartCmd = defineCommand17({
|
|
2656
|
+
meta: {
|
|
2657
|
+
name: "restart",
|
|
2658
|
+
description: "Force-restart the bot (tears down + brings up from current creds)"
|
|
2659
|
+
},
|
|
2660
|
+
async run() {
|
|
2661
|
+
const client = createClient2();
|
|
2662
|
+
await client.post("/api/config/telegram/restart");
|
|
2663
|
+
console.log("restart requested");
|
|
2664
|
+
}
|
|
2665
|
+
});
|
|
2666
|
+
var botCmd = defineCommand17({
|
|
2667
|
+
meta: {
|
|
2668
|
+
name: "bot",
|
|
2669
|
+
description: "Inspect / control the live polling bot"
|
|
2670
|
+
},
|
|
2671
|
+
subCommands: {
|
|
2672
|
+
status: botStatusCmd,
|
|
2673
|
+
restart: botRestartCmd
|
|
2674
|
+
}
|
|
2675
|
+
});
|
|
2676
|
+
var bindCmd = defineCommand17({
|
|
2677
|
+
meta: {
|
|
2678
|
+
name: "bind",
|
|
2679
|
+
description: "Create a Telegram topic for an agent (manual fallback for /talk)"
|
|
2680
|
+
},
|
|
2681
|
+
args: {
|
|
2682
|
+
agent: { type: "positional", required: true, description: "Agent id or prefix" }
|
|
2683
|
+
},
|
|
2684
|
+
async run({ args }) {
|
|
2685
|
+
const client = createClient2();
|
|
2686
|
+
const result = await client.post(
|
|
2687
|
+
`/api/agents/${args.agent}/telegram/bind`
|
|
2688
|
+
);
|
|
2689
|
+
const verb = result.created ? "created topic" : "already bound to";
|
|
2690
|
+
console.log(`${verb} #${result.topicId} for agent ${result.agent.name} (${result.agent.id})`);
|
|
2691
|
+
console.log(` ${result.deepLink}`);
|
|
2692
|
+
}
|
|
2693
|
+
});
|
|
2694
|
+
var unbindCmd = defineCommand17({
|
|
2695
|
+
meta: {
|
|
2696
|
+
name: "unbind",
|
|
2697
|
+
description: "Clear an agent's Telegram topic binding (topic stays in Telegram as orphan)"
|
|
2698
|
+
},
|
|
2699
|
+
args: {
|
|
2700
|
+
agent: { type: "positional", required: true, description: "Agent id or prefix" }
|
|
2701
|
+
},
|
|
2702
|
+
async run({ args }) {
|
|
2703
|
+
const client = createClient2();
|
|
2704
|
+
await client.del(`/api/agents/${args.agent}/telegram/binding`);
|
|
2705
|
+
console.log(`unbound agent ${args.agent}`);
|
|
2706
|
+
}
|
|
2707
|
+
});
|
|
2708
|
+
var listBindingsCmd = defineCommand17({
|
|
2709
|
+
meta: {
|
|
2710
|
+
name: "list",
|
|
2711
|
+
description: "List agents and their Telegram topic bindings"
|
|
2712
|
+
},
|
|
2713
|
+
async run() {
|
|
2714
|
+
const client = createClient2();
|
|
2715
|
+
const agents = await client.get("/api/agents");
|
|
2716
|
+
const bound = agents.filter((a) => a.telegramTopicId !== null);
|
|
2717
|
+
const unbound = agents.filter((a) => a.telegramTopicId === null);
|
|
2718
|
+
if (bound.length === 0 && unbound.length === 0) {
|
|
2719
|
+
console.log("(no agents)");
|
|
2720
|
+
return;
|
|
2721
|
+
}
|
|
2722
|
+
if (bound.length > 0) {
|
|
2723
|
+
console.log("bound:");
|
|
2724
|
+
for (const a of bound) {
|
|
2725
|
+
console.log(` #${a.telegramTopicId} ${a.name} (group: ${a.groupId})`);
|
|
2726
|
+
}
|
|
2727
|
+
}
|
|
2728
|
+
if (unbound.length > 0) {
|
|
2729
|
+
console.log("unbound:");
|
|
2730
|
+
for (const a of unbound) {
|
|
2731
|
+
console.log(` \u2014 ${a.name} (group: ${a.groupId})`);
|
|
2732
|
+
}
|
|
2733
|
+
}
|
|
2734
|
+
}
|
|
2735
|
+
});
|
|
2736
|
+
var allowCmd = defineCommand17({
|
|
2737
|
+
meta: { name: "allow", description: "Add a Telegram user id to the allowlist" },
|
|
2738
|
+
args: {
|
|
2739
|
+
userId: { type: "positional", required: true, description: "Numeric Telegram user id" },
|
|
2740
|
+
label: { type: "string", description: "Optional human label" },
|
|
2741
|
+
owner: { type: "boolean", description: "Grant owner role (can manage the allowlist)" }
|
|
2742
|
+
},
|
|
2743
|
+
async run({ args }) {
|
|
2744
|
+
const client = createClient2();
|
|
2745
|
+
const u = await client.post("/api/config/telegram/acl", {
|
|
2746
|
+
userId: Number(args.userId),
|
|
2747
|
+
label: args.label ?? null,
|
|
2748
|
+
role: args.owner ? "owner" : "member"
|
|
2749
|
+
});
|
|
2750
|
+
console.log(`allowed ${u.userId} (${u.role})`);
|
|
2751
|
+
}
|
|
2752
|
+
});
|
|
2753
|
+
var denyCmd = defineCommand17({
|
|
2754
|
+
meta: { name: "deny", description: "Remove a Telegram user id from the allowlist" },
|
|
2755
|
+
args: { userId: { type: "positional", required: true } },
|
|
2756
|
+
async run({ args }) {
|
|
2757
|
+
const client = createClient2();
|
|
2758
|
+
await client.del(`/api/config/telegram/acl/${Number(args.userId)}`);
|
|
2759
|
+
console.log(`removed ${args.userId}`);
|
|
2760
|
+
}
|
|
2761
|
+
});
|
|
2762
|
+
var allowedCmd = defineCommand17({
|
|
2763
|
+
meta: { name: "allowed", description: "List allowlisted Telegram users" },
|
|
2764
|
+
async run() {
|
|
2765
|
+
const client = createClient2();
|
|
2766
|
+
const users = await client.get("/api/config/telegram/acl");
|
|
2767
|
+
if (users.length === 0) {
|
|
2768
|
+
console.log("(allowlist empty \u2014 open; first user to message becomes owner)");
|
|
2769
|
+
return;
|
|
2770
|
+
}
|
|
2771
|
+
for (const u of users) {
|
|
2772
|
+
const who = u.label ?? (u.username ? `@${u.username}` : "\u2014");
|
|
2773
|
+
console.log(`${u.userId} ${u.role} ${who}`);
|
|
2774
|
+
}
|
|
2775
|
+
}
|
|
2776
|
+
});
|
|
2777
|
+
var telegramCommand = defineCommand17({
|
|
2778
|
+
meta: {
|
|
2779
|
+
name: "telegram",
|
|
2780
|
+
description: "Telegram integration: credentials, health, bot lifecycle, bindings, access"
|
|
2781
|
+
},
|
|
2782
|
+
subCommands: {
|
|
2783
|
+
config: configCmd,
|
|
2784
|
+
health: healthCmd,
|
|
2785
|
+
bot: botCmd,
|
|
2786
|
+
reconnect: reconnectCmd,
|
|
2787
|
+
bind: bindCmd,
|
|
2788
|
+
unbind: unbindCmd,
|
|
2789
|
+
list: listBindingsCmd,
|
|
2790
|
+
allow: allowCmd,
|
|
2791
|
+
deny: denyCmd,
|
|
2792
|
+
allowed: allowedCmd
|
|
2793
|
+
}
|
|
2794
|
+
});
|
|
2795
|
+
|
|
2451
2796
|
// src/commands/token.ts
|
|
2452
2797
|
import { networkInterfaces } from "os";
|
|
2453
|
-
import { defineCommand as
|
|
2798
|
+
import { defineCommand as defineCommand18 } from "citty";
|
|
2454
2799
|
import qrcode from "qrcode-terminal";
|
|
2455
2800
|
function tokenRow(t) {
|
|
2456
2801
|
const last = t.lastUsedAt ? new Date(t.lastUsedAt).toISOString() : "(never)";
|
|
@@ -2484,7 +2829,7 @@ function resolveQrServer(override) {
|
|
|
2484
2829
|
if (detected.warning) console.warn(`\u26A0 ${detected.warning}`);
|
|
2485
2830
|
return detected.origin;
|
|
2486
2831
|
}
|
|
2487
|
-
var createCmd4 =
|
|
2832
|
+
var createCmd4 = defineCommand18({
|
|
2488
2833
|
meta: { name: "create", description: "Mint a new web token (shown once)" },
|
|
2489
2834
|
args: {
|
|
2490
2835
|
label: { type: "positional", required: true, description: "Human-readable label" },
|
|
@@ -2515,7 +2860,7 @@ var createCmd4 = defineCommand17({
|
|
|
2515
2860
|
qrcode.generate(pairUrl, { small: true }, (qr) => console.log(qr));
|
|
2516
2861
|
}
|
|
2517
2862
|
});
|
|
2518
|
-
var listCmd10 =
|
|
2863
|
+
var listCmd10 = defineCommand18({
|
|
2519
2864
|
meta: { name: "list", description: "List web tokens" },
|
|
2520
2865
|
args: {
|
|
2521
2866
|
all: { type: "boolean", description: "Include revoked tokens" }
|
|
@@ -2531,7 +2876,7 @@ var listCmd10 = defineCommand17({
|
|
|
2531
2876
|
for (const line of columnize(tokens.map(tokenRow))) console.log(line);
|
|
2532
2877
|
}
|
|
2533
2878
|
});
|
|
2534
|
-
var showLocalCmd =
|
|
2879
|
+
var showLocalCmd = defineCommand18({
|
|
2535
2880
|
meta: {
|
|
2536
2881
|
name: "show-local",
|
|
2537
2882
|
description: "Print the bootstrap web token stored in ~/.bazilion/auth.json"
|
|
@@ -2541,7 +2886,7 @@ var showLocalCmd = defineCommand17({
|
|
|
2541
2886
|
console.log(readAuthFile(paths.authFile).token);
|
|
2542
2887
|
}
|
|
2543
2888
|
});
|
|
2544
|
-
var revokeCmd =
|
|
2889
|
+
var revokeCmd = defineCommand18({
|
|
2545
2890
|
meta: { name: "revoke", description: "Revoke a web token" },
|
|
2546
2891
|
args: {
|
|
2547
2892
|
id: { type: "positional", required: true }
|
|
@@ -2552,7 +2897,7 @@ var revokeCmd = defineCommand17({
|
|
|
2552
2897
|
console.log(`revoked token ${args.id}`);
|
|
2553
2898
|
}
|
|
2554
2899
|
});
|
|
2555
|
-
var tokenCommand =
|
|
2900
|
+
var tokenCommand = defineCommand18({
|
|
2556
2901
|
meta: { name: "token", description: "Manage web tokens for API/CLI clients" },
|
|
2557
2902
|
subCommands: {
|
|
2558
2903
|
create: createCmd4,
|
|
@@ -2563,8 +2908,8 @@ var tokenCommand = defineCommand17({
|
|
|
2563
2908
|
});
|
|
2564
2909
|
|
|
2565
2910
|
// src/commands/trigger.ts
|
|
2566
|
-
import { defineCommand as
|
|
2567
|
-
var addCmd2 =
|
|
2911
|
+
import { defineCommand as defineCommand19 } from "citty";
|
|
2912
|
+
var addCmd2 = defineCommand19({
|
|
2568
2913
|
meta: { name: "add", description: "Add a heartbeat / cron trigger to an agent" },
|
|
2569
2914
|
args: {
|
|
2570
2915
|
agent: { type: "positional", required: true },
|
|
@@ -2612,7 +2957,7 @@ function triggerRow(t) {
|
|
|
2612
2957
|
const msgPreview = t.message.length > 60 ? `${t.message.slice(0, 60)}\u2026` : t.message;
|
|
2613
2958
|
return [t.id, state, spec, `last: ${last}`, `"${msgPreview}"`];
|
|
2614
2959
|
}
|
|
2615
|
-
var listCmd11 =
|
|
2960
|
+
var listCmd11 = defineCommand19({
|
|
2616
2961
|
meta: { name: "list", description: "List triggers for an agent" },
|
|
2617
2962
|
args: {
|
|
2618
2963
|
agent: { type: "positional", required: true }
|
|
@@ -2629,7 +2974,7 @@ var listCmd11 = defineCommand18({
|
|
|
2629
2974
|
for (const line of columnize(triggers.map(triggerRow))) console.log(line);
|
|
2630
2975
|
}
|
|
2631
2976
|
});
|
|
2632
|
-
var rmCmd5 =
|
|
2977
|
+
var rmCmd5 = defineCommand19({
|
|
2633
2978
|
meta: { name: "rm", description: "Delete a trigger" },
|
|
2634
2979
|
args: {
|
|
2635
2980
|
id: { type: "positional", required: true }
|
|
@@ -2640,7 +2985,7 @@ var rmCmd5 = defineCommand18({
|
|
|
2640
2985
|
console.log(`removed trigger ${args.id}`);
|
|
2641
2986
|
}
|
|
2642
2987
|
});
|
|
2643
|
-
var enableCmd2 =
|
|
2988
|
+
var enableCmd2 = defineCommand19({
|
|
2644
2989
|
meta: { name: "enable", description: "Enable a trigger" },
|
|
2645
2990
|
args: {
|
|
2646
2991
|
id: { type: "positional", required: true }
|
|
@@ -2652,7 +2997,7 @@ var enableCmd2 = defineCommand18({
|
|
|
2652
2997
|
console.log(`enabled trigger ${args.id}`);
|
|
2653
2998
|
}
|
|
2654
2999
|
});
|
|
2655
|
-
var disableCmd2 =
|
|
3000
|
+
var disableCmd2 = defineCommand19({
|
|
2656
3001
|
meta: { name: "disable", description: "Disable a trigger" },
|
|
2657
3002
|
args: {
|
|
2658
3003
|
id: { type: "positional", required: true }
|
|
@@ -2664,7 +3009,7 @@ var disableCmd2 = defineCommand18({
|
|
|
2664
3009
|
console.log(`disabled trigger ${args.id}`);
|
|
2665
3010
|
}
|
|
2666
3011
|
});
|
|
2667
|
-
var triggerCommand =
|
|
3012
|
+
var triggerCommand = defineCommand19({
|
|
2668
3013
|
meta: { name: "trigger", description: "Manage agent heartbeats / cron triggers" },
|
|
2669
3014
|
subCommands: {
|
|
2670
3015
|
add: addCmd2,
|
|
@@ -2678,7 +3023,7 @@ var triggerCommand = defineCommand18({
|
|
|
2678
3023
|
// src/commands/uninstall.ts
|
|
2679
3024
|
import { existsSync as existsSync6, readdirSync as readdirSync2, rmSync as rmSync4 } from "fs";
|
|
2680
3025
|
import { join as join5 } from "path";
|
|
2681
|
-
import { defineCommand as
|
|
3026
|
+
import { defineCommand as defineCommand20 } from "citty";
|
|
2682
3027
|
function makeLineReader() {
|
|
2683
3028
|
let buffer = "";
|
|
2684
3029
|
let ended = false;
|
|
@@ -2726,7 +3071,7 @@ function removePath(p) {
|
|
|
2726
3071
|
rmSync4(p, { recursive: true, force: true });
|
|
2727
3072
|
return true;
|
|
2728
3073
|
}
|
|
2729
|
-
var uninstallCommand =
|
|
3074
|
+
var uninstallCommand = defineCommand20({
|
|
2730
3075
|
meta: {
|
|
2731
3076
|
name: "uninstall",
|
|
2732
3077
|
description: "Wipe bazilion state from ~/.bazilion (or BAZILION_HOME)"
|
|
@@ -2804,7 +3149,7 @@ var uninstallCommand = defineCommand19({
|
|
|
2804
3149
|
|
|
2805
3150
|
// src/index.ts
|
|
2806
3151
|
var VERSION = package_default.version;
|
|
2807
|
-
var main =
|
|
3152
|
+
var main = defineCommand21({
|
|
2808
3153
|
meta: {
|
|
2809
3154
|
name: "bazilion",
|
|
2810
3155
|
version: VERSION,
|
|
@@ -2828,6 +3173,7 @@ var main = defineCommand20({
|
|
|
2828
3173
|
trigger: triggerCommand,
|
|
2829
3174
|
token: tokenCommand,
|
|
2830
3175
|
auth: authCommand,
|
|
3176
|
+
telegram: telegramCommand,
|
|
2831
3177
|
uninstall: uninstallCommand
|
|
2832
3178
|
}
|
|
2833
3179
|
});
|
|
@@ -2903,6 +3249,10 @@ function printTopLevelHelp() {
|
|
|
2903
3249
|
["trigger", "Manage agent heartbeats / cron triggers"]
|
|
2904
3250
|
]
|
|
2905
3251
|
},
|
|
3252
|
+
{
|
|
3253
|
+
title: "integrations",
|
|
3254
|
+
items: [["telegram", "Telegram bot setup, health, lifecycle"]]
|
|
3255
|
+
},
|
|
2906
3256
|
{
|
|
2907
3257
|
title: "ops",
|
|
2908
3258
|
items: [["backup", "Download a tar.gz backup of ~/.bazilion"]]
|