feat: openclaw-style secrets (env.vars + \) and per-task model routing
- Replace python-dotenv with config.json env.vars block + \ substitution - Add models section for per-task model routing (heartbeat, subagent, default) - Heartbeat/subagent tasks can use different models/providers than main chat - Remove python-dotenv from dependencies - Update all docs to reflect new config approach - Reorganize docs into project/ and research/ subdirectories
This commit is contained in:
@@ -206,6 +206,17 @@ class ClaudeCodeRuntime:
|
||||
"""Clean up stale sessions. Returns count removed."""
|
||||
return self._sessions.cleanup(self._config.session_ttl_hours)
|
||||
|
||||
def reset_session(self, conversation_id: str) -> bool:
|
||||
"""Clear the persistent session mapping for a conversation.
|
||||
|
||||
Returns ``True`` if a session was cleared.
|
||||
"""
|
||||
had = self._sessions.get(conversation_id) is not None
|
||||
if had:
|
||||
self._sessions.remove(conversation_id)
|
||||
logger.info(f"Session reset: {conversation_id}")
|
||||
return had
|
||||
|
||||
# -------------------------------------------------------------------
|
||||
# Core: Run claude CLI
|
||||
# -------------------------------------------------------------------
|
||||
|
||||
@@ -711,6 +711,20 @@ class OpenCodeRuntime:
|
||||
"""Clean up stale sessions. Returns count removed."""
|
||||
return self._sessions.cleanup(self._config.session_ttl_hours)
|
||||
|
||||
def reset_session(self, conversation_id: str) -> bool:
|
||||
"""Clear both the persistent session mapping and the live session.
|
||||
|
||||
Returns ``True`` if anything was cleared.
|
||||
"""
|
||||
had_live = self.close_session(conversation_id)
|
||||
had_persistent = self._sessions.get(conversation_id) is not None
|
||||
if had_persistent:
|
||||
self._sessions.remove(conversation_id)
|
||||
cleared = had_live or had_persistent
|
||||
if cleared:
|
||||
logger.info(f"Session reset: {conversation_id}")
|
||||
return cleared
|
||||
|
||||
# -------------------------------------------------------------------
|
||||
# CLI Mode: Subprocess execution
|
||||
# (mirrors OpenClaw's runCliAgent → runCommandWithTimeout pattern)
|
||||
|
||||
@@ -16,6 +16,7 @@ Type these as regular messages in any channel or DM. No `/` prefix needed — ju
|
||||
| `help` | Show all available commands |
|
||||
| `time` | Current server time |
|
||||
| `sessions` | Active session count + cleanup stale |
|
||||
| `new` / `reset` | Start a fresh conversation (clears session for this channel) |
|
||||
| `reload` | Reload config.json and skills |
|
||||
| `subagents` | List active background tasks |
|
||||
|
||||
|
||||
10
main.py
10
main.py
@@ -214,6 +214,15 @@ def ai_handler(msg: IncomingMessage) -> str:
|
||||
if cmd in ("sessions",):
|
||||
return _format_sessions()
|
||||
|
||||
# Reset session for this conversation
|
||||
if cmd in ("new", "reset"):
|
||||
cleared = _runtime.reset_session(msg.conversation_id)
|
||||
if _hook_mgr:
|
||||
_hook_mgr.trigger(HookEvent(type="command", action="new"))
|
||||
if cleared:
|
||||
return "🆕 Session cleared — next message starts a fresh conversation."
|
||||
return "🆕 No active session to clear — already starting fresh."
|
||||
|
||||
# Cron management commands
|
||||
if cmd.startswith("cron"):
|
||||
return _handle_cron_command(cmd)
|
||||
@@ -1606,6 +1615,7 @@ def _format_help() -> str:
|
||||
"• `help` — This help message\n"
|
||||
"• `time` — Server time\n"
|
||||
"• `sessions` — Active session count\n"
|
||||
"• `new` / `reset` — Start a fresh conversation (clears session)\n"
|
||||
"• `reload` — Reload config and skills\n"
|
||||
"\n"
|
||||
"*Runtime:*\n"
|
||||
|
||||
Reference in New Issue
Block a user