UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

40 lines (39 loc) • 1.57 kB
import { s as emitTrustedDiagnosticEvent, t as areDiagnosticsEnabledForProcess } from "./diagnostic-events-BjAH1Kbx.mjs"; import { n as emitDiagnosticsTimelineEvent, o as isDiagnosticsTimelineEnabled } from "./diagnostics-timeline-CSwiG24r.mjs"; import { u as markDiagnosticRunProgress } from "./diagnostic-run-activity-BzWz2WN_.mjs"; //#region src/logging/diagnostic-model-stream-progress.ts const MODEL_CALL_STREAM_PROGRESS_INTERVAL_MS = 3e4; /** Canonical progress reason for model output observed on a live backend stream. */ const MODEL_CALL_STREAM_PROGRESS_REASON = "model_call:stream_progress"; function createModelCallStreamProgressReporter({ recordProgress: e, config: t, target: n }) { const r = { runId: n.runId, ...n.sessionKey ? { sessionKey: n.sessionKey } : {}, ...n.sessionId ? { sessionId: n.sessionId } : {}, reason: MODEL_CALL_STREAM_PROGRESS_REASON }; let i; return (a) => { if (e && !e()) return; const o = areDiagnosticsEnabledForProcess(); if (o && !e) markDiagnosticRunProgress(r); const s = Date.now(); if (i !== void 0 && s - i < MODEL_CALL_STREAM_PROGRESS_INTERVAL_MS) return; const c = a !== void 0 && isDiagnosticsTimelineEnabled({ config: t }); if (!o && !c) return; i = s; if (o) emitTrustedDiagnosticEvent({ type: "run.progress", ...r }); if (c) emitDiagnosticsTimelineEvent({ type: "mark", name: "provider.request.activity", timestamp: new Date(s).toISOString(), runId: n.runId, spanId: a }, { config: t }); }; } //#endregion export { createModelCallStreamProgressReporter as t };