verify_lobster_phase2.ps1 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. # Lobster Phase 2 - API verification (no Python/DB required)
  2. # Usage:
  3. # cd d:\ylrz_saas_new\java\scripts
  4. # .\verify_lobster_phase2.ps1
  5. # .\verify_lobster_phase2.ps1 -ApiBase http://127.0.0.1:8006 -CompanyId 1 -Token "eyJ..."
  6. param(
  7. [string]$ApiBase = "http://127.0.0.1:8006",
  8. [int]$CompanyId = 1,
  9. [string]$Token = $env:LOBSTER_API_TOKEN
  10. )
  11. $ErrorActionPreference = "Continue"
  12. Write-Host "=== Lobster Phase2 API verify ===" -ForegroundColor Cyan
  13. Write-Host "ApiBase=$ApiBase CompanyId=$CompanyId"
  14. function Test-Endpoint {
  15. param([string]$Method, [string]$Path, [bool]$NeedAuth = $false)
  16. $uri = "$($ApiBase.TrimEnd('/'))$Path"
  17. $headers = @{ "Content-Type" = "application/json" }
  18. if ($NeedAuth -and $Token) {
  19. $auth = if ($Token -match "^Bearer ") { $Token } else { "Bearer $Token" }
  20. $headers["Authorization"] = $auth
  21. }
  22. try {
  23. if ($Method -eq "GET") {
  24. $r = Invoke-WebRequest -Uri $uri -Method GET -Headers $headers -UseBasicParsing -TimeoutSec 15
  25. } else {
  26. $r = Invoke-WebRequest -Uri $uri -Method POST -Headers $headers -UseBasicParsing -TimeoutSec 60
  27. }
  28. Write-Host "OK $Method $Path -> $($r.StatusCode)" -ForegroundColor Green
  29. if ($r.Content) { Write-Host $r.Content.Substring(0, [Math]::Min(500, $r.Content.Length)) }
  30. return $true
  31. } catch {
  32. $code = $_.Exception.Response.StatusCode.value__
  33. Write-Host "FAIL $Method $Path -> HTTP $code $($_.Exception.Message)" -ForegroundColor Yellow
  34. return $false
  35. }
  36. }
  37. # 1) Service up
  38. try {
  39. $h = Invoke-WebRequest -Uri "$ApiBase/" -UseBasicParsing -TimeoutSec 5
  40. Write-Host "OK service reachable ($($h.StatusCode))" -ForegroundColor Green
  41. } catch {
  42. Write-Host "FAIL service not reachable at $ApiBase" -ForegroundColor Red
  43. Write-Host "Start: java -jar fs-saas-company.jar --spring.profiles.active=dev"
  44. exit 1
  45. }
  46. # 2) Learning metrics (may 401 without token)
  47. Test-Endpoint -Method GET -Path "/api/lobster/admin/learning/metrics/$CompanyId" -NeedAuth:$false
  48. if (-not $Token) {
  49. Write-Host ""
  50. Write-Host "SKIP GEPA / staged skills (no token)." -ForegroundColor Yellow
  51. Write-Host "Login saas-companyui -> F12 Network -> copy Authorization header ->"
  52. Write-Host ' $env:LOBSTER_API_TOKEN="eyJ..."; .\verify_lobster_phase2.ps1'
  53. exit 0
  54. }
  55. Test-Endpoint -Method GET -Path "/api/lobster/admin/skill/staged/$CompanyId?offset=0&limit=5" -NeedAuth $true
  56. Test-Endpoint -Method POST -Path "/api/lobster/admin/learning/gepa/$CompanyId" -NeedAuth $true
  57. Test-Endpoint -Method GET -Path "/api/lobster/admin/learning/metrics/$CompanyId" -NeedAuth $true
  58. Write-Host ""
  59. Write-Host "=== Done. Check skillsEvolved in GEPA response; staged tab in UI. ===" -ForegroundColor Cyan