cc-claw 0.3.1 → 0.3.3
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/agents/mcp-server.js +1 -1
- package/dist/cli.js +560 -177
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -48,7 +48,7 @@ var VERSION;
|
|
|
48
48
|
var init_version = __esm({
|
|
49
49
|
"src/version.ts"() {
|
|
50
50
|
"use strict";
|
|
51
|
-
VERSION = true ? "0.3.
|
|
51
|
+
VERSION = true ? "0.3.3" : (() => {
|
|
52
52
|
try {
|
|
53
53
|
return JSON.parse(readFileSync(join2(process.cwd(), "package.json"), "utf-8")).version ?? "unknown";
|
|
54
54
|
} catch {
|
|
@@ -410,6 +410,20 @@ var init_store = __esm({
|
|
|
410
410
|
});
|
|
411
411
|
|
|
412
412
|
// src/mcps/store.ts
|
|
413
|
+
var store_exports2 = {};
|
|
414
|
+
__export(store_exports2, {
|
|
415
|
+
addMcpServer: () => addMcpServer,
|
|
416
|
+
addPropagation: () => addPropagation,
|
|
417
|
+
getMcpServer: () => getMcpServer,
|
|
418
|
+
getPropagationsForRunner: () => getPropagationsForRunner,
|
|
419
|
+
initMcpTables: () => initMcpTables,
|
|
420
|
+
listMcpServers: () => listMcpServers,
|
|
421
|
+
listPropagations: () => listPropagations,
|
|
422
|
+
removeMcpServer: () => removeMcpServer,
|
|
423
|
+
removePropagation: () => removePropagation,
|
|
424
|
+
updateMcpHealth: () => updateMcpHealth,
|
|
425
|
+
updateMcpServer: () => updateMcpServer
|
|
426
|
+
});
|
|
413
427
|
function initMcpTables(db3) {
|
|
414
428
|
db3.exec(`
|
|
415
429
|
CREATE TABLE IF NOT EXISTS mcp_servers (
|
|
@@ -433,6 +447,14 @@ function initMcpTables(db3) {
|
|
|
433
447
|
PRIMARY KEY (mcpName, runnerId, scope)
|
|
434
448
|
)
|
|
435
449
|
`);
|
|
450
|
+
const cols = db3.pragma("table_info(mcp_servers)");
|
|
451
|
+
const colNames = new Set(cols.map((c) => c.name));
|
|
452
|
+
if (!colNames.has("healthStatus")) {
|
|
453
|
+
db3.exec("ALTER TABLE mcp_servers ADD COLUMN healthStatus TEXT DEFAULT 'unknown'");
|
|
454
|
+
}
|
|
455
|
+
if (!colNames.has("lastHealthCheck")) {
|
|
456
|
+
db3.exec("ALTER TABLE mcp_servers ADD COLUMN lastHealthCheck TEXT");
|
|
457
|
+
}
|
|
436
458
|
}
|
|
437
459
|
function addMcpServer(db3, opts) {
|
|
438
460
|
db3.prepare(`
|
|
@@ -449,6 +471,45 @@ function addMcpServer(db3, opts) {
|
|
|
449
471
|
opts.enabledByDefault ? 1 : 0
|
|
450
472
|
);
|
|
451
473
|
}
|
|
474
|
+
function updateMcpServer(db3, name, updates) {
|
|
475
|
+
const fields = [];
|
|
476
|
+
const params = [];
|
|
477
|
+
if (updates.transport !== void 0) {
|
|
478
|
+
fields.push("transport = ?");
|
|
479
|
+
params.push(updates.transport);
|
|
480
|
+
}
|
|
481
|
+
if (updates.command !== void 0) {
|
|
482
|
+
fields.push("command = ?");
|
|
483
|
+
params.push(updates.command);
|
|
484
|
+
}
|
|
485
|
+
if (updates.args !== void 0) {
|
|
486
|
+
fields.push("args = ?");
|
|
487
|
+
params.push(updates.args ? JSON.stringify(updates.args) : null);
|
|
488
|
+
}
|
|
489
|
+
if (updates.url !== void 0) {
|
|
490
|
+
fields.push("url = ?");
|
|
491
|
+
params.push(updates.url);
|
|
492
|
+
}
|
|
493
|
+
if (updates.env !== void 0) {
|
|
494
|
+
fields.push("env = ?");
|
|
495
|
+
params.push(updates.env ? JSON.stringify(updates.env) : null);
|
|
496
|
+
}
|
|
497
|
+
if (updates.description !== void 0) {
|
|
498
|
+
fields.push("description = ?");
|
|
499
|
+
params.push(updates.description);
|
|
500
|
+
}
|
|
501
|
+
if (updates.enabledByDefault !== void 0) {
|
|
502
|
+
fields.push("enabledByDefault = ?");
|
|
503
|
+
params.push(updates.enabledByDefault ? 1 : 0);
|
|
504
|
+
}
|
|
505
|
+
if (fields.length === 0) return;
|
|
506
|
+
params.push(name);
|
|
507
|
+
db3.prepare(`UPDATE mcp_servers SET ${fields.join(", ")} WHERE name = ?`).run(...params);
|
|
508
|
+
}
|
|
509
|
+
function removeMcpServer(db3, name) {
|
|
510
|
+
db3.prepare("DELETE FROM mcp_propagation WHERE mcpName = ?").run(name);
|
|
511
|
+
db3.prepare("DELETE FROM mcp_servers WHERE name = ?").run(name);
|
|
512
|
+
}
|
|
452
513
|
function getMcpServer(db3, name) {
|
|
453
514
|
return db3.prepare("SELECT * FROM mcp_servers WHERE name = ?").get(name);
|
|
454
515
|
}
|
|
@@ -463,6 +524,15 @@ function addPropagation(db3, mcpName, runnerId, scope) {
|
|
|
463
524
|
function removePropagation(db3, mcpName, runnerId, scope) {
|
|
464
525
|
db3.prepare("DELETE FROM mcp_propagation WHERE mcpName = ? AND runnerId = ? AND scope = ?").run(mcpName, runnerId, scope);
|
|
465
526
|
}
|
|
527
|
+
function listPropagations(db3) {
|
|
528
|
+
return db3.prepare("SELECT * FROM mcp_propagation ORDER BY mcpName").all();
|
|
529
|
+
}
|
|
530
|
+
function getPropagationsForRunner(db3, runnerId) {
|
|
531
|
+
return db3.prepare("SELECT * FROM mcp_propagation WHERE runnerId = ? ORDER BY mcpName").all(runnerId);
|
|
532
|
+
}
|
|
533
|
+
function updateMcpHealth(db3, name, status) {
|
|
534
|
+
db3.prepare("UPDATE mcp_servers SET healthStatus = ?, lastHealthCheck = datetime('now') WHERE name = ?").run(status, name);
|
|
535
|
+
}
|
|
466
536
|
var init_store2 = __esm({
|
|
467
537
|
"src/mcps/store.ts"() {
|
|
468
538
|
"use strict";
|
|
@@ -847,8 +917,8 @@ var init_embeddings = __esm({
|
|
|
847
917
|
});
|
|
848
918
|
|
|
849
919
|
// src/memory/store.ts
|
|
850
|
-
var
|
|
851
|
-
__export(
|
|
920
|
+
var store_exports3 = {};
|
|
921
|
+
__export(store_exports3, {
|
|
852
922
|
ALL_TOOLS: () => ALL_TOOLS,
|
|
853
923
|
addHeartbeatWatch: () => addHeartbeatWatch,
|
|
854
924
|
addUsage: () => addUsage,
|
|
@@ -2719,7 +2789,7 @@ var init_codex = __esm({
|
|
|
2719
2789
|
type: "result",
|
|
2720
2790
|
resultText: "",
|
|
2721
2791
|
usage: u ? {
|
|
2722
|
-
input: u.input_tokens ?? 0,
|
|
2792
|
+
input: (u.input_tokens ?? 0) - (u.cached_input_tokens ?? 0),
|
|
2723
2793
|
output: u.output_tokens ?? 0,
|
|
2724
2794
|
cacheRead: u.cached_input_tokens ?? 0
|
|
2725
2795
|
} : void 0
|
|
@@ -3712,15 +3782,31 @@ var init_cost = __esm({
|
|
|
3712
3782
|
// src/mcps/propagate.ts
|
|
3713
3783
|
import { execFile } from "child_process";
|
|
3714
3784
|
import { promisify } from "util";
|
|
3785
|
+
import { homedir as homedir2 } from "os";
|
|
3715
3786
|
async function discoverExistingMcps(runner) {
|
|
3716
3787
|
try {
|
|
3717
3788
|
const listCmd = runner.getMcpListCommand();
|
|
3718
3789
|
const exe = runner.getExecutablePath();
|
|
3719
3790
|
const args = listCmd.slice(1);
|
|
3720
|
-
const result = await execFileAsync(exe, args, {
|
|
3791
|
+
const result = await execFileAsync(exe, args, {
|
|
3792
|
+
encoding: "utf-8",
|
|
3793
|
+
env: runner.getEnv(),
|
|
3794
|
+
cwd: homedir2(),
|
|
3795
|
+
timeout: 3e4
|
|
3796
|
+
});
|
|
3721
3797
|
const stdout = typeof result === "string" ? result : Array.isArray(result) ? result[0] : result?.stdout ?? null;
|
|
3722
3798
|
if (stdout == null) return [];
|
|
3723
|
-
|
|
3799
|
+
const seen = /* @__PURE__ */ new Set();
|
|
3800
|
+
for (const line of stdout.split("\n")) {
|
|
3801
|
+
const trimmed = line.trim();
|
|
3802
|
+
if (!trimmed || SKIP_LINE.test(trimmed)) continue;
|
|
3803
|
+
const cleaned = trimmed.replace(/^[✓✗•\-●]\s*/, "");
|
|
3804
|
+
const match = cleaned.match(/^([a-zA-Z0-9_-]+):/);
|
|
3805
|
+
if (match && !seen.has(match[1])) {
|
|
3806
|
+
seen.add(match[1]);
|
|
3807
|
+
}
|
|
3808
|
+
}
|
|
3809
|
+
return [...seen];
|
|
3724
3810
|
} catch {
|
|
3725
3811
|
return [];
|
|
3726
3812
|
}
|
|
@@ -3772,12 +3858,13 @@ async function cleanupMcps(runner, mcps2, db3, scope) {
|
|
|
3772
3858
|
removePropagation(db3, name, runnerId, scope);
|
|
3773
3859
|
}
|
|
3774
3860
|
}
|
|
3775
|
-
var execFileAsync;
|
|
3861
|
+
var execFileAsync, SKIP_LINE;
|
|
3776
3862
|
var init_propagate = __esm({
|
|
3777
3863
|
"src/mcps/propagate.ts"() {
|
|
3778
3864
|
"use strict";
|
|
3779
3865
|
init_store2();
|
|
3780
3866
|
execFileAsync = promisify(execFile);
|
|
3867
|
+
SKIP_LINE = /^(Checking|Configured|No MCP|Try |──)/i;
|
|
3781
3868
|
}
|
|
3782
3869
|
});
|
|
3783
3870
|
|
|
@@ -4465,14 +4552,223 @@ var init_orchestrator = __esm({
|
|
|
4465
4552
|
});
|
|
4466
4553
|
|
|
4467
4554
|
// src/mcps/registry.ts
|
|
4555
|
+
var registry_exports2 = {};
|
|
4556
|
+
__export(registry_exports2, {
|
|
4557
|
+
getMcp: () => getMcp,
|
|
4558
|
+
importMcpsFromBackends: () => importMcpsFromBackends,
|
|
4559
|
+
listRegisteredMcps: () => listRegisteredMcps,
|
|
4560
|
+
registerMcp: () => registerMcp,
|
|
4561
|
+
syncMcps: () => syncMcps,
|
|
4562
|
+
unregisterMcp: () => unregisterMcp
|
|
4563
|
+
});
|
|
4564
|
+
async function propagateChange(db3, mcpName, action) {
|
|
4565
|
+
try {
|
|
4566
|
+
const runners2 = getAllRunners();
|
|
4567
|
+
if (action === "remove") {
|
|
4568
|
+
for (const runner of runners2) {
|
|
4569
|
+
if (!runner.capabilities.supportsMcp) continue;
|
|
4570
|
+
await cleanupMcps(runner, [mcpName], db3, "global").catch(() => {
|
|
4571
|
+
});
|
|
4572
|
+
}
|
|
4573
|
+
} else {
|
|
4574
|
+
const def = getMcpServer(db3, mcpName);
|
|
4575
|
+
if (!def || !def.enabledByDefault) return;
|
|
4576
|
+
for (const runner of runners2) {
|
|
4577
|
+
if (!runner.capabilities.supportsMcp) continue;
|
|
4578
|
+
const existing = await discoverExistingMcps(runner);
|
|
4579
|
+
const missing = diffMcps([mcpName], existing);
|
|
4580
|
+
if (missing.length > 0) {
|
|
4581
|
+
await injectMcps(runner, missing, db3, "global").catch(() => {
|
|
4582
|
+
});
|
|
4583
|
+
}
|
|
4584
|
+
}
|
|
4585
|
+
}
|
|
4586
|
+
} catch (err) {
|
|
4587
|
+
warn(`[mcps] Failed to propagate ${action} for ${mcpName}:`, err);
|
|
4588
|
+
}
|
|
4589
|
+
}
|
|
4590
|
+
function registerMcp(db3, opts) {
|
|
4591
|
+
addMcpServer(db3, opts);
|
|
4592
|
+
propagateChange(db3, opts.name, "add").catch(() => {
|
|
4593
|
+
});
|
|
4594
|
+
}
|
|
4595
|
+
function unregisterMcp(db3, name) {
|
|
4596
|
+
propagateChange(db3, name, "remove").catch(() => {
|
|
4597
|
+
});
|
|
4598
|
+
removeMcpServer(db3, name);
|
|
4599
|
+
}
|
|
4468
4600
|
function listRegisteredMcps(db3) {
|
|
4469
4601
|
return listMcpServers(db3);
|
|
4470
4602
|
}
|
|
4603
|
+
function getMcp(db3, name) {
|
|
4604
|
+
return getMcpServer(db3, name) ?? null;
|
|
4605
|
+
}
|
|
4606
|
+
async function syncMcps(db3, runners2) {
|
|
4607
|
+
const result = { succeeded: [], failed: [] };
|
|
4608
|
+
const enabled = listMcpServers(db3).filter((s) => s.enabledByDefault === 1);
|
|
4609
|
+
const neededNames = enabled.map((s) => s.name);
|
|
4610
|
+
for (const runner of runners2) {
|
|
4611
|
+
if (!runner.capabilities.supportsMcp) continue;
|
|
4612
|
+
try {
|
|
4613
|
+
const existing = await discoverExistingMcps(runner);
|
|
4614
|
+
const toAdd = diffMcps(neededNames, existing);
|
|
4615
|
+
const added = await injectMcps(runner, toAdd, db3, SYNC_SCOPE);
|
|
4616
|
+
if (added.length > 0) result.succeeded.push(`${runner.id}:${added.join(",")}`);
|
|
4617
|
+
} catch (err) {
|
|
4618
|
+
result.failed.push({ runnerId: runner.id, error: err instanceof Error ? err.message : String(err) });
|
|
4619
|
+
}
|
|
4620
|
+
}
|
|
4621
|
+
return result;
|
|
4622
|
+
}
|
|
4623
|
+
async function importMcpsFromBackends(db3, runners2) {
|
|
4624
|
+
const result = { imported: [], skipped: [], errors: [] };
|
|
4625
|
+
const existingNames = new Set(listMcpServers(db3).map((s) => s.name));
|
|
4626
|
+
for (const runner of runners2) {
|
|
4627
|
+
if (!runner.capabilities.supportsMcp) continue;
|
|
4628
|
+
try {
|
|
4629
|
+
const discovered = await discoverExistingMcps(runner);
|
|
4630
|
+
for (const name of discovered) {
|
|
4631
|
+
if (existingNames.has(name)) {
|
|
4632
|
+
result.skipped.push(name);
|
|
4633
|
+
continue;
|
|
4634
|
+
}
|
|
4635
|
+
try {
|
|
4636
|
+
addMcpServer(db3, {
|
|
4637
|
+
name,
|
|
4638
|
+
transport: "stdio",
|
|
4639
|
+
description: `Imported from ${runner.displayName}`
|
|
4640
|
+
});
|
|
4641
|
+
existingNames.add(name);
|
|
4642
|
+
result.imported.push(name);
|
|
4643
|
+
} catch (err) {
|
|
4644
|
+
result.errors.push({ name, error: err instanceof Error ? err.message : String(err) });
|
|
4645
|
+
}
|
|
4646
|
+
}
|
|
4647
|
+
} catch (err) {
|
|
4648
|
+
result.errors.push({ name: `${runner.id}:*`, error: err instanceof Error ? err.message : String(err) });
|
|
4649
|
+
}
|
|
4650
|
+
}
|
|
4651
|
+
return result;
|
|
4652
|
+
}
|
|
4653
|
+
var SYNC_SCOPE;
|
|
4471
4654
|
var init_registry2 = __esm({
|
|
4472
4655
|
"src/mcps/registry.ts"() {
|
|
4473
4656
|
"use strict";
|
|
4474
4657
|
init_store2();
|
|
4475
4658
|
init_propagate();
|
|
4659
|
+
init_registry();
|
|
4660
|
+
init_log();
|
|
4661
|
+
SYNC_SCOPE = "global";
|
|
4662
|
+
}
|
|
4663
|
+
});
|
|
4664
|
+
|
|
4665
|
+
// src/mcps/health.ts
|
|
4666
|
+
var health_exports = {};
|
|
4667
|
+
__export(health_exports, {
|
|
4668
|
+
runHealthChecks: () => runHealthChecks,
|
|
4669
|
+
startHealthMonitor: () => startHealthMonitor,
|
|
4670
|
+
stopHealthMonitor: () => stopHealthMonitor
|
|
4671
|
+
});
|
|
4672
|
+
import { spawn as spawn3 } from "child_process";
|
|
4673
|
+
async function checkStdioHealth(command, args) {
|
|
4674
|
+
return new Promise((resolve) => {
|
|
4675
|
+
const timer = setTimeout(() => {
|
|
4676
|
+
child.kill("SIGKILL");
|
|
4677
|
+
resolve("timeout");
|
|
4678
|
+
}, CHECK_TIMEOUT_MS);
|
|
4679
|
+
const child = spawn3(command, args, {
|
|
4680
|
+
stdio: ["pipe", "pipe", "pipe"]
|
|
4681
|
+
});
|
|
4682
|
+
let responded = false;
|
|
4683
|
+
child.stdout?.on("data", () => {
|
|
4684
|
+
if (!responded) {
|
|
4685
|
+
responded = true;
|
|
4686
|
+
clearTimeout(timer);
|
|
4687
|
+
child.kill("SIGTERM");
|
|
4688
|
+
resolve("healthy");
|
|
4689
|
+
}
|
|
4690
|
+
});
|
|
4691
|
+
child.on("error", () => {
|
|
4692
|
+
clearTimeout(timer);
|
|
4693
|
+
resolve("unhealthy");
|
|
4694
|
+
});
|
|
4695
|
+
child.on("close", (code) => {
|
|
4696
|
+
if (!responded) {
|
|
4697
|
+
clearTimeout(timer);
|
|
4698
|
+
resolve(code === 0 ? "healthy" : "unhealthy");
|
|
4699
|
+
}
|
|
4700
|
+
});
|
|
4701
|
+
const initRequest = JSON.stringify({
|
|
4702
|
+
jsonrpc: "2.0",
|
|
4703
|
+
id: 1,
|
|
4704
|
+
method: "initialize",
|
|
4705
|
+
params: { protocolVersion: "2024-11-05", capabilities: {}, clientInfo: { name: "cc-claw-health", version: "1.0" } }
|
|
4706
|
+
});
|
|
4707
|
+
child.stdin?.write(initRequest + "\n");
|
|
4708
|
+
child.stdin?.end();
|
|
4709
|
+
});
|
|
4710
|
+
}
|
|
4711
|
+
async function checkHttpHealth(url) {
|
|
4712
|
+
try {
|
|
4713
|
+
const controller = new AbortController();
|
|
4714
|
+
const timer = setTimeout(() => controller.abort(), CHECK_TIMEOUT_MS);
|
|
4715
|
+
const res = await fetch(url, { signal: controller.signal });
|
|
4716
|
+
clearTimeout(timer);
|
|
4717
|
+
return res.ok ? "healthy" : "unhealthy";
|
|
4718
|
+
} catch {
|
|
4719
|
+
return "unhealthy";
|
|
4720
|
+
}
|
|
4721
|
+
}
|
|
4722
|
+
async function runHealthChecks(db3) {
|
|
4723
|
+
const mcps2 = listMcpServers(db3);
|
|
4724
|
+
const sorted = mcps2.sort((a, b) => {
|
|
4725
|
+
const aTime = a.lastHealthCheck ?? "0";
|
|
4726
|
+
const bTime = b.lastHealthCheck ?? "0";
|
|
4727
|
+
return aTime < bTime ? -1 : aTime > bTime ? 1 : 0;
|
|
4728
|
+
});
|
|
4729
|
+
const batch = sorted.slice(0, MAX_CHECKS_PER_CYCLE);
|
|
4730
|
+
for (const mcp of batch) {
|
|
4731
|
+
let status = "unhealthy";
|
|
4732
|
+
try {
|
|
4733
|
+
if (mcp.transport === "stdio" && mcp.command) {
|
|
4734
|
+
const args = mcp.args ? JSON.parse(mcp.args) : [];
|
|
4735
|
+
status = await checkStdioHealth(mcp.command, args);
|
|
4736
|
+
} else if ((mcp.transport === "sse" || mcp.transport === "streamable-http") && mcp.url) {
|
|
4737
|
+
status = await checkHttpHealth(mcp.url);
|
|
4738
|
+
} else {
|
|
4739
|
+
status = "unknown";
|
|
4740
|
+
}
|
|
4741
|
+
} catch {
|
|
4742
|
+
status = "unhealthy";
|
|
4743
|
+
}
|
|
4744
|
+
updateMcpHealth(db3, mcp.name, status);
|
|
4745
|
+
}
|
|
4746
|
+
}
|
|
4747
|
+
function startHealthMonitor(db3) {
|
|
4748
|
+
if (healthTimer) return;
|
|
4749
|
+
healthTimer = setInterval(() => {
|
|
4750
|
+
runHealthChecks(db3).catch((err) => warn("[mcp-health] Check failed:", err));
|
|
4751
|
+
}, CHECK_INTERVAL_MS);
|
|
4752
|
+
setTimeout(() => runHealthChecks(db3).catch(() => {
|
|
4753
|
+
}), 3e4);
|
|
4754
|
+
log("[mcp-health] Monitor started (every 5m, max 10 per cycle)");
|
|
4755
|
+
}
|
|
4756
|
+
function stopHealthMonitor() {
|
|
4757
|
+
if (healthTimer) {
|
|
4758
|
+
clearInterval(healthTimer);
|
|
4759
|
+
healthTimer = null;
|
|
4760
|
+
}
|
|
4761
|
+
}
|
|
4762
|
+
var CHECK_INTERVAL_MS, CHECK_TIMEOUT_MS, MAX_CHECKS_PER_CYCLE, healthTimer;
|
|
4763
|
+
var init_health = __esm({
|
|
4764
|
+
"src/mcps/health.ts"() {
|
|
4765
|
+
"use strict";
|
|
4766
|
+
init_store2();
|
|
4767
|
+
init_log();
|
|
4768
|
+
CHECK_INTERVAL_MS = 5 * 60 * 1e3;
|
|
4769
|
+
CHECK_TIMEOUT_MS = 1e4;
|
|
4770
|
+
MAX_CHECKS_PER_CYCLE = 10;
|
|
4771
|
+
healthTimer = null;
|
|
4476
4772
|
}
|
|
4477
4773
|
});
|
|
4478
4774
|
|
|
@@ -4548,7 +4844,7 @@ function startDashboard() {
|
|
|
4548
4844
|
return jsonResponse(res, { error: "Forbidden: sub-agent tokens cannot access this endpoint" }, 403);
|
|
4549
4845
|
}
|
|
4550
4846
|
if (url.pathname === "/api/health") {
|
|
4551
|
-
return jsonResponse(res, { status: "ok", uptime: process.uptime() });
|
|
4847
|
+
return jsonResponse(res, { status: "ok", version: VERSION, uptime: process.uptime() });
|
|
4552
4848
|
}
|
|
4553
4849
|
if (url.pathname === "/api/jobs") {
|
|
4554
4850
|
return jsonResponse(res, listJobs());
|
|
@@ -4582,10 +4878,71 @@ function startDashboard() {
|
|
|
4582
4878
|
}
|
|
4583
4879
|
return jsonResponse(res, tasks);
|
|
4584
4880
|
}
|
|
4585
|
-
if (url.pathname === "/api/mcps") {
|
|
4881
|
+
if (url.pathname === "/api/mcps" && req.method === "GET") {
|
|
4586
4882
|
const db3 = getDb();
|
|
4587
4883
|
return jsonResponse(res, listMcpServers(db3));
|
|
4588
4884
|
}
|
|
4885
|
+
if (url.pathname === "/api/mcps/sync" && req.method === "POST") {
|
|
4886
|
+
try {
|
|
4887
|
+
const { syncMcps: syncMcps2 } = await Promise.resolve().then(() => (init_registry2(), registry_exports2));
|
|
4888
|
+
const { getAllRunners: getAllRunners2 } = await Promise.resolve().then(() => (init_registry(), registry_exports));
|
|
4889
|
+
const result = await syncMcps2(getDb(), getAllRunners2());
|
|
4890
|
+
return jsonResponse(res, result);
|
|
4891
|
+
} catch (err) {
|
|
4892
|
+
return jsonResponse(res, { error: errorMessage(err) }, 400);
|
|
4893
|
+
}
|
|
4894
|
+
}
|
|
4895
|
+
if (url.pathname === "/api/mcps/import" && req.method === "POST") {
|
|
4896
|
+
try {
|
|
4897
|
+
const { importMcpsFromBackends: importMcpsFromBackends2 } = await Promise.resolve().then(() => (init_registry2(), registry_exports2));
|
|
4898
|
+
const { getAllRunners: getAllRunners2 } = await Promise.resolve().then(() => (init_registry(), registry_exports));
|
|
4899
|
+
const result = await importMcpsFromBackends2(getDb(), getAllRunners2());
|
|
4900
|
+
return jsonResponse(res, result);
|
|
4901
|
+
} catch (err) {
|
|
4902
|
+
return jsonResponse(res, { error: errorMessage(err) }, 400);
|
|
4903
|
+
}
|
|
4904
|
+
}
|
|
4905
|
+
if (url.pathname === "/api/mcps/health" && req.method === "POST") {
|
|
4906
|
+
try {
|
|
4907
|
+
const { runHealthChecks: runHealthChecks2 } = await Promise.resolve().then(() => (init_health(), health_exports));
|
|
4908
|
+
await runHealthChecks2(getDb());
|
|
4909
|
+
const mcps2 = listMcpServers(getDb());
|
|
4910
|
+
return jsonResponse(res, mcps2);
|
|
4911
|
+
} catch (err) {
|
|
4912
|
+
return jsonResponse(res, { error: errorMessage(err) }, 400);
|
|
4913
|
+
}
|
|
4914
|
+
}
|
|
4915
|
+
if (url.pathname === "/api/mcps" && req.method === "POST") {
|
|
4916
|
+
try {
|
|
4917
|
+
const body = JSON.parse(await readBody(req));
|
|
4918
|
+
const { addMcpServer: addMcpServer2 } = await Promise.resolve().then(() => (init_store2(), store_exports2));
|
|
4919
|
+
addMcpServer2(getDb(), body);
|
|
4920
|
+
return jsonResponse(res, { success: true });
|
|
4921
|
+
} catch (err) {
|
|
4922
|
+
return jsonResponse(res, { error: errorMessage(err) }, 400);
|
|
4923
|
+
}
|
|
4924
|
+
}
|
|
4925
|
+
if (url.pathname.startsWith("/api/mcps/") && url.pathname !== "/api/mcps/sync" && url.pathname !== "/api/mcps/import" && req.method === "PUT") {
|
|
4926
|
+
try {
|
|
4927
|
+
const name = decodeURIComponent(url.pathname.slice("/api/mcps/".length));
|
|
4928
|
+
const body = JSON.parse(await readBody(req));
|
|
4929
|
+
const { updateMcpServer: updateMcpServer2 } = await Promise.resolve().then(() => (init_store2(), store_exports2));
|
|
4930
|
+
updateMcpServer2(getDb(), name, body);
|
|
4931
|
+
return jsonResponse(res, { success: true });
|
|
4932
|
+
} catch (err) {
|
|
4933
|
+
return jsonResponse(res, { error: errorMessage(err) }, 400);
|
|
4934
|
+
}
|
|
4935
|
+
}
|
|
4936
|
+
if (url.pathname.startsWith("/api/mcps/") && url.pathname !== "/api/mcps/sync" && url.pathname !== "/api/mcps/import" && req.method === "DELETE") {
|
|
4937
|
+
try {
|
|
4938
|
+
const name = decodeURIComponent(url.pathname.slice("/api/mcps/".length));
|
|
4939
|
+
const { removeMcpServer: removeMcpServer2 } = await Promise.resolve().then(() => (init_store2(), store_exports2));
|
|
4940
|
+
removeMcpServer2(getDb(), name);
|
|
4941
|
+
return jsonResponse(res, { success: true });
|
|
4942
|
+
} catch (err) {
|
|
4943
|
+
return jsonResponse(res, { error: errorMessage(err) }, 400);
|
|
4944
|
+
}
|
|
4945
|
+
}
|
|
4589
4946
|
if (url.pathname === "/api/orchestrations") {
|
|
4590
4947
|
const db3 = getDb();
|
|
4591
4948
|
const orchestrations = db3.prepare(
|
|
@@ -4772,7 +5129,7 @@ function startDashboard() {
|
|
|
4772
5129
|
if (url.pathname === "/api/backend/set" && req.method === "POST") {
|
|
4773
5130
|
try {
|
|
4774
5131
|
const body = JSON.parse(await readBody(req));
|
|
4775
|
-
const { setBackend: setBackend2, clearSession: clearSession2, clearModel: clearModel2, clearThinkingLevel: clearThinkingLevel2 } = await Promise.resolve().then(() => (init_store4(),
|
|
5132
|
+
const { setBackend: setBackend2, clearSession: clearSession2, clearModel: clearModel2, clearThinkingLevel: clearThinkingLevel2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
|
|
4776
5133
|
const { summarizeSession: summarizeSession2 } = await Promise.resolve().then(() => (init_summarize(), summarize_exports));
|
|
4777
5134
|
summarizeSession2(body.chatId).catch(() => {
|
|
4778
5135
|
});
|
|
@@ -4789,7 +5146,7 @@ function startDashboard() {
|
|
|
4789
5146
|
if (url.pathname === "/api/model/set" && req.method === "POST") {
|
|
4790
5147
|
try {
|
|
4791
5148
|
const body = JSON.parse(await readBody(req));
|
|
4792
|
-
const { setModel: setModel2, clearThinkingLevel: clearThinkingLevel2, clearSession: clearSession2 } = await Promise.resolve().then(() => (init_store4(),
|
|
5149
|
+
const { setModel: setModel2, clearThinkingLevel: clearThinkingLevel2, clearSession: clearSession2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
|
|
4793
5150
|
setModel2(body.chatId, body.model);
|
|
4794
5151
|
clearThinkingLevel2(body.chatId);
|
|
4795
5152
|
clearSession2(body.chatId);
|
|
@@ -4802,7 +5159,7 @@ function startDashboard() {
|
|
|
4802
5159
|
if (url.pathname === "/api/thinking/set" && req.method === "POST") {
|
|
4803
5160
|
try {
|
|
4804
5161
|
const body = JSON.parse(await readBody(req));
|
|
4805
|
-
const { setThinkingLevel: setThinkingLevel2 } = await Promise.resolve().then(() => (init_store4(),
|
|
5162
|
+
const { setThinkingLevel: setThinkingLevel2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
|
|
4806
5163
|
setThinkingLevel2(body.chatId, body.level);
|
|
4807
5164
|
logActivity(getDb(), { chatId: body.chatId, source: "cli", eventType: "config_changed", summary: `Thinking set to ${body.level}`, detail: { field: "thinking", value: body.level } });
|
|
4808
5165
|
return jsonResponse(res, { success: true });
|
|
@@ -4813,7 +5170,7 @@ function startDashboard() {
|
|
|
4813
5170
|
if (url.pathname === "/api/summarizer/set" && req.method === "POST") {
|
|
4814
5171
|
try {
|
|
4815
5172
|
const body = JSON.parse(await readBody(req));
|
|
4816
|
-
const { setSummarizer: setSummarizer2, clearSummarizer: clearSummarizer2 } = await Promise.resolve().then(() => (init_store4(),
|
|
5173
|
+
const { setSummarizer: setSummarizer2, clearSummarizer: clearSummarizer2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
|
|
4817
5174
|
if (body.value === "auto") {
|
|
4818
5175
|
clearSummarizer2(body.chatId);
|
|
4819
5176
|
} else if (body.value === "off") {
|
|
@@ -4830,7 +5187,7 @@ function startDashboard() {
|
|
|
4830
5187
|
if (url.pathname === "/api/session/new" && req.method === "POST") {
|
|
4831
5188
|
try {
|
|
4832
5189
|
const body = JSON.parse(await readBody(req));
|
|
4833
|
-
const { clearSession: clearSession2, setSessionStartedAt: setSessionStartedAt2 } = await Promise.resolve().then(() => (init_store4(),
|
|
5190
|
+
const { clearSession: clearSession2, setSessionStartedAt: setSessionStartedAt2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
|
|
4834
5191
|
const { summarizeSession: summarizeSession2 } = await Promise.resolve().then(() => (init_summarize(), summarize_exports));
|
|
4835
5192
|
await summarizeSession2(body.chatId);
|
|
4836
5193
|
clearSession2(body.chatId);
|
|
@@ -4848,7 +5205,7 @@ function startDashboard() {
|
|
|
4848
5205
|
return jsonResponse(res, { error: "message and chatId required" }, 400);
|
|
4849
5206
|
}
|
|
4850
5207
|
const { askAgent: askAgent2 } = await Promise.resolve().then(() => (init_agent(), agent_exports));
|
|
4851
|
-
const { getMode: getMode2, getCwd: getCwd2, getModel: getModel2, addUsage: addUsage2, getBackend: getBackend2 } = await Promise.resolve().then(() => (init_store4(),
|
|
5208
|
+
const { getMode: getMode2, getCwd: getCwd2, getModel: getModel2, addUsage: addUsage2, getBackend: getBackend2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
|
|
4852
5209
|
const { getAdapterForChat: getAdapterForChat2 } = await Promise.resolve().then(() => (init_backends(), backends_exports));
|
|
4853
5210
|
const chatId = body.chatId;
|
|
4854
5211
|
const mode = body.mode ?? getMode2(chatId);
|
|
@@ -4906,7 +5263,7 @@ data: ${JSON.stringify(data)}
|
|
|
4906
5263
|
if (url.pathname === "/api/memory/add" && req.method === "POST") {
|
|
4907
5264
|
try {
|
|
4908
5265
|
const body = JSON.parse(await readBody(req));
|
|
4909
|
-
const { saveMemoryWithEmbedding: saveMemoryWithEmbedding2 } = await Promise.resolve().then(() => (init_store4(),
|
|
5266
|
+
const { saveMemoryWithEmbedding: saveMemoryWithEmbedding2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
|
|
4910
5267
|
const id = saveMemoryWithEmbedding2(body.trigger, body.content, body.type ?? "semantic");
|
|
4911
5268
|
return jsonResponse(res, { success: true, id });
|
|
4912
5269
|
} catch (err) {
|
|
@@ -4916,7 +5273,7 @@ data: ${JSON.stringify(data)}
|
|
|
4916
5273
|
if (url.pathname === "/api/memory/forget" && req.method === "POST") {
|
|
4917
5274
|
try {
|
|
4918
5275
|
const body = JSON.parse(await readBody(req));
|
|
4919
|
-
const { forgetMemory: forgetMemory2 } = await Promise.resolve().then(() => (init_store4(),
|
|
5276
|
+
const { forgetMemory: forgetMemory2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
|
|
4920
5277
|
const count = forgetMemory2(body.keyword);
|
|
4921
5278
|
return jsonResponse(res, { success: true, count });
|
|
4922
5279
|
} catch (err) {
|
|
@@ -4926,7 +5283,7 @@ data: ${JSON.stringify(data)}
|
|
|
4926
5283
|
if (url.pathname === "/api/permissions/set" && req.method === "POST") {
|
|
4927
5284
|
try {
|
|
4928
5285
|
const body = JSON.parse(await readBody(req));
|
|
4929
|
-
const { setMode: setMode2 } = await Promise.resolve().then(() => (init_store4(),
|
|
5286
|
+
const { setMode: setMode2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
|
|
4930
5287
|
setMode2(body.chatId, body.mode);
|
|
4931
5288
|
logActivity(getDb(), { chatId: body.chatId, source: "cli", eventType: "config_changed", summary: `Permissions set to ${body.mode}`, detail: { field: "permissions", value: body.mode } });
|
|
4932
5289
|
return jsonResponse(res, { success: true });
|
|
@@ -4937,7 +5294,7 @@ data: ${JSON.stringify(data)}
|
|
|
4937
5294
|
if (url.pathname === "/api/tools/toggle" && req.method === "POST") {
|
|
4938
5295
|
try {
|
|
4939
5296
|
const body = JSON.parse(await readBody(req));
|
|
4940
|
-
const { toggleTool: toggleTool3 } = await Promise.resolve().then(() => (init_store4(),
|
|
5297
|
+
const { toggleTool: toggleTool3 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
|
|
4941
5298
|
if (body.enabled !== void 0) {
|
|
4942
5299
|
const db3 = getDb();
|
|
4943
5300
|
db3.prepare("INSERT OR REPLACE INTO chat_tools (chat_id, tool, enabled) VALUES (?, ?, ?)").run(body.chatId, body.tool, body.enabled ? 1 : 0);
|
|
@@ -4952,7 +5309,7 @@ data: ${JSON.stringify(data)}
|
|
|
4952
5309
|
if (url.pathname === "/api/tools/reset" && req.method === "POST") {
|
|
4953
5310
|
try {
|
|
4954
5311
|
const body = JSON.parse(await readBody(req));
|
|
4955
|
-
const { resetTools: resetTools2 } = await Promise.resolve().then(() => (init_store4(),
|
|
5312
|
+
const { resetTools: resetTools2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
|
|
4956
5313
|
resetTools2(body.chatId);
|
|
4957
5314
|
return jsonResponse(res, { success: true });
|
|
4958
5315
|
} catch (err) {
|
|
@@ -4962,7 +5319,7 @@ data: ${JSON.stringify(data)}
|
|
|
4962
5319
|
if (url.pathname === "/api/verbose/set" && req.method === "POST") {
|
|
4963
5320
|
try {
|
|
4964
5321
|
const body = JSON.parse(await readBody(req));
|
|
4965
|
-
const { setVerboseLevel: setVerboseLevel2 } = await Promise.resolve().then(() => (init_store4(),
|
|
5322
|
+
const { setVerboseLevel: setVerboseLevel2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
|
|
4966
5323
|
setVerboseLevel2(body.chatId, body.level);
|
|
4967
5324
|
return jsonResponse(res, { success: true });
|
|
4968
5325
|
} catch (err) {
|
|
@@ -4982,7 +5339,7 @@ data: ${JSON.stringify(data)}
|
|
|
4982
5339
|
if (url.pathname === "/api/cwd/set" && req.method === "POST") {
|
|
4983
5340
|
try {
|
|
4984
5341
|
const body = JSON.parse(await readBody(req));
|
|
4985
|
-
const { setCwd: setCwd2, clearSession: clearSession2 } = await Promise.resolve().then(() => (init_store4(),
|
|
5342
|
+
const { setCwd: setCwd2, clearSession: clearSession2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
|
|
4986
5343
|
setCwd2(body.chatId, body.cwd);
|
|
4987
5344
|
clearSession2(body.chatId);
|
|
4988
5345
|
logActivity(getDb(), { chatId: body.chatId, source: "cli", eventType: "config_changed", summary: `Working directory set to ${body.cwd}`, detail: { field: "cwd", value: body.cwd } });
|
|
@@ -4994,7 +5351,7 @@ data: ${JSON.stringify(data)}
|
|
|
4994
5351
|
if (url.pathname === "/api/cwd/clear" && req.method === "POST") {
|
|
4995
5352
|
try {
|
|
4996
5353
|
const body = JSON.parse(await readBody(req));
|
|
4997
|
-
const { clearCwd: clearCwd2 } = await Promise.resolve().then(() => (init_store4(),
|
|
5354
|
+
const { clearCwd: clearCwd2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
|
|
4998
5355
|
clearCwd2(body.chatId);
|
|
4999
5356
|
return jsonResponse(res, { success: true });
|
|
5000
5357
|
} catch (err) {
|
|
@@ -5004,7 +5361,7 @@ data: ${JSON.stringify(data)}
|
|
|
5004
5361
|
if (url.pathname === "/api/heartbeat/set" && req.method === "POST") {
|
|
5005
5362
|
try {
|
|
5006
5363
|
const body = JSON.parse(await readBody(req));
|
|
5007
|
-
const { setHeartbeatConfig: setHeartbeatConfig3 } = await Promise.resolve().then(() => (init_store4(),
|
|
5364
|
+
const { setHeartbeatConfig: setHeartbeatConfig3 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
|
|
5008
5365
|
setHeartbeatConfig3(body.chatId, body);
|
|
5009
5366
|
return jsonResponse(res, { success: true });
|
|
5010
5367
|
} catch (err) {
|
|
@@ -5014,7 +5371,7 @@ data: ${JSON.stringify(data)}
|
|
|
5014
5371
|
if (url.pathname === "/api/limits/set" && req.method === "POST") {
|
|
5015
5372
|
try {
|
|
5016
5373
|
const body = JSON.parse(await readBody(req));
|
|
5017
|
-
const { setBackendLimit: setBackendLimit2 } = await Promise.resolve().then(() => (init_store4(),
|
|
5374
|
+
const { setBackendLimit: setBackendLimit2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
|
|
5018
5375
|
setBackendLimit2(body.backend, body.window, body.maxInputTokens);
|
|
5019
5376
|
return jsonResponse(res, { success: true });
|
|
5020
5377
|
} catch (err) {
|
|
@@ -5024,7 +5381,7 @@ data: ${JSON.stringify(data)}
|
|
|
5024
5381
|
if (url.pathname === "/api/limits/clear" && req.method === "POST") {
|
|
5025
5382
|
try {
|
|
5026
5383
|
const body = JSON.parse(await readBody(req));
|
|
5027
|
-
const { clearBackendLimit: clearBackendLimit2 } = await Promise.resolve().then(() => (init_store4(),
|
|
5384
|
+
const { clearBackendLimit: clearBackendLimit2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
|
|
5028
5385
|
clearBackendLimit2(body.backend, body.window);
|
|
5029
5386
|
return jsonResponse(res, { success: true });
|
|
5030
5387
|
} catch (err) {
|
|
@@ -5034,7 +5391,7 @@ data: ${JSON.stringify(data)}
|
|
|
5034
5391
|
if (url.pathname === "/api/chats/alias" && req.method === "POST") {
|
|
5035
5392
|
try {
|
|
5036
5393
|
const body = JSON.parse(await readBody(req));
|
|
5037
|
-
const { setChatAlias: setChatAlias2 } = await Promise.resolve().then(() => (init_store4(),
|
|
5394
|
+
const { setChatAlias: setChatAlias2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
|
|
5038
5395
|
setChatAlias2(body.alias, body.chatId);
|
|
5039
5396
|
return jsonResponse(res, { success: true });
|
|
5040
5397
|
} catch (err) {
|
|
@@ -5044,7 +5401,7 @@ data: ${JSON.stringify(data)}
|
|
|
5044
5401
|
if (url.pathname === "/api/chats/remove-alias" && req.method === "POST") {
|
|
5045
5402
|
try {
|
|
5046
5403
|
const body = JSON.parse(await readBody(req));
|
|
5047
|
-
const { removeChatAlias: removeChatAlias2 } = await Promise.resolve().then(() => (init_store4(),
|
|
5404
|
+
const { removeChatAlias: removeChatAlias2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
|
|
5048
5405
|
const removed = removeChatAlias2(body.alias);
|
|
5049
5406
|
return jsonResponse(res, { success: removed });
|
|
5050
5407
|
} catch (err) {
|
|
@@ -5067,33 +5424,33 @@ data: ${JSON.stringify(data)}
|
|
|
5067
5424
|
verbose: "/api/verbose/set"
|
|
5068
5425
|
};
|
|
5069
5426
|
if (body.key === "cwd") {
|
|
5070
|
-
const { setCwd: setCwd2 } = await Promise.resolve().then(() => (init_store4(),
|
|
5427
|
+
const { setCwd: setCwd2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
|
|
5071
5428
|
setCwd2(body.chatId, body.value);
|
|
5072
5429
|
} else if (body.key === "voice") {
|
|
5073
5430
|
const db3 = getDb();
|
|
5074
5431
|
db3.prepare("INSERT OR REPLACE INTO chat_voice (chat_id, enabled) VALUES (?, ?)").run(body.chatId, body.value === "on" || body.value === "1" ? 1 : 0);
|
|
5075
5432
|
} else if (body.key === "backend") {
|
|
5076
|
-
const { setBackend: setBackend2, clearSession: clearSession2, clearModel: clearModel2, clearThinkingLevel: clearThinkingLevel2 } = await Promise.resolve().then(() => (init_store4(),
|
|
5433
|
+
const { setBackend: setBackend2, clearSession: clearSession2, clearModel: clearModel2, clearThinkingLevel: clearThinkingLevel2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
|
|
5077
5434
|
clearSession2(body.chatId);
|
|
5078
5435
|
clearModel2(body.chatId);
|
|
5079
5436
|
clearThinkingLevel2(body.chatId);
|
|
5080
5437
|
setBackend2(body.chatId, body.value);
|
|
5081
5438
|
} else if (body.key === "model") {
|
|
5082
|
-
const { setModel: setModel2, clearThinkingLevel: clearThinkingLevel2, clearSession: clearSession2 } = await Promise.resolve().then(() => (init_store4(),
|
|
5439
|
+
const { setModel: setModel2, clearThinkingLevel: clearThinkingLevel2, clearSession: clearSession2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
|
|
5083
5440
|
setModel2(body.chatId, body.value);
|
|
5084
5441
|
clearThinkingLevel2(body.chatId);
|
|
5085
5442
|
clearSession2(body.chatId);
|
|
5086
5443
|
} else if (body.key === "thinking") {
|
|
5087
|
-
const { setThinkingLevel: setThinkingLevel2 } = await Promise.resolve().then(() => (init_store4(),
|
|
5444
|
+
const { setThinkingLevel: setThinkingLevel2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
|
|
5088
5445
|
setThinkingLevel2(body.chatId, body.value);
|
|
5089
5446
|
} else if (body.key === "mode") {
|
|
5090
|
-
const { setMode: setMode2 } = await Promise.resolve().then(() => (init_store4(),
|
|
5447
|
+
const { setMode: setMode2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
|
|
5091
5448
|
setMode2(body.chatId, body.value);
|
|
5092
5449
|
} else if (body.key === "verbose") {
|
|
5093
|
-
const { setVerboseLevel: setVerboseLevel2 } = await Promise.resolve().then(() => (init_store4(),
|
|
5450
|
+
const { setVerboseLevel: setVerboseLevel2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
|
|
5094
5451
|
setVerboseLevel2(body.chatId, body.value);
|
|
5095
5452
|
} else if (body.key === "summarizer") {
|
|
5096
|
-
const { setSummarizer: setSummarizer2, clearSummarizer: clearSummarizer2 } = await Promise.resolve().then(() => (init_store4(),
|
|
5453
|
+
const { setSummarizer: setSummarizer2, clearSummarizer: clearSummarizer2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
|
|
5097
5454
|
if (body.value === "auto") clearSummarizer2(body.chatId);
|
|
5098
5455
|
else if (body.value === "off") setSummarizer2(body.chatId, "off", null);
|
|
5099
5456
|
else {
|
|
@@ -5181,6 +5538,7 @@ var init_server = __esm({
|
|
|
5181
5538
|
init_registry();
|
|
5182
5539
|
init_registry2();
|
|
5183
5540
|
init_log();
|
|
5541
|
+
init_version();
|
|
5184
5542
|
init_store3();
|
|
5185
5543
|
PORT = parseInt(process.env.DASHBOARD_PORT ?? "3141", 10);
|
|
5186
5544
|
DASHBOARD_TOKEN = process.env.DASHBOARD_TOKEN || randomBytes(32).toString("hex");
|
|
@@ -5306,7 +5664,7 @@ __export(agent_exports, {
|
|
|
5306
5664
|
isChatBusy: () => isChatBusy,
|
|
5307
5665
|
stopAgent: () => stopAgent
|
|
5308
5666
|
});
|
|
5309
|
-
import { spawn as
|
|
5667
|
+
import { spawn as spawn4 } from "child_process";
|
|
5310
5668
|
import { createInterface as createInterface3 } from "readline";
|
|
5311
5669
|
import { dirname as dirname2 } from "path";
|
|
5312
5670
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
@@ -5344,7 +5702,7 @@ function spawnQuery(adapter, config2, model2, cancelState, onStream, onToolActio
|
|
|
5344
5702
|
const env = adapter.getEnv(thinkingConfig?.envOverrides);
|
|
5345
5703
|
const finalArgs = thinkingConfig?.extraArgs ? [...config2.args, ...thinkingConfig.extraArgs] : config2.args;
|
|
5346
5704
|
log(`[agent:spawn] backend=${adapter.id} exe=${config2.executable} model=${model2} cwd=${config2.cwd ?? "(inherited)"}`);
|
|
5347
|
-
const proc =
|
|
5705
|
+
const proc = spawn4(config2.executable, finalArgs, {
|
|
5348
5706
|
env,
|
|
5349
5707
|
stdio: ["ignore", "pipe", "pipe"],
|
|
5350
5708
|
...config2.cwd ? { cwd: config2.cwd } : {}
|
|
@@ -5786,14 +6144,14 @@ var init_retry = __esm({
|
|
|
5786
6144
|
});
|
|
5787
6145
|
|
|
5788
6146
|
// src/scheduler/health.ts
|
|
5789
|
-
function
|
|
6147
|
+
function startHealthMonitor2() {
|
|
5790
6148
|
lastHeartbeat = /* @__PURE__ */ new Date();
|
|
5791
6149
|
heartbeatTimer = setInterval(() => {
|
|
5792
6150
|
lastHeartbeat = /* @__PURE__ */ new Date();
|
|
5793
6151
|
log(`[health] Scheduler heartbeat at ${lastHeartbeat.toISOString()}`);
|
|
5794
6152
|
}, HEARTBEAT_INTERVAL_MS);
|
|
5795
6153
|
}
|
|
5796
|
-
function
|
|
6154
|
+
function stopHealthMonitor2() {
|
|
5797
6155
|
if (heartbeatTimer) {
|
|
5798
6156
|
clearInterval(heartbeatTimer);
|
|
5799
6157
|
heartbeatTimer = null;
|
|
@@ -5842,7 +6200,7 @@ function computeStaggerMs(jobId, cronExpr) {
|
|
|
5842
6200
|
return jobId * 7919 % maxStagger;
|
|
5843
6201
|
}
|
|
5844
6202
|
var lastHeartbeat, heartbeatTimer, HEARTBEAT_INTERVAL_MS;
|
|
5845
|
-
var
|
|
6203
|
+
var init_health2 = __esm({
|
|
5846
6204
|
"src/scheduler/health.ts"() {
|
|
5847
6205
|
"use strict";
|
|
5848
6206
|
init_store4();
|
|
@@ -5872,9 +6230,9 @@ __export(cron_exports, {
|
|
|
5872
6230
|
import { Cron } from "croner";
|
|
5873
6231
|
function initScheduler(channelReg) {
|
|
5874
6232
|
setChannelRegistry(channelReg);
|
|
5875
|
-
|
|
6233
|
+
startHealthMonitor2();
|
|
5876
6234
|
try {
|
|
5877
|
-
const { getDb: getDb2 } = (init_store4(), __toCommonJS(
|
|
6235
|
+
const { getDb: getDb2 } = (init_store4(), __toCommonJS(store_exports3));
|
|
5878
6236
|
const db3 = getDb2();
|
|
5879
6237
|
const orphaned = db3.prepare(
|
|
5880
6238
|
"UPDATE job_runs SET status = 'failed', finished_at = datetime('now'), error = 'Process interrupted' WHERE status = 'running'"
|
|
@@ -6109,7 +6467,7 @@ function shutdownScheduler() {
|
|
|
6109
6467
|
for (const [id] of activeTimers) {
|
|
6110
6468
|
stopJobTimer(id);
|
|
6111
6469
|
}
|
|
6112
|
-
|
|
6470
|
+
stopHealthMonitor2();
|
|
6113
6471
|
log("[scheduler] Shutdown complete");
|
|
6114
6472
|
}
|
|
6115
6473
|
var activeTimers, runningJobs;
|
|
@@ -6122,7 +6480,7 @@ var init_cron = __esm({
|
|
|
6122
6480
|
init_log();
|
|
6123
6481
|
init_delivery();
|
|
6124
6482
|
init_retry();
|
|
6125
|
-
|
|
6483
|
+
init_health2();
|
|
6126
6484
|
activeTimers = /* @__PURE__ */ new Map();
|
|
6127
6485
|
runningJobs = /* @__PURE__ */ new Set();
|
|
6128
6486
|
}
|
|
@@ -6130,61 +6488,43 @@ var init_cron = __esm({
|
|
|
6130
6488
|
|
|
6131
6489
|
// src/agents/runners/wrap-backend.ts
|
|
6132
6490
|
import { join as join8 } from "path";
|
|
6133
|
-
import { writeFileSync as writeFileSync4, unlinkSync as unlinkSync2, mkdirSync as mkdirSync4 } from "fs";
|
|
6134
6491
|
function buildMcpCommands(backendId) {
|
|
6135
6492
|
const exe = backendId;
|
|
6136
6493
|
return {
|
|
6137
6494
|
add: (server) => {
|
|
6138
6495
|
const cmd = [exe, "mcp", "add"];
|
|
6139
|
-
if (backendId === "
|
|
6140
|
-
|
|
6141
|
-
const wrapperPath = writeEnvWrapper(server);
|
|
6142
|
-
cmd.push(server.name, "--", "sh", wrapperPath);
|
|
6143
|
-
return cmd;
|
|
6144
|
-
}
|
|
6145
|
-
cmd.push(server.name);
|
|
6146
|
-
if (server.transport === "stdio" && server.command) {
|
|
6147
|
-
cmd.push("--", server.command, ...server.args ?? []);
|
|
6148
|
-
}
|
|
6149
|
-
return cmd;
|
|
6496
|
+
if (backendId === "gemini") {
|
|
6497
|
+
cmd.push("-s", "user");
|
|
6150
6498
|
}
|
|
6151
|
-
if (server.env) {
|
|
6499
|
+
if (backendId !== "codex" && server.env) {
|
|
6152
6500
|
for (const [k, v] of Object.entries(server.env)) {
|
|
6153
6501
|
cmd.push("-e", `${k}=${v}`);
|
|
6154
6502
|
}
|
|
6155
6503
|
}
|
|
6156
|
-
cmd.push(server.name);
|
|
6157
6504
|
if (server.transport === "stdio" && server.command) {
|
|
6158
|
-
|
|
6159
|
-
|
|
6160
|
-
} else {
|
|
6505
|
+
cmd.push(server.name);
|
|
6506
|
+
if (backendId === "gemini") {
|
|
6161
6507
|
cmd.push(server.command, ...server.args ?? []);
|
|
6508
|
+
} else {
|
|
6509
|
+
cmd.push("--", server.command, ...server.args ?? []);
|
|
6162
6510
|
}
|
|
6511
|
+
} else if ((server.transport === "sse" || server.transport === "streamable-http") && server.url) {
|
|
6512
|
+
const transportFlag = server.transport === "streamable-http" ? "http" : server.transport;
|
|
6513
|
+
cmd.push("--transport", transportFlag, server.name, server.url);
|
|
6514
|
+
} else {
|
|
6515
|
+
cmd.push(server.name);
|
|
6163
6516
|
}
|
|
6164
6517
|
return cmd;
|
|
6165
6518
|
},
|
|
6166
6519
|
remove: (name) => {
|
|
6167
|
-
|
|
6168
|
-
|
|
6169
|
-
} catch {
|
|
6520
|
+
if (backendId === "gemini") {
|
|
6521
|
+
return [exe, "mcp", "remove", "-s", "user", name];
|
|
6170
6522
|
}
|
|
6171
6523
|
return [exe, "mcp", "remove", name];
|
|
6172
6524
|
},
|
|
6173
6525
|
list: () => [exe, "mcp", "list"]
|
|
6174
6526
|
};
|
|
6175
6527
|
}
|
|
6176
|
-
function writeEnvWrapper(server) {
|
|
6177
|
-
const dir = join8(CC_CLAW_HOME, "mcp-configs");
|
|
6178
|
-
mkdirSync4(dir, { recursive: true, mode: 448 });
|
|
6179
|
-
const lines = ["#!/bin/sh"];
|
|
6180
|
-
for (const [k, v] of Object.entries(server.env ?? {})) {
|
|
6181
|
-
lines.push(`export ${k}='${v.replace(/'/g, "'\\''")}'`);
|
|
6182
|
-
}
|
|
6183
|
-
lines.push(`exec ${server.command} ${(server.args ?? []).map((a) => `'${a.replace(/'/g, "'\\''")}'`).join(" ")}`);
|
|
6184
|
-
const path = join8(dir, `wrapper-${server.name}.sh`);
|
|
6185
|
-
writeFileSync4(path, lines.join("\n") + "\n", { mode: 448 });
|
|
6186
|
-
return path;
|
|
6187
|
-
}
|
|
6188
6528
|
function wrapBackendAdapter(adapter) {
|
|
6189
6529
|
const caps = BACKEND_CAPABILITIES[adapter.id] ?? {};
|
|
6190
6530
|
const mcpCmds = buildMcpCommands(adapter.id);
|
|
@@ -6219,11 +6559,23 @@ function wrapBackendAdapter(adapter) {
|
|
|
6219
6559
|
getMcpListCommand: () => mcpCmds.list(),
|
|
6220
6560
|
prepareMcpInjection(server) {
|
|
6221
6561
|
const method = caps.mcpInjection ?? "add-remove";
|
|
6222
|
-
if (method
|
|
6223
|
-
|
|
6224
|
-
|
|
6562
|
+
if (method !== "config-file") return [];
|
|
6563
|
+
if (adapter.id === "codex") {
|
|
6564
|
+
const safeName = server.name.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
6565
|
+
const args = [];
|
|
6566
|
+
args.push("-c", `mcp_servers.${safeName}.command="${server.command}"`);
|
|
6567
|
+
if (server.args?.length) {
|
|
6568
|
+
args.push("-c", `mcp_servers.${safeName}.args=${JSON.stringify(server.args)}`);
|
|
6569
|
+
}
|
|
6570
|
+
if (server.env) {
|
|
6571
|
+
for (const [k, v] of Object.entries(server.env)) {
|
|
6572
|
+
args.push("-c", `mcp_servers.${safeName}.env.${k}="${v}"`);
|
|
6573
|
+
}
|
|
6574
|
+
}
|
|
6575
|
+
return args;
|
|
6225
6576
|
}
|
|
6226
|
-
|
|
6577
|
+
const configPath = writeMcpConfigFile(server);
|
|
6578
|
+
return ["--mcp-config", configPath];
|
|
6227
6579
|
},
|
|
6228
6580
|
getSkillPath: () => join8(SKILLS_PATH, `agent-${adapter.id}.md`)
|
|
6229
6581
|
};
|
|
@@ -6260,14 +6612,14 @@ var init_wrap_backend = __esm({
|
|
|
6260
6612
|
supportsPermissionModes: true,
|
|
6261
6613
|
maxConcurrentSessions: 4,
|
|
6262
6614
|
specialties: ["code-generation", "refactoring"],
|
|
6263
|
-
mcpInjection: "
|
|
6615
|
+
mcpInjection: "config-file"
|
|
6264
6616
|
}
|
|
6265
6617
|
};
|
|
6266
6618
|
}
|
|
6267
6619
|
});
|
|
6268
6620
|
|
|
6269
6621
|
// src/agents/runners/config-loader.ts
|
|
6270
|
-
import { readFileSync as readFileSync6, readdirSync as readdirSync4, existsSync as existsSync9, mkdirSync as
|
|
6622
|
+
import { readFileSync as readFileSync6, readdirSync as readdirSync4, existsSync as existsSync9, mkdirSync as mkdirSync4, watchFile, unwatchFile } from "fs";
|
|
6271
6623
|
import { join as join9 } from "path";
|
|
6272
6624
|
import { execFileSync } from "child_process";
|
|
6273
6625
|
function resolveExecutable(config2) {
|
|
@@ -6418,7 +6770,7 @@ function loadRunnerConfig(filePath) {
|
|
|
6418
6770
|
}
|
|
6419
6771
|
function loadAllRunnerConfigs() {
|
|
6420
6772
|
if (!existsSync9(RUNNERS_PATH)) {
|
|
6421
|
-
|
|
6773
|
+
mkdirSync4(RUNNERS_PATH, { recursive: true });
|
|
6422
6774
|
return [];
|
|
6423
6775
|
}
|
|
6424
6776
|
const files = readdirSync4(RUNNERS_PATH).filter((f) => f.endsWith(".json"));
|
|
@@ -7033,13 +7385,13 @@ __export(discover_exports, {
|
|
|
7033
7385
|
});
|
|
7034
7386
|
import { readdir, readFile as readFile2 } from "fs/promises";
|
|
7035
7387
|
import { createHash } from "crypto";
|
|
7036
|
-
import { homedir as
|
|
7388
|
+
import { homedir as homedir3 } from "os";
|
|
7037
7389
|
import { join as join10 } from "path";
|
|
7038
7390
|
async function discoverAllSkills() {
|
|
7039
7391
|
const rawSkills = [];
|
|
7040
7392
|
rawSkills.push(...await scanSkillDir(SKILLS_PATH, "cc-claw"));
|
|
7041
7393
|
for (const backendId of getAllBackendIds()) {
|
|
7042
|
-
const dirs = BACKEND_SKILL_DIRS[backendId] ?? [join10(
|
|
7394
|
+
const dirs = BACKEND_SKILL_DIRS[backendId] ?? [join10(homedir3(), `.${backendId}`, "skills")];
|
|
7043
7395
|
for (const dir of dirs) {
|
|
7044
7396
|
rawSkills.push(...await scanSkillDir(dir, backendId));
|
|
7045
7397
|
}
|
|
@@ -7162,11 +7514,11 @@ var init_discover = __esm({
|
|
|
7162
7514
|
init_backends();
|
|
7163
7515
|
SKILL_FILE_CANDIDATES = ["SKILL.md", "skill.md"];
|
|
7164
7516
|
BACKEND_SKILL_DIRS = {
|
|
7165
|
-
claude: [join10(
|
|
7166
|
-
gemini: [join10(
|
|
7517
|
+
claude: [join10(homedir3(), ".claude", "skills")],
|
|
7518
|
+
gemini: [join10(homedir3(), ".gemini", "skills")],
|
|
7167
7519
|
codex: [
|
|
7168
|
-
join10(
|
|
7169
|
-
join10(
|
|
7520
|
+
join10(homedir3(), ".agents", "skills"),
|
|
7521
|
+
join10(homedir3(), ".codex", "skills")
|
|
7170
7522
|
]
|
|
7171
7523
|
};
|
|
7172
7524
|
}
|
|
@@ -7300,7 +7652,7 @@ var init_install = __esm({
|
|
|
7300
7652
|
});
|
|
7301
7653
|
|
|
7302
7654
|
// src/bootstrap/profile.ts
|
|
7303
|
-
import { readFileSync as readFileSync7, writeFileSync as
|
|
7655
|
+
import { readFileSync as readFileSync7, writeFileSync as writeFileSync4, existsSync as existsSync11 } from "fs";
|
|
7304
7656
|
import { join as join12 } from "path";
|
|
7305
7657
|
function hasActiveProfile(chatId) {
|
|
7306
7658
|
return activeProfiles.has(chatId);
|
|
@@ -7404,7 +7756,7 @@ async function finalizeProfile(chatId, state, channel) {
|
|
|
7404
7756
|
"<!-- Add any additional preferences below this line -->",
|
|
7405
7757
|
""
|
|
7406
7758
|
].join("\n");
|
|
7407
|
-
|
|
7759
|
+
writeFileSync4(USER_PATH3, content, "utf-8");
|
|
7408
7760
|
activeProfiles.delete(chatId);
|
|
7409
7761
|
log(`[profile] User profile saved for chat ${chatId}`);
|
|
7410
7762
|
await channel.sendText(
|
|
@@ -7437,7 +7789,7 @@ function appendToUserProfile(key, value) {
|
|
|
7437
7789
|
const updated = content.trimEnd() + `
|
|
7438
7790
|
${line}
|
|
7439
7791
|
`;
|
|
7440
|
-
|
|
7792
|
+
writeFileSync4(USER_PATH3, updated, "utf-8");
|
|
7441
7793
|
log(`[profile] Appended preference: ${key}=${value}`);
|
|
7442
7794
|
}
|
|
7443
7795
|
var USER_PATH3, activeProfiles;
|
|
@@ -7627,7 +7979,7 @@ var init_heartbeat = __esm({
|
|
|
7627
7979
|
init_agent();
|
|
7628
7980
|
init_store4();
|
|
7629
7981
|
init_backends();
|
|
7630
|
-
|
|
7982
|
+
init_health2();
|
|
7631
7983
|
init_log();
|
|
7632
7984
|
HEARTBEAT_MD_PATH = join13(WORKSPACE_PATH, "HEARTBEAT.md");
|
|
7633
7985
|
HEARTBEAT_OK = "HEARTBEAT_OK";
|
|
@@ -9579,8 +9931,8 @@ Use /skills to see it.`, "plain");
|
|
|
9579
9931
|
lines.push(` \u2705 <b>cc-claw</b> <i>Agent orchestrator (spawn, tasks, inbox)</i>`);
|
|
9580
9932
|
}
|
|
9581
9933
|
const { execFile: execFile5 } = await import("child_process");
|
|
9582
|
-
const { homedir:
|
|
9583
|
-
const discoveryCwd =
|
|
9934
|
+
const { homedir: homedir6 } = await import("os");
|
|
9935
|
+
const discoveryCwd = homedir6();
|
|
9584
9936
|
const runnerResults = await Promise.allSettled(
|
|
9585
9937
|
getAllRunners().map((runner) => {
|
|
9586
9938
|
const listCmd = runner.getMcpListCommand();
|
|
@@ -10428,7 +10780,7 @@ var init_router = __esm({
|
|
|
10428
10780
|
init_backends();
|
|
10429
10781
|
init_cron();
|
|
10430
10782
|
init_wizard();
|
|
10431
|
-
|
|
10783
|
+
init_health2();
|
|
10432
10784
|
init_video();
|
|
10433
10785
|
init_store();
|
|
10434
10786
|
init_orchestrator();
|
|
@@ -10735,7 +11087,7 @@ async function attemptReconnect(channel, handler) {
|
|
|
10735
11087
|
return false;
|
|
10736
11088
|
}
|
|
10737
11089
|
}
|
|
10738
|
-
function
|
|
11090
|
+
function startHealthMonitor3(channels, handler) {
|
|
10739
11091
|
registeredHandler = handler;
|
|
10740
11092
|
for (const ch of channels) {
|
|
10741
11093
|
trackChannel(ch);
|
|
@@ -10751,14 +11103,14 @@ function startHealthMonitor2(channels, handler) {
|
|
|
10751
11103
|
}, HEALTH_CHECK_INTERVAL_MS);
|
|
10752
11104
|
log(`[channel-health] Monitoring ${channels.length} channel(s)`);
|
|
10753
11105
|
}
|
|
10754
|
-
function
|
|
11106
|
+
function stopHealthMonitor3() {
|
|
10755
11107
|
if (healthInterval) {
|
|
10756
11108
|
clearInterval(healthInterval);
|
|
10757
11109
|
healthInterval = null;
|
|
10758
11110
|
}
|
|
10759
11111
|
}
|
|
10760
11112
|
var healthState, MAX_RECONNECT_ATTEMPTS, RECONNECT_BASE_MS, HEALTH_CHECK_INTERVAL_MS, healthInterval, registeredHandler;
|
|
10761
|
-
var
|
|
11113
|
+
var init_health3 = __esm({
|
|
10762
11114
|
"src/channels/health.ts"() {
|
|
10763
11115
|
"use strict";
|
|
10764
11116
|
init_log();
|
|
@@ -10777,15 +11129,15 @@ __export(ai_skill_exports, {
|
|
|
10777
11129
|
generateAiSkill: () => generateAiSkill,
|
|
10778
11130
|
installAiSkill: () => installAiSkill
|
|
10779
11131
|
});
|
|
10780
|
-
import { existsSync as existsSync14, writeFileSync as
|
|
11132
|
+
import { existsSync as existsSync14, writeFileSync as writeFileSync5, mkdirSync as mkdirSync5 } from "fs";
|
|
10781
11133
|
import { join as join15 } from "path";
|
|
10782
|
-
import { homedir as
|
|
11134
|
+
import { homedir as homedir4 } from "os";
|
|
10783
11135
|
function generateAiSkill() {
|
|
10784
11136
|
const version = VERSION;
|
|
10785
11137
|
let systemState = "";
|
|
10786
11138
|
if (existsSync14(DB_PATH)) {
|
|
10787
11139
|
try {
|
|
10788
|
-
const { openDatabaseReadOnly: openDatabaseReadOnly2 } = (init_store4(), __toCommonJS(
|
|
11140
|
+
const { openDatabaseReadOnly: openDatabaseReadOnly2 } = (init_store4(), __toCommonJS(store_exports3));
|
|
10789
11141
|
const readDb = openDatabaseReadOnly2();
|
|
10790
11142
|
const backendRow = readDb.prepare("SELECT backend FROM chat_backend LIMIT 1").get();
|
|
10791
11143
|
const modelRow = readDb.prepare("SELECT model FROM chat_model LIMIT 1").get();
|
|
@@ -11009,8 +11361,8 @@ function installAiSkill() {
|
|
|
11009
11361
|
const skillDir = join15(dir, "cc-claw-cli");
|
|
11010
11362
|
const skillPath = join15(skillDir, "SKILL.md");
|
|
11011
11363
|
try {
|
|
11012
|
-
|
|
11013
|
-
|
|
11364
|
+
mkdirSync5(skillDir, { recursive: true });
|
|
11365
|
+
writeFileSync5(skillPath, skill, "utf-8");
|
|
11014
11366
|
installed.push(skillPath);
|
|
11015
11367
|
} catch {
|
|
11016
11368
|
failed.push(skillPath);
|
|
@@ -11026,10 +11378,10 @@ var init_ai_skill = __esm({
|
|
|
11026
11378
|
init_paths();
|
|
11027
11379
|
init_version();
|
|
11028
11380
|
BACKEND_SKILL_DIRS2 = {
|
|
11029
|
-
"cc-claw": [join15(
|
|
11030
|
-
claude: [join15(
|
|
11031
|
-
gemini: [join15(
|
|
11032
|
-
codex: [join15(
|
|
11381
|
+
"cc-claw": [join15(homedir4(), ".cc-claw", "workspace", "skills")],
|
|
11382
|
+
claude: [join15(homedir4(), ".claude", "skills")],
|
|
11383
|
+
gemini: [join15(homedir4(), ".gemini", "skills")],
|
|
11384
|
+
codex: [join15(homedir4(), ".agents", "skills")]
|
|
11033
11385
|
};
|
|
11034
11386
|
}
|
|
11035
11387
|
});
|
|
@@ -11039,7 +11391,7 @@ var index_exports = {};
|
|
|
11039
11391
|
__export(index_exports, {
|
|
11040
11392
|
main: () => main
|
|
11041
11393
|
});
|
|
11042
|
-
import { mkdirSync as
|
|
11394
|
+
import { mkdirSync as mkdirSync6, existsSync as existsSync15, renameSync, statSync as statSync3 } from "fs";
|
|
11043
11395
|
import { join as join16 } from "path";
|
|
11044
11396
|
import dotenv from "dotenv";
|
|
11045
11397
|
function migrateLayout() {
|
|
@@ -11119,15 +11471,27 @@ async function main() {
|
|
|
11119
11471
|
startPersistedJobs();
|
|
11120
11472
|
initRunnerRegistry();
|
|
11121
11473
|
initOrchestrator();
|
|
11474
|
+
let notifyQueue = Promise.resolve();
|
|
11122
11475
|
setNotifyCallback((chatId, message) => {
|
|
11123
11476
|
const primaryChatId = (process.env.ALLOWED_CHAT_ID ?? "").split(",")[0]?.trim();
|
|
11124
11477
|
const targetChatId = primaryChatId || chatId;
|
|
11125
|
-
|
|
11126
|
-
|
|
11127
|
-
|
|
11128
|
-
|
|
11478
|
+
notifyQueue = notifyQueue.then(async () => {
|
|
11479
|
+
for (const ch of channelRegistry.list()) {
|
|
11480
|
+
await ch.sendText(targetChatId, `\u{1F916} ${message}`, "plain").catch(() => {
|
|
11481
|
+
});
|
|
11482
|
+
}
|
|
11483
|
+
await new Promise((r) => setTimeout(r, 300));
|
|
11484
|
+
});
|
|
11129
11485
|
});
|
|
11130
11486
|
log("[cc-claw] Agent orchestrator initialized");
|
|
11487
|
+
Promise.resolve().then(() => (init_registry2(), registry_exports2)).then(({ syncMcps: syncMcps2 }) => {
|
|
11488
|
+
Promise.resolve().then(() => (init_registry(), registry_exports)).then(({ getAllRunners: getAllRunners2 }) => {
|
|
11489
|
+
syncMcps2(getDb(), getAllRunners2()).catch((err) => {
|
|
11490
|
+
warn("[mcps] Sync failed:", err);
|
|
11491
|
+
});
|
|
11492
|
+
});
|
|
11493
|
+
}).catch(() => {
|
|
11494
|
+
});
|
|
11131
11495
|
log("[cc-claw] Scheduler initialized");
|
|
11132
11496
|
if (process.env.DASHBOARD_ENABLED === "1") {
|
|
11133
11497
|
startDashboard();
|
|
@@ -11137,18 +11501,22 @@ async function main() {
|
|
|
11137
11501
|
bootstrapSkills().catch((err) => error("[cc-claw] Skill bootstrap failed:", err));
|
|
11138
11502
|
try {
|
|
11139
11503
|
const { generateAiSkill: generateAiSkill2 } = await Promise.resolve().then(() => (init_ai_skill(), ai_skill_exports));
|
|
11140
|
-
const { writeFileSync:
|
|
11504
|
+
const { writeFileSync: writeFileSync8, mkdirSync: mkdirSync10 } = await import("fs");
|
|
11141
11505
|
const { join: join19 } = await import("path");
|
|
11142
11506
|
const skillDir = join19(SKILLS_PATH, "cc-claw-cli");
|
|
11143
|
-
|
|
11144
|
-
|
|
11507
|
+
mkdirSync10(skillDir, { recursive: true });
|
|
11508
|
+
writeFileSync8(join19(skillDir, "SKILL.md"), generateAiSkill2(), "utf-8");
|
|
11145
11509
|
log("[cc-claw] AI skill updated");
|
|
11146
11510
|
} catch {
|
|
11147
11511
|
}
|
|
11148
11512
|
migrateEmbeddings().catch((err) => error("[cc-claw] Embedding migration failed:", err));
|
|
11149
11513
|
initHeartbeat(channelRegistry);
|
|
11150
11514
|
startAllHeartbeats();
|
|
11151
|
-
|
|
11515
|
+
startHealthMonitor3(channelRegistry.list(), handleMessage);
|
|
11516
|
+
Promise.resolve().then(() => (init_health(), health_exports)).then(({ startHealthMonitor: startMcpHealthMonitor }) => {
|
|
11517
|
+
startMcpHealthMonitor(getDb());
|
|
11518
|
+
}).catch(() => {
|
|
11519
|
+
});
|
|
11152
11520
|
startMonitor({
|
|
11153
11521
|
onIdleDetected: (agent) => {
|
|
11154
11522
|
log(`[orchestrator] Agent ${agent.id.slice(0, 8)} idle \u2014 nudging`);
|
|
@@ -11159,7 +11527,7 @@ async function main() {
|
|
|
11159
11527
|
log(`[cc-claw] Received ${signal}, shutting down...`);
|
|
11160
11528
|
try {
|
|
11161
11529
|
stopAllHeartbeats();
|
|
11162
|
-
|
|
11530
|
+
stopHealthMonitor3();
|
|
11163
11531
|
stopMonitor();
|
|
11164
11532
|
shutdownOrchestrator();
|
|
11165
11533
|
shutdownScheduler();
|
|
@@ -11195,9 +11563,9 @@ var init_index = __esm({
|
|
|
11195
11563
|
init_heartbeat();
|
|
11196
11564
|
init_migrate_embeddings();
|
|
11197
11565
|
init_bootstrap2();
|
|
11198
|
-
|
|
11566
|
+
init_health3();
|
|
11199
11567
|
for (const dir of [CC_CLAW_HOME, DATA_PATH, LOGS_PATH, SKILLS_PATH, RUNNERS_PATH, AGENTS_PATH]) {
|
|
11200
|
-
if (!existsSync15(dir))
|
|
11568
|
+
if (!existsSync15(dir)) mkdirSync6(dir, { recursive: true });
|
|
11201
11569
|
}
|
|
11202
11570
|
migrateLayout();
|
|
11203
11571
|
if (existsSync15(ENV_PATH)) {
|
|
@@ -11221,9 +11589,9 @@ __export(service_exports, {
|
|
|
11221
11589
|
serviceStatus: () => serviceStatus,
|
|
11222
11590
|
uninstallService: () => uninstallService
|
|
11223
11591
|
});
|
|
11224
|
-
import { existsSync as existsSync16, mkdirSync as
|
|
11592
|
+
import { existsSync as existsSync16, mkdirSync as mkdirSync7, writeFileSync as writeFileSync6, unlinkSync as unlinkSync2 } from "fs";
|
|
11225
11593
|
import { execFileSync as execFileSync2, execSync as execSync5 } from "child_process";
|
|
11226
|
-
import { homedir as
|
|
11594
|
+
import { homedir as homedir5, platform } from "os";
|
|
11227
11595
|
import { join as join17, dirname as dirname4 } from "path";
|
|
11228
11596
|
function resolveExecutable2(name) {
|
|
11229
11597
|
try {
|
|
@@ -11234,7 +11602,7 @@ function resolveExecutable2(name) {
|
|
|
11234
11602
|
}
|
|
11235
11603
|
function getPathDirs() {
|
|
11236
11604
|
const nodeBin = dirname4(process.execPath);
|
|
11237
|
-
const home =
|
|
11605
|
+
const home = homedir5();
|
|
11238
11606
|
const dirs = /* @__PURE__ */ new Set([
|
|
11239
11607
|
nodeBin,
|
|
11240
11608
|
join17(home, ".local", "bin"),
|
|
@@ -11252,7 +11620,7 @@ function getPathDirs() {
|
|
|
11252
11620
|
function generatePlist() {
|
|
11253
11621
|
const ccClawBin = resolveExecutable2("cc-claw");
|
|
11254
11622
|
const pathDirs = getPathDirs();
|
|
11255
|
-
const home =
|
|
11623
|
+
const home = homedir5();
|
|
11256
11624
|
return `<?xml version="1.0" encoding="UTF-8"?>
|
|
11257
11625
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
11258
11626
|
<plist version="1.0">
|
|
@@ -11299,15 +11667,15 @@ function generatePlist() {
|
|
|
11299
11667
|
}
|
|
11300
11668
|
function installMacOS() {
|
|
11301
11669
|
const agentsDir = dirname4(PLIST_PATH);
|
|
11302
|
-
if (!existsSync16(agentsDir))
|
|
11303
|
-
if (!existsSync16(LOGS_PATH))
|
|
11670
|
+
if (!existsSync16(agentsDir)) mkdirSync7(agentsDir, { recursive: true });
|
|
11671
|
+
if (!existsSync16(LOGS_PATH)) mkdirSync7(LOGS_PATH, { recursive: true });
|
|
11304
11672
|
if (existsSync16(PLIST_PATH)) {
|
|
11305
11673
|
try {
|
|
11306
11674
|
execFileSync2("launchctl", ["unload", PLIST_PATH]);
|
|
11307
11675
|
} catch {
|
|
11308
11676
|
}
|
|
11309
11677
|
}
|
|
11310
|
-
|
|
11678
|
+
writeFileSync6(PLIST_PATH, generatePlist());
|
|
11311
11679
|
console.log(` Installed: ${PLIST_PATH}`);
|
|
11312
11680
|
execFileSync2("launchctl", ["load", PLIST_PATH]);
|
|
11313
11681
|
console.log(" Service loaded and starting.");
|
|
@@ -11321,7 +11689,7 @@ function uninstallMacOS() {
|
|
|
11321
11689
|
execFileSync2("launchctl", ["unload", PLIST_PATH]);
|
|
11322
11690
|
} catch {
|
|
11323
11691
|
}
|
|
11324
|
-
|
|
11692
|
+
unlinkSync2(PLIST_PATH);
|
|
11325
11693
|
console.log(" Service uninstalled.");
|
|
11326
11694
|
}
|
|
11327
11695
|
function statusMacOS() {
|
|
@@ -11357,16 +11725,16 @@ Restart=on-failure
|
|
|
11357
11725
|
RestartSec=10
|
|
11358
11726
|
WorkingDirectory=${CC_CLAW_HOME}
|
|
11359
11727
|
Environment=PATH=${pathDirs}
|
|
11360
|
-
Environment=HOME=${
|
|
11728
|
+
Environment=HOME=${homedir5()}
|
|
11361
11729
|
|
|
11362
11730
|
[Install]
|
|
11363
11731
|
WantedBy=default.target
|
|
11364
11732
|
`;
|
|
11365
11733
|
}
|
|
11366
11734
|
function installLinux() {
|
|
11367
|
-
if (!existsSync16(SYSTEMD_DIR))
|
|
11368
|
-
if (!existsSync16(LOGS_PATH))
|
|
11369
|
-
|
|
11735
|
+
if (!existsSync16(SYSTEMD_DIR)) mkdirSync7(SYSTEMD_DIR, { recursive: true });
|
|
11736
|
+
if (!existsSync16(LOGS_PATH)) mkdirSync7(LOGS_PATH, { recursive: true });
|
|
11737
|
+
writeFileSync6(UNIT_PATH, generateUnit());
|
|
11370
11738
|
console.log(` Installed: ${UNIT_PATH}`);
|
|
11371
11739
|
execFileSync2("systemctl", ["--user", "daemon-reload"]);
|
|
11372
11740
|
execFileSync2("systemctl", ["--user", "enable", "cc-claw"]);
|
|
@@ -11386,7 +11754,7 @@ function uninstallLinux() {
|
|
|
11386
11754
|
execFileSync2("systemctl", ["--user", "disable", "cc-claw"]);
|
|
11387
11755
|
} catch {
|
|
11388
11756
|
}
|
|
11389
|
-
|
|
11757
|
+
unlinkSync2(UNIT_PATH);
|
|
11390
11758
|
execFileSync2("systemctl", ["--user", "daemon-reload"]);
|
|
11391
11759
|
console.log(" Service uninstalled.");
|
|
11392
11760
|
}
|
|
@@ -11428,8 +11796,8 @@ var init_service = __esm({
|
|
|
11428
11796
|
"use strict";
|
|
11429
11797
|
init_paths();
|
|
11430
11798
|
PLIST_LABEL = "com.cc-claw";
|
|
11431
|
-
PLIST_PATH = join17(
|
|
11432
|
-
SYSTEMD_DIR = join17(
|
|
11799
|
+
PLIST_PATH = join17(homedir5(), "Library", "LaunchAgents", `${PLIST_LABEL}.plist`);
|
|
11800
|
+
SYSTEMD_DIR = join17(homedir5(), ".config", "systemd", "user");
|
|
11433
11801
|
UNIT_PATH = join17(SYSTEMD_DIR, "cc-claw.service");
|
|
11434
11802
|
}
|
|
11435
11803
|
});
|
|
@@ -11730,7 +12098,7 @@ __export(status_exports, {
|
|
|
11730
12098
|
import { existsSync as existsSync18, statSync as statSync4 } from "fs";
|
|
11731
12099
|
async function statusCommand(globalOpts, localOpts) {
|
|
11732
12100
|
try {
|
|
11733
|
-
const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(),
|
|
12101
|
+
const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
|
|
11734
12102
|
const readDb = openDatabaseReadOnly2();
|
|
11735
12103
|
const chatId = resolveChatId(globalOpts);
|
|
11736
12104
|
const { getAdapterForChat: getAdapterForChat2, getAdapter: getAdapter2, getAllAdapters: getAllAdapters2 } = await Promise.resolve().then(() => (init_backends(), backends_exports));
|
|
@@ -11866,7 +12234,7 @@ async function doctorCommand(globalOpts, localOpts) {
|
|
|
11866
12234
|
const size = statSync5(DB_PATH).size;
|
|
11867
12235
|
checks.push({ name: "Database", status: "ok", message: `${DB_PATH} (${(size / 1024).toFixed(0)}KB)` });
|
|
11868
12236
|
try {
|
|
11869
|
-
const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(),
|
|
12237
|
+
const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
|
|
11870
12238
|
const readDb = openDatabaseReadOnly2();
|
|
11871
12239
|
const journal = readDb.prepare("PRAGMA journal_mode").get();
|
|
11872
12240
|
if (!journal) {
|
|
@@ -11906,10 +12274,25 @@ async function doctorCommand(globalOpts, localOpts) {
|
|
|
11906
12274
|
}
|
|
11907
12275
|
}
|
|
11908
12276
|
try {
|
|
11909
|
-
const { isDaemonRunning: isDaemonRunning2 } = await Promise.resolve().then(() => (init_api_client(), api_client_exports));
|
|
12277
|
+
const { isDaemonRunning: isDaemonRunning2, apiGet: apiGet2 } = await Promise.resolve().then(() => (init_api_client(), api_client_exports));
|
|
11910
12278
|
const running = await isDaemonRunning2();
|
|
11911
12279
|
if (running) {
|
|
11912
12280
|
checks.push({ name: "Daemon", status: "ok", message: "running" });
|
|
12281
|
+
try {
|
|
12282
|
+
const health = await apiGet2("/api/health");
|
|
12283
|
+
const daemonVersion = health.data?.version;
|
|
12284
|
+
if (daemonVersion && daemonVersion !== VERSION) {
|
|
12285
|
+
checks.push({
|
|
12286
|
+
name: "Version",
|
|
12287
|
+
status: "warning",
|
|
12288
|
+
message: `service is v${daemonVersion}, CLI is v${VERSION} \u2014 restart required`,
|
|
12289
|
+
fix: "cc-claw service restart"
|
|
12290
|
+
});
|
|
12291
|
+
} else if (daemonVersion) {
|
|
12292
|
+
checks.push({ name: "Version", status: "ok", message: `v${VERSION}` });
|
|
12293
|
+
}
|
|
12294
|
+
} catch {
|
|
12295
|
+
}
|
|
11913
12296
|
} else {
|
|
11914
12297
|
checks.push({ name: "Daemon", status: "warning", message: "not running", fix: "cc-claw service start" });
|
|
11915
12298
|
}
|
|
@@ -12002,7 +12385,7 @@ async function doctorCommand(globalOpts, localOpts) {
|
|
|
12002
12385
|
}
|
|
12003
12386
|
if (check.name === "Usage log" && check.fix?.includes("prune")) {
|
|
12004
12387
|
try {
|
|
12005
|
-
const { getDb: getDb2 } = await Promise.resolve().then(() => (init_store4(),
|
|
12388
|
+
const { getDb: getDb2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
|
|
12006
12389
|
const db3 = getDb2();
|
|
12007
12390
|
const cutoff = new Date(Date.now() - 90 * 864e5).toISOString();
|
|
12008
12391
|
db3.prepare("DELETE FROM usage_log WHERE created_at < ?").run(cutoff);
|
|
@@ -12116,7 +12499,7 @@ async function backendList(globalOpts) {
|
|
|
12116
12499
|
const chatId = resolveChatId(globalOpts);
|
|
12117
12500
|
let activeBackend = null;
|
|
12118
12501
|
if (existsSync21(DB_PATH)) {
|
|
12119
|
-
const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(),
|
|
12502
|
+
const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
|
|
12120
12503
|
const readDb = openDatabaseReadOnly2();
|
|
12121
12504
|
try {
|
|
12122
12505
|
const row = readDb.prepare("SELECT backend FROM chat_backend WHERE chat_id = ?").get(chatId);
|
|
@@ -12150,7 +12533,7 @@ async function backendGet(globalOpts) {
|
|
|
12150
12533
|
outputError("DB_NOT_FOUND", "Database not found. Run cc-claw setup first.");
|
|
12151
12534
|
process.exit(1);
|
|
12152
12535
|
}
|
|
12153
|
-
const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(),
|
|
12536
|
+
const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
|
|
12154
12537
|
const readDb = openDatabaseReadOnly2();
|
|
12155
12538
|
const row = readDb.prepare("SELECT backend FROM chat_backend WHERE chat_id = ?").get(chatId);
|
|
12156
12539
|
readDb.close();
|
|
@@ -12193,7 +12576,7 @@ __export(model_exports, {
|
|
|
12193
12576
|
import { existsSync as existsSync22 } from "fs";
|
|
12194
12577
|
async function modelList(globalOpts) {
|
|
12195
12578
|
const chatId = resolveChatId(globalOpts);
|
|
12196
|
-
const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(),
|
|
12579
|
+
const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
|
|
12197
12580
|
const { getAdapter: getAdapter2, getAllAdapters: getAllAdapters2 } = await Promise.resolve().then(() => (init_backends(), backends_exports));
|
|
12198
12581
|
let backendId = "claude";
|
|
12199
12582
|
if (existsSync22(DB_PATH)) {
|
|
@@ -12233,7 +12616,7 @@ async function modelGet(globalOpts) {
|
|
|
12233
12616
|
outputError("DB_NOT_FOUND", "Database not found.");
|
|
12234
12617
|
process.exit(1);
|
|
12235
12618
|
}
|
|
12236
|
-
const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(),
|
|
12619
|
+
const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
|
|
12237
12620
|
const readDb = openDatabaseReadOnly2();
|
|
12238
12621
|
const row = readDb.prepare("SELECT model FROM chat_model WHERE chat_id = ?").get(chatId);
|
|
12239
12622
|
readDb.close();
|
|
@@ -12279,7 +12662,7 @@ async function memoryList(globalOpts) {
|
|
|
12279
12662
|
outputError("DB_NOT_FOUND", "Database not found. Run cc-claw setup first.");
|
|
12280
12663
|
process.exit(1);
|
|
12281
12664
|
}
|
|
12282
|
-
const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(),
|
|
12665
|
+
const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
|
|
12283
12666
|
const readDb = openDatabaseReadOnly2();
|
|
12284
12667
|
const memories = readDb.prepare(
|
|
12285
12668
|
"SELECT * FROM memories WHERE salience >= 0.1 ORDER BY salience DESC"
|
|
@@ -12303,7 +12686,7 @@ async function memorySearch(globalOpts, query) {
|
|
|
12303
12686
|
outputError("DB_NOT_FOUND", "Database not found.");
|
|
12304
12687
|
process.exit(1);
|
|
12305
12688
|
}
|
|
12306
|
-
const { openDatabaseReadOnly: openDatabaseReadOnly2, searchMemoriesReadOnly: searchMemoriesReadOnly2 } = await Promise.resolve().then(() => (init_store4(),
|
|
12689
|
+
const { openDatabaseReadOnly: openDatabaseReadOnly2, searchMemoriesReadOnly: searchMemoriesReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
|
|
12307
12690
|
const readDb = openDatabaseReadOnly2();
|
|
12308
12691
|
const results = searchMemoriesReadOnly2(readDb, query, 10);
|
|
12309
12692
|
readDb.close();
|
|
@@ -12325,7 +12708,7 @@ async function memoryHistory(globalOpts, opts) {
|
|
|
12325
12708
|
outputError("DB_NOT_FOUND", "Database not found.");
|
|
12326
12709
|
process.exit(1);
|
|
12327
12710
|
}
|
|
12328
|
-
const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(),
|
|
12711
|
+
const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
|
|
12329
12712
|
const readDb = openDatabaseReadOnly2();
|
|
12330
12713
|
const limit = parseInt(opts.limit ?? "10", 10);
|
|
12331
12714
|
const chatId = resolveChatId(globalOpts);
|
|
@@ -12374,7 +12757,7 @@ async function cronList(globalOpts) {
|
|
|
12374
12757
|
outputError("DB_NOT_FOUND", "Database not found.");
|
|
12375
12758
|
process.exit(1);
|
|
12376
12759
|
}
|
|
12377
|
-
const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(),
|
|
12760
|
+
const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
|
|
12378
12761
|
const readDb = openDatabaseReadOnly2();
|
|
12379
12762
|
const jobs = readDb.prepare("SELECT * FROM jobs ORDER BY id").all();
|
|
12380
12763
|
readDb.close();
|
|
@@ -12402,7 +12785,7 @@ async function cronHealth(globalOpts) {
|
|
|
12402
12785
|
outputError("DB_NOT_FOUND", "Database not found.");
|
|
12403
12786
|
process.exit(1);
|
|
12404
12787
|
}
|
|
12405
|
-
const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(),
|
|
12788
|
+
const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
|
|
12406
12789
|
const readDb = openDatabaseReadOnly2();
|
|
12407
12790
|
const totalJobs = readDb.prepare("SELECT COUNT(*) as c FROM jobs WHERE active = 1").get().c;
|
|
12408
12791
|
const enabledJobs = readDb.prepare("SELECT COUNT(*) as c FROM jobs WHERE active = 1 AND enabled = 1").get().c;
|
|
@@ -12439,8 +12822,8 @@ async function cronCreate(globalOpts, opts) {
|
|
|
12439
12822
|
const chatId = resolveChatId(globalOpts);
|
|
12440
12823
|
const { success: successFmt } = await Promise.resolve().then(() => (init_format(), format_exports));
|
|
12441
12824
|
try {
|
|
12442
|
-
const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(),
|
|
12443
|
-
const { getDb: getDb2 } = await Promise.resolve().then(() => (init_store4(),
|
|
12825
|
+
const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
|
|
12826
|
+
const { getDb: getDb2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
|
|
12444
12827
|
const db3 = getDb2();
|
|
12445
12828
|
const schedType = opts.cron ? "cron" : opts.at ? "at" : "every";
|
|
12446
12829
|
let everyMs = null;
|
|
@@ -12508,7 +12891,7 @@ async function cronEdit(globalOpts, id, opts) {
|
|
|
12508
12891
|
const jobId = parseInt(id, 10);
|
|
12509
12892
|
const { success: successFmt } = await Promise.resolve().then(() => (init_format(), format_exports));
|
|
12510
12893
|
try {
|
|
12511
|
-
const { getDb: getDb2 } = await Promise.resolve().then(() => (init_store4(),
|
|
12894
|
+
const { getDb: getDb2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
|
|
12512
12895
|
const db3 = getDb2();
|
|
12513
12896
|
const updates = [];
|
|
12514
12897
|
const values = [];
|
|
@@ -12563,7 +12946,7 @@ async function cronRuns(globalOpts, jobId, opts) {
|
|
|
12563
12946
|
outputError("DB_NOT_FOUND", "Database not found.");
|
|
12564
12947
|
process.exit(1);
|
|
12565
12948
|
}
|
|
12566
|
-
const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(),
|
|
12949
|
+
const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
|
|
12567
12950
|
const readDb = openDatabaseReadOnly2();
|
|
12568
12951
|
const limit = parseInt(opts.limit ?? "10", 10);
|
|
12569
12952
|
const query = jobId ? "SELECT * FROM job_runs WHERE job_id = ? ORDER BY started_at DESC LIMIT ?" : "SELECT * FROM job_runs ORDER BY started_at DESC LIMIT ?";
|
|
@@ -12610,7 +12993,7 @@ async function agentsList(globalOpts) {
|
|
|
12610
12993
|
outputError("DB_NOT_FOUND", "Database not found.");
|
|
12611
12994
|
process.exit(1);
|
|
12612
12995
|
}
|
|
12613
|
-
const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(),
|
|
12996
|
+
const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
|
|
12614
12997
|
const readDb = openDatabaseReadOnly2();
|
|
12615
12998
|
const agents2 = readDb.prepare(
|
|
12616
12999
|
"SELECT * FROM agents WHERE status IN ('running', 'queued', 'starting', 'idle') ORDER BY created_at DESC"
|
|
@@ -12641,7 +13024,7 @@ async function tasksList(globalOpts) {
|
|
|
12641
13024
|
outputError("DB_NOT_FOUND", "Database not found.");
|
|
12642
13025
|
process.exit(1);
|
|
12643
13026
|
}
|
|
12644
|
-
const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(),
|
|
13027
|
+
const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
|
|
12645
13028
|
const readDb = openDatabaseReadOnly2();
|
|
12646
13029
|
const tasks = readDb.prepare(
|
|
12647
13030
|
"SELECT t.* FROM tasks t JOIN orchestrations o ON t.orchestration_id = o.id WHERE o.status = 'active' ORDER BY t.id"
|
|
@@ -12765,14 +13148,14 @@ __export(db_exports, {
|
|
|
12765
13148
|
dbPath: () => dbPath,
|
|
12766
13149
|
dbStats: () => dbStats
|
|
12767
13150
|
});
|
|
12768
|
-
import { existsSync as existsSync26, statSync as statSync6, copyFileSync, mkdirSync as
|
|
13151
|
+
import { existsSync as existsSync26, statSync as statSync6, copyFileSync, mkdirSync as mkdirSync8 } from "fs";
|
|
12769
13152
|
import { dirname as dirname5 } from "path";
|
|
12770
13153
|
async function dbStats(globalOpts) {
|
|
12771
13154
|
if (!existsSync26(DB_PATH)) {
|
|
12772
13155
|
outputError("DB_NOT_FOUND", `Database not found at ${DB_PATH}`);
|
|
12773
13156
|
process.exit(1);
|
|
12774
13157
|
}
|
|
12775
|
-
const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(),
|
|
13158
|
+
const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
|
|
12776
13159
|
const readDb = openDatabaseReadOnly2();
|
|
12777
13160
|
const mainSize = statSync6(DB_PATH).size;
|
|
12778
13161
|
const walPath = DB_PATH + "-wal";
|
|
@@ -12816,7 +13199,7 @@ async function dbBackup(globalOpts, destPath) {
|
|
|
12816
13199
|
}
|
|
12817
13200
|
const dest = destPath ?? `${DB_PATH}.backup-${(/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-")}`;
|
|
12818
13201
|
try {
|
|
12819
|
-
|
|
13202
|
+
mkdirSync8(dirname5(dest), { recursive: true });
|
|
12820
13203
|
copyFileSync(DB_PATH, dest);
|
|
12821
13204
|
const walPath = DB_PATH + "-wal";
|
|
12822
13205
|
if (existsSync26(walPath)) copyFileSync(walPath, dest + "-wal");
|
|
@@ -12857,7 +13240,7 @@ function ensureDb() {
|
|
|
12857
13240
|
}
|
|
12858
13241
|
async function usageCost(globalOpts, opts) {
|
|
12859
13242
|
ensureDb();
|
|
12860
|
-
const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(),
|
|
13243
|
+
const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
|
|
12861
13244
|
const readDb = openDatabaseReadOnly2();
|
|
12862
13245
|
const { getAllAdapters: getAllAdapters2 } = await Promise.resolve().then(() => (init_backends(), backends_exports));
|
|
12863
13246
|
const pricing = {};
|
|
@@ -12937,7 +13320,7 @@ async function usageCost(globalOpts, opts) {
|
|
|
12937
13320
|
}
|
|
12938
13321
|
async function usageTokens(globalOpts) {
|
|
12939
13322
|
ensureDb();
|
|
12940
|
-
const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(),
|
|
13323
|
+
const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
|
|
12941
13324
|
const { getAllAdapters: getAllAdapters2, getAllBackendIds: getAllBackendIds2 } = await Promise.resolve().then(() => (init_backends(), backends_exports));
|
|
12942
13325
|
const readDb = openDatabaseReadOnly2();
|
|
12943
13326
|
const backendIds = getAllBackendIds2();
|
|
@@ -12971,7 +13354,7 @@ async function usageTokens(globalOpts) {
|
|
|
12971
13354
|
}
|
|
12972
13355
|
async function limitsList(globalOpts) {
|
|
12973
13356
|
ensureDb();
|
|
12974
|
-
const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(),
|
|
13357
|
+
const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
|
|
12975
13358
|
const readDb = openDatabaseReadOnly2();
|
|
12976
13359
|
const limits2 = readDb.prepare("SELECT * FROM backend_limits").all();
|
|
12977
13360
|
readDb.close();
|
|
@@ -13046,7 +13429,7 @@ async function configList(globalOpts) {
|
|
|
13046
13429
|
outputError("DB_NOT_FOUND", "Database not found.");
|
|
13047
13430
|
process.exit(1);
|
|
13048
13431
|
}
|
|
13049
|
-
const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(),
|
|
13432
|
+
const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
|
|
13050
13433
|
const readDb = openDatabaseReadOnly2();
|
|
13051
13434
|
const chatId = resolveChatId(globalOpts);
|
|
13052
13435
|
const config2 = {};
|
|
@@ -13080,7 +13463,7 @@ async function configGet(globalOpts, key) {
|
|
|
13080
13463
|
outputError("DB_NOT_FOUND", "Database not found.");
|
|
13081
13464
|
process.exit(1);
|
|
13082
13465
|
}
|
|
13083
|
-
const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(),
|
|
13466
|
+
const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
|
|
13084
13467
|
const readDb = openDatabaseReadOnly2();
|
|
13085
13468
|
const chatId = resolveChatId(globalOpts);
|
|
13086
13469
|
const { table, col } = KEY_TABLE_MAP[key];
|
|
@@ -13181,7 +13564,7 @@ async function sessionGet(globalOpts) {
|
|
|
13181
13564
|
outputError("DB_NOT_FOUND", "Database not found.");
|
|
13182
13565
|
process.exit(1);
|
|
13183
13566
|
}
|
|
13184
|
-
const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(),
|
|
13567
|
+
const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
|
|
13185
13568
|
const readDb = openDatabaseReadOnly2();
|
|
13186
13569
|
const chatId = resolveChatId(globalOpts);
|
|
13187
13570
|
const session2 = readDb.prepare("SELECT * FROM sessions WHERE chat_id = ?").get(chatId);
|
|
@@ -13247,7 +13630,7 @@ function ensureDb2() {
|
|
|
13247
13630
|
}
|
|
13248
13631
|
async function permissionsGet(globalOpts) {
|
|
13249
13632
|
ensureDb2();
|
|
13250
|
-
const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(),
|
|
13633
|
+
const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
|
|
13251
13634
|
const readDb = openDatabaseReadOnly2();
|
|
13252
13635
|
const chatId = resolveChatId(globalOpts);
|
|
13253
13636
|
const row = readDb.prepare("SELECT mode FROM chat_mode WHERE chat_id = ?").get(chatId);
|
|
@@ -13279,7 +13662,7 @@ async function permissionsSet(globalOpts, mode) {
|
|
|
13279
13662
|
}
|
|
13280
13663
|
async function toolsList(globalOpts) {
|
|
13281
13664
|
ensureDb2();
|
|
13282
|
-
const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(),
|
|
13665
|
+
const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
|
|
13283
13666
|
const readDb = openDatabaseReadOnly2();
|
|
13284
13667
|
const chatId = resolveChatId(globalOpts);
|
|
13285
13668
|
const rows = readDb.prepare("SELECT tool, enabled FROM chat_tools WHERE chat_id = ?").all(chatId);
|
|
@@ -13340,7 +13723,7 @@ async function toggleTool2(globalOpts, name, enabled) {
|
|
|
13340
13723
|
}
|
|
13341
13724
|
async function verboseGet(globalOpts) {
|
|
13342
13725
|
ensureDb2();
|
|
13343
|
-
const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(),
|
|
13726
|
+
const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
|
|
13344
13727
|
const readDb = openDatabaseReadOnly2();
|
|
13345
13728
|
const chatId = resolveChatId(globalOpts);
|
|
13346
13729
|
const row = readDb.prepare("SELECT level FROM chat_verbose WHERE chat_id = ?").get(chatId);
|
|
@@ -13392,7 +13775,7 @@ async function cwdGet(globalOpts) {
|
|
|
13392
13775
|
outputError("DB_NOT_FOUND", "Database not found.");
|
|
13393
13776
|
process.exit(1);
|
|
13394
13777
|
}
|
|
13395
|
-
const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(),
|
|
13778
|
+
const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
|
|
13396
13779
|
const readDb = openDatabaseReadOnly2();
|
|
13397
13780
|
const chatId = resolveChatId(globalOpts);
|
|
13398
13781
|
const row = readDb.prepare("SELECT cwd FROM chat_cwd WHERE chat_id = ?").get(chatId);
|
|
@@ -13456,7 +13839,7 @@ async function voiceGet(globalOpts) {
|
|
|
13456
13839
|
outputError("DB_NOT_FOUND", "Database not found.");
|
|
13457
13840
|
process.exit(1);
|
|
13458
13841
|
}
|
|
13459
|
-
const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(),
|
|
13842
|
+
const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
|
|
13460
13843
|
const readDb = openDatabaseReadOnly2();
|
|
13461
13844
|
const chatId = resolveChatId(globalOpts);
|
|
13462
13845
|
const row = readDb.prepare("SELECT enabled FROM chat_voice WHERE chat_id = ?").get(chatId);
|
|
@@ -13507,7 +13890,7 @@ async function heartbeatGet(globalOpts) {
|
|
|
13507
13890
|
outputError("DB_NOT_FOUND", "Database not found.");
|
|
13508
13891
|
process.exit(1);
|
|
13509
13892
|
}
|
|
13510
|
-
const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(),
|
|
13893
|
+
const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
|
|
13511
13894
|
const readDb = openDatabaseReadOnly2();
|
|
13512
13895
|
const chatId = resolveChatId(globalOpts);
|
|
13513
13896
|
const row = readDb.prepare("SELECT * FROM chat_heartbeat WHERE chat_id = ?").get(chatId);
|
|
@@ -13619,7 +14002,7 @@ async function chatsList(_globalOpts) {
|
|
|
13619
14002
|
outputError("DB_NOT_FOUND", "Database not found.");
|
|
13620
14003
|
process.exit(1);
|
|
13621
14004
|
}
|
|
13622
|
-
const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(),
|
|
14005
|
+
const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
|
|
13623
14006
|
const readDb = openDatabaseReadOnly2();
|
|
13624
14007
|
const aliases = readDb.prepare("SELECT alias, chat_id FROM chat_aliases ORDER BY alias").all();
|
|
13625
14008
|
readDb.close();
|
|
@@ -13749,7 +14132,7 @@ async function mcpsList(_globalOpts) {
|
|
|
13749
14132
|
outputError("DB_NOT_FOUND", "Database not found.");
|
|
13750
14133
|
process.exit(1);
|
|
13751
14134
|
}
|
|
13752
|
-
const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(),
|
|
14135
|
+
const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
|
|
13753
14136
|
const readDb = openDatabaseReadOnly2();
|
|
13754
14137
|
const mcps2 = readDb.prepare("SELECT * FROM mcp_servers ORDER BY name").all();
|
|
13755
14138
|
readDb.close();
|
|
@@ -13760,7 +14143,7 @@ async function mcpsList(_globalOpts) {
|
|
|
13760
14143
|
`;
|
|
13761
14144
|
const lines = ["", divider(`MCP Servers (${list.length})`), ""];
|
|
13762
14145
|
for (const m of list) {
|
|
13763
|
-
const auto = m.
|
|
14146
|
+
const auto = m.enabledByDefault ? " \u{1F4CC}" : "";
|
|
13764
14147
|
const desc = m.description ? ` \u2014 ${m.description}` : "";
|
|
13765
14148
|
lines.push(` ${checkMark(true)} ${m.name}${auto}${desc}`);
|
|
13766
14149
|
}
|
|
@@ -14212,7 +14595,7 @@ var init_completion = __esm({
|
|
|
14212
14595
|
|
|
14213
14596
|
// src/setup.ts
|
|
14214
14597
|
var setup_exports = {};
|
|
14215
|
-
import { existsSync as existsSync37, writeFileSync as
|
|
14598
|
+
import { existsSync as existsSync37, writeFileSync as writeFileSync7, readFileSync as readFileSync16, copyFileSync as copyFileSync2, mkdirSync as mkdirSync9, statSync as statSync7 } from "fs";
|
|
14216
14599
|
import { execFileSync as execFileSync4 } from "child_process";
|
|
14217
14600
|
import { createInterface as createInterface5 } from "readline";
|
|
14218
14601
|
import { join as join18 } from "path";
|
|
@@ -14289,7 +14672,7 @@ async function setup() {
|
|
|
14289
14672
|
}
|
|
14290
14673
|
console.log("");
|
|
14291
14674
|
for (const dir of [CC_CLAW_HOME, DATA_PATH, LOGS_PATH, SKILLS_PATH, RUNNERS_PATH, AGENTS_PATH]) {
|
|
14292
|
-
if (!existsSync37(dir))
|
|
14675
|
+
if (!existsSync37(dir)) mkdirSync9(dir, { recursive: true });
|
|
14293
14676
|
}
|
|
14294
14677
|
const env = {};
|
|
14295
14678
|
const envSource = existsSync37(ENV_PATH) ? ENV_PATH : existsSync37(".env") ? ".env" : null;
|
|
@@ -14497,7 +14880,7 @@ async function setup() {
|
|
|
14497
14880
|
envLines.push("", "# Video Analysis", `GEMINI_API_KEY=${env.GEMINI_API_KEY}`);
|
|
14498
14881
|
}
|
|
14499
14882
|
const envContent = envLines.join("\n") + "\n";
|
|
14500
|
-
|
|
14883
|
+
writeFileSync7(ENV_PATH, envContent, { mode: 384 });
|
|
14501
14884
|
console.log(green(` Config saved to ${ENV_PATH} (permissions: owner-only)`));
|
|
14502
14885
|
header(6, TOTAL_STEPS, "Run on Startup (Daemon)");
|
|
14503
14886
|
console.log(" CC-Claw can run automatically in the background, starting");
|
|
@@ -14866,7 +15249,7 @@ summarizer.command("get").description("Current summarizer config").action(async
|
|
|
14866
15249
|
outputError3("DB_NOT_FOUND", "Database not found.");
|
|
14867
15250
|
process.exit(1);
|
|
14868
15251
|
}
|
|
14869
|
-
const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(),
|
|
15252
|
+
const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
|
|
14870
15253
|
const readDb = openDatabaseReadOnly2();
|
|
14871
15254
|
const chatId = program.opts().chat ?? "default";
|
|
14872
15255
|
const row = readDb.prepare("SELECT backend, model FROM chat_summarizer WHERE chat_id = ?").get(chatId);
|
|
@@ -14902,7 +15285,7 @@ thinking.command("get").description("Current thinking level").action(async () =>
|
|
|
14902
15285
|
outputError3("DB_NOT_FOUND", "Database not found.");
|
|
14903
15286
|
process.exit(1);
|
|
14904
15287
|
}
|
|
14905
|
-
const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(),
|
|
15288
|
+
const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
|
|
14906
15289
|
const readDb = openDatabaseReadOnly2();
|
|
14907
15290
|
const chatId = program.opts().chat ?? "default";
|
|
14908
15291
|
const row = readDb.prepare("SELECT level FROM chat_thinking WHERE chat_id = ?").get(chatId);
|