mirror of
https://github.com/moltbot/moltbot.git
synced 2026-04-23 14:45:46 +00:00
Reduce lint suppressions in core tests and runtime
This commit is contained in:
@@ -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 } } };
|
||||
}
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user