const publicSafeProviderFailurePrefix = "PUBLIC_SAFE_PROVIDER_FAILURE:";
export const checkboxConfirmDependencyDeclarations = [
    {
        dependencyId: "runtime.execEngine.computeruse.pointerAction",
        kind: "runtime",
        required: true,
        description: "Runtime-owned pointer confirmation support exposed through BaseToolExecutorPort.computeruse.pointerAction.",
    },
    {
        dependencyId: "runtime.governancePlane.toolInvocationGrant",
        kind: "permission",
        required: true,
        description: "dryRun:false requires an affirmative runtime guard before checkbox confirmation dispatch.",
    },
    {
        dependencyId: "runtime.inputController.pointer",
        kind: "runtime",
        required: true,
        description: "Runtime owns OS pointer events, focus, target resolution, platform adapters, cleanup, and input policy.",
    },
];
export function createRuntimeCheckboxConfirmProvider(executor) {
    const pointerAction = executor?.computeruse?.pointerAction;
    if (pointerAction === undefined)
        return undefined;
    return async (request) => {
        const result = await pointerAction({
            action: "confirm",
            target: {
                expectedState: request.target.expectedState,
                currentState: request.target.currentState,
                label: request.target.label,
                selectorHint: request.target.selectorHint,
                point: request.target.point,
                coordinateSpace: request.target.coordinateSpace,
                displayId: request.target.displayId,
                windowId: request.target.windowId,
                clickMode: request.target.clickMode,
                clickCount: request.target.clickCount,
                wouldToggle: request.target.wouldToggle,
            },
            metadata: {
                runtimeId: request.context.runtimeId,
                sessionId: request.context.sessionId,
                invocationId: request.context.invocationId,
                purpose: request.purpose,
                runtimeGuardAccepted: true,
                auditMetadata: request.context.auditMetadata,
            },
        });
        if (!result.ok) {
            throw new Error(`${publicSafeProviderFailurePrefix}${result.error.message}`);
        }
        return {
            actionId: result.output.actionId,
            metadata: {
                ...(result.output.metadata ?? {}),
                ...(result.metadata ?? {}),
            },
        };
    };
}
