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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. package/dist/accounts-UXAvdBo_.js +105 -0
  2. package/dist/api.js +11 -0
  3. package/dist/basic-cards-7DTG6E-A.js +307 -0
  4. package/dist/card-command-UlPc6Vuc.js +240 -0
  5. package/dist/channel-Rls9s60K.js +601 -0
  6. package/dist/channel-plugin-api.js +2 -0
  7. package/dist/channel.runtime-bXoj8_Sl.js +4 -0
  8. package/dist/contract-api.js +2 -0
  9. package/dist/index.js +45 -0
  10. package/dist/markdown-to-line-CCWK6PJh.js +789 -0
  11. package/dist/monitor-B4_RxHc0.js +1523 -0
  12. package/dist/monitor.runtime-DyxYlrM9.js +2 -0
  13. package/dist/outbound-media-BfhBmWq5.js +55 -0
  14. package/dist/outbound.runtime-B-luYwEB.js +2 -0
  15. package/dist/probe-D9BPzb2n.js +30 -0
  16. package/dist/probe.runtime-N91OWW1J.js +2 -0
  17. package/dist/quick-reply-fallback-HskUUWsn.js +55 -0
  18. package/dist/reply-payload-transform-CFGTs9ln.js +713 -0
  19. package/dist/runtime-api.js +277 -0
  20. package/dist/schedule-cards-BwQChTdM.js +359 -0
  21. package/dist/secret-contract-api.js +5 -0
  22. package/dist/setup-api.js +2 -0
  23. package/dist/setup-entry.js +11 -0
  24. package/dist/setup-surface-DCH7CE-y.js +281 -0
  25. package/package.json +14 -6
  26. package/api.ts +0 -11
  27. package/channel-plugin-api.ts +0 -1
  28. package/contract-api.ts +0 -5
  29. package/index.ts +0 -54
  30. package/runtime-api.ts +0 -187
  31. package/secret-contract-api.ts +0 -4
  32. package/setup-api.ts +0 -2
  33. package/setup-entry.ts +0 -9
  34. package/src/account-helpers.ts +0 -16
  35. package/src/accounts.test.ts +0 -290
  36. package/src/accounts.ts +0 -187
  37. package/src/actions.ts +0 -61
  38. package/src/auto-reply-delivery.test.ts +0 -248
  39. package/src/auto-reply-delivery.ts +0 -200
  40. package/src/bindings.ts +0 -65
  41. package/src/bot-access.ts +0 -48
  42. package/src/bot-handlers.test.ts +0 -1089
  43. package/src/bot-handlers.ts +0 -642
  44. package/src/bot-message-context.test.ts +0 -405
  45. package/src/bot-message-context.ts +0 -581
  46. package/src/bot.ts +0 -70
  47. package/src/card-command.ts +0 -347
  48. package/src/channel-access-token.ts +0 -14
  49. package/src/channel-api.ts +0 -17
  50. package/src/channel-setup-status.contract.test.ts +0 -70
  51. package/src/channel-shared.ts +0 -48
  52. package/src/channel.logout.test.ts +0 -145
  53. package/src/channel.runtime.ts +0 -3
  54. package/src/channel.sendPayload.test.ts +0 -514
  55. package/src/channel.setup.ts +0 -11
  56. package/src/channel.status.test.ts +0 -63
  57. package/src/channel.ts +0 -154
  58. package/src/config-adapter.ts +0 -29
  59. package/src/config-schema.ts +0 -57
  60. package/src/download.test.ts +0 -133
  61. package/src/download.ts +0 -87
  62. package/src/flex-templates/basic-cards.ts +0 -395
  63. package/src/flex-templates/common.ts +0 -20
  64. package/src/flex-templates/media-control-cards.ts +0 -555
  65. package/src/flex-templates/message.ts +0 -13
  66. package/src/flex-templates/schedule-cards.ts +0 -467
  67. package/src/flex-templates/types.ts +0 -22
  68. package/src/flex-templates.ts +0 -32
  69. package/src/gateway.ts +0 -129
  70. package/src/group-keys.test.ts +0 -123
  71. package/src/group-keys.ts +0 -65
  72. package/src/group-policy.ts +0 -22
  73. package/src/markdown-to-line.test.ts +0 -348
  74. package/src/markdown-to-line.ts +0 -416
  75. package/src/message-cards.test.ts +0 -204
  76. package/src/monitor.lifecycle.test.ts +0 -421
  77. package/src/monitor.runtime.ts +0 -1
  78. package/src/monitor.ts +0 -506
  79. package/src/outbound-media.test.ts +0 -189
  80. package/src/outbound-media.ts +0 -120
  81. package/src/outbound.runtime.ts +0 -12
  82. package/src/outbound.ts +0 -356
  83. package/src/probe.contract.test.ts +0 -9
  84. package/src/probe.runtime.ts +0 -1
  85. package/src/probe.ts +0 -34
  86. package/src/quick-reply-fallback.ts +0 -10
  87. package/src/reply-chunks.test.ts +0 -179
  88. package/src/reply-chunks.ts +0 -110
  89. package/src/reply-payload-transform.test.ts +0 -387
  90. package/src/reply-payload-transform.ts +0 -317
  91. package/src/rich-menu.test.ts +0 -310
  92. package/src/rich-menu.ts +0 -326
  93. package/src/runtime.ts +0 -32
  94. package/src/send.test.ts +0 -346
  95. package/src/send.ts +0 -489
  96. package/src/setup-core.ts +0 -149
  97. package/src/setup-runtime-api.ts +0 -9
  98. package/src/setup-surface.test.ts +0 -474
  99. package/src/setup-surface.ts +0 -227
  100. package/src/signature.test.ts +0 -34
  101. package/src/signature.ts +0 -24
  102. package/src/status.ts +0 -37
  103. package/src/template-messages.ts +0 -333
  104. package/src/types.ts +0 -128
  105. package/src/webhook-node.test.ts +0 -513
  106. package/src/webhook-node.ts +0 -131
  107. package/src/webhook-utils.ts +0 -10
  108. package/src/webhook.ts +0 -111
  109. package/tsconfig.json +0 -16
