agentix-cli 0.8.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/README.md +337 -116
  2. package/dist/agent-QYQVGKLM.js +2 -0
  3. package/dist/chunk-34UAFPK4.js +10 -0
  4. package/dist/chunk-34UAFPK4.js.map +1 -0
  5. package/dist/{chunk-X7UN6JAA.js → chunk-6MKAXEE5.js} +2 -2
  6. package/dist/chunk-BAIQJHQF.js +64 -0
  7. package/dist/chunk-BAIQJHQF.js.map +1 -0
  8. package/dist/chunk-BHDLKX3G.js +6 -0
  9. package/dist/chunk-BHDLKX3G.js.map +1 -0
  10. package/dist/chunk-CJ45Y2IR.js +12 -0
  11. package/dist/chunk-CJ45Y2IR.js.map +1 -0
  12. package/dist/chunk-DSYKYZMT.js +2 -0
  13. package/dist/chunk-DSYKYZMT.js.map +1 -0
  14. package/dist/chunk-IVVVYXPH.js +136 -0
  15. package/dist/chunk-IVVVYXPH.js.map +1 -0
  16. package/dist/{chunk-MGMZNJCE.js → chunk-KXZMYLHQ.js} +27 -27
  17. package/dist/chunk-KXZMYLHQ.js.map +1 -0
  18. package/dist/chunk-SBUX74OU.js +108 -0
  19. package/dist/chunk-SBUX74OU.js.map +1 -0
  20. package/dist/chunk-X32247GM.js +2 -0
  21. package/dist/chunk-X32247GM.js.map +1 -0
  22. package/dist/chunk-ZRYBSI5G.js +23 -0
  23. package/dist/chunk-ZRYBSI5G.js.map +1 -0
  24. package/dist/cli.js +280 -36
  25. package/dist/cli.js.map +1 -1
  26. package/dist/compaction-E3MQRLTL.js +28 -0
  27. package/dist/compaction-E3MQRLTL.js.map +1 -0
  28. package/dist/config-MSWKC466.js +2 -0
  29. package/dist/debug-N3B5NVJU.js +2 -0
  30. package/dist/heal-OTGT5HHJ.js +2 -0
  31. package/dist/heal-OTGT5HHJ.js.map +1 -0
  32. package/dist/index.d.ts +712 -239
  33. package/dist/index.js +2 -2
  34. package/dist/index.js.map +1 -1
  35. package/dist/memory-extract-RGPUPMKU.js +2 -0
  36. package/dist/memory-extract-RGPUPMKU.js.map +1 -0
  37. package/dist/{providers-AVYG63KK.js → providers-G3WZ4RVJ.js} +2 -2
  38. package/dist/providers-G3WZ4RVJ.js.map +1 -0
  39. package/dist/registry-FP6FUOXF.js +2 -0
  40. package/dist/registry-FP6FUOXF.js.map +1 -0
  41. package/dist/subagent-WV7QKQ3L.js +3 -0
  42. package/dist/subagent-WV7QKQ3L.js.map +1 -0
  43. package/dist/usage-dashboard-2TJQBFSH.js +404 -0
  44. package/dist/usage-dashboard-2TJQBFSH.js.map +1 -0
  45. package/package.json +4 -1
  46. package/dist/agent-K2YOEOJ5.js +0 -2
  47. package/dist/chunk-F73GPYCO.js +0 -106
  48. package/dist/chunk-F73GPYCO.js.map +0 -1
  49. package/dist/chunk-MGMZNJCE.js.map +0 -1
  50. package/dist/chunk-NGKOM4ZZ.js +0 -137
  51. package/dist/chunk-NGKOM4ZZ.js.map +0 -1
  52. package/dist/chunk-Z4GC5D6D.js +0 -12
  53. package/dist/chunk-Z4GC5D6D.js.map +0 -1
  54. package/dist/heal-UV5A6B5T.js +0 -2
  55. /package/dist/{agent-K2YOEOJ5.js.map → agent-QYQVGKLM.js.map} +0 -0
  56. /package/dist/{chunk-X7UN6JAA.js.map → chunk-6MKAXEE5.js.map} +0 -0
  57. /package/dist/{heal-UV5A6B5T.js.map → config-MSWKC466.js.map} +0 -0
  58. /package/dist/{providers-AVYG63KK.js.map → debug-N3B5NVJU.js.map} +0 -0
package/dist/index.d.ts CHANGED
@@ -598,6 +598,7 @@ declare class ToolExecutor {
598
598
  private runCommand;
599
599
  private editFile;
600
600
  private createFiles;
601
+ private spawnAgent;
601
602
  private askUser;
602
603
  }
603
604
 
@@ -809,15 +810,22 @@ declare class UsageTracker {
809
810
  }
810
811
  declare const globalTracker: UsageTracker;
811
812
 
812
- declare function setDebug(enabled: boolean): void;
813
- declare function isDebug(): boolean;
813
+ type DebugCategory = "webhook" | "agent" | "channel" | "cron" | "mesh" | "context" | "memory" | "config" | "all";
814
+ declare function setDebug(enabled: boolean, categories?: DebugCategory[]): void;
815
+ declare function isDebug(category?: DebugCategory): boolean;
814
816
  declare const debug: {
815
817
  log(...args: unknown[]): void;
818
+ /** Log with a specific category — only outputs if that category is enabled */
819
+ cat(category: DebugCategory, message: string, ...extra: unknown[]): void;
816
820
  step(step: number, message: string): void;
817
821
  hook(name: string, duration: number, result: string): void;
818
822
  api(method: string, model: string, tokens?: number): void;
819
823
  tokens(input: number, output: number, cost: number): void;
820
824
  context(label: string, detail: string): void;
825
+ /** Log webhook event with full payload summary */
826
+ webhook(channel: string, event: string, detail: string): void;
827
+ /** Log channel lifecycle event */
828
+ channel(name: string, event: string, detail?: string): void;
821
829
  };
822
830
 
