mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-19 14:18:37 +00:00
chore(gate): fix lint and formatting
This commit is contained in:
@@ -4,10 +4,7 @@ import path from "node:path";
|
||||
|
||||
import { afterEach, beforeEach, describe, expect, it } from "vitest";
|
||||
|
||||
import {
|
||||
resolveBootstrapContextForRun,
|
||||
resolveBootstrapFilesForRun,
|
||||
} from "./bootstrap-files.js";
|
||||
import { resolveBootstrapContextForRun, resolveBootstrapFilesForRun } from "./bootstrap-files.js";
|
||||
import {
|
||||
clearInternalHooks,
|
||||
registerInternalHook,
|
||||
|
||||
@@ -146,7 +146,10 @@ const readSessionMessages = async (sessionFile: string) => {
|
||||
};
|
||||
|
||||
describe("runEmbeddedPiAgent", () => {
|
||||
it("appends new user + assistant after existing transcript entries", { timeout: 90_000 }, async () => {
|
||||
it(
|
||||
"appends new user + assistant after existing transcript entries",
|
||||
{ timeout: 90_000 },
|
||||
async () => {
|
||||
const { SessionManager } = await import("@mariozechner/pi-coding-agent");
|
||||
|
||||
const agentDir = await fs.mkdtemp(path.join(os.tmpdir(), "clawdbot-agent-"));
|
||||
@@ -217,7 +220,8 @@ describe("runEmbeddedPiAgent", () => {
|
||||
expect(seedAssistantIndex).toBeGreaterThan(seedUserIndex);
|
||||
expect(newUserIndex).toBeGreaterThan(seedAssistantIndex);
|
||||
expect(newAssistantIndex).toBeGreaterThan(newUserIndex);
|
||||
});
|
||||
},
|
||||
);
|
||||
it("persists multi-turn user/assistant ordering across runs", async () => {
|
||||
const agentDir = await fs.mkdtemp(path.join(os.tmpdir(), "clawdbot-agent-"));
|
||||
const workspaceDir = await fs.mkdtemp(path.join(os.tmpdir(), "clawdbot-workspace-"));
|
||||
|
||||
@@ -23,7 +23,6 @@ import { getApiKeyForModel, resolveModelAuthMode } from "../model-auth.js";
|
||||
import { ensureClawdbotModelsJson } from "../models-config.js";
|
||||
import {
|
||||
ensureSessionHeader,
|
||||
resolveBootstrapMaxChars,
|
||||
validateAnthropicTurns,
|
||||
validateGeminiTurns,
|
||||
} from "../pi-embedded-helpers.js";
|
||||
|
||||
@@ -136,7 +136,7 @@ async function resolveContextReport(
|
||||
bootstrapMaxChars,
|
||||
sandbox: { mode: sandboxRuntime.mode, sandboxed: sandboxRuntime.sandboxed },
|
||||
systemPrompt,
|
||||
bootstrapFiles: hookAdjustedBootstrapFiles,
|
||||
bootstrapFiles,
|
||||
injectedFiles,
|
||||
skillsPrompt,
|
||||
tools,
|
||||
|
||||
@@ -12,7 +12,8 @@ export async function checkGatewayHealth(params: {
|
||||
timeoutMs?: number;
|
||||
}) {
|
||||
const gatewayDetails = buildGatewayConnectionDetails({ config: params.cfg });
|
||||
const timeoutMs = typeof params.timeoutMs === "number" && params.timeoutMs > 0 ? params.timeoutMs : 10_000;
|
||||
const timeoutMs =
|
||||
typeof params.timeoutMs === "number" && params.timeoutMs > 0 ? params.timeoutMs : 10_000;
|
||||
let healthOk = false;
|
||||
try {
|
||||
await healthCommand({ json: false, timeoutMs }, params.runtime);
|
||||
|
||||
@@ -211,10 +211,7 @@ async function connectClient(params: { url: string; token: string }) {
|
||||
}
|
||||
|
||||
describe("gateway (mock openai): tool calling", () => {
|
||||
it(
|
||||
"runs a Read tool call end-to-end via gateway agent loop",
|
||||
{ timeout: 90_000 },
|
||||
async () => {
|
||||
it("runs a Read tool call end-to-end via gateway agent loop", { timeout: 90_000 }, async () => {
|
||||
const prev = {
|
||||
home: process.env.HOME,
|
||||
configPath: process.env.CLAWDBOT_CONFIG_PATH,
|
||||
@@ -366,6 +363,5 @@ describe("gateway (mock openai): tool calling", () => {
|
||||
process.env.CLAWDBOT_SKIP_CRON = prev.skipCron;
|
||||
process.env.CLAWDBOT_SKIP_CANVAS_HOST = prev.skipCanvas;
|
||||
}
|
||||
},
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -4,8 +4,8 @@ import { bm25RankToScore, buildFtsQuery, mergeHybridResults } from "./hybrid.js"
|
||||
|
||||
describe("memory hybrid helpers", () => {
|
||||
it("buildFtsQuery tokenizes and AND-joins", () => {
|
||||
expect(buildFtsQuery("hello world")).toBe("\"hello\" AND \"world\"");
|
||||
expect(buildFtsQuery("FOO_bar baz-1")).toBe("\"FOO_bar\" AND \"baz\" AND \"1\"");
|
||||
expect(buildFtsQuery("hello world")).toBe('"hello" AND "world"');
|
||||
expect(buildFtsQuery("FOO_bar baz-1")).toBe('"FOO_bar" AND "baz" AND "1"');
|
||||
expect(buildFtsQuery(" ")).toBeNull();
|
||||
});
|
||||
|
||||
@@ -84,4 +84,3 @@ describe("memory hybrid helpers", () => {
|
||||
expect(merged[0]?.score).toBeCloseTo(0.5 * 0.2 + 0.5 * 1.0);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -21,9 +21,13 @@ export type HybridKeywordResult = {
|
||||
};
|
||||
|
||||
export function buildFtsQuery(raw: string): string | null {
|
||||
const tokens = raw.match(/[A-Za-z0-9_]+/g)?.map((t) => t.trim()).filter(Boolean) ?? [];
|
||||
const tokens =
|
||||
raw
|
||||
.match(/[A-Za-z0-9_]+/g)
|
||||
?.map((t) => t.trim())
|
||||
.filter(Boolean) ?? [];
|
||||
if (tokens.length === 0) return null;
|
||||
const quoted = tokens.map((t) => `"${t.replaceAll("\"", "")}"`);
|
||||
const quoted = tokens.map((t) => `"${t.replaceAll('"', "")}"`);
|
||||
return quoted.join(" AND ");
|
||||
}
|
||||
|
||||
@@ -105,4 +109,3 @@ export function mergeHybridResults(params: {
|
||||
|
||||
return merged.sort((a, b) => b.score - a.score);
|
||||
}
|
||||
|
||||
|
||||
@@ -236,7 +236,12 @@ describe("memory index", () => {
|
||||
query: {
|
||||
minScore: 0,
|
||||
maxResults: 200,
|
||||
hybrid: { enabled: true, vectorWeight: 0.99, textWeight: 0.01, candidateMultiplier: 10 },
|
||||
hybrid: {
|
||||
enabled: true,
|
||||
vectorWeight: 0.99,
|
||||
textWeight: 0.01,
|
||||
candidateMultiplier: 10,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -284,7 +289,12 @@ describe("memory index", () => {
|
||||
query: {
|
||||
minScore: 0,
|
||||
maxResults: 200,
|
||||
hybrid: { enabled: true, vectorWeight: 0.01, textWeight: 0.99, candidateMultiplier: 10 },
|
||||
hybrid: {
|
||||
enabled: true,
|
||||
vectorWeight: 0.01,
|
||||
textWeight: 0.99,
|
||||
candidateMultiplier: 10,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -3,7 +3,8 @@ import type { DatabaseSync } from "node:sqlite";
|
||||
import { truncateUtf16Safe } from "../utils.js";
|
||||
import { cosineSimilarity, parseEmbedding } from "./internal.js";
|
||||
|
||||
const vectorToBlob = (embedding: number[]): Buffer => Buffer.from(new Float32Array(embedding).buffer);
|
||||
const vectorToBlob = (embedding: number[]): Buffer =>
|
||||
Buffer.from(new Float32Array(embedding).buffer);
|
||||
|
||||
export type SearchSource = string;
|
||||
|
||||
|
||||
@@ -92,4 +92,3 @@ function ensureColumn(
|
||||
if (rows.some((row) => row.name === column)) return;
|
||||
db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
|
||||
}
|
||||
|
||||
|
||||
@@ -156,7 +156,10 @@ async function readOpenAiBatchError(params: {
|
||||
errorFileId: string;
|
||||
}): Promise<string | undefined> {
|
||||
try {
|
||||
const content = await fetchOpenAiFileContent({ openAi: params.openAi, fileId: params.errorFileId });
|
||||
const content = await fetchOpenAiFileContent({
|
||||
openAi: params.openAi,
|
||||
fileId: params.errorFileId,
|
||||
});
|
||||
const lines = parseOpenAiBatchOutput(content);
|
||||
const first = lines.find((line) => line.error?.message || line.response?.body?.error);
|
||||
const message =
|
||||
@@ -357,4 +360,3 @@ export async function runOpenAiEmbeddingBatches(params: {
|
||||
await runWithConcurrency(tasks, params.concurrency);
|
||||
return byCustomId;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,4 +22,3 @@ export async function loadSqliteVecExtension(params: {
|
||||
return { ok: false, error: message };
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,10 @@ import { dispatchReplyWithBufferedBlockDispatcher } from "../../auto-reply/reply
|
||||
import { createReplyDispatcherWithTyping } from "../../auto-reply/reply/reply-dispatcher.js";
|
||||
import { resolveEffectiveMessagesConfig, resolveHumanDelayConfig } from "../../agents/identity.js";
|
||||
import { resolveCommandAuthorizedFromAuthorizers } from "../../channels/command-gating.js";
|
||||
import { resolveChannelGroupPolicy, resolveChannelGroupRequireMention } from "../../config/group-policy.js";
|
||||
import {
|
||||
resolveChannelGroupPolicy,
|
||||
resolveChannelGroupRequireMention,
|
||||
} from "../../config/group-policy.js";
|
||||
import { resolveStateDir } from "../../config/paths.js";
|
||||
import { shouldLogVerbose } from "../../globals.js";
|
||||
import { getChildLogger } from "../../logging.js";
|
||||
|
||||
@@ -63,9 +63,9 @@ export async function getDeterministicFreePortBlock(params?: {
|
||||
for (let attempt = 0; attempt < usable; attempt += 1) {
|
||||
const start = base + ((nextTestPortOffset + attempt) % usable);
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
const ok = (
|
||||
await Promise.all(offsets.map((offset) => isPortFree(start + offset)))
|
||||
).every(Boolean);
|
||||
const ok = (await Promise.all(offsets.map((offset) => isPortFree(start + offset)))).every(
|
||||
Boolean,
|
||||
);
|
||||
if (!ok) continue;
|
||||
nextTestPortOffset = (nextTestPortOffset + attempt + blockSize) % usable;
|
||||
return start;
|
||||
|
||||
Reference in New Issue
Block a user