@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.
@@ -0,0 +1,3 @@
1
+ import { t as linePlugin } from "./channel-D8h0qJMW.mjs";
2
+ import { t as lineSetupPlugin } from "./api-BHi0Jdse.mjs";
3
+ export { linePlugin, lineSetupPlugin };
@@ -1,5 +1,5 @@
1
+ import { w as lineChannelPluginCommon } from "./channel-D8h0qJMW.mjs";
1
2
  import { r as lineSetupContract, t as lineSetupWizard } from "./setup-surface-DvbBjHFi.mjs";
2
- import { l as lineChannelPluginCommon } from "./channel-p6vbK7z1.mjs";
3
3
  // extensions/line/src/channel.setup.ts
4
4
  const lineSetupPlugin = {
5
5
  id: "line",
@@ -1,5 +1,5 @@
1
- import { d as createActionCard, f as createImageCard, m as createListCard, p as createInfoCard, u as createReceiptCard } from "./send-retry-D6J7bThI.mjs";
2
- import { t as createFlexMessage } from "./send-H86JOXWw.mjs";
1
+ import { a as createImageCard, i as createActionCard, o as createInfoCard, r as createReceiptCard, s as createListCard } from "./schedule-cards-D2zI0jRv.mjs";
2
+ import { n as createFlexMessage } from "./template-messages-5ZlXYNrb.mjs";
3
3
  import { normalizeLowercaseStringOrEmpty } from "openclaw/plugin-sdk/string-coerce-runtime";
4
4
  import { expectDefined } from "openclaw/plugin-sdk/expect-runtime";
5
5
  // extensions/line/src/card-command.ts
@@ -1,7 +1,7 @@
1
- import { A as reportLineQuoteCarrierMissing, D as canCarryLineQuoteToken, F as normalizeLineMessagingTarget, N as buildLineMediaMessage, P as inferLineTargetChatType, S as truncateLineActionLabel, _ as createCardBubble, c as createAgendaCard, d as createActionCard, g as cardText, h as cardBox, j as resolveLineQuoteToken, l as createEventCard, t as explainLineRefusal, v as createCardTitle, w as fitsLineFlexBubble, x as postbackAction, y as messageAction } from "./send-retry-D6J7bThI.mjs";
2
1
  import { n as resolveDefaultLineAccountId, r as resolveLineAccount, t as listLineAccountIds } from "./accounts-Dm_NoU7R.mjs";
3
2
  import { a as normalizeLineAllowEntry, i as hasLineCredentials, r as lineSetupContract, t as lineSetupWizard } from "./setup-surface-DvbBjHFi.mjs";
4
3
  import { t as getLineRuntime } from "./runtime-C9ldw-V4.mjs";
4
+ import { _ as fitsLineFlexBubble, c as cardBox, d as createCardTitle, f as messageAction, h as truncateLineActionLabel, i as createActionCard, l as cardText, m as postbackAction, n as createEventCard, t as createAgendaCard, u as createCardBubble, y as isHttpsUrl } from "./schedule-cards-D2zI0jRv.mjs";
5
5
  import { buildDmGroupAccountAllowlistAdapter, createFlatAllowlistOverrideResolver } from "openclaw/plugin-sdk/allowlist-config-edit";
6
6
  import { buildChannelOutboundSessionRoute, createChatChannelPlugin } from "openclaw/plugin-sdk/channel-core";
7
7
  import { createPairingPrefixStripper } from "openclaw/plugin-sdk/channel-pairing";
@@ -9,9 +9,9 @@ import { buildChannelGroupsScopeTree, createRestrictSendersChannelSecurity, reso
9
9
  import { createChannelDirectoryAdapter, createResolvedDirectoryEntriesLister } from "openclaw/plugin-sdk/directory-runtime";
10
10
  import { createLazyRuntimeModule } from "openclaw/plugin-sdk/lazy-runtime";
11
11
  import { describeWebhookAccountSnapshot } from "openclaw/plugin-sdk/account-helpers";
12
- import { DEFAULT_ACCOUNT_ID } from "openclaw/plugin-sdk/account-id";
12
+ import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "openclaw/plugin-sdk/account-id";
13
13
  import { clearAccountFieldsFromConfigSection, createScopedChannelConfigAdapter } from "openclaw/plugin-sdk/channel-config-helpers";
14
- import { isRecord, normalizeLowercaseStringOrEmpty, normalizeOptionalString, normalizeStringEntries, readStringValue } from "openclaw/plugin-sdk/string-coerce-runtime";
14
+ import { asSafeIntegerInRange, isRecord, normalizeLowercaseStringOrEmpty, normalizeOptionalString, normalizeStringEntries, readStringValue } from "openclaw/plugin-sdk/string-coerce-runtime";
15
15
  import { ChannelDeliveryStreamingConfigSchema, DmPolicySchema, GroupPolicySchema, buildChannelConfigSchema, buildGroupEntrySchema, buildMultiAccountChannelSchema, requireOpenAllowFrom } from "openclaw/plugin-sdk/channel-config-schema";
16
16
  import { requireChannelOpenAllowFrom } from "openclaw/plugin-sdk/extension-shared";
17
17
  import { z } from "zod";
@@ -21,11 +21,31 @@ import { createAccountStatusSink, createChannelMessageAdapterFromOutbound } from
21
21
  import { buildTokenChannelStatusSummary, collectIssuesForEnabledAccounts, createComputedAccountStatusAdapter, createDefaultChannelRuntimeState, createDependentCredentialStatusIssueCollector } from "openclaw/plugin-sdk/status-helpers";
22
22
  import { createAcceptedChannelDeliveryResult, createChannelPartialDeliveryError, isChannelPartialDeliveryError } from "openclaw/plugin-sdk/channel-inbound";
23
23
  import { createAttachedChannelResultAdapter, createEmptyChannelResult } from "openclaw/plugin-sdk/channel-send-result";
24
- import { PlatformMessageNotDispatchedError } from "openclaw/plugin-sdk/error-runtime";
24
+ import { PlatformMessageNotDispatchedError, collectErrorGraphCandidates, extractErrorCode, formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
25
25
  import { resolveAskUserQuestionOptionIndex, resolveAskUserQuestionOptionIndices, resolveOutboundMediaUrls } from "openclaw/plugin-sdk/reply-payload";
26
26
  import { sanitizeAssistantVisibleText } from "openclaw/plugin-sdk/text-chunking";
27
+ import { getFileExtension, mimeTypeFromFilePath } from "openclaw/plugin-sdk/media-mime";
28
+ import { resolvePinnedHostnameWithPolicy } from "openclaw/plugin-sdk/ssrf-runtime";
29
+ import { pruneMapToMaxSize } from "openclaw/plugin-sdk/collection-runtime";
30
+ import { logVerbose } from "openclaw/plugin-sdk/runtime-env";
27
31
  import { normalizeMessagePresentation, renderMessagePresentationFallbackText, renderPresentationForDelivery, resolveMessagePresentationButtonAction, resolveMessagePresentationOptionAction } from "openclaw/plugin-sdk/interactive-runtime";
32
+ import { runChannelProbe } from "openclaw/plugin-sdk/text-utility-runtime";
28
33
  import { Type } from "typebox";
34
+ import { HTTPFetchError } from "@line/bot-sdk";
35
+ import { classifyTransientNetworkErrorCode, createChannelApiRetryRunner } from "openclaw/plugin-sdk/retry-runtime";
36
+ import { assertOkOrThrowHttpError, createProviderOperationDeadline, createProviderOperationTimeoutResolver, fetchWithTimeout, readProviderJsonResponse } from "openclaw/plugin-sdk/provider-http";
37
+ import { fetchWithRuntimeDispatcherOrMockedGlobal } from "openclaw/plugin-sdk/runtime-fetch";
38
+ // \0rolldown/runtime.js
39
+ var __defProp = Object.defineProperty;
40
+ var __exportAll = (all, no_symbols) => {
41
+ let target = {};
42
+ for (var name in all) __defProp(target, name, {
43
+ get: all[name],
44
+ enumerable: true
45
+ });
46
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
47
+ return target;
48
+ };
29
49
  // extensions/line/src/config-adapter.ts
30
50
  const lineConfigAdapter = createScopedChannelConfigAdapter({
31
51
  sectionKey: "line",
@@ -311,7 +331,7 @@ const lineStatusAdapter = createComputedAccountStatusAdapter({
311
331
  }
312
332
  })],
313
333
  buildChannelSummary: ({ snapshot }) => buildTokenChannelStatusSummary(snapshot),
314
- probeAccount: async ({ account, timeoutMs }) => await (await import("./send-retry-D6J7bThI.mjs").then((n) => n.o)).probeLineBot(account.channelAccessToken, timeoutMs),
334
+ probeAccount: async ({ account, timeoutMs }) => await (await Promise.resolve().then(() => probe_exports)).probeLineBot(account.channelAccessToken, timeoutMs),
315
335
  resolveAccountSnapshot: ({ account, probe }) => ({
316
336
  accountId: account.accountId,
317
337
  name: account.name,
@@ -342,7 +362,7 @@ const lineGatewayAdapter = {
342
362
  statusSink({ lifecycle: "starting" });
343
363
  let lineBotLabel = "";
344
364
  try {
345
- const probe = await (await import("./send-retry-D6J7bThI.mjs").then((n) => n.o)).probeLineBot(token, 2500);
365
+ const probe = await (await Promise.resolve().then(() => probe_exports)).probeLineBot(token, 2500);
346
366
  const displayName = probe.ok ? probe.bot?.displayName?.trim() : null;
347
367
  if (displayName) lineBotLabel = ` (${displayName})`;
348
368
  const delivery = describeLineWebhookDelivery({ webhook: probe.ok ? probe.webhook : void 0 });
@@ -351,7 +371,7 @@ const lineGatewayAdapter = {
351
371
  if (getLineRuntime().logging.shouldLogVerbose()) ctx.log?.debug?.(`[${account.accountId}] bot check failed: ${String(err)}`);
352
372
  }
353
373
  ctx.log?.info(`[${account.accountId}] starting LINE provider${lineBotLabel}`);
354
- const { monitorLineProvider } = await import("./monitor-D_RfCX20.mjs");
374
+ const { monitorLineProvider } = await import("./monitor-B4Vqphj5.mjs");
355
375
  return await monitorLineProvider({
356
376
  channelAccessToken: token,
357
377
  channelSecret: secret,
@@ -393,12 +413,178 @@ const lineGatewayAdapter = {
393
413
  };
394
414
  }
395
415
  };
416
+ // extensions/line/src/messaging-target.ts
417
+ function normalizeLineMessagingTarget(target) {
418
+ const trimmed = target.trim();
419
+ if (!trimmed) return;
420
+ return trimmed.replace(/^line:(group|room|user):/i, "").replace(/^line:/i, "");
421
+ }
422
+ function inferLineTargetChatType(target) {
423
+ const normalized = normalizeLineMessagingTarget(target);
424
+ if (!normalized) return;
425
+ if (/^U[a-f0-9]{32}$/i.test(normalized)) return "direct";
426
+ return /^[CR][a-f0-9]{32}$/i.test(normalized) ? "group" : void 0;
427
+ }
428
+ // extensions/line/src/outbound-media.ts
429
+ const LINE_OUTBOUND_MEDIA_SSRF_POLICY = { allowPrivateNetwork: false };
430
+ async function validateLineMediaUrl(url) {
431
+ const parsed = URL.parse(url);
432
+ if (!parsed) throw new Error("LINE outbound media URL must be a valid URL");
433
+ if (parsed.protocol !== "https:") throw new Error("LINE outbound media URL must use HTTPS");
434
+ if (url.length > 2e3) throw new Error(`LINE outbound media URL must be 2000 chars or less (got ${url.length})`);
435
+ await resolvePinnedHostnameWithPolicy(parsed.hostname, { policy: LINE_OUTBOUND_MEDIA_SSRF_POLICY });
436
+ }
437
+ const LINE_MEDIA_KIND_BY_MIME = {
438
+ "image/jpeg": "image",
439
+ "image/png": "image",
440
+ "video/mp4": "video",
441
+ "audio/mpeg": "audio",
442
+ "audio/x-m4a": "audio"
443
+ };
444
+ function detectLineMediaKindFromUrl(url) {
445
+ const mimeType = mimeTypeFromFilePath(url);
446
+ if (mimeType === void 0) return getFileExtension(url) === void 0 ? void 0 : "unsupported";
447
+ return LINE_MEDIA_KIND_BY_MIME[mimeType] ?? "unsupported";
448
+ }
449
+ function resolveLineMediaKind(url, opts) {
450
+ if (opts.mediaKind !== void 0) return {
451
+ mediaKind: opts.mediaKind,
452
+ kindSource: "declared"
453
+ };
454
+ if (opts.durationMs !== void 0) return {
455
+ mediaKind: "audio",
456
+ kindSource: "metadata"
457
+ };
458
+ if (opts.trackingId?.trim()) return {
459
+ mediaKind: "video",
460
+ kindSource: "metadata"
461
+ };
462
+ const detected = detectLineMediaKindFromUrl(url);
463
+ return detected === void 0 ? {
464
+ mediaKind: "image",
465
+ kindSource: "fallback"
466
+ } : {
467
+ mediaKind: detected,
468
+ kindSource: "url"
469
+ };
470
+ }
471
+ function isLineUserTarget(target) {
472
+ const normalized = target.trim().replace(/^line:(group|room|user):/i, "").replace(/^line:/i, "");
473
+ return /^U/i.test(normalized);
474
+ }
475
+ async function buildLineMediaMessage(mediaUrl, opts, target) {
476
+ const trimmedUrl = mediaUrl.trim();
477
+ 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");
478
+ await validateLineMediaUrl(trimmedUrl);
479
+ const previewImageUrl = opts.previewImageUrl?.trim();
480
+ if (previewImageUrl) await validateLineMediaUrl(previewImageUrl);
481
+ const { mediaKind, kindSource } = resolveLineMediaKind(trimmedUrl, opts);
482
+ switch (mediaKind) {
483
+ case "unsupported": return {
484
+ type: "text",
485
+ text: trimmedUrl
486
+ };
487
+ case "video":
488
+ if (previewImageUrl) return {
489
+ type: "video",
490
+ originalContentUrl: trimmedUrl,
491
+ previewImageUrl,
492
+ ...isLineUserTarget(target) && opts.trackingId ? { trackingId: opts.trackingId } : {}
493
+ };
494
+ if (kindSource !== "url") throw new Error("LINE video messages require previewImageUrl to reference an image URL");
495
+ return {
496
+ type: "text",
497
+ text: trimmedUrl
498
+ };
499
+ case "audio": return {
500
+ type: "audio",
501
+ originalContentUrl: trimmedUrl,
502
+ duration: opts.durationMs ?? 6e4
503
+ };
504
+ default: return {
505
+ type: "image",
506
+ originalContentUrl: trimmedUrl,
507
+ previewImageUrl: previewImageUrl || trimmedUrl
508
+ };
509
+ }
510
+ }
396
511
  // extensions/line/src/quick-reply-fallback.ts
397
512
  function buildLineQuickReplyFallbackText(labels) {
398
513
  const normalized = normalizeStringEntries(labels).slice(0, 13);
399
514
  if (normalized.length === 0) return "Choose an option.";
400
515
  return `Options:\n${normalized.map((label) => `- ${label}`).join("\n")}`;
401
516
  }
517
+ // extensions/line/src/quote-tokens.ts
518
+ const QUOTE_TOKEN_LIMIT = 500;
519
+ const quoteTokensByAccount = /* @__PURE__ */ new Map();
520
+ function quoteTokenKey(chatId, messageId) {
521
+ const chat = normalizeLineMessagingTarget(chatId);
522
+ const message = messageId.trim();
523
+ return chat && message ? `${chat}|${message}` : void 0;
524
+ }
525
+ /** Reads the quote token LINE attaches to the message kinds a person can quote. */
526
+ function readLineQuoteToken(message) {
527
+ return message.type === "text" || message.type === "image" || message.type === "video" || message.type === "sticker" ? message.quoteToken : void 0;
528
+ }
529
+ function recordLineQuoteToken(params) {
530
+ const quoteToken = params.quoteToken;
531
+ if (!quoteToken) return;
532
+ const key = quoteTokenKey(params.chatId, params.messageId);
533
+ if (!key) return;
534
+ const tokens = quoteTokensByAccount.get(params.accountId) ?? /* @__PURE__ */ new Map();
535
+ quoteTokensByAccount.set(params.accountId, tokens);
536
+ tokens.delete(key);
537
+ tokens.set(key, quoteToken);
538
+ pruneMapToMaxSize(tokens, QUOTE_TOKEN_LIMIT);
539
+ }
540
+ function resolveLineQuoteToken(params) {
541
+ const key = params.messageId ? quoteTokenKey(params.chatId, params.messageId) : void 0;
542
+ if (!key) return;
543
+ const accountId = normalizeAccountId(params.accountId ?? resolveDefaultLineAccountId(params.cfg));
544
+ const quoteToken = quoteTokensByAccount.get(accountId)?.get(key);
545
+ if (!quoteToken) logVerbose(`line: account ${accountId} remembers no quote token for ${key}; sending the reply unquoted`);
546
+ return quoteToken;
547
+ }
548
+ const QUOTABLE_OUTBOUND_TYPES = /* @__PURE__ */ new Set([
549
+ "text",
550
+ "textV2",
551
+ "sticker"
552
+ ]);
553
+ /** True when LINE lets this message carry the quote for its request. */
554
+ function canCarryLineQuoteToken(message) {
555
+ return QUOTABLE_OUTBOUND_TYPES.has(message.type);
556
+ }
557
+ /**
558
+ * Reports a reply that answered a message but had nothing able to carry the quote.
559
+ *
560
+ * Both delivery paths reach this state, and without a line here the silence reads
561
+ * as "the quote went out" to anyone who saw the resolve step succeed.
562
+ */
563
+ function reportLineQuoteCarrierMissing(chatId) {
564
+ logVerbose(`line: nothing in this reply to ${chatId} can carry a quote; sending it unquoted`);
565
+ }
566
+ /** Attaches a quote token to the first message in a request that can carry one. */
567
+ function applyLineQuoteToken(messages, quoteToken) {
568
+ const target = quoteToken ? messages.findIndex(canCarryLineQuoteToken) : -1;
569
+ return target < 0 ? messages : messages.map((message, index) => index === target ? {
570
+ ...message,
571
+ quoteToken
572
+ } : message);
573
+ }
574
+ /**
575
+ * Drops every quote token from a request, or undefined when it carried none.
576
+ *
577
+ * LINE can refuse a whole request for an invalid quote token without naming a
578
+ * field in its error. Offering the same reply without the quote lets delivery
579
+ * recover from that rejection.
580
+ */
581
+ function withoutLineQuoteTokens(messages) {
582
+ if (!messages.some((message) => "quoteToken" in message)) return;
583
+ return messages.map((message) => "quoteToken" in message ? {
584
+ ...message,
585
+ quoteToken: void 0
586
+ } : message);
587
+ }
402
588
  // extensions/line/src/question-postback.ts
403
589
  const QUESTION_ID_PARAM = "line.question";
404
590
  const OPTION_INDEX_PARAM = "line.option";
@@ -909,8 +1095,169 @@ function createLineQuickReply(items) {
909
1095
  action: item.action.type === "command" ? messageAction(item.label, item.action.command) : postbackAction(item.label, item.action.value, item.label)
910
1096
  })) };
911
1097
  }
1098
+ // extensions/line/src/channel-access-token.ts
1099
+ function resolveLineChannelAccessToken(explicit, params) {
1100
+ if (explicit?.trim()) return explicit.trim();
1101
+ 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).`);
1102
+ return params.channelAccessToken.trim();
1103
+ }
1104
+ // extensions/line/src/probe.ts
1105
+ var probe_exports = /* @__PURE__ */ __exportAll({
1106
+ probeLineBot: () => probeLineBot,
1107
+ readLineAccountMessageQuota: () => readLineAccountMessageQuota
1108
+ });
1109
+ const LINE_QUOTA_TIMEOUT_MS = 2e3;
1110
+ const LINE_JSON_MAX_BYTES = 16384;
1111
+ function createLineApiReader(channelAccessToken, timeoutMs) {
1112
+ const remaining = createProviderOperationTimeoutResolver({
1113
+ deadline: createProviderOperationDeadline({
1114
+ timeoutMs,
1115
+ label: "LINE API"
1116
+ }),
1117
+ defaultTimeoutMs: timeoutMs
1118
+ });
1119
+ const headers = { Authorization: `Bearer ${channelAccessToken}` };
1120
+ return async (endpoint) => {
1121
+ const response = await fetchWithTimeout(`https://api.line.me/v2/bot/${endpoint}`, { headers }, remaining(), fetchWithRuntimeDispatcherOrMockedGlobal);
1122
+ await assertOkOrThrowHttpError(response, "LINE API", {
1123
+ bodyTimeoutMs: remaining,
1124
+ requestHeaders: headers
1125
+ });
1126
+ return await readProviderJsonResponse(response, "LINE API", {
1127
+ maxBytes: LINE_JSON_MAX_BYTES,
1128
+ timeoutMs: remaining,
1129
+ requestHeaders: headers
1130
+ });
1131
+ };
1132
+ }
1133
+ async function readLineMessageQuota(channelAccessToken, budgetMs) {
1134
+ if (!Number.isFinite(budgetMs) || budgetMs <= 0) return;
1135
+ try {
1136
+ const read = createLineApiReader(channelAccessToken, budgetMs);
1137
+ const quota = await read("message/quota");
1138
+ if (quota.type === "none") return { kind: "unlimited" };
1139
+ const limit = asSafeIntegerInRange(quota.value, { min: 0 });
1140
+ if (quota.type !== "limited" || limit === void 0) return;
1141
+ const { totalUsage } = await read("message/quota/consumption");
1142
+ const used = asSafeIntegerInRange(totalUsage, { min: 0 });
1143
+ return used === void 0 ? void 0 : {
1144
+ kind: "limited",
1145
+ limit,
1146
+ used
1147
+ };
1148
+ } catch {
1149
+ return;
1150
+ }
1151
+ }
1152
+ async function readLineWebhookState(channelAccessToken, budgetMs) {
1153
+ if (!Number.isFinite(budgetMs) || budgetMs <= 0) return;
1154
+ try {
1155
+ const registered = await createLineApiReader(channelAccessToken, budgetMs)("channel/webhook/endpoint");
1156
+ return typeof registered.active === "boolean" ? { status: registered.active ? "active" : "disabled" } : void 0;
1157
+ } catch (error) {
1158
+ return isRecord(error) && error.status === 404 ? { status: "unset" } : void 0;
1159
+ }
1160
+ }
1161
+ async function readLineAccountMessageQuota(params) {
1162
+ try {
1163
+ return await readLineMessageQuota(resolveLineChannelAccessToken(void 0, resolveLineAccount({
1164
+ cfg: params.cfg,
1165
+ accountId: params.accountId ?? void 0
1166
+ })), LINE_QUOTA_TIMEOUT_MS);
1167
+ } catch {
1168
+ return;
1169
+ }
1170
+ }
1171
+ async function probeLineBot(channelAccessToken, timeoutMs = 5e3) {
1172
+ if (!channelAccessToken?.trim()) return {
1173
+ ok: false,
1174
+ error: "Channel access token not configured"
1175
+ };
1176
+ const token = channelAccessToken.trim();
1177
+ return await runChannelProbe(timeoutMs, async ({ elapsedMs }) => {
1178
+ const profile = await createLineApiReader(token, timeoutMs)("info");
1179
+ const optionalBudgetMs = () => Math.floor(Math.max(timeoutMs - elapsedMs(), 0) / 2);
1180
+ const quota = await readLineMessageQuota(token, optionalBudgetMs());
1181
+ const webhook = await readLineWebhookState(token, optionalBudgetMs());
1182
+ return {
1183
+ ok: true,
1184
+ bot: {
1185
+ displayName: profile.displayName,
1186
+ userId: profile.userId,
1187
+ basicId: profile.basicId,
1188
+ pictureUrl: profile.pictureUrl
1189
+ },
1190
+ ...webhook ? { webhook } : {},
1191
+ ...quota ? { quota } : {}
1192
+ };
1193
+ }, (error) => ({
1194
+ ok: false,
1195
+ error: formatErrorMessage(error)
1196
+ }));
1197
+ }
1198
+ // extensions/line/src/send-retry.ts
1199
+ /** The LINE HTTP response carried by an error graph, when the request reached LINE. */
1200
+ function findLineHttpError(error) {
1201
+ return collectErrorGraphCandidates(error, (candidate) => [candidate.cause, candidate.error]).find((candidate) => candidate instanceof HTTPFetchError);
1202
+ }
1203
+ /**
1204
+ * LINE answered this attempt with a client error, so it rejected the request and
1205
+ * sent nothing.
1206
+ *
1207
+ * A 429 proves this attempt was refused but remains retryable by durable
1208
+ * delivery. A 408 stays ambiguous because the request may have reached LINE.
1209
+ */
1210
+ function resolveAttemptNonDispatchRetryable(error) {
1211
+ const status = findLineHttpError(error)?.status;
1212
+ if (status === 429) return true;
1213
+ if (status === 409) return;
1214
+ return status !== void 0 && status >= 400 && status < 500 && status !== 408 ? false : void 0;
1215
+ }
1216
+ const pushErrorsWithAmbiguousAttempt = /* @__PURE__ */ new WeakSet();
1217
+ /** Retryability when LINE refused every attempt, or undefined when delivery is ambiguous. */
1218
+ function resolveLineNonDispatchRetryable(error) {
1219
+ if (collectErrorGraphCandidates(error, (candidate) => [candidate.cause, candidate.error]).some((candidate) => typeof candidate === "object" && candidate !== null && pushErrorsWithAmbiguousAttempt.has(candidate))) return;
1220
+ return resolveAttemptNonDispatchRetryable(error);
1221
+ }
1222
+ function isRetryableLinePushError(error) {
1223
+ const httpError = findLineHttpError(error);
1224
+ if (httpError) return httpError.status >= 500;
1225
+ return collectErrorGraphCandidates(error, (candidate) => [candidate.cause, candidate.error]).some((candidate) => classifyTransientNetworkErrorCode(extractErrorCode(candidate)) !== void 0);
1226
+ }
1227
+ /**
1228
+ * Pushes are non-idempotent without a retry key, so the generic message-matching
1229
+ * fallback stays off and only the classification above may replay a request.
1230
+ */
1231
+ const runLinePushAttempts = createChannelApiRetryRunner({
1232
+ shouldRetry: isRetryableLinePushError,
1233
+ strictShouldRetry: true,
1234
+ verbose: true
1235
+ });
1236
+ const runLinePushWithRetries = (fn, label) => {
1237
+ let sawAmbiguousAttempt = false;
1238
+ return runLinePushAttempts(async () => {
1239
+ try {
1240
+ return await fn();
1241
+ } catch (error) {
1242
+ sawAmbiguousAttempt ||= resolveAttemptNonDispatchRetryable(error) === void 0;
1243
+ throw error;
1244
+ }
1245
+ }, label).catch((error) => {
1246
+ if (sawAmbiguousAttempt && typeof error === "object" && error !== null) pushErrorsWithAmbiguousAttempt.add(error);
1247
+ throw error;
1248
+ });
1249
+ };
1250
+ async function explainLineRefusal(params) {
1251
+ const retryable = resolveLineNonDispatchRetryable(params.error);
1252
+ const quota = retryable === true && findLineHttpError(params.error)?.status === 429 ? await readLineAccountMessageQuota(params) : void 0;
1253
+ const exhausted = quota?.kind === "limited" && quota.used >= quota.limit;
1254
+ return {
1255
+ retryable: exhausted ? false : retryable,
1256
+ 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"
1257
+ };
1258
+ }
912
1259
  // extensions/line/src/outbound.ts
913
- const loadLineOutboundRuntime = createLazyRuntimeModule(() => import("./outbound.runtime-BGlJ18sK.mjs"));
1260
+ const loadLineOutboundRuntime = createLazyRuntimeModule(() => import("./outbound.runtime-C41lKCRl.mjs"));
914
1261
  function quotedOption(quoteToken) {
915
1262
  return quoteToken ? { quoteToken } : {};
916
1263
  }
@@ -1009,10 +1356,18 @@ const lineOutboundAdapter = {
1009
1356
  };
1010
1357
  const processed = payload.text ? outboundRuntime.processLineMessage(payload.text) : [];
1011
1358
  const chunkLimit = runtime.channel.text.resolveTextChunkLimit(cfg, "line", accountId ?? void 0, { fallbackLimit: 5e3 });
1012
- const orderedMessages = processed.flatMap((segment) => segment.type === "flex" ? [segment.message] : runtime.channel.text.chunkMarkdownText(segment.text, chunkLimit).map((text) => ({
1013
- type: "text",
1014
- text
1015
- })));
1359
+ const tablePushText = /* @__PURE__ */ new Map();
1360
+ const orderedMessages = processed.flatMap((segment) => {
1361
+ if (segment.type === "flex") return [segment.message];
1362
+ return outboundRuntime.chunkLineText(segment, chunkLimit, runtime.channel.text.chunkMarkdownText).map(({ text, pushText }) => {
1363
+ const message = {
1364
+ type: "text",
1365
+ text
1366
+ };
1367
+ if (pushText !== void 0) tablePushText.set(message, pushText);
1368
+ return message;
1369
+ });
1370
+ });
1016
1371
  const hasText = orderedMessages.some((message) => message.type === "text");
1017
1372
  const mediaUrls = resolveOutboundMediaUrls(payload);
1018
1373
  const mediaOptions = {
@@ -1066,10 +1421,18 @@ const lineOutboundAdapter = {
1066
1421
  }]);
