@genduo/desk 0.5.1 → 0.5.3

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.
Files changed (2) hide show
  1. package/jdy_secrets.py +51 -13
  2. package/package.json +1 -1
package/jdy_secrets.py CHANGED
@@ -38,8 +38,17 @@ JDY_PWD_F_PASSWORD = "_widget_1729661480439" # Password (text)
38
38
  JDY_API_KEY_TITLE = "api key 精细化运营"
39
39
  JDY_MCP_KEYRING_SERVICE = "JDY_MCP"
40
40
  JDY_MCP_KEYRING_ACCOUNT = "本机JDY服务器URL"
41
- # 兼容旧条目(早期文档写过 account=服务器URL)
42
- JDY_MCP_KEYRING_ACCOUNT_ALIASES = ("本机JDY服务器URL", "服务器URL")
41
+ # 钥匙串访问里常见:服务/位置与账户同为「本机 JDY 服务器 URL」;亦兼容 JDY_MCP + 无空格旧名
42
+ JDY_MCP_KEYRING_ACCOUNT_ALIASES = (
43
+ "本机JDY服务器URL",
44
+ "本机 JDY 服务器 URL",
45
+ "服务器URL",
46
+ )
47
+ JDY_MCP_KEYRING_SERVICE_ALIASES = (
48
+ "本机JDY服务器URL",
49
+ "本机 JDY 服务器 URL",
50
+ "JDY_MCP",
51
+ )
43
52
 
44
53
  # 别名(旧调用方)
45
54
  JDY_MCP_SERVICE = JDY_MCP_KEYRING_SERVICE
@@ -55,19 +64,47 @@ def _get_mcp_url() -> str:
55
64
  return env
56
65
  try:
57
66
  import keyring
58
- for acct in JDY_MCP_KEYRING_ACCOUNT_ALIASES:
59
- v = keyring.get_password(JDY_MCP_KEYRING_SERVICE, acct)
60
- if v:
61
- return v
67
+ for svc in JDY_MCP_KEYRING_SERVICE_ALIASES:
68
+ for acct in JDY_MCP_KEYRING_ACCOUNT_ALIASES:
69
+ v = keyring.get_password(svc, acct)
70
+ if v:
71
+ return v
62
72
  except Exception:
63
73
  pass
64
- # keyring 未装或读失败时:同条目的 security CLI
65
- for acct in JDY_MCP_KEYRING_ACCOUNT_ALIASES:
74
+ # keyring 未装或读失败时:security CLI(通用密码;服务/账户多种写法)
75
+ for svc in JDY_MCP_KEYRING_SERVICE_ALIASES:
76
+ for acct in JDY_MCP_KEYRING_ACCOUNT_ALIASES:
77
+ try:
78
+ r = subprocess.run(
79
+ ["security", "find-generic-password",
80
+ "-s", svc, "-a", acct, "-w"],
81
+ capture_output=True, text=True,
82
+ )
83
+ if r.returncode == 0 and (r.stdout or "").strip():
84
+ return (r.stdout or "").rstrip("\n")
85
+ except Exception:
86
+ pass
87
+ # 「密码」App 网站密码(用户常写成 本机 JDY 服务器 URL + jiandaoyun.com)
88
+ for acct in (
89
+ "本机JDY服务器URL",
90
+ "本机 JDY 服务器 URL",
91
+ "服务器URL",
92
+ ):
93
+ for server in ("jiandaoyun.com", "www.jiandaoyun.com"):
94
+ try:
95
+ r = subprocess.run(
96
+ ["security", "find-internet-password",
97
+ "-s", server, "-a", acct, "-w"],
98
+ capture_output=True, text=True,
99
+ )
100
+ if r.returncode == 0 and (r.stdout or "").strip():
101
+ return (r.stdout or "").rstrip("\n")
102
+ except Exception:
103
+ pass
104
+ # 仅按账户名扫(不限网站)
66
105
  try:
67
106
  r = subprocess.run(
68
- ["security", "find-generic-password",
69
- "-s", JDY_MCP_KEYRING_SERVICE,
70
- "-a", acct, "-w"],
107
+ ["security", "find-internet-password", "-a", acct, "-w"],
71
108
  capture_output=True, text=True,
72
109
  )
73
110
  if r.returncode == 0 and (r.stdout or "").strip():
@@ -75,8 +112,9 @@ def _get_mcp_url() -> str:
75
112
  except Exception:
76
113
  pass
77
114
  raise RuntimeError(
78
- "未找到 JDY MCP URL:请设置环境变量 JDY_MCP_URL "
79
- "或钥匙串条目 JDY_MCP/本机JDY服务器URL"
115
+ "未找到 JDY MCP URL:请设置环境变量 JDY_MCP_URL,"
116
+ "或通用密码「本机 JDY 服务器 URL」(服务/账户同名;亦兼容 JDY_MCP),"
117
+ "或「密码」App 网站条目(账户 本机 JDY 服务器 URL)"
80
118
  )
81
119
 
82
120
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@genduo/desk",
3
- "version": "0.5.1",
3
+ "version": "0.5.3",
4
4
  "description": "Local Mac desk agent CLI for genduo",
5
5
  "bin": {
6
6
  "genduo-desk": "bin/genduo-desk.js"