From c50ce657d8116847e3879aedd5580ed8875859b6 Mon Sep 17 00:00:00 2001 From: Jason Carreira Date: Mon, 16 Mar 2026 01:22:43 -0400 Subject: [PATCH] fix(logging): set correct trigger type for cron/heartbeat turns MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Set the correct trigger type ('cron' and 'heartbeat') for cron/heartbeat turns instead of defaulting to 'message', and remove the spurious channel property from heartbeat turns. Written by Cameron ◯ Letta Code "The measure of intelligence is the ability to change." -- Albert Einstein --- src/cron/heartbeat.ts | 3 --- src/cron/service.ts | 7 +++++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/cron/heartbeat.ts b/src/cron/heartbeat.ts index a8307f7..82c004e 100644 --- a/src/cron/heartbeat.ts +++ b/src/cron/heartbeat.ts @@ -278,12 +278,9 @@ export class HeartbeatService { }); // Build trigger context for silent mode - const lastTarget = this.bot.getLastMessageTarget(); const triggerContext: TriggerContext = { type: 'heartbeat', outputMode: 'silent', - sourceChannel: lastTarget?.channel, - sourceChatId: lastTarget?.chatId, }; try { diff --git a/src/cron/service.ts b/src/cron/service.ts index 22a6216..b36455a 100644 --- a/src/cron/service.ts +++ b/src/cron/service.ts @@ -8,6 +8,7 @@ import { existsSync, readFileSync, writeFileSync, appendFileSync, mkdirSync, copyFileSync, renameSync, watch, type FSWatcher } from 'node:fs'; import { resolve, dirname, basename } from 'node:path'; import type { AgentSession } from '../core/interfaces.js'; +import type { TriggerContext } from '../core/types.js'; import type { CronJob, CronJobCreate, CronSchedule, CronConfig, HeartbeatConfig } from './types.js'; import { DEFAULT_HEARTBEAT_MESSAGES } from './types.js'; import { getCronDataDir, getCronLogPath, getCronStorePath, getLegacyCronStorePath } from '../utils/paths.js'; @@ -317,7 +318,8 @@ export class CronService { try { // SILENT MODE - response NOT auto-delivered // Agent must use `lettabot-message` CLI to send messages - const response = await this.bot.sendToAgent(config.message); + const triggerContext: TriggerContext = { type: 'heartbeat', outputMode: 'silent' }; + const response = await this.bot.sendToAgent(config.message, triggerContext); log.info(`Heartbeat finished (SILENT MODE)`); log.info(` - Response: ${response?.slice(0, 100)}${(response?.length || 0) > 100 ? '...' : ''}`); @@ -446,7 +448,8 @@ export class CronService { ].join('\n'); // Send message to agent - const response = await this.bot.sendToAgent(messageWithMetadata); + const triggerContext: TriggerContext = { type: 'cron', outputMode: 'silent' }; + const response = await this.bot.sendToAgent(messageWithMetadata, triggerContext); // Resolve delivery target: explicit config > last message target fallback > silent let deliverTarget: { channel: string; chatId: string } | null = job.deliver ?? null;