cc-claw 0.3.2 → 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.
Files changed (2) hide show
  1. package/dist/cli.js +508 -114
  2. 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.2" : (() => {
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 store_exports2 = {};
851
- __export(store_exports2, {
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, { encoding: "utf-8" });
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
- return stdout.trim().split(/\n/).map((line) => line.trim()).filter((line) => line.length > 0);
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(), store_exports2));
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(), store_exports2));
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(), store_exports2));
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(), store_exports2));
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(), store_exports2));
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(), store_exports2));
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(), store_exports2));
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(), store_exports2));
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(), store_exports2));
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(), store_exports2));
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(), store_exports2));
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(), store_exports2));
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(), store_exports2));
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(), store_exports2));
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(), store_exports2));
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(), store_exports2));
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(), store_exports2));
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(), store_exports2));
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(), store_exports2));
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(), store_exports2));
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(), store_exports2));
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(), store_exports2));
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(), store_exports2));
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(), store_exports2));
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(), store_exports2));
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(), store_exports2));
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 spawn3 } from "child_process";
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 = spawn3(config2.executable, finalArgs, {
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 startHealthMonitor() {
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 stopHealthMonitor() {
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 init_health = __esm({
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
- startHealthMonitor();
6233
+ startHealthMonitor2();
5876
6234
  try {
5877
- const { getDb: getDb2 } = (init_store4(), __toCommonJS(store_exports2));
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
- stopHealthMonitor();
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
- init_health();
6483
+ init_health2();
6126
6484
  activeTimers = /* @__PURE__ */ new Map();
6127
6485
  runningJobs = /* @__PURE__ */ new Set();
6128
6486
  }
@@ -6143,13 +6501,18 @@ function buildMcpCommands(backendId) {
6143
6501
  cmd.push("-e", `${k}=${v}`);
6144
6502
  }
6145
6503
  }
6146
- cmd.push(server.name);
6147
6504
  if (server.transport === "stdio" && server.command) {
6505
+ cmd.push(server.name);
6148
6506
  if (backendId === "gemini") {
6149
6507
  cmd.push(server.command, ...server.args ?? []);
6150
6508
  } else {
6151
6509
  cmd.push("--", server.command, ...server.args ?? []);
6152
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);
6153
6516
  }
6154
6517
  return cmd;
6155
6518
  },
@@ -7022,13 +7385,13 @@ __export(discover_exports, {
7022
7385
  });
7023
7386
  import { readdir, readFile as readFile2 } from "fs/promises";
7024
7387
  import { createHash } from "crypto";
7025
- import { homedir as homedir2 } from "os";
7388
+ import { homedir as homedir3 } from "os";
7026
7389
  import { join as join10 } from "path";
7027
7390
  async function discoverAllSkills() {
7028
7391
  const rawSkills = [];
7029
7392
  rawSkills.push(...await scanSkillDir(SKILLS_PATH, "cc-claw"));
7030
7393
  for (const backendId of getAllBackendIds()) {
7031
- const dirs = BACKEND_SKILL_DIRS[backendId] ?? [join10(homedir2(), `.${backendId}`, "skills")];
7394
+ const dirs = BACKEND_SKILL_DIRS[backendId] ?? [join10(homedir3(), `.${backendId}`, "skills")];
7032
7395
  for (const dir of dirs) {
7033
7396
  rawSkills.push(...await scanSkillDir(dir, backendId));
7034
7397
  }
@@ -7151,11 +7514,11 @@ var init_discover = __esm({
7151
7514
  init_backends();
7152
7515
  SKILL_FILE_CANDIDATES = ["SKILL.md", "skill.md"];
7153
7516
  BACKEND_SKILL_DIRS = {
7154
- claude: [join10(homedir2(), ".claude", "skills")],
7155
- gemini: [join10(homedir2(), ".gemini", "skills")],
7517
+ claude: [join10(homedir3(), ".claude", "skills")],
7518
+ gemini: [join10(homedir3(), ".gemini", "skills")],
7156
7519
  codex: [
7157
- join10(homedir2(), ".agents", "skills"),
7158
- join10(homedir2(), ".codex", "skills")
7520
+ join10(homedir3(), ".agents", "skills"),
7521
+ join10(homedir3(), ".codex", "skills")
7159
7522
  ]
7160
7523
  };
7161
7524
  }
@@ -7616,7 +7979,7 @@ var init_heartbeat = __esm({
7616
7979
  init_agent();
7617
7980
  init_store4();
7618
7981
  init_backends();
7619
- init_health();
7982
+ init_health2();
7620
7983
  init_log();
7621
7984
  HEARTBEAT_MD_PATH = join13(WORKSPACE_PATH, "HEARTBEAT.md");
7622
7985
  HEARTBEAT_OK = "HEARTBEAT_OK";
@@ -9568,8 +9931,8 @@ Use /skills to see it.`, "plain");
9568
9931
  lines.push(` \u2705 <b>cc-claw</b> <i>Agent orchestrator (spawn, tasks, inbox)</i>`);
9569
9932
  }
9570
9933
  const { execFile: execFile5 } = await import("child_process");
9571
- const { homedir: homedir5 } = await import("os");
9572
- const discoveryCwd = homedir5();
9934
+ const { homedir: homedir6 } = await import("os");
9935
+ const discoveryCwd = homedir6();
9573
9936
  const runnerResults = await Promise.allSettled(
9574
9937
  getAllRunners().map((runner) => {
9575
9938
  const listCmd = runner.getMcpListCommand();
@@ -10417,7 +10780,7 @@ var init_router = __esm({
10417
10780
  init_backends();
10418
10781
  init_cron();
10419
10782
  init_wizard();
10420
- init_health();
10783
+ init_health2();
10421
10784
  init_video();
10422
10785
  init_store();
10423
10786
  init_orchestrator();
@@ -10724,7 +11087,7 @@ async function attemptReconnect(channel, handler) {
10724
11087
  return false;
10725
11088
  }
10726
11089
  }
10727
- function startHealthMonitor2(channels, handler) {
11090
+ function startHealthMonitor3(channels, handler) {
10728
11091
  registeredHandler = handler;
10729
11092
  for (const ch of channels) {
10730
11093
  trackChannel(ch);
@@ -10740,14 +11103,14 @@ function startHealthMonitor2(channels, handler) {
10740
11103
  }, HEALTH_CHECK_INTERVAL_MS);
10741
11104
  log(`[channel-health] Monitoring ${channels.length} channel(s)`);
10742
11105
  }
10743
- function stopHealthMonitor2() {
11106
+ function stopHealthMonitor3() {
10744
11107
  if (healthInterval) {
10745
11108
  clearInterval(healthInterval);
10746
11109
  healthInterval = null;
10747
11110
  }
10748
11111
  }
10749
11112
  var healthState, MAX_RECONNECT_ATTEMPTS, RECONNECT_BASE_MS, HEALTH_CHECK_INTERVAL_MS, healthInterval, registeredHandler;
10750
- var init_health2 = __esm({
11113
+ var init_health3 = __esm({
10751
11114
  "src/channels/health.ts"() {
10752
11115
  "use strict";
10753
11116
  init_log();
@@ -10768,13 +11131,13 @@ __export(ai_skill_exports, {
10768
11131
  });
10769
11132
  import { existsSync as existsSync14, writeFileSync as writeFileSync5, mkdirSync as mkdirSync5 } from "fs";
10770
11133
  import { join as join15 } from "path";
10771
- import { homedir as homedir3 } from "os";
11134
+ import { homedir as homedir4 } from "os";
10772
11135
  function generateAiSkill() {
10773
11136
  const version = VERSION;
10774
11137
  let systemState = "";
10775
11138
  if (existsSync14(DB_PATH)) {
10776
11139
  try {
10777
- const { openDatabaseReadOnly: openDatabaseReadOnly2 } = (init_store4(), __toCommonJS(store_exports2));
11140
+ const { openDatabaseReadOnly: openDatabaseReadOnly2 } = (init_store4(), __toCommonJS(store_exports3));
10778
11141
  const readDb = openDatabaseReadOnly2();
10779
11142
  const backendRow = readDb.prepare("SELECT backend FROM chat_backend LIMIT 1").get();
10780
11143
  const modelRow = readDb.prepare("SELECT model FROM chat_model LIMIT 1").get();
@@ -11015,10 +11378,10 @@ var init_ai_skill = __esm({
11015
11378
  init_paths();
11016
11379
  init_version();
11017
11380
  BACKEND_SKILL_DIRS2 = {
11018
- "cc-claw": [join15(homedir3(), ".cc-claw", "workspace", "skills")],
11019
- claude: [join15(homedir3(), ".claude", "skills")],
11020
- gemini: [join15(homedir3(), ".gemini", "skills")],
11021
- codex: [join15(homedir3(), ".agents", "skills")]
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")]
11022
11385
  };
11023
11386
  }
11024
11387
  });
@@ -11108,15 +11471,27 @@ async function main() {
11108
11471
  startPersistedJobs();
11109
11472
  initRunnerRegistry();
11110
11473
  initOrchestrator();
11474
+ let notifyQueue = Promise.resolve();
11111
11475
  setNotifyCallback((chatId, message) => {
11112
11476
  const primaryChatId = (process.env.ALLOWED_CHAT_ID ?? "").split(",")[0]?.trim();
11113
11477
  const targetChatId = primaryChatId || chatId;
11114
- for (const ch of channelRegistry.list()) {
11115
- ch.sendText(targetChatId, `\u{1F916} ${message}`, "plain").catch(() => {
11116
- });
11117
- }
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
+ });
11118
11485
  });
11119
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
+ });
11120
11495
  log("[cc-claw] Scheduler initialized");
11121
11496
  if (process.env.DASHBOARD_ENABLED === "1") {
11122
11497
  startDashboard();
@@ -11137,7 +11512,11 @@ async function main() {
11137
11512
  migrateEmbeddings().catch((err) => error("[cc-claw] Embedding migration failed:", err));
11138
11513
  initHeartbeat(channelRegistry);
11139
11514
  startAllHeartbeats();
11140
- startHealthMonitor2(channelRegistry.list(), handleMessage);
11515
+ startHealthMonitor3(channelRegistry.list(), handleMessage);
11516
+ Promise.resolve().then(() => (init_health(), health_exports)).then(({ startHealthMonitor: startMcpHealthMonitor }) => {
11517
+ startMcpHealthMonitor(getDb());
11518
+ }).catch(() => {
11519
+ });
11141
11520
  startMonitor({
11142
11521
  onIdleDetected: (agent) => {
11143
11522
  log(`[orchestrator] Agent ${agent.id.slice(0, 8)} idle \u2014 nudging`);
@@ -11148,7 +11527,7 @@ async function main() {
11148
11527
  log(`[cc-claw] Received ${signal}, shutting down...`);
11149
11528
  try {
11150
11529
  stopAllHeartbeats();
11151
- stopHealthMonitor2();
11530
+ stopHealthMonitor3();
11152
11531
  stopMonitor();
11153
11532
  shutdownOrchestrator();
11154
11533
  shutdownScheduler();
@@ -11184,7 +11563,7 @@ var init_index = __esm({
11184
11563
  init_heartbeat();
11185
11564
  init_migrate_embeddings();
11186
11565
  init_bootstrap2();
11187
- init_health2();
11566
+ init_health3();
11188
11567
  for (const dir of [CC_CLAW_HOME, DATA_PATH, LOGS_PATH, SKILLS_PATH, RUNNERS_PATH, AGENTS_PATH]) {
11189
11568
  if (!existsSync15(dir)) mkdirSync6(dir, { recursive: true });
11190
11569
  }
@@ -11212,7 +11591,7 @@ __export(service_exports, {
11212
11591
  });
11213
11592
  import { existsSync as existsSync16, mkdirSync as mkdirSync7, writeFileSync as writeFileSync6, unlinkSync as unlinkSync2 } from "fs";
11214
11593
  import { execFileSync as execFileSync2, execSync as execSync5 } from "child_process";
11215
- import { homedir as homedir4, platform } from "os";
11594
+ import { homedir as homedir5, platform } from "os";
11216
11595
  import { join as join17, dirname as dirname4 } from "path";
11217
11596
  function resolveExecutable2(name) {
11218
11597
  try {
@@ -11223,7 +11602,7 @@ function resolveExecutable2(name) {
11223
11602
  }
11224
11603
  function getPathDirs() {
11225
11604
  const nodeBin = dirname4(process.execPath);
11226
- const home = homedir4();
11605
+ const home = homedir5();
11227
11606
  const dirs = /* @__PURE__ */ new Set([
11228
11607
  nodeBin,
11229
11608
  join17(home, ".local", "bin"),
@@ -11241,7 +11620,7 @@ function getPathDirs() {
11241
11620
  function generatePlist() {
11242
11621
  const ccClawBin = resolveExecutable2("cc-claw");
11243
11622
  const pathDirs = getPathDirs();
11244
- const home = homedir4();
11623
+ const home = homedir5();
11245
11624
  return `<?xml version="1.0" encoding="UTF-8"?>
11246
11625
  <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
11247
11626
  <plist version="1.0">
@@ -11346,7 +11725,7 @@ Restart=on-failure
11346
11725
  RestartSec=10
11347
11726
  WorkingDirectory=${CC_CLAW_HOME}
11348
11727
  Environment=PATH=${pathDirs}
11349
- Environment=HOME=${homedir4()}
11728
+ Environment=HOME=${homedir5()}
11350
11729
 
11351
11730
  [Install]
11352
11731
  WantedBy=default.target
@@ -11417,8 +11796,8 @@ var init_service = __esm({
11417
11796
  "use strict";
11418
11797
  init_paths();
11419
11798
  PLIST_LABEL = "com.cc-claw";
11420
- PLIST_PATH = join17(homedir4(), "Library", "LaunchAgents", `${PLIST_LABEL}.plist`);
11421
- SYSTEMD_DIR = join17(homedir4(), ".config", "systemd", "user");
11799
+ PLIST_PATH = join17(homedir5(), "Library", "LaunchAgents", `${PLIST_LABEL}.plist`);
11800
+ SYSTEMD_DIR = join17(homedir5(), ".config", "systemd", "user");
11422
11801
  UNIT_PATH = join17(SYSTEMD_DIR, "cc-claw.service");
11423
11802
  }
11424
11803
  });
@@ -11719,7 +12098,7 @@ __export(status_exports, {
11719
12098
  import { existsSync as existsSync18, statSync as statSync4 } from "fs";
11720
12099
  async function statusCommand(globalOpts, localOpts) {
11721
12100
  try {
11722
- const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports2));
12101
+ const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
11723
12102
  const readDb = openDatabaseReadOnly2();
11724
12103
  const chatId = resolveChatId(globalOpts);
11725
12104
  const { getAdapterForChat: getAdapterForChat2, getAdapter: getAdapter2, getAllAdapters: getAllAdapters2 } = await Promise.resolve().then(() => (init_backends(), backends_exports));
@@ -11855,7 +12234,7 @@ async function doctorCommand(globalOpts, localOpts) {
11855
12234
  const size = statSync5(DB_PATH).size;
11856
12235
  checks.push({ name: "Database", status: "ok", message: `${DB_PATH} (${(size / 1024).toFixed(0)}KB)` });
11857
12236
  try {
11858
- const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports2));
12237
+ const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
11859
12238
  const readDb = openDatabaseReadOnly2();
11860
12239
  const journal = readDb.prepare("PRAGMA journal_mode").get();
11861
12240
  if (!journal) {
@@ -11895,10 +12274,25 @@ async function doctorCommand(globalOpts, localOpts) {
11895
12274
  }
11896
12275
  }
11897
12276
  try {
11898
- 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));
11899
12278
  const running = await isDaemonRunning2();
11900
12279
  if (running) {
11901
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
+ }
11902
12296
  } else {
11903
12297
  checks.push({ name: "Daemon", status: "warning", message: "not running", fix: "cc-claw service start" });
11904
12298
  }
@@ -11991,7 +12385,7 @@ async function doctorCommand(globalOpts, localOpts) {
11991
12385
  }
11992
12386
  if (check.name === "Usage log" && check.fix?.includes("prune")) {
11993
12387
  try {
11994
- const { getDb: getDb2 } = await Promise.resolve().then(() => (init_store4(), store_exports2));
12388
+ const { getDb: getDb2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
11995
12389
  const db3 = getDb2();
11996
12390
  const cutoff = new Date(Date.now() - 90 * 864e5).toISOString();
11997
12391
  db3.prepare("DELETE FROM usage_log WHERE created_at < ?").run(cutoff);
@@ -12105,7 +12499,7 @@ async function backendList(globalOpts) {
12105
12499
  const chatId = resolveChatId(globalOpts);
12106
12500
  let activeBackend = null;
12107
12501
  if (existsSync21(DB_PATH)) {
12108
- const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports2));
12502
+ const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
12109
12503
  const readDb = openDatabaseReadOnly2();
12110
12504
  try {
12111
12505
  const row = readDb.prepare("SELECT backend FROM chat_backend WHERE chat_id = ?").get(chatId);
@@ -12139,7 +12533,7 @@ async function backendGet(globalOpts) {
12139
12533
  outputError("DB_NOT_FOUND", "Database not found. Run cc-claw setup first.");
12140
12534
  process.exit(1);
12141
12535
  }
12142
- const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports2));
12536
+ const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
12143
12537
  const readDb = openDatabaseReadOnly2();
12144
12538
  const row = readDb.prepare("SELECT backend FROM chat_backend WHERE chat_id = ?").get(chatId);
12145
12539
  readDb.close();
@@ -12182,7 +12576,7 @@ __export(model_exports, {
12182
12576
  import { existsSync as existsSync22 } from "fs";
12183
12577
  async function modelList(globalOpts) {
12184
12578
  const chatId = resolveChatId(globalOpts);
12185
- const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports2));
12579
+ const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
12186
12580
  const { getAdapter: getAdapter2, getAllAdapters: getAllAdapters2 } = await Promise.resolve().then(() => (init_backends(), backends_exports));
12187
12581
  let backendId = "claude";
12188
12582
  if (existsSync22(DB_PATH)) {
@@ -12222,7 +12616,7 @@ async function modelGet(globalOpts) {
12222
12616
  outputError("DB_NOT_FOUND", "Database not found.");
12223
12617
  process.exit(1);
12224
12618
  }
12225
- const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports2));
12619
+ const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
12226
12620
  const readDb = openDatabaseReadOnly2();
12227
12621
  const row = readDb.prepare("SELECT model FROM chat_model WHERE chat_id = ?").get(chatId);
12228
12622
  readDb.close();
@@ -12268,7 +12662,7 @@ async function memoryList(globalOpts) {
12268
12662
  outputError("DB_NOT_FOUND", "Database not found. Run cc-claw setup first.");
12269
12663
  process.exit(1);
12270
12664
  }
12271
- const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports2));
12665
+ const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
12272
12666
  const readDb = openDatabaseReadOnly2();
12273
12667
  const memories = readDb.prepare(
12274
12668
  "SELECT * FROM memories WHERE salience >= 0.1 ORDER BY salience DESC"
@@ -12292,7 +12686,7 @@ async function memorySearch(globalOpts, query) {
12292
12686
  outputError("DB_NOT_FOUND", "Database not found.");
12293
12687
  process.exit(1);
12294
12688
  }
12295
- const { openDatabaseReadOnly: openDatabaseReadOnly2, searchMemoriesReadOnly: searchMemoriesReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports2));
12689
+ const { openDatabaseReadOnly: openDatabaseReadOnly2, searchMemoriesReadOnly: searchMemoriesReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
12296
12690
  const readDb = openDatabaseReadOnly2();
12297
12691
  const results = searchMemoriesReadOnly2(readDb, query, 10);
12298
12692
  readDb.close();
@@ -12314,7 +12708,7 @@ async function memoryHistory(globalOpts, opts) {
12314
12708
  outputError("DB_NOT_FOUND", "Database not found.");
12315
12709
  process.exit(1);
12316
12710
  }
12317
- const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports2));
12711
+ const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
12318
12712
  const readDb = openDatabaseReadOnly2();
12319
12713
  const limit = parseInt(opts.limit ?? "10", 10);
12320
12714
  const chatId = resolveChatId(globalOpts);
@@ -12363,7 +12757,7 @@ async function cronList(globalOpts) {
12363
12757
  outputError("DB_NOT_FOUND", "Database not found.");
12364
12758
  process.exit(1);
12365
12759
  }
12366
- const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports2));
12760
+ const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
12367
12761
  const readDb = openDatabaseReadOnly2();
12368
12762
  const jobs = readDb.prepare("SELECT * FROM jobs ORDER BY id").all();
12369
12763
  readDb.close();
@@ -12391,7 +12785,7 @@ async function cronHealth(globalOpts) {
12391
12785
  outputError("DB_NOT_FOUND", "Database not found.");
12392
12786
  process.exit(1);
12393
12787
  }
12394
- const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports2));
12788
+ const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
12395
12789
  const readDb = openDatabaseReadOnly2();
12396
12790
  const totalJobs = readDb.prepare("SELECT COUNT(*) as c FROM jobs WHERE active = 1").get().c;
12397
12791
  const enabledJobs = readDb.prepare("SELECT COUNT(*) as c FROM jobs WHERE active = 1 AND enabled = 1").get().c;
@@ -12428,8 +12822,8 @@ async function cronCreate(globalOpts, opts) {
12428
12822
  const chatId = resolveChatId(globalOpts);
12429
12823
  const { success: successFmt } = await Promise.resolve().then(() => (init_format(), format_exports));
12430
12824
  try {
12431
- const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports2));
12432
- const { getDb: getDb2 } = await Promise.resolve().then(() => (init_store4(), store_exports2));
12825
+ const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
12826
+ const { getDb: getDb2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
12433
12827
  const db3 = getDb2();
12434
12828
  const schedType = opts.cron ? "cron" : opts.at ? "at" : "every";
12435
12829
  let everyMs = null;
@@ -12497,7 +12891,7 @@ async function cronEdit(globalOpts, id, opts) {
12497
12891
  const jobId = parseInt(id, 10);
12498
12892
  const { success: successFmt } = await Promise.resolve().then(() => (init_format(), format_exports));
12499
12893
  try {
12500
- const { getDb: getDb2 } = await Promise.resolve().then(() => (init_store4(), store_exports2));
12894
+ const { getDb: getDb2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
12501
12895
  const db3 = getDb2();
12502
12896
  const updates = [];
12503
12897
  const values = [];
@@ -12552,7 +12946,7 @@ async function cronRuns(globalOpts, jobId, opts) {
12552
12946
  outputError("DB_NOT_FOUND", "Database not found.");
12553
12947
  process.exit(1);
12554
12948
  }
12555
- const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports2));
12949
+ const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
12556
12950
  const readDb = openDatabaseReadOnly2();
12557
12951
  const limit = parseInt(opts.limit ?? "10", 10);
12558
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 ?";
@@ -12599,7 +12993,7 @@ async function agentsList(globalOpts) {
12599
12993
  outputError("DB_NOT_FOUND", "Database not found.");
12600
12994
  process.exit(1);
12601
12995
  }
12602
- const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports2));
12996
+ const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
12603
12997
  const readDb = openDatabaseReadOnly2();
12604
12998
  const agents2 = readDb.prepare(
12605
12999
  "SELECT * FROM agents WHERE status IN ('running', 'queued', 'starting', 'idle') ORDER BY created_at DESC"
@@ -12630,7 +13024,7 @@ async function tasksList(globalOpts) {
12630
13024
  outputError("DB_NOT_FOUND", "Database not found.");
12631
13025
  process.exit(1);
12632
13026
  }
12633
- const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports2));
13027
+ const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
12634
13028
  const readDb = openDatabaseReadOnly2();
12635
13029
  const tasks = readDb.prepare(
12636
13030
  "SELECT t.* FROM tasks t JOIN orchestrations o ON t.orchestration_id = o.id WHERE o.status = 'active' ORDER BY t.id"
@@ -12761,7 +13155,7 @@ async function dbStats(globalOpts) {
12761
13155
  outputError("DB_NOT_FOUND", `Database not found at ${DB_PATH}`);
12762
13156
  process.exit(1);
12763
13157
  }
12764
- const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports2));
13158
+ const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
12765
13159
  const readDb = openDatabaseReadOnly2();
12766
13160
  const mainSize = statSync6(DB_PATH).size;
12767
13161
  const walPath = DB_PATH + "-wal";
@@ -12846,7 +13240,7 @@ function ensureDb() {
12846
13240
  }
12847
13241
  async function usageCost(globalOpts, opts) {
12848
13242
  ensureDb();
12849
- const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports2));
13243
+ const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
12850
13244
  const readDb = openDatabaseReadOnly2();
