mirror of
https://github.com/moltbot/moltbot.git
synced 2026-05-08 08:45:41 +00:00
* fix(agents): normalize Windows runtime imports * test(providers): align manifest contract coverage
21 lines
729 B
TypeScript
21 lines
729 B
TypeScript
import { toSafeImportPath } from "./import-specifier.js";
|
|
|
|
export { toSafeImportPath as toSafeRuntimeImportPath } from "./import-specifier.js";
|
|
|
|
export function resolveRuntimeImportSpecifier(baseUrl: string, parts: readonly string[]): string {
|
|
const joined = parts.join("");
|
|
const safeJoined = toSafeImportPath(joined);
|
|
if (safeJoined !== joined) {
|
|
return safeJoined;
|
|
}
|
|
return new URL(joined, toSafeImportPath(baseUrl)).href;
|
|
}
|
|
|
|
export async function importRuntimeModule<T>(
|
|
baseUrl: string,
|
|
parts: readonly string[],
|
|
importModule: (specifier: string) => Promise<unknown> = (specifier) => import(specifier),
|
|
): Promise<T> {
|
|
return (await importModule(resolveRuntimeImportSpecifier(baseUrl, parts))) as T;
|
|
}
|