Skip to content

JiuwenSwarm is an intelligent AI Agent built on openJiuwen. It extends the powerful capabilities of large language models directly to your fingertips through various communication apps you use daily.

Python

update(mode): new mode config

dourand7e8e84c3a59
diff --git a/docs/zh/SLASH_COMMAND_ARCHITECTURE.md b/docs/zh/SLASH_COMMAND_ARCHITECTURE.md
index b28f965da4..3784be8732 100644
--- a/docs/zh/SLASH_COMMAND_ARCHITECTURE.md
+++ b/docs/zh/SLASH_COMMAND_ARCHITECTURE.md
@@ -39,7 +39,7 @@
**定义**:到达 Gateway 用户消息中,由 `MessageHandler`(或其后继统一入口)识别后,**可能只改会话/模式/路由,而不进入 Agent 对话**的指令。
-**典型**:`/new_session`、受控通道上的 `/mode plan|fast|team`(以当前实现为准)。
+**典型**:`/new_session`、受控通道上的 `/mode agent|code|team` 与 `/switch plan|fast|normal`,以及 `/mode agent.plan|agent.fast|code.plan|code.normal` 直达写法(以当前实现为准)。
**要求**:
@@ -115,7 +115,7 @@
## 7. 测试与质量保障
-- 为 SSOT 提供**单元测试**:覆盖精确匹配、非法后缀、多行文本、各 `mode` 变体等与现网一致的行为。
+- 为 SSOT 提供**单元测试**:覆盖精确匹配、非法后缀、多行文本、`/mode` 一级入口与直达值、`/switch` 合法/非法组合等与现网一致的行为。
- 回归时注意:**SessionMap 通道族**与普通受控通道在 `session_id` 行为上的差异仍由现有状态机负责,SSOT 只解决「字符串层」一致性与可维护性。
---
diff --git "a/docs/zh/Slash\345\221\275\344\273\244\350\241\250.md" "b/docs/zh/Slash\345\221\275\344\273\244\350\241\250.md"
index 275f2fba9c..f1b886a270 100644
--- "a/docs/zh/Slash\345\221\275\344\273\244\350\241\250.md"
+++ "b/docs/zh/Slash\345\221\275\344\273\244\350\241\250.md"
@@ -16,8 +16,7 @@
| `/exit` | 退出 |
| `/help` | 查看可用命令 |
| `/theme` | 切换主题 |
-| `/team` | 切换 Agent Team 模式(计划更名为 `/mode team`) |
-| `/mode` | 切换当前模式(**仅 IM 通道生效**) |
+| `/mode` | 切换当前模式(支持一级入口与直达值;**仅 IM 通道生效**) |
| `/config` | 修改配置(当前为 TUI 本地实现;规划改为走 Gateway 统一接口) |
---
@@ -32,8 +31,27 @@
| `/plan` | 切换规划子模式 |
| `/resume` | 见下方子用法 |
| `/new_session` | 创建新会话(**仅 IM 生效**) |
+| `/mode` | 受控通道模式切换(支持一级与直达写法) |
+| `/switch` | 在当前模式族内切换二级模式 |
| `/skills` | 见下方「技能」说明 |
+**`/mode` 与 `/switch`(受控通道)**
+
+- 一级入口:
+ - `/mode agent` -> `agent.plan`
+ - `/mode code` -> `code.normal`
+ - `/mode team` -> `team`
+- 已移除独立 `/team` 命令,请统一使用 `/mode team`。
+- 直达写法(今日已支持):
+ - `/mode agent.plan` -> `agent.plan`
+ - `/mode agent.fast` -> `agent.fast`
+ - `/mode code.plan` -> `code.plan`
+ - `/mode code.normal` -> `code.normal`
+- 二级切换(按当前模式族):
+ - agent 族:`/switch plan` <-> `agent.plan`,`/switch fast` <-> `agent.fast`
+ - code 族:`/switch plan` <-> `code.plan`,`/switch normal` <-> `code.normal`
+- 非法组合(例如 `code.*` 下 `/switch fast`)返回:`非法指令`
+
**`/resume`**
- `/resume list`:列出历史会话
diff --git a/jiuwenclaw/agentserver/agent_manager.py b/jiuwenclaw/agentserver/agent_manager.py
index 0b78a8e08d..08a88c5868 100644
--- a/jiuwenclaw/agentserver/agent_manager.py
+++ b/jiuwenclaw/agentserver/agent_manager.py
@@ -57,11 +57,11 @@ class AgentManager:
"""
def __init__(self) -> None:
- self.agents: dict[str, "JiuWenClaw"] = {}
+ self.agents: dict[str, dict[str, "JiuWenClaw"]] = {}
self._client_capabilities_by_channel: dict[str, dict[str, Any]] = {}
async def _create_agent(
- self, agent_key: str, config: dict[str, Any] | None = None
+ self, agent_key: str, mode: str = "agent", config: dict[str, Any] | None = None
) -> "JiuWenClaw":
"""创建 Agent 实例.
@@ -74,11 +74,10 @@ class AgentManager:
"""
from jiuwenclaw.agentserver.interface import JiuWenClaw
- mode = "code" if agent_key in ("acp", "tui") else "claw"
logger.info("[AgentManager] Creating %s agent (mode=%s)", agent_key, mode)
agent = JiuWenClaw()
await agent.create_instance(config, mode=mode)
- self.agents[agent_key] = agent
+ self.agents[agent_key] = {mode: agent}
logger.info("[AgentManager] %s agent created", agent_key)
return agent
@@ -112,7 +111,7 @@ class AgentManager:
del self.agents["acp"]
config = _build_acp_agent_config(extra_config)
- await self._create_agent("acp", config)
+ await self._create_agent("acp", "code", config)
return ACP_DEFAULT_CAPABILITIES.copy()
return None
@@ -141,23 +140,26 @@ class AgentManager:
return session_id
return "default"
- async def get_agent(self, channel_id: str = "") -> "JiuWenClaw | None":
+ async def get_agent(self, channel_id: str = "", mode: str = "agent") -> "JiuWenClaw | None":
"""获取 Agent 实例(自动创建).
如果 agent 不存在,会自动创建(仅用于非 ACP 场景)。
Args:
channel_id: 通道 ID
+ mode: 每个模式对应的实例
Returns:
JiuWenClaw | None: Agent 实例
"""
- if channel_id not in self.agents:
+ if channel_id in self.agents and mode in self.agents[channel_id]:
+ return self.agents[channel_id][mode]
+ else:
config: dict[str, Any] | None = None
if channel_id == "acp":
config = _build_acp_agent_config()
- await self._create_agent(channel_id, config)
- return self.agents.get(channel_id)
+ await self._create_agent(channel_id, mode, config)
+ return self.agents.get(channel_id).get(mode)
def get_agent_nowait(self, channel_id: str = "") -> "JiuWenClaw | None":
"""获取 Agent 实例(同步,不自动创建).
diff --git a/jiuwenclaw/agentserver/agent_ws_server.py b/jiuwenclaw/agentserver/agent_ws_server.py
index ae46912796..1ed1378a70 100644
--- a/jiuwenclaw/agentserver/agent_ws_server.py
+++ b/jiuwenclaw/agentserver/agent_ws_server.py
@@ -422,7 +422,8 @@ class AgentWebSocketServer:
await self._handle_acp_tool_response(ws, request, send_lock)
return
- agent = await self._agent_manager.get_agent(channel_id=channel_id)
+ mode = request.params.get("mode", "agent.plan").split(".")[0]
+ agent = await self._agent_manager.get_agent(channel_id=channel_id, mode=mode)
if agent is None:
raise ValueError("Failed to get agent")
@@ -441,8 +442,8 @@ class AgentWebSocketServer:
from jiuwenclaw.schema.message import ReqMethod
channel_id = request.channel_id or "default"
-
- agent = await self._agent_manager.get_agent(channel_id=channel_id)
+ mode = request.params.get("mode", "agent.plan").split(".")[0]
+ agent = await self._agent_manager.get_agent(channel_id=channel_id, mode=mode)
if agent is None:
raise ValueError("Failed to get agent")
diff --git a/jiuwenclaw/agentserver/deep_agent/cron_runtime.py b/jiuwenclaw/agentserver/deep_agent/cron_runtime.py
index fd789f174a..9ff7c25fe3 100644
--- a/jiuwenclaw/agentserver/deep_agent/cron_runtime.py
+++ b/jiuwenclaw/agentserver/deep_agent/cron_runtime.py
@@ -158,7 +158,7 @@ class _CronToolsCronBackend(CronToolBackend):
params={
"query": text,
"content": text,
- "mode": (mode or context.mode or "agent"),
+ "mode": (mode or context.mode or "agent.fast"),
},
timestamp=time.time(),
ok=True,
@@ -309,12 +309,12 @@ def _extract_legacy_params(
mode_resolved = (
context_mode
or data.get("mode")
- or "agent"
+ or "agent.fast"
)
out["mode"] = (
str(mode_resolved).strip().lower()
if isinstance(mode_resolved, str) and str(mode_resolved).strip()
- else "agent"
+ else "agent.fast"
)
return out
diff --git a/jiuwenclaw/agentserver/deep_agent/interface_deep.py b/jiuwenclaw/agentserver/deep_agent/interface_deep.py
index 75a227f4f0..48e3fee98d 100644
--- a/jiuwenclaw/agentserver/deep_agent/interface_deep.py
+++ b/jiuwenclaw/agentserver/deep_agent/interface_deep.py
@@ -208,7 +208,7 @@ def _deep_agent_context_engine_config(react_cfg: dict[str, Any] | None) -> Conte
def _build_context_engineering_rail(config: dict[str, Any],
- mode: str = "agent") -> ContextEngineeringRail | None:
+ mode: str = "agent.fast") -> ContextEngineeringRail | None:
"""Build ContextEngineeringRail with user config merged into presets.
用户提供的 processor 配置(dict 格式)会与预置配置做字段级别合并,
@@ -216,10 +216,10 @@ def _build_context_engineering_rail(config: dict[str, Any],
Args:
config: 配置字典
- mode: 模式,plan 模式使用 preset=True 和 processors,其他模式使用 preset=False 和 processors=None
+ mode: 模式,agent.plan 模式使用 preset=True 和 processors,其他模式使用 preset=False 和 processors=None
"""
try:
- if mode == "plan":
+ if mode == "agent.plan":
user_processors: List[Tuple[str, dict]] = []
context_engine_cfg = config.get("context_engine_config", {})
@@ -244,7 +244,7 @@ def _build_context_engineering_rail(config: dict[str, Any],
preset=True,
)
logger.info(
- "[JiuWenClawDeepAdapter] JiuClawContextEngineeringRail create success for plan mode, "
+ "[JiuWenClawDeepAdapter] JiuClawContextEngineeringRail create success for agent.plan mode, "
"user_processors=%s",
[p[0] for p in user_processors] if user_processors else "none"
)
@@ -1095,7 +1095,7 @@ class JiuWenClawDeepAdapter:
return rail
def _build_agent_rails(self, config: dict[str, Any], config_base: dict[str, Any], *,
- mode: str = "claw") -> list[Any]:
+ mode: str = "agent.plan") -> list[Any]:
"""Build DeepAgent rails consistently for cold start and hot reload."""
@dataclass
@@ -1185,7 +1185,7 @@ class JiuWenClawDeepAdapter:
model=model,
card=agent_card,
system_prompt=build_identity_prompt(
- mode="agent",
+ mode="agent.fast",
language=self._resolve_prompt_language(),
channel=(
"acp" if self._is_acp_tool_profile(self._instance_overrides)
@@ -1397,7 +1397,7 @@ class JiuWenClawDeepAdapter:
"""Backward-compatible no-op hook for tests and legacy call sites."""
return None
- async def create_instance(self, config: dict[str, Any] | None = None, *, mode: str = "claw") -> None:
+ async def create_instance(self, config: dict[str, Any] | None = None, *, mode: str = "agent.plan") -> None:
"""初始化 DeepAgent 实例.
Args:
@@ -1441,7 +1441,7 @@ class JiuWenClawDeepAdapter:
model=model,
card=agent_card,
system_prompt=build_identity_prompt(
- mode="agent",
+ mode="agent.fast",
language=self._resolve_prompt_language(),
channel=(
"acp" if self._is_acp_tool_profile(self._instance_overrides)
@@ -1603,7 +1603,7 @@ class JiuWenClawDeepAdapter:
async def _update_rails_for_mode(self, mode: str) -> None:
"""按 mode 注册或卸载 rails。"""
- if mode == "plan":
+ if mode == "agent.plan":
await self._update_plan_mode_rails()
else:
await self._update_agent_mode_rails()
@@ -1620,18 +1620,18 @@ class JiuWenClawDeepAdapter:
if getattr(existing, "name", "").startswith(("session_new", "session_cancel", "session_list")):
self._instance.ability_manager.remove(existing.name)
# plan 模式,根据config选择是否注册或者卸载memory rail
- await self._handle_memory_rail_by_config("plan")
+ await self._handle_memory_rail_by_config("agent.plan")
# 恢复上下文 rail(仅配置启用时)
if self._config_cache.get("context_engine_config", {}).get("enabled", False):
- if self._context_engineering_rail is not None and self._context_engineering_rail_mode != "plan":
+ if self._context_engineering_rail is not None and self._context_engineering_rail_mode != "agent.plan":
await self._instance.unregister_rail(self._context_engineering_rail)
self._context_engineering_rail = None
self._context_engineering_rail_mode = None
if self._context_engineering_rail is None:
self._context_engineering_rail = _build_context_engineering_rail(
- self._config_cache, mode="plan")
+ self._config_cache, mode="agent.plan")
if self._context_engineering_rail is not None:
- self._context_engineering_rail_mode = "plan"
+ self._context_engineering_rail_mode = "agent.plan"
await self._instance.register_rail(self._context_engineering_rail)
elif self._context_engineering_rail is not None:
await self._instance.unregister_rail(self._context_engineering_rail)
@@ -1667,15 +1667,15 @@ class JiuWenClawDeepAdapter:
await self._handle_memory_rail_by_config("fast")
# agent/智能模式:恢复上下文 rail(仅配置启用时)
if self._config_cache.get("context_engine_config", {}).get("enabled", False):
- if self._context_engineering_rail is not None and self._context_engineering_rail_mode == "plan":
+ if self._context_engineering_rail is not None and self._context_engineering_rail_mode == "agent.plan":
await self._instance.unregister_rail(self._context_engineering_rail)
self._context_engineering_rail = None
self._context_engineering_rail_mode = None
if self._context_engineering_rail is None:
self._context_engineering_rail = _build_context_engineering_rail(
- self._config_cache, mode="agent")
+ self._config_cache, mode="agent.fast")
if self._context_engineering_rail is not None:
- self._context_engineering_rail_mode = "agent"
+ self._context_engineering_rail_mode = "agent.fast"
await self._instance.register_rail(self._context_engineering_rail)
@staticmethod
@@ -1718,7 +1718,7 @@ class JiuWenClawDeepAdapter:
async def _update_tools_for_mode(self, mode: str, session_id: str | None, request_id: str | None) -> None:
"""按 mode 注册或卸载 multi-session 工具。"""
- if mode != "agent":
+ if mode != "agent.fast":
return
if not (request_id and session_id and self._model_client_config is not None):
return
@@ -1864,7 +1864,7 @@ class JiuWenClawDeepAdapter:
async def _update_runtime_config(
self,
session_id: str | None,
- mode: str = "plan",
+ mode: str = "agent.plan",
request_id: str | None = None,
channel_id: str | None = None,
request_metadata: dict[str, Any] | None = None,
@@ -2352,7 +2352,7 @@ class JiuWenClawDeepAdapter:
Returns None when the rail is (or becomes) available, or an error message string.
"""
- if mode != "plan":
+ if mode != "agent.plan":
return "agent 模式下演进功能不可用。"
if not self._config_cache.get("evolution", {}).get("enabled", False):
return "演进功能未启用。"
@@ -2363,7 +2363,7 @@ class JiuWenClawDeepAdapter:
return None
async def _handle_slash_command(
- self, query: str, session_id: str = "default", mode: str = "plan",
+ self, query: str, session_id: str = "default", mode: str = "agent.plan",
) -> dict[str, Any] | None:
"""Intercept /evolve and /solidify before agent invocation.
@@ -2473,7 +2473,7 @@ class JiuWenClawDeepAdapter:
session_id = request.session_id or "default"
query = request.params.get("query", "")
- mode = request.params.get("mode", "plan")
+ mode = request.params.get("mode", "agent.plan")
slash_result = await self._handle_slash_command(query, session_id, mode)
if slash_result is not None:
@@ -2559,7 +2559,7 @@ class JiuWenClawDeepAdapter:
rid = request.request_id
cid = request.channel_id
query = request.params.get("query", "")
- mode = request.params.get("mode", "plan")
+ mode = request.params.get("mode", "agent.plan")
# Team 模式处理
if mode == "team":
@@ -2692,7 +2692,7 @@ class JiuWenClawDeepAdapter:
if (
not evolution_status_started
and self._skill_evolution_rail is not None
- and request.params.get("mode", "plan") == "plan"
+ and request.params.get("mode", "agent.plan") == "agent.plan"
):
# Mark evolution phase start before after_invoke auto-evolution runs.
yield AgentResponseChunk(
diff --git a/jiuwenclaw/agentserver/interface.py b/jiuwenclaw/agentserver/interface.py
index cb8fa62683..b59b89f786 100644
--- a/jiuwenclaw/agentserver/interface.py
+++ b/jiuwenclaw/agentserver/interface.py
@@ -160,7 +160,7 @@ class JiuWenClaw:
logger.info("[JiuWenClaw] Initialized adapter: sdk=%s", self._sdk_name)
return self._adapter
- async def create_instance(self, config: dict[str, Any] | None = None, *, mode: str = "claw") -> None:
+ async def create_instance(self, config: dict[str, Any] | None = None, *, mode: str = "agent") -> None:
"""初始化 Agent 实例.
Args:
diff --git a/jiuwenclaw/app_gateway.py b/jiuwenclaw/app_gateway.py
index 9557675fca..a2eb180ca6 100644
--- a/jiuwenclaw/app_gateway.py
+++ b/jiuwenclaw/app_gateway.py
@@ -873,7 +873,7 @@ class GatewayServer:
timestamp=time.time(),
ok=True,
req_method=ReqMethod.CHAT_SEND,
- mode=Mode.AGENT,
+ mode=Mode.CODE_NORMAL,
metadata={"acp": {"jsonrpc_id": rpc_id, "method": method}},
)
if self._on_message_cb is not None:
@@ -967,13 +967,7 @@ class GatewayServer:
if session_key is not None:
self._session_to_client[session_key] = ws
- mode = Mode.PLAN
- raw_mode = params.get("mode")
- if isinstance(raw_mode, str):
- try:
- mode = Mode(raw_mode.strip().lower())
- except ValueError:
- mode = Mode.PLAN
+ mode = Mode.from_raw(params.get("mode"), default=Mode.AGENT_PLAN)
msg = Message(
id=req_id,
diff --git a/jiuwenclaw/channel/acp_channel.py b/jiuwenclaw/channel/acp_channel.py
index cd67d0933c..e7663758e6 100644
--- a/jiuwenclaw/channel/acp_channel.py
+++ b/jiuwenclaw/channel/acp_channel.py
@@ -934,7 +934,7 @@ class AcpChannel(BaseChannel):
if msg.session_id:
params.setdefault("session_id", msg.session_id)
if msg.mode is not None:
- params.setdefault("mode", msg.mode.value)
+ params.setdefault("mode", msg.mode.to_runtime_mode())
req_method = getattr(msg.req_method, "value", None)
if not isinstance(req_method, str) or not req_method:
diff --git a/jiuwenclaw/channel/web_channel.py b/jiuwenclaw/channel/web_channel.py
index a165bce6bb..d4991649c0 100644
--- a/jiuwenclaw/channel/web_channel.py
+++ b/jiuwenclaw/channel/web_channel.py
@@ -508,14 +508,7 @@ class WebChannel(BaseChannel):
@staticmethod
def _parse_mode(raw_mode: Any) -> Mode:
- if isinstance(raw_mode, str):
- normalized = raw_mode.strip().lower()
- if normalized:
- try:
- return Mode(normalized)
- except ValueError:
- pass
- return Mode.PLAN
+ return Mode.from_raw(raw_mode, default=Mode.AGENT_PLAN)
@staticmethod
def _make_session_id() -> str:
diff --git a/jiuwenclaw/cli/src/app-state.ts b/jiuwenclaw/cli/src/app-state.ts
index 4f686d652c..46ebfe7c0f 100644
--- a/jiuwenclaw/cli/src/app-state.ts
+++ b/jiuwenclaw/cli/src/app-state.ts
@@ -44,7 +44,7 @@ import { type ConnectionStatus, WsClient } from "./core/ws-client.js";
export interface AppSnapshot {
connectionStatus: ConnectionStatus;
sessionId: string;
- mode: "plan" | "agent" | "team";
+ mode: "agent.plan" | "agent.fast" | "code.plan" | "code.normal" | "team";
themeName: ThemeName;
accentColor: AccentColorName;
transcriptMode: "compact" | "detailed";
@@ -71,7 +71,8 @@ export class CliPiAppState {
private entries: HistoryItem[] = [];
private connectionStatus: ConnectionStatus = "idle";
private sessionId: string;
- private mode: "plan" | "agent" | "team" = "plan";
+ private mode: "agent.plan" | "agent.fast" | "code.plan" | "code.normal" | "team" =
+ "agent.plan";
private themeName: ThemeName = getCurrentThemeName();
private accentColor: AccentColorName = getCurrentAccentColor();
private transcriptMode: "compact" | "detailed" = "compact";
@@ -333,7 +334,9 @@ export class CliPiAppState {
this.emitChange();
};
- readonly setMode = (mode: "plan" | "agent" | "team"): void => {
+ readonly setMode = (
+ mode: "agent.plan" | "agent.fast" | "code.plan" | "code.normal" | "team",
+ ): void => {
if (this.mode !== mode) {
this.mode = mode;
this.emitChange();
@@ -410,7 +413,7 @@ export class CliPiAppState {
readonly sendMessage = (
content: string,
- modeOverride?: "plan" | "agent" | "team",
+ modeOverride?: "agent.plan" | "agent.fast" | "code.plan" | "code.normal" | "team",
): string | null => {
if (this.connectionStatus !== "connected") return null;
const mode = modeOverride ?? this.mode;
diff --git a/jiuwenclaw/cli/src/core/commands/builtins/mode.ts b/jiuwenclaw/cli/src/core/commands/builtins/mode.ts
index ad4a5aa40f..0592ee5b37 100644
--- a/jiuwenclaw/cli/src/core/commands/builtins/mode.ts
+++ b/jiuwenclaw/cli/src/core/commands/builtins/mode.ts
@@ -2,27 +2,49 @@ import { makeItem } from "../helpers.js";
import { CommandKind, type SlashCommand } from "../types.js";
export function createModeCommand(): SlashCommand {
+ const directModes = ["agent.plan", "agent.fast", "code.plan", "code.normal", "team"] as const;
+ const modeAlias: Record<
+ string,
+ "agent.plan" | "agent.fast" | "code.plan" | "code.normal" | "team"
+ > = {
+ plan: "agent.plan",
+ agent: "agent.fast",
+ code: "code.normal",
+ "agent.plan": "agent.plan",
+ "agent.fast": "agent.fast",
+ "code.plan": "code.plan",
+ "code.normal": "code.normal",
+ team: "team",
+ };
+
return {
name: "mode",
description: "Switch chat mode",
- usage: "/mode <plan|agent>",
- example: "/mode agent",
+ usage: "/mode <agent.plan|agent.fast|code.plan|code.normal|team>",
+ example: "/mode agent.plan",
kind: CommandKind.BUILT_IN,
takesArgs: true,
- completion: async () => ["plan", "agent"],
+ completion: async () => [...directModes],
action: async (ctx, args) => {
- const nextMode = args.trim();
- if (nextMode !== "plan" && nextMode !== "agent") {
- ctx.addItem(makeItem(ctx.sessionId, "error", "usage: /mode <plan|agent>"));
+ const requestedMode = args.trim();
+ const nextMode = modeAlias[requestedMode];
+ if (!nextMode) {
+ ctx.addItem(
+ makeItem(
+ ctx.sessionId,
+ "error",
+ "usage: /mode <agent.plan|agent.fast|code.plan|code.normal|team>",
+ ),
+ );
return;
}
try {
- await ctx.request("mode.set", { mode: nextMode });
+ await ctx.request("mode.set", { mode: requestedMode });
} catch {
// Some backends still accept mode only on chat.send.
}
ctx.setMode(nextMode);
- ctx.addItem(makeItem(ctx.sessionId, "info", `Mode set to ${nextMode}`, "m"));
+ ctx.addItem(makeItem(ctx.sessionId, "info", `Mode set to ${requestedMode}`, "m"));
},
};
}
diff --git a/jiuwenclaw/cli/src/core/commands/builtins/plan.ts b/jiuwenclaw/cli/src/core/commands/builtins/plan.ts
index a8cc9aab4f..4933623652 100644
--- a/jiuwenclaw/cli/src/core/commands/builtins/plan.ts
+++ b/jiuwenclaw/cli/src/core/commands/builtins/plan.ts
@@ -11,8 +11,8 @@ export function createPlanCommand(): SlashCommand {
takesArgs: true,
action: (ctx, args) => {
const value = args.trim();
- if (ctx.mode !== "plan") {
- ctx.setMode("plan");
+ if (ctx.mode !== "agent.plan") {
+ ctx.setMode("agent.plan");
}
if (!value) {
@@ -31,7 +31,7 @@ export function createPlanCommand(): SlashCommand {
return;
}
- const requestId = ctx.sendMessage(value, "plan");
+ const requestId = ctx.sendMessage(value, "agent.plan");
if (!requestId) {
ctx.addItem(
addInfo(ctx.sessionId, "offline: waiting for reconnect before sending plan request", "p"),
diff --git a/jiuwenclaw/cli/src/core/commands/builtins/team.ts b/jiuwenclaw/cli/src/core/commands/builtins/team.ts
deleted file mode 100644
index 6f420945d3..0000000000
--- a/jiuwenclaw/cli/src/core/commands/builtins/team.ts
+++ /dev/null
@@ -1,46 +0,0 @@
-import { generateSessionId } from "../../session-state.js";
-import { addError, addInfo } from "../helpers.js";
-import { CommandKind, type SlashCommand } from "../types.js";
-
-export function createTeamCommand(): SlashCommand {
- return {
- name: "team",
- description: "Toggle team mode",
- usage: "/team",
- example: "/team",
- kind: CommandKind.BUILT_IN,
- action: async (ctx) => {
- if (ctx.isProcessing) {
- ctx.addItem(
- addError(
- ctx.sessionId,
- "session is busy; stop the current run before switching team mode",
- ),
- );
- return;
- }
-
- const nextMode = ctx.mode === "team" ? "plan" : "team";
- const nextId = generateSessionId();
- try {
- await ctx.request("session.create", { session_id: nextId });
- } catch {
- // Some backends may create the session lazily on first message.
- }
-
- ctx.setMode(nextMode);
- ctx.updateSession(nextId);
- ctx.clearEntries();
- ctx.addItem(
- addInfo(
- nextId,
- nextMode === "team"
- ? `Team mode enabled. Started a fresh conversation in ${nextId}`
- : `Team mode disabled. Back to plan mode in ${nextId}`,
- "t",
- ),
- );
- await ctx.restoreHistory(nextId);
- },
- };
-}
diff --git a/jiuwenclaw/cli/src/core/commands/registry.ts b/jiuwenclaw/cli/src/core/commands/registry.ts
index 4201477e9a..bfb8d4d4a1 100644
--- a/jiuwenclaw/cli/src/core/commands/registry.ts
+++ b/jiuwenclaw/cli/src/core/commands/registry.ts
@@ -11,11 +11,12 @@ import { createExitCommand } from "./builtins/exit.js";
import { createHelpCommand } from "./builtins/help.js";
import { createHotkeyCommand } from "./builtins/hotkey.js";
import { createModelCommand } from "./builtins/model.js";
+import { createModeCommand } from "./builtins/mode.js";
import { createPlanCommand } from "./builtins/plan.js";
import { createResumeCommand } from "./builtins/resume.js";
import { createSessionCommand } from "./builtins/session.js";
import { createSkillsCommand } from "./builtins/skills.js";
-import { createTeamCommand } from "./builtins/team.js";
+import { createSwitchCommand } from "./builtins/switch.js";
import { createThemeCommand } from "./builtins/theme.js";
export function createBuiltinCommands(): SlashCommand[] {
@@ -30,11 +31,12 @@ export function createBuiltinCommands(): SlashCommand[] {
createDiffCommand(),
createExitCommand(),
createModelCommand(),
+ createModeCommand(),
+ createSwitchCommand(),
createPlanCommand(),
createResumeCommand(),
createSessionCommand(),
createSkillsCommand(),
- createTeamCommand(),
createThemeCommand(),
createHotkeyCommand(),
];
diff --git a/jiuwenclaw/cli/src/core/commands/types.ts b/jiuwenclaw/cli/src/core/commands/types.ts
index 7b47d790f6..12286fed5f 100644
--- a/jiuwenclaw/cli/src/core/commands/types.ts
+++ b/jiuwenclaw/cli/src/core/commands/types.ts
@@ -20,7 +20,10 @@ export interface CommandContext {
method: string,
params: Record<string, unknown>,
) => Promise<T>;
- sendMessage: (content: string, mode?: "plan" | "agent" | "team") => string | null;
+ sendMessage: (
+ content: string,
+ mode?: "agent.plan" | "agent.fast" | "code.plan" | "code.normal" | "team",
+ ) => string | null;
sessionId: string;
entries: HistoryItem[];
themeName: ThemeName;
@@ -32,8 +35,8 @@ export interface CommandContext {
exitApp: () => void;
isProcessing: boolean;
connectionStatus: ConnectionStatus;
- mode: "plan" | "agent" | "team";
- setMode: (mode: "plan" | "agent" | "team") => void;
+ mode: "agent.plan" | "agent.fast" | "code.plan" | "code.normal" | "team";
+ setMode: (mode: "agent.plan" | "agent.fast" | "code.plan" | "code.normal" | "team") => void;
setThemeName: (theme: ThemeName) => void;
setAccentColor: (color: AccentColorName) => void;
transcriptMode: "compact" | "detailed";
diff --git a/jiuwenclaw/cli/src/core/event-handlers.ts b/jiuwenclaw/cli/src/core/event-handlers.ts
index a4c6a97c4a..19ec58cad2 100644
--- a/jiuwenclaw/cli/src/core/event-handlers.ts
+++ b/jiuwenclaw/cli/src/core/event-handlers.ts
@@ -48,7 +48,7 @@ export interface AppEventDelegate {
getConnectionStatus(): ConnectionStatus;
getSessionId(): string;
setSessionId(sessionId: string): void;
- setMode(mode: "plan" | "agent" | "team"): void;
+ setMode(mode: "agent.plan" | "agent.fast" | "code.plan" | "code.normal" | "team"): void;
getEntries(): HistoryItem[];
setEntries(entries: HistoryItem[]): void;
setStreamingState(state: StreamingState): void;
@@ -666,8 +666,14 @@ export function handleIncomingFrame(delegate: AppEventDelegate, frame: EventFram
case "session.updated": {
const mode = typeof payload.mode === "string" ? payload.mode : "";
- if (mode === "plan" || mode === "agent" || mode === "team") {
- delegate.setMode(mode as "plan" | "agent" | "team");
+ if (
+ mode === "agent.plan" ||
+ mode === "agent.fast" ||
+ mode === "code.plan" ||
+ mode === "code.normal" ||
+ mode === "team"
+ ) {
+ delegate.setMode(mode as "agent.plan" | "agent.fast" | "code.plan" | "code.normal" | "team");
}
return true;
}
diff --git a/jiuwenclaw/cli/src/ui/screen-layout.ts b/jiuwenclaw/cli/src/ui/screen-layout.ts
index 8435281573..535b13c6c5 100644
--- a/jiuwenclaw/cli/src/ui/screen-layout.ts
+++ b/jiuwenclaw/cli/src/ui/screen-layout.ts
@@ -94,7 +94,7 @@ function buildStatusLines(
const left: string[] = [];
const connectionLabel = connectionStatusLabel(snapshot.connectionStatus);
if (connectionLabel) left.push(connectionLabel);
- if (snapshot.mode !== "plan") left.push(`mode:${snapshot.mode}`);
+ if (snapshot.mode !== "agent.plan") left.push(`mode:${snapshot.mode}`);
if (snapshot.transcriptFoldMode !== "none") left.push(`fold:${snapshot.transcriptFoldMode}`);
const teamWorking =
snapshot.mode === "team" &&
diff --git a/jiuwenclaw/gateway/message_handler.py b/jiuwenclaw/gateway/message_handler.py
index 20e93a2a2a..034f4f666c 100644
--- a/jiuwenclaw/gateway/message_handler.py
+++ b/jiuwenclaw/gateway/message_handler.py
@@ -43,15 +43,17 @@ _KNOWN_JIUWENCLAW_SESSION_PREFIXES = (
class ChannelMode(str, Enum):
- PLAN = "plan"
- AGENT = "agent"
+ AGENT_PLAN = "agent.plan"
+ AGENT_FAST = "agent.fast"
+ CODE_PLAN = "code.plan"
+ CODE_NORMAL = "code.normal"
TEAM = "team"
@dataclass
class ChannelControlState:
session_id: str | None = None
- mode: ChannelMode = ChannelMode.PLAN
+ mode: ChannelMode = ChannelMode.AGENT_PLAN
@dataclass
@@ -118,7 +120,7 @@ class MessageHandler(ABC):
self._stream_tasks: dict[str, asyncio.Task] = {} # request_id -> task
self._stream_sessions: dict[str, str | None] = {} # request_id -> session_id
self._stream_metadata: dict[str, dict[str, Any] | None] = {} # request_id -> request metadata
- self._stream_modes: dict[str, str] = {} # request_id -> mode (plan/agent/team)
+ self._stream_modes: dict[str, str] = {} # request_id -> mode
self._pending_evolution_approval: dict[str, str] = {} # session_id -> approval_request_id
self._queued_supplement_input: dict[str, str] = {} # session_id -> queued_new_input
self._session_evolution_in_progress: set[str] = set()
@@ -203,13 +205,15 @@ class MessageHandler(ABC):
# 若未在 config 中指定默认 session_id,为该 channel 生成一个带时间戳的新 session_id
if not sid:
sid = self._generate_channel_session_id(channel_id)
- mode_raw = str(ch_cfg.get("default_mode") or "plan").strip().lower()
- if mode_raw in ("agent", "fast"):
- mode = ChannelMode.AGENT
- elif mode_raw == "team":
- mode = ChannelMode.TEAM
- else:
- mode = ChannelMode.PLAN
+ mode_raw = str(ch_cfg.get("default_mode") or "agent.plan").strip().lower()
+ mode_map = {
+ "agent.plan": ChannelMode.AGENT_PLAN,
+ "agent.fast": ChannelMode.AGENT_FAST,
+ "code.plan": ChannelMode.CODE_PLAN,
+ "code.normal": ChannelMode.CODE_NORMAL,
+ "team": ChannelMode.TEAM,
+ }
+ mode = mode_map.get(mode_raw, ChannelMode.AGENT_PLAN)
return ChannelControlState(session_id=sid, mode=mode)
def _get_channel_state_key(self, channel_id: str, conversation_id: str | None) -> str:
@@ -419,8 +423,7 @@ class MessageHandler(ABC):
@staticmethod
def _build_mode_change_notice_text(mode_label: str) -> str:
- display = "fast" if mode_label == ChannelMode.AGENT.value else mode_label
- return f"[收到 CLI 指令], mode 已变更为 {display}"
+ return f"[收到 CLI 指令], mode 已变更为 {mode_label}"
def _handle_channel_control(self, msg: "Message") -> bool:
r"""处理 \new_session / \mode / \skills 指令.
@@ -496,7 +499,15 @@ class MessageHandler(ABC):
if parsed.action is ParsedControlAction.MODE_OK:
mode_str = parsed.mode_subcommand or ""
- if mode_str not in ("plan", "fast", "team"):
+ if mode_str not in (
+ "agent",
+ "code",
+ "team",
+ "agent.plan",
+ "agent.fast",
+ "code.plan",
+ "code.normal",
+ ):
asyncio.create_task(
self._send_channel_notice(
user_infos,
@@ -508,12 +519,71 @@ class MessageHandler(ABC):
return True
old_mode = state.mode
old_sid = state.session_id
- if mode_str == "fast":
- state.mode = ChannelMode.AGENT
+ if mode_str == "agent":
+ state.mode = ChannelMode.AGENT_PLAN
+ elif mode_str == "code":
+ state.mode = ChannelMode.CODE_NORMAL
elif mode_str == "team":
state.mode = ChannelMode.TEAM
+ elif mode_str == "agent.plan":
+ state.mode = ChannelMode.AGENT_PLAN
+ elif mode_str == "agent.fast":
+ state.mode = ChannelMode.AGENT_FAST
+ elif mode_str == "code.plan":
+ state.mode = ChannelMode.CODE_PLAN
+ elif mode_str == "code.normal":
+ state.mode = ChannelMode.CODE_NORMAL
+ new_label = state.mode.value
+ if old_mode != state.mode:
+ asyncio.create_task(
+ self._mode_change_cancel_and_notice(
+ ModeChangeCancelParams(
+ user_infos=user_infos,
+ channel_id=ch,
+ reply_session_id=msg.session_id,
+ old_sid=old_sid,
+ new_mode_label=new_label,
+ ),
+ msg,
+ )
+ )
else:
- state.mode = ChannelMode.PLAN
+ asyncio.create_task(
+ self._send_channel_notice(
+ user_infos,
+ ch,
+ msg.session_id,
+ self._build_mode_change_notice_text(new_label),
+ )
+ )
+ return True
+ if parsed.action is ParsedControlAction.SWITCH_OK:
+ switch_str = parsed.switch_subcommand or ""
+ target_mode: ChannelMode | None = None
+ if switch_str == "plan":
+ if state.mode in (ChannelMode.AGENT_PLAN, ChannelMode.AGENT_FAST):
+ target_mode = ChannelMode.AGENT_PLAN
+ elif state.mode in (ChannelMode.CODE_PLAN, ChannelMode.CODE_NORMAL):
+ target_mode = ChannelMode.CODE_PLAN
+ elif switch_str == "fast":
+ if state.mode in (ChannelMode.AGENT_PLAN, ChannelMode.AGENT_FAST):
+ target_mode = ChannelMode.AGENT_FAST
+ elif switch_str == "normal":
+ if state.mode in (ChannelMode.CODE_PLAN, ChannelMode.CODE_NORMAL):
+ target_mode = ChannelMode.CODE_NORMAL
+ if target_mode is None:
+ asyncio.create_task(
+ self._send_channel_notice(
+ user_infos,
+ ch,
+ msg.session_id,
+ "非法指令",
+ )
+ )
+ return True
+ old_mode = state.mode
+ old_sid = state.session_id
+ state.mode = target_mode
new_label = state.mode.value
if old_mode != state.mode:
asyncio.create_task(
@@ -538,7 +608,7 @@ class MessageHandler(ABC):
)
)
return True
- if parsed.action is ParsedControlAction.MODE_BAD:
+ if parsed.action in (ParsedControlAction.MODE_BAD, ParsedControlAction.SWITCH_BAD):
asyncio.create_task(
self._send_channel_notice(
user_infos,
diff --git a/jiuwenclaw/gateway/slash_command.py b/jiuwenclaw/gateway/slash_command.py
index cf27ef90eb..ab7a331971 100644
--- a/jiuwenclaw/gateway/slash_command.py
+++ b/jiuwenclaw/gateway/slash_command.py
@@ -22,6 +22,7 @@ class GatewaySlashCommand(str, Enum):
NEW_SESSION = "/new_session"
MODE = "/mode"
+ SWITCH = "/switch"
SKILLS = "/skills"
SKILLS_LIST = "/skills list"
@@ -29,17 +30,39 @@ class GatewaySlashCommand(str, Enum):
class ModeSubcommand(str, Enum):
"""`/mode` 支持的子命令。"""
- PLAN = "plan"
- FAST = "fast"
+ AGENT = "agent"
+ CODE = "code"
TEAM = "team"
+ AGENT_PLAN = "agent.plan"
+ AGENT_FAST = "agent.fast"
+ CODE_PLAN = "code.plan"
+ CODE_NORMAL = "code.normal"
_VALID_MODE_LINES: frozenset[str] = frozenset(
f"{GatewaySlashCommand.MODE.value} {sub.value}" for sub in ModeSubcommand
)
+
+class SwitchSubcommand(str, Enum):
+ """`/switch` 支持的子命令。"""
+
+ PLAN = "plan"
+ FAST = "fast"
+ NORMAL = "normal"
+
+
+_VALID_SWITCH_LINES: frozenset[str] = frozenset(
+ f"{GatewaySlashCommand.SWITCH.value} {sub.value}" for sub in SwitchSubcommand
+)
+
CONTROL_MESSAGE_TEXTS: frozenset[str] = frozenset(
- {GatewaySlashCommand.NEW_SESSION.value, *_VALID_MODE_LINES, GatewaySlashCommand.SKILLS_LIST.value}
+ {
+ GatewaySlashCommand.NEW_SESSION.value,
+ *_VALID_MODE_LINES,
+ *_VALID_SWITCH_LINES,
+ GatewaySlashCommand.SKILLS_LIST.value,
+ }
)
@@ -51,6 +74,8 @@ class ParsedControlAction(str, Enum):
NEW_SESSION_BAD = "new_session_bad"
MODE_OK = "mode_ok"
MODE_BAD = "mode_bad"
+ SWITCH_OK = "switch_ok"
+ SWITCH_BAD = "switch_bad"
SKILLS_OK = "skills_ok"
@@ -60,15 +85,18 @@ class ParsedChannelControl:
action: ParsedControlAction
mode_subcommand: str | None = None
- """mode_ok 时为 plan|fast|team 之一。"""
+ """mode_ok 时为 agent|code|team|agent.plan|agent.fast|code.plan|code.normal 之一。"""
+ switch_subcommand: str | None = None
+ """switch_ok 时为 plan|fast|normal 之一。"""
def parse_channel_control_text(text: str) -> ParsedChannelControl:
- """解析单条用户文本是否为 /new_session、/mode、/skills list 控制指令。
+ """解析单条用户文本是否为 /new_session、/mode、/switch、/skills list 控制指令。
- 含换行则视为非控制(与原 _handle_channel_control 一致)。
- /new_session 仅整行精确匹配为合法;带后缀为非法但仍为控制指令。
- - /mode 仅白名单整行合法;其它以 /mode 开头且单行非法。
+ - /mode 仅白名单整行合法;支持 agent|code|team 及四个直达模式值;其它以 /mode 开头且单行非法。
+ - /switch 仅白名单整行合法;其它以 /switch 开头且单行非法。
- /skills list 仅整行精确匹配(/skills 本身不再触发)。
"""
if not text:
@@ -87,15 +115,21 @@ def parse_channel_control_text(text: str) -> ParsedChannelControl:
parts = t.split()
sub = parts[1] if len(parts) >= 2 else ""
return ParsedChannelControl(ParsedControlAction.MODE_OK, mode_subcommand=sub)
+ if t in _VALID_SWITCH_LINES:
+ parts = t.split()
+ sub = parts[1] if len(parts) >= 2 else ""
+ return ParsedChannelControl(ParsedControlAction.SWITCH_OK, switch_subcommand=sub)
if t.startswith(GatewaySlashCommand.MODE.value):
return ParsedChannelControl(ParsedControlAction.MODE_BAD)
+ if t.startswith(GatewaySlashCommand.SWITCH.value):
+ return ParsedChannelControl(ParsedControlAction.SWITCH_BAD)
return ParsedChannelControl(ParsedControlAction.NONE)
def is_control_like_for_im_batching(text: str) -> bool:
"""飞书/企微等:控制类消息不走合并窗口(与历史行为一致并补全 mode 变体与 /skills list)。
- 单条文本、且为已知控制句、或以 /mode / /new_session 为前缀(含非法变体)时返回 True。
+ 单条文本、且为已知控制句、或以 /mode / /switch / /new_session 为前缀(含非法变体)时返回 True。
"""
if not text:
return False
@@ -109,6 +143,10 @@ def is_control_like_for_im_batching(text: str) -> bool:
return True
if t.startswith(f"{GatewaySlashCommand.MODE.value} "):
return True
+ if t.startswith(f"{GatewaySlashCommand.SWITCH.value} "):
+ return True
+ if t.startswith(GatewaySlashCommand.SWITCH.value):
+ return True
if t.startswith(GatewaySlashCommand.NEW_SESSION.value):
return True
return False
@@ -140,10 +178,17 @@ FIRST_BATCH_REGISTRY: tuple[SlashCommandEntry, ...] = (
),
SlashCommandEntry(
id="mode",
- canonical_text=f"{GatewaySlashCommand.MODE.value} plan|fast|team",
+ canonical_text=f"{GatewaySlashCommand.MODE.value} agent|code|team|agent.plan|agent.fast|code.plan|code.normal",
+ scope="gateway",
+ req_method=None,
+ notes="受控通道切换模式:一级模式 agent/code/team(映射到默认子模式)或直达 agent.plan/agent.fast/code.plan/code.normal;写入 params.mode。",
+ ),
+ SlashCommandEntry(
+ id="switch",
+ canonical_text=f"{GatewaySlashCommand.SWITCH.value} plan|fast|normal",
scope="gateway",
req_method=None,
- notes="受控通道切换 ChannelMode;写入 params.mode。",
+ notes="受控通道切换二级模式:agent 下 plan/fast,code 下 plan/normal。",
),
SlashCommandEntry(
id="skills",
@@ -194,3 +239,5 @@ def format_skills_list_for_notice(payload: dict[str, Any] | None, *, max_items:
# 供单测校验与外部只读引用(与 _VALID_MODE_LINES 相同)
VALID_MODE_LINES: frozenset[str] = _VALID_MODE_LINES
VALID_MODE_SUBCOMMANDS: tuple[str, ...] = tuple(sub.value for sub in ModeSubcommand)
+VALID_SWITCH_LINES: frozenset[str] = _VALID_SWITCH_LINES
+VALID_SWITCH_SUBCOMMANDS: tuple[str, ...] = tuple(sub.value for sub in SwitchSubcommand)
diff --git a/jiuwenclaw/resources/agent/jiuwenclaw_workspace/agent-data.json b/jiuwenclaw/resources/agent/jiuwenclaw_workspace/agent-data.json
index 558d7e5a4c..70e9a63b38 100644
--- a/jiuwenclaw/resources/agent/jiuwenclaw_workspace/agent-data.json
+++ b/jiuwenclaw/resources/agent/jiuwenclaw_workspace/agent-data.json
@@ -38,100 +38,107 @@
"isMarkdown": true
}
],
- "jiuwenclaw_workspace/skills/cross-channel-history-retrieval": [
- {
- "name": "SKILL.md",
- "path": "agent/jiuwenclaw_workspace/skills/cross-channel-history-retrieval/SKILL.md",
- "isMarkdown": true
- }
- ],
- "jiuwenclaw_workspace/skills/cross-channel-history-retrieval/scripts": [
- {
- "name": "search_history.py",
- "path": "agent/jiuwenclaw_workspace/skills/cross-channel-history-retrieval/scripts/search_history.py",
- "isMarkdown": false
- }
- ],
- "jiuwenclaw_workspace/skills/daily-report": [
+ "jiuwenclaw_workspace/skills/advanced-daily-report": [
{
"name": "AI_ANALYSIS_TASKS.md",
- "path": "agent/jiuwenclaw_workspace/skills/daily-report/AI_ANALYSIS_TASKS.md",
+ "path": "agent/jiuwenclaw_workspace/skills/advanced-daily-report/AI_ANALYSIS_TASKS.md",
"isMarkdown": true
},
{
"name": "report_helper.py",
- "path": "agent/jiuwenclaw_workspace/skills/daily-report/report_helper.py",
+ "path": "agent/jiuwenclaw_workspace/skills/advanced-daily-report/report_helper.py",
"isMarkdown": false
},
{
"name": "run_report.py",
- "path": "agent/jiuwenclaw_workspace/skills/daily-report/run_report.py",
+ "path": "agent/jiuwenclaw_workspace/skills/advanced-daily-report/run_report.py",
"isMarkdown": false
},
{
"name": "SKILL.md",
- "path": "agent/jiuwenclaw_workspace/skills/daily-report/SKILL.md",
+ "path": "agent/jiuwenclaw_workspace/skills/advanced-daily-report/SKILL.md",
"isMarkdown": true
}
],
- "jiuwenclaw_workspace/skills/daily-report/analyzers": [
+ "jiuwenclaw_workspace/skills/advanced-daily-report/analyzers": [
{
"name": "__init__.py",
- "path": "agent/jiuwenclaw_workspace/skills/daily-report/analyzers/__init__.py",
+ "path": "agent/jiuwenclaw_workspace/skills/advanced-daily-report/analyzers/__init__.py",
"isMarkdown": false
},
{
"name": "ai_analyzer.py",
- "path": "agent/jiuwenclaw_workspace/skills/daily-report/analyzers/ai_analyzer.py",
+ "path": "agent/jiuwenclaw_workspace/skills/advanced-daily-report/analyzers/ai_analyzer.py",
"isMarkdown": false
},
{
"name": "work_analyzer.py",
- "path": "agent/jiuwenclaw_workspace/skills/daily-report/analyzers/work_analyzer.py",
+ "path": "agent/jiuwenclaw_workspace/skills/advanced-daily-report/analyzers/work_analyzer.py",
"isMarkdown": false
}
],
- "jiuwenclaw_workspace/skills/daily-report/collectors": [
+ "jiuwenclaw_workspace/skills/advanced-daily-report/collectors": [
{
"name": "__init__.py",
- "path": "agent/jiuwenclaw_workspace/skills/daily-report/collectors/__init__.py",
+ "path": "agent/jiuwenclaw_workspace/skills/advanced-daily-report/collectors/__init__.py",
"isMarkdown": false
},
{
"name": "aggregator.py",
- "path": "agent/jiuwenclaw_workspace/skills/daily-report/collectors/aggregator.py",
+ "path": "agent/jiuwenclaw_workspace/skills/advanced-daily-report/collectors/aggregator.py",
"isMarkdown": false
},
{
"name": "email_collector.py",
- "path": "agent/jiuwenclaw_workspace/skills/daily-report/collectors/email_collector.py",
+ "path": "agent/jiuwenclaw_workspace/skills/advanced-daily-report/collectors/email_collector.py",
"isMarkdown": false
},
{
"name": "git_collector.py",
- "path": "agent/jiuwenclaw_workspace/skills/daily-report/collectors/git_collector.py",
+ "path": "agent/jiuwenclaw_workspace/skills/advanced-daily-report/collectors/git_collector.py",
"isMarkdown": false
},
{
"name": "memory_collector.py",
- "path": "agent/jiuwenclaw_workspace/skills/daily-report/collectors/memory_collector.py",
+ "path": "agent/jiuwenclaw_workspace/skills/advanced-daily-report/collectors/memory_collector.py",
"isMarkdown": false
},
{
"name": "todo_collector.py",
- "path": "agent/jiuwenclaw_workspace/skills/daily-report/collectors/todo_collector.py",
+ "path": "agent/jiuwenclaw_workspace/skills/advanced-daily-report/collectors/todo_collector.py",
"isMarkdown": false
}
],
- "jiuwenclaw_workspace/skills/daily-report/generators": [
+ "jiuwenclaw_workspace/skills/advanced-daily-report/generators": [
{
"name": "__init__.py",
- "path": "agent/jiuwenclaw_workspace/skills/daily-report/generators/__init__.py",
+ "path": "agent/jiuwenclaw_workspace/skills/advanced-daily-report/generators/__init__.py",
"isMarkdown": false
},
{
"name": "report_generator.py",
- "path": "agent/jiuwenclaw_workspace/skills/daily-report/generators/report_generator.py",
+ "path": "agent/jiuwenclaw_workspace/skills/advanced-daily-report/generators/report_generator.py",
+ "isMarkdown": false
+ }
+ ],
+ "jiuwenclaw_workspace/skills/akg-agents": [
+ {
+ "name": "SKILL.md",
+ "path": "agent/jiuwenclaw_workspace/skills/akg-agents/SKILL.md",
+ "isMarkdown": true
+ }
+ ],
+ "jiuwenclaw_workspace/skills/cross-channel-history-retrieval": [
+ {
+ "name": "SKILL.md",
+ "path": "agent/jiuwenclaw_workspace/skills/cross-channel-history-retrieval/SKILL.md",
+ "isMarkdown": true
+ }
+ ],
+ "jiuwenclaw_workspace/skills/cross-channel-history-retrieval/scripts": [
+ {
+ "name": "search_history.py",
+ "path": "agent/jiuwenclaw_workspace/skills/cross-channel-history-retrieval/scripts/search_history.py",
"isMarkdown": false
}
],
@@ -389,5 +396,12 @@
"path": "agent/jiuwenclaw_workspace/skills/skill-gen-4-enterprise-doc/scripts/skill_gen/url_ingest/wechat_article.py",
"isMarkdown": false
}
+ ],
+ "workspace": [
+ {
+ "name": "agent-data.json",
+ "path": "agent/workspace/agent-data.json",
+ "isMarkdown": false
+ }
]
-}
+}
\ No newline at end of file
diff --git a/jiuwenclaw/resources/config.yaml b/jiuwenclaw/resources/config.yaml
index 26f30787ed..0b91dec431 100644
--- a/jiuwenclaw/resources/config.yaml
+++ b/jiuwenclaw/resources/config.yaml
@@ -527,9 +527,9 @@ team:
connect_timeout: 300
modes:
- # 一级模式 claw / code
- claw:
- # claw 模式支持 性能/规划/集群
+ # 一级模式 agent / code / team
+ agent:
+ # agent 模式支持 性能/规划/集群
fast:
memory:
enabled: true
diff --git a/jiuwenclaw/schema/message.py b/jiuwenclaw/schema/message.py
index 347d3e6db4..8936d00411 100644
--- a/jiuwenclaw/schema/message.py
+++ b/jiuwenclaw/schema/message.py
@@ -128,10 +128,32 @@ class EventType(Enum):
class Mode(Enum):
- AGENT = "agent"
- PLAN = "plan"
+ AGENT_PLAN = "agent.plan"
+ AGENT_FAST = "agent.fast"
+ CODE_PLAN = "code.plan"
+ CODE_NORMAL = "code.normal"
TEAM = "team"
+ @classmethod
+ def from_raw(cls, raw_mode: Any, default: "Mode | None" = None) -> "Mode":
+ """解析 mode,仅接受新值(agent.plan/agent.fast/code.plan/code.normal/team)。"""
+ fallback = default or cls.AGENT_PLAN
+ if isinstance(raw_mode, Mode):
+ return raw_mode
+ if not isinstance(raw_mode, str):
+ return fallback
+ normalized = raw_mode.strip().lower()
+ if not normalized:
+ return fallback
+ try:
+ return cls(normalized)
+ except ValueError:
+ return fallback
+
+ def to_runtime_mode(self) -> str:
+ """输出新 mode 值本身。"""
+ return self.value
+
@dataclass
class Message:
@@ -150,7 +172,7 @@ class Message:
payload: dict | None = None
req_method: ReqMethod | None = None
event_type: EventType | None = None
- mode: Mode = Mode.PLAN
+ mode: Mode = Mode.AGENT_PLAN
is_stream: bool = False
stream_seq: int | None = None
stream_id: str | None = None
diff --git a/jiuwenclaw/web/src/App.tsx b/jiuwenclaw/web/src/App.tsx
index c767024566..0e58beece9 100644
--- a/jiuwenclaw/web/src/App.tsx
+++ b/jiuwenclaw/web/src/App.tsx
@@ -985,7 +985,7 @@ function AppContent() {
</div>
{/* Status Bar - 只在非集群模式下显示 */}
- {mode !== 'agentteam' && (
+ {mode !== 'team' && (
<StatusBar
onPause={handlePause}
onCancel={handleCancel}
diff --git a/jiuwenclaw/web/src/components/ChatPanel/InputArea.tsx b/jiuwenclaw/web/src/components/ChatPanel/InputArea.tsx
index 21a584d18a..3f8b6f2ef5 100644
--- a/jiuwenclaw/web/src/components/ChatPanel/InputArea.tsx
+++ b/jiuwenclaw/web/src/components/ChatPanel/InputArea.tsx
@@ -33,21 +33,21 @@ export function InputArea({
const { isPaused, taskQueue, addToTaskQueue, removeFromTaskQueue, inputValue, setInputValue, messages } = useChatStore();
const { mode } = useSessionStore();
const isInterruptible = isProcessing || isPaused;
- const isAgentMode = mode === 'agent';
- const isTeamMode = mode === 'agentteam';
+ const isAgentMode = mode === 'agent.fast';
+ const isTeamMode = mode === 'team';
const hasHistoryMessages = messages.length > 0;
const modes: Array<{ value: AgentMode; label: string; icon: JSX.Element }> = [
- { value: 'plan', label: t('chat.modePlan'), icon: (
+ { value: 'agent.plan', label: t('chat.modePlan'), icon: (
<svg className="w-4 h-4" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth={2}>
<path strokeLinecap="round" strokeLinejoin="round" d="M9 12h3.75M9 15h3.75M9 18h3.75m3 .75H18a2.25 2.25 0 002.25-2.25V6.108c0-1.135-.845-2.098-1.976-2.192a48.424 48.424 0 00-1.123-.08m-5.801 0c-.065.21-.1.433-.1.664 0 .414.336.75.75.75h4.5a.75.75 0 00.75-.75 2.25 2.25 0 00-.1-.664m-5.8 0A2.251 2.251 0 0113.5 2.25H15c1.012 0 1.867.668 2.15 1.586m-5.8 0c-.376.023-.75.05-1.124.08C9.095 4.01 8.25 4.973 8.25 6.108V8.25m0 0H4.875c-.621 0-1.125.504-1.125 1.125v11.25c0 .621.504 1.125 1.125 1.125h9.75c.621 0 1.125-.504 1.125-1.125V9.375c0-.621-.504-1.125-1.125-1.125H8.25zM6.75 12h.008v.008H6.75V12zm0 3h.008v.008H6.75V15zm0 3h.008v.008H6.75V18z" />
</svg>
)},
- { value: 'agent', label: t('chat.modeAgent'), icon: (
+ { value: 'agent.fast', label: t('chat.modeAgent'), icon: (
<svg className="w-4 h-4" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth={2}>
<path strokeLinecap="round" strokeLinejoin="round" d="M11.42 15.17L17.25 21A2.652 2.652 0 0021 17.25l-5.877-5.877M11.42 15.17l2.496-3.03c.317-.384.74-.626 1.208-.766M11.42 15.17l-4.655 5.653a2.548 2.548 0 11-3.586-3.586l6.837-5.63m5.108-.233c.55-.164 1.163-.188 1.743-.14a4.5 4.5 0 004.486-6.336l-3.276 3.277a3.004 3.004 0 01-2.25-2.25l3.276-3.276a4.5 4.5 0 00-6.336 4.486c.091 1.076-.071 2.264-.904 2.95l-.102.085m-1.745 1.437L5.909 7.5H4.5L2.25 3.75l1.5-1.5L7.5 4.5v1.409l4.26 4.26m-1.745 1.437l1.745-1.437m6.615 8.206L15.75 15.75M4.867 19.125h.008v.008h-.008v-.008z" />
</svg>
)},
- { value: 'agentteam', label: t('chat.modeAgentTeam'), icon: (
+ { value: 'team', label: t('chat.modeAgentTeam'), icon: (
<svg className="w-4 h-4" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth={2}>
<path strokeLinecap="round" strokeLinejoin="round" d="M17.982 18.725A7.488 7.488 0 0012 15.75a7.488 7.488 0 00-5.982 2.975m11.963 0a9 9 0 10-11.963 0m11.963 0A8.966 8.966 0 0112 21a8.966 8.966 0 01-5.982-2.275M15 9.75a3 3 0 11-6 0 3 3 0 016 0zm6 3a2.25 2.25 0 11-4.5 0 2.25 2.25 0 014.5 0zm-13.5 0a2.25 2.25 0 11-4.5 0 2.25 2.25 0 014.5 0z" />
</svg>
diff --git a/jiuwenclaw/web/src/components/ToolPanel/index.tsx b/jiuwenclaw/web/src/components/ToolPanel/index.tsx
index dd75f8677c..1b1e03abe2 100644
--- a/jiuwenclaw/web/src/components/ToolPanel/index.tsx
+++ b/jiuwenclaw/web/src/components/ToolPanel/index.tsx
@@ -120,7 +120,7 @@ export function ToolPanel() {
>
<div className="h-full bg-panel flex flex-col overflow-hidden">
{/* 任务事件日志 */}
- {mode === 'agentteam' ? (
+ {mode === 'team' ? (
<div className="flex-1 overflow-y-auto mb-4">
<div className="bg-card rounded-lg border border-border overflow-hidden h-full">
<TeamTaskEvents events={teamTaskEvents} />
@@ -136,7 +136,7 @@ export function ToolPanel() {
)}
{/* 团队区域 */}
- {mode === 'agentteam' && (
+ {mode === 'team' && (
<div className="flex-1 overflow-y-auto">
<div className="bg-card rounded-lg border border-border overflow-hidden h-full">
<TeamArea
diff --git a/jiuwenclaw/web/src/hooks/useWebSocket.ts b/jiuwenclaw/web/src/hooks/useWebSocket.ts
index e37bc595a6..c67aa62486 100644
--- a/jiuwenclaw/web/src/hooks/useWebSocket.ts
+++ b/jiuwenclaw/web/src/hooks/useWebSocket.ts
@@ -81,9 +81,11 @@ interface UseWebSocketReturn {
}
function normalizeAgentMode(rawMode: unknown): AgentMode {
- if (typeof rawMode !== 'string') return 'plan';
+ if (typeof rawMode !== 'string') return 'agent.plan';
const normalized = rawMode.trim().toLowerCase();
- return normalized === 'agent' ? 'agent' : normalized === 'agentteam' ? 'agentteam' : 'plan';
+ if (normalized === 'agent.fast') return 'agent.fast';
+ if (normalized === 'team') return 'team';
+ return 'agent.plan';
}
const EVENT_DEDUP_WINDOW_MS = 1500;
@@ -275,12 +277,11 @@ export function useWebSocket(options: UseWebSocketOptions): UseWebSocketReturn {
// 正常调用接口
const currentMode = useSessionStore.getState().mode;
- const sendMode = currentMode === 'agentteam' ? 'team' : currentMode;
try {
await request('chat.send', {
session_id: sessionId,
content,
- mode: sendMode,
+ mode: currentMode,
});
} catch (error) {
const webError = error as WebError;
@@ -502,7 +503,7 @@ export function useWebSocket(options: UseWebSocketOptions): UseWebSocketReturn {
const content = typeof payload.content === 'string' ? payload.content : '';
// team 模式下,累积 chat.delta 内容
- if (currentMode === 'agentteam' && content) {
+ if (currentMode === 'team' && content) {
setThinking(false);
const { messages } = useChatStore.getState();
@@ -554,7 +555,7 @@ export function useWebSocket(options: UseWebSocketOptions): UseWebSocketReturn {
const content = normalizeFinalContent(payload);
// team 模式下,将 chat.final 作为 team_leader 消息处理
- if (currentMode === 'agentteam' && content) {
+ if (currentMode === 'team' && content) {
setThinking(false);
const { messages } = useChatStore.getState();
@@ -759,7 +760,7 @@ export function useWebSocket(options: UseWebSocketOptions): UseWebSocketReturn {
// 检查是否有等待的任务队列
const currentMode = useSessionStore.getState().mode;
const { taskQueue } = useChatStore.getState();
- if (currentMode === 'agent' && taskQueue.length > 0) {
+ if (currentMode === 'agent.fast' && taskQueue.length > 0) {
// 智能执行模式下,自动处理队列中的下一个任务
const nextTask = taskQueue[0];
if (nextTask && activeSessionIdRef.current && sendMessageRef.current) {
diff --git a/jiuwenclaw/web/src/stores/sessionStore.ts b/jiuwenclaw/web/src/stores/sessionStore.ts
index fbb68ec17b..f07d8bafc4 100644
--- a/jiuwenclaw/web/src/stores/sessionStore.ts
+++ b/jiuwenclaw/web/src/stores/sessionStore.ts
@@ -48,12 +48,14 @@ function saveModeToStorage(mode: AgentMode) {
}
}
-const DEFAULT_MODE: AgentMode = 'plan';
+const DEFAULT_MODE: AgentMode = 'agent.plan';
function normalizeAgentMode(mode: unknown): AgentMode {
if (typeof mode !== 'string') return DEFAULT_MODE;
const normalized = mode.trim().toLowerCase();
- return normalized === 'agent' ? 'agent' : normalized === 'agentteam' ? 'agentteam' : 'plan';
+ if (normalized === 'agent.fast') return 'agent.fast';
+ if (normalized === 'team') return 'team';
+ return 'agent.plan';
}
function normalizeSession(session: Session): Session {
diff --git a/jiuwenclaw/web/src/types/index.ts b/jiuwenclaw/web/src/types/index.ts
index b3459c4443..ed30523d2b 100644
--- a/jiuwenclaw/web/src/types/index.ts
+++ b/jiuwenclaw/web/src/types/index.ts
@@ -26,7 +26,7 @@ export interface Session {
last_message_at?: number; // 最近对话时间(Unix时间戳)
}
-export type AgentMode = 'agent' | 'plan' | 'agentteam';
+export type AgentMode = 'agent.fast' | 'agent.plan' | 'team';
export type SessionStatus = 'active' | 'paused' | 'completed' | 'interrupted';
export interface OffloadFileListResponse {
diff --git a/tests/system_tests/test_cli_channel_ws.py b/tests/system_tests/test_cli_channel_ws.py
index b188903dd0..a7a16815bc 100644
--- a/tests/system_tests/test_cli_channel_ws.py
+++ b/tests/system_tests/test_cli_channel_ws.py
@@ -152,7 +152,7 @@ async def test_cli_route_system_roundtrip(temp_home: Path, monkeypatch: pytest.M
"params": {
"session_id": "sess_test",
"content": "hello cli",
- "mode": "plan",
+ "mode": "agent.plan",
},
}
await ws.send(json.dumps(req_chat, ensure_ascii=False))
diff --git a/tests/system_tests/test_system_prompt_live_capture.py b/tests/system_tests/test_system_prompt_live_capture.py
index 06b1f00edc..63a06c0410 100644
--- a/tests/system_tests/test_system_prompt_live_capture.py
+++ b/tests/system_tests/test_system_prompt_live_capture.py
@@ -305,13 +305,13 @@ async def test_live_capture_system_prompt(prompt_capture: PromptCapture):
"""Live-capture the full system prompt for explicit auto_list mode."""
result, first_system_prompt = await _run_live_capture(
prompt_capture,
- mode="plan",
+ mode="agent.plan",
skill_mode="auto_list",
output_stem="system_prompt_live_capture",
)
_assert_common_prompt_structure(first_system_prompt)
- assert result["request"]["mode"] == "plan"
+ assert result["request"]["mode"] == "agent.plan"
assert result["request"]["skill_mode"] == "auto_list"
assert "- list_skill: 列出可用技能" in first_system_prompt
assert "需要时先调用 list_skill 查看可用技能" in first_system_prompt
@@ -333,13 +333,13 @@ async def test_live_capture_system_prompt_skill_mode_all(prompt_capture: PromptC
"""Live-capture the full system prompt for explicit all mode."""
result, first_system_prompt = await _run_live_capture(
prompt_capture,
- mode="plan",
+ mode="agent.plan",
skill_mode="all",
output_stem="system_prompt_live_capture_skill_mode_all",
)
_assert_common_prompt_structure(first_system_prompt)
- assert result["request"]["mode"] == "plan"
+ assert result["request"]["mode"] == "agent.plan"
assert result["request"]["skill_mode"] == "all"
assert "- list_skill: 列出可用技能" not in first_system_prompt
assert "需要时先调用 list_skill 查看可用技能" not in first_system_prompt
diff --git a/tests/unit/deep_agent/test_browser_subagent_integration.py b/tests/unit/deep_agent/test_browser_subagent_integration.py
index 5bc601883a..4d547dfdcd 100644
--- a/tests/unit/deep_agent/test_browser_subagent_integration.py
+++ b/tests/unit/deep_agent/test_browser_subagent_integration.py
@@ -341,7 +341,7 @@ async def test_interface_deep_browser_subagent_task_tool_chain(
session_id="sess-browser-1",
params={
"query": "Use the browser agent to inspect https://example.com.",
- "mode": "agent",
+ "mode": "agent.fast",
},
)
response = await adapter.process_message_impl(
diff --git a/tests/unit_tests/agentserver/test_agentserver_acp.py b/tests/unit_tests/agentserver/test_agentserver_acp.py
index a30c3d3c61..2174995971 100644
--- a/tests/unit_tests/agentserver/test_agentserver_acp.py
+++ b/tests/unit_tests/agentserver/test_agentserver_acp.py
@@ -65,7 +65,7 @@ class AgentWebSocketServerHarness(agent_ws_server_module.AgentWebSocketServer):
class DeepAdapterHarness(interface_deep_module.JiuWenClawDeepAdapter):
def build_context_engineering_rail_for_test(self, config):
- return _build_context_engineering_rail(config, "plan")
+ return _build_context_engineering_rail(config, "agent.plan")
def fake_encode_agent_response_for_wire(resp, response_id):
diff --git a/tests/unit_tests/agentserver/test_system_prompt_restructure.py b/tests/unit_tests/agentserver/test_system_prompt_restructure.py
index 0664837fcc..91f9f95397 100644
--- a/tests/unit_tests/agentserver/test_system_prompt_restructure.py
+++ b/tests/unit_tests/agentserver/test_system_prompt_restructure.py
@@ -26,7 +26,7 @@ class _TestableJiuWenClawDeepAdapter(JiuWenClawDeepAdapter):
def test_build_identity_prompt_contains_identity_section_only():
- prompt = build_identity_prompt(mode="agent", language="zh", channel="web")
+ prompt = build_identity_prompt(mode="agent.fast", language="zh", channel="web")
assert "# 你的家" in prompt
assert "# 消息说明" not in prompt
diff --git a/tests/unit_tests/evolution/test_message.py b/tests/unit_tests/evolution/test_message.py
index d3e54675d1..6cedcc4145 100644
--- a/tests/unit_tests/evolution/test_message.py
+++ b/tests/unit_tests/evolution/test_message.py
@@ -64,8 +64,30 @@ class TestMode:
@staticmethod
def test_mode_values():
"""Test mode enum values."""
- assert Mode.AGENT.value == "agent"
- assert Mode.PLAN.value == "plan"
+ assert Mode.AGENT_PLAN.value == "agent.plan"
+ assert Mode.AGENT_FAST.value == "agent.fast"
+ assert Mode.CODE_PLAN.value == "code.plan"
+ assert Mode.CODE_NORMAL.value == "code.normal"
+ assert Mode.TEAM.value == "team"
+
+ @staticmethod
+ def test_mode_from_raw_legacy_compatibility():
+ """Test only new mode strings are accepted directly."""
+ assert Mode.from_raw("agent.plan") == Mode.AGENT_PLAN
+ assert Mode.from_raw("agent.fast") == Mode.AGENT_FAST
+ assert Mode.from_raw("code.plan") == Mode.CODE_PLAN
+ assert Mode.from_raw("code.normal") == Mode.CODE_NORMAL
+ assert Mode.from_raw("team") == Mode.TEAM
+ assert Mode.from_raw("invalid") == Mode.AGENT_PLAN
+
+ @staticmethod
+ def test_mode_to_runtime_mode():
+ """Test runtime mode mapping returns new mode values."""
+ assert Mode.AGENT_PLAN.to_runtime_mode() == "agent.plan"
+ assert Mode.AGENT_FAST.to_runtime_mode() == "agent.fast"
+ assert Mode.CODE_PLAN.to_runtime_mode() == "code.plan"
+ assert Mode.CODE_NORMAL.to_runtime_mode() == "code.normal"
+ assert Mode.TEAM.to_runtime_mode() == "team"
class TestAgentRequest:
@@ -255,9 +277,9 @@ class TestMessage:
params={},
timestamp=1234567894.0,
ok=True,
- mode=Mode.PLAN,
+ mode=Mode.AGENT_PLAN,
)
- assert plan_message.mode == Mode.PLAN
+ assert plan_message.mode == Mode.AGENT_PLAN
agent_message = Message(
id="msg-6",
@@ -267,6 +289,6 @@ class TestMessage:
params={},
timestamp=1234567895.0,
ok=True,
- mode=Mode.AGENT,
+ mode=Mode.AGENT_FAST,
)
- assert agent_message.mode == Mode.AGENT
+ assert agent_message.mode == Mode.AGENT_FAST
diff --git a/tests/unit_tests/gateway/test_app_gateway_acp.py b/tests/unit_tests/gateway/test_app_gateway_acp.py
index b672127877..ee862b371a 100644
--- a/tests/unit_tests/gateway/test_app_gateway_acp.py
+++ b/tests/unit_tests/gateway/test_app_gateway_acp.py
@@ -690,7 +690,7 @@ async def test_gateway_server_handle_raw_message_forwards_request():
"params": {
"session_id": "sess-3",
"content": "hello",
- "mode": "agent",
+ "mode": "agent.fast",
},
},
ensure_ascii=False,
@@ -704,7 +704,7 @@ async def test_gateway_server_handle_raw_message_forwards_request():
assert msg.session_id == "sess-3"
assert msg.req_method == ReqMethod.CHAT_SEND
assert msg.params.get("content") == "hello"
- assert msg.mode.value == "agent"
+ assert msg.mode.value == "agent.fast"
assert ws.sent_frames == []
diff --git a/tests/unit_tests/gateway/test_slash_command.py b/tests/unit_tests/gateway/test_slash_command.py
index c7a95efc49..66ba705b84 100644
--- a/tests/unit_tests/gateway/test_slash_command.py
+++ b/tests/unit_tests/gateway/test_slash_command.py
@@ -22,53 +22,71 @@ CONTROL_MESSAGE_TEXTS = _MOD.CONTROL_MESSAGE_TEXTS
FIRST_BATCH_REGISTRY = _MOD.FIRST_BATCH_REGISTRY
ParsedControlAction = _MOD.ParsedControlAction
VALID_MODE_LINES = _MOD.VALID_MODE_LINES
+VALID_SWITCH_LINES = _MOD.VALID_SWITCH_LINES
format_skills_list_for_notice = _MOD.format_skills_list_for_notice
is_control_like_for_im_batching = _MOD.is_control_like_for_im_batching
parse_channel_control_text = _MOD.parse_channel_control_text
@pytest.mark.parametrize(
- ("text", "action", "mode_sub"),
+ ("text", "action", "mode_sub", "switch_sub"),
[
- ("", ParsedControlAction.NONE, None),
- ("hello", ParsedControlAction.NONE, None),
- ("/new_session", ParsedControlAction.NEW_SESSION_OK, None),
- ("/new_session x", ParsedControlAction.NEW_SESSION_BAD, None),
- ("/mode plan", ParsedControlAction.MODE_OK, "plan"),
- ("/mode agent", ParsedControlAction.MODE_BAD, None),
- ("/mode fast", ParsedControlAction.MODE_OK, "fast"),
- ("/mode team", ParsedControlAction.MODE_OK, "team"),
- ("/mode claw", ParsedControlAction.MODE_BAD, None),
- ("/mode", ParsedControlAction.MODE_BAD, None),
- ("/skills", ParsedControlAction.NONE, None),
- ("/skills list", ParsedControlAction.SKILLS_OK, None),
- ("/skills list", ParsedControlAction.SKILLS_OK, None),
- ("/skills extra", ParsedControlAction.NONE, None),
- ("line1\nline2", ParsedControlAction.NONE, None),
+ ("", ParsedControlAction.NONE, None, None),
+ ("hello", ParsedControlAction.NONE, None, None),
+ ("/new_session", ParsedControlAction.NEW_SESSION_OK, None, None),
+ ("/new_session x", ParsedControlAction.NEW_SESSION_BAD, None, None),
+ ("/mode agent", ParsedControlAction.MODE_OK, "agent", None),
+ ("/mode code", ParsedControlAction.MODE_OK, "code", None),
+ ("/mode team", ParsedControlAction.MODE_OK, "team", None),
+ ("/mode agent.plan", ParsedControlAction.MODE_OK, "agent.plan", None),
+ ("/mode agent.fast", ParsedControlAction.MODE_OK, "agent.fast", None),
+ ("/mode code.plan", ParsedControlAction.MODE_OK, "code.plan", None),
+ ("/mode code.normal", ParsedControlAction.MODE_OK, "code.normal", None),
+ ("/mode plan", ParsedControlAction.MODE_BAD, None, None),
+ ("/mode", ParsedControlAction.MODE_BAD, None, None),
+ ("/switch plan", ParsedControlAction.SWITCH_OK, None, "plan"),
+ ("/switch fast", ParsedControlAction.SWITCH_OK, None, "fast"),
+ ("/switch normal", ParsedControlAction.SWITCH_OK, None, "normal"),
+ ("/switch code", ParsedControlAction.SWITCH_BAD, None, None),
+ ("/switch", ParsedControlAction.SWITCH_BAD, None, None),
+ ("/skills", ParsedControlAction.NONE, None, None),
+ ("/skills list", ParsedControlAction.SKILLS_OK, None, None),
+ ("/skills list", ParsedControlAction.SKILLS_OK, None, None),
+ ("/skills extra", ParsedControlAction.NONE, None, None),
+ ("line1\nline2", ParsedControlAction.NONE, None, None),
],
)
def test_parse_channel_control_text(
text: str,
action: ParsedControlAction,
mode_sub: str | None,
+ switch_sub: str | None,
) -> None:
p = parse_channel_control_text(text)
assert p.action is action
assert p.mode_subcommand == mode_sub
+ assert p.switch_subcommand == switch_sub
def test_control_message_texts_contains_mode_variants_and_skills() -> None:
assert "/new_session" in CONTROL_MESSAGE_TEXTS
assert "/skills list" in CONTROL_MESSAGE_TEXTS
assert VALID_MODE_LINES <= CONTROL_MESSAGE_TEXTS
+ assert VALID_SWITCH_LINES <= CONTROL_MESSAGE_TEXTS
assert "/mode team" in CONTROL_MESSAGE_TEXTS
- assert "/mode fast" in CONTROL_MESSAGE_TEXTS
+ assert "/mode code" in CONTROL_MESSAGE_TEXTS
+ assert "/mode agent.plan" in CONTROL_MESSAGE_TEXTS
+ assert "/mode code.normal" in CONTROL_MESSAGE_TEXTS
+ assert "/switch normal" in CONTROL_MESSAGE_TEXTS
def test_is_control_like_for_im_batching() -> None:
assert is_control_like_for_im_batching("/new_session")
- assert is_control_like_for_im_batching("/mode plan")
+ assert is_control_like_for_im_batching("/mode agent")
+ assert is_control_like_for_im_batching("/mode agent.plan")
assert is_control_like_for_im_batching("/mode foo")
+ assert is_control_like_for_im_batching("/switch plan")
+ assert is_control_like_for_im_batching("/switch foo")
assert is_control_like_for_im_batching("/new_sessionoops")
assert is_control_like_for_im_batching("/skills list")
assert is_control_like_for_im_batching("/skills list")
@@ -94,4 +112,4 @@ def test_format_skills_list_for_notice() -> None:
def test_first_batch_registry_ids() -> None:
ids = {e.id for e in FIRST_BATCH_REGISTRY}
- assert ids == {"new_session", "mode", "skills", "resume"}
+ assert ids == {"new_session", "mode", "switch", "skills", "resume"}