@easbot/gateway 0.2.23 → 0.2.25
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/chunks/chunk-OBW6CNOG.mjs +7 -0
- package/dist/chunks/chunk-OHUELRXK.mjs +14 -0
- package/dist/chunks/chunk-RIWYHEQ6.cjs +7 -0
- package/dist/chunks/chunk-U32NADBK.cjs +14 -0
- package/dist/chunks/global-JYEIXTJ2.mjs +2 -0
- package/dist/chunks/global-Y53VDBKD.cjs +1 -0
- package/dist/chunks/log-7WPRHZWH.cjs +1 -0
- package/dist/chunks/log-MKRLBH4R.mjs +1 -0
- package/dist/chunks/server-MTS5PR2P.mjs +1 -0
- package/dist/chunks/server-ZPM3AQHL.cjs +1 -0
- package/dist/index.cjs +2 -11
- package/dist/index.d.cts +440 -100
- package/dist/index.d.ts +440 -100
- package/dist/index.mjs +2 -11
- package/package.json +14 -13
- package/dist/chunks/chunk-2MXYBRPH.cjs +0 -1
- package/dist/chunks/chunk-5ETPYYQR.cjs +0 -7
- package/dist/chunks/chunk-6TRL3CVJ.mjs +0 -7
- package/dist/chunks/chunk-77F43CRD.mjs +0 -2
- package/dist/chunks/chunk-ASIAS35P.cjs +0 -2
- package/dist/chunks/chunk-DJTIL3AB.mjs +0 -2
- package/dist/chunks/chunk-RR6UFR5U.cjs +0 -2
- package/dist/chunks/chunk-YP2P4RQW.mjs +0 -1
- package/dist/chunks/global-5DV25LCJ.mjs +0 -2
- package/dist/chunks/global-OVOYDKEL.cjs +0 -1
- package/dist/chunks/log-B5SORET6.cjs +0 -1
- package/dist/chunks/log-K67H67P2.mjs +0 -1
- package/dist/chunks/server-CPD2KBY7.cjs +0 -1
- package/dist/chunks/server-TLTUACMN.mjs +0 -1
- package/dist/cli.cjs +0 -8
- package/dist/cli.d.cts +0 -6
- package/dist/cli.d.ts +0 -6
- package/dist/cli.mjs +0 -8
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IGatewayServer, GatewayConfig as GatewayConfig$1, GatewayServerConfig as GatewayServerConfig$1, PlatformType, GatewayMessage, SubAgentConfig, ChannelInfo, AgentAdapter } from '@easbot/types';
|
|
1
|
+
import { IGatewayServer, GatewayConfig as GatewayConfig$1, GatewayServerConfig as GatewayServerConfig$1, PlatformType, GatewayMessage, SubAgentConfig, ChannelInfo, ChannelListResponse, AgentAdapter } from '@easbot/types';
|
|
2
2
|
export { AgentAdapter, AgentInfo, ChannelInfo, GatewayMessage, GatewayMessagePromptPart, IGatewayServer, IGlobal, IHookRegistry, IInstance, ISubAgentRunner, MessageContext, MessageMetadata, MessageStorage, MessageType, PlatformType } from '@easbot/types';
|
|
3
3
|
import z from 'zod';
|
|
4
4
|
import { WSContext } from '@easbot/utils';
|
|
@@ -35,12 +35,12 @@ declare namespace Gateway {
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
declare const ChannelTypeSchema: z.ZodEnum<{
|
|
38
|
-
signal: "signal";
|
|
39
38
|
telegram: "telegram";
|
|
40
39
|
slack: "slack";
|
|
41
40
|
feishu: "feishu";
|
|
42
41
|
wechat: "wechat";
|
|
43
42
|
webchat: "webchat";
|
|
43
|
+
signal: "signal";
|
|
44
44
|
nostr: "nostr";
|
|
45
45
|
}>;
|
|
46
46
|
type ChannelType = z.infer<typeof ChannelTypeSchema>;
|
|
@@ -262,8 +262,8 @@ declare const AuthConfigSchema: z.ZodObject<{
|
|
|
262
262
|
type AuthConfig = z.infer<typeof AuthConfigSchema>;
|
|
263
263
|
declare const AgentSyncConfigSchema: z.ZodObject<{
|
|
264
264
|
mode: z.ZodDefault<z.ZodEnum<{
|
|
265
|
-
push: "push";
|
|
266
265
|
pull: "pull";
|
|
266
|
+
push: "push";
|
|
267
267
|
both: "both";
|
|
268
268
|
}>>;
|
|
269
269
|
interval: z.ZodDefault<z.ZodNumber>;
|
|
@@ -297,8 +297,8 @@ declare const GatewayClusterConfigSchema: z.ZodObject<{
|
|
|
297
297
|
}, z.core.$strip>>>;
|
|
298
298
|
sync: z.ZodOptional<z.ZodObject<{
|
|
299
299
|
mode: z.ZodDefault<z.ZodEnum<{
|
|
300
|
-
push: "push";
|
|
301
300
|
pull: "pull";
|
|
301
|
+
push: "push";
|
|
302
302
|
both: "both";
|
|
303
303
|
}>>;
|
|
304
304
|
interval: z.ZodDefault<z.ZodNumber>;
|
|
@@ -545,8 +545,8 @@ declare const GatewayConfigSchema: z.ZodObject<{
|
|
|
545
545
|
}, z.core.$strip>>>;
|
|
546
546
|
sync: z.ZodOptional<z.ZodObject<{
|
|
547
547
|
mode: z.ZodDefault<z.ZodEnum<{
|
|
548
|
-
push: "push";
|
|
549
548
|
pull: "pull";
|
|
549
|
+
push: "push";
|
|
550
550
|
both: "both";
|
|
551
551
|
}>>;
|
|
552
552
|
interval: z.ZodDefault<z.ZodNumber>;
|
|
@@ -603,6 +603,10 @@ declare const GatewayConfigSchema: z.ZodObject<{
|
|
|
603
603
|
maxSessions: z.ZodDefault<z.ZodNumber>;
|
|
604
604
|
persistenceFile: z.ZodOptional<z.ZodString>;
|
|
605
605
|
}, z.core.$strip>>;
|
|
606
|
+
defaults: z.ZodOptional<z.ZodObject<{
|
|
607
|
+
channel: z.ZodOptional<z.ZodString>;
|
|
608
|
+
fallbackChannels: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
609
|
+
}, z.core.$strip>>;
|
|
606
610
|
defaultAgent: z.ZodOptional<z.ZodString>;
|
|
607
611
|
logLevel: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
|
|
608
612
|
DEBUG: "DEBUG";
|
|
@@ -729,7 +733,7 @@ interface GatewaySession {
|
|
|
729
733
|
createdAt: number;
|
|
730
734
|
lastActiveAt: number;
|
|
731
735
|
}
|
|
732
|
-
interface SessionChannelInfo {
|
|
736
|
+
interface SessionChannelInfo extends ChannelInfo {
|
|
733
737
|
platform: PlatformType;
|
|
734
738
|
channelId: string;
|
|
735
739
|
chatId?: string;
|
|
@@ -756,6 +760,55 @@ interface SessionFilter {
|
|
|
756
760
|
declare function generateSessionId(channel: SessionChannelInfo): string;
|
|
757
761
|
declare function createDefaultSessionState(): SessionState;
|
|
758
762
|
|
|
763
|
+
interface ContactProfile {
|
|
764
|
+
displayName?: string;
|
|
765
|
+
username?: string;
|
|
766
|
+
avatar?: string;
|
|
767
|
+
email?: string;
|
|
768
|
+
phone?: string;
|
|
769
|
+
locale?: string;
|
|
770
|
+
timezone?: string;
|
|
771
|
+
}
|
|
772
|
+
interface PlatformAlias {
|
|
773
|
+
stableId?: string;
|
|
774
|
+
username?: string;
|
|
775
|
+
displayName?: string;
|
|
776
|
+
chatId?: string;
|
|
777
|
+
}
|
|
778
|
+
interface PlatformAliases {
|
|
779
|
+
[platform: string]: PlatformAlias | undefined;
|
|
780
|
+
}
|
|
781
|
+
interface Contact {
|
|
782
|
+
uid: string;
|
|
783
|
+
platform: PlatformType;
|
|
784
|
+
stableId: string;
|
|
785
|
+
aliases: PlatformAliases;
|
|
786
|
+
profile: ContactProfile;
|
|
787
|
+
createdAt: number;
|
|
788
|
+
lastSeenAt: number;
|
|
789
|
+
metadata?: Record<string, unknown>;
|
|
790
|
+
}
|
|
791
|
+
interface CreateContactParams {
|
|
792
|
+
platform: PlatformType;
|
|
793
|
+
stableId: string;
|
|
794
|
+
profile?: Partial<ContactProfile>;
|
|
795
|
+
aliases?: PlatformAliases;
|
|
796
|
+
metadata?: Record<string, unknown>;
|
|
797
|
+
}
|
|
798
|
+
interface UpdateContactParams {
|
|
799
|
+
profile?: Partial<ContactProfile>;
|
|
800
|
+
aliases?: Partial<PlatformAliases>;
|
|
801
|
+
metadata?: Record<string, unknown>;
|
|
802
|
+
}
|
|
803
|
+
interface ContactQuery {
|
|
804
|
+
platform?: PlatformType;
|
|
805
|
+
username?: string;
|
|
806
|
+
email?: string;
|
|
807
|
+
phone?: string;
|
|
808
|
+
limit?: number;
|
|
809
|
+
offset?: number;
|
|
810
|
+
}
|
|
811
|
+
|
|
759
812
|
interface Subscriber {
|
|
760
813
|
id: string;
|
|
761
814
|
type: SubscriberType;
|
|
@@ -809,6 +862,7 @@ interface ClientInitializeMessage extends WebSocketMessageBase {
|
|
|
809
862
|
interface ClientSubscribeMessage extends WebSocketMessageBase {
|
|
810
863
|
type: 'subscribe';
|
|
811
864
|
sessionId: string;
|
|
865
|
+
backendSessionId?: string;
|
|
812
866
|
payload?: {
|
|
813
867
|
eventTypes?: string[];
|
|
814
868
|
};
|
|
@@ -1001,7 +1055,7 @@ interface CreateSessionRequest {
|
|
|
1001
1055
|
};
|
|
1002
1056
|
context?: Record<string, unknown>;
|
|
1003
1057
|
}
|
|
1004
|
-
interface CreateSessionResponse {
|
|
1058
|
+
interface CreateSessionResponse$1 {
|
|
1005
1059
|
id: string;
|
|
1006
1060
|
createdAt: number;
|
|
1007
1061
|
}
|
|
@@ -1016,10 +1070,15 @@ interface SendMessageRequest {
|
|
|
1016
1070
|
}>;
|
|
1017
1071
|
[key: string]: unknown;
|
|
1018
1072
|
}
|
|
1019
|
-
interface SendMessageResponse {
|
|
1073
|
+
interface SendMessageResponse$1 {
|
|
1020
1074
|
messageId: string;
|
|
1021
1075
|
sessionId: string;
|
|
1022
1076
|
createdAt: number;
|
|
1077
|
+
metadata?: {
|
|
1078
|
+
channel?: string;
|
|
1079
|
+
channelSource?: string;
|
|
1080
|
+
channelInfo?: ChannelInfo;
|
|
1081
|
+
};
|
|
1023
1082
|
}
|
|
1024
1083
|
interface SubscriptionsResponse {
|
|
1025
1084
|
subscriptions: Array<{
|
|
@@ -1252,6 +1311,46 @@ interface ConnectionPoolEvent<T = unknown> {
|
|
|
1252
1311
|
}
|
|
1253
1312
|
type ConnectionPoolEventCallback<T = unknown> = (event: ConnectionPoolEvent<T>) => void | Promise<void>;
|
|
1254
1313
|
|
|
1314
|
+
interface CancelEvent {
|
|
1315
|
+
sessionId: string;
|
|
1316
|
+
messageId: string;
|
|
1317
|
+
processedBy: string;
|
|
1318
|
+
reason: 'completed' | 'failed' | 'timeout';
|
|
1319
|
+
timestamp: number;
|
|
1320
|
+
}
|
|
1321
|
+
type CancelEventHandler = (event: CancelEvent) => void | Promise<void>;
|
|
1322
|
+
declare class MessageRouter {
|
|
1323
|
+
private log;
|
|
1324
|
+
private subscribers;
|
|
1325
|
+
private subscriptions;
|
|
1326
|
+
private sessionSubscriptions;
|
|
1327
|
+
private channelPlugins;
|
|
1328
|
+
private lockManager;
|
|
1329
|
+
private retryManager;
|
|
1330
|
+
private cancelHandlers;
|
|
1331
|
+
constructor();
|
|
1332
|
+
onCancel(handler: CancelEventHandler): void;
|
|
1333
|
+
offCancel(handler: CancelEventHandler): void;
|
|
1334
|
+
private emitCancel;
|
|
1335
|
+
route(message: GatewayMessage): Promise<RouteResult>;
|
|
1336
|
+
completeMessage(sessionId: string, messageId: string, subscriberId: string, reason?: 'completed' | 'failed' | 'timeout'): Promise<void>;
|
|
1337
|
+
scheduleRetry(message: GatewayMessage, error: Error): boolean;
|
|
1338
|
+
subscribe(sessionId: string, subscriber: Subscriber): Promise<Subscription>;
|
|
1339
|
+
unsubscribe(subscriptionId: string): Promise<void>;
|
|
1340
|
+
unsubscribeAll(subscriberId: string): Promise<void>;
|
|
1341
|
+
registerChannel(plugin: ChannelPlugin): void;
|
|
1342
|
+
unregisterChannel(pluginId: string): void;
|
|
1343
|
+
getSubscriber(subscriberId: string): Subscriber | undefined;
|
|
1344
|
+
getSubscription(subscriptionId: string): Subscription | undefined;
|
|
1345
|
+
getSubscriberCount(sessionId: string): number;
|
|
1346
|
+
getStats(): {
|
|
1347
|
+
subscribers: number;
|
|
1348
|
+
subscriptions: number;
|
|
1349
|
+
sessions: number;
|
|
1350
|
+
};
|
|
1351
|
+
shutdown(): Promise<void>;
|
|
1352
|
+
}
|
|
1353
|
+
|
|
1255
1354
|
interface LockState {
|
|
1256
1355
|
sessionId: string;
|
|
1257
1356
|
messageId: string;
|
|
@@ -1320,44 +1419,6 @@ declare class MessageRetryManager {
|
|
|
1320
1419
|
};
|
|
1321
1420
|
}
|
|
1322
1421
|
|
|
1323
|
-
interface CancelEvent {
|
|
1324
|
-
sessionId: string;
|
|
1325
|
-
messageId: string;
|
|
1326
|
-
processedBy: string;
|
|
1327
|
-
reason: 'completed' | 'failed' | 'timeout';
|
|
1328
|
-
timestamp: number;
|
|
1329
|
-
}
|
|
1330
|
-
type CancelEventHandler = (event: CancelEvent) => void | Promise<void>;
|
|
1331
|
-
declare class MessageRouter {
|
|
1332
|
-
private log;
|
|
1333
|
-
private subscribers;
|
|
1334
|
-
private subscriptions;
|
|
1335
|
-
private sessionSubscriptions;
|
|
1336
|
-
private channelPlugins;
|
|
1337
|
-
private lockManager;
|
|
1338
|
-
private retryManager;
|
|
1339
|
-
private cancelHandlers;
|
|
1340
|
-
constructor();
|
|
1341
|
-
onCancel(handler: CancelEventHandler): void;
|
|
1342
|
-
offCancel(handler: CancelEventHandler): void;
|
|
1343
|
-
private emitCancel;
|
|
1344
|
-
route(message: GatewayMessage): Promise<RouteResult>;
|
|
1345
|
-
completeMessage(sessionId: string, messageId: string, subscriberId: string, reason?: 'completed' | 'failed' | 'timeout'): Promise<void>;
|
|
1346
|
-
scheduleRetry(message: GatewayMessage, error: Error): boolean;
|
|
1347
|
-
subscribe(sessionId: string, subscriber: Subscriber): Promise<Subscription>;
|
|
1348
|
-
unsubscribe(subscriptionId: string): Promise<void>;
|
|
1349
|
-
unsubscribeAll(subscriberId: string): Promise<void>;
|
|
1350
|
-
registerChannel(plugin: ChannelPlugin): Promise<void>;
|
|
1351
|
-
unregisterChannel(pluginId: string): Promise<void>;
|
|
1352
|
-
getSubscriberCount(sessionId: string): number;
|
|
1353
|
-
getAllSubscribers(): Subscriber[];
|
|
1354
|
-
getChannelPlugin(pluginId: string): ChannelPlugin | undefined;
|
|
1355
|
-
getAllChannelPlugins(): ChannelPlugin[];
|
|
1356
|
-
getLockManager(): MessageLockManager;
|
|
1357
|
-
getRetryManager(): MessageRetryManager;
|
|
1358
|
-
shutdown(): Promise<void>;
|
|
1359
|
-
}
|
|
1360
|
-
|
|
1361
1422
|
interface SessionManagerConfig {
|
|
1362
1423
|
enablePersistence: boolean;
|
|
1363
1424
|
storagePath: string;
|
|
@@ -1431,15 +1492,11 @@ declare class AgentSyncManager {
|
|
|
1431
1492
|
private remoteAgents;
|
|
1432
1493
|
private syncTimer;
|
|
1433
1494
|
private running;
|
|
1434
|
-
private httpClient;
|
|
1435
1495
|
constructor(options: {
|
|
1436
1496
|
registry: AgentRegistry;
|
|
1437
1497
|
localNodeId: string;
|
|
1438
1498
|
localNodeName: string;
|
|
1439
1499
|
config?: Partial<SyncConfig>;
|
|
1440
|
-
httpClient?: {
|
|
1441
|
-
fetch: typeof fetch;
|
|
1442
|
-
};
|
|
1443
1500
|
});
|
|
1444
1501
|
start(): Promise<void>;
|
|
1445
1502
|
stop(): Promise<void>;
|
|
@@ -1513,10 +1570,14 @@ declare abstract class BaseChannelPlugin implements ChannelPlugin {
|
|
|
1513
1570
|
protected messageHandler: MessageHandler | null;
|
|
1514
1571
|
protected _status: ChannelStatusType;
|
|
1515
1572
|
protected lastActivity: number;
|
|
1573
|
+
private startPromise;
|
|
1574
|
+
private stopPromise;
|
|
1516
1575
|
constructor();
|
|
1517
1576
|
protected initLog(): void;
|
|
1518
1577
|
start(config: ChannelConfig, messageHandler: MessageHandler): Promise<void>;
|
|
1578
|
+
private doStartInternal;
|
|
1519
1579
|
stop(): Promise<void>;
|
|
1580
|
+
private doStopInternal;
|
|
1520
1581
|
healthCheck(): Promise<ChannelHealth>;
|
|
1521
1582
|
getStatus(): ChannelStatus;
|
|
1522
1583
|
abstract send(message: GatewayMessage): Promise<string>;
|
|
@@ -1524,10 +1585,50 @@ declare abstract class BaseChannelPlugin implements ChannelPlugin {
|
|
|
1524
1585
|
protected abstract doStop(): Promise<void>;
|
|
1525
1586
|
protected doHealthCheck(): Promise<boolean>;
|
|
1526
1587
|
protected updateActivity(): void;
|
|
1588
|
+
protected extractText(message: GatewayMessage): string;
|
|
1589
|
+
protected buildSessionId(channelId: string, chatId: string, userId?: string): string;
|
|
1527
1590
|
protected handleMessage(message: GatewayMessage): Promise<void>;
|
|
1528
1591
|
protected handleEvent(type: string, data?: unknown): Promise<void>;
|
|
1529
1592
|
}
|
|
1530
1593
|
|
|
1594
|
+
interface PluginLoaderConfig {
|
|
1595
|
+
pluginDir?: string;
|
|
1596
|
+
autoDiscover?: boolean;
|
|
1597
|
+
healthCheckInterval?: number;
|
|
1598
|
+
healthCheckTimeout?: number;
|
|
1599
|
+
autoReconnect?: boolean;
|
|
1600
|
+
maxReconnectAttempts?: number;
|
|
1601
|
+
reconnectInitialDelay?: number;
|
|
1602
|
+
reconnectMaxDelay?: number;
|
|
1603
|
+
}
|
|
1604
|
+
declare class ChannelPluginLoader {
|
|
1605
|
+
private log;
|
|
1606
|
+
private plugins;
|
|
1607
|
+
private messageHandler;
|
|
1608
|
+
private healthCheckTimer;
|
|
1609
|
+
private config;
|
|
1610
|
+
private backoffPolicy;
|
|
1611
|
+
constructor(config?: PluginLoaderConfig);
|
|
1612
|
+
setMessageHandler(handler: MessageHandler): void;
|
|
1613
|
+
register(plugin: ChannelPlugin, config: ChannelConfig): Promise<void>;
|
|
1614
|
+
unregister(pluginId: string): Promise<void>;
|
|
1615
|
+
start(pluginId: string): Promise<void>;
|
|
1616
|
+
stop(pluginId: string): Promise<void>;
|
|
1617
|
+
startAll(): Promise<void>;
|
|
1618
|
+
stopAll(): Promise<void>;
|
|
1619
|
+
getPlugin(pluginId: string): ChannelPlugin | undefined;
|
|
1620
|
+
getAllPlugins(): ChannelPlugin[];
|
|
1621
|
+
getRunningPlugins(): ChannelPlugin[];
|
|
1622
|
+
isRunning(pluginId: string): boolean;
|
|
1623
|
+
healthCheck(pluginId: string): Promise<ChannelHealth>;
|
|
1624
|
+
healthCheckAll(): Promise<Map<string, ChannelHealth>>;
|
|
1625
|
+
startHealthCheckTimer(): void;
|
|
1626
|
+
stopHealthCheckTimer(): void;
|
|
1627
|
+
private scheduleReconnect;
|
|
1628
|
+
private cancelReconnect;
|
|
1629
|
+
private calculateBackoffDelay;
|
|
1630
|
+
}
|
|
1631
|
+
|
|
1531
1632
|
interface MessageRecord {
|
|
1532
1633
|
message: GatewayMessage;
|
|
1533
1634
|
status: MessageStatus;
|
|
@@ -1543,13 +1644,21 @@ interface MessageStoreConfig {
|
|
|
1543
1644
|
storagePath: string;
|
|
1544
1645
|
maxRetentionDays: number;
|
|
1545
1646
|
maxRecords: number;
|
|
1647
|
+
cleanupIntervalMs: number;
|
|
1648
|
+
cleanupBatchSize: number;
|
|
1649
|
+
lruEnabled: boolean;
|
|
1650
|
+
lruMaxMemory?: number;
|
|
1546
1651
|
}
|
|
1547
1652
|
declare class MessageStore {
|
|
1548
1653
|
private log;
|
|
1549
1654
|
private config;
|
|
1550
1655
|
private messages;
|
|
1551
1656
|
private sessionMessages;
|
|
1657
|
+
private cleanupTimer;
|
|
1658
|
+
private accessOrder;
|
|
1552
1659
|
constructor(config?: Partial<MessageStoreConfig>);
|
|
1660
|
+
private startCleanupTimer;
|
|
1661
|
+
private performCleanup;
|
|
1553
1662
|
store(message: GatewayMessage): Promise<MessageRecord>;
|
|
1554
1663
|
get(messageId: string): MessageRecord | undefined;
|
|
1555
1664
|
updateStatus(messageId: string, status: MessageStatus, options?: {
|
|
@@ -1561,7 +1670,10 @@ declare class MessageStore {
|
|
|
1561
1670
|
getSessionHistory(sessionId: string, limit?: number): MessageRecord[];
|
|
1562
1671
|
getPendingMessages(sessionId?: string): MessageRecord[];
|
|
1563
1672
|
getFailedMessages(maxRetries?: number): MessageRecord[];
|
|
1564
|
-
cleanup():
|
|
1673
|
+
cleanup(): number;
|
|
1674
|
+
private evictLRU;
|
|
1675
|
+
private updateAccessOrder;
|
|
1676
|
+
private deleteMessage;
|
|
1565
1677
|
getStats(): {
|
|
1566
1678
|
total: number;
|
|
1567
1679
|
pending: number;
|
|
@@ -1569,7 +1681,9 @@ declare class MessageStore {
|
|
|
1569
1681
|
completed: number;
|
|
1570
1682
|
failed: number;
|
|
1571
1683
|
cancelled: number;
|
|
1684
|
+
sessions: number;
|
|
1572
1685
|
};
|
|
1686
|
+
close(): Promise<void>;
|
|
1573
1687
|
}
|
|
1574
1688
|
|
|
1575
1689
|
interface SerializableSession {
|
|
@@ -1620,37 +1734,95 @@ declare class SessionStore {
|
|
|
1620
1734
|
};
|
|
1621
1735
|
}
|
|
1622
1736
|
|
|
1623
|
-
interface
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1737
|
+
interface ContactListResult {
|
|
1738
|
+
contacts: Contact[];
|
|
1739
|
+
total: number;
|
|
1740
|
+
hasMore: boolean;
|
|
1741
|
+
}
|
|
1742
|
+
interface IContactStore {
|
|
1743
|
+
initialize?(): Promise<void>;
|
|
1744
|
+
save(contact: Contact): Promise<Contact>;
|
|
1745
|
+
create(params: CreateContactParams): Promise<Contact>;
|
|
1746
|
+
getOrCreate(platform: PlatformType, stableId: string, profile?: Partial<ContactProfile>): Promise<Contact>;
|
|
1747
|
+
findByUid(uid: string): Promise<Contact | null>;
|
|
1748
|
+
findByPlatformId(platform: PlatformType, stableId: string): Promise<Contact | null>;
|
|
1749
|
+
update(uid: string, params: UpdateContactParams): Promise<Contact | null>;
|
|
1750
|
+
touch(uid: string): Promise<void>;
|
|
1751
|
+
delete(uid: string): Promise<boolean>;
|
|
1752
|
+
listByPlatform(platform: PlatformType, limit?: number, offset?: number): Promise<ContactListResult>;
|
|
1753
|
+
findByUsername(username: string): Promise<Contact | null>;
|
|
1754
|
+
findByEmail(email: string): Promise<Contact | null>;
|
|
1755
|
+
findByPhone(phone: string): Promise<Contact | null>;
|
|
1756
|
+
search(query: ContactQuery): Promise<ContactListResult>;
|
|
1757
|
+
count(platform?: PlatformType): Promise<number>;
|
|
1758
|
+
exists(uid: string): Promise<boolean>;
|
|
1759
|
+
addAlias(uid: string, platform: PlatformType, alias: {
|
|
1760
|
+
stableId?: string;
|
|
1761
|
+
username?: string;
|
|
1762
|
+
displayName?: string;
|
|
1763
|
+
chatId?: string;
|
|
1764
|
+
}): Promise<Contact | null>;
|
|
1765
|
+
close(): Promise<void>;
|
|
1628
1766
|
}
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1767
|
+
|
|
1768
|
+
interface ResolveChannelParams {
|
|
1769
|
+
channel?: string | null;
|
|
1770
|
+
sessionId?: string | null;
|
|
1771
|
+
userId?: string | null;
|
|
1772
|
+
defaultChannel?: string | null;
|
|
1773
|
+
fallbackChannels?: string[] | null;
|
|
1774
|
+
sessionManager?: {
|
|
1775
|
+
get(sessionId: string): GatewaySession | undefined;
|
|
1776
|
+
bindBackendSession(gatewaySessionId: string, backendSessionId: string): Promise<void>;
|
|
1777
|
+
};
|
|
1778
|
+
pluginLoader?: {
|
|
1779
|
+
getPlugin(pluginId: string): ChannelPlugin | undefined;
|
|
1780
|
+
getAllPlugins(): ChannelPlugin[];
|
|
1781
|
+
isRunning(pluginId: string): boolean;
|
|
1782
|
+
};
|
|
1783
|
+
contactStore?: {
|
|
1784
|
+
findByPlatformId(platform: PlatformType, stableId: string): Promise<{
|
|
1785
|
+
uid: string;
|
|
1786
|
+
platform: PlatformType;
|
|
1787
|
+
stableId: string;
|
|
1788
|
+
profile: {
|
|
1789
|
+
username?: string;
|
|
1790
|
+
displayName?: string;
|
|
1791
|
+
};
|
|
1792
|
+
lastSeenAt: number;
|
|
1793
|
+
} | null>;
|
|
1794
|
+
findByUid(uid: string): Promise<{
|
|
1795
|
+
uid: string;
|
|
1796
|
+
platform: PlatformType;
|
|
1797
|
+
stableId: string;
|
|
1798
|
+
profile: {
|
|
1799
|
+
username?: string;
|
|
1800
|
+
displayName?: string;
|
|
1801
|
+
};
|
|
1802
|
+
aliases?: Record<string, unknown>;
|
|
1803
|
+
lastSeenAt: number;
|
|
1804
|
+
createdAt: number;
|
|
1805
|
+
} | null>;
|
|
1806
|
+
listByPlatform(platform: PlatformType, limit?: number, offset?: number): Promise<{
|
|
1807
|
+
contacts: Array<{
|
|
1808
|
+
uid: string;
|
|
1809
|
+
platform: PlatformType;
|
|
1810
|
+
stableId: string;
|
|
1811
|
+
profile: {
|
|
1812
|
+
username?: string;
|
|
1813
|
+
displayName?: string;
|
|
1814
|
+
};
|
|
1815
|
+
lastSeenAt: number;
|
|
1816
|
+
createdAt: number;
|
|
1817
|
+
}>;
|
|
1818
|
+
total: number;
|
|
1819
|
+
hasMore: boolean;
|
|
1820
|
+
}>;
|
|
1821
|
+
count(platform?: PlatformType): Promise<number>;
|
|
1822
|
+
};
|
|
1652
1823
|
}
|
|
1653
1824
|
|
|
1825
|
+
type MessageSender = (pluginId: string, message: GatewayMessage) => Promise<string>;
|
|
1654
1826
|
declare class GatewayWebSocketServer {
|
|
1655
1827
|
private config;
|
|
1656
1828
|
private server;
|
|
@@ -1665,7 +1837,16 @@ declare class GatewayWebSocketServer {
|
|
|
1665
1837
|
private heartbeatInterval;
|
|
1666
1838
|
private startTime;
|
|
1667
1839
|
private running;
|
|
1840
|
+
private channelResolveParams;
|
|
1668
1841
|
constructor(config?: Partial<GatewayServerConfig>);
|
|
1842
|
+
setChannelResolveDeps(params: ResolveChannelParams): void;
|
|
1843
|
+
setMessageSender(sender: MessageSender): void;
|
|
1844
|
+
private messageSender;
|
|
1845
|
+
private pluginLoaderRef;
|
|
1846
|
+
setPluginLoader(loader: {
|
|
1847
|
+
send(pluginId: string, message: GatewayMessage): Promise<string>;
|
|
1848
|
+
}): void;
|
|
1849
|
+
private getChannelResolveParams;
|
|
1669
1850
|
start(): Promise<void>;
|
|
1670
1851
|
private startHTTPServer;
|
|
1671
1852
|
private startHTTPSServer;
|
|
@@ -1703,10 +1884,12 @@ declare class GatewayServer implements IGatewayServer {
|
|
|
1703
1884
|
private sessionManager;
|
|
1704
1885
|
private pluginLoader;
|
|
1705
1886
|
private messageStore;
|
|
1887
|
+
private contactStore;
|
|
1706
1888
|
private wsServer;
|
|
1707
1889
|
private running;
|
|
1708
1890
|
private connections;
|
|
1709
1891
|
constructor(config: GatewayServerConfig$1);
|
|
1892
|
+
private loadChannelPlugins;
|
|
1710
1893
|
start(): Promise<void>;
|
|
1711
1894
|
stop(): Promise<void>;
|
|
1712
1895
|
getStatus(): {
|
|
@@ -1716,6 +1899,9 @@ declare class GatewayServer implements IGatewayServer {
|
|
|
1716
1899
|
connections?: number;
|
|
1717
1900
|
};
|
|
1718
1901
|
onMessage(message: GatewayMessage): Promise<void>;
|
|
1902
|
+
private saveContactFromMessage;
|
|
1903
|
+
private dispatchToSubAgent;
|
|
1904
|
+
private triggerHook;
|
|
1719
1905
|
private storeMessage;
|
|
1720
1906
|
processMessage(sessionId: string, messageId: string, processorId: string, options?: {
|
|
1721
1907
|
processType?: 'subagent' | 'direct' | 'tool';
|
|
@@ -1743,6 +1929,7 @@ declare class GatewayServer implements IGatewayServer {
|
|
|
1743
1929
|
getRouter(): MessageRouter;
|
|
1744
1930
|
getPluginLoader(): ChannelPluginLoader;
|
|
1745
1931
|
getMessageStore(): MessageStore;
|
|
1932
|
+
getContactStore(): IContactStore | null;
|
|
1746
1933
|
getMessageHistory(sessionId: string, limit?: number): Promise<MessageRecord[]>;
|
|
1747
1934
|
}
|
|
1748
1935
|
|
|
@@ -1762,6 +1949,58 @@ interface GatewayClientConfig {
|
|
|
1762
1949
|
}
|
|
1763
1950
|
type MessageCallback = (message: GatewayMessage) => void | Promise<void>;
|
|
1764
1951
|
type AgentListChangeCallback = (agents: AgentSyncInfo[]) => void | Promise<void>;
|
|
1952
|
+
interface HealthResponse {
|
|
1953
|
+
status: string;
|
|
1954
|
+
timestamp: number;
|
|
1955
|
+
version: string;
|
|
1956
|
+
}
|
|
1957
|
+
interface StatusResponse {
|
|
1958
|
+
status: string;
|
|
1959
|
+
connections: number;
|
|
1960
|
+
sessions: number;
|
|
1961
|
+
subscriptions: number;
|
|
1962
|
+
uptime: number;
|
|
1963
|
+
version: string;
|
|
1964
|
+
}
|
|
1965
|
+
interface ContactInfo {
|
|
1966
|
+
uid: string;
|
|
1967
|
+
platform: string;
|
|
1968
|
+
stableId: string;
|
|
1969
|
+
profile: {
|
|
1970
|
+
displayName?: string;
|
|
1971
|
+
username?: string;
|
|
1972
|
+
};
|
|
1973
|
+
lastSeenAt: number;
|
|
1974
|
+
createdAt: number;
|
|
1975
|
+
}
|
|
1976
|
+
interface ContactListResponse {
|
|
1977
|
+
contacts: ContactInfo[];
|
|
1978
|
+
total: number;
|
|
1979
|
+
hasMore: boolean;
|
|
1980
|
+
}
|
|
1981
|
+
interface SessionInfo {
|
|
1982
|
+
id: string;
|
|
1983
|
+
platform?: string;
|
|
1984
|
+
channelId?: string;
|
|
1985
|
+
userId?: string;
|
|
1986
|
+
chatId?: string;
|
|
1987
|
+
state: string;
|
|
1988
|
+
createdAt: number;
|
|
1989
|
+
lastActiveAt: number;
|
|
1990
|
+
}
|
|
1991
|
+
interface SessionListResponse {
|
|
1992
|
+
sessions: SessionInfo[];
|
|
1993
|
+
total: number;
|
|
1994
|
+
hasMore: boolean;
|
|
1995
|
+
}
|
|
1996
|
+
interface CreateSessionResponse {
|
|
1997
|
+
id: string;
|
|
1998
|
+
createdAt: number;
|
|
1999
|
+
}
|
|
2000
|
+
interface SendMessageResponse {
|
|
2001
|
+
success: boolean;
|
|
2002
|
+
messageId?: string;
|
|
2003
|
+
}
|
|
1765
2004
|
type ConnectionState = 'disconnected' | 'connecting' | 'connected' | 'reconnecting';
|
|
1766
2005
|
interface AgentListMergeOptions {
|
|
1767
2006
|
localAgents?: AgentSyncInfo[];
|
|
@@ -1786,7 +2025,7 @@ declare class GatewayClient {
|
|
|
1786
2025
|
constructor(config: GatewayClientConfig);
|
|
1787
2026
|
connect(): Promise<void>;
|
|
1788
2027
|
disconnect(): Promise<void>;
|
|
1789
|
-
subscribe(sessionId: string): Promise<void>;
|
|
2028
|
+
subscribe(sessionId: string, backendSessionId?: string): Promise<void>;
|
|
1790
2029
|
unsubscribe(sessionId: string): Promise<void>;
|
|
1791
2030
|
send(message: GatewayMessage): Promise<void>;
|
|
1792
2031
|
onMessage(callback: MessageCallback): void;
|
|
@@ -1812,6 +2051,39 @@ declare class GatewayClient {
|
|
|
1812
2051
|
private startHeartbeat;
|
|
1813
2052
|
private stopHeartbeat;
|
|
1814
2053
|
private resubscribeAll;
|
|
2054
|
+
private getHttpUrl;
|
|
2055
|
+
private httpRequest;
|
|
2056
|
+
healthCheck(): Promise<HealthResponse>;
|
|
2057
|
+
getStatus(): Promise<StatusResponse>;
|
|
2058
|
+
listChannels(): Promise<ChannelListResponse>;
|
|
2059
|
+
listContacts(platform: string, options?: {
|
|
2060
|
+
limit?: number;
|
|
2061
|
+
offset?: number;
|
|
2062
|
+
}): Promise<ContactListResponse>;
|
|
2063
|
+
getContact(uid: string): Promise<ContactInfo & {
|
|
2064
|
+
aliases?: Record<string, unknown>;
|
|
2065
|
+
}>;
|
|
2066
|
+
listSessions(options?: {
|
|
2067
|
+
limit?: number;
|
|
2068
|
+
offset?: number;
|
|
2069
|
+
}): Promise<SessionListResponse>;
|
|
2070
|
+
getSession(sessionId: string): Promise<SessionInfo & {
|
|
2071
|
+
subscriberCount?: number;
|
|
2072
|
+
}>;
|
|
2073
|
+
createSession(params?: {
|
|
2074
|
+
channel?: string;
|
|
2075
|
+
}): Promise<CreateSessionResponse>;
|
|
2076
|
+
sendMessage(sessionId: string, message: {
|
|
2077
|
+
content: Array<{
|
|
2078
|
+
type: string;
|
|
2079
|
+
text?: string;
|
|
2080
|
+
image?: string;
|
|
2081
|
+
data?: string;
|
|
2082
|
+
}>;
|
|
2083
|
+
channel?: string;
|
|
2084
|
+
userId?: string;
|
|
2085
|
+
messageType?: string;
|
|
2086
|
+
}): Promise<SendMessageResponse>;
|
|
1815
2087
|
}
|
|
1816
2088
|
|
|
1817
2089
|
interface TelegramBotConfig {
|
|
@@ -1820,35 +2092,91 @@ interface TelegramBotConfig {
|
|
|
1820
2092
|
enabled: boolean;
|
|
1821
2093
|
url: string;
|
|
1822
2094
|
port?: number;
|
|
2095
|
+
secret?: string;
|
|
1823
2096
|
};
|
|
1824
2097
|
polling?: {
|
|
1825
2098
|
enabled: boolean;
|
|
1826
2099
|
interval?: number;
|
|
2100
|
+
timeout?: number;
|
|
2101
|
+
};
|
|
2102
|
+
retry?: {
|
|
2103
|
+
maxAttempts?: number;
|
|
2104
|
+
initialDelay?: number;
|
|
2105
|
+
maxDelay?: number;
|
|
1827
2106
|
};
|
|
2107
|
+
commands?: TelegramBotCommand[];
|
|
2108
|
+
}
|
|
2109
|
+
interface TelegramBotCommand {
|
|
2110
|
+
command: string;
|
|
2111
|
+
description: string;
|
|
2112
|
+
handler: (ctx: TelegramCommandContext) => Promise<void>;
|
|
2113
|
+
}
|
|
2114
|
+
interface TelegramCommandContext {
|
|
2115
|
+
chatId: string;
|
|
2116
|
+
userId?: string;
|
|
2117
|
+
args: string[];
|
|
2118
|
+
messageId: number;
|
|
2119
|
+
reply?: (text: string, options?: SendMessageOptions) => Promise<string>;
|
|
2120
|
+
}
|
|
2121
|
+
interface SendMessageOptions {
|
|
2122
|
+
parseMode?: 'Markdown' | 'HTML' | 'None';
|
|
2123
|
+
replyTo?: number;
|
|
2124
|
+
replyMarkup?: ReplyMarkup;
|
|
2125
|
+
}
|
|
2126
|
+
type ReplyMarkup = InlineKeyboardMarkup | ReplyKeyboardMarkup;
|
|
2127
|
+
interface InlineKeyboardMarkup {
|
|
2128
|
+
inline_keyboard: InlineKeyboardButton[][];
|
|
2129
|
+
}
|
|
2130
|
+
interface InlineKeyboardButton {
|
|
2131
|
+
text: string;
|
|
2132
|
+
url?: string;
|
|
2133
|
+
callback_data?: string;
|
|
2134
|
+
}
|
|
2135
|
+
interface ReplyKeyboardMarkup {
|
|
2136
|
+
keyboard: KeyboardButton[][];
|
|
2137
|
+
resize_keyboard?: boolean;
|
|
2138
|
+
one_time_keyboard?: boolean;
|
|
2139
|
+
selective?: boolean;
|
|
2140
|
+
}
|
|
2141
|
+
interface KeyboardButton {
|
|
2142
|
+
text: string;
|
|
2143
|
+
request_contact?: boolean;
|
|
2144
|
+
request_location?: boolean;
|
|
1828
2145
|
}
|
|
1829
2146
|
declare class TelegramPlugin extends BaseChannelPlugin {
|
|
1830
2147
|
readonly id: string;
|
|
1831
2148
|
readonly platform: "telegram";
|
|
1832
2149
|
readonly name = "Telegram Bot";
|
|
1833
2150
|
private botConfig;
|
|
1834
|
-
private pollingInterval;
|
|
1835
|
-
private lastUpdateId;
|
|
1836
2151
|
private baseUrl;
|
|
2152
|
+
private abortController;
|
|
2153
|
+
private lastUpdateId;
|
|
2154
|
+
private typingTimers;
|
|
2155
|
+
private commandRouter;
|
|
2156
|
+
private retryState;
|
|
1837
2157
|
constructor(id?: string);
|
|
1838
2158
|
protected doStart(): Promise<void>;
|
|
1839
2159
|
protected doStop(): Promise<void>;
|
|
1840
2160
|
send(message: GatewayMessage): Promise<string>;
|
|
2161
|
+
sendTyping(chatId: string): Promise<void>;
|
|
2162
|
+
sendChatAction(chatId: string, action: 'typing' | 'upload_photo' | 'upload_document' | 'record_video' | 'upload_video' | 'record_audio' | 'upload_audio'): Promise<void>;
|
|
2163
|
+
private scheduleTypingStop;
|
|
2164
|
+
private clearAllTyping;
|
|
2165
|
+
private detectParseMode;
|
|
1841
2166
|
private startPolling;
|
|
1842
|
-
private
|
|
2167
|
+
private pollLoop;
|
|
1843
2168
|
private poll;
|
|
2169
|
+
private handlePollingError;
|
|
2170
|
+
private sleep;
|
|
1844
2171
|
private handleTelegramMessage;
|
|
2172
|
+
private handleCommand;
|
|
1845
2173
|
private toGatewayMessage;
|
|
1846
2174
|
private parseContent;
|
|
1847
|
-
|
|
1848
|
-
private
|
|
2175
|
+
protected buildSessionId(channelId: string, chatId: string, userId?: string): string;
|
|
2176
|
+
private processMessageAndGetSessionId;
|
|
1849
2177
|
private getMe;
|
|
1850
2178
|
private getUpdates;
|
|
1851
|
-
private
|
|
2179
|
+
private sendApiMessage;
|
|
1852
2180
|
private request;
|
|
1853
2181
|
}
|
|
1854
2182
|
|
|
@@ -1875,6 +2203,9 @@ declare class DiscordPlugin extends BaseChannelPlugin {
|
|
|
1875
2203
|
private heartbeatInterval;
|
|
1876
2204
|
private sessionId;
|
|
1877
2205
|
private sequenceNumber;
|
|
2206
|
+
private abortController;
|
|
2207
|
+
private reconnectAttempts;
|
|
2208
|
+
private maxReconnectAttempts;
|
|
1878
2209
|
constructor(id?: string);
|
|
1879
2210
|
protected doStart(): Promise<void>;
|
|
1880
2211
|
protected doStop(): Promise<void>;
|
|
@@ -1886,8 +2217,8 @@ declare class DiscordPlugin extends BaseChannelPlugin {
|
|
|
1886
2217
|
private handleDiscordMessage;
|
|
1887
2218
|
private toGatewayMessage;
|
|
1888
2219
|
private parseContent;
|
|
1889
|
-
|
|
1890
|
-
private
|
|
2220
|
+
protected buildSessionId(channelId: string, chatId: string, userId?: string): string;
|
|
2221
|
+
private processMessageAndGetSessionId;
|
|
1891
2222
|
private getCurrentUser;
|
|
1892
2223
|
private getGatewayBot;
|
|
1893
2224
|
private createMessage;
|
|
@@ -1912,6 +2243,7 @@ declare class SlackPlugin extends BaseChannelPlugin {
|
|
|
1912
2243
|
private botConfig;
|
|
1913
2244
|
private baseUrl;
|
|
1914
2245
|
private socketModeClient;
|
|
2246
|
+
private abortController;
|
|
1915
2247
|
constructor(id?: string);
|
|
1916
2248
|
protected doStart(): Promise<void>;
|
|
1917
2249
|
protected doStop(): Promise<void>;
|
|
@@ -1921,8 +2253,8 @@ declare class SlackPlugin extends BaseChannelPlugin {
|
|
|
1921
2253
|
private handleSlackMessage;
|
|
1922
2254
|
private toGatewayMessage;
|
|
1923
2255
|
private parseContent;
|
|
1924
|
-
|
|
1925
|
-
private
|
|
2256
|
+
protected buildSessionId(channelId: string, chatId: string, userId?: string): string;
|
|
2257
|
+
private processMessageAndGetSessionId;
|
|
1926
2258
|
private authTest;
|
|
1927
2259
|
private postMessage;
|
|
1928
2260
|
private request;
|
|
@@ -1973,6 +2305,7 @@ declare class FeishuPlugin extends BaseChannelPlugin {
|
|
|
1973
2305
|
private baseUrl;
|
|
1974
2306
|
private tenantAccessToken;
|
|
1975
2307
|
private tokenExpireTime;
|
|
2308
|
+
private abortController;
|
|
1976
2309
|
constructor(id?: string);
|
|
1977
2310
|
protected doStart(): Promise<void>;
|
|
1978
2311
|
protected doStop(): Promise<void>;
|
|
@@ -1981,8 +2314,8 @@ declare class FeishuPlugin extends BaseChannelPlugin {
|
|
|
1981
2314
|
private toGatewayMessage;
|
|
1982
2315
|
private parseContent;
|
|
1983
2316
|
private extractPostContent;
|
|
1984
|
-
|
|
1985
|
-
private
|
|
2317
|
+
protected buildSessionId(channelId: string, chatId: string, userId?: string): string;
|
|
2318
|
+
private processMessageAndGetSessionId;
|
|
1986
2319
|
private refreshTenantAccessToken;
|
|
1987
2320
|
private ensureTokenValid;
|
|
1988
2321
|
private sendMessage;
|
|
@@ -2008,6 +2341,7 @@ declare class WeChatPlugin extends BaseChannelPlugin {
|
|
|
2008
2341
|
private botConfig;
|
|
2009
2342
|
private accessToken;
|
|
2010
2343
|
private tokenExpireTime;
|
|
2344
|
+
private abortController;
|
|
2011
2345
|
constructor(id?: string);
|
|
2012
2346
|
protected doStart(): Promise<void>;
|
|
2013
2347
|
protected doStop(): Promise<void>;
|
|
@@ -2016,8 +2350,8 @@ declare class WeChatPlugin extends BaseChannelPlugin {
|
|
|
2016
2350
|
private parseXmlMessage;
|
|
2017
2351
|
private toGatewayMessage;
|
|
2018
2352
|
private parseContent;
|
|
2019
|
-
|
|
2020
|
-
private
|
|
2353
|
+
protected buildSessionId(channelId: string, chatId: string, userId?: string): string;
|
|
2354
|
+
private processMessageAndGetSessionId;
|
|
2021
2355
|
private refreshAccessToken;
|
|
2022
2356
|
private ensureTokenValid;
|
|
2023
2357
|
private sendOfficialMessage;
|
|
@@ -2042,6 +2376,7 @@ declare class WebChatPlugin extends BaseChannelPlugin {
|
|
|
2042
2376
|
private webChatConfig;
|
|
2043
2377
|
private connections;
|
|
2044
2378
|
private heartbeatInterval;
|
|
2379
|
+
private abortController;
|
|
2045
2380
|
private wsServer;
|
|
2046
2381
|
constructor(id?: string);
|
|
2047
2382
|
protected doStart(): Promise<void>;
|
|
@@ -2075,19 +2410,21 @@ declare class SignalPlugin extends BaseChannelPlugin {
|
|
|
2075
2410
|
readonly platform: "signal";
|
|
2076
2411
|
readonly name = "Signal Bot";
|
|
2077
2412
|
private botConfig;
|
|
2078
|
-
private
|
|
2413
|
+
private abortController;
|
|
2079
2414
|
private lastTimestamp;
|
|
2415
|
+
private pollingIntervalMs;
|
|
2080
2416
|
constructor(id?: string);
|
|
2081
2417
|
protected doStart(): Promise<void>;
|
|
2082
2418
|
protected doStop(): Promise<void>;
|
|
2083
2419
|
send(message: GatewayMessage): Promise<string>;
|
|
2084
2420
|
private startPolling;
|
|
2421
|
+
private pollLoop;
|
|
2085
2422
|
private poll;
|
|
2086
2423
|
private handleSignalMessage;
|
|
2087
2424
|
private toGatewayMessage;
|
|
2088
2425
|
private parseContent;
|
|
2089
|
-
|
|
2090
|
-
private
|
|
2426
|
+
protected buildSessionId(channelId: string, chatId: string, userId?: string): string;
|
|
2427
|
+
private processMessageAndGetSessionId;
|
|
2091
2428
|
private getAccountInfo;
|
|
2092
2429
|
private receiveMessages;
|
|
2093
2430
|
private sendMessage;
|
|
@@ -2108,6 +2445,9 @@ declare class NostrPlugin extends BaseChannelPlugin {
|
|
|
2108
2445
|
private relayConnections;
|
|
2109
2446
|
private subscriptions;
|
|
2110
2447
|
private eventHandlers;
|
|
2448
|
+
private abortController;
|
|
2449
|
+
private relayReconnectAttempts;
|
|
2450
|
+
private maxReconnectAttempts;
|
|
2111
2451
|
constructor(id?: string);
|
|
2112
2452
|
protected doStart(): Promise<void>;
|
|
2113
2453
|
protected doStop(): Promise<void>;
|
|
@@ -2118,8 +2458,8 @@ declare class NostrPlugin extends BaseChannelPlugin {
|
|
|
2118
2458
|
private toGatewayMessage;
|
|
2119
2459
|
private parseContent;
|
|
2120
2460
|
private findReplyTo;
|
|
2121
|
-
|
|
2122
|
-
private
|
|
2461
|
+
protected buildSessionId(channelId: string, chatId: string, userId?: string): string;
|
|
2462
|
+
private processMessageAndGetSessionId;
|
|
2123
2463
|
private subscribeToRelay;
|
|
2124
2464
|
private createEvent;
|
|
2125
2465
|
private computeEventId;
|
|
@@ -2202,4 +2542,4 @@ declare function initLog(options: {
|
|
|
2202
2542
|
level?: 'DEBUG' | 'INFO' | 'WARN' | 'ERROR';
|
|
2203
2543
|
}): Promise<void>;
|
|
2204
2544
|
|
|
2205
|
-
export { type AgentDeregisterMessage, type AgentHealthStatus, type AgentHeartbeat, type AgentHeartbeatSyncMessage, type AgentListRequestMessage, type AgentListResponseMessage, type AgentRegisterMessage, type AgentRegistration, type AgentRegistrationRequest, AgentRegistry, type AgentRegistryConfig, AgentRegistryConfigSchema, type AgentRegistryStats, type AgentSelectionOptions, type AgentSelectionRecord, type AgentSelectionStrategy, type AgentStatusChangeMessage, type AgentSyncConfig, AgentSyncConfigSchema, type AgentSyncInfo, AgentSyncManager, type AuthConfig, AuthConfigSchema, type AuthResult, BaseChannelPlugin, type CancelEvent, type CancelEventHandler, type ChannelConfig, ChannelConfigSchema, type ChannelEvent, type ChannelEventType, type ChannelHealth, type ChannelPlugin, ChannelPluginLoader, ChannelPluginRegistry, type SessionConfig as ChannelSessionConfig, type ChannelStatus, type ChannelStatusType, type ChannelType, type CircuitBreakerConfig, CircuitBreakerConfigSchema, type ConnectionState as ClientConnectionState, type ClientInitializeMessage, type ClientInterruptMessage, type ClientMessage, type ClientMessageMessage, type ClientMessageType, type ClientPingMessage, type ClientReleaseSubscriptionMessage, type ClientSubscribeMessage, type ClientSubscription, type ClientUnsubscribeMessage, type ConflictResolutionStrategy, type ConnectionCloser, type ConnectionFactory, type ConnectionHealthChecker, type ConnectionPoolConfig, ConnectionPoolConfigSchema, type ConnectionPoolEvent, type ConnectionPoolEventCallback, type ConnectionPoolEventType, type ConnectionPoolStats, type ConnectionState$1 as ConnectionState, type CreateSessionRequest, type CreateSessionResponse, DEFAULT_AGENT_REGISTRY_CONFIG, DEFAULT_CONNECTION_POOL_CONFIG, DEFAULT_SYNC_CONFIG, DEFAULT_TOKEN_AUTH_CONFIG, DEFAULT_WEBSOCKET_SERVER_CONFIG, type DiscordBotConfig, DiscordPlugin, type FeishuBotConfig, type FeishuChannelConfig, FeishuChannelConfigSchema, FeishuPlugin, Gateway, GatewayClient, type GatewayClientConfig, type GatewayClusterConfig, GatewayClusterConfigSchema, type GatewayConfig, GatewayConfigSchema, type GatewayNodeConfig, type GatewayNodeInfo, GatewayServer, type GatewayServerConfig, GatewayServerConfigSchema, type GatewaySession, GatewaySessionManager, type HTTPSConfig, HTTPSConfigSchema, type HealthCheckResponse, type IAuthProvider, type MessageCallback, type MessageHandler, MessageLockManager, type MessagePriority, type MessageQueueConfig, MessageQueueConfigSchema, type MessageRecord, MessageRetryManager, MessageRouter, type MessageStatus, MessageStore, type MessageStoreConfig, type NostrBotConfig, type NostrChannelConfig, NostrChannelConfigSchema, NostrPlugin, type OAuth2AuthConfig, type PluginLoaderConfig, type PooledConnection, type PushEventType, type RouteResult, type RoutingConfig, type SendMessageRequest, type SendMessageResponse, type SerializableSession, type ServerConnectedMessage, type ServerErrorMessage, type ServerEventMessage, type ServerInitializeResponseMessage, type ServerInterruptedMessage, type ServerMessage, type ServerMessageType, type ServerPongMessage, type ServerResponseMessage, type ServerSessionClosedMessage, type ServerStatusResponse, type ServerSubscribedMessage, type ServerSubscriptionReleasedMessage, type ServerUnsubscribedMessage, type SessionChannelInfo, type SessionConfig$1 as SessionConfig, SessionConfigSchema, type SessionContext, type SessionEventPayload, type SessionEventType, type SessionFilter, type SessionManagerConfig, type SessionResetPolicy, type SessionState, type SessionStatusType, SessionStore, type SessionStoreConfig, type SignalBotConfig, type SignalChannelConfig, SignalChannelConfigSchema, SignalPlugin, type SlackBotConfig, type SlackChannelConfig, SlackChannelConfigSchema, SlackPlugin, type Subscriber, type SubscriberConnection, type SubscriberType, type Subscription, type SubscriptionOptions, type SubscriptionsResponse, type SyncConfig, type SyncMessage, type SyncMode, type SyncState, type SyncStats, type TelegramBotConfig, type TelegramChannelConfig, TelegramChannelConfigSchema, TelegramPlugin, type TokenAuthConfig, type TokenAuthItem, type TokenConfig, type WeChatBotConfig, type WeChatChannelConfig, WeChatChannelConfigSchema, WeChatPlugin, type WebChatChannelConfig, WebChatChannelConfigSchema, type WebChatConfig, WebChatPlugin, type WebSocketConnectionInfo, type WebSocketConnectionState, type WebSocketMessage, type WebSocketMessageBase, clearConfigCache, createChannelPlugin, createDefaultSessionState, createGatewayMessage, createTextMessage, generateSessionId, generateSubscriptionId, getAgentAdapter, getAgentRegistryConfig, getAuthConfig, getChannelConfig, getCircuitBreakerConfig, getClusterConfig, getConfig, getConfigDirectory, getConnectionPoolConfig, getDefaultAgent, getHTTPSConfig, getLogLevel, getMessageQueueConfig, getServerConfig, getSessionConfig, getSupportedPlatforms, hasAgentAdapter, initLog, isConfigLoaded, loadConfig, parsePartialConfig, requireAgentAdapter, setAgentAdapter, validateConfig };
|
|
2545
|
+
export { type AgentDeregisterMessage, type AgentHealthStatus, type AgentHeartbeat, type AgentHeartbeatSyncMessage, type AgentListRequestMessage, type AgentListResponseMessage, type AgentRegisterMessage, type AgentRegistration, type AgentRegistrationRequest, AgentRegistry, type AgentRegistryConfig, AgentRegistryConfigSchema, type AgentRegistryStats, type AgentSelectionOptions, type AgentSelectionRecord, type AgentSelectionStrategy, type AgentStatusChangeMessage, type AgentSyncConfig, AgentSyncConfigSchema, type AgentSyncInfo, AgentSyncManager, type AuthConfig, AuthConfigSchema, type AuthResult, BaseChannelPlugin, type CancelEvent, type CancelEventHandler, type ChannelConfig, ChannelConfigSchema, type ChannelEvent, type ChannelEventType, type ChannelHealth, type ChannelPlugin, ChannelPluginLoader, ChannelPluginRegistry, type SessionConfig as ChannelSessionConfig, type ChannelStatus, type ChannelStatusType, type ChannelType, type CircuitBreakerConfig, CircuitBreakerConfigSchema, type ConnectionState as ClientConnectionState, type ClientInitializeMessage, type ClientInterruptMessage, type ClientMessage, type ClientMessageMessage, type ClientMessageType, type ClientPingMessage, type ClientReleaseSubscriptionMessage, type ClientSubscribeMessage, type ClientSubscription, type ClientUnsubscribeMessage, type ConflictResolutionStrategy, type ConnectionCloser, type ConnectionFactory, type ConnectionHealthChecker, type ConnectionPoolConfig, ConnectionPoolConfigSchema, type ConnectionPoolEvent, type ConnectionPoolEventCallback, type ConnectionPoolEventType, type ConnectionPoolStats, type ConnectionState$1 as ConnectionState, type ContactInfo, type ContactListResponse, type CreateSessionRequest, type CreateSessionResponse$1 as CreateSessionResponse, DEFAULT_AGENT_REGISTRY_CONFIG, DEFAULT_CONNECTION_POOL_CONFIG, DEFAULT_SYNC_CONFIG, DEFAULT_TOKEN_AUTH_CONFIG, DEFAULT_WEBSOCKET_SERVER_CONFIG, type DiscordBotConfig, DiscordPlugin, type FeishuBotConfig, type FeishuChannelConfig, FeishuChannelConfigSchema, FeishuPlugin, Gateway, GatewayClient, type GatewayClientConfig, type GatewayClusterConfig, GatewayClusterConfigSchema, type GatewayConfig, GatewayConfigSchema, type GatewayNodeConfig, type GatewayNodeInfo, GatewayServer, type GatewayServerConfig, GatewayServerConfigSchema, type GatewaySession, GatewaySessionManager, type HTTPSConfig, HTTPSConfigSchema, type HealthCheckResponse, type HealthResponse, type IAuthProvider, type MessageCallback, type MessageHandler, MessageLockManager, type MessagePriority, type MessageQueueConfig, MessageQueueConfigSchema, type MessageRecord, MessageRetryManager, MessageRouter, type MessageStatus, MessageStore, type MessageStoreConfig, type NostrBotConfig, type NostrChannelConfig, NostrChannelConfigSchema, NostrPlugin, type OAuth2AuthConfig, type PluginLoaderConfig, type PooledConnection, type PushEventType, type RouteResult, type RoutingConfig, type SendMessageRequest, type SendMessageResponse$1 as SendMessageResponse, type SerializableSession, type ServerConnectedMessage, type ServerErrorMessage, type ServerEventMessage, type ServerInitializeResponseMessage, type ServerInterruptedMessage, type ServerMessage, type ServerMessageType, type ServerPongMessage, type ServerResponseMessage, type ServerSessionClosedMessage, type ServerStatusResponse, type ServerSubscribedMessage, type ServerSubscriptionReleasedMessage, type ServerUnsubscribedMessage, type SessionChannelInfo, type SessionConfig$1 as SessionConfig, SessionConfigSchema, type SessionContext, type SessionEventPayload, type SessionEventType, type SessionFilter, type SessionInfo, type SessionListResponse, type SessionManagerConfig, type SessionResetPolicy, type SessionState, type SessionStatusType, SessionStore, type SessionStoreConfig, type SignalBotConfig, type SignalChannelConfig, SignalChannelConfigSchema, SignalPlugin, type SlackBotConfig, type SlackChannelConfig, SlackChannelConfigSchema, SlackPlugin, type StatusResponse, type Subscriber, type SubscriberConnection, type SubscriberType, type Subscription, type SubscriptionOptions, type SubscriptionsResponse, type SyncConfig, type SyncMessage, type SyncMode, type SyncState, type SyncStats, type TelegramBotConfig, type TelegramChannelConfig, TelegramChannelConfigSchema, TelegramPlugin, type TokenAuthConfig, type TokenAuthItem, type TokenConfig, type WeChatBotConfig, type WeChatChannelConfig, WeChatChannelConfigSchema, WeChatPlugin, type WebChatChannelConfig, WebChatChannelConfigSchema, type WebChatConfig, WebChatPlugin, type WebSocketConnectionInfo, type WebSocketConnectionState, type WebSocketMessage, type WebSocketMessageBase, clearConfigCache, createChannelPlugin, createDefaultSessionState, createGatewayMessage, createTextMessage, generateSessionId, generateSubscriptionId, getAgentAdapter, getAgentRegistryConfig, getAuthConfig, getChannelConfig, getCircuitBreakerConfig, getClusterConfig, getConfig, getConfigDirectory, getConnectionPoolConfig, getDefaultAgent, getHTTPSConfig, getLogLevel, getMessageQueueConfig, getServerConfig, getSessionConfig, getSupportedPlatforms, hasAgentAdapter, initLog, isConfigLoaded, loadConfig, parsePartialConfig, requireAgentAdapter, setAgentAdapter, validateConfig };
|