import {
  defineExecutorConfig
} from "./chunk-2LU3SC64.js";
import {
  InternalError,
  OAUTH_POPUP_MESSAGE_TYPE,
  isOAuthPopupResult
} from "./chunk-B4YGTZF6.js";
import {
  SecretBackedMap,
  SecretBackedValue,
  isSecretBackedRef,
  resolveSecretBackedMap
} from "./chunk-MLNVNVRI.js";
import {
  ConnectionProviderState,
  ConnectionRef,
  ConnectionRefreshError,
  CreateConnectionInput,
  ElicitationAction,
  ElicitationDeclinedError,
  ElicitationResponse,
  FormElicitation,
  HostedOutboundRequestBlocked,
  OAUTH2_DEFAULT_TIMEOUT_MS,
  OAUTH2_REFRESH_SKEW_MS,
  OAuth2Error,
  OAuthAuthorizationServerMetadataSchema,
  OAuthClientInformationSchema,
  OAuthDiscoveryError,
  OAuthProtectedResourceMetadataSchema,
  RemoveConnectionInput,
  RemoveSecretInput,
  Scope,
  SecretRef,
  SetSecretInput,
  TokenMaterial,
  ToolResult,
  UpdateConnectionTokensInput,
  UrlElicitation,
  assertSupportedOAuthEndpointUrl,
  beginDynamicAuthorization,
  buildAuthorizationUrl,
  buildToolTypeScriptPreview,
  collectRefs,
  collectTables,
  coreToolsPlugin,
  createExecutor,
  createPkceCodeChallenge,
  createPkceCodeVerifier,
  defaultSourceInstallScopeId,
  definePlugin,
  discoverAuthorizationServerMetadata,
  discoverProtectedResourceMetadata,
  exchangeAuthorizationCode,
  exchangeClientCredentials,
  hoistDefinitions,
  isSupportedOAuthEndpointUrl,
  isToolResult,
  makeFumaBlobStore,
  makeHostedHttpClientLayer,
  makeInMemoryBlobStore,
  makeOAuth2Service,
  normalizeRefs,
  pluginBlobStore,
  reattachDefs,
  refreshAccessToken,
  registerDynamicClient,
  schemaToTypeScriptPreview,
  schemaToTypeScriptPreviewWithDefs,
  shouldRefreshToken,
  tool,
  validateHostedOutboundUrl
} from "./chunk-W3GGXFXE.js";
import {
  ConfiguredCredentialBinding,
  ConfiguredCredentialValue,
  ConnectionId,
  ConnectionInUseError,
  ConnectionNotFoundError,
  ConnectionProviderNotRegisteredError,
  ConnectionReauthRequiredError,
  ConnectionRefreshNotSupportedError,
  CredentialBindingId,
  CredentialBindingKind,
  CredentialBindingRef,
  CredentialBindingResolutionStatus,
  CredentialBindingSlotInput,
  CredentialBindingValue,
  NoHandlerError,
  OAUTH2_PROVIDER_KEY,
  OAUTH2_SESSION_TTL_MS,
  OAuthAuthorizationCodeStrategy,
  OAuthClientCredentialsStrategy,
  OAuthCompleteError,
  OAuthDynamicDcrStrategy,
  OAuthProbeError,
  OAuthProviderState,
  OAuthSessionNotFoundError,
  OAuthStartError,
  OAuthStrategy,
  PluginNotLoadedError,
  PolicyId,
  RemoveCredentialBindingInput,
  RemoveSourceCredentialBindingInput,
  ReplaceCredentialBindingValue,
  ReplaceCredentialBindingsInput,
  ReplaceSourceCredentialBindingsInput,
  ResolvedCredentialSlot,
  ScopeId,
  ScopedSecretCredentialInput,
  SecretId,
  SecretInUseError,
  SecretNotFoundError,
  SecretOwnedByConnectionError,
  SecretResolutionError,
  SetSourceCredentialBindingInput,
  SourceCredentialBindingSlotInput,
  SourceCredentialBindingSource,
  SourceCredentialBindingSourceInput,
  SourceDetectionResult,
  SourceNotFoundError,
  SourceRemovalNotAllowedError,
  StorageError,
  TOOL_POLICY_ACTIONS,
  ToolBlockedError,
  ToolId,
  ToolInvocationError,
  ToolNotFoundError,
  ToolPolicyActionSchema,
  ToolSchema,
  UniqueViolationError,
  Usage,
  bigintColumn,
  boolColumn,
  coreSchema,
  credentialBindingId,
  credentialBindingRowToRef,
  credentialBindingValueFromRow,
  credentialSlotKey,
  credentialSlotPart,
  dateColumn,
  effectivePolicyFromSorted,
  isStorageFailure,
  isToolPolicyAction,
  isValidPattern,
  jsonColumn,
  matchPattern,
  nullableBigintColumn,
  nullableJsonColumn,
  nullableTextColumn,
  pluginStorageId,
  resolveEffectivePolicy,
  resolveToolPolicy,
  rowToToolPolicy,
  scopedExecutorTable,
  textColumn
} from "./chunk-ZANQD7E2.js";
import "./chunk-7D4SUZUM.js";

