@elizaos/plugin-wechat 2.0.3-beta.6 → 2.0.3-beta.7
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/bot.d.ts +21 -0
- package/dist/callback-server.d.ts +16 -0
- package/dist/channel.d.ts +35 -0
- package/dist/connector-account-provider.d.ts +14 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.js +1304 -0
- package/dist/index.js.map +1 -0
- package/dist/proxy-client.d.ts +34 -0
- package/dist/reply-dispatcher.d.ts +13 -0
- package/dist/runtime-bridge.d.ts +8 -0
- package/dist/types.d.ts +64 -0
- package/dist/utils/qrcode.d.ts +6 -0
- package/package.json +4 -4
package/dist/bot.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { WechatMessageContext } from "./types";
|
|
2
|
+
export interface BotOptions {
|
|
3
|
+
onMessage: (msg: WechatMessageContext) => void | Promise<void>;
|
|
4
|
+
featuresGroups?: boolean;
|
|
5
|
+
featuresImages?: boolean;
|
|
6
|
+
/** Deduplication window in milliseconds. Defaults to 30 minutes. */
|
|
7
|
+
dedupWindowMs?: number;
|
|
8
|
+
}
|
|
9
|
+
export declare class Bot {
|
|
10
|
+
private readonly seen;
|
|
11
|
+
private readonly onMessage;
|
|
12
|
+
private readonly featuresGroups;
|
|
13
|
+
private readonly featuresImages;
|
|
14
|
+
private readonly dedupWindowMs;
|
|
15
|
+
private cleanupTimer;
|
|
16
|
+
constructor(options: BotOptions);
|
|
17
|
+
handleIncoming(message: WechatMessageContext): void;
|
|
18
|
+
private isDuplicate;
|
|
19
|
+
private cleanup;
|
|
20
|
+
stop(): void;
|
|
21
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { WechatMessageContext } from "./types";
|
|
2
|
+
export interface CallbackServerOptions {
|
|
3
|
+
port: number;
|
|
4
|
+
accounts: Array<{
|
|
5
|
+
accountId: string;
|
|
6
|
+
apiKey: string;
|
|
7
|
+
}>;
|
|
8
|
+
onMessage: (accountId: string, msg: WechatMessageContext) => void;
|
|
9
|
+
signal?: AbortSignal;
|
|
10
|
+
maxBodyBytes?: number;
|
|
11
|
+
}
|
|
12
|
+
export declare function startCallbackServer(options: CallbackServerOptions): Promise<{
|
|
13
|
+
close: () => Promise<void>;
|
|
14
|
+
port: number;
|
|
15
|
+
}>;
|
|
16
|
+
export declare function normalizePayload(payload: Record<string, unknown>): WechatMessageContext | null;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { WechatConfig, WechatMessageContext } from "./types";
|
|
2
|
+
export interface ChannelOptions {
|
|
3
|
+
config: WechatConfig;
|
|
4
|
+
onMessage: (accountId: string, msg: WechatMessageContext) => void | Promise<void>;
|
|
5
|
+
}
|
|
6
|
+
export declare class WechatChannel {
|
|
7
|
+
private readonly config;
|
|
8
|
+
private readonly onMessage;
|
|
9
|
+
private readonly accounts;
|
|
10
|
+
private readonly callbackServers;
|
|
11
|
+
private readonly loginPromises;
|
|
12
|
+
private healthTimer;
|
|
13
|
+
private abortController;
|
|
14
|
+
constructor(options: ChannelOptions);
|
|
15
|
+
start(): Promise<void>;
|
|
16
|
+
stop(): Promise<void>;
|
|
17
|
+
sendText(accountId: string, to: string, text: string): Promise<void>;
|
|
18
|
+
sendImage(accountId: string, to: string, imagePath: string, caption?: string): Promise<void>;
|
|
19
|
+
getAccountIds(): string[];
|
|
20
|
+
listContacts(accountId: string): Promise<{
|
|
21
|
+
friends: Array<{
|
|
22
|
+
wxid: string;
|
|
23
|
+
name: string;
|
|
24
|
+
}>;
|
|
25
|
+
chatrooms: Array<{
|
|
26
|
+
wxid: string;
|
|
27
|
+
name: string;
|
|
28
|
+
}>;
|
|
29
|
+
}>;
|
|
30
|
+
private routeIncoming;
|
|
31
|
+
private ensureLoggedIn;
|
|
32
|
+
private doLogin;
|
|
33
|
+
private healthCheck;
|
|
34
|
+
private resolveAccounts;
|
|
35
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WeChat ConnectorAccountManager provider.
|
|
3
|
+
*
|
|
4
|
+
* Adapts the multi-account scaffolding (`WechatConfig.accounts`) to the
|
|
5
|
+
* `ConnectorAccountProvider` contract from
|
|
6
|
+
* `@elizaos/core/connectors/account-manager`.
|
|
7
|
+
*
|
|
8
|
+
* Source of truth is the wechat config block (proxy URL + API key per account).
|
|
9
|
+
* AccountKey is the proxy account id (the key in `WechatConfig.accounts`) or
|
|
10
|
+
* `default` for single-account env-only deployments. Role is `AGENT` since
|
|
11
|
+
* wechat proxy creds authenticate the bot, not the user.
|
|
12
|
+
*/
|
|
13
|
+
import type { ConnectorAccountProvider, IAgentRuntime } from "@elizaos/core";
|
|
14
|
+
export declare function createWechatConnectorAccountProvider(runtime: IAgentRuntime): ConnectorAccountProvider;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { WechatConfig } from "./types";
|
|
2
|
+
export declare const WECHAT_PLUGIN_PACKAGE: "@elizaos/plugin-wechat";
|
|
3
|
+
export declare function isWechatConnectorConfigured(config: WechatConfig | Record<string, unknown> | null | undefined): boolean;
|
|
4
|
+
export interface Plugin {
|
|
5
|
+
name: string;
|
|
6
|
+
description: string;
|
|
7
|
+
init?: (config: Record<string, unknown>, runtime: unknown) => Promise<void | (() => Promise<void>)>;
|
|
8
|
+
dispose?: () => Promise<void> | void;
|
|
9
|
+
/**
|
|
10
|
+
* Declarative auto-enable conditions consumed by the runtime's
|
|
11
|
+
* plugin-auto-enable engine. Mirrors the shape on `@elizaos/core` Plugin.
|
|
12
|
+
*/
|
|
13
|
+
autoEnable?: {
|
|
14
|
+
envKeys?: string[];
|
|
15
|
+
connectorKeys?: string[];
|
|
16
|
+
shouldEnable?: (env: Record<string, string | undefined>, config: Record<string, unknown>) => boolean;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
declare const wechatPlugin: Plugin;
|
|
20
|
+
export default wechatPlugin;
|
|
21
|
+
export { Bot } from "./bot";
|
|
22
|
+
export { WechatChannel } from "./channel";
|
|
23
|
+
export { ProxyClient } from "./proxy-client";
|
|
24
|
+
export { ReplyDispatcher } from "./reply-dispatcher";
|
|
25
|
+
export { deliverIncomingWechatMessage } from "./runtime-bridge";
|
|
26
|
+
export type { WechatConfig, WechatMessageContext } from "./types";
|
|
27
|
+
export { wechatPlugin };
|