mirror of
https://github.com/morluto/rea.git
synced 2026-11-19 13:12:26 +00:00
* refactor(contracts): move the CLI command name owner into src/contracts * refactor(contracts): own catalog identity in contracts and server identity in process (#11435) * refactor(contracts): move catalog identity into contracts and server identity into process * refactor(contracts): own the advertised MCP schema presentation in contracts * test(mcp): import the advertised presentation from contracts in toolSchemaValidity * test(release): expect the catalog identity at its contracts path in the canary * test(mcp): import the catalog identity from contracts in syntheticContractSurfaces * refactor(contracts): import CLI command names from contracts in the capability conformance test
66 lines
2.6 KiB
TypeScript
66 lines
2.6 KiB
TypeScript
import { jsonObjectSchema, type JsonValue } from "../domain/jsonValue.js";
|
|
import { createServerIdentity } from "../process/ServerIdentity.js";
|
|
import { silentLogger } from "../logger.js";
|
|
import type { Logger } from "pino";
|
|
import type { DirectAnalysisDependencies } from "./DirectAnalysisDependencies.js";
|
|
import { providerCapabilitySet } from "../contracts/toolOutputSchemaPrimitives.js";
|
|
import { providerCapabilitySets } from "./binary/BinarySessionStatus.js";
|
|
import { sqliteDatabaseCapability } from "./sqlite/SqliteDatabaseCapability.js";
|
|
import { CURRENT_ENTRYPOINT_PATH } from "../process/CurrentEntrypointPath.js";
|
|
import { catalogIdentityForToolFamilies } from "../contracts/catalog/catalogIdentity.js";
|
|
import { progressiveCatalogIdentity } from "../contracts/catalog/catalogDiscovery.js";
|
|
import {
|
|
directAnalysisCleanupFailure,
|
|
projectInvocationFailure,
|
|
withSessionCleanup,
|
|
} from "./DirectAnalysisCleanup.js";
|
|
import { ok } from "../domain/result.js";
|
|
import {
|
|
COMPACT_INPUT_SCHEMA_PRESENTATION,
|
|
resolveMcpOutputSchemaProfile,
|
|
} from "../contracts/mcpSchemaPresentation.js";
|
|
|
|
/** Read target-free provider status and operation availability. */
|
|
export const runSessionStatus = async (
|
|
dependencies: Pick<
|
|
DirectAnalysisDependencies,
|
|
"createBinarySession" | "readConfiguration"
|
|
>,
|
|
logger: Logger = silentLogger,
|
|
): Promise<JsonValue> => {
|
|
const config = dependencies.readConfiguration();
|
|
if (!config.ok) return { error: projectInvocationFailure(config.error) };
|
|
const session = await dependencies.createBinarySession(config.value, logger);
|
|
return withSessionCleanup<JsonValue>(
|
|
session,
|
|
async () => {
|
|
const status = jsonObjectSchema.parse(await session.status());
|
|
const catalog = catalogIdentityForToolFamilies(
|
|
COMPACT_INPUT_SCHEMA_PRESENTATION,
|
|
resolveMcpOutputSchemaProfile(config.value.mcpOutputSchemaProfile),
|
|
config.value.mcpToolFamilies === undefined
|
|
? undefined
|
|
: new Set(config.value.mcpToolFamilies),
|
|
);
|
|
return {
|
|
...status,
|
|
capabilities: [
|
|
...providerCapabilitySet.array().parse(status.capabilities),
|
|
...providerCapabilitySets([
|
|
sqliteDatabaseCapability(process.versions.node),
|
|
]),
|
|
],
|
|
server_identity: createServerIdentity({
|
|
startedAt: new Date().toISOString(),
|
|
commandPath: CURRENT_ENTRYPOINT_PATH,
|
|
catalog:
|
|
config.value.mcpToolCatalogProfile === "hot-cold"
|
|
? progressiveCatalogIdentity(catalog)
|
|
: catalog,
|
|
}),
|
|
};
|
|
},
|
|
(status, cleanup) => directAnalysisCleanupFailure(ok(status), cleanup),
|
|
);
|
|
};
|