@junjiezhang/openclaw-wecom-plugin 1.0.0 → 1.0.2
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/index.js +1 -1
- package/openclaw.plugin.json +1 -1
- package/package.json +7 -1
- package/src/accounts.ts +0 -81
- package/src/bot.ts +0 -410
- package/src/channel.ts +0 -278
- package/src/client.ts +0 -55
- package/src/config-schema.ts +0 -102
- package/src/dedup.ts +0 -60
- package/src/directory.ts +0 -150
- package/src/index.ts +0 -20
- package/src/media.ts +0 -105
- package/src/monitor.ts +0 -344
- package/src/outbound.ts +0 -26
- package/src/policy.ts +0 -108
- package/src/probe.ts +0 -13
- package/src/reply-dispatcher.ts +0 -78
- package/src/runtime.ts +0 -14
- package/src/send.ts +0 -91
- package/src/targets.ts +0 -21
- package/src/types.d.ts +0 -17
- package/src/types.ts +0 -3
- package/tsconfig.json +0 -32
- package/types.d.ts +0 -43
package/src/send.ts
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import type { ClawdbotConfig } from "openclaw/plugin-sdk";
|
|
2
|
-
import { fetchWithSsrFGuard } from "openclaw/plugin-sdk";
|
|
3
|
-
import { resolveWeComCredentials } from "./accounts.js";
|
|
4
|
-
import { getWeComAccessToken } from "./client.js";
|
|
5
|
-
|
|
6
|
-
const WECOM_API_POLICY = { allowedHostnames: ["qyapi.weixin.qq.com"] };
|
|
7
|
-
|
|
8
|
-
export async function sendMessageWeCom({
|
|
9
|
-
cfg,
|
|
10
|
-
to,
|
|
11
|
-
text,
|
|
12
|
-
accountId,
|
|
13
|
-
}: {
|
|
14
|
-
cfg: ClawdbotConfig;
|
|
15
|
-
to: string;
|
|
16
|
-
text: string;
|
|
17
|
-
accountId?: string;
|
|
18
|
-
}): Promise<{ messageId: string }> {
|
|
19
|
-
const accessToken = await getWeComAccessToken({ cfg, accountId });
|
|
20
|
-
const { agentId } = resolveWeComCredentials({ cfg, accountId });
|
|
21
|
-
|
|
22
|
-
const url = `https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=${accessToken}`;
|
|
23
|
-
const { response, release } = await fetchWithSsrFGuard({
|
|
24
|
-
url,
|
|
25
|
-
init: {
|
|
26
|
-
method: "POST",
|
|
27
|
-
headers: { "Content-Type": "application/json" },
|
|
28
|
-
body: JSON.stringify({
|
|
29
|
-
touser: to,
|
|
30
|
-
msgtype: "text",
|
|
31
|
-
agentid: agentId,
|
|
32
|
-
text: { content: text },
|
|
33
|
-
}),
|
|
34
|
-
},
|
|
35
|
-
policy: WECOM_API_POLICY,
|
|
36
|
-
auditContext: "wecom-send-message",
|
|
37
|
-
});
|
|
38
|
-
let data: { errcode: number; errmsg: string; msgid?: string };
|
|
39
|
-
try {
|
|
40
|
-
data = await response.json();
|
|
41
|
-
} finally {
|
|
42
|
-
await release();
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
if (data.errcode !== 0) {
|
|
46
|
-
throw new Error(`WeCom send error ${data.errcode}: ${data.errmsg}`);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return { messageId: data.msgid ?? "" };
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Send message to group chat
|
|
54
|
-
*/
|
|
55
|
-
export async function sendGroupMessageWeCom({
|
|
56
|
-
cfg,
|
|
57
|
-
chatId,
|
|
58
|
-
text,
|
|
59
|
-
accountId,
|
|
60
|
-
}: {
|
|
61
|
-
cfg: ClawdbotConfig;
|
|
62
|
-
chatId: string;
|
|
63
|
-
text: string;
|
|
64
|
-
accountId?: string;
|
|
65
|
-
}): Promise<{ messageId: string }> {
|
|
66
|
-
const accessToken = await getWeComAccessToken({ cfg, accountId });
|
|
67
|
-
|
|
68
|
-
const url = `https://qyapi.weixin.qq.com/cgi-bin/appchat/send?access_token=${accessToken}`;
|
|
69
|
-
const { response, release } = await fetchWithSsrFGuard({
|
|
70
|
-
url,
|
|
71
|
-
init: {
|
|
72
|
-
method: "POST",
|
|
73
|
-
headers: { "Content-Type": "application/json" },
|
|
74
|
-
body: JSON.stringify({ chatid: chatId, msgtype: "text", text: { content: text } }),
|
|
75
|
-
},
|
|
76
|
-
policy: WECOM_API_POLICY,
|
|
77
|
-
auditContext: "wecom-send-group-message",
|
|
78
|
-
});
|
|
79
|
-
let data: { errcode: number; errmsg: string; msgid?: string };
|
|
80
|
-
try {
|
|
81
|
-
data = await response.json();
|
|
82
|
-
} finally {
|
|
83
|
-
await release();
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
if (data.errcode !== 0) {
|
|
87
|
-
throw new Error(`WeCom group send error ${data.errcode}: ${data.errmsg}`);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
return { messageId: data.msgid ?? "" };
|
|
91
|
-
}
|
package/src/targets.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export function normalizeWeComTarget(raw: string): string | null {
|
|
2
|
-
if (!raw) return null;
|
|
3
|
-
|
|
4
|
-
// Remove prefix if present
|
|
5
|
-
const cleaned = raw.replace(/^(wecom|user):/i, "");
|
|
6
|
-
|
|
7
|
-
// WeCom user IDs are typically alphanumeric
|
|
8
|
-
if (/^[a-zA-Z0-9_-]+$/.test(cleaned)) {
|
|
9
|
-
return cleaned;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
return null;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export function looksLikeWeComId(raw: string): boolean {
|
|
16
|
-
return /^[a-zA-Z0-9_-]+$/.test(raw);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export function formatWeComTarget(userId: string): string {
|
|
20
|
-
return `user:${userId}`;
|
|
21
|
-
}
|
package/src/types.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
// Type declarations for OpenClaw plugin-sdk
|
|
2
|
-
declare module "openclaw/plugin-sdk" {
|
|
3
|
-
export interface OpenClawPluginApi {
|
|
4
|
-
log: {
|
|
5
|
-
info: (msg: string) => void;
|
|
6
|
-
warn: (msg: string) => void;
|
|
7
|
-
error: (msg: string) => void;
|
|
8
|
-
};
|
|
9
|
-
registerChannel: (config: any) => void;
|
|
10
|
-
registerTool: (tool: any) => void;
|
|
11
|
-
registerCommand: (command: any) => void;
|
|
12
|
-
registerRpc: (rpc: any) => void;
|
|
13
|
-
runtime: any;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export function emptyPluginConfigSchema(): any;
|
|
17
|
-
}
|
package/src/types.ts
DELETED
package/tsconfig.json
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2022",
|
|
4
|
-
"module": "NodeNext",
|
|
5
|
-
"moduleResolution": "NodeNext",
|
|
6
|
-
"lib": ["ES2022"],
|
|
7
|
-
"outDir": "./dist",
|
|
8
|
-
"rootDir": "./src",
|
|
9
|
-
"strict": false,
|
|
10
|
-
"esModuleInterop": true,
|
|
11
|
-
"skipLibCheck": true,
|
|
12
|
-
"forceConsistentCasingInFileNames": true,
|
|
13
|
-
"resolveJsonModule": true,
|
|
14
|
-
"declaration": true,
|
|
15
|
-
"declarationMap": true,
|
|
16
|
-
"sourceMap": true,
|
|
17
|
-
"removeComments": true,
|
|
18
|
-
"noUnusedLocals": false,
|
|
19
|
-
"noUnusedParameters": false,
|
|
20
|
-
"noImplicitReturns": false,
|
|
21
|
-
"noFallthroughCasesInSwitch": false,
|
|
22
|
-
"noImplicitAny": false,
|
|
23
|
-
"noImplicitThis": false,
|
|
24
|
-
"typeRoots": ["./types.d.ts", "./node_modules/@types"],
|
|
25
|
-
"baseUrl": ".",
|
|
26
|
-
"paths": {
|
|
27
|
-
"openclaw/plugin-sdk": ["./types.d.ts"]
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
"include": ["src/**/*", "types.d.ts"],
|
|
31
|
-
"exclude": ["node_modules", "dist"]
|
|
32
|
-
}
|
package/types.d.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
// Type declarations for OpenClaw plugin-sdk
|
|
2
|
-
declare module "openclaw/plugin-sdk" {
|
|
3
|
-
export type ClawdbotConfig = any;
|
|
4
|
-
export type RuntimeEnv = any;
|
|
5
|
-
export type HistoryEntry = any;
|
|
6
|
-
export type ChannelMeta = any;
|
|
7
|
-
export type ChannelPlugin<T = any> = any;
|
|
8
|
-
export type ChannelOutboundAdapter = any;
|
|
9
|
-
export type AllowlistMatch<T = any> = any;
|
|
10
|
-
export type ChannelGroupContext = any;
|
|
11
|
-
export type GroupToolPolicyConfig = any;
|
|
12
|
-
export type ReplyPayload = any;
|
|
13
|
-
export type PluginRuntime = any;
|
|
14
|
-
|
|
15
|
-
export interface OpenClawPluginApi {
|
|
16
|
-
logger: any;
|
|
17
|
-
registerChannel: (config: any) => void;
|
|
18
|
-
registerTool: (tool: any) => void;
|
|
19
|
-
registerCommand: (command: any) => void;
|
|
20
|
-
registerRpc: (rpc: any) => void;
|
|
21
|
-
runtime: PluginRuntime;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export const DEFAULT_ACCOUNT_ID: string;
|
|
25
|
-
export const PAIRING_APPROVED_MESSAGE: string;
|
|
26
|
-
|
|
27
|
-
export function emptyPluginConfigSchema(): any;
|
|
28
|
-
export function buildAgentMediaPayload(...args: any[]): any;
|
|
29
|
-
export function buildBaseChannelStatusSummary(...args: any[]): any;
|
|
30
|
-
export function buildPendingHistoryContextFromMap(...args: any[]): any;
|
|
31
|
-
export function clearHistoryEntriesIfEnabled(...args: any[]): any;
|
|
32
|
-
export function createScopedPairingAccess(...args: any[]): any;
|
|
33
|
-
export function createDefaultChannelRuntimeState(...args: any[]): any;
|
|
34
|
-
export function recordPendingHistoryEntryIfEnabled(...args: any[]): any;
|
|
35
|
-
export function resolveDefaultGroupPolicy(...args: any[]): any;
|
|
36
|
-
export function resolveAllowlistProviderRuntimeGroupPolicy(...args: any[]): any;
|
|
37
|
-
export function fetchWithSsrFGuard(...args: any[]): any;
|
|
38
|
-
export function createDedupeCache(...args: any[]): any;
|
|
39
|
-
export function createPersistentDedupe(...args: any[]): any;
|
|
40
|
-
export function resolvePreferredOpenClawTmpDir(...args: any[]): any;
|
|
41
|
-
export function installRequestBodyLimitGuard(...args: any[]): any;
|
|
42
|
-
export function createReplyPrefixContext(...args: any[]): any;
|
|
43
|
-
}
|