datarobot-genai 0.2.31__tar.gz → 0.2.39__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/PKG-INFO +1 -1
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/pyproject.toml +1 -1
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/core/cli/agent_kernel.py +4 -1
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/drmcp/core/exceptions.py +0 -4
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/drmcp/core/logging.py +2 -2
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/drmcp/test_utils/clients/base.py +1 -1
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/drmcp/test_utils/mcp_utils_ete.py +20 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/drmcp/tools/clients/gdrive.py +91 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/drmcp/tools/clients/microsoft_graph.py +171 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/drmcp/tools/confluence/tools.py +43 -89
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/drmcp/tools/gdrive/tools.py +115 -58
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/drmcp/tools/jira/tools.py +15 -33
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/drmcp/tools/microsoft_graph/tools.py +152 -20
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/drmcp/tools/predictive/data.py +5 -5
- datarobot_genai-0.2.39/src/datarobot_genai/drmcp/tools/predictive/deployment.py +97 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/drmcp/tools/predictive/deployment_info.py +100 -107
- datarobot_genai-0.2.39/src/datarobot_genai/drmcp/tools/predictive/model.py +183 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/drmcp/tools/predictive/project.py +2 -2
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/drmcp/tools/predictive/training.py +52 -24
- datarobot_genai-0.2.31/src/datarobot_genai/drmcp/tools/predictive/deployment.py +0 -91
- datarobot_genai-0.2.31/src/datarobot_genai/drmcp/tools/predictive/model.py +0 -148
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/.gitignore +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/AUTHORS +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/LICENSE +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/README.md +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/__init__.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/core/__init__.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/core/agents/__init__.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/core/agents/base.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/core/chat/__init__.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/core/chat/auth.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/core/chat/client.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/core/chat/responses.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/core/cli/__init__.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/core/cli/agent_environment.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/core/custom_model.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/core/mcp/__init__.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/core/mcp/common.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/core/telemetry_agent.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/core/utils/__init__.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/core/utils/auth.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/core/utils/urls.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/crewai/__init__.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/crewai/agent.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/crewai/base.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/crewai/events.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/crewai/mcp.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/drmcp/__init__.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/drmcp/core/__init__.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/drmcp/core/auth.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/drmcp/core/clients.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/drmcp/core/config.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/drmcp/core/config_utils.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/drmcp/core/constants.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/drmcp/core/credentials.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/drmcp/core/dr_mcp_server.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/drmcp/core/dr_mcp_server_logo.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/drmcp/core/dynamic_prompts/__init__.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/drmcp/core/dynamic_prompts/controllers.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/drmcp/core/dynamic_prompts/dr_lib.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/drmcp/core/dynamic_prompts/register.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/drmcp/core/dynamic_prompts/utils.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/drmcp/core/dynamic_tools/__init__.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/drmcp/core/dynamic_tools/deployment/__init__.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/drmcp/core/dynamic_tools/deployment/adapters/__init__.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/drmcp/core/dynamic_tools/deployment/adapters/base.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/drmcp/core/dynamic_tools/deployment/adapters/default.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/drmcp/core/dynamic_tools/deployment/adapters/drum.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/drmcp/core/dynamic_tools/deployment/config.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/drmcp/core/dynamic_tools/deployment/controllers.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/drmcp/core/dynamic_tools/deployment/metadata.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/drmcp/core/dynamic_tools/deployment/register.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/drmcp/core/dynamic_tools/deployment/schemas/drum_agentic_fallback_schema.json +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/drmcp/core/dynamic_tools/deployment/schemas/drum_prediction_fallback_schema.json +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/drmcp/core/dynamic_tools/register.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/drmcp/core/dynamic_tools/schema.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/drmcp/core/mcp_instance.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/drmcp/core/memory_management/__init__.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/drmcp/core/memory_management/manager.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/drmcp/core/memory_management/memory_tools.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/drmcp/core/routes.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/drmcp/core/routes_utils.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/drmcp/core/server_life_cycle.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/drmcp/core/telemetry.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/drmcp/core/tool_config.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/drmcp/core/tool_filter.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/drmcp/core/utils.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/drmcp/server.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/drmcp/test_utils/__init__.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/drmcp/test_utils/clients/__init__.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/drmcp/test_utils/clients/anthropic.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/drmcp/test_utils/clients/dr_gateway.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/drmcp/test_utils/clients/openai.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/drmcp/test_utils/elicitation_test_tool.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/drmcp/test_utils/integration_mcp_server.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/drmcp/test_utils/mcp_utils_integration.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/drmcp/test_utils/test_interactive.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/drmcp/test_utils/tool_base_ete.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/drmcp/test_utils/utils.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/drmcp/tools/__init__.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/drmcp/tools/clients/__init__.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/drmcp/tools/clients/atlassian.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/drmcp/tools/clients/confluence.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/drmcp/tools/clients/jira.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/drmcp/tools/clients/s3.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/drmcp/tools/confluence/__init__.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/drmcp/tools/gdrive/__init__.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/drmcp/tools/jira/__init__.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/drmcp/tools/microsoft_graph/__init__.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/drmcp/tools/predictive/__init__.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/drmcp/tools/predictive/predict.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/drmcp/tools/predictive/predict_realtime.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/langgraph/__init__.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/langgraph/agent.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/langgraph/mcp.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/llama_index/__init__.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/llama_index/agent.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/llama_index/base.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/llama_index/mcp.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/nat/__init__.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/nat/agent.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/nat/datarobot_auth_provider.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/nat/datarobot_llm_clients.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/nat/datarobot_llm_providers.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/nat/datarobot_mcp_client.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/nat/helpers.py +0 -0
- {datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/py.typed +0 -0
{datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/core/cli/agent_kernel.py
RENAMED
|
@@ -107,7 +107,10 @@ class AgentKernel:
|
|
|
107
107
|
stream: bool = False,
|
|
108
108
|
config: Any | None = None,
|
|
109
109
|
) -> ChatCompletion | Stream[ChatCompletionChunk]:
|
|
110
|
-
|
|
110
|
+
if config is not None:
|
|
111
|
+
chat_api_url = f"http://localhost:{config.local_dev_port}"
|
|
112
|
+
else:
|
|
113
|
+
chat_api_url = self.base_url
|
|
111
114
|
print(chat_api_url)
|
|
112
115
|
|
|
113
116
|
return self._do_chat_completion(chat_api_url, user_prompt, completion_json, stream=stream)
|
|
@@ -20,7 +20,7 @@ from collections.abc import Callable
|
|
|
20
20
|
from typing import Any
|
|
21
21
|
from typing import TypeVar
|
|
22
22
|
|
|
23
|
-
from .exceptions import
|
|
23
|
+
from fastmcp.exceptions import ToolError
|
|
24
24
|
|
|
25
25
|
# Secret patterns to redact from logs
|
|
26
26
|
SECRET_PATTERNS = [
|
|
@@ -93,6 +93,6 @@ def log_execution(func: F) -> F:
|
|
|
93
93
|
return result
|
|
94
94
|
except Exception as e:
|
|
95
95
|
error_msg = _log_error(logger, func.__name__, e, args=args, kwargs=kwargs)
|
|
96
|
-
raise
|
|
96
|
+
raise ToolError(error_msg)
|
|
97
97
|
|
|
98
98
|
return wrapper # type: ignore[return-value]
|
|
@@ -27,7 +27,7 @@ from mcp.types import ListToolsResult
|
|
|
27
27
|
from mcp.types import TextContent
|
|
28
28
|
from openai.types.chat.chat_completion import ChatCompletion
|
|
29
29
|
|
|
30
|
-
from
|
|
30
|
+
from datarobot_genai.drmcp.test_utils.utils import save_response_to_file
|
|
31
31
|
|
|
32
32
|
|
|
33
33
|
class ToolCall:
|
|
@@ -68,6 +68,26 @@ def get_openai_llm_client_config() -> dict[str, str]:
|
|
|
68
68
|
return config
|
|
69
69
|
|
|
70
70
|
|
|
71
|
+
def get_dr_llm_gateway_client_config() -> dict[str, str]:
|
|
72
|
+
"""Get DataRobot LLM Gateway client configuration."""
|
|
73
|
+
datarobot_api_token = os.environ.get("DATAROBOT_API_TOKEN")
|
|
74
|
+
datarobot_endpoint = os.environ.get("DATAROBOT_ENDPOINT")
|
|
75
|
+
save_llm_responses = os.environ.get("SAVE_LLM_RESPONSES", "false").lower() == "true"
|
|
76
|
+
|
|
77
|
+
if not datarobot_api_token:
|
|
78
|
+
raise ValueError("Missing required environment variable: DATAROBOT_API_TOKEN")
|
|
79
|
+
|
|
80
|
+
config: dict[str, str] = {
|
|
81
|
+
"datarobot_api_token": datarobot_api_token,
|
|
82
|
+
"save_llm_responses": str(save_llm_responses),
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if datarobot_endpoint:
|
|
86
|
+
config["datarobot_endpoint"] = datarobot_endpoint
|
|
87
|
+
|
|
88
|
+
return config
|
|
89
|
+
|
|
90
|
+
|
|
71
91
|
def get_headers() -> dict[str, str]:
|
|
72
92
|
# When the MCP server is deployed in DataRobot, we have to include the API token in headers for
|
|
73
93
|
# authentication.
|
{datarobot_genai-0.2.31 → datarobot_genai-0.2.39}/src/datarobot_genai/drmcp/tools/clients/gdrive.py
RENAMED
|
@@ -20,6 +20,7 @@ import logging
|
|
|
20
20
|
import uuid
|
|
21
21
|
from typing import Annotated
|
|
22
22
|
from typing import Any
|
|
23
|
+
from typing import Literal
|
|
23
24
|
|
|
24
25
|
import httpx
|
|
25
26
|
from datarobot.auth.datarobot.exceptions import OAuthServiceClientErr
|
|
@@ -821,6 +822,96 @@ class GoogleDriveClient:
|
|
|
821
822
|
headers={"Content-Type": f"multipart/related; boundary={boundary}"},
|
|
822
823
|
)
|
|
823
824
|
|
|
825
|
+
async def manage_access(
|
|
826
|
+
self,
|
|
827
|
+
*,
|
|
828
|
+
file_id: str,
|
|
829
|
+
action: Literal["add", "update", "remove"],
|
|
830
|
+
role: Literal["reader", "commenter", "writer", "fileOrganizer", "organizer", "owner"]
|
|
831
|
+
| None = None,
|
|
832
|
+
email_address: str | None = None,
|
|
833
|
+
permission_id: str | None = None,
|
|
834
|
+
transfer_ownership: bool = False,
|
|
835
|
+
) -> str:
|
|
836
|
+
"""Manage access permissions for a Google Drive file or folder.
|
|
837
|
+
|
|
838
|
+
Adds, updates, or removes sharing permissions on an existing Google Drive
|
|
839
|
+
file or folder using the Google Drive Permissions API.
|
|
840
|
+
|
|
841
|
+
This method supports granting access to users or groups, changing access
|
|
842
|
+
roles, and revoking permissions. Ownership transfer is supported for files
|
|
843
|
+
in "My Drive" when explicitly requested.
|
|
844
|
+
|
|
845
|
+
Args:
|
|
846
|
+
file_id: The ID of the Google Drive file or folder whose permissions
|
|
847
|
+
are being managed.
|
|
848
|
+
action: The permission operation to perform.
|
|
849
|
+
role: The access role to assign or update. Valid values include
|
|
850
|
+
Required for "add" and "update" actions.
|
|
851
|
+
email_address: The email address of the user or group to grant access to.
|
|
852
|
+
Required for the "add" action.
|
|
853
|
+
permission_id: The ID of the permission to update or remove.
|
|
854
|
+
Required for "update" and "remove" actions.
|
|
855
|
+
transfer_ownership: Whether to transfer ownership of the file.
|
|
856
|
+
Only applicable when action="update" and role="owner".
|
|
857
|
+
|
|
858
|
+
Returns
|
|
859
|
+
-------
|
|
860
|
+
Permission id.
|
|
861
|
+
For "add" its newly added permission.
|
|
862
|
+
For "update"/"remove" its previous permission.
|
|
863
|
+
|
|
864
|
+
Raises
|
|
865
|
+
------
|
|
866
|
+
GoogleDriveError: If the permission operation fails (invalid arguments,
|
|
867
|
+
insufficient permissions, resource not found, ownership transfer
|
|
868
|
+
not allowed, rate limited, etc.).
|
|
869
|
+
"""
|
|
870
|
+
if not file_id.strip():
|
|
871
|
+
raise GoogleDriveError("Argument validation error: 'file_id' cannot be empty.")
|
|
872
|
+
|
|
873
|
+
if action == "add" and not email_address:
|
|
874
|
+
raise GoogleDriveError("'email_address' is required for action 'add'.")
|
|
875
|
+
|
|
876
|
+
if action in ("update", "remove") and not permission_id:
|
|
877
|
+
raise GoogleDriveError("'permission_id' is required for action 'update' or 'remove'.")
|
|
878
|
+
|
|
879
|
+
if action != "remove" and not role:
|
|
880
|
+
raise GoogleDriveError("'role' is required for action 'add' or 'update'.")
|
|
881
|
+
|
|
882
|
+
if action == "add":
|
|
883
|
+
response = await self._client.post(
|
|
884
|
+
url=f"/{file_id}/permissions",
|
|
885
|
+
json={
|
|
886
|
+
"type": "user",
|
|
887
|
+
"role": role,
|
|
888
|
+
"emailAddress": email_address,
|
|
889
|
+
},
|
|
890
|
+
params={"sendNotificationEmail": False, "supportsAllDrives": True},
|
|
891
|
+
)
|
|
892
|
+
|
|
893
|
+
elif action == "update":
|
|
894
|
+
response = await self._client.patch(
|
|
895
|
+
url=f"/{file_id}/permissions/{permission_id}",
|
|
896
|
+
json={"role": role},
|
|
897
|
+
params={"transferOwnership": transfer_ownership, "supportsAllDrives": True},
|
|
898
|
+
)
|
|
899
|
+
|
|
900
|
+
elif action == "remove":
|
|
901
|
+
response = await self._client.delete(url=f"/{file_id}/permissions/{permission_id}")
|
|
902
|
+
|
|
903
|
+
else:
|
|
904
|
+
raise GoogleDriveError(f"Invalid action '{action}'")
|
|
905
|
+
|
|
906
|
+
if response.status_code not in (200, 201, 204):
|
|
907
|
+
raise GoogleDriveError(f"Drive API error {response.status_code}: {response.text}")
|
|
908
|
+
|
|
909
|
+
if action == "add":
|
|
910
|
+
return response.json()["id"]
|
|
911
|
+
|
|
912
|
+
# Cannot be null here because of above validators
|
|
913
|
+
return permission_id # type: ignore
|
|
914
|
+
|
|
824
915
|
async def __aenter__(self) -> "GoogleDriveClient":
|
|
825
916
|
"""Async context manager entry."""
|
|
826
917
|
return self
|
|
@@ -16,6 +16,8 @@
|
|
|
16
16
|
|
|
17
17
|
import logging
|
|
18
18
|
from typing import Any
|
|
19
|
+
from typing import Literal
|
|
20
|
+
from urllib.parse import quote
|
|
19
21
|
|
|
20
22
|
import httpx
|
|
21
23
|
from datarobot.auth.datarobot.exceptions import OAuthServiceClientErr
|
|
@@ -415,6 +417,175 @@ class MicrosoftGraphClient:
|
|
|
415
417
|
|
|
416
418
|
return base_resource
|
|
417
419
|
|
|
420
|
+
async def get_personal_drive_id(self) -> str:
|
|
421
|
+
"""Get the current user's personal OneDrive drive ID.
|
|
422
|
+
|
|
423
|
+
Returns
|
|
424
|
+
-------
|
|
425
|
+
The drive ID string for the user's personal OneDrive.
|
|
426
|
+
|
|
427
|
+
Raises
|
|
428
|
+
------
|
|
429
|
+
MicrosoftGraphError: If the drive cannot be retrieved.
|
|
430
|
+
"""
|
|
431
|
+
try:
|
|
432
|
+
response = await self._client.get(f"{GRAPH_API_BASE}/me/drive")
|
|
433
|
+
response.raise_for_status()
|
|
434
|
+
data = response.json()
|
|
435
|
+
return data["id"]
|
|
436
|
+
except httpx.HTTPStatusError as e:
|
|
437
|
+
status_code = e.response.status_code
|
|
438
|
+
if status_code == 401:
|
|
439
|
+
raise MicrosoftGraphError(
|
|
440
|
+
"Authentication failed. Access token may be expired or invalid."
|
|
441
|
+
) from e
|
|
442
|
+
if status_code == 403:
|
|
443
|
+
raise MicrosoftGraphError(
|
|
444
|
+
"Permission denied: cannot access personal OneDrive. "
|
|
445
|
+
"Requires Files.Read or Files.ReadWrite permission."
|
|
446
|
+
) from e
|
|
447
|
+
raise MicrosoftGraphError(f"Failed to get personal OneDrive: HTTP {status_code}") from e
|
|
448
|
+
|
|
449
|
+
async def create_file(
|
|
450
|
+
self,
|
|
451
|
+
drive_id: str,
|
|
452
|
+
file_name: str,
|
|
453
|
+
content: str,
|
|
454
|
+
parent_folder_id: str = "root",
|
|
455
|
+
conflict_behavior: str = "rename",
|
|
456
|
+
) -> MicrosoftGraphItem:
|
|
457
|
+
"""Create a text file in a drive (SharePoint document library or OneDrive).
|
|
458
|
+
|
|
459
|
+
Uses Microsoft Graph's simple upload endpoint for files < 4MB.
|
|
460
|
+
Files are created as text/plain content.
|
|
461
|
+
|
|
462
|
+
Args:
|
|
463
|
+
drive_id: The ID of the drive (document library) where the file will be created.
|
|
464
|
+
file_name: The name of the file to create (e.g., 'report.txt').
|
|
465
|
+
content: The text content to store in the file.
|
|
466
|
+
parent_folder_id: ID of the parent folder. Defaults to "root" (drive root folder).
|
|
467
|
+
conflict_behavior: How to handle name conflicts. Options:
|
|
468
|
+
- "rename" (default): Auto-renames to 'filename (1).txt', etc.
|
|
469
|
+
- "fail": Returns 409 Conflict error
|
|
470
|
+
- "replace": Overwrites existing file
|
|
471
|
+
|
|
472
|
+
Returns
|
|
473
|
+
-------
|
|
474
|
+
MicrosoftGraphItem representing the created file.
|
|
475
|
+
|
|
476
|
+
Raises
|
|
477
|
+
------
|
|
478
|
+
MicrosoftGraphError: If file creation fails.
|
|
479
|
+
"""
|
|
480
|
+
if not drive_id or not drive_id.strip():
|
|
481
|
+
raise MicrosoftGraphError("drive_id cannot be empty")
|
|
482
|
+
if not file_name or not file_name.strip():
|
|
483
|
+
raise MicrosoftGraphError("file_name cannot be empty")
|
|
484
|
+
|
|
485
|
+
# URL encode the filename for path-based addressing
|
|
486
|
+
encoded_name = quote(file_name, safe="")
|
|
487
|
+
|
|
488
|
+
# Simple upload endpoint for files < 4MB
|
|
489
|
+
# Reference: https://learn.microsoft.com/en-us/graph/api/driveitem-put-content
|
|
490
|
+
upload_url = (
|
|
491
|
+
f"{GRAPH_API_BASE}/drives/{drive_id}/items/{parent_folder_id}:/{encoded_name}:/content"
|
|
492
|
+
)
|
|
493
|
+
|
|
494
|
+
try:
|
|
495
|
+
response = await self._client.put(
|
|
496
|
+
upload_url,
|
|
497
|
+
content=content.encode("utf-8"),
|
|
498
|
+
headers={"Content-Type": "text/plain"},
|
|
499
|
+
params={"@microsoft.graph.conflictBehavior": conflict_behavior},
|
|
500
|
+
)
|
|
501
|
+
response.raise_for_status()
|
|
502
|
+
except httpx.HTTPStatusError as e:
|
|
503
|
+
raise self._handle_create_file_error(e, drive_id, file_name, parent_folder_id) from e
|
|
504
|
+
|
|
505
|
+
return MicrosoftGraphItem.from_api_response(response.json())
|
|
506
|
+
|
|
507
|
+
def _handle_create_file_error(
|
|
508
|
+
self,
|
|
509
|
+
error: httpx.HTTPStatusError,
|
|
510
|
+
drive_id: str,
|
|
511
|
+
file_name: str,
|
|
512
|
+
parent_folder_id: str,
|
|
513
|
+
) -> MicrosoftGraphError:
|
|
514
|
+
"""Handle HTTP errors for file creation and return appropriate MicrosoftGraphError."""
|
|
515
|
+
status_code = error.response.status_code
|
|
516
|
+
error_msg = f"Failed to create file: HTTP {status_code}"
|
|
517
|
+
|
|
518
|
+
if status_code == 400:
|
|
519
|
+
try:
|
|
520
|
+
error_data = error.response.json()
|
|
521
|
+
api_message = error_data.get("error", {}).get("message", "Invalid request")
|
|
522
|
+
error_msg = f"Bad request creating file: {api_message}"
|
|
523
|
+
except Exception:
|
|
524
|
+
error_msg = "Bad request: invalid parameters for file creation."
|
|
525
|
+
elif status_code == 401:
|
|
526
|
+
error_msg = "Authentication failed. Access token may be expired or invalid."
|
|
527
|
+
elif status_code == 403:
|
|
528
|
+
error_msg = (
|
|
529
|
+
f"Permission denied: you don't have permission to create files in drive "
|
|
530
|
+
f"'{drive_id}'. Requires Files.ReadWrite.All permission."
|
|
531
|
+
)
|
|
532
|
+
elif status_code == 404:
|
|
533
|
+
error_msg = (
|
|
534
|
+
f"Parent folder '{parent_folder_id}' not found in drive '{drive_id}'."
|
|
535
|
+
if parent_folder_id != "root"
|
|
536
|
+
else f"Drive '{drive_id}' not found."
|
|
537
|
+
)
|
|
538
|
+
elif status_code == 409:
|
|
539
|
+
error_msg = f"File '{file_name}' already exists and conflict behavior is set to 'fail'."
|
|
540
|
+
elif status_code == 429:
|
|
541
|
+
error_msg = "Rate limit exceeded. Please try again later."
|
|
542
|
+
|
|
543
|
+
return MicrosoftGraphError(error_msg)
|
|
544
|
+
|
|
545
|
+
async def share_item(
|
|
546
|
+
self,
|
|
547
|
+
file_id: str,
|
|
548
|
+
document_library_id: str,
|
|
549
|
+
recipient_emails: list[str],
|
|
550
|
+
role: Literal["read", "write"],
|
|
551
|
+
send_invitation: bool,
|
|
552
|
+
) -> None:
|
|
553
|
+
"""
|
|
554
|
+
Share sharepoint / ondrive item using Microsoft Graph API.
|
|
555
|
+
Under the hood all resources in sharepoint/onedrive
|
|
556
|
+
in MS Graph API are treated as 'driveItem'.
|
|
557
|
+
|
|
558
|
+
Args:
|
|
559
|
+
file_id: The ID of the file or folder to share.
|
|
560
|
+
document_library_id: The ID of the document library containing the item.
|
|
561
|
+
recipient_emails: A list of email addresses to invite.
|
|
562
|
+
role: The role to assign.
|
|
563
|
+
send_invitation: Flag determining if recipients should be notified
|
|
564
|
+
|
|
565
|
+
Returns
|
|
566
|
+
-------
|
|
567
|
+
None
|
|
568
|
+
|
|
569
|
+
Raises
|
|
570
|
+
------
|
|
571
|
+
MicrosoftGraphError: If sharing fails
|
|
572
|
+
"""
|
|
573
|
+
graph_url = f"{GRAPH_API_BASE}/drives/{document_library_id}/items/{file_id}/invite"
|
|
574
|
+
|
|
575
|
+
payload = {
|
|
576
|
+
"recipients": [{"email": email} for email in recipient_emails],
|
|
577
|
+
"requireSignIn": True,
|
|
578
|
+
"sendInvitation": send_invitation,
|
|
579
|
+
"roles": [role],
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
response = await self._client.post(url=graph_url, json=payload)
|
|
583
|
+
|
|
584
|
+
if response.status_code not in (200, 201):
|
|
585
|
+
raise MicrosoftGraphError(
|
|
586
|
+
f"Microsoft Graph API error {response.status_code}: {response.text}"
|
|
587
|
+
)
|
|
588
|
+
|
|
418
589
|
async def __aenter__(self) -> "MicrosoftGraphClient":
|
|
419
590
|
"""Async context manager entry."""
|
|
420
591
|
return self
|
|
@@ -55,26 +55,16 @@ async def confluence_get_page(
|
|
|
55
55
|
if isinstance(access_token, ToolError):
|
|
56
56
|
raise access_token
|
|
57
57
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
page_response = await client.get_page_by_title(page_id_or_title, space_key)
|
|
69
|
-
except ConfluenceError as e:
|
|
70
|
-
logger.error(f"Confluence error getting page: {e}")
|
|
71
|
-
raise ToolError(str(e))
|
|
72
|
-
except Exception as e:
|
|
73
|
-
logger.error(f"Unexpected error getting Confluence page: {e}")
|
|
74
|
-
raise ToolError(
|
|
75
|
-
f"An unexpected error occurred while getting Confluence page "
|
|
76
|
-
f"'{page_id_or_title}': {str(e)}"
|
|
77
|
-
)
|
|
58
|
+
async with ConfluenceClient(access_token) as client:
|
|
59
|
+
if page_id_or_title.isdigit():
|
|
60
|
+
page_response = await client.get_page_by_id(page_id_or_title)
|
|
61
|
+
else:
|
|
62
|
+
if not space_key:
|
|
63
|
+
raise ToolError(
|
|
64
|
+
"Argument validation error: "
|
|
65
|
+
"'space_key' is required when identifying a page by title."
|
|
66
|
+
)
|
|
67
|
+
page_response = await client.get_page_by_title(page_id_or_title, space_key)
|
|
78
68
|
|
|
79
69
|
return ToolResult(
|
|
80
70
|
content=f"Successfully retrieved page '{page_response.title}'.",
|
|
@@ -116,22 +106,12 @@ async def confluence_create_page(
|
|
|
116
106
|
if isinstance(access_token, ToolError):
|
|
117
107
|
raise access_token
|
|
118
108
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
parent_id=parent_id,
|
|
126
|
-
)
|
|
127
|
-
except ConfluenceError as e:
|
|
128
|
-
logger.error(f"Confluence error creating page: {e}")
|
|
129
|
-
raise ToolError(str(e))
|
|
130
|
-
except Exception as e:
|
|
131
|
-
logger.error(f"Unexpected error creating Confluence page: {e}")
|
|
132
|
-
raise ToolError(
|
|
133
|
-
f"An unexpected error occurred while creating Confluence page "
|
|
134
|
-
f"'{title}' in space '{space_key}': {str(e)}"
|
|
109
|
+
async with ConfluenceClient(access_token) as client:
|
|
110
|
+
page_response = await client.create_page(
|
|
111
|
+
space_key=space_key,
|
|
112
|
+
title=title,
|
|
113
|
+
body_content=body_content,
|
|
114
|
+
parent_id=parent_id,
|
|
135
115
|
)
|
|
136
116
|
|
|
137
117
|
return ToolResult(
|
|
@@ -164,19 +144,10 @@ async def confluence_add_comment(
|
|
|
164
144
|
if isinstance(access_token, ToolError):
|
|
165
145
|
raise access_token
|
|
166
146
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
comment_body=comment_body,
|
|
172
|
-
)
|
|
173
|
-
except ConfluenceError as e:
|
|
174
|
-
logger.error(f"Confluence error adding comment: {e}")
|
|
175
|
-
raise ToolError(str(e))
|
|
176
|
-
except Exception as e:
|
|
177
|
-
logger.error(f"Unexpected error adding comment to Confluence page: {e}")
|
|
178
|
-
raise ToolError(
|
|
179
|
-
f"An unexpected error occurred while adding comment to page '{page_id}': {str(e)}"
|
|
147
|
+
async with ConfluenceClient(access_token) as client:
|
|
148
|
+
comment_response = await client.add_comment(
|
|
149
|
+
page_id=page_id,
|
|
150
|
+
comment_body=comment_body,
|
|
180
151
|
)
|
|
181
152
|
|
|
182
153
|
return ToolResult(
|
|
@@ -220,32 +191,24 @@ async def confluence_search(
|
|
|
220
191
|
if isinstance(access_token, ToolError):
|
|
221
192
|
raise access_token
|
|
222
193
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
data = [result.as_flat_dict() for result in results]
|
|
242
|
-
|
|
243
|
-
except ConfluenceError as e:
|
|
244
|
-
logger.error(f"Confluence error searching content: {e}")
|
|
245
|
-
raise ToolError(str(e))
|
|
246
|
-
except Exception as e:
|
|
247
|
-
logger.error(f"Unexpected error searching Confluence content: {e}")
|
|
248
|
-
raise ToolError(f"An unexpected error occurred while searching Confluence: {str(e)}")
|
|
194
|
+
async with ConfluenceClient(access_token) as client:
|
|
195
|
+
results = await client.search_confluence_content(
|
|
196
|
+
cql_query=cql_query, max_results=max_results
|
|
197
|
+
)
|
|
198
|
+
|
|
199
|
+
# If include_body is True, fetch full content for each page
|
|
200
|
+
if include_body and results:
|
|
201
|
+
data = []
|
|
202
|
+
for result in results:
|
|
203
|
+
flat = result.as_flat_dict()
|
|
204
|
+
try:
|
|
205
|
+
page = await client.get_page_by_id(result.id)
|
|
206
|
+
flat["body"] = page.body
|
|
207
|
+
except ConfluenceError:
|
|
208
|
+
flat["body"] = None # Keep excerpt if page fetch fails
|
|
209
|
+
data.append(flat)
|
|
210
|
+
else:
|
|
211
|
+
data = [result.as_flat_dict() for result in results]
|
|
249
212
|
|
|
250
213
|
n = len(results)
|
|
251
214
|
return ToolResult(
|
|
@@ -296,20 +259,11 @@ async def confluence_update_page(
|
|
|
296
259
|
if isinstance(access_token, ToolError):
|
|
297
260
|
raise access_token
|
|
298
261
|
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
version_number=version_number,
|
|
305
|
-
)
|
|
306
|
-
except ConfluenceError as e:
|
|
307
|
-
logger.error(f"Confluence error updating page: {e}")
|
|
308
|
-
raise ToolError(str(e))
|
|
309
|
-
except Exception as e:
|
|
310
|
-
logger.error(f"Unexpected error updating Confluence page: {e}")
|
|
311
|
-
raise ToolError(
|
|
312
|
-
f"An unexpected error occurred while updating Confluence page '{page_id}': {str(e)}"
|
|
262
|
+
async with ConfluenceClient(access_token) as client:
|
|
263
|
+
page_response = await client.update_page(
|
|
264
|
+
page_id=page_id,
|
|
265
|
+
new_body_content=new_body_content,
|
|
266
|
+
version_number=version_number,
|
|
313
267
|
)
|
|
314
268
|
|
|
315
269
|
return ToolResult(
|