import { EMPTY_OBJECT_SCHEMA, STRING_SCHEMA, objectSchema, listOutputSchema, entityOutputSchema, bodyEnvelopeSchema, methodDescriptor } from './method-catalog-shared.js';
import { CONFIG_SET_OUTPUT_SCHEMA, CONFIG_SNAPSHOT_SCHEMA, LOCAL_AUTH_USER_SCHEMA, LOCAL_AUTH_BOOTSTRAP_DELETE_OUTPUT_SCHEMA, LOCAL_AUTH_DELETE_OUTPUT_SCHEMA, LOCAL_AUTH_SESSION_REVOKE_OUTPUT_SCHEMA, LOCAL_AUTH_STATUS_SCHEMA, LOCAL_AUTH_ROTATE_PASSWORD_OUTPUT_SCHEMA, PANEL_OPEN_OUTPUT_SCHEMA, PANEL_SNAPSHOT_SCHEMA, } from './operator-contract-schemas.js';
export const builtinGatewayAdminMethodDescriptors = [
    methodDescriptor({
        id: 'local_auth.status',
        title: 'Local Auth Status',
        description: 'Return local auth posture, users, and sessions.',
        category: 'auth',
        scopes: ['read:auth'],
        access: 'admin',
        http: { method: 'GET', path: '/api/local-auth' },
        inputSchema: EMPTY_OBJECT_SCHEMA,
        outputSchema: LOCAL_AUTH_STATUS_SCHEMA,
    }),
    methodDescriptor({
        id: 'local_auth.users.create',
        title: 'Create Local Auth User',
        description: 'Create a local auth user.',
        category: 'auth',
        scopes: ['write:auth'],
        access: 'admin',
        http: { method: 'POST', path: '/api/local-auth/users' },
        inputSchema: bodyEnvelopeSchema({
            username: STRING_SCHEMA,
            password: STRING_SCHEMA,
        }, ['username', 'password']),
        outputSchema: entityOutputSchema('user', LOCAL_AUTH_USER_SCHEMA),
    }),
    methodDescriptor({
        id: 'local_auth.users.delete',
        title: 'Delete Local Auth User',
        description: 'Delete a local auth user.',
        category: 'auth',
        scopes: ['write:auth'],
        access: 'admin',
        http: { method: 'DELETE', path: '/api/local-auth/users/{username}' },
        inputSchema: objectSchema({ username: STRING_SCHEMA }, ['username']),
        outputSchema: LOCAL_AUTH_DELETE_OUTPUT_SCHEMA,
        dangerous: true,
    }),
    methodDescriptor({
        id: 'local_auth.users.password.rotate',
        title: 'Rotate Local Auth Password',
        description: 'Rotate a local auth user password.',
        category: 'auth',
        scopes: ['write:auth'],
        access: 'admin',
        http: { method: 'POST', path: '/api/local-auth/users/{username}/password' },
        inputSchema: bodyEnvelopeSchema({ password: STRING_SCHEMA }, ['password']),
        outputSchema: LOCAL_AUTH_ROTATE_PASSWORD_OUTPUT_SCHEMA,
    }),
    methodDescriptor({
        id: 'local_auth.sessions.delete',
        title: 'Revoke Local Auth Session',
        description: 'Revoke a local auth session.',
        category: 'auth',
        scopes: ['write:auth'],
        access: 'admin',
        http: { method: 'DELETE', path: '/api/local-auth/sessions/{sessionId}' },
        inputSchema: objectSchema({ sessionId: STRING_SCHEMA }, ['sessionId']),
        outputSchema: LOCAL_AUTH_SESSION_REVOKE_OUTPUT_SCHEMA,
        dangerous: true,
    }),
    methodDescriptor({
        id: 'local_auth.bootstrap.delete',
        title: 'Delete Bootstrap File',
        description: 'Delete the local-auth bootstrap credential file.',
        category: 'auth',
        scopes: ['write:auth'],
        access: 'admin',
        http: { method: 'DELETE', path: '/api/local-auth/bootstrap-file' },
        inputSchema: EMPTY_OBJECT_SCHEMA,
        outputSchema: LOCAL_AUTH_BOOTSTRAP_DELETE_OUTPUT_SCHEMA,
        dangerous: true,
    }),
    methodDescriptor({
        id: 'panels.list',
        title: 'List Panels',
        description: 'Return integration panel descriptors.',
        category: 'panels',
        scopes: ['read:panels'],
        http: { method: 'GET', path: '/api/panels' },
        inputSchema: EMPTY_OBJECT_SCHEMA,
        outputSchema: listOutputSchema('panels', PANEL_SNAPSHOT_SCHEMA),
    }),
    methodDescriptor({
        id: 'panels.open',
        title: 'Open Panel',
        description: 'Request that a panel be opened in the current TUI session.',
        category: 'panels',
        scopes: ['write:panels'],
        http: { method: 'POST', path: '/api/panels/open' },
        inputSchema: bodyEnvelopeSchema({
            id: STRING_SCHEMA,
            pane: STRING_SCHEMA,
        }, ['id']),
        outputSchema: PANEL_OPEN_OUTPUT_SCHEMA,
    }),
    methodDescriptor({
        id: 'config.get',
        title: 'Get Config',
        description: 'Return the resolved GoodVibes config snapshot.',
        category: 'config',
        scopes: ['read:config'],
        access: 'admin',
        http: { method: 'GET', path: '/config' },
        inputSchema: EMPTY_OBJECT_SCHEMA,
        outputSchema: CONFIG_SNAPSHOT_SCHEMA,
    }),
    methodDescriptor({
        id: 'config.set',
        title: 'Set Config Value',
        description: 'Set a config value through the daemon API.',
        category: 'config',
        scopes: ['write:config'],
        access: 'admin',
        http: { method: 'POST', path: '/config' },
        inputSchema: bodyEnvelopeSchema({
            key: STRING_SCHEMA,
        }, ['key']),
        outputSchema: CONFIG_SET_OUTPUT_SCHEMA,
    }),
];
