export const codeReadDependencyDeclarations = [
    {
        dependencyId: "runtime.execEngine.filesystem.readText",
        kind: "filesystem",
        required: true,
        description: "Runtime-provided text reader exposed through BaseToolExecutorPort.filesystem.readText",
    },
    {
        dependencyId: "runtime.governancePlane.workspaceReadScope",
        kind: "permission",
        required: true,
        description: "Runtime workspaceRoot, allowedRoots, and scope decision carried in code.read context",
    },
    {
        dependencyId: "runtime.capabilityExposure.codeReadEnvelope",
        kind: "runtime",
        required: true,
        description: "Runtime-safe code read result envelope for content, encoding, byte count, and truncation metadata",
    },
];
export function createHostExecutorCodeReadProvider(executor) {
    const readText = executor?.filesystem?.readText;
    if (readText === undefined) {
        return undefined;
    }
    return async (request) => {
        const result = await readText({
            path: request.targetPath,
            encoding: request.encoding,
            maxBytes: request.maxBytes,
        });
        if (!result.ok) {
            throw new Error(result.error.message);
        }
        return {
            content: result.output.content,
            encoding: request.encoding,
            truncated: result.output.truncated,
        };
    };
}
