Job 1788378367517

Command: python -c "import sys,inspect;sys.path.insert(0,'..');import sheet_relay as sr;print(inspect.getsource(sr.result))"
Directory: projects
Status: SUCCESS
Exit code: 0

Cancel Job Rerun Command Refresh

def result(command_id, status, http_status, text, error, started, meta=None):
    meta = dict(meta or {})
    base_text = str(text)
    full_text = f"{base_text}\n\nRELAY_METADATA: {json.dumps(meta, sort_keys=True)}" if meta else base_text
    truncated = False
    if len(full_text) > SHEET_INLINE_RESULT_CHARS:
        offload = _offload_result_to_drive(command_id, full_text)
        if offload:
            meta["drive_offload"] = offload
            preview = base_text[:SHEET_INLINE_RESULT_CHARS]
            text = (
                f"{preview}\n...[full result offloaded to Google Drive: {offload['relative_path']}]"
                f"\n\nRELAY_METADATA: {json.dumps(meta, sort_keys=True)}"
            )
            truncated = True
        else:
            meta["drive_offload"] = {"status": "unavailable", "reason": "drive_mount_not_found"}
            text = f"{base_text}\n\nRELAY_METADATA: {json.dumps(meta, sort_keys=True)}"
    else:
        text = full_text
    if len(text) > SHEET_CELL_SAFE_CHARS:
        truncated = True
        text = text[:SHEET_CELL_SAFE_CHARS] + "\n...[truncated by sheet_relay; Drive offload unavailable]"
    return {
        "action": "result",
        "command_id": command_id,
        "ok": status == "done",
        "status": status,
        "result_status": "completed" if status == "done" else "error",
        "http_status": http_status,
        "result_text": text,
        "error": error,
        "duration_ms": int((time.time() - started) * 1000),
        "result_sha256": hashlib.sha256(text.encode("utf-8", errors="replace")).hexdigest(),
        "truncated": truncated,
        "metadata": meta,
    }