1067
1422
  else await recordResult(sendFlex(to, message.altText, message.contents, sendOptions));
1068
1423
  } else if (isLast && hasQuickReplies) await sendTextWithQuickReply(message.text, quoteToken);
1069
- else await recordResult(sendText(to, message.text, {
1070
- ...sendOptions,
1071
- ...quotedOption(quoteToken)
1072
- }));
1424
+ else {
1425
+ const pushText = tablePushText.get(message);
1426
+ if (pushText !== void 0) await sendMessageBatch([{
1427
+ ...message,
1428
+ text: pushText,
1429
+ ...quotedOption(quoteToken)
1430
+ }]);
1431
+ else await recordResult(sendText(to, message.text, {
1432
+ ...sendOptions,
1433
+ ...quotedOption(quoteToken)
1434
+ }));
1435
+ }
1073
1436
  }
1074
1437
  } else {
1075
1438
  const quickReplyMessages = [];
@@ -1154,7 +1517,7 @@ const lineMessageAdapter = createChannelMessageAdapterFromOutbound({
1154
1517
  }
1155
1518
  });
1156
1519
  // extensions/line/src/channel.ts
1157
- const loadLineChannelRuntime = createLazyRuntimeModule(() => import("./channel.runtime-DlTsOqaQ.mjs"));
1520
+ const loadLineChannelRuntime = createLazyRuntimeModule(() => import("./channel.runtime-BBSUSMgH.mjs"));
1158
1521
  const lineSecurityAdapter = createRestrictSendersChannelSecurity({
1159
1522
  channelKey: "line",
1160
1523
  resolveDmPolicy: (account) => account.config.dmPolicy,
@@ -1351,4 +1714,4 @@ const linePlugin = createChatChannelPlugin({
1351
1714
  } },
1352
1715
  outbound: lineOutboundAdapter
1353
1716
  });
