// Side-effect import: augments `CraftConfig` with first-class `llm`, `mcp`,
// `embedding`, and `agent` keys, and registers the corresponding config
// appliers so those keys produce plugins on context startup.
import "./config.ts";

// Cross-instance identity (Symbol.for) for MCP adapters
export { BRAND, isMcpAdapter } from "./brand.ts";

// Type registries for compile-time safety
export type {
  LlmProviderRegistry,
  McpServerRegistry,
  RegisteredLlmModelId,
  RegisteredMcpServer,
  RegisteredMcpShorthand,
} from "./registry.ts";

// LLM adapter and plugin
export {
  ADAPTER_LLM_PROVIDERS,
  ADAPTER_LLM_OPTIONS,
  llm,
  LlmDestinationAdapter,
  llmPlugin,
  validateLlmPluginOptions,
} from "./llm/index.ts";
export type {
  LlmAnthropicProviderOptions,
  LlmGeminiProviderOptions,
  LlmModelConfig,
  LlmModelConfigAnthropic,
  LlmModelConfigGemini,
  LlmModelConfigOllama,
  LlmModelConfigOpenAI,
  LlmModelConfigOpenRouter,
  LlmModelId,
  LlmOllamaProviderOptions,
  LlmOpenAIProviderOptions,
  LlmOpenRouterProviderOptions,
  LlmOptions,
  LlmPluginOptions,
  LlmPluginProviders,
  LlmPromptSource,
  LlmProviderType,
  LlmResult,
  LlmToolCallSummary,
  LlmUsage,
} from "./llm/index.ts";

// Auth primitives re-exported from core for convenience.
// Canonical location: @routecraft/routecraft
export {
  jwt,
  jwks,
  type ClaimMappers,
  type JwtAudience,
  type JwtAuthOptions,
  type JwtHmacOptions,
  type JwtRsaOptions,
  type JwksOptions,
  type OAuthPrincipal,
  type OAuthTokenVerifier,
  type OAuthValidatorAuthOptions,
  type Principal,
  type TokenVerifier,
  type ValidatorAuthOptions,
} from "@routecraft/routecraft";

// MCP DSL, adapter, and types
export {
  ADAPTER_MCP_CLIENT_SERVERS,
  BRAND_MCP_ADAPTER,
  defaultArgs,
  isOAuthAuth,
  mcp,
  oauth,
  McpHeadersKeys,
  mcpPlugin,
  McpServer,
  McpToolRegistry,
  MCP_LOCAL_TOOL_REGISTRY,
  MCP_PLUGIN_REGISTERED,
  MCP_STDIO_MANAGERS,
  MCP_TOOL_REGISTRY,
  validateWithSchema,
  type McpLocalToolEntry,
  type McpOptions,
  type McpPluginOptions,
  type McpResourceOptions,
  type McpServerOptions,
  type McpTool,
  type McpToolAnnotations,
  type McpInput,
  type McpOutput,
  type McpIcon,
  type McpToolRegistryEntry,
  type McpToolResult,
  type OAuthAuthOptions,
  type OAuthClientInfo,
  type OAuthClientSupplier,
  type OAuthFactoryOptions,
  type OAuthProxyEndpoints,
  type OAuthVerifier,
  type UserinfoFn,
  type UserinfoOption,
} from "./mcp/index.ts";
export type {
  McpClientAuthOptions,
  McpClientOptions,
  McpClientServerConfig,
  McpClientStdioConfig,
  McpClientTokenProvider,
  McpHttpAuthOptions,
} from "./mcp/types.ts";
export type {
  McpArgsExtractor,
  McpClientHttpConfig,
  McpMessage,
} from "./mcp/index.ts";

// Agent destination, plugin, and types. For inline use, identity and
// description come from the enclosing route (`.id()`, `.description()`).
// For by-name use, register agents via `agentPlugin({ agents: { name: {...} } })`.
export {
  agent,
  AgentDestinationAdapter,
  agentPlugin,
  agents,
  ADAPTER_AGENT_DEFAULT_OPTIONS,
  ADAPTER_AGENT_REGISTRY,
  SuspendError,
  isSuspendError,
} from "./agent/index.ts";
export type {
  AgentBinding,
  AgentDefaultOptions,
  AgentByNameOverrides,
  AgentDelta,
  AgentMarkdownOverride,
  AgentDeltaListener,
  AgentOptions,
  AgentPluginOptions,
  AgentPrincipalRenderer,
  AgentRegisteredOptions,
  AgentResult,
  AgentToolCallSummary,
  AgentUserPromptSource,
} from "./agent/index.ts";

// Fn primitive: ad-hoc in-process functions registered via
// `agentPlugin({ functions: { id: {...} } })`. Consumed exclusively by
// the agent tool loop (follow-up story); not directly invocable from
// user code. For tests, use `testFn` from `@routecraft/testing`.
export { ADAPTER_FN_REGISTRY } from "./fn/index.ts";
export type {
  FnHandlerContext,
  FnOptions,
  FnRegistry,
  ReadonlyPrincipal,
  RegisteredFnId,
} from "./fn/index.ts";

// Tool builders: wrap registered routes as fn-shaped entries usable
// from `agentPlugin({ functions: { ... } })`, plus the `tools([...])`
// selector consumed by the agent runtime. MCP tools are resolved
// directly via the `mcp_<client>:<tool>` grammar inside `tools(...)`;
// sub-agent tools land in a follow-up story.
export {
  defaultFns,
  directTool,
  isDeferredFn,
  isToolSelection,
  tools,
  type DeferredFn,
  type DeferredFnKind,
  type FnEntry,
  type ResolvedTool,
  type ToolBuilderOverrides,
  type ToolGuard,
  type ToolSelection,
  type ToolsItem,
} from "./agent/tools/index.ts";

// Skills (portable instruction-set primitive) and skills() markdown loader
export {
  ADAPTER_SKILL_REGISTRY,
  skills,
  type RegisteredSkillName,
  type Skill,
  type SkillOverride,
  type SkillRegistry,
} from "./skill/index.ts";

// Embedding adapter and plugin
export {
  embedding,
  EmbeddingDestinationAdapter,
  embeddingPlugin,
  disposeEmbeddingPipelineCache,
} from "./embedding/index.ts";
export type {
  EmbeddingModelConfig,
  EmbeddingModelConfigHuggingFace,
  EmbeddingModelConfigOllama,
  EmbeddingModelConfigOpenAI,
  EmbeddingModelId,
  EmbeddingOptions,
  EmbeddingPluginOptions,
  EmbeddingPluginProviders,
  EmbeddingProviderType,
  EmbeddingResult,
} from "./embedding/index.ts";
