# Copyright (c) Microsoft. All rights reserved.

from typing import Final

__version__: Final[str]

from ._agents import Agent, BaseAgent, RawAgent, SupportsAgentRun
from ._clients import (
    BaseChatClient,
    BaseEmbeddingClient,
    SupportsChatGetResponse,
    SupportsCodeInterpreterTool,
    SupportsFileSearchTool,
    SupportsGetEmbeddings,
    SupportsImageGenerationTool,
    SupportsMCPTool,
    SupportsShellTool,
    SupportsWebSearchTool,
)
from ._compaction import (
    COMPACTION_STATE_KEY,
    EXCLUDE_REASON_KEY,
    EXCLUDED_KEY,
    GROUP_ANNOTATION_KEY,
    GROUP_HAS_REASONING_KEY,
    GROUP_ID_KEY,
    GROUP_INDEX_KEY,
    GROUP_KIND_KEY,
    GROUP_TOKEN_COUNT_KEY,
    SUMMARIZED_BY_SUMMARY_ID_KEY,
    SUMMARY_OF_GROUP_IDS_KEY,
    SUMMARY_OF_MESSAGE_IDS_KEY,
    CharacterEstimatorTokenizer,
    CompactionProvider,
    CompactionStrategy,
    ContextWindowCompactionStrategy,
    SelectiveToolCallCompactionStrategy,
    SlidingWindowStrategy,
    SummarizationStrategy,
    TokenBudgetComposedStrategy,
    TokenizerProtocol,
    ToolResultCompactionStrategy,
    TruncationStrategy,
    annotate_message_groups,
    apply_compaction,
    included_messages,
    included_token_count,
)
from ._evaluation import (
    AgentEvalConverter,
    CheckResult,
    ConversationSplit,
    ConversationSplitter,
    EvalItem,
    EvalItemResult,
    EvalNotPassedError,
    EvalResults,
    EvalScoreResult,
    Evaluator,
    ExpectedToolCall,
    LocalEvaluator,
    RubricScore,
    evaluate_agent,
    evaluate_workflow,
    evaluator,
    keyword_check,
    tool_call_args_match,
    tool_called_check,
    tool_calls_present,
)
from ._feature_stage import ExperimentalFeature, ReleaseCandidateFeature
from ._harness._agent import DEFAULT_HARNESS_INSTRUCTIONS, create_harness_agent
from ._harness._background_agents import (
    DEFAULT_BACKGROUND_AGENTS_SOURCE_ID,
    BackgroundAgentsProvider,
    BackgroundTaskInfo,
    BackgroundTaskStatus,
)
from ._harness._file_access import (
    DEFAULT_FILE_ACCESS_INSTRUCTIONS,
    DEFAULT_FILE_ACCESS_SOURCE_ID,
    AgentFileStore,
    FileAccessProvider,
    FileSearchMatch,
    FileSearchResult,
    FileStoreEntry,
    FileSystemAgentFileStore,
    InMemoryAgentFileStore,
)
from ._harness._file_memory import DEFAULT_FILE_MEMORY_INSTRUCTIONS, DEFAULT_FILE_MEMORY_SOURCE_ID, FileMemoryProvider
from ._harness._loop import (
    AgentLoopMiddleware,
    JudgeVerdict,
    background_tasks_running,
    background_tasks_running_message,
    todos_remaining,
    todos_remaining_message,
)
from ._harness._memory import (
    DEFAULT_MEMORY_SOURCE_ID,
    MemoryContextProvider,
    MemoryFileStore,
    MemoryIndexEntry,
    MemoryStore,
    MemoryTopicRecord,
)
from ._harness._mode import DEFAULT_MODE_SOURCE_ID, AgentModeProvider, get_agent_mode, set_agent_mode
from ._harness._todo import (
    DEFAULT_TODO_SOURCE_ID,
    TodoFileStore,
    TodoInput,
    TodoItem,
    TodoProvider,
    TodoSessionStore,
    TodoStore,
)
from ._harness._tool_approval import (
    DEFAULT_TOOL_APPROVAL_SOURCE_ID,
    ToolApprovalMiddleware,
    ToolApprovalRule,
    ToolApprovalRuleCallback,
    ToolApprovalState,
    create_always_approve_tool_response,
    create_always_approve_tool_with_arguments_response,
)
from ._mcp import (
    MCPStdioTool,
    MCPStreamableHTTPTool,
    MCPTaskOptions,
    MCPWebsocketTool,
    SamplingApprovalCallback,
)
from ._middleware import (
    AgentContext,
    AgentMiddleware,
    AgentMiddlewareLayer,
    AgentMiddlewareTypes,
    ChatAndFunctionMiddlewareTypes,
    ChatContext,
    ChatMiddleware,
    ChatMiddlewareLayer,
    ChatMiddlewareTypes,
    FunctionInvocationContext,
    FunctionMiddleware,
    FunctionMiddlewareTypes,
    MiddlewareTermination,
    MiddlewareType,
    MiddlewareTypes,
    agent_middleware,
    chat_middleware,
    function_middleware,
)
from ._sessions import (
    MESSAGE_INJECTION_PENDING_MESSAGES_STATE_KEY,
    AgentSession,
    ContextProvider,
    FileHistoryProvider,
    HistoryProvider,
    InMemoryHistoryProvider,
    MessageInjectionMiddleware,
    ServiceSessionId,
    SessionContext,
    enqueue_messages,
    register_state_type,
)
from ._settings import SecretString, load_settings
from ._skills import (
    AggregatingSkillsSource,
    CachingSkillsSource,
    ClassSkill,
    DeduplicatingSkillsSource,
    DelegatingSkillsSource,
    FileSkill,
    FileSkillScript,
    FileSkillsSource,
    FilteringSkillsSource,
    InlineSkill,
    InlineSkillResource,
    InlineSkillScript,
    InMemorySkillsSource,
    MCPSkill,
    MCPSkillResource,
    MCPSkillsSource,
    Skill,
    SkillFrontmatter,
    SkillResource,
    SkillScript,
    SkillScriptArgumentParser,
    SkillScriptRunner,
    SkillsProvider,
    SkillsSource,
    SkillsSourceContext,
)
from ._telemetry import (
    AGENT_FRAMEWORK_USER_AGENT,
    APP_INFO,
    USER_AGENT_KEY,
    USER_AGENT_TELEMETRY_DISABLED_ENV_VAR,
    prepend_agent_framework_to_user_agent,
)
from ._tools import (
    SKIP_PARSING,
    FunctionInvocationConfiguration,
    FunctionInvocationLayer,
    FunctionTool,
    ToolTypes,
    normalize_function_invocation_configuration,
    tool,
)
from ._types import (
    AgentResponse,
    AgentResponseUpdate,
    AgentRunInputs,
    Annotation,
    ChatOptions,
    ChatResponse,
    ChatResponseUpdate,
    Content,
    ContinuationToken,
    Embedding,
    EmbeddingGenerationOptions,
    EmbeddingInputT,
    EmbeddingT,
    FinalT,
    FinishReason,
    FinishReasonLiteral,
    GeneratedEmbeddings,
    Message,
    OuterFinalT,
    OuterUpdateT,
    ResponseStream,
    Role,
    RoleLiteral,
    TextSpanRegion,
    ToolMode,
    UpdateT,
    UsageDetails,
    add_usage_details,
    detect_media_type_from_base64,
    map_chat_to_agent_update,
    merge_chat_options,
    normalize_messages,
    normalize_tools,
    prepend_instructions_to_messages,
    validate_chat_options,
    validate_tool_mode,
    validate_tools,
)
from ._workflows._agent import WorkflowAgent
from ._workflows._agent_executor import AgentExecutor, AgentExecutorRequest, AgentExecutorResponse
from ._workflows._agent_utils import resolve_agent_id
from ._workflows._checkpoint import (
    CheckpointID,
    CheckpointStorage,
    FileCheckpointStorage,
    InMemoryCheckpointStorage,
    WorkflowCheckpoint,
)
from ._workflows._const import DEFAULT_MAX_ITERATIONS
from ._workflows._edge import (
    Case,
    Default,
    Edge,
    EdgeCondition,
    FanInEdgeGroup,
    FanOutEdgeGroup,
    SingleEdgeGroup,
    SwitchCaseEdgeGroup,
    SwitchCaseEdgeGroupCase,
    SwitchCaseEdgeGroupDefault,
)
from ._workflows._edge_runner import create_edge_runner
from ._workflows._events import (
    WorkflowErrorDetails,
    WorkflowEvent,
    WorkflowEventSource,
    WorkflowEventType,
    WorkflowRunState,
)
from ._workflows._executor import Executor, handler
from ._workflows._function_executor import FunctionExecutor, executor
from ._workflows._functional import (
    FunctionalWorkflow,
    FunctionalWorkflowAgent,
    RunContext,
    StepWrapper,
    get_run_context,
    step,
    workflow,
)
from ._workflows._request_info_mixin import response_handler
from ._workflows._runner import Runner
from ._workflows._runner_context import InProcRunnerContext, RunnerContext, WorkflowMessage
from ._workflows._validation import (
    EdgeDuplicationError,
    GraphConnectivityError,
    TypeCompatibilityError,
    ValidationTypeEnum,
    WorkflowValidationError,
    validate_workflow_graph,
)
from ._workflows._viz import WorkflowViz
from ._workflows._workflow import Workflow, WorkflowRunResult
from ._workflows._workflow_builder import WorkflowBuilder
from ._workflows._workflow_context import WorkflowContext
from ._workflows._workflow_executor import SubWorkflowRequestMessage, SubWorkflowResponseMessage, WorkflowExecutor
from .exceptions import (
    AgentFrameworkException,
    MiddlewareException,
    UserInputRequiredException,
    WorkflowCheckpointException,
    WorkflowConvergenceException,
    WorkflowException,
    WorkflowRunnerException,
)

