Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gateway/platforms/qqbot/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -1086,7 +1086,7 @@ def _is_authorized_interaction_for_session(

chat_type = parsed.get("chat_type", "")
chat_id = parsed.get("chat_id", "")
if chat_type == "c2c":
if chat_type in ("c2c", "dm"):
return bool(chat_id) and operator == chat_id

if chat_type in {"group", "guild"}:
Expand Down
5 changes: 4 additions & 1 deletion gateway/platforms/weixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,10 @@ def _is_stale_session_ret(
a genuine rate limit."""
if ret != RATE_LIMIT_ERRCODE and errcode != RATE_LIMIT_ERRCODE:
return False
return (errmsg or "").lower() == "unknown error"
msg = (errmsg or "").strip().lower()
if not msg:
return True
return msg in ("unknown error", "rate limited")


MEDIA_IMAGE = 1
Expand Down
1 change: 1 addition & 0 deletions gateway/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -9106,6 +9106,7 @@ async def _handle_message_with_agent(self, event, source, _quick_key: str, run_g
context_tokens=agent_result.get("last_prompt_tokens", 0) or 0,
context_length=agent_result.get("context_length") or None,
cwd=os.environ.get("TERMINAL_CWD", ""),
session_key=session_key,
)
except Exception as _footer_err:
logger.debug("runtime_footer build failed: %s", _footer_err)
Expand Down
13 changes: 12 additions & 1 deletion gateway/runtime_footer.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ def format_runtime_footer(
context_tokens: int,
context_length: Optional[int],
cwd: Optional[str] = None,
session_key: Optional[str] = None,
fields: Iterable[str] = _DEFAULT_FIELDS,
) -> str:
"""Render the footer line, or return "" if no fields have data.
Expand All @@ -112,7 +113,15 @@ def format_runtime_footer(
pct = max(0, min(100, round((context_tokens / context_length) * 100)))
parts.append(f"{pct}%")
elif field == "cwd":
rel = _home_relative_cwd(cwd or os.environ.get("TERMINAL_CWD", ""))
# Try live cwd from task env overrides first, then fall back to static TERMINAL_CWD
live_cwd = None
if session_key:
try:
from tools.terminal_tool import get_task_cwd
live_cwd = get_task_cwd(session_key)
except Exception:
pass
rel = _home_relative_cwd(cwd or live_cwd or os.environ.get("TERMINAL_CWD", ""))
if rel:
parts.append(rel)
# Unknown field names are silently ignored.
Expand All @@ -130,6 +139,7 @@ def build_footer_line(
context_tokens: int,
context_length: Optional[int],
cwd: Optional[str] = None,
session_key: Optional[str] = None,
) -> str:
"""Top-level entry point used by gateway/run.py.

Expand All @@ -145,5 +155,6 @@ def build_footer_line(
context_tokens=context_tokens,
context_length=context_length,
cwd=cwd,
session_key=session_key,
fields=cfg.get("fields") or _DEFAULT_FIELDS,
)
9 changes: 9 additions & 0 deletions tools/skill_manager_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -831,11 +831,17 @@ def skill_manage(
Returns JSON string with results.
"""
if action == "create":
# Fallback: LLM may mistakenly pass content via file_content
if not content and file_content:
content = file_content
if not content:
return tool_error("content is required for 'create'. Provide the full SKILL.md text (frontmatter + body).", success=False)
result = _create_skill(name, content, category)

elif action == "edit":
# Fallback: LLM may mistakenly pass content via file_content
if not content and file_content:
content = file_content
if not content:
return tool_error("content is required for 'edit'. Provide the full updated SKILL.md text.", success=False)
result = _edit_skill(name, content)
Expand All @@ -853,6 +859,9 @@ def skill_manage(
elif action == "write_file":
if not file_path:
return tool_error("file_path is required for 'write_file'. Example: 'references/api-guide.md'", success=False)
# Fallback: LLM may mistakenly pass file_content via content
if file_content is None and content:
file_content = content
if file_content is None:
return tool_error("file_content is required for 'write_file'.", success=False)
result = _write_file(name, file_path, file_content)
Expand Down
13 changes: 12 additions & 1 deletion tools/skills_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -963,7 +963,18 @@ def _record(sd: Optional[Path], smd: Path) -> None:
# Strategy 3: legacy flat <name>.md files anywhere under the dir.
for found_md in search_dir.rglob(f"{name}.md"):
if found_md.name != "SKILL.md":
_record(None, found_md)
# Skip if this .md is an asset inside another skill's directory
# (e.g., templates/foo.md inside a skill named "bar" should not
# be treated as a standalone "foo" skill)
parent = found_md.parent
is_asset = False
while parent != search_dir and parent.exists():
if (parent / "SKILL.md").exists():
is_asset = True
break
parent = parent.parent
if not is_asset:
_record(None, found_md)

if len(candidates) > 1:
paths = [str(smd) for _, smd in candidates]
Expand Down
11 changes: 11 additions & 0 deletions tools/terminal_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -972,6 +972,17 @@ def clear_task_env_overrides(task_id: str):
_task_env_overrides.pop(task_id, None)


def get_task_cwd(task_id: str) -> Optional[str]:
"""
Get the current working directory for a task.

Returns the cwd from task env overrides if available, otherwise None.
Used by runtime_footer to display the live cwd instead of stale TERMINAL_CWD.
"""
overrides = _task_env_overrides.get(task_id, {})
return overrides.get("cwd")


def _resolve_container_task_id(task_id: Optional[str]) -> str:
"""
Map a tool-call ``task_id`` to the container/sandbox key used by
Expand Down