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