WCMD 0.2.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
wcmd/__init__.py ADDED
@@ -0,0 +1,6 @@
1
+ # -*- coding: utf-8 -*-
2
+ """WinControl MCP Driver - MCP server for AI-agent-driven Windows UI control."""
3
+
4
+ __version__ = "0.2.0"
5
+ __author__ = "leowu0511"
6
+ __license__ = "MIT"
wcmd/__main__.py ADDED
@@ -0,0 +1,6 @@
1
+ # -*- coding: utf-8 -*-
2
+ """支援 python -m wcmd 啟動 (與 wcmd-mcp 指令等價)。"""
3
+ from wcmd.server import main
4
+
5
+ if __name__ == "__main__":
6
+ main()
wcmd/config.py ADDED
@@ -0,0 +1,98 @@
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ ============================================================================
4
+ WCMD 套件設定 (config.py)
5
+ ============================================================================
6
+ 集中管理所有可透過環境變數覆寫的設定項,避免在主程式碼中散落 magic string。
7
+
8
+ 優先順序(高 → 低):
9
+ 1. 命令列參數 (僅 CLI 模式)
10
+ 2. 環境變數 (WCMD_* 開頭,建議用)
11
+ 3. 環境變數 (VISION_* 開頭,相容舊名稱)
12
+ 4. 下方預設值
13
+
14
+ 環境變數一覽:
15
+ WCMD_DATA_DIR 資料目錄 (預設 ~/.wcmd)
16
+ WCMD_VISION_API_KEY Vision Model API Key
17
+ WCMD_VISION_BASE_URL Vision Model API 端點
18
+ WCMD_VISION_MODEL Vision Model 名稱
19
+ ============================================================================
20
+ """
21
+
22
+ import os
23
+ from pathlib import Path
24
+
25
+
26
+ # ============================================================
27
+ # 資料目錄
28
+ # ============================================================
29
+ # 預設放在使用者家目錄下的 .wcmd/ 子目錄 (跨平台、跨帳號安全)
30
+ # 範例:Windows → C:\Users\xxx\.wcmd\
31
+ # macOS/Linux → /home/xxx/.wcmd/
32
+ _DEFAULT_DATA_DIR = Path.home() / ".wcmd"
33
+
34
+ DATA_DIR: Path = Path(
35
+ os.environ.get("WCMD_DATA_DIR", str(_DEFAULT_DATA_DIR))
36
+ ).expanduser().resolve()
37
+
38
+ # 確保目錄存在
39
+ DATA_DIR.mkdir(parents=True, exist_ok=True)
40
+
41
+
42
+ # ============================================================
43
+ # 檔案路徑 (全部相對於 DATA_DIR)
44
+ # ============================================================
45
+ OUTPUT_IMAGE_PATH: str = str(DATA_DIR / "marked_screen.png")
46
+ COORD_MAP_PATH: str = str(DATA_DIR / "coord_map.json")
47
+ COORD_MAP_GRID_PATH: str = str(DATA_DIR / "coord_map_grid.json")
48
+
49
+
50
+ # ============================================================
51
+ # Vision Model 連線設定
52
+ # ============================================================
53
+ # 解析優先順序:WCMD_* 環境變數 > VISION_* 環境變數 > 預設值
54
+ def _get_env(*names: str, default: str = "") -> str:
55
+ """依序檢查多個環境變數名稱,回傳第一個有值的"""
56
+ for name in names:
57
+ val = os.environ.get(name, "").strip()
58
+ if val:
59
+ return val
60
+ return default
61
+
62
+
63
+ # 預設指向 OpenCode Go (Anthropic 相容模式) + Qwen3.7 Plus
64
+ # 推薦供應商 (依使用情境選用):
65
+ # OpenCode Go (Anthropic 格式):https://opencode.ai/zen/go + qwen3.7-plus
66
+ # OpenCode Zen (OpenAI 格式) :https://opencode.ai/zen/v1 + qwen3.6-plus
67
+ # 阿里雲 DashScope (OpenAI) :https://dashscope.aliyuncs.com/compatible-mode/v1 + qwen-vl-plus
68
+ # OpenAI 官方 :https://api.openai.com/v1 + gpt-4o
69
+ # Anthropic 官方 :https://api.anthropic.com + claude-sonnet-4
70
+ VISION_API_KEY: str = _get_env("WCMD_VISION_API_KEY", "VISION_API_KEY", default="")
71
+ VISION_BASE_URL: str = _get_env(
72
+ "WCMD_VISION_BASE_URL",
73
+ "VISION_BASE_URL",
74
+ default="https://opencode.ai/zen/go",
75
+ )
76
+ VISION_MODEL: str = _get_env(
77
+ "WCMD_VISION_MODEL",
78
+ "VISION_MODEL",
79
+ default="qwen3.7-plus",
80
+ )
81
+
82
+
83
+ def is_vision_configured() -> bool:
84
+ """檢查 Vision Model 是否已設定 (有 API Key 即可)"""
85
+ return bool(VISION_API_KEY)
86
+
87
+
88
+ def get_vision_config() -> dict:
89
+ """回傳目前 Vision Model 設定 (用於 debug 與 log)"""
90
+ return {
91
+ "api_key_set": bool(VISION_API_KEY),
92
+ "api_key_preview": (VISION_API_KEY[:8] + "..." + VISION_API_KEY[-4:])
93
+ if VISION_API_KEY and len(VISION_API_KEY) > 12
94
+ else ("(set)" if VISION_API_KEY else "(empty)"),
95
+ "base_url": VISION_BASE_URL,
96
+ "model": VISION_MODEL,
97
+ "data_dir": str(DATA_DIR),
98
+ }