@gakr-gakr/line 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/autobot.plugin.json +329 -2
  2. package/dist/accounts-iYDb5rCF.js +105 -0
  3. package/dist/api.js +11 -0
  4. package/dist/basic-cards-BISytiSa.js +307 -0
  5. package/dist/card-command-ClPV_2Pv.js +240 -0
  6. package/dist/channel-DiGZGSCs.js +649 -0
  7. package/dist/channel-plugin-api.js +2 -0
  8. package/dist/channel.runtime-MtUBCnpZ.js +4 -0
  9. package/dist/contract-api.js +2 -0
  10. package/dist/index.js +45 -0
  11. package/dist/markdown-to-line-C_SjIW6w.js +810 -0
  12. package/dist/monitor-DvzJLJH3.js +1485 -0
  13. package/dist/monitor.runtime-D9vYRoT9.js +2 -0
  14. package/dist/outbound.runtime-CW6t8VaR.js +2 -0
  15. package/dist/probe-CBAVL6_q.js +30 -0
  16. package/dist/probe.runtime-B6T5QA0x.js +2 -0
  17. package/dist/reply-payload-transform-BP3Ty1Jo.js +855 -0
  18. package/dist/runtime-api.js +291 -0
  19. package/dist/schedule-cards-D-yZMHDE.js +359 -0
  20. package/dist/secret-contract-api.js +5 -0
  21. package/dist/setup-api.js +2 -0
  22. package/dist/setup-entry.js +11 -0
  23. package/dist/setup-surface-CDqPUXaa.js +282 -0
  24. package/package.json +16 -4
  25. package/api.ts +0 -11
  26. package/channel-plugin-api.ts +0 -1
  27. package/contract-api.ts +0 -5
  28. package/index.ts +0 -54
  29. package/runtime-api.ts +0 -182
  30. package/secret-contract-api.ts +0 -4
  31. package/setup-api.ts +0 -2
  32. package/setup-entry.ts +0 -9
  33. package/src/account-helpers.ts +0 -16
  34. package/src/accounts.ts +0 -187
  35. package/src/actions.ts +0 -61
  36. package/src/auto-reply-delivery.ts +0 -200
  37. package/src/bindings.ts +0 -65
  38. package/src/bot-access.ts +0 -30
  39. package/src/bot-handlers.ts +0 -620
  40. package/src/bot-message-context.ts +0 -586
  41. package/src/bot.ts +0 -70
  42. package/src/card-command.ts +0 -347
  43. package/src/channel-access-token.ts +0 -14
  44. package/src/channel-api.ts +0 -17
  45. package/src/channel-shared.ts +0 -48
  46. package/src/channel.runtime.ts +0 -3
  47. package/src/channel.setup.ts +0 -11
  48. package/src/channel.ts +0 -155
  49. package/src/config-adapter.ts +0 -29
  50. package/src/config-schema.ts +0 -81
  51. package/src/download.ts +0 -34
  52. package/src/flex-templates/basic-cards.ts +0 -395
  53. package/src/flex-templates/common.ts +0 -20
  54. package/src/flex-templates/media-control-cards.ts +0 -555
  55. package/src/flex-templates/message.ts +0 -13
  56. package/src/flex-templates/schedule-cards.ts +0 -467
  57. package/src/flex-templates/types.ts +0 -22
  58. package/src/flex-templates.ts +0 -32
  59. package/src/gateway.ts +0 -129
  60. package/src/group-keys.ts +0 -65
  61. package/src/group-policy.ts +0 -22
  62. package/src/markdown-to-line.ts +0 -416
  63. package/src/monitor-durable.ts +0 -37
  64. package/src/monitor.runtime.ts +0 -1
  65. package/src/monitor.ts +0 -507
  66. package/src/outbound-media.ts +0 -120
  67. package/src/outbound.runtime.ts +0 -12
  68. package/src/outbound.ts +0 -427
  69. package/src/probe.runtime.ts +0 -1
  70. package/src/probe.ts +0 -34
  71. package/src/quick-reply-fallback.ts +0 -10
  72. package/src/reply-chunks.ts +0 -110
  73. package/src/reply-payload-transform.ts +0 -317
  74. package/src/rich-menu.ts +0 -326
  75. package/src/runtime.ts +0 -32
  76. package/src/send-receipt.ts +0 -32
  77. package/src/send.ts +0 -531
  78. package/src/setup-core.ts +0 -149
  79. package/src/setup-runtime-api.ts +0 -9
  80. package/src/setup-surface.ts +0 -229
  81. package/src/signature.ts +0 -24
  82. package/src/status.ts +0 -37
  83. package/src/template-messages.ts +0 -333
  84. package/src/types.ts +0 -130
  85. package/src/webhook-node.ts +0 -155
  86. package/src/webhook-utils.ts +0 -10
  87. package/src/webhook.ts +0 -135
  88. package/tsconfig.json +0 -16
