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