openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
30 lines (29 loc) • 1.27 kB
JavaScript
import { o as emitTrustedDiagnosticEvent, t as areDiagnosticsEnabledForProcess } from "./diagnostic-events-Cwe92uV3.js";
import { f as markDiagnosticRunProgress } from "./diagnostic-run-activity-CJrEba4R.js";
//#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) {
let lastEmittedAtMs;
return (target) => {
if (recordProgress && !recordProgress()) return;
if (!areDiagnosticsEnabledForProcess()) return;
const fields = {
runId: target.runId,
...target.sessionKey ? { sessionKey: target.sessionKey } : {},
...target.sessionId ? { sessionId: target.sessionId } : {},
reason: MODEL_CALL_STREAM_PROGRESS_REASON
};
if (!recordProgress) markDiagnosticRunProgress(fields);
const now = Date.now();
if (lastEmittedAtMs !== void 0 && now - lastEmittedAtMs < MODEL_CALL_STREAM_PROGRESS_INTERVAL_MS) return;
lastEmittedAtMs = now;
emitTrustedDiagnosticEvent({
type: "run.progress",
...fields
});
};
}
//#endregion
export { createModelCallStreamProgressReporter as t };