1354
- export { parseLineQuestionPostbackData as a, resolveLineGroupConfigEntry as c, isLineQuestionPostbackData as i, lineChannelPluginCommon as l, createLineQuickReply as n, resolveLineQuestionPostback as o, prepareLineReplyPayload as r, buildLineQuickReplyFallbackText as s, linePlugin as t };
1717
+ export { resolveLineGroupConfigEntry as C, normalizeLineMessagingTarget as S, reportLineQuoteCarrierMissing as _, runLinePushWithRetries as a, buildLineQuickReplyFallbackText as b, createLineQuickReply as c, parseLineQuestionPostbackData as d, resolveLineQuestionPostback as f, recordLineQuoteToken as g, readLineQuoteToken as h, resolveLineNonDispatchRetryable as i, prepareLineReplyPayload as l, canCarryLineQuoteToken as m, explainLineRefusal as n, probeLineBot as o, applyLineQuoteToken as p, findLineHttpError as r, resolveLineChannelAccessToken as s, linePlugin as t, isLineQuestionPostbackData as u, resolveLineQuoteToken as v, lineChannelPluginCommon as w, buildLineMediaMessage as x, withoutLineQuoteTokens as y };
@@ -0,0 +1,4 @@
1
+ import { o as probeLineBot } from "./channel-D8h0qJMW.mjs";
2
+ import { d as showLoadingAnimation, o as pushMessageLine } from "./send-Btj5Sv6v.mjs";
3
+ import { monitorLineProvider } from "./monitor-B4Vqphj5.mjs";
4
+ export { monitorLineProvider, probeLineBot, pushMessageLine, showLoadingAnimation };
@@ -1,11 +1,10 @@
1
- import { A as reportLineQuoteCarrierMissing, D as canCarryLineQuoteToken, E as applyLineQuoteToken, N as buildLineMediaMessage, O as readLineQuoteToken, j as resolveLineQuoteToken, k as recordLineQuoteToken, n as findLineHttpError, r as resolveLineNonDispatchRetryable, t as explainLineRefusal } from "./send-retry-D6J7bThI.mjs";
1
+ import { C as resolveLineGroupConfigEntry, _ as reportLineQuoteCarrierMissing, b as buildLineQuickReplyFallbackText, c as createLineQuickReply, d as parseLineQuestionPostbackData, f as resolveLineQuestionPostback, g as recordLineQuoteToken, h as readLineQuoteToken, i as resolveLineNonDispatchRetryable, l as prepareLineReplyPayload, m as canCarryLineQuoteToken, n as explainLineRefusal, p as applyLineQuoteToken, r as findLineHttpError, u as isLineQuestionPostbackData, v as resolveLineQuoteToken, x as buildLineMediaMessage } from "./channel-D8h0qJMW.mjs";
2
2
  import { n as resolveDefaultLineAccountId, r as resolveLineAccount } from "./accounts-Dm_NoU7R.mjs";
