@openclaw/line 2026.5.2-beta.2 → 2026.5.3-beta.1

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.
Files changed (109) hide show
  1. package/dist/accounts-UXAvdBo_.js +105 -0
  2. package/dist/api.js +11 -0
  3. package/dist/basic-cards-7DTG6E-A.js +307 -0
  4. package/dist/card-command-UlPc6Vuc.js +240 -0
  5. package/dist/channel-Rls9s60K.js +601 -0
  6. package/dist/channel-plugin-api.js +2 -0
  7. package/dist/channel.runtime-bXoj8_Sl.js +4 -0
  8. package/dist/contract-api.js +2 -0
  9. package/dist/index.js +45 -0
  10. package/dist/markdown-to-line-CCWK6PJh.js +789 -0
  11. package/dist/monitor-B4_RxHc0.js +1523 -0
  12. package/dist/monitor.runtime-DyxYlrM9.js +2 -0
  13. package/dist/outbound-media-BfhBmWq5.js +55 -0
  14. package/dist/outbound.runtime-B-luYwEB.js +2 -0
  15. package/dist/probe-D9BPzb2n.js +30 -0
  16. package/dist/probe.runtime-N91OWW1J.js +2 -0
  17. package/dist/quick-reply-fallback-HskUUWsn.js +55 -0
  18. package/dist/reply-payload-transform-CFGTs9ln.js +713 -0
  19. package/dist/runtime-api.js +277 -0
  20. package/dist/schedule-cards-BwQChTdM.js +359 -0
  21. package/dist/secret-contract-api.js +5 -0
  22. package/dist/setup-api.js +2 -0
  23. package/dist/setup-entry.js +11 -0
  24. package/dist/setup-surface-DCH7CE-y.js +281 -0
  25. package/package.json +14 -6
  26. package/api.ts +0 -11
  27. package/channel-plugin-api.ts +0 -1
  28. package/contract-api.ts +0 -5
  29. package/index.ts +0 -54
  30. package/runtime-api.ts +0 -187
  31. package/secret-contract-api.ts +0 -4
  32. package/setup-api.ts +0 -2
  33. package/setup-entry.ts +0 -9
  34. package/src/account-helpers.ts +0 -16
  35. package/src/accounts.test.ts +0 -290
  36. package/src/accounts.ts +0 -187
  37. package/src/actions.ts +0 -61
  38. package/src/auto-reply-delivery.test.ts +0 -248
  39. package/src/auto-reply-delivery.ts +0 -200
  40. package/src/bindings.ts +0 -65
  41. package/src/bot-access.ts +0 -48
  42. package/src/bot-handlers.test.ts +0 -1089
  43. package/src/bot-handlers.ts +0 -642
  44. package/src/bot-message-context.test.ts +0 -405
  45. package/src/bot-message-context.ts +0 -581
  46. package/src/bot.ts +0 -70
  47. package/src/card-command.ts +0 -347
  48. package/src/channel-access-token.ts +0 -14
  49. package/src/channel-api.ts +0 -17
  50. package/src/channel-setup-status.contract.test.ts +0 -70
  51. package/src/channel-shared.ts +0 -48
  52. package/src/channel.logout.test.ts +0 -145
  53. package/src/channel.runtime.ts +0 -3
  54. package/src/channel.sendPayload.test.ts +0 -514
  55. package/src/channel.setup.ts +0 -11
  56. package/src/channel.status.test.ts +0 -63
  57. package/src/channel.ts +0 -154
  58. package/src/config-adapter.ts +0 -29
  59. package/src/config-schema.ts +0 -57
  60. package/src/download.test.ts +0 -133
  61. package/src/download.ts +0 -87
  62. package/src/flex-templates/basic-cards.ts +0 -395
  63. package/src/flex-templates/common.ts +0 -20
  64. package/src/flex-templates/media-control-cards.ts +0 -555
  65. package/src/flex-templates/message.ts +0 -13
  66. package/src/flex-templates/schedule-cards.ts +0 -467
  67. package/src/flex-templates/types.ts +0 -22
  68. package/src/flex-templates.ts +0 -32
  69. package/src/gateway.ts +0 -129
  70. package/src/group-keys.test.ts +0 -123
  71. package/src/group-keys.ts +0 -65
  72. package/src/group-policy.ts +0 -22
  73. package/src/markdown-to-line.test.ts +0 -348
  74. package/src/markdown-to-line.ts +0 -416
  75. package/src/message-cards.test.ts +0 -204
  76. package/src/monitor.lifecycle.test.ts +0 -421
  77. package/src/monitor.runtime.ts +0 -1
  78. package/src/monitor.ts +0 -506
  79. package/src/outbound-media.test.ts +0 -189
  80. package/src/outbound-media.ts +0 -120
  81. package/src/outbound.runtime.ts +0 -12
  82. package/src/outbound.ts +0 -356
  83. package/src/probe.contract.test.ts +0 -9
  84. package/src/probe.runtime.ts +0 -1
  85. package/src/probe.ts +0 -34
  86. package/src/quick-reply-fallback.ts +0 -10
  87. package/src/reply-chunks.test.ts +0 -179
  88. package/src/reply-chunks.ts +0 -110
  89. package/src/reply-payload-transform.test.ts +0 -387
  90. package/src/reply-payload-transform.ts +0 -317
  91. package/src/rich-menu.test.ts +0 -310
  92. package/src/rich-menu.ts +0 -326
  93. package/src/runtime.ts +0 -32
  94. package/src/send.test.ts +0 -346
  95. package/src/send.ts +0 -489
  96. package/src/setup-core.ts +0 -149
  97. package/src/setup-runtime-api.ts +0 -9
  98. package/src/setup-surface.test.ts +0 -474
  99. package/src/setup-surface.ts +0 -227
  100. package/src/signature.test.ts +0 -34
  101. package/src/signature.ts +0 -24
  102. package/src/status.ts +0 -37
  103. package/src/template-messages.ts +0 -333
  104. package/src/types.ts +0 -128
  105. package/src/webhook-node.test.ts +0 -513
  106. package/src/webhook-node.ts +0 -131
  107. package/src/webhook-utils.ts +0 -10
  108. package/src/webhook.ts +0 -111
  109. package/tsconfig.json +0 -16