12851
13245
  const { getAllAdapters: getAllAdapters2 } = await Promise.resolve().then(() => (init_backends(), backends_exports));
12852
13246
  const pricing = {};
@@ -12926,7 +13320,7 @@ async function usageCost(globalOpts, opts) {
12926
13320
  }
12927
13321
  async function usageTokens(globalOpts) {
12928
13322
  ensureDb();
12929
- const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports2));
13323
+ const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
12930
13324
  const { getAllAdapters: getAllAdapters2, getAllBackendIds: getAllBackendIds2 } = await Promise.resolve().then(() => (init_backends(), backends_exports));
12931
13325
  const readDb = openDatabaseReadOnly2();
12932
13326
  const backendIds = getAllBackendIds2();
@@ -12960,7 +13354,7 @@ async function usageTokens(globalOpts) {
12960
13354
  }
12961
13355
  async function limitsList(globalOpts) {
12962
13356
  ensureDb();
12963
- const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports2));
13357
+ const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
12964
13358
  const readDb = openDatabaseReadOnly2();
12965
13359
  const limits2 = readDb.prepare("SELECT * FROM backend_limits").all();
12966
13360
  readDb.close();
@@ -13035,7 +13429,7 @@ async function configList(globalOpts) {
13035
13429
  outputError("DB_NOT_FOUND", "Database not found.");
13036
13430
  process.exit(1);
13037
13431
  }
