@soimy/dingtalk 3.5.2 → 3.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.
- package/README.md +6 -23
- package/index.ts +7 -0
- package/openclaw.plugin.json +799 -0
- package/package.json +5 -5
- 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-streaming-mode.ts +30 -0
- package/src/card/card-template.ts +14 -3
- package/src/card/reasoning-answer-split.ts +162 -0
- package/src/card/statusline-renderer.ts +94 -0
- package/src/card-draft-controller.ts +326 -54
- package/src/card-service.ts +479 -8
- package/src/channel.ts +19 -1062
- package/src/config-schema.ts +81 -38
- package/src/config.ts +142 -4
- package/src/device-registration.ts +245 -0
- package/src/gateway/channel-gateway.ts +636 -0
- package/src/inbound-handler.ts +489 -49
- package/src/media-utils.ts +169 -7
- package/src/message-utils.ts +153 -17
- package/src/messaging/btw-deliver.ts +85 -0
- package/src/messaging/channel-actions.ts +173 -0
- package/src/messaging/channel-outbound.ts +158 -0
- package/src/messaging/quoted-file-service.ts +9 -4
- package/src/onboarding.ts +323 -205
- package/src/platform/channel-status.ts +81 -0
- package/src/plugin-sdk-channel-actions-augment.ts +11 -0
- package/src/reply-strategy-card.ts +568 -44
- package/src/reply-strategy-markdown.ts +2 -2
- package/src/reply-strategy-types.ts +93 -0
- package/src/reply-strategy-with-reaction.ts +1 -1
- package/src/reply-strategy.ts +14 -56
- package/src/run-usage-store.ts +59 -0
- package/src/send-service.ts +225 -7
- package/src/session-state.ts +62 -0
- package/src/targeting/agent-name-matcher.ts +28 -0
- package/src/targeting/agent-routing.ts +44 -28
- package/src/types.ts +49 -117
- package/src/utils.ts +25 -0
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ChannelMessageActionAdapter } from "openclaw/plugin-sdk/channel-contract";
|
|
2
|
+
|
|
3
|
+
type JsonResultReturn = NonNullable<ChannelMessageActionAdapter["handleAction"]> extends (
|
|
4
|
+
...args: unknown[]
|
|
5
|
+
) => Promise<infer TResult>
|
|
6
|
+
? TResult
|
|
7
|
+
: never;
|
|
8
|
+
|
|
9
|
+
declare module "openclaw/plugin-sdk/channel-actions" {
|
|
10
|
+
export function jsonResult(payload: unknown): JsonResultReturn;
|
|
11
|
+
}
|