export const microphoneStopRecordingDependencyDeclarations = [
    {
        dependencyId: "runtime.execEngine.computeruse.stopRecording",
        kind: "runtime",
        required: true,
        description: "Runtime-owned microphone recording stop/finalization support exposed through BaseToolExecutorPort.computeruse.stopRecording.",
    },
    {
        dependencyId: "runtime.governancePlane.toolInvocationGrant",
        kind: "permission",
        required: true,
        description: "dryRun:false requires an affirmative runtime guard before microphone recording stop dispatch.",
    },
    {
        dependencyId: "runtime.recordingSession.microphone",
        kind: "runtime",
        required: true,
        description: "Runtime owns microphone recording session handles, final audio artifacts, device cleanup, privacy boundaries, and retention.",
    },
];
export function createRuntimeMicrophoneStopRecordingProvider(executor) {
    const stopRecording = executor?.computeruse?.stopRecording;
    if (stopRecording === undefined)
        return undefined;
    return async (request) => {
        const result = await stopRecording({
            resource: "microphone",
            recordingId: request.target.recordingId,
            storageTarget: request.target.persistHint,
            purpose: request.purpose,
            metadata: {
                runtimeId: request.context.runtimeId,
                sessionId: request.context.sessionId,
                invocationId: request.context.invocationId,
                deviceId: request.target.deviceId,
                releaseDevice: request.target.releaseDevice,
                auditMetadata: request.context.auditMetadata,
            },
        });
        if (!result.ok) {
            throw new Error(result.error.message);
        }
        return {
            artifactId: result.output.artifactId,
            mimeType: result.output.mimeType,
            metadata: {
                ...(result.output.metadata ?? {}),
                ...(result.metadata ?? {}),
            },
        };
    };
}