13038
- const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports2));
13432
+ const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
13039
13433
  const readDb = openDatabaseReadOnly2();
13040
13434
  const chatId = resolveChatId(globalOpts);
13041
13435
  const config2 = {};
@@ -13069,7 +13463,7 @@ async function configGet(globalOpts, key) {
13069
13463
  outputError("DB_NOT_FOUND", "Database not found.");
13070
13464
  process.exit(1);
13071
13465
  }
13072
- const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports2));
13466
+ const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
13073
13467
  const readDb = openDatabaseReadOnly2();
13074
13468
  const chatId = resolveChatId(globalOpts);
13075
13469
  const { table, col } = KEY_TABLE_MAP[key];
@@ -13170,7 +13564,7 @@ async function sessionGet(globalOpts) {
13170
13564
  outputError("DB_NOT_FOUND", "Database not found.");
13171
13565
  process.exit(1);
13172
13566
  }
13173
- const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports2));
13567
+ const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
13174
13568
  const readDb = openDatabaseReadOnly2();
13175
13569
  const chatId = resolveChatId(globalOpts);
13176
13570
  const session2 = readDb.prepare("SELECT * FROM sessions WHERE chat_id = ?").get(chatId);
@@ -13236,7 +13630,7 @@ function ensureDb2() {
13236
13630
  }
