opencode-plugin-wecom 0.0.0-stage → 0.1.1
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 +135 -2
- package/dist/gui-experimental.cjs +460 -0
- package/dist/index.d.ts +285 -0
- package/dist/index.js +1901 -0
- package/dist/rpc-CDRXKJwO.js +71 -0
- package/dist/rpc-D5Bs48Ma.d.ts +105 -0
- package/dist/rpc.d.ts +2 -0
- package/dist/rpc.js +3 -0
- package/package.json +56 -3
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
import { n as WecomRpc, t as PLUGIN_ID } from "./rpc-D5Bs48Ma.js";
|
|
2
|
+
import { Plugin } from "@opencode/plugin";
|
|
3
|
+
|
|
4
|
+
//#region src/types.d.ts
|
|
5
|
+
interface StorageScanOptions {
|
|
6
|
+
readonly prefix: string;
|
|
7
|
+
readonly after?: string;
|
|
8
|
+
readonly limit?: number;
|
|
9
|
+
}
|
|
10
|
+
interface StorageScanResult {
|
|
11
|
+
readonly entries: readonly {
|
|
12
|
+
readonly key: string;
|
|
13
|
+
readonly value: unknown;
|
|
14
|
+
}[];
|
|
15
|
+
readonly next?: string;
|
|
16
|
+
}
|
|
17
|
+
interface StorageAdapter {
|
|
18
|
+
get(key: string): Promise<unknown>;
|
|
19
|
+
set(key: string, value: unknown): Promise<void>;
|
|
20
|
+
remove(key: string): Promise<void>;
|
|
21
|
+
scan(options: StorageScanOptions): Promise<StorageScanResult>;
|
|
22
|
+
}
|
|
23
|
+
interface Clock {
|
|
24
|
+
now(): number;
|
|
25
|
+
monotonic(): number;
|
|
26
|
+
sleep(ms: number, signal?: AbortSignal): Promise<void>;
|
|
27
|
+
}
|
|
28
|
+
interface HttpRequest {
|
|
29
|
+
readonly method: 'GET' | 'POST';
|
|
30
|
+
readonly url: string;
|
|
31
|
+
readonly headers: Record<string, string>;
|
|
32
|
+
readonly body?: string;
|
|
33
|
+
readonly timeoutMs: number;
|
|
34
|
+
readonly maxBytes: number;
|
|
35
|
+
readonly signal?: AbortSignal;
|
|
36
|
+
}
|
|
37
|
+
interface HttpResponse {
|
|
38
|
+
readonly status: number;
|
|
39
|
+
readonly body: string;
|
|
40
|
+
}
|
|
41
|
+
type HttpTransport = (request: HttpRequest) => Promise<HttpResponse>;
|
|
42
|
+
declare class WecomError extends Error {
|
|
43
|
+
readonly code: string;
|
|
44
|
+
readonly definitive: boolean;
|
|
45
|
+
constructor(code: string, definitive?: boolean);
|
|
46
|
+
}
|
|
47
|
+
//#endregion
|
|
48
|
+
//#region src/wecom/cli.d.ts
|
|
49
|
+
declare const ALLOWED_CLI_DOMAINS: readonly ["doc", "smartsheet", "calendar", "meeting", "mail", "wedrive", "contact", "auth"];
|
|
50
|
+
type WecomCliDomain = (typeof ALLOWED_CLI_DOMAINS)[number];
|
|
51
|
+
interface ProcessRunResult {
|
|
52
|
+
readonly exitCode: number;
|
|
53
|
+
readonly stdout: string;
|
|
54
|
+
readonly stderr: string;
|
|
55
|
+
}
|
|
56
|
+
type ProcessRunner = (binary: string, args: readonly string[], options: {
|
|
57
|
+
readonly timeoutMs: number;
|
|
58
|
+
readonly signal?: AbortSignal;
|
|
59
|
+
}) => Promise<ProcessRunResult>;
|
|
60
|
+
interface WecomCliProbe {
|
|
61
|
+
readonly available: boolean;
|
|
62
|
+
readonly binary: string;
|
|
63
|
+
readonly version?: string;
|
|
64
|
+
readonly install_hint?: string;
|
|
65
|
+
}
|
|
66
|
+
interface WecomCliRunInput {
|
|
67
|
+
readonly domain: WecomCliDomain;
|
|
68
|
+
readonly args: readonly string[];
|
|
69
|
+
readonly timeout_ms?: number;
|
|
70
|
+
}
|
|
71
|
+
interface WecomCliRunResult {
|
|
72
|
+
readonly ok: boolean;
|
|
73
|
+
readonly exit_code: number;
|
|
74
|
+
readonly domain: WecomCliDomain;
|
|
75
|
+
readonly data?: unknown;
|
|
76
|
+
readonly stdout: string;
|
|
77
|
+
readonly stderr: string;
|
|
78
|
+
}
|
|
79
|
+
interface WecomCliBridgeOptions {
|
|
80
|
+
readonly binary?: string;
|
|
81
|
+
readonly allowWrite?: boolean;
|
|
82
|
+
readonly runner?: ProcessRunner;
|
|
83
|
+
}
|
|
84
|
+
declare class WecomCliBridge {
|
|
85
|
+
private readonly binary;
|
|
86
|
+
private readonly allowWrite;
|
|
87
|
+
private readonly runner;
|
|
88
|
+
constructor(options?: WecomCliBridgeOptions);
|
|
89
|
+
probe(signal?: AbortSignal): Promise<WecomCliProbe>;
|
|
90
|
+
run(input: WecomCliRunInput, signal?: AbortSignal): Promise<WecomCliRunResult>;
|
|
91
|
+
}
|
|
92
|
+
//#endregion
|
|
93
|
+
//#region src/auth/workbuddy.d.ts
|
|
94
|
+
declare const WORKBUDDY_ORIGIN = "https://www.workbuddy.cn";
|
|
95
|
+
declare const WECOM_LOGIN_URL = "https://www.workbuddy.cn/login/wecom-auth";
|
|
96
|
+
type AuthPhase = 'logged_out' | 'pending_token' | 'pending_account' | 'ready' | 'refresh_unknown' | 'login_required' | 'account_changed';
|
|
97
|
+
interface WecomCredential {
|
|
98
|
+
access_token: string;
|
|
99
|
+
identity: string;
|
|
100
|
+
expires_at_ms: number;
|
|
101
|
+
source: 'workbuddy_cloud';
|
|
102
|
+
}
|
|
103
|
+
interface WorkBuddyStatus {
|
|
104
|
+
phase: AuthPhase;
|
|
105
|
+
desktop_required: false;
|
|
106
|
+
cloud_dependency: string;
|
|
107
|
+
account_expires_at_ms: number | null;
|
|
108
|
+
refresh_expires_at_ms: number | null;
|
|
109
|
+
refresh_credential_present: boolean;
|
|
110
|
+
wecom_expires_at_ms: number | null;
|
|
111
|
+
wecom_configured: boolean;
|
|
112
|
+
authorization_verified: boolean;
|
|
113
|
+
}
|
|
114
|
+
interface StartLoginResult {
|
|
115
|
+
phase: 'pending_token';
|
|
116
|
+
authorization_url: string;
|
|
117
|
+
}
|
|
118
|
+
interface FinishLoginResult {
|
|
119
|
+
phase: 'pending_token' | 'pending_account' | 'ready';
|
|
120
|
+
desktop_required?: false;
|
|
121
|
+
cloud_dependency?: string;
|
|
122
|
+
}
|
|
123
|
+
interface WecomLoginInfo {
|
|
124
|
+
authorization_url: string;
|
|
125
|
+
instruction: string;
|
|
126
|
+
}
|
|
127
|
+
interface WorkBuddyAuthOptions {
|
|
128
|
+
storage: StorageAdapter;
|
|
129
|
+
transport?: HttpTransport;
|
|
130
|
+
clock?: Clock;
|
|
131
|
+
onAuthChange?: (status: WorkBuddyStatus) => void | Promise<void>;
|
|
132
|
+
}
|
|
133
|
+
declare function formatLoginUrl(rawUrl: string): string;
|
|
134
|
+
declare class WorkBuddyAuth {
|
|
135
|
+
private readonly storage;
|
|
136
|
+
private readonly transport;
|
|
137
|
+
private readonly clock;
|
|
138
|
+
private readonly onAuthChange?;
|
|
139
|
+
private readonly lock;
|
|
140
|
+
constructor(options: WorkBuddyAuthOptions);
|
|
141
|
+
private load;
|
|
142
|
+
private save;
|
|
143
|
+
private toStatus;
|
|
144
|
+
private requestCloud;
|
|
145
|
+
status(): Promise<WorkBuddyStatus>;
|
|
146
|
+
wecomLoginInfo(): WecomLoginInfo;
|
|
147
|
+
start(options?: {
|
|
148
|
+
signal?: AbortSignal;
|
|
149
|
+
}): Promise<StartLoginResult>;
|
|
150
|
+
private fetchAccount;
|
|
151
|
+
finish(options?: {
|
|
152
|
+
signal?: AbortSignal;
|
|
153
|
+
deadlineMonoMs?: number;
|
|
154
|
+
}): Promise<FinishLoginResult>;
|
|
155
|
+
waitForLogin(options: {
|
|
156
|
+
waitSeconds: number;
|
|
157
|
+
signal?: AbortSignal;
|
|
158
|
+
exchangeWecom?: boolean;
|
|
159
|
+
}): Promise<WorkBuddyStatus>;
|
|
160
|
+
private refreshAccount;
|
|
161
|
+
private cachedWecom;
|
|
162
|
+
ensureWecom(options?: {
|
|
163
|
+
force?: boolean;
|
|
164
|
+
refreshAccount?: boolean;
|
|
165
|
+
deadlineMonoMs?: number;
|
|
166
|
+
signal?: AbortSignal;
|
|
167
|
+
}): Promise<WecomCredential>;
|
|
168
|
+
logout(): Promise<WorkBuddyStatus>;
|
|
169
|
+
}
|
|
170
|
+
//#endregion
|
|
171
|
+
//#region src/a2a/client.d.ts
|
|
172
|
+
type DayuanAction = 'search_groups' | 'read_chat' | 'search_messages';
|
|
173
|
+
type A2ATaskState = 'submitted' | 'working' | 'input_required' | 'completed' | 'failed' | 'canceled' | 'rejected' | 'unknown';
|
|
174
|
+
type InteractionKind = 'none' | 'text_clarification' | 'approval_required' | 'unsupported';
|
|
175
|
+
interface SearchGroupsInput {
|
|
176
|
+
readonly action: 'search_groups';
|
|
177
|
+
readonly query: string;
|
|
178
|
+
readonly limit?: number;
|
|
179
|
+
readonly request_id?: string;
|
|
180
|
+
readonly wait_seconds?: number;
|
|
181
|
+
}
|
|
182
|
+
interface ReadChatInput {
|
|
183
|
+
readonly action: 'read_chat';
|
|
184
|
+
readonly chat_name: string;
|
|
185
|
+
readonly question: string;
|
|
186
|
+
readonly time_range?: string;
|
|
187
|
+
readonly request_id?: string;
|
|
188
|
+
readonly wait_seconds?: number;
|
|
189
|
+
}
|
|
190
|
+
interface SearchMessagesInput {
|
|
191
|
+
readonly action: 'search_messages';
|
|
192
|
+
readonly query: string;
|
|
193
|
+
readonly chat_name?: string;
|
|
194
|
+
readonly time_range?: string;
|
|
195
|
+
readonly request_id?: string;
|
|
196
|
+
readonly wait_seconds?: number;
|
|
197
|
+
}
|
|
198
|
+
type DayuanReadStartInput = SearchGroupsInput | ReadChatInput | SearchMessagesInput;
|
|
199
|
+
interface DayuanReadResultInput {
|
|
200
|
+
readonly task_id: string;
|
|
201
|
+
readonly wait_seconds?: number;
|
|
202
|
+
}
|
|
203
|
+
interface DayuanReadReplyInput {
|
|
204
|
+
readonly task_id: string;
|
|
205
|
+
readonly text: string;
|
|
206
|
+
readonly request_id?: string;
|
|
207
|
+
readonly wait_seconds?: number;
|
|
208
|
+
}
|
|
209
|
+
interface DayuanProgressUpdate {
|
|
210
|
+
readonly task_id: string;
|
|
211
|
+
readonly state: A2ATaskState;
|
|
212
|
+
readonly poll_count: number;
|
|
213
|
+
}
|
|
214
|
+
interface DayuanCallOptions {
|
|
215
|
+
readonly signal?: AbortSignal;
|
|
216
|
+
readonly onProgress?: (update: DayuanProgressUpdate) => void | Promise<void>;
|
|
217
|
+
}
|
|
218
|
+
interface DayuanTaskResult {
|
|
219
|
+
readonly task_id: string;
|
|
220
|
+
readonly context_id?: string;
|
|
221
|
+
readonly request_id?: string;
|
|
222
|
+
readonly action?: DayuanAction;
|
|
223
|
+
readonly state: A2ATaskState;
|
|
224
|
+
readonly completed: boolean;
|
|
225
|
+
readonly is_summary: true;
|
|
226
|
+
readonly summary: string;
|
|
227
|
+
readonly interaction_kind: InteractionKind;
|
|
228
|
+
readonly can_reply_in_text: boolean;
|
|
229
|
+
readonly human_action_required: boolean;
|
|
230
|
+
readonly guidance?: string;
|
|
231
|
+
readonly from_cache: boolean;
|
|
232
|
+
readonly updated_at_ms: number;
|
|
233
|
+
}
|
|
234
|
+
interface DayuanReceiptSummary {
|
|
235
|
+
readonly request_id: string;
|
|
236
|
+
readonly action: DayuanAction;
|
|
237
|
+
readonly status: 'submit_unknown' | A2ATaskState;
|
|
238
|
+
readonly task_id?: string;
|
|
239
|
+
readonly summary_preview?: string;
|
|
240
|
+
readonly updated_at_ms: number;
|
|
241
|
+
}
|
|
242
|
+
interface WecomCredentialProvider {
|
|
243
|
+
ensureWecom(options?: {
|
|
244
|
+
force?: boolean;
|
|
245
|
+
refreshAccount?: boolean;
|
|
246
|
+
deadlineMonoMs?: number;
|
|
247
|
+
signal?: AbortSignal;
|
|
248
|
+
}): Promise<WecomCredential>;
|
|
249
|
+
}
|
|
250
|
+
interface DayuanA2AClientOptions {
|
|
251
|
+
readonly auth: WecomCredentialProvider;
|
|
252
|
+
readonly storage: StorageAdapter;
|
|
253
|
+
readonly transport?: HttpTransport;
|
|
254
|
+
readonly clock?: Clock;
|
|
255
|
+
}
|
|
256
|
+
declare class DayuanA2AClient {
|
|
257
|
+
private readonly auth;
|
|
258
|
+
private readonly storage;
|
|
259
|
+
private readonly transport;
|
|
260
|
+
private readonly clock;
|
|
261
|
+
private readonly lock;
|
|
262
|
+
constructor(options: DayuanA2AClientOptions);
|
|
263
|
+
private receiptKey;
|
|
264
|
+
private taskKey;
|
|
265
|
+
private parseTaskPayload;
|
|
266
|
+
private requestA2A;
|
|
267
|
+
private saveTaskRecord;
|
|
268
|
+
private loadTaskRecord;
|
|
269
|
+
private pollTask;
|
|
270
|
+
start(input: DayuanReadStartInput, options?: DayuanCallOptions): Promise<DayuanTaskResult>;
|
|
271
|
+
getResult(input: DayuanReadResultInput, options?: DayuanCallOptions): Promise<DayuanTaskResult>;
|
|
272
|
+
reply(input: DayuanReadReplyInput, options?: DayuanCallOptions): Promise<DayuanTaskResult>;
|
|
273
|
+
listReceipts(limit?: number): Promise<DayuanReceiptSummary[]>;
|
|
274
|
+
}
|
|
275
|
+
//#endregion
|
|
276
|
+
//#region src/index.d.ts
|
|
277
|
+
interface WecomPluginDeps {
|
|
278
|
+
readonly transport?: HttpTransport;
|
|
279
|
+
readonly clock?: Clock;
|
|
280
|
+
readonly cliRunner?: ProcessRunner;
|
|
281
|
+
}
|
|
282
|
+
declare function createWecomPlugin(deps?: WecomPluginDeps): Plugin.Plugin;
|
|
283
|
+
declare const _default: Plugin.Plugin;
|
|
284
|
+
//#endregion
|
|
285
|
+
export { ALLOWED_CLI_DOMAINS, DayuanA2AClient, PLUGIN_ID, WECOM_LOGIN_URL, WORKBUDDY_ORIGIN, WecomCliBridge, WecomError, WecomPluginDeps, WecomRpc, WorkBuddyAuth, createWecomPlugin, _default as default, formatLoginUrl };
|