Agent 生成器
- 作者仓库星标 1
- 作者更新于 实时读取
- 作者仓库 Solar
- 领域
- 通用
- 兼容 Agent
-
- Claude Code
- Cursor
- Cline
- Codex
- Windsurf
- Gemini CLI
- +20
- 信任分
- 88 / 100 · 社区维护
- 作者 / 版本 / 许可
- @Uhorizon-AI · 未声明 license
- Token 消耗评级
- 低消耗
- 接入复杂程度
- 需简单配置
- 是否需要外部 API Key
- 不需要
- 兼容的系统
- 未声明(默认跨平台)
- 底层运行要求
- 无特殊要求
- 文件与系统权限
-
- 只读
- 允许写入 / 修改
- Shell 执行
- 读取环境变量
- 网络行为
- 允许外网请求
- 安装命令数
- 26 条
档案由构建时根据 SKILL.md 与安装命令自动衍生,可能与作者实际意图存在差异。
需要注意: 未限定 allowed-tools,默认拥有全部工具权限。
---
name: solar-router
description: > Single source of truth for all AI execution in Solar: Use this skill as infrastructure for Sol…
category: 通用
runtime: 无特殊运行时
---
# solar-router 输出预览
## PART A: 任务判断
- 适用问题:通用任务拆解、检查和交付。
- 输入要求:目标材料、限制条件、期望输出和验收方式。
- 证据边界:围绕“Purpose / Operational boundary / Scope”读取原文规则,不把推断写成作者承诺。
## PART B: 执行结果
- **01** 任务判断:确认你的需求是否属于通用任务拆解、检查和交付,并标出输入、限制和预期结果。
- **02** 执行计划:优先按“Purpose / Operational boundary / Scope”拆成步骤,说明每一步会读取什么、修改什么、产出什么。
- **03** 交付结果:给出可复制的命令、文件改动、检查清单或内容草稿,并说明如何继续迭代。
- **04** 风险边界:结合 读取文件、写入/修改文件、执行终端命令、读取环境变量、会按任务需要访问外部网络、通常不需要额外 API Key 给出执行前确认项。
## Running Rules
- 读取文件、写入/修改文件、执行终端命令、读取环境变量;会按任务需要访问外部网络;通常不需要额外 API Key。
- 先小样例验证,再放大到真实任务。
- 交付时同时给结果、检查口径和下一步迭代建议。 原文出现了 `/tmp` 这类斜杠命令;如果你的 Agent 支持命令触发,优先用命令开场,再补充目标和边界。
告诉 Agent 目标文件或材料、期望结果、不可改范围、是否允许联网或执行命令。本 Skill 的权限画像是:读取文件、写入/修改文件、执行终端命令、读取环境变量。
先用一个小任务确认它会围绕“Purpose / Operational boundary / Scope”工作;涉及文件或命令时,先看 diff、日志、预览或测试结果。
检查最终产物是否包含明确结果、必要证据和下一步动作;如果输出泛泛而谈,就补充输入、边界和验收标准后重跑。
---
name: solar-router
description: > Single source of truth for all AI execution in Solar: Use this skill as infrastructure for Sol…
category: 通用
source: Uhorizon-AI/Solar
---
# solar-router
## 什么时候使用
- 把通用方向的常用动作沉淀成 Agent 可调用的技能 适合处理通用任务拆解、检查、交付和复盘,核心价值是把输入、判断、执行、验证和交付边界固定下来,避免 Agent 泛泛回答。 把任务拆成可执行、可检查、可继续迭代的步骤;通常不需要额外…
- 面向通用任务拆解、检查和交付,优先处理能明确输入、步骤和验收标准的工作。
## 需要提供什么
- 目标材料、目录范围、期望结果和不可改动内容。
- 是否允许联网、执行命令、读写文件或调用外部服务。
## 执行规则
- 围绕「Purpose / Operational boundary / Scope」组织步骤,不把推断写成作者事实。
- 读取文件、写入/修改文件、执行终端命令、读取环境变量;会按任务需要访问外部网络;通常不需要额外 API Key。
- 先跑小样例,确认结果可检查后再扩大任务范围。
## 输出要求
- 给出最终产物、关键证据、验证方式和下一步动作。
- 信息不足时标记 unknown,不编造命令、平台或依赖。 作者原文负责流程事实;仓库文件负责来源和命令;流狐只补充适用场景、限制和质量判断。
skill "solar-router" {
输入层 -> 用户目标 + 目标文件 + 禁止范围 + 验收标准
上下文层 -> Purpose / Operational boundary / Scope
规则层 -> SKILL.md 触发条件 / 执行顺序 / 输出格式
运行层 -> 无特殊运行时 | 读取文件、写入/修改文件、执行终端命令、读取环境变量 | 会按任务需要访问外部网络
安全层 -> 通常不需要额外 API Key + 小任务验证 + diff / 日志复核
输出层 -> 可复制结果 + 检查清单 + 下一步迭代
} Solar Router
Purpose
Single source of truth for all AI execution in Solar:
- Provider selection and fallback live only here.
- Async routing policy (
direct_replyvsasync_draft_created) lives only here. - Used by solar-gateway (WebSocket/bridge) and solar-async-tasks (task execution).
Operational boundary
Use this skill as infrastructure for Solar runtimes and controlled diagnostics. Do not use solar-router or provider CLIs as the normal path for work that is deferred, multiprovider, browser/MCP-dependent, network/auth/keychain-dependent, long-running, or likely to block the conversation.
For that work, create or propose a task through solar-async-tasks. When solar-system supervises async-tasks, approve/queue the task and let the system runtime execute it.
Scope
- Accept JSON payload (router contract v3) on stdin; output structured JSON on stdout.
- Run the selected provider with
cwd=SOLAR_WORKSPACEso all providers seesun/,planets/, and workspaceAGENTS.md. - Resolve
SOLAR_ROUTER_SYSTEM_PROMPT_FILEandSOLAR_ROUTER_RUNTIME_DIRagainstSOLAR_WORKSPACEwhen relative. - Codex default command includes
-C <repo-root>and--add-dir ~/.codex. - Persist conversation turns in runtime dir (JSONL) for continuity.
- Implement
DecisionEngine: decidedecision.kindbased onmode,channel, and AI semantic output. - Resolve JIT context from
metadata: lookup agent/skills in planet → fallback to core → generate role inline if not found. - Write audit log (
sun/runtime/router/audit.jsonl) withstart/endevents per execution for traceability (including failed early-exit paths).
Internal architecture
scripts/
run_router.py — thin entrypoint: stdin → route() → stdout + exit
router.py — all provider-agnostic logic (parse, validate, JIT, prompt, decision engine)
providers/
__init__.py — PROVIDERS dict, exports all adapters
base.py — BaseProvider: resolve_binary, get_cmd, prepare_env, clean_output, run
claude.py — static default_cmd
codex.py — build_default_cmd() with SOLAR_WORKSPACE + CODEX_STATE_DIR
gemini.py — prepare_env (GEMINI_* vars) + clean_output (ANSI strip, OAuth guard)
agent.py — build_default_cmd() with SOLAR_WORKSPACE
Automated tests live under `core/tests/skills/solar-router/` (framework-wide layout; see `core/AGENTS.md`).
Layer contract:
router.pydecides (context, prompt, policy, response shape).providers/executes (subprocess, env, normalization). No routing logic.run_router.pydoes I/O only. No logic.
Required MCP
None
Setup
# Configure router environment variables (SOLAR_ROUTER_*, timeouts, etc.)
bash core/skills/solar-router/scripts/onboard_router_env.sh
Key environment variables:
SOLAR_ROUTER_PROVIDER_PRIORITY— Comma-separated provider list (e.g.,codex,claude,gemini,ollama)SOLAR_ROUTER_RUNTIME_DIR— Where conversation history is stored (default:sun/runtime/router)SOLAR_ROUTER_SYSTEM_PROMPT_FILE— System prompt file path (default:core/skills/solar-router/assets/system_prompt.md)SOLAR_ROUTER_CONTEXT_TURNS— Number of conversation turns to include (default:12)SOLAR_ROUTER_TIMEOUT_SEC— End-to-end router timeout, including provider execution (default:300)
Optional command overrides:
SOLAR_ROUTER_CODEX_CMDSOLAR_ROUTER_CLAUDE_CMDSOLAR_ROUTER_GEMINI_CMDSOLAR_ROUTER_OLLAMA_CMD
Ollama setup:
provider=ollamaalways targets the local model namedsolar- Build or refresh it with
bash core/skills/solar-router/scripts/setup_ollama.sh
Validation commands
# Validate skill structure
python3 core/skills/solar-skill-creator/scripts/package_skill.py core/skills/solar-router /tmp
# List configured providers (reads SOLAR_ROUTER_PROVIDER_PRIORITY)
bash core/skills/solar-router/scripts/list_providers.sh
bash core/skills/solar-router/scripts/list_providers.sh --exclude claude
bash core/skills/solar-router/scripts/list_providers.sh --exclude claude --format csv
# Diagnose router / preflight providers (native helper in this skill)
bash core/skills/solar-router/scripts/diagnose_router.sh --dry-run
bash core/skills/solar-router/scripts/diagnose_router.sh
# Full error output when a provider fails (e.g. 401, binary not found)
bash core/skills/solar-router/scripts/diagnose_router.sh --verbose
# Unit tests: router logic + provider adapters (centralized under core/tests; pytest runs unittest-style tests; no real AI calls)
uv run --project core/tests pytest core/tests/skills/solar-router -q
# Without uv: PYTHONPATH=core/skills/solar-router/scripts python3 -m unittest discover -s core/tests/skills/solar-router -p "test_*.py" -v
# Smoke tests: validate router contract v3, bridge delegation, execute_active.py JSON parsing
bash core/skills/solar-router/scripts/check_router.sh
# Live status: provider health, in-flight processes, last executions
bash core/skills/solar-router/scripts/status_router.sh
bash core/skills/solar-router/scripts/status_router.sh --last 20
Router contract v3
Input (stdin JSON)
{
"request_id": "string",
"session_id": "string",
"user_id": "string",
"text": "string",
"channel": "telegram|n8n|async-task|other",
"mode": "auto|direct_only|async_only",
"provider": "codex|claude|gemini|agent|ollama|null",
"metadata": {
"agent": "agent-name|null",
"skills": ["planet:skill-name", "core-skill-name"],
"planet": "planet-name|null"
}
}
provider: optional. If set, strict mode — no fallback. If fails →error_code: provider_locked_failed.mode: defaults toauto.direct_onlyalways returnsdirect_reply.async_onlyrequiresasync-tasksfeature enabled.channel: used byDecisionEnginefor semantic routing inmode=auto.metadata.agent: existing agent name from planet'sagents/, ornullfor JIT role generation.metadata.skills: skill name format —planet:skillresolves toplanets/<planet>/skills/<skill>/SKILL.md; unprefixedskillresolves toplanets/<metadata.planet>/skills/<skill>/SKILL.mdfirst (ifmetadata.planetis set), then falls back tocore/skills/<skill>/SKILL.md. Only description is injected (on-demand).metadata.planet: planet that owns the task domain. Used for agent/skill lookup.
Secure Invocation Protocol (Required)
To prevent JSON parsing errors (invalid control characters, unescaped newlines), always use one of these two methods when calling the router from an AI agent or shell:
Method A: Temporary JSON File (Recommended for Agents)
- Use
write_fileto create a temporary JSON file (e.g.,sun/runtime/router/request_<id>.json). - Ensure the
textfield contains explicit\nfor newlines. - Execute the router piping the file:
python3 core/skills/solar-router/scripts/run_router.py < sun/runtime/router/request_<id>.json.
Method B: Heredoc with Single Quotes (Shell)
Use a heredoc with 'EOF' (single quotes) to prevent the shell from interpreting backslashes or special characters:
cat << 'EOF' | python3 core/skills/solar-router/scripts/run_router.py
{
"request_id": "my-id",
"text": "Line 1\nLine 2",
"channel": "other",
"mode": "direct_only"
}
EOF
Critical Rules:
- Prefer escaped newlines (
\n) inside JSON strings for portability. - Escape double quotes inside the
textstring as\". - Validate JSON before sending if using a custom script.
Output (stdout JSON)
{
"status": "success|failed",
"request_id": "string",
"provider_used": "codex|claude|gemini|agent|ollama",
"reply_text": "string",
"decision": {
"kind": "direct_reply|async_draft_proposal|async_draft_created|async_activation_needed",
"task_id": "string|null",
"priority_suggested": "high|normal|low|null"
},
"error_code": "string|null",
"error": "string|null"
}
DecisionEngine rules
mode=direct_only→decision.kind=direct_replyalways.mode=async_only+async-tasksenabled →decision.kind=async_draft_created.mode=async_only+async-tasksdisabled →status=failed+ explicit error.mode=auto+channel=async-task→decision.kind=direct_reply(already in queue).mode=auto+channel=telegram|n8n|other→ AI decides semantically via structured JSON output.
Consumers
- solar-gateway:
run_websocket_bridge.pyand HTTP webhook bridge call the router with full v3 contract. - solar-async-tasks:
execute_active.py(viaexecute_active.sh) calls the router withchannel=async-task,mode=direct_only.
Runtime files
sun/runtime/router/conversations/<user_id>.jsonl— conversation history per user (for context continuity).sun/runtime/router/audit.jsonl— audit log with onestart/endrecord pair per execution. Fields:router_id(internal UUID),request_id(caller ref),user_id,metadata,provider,status,jit_generated,duration_ms.
References
references/routing-policy.md— provider priority, env keys, repo-context policy, v3 contract rules.
先判断是否适合
作者设计意图
作者的方法与取舍
边界和复核