@tina_summer/codepocket 2.6.9 → 2.6.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/bin/codepocket.js CHANGED
@@ -270,21 +270,28 @@ if (args[0] === 'stop') {
270
270
  console.log(`[codepocket] Stopped (PID ${pid})${extra}`)
271
271
  process.exit(0)
272
272
  }, 300)
273
+ // CRITICAL: do not fall through. The exit is scheduled 300ms out; without
274
+ // this return, execution continues to run(), whose foreground path sees
275
+ // "no daemon running", auto-starts a NEW daemon (stop never sticks), and
276
+ // spawns a claude session with the CLI args as prompt (trust banner +
277
+ // "--print needs input" error noise).
278
+ return
273
279
  }
274
280
 
275
- // Kill orphaned hub/runner processes by binary name (cross-platform).
276
- // The hub binary (cpkt-hub) also runs the runner/sync modes, so matching the
277
- // binary name catches every mode it was spawned in.
281
+ // Kill orphaned hub processes (cross-platform). Only `hub start` mode is
282
+ // targeted — the same binary also runs claude session wrappers and the
283
+ // runner, so never match the bare binary name. Covers the shipped path
284
+ // (`.../bin/codepocket hub start`) and dev/legacy `cpkt-hub` builds.
278
285
  function killOrphans() {
279
- try {
280
- if (process.platform === 'win32') {
281
- execSync('taskkill /F /IM cpkt-hub.exe /T', { stdio: 'ignore' })
282
- } else {
283
- execSync('pkill -f cpkt-hub', { stdio: 'ignore' })
284
- }
285
- return 'hub'
286
- } catch {}
287
- return ''
286
+ const killed = []
287
+ const run = (cmd) => { try { execSync(cmd, { stdio: 'ignore' }); return true } catch { return false } }
288
+ if (process.platform === 'win32') {
289
+ if (run('powershell -NoProfile -Command "Get-CimInstance Win32_Process -Filter \\"Name=\'codepocket.exe\' or Name=\'cpkt-hub.exe\'\\" | Where-Object { $_.CommandLine -match \'hub start\' } | ForEach-Object { Stop-Process -Id $_.ProcessId -Force }"')) killed.push('hub')
290
+ } else {
291
+ if (run('pkill -f "bin/codepocket hub start"')) killed.push('hub')
292
+ if (run('pkill -f "cpkt-hub hub start"')) killed.push('hub')
293
+ }
294
+ return [...new Set(killed)].join('+')
288
295
  }
289
296
 
290
297
  // 'logs' subcommand
@@ -682,7 +689,11 @@ function connectRelay() {
682
689
  if (proxyAgent) {
683
690
  log(`[codepocket] 使用代理: ${detectProxyUrl()}`)
684
691
  }
685
- const wsOptions = proxyAgent ? { agent: proxyAgent } : {}
692
+ // handshakeTimeout: a wedged TLS/WS upgrade (TCP accepted but no response,
693
+ // e.g. CF edge holding the connection) fires neither open/close/error —
694
+ // without a timeout the daemon stays CONNECTING forever and the phone
695
+ // sees hub_offline while the process looks alive.
696
+ const wsOptions = { handshakeTimeout: 15000, ...(proxyAgent ? { agent: proxyAgent } : {}) }
686
697
 
687
698
  relayWs = new WebSocket(relayUrl, wsOptions)
688
699
 
package/bin/run.js CHANGED
@@ -138,7 +138,8 @@ function connectRelay() {
138
138
  let savedSession = null
139
139
  try { savedSession = JSON.parse(fs.readFileSync(SESSION_FILE, 'utf-8')) } catch {}
140
140
 
141
- relayWs = new WebSocket(relayUrl)
141
+ // handshakeTimeout — see bin/codepocket.js connectRelay for rationale
142
+ relayWs = new WebSocket(relayUrl, { handshakeTimeout: 15000 })
142
143
 
143
144
  relayWs.on('open', () => {
144
145
  console.log('[Relay] connected')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tina_summer/codepocket",
3
- "version": "2.6.9",
3
+ "version": "2.6.11",
4
4
  "description": "CodePocket — 基于ClaudeCode的微信小程序工作台",
5
5
  "bin": {
6
6
  "codepocket": "bin/codepocket.js",
@@ -20,10 +20,10 @@
20
20
  "ws": "^8.18.0"
21
21
  },
22
22
  "optionalDependencies": {
23
- "@tina_summer/codepocket-darwin-arm64": "2.6.9",
24
- "@tina_summer/codepocket-darwin-x64": "2.6.9",
25
- "@tina_summer/codepocket-linux-x64": "2.6.9",
26
- "@tina_summer/codepocket-win32-x64": "2.6.9"
23
+ "@tina_summer/codepocket-darwin-arm64": "2.6.11",
24
+ "@tina_summer/codepocket-darwin-x64": "2.6.11",
25
+ "@tina_summer/codepocket-linux-x64": "2.6.11",
26
+ "@tina_summer/codepocket-win32-x64": "2.6.11"
27
27
  },
28
28
  "engines": {
29
29
  "node": ">=18"
package/src/index.ts CHANGED
@@ -156,7 +156,9 @@ function startSSE() {
156
156
 
157
157
  function connectRelay() {
158
158
  try {
159
- relayWs = new WebSocket(relayUrl)
159
+ // handshakeTimeout — a wedged TLS/WS upgrade fires neither open nor error;
160
+ // without it the connector can hang in CONNECTING forever.
161
+ relayWs = new WebSocket(relayUrl, { handshakeTimeout: 15000 })
160
162
  } catch (err) {
161
163
  console.error(`[Relay] connect failed, retrying in 5s...`)
162
164
  setTimeout(connectRelay, 5000)