diff --git a/src/tool_schemas.py b/src/tool_schemas.py index 6adb087..21a8e61 100644 --- a/src/tool_schemas.py +++ b/src/tool_schemas.py @@ -621,6 +621,7 @@ FUNCTION_TOOL_SCHEMAS = [ "type": "object", "properties": { "integration": {"type": "string", "description": "Integration name or ID (e.g. 'Miniflux', 'Gitea')"}, + "integration_id": {"type": "string", "description": "Integration ID alias. Prefer 'integration' when possible; accepted for compatibility with context-provided IDs."}, "method": {"type": "string", "enum": ["GET", "POST", "PUT", "PATCH", "DELETE"], "description": "HTTP method"}, "path": {"type": "string", "description": "API endpoint path (e.g. '/v1/entries?status=unread&limit=20')"}, "body": {"type": "object", "description": "JSON request body (for POST/PUT/PATCH)"} diff --git a/src/tools/system.py b/src/tools/system.py index 3fedac6..36298c4 100644 --- a/src/tools/system.py +++ b/src/tools/system.py @@ -483,7 +483,13 @@ async def do_api_call(content: str) -> Dict: except json.JSONDecodeError: pass - integration_name = args.get("integration", "") + integration_name = ( + args.get("integration") + or args.get("integration_id") + or args.get("integrationId") + or args.get("id") + or "" + ) integrations = load_integrations() intg = next((i for i in integrations if i["id"] == integration_name or i["name"].lower() == integration_name.lower()), None) diff --git a/tests/test_api_call_integration_id_alias.py b/tests/test_api_call_integration_id_alias.py new file mode 100644 index 0000000..96d46ba --- /dev/null +++ b/tests/test_api_call_integration_id_alias.py @@ -0,0 +1,40 @@ +import json +from unittest.mock import AsyncMock, patch + +import pytest + + +@pytest.mark.asyncio +async def test_api_call_accepts_integration_id_alias(): + from src.tools import system + + integrations = [ + { + "id": "f9909f22dc17", + "name": "Gitea", + "enabled": True, + "base_url": "https://git.example.test", + } + ] + + with ( + patch("src.integrations.load_integrations", return_value=integrations), + patch("src.integrations.execute_api_call", new_callable=AsyncMock) as execute, + ): + execute.return_value = {"output": "ok", "exit_code": 0} + + result = await system.do_api_call(json.dumps({ + "integration_id": "f9909f22dc17", + "method": "GET", + "path": "/api/v1/user/repos", + })) + + assert result == {"output": "ok", "exit_code": 0} + execute.assert_awaited_once_with( + "f9909f22dc17", + "GET", + "/api/v1/user/repos", + params=None, + body=None, + extra_headers=None, + )