We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/starlink-awaken/SocialGuessSkills'
If you have feedback or need assistance with the MCP directory API, please join our Discord server
import type { Conflict, AgentType, AgentOutput } from "../types";
export function detectConflicts(outputs: AgentOutput[]): Conflict[] {
const conflicts: Conflict[] = [];
conflicts.push(...detectLogicalConflicts(outputs));
conflicts.push(...detectPriorityConflicts(outputs));
conflicts.push(...detectRiskAmplification(outputs));
conflicts.push(...detectGoalConflicts(outputs));
conflicts.push(...detectConstraintConflicts(outputs));
conflicts.push(...detectEvidenceConflicts(outputs));
return conflicts;
}
function detectLogicalConflicts(outputs: AgentOutput[]): Conflict[] {
const conflicts: Conflict[] = [];
// Known domain tension pairs where conclusions naturally conflict
const incompatiblePairs: [AgentType, AgentType, string][] = [
["econ", "socio", "经济效率最大化与社会公平分配存在结构性张力"],
["governance", "culture", "制度化管控与文化自主性之间需要平衡"],
["risk", "econ", "风险规避与经济增长之间存在取舍"],
["technology", "historical", "技术颠覆与历史路径依赖之间存在冲突"],
["infrastructure", "environmental", "基础设施扩张与生态保护之间需要协调"],
["military", "econ", "军事投入与经济发展之间存在资源竞争"],
["religion", "governance", "宗教权威与世俗治理之间存在权力边界张力"],
["ethnicity", "culture", "族群特殊性保护与文化统一性之间需要平衡"],
["geopolitics", "socio", "地缘战略考量可能压制社会福利优先级"],
["disaster", "infrastructure", "灾后重建需求与日常基础设施投资之间存在资源竞争"],
["emergency", "governance", "紧急状态下的集中权力与常态治理的分权原则存在冲突"],
];
const conclusionKeywords: Record<AgentType, string[]> = {
systems: ["反馈", "回路", "稳定"],
econ: ["激励", "产权", "效率"],
socio: ["认同", "规范", "共同体"],
governance: ["权力", "执行", "监督"],
culture: ["仪式", "符号", "认同"],
risk: ["崩溃", "储备", "缓冲"],
validation: ["可证伪", "反例", "验证"],
environmental: ["生态", "环境", "可持续"],
demographic: ["人口", "迁移", "老龄化"],
infrastructure: ["基础设施", "网络", "承载力"],
technology: ["技术", "创新", "自动化"],
historical: ["历史", "先例", "演变"],
geopolitics: ["地缘", "领土", "联盟"],
ethnicity: ["族群", "民族", "认同"],
religion: ["信仰", "教义", "世俗"],
military: ["防御", "武力", "威慑"],
disaster: ["灾害", "预警", "救援"],
emergency: ["应急", "危机", "响应"]
};
// Negation indicators in falsifiable statements
const negationIndicators = ["不成立", "失效", "无法", "不能", "未能", "失败"];
const outputMap = new Map(outputs.map(o => [o.agentType, o]));
for (let i = 0; i < outputs.length; i++) {
for (let j = i + 1; j < outputs.length; j++) {
const agentA = outputs[i];
const agentB = outputs[j];
if (!agentA || !agentB) continue;
const keywordsA = conclusionKeywords[agentA.agentType] || [];
const keywordsB = conclusionKeywords[agentB.agentType] || [];
const falsifiableA = agentA.falsifiable ?? "";
const falsifiableB = agentB.falsifiable ?? "";
// Check 1: Known incompatible pairs (both present in outputs)
const knownConflict = incompatiblePairs.find(([a, b]) =>
(agentA.agentType === a && agentB.agentType === b) ||
(agentA.agentType === b && agentB.agentType === a)
);
if (knownConflict) {
conflicts.push({
type: "logical",
involvedAgents: [agentA.agentType, agentB.agentType],
description: knownConflict[2],
severity: "medium",
resolutionStrategy: "需明确优先级并在两个目标间寻找帕累托最优解"
});
continue; // Skip keyword check for known pairs
}
// Check 2: Semantic negation - one agent's falsifiable negates another's conclusion keywords
const negatesB = negationIndicators.some(neg => falsifiableA.includes(neg)) &&
keywordsB.some(kw => falsifiableA.includes(kw));
const negatesA = negationIndicators.some(neg => falsifiableB.includes(neg)) &&
keywordsA.some(kw => falsifiableB.includes(kw));
if (negatesB || negatesA) {
conflicts.push({
type: "logical",
involvedAgents: [agentA.agentType, agentB.agentType],
description: `${agentA.agentType}的可证伪假设与${agentB.agentType}的核心结论存在语义矛盾`,
severity: "high",
resolutionStrategy: "需重新审视两个Agent的假设边界,明确适用条件"
});
continue;
}
// Check 3: Original keyword cross-reference (lower priority)
const hasConflict = keywordsA.some(kw =>
falsifiableB.toLowerCase().includes(kw.toLowerCase())
) || keywordsB.some(kw =>
falsifiableA.toLowerCase().includes(kw.toLowerCase())
);
if (hasConflict) {
conflicts.push({
type: "logical",
involvedAgents: [agentA.agentType, agentB.agentType],
description: `${agentA.agentType}的结论可能与${agentB.agentType}的可证伪点冲突`,
severity: "medium",
resolutionStrategy: "需重新审视两个Agent的假设边界,明确适用条件"
});
}
}
}
return conflicts;
}
function detectPriorityConflicts(outputs: AgentOutput[]): Conflict[] {
const conflicts: Conflict[] = [];
const priorityMatrix: Record<AgentType, number> = {
systems: 3,
econ: 2,
socio: 2,
governance: 4,
culture: 2,
risk: 5,
validation: 1,
environmental: 3,
demographic: 2,
infrastructure: 3,
technology: 2,
historical: 2,
geopolitics: 4,
ethnicity: 3,
religion: 3,
military: 5,
disaster: 4,
emergency: 5
};
const suggestionGroups = new Map<string, AgentType[]>();
outputs.forEach(output => {
output.suggestions.forEach(suggestion => {
const key = suggestion.substring(0, 20);
if (!suggestionGroups.has(key)) {
suggestionGroups.set(key, []);
}
suggestionGroups.get(key)!.push(output.agentType);
});
});
suggestionGroups.forEach((agents, key) => {
if (agents.length > 1) {
const highPriorityAgent = agents.sort((a, b) =>
priorityMatrix[b] - priorityMatrix[a]
)[0];
conflicts.push({
type: "priority",
involvedAgents: agents,
description: `多个Agent提出相似建议: "${key}...",应优先采纳${highPriorityAgent}的视角`,
severity: "low",
resolutionStrategy: `按优先级排序(Risk > Governance > Systems > Econ/Socio/Culture > Validation),采纳${highPriorityAgent}的建议`
});
}
});
const resourceKeywords = ["资源", "分配", "储备", "投入", "产出"];
const resourceSuggestions = outputs.flatMap(o =>
o.suggestions.filter(s => resourceKeywords.some(k => s.includes(k)))
.map(s => ({ agent: o.agentType, suggestion: s }))
);
if (resourceSuggestions.length > 1) {
const agents = [...new Set(resourceSuggestions.map(r => r.agent))];
if (agents.length > 1) {
conflicts.push({
type: "priority",
involvedAgents: agents,
description: "多个Agent对资源配置提出互斥建议",
severity: "high",
resolutionStrategy: "按优先级采纳,并由Governance Agent最终决策"
});
}
}
return conflicts;
}
function detectRiskAmplification(outputs: AgentOutput[]): Conflict[] {
const conflicts: Conflict[] = [];
const riskKeywords = {
"崩溃": 5,
"失稳": 4,
"瓦解": 5,
"崩塌": 5,
"异化": 3,
"失效": 4,
"失败": 4
};
let totalRiskScore = 0;
const riskDetails: string[] = [];
outputs.forEach(output => {
output.risks.forEach(risk => {
for (const [keyword, score] of Object.entries(riskKeywords)) {
if (risk.includes(keyword)) {
totalRiskScore += score;
riskDetails.push(`${output.agentType}: ${risk.substring(0, 50)}...`);
break;
}
}
});
});
const avgRiskPerAgent = totalRiskScore / outputs.length;
if (avgRiskPerAgent > 3) {
conflicts.push({
type: "risk_amplification",
involvedAgents: outputs.map(o => o.agentType),
description: `整体风险水平过高(平均${avgRiskPerAgent.toFixed(1)}分/Agent),多个Agent识别到高风险点`,
severity: "high",
resolutionStrategy: "需优先由Risk Agent审查,设计缓冲与冗余机制,降低整体脆弱性"
});
}
const highRiskAgents = outputs.filter(o =>
o.risks.some(r => ["崩溃", "瓦解", "崩塌"].some(k => r.includes(k)))
);
if (highRiskAgents.length >= 3) {
conflicts.push({
type: "risk_amplification",
involvedAgents: highRiskAgents.map(o => o.agentType),
description: `多个Agent(${highRiskAgents.length}个)识别到系统崩溃风险,需强化韧性与缓冲机制`,
severity: "high",
resolutionStrategy: "启动风险缓解方案,建立应急储备,预设权力边界,防止连锁崩溃"
});
}
return conflicts;
}
function detectGoalConflicts(outputs: AgentOutput[]): Conflict[] {
const conflicts: Conflict[] = [];
const goalKeywords: Record<AgentType, string[]> = {
systems: ["效率", "优化", "改进"],
econ: ["利润", "最大化", "增长"],
socio: ["公平", "平等", "分配"],
governance: ["控制", "监管", "稳定"],
culture: ["传统", "保护", "延续"],
risk: ["稳健", "安全", "防护"],
validation: ["验证", "测试", "评估"],
environmental: ["可持续", "碳中和", "生态平衡"],
demographic: ["均衡", "适龄", "人口红利"],
infrastructure: ["互联互通", "冗余", "升级"],
technology: ["数字化", "智能化", "颠覆"],
historical: ["延续", "复兴", "借鉴"],
geopolitics: ["战略自主", "缓冲", "外交平衡"],
ethnicity: ["融合", "多元", "平等权利"],
religion: ["信仰自由", "政教分离", "宗教和谐"],
military: ["安全", "防御", "文官控制"],
disaster: ["防灾", "减灾", "恢复"],
emergency: ["快速响应", "韧性", "预案"]
};
for (let i = 0; i < outputs.length; i++) {
for (let j = i + 1; j < outputs.length; j++) {
const agentA = outputs[i];
const agentB = outputs[j];
if (!agentA || !agentB) continue;
// Check if one agent prioritizes efficiency while another prioritizes stability
const agentAType = agentA.agentType;
const agentBType = agentB.agentType;
const keywordsA = goalKeywords[agentAType] || [];
const keywordsB = goalKeywords[agentBType] || [];
// Check for conflicting goals (efficiency vs stability, profit vs equality, etc.)
const conflictPairs: [string[], string[]][] = [
[["效率", "增长"], ["公平", "平等", "稳定"]], // econ vs socio/governance
[["控制", "监管"], ["自由", "创新"]], // governance vs systems
[["传统", "保护"], ["效率", "优化"]], // culture vs systems
[["稳健", "安全"], ["最大化", "增长"]] // risk vs econ
];
for (const [goalsA, goalsB] of conflictPairs) {
const agentAHasGoals = keywordsA.some(k => goalsA.includes(k));
const agentBHasGoals = keywordsB.some(k => goalsB.includes(k));
if (agentAHasGoals && agentBHasGoals) {
conflicts.push({
type: "goal",
involvedAgents: [agentA.agentType, agentB.agentType],
description: `${agentA.agentType}的目标(${keywordsA.join("/")})与${agentB.agentType}的目标(${keywordsB.join("/")})存在潜在冲突`,
severity: "medium",
resolutionStrategy: "需明确优先级顺序,建立目标权衡机制,寻求多目标共赢方案"
});
break; // Avoid duplicate conflicts
}
}
}
}
return conflicts;
}
function detectConstraintConflicts(outputs: AgentOutput[]): Conflict[] {
const conflicts: Conflict[] = [];
const constraintKeywords: Record<AgentType, string[]> = {
systems: ["必须", "应当", "强制"],
econ: ["成本", "预算", "资源限制"],
socio: ["参与", "共识", "民主"],
governance: ["法规", "合规", "审批"],
culture: ["习俗", "禁忌", "规范"],
risk: ["风险阈值", "安全标准", "底线"],
validation: ["测试条件", "验证标准", "证据要求"],
environmental: ["排放上限", "生态红线", "环评"],
demographic: ["人口容量", "承载极限", "迁移配额"],
infrastructure: ["承载上限", "维护周期", "冗余要求"],
technology: ["技术成熟度", "兼容性", "安全审计"],
historical: ["历史教训", "制度惯性", "路径依赖"],
geopolitics: ["地缘格局", "领土完整", "联盟义务"],
ethnicity: ["族群比例", "文化权利", "反歧视"],
religion: ["信仰边界", "宗教法", "世俗原则"],
military: ["武力边界", "军民比例", "防卫预算"],
disaster: ["灾害等级", "响应时限", "储备标准"],
emergency: ["应急等级", "触发条件", "恢复期限"]
};
for (let i = 0; i < outputs.length; i++) {
for (let j = i + 1; j < outputs.length; j++) {
const agentA = outputs[i];
const agentB = outputs[j];
if (!agentA || !agentB) continue;
const agentAType = agentA.agentType;
const agentBType = agentB.agentType;
const keywordsA = constraintKeywords[agentAType] || [];
const keywordsB = constraintKeywords[agentBType] || [];
// Check for incompatible constraints
const incompatiblePairs: [string[], string[]][] = [
[["强制", "必须"], ["应当", "建议", "自主"]], // strict vs flexible
[["成本限制"], ["高投入", "资源充足"]], // econ vs systems (resource mismatch)
[["法规", "合规"], ["灵活", "创新"]], // governance vs culture
[["风险阈值"], ["激进", "最大化"]], // risk vs econ
[["测试条件"], ["快速", "敏捷"]] // validation vs systems
];
for (const [constraintsA, constraintsB] of incompatiblePairs) {
const agentAConstraints = keywordsA.some(k => constraintsA.includes(k));
const agentBConstraints = keywordsB.some(k => constraintsB.includes(k));
if (agentAConstraints && agentBConstraints) {
conflicts.push({
type: "constraint",
involvedAgents: [agentA.agentType, agentB.agentType],
description: `${agentA.agentType}的约束条件(${keywordsA.join("/")})与${agentB.agentType}的约束条件(${keywordsB.join("/")})不兼容`,
severity: "medium",
resolutionStrategy: "需重新评估约束条件的必要性和可执行性,寻求折中方案或分阶段实施"
});
break;
}
}
}
}
return conflicts;
}
function detectEvidenceConflicts(outputs: AgentOutput[]): Conflict[] {
const conflicts: Conflict[] = [];
for (let i = 0; i < outputs.length; i++) {
for (let j = i + 1; j < outputs.length; j++) {
const agentA = outputs[i];
const agentB = outputs[j];
if (!agentA || !agentB) continue;
// Check for contradictory falsifiable evidence
const falsifiableA = agentA.falsifiable ?? "";
const falsifiableB = agentB.falsifiable ?? "";
if (!falsifiableA || !falsifiableB) continue;
// Evidence contradictions
const contradictionPatterns = [
{ pattern1: ["必然"], pattern2: ["可能", "也许", "不确定"] },
{ pattern1: ["不可能"], pattern2: ["可行", "可以实现"] },
{ pattern1: ["完全", "总是"], pattern2: ["很少", "有时"] },
{ pattern1: ["增加"], pattern2: ["减少", "下降"] },
{ pattern1: ["稳定"], pattern2: ["波动", "不稳定"] }
];
for (const { pattern1, pattern2 } of contradictionPatterns) {
const hasPattern1 = pattern1.some(p => falsifiableA.includes(p));
const hasPattern2 = pattern2.some(p => falsifiableB.includes(p));
if (hasPattern1 && hasPattern2) {
conflicts.push({
type: "evidence",
involvedAgents: [agentA.agentType, agentB.agentType],
description: `${agentA.agentType}的可证伪点"${falsifiableA.substring(0, 50)}..."与${agentB.agentType}的可证伪点"${falsifiableB.substring(0, 50)}..."存在逻辑矛盾`,
severity: "high",
resolutionStrategy: "需重新验证双方证据,明确适用条件和边界条件,或寻求第三方验证"
});
break;
}
}
}
}
return conflicts;
}
export function suggestResolution(conflict: Conflict): string {
if (conflict.resolutionStrategy) {
return conflict.resolutionStrategy;
}
switch (conflict.type) {
case "logical":
return "重新审视矛盾双方的假设边界,明确适用条件,避免冲突";
case "priority":
return "按优先级排序(Risk > Governance > Systems > Econ/Socio/Culture > Validation)采纳建议";
case "risk_amplification":
return "启动风险缓解方案,建立缓冲与冗余机制,降低整体脆弱性";
case "goal":
return "需明确优先级顺序,建立目标权衡机制,寻求多目标共赢方案";
case "constraint":
return "需重新评估约束条件的必要性和可执行性,寻求折中方案或分阶段实施";
case "evidence":
return "需重新验证双方证据,明确适用条件和边界条件,或寻求第三方验证";
default:
return "需人工审查并决策";
}
}
export function filterConflictsBySeverity(
conflicts: Conflict[],
minSeverity: 'low' | 'medium' | 'high'
): Conflict[] {
const severityOrder = ['low', 'medium', 'high'];
const minIndex = severityOrder.indexOf(minSeverity);
return conflicts.filter(c =>
severityOrder.indexOf(c.severity) >= minIndex
);
}