@ducci/jarvis 1.0.55 → 1.0.57
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/package.json
CHANGED
|
@@ -12,10 +12,10 @@ function getTelegramChatLogPath(chatId, sessionId) {
|
|
|
12
12
|
return path.join(PATHS.telegramChatsDir, `${chatId}-${prefix}.log`);
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
async function appendTelegramChatLog(chatId, sessionId, direction, text) {
|
|
15
|
+
async function appendTelegramChatLog(chatId, sessionId, direction, text, ts = null) {
|
|
16
16
|
const logFile = getTelegramChatLogPath(chatId, sessionId);
|
|
17
|
-
const
|
|
18
|
-
const line = `${
|
|
17
|
+
const timestamp = ts || new Date().toISOString();
|
|
18
|
+
const line = `${timestamp} [${direction}] ${String(text).replace(/\n/g, ' ')}\n`;
|
|
19
19
|
await fs.promises.appendFile(logFile, line, 'utf8').catch(() => {});
|
|
20
20
|
}
|
|
21
21
|
|
|
@@ -121,6 +121,7 @@ export async function startTelegramChannel(config) {
|
|
|
121
121
|
ctx.api.sendChatAction(chatId, 'typing').catch(() => {});
|
|
122
122
|
}, 4000);
|
|
123
123
|
|
|
124
|
+
const userTs = new Date().toISOString();
|
|
124
125
|
let result;
|
|
125
126
|
try {
|
|
126
127
|
const photo = ctx.message.photo.filter(p => p.width <= 800).at(-1)
|
|
@@ -150,7 +151,7 @@ export async function startTelegramChannel(config) {
|
|
|
150
151
|
}
|
|
151
152
|
|
|
152
153
|
const captionText = ctx.message.caption || '[photo]';
|
|
153
|
-
await appendTelegramChatLog(chatId, result.sessionId, 'USER', `[photo] ${captionText}
|
|
154
|
+
await appendTelegramChatLog(chatId, result.sessionId, 'USER', `[photo] ${captionText}`, userTs);
|
|
154
155
|
|
|
155
156
|
try {
|
|
156
157
|
const rawResponse = typeof result.response === 'string'
|
|
@@ -185,6 +186,7 @@ export async function startTelegramChannel(config) {
|
|
|
185
186
|
ctx.api.sendChatAction(chatId, 'typing').catch(() => {});
|
|
186
187
|
}, 4000);
|
|
187
188
|
|
|
189
|
+
const userTs = new Date().toISOString();
|
|
188
190
|
let result;
|
|
189
191
|
try {
|
|
190
192
|
result = await handleChat(config, sessionId, ctx.message.text);
|
|
@@ -205,7 +207,7 @@ export async function startTelegramChannel(config) {
|
|
|
205
207
|
console.log(`[telegram] session created sessionId=${result.sessionId.slice(0, 8)}`);
|
|
206
208
|
}
|
|
207
209
|
|
|
208
|
-
await appendTelegramChatLog(chatId, result.sessionId, 'USER', ctx.message.text);
|
|
210
|
+
await appendTelegramChatLog(chatId, result.sessionId, 'USER', ctx.message.text, userTs);
|
|
209
211
|
|
|
210
212
|
try {
|
|
211
213
|
// Guard against empty or non-string response (e.g. model returns array instead of string)
|
package/src/server/crons.js
CHANGED
|
@@ -29,7 +29,8 @@ async function writeSyntheticMessageToTelegramSession(entry, response, config) {
|
|
|
29
29
|
const sessionId = sessions[chatId];
|
|
30
30
|
if (!sessionId) return;
|
|
31
31
|
|
|
32
|
-
const
|
|
32
|
+
const tz = config.timezone || 'Europe/Berlin';
|
|
33
|
+
const ts = new Date().toLocaleString('sv', { timeZone: tz }).slice(0, 16);
|
|
33
34
|
const syntheticMessage = `[Cron "${entry.name}" | ${ts}] ${response}`;
|
|
34
35
|
|
|
35
36
|
await withSessionLock(sessionId, async () => {
|
package/src/server/tools.js
CHANGED
|
@@ -38,7 +38,7 @@ const SEED_TOOLS = {
|
|
|
38
38
|
},
|
|
39
39
|
},
|
|
40
40
|
code: `
|
|
41
|
-
const targetPath = path.resolve(
|
|
41
|
+
const _p = args.path; const targetPath = path.resolve(_p === '~' || _p.startsWith('~/') ? require('os').homedir() + _p.slice(1) : _p);
|
|
42
42
|
const raw = await fs.promises.readFile(targetPath, 'utf8');
|
|
43
43
|
const lines = raw.split('\\n');
|
|
44
44
|
const offset = args.offset ? args.offset - 1 : 0;
|
|
@@ -308,7 +308,7 @@ const SEED_TOOLS = {
|
|
|
308
308
|
},
|
|
309
309
|
},
|
|
310
310
|
code: `
|
|
311
|
-
const targetPath = path.resolve(
|
|
311
|
+
const _p = args.path; const targetPath = path.resolve(_p === '~' || _p.startsWith('~/') ? require('os').homedir() + _p.slice(1) : _p);
|
|
312
312
|
await fs.promises.mkdir(path.dirname(targetPath), { recursive: true });
|
|
313
313
|
await fs.promises.writeFile(targetPath, args.content, 'utf8');
|
|
314
314
|
if (args.mode) {
|
|
@@ -345,7 +345,7 @@ const SEED_TOOLS = {
|
|
|
345
345
|
},
|
|
346
346
|
},
|
|
347
347
|
code: `
|
|
348
|
-
const targetPath = path.resolve(
|
|
348
|
+
const _p = args.path; const targetPath = path.resolve(_p === '~' || _p.startsWith('~/') ? require('os').homedir() + _p.slice(1) : _p);
|
|
349
349
|
const content = await fs.promises.readFile(targetPath, 'utf8');
|
|
350
350
|
const count = content.split(args.old_string).length - 1;
|
|
351
351
|
if (count === 0) {
|