@openclaw/line 2026.11.12 → 2026.12.1-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.
- package/dist/.setup/api-BFKOcDBj.mjs +3 -0
- package/dist/.setup/{api-CMPtJvIX.mjs → api-BHi0Jdse.mjs} +1 -1
- package/dist/.setup/{card-command-utjlRvb-.mjs → card-command-3YJcF1Sg.mjs} +2 -2
- package/dist/.setup/{channel-p6vbK7z1.mjs → channel-D8h0qJMW.mjs} +381 -18
- package/dist/.setup/channel.runtime-BBSUSMgH.mjs +4 -0
- package/dist/.setup/{monitor-D_RfCX20.mjs → monitor-B4Vqphj5.mjs} +7 -8
- package/dist/.setup/outbound.runtime-C41lKCRl.mjs +3 -0
- package/dist/.setup/{send-retry-D6J7bThI.mjs → schedule-cards-D2zI0jRv.mjs} +3 -352
- package/dist/.setup/send-Btj5Sv6v.mjs +664 -0
- package/dist/.setup/template-messages-5ZlXYNrb.mjs +198 -0
- package/dist/.source-module-urls/2c97352967966b7ab9f67f528eb25c098b6fe10ea0e4616ffae3851ed839d81e.json +1 -1
- package/dist/api.js +2 -2
- package/dist/channel-plugin-api.js +1 -1
- package/dist/index.js +1 -1
- package/dist/setup-entry.js +1 -1
- package/package.json +4 -4
- package/dist/.setup/api-B7qoCDpM.mjs +0 -3
- package/dist/.setup/channel.runtime-DlTsOqaQ.mjs +0 -4
- package/dist/.setup/outbound.runtime-BGlJ18sK.mjs +0 -3
- package/dist/.setup/send-H86JOXWw.mjs +0 -335
- package/dist/.setup/template-messages-B8c6X5DV.mjs +0 -464
|
@@ -1,197 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { asSafeIntegerInRange, hasNonEmptyString, isRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
4
|
-
import { collectErrorGraphCandidates, extractErrorCode, formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
|
|
5
|
-
import { getFileExtension, mimeTypeFromFilePath } from "openclaw/plugin-sdk/media-mime";
|
|
6
|
-
import { resolvePinnedHostnameWithPolicy } from "openclaw/plugin-sdk/ssrf-runtime";
|
|
7
|
-
import { pruneMapToMaxSize } from "openclaw/plugin-sdk/collection-runtime";
|
|
8
|
-
import { logVerbose } from "openclaw/plugin-sdk/runtime-env";
|
|
9
|
-
import { runChannelProbe, truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
|
|
10
|
-
import { HTTPFetchError } from "@line/bot-sdk";
|
|
11
|
-
import { classifyTransientNetworkErrorCode, createChannelApiRetryRunner } from "openclaw/plugin-sdk/retry-runtime";
|
|
12
|
-
import { assertOkOrThrowHttpError, createProviderOperationDeadline, createProviderOperationTimeoutResolver, fetchWithTimeout, readProviderJsonResponse } from "openclaw/plugin-sdk/provider-http";
|
|
13
|
-
import { fetchWithRuntimeDispatcherOrMockedGlobal } from "openclaw/plugin-sdk/runtime-fetch";
|
|
14
|
-
// \0rolldown/runtime.js
|
|
15
|
-
var __defProp = Object.defineProperty;
|
|
16
|
-
var __exportAll = (all, no_symbols) => {
|
|
17
|
-
let target = {};
|
|
18
|
-
for (var name in all) __defProp(target, name, {
|
|
19
|
-
get: all[name],
|
|
20
|
-
enumerable: true
|
|
21
|
-
});
|
|
22
|
-
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
23
|
-
return target;
|
|
24
|
-
};
|
|
25
|
-
// extensions/line/src/messaging-target.ts
|
|
26
|
-
function normalizeLineMessagingTarget(target) {
|
|
27
|
-
const trimmed = target.trim();
|
|
28
|
-
if (!trimmed) return;
|
|
29
|
-
return trimmed.replace(/^line:(group|room|user):/i, "").replace(/^line:/i, "");
|
|
30
|
-
}
|
|
31
|
-
function inferLineTargetChatType(target) {
|
|
32
|
-
const normalized = normalizeLineMessagingTarget(target);
|
|
33
|
-
if (!normalized) return;
|
|
34
|
-
if (/^U[a-f0-9]{32}$/i.test(normalized)) return "direct";
|
|
35
|
-
return /^[CR][a-f0-9]{32}$/i.test(normalized) ? "group" : void 0;
|
|
36
|
-
}
|
|
1
|
+
import { hasNonEmptyString, isRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
2
|
+
import { truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
|
|
37
3
|
// extensions/line/src/media-url.ts
|
|
38
4
|
function isHttpsUrl(value) {
|
|
39
5
|
return typeof value === "string" && URL.parse(value)?.protocol === "https:";
|
|
40
6
|
}
|
|
41
|
-
// extensions/line/src/outbound-media.ts
|
|
42
|
-
const LINE_OUTBOUND_MEDIA_SSRF_POLICY = { allowPrivateNetwork: false };
|
|
43
|
-
async function validateLineMediaUrl(url) {
|
|
44
|
-
const parsed = URL.parse(url);
|
|
45
|
-
if (!parsed) throw new Error("LINE outbound media URL must be a valid URL");
|
|
46
|
-
if (parsed.protocol !== "https:") throw new Error("LINE outbound media URL must use HTTPS");
|
|
47
|
-
if (url.length > 2e3) throw new Error(`LINE outbound media URL must be 2000 chars or less (got ${url.length})`);
|
|
48
|
-
await resolvePinnedHostnameWithPolicy(parsed.hostname, { policy: LINE_OUTBOUND_MEDIA_SSRF_POLICY });
|
|
49
|
-
}
|
|
50
|
-
const LINE_MEDIA_KIND_BY_MIME = {
|
|
51
|
-
"image/jpeg": "image",
|
|
52
|
-
"image/png": "image",
|
|
53
|
-
"video/mp4": "video",
|
|
54
|
-
"audio/mpeg": "audio",
|
|
55
|
-
"audio/x-m4a": "audio"
|
|
56
|
-
};
|
|
57
|
-
function detectLineMediaKindFromUrl(url) {
|
|
58
|
-
const mimeType = mimeTypeFromFilePath(url);
|
|
59
|
-
if (mimeType === void 0) return getFileExtension(url) === void 0 ? void 0 : "unsupported";
|
|
60
|
-
return LINE_MEDIA_KIND_BY_MIME[mimeType] ?? "unsupported";
|
|
61
|
-
}
|
|
62
|
-
function resolveLineMediaKind(url, opts) {
|
|
63
|
-
if (opts.mediaKind !== void 0) return {
|
|
64
|
-
mediaKind: opts.mediaKind,
|
|
65
|
-
kindSource: "declared"
|
|
66
|
-
};
|
|
67
|
-
if (opts.durationMs !== void 0) return {
|
|
68
|
-
mediaKind: "audio",
|
|
69
|
-
kindSource: "metadata"
|
|
70
|
-
};
|
|
71
|
-
if (opts.trackingId?.trim()) return {
|
|
72
|
-
mediaKind: "video",
|
|
73
|
-
kindSource: "metadata"
|
|
74
|
-
};
|
|
75
|
-
const detected = detectLineMediaKindFromUrl(url);
|
|
76
|
-
return detected === void 0 ? {
|
|
77
|
-
mediaKind: "image",
|
|
78
|
-
kindSource: "fallback"
|
|
79
|
-
} : {
|
|
80
|
-
mediaKind: detected,
|
|
81
|
-
kindSource: "url"
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
function isLineUserTarget(target) {
|
|
85
|
-
const normalized = target.trim().replace(/^line:(group|room|user):/i, "").replace(/^line:/i, "");
|
|
86
|
-
return /^U/i.test(normalized);
|
|
87
|
-
}
|
|
88
|
-
async function buildLineMediaMessage(mediaUrl, opts, target) {
|
|
89
|
-
const trimmedUrl = mediaUrl.trim();
|
|
90
|
-
if (!isHttpsUrl(trimmedUrl)) throw new Error(URL.canParse(trimmedUrl) ? "LINE outbound media URL must use HTTPS" : "LINE outbound media currently requires a public HTTPS URL");
|
|
91
|
-
await validateLineMediaUrl(trimmedUrl);
|
|
92
|
-
const previewImageUrl = opts.previewImageUrl?.trim();
|
|
93
|
-
if (previewImageUrl) await validateLineMediaUrl(previewImageUrl);
|
|
94
|
-
const { mediaKind, kindSource } = resolveLineMediaKind(trimmedUrl, opts);
|
|
95
|
-
switch (mediaKind) {
|
|
96
|
-
case "unsupported": return {
|
|
97
|
-
type: "text",
|
|
98
|
-
text: trimmedUrl
|
|
99
|
-
};
|
|
100
|
-
case "video":
|
|
101
|
-
if (previewImageUrl) return {
|
|
102
|
-
type: "video",
|
|
103
|
-
originalContentUrl: trimmedUrl,
|
|
104
|
-
previewImageUrl,
|
|
105
|
-
...isLineUserTarget(target) && opts.trackingId ? { trackingId: opts.trackingId } : {}
|
|
106
|
-
};
|
|
107
|
-
if (kindSource !== "url") throw new Error("LINE video messages require previewImageUrl to reference an image URL");
|
|
108
|
-
return {
|
|
109
|
-
type: "text",
|
|
110
|
-
text: trimmedUrl
|
|
111
|
-
};
|
|
112
|
-
case "audio": return {
|
|
113
|
-
type: "audio",
|
|
114
|
-
originalContentUrl: trimmedUrl,
|
|
115
|
-
duration: opts.durationMs ?? 6e4
|
|
116
|
-
};
|
|
117
|
-
default: return {
|
|
118
|
-
type: "image",
|
|
119
|
-
originalContentUrl: trimmedUrl,
|
|
120
|
-
previewImageUrl: previewImageUrl || trimmedUrl
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
// extensions/line/src/quote-tokens.ts
|
|
125
|
-
const QUOTE_TOKEN_LIMIT = 500;
|
|
126
|
-
const quoteTokensByAccount = /* @__PURE__ */ new Map();
|
|
127
|
-
function quoteTokenKey(chatId, messageId) {
|
|
128
|
-
const chat = normalizeLineMessagingTarget(chatId);
|
|
129
|
-
const message = messageId.trim();
|
|
130
|
-
return chat && message ? `${chat}|${message}` : void 0;
|
|
131
|
-
}
|
|
132
|
-
/** Reads the quote token LINE attaches to the message kinds a person can quote. */
|
|
133
|
-
function readLineQuoteToken(message) {
|
|
134
|
-
return message.type === "text" || message.type === "image" || message.type === "video" || message.type === "sticker" ? message.quoteToken : void 0;
|
|
135
|
-
}
|
|
136
|
-
function recordLineQuoteToken(params) {
|
|
137
|
-
const quoteToken = params.quoteToken;
|
|
138
|
-
if (!quoteToken) return;
|
|
139
|
-
const key = quoteTokenKey(params.chatId, params.messageId);
|
|
140
|
-
if (!key) return;
|
|
141
|
-
const tokens = quoteTokensByAccount.get(params.accountId) ?? /* @__PURE__ */ new Map();
|
|
142
|
-
quoteTokensByAccount.set(params.accountId, tokens);
|
|
143
|
-
tokens.delete(key);
|
|
144
|
-
tokens.set(key, quoteToken);
|
|
145
|
-
pruneMapToMaxSize(tokens, QUOTE_TOKEN_LIMIT);
|
|
146
|
-
}
|
|
147
|
-
function resolveLineQuoteToken(params) {
|
|
148
|
-
const key = params.messageId ? quoteTokenKey(params.chatId, params.messageId) : void 0;
|
|
149
|
-
if (!key) return;
|
|
150
|
-
const accountId = normalizeAccountId(params.accountId ?? resolveDefaultLineAccountId(params.cfg));
|
|
151
|
-
const quoteToken = quoteTokensByAccount.get(accountId)?.get(key);
|
|
152
|
-
if (!quoteToken) logVerbose(`line: account ${accountId} remembers no quote token for ${key}; sending the reply unquoted`);
|
|
153
|
-
return quoteToken;
|
|
154
|
-
}
|
|
155
|
-
const QUOTABLE_OUTBOUND_TYPES = /* @__PURE__ */ new Set([
|
|
156
|
-
"text",
|
|
157
|
-
"textV2",
|
|
158
|
-
"sticker"
|
|
159
|
-
]);
|
|
160
|
-
/** True when LINE lets this message carry the quote for its request. */
|
|
161
|
-
function canCarryLineQuoteToken(message) {
|
|
162
|
-
return QUOTABLE_OUTBOUND_TYPES.has(message.type);
|
|
163
|
-
}
|
|
164
|
-
/**
|
|
165
|
-
* Reports a reply that answered a message but had nothing able to carry the quote.
|
|
166
|
-
*
|
|
167
|
-
* Both delivery paths reach this state, and without a line here the silence reads
|
|
168
|
-
* as "the quote went out" to anyone who saw the resolve step succeed.
|
|
169
|
-
*/
|
|
170
|
-
function reportLineQuoteCarrierMissing(chatId) {
|
|
171
|
-
logVerbose(`line: nothing in this reply to ${chatId} can carry a quote; sending it unquoted`);
|
|
172
|
-
}
|
|
173
|
-
/** Attaches a quote token to the first message in a request that can carry one. */
|
|
174
|
-
function applyLineQuoteToken(messages, quoteToken) {
|
|
175
|
-
const target = quoteToken ? messages.findIndex(canCarryLineQuoteToken) : -1;
|
|
176
|
-
return target < 0 ? messages : messages.map((message, index) => index === target ? {
|
|
177
|
-
...message,
|
|
178
|
-
quoteToken
|
|
179
|
-
} : message);
|
|
180
|
-
}
|
|
181
|
-
/**
|
|
182
|
-
* Drops every quote token from a request, or undefined when it carried none.
|
|
183
|
-
*
|
|
184
|
-
* LINE can refuse a whole request for an invalid quote token without naming a
|
|
185
|
-
* field in its error. Offering the same reply without the quote lets delivery
|
|
186
|
-
* recover from that rejection.
|
|
187
|
-
*/
|
|
188
|
-
function withoutLineQuoteTokens(messages) {
|
|
189
|
-
if (!messages.some((message) => "quoteToken" in message)) return;
|
|
190
|
-
return messages.map((message) => "quoteToken" in message ? {
|
|
191
|
-
...message,
|
|
192
|
-
quoteToken: void 0
|
|
193
|
-
} : message);
|
|
194
|
-
}
|
|
195
7
|
// extensions/line/src/flex-templates/message.ts
|
|
196
8
|
const LINE_FLEX_BUBBLE_MAX_BYTES = 3e4;
|
|
197
9
|
const LINE_FLEX_CAROUSEL_MAX_BYTES = 5e4;
|
|
@@ -926,165 +738,4 @@ function createAgendaCard(params) {
|
|
|
926
738
|
});
|
|
927
739
|
return createCardBubble([...buildCardHeaderSections(headerContents), cardBox("vertical", eventItems, { paddingTop: "xl" })], footer);
|
|
928
740
|
}
|
|
929
|
-
|
|
930
|
-
function resolveLineChannelAccessToken(explicit, params) {
|
|
931
|
-
if (explicit?.trim()) return explicit.trim();
|
|
932
|
-
if (!params.channelAccessToken) throw new Error(params.tokenStatus === "configured_unavailable" ? `LINE channel access token is configured but unavailable for account "${params.accountId}" (check the configured tokenFile).` : `LINE channel access token missing for account "${params.accountId}" (set channels.line.channelAccessToken or LINE_CHANNEL_ACCESS_TOKEN).`);
|
|
933
|
-
return params.channelAccessToken.trim();
|
|
934
|
-
}
|
|
935
|
-
// extensions/line/src/probe.ts
|
|
936
|
-
var probe_exports = /* @__PURE__ */ __exportAll({
|
|
937
|
-
probeLineBot: () => probeLineBot,
|
|
938
|
-
readLineAccountMessageQuota: () => readLineAccountMessageQuota
|
|
939
|
-
});
|
|
940
|
-
const LINE_QUOTA_TIMEOUT_MS = 2e3;
|
|
941
|
-
const LINE_JSON_MAX_BYTES = 16384;
|
|
942
|
-
function createLineApiReader(channelAccessToken, timeoutMs) {
|
|
943
|
-
const remaining = createProviderOperationTimeoutResolver({
|
|
944
|
-
deadline: createProviderOperationDeadline({
|
|
945
|
-
timeoutMs,
|
|
946
|
-
label: "LINE API"
|
|
947
|
-
}),
|
|
948
|
-
defaultTimeoutMs: timeoutMs
|
|
949
|
-
});
|
|
950
|
-
const headers = { Authorization: `Bearer ${channelAccessToken}` };
|
|
951
|
-
return async (endpoint) => {
|
|
952
|
-
const response = await fetchWithTimeout(`https://api.line.me/v2/bot/${endpoint}`, { headers }, remaining(), fetchWithRuntimeDispatcherOrMockedGlobal);
|
|
953
|
-
await assertOkOrThrowHttpError(response, "LINE API", {
|
|
954
|
-
bodyTimeoutMs: remaining,
|
|
955
|
-
requestHeaders: headers
|
|
956
|
-
});
|
|
957
|
-
return await readProviderJsonResponse(response, "LINE API", {
|
|
958
|
-
maxBytes: LINE_JSON_MAX_BYTES,
|
|
959
|
-
timeoutMs: remaining,
|
|
960
|
-
requestHeaders: headers
|
|
961
|
-
});
|
|
962
|
-
};
|
|
963
|
-
}
|
|
964
|
-
async function readLineMessageQuota(channelAccessToken, budgetMs) {
|
|
965
|
-
if (!Number.isFinite(budgetMs) || budgetMs <= 0) return;
|
|
966
|
-
try {
|
|
967
|
-
const read = createLineApiReader(channelAccessToken, budgetMs);
|
|
968
|
-
const quota = await read("message/quota");
|
|
969
|
-
if (quota.type === "none") return { kind: "unlimited" };
|
|
970
|
-
const limit = asSafeIntegerInRange(quota.value, { min: 0 });
|
|
971
|
-
if (quota.type !== "limited" || limit === void 0) return;
|
|
972
|
-
const { totalUsage } = await read("message/quota/consumption");
|
|
973
|
-
const used = asSafeIntegerInRange(totalUsage, { min: 0 });
|
|
974
|
-
return used === void 0 ? void 0 : {
|
|
975
|
-
kind: "limited",
|
|
976
|
-
limit,
|
|
977
|
-
used
|
|
978
|
-
};
|
|
979
|
-
} catch {
|
|
980
|
-
return;
|
|
981
|
-
}
|
|
982
|
-
}
|
|
983
|
-
async function readLineWebhookState(channelAccessToken, budgetMs) {
|
|
984
|
-
if (!Number.isFinite(budgetMs) || budgetMs <= 0) return;
|
|
985
|
-
try {
|
|
986
|
-
const registered = await createLineApiReader(channelAccessToken, budgetMs)("channel/webhook/endpoint");
|
|
987
|
-
return typeof registered.active === "boolean" ? { status: registered.active ? "active" : "disabled" } : void 0;
|
|
988
|
-
} catch (error) {
|
|
989
|
-
return isRecord(error) && error.status === 404 ? { status: "unset" } : void 0;
|
|
990
|
-
}
|
|
991
|
-
}
|
|
992
|
-
async function readLineAccountMessageQuota(params) {
|
|
993
|
-
try {
|
|
994
|
-
return await readLineMessageQuota(resolveLineChannelAccessToken(void 0, resolveLineAccount({
|
|
995
|
-
cfg: params.cfg,
|
|
996
|
-
accountId: params.accountId ?? void 0
|
|
997
|
-
})), LINE_QUOTA_TIMEOUT_MS);
|
|
998
|
-
} catch {
|
|
999
|
-
return;
|
|
1000
|
-
}
|
|
1001
|
-
}
|
|
1002
|
-
async function probeLineBot(channelAccessToken, timeoutMs = 5e3) {
|
|
1003
|
-
if (!channelAccessToken?.trim()) return {
|
|
1004
|
-
ok: false,
|
|
1005
|
-
error: "Channel access token not configured"
|
|
1006
|
-
};
|
|
1007
|
-
const token = channelAccessToken.trim();
|
|
1008
|
-
return await runChannelProbe(timeoutMs, async ({ elapsedMs }) => {
|
|
1009
|
-
const profile = await createLineApiReader(token, timeoutMs)("info");
|
|
1010
|
-
const optionalBudgetMs = () => Math.floor(Math.max(timeoutMs - elapsedMs(), 0) / 2);
|
|
1011
|
-
const quota = await readLineMessageQuota(token, optionalBudgetMs());
|
|
1012
|
-
const webhook = await readLineWebhookState(token, optionalBudgetMs());
|
|
1013
|
-
return {
|
|
1014
|
-
ok: true,
|
|
1015
|
-
bot: {
|
|
1016
|
-
displayName: profile.displayName,
|
|
1017
|
-
userId: profile.userId,
|
|
1018
|
-
basicId: profile.basicId,
|
|
1019
|
-
pictureUrl: profile.pictureUrl
|
|
1020
|
-
},
|
|
1021
|
-
...webhook ? { webhook } : {},
|
|
1022
|
-
...quota ? { quota } : {}
|
|
1023
|
-
};
|
|
1024
|
-
}, (error) => ({
|
|
1025
|
-
ok: false,
|
|
1026
|
-
error: formatErrorMessage(error)
|
|
1027
|
-
}));
|
|
1028
|
-
}
|
|
1029
|
-
// extensions/line/src/send-retry.ts
|
|
1030
|
-
/** The LINE HTTP response carried by an error graph, when the request reached LINE. */
|
|
1031
|
-
function findLineHttpError(error) {
|
|
1032
|
-
return collectErrorGraphCandidates(error, (candidate) => [candidate.cause, candidate.error]).find((candidate) => candidate instanceof HTTPFetchError);
|
|
1033
|
-
}
|
|
1034
|
-
/**
|
|
1035
|
-
* LINE answered this attempt with a client error, so it rejected the request and
|
|
1036
|
-
* sent nothing.
|
|
1037
|
-
*
|
|
1038
|
-
* A 429 proves this attempt was refused but remains retryable by durable
|
|
1039
|
-
* delivery. A 408 stays ambiguous because the request may have reached LINE.
|
|
1040
|
-
*/
|
|
1041
|
-
function resolveAttemptNonDispatchRetryable(error) {
|
|
1042
|
-
const status = findLineHttpError(error)?.status;
|
|
1043
|
-
if (status === 429) return true;
|
|
1044
|
-
if (status === 409) return;
|
|
1045
|
-
return status !== void 0 && status >= 400 && status < 500 && status !== 408 ? false : void 0;
|
|
1046
|
-
}
|
|
1047
|
-
const pushErrorsWithAmbiguousAttempt = /* @__PURE__ */ new WeakSet();
|
|
1048
|
-
/** Retryability when LINE refused every attempt, or undefined when delivery is ambiguous. */
|
|
1049
|
-
function resolveLineNonDispatchRetryable(error) {
|
|
1050
|
-
if (collectErrorGraphCandidates(error, (candidate) => [candidate.cause, candidate.error]).some((candidate) => typeof candidate === "object" && candidate !== null && pushErrorsWithAmbiguousAttempt.has(candidate))) return;
|
|
1051
|
-
return resolveAttemptNonDispatchRetryable(error);
|
|
1052
|
-
}
|
|
1053
|
-
function isRetryableLinePushError(error) {
|
|
1054
|
-
const httpError = findLineHttpError(error);
|
|
1055
|
-
if (httpError) return httpError.status >= 500;
|
|
1056
|
-
return collectErrorGraphCandidates(error, (candidate) => [candidate.cause, candidate.error]).some((candidate) => classifyTransientNetworkErrorCode(extractErrorCode(candidate)) !== void 0);
|
|
1057
|
-
}
|
|
1058
|
-
/**
|
|
1059
|
-
* Pushes are non-idempotent without a retry key, so the generic message-matching
|
|
1060
|
-
* fallback stays off and only the classification above may replay a request.
|
|
1061
|
-
*/
|
|
1062
|
-
const runLinePushAttempts = createChannelApiRetryRunner({
|
|
1063
|
-
shouldRetry: isRetryableLinePushError,
|
|
1064
|
-
strictShouldRetry: true,
|
|
1065
|
-
verbose: true
|
|
1066
|
-
});
|
|
1067
|
-
const runLinePushWithRetries = (fn, label) => {
|
|
1068
|
-
let sawAmbiguousAttempt = false;
|
|
1069
|
-
return runLinePushAttempts(async () => {
|
|
1070
|
-
try {
|
|
1071
|
-
return await fn();
|
|
1072
|
-
} catch (error) {
|
|
1073
|
-
sawAmbiguousAttempt ||= resolveAttemptNonDispatchRetryable(error) === void 0;
|
|
1074
|
-
throw error;
|
|
1075
|
-
}
|
|
1076
|
-
}, label).catch((error) => {
|
|
1077
|
-
if (sawAmbiguousAttempt && typeof error === "object" && error !== null) pushErrorsWithAmbiguousAttempt.add(error);
|
|
1078
|
-
throw error;
|
|
1079
|
-
});
|
|
1080
|
-
};
|
|
1081
|
-
async function explainLineRefusal(params) {
|
|
1082
|
-
const retryable = resolveLineNonDispatchRetryable(params.error);
|
|
1083
|
-
const quota = retryable === true && findLineHttpError(params.error)?.status === 429 ? await readLineAccountMessageQuota(params) : void 0;
|
|
1084
|
-
const exhausted = quota?.kind === "limited" && quota.used >= quota.limit;
|
|
1085
|
-
return {
|
|
1086
|
-
retryable: exhausted ? false : retryable,
|
|
1087
|
-
reason: exhausted ? `LINE refused the push: ${quota.used}/${quota.limit} monthly messages used. Check the account allowance or plan before retrying.` : params.error instanceof Error ? params.error.message : "LINE rejected the message"
|
|
1088
|
-
};
|
|
1089
|
-
}
|
|
1090
|
-
export { reportLineQuoteCarrierMissing as A, uriAction as C, canCarryLineQuoteToken as D, applyLineQuoteToken as E, normalizeLineMessagingTarget as F, withoutLineQuoteTokens as M, buildLineMediaMessage as N, readLineQuoteToken as O, inferLineTargetChatType as P, truncateLineActionLabel as S, toFlexMessage as T, createCardBubble as _, probeLineBot as a, normalizeLineMessage as b, createAgendaCard as c, createActionCard as d, createImageCard as f, cardText as g, cardBox as h, runLinePushWithRetries as i, resolveLineQuoteToken as j, recordLineQuoteToken as k, createEventCard as l, createListCard as m, findLineHttpError as n, probe_exports as o, createInfoCard as p, resolveLineNonDispatchRetryable as r, resolveLineChannelAccessToken as s, explainLineRefusal as t, createReceiptCard as u, createCardTitle as v, fitsLineFlexBubble as w, postbackAction as x, messageAction as y };
|
|
741
|
+
export { fitsLineFlexBubble as _, createImageCard as a, cardBox as c, createCardTitle as d, messageAction as f, uriAction as g, truncateLineActionLabel as h, createActionCard as i, cardText as l, postbackAction as m, createEventCard as n, createInfoCard as o, normalizeLineMessage as p, createReceiptCard as r, createListCard as s, createAgendaCard as t, createCardBubble as u, toFlexMessage as v, isHttpsUrl as y };
|