Files
dj/huobao-source/backend/src/services/local-task-tracking.ts
T

19 lines
951 B
TypeScript

import { taskRouting } from './worker-routing.js'
import type { AIConfig } from './adapters/types.js'
export function isLocalQueuedTask(config: Pick<AIConfig, 'baseUrl' | 'provider'>, taskId?: string | null): boolean {
try {
const url = new URL(config.baseUrl)
return url.hostname === '192.168.110.111' && ['18792', '18794'].includes(url.port)
&& !!taskRouting({ provider: config.provider, taskId })
} catch { return false }
}
export function taskPollingProfile(type: 'image' | 'video', local: boolean, hd = false) {
// Queue waiting and confirmed execution are not generation failures. These
// services retain job IDs, so tracking can resume without submitting again.
if (local) return { attempts: Infinity, intervalMs: 10_000, maxDurationMs: null }
if (type === 'image') return { attempts: 120, intervalMs: 5000, maxDurationMs: 600_000 }
return { attempts: hd ? 1080 : 300, intervalMs: 10_000, maxDurationMs: null }
}