export const shellCommandValidationDependencyDeclarations = [
    {
        dependencyId: "runtime.execEngine.shellGuard.validateCommand",
        kind: "runtime",
        required: true,
        description: "Runtime-owned shell command validation port exposed through BaseToolExecutorPort.shell.validateCommand",
    },
    {
        dependencyId: "runtime.governancePlane.toolInvocationGrant",
        kind: "permission",
        required: true,
        description: "Runtime governance decision carried in context.guard for real command validation dispatch",
    },
];
export function createHostExecutorShellCommandValidationProvider(executor) {
    const run = executor?.shell?.validateCommand;
    if (run === undefined) {
        return undefined;
    }
    return async (request, context) => {
        const result = await run({
            command: request.command ?? "",
            workingDirectory: request.workingDirectory,
            shell: request.shell ?? "sh",
            policy: request.policy,
            context: context,
        });
        if (!result.ok) {
            throw Object.assign(new Error(result.error.message), { publicSafe: result.error.publicSafe });
        }
        return result.output;
    };
}
