Reduce lint suppressions in core tests and runtime

This commit is contained in:
Tak Hoffman
2026-03-27 01:26:57 -05:00
parent 7c00cc9d0a
commit f5643544c2
11 changed files with 115 additions and 112 deletions

View File

@@ -1,6 +1,7 @@
import type { AgentMessage } from "@mariozechner/pi-agent-core";
import { beforeEach, describe, expect, it, vi } from "vitest";
import { compactEmbeddedPiSessionDirect } from "../agents/pi-embedded-runner/compact.runtime.js";
import type { OpenClawConfig } from "../config/types.openclaw.js";
// ---------------------------------------------------------------------------
// We dynamically import the registry so we can get a fresh module per test
// group when needed. For most groups we use the shared singleton directly.
@@ -46,8 +47,7 @@ const mockedCompactEmbeddedPiSessionDirect = vi.mocked(compactEmbeddedPiSessionD
// ---------------------------------------------------------------------------
/** Build a config object with a contextEngine slot for testing. */
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function configWithSlot(engineId: string): any {
function configWithSlot(engineId: string): OpenClawConfig {
return { plugins: { slots: { contextEngine: engineId } } };
}

View File

@@ -19,11 +19,13 @@ export async function delegateCompactionToRuntime(
// Import through a dedicated runtime boundary so the lazy edge remains effective.
const { compactEmbeddedPiSessionDirect } =
await import("../agents/pi-embedded-runner/compact.runtime.js");
type RuntimeCompactionParams = Parameters<typeof compactEmbeddedPiSessionDirect>[0];
// runtimeContext carries the full CompactEmbeddedPiSessionParams fields set
// by runtime callers. We spread them and override the fields that come from
// the public ContextEngine compact() signature directly.
const runtimeContext: ContextEngineRuntimeContext = params.runtimeContext ?? {};
const runtimeContext = (params.runtimeContext ?? {}) as ContextEngineRuntimeContext &
Partial<RuntimeCompactionParams>;
const currentTokenCount =
params.currentTokenCount ??
(typeof runtimeContext.currentTokenCount === "number" &&
@@ -32,7 +34,6 @@ export async function delegateCompactionToRuntime(
? Math.floor(runtimeContext.currentTokenCount)
: undefined);
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- bridge runtimeContext matches CompactEmbeddedPiSessionParams
const result = await compactEmbeddedPiSessionDirect({
...runtimeContext,
sessionId: params.sessionId,
@@ -41,8 +42,9 @@ export async function delegateCompactionToRuntime(
...(currentTokenCount !== undefined ? { currentTokenCount } : {}),
force: params.force,
customInstructions: params.customInstructions,
workspaceDir: (runtimeContext.workspaceDir as string) ?? process.cwd(),
} as Parameters<typeof compactEmbeddedPiSessionDirect>[0]);
workspaceDir:
typeof runtimeContext.workspaceDir === "string" ? runtimeContext.workspaceDir : process.cwd(),
});
return {
ok: result.ok,