13237
13631
  async function permissionsGet(globalOpts) {
13238
13632
  ensureDb2();
13239
- const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports2));
13633
+ const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
13240
13634
  const readDb = openDatabaseReadOnly2();
13241
13635
  const chatId = resolveChatId(globalOpts);
13242
13636
  const row = readDb.prepare("SELECT mode FROM chat_mode WHERE chat_id = ?").get(chatId);
@@ -13268,7 +13662,7 @@ async function permissionsSet(globalOpts, mode) {
13268
13662
  }
13269
13663
  async function toolsList(globalOpts) {
13270
13664
  ensureDb2();
13271
- const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports2));
13665
+ const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
13272
13666
  const readDb = openDatabaseReadOnly2();
13273
13667
  const chatId = resolveChatId(globalOpts);
13274
13668
  const rows = readDb.prepare("SELECT tool, enabled FROM chat_tools WHERE chat_id = ?").all(chatId);
@@ -13329,7 +13723,7 @@ async function toggleTool2(globalOpts, name, enabled) {
13329
13723
  }
13330
13724
  async function verboseGet(globalOpts) {
13331
13725
  ensureDb2();
13332
- const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports2));
13726
+ const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
13333
13727
  const readDb = openDatabaseReadOnly2();
13334
13728
  const chatId = resolveChatId(globalOpts);