823
831
  interface Session {
@@ -1277,6 +1285,23 @@ declare const agentConfigSchema: z.ZodObject<{
1277
1285
  mentions: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
1278
1286
  maxConcurrent: z.ZodDefault<z.ZodNumber>;
1279
1287
  permissionMode: z.ZodDefault<z.ZodString>;
1288
+ queueMode: z.ZodDefault<z.ZodEnum<["collect", "followup", "drop"]>>;
1289
+ heartbeat: z.ZodDefault<z.ZodObject<{
1290
+ enabled: z.ZodDefault<z.ZodBoolean>;
1291
+ intervalMinutes: z.ZodDefault<z.ZodNumber>;
1292
+ prompt: z.ZodDefault<z.ZodString>;
1293
+ channel: z.ZodDefault<z.ZodString>;
1294
+ }, "strip", z.ZodTypeAny, {
1295
+ enabled: boolean;
1296
+ prompt: string;
1297
+ channel: string;
1298
+ intervalMinutes: number;
1299
+ }, {
1300
+ enabled?: boolean | undefined;
1301
+ prompt?: string | undefined;
1302
+ channel?: string | undefined;
1303
+ intervalMinutes?: number | undefined;
1304
+ }>>;
1280
1305
  }, "strip", z.ZodTypeAny, {
1281
1306
  name: string;
1282
1307
  workspace: string;
@@ -1284,6 +1309,13 @@ declare const agentConfigSchema: z.ZodObject<{
1284
1309
  mentions: string[];
1285
1310
  maxConcurrent: number;
1286
1311
  permissionMode: string;
1312
+ queueMode: "collect" | "followup" | "drop";
1313
+ heartbeat: {
1314
+ enabled: boolean;
1315
+ prompt: string;
1316
+ channel: string;
1317
+ intervalMinutes: number;
1318
+ };
1287
1319
  provider?: string | undefined;
1288
1320
  model?: string | undefined;
1289
1321
  systemPrompt?: string | undefined;
@@ -1292,11 +1324,18 @@ declare const agentConfigSchema: z.ZodObject<{
1292
1324
  workspace: string;
1293
1325
  provider?: string | undefined;
1294
1326
  model?: string | undefined;
1295
- systemPrompt?: string | undefined;
1296
1327
  tier?: "claude-code" | "sdk" | "orchestrator" | undefined;
1328
+ systemPrompt?: string | undefined;
1297
1329
  mentions?: string[] | undefined;
1298
1330
  maxConcurrent?: number | undefined;
1299
1331
  permissionMode?: string | undefined;
1332
+ queueMode?: "collect" | "followup" | "drop" | undefined;
1333
+ heartbeat?: {
1334
+ enabled?: boolean | undefined;
1335
+ prompt?: string | undefined;
1336
+ channel?: string | undefined;
1337
+ intervalMinutes?: number | undefined;
1338
+ } | undefined;
1300
1339
  }>;
1301
1340
  declare const cronJobSchema: z.ZodObject<{
1302
1341
  enabled: z.ZodDefault<z.ZodBoolean>;
@@ -1307,15 +1346,33 @@ declare const cronJobSchema: z.ZodObject<{
1307
1346
  timeout: z.ZodDefault<z.ZodNumber>;
1308
1347
  model: z.ZodOptional<z.ZodString>;
1309
1348
  onError: z.ZodDefault<z.ZodEnum<["log", "notify", "disable"]>>;
1349
+ notify: z.ZodOptional<z.ZodObject<{
1350
+ channel: z.ZodString;
1351
+ chatId: z.ZodString;
1352
+ accountId: z.ZodOptional<z.ZodString>;
1353
+ }, "strip", z.ZodTypeAny, {
1354
+ channel: string;
1355
+ chatId: string;
1356
+ accountId?: string | undefined;
1357
+ }, {
1358
+ channel: string;
1359
+ chatId: string;
1360
+ accountId?: string | undefined;
1361
+ }>>;
1310
1362
  }, "strip", z.ZodTypeAny, {
1311
1363
  enabled: boolean;
1312
1364
  agent: string;
1313
- timeout: number;
1314
1365
  prompt: string;
1366
+ timeout: number;
1315
1367
  schedule: string;
1316
1368
  timezone: string;
1317
1369
  onError: "log" | "notify" | "disable";
1318
1370
  model?: string | undefined;
1371
+ notify?: {
1372
+ channel: string;
1373
+ chatId: string;
1374
+ accountId?: string | undefined;
1375
+ } | undefined;
1319
1376
  }, {
1320
1377
  agent: string;
1321
1378
  prompt: string;
@@ -1324,6 +1381,11 @@ declare const cronJobSchema: z.ZodObject<{
1324
1381
  enabled?: boolean | undefined;
1325
1382
  timeout?: number | undefined;
1326
1383
  timezone?: string | undefined;
1384
+ notify?: {
1385
+ channel: string;
1386
+ chatId: string;
1387
+ accountId?: string | undefined;
1388
+ } | undefined;
1327
1389
  onError?: "log" | "notify" | "disable" | undefined;
1328
1390
  }>;
1329
1391
  declare const meshPeerSchema: z.ZodObject<{
@@ -1376,6 +1438,23 @@ declare const daemonConfigSchema: z.ZodObject<{
1376
1438
  mentions: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
1377
1439
  maxConcurrent: z.ZodDefault<z.ZodNumber>;
1378
1440
  permissionMode: z.ZodDefault<z.ZodString>;
1441
+ queueMode: z.ZodDefault<z.ZodEnum<["collect", "followup", "drop"]>>;
1442
+ heartbeat: z.ZodDefault<z.ZodObject<{
1443
+ enabled: z.ZodDefault<z.ZodBoolean>;
1444
+ intervalMinutes: z.ZodDefault<z.ZodNumber>;
1445
+ prompt: z.ZodDefault<z.ZodString>;
1446
+ channel: z.ZodDefault<z.ZodString>;
1447
+ }, "strip", z.ZodTypeAny, {
1448
+ enabled: boolean;
1449
+ prompt: string;
1450
+ channel: string;
1451
+ intervalMinutes: number;
1452
+ }, {
1453
+ enabled?: boolean | undefined;
1454
+ prompt?: string | undefined;
1455
+ channel?: string | undefined;
1456
+ intervalMinutes?: number | undefined;
1457
+ }>>;
1379
1458
  }, "strip", z.ZodTypeAny, {
1380
1459
  name: string;
1381
1460
  workspace: string;
@@ -1383,6 +1462,13 @@ declare const daemonConfigSchema: z.ZodObject<{
1383
1462
  mentions: string[];
1384
1463
  maxConcurrent: number;
1385
1464
  permissionMode: string;
1465
+ queueMode: "collect" | "followup" | "drop";
1466
+ heartbeat: {
1467
+ enabled: boolean;
1468
+ prompt: string;
1469
+ channel: string;
1470
+ intervalMinutes: number;
1471
+ };
1386
1472
  provider?: string | undefined;
1387
1473
  model?: string | undefined;
1388
1474
  systemPrompt?: string | undefined;
@@ -1391,11 +1477,18 @@ declare const daemonConfigSchema: z.ZodObject<{
1391
1477
  workspace: string;
1392
1478
  provider?: string | undefined;
1393
1479
  model?: string | undefined;
1394
- systemPrompt?: string | undefined;
1395
1480
  tier?: "claude-code" | "sdk" | "orchestrator" | undefined;
1481
+ systemPrompt?: string | undefined;
1396
1482
  mentions?: string[] | undefined;
1397
1483
  maxConcurrent?: number | undefined;
1398
1484
  permissionMode?: string | undefined;
1485
+ queueMode?: "collect" | "followup" | "drop" | undefined;
1486
+ heartbeat?: {
1487
+ enabled?: boolean | undefined;
1488
+ prompt?: string | undefined;
1489
+ channel?: string | undefined;
1490
+ intervalMinutes?: number | undefined;
1491
+ } | undefined;
1399
1492
  }>>>;
1400
1493
  channels: z.ZodDefault<z.ZodObject<{
1401
1494
  telegram: z.ZodDefault<z.ZodObject<{
@@ -1513,42 +1606,47 @@ declare const daemonConfigSchema: z.ZodObject<{
1513
1606
  agentId: z.ZodString;
1514
1607
  gitlabUsernames: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
1515
1608
  keywords: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
1609
+ token: z.ZodOptional<z.ZodString>;
1516
1610
  }, "strip", z.ZodTypeAny, {
1517
1611
  agentId: string;
1518
1612
  gitlabUsernames: string[];
1519
1613
  keywords: string[];
1614
+ token?: string | undefined;
1520
1615
  }, {
1521
1616
  agentId: string;
1617
+ token?: string | undefined;
1522
1618
  gitlabUsernames?: string[] | undefined;
1523
1619
  keywords?: string[] | undefined;
1524
1620
  }>, "many">>;
1525
1621
  }, "strip", z.ZodTypeAny, {
1526
1622
  enabled: boolean;
1527
- host: string;
1528
1623
  routes: {
1529
1624
  agent: string;
1530
1625
  project: string;
1531
1626
  }[];
1532
1627
  webhookPort: number;
1628
+ host: string;
1533
1629
  agentMappings: {
1534
1630
  agentId: string;
1535
1631
  gitlabUsernames: string[];
1536
1632
  keywords: string[];
1633
+ token?: string | undefined;
1537
1634
  }[];
1538
1635
  token?: string | undefined;
1539
1636
  webhookSecret?: string | undefined;
1540
1637
  }, {
1541
1638
  enabled?: boolean | undefined;
1542
1639
  token?: string | undefined;
1543
- host?: string | undefined;
1544
1640
  routes?: {
1545
1641
  agent: string;
1546
1642
  project: string;
1547
1643
  }[] | undefined;
1548
1644
  webhookPort?: number | undefined;
1549
1645
  webhookSecret?: string | undefined;
1646
+ host?: string | undefined;
1550
1647
  agentMappings?: {
1551
1648
  agentId: string;
1649
+ token?: string | undefined;
1552
1650
  gitlabUsernames?: string[] | undefined;
1553
1651
  keywords?: string[] | undefined;
1554
1652
  }[] | undefined;
@@ -1583,16 +1681,17 @@ declare const daemonConfigSchema: z.ZodObject<{
1583
1681
  };
1584
1682
  gitlab: {
1585
1683
  enabled: boolean;
1586
- host: string;
1587
1684
  routes: {
1588
1685
  agent: string;
1589
1686
  project: string;
1590
1687
  }[];
1591
1688
  webhookPort: number;
1689
+ host: string;
1592
1690
  agentMappings: {
1593
1691
  agentId: string;
1594
1692
  gitlabUsernames: string[];
1595
1693
  keywords: string[];
1694
+ token?: string | undefined;
1596
1695
  }[];
1597
1696
  token?: string | undefined;
1598
1697
  webhookSecret?: string | undefined;
@@ -1628,15 +1727,16 @@ declare const daemonConfigSchema: z.ZodObject<{
1628
1727
  gitlab?: {
1629
1728
  enabled?: boolean | undefined;
1630
1729
  token?: string | undefined;
1631
- host?: string | undefined;
1632
1730
  routes?: {
1633
1731
  agent: string;
1634
1732
  project: string;
1635
1733
  }[] | undefined;
1636
1734
  webhookPort?: number | undefined;
1637
1735
  webhookSecret?: string | undefined;
1736
+ host?: string | undefined;
1638
1737
  agentMappings?: {
1639
1738
  agentId: string;
1739
+ token?: string | undefined;
1640
1740
  gitlabUsernames?: string[] | undefined;
1641
1741
  keywords?: string[] | undefined;
1642
1742
  }[] | undefined;
@@ -1651,15 +1751,33 @@ declare const daemonConfigSchema: z.ZodObject<{
1651
1751
  timeout: z.ZodDefault<z.ZodNumber>;
1652
1752
  model: z.ZodOptional<z.ZodString>;
1653
1753
  onError: z.ZodDefault<z.ZodEnum<["log", "notify", "disable"]>>;
1754
+ notify: z.ZodOptional<z.ZodObject<{
1755
+ channel: z.ZodString;
1756
+ chatId: z.ZodString;
1757
+ accountId: z.ZodOptional<z.ZodString>;
1758
+ }, "strip", z.ZodTypeAny, {
1759
+ channel: string;
1760
+ chatId: string;
1761
+ accountId?: string | undefined;
1762
+ }, {
1763
+ channel: string;
1764
+ chatId: string;
1765
+ accountId?: string | undefined;
1766
+ }>>;
1654
1767
  }, "strip", z.ZodTypeAny, {
1655
1768
  enabled: boolean;
1656
1769
  agent: string;
1657
- timeout: number;
1658
1770
  prompt: string;
1771
+ timeout: number;
1659
1772
  schedule: string;
1660
1773
  timezone: string;
1661
1774
  onError: "log" | "notify" | "disable";
1662
1775
  model?: string | undefined;
1776
+ notify?: {
1777
+ channel: string;
1778
+ chatId: string;
1779
+ accountId?: string | undefined;
1780
+ } | undefined;
1663
1781
  }, {
1664
1782
  agent: string;
1665
1783
  prompt: string;
@@ -1668,6 +1786,11 @@ declare const daemonConfigSchema: z.ZodObject<{
1668
1786
  enabled?: boolean | undefined;
1669
1787
  timeout?: number | undefined;
1670
1788
  timezone?: string | undefined;
1789
+ notify?: {
1790
+ channel: string;
1791
+ chatId: string;
1792
+ accountId?: string | undefined;
1793
+ } | undefined;
1671
1794
  onError?: "log" | "notify" | "disable" | undefined;
1672
1795
  }>>>;
1673
1796
  mesh: z.ZodDefault<z.ZodObject<{
@@ -1729,10 +1852,30 @@ declare const daemonConfigSchema: z.ZodObject<{
1729
1852
  mentions: string[];
1730
1853
  maxConcurrent: number;
1731
1854
  permissionMode: string;
1855
+ queueMode: "collect" | "followup" | "drop";
1856
+ heartbeat: {
1857
+ enabled: boolean;
1858
+ prompt: string;
1859
+ channel: string;
1860
+ intervalMinutes: number;
1861
+ };
1732
1862
  provider?: string | undefined;
1733
1863
  model?: string | undefined;
1734
1864
  systemPrompt?: string | undefined;
1735
1865
  }>;
1866
+ mesh: {
1867
+ enabled: boolean;
1868
+ peers: {
1869
+ name: string;
1870
+ url: string;
1871
+ token?: string | undefined;
1872
+ }[];
1873
+ discovery: "static" | "mdns";
1874
+ healthCheck: {
1875
+ timeout: number;
1876
+ interval: number;
1877
+ };
1878
+ };
1736
1879
  node: {
1737
1880
  id: string;
1738
1881
  name: string;
@@ -1773,16 +1916,17 @@ declare const daemonConfigSchema: z.ZodObject<{
1773
1916
  };
1774
1917
  gitlab: {
1775
1918
  enabled: boolean;
1776
- host: string;
1777
1919
  routes: {
1778
1920
  agent: string;
1779
1921
  project: string;
1780
1922
  }[];
1781
1923
  webhookPort: number;
1924
+ host: string;
1782
1925
  agentMappings: {
1783
1926
  agentId: string;
1784
1927
  gitlabUsernames: string[];
1785
1928
  keywords: string[];
1929
+ token?: string | undefined;
1786
1930
  }[];
1787
1931
  token?: string | undefined;
1788
1932
  webhookSecret?: string | undefined;
@@ -1791,26 +1935,18 @@ declare const daemonConfigSchema: z.ZodObject<{
1791
1935
  crons: Record<string, {
1792
1936
  enabled: boolean;
1793
1937
  agent: string;
1794
- timeout: number;
1795
1938
  prompt: string;
1939
+ timeout: number;
1796
1940
  schedule: string;
1797
1941
  timezone: string;
1798
1942
  onError: "log" | "notify" | "disable";
1799
1943
  model?: string | undefined;
1944
+ notify?: {
1945
+ channel: string;
1946
+ chatId: string;
1947
+ accountId?: string | undefined;
1948
+ } | undefined;
1800
1949
  }>;
1801
- mesh: {
1802
- enabled: boolean;
1803
- peers: {
1804
- name: string;
1805
- url: string;
1806
- token?: string | undefined;
1807
- }[];
1808
- discovery: "static" | "mdns";
1809
- healthCheck: {
1810
- timeout: number;
1811
- interval: number;
1812
- };
1813
- };
1814
1950
  }, {
1815
1951
  node: {
1816
1952
  id: string;
@@ -1822,12 +1958,32 @@ declare const daemonConfigSchema: z.ZodObject<{
1822
1958
  workspace: string;
1823
1959
  provider?: string | undefined;
1824
1960
  model?: string | undefined;
1825
- systemPrompt?: string | undefined;
1826
1961
  tier?: "claude-code" | "sdk" | "orchestrator" | undefined;
1962
+ systemPrompt?: string | undefined;
1827
1963
  mentions?: string[] | undefined;
1828
1964
  maxConcurrent?: number | undefined;
1829
1965
  permissionMode?: string | undefined;
1966
+ queueMode?: "collect" | "followup" | "drop" | undefined;
1967
+ heartbeat?: {
1968
+ enabled?: boolean | undefined;
1969
+ prompt?: string | undefined;
1970
+ channel?: string | undefined;
1971
+ intervalMinutes?: number | undefined;
1972
+ } | undefined;
1830
1973
  }> | undefined;
1974
+ mesh?: {
1975
+ enabled?: boolean | undefined;
1976
+ peers?: {
1977
+ name: string;
1978
+ url: string;
1979
+ token?: string | undefined;
1980
+ }[] | undefined;
1981
+ discovery?: "static" | "mdns" | undefined;
1982
+ healthCheck?: {
1983
+ timeout?: number | undefined;
1984
+ interval?: number | undefined;
1985
+ } | undefined;
1986
+ } | undefined;
1831
1987
  providers?: Record<string, {
1832
1988
  apiKey?: string | undefined;
1833
1989
  defaultModel?: string | undefined;
@@ -1864,15 +2020,16 @@ declare const daemonConfigSchema: z.ZodObject<{
1864
2020
  gitlab?: {
1865
2021
  enabled?: boolean | undefined;
1866
2022
  token?: string | undefined;
1867
- host?: string | undefined;
1868
2023
  routes?: {
1869
2024
  agent: string;
1870
2025
  project: string;
1871
2026
  }[] | undefined;
1872
2027
  webhookPort?: number | undefined;
1873
2028
  webhookSecret?: string | undefined;
2029
+ host?: string | undefined;
1874
2030
  agentMappings?: {
1875
2031
  agentId: string;
2032
+ token?: string | undefined;
1876
2033
  gitlabUsernames?: string[] | undefined;
1877
2034
  keywords?: string[] | undefined;
1878
2035
  }[] | undefined;
@@ -1886,21 +2043,13 @@ declare const daemonConfigSchema: z.ZodObject<{
1886
2043
  enabled?: boolean | undefined;
1887
2044
  timeout?: number | undefined;
1888
2045
  timezone?: string | undefined;
2046
+ notify?: {
2047
+ channel: string;
2048
+ chatId: string;
2049
+ accountId?: string | undefined;
2050
+ } | undefined;
1889
2051
  onError?: "log" | "notify" | "disable" | undefined;
1890
2052
  }> | undefined;
1891
- mesh?: {
1892
- enabled?: boolean | undefined;
1893
- peers?: {
1894
- name: string;
1895
- url: string;
1896
- token?: string | undefined;
1897
- }[] | undefined;
1898
- discovery?: "static" | "mdns" | undefined;
1899
- healthCheck?: {
1900
- timeout?: number | undefined;
1901
- interval?: number | undefined;
1902
- } | undefined;
1903
- } | undefined;
1904
2053
  }>;
1905
2054
  type DaemonConfig = z.infer<typeof daemonConfigSchema>;
1906
2055
  type AgentDef = z.infer<typeof agentConfigSchema>;
@@ -1968,14 +2117,29 @@ declare class AgentXDaemon {
1968
2117
  private cron;
1969
2118
  private mesh?;
1970
2119
  private hooks;
2120
+ private landscape;
2121
+ private heartbeat;
1971
2122
  private httpServer?;
1972
2123
  private webhooks;
1973
2124
  private log;
2125
+ private sseClients;
1974
2126
  constructor(configPath?: string);
1975
2127
  start(): Promise<void>;
1976
2128
  stop(): Promise<void>;
2129
+ private midnightTimer?;
2130
+ private scheduleMidnightHook;
2131
+ private runDailyCostReport;
1977
2132
  private startChannels;
1978
2133
  private startHttpApi;
2134
+ /**
2135
+ * Broadcast an SSE event to all connected clients.
2136
+ */
2137
+ private broadcastSSE;
2138
+ /**
2139
+ * Handle SSE connection for live event streaming.
2140
+ * GET /events — streams daemon logs in real-time.
2141
+ */
2142
+ private handleSSE;
1979
2143
  private handleHttp;
1980
2144
  /**
1981
2145
  * OpenAI-compatible chat completions endpoint.
@@ -2004,6 +2168,79 @@ interface AgentUsage {
2004
2168
  cacheCreateTokens: number;
2005
2169
  totalDuration: number;
2006
2170
  errors: number;
2171
+ model?: string;
2172
+ }
2173
+ interface DailyReport {
2174
+ date: string;
2175
+ totalTasks: number;
2176
+ totalInput: number;
2177
+ totalOutput: number;
2178
+ totalCacheRead: number;
2179
+ totalCacheCreate: number;
2180
+ totalCost: number;
2181
+ topAgent: string;
2182
+ topCost: number;
2183
+ agentCosts: Record<string, number>;
2184
+ }
2185
+ declare class TokenTracker {
2186
+ private dir;
2187
+ private cache;
2188
+ constructor(baseDir?: string);
2189
+ /**
2190
+ * Calculate cost for an agent's usage with cache-aware pricing.
2191
+ */
2192
+ static calculateCost(usage: AgentUsage): number;
2193
+ /**
2194
+ * Record a task execution with real or estimated token counts.
2195
+ */
2196
+ record(agentId: string, duration: number, realUsage?: {
2197
+ inputTokens: number;
2198
+ outputTokens: number;
2199
+ cacheReadTokens: number;
2200
+ cacheCreateTokens: number;
2201
+ }, messageLength?: number, responseLength?: number, error?: boolean, model?: string): void;
2202
+ /**
2203
+ * Get today's usage summary.
2204
+ */
2205
+ today(): DailyUsage;
2206
+ /**
2207
+ * Get usage for a specific date.
2208
+ */
2209
+ getDate(date: string): DailyUsage | null;
2210
+ /**
2211
+ * Generate a daily cost report for a given date.
2212
+ */
2213
+ generateDailyReport(date?: string): DailyReport | null;
2214
+ /**
2215
+ * Append a daily report row to TOKEN_COSTS.md.
2216
+ */
2217
+ appendToTokenCosts(report: DailyReport, filePath?: string): void;
2218
+ /**
2219
+ * Get summary across last N days.
2220
+ */
2221
+ summary(days?: number): {
2222
+ totalTasks: number;
2223
+ totalTokens: number;
2224
+ totalInput: number;
2225
+ totalOutput: number;
2226
+ totalCacheRead: number;
2227
+ totalCacheCreate: number;
2228
+ cacheHitRatio: number;
2229
+ totalErrors: number;
2230
+ totalCost: number;
2231
+ byAgent: Record<string, {
2232
+ tasks: number;
2233
+ input: number;
2234
+ output: number;
2235
+ cacheRead: number;
2236
+ cacheCreate: number;
2237
+ total: number;
2238
+ avgDuration: number;
2239
+ cost: number;
2240
+ }>;
2241
+ };
2242
+ private filePath;
2243
+ private save;
2007
2244
  }
2008
2245
 
2009
2246
  interface AgentPeer {
@@ -2018,7 +2255,13 @@ interface AgentTask {
2018
2255
  context?: {
2019
2256
  channel?: string;
2020
2257
  sender?: string;
2258
+ /** Platform user ID (e.g. Telegram user ID) */
2259
+ senderId?: string;
2260
+ /** Platform username (e.g. @username) */
2261
+ senderUsername?: string;
2021
2262
  group?: string;
2263
+ /** Stable chat ID for session keying (e.g. "project:issue:123" for GitLab) */
2264
+ chatId?: string;
2022
2265
  /** Attached media file (image, audio, video, document) */
2023
2266
  mediaPath?: string;
2024
2267
  mediaType?: string;
@@ -2032,6 +2275,21 @@ interface AgentTask {
2032
2275
  myHandle?: string;
2033
2276
  /** Other available agents and their handles */
2034
2277
  peers?: AgentPeer[];
2278
+ /** Verified channel metadata (from adapter) */
2279
+ channelMeta?: {
2280
+ agents?: Array<{
2281
+ id: string;
2282
+ name: string;
2283
+ handle?: string;
2284
+ }>;
2285
+ project?: string;
2286
+ issue?: {
2287
+ type: string;
2288
+ iid: string;
2289
+ title: string;
2290
+ };
2291
+ facts?: string[];
2292
+ };
2035
2293
  };
2036
2294
  }
2037
2295
  interface AgentResponse {
@@ -2074,62 +2332,335 @@ declare function executeTask(agent: AgentDef, task: AgentTask, providers: Record
2074
2332
  apiKey?: string;
2075
2333
  }>, onDelta?: StreamCallback, historyContext?: string, resumeSessionId?: string): Promise<AgentResponse>;
2076
2334
 
2077
- declare class AgentRegistry {
2078
- private agents;
2079
- private config;
2080
- private providers;
2081
- private sessions;
2082
- private wikis;
2083
- private rateLimiter;
2084
- private tokenTracker;
2335
+ type WikiAccess = "private" | "shared" | "public";
2336
+ /**
2337
+ * Article metadata. Intentionally minimal — tags do the heavy lifting.
2338
+ */
2339
+ interface WikiArticleMeta {
2340
+ title: string;
2341
+ tags: string[];
2342
+ owner: string;
2343
+ access: WikiAccess;
2344
+ sharedWith?: string[];
2345
+ created: string;
2346
+ lastUpdated: string;
2347
+ sources: string[];
2348
+ }
2349
+ interface WikiArticle {
2350
+ meta: WikiArticleMeta;
2351
+ content: string;
2352
+ path: string;
2353
+ }
2354
+ interface WikiEntry {
2355
+ id: string;
2356
+ date: string;
2357
+ agentId: string;
2358
+ source: string;
2359
+ sourceContext?: string;
2360
+ content: string;
2361
+ meta?: Record<string, unknown>;
2362
+ }
2363
+ interface WikiIndex {
2364
+ articles: Array<{
2365
+ path: string;
2366
+ title: string;
2367
+ tags: string[];
2368
+ owner: string;
2369
+ access: WikiAccess;
2370
+ sharedWith?: string[];
2371
+ aliases: string[];
2372
+ backlinks: number;
2373
+ sources?: string[];
2374
+ lastUpdated?: string;
2375
+ }>;
2376
+ lastRebuilt: string;
2377
+ }
2378
+
2379
+ declare class WikiStore {
2380
+ private baseDir;
2381
+ private rawDir;
2085
2382
  private log;
2086
- constructor(config: DaemonConfig, log?: (...args: unknown[]) => void);
2383
+ constructor(baseDir?: string, log?: (...args: unknown[]) => void);
2087
2384
  /**
2088
- * Get agent definition by ID.
2385
+ * Check if an agent can read an article.
2089
2386
  */
2090
- getAgent(id: string): AgentDef | undefined;
2387
+ canRead(article: WikiArticleMeta, agentId?: string): boolean;
2091
2388
  /**
2092
- * Find agent by mention pattern (e.g., "@nadia" -> "marketing-agent").
2093
- * Returns the agent with the longest (most specific) mention match.
2389
+ * Check if an agent can write an article.
2094
2390
  */
2095
- findByMention(text: string): string | undefined;
2391
+ canWrite(article: WikiArticleMeta, agentId: string): boolean;
2096
2392
  /**
2097
- * Find ALL agents mentioned in text (for bot-to-bot detection).
2393
+ * Add a raw entry (from a conversation, cron result, etc.)
2098
2394
  */
2099
- findAllMentioned(text: string): string[];
2395
+ addEntry(entry: WikiEntry): string;
2100
2396
  /**
2101
- * Get or create per-agent wiki (Karpathy design: each agent has its own knowledge base).
2397
+ * List raw entries, optionally filtered by agent or date range.
2102
2398
  */
2103
- private getWiki;
2399
+ listEntries(filter?: {
2400
+ agentId?: string;
2401
+ after?: string;
2402
+ before?: string;
2403
+ }): WikiEntry[];
2404
+ private parseEntry;
2104
2405
  /**
2105
- * Build peer list for context engine.
2406
+ * Write or update a wiki article.
2106
2407
  */
2107
- private buildPeerList;
2408
+ writeArticle(path: string, meta: WikiArticleMeta, content: string, agentId: string): boolean;
2108
2409
  /**
2109
- * Get the primary channel handle for an agent (e.g. "@noqta_devops_bot" on telegram).
2410
+ * Read an article. Returns null if not found.
2110
2411
  */
2111
- private getChannelHandle;
2412
+ readArticle(path: string): WikiArticle | null;
2112
2413
  /**
2113
- * Execute a task on an agent. Respects maxConcurrent limit.
2414
+ * Read an article with permission check.
2114
2415
  */
2115
- execute(task: AgentTask, onDelta?: StreamCallback): Promise<AgentResponse>;
2416
+ readArticleAs(path: string, agentId: string): WikiArticle | null;
2417
+ private parseArticle;
2116
2418
  /**
2117
- * List all agents and their status.
2419
+ * List all articles accessible to an agent.
2118
2420
  */
2119
- list(): Array<{
2120
- id: string;
2121
- name: string;
2122
- tier: string;
2123
- workspace: string;
2124
- active: number;
2125
- total: number;
2126
- errors: number;
2127
- lastActive?: Date;
2128
- }>;
2421
+ listArticles(agentId: string): WikiArticle[];
2129
2422
  /**
2130
- * Get token usage summary.
2423
+ * Search articles by keyword. Returns articles the agent can read.
2131
2424
  */
2132
- getUsage(days?: number): {
2425
+ search(query: string, agentId: string, maxResults?: number): WikiArticle[];
2426
+ /**
2427
+ * Find articles relevant to a message (for context injection).
2428
+ * Extracts keywords from the message and searches the wiki.
2429
+ */
2430
+ findRelevant(message: string, agentId?: string, maxArticles?: number): WikiArticle[];
2431
+ /**
2432
+ * Build context string from relevant wiki articles for prompt injection.
2433
+ * Token-efficient: includes title + first ~500 chars of each article.
2434
+ */
2435
+ buildContext(articles: WikiArticle[], maxChars?: number): string;
2436
+ /**
2437
+ * Rebuild the master index.
2438
+ */
2439
+ rebuildIndex(): WikiIndex;
2440
+ /**
2441
+ * Get wiki stats.
2442
+ */
2443
+ stats(): {
2444
+ totalArticles: number;
2445
+ totalEntries: number;
2446
+ articlesByType: Record<string, number>;
2447
+ articlesByAccess: Record<string, number>;
2448
+ articlesByOwner: Record<string, number>;
2449
+ };
2450
+ /**
2451
+ * Append an entry to log.md.
2452
+ * Format: ## [YYYY-MM-DD HH:MM] action | details
2453
+ */
2454
+ appendLog(action: string, details: string): void;
2455
+ /**
2456
+ * Get recent log entries.
2457
+ */
2458
+ getLog(limit?: number): string[];
2459
+ /**
2460
+ * Create _schema.md if it doesn't exist.
2461
+ * This tells the LLM how to operate on the wiki.
2462
+ */
2463
+ private ensureSchema;
2464
+ /**
2465
+ * Extract all [[wikilinks]] from article content.
2466
+ */
2467
+ extractWikilinks(content: string): string[];
2468
+ /**
2469
+ * Build backlinks index: for each article, which other articles link to it.
2470
+ */
2471
+ buildBacklinks(): Record<string, string[]>;
2472
+ /**
2473
+ * Get backlinks for a specific article title.
2474
+ */
2475
+ getBacklinks(title: string): string[];
2476
+ /**
2477
+ * Find articles matching ANY of the given tags.
2478
+ * This is how agents get relevant context — only articles tagged with
2479
+ * the client/project/topic they're working on.
2480
+ */
2481
+ findByTags(tags: string[], agentId?: string, limit?: number): WikiArticle[];
2482
+ /**
2483
+ * Get all unique tags across all articles.
2484
+ */
2485
+ getAllTags(): Map<string, number>;
2486
+ /**
2487
+ * Get the worldview file. This is the user's description of their world —
2488
+ * the LLM uses it during absorb to know where things go.
2489
+ * Returns null if not set.
2490
+ */
2491
+ getWorldview(): string | null;
2492
+ /**
2493
+ * Set the worldview. The user describes their world: companies, clients,
2494
+ * projects, team, processes. The LLM uses this as context during absorb.
2495
+ */
2496
+ setWorldview(content: string): void;
2497
+ /**
2498
+ * Run a lint pass on the wiki. Returns issues found.
2499
+ */
2500
+ lint(): Array<{
2501
+ type: string;
2502
+ article: string;
2503
+ message: string;
2504
+ }>;
2505
+ /**
2506
+ * Get unabsorbed entries (entries not referenced by any article's sources field).
2507
+ */
2508
+ getUnabsorbedEntries(): WikiEntry[];
2509
+ /**
2510
+ * Build an absorb prompt for unprocessed entries.
2511
+ * Returns a prompt string an agent can execute to compile entries into articles.
2512
+ */
2513
+ buildAbsorbPrompt(maxEntries?: number): string | null;
2514
+ private walkDir;
2515
+ }
2516
+
2517
+ type WikiMode = "flat" | "graph" | "unified";
2518
+ /**
2519
+ * WikiHub: manages per-agent wikis with a shared raw entry pool.
2520
+ * Supports two compilation modes:
2521
+ * - flat: Karpathy pattern — tags, LLM-chosen paths, worldview, gap detection
2522
+ * - graph: Knowledge graph — kind, parent, hierarchy, events, entities
2523
+ *
2524
+ * Both modes share the same raw entries. Articles stored separately:
2525
+ * agents/<id>/flat/ ← Karpathy compilation
2526
+ * agents/<id>/graph/ ← Knowledge graph compilation
2527
+ */
2528
+ declare class WikiHub {
2529
+ private baseDir;
2530
+ private agentsDir;
2531
+ private mode;
2532
+ private sharedStore;
2533
+ private agentStores;
2534
+ private log;
2535
+ constructor(baseDir?: string, log?: (...args: unknown[]) => void, mode?: WikiMode);
2536
+ getMode(): WikiMode;
2537
+ /**
2538
+ * Get or create the wiki store for a specific agent (mode-aware).
2539
+ * flat: agents/<id>/flat/
2540
+ * graph: agents/<id>/graph/
2541
+ */
2542
+ getAgentWiki(agentId: string): WikiStore;
2543
+ getSharedStore(): WikiStore;
2544
+ listAgents(): string[];
2545
+ getAgentEntries(agentId: string): WikiEntry[];
2546
+ getUnabsorbedEntries(agentId: string): WikiEntry[];
2547
+ summary(): AgentWikiSummary[];
2548
+ }
2549
+ interface AgentWikiSummary {
2550
+ agentId: string;
2551
+ totalEntries: number;
2552
+ totalArticles: number;
2553
+ unabsorbed: number;
2554
+ articles: Array<{
2555
+ title: string;
2556
+ path: string;
2557
+ tags?: string[];
2558
+ }>;
2559
+ }
2560
+
2561
+ interface MeshPeerInfo {
2562
+ peer: string;
2563
+ healthy: boolean;
2564
+ skills: Array<{
2565
+ id: string;
2566
+ name: string;
2567
+ description: string;
2568
+ }>;
2569
+ }
2570
+ /**
2571
+ * Build and cache per-agent landscape strings.
2572
+ */
2573
+ declare class LandscapeBuilder {
2574
+ private cache;
2575
+ private config;
2576
+ private meshPeers;
2577
+ constructor(config: DaemonConfig);
2578
+ /**
2579
+ * Build landscape strings for all agents. Call at startup.
2580
+ */
2581
+ build(meshPeers?: MeshPeerInfo[]): void;
2582
+ /**
2583
+ * Get the cached landscape string for a specific agent.
2584
+ */
2585
+ getForAgent(agentId: string): string | undefined;
2586
+ /**
2587
+ * Rebuild after mesh topology changes.
2588
+ */
2589
+ refresh(meshPeers: MeshPeerInfo[]): void;
2590
+ private renderForAgent;
2591
+ private renderChannels;
2592
+ /**
2593
+ * Get the primary Telegram handle for an agent (the @username).
2594
+ */
2595
+ private getPrimaryHandle;
2596
+ /**
2597
+ * Extract a short capability description from systemPrompt.
2598
+ * Takes the first sentence, max 80 chars.
2599
+ */
2600
+ private extractCapability;
2601
+ }
2602
+
2603
+ declare class AgentRegistry {
2604
+ private agents;
2605
+ private config;
2606
+ private providers;
2607
+ private sessions;
2608
+ private wikiHub;
2609
+ private memoryStore;
2610
+ private rateLimiter;
2611
+ private tokenTracker;
2612
+ private landscape?;
2613
+ private messageQueue;
2614
+ private log;
2615
+ constructor(config: DaemonConfig, log?: (...args: unknown[]) => void);
2616
+ /**
2617
+ * Set landscape builder (called after mesh init).
2618
+ */
2619
+ setLandscape(builder: LandscapeBuilder): void;
2620
+ /**
2621
+ * Get agent definition by ID.
2622
+ */
2623
+ getAgent(id: string): AgentDef | undefined;
2624
+ /**
2625
+ * Find agent by mention pattern (e.g., "@my_bot" -> "my-agent").
2626
+ * Returns the agent with the longest (most specific) mention match.
2627
+ */
2628
+ findByMention(text: string): string | undefined;
2629
+ /**
2630
+ * Find ALL agents mentioned in text (for bot-to-bot detection).
2631
+ */
2632
+ findAllMentioned(text: string): string[];
2633
+ /** Wiki hub accessor. */
2634
+ getWikiHub(): WikiHub;
2635
+ /**
2636
+ * Build peer list for context engine.
2637
+ */
2638
+ private buildPeerList;
2639
+ /**
2640
+ * Get the primary channel handle for an agent (e.g. "@my_bot" on telegram).
2641
+ */
2642
+ private getChannelHandle;
2643
+ /**
2644
+ * Execute a task on an agent. Respects maxConcurrent limit.
2645
+ */
2646
+ execute(task: AgentTask, onDelta?: StreamCallback): Promise<AgentResponse>;
2647
+ /**
2648
+ * List all agents and their status.
2649
+ */
2650
+ list(): Array<{
2651
+ id: string;
2652
+ name: string;
2653
+ tier: string;
2654
+ workspace: string;
2655
+ active: number;
2656
+ total: number;
2657
+ errors: number;
2658
+ lastActive?: Date;
2659
+ }>;
2660
+ /**
2661
+ * Get token usage summary.
2662
+ */
2663
+ getUsage(days?: number): {
2133
2664
  totalTasks: number;
2134
2665
  totalTokens: number;
2135
2666
  totalInput: number;
@@ -2138,6 +2669,7 @@ declare class AgentRegistry {
2138
2669
  totalCacheCreate: number;
2139
2670
  cacheHitRatio: number;
2140
2671
  totalErrors: number;
2672
+ totalCost: number;
2141
2673
  byAgent: Record<string, {
2142
2674
  tasks: number;
2143
2675
  input: number;
@@ -2146,14 +2678,43 @@ declare class AgentRegistry {
2146
2678
  cacheCreate: number;
2147
2679
  total: number;
2148
2680
  avgDuration: number;
2681
+ cost: number;
2149
2682
  }>;
2150
2683
  };
2151
2684
  /**
2152
2685
  * Get today's usage.
2153
2686
  */
2154
2687
  getTodayUsage(): DailyUsage;
2688
+ /**
2689
+ * Get the token tracker instance (for daemon hooks).
2690
+ */
2691
+ getTokenTracker(): TokenTracker;
2155
2692
  }
2156
2693
 
2694
+ /**
2695
+ * Verified channel context — facts the channel adapter knows for certain.
2696
+ * Prevents agents from hallucinating about their environment.
2697
+ */
2698
+ interface ChannelMeta {
2699
+ /** Channel name */
2700
+ channel: string;
2701
+ /** Verified agents/bots present in this chat/group/project */
2702
+ agents?: Array<{
2703
+ id: string;
2704
+ name: string;
2705
+ handle?: string;
2706
+ }>;
2707
+ /** Project path (GitLab) or group topic */
2708
+ project?: string;
2709
+ /** Issue/MR context (GitLab) */
2710
+ issue?: {
2711
+ type: string;
2712
+ iid: string;
2713
+ title: string;
2714
+ };
2715
+ /** Channel-specific facts (e.g., pipeline status, group description) */
2716
+ facts?: string[];
2717
+ }
2157
2718
  interface IncomingMessage {
2158
2719
  id: string;
2159
2720
  channel: string;
@@ -2178,6 +2739,7 @@ interface IncomingMessage {
2178
2739
  };
2179
2740
  raw?: unknown;
2180
2741
  resolvedAgent?: string;
2742
+ channelMeta?: ChannelMeta;
2181
2743
  }
2182
2744
  interface OutgoingMessage {
2183
2745
  channel: string;
@@ -2185,6 +2747,7 @@ interface OutgoingMessage {
2185
2747
  text: string;
2186
2748
  replyTo?: string;
2187
2749
  parseMode?: "markdown" | "html" | "plain";
2750
+ agentId?: string;
2188
2751
  }
2189
2752
  interface ChannelAdapter {
2190
2753
  readonly name: string;
@@ -2202,6 +2765,8 @@ interface ChannelAdapter {
2202
2765
  react?(chatId: string, messageId: string, emoji?: string): Promise<void>;
2203
2766
  /** Register handler for incoming messages */
2204
2767
  onMessage(handler: (msg: IncomingMessage) => Promise<void>): void;
2768
+ /** Get verified context for a chat (optional — channels implement what they can) */
2769
+ getChannelMeta?(chatId: string): Promise<ChannelMeta | undefined>;
2205
2770
  }
2206
2771
 
2207
2772
  declare class MessageRouter {
@@ -2215,6 +2780,17 @@ declare class MessageRouter {
2215
2780
  constructor(registry: AgentRegistry, config: DaemonConfig, hooks?: HookRegistry, log?: (...args: unknown[]) => void);
2216
2781
  setMesh(mesh: A2AMesh): void;
2217
2782
  addChannel(adapter: ChannelAdapter): void;
2783
+ /**
2784
+ * Send an outbound message to any registered channel.
2785
+ * Used for agent-initiated messages, cron notifications, cross-channel routing.
2786
+ *
2787
+ * If accountId is not provided for Telegram, auto-resolves from agentId binding.
2788
+ */
2789
+ sendOutbound(msg: OutgoingMessage & {
2790
+ accountId?: string;
2791
+ }): Promise<string | void>;
2792
+ /** List registered channel names. */
2793
+ getChannelNames(): string[];
2218
2794
  startAll(): Promise<void>;
2219
2795
  stopAll(): Promise<void>;
2220
2796
  private handleMessage;
@@ -2224,7 +2800,7 @@ declare class MessageRouter {
2224
2800
  * Guards:
2225
2801
  * 1. Max depth (default 3)
2226
2802
  * 2. No agent called twice in the same chain (prevents A→B→A→B loops)
2227
- * 3. Only on channels that support it (Telegram)
2803
+ * Works on Telegram (multi-account), WhatsApp (shared number), Discord.
2228
2804
  */
2229
2805
  private handleBotToBotChain;
2230
2806
  private adapterSend;
@@ -2269,6 +2845,8 @@ declare class TelegramAdapter implements ChannelAdapter {
2269
2845
  private resolveToken;
2270
2846
  /** Track which account a chat was last seen on (for DMs) */
2271
2847
  private chatAccountMap;
2848
+ private botInfo;
2849
+ private groupStore;
2272
2850
  /**
2273
2851
  * Send a message. Returns the sent message ID.
2274
2852
  * Pass accountId to send from a specific bot account.
@@ -2289,6 +2867,16 @@ declare class TelegramAdapter implements ChannelAdapter {
2289
2867
  */
2290
2868
  sendTyping(chatId: string, accountId?: string): Promise<void>;
2291
2869
  private pollLoop;
2870
+ /**
2871
+ * Get verified context for a Telegram chat.
2872
+ * Reads from persistent group store (fed by my_chat_member events + API seed).
2873
+ */
2874
+ getChannelMeta(chatId: string): Promise<ChannelMeta | undefined>;
2875
+ /**
2876
+ * Seed group membership by querying the Telegram API for each bot.
2877
+ * Called once per group on first encounter, then maintained via my_chat_member events.
2878
+ */
2879
+ private seedGroupMembership;
2292
2880
  private apiCall;
2293
2881
  }
2294
2882
 
@@ -2305,6 +2893,9 @@ declare class WhatsAppAdapter implements ChannelAdapter {
2305
2893
  private routes;
2306
2894
  private handler?;
2307
2895
  private sock;
2896
+ private reconnectAttempts;
2897
+ /** Generation counter — incremented on each start() to ignore stale socket events */
2898
+ private generation;
2308
2899
  private sentMessageIds;
2309
2900
  private log;
2310
2901
  constructor(config: {
@@ -2338,8 +2929,13 @@ interface CronJobState {
2338
2929
  onError: "log" | "notify" | "disable";
2339
2930
  lastRun?: Date;
2340
2931
  nextRun?: Date;
2932
+ lastSuccess?: Date;
2933
+ lastError?: string;
2341
2934
  consecutiveErrors: number;
2342
2935
  totalRuns: number;
2936
+ totalFailures: number;
2937
+ /** Whether a retry is currently pending */
2938
+ retryPending?: boolean;
2343
2939
  }
2344
2940
  interface CronRunResult {
2345
2941
  jobId: string;
@@ -2349,190 +2945,67 @@ interface CronRunResult {
2349
2945
  response?: string;
2350
2946
  error?: string;
2351
2947
  duration: number;
2948
+ /** Was this a retry attempt? */
2949
+ isRetry?: boolean;
2950
+ retryAttempt?: number;
2352
2951
  }
2353
2952
 
2953
+ /** Notification callback — injected by daemon to send alerts via channels */
2954
+ type CronNotifyCallback = (jobId: string, agent: string, error: string, consecutiveErrors: number) => Promise<void>;
2354
2955
  declare class CronScheduler {
2355
2956
  private jobs;
2356
2957
  private timers;
2357
2958
  private registry;
2358
2959
  private hooks?;
2359
2960
  private runsDir;
2961
+ private lastRunFile;
2360
2962
  private running;
2963
+ private notifyCallback?;
2361
2964
  private log;
2362
2965
  constructor(config: DaemonConfig, registry: AgentRegistry, hooks?: HookRegistry, log?: (...args: unknown[]) => void);
2966
+ /**
2967
+ * Set a notification callback for failed crons.
2968
+ * Called when onError is "notify" or after multiple consecutive failures.
2969
+ */
2970
+ setNotifyCallback(cb: CronNotifyCallback): void;
2363
2971
  start(): Promise<void>;
2364
2972
  stop(): Promise<void>;
2365
2973
  private scheduleNext;
2974
+ private scheduleRetry;
2366
2975
  private executeJob;
2367
- private logRun;
2368
- /**
2369
- * List all jobs and their status.
2370
- */
2371
- list(): CronJobState[];
2372
- }
2373
-
2374
- /**
2375
- * Access levels for wiki articles:
2376
- * - private: only the owning agent can read/write
2377
- * - shared: specific agents listed in `sharedWith` can read, owner can write
2378
- * - public: all agents on this node can read, owner can write
2379
- */
2380
- type WikiAccess = "private" | "shared" | "public";
2381
- interface WikiArticleMeta {
2382
- title: string;
2383
- type: string;
2384
- owner: string;
2385
- access: WikiAccess;
2386
- sharedWith?: string[];
2387
- created: string;
2388
- lastUpdated: string;
2389
- related: string[];
2390
- sources: string[];
2391
- tags?: string[];
2392
- }
2393
- interface WikiArticle {
2394
- meta: WikiArticleMeta;
2395
- content: string;
2396
- path: string;
2397
- }
2398
- interface WikiEntry {
2399
- id: string;
2400
- date: string;
2401
- agentId: string;
2402
- source: string;
2403
- sourceContext?: string;
2404
- content: string;
2405
- meta?: Record<string, unknown>;
2406
- }
2407
- interface WikiIndex {
2408
- articles: Array<{
2409
- path: string;
2410
- title: string;
2411
- type: string;
2412
- owner: string;
2413
- access: WikiAccess;
2414
- sharedWith?: string[];
2415
- aliases: string[];
2416
- backlinks: number;
2417
- }>;
2418
- lastRebuilt: string;
2419
- }
2420
-
2421
- declare class WikiStore {
2422
- private baseDir;
2423
- private rawDir;
2424
- private log;
2425
- constructor(baseDir?: string, log?: (...args: unknown[]) => void);
2426
2976
  /**
2427
- * Check if an agent can read an article.
2977
+ * Detect cron jobs that should have fired while the daemon was down.
2978
+ * Compares saved last-run times against the cron schedule.
2428
2979
  */
2429
- canRead(article: WikiArticleMeta, agentId: string): boolean;
2980
+ private detectMissedRuns;
2430
2981
  /**
2431
- * Check if an agent can write an article.
2982
+ * Execute missed runs (catch-up). Runs sequentially to avoid overwhelming agents.
2432
2983
  */
2433
- canWrite(article: WikiArticleMeta, agentId: string): boolean;
2434
- /**
2435
- * Add a raw entry (from a conversation, cron result, etc.)
2436
- */
2437
- addEntry(entry: WikiEntry): string;
2438
- /**
2439
- * List raw entries, optionally filtered by agent or date range.
2440
- */
2441
- listEntries(filter?: {
2442
- agentId?: string;
2443
- after?: string;
2444
- before?: string;
2445
- }): WikiEntry[];
2446
- private parseEntry;
2447
- /**
2448
- * Write or update a wiki article.
2449
- */
2450
- writeArticle(path: string, meta: WikiArticleMeta, content: string, agentId: string): boolean;
2451
- /**
2452
- * Read an article. Returns null if not found.
2453
- */
2454
- readArticle(path: string): WikiArticle | null;
2455
- /**
2456
- * Read an article with permission check.
2457
- */
2458
- readArticleAs(path: string, agentId: string): WikiArticle | null;
2459
- private parseArticle;
2460
- /**
2461
- * List all articles accessible to an agent.
2462
- */
2463
- listArticles(agentId: string): WikiArticle[];
2464
- /**
2465
- * Search articles by keyword. Returns articles the agent can read.
2466
- */
2467
- search(query: string, agentId: string, maxResults?: number): WikiArticle[];
2468
- /**
2469
- * Find articles relevant to a message (for context injection).
2470
- * Extracts keywords from the message and searches the wiki.
2471
- */
2472
- findRelevant(message: string, agentId: string, maxArticles?: number): WikiArticle[];
2473
- /**
2474
- * Build context string from relevant wiki articles for prompt injection.
2475
- * Token-efficient: includes title + first ~500 chars of each article.
2476
- */
2477
- buildContext(articles: WikiArticle[], maxChars?: number): string;
2984
+ private executeMissedRuns;
2985
+ private notifyFailure;
2986
+ private notifyDisabled;
2987
+ private saveLastRuns;
2988
+ private loadLastRuns;
2989
+ private logRun;
2478
2990
  /**
2479
- * Rebuild the master index.
2991
+ * List all jobs and their status (including failure info).
2480
2992
  */
2481
- rebuildIndex(): WikiIndex;
2993
+ list(): CronJobState[];
2482
2994
  /**
2483
- * Get wiki stats.
2484
- */
2485
- stats(): {
2486
- totalArticles: number;
2487
- totalEntries: number;
2488
- articlesByType: Record<string, number>;
2489
- articlesByAccess: Record<string, number>;
2490
- articlesByOwner: Record<string, number>;
2995
+ * Get a health summary of cron jobs.
2996
+ */
2997
+ health(): {
2998
+ healthy: number;
2999
+ failing: number;
3000
+ disabled: number;
3001
+ missed: number;
3002
+ jobs: Array<{
3003
+ id: string;
3004
+ status: string;
3005
+ consecutiveErrors: number;
3006
+ lastError?: string;
3007
+ }>;
2491
3008
  };
2492
- /**
2493
- * Append an entry to log.md.
2494
- * Format: ## [YYYY-MM-DD HH:MM] action | details
2495
- */
2496
- appendLog(action: string, details: string): void;
2497
- /**
2498
- * Get recent log entries.
2499
- */
2500
- getLog(limit?: number): string[];
2501
- /**
2502
- * Create _schema.md if it doesn't exist.
2503
- * This tells the LLM how to operate on the wiki.
2504
- */
2505
- private ensureSchema;
2506
- /**
2507
- * Extract all [[wikilinks]] from article content.
2508
- */
2509
- extractWikilinks(content: string): string[];
2510
- /**
2511
- * Build backlinks index: for each article, which other articles link to it.
2512
- */
2513
- buildBacklinks(): Record<string, string[]>;
2514
- /**
2515
- * Get backlinks for a specific article title.
2516
- */
2517
- getBacklinks(title: string): string[];
2518
- /**
2519
- * Run a lint pass on the wiki. Returns issues found.
2520
- */
2521
- lint(): Array<{
2522
- type: string;
2523
- article: string;
2524
- message: string;
2525
- }>;
2526
- /**
2527
- * Get unabsorbed entries (entries not referenced by any article's sources field).
2528
- */
2529
- getUnabsorbedEntries(): WikiEntry[];
2530
- /**
2531
- * Build an absorb prompt for unprocessed entries.
2532
- * Returns a prompt string an agent can execute to compile entries into articles.
2533
- */
2534
- buildAbsorbPrompt(maxEntries?: number): string | null;
2535
- private walkDir;
2536
3009
  }
2537
3010
 
2538
3011
  interface ProviderCapabilities {