@poolzin/pool-bot 2026.1.39 → 2026.2.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/assets/chrome-extension/README.md +3 -3
- package/assets/chrome-extension/background.js +5 -5
- package/assets/chrome-extension/manifest.json +3 -3
- package/assets/chrome-extension/options.html +4 -4
- package/assets/chrome-extension/options.js +1 -1
- package/dist/acp/client.js +3 -3
- package/dist/acp/types.js +1 -1
- package/dist/agents/agent-paths.js +3 -3
- package/dist/agents/auth-profiles/paths.js +3 -3
- package/dist/agents/cli-runner/helpers.js +1 -1
- package/dist/agents/cli-runner.js +2 -2
- package/dist/agents/cloudflare-ai-gateway.js +31 -0
- package/dist/agents/compaction.js +16 -2
- package/dist/agents/context-window-guard.js +13 -10
- package/dist/agents/context.js +4 -4
- package/dist/agents/docs-path.js +1 -1
- package/dist/agents/minimax-vlm.js +1 -1
- package/dist/agents/model-auth.js +12 -1
- package/dist/agents/model-catalog.js +4 -4
- package/dist/agents/model-selection.js +10 -4
- package/dist/agents/models-config.js +3 -3
- package/dist/agents/models-config.providers.js +147 -39
- package/dist/agents/pi-embedded-helpers/openai.js +1 -1
- package/dist/agents/pi-embedded-runner/compact.js +8 -8
- package/dist/agents/pi-embedded-runner/model.js +2 -2
- package/dist/agents/pi-embedded-runner/run/attempt.js +6 -6
- package/dist/agents/pi-embedded-runner/run.js +4 -4
- package/dist/agents/pi-embedded-runner/tool-result-truncation.js +275 -0
- package/dist/agents/pi-embedded-runner/utils.js +1 -1
- package/dist/agents/pi-model-discovery.js +10 -0
- package/dist/agents/pi-tool-definition-adapter.js +50 -9
- package/dist/agents/pi-tools.before-tool-call.js +67 -0
- package/dist/agents/pi-tools.js +10 -5
- package/dist/agents/pi-tools.read.js +2 -2
- package/dist/agents/session-file-repair.js +83 -0
- package/dist/agents/session-transcript-repair.js +68 -0
- package/dist/agents/skills/frontmatter.js +1 -1
- package/dist/agents/skills/workspace.js +2 -2
- package/dist/agents/system-prompt.js +28 -4
- package/dist/agents/together-models.js +127 -0
- package/dist/agents/tool-images.js +1 -1
- package/dist/agents/tool-policy.js +1 -1
- package/dist/agents/tools/browser-tool.js +3 -3
- package/dist/agents/tools/image-tool.js +2 -2
- package/dist/agents/tools/memory-tool.js +93 -5
- package/dist/agents/tools/web-search.js +1 -1
- package/dist/auto-reply/commands-registry.data.js +1 -1
- package/dist/auto-reply/reply/commands-context-report.js +2 -2
- package/dist/auto-reply/reply/commands-session.js +2 -2
- package/dist/auto-reply/reply/get-reply-run.js +14 -4
- package/dist/auto-reply/reply/groups.js +1 -1
- package/dist/auto-reply/reply/inbound-context.js +4 -0
- package/dist/auto-reply/reply/inbound-meta.js +130 -0
- package/dist/auto-reply/reply/untrusted-context.js +15 -0
- package/dist/auto-reply/status.js +1 -1
- package/dist/browser/client-fetch.js +1 -1
- package/dist/browser/config.js +1 -1
- package/dist/browser/extension-relay.js +3 -3
- package/dist/browser/server-context.js +2 -2
- package/dist/build-info.json +3 -3
- package/dist/canvas-host/a2ui.js +3 -3
- package/dist/channels/plugins/catalog.js +2 -2
- package/dist/channels/plugins/onboarding/imessage.js +1 -1
- package/dist/channels/plugins/onboarding/signal.js +1 -1
- package/dist/channels/plugins/onboarding/slack.js +4 -4
- package/dist/channels/plugins/onboarding/whatsapp.js +3 -3
- package/dist/channels/plugins/pairing-message.js +1 -1
- package/dist/cli/browser-cli-extension.js +2 -2
- package/dist/cli/docs-cli.js +1 -1
- package/dist/cli/gateway-cli/dev.js +1 -1
- package/dist/cli/memory-cli.js +25 -15
- package/dist/cli/nodes-cli/register.canvas.js +1 -1
- package/dist/cli/plugins-cli.js +1 -1
- package/dist/cli/run-main.js +2 -2
- package/dist/cli/security-cli.js +1 -1
- package/dist/cli/tagline.js +1 -1
- package/dist/cli/update-cli.js +4 -4
- package/dist/cli/webhooks-cli.js +5 -5
- package/dist/commands/agents.commands.add.js +1 -1
- package/dist/commands/auth-choice.apply.api-providers.js +305 -17
- package/dist/commands/auth-choice.apply.js +4 -1
- package/dist/commands/auth-choice.apply.plugin-provider.js +2 -2
- package/dist/commands/auth-choice.apply.xai.js +63 -0
- package/dist/commands/auth-choice.preferred-provider.js +7 -1
- package/dist/commands/configure.wizard.js +1 -1
- package/dist/commands/dashboard.js +1 -1
- package/dist/commands/docs.js +1 -1
- package/dist/commands/doctor-gateway-services.js +3 -3
- package/dist/commands/doctor-update.js +3 -3
- package/dist/commands/doctor.js +1 -1
- package/dist/commands/models/list.probe.js +2 -2
- package/dist/commands/models/list.registry.js +4 -4
- package/dist/commands/models/list.status-command.js +2 -2
- package/dist/commands/onboard-auth.config-core.js +366 -28
- package/dist/commands/onboard-auth.credentials.js +71 -9
- package/dist/commands/onboard-auth.js +3 -3
- package/dist/commands/onboard-auth.models.js +26 -24
- package/dist/commands/onboard-non-interactive/local/auth-choice.js +140 -6
- package/dist/commands/status-all/report-lines.js +1 -1
- package/dist/commands/status.command.js +1 -1
- package/dist/commands/uninstall.js +3 -3
- package/dist/compat/legacy-names.js +1 -1
- package/dist/config/io.js +3 -3
- package/dist/config/schema.js +1 -1
- package/dist/config/types.memory.js +1 -0
- package/dist/config/version.js +4 -4
- package/dist/daemon/constants.js +7 -7
- package/dist/daemon/inspect.js +6 -6
- package/dist/daemon/systemd-unit.js +1 -1
- package/dist/gateway/live-image-probe.js +1 -66
- package/dist/gateway/openai-http.js +2 -2
- package/dist/gateway/openresponses-http.js +4 -4
- package/dist/gateway/server-discovery.js +2 -2
- package/dist/gateway/server-http.js +1 -1
- package/dist/gateway/server.impl.js +2 -2
- package/dist/hooks/frontmatter.js +1 -1
- package/dist/hooks/hooks-status.js +1 -1
- package/dist/hooks/install.js +2 -2
- package/dist/hooks/loader.js +1 -1
- package/dist/hooks/workspace.js +3 -3
- package/dist/index.js +2 -2
- package/dist/infra/bonjour.js +3 -3
- package/dist/infra/path-env.js +3 -3
- package/dist/infra/provider-usage.fetch.minimax.js +1 -1
- package/dist/infra/restart.js +1 -1
- package/dist/infra/tailscale.js +1 -1
- package/dist/macos/relay.js +2 -2
- package/dist/media/input-files.js +1 -1
- package/dist/media/mime.js +4 -0
- package/dist/media/png-encode.js +74 -0
- package/dist/media-understanding/providers/image.js +2 -2
- package/dist/memory/backend-config.js +207 -0
- package/dist/memory/embeddings.js +1 -1
- package/dist/memory/manager.js +1 -0
- package/dist/memory/types.js +1 -0
- package/dist/node-host/runner.js +2 -2
- package/dist/pairing/pairing-messages.js +1 -1
- package/dist/plugins/discovery.js +1 -1
- package/dist/plugins/install.js +2 -2
- package/dist/plugins/update.js +1 -1
- package/dist/security/audit.js +2 -2
- package/dist/shared/text/reasoning-tags.js +52 -7
- package/dist/tailscale/detect.js +146 -0
- package/dist/telegram/bot-message-context.js +1 -1
- package/dist/test-helpers/workspace.js +11 -0
- package/dist/test-utils/channel-plugins.js +82 -0
- package/dist/test-utils/ports.js +73 -0
- package/dist/utils/shell-argv.js +61 -0
- package/dist/utils.js +10 -0
- package/dist/web/qr-image.js +1 -61
- package/dist/wizard/onboarding.finalize.js +7 -7
- package/dist/wizard/onboarding.js +3 -3
- package/docs/RELEASE_WORKFOTS_COMPARISON.md +3 -3
- package/docs/_config.yml +2 -2
- package/docs/_layouts/default.html +9 -9
- package/docs/concepts/typebox.md +1 -1
- package/docs/docs.json +1 -1
- package/docs/northflank.mdx +7 -7
- package/docs/railway.mdx +3 -3
- package/docs/render.mdx +5 -5
- package/docs/start/lore.md +2 -2
- package/extensions/bluebubbles/index.ts +2 -2
- package/extensions/bluebubbles/package.json +1 -1
- package/extensions/bluebubbles/src/accounts.ts +8 -8
- package/extensions/bluebubbles/src/actions.test.ts +22 -22
- package/extensions/bluebubbles/src/actions.ts +5 -5
- package/extensions/bluebubbles/src/attachments.ts +2 -2
- package/extensions/bluebubbles/src/channel.ts +16 -16
- package/extensions/bluebubbles/src/chat.ts +2 -2
- package/extensions/bluebubbles/src/media-send.ts +2 -2
- package/extensions/bluebubbles/src/monitor.test.ts +46 -46
- package/extensions/bluebubbles/src/monitor.ts +5 -5
- package/extensions/bluebubbles/src/onboarding.ts +7 -7
- package/extensions/bluebubbles/src/reactions.ts +2 -2
- package/extensions/bluebubbles/src/send.ts +2 -2
- package/extensions/copilot-proxy/README.md +1 -1
- package/extensions/copilot-proxy/package.json +1 -1
- package/extensions/diagnostics-otel/index.ts +2 -2
- package/extensions/diagnostics-otel/package.json +1 -1
- package/extensions/diagnostics-otel/src/service.ts +3 -3
- package/extensions/discord/index.ts +2 -2
- package/extensions/discord/package.json +1 -1
- package/extensions/google-antigravity-auth/README.md +1 -1
- package/extensions/google-antigravity-auth/index.ts +1 -1
- package/extensions/google-antigravity-auth/package.json +1 -1
- package/extensions/google-gemini-cli-auth/README.md +1 -1
- package/extensions/google-gemini-cli-auth/oauth.ts +1 -1
- package/extensions/google-gemini-cli-auth/package.json +1 -1
- package/extensions/googlechat/index.ts +3 -3
- package/extensions/googlechat/package.json +1 -1
- package/extensions/googlechat/src/accounts.ts +8 -8
- package/extensions/googlechat/src/actions.ts +6 -6
- package/extensions/googlechat/src/channel.ts +21 -21
- package/extensions/googlechat/src/monitor.ts +8 -8
- package/extensions/googlechat/src/onboarding.ts +10 -10
- package/extensions/imessage/index.ts +2 -2
- package/extensions/imessage/package.json +1 -1
- package/extensions/line/index.ts +2 -2
- package/extensions/line/package.json +1 -1
- package/extensions/line/src/card-command.ts +2 -2
- package/extensions/line/src/channel.logout.test.ts +4 -4
- package/extensions/line/src/channel.sendPayload.test.ts +8 -8
- package/extensions/line/src/channel.ts +3 -3
- package/extensions/llm-task/README.md +3 -3
- package/extensions/llm-task/index.ts +2 -2
- package/extensions/llm-task/package.json +1 -1
- package/extensions/llm-task/src/llm-task-tool.ts +4 -4
- package/extensions/lobster/README.md +6 -6
- package/extensions/lobster/index.ts +2 -2
- package/extensions/lobster/src/lobster-tool.test.ts +4 -4
- package/extensions/lobster/src/lobster-tool.ts +2 -2
- package/extensions/matrix/index.ts +2 -2
- package/extensions/matrix/package.json +1 -1
- package/extensions/matrix/src/matrix/client/config.ts +1 -1
- package/extensions/matrix/src/matrix/monitor/handler.ts +1 -1
- package/extensions/matrix/src/onboarding.ts +1 -1
- package/extensions/mattermost/index.ts +2 -2
- package/extensions/mattermost/package.json +1 -1
- package/extensions/mattermost/src/mattermost/accounts.ts +8 -8
- package/extensions/mattermost/src/mattermost/monitor-helpers.ts +5 -5
- package/extensions/mattermost/src/mattermost/monitor.ts +2 -2
- package/extensions/mattermost/src/onboarding-helpers.ts +3 -3
- package/extensions/mattermost/src/onboarding.ts +2 -2
- package/extensions/memory-core/index.ts +2 -2
- package/extensions/memory-core/package.json +1 -1
- package/extensions/memory-lancedb/index.ts +3 -3
- package/extensions/memory-lancedb/package.json +1 -1
- package/extensions/msteams/index.ts +2 -2
- package/extensions/msteams/package.json +1 -1
- package/extensions/msteams/src/channel.directory.test.ts +2 -2
- package/extensions/msteams/src/channel.ts +2 -2
- package/extensions/msteams/src/graph-upload.ts +4 -4
- package/extensions/msteams/src/monitor-handler.ts +2 -2
- package/extensions/msteams/src/monitor.ts +2 -2
- package/extensions/msteams/src/onboarding.ts +9 -9
- package/extensions/msteams/src/reply-dispatcher.ts +2 -2
- package/extensions/msteams/src/send-context.ts +2 -2
- package/extensions/msteams/src/send.ts +4 -4
- package/extensions/nextcloud-talk/index.ts +2 -2
- package/extensions/nextcloud-talk/package.json +1 -1
- package/extensions/nextcloud-talk/src/channel.ts +7 -7
- package/extensions/nextcloud-talk/src/inbound.ts +7 -7
- package/extensions/nextcloud-talk/src/onboarding.ts +1 -1
- package/extensions/nostr/README.md +2 -2
- package/extensions/nostr/index.ts +5 -5
- package/extensions/nostr/package.json +1 -1
- package/extensions/nostr/src/types.ts +4 -4
- package/extensions/open-prose/index.ts +2 -2
- package/extensions/qwen-portal-auth/README.md +1 -1
- package/extensions/signal/index.ts +2 -2
- package/extensions/signal/package.json +1 -1
- package/extensions/slack/index.ts +2 -2
- package/extensions/slack/package.json +1 -1
- package/extensions/telegram/index.ts +2 -2
- package/extensions/telegram/package.json +1 -1
- package/extensions/telegram/src/channel.ts +2 -2
- package/extensions/tlon/README.md +2 -2
- package/extensions/tlon/index.ts +2 -2
- package/extensions/tlon/package.json +1 -1
- package/extensions/tlon/src/channel.ts +13 -13
- package/extensions/tlon/src/monitor/index.ts +3 -3
- package/extensions/tlon/src/onboarding.ts +3 -3
- package/extensions/tlon/src/types.ts +3 -3
- package/extensions/twitch/README.md +1 -1
- package/extensions/twitch/index.ts +2 -2
- package/extensions/twitch/package.json +1 -1
- package/extensions/twitch/src/config.ts +3 -3
- package/extensions/twitch/src/monitor.ts +3 -3
- package/extensions/twitch/src/onboarding.ts +9 -9
- package/extensions/twitch/src/outbound.test.ts +2 -2
- package/extensions/twitch/src/plugin.test.ts +2 -2
- package/extensions/twitch/src/plugin.ts +8 -8
- package/extensions/twitch/src/send.test.ts +2 -2
- package/extensions/twitch/src/send.ts +4 -4
- package/extensions/twitch/src/token.test.ts +8 -8
- package/extensions/twitch/src/token.ts +3 -3
- package/extensions/twitch/src/twitch-client.ts +3 -3
- package/extensions/twitch/src/types.ts +3 -3
- package/extensions/twitch/src/utils/markdown.ts +1 -1
- package/extensions/voice-call/README.md +3 -3
- package/extensions/voice-call/package.json +1 -1
- package/extensions/voice-call/src/core-bridge.ts +2 -2
- package/extensions/voice-call/src/response-generator.ts +1 -1
- package/extensions/whatsapp/index.ts +2 -2
- package/extensions/whatsapp/package.json +1 -1
- package/extensions/zalo/README.md +1 -1
- package/extensions/zalo/index.ts +2 -2
- package/extensions/zalo/package.json +1 -1
- package/extensions/zalo/src/accounts.ts +8 -8
- package/extensions/zalo/src/actions.ts +4 -4
- package/extensions/zalo/src/channel.directory.test.ts +2 -2
- package/extensions/zalo/src/channel.ts +18 -18
- package/extensions/zalo/src/monitor.ts +9 -9
- package/extensions/zalo/src/monitor.webhook.test.ts +2 -2
- package/extensions/zalo/src/onboarding.ts +24 -24
- package/extensions/zalo/src/send.ts +2 -2
- package/extensions/zalouser/README.md +2 -2
- package/extensions/zalouser/index.ts +2 -2
- package/extensions/zalouser/package.json +1 -1
- package/extensions/zalouser/src/accounts.ts +9 -9
- package/extensions/zalouser/src/channel.ts +24 -24
- package/extensions/zalouser/src/monitor.ts +4 -4
- package/extensions/zalouser/src/onboarding.ts +28 -28
- package/package.json +13 -251
- package/skills/nano-banana-pro/scripts/generate_image.py +1 -1
- package/skills/tmux/scripts/find-sessions.sh +1 -1
- package/CHANGELOG.md +0 -102
- package/README-header.png +0 -0
- package/git-hooks/pre-commit +0 -4
- package/scripts/format-staged.js +0 -148
- package/scripts/postinstall.js +0 -300
- package/scripts/setup-git-hooks.js +0 -96
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { PoolbotConfig } from "poolbot/plugin-sdk";
|
|
2
2
|
import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "poolbot/plugin-sdk";
|
|
3
3
|
|
|
4
4
|
import type { ResolvedZaloAccount, ZaloAccountConfig, ZaloConfig } from "./types.js";
|
|
5
5
|
import { resolveZaloToken } from "./token.js";
|
|
6
6
|
|
|
7
|
-
function listConfiguredAccountIds(cfg:
|
|
7
|
+
function listConfiguredAccountIds(cfg: PoolbotConfig): string[] {
|
|
8
8
|
const accounts = (cfg.channels?.zalo as ZaloConfig | undefined)?.accounts;
|
|
9
9
|
if (!accounts || typeof accounts !== "object") return [];
|
|
10
10
|
return Object.keys(accounts).filter(Boolean);
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
export function listZaloAccountIds(cfg:
|
|
13
|
+
export function listZaloAccountIds(cfg: PoolbotConfig): string[] {
|
|
14
14
|
const ids = listConfiguredAccountIds(cfg);
|
|
15
15
|
if (ids.length === 0) return [DEFAULT_ACCOUNT_ID];
|
|
16
16
|
return ids.sort((a, b) => a.localeCompare(b));
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
export function resolveDefaultZaloAccountId(cfg:
|
|
19
|
+
export function resolveDefaultZaloAccountId(cfg: PoolbotConfig): string {
|
|
20
20
|
const zaloConfig = cfg.channels?.zalo as ZaloConfig | undefined;
|
|
21
21
|
if (zaloConfig?.defaultAccount?.trim()) return zaloConfig.defaultAccount.trim();
|
|
22
22
|
const ids = listZaloAccountIds(cfg);
|
|
@@ -25,7 +25,7 @@ export function resolveDefaultZaloAccountId(cfg: MoltbotConfig): string {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
function resolveAccountConfig(
|
|
28
|
-
cfg:
|
|
28
|
+
cfg: PoolbotConfig,
|
|
29
29
|
accountId: string,
|
|
30
30
|
): ZaloAccountConfig | undefined {
|
|
31
31
|
const accounts = (cfg.channels?.zalo as ZaloConfig | undefined)?.accounts;
|
|
@@ -33,7 +33,7 @@ function resolveAccountConfig(
|
|
|
33
33
|
return accounts[accountId] as ZaloAccountConfig | undefined;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
function mergeZaloAccountConfig(cfg:
|
|
36
|
+
function mergeZaloAccountConfig(cfg: PoolbotConfig, accountId: string): ZaloAccountConfig {
|
|
37
37
|
const raw = (cfg.channels?.zalo ?? {}) as ZaloConfig;
|
|
38
38
|
const { accounts: _ignored, defaultAccount: _ignored2, ...base } = raw;
|
|
39
39
|
const account = resolveAccountConfig(cfg, accountId) ?? {};
|
|
@@ -41,7 +41,7 @@ function mergeZaloAccountConfig(cfg: MoltbotConfig, accountId: string): ZaloAcco
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
export function resolveZaloAccount(params: {
|
|
44
|
-
cfg:
|
|
44
|
+
cfg: PoolbotConfig;
|
|
45
45
|
accountId?: string | null;
|
|
46
46
|
}): ResolvedZaloAccount {
|
|
47
47
|
const accountId = normalizeAccountId(params.accountId);
|
|
@@ -64,7 +64,7 @@ export function resolveZaloAccount(params: {
|
|
|
64
64
|
};
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
export function listEnabledZaloAccounts(cfg:
|
|
67
|
+
export function listEnabledZaloAccounts(cfg: PoolbotConfig): ResolvedZaloAccount[] {
|
|
68
68
|
return listZaloAccountIds(cfg)
|
|
69
69
|
.map((accountId) => resolveZaloAccount({ cfg, accountId }))
|
|
70
70
|
.filter((account) => account.enabled);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
ChannelMessageActionAdapter,
|
|
3
3
|
ChannelMessageActionName,
|
|
4
|
-
|
|
4
|
+
PoolbotConfig,
|
|
5
5
|
} from "poolbot/plugin-sdk";
|
|
6
6
|
import { jsonResult, readStringParam } from "poolbot/plugin-sdk";
|
|
7
7
|
|
|
@@ -10,7 +10,7 @@ import { sendMessageZalo } from "./send.js";
|
|
|
10
10
|
|
|
11
11
|
const providerId = "zalo";
|
|
12
12
|
|
|
13
|
-
function listEnabledAccounts(cfg:
|
|
13
|
+
function listEnabledAccounts(cfg: PoolbotConfig) {
|
|
14
14
|
return listEnabledZaloAccounts(cfg).filter(
|
|
15
15
|
(account) => account.enabled && account.tokenSource !== "none",
|
|
16
16
|
);
|
|
@@ -18,7 +18,7 @@ function listEnabledAccounts(cfg: MoltbotConfig) {
|
|
|
18
18
|
|
|
19
19
|
export const zaloMessageActions: ChannelMessageActionAdapter = {
|
|
20
20
|
listActions: ({ cfg }) => {
|
|
21
|
-
const accounts = listEnabledAccounts(cfg as
|
|
21
|
+
const accounts = listEnabledAccounts(cfg as PoolbotConfig);
|
|
22
22
|
if (accounts.length === 0) return [];
|
|
23
23
|
const actions = new Set<ChannelMessageActionName>(["send"]);
|
|
24
24
|
return Array.from(actions);
|
|
@@ -44,7 +44,7 @@ export const zaloMessageActions: ChannelMessageActionAdapter = {
|
|
|
44
44
|
const result = await sendMessageZalo(to ?? "", content ?? "", {
|
|
45
45
|
accountId: accountId ?? undefined,
|
|
46
46
|
mediaUrl: mediaUrl ?? undefined,
|
|
47
|
-
cfg: cfg as
|
|
47
|
+
cfg: cfg as PoolbotConfig,
|
|
48
48
|
});
|
|
49
49
|
|
|
50
50
|
if (!result.ok) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { describe, expect, it } from "vitest";
|
|
2
2
|
|
|
3
|
-
import type {
|
|
3
|
+
import type { PoolbotConfig } from "poolbot/plugin-sdk";
|
|
4
4
|
|
|
5
5
|
import { zaloPlugin } from "./channel.js";
|
|
6
6
|
|
|
@@ -12,7 +12,7 @@ describe("zalo directory", () => {
|
|
|
12
12
|
allowFrom: ["zalo:123", "zl:234", "345"],
|
|
13
13
|
},
|
|
14
14
|
},
|
|
15
|
-
} as unknown as
|
|
15
|
+
} as unknown as PoolbotConfig;
|
|
16
16
|
|
|
17
17
|
expect(zaloPlugin.directory).toBeTruthy();
|
|
18
18
|
expect(zaloPlugin.directory?.listPeers).toBeTruthy();
|
|
@@ -2,7 +2,7 @@ import type {
|
|
|
2
2
|
ChannelAccountSnapshot,
|
|
3
3
|
ChannelDock,
|
|
4
4
|
ChannelPlugin,
|
|
5
|
-
|
|
5
|
+
PoolbotConfig,
|
|
6
6
|
} from "poolbot/plugin-sdk";
|
|
7
7
|
import {
|
|
8
8
|
applyAccountNameToChannelSection,
|
|
@@ -53,7 +53,7 @@ export const zaloDock: ChannelDock = {
|
|
|
53
53
|
outbound: { textChunkLimit: 2000 },
|
|
54
54
|
config: {
|
|
55
55
|
resolveAllowFrom: ({ cfg, accountId }) =>
|
|
56
|
-
(resolveZaloAccount({ cfg: cfg as
|
|
56
|
+
(resolveZaloAccount({ cfg: cfg as PoolbotConfig, accountId }).config.allowFrom ?? []).map(
|
|
57
57
|
(entry) => String(entry),
|
|
58
58
|
),
|
|
59
59
|
formatAllowFrom: ({ allowFrom }) =>
|
|
@@ -87,12 +87,12 @@ export const zaloPlugin: ChannelPlugin<ResolvedZaloAccount> = {
|
|
|
87
87
|
reload: { configPrefixes: ["channels.zalo"] },
|
|
88
88
|
configSchema: buildChannelConfigSchema(ZaloConfigSchema),
|
|
89
89
|
config: {
|
|
90
|
-
listAccountIds: (cfg) => listZaloAccountIds(cfg as
|
|
91
|
-
resolveAccount: (cfg, accountId) => resolveZaloAccount({ cfg: cfg as
|
|
92
|
-
defaultAccountId: (cfg) => resolveDefaultZaloAccountId(cfg as
|
|
90
|
+
listAccountIds: (cfg) => listZaloAccountIds(cfg as PoolbotConfig),
|
|
91
|
+
resolveAccount: (cfg, accountId) => resolveZaloAccount({ cfg: cfg as PoolbotConfig, accountId }),
|
|
92
|
+
defaultAccountId: (cfg) => resolveDefaultZaloAccountId(cfg as PoolbotConfig),
|
|
93
93
|
setAccountEnabled: ({ cfg, accountId, enabled }) =>
|
|
94
94
|
setAccountEnabledInConfigSection({
|
|
95
|
-
cfg: cfg as
|
|
95
|
+
cfg: cfg as PoolbotConfig,
|
|
96
96
|
sectionKey: "zalo",
|
|
97
97
|
accountId,
|
|
98
98
|
enabled,
|
|
@@ -100,7 +100,7 @@ export const zaloPlugin: ChannelPlugin<ResolvedZaloAccount> = {
|
|
|
100
100
|
}),
|
|
101
101
|
deleteAccount: ({ cfg, accountId }) =>
|
|
102
102
|
deleteAccountFromConfigSection({
|
|
103
|
-
cfg: cfg as
|
|
103
|
+
cfg: cfg as PoolbotConfig,
|
|
104
104
|
sectionKey: "zalo",
|
|
105
105
|
accountId,
|
|
106
106
|
clearBaseFields: ["botToken", "tokenFile", "name"],
|
|
@@ -114,7 +114,7 @@ export const zaloPlugin: ChannelPlugin<ResolvedZaloAccount> = {
|
|
|
114
114
|
tokenSource: account.tokenSource,
|
|
115
115
|
}),
|
|
116
116
|
resolveAllowFrom: ({ cfg, accountId }) =>
|
|
117
|
-
(resolveZaloAccount({ cfg: cfg as
|
|
117
|
+
(resolveZaloAccount({ cfg: cfg as PoolbotConfig, accountId }).config.allowFrom ?? []).map(
|
|
118
118
|
(entry) => String(entry),
|
|
119
119
|
),
|
|
120
120
|
formatAllowFrom: ({ allowFrom }) =>
|
|
@@ -128,7 +128,7 @@ export const zaloPlugin: ChannelPlugin<ResolvedZaloAccount> = {
|
|
|
128
128
|
resolveDmPolicy: ({ cfg, accountId, account }) => {
|
|
129
129
|
const resolvedAccountId = accountId ?? account.accountId ?? DEFAULT_ACCOUNT_ID;
|
|
130
130
|
const useAccountPath = Boolean(
|
|
131
|
-
(cfg as
|
|
131
|
+
(cfg as PoolbotConfig).channels?.zalo?.accounts?.[resolvedAccountId],
|
|
132
132
|
);
|
|
133
133
|
const basePath = useAccountPath
|
|
134
134
|
? `channels.zalo.accounts.${resolvedAccountId}.`
|
|
@@ -164,7 +164,7 @@ export const zaloPlugin: ChannelPlugin<ResolvedZaloAccount> = {
|
|
|
164
164
|
directory: {
|
|
165
165
|
self: async () => null,
|
|
166
166
|
listPeers: async ({ cfg, accountId, query, limit }) => {
|
|
167
|
-
const account = resolveZaloAccount({ cfg: cfg as
|
|
167
|
+
const account = resolveZaloAccount({ cfg: cfg as PoolbotConfig, accountId });
|
|
168
168
|
const q = query?.trim().toLowerCase() || "";
|
|
169
169
|
const peers = Array.from(
|
|
170
170
|
new Set(
|
|
@@ -185,7 +185,7 @@ export const zaloPlugin: ChannelPlugin<ResolvedZaloAccount> = {
|
|
|
185
185
|
resolveAccountId: ({ accountId }) => normalizeAccountId(accountId),
|
|
186
186
|
applyAccountName: ({ cfg, accountId, name }) =>
|
|
187
187
|
applyAccountNameToChannelSection({
|
|
188
|
-
cfg: cfg as
|
|
188
|
+
cfg: cfg as PoolbotConfig,
|
|
189
189
|
channelKey: "zalo",
|
|
190
190
|
accountId,
|
|
191
191
|
name,
|
|
@@ -201,7 +201,7 @@ export const zaloPlugin: ChannelPlugin<ResolvedZaloAccount> = {
|
|
|
201
201
|
},
|
|
202
202
|
applyAccountConfig: ({ cfg, accountId, input }) => {
|
|
203
203
|
const namedConfig = applyAccountNameToChannelSection({
|
|
204
|
-
cfg: cfg as
|
|
204
|
+
cfg: cfg as PoolbotConfig,
|
|
205
205
|
channelKey: "zalo",
|
|
206
206
|
accountId,
|
|
207
207
|
name: input.name,
|
|
@@ -230,7 +230,7 @@ export const zaloPlugin: ChannelPlugin<ResolvedZaloAccount> = {
|
|
|
230
230
|
: {}),
|
|
231
231
|
},
|
|
232
232
|
},
|
|
233
|
-
} as
|
|
233
|
+
} as PoolbotConfig;
|
|
234
234
|
}
|
|
235
235
|
return {
|
|
236
236
|
...next,
|
|
@@ -253,14 +253,14 @@ export const zaloPlugin: ChannelPlugin<ResolvedZaloAccount> = {
|
|
|
253
253
|
},
|
|
254
254
|
},
|
|
255
255
|
},
|
|
256
|
-
} as
|
|
256
|
+
} as PoolbotConfig;
|
|
257
257
|
},
|
|
258
258
|
},
|
|
259
259
|
pairing: {
|
|
260
260
|
idLabel: "zaloUserId",
|
|
261
261
|
normalizeAllowEntry: (entry) => entry.replace(/^(zalo|zl):/i, ""),
|
|
262
262
|
notifyApproval: async ({ cfg, id }) => {
|
|
263
|
-
const account = resolveZaloAccount({ cfg: cfg as
|
|
263
|
+
const account = resolveZaloAccount({ cfg: cfg as PoolbotConfig });
|
|
264
264
|
if (!account.token) throw new Error("Zalo token not configured");
|
|
265
265
|
await sendMessageZalo(id, PAIRING_APPROVED_MESSAGE, { token: account.token });
|
|
266
266
|
},
|
|
@@ -293,7 +293,7 @@ export const zaloPlugin: ChannelPlugin<ResolvedZaloAccount> = {
|
|
|
293
293
|
sendText: async ({ to, text, accountId, cfg }) => {
|
|
294
294
|
const result = await sendMessageZalo(to, text, {
|
|
295
295
|
accountId: accountId ?? undefined,
|
|
296
|
-
cfg: cfg as
|
|
296
|
+
cfg: cfg as PoolbotConfig,
|
|
297
297
|
});
|
|
298
298
|
return {
|
|
299
299
|
channel: "zalo",
|
|
@@ -306,7 +306,7 @@ export const zaloPlugin: ChannelPlugin<ResolvedZaloAccount> = {
|
|
|
306
306
|
const result = await sendMessageZalo(to, text, {
|
|
307
307
|
accountId: accountId ?? undefined,
|
|
308
308
|
mediaUrl,
|
|
309
|
-
cfg: cfg as
|
|
309
|
+
cfg: cfg as PoolbotConfig,
|
|
310
310
|
});
|
|
311
311
|
return {
|
|
312
312
|
channel: "zalo",
|
|
@@ -379,7 +379,7 @@ export const zaloPlugin: ChannelPlugin<ResolvedZaloAccount> = {
|
|
|
379
379
|
return monitorZaloProvider({
|
|
380
380
|
token,
|
|
381
381
|
account,
|
|
382
|
-
config: ctx.cfg as
|
|
382
|
+
config: ctx.cfg as PoolbotConfig,
|
|
383
383
|
runtime: ctx.runtime,
|
|
384
384
|
abortSignal: ctx.abortSignal,
|
|
385
385
|
useWebhook: Boolean(account.config.webhookUrl),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { IncomingMessage, ServerResponse } from "node:http";
|
|
2
2
|
|
|
3
|
-
import type {
|
|
3
|
+
import type { PoolbotConfig, MarkdownTableMode } from "poolbot/plugin-sdk";
|
|
4
4
|
|
|
5
5
|
import type { ResolvedZaloAccount } from "./accounts.js";
|
|
6
6
|
import {
|
|
@@ -25,7 +25,7 @@ export type ZaloRuntimeEnv = {
|
|
|
25
25
|
export type ZaloMonitorOptions = {
|
|
26
26
|
token: string;
|
|
27
27
|
account: ResolvedZaloAccount;
|
|
28
|
-
config:
|
|
28
|
+
config: PoolbotConfig;
|
|
29
29
|
runtime: ZaloRuntimeEnv;
|
|
30
30
|
abortSignal: AbortSignal;
|
|
31
31
|
useWebhook?: boolean;
|
|
@@ -94,7 +94,7 @@ async function readJsonBody(req: IncomingMessage, maxBytes: number) {
|
|
|
94
94
|
type WebhookTarget = {
|
|
95
95
|
token: string;
|
|
96
96
|
account: ResolvedZaloAccount;
|
|
97
|
-
config:
|
|
97
|
+
config: PoolbotConfig;
|
|
98
98
|
runtime: ZaloRuntimeEnv;
|
|
99
99
|
core: ZaloCoreRuntime;
|
|
100
100
|
secret: string;
|
|
@@ -217,7 +217,7 @@ export async function handleZaloWebhookRequest(
|
|
|
217
217
|
function startPollingLoop(params: {
|
|
218
218
|
token: string;
|
|
219
219
|
account: ResolvedZaloAccount;
|
|
220
|
-
config:
|
|
220
|
+
config: PoolbotConfig;
|
|
221
221
|
runtime: ZaloRuntimeEnv;
|
|
222
222
|
core: ZaloCoreRuntime;
|
|
223
223
|
abortSignal: AbortSignal;
|
|
@@ -280,7 +280,7 @@ async function processUpdate(
|
|
|
280
280
|
update: ZaloUpdate,
|
|
281
281
|
token: string,
|
|
282
282
|
account: ResolvedZaloAccount,
|
|
283
|
-
config:
|
|
283
|
+
config: PoolbotConfig,
|
|
284
284
|
runtime: ZaloRuntimeEnv,
|
|
285
285
|
core: ZaloCoreRuntime,
|
|
286
286
|
mediaMaxMb: number,
|
|
@@ -331,7 +331,7 @@ async function handleTextMessage(
|
|
|
331
331
|
message: ZaloMessage,
|
|
332
332
|
token: string,
|
|
333
333
|
account: ResolvedZaloAccount,
|
|
334
|
-
config:
|
|
334
|
+
config: PoolbotConfig,
|
|
335
335
|
runtime: ZaloRuntimeEnv,
|
|
336
336
|
core: ZaloCoreRuntime,
|
|
337
337
|
statusSink?: (patch: { lastInboundAt?: number; lastOutboundAt?: number }) => void,
|
|
@@ -359,7 +359,7 @@ async function handleImageMessage(
|
|
|
359
359
|
message: ZaloMessage,
|
|
360
360
|
token: string,
|
|
361
361
|
account: ResolvedZaloAccount,
|
|
362
|
-
config:
|
|
362
|
+
config: PoolbotConfig,
|
|
363
363
|
runtime: ZaloRuntimeEnv,
|
|
364
364
|
core: ZaloCoreRuntime,
|
|
365
365
|
mediaMaxMb: number,
|
|
@@ -407,7 +407,7 @@ async function processMessageWithPipeline(params: {
|
|
|
407
407
|
message: ZaloMessage;
|
|
408
408
|
token: string;
|
|
409
409
|
account: ResolvedZaloAccount;
|
|
410
|
-
config:
|
|
410
|
+
config: PoolbotConfig;
|
|
411
411
|
runtime: ZaloRuntimeEnv;
|
|
412
412
|
core: ZaloCoreRuntime;
|
|
413
413
|
text?: string;
|
|
@@ -616,7 +616,7 @@ async function deliverZaloReply(params: {
|
|
|
616
616
|
chatId: string;
|
|
617
617
|
runtime: ZaloRuntimeEnv;
|
|
618
618
|
core: ZaloCoreRuntime;
|
|
619
|
-
config:
|
|
619
|
+
config: PoolbotConfig;
|
|
620
620
|
accountId?: string;
|
|
621
621
|
statusSink?: (patch: { lastInboundAt?: number; lastOutboundAt?: number }) => void;
|
|
622
622
|
fetcher?: ZaloFetch;
|
|
@@ -3,7 +3,7 @@ import type { AddressInfo } from "node:net";
|
|
|
3
3
|
|
|
4
4
|
import { describe, expect, it } from "vitest";
|
|
5
5
|
|
|
6
|
-
import type {
|
|
6
|
+
import type { PoolbotConfig, PluginRuntime } from "poolbot/plugin-sdk";
|
|
7
7
|
import type { ResolvedZaloAccount } from "./types.js";
|
|
8
8
|
import { handleZaloWebhookRequest, registerZaloWebhookTarget } from "./monitor.js";
|
|
9
9
|
|
|
@@ -37,7 +37,7 @@ describe("handleZaloWebhookRequest", () => {
|
|
|
37
37
|
const unregister = registerZaloWebhookTarget({
|
|
38
38
|
token: "tok",
|
|
39
39
|
account,
|
|
40
|
-
config: {} as
|
|
40
|
+
config: {} as PoolbotConfig,
|
|
41
41
|
runtime: {},
|
|
42
42
|
core,
|
|
43
43
|
secret: "secret",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
ChannelOnboardingAdapter,
|
|
3
3
|
ChannelOnboardingDmPolicy,
|
|
4
|
-
|
|
4
|
+
PoolbotConfig,
|
|
5
5
|
WizardPrompter,
|
|
6
6
|
} from "poolbot/plugin-sdk";
|
|
7
7
|
import {
|
|
@@ -22,7 +22,7 @@ const channel = "zalo" as const;
|
|
|
22
22
|
type UpdateMode = "polling" | "webhook";
|
|
23
23
|
|
|
24
24
|
function setZaloDmPolicy(
|
|
25
|
-
cfg:
|
|
25
|
+
cfg: PoolbotConfig,
|
|
26
26
|
dmPolicy: "pairing" | "allowlist" | "open" | "disabled",
|
|
27
27
|
) {
|
|
28
28
|
const allowFrom = dmPolicy === "open" ? addWildcardAllowFrom(cfg.channels?.zalo?.allowFrom) : undefined;
|
|
@@ -36,17 +36,17 @@ function setZaloDmPolicy(
|
|
|
36
36
|
...(allowFrom ? { allowFrom } : {}),
|
|
37
37
|
},
|
|
38
38
|
},
|
|
39
|
-
} as
|
|
39
|
+
} as PoolbotConfig;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
function setZaloUpdateMode(
|
|
43
|
-
cfg:
|
|
43
|
+
cfg: PoolbotConfig,
|
|
44
44
|
accountId: string,
|
|
45
45
|
mode: UpdateMode,
|
|
46
46
|
webhookUrl?: string,
|
|
47
47
|
webhookSecret?: string,
|
|
48
48
|
webhookPath?: string,
|
|
49
|
-
):
|
|
49
|
+
): PoolbotConfig {
|
|
50
50
|
const isDefault = accountId === DEFAULT_ACCOUNT_ID;
|
|
51
51
|
if (mode === "polling") {
|
|
52
52
|
if (isDefault) {
|
|
@@ -62,7 +62,7 @@ function setZaloUpdateMode(
|
|
|
62
62
|
...cfg.channels,
|
|
63
63
|
zalo: rest,
|
|
64
64
|
},
|
|
65
|
-
} as
|
|
65
|
+
} as PoolbotConfig;
|
|
66
66
|
}
|
|
67
67
|
const accounts = { ...(cfg.channels?.zalo?.accounts ?? {}) } as Record<
|
|
68
68
|
string,
|
|
@@ -85,7 +85,7 @@ function setZaloUpdateMode(
|
|
|
85
85
|
accounts,
|
|
86
86
|
},
|
|
87
87
|
},
|
|
88
|
-
} as
|
|
88
|
+
} as PoolbotConfig;
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
if (isDefault) {
|
|
@@ -100,7 +100,7 @@ function setZaloUpdateMode(
|
|
|
100
100
|
webhookPath,
|
|
101
101
|
},
|
|
102
102
|
},
|
|
103
|
-
} as
|
|
103
|
+
} as PoolbotConfig;
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
const accounts = { ...(cfg.channels?.zalo?.accounts ?? {}) } as Record<
|
|
@@ -122,7 +122,7 @@ function setZaloUpdateMode(
|
|
|
122
122
|
accounts,
|
|
123
123
|
},
|
|
124
124
|
},
|
|
125
|
-
} as
|
|
125
|
+
} as PoolbotConfig;
|
|
126
126
|
}
|
|
127
127
|
|
|
128
128
|
async function noteZaloTokenHelp(prompter: WizardPrompter): Promise<void> {
|
|
@@ -139,10 +139,10 @@ async function noteZaloTokenHelp(prompter: WizardPrompter): Promise<void> {
|
|
|
139
139
|
}
|
|
140
140
|
|
|
141
141
|
async function promptZaloAllowFrom(params: {
|
|
142
|
-
cfg:
|
|
142
|
+
cfg: PoolbotConfig;
|
|
143
143
|
prompter: WizardPrompter;
|
|
144
144
|
accountId: string;
|
|
145
|
-
}): Promise<
|
|
145
|
+
}): Promise<PoolbotConfig> {
|
|
146
146
|
const { cfg, prompter, accountId } = params;
|
|
147
147
|
const resolved = resolveZaloAccount({ cfg, accountId });
|
|
148
148
|
const existingAllowFrom = resolved.config.allowFrom ?? [];
|
|
@@ -176,7 +176,7 @@ async function promptZaloAllowFrom(params: {
|
|
|
176
176
|
allowFrom: unique,
|
|
177
177
|
},
|
|
178
178
|
},
|
|
179
|
-
} as
|
|
179
|
+
} as PoolbotConfig;
|
|
180
180
|
}
|
|
181
181
|
|
|
182
182
|
return {
|
|
@@ -197,7 +197,7 @@ async function promptZaloAllowFrom(params: {
|
|
|
197
197
|
},
|
|
198
198
|
},
|
|
199
199
|
},
|
|
200
|
-
} as
|
|
200
|
+
} as PoolbotConfig;
|
|
201
201
|
}
|
|
202
202
|
|
|
203
203
|
const dmPolicy: ChannelOnboardingDmPolicy = {
|
|
@@ -206,14 +206,14 @@ const dmPolicy: ChannelOnboardingDmPolicy = {
|
|
|
206
206
|
policyKey: "channels.zalo.dmPolicy",
|
|
207
207
|
allowFromKey: "channels.zalo.allowFrom",
|
|
208
208
|
getCurrent: (cfg) => (cfg.channels?.zalo?.dmPolicy ?? "pairing") as "pairing",
|
|
209
|
-
setPolicy: (cfg, policy) => setZaloDmPolicy(cfg as
|
|
209
|
+
setPolicy: (cfg, policy) => setZaloDmPolicy(cfg as PoolbotConfig, policy),
|
|
210
210
|
promptAllowFrom: async ({ cfg, prompter, accountId }) => {
|
|
211
211
|
const id =
|
|
212
212
|
accountId && normalizeAccountId(accountId)
|
|
213
213
|
? normalizeAccountId(accountId) ?? DEFAULT_ACCOUNT_ID
|
|
214
|
-
: resolveDefaultZaloAccountId(cfg as
|
|
214
|
+
: resolveDefaultZaloAccountId(cfg as PoolbotConfig);
|
|
215
215
|
return promptZaloAllowFrom({
|
|
216
|
-
cfg: cfg as
|
|
216
|
+
cfg: cfg as PoolbotConfig,
|
|
217
217
|
prompter,
|
|
218
218
|
accountId: id,
|
|
219
219
|
});
|
|
@@ -224,8 +224,8 @@ export const zaloOnboardingAdapter: ChannelOnboardingAdapter = {
|
|
|
224
224
|
channel,
|
|
225
225
|
dmPolicy,
|
|
226
226
|
getStatus: async ({ cfg }) => {
|
|
227
|
-
const configured = listZaloAccountIds(cfg as
|
|
228
|
-
Boolean(resolveZaloAccount({ cfg: cfg as
|
|
227
|
+
const configured = listZaloAccountIds(cfg as PoolbotConfig).some((accountId) =>
|
|
228
|
+
Boolean(resolveZaloAccount({ cfg: cfg as PoolbotConfig, accountId }).token),
|
|
229
229
|
);
|
|
230
230
|
return {
|
|
231
231
|
channel,
|
|
@@ -237,13 +237,13 @@ export const zaloOnboardingAdapter: ChannelOnboardingAdapter = {
|
|
|
237
237
|
},
|
|
238
238
|
configure: async ({ cfg, prompter, accountOverrides, shouldPromptAccountIds, forceAllowFrom }) => {
|
|
239
239
|
const zaloOverride = accountOverrides.zalo?.trim();
|
|
240
|
-
const defaultZaloAccountId = resolveDefaultZaloAccountId(cfg as
|
|
240
|
+
const defaultZaloAccountId = resolveDefaultZaloAccountId(cfg as PoolbotConfig);
|
|
241
241
|
let zaloAccountId = zaloOverride
|
|
242
242
|
? normalizeAccountId(zaloOverride)
|
|
243
243
|
: defaultZaloAccountId;
|
|
244
244
|
if (shouldPromptAccountIds && !zaloOverride) {
|
|
245
245
|
zaloAccountId = await promptAccountId({
|
|
246
|
-
cfg: cfg as
|
|
246
|
+
cfg: cfg as PoolbotConfig,
|
|
247
247
|
prompter,
|
|
248
248
|
label: "Zalo",
|
|
249
249
|
currentId: zaloAccountId,
|
|
@@ -252,7 +252,7 @@ export const zaloOnboardingAdapter: ChannelOnboardingAdapter = {
|
|
|
252
252
|
});
|
|
253
253
|
}
|
|
254
254
|
|
|
255
|
-
let next = cfg as
|
|
255
|
+
let next = cfg as PoolbotConfig;
|
|
256
256
|
const resolvedAccount = resolveZaloAccount({ cfg: next, accountId: zaloAccountId });
|
|
257
257
|
const accountConfigured = Boolean(resolvedAccount.token);
|
|
258
258
|
const allowEnv = zaloAccountId === DEFAULT_ACCOUNT_ID;
|
|
@@ -280,7 +280,7 @@ export const zaloOnboardingAdapter: ChannelOnboardingAdapter = {
|
|
|
280
280
|
enabled: true,
|
|
281
281
|
},
|
|
282
282
|
},
|
|
283
|
-
} as
|
|
283
|
+
} as PoolbotConfig;
|
|
284
284
|
} else {
|
|
285
285
|
token = String(
|
|
286
286
|
await prompter.text({
|
|
@@ -323,7 +323,7 @@ export const zaloOnboardingAdapter: ChannelOnboardingAdapter = {
|
|
|
323
323
|
botToken: token,
|
|
324
324
|
},
|
|
325
325
|
},
|
|
326
|
-
} as
|
|
326
|
+
} as PoolbotConfig;
|
|
327
327
|
} else {
|
|
328
328
|
next = {
|
|
329
329
|
...next,
|
|
@@ -342,7 +342,7 @@ export const zaloOnboardingAdapter: ChannelOnboardingAdapter = {
|
|
|
342
342
|
},
|
|
343
343
|
},
|
|
344
344
|
},
|
|
345
|
-
} as
|
|
345
|
+
} as PoolbotConfig;
|
|
346
346
|
}
|
|
347
347
|
}
|
|
348
348
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { PoolbotConfig } from "poolbot/plugin-sdk";
|
|
2
2
|
|
|
3
3
|
import type { ZaloFetch } from "./api.js";
|
|
4
4
|
import { sendMessage, sendPhoto } from "./api.js";
|
|
@@ -9,7 +9,7 @@ import { resolveZaloToken } from "./token.js";
|
|
|
9
9
|
export type ZaloSendOptions = {
|
|
10
10
|
token?: string;
|
|
11
11
|
accountId?: string;
|
|
12
|
-
cfg?:
|
|
12
|
+
cfg?: PoolbotConfig;
|
|
13
13
|
mediaUrl?: string;
|
|
14
14
|
caption?: string;
|
|
15
15
|
verbose?: boolean;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @poolbot/zalouser
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Pool-Bot extension for Zalo Personal Account messaging via [zca-cli](https://zca-cli.dev).
|
|
4
4
|
|
|
5
5
|
> **Warning:** Using Zalo automation may result in account suspension or ban. Use at your own risk. This is an unofficial integration.
|
|
6
6
|
|
|
@@ -88,7 +88,7 @@ poolbot channels login --channel zalouser
|
|
|
88
88
|
### Send a Message
|
|
89
89
|
|
|
90
90
|
```bash
|
|
91
|
-
poolbot message send --channel zalouser --target <threadId> --message "Hello from
|
|
91
|
+
poolbot message send --channel zalouser --target <threadId> --message "Hello from Pool-Bot!"
|
|
92
92
|
```
|
|
93
93
|
|
|
94
94
|
## Configuration
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { PoolbotPluginApi } from "poolbot/plugin-sdk";
|
|
2
2
|
import { emptyPluginConfigSchema } from "poolbot/plugin-sdk";
|
|
3
3
|
|
|
4
4
|
import { zalouserDock, zalouserPlugin } from "./src/channel.js";
|
|
@@ -10,7 +10,7 @@ const plugin = {
|
|
|
10
10
|
name: "Zalo Personal",
|
|
11
11
|
description: "Zalo personal account messaging via zca-cli",
|
|
12
12
|
configSchema: emptyPluginConfigSchema(),
|
|
13
|
-
register(api:
|
|
13
|
+
register(api: PoolbotPluginApi) {
|
|
14
14
|
setZalouserRuntime(api.runtime);
|
|
15
15
|
// Register channel plugin (for onboarding & gateway)
|
|
16
16
|
api.registerChannel({ plugin: zalouserPlugin, dock: zalouserDock });
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@poolbot/zalouser",
|
|
3
3
|
"version": "2026.1.26",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"description": "
|
|
5
|
+
"description": "Poolbot Zalo Personal Account plugin via zca-cli",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"poolbot": "workspace:*",
|
|
8
8
|
"@sinclair/typebox": "0.34.47"
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { PoolbotConfig } from "poolbot/plugin-sdk";
|
|
2
2
|
import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "poolbot/plugin-sdk";
|
|
3
3
|
|
|
4
4
|
import { runZca, parseJsonOutput } from "./zca.js";
|
|
5
5
|
import type { ResolvedZalouserAccount, ZalouserAccountConfig, ZalouserConfig } from "./types.js";
|
|
6
6
|
|
|
7
|
-
function listConfiguredAccountIds(cfg:
|
|
7
|
+
function listConfiguredAccountIds(cfg: PoolbotConfig): string[] {
|
|
8
8
|
const accounts = (cfg.channels?.zalouser as ZalouserConfig | undefined)?.accounts;
|
|
9
9
|
if (!accounts || typeof accounts !== "object") return [];
|
|
10
10
|
return Object.keys(accounts).filter(Boolean);
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
export function listZalouserAccountIds(cfg:
|
|
13
|
+
export function listZalouserAccountIds(cfg: PoolbotConfig): string[] {
|
|
14
14
|
const ids = listConfiguredAccountIds(cfg);
|
|
15
15
|
if (ids.length === 0) return [DEFAULT_ACCOUNT_ID];
|
|
16
16
|
return ids.sort((a, b) => a.localeCompare(b));
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
export function resolveDefaultZalouserAccountId(cfg:
|
|
19
|
+
export function resolveDefaultZalouserAccountId(cfg: PoolbotConfig): string {
|
|
20
20
|
const zalouserConfig = cfg.channels?.zalouser as ZalouserConfig | undefined;
|
|
21
21
|
if (zalouserConfig?.defaultAccount?.trim()) return zalouserConfig.defaultAccount.trim();
|
|
22
22
|
const ids = listZalouserAccountIds(cfg);
|
|
@@ -25,7 +25,7 @@ export function resolveDefaultZalouserAccountId(cfg: MoltbotConfig): string {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
function resolveAccountConfig(
|
|
28
|
-
cfg:
|
|
28
|
+
cfg: PoolbotConfig,
|
|
29
29
|
accountId: string,
|
|
30
30
|
): ZalouserAccountConfig | undefined {
|
|
31
31
|
const accounts = (cfg.channels?.zalouser as ZalouserConfig | undefined)?.accounts;
|
|
@@ -34,7 +34,7 @@ function resolveAccountConfig(
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
function mergeZalouserAccountConfig(
|
|
37
|
-
cfg:
|
|
37
|
+
cfg: PoolbotConfig,
|
|
38
38
|
accountId: string,
|
|
39
39
|
): ZalouserAccountConfig {
|
|
40
40
|
const raw = (cfg.channels?.zalouser ?? {}) as ZalouserConfig;
|
|
@@ -56,7 +56,7 @@ export async function checkZcaAuthenticated(profile: string): Promise<boolean> {
|
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
export async function resolveZalouserAccount(params: {
|
|
59
|
-
cfg:
|
|
59
|
+
cfg: PoolbotConfig;
|
|
60
60
|
accountId?: string | null;
|
|
61
61
|
}): Promise<ResolvedZalouserAccount> {
|
|
62
62
|
const accountId = normalizeAccountId(params.accountId);
|
|
@@ -78,7 +78,7 @@ export async function resolveZalouserAccount(params: {
|
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
export function resolveZalouserAccountSync(params: {
|
|
81
|
-
cfg:
|
|
81
|
+
cfg: PoolbotConfig;
|
|
82
82
|
accountId?: string | null;
|
|
83
83
|
}): ResolvedZalouserAccount {
|
|
84
84
|
const accountId = normalizeAccountId(params.accountId);
|
|
@@ -99,7 +99,7 @@ export function resolveZalouserAccountSync(params: {
|
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
export async function listEnabledZalouserAccounts(
|
|
102
|
-
cfg:
|
|
102
|
+
cfg: PoolbotConfig,
|
|
103
103
|
): Promise<ResolvedZalouserAccount[]> {
|
|
104
104
|
const ids = listZalouserAccountIds(cfg);
|
|
105
105
|
const accounts = await Promise.all(
|