@wps365/openclaw-wpsxiezuo 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +335 -0
- package/README_ZH-CN.md +318 -0
- package/bin/cli.mjs +677 -0
- package/dist/channel/event-crypto.d.ts +19 -0
- package/dist/channel/event-handlers.d.ts +61 -0
- package/dist/channel/event-types.d.ts +88 -0
- package/dist/channel/index.d.ts +8 -0
- package/dist/channel/plugin.d.ts +11 -0
- package/dist/channel/register-tool-bridge.d.ts +14 -0
- package/dist/channel/sdk-client-options.d.ts +24 -0
- package/dist/channel/sdk-helpers.d.ts +12 -0
- package/dist/channel/sdk-provider.d.ts +23 -0
- package/dist/channel/types.d.ts +324 -0
- package/dist/core/config.d.ts +267 -0
- package/dist/core/errors.d.ts +36 -0
- package/dist/core/index.d.ts +18 -0
- package/dist/core/lazy-client-store.d.ts +28 -0
- package/dist/core/media-utils.d.ts +27 -0
- package/dist/core/reaction.d.ts +29 -0
- package/dist/core/token-store.d.ts +34 -0
- package/dist/core/user-token-store.d.ts +35 -0
- package/dist/core/wps-client.d.ts +42 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.js +33 -0
- package/dist/messaging/handler.d.ts +73 -0
- package/dist/messaging/inbound/content-parser.d.ts +17 -0
- package/dist/messaging/inbound/handler.d.ts +44 -0
- package/dist/messaging/inbound/index.d.ts +5 -0
- package/dist/messaging/inbound/media-prefetch.d.ts +43 -0
- package/dist/messaging/inbound/pairing-allow-store.d.ts +11 -0
- package/dist/messaging/index.d.ts +3 -0
- package/dist/messaging/outbound.d.ts +15 -0
- package/dist/session/idempotency.d.ts +8 -0
- package/dist/session/index.d.ts +5 -0
- package/dist/session/resolver.d.ts +17 -0
- package/dist/session/types.d.ts +37 -0
- package/dist/tools/oapi/calendar.d.ts +106 -0
- package/dist/tools/oapi/chat.d.ts +10 -0
- package/dist/tools/oapi/delegated-auth.d.ts +14 -0
- package/dist/tools/oapi/drive.d.ts +112 -0
- package/dist/tools/oapi/index.d.ts +24 -0
- package/dist/tools/oapi/media.d.ts +32 -0
- package/dist/tools/oapi/messaging.d.ts +10 -0
- package/dist/tools/oapi/todo.d.ts +96 -0
- package/dist/tools/oapi/user.d.ts +10 -0
- package/dist/tools/oauth/index.d.ts +65 -0
- package/openclaw.plugin.json +154 -0
- package/package.json +91 -0
- package/scripts/upgrade.sh +37 -0
- package/skills/wps-auth-provider.md +63 -0
- package/skills/wps-calendar/SKILL.md +147 -0
- package/skills/wps-channel-rules/SKILL.md +50 -0
- package/skills/wps-chat/SKILL.md +106 -0
- package/skills/wps-drive/SKILL.md +79 -0
- package/skills/wps-im-read/SKILL.md +88 -0
- package/skills/wps-im-send/SKILL.md +183 -0
- package/skills/wps-media/SKILL.md +101 -0
- package/skills/wps-message-handler.md +48 -0
- package/skills/wps-todo/SKILL.md +65 -0
- package/skills/wps-user/SKILL.md +105 -0
- package/skills/wps-xiezuo-session-mapper.md +62 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WPS 入站事件处理 — Webhook HTTP + SDK 长连接双模式。
|
|
3
|
+
*
|
|
4
|
+
* 对标飞书 src/channel/event-handlers.ts:
|
|
5
|
+
* - Webhook: Express POST → challenge / 加解密 / 分发
|
|
6
|
+
* - SDK: open-event-sdk 映射为统一 WpsEventPayload
|
|
7
|
+
*
|
|
8
|
+
* 不包含业务逻辑(session / routing / reply),仅做事件基础设施。
|
|
9
|
+
*/
|
|
10
|
+
import type { WpsEventPayload } from "./event-types.js";
|
|
11
|
+
import type { LogFacade } from "./types.js";
|
|
12
|
+
export declare function shouldSkipNonMessageTopic(topic: unknown): boolean;
|
|
13
|
+
type SdkMessageData = {
|
|
14
|
+
chat: {
|
|
15
|
+
id: string;
|
|
16
|
+
type: string;
|
|
17
|
+
};
|
|
18
|
+
message: {
|
|
19
|
+
id: string;
|
|
20
|
+
type: string;
|
|
21
|
+
content: unknown;
|
|
22
|
+
quote_msg_id?: string;
|
|
23
|
+
mentions?: unknown;
|
|
24
|
+
reply_to?: unknown;
|
|
25
|
+
};
|
|
26
|
+
sender: {
|
|
27
|
+
id: string;
|
|
28
|
+
type: string;
|
|
29
|
+
extended_attribute?: {
|
|
30
|
+
name?: string;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
send_time: number;
|
|
34
|
+
quote_msg_id?: string;
|
|
35
|
+
};
|
|
36
|
+
export declare function buildMessageContent(msg: SdkMessageData["message"]): Record<string, unknown>;
|
|
37
|
+
export declare function extractRichTextContent(richText: unknown): string[];
|
|
38
|
+
/** 将 open-event-sdk 消息事件转为统一 WpsEventPayload */
|
|
39
|
+
export declare function mapSdkMessageToPayload(data: SdkMessageData): WpsEventPayload;
|
|
40
|
+
export type WebhookDecryptResult = {
|
|
41
|
+
ok: true;
|
|
42
|
+
payload: WpsEventPayload;
|
|
43
|
+
} | {
|
|
44
|
+
ok: false;
|
|
45
|
+
error: string;
|
|
46
|
+
status?: number;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* 处理单个 Webhook POST body:
|
|
50
|
+
* - challenge 验证 → 返回 { challenge }
|
|
51
|
+
* - 加密事件 → 签名校验 + 解密
|
|
52
|
+
* - 明文事件 → 直接透传
|
|
53
|
+
*/
|
|
54
|
+
export declare function processWebhookBody(body: unknown, creds: {
|
|
55
|
+
appId: string;
|
|
56
|
+
appSecret: string;
|
|
57
|
+
}, enableEncryption: boolean, log?: LogFacade): {
|
|
58
|
+
challenge: string;
|
|
59
|
+
} | WebhookDecryptResult;
|
|
60
|
+
export {};
|
|
61
|
+
//# sourceMappingURL=event-handlers.d.ts.map
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WPS 入站事件类型定义。
|
|
3
|
+
* 对标飞书 src/channel/event-types.ts。
|
|
4
|
+
*/
|
|
5
|
+
/** Webhook 解密后或 SDK 映射后的统一入站事件结构 */
|
|
6
|
+
export type WpsEventPayload = {
|
|
7
|
+
topic?: string;
|
|
8
|
+
event_id?: string;
|
|
9
|
+
company_id?: string;
|
|
10
|
+
chat?: {
|
|
11
|
+
id?: string;
|
|
12
|
+
type?: string;
|
|
13
|
+
};
|
|
14
|
+
message?: {
|
|
15
|
+
id?: string;
|
|
16
|
+
type?: string;
|
|
17
|
+
content?: Record<string, unknown>;
|
|
18
|
+
sender?: {
|
|
19
|
+
id?: string;
|
|
20
|
+
type?: string;
|
|
21
|
+
};
|
|
22
|
+
mentions?: Array<{
|
|
23
|
+
type?: string;
|
|
24
|
+
id?: string;
|
|
25
|
+
user_id?: string;
|
|
26
|
+
userId?: string;
|
|
27
|
+
open_id?: string;
|
|
28
|
+
offset?: number;
|
|
29
|
+
length?: number;
|
|
30
|
+
identity?: {
|
|
31
|
+
id?: string;
|
|
32
|
+
app_id?: string;
|
|
33
|
+
name?: string;
|
|
34
|
+
type?: string;
|
|
35
|
+
company_id?: string;
|
|
36
|
+
};
|
|
37
|
+
}>;
|
|
38
|
+
reply_to?: {
|
|
39
|
+
sender_id?: string;
|
|
40
|
+
sender?: {
|
|
41
|
+
id?: string;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
/** 引用回复场景下被引用消息的 id(SDK v7 notification 顶层 quote_msg_id 字段) */
|
|
46
|
+
quote_msg_id?: string;
|
|
47
|
+
sender?: {
|
|
48
|
+
id?: string;
|
|
49
|
+
type?: string;
|
|
50
|
+
name?: string;
|
|
51
|
+
};
|
|
52
|
+
send_time?: number;
|
|
53
|
+
};
|
|
54
|
+
/** Webhook 加密事件外壳 */
|
|
55
|
+
export type WpsEncryptedEvent = {
|
|
56
|
+
topic: string;
|
|
57
|
+
operation: string;
|
|
58
|
+
time: number;
|
|
59
|
+
nonce: string;
|
|
60
|
+
signature: string;
|
|
61
|
+
encrypted_data: string;
|
|
62
|
+
};
|
|
63
|
+
/** 入站消息附件元数据 */
|
|
64
|
+
export type InboundAttachmentMeta = {
|
|
65
|
+
kind: "image" | "file";
|
|
66
|
+
name?: string;
|
|
67
|
+
fileId?: string;
|
|
68
|
+
url?: string;
|
|
69
|
+
mimeType?: string;
|
|
70
|
+
size?: number;
|
|
71
|
+
storageKey?: string;
|
|
72
|
+
width?: number;
|
|
73
|
+
height?: number;
|
|
74
|
+
thumbnailStorageKey?: string;
|
|
75
|
+
/** WPS cloud file: type="cloud", has link_url but no storage_key */
|
|
76
|
+
cloudType?: boolean;
|
|
77
|
+
cloudLinkUrl?: string;
|
|
78
|
+
cloudLinkId?: string;
|
|
79
|
+
};
|
|
80
|
+
/** 归一化后的入站消息 */
|
|
81
|
+
export type NormalizedInboundMessage = {
|
|
82
|
+
kind: "text" | "image" | "file" | "rich_text" | "sticker" | "card" | "mixed" | "unknown";
|
|
83
|
+
plainText: string;
|
|
84
|
+
agentText: string;
|
|
85
|
+
attachments: InboundAttachmentMeta[];
|
|
86
|
+
};
|
|
87
|
+
export declare const MESSAGE_TOPIC = "kso.app_chat.message";
|
|
88
|
+
//# sourceMappingURL=event-types.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WPS ChannelPlugin 契约实现。
|
|
3
|
+
*
|
|
4
|
+
* 对标飞书 src/channel/plugin.ts:实现 ChannelPlugin 接口的全部能力面。
|
|
5
|
+
* 依赖方向:channel/ → core/(不反向)。
|
|
6
|
+
*/
|
|
7
|
+
import type { ChannelPlugin, ResolvedWpsAccount, PluginRuntime } from "./types.js";
|
|
8
|
+
export declare function setPluginRuntime(rt: PluginRuntime): void;
|
|
9
|
+
export declare function getPluginRuntime(): PluginRuntime;
|
|
10
|
+
export declare const wpsPlugin: ChannelPlugin<ResolvedWpsAccount>;
|
|
11
|
+
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 工具注册桥接模块。
|
|
3
|
+
*
|
|
4
|
+
* OpenClaw 的 api.registerTool 在 register() 阶段提供,
|
|
5
|
+
* 但需要在 startAccount() 阶段(gateway 完全启动后)才能有效注册工具。
|
|
6
|
+
* 此模块保存函数引用,供 startAccount() 延迟调用。
|
|
7
|
+
*/
|
|
8
|
+
type RegisterToolFn = (tool: unknown, opts?: {
|
|
9
|
+
name?: string;
|
|
10
|
+
}) => void;
|
|
11
|
+
export declare function setSavedRegisterTool(fn: RegisterToolFn): void;
|
|
12
|
+
export declare function getSavedRegisterTool(): RegisterToolFn | null;
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=register-tool-bridge.d.ts.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Dispatcher } from "open-event-sdk";
|
|
2
|
+
import type { WpsConfig } from "../core/config.js";
|
|
3
|
+
export type BaseSdkClientOptions = {
|
|
4
|
+
appId: string;
|
|
5
|
+
appSecret: string;
|
|
6
|
+
dispatcher: Dispatcher;
|
|
7
|
+
logLevel: number;
|
|
8
|
+
endpoint?: string;
|
|
9
|
+
};
|
|
10
|
+
export type ExtendedSdkClientOptions = BaseSdkClientOptions & {
|
|
11
|
+
pongTimeout: number;
|
|
12
|
+
autoReconnect: boolean;
|
|
13
|
+
reconnectBaseInterval: number;
|
|
14
|
+
reconnectMaxInterval: number;
|
|
15
|
+
reconnectMultiplier: number;
|
|
16
|
+
reconnectMaxRetry: number;
|
|
17
|
+
reconnectJitter: number;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Build client options with stable defaults so all SDK entry points share
|
|
21
|
+
* the same heartbeat and reconnect behavior.
|
|
22
|
+
*/
|
|
23
|
+
export declare function buildSdkClientOptions(base: BaseSdkClientOptions, sdkCfg?: WpsConfig["sdk"]): ExtendedSdkClientOptions;
|
|
24
|
+
//# sourceMappingURL=sdk-client-options.d.ts.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenClaw Plugin SDK 运行时辅助函数。
|
|
3
|
+
*
|
|
4
|
+
* SDK 由 OpenClaw 宿主在运行时提供,这里做安全加载和 fallback。
|
|
5
|
+
* 对标飞书 src/core/ 中的 sdk 辅助。
|
|
6
|
+
*/
|
|
7
|
+
export declare const SDK_DEFAULT_ACCOUNT_ID: string;
|
|
8
|
+
export declare function emptyPluginConfigSchema(): unknown;
|
|
9
|
+
export declare function buildChannelConfigSchema(schema: unknown): unknown;
|
|
10
|
+
export declare function formatPairingApproveHint(channel: string): string;
|
|
11
|
+
export declare function waitUntilAbort(signal: AbortSignal, onAbort: () => Promise<void>): Promise<void>;
|
|
12
|
+
//# sourceMappingURL=sdk-helpers.d.ts.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WPS SDK Provider - 管理 open-event-sdk 长连接生命周期
|
|
3
|
+
*
|
|
4
|
+
* 参考 openclaw-wps-xiezuo-helper/packages/channel-plugin/src/wps-sdk-provider.ts
|
|
5
|
+
* 实现 WebSocket 长连接的启动、状态检查和优雅关闭
|
|
6
|
+
*/
|
|
7
|
+
import { Dispatcher } from "open-event-sdk";
|
|
8
|
+
import type { WpsConfig } from "../core/config.js";
|
|
9
|
+
import type { OpenClawPluginApi } from "openclaw/plugin-sdk/core";
|
|
10
|
+
export type SdkProviderResult = {
|
|
11
|
+
shutdown: () => void;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* 启动 WPS 开放平台长连接(open-event-sdk)
|
|
15
|
+
* 连接在超时内未建立则抛出错误
|
|
16
|
+
*/
|
|
17
|
+
export declare function startSdkProvider(opts: {
|
|
18
|
+
config: WpsConfig;
|
|
19
|
+
api: OpenClawPluginApi;
|
|
20
|
+
dispatcher: Dispatcher;
|
|
21
|
+
abortSignal?: AbortSignal;
|
|
22
|
+
}): Promise<SdkProviderResult>;
|
|
23
|
+
//# sourceMappingURL=sdk-provider.d.ts.map
|
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenClaw Plugin SDK 类型定义。
|
|
3
|
+
*
|
|
4
|
+
* OpenClaw 在运行时注入 SDK,这里定义插件侧使用的契约类型。
|
|
5
|
+
* v1 中 plugin-sdk-types.ts 全部用 any,v2 给出结构化定义。
|
|
6
|
+
*/
|
|
7
|
+
export type OpenClawPluginApi = {
|
|
8
|
+
runtime: PluginRuntime;
|
|
9
|
+
logger?: {
|
|
10
|
+
info: (msg: string) => void;
|
|
11
|
+
warn: (msg: string) => void;
|
|
12
|
+
error: (msg: string) => void;
|
|
13
|
+
debug?: (msg: string) => void;
|
|
14
|
+
};
|
|
15
|
+
registerChannel: (opts: {
|
|
16
|
+
plugin: ChannelPlugin<unknown>;
|
|
17
|
+
}) => void;
|
|
18
|
+
registerTool?: (tool: unknown, opts?: {
|
|
19
|
+
name?: string;
|
|
20
|
+
}) => void;
|
|
21
|
+
on?: (hookName: string, handler: (...args: unknown[]) => unknown, opts?: {
|
|
22
|
+
priority?: number;
|
|
23
|
+
}) => void;
|
|
24
|
+
};
|
|
25
|
+
export type PluginRuntime = {
|
|
26
|
+
log?: LogFacade;
|
|
27
|
+
config?: Record<string, unknown>;
|
|
28
|
+
channel: {
|
|
29
|
+
text: {
|
|
30
|
+
chunkMarkdownText: (text: string, limit: number) => string[];
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
export type LogFacade = {
|
|
35
|
+
info?: (...args: unknown[]) => void;
|
|
36
|
+
warn?: (...args: unknown[]) => void;
|
|
37
|
+
error?: (...args: unknown[]) => void;
|
|
38
|
+
debug?: (...args: unknown[]) => void;
|
|
39
|
+
};
|
|
40
|
+
export type ToolRegistration = {
|
|
41
|
+
name: string;
|
|
42
|
+
description: string;
|
|
43
|
+
parameters: unknown;
|
|
44
|
+
execute: (id: string, params: Record<string, unknown>) => Promise<unknown>;
|
|
45
|
+
};
|
|
46
|
+
export type OpenClawConfig = Record<string, unknown> & {
|
|
47
|
+
channels?: Record<string, unknown>;
|
|
48
|
+
};
|
|
49
|
+
export type ChannelPlugin<TAccount = unknown> = {
|
|
50
|
+
id: string;
|
|
51
|
+
meta: ChannelMeta;
|
|
52
|
+
capabilities: ChannelCapabilities;
|
|
53
|
+
reload?: {
|
|
54
|
+
configPrefixes: string[];
|
|
55
|
+
};
|
|
56
|
+
configSchema?: unknown;
|
|
57
|
+
messaging: ChannelMessaging;
|
|
58
|
+
config: ChannelConfig<TAccount>;
|
|
59
|
+
security: ChannelSecurity;
|
|
60
|
+
pairing: ChannelPairing;
|
|
61
|
+
groups: ChannelGroups;
|
|
62
|
+
outbound: ChannelOutbound;
|
|
63
|
+
status: ChannelStatus<TAccount>;
|
|
64
|
+
gateway: ChannelGateway;
|
|
65
|
+
onboarding: ChannelOnboarding;
|
|
66
|
+
agentPrompt?: ChannelAgentPromptAdapter;
|
|
67
|
+
actions?: ChannelMessageActionAdapter;
|
|
68
|
+
};
|
|
69
|
+
export type ChannelMeta = {
|
|
70
|
+
id: string;
|
|
71
|
+
label: string;
|
|
72
|
+
selectionLabel: string;
|
|
73
|
+
docsPath: string;
|
|
74
|
+
docsLabel: string;
|
|
75
|
+
blurb: string;
|
|
76
|
+
aliases: string[];
|
|
77
|
+
order: number;
|
|
78
|
+
};
|
|
79
|
+
export type ChannelCapabilities = {
|
|
80
|
+
chatTypes: ("direct" | "group")[];
|
|
81
|
+
media: boolean;
|
|
82
|
+
threads: boolean;
|
|
83
|
+
nativeCommands: boolean;
|
|
84
|
+
blockStreaming: boolean;
|
|
85
|
+
};
|
|
86
|
+
export type ChannelMessaging = {
|
|
87
|
+
normalizeTarget: (raw: string) => string;
|
|
88
|
+
targetResolver: {
|
|
89
|
+
hint: string;
|
|
90
|
+
looksLikeId: (raw: string) => boolean;
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
export type ChannelConfig<TAccount> = {
|
|
94
|
+
listAccountIds: () => string[];
|
|
95
|
+
resolveAccount: (cfg: unknown) => TAccount;
|
|
96
|
+
defaultAccountId: () => string;
|
|
97
|
+
setAccountEnabled: (opts: {
|
|
98
|
+
cfg: unknown;
|
|
99
|
+
enabled: boolean;
|
|
100
|
+
}) => unknown;
|
|
101
|
+
deleteAccount: (opts: {
|
|
102
|
+
cfg: unknown;
|
|
103
|
+
}) => unknown;
|
|
104
|
+
isConfigured: (account: TAccount, cfg: unknown) => boolean;
|
|
105
|
+
describeAccount: (account: TAccount) => Record<string, unknown>;
|
|
106
|
+
resolveAllowFrom: (opts: {
|
|
107
|
+
cfg: unknown;
|
|
108
|
+
}) => string[];
|
|
109
|
+
formatAllowFrom: (opts: {
|
|
110
|
+
allowFrom: unknown[];
|
|
111
|
+
}) => string[];
|
|
112
|
+
};
|
|
113
|
+
export type ChannelSecurity = {
|
|
114
|
+
resolveDmPolicy: (opts: {
|
|
115
|
+
cfg: unknown;
|
|
116
|
+
}) => {
|
|
117
|
+
policy: string;
|
|
118
|
+
allowFrom: string[];
|
|
119
|
+
policyPath: string;
|
|
120
|
+
allowFromPath: string;
|
|
121
|
+
approveHint: string;
|
|
122
|
+
normalizeEntry: (entry: string) => string;
|
|
123
|
+
};
|
|
124
|
+
collectWarnings: (opts: {
|
|
125
|
+
cfg: unknown;
|
|
126
|
+
}) => string[];
|
|
127
|
+
};
|
|
128
|
+
export type ChannelPairing = {
|
|
129
|
+
idLabel: string;
|
|
130
|
+
normalizeAllowEntry: (entry: string) => string;
|
|
131
|
+
notifyApproval: (opts: {
|
|
132
|
+
cfg: unknown;
|
|
133
|
+
id: string;
|
|
134
|
+
}) => Promise<void>;
|
|
135
|
+
};
|
|
136
|
+
export type ChannelGroups = {
|
|
137
|
+
resolveRequireMention: (opts: {
|
|
138
|
+
cfg: unknown;
|
|
139
|
+
groupId?: string;
|
|
140
|
+
}) => boolean;
|
|
141
|
+
resolveToolPolicy: (opts: {
|
|
142
|
+
cfg: unknown;
|
|
143
|
+
groupId?: string;
|
|
144
|
+
}) => string | undefined;
|
|
145
|
+
};
|
|
146
|
+
export type ChannelOutbound = {
|
|
147
|
+
deliveryMode: "direct";
|
|
148
|
+
textChunkLimit: number;
|
|
149
|
+
chunker: (text: string, limit: number) => string[];
|
|
150
|
+
chunkerMode: string;
|
|
151
|
+
resolveTarget: (opts: {
|
|
152
|
+
to?: string;
|
|
153
|
+
allowFrom?: unknown[];
|
|
154
|
+
}) => {
|
|
155
|
+
ok: boolean;
|
|
156
|
+
to?: string;
|
|
157
|
+
error?: Error;
|
|
158
|
+
};
|
|
159
|
+
sendText: (opts: {
|
|
160
|
+
cfg: unknown;
|
|
161
|
+
to: string;
|
|
162
|
+
text: string;
|
|
163
|
+
}) => Promise<unknown>;
|
|
164
|
+
sendMedia: (opts: {
|
|
165
|
+
cfg: unknown;
|
|
166
|
+
to: string;
|
|
167
|
+
mediaUrl: string;
|
|
168
|
+
mimeType?: string;
|
|
169
|
+
}) => Promise<unknown>;
|
|
170
|
+
};
|
|
171
|
+
export type ChannelStatusIssue = {
|
|
172
|
+
channel: string;
|
|
173
|
+
accountId: string;
|
|
174
|
+
kind: "config" | "health" | "auth";
|
|
175
|
+
message: string;
|
|
176
|
+
fix?: string;
|
|
177
|
+
};
|
|
178
|
+
export type ChannelStatus<TAccount> = {
|
|
179
|
+
defaultRuntime: Record<string, unknown>;
|
|
180
|
+
collectStatusIssues: (accounts: TAccount[]) => ChannelStatusIssue[];
|
|
181
|
+
buildChannelSummary: (opts: {
|
|
182
|
+
snapshot: Record<string, unknown>;
|
|
183
|
+
}) => Record<string, unknown>;
|
|
184
|
+
probeAccount: (opts: {
|
|
185
|
+
account: TAccount;
|
|
186
|
+
}) => Promise<Record<string, unknown>>;
|
|
187
|
+
buildAccountSnapshot: (opts: {
|
|
188
|
+
account: TAccount;
|
|
189
|
+
runtime?: Record<string, unknown>;
|
|
190
|
+
probe?: Record<string, unknown>;
|
|
191
|
+
}) => Record<string, unknown>;
|
|
192
|
+
};
|
|
193
|
+
export type RuntimeEnv = {
|
|
194
|
+
log?: (...args: unknown[]) => void;
|
|
195
|
+
error?: (...args: unknown[]) => void;
|
|
196
|
+
writeStdout?: (value: string) => void;
|
|
197
|
+
writeJson?: (value: unknown, space?: number) => void;
|
|
198
|
+
exit?: (code?: number) => void;
|
|
199
|
+
};
|
|
200
|
+
/**
|
|
201
|
+
* channelRuntime 表面 — 由 createPluginRuntime().channel 创建。
|
|
202
|
+
* 外部插件通过 ctx.channelRuntime 访问 AI reply/routing/session 等高级功能。
|
|
203
|
+
* @see PluginRuntimeChannel in openclaw/dist/plugin-sdk/src/plugins/runtime/types-channel.d.ts
|
|
204
|
+
*/
|
|
205
|
+
export type ChannelRuntimeSurface = {
|
|
206
|
+
reply: {
|
|
207
|
+
dispatchReplyFromConfig: (params: {
|
|
208
|
+
ctx: Record<string, unknown>;
|
|
209
|
+
cfg: unknown;
|
|
210
|
+
dispatcher: unknown;
|
|
211
|
+
replyOptions?: Record<string, unknown>;
|
|
212
|
+
}) => Promise<unknown>;
|
|
213
|
+
dispatchReplyWithBufferedBlockDispatcher: (params: {
|
|
214
|
+
ctx: Record<string, unknown>;
|
|
215
|
+
cfg: unknown;
|
|
216
|
+
dispatcherOptions: {
|
|
217
|
+
deliver: (payload: {
|
|
218
|
+
text?: string;
|
|
219
|
+
[k: string]: unknown;
|
|
220
|
+
}, info: {
|
|
221
|
+
kind: string;
|
|
222
|
+
}) => Promise<void>;
|
|
223
|
+
responsePrefix?: string;
|
|
224
|
+
humanDelay?: unknown;
|
|
225
|
+
onError?: (err: unknown, info: {
|
|
226
|
+
kind: string;
|
|
227
|
+
}) => void;
|
|
228
|
+
};
|
|
229
|
+
replyOptions?: Record<string, unknown>;
|
|
230
|
+
}) => Promise<unknown>;
|
|
231
|
+
createReplyDispatcherWithTyping: (opts: unknown) => {
|
|
232
|
+
dispatcher: unknown;
|
|
233
|
+
replyOptions: Record<string, unknown>;
|
|
234
|
+
markDispatchIdle: () => void;
|
|
235
|
+
markRunComplete: () => void;
|
|
236
|
+
};
|
|
237
|
+
resolveHumanDelayConfig: (cfg: unknown, agentId: string) => unknown;
|
|
238
|
+
finalizeInboundContext: <T extends Record<string, unknown>>(ctx: T, opts?: Record<string, unknown>) => T;
|
|
239
|
+
[key: string]: unknown;
|
|
240
|
+
};
|
|
241
|
+
routing: {
|
|
242
|
+
resolveAgentRoute: (opts: {
|
|
243
|
+
cfg: unknown;
|
|
244
|
+
channel: string;
|
|
245
|
+
accountId?: string;
|
|
246
|
+
peer: {
|
|
247
|
+
kind: string;
|
|
248
|
+
id: string;
|
|
249
|
+
};
|
|
250
|
+
}) => {
|
|
251
|
+
agentId: string;
|
|
252
|
+
sessionKey?: string;
|
|
253
|
+
accountId?: string;
|
|
254
|
+
};
|
|
255
|
+
buildAgentSessionKey: (...args: unknown[]) => string;
|
|
256
|
+
[key: string]: unknown;
|
|
257
|
+
};
|
|
258
|
+
session: {
|
|
259
|
+
resolveStorePath: (...args: unknown[]) => string;
|
|
260
|
+
recordInboundSession: (...args: unknown[]) => unknown;
|
|
261
|
+
[key: string]: unknown;
|
|
262
|
+
};
|
|
263
|
+
text: {
|
|
264
|
+
chunkMarkdownText: (text: string, limit: number) => string[];
|
|
265
|
+
[key: string]: unknown;
|
|
266
|
+
};
|
|
267
|
+
[key: string]: unknown;
|
|
268
|
+
};
|
|
269
|
+
export type GatewayContext = {
|
|
270
|
+
accountId: string;
|
|
271
|
+
cfg: unknown;
|
|
272
|
+
runtime: RuntimeEnv;
|
|
273
|
+
channelRuntime?: ChannelRuntimeSurface;
|
|
274
|
+
abortSignal: AbortSignal;
|
|
275
|
+
log?: LogFacade;
|
|
276
|
+
getStatus?: () => Record<string, unknown>;
|
|
277
|
+
setStatus: (status: Record<string, unknown>) => void;
|
|
278
|
+
};
|
|
279
|
+
export type ChannelGateway = {
|
|
280
|
+
startAccount: (ctx: GatewayContext) => Promise<void>;
|
|
281
|
+
};
|
|
282
|
+
export type ChannelOnboarding = {
|
|
283
|
+
channel: string;
|
|
284
|
+
getStatus: (opts: {
|
|
285
|
+
cfg: unknown;
|
|
286
|
+
}) => Promise<{
|
|
287
|
+
channel: string;
|
|
288
|
+
configured: boolean;
|
|
289
|
+
statusLines: string[];
|
|
290
|
+
selectionHint: string;
|
|
291
|
+
quickstartScore: number;
|
|
292
|
+
}>;
|
|
293
|
+
configure: (opts: {
|
|
294
|
+
cfg: unknown;
|
|
295
|
+
}) => Promise<{
|
|
296
|
+
cfg: unknown;
|
|
297
|
+
}>;
|
|
298
|
+
};
|
|
299
|
+
export type ChannelAgentPromptAdapter = {
|
|
300
|
+
messageToolHints?: (params: {
|
|
301
|
+
cfg: unknown;
|
|
302
|
+
accountId?: string | null;
|
|
303
|
+
}) => string[];
|
|
304
|
+
};
|
|
305
|
+
export type ChannelMessageActionAdapter = {
|
|
306
|
+
describeMessageTool: (params: Record<string, unknown>) => {
|
|
307
|
+
actions?: readonly string[] | null;
|
|
308
|
+
} | null | undefined;
|
|
309
|
+
handleAction?: (ctx: ChannelMessageActionContext) => Promise<unknown>;
|
|
310
|
+
};
|
|
311
|
+
export type ChannelMessageActionContext = {
|
|
312
|
+
channel: string;
|
|
313
|
+
action: string;
|
|
314
|
+
cfg: unknown;
|
|
315
|
+
params: Record<string, unknown>;
|
|
316
|
+
accountId?: string | null;
|
|
317
|
+
};
|
|
318
|
+
export type ResolvedWpsAccount = {
|
|
319
|
+
accountId: string;
|
|
320
|
+
enabled: boolean;
|
|
321
|
+
configured: boolean;
|
|
322
|
+
config: import("../core/config.js").WpsConfig;
|
|
323
|
+
};
|
|
324
|
+
//# sourceMappingURL=types.d.ts.map
|