@mcviseron/dsh-qq-bridge 0.3.9 → 0.3.11

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/bot/main.py CHANGED
@@ -32,6 +32,9 @@ from viseron_qqbotpy import configure_logging, load_env, get_logger, load_panels
32
32
  from bridge import BridgeClient, BridgeError, download_image
33
33
 
34
34
  ROOT = Path(__file__).resolve().parent
35
+ # 机器人本身是无窗运行的;它再拉 tasklist / taskkill 时如果没带这个标志,Windows 会
36
+ # 给它分配一个新控制台(Win11 上就是弹出的 Windows Terminal 窗口),所以统一带上。
37
+ _NO_WINDOW = getattr(subprocess, "CREATE_NO_WINDOW", 0x08000000) if os.name == "nt" else 0
35
38
  SG_GROUP_BASE_URL = "https://api.sgroup.qq.com"
36
39
  STATE_FILE = ROOT / "state.json"
37
40
  CURSOR_FILE = ROOT / "state" / "cursor.txt"
@@ -4015,7 +4018,12 @@ def _alive(pid: int) -> bool:
4015
4018
  """Whether the process still exists (Windows: tasklist, else signal 0)."""
4016
4019
  try:
4017
4020
  if os.name == "nt":
4018
- result = subprocess.run(["tasklist", "/FI", f"PID eq {pid}"], capture_output=True, text=True)
4021
+ result = subprocess.run(
4022
+ ["tasklist", "/FI", f"PID eq {pid}"],
4023
+ capture_output=True,
4024
+ text=True,
4025
+ creationflags=_NO_WINDOW,
4026
+ )
4019
4027
  return str(pid) in (result.stdout or "")
4020
4028
  os.kill(pid, 0)
4021
4029
  return True
@@ -4029,7 +4037,12 @@ def _kill_tree(pid: int) -> None:
4029
4037
  return
4030
4038
  try:
4031
4039
  if os.name == "nt":
4032
- subprocess.run(["taskkill", "/PID", str(pid), "/T", "/F"], capture_output=True, check=False)
4040
+ subprocess.run(
4041
+ ["taskkill", "/PID", str(pid), "/T", "/F"],
4042
+ capture_output=True,
4043
+ check=False,
4044
+ creationflags=_NO_WINDOW,
4045
+ )
4033
4046
  else:
4034
4047
  os.kill(pid, signal.SIGKILL)
4035
4048
  except OSError as error:
@@ -4188,7 +4201,7 @@ def supervise() -> int:
4188
4201
  state: Dict[str, Any] = {"child": None, "started_at": 0.0, "attempt": 0, "next_at": 0.0, "note": "starting", "log": []}
4189
4202
  lock = threading.Lock()
4190
4203
  log_path = STATE_DIR / "bot-output.log"
4191
- no_window = getattr(subprocess, "CREATE_NO_WINDOW", 0x08000000) if os.name == "nt" else 0
4204
+ no_window = _NO_WINDOW
4192
4205
 
4193
4206
  def pump(stream: Any) -> None:
4194
4207
  """Mirror the child's console output into a ring buffer and a file."""
package/lib/index.js CHANGED
@@ -134,6 +134,7 @@ export function apply(ctx, rawConfig) {
134
134
  detached: true,
135
135
  stdio: 'ignore',
136
136
  windowsHide: true,
137
+ creationflags: process.platform === 'win32' ? 0x08000000 : 0,
137
138
  })
138
139
  child.on('error', (error) => log(`bot supervisor spawn failed: ${error.message}`))
139
140
  child.unref()
@@ -834,6 +835,9 @@ export function apply(ctx, rawConfig) {
834
835
  detached: true,
835
836
  stdio: 'ignore',
836
837
  windowsHide: true,
838
+ // detached 会在 Windows 上给子进程一个新控制台,windowsHide 压不住它:
839
+ // 用户会看到一个黑窗口,关掉它就等于把机器人杀了。CREATE_NO_WINDOW 才真正无窗。
840
+ creationflags: process.platform === 'win32' ? 0x08000000 : 0,
837
841
  })
838
842
  child.on('error', (error) => log(`bot autostart failed: ${error.message}`))
839
843
  child.unref()
package/lib/install.js CHANGED
@@ -30,7 +30,12 @@ export function runCommand(command, args, options = {}) {
30
30
  if (error) fail(error)
31
31
  else done(value)
32
32
  }
33
- const child = spawn(command, args, { cwd: options.cwd, windowsHide: true, shell: false })
33
+ const child = spawn(command, args, {
34
+ cwd: options.cwd,
35
+ windowsHide: true,
36
+ shell: false,
37
+ creationflags: process.platform === 'win32' ? 0x08000000 : 0,
38
+ })
34
39
  const timer = setTimeout(() => {
35
40
  child.kill()
36
41
  settle(new Error(`${command} 超时(${options.timeoutMs ?? 120000}ms)`))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mcviseron/dsh-qq-bridge",
3
- "version": "0.3.9",
3
+ "version": "0.3.11",
4
4
  "description": "DeepSeek Harness plugin: bridge QQ conversations (driven by an external viseron-botpy bot) to DSH sessions — injects user messages, captures assistant replies, streams C2C answers, and relays tool approvals to the bot owner.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",