openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
170 lines • 7.42 kB
TypeScript
import { Bx as redactSensitiveText, UD as GatewayScheduler, Vx as redactToolPayloadText, it as ReplyOperation, zx as redactSensitiveFieldValue } from "../config-contracts-DqOiJKQx.js";
import { P as OpenClawConfig } from "../types-D3g9JHH2.js";
import { i as DiagnosticMemoryUsage } from "../diagnostic-process-types-DSi9Vq97.js";
import { n as RuntimeEnv } from "../runtime-M_jncu14.js";
import { n as createSubsystemLogger } from "../subsystem-RmDRaRJV.js";
import { i as DiagnosticLivenessWarningReason, n as DiagnosticEventPayload, o as DiagnosticSessionActiveWorkKind, s as DiagnosticSessionState } from "../diagnostic-events-8AWE4yor.js";
import { a as LoggerResolvedSettings, o as getChildLogger, u as LoggerSettings } from "../runtime-env-BGr10jK3.js";
//#region src/logging/diagnostic-liveness.d.ts
type DiagnosticLivenessSample = {
reasons: DiagnosticLivenessWarningReason[];
intervalMs: number;
degradedSinceMs?: number;
eventLoopDelayP99Ms?: number;
eventLoopDelayMaxMs?: number;
eventLoopUtilization?: number;
cpuUserMs?: number;
cpuSystemMs?: number;
cpuTotalMs?: number;
cpuCoreRatio?: number;
};
//#endregion
//#region src/logging/diagnostic-memory.d.ts
type DiagnosticMemoryThresholds = {
rssWarningBytes?: number;
rssCriticalBytes?: number;
heapUsedWarningBytes?: number;
heapUsedCriticalBytes?: number;
pressureRepeatMs?: number;
};
declare function emitDiagnosticMemorySample(options?: {
now?: number;
memoryUsage?: NodeJS.MemoryUsage;
heapSizeLimitBytes?: number;
processMemoryLimitBytes?: number;
physicalMemoryBytes?: number;
isBunRuntime?: boolean;
uptimeMs?: number;
thresholds?: DiagnosticMemoryThresholds;
emitSample?: boolean;
}, collectDiagnostics?: boolean): DiagnosticMemoryUsage;
type EmitDiagnosticMemorySample = (options?: NonNullable<Parameters<typeof emitDiagnosticMemorySample>[0]> & {
thresholds?: DiagnosticMemoryThresholds & {
rssGrowthWarningBytes?: number;
rssGrowthCriticalBytes?: number;
growthWindowMs?: number;
};
writeCriticalBundle?: boolean;
stateDir?: string;
sessionStorePaths?: string[];
resolveSessionStorePaths?: () => string[] | undefined;
}) => ReturnType<typeof emitDiagnosticMemorySample>;
//#endregion
//#region src/logging/diagnostic-session-recovery.d.ts
type StuckSessionRecoveryRequest = {
/** Exact captured controller owner; diagnostic IDs and map absence grant no authority. */
operation?: ReplyOperation;
sessionId?: string;
sessionKey?: string;
sessionFile?: string;
ageMs: number;
queueDepth?: number;
/** Recorded controller decision for SDK recovery callbacks, never independent authority. */
allowActiveAbort?: boolean;
/** Legacy diagnostic threshold metadata retained by the logging-core SDK callback contract. */
repeatedRequestNoProgressAbortMs?: number;
expectedState?: DiagnosticSessionState;
stateGeneration?: number;
/**
* Legacy observation threshold retained for SDK callback compatibility.
* The captured controller alone decides whether its work can be recovered.
*/
staleActiveProgressAbortMs?: number;
/**
* Resolved compaction timeout metadata retained for SDK callbacks.
* It never grants ownerless recovery or changes the controller deadline.
*/
compactionSafetyTimeoutMs?: number;
};
type DiagnosticSessionRecoveryBaseOutcome = {
sessionId?: string;
sessionKey?: string;
activeSessionId?: string;
lane?: string;
activeWorkKind?: DiagnosticSessionActiveWorkKind;
};
type StuckSessionRecoveryOutcome = (DiagnosticSessionRecoveryBaseOutcome & {
status: "noop";
action: "reconcile_state";
reason: "no_active_work" | "pending_session_work";
}) | (DiagnosticSessionRecoveryBaseOutcome & {
status: "aborted";
action: "abort_embedded_run";
aborted: boolean;
drained: boolean;
forceCleared: boolean;
released: number;
queuedCount?: number;
}) | (DiagnosticSessionRecoveryBaseOutcome & {
status: "released";
action: "release_lane";
reason?: "no_active_work" | "stale_lane_task";
released: number;
queuedCount?: number;
}) | (DiagnosticSessionRecoveryBaseOutcome & {
status: "skipped";
action: "observe_only" | "keep_lane";
reason: "active_embedded_run" | "model_attempt_recovery" | "active_reply_work" | "human_input_wait" | "runtime_owned_wait" | "deferred_maintenance_wait" | "terminal_outcome_committed" | "global_lane_wait" | "active_lane_task" | "already_in_flight" | "missing_session_ref" | "stale_session_state";
activeCount?: number;
queuedCount?: number;
}) | (DiagnosticSessionRecoveryBaseOutcome & {
status: "failed";
action: "none";
reason: "exception";
error: string;
}) | (DiagnosticSessionRecoveryBaseOutcome & {
status: "failed";
action: "fail_worker_turn";
reason: "terminal_worker";
error: string;
});
//#endregion
//#region src/logging/diagnostic-session-recovery-coordinator.d.ts
type RecoverStuckSession = (params: StuckSessionRecoveryRequest) => void | StuckSessionRecoveryOutcome | Promise<void | StuckSessionRecoveryOutcome>;
//#endregion
//#region src/logging/diagnostic.d.ts
type DiagnosticWorkSnapshot = {
activeCount: number;
waitingCount: number;
queuedCount: number;
activeLabels: string[];
waitingLabels: string[];
queuedLabels: string[];
};
type StartDiagnosticHeartbeatOptions = {
getConfig?: () => OpenClawConfig;
emitMemorySample?: EmitDiagnosticMemorySample;
sampleLiveness?: (now: number, work: DiagnosticWorkSnapshot) => DiagnosticLivenessSample | null;
recoverStuckSession?: RecoverStuckSession;
startupGraceMs?: number;
/** Bounds diagnostic reporting in tests, never the controller-owned watchdog policy. */
testTimings?: {
stuckSessionWarnMs: number;
stuckSessionAbortMs: number;
};
};
type DiagnosticLogParams<T extends DiagnosticEventPayload["type"]> = Omit<Extract<DiagnosticEventPayload, {
type: T;
}>, "type" | "seq" | "ts" | "trace">;
export declare function logWebhookReceived(params: DiagnosticLogParams<"webhook.received">): void;
export declare function logWebhookProcessed(params: DiagnosticLogParams<"webhook.processed">): void;
export declare function logWebhookError(params: DiagnosticLogParams<"webhook.error">): void;
declare function startGatewayDiagnosticHeartbeat(scheduler: GatewayScheduler, initialConfig?: OpenClawConfig, initialOpts?: StartDiagnosticHeartbeatOptions): void;
//#endregion
//#region src/logger.d.ts
export declare function logInfo(message: string, runtime?: RuntimeEnv): void;
export declare function logError(message: string, runtime?: RuntimeEnv): void;
export declare function logDebug(message: string): void;
//#endregion
//#region packages/normalization-core/src/node-crypto.d.ts
/** Redacts an identifier to a stable hash label, or "-" for missing values. */
export declare function redactIdentifier(value: string | undefined, opts?: {
len?: number;
}): string;
//#endregion
//#region src/plugin-sdk/logging-core.d.ts
/** Standalone SDK callers own this schedule; Gateway plugins use their bound host. */
export declare function startDiagnosticHeartbeat(config?: Parameters<typeof startGatewayDiagnosticHeartbeat>[1], opts?: Parameters<typeof startGatewayDiagnosticHeartbeat>[2]): void;
export declare function stopDiagnosticHeartbeat(): void;
//#endregion
export { type LoggerResolvedSettings, type LoggerSettings, createSubsystemLogger, getChildLogger, redactSensitiveFieldValue, redactSensitiveText, redactToolPayloadText };