"use strict";
// ── Admin tool manifests ─────────────────────────────────────────────────────
// Each entry mirrors the exact tool registered in system/mcp-servers/admin/
Object.defineProperty(exports, "__esModule", { value: true });
exports.ADMIN_TOOLS = void 0;
exports.ADMIN_TOOLS = [
    // ── tasks.ts ────────────────────────────────────────────────────────────
    { name: 'find_tasks', description: 'Search tasks with optional filters. Returns task records with workflow_id, status, workflow_type, and timestamps.', read_safe: true, inputSchema: { type: 'object', properties: { status: { type: 'string' }, workflow_type: { type: 'string' }, workflow_id: { type: 'string' }, origin_id: { type: 'string' }, limit: { type: 'integer' }, offset: { type: 'integer' } } } },
    { name: 'get_process_detail', description: 'Get all tasks and escalations for a process (origin_id).', read_safe: true, inputSchema: { type: 'object', properties: { origin_id: { type: 'string' } }, required: ['origin_id'] } },
    // ── escalations.ts ──────────────────────────────────────────────────────
    { name: 'find_escalations', description: 'Search escalations with optional filters by status, role, type, priority.', read_safe: true, inputSchema: { type: 'object', properties: { status: { type: 'string', enum: ['pending', 'resolved'] }, role: { type: 'string' }, type: { type: 'string' }, priority: { type: 'integer' }, limit: { type: 'integer' }, offset: { type: 'integer' } } } },
    { name: 'get_escalation_stats', description: 'Aggregated escalation statistics: pending, claimed, created, resolved counts with breakdown by role.', read_safe: true, inputSchema: { type: 'object', properties: { period: { type: 'string' } } } },
    { name: 'claim_escalation', description: 'Claim an escalation for a time-boxed lock.', read_safe: false, inputSchema: { type: 'object', properties: { id: { type: 'string' }, duration_minutes: { type: 'integer' } }, required: ['id'] } },
    { name: 'release_expired_claims', description: 'Release all escalation claims that exceeded their lock duration.', read_safe: false, inputSchema: { type: 'object', properties: {} } },
    { name: 'bulk_triage', description: 'Resolve escalations for triage and start mcpTriage workflows.', read_safe: false, inputSchema: { type: 'object', properties: { ids: { type: 'array', items: { type: 'string' } }, hint: { type: 'string' } }, required: ['ids'] } },
    { name: 'find_by_metadata', description: 'Find escalations by a metadata key-value pair.', read_safe: true, inputSchema: { type: 'object', properties: { key: { type: 'string' }, value: { type: 'string' }, status: { type: 'string' }, limit: { type: 'integer' }, offset: { type: 'integer' } }, required: ['key', 'value'] } },
    { name: 'claim_by_metadata', description: 'Find and claim an escalation by metadata key-value pair. Supports provisionIfAbsent for JIT user+role provisioning (superadmin only).', read_safe: false, inputSchema: { type: 'object', properties: { key: { type: 'string' }, value: { type: 'string' }, durationMinutes: { type: 'integer' }, assignee: { type: 'string' }, metadata: { type: 'object' }, provisionIfAbsent: { type: 'object', description: 'JIT-provision assignee if absent: { displayName?, email?, roles?: [{ role, type? }] }' } }, required: ['key', 'value'] } },
    { name: 'resolve_by_metadata', description: 'Find and resolve an escalation by metadata key-value pair. Signal-backed escalations (metadata.signal_id) are signaled to the workflow instead of resolved directly.', read_safe: false, inputSchema: { type: 'object', properties: { key: { type: 'string' }, value: { type: 'string' }, resolverPayload: { type: 'object' }, assignee: { type: 'string' }, metadata: { type: 'object' } }, required: ['key', 'value', 'resolverPayload'] } },
    { name: 'bulk_claim', description: 'Claim multiple escalations in a single operation.', read_safe: false, inputSchema: { type: 'object', properties: { ids: { type: 'array', items: { type: 'string' } }, durationMinutes: { type: 'integer' } }, required: ['ids'] } },
    { name: 'bulk_assign', description: 'Assign multiple escalations to a specific user.', read_safe: false, inputSchema: { type: 'object', properties: { ids: { type: 'array', items: { type: 'string' } }, targetUserId: { type: 'string' }, durationMinutes: { type: 'integer' } }, required: ['ids', 'targetUserId'] } },
    { name: 'bulk_escalate', description: 'Escalate multiple escalations to a different role.', read_safe: false, inputSchema: { type: 'object', properties: { ids: { type: 'array', items: { type: 'string' } }, targetRole: { type: 'string' } }, required: ['ids', 'targetRole'] } },
    { name: 'update_priority', description: 'Update the priority of multiple escalations.', read_safe: false, inputSchema: { type: 'object', properties: { ids: { type: 'array', items: { type: 'string' } }, priority: { type: 'integer' } }, required: ['ids', 'priority'] } },
    // ── workflow-config.ts ──────────────────────────────────────────────────
    { name: 'list_workflow_configs', description: 'List all certified workflow configurations with roles and settings.', read_safe: true, inputSchema: { type: 'object', properties: {} } },
    { name: 'upsert_workflow_config', description: 'Create or replace a workflow configuration (certify). Activates the interceptor for task tracking and escalation chains.', read_safe: false, inputSchema: { type: 'object', properties: { workflow_type: { type: 'string' }, invocable: { type: 'boolean' }, task_queue: { type: 'string' }, default_role: { type: 'string' }, description: { type: 'string' }, execute_as: { type: 'string' }, roles: { type: 'array', items: { type: 'string' } }, invocation_roles: { type: 'array', items: { type: 'string' } }, consumes: { type: 'array', items: { type: 'string' } }, tool_tags: { type: 'array', items: { type: 'string' } }, cron_schedule: { type: 'string' } }, required: ['workflow_type'] } },
    { name: 'delete_workflow_config', description: 'De-certify a workflow by removing its config entry.', read_safe: false, inputSchema: { type: 'object', properties: { workflow_type: { type: 'string' } }, required: ['workflow_type'] } },
    // ── workflows.ts ────────────────────────────────────────────────────────
    { name: 'list_discovered_workflows', description: 'Unified list of all known workflows: active workers, historical entities, and registered configs.', read_safe: true, inputSchema: { type: 'object', properties: { include_system: { type: 'boolean' } } } },
    { name: 'invoke_workflow', description: 'Start a certified workflow by type. Returns workflow ID immediately.', read_safe: false, inputSchema: { type: 'object', properties: { workflow_type: { type: 'string' }, data: { type: 'object' }, metadata: { type: 'object' }, execute_as: { type: 'string' } }, required: ['workflow_type', 'data'] } },
    { name: 'get_workflow_status', description: 'Check workflow status and result. Returns status (0=complete, positive=running) and result if complete.', read_safe: true, inputSchema: { type: 'object', properties: { workflow_id: { type: 'string' } }, required: ['workflow_id'] } },
    // ── mcp-servers.ts ──────────────────────────────────────────────────────
    { name: 'list_mcp_servers', description: 'List registered MCP servers with optional filters by status, tags, or search.', read_safe: true, inputSchema: { type: 'object', properties: { status: { type: 'string' }, tags: { type: 'string' }, search: { type: 'string' }, limit: { type: 'integer' }, offset: { type: 'integer' } } } },
    { name: 'update_mcp_server', description: 'Update an MCP server registration (tags, description, auto_connect).', read_safe: false, inputSchema: { type: 'object', properties: { id: { type: 'string' }, name: { type: 'string' }, description: { type: 'string' }, tags: { type: 'array', items: { type: 'string' } }, auto_connect: { type: 'boolean' } }, required: ['id'] } },
    { name: 'connect_mcp_server', description: 'Connect to a registered MCP server.', read_safe: false, inputSchema: { type: 'object', properties: { id: { type: 'string' } }, required: ['id'] } },
    { name: 'disconnect_mcp_server', description: 'Disconnect from an MCP server.', read_safe: false, inputSchema: { type: 'object', properties: { id: { type: 'string' } }, required: ['id'] } },
    // ── yaml-workflows.ts ───────────────────────────────────────────────────
    { name: 'list_yaml_workflows', description: 'List compiled YAML workflows with optional status, namespace, or search filter.', read_safe: true, inputSchema: { type: 'object', properties: { status: { type: 'string' }, app_id: { type: 'string' }, search: { type: 'string' }, source_workflow_id: { type: 'string' }, limit: { type: 'integer' }, offset: { type: 'integer' } } } },
    { name: 'get_yaml_workflow', description: 'Inspect a compiled workflow by ID. Returns activity manifest, schemas, and YAML content.', read_safe: true, inputSchema: { type: 'object', properties: { id: { type: 'string' } }, required: ['id'] } },
    { name: 'create_yaml_workflow', description: 'Compile a completed execution into a deterministic YAML workflow. Stored as a draft.', read_safe: false, inputSchema: { type: 'object', properties: { workflow_id: { type: 'string' }, task_queue: { type: 'string' }, workflow_name: { type: 'string' }, name: { type: 'string' }, description: { type: 'string' }, app_id: { type: 'string' }, tags: { type: 'array', items: { type: 'string' } }, compilation_feedback: { type: 'string' } }, required: ['workflow_id', 'task_queue', 'workflow_name', 'name'] } },
    { name: 'deploy_yaml_workflow', description: 'Deploy a compiled YAML workflow, activate it, and register workers.', read_safe: false, inputSchema: { type: 'object', properties: { id: { type: 'string' } }, required: ['id'] } },
    { name: 'invoke_yaml_workflow', description: 'Run a compiled YAML workflow. Deterministic — no LLM. Set sync=true to wait.', read_safe: false, inputSchema: { type: 'object', properties: { id: { type: 'string' }, data: { type: 'object' }, sync: { type: 'boolean' }, timeout: { type: 'integer' } }, required: ['id'] } },
    // ── users.ts (users + roles) ────────────────────────────────────────────
    { name: 'list_users', description: 'List user accounts with optional role and status filters.', read_safe: true, inputSchema: { type: 'object', properties: { role: { type: 'string' }, status: { type: 'string' }, limit: { type: 'integer' }, offset: { type: 'integer' } } } },
    { name: 'create_user', description: 'Create a new user account with optional roles.', read_safe: false, inputSchema: { type: 'object', properties: { external_id: { type: 'string' }, display_name: { type: 'string' }, email: { type: 'string' }, roles: { type: 'array', items: { type: 'object', properties: { role: { type: 'string' }, type: { type: 'string', enum: ['superadmin', 'admin', 'member'] } }, required: ['role', 'type'] } } }, required: ['external_id'] } },
    { name: 'add_user_role', description: 'Assign a role to a user.', read_safe: false, inputSchema: { type: 'object', properties: { user_id: { type: 'string' }, role: { type: 'string' }, type: { type: 'string', enum: ['superadmin', 'admin', 'member'] } }, required: ['user_id', 'role', 'type'] } },
    { name: 'remove_user_role', description: 'Remove a role from a user.', read_safe: false, inputSchema: { type: 'object', properties: { user_id: { type: 'string' }, role: { type: 'string' } }, required: ['user_id', 'role'] } },
    { name: 'list_roles', description: 'List all distinct roles known to the system.', read_safe: true, inputSchema: { type: 'object', properties: {} } },
    { name: 'create_role', description: 'Create a new role. Lowercase alphanumeric with hyphens/underscores.', read_safe: false, inputSchema: { type: 'object', properties: { role: { type: 'string' } }, required: ['role'] } },
    { name: 'add_escalation_chain', description: 'Define an escalation path from one role to another.', read_safe: false, inputSchema: { type: 'object', properties: { source_role: { type: 'string' }, target_role: { type: 'string' } }, required: ['source_role', 'target_role'] } },
    // ── maintenance.ts ──────────────────────────────────────────────────────
    { name: 'prune', description: 'Prune expired jobs, streams, and execution artifacts from the database.', read_safe: false, inputSchema: { type: 'object', properties: { expire: { type: 'string' }, jobs: { type: 'boolean' }, streams: { type: 'boolean' }, entities: { type: 'array', items: { type: 'string' } }, prune_transient: { type: 'boolean' } } } },
    // ── agents.ts ───────────────────────────────────────────────────────────
    { name: 'list_agents', description: 'List agent automations with optional status and knowledge domain filters.', read_safe: true, inputSchema: { type: 'object', properties: { status: { type: 'string' }, knowledge_domain: { type: 'string' }, limit: { type: 'integer' }, offset: { type: 'integer' } } } },
    { name: 'get_agent', description: 'Get a single agent automation by ID with aggregated stats.', read_safe: true, inputSchema: { type: 'object', properties: { id: { type: 'string' } }, required: ['id'] } },
    { name: 'create_agent', description: 'Create a new agent automation with identity, goals, rules, and subscriptions.', read_safe: false, inputSchema: { type: 'object', properties: { id: { type: 'string' }, description: { type: 'string' }, goals: { type: 'array', items: { type: 'string' } }, rules: { type: 'array', items: { type: 'string' } }, status: { type: 'string' }, knowledge_domain: { type: 'string' }, schedules: { type: 'array' }, subscriptions: { type: 'array' } }, required: ['id'] } },
    { name: 'update_agent', description: 'Update an existing agent automation.', read_safe: false, inputSchema: { type: 'object', properties: { id: { type: 'string' }, description: { type: 'string' }, goals: { type: 'array', items: { type: 'string' } }, rules: { type: 'array', items: { type: 'string' } }, status: { type: 'string' }, knowledge_domain: { type: 'string' } }, required: ['id'] } },
    { name: 'delete_agent', description: 'Delete an agent automation and all its subscriptions.', read_safe: false, inputSchema: { type: 'object', properties: { id: { type: 'string' } }, required: ['id'] } },
    // ── agent-subscriptions.ts ──────────────────────────────────────────────
    { name: 'list_agent_subscriptions', description: 'List all event subscriptions for an agent.', read_safe: true, inputSchema: { type: 'object', properties: { agent_id: { type: 'string' } }, required: ['agent_id'] } },
    { name: 'create_agent_subscription', description: 'Create an event subscription for an agent.', read_safe: false, inputSchema: { type: 'object', properties: { agent_id: { type: 'string' }, topic: { type: 'string' }, reaction_type: { type: 'string' }, workflow_type: { type: 'string' }, pipeline_id: { type: 'string' }, mcp_prompt: { type: 'string' }, input_mapping: { type: 'object' }, filter: { type: 'object' }, execute_as: { type: 'string' } }, required: ['agent_id', 'topic', 'reaction_type'] } },
    { name: 'delete_agent_subscription', description: 'Delete an event subscription by ID.', read_safe: false, inputSchema: { type: 'object', properties: { id: { type: 'string' } }, required: ['id'] } },
    // ── bot-accounts.ts ─────────────────────────────────────────────────────
    { name: 'list_bot_accounts', description: 'List all bot (service) accounts with pagination.', read_safe: true, inputSchema: { type: 'object', properties: { limit: { type: 'integer' }, offset: { type: 'integer' } } } },
    { name: 'get_bot_account', description: 'Get a single bot account by ID.', read_safe: true, inputSchema: { type: 'object', properties: { id: { type: 'string' } }, required: ['id'] } },
    { name: 'create_bot_account', description: 'Create a new bot (service) account with optional roles.', read_safe: false, inputSchema: { type: 'object', properties: { name: { type: 'string' }, description: { type: 'string' }, display_name: { type: 'string' }, roles: { type: 'array', items: { type: 'object', properties: { role: { type: 'string' }, type: { type: 'string' } } } } }, required: ['name'] } },
    { name: 'update_bot_account', description: 'Update a bot account (display name, description, status).', read_safe: false, inputSchema: { type: 'object', properties: { id: { type: 'string' }, display_name: { type: 'string' }, description: { type: 'string' }, status: { type: 'string' } }, required: ['id'] } },
    { name: 'delete_bot_account', description: 'Delete a bot account and all its API keys.', read_safe: false, inputSchema: { type: 'object', properties: { id: { type: 'string' } }, required: ['id'] } },
    { name: 'create_bot_api_key', description: 'Generate a new API key for a bot account. Returns the raw key ONCE.', read_safe: false, inputSchema: { type: 'object', properties: { id: { type: 'string' }, name: { type: 'string' }, scopes: { type: 'array', items: { type: 'string' } }, expires_at: { type: 'string' } }, required: ['id', 'name'] } },
    { name: 'revoke_bot_api_key', description: 'Revoke (delete) an API key for a bot account.', read_safe: false, inputSchema: { type: 'object', properties: { key_id: { type: 'string' } }, required: ['key_id'] } },
    // ── controlplane.ts ─────────────────────────────────────────────────────
    { name: 'list_apps', description: 'List available HotMesh application namespaces.', read_safe: true, inputSchema: { type: 'object', properties: {} } },
    { name: 'rollcall', description: 'Execute a roll call — discovers all engines and workers in the mesh.', read_safe: true, inputSchema: { type: 'object', properties: { app_id: { type: 'string' }, delay: { type: 'integer' } } } },
    { name: 'apply_throttle', description: 'Apply a throttle to the mesh (-1=pause, 0=resume, >0=delay ms per message).', read_safe: false, inputSchema: { type: 'object', properties: { appId: { type: 'string' }, throttle: { type: 'integer' }, topic: { type: 'string' }, guid: { type: 'string' }, scope: { type: 'string' } }, required: ['throttle'] } },
    { name: 'get_stream_stats', description: 'Stream processing statistics — pending count and processed volume by time range.', read_safe: true, inputSchema: { type: 'object', properties: { app_id: { type: 'string' }, duration: { type: 'string' }, stream: { type: 'string' } } } },
    { name: 'list_stream_messages', description: 'Browse stream messages with pagination, filtering, and sorting.', read_safe: true, inputSchema: { type: 'object', properties: { namespace: { type: 'string' }, source: { type: 'string' }, limit: { type: 'integer' }, offset: { type: 'integer' }, sort_by: { type: 'string' }, order: { type: 'string', enum: ['asc', 'desc'] }, status: { type: 'string' }, stream_name: { type: 'string' }, msg_type: { type: 'string' }, topic: { type: 'string' }, workflow_name: { type: 'string' }, jid: { type: 'string' }, aid: { type: 'string' } }, required: ['namespace', 'source'] } },
    // ── pipelines.ts ────────────────────────────────────────────────────────
    { name: 'list_pipeline_entities', description: 'List distinct entity (tool) names from pipeline jobs.', read_safe: true, inputSchema: { type: 'object', properties: { app_id: { type: 'string' } } } },
    { name: 'list_pipeline_jobs', description: 'List pipeline jobs with optional entity, search, and status filters.', read_safe: true, inputSchema: { type: 'object', properties: { app_id: { type: 'string' }, limit: { type: 'integer' }, offset: { type: 'integer' }, entity: { type: 'string' }, search: { type: 'string' }, status: { type: 'string' }, sort_by: { type: 'string' }, order: { type: 'string', enum: ['asc', 'desc'] } } } },
    { name: 'get_pipeline_execution', description: 'Export execution details for a specific pipeline job.', read_safe: true, inputSchema: { type: 'object', properties: { job_id: { type: 'string' }, app_id: { type: 'string' } }, required: ['job_id'] } },
    { name: 'interrupt_pipeline_job', description: 'Interrupt a running pipeline job.', read_safe: false, inputSchema: { type: 'object', properties: { job_id: { type: 'string' }, topic: { type: 'string' }, app_id: { type: 'string' } }, required: ['job_id', 'topic'] } },
    // ── topics.ts ───────────────────────────────────────────────────────────
    { name: 'list_topics', description: 'List topics in the event catalog with optional category and search filters.', read_safe: true, inputSchema: { type: 'object', properties: { category: { type: 'string' }, search: { type: 'string' }, limit: { type: 'integer' }, offset: { type: 'integer' } } } },
    { name: 'get_topic', description: 'Get a single topic by name, including schema and example payload.', read_safe: true, inputSchema: { type: 'object', properties: { topic: { type: 'string' } }, required: ['topic'] } },
    { name: 'create_topic', description: 'Register a new topic in the event catalog.', read_safe: false, inputSchema: { type: 'object', properties: { topic: { type: 'string' }, category: { type: 'string' }, description: { type: 'string' }, payload_schema: { type: 'object' }, example_payload: { type: 'object' }, tags: { type: 'array', items: { type: 'string' } } }, required: ['topic', 'category'] } },
    { name: 'update_topic', description: 'Update a topic in the event catalog.', read_safe: false, inputSchema: { type: 'object', properties: { topic: { type: 'string' }, description: { type: 'string' }, category: { type: 'string' }, payload_schema: { type: 'object' }, example_payload: { type: 'object' }, tags: { type: 'array', items: { type: 'string' } } }, required: ['topic'] } },
    { name: 'delete_topic', description: 'Delete a topic from the catalog (system topics are protected).', read_safe: false, inputSchema: { type: 'object', properties: { topic: { type: 'string' } }, required: ['topic'] } },
    // ── settings.ts ─────────────────────────────────────────────────────────
    { name: 'get_settings', description: 'Get frontend-relevant configuration (no secrets). Returns feature flags, enabled capabilities, and system metadata.', read_safe: true, inputSchema: { type: 'object', properties: {} } },
    // ── exports.ts ──────────────────────────────────────────────────────────
    { name: 'list_export_jobs', description: 'List workflow jobs with optional filtering and pagination.', read_safe: true, inputSchema: { type: 'object', properties: { limit: { type: 'integer' }, offset: { type: 'integer' }, entity: { type: 'string' }, search: { type: 'string' }, status: { type: 'string' }, sort_by: { type: 'string' }, order: { type: 'string', enum: ['asc', 'desc'] } } } },
    { name: 'export_workflow_state', description: 'Export the full workflow state using HotMesh durable export.', read_safe: true, inputSchema: { type: 'object', properties: { workflow_id: { type: 'string' }, allow: { type: 'array', items: { type: 'string' } }, block: { type: 'array', items: { type: 'string' } }, values: { type: 'object' } }, required: ['workflow_id'] } },
    { name: 'export_workflow_execution', description: 'Export workflow state as a structured execution event history.', read_safe: true, inputSchema: { type: 'object', properties: { workflow_id: { type: 'string' }, excludeSystem: { type: 'boolean' }, omitResults: { type: 'boolean' }, mode: { type: 'string' }, maxDepth: { type: 'integer' } }, required: ['workflow_id'] } },
    { name: 'get_export_status', description: 'Return the numeric status semaphore for a workflow.', read_safe: true, inputSchema: { type: 'object', properties: { workflow_id: { type: 'string' } }, required: ['workflow_id'] } },
];
