refactor(agent): dedupe harness and command workflows

This commit is contained in:
Peter Steinberger
2026-02-16 14:52:09 +00:00
parent 04892ee230
commit f717a13039
204 changed files with 7366 additions and 11540 deletions

View File

@@ -1,4 +1,4 @@
import { afterEach, beforeEach } from "vitest";
import { afterEach, beforeEach, vi } from "vitest";
import type { OpenClawConfig } from "../config/config.js";
import { withTempHome as withTempHomeBase } from "../../test/helpers/temp-home.js";
@@ -48,6 +48,28 @@ export function unsetEnv(vars: string[]) {
}
}
export const COPILOT_TOKEN_ENV_VARS = ["COPILOT_GITHUB_TOKEN", "GH_TOKEN", "GITHUB_TOKEN"];
export async function withUnsetCopilotTokenEnv<T>(fn: () => Promise<T>): Promise<T> {
return withTempEnv(COPILOT_TOKEN_ENV_VARS, async () => {
unsetEnv(COPILOT_TOKEN_ENV_VARS);
return fn();
});
}
export function mockCopilotTokenExchangeSuccess() {
const fetchMock = vi.fn().mockResolvedValue({
ok: true,
status: 200,
json: async () => ({
token: "copilot-token;proxy-ep=proxy.copilot.example",
expires_at: Math.floor(Date.now() / 1000) + 3600,
}),
});
globalThis.fetch = fetchMock as unknown as typeof fetch;
return fetchMock;
}
export const MODELS_CONFIG_IMPLICIT_ENV_VARS = [
"CLOUDFLARE_AI_GATEWAY_API_KEY",
"COPILOT_GITHUB_TOKEN",