@elizaos/plugin-line 2.0.0-alpha.7 → 2.0.11-beta.7
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
package/dist/messaging.js
DELETED
|
@@ -1,357 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* LINE text chunk limit (API supports 5000 characters per message)
|
|
3
|
-
*/
|
|
4
|
-
export 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 const LINE_MAX_REPLY_MESSAGES = 5;
|
|
9
|
-
/**
|
|
10
|
-
* Regex patterns for markdown detection
|
|
11
|
-
*/
|
|
12
|
-
const MARKDOWN_TABLE_REGEX = /^\|(.+)\|[\r\n]+\|[-:\s|]+\|[\r\n]+((?:\|.+\|[\r\n]*)+)/gm;
|
|
13
|
-
const MARKDOWN_CODE_BLOCK_REGEX = /```(\w*)\n([\s\S]*?)```/g;
|
|
14
|
-
const MARKDOWN_LINK_REGEX = /\[([^\]]+)\]\(([^)]+)\)/g;
|
|
15
|
-
/**
|
|
16
|
-
* Parses a single table row (pipe-separated values)
|
|
17
|
-
*/
|
|
18
|
-
function parseTableRow(row) {
|
|
19
|
-
return row
|
|
20
|
-
.split("|")
|
|
21
|
-
.map((cell) => cell.trim())
|
|
22
|
-
.filter((cell, index, arr) => {
|
|
23
|
-
// Filter out empty cells at start/end (from leading/trailing pipes)
|
|
24
|
-
if (index === 0 && cell === "") {
|
|
25
|
-
return false;
|
|
26
|
-
}
|
|
27
|
-
if (index === arr.length - 1 && cell === "") {
|
|
28
|
-
return false;
|
|
29
|
-
}
|
|
30
|
-
return true;
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Extracts markdown tables from text
|
|
35
|
-
*/
|
|
36
|
-
export function extractMarkdownTables(text) {
|
|
37
|
-
const tables = [];
|
|
38
|
-
let textWithoutTables = text;
|
|
39
|
-
// Reset regex state
|
|
40
|
-
MARKDOWN_TABLE_REGEX.lastIndex = 0;
|
|
41
|
-
let match;
|
|
42
|
-
const matches = [];
|
|
43
|
-
match = MARKDOWN_TABLE_REGEX.exec(text);
|
|
44
|
-
while (match !== null) {
|
|
45
|
-
const fullMatch = match[0];
|
|
46
|
-
const headerLine = match[1];
|
|
47
|
-
const bodyLines = match[2];
|
|
48
|
-
const headers = parseTableRow(headerLine);
|
|
49
|
-
const rows = bodyLines
|
|
50
|
-
.trim()
|
|
51
|
-
.split(/[\r\n]+/)
|
|
52
|
-
.filter((line) => line.trim())
|
|
53
|
-
.map(parseTableRow);
|
|
54
|
-
if (headers.length > 0 && rows.length > 0) {
|
|
55
|
-
matches.push({
|
|
56
|
-
fullMatch,
|
|
57
|
-
table: { headers, rows },
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
match = MARKDOWN_TABLE_REGEX.exec(text);
|
|
61
|
-
}
|
|
62
|
-
// Remove tables from text in reverse order to preserve indices
|
|
63
|
-
for (let i = matches.length - 1; i >= 0; i--) {
|
|
64
|
-
const { fullMatch, table } = matches[i];
|
|
65
|
-
tables.unshift(table);
|
|
66
|
-
textWithoutTables = textWithoutTables.replace(fullMatch, "");
|
|
67
|
-
}
|
|
68
|
-
return { tables, textWithoutTables };
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Extracts code blocks from text
|
|
72
|
-
*/
|
|
73
|
-
export function extractCodeBlocks(text) {
|
|
74
|
-
const codeBlocks = [];
|
|
75
|
-
let textWithoutCode = text;
|
|
76
|
-
// Reset regex state
|
|
77
|
-
MARKDOWN_CODE_BLOCK_REGEX.lastIndex = 0;
|
|
78
|
-
let match;
|
|
79
|
-
const matches = [];
|
|
80
|
-
match = MARKDOWN_CODE_BLOCK_REGEX.exec(text);
|
|
81
|
-
while (match !== null) {
|
|
82
|
-
const fullMatch = match[0];
|
|
83
|
-
const language = match[1] || undefined;
|
|
84
|
-
const code = match[2];
|
|
85
|
-
matches.push({
|
|
86
|
-
fullMatch,
|
|
87
|
-
block: { language, code: code.trim() },
|
|
88
|
-
});
|
|
89
|
-
match = MARKDOWN_CODE_BLOCK_REGEX.exec(text);
|
|
90
|
-
}
|
|
91
|
-
// Remove code blocks in reverse order
|
|
92
|
-
for (let i = matches.length - 1; i >= 0; i--) {
|
|
93
|
-
const { fullMatch, block } = matches[i];
|
|
94
|
-
codeBlocks.unshift(block);
|
|
95
|
-
textWithoutCode = textWithoutCode.replace(fullMatch, "");
|
|
96
|
-
}
|
|
97
|
-
return { codeBlocks, textWithoutCode };
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Extracts markdown links from text
|
|
101
|
-
*/
|
|
102
|
-
export function extractLinks(text) {
|
|
103
|
-
const links = [];
|
|
104
|
-
// Reset regex state
|
|
105
|
-
MARKDOWN_LINK_REGEX.lastIndex = 0;
|
|
106
|
-
let match;
|
|
107
|
-
match = MARKDOWN_LINK_REGEX.exec(text);
|
|
108
|
-
while (match !== null) {
|
|
109
|
-
links.push({
|
|
110
|
-
text: match[1],
|
|
111
|
-
url: match[2],
|
|
112
|
-
});
|
|
113
|
-
match = MARKDOWN_LINK_REGEX.exec(text);
|
|
114
|
-
}
|
|
115
|
-
// Replace markdown links with just the text (for plain text output)
|
|
116
|
-
const textWithLinks = text.replace(MARKDOWN_LINK_REGEX, "$1");
|
|
117
|
-
return { links, textWithLinks };
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* Strips markdown formatting from text
|
|
121
|
-
*/
|
|
122
|
-
export function stripMarkdown(text) {
|
|
123
|
-
let result = text;
|
|
124
|
-
// Remove bold: **text** or __text__
|
|
125
|
-
result = result.replace(/\*\*(.+?)\*\*/g, "$1");
|
|
126
|
-
result = result.replace(/__(.+?)__/g, "$1");
|
|
127
|
-
// Remove italic: *text* or _text_ (but not already processed)
|
|
128
|
-
result = result.replace(/(?<!\*)\*(?!\*)(.+?)(?<!\*)\*(?!\*)/g, "$1");
|
|
129
|
-
result = result.replace(/(?<!_)_(?!_)(.+?)(?<!_)_(?!_)/g, "$1");
|
|
130
|
-
// Remove strikethrough: ~~text~~
|
|
131
|
-
result = result.replace(/~~(.+?)~~/g, "$1");
|
|
132
|
-
// Remove headers: # Title, ## Title, etc.
|
|
133
|
-
result = result.replace(/^#{1,6}\s+(.+)$/gm, "$1");
|
|
134
|
-
// Remove blockquotes: > text
|
|
135
|
-
result = result.replace(/^>\s?(.*)$/gm, "$1");
|
|
136
|
-
// Remove horizontal rules: ---, ***, ___
|
|
137
|
-
result = result.replace(/^[-*_]{3,}$/gm, "");
|
|
138
|
-
// Remove inline code: `code`
|
|
139
|
-
result = result.replace(/`([^`]+)`/g, "$1");
|
|
140
|
-
// Clean up extra whitespace
|
|
141
|
-
result = result.replace(/\n{3,}/g, "\n\n");
|
|
142
|
-
result = result.trim();
|
|
143
|
-
return result;
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* Checks if text contains markdown that needs conversion
|
|
147
|
-
*/
|
|
148
|
-
export function hasMarkdownContent(text) {
|
|
149
|
-
// Check for tables
|
|
150
|
-
MARKDOWN_TABLE_REGEX.lastIndex = 0;
|
|
151
|
-
if (MARKDOWN_TABLE_REGEX.test(text)) {
|
|
152
|
-
return true;
|
|
153
|
-
}
|
|
154
|
-
// Check for code blocks
|
|
155
|
-
MARKDOWN_CODE_BLOCK_REGEX.lastIndex = 0;
|
|
156
|
-
if (MARKDOWN_CODE_BLOCK_REGEX.test(text)) {
|
|
157
|
-
return true;
|
|
158
|
-
}
|
|
159
|
-
// Check for other markdown patterns
|
|
160
|
-
if (/\*\*[^*]+\*\*/.test(text)) {
|
|
161
|
-
return true;
|
|
162
|
-
}
|
|
163
|
-
if (/~~[^~]+~~/.test(text)) {
|
|
164
|
-
return true;
|
|
165
|
-
}
|
|
166
|
-
if (/^#{1,6}\s+/m.test(text)) {
|
|
167
|
-
return true;
|
|
168
|
-
}
|
|
169
|
-
if (/^>\s+/m.test(text)) {
|
|
170
|
-
return true;
|
|
171
|
-
}
|
|
172
|
-
return false;
|
|
173
|
-
}
|
|
174
|
-
/**
|
|
175
|
-
* Processes text for LINE output
|
|
176
|
-
*/
|
|
177
|
-
export function processLineMessage(text) {
|
|
178
|
-
let processedText = text;
|
|
179
|
-
// Extract tables
|
|
180
|
-
const { tables, textWithoutTables } = extractMarkdownTables(processedText);
|
|
181
|
-
processedText = textWithoutTables;
|
|
182
|
-
// Extract code blocks
|
|
183
|
-
const { codeBlocks, textWithoutCode } = extractCodeBlocks(processedText);
|
|
184
|
-
processedText = textWithoutCode;
|
|
185
|
-
// Handle links
|
|
186
|
-
const { links, textWithLinks } = extractLinks(processedText);
|
|
187
|
-
processedText = textWithLinks;
|
|
188
|
-
// Strip remaining markdown formatting
|
|
189
|
-
processedText = stripMarkdown(processedText);
|
|
190
|
-
return {
|
|
191
|
-
text: processedText,
|
|
192
|
-
tables,
|
|
193
|
-
codeBlocks,
|
|
194
|
-
links,
|
|
195
|
-
};
|
|
196
|
-
}
|
|
197
|
-
/**
|
|
198
|
-
* Splits text at the last safe break point within the limit
|
|
199
|
-
*/
|
|
200
|
-
function splitAtBreakPoint(text, limit) {
|
|
201
|
-
if (text.length <= limit) {
|
|
202
|
-
return { chunk: text, remainder: "" };
|
|
203
|
-
}
|
|
204
|
-
// Try to find a natural break point
|
|
205
|
-
const searchArea = text.slice(0, limit);
|
|
206
|
-
// Prefer double newlines (paragraph breaks)
|
|
207
|
-
const doubleNewline = searchArea.lastIndexOf("\n\n");
|
|
208
|
-
if (doubleNewline > limit * 0.5) {
|
|
209
|
-
return {
|
|
210
|
-
chunk: text.slice(0, doubleNewline).trimEnd(),
|
|
211
|
-
remainder: text.slice(doubleNewline + 2).trimStart(),
|
|
212
|
-
};
|
|
213
|
-
}
|
|
214
|
-
// Try single newlines
|
|
215
|
-
const singleNewline = searchArea.lastIndexOf("\n");
|
|
216
|
-
if (singleNewline > limit * 0.5) {
|
|
217
|
-
return {
|
|
218
|
-
chunk: text.slice(0, singleNewline).trimEnd(),
|
|
219
|
-
remainder: text.slice(singleNewline + 1).trimStart(),
|
|
220
|
-
};
|
|
221
|
-
}
|
|
222
|
-
// Try sentence boundaries
|
|
223
|
-
const sentenceEnd = Math.max(searchArea.lastIndexOf(". "), searchArea.lastIndexOf("! "), searchArea.lastIndexOf("? "));
|
|
224
|
-
if (sentenceEnd > limit * 0.5) {
|
|
225
|
-
return {
|
|
226
|
-
chunk: text.slice(0, sentenceEnd + 1).trimEnd(),
|
|
227
|
-
remainder: text.slice(sentenceEnd + 2).trimStart(),
|
|
228
|
-
};
|
|
229
|
-
}
|
|
230
|
-
// Try word boundaries
|
|
231
|
-
const space = searchArea.lastIndexOf(" ");
|
|
232
|
-
if (space > limit * 0.5) {
|
|
233
|
-
return {
|
|
234
|
-
chunk: text.slice(0, space).trimEnd(),
|
|
235
|
-
remainder: text.slice(space + 1).trimStart(),
|
|
236
|
-
};
|
|
237
|
-
}
|
|
238
|
-
// Hard break at limit
|
|
239
|
-
return {
|
|
240
|
-
chunk: text.slice(0, limit),
|
|
241
|
-
remainder: text.slice(limit),
|
|
242
|
-
};
|
|
243
|
-
}
|
|
244
|
-
/**
|
|
245
|
-
* Chunks text for LINE messages
|
|
246
|
-
*/
|
|
247
|
-
export function chunkLineText(text, opts = {}) {
|
|
248
|
-
const limit = opts.limit ?? LINE_TEXT_CHUNK_LIMIT;
|
|
249
|
-
if (!text?.trim()) {
|
|
250
|
-
return [];
|
|
251
|
-
}
|
|
252
|
-
const normalizedText = text.trim();
|
|
253
|
-
if (normalizedText.length <= limit) {
|
|
254
|
-
return [normalizedText];
|
|
255
|
-
}
|
|
256
|
-
const chunks = [];
|
|
257
|
-
let remaining = normalizedText;
|
|
258
|
-
while (remaining.length > 0) {
|
|
259
|
-
const { chunk, remainder } = splitAtBreakPoint(remaining, limit);
|
|
260
|
-
if (chunk) {
|
|
261
|
-
chunks.push(chunk);
|
|
262
|
-
}
|
|
263
|
-
remaining = remainder;
|
|
264
|
-
}
|
|
265
|
-
return chunks.filter((c) => c.length > 0);
|
|
266
|
-
}
|
|
267
|
-
/**
|
|
268
|
-
* Processes and chunks a markdown message for LINE
|
|
269
|
-
*/
|
|
270
|
-
export function markdownToLineChunks(markdown, opts = {}) {
|
|
271
|
-
const processed = processLineMessage(markdown);
|
|
272
|
-
const textChunks = chunkLineText(processed.text, opts);
|
|
273
|
-
return {
|
|
274
|
-
textChunks,
|
|
275
|
-
tables: processed.tables,
|
|
276
|
-
codeBlocks: processed.codeBlocks,
|
|
277
|
-
links: processed.links,
|
|
278
|
-
};
|
|
279
|
-
}
|
|
280
|
-
/**
|
|
281
|
-
* Formats a table as plain text
|
|
282
|
-
*/
|
|
283
|
-
export function formatTableAsText(table) {
|
|
284
|
-
const lines = [];
|
|
285
|
-
// Header
|
|
286
|
-
lines.push(table.headers.join(" | "));
|
|
287
|
-
lines.push("-".repeat(lines[0].length));
|
|
288
|
-
// Rows
|
|
289
|
-
for (const row of table.rows) {
|
|
290
|
-
lines.push(row.join(" | "));
|
|
291
|
-
}
|
|
292
|
-
return lines.join("\n");
|
|
293
|
-
}
|
|
294
|
-
/**
|
|
295
|
-
* Formats a code block as plain text
|
|
296
|
-
*/
|
|
297
|
-
export function formatCodeBlockAsText(block) {
|
|
298
|
-
const langLabel = block.language ? `[${block.language}]` : "[code]";
|
|
299
|
-
return `${langLabel}\n${block.code}`;
|
|
300
|
-
}
|
|
301
|
-
/**
|
|
302
|
-
* Truncates text to a maximum length with ellipsis
|
|
303
|
-
*/
|
|
304
|
-
export function truncateText(text, maxLength) {
|
|
305
|
-
if (text.length <= maxLength) {
|
|
306
|
-
return text;
|
|
307
|
-
}
|
|
308
|
-
if (maxLength <= 3) {
|
|
309
|
-
return "...".slice(0, maxLength);
|
|
310
|
-
}
|
|
311
|
-
return `${text.slice(0, maxLength - 3)}...`;
|
|
312
|
-
}
|
|
313
|
-
/**
|
|
314
|
-
* Formats a LINE user display name
|
|
315
|
-
*/
|
|
316
|
-
export function formatLineUser(displayName, userId) {
|
|
317
|
-
return displayName || `User(${userId.slice(0, 8)}...)`;
|
|
318
|
-
}
|
|
319
|
-
/**
|
|
320
|
-
* Builds a LINE deep link URL
|
|
321
|
-
*/
|
|
322
|
-
export function buildLineDeepLink(_type, id) {
|
|
323
|
-
return `line://ti/p/${id}`;
|
|
324
|
-
}
|
|
325
|
-
/**
|
|
326
|
-
* Resolves the system location string for logging
|
|
327
|
-
*/
|
|
328
|
-
export function resolveLineSystemLocation(params) {
|
|
329
|
-
const { chatType, chatId, chatName } = params;
|
|
330
|
-
const name = chatName || chatId.slice(0, 8);
|
|
331
|
-
return `LINE ${chatType}:${name}`;
|
|
332
|
-
}
|
|
333
|
-
/**
|
|
334
|
-
* Checks if a chat is a group chat
|
|
335
|
-
*/
|
|
336
|
-
export function isGroupChat(params) {
|
|
337
|
-
return Boolean(params.groupId || params.roomId);
|
|
338
|
-
}
|
|
339
|
-
/**
|
|
340
|
-
* Gets the chat ID from context
|
|
341
|
-
*/
|
|
342
|
-
export function getChatId(params) {
|
|
343
|
-
return params.groupId || params.roomId || params.userId;
|
|
344
|
-
}
|
|
345
|
-
/**
|
|
346
|
-
* Gets the chat type from context
|
|
347
|
-
*/
|
|
348
|
-
export function getChatType(params) {
|
|
349
|
-
if (params.groupId) {
|
|
350
|
-
return "group";
|
|
351
|
-
}
|
|
352
|
-
if (params.roomId) {
|
|
353
|
-
return "room";
|
|
354
|
-
}
|
|
355
|
-
return "user";
|
|
356
|
-
}
|
|
357
|
-
//# sourceMappingURL=messaging.js.map
|
package/dist/messaging.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"messaging.js","sourceRoot":"","sources":["../src/messaging.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,CAAC;AAE1C;;GAEG;AACH,MAAM,CAA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,CAAC;IAC9C,MAAM,IAAI,GAAG,QAAQ,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC5C,OAAO,QAAQ,QAAQ,IAAI,IAAI,EAAE,CAAC;AACpC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,WAAW,CAAC,MAA6C;IACvE,OAAO,OAAO,CAAC,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,MAAM,CAAC,CAAC;AAClD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,SAAS,CAAC,MAA6D;IACrF,OAAO,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,CAAC;AAC1D,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,WAAW,CAAC,MAG3B;IACC,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;QACnB,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;QAClB,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"chatContext.d.ts","sourceRoot":"","sources":["../../src/providers/chatContext.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAyB,QAAQ,EAAyB,MAAM,eAAe,CAAC;AAI5F,eAAO,MAAM,mBAAmB,EAAE,QA0FjC,CAAC"}
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Chat context provider for the LINE plugin.
|
|
3
|
-
*/
|
|
4
|
-
import { LINE_SERVICE_NAME } from "../types.js";
|
|
5
|
-
export const chatContextProvider = {
|
|
6
|
-
name: "lineChatContext",
|
|
7
|
-
description: "Provides information about the current LINE chat context",
|
|
8
|
-
dynamic: true,
|
|
9
|
-
get: async (runtime, message, state) => {
|
|
10
|
-
// Only provide context for LINE messages
|
|
11
|
-
if (message.content.source !== "line") {
|
|
12
|
-
return {
|
|
13
|
-
data: {},
|
|
14
|
-
values: {},
|
|
15
|
-
text: "",
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
const lineService = runtime.getService(LINE_SERVICE_NAME);
|
|
19
|
-
if (!lineService || !lineService.isConnected()) {
|
|
20
|
-
return {
|
|
21
|
-
data: { connected: false },
|
|
22
|
-
values: { connected: false },
|
|
23
|
-
text: "",
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
const agentName = state?.agentName || "The agent";
|
|
27
|
-
const stateData = (state?.data || {});
|
|
28
|
-
const userId = stateData.userId;
|
|
29
|
-
const groupId = stateData.groupId;
|
|
30
|
-
const roomId = stateData.roomId;
|
|
31
|
-
let chatType = "user";
|
|
32
|
-
let chatId = userId || "";
|
|
33
|
-
if (groupId) {
|
|
34
|
-
chatType = "group";
|
|
35
|
-
chatId = groupId;
|
|
36
|
-
}
|
|
37
|
-
else if (roomId) {
|
|
38
|
-
chatType = "room";
|
|
39
|
-
chatId = roomId;
|
|
40
|
-
}
|
|
41
|
-
// Get additional info based on chat type
|
|
42
|
-
let chatName = "";
|
|
43
|
-
let memberCount;
|
|
44
|
-
if (chatType === "group" && groupId) {
|
|
45
|
-
const groupInfo = await lineService.getGroupInfo(groupId);
|
|
46
|
-
if (groupInfo) {
|
|
47
|
-
chatName = groupInfo.groupName || "";
|
|
48
|
-
memberCount = groupInfo.memberCount;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
let responseText = `${agentName} is chatting on LINE `;
|
|
52
|
-
if (chatType === "user") {
|
|
53
|
-
responseText += "in a direct message conversation.";
|
|
54
|
-
}
|
|
55
|
-
else if (chatType === "group") {
|
|
56
|
-
responseText += `in group "${chatName || chatId}".`;
|
|
57
|
-
if (memberCount) {
|
|
58
|
-
responseText += ` The group has ${memberCount} members.`;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
else if (chatType === "room") {
|
|
62
|
-
responseText += "in a multi-person chat room.";
|
|
63
|
-
}
|
|
64
|
-
responseText +=
|
|
65
|
-
" LINE supports text messages, images, locations, rich cards (flex messages), and quick replies.";
|
|
66
|
-
return {
|
|
67
|
-
data: {
|
|
68
|
-
chatType,
|
|
69
|
-
chatId,
|
|
70
|
-
userId,
|
|
71
|
-
groupId,
|
|
72
|
-
roomId,
|
|
73
|
-
chatName,
|
|
74
|
-
memberCount,
|
|
75
|
-
connected: true,
|
|
76
|
-
},
|
|
77
|
-
values: {
|
|
78
|
-
chatType,
|
|
79
|
-
chatId,
|
|
80
|
-
chatName,
|
|
81
|
-
},
|
|
82
|
-
text: responseText,
|
|
83
|
-
};
|
|
84
|
-
},
|
|
85
|
-
};
|
|
86
|
-
//# sourceMappingURL=chatContext.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"chatContext.js","sourceRoot":"","sources":["../../src/providers/chatContext.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EAAE,iBAAiB,EAAqB,MAAM,aAAa,CAAC;AAEnE,MAAM,CAAC,MAAM,mBAAmB,GAAa;IAC3C,IAAI,EAAE,iBAAiB;IACvB,WAAW,EAAE,0DAA0D;IAEvE,OAAO,EAAE,IAAI;IACb,GAAG,EAAE,KAAK,EAAE,OAAsB,EAAE,OAAe,EAAE,KAAY,EAA2B,EAAE;QAC5F,yCAAyC;QACzC,IAAI,OAAO,CAAC,OAAO,CAAC,MAAM,KAAK,MAAM,EAAE,CAAC;YACtC,OAAO;gBACL,IAAI,EAAE,EAAE;gBACR,MAAM,EAAE,EAAE;gBACV,IAAI,EAAE,EAAE;aACT,CAAC;QACJ,CAAC;QAED,MAAM,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,iBAAiB,CAAuC,CAAC;QAEhG,IAAI,CAAC,WAAW,IAAI,CAAC,WAAW,CAAC,WAAW,EAAE,EAAE,CAAC;YAC/C,OAAO;gBACL,IAAI,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE;gBAC1B,MA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AQ,IAAI,MAAM,IAAI,CAAC;YACpD,IAAI,WAAW,EAAE,CAAC;gBAChB,YAAY,IAAI,kBAAkB,WAAW,WAAW,CAAC;YAC3D,CAAC;QACH,CAAC;aAAM,IAAI,QAAQ,KAAK,MAAM,EAAE,CAAC;YAC/B,YAAY,IAAI,8BAA8B,CAAC;QACjD,CAAC;QAED,YAAY;YACV,iGAAiG,CAAC;QAEpG,OAAO;YACL,IAAI,EAAE;gBACJ,QAAQ;gBACR,MAAM;gBACN,MAAM;gBACN,OAAO;gBACP,MAAM;gBACN,QAAQ;gBACR,WAAW;gBACX,SAAS,EAAE,IAAI;aAChB;YACD,MAAM,EAAE;gBACN,QAAQ;gBACR,MAAM;gBACN,QAAQ;aACT;YACD,IAAI,EAAE,YAAY;SACnB,CAAC;IACJ,CAAC;CACF,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/providers/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC"}
|
package/dist/providers/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/providers/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"userContext.d.ts","sourceRoot":"","sources":["../../src/providers/userContext.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAyB,QAAQ,EAAyB,MAAM,eAAe,CAAC;AAI5F,eAAO,MAAM,mBAAmB,EAAE,QA4EjC,CAAC"}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* User context provider for the LINE plugin.
|
|
3
|
-
*/
|
|
4
|
-
import { LINE_SERVICE_NAME } from "../types.js";
|
|
5
|
-
export const userContextProvider = {
|
|
6
|
-
name: "lineUserContext",
|
|
7
|
-
description: "Provides information about the LINE user in the current conversation",
|
|
8
|
-
dynamic: true,
|
|
9
|
-
get: async (runtime, message, state) => {
|
|
10
|
-
// Only provide context for LINE messages
|
|
11
|
-
if (message.content.source !== "line") {
|
|
12
|
-
return {
|
|
13
|
-
data: {},
|
|
14
|
-
values: {},
|
|
15
|
-
text: "",
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
const lineService = runtime.getService(LINE_SERVICE_NAME);
|
|
19
|
-
if (!lineService || !lineService.isConnected()) {
|
|
20
|
-
return {
|
|
21
|
-
data: { connected: false },
|
|
22
|
-
values: { connected: false },
|
|
23
|
-
text: "",
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
const agentName = state?.agentName || "The agent";
|
|
27
|
-
const stateData = (state?.data || {});
|
|
28
|
-
const userId = stateData.userId;
|
|
29
|
-
if (!userId) {
|
|
30
|
-
return {
|
|
31
|
-
data: { connected: true },
|
|
32
|
-
values: { connected: true },
|
|
33
|
-
text: "",
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
// Get user profile
|
|
37
|
-
const profile = await lineService.getUserProfile(userId);
|
|
38
|
-
if (!profile) {
|
|
39
|
-
return {
|
|
40
|
-
data: {
|
|
41
|
-
connected: true,
|
|
42
|
-
userId,
|
|
43
|
-
},
|
|
44
|
-
values: {
|
|
45
|
-
userId,
|
|
46
|
-
},
|
|
47
|
-
text: `${agentName} is talking to a LINE user (ID: ${userId.slice(0, 8)}...).`,
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
const responseText = `${agentName} is talking to ${profile.displayName} on LINE. ` +
|
|
51
|
-
(profile.statusMessage ? `Their status: "${profile.statusMessage}". ` : "") +
|
|
52
|
-
(profile.language ? `Language preference: ${profile.language}.` : "");
|
|
53
|
-
return {
|
|
54
|
-
data: {
|
|
55
|
-
userId: profile.userId,
|
|
56
|
-
displayName: profile.displayName,
|
|
57
|
-
pictureUrl: profile.pictureUrl,
|
|
58
|
-
statusMessage: profile.statusMessage,
|
|
59
|
-
language: profile.language,
|
|
60
|
-
connected: true,
|
|
61
|
-
},
|
|
62
|
-
values: {
|
|
63
|
-
userId: profile.userId,
|
|
64
|
-
displayName: profile.displayName,
|
|
65
|
-
language: profile.language,
|
|
66
|
-
},
|
|
67
|
-
text: responseText,
|
|
68
|
-
};
|
|
69
|
-
},
|
|
70
|
-
};
|
|
71
|
-
//# sourceMappingURL=userContext.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"userContext.js","sourceRoot":"","sources":["../../src/providers/userContext.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD,MAAM,CAAC,MAAM,mBAAmB,GAAa;IAC3C,IAAI,EAAE,iBAAiB;IACvB,WAAW,EAAE,sEAAsE;IAEnF,OAAO,EAAE,IAAI;IACb,GAAG,EAAE,KAAK,EAAE,OAAsB,EAAE,OAAe,EAAE,KAAY,EAA2B,EAAE;QAC5F,yCAAyC;QACzC,IAAI,OAAO,CAAC,OAAO,CAAC,MAAM,KAAK,MAAM,EAAE,CAAC;YACtC,OAAO;gBACL,IAAI,EAAE,EAAE;gBACR,MAAM,EAAE,EAAE;gBACV,IAAI,EAAE,EAAE;aACT,CAAC;QACJ,CAAC;QAED,MAAM,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,iBAAiB,CAAuC,CAAC;QAEhG,IAAI,CAAC,WAAW,IAAI,CAAC,WAAW,CAAC,WAAW,EAAE,EAAE,CAAC;YAC/C,OAAO;gBACL,IAAI,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE;gBAC1B,MAAM,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE;gBAC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