@@ -1,405 +0,0 @@
1
- import fs from "node:fs/promises";
2
- import os from "node:os";
3
- import path from "node:path";
4
- import type { webhook } from "@line/bot-sdk";
5
- import type { OpenClawConfig } from "openclaw/plugin-sdk/config-types";
6
- import { getSessionBindingService } from "openclaw/plugin-sdk/conversation-runtime";
7
- import { __testing as sessionBindingTesting } from "openclaw/plugin-sdk/conversation-runtime";
8
- import {
9
- createTestRegistry,
10
- setActivePluginRegistry,
11
- } from "openclaw/plugin-sdk/plugin-test-runtime";
12
- import { afterEach, beforeEach, describe, expect, it } from "vitest";
13
- import { lineBindingsAdapter } from "./bindings.js";
14
- import { buildLineMessageContext, buildLinePostbackContext } from "./bot-message-context.js";
15
- import type { ResolvedLineAccount } from "./types.js";
16
-
17
- type MessageEvent = webhook.MessageEvent;
18
- type PostbackEvent = webhook.PostbackEvent;
19
-
20
- const lineBindingsPlugin = {
21
- id: "line",
22
- bindings: lineBindingsAdapter,
23
- conversationBindings: {
24
- defaultTopLevelPlacement: "current",
25
- supportsCurrentConversationBinding: true,
26
- },
27
- };
28
-
29
- describe("buildLineMessageContext", () => {
30
- let tmpDir: string;
31
- let storePath: string;
32
- let cfg: OpenClawConfig;
33
- const account: ResolvedLineAccount = {
34
- accountId: "default",
35
- enabled: true,
36
- channelAccessToken: "token",
37
- channelSecret: "secret",
38
- tokenSource: "config",
39
- config: {},
40
- };
41
-
42
- const createMessageEvent = (
43
- source: MessageEvent["source"],
44
- overrides?: Partial<MessageEvent>,
45
- ): MessageEvent =>
46
- ({
47
- type: "message",
48
- message: { id: "1", type: "text", text: "hello" },
49
- replyToken: "reply-token",
50
- timestamp: Date.now(),
51
- source,
52
- mode: "active",
53
- webhookEventId: "evt-1",
54
- deliveryContext: { isRedelivery: false },
55
- ...overrides,
56
- }) as MessageEvent;
57
-
58
- const createPostbackEvent = (
59
- source: PostbackEvent["source"],
60
- overrides?: Partial<PostbackEvent>,
61
- ): PostbackEvent =>
62
- ({
63
- type: "postback",
64
- postback: { data: "action=select" },
65
- replyToken: "reply-token",
66
- timestamp: Date.now(),
67
- source,
68
- mode: "active",
69
- webhookEventId: "evt-2",
70
- deliveryContext: { isRedelivery: false },
71
- ...overrides,
72
- }) as PostbackEvent;
73
-
74
- beforeEach(async () => {
75
- setActivePluginRegistry(
76
- createTestRegistry([
77
- {
78
- pluginId: lineBindingsPlugin.id,
79
- plugin: lineBindingsPlugin,
80
- source: "test",
81
- },
82
- ]),
83
- );
84
- sessionBindingTesting.resetSessionBindingAdaptersForTests();
85
- tmpDir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-line-context-"));
86
- storePath = path.join(tmpDir, "sessions.json");
87
- cfg = { session: { store: storePath } };
88
- });
89
-
90
- afterEach(async () => {
91
- sessionBindingTesting.resetSessionBindingAdaptersForTests();
92
- await fs.rm(tmpDir, {
93
- recursive: true,
94
- force: true,
95
- maxRetries: 3,
96
- retryDelay: 50,
97
- });
98
- });
99
-
100
- it("routes group message replies to the group id", async () => {
101
- const event = createMessageEvent({ type: "group", groupId: "group-1", userId: "user-1" });
102
-
103
- const context = await buildLineMessageContext({
104
- event,
105
- allMedia: [],
106
- cfg,
107
- account,
108
- commandAuthorized: true,
109
- });
110
- expect(context).not.toBeNull();
111
- if (!context) {
112
- throw new Error("context missing");
113
- }
114
-
115
- expect(context.ctxPayload.OriginatingTo).toBe("line:group:group-1");
116
- expect(context.ctxPayload.To).toBe("line:group:group-1");
117
- });
118
-
119
- it("routes group postback replies to the group id", async () => {
120
- const event = createPostbackEvent({ type: "group", groupId: "group-2", userId: "user-2" });
121
-
122
- const context = await buildLinePostbackContext({
123
- event,
124
- cfg,
125
- account,
126
- commandAuthorized: true,
127
- });
128
-
129
- expect(context?.ctxPayload.OriginatingTo).toBe("line:group:group-2");
130
- expect(context?.ctxPayload.To).toBe("line:group:group-2");
131
- });
132
-
133
- it("routes room postback replies to the room id", async () => {
134
- const event = createPostbackEvent({ type: "room", roomId: "room-1", userId: "user-3" });
135
-
136
- const context = await buildLinePostbackContext({
137
- event,
138
- cfg,
139
- account,
140
- commandAuthorized: true,
141
- });
142
-
143
- expect(context?.ctxPayload.OriginatingTo).toBe("line:room:room-1");
144
- expect(context?.ctxPayload.To).toBe("line:room:room-1");
145
- });
146
-
147
- it("resolves prefixed-only group config through the inbound message context", async () => {
148
- const event = createMessageEvent({ type: "group", groupId: "group-1", userId: "user-1" });
149
-
150
- const context = await buildLineMessageContext({
151
- event,
152
- allMedia: [],
153
- cfg,
154
- account: {
155
- ...account,
156
- config: {
157
- groups: {
158
- "group:group-1": {
159
- systemPrompt: "Use the prefixed group config",
160
- },
161
- },
162
- },
163
- },
164
- commandAuthorized: true,
165
- });
166
-
167
- expect(context?.ctxPayload.GroupSystemPrompt).toBe("Use the prefixed group config");
168
- });
169
-
170
- it("resolves prefixed-only room config through the inbound message context", async () => {
171
- const event = createMessageEvent({ type: "room", roomId: "room-1", userId: "user-1" });
172
-
173
- const context = await buildLineMessageContext({
174
- event,
175
- allMedia: [],
176
- cfg,
177
- account: {
178
- ...account,
179
- config: {
180
- groups: {
181
- "room:room-1": {
182
- systemPrompt: "Use the prefixed room config",
183
- },
184
- },
185
- },
186
- },
187
- commandAuthorized: true,
188
- });
189
-
190
- expect(context?.ctxPayload.GroupSystemPrompt).toBe("Use the prefixed room config");
191
- });
192
-
193
- it("keeps non-text message contexts fail-closed for command auth", async () => {
194
- const event = createMessageEvent(
195
- { type: "user", userId: "user-audio" },
196
- {
197
- message: { id: "audio-1", type: "audio", duration: 1000 } as MessageEvent["message"],
198
- },
199
- );
200
-
201
- const context = await buildLineMessageContext({
202
- event,
203
- allMedia: [],
204
- cfg,
205
- account,
206
- commandAuthorized: false,
207
- });
208
-
209
- expect(context).not.toBeNull();
210
- expect(context?.ctxPayload.CommandAuthorized).toBe(false);
211
- });
212
-
213
- it("sets CommandAuthorized=true when authorized", async () => {
214
- const event = createMessageEvent({ type: "user", userId: "user-auth" });
215
-
216
- const context = await buildLineMessageContext({
217
- event,
218
- allMedia: [],
219
- cfg,
220
- account,
221
- commandAuthorized: true,
222
- });
223
-
224
- expect(context?.ctxPayload.CommandAuthorized).toBe(true);
225
- });
226
-
227
- it("sets CommandAuthorized=false when not authorized", async () => {
228
- const event = createMessageEvent({ type: "user", userId: "user-noauth" });
229
-
230
- const context = await buildLineMessageContext({
231
- event,
232
- allMedia: [],
233
- cfg,
234
- account,
235
- commandAuthorized: false,
236
- });
237
-
238
- expect(context?.ctxPayload.CommandAuthorized).toBe(false);
239
- });
240
-
241
- it("sets CommandAuthorized on postback context", async () => {
242
- const event = createPostbackEvent({ type: "user", userId: "user-pb" });
243
-
244
- const context = await buildLinePostbackContext({
245
- event,
246
- cfg,
247
- account,
248
- commandAuthorized: true,
249
- });
250
-
251
- expect(context?.ctxPayload.CommandAuthorized).toBe(true);
252
- });
253
-
254
- it("group peer binding matches raw groupId without prefix (#21907)", async () => {
255
- const groupId = "Cc7e3bece1234567890abcdef"; // pragma: allowlist secret
256
- const bindingCfg: OpenClawConfig = {
257
- session: { store: storePath },
258
- agents: {
259
- list: [{ id: "main" }, { id: "line-group-agent" }],
260
- },
261
- bindings: [
262
- {
263
- agentId: "line-group-agent",
264
- match: { channel: "line", peer: { kind: "group", id: groupId } },
265
- },
266
- ],
267
- };
268
-
269
- const event = {
270
- type: "message",
271
- message: { id: "msg-1", type: "text", text: "hello" },
272
- replyToken: "reply-token",
273
- timestamp: Date.now(),
274
- source: { type: "group", groupId, userId: "user-1" },
275
- mode: "active",
276
- webhookEventId: "evt-1",
277
- deliveryContext: { isRedelivery: false },
278
- } as MessageEvent;
279
-
280
- const context = await buildLineMessageContext({
281
- event,
282
- allMedia: [],
283
- cfg: bindingCfg,
284
- account,
285
- commandAuthorized: true,
286
- });
287
- expect(context).not.toBeNull();
288
- expect(context!.route.agentId).toBe("line-group-agent");
289
- expect(context!.route.matchedBy).toBe("binding.peer");
290
- });
291
-
292
- it("room peer binding matches raw roomId without prefix (#21907)", async () => {
293
- const roomId = "Rr1234567890abcdef";
294
- const bindingCfg: OpenClawConfig = {
295
- session: { store: storePath },
296
- agents: {
297
- list: [{ id: "main" }, { id: "line-room-agent" }],
298
- },
299
- bindings: [
300
- {
301
- agentId: "line-room-agent",
302
- match: { channel: "line", peer: { kind: "group", id: roomId } },
303
- },
304
- ],
305
- };
306
-
307
- const event = {
308
- type: "message",
309
- message: { id: "msg-2", type: "text", text: "hello" },
310
- replyToken: "reply-token",
311
- timestamp: Date.now(),
312
- source: { type: "room", roomId, userId: "user-2" },
313
- mode: "active",
314
- webhookEventId: "evt-2",
315
- deliveryContext: { isRedelivery: false },
316
- } as MessageEvent;
317
-
318
- const context = await buildLineMessageContext({
319
- event,
320
- allMedia: [],
321
- cfg: bindingCfg,
322
- account,
323
- commandAuthorized: true,
324
- });
325
- expect(context).not.toBeNull();
326
- expect(context!.route.agentId).toBe("line-room-agent");
327
- expect(context!.route.matchedBy).toBe("binding.peer");
328
- });
329
-
330
- it("normalizes LINE ACP binding conversation ids through the plugin bindings surface", async () => {
331
- const compiled = lineBindingsAdapter.compileConfiguredBinding({
332
- conversationId: "line:user:U1234567890abcdef1234567890abcdef",
333
- });
334
-
335
- expect(compiled).toEqual({
336
- conversationId: "U1234567890abcdef1234567890abcdef",
337
- });
338
- expect(
339
- lineBindingsAdapter.matchInboundConversation({
340
- compiledBinding: compiled!,
341
- conversationId: "U1234567890abcdef1234567890abcdef",
342
- }),
343
- ).toEqual({
344
- conversationId: "U1234567890abcdef1234567890abcdef",
345
- matchPriority: 2,
346
- });
347
- });
348
-
349
- it("normalizes canonical LINE targets through the plugin bindings surface", async () => {
350
- const compiled = lineBindingsAdapter.compileConfiguredBinding({
351
- conversationId: "line:U1234567890abcdef1234567890abcdef",
352
- });
353
-
354
- expect(compiled).toEqual({
355
- conversationId: "U1234567890abcdef1234567890abcdef",
356
- });
357
- expect(
358
- lineBindingsAdapter.resolveCommandConversation({
359
- originatingTo: "line:U1234567890abcdef1234567890abcdef",
360
- }),
361
- ).toEqual({
362
- conversationId: "U1234567890abcdef1234567890abcdef",
363
- });
364
- expect(
365
- lineBindingsAdapter.matchInboundConversation({
366
- compiledBinding: compiled!,
367
- conversationId: "U1234567890abcdef1234567890abcdef",
368
- }),
369
- ).toEqual({
370
- conversationId: "U1234567890abcdef1234567890abcdef",
371
- matchPriority: 2,
372
- });
373
- });
374
-
375
- it("routes LINE conversations through active ACP session bindings", async () => {
376
- const userId = "U1234567890abcdef1234567890abcdef";
377
- await getSessionBindingService().bind({
378
- targetSessionKey: "agent:codex:acp:binding:line:default:test123",
379
- targetKind: "session",
380
- conversation: {
381
- channel: "line",
382
- accountId: "default",
383
- conversationId: userId,
384
- },
385
- placement: "current",
386
- metadata: {
387
- agentId: "codex",
388
- },
389
- });
390
-
391
- const event = createMessageEvent({ type: "user", userId });
392
- const context = await buildLineMessageContext({
393
- event,
394
- allMedia: [],
395
- cfg,
396
- account,
397
- commandAuthorized: true,
398
- });
399
-
400
- expect(context).not.toBeNull();
401
- expect(context!.route.agentId).toBe("codex");
402
- expect(context!.route.sessionKey).toBe("agent:codex:acp:binding:line:default:test123");
403
- expect(context!.route.matchedBy).toBe("binding.channel");
404
- });
405
- });