ppagent 0.0.39 → 0.2.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/lib.d.ts +159 -180
- package/dist/lib.js +26 -21
- package/package.json +22 -9
package/dist/lib.d.ts
CHANGED
|
@@ -5,10 +5,10 @@ import { WebSocket } from 'ws';
|
|
|
5
5
|
import { ReadStream, Stats } from 'node:fs';
|
|
6
6
|
import { Buffer as Buffer$1 } from 'node:buffer';
|
|
7
7
|
import { ISchema, SchemaProperties } from '@formily/react';
|
|
8
|
+
import Keyv from 'keyv';
|
|
8
9
|
import * as http from 'http';
|
|
9
|
-
import {
|
|
10
|
+
import { Tool } from 'ai';
|
|
10
11
|
import pino, { Level } from 'pino';
|
|
11
|
-
import Keyv from 'keyv';
|
|
12
12
|
import { StreamChatReq, CozeAPI, CreateChatData, StreamChatData } from '@coze/api';
|
|
13
13
|
import OpenAI, { ClientOptions } from 'openai';
|
|
14
14
|
import * as typeorm from 'typeorm';
|
|
@@ -105,6 +105,7 @@ interface IModelInfo {
|
|
|
105
105
|
user_updated?: string;
|
|
106
106
|
date_update?: any;
|
|
107
107
|
name: string;
|
|
108
|
+
displayName?: string;
|
|
108
109
|
desc?: string;
|
|
109
110
|
}
|
|
110
111
|
declare enum SimpleSchemaType {
|
|
@@ -153,7 +154,7 @@ interface IConfigParams {
|
|
|
153
154
|
name: string;
|
|
154
155
|
desc?: string;
|
|
155
156
|
/**
|
|
156
|
-
*
|
|
157
|
+
* 公共目录的相对或者绝对路径,如 /public/images/logo.png
|
|
157
158
|
*/
|
|
158
159
|
logoPath?: string;
|
|
159
160
|
/**
|
|
@@ -187,10 +188,6 @@ declare const config: {
|
|
|
187
188
|
publicPathName: string;
|
|
188
189
|
tempDir: string;
|
|
189
190
|
redisUrl: string;
|
|
190
|
-
offline: boolean;
|
|
191
|
-
configServerUrl: string;
|
|
192
|
-
configServerEmail: string;
|
|
193
|
-
configServerPassword: string;
|
|
194
191
|
publicToken: string;
|
|
195
192
|
publicForceAuth: boolean;
|
|
196
193
|
secretFile: string;
|
|
@@ -203,6 +200,26 @@ declare const config: {
|
|
|
203
200
|
dataPath: string;
|
|
204
201
|
dbProvider: string;
|
|
205
202
|
dbConnection: string;
|
|
203
|
+
imUserId: string;
|
|
204
|
+
imUserNickname: string;
|
|
205
|
+
imUserFaceURL: string;
|
|
206
|
+
imUserEx: {
|
|
207
|
+
owner: boolean;
|
|
208
|
+
};
|
|
209
|
+
imUserUpdateInfo: boolean;
|
|
210
|
+
imEnabled: boolean;
|
|
211
|
+
imApiAddr: string;
|
|
212
|
+
imWSAddr: string;
|
|
213
|
+
imRootID: string;
|
|
214
|
+
imRootSecret: string;
|
|
215
|
+
imSourceFilterMode: string;
|
|
216
|
+
imSourceFilterList: string[];
|
|
217
|
+
minioEnabled: boolean;
|
|
218
|
+
minioEndpoint: string;
|
|
219
|
+
minioPort: number;
|
|
220
|
+
minioAccessKey: string;
|
|
221
|
+
minioSecretKey: string;
|
|
222
|
+
minioSSL: boolean;
|
|
206
223
|
minioMessageBucket: string;
|
|
207
224
|
};
|
|
208
225
|
|
|
@@ -249,6 +266,7 @@ declare abstract class InstanceBaseManager<InstanceType extends IInstance, Creat
|
|
|
249
266
|
* @returns
|
|
250
267
|
*/
|
|
251
268
|
getInstance(instanceName: string): InstanceType;
|
|
269
|
+
removeInstance(instanceName: string): void;
|
|
252
270
|
/**
|
|
253
271
|
* 获取某个类型的所有的实例
|
|
254
272
|
* @param typeName 类型名称
|
|
@@ -705,9 +723,9 @@ interface ISourceChatMessage {
|
|
|
705
723
|
*/
|
|
706
724
|
customType?: string;
|
|
707
725
|
/**
|
|
708
|
-
* 消息状态,仅用于标记大模型返回的消息。reasoning表示推理过程消息,content
|
|
726
|
+
* 消息状态,仅用于标记大模型返回的消息。reasoning表示推理过程消息,content表示回复的消息,tool表示工具调用消息。为空表示content。
|
|
709
727
|
*/
|
|
710
|
-
status?: "reasoning" | "content";
|
|
728
|
+
status?: "reasoning" | "content" | "tool";
|
|
711
729
|
}
|
|
712
730
|
interface ISourceGroupChatMessage extends ISourceChatMessage {
|
|
713
731
|
groupInfo: ISourceUserInfo;
|
|
@@ -886,6 +904,7 @@ interface IBotParams extends IConfigParams {
|
|
|
886
904
|
* 在一个用户的当前对话中是否允许有多个活跃的chat,默认false。,一般均不允许,agent会等待bot上一个回复完成再继续下一次对话
|
|
887
905
|
*/
|
|
888
906
|
allowMultiActiveChat?: boolean;
|
|
907
|
+
supportTools?: boolean;
|
|
889
908
|
}
|
|
890
909
|
/**
|
|
891
910
|
* 机器人的实例属性,在创建机器人实例的时候配置
|
|
@@ -895,6 +914,11 @@ interface IBotOptions extends IInstanceCreateOptions {
|
|
|
895
914
|
* 并不是所有bot都支持自定义prompt,比如agent类的,一般都在agent平台上预置好,或者通过自定义变量传入
|
|
896
915
|
*/
|
|
897
916
|
systemPrompt?: string;
|
|
917
|
+
/**
|
|
918
|
+
* 可调用的工具集的instanceId.toolKey集合。不是所有bot都支持工具调用。
|
|
919
|
+
* 如 ["toolInstanceId1.toolKey1", "toolInstanceId2.toolKey2"]
|
|
920
|
+
*/
|
|
921
|
+
tools?: string[];
|
|
898
922
|
}
|
|
899
923
|
interface IMessageContentReceiver {
|
|
900
924
|
/**
|
|
@@ -1007,22 +1031,28 @@ interface IBotCacheMessage {
|
|
|
1007
1031
|
*/
|
|
1008
1032
|
declare class HistoryMessageManager {
|
|
1009
1033
|
protected options: IHisotryMessageManagerOptions;
|
|
1034
|
+
protected namespace: string;
|
|
1010
1035
|
static DefaultOptions: IHisotryMessageManagerOptions;
|
|
1011
|
-
|
|
1036
|
+
protected cache: Keyv;
|
|
1037
|
+
constructor(options: IHisotryMessageManagerOptions, namespace?: string);
|
|
1012
1038
|
protected messages: IBotCacheMessage[];
|
|
1013
1039
|
protected wordsCount: number;
|
|
1040
|
+
protected loaded: boolean;
|
|
1041
|
+
protected loadPromise: Promise<void> | undefined;
|
|
1042
|
+
protected load(): Promise<void>;
|
|
1043
|
+
protected save(): void;
|
|
1014
1044
|
/**
|
|
1015
1045
|
* 增加一条历史消息,如果是文本类型的,需要单独传入文本内容content,以便统计字数
|
|
1016
1046
|
* @param message
|
|
1017
1047
|
* @param content
|
|
1018
1048
|
*/
|
|
1019
|
-
addMessage(message: IBotHistoryMessage, content?: SourceChatContent): void
|
|
1049
|
+
addMessage(message: IBotHistoryMessage, content?: SourceChatContent): Promise<void>;
|
|
1020
1050
|
/**
|
|
1021
1051
|
* 获取历史消息,获取的是内部的一个浅拷贝
|
|
1022
1052
|
* @returns
|
|
1023
1053
|
*/
|
|
1024
|
-
getHistoryMessages(): IBotHistoryMessage[]
|
|
1025
|
-
clearHistory(): void
|
|
1054
|
+
getHistoryMessages(): Promise<IBotHistoryMessage[]>;
|
|
1055
|
+
clearHistory(): Promise<void>;
|
|
1026
1056
|
}
|
|
1027
1057
|
|
|
1028
1058
|
interface IDisposable {
|
|
@@ -1215,6 +1245,21 @@ declare class TaskService implements IDisposable {
|
|
|
1215
1245
|
dispose(): Promise<string>;
|
|
1216
1246
|
}
|
|
1217
1247
|
|
|
1248
|
+
interface IToolOptions extends IInstanceCreateOptions {
|
|
1249
|
+
/**
|
|
1250
|
+
* 工具集的描述
|
|
1251
|
+
*/
|
|
1252
|
+
description?: string;
|
|
1253
|
+
}
|
|
1254
|
+
interface ITool extends IInstance {
|
|
1255
|
+
getTools(): Promise<Record<string, Tool>>;
|
|
1256
|
+
get options(): IToolOptions;
|
|
1257
|
+
get params(): IToolParams;
|
|
1258
|
+
}
|
|
1259
|
+
type ToolCreator = (options: IToolOptions) => ITool;
|
|
1260
|
+
interface IToolParams extends IConfigParams {
|
|
1261
|
+
}
|
|
1262
|
+
|
|
1218
1263
|
type Creator<OptionsType, InstanceType> = (options: OptionsType) => InstanceType;
|
|
1219
1264
|
interface IInstanceCreator<OptionsType, InstanceType, ParamsType> {
|
|
1220
1265
|
creator: Creator<OptionsType, InstanceType>;
|
|
@@ -1241,6 +1286,7 @@ interface IPPAgentPluginHandler extends IDisposable {
|
|
|
1241
1286
|
sources?: IInstanceCreator<ISourceOptions, ISource, ISourceParamas>[];
|
|
1242
1287
|
taskTriggers?: IInstanceCreator<ITaskTriggerOptions, ITaskTrigger, ITaskTriggerParams>[];
|
|
1243
1288
|
taskRunners?: IInstanceCreator<ITaskRunnerOptions, ITaskRunner, ITaskRunnerParams>[];
|
|
1289
|
+
tools?: IInstanceCreator<IToolOptions, ITool, IToolParams>[];
|
|
1244
1290
|
}>;
|
|
1245
1291
|
/**
|
|
1246
1292
|
* HTTP服务启动之前(agent和task创建之后)
|
|
@@ -1257,10 +1303,6 @@ interface IPPAgentPluginHandler extends IDisposable {
|
|
|
1257
1303
|
* @returns
|
|
1258
1304
|
*/
|
|
1259
1305
|
beforeClose?: () => Promise<void>;
|
|
1260
|
-
/**
|
|
1261
|
-
* 是否必须使用在线配置的相关功能,如进行数据存储。
|
|
1262
|
-
*/
|
|
1263
|
-
needOnline: boolean;
|
|
1264
1306
|
/**
|
|
1265
1307
|
* 插件名称,需要跟package.json中的完全一致
|
|
1266
1308
|
*/
|
|
@@ -1303,6 +1345,13 @@ interface IAgentModels {
|
|
|
1303
1345
|
name: string;
|
|
1304
1346
|
options: ISourceOptions;
|
|
1305
1347
|
}[];
|
|
1348
|
+
/**
|
|
1349
|
+
* 工具列表
|
|
1350
|
+
*/
|
|
1351
|
+
tools?: {
|
|
1352
|
+
name: string;
|
|
1353
|
+
options: IToolOptions;
|
|
1354
|
+
}[];
|
|
1306
1355
|
}
|
|
1307
1356
|
interface IAgentServiceOptions {
|
|
1308
1357
|
/**
|
|
@@ -1327,6 +1376,7 @@ declare class AgentService implements IDisposable {
|
|
|
1327
1376
|
bots: number;
|
|
1328
1377
|
sources: number;
|
|
1329
1378
|
skills: number;
|
|
1379
|
+
tools: number;
|
|
1330
1380
|
};
|
|
1331
1381
|
get agents(): Agent[];
|
|
1332
1382
|
init(): Promise<void>;
|
|
@@ -1338,6 +1388,7 @@ declare class AgentService implements IDisposable {
|
|
|
1338
1388
|
private _loadConfig;
|
|
1339
1389
|
private _loadTableConfig;
|
|
1340
1390
|
private _loadInstances;
|
|
1391
|
+
private _loadTools;
|
|
1341
1392
|
private _loadSources;
|
|
1342
1393
|
private _loadBots;
|
|
1343
1394
|
private _loadSkills;
|
|
@@ -1442,16 +1493,74 @@ declare class GlobalEvent extends Emittery<{
|
|
|
1442
1493
|
registerGlobalEventNames(name: string): void;
|
|
1443
1494
|
}
|
|
1444
1495
|
|
|
1496
|
+
declare class ToolManager extends InstanceBaseManager<ITool, ToolCreator, IToolOptions, IToolParams> {
|
|
1497
|
+
}
|
|
1498
|
+
|
|
1499
|
+
interface GetListParams {
|
|
1500
|
+
resource: string;
|
|
1501
|
+
pagination?: {
|
|
1502
|
+
current?: number;
|
|
1503
|
+
pageSize?: number;
|
|
1504
|
+
};
|
|
1505
|
+
sorters?: Array<{
|
|
1506
|
+
field: string;
|
|
1507
|
+
order: "asc" | "desc";
|
|
1508
|
+
}>;
|
|
1509
|
+
filters?: Array<{
|
|
1510
|
+
field: string;
|
|
1511
|
+
operator: string;
|
|
1512
|
+
value: any;
|
|
1513
|
+
}>;
|
|
1514
|
+
}
|
|
1515
|
+
interface GetOneParams {
|
|
1516
|
+
resource: string;
|
|
1517
|
+
id: string;
|
|
1518
|
+
}
|
|
1519
|
+
interface CreateParams {
|
|
1520
|
+
resource: string;
|
|
1521
|
+
variables: any;
|
|
1522
|
+
}
|
|
1523
|
+
interface UpdateParams {
|
|
1524
|
+
resource: string;
|
|
1525
|
+
id: string;
|
|
1526
|
+
variables: any;
|
|
1527
|
+
}
|
|
1528
|
+
interface DeleteOneParams {
|
|
1529
|
+
resource: string;
|
|
1530
|
+
id: string;
|
|
1531
|
+
}
|
|
1532
|
+
interface GetListResult<T = any> {
|
|
1533
|
+
data: T[];
|
|
1534
|
+
total: number;
|
|
1535
|
+
}
|
|
1536
|
+
interface DataResult<T = any> {
|
|
1537
|
+
data: T;
|
|
1538
|
+
}
|
|
1539
|
+
declare class DbService {
|
|
1540
|
+
private repositories;
|
|
1541
|
+
private currentUserId;
|
|
1542
|
+
constructor();
|
|
1543
|
+
private initRepositories;
|
|
1544
|
+
private getRepository;
|
|
1545
|
+
private buildFilters;
|
|
1546
|
+
private buildOrder;
|
|
1547
|
+
getList(params: GetListParams): Promise<GetListResult>;
|
|
1548
|
+
getOne(params: GetOneParams): Promise<DataResult>;
|
|
1549
|
+
create(params: CreateParams): Promise<DataResult>;
|
|
1550
|
+
update(params: UpdateParams): Promise<DataResult>;
|
|
1551
|
+
deleteOne(params: DeleteOneParams): Promise<DataResult>;
|
|
1552
|
+
getMany(params: {
|
|
1553
|
+
resource: string;
|
|
1554
|
+
ids: string[];
|
|
1555
|
+
}): Promise<GetListResult>;
|
|
1556
|
+
}
|
|
1557
|
+
|
|
1445
1558
|
interface IPPAgentOptions {
|
|
1446
1559
|
/**
|
|
1447
1560
|
* agent服务的构建参数
|
|
1448
1561
|
*/
|
|
1449
1562
|
agentServiceOptions?: IAgentServiceOptions;
|
|
1450
1563
|
taskServiceOptions?: ITaskServiceOptions;
|
|
1451
|
-
/**
|
|
1452
|
-
* 是否是离线模式,离线模式不从网络加载配置
|
|
1453
|
-
*/
|
|
1454
|
-
offline?: boolean;
|
|
1455
1564
|
/**
|
|
1456
1565
|
* 如果配置,那么应用可以在有需要的时候使用默认图
|
|
1457
1566
|
*/
|
|
@@ -1486,163 +1595,34 @@ declare class PPAgent extends Emittery {
|
|
|
1486
1595
|
private _taskService;
|
|
1487
1596
|
private _taskTriggerManager;
|
|
1488
1597
|
private _taskRunnerManager;
|
|
1598
|
+
private _toolManager;
|
|
1489
1599
|
private _xmlParser;
|
|
1490
1600
|
private _sharedCover;
|
|
1491
1601
|
private _sharedLogo;
|
|
1492
|
-
private _client;
|
|
1493
1602
|
private _me;
|
|
1494
1603
|
private _globalEvent;
|
|
1495
1604
|
private _logger;
|
|
1496
1605
|
private _onlinePluginInfos;
|
|
1497
1606
|
private _services;
|
|
1607
|
+
private _dbService;
|
|
1498
1608
|
get server(): FastifyInstance<fastify.RawServerDefault, http.IncomingMessage, http.ServerResponse<http.IncomingMessage>, fastify.FastifyBaseLogger, fastify.FastifyTypeProviderDefault>;
|
|
1499
1609
|
get skillManager(): SkillManager;
|
|
1500
1610
|
get sourceManager(): SourceManager;
|
|
1501
1611
|
get botManager(): BotManager;
|
|
1502
1612
|
get taskTriggerManager(): TaskTriggerManager;
|
|
1503
1613
|
get taskRunnerManager(): TaskRunnerManager;
|
|
1614
|
+
get toolManager(): ToolManager;
|
|
1504
1615
|
get agentService(): AgentService;
|
|
1505
|
-
get offlineMode(): boolean;
|
|
1506
1616
|
get sharedCover(): IAsyncFile;
|
|
1507
1617
|
get sharedLogo(): IAsyncFile;
|
|
1508
|
-
get client(): AuthenticationClient<any> & RestClient<any>;
|
|
1509
1618
|
get options(): IPPAgentOptions;
|
|
1510
1619
|
get taskService(): TaskService;
|
|
1511
1620
|
get globalEvent(): GlobalEvent;
|
|
1512
1621
|
get plugins(): IPPAgentPluginHandler[];
|
|
1513
|
-
get me(): {
|
|
1514
|
-
id: string;
|
|
1515
|
-
first_name: string | null;
|
|
1516
|
-
last_name: string | null;
|
|
1517
|
-
email: string | null;
|
|
1518
|
-
password: string | null;
|
|
1519
|
-
location: string | null;
|
|
1520
|
-
title: string | null;
|
|
1521
|
-
description: string | null;
|
|
1522
|
-
tags: string[] | null;
|
|
1523
|
-
avatar: string | {
|
|
1524
|
-
id: string;
|
|
1525
|
-
storage: string;
|
|
1526
|
-
filename_disk: string | null;
|
|
1527
|
-
filename_download: string;
|
|
1528
|
-
title: string | null;
|
|
1529
|
-
type: string | null;
|
|
1530
|
-
folder: string | {
|
|
1531
|
-
id: string;
|
|
1532
|
-
name: string;
|
|
1533
|
-
parent: string | /*elided*/ any;
|
|
1534
|
-
};
|
|
1535
|
-
uploaded_by: string | /*elided*/ any;
|
|
1536
|
-
uploaded_on: "datetime";
|
|
1537
|
-
modified_by: string | /*elided*/ any;
|
|
1538
|
-
modified_on: "datetime";
|
|
1539
|
-
charset: string | null;
|
|
1540
|
-
filesize: string | null;
|
|
1541
|
-
width: number | null;
|
|
1542
|
-
height: number | null;
|
|
1543
|
-
duration: number | null;
|
|
1544
|
-
embed: unknown | null;
|
|
1545
|
-
description: string | null;
|
|
1546
|
-
location: string | null;
|
|
1547
|
-
tags: string[] | null;
|
|
1548
|
-
metadata: Record<string, any> | null;
|
|
1549
|
-
focal_point_x: number | null;
|
|
1550
|
-
focal_point_y: number | null;
|
|
1551
|
-
};
|
|
1552
|
-
language: string | null;
|
|
1553
|
-
theme: string | null;
|
|
1554
|
-
tfa_secret: string | null;
|
|
1555
|
-
status: string;
|
|
1556
|
-
role: string | {
|
|
1557
|
-
id: string;
|
|
1558
|
-
name: string;
|
|
1559
|
-
icon: string;
|
|
1560
|
-
description: string | null;
|
|
1561
|
-
parent: string | /*elided*/ any;
|
|
1562
|
-
children: string[] | /*elided*/ any[];
|
|
1563
|
-
policies: string[] | {
|
|
1564
|
-
id: string;
|
|
1565
|
-
role: string | /*elided*/ any;
|
|
1566
|
-
user: string | /*elided*/ any;
|
|
1567
|
-
policy: string | {
|
|
1568
|
-
id: string;
|
|
1569
|
-
name: string;
|
|
1570
|
-
icon: string;
|
|
1571
|
-
description: string | null;
|
|
1572
|
-
ip_access: string | null;
|
|
1573
|
-
enforce_tfa: boolean;
|
|
1574
|
-
admin_access: boolean;
|
|
1575
|
-
app_access: boolean;
|
|
1576
|
-
permissions: number[] | {
|
|
1577
|
-
id: number;
|
|
1578
|
-
policy: string | /*elided*/ any;
|
|
1579
|
-
collection: string;
|
|
1580
|
-
action: string;
|
|
1581
|
-
permissions: Record<string, any> | null;
|
|
1582
|
-
validation: Record<string, any> | null;
|
|
1583
|
-
presets: Record<string, any> | null;
|
|
1584
|
-
fields: string[] | null;
|
|
1585
|
-
}[];
|
|
1586
|
-
users: string[] | /*elided*/ any[];
|
|
1587
|
-
roles: string[] | /*elided*/ any[];
|
|
1588
|
-
};
|
|
1589
|
-
sort: number;
|
|
1590
|
-
}[];
|
|
1591
|
-
users: string[] | /*elided*/ any[];
|
|
1592
|
-
};
|
|
1593
|
-
token: string | null;
|
|
1594
|
-
last_access: "datetime" | null;
|
|
1595
|
-
last_page: string | null;
|
|
1596
|
-
provider: string;
|
|
1597
|
-
external_identifier: string | null;
|
|
1598
|
-
auth_data: Record<string, any> | null;
|
|
1599
|
-
email_notifications: boolean | null;
|
|
1600
|
-
appearance: string | null;
|
|
1601
|
-
theme_dark: string | null;
|
|
1602
|
-
theme_light: string | null;
|
|
1603
|
-
theme_light_overrides: Record<string, unknown> | null;
|
|
1604
|
-
theme_dark_overrides: Record<string, unknown> | null;
|
|
1605
|
-
policies: string[] | {
|
|
1606
|
-
id: string;
|
|
1607
|
-
name: string;
|
|
1608
|
-
icon: string;
|
|
1609
|
-
description: string | null;
|
|
1610
|
-
ip_access: string | null;
|
|
1611
|
-
enforce_tfa: boolean;
|
|
1612
|
-
admin_access: boolean;
|
|
1613
|
-
app_access: boolean;
|
|
1614
|
-
permissions: number[] | {
|
|
1615
|
-
id: number;
|
|
1616
|
-
policy: string | /*elided*/ any;
|
|
1617
|
-
collection: string;
|
|
1618
|
-
action: string;
|
|
1619
|
-
permissions: Record<string, any> | null;
|
|
1620
|
-
validation: Record<string, any> | null;
|
|
1621
|
-
presets: Record<string, any> | null;
|
|
1622
|
-
fields: string[] | null;
|
|
1623
|
-
}[];
|
|
1624
|
-
users: string[] | /*elided*/ any[];
|
|
1625
|
-
roles: string[] | {
|
|
1626
|
-
id: string;
|
|
1627
|
-
name: string;
|
|
1628
|
-
icon: string;
|
|
1629
|
-
description: string | null;
|
|
1630
|
-
parent: string | /*elided*/ any;
|
|
1631
|
-
children: string[] | /*elided*/ any[];
|
|
1632
|
-
policies: string[] | {
|
|
1633
|
-
id: string;
|
|
1634
|
-
role: string | /*elided*/ any;
|
|
1635
|
-
user: string | /*elided*/ any;
|
|
1636
|
-
policy: string | /*elided*/ any;
|
|
1637
|
-
sort: number;
|
|
1638
|
-
}[];
|
|
1639
|
-
users: string[] | /*elided*/ any[];
|
|
1640
|
-
}[];
|
|
1641
|
-
}[];
|
|
1642
|
-
};
|
|
1643
1622
|
get onlinePlugins(): MapIterator<IOnlinePluginInfo>;
|
|
1644
1623
|
get running(): boolean;
|
|
1645
1624
|
get services(): Map<string, any>;
|
|
1625
|
+
get dbService(): DbService;
|
|
1646
1626
|
private _createServer;
|
|
1647
1627
|
private _initServer;
|
|
1648
1628
|
private _checkRegister;
|
|
@@ -1800,6 +1780,10 @@ interface IAgentOptions {
|
|
|
1800
1780
|
* 回复内容的前缀,如 【回复】。仅对推理模型生效。正常对内容的修改可以通过添加技能完成
|
|
1801
1781
|
*/
|
|
1802
1782
|
contentPrefix?: string;
|
|
1783
|
+
/**
|
|
1784
|
+
* 是否公开该Agent,如果公开,则可以通过公开接口无需鉴权访问
|
|
1785
|
+
*/
|
|
1786
|
+
public?: boolean;
|
|
1803
1787
|
}
|
|
1804
1788
|
/**
|
|
1805
1789
|
* 一个智能体,用于连接source和bot。
|
|
@@ -1836,6 +1820,7 @@ declare class Agent extends Emittery implements IDisposable {
|
|
|
1836
1820
|
*/
|
|
1837
1821
|
sendMessage(message: ISourceChatMessage, to: ISource, now?: boolean, fromMessage?: ISourceChatMessage): Promise<string>;
|
|
1838
1822
|
dispose(): Promise<string>;
|
|
1823
|
+
processChatRequest(sourceData: ISourceChatMessageEventData): Promise<void>;
|
|
1839
1824
|
protected processChatMessage: (sourceData: ISourceChatMessageEventData) => Promise<void>;
|
|
1840
1825
|
protected onChatMessage: (data: IAgentChatEventData) => Promise<void>;
|
|
1841
1826
|
protected onSelfChatMessage: (data: ISourceChatMessageEventData) => void;
|
|
@@ -2117,9 +2102,10 @@ interface IOpenAIBotOptions extends IBasicBotOptions {
|
|
|
2117
2102
|
chatOptions: Omit<OpenAI.ChatCompletionCreateParamsStreaming, "messages" | "stream" | "audio">;
|
|
2118
2103
|
}
|
|
2119
2104
|
declare class OpenAIBot extends BasicBot {
|
|
2105
|
+
protected _app: PPAgent;
|
|
2120
2106
|
protected _options: IOpenAIBotOptions;
|
|
2121
2107
|
static params: IBotParams;
|
|
2122
|
-
constructor(_options: IOpenAIBotOptions);
|
|
2108
|
+
constructor(_app: PPAgent, _options: IOpenAIBotOptions);
|
|
2123
2109
|
protected client: OpenAI;
|
|
2124
2110
|
get options(): IOpenAIBotOptions;
|
|
2125
2111
|
get params(): IBotParams;
|
|
@@ -2140,7 +2126,7 @@ declare class OpenAIBot extends BasicBot {
|
|
|
2140
2126
|
* @returns
|
|
2141
2127
|
*/
|
|
2142
2128
|
onCompleted: (conversationId: string, timeInSeconds: number) => void;
|
|
2143
|
-
}): Promise<IBotHistoryMessage>;
|
|
2129
|
+
}, lastInfo?: ILastBotMessageInfo, evt?: IAgentChatEventData): Promise<IBotHistoryMessage>;
|
|
2144
2130
|
init(): Promise<void>;
|
|
2145
2131
|
}
|
|
2146
2132
|
|
|
@@ -2160,9 +2146,10 @@ interface IFastGPTBotOptions extends IOpenAIBotOptions {
|
|
|
2160
2146
|
appId: string;
|
|
2161
2147
|
}
|
|
2162
2148
|
declare class FastGPTBot extends OpenAIBot {
|
|
2149
|
+
protected _app: PPAgent;
|
|
2163
2150
|
protected _options: IFastGPTBotOptions;
|
|
2164
2151
|
static params: IBotParams;
|
|
2165
|
-
constructor(_options: IFastGPTBotOptions);
|
|
2152
|
+
constructor(_app: PPAgent, _options: IFastGPTBotOptions);
|
|
2166
2153
|
private _commonApiBase;
|
|
2167
2154
|
get options(): IFastGPTBotOptions;
|
|
2168
2155
|
get supportConversationOnline(): boolean;
|
|
@@ -2224,8 +2211,10 @@ declare class OllamaBot extends BasicBot {
|
|
|
2224
2211
|
}
|
|
2225
2212
|
|
|
2226
2213
|
declare class OpenRouterBot extends OpenAIBot {
|
|
2214
|
+
protected _app: PPAgent;
|
|
2215
|
+
protected _options: IOpenAIBotOptions;
|
|
2227
2216
|
static params: IBotParams;
|
|
2228
|
-
constructor(
|
|
2217
|
+
constructor(_app: PPAgent, _options: IOpenAIBotOptions);
|
|
2229
2218
|
}
|
|
2230
2219
|
|
|
2231
2220
|
interface IQAnythingBotOptions extends IBasicBotOptions {
|
|
@@ -2350,8 +2339,10 @@ declare class ZhipuQingyanBot extends BasicBot {
|
|
|
2350
2339
|
}
|
|
2351
2340
|
|
|
2352
2341
|
declare class SiliconFlowBot extends OpenAIBot {
|
|
2342
|
+
protected _app: PPAgent;
|
|
2343
|
+
protected _options: IOpenAIBotOptions;
|
|
2353
2344
|
static params: IBotParams;
|
|
2354
|
-
constructor(
|
|
2345
|
+
constructor(_app: PPAgent, _options: IOpenAIBotOptions);
|
|
2355
2346
|
}
|
|
2356
2347
|
|
|
2357
2348
|
interface IXunfeiBotOptions extends IOpenAIBotOptions {
|
|
@@ -2361,8 +2352,10 @@ interface IXunfeiBotOptions extends IOpenAIBotOptions {
|
|
|
2361
2352
|
modelName?: string;
|
|
2362
2353
|
}
|
|
2363
2354
|
declare class XunfeiBot extends OpenAIBot {
|
|
2355
|
+
protected _app: PPAgent;
|
|
2356
|
+
protected _options: IXunfeiBotOptions;
|
|
2364
2357
|
static params: IBotParams;
|
|
2365
|
-
constructor(
|
|
2358
|
+
constructor(_app: PPAgent, _options: IXunfeiBotOptions);
|
|
2366
2359
|
}
|
|
2367
2360
|
|
|
2368
2361
|
interface IZhipuBotOptions extends IOpenAIBotOptions {
|
|
@@ -2372,28 +2365,12 @@ interface IZhipuBotOptions extends IOpenAIBotOptions {
|
|
|
2372
2365
|
modelName?: string;
|
|
2373
2366
|
}
|
|
2374
2367
|
declare class ZhipuBot extends OpenAIBot {
|
|
2368
|
+
protected _app: PPAgent;
|
|
2369
|
+
protected _options: IZhipuBotOptions;
|
|
2375
2370
|
static params: IBotParams;
|
|
2376
|
-
constructor(
|
|
2371
|
+
constructor(_app: PPAgent, _options: IZhipuBotOptions);
|
|
2377
2372
|
}
|
|
2378
2373
|
|
|
2379
|
-
interface IPPAgentPluginOptions {
|
|
2380
|
-
/**
|
|
2381
|
-
* 通知有效期,过期的会被删除,客户端将看不到。
|
|
2382
|
-
*
|
|
2383
|
-
* 默认为1小时,即3600秒。最长不超过7天。
|
|
2384
|
-
*
|
|
2385
|
-
* 如果消息内指定了单独的有效期,以消息内的为准。
|
|
2386
|
-
*/
|
|
2387
|
-
expiresInSeconds?: number;
|
|
2388
|
-
/**
|
|
2389
|
-
* 每隔多久检查一次消息的过期情况,默认是20秒。
|
|
2390
|
-
*/
|
|
2391
|
-
checkNotifyFequencySeconds?: number;
|
|
2392
|
-
/**
|
|
2393
|
-
* 最大留存通知条数,超过后新的将覆盖旧的,默认100条。最少5条。
|
|
2394
|
-
*/
|
|
2395
|
-
maxNotifyCount?: number;
|
|
2396
|
-
}
|
|
2397
2374
|
declare const apiPlugin: IPPAgentPlugin;
|
|
2398
2375
|
|
|
2399
2376
|
declare const defaultPlugin: IPPAgentPlugin;
|
|
@@ -3059,6 +3036,7 @@ declare class FeishuSource implements ISource, IDisposable {
|
|
|
3059
3036
|
static params: ISourceParamas;
|
|
3060
3037
|
constructor(_app: PPAgent, _options: IFeishuSourceOptions);
|
|
3061
3038
|
private _me;
|
|
3039
|
+
private _initTime;
|
|
3062
3040
|
private _client;
|
|
3063
3041
|
private _wsClient;
|
|
3064
3042
|
private _connected;
|
|
@@ -3529,6 +3507,7 @@ declare function directRunBot(bot: IBot, type: SourceChatMessageType, content: S
|
|
|
3529
3507
|
type: SourceChatMessageType;
|
|
3530
3508
|
}[];
|
|
3531
3509
|
}>;
|
|
3510
|
+
declare function getTools(ids: string[], toolManager: ToolManager): Promise<Record<string, Tool>>;
|
|
3532
3511
|
|
|
3533
3512
|
/**
|
|
3534
3513
|
* 按照进来顺序回调输出
|
|
@@ -3539,4 +3518,4 @@ declare class SortedPromise extends Emittery {
|
|
|
3539
3518
|
add<T>(p: Promise<T>): Promise<T>;
|
|
3540
3519
|
}
|
|
3541
3520
|
|
|
3542
|
-
export { Agent, type AgentChatMessageReplyType, AgentService, AsyncFile, type AsyncFileLoader, BaiduSTTSkill, BaiduTTSSkill, BaseDrawSkill, BaseSTTSkill, BaseTTSSkill, BasicBot, type BotCreator, BotManager, ChatMessage, ChatMessageTaskRunner, CogVideoDrawSkill, CogviewDrawSkill, CozeBot, CozeService, CronTaskTrigger, DifyAgentBot, DingRobotSource, EchoTaskRunner, EventTaskTrigger, FastGPTBot, FeishuSource, FishAudioTTSSkill, GlobalEvent, GlobalEventNames, GlobalEventTaskTrigger, HistoryMessageManager, type IAgentChatEventData, type IAgentModels, type IAgentOptions, type IAgentServiceOptions, type IAsyncFile, type IAsyncFileSource, type IBaiduSTTSkillOptions, type IBaiduTTSSkillOptions, type IBaseDrawSkillOptions, type IBaseSTTSkillOptions, type IBaseTTSSkillOptions, type IBasicBotOptions, type IBot, type IBotEventData, type IBotFileInfo, type IBotHistoryMessage, type IBotHistoryRecordEventData, type IBotOptions, type IBotParams, type IBotReadyMessage, type IChatMessageTaskRunnerOptions, type ICogVideoDrawSkillOptions, type ICogviewDrawSkillOptions, type IConfigParams, type IConfigSchema, type ICozeBotOptions, type ICozeServiceOptions, type ICronTaskTriggerOptions, type IDifyAgentBotOptions, type IDingRobotSourceOptions, type IDingRobotSourceParams, type IDisposable, type IDrawResult, type IEventTaskTriggerOptions, type IFastGPTBotOptions, type IFeishuSourceOptions, type IFishAudioTTSSkillOptions, type IGlobalEventData, type IGlobalNotifyEventData, type IHisotryMessageManagerOptions, type IInstance, type IInstanceBaseMangerOptions, type IInstanceCreateOptions, type ILastBotMessageInfo, type ILogger, type ILoggerEmitContent, type IMessageContentReceiver, type IMessageContentRule, type IMessageRule, type IModelInfo, type IOllamaBotOptions, type IOnlinePluginInfo, type IOpenAIBotOptions, type IOpenAIDrawSkillOptions, type IOpenAISTTSkillOptions, type IOpenAITTSSkillOptions, type IPPAgentOptions, type IPPAgentPlugin, type IPPAgentPluginHandler, type
|
|
3521
|
+
export { Agent, type AgentChatMessageReplyType, AgentService, AsyncFile, type AsyncFileLoader, BaiduSTTSkill, BaiduTTSSkill, BaseDrawSkill, BaseSTTSkill, BaseTTSSkill, BasicBot, type BotCreator, BotManager, ChatMessage, ChatMessageTaskRunner, CogVideoDrawSkill, CogviewDrawSkill, CozeBot, CozeService, CronTaskTrigger, DifyAgentBot, DingRobotSource, EchoTaskRunner, EventTaskTrigger, FastGPTBot, FeishuSource, FishAudioTTSSkill, GlobalEvent, GlobalEventNames, GlobalEventTaskTrigger, HistoryMessageManager, type IAgentChatEventData, type IAgentModels, type IAgentOptions, type IAgentServiceOptions, type IAsyncFile, type IAsyncFileSource, type IBaiduSTTSkillOptions, type IBaiduTTSSkillOptions, type IBaseDrawSkillOptions, type IBaseSTTSkillOptions, type IBaseTTSSkillOptions, type IBasicBotOptions, type IBot, type IBotEventData, type IBotFileInfo, type IBotHistoryMessage, type IBotHistoryRecordEventData, type IBotOptions, type IBotParams, type IBotReadyMessage, type IChatMessageTaskRunnerOptions, type ICogVideoDrawSkillOptions, type ICogviewDrawSkillOptions, type IConfigParams, type IConfigSchema, type ICozeBotOptions, type ICozeServiceOptions, type ICronTaskTriggerOptions, type IDifyAgentBotOptions, type IDingRobotSourceOptions, type IDingRobotSourceParams, type IDisposable, type IDrawResult, type IEventTaskTriggerOptions, type IFastGPTBotOptions, type IFeishuSourceOptions, type IFishAudioTTSSkillOptions, type IGlobalEventData, type IGlobalNotifyEventData, type IHisotryMessageManagerOptions, type IInstance, type IInstanceBaseMangerOptions, type IInstanceCreateOptions, type ILastBotMessageInfo, type ILogger, type ILoggerEmitContent, type IMessageContentReceiver, type IMessageContentRule, type IMessageRule, type IModelInfo, type IOllamaBotOptions, type IOnlinePluginInfo, type IOpenAIBotOptions, type IOpenAIDrawSkillOptions, type IOpenAISTTSkillOptions, type IOpenAITTSSkillOptions, type IPPAgentOptions, type IPPAgentPlugin, type IPPAgentPluginHandler, type IQAnythingBotOptions, type IQQSourceOptions, type ISenseVoiceSTTSkillOptions, type ISiliconFlowDrawSkillOptions, type ISiliconFlowSTTSkillOptions, type ISiliconFlowTTSSkillOptions, type ISimpleSchemaItem, type ISkill, type ISkillOptions, type ISkillParams, type ISource, type ISourceActionInfo, type ISourceApiAction, type ISourceApiResponseType, type ISourceChatMessage, type ISourceChatMessageEventData, type ISourceEventData, type ISourceEventTaskTriggerOptions, type ISourceGroupChatMessage, type ISourceGroupInfoChangedEventData, type ISourceLoginEventData, type ISourceLogoutEventData, type ISourceOptions, type ISourceParamas, type ISourceResponseMessageEventData, type ISourceSystemEventData, type ISourceTodoEventData, type ISourceUserInfo, type ISourceWSNormalInMessage, type ISourceWSNormalOutMessage, type ISoviteTTSSkillOptions, type ITaskConfig, type ITaskEventTriggerData, type ITaskRunResult, type ITaskRunner, type ITaskRunnerOptions, type ITaskRunnerParams, type ITaskServiceOptions, type ITaskTrigger, type ITaskTriggerData, type ITaskTriggerOptions, type ITaskTriggerParams, type ITencentSTTSkillOptions, type ITencentTTSSkillOptions, type IWCAISourceOptions, type IWCOASourceOptions, type IWeWorkSourceOptions, type IWenxinAgentBotOptions, type IXunfeiBotOptions, type IXunfeiSTTSkillOptions, type IXunfeiTTSSkillOptions, type IYuanQiBotOptions, type IZhipuBotOptions, type IZhipuQingyanBotOptions, InstanceBaseManager, OllamaBot, OpenAIBot, OpenAIDrawSkill, OpenAISTTSkill, OpenAITTSSkill, OpenRouterBot, PPAgent, QAnythingBot, QQSource, SchemaBaseProperties, SenseVoiceSTTSkill, SiliconFlowBot, SiliconFlowDrawSkill, SiliconFlowSTTSkill, SiliconFlowTTSSkill, SimpleSchemaType, type SkillCreator, SkillManager, SkillSchemaBaseProperties, SortedPromise, SourceApiMissingParamsError, SourceApiNotFoundError, SourceApiUnAuthorizedError, type SourceChatArticleContent, type SourceChatAudioContent, type SourceChatCardContent, type SourceChatContactContent, type SourceChatContent, type SourceChatEmotionContent, type SourceChatFileContent, type SourceChatImageContent, type SourceChatMPContent, SourceChatMessageType, type SourceChatMusicContent, type SourceChatPatContentType, type SourceChatPhoneContent, type SourceChatPositionContent, type SourceChatRecallContent, type SourceChatRefContent, type SourceChatRichTextContent, type SourceChatSubscribeContent, type SourceChatSystemContent, type SourceChatTextContent, type SourceChatVideoContent, type SourceCreator, SourceEventTaskTrigger, SourceEventType, SourceManager, type SourceWSCustomAction, type SourceWSNormalAction, SoviteTTSSkill, type TaskRunnerCreator, TaskRunnerManager, TaskRunnerSchemaBaseProperties, TaskService, TaskTrigger, type TaskTriggerCreator, TaskTriggerManager, TencentSTTSkill, TencentTTSSkill, WCAISource, WCOASource, WeWorkSource, WenxinAgentBot, XunfeiBot, XunfeiSTTSkill, XunfeiTTSSkill, YuanQiBot, ZhipuBot, ZhipuQingyanBot, addWavHeader, apiPlugin, arm2wav, betterMarkdown, chatMessageRepo, chatSource, checkMessageRule, config, createCacheManager, createFakeMessage, createFormilySchema, defaultPlugin, detectName, directRunBot, disposeObjects, extractArticleInfo, extractImageUrls, extractMarkdownImageTags, extractMessageContentText, extractPositionInfo, filterContentRule, generateRandomString, getEnvNumber, getFromMessageSummary, getLogger, getSecret, getToMessageSummary, getTools, hasEmoji, hasMarkdown, installAndGetPluginInfo, installDep, isPhoneNumber, removeEmoji, removeMarkdown, removeTextAt, richText2Markdown, sleep, sse, stream2buffer, transFileFormat, transFormat, uninstallDep, wav2amr };
|