add logging

This commit is contained in:
Ramnique Singh 2026-04-13 13:45:35 +05:30
parent 9587368acf
commit f31ad34b78

View file

@ -4,6 +4,7 @@ import { createRun, createMessage } from '../../runs/runs.js';
import { extractAgentResponse, waitForRunCompletion } from '../../agents/utils.js'; import { extractAgentResponse, waitForRunCompletion } from '../../agents/utils.js';
import { trackBus } from './bus.js'; import { trackBus } from './bus.js';
import type { TrackStateSchema } from './types.js'; import type { TrackStateSchema } from './types.js';
import { PrefixLogger } from '@x/shared/dist/prefix-logger.js';
export interface TrackUpdateResult { export interface TrackUpdateResult {
trackId: string; trackId: string;
@ -63,16 +64,20 @@ export async function triggerTrackUpdate(
trigger: 'manual' | 'timed' | 'event' = 'manual', trigger: 'manual' | 'timed' | 'event' = 'manual',
): Promise<TrackUpdateResult> { ): Promise<TrackUpdateResult> {
const key = `${trackId}:${filePath}`; const key = `${trackId}:${filePath}`;
const logger = new PrefixLogger('track:runner');
logger.log('triggering track update', trackId, filePath, trigger, context);
if (runningTracks.has(key)) { if (runningTracks.has(key)) {
logger.log('skipping, already running');
return { trackId, action: 'no_update', contentBefore: null, contentAfter: null, summary: null, error: 'Already running' }; return { trackId, action: 'no_update', contentBefore: null, contentAfter: null, summary: null, error: 'Already running' };
} }
runningTracks.add(key); runningTracks.add(key);
try { try {
console.log('triggerTrackUpdate', trackId, filePath, trigger, context);
const tracks = await fetchAll(filePath); const tracks = await fetchAll(filePath);
logger.log('fetched tracks from file', tracks);
const track = tracks.find(t => t.track.trackId === trackId); const track = tracks.find(t => t.track.trackId === trackId);
if (!track) { if (!track) {
logger.log('track not found', trackId, filePath, trigger, context);
return { trackId, action: 'no_update', contentBefore: null, contentAfter: null, summary: null, error: 'Track not found' }; return { trackId, action: 'no_update', contentBefore: null, contentAfter: null, summary: null, error: 'Track not found' };
} }