How superdesigndev/treg works
Treg is a shared registry and credential-injecting proxy for agent tools. The main workflow is: an agent or user discovers a catalog endpoint, authenticates with a Treg token, invokes it, and receives a relayed provider response; calls may use team credentials, verified public routes, or Treg-managed credentials and prepaid billing. Teams can also register tools, CLIs, skills, and connections for shared use. The graph combines README-documented capabilities with sampled call-service, dashboard, and worker code; unsampled subsystem wiring is represented only where the tree or documentation supports it.
Components 23
Clients and dashboard
- Treg CLI
src/treg/cli.py - Dashboard UI
frontend/src/App.vue - Dashboard API client
frontend/src/api.ts - HTTP application
src/treg/api.py
Catalog and tools
- Catalog routes
src/treg/routers/catalog.py - Catalog index
src/treg/domain/catalog/store.py - Tool and resource routes
src/treg/routers/resources.py - Tool bindings and bundles
src/treg/domain/tools/bindings.py - Connections and OAuth
src/treg/routers/connections.py
Call execution
- Call endpoints
src/treg/routers/call.py - Call orchestration
src/treg/application/call/service.py - Upstream relay
src/treg/infra/upstream/relay.py - Billing and settlement
src/treg/application/billing.py - Deferred task settlement
src/treg/application/asynctasks.py
Identity and accounts
- Auth and API keys
src/treg/routers/auth.py - Teams and governance
src/treg/domain/governance/teams.py
Insights and operations
- Enrich Arena
src/treg/routers/arena.py - Feedback and reviews
src/treg/routers/feedback.py - Scheduled worker
src/treg/worker.py - Application database
src/treg/infra/db.py
Other components
- Agent or user
- Tool providers
- Stripe
Connections 27
- Agent or user → Treg CLI: runs commands
- Treg CLI → HTTP application: sends requests
- Agent or user → Dashboard UI: uses dashboard
- Dashboard UI → Dashboard API client: requests data
- Dashboard API client → HTTP application: calls API
- HTTP application → Catalog routes: dispatches catalog
- Catalog routes → Catalog index: reads catalog
- HTTP application → Tool and resource routes: dispatches tools
- Tool and resource routes → Tool bindings and bundles: manages bindings
- HTTP application → Connections and OAuth: dispatches connections
- HTTP application → Call endpoints: dispatches calls
- Call endpoints → Call orchestration: executes call
- Call orchestration → Catalog index: resolves endpoint
- Call orchestration → Upstream relay: relays request
- Upstream relay → Tool providers: forwards request
- Call orchestration → Billing and settlement: charges or holds
- Call orchestration → Deferred task settlement: records deferred task
- HTTP application → Auth and API keys: dispatches identity
- HTTP application → Teams and governance: serves team policies
- Billing and settlement → Stripe: handles payments
- HTTP application → Enrich Arena: dispatches Arena
- HTTP application → Feedback and reviews: dispatches feedback
- Scheduled worker → Application database: aggregates records
- Scheduled worker → Catalog index: loads catalog
- Scheduled worker → Tool providers: checks routes
- Call orchestration → Application database: persists call state
- Deferred task settlement → Application database: settles task records