@openclaw/zalo 2026.5.14-beta.1 → 2026.5.14-beta.2

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.
@@ -1,4 +1,4 @@
1
- import { t as sendMessageZalo } from "./send-B33YPMz_.js";
1
+ import { t as sendMessageZalo } from "./send-DC0JAcxV.js";
2
2
  //#region extensions/zalo/src/actions.runtime.ts
3
3
  const zaloActionsRuntime = { sendMessageZalo };
4
4
  //#endregion
package/dist/api.js CHANGED
@@ -1,5 +1,5 @@
1
- import { t as zaloPlugin } from "./channel-Cm5LsFn-.js";
2
- import { n as zaloDmPolicy, r as zaloSetupAdapter, t as createZaloSetupWizardProxy } from "./setup-core-B-97bdBF.js";
3
- import { n as resolveZaloRuntimeGroupPolicy } from "./group-access-B_fAqJAN.js";
1
+ import { n as zaloDmPolicy, r as zaloSetupAdapter, t as createZaloSetupWizardProxy } from "./setup-core-c-VVz39c.js";
2
+ import { t as zaloPlugin } from "./channel-Ds8WfCFp.js";
3
+ import { n as resolveZaloRuntimeGroupPolicy } from "./group-access-Boqk-JNd.js";
4
4
  import { zaloSetupWizard } from "./setup-api.js";
5
5
  export { createZaloSetupWizardProxy, resolveZaloRuntimeGroupPolicy, zaloDmPolicy, zaloPlugin, zaloSetupAdapter, zaloSetupWizard };
@@ -1,6 +1,5 @@
1
- import { a as resolveZaloAccount, i as resolveDefaultZaloAccountId, n as listEnabledZaloAccounts, r as listZaloAccountIds, s as buildSecretInputSchema } from "./accounts-OjbMFek2.js";
1
+ import { c as listZaloAccountIds, f as buildSecretInputSchema, l as resolveDefaultZaloAccountId, r as zaloSetupAdapter, s as listEnabledZaloAccounts, t as createZaloSetupWizardProxy, u as resolveZaloAccount } from "./setup-core-c-VVz39c.js";
2
2
  import { n as collectRuntimeConfigAssignments, r as secretTargetRegistryEntries } from "./secret-contract-Dw93tGo2.js";
3
- import { r as zaloSetupAdapter, t as createZaloSetupWizardProxy } from "./setup-core-B-97bdBF.js";
4
3
  import { describeWebhookAccountSnapshot } from "openclaw/plugin-sdk/account-helpers";
5
4
  import { DEFAULT_ACCOUNT_ID } from "openclaw/plugin-sdk/account-id";
6
5
  import { formatAllowFromLowercase } from "openclaw/plugin-sdk/allow-from";
