@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.
Files changed (62) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +335 -0
  3. package/README_ZH-CN.md +318 -0
  4. package/bin/cli.mjs +677 -0
  5. package/dist/channel/event-crypto.d.ts +19 -0
  6. package/dist/channel/event-handlers.d.ts +61 -0
  7. package/dist/channel/event-types.d.ts +88 -0
  8. package/dist/channel/index.d.ts +8 -0
  9. package/dist/channel/plugin.d.ts +11 -0
  10. package/dist/channel/register-tool-bridge.d.ts +14 -0
  11. package/dist/channel/sdk-client-options.d.ts +24 -0
  12. package/dist/channel/sdk-helpers.d.ts +12 -0
  13. package/dist/channel/sdk-provider.d.ts +23 -0
  14. package/dist/channel/types.d.ts +324 -0
  15. package/dist/core/config.d.ts +267 -0
  16. package/dist/core/errors.d.ts +36 -0
  17. package/dist/core/index.d.ts +18 -0
  18. package/dist/core/lazy-client-store.d.ts +28 -0
  19. package/dist/core/media-utils.d.ts +27 -0
  20. package/dist/core/reaction.d.ts +29 -0
  21. package/dist/core/token-store.d.ts +34 -0
  22. package/dist/core/user-token-store.d.ts +35 -0
  23. package/dist/core/wps-client.d.ts +42 -0
  24. package/dist/index.d.ts +17 -0
  25. package/dist/index.js +33 -0
  26. package/dist/messaging/handler.d.ts +73 -0
  27. package/dist/messaging/inbound/content-parser.d.ts +17 -0
  28. package/dist/messaging/inbound/handler.d.ts +44 -0
  29. package/dist/messaging/inbound/index.d.ts +5 -0
  30. package/dist/messaging/inbound/media-prefetch.d.ts +43 -0
  31. package/dist/messaging/inbound/pairing-allow-store.d.ts +11 -0
  32. package/dist/messaging/index.d.ts +3 -0
  33. package/dist/messaging/outbound.d.ts +15 -0
  34. package/dist/session/idempotency.d.ts +8 -0
  35. package/dist/session/index.d.ts +5 -0
  36. package/dist/session/resolver.d.ts +17 -0
  37. package/dist/session/types.d.ts +37 -0
  38. package/dist/tools/oapi/calendar.d.ts +106 -0
  39. package/dist/tools/oapi/chat.d.ts +10 -0
  40. package/dist/tools/oapi/delegated-auth.d.ts +14 -0
  41. package/dist/tools/oapi/drive.d.ts +112 -0
  42. package/dist/tools/oapi/index.d.ts +24 -0
  43. package/dist/tools/oapi/media.d.ts +32 -0
  44. package/dist/tools/oapi/messaging.d.ts +10 -0
  45. package/dist/tools/oapi/todo.d.ts +96 -0
  46. package/dist/tools/oapi/user.d.ts +10 -0
  47. package/dist/tools/oauth/index.d.ts +65 -0
  48. package/openclaw.plugin.json +154 -0
  49. package/package.json +91 -0
  50. package/scripts/upgrade.sh +37 -0
  51. package/skills/wps-auth-provider.md +63 -0
  52. package/skills/wps-calendar/SKILL.md +147 -0
  53. package/skills/wps-channel-rules/SKILL.md +50 -0
  54. package/skills/wps-chat/SKILL.md +106 -0
  55. package/skills/wps-drive/SKILL.md +79 -0
  56. package/skills/wps-im-read/SKILL.md +88 -0
  57. package/skills/wps-im-send/SKILL.md +183 -0
  58. package/skills/wps-media/SKILL.md +101 -0
  59. package/skills/wps-message-handler.md +48 -0
  60. package/skills/wps-todo/SKILL.md +65 -0
  61. package/skills/wps-user/SKILL.md +105 -0
  62. package/skills/wps-xiezuo-session-mapper.md +62 -0
