SPB Git

Repository Public

record-research-fixtures-remote.sh 7.3 KB 106 lines shellscript

1#!/bin/bash2# Records the research-agent fixtures (CONTRACT §9) from the copy that holds a real study (M2U64, port 5059,3# ~/dev/vquant-next-agent — read-only). Runs ON the node:  ssh M2U64 'bash -s' < Scripts/record-research-fixtures-remote.sh4# then: scp 'M2U64:/tmp/vqkit-fx-research/*' <tmp>/ ; copy research_*.json to Tests/VQuantKitTests/Fixtures/research/5# (without the research_ prefix) and downscale figure_01…06.png with `sips -Z 720`.6# The device token is minted once into /tmp/vq-api-token-5059 (mode 600) and never printed. The stored conversation is7# written with its base64 figures cut short. stream_study.json is NOT recorded here: it is the web team's recording of8# the same study (client/src/lib/research/__fixtures__/stream-study.json).9# 0.3: session_v03_<id>.json / conversation_v03_<id>.json / approvals_v03_all.json / trace_v03_*.json are the same routes10# re-read after the server gained `generations`, `plan`, `figures` (four sessions, two with approvals), and11# approval_stream.json is tests/fixtures/research/approval_stream.json of the web repo.12set -u13export PATH=$HOME/local/node-v22.15.0-darwin-arm64/bin:$PATH14cd ~/dev/vquant-next-agent || exit 115TF=/tmp/vq-api-token-505916if [ ! -s "$TF" ]; then ( umask 077; node --env-file=.env scripts/native-test-token.mjs simon macos 2>/dev/null | awk '{print $1}' > "$TF" ); fi17TOKEN=$(cat "$TF"); case "$TOKEN" in vqn_*) ;; *) echo "no token"; exit 1;; esac18B=http://localhost:5059; OUT=/tmp/vqkit-fx-research; rm -rf "$OUT"; mkdir -p "$OUT"19g() { curl -s -m 60 -H "Authorization: Bearer $TOKEN" -H "X-VQ-Client: vquant-macos/2.0.0" "$B$1" -o "$OUT/$2" -w "%{http_code} $2 %{size_download}\n"; }20g /api/v2/research/sandbox research_sandbox.json21g /api/v2/research/sessions research_sessions.json22g "/api/v2/research/approvals?status=pending" research_approvals_pending.json23g /api/v2/research/approvals research_approvals_all.json24g /api/config config_research.json25python3 - <<'PY'26import json27d=json.load(open("/tmp/vqkit-fx-research/research_sessions.json"))28for s in d["sessions"]: print({k:(v if k!="title" else str(v)[:60]) for k,v in s.items()})29print(open("/tmp/vqkit-fx-research/research_sandbox.json").read()[:900])30print(open("/tmp/vqkit-fx-research/config_research.json").read()[:300])31print(open("/tmp/vqkit-fx-research/research_approvals_all.json").read()[:600])32PY33S=3d04acf2-235e-46e3-8c2d-bf26b0ba3c81; W=s-$S34g "/api/v2/research/sessions/$W" research_session.json35g "/api/v2/research/sessions/session:$S" research_session_by_session.json36g "/api/v2/research/sessions/$W/files?path=&recursive=1" research_files.json37g "/api/v2/research/sessions/$W/files?path=artifacts" research_files_artifacts.json38g "/api/v2/research/sessions/$W/experiments" research_experiments_all.json39g "/api/v2/research/sessions/$W/experiments?kind=experiment" research_experiments.json40g "/api/v2/research/sessions/$W/experiments?kind=execution" research_executions.json41g "/api/v2/research/sessions/$W/runs" research_runs.json42g "/api/sessions/$S" research_conversation.json43g "/api/v2/generations/x/trace?sessionId=$S" research_trace.json44g "/api/generations" generations_list.json45g "/api/v2/research/sessions/s-c0879eed-c88b-4eda-894e-8a212ba8b001" research_session_bg.json46g "/api/v2/research/sessions/s-nope" research_session_404.json47python3 - <<'PY'48import json49O="/tmp/vqkit-fx-research/"50d=json.load(open(O+"research_session.json"))51print({k:(type(v).__name__, len(v) if hasattr(v,"__len__") else v) for k,v in d.items()})52print("session",d["session"])53import collections54print("file types",collections.Counter((f["type"],f["path"].split("/")[0]) for f in d["files"]))55print([f for f in d["files"]][:6])56print("exp0",json.dumps(d["experiments"][0])[:900])57print("exec0",json.dumps(d["executions"][0])[:700])58print("statuses",collections.Counter((e["kind"],e["status"]) for e in d["experiments"]+d["executions"]))59print("run0",json.dumps(d["runs"][0])[:700] if d["runs"] else None, len(d["runs"]))60print("note0",json.dumps(d["notes"][0])[:500] if d["notes"] else None)61print("library",json.dumps(d["library"])[:400])62e=d["environment"]; print("env",{k:(v if not isinstance(v,(list,str)) or len(v)<120 else (type(v).__name__,len(v),str(v)[:200])) for k,v in e.items()})63print("approvals",d["approvals"])64c=json.load(open(O+"research_conversation.json")); ms=c["messages"]; ms=json.loads(ms) if isinstance(ms,str) else ms65for m in ms: print("msg",{k:(type(v).__name__, len(v) if hasattr(v,"__len__") else v) for k,v in m.items()})66print("research",json.dumps(ms[-1].get("research"))[:1500])67g=json.load(open(O+"generations_list.json")); print("gens",json.dumps(g)[:600])68t=json.load(open(O+"research_trace.json")); print("trace",{k:(len(v) if isinstance(v,list) else v) for k,v in t.items() if k!="usage"})69PY70enc() { python3 -c "import urllib.parse,sys;print(urllib.parse.quote(sys.argv[1],safe=''))" "$1"; }71f() { g "/api/v2/research/sessions/$W/file?path=$(enc "$1")${3:-}" "$2"; }72f code/fc_ucsv.py research_file_code.json73f code/common.py research_file_common.json74f artifacts/dm_post1985.csv research_file_csv.json75f environment.lock.txt research_file_lock.json76f logs/cells/8d9c3f020872866c.py research_file_cell.json77f logs/executions.jsonl research_file_jsonl.json "&offset=0&limit=5"78f nope/missing.py research_file_404.json79g "/api/v2/research/sessions/$W/inspect?path=$(enc data/us_macro_quarterly.csv)" research_inspect.json80RID=fe07fc39-611b-47f2-b7ca-f19c05d3dc7381g "/api/v2/research/runs/$RID?tail=4000" research_run_detail.json82g "/api/v2/research/runs/nope" research_run_404.json83python3 - <<'PY'84import json,os85O="/tmp/vqkit-fx-research/"86d=json.load(open(O+"research_session.json"))87pngs=sorted(f["path"] for f in d["files"] if f["path"].startswith("artifacts/figures/") and f["path"].endswith(".png"))88open(O+"_pngs.txt","w").write("\n".join(pngs[:14]))89print(len(pngs), "pngs")90c=json.load(open(O+"research_conversation.json")); ms=c["messages"]; was_str=isinstance(ms,str); ms=json.loads(ms) if was_str else ms91for m in ms:92    figs=m.get("customPythonFigures") or []93    print("figureUrls", [x.get("figureUrls") for x in figs][:2])94    for x in figs:95        x["figures"]=[s[:48]+"…(trimmed %d chars)"%len(s) for s in x.get("figures",[])]96c["messages"]=ms97json.dump(c,open(O+"research_conversation.json","w"),ensure_ascii=False,separators=(",",":"))98print("conversation bytes", os.path.getsize(O+"research_conversation.json"), "messages was string:", was_str)99for n in ["research_file_code","research_file_csv","research_inspect","research_run_detail","research_file_jsonl"]:100    j=json.load(open(O+n+".json")); print(n, {k:(v if not isinstance(v,(str,list,dict)) or len(str(v))<80 else type(v).__name__+":"+str(len(v))) for k,v in (j.get("dataset") or j).items()})101PY102i=0; while read -r p; do i=$((i+1)); curl -s -m 60 -H "Authorization: Bearer $TOKEN" -H "X-VQ-Client: vquant-macos/2.0.0" "$B/api/v2/research/sessions/$W/file?path=$(enc "$p")" -o "$OUT/figure_$(printf %02d $i).png" -D "$OUT/_hdr_$i.txt"; done < "$OUT/_pngs.txt"103grep -i -E "content-type|content-disposition|content-security" "$OUT/_hdr_1.txt" | cut -c1-200104curl -s -m 30 -H "Authorization: Bearer $TOKEN" -H "X-VQ-Client: vquant-macos/2.0.0" "$B/api/v2/research/sessions/$W/file?path=$(enc "$(head -1 $OUT/_pngs.txt | sed 's/png$/svg/')")" -o "$OUT/figure_01.svg" -w "%{http_code} svg %{size_download}\n"105rm -f "$OUT"/_hdr_*.txt; ls "$OUT" | wc -l106
Files main
Menu

Theme