@openclaw/line 2026.9.1-beta.1 → 2026.9.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.
Files changed (46) hide show
  1. package/dist/account-helpers-BSUyZwLm.js +12 -0
  2. package/dist/{accounts-BqEVsDoB.js → accounts-BBEFMYbY.js} +2 -1
  3. package/dist/api.js +2 -2
  4. package/dist/card-command-pwvE48Wb.js +252 -0
  5. package/dist/{channel-CsQLcrsA.js → channel-BJvELOIg.js} +111 -380
  6. package/dist/channel-plugin-api.js +1 -1
  7. package/dist/channel.runtime-CZOszXXj.js +4 -0
  8. package/dist/contract-api.js +1 -1
  9. package/dist/doctor-contract-api.js +141 -0
  10. package/dist/index.js +5 -17
  11. package/dist/{markdown-to-line-BmZ4hhfC.js → markdown-to-line-B-sj-7II.js} +22 -23
  12. package/dist/{monitor-Bd9XDV1i.js → monitor-m9h5osFz.js} +339 -237
  13. package/dist/monitor.runtime-C90LL-P3.js +2 -0
  14. package/dist/outbound.runtime-CGqyJ-Ug.js +3 -0
  15. package/dist/probe.runtime-CbtMgU4s.js +2 -0
  16. package/dist/rich-messages-DY1AGKAJ.js +742 -0
  17. package/dist/runtime-api.js +14 -15
  18. package/dist/{send-Dce0m539.js → send-CQQxpxPp.js} +142 -112
  19. package/dist/{send-receipt-CCPTalf9.js → send-retry-ChpfJ-LM.js} +326 -86
  20. package/dist/setup-api.js +1 -1
  21. package/dist/{setup-surface-W0Dbgu58.js → setup-surface-CDlgkTKi.js} +47 -39
  22. package/dist/webhook-spool-contract-1rY8OJw8.js +59 -0
  23. package/node_modules/typebox/build/format/email.mjs +1 -1
  24. package/node_modules/typebox/build/format/idna/idn-hostname.mjs +19 -1
  25. package/node_modules/typebox/build/format/json_pointer.d.mts +2 -2
  26. package/node_modules/typebox/build/format/json_pointer.mjs +2 -2
  27. package/node_modules/typebox/build/format/json_pointer_uri_fragment.d.mts +2 -2
  28. package/node_modules/typebox/build/format/json_pointer_uri_fragment.mjs +2 -2
  29. package/node_modules/typebox/build/format/relative_json_pointer.d.mts +2 -2
  30. package/node_modules/typebox/build/format/relative_json_pointer.mjs +2 -2
  31. package/node_modules/typebox/build/system/memory/assign.mjs +2 -1
  32. package/node_modules/typebox/build/system/memory/create.mjs +3 -4
  33. package/node_modules/typebox/build/system/memory/discard.mjs +2 -2
  34. package/node_modules/typebox/build/system/memory/freeze.d.mts +4 -0
  35. package/node_modules/typebox/build/system/memory/freeze.mjs +6 -0
  36. package/node_modules/typebox/build/system/memory/update.mjs +3 -2
  37. package/node_modules/typebox/package.json +1 -1
  38. package/openclaw.plugin.json +16 -3
  39. package/package.json +5 -5
  40. package/dist/card-command-CmU47gD9.js +0 -230
  41. package/dist/channel.runtime-B83x7k_i.js +0 -4
  42. package/dist/media-control-cards-CksNB8Wk.js +0 -474
  43. package/dist/monitor.runtime-BCCa6qTX.js +0 -2
  44. package/dist/outbound.runtime-D4w0-Gkc.js +0 -3
  45. package/dist/probe-CM03wo6r.js +0 -28
  46. package/dist/probe.runtime-D13ZtXsd.js +0 -2
