# Lobster Phase 2 - API verification (no Python/DB required) # Usage: # cd d:\ylrz_saas_new\java\scripts # .\verify_lobster_phase2.ps1 # .\verify_lobster_phase2.ps1 -ApiBase http://127.0.0.1:8006 -CompanyId 1 -Token "eyJ..." param( [string]$ApiBase = "http://127.0.0.1:8006", [int]$CompanyId = 1, [string]$Token = $env:LOBSTER_API_TOKEN ) $ErrorActionPreference = "Continue" Write-Host "=== Lobster Phase2 API verify ===" -ForegroundColor Cyan Write-Host "ApiBase=$ApiBase CompanyId=$CompanyId" function Test-Endpoint { param([string]$Method, [string]$Path, [bool]$NeedAuth = $false) $uri = "$($ApiBase.TrimEnd('/'))$Path" $headers = @{ "Content-Type" = "application/json" } if ($NeedAuth -and $Token) { $auth = if ($Token -match "^Bearer ") { $Token } else { "Bearer $Token" } $headers["Authorization"] = $auth } try { if ($Method -eq "GET") { $r = Invoke-WebRequest -Uri $uri -Method GET -Headers $headers -UseBasicParsing -TimeoutSec 15 } else { $r = Invoke-WebRequest -Uri $uri -Method POST -Headers $headers -UseBasicParsing -TimeoutSec 60 } Write-Host "OK $Method $Path -> $($r.StatusCode)" -ForegroundColor Green if ($r.Content) { Write-Host $r.Content.Substring(0, [Math]::Min(500, $r.Content.Length)) } return $true } catch { $code = $_.Exception.Response.StatusCode.value__ Write-Host "FAIL $Method $Path -> HTTP $code $($_.Exception.Message)" -ForegroundColor Yellow return $false } } # 1) Service up try { $h = Invoke-WebRequest -Uri "$ApiBase/" -UseBasicParsing -TimeoutSec 5 Write-Host "OK service reachable ($($h.StatusCode))" -ForegroundColor Green } catch { Write-Host "FAIL service not reachable at $ApiBase" -ForegroundColor Red Write-Host "Start: java -jar fs-saas-company.jar --spring.profiles.active=dev" exit 1 } # 2) Learning metrics (may 401 without token) Test-Endpoint -Method GET -Path "/api/lobster/admin/learning/metrics/$CompanyId" -NeedAuth:$false if (-not $Token) { Write-Host "" Write-Host "SKIP GEPA / staged skills (no token)." -ForegroundColor Yellow Write-Host "Login saas-companyui -> F12 Network -> copy Authorization header ->" Write-Host ' $env:LOBSTER_API_TOKEN="eyJ..."; .\verify_lobster_phase2.ps1' exit 0 } Test-Endpoint -Method GET -Path "/api/lobster/admin/skill/staged/$CompanyId?offset=0&limit=5" -NeedAuth $true Test-Endpoint -Method POST -Path "/api/lobster/admin/learning/gepa/$CompanyId" -NeedAuth $true Test-Endpoint -Method GET -Path "/api/lobster/admin/learning/metrics/$CompanyId" -NeedAuth $true Write-Host "" Write-Host "=== Done. Check skillsEvolved in GEPA response; staged tab in UI. ===" -ForegroundColor Cyan