witbitz-code 1.15.6__tar.gz → 1.15.7__tar.gz

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 (125) hide show
  1. {witbitz_code-1.15.6/src/witbitz_code.egg-info → witbitz_code-1.15.7}/PKG-INFO +1 -1
  2. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/pyproject.toml +1 -1
  3. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/src/witbitz_code/__init__.py +1 -1
  4. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/src/witbitz_code/app.py +5 -0
  5. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/src/witbitz_code/connector.py +1 -1
  6. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/src/witbitz_code/device.py +4 -2
  7. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/src/witbitz_code/pairings.py +23 -4
  8. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/src/witbitz_code/seccheck.py +7 -3
  9. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/src/witbitz_code/ui.py +19 -1
  10. witbitz_code-1.15.7/src/witbitz_code/winrun.py +34 -0
  11. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/src/witbitz_code/wslstart.py +3 -0
  12. {witbitz_code-1.15.6 → witbitz_code-1.15.7/src/witbitz_code.egg-info}/PKG-INFO +1 -1
  13. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/src/witbitz_code.egg-info/SOURCES.txt +2 -0
  14. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/tests/test_pair_flows.py +17 -0
  15. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/tests/test_ui.py +57 -0
  16. witbitz_code-1.15.7/tests/test_winrun.py +44 -0
  17. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/LICENSE +0 -0
  18. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/README.md +0 -0
  19. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/setup.cfg +0 -0
  20. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/src/witbitz_code/__main__.py +0 -0
  21. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/src/witbitz_code/_js.py +0 -0
  22. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/src/witbitz_code/account.py +0 -0
  23. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/src/witbitz_code/asks.py +0 -0
  24. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/src/witbitz_code/attachments.py +0 -0
  25. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/src/witbitz_code/auto.py +0 -0
  26. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/src/witbitz_code/auto_runner.py +0 -0
  27. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/src/witbitz_code/browse.py +0 -0
  28. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/src/witbitz_code/browsetree.py +0 -0
  29. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/src/witbitz_code/cli.py +0 -0
  30. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/src/witbitz_code/codekeys.py +0 -0
  31. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/src/witbitz_code/codetools.py +0 -0
  32. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/src/witbitz_code/compress.py +0 -0
  33. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/src/witbitz_code/computers.py +0 -0
  34. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/src/witbitz_code/confidential.py +0 -0
  35. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/src/witbitz_code/confidential_models.json +0 -0
  36. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/src/witbitz_code/devicelink.py +0 -0
  37. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/src/witbitz_code/dirs.py +0 -0
  38. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/src/witbitz_code/files.py +0 -0
  39. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/src/witbitz_code/folders.py +0 -0
  40. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/src/witbitz_code/gateway.py +0 -0
  41. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/src/witbitz_code/icons/witbitz-code-wsl.ico +0 -0
  42. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/src/witbitz_code/icons/witbitz-code.ico +0 -0
  43. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/src/witbitz_code/images.py +0 -0
  44. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/src/witbitz_code/keys.py +0 -0
  45. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/src/witbitz_code/link.py +0 -0
  46. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/src/witbitz_code/mkdir.py +0 -0
  47. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/src/witbitz_code/models.py +0 -0
  48. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/src/witbitz_code/net.py +0 -0
  49. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/src/witbitz_code/offered_models.json +0 -0
  50. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/src/witbitz_code/opencode_plugins/notes-init.md +0 -0
  51. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/src/witbitz_code/opencode_plugins/witbitz-browse-cdp.mjs +0 -0
  52. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/src/witbitz_code/opencode_plugins/witbitz-browse-local.mjs +0 -0
  53. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/src/witbitz_code/opencode_plugins/witbitz-browse-publisher.mjs +0 -0
  54. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/src/witbitz_code/opencode_plugins/witbitz-browse-tree.mjs +0 -0
  55. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/src/witbitz_code/opencode_plugins/witbitz-browser.js +0 -0
  56. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/src/witbitz_code/opencode_plugins/witbitz-media-server.mjs +0 -0
  57. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/src/witbitz_code/opencode_plugins/witbitz-notes.js +0 -0
  58. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/src/witbitz_code/opencode_plugins/witbitz-progress.js +0 -0
  59. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/src/witbitz_code/outputs.py +0 -0
  60. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/src/witbitz_code/pair.py +0 -0
  61. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/src/witbitz_code/payers.py +0 -0
  62. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/src/witbitz_code/plugins.py +0 -0
  63. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/src/witbitz_code/policy.py +0 -0
  64. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/src/witbitz_code/ports.py +0 -0
  65. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/src/witbitz_code/qr.py +0 -0
  66. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/src/witbitz_code/receipt.py +0 -0
  67. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/src/witbitz_code/relay.py +0 -0
  68. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/src/witbitz_code/remind.py +0 -0
  69. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/src/witbitz_code/seen.py +0 -0
  70. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/src/witbitz_code/selfupdate.py +0 -0
  71. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/src/witbitz_code/tinfoil_read.py +0 -0
  72. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/src/witbitz_code/tools_catalog.json +0 -0
  73. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/src/witbitz_code/tools_probe.py +0 -0
  74. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/src/witbitz_code/toolsetup.py +0 -0
  75. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/src/witbitz_code/ui_static/app.css +0 -0
  76. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/src/witbitz_code/ui_static/app.js +0 -0
  77. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/src/witbitz_code/ui_static/index.html +0 -0
  78. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/src/witbitz_code/uitools.py +0 -0
  79. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/src/witbitz_code/uninstall.py +0 -0
  80. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/src/witbitz_code/winagent.py +0 -0
  81. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/src/witbitz_code/winbg.py +0 -0
  82. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/src/witbitz_code/winconsole.py +0 -0
  83. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/src/witbitz_code/wizard.py +0 -0
  84. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/src/witbitz_code.egg-info/dependency_links.txt +0 -0
  85. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/src/witbitz_code.egg-info/entry_points.txt +0 -0
  86. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/src/witbitz_code.egg-info/requires.txt +0 -0
  87. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/src/witbitz_code.egg-info/top_level.txt +0 -0
  88. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/tests/test_asks.py +0 -0
  89. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/tests/test_attachments.py +0 -0
  90. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/tests/test_auto.py +0 -0
  91. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/tests/test_browse.py +0 -0
  92. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/tests/test_browsetree.py +0 -0
  93. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/tests/test_cli.py +0 -0
  94. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/tests/test_codekeys.py +0 -0
  95. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/tests/test_codetools.py +0 -0
  96. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/tests/test_confidential.py +0 -0
  97. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/tests/test_connector_e2e.py +0 -0
  98. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/tests/test_device.py +0 -0
  99. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/tests/test_devicelink.py +0 -0
  100. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/tests/test_dirs.py +0 -0
  101. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/tests/test_files.py +0 -0
  102. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/tests/test_files_and_compress.py +0 -0
  103. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/tests/test_folders.py +0 -0
  104. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/tests/test_images.py +0 -0
  105. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/tests/test_outputs.py +0 -0
  106. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/tests/test_plugins.py +0 -0
  107. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/tests/test_policy.py +0 -0
  108. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/tests/test_ports.py +0 -0
  109. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/tests/test_ports_win.py +0 -0
  110. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/tests/test_registry.py +0 -0
  111. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/tests/test_relay_codec.py +0 -0
  112. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/tests/test_remind.py +0 -0
  113. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/tests/test_seccheck.py +0 -0
  114. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/tests/test_selfupdate.py +0 -0
  115. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/tests/test_setup.py +0 -0
  116. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/tests/test_tools_probe.py +0 -0
  117. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/tests/test_toolsetup.py +0 -0
  118. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/tests/test_ui_page.py +0 -0
  119. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/tests/test_uitools.py +0 -0
  120. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/tests/test_uninstall.py +0 -0
  121. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/tests/test_winagent.py +0 -0
  122. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/tests/test_winbg.py +0 -0
  123. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/tests/test_winconsole.py +0 -0
  124. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/tests/test_windows_files.py +0 -0
  125. {witbitz_code-1.15.6 → witbitz_code-1.15.7}/tests/test_wslstart.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: witbitz-code
