@openclaw/line 2026.7.2-beta.7 → 2026.7.34
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.
- package/README.md +1 -1
- package/dist/.setup/accounts-DJVOv1JI.mjs +107 -0
- package/dist/.setup/api-D3h9w6oz.mjs +3 -0
- package/dist/.setup/api-DdlGHKoX.mjs +11 -0
- package/dist/.setup/basic-cards-C8Qwh2X1.mjs +307 -0
- package/dist/{card-command-ty11OJNt.js → .setup/card-command-CWrkUiGY.mjs} +51 -23
- package/dist/{channel-D4i_K4fQ.js → .setup/channel-Du0PrvOH.mjs} +76 -66
- package/dist/.setup/channel.runtime-b3suPB-W.mjs +4 -0
- package/dist/.setup/flex-templates-BP6VHjzK.mjs +814 -0
- package/dist/{markdown-to-line-DMDQTMhx.js → .setup/markdown-to-line-o89GT1Qn.mjs} +252 -254
- package/dist/{monitor-DXEodYFJ.js → .setup/monitor-DpxjN6Ks.mjs} +491 -658
- package/dist/.setup/monitor.runtime-BS-cGD5Q.mjs +2 -0
- package/dist/.setup/outbound.runtime-BeNDuEIF.mjs +2 -0
- package/dist/{probe-CM03wo6r.js → .setup/probe-BslD77tJ.mjs} +9 -7
- package/dist/.setup/probe.runtime-YwWmWIlk.mjs +2 -0
- package/dist/{reply-payload-transform-D5-dHB8b.js → .setup/reply-payload-transform-CYQIy_x8.mjs} +204 -80
- package/dist/{setup-surface-DRQ7n0En.js → .setup/setup-surface-M1ivmZ-G.mjs} +143 -158
- package/dist/api.js +2 -11
- package/dist/channel-plugin-api.js +1 -1
- package/dist/contract-api.js +1 -1
- package/dist/index.js +1 -1
- package/dist/runtime-api.js +56 -15
- package/dist/setup-api.js +1 -1
- package/dist/setup-entry.js +2 -1
- package/node_modules/@line/bot-sdk/dist/cjs/manage-audience/model/audienceGroupCreateRoute.d.ts.map +1 -1
- package/node_modules/@line/bot-sdk/dist/cjs/manage-audience/model/audienceGroupFailedType.d.ts.map +1 -1
- package/node_modules/@line/bot-sdk/dist/cjs/manage-audience/model/audienceGroupJobFailedType.d.ts.map +1 -1
- package/node_modules/@line/bot-sdk/dist/cjs/manage-audience/model/audienceGroupJobStatus.d.ts.map +1 -1
- package/node_modules/@line/bot-sdk/dist/cjs/manage-audience/model/audienceGroupStatus.d.ts.map +1 -1
- package/node_modules/@line/bot-sdk/dist/cjs/messaging-api/model/flexBoxBorderWidth.d.ts.map +1 -1
- package/node_modules/@line/bot-sdk/dist/cjs/messaging-api/model/flexBoxCornerRadius.d.ts.map +1 -1
- package/node_modules/@line/bot-sdk/dist/cjs/messaging-api/model/flexBubble.d.ts.map +1 -1
- package/node_modules/@line/bot-sdk/dist/cjs/messaging-api/model/flexIconSize.d.ts.map +1 -1
- package/node_modules/@line/bot-sdk/dist/cjs/messaging-api/model/flexSpanSize.d.ts.map +1 -1
- package/node_modules/@line/bot-sdk/dist/cjs/messaging-api/model/flexTextFontSize.d.ts.map +1 -1
- package/node_modules/@line/bot-sdk/dist/cjs/messaging-api/model/numberOfMessagesResponse.d.ts.map +1 -1
- package/node_modules/@line/bot-sdk/dist/cjs/messaging-api/model/postbackAction.d.ts.map +1 -1
- package/node_modules/@line/bot-sdk/dist/cjs/messaging-api/model/subscriptionPeriodDemographic.d.ts.map +1 -1
- package/node_modules/@line/bot-sdk/dist/cjs/version.d.ts +1 -1
- package/node_modules/@line/bot-sdk/dist/cjs/version.js +1 -1
- package/node_modules/@line/bot-sdk/dist/cjs/webhook/model/event.d.ts +1 -2
- package/node_modules/@line/bot-sdk/dist/cjs/webhook/model/event.d.ts.map +1 -1
- package/node_modules/@line/bot-sdk/dist/cjs/webhook/model/models.d.ts +0 -1
- package/node_modules/@line/bot-sdk/dist/cjs/webhook/model/models.d.ts.map +1 -1
- package/node_modules/@line/bot-sdk/dist/cjs/webhook/model/models.js +0 -1
- package/node_modules/@line/bot-sdk/dist/cjs/webhook/model/models.js.map +1 -1
- package/node_modules/@line/bot-sdk/dist/manage-audience/model/audienceGroupCreateRoute.d.ts.map +1 -1
- package/node_modules/@line/bot-sdk/dist/manage-audience/model/audienceGroupFailedType.d.ts.map +1 -1
- package/node_modules/@line/bot-sdk/dist/manage-audience/model/audienceGroupJobFailedType.d.ts.map +1 -1
- package/node_modules/@line/bot-sdk/dist/manage-audience/model/audienceGroupJobStatus.d.ts.map +1 -1
- package/node_modules/@line/bot-sdk/dist/manage-audience/model/audienceGroupStatus.d.ts.map +1 -1
- package/node_modules/@line/bot-sdk/dist/messaging-api/model/flexBoxBorderWidth.d.ts.map +1 -1
- package/node_modules/@line/bot-sdk/dist/messaging-api/model/flexBoxCornerRadius.d.ts.map +1 -1
- package/node_modules/@line/bot-sdk/dist/messaging-api/model/flexBubble.d.ts.map +1 -1
- package/node_modules/@line/bot-sdk/dist/messaging-api/model/flexIconSize.d.ts.map +1 -1
- package/node_modules/@line/bot-sdk/dist/messaging-api/model/flexSpanSize.d.ts.map +1 -1
- package/node_modules/@line/bot-sdk/dist/messaging-api/model/flexTextFontSize.d.ts.map +1 -1
- package/node_modules/@line/bot-sdk/dist/messaging-api/model/numberOfMessagesResponse.d.ts.map +1 -1
- package/node_modules/@line/bot-sdk/dist/messaging-api/model/postbackAction.d.ts.map +1 -1
- package/node_modules/@line/bot-sdk/dist/messaging-api/model/subscriptionPeriodDemographic.d.ts.map +1 -1
- package/node_modules/@line/bot-sdk/dist/version.d.ts +1 -1
- package/node_modules/@line/bot-sdk/dist/version.js +1 -1
- package/node_modules/@line/bot-sdk/dist/webhook/model/event.d.ts +1 -2
- package/node_modules/@line/bot-sdk/dist/webhook/model/event.d.ts.map +1 -1
- package/node_modules/@line/bot-sdk/dist/webhook/model/models.d.ts +0 -1
- package/node_modules/@line/bot-sdk/dist/webhook/model/models.d.ts.map +1 -1
- package/node_modules/@line/bot-sdk/dist/webhook/model/models.js +0 -1
- package/node_modules/@line/bot-sdk/dist/webhook/model/models.js.map +1 -1
- package/node_modules/@line/bot-sdk/lib/insight/model/getNumberOfFollowersResponse.ts +1 -1
- package/node_modules/@line/bot-sdk/lib/liff/model/liffScope.ts +1 -1
- package/node_modules/@line/bot-sdk/lib/manage-audience/model/audienceGroupCreateRoute.ts +4 -1
- package/node_modules/@line/bot-sdk/lib/manage-audience/model/audienceGroupFailedType.ts +2 -1
- package/node_modules/@line/bot-sdk/lib/manage-audience/model/audienceGroupJobFailedType.ts +2 -1
- package/node_modules/@line/bot-sdk/lib/manage-audience/model/audienceGroupJobStatus.ts +4 -1
- package/node_modules/@line/bot-sdk/lib/manage-audience/model/audienceGroupStatus.ts +6 -1
- package/node_modules/@line/bot-sdk/lib/messaging-api/model/botInfoResponse.ts +1 -1
- package/node_modules/@line/bot-sdk/lib/messaging-api/model/flexBoxBorderWidth.ts +6 -1
- package/node_modules/@line/bot-sdk/lib/messaging-api/model/flexBoxCornerRadius.ts +7 -1
- package/node_modules/@line/bot-sdk/lib/messaging-api/model/flexBubble.ts +7 -1
- package/node_modules/@line/bot-sdk/lib/messaging-api/model/flexIconSize.ts +10 -1
- package/node_modules/@line/bot-sdk/lib/messaging-api/model/flexSpanSize.ts +10 -1
- package/node_modules/@line/bot-sdk/lib/messaging-api/model/flexTextFontSize.ts +10 -1
- package/node_modules/@line/bot-sdk/lib/messaging-api/model/getAggregationUnitNameListResponse.ts +1 -1
- package/node_modules/@line/bot-sdk/lib/messaging-api/model/getFollowersResponse.ts +1 -1
- package/node_modules/@line/bot-sdk/lib/messaging-api/model/getJoinedMembershipUsersResponse.ts +1 -1
- package/node_modules/@line/bot-sdk/lib/messaging-api/model/issueLinkTokenResponse.ts +1 -1
- package/node_modules/@line/bot-sdk/lib/messaging-api/model/numberOfMessagesResponse.ts +5 -2
- package/node_modules/@line/bot-sdk/lib/messaging-api/model/postbackAction.ts +4 -1
- package/node_modules/@line/bot-sdk/lib/messaging-api/model/subscriptionPeriodDemographic.ts +5 -1
- package/node_modules/@line/bot-sdk/lib/version.ts +1 -1
- package/node_modules/@line/bot-sdk/lib/webhook/.openapi-generator/FILES +0 -1
- package/node_modules/@line/bot-sdk/lib/webhook/model/event.ts +0 -2
- package/node_modules/@line/bot-sdk/lib/webhook/model/models.ts +0 -1
- package/node_modules/@line/bot-sdk/lib/webhook/model/stickerMessageContent.ts +1 -1
- package/node_modules/@line/bot-sdk/node_modules/@types/node/README.md +1 -1
- package/node_modules/@line/bot-sdk/node_modules/@types/node/fs/promises.d.ts +5 -16
- package/node_modules/@line/bot-sdk/node_modules/@types/node/package.json +3 -3
- package/node_modules/@line/bot-sdk/package.json +3 -3
- package/openclaw.plugin.json +75 -57
- package/package.json +6 -71
- package/dist/accounts-BqEVsDoB.js +0 -103
- package/dist/channel.runtime-BdhK8Xw7.js +0 -4
- package/dist/flex-templates-iKJsyCq-.js +0 -1339
- package/dist/monitor.runtime-CZquR7jI.js +0 -2
- package/dist/outbound.runtime-BS0IhU_M.js +0 -2
- package/dist/probe.runtime-D13ZtXsd.js +0 -2
- package/dist/quick-reply-fallback-D86FwAfr.js +0 -56
- package/dist/send-receipt-CY2ey8XH.js +0 -107
- package/node_modules/@line/bot-sdk/dist/cjs/webhook/model/messageEditedEvent.d.ts +0 -24
- package/node_modules/@line/bot-sdk/dist/cjs/webhook/model/messageEditedEvent.d.ts.map +0 -1
- package/node_modules/@line/bot-sdk/dist/cjs/webhook/model/messageEditedEvent.js +0 -14
- package/node_modules/@line/bot-sdk/dist/cjs/webhook/model/messageEditedEvent.js.map +0 -1
- package/node_modules/@line/bot-sdk/dist/webhook/model/messageEditedEvent.d.ts +0 -24
- package/node_modules/@line/bot-sdk/dist/webhook/model/messageEditedEvent.d.ts.map +0 -1
- package/node_modules/@line/bot-sdk/dist/webhook/model/messageEditedEvent.js +0 -13
- package/node_modules/@line/bot-sdk/dist/webhook/model/messageEditedEvent.js.map +0 -1
- package/node_modules/@line/bot-sdk/lib/webhook/model/messageEditedEvent.ts +0 -32
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@ Official OpenClaw channel plugin for LINE Bot API chats.
|
|
|
5
5
|
Install from OpenClaw:
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
openclaw
|
|
8
|
+
openclaw plugin add @openclaw/line
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
Configure LINE channel credentials in OpenClaw, then connect the bot to the chats where agents should receive and send messages.
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { DEFAULT_ACCOUNT_ID, normalizeAccountId, normalizeOptionalAccountId } from "openclaw/plugin-sdk/account-id";
|
|
2
|
+
import { resolveAccountEntry } from "openclaw/plugin-sdk/account-resolution";
|
|
3
|
+
import { tryReadSecretFileSync } from "openclaw/plugin-sdk/core";
|
|
4
|
+
//#region extensions/line/src/accounts.ts
|
|
5
|
+
function readFileIfExists(filePath) {
|
|
6
|
+
return tryReadSecretFileSync(filePath, "LINE credential file", { rejectSymlink: true });
|
|
7
|
+
}
|
|
8
|
+
function resolveToken(params) {
|
|
9
|
+
const { accountId, baseConfig, accountConfig } = params;
|
|
10
|
+
if (accountConfig?.channelAccessToken?.trim()) return {
|
|
11
|
+
token: accountConfig.channelAccessToken.trim(),
|
|
12
|
+
tokenSource: "config"
|
|
13
|
+
};
|
|
14
|
+
const accountFileToken = readFileIfExists(accountConfig?.tokenFile);
|
|
15
|
+
if (accountFileToken) return {
|
|
16
|
+
token: accountFileToken,
|
|
17
|
+
tokenSource: "file"
|
|
18
|
+
};
|
|
19
|
+
if (accountId === DEFAULT_ACCOUNT_ID) {
|
|
20
|
+
if (baseConfig?.channelAccessToken?.trim()) return {
|
|
21
|
+
token: baseConfig.channelAccessToken.trim(),
|
|
22
|
+
tokenSource: "config"
|
|
23
|
+
};
|
|
24
|
+
const baseFileToken = readFileIfExists(baseConfig?.tokenFile);
|
|
25
|
+
if (baseFileToken) return {
|
|
26
|
+
token: baseFileToken,
|
|
27
|
+
tokenSource: "file"
|
|
28
|
+
};
|
|
29
|
+
const envToken = process.env.LINE_CHANNEL_ACCESS_TOKEN?.trim();
|
|
30
|
+
if (envToken) return {
|
|
31
|
+
token: envToken,
|
|
32
|
+
tokenSource: "env"
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
return {
|
|
36
|
+
token: "",
|
|
37
|
+
tokenSource: "none"
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
function resolveSecret(params) {
|
|
41
|
+
const { accountId, baseConfig, accountConfig } = params;
|
|
42
|
+
if (accountConfig?.channelSecret?.trim()) return accountConfig.channelSecret.trim();
|
|
43
|
+
const accountFileSecret = readFileIfExists(accountConfig?.secretFile);
|
|
44
|
+
if (accountFileSecret) return accountFileSecret;
|
|
45
|
+
if (accountId === DEFAULT_ACCOUNT_ID) {
|
|
46
|
+
if (baseConfig?.channelSecret?.trim()) return baseConfig.channelSecret.trim();
|
|
47
|
+
const baseFileSecret = readFileIfExists(baseConfig?.secretFile);
|
|
48
|
+
if (baseFileSecret) return baseFileSecret;
|
|
49
|
+
const envSecret = process.env.LINE_CHANNEL_SECRET?.trim();
|
|
50
|
+
if (envSecret) return envSecret;
|
|
51
|
+
}
|
|
52
|
+
return "";
|
|
53
|
+
}
|
|
54
|
+
function resolveLineAccount(params) {
|
|
55
|
+
const cfg = params.cfg;
|
|
56
|
+
const accountId = normalizeAccountId(params.accountId ?? resolveDefaultLineAccountId(cfg));
|
|
57
|
+
const lineConfig = cfg.channels?.line;
|
|
58
|
+
const accounts = lineConfig?.accounts;
|
|
59
|
+
const accountConfig = resolveAccountEntry(accounts, accountId);
|
|
60
|
+
const { token, tokenSource } = resolveToken({
|
|
61
|
+
accountId,
|
|
62
|
+
baseConfig: lineConfig,
|
|
63
|
+
accountConfig
|
|
64
|
+
});
|
|
65
|
+
const secret = resolveSecret({
|
|
66
|
+
accountId,
|
|
67
|
+
baseConfig: lineConfig,
|
|
68
|
+
accountConfig
|
|
69
|
+
});
|
|
70
|
+
const { accounts: _ignoredAccounts, defaultAccount: _ignoredDefaultAccount, ...lineBase } = lineConfig ?? {};
|
|
71
|
+
const mergedConfig = {
|
|
72
|
+
...lineBase,
|
|
73
|
+
...accountConfig
|
|
74
|
+
};
|
|
75
|
+
const baseEnabled = lineConfig?.enabled !== false;
|
|
76
|
+
const accountEnabled = accountConfig?.enabled !== false;
|
|
77
|
+
const enabled = baseEnabled && accountEnabled;
|
|
78
|
+
return {
|
|
79
|
+
accountId,
|
|
80
|
+
name: accountConfig?.name ?? (accountId === DEFAULT_ACCOUNT_ID ? lineConfig?.name : void 0),
|
|
81
|
+
enabled,
|
|
82
|
+
channelAccessToken: token,
|
|
83
|
+
channelSecret: secret,
|
|
84
|
+
tokenSource,
|
|
85
|
+
config: mergedConfig
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
function listLineAccountIds(cfg) {
|
|
89
|
+
const lineConfig = cfg.channels?.line;
|
|
90
|
+
const accounts = lineConfig?.accounts;
|
|
91
|
+
const ids = /* @__PURE__ */ new Set();
|
|
92
|
+
if (lineConfig?.channelAccessToken?.trim() || lineConfig?.tokenFile || process.env.LINE_CHANNEL_ACCESS_TOKEN?.trim()) ids.add(DEFAULT_ACCOUNT_ID);
|
|
93
|
+
if (accounts) for (const id of Object.keys(accounts)) ids.add(id);
|
|
94
|
+
return Array.from(ids);
|
|
95
|
+
}
|
|
96
|
+
function resolveDefaultLineAccountId(cfg) {
|
|
97
|
+
const preferred = normalizeOptionalAccountId((cfg.channels?.line)?.defaultAccount);
|
|
98
|
+
if (preferred && listLineAccountIds(cfg).some((accountId) => normalizeAccountId(accountId) === preferred)) return preferred;
|
|
99
|
+
const ids = listLineAccountIds(cfg);
|
|
100
|
+
if (ids.includes(DEFAULT_ACCOUNT_ID)) return DEFAULT_ACCOUNT_ID;
|
|
101
|
+
return ids[0] ?? DEFAULT_ACCOUNT_ID;
|
|
102
|
+
}
|
|
103
|
+
function normalizeAccountId$1(accountId) {
|
|
104
|
+
return normalizeAccountId(accountId);
|
|
105
|
+
}
|
|
106
|
+
//#endregion
|
|
107
|
+
export { resolveLineAccount as i, normalizeAccountId$1 as n, resolveDefaultLineAccountId as r, listLineAccountIds as t };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { n as lineChannelPluginCommon } from "./channel-Du0PrvOH.mjs";
|
|
2
|
+
import { n as lineSetupAdapter, t as lineSetupWizard } from "./setup-surface-M1ivmZ-G.mjs";
|
|
3
|
+
//#region extensions/line/src/channel.setup.ts
|
|
4
|
+
const lineSetupPlugin = {
|
|
5
|
+
id: "line",
|
|
6
|
+
...lineChannelPluginCommon,
|
|
7
|
+
setupWizard: lineSetupWizard,
|
|
8
|
+
setup: lineSetupAdapter
|
|
9
|
+
};
|
|
10
|
+
//#endregion
|
|
11
|
+
export { lineSetupPlugin as t };
|
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
import { d as attachFooterText } from "./flex-templates-BP6VHjzK.mjs";
|
|
2
|
+
//#region extensions/line/src/flex-templates/basic-cards.ts
|
|
3
|
+
/**
|
|
4
|
+
* Create an info card with title, body, and optional footer
|
|
5
|
+
*
|
|
6
|
+
* Editorial design: Clean hierarchy with accent bar, generous spacing,
|
|
7
|
+
* and subtle background zones for visual separation.
|
|
8
|
+
*/
|
|
9
|
+
function createInfoCard(title, body, footer) {
|
|
10
|
+
const bubble = {
|
|
11
|
+
type: "bubble",
|
|
12
|
+
size: "mega",
|
|
13
|
+
body: {
|
|
14
|
+
type: "box",
|
|
15
|
+
layout: "vertical",
|
|
16
|
+
contents: [{
|
|
17
|
+
type: "box",
|
|
18
|
+
layout: "horizontal",
|
|
19
|
+
contents: [{
|
|
20
|
+
type: "box",
|
|
21
|
+
layout: "vertical",
|
|
22
|
+
contents: [],
|
|
23
|
+
width: "4px",
|
|
24
|
+
backgroundColor: "#06C755",
|
|
25
|
+
cornerRadius: "2px"
|
|
26
|
+
}, {
|
|
27
|
+
type: "text",
|
|
28
|
+
text: title,
|
|
29
|
+
weight: "bold",
|
|
30
|
+
size: "xl",
|
|
31
|
+
color: "#111111",
|
|
32
|
+
wrap: true,
|
|
33
|
+
flex: 1,
|
|
34
|
+
margin: "lg"
|
|
35
|
+
}]
|
|
36
|
+
}, {
|
|
37
|
+
type: "box",
|
|
38
|
+
layout: "vertical",
|
|
39
|
+
contents: [{
|
|
40
|
+
type: "text",
|
|
41
|
+
text: body,
|
|
42
|
+
size: "md",
|
|
43
|
+
color: "#444444",
|
|
44
|
+
wrap: true,
|
|
45
|
+
lineSpacing: "6px"
|
|
46
|
+
}],
|
|
47
|
+
margin: "xl",
|
|
48
|
+
paddingAll: "lg",
|
|
49
|
+
backgroundColor: "#F8F9FA",
|
|
50
|
+
cornerRadius: "lg"
|
|
51
|
+
}],
|
|
52
|
+
paddingAll: "xl",
|
|
53
|
+
backgroundColor: "#FFFFFF"
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
if (footer) attachFooterText(bubble, footer);
|
|
57
|
+
return bubble;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Create a list card with title and multiple items
|
|
61
|
+
*
|
|
62
|
+
* Editorial design: Numbered/bulleted list with clear visual hierarchy,
|
|
63
|
+
* accent dots for each item, and generous spacing.
|
|
64
|
+
*/
|
|
65
|
+
function createListCard(title, items) {
|
|
66
|
+
const itemContents = items.slice(0, 8).map((item, index) => {
|
|
67
|
+
const itemContentsLocal = [{
|
|
68
|
+
type: "text",
|
|
69
|
+
text: item.title,
|
|
70
|
+
size: "md",
|
|
71
|
+
weight: "bold",
|
|
72
|
+
color: "#1a1a1a",
|
|
73
|
+
wrap: true
|
|
74
|
+
}];
|
|
75
|
+
if (item.subtitle) itemContentsLocal.push({
|
|
76
|
+
type: "text",
|
|
77
|
+
text: item.subtitle,
|
|
78
|
+
size: "sm",
|
|
79
|
+
color: "#888888",
|
|
80
|
+
wrap: true,
|
|
81
|
+
margin: "xs"
|
|
82
|
+
});
|
|
83
|
+
const itemBox = {
|
|
84
|
+
type: "box",
|
|
85
|
+
layout: "horizontal",
|
|
86
|
+
contents: [{
|
|
87
|
+
type: "box",
|
|
88
|
+
layout: "vertical",
|
|
89
|
+
contents: [{
|
|
90
|
+
type: "box",
|
|
91
|
+
layout: "vertical",
|
|
92
|
+
contents: [],
|
|
93
|
+
width: "8px",
|
|
94
|
+
height: "8px",
|
|
95
|
+
backgroundColor: index === 0 ? "#06C755" : "#DDDDDD",
|
|
96
|
+
cornerRadius: "4px"
|
|
97
|
+
}],
|
|
98
|
+
width: "20px",
|
|
99
|
+
alignItems: "center",
|
|
100
|
+
paddingTop: "sm"
|
|
101
|
+
}, {
|
|
102
|
+
type: "box",
|
|
103
|
+
layout: "vertical",
|
|
104
|
+
contents: itemContentsLocal,
|
|
105
|
+
flex: 1
|
|
106
|
+
}],
|
|
107
|
+
margin: index > 0 ? "lg" : void 0
|
|
108
|
+
};
|
|
109
|
+
if (item.action) itemBox.action = item.action;
|
|
110
|
+
return itemBox;
|
|
111
|
+
});
|
|
112
|
+
return {
|
|
113
|
+
type: "bubble",
|
|
114
|
+
size: "mega",
|
|
115
|
+
body: {
|
|
116
|
+
type: "box",
|
|
117
|
+
layout: "vertical",
|
|
118
|
+
contents: [
|
|
119
|
+
{
|
|
120
|
+
type: "text",
|
|
121
|
+
text: title,
|
|
122
|
+
weight: "bold",
|
|
123
|
+
size: "xl",
|
|
124
|
+
color: "#111111",
|
|
125
|
+
wrap: true
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
type: "separator",
|
|
129
|
+
margin: "lg",
|
|
130
|
+
color: "#EEEEEE"
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
type: "box",
|
|
134
|
+
layout: "vertical",
|
|
135
|
+
contents: itemContents,
|
|
136
|
+
margin: "lg"
|
|
137
|
+
}
|
|
138
|
+
],
|
|
139
|
+
paddingAll: "xl",
|
|
140
|
+
backgroundColor: "#FFFFFF"
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Create an image card with image, title, and optional body text
|
|
146
|
+
*/
|
|
147
|
+
function createImageCard(imageUrl, title, body, options) {
|
|
148
|
+
const bubble = {
|
|
149
|
+
type: "bubble",
|
|
150
|
+
hero: {
|
|
151
|
+
type: "image",
|
|
152
|
+
url: imageUrl,
|
|
153
|
+
size: "full",
|
|
154
|
+
aspectRatio: options?.aspectRatio ?? "20:13",
|
|
155
|
+
aspectMode: options?.aspectMode ?? "cover",
|
|
156
|
+
action: options?.action
|
|
157
|
+
},
|
|
158
|
+
body: {
|
|
159
|
+
type: "box",
|
|
160
|
+
layout: "vertical",
|
|
161
|
+
contents: [{
|
|
162
|
+
type: "text",
|
|
163
|
+
text: title,
|
|
164
|
+
weight: "bold",
|
|
165
|
+
size: "xl",
|
|
166
|
+
wrap: true
|
|
167
|
+
}],
|
|
168
|
+
paddingAll: "lg"
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
if (body && bubble.body) bubble.body.contents.push({
|
|
172
|
+
type: "text",
|
|
173
|
+
text: body,
|
|
174
|
+
size: "md",
|
|
175
|
+
wrap: true,
|
|
176
|
+
margin: "md",
|
|
177
|
+
color: "#666666"
|
|
178
|
+
});
|
|
179
|
+
return bubble;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Create an action card with title, body, and action buttons
|
|
183
|
+
*/
|
|
184
|
+
function createActionCard(title, body, actions, options) {
|
|
185
|
+
const bubble = {
|
|
186
|
+
type: "bubble",
|
|
187
|
+
body: {
|
|
188
|
+
type: "box",
|
|
189
|
+
layout: "vertical",
|
|
190
|
+
contents: [{
|
|
191
|
+
type: "text",
|
|
192
|
+
text: title,
|
|
193
|
+
weight: "bold",
|
|
194
|
+
size: "xl",
|
|
195
|
+
wrap: true
|
|
196
|
+
}, {
|
|
197
|
+
type: "text",
|
|
198
|
+
text: body,
|
|
199
|
+
size: "md",
|
|
200
|
+
wrap: true,
|
|
201
|
+
margin: "md",
|
|
202
|
+
color: "#666666"
|
|
203
|
+
}],
|
|
204
|
+
paddingAll: "lg"
|
|
205
|
+
},
|
|
206
|
+
footer: {
|
|
207
|
+
type: "box",
|
|
208
|
+
layout: "vertical",
|
|
209
|
+
contents: actions.slice(0, 4).map((action, index) => ({
|
|
210
|
+
type: "button",
|
|
211
|
+
action: action.action,
|
|
212
|
+
style: index === 0 ? "primary" : "secondary",
|
|
213
|
+
margin: index > 0 ? "sm" : void 0
|
|
214
|
+
})),
|
|
215
|
+
paddingAll: "md"
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
if (options?.imageUrl) bubble.hero = {
|
|
219
|
+
type: "image",
|
|
220
|
+
url: options.imageUrl,
|
|
221
|
+
size: "full",
|
|
222
|
+
aspectRatio: options.aspectRatio ?? "20:13",
|
|
223
|
+
aspectMode: "cover"
|
|
224
|
+
};
|
|
225
|
+
return bubble;
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Create a carousel container from multiple bubbles
|
|
229
|
+
* LINE allows max 12 bubbles in a carousel
|
|
230
|
+
*/
|
|
231
|
+
function createCarousel(bubbles) {
|
|
232
|
+
return {
|
|
233
|
+
type: "carousel",
|
|
234
|
+
contents: bubbles.slice(0, 12)
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Create a notification bubble (for alerts, status updates)
|
|
239
|
+
*
|
|
240
|
+
* Editorial design: Bold status indicator with accent color,
|
|
241
|
+
* clear typography, optional icon for context.
|
|
242
|
+
*/
|
|
243
|
+
function createNotificationBubble(text, options) {
|
|
244
|
+
const typeColors = {
|
|
245
|
+
info: {
|
|
246
|
+
accent: "#3B82F6",
|
|
247
|
+
bg: "#EFF6FF"
|
|
248
|
+
},
|
|
249
|
+
success: {
|
|
250
|
+
accent: "#06C755",
|
|
251
|
+
bg: "#F0FDF4"
|
|
252
|
+
},
|
|
253
|
+
warning: {
|
|
254
|
+
accent: "#F59E0B",
|
|
255
|
+
bg: "#FFFBEB"
|
|
256
|
+
},
|
|
257
|
+
error: {
|
|
258
|
+
accent: "#EF4444",
|
|
259
|
+
bg: "#FEF2F2"
|
|
260
|
+
}
|
|
261
|
+
}[options?.type ?? "info"];
|
|
262
|
+
const contents = [];
|
|
263
|
+
contents.push({
|
|
264
|
+
type: "box",
|
|
265
|
+
layout: "vertical",
|
|
266
|
+
contents: [],
|
|
267
|
+
width: "4px",
|
|
268
|
+
backgroundColor: typeColors.accent,
|
|
269
|
+
cornerRadius: "2px"
|
|
270
|
+
});
|
|
271
|
+
const textContents = [];
|
|
272
|
+
if (options?.title) textContents.push({
|
|
273
|
+
type: "text",
|
|
274
|
+
text: options.title,
|
|
275
|
+
size: "md",
|
|
276
|
+
weight: "bold",
|
|
277
|
+
color: "#111111",
|
|
278
|
+
wrap: true
|
|
279
|
+
});
|
|
280
|
+
textContents.push({
|
|
281
|
+
type: "text",
|
|
282
|
+
text,
|
|
283
|
+
size: options?.title ? "sm" : "md",
|
|
284
|
+
color: options?.title ? "#666666" : "#333333",
|
|
285
|
+
wrap: true,
|
|
286
|
+
margin: options?.title ? "sm" : void 0
|
|
287
|
+
});
|
|
288
|
+
contents.push({
|
|
289
|
+
type: "box",
|
|
290
|
+
layout: "vertical",
|
|
291
|
+
contents: textContents,
|
|
292
|
+
flex: 1,
|
|
293
|
+
paddingStart: "lg"
|
|
294
|
+
});
|
|
295
|
+
return {
|
|
296
|
+
type: "bubble",
|
|
297
|
+
body: {
|
|
298
|
+
type: "box",
|
|
299
|
+
layout: "horizontal",
|
|
300
|
+
contents,
|
|
301
|
+
paddingAll: "xl",
|
|
302
|
+
backgroundColor: typeColors.bg
|
|
303
|
+
}
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
//#endregion
|
|
307
|
+
export { createListCard as a, createInfoCard as i, createCarousel as n, createNotificationBubble as o, createImageCard as r, createActionCard as t };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as messageAction, o as postbackAction, s as uriAction, u as createReceiptCard } from "./flex-templates-BP6VHjzK.mjs";
|
|
2
|
+
import { a as createListCard, i as createInfoCard, r as createImageCard, t as createActionCard } from "./basic-cards-C8Qwh2X1.mjs";
|
|
2
3
|
import { normalizeLowercaseStringOrEmpty } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
3
4
|
import { truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
|
|
4
|
-
import { expectDefined } from "openclaw/plugin-sdk/expect-runtime";
|
|
5
5
|
//#region extensions/line/src/card-command.ts
|
|
6
6
|
const CARD_USAGE = `Usage: /card <type> "title" "body" [options]
|
|
7
7
|
|
|
@@ -14,22 +14,56 @@ Types:
|
|
|
14
14
|
confirm "Question?" --yes "Yes|data" --no "No|data"
|
|
15
15
|
buttons "Title" "Text" --actions "Btn1|url1,Btn2|data2"
|
|
16
16
|
|
|
17
|
+
Escape a separator that belongs to the data with a backslash: \\, \\|, or \\:
|
|
18
|
+
|
|
17
19
|
Examples:
|
|
18
20
|
/card info "Welcome" "Thanks for joining!"
|
|
19
21
|
/card image "Product" "Check it out" --url https://example.com/img.jpg
|
|
20
|
-
/card action "Menu" "Choose an option" --actions "Order|/order,Help|/help"
|
|
22
|
+
/card action "Menu" "Choose an option" --actions "Order|/order,Help|/help"
|
|
23
|
+
/card action "Links" "Pick one" --actions "Open|https://example.com/a\\,b"`;
|
|
21
24
|
function buildLineReply(lineData) {
|
|
22
25
|
return { channelData: { line: lineData } };
|
|
23
26
|
}
|
|
24
27
|
/**
|
|
28
|
+
* Split a card option value on its unescaped separators.
|
|
29
|
+
*
|
|
30
|
+
* Each pass consumes escapes for its own separator and preserves every other
|
|
31
|
+
* backslash. This lets nested comma, pipe, and colon passes stay independent.
|
|
32
|
+
*/
|
|
33
|
+
function splitCardValue(value, separator) {
|
|
34
|
+
const parts = [];
|
|
35
|
+
let current = "";
|
|
36
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
37
|
+
const char = value[index];
|
|
38
|
+
if (char === "\\" && value[index + 1] === separator) {
|
|
39
|
+
current += separator;
|
|
40
|
+
index += 1;
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
if (char === separator) {
|
|
44
|
+
parts.push(current);
|
|
45
|
+
current = "";
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
current += char;
|
|
49
|
+
}
|
|
50
|
+
parts.push(current);
|
|
51
|
+
return parts;
|
|
52
|
+
}
|
|
53
|
+
/** Split a "Label|data" pair, keeping escaped separators inside either side. */
|
|
54
|
+
function splitCardPair(part) {
|
|
55
|
+
const [label = "", data] = splitCardValue(part, "|").map((piece) => piece.trim());
|
|
56
|
+
return [label, data];
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
25
59
|
* Parse action string format: "Label|data,Label2|data2"
|
|
26
60
|
* Data can be a URL (uri action) or plain text (message action) or key=value (postback)
|
|
27
61
|
*/
|
|
28
62
|
function parseActions(actionsStr) {
|
|
29
63
|
if (!actionsStr) return [];
|
|
30
64
|
const results = [];
|
|
31
|
-
for (const part of actionsStr
|
|
32
|
-
const [label, data] = part
|
|
65
|
+
for (const part of splitCardValue(actionsStr, ",")) {
|
|
66
|
+
const [label, data] = splitCardPair(part);
|
|
33
67
|
if (!label) continue;
|
|
34
68
|
const actionData = data || label;
|
|
35
69
|
if (actionData.startsWith("http://") || actionData.startsWith("https://")) results.push({
|
|
@@ -51,10 +85,10 @@ function parseActions(actionsStr) {
|
|
|
51
85
|
* Parse list items format: "Item1|Subtitle1,Item2|Subtitle2"
|
|
52
86
|
*/
|
|
53
87
|
function parseListItems(itemsStr) {
|
|
54
|
-
return itemsStr
|
|
55
|
-
const [title, subtitle] = part
|
|
88
|
+
return splitCardValue(itemsStr, ",").map((part) => {
|
|
89
|
+
const [title, subtitle] = splitCardPair(part);
|
|
56
90
|
return {
|
|
57
|
-
title
|
|
91
|
+
title,
|
|
58
92
|
subtitle
|
|
59
93
|
};
|
|
60
94
|
}).filter((item) => item.title);
|
|
@@ -63,15 +97,12 @@ function parseListItems(itemsStr) {
|
|
|
63
97
|
* Parse receipt items format: "Item1:$10,Item2:$20"
|
|
64
98
|
*/
|
|
65
99
|
function parseReceiptItems(itemsStr) {
|
|
66
|
-
return itemsStr
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
name: part.trim(),
|
|
70
|
-
value: ""
|
|
71
|
-
};
|
|
100
|
+
return splitCardValue(itemsStr, ",").map((part) => {
|
|
101
|
+
const segments = splitCardValue(part, ":");
|
|
102
|
+
const value = segments.length > 1 ? segments.pop() : void 0;
|
|
72
103
|
return {
|
|
73
|
-
name:
|
|
74
|
-
value:
|
|
104
|
+
name: segments.join(":").trim(),
|
|
105
|
+
value: value?.trim() ?? ""
|
|
75
106
|
};
|
|
76
107
|
}).filter((item) => item.name);
|
|
77
108
|
}
|
|
@@ -93,12 +124,9 @@ function parseCardArgs(argsStrInput) {
|
|
|
93
124
|
}
|
|
94
125
|
const quotedRegex = /"([^"]*?)"/g;
|
|
95
126
|
let match;
|
|
96
|
-
while ((match = quotedRegex.exec(argsStr)) !== null) result.args.push(
|
|
127
|
+
while ((match = quotedRegex.exec(argsStr)) !== null) result.args.push(match[1]);
|
|
97
128
|
const flagRegex = /--(\w+)\s+(?:"([^"]*?)"|(\S+))/g;
|
|
98
|
-
while ((match = flagRegex.exec(argsStr)) !== null)
|
|
99
|
-
const key = expectDefined(match[1], "card flag name capture");
|
|
100
|
-
result.flags[key] = expectDefined(match[2] ?? match[3], "card flag value capture");
|
|
101
|
-
}
|
|
129
|
+
while ((match = flagRegex.exec(argsStr)) !== null) result.flags[match[1]] = match[2] ?? match[3];
|
|
102
130
|
return result;
|
|
103
131
|
}
|
|
104
132
|
function registerLineCardCommand(api) {
|
|
@@ -177,8 +205,8 @@ function registerLineCardCommand(api) {
|
|
|
177
205
|
const [question = "Confirm?"] = args;
|
|
178
206
|
const yesStr = flags.yes || "Yes|yes";
|
|
179
207
|
const noStr = flags.no || "No|no";
|
|
180
|
-
const [yesLabel, yesData] = yesStr
|
|
181
|
-
const [noLabel, noData] = noStr
|
|
208
|
+
const [yesLabel, yesData] = splitCardPair(yesStr);
|
|
209
|
+
const [noLabel, noData] = splitCardPair(noStr);
|
|
182
210
|
return buildLineReply({ templateMessage: {
|
|
183
211
|
type: "confirm",
|
|
184
212
|
text: question,
|