bazilion 0.3.0 → 0.5.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 +308 -129
- package/dist/cli.js.map +1 -1
- package/dist/daemon.js +21921 -1198
- package/dist/daemon.js.map +1 -1
- package/dist/migrations/0002_profile_groups.sql +0 -1
- package/dist/migrations/0007_mcp_servers.sql +30 -0
- package/dist/migrations/0008_seed_user_md.sql +39 -0
- package/dist/worker.js +436 -92
- package/dist/worker.js.map +1 -1
- package/package.json +11 -10
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 defineCommand22, 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.5.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: {
|
|
@@ -49,18 +49,19 @@ var package_default = {
|
|
|
49
49
|
access: "public"
|
|
50
50
|
},
|
|
51
51
|
dependencies: {
|
|
52
|
-
"@earendil-works/pi-agent-core": "^0.
|
|
53
|
-
"@earendil-works/pi-ai": "^0.
|
|
54
|
-
"@earendil-works/pi-coding-agent": "^0.
|
|
55
|
-
"@hono/node-server": "^2.0.
|
|
52
|
+
"@earendil-works/pi-agent-core": "^0.77.0",
|
|
53
|
+
"@earendil-works/pi-ai": "^0.77.0",
|
|
54
|
+
"@earendil-works/pi-coding-agent": "^0.77.0",
|
|
55
|
+
"@hono/node-server": "^2.0.4",
|
|
56
56
|
"@mozilla/readability": "^0.6.0",
|
|
57
|
-
"@tobilu/qmd": "^2.5.
|
|
57
|
+
"@tobilu/qmd": "^2.5.3",
|
|
58
58
|
"adm-zip": "^0.5.17",
|
|
59
59
|
citty: "^0.2.2",
|
|
60
|
-
hono: "^4.12.
|
|
60
|
+
hono: "^4.12.23",
|
|
61
61
|
linkedom: "^0.18.12",
|
|
62
|
+
playwright: "^1.60.0",
|
|
62
63
|
"qrcode-terminal": "^0.12.0",
|
|
63
|
-
typebox: "^1.1.
|
|
64
|
+
typebox: "^1.1.39",
|
|
64
65
|
undici: "^8.3.0",
|
|
65
66
|
yaml: "^2.9.0"
|
|
66
67
|
},
|
|
@@ -209,6 +210,8 @@ function createClient2(cfg = loadClientConfig()) {
|
|
|
209
210
|
}
|
|
210
211
|
|
|
211
212
|
// src/commands/agent.ts
|
|
213
|
+
import { readFileSync as readFileSync2, writeFileSync } from "fs";
|
|
214
|
+
import { basename, extname } from "path";
|
|
212
215
|
import { stdin, stdout } from "process";
|
|
213
216
|
import { createInterface } from "readline/promises";
|
|
214
217
|
import { defineCommand } from "citty";
|
|
@@ -234,6 +237,39 @@ function columnize(rows, gap = " ") {
|
|
|
234
237
|
}
|
|
235
238
|
|
|
236
239
|
// src/commands/agent.ts
|
|
240
|
+
var IMAGE_MIME = {
|
|
241
|
+
".png": "image/png",
|
|
242
|
+
".jpg": "image/jpeg",
|
|
243
|
+
".jpeg": "image/jpeg",
|
|
244
|
+
".gif": "image/gif",
|
|
245
|
+
".webp": "image/webp"
|
|
246
|
+
};
|
|
247
|
+
function loadImages(paths) {
|
|
248
|
+
return paths.map((p) => {
|
|
249
|
+
const mimeType = IMAGE_MIME[extname(p).toLowerCase()];
|
|
250
|
+
if (!mimeType) throw new Error(`unsupported image type: ${p} (png/jpg/gif/webp only)`);
|
|
251
|
+
return { name: basename(p), mimeType, data: readFileSync2(p).toString("base64") };
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
var FILE_MIME = {
|
|
255
|
+
".pdf": "application/pdf",
|
|
256
|
+
".txt": "text/plain",
|
|
257
|
+
".md": "text/markdown",
|
|
258
|
+
".csv": "text/csv",
|
|
259
|
+
".json": "application/json",
|
|
260
|
+
".html": "text/html",
|
|
261
|
+
".zip": "application/zip"
|
|
262
|
+
};
|
|
263
|
+
function loadFiles(paths) {
|
|
264
|
+
return paths.map((p) => ({
|
|
265
|
+
name: basename(p),
|
|
266
|
+
mimeType: FILE_MIME[extname(p).toLowerCase()] ?? "application/octet-stream",
|
|
267
|
+
data: readFileSync2(p).toString("base64")
|
|
268
|
+
}));
|
|
269
|
+
}
|
|
270
|
+
function asPaths(v) {
|
|
271
|
+
return v ? Array.isArray(v) ? v : [v] : [];
|
|
272
|
+
}
|
|
237
273
|
var spawnCmd = defineCommand({
|
|
238
274
|
meta: { name: "spawn", description: "Spawn an agent from a profile into a group" },
|
|
239
275
|
args: {
|
|
@@ -419,6 +455,16 @@ function printEvent(e, state) {
|
|
|
419
455
|
case "tool_error":
|
|
420
456
|
console.log(` [tool error: ${e.name} \u2014 ${e.error}]`);
|
|
421
457
|
break;
|
|
458
|
+
case "file": {
|
|
459
|
+
if (state.inDeltaStream) {
|
|
460
|
+
process.stdout.write("\n");
|
|
461
|
+
state.inDeltaStream = false;
|
|
462
|
+
}
|
|
463
|
+
const out = basename(e.name).replace(/[^\w.-]/g, "_") || "file";
|
|
464
|
+
writeFileSync(out, Buffer.from(e.data, "base64"));
|
|
465
|
+
console.log(` [file received: saved to ./${out} (${e.mimeType})]`);
|
|
466
|
+
break;
|
|
467
|
+
}
|
|
422
468
|
case "error":
|
|
423
469
|
if (state.inDeltaStream) {
|
|
424
470
|
process.stdout.write("\n");
|
|
@@ -428,10 +474,11 @@ function printEvent(e, state) {
|
|
|
428
474
|
break;
|
|
429
475
|
}
|
|
430
476
|
}
|
|
431
|
-
async function streamTurn(client, agentId, message) {
|
|
477
|
+
async function streamTurn(client, agentId, message, attachments) {
|
|
432
478
|
const state = { inDeltaStream: false };
|
|
433
479
|
for await (const frame of client.stream("POST", `/api/agents/${agentId}/chat`, {
|
|
434
|
-
message
|
|
480
|
+
message,
|
|
481
|
+
...attachments && attachments.length > 0 ? { attachments } : {}
|
|
435
482
|
})) {
|
|
436
483
|
if (frame.kind === "event") {
|
|
437
484
|
if (frame.event.type !== "user_message") printEvent(frame.event, state);
|
|
@@ -448,13 +495,25 @@ var chatCmd = defineCommand({
|
|
|
448
495
|
message: {
|
|
449
496
|
type: "string",
|
|
450
497
|
description: "Send a single message and exit (one-shot mode)"
|
|
498
|
+
},
|
|
499
|
+
image: {
|
|
500
|
+
type: "string",
|
|
501
|
+
description: "Attach an image file (png/jpg/gif/webp; repeatable). One-shot mode."
|
|
502
|
+
},
|
|
503
|
+
file: {
|
|
504
|
+
type: "string",
|
|
505
|
+
description: "Attach any file \u2014 the agent gets a path reference (repeatable). One-shot mode."
|
|
451
506
|
}
|
|
452
507
|
},
|
|
453
508
|
async run({ args }) {
|
|
454
509
|
const client = createClient2();
|
|
455
510
|
const resolved = await client.get(`/api/agents/${args.id}`);
|
|
456
|
-
|
|
457
|
-
|
|
511
|
+
const attachments = [
|
|
512
|
+
...loadImages(asPaths(args.image)),
|
|
513
|
+
...loadFiles(asPaths(args.file))
|
|
514
|
+
];
|
|
515
|
+
if (args.message || attachments.length > 0) {
|
|
516
|
+
await streamTurn(client, resolved.agent.id, args.message ?? "", attachments);
|
|
458
517
|
return;
|
|
459
518
|
}
|
|
460
519
|
console.log(`chatting with ${resolved.agent.name} (${resolved.model})`);
|
|
@@ -808,7 +867,7 @@ var openaiLoginCmd = defineCommand2({
|
|
|
808
867
|
console.log(`access token expires: ${formatExpiry(status.expiresAt)}`);
|
|
809
868
|
console.log("");
|
|
810
869
|
console.log(`enable the 'openai-codex' provider on /config and add at least one model`);
|
|
811
|
-
console.log("(e.g. gpt-5.
|
|
870
|
+
console.log("(e.g. gpt-5.3-codex, gpt-5.4, gpt-5.5) to start using it.");
|
|
812
871
|
}
|
|
813
872
|
});
|
|
814
873
|
var openaiLogoutCmd = defineCommand2({
|
|
@@ -1295,7 +1354,7 @@ var doctorCommand = defineCommand6({
|
|
|
1295
1354
|
});
|
|
1296
1355
|
|
|
1297
1356
|
// src/commands/group.ts
|
|
1298
|
-
import { readFileSync as
|
|
1357
|
+
import { readFileSync as readFileSync3 } from "fs";
|
|
1299
1358
|
import { stdin as stdin2 } from "process";
|
|
1300
1359
|
import { defineCommand as defineCommand7 } from "citty";
|
|
1301
1360
|
var addCmd = defineCommand7({
|
|
@@ -1375,7 +1434,7 @@ var userMdSetCmd = defineCommand7({
|
|
|
1375
1434
|
async run({ args }) {
|
|
1376
1435
|
let content;
|
|
1377
1436
|
if (args["from-stdin"]) content = await readStdin();
|
|
1378
|
-
else if (args.file) content =
|
|
1437
|
+
else if (args.file) content = readFileSync3(args.file, "utf8");
|
|
1379
1438
|
else if (args.text !== void 0) content = args.text;
|
|
1380
1439
|
else {
|
|
1381
1440
|
console.error("group user-md set: provide --file, --from-stdin, or --text");
|
|
@@ -1543,7 +1602,7 @@ var inboxCommand = defineCommand8({
|
|
|
1543
1602
|
});
|
|
1544
1603
|
|
|
1545
1604
|
// src/commands/login.ts
|
|
1546
|
-
import { existsSync as existsSync3, readFileSync as
|
|
1605
|
+
import { existsSync as existsSync3, readFileSync as readFileSync4, writeFileSync as writeFileSync2 } from "fs";
|
|
1547
1606
|
import { defineCommand as defineCommand9 } from "citty";
|
|
1548
1607
|
function normalizeServer(raw) {
|
|
1549
1608
|
let url;
|
|
@@ -1582,14 +1641,14 @@ var loginCommand = defineCommand9({
|
|
|
1582
1641
|
`${paths.authFile} not found. Start the daemon with "bazilion serve" first \u2014 login stores the remote there.`
|
|
1583
1642
|
);
|
|
1584
1643
|
}
|
|
1585
|
-
const auth = JSON.parse(
|
|
1644
|
+
const auth = JSON.parse(readFileSync4(paths.authFile, "utf8"));
|
|
1586
1645
|
if (args.clear) {
|
|
1587
1646
|
if (!auth.remote) {
|
|
1588
1647
|
console.log("no remote stored \u2014 nothing to clear");
|
|
1589
1648
|
return;
|
|
1590
1649
|
}
|
|
1591
1650
|
delete auth.remote;
|
|
1592
|
-
|
|
1651
|
+
writeFileSync2(paths.authFile, `${JSON.stringify(auth, null, 2)}
|
|
1593
1652
|
`, { mode: 384 });
|
|
1594
1653
|
console.log("cleared stored remote; CLI will fall back to the local daemon");
|
|
1595
1654
|
return;
|
|
@@ -1604,19 +1663,138 @@ var loginCommand = defineCommand9({
|
|
|
1604
1663
|
await verifyToken(server, args.token);
|
|
1605
1664
|
}
|
|
1606
1665
|
auth.remote = { server, token: args.token };
|
|
1607
|
-
|
|
1666
|
+
writeFileSync2(paths.authFile, `${JSON.stringify(auth, null, 2)}
|
|
1608
1667
|
`, { mode: 384 });
|
|
1609
1668
|
console.log(`saved remote: ${server}`);
|
|
1610
1669
|
console.log("CLI will now target this server unless BAZILION_SERVER is set in the env.");
|
|
1611
1670
|
}
|
|
1612
1671
|
});
|
|
1613
1672
|
|
|
1614
|
-
// src/commands/
|
|
1673
|
+
// src/commands/mcp.ts
|
|
1615
1674
|
import { defineCommand as defineCommand10 } from "citty";
|
|
1675
|
+
function serverRow(s) {
|
|
1676
|
+
const where = s.transport === "stdio" ? `${s.command} ${s.args.join(" ")}`.trim() : s.url ?? "";
|
|
1677
|
+
return [
|
|
1678
|
+
s.id,
|
|
1679
|
+
s.enabled ? "enabled" : "disabled",
|
|
1680
|
+
s.transport,
|
|
1681
|
+
s.hasAuthToken ? "auth" : "-",
|
|
1682
|
+
s.name,
|
|
1683
|
+
where
|
|
1684
|
+
];
|
|
1685
|
+
}
|
|
1686
|
+
var addCmd2 = defineCommand10({
|
|
1687
|
+
meta: { name: "add", description: "Register an MCP server" },
|
|
1688
|
+
args: {
|
|
1689
|
+
name: { type: "positional", required: true, description: "Unique name ([a-zA-Z0-9_])" },
|
|
1690
|
+
transport: { type: "string", description: "stdio | http | sse (default stdio)" },
|
|
1691
|
+
command: { type: "string", description: "stdio: executable to run (e.g. npx)" },
|
|
1692
|
+
args: { type: "string", description: "stdio: space-separated args (quote the whole string)" },
|
|
1693
|
+
url: { type: "string", description: "http/sse: endpoint URL" },
|
|
1694
|
+
token: { type: "string", description: "http/sse: bearer token (stored encrypted)" },
|
|
1695
|
+
disabled: { type: "boolean", description: "Create disabled" }
|
|
1696
|
+
},
|
|
1697
|
+
async run({ args }) {
|
|
1698
|
+
const transport = args.transport ?? "stdio";
|
|
1699
|
+
const body = {
|
|
1700
|
+
name: args.name,
|
|
1701
|
+
transport,
|
|
1702
|
+
command: args.command ?? null,
|
|
1703
|
+
args: args.args ? args.args.split(" ").filter(Boolean) : [],
|
|
1704
|
+
url: args.url ?? null,
|
|
1705
|
+
authToken: args.token ?? void 0,
|
|
1706
|
+
enabled: !args.disabled
|
|
1707
|
+
};
|
|
1708
|
+
const client = createClient2();
|
|
1709
|
+
const { server } = await client.post("/api/mcp-servers", body);
|
|
1710
|
+
console.log(`${server.id} ${server.name} ${server.transport}`);
|
|
1711
|
+
}
|
|
1712
|
+
});
|
|
1713
|
+
var listCmd5 = defineCommand10({
|
|
1714
|
+
meta: { name: "list", description: "List MCP servers" },
|
|
1715
|
+
async run() {
|
|
1716
|
+
const client = createClient2();
|
|
1717
|
+
const { servers } = await client.get("/api/mcp-servers");
|
|
1718
|
+
if (servers.length === 0) {
|
|
1719
|
+
console.log("(no MCP servers)");
|
|
1720
|
+
return;
|
|
1721
|
+
}
|
|
1722
|
+
for (const line of columnize(servers.map(serverRow))) console.log(line);
|
|
1723
|
+
}
|
|
1724
|
+
});
|
|
1725
|
+
var showCmd3 = defineCommand10({
|
|
1726
|
+
meta: { name: "show", description: "Show one MCP server" },
|
|
1727
|
+
args: { id: { type: "positional", required: true } },
|
|
1728
|
+
async run({ args }) {
|
|
1729
|
+
const client = createClient2();
|
|
1730
|
+
const { server } = await client.get(`/api/mcp-servers/${args.id}`);
|
|
1731
|
+
console.log(JSON.stringify(server, null, 2));
|
|
1732
|
+
}
|
|
1733
|
+
});
|
|
1734
|
+
var rmCmd3 = defineCommand10({
|
|
1735
|
+
meta: { name: "rm", description: "Delete an MCP server" },
|
|
1736
|
+
args: { id: { type: "positional", required: true } },
|
|
1737
|
+
async run({ args }) {
|
|
1738
|
+
const client = createClient2();
|
|
1739
|
+
await client.del(`/api/mcp-servers/${args.id}`);
|
|
1740
|
+
console.log(`removed MCP server ${args.id}`);
|
|
1741
|
+
}
|
|
1742
|
+
});
|
|
1743
|
+
var enableCmd = defineCommand10({
|
|
1744
|
+
meta: { name: "enable", description: "Enable an MCP server" },
|
|
1745
|
+
args: { id: { type: "positional", required: true } },
|
|
1746
|
+
async run({ args }) {
|
|
1747
|
+
const client = createClient2();
|
|
1748
|
+
await client.patch(`/api/mcp-servers/${args.id}`, { enabled: true });
|
|
1749
|
+
console.log(`enabled MCP server ${args.id}`);
|
|
1750
|
+
}
|
|
1751
|
+
});
|
|
1752
|
+
var disableCmd = defineCommand10({
|
|
1753
|
+
meta: { name: "disable", description: "Disable an MCP server" },
|
|
1754
|
+
args: { id: { type: "positional", required: true } },
|
|
1755
|
+
async run({ args }) {
|
|
1756
|
+
const client = createClient2();
|
|
1757
|
+
await client.patch(`/api/mcp-servers/${args.id}`, { enabled: false });
|
|
1758
|
+
console.log(`disabled MCP server ${args.id}`);
|
|
1759
|
+
}
|
|
1760
|
+
});
|
|
1761
|
+
var testCmd = defineCommand10({
|
|
1762
|
+
meta: { name: "test", description: "Connect to a server and list its tools" },
|
|
1763
|
+
args: { id: { type: "positional", required: true } },
|
|
1764
|
+
async run({ args }) {
|
|
1765
|
+
const client = createClient2();
|
|
1766
|
+
const res = await client.post(
|
|
1767
|
+
`/api/mcp-servers/${args.id}/test`
|
|
1768
|
+
);
|
|
1769
|
+
if (!res.ok) {
|
|
1770
|
+
console.error(`connection failed: ${res.error}`);
|
|
1771
|
+
process.exitCode = 1;
|
|
1772
|
+
return;
|
|
1773
|
+
}
|
|
1774
|
+
const tools = res.tools ?? [];
|
|
1775
|
+
console.log(`connected \u2014 ${tools.length} tool(s):`);
|
|
1776
|
+
for (const t of tools) console.log(` ${t.name} ${t.description}`);
|
|
1777
|
+
}
|
|
1778
|
+
});
|
|
1779
|
+
var mcpCommand = defineCommand10({
|
|
1780
|
+
meta: { name: "mcp", description: "Manage MCP servers" },
|
|
1781
|
+
subCommands: {
|
|
1782
|
+
add: addCmd2,
|
|
1783
|
+
list: listCmd5,
|
|
1784
|
+
show: showCmd3,
|
|
1785
|
+
rm: rmCmd3,
|
|
1786
|
+
enable: enableCmd,
|
|
1787
|
+
disable: disableCmd,
|
|
1788
|
+
test: testCmd
|
|
1789
|
+
}
|
|
1790
|
+
});
|
|
1791
|
+
|
|
1792
|
+
// src/commands/memory.ts
|
|
1793
|
+
import { defineCommand as defineCommand11 } from "citty";
|
|
1616
1794
|
function encodeKey(key) {
|
|
1617
1795
|
return key.split("/").map(encodeURIComponent).join("/");
|
|
1618
1796
|
}
|
|
1619
|
-
var writeCmd =
|
|
1797
|
+
var writeCmd = defineCommand11({
|
|
1620
1798
|
meta: { name: "write", description: "Write an entry into a group's shared memory" },
|
|
1621
1799
|
args: {
|
|
1622
1800
|
group: { type: "positional", required: true, description: "Group slug" },
|
|
@@ -1632,7 +1810,7 @@ var writeCmd = defineCommand10({
|
|
|
1632
1810
|
console.log(`wrote ${entry2.key} (${entry2.content.length} bytes)`);
|
|
1633
1811
|
}
|
|
1634
1812
|
});
|
|
1635
|
-
var readCmd2 =
|
|
1813
|
+
var readCmd2 = defineCommand11({
|
|
1636
1814
|
meta: { name: "read", description: "Read an entry from a group's shared memory" },
|
|
1637
1815
|
args: {
|
|
1638
1816
|
group: { type: "positional", required: true, description: "Group slug" },
|
|
@@ -1646,7 +1824,7 @@ var readCmd2 = defineCommand10({
|
|
|
1646
1824
|
console.log(entry2.content);
|
|
1647
1825
|
}
|
|
1648
1826
|
});
|
|
1649
|
-
var searchCmd =
|
|
1827
|
+
var searchCmd = defineCommand11({
|
|
1650
1828
|
meta: { name: "search", description: "Search a group's shared memory" },
|
|
1651
1829
|
args: {
|
|
1652
1830
|
group: { type: "positional", required: true, description: "Group slug" },
|
|
@@ -1667,7 +1845,7 @@ var searchCmd = defineCommand10({
|
|
|
1667
1845
|
}
|
|
1668
1846
|
}
|
|
1669
1847
|
});
|
|
1670
|
-
var
|
|
1848
|
+
var listCmd6 = defineCommand11({
|
|
1671
1849
|
meta: { name: "list", description: "List all entries in a group's shared memory" },
|
|
1672
1850
|
args: {
|
|
1673
1851
|
group: { type: "positional", required: true, description: "Group slug" }
|
|
@@ -1684,7 +1862,7 @@ var listCmd5 = defineCommand10({
|
|
|
1684
1862
|
}
|
|
1685
1863
|
}
|
|
1686
1864
|
});
|
|
1687
|
-
var
|
|
1865
|
+
var rmCmd4 = defineCommand11({
|
|
1688
1866
|
meta: { name: "rm", description: "Remove an entry from a group's shared memory" },
|
|
1689
1867
|
args: {
|
|
1690
1868
|
group: { type: "positional", required: true, description: "Group slug" },
|
|
@@ -1696,7 +1874,7 @@ var rmCmd3 = defineCommand10({
|
|
|
1696
1874
|
console.log(`removed ${args.key}`);
|
|
1697
1875
|
}
|
|
1698
1876
|
});
|
|
1699
|
-
var memoryCommand =
|
|
1877
|
+
var memoryCommand = defineCommand11({
|
|
1700
1878
|
meta: {
|
|
1701
1879
|
name: "memory",
|
|
1702
1880
|
description: "Manage a group's shared memory (BM25-indexed markdown notes)"
|
|
@@ -1705,15 +1883,15 @@ var memoryCommand = defineCommand10({
|
|
|
1705
1883
|
write: writeCmd,
|
|
1706
1884
|
read: readCmd2,
|
|
1707
1885
|
search: searchCmd,
|
|
1708
|
-
list:
|
|
1709
|
-
rm:
|
|
1886
|
+
list: listCmd6,
|
|
1887
|
+
rm: rmCmd4
|
|
1710
1888
|
}
|
|
1711
1889
|
});
|
|
1712
1890
|
|
|
1713
1891
|
// src/commands/profile.ts
|
|
1714
1892
|
import { spawn as spawn2 } from "child_process";
|
|
1715
1893
|
import { randomBytes } from "crypto";
|
|
1716
|
-
import { readFileSync as
|
|
1894
|
+
import { readFileSync as readFileSync5, rmSync as rmSync2, writeFileSync as writeFileSync3 } from "fs";
|
|
1717
1895
|
import { tmpdir } from "os";
|
|
1718
1896
|
import { join as join2 } from "path";
|
|
1719
1897
|
|
|
@@ -1729,7 +1907,7 @@ var PROFILE_FILES = [
|
|
|
1729
1907
|
];
|
|
1730
1908
|
|
|
1731
1909
|
// src/commands/profile.ts
|
|
1732
|
-
import { defineCommand as
|
|
1910
|
+
import { defineCommand as defineCommand12 } from "citty";
|
|
1733
1911
|
function splitCsv(v) {
|
|
1734
1912
|
if (!v) return void 0;
|
|
1735
1913
|
const out = v.split(",").map((s) => s.trim()).filter(Boolean);
|
|
@@ -1740,7 +1918,7 @@ function parseSkillsMode(v) {
|
|
|
1740
1918
|
if (v === "all" || v === "selected") return v;
|
|
1741
1919
|
throw new Error(`--skills-mode must be 'all' or 'selected', got '${v}'`);
|
|
1742
1920
|
}
|
|
1743
|
-
var createCmd2 =
|
|
1921
|
+
var createCmd2 = defineCommand12({
|
|
1744
1922
|
meta: { name: "create", description: "Create a new profile" },
|
|
1745
1923
|
args: {
|
|
1746
1924
|
id: { type: "positional", required: true, description: "Profile slug" },
|
|
@@ -1748,7 +1926,7 @@ var createCmd2 = defineCommand11({
|
|
|
1748
1926
|
model: {
|
|
1749
1927
|
type: "string",
|
|
1750
1928
|
required: true,
|
|
1751
|
-
description: "Default model, e.g. anthropic:claude-opus-4-
|
|
1929
|
+
description: "Default model, e.g. anthropic:claude-opus-4-8"
|
|
1752
1930
|
},
|
|
1753
1931
|
"skills-mode": {
|
|
1754
1932
|
type: "string",
|
|
@@ -1789,7 +1967,7 @@ var createCmd2 = defineCommand11({
|
|
|
1789
1967
|
},
|
|
1790
1968
|
async run({ args }) {
|
|
1791
1969
|
const skillsMode = parseSkillsMode(args["skills-mode"]);
|
|
1792
|
-
const readTemplate = (path) => path ?
|
|
1970
|
+
const readTemplate = (path) => path ? readFileSync5(path, "utf8") : void 0;
|
|
1793
1971
|
const body = {
|
|
1794
1972
|
id: args.id,
|
|
1795
1973
|
name: args.name,
|
|
@@ -1808,7 +1986,7 @@ var createCmd2 = defineCommand11({
|
|
|
1808
1986
|
console.log(`created profile ${profile.id} at ${profile.dir}`);
|
|
1809
1987
|
}
|
|
1810
1988
|
});
|
|
1811
|
-
var
|
|
1989
|
+
var listCmd7 = defineCommand12({
|
|
1812
1990
|
meta: { name: "list", description: "List profiles" },
|
|
1813
1991
|
async run() {
|
|
1814
1992
|
const client = createClient2();
|
|
@@ -1821,7 +1999,7 @@ var listCmd6 = defineCommand11({
|
|
|
1821
1999
|
for (const line of columnize(rows)) console.log(line);
|
|
1822
2000
|
}
|
|
1823
2001
|
});
|
|
1824
|
-
var
|
|
2002
|
+
var showCmd4 = defineCommand12({
|
|
1825
2003
|
meta: { name: "show", description: "Show profile details" },
|
|
1826
2004
|
args: {
|
|
1827
2005
|
id: { type: "positional", required: true }
|
|
@@ -1847,7 +2025,7 @@ var showCmd3 = defineCommand11({
|
|
|
1847
2025
|
}
|
|
1848
2026
|
}
|
|
1849
2027
|
});
|
|
1850
|
-
var editCmd2 =
|
|
2028
|
+
var editCmd2 = defineCommand12({
|
|
1851
2029
|
meta: { name: "edit", description: "Open a profile file in $EDITOR" },
|
|
1852
2030
|
args: {
|
|
1853
2031
|
id: { type: "positional", required: true },
|
|
@@ -1867,7 +2045,7 @@ var editCmd2 = defineCommand11({
|
|
|
1867
2045
|
`/api/profiles/${args.id}/files/${file}`
|
|
1868
2046
|
);
|
|
1869
2047
|
const tmpPath = join2(tmpdir(), `bazilion-${args.id}-${file}-${randomBytes(4).toString("hex")}`);
|
|
1870
|
-
|
|
2048
|
+
writeFileSync3(tmpPath, content);
|
|
1871
2049
|
try {
|
|
1872
2050
|
const editor = process.env.EDITOR ?? process.env.VISUAL ?? "vi";
|
|
1873
2051
|
const code = await new Promise((resolve3, reject) => {
|
|
@@ -1876,7 +2054,7 @@ var editCmd2 = defineCommand11({
|
|
|
1876
2054
|
child.on("close", (c) => resolve3(c ?? 0));
|
|
1877
2055
|
});
|
|
1878
2056
|
if (code !== 0) throw new Error(`editor exited with code ${code}`);
|
|
1879
|
-
const updated =
|
|
2057
|
+
const updated = readFileSync5(tmpPath, "utf8");
|
|
1880
2058
|
if (updated === content) {
|
|
1881
2059
|
console.log("(no changes)");
|
|
1882
2060
|
return;
|
|
@@ -1892,7 +2070,7 @@ var editCmd2 = defineCommand11({
|
|
|
1892
2070
|
}
|
|
1893
2071
|
}
|
|
1894
2072
|
});
|
|
1895
|
-
var updateCmd =
|
|
2073
|
+
var updateCmd = defineCommand12({
|
|
1896
2074
|
meta: {
|
|
1897
2075
|
name: "update",
|
|
1898
2076
|
description: "Update profile settings (name, model, skills-mode, skills)"
|
|
@@ -1926,7 +2104,7 @@ var updateCmd = defineCommand11({
|
|
|
1926
2104
|
console.log(`updated profile ${profile.id}`);
|
|
1927
2105
|
}
|
|
1928
2106
|
});
|
|
1929
|
-
var deleteCmd2 =
|
|
2107
|
+
var deleteCmd2 = defineCommand12({
|
|
1930
2108
|
meta: { name: "delete", description: "Permanently delete a profile and its files" },
|
|
1931
2109
|
args: {
|
|
1932
2110
|
id: { type: "positional", required: true }
|
|
@@ -1937,12 +2115,12 @@ var deleteCmd2 = defineCommand11({
|
|
|
1937
2115
|
console.log(`deleted profile ${args.id}`);
|
|
1938
2116
|
}
|
|
1939
2117
|
});
|
|
1940
|
-
var profileCommand =
|
|
2118
|
+
var profileCommand = defineCommand12({
|
|
1941
2119
|
meta: { name: "profile", description: "Manage profiles" },
|
|
1942
2120
|
subCommands: {
|
|
1943
2121
|
create: createCmd2,
|
|
1944
|
-
list:
|
|
1945
|
-
show:
|
|
2122
|
+
list: listCmd7,
|
|
2123
|
+
show: showCmd4,
|
|
1946
2124
|
edit: editCmd2,
|
|
1947
2125
|
update: updateCmd,
|
|
1948
2126
|
delete: deleteCmd2
|
|
@@ -1952,11 +2130,11 @@ var profileCommand = defineCommand11({
|
|
|
1952
2130
|
// src/commands/profile-group.ts
|
|
1953
2131
|
import { spawn as spawn3 } from "child_process";
|
|
1954
2132
|
import { randomBytes as randomBytes2 } from "crypto";
|
|
1955
|
-
import { readFileSync as
|
|
2133
|
+
import { readFileSync as readFileSync6, rmSync as rmSync3, writeFileSync as writeFileSync4 } from "fs";
|
|
1956
2134
|
import { tmpdir as tmpdir2 } from "os";
|
|
1957
2135
|
import { join as join3 } from "path";
|
|
1958
|
-
import { defineCommand as
|
|
1959
|
-
var createCmd3 =
|
|
2136
|
+
import { defineCommand as defineCommand13 } from "citty";
|
|
2137
|
+
var createCmd3 = defineCommand13({
|
|
1960
2138
|
meta: { name: "create", description: "Create a new profile group (team template)" },
|
|
1961
2139
|
args: {
|
|
1962
2140
|
id: { type: "positional", required: true, description: "Profile group slug" },
|
|
@@ -1969,13 +2147,13 @@ var createCmd3 = defineCommand12({
|
|
|
1969
2147
|
async run({ args }) {
|
|
1970
2148
|
const body = { id: args.id };
|
|
1971
2149
|
if (args.name) body.name = args.name;
|
|
1972
|
-
if (args["user-md-file"]) body.userMd =
|
|
2150
|
+
if (args["user-md-file"]) body.userMd = readFileSync6(args["user-md-file"], "utf8");
|
|
1973
2151
|
const client = createClient2();
|
|
1974
2152
|
const created = await client.post("/api/profile-groups", body);
|
|
1975
2153
|
console.log(`created profile group ${created.id}`);
|
|
1976
2154
|
}
|
|
1977
2155
|
});
|
|
1978
|
-
var
|
|
2156
|
+
var listCmd8 = defineCommand13({
|
|
1979
2157
|
meta: { name: "list", description: "List profile groups" },
|
|
1980
2158
|
async run() {
|
|
1981
2159
|
const client = createClient2();
|
|
@@ -1988,7 +2166,7 @@ var listCmd7 = defineCommand12({
|
|
|
1988
2166
|
for (const line of columnize(rows)) console.log(line);
|
|
1989
2167
|
}
|
|
1990
2168
|
});
|
|
1991
|
-
var
|
|
2169
|
+
var showCmd5 = defineCommand13({
|
|
1992
2170
|
meta: { name: "show", description: "Show profile group details + members" },
|
|
1993
2171
|
args: {
|
|
1994
2172
|
id: { type: "positional", required: true },
|
|
@@ -2025,7 +2203,7 @@ var showCmd4 = defineCommand12({
|
|
|
2025
2203
|
for (const line of columnize(rows)) console.log(` ${line}`);
|
|
2026
2204
|
}
|
|
2027
2205
|
});
|
|
2028
|
-
var updateCmd2 =
|
|
2206
|
+
var updateCmd2 = defineCommand13({
|
|
2029
2207
|
meta: { name: "update", description: "Update profile group basics (name, user-md)" },
|
|
2030
2208
|
args: {
|
|
2031
2209
|
id: { type: "positional", required: true },
|
|
@@ -2039,7 +2217,7 @@ var updateCmd2 = defineCommand12({
|
|
|
2039
2217
|
const body = {};
|
|
2040
2218
|
if (args.name !== void 0) body.name = args.name;
|
|
2041
2219
|
if (args["user-md-file"] !== void 0) {
|
|
2042
|
-
body.userMd = args["user-md-file"] === "" ? null :
|
|
2220
|
+
body.userMd = args["user-md-file"] === "" ? null : readFileSync6(args["user-md-file"], "utf8");
|
|
2043
2221
|
}
|
|
2044
2222
|
if (Object.keys(body).length === 0) {
|
|
2045
2223
|
throw new Error("nothing to update \u2014 pass at least one of --name/--user-md-file");
|
|
@@ -2049,7 +2227,7 @@ var updateCmd2 = defineCommand12({
|
|
|
2049
2227
|
console.log(`updated profile group ${updated.id}`);
|
|
2050
2228
|
}
|
|
2051
2229
|
});
|
|
2052
|
-
var editCmd3 =
|
|
2230
|
+
var editCmd3 = defineCommand13({
|
|
2053
2231
|
meta: { name: "edit", description: "Edit the member array in $EDITOR (JSON)" },
|
|
2054
2232
|
args: {
|
|
2055
2233
|
id: { type: "positional", required: true }
|
|
@@ -2069,7 +2247,7 @@ var editCmd3 = defineCommand12({
|
|
|
2069
2247
|
tmpdir2(),
|
|
2070
2248
|
`bazilion-profile-group-${args.id}-${randomBytes2(4).toString("hex")}.json`
|
|
2071
2249
|
);
|
|
2072
|
-
|
|
2250
|
+
writeFileSync4(tmpPath, before);
|
|
2073
2251
|
try {
|
|
2074
2252
|
const editor = process.env.EDITOR ?? process.env.VISUAL ?? "vi";
|
|
2075
2253
|
const code = await new Promise((resolve3, reject) => {
|
|
@@ -2078,7 +2256,7 @@ var editCmd3 = defineCommand12({
|
|
|
2078
2256
|
child.on("close", (c) => resolve3(c ?? 0));
|
|
2079
2257
|
});
|
|
2080
2258
|
if (code !== 0) throw new Error(`editor exited with code ${code}`);
|
|
2081
|
-
const after =
|
|
2259
|
+
const after = readFileSync6(tmpPath, "utf8");
|
|
2082
2260
|
if (after === before) {
|
|
2083
2261
|
console.log("(no changes)");
|
|
2084
2262
|
return;
|
|
@@ -2116,7 +2294,7 @@ var editCmd3 = defineCommand12({
|
|
|
2116
2294
|
}
|
|
2117
2295
|
}
|
|
2118
2296
|
});
|
|
2119
|
-
var deleteCmd3 =
|
|
2297
|
+
var deleteCmd3 = defineCommand13({
|
|
2120
2298
|
meta: { name: "delete", description: "Delete a profile group (does not affect spawned agents)" },
|
|
2121
2299
|
args: {
|
|
2122
2300
|
id: { type: "positional", required: true }
|
|
@@ -2127,7 +2305,7 @@ var deleteCmd3 = defineCommand12({
|
|
|
2127
2305
|
console.log(`deleted profile group ${args.id}`);
|
|
2128
2306
|
}
|
|
2129
2307
|
});
|
|
2130
|
-
var spawnCmd2 =
|
|
2308
|
+
var spawnCmd2 = defineCommand13({
|
|
2131
2309
|
meta: { name: "spawn", description: "Spawn the whole team into a group (transactional)" },
|
|
2132
2310
|
args: {
|
|
2133
2311
|
id: { type: "positional", required: true },
|
|
@@ -2143,7 +2321,7 @@ var spawnCmd2 = defineCommand12({
|
|
|
2143
2321
|
async run({ args }) {
|
|
2144
2322
|
const body = {};
|
|
2145
2323
|
if (args.group) body.groupSlug = args.group;
|
|
2146
|
-
if (args["user-md-file"]) body.userMd =
|
|
2324
|
+
if (args["user-md-file"]) body.userMd = readFileSync6(args["user-md-file"], "utf8");
|
|
2147
2325
|
const client = createClient2();
|
|
2148
2326
|
const result = await client.post(
|
|
2149
2327
|
`/api/profile-groups/${args.id}/spawn`,
|
|
@@ -2160,12 +2338,12 @@ var spawnCmd2 = defineCommand12({
|
|
|
2160
2338
|
}
|
|
2161
2339
|
}
|
|
2162
2340
|
});
|
|
2163
|
-
var profileGroupCommand =
|
|
2341
|
+
var profileGroupCommand = defineCommand13({
|
|
2164
2342
|
meta: { name: "profile-group", description: "Manage profile groups" },
|
|
2165
2343
|
subCommands: {
|
|
2166
2344
|
create: createCmd3,
|
|
2167
|
-
list:
|
|
2168
|
-
show:
|
|
2345
|
+
list: listCmd8,
|
|
2346
|
+
show: showCmd5,
|
|
2169
2347
|
update: updateCmd2,
|
|
2170
2348
|
edit: editCmd3,
|
|
2171
2349
|
delete: deleteCmd3,
|
|
@@ -2174,8 +2352,8 @@ var profileGroupCommand = defineCommand12({
|
|
|
2174
2352
|
});
|
|
2175
2353
|
|
|
2176
2354
|
// src/commands/provider.ts
|
|
2177
|
-
import { defineCommand as
|
|
2178
|
-
var
|
|
2355
|
+
import { defineCommand as defineCommand14 } from "citty";
|
|
2356
|
+
var listCmd9 = defineCommand14({
|
|
2179
2357
|
meta: {
|
|
2180
2358
|
name: "list",
|
|
2181
2359
|
description: "List all providers with enabled/disabled state and curated model counts"
|
|
@@ -2201,7 +2379,7 @@ var listCmd8 = defineCommand13({
|
|
|
2201
2379
|
for (const line of columnize(rows)) console.log(line);
|
|
2202
2380
|
}
|
|
2203
2381
|
});
|
|
2204
|
-
var modelsCmd =
|
|
2382
|
+
var modelsCmd = defineCommand14({
|
|
2205
2383
|
meta: {
|
|
2206
2384
|
name: "models",
|
|
2207
2385
|
description: "Show curated + catalog + live models for one provider"
|
|
@@ -2233,7 +2411,7 @@ var modelsCmd = defineCommand13({
|
|
|
2233
2411
|
}
|
|
2234
2412
|
}
|
|
2235
2413
|
});
|
|
2236
|
-
var modelsSetCmd =
|
|
2414
|
+
var modelsSetCmd = defineCommand14({
|
|
2237
2415
|
meta: {
|
|
2238
2416
|
name: "models-set",
|
|
2239
2417
|
description: "Replace the curated model list for a provider (comma-separated)"
|
|
@@ -2258,7 +2436,7 @@ var modelsSetCmd = defineCommand13({
|
|
|
2258
2436
|
for (const m of saved.models) console.log(` ${m}`);
|
|
2259
2437
|
}
|
|
2260
2438
|
});
|
|
2261
|
-
var
|
|
2439
|
+
var enableCmd2 = defineCommand14({
|
|
2262
2440
|
meta: { name: "enable", description: "Toggle a provider on so agents can use it" },
|
|
2263
2441
|
args: {
|
|
2264
2442
|
name: { type: "positional", required: true, description: "Provider id (e.g. anthropic)" }
|
|
@@ -2272,7 +2450,7 @@ var enableCmd = defineCommand13({
|
|
|
2272
2450
|
console.log(`${res.name}: enabled`);
|
|
2273
2451
|
}
|
|
2274
2452
|
});
|
|
2275
|
-
var
|
|
2453
|
+
var disableCmd2 = defineCommand14({
|
|
2276
2454
|
meta: {
|
|
2277
2455
|
name: "disable",
|
|
2278
2456
|
description: "Toggle a provider off \u2014 agents will refuse its model strings"
|
|
@@ -2289,13 +2467,13 @@ var disableCmd = defineCommand13({
|
|
|
2289
2467
|
console.log(`${res.name}: disabled`);
|
|
2290
2468
|
}
|
|
2291
2469
|
});
|
|
2292
|
-
var
|
|
2470
|
+
var testCmd2 = defineCommand14({
|
|
2293
2471
|
meta: { name: "test", description: "Send a single chat to a model and print the reply" },
|
|
2294
2472
|
args: {
|
|
2295
2473
|
model: {
|
|
2296
2474
|
type: "positional",
|
|
2297
2475
|
required: true,
|
|
2298
|
-
description: "Model string, e.g. anthropic:claude-opus-4-
|
|
2476
|
+
description: "Model string, e.g. anthropic:claude-opus-4-8"
|
|
2299
2477
|
},
|
|
2300
2478
|
message: { type: "string", description: 'Message text (default "say hi briefly")' }
|
|
2301
2479
|
},
|
|
@@ -2310,21 +2488,21 @@ var testCmd = defineCommand13({
|
|
|
2310
2488
|
}
|
|
2311
2489
|
}
|
|
2312
2490
|
});
|
|
2313
|
-
var providerCommand =
|
|
2491
|
+
var providerCommand = defineCommand14({
|
|
2314
2492
|
meta: { name: "provider", description: "Manage and test LLM providers" },
|
|
2315
2493
|
subCommands: {
|
|
2316
|
-
list:
|
|
2317
|
-
enable:
|
|
2318
|
-
disable:
|
|
2494
|
+
list: listCmd9,
|
|
2495
|
+
enable: enableCmd2,
|
|
2496
|
+
disable: disableCmd2,
|
|
2319
2497
|
models: modelsCmd,
|
|
2320
2498
|
"models-set": modelsSetCmd,
|
|
2321
|
-
test:
|
|
2499
|
+
test: testCmd2
|
|
2322
2500
|
}
|
|
2323
2501
|
});
|
|
2324
2502
|
|
|
2325
2503
|
// src/commands/send.ts
|
|
2326
|
-
import { defineCommand as
|
|
2327
|
-
var sendCommand =
|
|
2504
|
+
import { defineCommand as defineCommand15 } from "citty";
|
|
2505
|
+
var sendCommand = defineCommand15({
|
|
2328
2506
|
meta: {
|
|
2329
2507
|
name: "send",
|
|
2330
2508
|
description: "Send a message from one agent to another"
|
|
@@ -2349,11 +2527,11 @@ var sendCommand = defineCommand14({
|
|
|
2349
2527
|
import { spawn as spawn4 } from "child_process";
|
|
2350
2528
|
import { existsSync as existsSync4 } from "fs";
|
|
2351
2529
|
import { join as join4 } from "path";
|
|
2352
|
-
import { defineCommand as
|
|
2530
|
+
import { defineCommand as defineCommand16 } from "citty";
|
|
2353
2531
|
var bundledDaemonEntry = join4(import.meta.dirname, "daemon.js");
|
|
2354
2532
|
var sourceDaemonEntry = join4(import.meta.dirname, "..", "..", "..", "daemon", "src", "index.ts");
|
|
2355
2533
|
var daemonEntry = existsSync4(bundledDaemonEntry) ? bundledDaemonEntry : sourceDaemonEntry;
|
|
2356
|
-
var serveCommand =
|
|
2534
|
+
var serveCommand = defineCommand16({
|
|
2357
2535
|
meta: {
|
|
2358
2536
|
name: "serve",
|
|
2359
2537
|
description: "Start the bazilion daemon (HTTP API)"
|
|
@@ -2420,10 +2598,10 @@ var serveCommand = defineCommand15({
|
|
|
2420
2598
|
});
|
|
2421
2599
|
|
|
2422
2600
|
// src/commands/skill.ts
|
|
2423
|
-
import { existsSync as existsSync5, readFileSync as
|
|
2424
|
-
import { basename, resolve as resolve2 } from "path";
|
|
2425
|
-
import { defineCommand as
|
|
2426
|
-
var
|
|
2601
|
+
import { existsSync as existsSync5, readFileSync as readFileSync7, statSync } from "fs";
|
|
2602
|
+
import { basename as basename2, resolve as resolve2 } from "path";
|
|
2603
|
+
import { defineCommand as defineCommand17 } from "citty";
|
|
2604
|
+
var listCmd10 = defineCommand17({
|
|
2427
2605
|
meta: { name: "list", description: "List installed skills (or those attached to an agent)" },
|
|
2428
2606
|
args: {
|
|
2429
2607
|
agent: { type: "string", description: "Filter to skills attached to this agent" }
|
|
@@ -2455,7 +2633,7 @@ var listCmd9 = defineCommand16({
|
|
|
2455
2633
|
for (const line of columnize(rows)) console.log(line);
|
|
2456
2634
|
}
|
|
2457
2635
|
});
|
|
2458
|
-
var importCmd =
|
|
2636
|
+
var importCmd = defineCommand17({
|
|
2459
2637
|
meta: {
|
|
2460
2638
|
name: "import",
|
|
2461
2639
|
description: "Import skills from openclaw, a directory, or a local .zip archive"
|
|
@@ -2474,8 +2652,8 @@ var importCmd = defineCommand16({
|
|
|
2474
2652
|
const isLocalZip = args.from.toLowerCase().endsWith(".zip") && existsSync5(absFrom) && statSync(absFrom).isFile();
|
|
2475
2653
|
let result;
|
|
2476
2654
|
if (isLocalZip) {
|
|
2477
|
-
const bytes =
|
|
2478
|
-
const file = new File([bytes],
|
|
2655
|
+
const bytes = readFileSync7(absFrom);
|
|
2656
|
+
const file = new File([bytes], basename2(absFrom), { type: "application/zip" });
|
|
2479
2657
|
const fd = new FormData();
|
|
2480
2658
|
fd.set("file", file);
|
|
2481
2659
|
if (args.force) fd.set("force", "true");
|
|
@@ -2499,7 +2677,7 @@ var importCmd = defineCommand16({
|
|
|
2499
2677
|
}
|
|
2500
2678
|
}
|
|
2501
2679
|
});
|
|
2502
|
-
var
|
|
2680
|
+
var rmCmd5 = defineCommand17({
|
|
2503
2681
|
meta: { name: "rm", description: "Remove an installed skill" },
|
|
2504
2682
|
args: {
|
|
2505
2683
|
name: { type: "positional", required: true }
|
|
@@ -2510,18 +2688,18 @@ var rmCmd4 = defineCommand16({
|
|
|
2510
2688
|
console.log(`removed skill ${args.name}`);
|
|
2511
2689
|
}
|
|
2512
2690
|
});
|
|
2513
|
-
var skillCommand =
|
|
2691
|
+
var skillCommand = defineCommand17({
|
|
2514
2692
|
meta: { name: "skill", description: "Manage the skill library" },
|
|
2515
2693
|
subCommands: {
|
|
2516
|
-
list:
|
|
2694
|
+
list: listCmd10,
|
|
2517
2695
|
import: importCmd,
|
|
2518
|
-
rm:
|
|
2696
|
+
rm: rmCmd5
|
|
2519
2697
|
}
|
|
2520
2698
|
});
|
|
2521
2699
|
|
|
2522
2700
|
// src/commands/telegram.ts
|
|
2523
|
-
import { defineCommand as
|
|
2524
|
-
var setCmd2 =
|
|
2701
|
+
import { defineCommand as defineCommand18 } from "citty";
|
|
2702
|
+
var setCmd2 = defineCommand18({
|
|
2525
2703
|
meta: {
|
|
2526
2704
|
name: "set",
|
|
2527
2705
|
description: "Save bot token + supergroup chat ID (paired write)"
|
|
@@ -2539,7 +2717,7 @@ var setCmd2 = defineCommand17({
|
|
|
2539
2717
|
console.log(`saved \xB7 token ${state.botTokenPreview} \xB7 chat ${state.chatId}`);
|
|
2540
2718
|
}
|
|
2541
2719
|
});
|
|
2542
|
-
var clearCmd =
|
|
2720
|
+
var clearCmd = defineCommand18({
|
|
2543
2721
|
meta: {
|
|
2544
2722
|
name: "clear",
|
|
2545
2723
|
description: "Remove stored bot token + chat ID"
|
|
@@ -2550,7 +2728,7 @@ var clearCmd = defineCommand17({
|
|
|
2550
2728
|
console.log("cleared");
|
|
2551
2729
|
}
|
|
2552
2730
|
});
|
|
2553
|
-
var
|
|
2731
|
+
var showCmd6 = defineCommand18({
|
|
2554
2732
|
meta: {
|
|
2555
2733
|
name: "show",
|
|
2556
2734
|
description: "Show what credentials are stored (token is masked)"
|
|
@@ -2571,7 +2749,7 @@ var showCmd5 = defineCommand17({
|
|
|
2571
2749
|
}
|
|
2572
2750
|
}
|
|
2573
2751
|
});
|
|
2574
|
-
var reconnectCmd =
|
|
2752
|
+
var reconnectCmd = defineCommand18({
|
|
2575
2753
|
meta: {
|
|
2576
2754
|
name: "reconnect",
|
|
2577
2755
|
description: "Apply a pending supergroup chat-id migration + re-activate the bot"
|
|
@@ -2582,7 +2760,7 @@ var reconnectCmd = defineCommand17({
|
|
|
2582
2760
|
console.log(`reconnected \xB7 chat ${state.chatId}`);
|
|
2583
2761
|
}
|
|
2584
2762
|
});
|
|
2585
|
-
var configCmd =
|
|
2763
|
+
var configCmd = defineCommand18({
|
|
2586
2764
|
meta: {
|
|
2587
2765
|
name: "config",
|
|
2588
2766
|
description: "Manage Telegram credentials (bot token + chat ID)"
|
|
@@ -2590,10 +2768,10 @@ var configCmd = defineCommand17({
|
|
|
2590
2768
|
subCommands: {
|
|
2591
2769
|
set: setCmd2,
|
|
2592
2770
|
clear: clearCmd,
|
|
2593
|
-
show:
|
|
2771
|
+
show: showCmd6
|
|
2594
2772
|
}
|
|
2595
2773
|
});
|
|
2596
|
-
var healthCmd =
|
|
2774
|
+
var healthCmd = defineCommand18({
|
|
2597
2775
|
meta: {
|
|
2598
2776
|
name: "health",
|
|
2599
2777
|
description: "Run the four-step preflight against the Telegram Bot API"
|
|
@@ -2627,7 +2805,7 @@ var healthCmd = defineCommand17({
|
|
|
2627
2805
|
if (!allOk) process.exitCode = 1;
|
|
2628
2806
|
}
|
|
2629
2807
|
});
|
|
2630
|
-
var botStatusCmd =
|
|
2808
|
+
var botStatusCmd = defineCommand18({
|
|
2631
2809
|
meta: {
|
|
2632
2810
|
name: "status",
|
|
2633
2811
|
description: "Show polling state of the live bot"
|
|
@@ -2652,7 +2830,7 @@ var botStatusCmd = defineCommand17({
|
|
|
2652
2830
|
if (!p.running) process.exitCode = 1;
|
|
2653
2831
|
}
|
|
2654
2832
|
});
|
|
2655
|
-
var botRestartCmd =
|
|
2833
|
+
var botRestartCmd = defineCommand18({
|
|
2656
2834
|
meta: {
|
|
2657
2835
|
name: "restart",
|
|
2658
2836
|
description: "Force-restart the bot (tears down + brings up from current creds)"
|
|
@@ -2663,7 +2841,7 @@ var botRestartCmd = defineCommand17({
|
|
|
2663
2841
|
console.log("restart requested");
|
|
2664
2842
|
}
|
|
2665
2843
|
});
|
|
2666
|
-
var botCmd =
|
|
2844
|
+
var botCmd = defineCommand18({
|
|
2667
2845
|
meta: {
|
|
2668
2846
|
name: "bot",
|
|
2669
2847
|
description: "Inspect / control the live polling bot"
|
|
@@ -2673,7 +2851,7 @@ var botCmd = defineCommand17({
|
|
|
2673
2851
|
restart: botRestartCmd
|
|
2674
2852
|
}
|
|
2675
2853
|
});
|
|
2676
|
-
var bindCmd =
|
|
2854
|
+
var bindCmd = defineCommand18({
|
|
2677
2855
|
meta: {
|
|
2678
2856
|
name: "bind",
|
|
2679
2857
|
description: "Create a Telegram topic for an agent (manual fallback for /talk)"
|
|
@@ -2691,7 +2869,7 @@ var bindCmd = defineCommand17({
|
|
|
2691
2869
|
console.log(` ${result.deepLink}`);
|
|
2692
2870
|
}
|
|
2693
2871
|
});
|
|
2694
|
-
var unbindCmd =
|
|
2872
|
+
var unbindCmd = defineCommand18({
|
|
2695
2873
|
meta: {
|
|
2696
2874
|
name: "unbind",
|
|
2697
2875
|
description: "Clear an agent's Telegram topic binding (topic stays in Telegram as orphan)"
|
|
@@ -2705,7 +2883,7 @@ var unbindCmd = defineCommand17({
|
|
|
2705
2883
|
console.log(`unbound agent ${args.agent}`);
|
|
2706
2884
|
}
|
|
2707
2885
|
});
|
|
2708
|
-
var listBindingsCmd =
|
|
2886
|
+
var listBindingsCmd = defineCommand18({
|
|
2709
2887
|
meta: {
|
|
2710
2888
|
name: "list",
|
|
2711
2889
|
description: "List agents and their Telegram topic bindings"
|
|
@@ -2733,7 +2911,7 @@ var listBindingsCmd = defineCommand17({
|
|
|
2733
2911
|
}
|
|
2734
2912
|
}
|
|
2735
2913
|
});
|
|
2736
|
-
var allowCmd =
|
|
2914
|
+
var allowCmd = defineCommand18({
|
|
2737
2915
|
meta: { name: "allow", description: "Add a Telegram user id to the allowlist" },
|
|
2738
2916
|
args: {
|
|
2739
2917
|
userId: { type: "positional", required: true, description: "Numeric Telegram user id" },
|
|
@@ -2750,7 +2928,7 @@ var allowCmd = defineCommand17({
|
|
|
2750
2928
|
console.log(`allowed ${u.userId} (${u.role})`);
|
|
2751
2929
|
}
|
|
2752
2930
|
});
|
|
2753
|
-
var denyCmd =
|
|
2931
|
+
var denyCmd = defineCommand18({
|
|
2754
2932
|
meta: { name: "deny", description: "Remove a Telegram user id from the allowlist" },
|
|
2755
2933
|
args: { userId: { type: "positional", required: true } },
|
|
2756
2934
|
async run({ args }) {
|
|
@@ -2759,7 +2937,7 @@ var denyCmd = defineCommand17({
|
|
|
2759
2937
|
console.log(`removed ${args.userId}`);
|
|
2760
2938
|
}
|
|
2761
2939
|
});
|
|
2762
|
-
var allowedCmd =
|
|
2940
|
+
var allowedCmd = defineCommand18({
|
|
2763
2941
|
meta: { name: "allowed", description: "List allowlisted Telegram users" },
|
|
2764
2942
|
async run() {
|
|
2765
2943
|
const client = createClient2();
|
|
@@ -2774,7 +2952,7 @@ var allowedCmd = defineCommand17({
|
|
|
2774
2952
|
}
|
|
2775
2953
|
}
|
|
2776
2954
|
});
|
|
2777
|
-
var telegramCommand =
|
|
2955
|
+
var telegramCommand = defineCommand18({
|
|
2778
2956
|
meta: {
|
|
2779
2957
|
name: "telegram",
|
|
2780
2958
|
description: "Telegram integration: credentials, health, bot lifecycle, bindings, access"
|
|
@@ -2795,7 +2973,7 @@ var telegramCommand = defineCommand17({
|
|
|
2795
2973
|
|
|
2796
2974
|
// src/commands/token.ts
|
|
2797
2975
|
import { networkInterfaces } from "os";
|
|
2798
|
-
import { defineCommand as
|
|
2976
|
+
import { defineCommand as defineCommand19 } from "citty";
|
|
2799
2977
|
import qrcode from "qrcode-terminal";
|
|
2800
2978
|
function tokenRow(t) {
|
|
2801
2979
|
const last = t.lastUsedAt ? new Date(t.lastUsedAt).toISOString() : "(never)";
|
|
@@ -2829,7 +3007,7 @@ function resolveQrServer(override) {
|
|
|
2829
3007
|
if (detected.warning) console.warn(`\u26A0 ${detected.warning}`);
|
|
2830
3008
|
return detected.origin;
|
|
2831
3009
|
}
|
|
2832
|
-
var createCmd4 =
|
|
3010
|
+
var createCmd4 = defineCommand19({
|
|
2833
3011
|
meta: { name: "create", description: "Mint a new web token (shown once)" },
|
|
2834
3012
|
args: {
|
|
2835
3013
|
label: { type: "positional", required: true, description: "Human-readable label" },
|
|
@@ -2860,7 +3038,7 @@ var createCmd4 = defineCommand18({
|
|
|
2860
3038
|
qrcode.generate(pairUrl, { small: true }, (qr) => console.log(qr));
|
|
2861
3039
|
}
|
|
2862
3040
|
});
|
|
2863
|
-
var
|
|
3041
|
+
var listCmd11 = defineCommand19({
|
|
2864
3042
|
meta: { name: "list", description: "List web tokens" },
|
|
2865
3043
|
args: {
|
|
2866
3044
|
all: { type: "boolean", description: "Include revoked tokens" }
|
|
@@ -2876,7 +3054,7 @@ var listCmd10 = defineCommand18({
|
|
|
2876
3054
|
for (const line of columnize(tokens.map(tokenRow))) console.log(line);
|
|
2877
3055
|
}
|
|
2878
3056
|
});
|
|
2879
|
-
var showLocalCmd =
|
|
3057
|
+
var showLocalCmd = defineCommand19({
|
|
2880
3058
|
meta: {
|
|
2881
3059
|
name: "show-local",
|
|
2882
3060
|
description: "Print the bootstrap web token stored in ~/.bazilion/auth.json"
|
|
@@ -2886,7 +3064,7 @@ var showLocalCmd = defineCommand18({
|
|
|
2886
3064
|
console.log(readAuthFile(paths.authFile).token);
|
|
2887
3065
|
}
|
|
2888
3066
|
});
|
|
2889
|
-
var revokeCmd =
|
|
3067
|
+
var revokeCmd = defineCommand19({
|
|
2890
3068
|
meta: { name: "revoke", description: "Revoke a web token" },
|
|
2891
3069
|
args: {
|
|
2892
3070
|
id: { type: "positional", required: true }
|
|
@@ -2897,19 +3075,19 @@ var revokeCmd = defineCommand18({
|
|
|
2897
3075
|
console.log(`revoked token ${args.id}`);
|
|
2898
3076
|
}
|
|
2899
3077
|
});
|
|
2900
|
-
var tokenCommand =
|
|
3078
|
+
var tokenCommand = defineCommand19({
|
|
2901
3079
|
meta: { name: "token", description: "Manage web tokens for API/CLI clients" },
|
|
2902
3080
|
subCommands: {
|
|
2903
3081
|
create: createCmd4,
|
|
2904
|
-
list:
|
|
3082
|
+
list: listCmd11,
|
|
2905
3083
|
revoke: revokeCmd,
|
|
2906
3084
|
"show-local": showLocalCmd
|
|
2907
3085
|
}
|
|
2908
3086
|
});
|
|
2909
3087
|
|
|
2910
3088
|
// src/commands/trigger.ts
|
|
2911
|
-
import { defineCommand as
|
|
2912
|
-
var
|
|
3089
|
+
import { defineCommand as defineCommand20 } from "citty";
|
|
3090
|
+
var addCmd3 = defineCommand20({
|
|
2913
3091
|
meta: { name: "add", description: "Add a heartbeat / cron trigger to an agent" },
|
|
2914
3092
|
args: {
|
|
2915
3093
|
agent: { type: "positional", required: true },
|
|
@@ -2957,7 +3135,7 @@ function triggerRow(t) {
|
|
|
2957
3135
|
const msgPreview = t.message.length > 60 ? `${t.message.slice(0, 60)}\u2026` : t.message;
|
|
2958
3136
|
return [t.id, state, spec, `last: ${last}`, `"${msgPreview}"`];
|
|
2959
3137
|
}
|
|
2960
|
-
var
|
|
3138
|
+
var listCmd12 = defineCommand20({
|
|
2961
3139
|
meta: { name: "list", description: "List triggers for an agent" },
|
|
2962
3140
|
args: {
|
|
2963
3141
|
agent: { type: "positional", required: true }
|
|
@@ -2974,7 +3152,7 @@ var listCmd11 = defineCommand19({
|
|
|
2974
3152
|
for (const line of columnize(triggers.map(triggerRow))) console.log(line);
|
|
2975
3153
|
}
|
|
2976
3154
|
});
|
|
2977
|
-
var
|
|
3155
|
+
var rmCmd6 = defineCommand20({
|
|
2978
3156
|
meta: { name: "rm", description: "Delete a trigger" },
|
|
2979
3157
|
args: {
|
|
2980
3158
|
id: { type: "positional", required: true }
|
|
@@ -2985,7 +3163,7 @@ var rmCmd5 = defineCommand19({
|
|
|
2985
3163
|
console.log(`removed trigger ${args.id}`);
|
|
2986
3164
|
}
|
|
2987
3165
|
});
|
|
2988
|
-
var
|
|
3166
|
+
var enableCmd3 = defineCommand20({
|
|
2989
3167
|
meta: { name: "enable", description: "Enable a trigger" },
|
|
2990
3168
|
args: {
|
|
2991
3169
|
id: { type: "positional", required: true }
|
|
@@ -2997,7 +3175,7 @@ var enableCmd2 = defineCommand19({
|
|
|
2997
3175
|
console.log(`enabled trigger ${args.id}`);
|
|
2998
3176
|
}
|
|
2999
3177
|
});
|
|
3000
|
-
var
|
|
3178
|
+
var disableCmd3 = defineCommand20({
|
|
3001
3179
|
meta: { name: "disable", description: "Disable a trigger" },
|
|
3002
3180
|
args: {
|
|
3003
3181
|
id: { type: "positional", required: true }
|
|
@@ -3009,21 +3187,21 @@ var disableCmd2 = defineCommand19({
|
|
|
3009
3187
|
console.log(`disabled trigger ${args.id}`);
|
|
3010
3188
|
}
|
|
3011
3189
|
});
|
|
3012
|
-
var triggerCommand =
|
|
3190
|
+
var triggerCommand = defineCommand20({
|
|
3013
3191
|
meta: { name: "trigger", description: "Manage agent heartbeats / cron triggers" },
|
|
3014
3192
|
subCommands: {
|
|
3015
|
-
add:
|
|
3016
|
-
list:
|
|
3017
|
-
rm:
|
|
3018
|
-
enable:
|
|
3019
|
-
disable:
|
|
3193
|
+
add: addCmd3,
|
|
3194
|
+
list: listCmd12,
|
|
3195
|
+
rm: rmCmd6,
|
|
3196
|
+
enable: enableCmd3,
|
|
3197
|
+
disable: disableCmd3
|
|
3020
3198
|
}
|
|
3021
3199
|
});
|
|
3022
3200
|
|
|
3023
3201
|
// src/commands/uninstall.ts
|
|
3024
3202
|
import { existsSync as existsSync6, readdirSync as readdirSync2, rmSync as rmSync4 } from "fs";
|
|
3025
3203
|
import { join as join5 } from "path";
|
|
3026
|
-
import { defineCommand as
|
|
3204
|
+
import { defineCommand as defineCommand21 } from "citty";
|
|
3027
3205
|
function makeLineReader() {
|
|
3028
3206
|
let buffer = "";
|
|
3029
3207
|
let ended = false;
|
|
@@ -3071,7 +3249,7 @@ function removePath(p) {
|
|
|
3071
3249
|
rmSync4(p, { recursive: true, force: true });
|
|
3072
3250
|
return true;
|
|
3073
3251
|
}
|
|
3074
|
-
var uninstallCommand =
|
|
3252
|
+
var uninstallCommand = defineCommand21({
|
|
3075
3253
|
meta: {
|
|
3076
3254
|
name: "uninstall",
|
|
3077
3255
|
description: "Wipe bazilion state from ~/.bazilion (or BAZILION_HOME)"
|
|
@@ -3149,7 +3327,7 @@ var uninstallCommand = defineCommand20({
|
|
|
3149
3327
|
|
|
3150
3328
|
// src/index.ts
|
|
3151
3329
|
var VERSION = package_default.version;
|
|
3152
|
-
var main =
|
|
3330
|
+
var main = defineCommand22({
|
|
3153
3331
|
meta: {
|
|
3154
3332
|
name: "bazilion",
|
|
3155
3333
|
version: VERSION,
|
|
@@ -3163,6 +3341,7 @@ var main = defineCommand21({
|
|
|
3163
3341
|
agent: agentCommand,
|
|
3164
3342
|
skill: skillCommand,
|
|
3165
3343
|
memory: memoryCommand,
|
|
3344
|
+
mcp: mcpCommand,
|
|
3166
3345
|
provider: providerCommand,
|
|
3167
3346
|
send: sendCommand,
|
|
3168
3347
|
inbox: inboxCommand,
|