@easbot/gateway 0.2.46 → 0.2.47
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-7OFQ65NG.mjs +7 -0
- package/dist/chunks/chunk-AUPHFE34.cjs +7 -0
- package/dist/chunks/chunk-EKVLJAIP.cjs +44 -0
- package/dist/chunks/chunk-GY3SWWW3.cjs +1 -0
- package/dist/chunks/chunk-HAMGVOQD.mjs +1 -0
- package/dist/chunks/chunk-NXFFFRVB.mjs +1 -0
- package/dist/chunks/chunk-TQ74GHLT.cjs +1 -0
- package/dist/chunks/chunk-VEA6YZG4.mjs +44 -0
- package/dist/chunks/log-JFEBRH2W.cjs +1 -0
- package/dist/chunks/log-MIT4H7S5.mjs +1 -0
- package/dist/chunks/permissions-42BQOY5P.mjs +1 -0
- package/dist/chunks/permissions-VBDNAQUT.cjs +1 -0
- package/dist/chunks/server-JXSJH7GK.cjs +1 -0
- package/dist/chunks/server-OGBOUOJL.mjs +1 -0
- package/dist/index.cjs +37 -1
- package/dist/index.d.cts +167 -5
- package/dist/index.d.ts +167 -5
- package/dist/index.mjs +37 -1
- package/package.json +8 -5
- package/dist/chunks/chunk-3SBZTZXS.cjs +0 -7
- package/dist/chunks/chunk-3SZYN4FH.cjs +0 -32
- package/dist/chunks/chunk-NXQVGFLW.mjs +0 -32
- package/dist/chunks/chunk-RGPJTZUB.mjs +0 -7
- package/dist/chunks/log-FQII2FT4.mjs +0 -1
- package/dist/chunks/log-VLMXTUPA.cjs +0 -1
- package/dist/chunks/server-33DE2N5W.mjs +0 -1
- package/dist/chunks/server-JHZH3ULE.cjs +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export { AgentAdapter, AgentInfo, ChannelInfo, ChannelListResponse, GatewayMessa
|
|
|
3
3
|
import z, { z as z$1 } from 'zod';
|
|
4
4
|
import { WSContext } from '@easbot/utils';
|
|
5
5
|
import { Command, EasbotClient } from '@easbot/sdk';
|
|
6
|
+
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
6
7
|
|
|
7
8
|
declare namespace Gateway {
|
|
8
9
|
export interface BootstrapConfig {
|
|
@@ -40,6 +41,7 @@ declare const ChannelTypeSchema: z.ZodEnum<{
|
|
|
40
41
|
slack: "slack";
|
|
41
42
|
feishu: "feishu";
|
|
42
43
|
wechat: "wechat";
|
|
44
|
+
weixin: "weixin";
|
|
43
45
|
webchat: "webchat";
|
|
44
46
|
signal: "signal";
|
|
45
47
|
nostr: "nostr";
|
|
@@ -171,6 +173,14 @@ declare const ChannelConfigSchema: z.ZodObject<{
|
|
|
171
173
|
maxConnections: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
172
174
|
timeout: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
173
175
|
}, z.core.$strip>>;
|
|
176
|
+
weixin: z.ZodOptional<z.ZodObject<{
|
|
177
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
178
|
+
stateDir: z.ZodOptional<z.ZodString>;
|
|
179
|
+
baseUrl: z.ZodOptional<z.ZodString>;
|
|
180
|
+
cdnBaseUrl: z.ZodOptional<z.ZodString>;
|
|
181
|
+
maxMessageLength: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
182
|
+
timeout: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
183
|
+
}, z.core.$strip>>;
|
|
174
184
|
webchat: z.ZodOptional<z.ZodObject<{
|
|
175
185
|
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
176
186
|
path: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
@@ -549,6 +559,14 @@ declare const GatewayConfigSchema: z.ZodObject<{
|
|
|
549
559
|
maxConnections: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
550
560
|
timeout: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
551
561
|
}, z.core.$strip>>;
|
|
562
|
+
weixin: z.ZodOptional<z.ZodObject<{
|
|
563
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
564
|
+
stateDir: z.ZodOptional<z.ZodString>;
|
|
565
|
+
baseUrl: z.ZodOptional<z.ZodString>;
|
|
566
|
+
cdnBaseUrl: z.ZodOptional<z.ZodString>;
|
|
567
|
+
maxMessageLength: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
568
|
+
timeout: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
569
|
+
}, z.core.$strip>>;
|
|
552
570
|
webchat: z.ZodOptional<z.ZodObject<{
|
|
553
571
|
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
554
572
|
path: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
@@ -1667,6 +1685,25 @@ interface LocalCommandResult {
|
|
|
1667
1685
|
reply?: string;
|
|
1668
1686
|
continueProcessing?: boolean;
|
|
1669
1687
|
}
|
|
1688
|
+
interface CommandContext {
|
|
1689
|
+
text: string;
|
|
1690
|
+
sessionId: string;
|
|
1691
|
+
chatId: string;
|
|
1692
|
+
channelInfo: {
|
|
1693
|
+
platform: string;
|
|
1694
|
+
channelId: string;
|
|
1695
|
+
userId?: string;
|
|
1696
|
+
chatId?: string;
|
|
1697
|
+
[key: string]: unknown;
|
|
1698
|
+
};
|
|
1699
|
+
messageId?: string;
|
|
1700
|
+
replyToMessageId?: string;
|
|
1701
|
+
}
|
|
1702
|
+
interface CommandResult {
|
|
1703
|
+
handled: boolean;
|
|
1704
|
+
reply?: string;
|
|
1705
|
+
gatewayMessage?: GatewayMessage;
|
|
1706
|
+
}
|
|
1670
1707
|
declare abstract class BaseChannelPlugin implements ChannelPlugin {
|
|
1671
1708
|
abstract readonly id: string;
|
|
1672
1709
|
abstract readonly platform: PlatformType;
|
|
@@ -1699,8 +1736,10 @@ declare abstract class BaseChannelPlugin implements ChannelPlugin {
|
|
|
1699
1736
|
protected handleEvent(type: string, data?: unknown): Promise<void>;
|
|
1700
1737
|
protected getCommandList(): Promise<Command[]>;
|
|
1701
1738
|
protected processLocalCommand(command: string, sessionId: string, chatId: string): Promise<LocalCommandResult>;
|
|
1739
|
+
private handleCommandsCommand;
|
|
1702
1740
|
private handleNewCommand;
|
|
1703
1741
|
private handleStatusCommand;
|
|
1742
|
+
processCommand(ctx: CommandContext): Promise<CommandResult>;
|
|
1704
1743
|
private formatStatusReport;
|
|
1705
1744
|
private formatUptime;
|
|
1706
1745
|
}
|
|
@@ -2602,6 +2641,61 @@ declare class WeChatPlugin extends BaseChannelPlugin {
|
|
|
2602
2641
|
protected buildSessionId(channelId: string, chatId: string, userId?: string): string;
|
|
2603
2642
|
}
|
|
2604
2643
|
|
|
2644
|
+
interface WeixinBotConfig {
|
|
2645
|
+
stateDir?: string;
|
|
2646
|
+
baseUrl?: string;
|
|
2647
|
+
cdnBaseUrl?: string;
|
|
2648
|
+
maxMessageLength?: number;
|
|
2649
|
+
timeout?: number;
|
|
2650
|
+
}
|
|
2651
|
+
declare class WeixinPlugin extends BaseChannelPlugin {
|
|
2652
|
+
readonly id: string;
|
|
2653
|
+
readonly platform: "weixin";
|
|
2654
|
+
readonly name = "WeChat iLink";
|
|
2655
|
+
private botConfig;
|
|
2656
|
+
private account;
|
|
2657
|
+
private abortController;
|
|
2658
|
+
private processedMessageIds;
|
|
2659
|
+
private sentMessages;
|
|
2660
|
+
private retryState;
|
|
2661
|
+
private pollingStopped;
|
|
2662
|
+
constructor(id?: string);
|
|
2663
|
+
protected doStart(): Promise<void>;
|
|
2664
|
+
private resolveStateDir;
|
|
2665
|
+
protected doStop(): Promise<void>;
|
|
2666
|
+
protected doHealthCheck(): Promise<boolean>;
|
|
2667
|
+
send(message: GatewayMessage): Promise<string>;
|
|
2668
|
+
getCapabilities(): {
|
|
2669
|
+
supportsText: boolean;
|
|
2670
|
+
supportsMedia: boolean;
|
|
2671
|
+
supportsReply: boolean;
|
|
2672
|
+
supportsThread: boolean;
|
|
2673
|
+
supportsEdit: boolean;
|
|
2674
|
+
supportsDelete: boolean;
|
|
2675
|
+
supportsTyping: boolean;
|
|
2676
|
+
supportsBatchSend: boolean;
|
|
2677
|
+
supportsMarkdown: boolean;
|
|
2678
|
+
supportsHtml: boolean;
|
|
2679
|
+
supportsDeliveryReceipt: boolean;
|
|
2680
|
+
supportsReadReceipt: boolean;
|
|
2681
|
+
supportsSlashCommands: boolean;
|
|
2682
|
+
supportsNativeCommands: boolean;
|
|
2683
|
+
commandPrefix: string;
|
|
2684
|
+
maxMessageLength: number;
|
|
2685
|
+
maxMediaCount: number;
|
|
2686
|
+
};
|
|
2687
|
+
private resolveDownloadDir;
|
|
2688
|
+
private runPollLoop;
|
|
2689
|
+
private restartPollLoop;
|
|
2690
|
+
private handleWeixinMessage;
|
|
2691
|
+
private sendCommandReply;
|
|
2692
|
+
private parseContent;
|
|
2693
|
+
private resolveAttachmentToPath;
|
|
2694
|
+
private downloadUrlToLocal;
|
|
2695
|
+
sendTyping(userId: string): Promise<void>;
|
|
2696
|
+
protected buildSessionId(channelId: string, chatId: string, userId?: string): string;
|
|
2697
|
+
}
|
|
2698
|
+
|
|
2605
2699
|
interface WebChatConfig {
|
|
2606
2700
|
port: number;
|
|
2607
2701
|
hostname: string;
|
|
@@ -2853,6 +2947,63 @@ declare function createChannelPlugin<TConfig = unknown, TProbe = unknown>(option
|
|
|
2853
2947
|
declare const ChannelPluginRegistry: Record<string, new (id?: string) => ChannelPlugin>;
|
|
2854
2948
|
declare function getSupportedPlatforms(): string[];
|
|
2855
2949
|
|
|
2950
|
+
declare function setStateDir(dir: string): void;
|
|
2951
|
+
|
|
2952
|
+
declare const WEIXIN_PLATFORM: PlatformType;
|
|
2953
|
+
interface EnsureUserOptions {
|
|
2954
|
+
userId: string;
|
|
2955
|
+
channelId?: string;
|
|
2956
|
+
displayName?: string;
|
|
2957
|
+
username?: string;
|
|
2958
|
+
aliases?: PlatformAliases;
|
|
2959
|
+
metadata?: Record<string, unknown>;
|
|
2960
|
+
}
|
|
2961
|
+
declare function ensureContact(opts: EnsureUserOptions): Promise<{
|
|
2962
|
+
contact: Contact;
|
|
2963
|
+
created: boolean;
|
|
2964
|
+
}>;
|
|
2965
|
+
declare function ensureSession(opts: EnsureUserOptions): Promise<{
|
|
2966
|
+
session: SerializableSession;
|
|
2967
|
+
created: boolean;
|
|
2968
|
+
}>;
|
|
2969
|
+
declare function ensureUser(opts: EnsureUserOptions): Promise<{
|
|
2970
|
+
contact: Contact;
|
|
2971
|
+
session: SerializableSession;
|
|
2972
|
+
created: {
|
|
2973
|
+
contact: boolean;
|
|
2974
|
+
session: boolean;
|
|
2975
|
+
};
|
|
2976
|
+
}>;
|
|
2977
|
+
declare function removeUser(userId: string, channelId?: string): Promise<{
|
|
2978
|
+
removed: {
|
|
2979
|
+
contact: boolean;
|
|
2980
|
+
session: boolean;
|
|
2981
|
+
};
|
|
2982
|
+
}>;
|
|
2983
|
+
declare function listWeixinContacts(): Promise<Contact[]>;
|
|
2984
|
+
|
|
2985
|
+
interface ChannelPermissionRequestParams {
|
|
2986
|
+
request_id: string;
|
|
2987
|
+
tool_name: string;
|
|
2988
|
+
description: string;
|
|
2989
|
+
input_preview: string;
|
|
2990
|
+
channel_context?: {
|
|
2991
|
+
source_server?: string;
|
|
2992
|
+
chat_id?: string;
|
|
2993
|
+
};
|
|
2994
|
+
}
|
|
2995
|
+
|
|
2996
|
+
interface WeixinServerDeps {
|
|
2997
|
+
enableConfigs(): void;
|
|
2998
|
+
initializeAnalyticsSink(): void;
|
|
2999
|
+
shutdownDatadog(): Promise<void>;
|
|
3000
|
+
shutdown1PEventLogging(): Promise<void>;
|
|
3001
|
+
logForDebugging(message: string): void;
|
|
3002
|
+
registerPermissionHandler(server: Server, handler: (request: ChannelPermissionRequestParams) => Promise<void>): void;
|
|
3003
|
+
}
|
|
3004
|
+
|
|
3005
|
+
declare function handleWeixinCli(args: string[], serverDeps?: WeixinServerDeps, version?: string): Promise<void>;
|
|
3006
|
+
|
|
2856
3007
|
declare enum SdkEventType {
|
|
2857
3008
|
SDK_SESSION_STATUS = "agent.status",
|
|
2858
3009
|
SDK_ERROR = "sdk.error",
|
|
@@ -2878,7 +3029,7 @@ declare const SdkErrorSchema: z$1.ZodObject<{
|
|
|
2878
3029
|
type SdkErrorProps = z$1.infer<typeof SdkErrorSchema>;
|
|
2879
3030
|
declare const SdkSessionUpdateSchema: z$1.ZodObject<{
|
|
2880
3031
|
sessionId: z$1.ZodString;
|
|
2881
|
-
|
|
3032
|
+
sessionEvent: z$1.ZodUnknown;
|
|
2882
3033
|
timestamp: z$1.ZodNumber;
|
|
2883
3034
|
}, z$1.core.$strip>;
|
|
2884
3035
|
type SdkSessionUpdateProps = z$1.infer<typeof SdkSessionUpdateSchema>;
|
|
@@ -2912,6 +3063,7 @@ declare class SdkEventBus {
|
|
|
2912
3063
|
subscribeAll(callback: LocalEventCallback): () => void;
|
|
2913
3064
|
publish(event: LocalEvent): Promise<void>;
|
|
2914
3065
|
publishSync(event: LocalEvent): void;
|
|
3066
|
+
private collectCallbacks;
|
|
2915
3067
|
subscriberCount(eventType?: SdkEventType): number;
|
|
2916
3068
|
totalSubscribers(): number;
|
|
2917
3069
|
hasSubscribers(eventType?: SdkEventType): boolean;
|
|
@@ -2927,8 +3079,11 @@ declare class SdkEventBridge {
|
|
|
2927
3079
|
private started;
|
|
2928
3080
|
private readonly sessionFilter?;
|
|
2929
3081
|
private _cachedPrimaryAgents;
|
|
3082
|
+
private readonly _messageMetaCache;
|
|
2930
3083
|
constructor(sdk: EasbotClient, localEventBus?: SdkEventBus, sessionFilter?: (sessionId: string) => boolean);
|
|
2931
|
-
private
|
|
3084
|
+
private getMessageMeta;
|
|
3085
|
+
private clearMessageMetaCache;
|
|
3086
|
+
private pushSessionEvent;
|
|
2932
3087
|
start(): Promise<void>;
|
|
2933
3088
|
stop(): Promise<void>;
|
|
2934
3089
|
isStarted(): boolean;
|
|
@@ -2960,9 +3115,12 @@ interface AgentMessage {
|
|
|
2960
3115
|
thinking?: string;
|
|
2961
3116
|
tools?: Array<{
|
|
2962
3117
|
name: string;
|
|
3118
|
+
callId?: string;
|
|
3119
|
+
title?: string;
|
|
2963
3120
|
status: 'completed' | 'error';
|
|
2964
3121
|
output?: unknown;
|
|
2965
3122
|
error?: string;
|
|
3123
|
+
input?: Record<string, unknown>;
|
|
2966
3124
|
}>;
|
|
2967
3125
|
metadata: {
|
|
2968
3126
|
sessionId: string;
|
|
@@ -3014,10 +3172,14 @@ interface PartData {
|
|
|
3014
3172
|
end?: number;
|
|
3015
3173
|
};
|
|
3016
3174
|
tool?: string;
|
|
3175
|
+
callId?: string;
|
|
3017
3176
|
state?: {
|
|
3018
|
-
status?: 'running' | 'completed' | 'error';
|
|
3177
|
+
status?: 'pending' | 'running' | 'completed' | 'error';
|
|
3178
|
+
input?: Record<string, unknown>;
|
|
3019
3179
|
output?: unknown;
|
|
3020
3180
|
error?: string;
|
|
3181
|
+
title?: string;
|
|
3182
|
+
metadata?: Record<string, unknown>;
|
|
3021
3183
|
};
|
|
3022
3184
|
tokens?: {
|
|
3023
3185
|
input: number;
|
|
@@ -3025,7 +3187,7 @@ interface PartData {
|
|
|
3025
3187
|
reasoning: number;
|
|
3026
3188
|
};
|
|
3027
3189
|
}
|
|
3028
|
-
declare class
|
|
3190
|
+
declare class SdkMessageCollector {
|
|
3029
3191
|
private filterConfig;
|
|
3030
3192
|
events: SessionEvent[];
|
|
3031
3193
|
isComplete: boolean;
|
|
@@ -3062,4 +3224,4 @@ declare function initLog(options: {
|
|
|
3062
3224
|
level?: 'DEBUG' | 'INFO' | 'WARN' | 'ERROR';
|
|
3063
3225
|
}): Promise<void>;
|
|
3064
3226
|
|
|
3065
|
-
export { type AgentClientFilterConfig, type AgentDeregisterMessage, type AgentHealthStatus, type AgentHeartbeat, type AgentHeartbeatSyncMessage, type AgentListRequestMessage, type AgentListResponseMessage, type AgentMessage, 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 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, type CreateSessionRequest, type CreateSessionResponse, DEBUG_AGENT_FILTER, DEFAULT_AGENT_FILTER, 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, type GatewayClientConfig, GatewayClientConfigSchema, 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 MessageHandler, type MessagePriority, type MessageQueueConfig, MessageQueueConfigSchema, type MessageRecord, MessageRouter, type MessageStatus, MessageStore, type MessageStoreConfig, type NostrBotConfig, type NostrChannelConfig, NostrChannelConfigSchema, NostrPlugin, type OAuth2AuthConfig, type PluginLoaderConfig, type PooledConnection, type PushEventType, type RouteResult, type RoutingConfig, SdkEventBridge, SdkEventBus, SdkEventType,
|
|
3227
|
+
export { type AgentClientFilterConfig, type AgentDeregisterMessage, type AgentHealthStatus, type AgentHeartbeat, type AgentHeartbeatSyncMessage, type AgentListRequestMessage, type AgentListResponseMessage, type AgentMessage, 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 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, type CreateSessionRequest, type CreateSessionResponse, DEBUG_AGENT_FILTER, DEFAULT_AGENT_FILTER, DEFAULT_AGENT_REGISTRY_CONFIG, DEFAULT_CONNECTION_POOL_CONFIG, DEFAULT_SYNC_CONFIG, DEFAULT_TOKEN_AUTH_CONFIG, DEFAULT_WEBSOCKET_SERVER_CONFIG, type DiscordBotConfig, DiscordPlugin, type EnsureUserOptions, type FeishuBotConfig, type FeishuChannelConfig, FeishuChannelConfigSchema, FeishuPlugin, Gateway, type GatewayClientConfig, GatewayClientConfigSchema, 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 MessageHandler, type MessagePriority, type MessageQueueConfig, MessageQueueConfigSchema, type MessageRecord, MessageRouter, type MessageStatus, MessageStore, type MessageStoreConfig, type NostrBotConfig, type NostrChannelConfig, NostrChannelConfigSchema, NostrPlugin, type OAuth2AuthConfig, type PartData, type PluginLoaderConfig, type PooledConnection, type PushEventType, type RouteResult, type RoutingConfig, SdkEventBridge, SdkEventBus, SdkEventType, SdkMessageCollector, type SdkSessionStatusProps, type SendMessageRequest, type SendMessageResponse, type SerializableSession, type ServerConnectedMessage, type ServerErrorMessage, type ServerEventMessage, type ServerInterruptedMessage, type ServerMessage, type ServerMessageType, type ServerPongMessage, type ServerResponseMessage, type ServerStatusResponse, type ServerSubscribedMessage, type ServerSubscriptionReleasedMessage, type ServerUnsubscribedMessage, type SessionChannelInfo, type SessionConfig$1 as SessionConfig, SessionConfigSchema, type SessionContext, type SessionEvent, type SessionEventPayload, type SessionEventType$1 as 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, WEIXIN_PLATFORM, type WeChatBotConfig, type WeChatChannelConfig, WeChatChannelConfigSchema, WeChatPlugin, type WebChatChannelConfig, WebChatChannelConfigSchema, type WebChatConfig, WebChatPlugin, type WebSocketConnectionInfo, type WebSocketConnectionState, type WebSocketMessage, type WebSocketMessageBase, type WeixinBotConfig, WeixinPlugin, type WeixinServerDeps, clearConfigCache, convertToGatewayMessage, createChannelPlugin, createDefaultSessionState, createGatewayMessage, createTextMessage, ensureContact, ensureSession, ensureUser, generateSessionId, generateSubscriptionId, getAgentAdapter, getAgentRegistryConfig, getAuthConfig, getChannelConfig, getCircuitBreakerConfig, getClusterConfig, getConfig, getConfigDirectory, getConnectionPoolConfig, getDefaultAgent, getGatewayClientConfig, getGatewayClientUrl, getHTTPSConfig, getLogLevel, getMessageQueueConfig, getServerConfig, getSessionConfig, getSupportedPlatforms, handleWeixinCli, hasAgentAdapter, initLog, isConfigLoaded, listWeixinContacts, loadConfig, parsePartialConfig, removeUser, requireAgentAdapter, setAgentAdapter, validateConfig, setStateDir as weixinSetStateDir };
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1,37 @@
|
|
|
1
|
-
import {Z,w,_}from'./chunks/chunk-
|
|
1
|
+
import {b,c}from'./chunks/chunk-NXFFFRVB.mjs';import {Z,w as w$1,_,Ca,Da,Ba,xa,ya,Na,Ja,Ha,Ia,Ea,Qa,Oa,Ra,Fa,Ka,La,Ma,Pa}from'./chunks/chunk-VEA6YZG4.mjs';export{Za as AgentRegistry,p as AgentRegistryConfigSchema,k as AgentSyncConfigSchema,_a as AgentSyncManager,j as AuthConfigSchema,qa as BaseChannelPlugin,h as ChannelConfigSchema,oa as ChannelPluginLoader,Xa as ChannelPluginRegistry,o as CircuitBreakerConfigSchema,m as ConnectionPoolConfigSchema,T as DEBUG_AGENT_FILTER,S as DEFAULT_AGENT_FILTER,ha as DEFAULT_AGENT_REGISTRY_CONFIG,ja as DEFAULT_CONNECTION_POOL_CONFIG,ia as DEFAULT_SYNC_CONFIG,ga as DEFAULT_TOKEN_AUTH_CONFIG,fa as DEFAULT_WEBSOCKET_SERVER_CONFIG,sa as DiscordPlugin,c as FeishuChannelConfigSchema,ua as FeishuPlugin,s as GatewayClientConfigSchema,l as GatewayClusterConfigSchema,t as GatewayConfigSchema,$a as GatewayServer,r as GatewayServerConfigSchema,na as GatewaySessionManager,i as HTTPSConfigSchema,n as MessageQueueConfigSchema,ka as MessageRouter,la as MessageStore,g as NostrChannelConfigSchema,Va as NostrPlugin,R as SdkEventBridge,Q as SdkEventBus,P as SdkEventType,U as SdkMessageCollector,q as SessionConfigSchema,ma as SessionStore,f as SignalChannelConfigSchema,Ua as SignalPlugin,b as SlackChannelConfigSchema,ta as SlackPlugin,a as TelegramChannelConfigSchema,ra as TelegramPlugin,wa as WEIXIN_PLATFORM,d as WeChatChannelConfigSchema,va as WeChatPlugin,e as WebChatChannelConfigSchema,Ta as WebChatPlugin,Sa as WeixinPlugin,z as clearConfigCache,ba as convertToGatewayMessage,Wa as createChannelPlugin,da as createDefaultSessionState,$ as createGatewayMessage,aa as createTextMessage,za as ensureContact,Aa as ensureSession,Ba as ensureUser,ca as generateSessionId,ea as generateSubscriptionId,W as getAgentAdapter,G as getAgentRegistryConfig,L as getAuthConfig,C as getChannelConfig,F as getCircuitBreakerConfig,M as getClusterConfig,x as getConfig,A as getConfigDirectory,D as getConnectionPoolConfig,N as getDefaultAgent,I as getGatewayClientConfig,J as getGatewayClientUrl,K as getHTTPSConfig,O as getLogLevel,E as getMessageQueueConfig,B as getServerConfig,H as getSessionConfig,Ya as getSupportedPlatforms,X as hasAgentAdapter,y as isConfigLoaded,Da as listWeixinContacts,w as loadConfig,v as parsePartialConfig,Ca as removeUser,Y as requireAgentAdapter,V as setAgentAdapter,u as validateConfig,Ga as weixinSetStateDir}from'./chunks/chunk-VEA6YZG4.mjs';import {a}from'./chunks/chunk-7OFQ65NG.mjs';import {a as a$1}from'./chunks/chunk-HAMGVOQD.mjs';import {Fetch}from'@easbot/utils';import {toString}from'qrcode';import {existsSync}from'fs';import {Server}from'@modelcontextprotocol/sdk/server/index.js';import {StdioServerTransport}from'@modelcontextprotocol/sdk/server/stdio.js';import {ListToolsRequestSchema,CallToolRequestSchema}from'@modelcontextprotocol/sdk/types.js';var d=a.create({service:"gateway"}),w=class e extends Error{constructor(t,n,o){super(t);a$1(this,"type");a$1(this,"stage");a$1(this,"cause");this.type="GatewayInitializationError",this.stage=n,this.cause=o,Error.captureStackTrace&&Error.captureStackTrace(this,e);}};function se(e){let r=["ECONNRESET","EPIPE","ETIMEDOUT","ECONNREFUSED","ENOTFOUND","EHOSTUNREACH","ENETUNREACH"],t=e.code;return r.includes(t??"")}function Nt(){process.on("unhandledRejection",e=>{let r=e instanceof Error?e:new Error(String(e));se(r)||d.error("unhandled promise rejection",{error:r.message,stack:r.stack});}),process.on("uncaughtException",e=>{se(e)||(d.error("uncaught exception",{error:e.message,stack:e.stack}),process.exit(1));});}var K;(tr=>{let e={initialized:false,initPromise:null,directory:".easbot",config:null},r,t={server:null,config:null,initialized:false,status:"stopped"};async function n(l={}){if(e.initialized)return;if(e.initPromise)return e.initPromise;let g={directory:l.directory??".easbot",printLogs:l.printLogs??false,logLevel:l.logLevel??"INFO"};return e.directory=g.directory,e.initPromise=(async()=>{let T=Z();try{await a.init({logDir:T.Path.log,print:g.printLogs,level:g.logLevel});}catch(a){throw new w("Failed to initialize log infrastructure","log",a instanceof Error?a:void 0)}try{Nt();}catch(a){throw new w("Failed to install unhandled exception handlers","server",a instanceof Error?a:void 0)}Fetch.hasProxyConfigured()&&(Fetch.enableProxy({connectTimeout:1e4,keepAliveTimeout:3e4}),d.info("global proxy enabled",{proxyUrl:Fetch.getProxyUrl()}));try{e.config=await w$1(g.directory);}catch(a){throw new w("Failed to load gateway configuration","config",a instanceof Error?a:void 0)}e.initialized=true,d.info("gateway runtime initialized",{directory:g.directory,logLevel:g.logLevel});})(),e.initPromise}tr.init=n;function o(){return e.initialized}tr.isInitialized=o;function c(){return r||(r=async()=>{if(!e.initialized)throw new w("Gateway not initialized. Call init() first.","server");let l=_(),g=await w$1(l.directory);return g.server?.enabled?(t={server:null,config:g,initialized:true,status:"stopped"},d.info("gateway initialized",{port:g.server?.port,hostname:g.server?.hostname}),t):(d.debug("gateway server disabled or not configured"),{server:null,config:g,initialized:true,status:"stopped"})}),r}function u(){return c()()}tr.state=u;async function C(){return (await u()).server}tr.get=C;async function i(){return (await u()).config?.server?.enabled??false}tr.isEnabled=i;async function f(){return (await u()).config}tr.config=f;function p(){return t.status}tr.getStatus=p;async function s(l){d.debug("Gateway.start: called"),e.initialized||await n();let g=await u();if(!(g.config?.server?.enabled??true))throw d.warn("gateway server is disabled"),new Error("Gateway server is disabled");if(t.status==="running"){d.info("gateway server is already running");return}if(t.status==="starting"){d.info("gateway server is starting");return}t.status="starting";try{let a={...g.config?.server,...l};d.debug("gateway start: creating server with config",{port:a.port,hostname:a.hostname,path:a.path,https:a.https?.enabled});let I=await ce(a);t.server=I,t.status="running",t.error=void 0,d.info("gateway server started",{port:a.port,hostname:a.hostname});}catch(a){throw t.status="error",t.error=a instanceof Error?a.message:String(a),d.error("failed to start gateway server",{error:t.error}),a}}tr.start=s;async function m(){if(t.status==="stopped"){d.info("gateway server is already stopped");return}if(t.status==="stopping"){d.info("gateway server is stopping");return}t.status="stopping";try{t.server&&await t.server.stop(),t.server=null,t.status="stopped",t.error=void 0,await a.close(),d.info("gateway server stopped");}catch(l){throw t.status="error",t.error=l instanceof Error?l.message:String(l),d.error("failed to stop gateway server",{error:t.error}),l}}tr.stop=m;async function h(l){d.info("restarting gateway server"),(t.status==="running"||t.status==="starting")&&await m(),await s(l);}tr.restart=h;async function J(){let l=_(),g=await w$1(l.directory);return t.config=g,e.config=g,d.info("gateway config reloaded"),g}tr.reloadConfig=J;async function ce(l,g){d.debug("createGatewayServer: starting");let{GatewayServer:T}=await import('./chunks/server-OGBOUOJL.mjs'),a=new T(l),I=g?.startupTimeout??3e4;if(await(async()=>{let v=new Promise((x,le)=>{setTimeout(()=>{le(new Error(`Gateway server startup timeout after ${I}ms`));},I);});try{await Promise.race([a.start(),v]);}catch(x){d.error("gateway server start failed, attempting cleanup",{error:x instanceof Error?x.message:String(x)});try{await a.stop();}catch{}throw x}})(),g?.onStarted)try{await g.onStarted(a);}catch(v){d.warn("server started but onStarted callback failed",{error:v instanceof Error?v.message:String(v)});}return d.info("gateway server created and started",{port:l.port,hostname:l.hostname}),a}tr.createGatewayServer=ce;})(K||(K={}));async function Wt(e){let r=await toString(e,{type:"terminal",errorCorrectionLevel:"L",small:true});process.stderr.write(`${r}
|
|
2
|
+
`);}async function D(e){let r=await fetch(`${e}/ilink/bot/get_bot_qrcode?bot_type=3`);if(!r.ok)throw new Error(`Failed to get QR code: HTTP ${r.status}`);let t=await r.json();if(!t.qrcode)throw new Error("No qrcode in response");let n=t.qrcode_img_content||"";return n&&await Wt(n),{qrcodeUrl:n,qrcodeId:t.qrcode,message:"Scan the QR code with WeChat to connect."}}async function Y(e){let{qrcodeId:r,apiBaseUrl:t,timeoutMs:n=48e4,maxRetries:o=3}=e,c=Date.now()+n,u=r,C=0;for(;Date.now()<c;){try{let i=new AbortController,f=setTimeout(()=>i.abort(),6e4),p=await fetch(`${t}/ilink/bot/get_qrcode_status?qrcode=${encodeURIComponent(u)}`,{headers:{"iLink-App-ClientVersion":"1"},signal:i.signal});if(clearTimeout(f),!p.ok)throw new Error(`HTTP ${p.status}`);let s=await p.json();switch(s.status){case "confirmed":return {connected:!0,token:s.bot_token,accountId:s.ilink_bot_id,baseUrl:s.baseurl,userId:s.ilink_user_id,message:"Connected to WeChat successfully!"};case "scaned":process.stderr.write(`QR code scanned, waiting for confirmation...
|
|
3
|
+
`);break;case "expired":{if(C+=1,C>=o)return {connected:!1,message:"QR code expired after maximum retries."};process.stderr.write(`QR code expired, refreshing...
|
|
4
|
+
`),u=(await D(t)).qrcodeId;break}case "wait":process.stderr.write(`QR code waiting, please wait...
|
|
5
|
+
`);break;default:break}}catch(i){if(i instanceof Error&&i.name==="AbortError")continue;throw i}await new Promise(i=>setTimeout(i,1e3));}return {connected:false,message:"Login timed out."}}function Qt(e){return ["Claude Code needs your approval.","",`Tool: ${e.tool_name}`,`Reason: ${e.description}`,`Input: ${e.input_preview}`,"",`Reply with: yes ${e.request_id}`,`Or deny with: no ${e.request_id}`].join(`
|
|
6
|
+
`)}function jt(e){let r=new Server({name:"weixin",version:e},{capabilities:{experimental:{"claude/channel":{},"claude/channel/permission":{}},tools:{}},instructions:'Messages from WeChat arrive as <channel source="plugin:weixin:weixin" chat_id="..." sender_id="...">. Reply using the reply tool with the chat_id from the channel tag. Use absolute paths for file attachments.'});return r.setRequestHandler(ListToolsRequestSchema,async()=>({tools:[{name:"reply",description:"Reply to a WeChat message. Pass the chat_id from the channel tag.",inputSchema:{type:"object",properties:{chat_id:{type:"string",description:"The chat_id from the channel notification"},text:{type:"string",description:"The reply text"},files:{type:"array",items:{type:"string"},description:"Optional absolute file paths to attach"}},required:["chat_id","text"]}},{name:"send_typing",description:"Send a typing indicator to a WeChat user.",inputSchema:{type:"object",properties:{chat_id:{type:"string",description:"The chat_id (user ID)"}},required:["chat_id"]}}]})),r.setRequestHandler(CallToolRequestSchema,async t=>{let{name:n,arguments:o}=t.params,c=Ha();if(!c)return {content:[{type:"text",text:"WeChat not connected. Run `easbot weixin login` first."}],isError:true};let u=c.baseUrl||Ea,C=Fa;switch(n){case "reply":{let i=typeof o?.chat_id=="string"?o.chat_id:"",f=typeof o?.text=="string"?o.text:"",p=Array.isArray(o?.files)?o.files.filter(m=>typeof m=="string"):void 0;if(!i||!f)return {content:[{type:"text",text:"Missing chat_id or text parameter."}],isError:true};let s=Qa(i)||"";try{if(p&&p.length>0){for(let[m,h]of p.entries()){if(!existsSync(h))return {content:[{type:"text",text:`File not found: ${h}`}],isError:!0};await Pa({filePath:h,to:i,text:m===0?f:"",baseUrl:u,token:c.token,contextToken:s,cdnBaseUrl:C});}return {content:[{type:"text",text:"Message sent with attachments."}]}}return await Oa({to:i,text:f,baseUrl:u,token:c.token,contextToken:s}),{content:[{type:"text",text:"Message sent."}]}}catch(m){return {content:[{type:"text",text:`Failed to send: ${m}`}],isError:true}}}case "send_typing":{let i=typeof o?.chat_id=="string"?o.chat_id:"";if(!i)return {content:[{type:"text",text:"Missing chat_id parameter."}],isError:true};try{let f=Qa(i),p=await Ka(u,c.token,i,f);return p.typing_ticket&&await La(u,c.token,{ilink_user_id:i,typing_ticket:p.typing_ticket,status:Ma.TYPING}),{content:[{type:"text",text:"Typing indicator sent."}]}}catch(f){return {content:[{type:"text",text:`Failed to send typing: ${f}`}],isError:true}}}default:return {content:[{type:"text",text:`Unknown tool: ${n}`}],isError:true}}}),r}async function ie(e,r){r.enableConfigs(),r.initializeAnalyticsSink();let t=Ha();t||(process.stderr.write("[weixin] No account configured. Run `easbot weixin login` to connect your WeChat account.\n"),await Promise.all([r.shutdown1PEventLogging(),r.shutdownDatadog()]),process.exit(1));let n=jt(e),o=new StdioServerTransport;r.registerPermissionHandler(n,async s=>{let m=s.channel_context?.chat_id,h=m?{chatId:m,contextToken:Qa(m)}:b();if(!h){r.logForDebugging(`[Weixin MCP] No active chat available for permission request ${s.request_id}`);return}try{c(s,h.chatId,h.contextToken),await Oa({to:h.chatId,text:Qt(s),baseUrl:c$1,token:t.token,contextToken:h.contextToken||""});}catch(J){process.stderr.write(`[weixin] Failed to relay permission request ${s.request_id}: ${J}
|
|
7
|
+
`);}}),await n.connect(o);let c$1=t.baseUrl||Ea,u=new AbortController,C=false,i=async()=>{C||(C=true,u.signal.aborted||u.abort(),await Promise.all([r.shutdown1PEventLogging(),r.shutdownDatadog()]),process.exit(0));};process.stdin.on("end",()=>{i();}),process.stdin.on("error",()=>{i();}),process.on("SIGINT",()=>{i();}),process.on("SIGTERM",()=>{i();}),process.on("SIGHUP",()=>{i();});let f=process.ppid,p=setInterval(()=>{try{process.kill(f,0);}catch{process.stderr.write(`[weixin] Parent process exited, shutting down...
|
|
8
|
+
`),clearInterval(p),i();}},5e3);r.logForDebugging("[Weixin MCP] Starting poll loop"),await Ra({baseUrl:c$1,cdnBaseUrl:Fa,token:t.token,onMessage:async s=>{await n.notification({method:"notifications/claude/channel",params:{content:s.text,meta:{chat_id:s.fromUserId,sender_id:s.fromUserId,message_id:s.messageId,...s.attachmentPath&&{attachment_path:s.attachmentPath},...s.attachmentType&&{attachment_type:s.attachmentType}}}});},onPermissionResponse:async s=>{await n.notification({method:"notifications/claude/channel/permission",params:{request_id:s.requestId,behavior:s.behavior}});},abortSignal:u.signal}),clearInterval(p),await i();}function ae(){process.stdout.write(["Usage:"," easbot weixin serve"," easbot weixin login"," easbot weixin login clear"," easbot weixin access pair <code>","","User routing:",' easbot weixin ensure-user <userId> [--display-name "<name>"] [--username "<u>"] [--channel-id <id>]'," easbot weixin list-users"," easbot weixin remove-user <userId> [--channel-id <id>]"].join(`
|
|
9
|
+
`)+`
|
|
10
|
+
`);}async function Vt(e=false){if(e){Ja(),process.stdout.write(`WeChat account cleared.
|
|
11
|
+
`);return}let r=Ha();if(r){process.stdout.write(["Already connected:",` User ID: ${r.userId||"unknown"}`,` Connected since: ${r.savedAt}`,"","Run `easbot weixin login clear` to disconnect."].join(`
|
|
12
|
+
`)+`
|
|
13
|
+
`);return}process.stdout.write(`Starting WeChat QR login...
|
|
14
|
+
|
|
15
|
+
`);let t=await D(Ea);process.stdout.write(`
|
|
16
|
+
Scan the QR code above with WeChat, or open this URL:
|
|
17
|
+
${t.qrcodeUrl||""}
|
|
18
|
+
|
|
19
|
+
`);let n=await Y({qrcodeId:t.qrcodeId,apiBaseUrl:Ea});(!n.connected||!n.token)&&(process.stderr.write(`Login failed: ${n.message}
|
|
20
|
+
`),process.exit(1)),Ia({token:n.token,baseUrl:n.baseUrl||Ea,userId:n.userId,savedAt:new Date().toISOString()}),process.stdout.write(["Connected successfully!",` User ID: ${n.userId||"unknown"}`,` Base URL: ${n.baseUrl||Ea}`].join(`
|
|
21
|
+
`)+`
|
|
22
|
+
`);}function Kt(e){(e[0]!=="pair"||!e[1])&&(ae(),process.exit(1));let r=Na(e[1]);r||(process.stderr.write(`Invalid or expired pairing code.
|
|
23
|
+
`),process.exit(1)),process.stdout.write(`Paired successfully: ${r}
|
|
24
|
+
`);}function Yt(e){if(e.length===0)return 'Usage: easbot weixin ensure-user <userId> [--display-name "<name>"] [--username "<u>"] [--channel-id <id>]';let r=e[0];if(!r)return "userId is required";let t={userId:r};for(let n=1;n<e.length;n++){let o=e[n];if(o==="--display-name"||o==="-d"){let c=e[++n];if(!c)return "--display-name requires a value";t.displayName=c;}else if(o==="--username"||o==="-u"){let c=e[++n];if(!c)return "--username requires a value";t.username=c;}else if(o==="--channel-id"||o==="-c"){let c=e[++n];if(!c)return "--channel-id requires a value";t.channelId=c;}}return t}function Jt(e){let r=Yt(e);typeof r=="string"&&(process.stderr.write(`${r}
|
|
25
|
+
`),process.exit(1)),Ba(r).then(t=>{let{contact:n,session:o,created:c}=t,u=c.contact&&c.session?"\u5DF2\u521B\u5EFA":"\u5DF2\u5B58\u5728\uFF08\u5DF2\u66F4\u65B0\uFF09";process.stdout.write([`[weixin routing] ${u} user: ${r.userId}`,` contact.uid: ${n.uid}`,` contact.path: ${xa()}/contacts/${n.platform}/${n.stableId}.json`,` session.id: ${o.id}`,` session.path: ${ya()}/sessions.json`,` profile: ${JSON.stringify(n.profile)}`].join(`
|
|
26
|
+
`)+`
|
|
27
|
+
`);}).catch(t=>{process.stderr.write(`ensure-user failed: ${t}
|
|
28
|
+
`),process.exit(1);});}function Xt(){Da().then(e=>{if(e.length===0){process.stdout.write(`No weixin users registered.
|
|
29
|
+
`),process.stdout.write("Use `easbot weixin ensure-user <userId>` to add one.\n");return}process.stdout.write(`weixin users (${e.length}):
|
|
30
|
+
`);for(let r of e){let t=r.profile.displayName??r.profile.username??"(no name)";process.stdout.write(` - ${r.stableId} ${t} lastSeen=${new Date(r.lastSeenAt).toISOString()}
|
|
31
|
+
`);}}).catch(e=>{process.stderr.write(`list-users failed: ${e}
|
|
32
|
+
`),process.exit(1);});}function Zt(e){e.length===0&&(process.stderr.write(`Usage: easbot weixin remove-user <userId> [--channel-id <id>]
|
|
33
|
+
`),process.exit(1));let r=e[0];r||(process.stderr.write(`userId is required
|
|
34
|
+
`),process.exit(1));let t="weixin-main";for(let n=1;n<e.length;n++)(e[n]==="--channel-id"||e[n]==="-c")&&(t=e[++n]??t);Ca(r,t).then(n=>{process.stdout.write(`[weixin routing] removed user: ${r} contact=${n.removed.contact} session=${n.removed.session}
|
|
35
|
+
`);}).catch(n=>{process.stderr.write(`remove-user failed: ${n}
|
|
36
|
+
`),process.exit(1);});}async function er(e,r,t){let[n,...o]=e;switch(n){case "serve":r||(process.stderr.write(`[weixin] serve handler not available in this context.
|
|
37
|
+
`),process.exit(1)),await ie(t??"0.0.0",r);return;case "login":await Vt(o[0]==="clear");return;case "access":Kt(o);return;case "ensure-user":Jt(o);return;case "list-users":Xt();return;case "remove-user":Zt(o);return;default:ae();}}async function pn(e){let{Log:r}=await import('./chunks/log-MIT4H7S5.mjs'),t=false;await r.init({logDir:e.logDir??process.env.EASBOT_LOG_PATH??process.cwd(),print:e.print??false,dev:e.dev??t,level:e.level??("INFO")});}export{K as Gateway,er as handleWeixinCli,pn as initLog};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@easbot/gateway",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.47",
|
|
4
4
|
"description": "EASBot Gateway - AI Agent Server and Multi-channel Integration Platform - 支持 WebSocket、HTTP、Discord、Telegram、Slack 等多渠道集成",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -48,6 +48,7 @@
|
|
|
48
48
|
"LICENSE"
|
|
49
49
|
],
|
|
50
50
|
"dependencies": {
|
|
51
|
+
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
51
52
|
"@ai-sdk/anthropic": "^3.0.76",
|
|
52
53
|
"@ai-sdk/openai-compatible": "^2.0.47",
|
|
53
54
|
"@ai-sdk/provider": "^3.0.10",
|
|
@@ -59,6 +60,7 @@
|
|
|
59
60
|
"ai": "^6.0.176",
|
|
60
61
|
"better-sqlite3": "^12.9.0",
|
|
61
62
|
"commander": "^14.0.3",
|
|
63
|
+
"qrcode": "^1.5.4",
|
|
62
64
|
"hono": "^4.12.18",
|
|
63
65
|
"hono-openapi": "^1.3.0",
|
|
64
66
|
"jieba-wasm": "^2.4.0",
|
|
@@ -67,12 +69,13 @@
|
|
|
67
69
|
"ws": "^8.20.0",
|
|
68
70
|
"xdg-basedir": "^5.1.0",
|
|
69
71
|
"zod": "^4.4.3",
|
|
70
|
-
"@easbot/sdk": "0.2.
|
|
71
|
-
"@easbot/plugin": "0.2.
|
|
72
|
-
"@easbot/types": "0.2.
|
|
73
|
-
"@easbot/utils": "0.2.
|
|
72
|
+
"@easbot/sdk": "0.2.47",
|
|
73
|
+
"@easbot/plugin": "0.2.47",
|
|
74
|
+
"@easbot/types": "0.2.47",
|
|
75
|
+
"@easbot/utils": "0.2.47"
|
|
74
76
|
},
|
|
75
77
|
"devDependencies": {
|
|
78
|
+
"@types/qrcode": "^1.5.6",
|
|
76
79
|
"@biomejs/biome": "^2.4.14",
|
|
77
80
|
"@types/better-sqlite3": "^7.6.13",
|
|
78
81
|
"@types/node": "^25.6.2",
|