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