@soimy/dingtalk 3.5.3 → 3.6.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/README.md +4 -1
- package/index.ts +7 -0
- package/openclaw.plugin.json +153 -5
- package/package.json +1 -1
- package/src/auth.ts +5 -2
- package/src/card/card-markdown-image-reroute.ts +106 -0
- package/src/card/card-run-registry.ts +54 -1
- package/src/card/card-stop-handler.ts +10 -20
- package/src/card/card-template.ts +14 -3
- package/src/card/statusline-renderer.ts +94 -0
- package/src/card-draft-controller.ts +245 -52
- package/src/card-service.ts +408 -23
- package/src/channel.ts +24 -1083
- package/src/config-schema.ts +21 -1
- package/src/config.ts +139 -66
- package/src/device-registration.ts +245 -0
- package/src/gateway/channel-gateway.ts +637 -0
- package/src/inbound-handler.ts +1276 -975
- package/src/media-utils.ts +6 -0
- package/src/message-context-store.ts +183 -85
- package/src/message-utils.ts +124 -16
- package/src/messaging/btw-deliver.ts +85 -0
- package/src/messaging/channel-actions.ts +174 -0
- package/src/messaging/channel-outbound.ts +158 -0
- package/src/onboarding.ts +333 -235
- package/src/path-utils.ts +49 -0
- package/src/platform/channel-status.ts +81 -0
- package/src/reply-strategy-card.ts +373 -64
- package/src/reply-strategy-markdown.ts +1 -1
- package/src/reply-strategy-types.ts +93 -0
- package/src/reply-strategy-with-reaction.ts +1 -1
- package/src/reply-strategy.ts +14 -72
- package/src/run-usage-store.ts +59 -0
- package/src/secret-input.ts +216 -0
- package/src/send-service.ts +115 -3
- package/src/session-state.ts +62 -0
- package/src/targeting/agent-name-matcher.ts +28 -0
- package/src/targeting/agent-routing.ts +30 -5
- package/src/types.ts +48 -157
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import * as os from "node:os";
|
|
2
|
+
import * as path from "node:path";
|
|
3
|
+
|
|
4
|
+
const WINDOWS_ROOT_DIRECTORIES = new Set([
|
|
5
|
+
"Users",
|
|
6
|
+
"Program Files",
|
|
7
|
+
"Program Files (x86)",
|
|
8
|
+
"ProgramData",
|
|
9
|
+
"Windows",
|
|
10
|
+
"Documents and Settings",
|
|
11
|
+
]);
|
|
12
|
+
|
|
13
|
+
export function resolveRelativePath(input: string): string {
|
|
14
|
+
const trimmed = input.trim();
|
|
15
|
+
if (!trimmed) {
|
|
16
|
+
return trimmed;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const segments = (value: string): string[] => value.split(/[\\/]+/).filter(Boolean);
|
|
20
|
+
const pathSegments = segments(trimmed);
|
|
21
|
+
const firstSegment = pathSegments[0];
|
|
22
|
+
|
|
23
|
+
if (trimmed === "~") {
|
|
24
|
+
return path.resolve(os.homedir());
|
|
25
|
+
}
|
|
26
|
+
if (trimmed.startsWith("~/") || trimmed.startsWith("~\\")) {
|
|
27
|
+
return path.resolve(os.homedir(), ...segments(trimmed.slice(2)));
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (process.platform === "win32") {
|
|
31
|
+
if (/^[a-zA-Z]:[\\/]/.test(trimmed)) {
|
|
32
|
+
return path.win32.normalize(trimmed);
|
|
33
|
+
}
|
|
34
|
+
if (firstSegment && /^[a-zA-Z]:$/.test(firstSegment)) {
|
|
35
|
+
return path.win32.resolve(`${firstSegment}\\`, ...pathSegments.slice(1));
|
|
36
|
+
}
|
|
37
|
+
if (firstSegment && WINDOWS_ROOT_DIRECTORIES.has(firstSegment)) {
|
|
38
|
+
return path.win32.resolve("\\", ...pathSegments);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (/^[\\/]/.test(trimmed)) {
|
|
43
|
+
return path.resolve(path.sep, ...pathSegments);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return path.resolve(process.cwd(), ...pathSegments);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export const resolveUserPath = resolveRelativePath;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { getAccessToken } from "../auth";
|
|
2
|
+
import type { DingTalkChannelPlugin } from "../types";
|
|
3
|
+
import { getCurrentTimestamp } from "../utils";
|
|
4
|
+
|
|
5
|
+
export function createDingTalkStatus(): NonNullable<DingTalkChannelPlugin["status"]> {
|
|
6
|
+
return {
|
|
7
|
+
defaultRuntime: {
|
|
8
|
+
accountId: "default",
|
|
9
|
+
running: false,
|
|
10
|
+
connected: false,
|
|
11
|
+
lastEventAt: null,
|
|
12
|
+
lastConnectedAt: null,
|
|
13
|
+
lastInboundAt: null,
|
|
14
|
+
lastStartAt: null,
|
|
15
|
+
lastStopAt: null,
|
|
16
|
+
lastError: null,
|
|
17
|
+
},
|
|
18
|
+
collectStatusIssues: (accounts: any[]) => {
|
|
19
|
+
return accounts.flatMap((account) => {
|
|
20
|
+
if (!account.configured) {
|
|
21
|
+
return [
|
|
22
|
+
{
|
|
23
|
+
channel: "dingtalk",
|
|
24
|
+
accountId: account.accountId,
|
|
25
|
+
kind: "config" as const,
|
|
26
|
+
message: "Account not configured (missing clientId or clientSecret)",
|
|
27
|
+
},
|
|
28
|
+
];
|
|
29
|
+
}
|
|
30
|
+
return [];
|
|
31
|
+
});
|
|
32
|
+
},
|
|
33
|
+
buildChannelSummary: ({ snapshot }: any) => ({
|
|
34
|
+
configured: snapshot?.configured ?? false,
|
|
35
|
+
running: snapshot?.running ?? false,
|
|
36
|
+
lastStartAt: snapshot?.lastStartAt ?? null,
|
|
37
|
+
lastStopAt: snapshot?.lastStopAt ?? null,
|
|
38
|
+
lastError: snapshot?.lastError ?? null,
|
|
39
|
+
}),
|
|
40
|
+
probeAccount: async ({ account, timeoutMs }: any) => {
|
|
41
|
+
if (!account.configured || !account.config?.clientId || !account.config?.clientSecret) {
|
|
42
|
+
return { ok: false, error: "Not configured" };
|
|
43
|
+
}
|
|
44
|
+
try {
|
|
45
|
+
const controller = new AbortController();
|
|
46
|
+
const timeoutId = timeoutMs ? setTimeout(() => controller.abort(), timeoutMs) : undefined;
|
|
47
|
+
try {
|
|
48
|
+
await getAccessToken(account.config);
|
|
49
|
+
return { ok: true, details: { clientId: account.config.clientId } };
|
|
50
|
+
} finally {
|
|
51
|
+
if (timeoutId) {
|
|
52
|
+
clearTimeout(timeoutId);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
} catch (error: any) {
|
|
56
|
+
return { ok: false, error: error.message };
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
buildAccountSnapshot: ({ account, runtime, snapshot, probe }: any) => {
|
|
60
|
+
const running = runtime?.running ?? snapshot?.running ?? false;
|
|
61
|
+
const persistedLastEventAt = runtime?.lastEventAt ?? snapshot?.lastEventAt ?? null;
|
|
62
|
+
|
|
63
|
+
return {
|
|
64
|
+
accountId: account.accountId,
|
|
65
|
+
name: account.name,
|
|
66
|
+
enabled: account.enabled,
|
|
67
|
+
configured: account.configured,
|
|
68
|
+
clientId: account.config?.clientId ?? null,
|
|
69
|
+
running,
|
|
70
|
+
connected: runtime?.connected ?? snapshot?.connected ?? null,
|
|
71
|
+
lastEventAt: running ? getCurrentTimestamp() : persistedLastEventAt,
|
|
72
|
+
lastConnectedAt: runtime?.lastConnectedAt ?? snapshot?.lastConnectedAt ?? null,
|
|
73
|
+
lastInboundAt: runtime?.lastInboundAt ?? snapshot?.lastInboundAt ?? null,
|
|
74
|
+
lastStartAt: runtime?.lastStartAt ?? snapshot?.lastStartAt ?? null,
|
|
75
|
+
lastStopAt: runtime?.lastStopAt ?? snapshot?.lastStopAt ?? null,
|
|
76
|
+
lastError: runtime?.lastError ?? snapshot?.lastError ?? null,
|
|
77
|
+
probe,
|
|
78
|
+
};
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
}
|