@@ -0,0 +1,267 @@
1
+ /**
2
+ * WPS 渠道运行时配置 — Zod Schema + 类型导出。
3
+ *
4
+ * 从 v1 packages/channel-plugin/src/types.ts 迁移并重构:
5
+ * - 配置定义集中在此文件
6
+ * - 凭证解析逻辑内聚
7
+ * - 预留 userAuth 扩展点
8
+ */
9
+ import { z } from "zod";
10
+ import type { AppCredentials } from "./token-store.js";
11
+ export declare const DmPolicySchema: z.ZodDefault<z.ZodEnum<{
12
+ disabled: "disabled";
13
+ open: "open";
14
+ allowlist: "allowlist";
15
+ pairing: "pairing";
16
+ }>>;
17
+ export declare const GroupConfigSchema: z.ZodObject<{
18
+ requireMention: z.ZodOptional<z.ZodBoolean>;
19
+ toolPolicy: z.ZodOptional<z.ZodEnum<{
20
+ full: "full";
21
+ limited: "limited";
22
+ none: "none";
23
+ }>>;
24
+ }, z.core.$loose>;
25
+ export declare const McpConfigSchema: z.ZodObject<{
26
+ enabled: z.ZodDefault<z.ZodBoolean>;
27
+ mode: z.ZodDefault<z.ZodLiteral<"app">>;
28
+ clientId: z.ZodOptional<z.ZodString>;
29
+ clientSecret: z.ZodOptional<z.ZodString>;
30
+ baseUrl: z.ZodOptional<z.ZodString>;
31
+ toolAllowlist: z.ZodDefault<z.ZodArray<z.ZodString>>;
32
+ }, z.core.$strip>;
33
+ export declare const InstantAckSchema: z.ZodObject<{
34
+ enabled: z.ZodDefault<z.ZodBoolean>;
35
+ text: z.ZodDefault<z.ZodString>;
36
+ }, z.core.$strip>;
37
+ export declare const SdkConfigSchema: z.ZodObject<{
38
+ enabled: z.ZodDefault<z.ZodBoolean>;
39
+ logLevel: z.ZodDefault<z.ZodEnum<{
40
+ error: "error";
41
+ debug: "debug";
42
+ info: "info";
43
+ warn: "warn";
44
+ }>>;
45
+ endpoint: z.ZodOptional<z.ZodString>;
46
+ connectTimeoutMs: z.ZodDefault<z.ZodNumber>;
47
+ pongTimeout: z.ZodDefault<z.ZodNumber>;
48
+ autoReconnect: z.ZodDefault<z.ZodBoolean>;
49
+ reconnectBaseInterval: z.ZodDefault<z.ZodNumber>;
50
+ reconnectMaxInterval: z.ZodDefault<z.ZodNumber>;
51
+ reconnectMultiplier: z.ZodDefault<z.ZodNumber>;
52
+ reconnectMaxRetry: z.ZodDefault<z.ZodNumber>;
53
+ reconnectJitter: z.ZodDefault<z.ZodNumber>;
54
+ }, z.core.$strip>;
55
+ export declare const WebhookConfigSchema: z.ZodObject<{
56
+ path: z.ZodDefault<z.ZodString>;
57
+ port: z.ZodDefault<z.ZodNumber>;
58
+ }, z.core.$strip>;
59
+ /**
60
+ * 用户 OAuth `redirect_uri`(插件内置,**须**与 WPS 开放平台「安全设置 → 用户授权回调地址」登记**完全一致**)。
61
+ */
62
+ export declare const DEFAULT_USER_OAUTH_REDIRECT_URI = "https://o.wpsgo.com/app/41000207/aY5vaqfh9T0o/";
63
+ export declare const WpsConfigSchema: z.ZodObject<{
64
+ enabled: z.ZodDefault<z.ZodBoolean>;
65
+ appId: z.ZodString;
66
+ appSecret: z.ZodString;
67
+ companyId: z.ZodOptional<z.ZodString>;
68
+ baseUrl: z.ZodDefault<z.ZodString>;
69
+ enableEncryption: z.ZodDefault<z.ZodBoolean>;
70
+ webhook: z.ZodOptional<z.ZodObject<{
71
+ path: z.ZodDefault<z.ZodString>;
72
+ port: z.ZodDefault<z.ZodNumber>;
73
+ }, z.core.$strip>>;
74
+ sdk: z.ZodOptional<z.ZodObject<{
75
+ enabled: z.ZodDefault<z.ZodBoolean>;
76
+ logLevel: z.ZodDefault<z.ZodEnum<{
77
+ error: "error";
78
+ debug: "debug";
79
+ info: "info";
80
+ warn: "warn";
81
+ }>>;
82
+ endpoint: z.ZodOptional<z.ZodString>;
83
+ connectTimeoutMs: z.ZodDefault<z.ZodNumber>;
84
+ pongTimeout: z.ZodDefault<z.ZodNumber>;
85
+ autoReconnect: z.ZodDefault<z.ZodBoolean>;
86
+ reconnectBaseInterval: z.ZodDefault<z.ZodNumber>;
87
+ reconnectMaxInterval: z.ZodDefault<z.ZodNumber>;
88
+ reconnectMultiplier: z.ZodDefault<z.ZodNumber>;
89
+ reconnectMaxRetry: z.ZodDefault<z.ZodNumber>;
90
+ reconnectJitter: z.ZodDefault<z.ZodNumber>;
91
+ }, z.core.$strip>>;
92
+ dmPolicy: z.ZodOptional<z.ZodDefault<z.ZodEnum<{
93
+ disabled: "disabled";
94
+ open: "open";
95
+ allowlist: "allowlist";
96
+ pairing: "pairing";
97
+ }>>>;
98
+ allowFrom: z.ZodOptional<z.ZodArray<z.ZodString>>;
99
+ groupPolicy: z.ZodOptional<z.ZodEnum<{
100
+ open: "open";
101
+ allowlist: "allowlist";
102
+ }>>;
103
+ groups: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
104
+ requireMention: z.ZodOptional<z.ZodBoolean>;
105
+ toolPolicy: z.ZodOptional<z.ZodEnum<{
106
+ full: "full";
107
+ limited: "limited";
108
+ none: "none";
109
+ }>>;
110
+ }, z.core.$loose>>>;
111
+ instantAck: z.ZodOptional<z.ZodObject<{
112
+ enabled: z.ZodDefault<z.ZodBoolean>;
113
+ text: z.ZodDefault<z.ZodString>;
114
+ }, z.core.$strip>>;
115
+ robotJoinGroupMessage: z.ZodOptional<z.ZodString>;
116
+ mcp: z.ZodOptional<z.ZodObject<{
117
+ enabled: z.ZodDefault<z.ZodBoolean>;
118
+ mode: z.ZodDefault<z.ZodLiteral<"app">>;
119
+ clientId: z.ZodOptional<z.ZodString>;
120
+ clientSecret: z.ZodOptional<z.ZodString>;
121
+ baseUrl: z.ZodOptional<z.ZodString>;
122
+ toolAllowlist: z.ZodDefault<z.ZodArray<z.ZodString>>;
123
+ }, z.core.$strip>>;
124
+ }, z.core.$strip>;
125
+ export declare const WpsChannelConfigSchema: z.ZodObject<{
126
+ enabled: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
127
+ appId: z.ZodOptional<z.ZodString>;
128
+ appSecret: z.ZodOptional<z.ZodString>;
129
+ companyId: z.ZodOptional<z.ZodOptional<z.ZodString>>;
130
+ baseUrl: z.ZodOptional<z.ZodDefault<z.ZodString>>;
131
+ enableEncryption: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
132
+ webhook: z.ZodOptional<z.ZodOptional<z.ZodObject<{
133
+ path: z.ZodDefault<z.ZodString>;
134
+ port: z.ZodDefault<z.ZodNumber>;
135
+ }, z.core.$strip>>>;
136
+ sdk: z.ZodOptional<z.ZodOptional<z.ZodObject<{
137
+ enabled: z.ZodDefault<z.ZodBoolean>;
138
+ logLevel: z.ZodDefault<z.ZodEnum<{
139
+ error: "error";
140
+ debug: "debug";
141
+ info: "info";
142
+ warn: "warn";
143
+ }>>;
144
+ endpoint: z.ZodOptional<z.ZodString>;
145
+ connectTimeoutMs: z.ZodDefault<z.ZodNumber>;
146
+ pongTimeout: z.ZodDefault<z.ZodNumber>;
147
+ autoReconnect: z.ZodDefault<z.ZodBoolean>;
148
+ reconnectBaseInterval: z.ZodDefault<z.ZodNumber>;
149
+ reconnectMaxInterval: z.ZodDefault<z.ZodNumber>;
150
+ reconnectMultiplier: z.ZodDefault<z.ZodNumber>;
151
+ reconnectMaxRetry: z.ZodDefault<z.ZodNumber>;
152
+ reconnectJitter: z.ZodDefault<z.ZodNumber>;
153
+ }, z.core.$strip>>>;
154
+ dmPolicy: z.ZodOptional<z.ZodOptional<z.ZodDefault<z.ZodEnum<{
155
+ disabled: "disabled";
156
+ open: "open";
157
+ allowlist: "allowlist";
158
+ pairing: "pairing";
159
+ }>>>>;
160
+ allowFrom: z.ZodOptional<z.ZodOptional<z.ZodArray<z.ZodString>>>;
161
+ groupPolicy: z.ZodOptional<z.ZodOptional<z.ZodEnum<{
162
+ open: "open";
163
+ allowlist: "allowlist";
164
+ }>>>;
165
+ groups: z.ZodOptional<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
166
+ requireMention: z.ZodOptional<z.ZodBoolean>;
167
+ toolPolicy: z.ZodOptional<z.ZodEnum<{
168
+ full: "full";
169
+ limited: "limited";
170
+ none: "none";
171
+ }>>;
172
+ }, z.core.$loose>>>>;
173
+ instantAck: z.ZodOptional<z.ZodOptional<z.ZodObject<{
174
+ enabled: z.ZodDefault<z.ZodBoolean>;
175
+ text: z.ZodDefault<z.ZodString>;
176
+ }, z.core.$strip>>>;
177
+ robotJoinGroupMessage: z.ZodOptional<z.ZodOptional<z.ZodString>>;
178
+ mcp: z.ZodOptional<z.ZodOptional<z.ZodObject<{
179
+ enabled: z.ZodDefault<z.ZodBoolean>;
180
+ mode: z.ZodDefault<z.ZodLiteral<"app">>;
181
+ clientId: z.ZodOptional<z.ZodString>;
182
+ clientSecret: z.ZodOptional<z.ZodString>;
183
+ baseUrl: z.ZodOptional<z.ZodString>;
184
+ toolAllowlist: z.ZodDefault<z.ZodArray<z.ZodString>>;
185
+ }, z.core.$strip>>>;
186
+ defaultAccountId: z.ZodOptional<z.ZodString>;
187
+ accounts: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
188
+ enabled: z.ZodDefault<z.ZodBoolean>;
189
+ appId: z.ZodString;
190
+ appSecret: z.ZodString;
191
+ companyId: z.ZodOptional<z.ZodString>;
192
+ baseUrl: z.ZodDefault<z.ZodString>;
193
+ enableEncryption: z.ZodDefault<z.ZodBoolean>;
194
+ webhook: z.ZodOptional<z.ZodObject<{
195
+ path: z.ZodDefault<z.ZodString>;
196
+ port: z.ZodDefault<z.ZodNumber>;
197
+ }, z.core.$strip>>;
198
+ sdk: z.ZodOptional<z.ZodObject<{
199
+ enabled: z.ZodDefault<z.ZodBoolean>;
200
+ logLevel: z.ZodDefault<z.ZodEnum<{
201
+ error: "error";
202
+ debug: "debug";
203
+ info: "info";
204
+ warn: "warn";
205
+ }>>;
206
+ endpoint: z.ZodOptional<z.ZodString>;
207
+ connectTimeoutMs: z.ZodDefault<z.ZodNumber>;
208
+ pongTimeout: z.ZodDefault<z.ZodNumber>;
209
+ autoReconnect: z.ZodDefault<z.ZodBoolean>;
210
+ reconnectBaseInterval: z.ZodDefault<z.ZodNumber>;
211
+ reconnectMaxInterval: z.ZodDefault<z.ZodNumber>;
212
+ reconnectMultiplier: z.ZodDefault<z.ZodNumber>;
213
+ reconnectMaxRetry: z.ZodDefault<z.ZodNumber>;
214
+ reconnectJitter: z.ZodDefault<z.ZodNumber>;
215
+ }, z.core.$strip>>;
216
+ dmPolicy: z.ZodOptional<z.ZodDefault<z.ZodEnum<{
217
+ disabled: "disabled";
218
+ open: "open";
219
+ allowlist: "allowlist";
220
+ pairing: "pairing";
221
+ }>>>;
222
+ allowFrom: z.ZodOptional<z.ZodArray<z.ZodString>>;
223
+ groupPolicy: z.ZodOptional<z.ZodEnum<{
224
+ open: "open";
225
+ allowlist: "allowlist";
226
+ }>>;
227
+ groups: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
228
+ requireMention: z.ZodOptional<z.ZodBoolean>;
229
+ toolPolicy: z.ZodOptional<z.ZodEnum<{
230
+ full: "full";
231
+ limited: "limited";
232
+ none: "none";
233
+ }>>;
234
+ }, z.core.$loose>>>;
235
+ instantAck: z.ZodOptional<z.ZodObject<{
236
+ enabled: z.ZodDefault<z.ZodBoolean>;
237
+ text: z.ZodDefault<z.ZodString>;
238
+ }, z.core.$strip>>;
239
+ robotJoinGroupMessage: z.ZodOptional<z.ZodString>;
240
+ mcp: z.ZodOptional<z.ZodObject<{
241
+ enabled: z.ZodDefault<z.ZodBoolean>;
242
+ mode: z.ZodDefault<z.ZodLiteral<"app">>;
243
+ clientId: z.ZodOptional<z.ZodString>;
244
+ clientSecret: z.ZodOptional<z.ZodString>;
245
+ baseUrl: z.ZodOptional<z.ZodString>;
246
+ toolAllowlist: z.ZodDefault<z.ZodArray<z.ZodString>>;
247
+ }, z.core.$strip>>;
248
+ }, z.core.$strip>>>;
249
+ }, z.core.$strip>;
250
+ export type WpsConfig = z.infer<typeof WpsConfigSchema>;
251
+ export type WpsChannelConfig = z.infer<typeof WpsChannelConfigSchema>;
252
+ export type DmPolicy = z.infer<typeof DmPolicySchema>;
253
+ export type GroupConfig = z.infer<typeof GroupConfigSchema>;
254
+ export type McpConfig = z.infer<typeof McpConfigSchema>;
255
+ export type InstantAckConfig = z.infer<typeof InstantAckSchema>;
256
+ export type SdkConfig = z.infer<typeof SdkConfigSchema>;
257
+ export type WebhookConfig = z.infer<typeof WebhookConfigSchema>;
258
+ /** 始终返回插件内置用户 OAuth 回调地址(忽略 channel 配置)。 */
259
+ export declare function resolveUserOAuthRedirectUri(_wpsCfg?: WpsConfig | null): string;
260
+ export declare function resolveDefaultWpsAccountId(cfg?: WpsChannelConfig): string;
261
+ export declare function resolveWpsAccounts(cfg?: WpsChannelConfig): Record<string, WpsConfig>;
262
+ export declare function resolveAppCredentials(cfg?: WpsConfig): AppCredentials | null;
263
+ export declare function resolveMcpCredentials(cfg?: WpsConfig): AppCredentials | null;
264
+ export declare const WPS_CHANNEL_ID = "wps-xiezuo";
265
+ export declare const WPS_PLUGIN_ID = "wps-xiezuo";
266
+ export declare const DEFAULT_ACCOUNT_ID = "default";
267
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1,36 @@
1
+ /**
2
+ * WPS OpenAPI 统一错误体系。
3
+ *
4
+ * 错误分三个阶段:
5
+ * - http: HTTP 层错误(4xx/5xx)
6
+ * - business: 业务层错误(code ≠ 0)
7
+ * - parse: 响应解析错误(非法 JSON)
8
+ */
9
+ export type WpsErrorStage = "http" | "business" | "parse";
10
+ export type WpsErrorDetail = {
11
+ stage: WpsErrorStage;
12
+ method: string;
13
+ path: string;
14
+ httpStatus?: number;
15
+ wpsCode?: number | string;
16
+ hint?: string;
17
+ retriable?: boolean;
18
+ requestId?: string;
19
+ };
20
+ export declare class WpsRequestError extends Error {
21
+ readonly detail: WpsErrorDetail;
22
+ readonly name = "WpsRequestError";
23
+ constructor(message: string, detail: WpsErrorDetail);
24
+ get retriable(): boolean;
25
+ get stage(): WpsErrorStage;
26
+ }
27
+ export declare class WpsTokenError extends Error {
28
+ readonly cause?: unknown | undefined;
29
+ readonly name = "WpsTokenError";
30
+ constructor(message: string, cause?: unknown | undefined);
31
+ }
32
+ export declare function httpStatusHint(status: number): {
33
+ hint: string;
34
+ retriable: boolean;
35
+ };
36
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1,18 @@
1
+ /**
2
+ * core/ 公共导出。
3
+ * 上层模块统一从 `@/core/index.js` 或具体文件导入。
4
+ */
5
+ export { WpsRequestError, WpsTokenError, httpStatusHint } from "./errors.js";
6
+ export type { WpsErrorStage, WpsErrorDetail } from "./errors.js";
7
+ export { AppTokenStore, getAppTokenStore, clearAllTokenStores } from "./token-store.js";
8
+ export type { TokenEntry, AppCredentials } from "./token-store.js";
9
+ export { exchangeCodeForToken, putUserToken, getUserToken, takeUserToken, hasUserToken, setRefreshContext } from "./user-token-store.js";
10
+ export type { UserTokenEntry, OAuthCodeExchangeParams } from "./user-token-store.js";
11
+ export { WpsClient, AppAuthProvider, UserAuthProvider, createWpsClient, createUserWpsClient } from "./wps-client.js";
12
+ export type { AuthProvider, WpsRequestOptions } from "./wps-client.js";
13
+ export { resolveDownloadUrl, resolveDownloadUrlOrThrow } from "./media-utils.js";
14
+ export { addThinkingReaction, removeThinkingReaction, REACTION_TYPE } from "./reaction.js";
15
+ export type { ThinkingIndicatorState } from "./reaction.js";
16
+ export { WpsConfigSchema, WpsChannelConfigSchema, DmPolicySchema, GroupConfigSchema, McpConfigSchema, InstantAckSchema, SdkConfigSchema, WebhookConfigSchema, resolveAppCredentials, resolveMcpCredentials, resolveDefaultWpsAccountId, resolveWpsAccounts, resolveUserOAuthRedirectUri, DEFAULT_USER_OAUTH_REDIRECT_URI, WPS_CHANNEL_ID, WPS_PLUGIN_ID, DEFAULT_ACCOUNT_ID, } from "./config.js";
17
+ export type { WpsConfig, WpsChannelConfig, DmPolicy, GroupConfig, McpConfig, InstantAckConfig, SdkConfig, WebhookConfig, } from "./config.js";
18
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,28 @@
1
+ /**
2
+ * 延迟初始化的 WpsClient 存储。
3
+ *
4
+ * 工具在 register() 阶段注册(此时无凭据),
5
+ * 凭据在 startAccount() 阶段设置,
6
+ * 工具执行时通过 getClient() 获取已初始化的 client。
7
+ */
8
+ import type { WpsClient } from "./wps-client.js";
9
+ import type { WpsConfig } from "./config.js";
10
+ import type { AppCredentials } from "./token-store.js";
11
+ declare let _log: {
12
+ info?: (...args: unknown[]) => void;
13
+ error?: (...args: unknown[]) => void;
14
+ warn?: (...args: unknown[]) => void;
15
+ } | null;
16
+ export declare function setLazyClient(client: WpsClient, log?: typeof _log, wpsCfg?: WpsConfig, creds?: AppCredentials): void;
17
+ export declare function getLazyClient(): WpsClient;
18
+ export declare function getLazyLog(): typeof _log;
19
+ export declare function getLazyWpsCfg(): WpsConfig;
20
+ export declare function getLazyCreds(): AppCredentials;
21
+ export type DelegatedScope = {
22
+ name: string;
23
+ description: string;
24
+ };
25
+ export declare function setDelegatedScopes(scopes: DelegatedScope[]): void;
26
+ export declare function getDelegatedScopes(): DelegatedScope[];
27
+ export {};
28
+ //# sourceMappingURL=lazy-client-store.d.ts.map
@@ -0,0 +1,27 @@
1
+ /**
2
+ * WPS 媒体相关公共工具。
3
+ *
4
+ * resolveDownloadUrl — 从 WPS download API 响应中提取预签名下载 URL。
5
+ * 统一供 tools/oapi/media.ts 和 messaging/inbound/media-prefetch.ts 使用。
6
+ */
7
+ /**
8
+ * 从 WPS download API 的 JSON 响应中解析出预签名下载 URL。
9
+ * 支持顶层字段和 `data` 嵌套(最多 2 层)。
10
+ *
11
+ * @returns URL string, or `null` if none found.
12
+ */
13
+ export declare function resolveDownloadUrl(data: unknown, depth?: number): string | null;
14
+ /**
15
+ * 同 resolveDownloadUrl,但找不到时抛出 Error(工具调用场景)。
16
+ */
17
+ export declare function resolveDownloadUrlOrThrow(data: unknown): string;
18
+ /**
19
+ * Parse image width/height from raw bytes.
20
+ * Delegates to `image-size` (supports 20+ formats including JPEG, PNG, GIF, WebP, BMP, TIFF, etc.).
21
+ * Returns null if format is unrecognized or header is malformed.
22
+ */
23
+ export declare function parseImageDimensions(buf: Buffer | Uint8Array): {
24
+ width: number;
25
+ height: number;
26
+ } | null;
27
+ //# sourceMappingURL=media-utils.d.ts.map
@@ -0,0 +1,29 @@
1
+ /**
2
+ * WPS 消息表情回复(Reaction)封装。
3
+ *
4
+ * 用于入站消息处理链路的"正在思考"指示器:
5
+ * 收到消息后添加 reaction,Agent 处理完成后删除。
6
+ */
7
+ import type { AppCredentials } from "./token-store.js";
8
+ export declare const REACTION_TYPE = "emoji_busy";
9
+ export type ThinkingIndicatorState = {
10
+ kind: "reaction";
11
+ chatId: string;
12
+ messageId: string;
13
+ } | {
14
+ kind: "text-fallback";
15
+ };
16
+ /**
17
+ * 对指定消息添加 thinking reaction。
18
+ * 失败时抛出异常,由调用方决定降级策略。
19
+ */
20
+ export declare function addThinkingReaction(creds: AppCredentials, chatId: string, messageId: string): Promise<void>;
21
+ /**
22
+ * 删除指定消息上的 thinking reaction。
23
+ * 内部捕获所有异常,不抛出(仅通过 log 记录)。
24
+ */
25
+ export declare function removeThinkingReaction(creds: AppCredentials, chatId: string, messageId: string, log?: {
26
+ info?: (...args: unknown[]) => void;
27
+ error?: (...args: unknown[]) => void;
28
+ }): Promise<void>;
29
+ //# sourceMappingURL=reaction.d.ts.map
@@ -0,0 +1,34 @@
1
+ /**
2
+ * 双轨 Token 管理。
3
+ *
4
+ * 本轮实现企业应用级(client_credentials)。
5
+ * 用户委托级(authorization_code + refresh_token)预留接口,后续补齐。
6
+ */
7
+ export type TokenEntry = {
8
+ accessToken: string;
9
+ expiresAt: number;
10
+ };
11
+ export type AppCredentials = {
12
+ clientId: string;
13
+ clientSecret: string;
14
+ baseUrl: string;
15
+ };
16
+ export declare class AppTokenStore {
17
+ private readonly creds;
18
+ private token;
19
+ private inFlight;
20
+ constructor(creds: AppCredentials);
21
+ getToken(): Promise<string>;
22
+ invalidate(): void;
23
+ private requestToken;
24
+ }
25
+ /**
26
+ * 获取或创建一个 AppTokenStore 实例。
27
+ * 以 clientId 为 key 做单例管理,避免同一应用创建多个 store。
28
+ */
29
+ export declare function getAppTokenStore(creds: AppCredentials): AppTokenStore;
30
+ /**
31
+ * 清除所有缓存的 TokenStore(用于测试或热重载)。
32
+ */
33
+ export declare function clearAllTokenStores(): void;
34
+ //# sourceMappingURL=token-store.d.ts.map
@@ -0,0 +1,35 @@
1
+ /**
2
+ * 用户级 OAuth Token 管理 — 内存存储 + 定时刷新。
3
+ *
4
+ * - 授权回调拿到 access_token / refresh_token / expires_in 后存入
5
+ * - 工具取 token 时不删除,可重复使用
6
+ * - 过期前自动用 refresh_token 续期
7
+ * - refresh_token 失败则清除,下次使用时触发重新授权
8
+ */
9
+ export type UserTokenEntry = {
10
+ accessToken: string;
11
+ refreshToken: string;
12
+ expiresAt: number;
13
+ openid: string;
14
+ };
15
+ export type OAuthCodeExchangeParams = {
16
+ appId: string;
17
+ appSecret: string;
18
+ baseUrl: string;
19
+ code: string;
20
+ redirectUri?: string;
21
+ };
22
+ export type RefreshContext = {
23
+ appId: string;
24
+ appSecret: string;
25
+ baseUrl: string;
26
+ };
27
+ /** 设置 refresh 所需的应用凭证(启动时调一次) */
28
+ export declare function setRefreshContext(ctx: RefreshContext): void;
29
+ export declare function putUserToken(wpsUserId: string, entry: UserTokenEntry): void;
30
+ export declare function getUserToken(wpsUserId: string): string | null;
31
+ /** 兼容旧调用方 — 行为改为不删除 */
32
+ export declare function takeUserToken(wpsUserId: string): string | null;
33
+ export declare function hasUserToken(wpsUserId: string): boolean;
34
+ export declare function exchangeCodeForToken(params: OAuthCodeExchangeParams): Promise<UserTokenEntry>;
35
+ //# sourceMappingURL=user-token-store.d.ts.map
@@ -0,0 +1,42 @@
1
+ /**
2
+ * WPS OpenAPI 统一 HTTP 客户端。
3
+ *
4
+ * - 自动注入 Authorization header(通过 AuthProvider 抽象)
5
+ * - 统一请求构造、响应解析、错误映射
6
+ * - 预留 KSO-1 签名注入点(后续补齐)
7
+ */
8
+ import type { AppTokenStore } from "./token-store.js";
9
+ export interface AuthProvider {
10
+ getHeaders(): Promise<Record<string, string>>;
11
+ }
12
+ export declare class AppAuthProvider implements AuthProvider {
13
+ private readonly tokenStore;
14
+ constructor(tokenStore: AppTokenStore);
15
+ getHeaders(): Promise<Record<string, string>>;
16
+ }
17
+ /**
18
+ * 一次性 user token provider — 拿一个 accessToken 字符串直接用。
19
+ */
20
+ export declare class UserAuthProvider implements AuthProvider {
21
+ private readonly accessToken;
22
+ constructor(accessToken: string);
23
+ getHeaders(): Promise<Record<string, string>>;
24
+ }
25
+ export type WpsRequestOptions = {
26
+ method?: "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
27
+ path: string;
28
+ query?: Record<string, string | number | boolean | string[] | undefined>;
29
+ body?: unknown;
30
+ headers?: Record<string, string>;
31
+ };
32
+ export declare class WpsClient {
33
+ private readonly baseUrl;
34
+ private readonly auth;
35
+ constructor(baseUrl: string, auth: AuthProvider);
36
+ request<T = unknown>(opts: WpsRequestOptions): Promise<T>;
37
+ private buildUrl;
38
+ private parseResponse;
39
+ }
40
+ export declare function createWpsClient(baseUrl: string, tokenStore: AppTokenStore): WpsClient;
41
+ export declare function createUserWpsClient(baseUrl: string, accessToken: string): WpsClient;
42
+ //# sourceMappingURL=wps-client.d.ts.map
@@ -0,0 +1,17 @@
1
+ /**
2
+ * OpenClaw WPS Xiezuo 插件入口。
3
+ *
4
+ * 工具必须在 register() 阶段注册(OpenClaw 在此之后冻结工具列表)。
5
+ * WpsClient 在 startAccount() 阶段通过 lazy-client-store 初始化,
6
+ * 工具执行时通过 getLazyClient() 获取。
7
+ */
8
+ import type { OpenClawPluginApi } from "./channel/types.js";
9
+ declare const plugin: {
10
+ id: string;
11
+ name: string;
12
+ description: string;
13
+ configSchema: unknown;
14
+ register(api: OpenClawPluginApi): void;
15
+ };
16
+ export default plugin;
17
+ //# sourceMappingURL=index.d.ts.map