@kodelyth/line 2026.5.39 → 2026.5.42
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/api.ts +11 -0
- package/channel-plugin-api.ts +1 -0
- package/contract-api.ts +5 -0
- package/dist/accounts-CD4A1FE7.js +105 -0
- package/dist/api.js +11 -0
- package/dist/basic-cards-BISytiSa.js +307 -0
- package/dist/card-command-dQBX3fVN.js +240 -0
- package/dist/channel-DV5h44-j.js +649 -0
- package/dist/channel-plugin-api.js +2 -0
- package/dist/channel.runtime-Cc-v3szZ.js +4 -0
- package/dist/contract-api.js +2 -0
- package/dist/index.js +45 -0
- package/dist/markdown-to-line-CC3BU6CC.js +810 -0
- package/dist/monitor-Ci8Hg8ay.js +1485 -0
- package/dist/monitor.runtime-t6-QvlDB.js +2 -0
- package/dist/outbound.runtime-D1CxEvcL.js +2 -0
- package/dist/probe-BPSs_A_8.js +30 -0
- package/dist/probe.runtime-7u2o9QN5.js +2 -0
- package/dist/reply-payload-transform-CDuBzoT4.js +855 -0
- package/dist/runtime-api.js +291 -0
- package/dist/schedule-cards-D-yZMHDE.js +359 -0
- package/dist/secret-contract-api.js +5 -0
- package/dist/setup-api.js +2 -0
- package/dist/setup-entry.js +11 -0
- package/dist/setup-surface-CHfQ6Z4i.js +282 -0
- package/index.ts +53 -0
- package/klaw.plugin.json +2 -329
- package/package.json +4 -4
- package/runtime-api.ts +179 -0
- package/secret-contract-api.ts +4 -0
- package/setup-api.ts +2 -0
- package/setup-entry.ts +9 -0
- package/src/account-helpers.ts +16 -0
- package/src/accounts.test.ts +288 -0
- package/src/accounts.ts +187 -0
- package/src/actions.ts +61 -0
- package/src/auto-reply-delivery.test.ts +253 -0
- package/src/auto-reply-delivery.ts +200 -0
- package/src/bindings.ts +65 -0
- package/src/bot-access.ts +30 -0
- package/src/bot-handlers.test.ts +1094 -0
- package/src/bot-handlers.ts +620 -0
- package/src/bot-message-context.test.ts +420 -0
- package/src/bot-message-context.ts +586 -0
- package/src/bot.ts +66 -0
- package/src/card-command.ts +347 -0
- package/src/channel-access-token.ts +14 -0
- package/src/channel-api.ts +17 -0
- package/src/channel-setup-status.contract.test.ts +70 -0
- package/src/channel-shared.ts +48 -0
- package/src/channel.logout.test.ts +145 -0
- package/src/channel.runtime.ts +3 -0
- package/src/channel.sendPayload.test.ts +659 -0
- package/src/channel.setup.ts +11 -0
- package/src/channel.status.test.ts +63 -0
- package/src/channel.ts +155 -0
- package/src/config-adapter.ts +29 -0
- package/src/config-schema.test.ts +53 -0
- package/src/config-schema.ts +81 -0
- package/src/download.test.ts +164 -0
- package/src/download.ts +34 -0
- package/src/flex-templates/basic-cards.ts +395 -0
- package/src/flex-templates/common.ts +20 -0
- package/src/flex-templates/media-control-cards.ts +555 -0
- package/src/flex-templates/message.ts +13 -0
- package/src/flex-templates/schedule-cards.ts +467 -0
- package/src/flex-templates/types.ts +22 -0
- package/src/flex-templates.ts +32 -0
- package/src/gateway.ts +129 -0
- package/src/group-keys.test.ts +123 -0
- package/src/group-keys.ts +65 -0
- package/src/group-policy.ts +22 -0
- package/src/markdown-to-line.test.ts +348 -0
- package/src/markdown-to-line.ts +416 -0
- package/src/message-cards.test.ts +204 -0
- package/src/monitor-durable.test.ts +57 -0
- package/src/monitor-durable.ts +37 -0
- package/src/monitor.lifecycle.test.ts +499 -0
- package/src/monitor.runtime.ts +1 -0
- package/src/monitor.ts +507 -0
- package/src/outbound-media.test.ts +194 -0
- package/src/outbound-media.ts +120 -0
- package/src/outbound.runtime.ts +12 -0
- package/src/outbound.ts +427 -0
- package/src/probe.contract.test.ts +9 -0
- package/src/probe.runtime.ts +1 -0
- package/src/probe.ts +34 -0
- package/src/quick-reply-fallback.ts +10 -0
- package/src/reply-chunks.test.ts +180 -0
- package/src/reply-chunks.ts +110 -0
- package/src/reply-payload-transform.test.ts +392 -0
- package/src/reply-payload-transform.ts +317 -0
- package/src/rich-menu.test.ts +315 -0
- package/src/rich-menu.ts +326 -0
- package/src/runtime.ts +32 -0
- package/src/send-receipt.ts +32 -0
- package/src/send.test.ts +453 -0
- package/src/send.ts +531 -0
- package/src/setup-core.ts +149 -0
- package/src/setup-runtime-api.ts +9 -0
- package/src/setup-surface.test.ts +481 -0
- package/src/setup-surface.ts +229 -0
- package/src/signature.test.ts +34 -0
- package/src/signature.ts +24 -0
- package/src/status.ts +37 -0
- package/src/template-messages.ts +333 -0
- package/src/types.ts +130 -0
- package/src/webhook-node.test.ts +598 -0
- package/src/webhook-node.ts +155 -0
- package/src/webhook-utils.ts +10 -0
- package/src/webhook.ts +135 -0
- package/tsconfig.json +16 -0
- package/api.js +0 -7
- package/channel-plugin-api.js +0 -7
- package/contract-api.js +0 -7
- package/index.js +0 -7
- package/runtime-api.js +0 -7
- package/secret-contract-api.js +0 -7
- package/setup-api.js +0 -7
- package/setup-entry.js +0 -7
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
import { i as resolveLineAccount, n as normalizeAccountId, r as resolveDefaultLineAccountId, t as listLineAccountIds } from "./accounts-CD4A1FE7.js";
|
|
2
|
+
import { normalizeOptionalString } from "klaw/plugin-sdk/string-coerce-runtime";
|
|
3
|
+
import { DEFAULT_ACCOUNT_ID, createAllowFromSection, createSetupInputPresenceValidator, createSetupTranslator, createStandardChannelSetupStatus, formatDocsLink, mergeAllowFromEntries, setSetupChannelEnabled, splitSetupEntries } from "klaw/plugin-sdk/setup";
|
|
4
|
+
//#region extensions/line/src/account-helpers.ts
|
|
5
|
+
function hasLineCredentials(account) {
|
|
6
|
+
return Boolean(account.channelAccessToken?.trim() && account.channelSecret?.trim());
|
|
7
|
+
}
|
|
8
|
+
function parseLineAllowFromId(raw) {
|
|
9
|
+
const trimmed = raw.trim().replace(/^line:(?:user:)?/i, "");
|
|
10
|
+
if (!/^U[a-f0-9]{32}$/i.test(trimmed)) return null;
|
|
11
|
+
return trimmed;
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
//#region extensions/line/src/setup-core.ts
|
|
15
|
+
function patchLineAccountConfig(params) {
|
|
16
|
+
const accountId = normalizeAccountId(params.accountId);
|
|
17
|
+
const lineConfig = params.cfg.channels?.line ?? {};
|
|
18
|
+
const clearFields = params.clearFields ?? [];
|
|
19
|
+
if (accountId === DEFAULT_ACCOUNT_ID) {
|
|
20
|
+
const nextLine = { ...lineConfig };
|
|
21
|
+
for (const field of clearFields) delete nextLine[field];
|
|
22
|
+
return {
|
|
23
|
+
...params.cfg,
|
|
24
|
+
channels: {
|
|
25
|
+
...params.cfg.channels,
|
|
26
|
+
line: {
|
|
27
|
+
...nextLine,
|
|
28
|
+
...params.enabled ? { enabled: true } : {},
|
|
29
|
+
...params.patch
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
const nextAccount = { ...lineConfig.accounts?.[accountId] };
|
|
35
|
+
for (const field of clearFields) delete nextAccount[field];
|
|
36
|
+
return {
|
|
37
|
+
...params.cfg,
|
|
38
|
+
channels: {
|
|
39
|
+
...params.cfg.channels,
|
|
40
|
+
line: {
|
|
41
|
+
...lineConfig,
|
|
42
|
+
...params.enabled ? { enabled: true } : {},
|
|
43
|
+
accounts: {
|
|
44
|
+
...lineConfig.accounts,
|
|
45
|
+
[accountId]: {
|
|
46
|
+
...nextAccount,
|
|
47
|
+
...params.enabled ? { enabled: true } : {},
|
|
48
|
+
...params.patch
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function isLineConfigured(cfg, accountId) {
|
|
56
|
+
return hasLineCredentials(resolveLineAccount({
|
|
57
|
+
cfg,
|
|
58
|
+
accountId
|
|
59
|
+
}));
|
|
60
|
+
}
|
|
61
|
+
const lineSetupAdapter = {
|
|
62
|
+
resolveAccountId: ({ accountId }) => normalizeAccountId(accountId),
|
|
63
|
+
applyAccountName: ({ cfg, accountId, name }) => patchLineAccountConfig({
|
|
64
|
+
cfg,
|
|
65
|
+
accountId,
|
|
66
|
+
patch: name?.trim() ? { name: name.trim() } : {}
|
|
67
|
+
}),
|
|
68
|
+
validateInput: createSetupInputPresenceValidator({
|
|
69
|
+
defaultAccountOnlyEnvError: "LINE_CHANNEL_ACCESS_TOKEN can only be used for the default account.",
|
|
70
|
+
whenNotUseEnv: [{
|
|
71
|
+
someOf: ["channelAccessToken", "tokenFile"],
|
|
72
|
+
message: "LINE requires channelAccessToken or --token-file (or --use-env)."
|
|
73
|
+
}, {
|
|
74
|
+
someOf: ["channelSecret", "secretFile"],
|
|
75
|
+
message: "LINE requires channelSecret or --secret-file (or --use-env)."
|
|
76
|
+
}]
|
|
77
|
+
}),
|
|
78
|
+
applyAccountConfig: ({ cfg, accountId, input }) => {
|
|
79
|
+
const typedInput = input;
|
|
80
|
+
const normalizedAccountId = normalizeAccountId(accountId);
|
|
81
|
+
if (normalizedAccountId === DEFAULT_ACCOUNT_ID) return patchLineAccountConfig({
|
|
82
|
+
cfg,
|
|
83
|
+
accountId: normalizedAccountId,
|
|
84
|
+
enabled: true,
|
|
85
|
+
clearFields: typedInput.useEnv ? [
|
|
86
|
+
"channelAccessToken",
|
|
87
|
+
"channelSecret",
|
|
88
|
+
"tokenFile",
|
|
89
|
+
"secretFile"
|
|
90
|
+
] : void 0,
|
|
91
|
+
patch: typedInput.useEnv ? {} : {
|
|
92
|
+
...typedInput.tokenFile ? { tokenFile: typedInput.tokenFile } : typedInput.channelAccessToken ? { channelAccessToken: typedInput.channelAccessToken } : {},
|
|
93
|
+
...typedInput.secretFile ? { secretFile: typedInput.secretFile } : typedInput.channelSecret ? { channelSecret: typedInput.channelSecret } : {}
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
return patchLineAccountConfig({
|
|
97
|
+
cfg,
|
|
98
|
+
accountId: normalizedAccountId,
|
|
99
|
+
enabled: true,
|
|
100
|
+
patch: {
|
|
101
|
+
...typedInput.tokenFile ? { tokenFile: typedInput.tokenFile } : typedInput.channelAccessToken ? { channelAccessToken: typedInput.channelAccessToken } : {},
|
|
102
|
+
...typedInput.secretFile ? { secretFile: typedInput.secretFile } : typedInput.channelSecret ? { channelSecret: typedInput.channelSecret } : {}
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
//#endregion
|
|
108
|
+
//#region extensions/line/src/setup-surface.ts
|
|
109
|
+
const t = createSetupTranslator();
|
|
110
|
+
const channel = "line";
|
|
111
|
+
const LINE_SETUP_HELP_LINES = [
|
|
112
|
+
t("wizard.line.helpOpenConsole"),
|
|
113
|
+
t("wizard.line.helpCopyCredentials"),
|
|
114
|
+
t("wizard.line.helpEnableWebhook"),
|
|
115
|
+
t("wizard.line.helpWebhookUrl"),
|
|
116
|
+
t("wizard.channels.docs", { link: formatDocsLink("/channels/line", "channels/line") })
|
|
117
|
+
];
|
|
118
|
+
const LINE_ALLOW_FROM_HELP_LINES = [
|
|
119
|
+
t("wizard.line.allowlistIntro"),
|
|
120
|
+
t("wizard.line.idsCaseSensitive"),
|
|
121
|
+
t("wizard.line.examples"),
|
|
122
|
+
"- U1234567890abcdef1234567890abcdef",
|
|
123
|
+
"- line:user:U1234567890abcdef1234567890abcdef",
|
|
124
|
+
t("wizard.line.multipleEntries"),
|
|
125
|
+
t("wizard.channels.docs", { link: formatDocsLink("/channels/line", "channels/line") })
|
|
126
|
+
];
|
|
127
|
+
const lineDmPolicy = {
|
|
128
|
+
label: "LINE",
|
|
129
|
+
channel,
|
|
130
|
+
policyKey: "channels.line.dmPolicy",
|
|
131
|
+
allowFromKey: "channels.line.allowFrom",
|
|
132
|
+
resolveConfigKeys: (cfg, accountId) => (accountId ?? resolveDefaultLineAccountId(cfg)) !== DEFAULT_ACCOUNT_ID ? {
|
|
133
|
+
policyKey: `channels.line.accounts.${accountId ?? resolveDefaultLineAccountId(cfg)}.dmPolicy`,
|
|
134
|
+
allowFromKey: `channels.line.accounts.${accountId ?? resolveDefaultLineAccountId(cfg)}.allowFrom`
|
|
135
|
+
} : {
|
|
136
|
+
policyKey: "channels.line.dmPolicy",
|
|
137
|
+
allowFromKey: "channels.line.allowFrom"
|
|
138
|
+
},
|
|
139
|
+
getCurrent: (cfg, accountId) => resolveLineAccount({
|
|
140
|
+
cfg,
|
|
141
|
+
accountId: accountId ?? resolveDefaultLineAccountId(cfg)
|
|
142
|
+
}).config.dmPolicy ?? "pairing",
|
|
143
|
+
setPolicy: (cfg, policy, accountId) => patchLineAccountConfig({
|
|
144
|
+
cfg,
|
|
145
|
+
accountId: accountId ?? resolveDefaultLineAccountId(cfg),
|
|
146
|
+
enabled: true,
|
|
147
|
+
patch: policy === "open" ? {
|
|
148
|
+
dmPolicy: "open",
|
|
149
|
+
allowFrom: mergeAllowFromEntries(resolveLineAccount({
|
|
150
|
+
cfg,
|
|
151
|
+
accountId: accountId ?? resolveDefaultLineAccountId(cfg)
|
|
152
|
+
}).config.allowFrom, ["*"])
|
|
153
|
+
} : { dmPolicy: policy },
|
|
154
|
+
clearFields: policy === "pairing" || policy === "disabled" ? ["allowFrom"] : void 0
|
|
155
|
+
})
|
|
156
|
+
};
|
|
157
|
+
const lineSetupWizard = {
|
|
158
|
+
channel,
|
|
159
|
+
status: createStandardChannelSetupStatus({
|
|
160
|
+
channelLabel: "LINE",
|
|
161
|
+
configuredLabel: t("wizard.channels.statusConfigured"),
|
|
162
|
+
unconfiguredLabel: t("wizard.channels.statusNeedsTokenSecret"),
|
|
163
|
+
configuredHint: t("wizard.channels.statusConfigured"),
|
|
164
|
+
unconfiguredHint: t("wizard.channels.statusNeedsTokenSecret"),
|
|
165
|
+
configuredScore: 1,
|
|
166
|
+
unconfiguredScore: 0,
|
|
167
|
+
includeStatusLine: true,
|
|
168
|
+
resolveConfigured: ({ cfg, accountId }) => isLineConfigured(cfg, accountId ?? resolveDefaultLineAccountId(cfg)),
|
|
169
|
+
resolveExtraStatusLines: ({ cfg }) => [`Accounts: ${listLineAccountIds(cfg).length || 0}`]
|
|
170
|
+
}),
|
|
171
|
+
introNote: {
|
|
172
|
+
title: t("wizard.line.messagingApiTitle"),
|
|
173
|
+
lines: LINE_SETUP_HELP_LINES,
|
|
174
|
+
shouldShow: ({ cfg, accountId }) => !isLineConfigured(cfg, accountId ?? resolveDefaultLineAccountId(cfg))
|
|
175
|
+
},
|
|
176
|
+
credentials: [{
|
|
177
|
+
inputKey: "token",
|
|
178
|
+
providerHint: channel,
|
|
179
|
+
credentialLabel: t("wizard.line.channelAccessToken"),
|
|
180
|
+
preferredEnvVar: "LINE_CHANNEL_ACCESS_TOKEN",
|
|
181
|
+
helpTitle: t("wizard.line.messagingApiTitle"),
|
|
182
|
+
helpLines: LINE_SETUP_HELP_LINES,
|
|
183
|
+
envPrompt: t("wizard.line.tokenEnvPrompt"),
|
|
184
|
+
keepPrompt: t("wizard.line.tokenKeepPrompt"),
|
|
185
|
+
inputPrompt: t("wizard.line.tokenInputPrompt"),
|
|
186
|
+
allowEnv: ({ accountId }) => accountId === DEFAULT_ACCOUNT_ID,
|
|
187
|
+
inspect: ({ cfg, accountId }) => {
|
|
188
|
+
const resolved = resolveLineAccount({
|
|
189
|
+
cfg,
|
|
190
|
+
accountId
|
|
191
|
+
});
|
|
192
|
+
return {
|
|
193
|
+
accountConfigured: Boolean(normalizeOptionalString(resolved.channelAccessToken) && normalizeOptionalString(resolved.channelSecret)),
|
|
194
|
+
hasConfiguredValue: Boolean(normalizeOptionalString(resolved.config.channelAccessToken) ?? normalizeOptionalString(resolved.config.tokenFile)),
|
|
195
|
+
resolvedValue: normalizeOptionalString(resolved.channelAccessToken),
|
|
196
|
+
envValue: accountId === DEFAULT_ACCOUNT_ID ? normalizeOptionalString(process.env.LINE_CHANNEL_ACCESS_TOKEN) : void 0
|
|
197
|
+
};
|
|
198
|
+
},
|
|
199
|
+
applyUseEnv: ({ cfg, accountId }) => patchLineAccountConfig({
|
|
200
|
+
cfg,
|
|
201
|
+
accountId,
|
|
202
|
+
enabled: true,
|
|
203
|
+
clearFields: ["channelAccessToken", "tokenFile"],
|
|
204
|
+
patch: {}
|
|
205
|
+
}),
|
|
206
|
+
applySet: ({ cfg, accountId, resolvedValue }) => patchLineAccountConfig({
|
|
207
|
+
cfg,
|
|
208
|
+
accountId,
|
|
209
|
+
enabled: true,
|
|
210
|
+
clearFields: ["tokenFile"],
|
|
211
|
+
patch: { channelAccessToken: resolvedValue }
|
|
212
|
+
})
|
|
213
|
+
}, {
|
|
214
|
+
inputKey: "password",
|
|
215
|
+
providerHint: "line-secret",
|
|
216
|
+
credentialLabel: t("wizard.line.channelSecret"),
|
|
217
|
+
preferredEnvVar: "LINE_CHANNEL_SECRET",
|
|
218
|
+
helpTitle: t("wizard.line.messagingApiTitle"),
|
|
219
|
+
helpLines: LINE_SETUP_HELP_LINES,
|
|
220
|
+
envPrompt: t("wizard.line.secretEnvPrompt"),
|
|
221
|
+
keepPrompt: t("wizard.line.secretKeepPrompt"),
|
|
222
|
+
inputPrompt: t("wizard.line.secretInputPrompt"),
|
|
223
|
+
allowEnv: ({ accountId }) => accountId === DEFAULT_ACCOUNT_ID,
|
|
224
|
+
inspect: ({ cfg, accountId }) => {
|
|
225
|
+
const resolved = resolveLineAccount({
|
|
226
|
+
cfg,
|
|
227
|
+
accountId
|
|
228
|
+
});
|
|
229
|
+
return {
|
|
230
|
+
accountConfigured: Boolean(normalizeOptionalString(resolved.channelAccessToken) && normalizeOptionalString(resolved.channelSecret)),
|
|
231
|
+
hasConfiguredValue: Boolean(normalizeOptionalString(resolved.config.channelSecret) ?? normalizeOptionalString(resolved.config.secretFile)),
|
|
232
|
+
resolvedValue: normalizeOptionalString(resolved.channelSecret),
|
|
233
|
+
envValue: accountId === DEFAULT_ACCOUNT_ID ? normalizeOptionalString(process.env.LINE_CHANNEL_SECRET) : void 0
|
|
234
|
+
};
|
|
235
|
+
},
|
|
236
|
+
applyUseEnv: ({ cfg, accountId }) => patchLineAccountConfig({
|
|
237
|
+
cfg,
|
|
238
|
+
accountId,
|
|
239
|
+
enabled: true,
|
|
240
|
+
clearFields: ["channelSecret", "secretFile"],
|
|
241
|
+
patch: {}
|
|
242
|
+
}),
|
|
243
|
+
applySet: ({ cfg, accountId, resolvedValue }) => patchLineAccountConfig({
|
|
244
|
+
cfg,
|
|
245
|
+
accountId,
|
|
246
|
+
enabled: true,
|
|
247
|
+
clearFields: ["secretFile"],
|
|
248
|
+
patch: { channelSecret: resolvedValue }
|
|
249
|
+
})
|
|
250
|
+
}],
|
|
251
|
+
allowFrom: createAllowFromSection({
|
|
252
|
+
helpTitle: t("wizard.line.allowlistTitle"),
|
|
253
|
+
helpLines: LINE_ALLOW_FROM_HELP_LINES,
|
|
254
|
+
message: t("wizard.line.allowFromPrompt"),
|
|
255
|
+
placeholder: "U1234567890abcdef1234567890abcdef",
|
|
256
|
+
invalidWithoutCredentialNote: t("wizard.line.allowFromInvalid"),
|
|
257
|
+
parseInputs: splitSetupEntries,
|
|
258
|
+
parseId: parseLineAllowFromId,
|
|
259
|
+
apply: ({ cfg, accountId, allowFrom }) => patchLineAccountConfig({
|
|
260
|
+
cfg,
|
|
261
|
+
accountId,
|
|
262
|
+
enabled: true,
|
|
263
|
+
patch: {
|
|
264
|
+
dmPolicy: "allowlist",
|
|
265
|
+
allowFrom
|
|
266
|
+
}
|
|
267
|
+
})
|
|
268
|
+
}),
|
|
269
|
+
dmPolicy: lineDmPolicy,
|
|
270
|
+
completionNote: {
|
|
271
|
+
title: t("wizard.line.webhookTitle"),
|
|
272
|
+
lines: [
|
|
273
|
+
t("wizard.line.completionEnableWebhook"),
|
|
274
|
+
t("wizard.line.completionDefaultWebhook"),
|
|
275
|
+
t("wizard.line.completionWebhookPath"),
|
|
276
|
+
t("wizard.channels.docs", { link: formatDocsLink("/channels/line", "channels/line") })
|
|
277
|
+
]
|
|
278
|
+
},
|
|
279
|
+
disable: (cfg) => setSetupChannelEnabled(cfg, channel, false)
|
|
280
|
+
};
|
|
281
|
+
//#endregion
|
|
282
|
+
export { lineSetupAdapter as n, hasLineCredentials as r, lineSetupWizard as t };
|
package/index.ts
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import {
|
|
2
|
+
defineBundledChannelEntry,
|
|
3
|
+
type KlawPluginApi,
|
|
4
|
+
} from "klaw/plugin-sdk/channel-entry-contract";
|
|
5
|
+
|
|
6
|
+
type RegisteredLineCardCommand = Parameters<KlawPluginApi["registerCommand"]>[0];
|
|
7
|
+
|
|
8
|
+
let lineCardCommandPromise: Promise<RegisteredLineCardCommand> | null = null;
|
|
9
|
+
|
|
10
|
+
async function loadLineCardCommand(api: KlawPluginApi): Promise<RegisteredLineCardCommand> {
|
|
11
|
+
lineCardCommandPromise ??= (async () => {
|
|
12
|
+
let registered: RegisteredLineCardCommand | null = null;
|
|
13
|
+
const { registerLineCardCommand } = await import("./src/card-command.js");
|
|
14
|
+
registerLineCardCommand({
|
|
15
|
+
...api,
|
|
16
|
+
registerCommand(command: RegisteredLineCardCommand) {
|
|
17
|
+
registered = command;
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
if (!registered) {
|
|
21
|
+
throw new Error("LINE card command registration unavailable");
|
|
22
|
+
}
|
|
23
|
+
return registered;
|
|
24
|
+
})();
|
|
25
|
+
return await lineCardCommandPromise;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export default defineBundledChannelEntry({
|
|
29
|
+
id: "line",
|
|
30
|
+
name: "LINE",
|
|
31
|
+
description: "LINE Messaging API channel plugin",
|
|
32
|
+
importMetaUrl: import.meta.url,
|
|
33
|
+
plugin: {
|
|
34
|
+
specifier: "./channel-plugin-api.js",
|
|
35
|
+
exportName: "linePlugin",
|
|
36
|
+
},
|
|
37
|
+
runtime: {
|
|
38
|
+
specifier: "./runtime-api.js",
|
|
39
|
+
exportName: "setLineRuntime",
|
|
40
|
+
},
|
|
41
|
+
registerFull(api) {
|
|
42
|
+
api.registerCommand({
|
|
43
|
+
name: "card",
|
|
44
|
+
description: "Send a rich card message (LINE).",
|
|
45
|
+
acceptsArgs: true,
|
|
46
|
+
requireAuth: false,
|
|
47
|
+
async handler(ctx) {
|
|
48
|
+
const command = await loadLineCardCommand(api);
|
|
49
|
+
return await command.handler(ctx);
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
},
|
|
53
|
+
});
|
package/klaw.plugin.json
CHANGED
|
@@ -3,340 +3,13 @@
|
|
|
3
3
|
"activation": {
|
|
4
4
|
"onStartup": false
|
|
5
5
|
},
|
|
6
|
-
"channels": [
|
|
7
|
-
"line"
|
|
8
|
-
],
|
|
6
|
+
"channels": ["line"],
|
|
9
7
|
"channelEnvVars": {
|
|
10
|
-
"line": [
|
|
11
|
-
"LINE_CHANNEL_ACCESS_TOKEN",
|
|
12
|
-
"LINE_CHANNEL_SECRET"
|
|
13
|
-
]
|
|
8
|
+
"line": ["LINE_CHANNEL_ACCESS_TOKEN", "LINE_CHANNEL_SECRET"]
|
|
14
9
|
},
|
|
15
10
|
"configSchema": {
|
|
16
11
|
"type": "object",
|
|
17
12
|
"additionalProperties": false,
|
|
18
13
|
"properties": {}
|
|
19
|
-
},
|
|
20
|
-
"channelConfigs": {
|
|
21
|
-
"line": {
|
|
22
|
-
"schema": {
|
|
23
|
-
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
24
|
-
"type": "object",
|
|
25
|
-
"properties": {
|
|
26
|
-
"enabled": {
|
|
27
|
-
"type": "boolean"
|
|
28
|
-
},
|
|
29
|
-
"channelAccessToken": {
|
|
30
|
-
"type": "string"
|
|
31
|
-
},
|
|
32
|
-
"channelSecret": {
|
|
33
|
-
"type": "string"
|
|
34
|
-
},
|
|
35
|
-
"tokenFile": {
|
|
36
|
-
"type": "string"
|
|
37
|
-
},
|
|
38
|
-
"secretFile": {
|
|
39
|
-
"type": "string"
|
|
40
|
-
},
|
|
41
|
-
"name": {
|
|
42
|
-
"type": "string"
|
|
43
|
-
},
|
|
44
|
-
"allowFrom": {
|
|
45
|
-
"type": "array",
|
|
46
|
-
"items": {
|
|
47
|
-
"anyOf": [
|
|
48
|
-
{
|
|
49
|
-
"type": "string"
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
"type": "number"
|
|
53
|
-
}
|
|
54
|
-
]
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
|
-
"groupAllowFrom": {
|
|
58
|
-
"type": "array",
|
|
59
|
-
"items": {
|
|
60
|
-
"anyOf": [
|
|
61
|
-
{
|
|
62
|
-
"type": "string"
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
"type": "number"
|
|
66
|
-
}
|
|
67
|
-
]
|
|
68
|
-
}
|
|
69
|
-
},
|
|
70
|
-
"dmPolicy": {
|
|
71
|
-
"default": "pairing",
|
|
72
|
-
"type": "string",
|
|
73
|
-
"enum": [
|
|
74
|
-
"open",
|
|
75
|
-
"allowlist",
|
|
76
|
-
"pairing",
|
|
77
|
-
"disabled"
|
|
78
|
-
]
|
|
79
|
-
},
|
|
80
|
-
"groupPolicy": {
|
|
81
|
-
"default": "allowlist",
|
|
82
|
-
"type": "string",
|
|
83
|
-
"enum": [
|
|
84
|
-
"open",
|
|
85
|
-
"allowlist",
|
|
86
|
-
"disabled"
|
|
87
|
-
]
|
|
88
|
-
},
|
|
89
|
-
"responsePrefix": {
|
|
90
|
-
"type": "string"
|
|
91
|
-
},
|
|
92
|
-
"mediaMaxMb": {
|
|
93
|
-
"type": "number"
|
|
94
|
-
},
|
|
95
|
-
"webhookPath": {
|
|
96
|
-
"type": "string"
|
|
97
|
-
},
|
|
98
|
-
"threadBindings": {
|
|
99
|
-
"type": "object",
|
|
100
|
-
"properties": {
|
|
101
|
-
"enabled": {
|
|
102
|
-
"type": "boolean"
|
|
103
|
-
},
|
|
104
|
-
"idleHours": {
|
|
105
|
-
"type": "number"
|
|
106
|
-
},
|
|
107
|
-
"maxAgeHours": {
|
|
108
|
-
"type": "number"
|
|
109
|
-
},
|
|
110
|
-
"spawnSessions": {
|
|
111
|
-
"type": "boolean"
|
|
112
|
-
},
|
|
113
|
-
"defaultSpawnContext": {
|
|
114
|
-
"type": "string",
|
|
115
|
-
"enum": [
|
|
116
|
-
"isolated",
|
|
117
|
-
"fork"
|
|
118
|
-
]
|
|
119
|
-
},
|
|
120
|
-
"spawnSubagentSessions": {
|
|
121
|
-
"type": "boolean"
|
|
122
|
-
},
|
|
123
|
-
"spawnAcpSessions": {
|
|
124
|
-
"type": "boolean"
|
|
125
|
-
}
|
|
126
|
-
},
|
|
127
|
-
"additionalProperties": false
|
|
128
|
-
},
|
|
129
|
-
"accounts": {
|
|
130
|
-
"type": "object",
|
|
131
|
-
"propertyNames": {
|
|
132
|
-
"type": "string"
|
|
133
|
-
},
|
|
134
|
-
"additionalProperties": {
|
|
135
|
-
"type": "object",
|
|
136
|
-
"properties": {
|
|
137
|
-
"enabled": {
|
|
138
|
-
"type": "boolean"
|
|
139
|
-
},
|
|
140
|
-
"channelAccessToken": {
|
|
141
|
-
"type": "string"
|
|
142
|
-
},
|
|
143
|
-
"channelSecret": {
|
|
144
|
-
"type": "string"
|
|
145
|
-
},
|
|
146
|
-
"tokenFile": {
|
|
147
|
-
"type": "string"
|
|
148
|
-
},
|
|
149
|
-
"secretFile": {
|
|
150
|
-
"type": "string"
|
|
151
|
-
},
|
|
152
|
-
"name": {
|
|
153
|
-
"type": "string"
|
|
154
|
-
},
|
|
155
|
-
"allowFrom": {
|
|
156
|
-
"type": "array",
|
|
157
|
-
"items": {
|
|
158
|
-
"anyOf": [
|
|
159
|
-
{
|
|
160
|
-
"type": "string"
|
|
161
|
-
},
|
|
162
|
-
{
|
|
163
|
-
"type": "number"
|
|
164
|
-
}
|
|
165
|
-
]
|
|
166
|
-
}
|
|
167
|
-
},
|
|
168
|
-
"groupAllowFrom": {
|
|
169
|
-
"type": "array",
|
|
170
|
-
"items": {
|
|
171
|
-
"anyOf": [
|
|
172
|
-
{
|
|
173
|
-
"type": "string"
|
|
174
|
-
},
|
|
175
|
-
{
|
|
176
|
-
"type": "number"
|
|
177
|
-
}
|
|
178
|
-
]
|
|
179
|
-
}
|
|
180
|
-
},
|
|
181
|
-
"dmPolicy": {
|
|
182
|
-
"default": "pairing",
|
|
183
|
-
"type": "string",
|
|
184
|
-
"enum": [
|
|
185
|
-
"open",
|
|
186
|
-
"allowlist",
|
|
187
|
-
"pairing",
|
|
188
|
-
"disabled"
|
|
189
|
-
]
|
|
190
|
-
},
|
|
191
|
-
"groupPolicy": {
|
|
192
|
-
"default": "allowlist",
|
|
193
|
-
"type": "string",
|
|
194
|
-
"enum": [
|
|
195
|
-
"open",
|
|
196
|
-
"allowlist",
|
|
197
|
-
"disabled"
|
|
198
|
-
]
|
|
199
|
-
},
|
|
200
|
-
"responsePrefix": {
|
|
201
|
-
"type": "string"
|
|
202
|
-
},
|
|
203
|
-
"mediaMaxMb": {
|
|
204
|
-
"type": "number"
|
|
205
|
-
},
|
|
206
|
-
"webhookPath": {
|
|
207
|
-
"type": "string"
|
|
208
|
-
},
|
|
209
|
-
"threadBindings": {
|
|
210
|
-
"type": "object",
|
|
211
|
-
"properties": {
|
|
212
|
-
"enabled": {
|
|
213
|
-
"type": "boolean"
|
|
214
|
-
},
|
|
215
|
-
"idleHours": {
|
|
216
|
-
"type": "number"
|
|
217
|
-
},
|
|
218
|
-
"maxAgeHours": {
|
|
219
|
-
"type": "number"
|
|
220
|
-
},
|
|
221
|
-
"spawnSessions": {
|
|
222
|
-
"type": "boolean"
|
|
223
|
-
},
|
|
224
|
-
"defaultSpawnContext": {
|
|
225
|
-
"type": "string",
|
|
226
|
-
"enum": [
|
|
227
|
-
"isolated",
|
|
228
|
-
"fork"
|
|
229
|
-
]
|
|
230
|
-
},
|
|
231
|
-
"spawnSubagentSessions": {
|
|
232
|
-
"type": "boolean"
|
|
233
|
-
},
|
|
234
|
-
"spawnAcpSessions": {
|
|
235
|
-
"type": "boolean"
|
|
236
|
-
}
|
|
237
|
-
},
|
|
238
|
-
"additionalProperties": false
|
|
239
|
-
},
|
|
240
|
-
"groups": {
|
|
241
|
-
"type": "object",
|
|
242
|
-
"propertyNames": {
|
|
243
|
-
"type": "string"
|
|
244
|
-
},
|
|
245
|
-
"additionalProperties": {
|
|
246
|
-
"type": "object",
|
|
247
|
-
"properties": {
|
|
248
|
-
"enabled": {
|
|
249
|
-
"type": "boolean"
|
|
250
|
-
},
|
|
251
|
-
"allowFrom": {
|
|
252
|
-
"type": "array",
|
|
253
|
-
"items": {
|
|
254
|
-
"anyOf": [
|
|
255
|
-
{
|
|
256
|
-
"type": "string"
|
|
257
|
-
},
|
|
258
|
-
{
|
|
259
|
-
"type": "number"
|
|
260
|
-
}
|
|
261
|
-
]
|
|
262
|
-
}
|
|
263
|
-
},
|
|
264
|
-
"requireMention": {
|
|
265
|
-
"type": "boolean"
|
|
266
|
-
},
|
|
267
|
-
"systemPrompt": {
|
|
268
|
-
"type": "string"
|
|
269
|
-
},
|
|
270
|
-
"skills": {
|
|
271
|
-
"type": "array",
|
|
272
|
-
"items": {
|
|
273
|
-
"type": "string"
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
},
|
|
277
|
-
"additionalProperties": false
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
},
|
|
281
|
-
"required": [
|
|
282
|
-
"dmPolicy",
|
|
283
|
-
"groupPolicy"
|
|
284
|
-
],
|
|
285
|
-
"additionalProperties": false
|
|
286
|
-
}
|
|
287
|
-
},
|
|
288
|
-
"defaultAccount": {
|
|
289
|
-
"type": "string"
|
|
290
|
-
},
|
|
291
|
-
"groups": {
|
|
292
|
-
"type": "object",
|
|
293
|
-
"propertyNames": {
|
|
294
|
-
"type": "string"
|
|
295
|
-
},
|
|
296
|
-
"additionalProperties": {
|
|
297
|
-
"type": "object",
|
|
298
|
-
"properties": {
|
|
299
|
-
"enabled": {
|
|
300
|
-
"type": "boolean"
|
|
301
|
-
},
|
|
302
|
-
"allowFrom": {
|
|
303
|
-
"type": "array",
|
|
304
|
-
"items": {
|
|
305
|
-
"anyOf": [
|
|
306
|
-
{
|
|
307
|
-
"type": "string"
|
|
308
|
-
},
|
|
309
|
-
{
|
|
310
|
-
"type": "number"
|
|
311
|
-
}
|
|
312
|
-
]
|
|
313
|
-
}
|
|
314
|
-
},
|
|
315
|
-
"requireMention": {
|
|
316
|
-
"type": "boolean"
|
|
317
|
-
},
|
|
318
|
-
"systemPrompt": {
|
|
319
|
-
"type": "string"
|
|
320
|
-
},
|
|
321
|
-
"skills": {
|
|
322
|
-
"type": "array",
|
|
323
|
-
"items": {
|
|
324
|
-
"type": "string"
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
},
|
|
328
|
-
"additionalProperties": false
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
},
|
|
332
|
-
"required": [
|
|
333
|
-
"dmPolicy",
|
|
334
|
-
"groupPolicy"
|
|
335
|
-
],
|
|
336
|
-
"additionalProperties": false
|
|
337
|
-
},
|
|
338
|
-
"label": "LINE",
|
|
339
|
-
"description": "LINE Messaging API webhook bot."
|
|
340
|
-
}
|
|
341
14
|
}
|
|
342
15
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kodelyth/line",
|
|
3
|
-
"version": "2026.5.
|
|
3
|
+
"version": "2026.5.42",
|
|
4
4
|
"description": "Klaw LINE channel plugin",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
15
|
"@kodelyth/plugin-sdk": "1.0.1",
|
|
16
|
-
"@kodelyth/klaw": "2026.5.
|
|
16
|
+
"@kodelyth/klaw": "2026.5.42"
|
|
17
17
|
},
|
|
18
18
|
"peerDependencies": {
|
|
19
19
|
"@kodelyth/klaw": ">=2026.5.19"
|
|
@@ -25,9 +25,9 @@
|
|
|
25
25
|
},
|
|
26
26
|
"klaw": {
|
|
27
27
|
"extensions": [
|
|
28
|
-
"./index.
|
|
28
|
+
"./index.ts"
|
|
29
29
|
],
|
|
30
|
-
"setupEntry": "./setup-entry.
|
|
30
|
+
"setupEntry": "./setup-entry.ts",
|
|
31
31
|
"channel": {
|
|
32
32
|
"id": "line",
|
|
33
33
|
"label": "LINE",
|