@elizaos/plugin-line 2.0.0-alpha.7 → 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 +185 -0
- package/package.json +28 -12
- 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 -7
- package/dist/actions/index.d.ts.map +0 -1
- package/dist/actions/index.js +0 -7
- package/dist/actions/index.js.map +0 -1
- package/dist/actions/sendFlexMessage.d.ts +0 -6
- package/dist/actions/sendFlexMessage.d.ts.map +0 -1
- package/dist/actions/sendFlexMessage.js +0 -204
- package/dist/actions/sendFlexMessage.js.map +0 -1
- package/dist/actions/sendLocation.d.ts +0 -6
- package/dist/actions/sendLocation.d.ts.map +0 -1
- package/dist/actions/sendLocation.js +0 -181
- package/dist/actions/sendLocation.js.map +0 -1
- package/dist/actions/sendMessage.d.ts +0 -6
- package/dist/actions/sendMessage.d.ts.map +0 -1
- package/dist/actions/sendMessage.js +0 -172
- package/dist/actions/sendMessage.js.map +0 -1
- package/dist/index.d.ts +0 -22
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -49
- 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/chatContext.d.ts +0 -6
- package/dist/providers/chatContext.d.ts.map +0 -1
- package/dist/providers/chatContext.js +0 -86
- package/dist/providers/chatContext.js.map +0 -1
- package/dist/providers/index.d.ts +0 -6
- package/dist/providers/index.d.ts.map +0 -1
- package/dist/providers/index.js +0 -6
- package/dist/providers/index.js.map +0 -1
- package/dist/providers/userContext.d.ts +0 -6
- package/dist/providers/userContext.d.ts.map +0 -1
- package/dist/providers/userContext.js +0 -71
- package/dist/providers/userContext.js.map +0 -1
- package/dist/service.d.ts +0 -102
- package/dist/service.d.ts.map +0 -1
- package/dist/service.js +0 -433
- 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
|
@@ -1,181 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Send location action for the LINE plugin.
|
|
3
|
-
*/
|
|
4
|
-
import { composePromptFromState, logger, ModelType, parseJSONObjectFromText } from "@elizaos/core";
|
|
5
|
-
import { isValidLineId, LINE_SERVICE_NAME, normalizeLineTarget, } from "../types.js";
|
|
6
|
-
const SEND_LOCATION_TEMPLATE = `# Task: Extract LINE location message parameters
|
|
7
|
-
|
|
8
|
-
Based on the conversation, determine the location to send.
|
|
9
|
-
|
|
10
|
-
Recent conversation:
|
|
11
|
-
{{recentMessages}}
|
|
12
|
-
|
|
13
|
-
Extract the following:
|
|
14
|
-
1. title: Place name
|
|
15
|
-
2. address: Full address
|
|
16
|
-
3. latitude: Latitude coordinate (number)
|
|
17
|
-
4. longitude: Longitude coordinate (number)
|
|
18
|
-
5. to: The target user/group/room ID (or "current" to reply to the current chat)
|
|
19
|
-
|
|
20
|
-
Respond with a JSON object:
|
|
21
|
-
\`\`\`json
|
|
22
|
-
{
|
|
23
|
-
"title": "Place Name",
|
|
24
|
-
"address": "123 Main St, City",
|
|
25
|
-
"latitude": 35.6762,
|
|
26
|
-
"longitude": 139.6503,
|
|
27
|
-
"to": "target ID or 'current'"
|
|
28
|
-
}
|
|
29
|
-
\`\`\`
|
|
30
|
-
`;
|
|
31
|
-
export const sendLocation = {
|
|
32
|
-
name: "LINE_SEND_LOCATION",
|
|
33
|
-
similes: ["SEND_LINE_LOCATION", "LINE_LOCATION", "LINE_MAP", "SHARE_LOCATION_LINE"],
|
|
34
|
-
description: "Send a location message via LINE",
|
|
35
|
-
validate: async (runtime, message, state, options) => {
|
|
36
|
-
const __avTextRaw = typeof message?.content?.text === "string" ? message.content.text : "";
|
|
37
|
-
const __avText = __avTextRaw.toLowerCase();
|
|
38
|
-
const __avKeywords = ["line", "send", "location"];
|
|
39
|
-
const __avKeywordOk = __avKeywords.length > 0 && __avKeywords.some((kw) => kw.length > 0 && __avText.includes(kw));
|
|
40
|
-
const __avRegex = /\b(?:line|send|location)\b/i;
|
|
41
|
-
const __avRegexOk = __avRegex.test(__avText);
|
|
42
|
-
const __avSource = String(message?.content?.source ?? message?.source ?? "");
|
|
43
|
-
const __avExpectedSource = "line";
|
|
44
|
-
const __avSourceOk = __avExpectedSource
|
|
45
|
-
? __avSource === __avExpectedSource
|
|
46
|
-
: Boolean(__avSource || state || runtime?.agentId || runtime?.getService);
|
|
47
|
-
const __avOptions = options && typeof options === "object" ? options : {};
|
|
48
|
-
const __avInputOk = __avText.trim().length > 0 ||
|
|
49
|
-
Object.keys(__avOptions).length > 0 ||
|
|
50
|
-
Boolean(message?.content && typeof message.content === "object");
|
|
51
|
-
if (!(__avKeywordOk && __avRegexOk && __avSourceOk && __avInputOk)) {
|
|
52
|
-
return false;
|
|
53
|
-
}
|
|
54
|
-
const __avLegacyValidate = async (_runtime, message, _state) => {
|
|
55
|
-
return message.content.source === "line";
|
|
56
|
-
};
|
|
57
|
-
try {
|
|
58
|
-
return Boolean(await __avLegacyValidate(runtime, message, state, options));
|
|
59
|
-
}
|
|
60
|
-
catch {
|
|
61
|
-
return false;
|
|
62
|
-
}
|
|
63
|
-
},
|
|
64
|
-
handler: async (runtime, message, state, _options, callback) => {
|
|
65
|
-
const lineService = runtime.getService(LINE_SERVICE_NAME);
|
|
66
|
-
if (!lineService || !lineService.isConnected()) {
|
|
67
|
-
if (callback) {
|
|
68
|
-
callback({ text: "LINE service is not available.", source: "line" });
|
|
69
|
-
}
|
|
70
|
-
return { success: false, error: "LINE service not available" };
|
|
71
|
-
}
|
|
72
|
-
const currentState = state ?? (await runtime.composeState(message));
|
|
73
|
-
// Extract parameters using LLM
|
|
74
|
-
const prompt = composePromptFromState({
|
|
75
|
-
template: SEND_LOCATION_TEMPLATE,
|
|
76
|
-
state: currentState,
|
|
77
|
-
});
|
|
78
|
-
let locationInfo = null;
|
|
79
|
-
for (let attempt = 0; attempt < 3; attempt++) {
|
|
80
|
-
const response = await runtime.useModel(ModelType.TEXT_SMALL, {
|
|
81
|
-
prompt,
|
|
82
|
-
});
|
|
83
|
-
const parsed = parseJSONObjectFromText(response);
|
|
84
|
-
if (parsed?.title &&
|
|
85
|
-
parsed?.address &&
|
|
86
|
-
typeof parsed?.latitude === "number" &&
|
|
87
|
-
typeof parsed?.longitude === "number") {
|
|
88
|
-
locationInfo = {
|
|
89
|
-
title: String(parsed.title),
|
|
90
|
-
address: String(parsed.address),
|
|
91
|
-
latitude: Number(parsed.latitude),
|
|
92
|
-
longitude: Number(parsed.longitude),
|
|
93
|
-
to: String(parsed.to || "current"),
|
|
94
|
-
};
|
|
95
|
-
break;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
if (!locationInfo) {
|
|
99
|
-
if (callback) {
|
|
100
|
-
callback({
|
|
101
|
-
text: "I couldn't understand the location information. Please provide title, address, and coordinates.",
|
|
102
|
-
source: "line",
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
return { success: false, error: "Could not extract location parameters" };
|
|
106
|
-
}
|
|
107
|
-
// Determine target
|
|
108
|
-
let targetId;
|
|
109
|
-
if (locationInfo.to && locationInfo.to !== "current") {
|
|
110
|
-
const normalized = normalizeLineTarget(locationInfo.to);
|
|
111
|
-
if (normalized && isValidLineId(normalized)) {
|
|
112
|
-
targetId = normalized;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
// Fall back to current chat
|
|
116
|
-
if (!targetId) {
|
|
117
|
-
const stateData = (currentState.data || {});
|
|
118
|
-
targetId =
|
|
119
|
-
stateData.groupId ||
|
|
120
|
-
stateData.roomId ||
|
|
121
|
-
stateData.userId;
|
|
122
|
-
}
|
|
123
|
-
if (!targetId) {
|
|
124
|
-
if (callback) {
|
|
125
|
-
callback({
|
|
126
|
-
text: "I couldn't determine where to send the location. Please specify a target.",
|
|
127
|
-
source: "line",
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
return { success: false, error: "Could not determine target" };
|
|
131
|
-
}
|
|
132
|
-
// Create location message
|
|
133
|
-
const location = {
|
|
134
|
-
type: "location",
|
|
135
|
-
title: locationInfo.title,
|
|
136
|
-
address: locationInfo.address,
|
|
137
|
-
latitude: locationInfo.latitude,
|
|
138
|
-
longitude: locationInfo.longitude,
|
|
139
|
-
};
|
|
140
|
-
// Send message
|
|
141
|
-
const result = await lineService.sendLocationMessage(targetId, location);
|
|
142
|
-
if (!result.success) {
|
|
143
|
-
if (callback) {
|
|
144
|
-
callback({
|
|
145
|
-
text: `Failed to send location: ${result.error}`,
|
|
146
|
-
source: "line",
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
return { success: false, error: result.error };
|
|
150
|
-
}
|
|
151
|
-
logger.debug(`Sent LINE location to ${targetId}`);
|
|
152
|
-
if (callback) {
|
|
153
|
-
callback({
|
|
154
|
-
text: "Location sent successfully.",
|
|
155
|
-
source: message.content.source,
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
return {
|
|
159
|
-
success: true,
|
|
160
|
-
text: "Location sent successfully",
|
|
161
|
-
};
|
|
162
|
-
},
|
|
163
|
-
examples: [
|
|
164
|
-
[
|
|
165
|
-
{
|
|
166
|
-
name: "{{user1}}",
|
|
167
|
-
content: {
|
|
168
|
-
text: "Send them the location of Tokyo Tower",
|
|
169
|
-
},
|
|
170
|
-
},
|
|
171
|
-
{
|
|
172
|
-
name: "{{agent}}",
|
|
173
|
-
content: {
|
|
174
|
-
text: "I'll send the location.",
|
|
175
|
-
actions: ["LINE_SEND_LOCATION"],
|
|
176
|
-
},
|
|
177
|
-
},
|
|
178
|
-
],
|
|
179
|
-
],
|
|
180
|
-
};
|
|
181
|
-
//# sourceMappingURL=sendLocation.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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":"AAAA;;GAEG;AAEH,OAAO,KAAK,EACV,MAAM,EAMP,MAAM,eAAe,CAAC;AA8BvB,eAAO,MAAM,WAAW,EAAE,MAkLzB,CAAC"}
|
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Send message action for the LINE plugin.
|
|
3
|
-
*/
|
|
4
|
-
import { composePromptFromState, logger, ModelType, parseJSONObjectFromText } from "@elizaos/core";
|
|
5
|
-
import { isValidLineId, LINE_SERVICE_NAME, normalizeLineTarget } from "../types.js";
|
|
6
|
-
const SEND_MESSAGE_TEMPLATE = `# Task: Extract LINE message parameters
|
|
7
|
-
|
|
8
|
-
Based on the conversation, determine what message to send and to whom.
|
|
9
|
-
|
|
10
|
-
Recent conversation:
|
|
11
|
-
{{recentMessages}}
|
|
12
|
-
|
|
13
|
-
Extract the following:
|
|
14
|
-
1. text: The message content to send
|
|
15
|
-
2. to: The target user/group/room ID (or "current" to reply to the current chat)
|
|
16
|
-
|
|
17
|
-
Respond with a JSON object:
|
|
18
|
-
\`\`\`json
|
|
19
|
-
{
|
|
20
|
-
"text": "message to send",
|
|
21
|
-
"to": "target ID or 'current'"
|
|
22
|
-
}
|
|
23
|
-
\`\`\`
|
|
24
|
-
`;
|
|
25
|
-
export const sendMessage = {
|
|
26
|
-
name: "LINE_SEND_MESSAGE",
|
|
27
|
-
similes: ["SEND_LINE_MESSAGE", "LINE_MESSAGE", "LINE_TEXT", "MESSAGE_LINE"],
|
|
28
|
-
description: "Send a text message via LINE",
|
|
29
|
-
validate: async (runtime, message, state, options) => {
|
|
30
|
-
const __avTextRaw = typeof message?.content?.text === "string" ? message.content.text : "";
|
|
31
|
-
const __avText = __avTextRaw.toLowerCase();
|
|
32
|
-
const __avKeywords = ["line", "send", "message"];
|
|
33
|
-
const __avKeywordOk = __avKeywords.length > 0 && __avKeywords.some((kw) => kw.length > 0 && __avText.includes(kw));
|
|
34
|
-
const __avRegex = /\b(?:line|send|message)\b/i;
|
|
35
|
-
const __avRegexOk = __avRegex.test(__avText);
|
|
36
|
-
const __avSource = String(message?.content?.source ?? message?.source ?? "");
|
|
37
|
-
const __avExpectedSource = "line";
|
|
38
|
-
const __avSourceOk = __avExpectedSource
|
|
39
|
-
? __avSource === __avExpectedSource
|
|
40
|
-
: Boolean(__avSource || state || runtime?.agentId || runtime?.getService);
|
|
41
|
-
const __avOptions = options && typeof options === "object" ? options : {};
|
|
42
|
-
const __avInputOk = __avText.trim().length > 0 ||
|
|
43
|
-
Object.keys(__avOptions).length > 0 ||
|
|
44
|
-
Boolean(message?.content && typeof message.content === "object");
|
|
45
|
-
if (!(__avKeywordOk && __avRegexOk && __avSourceOk && __avInputOk)) {
|
|
46
|
-
return false;
|
|
47
|
-
}
|
|
48
|
-
const __avLegacyValidate = async (_runtime, message, _state) => {
|
|
49
|
-
return message.content.source === "line";
|
|
50
|
-
};
|
|
51
|
-
try {
|
|
52
|
-
return Boolean(await __avLegacyValidate(runtime, message, state, options));
|
|
53
|
-
}
|
|
54
|
-
catch {
|
|
55
|
-
return false;
|
|
56
|
-
}
|
|
57
|
-
},
|
|
58
|
-
handler: async (runtime, message, state, _options, callback) => {
|
|
59
|
-
const lineService = runtime.getService(LINE_SERVICE_NAME);
|
|
60
|
-
if (!lineService || !lineService.isConnected()) {
|
|
61
|
-
if (callback) {
|
|
62
|
-
callback({ text: "LINE service is not available.", source: "line" });
|
|
63
|
-
}
|
|
64
|
-
return { success: false, error: "LINE service not available" };
|
|
65
|
-
}
|
|
66
|
-
const currentState = state ?? (await runtime.composeState(message));
|
|
67
|
-
// Extract parameters using LLM
|
|
68
|
-
const prompt = composePromptFromState({
|
|
69
|
-
template: SEND_MESSAGE_TEMPLATE,
|
|
70
|
-
state: currentState,
|
|
71
|
-
});
|
|
72
|
-
let msgInfo = null;
|
|
73
|
-
for (let attempt = 0; attempt < 3; attempt++) {
|
|
74
|
-
const response = await runtime.useModel(ModelType.TEXT_SMALL, {
|
|
75
|
-
prompt,
|
|
76
|
-
});
|
|
77
|
-
const parsed = parseJSONObjectFromText(response);
|
|
78
|
-
if (parsed?.text) {
|
|
79
|
-
msgInfo = {
|
|
80
|
-
text: String(parsed.text),
|
|
81
|
-
to: String(parsed.to || "current"),
|
|
82
|
-
};
|
|
83
|
-
break;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
if (!msgInfo || !msgInfo.text) {
|
|
87
|
-
if (callback) {
|
|
88
|
-
callback({
|
|
89
|
-
text: "I couldn't understand what message you want me to send. Please try again.",
|
|
90
|
-
source: "line",
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
return { success: false, error: "Could not extract message parameters" };
|
|
94
|
-
}
|
|
95
|
-
// Determine target
|
|
96
|
-
let targetId;
|
|
97
|
-
if (msgInfo.to && msgInfo.to !== "current") {
|
|
98
|
-
const normalized = normalizeLineTarget(msgInfo.to);
|
|
99
|
-
if (normalized && isValidLineId(normalized)) {
|
|
100
|
-
targetId = normalized;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
// Fall back to current chat
|
|
104
|
-
if (!targetId) {
|
|
105
|
-
const stateData = (currentState.data || {});
|
|
106
|
-
targetId =
|
|
107
|
-
stateData.groupId ||
|
|
108
|
-
stateData.roomId ||
|
|
109
|
-
stateData.userId;
|
|
110
|
-
}
|
|
111
|
-
if (!targetId) {
|
|
112
|
-
if (callback) {
|
|
113
|
-
callback({
|
|
114
|
-
text: "I couldn't determine where to send the message. Please specify a target.",
|
|
115
|
-
source: "line",
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
return { success: false, error: "Could not determine target" };
|
|
119
|
-
}
|
|
120
|
-
// Send message
|
|
121
|
-
const result = await lineService.sendMessage(targetId, msgInfo.text);
|
|
122
|
-
if (!result.success) {
|
|
123
|
-
if (callback) {
|
|
124
|
-
callback({
|
|
125
|
-
text: `Failed to send message: ${result.error}`,
|
|
126
|
-
source: "line",
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
return { success: false, error: result.error };
|
|
130
|
-
}
|
|
131
|
-
logger.debug(`Sent LINE message to ${targetId}`);
|
|
132
|
-
if (callback) {
|
|
133
|
-
callback({
|
|
134
|
-
text: "Message sent successfully.",
|
|
135
|
-
source: message.content.source,
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
return {
|
|
139
|
-
success: true,
|
|
140
|
-
text: "Message sent successfully",
|
|
141
|
-
};
|
|
142
|
-
},
|
|
143
|
-
examples: [
|
|
144
|
-
[
|
|
145
|
-
{
|
|
146
|
-
name: "{{user1}}",
|
|
147
|
-
content: { text: "Send them a message saying 'Hello!'" },
|
|
148
|
-
},
|
|
149
|
-
{
|
|
150
|
-
name: "{{agent}}",
|
|
151
|
-
content: {
|
|
152
|
-
text: "I'll send that message via LINE.",
|
|
153
|
-
actions: ["LINE_SEND_MESSAGE"],
|
|
154
|
-
},
|
|
155
|
-
},
|
|
156
|
-
],
|
|
157
|
-
[
|
|
158
|
-
{
|
|
159
|
-
name: "{{user1}}",
|
|
160
|
-
content: { text: "Message the group saying 'Meeting in 5 minutes'" },
|
|
161
|
-
},
|
|
162
|
-
{
|
|
163
|
-
name: "{{agent}}",
|
|
164
|
-
content: {
|
|
165
|
-
text: "I'll send that to the group.",
|
|
166
|
-
actions: ["LINE_SEND_MESSAGE"],
|
|
167
|
-
},
|
|
168
|
-
},
|
|
169
|
-
],
|
|
170
|
-
],
|
|
171
|
-
};
|
|
172
|
-
//# sourceMappingURL=sendMessage.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sendMessage.js","sourceRoot":"","sources":["../../src/actions/sendMessage.ts"],"names":[],"mappings":"AAAA;;GAEG;AAUH,OAAO,EAAE,sBAAsB,EAAE,MAAM,EAAE,SAAS,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAEnG,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAEpF,MAAM,qBAAqB,GAAG;;;;;;;;;;;;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L,CAAC;QAED,OAAO;YACL,OAAO,EAAE,IAAI;YACb,IAAI,EAAE,2BAA2B;SAClC,CAAC;IACJ,CAAC;IAED,QAAQ,EAAE;QACR;YACE;gBACE,IAAI,EAAE,WAAW;gBACjB,OAAO,EAAE,EAAE,IAAI,EAAE,qCAAqC,EAAE;aACzD;YACD;gBACE,IAAI,EAAE,WAAW;gBACjB,OAAO,EAAE;oBACP,IAAI,EAAE,kCAAkC;oBACxC,OAAO,EAAE,CAAC,mBAAmB,CAAC;iBAC/B;aACF;SACF;QACD;YACE;gBACE,IAAI,EAAE,WAAW;gBACjB,OAAO,EAAE,EAAE,IAAI,EAAE,iDAAiD,EAAE;aACrE;YACD;gBACE,IAAI,EAAE,WAAW;gBACjB,OAAO,EAAE;oBACP,IAAI,EAAE,8BAA8B;oBACpC,OAAO,EAAE,CAAC,mBAAmB,CAAC;iBAC/B;aACF;SACF;KACF;CACF,CAAC"}
|
package/dist/index.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* LINE Plugin for ElizaOS
|
|
3
|
-
*
|
|
4
|
-
* Provides LINE Messaging API integration for ElizaOS agents,
|
|
5
|
-
* supporting text, flex messages, locations, and more.
|
|
6
|
-
*/
|
|
7
|
-
import type { Plugin } from "@elizaos/core";
|
|
8
|
-
import { sendFlexMessage, sendLocation, sendMessage } from "./actions/index.js";
|
|
9
|
-
import { chatContextProvider, userContextProvider } from "./providers/index.js";
|
|
10
|
-
import { LineService } from "./service.js";
|
|
11
|
-
export * from "./types.js";
|
|
12
|
-
export { LineService };
|
|
13
|
-
export { sendMessage, sendFlexMessage, sendLocation };
|
|
14
|
-
export { chatContextProvider, userContextProvider };
|
|
15
|
-
export { DEFAULT_ACCOUNT_ID, isLineMentionRequired, isLineUserAllowed, isMultiAccountEnabled, type LineAccountConfig, type LineGroupConfig, type LineMultiAccountConfig, type LineTokenResolution, type LineTokenSource, listEnabledLineAccounts, listLineAccountIds, normalizeAccountId, type ResolvedLineAccount, resolveDefaultLineAccountId, resolveLineAccount, resolveLineGroupConfig, resolveLineSecret, resolveLineToken, } from "./accounts.js";
|
|
16
|
-
export { buildLineDeepLink, type ChunkLineTextOpts, type CodeBlock, chunkLineText, extractCodeBlocks, extractLinks, extractMarkdownTables, formatCodeBlockAsText, formatLineUser, formatTableAsText, getChatId, getChatType, hasMarkdownContent, isGroupChat, LINE_MAX_REPLY_MESSAGES, LINE_TEXT_CHUNK_LIMIT, type MarkdownLink, type MarkdownTable, markdownToLineChunks, type ProcessedLineMessage, processLineMessage, resolveLineSystemLocation, stripMarkdown, truncateText, } from "./messaging.js";
|
|
17
|
-
/**
|
|
18
|
-
* LINE plugin for ElizaOS agents.
|
|
19
|
-
*/
|
|
20
|
-
declare const linePlugin: Plugin;
|
|
21
|
-
export default linePlugin;
|
|
22
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAiB,MAAM,EAAE,MAAM,eAAe,CAAC;AAE3D,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAChF,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAChF,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAG3C,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,WAAW,EAAE,CAAC;AACvB,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,YAAY,EAAE,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,CAAC;AAGpD,OAAO,EACL,kBAAkB,EAClB,qBAAqB,EACrB,iBAAiB,EACjB,qBAAqB,EACrB,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,sBAAsB,EAC3B,KAAK,mBAAmB,EACxB,KAAK,eAAe,EACpB,uBAAuB,EACvB,kBAAkB,EAClB,kBAAkB,EAClB,KAAK,mBAAmB,EACxB,2BAA2B,EAC3B,kBAAkB,EAClB,sBAAsB,EACtB,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,eAAe,CAAC;AAGvB,OAAO,EACL,iBAAiB,EACjB,KAAK,iBAAiB,EACtB,KAAK,SAAS,EACd,aAAa,EACb,iBAAiB,EACjB,YAAY,EACZ,qBAAqB,EACrB,qBAAqB,EACrB,cAAc,EACd,iBAAiB,EACjB,SAAS,EACT,WAAW,EACX,kBAAkB,EAClB,WAAW,EACX,uBAAuB,EACvB,qBAAqB,EACrB,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,oBAAoB,EACpB,KAAK,oBAAoB,EACzB,kBAAkB,EAClB,yBAAyB,EACzB,aAAa,EACb,YAAY,GACb,MAAM,gBAAgB,CAAC;AAExB;;GAEG;AACH,QAAA,MAAM,UAAU,EAAE,MAqCjB,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
package/dist/index.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* LINE Plugin for ElizaOS
|
|
3
|
-
*
|
|
4
|
-
* Provides LINE Messaging API integration for ElizaOS agents,
|
|
5
|
-
* supporting text, flex messages, locations, and more.
|
|
6
|
-
*/
|
|
7
|
-
import { logger } from "@elizaos/core";
|
|
8
|
-
import { sendFlexMessage, sendLocation, sendMessage } from "./actions/index.js";
|
|
9
|
-
import { chatContextProvider, userContextProvider } from "./providers/index.js";
|
|
10
|
-
import { LineService } from "./service.js";
|
|
11
|
-
// Re-export types and service
|
|
12
|
-
export * from "./types.js";
|
|
13
|
-
export { LineService };
|
|
14
|
-
export { sendMessage, sendFlexMessage, sendLocation };
|
|
15
|
-
export { chatContextProvider, userContextProvider };
|
|
16
|
-
// Account management exports
|
|
17
|
-
export { DEFAULT_ACCOUNT_ID, isLineMentionRequired, isLineUserAllowed, isMultiAccountEnabled, listEnabledLineAccounts, listLineAccountIds, normalizeAccountId, resolveDefaultLineAccountId, resolveLineAccount, resolveLineGroupConfig, resolveLineSecret, resolveLineToken, } from "./accounts.js";
|
|
18
|
-
// Messaging utilities exports
|
|
19
|
-
export { buildLineDeepLink, chunkLineText, extractCodeBlocks, extractLinks, extractMarkdownTables, formatCodeBlockAsText, formatLineUser, formatTableAsText, getChatId, getChatType, hasMarkdownContent, isGroupChat, LINE_MAX_REPLY_MESSAGES, LINE_TEXT_CHUNK_LIMIT, markdownToLineChunks, processLineMessage, resolveLineSystemLocation, stripMarkdown, truncateText, } from "./messaging.js";
|
|
20
|
-
/**
|
|
21
|
-
* LINE plugin for ElizaOS agents.
|
|
22
|
-
*/
|
|
23
|
-
const linePlugin = {
|
|
24
|
-
name: "line",
|
|
25
|
-
description: "LINE Messaging API plugin for ElizaOS agents",
|
|
26
|
-
services: [LineService],
|
|
27
|
-
actions: [sendMessage, sendFlexMessage, sendLocation],
|
|
28
|
-
providers: [chatContextProvider, userContextProvider],
|
|
29
|
-
tests: [],
|
|
30
|
-
init: async (config, _runtime) => {
|
|
31
|
-
logger.info("Initializing LINE plugin...");
|
|
32
|
-
const hasAccessToken = Boolean(config.LINE_CHANNEL_ACCESS_TOKEN || process.env.LINE_CHANNEL_ACCESS_TOKEN);
|
|
33
|
-
const hasSecret = Boolean(config.LINE_CHANNEL_SECRET || process.env.LINE_CHANNEL_SECRET);
|
|
34
|
-
logger.info("LINE plugin configuration:");
|
|
35
|
-
logger.info(` - Access token configured: ${hasAccessToken ? "Yes" : "No"}`);
|
|
36
|
-
logger.info(` - Channel secret configured: ${hasSecret ? "Yes" : "No"}`);
|
|
37
|
-
logger.info(` - DM policy: ${config.LINE_DM_POLICY || process.env.LINE_DM_POLICY || "pairing"}`);
|
|
38
|
-
logger.info(` - Group policy: ${config.LINE_GROUP_POLICY || process.env.LINE_GROUP_POLICY || "allowlist"}`);
|
|
39
|
-
if (!hasAccessToken) {
|
|
40
|
-
logger.warn("LINE channel access token not configured. Set LINE_CHANNEL_ACCESS_TOKEN.");
|
|
41
|
-
}
|
|
42
|
-
if (!hasSecret) {
|
|
43
|
-
logger.warn("LINE channel secret not configured. Set LINE_CHANNEL_SECRET.");
|
|
44
|
-
}
|
|
45
|
-
logger.info("LINE plugin initialized");
|
|
46
|
-
},
|
|
47
|
-
};
|
|
48
|
-
export default linePlugin;
|
|
49
|
-
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAChF,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAChF,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,8BAA8B;AAC9B,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,WAAW,EAAE,CAAC;AACvB,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,YAAY,EAAE,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,CAAC;AAEpD,6BAA6B;AAC7B,OAAO,EACL,kBAAkB,EAClB,qBAAqB,EACrB,iBAAiB,EACjB,qBAAqB,EAMrB,uBAAuB,EACvB,kBAAkB,EAClB,kBAAkB,EAElB,2BAA2B,EAC3B,kBAAkB,EAClB,sBAAsB,EACtB,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,eAAe,CAAC;AAEvB,8BAA8B;AAC9B,OAAO,EACL,iBAAiB,EAGjB,aAAa,EACb,iBAAiB,EACjB,YAAY,EACZ,qBAAqB,EACrB,qBAAqB,EACrB,cAAc,EACd,iBAAiB,EACjB,SAAS,EACT,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AAiB,IAAI,WAAW,EAAE,CAChG,CAAC;QAEF,IAAI,CAAC,cAAc,EAAE,CAAC;YACpB,MAAM,CAAC,IAAI,CAAC,0EAA0E,CAAC,CAAC;QAC1F,CAAC;QAED,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,MAAM,CAAC,IAAI,CAAC,8DAA8D,CAAC,CAAC;QAC9E,CAAC;QAED,MAAM,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC;IACzC,CAAC;CACF,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
package/dist/messaging.d.ts
DELETED
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* LINE text chunk limit (API supports 5000 characters per message)
|
|
3
|
-
*/
|
|
4
|
-
export declare const LINE_TEXT_CHUNK_LIMIT = 5000;
|
|
5
|
-
/**
|
|
6
|
-
* LINE max messages per reply (API supports up to 5 messages in a reply)
|
|
7
|
-
*/
|
|
8
|
-
export declare const LINE_MAX_REPLY_MESSAGES = 5;
|
|
9
|
-
/**
|
|
10
|
-
* Represents a markdown table extracted from text
|
|
11
|
-
*/
|
|
12
|
-
export interface MarkdownTable {
|
|
13
|
-
headers: string[];
|
|
14
|
-
rows: string[][];
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Represents a code block extracted from text
|
|
18
|
-
*/
|
|
19
|
-
export interface CodeBlock {
|
|
20
|
-
language?: string;
|
|
21
|
-
code: string;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Represents a markdown link
|
|
25
|
-
*/
|
|
26
|
-
export interface MarkdownLink {
|
|
27
|
-
text: string;
|
|
28
|
-
url: string;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Result of processing text for LINE
|
|
32
|
-
*/
|
|
33
|
-
export interface ProcessedLineMessage {
|
|
34
|
-
text: string;
|
|
35
|
-
tables: MarkdownTable[];
|
|
36
|
-
codeBlocks: CodeBlock[];
|
|
37
|
-
links: MarkdownLink[];
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Options for text chunking
|
|
41
|
-
*/
|
|
42
|
-
export interface ChunkLineTextOpts {
|
|
43
|
-
limit?: number;
|
|
44
|
-
preserveCodeBlocks?: boolean;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Extracts markdown tables from text
|
|
48
|
-
*/
|
|
49
|
-
export declare function extractMarkdownTables(text: string): {
|
|
50
|
-
tables: MarkdownTable[];
|
|
51
|
-
textWithoutTables: string;
|
|
52
|
-
};
|
|
53
|
-
/**
|
|
54
|
-
* Extracts code blocks from text
|
|
55
|
-
*/
|
|
56
|
-
export declare function extractCodeBlocks(text: string): {
|
|
57
|
-
codeBlocks: CodeBlock[];
|
|
58
|
-
textWithoutCode: string;
|
|
59
|
-
};
|
|
60
|
-
/**
|
|
61
|
-
* Extracts markdown links from text
|
|
62
|
-
*/
|
|
63
|
-
export declare function extractLinks(text: string): {
|
|
64
|
-
links: MarkdownLink[];
|
|
65
|
-
textWithLinks: string;
|
|
66
|
-
};
|
|
67
|
-
/**
|
|
68
|
-
* Strips markdown formatting from text
|
|
69
|
-
*/
|
|
70
|
-
export declare function stripMarkdown(text: string): string;
|
|
71
|
-
/**
|
|
72
|
-
* Checks if text contains markdown that needs conversion
|
|
73
|
-
*/
|
|
74
|
-
export declare function hasMarkdownContent(text: string): boolean;
|
|
75
|
-
/**
|
|
76
|
-
* Processes text for LINE output
|
|
77
|
-
*/
|
|
78
|
-
export declare function processLineMessage(text: string): ProcessedLineMessage;
|
|
79
|
-
/**
|
|
80
|
-
* Chunks text for LINE messages
|
|
81
|
-
*/
|
|
82
|
-
export declare function chunkLineText(text: string, opts?: ChunkLineTextOpts): string[];
|
|
83
|
-
/**
|
|
84
|
-
* Processes and chunks a markdown message for LINE
|
|
85
|
-
*/
|
|
86
|
-
export declare function markdownToLineChunks(markdown: string, opts?: ChunkLineTextOpts): {
|
|
87
|
-
textChunks: string[];
|
|
88
|
-
tables: MarkdownTable[];
|
|
89
|
-
codeBlocks: CodeBlock[];
|
|
90
|
-
links: MarkdownLink[];
|
|
91
|
-
};
|
|
92
|
-
/**
|
|
93
|
-
* Formats a table as plain text
|
|
94
|
-
*/
|
|
95
|
-
export declare function formatTableAsText(table: MarkdownTable): string;
|
|
96
|
-
/**
|
|
97
|
-
* Formats a code block as plain text
|
|
98
|
-
*/
|
|
99
|
-
export declare function formatCodeBlockAsText(block: CodeBlock): string;
|
|
100
|
-
/**
|
|
101
|
-
* Truncates text to a maximum length with ellipsis
|
|
102
|
-
*/
|
|
103
|
-
export declare function truncateText(text: string, maxLength: number): string;
|
|
104
|
-
/**
|
|
105
|
-
* Formats a LINE user display name
|
|
106
|
-
*/
|
|
107
|
-
export declare function formatLineUser(displayName: string, userId: string): string;
|
|
108
|
-
/**
|
|
109
|
-
* Builds a LINE deep link URL
|
|
110
|
-
*/
|
|
111
|
-
export declare function buildLineDeepLink(_type: "user" | "group" | "room", id: string): string;
|
|
112
|
-
/**
|
|
113
|
-
* Resolves the system location string for logging
|
|
114
|
-
*/
|
|
115
|
-
export declare function resolveLineSystemLocation(params: {
|
|
116
|
-
chatType: "user" | "group" | "room";
|
|
117
|
-
chatId: string;
|
|
118
|
-
chatName?: string;
|
|
119
|
-
}): string;
|
|
120
|
-
/**
|
|
121
|
-
* Checks if a chat is a group chat
|
|
122
|
-
*/
|
|
123
|
-
export declare function isGroupChat(params: {
|
|
124
|
-
groupId?: string;
|
|
125
|
-
roomId?: string;
|
|
126
|
-
}): boolean;
|
|
127
|
-
/**
|
|
128
|
-
* Gets the chat ID from context
|
|
129
|
-
*/
|
|
130
|
-
export declare function getChatId(params: {
|
|
131
|
-
userId: string;
|
|
132
|
-
groupId?: string;
|
|
133
|
-
roomId?: string;
|
|
134
|
-
}): string;
|
|
135
|
-
/**
|
|
136
|
-
* Gets the chat type from context
|
|
137
|
-
*/
|
|
138
|
-
export declare function getChatType(params: {
|
|
139
|
-
groupId?: string;
|
|
140
|
-
roomId?: string;
|
|
141
|
-
}): "user" | "group" | "room";
|
|
142
|
-
//# sourceMappingURL=messaging.d.ts.map
|
package/dist/messaging.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"messaging.d.ts","sourceRoot":"","sources":["../src/messaging.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,qBAAqB,OAAO,CAAC;AAE1C;;GAEG;AACH,eAAO,MAAM,uBAAuB,IAAI,CAAC;AAEzC;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,IAAI,EAAE,MAAM,EAAE,EAAE,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;CACb;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,aAAa,EAAE,CAAC;IACxB,UAAU,EAAE,SAAS,EAAE,CAAC;IACxB,KAAK,EAAE,YAAY,EAAE,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AA4BD;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG;IACnD,MAAM,EAAE,aAAa,EAAE,CAAC;IACxB,iBAAiB,EAAE,MAAM,CAAC;CAC3B,CAyCA;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG;IAC/C,UAAU,EAAE,SAAS,EAAE,CAAC;IACxB,eAAe,EAAE,MAAM,CAAC;CACzB,CAgCA;AAED;;GAEG;AACH,wBA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