juglans 0.1.0

Compiler and runtime for Juglans Workflow Language (JWL)
Documentation
name: "AI Router with Tooling"
prompts: [ "../prompts/*.jgprompt" ]
agents: [ "../agents/*.jgagent" ]

entry: [init]
exit: [final_notify]

[init]: notify(status="🔍 正在分析您的提问...")

# 第一步:复杂度分析 (开启静默模式,防止 JSON 结果污染屏幕)
[classify]: chat(
    agent="deepseek-local",
    format="json",
    stateless="true", # 💡 关键:不会出现在最终 Response 里
    message=p(slug="router", user_msg=$input.message)
)

[simple_reply]: chat(
    agent="deepseek-local", 
    chat_id=$reply.chat_id,
    message="用户刚才问了: '$input.message'。请根据上下文简洁回答。"
)

[complex_thinking]: notify(status="🧠 复杂问题,启动联网插件...")

# 【核心修改】原生 JSON 数组写法,无需转义
[complex_solver]: chat(
    agent="deepseek-local",
    chat_id=$reply.chat_id,
    message=p(slug="solver", user_msg=$input.message),
    tools=[
        {
            "type": "function",
            "function": {
                "name": "fetch_url",
                "description": "获取网页的源代码或文本内容",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "url": {"type": "string", "description": "完整的网页 URL"},
                        "method": {"type": "string", "enum": ["GET", "POST"]}
                    },
                    "required": ["url"]
                }
            }
        }
    ]
)

[final_notify]: notify(status="✅ 处理完毕")

[init] -> [classify]

[classify] if ctx.classify.output.complexity == "simple" -> [simple_reply]
[classify] if ctx.classify.output.complexity == "complex" -> [complex_thinking]

[complex_thinking] -> [complex_solver]

[simple_reply] -> [final_notify]
[complex_solver] -> [final_notify]