Update app.py
Browse files
app.py
CHANGED
|
@@ -94,15 +94,6 @@ def _j(obj) -> str:
|
|
| 94 |
|
| 95 |
|
| 96 |
def ui_quickstart_run(sign_all: bool, current_sk: str, current_pk: str):
|
| 97 |
-
"""
|
| 98 |
-
One-click guided demo:
|
| 99 |
-
- optionally generate + use keys
|
| 100 |
-
- start session
|
| 101 |
-
- append a realistic sequence of events
|
| 102 |
-
- verify
|
| 103 |
-
- finalise + export
|
| 104 |
-
- fill the other tabs automatically
|
| 105 |
-
"""
|
| 106 |
status_lines = []
|
| 107 |
|
| 108 |
# Decide keys
|
|
@@ -125,18 +116,20 @@ def ui_quickstart_run(sign_all: bool, current_sk: str, current_pk: str):
|
|
| 125 |
sign_start=bool(sign_all),
|
| 126 |
sk_hex=sk_hex,
|
| 127 |
)
|
|
|
|
| 128 |
if not sid:
|
| 129 |
status_lines.append(f"[FAIL] start_session: {start_msg}")
|
| 130 |
-
|
| 131 |
return (
|
| 132 |
(sk_hex if sign_all else current_sk),
|
| 133 |
(pk_hex if sign_all else current_pk),
|
| 134 |
"", "", "", "", "", # session ids fanout
|
| 135 |
-
|
| 136 |
[], "No timeline.",
|
| 137 |
"FAIL", False, "Quickstart failed at start_session.",
|
| 138 |
None, "Not finalised.",
|
| 139 |
None, "No export.",
|
|
|
|
| 140 |
)
|
| 141 |
|
| 142 |
status_lines.append(f"[OK] Started session: {sid}")
|
|
@@ -178,9 +171,8 @@ def ui_quickstart_run(sign_all: bool, current_sk: str, current_pk: str):
|
|
| 178 |
pk_hex=(pk_hex if sign_all else ""),
|
| 179 |
require_signatures=bool(sign_all),
|
| 180 |
)
|
| 181 |
-
status_lines.append(f"[{
|
| 182 |
|
| 183 |
-
# Finalise + export only if verification ok
|
| 184 |
anchor = None
|
| 185 |
fin_msg = "Not finalised."
|
| 186 |
export_path = None
|
|
@@ -202,18 +194,18 @@ def ui_quickstart_run(sign_all: bool, current_sk: str, current_pk: str):
|
|
| 202 |
else:
|
| 203 |
status_lines.append("[SKIP] Finalise/export skipped because verification failed.")
|
| 204 |
|
| 205 |
-
|
| 206 |
-
start_status_msg = f"Quickstart complete. session_id={sid}"
|
| 207 |
|
| 208 |
return (
|
| 209 |
(sk_hex if sign_all else current_sk),
|
| 210 |
(pk_hex if sign_all else current_pk),
|
| 211 |
-
sid, sid, sid, sid, sid,
|
| 212 |
-
|
| 213 |
tl_rows, tl_msg,
|
| 214 |
verify_status, verify_ok, verify_report,
|
| 215 |
anchor, fin_msg,
|
| 216 |
export_path, export_msg,
|
|
|
|
| 217 |
)
|
| 218 |
|
| 219 |
|
|
@@ -225,6 +217,20 @@ with gr.Blocks(title="RFT Agent Flight Recorder — Black Box Trace + Third-Part
|
|
| 225 |
"**Key safety note:** Public demo. Do not paste production private keys here."
|
| 226 |
)
|
| 227 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 228 |
with gr.Tab("Keys"):
|
| 229 |
sk = gr.Textbox(label="Ed25519 Private Key (hex)", lines=2)
|
| 230 |
pk = gr.Textbox(label="Ed25519 Public Key (hex)", lines=2)
|
|
@@ -254,7 +260,6 @@ with gr.Blocks(title="RFT Agent Flight Recorder — Black Box Trace + Third-Part
|
|
| 254 |
start_btn = gr.Button("Start New Session")
|
| 255 |
start_status = gr.Textbox(label="Status", lines=2)
|
| 256 |
|
| 257 |
-
# fan-out session id to all places
|
| 258 |
start_btn.click(
|
| 259 |
fn=ui_start_session,
|
| 260 |
inputs=[model_id, run_mode, notes, sign_start, sk],
|
|
@@ -391,36 +396,21 @@ with gr.Blocks(title="RFT Agent Flight Recorder — Black Box Trace + Third-Part
|
|
| 391 |
diff_out = gr.Textbox(label="Diff", lines=14)
|
| 392 |
diff_btn.click(fn=text_diff, inputs=[before, after], outputs=[diff_out])
|
| 393 |
|
| 394 |
-
#
|
| 395 |
-
|
| 396 |
-
|
| 397 |
-
|
| 398 |
-
|
| 399 |
-
|
| 400 |
-
|
| 401 |
-
|
| 402 |
-
|
| 403 |
-
|
| 404 |
-
|
| 405 |
-
|
| 406 |
-
|
| 407 |
-
|
| 408 |
-
|
| 409 |
-
|
| 410 |
-
outputs=[
|
| 411 |
-
sk,
|
| 412 |
-
pk,
|
| 413 |
-
sid_start, sid_record, sid_tl, sid_verify, sid_final,
|
| 414 |
-
start_status,
|
| 415 |
-
tl, tl_status,
|
| 416 |
-
verify_msg, verify_ok, verify_report,
|
| 417 |
-
anchor_out, fin_status,
|
| 418 |
-
export_file, export_status,
|
| 419 |
-
],
|
| 420 |
-
)
|
| 421 |
-
# Also show the status in this tab by mirroring Start Session status
|
| 422 |
-
# (no extra logic; we just display whatever Start Session status was set to)
|
| 423 |
-
# Users see it immediately without tab switching.
|
| 424 |
-
gr.Markdown("Tip: after running, open **Timeline**, **Verify Session**, and **Finalise + Export** — everything is already populated.")
|
| 425 |
|
| 426 |
demo.launch()
|
|
|
|
| 94 |
|
| 95 |
|
| 96 |
def ui_quickstart_run(sign_all: bool, current_sk: str, current_pk: str):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 97 |
status_lines = []
|
| 98 |
|
| 99 |
# Decide keys
|
|
|
|
| 116 |
sign_start=bool(sign_all),
|
| 117 |
sk_hex=sk_hex,
|
| 118 |
)
|
| 119 |
+
|
| 120 |
if not sid:
|
| 121 |
status_lines.append(f"[FAIL] start_session: {start_msg}")
|
| 122 |
+
quick_msg = "\n".join(status_lines)
|
| 123 |
return (
|
| 124 |
(sk_hex if sign_all else current_sk),
|
| 125 |
(pk_hex if sign_all else current_pk),
|
| 126 |
"", "", "", "", "", # session ids fanout
|
| 127 |
+
quick_msg, # start_status
|
| 128 |
[], "No timeline.",
|
| 129 |
"FAIL", False, "Quickstart failed at start_session.",
|
| 130 |
None, "Not finalised.",
|
| 131 |
None, "No export.",
|
| 132 |
+
quick_msg, # quick_status
|
| 133 |
)
|
| 134 |
|
| 135 |
status_lines.append(f"[OK] Started session: {sid}")
|
|
|
|
| 171 |
pk_hex=(pk_hex if sign_all else ""),
|
| 172 |
require_signatures=bool(sign_all),
|
| 173 |
)
|
| 174 |
+
status_lines.append(f"[{'OK' if verify_ok else 'FAIL'}] verify_session (pre-finalise): {verify_status}")
|
| 175 |
|
|
|
|
| 176 |
anchor = None
|
| 177 |
fin_msg = "Not finalised."
|
| 178 |
export_path = None
|
|
|
|
| 194 |
else:
|
| 195 |
status_lines.append("[SKIP] Finalise/export skipped because verification failed.")
|
| 196 |
|
| 197 |
+
quick_msg = f"Quickstart complete. session_id={sid}\n\n" + "\n".join(status_lines)
|
|
|
|
| 198 |
|
| 199 |
return (
|
| 200 |
(sk_hex if sign_all else current_sk),
|
| 201 |
(pk_hex if sign_all else current_pk),
|
| 202 |
+
sid, sid, sid, sid, sid, # session ids fanout
|
| 203 |
+
quick_msg, # start_status
|
| 204 |
tl_rows, tl_msg,
|
| 205 |
verify_status, verify_ok, verify_report,
|
| 206 |
anchor, fin_msg,
|
| 207 |
export_path, export_msg,
|
| 208 |
+
quick_msg, # quick_status
|
| 209 |
)
|
| 210 |
|
| 211 |
|
|
|
|
| 217 |
"**Key safety note:** Public demo. Do not paste production private keys here."
|
| 218 |
)
|
| 219 |
|
| 220 |
+
# ------------------------------------------------------------
|
| 221 |
+
# Quickstart FIRST (most important UX improvement)
|
| 222 |
+
# ------------------------------------------------------------
|
| 223 |
+
with gr.Tab("Quickstart (1-click)"):
|
| 224 |
+
gr.Markdown(
|
| 225 |
+
"## Quickstart (1-click)\n"
|
| 226 |
+
"If you just want to see the full workflow **without guessing what to click**, use this.\n\n"
|
| 227 |
+
"**This will:** start a session → append events → verify → finalise → export a ZIP proof bundle → "
|
| 228 |
+
"and auto-fill the other tabs with the `session_id`, timeline, reports, and export file."
|
| 229 |
+
)
|
| 230 |
+
quick_sign = gr.Checkbox(label="Sign everything (Ed25519) + generate fresh keys for this run", value=False)
|
| 231 |
+
quick_run = gr.Button("Run Quickstart Demo Now")
|
| 232 |
+
quick_status = gr.Textbox(label="Quickstart status", lines=14)
|
| 233 |
+
|
| 234 |
with gr.Tab("Keys"):
|
| 235 |
sk = gr.Textbox(label="Ed25519 Private Key (hex)", lines=2)
|
| 236 |
pk = gr.Textbox(label="Ed25519 Public Key (hex)", lines=2)
|
|
|
|
| 260 |
start_btn = gr.Button("Start New Session")
|
| 261 |
start_status = gr.Textbox(label="Status", lines=2)
|
| 262 |
|
|
|
|
| 263 |
start_btn.click(
|
| 264 |
fn=ui_start_session,
|
| 265 |
inputs=[model_id, run_mode, notes, sign_start, sk],
|
|
|
|
| 396 |
diff_out = gr.Textbox(label="Diff", lines=14)
|
| 397 |
diff_btn.click(fn=text_diff, inputs=[before, after], outputs=[diff_out])
|
| 398 |
|
| 399 |
+
# Wire Quickstart click NOW that all components exist
|
| 400 |
+
quick_run.click(
|
| 401 |
+
fn=ui_quickstart_run,
|
| 402 |
+
inputs=[quick_sign, sk, pk],
|
| 403 |
+
outputs=[
|
| 404 |
+
sk,
|
| 405 |
+
pk,
|
| 406 |
+
sid_start, sid_record, sid_tl, sid_verify, sid_final,
|
| 407 |
+
start_status,
|
| 408 |
+
tl, tl_status,
|
| 409 |
+
verify_msg, verify_ok, verify_report,
|
| 410 |
+
anchor_out, fin_status,
|
| 411 |
+
export_file, export_status,
|
| 412 |
+
quick_status,
|
| 413 |
+
],
|
| 414 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 415 |
|
| 416 |
demo.launch()
|