@@ -25,7 +24,7 @@ import { AllowFromListSchema, DmPolicySchema, GroupPolicySchema, MarkdownConfigS
25
24
  import { z } from "zod";
26
25
  import { coerceStatusIssueAccountId, readStatusIssueFields } from "openclaw/plugin-sdk/extension-shared";
27
26
  //#region extensions/zalo/src/actions.ts
28
- const loadZaloActionsRuntime = createLazyRuntimeNamedExport(() => import("./actions.runtime-B-RkyU18.js"), "zaloActionsRuntime");
27
+ const loadZaloActionsRuntime = createLazyRuntimeNamedExport(() => import("./actions.runtime-DPLidmVV.js"), "zaloActionsRuntime");
29
28
  const providerId = "zalo";
30
29
  function listEnabledAccounts(cfg, accountId) {
31
30
  return (accountId ? [resolveZaloAccount({
@@ -174,8 +173,8 @@ function normalizeZaloMessagingTarget(raw) {
174
173
  if (!trimmed) return;
175
174
  return trimmed.replace(/^(zalo|zl):/i, "").trim();
176
175
  }
177
- const loadZaloChannelRuntime = createLazyRuntimeModule(() => import("./channel.runtime-4Hdh_1my.js"));
178
- const zaloSetupWizard = createZaloSetupWizardProxy(async () => (await import("./setup-surface-Cs4_XZXk.js")).zaloSetupWizard);
176
+ const loadZaloChannelRuntime = createLazyRuntimeModule(() => import("./channel.runtime-BwHejuBf.js"));
177
+ const zaloSetupWizard = createZaloSetupWizardProxy(async () => (await import("./setup-surface-DY3c-fas.js")).zaloSetupWizard);
179
178
  const zaloTextChunkLimit = 2e3;
180
179
  const zaloRawSendResultAdapter = createRawChannelSendResultAdapter({
181
180
  channel: "zalo",
@@ -1,2 +1,2 @@
1
- import { t as zaloPlugin } from "./channel-Cm5LsFn-.js";
1
+ import { t as zaloPlugin } from "./channel-Ds8WfCFp.js";
2
2
  export { zaloPlugin };
@@ -1,7 +1,6 @@
1
- import { c as normalizeSecretInputString } from "./accounts-OjbMFek2.js";
2
- import { n as PAIRING_APPROVED_MESSAGE } from "./runtime-api-df534_Ih.js";
3
- import { i as getMe, n as ZaloApiError, t as resolveZaloProxyFetch } from "./proxy-D5AGEsI0.js";
4
- import { t as sendMessageZalo } from "./send-B33YPMz_.js";
1
+ import { p as normalizeSecretInputString } from "./setup-core-c-VVz39c.js";
2
+ import { i as PAIRING_APPROVED_MESSAGE } from "./runtime-api-CnYIxmRv.js";
3
+ import { a as getMe, n as resolveZaloProxyFetch, r as ZaloApiError, t as sendMessageZalo } from "./send-DC0JAcxV.js";
5
4
  import { createAccountStatusSink } from "openclaw/plugin-sdk/channel-lifecycle";
6
5
  //#region extensions/zalo/src/probe.ts
7
6
  async function probeZalo(token, timeoutMs = 5e3, fetcher) {
@@ -53,7 +52,7 @@ async function probeZalo(token, timeoutMs = 5e3, fetcher) {
53
52
  //#endregion
54
53
  //#region extensions/zalo/src/channel.runtime.ts
55
54
  async function notifyZaloPairingApproval(params) {
56
- const { resolveZaloAccount } = await import("./accounts-OjbMFek2.js").then((n) => n.t);
55
+ const { resolveZaloAccount } = await import("./setup-core-c-VVz39c.js").then((n) => n.o);
57
56
  const account = resolveZaloAccount({ cfg: params.cfg });
58
57
  if (!account.token) throw new Error("Zalo token not configured");
59
58
  await sendMessageZalo(params.id, PAIRING_APPROVED_MESSAGE, { token: account.token });
@@ -87,7 +86,7 @@ async function startZaloGatewayAccount(ctx) {
87
86
  setStatus: ctx.setStatus
88
87
  });
89
88
  ctx.log?.info(`[${account.accountId}] starting provider${zaloBotLabel} mode=${mode}`);
90
- const { monitorZaloProvider } = await import("./monitor-DcrZwSax.js");
89
+ const { monitorZaloProvider } = await import("./monitor-BMpWuV4T.js");
91
90
  return monitorZaloProvider({
92
91
  token,
93
92
  account,
@@ -1,3 +1,3 @@
1
1
  import { n as collectRuntimeConfigAssignments, r as secretTargetRegistryEntries } from "./secret-contract-Dw93tGo2.js";
2
- import { n as resolveZaloRuntimeGroupPolicy } from "./group-access-B_fAqJAN.js";
2
+ import { n as resolveZaloRuntimeGroupPolicy } from "./group-access-Boqk-JNd.js";
3
3
  export { collectRuntimeConfigAssignments, resolveZaloRuntimeGroupPolicy, secretTargetRegistryEntries };
@@ -1,6 +1,6 @@
1
- import { n as resolveZaloRuntimeGroupPolicy, t as normalizeZaloAllowEntry } from "./group-access-B_fAqJAN.js";
2
- import { t as getZaloRuntime } from "./runtime-BRFxnYQx.js";
3
- import { a as getUpdates, c as sendMessage, l as sendPhoto, n as ZaloApiError, o as getWebhookInfo, r as deleteWebhook, s as sendChatAction, t as resolveZaloProxyFetch, u as setWebhook } from "./proxy-D5AGEsI0.js";
1
+ import { n as resolveZaloRuntimeGroupPolicy, t as normalizeZaloAllowEntry } from "./group-access-Boqk-JNd.js";
2
+ import { t as getZaloRuntime } from "./runtime-api-CnYIxmRv.js";
3
+ import { c as sendChatAction, d as setWebhook, i as deleteWebhook, l as sendMessage, n as resolveZaloProxyFetch, o as getUpdates, r as ZaloApiError, s as getWebhookInfo, u as sendPhoto } from "./send-DC0JAcxV.js";
4
4
  import { deliverTextOrMediaReply, resolveSendableOutboundReplyParts } from "openclaw/plugin-sdk/reply-payload";
5
5
  import { normalizeStringEntries } from "openclaw/plugin-sdk/string-coerce-runtime";
6
6
  import { resolveDefaultGroupPolicy, warnMissingProviderGroupPolicyFallbackOnce } from "openclaw/plugin-sdk/runtime-group-policy";
@@ -186,7 +186,7 @@ const ZALO_TYPING_TIMEOUT_MS = 5e3;
186
186
  let zaloWebhookModulePromise;
187
187
  const hostedMediaRouteRefs = /* @__PURE__ */ new Map();
188
188
  function loadZaloWebhookModule() {
189
- zaloWebhookModulePromise ??= import("./monitor.webhook-DDHdDX2R.js");
189
+ zaloWebhookModulePromise ??= import("./monitor.webhook-DlMvHl6I.js");
190
190
  return zaloWebhookModulePromise;
191
191
  }
192
192
  function registerSharedHostedMediaRoute(params) {
@@ -1,4 +1,4 @@
1
- import { L as registerWebhookTarget, P as readJsonWebhookBodyOrReject, R as registerWebhookTargetWithPluginRoute, W as resolveWebhookTargetWithAuthOrRejectSync, X as withResolvedWebhookRequestPipeline, i as WEBHOOK_RATE_LIMIT_DEFAULTS, r as WEBHOOK_ANOMALY_COUNTER_DEFAULTS, s as applyBasicWebhookRequestGuards, v as createFixedWindowRateLimiter, y as createWebhookAnomalyTracker, z as resolveClientIp } from "./runtime-api-df534_Ih.js";
1
+ import { B as registerWebhookTargetWithPluginRoute, I as readJsonWebhookBodyOrReject, K as resolveWebhookTargetWithAuthOrRejectSync, Q as withResolvedWebhookRequestPipeline, V as resolveClientIp, a as WEBHOOK_ANOMALY_COUNTER_DEFAULTS, b as createFixedWindowRateLimiter, l as applyBasicWebhookRequestGuards, o as WEBHOOK_RATE_LIMIT_DEFAULTS, x as createWebhookAnomalyTracker, z as registerWebhookTarget } from "./runtime-api-CnYIxmRv.js";
2
2
  import { safeEqualSecret } from "openclaw/plugin-sdk/security-runtime";
3
3
  import { createClaimableDedupe } from "openclaw/plugin-sdk/persistent-dedupe";
4
4
  //#region extensions/zalo/src/monitor.webhook.ts
@@ -1,4 +1,3 @@
1
- import "./runtime-BRFxnYQx.js";
2
1
  import { formatAllowFromLowercase as formatAllowFromLowercase$1, isNormalizedSenderAllowed } from "openclaw/plugin-sdk/allow-from";
3
2
  import { createChannelMessageReplyPipeline } from "openclaw/plugin-sdk/channel-message";
4
3
  import { PAIRING_APPROVED_MESSAGE, buildTokenChannelStatusSummary as buildTokenChannelStatusSummary$1 } from "openclaw/plugin-sdk/channel-status";
@@ -14,4 +13,11 @@ import { logTypingFailure as logTypingFailure$1 } from "openclaw/plugin-sdk/chan
14
13
  import { resolveInboundRouteEnvelopeBuilderWithRuntime as resolveInboundRouteEnvelopeBuilderWithRuntime$1 } from "openclaw/plugin-sdk/inbound-envelope";
15
14
  import { waitForAbortSignal } from "openclaw/plugin-sdk/runtime";
16
15
  import { WEBHOOK_ANOMALY_COUNTER_DEFAULTS, WEBHOOK_RATE_LIMIT_DEFAULTS, applyBasicWebhookRequestGuards, createFixedWindowRateLimiter, createWebhookAnomalyTracker, readJsonWebhookBodyOrReject, registerPluginHttpRoute as registerPluginHttpRoute$1, registerWebhookTarget, registerWebhookTargetWithPluginRoute, resolveWebhookPath as resolveWebhookPath$1, resolveWebhookTargetWithAuthOrRejectSync, withResolvedWebhookRequestPipeline } from "openclaw/plugin-sdk/webhook-ingress";
17
- export { normalizeAccountId$1 as A, resolveDefaultGroupPolicy$1 as B, hasConfiguredSecretInput$1 as C, logTypingFailure$1 as D, jsonResult as E, readStringParam as F, runSingleChannelSecretStep$1 as G, resolveOpenProviderRuntimeGroupPolicy$1 as H, registerPluginHttpRoute$1 as I, waitForAbortSignal as J, sendPayloadWithChunkedTextAndMedia$1 as K, registerWebhookTarget as L, normalizeSecretInputString as M, promptSingleChannelSecretInput$1 as N, mergeAllowFromEntries$1 as O, readJsonWebhookBodyOrReject as P, registerWebhookTargetWithPluginRoute as R, formatPairingApproveHint as S, isNumericTargetId$1 as T, resolveWebhookPath$1 as U, resolveInboundRouteEnvelopeBuilderWithRuntime$1 as V, resolveWebhookTargetWithAuthOrRejectSync as W, withResolvedWebhookRequestPipeline as X, warnMissingProviderGroupPolicyFallbackOnce$1 as Y, createDedupeCache as _, addWildcardAllowFrom$1 as a, deliverTextOrMediaReply$1 as b, applySetupAccountConfigPatch as c, buildSecretInputSchema as d, buildSingleChannelSecretPromptState$1 as f, createChannelPairingController$1 as g, createChannelMessageReplyPipeline as h, WEBHOOK_RATE_LIMIT_DEFAULTS as i, normalizeResolvedSecretInputString as j, migrateBaseNameToDefaultAccount as k, buildBaseAccountStatusSnapshot as l, chunkTextForOutbound$1 as m, PAIRING_APPROVED_MESSAGE as n, applyAccountNameToChannelSection as o, buildTokenChannelStatusSummary$1 as p, setTopLevelChannelDmPolicyWithAllowFrom as q, WEBHOOK_ANOMALY_COUNTER_DEFAULTS as r, applyBasicWebhookRequestGuards as s, DEFAULT_ACCOUNT_ID$1 as t, buildChannelConfigSchema as u, createFixedWindowRateLimiter as v, isNormalizedSenderAllowed as w, formatAllowFromLowercase$1 as x, createWebhookAnomalyTracker as y, resolveClientIp as z };
16
+ import { createPluginRuntimeStore } from "openclaw/plugin-sdk/runtime-store";
17
+ //#region extensions/zalo/src/runtime.ts
18
+ const { setRuntime: setZaloRuntime, getRuntime: getZaloRuntime } = createPluginRuntimeStore({
19
+ pluginId: "zalo",
20
+ errorMessage: "Zalo runtime not initialized"
21
+ });
22
+ //#endregion
23
+ export { mergeAllowFromEntries$1 as A, registerWebhookTargetWithPluginRoute as B, formatAllowFromLowercase$1 as C, isNumericTargetId$1 as D, isNormalizedSenderAllowed as E, promptSingleChannelSecretInput$1 as F, resolveWebhookPath$1 as G, resolveDefaultGroupPolicy$1 as H, readJsonWebhookBodyOrReject as I, sendPayloadWithChunkedTextAndMedia$1 as J, resolveWebhookTargetWithAuthOrRejectSync as K, readStringParam as L, normalizeAccountId$1 as M, normalizeResolvedSecretInputString as N, jsonResult as O, normalizeSecretInputString as P, withResolvedWebhookRequestPipeline as Q, registerPluginHttpRoute$1 as R, deliverTextOrMediaReply$1 as S, hasConfiguredSecretInput$1 as T, resolveInboundRouteEnvelopeBuilderWithRuntime$1 as U, resolveClientIp as V, resolveOpenProviderRuntimeGroupPolicy$1 as W, waitForAbortSignal as X, setTopLevelChannelDmPolicyWithAllowFrom as Y, warnMissingProviderGroupPolicyFallbackOnce$1 as Z, createChannelMessageReplyPipeline as _, WEBHOOK_ANOMALY_COUNTER_DEFAULTS as a, createFixedWindowRateLimiter as b, applyAccountNameToChannelSection as c, buildBaseAccountStatusSnapshot as d, buildChannelConfigSchema as f, chunkTextForOutbound$1 as g, buildTokenChannelStatusSummary$1 as h, PAIRING_APPROVED_MESSAGE as i, migrateBaseNameToDefaultAccount as j, logTypingFailure$1 as k, applyBasicWebhookRequestGuards as l, buildSingleChannelSecretPromptState$1 as m, setZaloRuntime as n, WEBHOOK_RATE_LIMIT_DEFAULTS as o, buildSecretInputSchema as p, runSingleChannelSecretStep$1 as q, DEFAULT_ACCOUNT_ID$1 as r, addWildcardAllowFrom$1 as s, getZaloRuntime as t, applySetupAccountConfigPatch as u, createChannelPairingController$1 as v, formatPairingApproveHint as w, createWebhookAnomalyTracker as x, createDedupeCache as y, registerWebhookTarget as z };
@@ -1,3 +1,2 @@
1
- import { A as normalizeAccountId, B as resolveDefaultGroupPolicy, C as hasConfiguredSecretInput, D as logTypingFailure, E as jsonResult, F as readStringParam, G as runSingleChannelSecretStep, H as resolveOpenProviderRuntimeGroupPolicy, I as registerPluginHttpRoute, J as waitForAbortSignal, K as sendPayloadWithChunkedTextAndMedia, L as registerWebhookTarget, M as normalizeSecretInputString, N as promptSingleChannelSecretInput, O as mergeAllowFromEntries, P as readJsonWebhookBodyOrReject, R as registerWebhookTargetWithPluginRoute, S as formatPairingApproveHint, T as isNumericTargetId, U as resolveWebhookPath, V as resolveInboundRouteEnvelopeBuilderWithRuntime, W as resolveWebhookTargetWithAuthOrRejectSync, X as withResolvedWebhookRequestPipeline, Y as warnMissingProviderGroupPolicyFallbackOnce, _ as createDedupeCache, a as addWildcardAllowFrom, b as deliverTextOrMediaReply, c as applySetupAccountConfigPatch, d as buildSecretInputSchema, f as buildSingleChannelSecretPromptState, g as createChannelPairingController, h as createChannelMessageReplyPipeline, i as WEBHOOK_RATE_LIMIT_DEFAULTS, j as normalizeResolvedSecretInputString, k as migrateBaseNameToDefaultAccount, l as buildBaseAccountStatusSnapshot, m as chunkTextForOutbound, n as PAIRING_APPROVED_MESSAGE, o as applyAccountNameToChannelSection, p as buildTokenChannelStatusSummary, q as setTopLevelChannelDmPolicyWithAllowFrom, r as WEBHOOK_ANOMALY_COUNTER_DEFAULTS, s as applyBasicWebhookRequestGuards, t as DEFAULT_ACCOUNT_ID, u as buildChannelConfigSchema, v as createFixedWindowRateLimiter, w as isNormalizedSenderAllowed, x as formatAllowFromLowercase, y as createWebhookAnomalyTracker, z as resolveClientIp } from "./runtime-api-df534_Ih.js";
2
- import { n as setZaloRuntime } from "./runtime-BRFxnYQx.js";
1
+ import { A as mergeAllowFromEntries, B as registerWebhookTargetWithPluginRoute, C as formatAllowFromLowercase, D as isNumericTargetId, E as isNormalizedSenderAllowed, F as promptSingleChannelSecretInput, G as resolveWebhookPath, H as resolveDefaultGroupPolicy, I as readJsonWebhookBodyOrReject, J as sendPayloadWithChunkedTextAndMedia, K as resolveWebhookTargetWithAuthOrRejectSync, L as readStringParam, M as normalizeAccountId, N as normalizeResolvedSecretInputString, O as jsonResult, P as normalizeSecretInputString, Q as withResolvedWebhookRequestPipeline, R as registerPluginHttpRoute, S as deliverTextOrMediaReply, T as hasConfiguredSecretInput, U as resolveInboundRouteEnvelopeBuilderWithRuntime, V as resolveClientIp, W as resolveOpenProviderRuntimeGroupPolicy, X as waitForAbortSignal, Y as setTopLevelChannelDmPolicyWithAllowFrom, Z as warnMissingProviderGroupPolicyFallbackOnce, _ as createChannelMessageReplyPipeline, a as WEBHOOK_ANOMALY_COUNTER_DEFAULTS, b as createFixedWindowRateLimiter, c as applyAccountNameToChannelSection, d as buildBaseAccountStatusSnapshot, f as buildChannelConfigSchema, g as chunkTextForOutbound, h as buildTokenChannelStatusSummary, i as PAIRING_APPROVED_MESSAGE, j as migrateBaseNameToDefaultAccount, k as logTypingFailure, l as applyBasicWebhookRequestGuards, m as buildSingleChannelSecretPromptState, n as setZaloRuntime, o as WEBHOOK_RATE_LIMIT_DEFAULTS, p as buildSecretInputSchema, q as runSingleChannelSecretStep, r as DEFAULT_ACCOUNT_ID, s as addWildcardAllowFrom, u as applySetupAccountConfigPatch, v as createChannelPairingController, w as formatPairingApproveHint, x as createWebhookAnomalyTracker, y as createDedupeCache, z as registerWebhookTarget } from "./runtime-api-CnYIxmRv.js";
3
2
  export { DEFAULT_ACCOUNT_ID, PAIRING_APPROVED_MESSAGE, WEBHOOK_ANOMALY_COUNTER_DEFAULTS, WEBHOOK_RATE_LIMIT_DEFAULTS, addWildcardAllowFrom, applyAccountNameToChannelSection, applyBasicWebhookRequestGuards, applySetupAccountConfigPatch, buildBaseAccountStatusSnapshot, buildChannelConfigSchema, buildSecretInputSchema, buildSingleChannelSecretPromptState, buildTokenChannelStatusSummary, chunkTextForOutbound, createChannelMessageReplyPipeline, createChannelPairingController, createDedupeCache, createFixedWindowRateLimiter, createWebhookAnomalyTracker, deliverTextOrMediaReply, formatAllowFromLowercase, formatPairingApproveHint, hasConfiguredSecretInput, isNormalizedSenderAllowed, isNumericTargetId, jsonResult, logTypingFailure, mergeAllowFromEntries, migrateBaseNameToDefaultAccount, normalizeAccountId, normalizeResolvedSecretInputString, normalizeSecretInputString, promptSingleChannelSecretInput, readJsonWebhookBodyOrReject, readStringParam, registerPluginHttpRoute, registerWebhookTarget, registerWebhookTargetWithPluginRoute, resolveClientIp, resolveDefaultGroupPolicy, resolveInboundRouteEnvelopeBuilderWithRuntime, resolveOpenProviderRuntimeGroupPolicy, resolveWebhookPath, resolveWebhookTargetWithAuthOrRejectSync, runSingleChannelSecretStep, sendPayloadWithChunkedTextAndMedia, setTopLevelChannelDmPolicyWithAllowFrom, setZaloRuntime, waitForAbortSignal, warnMissingProviderGroupPolicyFallbackOnce, withResolvedWebhookRequestPipeline };
@@ -0,0 +1,270 @@
1
+ import { d as resolveZaloToken, u as resolveZaloAccount } from "./setup-core-c-VVz39c.js";
2
+ import { createMessageReceiptFromOutboundResults } from "openclaw/plugin-sdk/channel-message";
3
+ import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
4
+ import { resolvePinnedHostnameWithPolicy } from "openclaw/plugin-sdk/ssrf-runtime";
5
+ import { makeProxyFetch } from "openclaw/plugin-sdk/fetch-runtime";
6
+ //#region extensions/zalo/src/api.ts
7
+ /**
8
+ * Zalo Bot API client
9
+ * @see https://bot.zaloplatforms.com/docs
10
+ */
11
+ const ZALO_API_BASE = "https://bot-api.zaloplatforms.com";
12
+ const ZALO_MEDIA_SSRF_POLICY = {};
13
+ var ZaloApiError = class extends Error {
14
+ constructor(message, errorCode, description) {
15
+ super(message);
16
+ this.errorCode = errorCode;
17
+ this.description = description;
18
+ this.name = "ZaloApiError";
19
+ }
20
+ /** True if this is a long-polling timeout (no updates available) */
21
+ get isPollingTimeout() {
22
+ return this.errorCode === 408;
23
+ }
24
+ };
25
+ /**
26
+ * Call the Zalo Bot API
27
+ */
28
+ async function callZaloApi(method, token, body, options) {
29
+ const url = `${ZALO_API_BASE}/bot${token}/${method}`;
30
+ const controller = new AbortController();
31
+ const timeoutId = options?.timeoutMs ? setTimeout(() => controller.abort(), options.timeoutMs) : void 0;
32
+ const fetcher = options?.fetch ?? fetch;
33
+ try {
34
+ const data = await (await fetcher(url, {
35
+ method: "POST",
36
+ headers: { "Content-Type": "application/json" },
37
+ body: body ? JSON.stringify(body) : void 0,
38
+ signal: controller.signal
39
+ })).json();
40
+ if (!data.ok) throw new ZaloApiError(data.description ?? `Zalo API error: ${method}`, data.error_code, data.description);
41
+ return data;
42
+ } finally {
43
+ if (timeoutId) clearTimeout(timeoutId);
44
+ }
45
+ }
46
+ /**
47
+ * Validate bot token and get bot info
48
+ */
49
+ async function getMe(token, timeoutMs, fetcher) {
50
+ return callZaloApi("getMe", token, void 0, {
51
+ timeoutMs,
52
+ fetch: fetcher
53
+ });
54
+ }
55
+ /**
56
+ * Send a text message
57
+ */
58
+ async function sendMessage(token, params, fetcher) {
59
+ return callZaloApi("sendMessage", token, params, { fetch: fetcher });
60
+ }
61
+ /**
62
+ * Send a photo message
63
+ */
64
+ async function sendPhoto(token, params, fetcher) {
65
+ const photoUrl = params.photo.trim();
66
+ let parsedPhotoUrl;
67
+ try {
68
+ parsedPhotoUrl = new URL(photoUrl);
69
+ } catch {
70
+ throw new Error("Zalo photo URL must be an absolute HTTP or HTTPS URL");
71
+ }
72
+ if (parsedPhotoUrl.protocol !== "http:" && parsedPhotoUrl.protocol !== "https:") throw new Error("Zalo photo URL must use HTTP or HTTPS");
73
+ await resolvePinnedHostnameWithPolicy(parsedPhotoUrl.hostname, { policy: ZALO_MEDIA_SSRF_POLICY });
74
+ return callZaloApi("sendPhoto", token, {
75
+ ...params,
76
+ photo: parsedPhotoUrl.href
77
+ }, { fetch: fetcher });
78
+ }
79
+ /**
80
+ * Send a temporary chat action such as typing.
81
+ */
82
+ async function sendChatAction(token, params, fetcher, timeoutMs) {
83
+ return callZaloApi("sendChatAction", token, params, {
84
+ timeoutMs,
85
+ fetch: fetcher
86
+ });
87
+ }
88
+ /**
89
+ * Get updates using long polling (dev/testing only)
90
+ * Note: Zalo returns a single update per call, not an array like Telegram
91
+ */
92
+ async function getUpdates(token, params, fetcher) {
93
+ const pollTimeoutSec = params?.timeout ?? 30;
94
+ const timeoutMs = (pollTimeoutSec + 5) * 1e3;
95
+ return callZaloApi("getUpdates", token, { timeout: String(pollTimeoutSec) }, {
96
+ timeoutMs,
97
+ fetch: fetcher
98
+ });
99
+ }
100
+ /**
101
+ * Set webhook URL for receiving updates
102
+ */
103
+ async function setWebhook(token, params, fetcher) {
104
+ return callZaloApi("setWebhook", token, params, { fetch: fetcher });
105
+ }
106
+ /**
107
+ * Delete webhook configuration
108
+ */
109
+ async function deleteWebhook(token, fetcher, timeoutMs) {
110
+ return callZaloApi("deleteWebhook", token, void 0, {
111
+ timeoutMs,
112
+ fetch: fetcher
113
+ });
114
+ }
115
+ /**
116
+ * Get current webhook info
117
+ */
118
+ async function getWebhookInfo(token, fetcher) {
119
+ return callZaloApi("getWebhookInfo", token, void 0, { fetch: fetcher });
120
+ }
121
+ //#endregion
122
+ //#region extensions/zalo/src/proxy.ts
123
+ const proxyCache = /* @__PURE__ */ new Map();
124
+ function resolveZaloProxyFetch(proxyUrl) {
125
+ const trimmed = proxyUrl?.trim();
126
+ if (!trimmed) return;
127
+ const cached = proxyCache.get(trimmed);
128
+ if (cached) return cached;
129
+ const fetcher = makeProxyFetch(trimmed);
130
+ proxyCache.set(trimmed, fetcher);
131
+ return fetcher;
132
+ }
133
+ //#endregion
134
+ //#region extensions/zalo/src/send.ts
135
+ function createZaloSendReceipt(params) {
136
+ const messageId = params.messageId?.trim();
137
+ return createMessageReceiptFromOutboundResults({
138
+ results: messageId ? [{
139
+ channel: "zalo",
140
+ messageId,
141
+ chatId: params.chatId
142
+ }] : [],
143
+ kind: params.kind
144
+ });
145
+ }
146
+ function toZaloSendResult(response, params) {
147
+ if (response.ok && response.result) return {
148
+ ok: true,
149
+ messageId: response.result.message_id,
150
+ receipt: createZaloSendReceipt({
151
+ messageId: response.result.message_id,
152
+ chatId: params.chatId,
153
+ kind: params.kind
154
+ })
155
+ };
156
+ return {
157
+ ok: false,
158
+ error: "Failed to send message",
159
+ receipt: createZaloSendReceipt({
160
+ chatId: params.chatId,
161
+ kind: params.kind
162
+ })
163
+ };
164
+ }
165
+ async function runZaloSend(failureMessage, params, send) {
166
+ try {
167
+ const result = toZaloSendResult(await send(), params);
168
+ return result.ok ? result : {
169
+ ok: false,
170
+ error: failureMessage,
171
+ receipt: result.receipt
172
+ };
173
+ } catch (err) {
174
+ return {
175
+ ok: false,
176
+ error: formatErrorMessage(err),
177
+ receipt: createZaloSendReceipt({
178
+ chatId: params.chatId,
179
+ kind: params.kind
180
+ })
181
+ };
182
+ }
183
+ }
184
+ function resolveSendContext(options) {
185
+ if (options.cfg) {
186
+ const account = resolveZaloAccount({
187
+ cfg: options.cfg,
188
+ accountId: options.accountId
189
+ });
190
+ return {
191
+ token: options.token || account.token,
192
+ fetcher: resolveZaloProxyFetch(options.proxy ?? account.config.proxy)
193
+ };
194
+ }
195
+ const token = options.token ?? resolveZaloToken(void 0, options.accountId).token;
196
+ const proxy = options.proxy;
197
+ return {
198
+ token,
199
+ fetcher: resolveZaloProxyFetch(proxy)
200
+ };
201
+ }
202
+ function resolveValidatedSendContext(chatId, options) {
203
+ const { token, fetcher } = resolveSendContext(options);
204
+ if (!token) return {
205
+ ok: false,
206
+ error: "No Zalo bot token configured"
207
+ };
208
+ const trimmedChatId = chatId?.trim();
209
+ if (!trimmedChatId) return {
210
+ ok: false,
211
+ error: "No chat_id provided"
212
+ };
213
+ return {
214
+ ok: true,
215
+ chatId: trimmedChatId,
216
+ token,
217
+ fetcher
218
+ };
219
+ }
220
+ function resolveSendContextOrFailure(chatId, options) {
221
+ const context = resolveValidatedSendContext(chatId, options);
222
+ return context.ok ? { context } : { failure: {
223
+ ok: false,
224
+ error: context.error,
225
+ receipt: createZaloSendReceipt({
226
+ chatId,
227
+ kind: "unknown"
228
+ })
229
+ } };
230
+ }
231
+ async function sendMessageZalo(chatId, text, options = {}) {
232
+ const resolved = resolveSendContextOrFailure(chatId, options);
233
+ if ("failure" in resolved) return resolved.failure;
234
+ const { context } = resolved;
235
+ if (options.mediaUrl) return sendPhotoZalo(context.chatId, options.mediaUrl, {
236
+ ...options,
237
+ token: context.token,
238
+ caption: text || options.caption
239
+ });
240
+ return await runZaloSend("Failed to send message", {
241
+ chatId: context.chatId,
242
+ kind: "text"
243
+ }, () => sendMessage(context.token, {
244
+ chat_id: context.chatId,
245
+ text: text.slice(0, 2e3)
246
+ }, context.fetcher));
247
+ }
248
+ async function sendPhotoZalo(chatId, photoUrl, options = {}) {
249
+ const resolved = resolveSendContextOrFailure(chatId, options);
250
+ if ("failure" in resolved) return resolved.failure;
251
+ const { context } = resolved;
252
+ if (!photoUrl?.trim()) return {
253
+ ok: false,
254
+ error: "No photo URL provided",
255
+ receipt: createZaloSendReceipt({
256
+ chatId: context.chatId,
257
+ kind: "media"
258
+ })
259
+ };
260
+ return await runZaloSend("Failed to send photo", {
261
+ chatId: context.chatId,
262
+ kind: "media"
263
+ }, () => (async () => sendPhoto(context.token, {
264
+ chat_id: context.chatId,
265
+ photo: photoUrl.trim(),
266
+ caption: options.caption?.slice(0, 2e3)
267
+ }, context.fetcher))());
268
+ }
269
+ //#endregion
270
+ export { getMe as a, sendChatAction as c, setWebhook as d, deleteWebhook as i, sendMessage as l, resolveZaloProxyFetch as n, getUpdates as o, ZaloApiError as r, getWebhookInfo as s, sendMessageZalo as t, sendPhoto as u };
package/dist/setup-api.js CHANGED
@@ -1,5 +1,5 @@
1
- import { n as zaloDmPolicy, r as zaloSetupAdapter, t as createZaloSetupWizardProxy } from "./setup-core-B-97bdBF.js";
2
- import { n as resolveZaloRuntimeGroupPolicy } from "./group-access-B_fAqJAN.js";
1
+ import { n as zaloDmPolicy, r as zaloSetupAdapter, t as createZaloSetupWizardProxy } from "./setup-core-c-VVz39c.js";
2
+ import { n as resolveZaloRuntimeGroupPolicy } from "./group-access-Boqk-JNd.js";
3
3
  import { loadBundledEntryExportSync } from "openclaw/plugin-sdk/channel-entry-contract";
4
4
  //#region extensions/zalo/setup-api.ts
5
5
  function createLazyObjectValue(load) {
@@ -0,0 +1,282 @@
1
+ import { createAccountListHelpers, resolveMergedAccountConfig } from "openclaw/plugin-sdk/account-helpers";
2
+ import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "openclaw/plugin-sdk/account-id";
3
+ import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
4
+ import { tryReadSecretFileSync } from "openclaw/plugin-sdk/core";
5
+ import { resolveAccountEntry } from "openclaw/plugin-sdk/routing";
6
+ import { buildSecretInputSchema, normalizeResolvedSecretInputString, normalizeSecretInputString } from "openclaw/plugin-sdk/secret-input";
7
+ import { DEFAULT_ACCOUNT_ID as DEFAULT_ACCOUNT_ID$1, addWildcardAllowFrom, createDelegatedSetupWizardProxy, createPatchedAccountSetupAdapter, createSetupInputPresenceValidator, formatDocsLink, mergeAllowFromEntries, normalizeAccountId as normalizeAccountId$1 } from "openclaw/plugin-sdk/setup";
8
+ //#region \0rolldown/runtime.js
9
+ var __defProp = Object.defineProperty;
10
+ var __exportAll = (all, no_symbols) => {
11
+ let target = {};
12
+ for (var name in all) __defProp(target, name, {
13
+ get: all[name],
14
+ enumerable: true
15
+ });
16
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
17
+ return target;
18
+ };
19
+ //#endregion
20
+ //#region extensions/zalo/src/token.ts
21
+ function readTokenFromFile(tokenFile) {
22
+ return tryReadSecretFileSync(tokenFile, "Zalo token file", { rejectSymlink: true }) ?? "";
23
+ }
24
+ function resolveZaloToken(config, accountId, options) {
25
+ const resolvedAccountId = normalizeAccountId(accountId ?? config?.defaultAccount);
26
+ const isDefaultAccount = resolvedAccountId === DEFAULT_ACCOUNT_ID;
27
+ const baseConfig = config;
28
+ const accountConfig = resolveAccountEntry(baseConfig?.accounts, normalizeAccountId(resolvedAccountId));
29
+ const accountHasBotToken = Boolean(accountConfig && Object.prototype.hasOwnProperty.call(accountConfig, "botToken"));
30
+ if (accountConfig && accountHasBotToken) {
31
+ const token = options?.allowUnresolvedSecretRef ? normalizeSecretInputString(accountConfig.botToken) : normalizeResolvedSecretInputString({
32
+ value: accountConfig.botToken,
33
+ path: `channels.zalo.accounts.${resolvedAccountId}.botToken`
34
+ });
35
+ if (token) return {
36
+ token,
37
+ source: "config"
38
+ };
39
+ const fileToken = readTokenFromFile(accountConfig.tokenFile);
40
+ if (fileToken) return {
41
+ token: fileToken,
42
+ source: "configFile"
43
+ };
44
+ }
45
+ if (!accountHasBotToken) {
46
+ const fileToken = readTokenFromFile(accountConfig?.tokenFile);
47
+ if (fileToken) return {
48
+ token: fileToken,
49
+ source: "configFile"
50
+ };
51
+ }
52
+ if (!accountHasBotToken) {
53
+ const token = options?.allowUnresolvedSecretRef ? normalizeSecretInputString(baseConfig?.botToken) : normalizeResolvedSecretInputString({
54
+ value: baseConfig?.botToken,
55
+ path: "channels.zalo.botToken"
56
+ });
57
+ if (token) return {
58
+ token,
59
+ source: "config"
60
+ };
61
+ const fileToken = readTokenFromFile(baseConfig?.tokenFile);
62
+ if (fileToken) return {
63
+ token: fileToken,
64
+ source: "configFile"
65
+ };
66
+ }
67
+ if (isDefaultAccount) {
68
+ const envToken = process.env.ZALO_BOT_TOKEN?.trim();
69
+ if (envToken) return {
70
+ token: envToken,
71
+ source: "env"
72
+ };
73
+ }
74
+ return {
75
+ token: "",
76
+ source: "none"
77
+ };
78
+ }
79
+ //#endregion
80
+ //#region extensions/zalo/src/accounts.ts
81
+ var accounts_exports = /* @__PURE__ */ __exportAll({
82
+ listEnabledZaloAccounts: () => listEnabledZaloAccounts,
83
+ listZaloAccountIds: () => listZaloAccountIds,
84
+ resolveDefaultZaloAccountId: () => resolveDefaultZaloAccountId,
85
+ resolveZaloAccount: () => resolveZaloAccount
86
+ });
87
+ const { listAccountIds: listZaloAccountIds, resolveDefaultAccountId: resolveDefaultZaloAccountId } = createAccountListHelpers("zalo");
88
+ function mergeZaloAccountConfig(cfg, accountId) {
89
+ return resolveMergedAccountConfig({
90
+ channelConfig: cfg.channels?.zalo,
91
+ accounts: (cfg.channels?.zalo)?.accounts,
92
+ accountId,
93
+ omitKeys: ["defaultAccount"]
94
+ });
95
+ }
96
+ function resolveZaloAccount(params) {
97
+ const accountId = normalizeAccountId(params.accountId ?? (params.cfg.channels?.zalo)?.defaultAccount);
98
+ const baseEnabled = (params.cfg.channels?.zalo)?.enabled !== false;
99
+ const merged = mergeZaloAccountConfig(params.cfg, accountId);
100
+ const accountEnabled = merged.enabled !== false;
101
+ const enabled = baseEnabled && accountEnabled;
102
+ const tokenResolution = resolveZaloToken(params.cfg.channels?.zalo, accountId, { allowUnresolvedSecretRef: params.allowUnresolvedSecretRef });
103
+ return {
104
+ accountId,
105
+ name: normalizeOptionalString(merged.name),
106
+ enabled,
107
+ token: tokenResolution.token,
108
+ tokenSource: tokenResolution.source,
109
+ config: merged
110
+ };
111
+ }
112
+ function listEnabledZaloAccounts(cfg) {
113
+ return listZaloAccountIds(cfg).map((accountId) => resolveZaloAccount({
114
+ cfg,
115
+ accountId
116
+ })).filter((account) => account.enabled);
117
+ }
118
+ //#endregion
119
+ //#region extensions/zalo/src/setup-allow-from.ts
120
+ async function noteZaloTokenHelp(prompter) {
121
+ await prompter.note([
122
+ "1) Open Zalo Bot Platform: https://bot.zaloplatforms.com",
123
+ "2) Create a bot and get the token",
124
+ "3) Token looks like 12345689:abc-xyz",
125
+ "Tip: you can also set ZALO_BOT_TOKEN in your env.",
126
+ `Docs: ${formatDocsLink("/channels/zalo", "zalo")}`
127
+ ].join("\n"), "Zalo bot token");
128
+ }
129
+ async function promptZaloAllowFrom(params) {
130
+ const { cfg, prompter } = params;
131
+ const accountId = params.accountId ?? resolveDefaultZaloAccountId(cfg);
132
+ const existingAllowFrom = resolveZaloAccount({
133
+ cfg,
134
+ accountId
135
+ }).config.allowFrom ?? [];
136
+ const unique = mergeAllowFromEntries(existingAllowFrom, [(await prompter.text({
137
+ message: "Zalo allowFrom (user id)",
138
+ placeholder: "123456789",
139
+ initialValue: existingAllowFrom[0] ? String(existingAllowFrom[0]) : void 0,
140
+ validate: (value) => {
141
+ const raw = (value ?? "").trim();
142
+ if (!raw) return "Required";
143
+ if (!/^\d+$/.test(raw)) return "Use a numeric Zalo user id";
144
+ }
145
+ })).trim()]);
146
+ if (accountId === DEFAULT_ACCOUNT_ID$1) return {
147
+ ...cfg,
148
+ channels: {
149
+ ...cfg.channels,
150
+ zalo: {
151
+ ...cfg.channels?.zalo,
152
+ enabled: true,
153
+ dmPolicy: "allowlist",
154
+ allowFrom: unique
155
+ }
156
+ }
157
+ };
158
+ const currentAccount = cfg.channels?.zalo?.accounts?.[accountId];
159
+ return {
160
+ ...cfg,
161
+ channels: {
162
+ ...cfg.channels,
163
+ zalo: {
164
+ ...cfg.channels?.zalo,
165
+ enabled: true,
166
+ accounts: {
167
+ ...cfg.channels?.zalo?.accounts,
168
+ [accountId]: {
169
+ ...currentAccount,
170
+ enabled: currentAccount?.enabled ?? true,
171
+ dmPolicy: "allowlist",
172
+ allowFrom: unique
173
+ }
174
+ }
175
+ }
176
+ }
177
+ };
178
+ }
179
+ //#endregion
180
+ //#region extensions/zalo/src/setup-core.ts
181
+ const channel = "zalo";
182
+ const zaloSetupAdapter = createPatchedAccountSetupAdapter({
183
+ channelKey: channel,
184
+ validateInput: createSetupInputPresenceValidator({
185
+ defaultAccountOnlyEnvError: "ZALO_BOT_TOKEN can only be used for the default account.",
186
+ whenNotUseEnv: [{
187
+ someOf: ["token", "tokenFile"],
188
+ message: "Zalo requires token or --token-file (or --use-env)."
189
+ }]
190
+ }),
191
+ buildPatch: (input) => input.useEnv ? {} : input.tokenFile ? { tokenFile: input.tokenFile } : input.token ? { botToken: input.token } : {}
192
+ });
193
+ const zaloDmPolicy = {
194
+ label: "Zalo",
195
+ channel,
196
+ policyKey: "channels.zalo.dmPolicy",
197
+ allowFromKey: "channels.zalo.allowFrom",
198
+ resolveConfigKeys: (cfg, accountId) => (accountId ?? resolveDefaultZaloAccountId(cfg)) !== DEFAULT_ACCOUNT_ID$1 ? {
199
+ policyKey: `channels.zalo.accounts.${accountId ?? resolveDefaultZaloAccountId(cfg)}.dmPolicy`,
200
+ allowFromKey: `channels.zalo.accounts.${accountId ?? resolveDefaultZaloAccountId(cfg)}.allowFrom`
201
+ } : {
202
+ policyKey: "channels.zalo.dmPolicy",
203
+ allowFromKey: "channels.zalo.allowFrom"
204
+ },
205
+ getCurrent: (cfg, accountId) => resolveZaloAccount({
206
+ cfg,
207
+ accountId: accountId ?? resolveDefaultZaloAccountId(cfg)
208
+ }).config.dmPolicy ?? "pairing",
209
+ setPolicy: (cfg, policy, accountId) => {
210
+ const resolvedAccountId = accountId && normalizeAccountId$1(accountId) ? normalizeAccountId$1(accountId) ?? DEFAULT_ACCOUNT_ID$1 : resolveDefaultZaloAccountId(cfg);
211
+ const resolved = resolveZaloAccount({
212
+ cfg,
213
+ accountId: resolvedAccountId
214
+ });
215
+ if (resolvedAccountId === DEFAULT_ACCOUNT_ID$1) return {
216
+ ...cfg,
217
+ channels: {
218
+ ...cfg.channels,
219
+ zalo: {
220
+ ...cfg.channels?.zalo,
221
+ enabled: true,
222
+ dmPolicy: policy,
223
+ ...policy === "open" ? { allowFrom: addWildcardAllowFrom(resolved.config.allowFrom) } : {}
224
+ }
225
+ }
226
+ };
227
+ const currentAccount = cfg.channels?.zalo?.accounts?.[resolvedAccountId];
228
+ return {
229
+ ...cfg,
230
+ channels: {
231
+ ...cfg.channels,
232
+ zalo: {
233
+ ...cfg.channels?.zalo,
234
+ enabled: true,
235
+ accounts: {
236
+ ...cfg.channels?.zalo?.accounts,
237
+ [resolvedAccountId]: {
238
+ ...currentAccount,
239
+ enabled: currentAccount?.enabled ?? true,
240
+ dmPolicy: policy,
241
+ ...policy === "open" ? { allowFrom: addWildcardAllowFrom(resolved.config.allowFrom) } : {}
242
+ }
243
+ }
244
+ }
245
+ }
246
+ };
247
+ },
248
+ promptAllowFrom: async ({ cfg, prompter, accountId }) => promptZaloAllowFrom({
249
+ cfg,
250
+ prompter,
251
+ accountId: accountId ?? resolveDefaultZaloAccountId(cfg)
252
+ })
253
+ };
254
+ function createZaloSetupWizardProxy(loadWizard) {
255
+ return createDelegatedSetupWizardProxy({
256
+ channel,
257
+ loadWizard,
258
+ status: {
259
+ configuredLabel: "configured",
260
+ unconfiguredLabel: "needs token",
261
+ configuredHint: "recommended · configured",
262
+ unconfiguredHint: "recommended · newcomer-friendly",
263
+ configuredScore: 1,
264
+ unconfiguredScore: 10
265
+ },
266
+ credentials: [],
267
+ delegateFinalize: true,
268
+ dmPolicy: zaloDmPolicy,
269
+ disable: (cfg) => ({
270
+ ...cfg,
271
+ channels: {
272
+ ...cfg.channels,
273
+ zalo: {
274
+ ...cfg.channels?.zalo,
275
+ enabled: false
276
+ }
277
+ }
278
+ })
279
+ });
280
+ }
281
+ //#endregion
282
+ export { promptZaloAllowFrom as a, listZaloAccountIds as c, resolveZaloToken as d, buildSecretInputSchema as f, noteZaloTokenHelp as i, resolveDefaultZaloAccountId as l, zaloDmPolicy as n, accounts_exports as o, normalizeSecretInputString as p, zaloSetupAdapter as r, listEnabledZaloAccounts as s, createZaloSetupWizardProxy as t, resolveZaloAccount as u };
@@ -1,5 +1,4 @@
1
- import { a as resolveZaloAccount } from "./accounts-OjbMFek2.js";
2
- import { a as promptZaloAllowFrom, i as noteZaloTokenHelp, n as zaloDmPolicy } from "./setup-core-B-97bdBF.js";
1
+ import { a as promptZaloAllowFrom, i as noteZaloTokenHelp, n as zaloDmPolicy, u as resolveZaloAccount } from "./setup-core-c-VVz39c.js";
3
2
  import { DEFAULT_ACCOUNT_ID, buildSingleChannelSecretPromptState, createStandardChannelSetupStatus, hasConfiguredSecretInput, promptSingleChannelSecretInput, runSingleChannelSecretStep } from "openclaw/plugin-sdk/setup";
4
3
  //#region extensions/zalo/src/setup-surface.ts
5
4
  const channel = "zalo";
package/dist/test-api.js CHANGED
@@ -1,2 +1,2 @@
1
- import { n as resolveZaloRuntimeGroupPolicy } from "./group-access-B_fAqJAN.js";
1
+ import { n as resolveZaloRuntimeGroupPolicy } from "./group-access-Boqk-JNd.js";
2
2
  export { resolveZaloRuntimeGroupPolicy };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openclaw/zalo",
3
- "version": "2026.5.14-beta.1",
3
+ "version": "2026.5.14-beta.2",
4
4
  "description": "OpenClaw Zalo channel plugin",
5
5
  "repository": {
6
6
  "type": "git",
@@ -12,7 +12,7 @@
12
12
  "openclaw": "workspace:*"
13
13
  },
14
14
  "peerDependencies": {
15
- "openclaw": ">=2026.5.14-beta.1"
15
+ "openclaw": ">=2026.5.14-beta.2"
16
16
  },
17
17
  "peerDependenciesMeta": {
18
18
  "openclaw": {
@@ -43,10 +43,10 @@
43
43
  "minHostVersion": ">=2026.4.10"
44
44
  },
45
45
  "compat": {
46
- "pluginApi": ">=2026.5.14-beta.1"
46
+ "pluginApi": ">=2026.5.14-beta.2"
47
47
  },
48
48
  "build": {
49
- "openclawVersion": "2026.5.14-beta.1"
49
+ "openclawVersion": "2026.5.14-beta.2"
50
50
  },
51
51
  "release": {
52
52
  "publishToClawHub": true,
@@ -1,118 +0,0 @@
1
- import { createAccountListHelpers, resolveMergedAccountConfig } from "openclaw/plugin-sdk/account-helpers";
2
- import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "openclaw/plugin-sdk/account-id";
3
- import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
4
- import { tryReadSecretFileSync } from "openclaw/plugin-sdk/core";
5
- import { resolveAccountEntry } from "openclaw/plugin-sdk/routing";
6
- import { buildSecretInputSchema, normalizeResolvedSecretInputString, normalizeSecretInputString } from "openclaw/plugin-sdk/secret-input";
7
- //#region \0rolldown/runtime.js
8
- var __defProp = Object.defineProperty;
9
- var __exportAll = (all, no_symbols) => {
10
- let target = {};
11
- for (var name in all) __defProp(target, name, {
12
- get: all[name],
13
- enumerable: true
14
- });
15
- if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
16
- return target;
17
- };
18
- //#endregion
19
- //#region extensions/zalo/src/token.ts
20
- function readTokenFromFile(tokenFile) {
21
- return tryReadSecretFileSync(tokenFile, "Zalo token file", { rejectSymlink: true }) ?? "";
22
- }
23
- function resolveZaloToken(config, accountId, options) {
24
- const resolvedAccountId = normalizeAccountId(accountId ?? config?.defaultAccount);
25
- const isDefaultAccount = resolvedAccountId === DEFAULT_ACCOUNT_ID;
26
- const baseConfig = config;
27
- const accountConfig = resolveAccountEntry(baseConfig?.accounts, normalizeAccountId(resolvedAccountId));
28
- const accountHasBotToken = Boolean(accountConfig && Object.prototype.hasOwnProperty.call(accountConfig, "botToken"));
29
- if (accountConfig && accountHasBotToken) {
30
- const token = options?.allowUnresolvedSecretRef ? normalizeSecretInputString(accountConfig.botToken) : normalizeResolvedSecretInputString({
31
- value: accountConfig.botToken,
32
- path: `channels.zalo.accounts.${resolvedAccountId}.botToken`
33
- });
34
- if (token) return {
35
- token,
36
- source: "config"
37
- };
38
- const fileToken = readTokenFromFile(accountConfig.tokenFile);
39
- if (fileToken) return {
40
- token: fileToken,
41
- source: "configFile"
42
- };
43
- }
44
- if (!accountHasBotToken) {
45
- const fileToken = readTokenFromFile(accountConfig?.tokenFile);
46
- if (fileToken) return {
47
- token: fileToken,
48
- source: "configFile"
49
- };
50
- }
51
- if (!accountHasBotToken) {
52
- const token = options?.allowUnresolvedSecretRef ? normalizeSecretInputString(baseConfig?.botToken) : normalizeResolvedSecretInputString({
53
- value: baseConfig?.botToken,
54
- path: "channels.zalo.botToken"
55
- });
56
- if (token) return {
57
- token,
58
- source: "config"
59
- };
60
- const fileToken = readTokenFromFile(baseConfig?.tokenFile);
61
- if (fileToken) return {
62
- token: fileToken,
63
- source: "configFile"
64
- };
65
- }
66
- if (isDefaultAccount) {
67
- const envToken = process.env.ZALO_BOT_TOKEN?.trim();
68
- if (envToken) return {
69
- token: envToken,
70
- source: "env"
71
- };
72
- }
73
- return {
74
- token: "",
75
- source: "none"
76
- };
77
- }
78
- //#endregion
79
- //#region extensions/zalo/src/accounts.ts
80
- var accounts_exports = /* @__PURE__ */ __exportAll({
81
- listEnabledZaloAccounts: () => listEnabledZaloAccounts,
82
- listZaloAccountIds: () => listZaloAccountIds,
83
- resolveDefaultZaloAccountId: () => resolveDefaultZaloAccountId,
84
- resolveZaloAccount: () => resolveZaloAccount
85
- });
86
- const { listAccountIds: listZaloAccountIds, resolveDefaultAccountId: resolveDefaultZaloAccountId } = createAccountListHelpers("zalo");
87
- function mergeZaloAccountConfig(cfg, accountId) {
88
- return resolveMergedAccountConfig({
89
- channelConfig: cfg.channels?.zalo,
90
- accounts: (cfg.channels?.zalo)?.accounts,
91
- accountId,
92
- omitKeys: ["defaultAccount"]
93
- });
94
- }
95
- function resolveZaloAccount(params) {
96
- const accountId = normalizeAccountId(params.accountId ?? (params.cfg.channels?.zalo)?.defaultAccount);
97
- const baseEnabled = (params.cfg.channels?.zalo)?.enabled !== false;
98
- const merged = mergeZaloAccountConfig(params.cfg, accountId);
99
- const accountEnabled = merged.enabled !== false;
100
- const enabled = baseEnabled && accountEnabled;
101
- const tokenResolution = resolveZaloToken(params.cfg.channels?.zalo, accountId, { allowUnresolvedSecretRef: params.allowUnresolvedSecretRef });
102
- return {
103
- accountId,
104
- name: normalizeOptionalString(merged.name),
105
- enabled,
106
- token: tokenResolution.token,
107
- tokenSource: tokenResolution.source,
108
- config: merged
109
- };
110
- }
111
- function listEnabledZaloAccounts(cfg) {
112
- return listZaloAccountIds(cfg).map((accountId) => resolveZaloAccount({
113
- cfg,
114
- accountId
115
- })).filter((account) => account.enabled);
116
- }
117
- //#endregion
118
- export { resolveZaloAccount as a, normalizeSecretInputString as c, resolveDefaultZaloAccountId as i, listEnabledZaloAccounts as n, resolveZaloToken as o, listZaloAccountIds as r, buildSecretInputSchema as s, accounts_exports as t };
@@ -1,131 +0,0 @@
1
- import { resolvePinnedHostnameWithPolicy } from "openclaw/plugin-sdk/ssrf-runtime";
2
- import { makeProxyFetch } from "openclaw/plugin-sdk/fetch-runtime";
3
- //#region extensions/zalo/src/api.ts
4
- /**
5
- * Zalo Bot API client
6
- * @see https://bot.zaloplatforms.com/docs
7
- */
8
- const ZALO_API_BASE = "https://bot-api.zaloplatforms.com";
9
- const ZALO_MEDIA_SSRF_POLICY = {};
10
- var ZaloApiError = class extends Error {
11
- constructor(message, errorCode, description) {
12
- super(message);
13
- this.errorCode = errorCode;
14
- this.description = description;
15
- this.name = "ZaloApiError";
16
- }
17
- /** True if this is a long-polling timeout (no updates available) */
18
- get isPollingTimeout() {
19
- return this.errorCode === 408;
20
- }
21
- };
22
- /**
23
- * Call the Zalo Bot API
24
- */
25
- async function callZaloApi(method, token, body, options) {
26
- const url = `${ZALO_API_BASE}/bot${token}/${method}`;
27
- const controller = new AbortController();
28
- const timeoutId = options?.timeoutMs ? setTimeout(() => controller.abort(), options.timeoutMs) : void 0;
29
- const fetcher = options?.fetch ?? fetch;
30
- try {
31
- const data = await (await fetcher(url, {
32
- method: "POST",
33
- headers: { "Content-Type": "application/json" },
34
- body: body ? JSON.stringify(body) : void 0,
35
- signal: controller.signal
36
- })).json();
37
- if (!data.ok) throw new ZaloApiError(data.description ?? `Zalo API error: ${method}`, data.error_code, data.description);
38
- return data;
39
- } finally {
40
- if (timeoutId) clearTimeout(timeoutId);
41
- }
42
- }
43
- /**
44
- * Validate bot token and get bot info
45
- */
46
- async function getMe(token, timeoutMs, fetcher) {
47
- return callZaloApi("getMe", token, void 0, {
48
- timeoutMs,
49
- fetch: fetcher
50
- });
51
- }
52
- /**
53
- * Send a text message
54
- */
55
- async function sendMessage(token, params, fetcher) {
56
- return callZaloApi("sendMessage", token, params, { fetch: fetcher });
57
- }
58
- /**
59
- * Send a photo message
60
- */
61
- async function sendPhoto(token, params, fetcher) {
62
- const photoUrl = params.photo.trim();
63
- let parsedPhotoUrl;
64
- try {
65
- parsedPhotoUrl = new URL(photoUrl);
66
- } catch {
67
- throw new Error("Zalo photo URL must be an absolute HTTP or HTTPS URL");
68
- }
69
- if (parsedPhotoUrl.protocol !== "http:" && parsedPhotoUrl.protocol !== "https:") throw new Error("Zalo photo URL must use HTTP or HTTPS");
70
- await resolvePinnedHostnameWithPolicy(parsedPhotoUrl.hostname, { policy: ZALO_MEDIA_SSRF_POLICY });
71
- return callZaloApi("sendPhoto", token, {
72
- ...params,
73
- photo: parsedPhotoUrl.href
74
- }, { fetch: fetcher });
75
- }
76
- /**
77
- * Send a temporary chat action such as typing.
78
- */
79
- async function sendChatAction(token, params, fetcher, timeoutMs) {
80
- return callZaloApi("sendChatAction", token, params, {
81
- timeoutMs,
82
- fetch: fetcher
83
- });
84
- }
85
- /**
86
- * Get updates using long polling (dev/testing only)
87
- * Note: Zalo returns a single update per call, not an array like Telegram
88
- */
89
- async function getUpdates(token, params, fetcher) {
90
- const pollTimeoutSec = params?.timeout ?? 30;
91
- const timeoutMs = (pollTimeoutSec + 5) * 1e3;
92
- return callZaloApi("getUpdates", token, { timeout: String(pollTimeoutSec) }, {
93
- timeoutMs,
94
- fetch: fetcher
95
- });
96
- }
97
- /**
98
- * Set webhook URL for receiving updates
99
- */
100
- async function setWebhook(token, params, fetcher) {
101
- return callZaloApi("setWebhook", token, params, { fetch: fetcher });
102
- }
103
- /**
104
- * Delete webhook configuration
105
- */
106
- async function deleteWebhook(token, fetcher, timeoutMs) {
107
- return callZaloApi("deleteWebhook", token, void 0, {
108
- timeoutMs,
109
- fetch: fetcher
110
- });
111
- }
112
- /**
113
- * Get current webhook info
114
- */
115
- async function getWebhookInfo(token, fetcher) {
116
- return callZaloApi("getWebhookInfo", token, void 0, { fetch: fetcher });
117
- }
118
- //#endregion
119
- //#region extensions/zalo/src/proxy.ts
120
- const proxyCache = /* @__PURE__ */ new Map();
121
- function resolveZaloProxyFetch(proxyUrl) {
122
- const trimmed = proxyUrl?.trim();
123
- if (!trimmed) return;
124
- const cached = proxyCache.get(trimmed);
125
- if (cached) return cached;
126
- const fetcher = makeProxyFetch(trimmed);
127
- proxyCache.set(trimmed, fetcher);
128
- return fetcher;
129
- }
130
- //#endregion
131
- export { getUpdates as a, sendMessage as c, getMe as i, sendPhoto as l, ZaloApiError as n, getWebhookInfo as o, deleteWebhook as r, sendChatAction as s, resolveZaloProxyFetch as t, setWebhook as u };
@@ -1,8 +0,0 @@
1
- import { createPluginRuntimeStore } from "openclaw/plugin-sdk/runtime-store";
2
- //#region extensions/zalo/src/runtime.ts
3
- const { setRuntime: setZaloRuntime, getRuntime: getZaloRuntime } = createPluginRuntimeStore({
4
- pluginId: "zalo",
5
- errorMessage: "Zalo runtime not initialized"
6
- });
7
- //#endregion
8
- export { setZaloRuntime as n, getZaloRuntime as t };
@@ -1,141 +0,0 @@
1
- import { a as resolveZaloAccount, o as resolveZaloToken } from "./accounts-OjbMFek2.js";
2
- import { c as sendMessage, l as sendPhoto, t as resolveZaloProxyFetch } from "./proxy-D5AGEsI0.js";
3
- import { createMessageReceiptFromOutboundResults } from "openclaw/plugin-sdk/channel-message";
4
- import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
5
- //#region extensions/zalo/src/send.ts
6
- function createZaloSendReceipt(params) {
7
- const messageId = params.messageId?.trim();
8
- return createMessageReceiptFromOutboundResults({
9
- results: messageId ? [{
10
- channel: "zalo",
11
- messageId,
12
- chatId: params.chatId
13
- }] : [],
14
- kind: params.kind
15
- });
16
- }
17
- function toZaloSendResult(response, params) {
18
- if (response.ok && response.result) return {
19
- ok: true,
20
- messageId: response.result.message_id,
21
- receipt: createZaloSendReceipt({
22
- messageId: response.result.message_id,
23
- chatId: params.chatId,
24
- kind: params.kind
25
- })
26
- };
27
- return {
28
- ok: false,
29
- error: "Failed to send message",
30
- receipt: createZaloSendReceipt({
31
- chatId: params.chatId,
32
- kind: params.kind
33
- })
34
- };
35
- }
36
- async function runZaloSend(failureMessage, params, send) {
37
- try {
38
- const result = toZaloSendResult(await send(), params);
39
- return result.ok ? result : {
40
- ok: false,
41
- error: failureMessage,
42
- receipt: result.receipt
43
- };
44
- } catch (err) {
45
- return {
46
- ok: false,
47
- error: formatErrorMessage(err),
48
- receipt: createZaloSendReceipt({
49
- chatId: params.chatId,
50
- kind: params.kind
51
- })
52
- };
53
- }
54
- }
55
- function resolveSendContext(options) {
56
- if (options.cfg) {
57
- const account = resolveZaloAccount({
58
- cfg: options.cfg,
59
- accountId: options.accountId
60
- });
61
- return {
62
- token: options.token || account.token,
63
- fetcher: resolveZaloProxyFetch(options.proxy ?? account.config.proxy)
64
- };
65
- }
66
- const token = options.token ?? resolveZaloToken(void 0, options.accountId).token;
67
- const proxy = options.proxy;
68
- return {
69
- token,
70
- fetcher: resolveZaloProxyFetch(proxy)
71
- };
72
- }
73
- function resolveValidatedSendContext(chatId, options) {
74
- const { token, fetcher } = resolveSendContext(options);
75
- if (!token) return {
76
- ok: false,
77
- error: "No Zalo bot token configured"
78
- };
79
- const trimmedChatId = chatId?.trim();
80
- if (!trimmedChatId) return {
81
- ok: false,
82
- error: "No chat_id provided"
83
- };
84
- return {
85
- ok: true,
86
- chatId: trimmedChatId,
87
- token,
88
- fetcher
89
- };
90
- }
91
- function resolveSendContextOrFailure(chatId, options) {
92
- const context = resolveValidatedSendContext(chatId, options);
93
- return context.ok ? { context } : { failure: {
94
- ok: false,
95
- error: context.error,
96
- receipt: createZaloSendReceipt({
97
- chatId,
98
- kind: "unknown"
99
- })
100
- } };
101
- }
102
- async function sendMessageZalo(chatId, text, options = {}) {
103
- const resolved = resolveSendContextOrFailure(chatId, options);
104
- if ("failure" in resolved) return resolved.failure;
105
- const { context } = resolved;
106
- if (options.mediaUrl) return sendPhotoZalo(context.chatId, options.mediaUrl, {
107
- ...options,
108
- token: context.token,
109
- caption: text || options.caption
110
- });
111
- return await runZaloSend("Failed to send message", {
112
- chatId: context.chatId,
113
- kind: "text"
114
- }, () => sendMessage(context.token, {
115
- chat_id: context.chatId,
116
- text: text.slice(0, 2e3)
117
- }, context.fetcher));
118
- }
119
- async function sendPhotoZalo(chatId, photoUrl, options = {}) {
120
- const resolved = resolveSendContextOrFailure(chatId, options);
121
- if ("failure" in resolved) return resolved.failure;
122
- const { context } = resolved;
123
- if (!photoUrl?.trim()) return {
124
- ok: false,
125
- error: "No photo URL provided",
126
- receipt: createZaloSendReceipt({
127
- chatId: context.chatId,
128
- kind: "media"
129
- })
130
- };
131
- return await runZaloSend("Failed to send photo", {
132
- chatId: context.chatId,
133
- kind: "media"
134
- }, () => (async () => sendPhoto(context.token, {
135
- chat_id: context.chatId,
136
- photo: photoUrl.trim(),
137
- caption: options.caption?.slice(0, 2e3)
138
- }, context.fetcher))());
139
- }
140
- //#endregion
141
- export { sendMessageZalo as t };
@@ -1,166 +0,0 @@
1
- import { a as resolveZaloAccount, i as resolveDefaultZaloAccountId } from "./accounts-OjbMFek2.js";
2
- import { DEFAULT_ACCOUNT_ID, addWildcardAllowFrom, createDelegatedSetupWizardProxy, createPatchedAccountSetupAdapter, createSetupInputPresenceValidator, formatDocsLink, mergeAllowFromEntries, normalizeAccountId } from "openclaw/plugin-sdk/setup";
3
- //#region extensions/zalo/src/setup-allow-from.ts
4
- async function noteZaloTokenHelp(prompter) {
5
- await prompter.note([
6
- "1) Open Zalo Bot Platform: https://bot.zaloplatforms.com",
7
- "2) Create a bot and get the token",
8
- "3) Token looks like 12345689:abc-xyz",
9
- "Tip: you can also set ZALO_BOT_TOKEN in your env.",
10
- `Docs: ${formatDocsLink("/channels/zalo", "zalo")}`
11
- ].join("\n"), "Zalo bot token");
12
- }
13
- async function promptZaloAllowFrom(params) {
14
- const { cfg, prompter } = params;
15
- const accountId = params.accountId ?? resolveDefaultZaloAccountId(cfg);
16
- const existingAllowFrom = resolveZaloAccount({
17
- cfg,
18
- accountId
19
- }).config.allowFrom ?? [];
20
- const unique = mergeAllowFromEntries(existingAllowFrom, [(await prompter.text({
21
- message: "Zalo allowFrom (user id)",
22
- placeholder: "123456789",
23
- initialValue: existingAllowFrom[0] ? String(existingAllowFrom[0]) : void 0,
24
- validate: (value) => {
25
- const raw = (value ?? "").trim();
26
- if (!raw) return "Required";
27
- if (!/^\d+$/.test(raw)) return "Use a numeric Zalo user id";
28
- }
29
- })).trim()]);
30
- if (accountId === DEFAULT_ACCOUNT_ID) return {
31
- ...cfg,
32
- channels: {
33
- ...cfg.channels,
34
- zalo: {
35
- ...cfg.channels?.zalo,
36
- enabled: true,
37
- dmPolicy: "allowlist",
38
- allowFrom: unique
39
- }
40
- }
41
- };
42
- const currentAccount = cfg.channels?.zalo?.accounts?.[accountId];
43
- return {
44
- ...cfg,
45
- channels: {
46
- ...cfg.channels,
47
- zalo: {
48
- ...cfg.channels?.zalo,
49
- enabled: true,
50
- accounts: {
51
- ...cfg.channels?.zalo?.accounts,
52
- [accountId]: {
53
- ...currentAccount,
54
- enabled: currentAccount?.enabled ?? true,
55
- dmPolicy: "allowlist",
56
- allowFrom: unique
57
- }
58
- }
59
- }
60
- }
61
- };
62
- }
63
- //#endregion
64
- //#region extensions/zalo/src/setup-core.ts
65
- const channel = "zalo";
66
- const zaloSetupAdapter = createPatchedAccountSetupAdapter({
67
- channelKey: channel,
68
- validateInput: createSetupInputPresenceValidator({
69
- defaultAccountOnlyEnvError: "ZALO_BOT_TOKEN can only be used for the default account.",
70
- whenNotUseEnv: [{
71
- someOf: ["token", "tokenFile"],
72
- message: "Zalo requires token or --token-file (or --use-env)."
73
- }]
74
- }),
75
- buildPatch: (input) => input.useEnv ? {} : input.tokenFile ? { tokenFile: input.tokenFile } : input.token ? { botToken: input.token } : {}
76
- });
77
- const zaloDmPolicy = {
78
- label: "Zalo",
79
- channel,
80
- policyKey: "channels.zalo.dmPolicy",
81
- allowFromKey: "channels.zalo.allowFrom",
82
- resolveConfigKeys: (cfg, accountId) => (accountId ?? resolveDefaultZaloAccountId(cfg)) !== DEFAULT_ACCOUNT_ID ? {
83
- policyKey: `channels.zalo.accounts.${accountId ?? resolveDefaultZaloAccountId(cfg)}.dmPolicy`,
84
- allowFromKey: `channels.zalo.accounts.${accountId ?? resolveDefaultZaloAccountId(cfg)}.allowFrom`
85
- } : {
86
- policyKey: "channels.zalo.dmPolicy",
87
- allowFromKey: "channels.zalo.allowFrom"
88
- },
89
- getCurrent: (cfg, accountId) => resolveZaloAccount({
90
- cfg,
91
- accountId: accountId ?? resolveDefaultZaloAccountId(cfg)
92
- }).config.dmPolicy ?? "pairing",
93
- setPolicy: (cfg, policy, accountId) => {
94
- const resolvedAccountId = accountId && normalizeAccountId(accountId) ? normalizeAccountId(accountId) ?? DEFAULT_ACCOUNT_ID : resolveDefaultZaloAccountId(cfg);
95
- const resolved = resolveZaloAccount({
96
- cfg,
97
- accountId: resolvedAccountId
98
- });
99
- if (resolvedAccountId === DEFAULT_ACCOUNT_ID) return {
100
- ...cfg,
101
- channels: {
102
- ...cfg.channels,
103
- zalo: {
104
- ...cfg.channels?.zalo,
105
- enabled: true,
106
- dmPolicy: policy,
107
- ...policy === "open" ? { allowFrom: addWildcardAllowFrom(resolved.config.allowFrom) } : {}
108
- }
109
- }
110
- };
111
- const currentAccount = cfg.channels?.zalo?.accounts?.[resolvedAccountId];
112
- return {
113
- ...cfg,
114
- channels: {
115
- ...cfg.channels,
116
- zalo: {
117
- ...cfg.channels?.zalo,
118
- enabled: true,
119
- accounts: {
120
- ...cfg.channels?.zalo?.accounts,
121
- [resolvedAccountId]: {
122
- ...currentAccount,
123
- enabled: currentAccount?.enabled ?? true,
124
- dmPolicy: policy,
125
- ...policy === "open" ? { allowFrom: addWildcardAllowFrom(resolved.config.allowFrom) } : {}
126
- }
127
- }
128
- }
129
- }
130
- };
131
- },
132
- promptAllowFrom: async ({ cfg, prompter, accountId }) => promptZaloAllowFrom({
133
- cfg,
134
- prompter,
135
- accountId: accountId ?? resolveDefaultZaloAccountId(cfg)
136
- })
137
- };
138
- function createZaloSetupWizardProxy(loadWizard) {
139
- return createDelegatedSetupWizardProxy({
140
- channel,
141
- loadWizard,
142
- status: {
143
- configuredLabel: "configured",
144
- unconfiguredLabel: "needs token",
145
- configuredHint: "recommended · configured",
146
- unconfiguredHint: "recommended · newcomer-friendly",
147
- configuredScore: 1,
148
- unconfiguredScore: 10
149
- },
150
- credentials: [],
151
- delegateFinalize: true,
152
- dmPolicy: zaloDmPolicy,
153
- disable: (cfg) => ({
154
- ...cfg,
155
- channels: {
156
- ...cfg.channels,
157
- zalo: {
158
- ...cfg.channels?.zalo,
159
- enabled: false
160
- }
161
- }
162
- })
163
- });
164
- }
165
- //#endregion
166
- export { promptZaloAllowFrom as a, noteZaloTokenHelp as i, zaloDmPolicy as n, zaloSetupAdapter as r, createZaloSetupWizardProxy as t };