3
- Version: 1.15.6
3
+ Version: 1.15.7
4
4
  Summary: Reach OpenCode on this computer from the Witbitz Spaces Code section, through an end-to-end sealed relay.
5
5
  Author: Witbitz
6
6
  License-Expression: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "witbitz-code"
7
- version = "1.15.6"
7
+ version = "1.15.7"
8
8
  description = "Reach OpenCode on this computer from the Witbitz Spaces Code section, through an end-to-end sealed relay."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -4,4 +4,4 @@ The Python implementation of tools/witbitz-code.mjs (docs/opencode-relay.md phas
4
4
  vectors and cross-implementation tests.
5
5
  """
6
6
 
7
- __version__ = "1.15.6"
7
+ __version__ = "1.15.7"
@@ -64,6 +64,11 @@ def ports() -> range:
64
64
  return range(base_port(), base_port() + PORTS_PER_APP)
65
65
 
66
66
 
67
+ def origin_of(which: str) -> str:
68
+ """An app's origin, by name (REGULAR / VAULTED)."""
69
+ return _APPS[which]["origin"]
70
+
71
+
67
72
  def origin() -> str:
68
73
  """The app's origin for an account call with no pairing to name it."""
69
74
  return _APPS[name()]["origin"]
@@ -1120,7 +1120,7 @@ class _DefaultDevices:
1120
1120
 
1121
1121
  def _watch_devices(c: Connector, devices: Any, log: Callable[[str], Any], on_all_signed_out: Callable[[], Any] | None) -> None:
1122
1122
  """SIGNED OUT OF THE ACCOUNT (account recovery v2, § 8.5; device.py): a pairing whose computer the account's service
1123
- registered is asked about now, hourly, and when a page connects. Signed out → that pairing stops and the account's keys
1123
+ registered is asked about now, every 5 minutes, and when a page connects. Signed out → that pairing stops and the account's keys
1124
1124
  here are wiped; nothing else changes on any other answer (offline, an error, a key the service does not know)."""
1125
1125
  dev = _DefaultDevices if devices is _DEFAULT_DEVICES else devices
1126
1126
  if dev is None:
@@ -31,8 +31,10 @@ from . import pairings as pp
31
31
  from ._js import b64u, unb64u_loose
32
32
 
33
33
  SIGNED_OUT_TEXT = "This computer was signed out of your account. Pair it again from the app."
34
- CHECK_EVERY_S = 3600 # hourly while serving (each check is signed: it says the computer is in use)
35
- CHECK_FLOOR_S = 600 # a page connecting asks again, at most this often
34
+ # every 5 minutes while serving (each check is signed: it says the computer is in use) — the owner, 2026-11-17: a computer
35
+ # signed out from Your devices kept running "Online" until its next hourly check ("do the Faster check on the computer")
36
+ CHECK_EVERY_S = 300
37
+ CHECK_FLOOR_S = 60 # a page connecting — Code in Spaces, or this computer's own page (ui.py) — asks again, at most this often
36
38
  _LABEL_MAX = 64
37
39
  # The account service a computer may ask: one of the two the apps use (spaces/public/acctV2Switch.js) — never an address a
38
40
  # link names.
@@ -237,12 +237,31 @@ def default_store_owner(pairings: list[dict]) -> str:
237
237
  return key
238
238
 
239
239
 
240
+ def store_keys(p: Any) -> list[str]:
241
+ """This account's store keys, its own first. A REGULAR-app account is the same account whether its pairing names the app's
242
+ origin or not: pairings before 2026-10-22 name none (= the regular app, app.of_origin), and a pairing since names
243
+ https://witbitz-spaces.pages.dev — so the owner's computer, paired again on 2026-11-16, opened a NEW empty store and its 27
244
+ sessions seemed gone ("what happened to the old sessions?"). Both spellings find the same store."""
245
+ p = p if isinstance(p, dict) else {}
246
+ keys = [store_key(p)]
247
+ if app_mod.of_origin(p.get("origin")) == app_mod.REGULAR:
248
+ for o in ("", app_mod.origin_of(app_mod.REGULAR)):
249
+ k = store_key({**p, "origin": o})
250
+ if k not in keys:
251
+ keys.append(k)
252
+ return keys
253
+
254
+
240
255
  def store_dir(p: Any, pairings: list[dict]) -> Path | None:
241
- """None = OpenCode's default store (the first account's); else this account's own folder."""
242
- key = store_key(p)
256
+ """None = OpenCode's default store (the first account's); else this account's own folder — one it already has under any of
257
+ its keys (store_keys), else a new one under its own."""
258
+ keys = store_keys(p)
259
+ base = pairings_path().parent / "accounts"
243
260
  if app_mod.is_vaulted(): # OpenCode's default store is the regular install's: every vaulted account has its own
244
- return pairings_path().parent / "accounts" / key
245
- return None if key == default_store_owner(pairings) else pairings_path().parent / "accounts" / key
261
+ return base / keys[0]
262
+ if default_store_owner(pairings) in keys:
263
+ return None
264
+ return next((base / k for k in keys if (base / k).is_dir()), base / keys[0])
246
265
 
247
266
 
248
267
  # ── files ─────────────────────────────────────────────────────────────────────────────────────────────────────────────
@@ -12,6 +12,7 @@ Windows only for now (also from WSL, where it reads the Windows that hosts it).
12
12
 
13
13
  from __future__ import annotations
14
14
 
15
+ from . import winrun # a Windows program from WSL, tried again when WSL's link times out
15
16
  import asyncio
16
17
  import json
17
18
  import os
@@ -144,9 +145,10 @@ def powershell() -> str | None:
144
145
 
145
146
  def _run_ps(ps: str, script: str, timeout: int = 60) -> subprocess.CompletedProcess:
146
147
  flags = getattr(subprocess, "CREATE_NO_WINDOW", 0)
147
- return subprocess.run([ps, "-NoProfile", "-NonInteractive", "-ExecutionPolicy", "Bypass", "-Command", script], # noqa: S603
148
- check=False, stdin=subprocess.DEVNULL, capture_output=True, text=True, errors="replace",
149
- timeout=timeout, creationflags=flags, cwd="/mnt/c" if _in_wsl() and os.path.isdir("/mnt/c") else None)
148
+ # tried again when WSL's link to Windows timed out (winrun.py) — the check runs in the background, so the wait costs the page nothing
149
+ return winrun.run_retrying(subprocess.run, [ps, "-NoProfile", "-NonInteractive", "-ExecutionPolicy", "Bypass", "-Command", script], # noqa: S603
150
+ check=False, stdin=subprocess.DEVNULL, capture_output=True, text=True, errors="replace",
151
+ timeout=timeout, creationflags=flags, cwd="/mnt/c" if _in_wsl() and os.path.isdir("/mnt/c") else None)
150
152
 
151
153
 
152
154
  def read_status(run: Callable[[str, str], subprocess.CompletedProcess] = _run_ps, ps: str | None = None) -> dict:
@@ -158,6 +160,8 @@ def read_status(run: Callable[[str, str], subprocess.CompletedProcess] = _run_ps
158
160
  try:
159
161
  return {"supported": True, **json.loads(out[-1] if out else "")}
160
162
  except (ValueError, IndexError):
163
+ if winrun.link_failed(r.stderr): # WSL's link to Windows, not the check: said in words, and the next minute's check tries again
164
+ return {"supported": True, "error": winrun.LINK_WORDS}
161
165
  return {"supported": True, "error": "Windows did not answer the check" + (f" ({(r.stderr or '').strip()[:120]})" if r.stderr else "")}
162
166
 
163
167
 
@@ -219,11 +219,29 @@ class Manager:
219
219
  out = {"available": False, "why": "not on this kind of computer yet — Windows and WSL only"}
220
220
  else:
221
221
  st = self._login_state(spec)
222
- out = {"available": st in ("on", "off"), "on": st == "on", **({} if st in ("on", "off") else {"why": "Windows did not answer"})}
222
+ out = {"available": st in ("on", "off"), "on": st == "on", **({} if st in ("on", "off") else {"why": "Windows did not answer just now — it asks again in a moment"})}
223
223
  self._login_cache = (time.monotonic(), out)
224
224
  return out
225
225
 
226
+ def poke_device_checks(self) -> int:
227
+ """This page is open (its status poll): ask the account's service whether each served pairing is still signed in —
228
+ each watch asks at most once a minute (device.CHECK_FLOOR_S). A computer signed out from Your devices then stops
229
+ while someone is looking at it, not at the next timed check (the owner, 2026-11-17). → how many checks started."""
230
+ n = 0
231
+ for r in self.runs.values():
232
+ if r["task"].done():
233
+ continue
234
+ conn = r["live"].get("connector")
235
+ for w in list(getattr(conn, "watchers", None) or []):
236
+ try:
237
+ if w.poke() is not None:
238
+ n += 1
239
+ except Exception: # noqa: BLE001 — a check that cannot start now is asked at its next time
240
+ pass
241
+ return n
242
+
226
243
  async def status(self, fresh: bool = False) -> dict:
244
+ self.poke_device_checks()
227
245
  ps = self.pairings()
228
246
  paired = []
229
247
  for p in ps:
@@ -0,0 +1,34 @@
1
+ """winrun.py — A WINDOWS PROGRAM STARTED FROM WSL, TRIED AGAIN WHEN WSL'S LINK TO WINDOWS TIMES OUT (the owner's laptop, 2026-11-17:
2
+ "This computer's security: Windows did not answer the check (<3>WSL (828767 - ) ERROR: UtilAcceptVsock:273: accept4 failed 110)").
3
+
4
+ WSL starts powershell.exe / cmd.exe through a socket to Windows; for a few minutes at a time (after the laptop wakes, under load)
5
+ that link times out — each launch fails after ~10 s with `UtilAcceptVsock … accept4 failed 110` — and then it works again, the same
6
+ command, unchanged. Measured there: 0 of 4 launches answered in one burst, 32 of 32 a few minutes later. So a launch that failed
7
+ THAT way is tried again a few seconds later, and if it still fails the page says so in words, not WSL's internals.
8
+ """
9
+ from __future__ import annotations
10
+
11
+ import re
12
+ import subprocess
13
+ import time
14
+ from typing import Callable
15
+
16
+ _LINK = re.compile(r"UtilAcceptVsock|UtilConnectVsock|accept4 failed")
17
+ LINK_WORDS = "Windows did not answer just now — WSL's link to Windows timed out. It checks again by itself in a minute."
18
+
19
+
20
+ def link_failed(stderr: str | None) -> bool:
21
+ """Did WSL fail to reach Windows (not: the program ran and failed)?"""
22
+ return bool(stderr) and bool(_LINK.search(stderr))
23
+
24
+
25
+ def run_retrying(run: Callable[..., subprocess.CompletedProcess], args, *, attempts: int = 3, pause: float = 3.0,
26
+ sleep: Callable[[float], None] = time.sleep, **kw) -> subprocess.CompletedProcess:
27
+ """`run(args, **kw)`, again (up to `attempts` in all, `pause` s apart) while WSL's link to Windows is what failed."""
28
+ r = run(args, **kw)
29
+ for _ in range(max(0, attempts - 1)):
30
+ if r.returncode == 0 or not link_failed(getattr(r, "stderr", "")):
31
+ break
32
+ sleep(pause)
33
+ r = run(args, **kw)
34
+ return r
@@ -16,6 +16,7 @@ launcher. Written and removed by Windows PowerShell (WSL's interop reaches it).
16
16
 
17
17
  from __future__ import annotations
18
18
 
19
+ from . import winrun # a Windows program from WSL, tried again when WSL's link times out
19
20
  import base64
20
21
  import getpass
21
22
  import os
@@ -162,6 +163,8 @@ def run_ps(script: str, *, powershell: str = "", run: Callable = subprocess.run)
162
163
  errors="replace", timeout=60, **({"creationflags": 0x08000000} if sys.platform == "win32" else {})) # no window
163
164
  except (OSError, subprocess.SubprocessError):
164
165
  return -1, ""
166
+ if r.returncode != 0 and winrun.link_failed(getattr(r, "stderr", "")):
167
+ return -2, "" # WSL's link to Windows timed out (winrun.py) — not an answer; the page asks again in 30 s
165
168
  return r.returncode, (r.stdout or "").strip()
166
169
 
167
170
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: witbitz-code
3
- Version: 1.15.6
3
+ Version: 1.15.7
4
4
  Summary: Reach OpenCode on this computer from the Witbitz Spaces Code section, through an end-to-end sealed relay.
5
5
  Author: Witbitz
6
6
  License-Expression: MIT
@@ -57,6 +57,7 @@ src/witbitz_code/uninstall.py
57
57
  src/witbitz_code/winagent.py
58
58
  src/witbitz_code/winbg.py
59
59
  src/witbitz_code/winconsole.py
60
+ src/witbitz_code/winrun.py
60
61
  src/witbitz_code/wizard.py
61
62
  src/witbitz_code/wslstart.py
62
63
  src/witbitz_code.egg-info/PKG-INFO
@@ -118,4 +119,5 @@ tests/test_winagent.py
118
119
  tests/test_winbg.py
119
120
  tests/test_winconsole.py
120
121
  tests/test_windows_files.py
122
+ tests/test_winrun.py
121
123
  tests/test_wslstart.py
@@ -429,6 +429,23 @@ def test_each_account_has_its_own_store_and_the_first_keeps_opencode_s_default()
429
429
  assert pp.store_dir(again, ps) == pp.store_dir(vaulted, ps), "pairing the same account again finds its sessions"
430
430
 
431
431
 
432
+ def test_a_regular_account_paired_again_with_its_origin_finds_the_store_it_had_without_one():
433
+ """The owner, 2026-11-16: the computer paired before pairings named their app (no origin), paired again today (origin =
434
+ the regular app) — OpenCode opened a new empty store and the 27 sessions seemed gone."""
435
+ old = {"account": "me@x", "idx": {"room": "r1", "mk": "m"}, "computerId": "c1", "secret": "s"}
436
+ assert pp.store_dir(old, [old]) is None # the default store is recorded for the origin-less key
437
+ new = {**old, "computerId": "c2", "origin": "https://witbitz-spaces.pages.dev"}
438
+ assert pp.store_dir(new, [new]) is None, "the same account: OpenCode's default store, its sessions"
439
+ # an account that had its OWN folder (not the default) finds it again too
440
+ other = {"account": "work@y", "idx": {"room": "r3", "mk": "m"}, "computerId": "c3", "secret": "s"}
441
+ legacy = pp.store_dir(other, [old, other])
442
+ legacy.mkdir(parents=True, exist_ok=True)
443
+ assert pp.store_dir({**other, "origin": "https://witbitz-spaces.pages.dev"}, [new, other]) == legacy
444
+ # the vaulted app's account is another account: never the regular one's store
445
+ v = {**old, "origin": "https://spaces.witbitz.chat"}
446
+ assert pp.store_dir(v, [new, v]) is not None
447
+
448
+
432
449
  def test_another_account_gets_its_own_opencode_port():
433
450
  doc = {"v": 1, "pairings": [{"account": "me@x", "idx": {"room": "r1", "mk": "m"}, "computerId": "c1", "secret": "s",
434
451
  "opencodeUrl": "http://127.0.0.1:4096"}]}
@@ -400,3 +400,60 @@ def test_the_page_offers_another_account_and_an_unpair_per_account():
400
400
  assert "if (s.paired.length > 1 && p.computer)" in js and "act('/api/unpair', { computer: p.computer }" in js, "a row unpairs by its id"
401
401
  assert "for (const p of ps) if (!(await act('/api/unpair', { computer: p.computer }))) return" in js, "Unpair all = each pairing in turn"
402
402
  assert "' · ' + p.app" in js, "each row says which app"
403
+
404
+
405
+ def test_the_open_page_asks_whether_the_computer_is_still_signed_in_at_most_once_a_minute():
406
+ """The owner, 2026-11-17: signed out from Your devices, the computer kept showing "Online" until its next timed check.
407
+ The page's status poll now pokes each served pairing's device check (device.DeviceWatch; its floor: once a minute)."""
408
+ from witbitz_code import device
409
+
410
+ async def go():
411
+ asked: list[str] = []
412
+ clock = [1000.0]
413
+
414
+ async def check():
415
+ asked.append("asked")
416
+ return "active"
417
+
418
+ async def on_revoked():
419
+ raise AssertionError("not signed out")
420
+
421
+ watch = device.DeviceWatch(check, on_revoked, every_s=device.CHECK_EVERY_S, floor_s=device.CHECK_FLOOR_S, now=lambda: clock[0])
422
+ w = World([DESK])
423
+
424
+ async def serve(args, *, stop, live_out):
425
+ live_out["connector"] = SimpleNamespace(servers=[SimpleNamespace(relay_state="open")], watchers=[watch])
426
+ await stop.event.wait()
427
+ return 0
428
+
429
+ w.serve = serve
430
+ m = w.manager()
431
+ srv, base = await with_server(m)
432
+ try:
433
+ async with httpx.AsyncClient() as c:
434
+ assert (await c.post(f"{base}/api/serve", headers=authed(srv), json={"on": True})).json() == {"ok": True}
435
+ assert await until(lambda: _state(c, base, srv, "online"))
436
+ assert await until(lambda: _async(len(asked) == 1)), "the open page asked once"
437
+ for _ in range(3): # the page polls again within the minute: no new question
438
+ await c.get(f"{base}/api/status", headers=authed(srv))
439
+ await asyncio.sleep(0.1)
440
+ assert len(asked) == 1
441
+ clock[0] += device.CHECK_FLOOR_S # a minute on: the next poll asks again
442
+ await c.get(f"{base}/api/status", headers=authed(srv))
443
+ assert await until(lambda: _async(len(asked) == 2))
444
+ finally:
445
+ watch.stop()
446
+ await m.shutdown()
447
+ await srv.close()
448
+
449
+ run(go())
450
+
451
+
452
+ async def _async(v):
453
+ return v
454
+
455
+
456
+ def test_the_timed_check_is_every_five_minutes_and_a_page_asks_at_most_once_a_minute():
457
+ from witbitz_code import device
458
+
459
+ assert (device.CHECK_EVERY_S, device.CHECK_FLOOR_S) == (300, 60)
@@ -0,0 +1,44 @@
1
+ """A Windows program started from WSL is tried again when WSL's link to Windows timed out (winrun.py; the owner's laptop, 2026-11-17)."""
2
+ import subprocess
3
+
4
+ from witbitz_code import seccheck, winrun, wslstart
5
+
6
+ LINK = "<3>WSL (828767 - ) ERROR: UtilAcceptVsock:273: accept4 failed 110"
7
+
8
+
9
+ def runner(results):
10
+ calls = []
11
+
12
+ def run(args, **kw):
13
+ calls.append(args)
14
+ code, out, err = results[min(len(calls) - 1, len(results) - 1)]
15
+ return subprocess.CompletedProcess(args, code, out, err)
16
+ return run, calls
17
+
18
+
19
+ def test_link_failure_is_tried_again_then_answers():
20
+ run, calls = runner([(1, "", LINK), (1, "", LINK), (0, "hi\n", "")])
21
+ r = winrun.run_retrying(run, ["powershell.exe"], sleep=lambda s: None)
22
+ assert r.returncode == 0 and r.stdout == "hi\n" and len(calls) == 3
23
+
24
+
25
+ def test_a_real_failure_is_not_retried():
26
+ run, calls = runner([(1, "", "The term 'x' is not recognized")])
27
+ assert winrun.run_retrying(run, ["powershell.exe"], sleep=lambda s: None).returncode == 1
28
+ assert len(calls) == 1, "only WSL's link is tried again — a script that failed failed"
29
+
30
+
31
+ def test_gives_up_after_its_attempts():
32
+ run, calls = runner([(1, "", LINK)])
33
+ assert winrun.run_retrying(run, ["x"], attempts=3, sleep=lambda s: None).returncode == 1 and len(calls) == 3
34
+
35
+
36
+ def test_the_security_check_says_it_in_words():
37
+ out = seccheck.read_status(run=lambda ps, script: subprocess.CompletedProcess([ps], 1, "", LINK), ps="powershell.exe")
38
+ assert out["error"] == winrun.LINK_WORDS and "UtilAcceptVsock" not in out["error"]
39
+
40
+
41
+ def test_start_at_login_reads_a_link_failure_as_no_answer():
42
+ run, _ = runner([(1, "", LINK)])
43
+ assert wslstart.run_ps("'on'", powershell="powershell.exe", run=run) == (-2, "")
44
+ assert wslstart.startup_state({"name": "x"}, ps=lambda s: (-2, "")) == "unknown"
File without changes
File without changes
File without changes