@ducci/jarvis 1.0.56 → 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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ducci/jarvis",
3
- "version": "1.0.56",
3
+ "version": "1.0.57",
4
4
  "description": "A fully automated agent system that lives on a server.",
5
5
  "main": "./src/index.js",
6
6
  "type": "module",
@@ -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 ts = new Date().toISOString();
18
- const line = `${ts} [${direction}] ${String(text).replace(/\n/g, ' ')}\n`;
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)
@@ -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 ts = new Date().toISOString().slice(0, 16).replace('T', ' ');
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 () => {