Packages

A Fair Source multi-agent runtime with deterministic agent scoring and replayable run history.

Retired package: Deprecated - superseded — operator console moved to the Syntropy app

Current section

Files

Jump to
syntropy lib syntropy_web router.ex
Raw

lib/syntropy_web/router.ex

defmodule SyntropyWeb.Router do
use SyntropyWeb, :router
pipeline :browser do
plug :accepts, ["html"]
plug :fetch_session
plug :fetch_live_flash
plug :put_root_layout, html: {SyntropyWeb.Layouts, :root}
plug :protect_from_forgery
plug :put_secure_browser_headers
end
pipeline :operator do
plug SyntropyWeb.Plugs.RequireOperator
end
pipeline :api_read do
plug :accepts, ["json"]
plug SyntropyWeb.Plugs.RateLimiter, class: :read
plug SyntropyWeb.Plugs.ApiAuth, scope: :read
end
pipeline :api_write do
plug :accepts, ["json"]
plug SyntropyWeb.Plugs.RateLimiter, class: :write
plug SyntropyWeb.Plugs.ApiAuth, scope: :write
end
pipeline :api_admin do
plug :accepts, ["json"]
plug SyntropyWeb.Plugs.RateLimiter, class: :write
plug SyntropyWeb.Plugs.ApiAuth, scope: :admin
end
pipeline :api_public do
plug :accepts, ["json"]
end
# Open wherever token auth is disabled (dev/test); in prod ApiAuth is
# required, so scraping needs a bearer token with at least read scope
# (SYNTROPY_API_TOKEN or a scoped API token).
pipeline :metrics do
plug SyntropyWeb.Plugs.ApiAuth, scope: :read
end
scope "/api", SyntropyWeb.Api, as: :api do
pipe_through :api_public
get "/health", StatusController, :health
get "/ready", StatusController, :ready
end
scope "/", SyntropyWeb do
pipe_through :metrics
get "/metrics", MetricsController, :index
end
scope "/api", SyntropyWeb.Api, as: :api do
pipe_through :api_read
get "/cluster", ClusterController, :show
get "/runtime-config", RuntimeConfigController, :show
get "/retention", RetentionController, :show
get "/usage", UsageController, :show
get "/agents", AgentController, :index
get "/agents/:id", AgentController, :show
get "/graph", GraphController, :show
get "/perspectives", PerspectiveController, :index
get "/tasks", TaskController, :index
get "/tasks/:id", TaskController, :show
get "/runs", RunController, :index
get "/runs/:id", RunController, :show
get "/history", HistoryController, :index
get "/history/:id", HistoryController, :show
get "/recommendations", RecommendationController, :index
get "/recommendations/:id", RecommendationController, :show
get "/events", EventController, :index
get "/webhooks", WebhookController, :index
end
scope "/api", SyntropyWeb.Api, as: :api do
pipe_through :api_write
post "/agents", AgentController, :create
delete "/agents/:id", AgentController, :delete
post "/tasks", TaskController, :create
post "/runs", RunController, :create
post "/runs/:id/cancel", RunController, :cancel
post "/recommendations/:id/approve", RecommendationController, :approve
post "/recommendations/:id/reject", RecommendationController, :reject
post "/webhooks", WebhookController, :create
patch "/webhooks/:id", WebhookController, :update
delete "/webhooks/:id", WebhookController, :delete
end
scope "/api", SyntropyWeb.Api, as: :api do
pipe_through :api_admin
put "/runtime-config/provider", RuntimeConfigController, :update_provider
post "/runtime-config/provider/test", RuntimeConfigController, :test_provider
put "/runtime-config/limits", RuntimeConfigController, :update_limits
put "/retention", RetentionController, :update
get "/tokens", TokenController, :index
post "/tokens", TokenController, :create
delete "/tokens/:id", TokenController, :delete
end
scope "/", SyntropyWeb do
pipe_through :browser
get "/login", SessionController, :new
post "/login", SessionController, :create
post "/logout", SessionController, :delete
end
scope "/", SyntropyWeb do
pipe_through [:browser, :operator]
live_session :operator, on_mount: {SyntropyWeb.OperatorAuth, :default} do
live "/", LatticeLive, :index
live "/tasks", TasksLive, :index
live "/history", HistoryLive, :index
live "/operations", OperationsLive, :index
live "/agent/:id", AgentLive, :show
end
end
end