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