3
3
  import { a as normalizeLineAllowEntry } from "./setup-surface-DvbBjHFi.mjs";
4
- import { a as parseLineQuestionPostbackData, c as resolveLineGroupConfigEntry, i as isLineQuestionPostbackData, n as createLineQuickReply, o as resolveLineQuestionPostback, r as prepareLineReplyPayload, s as buildLineQuickReplyFallbackText } from "./channel-p6vbK7z1.mjs";
5
4
  import { t as getLineRuntime } from "./runtime-C9ldw-V4.mjs";
6
5
  import { a as laneKeyFor, i as eventIdFor, n as LINE_WEBHOOK_SPOOL_INVALID_PAYLOAD_MESSAGE, r as LineWebhookPayloadError, t as LINE_WEBHOOK_SPOOL_INVALID_EVENT_REASON } from "./webhook-spool-contract-COhQK5XQ.mjs";
7
- import { a as getUserDisplayName, h as quotesLineBotMessage, i as getLineGroupName, l as pushMessageLine, m as showLoadingAnimation, n as createLocationMessage, o as getUserProfile, p as replyMessageLine, t as createFlexMessage, u as pushMessagesLine } from "./send-H86JOXWw.mjs";
8
- import { n as processLineMessage, t as buildTemplateMessageFromPayload } from "./template-messages-B8c6X5DV.mjs";
6
+ import { n as createFlexMessage, r as createLocationMessage, t as buildTemplateMessageFromPayload } from "./template-messages-5ZlXYNrb.mjs";
7
+ import { d as showLoadingAnimation, f as quotesLineBotMessage, m as processLineMessage, n as getUserDisplayName, o as pushMessageLine, p as chunkLineText, r as getUserProfile, s as pushMessagesLine, t as getLineGroupName, u as replyMessageLine } from "./send-Btj5Sv6v.mjs";
9
8
  import { createChannelPairingChallengeIssuer } from "openclaw/plugin-sdk/channel-pairing";
