@poolzin/pool-bot 2026.3.25 → 2026.3.27
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/agents/model-fallback.js +5 -4
- package/dist/agents/tools/common.js +16 -201
- package/dist/auto-reply/auto-reply/reply/agent-runner-execution.js +502 -0
- package/dist/auto-reply/auto-reply/reply/agent-runner-helpers.js +65 -0
- package/dist/auto-reply/auto-reply/reply/agent-runner-memory.js +160 -0
- package/dist/auto-reply/auto-reply/reply/agent-runner-payloads.js +85 -0
- package/dist/auto-reply/auto-reply/reply/agent-runner-utils.js +101 -0
- package/dist/auto-reply/auto-reply/reply/bash-command.js +338 -0
- package/dist/auto-reply/auto-reply/reply/block-streaming.js +91 -0
- package/dist/auto-reply/auto-reply/reply/commands-approve.js +88 -0
- package/dist/auto-reply/auto-reply/reply/commands-bash.js +26 -0
- package/dist/auto-reply/auto-reply/reply/commands-compact.js +107 -0
- package/dist/auto-reply/auto-reply/reply/commands-config.js +241 -0
- package/dist/auto-reply/auto-reply/reply/commands-context-report.js +295 -0
- package/dist/auto-reply/auto-reply/reply/commands-context.js +30 -0
- package/dist/auto-reply/auto-reply/reply/commands-core.js +151 -0
- package/dist/auto-reply/auto-reply/reply/commands-export-session.js +163 -0
- package/dist/auto-reply/auto-reply/reply/commands-info.js +184 -0
- package/dist/auto-reply/auto-reply/reply/commands-models.js +299 -0
- package/dist/auto-reply/auto-reply/reply/commands-plugin.js +35 -0
- package/dist/auto-reply/auto-reply/reply/commands-ptt.js +171 -0
- package/dist/auto-reply/auto-reply/reply/commands-setunset-standard.js +13 -0
- package/dist/auto-reply/auto-reply/reply/commands-setunset.js +73 -0
- package/dist/auto-reply/auto-reply/reply/commands-slash-parse.js +31 -0
- package/dist/auto-reply/auto-reply/reply/commands-status.js +178 -0
- package/dist/auto-reply/auto-reply/reply/commands-subagents.js +73 -0
- package/dist/auto-reply/auto-reply/reply/commands-system-prompt.js +117 -0
- package/dist/auto-reply/auto-reply/reply/commands-tts.js +231 -0
- package/dist/auto-reply/auto-reply/reply/directive-handling.impl.js +380 -0
- package/dist/auto-reply/auto-reply/reply/followup-runner.js +227 -0
- package/dist/auto-reply/auto-reply/reply/get-reply-directives-apply.js +201 -0
- package/dist/auto-reply/auto-reply/reply/get-reply-directives-utils.js +54 -0
- package/dist/auto-reply/auto-reply/reply/get-reply-directives.js +332 -0
- package/dist/auto-reply/auto-reply/reply/get-reply-inline-actions.js +258 -0
- package/dist/auto-reply/auto-reply/reply/get-reply-run.js +297 -0
- package/dist/auto-reply/auto-reply/reply/groups.js +102 -0
- package/dist/auto-reply/auto-reply/reply/mentions.js +129 -0
- package/dist/auto-reply/auto-reply/reply/reply-delivery.js +92 -0
- package/dist/auto-reply/auto-reply/reply/reply-directives.js +30 -0
- package/dist/auto-reply/auto-reply/reply/reply-dispatcher.js +152 -0
- package/dist/auto-reply/auto-reply/reply/reply-elevated.js +166 -0
- package/dist/auto-reply/auto-reply/reply/reply-inline.js +28 -0
- package/dist/auto-reply/auto-reply/reply/reply-payloads.js +114 -0
- package/dist/auto-reply/auto-reply/reply/reply-reference.js +36 -0
- package/dist/auto-reply/auto-reply/reply/reply-tags.js +13 -0
- package/dist/auto-reply/auto-reply/reply/reply-threading.js +41 -0
- package/dist/auto-reply/auto-reply/reply/session-updates.js +233 -0
- package/dist/auto-reply/auto-reply/reply/stage-sandbox-media.js +146 -0
- package/dist/build-info.json +3 -3
- package/dist/canvas-host/a2ui/.bundle.hash +1 -1
- package/dist/canvas-host/a2ui/a2ui.bundle.js +2 -17772
- package/dist/canvas-host/a2ui/index.html +1 -307
- package/dist/channels/channels/directory-config.js +185 -0
- package/dist/channels/channels/discord/handle-action.guild-admin.js +332 -0
- package/dist/channels/channels/discord/handle-action.js +165 -0
- package/dist/channels/channels/discord.js +413 -0
- package/dist/channels/channels/dock.js +436 -0
- package/dist/channels/channels/index.js +51 -0
- package/dist/channels/channels/plugins/outbound/discord.js +101 -0
- package/dist/channels/channels/whatsapp.js +17 -0
- package/dist/channels/plugins/types.js +1 -1
- package/dist/channels/run-state-machine.js +7 -0
- package/dist/commands/models/auth.js +47 -1
- package/dist/commands-subagents/action-agents.js +44 -0
- package/dist/commands-subagents/action-focus.js +64 -0
- package/dist/commands-subagents/action-help.js +4 -0
- package/dist/commands-subagents/action-info.js +45 -0
- package/dist/commands-subagents/action-kill.js +60 -0
- package/dist/commands-subagents/action-list.js +44 -0
- package/dist/commands-subagents/action-log.js +29 -0
- package/dist/commands-subagents/action-send.js +119 -0
- package/dist/commands-subagents/action-spawn.js +52 -0
- package/dist/commands-subagents/action-unfocus.js +30 -0
- package/dist/commands-subagents/shared.js +303 -0
- package/dist/config/config.js +1 -8
- package/dist/config/types.secrets.js +61 -0
- package/dist/control-ui/assets/{index-D7shnQwQ.js → index-umCsvrWy.js} +884 -741
- package/dist/control-ui/assets/index-umCsvrWy.js.map +1 -0
- package/dist/control-ui/assets/pt-BR-DedEVAvY.js +2 -0
- package/dist/control-ui/assets/pt-BR-DedEVAvY.js.map +1 -0
- package/dist/control-ui/assets/zh-CN-CDzeklK-.js +2 -0
- package/dist/control-ui/assets/zh-CN-CDzeklK-.js.map +1 -0
- package/dist/control-ui/assets/zh-TW-BJCRYNWH.js +2 -0
- package/dist/control-ui/assets/zh-TW-BJCRYNWH.js.map +1 -0
- package/dist/control-ui/index.html +1 -1
- package/dist/gateway/method-scopes.js +9 -1
- package/dist/gateway/node-pending-work.js +142 -0
- package/dist/gateway/protocol/index.js +5 -1
- package/dist/gateway/protocol/schema/nodes.js +18 -0
- package/dist/gateway/server-methods/nodes-pending.js +96 -0
- package/dist/gateway/server-methods-list.js +4 -0
- package/dist/gateway/server-methods.js +2 -0
- package/dist/imessage/channel.js +253 -0
- package/dist/imessage/monitor/echo-cache.js +70 -0
- package/dist/imessage/monitor/loop-rate-limiter.js +51 -0
- package/dist/imessage/monitor/reflection-guard.js +50 -0
- package/dist/imessage/monitor/sanitize-outbound.js +25 -0
- package/dist/imessage/monitor/self-chat-cache.js +75 -0
- package/dist/imessage/runtime.js +3 -0
- package/dist/infra/exec-approval-reply.js +7 -0
- package/dist/infra/tmp-openclaw-dir.js +84 -0
- package/dist/pairing/pairing-challenge.js +15 -0
- package/dist/plugin-sdk/account-id.d.ts +1 -0
- package/dist/plugin-sdk/agent-media-payload.d.ts +12 -0
- package/dist/plugin-sdk/allow-from.d.ts +27 -0
- package/dist/plugin-sdk/command-auth.d.ts +25 -0
- package/dist/plugin-sdk/command-auth.js +3 -1
- package/dist/plugin-sdk/config-paths.d.ts +6 -0
- package/dist/plugin-sdk/file-lock.d.ts +16 -0
- package/dist/plugin-sdk/index.d.ts +428 -0
- package/dist/plugin-sdk/index.js +237 -103
- package/dist/plugin-sdk/json-store.d.ts +5 -0
- package/dist/plugin-sdk/keyed-async-queue.d.ts +12 -0
- package/dist/plugin-sdk/onboarding.d.ts +11 -0
- package/dist/plugin-sdk/provider-auth-result.d.ts +14 -0
- package/dist/plugin-sdk/slack-message-actions.d.ts +11 -0
- package/dist/plugin-sdk/status-helpers.d.ts +25 -0
- package/dist/plugin-sdk/temp-path.d.ts +12 -0
- package/dist/plugin-sdk/text-chunking.d.ts +1 -0
- package/dist/plugin-sdk/tool-send.d.ts +4 -0
- package/dist/plugin-sdk/webhook-path.d.ts +6 -0
- package/dist/plugin-sdk/webhook-targets.d.ts +23 -0
- package/dist/plugin-sdk/windows-spawn.d.ts +39 -0
- package/dist/plugin-sdk-internal/accounts.js +6 -0
- package/dist/plugin-sdk-internal/discord.js +23 -0
- package/dist/plugin-sdk-internal/imessage.js +13 -0
- package/dist/plugin-sdk-internal/setup.js +9 -0
- package/dist/plugin-sdk-internal/signal.js +13 -0
- package/dist/plugin-sdk-internal/slack.js +22 -0
- package/dist/plugin-sdk-internal/telegram.js +32 -0
- package/dist/plugin-sdk-internal/whatsapp.js +29 -0
- package/dist/routing/session-key.js +4 -185
- package/dist/shared/pid-alive.js +2 -61
- package/dist/shared/process-scoped-map.js +5 -7
- package/dist/signal/channel.js +264 -0
- package/dist/signal/monitor/access-policy.js +60 -0
- package/dist/signal/runtime.js +3 -0
- package/dist/slack/account-inspect.js +135 -0
- package/dist/slack/blocks-input.js +7 -38
- package/dist/slack/channel.js +394 -0
- package/dist/slack/interactive-replies.js +28 -0
- package/dist/slack/monitor/channel-type.js +31 -0
- package/dist/slack/monitor/dm-auth.js +49 -0
- package/dist/slack/monitor/events/interactions.modal.js +137 -0
- package/dist/slack/monitor/events/message-subtype-handlers.js +68 -0
- package/dist/slack/monitor/events/system-event-context.js +29 -0
- package/dist/slack/monitor/events/system-event-test-harness.js +41 -0
- package/dist/slack/monitor/external-arg-menu-store.js +46 -0
- package/dist/slack/monitor/message-handler/prepare-content.js +69 -0
- package/dist/slack/monitor/message-handler/prepare-thread-context.js +91 -0
- package/dist/slack/monitor/message-handler/prepare.test-helpers.js +55 -0
- package/dist/slack/monitor/reconnect-policy.js +78 -0
- package/dist/slack/monitor/slash-commands.runtime.js +1 -0
- package/dist/slack/monitor/slash-dispatch.runtime.js +9 -0
- package/dist/slack/monitor/slash-skill-commands.runtime.js +1 -0
- package/dist/slack/resolve-allowlist-common.js +36 -0
- package/dist/slack/runtime.js +3 -0
- package/dist/slack/sent-thread-cache.js +61 -0
- package/dist/slack/truncate.js +10 -0
- package/dist/telegram/account-inspect.js +175 -0
- package/dist/telegram/allow-from.js +10 -0
- package/dist/telegram/api-fetch.js +18 -0
- package/dist/telegram/approval-buttons.js +30 -0
- package/dist/telegram/audit-membership-runtime.js +61 -0
- package/dist/telegram/bot/delivery.replies.js +508 -0
- package/dist/telegram/bot/delivery.resolve-media.js +227 -0
- package/dist/telegram/bot/delivery.send.js +132 -0
- package/dist/telegram/bot/reply-threading.js +46 -0
- package/dist/telegram/bot-message-context.body.js +186 -0
- package/dist/telegram/bot-message-context.session.js +207 -0
- package/dist/telegram/bot-message-context.types.js +1 -0
- package/dist/telegram/bot-native-commands.test-helpers.js +117 -0
- package/dist/telegram/bot.media.e2e-harness.js +81 -0
- package/dist/telegram/bot.media.test-utils.js +81 -0
- package/dist/telegram/channel-actions.js +225 -0
- package/dist/telegram/channel.js +515 -0
- package/dist/telegram/conversation-route.js +107 -0
- package/dist/telegram/delivery.js +2 -0
- package/dist/telegram/delivery.replies.js +508 -0
- package/dist/telegram/dm-access.js +86 -0
- package/dist/telegram/draft-stream.test-helpers.js +62 -0
- package/dist/telegram/exec-approvals-handler.js +281 -0
- package/dist/telegram/exec-approvals.js +62 -0
- package/dist/telegram/forum-service-message.js +22 -0
- package/dist/telegram/group-config-helpers.js +10 -0
- package/dist/telegram/lane-delivery-state.js +19 -0
- package/dist/telegram/lane-delivery-text-deliverer.js +357 -0
- package/dist/telegram/lane-delivery.js +2 -0
- package/dist/telegram/normalize.js +37 -0
- package/dist/telegram/onboarding.js +192 -0
- package/dist/telegram/outbound-adapter.js +100 -0
- package/dist/telegram/polling-session.js +275 -0
- package/dist/telegram/runtime.js +3 -0
- package/dist/telegram/sendchataction-401-backoff.js +71 -0
- package/dist/telegram/sequential-key.js +46 -0
- package/dist/telegram/status-issues.js +105 -0
- package/dist/telegram/target-writeback.js +165 -0
- package/dist/telegram/thread-bindings.js +560 -0
- package/dist/utils.js +32 -257
- package/dist/wizard/prompts.js +5 -5
- package/extensions/feishu/src/policy.ts +1 -1
- package/extensions/firecrawl/index.test.ts +82 -0
- package/extensions/firecrawl/index.ts +20 -0
- package/extensions/firecrawl/openclaw.plugin.json +8 -0
- package/extensions/firecrawl/package.json +12 -0
- package/extensions/firecrawl/src/config.ts +159 -0
- package/extensions/firecrawl/src/firecrawl-client.ts +446 -0
- package/extensions/firecrawl/src/firecrawl-scrape-tool.ts +89 -0
- package/extensions/firecrawl/src/firecrawl-search-provider.ts +63 -0
- package/extensions/firecrawl/src/firecrawl-search-tool.ts +76 -0
- package/package.json +1 -1
- package/dist/.buildstamp +0 -1
- package/dist/acp/bindings-store.js +0 -209
- package/dist/acp/control-plane/runtime-cache.js +0 -54
- package/dist/acp/control-plane/runtime-options.js +0 -215
- package/dist/acp/control-plane/session-actor-queue.js +0 -36
- package/dist/acp/index.js +0 -2
- package/dist/acp/runtime/errors.js +0 -47
- package/dist/acp/runtime/registry.js +0 -86
- package/dist/acp/secret-file.js +0 -22
- package/dist/agents/auth-profiles.resolve-auth-profile-order.fixtures.js +0 -23
- package/dist/agents/bash-process-registry.test-helpers.js +0 -29
- package/dist/agents/bash-tools.exec-approval-request.js +0 -20
- package/dist/agents/bash-tools.exec-host-gateway.js +0 -240
- package/dist/agents/bash-tools.exec-host-node.js +0 -235
- package/dist/agents/checkpoint-manager.js +0 -290
- package/dist/agents/claude-cli-runner.js +0 -3
- package/dist/agents/error-classifier.js +0 -251
- package/dist/agents/live-model-filter.js +0 -84
- package/dist/agents/nvidia-models.js +0 -228
- package/dist/agents/pi-embedded-runner/run.overflow-compaction.fixture.js +0 -34
- package/dist/agents/pi-embedded-runner/run.overflow-compaction.mocks.shared.js +0 -156
- package/dist/agents/pi-embedded-subscribe.handlers.tools.media.test-helpers.js +0 -30
- package/dist/agents/provider/config-loader.js +0 -76
- package/dist/agents/provider/index.js +0 -15
- package/dist/agents/provider/models-dev.js +0 -129
- package/dist/agents/provider/session-binding.js +0 -376
- package/dist/agents/queued-file-writer.js +0 -22
- package/dist/agents/skills/bundled-context.js +0 -23
- package/dist/agents/skills/security.js +0 -211
- package/dist/agents/skills/tools-dir.js +0 -9
- package/dist/agents/skills-install-download.js +0 -290
- package/dist/agents/skills-install-output.js +0 -30
- package/dist/agents/skills-install.download-test-utils.js +0 -36
- package/dist/agents/skills.test-helpers.js +0 -13
- package/dist/agents/subagent-announce-reliability.js +0 -160
- package/dist/agents/subagent-registry.mocks.shared.js +0 -12
- package/dist/agents/test-helpers/assistant-message-fixtures.js +0 -29
- package/dist/agents/test-helpers/fast-coding-tools.js +0 -1
- package/dist/agents/test-helpers/fast-core-tools.js +0 -8
- package/dist/agents/test-helpers/fast-tool-stubs.js +0 -18
- package/dist/agents/test-helpers/host-sandbox-fs-bridge.js +0 -74
- package/dist/agents/test-helpers/pi-tools-sandbox-context.js +0 -27
- package/dist/agents/tool-display-common.js +0 -915
- package/dist/agents/tool-policy-shared.js +0 -108
- package/dist/agents/tool-policy.conformance.js +0 -14
- package/dist/agents/tool-result-truncation.js +0 -299
- package/dist/agents/tools/cron-tool.test-helpers.js +0 -12
- package/dist/agents/tools/discord-actions-moderation-shared.js +0 -27
- package/dist/agents/tools/discord-actions-presence.js +0 -78
- package/dist/control-ui/assets/index-D7shnQwQ.js.map +0 -1
- package/dist/discord/discord-improvements.js +0 -167
- package/dist/discord/index.js +0 -2
- package/dist/hooks/bundled/boot-md/HOOK.md +0 -19
- package/dist/hooks/bundled/command-logger/HOOK.md +0 -122
- package/dist/hooks/bundled/session-memory/HOOK.md +0 -86
- package/dist/hooks/bundled/soul-evil/HOOK.md +0 -71
- package/dist/whatsapp/normalize.js +0 -66
- package/dist/whatsapp/resolve-outbound-target.js +0 -42
- /package/dist/{acp/runtime/types.js → auto-reply/auto-reply/reply/commands-types.js} +0 -0
- /package/dist/{agents/pi-embedded-payloads.js → slack/account-surface-fields.js} +0 -0
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import { readNumberParam, readStringArrayParam, readStringOrNumberParam, readStringParam, } from "../../../src/agents/tools/common.js";
|
|
2
|
+
import { handleTelegramAction } from "../../../src/agents/tools/telegram-actions.js";
|
|
3
|
+
import { resolveReactionMessageId } from "../../../src/channels/plugins/actions/reaction-message-id.js";
|
|
4
|
+
import { createUnionActionGate, listTokenSourcedAccounts, } from "../../../src/channels/plugins/actions/shared.js";
|
|
5
|
+
import { readBooleanParam } from "../../../src/plugin-sdk/boolean-param.js";
|
|
6
|
+
import { extractToolSend } from "../../../src/plugin-sdk/tool-send.js";
|
|
7
|
+
import { resolveTelegramPollVisibility } from "../../../src/poll-params.js";
|
|
8
|
+
import { createTelegramActionGate, listEnabledTelegramAccounts, resolveTelegramPollActionGateState, } from "./accounts.js";
|
|
9
|
+
import { isTelegramInlineButtonsEnabled } from "./inline-buttons.js";
|
|
10
|
+
const providerId = "telegram";
|
|
11
|
+
function readTelegramSendParams(params) {
|
|
12
|
+
const to = readStringParam(params, "to", { required: true });
|
|
13
|
+
const mediaUrl = readStringParam(params, "media", { trim: false });
|
|
14
|
+
const message = readStringParam(params, "message", { required: !mediaUrl, allowEmpty: true });
|
|
15
|
+
const caption = readStringParam(params, "caption", { allowEmpty: true });
|
|
16
|
+
const content = message || caption || "";
|
|
17
|
+
const replyTo = readStringParam(params, "replyTo");
|
|
18
|
+
const threadId = readStringParam(params, "threadId");
|
|
19
|
+
const buttons = params.buttons;
|
|
20
|
+
const asVoice = readBooleanParam(params, "asVoice");
|
|
21
|
+
const silent = readBooleanParam(params, "silent");
|
|
22
|
+
const forceDocument = readBooleanParam(params, "forceDocument");
|
|
23
|
+
const quoteText = readStringParam(params, "quoteText");
|
|
24
|
+
return {
|
|
25
|
+
to,
|
|
26
|
+
content,
|
|
27
|
+
mediaUrl: mediaUrl ?? undefined,
|
|
28
|
+
replyToMessageId: replyTo ?? undefined,
|
|
29
|
+
messageThreadId: threadId ?? undefined,
|
|
30
|
+
buttons,
|
|
31
|
+
asVoice,
|
|
32
|
+
silent,
|
|
33
|
+
forceDocument,
|
|
34
|
+
quoteText: quoteText ?? undefined,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
function readTelegramChatIdParam(params) {
|
|
38
|
+
return (readStringOrNumberParam(params, "chatId") ??
|
|
39
|
+
readStringOrNumberParam(params, "channelId") ??
|
|
40
|
+
readStringParam(params, "to", { required: true }));
|
|
41
|
+
}
|
|
42
|
+
function readTelegramMessageIdParam(params) {
|
|
43
|
+
const messageId = readNumberParam(params, "messageId", {
|
|
44
|
+
required: true,
|
|
45
|
+
integer: true,
|
|
46
|
+
});
|
|
47
|
+
if (typeof messageId !== "number") {
|
|
48
|
+
throw new Error("messageId is required.");
|
|
49
|
+
}
|
|
50
|
+
return messageId;
|
|
51
|
+
}
|
|
52
|
+
export const telegramMessageActions = {
|
|
53
|
+
listActions: ({ cfg }) => {
|
|
54
|
+
const accounts = listTokenSourcedAccounts(listEnabledTelegramAccounts(cfg));
|
|
55
|
+
if (accounts.length === 0) {
|
|
56
|
+
return [];
|
|
57
|
+
}
|
|
58
|
+
// Union of all accounts' action gates (any account enabling an action makes it available)
|
|
59
|
+
const gate = createUnionActionGate(accounts, (account) => createTelegramActionGate({
|
|
60
|
+
cfg,
|
|
61
|
+
accountId: account.accountId,
|
|
62
|
+
}));
|
|
63
|
+
const isEnabled = (key, defaultValue = true) => gate(key, defaultValue);
|
|
64
|
+
const actions = new Set(["send"]);
|
|
65
|
+
const pollEnabledForAnyAccount = accounts.some((account) => {
|
|
66
|
+
const accountGate = createTelegramActionGate({
|
|
67
|
+
cfg,
|
|
68
|
+
accountId: account.accountId,
|
|
69
|
+
});
|
|
70
|
+
return resolveTelegramPollActionGateState(accountGate).enabled;
|
|
71
|
+
});
|
|
72
|
+
if (pollEnabledForAnyAccount) {
|
|
73
|
+
actions.add("poll");
|
|
74
|
+
}
|
|
75
|
+
if (isEnabled("reactions")) {
|
|
76
|
+
actions.add("react");
|
|
77
|
+
}
|
|
78
|
+
if (isEnabled("deleteMessage")) {
|
|
79
|
+
actions.add("delete");
|
|
80
|
+
}
|
|
81
|
+
if (isEnabled("editMessage")) {
|
|
82
|
+
actions.add("edit");
|
|
83
|
+
}
|
|
84
|
+
if (isEnabled("sticker", false)) {
|
|
85
|
+
actions.add("sticker");
|
|
86
|
+
actions.add("sticker-search");
|
|
87
|
+
}
|
|
88
|
+
if (isEnabled("createForumTopic")) {
|
|
89
|
+
actions.add("topic-create");
|
|
90
|
+
}
|
|
91
|
+
return Array.from(actions);
|
|
92
|
+
},
|
|
93
|
+
supportsButtons: ({ cfg }) => {
|
|
94
|
+
const accounts = listTokenSourcedAccounts(listEnabledTelegramAccounts(cfg));
|
|
95
|
+
if (accounts.length === 0) {
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
return accounts.some((account) => isTelegramInlineButtonsEnabled({ cfg, accountId: account.accountId }));
|
|
99
|
+
},
|
|
100
|
+
extractToolSend: ({ args }) => {
|
|
101
|
+
return extractToolSend(args, "sendMessage");
|
|
102
|
+
},
|
|
103
|
+
handleAction: async ({ action, params, cfg, accountId, mediaLocalRoots, toolContext }) => {
|
|
104
|
+
if (action === "send") {
|
|
105
|
+
const sendParams = readTelegramSendParams(params);
|
|
106
|
+
return await handleTelegramAction({
|
|
107
|
+
action: "sendMessage",
|
|
108
|
+
...sendParams,
|
|
109
|
+
accountId: accountId ?? undefined,
|
|
110
|
+
}, cfg, { mediaLocalRoots });
|
|
111
|
+
}
|
|
112
|
+
if (action === "react") {
|
|
113
|
+
const messageId = resolveReactionMessageId({ args: params, toolContext });
|
|
114
|
+
const emoji = readStringParam(params, "emoji", { allowEmpty: true });
|
|
115
|
+
const remove = readBooleanParam(params, "remove");
|
|
116
|
+
return await handleTelegramAction({
|
|
117
|
+
action: "react",
|
|
118
|
+
chatId: readTelegramChatIdParam(params),
|
|
119
|
+
messageId,
|
|
120
|
+
emoji,
|
|
121
|
+
remove,
|
|
122
|
+
accountId: accountId ?? undefined,
|
|
123
|
+
}, cfg, { mediaLocalRoots });
|
|
124
|
+
}
|
|
125
|
+
if (action === "poll") {
|
|
126
|
+
const to = readStringParam(params, "to", { required: true });
|
|
127
|
+
const question = readStringParam(params, "pollQuestion", { required: true });
|
|
128
|
+
const answers = readStringArrayParam(params, "pollOption", { required: true });
|
|
129
|
+
const durationHours = readNumberParam(params, "pollDurationHours", {
|
|
130
|
+
integer: true,
|
|
131
|
+
strict: true,
|
|
132
|
+
});
|
|
133
|
+
const durationSeconds = readNumberParam(params, "pollDurationSeconds", {
|
|
134
|
+
integer: true,
|
|
135
|
+
strict: true,
|
|
136
|
+
});
|
|
137
|
+
const replyToMessageId = readNumberParam(params, "replyTo", { integer: true });
|
|
138
|
+
const messageThreadId = readNumberParam(params, "threadId", { integer: true });
|
|
139
|
+
const allowMultiselect = readBooleanParam(params, "pollMulti");
|
|
140
|
+
const pollAnonymous = readBooleanParam(params, "pollAnonymous");
|
|
141
|
+
const pollPublic = readBooleanParam(params, "pollPublic");
|
|
142
|
+
const isAnonymous = resolveTelegramPollVisibility({ pollAnonymous, pollPublic });
|
|
143
|
+
const silent = readBooleanParam(params, "silent");
|
|
144
|
+
return await handleTelegramAction({
|
|
145
|
+
action: "poll",
|
|
146
|
+
to,
|
|
147
|
+
question,
|
|
148
|
+
answers,
|
|
149
|
+
allowMultiselect,
|
|
150
|
+
durationHours: durationHours ?? undefined,
|
|
151
|
+
durationSeconds: durationSeconds ?? undefined,
|
|
152
|
+
replyToMessageId: replyToMessageId ?? undefined,
|
|
153
|
+
messageThreadId: messageThreadId ?? undefined,
|
|
154
|
+
isAnonymous,
|
|
155
|
+
silent,
|
|
156
|
+
accountId: accountId ?? undefined,
|
|
157
|
+
}, cfg, { mediaLocalRoots });
|
|
158
|
+
}
|
|
159
|
+
if (action === "delete") {
|
|
160
|
+
const chatId = readTelegramChatIdParam(params);
|
|
161
|
+
const messageId = readTelegramMessageIdParam(params);
|
|
162
|
+
return await handleTelegramAction({
|
|
163
|
+
action: "deleteMessage",
|
|
164
|
+
chatId,
|
|
165
|
+
messageId,
|
|
166
|
+
accountId: accountId ?? undefined,
|
|
167
|
+
}, cfg, { mediaLocalRoots });
|
|
168
|
+
}
|
|
169
|
+
if (action === "edit") {
|
|
170
|
+
const chatId = readTelegramChatIdParam(params);
|
|
171
|
+
const messageId = readTelegramMessageIdParam(params);
|
|
172
|
+
const message = readStringParam(params, "message", { required: true, allowEmpty: false });
|
|
173
|
+
const buttons = params.buttons;
|
|
174
|
+
return await handleTelegramAction({
|
|
175
|
+
action: "editMessage",
|
|
176
|
+
chatId,
|
|
177
|
+
messageId,
|
|
178
|
+
content: message,
|
|
179
|
+
buttons,
|
|
180
|
+
accountId: accountId ?? undefined,
|
|
181
|
+
}, cfg, { mediaLocalRoots });
|
|
182
|
+
}
|
|
183
|
+
if (action === "sticker") {
|
|
184
|
+
const to = readStringParam(params, "to") ?? readStringParam(params, "target", { required: true });
|
|
185
|
+
// Accept stickerId (array from shared schema) and use first element as fileId
|
|
186
|
+
const stickerIds = readStringArrayParam(params, "stickerId");
|
|
187
|
+
const fileId = stickerIds?.[0] ?? readStringParam(params, "fileId", { required: true });
|
|
188
|
+
const replyToMessageId = readNumberParam(params, "replyTo", { integer: true });
|
|
189
|
+
const messageThreadId = readNumberParam(params, "threadId", { integer: true });
|
|
190
|
+
return await handleTelegramAction({
|
|
191
|
+
action: "sendSticker",
|
|
192
|
+
to,
|
|
193
|
+
fileId,
|
|
194
|
+
replyToMessageId: replyToMessageId ?? undefined,
|
|
195
|
+
messageThreadId: messageThreadId ?? undefined,
|
|
196
|
+
accountId: accountId ?? undefined,
|
|
197
|
+
}, cfg, { mediaLocalRoots });
|
|
198
|
+
}
|
|
199
|
+
if (action === "sticker-search") {
|
|
200
|
+
const query = readStringParam(params, "query", { required: true });
|
|
201
|
+
const limit = readNumberParam(params, "limit", { integer: true });
|
|
202
|
+
return await handleTelegramAction({
|
|
203
|
+
action: "searchSticker",
|
|
204
|
+
query,
|
|
205
|
+
limit: limit ?? undefined,
|
|
206
|
+
accountId: accountId ?? undefined,
|
|
207
|
+
}, cfg, { mediaLocalRoots });
|
|
208
|
+
}
|
|
209
|
+
if (action === "topic-create") {
|
|
210
|
+
const chatId = readTelegramChatIdParam(params);
|
|
211
|
+
const name = readStringParam(params, "name", { required: true });
|
|
212
|
+
const iconColor = readNumberParam(params, "iconColor", { integer: true });
|
|
213
|
+
const iconCustomEmojiId = readStringParam(params, "iconCustomEmojiId");
|
|
214
|
+
return await handleTelegramAction({
|
|
215
|
+
action: "createForumTopic",
|
|
216
|
+
chatId,
|
|
217
|
+
name,
|
|
218
|
+
iconColor: iconColor ?? undefined,
|
|
219
|
+
iconCustomEmojiId: iconCustomEmojiId ?? undefined,
|
|
220
|
+
accountId: accountId ?? undefined,
|
|
221
|
+
}, cfg, { mediaLocalRoots });
|
|
222
|
+
}
|
|
223
|
+
throw new Error(`Action ${action} is not supported for provider ${providerId}.`);
|
|
224
|
+
},
|
|
225
|
+
};
|