Refactor conversation persistence into workspace-scoped storage with host workspace legacy migration, current workspace filtering, and active host workspace state protection. Add proactive recent-conversation prompt injection with personal-space controls, configurable item count, empty-conversation filtering, and frozen per-conversation prompt metadata to keep request caches stable. Introduce conversation_search and conversation_review tools for current-workspace history: multi-keyword search, list mode, current conversation exclusion, message/tool counts, formatted model output, read/save review modes, long-review fallback, and .agents/review storage. Move internal workspace artifacts under .agents, including uploads, skills, compact results, and reviews; update prompt file-tree visibility, compression output, upload paths, and hidden versioning exclusions. Add create_skill workflow and a Skills tool category, move read_skill into Skills, validate/归档 skill folders, support host global skills and Docker/API private skills, and sync private skills into .agents/skills and skill prompts. Update frontend tool icons, statuses, and expanded renderers for conversation recall and skills workflows; add workspace conversation and skills-manager tests.
61 lines
2.3 KiB
Python
61 lines
2.3 KiB
Python
"""项目路径与目录配置。"""
|
||
|
||
import os
|
||
from pathlib import Path
|
||
|
||
|
||
_REPO_ROOT = Path(__file__).resolve().parents[1]
|
||
|
||
|
||
def _resolve_repo_path(raw_value: str, default: str) -> str:
|
||
candidate = str(raw_value or "").strip() or str(default)
|
||
path = Path(candidate).expanduser()
|
||
if not path.is_absolute():
|
||
path = (_REPO_ROOT / path).resolve()
|
||
else:
|
||
path = path.resolve()
|
||
return str(path)
|
||
|
||
# 默认项目路径,可通过环境变量覆盖以指向宿主机任意目录
|
||
DEFAULT_PROJECT_PATH = _resolve_repo_path(os.environ.get("DEFAULT_PROJECT_PATH", ""), "./project")
|
||
# 宿主机模式工作区配置文件(JSON)
|
||
HOST_WORKSPACES_FILE = _resolve_repo_path(os.environ.get("HOST_WORKSPACES_FILE", ""), "./config/host_workspaces.json")
|
||
# 兼容旧配置:若仍有模块读取 HOST_PROJECT_PATH,保留该键(实际宿主机路径选择改由 JSON 管理)
|
||
HOST_PROJECT_PATH = _resolve_repo_path(os.environ.get("HOST_PROJECT_PATH", ""), DEFAULT_PROJECT_PATH)
|
||
PROMPTS_DIR = _resolve_repo_path(os.environ.get("PROMPTS_DIR", ""), "./prompts")
|
||
DATA_DIR = _resolve_repo_path(os.environ.get("DATA_DIR", ""), "./data")
|
||
LOGS_DIR = _resolve_repo_path(os.environ.get("LOGS_DIR", ""), "./logs")
|
||
AGENT_SKILLS_DIR = _resolve_repo_path(os.environ.get("AGENT_SKILLS_DIR", ""), "./agentskills")
|
||
WORKSPACE_SKILLS_DIRNAME = ".agents/skills"
|
||
|
||
# 多用户空间
|
||
USER_SPACE_DIR = _resolve_repo_path(os.environ.get("USER_SPACE_DIR", ""), "./users")
|
||
USERS_DB_FILE = f"{DATA_DIR}/users.json"
|
||
INVITE_CODES_FILE = f"{DATA_DIR}/invite_codes.json"
|
||
ADMIN_POLICY_FILE = f"{DATA_DIR}/admin_policy.json"
|
||
|
||
# API 专用用户与工作区(与网页用户隔离)
|
||
API_USER_SPACE_DIR = _resolve_repo_path(os.environ.get("API_USER_SPACE_DIR", ""), "./api/users")
|
||
API_USERS_DB_FILE = f"{DATA_DIR}/api_users.json"
|
||
API_TOKENS_FILE = f"{DATA_DIR}/api_tokens.json"
|
||
API_USAGE_FILE = f"{DATA_DIR}/api_usage.json"
|
||
|
||
__all__ = [
|
||
"DEFAULT_PROJECT_PATH",
|
||
"HOST_WORKSPACES_FILE",
|
||
"HOST_PROJECT_PATH",
|
||
"PROMPTS_DIR",
|
||
"DATA_DIR",
|
||
"LOGS_DIR",
|
||
"AGENT_SKILLS_DIR",
|
||
"WORKSPACE_SKILLS_DIRNAME",
|
||
"USER_SPACE_DIR",
|
||
"USERS_DB_FILE",
|
||
"INVITE_CODES_FILE",
|
||
"ADMIN_POLICY_FILE",
|
||
"API_USER_SPACE_DIR",
|
||
"API_USERS_DB_FILE",
|
||
"API_TOKENS_FILE",
|
||
"API_USAGE_FILE",
|
||
]
|