10
9
  import { resolveChannelGroupsConfigPath } from "openclaw/plugin-sdk/channel-policy";
11
10
  import { normalizeOptionalString, normalizeStringEntries, readNonEmptyStringPreservingWhitespace } from "openclaw/plugin-sdk/string-coerce-runtime";
@@ -17,17 +16,18 @@ import { collectErrorGraphCandidates, extractErrorCode, formatErrorMessage, read
17
16
  import { resolveSendableOutboundReplyParts } from "openclaw/plugin-sdk/reply-payload";
18
17
  import { sanitizeAssistantVisibleText } from "openclaw/plugin-sdk/text-chunking";
19
18
  import { danger, logVerbose, waitForAbortSignal, warn } from "openclaw/plugin-sdk/runtime-env";
19
+ import { agentControlText } from "openclaw/plugin-sdk/interactive-runtime";
20
20
  import { safeParseJson } from "openclaw/plugin-sdk/text-utility-runtime";
21
21
  import { classifyTransientNetworkErrorCode } from "openclaw/plugin-sdk/retry-runtime";
22
22
  import { fetchWithRuntimeDispatcherOrMockedGlobal } from "openclaw/plugin-sdk/runtime-fetch";
23
23
  import { expectDefined } from "openclaw/plugin-sdk/expect-runtime";
24
- import crypto from "node:crypto";
25
- import { recordChannelActivity } from "openclaw/plugin-sdk/channel-activity-runtime";
26
24
  import { resolveHumanDelayConfig } from "openclaw/plugin-sdk/agent-runtime";
27
25
  import { channelReadyPatch, channelStoppedPatch } from "openclaw/plugin-sdk/gateway-runtime";
28
26
  import { canonicalizeWebhookRouteKey, registerWebhookTargetWithPluginRoute, resolveSingleWebhookTarget, resolveWebhookPath } from "openclaw/plugin-sdk/webhook-ingress";
29
27
  import { beginWebhookRequestPipelineOrReject, createWebhookInFlightLimiter, isRequestBodyLimitError, readRequestBodyWithLimit, requestBodyErrorToText, runDetachedWebhookWork, sendHttpRequestRejection } from "openclaw/plugin-sdk/webhook-request-guards";
30
28
  import { chunkMarkdownText } from "openclaw/plugin-sdk/reply-runtime";
29
+ import crypto from "node:crypto";
30
+ import { recordChannelActivity } from "openclaw/plugin-sdk/channel-activity-runtime";
31
31
  import { resolvePromptHistoryLimit } from "openclaw/plugin-sdk/number-runtime";
32
32
  import { getRuntimeConfigSnapshot, getRuntimeConfigSourceSnapshot, selectApplicableRuntimeConfig } from "openclaw/plugin-sdk/runtime-config-snapshot";
33
33
  import { fanInChannelIngressLifecycles, resolveChannelImplicitMentions } from "openclaw/plugin-sdk/channel-ingress-runtime";
@@ -37,7 +37,6 @@ import { ensureConfiguredBindingRouteReady, readChannelAllowFromStore, resolveCo
37
37
  import { DEFAULT_GROUP_HISTORY_LIMIT, createChannelHistoryWindow } from "openclaw/plugin-sdk/reply-history";
38
38
  import { parseAgentSessionKey, resolveAgentRoute, resolveInboundLastRouteSessionKey } from "openclaw/plugin-sdk/routing";
39
39
  import { resolveAllowlistProviderRuntimeGroupPolicy, resolveDefaultGroupPolicy, warnMissingProviderGroupPolicyFallbackOnce } from "openclaw/plugin-sdk/runtime-group-policy";
40
- import { agentControlText } from "openclaw/plugin-sdk/agent-control-runtime";
41
40
  import { getSessionBindingService, inspectRuntimeConversationBindingRoute } from "openclaw/plugin-sdk/conversation-binding-runtime";
42
41
  import { setTimeout as setTimeout$1 } from "node:timers/promises";
43
42
  import { MediaFetchError } from "openclaw/plugin-sdk/media-runtime";
@@ -139,7 +138,7 @@ async function deliverLineAutoReply(params) {
139
138
  }
140
139
  if (lineData.location) richMessages.push(createLocationMessage(lineData.location));
141
140
  const visibleText = payload.text ? sanitizeAssistantVisibleText(payload.text) : "";
142
- const markdownMessages = (visibleText ? processLineMessage(visibleText) : []).flatMap((segment) => segment.type === "flex" ? [createFlexMessage(segment.message.altText, segment.message.contents)] : chunkMarkdownText(segment.text, textLimit).map((text) => ({
141
+ const markdownMessages = (visibleText ? processLineMessage(visibleText) : []).flatMap((segment) => segment.type === "flex" ? [createFlexMessage(segment.message.altText, segment.message.contents)] : chunkLineText(segment, textLimit, chunkMarkdownText).map(({ text }) => ({
143
142
  type: "text",
144
143
  text
145
144
  })));
@@ -0,0 +1,3 @@
1
+ import { i as createQuickReplyItems, n as createFlexMessage, r as createLocationMessage, t as buildTemplateMessageFromPayload } from "./template-messages-5ZlXYNrb.mjs";
2
+ import { a as pushLocationMessage, c as pushTemplateMessage, i as pushFlexMessage, l as pushTextMessageWithQuickReplies, m as processLineMessage, o as pushMessageLine, p as chunkLineText, s as pushMessagesLine } from "./send-Btj5Sv6v.mjs";
3
+ export { buildTemplateMessageFromPayload, chunkLineText, createFlexMessage, createLocationMessage, createQuickReplyItems, processLineMessage, pushFlexMessage, pushLocationMessage, pushMessageLine, pushMessagesLine, pushTemplateMessage, pushTextMessageWithQuickReplies };