nextclaw-core 0.3.0 → 0.4.1

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 (3) hide show
  1. package/dist/index.d.ts +443 -109
  2. package/dist/index.js +1193 -104
  3. package/package.json +1 -1
package/dist/index.d.ts CHANGED
@@ -67,6 +67,65 @@ declare class ProviderManager {
67
67
  set(next: LLMProvider): void;
68
68
  }
69
69
 
70
+ declare abstract class Tool {
71
+ private static typeMap;
72
+ abstract get name(): string;
73
+ abstract get description(): string;
74
+ abstract get parameters(): Record<string, unknown>;
75
+ abstract execute(params: Record<string, unknown>): Promise<string>;
76
+ validateParams(params: Record<string, unknown>): string[];
77
+ toSchema(): Record<string, unknown>;
78
+ private validateValue;
79
+ }
80
+
81
+ type GatewayConfigSnapshot = {
82
+ raw?: string | null;
83
+ hash?: string | null;
84
+ path?: string;
85
+ config?: Record<string, unknown>;
86
+ parsed?: Record<string, unknown>;
87
+ resolved?: Record<string, unknown>;
88
+ valid?: boolean;
89
+ };
90
+ type GatewayController = {
91
+ status?: () => Promise<Record<string, unknown> | string> | Record<string, unknown> | string;
92
+ reloadConfig?: (reason?: string) => Promise<string | void> | string | void;
93
+ restart?: (options?: {
94
+ delayMs?: number;
95
+ reason?: string;
96
+ }) => Promise<string | void> | string | void;
97
+ getConfig?: () => Promise<GatewayConfigSnapshot | string> | GatewayConfigSnapshot | string;
98
+ getConfigSchema?: () => Promise<Record<string, unknown> | string> | Record<string, unknown> | string;
99
+ applyConfig?: (params: {
100
+ raw: string;
101
+ baseHash?: string;
102
+ note?: string;
103
+ restartDelayMs?: number;
104
+ sessionKey?: string;
105
+ }) => Promise<Record<string, unknown> | string | void> | Record<string, unknown> | string | void;
106
+ patchConfig?: (params: {
107
+ raw: string;
108
+ baseHash?: string;
109
+ note?: string;
110
+ restartDelayMs?: number;
111
+ sessionKey?: string;
112
+ }) => Promise<Record<string, unknown> | string | void> | Record<string, unknown> | string | void;
113
+ updateRun?: (params: {
114
+ note?: string;
115
+ restartDelayMs?: number;
116
+ timeoutMs?: number;
117
+ sessionKey?: string;
118
+ }) => Promise<Record<string, unknown> | string | void> | Record<string, unknown> | string | void;
119
+ };
120
+ declare class GatewayTool extends Tool {
121
+ private controller?;
122
+ constructor(controller?: GatewayController | undefined);
123
+ get name(): string;
124
+ get description(): string;
125
+ get parameters(): Record<string, unknown>;
126
+ execute(params: Record<string, unknown>): Promise<string>;
127
+ }
128
+
70
129
  type SessionMessage = {
71
130
  role: string;
72
131
  content: string;
@@ -87,6 +146,7 @@ declare class SessionManager {
87
146
  constructor(workspace: string);
88
147
  private getSessionPath;
89
148
  getOrCreate(key: string): Session;
149
+ getIfExists(key: string): Session | null;
90
150
  addMessage(session: Session, role: string, content: string, extra?: Record<string, unknown>): void;
91
151
  getHistory(session: Session, maxMessages?: number): Array<Record<string, string>>;
92
152
  clear(session: Session): void;
@@ -168,52 +228,6 @@ declare class CronService {
168
228
  };
169
229
  }
170
230
 
171
- declare class AgentLoop {
172
- private options;
173
- private context;
174
- private sessions;
175
- private tools;
176
- private subagents;
177
- private running;
178
- constructor(options: {
179
- bus: MessageBus;
180
- providerManager: ProviderManager;
181
- workspace: string;
182
- model?: string | null;
183
- maxIterations?: number;
184
- braveApiKey?: string | null;
185
- execConfig?: {
186
- timeout: number;
187
- };
188
- cronService?: CronService | null;
189
- restrictToWorkspace?: boolean;
190
- sessionManager?: SessionManager;
191
- });
192
- private registerDefaultTools;
193
- run(): Promise<void>;
194
- stop(): void;
195
- processDirect(params: {
196
- content: string;
197
- sessionKey?: string;
198
- channel?: string;
199
- chatId?: string;
200
- }): Promise<string>;
201
- private processMessage;
202
- private processSystemMessage;
203
- }
204
-
205
- type FeishuProbeResult = {
206
- ok: true;
207
- appId: string;
208
- botName?: string;
209
- botOpenId?: string;
210
- } | {
211
- ok: false;
212
- appId?: string;
213
- error: string;
214
- };
215
- declare function probeFeishu(appId: string, appSecret: string): Promise<FeishuProbeResult>;
216
-
217
231
  declare const WhatsAppConfigSchema: z.ZodObject<{
218
232
  enabled: z.ZodDefault<z.ZodBoolean>;
219
233
  bridgeUrl: z.ZodDefault<z.ZodString>;
@@ -252,15 +266,15 @@ declare const FeishuConfigSchema: z.ZodObject<{
252
266
  allowFrom: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
253
267
  }, "strip", z.ZodTypeAny, {
254
268
  enabled: boolean;
255
- appId: string;
256
269
  allowFrom: string[];
270
+ appId: string;
257
271
  appSecret: string;
258
272
  encryptKey: string;
259
273
  verificationToken: string;
260
274
  }, {
261
275
  enabled?: boolean | undefined;
262
- appId?: string | undefined;
263
276
  allowFrom?: string[] | undefined;
277
+ appId?: string | undefined;
264
278
  appSecret?: string | undefined;
265
279
  encryptKey?: string | undefined;
266
280
  verificationToken?: string | undefined;
@@ -543,14 +557,14 @@ declare const QQConfigSchema: z.ZodObject<{
543
557
  allowFrom: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
544
558
  }, "strip", z.ZodTypeAny, {
545
559
  enabled: boolean;
546
- appId: string;
547
560
  allowFrom: string[];
561
+ appId: string;
548
562
  secret: string;
549
563
  markdownSupport: boolean;
550
564
  }, {
551
565
  enabled?: boolean | undefined;
552
- appId?: string | undefined;
553
566
  allowFrom?: string[] | undefined;
567
+ appId?: string | undefined;
554
568
  secret?: string | undefined;
555
569
  markdownSupport?: boolean | undefined;
556
570
  }>;
@@ -612,15 +626,15 @@ declare const ChannelsConfigSchema: z.ZodObject<{
612
626
  allowFrom: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
613
627
  }, "strip", z.ZodTypeAny, {
614
628
  enabled: boolean;
615
- appId: string;
616
629
  allowFrom: string[];
630
+ appId: string;
617
631
  appSecret: string;
618
632
  encryptKey: string;
619
633
  verificationToken: string;
620
634
  }, {
621
635
  enabled?: boolean | undefined;
622
- appId?: string | undefined;
623
636
  allowFrom?: string[] | undefined;
637
+ appId?: string | undefined;
624
638
  appSecret?: string | undefined;
625
639
  encryptKey?: string | undefined;
626
640
  verificationToken?: string | undefined;
@@ -857,14 +871,14 @@ declare const ChannelsConfigSchema: z.ZodObject<{
857
871
  allowFrom: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
858
872
  }, "strip", z.ZodTypeAny, {
859
873
  enabled: boolean;
860
- appId: string;
861
874
  allowFrom: string[];
875
+ appId: string;
862
876
  secret: string;
863
877
  markdownSupport: boolean;
864
878
  }, {
865
879
  enabled?: boolean | undefined;
866
- appId?: string | undefined;
867
880
  allowFrom?: string[] | undefined;
881
+ appId?: string | undefined;
868
882
  secret?: string | undefined;
869
883
  markdownSupport?: boolean | undefined;
870
884
  }>>;
@@ -889,8 +903,8 @@ declare const ChannelsConfigSchema: z.ZodObject<{
889
903
  };
890
904
  feishu: {
891
905
  enabled: boolean;
892
- appId: string;
893
906
  allowFrom: string[];
907
+ appId: string;
894
908
  appSecret: string;
895
909
  encryptKey: string;
896
910
  verificationToken: string;
@@ -969,8 +983,8 @@ declare const ChannelsConfigSchema: z.ZodObject<{
969
983
  };
970
984
  qq: {
971
985
  enabled: boolean;
972
- appId: string;
973
986
  allowFrom: string[];
987
+ appId: string;
974
988
  secret: string;
975
989
  markdownSupport: boolean;
976
990
  };
@@ -995,8 +1009,8 @@ declare const ChannelsConfigSchema: z.ZodObject<{
995
1009
  } | undefined;
996
1010
  feishu?: {
997
1011
  enabled?: boolean | undefined;
998
- appId?: string | undefined;
999
1012
  allowFrom?: string[] | undefined;
1013
+ appId?: string | undefined;
1000
1014
  appSecret?: string | undefined;
1001
1015
  encryptKey?: string | undefined;
1002
1016
  verificationToken?: string | undefined;
@@ -1075,8 +1089,8 @@ declare const ChannelsConfigSchema: z.ZodObject<{
1075
1089
  } | undefined;
1076
1090
  qq?: {
1077
1091
  enabled?: boolean | undefined;
1078
- appId?: string | undefined;
1079
1092
  allowFrom?: string[] | undefined;
1093
+ appId?: string | undefined;
1080
1094
  secret?: string | undefined;
1081
1095
  markdownSupport?: boolean | undefined;
1082
1096
  } | undefined;
@@ -1100,6 +1114,90 @@ declare const AgentDefaultsSchema: z.ZodObject<{
1100
1114
  maxTokens?: number | undefined;
1101
1115
  maxToolIterations?: number | undefined;
1102
1116
  }>;
1117
+ declare const ContextBootstrapSchema: z.ZodObject<{
1118
+ files: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
1119
+ minimalFiles: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
1120
+ heartbeatFiles: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
1121
+ perFileChars: z.ZodDefault<z.ZodNumber>;
1122
+ totalChars: z.ZodDefault<z.ZodNumber>;
1123
+ }, "strip", z.ZodTypeAny, {
1124
+ files: string[];
1125
+ minimalFiles: string[];
1126
+ heartbeatFiles: string[];
1127
+ perFileChars: number;
1128
+ totalChars: number;
1129
+ }, {
1130
+ files?: string[] | undefined;
1131
+ minimalFiles?: string[] | undefined;
1132
+ heartbeatFiles?: string[] | undefined;
1133
+ perFileChars?: number | undefined;
1134
+ totalChars?: number | undefined;
1135
+ }>;
1136
+ declare const ContextMemorySchema: z.ZodObject<{
1137
+ enabled: z.ZodDefault<z.ZodBoolean>;
1138
+ maxChars: z.ZodDefault<z.ZodNumber>;
1139
+ }, "strip", z.ZodTypeAny, {
1140
+ enabled: boolean;
1141
+ maxChars: number;
1142
+ }, {
1143
+ enabled?: boolean | undefined;
1144
+ maxChars?: number | undefined;
1145
+ }>;
1146
+ declare const ContextConfigSchema: z.ZodObject<{
1147
+ bootstrap: z.ZodDefault<z.ZodObject<{
1148
+ files: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
1149
+ minimalFiles: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
1150
+ heartbeatFiles: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
1151
+ perFileChars: z.ZodDefault<z.ZodNumber>;
1152
+ totalChars: z.ZodDefault<z.ZodNumber>;
1153
+ }, "strip", z.ZodTypeAny, {
1154
+ files: string[];
1155
+ minimalFiles: string[];
1156
+ heartbeatFiles: string[];
1157
+ perFileChars: number;
1158
+ totalChars: number;
1159
+ }, {
1160
+ files?: string[] | undefined;
1161
+ minimalFiles?: string[] | undefined;
1162
+ heartbeatFiles?: string[] | undefined;
1163
+ perFileChars?: number | undefined;
1164
+ totalChars?: number | undefined;
1165
+ }>>;
1166
+ memory: z.ZodDefault<z.ZodObject<{
1167
+ enabled: z.ZodDefault<z.ZodBoolean>;
1168
+ maxChars: z.ZodDefault<z.ZodNumber>;
1169
+ }, "strip", z.ZodTypeAny, {
1170
+ enabled: boolean;
1171
+ maxChars: number;
1172
+ }, {
1173
+ enabled?: boolean | undefined;
1174
+ maxChars?: number | undefined;
1175
+ }>>;
1176
+ }, "strip", z.ZodTypeAny, {
1177
+ memory: {
1178
+ enabled: boolean;
1179
+ maxChars: number;
1180
+ };
1181
+ bootstrap: {
1182
+ files: string[];
1183
+ minimalFiles: string[];
1184
+ heartbeatFiles: string[];
1185
+ perFileChars: number;
1186
+ totalChars: number;
1187
+ };
1188
+ }, {
1189
+ memory?: {
1190
+ enabled?: boolean | undefined;
1191
+ maxChars?: number | undefined;
1192
+ } | undefined;
1193
+ bootstrap?: {
1194
+ files?: string[] | undefined;
1195
+ minimalFiles?: string[] | undefined;
1196
+ heartbeatFiles?: string[] | undefined;
1197
+ perFileChars?: number | undefined;
1198
+ totalChars?: number | undefined;
1199
+ } | undefined;
1200
+ }>;
1103
1201
  declare const AgentsConfigSchema: z.ZodObject<{
1104
1202
  defaults: z.ZodDefault<z.ZodObject<{
1105
1203
  workspace: z.ZodDefault<z.ZodString>;
@@ -1120,6 +1218,61 @@ declare const AgentsConfigSchema: z.ZodObject<{
1120
1218
  maxTokens?: number | undefined;
1121
1219
  maxToolIterations?: number | undefined;
1122
1220
  }>>;
1221
+ context: z.ZodDefault<z.ZodObject<{
1222
+ bootstrap: z.ZodDefault<z.ZodObject<{
1223
+ files: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
1224
+ minimalFiles: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
1225
+ heartbeatFiles: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
1226
+ perFileChars: z.ZodDefault<z.ZodNumber>;
1227
+ totalChars: z.ZodDefault<z.ZodNumber>;
1228
+ }, "strip", z.ZodTypeAny, {
1229
+ files: string[];
1230
+ minimalFiles: string[];
1231
+ heartbeatFiles: string[];
1232
+ perFileChars: number;
1233
+ totalChars: number;
1234
+ }, {
1235
+ files?: string[] | undefined;
1236
+ minimalFiles?: string[] | undefined;
1237
+ heartbeatFiles?: string[] | undefined;
1238
+ perFileChars?: number | undefined;
1239
+ totalChars?: number | undefined;
1240
+ }>>;
1241
+ memory: z.ZodDefault<z.ZodObject<{
1242
+ enabled: z.ZodDefault<z.ZodBoolean>;
1243
+ maxChars: z.ZodDefault<z.ZodNumber>;
1244
+ }, "strip", z.ZodTypeAny, {
1245
+ enabled: boolean;
1246
+ maxChars: number;
1247
+ }, {
1248
+ enabled?: boolean | undefined;
1249
+ maxChars?: number | undefined;
1250
+ }>>;
1251
+ }, "strip", z.ZodTypeAny, {
1252
+ memory: {
1253
+ enabled: boolean;
1254
+ maxChars: number;
1255
+ };
1256
+ bootstrap: {
1257
+ files: string[];
1258
+ minimalFiles: string[];
1259
+ heartbeatFiles: string[];
1260
+ perFileChars: number;
1261
+ totalChars: number;
1262
+ };
1263
+ }, {
1264
+ memory?: {
1265
+ enabled?: boolean | undefined;
1266
+ maxChars?: number | undefined;
1267
+ } | undefined;
1268
+ bootstrap?: {
1269
+ files?: string[] | undefined;
1270
+ minimalFiles?: string[] | undefined;
1271
+ heartbeatFiles?: string[] | undefined;
1272
+ perFileChars?: number | undefined;
1273
+ totalChars?: number | undefined;
1274
+ } | undefined;
1275
+ }>>;
1123
1276
  }, "strip", z.ZodTypeAny, {
1124
1277
  defaults: {
1125
1278
  workspace: string;
@@ -1128,6 +1281,19 @@ declare const AgentsConfigSchema: z.ZodObject<{
1128
1281
  maxTokens: number;
1129
1282
  maxToolIterations: number;
1130
1283
  };
1284
+ context: {
1285
+ memory: {
1286
+ enabled: boolean;
1287
+ maxChars: number;
1288
+ };
1289
+ bootstrap: {
1290
+ files: string[];
1291
+ minimalFiles: string[];
1292
+ heartbeatFiles: string[];
1293
+ perFileChars: number;
1294
+ totalChars: number;
1295
+ };
1296
+ };
1131
1297
  }, {
1132
1298
  defaults?: {
1133
1299
  workspace?: string | undefined;
@@ -1136,6 +1302,19 @@ declare const AgentsConfigSchema: z.ZodObject<{
1136
1302
  maxTokens?: number | undefined;
1137
1303
  maxToolIterations?: number | undefined;
1138
1304
  } | undefined;
1305
+ context?: {
1306
+ memory?: {
1307
+ enabled?: boolean | undefined;
1308
+ maxChars?: number | undefined;
1309
+ } | undefined;
1310
+ bootstrap?: {
1311
+ files?: string[] | undefined;
1312
+ minimalFiles?: string[] | undefined;
1313
+ heartbeatFiles?: string[] | undefined;
1314
+ perFileChars?: number | undefined;
1315
+ totalChars?: number | undefined;
1316
+ } | undefined;
1317
+ } | undefined;
1139
1318
  }>;
1140
1319
  declare const ProviderConfigSchema: z.ZodObject<{
1141
1320
  apiKey: z.ZodDefault<z.ZodString>;
@@ -1523,32 +1702,32 @@ declare const WebSearchConfigSchema: z.ZodObject<{
1523
1702
  apiKey: z.ZodDefault<z.ZodString>;
1524
1703
  maxResults: z.ZodDefault<z.ZodNumber>;
1525
1704
  }, "strip", z.ZodTypeAny, {
1526
- maxResults: number;
1527
1705
  apiKey: string;
1706
+ maxResults: number;
1528
1707
  }, {
1529
- maxResults?: number | undefined;
1530
1708
  apiKey?: string | undefined;
1709
+ maxResults?: number | undefined;
1531
1710
  }>;
1532
1711
  declare const WebToolsConfigSchema: z.ZodObject<{
1533
1712
  search: z.ZodDefault<z.ZodObject<{
1534
1713
  apiKey: z.ZodDefault<z.ZodString>;
1535
1714
  maxResults: z.ZodDefault<z.ZodNumber>;
1536
1715
  }, "strip", z.ZodTypeAny, {
1537
- maxResults: number;
1538
1716
  apiKey: string;
1717
+ maxResults: number;
1539
1718
  }, {
1540
- maxResults?: number | undefined;
1541
1719
  apiKey?: string | undefined;
1720
+ maxResults?: number | undefined;
1542
1721
  }>>;
1543
1722
  }, "strip", z.ZodTypeAny, {
1544
1723
  search: {
1545
- maxResults: number;
1546
1724
  apiKey: string;
1725
+ maxResults: number;
1547
1726
  };
1548
1727
  }, {
1549
1728
  search?: {
1550
- maxResults?: number | undefined;
1551
1729
  apiKey?: string | undefined;
1730
+ maxResults?: number | undefined;
1552
1731
  } | undefined;
1553
1732
  }>;
1554
1733
  declare const ExecToolConfigSchema: z.ZodObject<{
@@ -1564,21 +1743,21 @@ declare const ToolsConfigSchema: z.ZodObject<{
1564
1743
  apiKey: z.ZodDefault<z.ZodString>;
1565
1744
  maxResults: z.ZodDefault<z.ZodNumber>;
1566
1745
  }, "strip", z.ZodTypeAny, {
1567
- maxResults: number;
1568
1746
  apiKey: string;
1747
+ maxResults: number;
1569
1748
  }, {
1570
- maxResults?: number | undefined;
1571
1749
  apiKey?: string | undefined;
1750
+ maxResults?: number | undefined;
1572
1751
  }>>;
1573
1752
  }, "strip", z.ZodTypeAny, {
1574
1753
  search: {
1575
- maxResults: number;
1576
1754
  apiKey: string;
1755
+ maxResults: number;
1577
1756
  };
1578
1757
  }, {
1579
1758
  search?: {
1580
- maxResults?: number | undefined;
1581
1759
  apiKey?: string | undefined;
1760
+ maxResults?: number | undefined;
1582
1761
  } | undefined;
1583
1762
  }>>;
1584
1763
  exec: z.ZodDefault<z.ZodObject<{
@@ -1590,26 +1769,26 @@ declare const ToolsConfigSchema: z.ZodObject<{
1590
1769
  }>>;
1591
1770
  restrictToWorkspace: z.ZodDefault<z.ZodBoolean>;
1592
1771
  }, "strip", z.ZodTypeAny, {
1593
- exec: {
1594
- timeout: number;
1595
- };
1596
1772
  web: {
1597
1773
  search: {
1598
- maxResults: number;
1599
1774
  apiKey: string;
1775
+ maxResults: number;
1600
1776
  };
1601
1777
  };
1778
+ exec: {
1779
+ timeout: number;
1780
+ };
1602
1781
  restrictToWorkspace: boolean;
1603
1782
  }, {
1604
- exec?: {
1605
- timeout?: number | undefined;
1606
- } | undefined;
1607
1783
  web?: {
1608
1784
  search?: {
1609
- maxResults?: number | undefined;
1610
1785
  apiKey?: string | undefined;
1786
+ maxResults?: number | undefined;
1611
1787
  } | undefined;
1612
1788
  } | undefined;
1789
+ exec?: {
1790
+ timeout?: number | undefined;
1791
+ } | undefined;
1613
1792
  restrictToWorkspace?: boolean | undefined;
1614
1793
  }>;
1615
1794
  declare const ConfigSchema: z.ZodObject<{
@@ -1633,6 +1812,61 @@ declare const ConfigSchema: z.ZodObject<{
1633
1812
  maxTokens?: number | undefined;
1634
1813
  maxToolIterations?: number | undefined;
1635
1814
  }>>;
1815
+ context: z.ZodDefault<z.ZodObject<{
1816
+ bootstrap: z.ZodDefault<z.ZodObject<{
1817
+ files: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
1818
+ minimalFiles: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
1819
+ heartbeatFiles: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
1820
+ perFileChars: z.ZodDefault<z.ZodNumber>;
1821
+ totalChars: z.ZodDefault<z.ZodNumber>;
1822
+ }, "strip", z.ZodTypeAny, {
1823
+ files: string[];
1824
+ minimalFiles: string[];
1825
+ heartbeatFiles: string[];
1826
+ perFileChars: number;
1827
+ totalChars: number;
1828
+ }, {
1829
+ files?: string[] | undefined;
1830
+ minimalFiles?: string[] | undefined;
1831
+ heartbeatFiles?: string[] | undefined;
1832
+ perFileChars?: number | undefined;
1833
+ totalChars?: number | undefined;
1834
+ }>>;
1835
+ memory: z.ZodDefault<z.ZodObject<{
1836
+ enabled: z.ZodDefault<z.ZodBoolean>;
1837
+ maxChars: z.ZodDefault<z.ZodNumber>;
1838
+ }, "strip", z.ZodTypeAny, {
1839
+ enabled: boolean;
1840
+ maxChars: number;
1841
+ }, {
1842
+ enabled?: boolean | undefined;
1843
+ maxChars?: number | undefined;
1844
+ }>>;
1845
+ }, "strip", z.ZodTypeAny, {
1846
+ memory: {
1847
+ enabled: boolean;
1848
+ maxChars: number;
1849
+ };
1850
+ bootstrap: {
1851
+ files: string[];
1852
+ minimalFiles: string[];
1853
+ heartbeatFiles: string[];
1854
+ perFileChars: number;
1855
+ totalChars: number;
1856
+ };
1857
+ }, {
1858
+ memory?: {
1859
+ enabled?: boolean | undefined;
1860
+ maxChars?: number | undefined;
1861
+ } | undefined;
1862
+ bootstrap?: {
1863
+ files?: string[] | undefined;
1864
+ minimalFiles?: string[] | undefined;
1865
+ heartbeatFiles?: string[] | undefined;
1866
+ perFileChars?: number | undefined;
1867
+ totalChars?: number | undefined;
1868
+ } | undefined;
1869
+ }>>;
1636
1870
  }, "strip", z.ZodTypeAny, {
1637
1871
  defaults: {
1638
1872
  workspace: string;
@@ -1641,6 +1875,19 @@ declare const ConfigSchema: z.ZodObject<{
1641
1875
  maxTokens: number;
1642
1876
  maxToolIterations: number;
1643
1877
  };
1878
+ context: {
1879
+ memory: {
1880
+ enabled: boolean;
1881
+ maxChars: number;
1882
+ };
1883
+ bootstrap: {
1884
+ files: string[];
1885
+ minimalFiles: string[];
1886
+ heartbeatFiles: string[];
1887
+ perFileChars: number;
1888
+ totalChars: number;
1889
+ };
1890
+ };
1644
1891
  }, {
1645
1892
  defaults?: {
1646
1893
  workspace?: string | undefined;
@@ -1649,6 +1896,19 @@ declare const ConfigSchema: z.ZodObject<{
1649
1896
  maxTokens?: number | undefined;
1650
1897
  maxToolIterations?: number | undefined;
1651
1898
  } | undefined;
1899
+ context?: {
1900
+ memory?: {
1901
+ enabled?: boolean | undefined;
1902
+ maxChars?: number | undefined;
1903
+ } | undefined;
1904
+ bootstrap?: {
1905
+ files?: string[] | undefined;
1906
+ minimalFiles?: string[] | undefined;
1907
+ heartbeatFiles?: string[] | undefined;
1908
+ perFileChars?: number | undefined;
1909
+ totalChars?: number | undefined;
1910
+ } | undefined;
1911
+ } | undefined;
1652
1912
  }>>;
1653
1913
  channels: z.ZodDefault<z.ZodObject<{
1654
1914
  whatsapp: z.ZodDefault<z.ZodObject<{
@@ -1708,15 +1968,15 @@ declare const ConfigSchema: z.ZodObject<{
1708
1968
  allowFrom: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
1709
1969
  }, "strip", z.ZodTypeAny, {
1710
1970
  enabled: boolean;
1711
- appId: string;
1712
1971
  allowFrom: string[];
1972
+ appId: string;
1713
1973
  appSecret: string;
1714
1974
  encryptKey: string;
1715
1975
  verificationToken: string;
1716
1976
  }, {
1717
1977
  enabled?: boolean | undefined;
1718
- appId?: string | undefined;
1719
1978
  allowFrom?: string[] | undefined;
1979
+ appId?: string | undefined;
1720
1980
  appSecret?: string | undefined;
1721
1981
  encryptKey?: string | undefined;
1722
1982
  verificationToken?: string | undefined;
@@ -1953,14 +2213,14 @@ declare const ConfigSchema: z.ZodObject<{
1953
2213
  allowFrom: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
1954
2214
  }, "strip", z.ZodTypeAny, {
1955
2215
  enabled: boolean;
1956
- appId: string;
1957
2216
  allowFrom: string[];
2217
+ appId: string;
1958
2218
  secret: string;
1959
2219
  markdownSupport: boolean;
1960
2220
  }, {
1961
2221
  enabled?: boolean | undefined;
1962
- appId?: string | undefined;
1963
2222
  allowFrom?: string[] | undefined;
2223
+ appId?: string | undefined;
1964
2224
  secret?: string | undefined;
1965
2225
  markdownSupport?: boolean | undefined;
1966
2226
  }>>;
@@ -1985,8 +2245,8 @@ declare const ConfigSchema: z.ZodObject<{
1985
2245
  };
1986
2246
  feishu: {
1987
2247
  enabled: boolean;
1988
- appId: string;
1989
2248
  allowFrom: string[];
2249
+ appId: string;
1990
2250
  appSecret: string;
1991
2251
  encryptKey: string;
1992
2252
  verificationToken: string;
@@ -2065,8 +2325,8 @@ declare const ConfigSchema: z.ZodObject<{
2065
2325
  };
2066
2326
  qq: {
2067
2327
  enabled: boolean;
2068
- appId: string;
2069
2328
  allowFrom: string[];
2329
+ appId: string;
2070
2330
  secret: string;
2071
2331
  markdownSupport: boolean;
2072
2332
  };
@@ -2091,8 +2351,8 @@ declare const ConfigSchema: z.ZodObject<{
2091
2351
  } | undefined;
2092
2352
  feishu?: {
2093
2353
  enabled?: boolean | undefined;
2094
- appId?: string | undefined;
2095
2354
  allowFrom?: string[] | undefined;
2355
+ appId?: string | undefined;
2096
2356
  appSecret?: string | undefined;
2097
2357
  encryptKey?: string | undefined;
2098
2358
  verificationToken?: string | undefined;
@@ -2171,8 +2431,8 @@ declare const ConfigSchema: z.ZodObject<{
2171
2431
  } | undefined;
2172
2432
  qq?: {
2173
2433
  enabled?: boolean | undefined;
2174
- appId?: string | undefined;
2175
2434
  allowFrom?: string[] | undefined;
2435
+ appId?: string | undefined;
2176
2436
  secret?: string | undefined;
2177
2437
  markdownSupport?: boolean | undefined;
2178
2438
  } | undefined;
@@ -2549,21 +2809,21 @@ declare const ConfigSchema: z.ZodObject<{
2549
2809
  apiKey: z.ZodDefault<z.ZodString>;
2550
2810
  maxResults: z.ZodDefault<z.ZodNumber>;
2551
2811
  }, "strip", z.ZodTypeAny, {
2552
- maxResults: number;
2553
2812
  apiKey: string;
2813
+ maxResults: number;
2554
2814
  }, {
2555
- maxResults?: number | undefined;
2556
2815
  apiKey?: string | undefined;
2816
+ maxResults?: number | undefined;
2557
2817
  }>>;
2558
2818
  }, "strip", z.ZodTypeAny, {
2559
2819
  search: {
2560
- maxResults: number;
2561
2820
  apiKey: string;
2821
+ maxResults: number;
2562
2822
  };
2563
2823
  }, {
2564
2824
  search?: {
2565
- maxResults?: number | undefined;
2566
2825
  apiKey?: string | undefined;
2826
+ maxResults?: number | undefined;
2567
2827
  } | undefined;
2568
2828
  }>>;
2569
2829
  exec: z.ZodDefault<z.ZodObject<{
@@ -2575,26 +2835,26 @@ declare const ConfigSchema: z.ZodObject<{
2575
2835
  }>>;
2576
2836
  restrictToWorkspace: z.ZodDefault<z.ZodBoolean>;
2577
2837
  }, "strip", z.ZodTypeAny, {
2578
- exec: {
2579
- timeout: number;
2580
- };
2581
2838
  web: {
2582
2839
  search: {
2583
- maxResults: number;
2584
2840
  apiKey: string;
2841
+ maxResults: number;
2585
2842
  };
2586
2843
  };
2844
+ exec: {
2845
+ timeout: number;
2846
+ };
2587
2847
  restrictToWorkspace: boolean;
2588
2848
  }, {
2589
- exec?: {
2590
- timeout?: number | undefined;
2591
- } | undefined;
2592
2849
  web?: {
2593
2850
  search?: {
2594
- maxResults?: number | undefined;
2595
2851
  apiKey?: string | undefined;
2852
+ maxResults?: number | undefined;
2596
2853
  } | undefined;
2597
2854
  } | undefined;
2855
+ exec?: {
2856
+ timeout?: number | undefined;
2857
+ } | undefined;
2598
2858
  restrictToWorkspace?: boolean | undefined;
2599
2859
  }>>;
2600
2860
  }, "strip", z.ZodTypeAny, {
@@ -2606,6 +2866,19 @@ declare const ConfigSchema: z.ZodObject<{
2606
2866
  maxTokens: number;
2607
2867
  maxToolIterations: number;
2608
2868
  };
2869
+ context: {
2870
+ memory: {
2871
+ enabled: boolean;
2872
+ maxChars: number;
2873
+ };
2874
+ bootstrap: {
2875
+ files: string[];
2876
+ minimalFiles: string[];
2877
+ heartbeatFiles: string[];
2878
+ perFileChars: number;
2879
+ totalChars: number;
2880
+ };
2881
+ };
2609
2882
  };
2610
2883
  channels: {
2611
2884
  whatsapp: {
@@ -2628,8 +2901,8 @@ declare const ConfigSchema: z.ZodObject<{
2628
2901
  };
2629
2902
  feishu: {
2630
2903
  enabled: boolean;
2631
- appId: string;
2632
2904
  allowFrom: string[];
2905
+ appId: string;
2633
2906
  appSecret: string;
2634
2907
  encryptKey: string;
2635
2908
  verificationToken: string;
@@ -2708,8 +2981,8 @@ declare const ConfigSchema: z.ZodObject<{
2708
2981
  };
2709
2982
  qq: {
2710
2983
  enabled: boolean;
2711
- appId: string;
2712
2984
  allowFrom: string[];
2985
+ appId: string;
2713
2986
  secret: string;
2714
2987
  markdownSupport: boolean;
2715
2988
  };
@@ -2799,15 +3072,15 @@ declare const ConfigSchema: z.ZodObject<{
2799
3072
  port: number;
2800
3073
  };
2801
3074
  tools: {
2802
- exec: {
2803
- timeout: number;
2804
- };
2805
3075
  web: {
2806
3076
  search: {
2807
- maxResults: number;
2808
3077
  apiKey: string;
3078
+ maxResults: number;
2809
3079
  };
2810
3080
  };
3081
+ exec: {
3082
+ timeout: number;
3083
+ };
2811
3084
  restrictToWorkspace: boolean;
2812
3085
  };
2813
3086
  }, {
@@ -2819,6 +3092,19 @@ declare const ConfigSchema: z.ZodObject<{
2819
3092
  maxTokens?: number | undefined;
2820
3093
  maxToolIterations?: number | undefined;
2821
3094
  } | undefined;
3095
+ context?: {
3096
+ memory?: {
3097
+ enabled?: boolean | undefined;
3098
+ maxChars?: number | undefined;
3099
+ } | undefined;
3100
+ bootstrap?: {
3101
+ files?: string[] | undefined;
3102
+ minimalFiles?: string[] | undefined;
3103
+ heartbeatFiles?: string[] | undefined;
3104
+ perFileChars?: number | undefined;
3105
+ totalChars?: number | undefined;
3106
+ } | undefined;
3107
+ } | undefined;
2822
3108
  } | undefined;
2823
3109
  channels?: {
2824
3110
  whatsapp?: {
@@ -2841,8 +3127,8 @@ declare const ConfigSchema: z.ZodObject<{
2841
3127
  } | undefined;
2842
3128
  feishu?: {
2843
3129
  enabled?: boolean | undefined;
2844
- appId?: string | undefined;
2845
3130
  allowFrom?: string[] | undefined;
3131
+ appId?: string | undefined;
2846
3132
  appSecret?: string | undefined;
2847
3133
  encryptKey?: string | undefined;
2848
3134
  verificationToken?: string | undefined;
@@ -2921,8 +3207,8 @@ declare const ConfigSchema: z.ZodObject<{
2921
3207
  } | undefined;
2922
3208
  qq?: {
2923
3209
  enabled?: boolean | undefined;
2924
- appId?: string | undefined;
2925
3210
  allowFrom?: string[] | undefined;
3211
+ appId?: string | undefined;
2926
3212
  secret?: string | undefined;
2927
3213
  markdownSupport?: boolean | undefined;
2928
3214
  } | undefined;
@@ -3012,15 +3298,15 @@ declare const ConfigSchema: z.ZodObject<{
3012
3298
  port?: number | undefined;
3013
3299
  } | undefined;
3014
3300
  tools?: {
3015
- exec?: {
3016
- timeout?: number | undefined;
3017
- } | undefined;
3018
3301
  web?: {
3019
3302
  search?: {
3020
- maxResults?: number | undefined;
3021
3303
  apiKey?: string | undefined;
3304
+ maxResults?: number | undefined;
3022
3305
  } | undefined;
3023
3306
  } | undefined;
3307
+ exec?: {
3308
+ timeout?: number | undefined;
3309
+ } | undefined;
3024
3310
  restrictToWorkspace?: boolean | undefined;
3025
3311
  } | undefined;
3026
3312
  }>;
@@ -3036,6 +3322,54 @@ declare function getProviderName(config: Config, model?: string): string | null;
3036
3322
  declare function getApiKey(config: Config, model?: string): string | null;
3037
3323
  declare function getApiBase(config: Config, model?: string): string | null;
3038
3324
 
3325
+ declare class AgentLoop {
3326
+ private options;
3327
+ private context;
3328
+ private sessions;
3329
+ private tools;
3330
+ private subagents;
3331
+ private running;
3332
+ constructor(options: {
3333
+ bus: MessageBus;
3334
+ providerManager: ProviderManager;
3335
+ workspace: string;
3336
+ model?: string | null;
3337
+ maxIterations?: number;
3338
+ braveApiKey?: string | null;
3339
+ execConfig?: {
3340
+ timeout: number;
3341
+ };
3342
+ cronService?: CronService | null;
3343
+ restrictToWorkspace?: boolean;
3344
+ sessionManager?: SessionManager;
3345
+ contextConfig?: Config["agents"]["context"];
3346
+ gatewayController?: GatewayController;
3347
+ });
3348
+ private registerDefaultTools;
3349
+ run(): Promise<void>;
3350
+ stop(): void;
3351
+ processDirect(params: {
3352
+ content: string;
3353
+ sessionKey?: string;
3354
+ channel?: string;
3355
+ chatId?: string;
3356
+ }): Promise<string>;
3357
+ private processMessage;
3358
+ private processSystemMessage;
3359
+ }
3360
+
3361
+ type FeishuProbeResult = {
3362
+ ok: true;
3363
+ appId: string;
3364
+ botName?: string;
3365
+ botOpenId?: string;
3366
+ } | {
3367
+ ok: false;
3368
+ appId?: string;
3369
+ error: string;
3370
+ };
3371
+ declare function probeFeishu(appId: string, appSecret: string): Promise<FeishuProbeResult>;
3372
+
3039
3373
  declare abstract class BaseChannel<TConfig extends Record<string, unknown>> {
3040
3374
  protected config: TConfig;
3041
3375
  protected bus: MessageBus;
@@ -3196,4 +3530,4 @@ declare function parseSessionKey(key: string): {
3196
3530
  };
3197
3531
  declare function expandHome(value: string): string;
3198
3532
 
3199
- export { APP_NAME, APP_REPLY_SUBJECT, APP_TAGLINE, APP_TITLE, APP_USER_AGENT, AgentDefaultsSchema, AgentLoop, AgentsConfigSchema, ChannelManager, ChannelsConfigSchema, type Config, ConfigSchema, CronService, DEFAULT_CONFIG_FILE, DEFAULT_CONFIG_PATH, DEFAULT_HEARTBEAT_INTERVAL_S, DEFAULT_HOME_DIR, DEFAULT_WORKSPACE_DIR, DEFAULT_WORKSPACE_PATH, DingTalkConfigSchema, DiscordConfigSchema, ENV_APP_NAME_KEY, ENV_HOME_KEY, EmailConfigSchema, ExecToolConfigSchema, FeishuConfigSchema, type FeishuProbeResult, GatewayConfigSchema, HEARTBEAT_OK_TOKEN, HEARTBEAT_PROMPT, HeartbeatService, LLMProvider, type LLMResponse, LiteLLMProvider, type LiteLLMProviderOptions, MessageBus, MochatConfigSchema, MochatGroupRuleSchema, MochatMentionSchema, PROVIDERS, type ProviderConfig, ProviderConfigSchema, ProviderManager, type ProviderSpec, ProvidersConfigSchema, QQConfigSchema, type ReloadPlan, SKILL_METADATA_KEY, type Session, SessionManager, type SessionMessage, SlackConfigSchema, SlackDMSchema, TelegramConfigSchema, type ToolCallRequest, ToolsConfigSchema, UiConfigSchema, WebSearchConfigSchema, WebToolsConfigSchema, WhatsAppConfigSchema, type WireApiMode, buildReloadPlan, diffConfigPaths, ensureDir, expandHome, findGateway, findProviderByModel, findProviderByName, getApiBase, getApiKey, getConfigPath, getDataDir, getDataPath, getMemoryPath, getProvider, getProviderName, getSessionsPath, getSkillsPath, getWorkspacePath, getWorkspacePathFromConfig, loadConfig, matchProvider, parseSessionKey, probeFeishu, providerLabel, safeFilename, saveConfig, timestamp, todayDate, truncateString };
3533
+ export { APP_NAME, APP_REPLY_SUBJECT, APP_TAGLINE, APP_TITLE, APP_USER_AGENT, AgentDefaultsSchema, AgentLoop, AgentsConfigSchema, ChannelManager, ChannelsConfigSchema, type Config, ConfigSchema, ContextBootstrapSchema, ContextConfigSchema, ContextMemorySchema, CronService, DEFAULT_CONFIG_FILE, DEFAULT_CONFIG_PATH, DEFAULT_HEARTBEAT_INTERVAL_S, DEFAULT_HOME_DIR, DEFAULT_WORKSPACE_DIR, DEFAULT_WORKSPACE_PATH, DingTalkConfigSchema, DiscordConfigSchema, ENV_APP_NAME_KEY, ENV_HOME_KEY, EmailConfigSchema, ExecToolConfigSchema, FeishuConfigSchema, type FeishuProbeResult, GatewayConfigSchema, type GatewayConfigSnapshot, type GatewayController, GatewayTool, HEARTBEAT_OK_TOKEN, HEARTBEAT_PROMPT, HeartbeatService, LLMProvider, type LLMResponse, LiteLLMProvider, type LiteLLMProviderOptions, MessageBus, MochatConfigSchema, MochatGroupRuleSchema, MochatMentionSchema, PROVIDERS, type ProviderConfig, ProviderConfigSchema, ProviderManager, type ProviderSpec, ProvidersConfigSchema, QQConfigSchema, type ReloadPlan, SKILL_METADATA_KEY, type Session, SessionManager, type SessionMessage, SlackConfigSchema, SlackDMSchema, TelegramConfigSchema, type ToolCallRequest, ToolsConfigSchema, UiConfigSchema, WebSearchConfigSchema, WebToolsConfigSchema, WhatsAppConfigSchema, type WireApiMode, buildReloadPlan, diffConfigPaths, ensureDir, expandHome, findGateway, findProviderByModel, findProviderByName, getApiBase, getApiKey, getConfigPath, getDataDir, getDataPath, getMemoryPath, getProvider, getProviderName, getSessionsPath, getSkillsPath, getWorkspacePath, getWorkspacePathFromConfig, loadConfig, matchProvider, parseSessionKey, probeFeishu, providerLabel, safeFilename, saveConfig, timestamp, todayDate, truncateString };