dsh-gemini-web 0.2.2-beta.0 → 0.2.2-beta.1

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.
package/client.js CHANGED
@@ -949,6 +949,7 @@ window.__ModuleLoader__.load({
949
949
  const selectableLadderModels = textGroup.length > 0 ? textGroup.map(m => ({ id: m.id, name: m.name })) : [
950
950
  { id: 'gemini-4-argon', name: 'Gemini 4 Argon' },
951
951
  { id: 'gemini-4-hydrogen', name: 'Gemini 4 Hydrogen' },
952
+ { id: 'gemini-4-neon', name: 'Gemini 4 Neon' },
952
953
  { id: 'gemini-3.8-flash', name: 'Gemini 3.8 Flash' },
953
954
  { id: 'gemini-3.5-flash-lite', name: 'Gemini 3.5 Flash Lite' },
954
955
  ]
@@ -1415,6 +1416,7 @@ window.__ModuleLoader__.load({
1415
1416
  h('optgroup', { label: t('group_text') }, [
1416
1417
  h('option', { key: 'fl', value: 'gemini-3.5-flash-lite' }, '⚡ 3.5 Flash Lite'),
1417
1418
  h('option', { key: 'f', value: 'gemini-3.8-flash' }, '🚀 3.8 Flash'),
1419
+ h('option', { key: 'n', value: 'gemini-4-neon' }, '⚡ 4 Neon (1M)'),
1418
1420
  h('option', { key: 'h', value: 'gemini-4-hydrogen' }, '🧠 4 Hydrogen (1M)'),
1419
1421
  h('option', { key: 'a', value: 'gemini-4-argon' }, '🏗️ 4 Argon'),
1420
1422
  ]),
package/index.js CHANGED
@@ -987,6 +987,7 @@ function createApiRouter(ctx) {
987
987
  discovered = [
988
988
  { id: "gemini-3.5-flash-lite", name: "Gemini 3.5 Flash Lite", new: false, paid: false },
989
989
  { id: "gemini-3.8-flash", name: "Gemini 3.8 Flash", new: false, paid: false },
990
+ { id: "gemini-4-neon", name: "Gemini 4 Neon", new: true, paid: false },
990
991
  { id: "gemini-4-hydrogen", name: "Gemini 4 Hydrogen", new: true, paid: false },
991
992
  { id: "gemini-4-argon", name: "Gemini 4 Argon", new: false, paid: false },
992
993
  { id: "gemini-nano-banana-2.1", name: "Nano Banana 2.1", new: true, paid: false },
@@ -1076,16 +1077,16 @@ function parseTaskToProposal(task, config) {
1076
1077
  } else if (/3\.8[- ]?flash|\bflash\b/i.test(task) && !/flash[- ]?lite/i.test(task)) {
1077
1078
  userSpecifiedModel = "gemini-3.8-flash";
1078
1079
  userSpecifiedModelKey = "gemini-3.8-flash";
1079
- } else if (/hydrogen|gemini-4/i.test(task)) {
1080
- userSpecifiedModel = "gemini-4-hydrogen";
1081
- userSpecifiedModelKey = "gemini-4-hydrogen";
1080
+ } else if (/neon/i.test(task)) {
1081
+ userSpecifiedModel = "gemini-4-neon";
1082
+ userSpecifiedModelKey = "gemini-4-neon";
1082
1083
  } else if (/argon/i.test(task)) {
1083
1084
  userSpecifiedModel = "gemini-4-hydrogen";
1084
1085
  userSpecifiedModelKey = "gemini-4-hydrogen";
1085
1086
  modelNote = "(注:Google 已将旧 Argon 槽位升级合并至 Hydrogen 深度推理,已自动为您映射)";
1086
- } else if (/neon/i.test(task)) {
1087
- userSpecifiedModel = "gemini-4-neon";
1088
- userSpecifiedModelKey = "neon";
1087
+ } else if (/hydrogen|gemini-4/i.test(task)) {
1088
+ userSpecifiedModel = "gemini-4-hydrogen";
1089
+ userSpecifiedModelKey = "gemini-4-hydrogen";
1089
1090
  } else if (/nano\s*banana/i.test(task)) {
1090
1091
  userSpecifiedModel = "Nano Banana 2.1";
1091
1092
  userSpecifiedModelKey = "nano-banana";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-gemini-web",
3
- "version": "0.2.2-beta.0",
3
+ "version": "0.2.2-beta.1",
4
4
  "description": "Multi-site & multi-modal Gemini web quota orchestration plugin for DeepSeek Harness (AI Studio + Google Flow + Gemini Web via Chrome / Edge / Brave).",
5
5
  "type": "module",
6
6
  "main": "./index.js",
@@ -54,6 +54,6 @@
54
54
  "license": "MIT",
55
55
  "repository": {
56
56
  "type": "git",
57
- "url": "https://github.com/stJL/dsh-gemini-web.git"
57
+ "url": "git+https://github.com/stJL/dsh-gemini-web.git"
58
58
  }
59
59
  }
@@ -589,7 +589,7 @@ def main() -> None:
589
589
  synced = False
590
590
  if args.auto or args.target:
591
591
  synced = sync_skill_files(source_root, target_dir)
592
- # 同步更新其他已存在的已知全局技能目录(如 ~/.dsh/gemini-web-agent 与 ~/.gemini/config/skills/gemini-web-agent)
592
+ # 同步更新其他已存在的已知全局技能目录(如 ~/.dsh/gemini-web-agent 與 ~/.gemini/config/skills/gemini-web-agent)
593
593
  home = Path.home()
594
594
  extra_candidates = [
595
595
  home / ".dsh" / SKILL_NAME,
@@ -7,12 +7,14 @@ sync_upstream.py - 一鍵同步原作者上游倉庫 (582835293/gemini-web-agent
7
7
  當原作者修復了 Google 站點 DOM 選擇器、新增支援模型或更新底層自動化邏輯時,
8
8
  只需在 dsh-gemini-web 目錄下執行:
9
9
  python scripts/sync_upstream.py
10
- 即可自動拉取上游最新改動,智慧同步底層核心腳本,保留 DSH 增強特性,並自動編譯外掛。
10
+ 即可自動拉取上游最新改動,智慧增量同步底層核心腳本,保護 DSH 專屬測試與增強特性,並自動編譯外掛。
11
11
  """
12
12
 
13
13
  import os
14
+ import re
14
15
  import sys
15
16
  import shutil
17
+ import tempfile
16
18
  import subprocess
17
19
  from pathlib import Path
18
20
 
@@ -20,7 +22,7 @@ UPSTREAM_REPO = "https://github.com/582835293/gemini-web-agent.git"
20
22
  LOCAL_UPSTREAM_DIR = Path.home() / ".dsh" / "gemini-web-agent"
21
23
  DSH_PLUGIN_DIR = Path(__file__).resolve().parent.parent
22
24
 
23
- # 需要從原作者倉庫同步的底層檔案與資料夾
25
+ # 需要從原作者倉庫同步的底層核心腳本
24
26
  SYNC_SCRIPTS = [
25
27
  "scripts/gemini_web.py",
26
28
  "scripts/gemini_agentlimb.py",
@@ -28,6 +30,8 @@ SYNC_SCRIPTS = [
28
30
  "scripts/platform_utils.py",
29
31
  "scripts/setup_skill.py",
30
32
  ]
33
+
34
+ # 需要智慧增量同步的資料夾(僅覆蓋上游自帶檔案,保留 DSH 專屬檔案)
31
35
  SYNC_DIRS = [
32
36
  "references",
33
37
  "tests",
@@ -38,19 +42,60 @@ def run_cmd(cmd, cwd=None):
38
42
  return res.returncode, res.stdout.strip(), res.stderr.strip()
39
43
 
40
44
  def apply_dsh_patches():
41
- """確保 DSH 專屬補丁保留(如 Flow 每日點數刷新正則、安全鎖定等)"""
45
+ """確保 DSH 專屬補丁保留(如 Flow 每日點數刷新正則、安全鎖定、DSH 技能目錄等)"""
46
+ # 1. 守護 scripts/gemini_web.py
42
47
  gw_py = DSH_PLUGIN_DIR / "scripts" / "gemini_web.py"
43
48
  if gw_py.exists():
44
49
  text = gw_py.read_text(encoding="utf-8")
45
- if r"Credits?\s+refresh" not in text:
46
- # 確保 Flow 每日重置正則支援
47
- text = text.replace(
48
- 'r"(?:重置时间[::]\\s*|Resets?\\s+)([^\n]+?)(?=\\s+(?:升级|person|Upgrade|退出|Sign\\s*out|frame_spark|可见水印|隐私权|Privacy)|$)"',
49
- 'r"(?:Resets?(?:\\s+on)?|Credits?\\s+refresh(?:\\s+daily\\s+at)?|点数将于|點數將於|刷新时间[::]|重置时间[::]|每日)\\s+([^\\n]+?)(?=\\s*(?:刷新|重置|升级|升級|person|Upgrade|Manage|退出|Sign\\s*out|frame_spark|可见水印|隐私权|Privacy)|$)"'
50
+ if "reset_period" not in text or "個\\s*Google Flow" not in text:
51
+ flow_body_pattern = re.compile(
52
+ r'(\s*dialog\.wait_for\(state="visible", timeout=10000\)\n)'
53
+ r'[\s\S]*?'
54
+ r'(\n\s*finally:\n)',
55
+ re.MULTILINE
56
+ )
57
+ dsh_flow_body = (
58
+ ' raw = (dialog.inner_text() or "").strip()\n'
59
+ ' credits_m = re.search(r"([\\d,]+)\\s*(?:個\\s*Google Flow\\s*點數|个\\s*Google Flow\\s*点数|Google Flow\\s*credits?)", raw, re.IGNORECASE)\n'
60
+ ' # 忠实抓取完整的重置/刷新说明语句(例如 "Credits refresh daily at 5:00 PM" 或 "Resets on Dec 15" 或 "点数将于每日 17:00 刷新")\n'
61
+ ' reset_m = re.search(\n'
62
+ ' r"(?:Credits?\\s+refresh[^\\n]+|Resets?(?:\\s+on)?\\s+[^\\n]+|点数将于[^\\n]+|點數將於[^\\n]+|(?:重置时间|刷新时间)[::]\\s*[^\\n]+|每日\\s*[\\d:]+\\s*(?:AM|PM)?)",\n'
63
+ ' raw,\n'
64
+ ' re.IGNORECASE,\n'
65
+ ' )\n'
66
+ ' raw_reset = reset_m.group(0).strip() if reset_m else None\n'
67
+ ' if raw_reset:\n'
68
+ ' raw_reset = re.sub(\n'
69
+ ' r"\\s*(?:Upgrade|Manage|Sign\\s*out|升级|升級|退出|person|Visible|可见水印|Privacy|隐私权|Terms).*$",\n'
70
+ ' "",\n'
71
+ ' raw_reset,\n'
72
+ ' flags=re.IGNORECASE,\n'
73
+ ' ).strip()\n\n'
74
+ ' period = None\n'
75
+ ' if raw_reset:\n'
76
+ ' lower = raw_reset.lower()\n'
77
+ ' if any(w in lower for w in ["daily", "每日", "每天"]):\n'
78
+ ' period = "daily"\n'
79
+ ' elif any(w in lower for w in ["month", "每月", "每逢", "resets on"]):\n'
80
+ ' period = "monthly"\n\n'
81
+ ' return {\n'
82
+ ' "status": "ok",\n'
83
+ ' "url": page.url,\n'
84
+ ' "credits": int(credits_m.group(1).replace(",", "")) if credits_m else None,\n'
85
+ ' "reset_time": raw_reset,\n'
86
+ ' "reset_period": period,\n'
87
+ ' "raw": raw,\n'
88
+ ' }'
50
89
  )
51
- gw_py.write_text(text, encoding="utf-8")
52
- print(" [Patch] 已注入 Google Flow 每日重置時間正則支援至 gemini_web.py")
90
+ def repl_flow(m):
91
+ return m.group(1) + dsh_flow_body + m.group(2)
53
92
 
93
+ new_text, count = flow_body_pattern.subn(repl_flow, text, count=1)
94
+ if count > 0:
95
+ gw_py.write_text(new_text, encoding="utf-8")
96
+ print(" [Patch] 已注入 Google Flow 點數重置與週期解析增強補丁至 gemini_web.py")
97
+
98
+ # 2. 守護 scripts/gemini_agentlimb.py
54
99
  al_py = DSH_PLUGIN_DIR / "scripts" / "gemini_agentlimb.py"
55
100
  if al_py.exists():
56
101
  text = al_py.read_text(encoding="utf-8")
@@ -62,87 +107,134 @@ def apply_dsh_patches():
62
107
  al_py.write_text(text, encoding="utf-8")
63
108
  print(" [Patch] 已確認保留 Google Flow 每日重置時間正則至 gemini_agentlimb.py")
64
109
 
110
+ # 3. 守護 scripts/setup_skill.py
111
+ sk_py = DSH_PLUGIN_DIR / "scripts" / "setup_skill.py"
112
+ if sk_py.exists():
113
+ text = sk_py.read_text(encoding="utf-8")
114
+ changed = False
115
+ if '"SKILL.zh-CN.md"' not in text:
116
+ text = text.replace('"SKILL.md",', '"SKILL.md", "SKILL.zh-CN.md",')
117
+ changed = True
118
+ if 'home / ".dsh",' not in text:
119
+ text = text.replace('home / ".gemini" / "skills",', 'home / ".gemini" / "skills",\n home / ".dsh",')
120
+ changed = True
121
+ if 'home / ".dsh" / SKILL_NAME' not in text and 'synced = sync_skill_files(source_root, target_dir)' in text:
122
+ extra_block = ''' synced = sync_skill_files(source_root, target_dir)
123
+ # 同步更新其他已存在的已知全局技能目录(如 ~/.dsh/gemini-web-agent 與 ~/.gemini/config/skills/gemini-web-agent)
124
+ home = Path.home()
125
+ extra_candidates = [
126
+ home / ".dsh" / SKILL_NAME,
127
+ home / ".gemini" / "config" / "skills" / SKILL_NAME,
128
+ home / ".gemini" / "skills" / SKILL_NAME,
129
+ home / ".agents" / "skills" / SKILL_NAME,
130
+ ]
131
+ for extra in extra_candidates:
132
+ if extra.exists() and extra.resolve() != target_dir.resolve() and extra.resolve() != source_root.resolve():
133
+ try:
134
+ sync_skill_files(source_root, extra)
135
+ _write_version_meta(extra, source_root)
136
+ except Exception:
137
+ pass'''
138
+ text = text.replace(' synced = sync_skill_files(source_root, target_dir)', extra_block)
139
+ changed = True
140
+ if changed:
141
+ sk_py.write_text(text, encoding="utf-8")
142
+ print(" [Patch] 已注入 DSH 全局技能目錄安裝與中英文文檔支援至 setup_skill.py")
143
+
65
144
  def main():
66
145
  print("=" * 65)
67
- print("🔄 dsh-gemini-web 上游同步器 (Upstream Sync)")
146
+ print("🔄 dsh-gemini-web 增強型上游同步器 (Upstream Sync)")
68
147
  print(f"📍 目標上游: {UPSTREAM_REPO}")
69
148
  print("=" * 65)
70
149
 
71
150
  source_dir = None
151
+ temp_dir = None
152
+
72
153
  if LOCAL_UPSTREAM_DIR.exists() and (LOCAL_UPSTREAM_DIR / ".git").exists():
73
154
  print(f"📦 偵測到本機上游倉庫: {LOCAL_UPSTREAM_DIR}")
74
155
  print(" 正在從 GitHub 獲取最新 origin/main 分支...")
75
156
  code, out, err = run_cmd("git fetch origin main", cwd=LOCAL_UPSTREAM_DIR)
76
157
  if code == 0:
77
- # 嘗試 fast-forward 或 checkout 最新 upstream
78
158
  run_cmd("git checkout -B upstream-sync origin/main", cwd=LOCAL_UPSTREAM_DIR)
79
159
  source_dir = LOCAL_UPSTREAM_DIR
80
160
  else:
81
161
  print(f" ⚠️ 本機目錄 fetch 失敗: {err}")
82
162
 
83
- if not source_dir:
84
- temp_dir = Path("/tmp/upstream_gemini_web_agent")
85
- if temp_dir.exists():
86
- shutil.rmtree(temp_dir)
87
- print("📥 正在臨時克隆最新上游倉庫...")
88
- code, out, err = run_cmd(f"git clone --depth 1 {UPSTREAM_REPO} {temp_dir}")
89
- if code != 0:
90
- print(f"❌ 克隆失敗: {err}")
91
- sys.exit(1)
92
- source_dir = temp_dir
93
-
94
- # 1. 比對並同步底層腳本
95
- print("\n🚀 正在比對並同步底層腳本...")
96
- updated_files = []
97
- for rel_path in SYNC_SCRIPTS:
98
- src = source_dir / rel_path
99
- dst = DSH_PLUGIN_DIR / rel_path
100
- if not src.exists():
101
- continue
102
-
103
- src_text = src.read_text(encoding="utf-8")
104
- dst_text = dst.read_text(encoding="utf-8") if dst.exists() else ""
105
-
106
- if src_text != dst_text:
107
- dst.parent.mkdir(parents=True, exist_ok=True)
108
- dst.write_text(src_text, encoding="utf-8")
109
- print(f" 📝 已更新: {rel_path}")
110
- updated_files.append(rel_path)
163
+ try:
164
+ if not source_dir:
165
+ temp_dir = Path(tempfile.mkdtemp(prefix="upstream_gemini_web_agent_"))
166
+ print(f"📥 正在臨時克隆最新上游倉庫 ({temp_dir})...")
167
+ code, out, err = run_cmd(f'git clone --depth 1 {UPSTREAM_REPO} "{temp_dir}"')
168
+ if code != 0:
169
+ print(f"❌ 克隆失敗: {err}")
170
+ sys.exit(1)
171
+ source_dir = temp_dir
172
+
173
+ # 1. 比對並同步底層腳本
174
+ print("\n🚀 正在比對並同步底層核心腳本...")
175
+ updated_files = []
176
+ for rel_path in SYNC_SCRIPTS:
177
+ src = source_dir / rel_path
178
+ dst = DSH_PLUGIN_DIR / rel_path
179
+ if not src.exists():
180
+ continue
181
+
182
+ src_text = src.read_text(encoding="utf-8")
183
+ dst_text = dst.read_text(encoding="utf-8") if dst.exists() else ""
184
+
185
+ if src_text != dst_text:
186
+ dst.parent.mkdir(parents=True, exist_ok=True)
187
+ dst.write_text(src_text, encoding="utf-8")
188
+ print(f" 📝 已更新: {rel_path}")
189
+ updated_files.append(rel_path)
190
+ else:
191
+ print(f" ✨ 已是最新: {rel_path}")
192
+
193
+ # 2. 智慧增量同步資料夾(如 references、tests 等),絕不刪除 DSH 專屬測試與文件
194
+ print("\n📚 正在增量同步參考文檔與測試套件...")
195
+ for d in SYNC_DIRS:
196
+ src_d = source_dir / d
197
+ dst_d = DSH_PLUGIN_DIR / d
198
+ if not src_d.exists():
199
+ continue
200
+ dst_d.mkdir(parents=True, exist_ok=True)
201
+ synced_count = 0
202
+ for item in src_d.rglob("*"):
203
+ if item.is_file():
204
+ rel = item.relative_to(src_d)
205
+ target_file = dst_d / rel
206
+ target_file.parent.mkdir(parents=True, exist_ok=True)
207
+ # 覆蓋或新增上游檔案,完全不刪除任何既有 DSH 檔案 (如 *.test.ts)
208
+ shutil.copy2(item, target_file)
209
+ synced_count += 1
210
+ print(f" ✅ 已增量同步 {d}/ ({synced_count} 個上游檔案,DSH 專屬檔案完好保留)")
211
+
212
+ # 3. 確保 DSH 專屬補丁不被沖掉
213
+ print("\n🛡️ 檢查並修復 DSH 專屬增強補丁...")
214
+ apply_dsh_patches()
215
+
216
+ # 4. 編譯外掛產物 (bun build)
217
+ print("\n🔨 建置外掛前端與後端產物 (bun build)...")
218
+ bun_path = shutil.which("bun") or shutil.which("bun", path=str(Path.home() / ".bun" / "bin"))
219
+ if bun_path:
220
+ code, out, err = run_cmd(f'"{bun_path}" build src/index.ts --outfile index.js --target node', cwd=DSH_PLUGIN_DIR)
221
+ if code == 0:
222
+ print(" ✅ 外掛 index.js 已自動編譯完成!")
223
+ else:
224
+ print(f" ⚠️ bun build 警告: {err}")
111
225
  else:
112
- print(f" ✨ 已是最新: {rel_path}")
113
-
114
- # 2. 同步資料夾(如 references、tests 等)
115
- for d in SYNC_DIRS:
116
- src_d = source_dir / d
117
- dst_d = DSH_PLUGIN_DIR / d
118
- if src_d.exists():
119
- if dst_d.exists():
120
- shutil.rmtree(dst_d)
121
- shutil.copytree(src_d, dst_d)
122
- print(f" 📚 已同步資料夾: {d}/")
123
-
124
- # 3. 確保 DSH 專屬補丁不被沖掉
125
- print("\n🛡️ 檢查並修復 DSH 專屬增強補丁...")
126
- apply_dsh_patches()
127
-
128
- # 4. 編譯外掛產物 (bun build)
129
- print("\n🔨 建置外掛前端與後端產物 (bun build)...")
130
- bun_path = shutil.which("bun")
131
- if bun_path:
132
- code, out, err = run_cmd("bun build src/index.ts --outfile index.js --target node", cwd=DSH_PLUGIN_DIR)
133
- if code == 0:
134
- print(" ✅ 外掛 index.js 已自動編譯完成!")
226
+ print(" 💡 未偵測到 bun,略過前端產物編譯。")
227
+
228
+ print("\n" + "=" * 65)
229
+ if updated_files:
230
+ print(f"🎉 同步完成!共更新了 {len(updated_files)} 個底層核心腳本。")
135
231
  else:
136
- print(f" ⚠️ bun build 警告: {err}")
137
- else:
138
- print(" 💡 未偵測到 bun,略過前端產物編譯。")
139
-
140
- print("\n" + "=" * 65)
141
- if updated_files:
142
- print(f"🎉 同步完成!共更新了 {len(updated_files)} 個底層核心腳本。")
143
- else:
144
- print("🎉 所有底層核心腳本均已是最新狀態,無需變更!")
145
- print("=" * 65)
232
+ print("🎉 所有底層核心腳本均已是最新狀態,無需變更!")
233
+ print("=" * 65)
234
+
235
+ finally:
236
+ if temp_dir and temp_dir.exists():
237
+ shutil.rmtree(temp_dir, ignore_errors=True)
146
238
 
147
239
  if __name__ == "__main__":
148
240
  main()