@@ -1,120 +0,0 @@
1
- import { resolvePinnedHostnameWithPolicy, type SsrFPolicy } from "openclaw/plugin-sdk/ssrf-runtime";
2
- import { normalizeLowercaseStringOrEmpty } from "openclaw/plugin-sdk/text-runtime";
3
-
4
- type LineOutboundMediaKind = "image" | "video" | "audio";
5
-
6
- export type LineOutboundMediaResolved = {
7
- mediaUrl: string;
8
- mediaKind: LineOutboundMediaKind;
9
- previewImageUrl?: string;
10
- durationMs?: number;
11
- trackingId?: string;
12
- };
13
-
14
- type ResolveLineOutboundMediaOpts = {
15
- mediaKind?: LineOutboundMediaKind;
16
- previewImageUrl?: string;
17
- durationMs?: number;
18
- trackingId?: string;
19
- };
20
-
21
- const LINE_OUTBOUND_MEDIA_SSRF_POLICY: SsrFPolicy = {
22
- allowPrivateNetwork: false,
23
- };
24
-
25
- export async function validateLineMediaUrl(url: string): Promise<void> {
26
- let parsed: URL;
27
- try {
28
- parsed = new URL(url);
29
- } catch {
30
- throw new Error(`LINE outbound media URL must be a valid URL: ${url}`);
31
- }
32
- if (parsed.protocol !== "https:") {
33
- throw new Error(`LINE outbound media URL must use HTTPS: ${url}`);
34
- }
35
- if (url.length > 2000) {
36
- throw new Error(`LINE outbound media URL must be 2000 chars or less (got ${url.length})`);
37
- }
38
- await resolvePinnedHostnameWithPolicy(parsed.hostname, {
39
- policy: LINE_OUTBOUND_MEDIA_SSRF_POLICY,
40
- });
41
- }
42
-
43
- export function detectLineMediaKind(mimeType: string): LineOutboundMediaKind {
44
- const normalized = normalizeLowercaseStringOrEmpty(mimeType);
45
- if (normalized.startsWith("image/")) {
46
- return "image";
47
- }
48
- if (normalized.startsWith("video/")) {
49
- return "video";
50
- }
51
- if (normalized.startsWith("audio/")) {
52
- return "audio";
53
- }
54
- return "image";
55
- }
56
-
57
- function isHttpsUrl(url: string): boolean {
58
- try {
59
- return new URL(url).protocol === "https:";
60
- } catch {
61
- return false;
62
- }
63
- }
64
-
65
- function detectLineMediaKindFromUrl(url: string): LineOutboundMediaKind | undefined {
66
- try {
67
- const pathname = normalizeLowercaseStringOrEmpty(new URL(url).pathname);
68
- if (/\.(png|jpe?g|gif|webp|bmp|heic|heif|avif)$/i.test(pathname)) {
69
- return "image";
70
- }
71
- if (/\.(mp4|mov|m4v|webm)$/i.test(pathname)) {
72
- return "video";
73
- }
74
- if (/\.(mp3|m4a|aac|wav|ogg|oga)$/i.test(pathname)) {
75
- return "audio";
76
- }
77
- } catch {
78
- return undefined;
79
- }
80
- return undefined;
81
- }
82
-
83
- export async function resolveLineOutboundMedia(
84
- mediaUrl: string,
85
- opts: ResolveLineOutboundMediaOpts = {},
86
- ): Promise<LineOutboundMediaResolved> {
87
- const trimmedUrl = mediaUrl.trim();
88
- if (isHttpsUrl(trimmedUrl)) {
89
- await validateLineMediaUrl(trimmedUrl);
90
- const previewImageUrl = opts.previewImageUrl?.trim();
91
- if (previewImageUrl) {
92
- await validateLineMediaUrl(previewImageUrl);
93
- }
94
- const mediaKind =
95
- opts.mediaKind ??
96
- (typeof opts.durationMs === "number" ? "audio" : undefined) ??
97
- (opts.trackingId?.trim() ? "video" : undefined) ??
98
- detectLineMediaKindFromUrl(trimmedUrl) ??
99
- "image";
100
- return {
101
- mediaUrl: trimmedUrl,
102
- mediaKind,
103
- ...(previewImageUrl ? { previewImageUrl } : {}),
104
- ...(typeof opts.durationMs === "number" ? { durationMs: opts.durationMs } : {}),
105
- ...(opts.trackingId ? { trackingId: opts.trackingId } : {}),
106
- };
107
- }
108
-
109
- try {
110
- const parsed = new URL(trimmedUrl);
111
- if (parsed.protocol !== "https:") {
112
- throw new Error(`LINE outbound media URL must use HTTPS: ${trimmedUrl}`);
113
- }
114
- } catch (e) {
115
- if (e instanceof Error && e.message.startsWith("LINE outbound")) {
116
- throw e;
117
- }
118
- }
119
- throw new Error("LINE outbound media currently requires a public HTTPS URL");
120
- }
@@ -1,12 +0,0 @@
1
- export { processLineMessage } from "./markdown-to-line.js";
2
- export {
3
- createQuickReplyItems,
4
- pushFlexMessage,
5
- pushLocationMessage,
6
- pushMessageLine,
7
- pushMessagesLine,
8
- pushTemplateMessage,
9
- pushTextMessageWithQuickReplies,
10
- sendMessageLine,
11
- } from "./send.js";
12
- export { buildTemplateMessageFromPayload } from "./template-messages.js";
package/src/outbound.ts DELETED
@@ -1,356 +0,0 @@
1
- import {
2
- createAttachedChannelResultAdapter,
3
- createEmptyChannelResult,
4
- } from "openclaw/plugin-sdk/channel-send-result";
5
- import { createLazyRuntimeModule } from "openclaw/plugin-sdk/lazy-runtime";
6
- import { resolveOutboundMediaUrls } from "openclaw/plugin-sdk/reply-payload";
7
- import { type ChannelPlugin, type ResolvedLineAccount } from "./channel-api.js";
8
- import { resolveLineOutboundMedia, type LineOutboundMediaResolved } from "./outbound-media.js";
9
- import { buildLineQuickReplyFallbackText } from "./quick-reply-fallback.js";
10
- import { getLineRuntime } from "./runtime.js";
11
- import type { LineChannelData } from "./types.js";
12
-
13
- const loadLineOutboundRuntime = createLazyRuntimeModule(() => import("./outbound.runtime.js"));
14
-
15
- type LineChannelDataWithMedia = LineChannelData & {
16
- mediaKind?: "image" | "video" | "audio";
17
- previewImageUrl?: string;
18
- durationMs?: number;
19
- trackingId?: string;
20
- };
21
-
22
- function isLineUserTarget(target: string): boolean {
23
- const normalized = target
24
- .trim()
25
- .replace(/^line:(group|room|user):/i, "")
26
- .replace(/^line:/i, "");
27
- return /^U/i.test(normalized);
28
- }
29
-
30
- function hasLineSpecificMediaOptions(lineData: LineChannelDataWithMedia): boolean {
31
- return Boolean(
32
- lineData.mediaKind ??
33
- lineData.previewImageUrl?.trim() ??
34
- (typeof lineData.durationMs === "number" ? lineData.durationMs : undefined) ??
35
- lineData.trackingId?.trim(),
36
- );
37
- }
38
-
39
- function buildLineMediaMessageObject(
40
- resolved: LineOutboundMediaResolved,
41
- opts?: { allowTrackingId?: boolean },
42
- ): Record<string, unknown> {
43
- switch (resolved.mediaKind) {
44
- case "video": {
45
- const previewImageUrl = resolved.previewImageUrl?.trim();
46
- if (!previewImageUrl) {
47
- throw new Error("LINE video messages require previewImageUrl to reference an image URL");
48
- }
49
- return {
50
- type: "video",
51
- originalContentUrl: resolved.mediaUrl,
52
- previewImageUrl,
53
- ...(opts?.allowTrackingId && resolved.trackingId
54
- ? { trackingId: resolved.trackingId }
55
- : {}),
56
- };
57
- }
58
- case "audio":
59
- return {
60
- type: "audio",
61
- originalContentUrl: resolved.mediaUrl,
62
- duration: resolved.durationMs ?? 60000,
63
- };
64
- default:
65
- return {
66
- type: "image",
67
- originalContentUrl: resolved.mediaUrl,
68
- previewImageUrl: resolved.previewImageUrl ?? resolved.mediaUrl,
69
- };
70
- }
71
- }
72
-
73
- export const lineOutboundAdapter: NonNullable<ChannelPlugin<ResolvedLineAccount>["outbound"]> = {
74
- deliveryMode: "direct",
75
- chunker: (text, limit) => getLineRuntime().channel.text.chunkMarkdownText(text, limit),
76
- textChunkLimit: 5000,
77
- sendPayload: async ({ to, payload, accountId, cfg }) => {
78
- const runtime = getLineRuntime();
79
- const outboundRuntime = await loadLineOutboundRuntime();
80
- const lineData = (payload.channelData?.line as LineChannelDataWithMedia | undefined) ?? {};
81
- const lineRuntime = runtime.channel.line;
82
- const sendText = lineRuntime?.pushMessageLine ?? outboundRuntime.pushMessageLine;
83
- const sendBatch = lineRuntime?.pushMessagesLine ?? outboundRuntime.pushMessagesLine;
84
- const sendFlex = lineRuntime?.pushFlexMessage ?? outboundRuntime.pushFlexMessage;
85
- const sendTemplate = lineRuntime?.pushTemplateMessage ?? outboundRuntime.pushTemplateMessage;
86
- const sendLocation = lineRuntime?.pushLocationMessage ?? outboundRuntime.pushLocationMessage;
87
- const sendQuickReplies =
88
- lineRuntime?.pushTextMessageWithQuickReplies ??
89
- outboundRuntime.pushTextMessageWithQuickReplies;
90
- const buildTemplate =
91
- lineRuntime?.buildTemplateMessageFromPayload ??
92
- outboundRuntime.buildTemplateMessageFromPayload;
93
-
94
- let lastResult: { messageId: string; chatId: string } | null = null;
95
- const quickReplies = lineData.quickReplies ?? [];
96
- const hasQuickReplies = quickReplies.length > 0;
97
- const quickReply = hasQuickReplies
98
- ? (lineRuntime?.createQuickReplyItems ?? outboundRuntime.createQuickReplyItems)(quickReplies)
99
- : undefined;
100
-
101
- // LINE SDK expects Message[] but we build dynamically.
102
- const sendMessageBatch = async (messages: Array<Record<string, unknown>>) => {
103
- if (messages.length === 0) {
104
- return;
105
- }
106
- for (let i = 0; i < messages.length; i += 5) {
107
- const batch = messages.slice(i, i + 5) as unknown as Parameters<typeof sendBatch>[1];
108
- const result = await sendBatch(to, batch, {
109
- verbose: false,
110
- cfg,
111
- accountId: accountId ?? undefined,
112
- });
113
- lastResult = { messageId: result.messageId, chatId: result.chatId };
114
- }
115
- };
116
-
117
- const processed = payload.text
118
- ? outboundRuntime.processLineMessage(payload.text)
119
- : { text: "", flexMessages: [] };
120
-
121
- const chunkLimit =
122
- runtime.channel.text.resolveTextChunkLimit?.(cfg, "line", accountId ?? undefined, {
123
- fallbackLimit: 5000,
124
- }) ?? 5000;
125
-
126
- const chunks = processed.text
127
- ? runtime.channel.text.chunkMarkdownText(processed.text, chunkLimit)
128
- : [];
129
- const mediaUrls = resolveOutboundMediaUrls(payload);
130
- const useLineSpecificMedia = hasLineSpecificMediaOptions(lineData);
131
- const shouldSendQuickRepliesInline = chunks.length === 0 && hasQuickReplies;
132
- const sendMediaMessages = async () => {
133
- for (const url of mediaUrls) {
134
- const trimmed = url?.trim();
135
- if (!trimmed) {
136
- continue;
137
- }
138
- if (!useLineSpecificMedia) {
139
- lastResult = await (lineRuntime?.sendMessageLine ?? outboundRuntime.sendMessageLine)(
140
- to,
141
- "",
142
- {
143
- verbose: false,
144
- mediaUrl: trimmed,
145
- cfg,
146
- accountId: accountId ?? undefined,
147
- },
148
- );
149
- continue;
150
- }
151
- const resolved = await resolveLineOutboundMedia(trimmed, {
152
- mediaKind: lineData.mediaKind,
153
- previewImageUrl: lineData.previewImageUrl,
154
- durationMs: lineData.durationMs,
155
- trackingId: lineData.trackingId,
156
- });
157
- lastResult = await (lineRuntime?.sendMessageLine ?? outboundRuntime.sendMessageLine)(
158
- to,
159
- "",
160
- {
161
- verbose: false,
162
- mediaUrl: resolved.mediaUrl,
163
- mediaKind: resolved.mediaKind,
164
- previewImageUrl: resolved.previewImageUrl,
165
- durationMs: resolved.durationMs,
166
- trackingId: resolved.trackingId,
167
- cfg,
168
- accountId: accountId ?? undefined,
169
- },
170
- );
171
- }
172
- };
173
-
174
- if (!shouldSendQuickRepliesInline) {
175
- if (lineData.flexMessage) {
176
- const flexContents = lineData.flexMessage.contents as Parameters<typeof sendFlex>[2];
177
- lastResult = await sendFlex(to, lineData.flexMessage.altText, flexContents, {
178
- verbose: false,
179
- cfg,
180
- accountId: accountId ?? undefined,
181
- });
182
- }
183
-
184
- if (lineData.templateMessage) {
185
- const template = buildTemplate(lineData.templateMessage);
186
- if (template) {
187
- lastResult = await sendTemplate(to, template, {
188
- verbose: false,
189
- cfg,
190
- accountId: accountId ?? undefined,
191
- });
192
- }
193
- }
194
-
195
- if (lineData.location) {
196
- lastResult = await sendLocation(to, lineData.location, {
197
- verbose: false,
198
- cfg,
199
- accountId: accountId ?? undefined,
200
- });
201
- }
202
-
203
- for (const flexMsg of processed.flexMessages) {
204
- const flexContents = flexMsg.contents;
205
- lastResult = await sendFlex(to, flexMsg.altText, flexContents, {
206
- verbose: false,
207
- cfg,
208
- accountId: accountId ?? undefined,
209
- });
210
- }
211
- }
212
-
213
- const sendMediaAfterText = !(hasQuickReplies && chunks.length > 0);
214
- if (mediaUrls.length > 0 && !shouldSendQuickRepliesInline && !sendMediaAfterText) {
215
- await sendMediaMessages();
216
- }
217
-
218
- if (chunks.length > 0) {
219
- for (let i = 0; i < chunks.length; i += 1) {
220
- const isLast = i === chunks.length - 1;
221
- if (isLast && hasQuickReplies) {
222
- lastResult = await sendQuickReplies(to, chunks[i], quickReplies, {
223
- verbose: false,
224
- cfg,
225
- accountId: accountId ?? undefined,
226
- });
227
- } else {
228
- lastResult = await sendText(to, chunks[i], {
229
- verbose: false,
230
- cfg,
231
- accountId: accountId ?? undefined,
232
- });
233
- }
234
- }
235
- } else if (shouldSendQuickRepliesInline) {
236
- const quickReplyMessages: Array<Record<string, unknown>> = [];
237
- if (lineData.flexMessage) {
238
- quickReplyMessages.push({
239
- type: "flex",
240
- altText: lineData.flexMessage.altText.slice(0, 400),
241
- contents: lineData.flexMessage.contents,
242
- });
243
- }
244
- if (lineData.templateMessage) {
245
- const template = buildTemplate(lineData.templateMessage);
246
- if (template) {
247
- quickReplyMessages.push(template);
248
- }
249
- }
250
- if (lineData.location) {
251
- quickReplyMessages.push({
252
- type: "location",
253
- title: lineData.location.title.slice(0, 100),
254
- address: lineData.location.address.slice(0, 100),
255
- latitude: lineData.location.latitude,
256
- longitude: lineData.location.longitude,
257
- });
258
- }
259
- for (const flexMsg of processed.flexMessages) {
260
- quickReplyMessages.push({
261
- type: "flex",
262
- altText: flexMsg.altText.slice(0, 400),
263
- contents: flexMsg.contents,
264
- });
265
- }
266
- for (const url of mediaUrls) {
267
- const trimmed = url?.trim();
268
- if (!trimmed) {
269
- continue;
270
- }
271
- if (!useLineSpecificMedia) {
272
- quickReplyMessages.push({
273
- type: "image",
274
- originalContentUrl: trimmed,
275
- previewImageUrl: trimmed,
276
- });
277
- continue;
278
- }
279
- const resolved = await resolveLineOutboundMedia(trimmed, {
280
- mediaKind: lineData.mediaKind,
281
- previewImageUrl: lineData.previewImageUrl,
282
- durationMs: lineData.durationMs,
283
- trackingId: lineData.trackingId,
284
- });
285
- quickReplyMessages.push(
286
- buildLineMediaMessageObject(resolved, { allowTrackingId: isLineUserTarget(to) }),
287
- );
288
- }
289
- if (quickReplyMessages.length > 0 && quickReply) {
290
- const lastIndex = quickReplyMessages.length - 1;
291
- quickReplyMessages[lastIndex] = {
292
- ...quickReplyMessages[lastIndex],
293
- quickReply,
294
- };
295
- await sendMessageBatch(quickReplyMessages);
296
- } else if (quickReply) {
297
- lastResult = await sendQuickReplies(
298
- to,
299
- buildLineQuickReplyFallbackText(quickReplies),
300
- quickReplies,
301
- {
302
- verbose: false,
303
- cfg,
304
- accountId: accountId ?? undefined,
305
- },
306
- );
307
- }
308
- }
309
-
310
- if (mediaUrls.length > 0 && !shouldSendQuickRepliesInline && sendMediaAfterText) {
311
- await sendMediaMessages();
312
- }
313
-
314
- if (lastResult) {
315
- return createEmptyChannelResult("line", { ...lastResult });
316
- }
317
- return createEmptyChannelResult("line", { messageId: "empty", chatId: to });
318
- },
319
- ...createAttachedChannelResultAdapter({
320
- channel: "line",
321
- sendText: async ({ cfg, to, text, accountId }) => {
322
- const outboundRuntime = await loadLineOutboundRuntime();
323
- const sendText = outboundRuntime.pushMessageLine;
324
- const sendFlex = outboundRuntime.pushFlexMessage;
325
- const processed = outboundRuntime.processLineMessage(text);
326
- let result: { messageId: string; chatId: string };
327
- if (processed.text.trim()) {
328
- result = await sendText(to, processed.text, {
329
- verbose: false,
330
- cfg,
331
- accountId: accountId ?? undefined,
332
- });
333
- } else {
334
- result = { messageId: "processed", chatId: to };
335
- }
336
- for (const flexMsg of processed.flexMessages) {
337
- const flexContents = flexMsg.contents;
338
- await sendFlex(to, flexMsg.altText, flexContents, {
339
- verbose: false,
340
- cfg,
341
- accountId: accountId ?? undefined,
342
- });
343
- }
344
- return result;
345
- },
346
- sendMedia: async ({ cfg, to, text, mediaUrl, accountId }) =>
347
- await (
348
- await loadLineOutboundRuntime()
349
- ).sendMessageLine(to, text, {
350
- verbose: false,
351
- mediaUrl,
352
- cfg,
353
- accountId: accountId ?? undefined,
354
- }),
355
- }),
356
- };
@@ -1,9 +0,0 @@
1
- import type { BaseProbeResult } from "openclaw/plugin-sdk/channel-contract";
2
- import { describe, expectTypeOf, it } from "vitest";
3
- import type { LineProbeResult } from "./types.js";
4
-
5
- describe("LINE probe contract", () => {
6
- it("keeps public probe aligned with base contract", () => {
7
- expectTypeOf<LineProbeResult>().toMatchTypeOf<BaseProbeResult>();
8
- });
9
- });
@@ -1 +0,0 @@
1
- export { probeLineBot } from "./probe.js";
package/src/probe.ts DELETED
@@ -1,34 +0,0 @@
1
- import { messagingApi } from "@line/bot-sdk";
2
- import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
3
- import { withTimeout } from "openclaw/plugin-sdk/text-runtime";
4
- import type { LineProbeResult } from "./types.js";
5
-
6
- export async function probeLineBot(
7
- channelAccessToken: string,
8
- timeoutMs = 5000,
9
- ): Promise<LineProbeResult> {
10
- if (!channelAccessToken?.trim()) {
11
- return { ok: false, error: "Channel access token not configured" };
12
- }
13
-
14
- const client = new messagingApi.MessagingApiClient({
15
- channelAccessToken: channelAccessToken.trim(),
16
- });
17
-
18
- try {
19
- const profile = await withTimeout(client.getBotInfo(), timeoutMs);
20
-
21
- return {
22
- ok: true,
23
- bot: {
24
- displayName: profile.displayName,
25
- userId: profile.userId,
26
- basicId: profile.basicId,
27
- pictureUrl: profile.pictureUrl,
28
- },
29
- };
30
- } catch (err) {
31
- const message = formatErrorMessage(err);
32
- return { ok: false, error: message };
33
- }
34
- }
@@ -1,10 +0,0 @@
1
- export function buildLineQuickReplyFallbackText(labels: readonly string[] | undefined): string {
2
- const normalized = (labels ?? [])
3
- .map((label) => label.trim())
4
- .filter(Boolean)
5
- .slice(0, 13);
6
- if (normalized.length === 0) {
7
- return "Choose an option.";
8
- }
9
- return `Options:\n${normalized.map((label) => `- ${label}`).join("\n")}`;
10
- }