@@ -0,0 +1,742 @@
1
+ import { i as resolveLineAccount } from "./accounts-BBEFMYbY.js";
2
+ import { t as hasLineCredentials } from "./account-helpers-BSUyZwLm.js";
3
+ import { S as fitsLineFlexBubble, b as truncateLineActionLabel, c as createAgendaCard, d as createActionCard, g as messageAction, l as createEventCard, y as postbackAction } from "./send-retry-ChpfJ-LM.js";
4
+ import { normalizeAccountId } from "openclaw/plugin-sdk/account-id";
5
+ import { resolveAccountEntry } from "openclaw/plugin-sdk/account-resolution";
6
+ import { isRecord, normalizeLowercaseStringOrEmpty, normalizeStringEntries } from "openclaw/plugin-sdk/string-coerce-runtime";
7
+ import { DmPolicySchema, GroupPolicySchema, buildChannelConfigSchema, buildGroupEntrySchema, buildMultiAccountChannelSchema, requireOpenAllowFrom } from "openclaw/plugin-sdk/channel-config-schema";
8
+ import { requireChannelOpenAllowFrom } from "openclaw/plugin-sdk/extension-shared";
9
+ import { z } from "zod";
10
+ import { createPluginRuntimeStore } from "openclaw/plugin-sdk/runtime-store";
11
+ import { adaptMessagePresentationForChannel, normalizeMessagePresentation, renderMessagePresentationFallbackText, resolveMessagePresentationButtonAction, resolveMessagePresentationOptionAction } from "openclaw/plugin-sdk/interactive-runtime";
12
+ import { Type } from "typebox";
13
+ //#region extensions/line/src/config-schema.ts
14
+ const ThreadBindingsSchema = z.object({
15
+ enabled: z.boolean().optional(),
16
+ idleHours: z.number().optional(),
17
+ maxAgeHours: z.number().optional(),
18
+ spawnSessions: z.boolean().optional(),
19
+ defaultSpawnContext: z.enum(["isolated", "fork"]).optional()
20
+ }).strict();
21
+ const LineCommonConfigSchemaBase = z.object({
22
+ enabled: z.boolean().optional(),
23
+ configWrites: z.boolean().optional(),
24
+ joinIntro: z.boolean().optional(),
25
+ historyLimit: z.number().int().min(0).optional(),
26
+ channelAccessToken: z.string().optional(),
27
+ channelSecret: z.string().optional(),
28
+ tokenFile: z.string().optional(),
29
+ secretFile: z.string().optional(),
30
+ name: z.string().optional(),
31
+ allowFrom: z.array(z.union([z.string(), z.number()])).optional(),
32
+ groupAllowFrom: z.array(z.union([z.string(), z.number()])).optional(),
33
+ dmPolicy: DmPolicySchema.optional().default("pairing"),
34
+ groupPolicy: GroupPolicySchema.optional().default("allowlist"),
35
+ responsePrefix: z.string().optional(),
36
+ mediaMaxMb: z.number().optional(),
37
+ webhookPath: z.string().optional(),
38
+ threadBindings: ThreadBindingsSchema.optional()
39
+ });
40
+ const LineGroupConfigSchema = buildGroupEntrySchema().omit({
41
+ tools: true,
42
+ toolsBySender: true
43
+ });
44
+ const LineAccountConfigSchema = LineCommonConfigSchemaBase.extend({ groups: z.record(z.string(), LineGroupConfigSchema.optional()).optional() }).strict();
45
+ const LineConfigSchema = buildMultiAccountChannelSchema(LineAccountConfigSchema, {
46
+ optionalAccount: true,
47
+ refine: (value, ctx) => {
48
+ requireChannelOpenAllowFrom({
49
+ channel: "line",
50
+ policy: value.dmPolicy,
51
+ allowFrom: value.allowFrom,
52
+ ctx,
53
+ requireOpenAllowFrom
54
+ });
55
+ }
56
+ });
57
+ const LineChannelConfigSchema = buildChannelConfigSchema(LineConfigSchema, { uiHints: { joinIntro: {
58
+ label: "LINE Group Join Introduction",
59
+ help: "Post one brief introduction when the bot joins an allowed LINE group or multi-person room (default: true). Account settings override the channel-wide setting."
60
+ } } });
61
+ //#endregion
62
+ //#region extensions/line/src/runtime.ts
63
+ const { setRuntime: setLineRuntime, getRuntime: getLineRuntime } = createPluginRuntimeStore({
64
+ pluginId: "line",
65
+ errorMessage: "LINE runtime not initialized - plugin not registered"
66
+ });
67
+ //#endregion
68
+ //#region extensions/line/src/group-keys.ts
69
+ function resolveLineGroupLookupIds(groupId) {
70
+ const normalized = groupId?.trim();
71
+ if (!normalized) return [];
72
+ if (normalized.startsWith("group:") || normalized.startsWith("room:")) {
73
+ const rawId = normalized.split(":").slice(1).join(":");
74
+ return rawId ? [rawId, normalized] : [normalized];
75
+ }
76
+ return [
77
+ normalized,
78
+ `group:${normalized}`,
79
+ `room:${normalized}`
80
+ ];
81
+ }
82
+ function resolveLineGroupConfigEntry(groups, params) {
83
+ if (!groups) return;
84
+ const defaults = groups["*"];
85
+ for (const candidate of [...resolveLineGroupLookupIds(params.groupId), ...resolveLineGroupLookupIds(params.roomId)]) {
86
+ const hit = groups[candidate];
87
+ if (hit) return defaults && defaults !== hit ? {
88
+ ...defaults,
89
+ ...hit
90
+ } : hit;
91
+ }
92
+ return defaults;
93
+ }
94
+ function resolveLineGroupsConfig(cfg, accountId) {
95
+ const lineConfig = cfg.channels?.line;
96
+ if (!lineConfig) return;
97
+ const normalizedAccountId = normalizeAccountId(accountId);
98
+ return resolveAccountEntry(lineConfig.accounts, normalizedAccountId)?.groups ?? lineConfig.groups;
99
+ }
100
+ function resolveExactLineGroupConfigKey(params) {
101
+ const { groups } = params;
102
+ if (!groups) return;
103
+ return resolveLineGroupLookupIds(params.groupId).find((candidate) => Object.hasOwn(groups, candidate));
104
+ }
105
+ //#endregion
106
+ //#region extensions/line/src/quick-reply-fallback.ts
107
+ function buildLineQuickReplyFallbackText(labels) {
108
+ const normalized = normalizeStringEntries(labels ?? []).slice(0, 13);
109
+ if (normalized.length === 0) return "Choose an option.";
110
+ return `Options:\n${normalized.map((label) => `- ${label}`).join("\n")}`;
111
+ }
112
+ //#endregion
113
+ //#region extensions/line/src/flex-templates/media-control-cards.ts
114
+ function horizontalRow(contents, options = {}) {
115
+ return {
116
+ type: "box",
117
+ layout: "horizontal",
118
+ contents,
119
+ ...options
120
+ };
121
+ }
122
+ /**
123
+ * Create a media player card for Sonos, Spotify, Apple Music, etc.
124
+ *
125
+ * Editorial design: Album art hero with gradient overlay for text,
126
+ * prominent now-playing indicator, refined playback controls.
127
+ */
128
+ function createMediaPlayerCard(params) {
129
+ const { title, subtitle, source, imageUrl, isPlaying, progress, controls, extraActions } = params;
130
+ const trackInfo = [{
131
+ type: "text",
132
+ text: title,
133
+ weight: "bold",
134
+ size: "xl",
135
+ color: "#111111",
136
+ wrap: true
137
+ }];
138
+ if (subtitle) trackInfo.push({
139
+ type: "text",
140
+ text: subtitle,
141
+ size: "md",
142
+ color: "#666666",
143
+ wrap: true,
144
+ margin: "sm"
145
+ });
146
+ const statusItems = [];
147
+ if (isPlaying !== void 0) statusItems.push(horizontalRow([{
148
+ type: "box",
149
+ layout: "vertical",
150
+ contents: [],
151
+ width: "8px",
152
+ height: "8px",
153
+ backgroundColor: isPlaying ? "#06C755" : "#CCCCCC",
154
+ cornerRadius: "4px"
155
+ }, {
156
+ type: "text",
157
+ text: isPlaying ? "Now Playing" : "Paused",
158
+ size: "xs",
159
+ color: isPlaying ? "#06C755" : "#888888",
160
+ weight: "bold",
161
+ margin: "sm"
162
+ }], { alignItems: "center" }));
163
+ if (source) statusItems.push({
164
+ type: "text",
165
+ text: source,
166
+ size: "xs",
167
+ color: "#AAAAAA",
168
+ margin: statusItems.length > 0 ? "lg" : void 0
169
+ });
170
+ if (progress) statusItems.push({
171
+ type: "text",
172
+ text: progress,
173
+ size: "xs",
174
+ color: "#888888",
175
+ align: "end",
176
+ flex: 1
177
+ });
178
+ const bodyContents = [{
179
+ type: "box",
180
+ layout: "vertical",
181
+ contents: trackInfo
182
+ }];
183
+ if (statusItems.length > 0) bodyContents.push(horizontalRow(statusItems, {
184
+ margin: "lg",
185
+ alignItems: "center"
186
+ }));
187
+ const bubble = {
188
+ type: "bubble",
189
+ size: "mega",
190
+ body: {
191
+ type: "box",
192
+ layout: "vertical",
193
+ contents: bodyContents,
194
+ paddingAll: "xl",
195
+ backgroundColor: "#FFFFFF"
196
+ }
197
+ };
198
+ if (imageUrl) bubble.hero = {
199
+ type: "image",
200
+ url: imageUrl,
201
+ size: "full",
202
+ aspectRatio: "1:1",
203
+ aspectMode: "cover"
204
+ };
205
+ if (controls || extraActions?.length) {
206
+ const footerContents = [];
207
+ if (controls) {
208
+ const controlButtons = [];
209
+ for (const [key, label, style] of [
210
+ [
211
+ "previous",
212
+ "⏮",
213
+ "secondary"
214
+ ],
215
+ [
216
+ "play",
217
+ "▶",
218
+ isPlaying ? "secondary" : "primary"
219
+ ],
220
+ [
221
+ "pause",
222
+ "⏸",
223
+ isPlaying ? "primary" : "secondary"
224
+ ],
225
+ [
226
+ "next",
227
+ "⏭",
228
+ "secondary"
229
+ ]
230
+ ]) {
231
+ const control = controls[key];
232
+ if (!control) continue;
233
+ const button = {
234
+ type: "button",
235
+ action: postbackAction(label, control.data),
236
+ style,
237
+ flex: 1,
238
+ height: "sm"
239
+ };
240
+ if (key !== "previous") button.margin = controlButtons.length > 0 ? "md" : void 0;
241
+ controlButtons.push(button);
242
+ }
243
+ if (controlButtons.length > 0) footerContents.push(horizontalRow(controlButtons));
244
+ }
245
+ if (extraActions?.length) footerContents.push(horizontalRow(extraActions.slice(0, 2).map((action, index) => ({
246
+ type: "button",
247
+ action: postbackAction(truncateLineActionLabel(action.label, 15), action.data),
248
+ style: "secondary",
249
+ flex: 1,
250
+ height: "sm",
251
+ margin: index > 0 ? "md" : void 0
252
+ })), { margin: "md" }));
253
+ if (footerContents.length > 0) bubble.footer = {
254
+ type: "box",
255
+ layout: "vertical",
256
+ contents: footerContents,
257
+ paddingAll: "lg",
258
+ backgroundColor: "#FAFAFA"
259
+ };
260
+ }
261
+ return bubble;
262
+ }
263
+ /**
264
+ * Create an Apple TV remote card with a D-pad and control rows.
265
+ */
266
+ function createAppleTvRemoteCard(params) {
267
+ const { deviceName, status, actionData } = params;
268
+ const headerContents = [{
269
+ type: "text",
270
+ text: deviceName,
271
+ weight: "bold",
272
+ size: "xl",
273
+ color: "#111111",
274
+ wrap: true
275
+ }];
276
+ if (status) headerContents.push({
277
+ type: "text",
278
+ text: status,
279
+ size: "sm",
280
+ color: "#666666",
281
+ wrap: true,
282
+ margin: "sm"
283
+ });
284
+ const makeButton = (label, data, style = "secondary") => ({
285
+ type: "button",
286
+ action: postbackAction(label, data),
287
+ style,
288
+ height: "sm",
289
+ flex: 1
290
+ });
291
+ const controlRows = [
292
+ horizontalRow([
293
+ { type: "filler" },
294
+ makeButton("↑", actionData.up),
295
+ { type: "filler" }
296
+ ]),
297
+ horizontalRow([
298
+ makeButton("←", actionData.left),
299
+ makeButton("OK", actionData.select, "primary"),
300
+ makeButton("→", actionData.right)
301
+ ], { margin: "md" }),
302
+ horizontalRow([
303
+ { type: "filler" },
304
+ makeButton("↓", actionData.down),
305
+ { type: "filler" }
306
+ ], { margin: "md" }),
307
+ horizontalRow([makeButton("Menu", actionData.menu), makeButton("Home", actionData.home)], { margin: "lg" }),
308
+ horizontalRow([makeButton("Play", actionData.play), makeButton("Pause", actionData.pause)], { margin: "md" }),
309
+ horizontalRow([
310
+ makeButton("Vol +", actionData.volumeUp),
311
+ makeButton("Mute", actionData.mute),
312
+ makeButton("Vol -", actionData.volumeDown)
313
+ ], { margin: "md" })
314
+ ];
315
+ return {
316
+ type: "bubble",
317
+ size: "mega",
318
+ body: {
319
+ type: "box",
320
+ layout: "vertical",
321
+ contents: [
322
+ {
323
+ type: "box",
324
+ layout: "vertical",
325
+ contents: headerContents
326
+ },
327
+ {
328
+ type: "separator",
329
+ margin: "lg",
330
+ color: "#EEEEEE"
331
+ },
332
+ ...controlRows
333
+ ],
334
+ paddingAll: "xl",
335
+ backgroundColor: "#FFFFFF"
336
+ }
337
+ };
338
+ }
339
+ /**
340
+ * Create a device control card for Apple TV, smart home devices, etc.
341
+ *
342
+ * Editorial design: Device-focused header with status indicator,
343
+ * clean control grid with clear visual hierarchy.
344
+ */
345
+ function createDeviceControlCard(params) {
346
+ const { deviceName, deviceType, status, isOnline, imageUrl, controls } = params;
347
+ const headerContents = [horizontalRow([{
348
+ type: "box",
349
+ layout: "vertical",
350
+ contents: [],
351
+ width: "10px",
352
+ height: "10px",
353
+ backgroundColor: isOnline !== false ? "#06C755" : "#FF5555",
354
+ cornerRadius: "5px"
355
+ }, {
356
+ type: "text",
357
+ text: deviceName,
358
+ weight: "bold",
359
+ size: "xl",
360
+ color: "#111111",
361
+ wrap: true,
362
+ flex: 1,
363
+ margin: "md"
364
+ }], { alignItems: "center" })];
365
+ if (deviceType) headerContents.push({
366
+ type: "text",
367
+ text: deviceType,
368
+ size: "sm",
369
+ color: "#888888",
370
+ margin: "sm"
371
+ });
372
+ if (status) headerContents.push({
373
+ type: "box",
374
+ layout: "vertical",
375
+ contents: [{
376
+ type: "text",
377
+ text: status,
378
+ size: "sm",
379
+ color: "#444444",
380
+ wrap: true
381
+ }],
382
+ margin: "lg",
383
+ paddingAll: "md",
384
+ backgroundColor: "#F8F9FA",
385
+ cornerRadius: "md"
386
+ });
387
+ const bubble = {
388
+ type: "bubble",
389
+ size: "mega",
390
+ body: {
391
+ type: "box",
392
+ layout: "vertical",
393
+ contents: headerContents,
394
+ paddingAll: "xl",
395
+ backgroundColor: "#FFFFFF"
396
+ }
397
+ };
398
+ if (imageUrl) bubble.hero = {
399
+ type: "image",
400
+ url: imageUrl,
401
+ size: "full",
402
+ aspectRatio: "16:9",
403
+ aspectMode: "cover"
404
+ };
405
+ if (controls.length > 0) {
406
+ const rows = [];
407
+ const limitedControls = controls.slice(0, 6);
408
+ for (let i = 0; i < limitedControls.length; i += 2) {
409
+ const rowButtons = [];
410
+ for (const [offset, ctrl] of limitedControls.slice(i, i + 2).entries()) {
411
+ const buttonLabel = ctrl.icon ? `${ctrl.icon} ${ctrl.label}` : ctrl.label;
412
+ rowButtons.push({
413
+ type: "button",
414
+ action: postbackAction(truncateLineActionLabel(buttonLabel, 18), ctrl.data),
415
+ style: ctrl.style ?? "secondary",
416
+ flex: 1,
417
+ height: "sm",
418
+ margin: offset > 0 ? "md" : void 0
419
+ });
420
+ }
421
+ if (rowButtons.length === 1) rowButtons.push({ type: "filler" });
422
+ rows.push(horizontalRow(rowButtons, { margin: i > 0 ? "md" : void 0 }));
423
+ }
424
+ bubble.footer = {
425
+ type: "box",
426
+ layout: "vertical",
427
+ contents: rows,
428
+ paddingAll: "lg",
429
+ backgroundColor: "#FAFAFA"
430
+ };
431
+ }
432
+ return bubble;
433
+ }
434
+ //#endregion
435
+ //#region extensions/line/src/rich-messages.ts
436
+ const nonempty = () => Type.String({ minLength: 1 });
437
+ const closed = (properties) => Type.Object(properties, { additionalProperties: false });
438
+ const lineCardSchema = Type.Union([
439
+ closed({
440
+ type: Type.Literal("media_player"),
441
+ title: nonempty(),
442
+ artist: Type.Optional(nonempty()),
443
+ source: Type.Optional(nonempty()),
444
+ imageUrl: Type.Optional(Type.String({ pattern: "^https://" })),
445
+ status: Type.Optional(Type.Union([Type.Literal("playing"), Type.Literal("paused")]))
446
+ }),
447
+ closed({
448
+ type: Type.Literal("event"),
449
+ title: nonempty(),
450
+ date: nonempty(),
451
+ time: Type.Optional(nonempty()),
452
+ location: Type.Optional(nonempty()),
453
+ description: Type.Optional(nonempty())
454
+ }),
455
+ closed({
456
+ type: Type.Literal("agenda"),
457
+ title: nonempty(),
458
+ events: Type.Array(closed({
459
+ title: nonempty(),
460
+ time: Type.Optional(nonempty()),
461
+ location: Type.Optional(nonempty())
462
+ }), {
463
+ minItems: 1,
464
+ maxItems: 6
465
+ })
466
+ }),
467
+ closed({
468
+ type: Type.Literal("device"),
469
+ name: nonempty(),
470
+ deviceType: Type.Optional(nonempty()),
471
+ status: Type.Optional(nonempty()),
472
+ controls: Type.Optional(Type.Array(closed({
473
+ label: nonempty(),
474
+ action: nonempty()
475
+ }), { maxItems: 6 }))
476
+ }),
477
+ closed({
478
+ type: Type.Literal("appletv_remote"),
479
+ name: Type.Optional(nonempty()),
480
+ status: Type.Optional(nonempty())
481
+ })
482
+ ]);
483
+ const lineChannelDataSchema = Type.Optional(closed({ line: closed({
484
+ location: Type.Optional(closed({
485
+ title: nonempty(),
486
+ address: nonempty(),
487
+ latitude: Type.Number({
488
+ minimum: -90,
489
+ maximum: 90
490
+ }),
491
+ longitude: Type.Number({
492
+ minimum: -180,
493
+ maximum: 180
494
+ })
495
+ })),
496
+ card: Type.Optional(lineCardSchema),
497
+ mediaKind: Type.Optional(Type.Union([
498
+ Type.Literal("image"),
499
+ Type.Literal("video"),
500
+ Type.Literal("audio")
501
+ ])),
502
+ previewImageUrl: Type.Optional(Type.String({ pattern: "^https://" })),
503
+ durationMs: Type.Optional(Type.Integer({ minimum: 1 })),
504
+ trackingId: Type.Optional(nonempty())
505
+ }) }));
506
+ const lineMessageActions = {
507
+ describeMessageTool: ({ cfg, accountId }) => {
508
+ const account = resolveLineAccount({
509
+ cfg,
510
+ accountId: accountId ?? void 0
511
+ });
512
+ return account.enabled && hasLineCredentials(account) ? {
513
+ actions: ["send"],
514
+ capabilities: ["presentation"],
515
+ schema: {
516
+ actions: ["send"],
517
+ properties: { channelData: lineChannelDataSchema }
518
+ }
519
+ } : {
520
+ actions: [],
521
+ capabilities: [],
522
+ schema: null
523
+ };
524
+ },
525
+ prepareSendPayload: ({ payload }) => payload
526
+ };
527
+ const LINE_QUICK_REPLY_LIMIT = 13;
528
+ const LINE_PRESENTATION_CAPABILITIES = {
529
+ supported: true,
530
+ buttons: true,
531
+ selects: true,
532
+ context: true,
533
+ limits: {
534
+ actions: {
535
+ maxActions: 4,
536
+ maxActionsPerRow: 1,
537
+ maxRows: 4,
538
+ maxLabelLength: 40
539
+ },
540
+ selects: {
541
+ maxOptions: LINE_QUICK_REPLY_LIMIT,
542
+ maxValueBytes: 300
543
+ },
544
+ text: { markdownDialect: "plain" }
545
+ }
546
+ };
547
+ function toLineAction(button) {
548
+ const normalized = resolveMessagePresentationButtonAction(button);
549
+ const { label } = button;
550
+ if (normalized?.type === "command") return {
551
+ type: "message",
552
+ label,
553
+ text: normalized.command
554
+ };
555
+ if (normalized?.type === "callback") return {
556
+ type: "postback",
557
+ label,
558
+ data: normalized.value,
559
+ displayText: label
560
+ };
561
+ if (normalized?.type === "url") return {
562
+ type: "uri",
563
+ label,
564
+ uri: normalized.url
565
+ };
566
+ if (normalized?.type === "web-app" && normalized.url) return {
567
+ type: "uri",
568
+ label,
569
+ uri: normalized.url
570
+ };
571
+ }
572
+ function renderLinePresentation(payload, presentation) {
573
+ const hasCard = presentation.blocks.some((block) => block.type === "buttons" && block.buttons.length > 0);
574
+ const buttons = [];
575
+ const quickReplyItems = [];
576
+ const carriedBlocks = [];
577
+ const cardBody = [];
578
+ for (const block of presentation.blocks) if (block.type === "buttons") for (const button of block.buttons) {
579
+ const action = toLineAction(button);
580
+ if (!action) return null;
581
+ buttons.push({
582
+ label: button.label,
583
+ action
584
+ });
585
+ }
586
+ else if (block.type === "select") {
587
+ const overflow = [];
588
+ for (const option of block.options) {
589
+ const action = resolveMessagePresentationOptionAction(option);
590
+ if (!action) return null;
591
+ if (quickReplyItems.length < LINE_QUICK_REPLY_LIMIT) quickReplyItems.push({
592
+ label: option.label,
593
+ action
594
+ });
595
+ else overflow.push(option);
596
+ }
597
+ if (overflow.length > 0) carriedBlocks.push({
598
+ ...block,
599
+ options: overflow
600
+ });
601
+ else if (block.placeholder) carriedBlocks.push({
602
+ type: "context",
603
+ text: block.placeholder
604
+ });
605
+ } else if (!hasCard) carriedBlocks.push(block);
606
+ else if (block.type === "text" || block.type === "context") cardBody.push(block.text);
607
+ if (buttons.length === 0 && quickReplyItems.length === 0) return null;
608
+ const lineData = isRecord(payload.channelData?.line) ? payload.channelData.line : {};
609
+ const title = presentation.title || "Choose an option";
610
+ const flexMessage = hasCard ? {
611
+ altText: title,
612
+ contents: createActionCard(title, cardBody.join("\n") || "Choose an option.", buttons)
613
+ } : void 0;
614
+ if (flexMessage && !fitsLineFlexBubble(flexMessage.contents)) return null;
615
+ const text = renderMessagePresentationFallbackText({
616
+ text: payload.text,
617
+ presentation: {
618
+ title: hasCard ? void 0 : presentation.title,
619
+ blocks: carriedBlocks
620
+ }
621
+ });
622
+ return {
623
+ ...payload,
624
+ ...text ? { text } : {},
625
+ channelData: {
626
+ ...payload.channelData,
627
+ line: {
628
+ ...lineData,
629
+ ...flexMessage ? { flexMessage } : {},
630
+ quickReplyItems
631
+ }
632
+ }
633
+ };
634
+ }
635
+ /**
636
+ * Resolve a reply's portable presentation into LINE-native controls.
637
+ *
638
+ * Core runs the presentation renderer inside the outbound send pipeline only, so
639
+ * replies the plugin delivers itself reach delivery with the controls still
640
+ * portable. Preparing them here keeps both LINE delivery paths on one rendering.
641
+ */
642
+ function prepareLineReplyPayload(payload) {
643
+ const presentation = normalizeMessagePresentation(payload.presentation);
644
+ if (!presentation) return payload;
645
+ const { presentation: _presentation, presentationTextMode, ...rest } = payload;
646
+ const usesFallbackText = presentationTextMode === "fallback" && Boolean(rest.text?.trim());
647
+ const rendered = renderLinePresentation(usesFallbackText ? {
648
+ ...rest,
649
+ text: void 0
650
+ } : rest, adaptMessagePresentationForChannel({
651
+ presentation,
652
+ capabilities: LINE_PRESENTATION_CAPABILITIES
653
+ }));
654
+ if (rendered) {
655
+ const renderedLine = isRecord(rendered.channelData?.line) ? rendered.channelData.line : {};
656
+ return usesFallbackText && renderedLine.flexMessage === void 0 ? {
657
+ ...rendered,
658
+ text: rest.text
659
+ } : rendered;
660
+ }
661
+ return {
662
+ ...rest,
663
+ text: usesFallbackText ? rest.text ?? renderMessagePresentationFallbackText({ presentation }) : renderMessagePresentationFallbackText({
664
+ text: rest.text,
665
+ presentation
666
+ })
667
+ };
668
+ }
669
+ const toSlug = (value) => normalizeLowercaseStringOrEmpty(value).replace(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, "") || "device";
670
+ const lineActionData = (action, device) => `line.action=${encodeURIComponent(action)}&line.device=${encodeURIComponent(device)}`;
671
+ function renderLineCard(card) {
672
+ if (card.type === "media_player") {
673
+ const device = toSlug(card.source || card.title);
674
+ return {
675
+ altText: `🎵 ${card.title}${card.artist ? ` - ${card.artist}` : ""}`,
676
+ contents: createMediaPlayerCard({
677
+ title: card.title,
678
+ subtitle: card.artist,
679
+ source: card.source,
680
+ imageUrl: card.imageUrl,
681
+ isPlaying: card.status ? card.status === "playing" : void 0,
682
+ controls: Object.fromEntries([
683
+ "previous",
684
+ "play",
685
+ "pause",
686
+ "next"
687
+ ].map((action) => [action, { data: lineActionData(action, device) }]))
688
+ })
689
+ };
690
+ }
691
+ if (card.type === "event") return {
692
+ altText: `📅 ${card.title} - ${card.date}${card.time ? ` ${card.time}` : ""}`,
693
+ contents: createEventCard(card)
694
+ };
695
+ if (card.type === "agenda") return {
696
+ altText: `📋 ${card.title} (${card.events.length} events)`,
697
+ contents: createAgendaCard(card)
698
+ };
699
+ const device = toSlug(card.type === "device" ? card.name : card.name || "apple_tv");
700
+ if (card.type === "device") return {
701
+ altText: `📱 ${card.name}${card.status ? `: ${card.status}` : ""}`,
702
+ contents: createDeviceControlCard({
703
+ deviceName: card.name,
704
+ deviceType: card.deviceType,
705
+ status: card.status,
706
+ controls: (card.controls ?? []).map((control) => ({
707
+ label: control.label,
708
+ data: lineActionData(control.action, device)
709
+ }))
710
+ })
711
+ };
712
+ const actionData = {
713
+ up: lineActionData("up", device),
714
+ down: lineActionData("down", device),
715
+ left: lineActionData("left", device),
716
+ right: lineActionData("right", device),
717
+ select: lineActionData("select", device),
718
+ menu: lineActionData("menu", device),
719
+ home: lineActionData("home", device),
720
+ play: lineActionData("play", device),
721
+ pause: lineActionData("pause", device),
722
+ volumeUp: lineActionData("volume_up", device),
723
+ volumeDown: lineActionData("volume_down", device),
724
+ mute: lineActionData("mute", device)
725
+ };
726
+ return {
727
+ altText: `📺 ${card.name || "Apple TV"} Remote`,
728
+ contents: createAppleTvRemoteCard({
729
+ deviceName: card.name || "Apple TV",
730
+ status: card.status,
731
+ actionData
732
+ })
733
+ };
734
+ }
735
+ function createLineQuickReply(items) {
736
+ return { items: items.slice(0, LINE_QUICK_REPLY_LIMIT).map((item) => ({
737
+ type: "action",
738
+ action: item.action.type === "command" ? messageAction(item.label, item.action.command) : postbackAction(item.label, item.action.value, item.label)
739
+ })) };
740
+ }
741
+ //#endregion
742
+ export { LineChannelConfigSchema as _, renderLineCard as a, createDeviceControlCard as c, resolveExactLineGroupConfigKey as d, resolveLineGroupConfigEntry as f, setLineRuntime as g, getLineRuntime as h, prepareLineReplyPayload as i, createMediaPlayerCard as l, resolveLineGroupsConfig as m, createLineQuickReply as n, renderLinePresentation as o, resolveLineGroupLookupIds as p, lineMessageActions as r, createAppleTvRemoteCard as s, LINE_PRESENTATION_CAPABILITIES as t, buildLineQuickReplyFallbackText as u, LineConfigSchema as v };