mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-29 16:43:38 +00:00
refactor(runtime): remove unused internal wrappers
This commit is contained in:
@@ -673,17 +673,6 @@ export function formatProbeLatency(latencyMs?: number | null) {
|
||||
return formatMs(latencyMs);
|
||||
}
|
||||
|
||||
/** Groups probe results by provider. */
|
||||
export function groupProbeResults(results: AuthProbeResult[]): Map<string, AuthProbeResult[]> {
|
||||
const map = new Map<string, AuthProbeResult[]>();
|
||||
for (const result of results) {
|
||||
const list = map.get(result.provider) ?? [];
|
||||
list.push(result);
|
||||
map.set(result.provider, list);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
/** Sorts probe results by provider and display label. */
|
||||
export function sortProbeResults(results: AuthProbeResult[]): AuthProbeResult[] {
|
||||
return results.slice().toSorted((a, b) => {
|
||||
|
||||
@@ -5,7 +5,6 @@ import {
|
||||
buildModelAliasIndex,
|
||||
legacyModelKey,
|
||||
modelKey,
|
||||
parseModelRef,
|
||||
resolveModelRefFromString,
|
||||
} from "../../agents/model-selection.js";
|
||||
import { formatCliCommand } from "../../cli/command-format.js";
|
||||
@@ -147,20 +146,6 @@ export function resolveModelKeysFromEntries(params: {
|
||||
.map((entry) => modelKey(entry.ref.provider, entry.ref.model));
|
||||
}
|
||||
|
||||
/** Builds the configured model allowlist from agents.defaults.models keys. */
|
||||
export function buildAllowlistSet(cfg: OpenClawConfig): Set<string> {
|
||||
const allowed = new Set<string>();
|
||||
const models = cfg.agents?.defaults?.models ?? {};
|
||||
for (const raw of Object.keys(models)) {
|
||||
const parsed = parseModelRef(raw, DEFAULT_PROVIDER);
|
||||
if (!parsed) {
|
||||
continue;
|
||||
}
|
||||
allowed.add(modelKey(parsed.provider, parsed.model));
|
||||
}
|
||||
return allowed;
|
||||
}
|
||||
|
||||
/** Validates an optional agent id against configured agents. */
|
||||
export function resolveKnownAgentId(params: {
|
||||
cfg: OpenClawConfig;
|
||||
|
||||
@@ -6,7 +6,6 @@ import fs from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
import { type FileLockOptions, withFileLock } from "../plugin-sdk/file-lock.js";
|
||||
import {
|
||||
clearStoreWriterQueuesForTest,
|
||||
runQueuedStoreWrite,
|
||||
type StoreWriterQueue,
|
||||
} from "../shared/store-writer-queue.js";
|
||||
@@ -45,7 +44,3 @@ export async function runExclusiveCommitmentsStoreWrite<T>(
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export function clearCommitmentsStoreWriterQueuesForTest(): void {
|
||||
clearStoreWriterQueuesForTest(WRITER_QUEUES, "commitments store writer queue cleared for test");
|
||||
}
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
/** Shared Vitest module mocks for isolated-agent cron tests. */
|
||||
import { vi } from "vitest";
|
||||
import {
|
||||
makeIsolatedAgentJobFixture,
|
||||
makeIsolatedAgentParamsFixture,
|
||||
} from "./isolated-agent/job-fixtures.js";
|
||||
|
||||
vi.mock("../agents/embedded-agent.js", () => ({
|
||||
abortEmbeddedAgentRun: vi.fn().mockReturnValue(false),
|
||||
@@ -36,6 +32,3 @@ vi.mock("../plugins/runtime-plugins.runtime.js", () => ({
|
||||
vi.mock("../gateway/call.js", () => ({
|
||||
callGateway: vi.fn(),
|
||||
}));
|
||||
|
||||
export const makeIsolatedAgentJob = makeIsolatedAgentJobFixture;
|
||||
export const makeIsolatedAgentParams = makeIsolatedAgentParamsFixture;
|
||||
|
||||
@@ -127,17 +127,6 @@ function stripRuntimeModelState(entry?: SessionEntry): SessionEntry | undefined
|
||||
};
|
||||
}
|
||||
|
||||
export function archiveSessionTranscriptsForSession(params: {
|
||||
sessionId: string | undefined;
|
||||
storePath: string;
|
||||
sessionFile?: string;
|
||||
agentId?: string;
|
||||
reason: "reset" | "deleted";
|
||||
onArchiveError?: (err: unknown, sourcePath: string) => void;
|
||||
}): string[] {
|
||||
return archiveSessionTranscriptsForSessionDetailed(params).map((entry) => entry.archivedPath);
|
||||
}
|
||||
|
||||
export function archiveSessionTranscriptsForSessionDetailed(params: {
|
||||
sessionId: string | undefined;
|
||||
storePath: string;
|
||||
|
||||
@@ -54,8 +54,3 @@ export function requireUnifiedTalkSessionConn(
|
||||
}
|
||||
return connId;
|
||||
}
|
||||
|
||||
/** Clears process-local Talk session mappings between tests. */
|
||||
export function clearUnifiedTalkSessionsForTest(): void {
|
||||
unifiedTalkSessions.clear();
|
||||
}
|
||||
|
||||
@@ -36,31 +36,6 @@ export function saveJsonFile(pathname: string, data: unknown): void {
|
||||
writeJsonSync(resolveJsonSaveTarget(pathname), data);
|
||||
}
|
||||
|
||||
export function repairJsonFilePermissions(pathname: string): void {
|
||||
const target = resolveJsonSaveTarget(pathname);
|
||||
let fd: number | undefined;
|
||||
try {
|
||||
fd = fs.openSync(
|
||||
target,
|
||||
fs.constants.O_RDONLY |
|
||||
(process.platform !== "win32" && "O_NOFOLLOW" in fs.constants
|
||||
? fs.constants.O_NOFOLLOW
|
||||
: 0),
|
||||
);
|
||||
fs.fchmodSync(fd, 0o600);
|
||||
} catch {
|
||||
// Matches fs-safe JSON writes: permission repair is best-effort.
|
||||
} finally {
|
||||
if (fd !== undefined) {
|
||||
try {
|
||||
fs.closeSync(fd);
|
||||
} catch {
|
||||
// best-effort cleanup
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// oxlint-disable-next-line typescript-eslint/no-unnecessary-type-parameters -- legacy typed JSON loader alias.
|
||||
export function loadJsonFile<T = unknown>(pathname: string): T | undefined {
|
||||
const direct = tryReadJsonSync<T>(pathname);
|
||||
|
||||
@@ -30,8 +30,3 @@ export function resolveOpenClawAgentSqlitePath(options: OpenClawAgentSqlitePathO
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/** Resolve the containing directory for one agent's SQLite database. */
|
||||
export function resolveOpenClawAgentSqliteDir(options: OpenClawAgentSqlitePathOptions): string {
|
||||
return path.dirname(resolveOpenClawAgentSqlitePath(options));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user