// src/index.ts
import { Context, Effect, Layer, Schema, Data, Option } from "effect";
import {
  HttpApi,
  HttpApiBuilder,
  HttpApiClient,
  HttpApiEndpoint,
  HttpApiGroup,
  HttpApiMiddleware,
  HttpApiSchema
} from "effect/unstable/httpapi";
import { fumadb } from "fumadb";
import { column, idColumn, schema, table } from "fumadb/schema";

// src/auth-tool-failure.ts
var authRecovery = (input) => ({
  secretsUrl: "https://executor.sh/secrets",
  createSecretTool: "executor.coreTools.secrets.create",
  startOAuthTool: "executor.coreTools.oauth.start",
  listConnectionsTool: "executor.coreTools.connections.list",
  ...input?.configureSourceTool ? { configureSourceTool: input.configureSourceTool } : {},
  secretInstructions: "For API keys, tokens, and other manually entered credentials, call createSecretTool and give the returned browser URL to the user before configuring the source binding.",
  oauthInstructions: "For OAuth credentials, call startOAuthTool and give the returned authorizationUrl to the user, then bind the completed connection with the source configuration tool."
});
var authToolFailure = (input) => {
  const error = {
    code: input.code,
    message: input.message,
    retryable: false,
    ...input.status !== void 0 ? { status: input.status } : {},
    details: {
      category: "authentication",
      ...input.source ? { source: input.source } : {},
      ...input.credential ? { credential: input.credential } : {},
      ...input.upstream ? { upstream: input.upstream } : {},
      recovery: authRecovery(input.recovery)
    }
  };
  return ToolResult.fail(error);
};
export {
  ConfiguredCredentialBinding,
  ConfiguredCredentialValue,
  ConnectionId,
  ConnectionInUseError,
  ConnectionNotFoundError,
  ConnectionProviderNotRegisteredError,
  ConnectionProviderState,
  ConnectionReauthRequiredError,
  ConnectionRef,
  ConnectionRefreshError,
  ConnectionRefreshNotSupportedError,
  Context,
  CreateConnectionInput,
  CredentialBindingId,
  CredentialBindingKind,
  CredentialBindingRef,
  CredentialBindingResolutionStatus,
  CredentialBindingSlotInput,
  CredentialBindingValue,
  Data,
  Effect,
  ElicitationAction,
  ElicitationDeclinedError,
  ElicitationResponse,
  FormElicitation,
  HostedOutboundRequestBlocked,
  HttpApi,
  HttpApiBuilder,
  HttpApiClient,
  HttpApiEndpoint,
  HttpApiGroup,
  HttpApiMiddleware,
  HttpApiSchema,
  InternalError,
  Layer,
  NoHandlerError,
  OAUTH2_DEFAULT_TIMEOUT_MS,
  OAUTH2_PROVIDER_KEY,
  OAUTH2_REFRESH_SKEW_MS,
  OAUTH2_SESSION_TTL_MS,
  OAUTH_POPUP_MESSAGE_TYPE,
  OAuth2Error,
  OAuthAuthorizationCodeStrategy as OAuthAuthorizationCodeStrategySchema,
  OAuthAuthorizationServerMetadataSchema,
  OAuthClientCredentialsStrategy as OAuthClientCredentialsStrategySchema,
  OAuthClientInformationSchema,
  OAuthCompleteError,
  OAuthDiscoveryError,
  OAuthDynamicDcrStrategy as OAuthDynamicDcrStrategySchema,
  OAuthProbeError,
  OAuthProtectedResourceMetadataSchema,
  OAuthProviderState as OAuthProviderStateSchema,
  OAuthSessionNotFoundError,
  OAuthStartError,
  OAuthStrategy as OAuthStrategySchema,
  Option,
  PluginNotLoadedError,
  PolicyId,
  RemoveConnectionInput,
  RemoveCredentialBindingInput,
  RemoveSecretInput,
  RemoveSourceCredentialBindingInput,
  ReplaceCredentialBindingValue,
  ReplaceCredentialBindingsInput,
  ReplaceSourceCredentialBindingsInput,
  ResolvedCredentialSlot,
  Schema,
  Scope,
  ScopeId,
  ScopedSecretCredentialInput,
  SecretBackedMap,
  SecretBackedValue,
  SecretId,
  SecretInUseError,
  SecretNotFoundError,
  SecretOwnedByConnectionError,
  SecretRef,
  SecretResolutionError,
  SetSecretInput,
  SetSourceCredentialBindingInput,
  SourceCredentialBindingSlotInput,
  SourceCredentialBindingSource,
  SourceCredentialBindingSourceInput,
  SourceDetectionResult,
  SourceNotFoundError,
  SourceRemovalNotAllowedError,
  StorageError,
  TOOL_POLICY_ACTIONS,
  TokenMaterial,
  ToolBlockedError,
  ToolId,
  ToolInvocationError,
  ToolNotFoundError,
  ToolPolicyActionSchema,
  ToolResult,
  ToolSchema,
  UniqueViolationError,
  UpdateConnectionTokensInput,
  UrlElicitation,
  Usage,
  assertSupportedOAuthEndpointUrl,
  authToolFailure,
  beginDynamicAuthorization,
  bigintColumn,
  boolColumn,
  buildAuthorizationUrl,
  buildToolTypeScriptPreview,
  collectRefs,
  collectTables,
  column,
  coreSchema,
  coreToolsPlugin,
  createExecutor,
  createPkceCodeChallenge,
  createPkceCodeVerifier,
  credentialBindingId,
  credentialBindingRowToRef,
  credentialBindingValueFromRow,
  credentialSlotKey,
  credentialSlotPart,
  dateColumn,
  defaultSourceInstallScopeId,
  defineExecutorConfig,
  definePlugin,
  discoverAuthorizationServerMetadata,
  discoverProtectedResourceMetadata,
  effectivePolicyFromSorted,
  exchangeAuthorizationCode,
  exchangeClientCredentials,
  schema as fumaSchema,
  fumadb,
  hoistDefinitions,
  idColumn,
  isOAuthPopupResult,
  isSecretBackedRef,
  isStorageFailure,
  isSupportedOAuthEndpointUrl,
  isToolPolicyAction,
  isToolResult,
  isValidPattern,
  jsonColumn,
  makeFumaBlobStore,
  makeHostedHttpClientLayer,
  makeInMemoryBlobStore,
  makeOAuth2Service,
  matchPattern,
  normalizeRefs,
  nullableBigintColumn,
  nullableJsonColumn,
  nullableTextColumn,
  pluginBlobStore,
  pluginStorageId,
  reattachDefs,
  refreshAccessToken,
  registerDynamicClient,
  resolveEffectivePolicy,
  resolveSecretBackedMap,
  resolveToolPolicy,
  rowToToolPolicy,
  schemaToTypeScriptPreview,
  schemaToTypeScriptPreviewWithDefs,
  scopedExecutorTable,
  shouldRefreshToken,
  table,
  textColumn,
  tool,
  validateHostedOutboundUrl
};
//# sourceMappingURL=core.js.map