@@ -3,13 +3,340 @@
3
3
  "activation": {
4
4
  "onStartup": false
5
5
  },
6
- "channels": ["line"],
6
+ "channels": [
7
+ "line"
8
+ ],
7
9
  "channelEnvVars": {
8
- "line": ["LINE_CHANNEL_ACCESS_TOKEN", "LINE_CHANNEL_SECRET"]
10
+ "line": [
11
+ "LINE_CHANNEL_ACCESS_TOKEN",
12
+ "LINE_CHANNEL_SECRET"
13
+ ]
9
14
  },
10
15
  "configSchema": {
11
16
  "type": "object",
12
17
  "additionalProperties": false,
13
18
  "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
+ }
14
341
  }
15
342
  }
@@ -0,0 +1,105 @@
1
+ import { DEFAULT_ACCOUNT_ID, normalizeAccountId, normalizeOptionalAccountId } from "autobot/plugin-sdk/account-id";
2
+ import { resolveAccountEntry } from "autobot/plugin-sdk/account-resolution";
3
+ import { tryReadSecretFileSync } from "autobot/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 = accountId !== DEFAULT_ACCOUNT_ID ? resolveAccountEntry(accounts, accountId) : void 0;
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 enabled = accountConfig?.enabled ?? (accountId === DEFAULT_ACCOUNT_ID ? lineConfig?.enabled ?? true : false);
76
+ return {
77
+ accountId,
78
+ name: accountConfig?.name ?? (accountId === DEFAULT_ACCOUNT_ID ? lineConfig?.name : void 0),
79
+ enabled,
80
+ channelAccessToken: token,
81
+ channelSecret: secret,
82
+ tokenSource,
83
+ config: mergedConfig
84
+ };
85
+ }
86
+ function listLineAccountIds(cfg) {
87
+ const lineConfig = cfg.channels?.line;
88
+ const accounts = lineConfig?.accounts;
89
+ const ids = /* @__PURE__ */ new Set();
90
+ if (lineConfig?.channelAccessToken?.trim() || lineConfig?.tokenFile || process.env.LINE_CHANNEL_ACCESS_TOKEN?.trim()) ids.add(DEFAULT_ACCOUNT_ID);
91
+ if (accounts) for (const id of Object.keys(accounts)) ids.add(id);
92
+ return Array.from(ids);
93
+ }
94
+ function resolveDefaultLineAccountId(cfg) {
95
+ const preferred = normalizeOptionalAccountId((cfg.channels?.line)?.defaultAccount);
96
+ if (preferred && listLineAccountIds(cfg).some((accountId) => normalizeAccountId(accountId) === preferred)) return preferred;
97
+ const ids = listLineAccountIds(cfg);
98
+ if (ids.includes(DEFAULT_ACCOUNT_ID)) return DEFAULT_ACCOUNT_ID;
99
+ return ids[0] ?? DEFAULT_ACCOUNT_ID;
100
+ }
101
+ function normalizeAccountId$1(accountId) {
102
+ return normalizeAccountId(accountId);
103
+ }
104
+ //#endregion
105
+ export { resolveLineAccount as i, normalizeAccountId$1 as n, resolveDefaultLineAccountId as r, listLineAccountIds as t };
package/dist/api.js ADDED
@@ -0,0 +1,11 @@
1
+ import { n as lineChannelPluginCommon, t as linePlugin } from "./channel-DiGZGSCs.js";
2
+ import { n as lineSetupAdapter, t as lineSetupWizard } from "./setup-surface-CDqPUXaa.js";
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 { linePlugin, lineSetupPlugin };