@elizaos/plugin-line 2.0.0-beta.1 → 2.0.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.
- package/LICENSE +21 -0
- package/README.md +3 -3
- package/package.json +22 -6
- package/dist/accounts.d.ts +0 -152
- package/dist/accounts.d.ts.map +0 -1
- package/dist/accounts.js +0 -258
- package/dist/accounts.js.map +0 -1
- package/dist/actions/index.d.ts +0 -1
- package/dist/actions/index.d.ts.map +0 -1
- package/dist/actions/index.js +0 -3
- package/dist/actions/index.js.map +0 -1
- package/dist/connector-account-provider.d.ts +0 -16
- package/dist/connector-account-provider.d.ts.map +0 -1
- package/dist/connector-account-provider.js +0 -82
- package/dist/connector-account-provider.js.map +0 -1
- package/dist/index.d.ts +0 -18
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -60
- package/dist/index.js.map +0 -1
- package/dist/messaging.d.ts +0 -142
- package/dist/messaging.d.ts.map +0 -1
- package/dist/messaging.js +0 -357
- package/dist/messaging.js.map +0 -1
- package/dist/providers/index.d.ts +0 -7
- package/dist/providers/index.d.ts.map +0 -1
- package/dist/providers/index.js +0 -8
- package/dist/providers/index.js.map +0 -1
- package/dist/service.d.ts +0 -110
- package/dist/service.d.ts.map +0 -1
- package/dist/service.js +0 -766
- package/dist/service.js.map +0 -1
- package/dist/types.d.ts +0 -279
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -106
- package/dist/types.js.map +0 -1
- package/dist/workflow-credential-provider.d.ts +0 -21
- package/dist/workflow-credential-provider.d.ts.map +0 -1
- package/dist/workflow-credential-provider.js +0 -32
- package/dist/workflow-credential-provider.js.map +0 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Shaw Walters and elizaOS Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @elizaos/plugin-line
|
|
2
2
|
|
|
3
|
-
LINE Messaging API plugin for
|
|
3
|
+
LINE Messaging API plugin for elizaOS agents. Enables chatbot integration with LINE, a popular messaging platform in Japan, Taiwan, and Thailand.
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
@@ -154,13 +154,13 @@ const flexMessage = {
|
|
|
154
154
|
### Building
|
|
155
155
|
|
|
156
156
|
```bash
|
|
157
|
-
|
|
157
|
+
bun run --cwd plugins/plugin-line build
|
|
158
158
|
```
|
|
159
159
|
|
|
160
160
|
### Testing
|
|
161
161
|
|
|
162
162
|
```bash
|
|
163
|
-
|
|
163
|
+
bun run --cwd plugins/plugin-line test
|
|
164
164
|
```
|
|
165
165
|
|
|
166
166
|
## API Reference
|
package/package.json
CHANGED
|
@@ -1,14 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elizaos/plugin-line",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.3-beta.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": {
|
|
9
9
|
"types": "./dist/index.d.ts",
|
|
10
|
+
"eliza-source": {
|
|
11
|
+
"types": "./src/index.ts",
|
|
12
|
+
"import": "./src/index.ts",
|
|
13
|
+
"default": "./src/index.ts"
|
|
14
|
+
},
|
|
10
15
|
"import": "./dist/index.js",
|
|
11
16
|
"default": "./dist/index.js"
|
|
17
|
+
},
|
|
18
|
+
"./*.css": "./dist/*.css",
|
|
19
|
+
"./*": {
|
|
20
|
+
"types": "./dist/*.d.ts",
|
|
21
|
+
"eliza-source": {
|
|
22
|
+
"types": "./src/*.ts",
|
|
23
|
+
"import": "./src/*.ts",
|
|
24
|
+
"default": "./src/*.ts"
|
|
25
|
+
},
|
|
26
|
+
"import": "./dist/*.js",
|
|
27
|
+
"default": "./dist/*.js"
|
|
12
28
|
}
|
|
13
29
|
},
|
|
14
30
|
"files": [
|
|
@@ -22,12 +38,11 @@
|
|
|
22
38
|
"lint:check": "bunx @biomejs/biome check .",
|
|
23
39
|
"format": "bunx @biomejs/biome format --write .",
|
|
24
40
|
"format:check": "bunx @biomejs/biome format .",
|
|
25
|
-
"typecheck": "
|
|
41
|
+
"typecheck": "tsgo --noEmit"
|
|
26
42
|
},
|
|
27
43
|
"dependencies": {
|
|
28
|
-
"@elizaos/core": "2.0.
|
|
29
|
-
"@line/bot-sdk": "^11.0.0"
|
|
30
|
-
"zod": "^4.4.3"
|
|
44
|
+
"@elizaos/core": "2.0.3-beta.2",
|
|
45
|
+
"@line/bot-sdk": "^11.0.0"
|
|
31
46
|
},
|
|
32
47
|
"devDependencies": {
|
|
33
48
|
"@biomejs/biome": "^2.4.14",
|
|
@@ -92,5 +107,6 @@
|
|
|
92
107
|
"sensitive": false
|
|
93
108
|
}
|
|
94
109
|
}
|
|
95
|
-
}
|
|
110
|
+
},
|
|
111
|
+
"gitHead": "82fe0f44215954c2417328203f5bd6510985c1fc"
|
|
96
112
|
}
|
package/dist/accounts.d.ts
DELETED
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
import type { IAgentRuntime } from "@elizaos/core";
|
|
2
|
-
/**
|
|
3
|
-
* Default account identifier used when no specific account is configured
|
|
4
|
-
*/
|
|
5
|
-
export declare const DEFAULT_ACCOUNT_ID = "default";
|
|
6
|
-
/**
|
|
7
|
-
* Token source indicator
|
|
8
|
-
*/
|
|
9
|
-
export type LineTokenSource = "config" | "env" | "character" | "none";
|
|
10
|
-
/**
|
|
11
|
-
* Group-specific configuration
|
|
12
|
-
*/
|
|
13
|
-
export interface LineGroupConfig {
|
|
14
|
-
/** If false, ignore messages from this group */
|
|
15
|
-
enabled?: boolean;
|
|
16
|
-
/** Allowlist for users in this group */
|
|
17
|
-
allowFrom?: Array<string | number>;
|
|
18
|
-
/** Require bot mention to respond */
|
|
19
|
-
requireMention?: boolean;
|
|
20
|
-
/** Custom system prompt for this group */
|
|
21
|
-
systemPrompt?: string;
|
|
22
|
-
/** Skills enabled for this group */
|
|
23
|
-
skills?: string[];
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Configuration for a single LINE account
|
|
27
|
-
*/
|
|
28
|
-
export interface LineAccountConfig {
|
|
29
|
-
/** Optional display name for this account */
|
|
30
|
-
name?: string;
|
|
31
|
-
/** If false, do not start this LINE account */
|
|
32
|
-
enabled?: boolean;
|
|
33
|
-
/** Channel access token */
|
|
34
|
-
channelAccessToken?: string;
|
|
35
|
-
/** Channel secret */
|
|
36
|
-
channelSecret?: string;
|
|
37
|
-
/** Path to file containing channel access token */
|
|
38
|
-
tokenFile?: string;
|
|
39
|
-
/** Path to file containing channel secret */
|
|
40
|
-
secretFile?: string;
|
|
41
|
-
/** Allowlist for DM senders */
|
|
42
|
-
allowFrom?: Array<string | number>;
|
|
43
|
-
/** Allowlist for groups */
|
|
44
|
-
groupAllowFrom?: Array<string | number>;
|
|
45
|
-
/** DM access policy */
|
|
46
|
-
dmPolicy?: "open" | "allowlist" | "pairing" | "disabled";
|
|
47
|
-
/** Group message access policy */
|
|
48
|
-
groupPolicy?: "open" | "allowlist" | "disabled";
|
|
49
|
-
/** Max media size in MB */
|
|
50
|
-
mediaMaxMb?: number;
|
|
51
|
-
/** Custom webhook path */
|
|
52
|
-
webhookPath?: string;
|
|
53
|
-
/** Group-specific configurations */
|
|
54
|
-
groups?: Record<string, LineGroupConfig>;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Multi-account LINE configuration structure
|
|
58
|
-
*/
|
|
59
|
-
export interface LineMultiAccountConfig {
|
|
60
|
-
/** Default/base configuration applied to all accounts */
|
|
61
|
-
enabled?: boolean;
|
|
62
|
-
channelAccessToken?: string;
|
|
63
|
-
channelSecret?: string;
|
|
64
|
-
tokenFile?: string;
|
|
65
|
-
secretFile?: string;
|
|
66
|
-
dmPolicy?: "open" | "allowlist" | "pairing" | "disabled";
|
|
67
|
-
groupPolicy?: "open" | "allowlist" | "disabled";
|
|
68
|
-
mediaMaxMb?: number;
|
|
69
|
-
webhookPath?: string;
|
|
70
|
-
/** Per-account configuration overrides */
|
|
71
|
-
accounts?: Record<string, LineAccountConfig>;
|
|
72
|
-
/** Group configurations at base level */
|
|
73
|
-
groups?: Record<string, LineGroupConfig>;
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Token resolution result
|
|
77
|
-
*/
|
|
78
|
-
export interface LineTokenResolution {
|
|
79
|
-
token: string;
|
|
80
|
-
source: LineTokenSource;
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Resolved LINE account with all configuration merged
|
|
84
|
-
*/
|
|
85
|
-
export interface ResolvedLineAccount {
|
|
86
|
-
accountId: string;
|
|
87
|
-
enabled: boolean;
|
|
88
|
-
name?: string;
|
|
89
|
-
channelAccessToken: string;
|
|
90
|
-
channelSecret: string;
|
|
91
|
-
tokenSource: LineTokenSource;
|
|
92
|
-
configured: boolean;
|
|
93
|
-
config: LineAccountConfig;
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Normalizes an account ID, returning the default if not provided
|
|
97
|
-
*/
|
|
98
|
-
export declare function normalizeAccountId(accountId?: string | null): string;
|
|
99
|
-
/**
|
|
100
|
-
* Gets the multi-account configuration from runtime settings
|
|
101
|
-
*/
|
|
102
|
-
export declare function getMultiAccountConfig(runtime: IAgentRuntime): LineMultiAccountConfig;
|
|
103
|
-
/**
|
|
104
|
-
* Lists all configured account IDs
|
|
105
|
-
*/
|
|
106
|
-
export declare function listLineAccountIds(runtime: IAgentRuntime): string[];
|
|
107
|
-
/**
|
|
108
|
-
* Resolves the default account ID to use
|
|
109
|
-
*/
|
|
110
|
-
export declare function resolveDefaultLineAccountId(runtime: IAgentRuntime): string;
|
|
111
|
-
/**
|
|
112
|
-
* Resolves the channel access token for a LINE account
|
|
113
|
-
*/
|
|
114
|
-
export declare function resolveLineToken(runtime: IAgentRuntime, accountId: string): LineTokenResolution;
|
|
115
|
-
/**
|
|
116
|
-
* Resolves the channel secret for a LINE account
|
|
117
|
-
*/
|
|
118
|
-
export declare function resolveLineSecret(runtime: IAgentRuntime, accountId: string): string;
|
|
119
|
-
/**
|
|
120
|
-
* Resolves a complete LINE account configuration
|
|
121
|
-
*/
|
|
122
|
-
export declare function resolveLineAccount(runtime: IAgentRuntime, accountId?: string | null): ResolvedLineAccount;
|
|
123
|
-
/**
|
|
124
|
-
* Lists all enabled LINE accounts
|
|
125
|
-
*/
|
|
126
|
-
export declare function listEnabledLineAccounts(runtime: IAgentRuntime): ResolvedLineAccount[];
|
|
127
|
-
/**
|
|
128
|
-
* Checks if multi-account mode is enabled
|
|
129
|
-
*/
|
|
130
|
-
export declare function isMultiAccountEnabled(runtime: IAgentRuntime): boolean;
|
|
131
|
-
/**
|
|
132
|
-
* Resolves group configuration for a specific group
|
|
133
|
-
*/
|
|
134
|
-
export declare function resolveLineGroupConfig(runtime: IAgentRuntime, accountId: string, groupId: string): LineGroupConfig | undefined;
|
|
135
|
-
/**
|
|
136
|
-
* Checks if a user is allowed based on policy and allowlist
|
|
137
|
-
*/
|
|
138
|
-
export declare function isLineUserAllowed(params: {
|
|
139
|
-
userId: string;
|
|
140
|
-
accountConfig: LineAccountConfig;
|
|
141
|
-
isGroup: boolean;
|
|
142
|
-
groupId?: string;
|
|
143
|
-
groupConfig?: LineGroupConfig;
|
|
144
|
-
}): boolean;
|
|
145
|
-
/**
|
|
146
|
-
* Checks if mention is required in a group
|
|
147
|
-
*/
|
|
148
|
-
export declare function isLineMentionRequired(params: {
|
|
149
|
-
accountConfig: LineAccountConfig;
|
|
150
|
-
groupConfig?: LineGroupConfig;
|
|
151
|
-
}): boolean;
|
|
152
|
-
//# sourceMappingURL=accounts.d.ts.map
|
package/dist/accounts.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"accounts.d.ts","sourceRoot":"","sources":["../src/accounts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnD;;GAEG;AACH,eAAO,MAAM,kBAAkB,YAAY,CAAC;AAE5C;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,QAAQ,GAAG,KAAK,GAAG,WAAW,GAAG,MAAM,CAAC;AAEtE;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,gDAAgD;IAChD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,wCAAwC;IACxC,SAAS,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC;IACnC,qCAAqC;IACrC,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,0CAA0C;IAC1C,YAAY,CAAC,E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E,SAAS,EAAE,MAAM,GAAG,MAAM,CAsBnF;AAmCD;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,aAAa,EACtB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,GACxB,mBAAmB,CAyBrB;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,aAAa,GAAG,mBAAmB,EAAE,CAIrF;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAGrE;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,aAAa,EACtB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,GACd,eAAe,GAAG,SAAS,CAY7B;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE;IACxC,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,iBAAiB,CAAC;IACjC,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,eAAe,CAAC;CAC/B,GAAG,OAAO,CA8CV;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE;IAC5C,aAAa,EAAE,iBAAiB,CAAC;IACjC,WAAW,CAAC,EAAE,eAAe,CAAC;CAC/B,GAAG,OAAO,CAGV"}
|
package/dist/accounts.js
DELETED
|
@@ -1,258 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Default account identifier used when no specific account is configured
|
|
3
|
-
*/
|
|
4
|
-
export const DEFAULT_ACCOUNT_ID = "default";
|
|
5
|
-
/**
|
|
6
|
-
* Normalizes an account ID, returning the default if not provided
|
|
7
|
-
*/
|
|
8
|
-
export function normalizeAccountId(accountId) {
|
|
9
|
-
if (!accountId || typeof accountId !== "string") {
|
|
10
|
-
return DEFAULT_ACCOUNT_ID;
|
|
11
|
-
}
|
|
12
|
-
const trimmed = accountId.trim().toLowerCase();
|
|
13
|
-
if (!trimmed || trimmed === "default") {
|
|
14
|
-
return DEFAULT_ACCOUNT_ID;
|
|
15
|
-
}
|
|
16
|
-
return trimmed;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Gets the multi-account configuration from runtime settings
|
|
20
|
-
*/
|
|
21
|
-
export function getMultiAccountConfig(runtime) {
|
|
22
|
-
const characterLine = runtime.character?.settings?.line;
|
|
23
|
-
return {
|
|
24
|
-
enabled: characterLine?.enabled,
|
|
25
|
-
channelAccessToken: characterLine?.channelAccessToken,
|
|
26
|
-
channelSecret: characterLine?.channelSecret,
|
|
27
|
-
tokenFile: characterLine?.tokenFile,
|
|
28
|
-
secretFile: characterLine?.secretFile,
|
|
29
|
-
dmPolicy: characterLine?.dmPolicy,
|
|
30
|
-
groupPolicy: characterLine?.groupPolicy,
|
|
31
|
-
mediaMaxMb: characterLine?.mediaMaxMb,
|
|
32
|
-
webhookPath: characterLine?.webhookPath,
|
|
33
|
-
accounts: characterLine?.accounts,
|
|
34
|
-
groups: characterLine?.groups,
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Lists all configured account IDs
|
|
39
|
-
*/
|
|
40
|
-
export function listLineAccountIds(runtime) {
|
|
41
|
-
const config = getMultiAccountConfig(runtime);
|
|
42
|
-
const accounts = config.accounts;
|
|
43
|
-
const ids = new Set();
|
|
44
|
-
// Add default account if configured at base level
|
|
45
|
-
const envToken = runtime.getSetting("LINE_CHANNEL_ACCESS_TOKEN");
|
|
46
|
-
if (config.channelAccessToken?.trim() || config.tokenFile || envToken?.trim()) {
|
|
47
|
-
ids.add(DEFAULT_ACCOUNT_ID);
|
|
48
|
-
}
|
|
49
|
-
// Add named accounts
|
|
50
|
-
if (accounts && typeof accounts === "object") {
|
|
51
|
-
for (const id of Object.keys(accounts)) {
|
|
52
|
-
if (id) {
|
|
53
|
-
ids.add(id);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
const result = Array.from(ids);
|
|
58
|
-
if (result.length === 0) {
|
|
59
|
-
return [DEFAULT_ACCOUNT_ID];
|
|
60
|
-
}
|
|
61
|
-
return result.slice().sort((a, b) => a.localeCompare(b));
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Resolves the default account ID to use
|
|
65
|
-
*/
|
|
66
|
-
export function resolveDefaultLineAccountId(runtime) {
|
|
67
|
-
const ids = listLineAccountIds(runtime);
|
|
68
|
-
if (ids.includes(DEFAULT_ACCOUNT_ID)) {
|
|
69
|
-
return DEFAULT_ACCOUNT_ID;
|
|
70
|
-
}
|
|
71
|
-
return ids[0] ?? DEFAULT_ACCOUNT_ID;
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Gets the account-specific configuration
|
|
75
|
-
*/
|
|
76
|
-
function getAccountConfig(runtime, accountId) {
|
|
77
|
-
const config = getMultiAccountConfig(runtime);
|
|
78
|
-
const accounts = config.accounts;
|
|
79
|
-
if (!accounts || typeof accounts !== "object") {
|
|
80
|
-
return undefined;
|
|
81
|
-
}
|
|
82
|
-
return accounts[accountId];
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Resolves the channel access token for a LINE account
|
|
86
|
-
*/
|
|
87
|
-
export function resolveLineToken(runtime, accountId) {
|
|
88
|
-
const multiConfig = getMultiAccountConfig(runtime);
|
|
89
|
-
const accountConfig = getAccountConfig(runtime, accountId);
|
|
90
|
-
// Check account-level config first
|
|
91
|
-
if (accountConfig?.channelAccessToken?.trim()) {
|
|
92
|
-
return { token: accountConfig.channelAccessToken.trim(), source: "config" };
|
|
93
|
-
}
|
|
94
|
-
// For default account, check base config
|
|
95
|
-
if (accountId === DEFAULT_ACCOUNT_ID) {
|
|
96
|
-
if (multiConfig.channelAccessToken?.trim()) {
|
|
97
|
-
return { token: multiConfig.channelAccessToken.trim(), source: "config" };
|
|
98
|
-
}
|
|
99
|
-
// Check environment/runtime settings
|
|
100
|
-
const envToken = runtime.getSetting("LINE_CHANNEL_ACCESS_TOKEN");
|
|
101
|
-
if (envToken?.trim()) {
|
|
102
|
-
return { token: envToken.trim(), source: "env" };
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
return { token: "", source: "none" };
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Resolves the channel secret for a LINE account
|
|
109
|
-
*/
|
|
110
|
-
export function resolveLineSecret(runtime, accountId) {
|
|
111
|
-
const multiConfig = getMultiAccountConfig(runtime);
|
|
112
|
-
const accountConfig = getAccountConfig(runtime, accountId);
|
|
113
|
-
// Check account-level config first
|
|
114
|
-
if (accountConfig?.channelSecret?.trim()) {
|
|
115
|
-
return accountConfig.channelSecret.trim();
|
|
116
|
-
}
|
|
117
|
-
// For default account, check base config and env
|
|
118
|
-
if (accountId === DEFAULT_ACCOUNT_ID) {
|
|
119
|
-
if (multiConfig.channelSecret?.trim()) {
|
|
120
|
-
return multiConfig.channelSecret.trim();
|
|
121
|
-
}
|
|
122
|
-
const envSecret = runtime.getSetting("LINE_CHANNEL_SECRET");
|
|
123
|
-
if (envSecret?.trim()) {
|
|
124
|
-
return envSecret.trim();
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
return "";
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* Merges base configuration with account-specific overrides
|
|
131
|
-
*/
|
|
132
|
-
/**
|
|
133
|
-
* Removes undefined values from an object to prevent them from overwriting during spread
|
|
134
|
-
*/
|
|
135
|
-
function filterDefined(obj) {
|
|
136
|
-
return Object.fromEntries(Object.entries(obj).filter(([, v]) => v !== undefined));
|
|
137
|
-
}
|
|
138
|
-
function mergeLineAccountConfig(runtime, accountId) {
|
|
139
|
-
const multiConfig = getMultiAccountConfig(runtime);
|
|
140
|
-
const { accounts: _ignored, ...baseConfig } = multiConfig;
|
|
141
|
-
const accountConfig = getAccountConfig(runtime, accountId) ?? {};
|
|
142
|
-
// Get environment/runtime settings for the base config
|
|
143
|
-
const envDmPolicy = runtime.getSetting("LINE_DM_POLICY");
|
|
144
|
-
const envGroupPolicy = runtime.getSetting("LINE_GROUP_POLICY");
|
|
145
|
-
const envConfig = {
|
|
146
|
-
dmPolicy: envDmPolicy,
|
|
147
|
-
groupPolicy: envGroupPolicy,
|
|
148
|
-
};
|
|
149
|
-
// Merge order: env defaults < base config < account config
|
|
150
|
-
// Filter undefined values to prevent them from overwriting defined values
|
|
151
|
-
return {
|
|
152
|
-
...filterDefined(envConfig),
|
|
153
|
-
...filterDefined(baseConfig),
|
|
154
|
-
...filterDefined(accountConfig),
|
|
155
|
-
};
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* Resolves a complete LINE account configuration
|
|
159
|
-
*/
|
|
160
|
-
export function resolveLineAccount(runtime, accountId) {
|
|
161
|
-
const normalizedAccountId = normalizeAccountId(accountId);
|
|
162
|
-
const multiConfig = getMultiAccountConfig(runtime);
|
|
163
|
-
const baseEnabled = multiConfig.enabled !== false;
|
|
164
|
-
const merged = mergeLineAccountConfig(runtime, normalizedAccountId);
|
|
165
|
-
const accountEnabled = merged.enabled !== false;
|
|
166
|
-
const enabled = baseEnabled && accountEnabled;
|
|
167
|
-
const { token, source: tokenSource } = resolveLineToken(runtime, normalizedAccountId);
|
|
168
|
-
const secret = resolveLineSecret(runtime, normalizedAccountId);
|
|
169
|
-
// Determine if this account is actually configured
|
|
170
|
-
const configured = Boolean(token || secret);
|
|
171
|
-
return {
|
|
172
|
-
accountId: normalizedAccountId,
|
|
173
|
-
enabled,
|
|
174
|
-
name: merged.name?.trim() || undefined,
|
|
175
|
-
channelAccessToken: token,
|
|
176
|
-
channelSecret: secret,
|
|
177
|
-
tokenSource,
|
|
178
|
-
configured,
|
|
179
|
-
config: merged,
|
|
180
|
-
};
|
|
181
|
-
}
|
|
182
|
-
/**
|
|
183
|
-
* Lists all enabled LINE accounts
|
|
184
|
-
*/
|
|
185
|
-
export function listEnabledLineAccounts(runtime) {
|
|
186
|
-
return listLineAccountIds(runtime)
|
|
187
|
-
.map((accountId) => resolveLineAccount(runtime, accountId))
|
|
188
|
-
.filter((account) => account.enabled && account.configured);
|
|
189
|
-
}
|
|
190
|
-
/**
|
|
191
|
-
* Checks if multi-account mode is enabled
|
|
192
|
-
*/
|
|
193
|
-
export function isMultiAccountEnabled(runtime) {
|
|
194
|
-
const accounts = listEnabledLineAccounts(runtime);
|
|
195
|
-
return accounts.length > 1;
|
|
196
|
-
}
|
|
197
|
-
/**
|
|
198
|
-
* Resolves group configuration for a specific group
|
|
199
|
-
*/
|
|
200
|
-
export function resolveLineGroupConfig(runtime, accountId, groupId) {
|
|
201
|
-
const multiConfig = getMultiAccountConfig(runtime);
|
|
202
|
-
const accountConfig = getAccountConfig(runtime, accountId);
|
|
203
|
-
// Check account-level groups first
|
|
204
|
-
const accountGroup = accountConfig?.groups?.[groupId];
|
|
205
|
-
if (accountGroup) {
|
|
206
|
-
return accountGroup;
|
|
207
|
-
}
|
|
208
|
-
// Fall back to base-level groups
|
|
209
|
-
return multiConfig.groups?.[groupId];
|
|
210
|
-
}
|
|
211
|
-
/**
|
|
212
|
-
* Checks if a user is allowed based on policy and allowlist
|
|
213
|
-
*/
|
|
214
|
-
export function isLineUserAllowed(params) {
|
|
215
|
-
const { userId, accountConfig, isGroup, groupConfig } = params;
|
|
216
|
-
if (isGroup) {
|
|
217
|
-
const policy = accountConfig.groupPolicy ?? "allowlist";
|
|
218
|
-
if (policy === "disabled") {
|
|
219
|
-
return false;
|
|
220
|
-
}
|
|
221
|
-
if (policy === "open") {
|
|
222
|
-
return true;
|
|
223
|
-
}
|
|
224
|
-
// Check group-specific allowlist first
|
|
225
|
-
if (groupConfig?.allowFrom?.length) {
|
|
226
|
-
return groupConfig.allowFrom.some((allowed) => String(allowed) === userId);
|
|
227
|
-
}
|
|
228
|
-
// Check account-level group allowlist
|
|
229
|
-
if (accountConfig.groupAllowFrom?.length) {
|
|
230
|
-
return accountConfig.groupAllowFrom.some((allowed) => String(allowed) === userId);
|
|
231
|
-
}
|
|
232
|
-
return policy !== "allowlist";
|
|
233
|
-
}
|
|
234
|
-
// DM handling
|
|
235
|
-
const policy = accountConfig.dmPolicy ?? "pairing";
|
|
236
|
-
if (policy === "disabled") {
|
|
237
|
-
return false;
|
|
238
|
-
}
|
|
239
|
-
if (policy === "open") {
|
|
240
|
-
return true;
|
|
241
|
-
}
|
|
242
|
-
if (policy === "pairing") {
|
|
243
|
-
return true;
|
|
244
|
-
}
|
|
245
|
-
// Allowlist policy
|
|
246
|
-
if (accountConfig.allowFrom?.length) {
|
|
247
|
-
return accountConfig.allowFrom.some((allowed) => String(allowed) === userId);
|
|
248
|
-
}
|
|
249
|
-
return false;
|
|
250
|
-
}
|
|
251
|
-
/**
|
|
252
|
-
* Checks if mention is required in a group
|
|
253
|
-
*/
|
|
254
|
-
export function isLineMentionRequired(params) {
|
|
255
|
-
const { groupConfig } = params;
|
|
256
|
-
return groupConfig?.requireMention ?? false;
|
|
257
|
-
}
|
|
258
|
-
//# sourceMappingURL=accounts.js.map
|
package/dist/accounts.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"accounts.js","sourceRoot":"","sources":["../src/accounts.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,SAAS,CAAC;AAiG5C;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAC,SAAyB;IAC1D,IAAI,CAAC,SAAS,IAAI,OAAO,SAAS,KAAK,QAAQ,EAAE,CAAC;QAChD,OAAO,kBAAkB,CAAC;IAC5B,CAAC;IACD,MAAM,OAAO,GAAG,SAAS,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAC/C,IAAI,CAAC,OAAO,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QACtC,OAAO,kBAAkB,CAAC;IAC5B,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,qBAAqB,CAAC,OAAsB;IAC1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CAAC,OAAO,CAAC,KAAK,MAAM,CAAC,CAAC;QACpF,CAAC;QAED,OAAO,MAAM,KAAK,WAAW,CAAC;IAChC,CAAC;IAED,cAAc;IACd,MAAM,MAAM,GAAG,aAAa,CAAC,QAAQ,IAAI,SAAS,CAAC;IACnD,IAAI,MAAM,KAAK,UAAU,EAAE,CAAC;QAC1B,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,MAAM,KAAK,MAAM,EAAE,CAAC;QACtB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,mBAAmB;IACnB,IAAI,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,CAAC;QACpC,OAAO,aAAa,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,MAAM,CAAC,CAAC;IAC/E,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,qBAAqB,CAAC,MAGrC;IACC,MAAM,EAAE,WAAW,EAAE,GAAG,MAAM,CAAC;IAC/B,OAAO,WAAW,EAAE,cAAc,IAAI,KAAK,CAAC;AAC9C,CAAC"}
|
package/dist/actions/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/actions/index.ts"],"names":[],"mappings":""}
|
package/dist/actions/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/actions/index.ts"],"names":[],"mappings":";AAAA,yDAAyD"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* LINE ConnectorAccountManager provider.
|
|
3
|
-
*
|
|
4
|
-
* Adapts the existing multi-account scaffolding in `accounts.ts` to the
|
|
5
|
-
* `ConnectorAccountProvider` contract from
|
|
6
|
-
* `@elizaos/core/connectors/account-manager`.
|
|
7
|
-
*
|
|
8
|
-
* Source of truth for accounts is character settings (`character.settings.line`)
|
|
9
|
-
* plus env-var fallbacks (LINE_CHANNEL_ACCESS_TOKEN, LINE_CHANNEL_SECRET).
|
|
10
|
-
* `listAccounts` enumerates all configured/enabled accounts; single-account
|
|
11
|
-
* env-only deployments still surface as a `default` account.
|
|
12
|
-
*/
|
|
13
|
-
import type { ConnectorAccountProvider, IAgentRuntime } from "@elizaos/core";
|
|
14
|
-
export declare const LINE_PROVIDER_ID = "line";
|
|
15
|
-
export declare function createLineConnectorAccountProvider(runtime: IAgentRuntime): ConnectorAccountProvider;
|
|
16
|
-
//# sourceMappingURL=connector-account-provider.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"connector-account-provider.d.ts","sourceRoot":"","sources":["../src/connector-account-provider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAIV,wBAAwB,EACxB,aAAa,EACd,MAAM,eAAe,CAAC;AASvB,eAAO,MAAM,gBAAgB,SAAS,CAAC;AAsCvC,wBAAgB,kCAAkC,CAChD,OAAO,EAAE,aAAa,GACrB,wBAAwB,CAoC1B"}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* LINE ConnectorAccountManager provider.
|
|
3
|
-
*
|
|
4
|
-
* Adapts the existing multi-account scaffolding in `accounts.ts` to the
|
|
5
|
-
* `ConnectorAccountProvider` contract from
|
|
6
|
-
* `@elizaos/core/connectors/account-manager`.
|
|
7
|
-
*
|
|
8
|
-
* Source of truth for accounts is character settings (`character.settings.line`)
|
|
9
|
-
* plus env-var fallbacks (LINE_CHANNEL_ACCESS_TOKEN, LINE_CHANNEL_SECRET).
|
|
10
|
-
* `listAccounts` enumerates all configured/enabled accounts; single-account
|
|
11
|
-
* env-only deployments still surface as a `default` account.
|
|
12
|
-
*/
|
|
13
|
-
import { DEFAULT_ACCOUNT_ID, listEnabledLineAccounts, normalizeAccountId, resolveLineAccount, } from "./accounts.js";
|
|
14
|
-
export const LINE_PROVIDER_ID = "line";
|
|
15
|
-
function purposeForAccount(_account) {
|
|
16
|
-
return ["messaging"];
|
|
17
|
-
}
|
|
18
|
-
function accessGateForAccount(account) {
|
|
19
|
-
const dmPolicy = account.config?.dmPolicy;
|
|
20
|
-
if (dmPolicy === "pairing")
|
|
21
|
-
return "pairing";
|
|
22
|
-
if (dmPolicy === "disabled")
|
|
23
|
-
return "disabled";
|
|
24
|
-
return "open";
|
|
25
|
-
}
|
|
26
|
-
function roleForAccount(_account) {
|
|
27
|
-
// LINE channel access tokens are bot tokens, not user-OAuth.
|
|
28
|
-
return "AGENT";
|
|
29
|
-
}
|
|
30
|
-
function toConnectorAccount(account) {
|
|
31
|
-
const now = Date.now();
|
|
32
|
-
return {
|
|
33
|
-
id: normalizeAccountId(account.accountId),
|
|
34
|
-
provider: LINE_PROVIDER_ID,
|
|
35
|
-
label: account.name ?? account.accountId,
|
|
36
|
-
role: roleForAccount(account),
|
|
37
|
-
purpose: purposeForAccount(account),
|
|
38
|
-
accessGate: accessGateForAccount(account),
|
|
39
|
-
status: account.enabled && account.configured ? "connected" : "disabled",
|
|
40
|
-
createdAt: now,
|
|
41
|
-
updatedAt: now,
|
|
42
|
-
metadata: {
|
|
43
|
-
tokenSource: account.tokenSource,
|
|
44
|
-
dmPolicy: account.config?.dmPolicy ?? "open",
|
|
45
|
-
groupPolicy: account.config?.groupPolicy ?? "allowlist",
|
|
46
|
-
},
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
export function createLineConnectorAccountProvider(runtime) {
|
|
50
|
-
return {
|
|
51
|
-
provider: LINE_PROVIDER_ID,
|
|
52
|
-
label: "LINE",
|
|
53
|
-
listAccounts: async (_manager) => {
|
|
54
|
-
const enabled = listEnabledLineAccounts(runtime);
|
|
55
|
-
if (enabled.length > 0) {
|
|
56
|
-
return enabled.map(toConnectorAccount);
|
|
57
|
-
}
|
|
58
|
-
// Fall back to default account so single-account env-only deployments
|
|
59
|
-
// still surface in the manager. Status reflects token configuration.
|
|
60
|
-
const fallback = resolveLineAccount(runtime, DEFAULT_ACCOUNT_ID);
|
|
61
|
-
return [toConnectorAccount(fallback)];
|
|
62
|
-
},
|
|
63
|
-
createAccount: async (input, _manager) => {
|
|
64
|
-
return {
|
|
65
|
-
...input,
|
|
66
|
-
provider: LINE_PROVIDER_ID,
|
|
67
|
-
role: input.role ?? "AGENT",
|
|
68
|
-
purpose: input.purpose ?? ["messaging"],
|
|
69
|
-
accessGate: input.accessGate ?? "open",
|
|
70
|
-
status: input.status ?? "pending",
|
|
71
|
-
};
|
|
72
|
-
},
|
|
73
|
-
patchAccount: async (_accountId, patch, _manager) => {
|
|
74
|
-
return { ...patch, provider: LINE_PROVIDER_ID };
|
|
75
|
-
},
|
|
76
|
-
deleteAccount: async (_accountId, _manager) => {
|
|
77
|
-
// No-op at provider layer — runtime credentials live in character
|
|
78
|
-
// settings; deletion of those is out of band.
|
|
79
|
-
},
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
//# sourceMappingURL=connector-account-provider.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"connector-account-provider.js","sourceRoot":"","sources":["../src/connector-account-provider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AASH,OAAO,EACL,kBAAkB,EAClB,uBAAuB,EACvB,kBAAkB,EAElB,kBAAkB,GACnB,MAAM,eAAe,CAAC;AAEvB,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC;AAEvC,SAAS,iBAAiB,CAAC,QAA6B;IACtD,OAAO,CAAC,WAAW,CAAC,CAAC;AACvB,CAAC;AAED,SAAS,oBAAoB,CAAC,OAA4B;IACxD,MAAM,QAAQ,GAAG,OAAO,CAAC,MAAM,EAAE,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