refactor(core): inline one-use helper modules

This commit is contained in:
Vincent Koc
2026-06-18 10:07:51 +08:00
parent a3ae453a1a
commit 7b74d7332f
6 changed files with 3 additions and 21 deletions
@@ -7,7 +7,6 @@ import {
} from "openclaw/plugin-sdk/llm";
import { afterEach, describe, expect, it, vi } from "vitest";
import type { OpenClawConfig } from "../../../config/config.js";
import { DEFAULT_LLM_IDLE_TIMEOUT_SECONDS } from "../../../config/agent-timeout-defaults.js";
import { notifyLlmRequestActivity } from "../../../shared/llm-request-activity.js";
import type { StreamFn } from "../../runtime/index.js";
import {
@@ -15,7 +14,7 @@ import {
streamWithIdleTimeout,
} from "./llm-idle-timeout.js";
const DEFAULT_LLM_IDLE_TIMEOUT_MS = DEFAULT_LLM_IDLE_TIMEOUT_SECONDS * 1000;
const DEFAULT_LLM_IDLE_TIMEOUT_MS = 120_000;
describe("resolveLlmIdleTimeoutMs", () => {
it("returns default when config is undefined", () => {
@@ -6,7 +6,6 @@ import {
clampTimerTimeoutMs,
MAX_TIMER_TIMEOUT_MS,
} from "@openclaw/normalization-core/number-coercion";
import { DEFAULT_LLM_IDLE_TIMEOUT_SECONDS } from "../../../config/agent-timeout-defaults.js";
import type { OpenClawConfig } from "../../../config/types.openclaw.js";
import { onLlmRequestActivity } from "../../../shared/llm-request-activity.js";
import type { StreamFn } from "../../runtime/index.js";
@@ -17,7 +16,7 @@ import type { EmbeddedRunTrigger } from "./params.js";
/**
* Default idle timeout for LLM streaming responses in milliseconds.
*/
const DEFAULT_LLM_IDLE_TIMEOUT_MS = DEFAULT_LLM_IDLE_TIMEOUT_SECONDS * 1000;
const DEFAULT_LLM_IDLE_TIMEOUT_MS = 120_000;
/**
* Detects loopback / private-network / `.local` base URLs. Local providers
-2
View File
@@ -1,2 +0,0 @@
/** Default idle timeout for agent LLM turns when no provider override exists. */
export const DEFAULT_LLM_IDLE_TIMEOUT_SECONDS = 120;
-2
View File
@@ -1,2 +0,0 @@
// Small shared labels used by status message tests and compact command output.
export const formatFastModeLabel = (enabled: boolean): string => `Fast: ${enabled ? "on" : "off"}`;
-11
View File
@@ -2,7 +2,6 @@
import { afterEach, describe, expect, it } from "vitest";
import { testing as cliBackendsTesting } from "../agents/cli-backends.js";
import type { ModelDefinitionConfig } from "../config/types.models.js";
import { formatFastModeLabel } from "./status-labels.js";
import { buildStatusMessage } from "./status-message.js";
function statusTestModel(id: string, name: string, contextWindow: number): ModelDefinitionConfig {
@@ -21,16 +20,6 @@ afterEach(() => {
cliBackendsTesting.resetDepsForTest();
});
describe("formatFastModeLabel", () => {
it("shows fast mode when enabled", () => {
expect(formatFastModeLabel(true)).toBe("Fast: on");
});
it("shows fast mode when disabled", () => {
expect(formatFastModeLabel(false)).toBe("Fast: off");
});
});
describe("buildStatusMessage context window", () => {
it("ignores stale runtime context after a manual session model switch", () => {
const text = buildStatusMessage({
+1 -2
View File
@@ -62,7 +62,6 @@ import {
import { VERSION } from "../version.js";
import { resolveAgentRuntimeLabel } from "./agent-runtime-label.js";
import { resolveActiveFallbackState } from "./fallback-notice-state.js";
import { formatFastModeLabel } from "./status-labels.js";
type AgentDefaults = NonNullable<NonNullable<OpenClawConfig["agents"]>["defaults"]>;
type AgentConfig = Partial<AgentDefaults> & {
@@ -957,7 +956,7 @@ export function buildStatusMessage(args: StatusArgs): string {
`Execution: ${execution.label}`,
`Runtime: ${agentRuntimeLabel}`,
`Think: ${thinkLevel}`,
formatFastModeLabel(fastMode),
`Fast: ${fastMode ? "on" : "off"}`,
textVerbosity ? `Text: ${textVerbosity}` : null,
verboseLabel,
traceLabel,