13335
13729
  const row = readDb.prepare("SELECT level FROM chat_verbose WHERE chat_id = ?").get(chatId);
@@ -13381,7 +13775,7 @@ async function cwdGet(globalOpts) {
13381
13775
  outputError("DB_NOT_FOUND", "Database not found.");
13382
13776
  process.exit(1);
13383
13777
  }
13384
- const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports2));
13778
+ const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
13385
13779
  const readDb = openDatabaseReadOnly2();
13386
13780
  const chatId = resolveChatId(globalOpts);
13387
13781
  const row = readDb.prepare("SELECT cwd FROM chat_cwd WHERE chat_id = ?").get(chatId);
@@ -13445,7 +13839,7 @@ async function voiceGet(globalOpts) {
13445
13839
  outputError("DB_NOT_FOUND", "Database not found.");
13446
13840
  process.exit(1);
13447
13841
  }
13448
- const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports2));
13842
+ const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
13449
13843
  const readDb = openDatabaseReadOnly2();
13450
13844
  const chatId = resolveChatId(globalOpts);
13451
13845
  const row = readDb.prepare("SELECT enabled FROM chat_voice WHERE chat_id = ?").get(chatId);
@@ -13496,7 +13890,7 @@ async function heartbeatGet(globalOpts) {
13496
13890
  outputError("DB_NOT_FOUND", "Database not found.");
13497
13891
  process.exit(1);
13498
13892
  }
