"""把内嵌源码列表 + BUNDLED_TOOL_FILES + 播种日志一起打出来。""" import base64 import json import sys import urllib.request try: sys.stdout.reconfigure(encoding="utf-8", errors="replace") except Exception: pass URL = "http://127.0.0.1:15199" D = "/storage/emulated/0/Android/data/com.doubao.lynxclone/files/tools" def call(path, payload=None, method="POST", timeout=90): data = json.dumps(payload, ensure_ascii=False).encode("utf-8") if payload is not None else None req = urllib.request.Request( URL + path, data=data, method=method, headers={"Content-Type": "application/json; charset=utf-8"}, ) with urllib.request.urlopen(req, timeout=timeout) as r: return json.loads(r.read().decode("utf-8")) probe = ''' import os, sys, json, traceback, inspect D = %r out = {} # 1) 内核进程里 doubao_entry 的 BUNDLED_TOOL_FILES mod = sys.modules.get("doubao_entry") if mod: out["BUNDLED_TOOL_FILES"] = list(getattr(mod, "BUNDLED_TOOL_FILES", [])) out["_module_source_show_ui"] = None try: s = mod._module_source("show_ui") out["_module_source_show_ui"] = (len(s) if s else None) except Exception as e: out["_module_source_err"] = f"{type(e).__name__}: {e}" # 2) 内嵌源码的键 try: import bundled_tool_sources srcs = bundled_tool_sources.sources() out["bundled_keys"] = sorted(srcs.keys()) out["bundled_count"] = len(srcs) except Exception as e: out["bundled_err"] = f"{type(e).__name__}: {e}" # 3) 手动调一次 _seed_tools 看它报什么 if mod: try: n = mod._seed_tools(D) out["manual_seed_wrote"] = n except Exception as e: out["manual_seed_err"] = f"{type(e).__name__}: {e}" out["manual_seed_tb"] = traceback.format_exc()[-800:] print(json.dumps(out, ensure_ascii=False, indent=1)) ''' b64 = base64.b64encode(probe.encode("utf-8")).decode() w = ( "import base64,os;" "open(os.path.join('%s','probe_seed.py'),'wb').write(base64.b64decode('%s'));" "print('ok')" % (D, b64) ) call("/api/tools/run", {"name": "python_run", "args": {"code": w, "timeout": 30}}, timeout=90) # 让内核发现它(force 一下) call("/api/tools", None, "GET") r = call("/api/tools/run", {"name": "probe_seed", "args": {}}, timeout=120) res = (r or {}).get("result") or {} print(res.get("stdout") or json.dumps(r, ensure_ascii=False)[:1500]) if res.get("stderr"): print("--- stderr ---") print(res["stderr"][-1200:])