import type { ToolRuntimeRouteProjection } from '../types/index.d';

export function toolRuntimeRouteLabel(route?: ToolRuntimeRouteProjection['runtimeRoute']) {
	switch (route) {
		case 'worker-local':
			return 'Worker 本地执行';
		case 'main-process-proxy':
			return '主进程代理执行';
		default:
			return 'Worker 禁用';
	}
}

export function toolWorkerRoutingHintLabel(hint?: ToolRuntimeRouteProjection['workerRoutingHint']) {
	switch (hint) {
		case 'local':
			return '支持 Worker 本地';
		case 'main-process-proxy':
			return '需主进程代理';
		default:
			return 'Worker 不支持';
	}
}

export function toolBlockedReasonLabel(reason?: string | null) {
	if (!reason) return '';
	switch (reason) {
		case 'runtime_disabled':
			return '当前运行时已禁用';
		case 'workspace_root_required':
			return '缺少工作区根目录';
		case 'shell_disabled_by_policy':
			return 'Shell 被策略禁用';
		case 'write_blocked_by_readonly_policy':
			return '只读策略禁止写入';
		case 'requires_main_process_proxy':
			return '需要主进程代理';
		case 'unsupported_in_worker':
			return 'Worker 不支持';
		case 'not_selected_for_subagent':
			return '未进入当前子代理工具集';
		default:
			return reason;
	}
}

export function toolRuntimeRouteTagType(route?: ToolRuntimeRouteProjection['runtimeRoute']) {
	if (route === 'worker-local') return 'success';
	if (route === 'main-process-proxy') return 'warning';
	return 'info';
}
