import { SandboxConfig } from "./types/app.js";
import "./types/index.js";
import { createAgentsHono } from "./createApp.js";
import { CredentialStore, ServerConfig } from "@inkeep/agents-core";
import * as hono10 from "hono";
import * as zod0 from "zod";
import { EmailServiceConfig, SSOProviderConfig, UserAuthConfig } from "@inkeep/agents-core/auth";
import * as hono_types4 from "hono/types";
import * as better_auth0 from "better-auth";
import * as better_auth_plugins0 from "better-auth/plugins";

//#region src/factory.d.ts
declare function createAgentsAuth(userAuthConfig?: UserAuthConfig, emailService?: EmailServiceConfig): better_auth0.Auth<{
  plugins: [{
    id: "bearer";
    hooks: {
      before: {
        matcher(context: better_auth0.HookEndpointContext): boolean;
        handler: (inputContext: better_auth0.MiddlewareInputContext<better_auth0.MiddlewareOptions>) => Promise<{
          context: {
            headers: Headers;
          };
        } | undefined>;
      }[];
      after: {
        matcher(context: better_auth0.HookEndpointContext): true;
        handler: (inputContext: better_auth0.MiddlewareInputContext<better_auth0.MiddlewareOptions>) => Promise<void>;
      }[];
    };
    options: better_auth_plugins0.BearerOptions | undefined;
  }, {
    id: "oauth-proxy";
    options: NoInfer<better_auth_plugins0.OAuthProxyOptions>;
    endpoints: {
      oAuthProxy: better_auth0.StrictEndpoint<"/oauth-proxy-callback", {
        method: "GET";
        operationId: string;
        query: zod0.ZodObject<{
          callbackURL: zod0.ZodString;
          profile: zod0.ZodOptional<zod0.ZodString>;
        }, better_auth0.$strip>;
        use: ((inputContext: better_auth0.MiddlewareInputContext<better_auth0.MiddlewareOptions>) => Promise<void>)[];
        metadata: {
          openapi: {
            operationId: string;
            description: string;
            parameters: ({
              in: "query";
              name: string;
              required: true;
              description: string;
            } | {
              in: "query";
              name: string;
              required: false;
              description: string;
            })[];
            responses: {
              302: {
                description: string;
                headers: {
                  Location: {
                    description: string;
                    schema: {
                      type: string;
                    };
                  };
                };
              };
            };
          };
        };
      }, never>;
    };
    hooks: {
      before: {
        matcher(context: better_auth0.HookEndpointContext): boolean;
        handler: (inputContext: better_auth0.MiddlewareInputContext<better_auth0.MiddlewareOptions>) => Promise<void>;
      }[];
      after: {
        matcher(context: better_auth0.HookEndpointContext): boolean;
        handler: (inputContext: better_auth0.MiddlewareInputContext<better_auth0.MiddlewareOptions>) => Promise<void>;
      }[];
    };
  }, better_auth_plugins0.DefaultOrganizationPlugin<{
    schema: {
      invitation: {
        additionalFields: {
          authMethod: {
            type: "string";
            required: false;
          };
        };
      };
      organization: {
        additionalFields: {
          preferredAuthMethod: {
            type: "string";
            input: true;
            required: false;
          };
          serviceAccountUserId: {
            type: "string";
            input: true;
            required: false;
          };
        };
      };
    };
  }>, {
    id: "device-authorization";
    schema: {
      deviceCode: {
        fields: {
          deviceCode: {
            type: "string";
            required: true;
          };
          userCode: {
            type: "string";
            required: true;
          };
          userId: {
            type: "string";
            required: false;
          };
          expiresAt: {
            type: "date";
            required: true;
          };
          status: {
            type: "string";
            required: true;
          };
          lastPolledAt: {
            type: "date";
            required: false;
          };
          pollingInterval: {
            type: "number";
            required: false;
          };
          clientId: {
            type: "string";
            required: false;
          };
          scope: {
            type: "string";
            required: false;
          };
        };
      };
    };
    endpoints: {
      deviceCode: better_auth0.StrictEndpoint<"/device/code", {
        method: "POST";
        body: zod0.ZodObject<{
          client_id: zod0.ZodString;
          scope: zod0.ZodOptional<zod0.ZodString>;
        }, better_auth0.$strip>;
        error: zod0.ZodObject<{
          error: zod0.ZodEnum<{
            invalid_request: "invalid_request";
            invalid_client: "invalid_client";
          }>;
          error_description: zod0.ZodString;
        }, better_auth0.$strip>;
        metadata: {
          openapi: {
            description: string;
            responses: {
              200: {
                description: string;
                content: {
                  "application/json": {
                    schema: {
                      type: "object";
                      properties: {
                        device_code: {
                          type: string;
                          description: string;
                        };
                        user_code: {
                          type: string;
                          description: string;
                        };
                        verification_uri: {
                          type: string;
                          format: string;
                          description: string;
                        };
                        verification_uri_complete: {
                          type: string;
                          format: string;
                          description: string;
                        };
                        expires_in: {
                          type: string;
                          description: string;
                        };
                        interval: {
                          type: string;
                          description: string;
                        };
                      };
                    };
                  };
                };
              };
              400: {
                description: string;
                content: {
                  "application/json": {
                    schema: {
                      type: "object";
                      properties: {
                        error: {
                          type: string;
                          enum: string[];
                        };
                        error_description: {
                          type: string;
                        };
                      };
                    };
                  };
                };
              };
            };
          };
        };
      }, {
        device_code: string;
        user_code: string;
        verification_uri: string;
        verification_uri_complete: string;
        expires_in: number;
        interval: number;
      }>;
      deviceToken: better_auth0.StrictEndpoint<"/device/token", {
        method: "POST";
        body: zod0.ZodObject<{
          grant_type: zod0.ZodLiteral<"urn:ietf:params:oauth:grant-type:device_code">;
          device_code: zod0.ZodString;
          client_id: zod0.ZodString;
        }, better_auth0.$strip>;
        error: zod0.ZodObject<{
          error: zod0.ZodEnum<{
            invalid_request: "invalid_request";
            authorization_pending: "authorization_pending";
            slow_down: "slow_down";
            expired_token: "expired_token";
            access_denied: "access_denied";
            invalid_grant: "invalid_grant";
          }>;
          error_description: zod0.ZodString;
        }, better_auth0.$strip>;
        metadata: {
          openapi: {
            description: string;
            responses: {
              200: {
                description: string;
                content: {
                  "application/json": {
                    schema: {
                      type: "object";
                      properties: {
                        session: {
                          $ref: string;
                        };
                        user: {
                          $ref: string;
                        };
                      };
                    };
                  };
                };
              };
              400: {
                description: string;
                content: {
                  "application/json": {
                    schema: {
                      type: "object";
                      properties: {
                        error: {
                          type: string;
                          enum: string[];
                        };
                        error_description: {
                          type: string;
                        };
                      };
                    };
                  };
                };
              };
            };
          };
        };
      }, {
        access_token: string;
        token_type: string;
        expires_in: number;
        scope: string;
      }>;
      deviceVerify: better_auth0.StrictEndpoint<"/device", {
        method: "GET";
        query: zod0.ZodObject<{
          user_code: zod0.ZodString;
        }, better_auth0.$strip>;
        error: zod0.ZodObject<{
          error: zod0.ZodEnum<{
            invalid_request: "invalid_request";
          }>;
          error_description: zod0.ZodString;
        }, better_auth0.$strip>;
        metadata: {
          openapi: {
            description: string;
            responses: {
              200: {
                description: string;
                content: {
                  "application/json": {
                    schema: {
                      type: "object";
                      properties: {
                        user_code: {
                          type: string;
                          description: string;
                        };
                        status: {
                          type: string;
                          enum: string[];
                          description: string;
                        };
                      };
                    };
                  };
                };
              };
            };
          };
        };
      }, {
        user_code: string;
        status: string;
      }>;
      deviceApprove: better_auth0.StrictEndpoint<"/device/approve", {
        method: "POST";
        body: zod0.ZodObject<{
          userCode: zod0.ZodString;
        }, better_auth0.$strip>;
        error: zod0.ZodObject<{
          error: zod0.ZodEnum<{
            invalid_request: "invalid_request";
            expired_token: "expired_token";
            access_denied: "access_denied";
            device_code_already_processed: "device_code_already_processed";
            unauthorized: "unauthorized";
          }>;
          error_description: zod0.ZodString;
        }, better_auth0.$strip>;
        requireHeaders: true;
        metadata: {
          openapi: {
            description: string;
            responses: {
              200: {
                description: string;
                content: {
                  "application/json": {
                    schema: {
                      type: "object";
                      properties: {
                        success: {
                          type: string;
                        };
                      };
                    };
                  };
                };
              };
            };
          };
        };
      }, {
        success: boolean;
      }>;
      deviceDeny: better_auth0.StrictEndpoint<"/device/deny", {
        method: "POST";
        body: zod0.ZodObject<{
          userCode: zod0.ZodString;
        }, better_auth0.$strip>;
        error: zod0.ZodObject<{
          error: zod0.ZodEnum<{
            invalid_request: "invalid_request";
            expired_token: "expired_token";
            access_denied: "access_denied";
            unauthorized: "unauthorized";
          }>;
          error_description: zod0.ZodString;
        }, better_auth0.$strip>;
        requireHeaders: true;
        metadata: {
          openapi: {
            description: string;
            responses: {
              200: {
                description: string;
                content: {
                  "application/json": {
                    schema: {
                      type: "object";
                      properties: {
                        success: {
                          type: string;
                        };
                      };
                    };
                  };
                };
              };
            };
          };
        };
      }, {
        success: boolean;
      }>;
    };
    $ERROR_CODES: {
      USER_NOT_FOUND: better_auth0.RawError<"USER_NOT_FOUND">;
      FAILED_TO_CREATE_SESSION: better_auth0.RawError<"FAILED_TO_CREATE_SESSION">;
      INVALID_DEVICE_CODE: better_auth0.RawError<"INVALID_DEVICE_CODE">;
      EXPIRED_DEVICE_CODE: better_auth0.RawError<"EXPIRED_DEVICE_CODE">;
      EXPIRED_USER_CODE: better_auth0.RawError<"EXPIRED_USER_CODE">;
      AUTHORIZATION_PENDING: better_auth0.RawError<"AUTHORIZATION_PENDING">;
      ACCESS_DENIED: better_auth0.RawError<"ACCESS_DENIED">;
      INVALID_USER_CODE: better_auth0.RawError<"INVALID_USER_CODE">;
      DEVICE_CODE_ALREADY_PROCESSED: better_auth0.RawError<"DEVICE_CODE_ALREADY_PROCESSED">;
      POLLING_TOO_FREQUENTLY: better_auth0.RawError<"POLLING_TOO_FREQUENTLY">;
      INVALID_DEVICE_CODE_STATUS: better_auth0.RawError<"INVALID_DEVICE_CODE_STATUS">;
      AUTHENTICATION_REQUIRED: better_auth0.RawError<"AUTHENTICATION_REQUIRED">;
    };
    options: Partial<{
      expiresIn: better_auth_plugins0.TimeString;
      interval: better_auth_plugins0.TimeString;
      deviceCodeLength: number;
      userCodeLength: number;
      schema: {
        deviceCode?: {
          modelName?: string | undefined;
          fields?: {
            deviceCode?: string | undefined;
            userCode?: string | undefined;
            userId?: string | undefined;
            expiresAt?: string | undefined;
            status?: string | undefined;
            lastPolledAt?: string | undefined;
            pollingInterval?: string | undefined;
            clientId?: string | undefined;
            scope?: string | undefined;
          } | undefined;
        } | undefined;
      };
      generateDeviceCode?: (() => string | Promise<string>) | undefined;
      generateUserCode?: (() => string | Promise<string>) | undefined;
      validateClient?: ((clientId: string) => boolean | Promise<boolean>) | undefined;
      onDeviceAuthRequest?: ((clientId: string, scope: string | undefined) => void | Promise<void>) | undefined;
      verificationUri?: string | undefined;
    }>;
  }];
}>;
declare function createAgentsApp(config?: {
  serverConfig?: ServerConfig;
  credentialStores?: CredentialStore[];
  auth?: UserAuthConfig;
  sandboxConfig?: SandboxConfig;
  emailService?: EmailServiceConfig;
}): hono10.Hono<hono_types4.BlankEnv, hono_types4.BlankSchema, "/">;
//#endregion
export { type SSOProviderConfig, type UserAuthConfig, createAgentsApp, createAgentsAuth, createAgentsHono };