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 { afterEach, beforeEach, describe, expect, it } from "vitest";
|
||||||
|
|
||||||
import {
|
import { resolveBootstrapContextForRun, resolveBootstrapFilesForRun } from "./bootstrap-files.js";
|
||||||
resolveBootstrapContextForRun,
|
|
||||||
resolveBootstrapFilesForRun,
|
|
||||||
} from "./bootstrap-files.js";
|
|
||||||
import {
|
import {
|
||||||
clearInternalHooks,
|
clearInternalHooks,
|
||||||
registerInternalHook,
|
registerInternalHook,
|
||||||
|
|||||||
@@ -146,7 +146,10 @@ const readSessionMessages = async (sessionFile: string) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
describe("runEmbeddedPiAgent", () => {
|
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 { SessionManager } = await import("@mariozechner/pi-coding-agent");
|
||||||
|
|
||||||
const agentDir = await fs.mkdtemp(path.join(os.tmpdir(), "clawdbot-agent-"));
|
const agentDir = await fs.mkdtemp(path.join(os.tmpdir(), "clawdbot-agent-"));
|
||||||
@@ -217,7 +220,8 @@ describe("runEmbeddedPiAgent", () => {
|
|||||||
expect(seedAssistantIndex).toBeGreaterThan(seedUserIndex);
|
expect(seedAssistantIndex).toBeGreaterThan(seedUserIndex);
|
||||||
expect(newUserIndex).toBeGreaterThan(seedAssistantIndex);
|
expect(newUserIndex).toBeGreaterThan(seedAssistantIndex);
|
||||||
expect(newAssistantIndex).toBeGreaterThan(newUserIndex);
|
expect(newAssistantIndex).toBeGreaterThan(newUserIndex);
|
||||||
});
|
},
|
||||||
|
);
|
||||||
it("persists multi-turn user/assistant ordering across runs", async () => {
|
it("persists multi-turn user/assistant ordering across runs", async () => {
|
||||||
const agentDir = await fs.mkdtemp(path.join(os.tmpdir(), "clawdbot-agent-"));
|
const agentDir = await fs.mkdtemp(path.join(os.tmpdir(), "clawdbot-agent-"));
|
||||||
const workspaceDir = await fs.mkdtemp(path.join(os.tmpdir(), "clawdbot-workspace-"));
|
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 { ensureClawdbotModelsJson } from "../models-config.js";
|
||||||
import {
|
import {
|
||||||
ensureSessionHeader,
|
ensureSessionHeader,
|
||||||
resolveBootstrapMaxChars,
|
|
||||||
validateAnthropicTurns,
|
validateAnthropicTurns,
|
||||||
validateGeminiTurns,
|
validateGeminiTurns,
|
||||||
} from "../pi-embedded-helpers.js";
|
} from "../pi-embedded-helpers.js";
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ async function resolveContextReport(
|
|||||||
bootstrapMaxChars,
|
bootstrapMaxChars,
|
||||||
sandbox: { mode: sandboxRuntime.mode, sandboxed: sandboxRuntime.sandboxed },
|
sandbox: { mode: sandboxRuntime.mode, sandboxed: sandboxRuntime.sandboxed },
|
||||||
systemPrompt,
|
systemPrompt,
|
||||||
bootstrapFiles: hookAdjustedBootstrapFiles,
|
bootstrapFiles,
|
||||||
injectedFiles,
|
injectedFiles,
|
||||||
skillsPrompt,
|
skillsPrompt,
|
||||||
tools,
|
tools,
|
||||||
|
|||||||
@@ -12,7 +12,8 @@ export async function checkGatewayHealth(params: {
|
|||||||
timeoutMs?: number;
|
timeoutMs?: number;
|
||||||
}) {
|
}) {
|
||||||
const gatewayDetails = buildGatewayConnectionDetails({ config: params.cfg });
|
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;
|
let healthOk = false;
|
||||||
try {
|
try {
|
||||||
await healthCommand({ json: false, timeoutMs }, params.runtime);
|
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", () => {
|
describe("gateway (mock openai): tool calling", () => {
|
||||||
it(
|
it("runs a Read tool call end-to-end via gateway agent loop", { timeout: 90_000 }, async () => {
|
||||||
"runs a Read tool call end-to-end via gateway agent loop",
|
|
||||||
{ timeout: 90_000 },
|
|
||||||
async () => {
|
|
||||||
const prev = {
|
const prev = {
|
||||||
home: process.env.HOME,
|
home: process.env.HOME,
|
||||||
configPath: process.env.CLAWDBOT_CONFIG_PATH,
|
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_CRON = prev.skipCron;
|
||||||
process.env.CLAWDBOT_SKIP_CANVAS_HOST = prev.skipCanvas;
|
process.env.CLAWDBOT_SKIP_CANVAS_HOST = prev.skipCanvas;
|
||||||
}
|
}
|
||||||
},
|
});
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ import { bm25RankToScore, buildFtsQuery, mergeHybridResults } from "./hybrid.js"
|
|||||||
|
|
||||||
describe("memory hybrid helpers", () => {
|
describe("memory hybrid helpers", () => {
|
||||||
it("buildFtsQuery tokenizes and AND-joins", () => {
|
it("buildFtsQuery tokenizes and AND-joins", () => {
|
||||||
expect(buildFtsQuery("hello world")).toBe("\"hello\" AND \"world\"");
|
expect(buildFtsQuery("hello world")).toBe('"hello" AND "world"');
|
||||||
expect(buildFtsQuery("FOO_bar baz-1")).toBe("\"FOO_bar\" AND \"baz\" AND \"1\"");
|
expect(buildFtsQuery("FOO_bar baz-1")).toBe('"FOO_bar" AND "baz" AND "1"');
|
||||||
expect(buildFtsQuery(" ")).toBeNull();
|
expect(buildFtsQuery(" ")).toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -84,4 +84,3 @@ describe("memory hybrid helpers", () => {
|
|||||||
expect(merged[0]?.score).toBeCloseTo(0.5 * 0.2 + 0.5 * 1.0);
|
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 {
|
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;
|
if (tokens.length === 0) return null;
|
||||||
const quoted = tokens.map((t) => `"${t.replaceAll("\"", "")}"`);
|
const quoted = tokens.map((t) => `"${t.replaceAll('"', "")}"`);
|
||||||
return quoted.join(" AND ");
|
return quoted.join(" AND ");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,4 +109,3 @@ export function mergeHybridResults(params: {
|
|||||||
|
|
||||||
return merged.sort((a, b) => b.score - a.score);
|
return merged.sort((a, b) => b.score - a.score);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -236,7 +236,12 @@ describe("memory index", () => {
|
|||||||
query: {
|
query: {
|
||||||
minScore: 0,
|
minScore: 0,
|
||||||
maxResults: 200,
|
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: {
|
query: {
|
||||||
minScore: 0,
|
minScore: 0,
|
||||||
maxResults: 200,
|
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 { truncateUtf16Safe } from "../utils.js";
|
||||||
import { cosineSimilarity, parseEmbedding } from "./internal.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;
|
export type SearchSource = string;
|
||||||
|
|
||||||
|
|||||||
@@ -92,4 +92,3 @@ function ensureColumn(
|
|||||||
if (rows.some((row) => row.name === column)) return;
|
if (rows.some((row) => row.name === column)) return;
|
||||||
db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
|
db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -156,7 +156,10 @@ async function readOpenAiBatchError(params: {
|
|||||||
errorFileId: string;
|
errorFileId: string;
|
||||||
}): Promise<string | undefined> {
|
}): Promise<string | undefined> {
|
||||||
try {
|
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 lines = parseOpenAiBatchOutput(content);
|
||||||
const first = lines.find((line) => line.error?.message || line.response?.body?.error);
|
const first = lines.find((line) => line.error?.message || line.response?.body?.error);
|
||||||
const message =
|
const message =
|
||||||
@@ -357,4 +360,3 @@ export async function runOpenAiEmbeddingBatches(params: {
|
|||||||
await runWithConcurrency(tasks, params.concurrency);
|
await runWithConcurrency(tasks, params.concurrency);
|
||||||
return byCustomId;
|
return byCustomId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,4 +22,3 @@ export async function loadSqliteVecExtension(params: {
|
|||||||
return { ok: false, error: message };
|
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 { createReplyDispatcherWithTyping } from "../../auto-reply/reply/reply-dispatcher.js";
|
||||||
import { resolveEffectiveMessagesConfig, resolveHumanDelayConfig } from "../../agents/identity.js";
|
import { resolveEffectiveMessagesConfig, resolveHumanDelayConfig } from "../../agents/identity.js";
|
||||||
import { resolveCommandAuthorizedFromAuthorizers } from "../../channels/command-gating.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 { resolveStateDir } from "../../config/paths.js";
|
||||||
import { shouldLogVerbose } from "../../globals.js";
|
import { shouldLogVerbose } from "../../globals.js";
|
||||||
import { getChildLogger } from "../../logging.js";
|
import { getChildLogger } from "../../logging.js";
|
||||||
|
|||||||
@@ -63,9 +63,9 @@ export async function getDeterministicFreePortBlock(params?: {
|
|||||||
for (let attempt = 0; attempt < usable; attempt += 1) {
|
for (let attempt = 0; attempt < usable; attempt += 1) {
|
||||||
const start = base + ((nextTestPortOffset + attempt) % usable);
|
const start = base + ((nextTestPortOffset + attempt) % usable);
|
||||||
// eslint-disable-next-line no-await-in-loop
|
// eslint-disable-next-line no-await-in-loop
|
||||||
const ok = (
|
const ok = (await Promise.all(offsets.map((offset) => isPortFree(start + offset)))).every(
|
||||||
await Promise.all(offsets.map((offset) => isPortFree(start + offset)))
|
Boolean,
|
||||||
).every(Boolean);
|
);
|
||||||
if (!ok) continue;
|
if (!ok) continue;
|
||||||
nextTestPortOffset = (nextTestPortOffset + attempt + blockSize) % usable;
|
nextTestPortOffset = (nextTestPortOffset + attempt + blockSize) % usable;
|
||||||
return start;
|
return start;
|
||||||
|
|||||||
Reference in New Issue
Block a user