mirror of
https://github.com/morluto/rea.git
synced 2026-12-06 14:59:05 +00:00
* perf(artifacts): isolate offline session composition from deep providers * test(mcp): use the artifact session factory in bundle resource tests
55 lines
2.3 KiB
TypeScript
55 lines
2.3 KiB
TypeScript
import type { AnalysisSettingsReader } from "../domain/analysisSettings.js";
|
|
import type { ArtifactPathInspectionDependencies } from "../application/artifacts/ArtifactPathInspection.js";
|
|
import type { BinarySession } from "../application/binary/BinarySession.js";
|
|
import { AnalysisProviderRegistry } from "../application/binary/AnalysisProviderRegistry.js";
|
|
import { composeBinarySession } from "../application/binary/BinarySessionComposition.js";
|
|
import { HOST_PLATFORM } from "../platform/HostPlatform.js";
|
|
import { snapshotEnvironment } from "../process/snapshotEnvironment.js";
|
|
import { createBundleResourceFactory } from "./bundleResources.js";
|
|
|
|
/** Compose the artifact operations without candidates for deep analysis engines. */
|
|
export const createArtifactBinarySession = (
|
|
selectedEnvironment: Readonly<NodeJS.ProcessEnv>,
|
|
platform: NodeJS.Platform = HOST_PLATFORM.platform,
|
|
settings?: AnalysisSettingsReader,
|
|
): Promise<BinarySession> =>
|
|
import("../artifacts/ArtifactProvider.js").then(({ ArtifactProvider }) =>
|
|
composeBinarySession(
|
|
new AnalysisProviderRegistry([]),
|
|
[
|
|
new ArtifactProvider(
|
|
snapshotEnvironment(selectedEnvironment, platform),
|
|
platform,
|
|
settings,
|
|
),
|
|
],
|
|
createBundleResourceFactory(
|
|
snapshotEnvironment(selectedEnvironment, platform),
|
|
platform,
|
|
),
|
|
),
|
|
);
|
|
|
|
/**
|
|
* Compose path-selected `inspect_artifact`: a directory is inventoried by the
|
|
* artifact provider directly, and any other path in its own artifact-only
|
|
* session. Neither uses a caller's open session target.
|
|
*/
|
|
export const createArtifactPathInspection = (
|
|
selectedEnvironment: Readonly<NodeJS.ProcessEnv>,
|
|
platform: NodeJS.Platform = HOST_PLATFORM.platform,
|
|
settings?: AnalysisSettingsReader,
|
|
): ArtifactPathInspectionDependencies => ({
|
|
inspectArtifactDirectory: async (path, parameters, options, retained) => {
|
|
const { ArtifactProvider } =
|
|
await import("../artifacts/ArtifactProvider.js");
|
|
return new ArtifactProvider(
|
|
snapshotEnvironment(selectedEnvironment, platform),
|
|
platform,
|
|
settings,
|
|
).inspectDirectory(path, parameters, options, retained);
|
|
},
|
|
createArtifactBinarySession: () =>
|
|
createArtifactBinarySession(selectedEnvironment, platform, settings),
|
|
});
|