export const shellProcessSpawningDependencyDeclarations = [
    {
        dependencyId: "runtime.processLifecycle.spawnHandle",
        kind: "runtime",
        required: true,
        description: "Runtime-provided shell process spawning provider; baseTools do not own shell/process side effects",
    },
    {
        dependencyId: "runtime.governancePlane.toolInvocationGrant",
        kind: "permission",
        required: true,
        description: "Runtime governance decision carried in context.guard for real execution",
    },
    {
        dependencyId: "runtime.capabilityExposure.shellAuditEnvelope",
        kind: "runtime",
        required: true,
        description: "Runtime audit envelope for process lifecycle and shell output material",
    },
];
export function createHostExecutorShellProcessSpawningProvider(executor) {
    const spawnProcess = executor?.shell?.spawnProcess;
    if (spawnProcess === undefined) {
        return undefined;
    }
    return async (request, context) => {
        const target = request.target ?? {};
        const command = typeof target.command === "string" ? target.command : target.executable;
        if (typeof command !== "string" || command.trim().length === 0) {
            throw new Error("shell.processSpawning requires a runtime command target");
        }
        const result = await spawnProcess({
            target,
            launchMode: request.launchMode ?? "foreground",
            context,
        });
        if (!result.ok) {
            throw new Error(result.error.message);
        }
        return {
            resultEnvelope: result.output,
            metadata: { hostExecutor: "BaseToolExecutorPort.shell.spawnProcess", ...(result.metadata ?? {}) },
        };
    };
}
