LeoYeAI/agent-master-skills / skills/agent-comm-hub
agent-comm-hub
Flagged多智能体协同通信基础设施——基于 MCP+SSE 的实时消息、任务调度、记忆共享与进化引擎。支持 WorkBuddy、Hermes、QClaw 及任意 MCP 兼容 Agent 接入。53 个 MCP 工具、4 级权限、零外部依赖 Python SDK。触发词:agent通信、智能体通信、hub通信、多智能体、跨agent通信、任务调度、assign_task、send_message、hermes通信、workbuddy通信、agent hub、通信hub、mcp通信、记忆共享、进化引擎、策略共享、经验分享、共享记忆,共同进化
src/errors.ts
View on GitHub/**
* errors.ts — 统一错误码体系
* Phase D: 替换散落的 new Error(),提供结构化错误信息
*/
// ─── 错误码枚举 ────────────────────────────────────────────
export enum HubErrorCode {
// 通用 1xxx
UNKNOWN = "HUB_1000",
INTERNAL = "HUB_1001",
NOT_FOUND = "HUB_1002",
VALIDATION = "HUB_1003",
ALREADY_EXISTS = "HUB_1004",
UNREACHABLE = "HUB_1005",
// 认证/权限 2xxx
AUTH_REQUIRED = "HUB_2000",
PERMISSION_DENIED = "HUB_2001",
TOKEN_EXPIRED = "HUB_2002",
TOKEN_INVALID = "HUB_2003",
// Agent 3xxx
AGENT_NOT_FOUND = "HUB_3000",
AGENT_OFFLINE = "HUB_3001",
INVALID_ROLE = "HUB_3002",
// 任务/编排 4xxx
TASK_NOT_FOUND = "HUB_4000",
INVALID_TRANSITION = "HUB_4001",
CYCLE_DETECTED = "HUB_4002",
DEPENDENCY_EXISTS = "HUB_4003",
DEPENDENCY_NOT_FOUND = "HUB_4004",
HANDOFF_NOT_TARGET = "HUB_4005",
GATE_NOT_FOUND = "HUB_4006",
GATE_ALREADY_EVAL = "HUB_4007",
PARALLEL_MIN_TASKS = "HUB_4008",
PARALLEL_MAX_TASKS = "HUB_4009",
GROUP_NOT_FOUND = "HUB_4010",
// Pipeline 5xxx
PIPELINE_NOT_FOUND = "HUB_5000",
// 消息 6xxx
MESSAGE_SEND_FAIL = "HUB_6000",
// 数据库 7xxx
DB_ERROR = "HUB_7000",
DB_INTEGRITY = "HUB_7001",
}
// ─── HubError 类 ────────────────────────────────────────────
export class HubError extends Error {
readonly code: HubErrorCode;
readonly details?: Record<string, unknown>;
constructor(code: HubErrorCode, message: string, details?: Record<string, unknown>) {
super(message);
this.name = "HubError";
this.code = code;
this.details = details;
}
/** 序列化为 MCP 工具返回格式 */
toJSON(): { error: true; code: string; message: string; details?: Record<string, unknown> } {
return {
error: true,
code: this.code,
message: this.message,
...(this.details && { details: this.details }),
};
}
/** 从 unknown 判断是否为 HubError */
static isHubError(err: unknown): err is HubError {
return err instanceof HubError;
}
}
// ─── 工厂函数(简化常见错误创建) ────────────────────────────
export function notFound(resource: string, id: string): HubError {
return new HubError(HubErrorCode.NOT_FOUND, `${resource} not found: ${id}`, { resource, id });
}
export function alreadyExists(resource: string, id?: string): HubError {
return new HubError(HubErrorCode.ALREADY_EXISTS, `${resource} already exists${id ? `: ${id}` : ""}`, { resource, id });
}
export function validation(msg: string, details?: Record<string, unknown>): HubError {
return new HubError(HubErrorCode.VALIDATION, msg, details);
}
export function permissionDenied(tool: string, required: string, actual: string): HubError {
return new HubError(
HubErrorCode.PERMISSION_DENIED,
`Permission denied: ${tool} requires '${required}' role, current role is '${actual}'`,
{ tool, required, actual },
);
}
export function authRequired(tool?: string): HubError {
return new HubError(HubErrorCode.AUTH_REQUIRED, tool ? `Authentication required for tool: ${tool}` : "Authentication required", { tool });
}
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness. | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |