nextclaw-core 0.2.8 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +162 -2
- package/dist/index.js +201 -21
- package/package.json +8 -8
package/dist/index.d.ts
CHANGED
|
@@ -60,6 +60,13 @@ declare abstract class LLMProvider {
|
|
|
60
60
|
abstract getDefaultModel(): string;
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
+
declare class ProviderManager {
|
|
64
|
+
private provider;
|
|
65
|
+
constructor(provider: LLMProvider);
|
|
66
|
+
get(): LLMProvider;
|
|
67
|
+
set(next: LLMProvider): void;
|
|
68
|
+
}
|
|
69
|
+
|
|
63
70
|
type SessionMessage = {
|
|
64
71
|
role: string;
|
|
65
72
|
content: string;
|
|
@@ -170,7 +177,7 @@ declare class AgentLoop {
|
|
|
170
177
|
private running;
|
|
171
178
|
constructor(options: {
|
|
172
179
|
bus: MessageBus;
|
|
173
|
-
|
|
180
|
+
providerManager: ProviderManager;
|
|
174
181
|
workspace: string;
|
|
175
182
|
model?: string | null;
|
|
176
183
|
maxIterations?: number;
|
|
@@ -1134,293 +1141,356 @@ declare const ProviderConfigSchema: z.ZodObject<{
|
|
|
1134
1141
|
apiKey: z.ZodDefault<z.ZodString>;
|
|
1135
1142
|
apiBase: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
1136
1143
|
extraHeaders: z.ZodDefault<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodString>>>;
|
|
1144
|
+
wireApi: z.ZodDefault<z.ZodEnum<["auto", "chat", "responses"]>>;
|
|
1137
1145
|
}, "strip", z.ZodTypeAny, {
|
|
1138
1146
|
apiKey: string;
|
|
1139
1147
|
apiBase: string | null;
|
|
1140
1148
|
extraHeaders: Record<string, string> | null;
|
|
1149
|
+
wireApi: "auto" | "chat" | "responses";
|
|
1141
1150
|
}, {
|
|
1142
1151
|
apiKey?: string | undefined;
|
|
1143
1152
|
apiBase?: string | null | undefined;
|
|
1144
1153
|
extraHeaders?: Record<string, string> | null | undefined;
|
|
1154
|
+
wireApi?: "auto" | "chat" | "responses" | undefined;
|
|
1145
1155
|
}>;
|
|
1146
1156
|
declare const ProvidersConfigSchema: z.ZodObject<{
|
|
1147
1157
|
anthropic: z.ZodDefault<z.ZodObject<{
|
|
1148
1158
|
apiKey: z.ZodDefault<z.ZodString>;
|
|
1149
1159
|
apiBase: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
1150
1160
|
extraHeaders: z.ZodDefault<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodString>>>;
|
|
1161
|
+
wireApi: z.ZodDefault<z.ZodEnum<["auto", "chat", "responses"]>>;
|
|
1151
1162
|
}, "strip", z.ZodTypeAny, {
|
|
1152
1163
|
apiKey: string;
|
|
1153
1164
|
apiBase: string | null;
|
|
1154
1165
|
extraHeaders: Record<string, string> | null;
|
|
1166
|
+
wireApi: "auto" | "chat" | "responses";
|
|
1155
1167
|
}, {
|
|
1156
1168
|
apiKey?: string | undefined;
|
|
1157
1169
|
apiBase?: string | null | undefined;
|
|
1158
1170
|
extraHeaders?: Record<string, string> | null | undefined;
|
|
1171
|
+
wireApi?: "auto" | "chat" | "responses" | undefined;
|
|
1159
1172
|
}>>;
|
|
1160
1173
|
openai: z.ZodDefault<z.ZodObject<{
|
|
1161
1174
|
apiKey: z.ZodDefault<z.ZodString>;
|
|
1162
1175
|
apiBase: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
1163
1176
|
extraHeaders: z.ZodDefault<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodString>>>;
|
|
1177
|
+
wireApi: z.ZodDefault<z.ZodEnum<["auto", "chat", "responses"]>>;
|
|
1164
1178
|
}, "strip", z.ZodTypeAny, {
|
|
1165
1179
|
apiKey: string;
|
|
1166
1180
|
apiBase: string | null;
|
|
1167
1181
|
extraHeaders: Record<string, string> | null;
|
|
1182
|
+
wireApi: "auto" | "chat" | "responses";
|
|
1168
1183
|
}, {
|
|
1169
1184
|
apiKey?: string | undefined;
|
|
1170
1185
|
apiBase?: string | null | undefined;
|
|
1171
1186
|
extraHeaders?: Record<string, string> | null | undefined;
|
|
1187
|
+
wireApi?: "auto" | "chat" | "responses" | undefined;
|
|
1172
1188
|
}>>;
|
|
1173
1189
|
openrouter: z.ZodDefault<z.ZodObject<{
|
|
1174
1190
|
apiKey: z.ZodDefault<z.ZodString>;
|
|
1175
1191
|
apiBase: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
1176
1192
|
extraHeaders: z.ZodDefault<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodString>>>;
|
|
1193
|
+
wireApi: z.ZodDefault<z.ZodEnum<["auto", "chat", "responses"]>>;
|
|
1177
1194
|
}, "strip", z.ZodTypeAny, {
|
|
1178
1195
|
apiKey: string;
|
|
1179
1196
|
apiBase: string | null;
|
|
1180
1197
|
extraHeaders: Record<string, string> | null;
|
|
1198
|
+
wireApi: "auto" | "chat" | "responses";
|
|
1181
1199
|
}, {
|
|
1182
1200
|
apiKey?: string | undefined;
|
|
1183
1201
|
apiBase?: string | null | undefined;
|
|
1184
1202
|
extraHeaders?: Record<string, string> | null | undefined;
|
|
1203
|
+
wireApi?: "auto" | "chat" | "responses" | undefined;
|
|
1185
1204
|
}>>;
|
|
1186
1205
|
deepseek: z.ZodDefault<z.ZodObject<{
|
|
1187
1206
|
apiKey: z.ZodDefault<z.ZodString>;
|
|
1188
1207
|
apiBase: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
1189
1208
|
extraHeaders: z.ZodDefault<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodString>>>;
|
|
1209
|
+
wireApi: z.ZodDefault<z.ZodEnum<["auto", "chat", "responses"]>>;
|
|
1190
1210
|
}, "strip", z.ZodTypeAny, {
|
|
1191
1211
|
apiKey: string;
|
|
1192
1212
|
apiBase: string | null;
|
|
1193
1213
|
extraHeaders: Record<string, string> | null;
|
|
1214
|
+
wireApi: "auto" | "chat" | "responses";
|
|
1194
1215
|
}, {
|
|
1195
1216
|
apiKey?: string | undefined;
|
|
1196
1217
|
apiBase?: string | null | undefined;
|
|
1197
1218
|
extraHeaders?: Record<string, string> | null | undefined;
|
|
1219
|
+
wireApi?: "auto" | "chat" | "responses" | undefined;
|
|
1198
1220
|
}>>;
|
|
1199
1221
|
groq: z.ZodDefault<z.ZodObject<{
|
|
1200
1222
|
apiKey: z.ZodDefault<z.ZodString>;
|
|
1201
1223
|
apiBase: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
1202
1224
|
extraHeaders: z.ZodDefault<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodString>>>;
|
|
1225
|
+
wireApi: z.ZodDefault<z.ZodEnum<["auto", "chat", "responses"]>>;
|
|
1203
1226
|
}, "strip", z.ZodTypeAny, {
|
|
1204
1227
|
apiKey: string;
|
|
1205
1228
|
apiBase: string | null;
|
|
1206
1229
|
extraHeaders: Record<string, string> | null;
|
|
1230
|
+
wireApi: "auto" | "chat" | "responses";
|
|
1207
1231
|
}, {
|
|
1208
1232
|
apiKey?: string | undefined;
|
|
1209
1233
|
apiBase?: string | null | undefined;
|
|
1210
1234
|
extraHeaders?: Record<string, string> | null | undefined;
|
|
1235
|
+
wireApi?: "auto" | "chat" | "responses" | undefined;
|
|
1211
1236
|
}>>;
|
|
1212
1237
|
zhipu: z.ZodDefault<z.ZodObject<{
|
|
1213
1238
|
apiKey: z.ZodDefault<z.ZodString>;
|
|
1214
1239
|
apiBase: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
1215
1240
|
extraHeaders: z.ZodDefault<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodString>>>;
|
|
1241
|
+
wireApi: z.ZodDefault<z.ZodEnum<["auto", "chat", "responses"]>>;
|
|
1216
1242
|
}, "strip", z.ZodTypeAny, {
|
|
1217
1243
|
apiKey: string;
|
|
1218
1244
|
apiBase: string | null;
|
|
1219
1245
|
extraHeaders: Record<string, string> | null;
|
|
1246
|
+
wireApi: "auto" | "chat" | "responses";
|
|
1220
1247
|
}, {
|
|
1221
1248
|
apiKey?: string | undefined;
|
|
1222
1249
|
apiBase?: string | null | undefined;
|
|
1223
1250
|
extraHeaders?: Record<string, string> | null | undefined;
|
|
1251
|
+
wireApi?: "auto" | "chat" | "responses" | undefined;
|
|
1224
1252
|
}>>;
|
|
1225
1253
|
dashscope: z.ZodDefault<z.ZodObject<{
|
|
1226
1254
|
apiKey: z.ZodDefault<z.ZodString>;
|
|
1227
1255
|
apiBase: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
1228
1256
|
extraHeaders: z.ZodDefault<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodString>>>;
|
|
1257
|
+
wireApi: z.ZodDefault<z.ZodEnum<["auto", "chat", "responses"]>>;
|
|
1229
1258
|
}, "strip", z.ZodTypeAny, {
|
|
1230
1259
|
apiKey: string;
|
|
1231
1260
|
apiBase: string | null;
|
|
1232
1261
|
extraHeaders: Record<string, string> | null;
|
|
1262
|
+
wireApi: "auto" | "chat" | "responses";
|
|
1233
1263
|
}, {
|
|
1234
1264
|
apiKey?: string | undefined;
|
|
1235
1265
|
apiBase?: string | null | undefined;
|
|
1236
1266
|
extraHeaders?: Record<string, string> | null | undefined;
|
|
1267
|
+
wireApi?: "auto" | "chat" | "responses" | undefined;
|
|
1237
1268
|
}>>;
|
|
1238
1269
|
vllm: z.ZodDefault<z.ZodObject<{
|
|
1239
1270
|
apiKey: z.ZodDefault<z.ZodString>;
|
|
1240
1271
|
apiBase: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
1241
1272
|
extraHeaders: z.ZodDefault<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodString>>>;
|
|
1273
|
+
wireApi: z.ZodDefault<z.ZodEnum<["auto", "chat", "responses"]>>;
|
|
1242
1274
|
}, "strip", z.ZodTypeAny, {
|
|
1243
1275
|
apiKey: string;
|
|
1244
1276
|
apiBase: string | null;
|
|
1245
1277
|
extraHeaders: Record<string, string> | null;
|
|
1278
|
+
wireApi: "auto" | "chat" | "responses";
|
|
1246
1279
|
}, {
|
|
1247
1280
|
apiKey?: string | undefined;
|
|
1248
1281
|
apiBase?: string | null | undefined;
|
|
1249
1282
|
extraHeaders?: Record<string, string> | null | undefined;
|
|
1283
|
+
wireApi?: "auto" | "chat" | "responses" | undefined;
|
|
1250
1284
|
}>>;
|
|
1251
1285
|
gemini: z.ZodDefault<z.ZodObject<{
|
|
1252
1286
|
apiKey: z.ZodDefault<z.ZodString>;
|
|
1253
1287
|
apiBase: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
1254
1288
|
extraHeaders: z.ZodDefault<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodString>>>;
|
|
1289
|
+
wireApi: z.ZodDefault<z.ZodEnum<["auto", "chat", "responses"]>>;
|
|
1255
1290
|
}, "strip", z.ZodTypeAny, {
|
|
1256
1291
|
apiKey: string;
|
|
1257
1292
|
apiBase: string | null;
|
|
1258
1293
|
extraHeaders: Record<string, string> | null;
|
|
1294
|
+
wireApi: "auto" | "chat" | "responses";
|
|
1259
1295
|
}, {
|
|
1260
1296
|
apiKey?: string | undefined;
|
|
1261
1297
|
apiBase?: string | null | undefined;
|
|
1262
1298
|
extraHeaders?: Record<string, string> | null | undefined;
|
|
1299
|
+
wireApi?: "auto" | "chat" | "responses" | undefined;
|
|
1263
1300
|
}>>;
|
|
1264
1301
|
moonshot: z.ZodDefault<z.ZodObject<{
|
|
1265
1302
|
apiKey: z.ZodDefault<z.ZodString>;
|
|
1266
1303
|
apiBase: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
1267
1304
|
extraHeaders: z.ZodDefault<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodString>>>;
|
|
1305
|
+
wireApi: z.ZodDefault<z.ZodEnum<["auto", "chat", "responses"]>>;
|
|
1268
1306
|
}, "strip", z.ZodTypeAny, {
|
|
1269
1307
|
apiKey: string;
|
|
1270
1308
|
apiBase: string | null;
|
|
1271
1309
|
extraHeaders: Record<string, string> | null;
|
|
1310
|
+
wireApi: "auto" | "chat" | "responses";
|
|
1272
1311
|
}, {
|
|
1273
1312
|
apiKey?: string | undefined;
|
|
1274
1313
|
apiBase?: string | null | undefined;
|
|
1275
1314
|
extraHeaders?: Record<string, string> | null | undefined;
|
|
1315
|
+
wireApi?: "auto" | "chat" | "responses" | undefined;
|
|
1276
1316
|
}>>;
|
|
1277
1317
|
minimax: z.ZodDefault<z.ZodObject<{
|
|
1278
1318
|
apiKey: z.ZodDefault<z.ZodString>;
|
|
1279
1319
|
apiBase: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
1280
1320
|
extraHeaders: z.ZodDefault<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodString>>>;
|
|
1321
|
+
wireApi: z.ZodDefault<z.ZodEnum<["auto", "chat", "responses"]>>;
|
|
1281
1322
|
}, "strip", z.ZodTypeAny, {
|
|
1282
1323
|
apiKey: string;
|
|
1283
1324
|
apiBase: string | null;
|
|
1284
1325
|
extraHeaders: Record<string, string> | null;
|
|
1326
|
+
wireApi: "auto" | "chat" | "responses";
|
|
1285
1327
|
}, {
|
|
1286
1328
|
apiKey?: string | undefined;
|
|
1287
1329
|
apiBase?: string | null | undefined;
|
|
1288
1330
|
extraHeaders?: Record<string, string> | null | undefined;
|
|
1331
|
+
wireApi?: "auto" | "chat" | "responses" | undefined;
|
|
1289
1332
|
}>>;
|
|
1290
1333
|
aihubmix: z.ZodDefault<z.ZodObject<{
|
|
1291
1334
|
apiKey: z.ZodDefault<z.ZodString>;
|
|
1292
1335
|
apiBase: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
1293
1336
|
extraHeaders: z.ZodDefault<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodString>>>;
|
|
1337
|
+
wireApi: z.ZodDefault<z.ZodEnum<["auto", "chat", "responses"]>>;
|
|
1294
1338
|
}, "strip", z.ZodTypeAny, {
|
|
1295
1339
|
apiKey: string;
|
|
1296
1340
|
apiBase: string | null;
|
|
1297
1341
|
extraHeaders: Record<string, string> | null;
|
|
1342
|
+
wireApi: "auto" | "chat" | "responses";
|
|
1298
1343
|
}, {
|
|
1299
1344
|
apiKey?: string | undefined;
|
|
1300
1345
|
apiBase?: string | null | undefined;
|
|
1301
1346
|
extraHeaders?: Record<string, string> | null | undefined;
|
|
1347
|
+
wireApi?: "auto" | "chat" | "responses" | undefined;
|
|
1302
1348
|
}>>;
|
|
1303
1349
|
}, "strip", z.ZodTypeAny, {
|
|
1304
1350
|
openrouter: {
|
|
1305
1351
|
apiKey: string;
|
|
1306
1352
|
apiBase: string | null;
|
|
1307
1353
|
extraHeaders: Record<string, string> | null;
|
|
1354
|
+
wireApi: "auto" | "chat" | "responses";
|
|
1308
1355
|
};
|
|
1309
1356
|
aihubmix: {
|
|
1310
1357
|
apiKey: string;
|
|
1311
1358
|
apiBase: string | null;
|
|
1312
1359
|
extraHeaders: Record<string, string> | null;
|
|
1360
|
+
wireApi: "auto" | "chat" | "responses";
|
|
1313
1361
|
};
|
|
1314
1362
|
openai: {
|
|
1315
1363
|
apiKey: string;
|
|
1316
1364
|
apiBase: string | null;
|
|
1317
1365
|
extraHeaders: Record<string, string> | null;
|
|
1366
|
+
wireApi: "auto" | "chat" | "responses";
|
|
1318
1367
|
};
|
|
1319
1368
|
anthropic: {
|
|
1320
1369
|
apiKey: string;
|
|
1321
1370
|
apiBase: string | null;
|
|
1322
1371
|
extraHeaders: Record<string, string> | null;
|
|
1372
|
+
wireApi: "auto" | "chat" | "responses";
|
|
1323
1373
|
};
|
|
1324
1374
|
deepseek: {
|
|
1325
1375
|
apiKey: string;
|
|
1326
1376
|
apiBase: string | null;
|
|
1327
1377
|
extraHeaders: Record<string, string> | null;
|
|
1378
|
+
wireApi: "auto" | "chat" | "responses";
|
|
1328
1379
|
};
|
|
1329
1380
|
gemini: {
|
|
1330
1381
|
apiKey: string;
|
|
1331
1382
|
apiBase: string | null;
|
|
1332
1383
|
extraHeaders: Record<string, string> | null;
|
|
1384
|
+
wireApi: "auto" | "chat" | "responses";
|
|
1333
1385
|
};
|
|
1334
1386
|
zhipu: {
|
|
1335
1387
|
apiKey: string;
|
|
1336
1388
|
apiBase: string | null;
|
|
1337
1389
|
extraHeaders: Record<string, string> | null;
|
|
1390
|
+
wireApi: "auto" | "chat" | "responses";
|
|
1338
1391
|
};
|
|
1339
1392
|
dashscope: {
|
|
1340
1393
|
apiKey: string;
|
|
1341
1394
|
apiBase: string | null;
|
|
1342
1395
|
extraHeaders: Record<string, string> | null;
|
|
1396
|
+
wireApi: "auto" | "chat" | "responses";
|
|
1343
1397
|
};
|
|
1344
1398
|
moonshot: {
|
|
1345
1399
|
apiKey: string;
|
|
1346
1400
|
apiBase: string | null;
|
|
1347
1401
|
extraHeaders: Record<string, string> | null;
|
|
1402
|
+
wireApi: "auto" | "chat" | "responses";
|
|
1348
1403
|
};
|
|
1349
1404
|
minimax: {
|
|
1350
1405
|
apiKey: string;
|
|
1351
1406
|
apiBase: string | null;
|
|
1352
1407
|
extraHeaders: Record<string, string> | null;
|
|
1408
|
+
wireApi: "auto" | "chat" | "responses";
|
|
1353
1409
|
};
|
|
1354
1410
|
vllm: {
|
|
1355
1411
|
apiKey: string;
|
|
1356
1412
|
apiBase: string | null;
|
|
1357
1413
|
extraHeaders: Record<string, string> | null;
|
|
1414
|
+
wireApi: "auto" | "chat" | "responses";
|
|
1358
1415
|
};
|
|
1359
1416
|
groq: {
|
|
1360
1417
|
apiKey: string;
|
|
1361
1418
|
apiBase: string | null;
|
|
1362
1419
|
extraHeaders: Record<string, string> | null;
|
|
1420
|
+
wireApi: "auto" | "chat" | "responses";
|
|
1363
1421
|
};
|
|
1364
1422
|
}, {
|
|
1365
1423
|
openrouter?: {
|
|
1366
1424
|
apiKey?: string | undefined;
|
|
1367
1425
|
apiBase?: string | null | undefined;
|
|
1368
1426
|
extraHeaders?: Record<string, string> | null | undefined;
|
|
1427
|
+
wireApi?: "auto" | "chat" | "responses" | undefined;
|
|
1369
1428
|
} | undefined;
|
|
1370
1429
|
aihubmix?: {
|
|
1371
1430
|
apiKey?: string | undefined;
|
|
1372
1431
|
apiBase?: string | null | undefined;
|
|
1373
1432
|
extraHeaders?: Record<string, string> | null | undefined;
|
|
1433
|
+
wireApi?: "auto" | "chat" | "responses" | undefined;
|
|
1374
1434
|
} | undefined;
|
|
1375
1435
|
openai?: {
|
|
1376
1436
|
apiKey?: string | undefined;
|
|
1377
1437
|
apiBase?: string | null | undefined;
|
|
1378
1438
|
extraHeaders?: Record<string, string> | null | undefined;
|
|
1439
|
+
wireApi?: "auto" | "chat" | "responses" | undefined;
|
|
1379
1440
|
} | undefined;
|
|
1380
1441
|
anthropic?: {
|
|
1381
1442
|
apiKey?: string | undefined;
|
|
1382
1443
|
apiBase?: string | null | undefined;
|
|
1383
1444
|
extraHeaders?: Record<string, string> | null | undefined;
|
|
1445
|
+
wireApi?: "auto" | "chat" | "responses" | undefined;
|
|
1384
1446
|
} | undefined;
|
|
1385
1447
|
deepseek?: {
|
|
1386
1448
|
apiKey?: string | undefined;
|
|
1387
1449
|
apiBase?: string | null | undefined;
|
|
1388
1450
|
extraHeaders?: Record<string, string> | null | undefined;
|
|
1451
|
+
wireApi?: "auto" | "chat" | "responses" | undefined;
|
|
1389
1452
|
} | undefined;
|
|
1390
1453
|
gemini?: {
|
|
1391
1454
|
apiKey?: string | undefined;
|
|
1392
1455
|
apiBase?: string | null | undefined;
|
|
1393
1456
|
extraHeaders?: Record<string, string> | null | undefined;
|
|
1457
|
+
wireApi?: "auto" | "chat" | "responses" | undefined;
|
|
1394
1458
|
} | undefined;
|
|
1395
1459
|
zhipu?: {
|
|
1396
1460
|
apiKey?: string | undefined;
|
|
1397
1461
|
apiBase?: string | null | undefined;
|
|
1398
1462
|
extraHeaders?: Record<string, string> | null | undefined;
|
|
1463
|
+
wireApi?: "auto" | "chat" | "responses" | undefined;
|
|
1399
1464
|
} | undefined;
|
|
1400
1465
|
dashscope?: {
|
|
1401
1466
|
apiKey?: string | undefined;
|
|
1402
1467
|
apiBase?: string | null | undefined;
|
|
1403
1468
|
extraHeaders?: Record<string, string> | null | undefined;
|
|
1469
|
+
wireApi?: "auto" | "chat" | "responses" | undefined;
|
|
1404
1470
|
} | undefined;
|
|
1405
1471
|
moonshot?: {
|
|
1406
1472
|
apiKey?: string | undefined;
|
|
1407
1473
|
apiBase?: string | null | undefined;
|
|
1408
1474
|
extraHeaders?: Record<string, string> | null | undefined;
|
|
1475
|
+
wireApi?: "auto" | "chat" | "responses" | undefined;
|
|
1409
1476
|
} | undefined;
|
|
1410
1477
|
minimax?: {
|
|
1411
1478
|
apiKey?: string | undefined;
|
|
1412
1479
|
apiBase?: string | null | undefined;
|
|
1413
1480
|
extraHeaders?: Record<string, string> | null | undefined;
|
|
1481
|
+
wireApi?: "auto" | "chat" | "responses" | undefined;
|
|
1414
1482
|
} | undefined;
|
|
1415
1483
|
vllm?: {
|
|
1416
1484
|
apiKey?: string | undefined;
|
|
1417
1485
|
apiBase?: string | null | undefined;
|
|
1418
1486
|
extraHeaders?: Record<string, string> | null | undefined;
|
|
1487
|
+
wireApi?: "auto" | "chat" | "responses" | undefined;
|
|
1419
1488
|
} | undefined;
|
|
1420
1489
|
groq?: {
|
|
1421
1490
|
apiKey?: string | undefined;
|
|
1422
1491
|
apiBase?: string | null | undefined;
|
|
1423
1492
|
extraHeaders?: Record<string, string> | null | undefined;
|
|
1493
|
+
wireApi?: "auto" | "chat" | "responses" | undefined;
|
|
1424
1494
|
} | undefined;
|
|
1425
1495
|
}>;
|
|
1426
1496
|
declare const GatewayConfigSchema: z.ZodObject<{
|
|
@@ -2112,279 +2182,339 @@ declare const ConfigSchema: z.ZodObject<{
|
|
|
2112
2182
|
apiKey: z.ZodDefault<z.ZodString>;
|
|
2113
2183
|
apiBase: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
2114
2184
|
extraHeaders: z.ZodDefault<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodString>>>;
|
|
2185
|
+
wireApi: z.ZodDefault<z.ZodEnum<["auto", "chat", "responses"]>>;
|
|
2115
2186
|
}, "strip", z.ZodTypeAny, {
|
|
2116
2187
|
apiKey: string;
|
|
2117
2188
|
apiBase: string | null;
|
|
2118
2189
|
extraHeaders: Record<string, string> | null;
|
|
2190
|
+
wireApi: "auto" | "chat" | "responses";
|
|
2119
2191
|
}, {
|
|
2120
2192
|
apiKey?: string | undefined;
|
|
2121
2193
|
apiBase?: string | null | undefined;
|
|
2122
2194
|
extraHeaders?: Record<string, string> | null | undefined;
|
|
2195
|
+
wireApi?: "auto" | "chat" | "responses" | undefined;
|
|
2123
2196
|
}>>;
|
|
2124
2197
|
openai: z.ZodDefault<z.ZodObject<{
|
|
2125
2198
|
apiKey: z.ZodDefault<z.ZodString>;
|
|
2126
2199
|
apiBase: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
2127
2200
|
extraHeaders: z.ZodDefault<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodString>>>;
|
|
2201
|
+
wireApi: z.ZodDefault<z.ZodEnum<["auto", "chat", "responses"]>>;
|
|
2128
2202
|
}, "strip", z.ZodTypeAny, {
|
|
2129
2203
|
apiKey: string;
|
|
2130
2204
|
apiBase: string | null;
|
|
2131
2205
|
extraHeaders: Record<string, string> | null;
|
|
2206
|
+
wireApi: "auto" | "chat" | "responses";
|
|
2132
2207
|
}, {
|
|
2133
2208
|
apiKey?: string | undefined;
|
|
2134
2209
|
apiBase?: string | null | undefined;
|
|
2135
2210
|
extraHeaders?: Record<string, string> | null | undefined;
|
|
2211
|
+
wireApi?: "auto" | "chat" | "responses" | undefined;
|
|
2136
2212
|
}>>;
|
|
2137
2213
|
openrouter: z.ZodDefault<z.ZodObject<{
|
|
2138
2214
|
apiKey: z.ZodDefault<z.ZodString>;
|
|
2139
2215
|
apiBase: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
2140
2216
|
extraHeaders: z.ZodDefault<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodString>>>;
|
|
2217
|
+
wireApi: z.ZodDefault<z.ZodEnum<["auto", "chat", "responses"]>>;
|
|
2141
2218
|
}, "strip", z.ZodTypeAny, {
|
|
2142
2219
|
apiKey: string;
|
|
2143
2220
|
apiBase: string | null;
|
|
2144
2221
|
extraHeaders: Record<string, string> | null;
|
|
2222
|
+
wireApi: "auto" | "chat" | "responses";
|
|
2145
2223
|
}, {
|
|
2146
2224
|
apiKey?: string | undefined;
|
|
2147
2225
|
apiBase?: string | null | undefined;
|
|
2148
2226
|
extraHeaders?: Record<string, string> | null | undefined;
|
|
2227
|
+
wireApi?: "auto" | "chat" | "responses" | undefined;
|
|
2149
2228
|
}>>;
|
|
2150
2229
|
deepseek: z.ZodDefault<z.ZodObject<{
|
|
2151
2230
|
apiKey: z.ZodDefault<z.ZodString>;
|
|
2152
2231
|
apiBase: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
2153
2232
|
extraHeaders: z.ZodDefault<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodString>>>;
|
|
2233
|
+
wireApi: z.ZodDefault<z.ZodEnum<["auto", "chat", "responses"]>>;
|
|
2154
2234
|
}, "strip", z.ZodTypeAny, {
|
|
2155
2235
|
apiKey: string;
|
|
2156
2236
|
apiBase: string | null;
|
|
2157
2237
|
extraHeaders: Record<string, string> | null;
|
|
2238
|
+
wireApi: "auto" | "chat" | "responses";
|
|
2158
2239
|
}, {
|
|
2159
2240
|
apiKey?: string | undefined;
|
|
2160
2241
|
apiBase?: string | null | undefined;
|
|
2161
2242
|
extraHeaders?: Record<string, string> | null | undefined;
|
|
2243
|
+
wireApi?: "auto" | "chat" | "responses" | undefined;
|
|
2162
2244
|
}>>;
|
|
2163
2245
|
groq: z.ZodDefault<z.ZodObject<{
|
|
2164
2246
|
apiKey: z.ZodDefault<z.ZodString>;
|
|
2165
2247
|
apiBase: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
2166
2248
|
extraHeaders: z.ZodDefault<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodString>>>;
|
|
2249
|
+
wireApi: z.ZodDefault<z.ZodEnum<["auto", "chat", "responses"]>>;
|
|
2167
2250
|
}, "strip", z.ZodTypeAny, {
|
|
2168
2251
|
apiKey: string;
|
|
2169
2252
|
apiBase: string | null;
|
|
2170
2253
|
extraHeaders: Record<string, string> | null;
|
|
2254
|
+
wireApi: "auto" | "chat" | "responses";
|
|
2171
2255
|
}, {
|
|
2172
2256
|
apiKey?: string | undefined;
|
|
2173
2257
|
apiBase?: string | null | undefined;
|
|
2174
2258
|
extraHeaders?: Record<string, string> | null | undefined;
|
|
2259
|
+
wireApi?: "auto" | "chat" | "responses" | undefined;
|
|
2175
2260
|
}>>;
|
|
2176
2261
|
zhipu: z.ZodDefault<z.ZodObject<{
|
|
2177
2262
|
apiKey: z.ZodDefault<z.ZodString>;
|
|
2178
2263
|
apiBase: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
2179
2264
|
extraHeaders: z.ZodDefault<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodString>>>;
|
|
2265
|
+
wireApi: z.ZodDefault<z.ZodEnum<["auto", "chat", "responses"]>>;
|
|
2180
2266
|
}, "strip", z.ZodTypeAny, {
|
|
2181
2267
|
apiKey: string;
|
|
2182
2268
|
apiBase: string | null;
|
|
2183
2269
|
extraHeaders: Record<string, string> | null;
|
|
2270
|
+
wireApi: "auto" | "chat" | "responses";
|
|
2184
2271
|
}, {
|
|
2185
2272
|
apiKey?: string | undefined;
|
|
2186
2273
|
apiBase?: string | null | undefined;
|
|
2187
2274
|
extraHeaders?: Record<string, string> | null | undefined;
|
|
2275
|
+
wireApi?: "auto" | "chat" | "responses" | undefined;
|
|
2188
2276
|
}>>;
|
|
2189
2277
|
dashscope: z.ZodDefault<z.ZodObject<{
|
|
2190
2278
|
apiKey: z.ZodDefault<z.ZodString>;
|
|
2191
2279
|
apiBase: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
2192
2280
|
extraHeaders: z.ZodDefault<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodString>>>;
|
|
2281
|
+
wireApi: z.ZodDefault<z.ZodEnum<["auto", "chat", "responses"]>>;
|
|
2193
2282
|
}, "strip", z.ZodTypeAny, {
|
|
2194
2283
|
apiKey: string;
|
|
2195
2284
|
apiBase: string | null;
|
|
2196
2285
|
extraHeaders: Record<string, string> | null;
|
|
2286
|
+
wireApi: "auto" | "chat" | "responses";
|
|
2197
2287
|
}, {
|
|
2198
2288
|
apiKey?: string | undefined;
|
|
2199
2289
|
apiBase?: string | null | undefined;
|
|
2200
2290
|
extraHeaders?: Record<string, string> | null | undefined;
|
|
2291
|
+
wireApi?: "auto" | "chat" | "responses" | undefined;
|
|
2201
2292
|
}>>;
|
|
2202
2293
|
vllm: z.ZodDefault<z.ZodObject<{
|
|
2203
2294
|
apiKey: z.ZodDefault<z.ZodString>;
|
|
2204
2295
|
apiBase: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
2205
2296
|
extraHeaders: z.ZodDefault<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodString>>>;
|
|
2297
|
+
wireApi: z.ZodDefault<z.ZodEnum<["auto", "chat", "responses"]>>;
|
|
2206
2298
|
}, "strip", z.ZodTypeAny, {
|
|
2207
2299
|
apiKey: string;
|
|
2208
2300
|
apiBase: string | null;
|
|
2209
2301
|
extraHeaders: Record<string, string> | null;
|
|
2302
|
+
wireApi: "auto" | "chat" | "responses";
|
|
2210
2303
|
}, {
|
|
2211
2304
|
apiKey?: string | undefined;
|
|
2212
2305
|
apiBase?: string | null | undefined;
|
|
2213
2306
|
extraHeaders?: Record<string, string> | null | undefined;
|
|
2307
|
+
wireApi?: "auto" | "chat" | "responses" | undefined;
|
|
2214
2308
|
}>>;
|
|
2215
2309
|
gemini: z.ZodDefault<z.ZodObject<{
|
|
2216
2310
|
apiKey: z.ZodDefault<z.ZodString>;
|
|
2217
2311
|
apiBase: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
2218
2312
|
extraHeaders: z.ZodDefault<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodString>>>;
|
|
2313
|
+
wireApi: z.ZodDefault<z.ZodEnum<["auto", "chat", "responses"]>>;
|
|
2219
2314
|
}, "strip", z.ZodTypeAny, {
|
|
2220
2315
|
apiKey: string;
|
|
2221
2316
|
apiBase: string | null;
|
|
2222
2317
|
extraHeaders: Record<string, string> | null;
|
|
2318
|
+
wireApi: "auto" | "chat" | "responses";
|
|
2223
2319
|
}, {
|
|
2224
2320
|
apiKey?: string | undefined;
|
|
2225
2321
|
apiBase?: string | null | undefined;
|
|
2226
2322
|
extraHeaders?: Record<string, string> | null | undefined;
|
|
2323
|
+
wireApi?: "auto" | "chat" | "responses" | undefined;
|
|
2227
2324
|
}>>;
|
|
2228
2325
|
moonshot: z.ZodDefault<z.ZodObject<{
|
|
2229
2326
|
apiKey: z.ZodDefault<z.ZodString>;
|
|
2230
2327
|
apiBase: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
2231
2328
|
extraHeaders: z.ZodDefault<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodString>>>;
|
|
2329
|
+
wireApi: z.ZodDefault<z.ZodEnum<["auto", "chat", "responses"]>>;
|
|
2232
2330
|
}, "strip", z.ZodTypeAny, {
|
|
2233
2331
|
apiKey: string;
|
|
2234
2332
|
apiBase: string | null;
|
|
2235
2333
|
extraHeaders: Record<string, string> | null;
|
|
2334
|
+
wireApi: "auto" | "chat" | "responses";
|
|
2236
2335
|
}, {
|
|
2237
2336
|
apiKey?: string | undefined;
|
|
2238
2337
|
apiBase?: string | null | undefined;
|
|
2239
2338
|
extraHeaders?: Record<string, string> | null | undefined;
|
|
2339
|
+
wireApi?: "auto" | "chat" | "responses" | undefined;
|
|
2240
2340
|
}>>;
|
|
2241
2341
|
minimax: z.ZodDefault<z.ZodObject<{
|
|
2242
2342
|
apiKey: z.ZodDefault<z.ZodString>;
|
|
2243
2343
|
apiBase: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
2244
2344
|
extraHeaders: z.ZodDefault<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodString>>>;
|
|
2345
|
+
wireApi: z.ZodDefault<z.ZodEnum<["auto", "chat", "responses"]>>;
|
|
2245
2346
|
}, "strip", z.ZodTypeAny, {
|
|
2246
2347
|
apiKey: string;
|
|
2247
2348
|
apiBase: string | null;
|
|
2248
2349
|
extraHeaders: Record<string, string> | null;
|
|
2350
|
+
wireApi: "auto" | "chat" | "responses";
|
|
2249
2351
|
}, {
|
|
2250
2352
|
apiKey?: string | undefined;
|
|
2251
2353
|
apiBase?: string | null | undefined;
|
|
2252
2354
|
extraHeaders?: Record<string, string> | null | undefined;
|
|
2355
|
+
wireApi?: "auto" | "chat" | "responses" | undefined;
|
|
2253
2356
|
}>>;
|
|
2254
2357
|
aihubmix: z.ZodDefault<z.ZodObject<{
|
|
2255
2358
|
apiKey: z.ZodDefault<z.ZodString>;
|
|
2256
2359
|
apiBase: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
2257
2360
|
extraHeaders: z.ZodDefault<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodString>>>;
|
|
2361
|
+
wireApi: z.ZodDefault<z.ZodEnum<["auto", "chat", "responses"]>>;
|
|
2258
2362
|
}, "strip", z.ZodTypeAny, {
|
|
2259
2363
|
apiKey: string;
|
|
2260
2364
|
apiBase: string | null;
|
|
2261
2365
|
extraHeaders: Record<string, string> | null;
|
|
2366
|
+
wireApi: "auto" | "chat" | "responses";
|
|
2262
2367
|
}, {
|
|
2263
2368
|
apiKey?: string | undefined;
|
|
2264
2369
|
apiBase?: string | null | undefined;
|
|
2265
2370
|
extraHeaders?: Record<string, string> | null | undefined;
|
|
2371
|
+
wireApi?: "auto" | "chat" | "responses" | undefined;
|
|
2266
2372
|
}>>;
|
|
2267
2373
|
}, "strip", z.ZodTypeAny, {
|
|
2268
2374
|
openrouter: {
|
|
2269
2375
|
apiKey: string;
|
|
2270
2376
|
apiBase: string | null;
|
|
2271
2377
|
extraHeaders: Record<string, string> | null;
|
|
2378
|
+
wireApi: "auto" | "chat" | "responses";
|
|
2272
2379
|
};
|
|
2273
2380
|
aihubmix: {
|
|
2274
2381
|
apiKey: string;
|
|
2275
2382
|
apiBase: string | null;
|
|
2276
2383
|
extraHeaders: Record<string, string> | null;
|
|
2384
|
+
wireApi: "auto" | "chat" | "responses";
|
|
2277
2385
|
};
|
|
2278
2386
|
openai: {
|
|
2279
2387
|
apiKey: string;
|
|
2280
2388
|
apiBase: string | null;
|
|
2281
2389
|
extraHeaders: Record<string, string> | null;
|
|
2390
|
+
wireApi: "auto" | "chat" | "responses";
|
|
2282
2391
|
};
|
|
2283
2392
|
anthropic: {
|
|
2284
2393
|
apiKey: string;
|
|
2285
2394
|
apiBase: string | null;
|
|
2286
2395
|
extraHeaders: Record<string, string> | null;
|
|
2396
|
+
wireApi: "auto" | "chat" | "responses";
|
|
2287
2397
|
};
|
|
2288
2398
|
deepseek: {
|
|
2289
2399
|
apiKey: string;
|
|
2290
2400
|
apiBase: string | null;
|
|
2291
2401
|
extraHeaders: Record<string, string> | null;
|
|
2402
|
+
wireApi: "auto" | "chat" | "responses";
|
|
2292
2403
|
};
|
|
2293
2404
|
gemini: {
|
|
2294
2405
|
apiKey: string;
|
|
2295
2406
|
apiBase: string | null;
|
|
2296
2407
|
extraHeaders: Record<string, string> | null;
|
|
2408
|
+
wireApi: "auto" | "chat" | "responses";
|
|
2297
2409
|
};
|
|
2298
2410
|
zhipu: {
|
|
2299
2411
|
apiKey: string;
|
|
2300
2412
|
apiBase: string | null;
|
|
2301
2413
|
extraHeaders: Record<string, string> | null;
|
|
2414
|
+
wireApi: "auto" | "chat" | "responses";
|
|
2302
2415
|
};
|
|
2303
2416
|
dashscope: {
|
|
2304
2417
|
apiKey: string;
|
|
2305
2418
|
apiBase: string | null;
|
|
2306
2419
|
extraHeaders: Record<string, string> | null;
|
|
2420
|
+
wireApi: "auto" | "chat" | "responses";
|
|
2307
2421
|
};
|
|
2308
2422
|
moonshot: {
|
|
2309
2423
|
apiKey: string;
|
|
2310
2424
|
apiBase: string | null;
|
|
2311
2425
|
extraHeaders: Record<string, string> | null;
|
|
2426
|
+
wireApi: "auto" | "chat" | "responses";
|
|
2312
2427
|
};
|
|
2313
2428
|
minimax: {
|
|
2314
2429
|
apiKey: string;
|
|
2315
2430
|
apiBase: string | null;
|
|
2316
2431
|
extraHeaders: Record<string, string> | null;
|
|
2432
|
+
wireApi: "auto" | "chat" | "responses";
|
|
2317
2433
|
};
|
|
2318
2434
|
vllm: {
|
|
2319
2435
|
apiKey: string;
|
|
2320
2436
|
apiBase: string | null;
|
|
2321
2437
|
extraHeaders: Record<string, string> | null;
|
|
2438
|
+
wireApi: "auto" | "chat" | "responses";
|
|
2322
2439
|
};
|
|
2323
2440
|
groq: {
|
|
2324
2441
|
apiKey: string;
|
|
2325
2442
|
apiBase: string | null;
|
|
2326
2443
|
extraHeaders: Record<string, string> | null;
|
|
2444
|
+
wireApi: "auto" | "chat" | "responses";
|
|
2327
2445
|
};
|
|
2328
2446
|
}, {
|
|
2329
2447
|
openrouter?: {
|
|
2330
2448
|
apiKey?: string | undefined;
|
|
2331
2449
|
apiBase?: string | null | undefined;
|
|
2332
2450
|
extraHeaders?: Record<string, string> | null | undefined;
|
|
2451
|
+
wireApi?: "auto" | "chat" | "responses" | undefined;
|
|
2333
2452
|
} | undefined;
|
|
2334
2453
|
aihubmix?: {
|
|
2335
2454
|
apiKey?: string | undefined;
|
|
2336
2455
|
apiBase?: string | null | undefined;
|
|
2337
2456
|
extraHeaders?: Record<string, string> | null | undefined;
|
|
2457
|
+
wireApi?: "auto" | "chat" | "responses" | undefined;
|
|
2338
2458
|
} | undefined;
|
|
2339
2459
|
openai?: {
|
|
2340
2460
|
apiKey?: string | undefined;
|
|
2341
2461
|
apiBase?: string | null | undefined;
|
|
2342
2462
|
extraHeaders?: Record<string, string> | null | undefined;
|
|
2463
|
+
wireApi?: "auto" | "chat" | "responses" | undefined;
|
|
2343
2464
|
} | undefined;
|
|
2344
2465
|
anthropic?: {
|
|
2345
2466
|
apiKey?: string | undefined;
|
|
2346
2467
|
apiBase?: string | null | undefined;
|
|
2347
2468
|
extraHeaders?: Record<string, string> | null | undefined;
|
|
2469
|
+
wireApi?: "auto" | "chat" | "responses" | undefined;
|
|
2348
2470
|
} | undefined;
|
|
2349
2471
|
deepseek?: {
|
|
2350
2472
|
apiKey?: string | undefined;
|
|
2351
2473
|
apiBase?: string | null | undefined;
|
|
2352
2474
|
extraHeaders?: Record<string, string> | null | undefined;
|
|
2475
|
+
wireApi?: "auto" | "chat" | "responses" | undefined;
|
|
2353
2476
|
} | undefined;
|
|
2354
2477
|
gemini?: {
|
|
2355
2478
|
apiKey?: string | undefined;
|
|
2356
2479
|
apiBase?: string | null | undefined;
|
|
2357
2480
|
extraHeaders?: Record<string, string> | null | undefined;
|
|
2481
|
+
wireApi?: "auto" | "chat" | "responses" | undefined;
|
|
2358
2482
|
} | undefined;
|
|
2359
2483
|
zhipu?: {
|
|
2360
2484
|
apiKey?: string | undefined;
|
|
2361
2485
|
apiBase?: string | null | undefined;
|
|
2362
2486
|
extraHeaders?: Record<string, string> | null | undefined;
|
|
2487
|
+
wireApi?: "auto" | "chat" | "responses" | undefined;
|
|
2363
2488
|
} | undefined;
|
|
2364
2489
|
dashscope?: {
|
|
2365
2490
|
apiKey?: string | undefined;
|
|
2366
2491
|
apiBase?: string | null | undefined;
|
|
2367
2492
|
extraHeaders?: Record<string, string> | null | undefined;
|
|
2493
|
+
wireApi?: "auto" | "chat" | "responses" | undefined;
|
|
2368
2494
|
} | undefined;
|
|
2369
2495
|
moonshot?: {
|
|
2370
2496
|
apiKey?: string | undefined;
|
|
2371
2497
|
apiBase?: string | null | undefined;
|
|
2372
2498
|
extraHeaders?: Record<string, string> | null | undefined;
|
|
2499
|
+
wireApi?: "auto" | "chat" | "responses" | undefined;
|
|
2373
2500
|
} | undefined;
|
|
2374
2501
|
minimax?: {
|
|
2375
2502
|
apiKey?: string | undefined;
|
|
2376
2503
|
apiBase?: string | null | undefined;
|
|
2377
2504
|
extraHeaders?: Record<string, string> | null | undefined;
|
|
2505
|
+
wireApi?: "auto" | "chat" | "responses" | undefined;
|
|
2378
2506
|
} | undefined;
|
|
2379
2507
|
vllm?: {
|
|
2380
2508
|
apiKey?: string | undefined;
|
|
2381
2509
|
apiBase?: string | null | undefined;
|
|
2382
2510
|
extraHeaders?: Record<string, string> | null | undefined;
|
|
2511
|
+
wireApi?: "auto" | "chat" | "responses" | undefined;
|
|
2383
2512
|
} | undefined;
|
|
2384
2513
|
groq?: {
|
|
2385
2514
|
apiKey?: string | undefined;
|
|
2386
2515
|
apiBase?: string | null | undefined;
|
|
2387
2516
|
extraHeaders?: Record<string, string> | null | undefined;
|
|
2517
|
+
wireApi?: "auto" | "chat" | "responses" | undefined;
|
|
2388
2518
|
} | undefined;
|
|
2389
2519
|
}>>;
|
|
2390
2520
|
gateway: z.ZodDefault<z.ZodObject<{
|
|
@@ -2589,61 +2719,73 @@ declare const ConfigSchema: z.ZodObject<{
|
|
|
2589
2719
|
apiKey: string;
|
|
2590
2720
|
apiBase: string | null;
|
|
2591
2721
|
extraHeaders: Record<string, string> | null;
|
|
2722
|
+
wireApi: "auto" | "chat" | "responses";
|
|
2592
2723
|
};
|
|
2593
2724
|
aihubmix: {
|
|
2594
2725
|
apiKey: string;
|
|
2595
2726
|
apiBase: string | null;
|
|
2596
2727
|
extraHeaders: Record<string, string> | null;
|
|
2728
|
+
wireApi: "auto" | "chat" | "responses";
|
|
2597
2729
|
};
|
|
2598
2730
|
openai: {
|
|
2599
2731
|
apiKey: string;
|
|
2600
2732
|
apiBase: string | null;
|
|
2601
2733
|
extraHeaders: Record<string, string> | null;
|
|
2734
|
+
wireApi: "auto" | "chat" | "responses";
|
|
2602
2735
|
};
|
|
2603
2736
|
anthropic: {
|
|
2604
2737
|
apiKey: string;
|
|
2605
2738
|
apiBase: string | null;
|
|
2606
2739
|
extraHeaders: Record<string, string> | null;
|
|
2740
|
+
wireApi: "auto" | "chat" | "responses";
|
|
2607
2741
|
};
|
|
2608
2742
|
deepseek: {
|
|
2609
2743
|
apiKey: string;
|
|
2610
2744
|
apiBase: string | null;
|
|
2611
2745
|
extraHeaders: Record<string, string> | null;
|
|
2746
|
+
wireApi: "auto" | "chat" | "responses";
|
|
2612
2747
|
};
|
|
2613
2748
|
gemini: {
|
|
2614
2749
|
apiKey: string;
|
|
2615
2750
|
apiBase: string | null;
|
|
2616
2751
|
extraHeaders: Record<string, string> | null;
|
|
2752
|
+
wireApi: "auto" | "chat" | "responses";
|
|
2617
2753
|
};
|
|
2618
2754
|
zhipu: {
|
|
2619
2755
|
apiKey: string;
|
|
2620
2756
|
apiBase: string | null;
|
|
2621
2757
|
extraHeaders: Record<string, string> | null;
|
|
2758
|
+
wireApi: "auto" | "chat" | "responses";
|
|
2622
2759
|
};
|
|
2623
2760
|
dashscope: {
|
|
2624
2761
|
apiKey: string;
|
|
2625
2762
|
apiBase: string | null;
|
|
2626
2763
|
extraHeaders: Record<string, string> | null;
|
|
2764
|
+
wireApi: "auto" | "chat" | "responses";
|
|
2627
2765
|
};
|
|
2628
2766
|
moonshot: {
|
|
2629
2767
|
apiKey: string;
|
|
2630
2768
|
apiBase: string | null;
|
|
2631
2769
|
extraHeaders: Record<string, string> | null;
|
|
2770
|
+
wireApi: "auto" | "chat" | "responses";
|
|
2632
2771
|
};
|
|
2633
2772
|
minimax: {
|
|
2634
2773
|
apiKey: string;
|
|
2635
2774
|
apiBase: string | null;
|
|
2636
2775
|
extraHeaders: Record<string, string> | null;
|
|
2776
|
+
wireApi: "auto" | "chat" | "responses";
|
|
2637
2777
|
};
|
|
2638
2778
|
vllm: {
|
|
2639
2779
|
apiKey: string;
|
|
2640
2780
|
apiBase: string | null;
|
|
2641
2781
|
extraHeaders: Record<string, string> | null;
|
|
2782
|
+
wireApi: "auto" | "chat" | "responses";
|
|
2642
2783
|
};
|
|
2643
2784
|
groq: {
|
|
2644
2785
|
apiKey: string;
|
|
2645
2786
|
apiBase: string | null;
|
|
2646
2787
|
extraHeaders: Record<string, string> | null;
|
|
2788
|
+
wireApi: "auto" | "chat" | "responses";
|
|
2647
2789
|
};
|
|
2648
2790
|
};
|
|
2649
2791
|
gateway: {
|
|
@@ -2790,61 +2932,73 @@ declare const ConfigSchema: z.ZodObject<{
|
|
|
2790
2932
|
apiKey?: string | undefined;
|
|
2791
2933
|
apiBase?: string | null | undefined;
|
|
2792
2934
|
extraHeaders?: Record<string, string> | null | undefined;
|
|
2935
|
+
wireApi?: "auto" | "chat" | "responses" | undefined;
|
|
2793
2936
|
} | undefined;
|
|
2794
2937
|
aihubmix?: {
|
|
2795
2938
|
apiKey?: string | undefined;
|
|
2796
2939
|
apiBase?: string | null | undefined;
|
|
2797
2940
|
extraHeaders?: Record<string, string> | null | undefined;
|
|
2941
|
+
wireApi?: "auto" | "chat" | "responses" | undefined;
|
|
2798
2942
|
} | undefined;
|
|
2799
2943
|
openai?: {
|
|
2800
2944
|
apiKey?: string | undefined;
|
|
2801
2945
|
apiBase?: string | null | undefined;
|
|
2802
2946
|
extraHeaders?: Record<string, string> | null | undefined;
|
|
2947
|
+
wireApi?: "auto" | "chat" | "responses" | undefined;
|
|
2803
2948
|
} | undefined;
|
|
2804
2949
|
anthropic?: {
|
|
2805
2950
|
apiKey?: string | undefined;
|
|
2806
2951
|
apiBase?: string | null | undefined;
|
|
2807
2952
|
extraHeaders?: Record<string, string> | null | undefined;
|
|
2953
|
+
wireApi?: "auto" | "chat" | "responses" | undefined;
|
|
2808
2954
|
} | undefined;
|
|
2809
2955
|
deepseek?: {
|
|
2810
2956
|
apiKey?: string | undefined;
|
|
2811
2957
|
apiBase?: string | null | undefined;
|
|
2812
2958
|
extraHeaders?: Record<string, string> | null | undefined;
|
|
2959
|
+
wireApi?: "auto" | "chat" | "responses" | undefined;
|
|
2813
2960
|
} | undefined;
|
|
2814
2961
|
gemini?: {
|
|
2815
2962
|
apiKey?: string | undefined;
|
|
2816
2963
|
apiBase?: string | null | undefined;
|
|
2817
2964
|
extraHeaders?: Record<string, string> | null | undefined;
|
|
2965
|
+
wireApi?: "auto" | "chat" | "responses" | undefined;
|
|
2818
2966
|
} | undefined;
|
|
2819
2967
|
zhipu?: {
|
|
2820
2968
|
apiKey?: string | undefined;
|
|
2821
2969
|
apiBase?: string | null | undefined;
|
|
2822
2970
|
extraHeaders?: Record<string, string> | null | undefined;
|
|
2971
|
+
wireApi?: "auto" | "chat" | "responses" | undefined;
|
|
2823
2972
|
} | undefined;
|
|
2824
2973
|
dashscope?: {
|
|
2825
2974
|
apiKey?: string | undefined;
|
|
2826
2975
|
apiBase?: string | null | undefined;
|
|
2827
2976
|
extraHeaders?: Record<string, string> | null | undefined;
|
|
2977
|
+
wireApi?: "auto" | "chat" | "responses" | undefined;
|
|
2828
2978
|
} | undefined;
|
|
2829
2979
|
moonshot?: {
|
|
2830
2980
|
apiKey?: string | undefined;
|
|
2831
2981
|
apiBase?: string | null | undefined;
|
|
2832
2982
|
extraHeaders?: Record<string, string> | null | undefined;
|
|
2983
|
+
wireApi?: "auto" | "chat" | "responses" | undefined;
|
|
2833
2984
|
} | undefined;
|
|
2834
2985
|
minimax?: {
|
|
2835
2986
|
apiKey?: string | undefined;
|
|
2836
2987
|
apiBase?: string | null | undefined;
|
|
2837
2988
|
extraHeaders?: Record<string, string> | null | undefined;
|
|
2989
|
+
wireApi?: "auto" | "chat" | "responses" | undefined;
|
|
2838
2990
|
} | undefined;
|
|
2839
2991
|
vllm?: {
|
|
2840
2992
|
apiKey?: string | undefined;
|
|
2841
2993
|
apiBase?: string | null | undefined;
|
|
2842
2994
|
extraHeaders?: Record<string, string> | null | undefined;
|
|
2995
|
+
wireApi?: "auto" | "chat" | "responses" | undefined;
|
|
2843
2996
|
} | undefined;
|
|
2844
2997
|
groq?: {
|
|
2845
2998
|
apiKey?: string | undefined;
|
|
2846
2999
|
apiBase?: string | null | undefined;
|
|
2847
3000
|
extraHeaders?: Record<string, string> | null | undefined;
|
|
3001
|
+
wireApi?: "auto" | "chat" | "responses" | undefined;
|
|
2848
3002
|
} | undefined;
|
|
2849
3003
|
} | undefined;
|
|
2850
3004
|
gateway?: {
|
|
@@ -2945,6 +3099,7 @@ declare function saveConfig(config: Config, configPath?: string): void;
|
|
|
2945
3099
|
type ReloadPlan = {
|
|
2946
3100
|
changedPaths: string[];
|
|
2947
3101
|
restartChannels: boolean;
|
|
3102
|
+
reloadProviders: boolean;
|
|
2948
3103
|
restartRequired: string[];
|
|
2949
3104
|
noopPaths: string[];
|
|
2950
3105
|
};
|
|
@@ -2976,6 +3131,7 @@ type LiteLLMProviderOptions = {
|
|
|
2976
3131
|
defaultModel: string;
|
|
2977
3132
|
extraHeaders?: Record<string, string> | null;
|
|
2978
3133
|
providerName?: string | null;
|
|
3134
|
+
wireApi?: "auto" | "chat" | "responses" | null;
|
|
2979
3135
|
};
|
|
2980
3136
|
declare class LiteLLMProvider extends LLMProvider {
|
|
2981
3137
|
private defaultModel;
|
|
@@ -2998,6 +3154,7 @@ declare class LiteLLMProvider extends LLMProvider {
|
|
|
2998
3154
|
private getStandardSpec;
|
|
2999
3155
|
}
|
|
3000
3156
|
|
|
3157
|
+
type WireApiMode = "auto" | "chat" | "responses";
|
|
3001
3158
|
type ProviderSpec = {
|
|
3002
3159
|
name: string;
|
|
3003
3160
|
keywords: string[];
|
|
@@ -3013,6 +3170,9 @@ type ProviderSpec = {
|
|
|
3013
3170
|
defaultApiBase?: string;
|
|
3014
3171
|
stripModelPrefix?: boolean;
|
|
3015
3172
|
modelOverrides?: Array<[string, Record<string, unknown>]>;
|
|
3173
|
+
supportsWireApi?: boolean;
|
|
3174
|
+
wireApiOptions?: WireApiMode[];
|
|
3175
|
+
defaultWireApi?: WireApiMode;
|
|
3016
3176
|
};
|
|
3017
3177
|
declare const PROVIDERS: ProviderSpec[];
|
|
3018
3178
|
declare function findProviderByName(name: string): ProviderSpec | undefined;
|
|
@@ -3036,4 +3196,4 @@ declare function parseSessionKey(key: string): {
|
|
|
3036
3196
|
};
|
|
3037
3197
|
declare function expandHome(value: string): string;
|
|
3038
3198
|
|
|
3039
|
-
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, type ProviderSpec, ProvidersConfigSchema, QQConfigSchema, type ReloadPlan, SKILL_METADATA_KEY, type Session, SessionManager, type SessionMessage, SlackConfigSchema, SlackDMSchema, TelegramConfigSchema, type ToolCallRequest, ToolsConfigSchema, UiConfigSchema, WebSearchConfigSchema, WebToolsConfigSchema, WhatsAppConfigSchema, 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 };
|
|
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 };
|
package/dist/index.js
CHANGED
|
@@ -898,7 +898,7 @@ function truncateOutput(result, maxLen = 1e4) {
|
|
|
898
898
|
}
|
|
899
899
|
|
|
900
900
|
// src/agent/tools/web.ts
|
|
901
|
-
import { fetch } from "undici";
|
|
901
|
+
import { fetch as fetch2 } from "undici";
|
|
902
902
|
var WebSearchTool = class extends Tool {
|
|
903
903
|
constructor(apiKey, maxResults = 5) {
|
|
904
904
|
super();
|
|
@@ -930,7 +930,7 @@ var WebSearchTool = class extends Tool {
|
|
|
930
930
|
const url = new URL("https://api.search.brave.com/res/v1/web/search");
|
|
931
931
|
url.searchParams.set("q", query);
|
|
932
932
|
url.searchParams.set("count", String(maxResults));
|
|
933
|
-
const response = await
|
|
933
|
+
const response = await fetch2(url.toString(), {
|
|
934
934
|
headers: {
|
|
935
935
|
"Accept": "application/json",
|
|
936
936
|
"X-Subscription-Token": this.apiKey
|
|
@@ -973,7 +973,7 @@ var WebFetchTool = class extends Tool {
|
|
|
973
973
|
}
|
|
974
974
|
async execute(params) {
|
|
975
975
|
const url = String(params.url ?? "");
|
|
976
|
-
const response = await
|
|
976
|
+
const response = await fetch2(url, { headers: { "User-Agent": APP_USER_AGENT } });
|
|
977
977
|
if (!response.ok) {
|
|
978
978
|
return `Error: Fetch failed (${response.status})`;
|
|
979
979
|
}
|
|
@@ -1178,7 +1178,7 @@ var SubagentManager = class {
|
|
|
1178
1178
|
let finalResult = null;
|
|
1179
1179
|
while (iteration < 15) {
|
|
1180
1180
|
iteration += 1;
|
|
1181
|
-
const response = await this.options.
|
|
1181
|
+
const response = await this.options.providerManager.get().chat({
|
|
1182
1182
|
messages,
|
|
1183
1183
|
tools: tools.getDefinitions(),
|
|
1184
1184
|
model: this.options.model
|
|
@@ -1421,10 +1421,10 @@ var AgentLoop = class {
|
|
|
1421
1421
|
this.sessions = options.sessionManager ?? new SessionManager(options.workspace);
|
|
1422
1422
|
this.tools = new ToolRegistry();
|
|
1423
1423
|
this.subagents = new SubagentManager({
|
|
1424
|
-
|
|
1424
|
+
providerManager: options.providerManager,
|
|
1425
1425
|
workspace: options.workspace,
|
|
1426
1426
|
bus: options.bus,
|
|
1427
|
-
model: options.model ?? options.
|
|
1427
|
+
model: options.model ?? options.providerManager.get().getDefaultModel(),
|
|
1428
1428
|
braveApiKey: options.braveApiKey ?? void 0,
|
|
1429
1429
|
execConfig: options.execConfig ?? { timeout: 60 },
|
|
1430
1430
|
restrictToWorkspace: options.restrictToWorkspace ?? false
|
|
@@ -1526,7 +1526,7 @@ var AgentLoop = class {
|
|
|
1526
1526
|
const maxIterations = this.options.maxIterations ?? 20;
|
|
1527
1527
|
while (iteration < maxIterations) {
|
|
1528
1528
|
iteration += 1;
|
|
1529
|
-
const response = await this.options.
|
|
1529
|
+
const response = await this.options.providerManager.get().chat({
|
|
1530
1530
|
messages,
|
|
1531
1531
|
tools: this.tools.getDefinitions(),
|
|
1532
1532
|
model: this.options.model ?? void 0
|
|
@@ -1591,7 +1591,7 @@ var AgentLoop = class {
|
|
|
1591
1591
|
const maxIterations = this.options.maxIterations ?? 20;
|
|
1592
1592
|
while (iteration < maxIterations) {
|
|
1593
1593
|
iteration += 1;
|
|
1594
|
-
const response = await this.options.
|
|
1594
|
+
const response = await this.options.providerManager.get().chat({
|
|
1595
1595
|
messages,
|
|
1596
1596
|
tools: this.tools.getDefinitions(),
|
|
1597
1597
|
model: this.options.model ?? void 0
|
|
@@ -1800,7 +1800,7 @@ var BaseChannel = class {
|
|
|
1800
1800
|
// src/providers/transcription.ts
|
|
1801
1801
|
import { createReadStream, existsSync as existsSync7 } from "fs";
|
|
1802
1802
|
import { basename } from "path";
|
|
1803
|
-
import { FormData, fetch as
|
|
1803
|
+
import { FormData, fetch as fetch3 } from "undici";
|
|
1804
1804
|
var GroqTranscriptionProvider = class {
|
|
1805
1805
|
apiKey;
|
|
1806
1806
|
apiUrl = "https://api.groq.com/openai/v1/audio/transcriptions";
|
|
@@ -1817,7 +1817,7 @@ var GroqTranscriptionProvider = class {
|
|
|
1817
1817
|
const form = new FormData();
|
|
1818
1818
|
form.append("file", createReadStream(filePath), basename(filePath));
|
|
1819
1819
|
form.append("model", "whisper-large-v3");
|
|
1820
|
-
const response = await
|
|
1820
|
+
const response = await fetch3(this.apiUrl, {
|
|
1821
1821
|
method: "POST",
|
|
1822
1822
|
headers: {
|
|
1823
1823
|
Authorization: `Bearer ${this.apiKey}`
|
|
@@ -2182,7 +2182,7 @@ import {
|
|
|
2182
2182
|
GatewayIntentBits,
|
|
2183
2183
|
Partials
|
|
2184
2184
|
} from "discord.js";
|
|
2185
|
-
import { fetch as
|
|
2185
|
+
import { fetch as fetch4 } from "undici";
|
|
2186
2186
|
import { join as join6 } from "path";
|
|
2187
2187
|
import { mkdirSync as mkdirSync3, writeFileSync as writeFileSync4 } from "fs";
|
|
2188
2188
|
var MAX_ATTACHMENT_BYTES = 20 * 1024 * 1024;
|
|
@@ -2262,7 +2262,7 @@ var DiscordChannel = class extends BaseChannel {
|
|
|
2262
2262
|
continue;
|
|
2263
2263
|
}
|
|
2264
2264
|
try {
|
|
2265
|
-
const res = await
|
|
2265
|
+
const res = await fetch4(attachment.url);
|
|
2266
2266
|
if (!res.ok) {
|
|
2267
2267
|
contentParts.push(`[attachment: ${attachment.name ?? "file"} - download failed]`);
|
|
2268
2268
|
continue;
|
|
@@ -2515,7 +2515,7 @@ function parseMdTable(tableText) {
|
|
|
2515
2515
|
|
|
2516
2516
|
// src/channels/mochat.ts
|
|
2517
2517
|
import { io } from "socket.io-client";
|
|
2518
|
-
import { fetch as
|
|
2518
|
+
import { fetch as fetch5 } from "undici";
|
|
2519
2519
|
import { join as join7 } from "path";
|
|
2520
2520
|
import { mkdirSync as mkdirSync4, existsSync as existsSync8, readFileSync as readFileSync6, writeFileSync as writeFileSync5 } from "fs";
|
|
2521
2521
|
var MAX_SEEN_MESSAGE_IDS = 2e3;
|
|
@@ -3259,7 +3259,7 @@ var MochatChannel = class extends BaseChannel {
|
|
|
3259
3259
|
}
|
|
3260
3260
|
async postJson(path, payload) {
|
|
3261
3261
|
const url = `${this.config.baseUrl.trim().replace(/\/$/, "")}${path}`;
|
|
3262
|
-
const response = await
|
|
3262
|
+
const response = await fetch5(url, {
|
|
3263
3263
|
method: "POST",
|
|
3264
3264
|
headers: {
|
|
3265
3265
|
"content-type": "application/json",
|
|
@@ -3464,7 +3464,7 @@ function sleep2(ms) {
|
|
|
3464
3464
|
|
|
3465
3465
|
// src/channels/dingtalk.ts
|
|
3466
3466
|
import { DWClient, EventAck, TOPIC_ROBOT } from "dingtalk-stream";
|
|
3467
|
-
import { fetch as
|
|
3467
|
+
import { fetch as fetch6 } from "undici";
|
|
3468
3468
|
var DingTalkChannel = class extends BaseChannel {
|
|
3469
3469
|
name = "dingtalk";
|
|
3470
3470
|
client = null;
|
|
@@ -3511,7 +3511,7 @@ var DingTalkChannel = class extends BaseChannel {
|
|
|
3511
3511
|
title: `${APP_TITLE} Reply`
|
|
3512
3512
|
})
|
|
3513
3513
|
};
|
|
3514
|
-
const response = await
|
|
3514
|
+
const response = await fetch6(url, {
|
|
3515
3515
|
method: "POST",
|
|
3516
3516
|
headers: {
|
|
3517
3517
|
"content-type": "application/json",
|
|
@@ -3565,7 +3565,7 @@ var DingTalkChannel = class extends BaseChannel {
|
|
|
3565
3565
|
appKey: this.config.clientId,
|
|
3566
3566
|
appSecret: this.config.clientSecret
|
|
3567
3567
|
};
|
|
3568
|
-
const response = await
|
|
3568
|
+
const response = await fetch6(url, {
|
|
3569
3569
|
method: "POST",
|
|
3570
3570
|
headers: { "content-type": "application/json" },
|
|
3571
3571
|
body: JSON.stringify(payload)
|
|
@@ -4257,7 +4257,10 @@ var PROVIDERS = [
|
|
|
4257
4257
|
detectByBaseKeyword: "",
|
|
4258
4258
|
defaultApiBase: "",
|
|
4259
4259
|
stripModelPrefix: false,
|
|
4260
|
-
modelOverrides: []
|
|
4260
|
+
modelOverrides: [],
|
|
4261
|
+
supportsWireApi: true,
|
|
4262
|
+
wireApiOptions: ["auto", "chat", "responses"],
|
|
4263
|
+
defaultWireApi: "auto"
|
|
4261
4264
|
},
|
|
4262
4265
|
{
|
|
4263
4266
|
name: "deepseek",
|
|
@@ -4555,7 +4558,8 @@ var AgentsConfigSchema = z.object({
|
|
|
4555
4558
|
var ProviderConfigSchema = z.object({
|
|
4556
4559
|
apiKey: z.string().default(""),
|
|
4557
4560
|
apiBase: z.string().nullable().default(null),
|
|
4558
|
-
extraHeaders: z.record(z.string()).nullable().default(null)
|
|
4561
|
+
extraHeaders: z.record(z.string()).nullable().default(null),
|
|
4562
|
+
wireApi: z.enum(["auto", "chat", "responses"]).default("auto")
|
|
4559
4563
|
});
|
|
4560
4564
|
var ProvidersConfigSchema = z.object({
|
|
4561
4565
|
anthropic: ProviderConfigSchema.default({}),
|
|
@@ -4696,7 +4700,7 @@ var isPlainObject = (value) => {
|
|
|
4696
4700
|
};
|
|
4697
4701
|
var RELOAD_RULES = [
|
|
4698
4702
|
{ prefix: "channels", kind: "restart-channels" },
|
|
4699
|
-
{ prefix: "providers", kind: "
|
|
4703
|
+
{ prefix: "providers", kind: "reload-providers" },
|
|
4700
4704
|
{ prefix: "agents.defaults.model", kind: "restart-required" },
|
|
4701
4705
|
{ prefix: "agents.defaults.maxTokens", kind: "restart-required" },
|
|
4702
4706
|
{ prefix: "agents.defaults.temperature", kind: "restart-required" },
|
|
@@ -4745,6 +4749,7 @@ function buildReloadPlan(changedPaths) {
|
|
|
4745
4749
|
const plan = {
|
|
4746
4750
|
changedPaths,
|
|
4747
4751
|
restartChannels: false,
|
|
4752
|
+
reloadProviders: false,
|
|
4748
4753
|
restartRequired: [],
|
|
4749
4754
|
noopPaths: []
|
|
4750
4755
|
};
|
|
@@ -4758,6 +4763,10 @@ function buildReloadPlan(changedPaths) {
|
|
|
4758
4763
|
plan.restartChannels = true;
|
|
4759
4764
|
continue;
|
|
4760
4765
|
}
|
|
4766
|
+
if (rule.kind === "reload-providers") {
|
|
4767
|
+
plan.reloadProviders = true;
|
|
4768
|
+
continue;
|
|
4769
|
+
}
|
|
4761
4770
|
if (rule.kind === "restart-required") {
|
|
4762
4771
|
plan.restartRequired.push(path);
|
|
4763
4772
|
continue;
|
|
@@ -5107,10 +5116,12 @@ var OpenAICompatibleProvider = class extends LLMProvider {
|
|
|
5107
5116
|
client;
|
|
5108
5117
|
defaultModel;
|
|
5109
5118
|
extraHeaders;
|
|
5119
|
+
wireApi;
|
|
5110
5120
|
constructor(options) {
|
|
5111
5121
|
super(options.apiKey, options.apiBase);
|
|
5112
5122
|
this.defaultModel = options.defaultModel;
|
|
5113
5123
|
this.extraHeaders = options.extraHeaders ?? null;
|
|
5124
|
+
this.wireApi = options.wireApi ?? "auto";
|
|
5114
5125
|
this.client = new OpenAI({
|
|
5115
5126
|
apiKey: options.apiKey ?? void 0,
|
|
5116
5127
|
baseURL: options.apiBase ?? void 0,
|
|
@@ -5121,6 +5132,22 @@ var OpenAICompatibleProvider = class extends LLMProvider {
|
|
|
5121
5132
|
return this.defaultModel;
|
|
5122
5133
|
}
|
|
5123
5134
|
async chat(params) {
|
|
5135
|
+
if (this.wireApi === "chat") {
|
|
5136
|
+
return this.chatCompletions(params);
|
|
5137
|
+
}
|
|
5138
|
+
if (this.wireApi === "responses") {
|
|
5139
|
+
return this.chatResponses(params);
|
|
5140
|
+
}
|
|
5141
|
+
try {
|
|
5142
|
+
return await this.chatCompletions(params);
|
|
5143
|
+
} catch (error) {
|
|
5144
|
+
if (this.shouldFallbackToResponses(error)) {
|
|
5145
|
+
return await this.chatResponses(params);
|
|
5146
|
+
}
|
|
5147
|
+
throw error;
|
|
5148
|
+
}
|
|
5149
|
+
}
|
|
5150
|
+
async chatCompletions(params) {
|
|
5124
5151
|
const model = params.model ?? this.defaultModel;
|
|
5125
5152
|
const temperature = params.temperature ?? 0.7;
|
|
5126
5153
|
const maxTokens = params.maxTokens ?? 4096;
|
|
@@ -5166,6 +5193,141 @@ var OpenAICompatibleProvider = class extends LLMProvider {
|
|
|
5166
5193
|
reasoningContent
|
|
5167
5194
|
};
|
|
5168
5195
|
}
|
|
5196
|
+
async chatResponses(params) {
|
|
5197
|
+
const model = params.model ?? this.defaultModel;
|
|
5198
|
+
const input = this.toResponsesInput(params.messages);
|
|
5199
|
+
const body = { model, input };
|
|
5200
|
+
if (params.tools && params.tools.length) {
|
|
5201
|
+
body.tools = params.tools;
|
|
5202
|
+
}
|
|
5203
|
+
const base = this.apiBase ?? "https://api.openai.com/v1";
|
|
5204
|
+
const responseUrl = new URL("responses", base.endsWith("/") ? base : `${base}/`);
|
|
5205
|
+
const response = await fetch(responseUrl.toString(), {
|
|
5206
|
+
method: "POST",
|
|
5207
|
+
headers: {
|
|
5208
|
+
"Authorization": this.apiKey ? `Bearer ${this.apiKey}` : "",
|
|
5209
|
+
"Content-Type": "application/json",
|
|
5210
|
+
...this.extraHeaders ?? {}
|
|
5211
|
+
},
|
|
5212
|
+
body: JSON.stringify(body)
|
|
5213
|
+
});
|
|
5214
|
+
if (!response.ok) {
|
|
5215
|
+
const text = await response.text();
|
|
5216
|
+
throw new Error(`Responses API failed (${response.status}): ${text.slice(0, 200)}`);
|
|
5217
|
+
}
|
|
5218
|
+
const responseAny = await response.json();
|
|
5219
|
+
const outputItems = responseAny.output ?? [];
|
|
5220
|
+
const toolCalls = [];
|
|
5221
|
+
const contentParts = [];
|
|
5222
|
+
let reasoningContent = null;
|
|
5223
|
+
for (const item of outputItems) {
|
|
5224
|
+
const itemAny = item;
|
|
5225
|
+
if (itemAny.type === "reasoning" && Array.isArray(itemAny.summary)) {
|
|
5226
|
+
const summaryText = itemAny.summary.map((entry) => typeof entry === "string" ? entry : String(entry.text ?? "")).filter(Boolean).join("\n");
|
|
5227
|
+
reasoningContent = summaryText || reasoningContent;
|
|
5228
|
+
}
|
|
5229
|
+
if (itemAny.type === "message" && Array.isArray(itemAny.content)) {
|
|
5230
|
+
for (const part of itemAny.content) {
|
|
5231
|
+
const partAny = part;
|
|
5232
|
+
if (partAny?.type === "output_text" || partAny?.type === "text") {
|
|
5233
|
+
const text = String(partAny?.text ?? "");
|
|
5234
|
+
if (text) {
|
|
5235
|
+
contentParts.push(text);
|
|
5236
|
+
}
|
|
5237
|
+
}
|
|
5238
|
+
}
|
|
5239
|
+
}
|
|
5240
|
+
if (itemAny.type === "tool_call" || itemAny.type === "function_call") {
|
|
5241
|
+
const itemFunction = itemAny.function;
|
|
5242
|
+
const name = String(itemAny.name ?? itemFunction?.name ?? "");
|
|
5243
|
+
const rawArgs = itemAny.arguments ?? itemFunction?.arguments ?? itemAny.input ?? itemFunction?.input ?? "{}";
|
|
5244
|
+
let args = {};
|
|
5245
|
+
try {
|
|
5246
|
+
args = typeof rawArgs === "string" ? JSON.parse(rawArgs) : rawArgs;
|
|
5247
|
+
} catch {
|
|
5248
|
+
args = {};
|
|
5249
|
+
}
|
|
5250
|
+
toolCalls.push({
|
|
5251
|
+
id: String(itemAny.id ?? itemAny.call_id ?? `${name}-${toolCalls.length}`),
|
|
5252
|
+
name,
|
|
5253
|
+
arguments: args
|
|
5254
|
+
});
|
|
5255
|
+
}
|
|
5256
|
+
}
|
|
5257
|
+
const usage = responseAny.usage ?? {};
|
|
5258
|
+
return {
|
|
5259
|
+
content: contentParts.join("") || null,
|
|
5260
|
+
toolCalls,
|
|
5261
|
+
finishReason: responseAny.status ?? "stop",
|
|
5262
|
+
usage: {
|
|
5263
|
+
prompt_tokens: usage.input_tokens ?? usage.prompt_tokens ?? 0,
|
|
5264
|
+
completion_tokens: usage.output_tokens ?? usage.completion_tokens ?? 0,
|
|
5265
|
+
total_tokens: usage.total_tokens ?? 0
|
|
5266
|
+
},
|
|
5267
|
+
reasoningContent
|
|
5268
|
+
};
|
|
5269
|
+
}
|
|
5270
|
+
shouldFallbackToResponses(error) {
|
|
5271
|
+
const err = error;
|
|
5272
|
+
const status = err?.status;
|
|
5273
|
+
const message = err?.message ?? "";
|
|
5274
|
+
if (status === 404) {
|
|
5275
|
+
return true;
|
|
5276
|
+
}
|
|
5277
|
+
if (message.includes("Cannot POST") && message.includes("chat/completions")) {
|
|
5278
|
+
return true;
|
|
5279
|
+
}
|
|
5280
|
+
if (message.includes("chat/completions") && message.includes("404")) {
|
|
5281
|
+
return true;
|
|
5282
|
+
}
|
|
5283
|
+
return false;
|
|
5284
|
+
}
|
|
5285
|
+
toResponsesInput(messages) {
|
|
5286
|
+
const input = [];
|
|
5287
|
+
for (const msg of messages) {
|
|
5288
|
+
const role = String(msg.role ?? "user");
|
|
5289
|
+
const content = msg.content;
|
|
5290
|
+
if (role === "tool") {
|
|
5291
|
+
const callId = typeof msg.tool_call_id === "string" ? msg.tool_call_id : "";
|
|
5292
|
+
const outputText = typeof content === "string" ? content : Array.isArray(content) ? JSON.stringify(content) : String(content ?? "");
|
|
5293
|
+
input.push({
|
|
5294
|
+
type: "function_call_output",
|
|
5295
|
+
call_id: callId,
|
|
5296
|
+
output: outputText
|
|
5297
|
+
});
|
|
5298
|
+
continue;
|
|
5299
|
+
}
|
|
5300
|
+
const output = { role };
|
|
5301
|
+
if (Array.isArray(content) || typeof content === "string") {
|
|
5302
|
+
output.content = content;
|
|
5303
|
+
} else {
|
|
5304
|
+
output.content = String(content ?? "");
|
|
5305
|
+
}
|
|
5306
|
+
if (typeof msg.reasoning_content === "string" && msg.reasoning_content) {
|
|
5307
|
+
output.reasoning = msg.reasoning_content;
|
|
5308
|
+
}
|
|
5309
|
+
input.push(output);
|
|
5310
|
+
if (Array.isArray(msg.tool_calls)) {
|
|
5311
|
+
for (const call of msg.tool_calls) {
|
|
5312
|
+
const callAny = call;
|
|
5313
|
+
const functionAny = callAny.function ?? {};
|
|
5314
|
+
const callId = String(callAny.id ?? callAny.call_id ?? "");
|
|
5315
|
+
const name = String(functionAny.name ?? callAny.name ?? "");
|
|
5316
|
+
const args = String(functionAny.arguments ?? callAny.arguments ?? "{}");
|
|
5317
|
+
if (!callId || !name) {
|
|
5318
|
+
continue;
|
|
5319
|
+
}
|
|
5320
|
+
input.push({
|
|
5321
|
+
type: "function_call",
|
|
5322
|
+
name,
|
|
5323
|
+
arguments: args,
|
|
5324
|
+
call_id: callId
|
|
5325
|
+
});
|
|
5326
|
+
}
|
|
5327
|
+
}
|
|
5328
|
+
}
|
|
5329
|
+
return input;
|
|
5330
|
+
}
|
|
5169
5331
|
};
|
|
5170
5332
|
|
|
5171
5333
|
// src/providers/litellm_provider.ts
|
|
@@ -5181,11 +5343,14 @@ var LiteLLMProvider = class extends LLMProvider {
|
|
|
5181
5343
|
this.extraHeaders = options.extraHeaders ?? null;
|
|
5182
5344
|
this.providerName = options.providerName ?? null;
|
|
5183
5345
|
this.gatewaySpec = findGateway(this.providerName, options.apiKey ?? null, options.apiBase ?? null) ?? void 0;
|
|
5346
|
+
const providerSpec = this.providerName ? findProviderByName(this.providerName) : void 0;
|
|
5347
|
+
const wireApi = providerSpec?.supportsWireApi ? options.wireApi ?? providerSpec.defaultWireApi ?? "auto" : void 0;
|
|
5184
5348
|
this.client = new OpenAICompatibleProvider({
|
|
5185
5349
|
apiKey: options.apiKey ?? null,
|
|
5186
5350
|
apiBase: options.apiBase ?? null,
|
|
5187
5351
|
defaultModel: options.defaultModel,
|
|
5188
|
-
extraHeaders: options.extraHeaders ?? null
|
|
5352
|
+
extraHeaders: options.extraHeaders ?? null,
|
|
5353
|
+
wireApi
|
|
5189
5354
|
});
|
|
5190
5355
|
}
|
|
5191
5356
|
getDefaultModel() {
|
|
@@ -5263,6 +5428,20 @@ var LiteLLMProvider = class extends LLMProvider {
|
|
|
5263
5428
|
return findProviderByModel(model) ?? (this.providerName ? findProviderByName(this.providerName) : void 0);
|
|
5264
5429
|
}
|
|
5265
5430
|
};
|
|
5431
|
+
|
|
5432
|
+
// src/providers/provider_manager.ts
|
|
5433
|
+
var ProviderManager = class {
|
|
5434
|
+
provider;
|
|
5435
|
+
constructor(provider) {
|
|
5436
|
+
this.provider = provider;
|
|
5437
|
+
}
|
|
5438
|
+
get() {
|
|
5439
|
+
return this.provider;
|
|
5440
|
+
}
|
|
5441
|
+
set(next) {
|
|
5442
|
+
this.provider = next;
|
|
5443
|
+
}
|
|
5444
|
+
};
|
|
5266
5445
|
export {
|
|
5267
5446
|
APP_NAME,
|
|
5268
5447
|
APP_REPLY_SUBJECT,
|
|
@@ -5301,6 +5480,7 @@ export {
|
|
|
5301
5480
|
MochatMentionSchema,
|
|
5302
5481
|
PROVIDERS,
|
|
5303
5482
|
ProviderConfigSchema,
|
|
5483
|
+
ProviderManager,
|
|
5304
5484
|
ProvidersConfigSchema,
|
|
5305
5485
|
QQConfigSchema,
|
|
5306
5486
|
SKILL_METADATA_KEY,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nextclaw-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Nextclaw runtime core (agent, channels, providers, config).",
|
|
6
6
|
"type": "module",
|
|
@@ -13,12 +13,6 @@
|
|
|
13
13
|
"files": [
|
|
14
14
|
"dist"
|
|
15
15
|
],
|
|
16
|
-
"scripts": {
|
|
17
|
-
"build": "tsup src/index.ts --format esm --dts --out-dir dist",
|
|
18
|
-
"lint": "eslint .",
|
|
19
|
-
"tsc": "tsc -p tsconfig.json",
|
|
20
|
-
"test": "vitest"
|
|
21
|
-
},
|
|
22
16
|
"dependencies": {
|
|
23
17
|
"@larksuiteoapi/node-sdk": "^1.58.0",
|
|
24
18
|
"@slack/socket-mode": "^1.3.3",
|
|
@@ -57,5 +51,11 @@
|
|
|
57
51
|
"tsx": "^4.19.2",
|
|
58
52
|
"typescript": "^5.6.3",
|
|
59
53
|
"vitest": "^2.1.2"
|
|
54
|
+
},
|
|
55
|
+
"scripts": {
|
|
56
|
+
"build": "tsup src/index.ts --format esm --dts --out-dir dist",
|
|
57
|
+
"lint": "eslint .",
|
|
58
|
+
"tsc": "tsc -p tsconfig.json",
|
|
59
|
+
"test": "vitest"
|
|
60
60
|
}
|
|
61
|
-
}
|
|
61
|
+
}
|