/** * Mastra `apiRoutes` for the GitHub App project feature. * * Registered alongside the other `/web/*` routes, behind the host auth gate. * Every route additionally re-checks the authenticated user via the injected * `RouteAuth` seam and scopes all rows by that user's stable id, so a user can * only ever see and operate on their own installations and projects. * * When the feature is disabled (`isGithubFeatureEnabled()` false), `buildGithubRoutes` * returns only `GET /web/github/status`, which reports `enabled:false` * so the SPA can cleanly hide all GitHub UI. */ import type { MountedMastraCode } from '@mastra/code-sdk'; import type { ApiRoute, IUserProvider } from '@mastra/core/server'; import type { FactoryStorage } from '@mastra/core/storage'; import type { RouteAuth } from '../../routes/route.js'; import type { MastraFactorySandboxConfig } from '../../sandbox/session-sandbox.js'; import type { StateSigner } from '../../state-signing.js'; import type { AuditEmitter } from '../../storage/domains/audit/domain.js'; import type { MemorySettingsStorage } from '../../storage/domains/memory-settings/base.js'; import type { FactoryProjectsStorage } from '../../storage/domains/projects/base.js'; import type { GithubIntegration } from './integration.js'; import type { ParsedGithubWebhook } from './webhook.js'; export interface MountGithubRoutesOptions { /** Host auth seam — resolves the signed-in user/tenant for each request. */ auth: RouteAuth; /** Optional user directory used to resolve session-owner display profiles. */ users?: SessionOwnerUserProvider; /** * The host's session-sandbox callback. Routes only read whether it is * configured: without one, `/web/github/status` reports * `sandboxEnabled: false` and sandbox-backed routes respond 503. Sandboxes * themselves are constructed per session and started lazily elsewhere. */ sandbox?: MastraFactorySandboxConfig; /** Factory storage backend used for the `appDbConfigured` diagnostic. */ storage?: FactoryStorage; /** * The GitHub App integration the handlers operate on (Octokit access, token * minting, OAuth URLs). Normally supplied by `GithubIntegration.routes()`; * when absent, only the disabled `status` route is served. */ github?: GithubIntegration; /** * Shared OAuth/install `state` signer (created once per boot by the * factory). Required for the OAuth/install flow; when absent, only the * disabled `status` route is served. */ stateSigner?: StateSigner; /** * Absolute base URL of the web server (e.g. `http://localhost:4111`), used to * build the OAuth/install redirect URI when one isn't explicitly configured. */ baseUrl?: string; /** Explicit OAuth callback URI; defaults to `/auth/github/callback`. */ redirectUri?: string; /** Controller used to route verified webhook notifications to exact subscribed sessions. */ controller?: MountedMastraCode['controller']; /** Owner-scoped observational-memory settings — the source of the model that names a thread. */ memorySettings: Pick; /** Best-effort audit emission supplied by the factory-owned audit domain. */ emitAudit?: AuditEmitter['emit']; /** Factory projects domain — resolves a project's default triage model. */ projects?: FactoryProjectsStorage; sessionRetirement?: import('../../sandbox/session-retirement.js').SessionRetirementCoordinator; /** Work-items domain — session deletion strips the refs work items hold on it. */ workItems?: Pick; /** Authoritative Factory rule ingress for normalized, signature-verified GitHub deliveries. */ ingestFactoryEvent?: (event: ParsedGithubWebhook) => Promise; } /** * Build the GitHub routes as Mastra `apiRoutes`. When the feature is disabled, * returns only the `status` route so the SPA can detect the disabled state. */ export declare function buildGithubRoutes(options: MountGithubRoutesOptions): ApiRoute[]; type SessionOwnerUserProvider = Pick & Partial>; export {}; //# sourceMappingURL=routes.d.ts.map