13499
- const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports2));
13893
+ const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
13500
13894
  const readDb = openDatabaseReadOnly2();
13501
13895
  const chatId = resolveChatId(globalOpts);
13502
13896
  const row = readDb.prepare("SELECT * FROM chat_heartbeat WHERE chat_id = ?").get(chatId);
@@ -13608,7 +14002,7 @@ async function chatsList(_globalOpts) {
13608
14002
  outputError("DB_NOT_FOUND", "Database not found.");
13609
14003
  process.exit(1);
13610
14004
  }
13611
- const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports2));
14005
+ const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
13612
14006
  const readDb = openDatabaseReadOnly2();
13613
14007
  const aliases = readDb.prepare("SELECT alias, chat_id FROM chat_aliases ORDER BY alias").all();
13614
14008
  readDb.close();
@@ -13738,7 +14132,7 @@ async function mcpsList(_globalOpts) {
13738
14132
  outputError("DB_NOT_FOUND", "Database not found.");
13739
14133
  process.exit(1);
13740
14134
  }
13741
- const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports2));
14135
+ const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
13742
14136
  const readDb = openDatabaseReadOnly2();
13743
14137
  const mcps2 = readDb.prepare("SELECT * FROM mcp_servers ORDER BY name").all();
13744
14138
  readDb.close();
