@yanhaidao/wecom 2.4.160 → 2.5.110
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 +68 -0
- package/dist/src/accounts.js +20 -0
- package/dist/src/agent/handler.js +895 -0
- package/dist/src/agent/index.js +5 -0
- package/dist/src/app/account-runtime.js +216 -0
- package/dist/src/app/bootstrap.js +19 -0
- package/dist/src/app/index.js +118 -0
- package/dist/src/capability/agent/delivery-service.js +63 -0
- package/dist/src/capability/agent/fallback-policy.js +6 -0
- package/dist/src/capability/agent/ingress-service.js +33 -0
- package/dist/src/capability/agent/upstream-delivery-service.js +71 -0
- package/dist/src/capability/bot/dispatch-config.js +45 -0
- package/dist/src/capability/bot/fallback-delivery.js +147 -0
- package/dist/src/capability/bot/local-path-delivery.js +178 -0
- package/dist/src/capability/bot/sandbox-media.js +138 -0
- package/dist/src/capability/bot/service.js +49 -0
- package/dist/src/capability/bot/stream-delivery.js +321 -0
- package/dist/src/capability/bot/stream-finalizer.js +81 -0
- package/dist/src/capability/bot/stream-orchestrator.js +318 -0
- package/dist/src/capability/bot/types.js +1 -0
- package/{src/capability/calendar/client.ts → dist/src/capability/calendar/client.js} +118 -241
- package/{src/capability/calendar/schema.ts → dist/src/capability/calendar/schema.js} +0 -38
- package/dist/src/capability/calendar/tool.js +365 -0
- package/dist/src/capability/calendar/types.js +12 -0
- package/{src/capability/doc/client.ts → dist/src/capability/doc/client.js} +370 -605
- package/{src/capability/doc/schema.ts → dist/src/capability/doc/schema.js} +345 -394
- package/dist/src/capability/doc/tool.js +1556 -0
- package/dist/src/capability/doc/types.js +113 -0
- package/dist/src/capability/mcp/index.js +3 -0
- package/dist/src/capability/mcp/schema.js +102 -0
- package/dist/src/capability/mcp/tool.js +146 -0
- package/dist/src/capability/mcp/transport.js +293 -0
- package/dist/src/channel.js +224 -0
- package/dist/src/config/accounts.js +236 -0
- package/dist/src/config/derived-paths.js +31 -0
- package/dist/src/config/index.js +7 -0
- package/dist/src/config/media.js +110 -0
- package/dist/src/config/network.js +32 -0
- package/dist/src/config/routing.js +20 -0
- package/dist/src/config/runtime-config.js +25 -0
- package/dist/src/config/schema.js +4 -0
- package/{src/config-schema.ts → dist/src/config-schema.js} +1 -1
- package/dist/src/context-store.js +219 -0
- package/{src/crypto/aes.ts → dist/src/crypto/aes.js} +11 -28
- package/dist/src/crypto/index.js +9 -0
- package/{src/crypto/signature.ts → dist/src/crypto/signature.js} +3 -18
- package/{src/crypto/xml.ts → dist/src/crypto/xml.js} +3 -11
- package/dist/src/crypto.js +145 -0
- package/dist/src/domain/models.js +1 -0
- package/dist/src/domain/policies.js +32 -0
- package/{src/dynamic-agent.ts → dist/src/dynamic-agent.js} +36 -73
- package/dist/src/gateway-monitor.js +139 -0
- package/dist/src/http.js +114 -0
- package/{src/media.ts → dist/src/media.js} +21 -40
- package/dist/src/monitor/limits.js +7 -0
- package/dist/src/monitor/state.js +28 -0
- package/dist/src/monitor.js +84 -0
- package/dist/src/observability/audit-log.js +30 -0
- package/dist/src/observability/legacy-operational-event-store.js +22 -0
- package/dist/src/observability/raw-envelope-log.js +24 -0
- package/dist/src/observability/status-registry.js +9 -0
- package/dist/src/observability/transport-session-view.js +14 -0
- package/dist/src/onboarding.js +546 -0
- package/dist/src/outbound.js +557 -0
- package/dist/src/runtime/dispatcher.js +57 -0
- package/{src/runtime/index.ts → dist/src/runtime/index.js} +0 -1
- package/dist/src/runtime/outbound-intent.js +1 -0
- package/dist/src/runtime/reply-orchestrator.js +38 -0
- package/dist/src/runtime/routing-bridge.js +26 -0
- package/dist/src/runtime/session-manager.js +112 -0
- package/dist/src/runtime/source-registry.js +174 -0
- package/dist/src/runtime.js +1 -0
- package/dist/src/shared/command-auth.js +57 -0
- package/{src/shared/index.ts → dist/src/shared/index.js} +0 -1
- package/dist/src/shared/media-asset.js +65 -0
- package/dist/src/shared/media-service.js +59 -0
- package/dist/src/shared/media-types.js +1 -0
- package/{src/shared/xml-parser.ts → dist/src/shared/xml-parser.js} +72 -63
- package/dist/src/store/active-reply-store.js +41 -0
- package/dist/src/store/interfaces.js +1 -0
- package/dist/src/store/memory-store.js +33 -0
- package/dist/src/store/stream-batch-store.js +319 -0
- package/{src/target.ts → dist/src/target.js} +15 -48
- package/dist/src/transport/agent-api/client.js +168 -0
- package/dist/src/transport/agent-api/core.js +337 -0
- package/dist/src/transport/agent-api/delivery.js +28 -0
- package/dist/src/transport/agent-api/media-upload.js +4 -0
- package/dist/src/transport/agent-api/reply.js +24 -0
- package/dist/src/transport/agent-api/upstream-delivery.js +30 -0
- package/dist/src/transport/agent-api/upstream-media-upload.js +46 -0
- package/dist/src/transport/agent-api/upstream-reply.js +26 -0
- package/dist/src/transport/agent-callback/http-handler.js +30 -0
- package/dist/src/transport/agent-callback/inbound.js +4 -0
- package/dist/src/transport/agent-callback/reply.js +8 -0
- package/dist/src/transport/agent-callback/request-handler.js +189 -0
- package/dist/src/transport/agent-callback/session.js +15 -0
- package/dist/src/transport/bot-webhook/active-reply.js +27 -0
- package/dist/src/transport/bot-webhook/http-handler.js +31 -0
- package/dist/src/transport/bot-webhook/inbound-normalizer.js +496 -0
- package/dist/src/transport/bot-webhook/inbound.js +4 -0
- package/dist/src/transport/bot-webhook/message-shape.js +98 -0
- package/dist/src/transport/bot-webhook/protocol.js +124 -0
- package/dist/src/transport/bot-webhook/reply.js +9 -0
- package/dist/src/transport/bot-webhook/request-handler.js +285 -0
- package/dist/src/transport/bot-webhook/session.js +15 -0
- package/dist/src/transport/bot-ws/inbound.js +147 -0
- package/dist/src/transport/bot-ws/media.js +236 -0
- package/dist/src/transport/bot-ws/reply.js +310 -0
- package/dist/src/transport/bot-ws/sdk-adapter.js +257 -0
- package/dist/src/transport/bot-ws/session.js +15 -0
- package/dist/src/transport/http/common.js +78 -0
- package/dist/src/transport/http/registry.js +71 -0
- package/dist/src/transport/http/request-handler.js +51 -0
- package/{src/transport/index.ts → dist/src/transport/index.js} +2 -10
- package/dist/src/types/account.js +1 -0
- package/dist/src/types/config.js +1 -0
- package/dist/src/types/constants.js +28 -0
- package/dist/src/types/events.js +1 -0
- package/dist/src/types/index.js +1 -0
- package/dist/src/types/legacy-stream.js +1 -0
- package/dist/src/types/message.js +5 -0
- package/dist/src/types/runtime-context.js +1 -0
- package/dist/src/types/runtime.js +1 -0
- package/dist/src/types.js +1 -0
- package/dist/src/upstream/index.js +111 -0
- package/dist/src/wecom_msg_adapter/markdown_adapter.js +280 -0
- package/openclaw.plugin.json +15 -0
- package/package.json +18 -1
- package/.github/workflows/release.yml +0 -143
- package/GOVERNANCE.md +0 -26
- package/SKILLS_CAL.md +0 -895
- package/SKILLS_DOC.md +0 -2288
- package/UPSTREAM_CONFIG.md +0 -170
- package/UPSTREAM_PLAN.md +0 -175
- package/assets/01.bot-add.png +0 -0
- package/assets/01.bot-setp2.png +0 -0
- package/assets/01.image.jpg +0 -0
- package/assets/02.agent.add.png +0 -0
- package/assets/02.agent.api-set.png +0 -0
- package/assets/02.image.jpg +0 -0
- package/assets/03.agent.page.png +0 -0
- package/assets/03.bot.page.png +0 -0
- package/assets/link-me.jpg +0 -0
- package/assets/register.png +0 -0
- package/changelog/v2.2.28.md +0 -70
- package/changelog/v2.3.10.md +0 -17
- package/changelog/v2.3.11.md +0 -19
- package/changelog/v2.3.12.md +0 -25
- package/changelog/v2.3.13.md +0 -19
- package/changelog/v2.3.14.md +0 -48
- package/changelog/v2.3.15.md +0 -15
- package/changelog/v2.3.16.md +0 -11
- package/changelog/v2.3.18.md +0 -22
- package/changelog/v2.3.19.md +0 -73
- package/changelog/v2.3.2.md +0 -28
- package/changelog/v2.3.26.md +0 -21
- package/changelog/v2.3.27.md +0 -33
- package/changelog/v2.3.4.md +0 -20
- package/changelog/v2.3.9.md +0 -22
- package/changelog/v2.4.12.md +0 -37
- package/changelog/v2.4.16.md +0 -19
- package/compat-single-account.md +0 -148
- package/index.test.ts +0 -38
- package/scripts/test-proxy.ts +0 -70
- package/src/accounts.ts +0 -34
- package/src/agent/api-client.upload.test.ts +0 -109
- package/src/agent/handler.event-filter.test.ts +0 -100
- package/src/agent/handler.ts +0 -1105
- package/src/agent/index.ts +0 -12
- package/src/app/account-runtime.ts +0 -276
- package/src/app/bootstrap.ts +0 -29
- package/src/app/index.ts +0 -192
- package/src/capability/agent/delivery-service.ts +0 -87
- package/src/capability/agent/fallback-policy.ts +0 -13
- package/src/capability/agent/ingress-service.ts +0 -38
- package/src/capability/agent/upstream-delivery-service.ts +0 -96
- package/src/capability/bot/dispatch-config.ts +0 -47
- package/src/capability/bot/fallback-delivery.ts +0 -178
- package/src/capability/bot/local-path-delivery.ts +0 -215
- package/src/capability/bot/sandbox-media.test.ts +0 -221
- package/src/capability/bot/sandbox-media.ts +0 -176
- package/src/capability/bot/service.ts +0 -56
- package/src/capability/bot/stream-delivery.ts +0 -379
- package/src/capability/bot/stream-finalizer.ts +0 -120
- package/src/capability/bot/stream-orchestrator.ts +0 -371
- package/src/capability/bot/types.ts +0 -8
- package/src/capability/calendar/SKILLS_CHECKLIST.md +0 -251
- package/src/capability/calendar/tool.ts +0 -417
- package/src/capability/calendar/types.ts +0 -309
- package/src/capability/doc/tool.ts +0 -1629
- package/src/capability/doc/types.ts +0 -792
- package/src/capability/mcp/index.ts +0 -10
- package/src/capability/mcp/schema.ts +0 -107
- package/src/capability/mcp/tool.ts +0 -174
- package/src/capability/mcp/transport.ts +0 -394
- package/src/channel.config.test.ts +0 -147
- package/src/channel.lifecycle.test.ts +0 -255
- package/src/channel.meta.test.ts +0 -26
- package/src/channel.ts +0 -256
- package/src/config/accounts.resolve.test.ts +0 -75
- package/src/config/accounts.ts +0 -296
- package/src/config/derived-paths.test.ts +0 -111
- package/src/config/derived-paths.ts +0 -41
- package/src/config/index.ts +0 -26
- package/src/config/media.test.ts +0 -113
- package/src/config/media.ts +0 -139
- package/src/config/network.ts +0 -53
- package/src/config/routing.test.ts +0 -88
- package/src/config/routing.ts +0 -26
- package/src/config/runtime-config.ts +0 -46
- package/src/config/schema.ts +0 -90
- package/src/context-store.ts +0 -297
- package/src/crypto/index.ts +0 -24
- package/src/crypto.test.ts +0 -32
- package/src/crypto.ts +0 -176
- package/src/domain/models.ts +0 -7
- package/src/domain/policies.ts +0 -36
- package/src/dynamic-agent.account-scope.test.ts +0 -17
- package/src/gateway-monitor.ts +0 -181
- package/src/http.ts +0 -145
- package/src/media.test.ts +0 -82
- package/src/monitor/limits.ts +0 -7
- package/src/monitor/state.queue.test.ts +0 -185
- package/src/monitor/state.ts +0 -34
- package/src/monitor.active.test.ts +0 -245
- package/src/monitor.inbound-filter.test.ts +0 -63
- package/src/monitor.integration.test.ts +0 -208
- package/src/monitor.ts +0 -121
- package/src/monitor.webhook.test.ts +0 -774
- package/src/observability/audit-log.ts +0 -48
- package/src/observability/legacy-operational-event-store.ts +0 -36
- package/src/observability/raw-envelope-log.ts +0 -28
- package/src/observability/status-registry.ts +0 -13
- package/src/observability/transport-session-view.ts +0 -14
- package/src/onboarding.test.ts +0 -336
- package/src/onboarding.ts +0 -704
- package/src/outbound.test.ts +0 -1271
- package/src/outbound.ts +0 -746
- package/src/runtime/dispatcher.ts +0 -71
- package/src/runtime/outbound-intent.ts +0 -4
- package/src/runtime/reply-orchestrator.test.ts +0 -71
- package/src/runtime/reply-orchestrator.ts +0 -67
- package/src/runtime/routing-bridge.test.ts +0 -115
- package/src/runtime/routing-bridge.ts +0 -44
- package/src/runtime/session-manager.test.ts +0 -174
- package/src/runtime/session-manager.ts +0 -139
- package/src/runtime/source-registry.ts +0 -249
- package/src/runtime.ts +0 -14
- package/src/shared/command-auth.ts +0 -87
- package/src/shared/media-asset.ts +0 -78
- package/src/shared/media-service.test.ts +0 -111
- package/src/shared/media-service.ts +0 -84
- package/src/shared/media-types.ts +0 -5
- package/src/shared/xml-parser.test.ts +0 -50
- package/src/store/active-reply-store.ts +0 -42
- package/src/store/interfaces.ts +0 -11
- package/src/store/memory-store.ts +0 -43
- package/src/store/stream-batch-store.ts +0 -350
- package/src/transport/agent-api/client.ts +0 -277
- package/src/transport/agent-api/core.ts +0 -463
- package/src/transport/agent-api/delivery.ts +0 -41
- package/src/transport/agent-api/media-upload.ts +0 -11
- package/src/transport/agent-api/reply.ts +0 -39
- package/src/transport/agent-api/upstream-delivery.ts +0 -45
- package/src/transport/agent-api/upstream-media-upload.ts +0 -70
- package/src/transport/agent-api/upstream-reply.ts +0 -43
- package/src/transport/agent-callback/http-handler.ts +0 -47
- package/src/transport/agent-callback/inbound.ts +0 -5
- package/src/transport/agent-callback/reply.ts +0 -13
- package/src/transport/agent-callback/request-handler.ts +0 -244
- package/src/transport/agent-callback/session.ts +0 -23
- package/src/transport/bot-webhook/active-reply.ts +0 -39
- package/src/transport/bot-webhook/http-handler.ts +0 -48
- package/src/transport/bot-webhook/inbound-normalizer.test.ts +0 -433
- package/src/transport/bot-webhook/inbound-normalizer.ts +0 -558
- package/src/transport/bot-webhook/inbound.ts +0 -5
- package/src/transport/bot-webhook/message-shape.ts +0 -92
- package/src/transport/bot-webhook/protocol.ts +0 -148
- package/src/transport/bot-webhook/reply.ts +0 -15
- package/src/transport/bot-webhook/request-handler.ts +0 -394
- package/src/transport/bot-webhook/session.ts +0 -23
- package/src/transport/bot-ws/inbound.test.ts +0 -290
- package/src/transport/bot-ws/inbound.ts +0 -163
- package/src/transport/bot-ws/media.test.ts +0 -44
- package/src/transport/bot-ws/media.ts +0 -321
- package/src/transport/bot-ws/reply.test.ts +0 -450
- package/src/transport/bot-ws/reply.ts +0 -365
- package/src/transport/bot-ws/sdk-adapter.test.ts +0 -187
- package/src/transport/bot-ws/sdk-adapter.ts +0 -314
- package/src/transport/bot-ws/session.ts +0 -28
- package/src/transport/http/common.ts +0 -109
- package/src/transport/http/registry.ts +0 -92
- package/src/transport/http/request-handler.ts +0 -84
- package/src/types/account.ts +0 -70
- package/src/types/config.ts +0 -114
- package/src/types/constants.ts +0 -31
- package/src/types/events.ts +0 -21
- package/src/types/global.d.ts +0 -9
- package/src/types/index.ts +0 -17
- package/src/types/legacy-stream.ts +0 -50
- package/src/types/message.ts +0 -189
- package/src/types/runtime-context.ts +0 -28
- package/src/types/runtime.ts +0 -165
- package/src/types.ts +0 -41
- package/src/upstream/index.ts +0 -150
- package/src/upstream.test.ts +0 -84
- package/src/wecom_msg_adapter/markdown_adapter.ts +0 -331
- package/tsconfig.json +0 -22
- package/vitest.config.ts +0 -26
- /package/{src/capability/agent/index.ts → dist/src/capability/agent/index.js} +0 -0
- /package/{src/capability/bot/index.ts → dist/src/capability/bot/index.js} +0 -0
- /package/{src/capability/calendar/index.ts → dist/src/capability/calendar/index.js} +0 -0
- /package/{src/capability/index.ts → dist/src/capability/index.js} +0 -0
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { resolveWecomAccount } from "../../config/index.js";
|
|
2
|
+
import { wecomFetch } from "../../http.js";
|
|
3
|
+
import { LIMITS } from "../../monitor/state.js";
|
|
4
|
+
import { sendMedia as sendAgentMedia, sendText as sendAgentText, uploadMedia } from "../../transport/agent-api/core.js";
|
|
5
|
+
import { buildStreamReplyFromState } from "../../transport/bot-webhook/protocol.js";
|
|
6
|
+
import { useActiveReplyOnce } from "../../transport/bot-webhook/active-reply.js";
|
|
7
|
+
import { guessContentTypeFromPath } from "../../transport/bot-webhook/inbound-normalizer.js";
|
|
8
|
+
const STREAM_MAX_DM_BYTES = 200_000;
|
|
9
|
+
export function appendDmContent(state, text) {
|
|
10
|
+
const next = state.dmContent ? `${state.dmContent}\n\n${text}`.trim() : text.trim();
|
|
11
|
+
const buf = Buffer.from(next, "utf8");
|
|
12
|
+
state.dmContent = buf.length <= STREAM_MAX_DM_BYTES ? next : buf.subarray(buf.length - STREAM_MAX_DM_BYTES).toString("utf8");
|
|
13
|
+
}
|
|
14
|
+
export function resolveAgentAccountOrUndefined(cfg, accountId) {
|
|
15
|
+
const agent = resolveWecomAccount({ cfg, accountId }).agent;
|
|
16
|
+
return agent?.configured ? agent : undefined;
|
|
17
|
+
}
|
|
18
|
+
export function buildFallbackPrompt(params) {
|
|
19
|
+
const who = params.userId ? `(${params.userId})` : "";
|
|
20
|
+
const scope = params.chatType === "group" ? "群聊" : params.chatType === "direct" ? "私聊" : "会话";
|
|
21
|
+
if (!params.agentConfigured) {
|
|
22
|
+
return `${scope}中需要通过应用私信发送${params.filename ? `(${params.filename})` : ""},但管理员尚未配置企业微信自建应用(Agent)通道。请联系管理员配置后再试。${who}`.trim();
|
|
23
|
+
}
|
|
24
|
+
if (!params.userId) {
|
|
25
|
+
return `${scope}中需要通过应用私信兜底发送${params.filename ? `(${params.filename})` : ""},但本次回调未能识别触发者 userid(请检查企微回调字段 from.userid / fromuserid)。请联系管理员排查配置。`.trim();
|
|
26
|
+
}
|
|
27
|
+
if (params.kind === "media") {
|
|
28
|
+
return `已生成文件${params.filename ? `(${params.filename})` : ""},将通过应用私信发送给你。${who}`.trim();
|
|
29
|
+
}
|
|
30
|
+
if (params.kind === "timeout") {
|
|
31
|
+
return `内容较长,为避免超时,后续内容将通过应用私信发送给你。${who}`.trim();
|
|
32
|
+
}
|
|
33
|
+
return `交付出现异常,已尝试通过应用私信发送给你。${who}`.trim();
|
|
34
|
+
}
|
|
35
|
+
export async function sendBotFallbackPromptNow(params) {
|
|
36
|
+
await useActiveReplyOnce(params.streamId, async ({ responseUrl, proxyUrl }) => {
|
|
37
|
+
const payload = {
|
|
38
|
+
msgtype: "stream",
|
|
39
|
+
stream: {
|
|
40
|
+
id: params.streamId,
|
|
41
|
+
finish: true,
|
|
42
|
+
content: params.text.trim() || "1",
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
const res = await wecomFetch(responseUrl, {
|
|
46
|
+
method: "POST",
|
|
47
|
+
headers: { "Content-Type": "application/json" },
|
|
48
|
+
body: JSON.stringify(payload),
|
|
49
|
+
}, { proxyUrl, timeoutMs: LIMITS.REQUEST_TIMEOUT_MS });
|
|
50
|
+
if (!res.ok) {
|
|
51
|
+
throw new Error(`fallback prompt push failed: ${res.status}`);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
export async function pushFinalStreamReplyNow(params) {
|
|
56
|
+
const finalReply = buildStreamReplyFromState(params.state);
|
|
57
|
+
await useActiveReplyOnce(params.streamId, async ({ responseUrl, proxyUrl }) => {
|
|
58
|
+
const res = await wecomFetch(responseUrl, {
|
|
59
|
+
method: "POST",
|
|
60
|
+
headers: { "Content-Type": "application/json" },
|
|
61
|
+
body: JSON.stringify(finalReply),
|
|
62
|
+
}, { proxyUrl, timeoutMs: LIMITS.REQUEST_TIMEOUT_MS });
|
|
63
|
+
if (!res.ok) {
|
|
64
|
+
throw new Error(`final stream push failed: ${res.status}`);
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
export async function sendAgentDmText(params) {
|
|
69
|
+
const chunks = params.core.channel.text.chunkText(params.text, 2048);
|
|
70
|
+
for (const chunk of chunks) {
|
|
71
|
+
const trimmed = chunk.trim();
|
|
72
|
+
if (!trimmed)
|
|
73
|
+
continue;
|
|
74
|
+
await sendAgentText({ agent: params.agent, toUser: params.userId, text: trimmed });
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
export async function sendAgentDmMedia(params) {
|
|
78
|
+
let buffer;
|
|
79
|
+
let inferredContentType = params.contentType;
|
|
80
|
+
const looksLikeUrl = /^https?:\/\//i.test(params.mediaUrlOrPath);
|
|
81
|
+
if (looksLikeUrl) {
|
|
82
|
+
const res = await fetch(params.mediaUrlOrPath, { signal: AbortSignal.timeout(30_000) });
|
|
83
|
+
if (!res.ok)
|
|
84
|
+
throw new Error(`media download failed: ${res.status}`);
|
|
85
|
+
buffer = Buffer.from(await res.arrayBuffer());
|
|
86
|
+
inferredContentType = inferredContentType || res.headers.get("content-type") || "application/octet-stream";
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
const fs = await import("node:fs/promises");
|
|
90
|
+
buffer = await fs.readFile(params.mediaUrlOrPath);
|
|
91
|
+
}
|
|
92
|
+
let mediaType = "file";
|
|
93
|
+
const ct = (inferredContentType || "").toLowerCase();
|
|
94
|
+
if (ct.startsWith("image/"))
|
|
95
|
+
mediaType = "image";
|
|
96
|
+
else if (ct.startsWith("audio/"))
|
|
97
|
+
mediaType = "voice";
|
|
98
|
+
else if (ct.startsWith("video/"))
|
|
99
|
+
mediaType = "video";
|
|
100
|
+
const mediaId = await uploadMedia({
|
|
101
|
+
agent: params.agent,
|
|
102
|
+
type: mediaType,
|
|
103
|
+
buffer,
|
|
104
|
+
filename: params.filename,
|
|
105
|
+
});
|
|
106
|
+
await sendAgentMedia({
|
|
107
|
+
agent: params.agent,
|
|
108
|
+
toUser: params.userId,
|
|
109
|
+
mediaId,
|
|
110
|
+
mediaType,
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
export function extractLocalImagePathsFromText(params) {
|
|
114
|
+
const text = params.text;
|
|
115
|
+
const mustAlsoAppearIn = params.mustAlsoAppearIn;
|
|
116
|
+
if (!text.trim())
|
|
117
|
+
return [];
|
|
118
|
+
const exts = "(png|jpg|jpeg|gif|webp|bmp)";
|
|
119
|
+
const re = new RegExp(String.raw `(\/(?:Users|tmp|root|home)\/[^\s"'<>]+?\.${exts})`, "gi");
|
|
120
|
+
const found = new Set();
|
|
121
|
+
let m;
|
|
122
|
+
while ((m = re.exec(text))) {
|
|
123
|
+
const p = m[1];
|
|
124
|
+
if (!p)
|
|
125
|
+
continue;
|
|
126
|
+
if (!mustAlsoAppearIn.includes(p))
|
|
127
|
+
continue;
|
|
128
|
+
found.add(p);
|
|
129
|
+
}
|
|
130
|
+
return Array.from(found);
|
|
131
|
+
}
|
|
132
|
+
export function extractLocalFilePathsFromText(text) {
|
|
133
|
+
if (!text.trim())
|
|
134
|
+
return [];
|
|
135
|
+
const re = /\/(?:Users|tmp|root|home)\/[^\s"'<>]+/g;
|
|
136
|
+
const found = new Set();
|
|
137
|
+
let m;
|
|
138
|
+
while ((m = re.exec(text))) {
|
|
139
|
+
const p = m[0]?.trim();
|
|
140
|
+
if (p)
|
|
141
|
+
found.add(p);
|
|
142
|
+
}
|
|
143
|
+
return Array.from(found);
|
|
144
|
+
}
|
|
145
|
+
export function guessLocalPathContentType(filePath) {
|
|
146
|
+
return guessContentTypeFromPath(filePath);
|
|
147
|
+
}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import crypto from "node:crypto";
|
|
2
|
+
import { wecomFetch } from "../../http.js";
|
|
3
|
+
import { LIMITS } from "../../monitor/state.js";
|
|
4
|
+
import { getActiveReplyUrl, useActiveReplyOnce } from "../../transport/bot-webhook/active-reply.js";
|
|
5
|
+
import { buildStreamReplyFromState } from "../../transport/bot-webhook/protocol.js";
|
|
6
|
+
import { buildFallbackPrompt, extractLocalFilePathsFromText, guessLocalPathContentType, resolveAgentAccountOrUndefined, sendAgentDmMedia, sendBotFallbackPromptNow, } from "./fallback-delivery.js";
|
|
7
|
+
export async function handleDirectLocalPathIntent(params) {
|
|
8
|
+
const { streamStore, target, streamId, rawBody, userId, chatType, logVerbose, looksLikeSendLocalFileIntent } = params;
|
|
9
|
+
const directLocalPaths = extractLocalFilePathsFromText(rawBody);
|
|
10
|
+
if (directLocalPaths.length) {
|
|
11
|
+
logVerbose(target, `local-path: 检测到用户消息包含本机路径 count=${directLocalPaths.length} intent=${looksLikeSendLocalFileIntent(rawBody)}`);
|
|
12
|
+
}
|
|
13
|
+
if (!directLocalPaths.length || !looksLikeSendLocalFileIntent(rawBody)) {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
const fs = await import("node:fs/promises");
|
|
17
|
+
const pathModule = await import("node:path");
|
|
18
|
+
const imageExts = new Set(["png", "jpg", "jpeg", "gif", "webp", "bmp"]);
|
|
19
|
+
const imagePaths = [];
|
|
20
|
+
const otherPaths = [];
|
|
21
|
+
for (const p of directLocalPaths) {
|
|
22
|
+
const ext = pathModule.extname(p).slice(1).toLowerCase();
|
|
23
|
+
if (imageExts.has(ext))
|
|
24
|
+
imagePaths.push(p);
|
|
25
|
+
else
|
|
26
|
+
otherPaths.push(p);
|
|
27
|
+
}
|
|
28
|
+
if (imagePaths.length > 0 && otherPaths.length === 0) {
|
|
29
|
+
const loaded = [];
|
|
30
|
+
for (const p of imagePaths) {
|
|
31
|
+
try {
|
|
32
|
+
const buf = await fs.readFile(p);
|
|
33
|
+
const base64 = buf.toString("base64");
|
|
34
|
+
const md5 = crypto.createHash("md5").update(buf).digest("hex");
|
|
35
|
+
loaded.push({ base64, md5, path: p });
|
|
36
|
+
}
|
|
37
|
+
catch (err) {
|
|
38
|
+
target.runtime.error?.(`local-path: 读取图片失败 path=${p}: ${String(err)}`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
if (loaded.length > 0) {
|
|
42
|
+
streamStore.updateStream(streamId, (s) => {
|
|
43
|
+
s.images = loaded.map(({ base64, md5 }) => ({ base64, md5 }));
|
|
44
|
+
s.content = loaded.length === 1 ? `已发送图片(${pathModule.basename(loaded[0].path)})` : `已发送 ${loaded.length} 张图片`;
|
|
45
|
+
s.finished = true;
|
|
46
|
+
});
|
|
47
|
+
const responseUrl = getActiveReplyUrl(streamId);
|
|
48
|
+
if (responseUrl) {
|
|
49
|
+
try {
|
|
50
|
+
const finalReply = buildStreamReplyFromState(streamStore.getStream(streamId));
|
|
51
|
+
await useActiveReplyOnce(streamId, async ({ responseUrl, proxyUrl }) => {
|
|
52
|
+
const res = await wecomFetch(responseUrl, {
|
|
53
|
+
method: "POST",
|
|
54
|
+
headers: { "Content-Type": "application/json" },
|
|
55
|
+
body: JSON.stringify(finalReply),
|
|
56
|
+
}, { proxyUrl, timeoutMs: LIMITS.REQUEST_TIMEOUT_MS });
|
|
57
|
+
if (!res.ok)
|
|
58
|
+
throw new Error(`local-path image push failed: ${res.status}`);
|
|
59
|
+
});
|
|
60
|
+
logVerbose(target, `local-path: 已通过 Bot response_url 推送图片 frames=final images=${loaded.length}`);
|
|
61
|
+
}
|
|
62
|
+
catch (err) {
|
|
63
|
+
target.runtime.error?.(`local-path: Bot 主动推送图片失败(将依赖 stream_refresh 拉取): ${String(err)}`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
logVerbose(target, "local-path: 无 response_url,等待 stream_refresh 拉取最终图片");
|
|
68
|
+
}
|
|
69
|
+
streamStore.onStreamFinished(streamId);
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
const agentCfg = resolveAgentAccountOrUndefined(target.config, target.account.accountId);
|
|
73
|
+
const agentOk = Boolean(agentCfg);
|
|
74
|
+
const fallbackName = imagePaths.length === 1 ? (imagePaths[0].split("/").pop() || "image") : `${imagePaths.length} 张图片`;
|
|
75
|
+
const prompt = buildFallbackPrompt({
|
|
76
|
+
kind: "media",
|
|
77
|
+
agentConfigured: agentOk,
|
|
78
|
+
userId,
|
|
79
|
+
filename: fallbackName,
|
|
80
|
+
chatType,
|
|
81
|
+
});
|
|
82
|
+
streamStore.updateStream(streamId, (s) => {
|
|
83
|
+
s.fallbackMode = "error";
|
|
84
|
+
s.finished = true;
|
|
85
|
+
s.content = prompt;
|
|
86
|
+
s.fallbackPromptSentAt = s.fallbackPromptSentAt ?? Date.now();
|
|
87
|
+
});
|
|
88
|
+
try {
|
|
89
|
+
await sendBotFallbackPromptNow({ streamId, text: prompt });
|
|
90
|
+
logVerbose(target, "local-path: 图片读取失败后已推送兜底提示");
|
|
91
|
+
}
|
|
92
|
+
catch (err) {
|
|
93
|
+
target.runtime.error?.(`local-path: 图片读取失败后的兜底提示推送失败: ${String(err)}`);
|
|
94
|
+
}
|
|
95
|
+
if (agentCfg && userId && userId !== "unknown") {
|
|
96
|
+
for (const p of imagePaths) {
|
|
97
|
+
const guessedType = guessLocalPathContentType(p);
|
|
98
|
+
try {
|
|
99
|
+
await sendAgentDmMedia({
|
|
100
|
+
agent: agentCfg,
|
|
101
|
+
userId,
|
|
102
|
+
mediaUrlOrPath: p,
|
|
103
|
+
contentType: guessedType,
|
|
104
|
+
filename: p.split("/").pop() || "image",
|
|
105
|
+
});
|
|
106
|
+
streamStore.updateStream(streamId, (s) => {
|
|
107
|
+
s.agentMediaKeys = Array.from(new Set([...(s.agentMediaKeys ?? []), p]));
|
|
108
|
+
});
|
|
109
|
+
logVerbose(target, `local-path: 图片已通过 Agent 私信发送 user=${userId} path=${p} contentType=${guessedType ?? "unknown"}`);
|
|
110
|
+
}
|
|
111
|
+
catch (err) {
|
|
112
|
+
target.runtime.error?.(`local-path: 图片 Agent 私信兜底失败 path=${p}: ${String(err)}`);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
streamStore.onStreamFinished(streamId);
|
|
117
|
+
return true;
|
|
118
|
+
}
|
|
119
|
+
if (otherPaths.length > 0) {
|
|
120
|
+
const agentCfg = resolveAgentAccountOrUndefined(target.config, target.account.accountId);
|
|
121
|
+
const agentOk = Boolean(agentCfg);
|
|
122
|
+
const filename = otherPaths.length === 1 ? otherPaths[0].split("/").pop() : `${otherPaths.length} 个文件`;
|
|
123
|
+
const prompt = buildFallbackPrompt({
|
|
124
|
+
kind: "media",
|
|
125
|
+
agentConfigured: agentOk,
|
|
126
|
+
userId,
|
|
127
|
+
filename,
|
|
128
|
+
chatType,
|
|
129
|
+
});
|
|
130
|
+
streamStore.updateStream(streamId, (s) => {
|
|
131
|
+
s.fallbackMode = "media";
|
|
132
|
+
s.finished = true;
|
|
133
|
+
s.content = prompt;
|
|
134
|
+
s.fallbackPromptSentAt = s.fallbackPromptSentAt ?? Date.now();
|
|
135
|
+
});
|
|
136
|
+
try {
|
|
137
|
+
await sendBotFallbackPromptNow({ streamId, text: prompt });
|
|
138
|
+
logVerbose(target, "local-path: 文件兜底提示已推送");
|
|
139
|
+
}
|
|
140
|
+
catch (err) {
|
|
141
|
+
target.runtime.error?.(`local-path: 文件兜底提示推送失败: ${String(err)}`);
|
|
142
|
+
}
|
|
143
|
+
if (!agentCfg) {
|
|
144
|
+
streamStore.onStreamFinished(streamId);
|
|
145
|
+
return true;
|
|
146
|
+
}
|
|
147
|
+
if (!userId || userId === "unknown") {
|
|
148
|
+
target.runtime.error?.("local-path: 无法识别触发者 userId,无法 Agent 私信发送文件");
|
|
149
|
+
streamStore.onStreamFinished(streamId);
|
|
150
|
+
return true;
|
|
151
|
+
}
|
|
152
|
+
for (const p of otherPaths) {
|
|
153
|
+
const alreadySent = streamStore.getStream(streamId)?.agentMediaKeys?.includes(p);
|
|
154
|
+
if (alreadySent)
|
|
155
|
+
continue;
|
|
156
|
+
const guessedType = guessLocalPathContentType(p);
|
|
157
|
+
try {
|
|
158
|
+
await sendAgentDmMedia({
|
|
159
|
+
agent: agentCfg,
|
|
160
|
+
userId,
|
|
161
|
+
mediaUrlOrPath: p,
|
|
162
|
+
contentType: guessedType,
|
|
163
|
+
filename: p.split("/").pop() || "file",
|
|
164
|
+
});
|
|
165
|
+
streamStore.updateStream(streamId, (s) => {
|
|
166
|
+
s.agentMediaKeys = Array.from(new Set([...(s.agentMediaKeys ?? []), p]));
|
|
167
|
+
});
|
|
168
|
+
logVerbose(target, `local-path: 文件已通过 Agent 私信发送 user=${userId} path=${p} contentType=${guessedType ?? "unknown"}`);
|
|
169
|
+
}
|
|
170
|
+
catch (err) {
|
|
171
|
+
target.runtime.error?.(`local-path: Agent 私信发送文件失败 path=${p}: ${String(err)}`);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
streamStore.onStreamFinished(streamId);
|
|
175
|
+
return true;
|
|
176
|
+
}
|
|
177
|
+
return false;
|
|
178
|
+
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import crypto from "node:crypto";
|
|
2
|
+
import { constants } from "node:fs";
|
|
3
|
+
import os from "node:os";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { copyFile, mkdir, stat } from "node:fs/promises";
|
|
6
|
+
import { resolveAgentConfig, resolveAgentWorkspaceDir } from "openclaw/plugin-sdk/agent-runtime";
|
|
7
|
+
import { resolveWecomMediaMaxBytes } from "../../config/index.js";
|
|
8
|
+
function expandHomeDir(input) {
|
|
9
|
+
if (input === "~")
|
|
10
|
+
return os.homedir();
|
|
11
|
+
if (input.startsWith("~/"))
|
|
12
|
+
return path.join(os.homedir(), input.slice(2));
|
|
13
|
+
return input;
|
|
14
|
+
}
|
|
15
|
+
function resolveOpenClawStateDir() {
|
|
16
|
+
const override = process.env.OPENCLAW_STATE_DIR?.trim() || process.env.CLAWDBOT_STATE_DIR?.trim();
|
|
17
|
+
if (override) {
|
|
18
|
+
return path.resolve(expandHomeDir(override));
|
|
19
|
+
}
|
|
20
|
+
return path.join(os.homedir(), ".openclaw");
|
|
21
|
+
}
|
|
22
|
+
function normalizeAgentId(agentId) {
|
|
23
|
+
return agentId.trim().toLowerCase() || "main";
|
|
24
|
+
}
|
|
25
|
+
function normalizeMainKey(mainKey) {
|
|
26
|
+
return typeof mainKey === "string" && mainKey.trim() ? mainKey.trim().toLowerCase() : "main";
|
|
27
|
+
}
|
|
28
|
+
function buildAgentMainSessionKey(cfg, agentId) {
|
|
29
|
+
if (cfg.session?.scope === "global") {
|
|
30
|
+
return "global";
|
|
31
|
+
}
|
|
32
|
+
return `agent:${normalizeAgentId(agentId)}:${normalizeMainKey(cfg.session?.mainKey)}`;
|
|
33
|
+
}
|
|
34
|
+
function slugifySessionKey(value) {
|
|
35
|
+
const trimmed = value.trim() || "session";
|
|
36
|
+
const hash = crypto.createHash("sha256").update(trimmed).digest("hex").slice(0, 8);
|
|
37
|
+
const prefix = trimmed
|
|
38
|
+
.toLowerCase()
|
|
39
|
+
.replace(/[^a-z0-9._-]+/g, "-")
|
|
40
|
+
.replace(/^-+|-+$/g, "")
|
|
41
|
+
.slice(0, 32) || "session";
|
|
42
|
+
return `${prefix}-${hash}`;
|
|
43
|
+
}
|
|
44
|
+
function isSandboxedSession(params) {
|
|
45
|
+
const sandbox = resolveAgentConfig(params.cfg, params.agentId)?.sandbox;
|
|
46
|
+
if (!sandbox || sandbox.mode === "off") {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
if (sandbox.mode === "all") {
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
return params.sessionKey.trim().toLowerCase() !== buildAgentMainSessionKey(params.cfg, params.agentId);
|
|
53
|
+
}
|
|
54
|
+
function resolveSessionWorkspaceTarget(params) {
|
|
55
|
+
const sandbox = resolveAgentConfig(params.cfg, params.agentId)?.sandbox;
|
|
56
|
+
const agentWorkspaceDirRaw = resolveAgentWorkspaceDir(params.cfg, params.agentId);
|
|
57
|
+
const agentWorkspaceDir = path.resolve(expandHomeDir(agentWorkspaceDirRaw || process.cwd()));
|
|
58
|
+
if (!sandbox || !isSandboxedSession(params)) {
|
|
59
|
+
return {
|
|
60
|
+
workspaceDir: agentWorkspaceDir,
|
|
61
|
+
sandboxed: false,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
if (sandbox.workspaceAccess === "rw" || !sandbox.workspaceRoot) {
|
|
65
|
+
if (sandbox.workspaceAccess === "rw") {
|
|
66
|
+
return {
|
|
67
|
+
workspaceDir: agentWorkspaceDir,
|
|
68
|
+
sandboxed: true,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
workspaceDir: path.join(resolveOpenClawStateDir(), "sandboxes", slugifySessionKey(params.sessionKey.trim() || "main")),
|
|
73
|
+
sandboxed: true,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
const workspaceRoot = path.resolve(expandHomeDir(sandbox.workspaceRoot));
|
|
77
|
+
const scopeKey = sandbox.scope === "shared"
|
|
78
|
+
? "shared"
|
|
79
|
+
: sandbox.scope === "session"
|
|
80
|
+
? params.sessionKey.trim() || "main"
|
|
81
|
+
: `agent:${normalizeAgentId(params.agentId)}`;
|
|
82
|
+
if (sandbox.scope === "shared") {
|
|
83
|
+
return {
|
|
84
|
+
workspaceDir: workspaceRoot,
|
|
85
|
+
sandboxed: true,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
return {
|
|
89
|
+
workspaceDir: path.join(workspaceRoot, slugifySessionKey(scopeKey)),
|
|
90
|
+
sandboxed: true,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
function buildStagedFilenameCandidate(parsed, suffix) {
|
|
94
|
+
if (suffix === 0) {
|
|
95
|
+
return parsed.base || "attachment";
|
|
96
|
+
}
|
|
97
|
+
return `${parsed.name || "attachment"}-${suffix}${parsed.ext}`;
|
|
98
|
+
}
|
|
99
|
+
async function copyIntoWorkspaceInbound(params) {
|
|
100
|
+
const inboundDir = path.join(params.workspaceDir, "media", "inbound");
|
|
101
|
+
await mkdir(inboundDir, { recursive: true });
|
|
102
|
+
const parsed = path.parse(params.filename);
|
|
103
|
+
for (let suffix = 0;; suffix += 1) {
|
|
104
|
+
const candidate = buildStagedFilenameCandidate(parsed, suffix);
|
|
105
|
+
const absolutePath = path.join(inboundDir, candidate);
|
|
106
|
+
try {
|
|
107
|
+
await copyFile(params.sourcePath, absolutePath, constants.COPYFILE_EXCL);
|
|
108
|
+
return {
|
|
109
|
+
absolutePath,
|
|
110
|
+
relativePath: path.posix.join("media", "inbound", candidate),
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
catch (error) {
|
|
114
|
+
if (error?.code === "EEXIST") {
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
throw error;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
export async function stageWecomInboundMediaForSession(params) {
|
|
122
|
+
const target = resolveSessionWorkspaceTarget({
|
|
123
|
+
cfg: params.cfg,
|
|
124
|
+
agentId: params.agentId,
|
|
125
|
+
sessionKey: params.sessionKey,
|
|
126
|
+
});
|
|
127
|
+
const maxBytes = resolveWecomMediaMaxBytes(params.cfg, params.accountId);
|
|
128
|
+
const sourceStat = await stat(params.mediaPath);
|
|
129
|
+
if (sourceStat.size > maxBytes) {
|
|
130
|
+
throw new Error(`Inbound media size ${(sourceStat.size / (1024 * 1024)).toFixed(2)}MB exceeds channels.wecom.mediaMaxMb ${(maxBytes / (1024 * 1024)).toFixed(2)}MB before workspace staging`);
|
|
131
|
+
}
|
|
132
|
+
const staged = await copyIntoWorkspaceInbound({
|
|
133
|
+
sourcePath: params.mediaPath,
|
|
134
|
+
workspaceDir: target.workspaceDir,
|
|
135
|
+
filename: params.filename || path.basename(params.mediaPath),
|
|
136
|
+
});
|
|
137
|
+
return target.sandboxed ? staged.relativePath : staged.absolutePath;
|
|
138
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { BotWsSdkAdapter } from "../../transport/bot-ws/sdk-adapter.js";
|
|
2
|
+
import { startBotWebhookTransport } from "../../transport/bot-webhook/http-handler.js";
|
|
3
|
+
export class WecomBotCapabilityService {
|
|
4
|
+
runtime;
|
|
5
|
+
cfg;
|
|
6
|
+
runtimeEnv;
|
|
7
|
+
wsAdapter;
|
|
8
|
+
stopTransport;
|
|
9
|
+
constructor(runtime, cfg, runtimeEnv) {
|
|
10
|
+
this.runtime = runtime;
|
|
11
|
+
this.cfg = cfg;
|
|
12
|
+
this.runtimeEnv = runtimeEnv;
|
|
13
|
+
}
|
|
14
|
+
start() {
|
|
15
|
+
const bot = this.runtime.account.bot;
|
|
16
|
+
if (!bot?.configured) {
|
|
17
|
+
return undefined;
|
|
18
|
+
}
|
|
19
|
+
if (bot.primaryTransport === "ws") {
|
|
20
|
+
this.wsAdapter = new BotWsSdkAdapter(this.runtime, {
|
|
21
|
+
info: this.runtimeEnv.log,
|
|
22
|
+
warn: this.runtimeEnv.log,
|
|
23
|
+
error: this.runtimeEnv.error,
|
|
24
|
+
});
|
|
25
|
+
this.wsAdapter.start();
|
|
26
|
+
this.stopTransport = () => this.wsAdapter?.stop();
|
|
27
|
+
return {
|
|
28
|
+
transport: "bot-ws",
|
|
29
|
+
descriptors: ["ws:primary"],
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
const webhook = startBotWebhookTransport({
|
|
33
|
+
account: bot,
|
|
34
|
+
cfg: this.cfg,
|
|
35
|
+
runtime: this.runtime,
|
|
36
|
+
runtimeEnv: this.runtimeEnv,
|
|
37
|
+
});
|
|
38
|
+
this.stopTransport = webhook.stop;
|
|
39
|
+
return {
|
|
40
|
+
transport: "bot-webhook",
|
|
41
|
+
descriptors: webhook.paths,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
stop() {
|
|
45
|
+
this.stopTransport?.();
|
|
46
|
+
this.stopTransport = undefined;
|
|
47
|
+
this.wsAdapter = undefined;
|
|
48
|
+
}
|
|
49
|
+
}
|