Command: python -c "from pathlib import Path; import re,json; p=Path(r'C:\\Users\\ash\\Documents\\Codex\\2026-08-26\\LaptopBridge-DEV\\bridge.py'); lines=p.read_text(encoding='utf-8',errors='replace').splitlines(); pats=re.compile(r'(config\.json|8765|PORT|fast-lane|bridge-inbox|bridge-output|client-config|DRIVE|inbox|outbox)',re.I); [print(f'{i+1}: {x[:300]}') for i,x in enumerate(lines) if pats.search(x)]"
Directory: projects
Status: SUCCESS
Exit code: 0
Cancel Job Rerun Command Refresh
3: import base64
5: import difflib
7: import hashlib
9: import html
11: import json
13: import mimetypes
15: import os
17: import re
19: import secrets
21: import shutil
23: import subprocess
25: import sys
27: import threading
29: import time
31: import urllib.parse
33: from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
35: from pathlib import Path
43: CONFIG_PATH = Path(__file__).with_name("config.json")
115: "port": int(config.get("port", 8765)),
145: FAST_LANE_DIR = CONFIG["data_dir"] / "fast-lane"
313: <meta name="viewport" content="width=device-width, initial-scale=1">
787: import re
1449: DRIVE_LANE_REVISION = "DL3"
1451: DRIVE_LANE_POLL_SECONDS = 0.20
1453: DRIVE_LANE_MAX_COMMAND_BYTES = 65536
1455: DRIVE_LANE_THREAD_LOCK = threading.Lock()
1457: DRIVE_LANE_THREAD_STARTED = False
1459: DRIVE_LANE_RESULTS_DIR = FAST_LANE_DIR / "drive-results"
1461: DRIVE_LANE_RESULTS_DIR.mkdir(exist_ok=True)
1463: DRIVE_LANE_RUNNING_DIR = FAST_LANE_DIR / "drive-running"
1465: DRIVE_LANE_RUNNING_DIR.mkdir(exist_ok=True)
1471: def _find_drive_lane_dirs():
1473: override = os.environ.get("CHATGPT_BRIDGE_DRIVE_ROOT", "").strip()
1479: drive = Path(f"{letter}:\\")
1483: drive / "My Drive" / "ChatGPT Bridge Data",
1485: drive / "ChatGPT Bridge Data",
1493: inbox = root / "fast-lane" / "inbox"
1495: outbox = root / "results"
1497: if inbox.is_dir():
1499: outbox.mkdir(parents=True, exist_ok=True)
1501: return inbox, outbox
1513: def _drive_lane_write_json(path, payload):
1527: def _drive_lane_error(command_id, action, error, received_epoch_ms, sha256=""):
1555: "drive_lane_revision": DRIVE_LANE_REVISION,
1563: def _drive_lane_terminal(text):
1577: def _drive_lane_execute(path, outbox):
1583: local_result = DRIVE_LANE_RESULTS_DIR / f"{command_id}.json"
1585: cloud_result = outbox / f"{command_id}.json"
1599: _drive_lane_write_json(fast_result, cached)
1601: _drive_lane_write_json(cloud_result, cached)
1621: if len(raw) > DRIVE_LANE_MAX_COMMAND_BYTES:
1623: result = _drive_lane_error(command_id, "", "command_file_too_large", received_epoch_ms)
1625: _drive_lane_write_json(local_result, result); _drive_lane_write_json(fast_result, result); _drive_lane_write_json(cloud_result, result); return
1635: result = _drive_lane_error(command_id, "", "invalid_command_json", received_epoch_ms, source_sha)
1637: _drive_lane_write_json(local_result, result); _drive_lane_write_json(fast_result, result); _drive_lane_write_json(cloud_result, result); return
1641: result = _drive_lane_error(command_id, "", "command_id_mismatch", received_epoch_ms, source_sha)
1643: _drive_lane_write_json(local_result, result); _drive_lane_write_json(fast_result, result); _drive_lane_write_json(cloud_result, result); return
1655: result = _drive_lane_error(command_id, str(command_file.get("action", "")), "command_expired", received_epoch_ms, source_sha)
1657: _drive_lane_write_json(local_result, result); _drive_lane_write_json(fast_result, result); _drive_lane_write_json(cloud_result, result); return
1665: result = _drive_lane_error(command_id, action, "invalid_action_or_payload", received_epoch_ms, source_sha)
1667: _drive_lane_write_json(local_result, result); _drive_lane_write_json(fast_result, result); _drive_lane_write_json(cloud_result, result); return
1671: running_path = DRIVE_LANE_RUNNING_DIR / f"{command_id}.json"
1693: return _drive_lane_execute(path, outbox)
1699: import sheet_relay as sr
1751: if _drive_lane_terminal(polled.get("result_text", "")):
1807: "drive_lane_revision": DRIVE_LANE_REVISION,
1839: "drive_lane_revision": DRIVE_LANE_REVISION,
1853: _drive_lane_write_json(local_result, result)
1855: _drive_lane_write_json(fast_result, result)
1856: _drive_lane_write_json(cloud_result, result)
1858: audit("DRIVE_LANE", f"id={command_id} action={action} status={result.get('status','')}")
1864: def drive_lane_worker():
1866: audit("DRIVE_LANE_WORKER", "started")
1872: inbox, outbox = _find_drive_lane_dirs()
1874: if inbox is None:
1880: paths = sorted((p for p in inbox.glob("*.json") if p.is_file()), key=lambda p: p.stat().st_mtime)
1882: pending = [p for p in paths if not (DRIVE_LANE_RESULTS_DIR / f"{p.stem}.json").exists()]
1885: _drive_lane_execute(path, outbox)
1889: audit("DRIVE_LANE_WORKER_ERROR", type(exc).__name__)
1891: time.sleep(DRIVE_LANE_POLL_SECONDS)
1897: def start_drive_lane_worker():
1899: global DRIVE_LANE_THREAD_STARTED
1901: with DRIVE_LANE_THREAD_LOCK:
1903: if DRIVE_LANE_THREAD_STARTED:
1907: thread = threading.Thread(target=drive_lane_worker, name="DriveLaneWorker", daemon=True)
1911: DRIVE_LANE_THREAD_STARTED = True
2287: # ChatGPT's browsing user agents, otherwise the transport is blocked.
2607: def find_drive_inbox():
2609: override = os.environ.get("CHATGPT_BRIDGE_DRIVE_ROOT", "").strip()
2615: candidates.append(Path(override) / "fast-lane" / "inbox")
2619: drive = Path(f"{letter}:\\")
2623: drive / "My Drive" / "ChatGPT Bridge Data" / "fast-lane" / "inbox",
2625: drive / "ChatGPT Bridge Data" / "fast-lane" / "inbox",
2728: drive_ref_sha256 = ""
2730: if trigger_action == "drive_ref":
2732: inbox = find_drive_inbox()
2734: if inbox is None:
2736: return encoded_response({"id":command_id,"action":trigger_action,"status":"error","http_status":503,"error":"drive_inbox_unavailable","received_epoch_ms":received_epoch_ms})
2738: ref_path = inbox / f"{command_id}.json"
2746: return encoded_response({"id":command_id,"action":trigger_action,"status":"error","http_status":404,"error":"drive_ref_not_found","received_epoch_ms":received_epoch_ms})
2750: return encoded_response({"id":command_id,"action":trigger_action,"status":"error","http_status":503,"error":"drive_ref_read_failed","received_epoch_ms":received_epoch_ms})
2754: return encoded_response({"id":command_id,"action":trigger_action,"status":"error","http_status":413,"error":"drive_ref_too_large","received_epoch_ms":received_epoch_ms})
2756: drive_ref_sha256 = hashlib.sha256(ref_raw).hexdigest()
2764: return encoded_response({"id":command_id,"action":trigger_action,"status":"error","http_status":400,"error":"drive_ref_invalid_json","received_epoch_ms":received_epoch_ms})
2768: return encoded_response({"id":command_id,"action":trigger_action,"status":"error","http_status":400,"error":"drive_ref_id_mismatch","received_epoch_ms":received_epoch_ms})
2780: return encoded_response({"id":command_id,"action":trigger_action,"status":"error","http_status":400,"error":"drive_ref_expired","received_epoch_ms":received_epoch_ms})
2788: return encoded_response({"id":command_id,"action":trigger_action,"status":"error","http_status":400,"error":"drive_ref_invalid_action","received_epoch_ms":received_epoch_ms})
2792: return encoded_response({"id":command_id,"action":trigger_action,"status":"error","http_status":400,"error":"drive_ref_invalid_payload","received_epoch_ms":received_epoch_ms})
2804: import sheet_relay as sr
2832: if drive_ref_sha256:
2834: metadata["drive_ref_sha256"] = drive_ref_sha256
2890: "metadata": {"drive_ref_sha256": drive_ref_sha256} if drive_ref_sha256 else {},
3154: import ctypes
3242: rows.append(f"<tr><td>Bridge</td><td>{badge(bridge_ok)}</td><td>pid {fmt(os.getpid())} � port 8765</td></tr>")
3336: "projects/", "bridge-inbox/", "bridge-output/",
3348: "import ", "package ", "class ", "object ", "fun ", "val ", "var ",
4608: path = resolve_path(q.get("path", "bridge-output"))
6232: import shutil as _shutil
6322: start_drive_lane_worker()
6324: address = (CONFIG["host"], CONFIG["port"])
6330: print(f"Listening: http://{CONFIG['host']}:{CONFIG['port']}/ (capability route enabled; token redacted)")