@openclaw/zalo 2026.5.12 → 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-CoWHeuWX.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-Cvycoekh.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-CoWHeuWX.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-DaJVBJGD.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) {
@@ -377,11 +377,10 @@ async function handleImageMessage(params) {
377
377
  let mediaType;
378
378
  if (photo_url) try {
379
379
  const maxBytes = mediaMaxMb * 1024 * 1024;
380
- const fetched = await core.channel.media.fetchRemoteMedia({
380
+ const saved = await core.channel.media.saveRemoteMedia({
381
381
  url: photo_url,
382
382
  maxBytes
383
383
  });
384
- const saved = await core.channel.media.saveMediaBuffer(fetched.buffer, fetched.contentType, "inbound", maxBytes);
385
384
  mediaPath = saved.path;
386
385
  mediaType = saved.contentType;
387
386
  } catch (err) {
@@ -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) {