updates on the ai and agent and all thse things awith onboarding

This commit is contained in:
2026-09-30 14:47:58 +05:30
parent 44ba33eda2
commit 0ac5d3d54f
37 changed files with 7755 additions and 0 deletions

View File

@@ -326,6 +326,18 @@ func RegisterRoutes(app *fiber.App, cfg *config.Config) {
adminAuth.Get("/tenants/:id", controllers.GetTenantDetails)
adminAuth.Put("/tenants/:id", controllers.UpdateTenant)
adminAuth.Delete("/tenants/:id", controllers.DeleteTenant)
// Client onboarding: a tenant + its console login in one transaction. Only
// the CLIENT_ONBOARDING_OWNERS logins (default admin@doormile.com), and
// only as Doormile staff with roleid 1 — onboarding mints credentials.
onboarding := adminAuth.Group("/clients", middlewares.ClientOnboardingOwnerOnly(cfg.ClientOnboardingOwners))
onboarding.Post("/onboard", controllers.OnboardClient)
onboarding.Get("/onboarded", controllers.GetOnboardedClients)
onboarding.Get("/cities", controllers.GetOnboardingCities)
// Edit and remove a client's console login (:id = doormile_auth id). Remove
// deletes the login only and marks the client Inactive; history is kept.
onboarding.Put("/:id", controllers.UpdateOnboardedClient)
onboarding.Delete("/:id", controllers.DeleteOnboardedClient)
adminAuth.Get("/tenants/:id/locations", controllers.GetTenantLocations)
adminAuth.Post("/tenants/:id/locations", controllers.CreateTenantLocation)
adminAuth.Put("/tenantlocations/:id", controllers.UpdateTenantLocation)
@@ -437,6 +449,27 @@ func RegisterRoutes(app *fiber.App, cfg *config.Config) {
adminAuth.Get("/exceptions/:id", controllers.GetExceptionDetails)
adminAuth.Put("/exceptions/:id/status", controllers.ResolveException)
// AI agent registry (krow_talent_app/docs/agent-platform-plan.md, Phase 1).
// Doormile staff only — a partner-tenant login gets 403. Reads are open to
// roles 1/3/4; every write is roleid 1 only and is audited.
aiRegistry := adminAuth.Group("/ai", middlewares.DoormileStaffOnly)
aiRegistry.Get("/agents", controllers.GetAIAgents)
aiRegistry.Get("/agents/:id", controllers.GetAIAgent)
aiRegistry.Patch("/agents/:id", middlewares.RoleCheckMiddleware(1), controllers.PatchAIAgent)
aiRegistry.Get("/skills", controllers.GetAISkills)
aiRegistry.Post("/skills", middlewares.RoleCheckMiddleware(1), controllers.CreateAISkill)
aiRegistry.Patch("/skills/:id", middlewares.RoleCheckMiddleware(1), controllers.PatchAISkill)
aiRegistry.Get("/tools", controllers.GetAITools)
aiRegistry.Get("/audit", controllers.GetAIRegistryAudit)
// What the agents did (Phase 4): runs from AI_engine telemetry, decisions
// from agent_decisions, live heartbeat from Redis. Read-only.
aiRegistry.Get("/insights", controllers.GetAIInsights)
aiRegistry.Get("/decisions", controllers.GetAIDecisions)
// Test tab (Phase 6): one prompt through Claude with a skill's tools. Reads
// run redacted; writes only become proposals. Admin only — every run is a
// paid API call — and rate-limited per user in the handler.
aiRegistry.Post("/playground/run", middlewares.RoleCheckMiddleware(1), controllers.RunAIPlayground)
// --------------------
// HUB CONSOLE APIS
// --------------------
@@ -532,6 +565,8 @@ func RegisterRoutes(app *fiber.App, cfg *config.Config) {
internal.Post("/agent-decisions", controllers.CreateAgentDecision)
internal.Get("/agent-decisions/similar", controllers.FindSimilarDecisions)
internal.Patch("/agent-decisions/:id/outcome", controllers.UpdateDecisionOutcome)
// The agent registry, for AI_engine to poll (ETag / If-None-Match → 304).
internal.Get("/ai/registry", controllers.GetInternalAIRegistry)
// Express-batch dispatch: the ExpressDispatchAgent reads a tenant's riders
// and the batch's bookings, then writes back the assignments it decided.