new_pull
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
import { createInMemoryModelRegistry, getModelRuntime } from "../model-runtime-test-utils.ts";
|
||||
import { createInMemoryModelRegistry, createModelRegistry, getModelRuntime } from "../model-runtime-test-utils.ts";
|
||||
/**
|
||||
* Local test harness for the new coding-agent test suite.
|
||||
*/
|
||||
|
||||
import { existsSync, mkdirSync, rmSync } from "node:fs";
|
||||
import { existsSync, mkdirSync, rmSync, writeFileSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import type { AgentMessage, AgentTool } from "@earendil-works/pi-agent-core";
|
||||
@@ -71,6 +71,7 @@ export interface HarnessOptions {
|
||||
resourceLoader?: ResourceLoader;
|
||||
extensionFactories?: Array<InlineExtension | CreateTestExtensionsResultInput>;
|
||||
withConfiguredAuth?: boolean;
|
||||
modelsJson?: Record<string, unknown>;
|
||||
}
|
||||
|
||||
export interface Harness {
|
||||
@@ -115,7 +116,11 @@ export async function createHarness(options: HarnessOptions = {}): Promise<Harne
|
||||
if (withConfiguredAuth) {
|
||||
await authStorage.modify(model.provider, async () => ({ type: "api_key", key: "faux-key" }));
|
||||
}
|
||||
const modelRegistry = await createInMemoryModelRegistry(authStorage);
|
||||
const modelsPath = options.modelsJson === undefined ? undefined : join(tempDir, "models.json");
|
||||
if (modelsPath) writeFileSync(modelsPath, JSON.stringify(options.modelsJson));
|
||||
const modelRegistry = modelsPath
|
||||
? await createModelRegistry(authStorage, modelsPath)
|
||||
: await createInMemoryModelRegistry(authStorage);
|
||||
if (withConfiguredAuth) {
|
||||
modelRegistry.registerProvider(model.provider, {
|
||||
baseUrl: model.baseUrl,
|
||||
|
||||
Reference in New Issue
Block a user