__all__ = [
    "AGENT_FRAMEWORK_USER_AGENT",
    "APP_INFO",
    "COMPACTION_STATE_KEY",
    "DEFAULT_BACKGROUND_AGENTS_SOURCE_ID",
    "DEFAULT_FILE_ACCESS_INSTRUCTIONS",
    "DEFAULT_FILE_ACCESS_SOURCE_ID",
    "DEFAULT_FILE_MEMORY_INSTRUCTIONS",
    "DEFAULT_FILE_MEMORY_SOURCE_ID",
    "DEFAULT_HARNESS_INSTRUCTIONS",
    "DEFAULT_MAX_ITERATIONS",
    "DEFAULT_MEMORY_SOURCE_ID",
    "DEFAULT_MODE_SOURCE_ID",
    "DEFAULT_TODO_SOURCE_ID",
    "DEFAULT_TOOL_APPROVAL_SOURCE_ID",
    "EXCLUDED_KEY",
    "EXCLUDE_REASON_KEY",
    "GROUP_ANNOTATION_KEY",
    "GROUP_HAS_REASONING_KEY",
    "GROUP_ID_KEY",
    "GROUP_INDEX_KEY",
    "GROUP_KIND_KEY",
    "GROUP_TOKEN_COUNT_KEY",
    "MESSAGE_INJECTION_PENDING_MESSAGES_STATE_KEY",
    "SKIP_PARSING",
    "SUMMARIZED_BY_SUMMARY_ID_KEY",
    "SUMMARY_OF_GROUP_IDS_KEY",
    "SUMMARY_OF_MESSAGE_IDS_KEY",
    "USER_AGENT_KEY",
    "USER_AGENT_TELEMETRY_DISABLED_ENV_VAR",
    "Agent",
    "AgentContext",
    "AgentEvalConverter",
    "AgentExecutor",
    "AgentExecutorRequest",
    "AgentExecutorResponse",
    "AgentFileStore",
    "AgentFrameworkException",
    "AgentLoopMiddleware",
    "AgentMiddleware",
    "AgentMiddlewareLayer",
    "AgentMiddlewareTypes",
    "AgentModeProvider",
    "AgentResponse",
    "AgentResponseUpdate",
    "AgentRunInputs",
    "AgentSession",
    "AggregatingSkillsSource",
    "Annotation",
    "BackgroundAgentsProvider",
    "BackgroundTaskInfo",
    "BackgroundTaskStatus",
    "BaseAgent",
    "BaseChatClient",
    "BaseEmbeddingClient",
    "CachingSkillsSource",
    "Case",
    "CharacterEstimatorTokenizer",
    "ChatAndFunctionMiddlewareTypes",
    "ChatContext",
    "ChatMiddleware",
    "ChatMiddlewareLayer",
    "ChatMiddlewareTypes",
    "ChatOptions",
    "ChatResponse",
    "ChatResponseUpdate",
    "CheckResult",
    "CheckpointID",
    "CheckpointStorage",
    "ClassSkill",
    "CompactionProvider",
    "CompactionStrategy",
    "Content",
    "ContextProvider",
    "ContextWindowCompactionStrategy",
    "ContinuationToken",
    "ConversationSplit",
    "ConversationSplitter",
    "DeduplicatingSkillsSource",
    "Default",
    "DelegatingSkillsSource",
    "Edge",
    "EdgeCondition",
    "EdgeDuplicationError",
    "Embedding",
    "EmbeddingGenerationOptions",
    "EmbeddingInputT",
    "EmbeddingT",
    "EvalItem",
    "EvalItemResult",
    "EvalNotPassedError",
    "EvalResults",
    "EvalScoreResult",
    "Evaluator",
    "Executor",
    "ExpectedToolCall",
    "ExperimentalFeature",
    "FanInEdgeGroup",
    "FanOutEdgeGroup",
    "FileAccessProvider",
    "FileCheckpointStorage",
    "FileHistoryProvider",
    "FileMemoryProvider",
    "FileSearchMatch",
    "FileSearchResult",
    "FileSkill",
    "FileSkillScript",
    "FileSkillsSource",
    "FileStoreEntry",
    "FileSystemAgentFileStore",
    "FilteringSkillsSource",
    "FinalT",
    "FinishReason",
    "FinishReasonLiteral",
    "FunctionExecutor",
    "FunctionInvocationConfiguration",
    "FunctionInvocationContext",
    "FunctionInvocationLayer",
    "FunctionMiddleware",
    "FunctionMiddlewareTypes",
    "FunctionTool",
    "FunctionalWorkflow",
    "FunctionalWorkflowAgent",
    "GeneratedEmbeddings",
    "GraphConnectivityError",
    "HistoryProvider",
    "InMemoryAgentFileStore",
    "InMemoryCheckpointStorage",
    "InMemoryHistoryProvider",
    "InMemorySkillsSource",
    "InProcRunnerContext",
    "InlineSkill",
    "InlineSkillResource",
    "InlineSkillScript",
    "JudgeVerdict",
    "LocalEvaluator",
    "MCPSkill",
    "MCPSkillResource",
    "MCPSkillsSource",
    "MCPStdioTool",
    "MCPStreamableHTTPTool",
    "MCPTaskOptions",
    "MCPWebsocketTool",
    "MemoryContextProvider",
    "MemoryFileStore",
    "MemoryIndexEntry",
    "MemoryStore",
    "MemoryTopicRecord",
    "Message",
    "MessageInjectionMiddleware",
    "MiddlewareException",
    "MiddlewareTermination",
    "MiddlewareType",
    "MiddlewareTypes",
    "OuterFinalT",
    "OuterUpdateT",
    "RawAgent",
    "ReleaseCandidateFeature",
    "ResponseStream",
    "Role",
    "RoleLiteral",
    "RubricScore",
    "RunContext",
    "Runner",
    "RunnerContext",
    "SamplingApprovalCallback",
    "SecretString",
    "SelectiveToolCallCompactionStrategy",
    "ServiceSessionId",
    "SessionContext",
    "SingleEdgeGroup",
    "Skill",
    "SkillFrontmatter",
    "SkillResource",
    "SkillScript",
    "SkillScriptArgumentParser",
    "SkillScriptRunner",
    "SkillsProvider",
    "SkillsSource",
    "SkillsSourceContext",
    "SlidingWindowStrategy",
    "StepWrapper",
    "SubWorkflowRequestMessage",
    "SubWorkflowResponseMessage",
    "SummarizationStrategy",
    "SupportsAgentRun",
    "SupportsChatGetResponse",
    "SupportsCodeInterpreterTool",
    "SupportsFileSearchTool",
    "SupportsGetEmbeddings",
    "SupportsImageGenerationTool",
    "SupportsMCPTool",
    "SupportsShellTool",
    "SupportsWebSearchTool",
    "SwitchCaseEdgeGroup",
    "SwitchCaseEdgeGroupCase",
    "SwitchCaseEdgeGroupDefault",
    "TextSpanRegion",
    "TodoFileStore",
    "TodoInput",
    "TodoItem",
    "TodoProvider",
    "TodoSessionStore",
    "TodoStore",
    "TokenBudgetComposedStrategy",
    "TokenizerProtocol",
    "ToolApprovalMiddleware",
    "ToolApprovalRule",
    "ToolApprovalRuleCallback",
    "ToolApprovalState",
    "ToolMode",
    "ToolResultCompactionStrategy",
    "ToolTypes",
    "TruncationStrategy",
    "TypeCompatibilityError",
    "UpdateT",
    "UsageDetails",
    "UserInputRequiredException",
    "ValidationTypeEnum",
    "Workflow",
    "WorkflowAgent",
    "WorkflowBuilder",
    "WorkflowCheckpoint",
    "WorkflowCheckpointException",
    "WorkflowContext",
    "WorkflowConvergenceException",
    "WorkflowErrorDetails",
    "WorkflowEvent",
    "WorkflowEventSource",
    "WorkflowEventType",
    "WorkflowException",
    "WorkflowExecutor",
    "WorkflowMessage",
    "WorkflowRunResult",
    "WorkflowRunState",
    "WorkflowRunnerException",
    "WorkflowValidationError",
    "WorkflowViz",
    "__version__",
    "add_usage_details",
    "agent_middleware",
    "annotate_message_groups",
    "apply_compaction",
    "background_tasks_running",
    "background_tasks_running_message",
    "chat_middleware",
    "create_always_approve_tool_response",
    "create_always_approve_tool_with_arguments_response",
    "create_edge_runner",
    "create_harness_agent",
    "detect_media_type_from_base64",
    "enqueue_messages",
    "evaluate_agent",
    "evaluate_workflow",
    "evaluator",
    "executor",
    "function_middleware",
    "get_agent_mode",
    "get_run_context",
    "handler",
    "included_messages",
    "included_token_count",
    "keyword_check",
    "load_settings",
    "map_chat_to_agent_update",
    "merge_chat_options",
    "normalize_function_invocation_configuration",
    "normalize_messages",
    "normalize_tools",
    "prepend_agent_framework_to_user_agent",
    "prepend_instructions_to_messages",
    "register_state_type",
    "resolve_agent_id",
    "response_handler",
    "set_agent_mode",
    "step",
    "todos_remaining",
    "todos_remaining_message",
    "tool",
    "tool_call_args_match",
    "tool_called_check",
    "tool_calls_present",
    "validate_chat_options",
    "validate_tool_mode",
    "validate_tools",
    "validate_workflow_graph",
    "workflow",
]
