feat(OX1b+CG4): Embedded TUI i opax.html + token intelligence endepunkter
OX1b: - opax.html: ny TUI-panel med xterm.js via /opax/tui-proxy WebSocket-bridge - Jason-chat flyttes til primærpanel, TUI som sekundærfane - Fullskjerm-toggle, kopier output, klar-knapp CG4a: - app.py: GET /billing/tokens/by-module — aggreger per module_name + caller_type - app.py: GET /billing/tokens/estimate — prosjektestimator (snitt-tokens × faktor) - Begge fallback til tomme lister ved BQ-feil (OQ-15 safe) ROADMAP: OX1a ✅, OX1b ✅, CG4a ✅ — oppdatert NOW/NEXT
This commit is contained in:
parent
1c447c4d3a
commit
749a107e9d
|
|
@ -80,13 +80,13 @@ async def _ensure_session(user_id: str, session_id: str):
|
|||
return session
|
||||
|
||||
|
||||
# ── helse ──────────────────────────────────────────────────────────────────────────────
|
||||
# ── helse ────────────────────────────────────────────────────────────────────
|
||||
@app.get("/health")
|
||||
async def health():
|
||||
return JSONResponse({"status": "ok", "service": APP_NAME})
|
||||
|
||||
|
||||
# ── agent run ───────────────────────────────────────────────────────────────────
|
||||
# ── agent run ────────────────────────────────────────────────────────────────
|
||||
@app.post("/run", response_model=RunResponse)
|
||||
async def run(req: RunRequest):
|
||||
try:
|
||||
|
|
@ -108,58 +108,35 @@ async def run(req: RunRequest):
|
|||
raise HTTPException(status_code=500, detail=str(e))
|
||||
|
||||
|
||||
# ── OX1a: Cloud Build status ────────────────────────────────────────────────────────
|
||||
# ── OX1a: Cloud Build status ──────────────────────────────────────────────────
|
||||
@app.get("/opax/build-status")
|
||||
async def build_status():
|
||||
"""
|
||||
OX1a — Hent siste Cloud Build-kjøring for OSVauco-repoet.
|
||||
Returnerer status, tidspunkt og varighet slik at opax.html kan vise
|
||||
live build-widget (spinner → ✅/❌).
|
||||
|
||||
Tilstandsverdier fra Cloud Build API:
|
||||
QUEUED, WORKING → bygger nå (vis spinner)
|
||||
SUCCESS → ok
|
||||
FAILURE / TIMEOUT / CANCELLED / INTERNAL_ERROR → feil
|
||||
OX1a — Hent siste Cloud Build-kjøring.
|
||||
Status: queued|working|success|failure|timeout|cancelled|unknown
|
||||
"""
|
||||
try:
|
||||
from google.cloud.devtools import cloudbuild_v1
|
||||
client = cloudbuild_v1.CloudBuildClient()
|
||||
|
||||
# Hent siste 5 builds for prosjektet
|
||||
request = cloudbuild_v1.ListBuildsRequest(
|
||||
project_id=PROJECT_ID,
|
||||
filter='trigger_id!=""', # kun trigger-builds, ikke manuelle
|
||||
filter='trigger_id!=""',
|
||||
page_size=5,
|
||||
)
|
||||
builds = list(client.list_builds(request=request))
|
||||
|
||||
if not builds:
|
||||
return JSONResponse({"status": "unknown", "message": "Ingen builds funnet"})
|
||||
|
||||
b = builds[0] # nyeste
|
||||
status_map = {
|
||||
1: "queued",
|
||||
2: "working",
|
||||
3: "success",
|
||||
4: "failure",
|
||||
5: "internal_error",
|
||||
6: "timeout",
|
||||
7: "cancelled",
|
||||
}
|
||||
b = builds[0]
|
||||
status_map = {1:"queued",2:"working",3:"success",4:"failure",5:"internal_error",6:"timeout",7:"cancelled"}
|
||||
status_str = status_map.get(int(b.status), "unknown")
|
||||
|
||||
# Beregn varighet
|
||||
duration_s = None
|
||||
start = b.start_time
|
||||
finish = b.finish_time
|
||||
if start and finish:
|
||||
duration_s = int((finish.seconds - start.seconds))
|
||||
elif start:
|
||||
if b.start_time and b.finish_time:
|
||||
duration_s = int(b.finish_time.seconds - b.start_time.seconds)
|
||||
elif b.start_time:
|
||||
import time
|
||||
duration_s = int(time.time() - start.seconds)
|
||||
|
||||
duration_s = int(time.time() - b.start_time.seconds)
|
||||
return JSONResponse({
|
||||
"status": status_str, # queued|working|success|failure|timeout|cancelled
|
||||
"status": status_str,
|
||||
"build_id": b.id,
|
||||
"trigger_id": b.build_trigger_id or "",
|
||||
"branch": (b.substitutions or {}).get("BRANCH_NAME", "main"),
|
||||
|
|
@ -174,7 +151,99 @@ async def build_status():
|
|||
return JSONResponse({"status": "error", "message": str(e)}, status_code=200)
|
||||
|
||||
|
||||
# ── billing: tokens ──────────────────────────────────────────────────────────────────
|
||||
# ── CG4a: Token intelligence — per modul ─────────────────────────────────────
|
||||
@app.get("/billing/tokens/by-module")
|
||||
async def tokens_by_module(days: int = 30):
|
||||
"""
|
||||
CG4a — Token-forbruk aggregert per module_name + caller_type.
|
||||
Brukes av opax.html TUI + fremtidig token-panel i billing dashboard.
|
||||
Fallback: tom liste hvis BQ mangler data (OQ-15 safe).
|
||||
"""
|
||||
try:
|
||||
from google.cloud import bigquery
|
||||
client = bigquery.Client(project=PROJECT_ID)
|
||||
query = f"""
|
||||
SELECT
|
||||
COALESCE(module_name, 'ukjent') AS module_name,
|
||||
COALESCE(caller_type, 'ukjent') AS caller_type,
|
||||
model_name,
|
||||
COUNT(*) AS calls,
|
||||
SUM(input_tokens) AS input_tokens,
|
||||
SUM(output_tokens) AS output_tokens,
|
||||
SUM(total_tokens) AS total_tokens,
|
||||
ROUND(SUM(estimated_cost_usd), 6) AS cost_usd
|
||||
FROM `{PROJECT_ID}.{BQ_BILLING_DATASET}.llm_token_usage`
|
||||
WHERE timestamp >= TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL {int(days)} DAY)
|
||||
GROUP BY module_name, caller_type, model_name
|
||||
ORDER BY cost_usd DESC
|
||||
LIMIT 100
|
||||
"""
|
||||
rows = [
|
||||
{
|
||||
"module_name": row.module_name,
|
||||
"caller_type": row.caller_type,
|
||||
"model_name": row.model_name,
|
||||
"calls": row.calls,
|
||||
"input_tokens": row.input_tokens,
|
||||
"output_tokens":row.output_tokens,
|
||||
"total_tokens": row.total_tokens,
|
||||
"cost_usd": float(row.cost_usd),
|
||||
}
|
||||
for row in client.query(query).result()
|
||||
]
|
||||
return JSONResponse({"period_days": days, "rows": rows})
|
||||
except Exception as e:
|
||||
logger.error(f"[/billing/tokens/by-module] Failed: {e}", exc_info=True)
|
||||
return JSONResponse({"period_days": days, "rows": [], "warning": str(e)})
|
||||
|
||||
|
||||
# ── CG4c: Prosjektestimator ───────────────────────────────────────────────────
|
||||
@app.get("/billing/tokens/estimate")
|
||||
async def tokens_estimate(complexity: str = "medium"):
|
||||
"""
|
||||
CG4c — Prosjektestimator.
|
||||
Henter snitt-tokens per kall siste 30 dager, multipliserer med kompleksitetsfaktor.
|
||||
complexity: low | medium | high | extreme
|
||||
Returnerer estimert kostnad i USD for et nytt oppdrag.
|
||||
"""
|
||||
factors = {"low": 0.5, "medium": 1.0, "high": 2.5, "extreme": 6.0}
|
||||
factor = factors.get(complexity, 1.0)
|
||||
try:
|
||||
from google.cloud import bigquery
|
||||
client = bigquery.Client(project=PROJECT_ID)
|
||||
query = f"""
|
||||
SELECT
|
||||
AVG(total_tokens) AS avg_tokens_per_call,
|
||||
AVG(estimated_cost_usd) AS avg_cost_per_call,
|
||||
COUNT(*) AS total_calls,
|
||||
SUM(estimated_cost_usd) AS total_cost_usd
|
||||
FROM `{PROJECT_ID}.{BQ_BILLING_DATASET}.llm_token_usage`
|
||||
WHERE timestamp >= TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 30 DAY)
|
||||
"""
|
||||
result = list(client.query(query).result())
|
||||
if not result or result[0].avg_tokens_per_call is None:
|
||||
return JSONResponse({"complexity": complexity, "factor": factor, "estimated_usd": None, "warning": "Ingen data ennå (OQ-15)"})
|
||||
row = result[0]
|
||||
avg_cost = float(row.avg_cost_per_call or 0)
|
||||
# Estimat: 1 oppdrag = 20 kall snitt × faktor
|
||||
CALLS_PER_TASK = 20
|
||||
estimated = round(avg_cost * CALLS_PER_TASK * factor, 4)
|
||||
return JSONResponse({
|
||||
"complexity": complexity,
|
||||
"factor": factor,
|
||||
"avg_tokens_per_call": round(float(row.avg_tokens_per_call or 0), 1),
|
||||
"avg_cost_per_call": round(avg_cost, 6),
|
||||
"total_calls_30d": row.total_calls,
|
||||
"total_cost_30d_usd": round(float(row.total_cost_usd or 0), 4),
|
||||
"estimated_usd": estimated,
|
||||
"calls_assumed": CALLS_PER_TASK,
|
||||
})
|
||||
except Exception as e:
|
||||
logger.error(f"[/billing/tokens/estimate] Failed: {e}", exc_info=True)
|
||||
return JSONResponse({"complexity": complexity, "estimated_usd": None, "warning": str(e)})
|
||||
|
||||
|
||||
# ── billing: tokens summary (eksisterende) ────────────────────────────────────
|
||||
@app.get("/billing/tokens/summary")
|
||||
async def billing_tokens_summary():
|
||||
try:
|
||||
|
|
@ -182,9 +251,7 @@ async def billing_tokens_summary():
|
|||
client = bigquery.Client(project=PROJECT_ID)
|
||||
query = f"""
|
||||
SELECT
|
||||
module_name,
|
||||
caller_type,
|
||||
model_name,
|
||||
module_name, caller_type, model_name,
|
||||
SUM(input_tokens) AS total_input_tokens,
|
||||
SUM(output_tokens) AS total_output_tokens,
|
||||
SUM(total_tokens) AS total_tokens,
|
||||
|
|
@ -212,7 +279,6 @@ async def billing_tokens_summary():
|
|||
raise HTTPException(status_code=500, detail=str(e))
|
||||
|
||||
|
||||
# ── billing: anbefalinger ─────────────────────────────────────────────────────────────
|
||||
@app.get("/billing/recommendations")
|
||||
async def billing_recommendations(budget: float = 500.0):
|
||||
try:
|
||||
|
|
@ -227,8 +293,7 @@ async def billing_recommendations(budget: float = 500.0):
|
|||
async def billing_by_service(days: int = 30):
|
||||
try:
|
||||
from ml.billing_agent import BillingAgent
|
||||
agent = BillingAgent()
|
||||
return JSONResponse(agent.get_service_totals(days))
|
||||
return JSONResponse(BillingAgent().get_service_totals(days))
|
||||
except Exception as e:
|
||||
logger.error(f"[/billing/by-service] Failed: {e}", exc_info=True)
|
||||
return JSONResponse([])
|
||||
|
|
@ -238,8 +303,7 @@ async def billing_by_service(days: int = 30):
|
|||
async def billing_anomalies():
|
||||
try:
|
||||
from ml.billing_agent import BillingAgent
|
||||
agent = BillingAgent()
|
||||
return JSONResponse(agent.get_anomalies())
|
||||
return JSONResponse(BillingAgent().get_anomalies())
|
||||
except Exception as e:
|
||||
logger.error(f"[/billing/anomalies] Failed: {e}", exc_info=True)
|
||||
return JSONResponse({"anomalies": []})
|
||||
|
|
@ -249,8 +313,7 @@ async def billing_anomalies():
|
|||
async def billing_history(days: int = 30):
|
||||
try:
|
||||
from ml.billing_agent import BillingAgent
|
||||
agent = BillingAgent()
|
||||
return JSONResponse({"history": agent.get_daily_history(days)})
|
||||
return JSONResponse({"history": BillingAgent().get_daily_history(days)})
|
||||
except Exception as e:
|
||||
logger.error(f"[/billing/history] Failed: {e}", exc_info=True)
|
||||
return JSONResponse({"history": []})
|
||||
|
|
@ -260,8 +323,7 @@ async def billing_history(days: int = 30):
|
|||
async def billing_summary():
|
||||
try:
|
||||
from ml.billing_agent import BillingAgent
|
||||
agent = BillingAgent()
|
||||
return JSONResponse(agent.get_summary())
|
||||
return JSONResponse(BillingAgent().get_summary())
|
||||
except Exception as e:
|
||||
logger.error(f"[/billing/summary] Failed: {e}", exc_info=True)
|
||||
return JSONResponse({"summary": []})
|
||||
|
|
@ -271,8 +333,7 @@ async def billing_summary():
|
|||
async def billing_live():
|
||||
try:
|
||||
from ml.billing_agent import BillingAgent
|
||||
agent = BillingAgent()
|
||||
return JSONResponse(agent.get_forecast())
|
||||
return JSONResponse(BillingAgent().get_forecast())
|
||||
except Exception as e:
|
||||
logger.error(f"[/billing/live] Failed: {e}", exc_info=True)
|
||||
return JSONResponse({})
|
||||
|
|
@ -280,8 +341,7 @@ async def billing_live():
|
|||
|
||||
@app.get("/billing/budget")
|
||||
async def get_budget(user: str = "default"):
|
||||
budget = _budget_store.get(user, 500.0)
|
||||
return JSONResponse({"budget": budget, "user": user})
|
||||
return JSONResponse({"budget": _budget_store.get(user, 500.0), "user": user})
|
||||
|
||||
|
||||
@app.post("/billing/budget")
|
||||
|
|
@ -289,5 +349,4 @@ async def set_budget(req: BudgetRequest):
|
|||
if req.budget <= 0:
|
||||
raise HTTPException(status_code=400, detail="Budget must be > 0")
|
||||
_budget_store[req.user] = req.budget
|
||||
logger.info(f"Budget updated: {req.user} -> {req.budget}")
|
||||
return JSONResponse({"budget": req.budget, "user": req.user})
|
||||
|
|
|
|||
562
static/opax.html
562
static/opax.html
|
|
@ -14,7 +14,6 @@
|
|||
--accent:#7c5cff;--accent-2:#00d4a8;--accent-glow:rgba(124,92,255,0.22);
|
||||
--green:#3ecf8e;--amber:#ffb547;--danger:#ff5c7c;
|
||||
--radius:12px;--radius-lg:18px;
|
||||
--shadow:0 8px 32px rgba(0,0,0,0.4);
|
||||
--sans:-apple-system,BlinkMacSystemFont,'Inter','SF Pro Display',system-ui,sans-serif;
|
||||
--mono:'SF Mono',ui-monospace,'JetBrains Mono',Menlo,monospace;
|
||||
}
|
||||
|
|
@ -26,14 +25,15 @@
|
|||
::-webkit-scrollbar-thumb{background:var(--bg-3);border-radius:6px}
|
||||
::-webkit-scrollbar-track{background:transparent}
|
||||
|
||||
.topbar{position:sticky;top:0;z-index:100;display:flex;align-items:center;justify-content:space-between;padding:14px 28px;background:rgba(10,10,15,0.82);backdrop-filter:blur(20px);border-bottom:1px solid var(--border)}
|
||||
/* topbar */
|
||||
.topbar{position:sticky;top:0;z-index:100;display:flex;align-items:center;justify-content:space-between;padding:14px 28px;background:rgba(10,10,15,0.88);backdrop-filter:blur(20px);border-bottom:1px solid var(--border)}
|
||||
.topbar-brand{display:flex;align-items:center;gap:12px}
|
||||
.logo-mark{width:30px;height:30px;border-radius:9px;background:linear-gradient(135deg,var(--accent),var(--accent-2));display:flex;align-items:center;justify-content:center;color:#0a0a0f;flex-shrink:0}
|
||||
.topbar-name{font-weight:800;font-size:16px;letter-spacing:-0.02em}
|
||||
.topbar-sep{color:var(--text-faint);font-weight:300}
|
||||
.topbar-sub{color:var(--text-dim);font-size:14px}
|
||||
.topbar-right{display:flex;align-items:center;gap:18px;flex-wrap:wrap;justify-content:flex-end}
|
||||
.status-pill{display:inline-flex;align-items:center;gap:7px;padding:5px 12px;border-radius:99px;background:var(--bg-3);border:1px solid var(--border);font-size:12px;color:var(--text-dim);font-weight:500}
|
||||
.topbar-right{display:flex;align-items:center;gap:14px;flex-wrap:wrap;justify-content:flex-end}
|
||||
.status-pill{display:inline-flex;align-items:center;gap:7px;padding:5px 12px;border-radius:99px;background:var(--bg-3);border:1px solid var(--border);font-size:12px;color:var(--text-dim);font-weight:500;cursor:default}
|
||||
.dot{width:7px;height:7px;border-radius:50%;background:var(--green);flex-shrink:0}
|
||||
.dot.amber{background:var(--amber)}
|
||||
.dot.red{background:var(--danger)}
|
||||
|
|
@ -42,8 +42,9 @@
|
|||
@keyframes pulse{0%,100%{opacity:1}50%{opacity:.35}}
|
||||
.topbar-id{font-family:var(--mono);font-size:11px;color:var(--text-faint)}
|
||||
|
||||
/* shell */
|
||||
.shell{display:flex;min-height:calc(100vh - 60px)}
|
||||
.sidebar{width:230px;flex-shrink:0;padding:24px 16px;border-right:1px solid var(--border);display:flex;flex-direction:column;gap:4px;position:sticky;top:60px;height:calc(100vh - 60px)}
|
||||
.sidebar{width:230px;flex-shrink:0;padding:24px 16px;border-right:1px solid var(--border);display:flex;flex-direction:column;gap:4px;position:sticky;top:60px;height:calc(100vh - 60px);overflow-y:auto}
|
||||
.side-label{font-size:11px;text-transform:uppercase;letter-spacing:0.08em;color:var(--text-faint);font-weight:600;padding:14px 12px 6px}
|
||||
.nav-item{display:flex;align-items:center;gap:10px;padding:9px 12px;border-radius:9px;font-size:14px;color:var(--text-dim);font-weight:500;transition:background .15s,color .15s}
|
||||
.nav-item:hover{background:var(--bg-2);color:var(--text)}
|
||||
|
|
@ -54,9 +55,10 @@
|
|||
.nav-badge.soon{background:rgba(255,181,71,0.1);color:var(--amber);border-color:rgba(255,181,71,0.18)}
|
||||
.side-foot{margin-top:auto;padding-top:16px;border-top:1px solid var(--border)}
|
||||
.me-card{padding:10px 12px;border-radius:10px;background:var(--bg-2);border:1px solid var(--border)}
|
||||
.me-name{font-size:12px;font-weight:600;color:var(--text)}
|
||||
.me-name{font-size:12px;font-weight:600}
|
||||
.me-role{font-size:11px;color:var(--text-faint);margin-top:2px;font-family:var(--mono)}
|
||||
|
||||
/* main */
|
||||
.main{flex:1;padding:32px 40px 56px;max-width:1180px;width:100%}
|
||||
.page-head{margin-bottom:36px}
|
||||
.page-title{font-size:30px;font-weight:800;letter-spacing:-0.03em;background:linear-gradient(180deg,#fff 0%,#a8aabc 100%);-webkit-background-clip:text;background-clip:text;-webkit-text-fill-color:transparent;padding-bottom:.08em}
|
||||
|
|
@ -66,6 +68,7 @@
|
|||
.section-label{font-size:13px;text-transform:uppercase;letter-spacing:0.1em;color:var(--text-faint);font-weight:700}
|
||||
.section-line{flex:1;height:1px;background:var(--border)}
|
||||
|
||||
/* cards */
|
||||
.grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(290px,1fr));gap:18px}
|
||||
.card{padding:24px;background:var(--bg-2);border:1px solid var(--border);border-radius:var(--radius-lg);transition:border-color .2s,transform .2s,background .2s;position:relative;overflow:hidden}
|
||||
.card.clickable{cursor:pointer}
|
||||
|
|
@ -79,10 +82,10 @@
|
|||
.card-name{font-size:17px;font-weight:700;letter-spacing:-0.01em}
|
||||
.card-desc{font-size:13.5px;color:var(--text-dim);margin-top:8px;line-height:1.55}
|
||||
.card-meta{display:flex;flex-wrap:wrap;gap:14px;margin-top:18px;font-size:12px;color:var(--text-faint);font-family:var(--mono)}
|
||||
.card-meta span{display:inline-flex;align-items:center;gap:6px}
|
||||
.card-link{display:inline-flex;align-items:center;gap:7px;margin-top:18px;font-size:13px;font-weight:600;color:var(--accent)}
|
||||
.card-link:hover{color:#9b80ff}
|
||||
|
||||
/* agents */
|
||||
.agent-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(280px,1fr));gap:14px}
|
||||
.agent-row{display:flex;align-items:center;gap:14px;padding:16px 18px;background:var(--bg-2);border:1px solid var(--border);border-radius:var(--radius);transition:border-color .2s,background .2s}
|
||||
.agent-row.actionable{cursor:pointer}
|
||||
|
|
@ -92,6 +95,25 @@
|
|||
.agent-go{margin-left:auto;font-size:11px;color:var(--accent);font-weight:600;opacity:0;transition:opacity .2s}
|
||||
.agent-row.actionable:hover .agent-go{opacity:1}
|
||||
|
||||
/* build widget */
|
||||
.build-widget{padding:20px 24px;background:var(--bg-2);border:1px solid var(--border);border-radius:var(--radius-lg);display:flex;align-items:center;gap:20px;flex-wrap:wrap}
|
||||
.build-icon{width:44px;height:44px;border-radius:12px;flex-shrink:0;background:var(--bg-3);border:1px solid var(--border-2);display:flex;align-items:center;justify-content:center}
|
||||
.build-info{flex:1;min-width:180px}
|
||||
.build-title{font-size:14px;font-weight:700;margin-bottom:3px}
|
||||
.build-meta{font-size:12px;color:var(--text-faint);font-family:var(--mono)}
|
||||
.build-status-row{display:flex;align-items:center;gap:10px;margin-top:8px;flex-wrap:wrap}
|
||||
.build-badge{display:inline-flex;align-items:center;gap:6px;padding:4px 12px;border-radius:99px;font-size:12px;font-weight:600}
|
||||
.build-badge.working{background:rgba(255,181,71,0.12);color:var(--amber);border:1px solid rgba(255,181,71,0.25)}
|
||||
.build-badge.success{background:rgba(62,207,142,0.12);color:var(--green);border:1px solid rgba(62,207,142,0.22)}
|
||||
.build-badge.failure,.build-badge.timeout,.build-badge.internal_error{background:rgba(255,92,124,0.1);color:var(--danger);border:1px solid rgba(255,92,124,0.2)}
|
||||
.build-badge.queued,.build-badge.unknown,.build-badge.error{background:var(--bg-3);color:var(--text-dim);border:1px solid var(--border)}
|
||||
.build-spinner{width:14px;height:14px;border-radius:50%;border:2px solid var(--amber);border-top-color:transparent;animation:spin .7s linear infinite;flex-shrink:0}
|
||||
@keyframes spin{to{transform:rotate(360deg)}}
|
||||
.build-duration,.build-commit{font-size:11px;color:var(--text-faint);font-family:var(--mono)}
|
||||
.build-log-link{font-size:12px;color:var(--accent);font-weight:600}
|
||||
.build-log-link:hover{color:#9b80ff}
|
||||
|
||||
/* infra */
|
||||
.infra-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(220px,1fr));gap:14px}
|
||||
.infra-item{padding:16px 18px;background:var(--bg-2);border:1px solid var(--border);border-radius:var(--radius)}
|
||||
.infra-label{font-size:11px;text-transform:uppercase;letter-spacing:0.06em;color:var(--text-faint);font-weight:600;margin-bottom:6px}
|
||||
|
|
@ -100,502 +122,42 @@
|
|||
.infra-value.warn{color:var(--amber)}
|
||||
.infra-value.neutral{color:var(--text)}
|
||||
|
||||
/* ── Build widget (OX1a) ────────────────────────────────────────────────────────── */
|
||||
.build-widget{
|
||||
padding:20px 24px;background:var(--bg-2);
|
||||
border:1px solid var(--border);border-radius:var(--radius-lg);
|
||||
display:flex;align-items:center;gap:20px;flex-wrap:wrap;
|
||||
/* ── OX1b: TUI panel ── */
|
||||
.tui-panel{
|
||||
background:var(--bg-2);border:1px solid var(--border);
|
||||
border-radius:var(--radius-lg);overflow:hidden;
|
||||
}
|
||||
.build-icon{
|
||||
width:44px;height:44px;border-radius:12px;flex-shrink:0;
|
||||
background:var(--bg-3);border:1px solid var(--border-2);
|
||||
display:flex;align-items:center;justify-content:center;
|
||||
.tui-head{
|
||||
display:flex;align-items:center;gap:10px;
|
||||
padding:12px 18px;border-bottom:1px solid var(--border);
|
||||
background:var(--bg-3);
|
||||
}
|
||||
.build-info{flex:1;min-width:180px}
|
||||
.build-title{font-size:14px;font-weight:700;margin-bottom:3px}
|
||||
.build-meta{font-size:12px;color:var(--text-faint);font-family:var(--mono)}
|
||||
.build-status-row{display:flex;align-items:center;gap:10px;margin-top:8px;flex-wrap:wrap}
|
||||
.build-badge{
|
||||
display:inline-flex;align-items:center;gap:6px;
|
||||
padding:4px 12px;border-radius:99px;
|
||||
font-size:12px;font-weight:600;
|
||||
.tui-tabs{display:flex;gap:2px}
|
||||
.tui-tab{
|
||||
padding:6px 14px;border-radius:8px;font-size:13px;font-weight:600;
|
||||
color:var(--text-dim);transition:background .15s,color .15s;
|
||||
}
|
||||
.build-badge.working{background:rgba(255,181,71,0.12);color:var(--amber);border:1px solid rgba(255,181,71,0.25)}
|
||||
.build-badge.success{background:rgba(62,207,142,0.12);color:var(--green);border:1px solid rgba(62,207,142,0.22)}
|
||||
.build-badge.failure,.build-badge.timeout,.build-badge.internal_error{
|
||||
background:rgba(255,92,124,0.1);color:var(--danger);border:1px solid rgba(255,92,124,0.2)}
|
||||
.build-badge.queued{background:var(--bg-3);color:var(--text-dim);border:1px solid var(--border)}
|
||||
.build-badge.unknown,.build-badge.error{background:var(--bg-3);color:var(--text-dim);border:1px solid var(--border)}
|
||||
.build-spinner{
|
||||
width:14px;height:14px;border-radius:50%;
|
||||
border:2px solid var(--amber);border-top-color:transparent;
|
||||
animation:spin .7s linear infinite;flex-shrink:0;
|
||||
.tui-tab:hover{background:var(--bg-2);color:var(--text)}
|
||||
.tui-tab.active{background:var(--accent);color:#fff}
|
||||
.tui-actions{margin-left:auto;display:flex;gap:8px}
|
||||
.tui-btn{
|
||||
padding:5px 12px;border-radius:8px;font-size:11px;font-weight:600;
|
||||
background:var(--bg-2);border:1px solid var(--border);color:var(--text-dim);
|
||||
transition:background .15s,color .15s;
|
||||
}
|
||||
@keyframes spin{to{transform:rotate(360deg)}}
|
||||
.build-duration{font-size:11px;color:var(--text-faint);font-family:var(--mono)}
|
||||
.build-log-link{font-size:12px;color:var(--accent);font-weight:600}
|
||||
.build-log-link:hover{color:#9b80ff}
|
||||
.build-commit{font-family:var(--mono);font-size:11px;color:var(--text-faint)}
|
||||
.tui-btn:hover{background:var(--bg-3);color:var(--text)}
|
||||
.tui-btn.danger:hover{background:rgba(255,92,124,0.12);color:var(--danger);border-color:rgba(255,92,124,0.25)}
|
||||
|
||||
.flow-box{padding:24px;background:var(--bg-2);border:1px solid var(--border);border-radius:var(--radius-lg);position:relative}
|
||||
.flow-box::after{content:'FASE 2 — IKKE AKTIVERT';position:absolute;top:18px;right:20px;font-size:10px;font-weight:700;letter-spacing:0.08em;color:var(--text-faint);font-family:var(--mono)}
|
||||
.flow-title{font-size:14px;font-weight:600;margin-bottom:18px}
|
||||
.flow-steps{display:flex;flex-wrap:wrap;align-items:center;gap:8px}
|
||||
.flow-step{padding:8px 14px;background:var(--bg-3);border:1px solid var(--border);border-radius:99px;font-size:12px;color:var(--text-dim);white-space:nowrap}
|
||||
.flow-arrow{color:var(--text-faint);font-size:13px}
|
||||
.flow-note{margin-top:16px;font-size:11px;color:var(--text-faint);font-family:var(--mono)}
|
||||
|
||||
.page-foot{display:flex;justify-content:space-between;flex-wrap:wrap;gap:10px;margin-top:48px;padding-top:20px;border-top:1px solid var(--border);font-size:11px;color:var(--text-faint);font-family:var(--mono)}
|
||||
|
||||
.chat-overlay{position:fixed;inset:0;background:rgba(0,0,0,0.55);backdrop-filter:blur(2px);z-index:200;opacity:0;pointer-events:none;transition:opacity .25s}
|
||||
.chat-overlay.open{opacity:1;pointer-events:auto}
|
||||
.chat-drawer{position:fixed;top:0;right:0;bottom:0;width:min(440px,100vw);background:var(--bg-2);border-left:1px solid var(--border-2);z-index:201;display:flex;flex-direction:column;transform:translateX(100%);transition:transform .28s cubic-bezier(.4,0,.2,1);box-shadow:-20px 0 60px rgba(0,0,0,0.5)}
|
||||
.chat-drawer.open{transform:translateX(0)}
|
||||
.chat-head{display:flex;align-items:center;gap:12px;padding:18px 20px;border-bottom:1px solid var(--border)}
|
||||
.chat-avatar{width:34px;height:34px;border-radius:10px;background:linear-gradient(135deg,var(--accent),var(--accent-2));display:flex;align-items:center;justify-content:center;color:#0a0a0f;font-weight:800;font-size:14px}
|
||||
.chat-title{font-size:15px;font-weight:700}
|
||||
.chat-sub{font-size:11px;color:var(--text-faint);font-family:var(--mono)}
|
||||
.chat-close{margin-left:auto;width:30px;height:30px;border-radius:8px;display:flex;align-items:center;justify-content:center;color:var(--text-dim)}
|
||||
.chat-close:hover{background:var(--bg-3);color:var(--text)}
|
||||
.chat-body{flex:1;overflow-y:auto;padding:20px;display:flex;flex-direction:column;gap:14px}
|
||||
.msg{max-width:85%;padding:11px 14px;border-radius:14px;font-size:14px;line-height:1.55;white-space:pre-wrap;word-wrap:break-word}
|
||||
.msg.user{align-self:flex-end;background:var(--accent);color:#fff;border-bottom-right-radius:4px}
|
||||
.msg.bot{align-self:flex-start;background:var(--bg-3);border:1px solid var(--border);border-bottom-left-radius:4px}
|
||||
.msg.err{align-self:flex-start;background:rgba(255,92,124,0.1);border:1px solid rgba(255,92,124,0.25);color:#ff9bb0}
|
||||
.msg.typing{align-self:flex-start;color:var(--text-faint);font-style:italic;font-size:13px;background:none;padding:4px 0}
|
||||
.chat-empty{margin:auto;text-align:center;color:var(--text-faint);font-size:13px;max-width:260px}
|
||||
.chat-empty svg{margin-bottom:12px;opacity:.5}
|
||||
.chat-foot{padding:14px 16px;border-top:1px solid var(--border);display:flex;gap:10px;align-items:flex-end}
|
||||
.chat-input{flex:1;background:var(--bg-3);border:1px solid var(--border-2);border-radius:12px;padding:11px 14px;color:var(--text);font-family:var(--sans);font-size:14px;resize:none;max-height:120px;line-height:1.5}
|
||||
.chat-input:focus{outline:none;border-color:var(--accent)}
|
||||
.chat-send{width:42px;height:42px;border-radius:11px;background:var(--accent);color:#fff;display:flex;align-items:center;justify-content:center;flex-shrink:0;transition:background .15s}
|
||||
.chat-send:hover{background:#6a4dee}
|
||||
.chat-send:disabled{opacity:.4;cursor:not-allowed}
|
||||
.mode-row{display:flex;gap:6px;padding:0 16px 12px}
|
||||
.mode-chip{font-size:11px;padding:4px 11px;border-radius:99px;background:var(--bg-3);border:1px solid var(--border);color:var(--text-dim);font-weight:600}
|
||||
.mode-chip.active{background:var(--accent);color:#fff;border-color:var(--accent)}
|
||||
|
||||
@media(max-width:860px){
|
||||
.shell{flex-direction:column}
|
||||
.sidebar{width:100%;height:auto;display:flex;flex-direction:row;align-items:center;overflow-x:auto;border-right:none;border-bottom:1px solid var(--border);padding:8px 12px;gap:6px;position:sticky;top:0;background:var(--bg-2);z-index:50}
|
||||
.sidebar::-webkit-scrollbar{display:none}
|
||||
.side-label{display:none}
|
||||
.nav-item{flex-shrink:0;white-space:nowrap;border-radius:99px;padding:8px 13px;align-self:center}
|
||||
.side-foot{display:none}
|
||||
.main{padding:22px 16px 48px}
|
||||
.topbar{padding:12px 16px;flex-wrap:wrap;gap:8px}
|
||||
.topbar-id{display:none}
|
||||
.topbar-sub{display:none}
|
||||
/* Chat-tab */
|
||||
.tui-chat-body{
|
||||
height:360px;overflow-y:auto;padding:20px;
|
||||
display:flex;flex-direction:column;gap:12px;
|
||||
background:#0c0d13;
|
||||
font-family:var(--mono);font-size:13px;
|
||||
}
|
||||
@media(max-width:560px){
|
||||
.chat-drawer{width:100vw}
|
||||
.topbar-right{width:100%;overflow-x:auto;flex-wrap:nowrap}
|
||||
.topbar-right::-webkit-scrollbar{display:none}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<header class="topbar">
|
||||
<div class="topbar-brand">
|
||||
<span class="logo-mark">
|
||||
<svg width="18" height="18" viewBox="0 0 20 20" fill="none" aria-label="OPAX">
|
||||
<polygon points="10,1 18,5.5 18,14.5 10,19 2,14.5 2,5.5" stroke="currentColor" stroke-width="1.4" fill="none"/>
|
||||
<circle cx="10" cy="10" r="2.2" fill="currentColor"/>
|
||||
</svg>
|
||||
</span>
|
||||
<span class="topbar-name">OPAX</span>
|
||||
<span class="topbar-sep">/</span>
|
||||
<span class="topbar-sub">Vauco Operator Hub</span>
|
||||
</div>
|
||||
<div class="topbar-right">
|
||||
<div class="status-pill" id="pill-run"><span class="dot dim pulse" id="dot-run"></span><span id="txt-run">kobler til…</span></div>
|
||||
<div class="status-pill" id="pill-build"><span class="dot dim" id="dot-build"></span><span id="txt-build">build…</span></div>
|
||||
<div class="topbar-id">propane-will-491900-m5 · us-central1</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div class="shell">
|
||||
<nav class="sidebar" aria-label="Navigasjon">
|
||||
<div class="side-label">Oversikt</div>
|
||||
<a class="nav-item active" href="#produkter">
|
||||
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="2" y="3" width="20" height="14" rx="2"/><path d="M8 21h8M12 17v4"/></svg>
|
||||
Produkter<span class="nav-badge live">1 live</span>
|
||||
</a>
|
||||
<a class="nav-item" href="#agenter">
|
||||
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="8" r="4"/><path d="M4 20c0-4 3.6-7 8-7s8 3 8 7"/></svg>
|
||||
Agenter<span class="nav-badge live">Jason</span>
|
||||
</a>
|
||||
<a class="nav-item" href="#deploy">
|
||||
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="16 18 22 12 16 6"/><polyline points="8 6 2 12 8 18"/></svg>
|
||||
Deploy<span class="nav-badge" id="nav-build-badge">-</span>
|
||||
</a>
|
||||
<a class="nav-item" href="#infrastruktur">
|
||||
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="2" y="2" width="20" height="8" rx="1"/><rect x="2" y="14" width="20" height="8" rx="1"/><path d="M6 6h.01M6 18h.01"/></svg>
|
||||
Infrastruktur
|
||||
</a>
|
||||
<a class="nav-item" href="#provisjonering">
|
||||
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07A19.5 19.5 0 0 1 4.14 12 19.79 19.79 0 0 1 1 3.18 2 2 0 0 1 3 1h3a2 2 0 0 1 2 1.72c.127.96.361 1.903.7 2.81a2 2 0 0 1-.45 2.11L7.09 8.91a16 16 0 0 0 5.99 5.99l1.27-1.27a2 2 0 0 1 2.11-.45c.907.339 1.85.573 2.81.7A2 2 0 0 1 22 16.92z"/></svg>
|
||||
Provisjonering<span class="nav-badge soon">fase 2</span>
|
||||
</a>
|
||||
<div class="side-label" style="margin-top:6px">Ressurser</div>
|
||||
<a class="nav-item" href="https://console.cloud.google.com/run?project=propane-will-491900-m5" target="_blank" rel="noopener">
|
||||
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/><polyline points="15 3 21 3 21 9"/><line x1="10" y1="14" x2="21" y2="3"/></svg>
|
||||
GCP Console
|
||||
</a>
|
||||
<a class="nav-item" href="https://github.com/vauco-saas/OSVauco" target="_blank" rel="noopener">
|
||||
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M9 19c-5 1.5-5-2.5-7-3m14 6v-3.87a3.37 3.37 0 0 0-.94-2.61c3.14-.35 6.44-1.54 6.44-7A5.44 5.44 0 0 0 20 4.77 5.07 5.07 0 0 0 19.91 1S18.73.65 16 2.48a13.38 13.38 0 0 0-7 0C6.27.65 5.09 1 5.09 1A5.07 5.07 0 0 0 5 4.77a5.44 5.44 0 0 0-1.5 3.78c0 5.42 3.3 6.61 6.44 7A3.37 3.37 0 0 0 9 18.13V22"/></svg>
|
||||
GitHub
|
||||
</a>
|
||||
<a class="nav-item" href="/static/billing-dashboard.html">
|
||||
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="22 12 18 12 15 21 9 3 6 12 2 12"/></svg>
|
||||
CostGuard Dashboard
|
||||
</a>
|
||||
<div class="side-foot">
|
||||
<div class="me-card">
|
||||
<div class="me-name">jason.vauger@vauco.no</div>
|
||||
<div class="me-role">billing.viewer · OPAX agent</div>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<main class="main">
|
||||
<div class="page-head">
|
||||
<div class="page-title">Operator Hub</div>
|
||||
<div class="page-desc">Vauco OS — intern plattform for drift, planlegging og kjøring av OPAX-moduler.</div>
|
||||
</div>
|
||||
|
||||
<!-- Produkter -->
|
||||
<section class="section" id="produkter">
|
||||
<div class="section-head"><span class="section-label">Produkter</span><span class="section-line"></span></div>
|
||||
<div class="grid">
|
||||
<div class="card clickable" onclick="location.href='/static/billing-dashboard.html'">
|
||||
<div class="card-top">
|
||||
<span class="card-icon"><svg width="18" height="18" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M10 2L17 6V14L10 18L3 14V6L10 2Z"/><circle cx="10" cy="10" r="2" fill="currentColor"/></svg></span>
|
||||
<span class="tag live">Live</span>
|
||||
</div>
|
||||
<div class="card-name">CostGuard</div>
|
||||
<div class="card-desc">Sanntids GCP-kostnadskontroll. Anomalideteksjon, budsjettvarsler, historikk og token-måler.</div>
|
||||
<div class="card-meta"><span>0 kunder</span><span>costguard.oss.vauco.no</span></div>
|
||||
<span class="card-link">Åpne dashboard <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M5 12h14M12 5l7 7-7 7"/></svg></span>
|
||||
</div>
|
||||
<div class="card muted">
|
||||
<div class="card-top">
|
||||
<span class="card-icon"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/></svg></span>
|
||||
<span class="tag soon">Planlagt</span>
|
||||
</div>
|
||||
<div class="card-name">Threadstone</div>
|
||||
<div class="card-desc">Kundeskreddersydd AI-salgsassistent. Landingsside er live, app under utvikling.</div>
|
||||
<div class="card-meta"><span>threadstone.vauco.no</span></div>
|
||||
</div>
|
||||
<div class="card muted">
|
||||
<div class="card-top">
|
||||
<span class="card-icon"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><rect x="3" y="3" width="7" height="7" rx="1"/><rect x="14" y="3" width="7" height="7" rx="1"/><rect x="14" y="14" width="7" height="7" rx="1"/><rect x="3" y="14" width="7" height="7" rx="1"/></svg></span>
|
||||
<span class="tag soon">Fase 3</span>
|
||||
</div>
|
||||
<div class="card-name">Module Builder</div>
|
||||
<div class="card-desc">Bygg og deploy nye salgsmoduler visuelt direkte fra OPAX.</div>
|
||||
<div class="card-meta"><span>opax.vauco.no/build</span></div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- Agenter -->
|
||||
<section class="section" id="agenter">
|
||||
<div class="section-head"><span class="section-label">Agenter</span><span class="section-line"></span></div>
|
||||
<div class="agent-grid">
|
||||
<div class="agent-row actionable" onclick="openChat('Jason','jason/light · gemini-2.5-flash','light')">
|
||||
<span class="dot" id="dot-jason"></span>
|
||||
<div><div class="agent-name">Jason — Light</div><div class="agent-desc">jason/light · gemini-2.5-flash</div></div>
|
||||
<span class="agent-go">Snakk →</span>
|
||||
</div>
|
||||
<div class="agent-row actionable" onclick="openChat('Jason Heavy','jason/heavy · gemini-2.5-pro','heavy')">
|
||||
<span class="dot" id="dot-jason-heavy"></span>
|
||||
<div><div class="agent-name">Jason — Heavy</div><div class="agent-desc">jason/heavy · gemini-2.5-pro</div></div>
|
||||
<span class="agent-go">Snakk →</span>
|
||||
</div>
|
||||
<div class="agent-row actionable" onclick="openChat('OPAX Core','POST /run · orkestrering','heavy')">
|
||||
<span class="dot dim" id="dot-core"></span>
|
||||
<div><div class="agent-name">OPAX Core</div><div class="agent-desc">POST /run · orkestrering</div></div>
|
||||
<span class="agent-go">Snakk →</span>
|
||||
</div>
|
||||
<div class="agent-row">
|
||||
<span class="dot dim"></span>
|
||||
<div><div class="agent-name">Provisioner</div><div class="agent-desc">mail · magic link · fase 2</div></div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- Deploy (OX1a) -->
|
||||
<section class="section" id="deploy">
|
||||
<div class="section-head"><span class="section-label">Deploy</span><span class="section-line"></span></div>
|
||||
<div class="build-widget" id="build-widget">
|
||||
<div class="build-icon" id="build-icon">
|
||||
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" id="build-svg">
|
||||
<polyline points="16 18 22 12 16 6"/><polyline points="8 6 2 12 8 18"/>
|
||||
</svg>
|
||||
</div>
|
||||
<div class="build-info">
|
||||
<div class="build-title">Cloud Build — OSVauco</div>
|
||||
<div class="build-meta" id="build-meta">laster…</div>
|
||||
<div class="build-status-row">
|
||||
<span class="build-badge unknown" id="build-badge">sjekker…</span>
|
||||
<span class="build-duration" id="build-duration"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div style="margin-left:auto;display:flex;flex-direction:column;align-items:flex-end;gap:6px">
|
||||
<a class="build-log-link" id="build-log-link" href="#" target="_blank" rel="noopener" style="visibility:hidden">Se logg →</a>
|
||||
<span class="build-commit" id="build-commit"></span>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- Infrastruktur -->
|
||||
<section class="section" id="infrastruktur">
|
||||
<div class="section-head"><span class="section-label">Infrastruktur</span><span class="section-line"></span></div>
|
||||
<div class="infra-grid">
|
||||
<div class="infra-item"><div class="infra-label">Cloud Run</div><div class="infra-value ok">osvauco-agent</div></div>
|
||||
<div class="infra-item"><div class="infra-label">Region (agent)</div><div class="infra-value neutral">us-central1</div></div>
|
||||
<div class="infra-item"><div class="infra-label">Project</div><div class="infra-value neutral">propane-will-491900-m5</div></div>
|
||||
<div class="infra-item"><div class="infra-label">RAG-korpus</div><div class="infra-value neutral">europe-west4 · EU</div></div>
|
||||
<div class="infra-item"><div class="infra-label">opax.vauco.no</div><div class="infra-value ok">CNAME live</div></div>
|
||||
<div class="infra-item"><div class="infra-label">costguard.oss.vauco.no</div><div class="infra-value ok">Cloud Run live</div></div>
|
||||
<div class="infra-item"><div class="infra-label">vauco.no</div><div class="infra-value ok">GCS + LB live</div></div>
|
||||
<div class="infra-item"><div class="infra-label">Secret Manager</div><div class="infra-value ok">aktiv</div></div>
|
||||
<div class="infra-item"><div class="infra-label">Deploy</div><div class="infra-value" id="infra-deploy">auto · push-to-main</div></div>
|
||||
<div class="infra-item"><div class="infra-label">Backend /health</div><div class="infra-value" id="infra-health">— sjekker…</div></div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- Provisjonering -->
|
||||
<section class="section" id="provisjonering">
|
||||
<div class="section-head"><span class="section-label">Provisjonering</span><span class="section-line"></span></div>
|
||||
<div class="flow-box">
|
||||
<div class="flow-title">Kundeprovisjoneringsflyt — Voice → Modul → Mail</div>
|
||||
<div class="flow-steps">
|
||||
<span class="flow-step">Chris taler (AirPods)</span><span class="flow-arrow">→</span>
|
||||
<span class="flow-step">Web Speech API</span><span class="flow-arrow">→</span>
|
||||
<span class="flow-step">Jason analyserer</span><span class="flow-arrow">→</span>
|
||||
<span class="flow-step">Modul genereres</span><span class="flow-arrow">→</span>
|
||||
<span class="flow-step">Chris godkjenner</span><span class="flow-arrow">→</span>
|
||||
<span class="flow-step">Magic link → kunde</span>
|
||||
</div>
|
||||
<div class="flow-note">Avhenger av: Fase 2 (SendGrid/Resend) · POST /opax/generate · kunde-subdomain via Terraform</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<footer class="page-foot">
|
||||
<span>OPAX · Vauco OS · intern</span>
|
||||
<span>propane-will-491900-m5 · us-central1 · 2026</span>
|
||||
</footer>
|
||||
</main>
|
||||
</div>
|
||||
|
||||
<!-- Chat drawer -->
|
||||
<div class="chat-overlay" id="chat-overlay" onclick="closeChat()"></div>
|
||||
<aside class="chat-drawer" id="chat-drawer" aria-label="Agent-chat">
|
||||
<div class="chat-head">
|
||||
<span class="chat-avatar" id="chat-avatar">J</span>
|
||||
<div>
|
||||
<div class="chat-title" id="chat-title">Jason</div>
|
||||
<div class="chat-sub" id="chat-sub">billing.viewer</div>
|
||||
</div>
|
||||
<button class="chat-close" onclick="closeChat()" aria-label="Lukk">
|
||||
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M18 6L6 18M6 6l12 12"/></svg>
|
||||
</button>
|
||||
</div>
|
||||
<div class="mode-row">
|
||||
<button class="mode-chip active" data-m="light" onclick="setMode('light')">light · flash</button>
|
||||
<button class="mode-chip" data-m="heavy" onclick="setMode('heavy')">heavy · 2.5-pro</button>
|
||||
</div>
|
||||
<div class="chat-body" id="chat-body">
|
||||
<div class="chat-empty" id="chat-empty">
|
||||
<svg width="40" height="40" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/></svg>
|
||||
<div>Send en melding til Jason. Kjører mot <code>POST /run</code> via Vertex AI.</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="chat-foot">
|
||||
<textarea class="chat-input" id="chat-input" rows="1" placeholder="Skriv en melding…" oninput="autoGrow(this)" onkeydown="onKey(event)"></textarea>
|
||||
<button class="chat-send" id="chat-send" onclick="sendMsg()" aria-label="Send">
|
||||
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M22 2L11 13M22 2l-7 20-4-9-9-4 20-7z"/></svg>
|
||||
</button>
|
||||
</div>
|
||||
</aside>
|
||||
|
||||
<script>
|
||||
const SESSION_ID = 'hub-' + Math.random().toString(36).slice(2, 8);
|
||||
let chatMode = 'light';
|
||||
let busy = false;
|
||||
let buildPolling = null;
|
||||
|
||||
async function jget(path){
|
||||
const r = await fetch(path, {headers:{'Accept':'application/json'}});
|
||||
if(!r.ok) throw new Error('HTTP ' + r.status);
|
||||
return r.json();
|
||||
}
|
||||
|
||||
/* ── Build widget (OX1a) ──────────────────────────────────────────────────── */
|
||||
async function loadBuildStatus(){
|
||||
try{
|
||||
const b = await jget('/opax/build-status');
|
||||
const st = b.status || 'unknown';
|
||||
const badge = document.getElementById('build-badge');
|
||||
const dotBuild = document.getElementById('dot-build');
|
||||
const txtBuild = document.getElementById('txt-build');
|
||||
const navBadge = document.getElementById('nav-build-badge');
|
||||
const meta = document.getElementById('build-meta');
|
||||
const dur = document.getElementById('build-duration');
|
||||
const logLink = document.getElementById('build-log-link');
|
||||
const commit = document.getElementById('build-commit');
|
||||
const icon = document.getElementById('build-icon');
|
||||
|
||||
// Badge label + class
|
||||
const labels = {working:'bygger…',queued:'kø…',success:'✅ ok',failure:'❌ feilet',timeout:'❌ timeout',cancelled:'avbrutt',internal_error:'❌ intern feil',unknown:'—',error:'feil'};
|
||||
badge.textContent = labels[st] || st;
|
||||
badge.className = 'build-badge ' + st;
|
||||
|
||||
// Topbar dot
|
||||
dotBuild.className = 'dot ' + (st === 'success' ? '' : st === 'working' || st === 'queued' ? 'amber pulse' : 'red');
|
||||
txtBuild.textContent = st === 'working' ? 'bygger…' : st === 'success' ? 'deploy ok' : st === 'failure' ? 'build feilet' : 'build';
|
||||
|
||||
// Nav badge
|
||||
navBadge.textContent = st === 'success' ? '✅' : st === 'working' || st === 'queued' ? '⧗' : st === 'failure' ? '❌' : '-';
|
||||
navBadge.className = 'nav-badge' + (st === 'success' ? ' live' : '');
|
||||
|
||||
// Spinner i ikon under aktiv build
|
||||
if(st === 'working' || st === 'queued'){
|
||||
icon.innerHTML = '<div class="build-spinner"></div>';
|
||||
if(!buildPolling) buildPolling = setInterval(loadBuildStatus, 8000);
|
||||
} else {
|
||||
icon.innerHTML = '<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6"><polyline points="16 18 22 12 16 6"/><polyline points="8 6 2 12 8 18"/></svg>';
|
||||
if(buildPolling){ clearInterval(buildPolling); buildPolling = null; }
|
||||
}
|
||||
|
||||
// Meta: branch + tid
|
||||
const branch = b.branch || 'main';
|
||||
const start = b.start_time ? new Date(b.start_time).toLocaleTimeString('no-NO',{hour:'2-digit',minute:'2-digit'}) : '';
|
||||
meta.textContent = branch + (start ? ' · ' + start : '');
|
||||
|
||||
// Varighet
|
||||
if(b.duration_s != null){
|
||||
const m = Math.floor(b.duration_s/60), s = b.duration_s % 60;
|
||||
dur.textContent = m > 0 ? m+'m '+s+'s' : s+'s';
|
||||
}
|
||||
|
||||
// Logg-lenke
|
||||
if(b.log_url){ logLink.href = b.log_url; logLink.style.visibility = 'visible'; }
|
||||
|
||||
// Commit SHA
|
||||
if(b.commit) commit.textContent = b.commit;
|
||||
|
||||
}catch(e){
|
||||
document.getElementById('build-badge').textContent = 'utilgjengelig';
|
||||
document.getElementById('build-meta').textContent = e.message;
|
||||
}
|
||||
}
|
||||
|
||||
/* ── Backend health + agent state ──────────────────────────────────────────────── */
|
||||
async function loadStatus(){
|
||||
try{
|
||||
const h = await jget('/health');
|
||||
const ok = h && (h.status === 'ok' || h.ok === true);
|
||||
document.getElementById('txt-run').textContent = ok ? 'cloud run live' : 'degradert';
|
||||
const d = document.getElementById('dot-run');
|
||||
d.className = 'dot ' + (ok ? '' : 'red') + ' pulse';
|
||||
const el = document.getElementById('infra-health');
|
||||
el.textContent = ok ? 'ok' : 'degradert';
|
||||
el.className = 'infra-value ' + (ok ? 'ok' : 'warn');
|
||||
}catch(e){
|
||||
document.getElementById('txt-run').textContent = 'utilgjengelig';
|
||||
document.getElementById('dot-run').className = 'dot red pulse';
|
||||
}
|
||||
try{
|
||||
const s = await jget('/state/agents');
|
||||
const ids = (s.agents||[]).map(a => typeof a==='string'?a:(a.agent_id||a.id||'')).filter(Boolean);
|
||||
document.getElementById('dot-core').className = 'dot ' + (ids.some(x=>x.toLowerCase().includes('opax'))?'':'dim');
|
||||
document.getElementById('dot-jason').className = 'dot';
|
||||
document.getElementById('dot-jason-heavy').className = 'dot';
|
||||
}catch(e){}
|
||||
}
|
||||
|
||||
/* ── Chat ────────────────────────────────────────────────────────────────────── */
|
||||
function openChat(name, sub, mode){
|
||||
document.getElementById('chat-title').textContent = name;
|
||||
document.getElementById('chat-sub').textContent = sub;
|
||||
document.getElementById('chat-avatar').textContent = name.charAt(0).toUpperCase();
|
||||
setMode(mode || 'light');
|
||||
document.getElementById('chat-overlay').classList.add('open');
|
||||
document.getElementById('chat-drawer').classList.add('open');
|
||||
setTimeout(() => document.getElementById('chat-input').focus(), 200);
|
||||
}
|
||||
function closeChat(){
|
||||
document.getElementById('chat-overlay').classList.remove('open');
|
||||
document.getElementById('chat-drawer').classList.remove('open');
|
||||
}
|
||||
function setMode(m){
|
||||
chatMode = m;
|
||||
document.querySelectorAll('.mode-chip').forEach(c => c.classList.toggle('active', c.dataset.m === m));
|
||||
}
|
||||
function autoGrow(t){ t.style.height='auto'; t.style.height=Math.min(t.scrollHeight,120)+'px'; }
|
||||
function onKey(e){ if(e.key==='Enter'&&!e.shiftKey){e.preventDefault();sendMsg();} }
|
||||
function addMsg(text, cls){
|
||||
const empty = document.getElementById('chat-empty');
|
||||
if(empty) empty.remove();
|
||||
const body = document.getElementById('chat-body');
|
||||
const el = document.createElement('div');
|
||||
el.className = 'msg ' + cls;
|
||||
el.textContent = text;
|
||||
body.appendChild(el);
|
||||
body.scrollTop = body.scrollHeight;
|
||||
return el;
|
||||
}
|
||||
async function sendMsg(){
|
||||
if(busy) return;
|
||||
const input = document.getElementById('chat-input');
|
||||
const text = input.value.trim();
|
||||
if(!text) return;
|
||||
input.value=''; autoGrow(input);
|
||||
addMsg(text, 'user');
|
||||
busy = true;
|
||||
document.getElementById('chat-send').disabled = true;
|
||||
const typing = addMsg('Jason tenker…', 'typing');
|
||||
try{
|
||||
const r = await fetch('/run',{
|
||||
method:'POST',
|
||||
headers:{'Content-Type':'application/json'},
|
||||
body: JSON.stringify({message:text, user_id:'opax', session_id:SESSION_ID, mode:chatMode})
|
||||
});
|
||||
typing.remove();
|
||||
if(!r.ok){
|
||||
let detail = 'HTTP ' + r.status;
|
||||
try{const j=await r.json();if(j.detail)detail=j.detail;}catch(_){}
|
||||
addMsg('Feil: ' + detail, 'err');
|
||||
}else{
|
||||
const j = await r.json();
|
||||
addMsg(j.response || '(tomt svar)', 'bot');
|
||||
}
|
||||
}catch(e){
|
||||
typing.remove();
|
||||
addMsg('Nettverksfeil: ' + e.message, 'err');
|
||||
}finally{
|
||||
busy = false;
|
||||
document.getElementById('chat-send').disabled = false;
|
||||
document.getElementById('chat-input').focus();
|
||||
}
|
||||
}
|
||||
|
||||
const navLinks = document.querySelectorAll('.nav-item[href^="#"]');
|
||||
window.addEventListener('scroll', () => {
|
||||
let cur = '';
|
||||
document.querySelectorAll('section[id]').forEach(s => { if(window.scrollY >= s.offsetTop - 120) cur = s.id; });
|
||||
navLinks.forEach(a => a.classList.toggle('active', a.getAttribute('href') === '#' + cur));
|
||||
});
|
||||
document.addEventListener('keydown', e => { if(e.key==='Escape') closeChat(); });
|
||||
|
||||
loadStatus();
|
||||
loadBuildStatus();
|
||||
setInterval(loadStatus, 30000);
|
||||
setInterval(loadBuildStatus, 60000);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
.tui-chat-foot{display:flex;gap:0;border-top:1px solid var(--border)}
|
||||
.tui-prefix{padding:12px 14px;font-family:var(--mono);font-size:13px;color:var(--accent-2);background:#0c0d13;flex-shrink:0;display:flex;align-items:center}
|
||||
.tui-input{
|
||||
flex:1;background:#0c0d13;border:none;color:var(--text);
|
||||
font-family:var(--mono);font-size:13px;padding:12px 0;
|
||||
outline:none;caret-color:var(--
|
||||
Loading…
Reference in New Issue
Block a user