From 59d9859a486e9c02782ef636f4797c544c92812a Mon Sep 17 00:00:00 2001 From: chrischristiansen-glitch Date: Tue, 26 May 2026 00:37:04 +0200 Subject: [PATCH] fix(deploy): legg til Procfile + main.py for Cloud Run Buildpacks entrypoint --- Procfile | 1 + main.py | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 Procfile create mode 100644 main.py diff --git a/Procfile b/Procfile new file mode 100644 index 0000000..302d889 --- /dev/null +++ b/Procfile @@ -0,0 +1 @@ +web: gunicorn main:app --bind 0.0.0.0:$PORT --workers 1 --threads 8 --timeout 120 diff --git a/main.py b/main.py new file mode 100644 index 0000000..e8c65b0 --- /dev/null +++ b/main.py @@ -0,0 +1,53 @@ +#!/usr/bin/env python3 +""" +main.py — Cloud Run entrypoint for OSVauco OPAX agent. +Exposes a minimal Flask HTTP API that wraps agent.run(). +""" + +import os +import sys + +# Ensure agents/core-logic is on the path +sys.path.insert(0, os.path.join(os.path.dirname(__file__), "agents", "core-logic")) + +from flask import Flask, request, jsonify +from agent import run # agents/core-logic/agent.py + +app = Flask(__name__) + + +@app.route("/health", methods=["GET"]) +def health(): + return jsonify({"status": "ok"}) + + +@app.route("/run", methods=["POST"]) +def run_agent(): + body = request.get_json(force=True, silent=True) or {} + message = body.get("message", "") + user_id = body.get("user_id", "opax") + session_id = body.get("session_id", "default") + mode = body.get("mode", "A") + + if not message: + return jsonify({"error": "'message' field required"}), 400 + + try: + response = run( + message=message, + user_id=user_id, + session_id=session_id, + mode=mode, + ) + return jsonify({"response": response}) + except PermissionError as e: + return jsonify({"error": str(e)}), 403 + except ValueError as e: + return jsonify({"error": str(e)}), 400 + except Exception as e: + return jsonify({"error": str(e)}), 500 + + +if __name__ == "__main__": + port = int(os.environ.get("PORT", 8080)) + app.run(host="0.0.0.0", port=port)