@receiz/mcp-server
Version:
MCP server for agents building and verifying Receiz proof-native applications through the canonical Receiz SDK rails.
26 lines • 1.7 kB
JavaScript
import { createReceizDeviceMaterialHost } from "./deviceMaterialHost.js";
import { realpath } from "node:fs/promises";
import { isAbsolute, relative, resolve } from "node:path";
import { readReceizV127SubjectRuntimeSourceFile } from "@receiz/sdk/subjects/node";
/** Paths only select exact source files; the SDK opens and admits their proof. */
export async function resolveReceizV127SubjectWorkspaceSource(sourcePath, workspacePath) {
const workspace = await realpath(workspacePath ?? process.env.RECEIZ_OFFLINE_WORKSPACE ?? process.cwd());
const path = await realpath(resolve(workspace, sourcePath));
const rel = relative(workspace, path);
if (rel.startsWith("..") || isAbsolute(rel))
throw new TypeError("SUBJECT_SOURCE_OUTSIDE_WORKSPACE");
return readReceizV127SubjectRuntimeSourceFile(path);
}
/** Resolve the existing device locator, then preserve canonical subject-source admission. */
export async function resolveReceizV127SubjectReferenceSource(reference, workspacePath) {
const workspace = await realpath(workspacePath ?? process.env.RECEIZ_OFFLINE_WORKSPACE ?? process.cwd());
await createReceizDeviceMaterialHost(workspace).resolveProofReference(reference);
const match = /^receiz:file:([a-f0-9]{64}):(.+)$/.exec(reference);
const source = await resolveReceizV127SubjectWorkspaceSource(match[2], workspace);
// The second canonical read must still describe exactly the reference-bound file.
if (source.verification.status !== "verified-artifact" || source.verification.artifactDigest.value !== match[1]) {
throw new Error("RECEIZ_DEVICE_SOURCE_CHANGED");
}
return source;
}
//# sourceMappingURL=v127SubjectHost.js.map