@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,11 @@
1
+ type LogLike = {
2
+ debug?: (...args: unknown[]) => void;
3
+ warn?: (...args: unknown[]) => void;
4
+ };
5
+ export declare function loadPairingAllowFrom(opts: {
6
+ channelId: string;
7
+ accountId: string;
8
+ log?: LogLike;
9
+ }): Promise<string[]>;
10
+ export {};
11
+ //# sourceMappingURL=pairing-allow-store.d.ts.map
@@ -0,0 +1,3 @@
1
+ export { handleInbound, normalizeInboundMessage, parseCardContent } from "./inbound/index.js";
2
+ export type { HandleInboundParams } from "./inbound/index.js";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,15 @@
1
+ /**
2
+ * WPS 消息发送 - 最小实现
3
+ *
4
+ * 用于测试消息处理流程,发送即时确认消息
5
+ */
6
+ import type { WpsConfig } from "../core/config.js";
7
+ type SendMessageParams = {
8
+ config: WpsConfig;
9
+ chatId: string;
10
+ text: string;
11
+ log?: (...args: unknown[]) => void;
12
+ };
13
+ export declare function sendTextMessage(params: SendMessageParams): Promise<void>;
14
+ export {};
15
+ //# sourceMappingURL=outbound.d.ts.map
@@ -0,0 +1,8 @@
1
+ import type { IdempotencyStore } from "./types.js";
2
+ export declare class MemoryIdempotencyStore implements IdempotencyStore {
3
+ private store;
4
+ check(key: string): Promise<boolean>;
5
+ mark(key: string, ttl: number): Promise<void>;
6
+ cleanup(): void;
7
+ }
8
+ //# sourceMappingURL=idempotency.d.ts.map
@@ -0,0 +1,5 @@
1
+ export { WpsSessionResolver } from "./resolver.js";
2
+ export { MemoryIdempotencyStore } from "./idempotency.js";
3
+ export { SessionResolverError } from "./types.js";
4
+ export type { StandardizedEvent, SessionInfo, SessionResolverConfig, IdempotencyStore } from "./types.js";
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,17 @@
1
+ /**
2
+ * WPS 会话解析器。
3
+ *
4
+ * 将原始入站事件标准化为 StandardizedEvent,再解析出 SessionInfo。
5
+ * 从 v1 packages/channel-plugin/src/session/resolver.ts 迁移,逻辑保持一致。
6
+ */
7
+ import type { StandardizedEvent, SessionInfo, SessionResolverConfig, IdempotencyStore } from "./types.js";
8
+ export declare class WpsSessionResolver {
9
+ private readonly config;
10
+ private readonly idempotencyStore;
11
+ constructor(config: SessionResolverConfig, idempotencyStore: IdempotencyStore);
12
+ normalizeEvent(event: unknown): StandardizedEvent;
13
+ resolve(std: StandardizedEvent): SessionInfo | null;
14
+ checkIdempotency(key: string): Promise<boolean>;
15
+ markProcessed(key: string, ttl?: number): Promise<void>;
16
+ }
17
+ //# sourceMappingURL=resolver.d.ts.map
@@ -0,0 +1,37 @@
1
+ /**
2
+ * 会话解析与幂等去重类型定义。
3
+ * 从 v1 packages/channel-plugin/src/session/types.ts 迁移。
4
+ */
5
+ export interface StandardizedEvent {
6
+ event_id: string;
7
+ message_id: string;
8
+ company_id: string;
9
+ user_id: string;
10
+ group_id?: string;
11
+ message: string;
12
+ is_at_bot: boolean;
13
+ is_reply_to_bot: boolean;
14
+ }
15
+ export interface SessionInfo {
16
+ scene: "p2p" | "group";
17
+ session_key: string;
18
+ idempotency_key: string;
19
+ message_id: string;
20
+ company_id: string;
21
+ user_id: string;
22
+ group_id?: string;
23
+ }
24
+ export interface SessionResolverConfig {
25
+ botId: string;
26
+ accountId?: string;
27
+ }
28
+ export declare class SessionResolverError extends Error {
29
+ readonly code: string;
30
+ readonly name = "SessionResolverError";
31
+ constructor(code: string, message: string);
32
+ }
33
+ export interface IdempotencyStore {
34
+ check(key: string): Promise<boolean>;
35
+ mark(key: string, ttl: number): Promise<void>;
36
+ }
37
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1,106 @@
1
+ /**
2
+ * WPS 日程工具 — create / list events / list instances(日历级与单条 event)。
3
+ *
4
+ * 列表接口与官方一致:
5
+ * - **事件列表**:`GET /v7/calendars/{calendar_id}/events`,主日历 `calendar_id=primary`
6
+ * - **日历级实例列表**:`GET /v7/calendars/{calendar_id}/event_instances`(按时间窗扫主日历下展开实例)
7
+ * - **单条日程详情**(官方「查询日程」):`GET /v7/calendars/{calendar_id}/events/{event_id}`(需 `event_id`;`data` 为单个日程对象,含 `recurrence` 等)
8
+ * - **单条日程实例**(官方「查询日程实例」):`GET /v7/calendars/{calendar_id}/events/{event_id}/event_instances`(需 `event_id`,可从事件列表取)
9
+ * - **答复日程邀请**:`POST /v7/calendars/{calendar_id}/events/{event_id}/respond`(body:`mod_type`、`response_status`、`which_day_time` 毫秒时间戳)
10
+ * - **参与者列表**:`GET /v7/calendars/{calendar_id}/events/{event_id}/attendees`(可选 `page_size`≤100、`page_token`)
11
+ * - 时间范围:`start_time` / `end_time` 为 **RFC3339** 字符串(URL 编码由客户端处理)
12
+ * - 时间窗长度:文档要求 **0~31 天**;超出则截断到 31 天
13
+ * - 事件列表增量:`sync_token`、`anchor_time`(RFC3339)、`with_cancelled`
14
+ *
15
+ * 文档:[查询日程列表](https://365.kdocs.cn/3rd/open/documents/app-integration-dev/wps365/server/calendar/calendar-event/get-calendar-event-list)
16
+ * · 查询日程实例列表(`event_instances`)见开放平台同域日历文档章节。
17
+ *
18
+ * 创建:用户 delegated token + POST `/v7/calendars/primary/events/create`
19
+ *
20
+ * **鉴权 / 签名**:与创建日程完全一致——均通过 `createUserWpsClient`(`UserAuthProvider`)仅注入
21
+ * `Authorization: Bearer <用户 access_token>`,无单独 KSO-1 或其它请求头分叉。
22
+ */
23
+ import type { WpsClient } from "../../core/wps-client.js";
24
+ import type { ToolRegistration } from "../../channel/types.js";
25
+ /**
26
+ * 解析主日历「事件列表 / 实例列表」共用的时间窗(RFC3339 边界日期,跨度 ≤ 31 天)。
27
+ *
28
+ * @internal 导出供单元测试。
29
+ */
30
+ export declare function resolvePrimaryCalendarTimeRange(input: {
31
+ startRfc?: string;
32
+ endRfc?: string;
33
+ now?: Date;
34
+ }): {
35
+ start: Date;
36
+ end: Date;
37
+ };
38
+ /**
39
+ * 构建 **日历级** `.../calendars/{id}/event_instances` GET 查询参数(RFC3339 时间窗 + 可选分页)。
40
+ *
41
+ * @internal 导出供单元测试。
42
+ */
43
+ export declare function buildPrimaryCalendarEventInstancesQuery(input: {
44
+ startRfc?: string;
45
+ endRfc?: string;
46
+ pageSize?: number;
47
+ pageToken?: string;
48
+ now?: Date;
49
+ }): Record<string, string | number>;
50
+ /**
51
+ * 单条日程「查询日程实例」GET query(文档仅 `start_time` / `end_time`,RFC3339,0~31 天)。
52
+ *
53
+ * @internal 导出供单元测试。
54
+ */
55
+ export declare function buildEventScopedEventInstancesQuery(input: {
56
+ startRfc?: string;
57
+ endRfc?: string;
58
+ now?: Date;
59
+ }): Record<string, string>;
60
+ /**
61
+ * 构建主日历事件列表 GET 查询参数(与开放平台「查询日程列表」一致)。
62
+ *
63
+ * - 带 `sync_token` 时:仅传增量相关字段,不再自动补 `start_time`/`end_time`。
64
+ * - 否则:补全或默认时间窗,并保证跨度 ≤ 31 天。
65
+ *
66
+ * @internal 导出供单元测试。
67
+ */
68
+ export declare function buildPrimaryCalendarEventsListQuery(input: {
69
+ startRfc?: string;
70
+ endRfc?: string;
71
+ pageSize?: number;
72
+ pageToken?: string;
73
+ withCancelled?: boolean;
74
+ syncToken?: string;
75
+ anchorTime?: string;
76
+ now?: Date;
77
+ }): Record<string, string | number | boolean>;
78
+ /**
79
+ * `.../calendars/{calendar_id}/events/{event_id}` 路径段(查询单条日程;亦为 event_instances 的前缀)。
80
+ *
81
+ * @internal 导出供单元测试。
82
+ */
83
+ export declare function buildCalendarGetEventPath(calendarId: string, eventId: string): string;
84
+ /**
85
+ * `POST .../events/{event_id}/respond`(答复日程邀请)。
86
+ *
87
+ * @internal 导出供单元测试。
88
+ */
89
+ export declare function buildCalendarRespondInvitationPath(calendarId: string, eventId: string): string;
90
+ /**
91
+ * `GET .../events/{event_id}/attendees`(获取日程参与者列表)。
92
+ *
93
+ * @internal 导出供单元测试。
94
+ */
95
+ export declare function buildCalendarEventAttendeesPath(calendarId: string, eventId: string): string;
96
+ /**
97
+ * 参与者列表 GET query:`page_size`(默认 30,最大 100)、可选 `page_token`。
98
+ *
99
+ * @internal 导出供单元测试。
100
+ */
101
+ export declare function buildEventAttendeesQuery(input: {
102
+ pageSize?: number;
103
+ pageToken?: string;
104
+ }): Record<string, string | number>;
105
+ export declare function registerCalendarTools(_client: WpsClient, registerTool: (opts: ToolRegistration) => void): void;
106
+ //# sourceMappingURL=calendar.d.ts.map
@@ -0,0 +1,10 @@
1
+ /**
2
+ * WPS OpenAPI chat session tools (create, list, get, members).
3
+ */
4
+ import type { WpsClient } from "../../core/wps-client.js";
5
+ import type { ToolRegistration } from "../../channel/types.js";
6
+ /**
7
+ * Registers WPS chat OpenAPI tools.
8
+ */
9
+ export declare function registerChatTools(client: WpsClient, registerTool: (opts: ToolRegistration) => void): void;
10
+ //# sourceMappingURL=chat.d.ts.map
@@ -0,0 +1,14 @@
1
+ import type { WpsClient } from "../../core/wps-client.js";
2
+ type NeedsAuthResult = {
3
+ needsAuth: true;
4
+ message: string;
5
+ };
6
+ export declare function withDelegatedUserClient(opts: {
7
+ wpsUserId: string;
8
+ authCardOriginalMessage: string;
9
+ needsAuthMessage: string;
10
+ logTag: string;
11
+ run: (client: WpsClient) => Promise<unknown>;
12
+ }): Promise<unknown | NeedsAuthResult>;
13
+ export {};
14
+ //# sourceMappingURL=delegated-auth.d.ts.map
@@ -0,0 +1,112 @@
1
+ /**
2
+ * WPS 云文档工具 — 盘列表 / 新建文件(夹)(用户 delegated OAuth)。
3
+ *
4
+ * - **获取盘列表**:`GET /v7/drives`
5
+ * - **新建文件(夹)**:`POST /v7/drives/{drive_id}/files/{parent_id}/create`
6
+ * - 文档权限:`kso.drive.readwrite`、`kso.file.readwrite`(或控制台等价 delegated)
7
+ */
8
+ import type { WpsClient } from "../../core/wps-client.js";
9
+ import type { ToolRegistration } from "../../channel/types.js";
10
+ /**
11
+ * 构建「获取盘列表」query。
12
+ *
13
+ * @internal 导出供单元测试。
14
+ */
15
+ export declare function buildDriveListQuery(input: {
16
+ alloteeType: "user" | "group" | "app";
17
+ alloteeId?: string;
18
+ withExtAttrs?: boolean;
19
+ pageSize?: number;
20
+ pageToken?: string;
21
+ sources?: string[];
22
+ }): Record<string, string | number | boolean | string[]>;
23
+ /**
24
+ * 构建「新建文件(夹)」path。
25
+ *
26
+ * @internal 导出供单元测试。
27
+ */
28
+ export declare function buildDriveCreateFilePath(driveId: string, parentId: string): string;
29
+ /**
30
+ * 构建「新建文件(夹)」body。
31
+ *
32
+ * @internal 导出供单元测试。
33
+ */
34
+ export declare function buildDriveCreateFileBody(input: {
35
+ fileType: "folder" | "file" | "shortcut";
36
+ name: string;
37
+ fileId?: string;
38
+ onNameConflict?: "fail" | "rename" | "overwrite" | "replace";
39
+ parentPath?: string[];
40
+ }): Record<string, unknown>;
41
+ /**
42
+ * 构建「文档内容抽取」path。
43
+ *
44
+ * @internal 导出供单元测试。
45
+ */
46
+ export declare function buildDriveExtractContentPath(driveId: string, fileId: string): string;
47
+ /**
48
+ * 构建「文档内容抽取」query。
49
+ *
50
+ * @internal 导出供单元测试。
51
+ */
52
+ export declare function buildDriveExtractContentQuery(input: {
53
+ format?: string;
54
+ includeElements?: string[];
55
+ mode?: string;
56
+ taskId?: string;
57
+ }): Record<string, string | string[]>;
58
+ /**
59
+ * 构建「获取文件信息」path。
60
+ *
61
+ * @internal 导出供单元测试。
62
+ */
63
+ export declare function buildDriveFileMetaPath(fileId: string): string;
64
+ /**
65
+ * 构建「获取文件信息」query。
66
+ *
67
+ * @internal 导出供单元测试。
68
+ */
69
+ export declare function buildDriveFileMetaQuery(input: {
70
+ withPermission?: boolean;
71
+ withExtAttrs?: boolean;
72
+ withDrive?: boolean;
73
+ }): Record<string, boolean>;
74
+ /**
75
+ * 构建「文件搜索」query。
76
+ *
77
+ * @internal 导出供单元测试。
78
+ */
79
+ export declare function buildDriveFileSearchQuery(input: {
80
+ keyword?: string;
81
+ type: "file_name" | "content" | "all";
82
+ fileType?: "folder" | "file" | "shortcut";
83
+ fileExts?: string[];
84
+ driveIds?: string[];
85
+ parentIds?: string[];
86
+ creatorIds?: string[];
87
+ modifierIds?: string[];
88
+ sharerIds?: string[];
89
+ receiverIds?: string[];
90
+ timeType?: "ctime" | "mtime" | "otime" | "stime";
91
+ startTime?: number;
92
+ endTime?: number;
93
+ withPermission?: boolean;
94
+ withLink?: boolean;
95
+ withTotal?: boolean;
96
+ pageSize?: number;
97
+ pageToken?: string;
98
+ channels?: string[];
99
+ deviceIds?: string[];
100
+ excludeChannels?: string[];
101
+ excludeFileExts?: string[];
102
+ filterUserId?: number;
103
+ fileExtGroups?: string[];
104
+ withFolder?: boolean;
105
+ withDrive?: boolean;
106
+ order?: "desc" | "asc";
107
+ orderBy?: "ctime" | "mtime";
108
+ scope?: string[];
109
+ searchOperatorName?: boolean;
110
+ }): Record<string, string | number | boolean | string[]>;
111
+ export declare function registerDriveTools(_client: WpsClient, registerTool: (opts: ToolRegistration) => void): void;
112
+ //# sourceMappingURL=drive.d.ts.map
@@ -0,0 +1,24 @@
1
+ /**
2
+ * WPS OpenAPI tool registrations for OpenClaw (barrel).
3
+ *
4
+ * 所有工具在 register() 阶段注册为工厂函数。
5
+ * 工厂在 agent dispatch 时被调用,此时 lazy client 已就绪。
6
+ */
7
+ export { registerMessagingTools } from "./messaging.js";
8
+ export { registerUserTools } from "./user.js";
9
+ export { registerChatTools } from "./chat.js";
10
+ export { registerMediaTools } from "./media.js";
11
+ export { registerCalendarTools } from "./calendar.js";
12
+ export { registerTodoTools } from "./todo.js";
13
+ export { registerDriveTools } from "./drive.js";
14
+ /**
15
+ * Registers all WPS OAPI tools as factory functions during register() phase.
16
+ *
17
+ * Uses a Proxy client that defers actual WPS API calls to after startAccount().
18
+ *
19
+ * @returns Number of tools registered
20
+ */
21
+ export declare function registerAllOapiToolFactories(rawRegisterTool: (tool: unknown, opts?: {
22
+ name?: string;
23
+ }) => void): number;
24
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,32 @@
1
+ /**
2
+ * WPS OpenAPI media tools (download URL, upload phase-1 entry).
3
+ */
4
+ import type { WpsClient } from "../../core/wps-client.js";
5
+ import type { ToolRegistration, LogFacade } from "../../channel/types.js";
6
+ /**
7
+ * SHA256 digest of file bytes as lowercase hex, for POST `/v7/chats/resources/upload` field `checksum`.
8
+ * If the platform rejects the value, confirm the latest WPS OpenAPI doc for the required algorithm.
9
+ */
10
+ export declare function computeWpsUploadChecksum(bytes: Buffer): string;
11
+ /**
12
+ * True when `s` is almost certainly a local filesystem path (OpenClaw passes prefetched
13
+ * attachment paths here), not a WPS `storage_key`.
14
+ */
15
+ export declare function isLikelyLocalMediaPath(s: string): boolean;
16
+ export type WpsUploadBytesResult = {
17
+ storage_key: string;
18
+ file_name: string;
19
+ file_size: number;
20
+ };
21
+ /**
22
+ * POST /v7/chats/resources/upload + PUT to pre-signed URL. Shared by `wps_media_upload_base64` and channel sendMedia.
23
+ */
24
+ export declare function uploadBytesToWpsStorage(client: WpsClient, fileName: string, fileType: string, rawBytes: Buffer, log?: {
25
+ info?: (...args: unknown[]) => void;
26
+ error?: (...args: unknown[]) => void;
27
+ }): Promise<WpsUploadBytesResult>;
28
+ /**
29
+ * Registers WPS media OpenAPI tools (pre-signed download URL, upload entry).
30
+ */
31
+ export declare function registerMediaTools(client: WpsClient, registerTool: (opts: ToolRegistration) => void, log?: LogFacade): void;
32
+ //# sourceMappingURL=media.d.ts.map
@@ -0,0 +1,10 @@
1
+ /**
2
+ * WPS OpenAPI messaging tools (create, reply, list, get).
3
+ */
4
+ import type { WpsClient } from "../../core/wps-client.js";
5
+ import type { ToolRegistration } from "../../channel/types.js";
6
+ /**
7
+ * Registers WPS IM message tools against the OpenClaw plugin API.
8
+ */
9
+ export declare function registerMessagingTools(client: WpsClient, registerTool: (opts: ToolRegistration) => void): void;
10
+ //# sourceMappingURL=messaging.d.ts.map
@@ -0,0 +1,96 @@
1
+ /**
2
+ * WPS 个人待办工具 — 创建 / 列表(开放平台用户 delegated OAuth)。
3
+ *
4
+ * - **创建个人待办**:`POST /v7/todo/personal_tasks`
5
+ * - **获取个人待办列表**:`POST /v7/todo/personal_tasks/batch_get`
6
+ * - **获取个人待办详情**:`GET /v7/todo/personal_tasks/{task_id}`
7
+ * - **更新个人待办**:`POST /v7/todo/personal_tasks/{task_id}/update`(文档要求 `kso.task.readwrite`)
8
+ * - **更新个人待办状态**:`POST /v7/todo/personal_tasks/{task_id}/update_status`
9
+ * - 文档权限:`kso.task.readwrite` / `kso.task.read`(或控制台等价 delegated)
10
+ *
11
+ * HTTP 调用与日历工具一致:用户 `access_token` + `Authorization: Bearer`(`createUserWpsClient`)。
12
+ * 开放平台文档虽标注 KSO-1,与本插件其它用户态 OpenAPI 用法对齐。
13
+ */
14
+ import type { WpsClient } from "../../core/wps-client.js";
15
+ import type { ToolRegistration } from "../../channel/types.js";
16
+ /**
17
+ * `GET .../personal_tasks/{task_id}`(获取个人待办详情)。
18
+ *
19
+ * @internal 导出供单元测试。
20
+ */
21
+ export declare function buildPersonalTaskDetailPath(taskId: string): string;
22
+ /**
23
+ * `POST .../personal_tasks/{task_id}/update`(更新个人待办)。
24
+ *
25
+ * @internal 导出供单元测试。
26
+ */
27
+ export declare function buildPersonalTaskUpdatePath(taskId: string): string;
28
+ /**
29
+ * `POST .../personal_tasks/{task_id}/update_status`(更新个人待办状态)。
30
+ *
31
+ * @internal 导出供单元测试。
32
+ */
33
+ export declare function buildPersonalTaskUpdateStatusPath(taskId: string): string;
34
+ /**
35
+ * 构建「创建个人待办」请求体。必填只有 `title`(对象,含 `subject`;可选 `prefix`)。
36
+ * 时间与文档一致:`due_time` 为毫秒时间戳。
37
+ *
38
+ * @internal 导出供单元测试。
39
+ */
40
+ export declare function buildPersonalTaskCreateBody(input: {
41
+ titleSubject: string;
42
+ titlePrefix?: string;
43
+ description?: string;
44
+ dueTimeMs?: number;
45
+ status?: "todo" | "finish";
46
+ executors?: string[];
47
+ }): Record<string, unknown>;
48
+ /**
49
+ * 构建「获取个人待办列表」`batch_get` 请求体(字段均可选)。
50
+ * 时间字段与文档示例一致,单位为毫秒时间戳。
51
+ *
52
+ * @internal 导出供单元测试。
53
+ */
54
+ export declare function buildPersonalTasksBatchGetBody(input: {
55
+ keyword?: string;
56
+ executor?: string;
57
+ status?: "todo" | "finish";
58
+ pageSize?: number;
59
+ pageToken?: string;
60
+ createdTimeStartMs?: number;
61
+ createdTimeEndMs?: number;
62
+ dueTimeStartMs?: number;
63
+ dueTimeEndMs?: number;
64
+ }): Record<string, unknown>;
65
+ /**
66
+ * 构建「更新个人待办」请求体(字段均可选;至少须有一项,否则抛错)。
67
+ *
68
+ * @internal 导出供单元测试。
69
+ */
70
+ export declare function buildPersonalTaskUpdateBody(input: {
71
+ titleSubject?: string;
72
+ titlePrefix?: string;
73
+ description?: string;
74
+ dueTimeMs?: number;
75
+ extAttrs?: Array<{
76
+ name: string;
77
+ value: string;
78
+ }>;
79
+ notifyConfig?: Record<string, unknown>;
80
+ }): Record<string, unknown>;
81
+ /**
82
+ * 开放平台 `POST .../update_status` 请求体:仅含 **`action`**,枚举与文档一致。
83
+ *
84
+ * @internal 导出供单元测试。
85
+ * @see parsePersonalTaskUpdateStatusAction
86
+ */
87
+ export type PersonalTaskUpdateStatusAction = "finish" | "unfinish" | "finish_all" | "unfinish_all";
88
+ /** 仅接受开放平台文档枚举;不接受历史错误拼写(如 unfinished),不做兼容映射。 */
89
+ export declare function parsePersonalTaskUpdateStatusAction(raw: string): PersonalTaskUpdateStatusAction;
90
+ export declare function buildPersonalTaskUpdateStatusBody(input: {
91
+ action: string;
92
+ }): {
93
+ action: PersonalTaskUpdateStatusAction;
94
+ };
95
+ export declare function registerTodoTools(_client: WpsClient, registerTool: (opts: ToolRegistration) => void): void;
96
+ //# sourceMappingURL=todo.d.ts.map
@@ -0,0 +1,10 @@
1
+ /**
2
+ * WPS OpenAPI user tools (current user, search).
3
+ */
4
+ import type { WpsClient } from "../../core/wps-client.js";
5
+ import type { ToolRegistration } from "../../channel/types.js";
6
+ /**
7
+ * Registers WPS user-related OpenAPI tools.
8
+ */
9
+ export declare function registerUserTools(client: WpsClient, registerTool: (opts: ToolRegistration) => void): void;
10
+ //# sourceMappingURL=user.d.ts.map
@@ -0,0 +1,65 @@
1
+ /**
2
+ * WPS 用户 OAuth 授权模块。
3
+ *
4
+ * 职责:
5
+ * - 构建授权 URL(buildAuthorizeUrl)
6
+ * - 构建授权前/后卡片消息(buildAuthCard / buildAuthSuccessCard)
7
+ * - 发送授权卡片给用户(sendAuthCard)
8
+ * - 处理授权事件(handleAuthEvent:code 换 token;成功卡片优先使用 state 内记录的本次 scope 名称)
9
+ * - state 编解码(encode/decode,nonce Map + 10 分钟 TTL)
10
+ */
11
+ import type { AppCredentials, WpsConfig } from "../../core/index.js";
12
+ import type { LogFacade } from "../../channel/types.js";
13
+ export type OAuthState = {
14
+ wpsUserId: string;
15
+ receiverType: "user" | "chat";
16
+ receiverId: string;
17
+ nonce: string;
18
+ messageId?: string;
19
+ originalMessage?: string;
20
+ /** 本次 authorize URL 中的权限点名称(与卡片列表一致);授权回调更新「已完成」卡片时优先使用 */
21
+ requestedScopeNames?: string[];
22
+ };
23
+ export declare function encodeState(state: OAuthState): string;
24
+ export declare function decodeState(key: string): OAuthState | null;
25
+ export declare function buildAuthorizeUrl(opts: {
26
+ baseUrl: string;
27
+ appId: string;
28
+ scopes: string[];
29
+ state: string;
30
+ redirectUri: string;
31
+ }): string;
32
+ /** `scopes` 为权限点 **名称**(如 `kso.xxx`),用于卡片列表展示,须与 OAuth `scope=` 一致。 */
33
+ export declare function buildAuthCard(authorizeUrl: string, scopes: string[]): unknown;
34
+ /** `scopes` 为权限点 **名称**(如 `kso.xxx`),用于「已完成授权」列表展示。 */
35
+ export declare function buildAuthSuccessCard(scopes: string[]): unknown;
36
+ /** 卡片「将要授权的权限」列表展示权限点名称(`kso.*`)。未传 `scopes` 时使用 `GET /v7/developer/apps` 同步的全量 delegated。 */
37
+ export declare function sendAuthCard(opts: {
38
+ creds: AppCredentials;
39
+ wpsCfg: WpsConfig;
40
+ wpsUserId: string;
41
+ receiverType: "user" | "chat";
42
+ receiverId: string;
43
+ originalMessage?: string;
44
+ /** 若传入,OAuth `scope=` 与卡片列表均使用其中的名称(通常来自开放平台 delegated)。 */
45
+ scopes?: {
46
+ names: string[];
47
+ };
48
+ }): Promise<{
49
+ messageId: string;
50
+ authorizeUrl: string;
51
+ } | null>;
52
+ /**
53
+ * 处理 SDK 推送的用户授权事件。
54
+ * 从事件 payload 拿 code + state,换 token,更新卡片。
55
+ * state 可能为空(事件 payload 不一定包含 state),此时走 userId 兜底。
56
+ */
57
+ export declare function handleAuthEvent(opts: {
58
+ code: string;
59
+ state: string;
60
+ creds: AppCredentials;
61
+ wpsCfg: WpsConfig;
62
+ log?: LogFacade;
63
+ userId?: string;
64
+ }): Promise<void>;
65
+ //# sourceMappingURL=index.d.ts.map