witbitz-code 1.15.2__tar.gz → 1.15.3__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.
- {witbitz_code-1.15.2/src/witbitz_code.egg-info → witbitz_code-1.15.3}/PKG-INFO +1 -1
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/pyproject.toml +1 -1
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/src/witbitz_code/__init__.py +1 -1
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/src/witbitz_code/connector.py +29 -17
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/src/witbitz_code/link.py +13 -6
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/src/witbitz_code/opencode_plugins/witbitz-browse-publisher.mjs +47 -5
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/src/witbitz_code/ui_static/app.js +1 -1
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/src/witbitz_code/wizard.py +0 -1
- {witbitz_code-1.15.2 → witbitz_code-1.15.3/src/witbitz_code.egg-info}/PKG-INFO +1 -1
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/tests/test_devicelink.py +5 -1
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/tests/test_remind.py +73 -2
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/LICENSE +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/README.md +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/setup.cfg +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/src/witbitz_code/__main__.py +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/src/witbitz_code/_js.py +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/src/witbitz_code/account.py +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/src/witbitz_code/app.py +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/src/witbitz_code/asks.py +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/src/witbitz_code/attachments.py +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/src/witbitz_code/auto.py +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/src/witbitz_code/auto_runner.py +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/src/witbitz_code/browse.py +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/src/witbitz_code/browsetree.py +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/src/witbitz_code/cli.py +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/src/witbitz_code/codekeys.py +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/src/witbitz_code/codetools.py +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/src/witbitz_code/compress.py +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/src/witbitz_code/computers.py +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/src/witbitz_code/confidential.py +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/src/witbitz_code/confidential_models.json +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/src/witbitz_code/devicelink.py +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/src/witbitz_code/dirs.py +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/src/witbitz_code/files.py +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/src/witbitz_code/folders.py +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/src/witbitz_code/gateway.py +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/src/witbitz_code/icons/witbitz-code-wsl.ico +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/src/witbitz_code/icons/witbitz-code.ico +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/src/witbitz_code/images.py +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/src/witbitz_code/keys.py +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/src/witbitz_code/mkdir.py +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/src/witbitz_code/models.py +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/src/witbitz_code/net.py +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/src/witbitz_code/offered_models.json +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/src/witbitz_code/opencode_plugins/notes-init.md +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/src/witbitz_code/opencode_plugins/witbitz-browse-cdp.mjs +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/src/witbitz_code/opencode_plugins/witbitz-browse-local.mjs +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/src/witbitz_code/opencode_plugins/witbitz-browse-tree.mjs +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/src/witbitz_code/opencode_plugins/witbitz-browser.js +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/src/witbitz_code/opencode_plugins/witbitz-media-server.mjs +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/src/witbitz_code/opencode_plugins/witbitz-notes.js +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/src/witbitz_code/opencode_plugins/witbitz-progress.js +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/src/witbitz_code/outputs.py +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/src/witbitz_code/pair.py +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/src/witbitz_code/pairings.py +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/src/witbitz_code/payers.py +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/src/witbitz_code/plugins.py +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/src/witbitz_code/policy.py +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/src/witbitz_code/ports.py +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/src/witbitz_code/qr.py +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/src/witbitz_code/receipt.py +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/src/witbitz_code/relay.py +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/src/witbitz_code/remind.py +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/src/witbitz_code/seccheck.py +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/src/witbitz_code/seen.py +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/src/witbitz_code/selfupdate.py +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/src/witbitz_code/tinfoil_read.py +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/src/witbitz_code/tools_catalog.json +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/src/witbitz_code/tools_probe.py +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/src/witbitz_code/toolsetup.py +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/src/witbitz_code/ui.py +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/src/witbitz_code/ui_static/app.css +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/src/witbitz_code/ui_static/index.html +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/src/witbitz_code/uitools.py +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/src/witbitz_code/uninstall.py +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/src/witbitz_code/winagent.py +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/src/witbitz_code/winbg.py +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/src/witbitz_code/winconsole.py +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/src/witbitz_code/wslstart.py +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/src/witbitz_code.egg-info/SOURCES.txt +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/src/witbitz_code.egg-info/dependency_links.txt +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/src/witbitz_code.egg-info/entry_points.txt +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/src/witbitz_code.egg-info/requires.txt +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/src/witbitz_code.egg-info/top_level.txt +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/tests/test_asks.py +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/tests/test_attachments.py +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/tests/test_auto.py +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/tests/test_browse.py +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/tests/test_browsetree.py +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/tests/test_cli.py +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/tests/test_codekeys.py +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/tests/test_codetools.py +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/tests/test_confidential.py +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/tests/test_connector_e2e.py +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/tests/test_dirs.py +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/tests/test_files.py +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/tests/test_files_and_compress.py +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/tests/test_folders.py +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/tests/test_images.py +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/tests/test_outputs.py +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/tests/test_pair_flows.py +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/tests/test_plugins.py +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/tests/test_policy.py +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/tests/test_ports.py +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/tests/test_ports_win.py +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/tests/test_registry.py +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/tests/test_relay_codec.py +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/tests/test_seccheck.py +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/tests/test_selfupdate.py +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/tests/test_setup.py +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/tests/test_tools_probe.py +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/tests/test_toolsetup.py +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/tests/test_ui.py +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/tests/test_ui_page.py +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/tests/test_uitools.py +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/tests/test_uninstall.py +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/tests/test_winagent.py +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/tests/test_winbg.py +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/tests/test_winconsole.py +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/tests/test_windows_files.py +0 -0
- {witbitz_code-1.15.2 → witbitz_code-1.15.3}/tests/test_wslstart.py +0 -0
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "witbitz-code"
|
|
7
|
-
version = "1.15.
|
|
7
|
+
version = "1.15.3"
|
|
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"
|
|
@@ -594,23 +594,35 @@ class PairingServer:
|
|
|
594
594
|
"""Each waiting approval: a tickle at one minute and a reminder at ten, to the device whose prompt led to it."""
|
|
595
595
|
if not self._asks_live:
|
|
596
596
|
return
|
|
597
|
-
for
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
597
|
+
# One `due` for every folder (state machines pass 8, K#1): `due` forgets the asks it is not shown, so asked per folder
|
|
598
|
+
# with asks waiting in two, each call forgot the other folder's and neither ever reminded.
|
|
599
|
+
dir_of: dict[str, str] = {}
|
|
600
|
+
everything: list[dict] = []
|
|
601
|
+
for d in self._asks.directories():
|
|
602
|
+
for a in self._asks.list(d):
|
|
603
|
+
if isinstance(a, dict) and isinstance(a.get("id"), str) and a["id"] not in dir_of:
|
|
604
|
+
dir_of[a["id"]] = d
|
|
605
|
+
everything.append(a)
|
|
606
|
+
for ask, stage in self._remind.due(everything):
|
|
607
|
+
directory = dir_of[ask["id"]]
|
|
608
|
+
# A stage is spent only by a tickle that went out (2026-11-08, docs/state-machines.md I16 / C#14): marked before the
|
|
609
|
+
# lookup and the POST, no device yet, a network error or a 5xx used it up. The Node connector does the same.
|
|
610
|
+
owner = await self._remind_owner(ask["sessionID"], directory)
|
|
611
|
+
e = self._remind.who(owner) if owner else None
|
|
612
|
+
if not e:
|
|
613
|
+
continue
|
|
614
|
+
n = seal_remind(e["key"], {"where": self.name, "what": detail_of(ask) or str(ask.get("permission") or ""),
|
|
615
|
+
"computer": self.pairing.get("computerId") or "", "session": owner})
|
|
616
|
+
try:
|
|
617
|
+
r = await self._client.post(e["url"], json={"op": "coderemind", "grant": e["grant"], "n": n}, timeout=15)
|
|
618
|
+
if 200 <= r.status_code < 300 or r.status_code == 410:
|
|
619
|
+
self._remind.sent(ask["id"], stage)
|
|
620
|
+
if r.status_code == 410:
|
|
621
|
+
self._remind.note(owner, {}) # that device's address is gone: nothing more to it
|
|
622
|
+
except asyncio.CancelledError:
|
|
623
|
+
raise
|
|
624
|
+
except Exception:
|
|
625
|
+
pass # offline: the same stage tries again at the next tick
|
|
614
626
|
|
|
615
627
|
def _own_review(self, session: str, start: bool) -> None:
|
|
616
628
|
if not self._payers:
|
|
@@ -68,9 +68,16 @@ def _node_base64(s: str) -> bytes:
|
|
|
68
68
|
return _js.atob(body)
|
|
69
69
|
|
|
70
70
|
|
|
71
|
-
|
|
71
|
+
# The account backup's home — every app's /space-config names it (vaultApi). The old same-origin `/api/backup` (Cloudflare KV)
|
|
72
|
+
# is retired (docs/TODO.md, 2026-11-07); its release tokens were the old home's own, so a token the app mints today never
|
|
73
|
+
# opened anything there.
|
|
74
|
+
VAULT_API = (os.environ.get("WITBITZ_VAULT_API") or "https://api.witbitz.chat/v1/vault").rstrip("/")
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
async def pull_index_room(account: Any, homes: list[str], post_json: net.PostJson) -> dict | None:
|
|
72
78
|
"""GAP-CLOSER: the link carried no index-room pointer → derive the backup location from the master, read the gated
|
|
73
|
-
backup with the release token, and take its indexRoom {room, mk}.
|
|
79
|
+
backup with the release token, and take its indexRoom {room, mk}. `homes`: the backup homes to ask (a vault API base
|
|
80
|
+
each, `<base>/release`); the pointer or None."""
|
|
74
81
|
if not isinstance(account, dict) or not truthy(account.get("master")):
|
|
75
82
|
return None
|
|
76
83
|
try:
|
|
@@ -82,15 +89,15 @@ async def pull_index_room(account: Any, origins: list[str], post_json: net.PostJ
|
|
|
82
89
|
loc = devicelink.derive_keys_from_secret(master)
|
|
83
90
|
rel = account.get("rel")
|
|
84
91
|
token = rel.get("token") if isinstance(rel, dict) else None
|
|
85
|
-
for
|
|
92
|
+
for home in homes:
|
|
86
93
|
blob = None
|
|
87
94
|
if truthy(token):
|
|
88
95
|
try:
|
|
89
|
-
r = await post_json(f"{
|
|
96
|
+
r = await post_json(f"{home}/release", {"token": token, "id": loc["id"]})
|
|
90
97
|
if isinstance(r, dict) and truthy(r.get("ok")) and truthy(r.get("blob")):
|
|
91
98
|
blob = r["blob"]
|
|
92
99
|
except Exception:
|
|
93
|
-
pass # try the next
|
|
100
|
+
pass # try the next home
|
|
94
101
|
if not blob:
|
|
95
102
|
continue
|
|
96
103
|
try:
|
|
@@ -216,7 +223,7 @@ async def _link(life_ms, poll_s, origins, get_json, post_json, challenge, svg_pa
|
|
|
216
223
|
out("witbitz-code: no index pointer in the link — recovering it from your account backup… ", end="")
|
|
217
224
|
idx = None
|
|
218
225
|
try:
|
|
219
|
-
idx = await pull_index_room(account,
|
|
226
|
+
idx = await pull_index_room(account, [VAULT_API], post_json)
|
|
220
227
|
except Exception:
|
|
221
228
|
pass
|
|
222
229
|
if idx:
|
|
@@ -983,20 +983,27 @@ var closing = false;
|
|
|
983
983
|
var first = { out: false, in: false, frame: false };
|
|
984
984
|
var tellControl = async (path, body) => {
|
|
985
985
|
try {
|
|
986
|
-
await fetch(CTL + path, { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify(body) });
|
|
986
|
+
const r = await fetch(CTL + path, { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify(body) });
|
|
987
|
+
if (!r.ok) log("control", path, "refused:", r.status);
|
|
988
|
+
return r.ok;
|
|
987
989
|
} catch (e) {
|
|
988
990
|
log("control", path, "failed:", String(e).slice(0, 80));
|
|
991
|
+
return false;
|
|
989
992
|
}
|
|
990
993
|
};
|
|
991
994
|
var said = null;
|
|
992
995
|
var holderVid = null;
|
|
996
|
+
var statusAsk = 0;
|
|
997
|
+
var takeGen = 0;
|
|
993
998
|
var tellTheViewerWhoHasTheControls = async (why) => {
|
|
994
999
|
let st = null;
|
|
1000
|
+
const ask = ++statusAsk, gen = takeGen;
|
|
995
1001
|
try {
|
|
996
1002
|
st = await (await fetch(CTL + "/status")).json();
|
|
997
1003
|
} catch {
|
|
998
1004
|
return;
|
|
999
1005
|
}
|
|
1006
|
+
if (ask !== statusAsk || gen !== takeGen) return;
|
|
1000
1007
|
held = !!st.takeover;
|
|
1001
1008
|
if (!held && cast && cast.incognito && cast.incognito()) closeIncognito("the controls lapsed");
|
|
1002
1009
|
if (!held) holderVid = null;
|
|
@@ -1019,9 +1026,19 @@ var tellTheViewerWhoHasTheControls = async (why) => {
|
|
|
1019
1026
|
st.web ? "on" : "off"
|
|
1020
1027
|
);
|
|
1021
1028
|
};
|
|
1029
|
+
var HOLDER_SILENT_MS = Number(process.env.WB_BROWSE_HOLDER_SILENT_MS) || 6e4;
|
|
1022
1030
|
setInterval(() => {
|
|
1023
|
-
|
|
1031
|
+
const h = holderVid && castViewers.get(holderVid);
|
|
1032
|
+
if (h && h.beats && Date.now() - h.at > HOLDER_SILENT_MS) holderLeft("the holder went silent");
|
|
1033
|
+
if (peers > 1 || held || holderVid) tellTheViewerWhoHasTheControls("poll");
|
|
1024
1034
|
}, 5e3);
|
|
1035
|
+
function holderLeft(why) {
|
|
1036
|
+
if (!holderVid) return;
|
|
1037
|
+
castViewers.delete(holderVid);
|
|
1038
|
+
assigned.delete(holderVid);
|
|
1039
|
+
log("take-over:", why, "\u2014 the enclave's grace decides");
|
|
1040
|
+
closeIncognito(why).finally(() => tellControl("/takeover", { on: false, gone: true }));
|
|
1041
|
+
}
|
|
1025
1042
|
var expectHello = false;
|
|
1026
1043
|
var strays = 0;
|
|
1027
1044
|
var isHello = (b) => b.byteLength === 12 && b[0] === 82 && b[1] === 70 && b[2] === 66 && b[3] === 32 && b[11] === 10;
|
|
@@ -1386,9 +1403,16 @@ function connectRelay() {
|
|
|
1386
1403
|
if (!c) return;
|
|
1387
1404
|
if (c.wb === "takeover") {
|
|
1388
1405
|
if (!c.on) await closeIncognito("the controls were given back");
|
|
1389
|
-
|
|
1406
|
+
takeGen++;
|
|
1407
|
+
if (!await tellControl("/takeover", { on: !!c.on })) {
|
|
1408
|
+
said = null;
|
|
1409
|
+
await tellTheViewerWhoHasTheControls("refused");
|
|
1410
|
+
return;
|
|
1411
|
+
}
|
|
1390
1412
|
held = !!c.on;
|
|
1391
1413
|
holderVid = c.on && typeof c.vid === "string" ? c.vid.slice(0, 64) : null;
|
|
1414
|
+
said = null;
|
|
1415
|
+
if (holderVid && castViewers.has(holderVid)) castViewers.get(holderVid).at = Date.now();
|
|
1392
1416
|
log("take-over", c.on ? "ON \u2014 the agent's CDP session is being closed" : "released");
|
|
1393
1417
|
if (cast) await cast.setController(c.on ? norm(c.view) || largestView() : null).catch(() => {
|
|
1394
1418
|
});
|
|
@@ -1417,12 +1441,30 @@ function connectRelay() {
|
|
|
1417
1441
|
const mode = await cast.setSiteMode(c.mode).catch(() => siteNow());
|
|
1418
1442
|
log("site: the", mode, "site, for everyone");
|
|
1419
1443
|
if (relay && relay.readyState === 1) relay.send(await sealCtl(key, { wb: "site", mode }));
|
|
1444
|
+
} else if (c.wb === "leave" && typeof c.vid === "string") {
|
|
1445
|
+
const v = c.vid.slice(0, 64);
|
|
1446
|
+
if (v === holderVid) holderLeft("the holder's page went away");
|
|
1447
|
+
else {
|
|
1448
|
+
castViewers.delete(v);
|
|
1449
|
+
assigned.delete(v);
|
|
1450
|
+
}
|
|
1451
|
+
} else if (c.wb === "hello" && c.hb && typeof c.vid === "string" && castViewers.has(c.vid.slice(0, 64))) {
|
|
1452
|
+
castViewers.get(c.vid.slice(0, 64)).at = Date.now();
|
|
1420
1453
|
} else if (c.wb === "hello" && c.cast && typeof c.vid === "string" && CDP) {
|
|
1421
1454
|
const known = castViewers.has(c.vid);
|
|
1422
1455
|
const mine = held && c.driving && (!holderVid || c.vid.slice(0, 64) === holderVid);
|
|
1423
|
-
castViewers.set(c.vid.slice(0, 64), { view: norm(c.view), at: Date.now(), driving: !!mine });
|
|
1424
|
-
|
|
1456
|
+
castViewers.set(c.vid.slice(0, 64), { view: norm(c.view), at: Date.now(), driving: !!mine, beats: !!c.beat });
|
|
1457
|
+
assigned.delete(c.vid.slice(0, 64));
|
|
1458
|
+
if (castViewers.size > 8) {
|
|
1459
|
+
const old = castViewers.keys().next().value;
|
|
1460
|
+
castViewers.delete(old);
|
|
1461
|
+
assigned.delete(old);
|
|
1462
|
+
}
|
|
1425
1463
|
if (!known) log("cast: a viewer said hello \u2014", JSON.stringify(norm(c.view)));
|
|
1464
|
+
if (mine && !known) {
|
|
1465
|
+
await tellControl("/takeover", { on: true });
|
|
1466
|
+
log("take-over: the holder came back \u2014 the controls stay theirs");
|
|
1467
|
+
}
|
|
1426
1468
|
if (relay && relay.readyState === 1) relay.send(await sealCtl(key, { wb: "cast", on: true, close: true }));
|
|
1427
1469
|
await startCast();
|
|
1428
1470
|
if (mine && cast) await cast.setController(norm(c.view)).catch(() => {
|
|
@@ -307,7 +307,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
|
|
307
307
|
}
|
|
308
308
|
// ANOTHER ACCOUNT ON THIS COMPUTER: a new code beside the pairings there are (pairings.json holds one per account, on the
|
|
309
309
|
// same OpenCode); nothing is unpaired. Code here pauses while the code is up and comes back when it is scanned or cancelled.
|
|
310
|
-
$('pairAdd').onclick = () => act('/api/pair', {}, 'Add another account? A new code appears — scan it from the other account:
|
|
310
|
+
$('pairAdd').onclick = () => act('/api/pair', {}, 'Add another account? A new code appears — scan it (or paste it) from the other account: Spaces → Settings → Privacy & security → Add a device. Code on this computer pauses until it is scanned or cancelled.')
|
|
311
311
|
$('pairCancel').onclick = () => act('/api/pair/cancel', {})
|
|
312
312
|
$('pairCopy').onclick = async () => {
|
|
313
313
|
const b = $('pairCopy')
|
|
@@ -119,7 +119,7 @@ def test_backup_keys_and_unseal_agree_with_recovery_js():
|
|
|
119
119
|
@requires_node
|
|
120
120
|
def test_link_node_end_to_end_with_a_js_sealed_reply_and_the_backup_fallback(tmp_path):
|
|
121
121
|
"""The whole poll: /api/link answers with a reply a JS device sealed; the payload has no idx, so the index room is
|
|
122
|
-
recovered from a JS-sealed backup through /api/backup
|
|
122
|
+
recovered from a JS-sealed backup through the vault home's /release (never the retired /api/backup)."""
|
|
123
123
|
master = bytes([9] * 32)
|
|
124
124
|
ch = devicelink.new_link_challenge()
|
|
125
125
|
out = run_node("""
|
|
@@ -139,7 +139,10 @@ def test_link_node_end_to_end_with_a_js_sealed_reply_and_the_backup_fallback(tmp
|
|
|
139
139
|
return {"ok": False, "reason": "unavailable"} if len(polls) == 1 else {"ok": False}
|
|
140
140
|
return {"ok": True, **out["reply"]}
|
|
141
141
|
|
|
142
|
+
released = []
|
|
143
|
+
|
|
142
144
|
async def post_json(url, body):
|
|
145
|
+
released.append(url)
|
|
143
146
|
return {"ok": True, "blob": out["blob"]} if body == {"token": "REL", "id": out["id"]} else {"ok": False}
|
|
144
147
|
|
|
145
148
|
lines = []
|
|
@@ -148,6 +151,7 @@ def test_link_node_end_to_end_with_a_js_sealed_reply_and_the_backup_fallback(tmp
|
|
|
148
151
|
out=lambda *a, **k: lines.append(" ".join(map(str, a))), err=lines.append))
|
|
149
152
|
assert account and account["email"] == "me@x"
|
|
150
153
|
assert account["idx"] == {"room": "sp-idx-9", "mk": "idxmk9"}
|
|
154
|
+
assert released == ["https://api.witbitz.chat/v1/vault/release"]
|
|
151
155
|
assert polls[0] == f"https://a.test/api/link?ref={ch.ref}"
|
|
152
156
|
assert (tmp_path / "qr.svg").stat().st_mode & 0o777 == 0o600
|
|
153
157
|
assert not any(_js.btoa(master) in ln for ln in lines), "the master never reaches the terminal"
|
|
@@ -63,8 +63,9 @@ def test_the_text_opens_with_the_devices_key_only_and_a_page_message_is_checked(
|
|
|
63
63
|
|
|
64
64
|
|
|
65
65
|
class Receiver:
|
|
66
|
-
def __init__(self):
|
|
66
|
+
def __init__(self, fail_first: int = 0):
|
|
67
67
|
self.got: list = []
|
|
68
|
+
self.failed = 0
|
|
68
69
|
outer = self
|
|
69
70
|
|
|
70
71
|
class H(BaseHTTPRequestHandler):
|
|
@@ -72,7 +73,13 @@ class Receiver:
|
|
|
72
73
|
pass
|
|
73
74
|
|
|
74
75
|
def do_POST(self):
|
|
75
|
-
|
|
76
|
+
body = json.loads(self.rfile.read(int(self.headers.get("content-length") or 0)))
|
|
77
|
+
if outer.failed < fail_first: # the push path is down for a while: 503, not delivered
|
|
78
|
+
outer.failed += 1
|
|
79
|
+
self.send_response(503)
|
|
80
|
+
self.end_headers()
|
|
81
|
+
return
|
|
82
|
+
outer.got.append({"path": self.path, "body": body})
|
|
76
83
|
self.send_response(200)
|
|
77
84
|
self.send_header("content-type", "application/json")
|
|
78
85
|
self.end_headers()
|
|
@@ -131,3 +138,67 @@ def test_both_connectors_push_a_waiting_approval_to_the_device_that_asked_twice_
|
|
|
131
138
|
run(go())
|
|
132
139
|
finally:
|
|
133
140
|
rx.close()
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
# ⛔ A STAGE IS SPENT ONLY BY A TICKLE THAT WENT OUT (2026-11-08, docs/state-machines.md I16 / C#14): the stage was marked before the
|
|
144
|
+
# POST, so a 5xx (or no device yet, or a network error) used it up — and after the second there was no retry.
|
|
145
|
+
@pytest.mark.parametrize("make,opts", CONNECTORS)
|
|
146
|
+
def test_a_reminder_the_push_path_refused_is_sent_again_not_used_up(make, opts, tmp_path):
|
|
147
|
+
rx = Receiver(fail_first=2)
|
|
148
|
+
|
|
149
|
+
async def go():
|
|
150
|
+
async with Rig() as rig:
|
|
151
|
+
if make is PyConnector:
|
|
152
|
+
PyConnector.OPTION_NAMES = {**PyConnector.OPTION_NAMES, "remindTimes": "remind_times"}
|
|
153
|
+
connector = make(rig, 30_000, autoDir=str(tmp_path / "auto"), **opts)
|
|
154
|
+
await connector.start()
|
|
155
|
+
client = PyClient(rig.secret, rig.relay.url)
|
|
156
|
+
try:
|
|
157
|
+
await client.start()
|
|
158
|
+
assert await until(lambda: rig.oc.global_count() == 1, 10)
|
|
159
|
+
await client.peer.send({"t": "remind", "k": client.nonce, "sid": "ses_main", "dir": "/home/u/repo", "grant": GRANT, "key": KEY, "url": rx.url})
|
|
160
|
+
await asyncio.sleep(0.2)
|
|
161
|
+
rig.oc.emit_global([_asked("/home/u/repo", ASK)])
|
|
162
|
+
assert await until(lambda: len(rx.got) >= 2, 10), f"both stages delivered after {rx.failed} refusals (got {len(rx.got)})"
|
|
163
|
+
assert rx.failed == 2
|
|
164
|
+
finally:
|
|
165
|
+
await client.peer.aclose()
|
|
166
|
+
await connector.stop()
|
|
167
|
+
|
|
168
|
+
try:
|
|
169
|
+
run(go())
|
|
170
|
+
finally:
|
|
171
|
+
rx.close()
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
# ⛔ ONE `due` FOR EVERY FOLDER (state machines pass 8, K#1): the tick asked the clock once per folder, and the clock forgets every
|
|
175
|
+
# ask it is not shown — so with asks waiting in two folders each call forgot the other's, and neither was ever reminded.
|
|
176
|
+
@pytest.mark.parametrize("make,opts", CONNECTORS)
|
|
177
|
+
def test_asks_waiting_in_two_folders_are_both_reminded(make, opts, tmp_path):
|
|
178
|
+
rx = Receiver()
|
|
179
|
+
other = {**ASK, "id": "per_edit", "permission": "edit", "patterns": ["a.py"], "metadata": {"command": "edit a.py"}}
|
|
180
|
+
|
|
181
|
+
async def go():
|
|
182
|
+
async with Rig() as rig:
|
|
183
|
+
if make is PyConnector:
|
|
184
|
+
PyConnector.OPTION_NAMES = {**PyConnector.OPTION_NAMES, "remindTimes": "remind_times"}
|
|
185
|
+
connector = make(rig, 30_000, autoDir=str(tmp_path / "auto"), **opts)
|
|
186
|
+
await connector.start()
|
|
187
|
+
client = PyClient(rig.secret, rig.relay.url)
|
|
188
|
+
try:
|
|
189
|
+
await client.start()
|
|
190
|
+
assert await until(lambda: rig.oc.global_count() == 1, 10)
|
|
191
|
+
await client.peer.send({"t": "remind", "k": client.nonce, "sid": "ses_main", "dir": "/home/u/repo", "grant": GRANT, "key": KEY, "url": rx.url})
|
|
192
|
+
await asyncio.sleep(0.2)
|
|
193
|
+
rig.oc.emit_global([_asked("/home/u/repo", ASK), _asked("/home/u/other", other)])
|
|
194
|
+
assert await until(lambda: len(rx.got) >= 4, 10), f"two stages for each folder's ask (got {len(rx.got)})"
|
|
195
|
+
whats = sorted(opened(g["body"]["n"])["what"] for g in rx.got)
|
|
196
|
+
assert whats == ["edit a.py", "edit a.py", "npm test", "npm test"], whats
|
|
197
|
+
finally:
|
|
198
|
+
await client.peer.aclose()
|
|
199
|
+
await connector.stop()
|
|
200
|
+
|
|
201
|
+
try:
|
|
202
|
+
run(go())
|
|
203
|
+
finally:
|
|
204
|
+
rx.close()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{witbitz_code-1.15.2 → witbitz_code-1.15.3}/src/witbitz_code/opencode_plugins/witbitz-browse-cdp.mjs
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{witbitz_code-1.15.2 → witbitz_code-1.15.3}/src/witbitz_code/opencode_plugins/witbitz-browser.js
RENAMED
|
File without changes
|
|
File without changes
|
{witbitz_code-1.15.2 → witbitz_code-1.15.3}/src/witbitz_code/opencode_plugins/witbitz-notes.js
RENAMED
|
File without changes
|
{witbitz_code-1.15.2 → witbitz_code-1.15.3}/src/witbitz_code/opencode_plugins/witbitz-progress.js
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|