@ducci/jarvis 1.0.74 → 1.0.75

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.74",
3
+ "version": "1.0.75",
4
4
  "description": "A fully automated agent system that lives on a server.",
5
5
  "main": "./src/index.js",
6
6
  "type": "module",
@@ -1,12 +1,10 @@
1
1
  import fs from 'fs';
2
2
  import path from 'path';
3
- import { runAgentLoop, withSessionLock } from './agent.js';
3
+ import { runAgentLoop } from './agent.js';
4
4
  import { createClient } from './provider.js';
5
5
  import { loadSystemPrompt, resolveSystemPrompt, PATHS } from './config.js';
6
- import { createSession, loadSession, saveSession } from './sessions.js';
6
+ import { createSession } from './sessions.js';
7
7
  import * as cronScheduler from './cron-scheduler.js';
8
- import { load as loadTelegramSessions } from '../channels/telegram/sessions.js';
9
-
10
8
  function loadCrons() {
11
9
  try {
12
10
  return JSON.parse(fs.readFileSync(PATHS.cronsFile, 'utf8'));
@@ -21,25 +19,6 @@ async function appendCronLog(cronId, entry) {
21
19
  await fs.promises.appendFile(logFile, line, 'utf8');
22
20
  }
23
21
 
24
- async function writeSyntheticMessageToTelegramSession(entry, response, config) {
25
- const chatId = config.telegram?.allowedUserIds?.[0];
26
- if (!chatId) return;
27
-
28
- const sessions = loadTelegramSessions();
29
- const sessionId = sessions[chatId];
30
- if (!sessionId) return;
31
-
32
- const tz = config.timezone || 'Europe/Berlin';
33
- const ts = new Date().toLocaleString('sv', { timeZone: tz }).slice(0, 16);
34
- const syntheticMessage = `[Cron "${entry.name}" | ${ts}] ${response}`;
35
-
36
- await withSessionLock(sessionId, async () => {
37
- const session = await loadSession(sessionId);
38
- if (!session) return;
39
- session.messages.push({ role: 'assistant', content: syntheticMessage });
40
- await saveSession(sessionId, session);
41
- });
42
- }
43
22
 
44
23
  export async function runCron(entry, config) {
45
24
  console.log(`[cron] running "${entry.name}"`);
@@ -128,11 +107,6 @@ export async function runCron(entry, config) {
128
107
  logSummary: run.logSummary,
129
108
  }).catch(e => console.error(`[cron] log error: ${e.message}`));
130
109
 
131
- // Write synthetic message to user's Telegram session
132
- await writeSyntheticMessageToTelegramSession(entry, run.response, config).catch(e => {
133
- console.error(`[cron] telegram session write error: ${e.message}`);
134
- });
135
-
136
110
  // once: true — delete after firing
137
111
  if (entry.once) {
138
112
  try {
@@ -550,6 +550,15 @@ const SEED_TOOLS = {
550
550
  const ts = new Date().toISOString();
551
551
  await fs.promises.mkdir(logDir, { recursive: true });
552
552
  await fs.promises.appendFile(logFile, ts + ' [CRON] ' + String(args.message).replace(/\\n/g, ' ') + '\\n', 'utf8');
553
+ if (sessionId) {
554
+ const convFile = path.join(process.env.HOME, '.jarvis/data/conversations/' + sessionId + '.json');
555
+ try {
556
+ const conv = JSON.parse(await fs.promises.readFile(convFile, 'utf8'));
557
+ conv.messages.push({ role: 'assistant', content: String(args.message) });
558
+ conv.metadata.updatedAt = ts;
559
+ await fs.promises.writeFile(convFile, JSON.stringify(conv, null, 2), 'utf8');
560
+ } catch {}
561
+ }
553
562
  } catch {}
554
563
  return { status: 'ok', chatId };
555
564
  `,