@@ -13749,7 +14143,7 @@ async function mcpsList(_globalOpts) {
13749
14143
  `;
13750
14144
  const lines = ["", divider(`MCP Servers (${list.length})`), ""];
13751
14145
  for (const m of list) {
13752
- const auto = m.enabled_by_default ? " \u{1F4CC}" : "";
14146
+ const auto = m.enabledByDefault ? " \u{1F4CC}" : "";
13753
14147
  const desc = m.description ? ` \u2014 ${m.description}` : "";
13754
14148
  lines.push(` ${checkMark(true)} ${m.name}${auto}${desc}`);
13755
14149
  }
@@ -14855,7 +15249,7 @@ summarizer.command("get").description("Current summarizer config").action(async
14855
15249
  outputError3("DB_NOT_FOUND", "Database not found.");
14856
15250
  process.exit(1);
14857
15251
  }
14858
- const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports2));
15252
+ const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
14859
15253
  const readDb = openDatabaseReadOnly2();
14860
15254
  const chatId = program.opts().chat ?? "default";
14861
15255
  const row = readDb.prepare("SELECT backend, model FROM chat_summarizer WHERE chat_id = ?").get(chatId);
@@ -14891,7 +15285,7 @@ thinking.command("get").description("Current thinking level").action(async () =>
14891
15285
  outputError3("DB_NOT_FOUND", "Database not found.");
14892
15286
  process.exit(1);
14893
15287
  }
14894
- const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports2));
15288
+ const { openDatabaseReadOnly: openDatabaseReadOnly2 } = await Promise.resolve().then(() => (init_store4(), store_exports3));
14895
15289
  const readDb = openDatabaseReadOnly2();
14896
15290
  const chatId = program.opts().chat ?? "default";
14897
15291
  const row = readDb.prepare("SELECT level FROM chat_thinking WHERE chat_id = ?").get(chatId);