Spaces:
Sleeping
Sleeping
NullState Team commited on
Commit ·
e94087f
1
Parent(s): 3b43e5e
Initial Space: NullState Gateway UI
Browse files- README.md +16 -7
- app.py +96 -0
- requirements.txt +2 -0
README.md
CHANGED
|
@@ -1,13 +1,22 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: gradio
|
| 7 |
-
sdk_version:
|
| 8 |
-
python_version: '3.13'
|
| 9 |
app_file: app.py
|
| 10 |
pinned: false
|
|
|
|
| 11 |
---
|
| 12 |
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
title: NullState Gateway
|
| 3 |
+
emoji: ⚡
|
| 4 |
+
colorFrom: green
|
| 5 |
+
colorTo: dark
|
| 6 |
sdk: gradio
|
| 7 |
+
sdk_version: "5.0"
|
|
|
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
+
license: mit
|
| 11 |
---
|
| 12 |
|
| 13 |
+
# NullState Gateway
|
| 14 |
+
|
| 15 |
+
AI agent payment infrastructure. Self-hosted, open-source, multi-protocol.
|
| 16 |
+
|
| 17 |
+
- **x402**: HTTP 402 micropayments
|
| 18 |
+
- **AP2**: Agent-to-agent mandates
|
| 19 |
+
- **MCP**: Model Context Protocol
|
| 20 |
+
- **KYA**: Agent identity
|
| 21 |
+
|
| 22 |
+
[Full gateway →](https://greensol.me/nullstate)
|
app.py
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import requests
|
| 3 |
+
import json
|
| 4 |
+
import os
|
| 5 |
+
from datetime import datetime
|
| 6 |
+
|
| 7 |
+
GATEWAY_URL = os.environ.get("NULLSTATE_GATEWAY_URL", "https://greensol.me/nullstate")
|
| 8 |
+
|
| 9 |
+
def fetch_status():
|
| 10 |
+
try:
|
| 11 |
+
r = requests.get(f"{GATEWAY_URL}/health", timeout=10, verify=False)
|
| 12 |
+
data = r.json()
|
| 13 |
+
return (
|
| 14 |
+
f"Tasks: {data.get('tasks', 'N/A')}\n"
|
| 15 |
+
f"Ledger: {data.get('ledger', 'N/A')}\n"
|
| 16 |
+
f"Balance: ${data.get('balance', '0.00')} USDC\n"
|
| 17 |
+
f"AI: {data.get('ai_model', 'N/A')}\n"
|
| 18 |
+
f"Pricing: {data.get('pricing', 'N/A')}"
|
| 19 |
+
)
|
| 20 |
+
except Exception as e:
|
| 21 |
+
return f"Gateway unreachable: {e}"
|
| 22 |
+
|
| 23 |
+
def get_kya_challenge():
|
| 24 |
+
try:
|
| 25 |
+
r = requests.get(f"{GATEWAY_URL}/kya/challenge", timeout=10, verify=False)
|
| 26 |
+
return r.text
|
| 27 |
+
except Exception as e:
|
| 28 |
+
return f"Error: {e}"
|
| 29 |
+
|
| 30 |
+
def submit_solution(task_id: str, solution: str):
|
| 31 |
+
try:
|
| 32 |
+
r = requests.post(
|
| 33 |
+
f"{GATEWAY_URL}/mcp",
|
| 34 |
+
json={
|
| 35 |
+
"jsonrpc": "2.0",
|
| 36 |
+
"id": 1,
|
| 37 |
+
"method": "tools/call",
|
| 38 |
+
"params": {"name": "submit_solution", "arguments": {"task_id": task_id, "solution": solution}}
|
| 39 |
+
},
|
| 40 |
+
timeout=15,
|
| 41 |
+
verify=False
|
| 42 |
+
)
|
| 43 |
+
return json.dumps(r.json(), indent=2)
|
| 44 |
+
except Exception as e:
|
| 45 |
+
return f"Error: {e}"
|
| 46 |
+
|
| 47 |
+
def query_intelligence(prompt: str):
|
| 48 |
+
try:
|
| 49 |
+
r = requests.post(
|
| 50 |
+
f"{GATEWAY_URL}/mcp",
|
| 51 |
+
json={
|
| 52 |
+
"jsonrpc": "2.0",
|
| 53 |
+
"id": 1,
|
| 54 |
+
"method": "tools/call",
|
| 55 |
+
"params": {"name": "get_intelligence", "arguments": {"prompt": prompt}}
|
| 56 |
+
},
|
| 57 |
+
timeout=30,
|
| 58 |
+
verify=False
|
| 59 |
+
)
|
| 60 |
+
return json.dumps(r.json(), indent=2)
|
| 61 |
+
except Exception as e:
|
| 62 |
+
return f"Error: {e}"
|
| 63 |
+
|
| 64 |
+
with gr.Blocks(theme=gr.themes.Soft(primary_hue="green"), title="NullState Gateway") as demo:
|
| 65 |
+
gr.Markdown("""# ⚡ NullState Gateway
|
| 66 |
+
**Payment Infrastructure for AI Agents** — x402 · AP2 · MCP · KYA
|
| 67 |
+
""")
|
| 68 |
+
|
| 69 |
+
with gr.Tab("Status"):
|
| 70 |
+
status_btn = gr.Button("Refresh Status", variant="primary")
|
| 71 |
+
status_output = gr.Textbox(label="Gateway Health", lines=6)
|
| 72 |
+
status_btn.click(fn=fetch_status, outputs=status_output)
|
| 73 |
+
|
| 74 |
+
with gr.Tab("KYA Challenge"):
|
| 75 |
+
kya_btn = gr.Button("Get KYA Challenge", variant="primary")
|
| 76 |
+
kya_output = gr.Textbox(label="Challenge Response", lines=8)
|
| 77 |
+
kya_btn.click(fn=get_kya_challenge, outputs=kya_output)
|
| 78 |
+
|
| 79 |
+
with gr.Tab("Submit Solution"):
|
| 80 |
+
task_id = gr.Textbox(label="Task ID", placeholder="task_abc123")
|
| 81 |
+
solution = gr.Textbox(label="Solution", lines=4, placeholder="Your solution here...")
|
| 82 |
+
submit_btn = gr.Button("Submit", variant="primary")
|
| 83 |
+
submit_output = gr.Textbox(label="Response", lines=6)
|
| 84 |
+
submit_btn.click(fn=submit_solution, inputs=[task_id, solution], outputs=submit_output)
|
| 85 |
+
|
| 86 |
+
with gr.Tab("Query AI"):
|
| 87 |
+
prompt = gr.Textbox(label="Prompt", lines=3, placeholder="Ask NullState AI...")
|
| 88 |
+
query_btn = gr.Button("Query", variant="primary")
|
| 89 |
+
query_output = gr.Textbox(label="Response", lines=8)
|
| 90 |
+
query_btn.click(fn=query_intelligence, inputs=[prompt], outputs=query_output)
|
| 91 |
+
|
| 92 |
+
gr.Markdown("""---
|
| 93 |
+
Built with ❤️ by [NullState](https://greensol.me/nullstate) — Open-source MIT
|
| 94 |
+
""")
|
| 95 |
+
|
| 96 |
+
demo.launch()
|
requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
gradio>=5.0
|
| 2 |
+
requests>=2.31.0
|