arcade-mcp/toolkits/microsoft/arcade_microsoft/outlook_calendar/tools/create_event.py
Sam Partee b6b4cd0a4c
🏗️ Restructure: Multi-Package Architecture + uv Migration (#412)
### Overview
Major restructuring from monolithic `arcade-ai` package to modular
library architecture with standardized uv-based dependency management.

![arcade-ai Monorepo
(2)](https://github.com/user-attachments/assets/25f102b0-bb87-4a04-9701-d227d05664b1)

### New Package Structure
- **`arcade-tdk`** - Lightweight toolkit development kit (core
decorators, auth)
- **`arcade-core`** - Core execution engine and catalog functionality  
- **`arcade-serve`** - FastAPI/MCP server components
- **`arcade-ai`** - Meta package that includes CLI functionality.
Optionally include evals via the `evals` extra. Optionally include all
packages via the `all` extra.

### Key Benefits
- **Lighter Dependencies**: Toolkits now depend only on `arcade-tdk` (~2
deps) vs full `arcade-ai` (~30+ deps)
- **Faster Builds**: uv provides 10-100x faster dependency resolution
and installation
- **Better Modularity**: Clear separation of concerns, consumers import
only what they need
- **Standard Tooling**: Eliminates custom poetry scripts, uses standard
Python packaging

### Migration Impact
- All 20 toolkits converted from poetry → uv with `arcade-tdk`
dependencies plus `arcade-ai[evals]` and `arcade-serve` dev
dependencies. When developing locally, devs should install toolkits via
`make install-local`.
- Modern Python 3.10+ type hints throughout
- Standardized build system with hatchling backend
- Enhanced Makefile with robust toolkit management commands
- Removed `arcade dev` CLI command
- Reduce the number of files created by `arcade new` and add an option
to not generate a tests and evals folder.

This foundation enables faster development cycles and cleaner dependency
chains for the growing toolkit ecosystem.

### Todo After this PR is merged
- [ ] Post-merge workflow(s) (release & publish containers, etc)
- [ ] Release order plan. @EricGustin suggests releasing in the
following order:
    1. `arcade-core` version 0.1.0
    2. `arcade-serve` version 0.1.0 and `arcade-tdk` version 0.1.0
    3. `arcade-ai` version 2.0.0
4. Patch release for all toolkits (all changes in toolkits are internal
refactors)
- [ ] [Update docs](https://github.com/ArcadeAI/docs/pull/318)

---------

Co-authored-by: Eric Gustin <eric@arcade.dev>
Co-authored-by: Eric Gustin <34000337+EricGustin@users.noreply.github.com>
2025-06-11 16:48:17 -07:00

81 lines
3.2 KiB
Python

from typing import Annotated
from arcade_tdk import ToolContext, tool
from arcade_tdk.auth import Microsoft
from arcade_microsoft.client import get_client
from arcade_microsoft.outlook_calendar._utils import (
create_timezone_request_config,
get_default_calendar_timezone,
prepare_meeting_body,
remove_timezone_offset,
validate_date_times,
validate_emails,
)
from arcade_microsoft.outlook_calendar.models import (
Attendee,
DateTimeTimeZone,
Event,
)
@tool(requires_auth=Microsoft(scopes=["MailboxSettings.Read", "Calendars.ReadWrite"]))
async def create_event(
context: ToolContext,
subject: Annotated[str, "The text of the event's subject (title) line."],
body: Annotated[str, "The body of the event"],
start_date_time: Annotated[
str,
"The datetime of the event's start, represented in "
"ISO 8601 format. Timezone offset is ignored. For example, 2025-04-25T13:00:00",
],
end_date_time: Annotated[
str,
"The datetime of the event's end, represented in "
"ISO 8601 format. Timezone offset is ignored. For example, 2025-04-25T13:30:00",
],
location: Annotated[str | None, "The location of the event"] = None,
attendee_emails: Annotated[
list[str] | None,
"The email addresses of the attendees of the event. "
"Must be valid email addresses e.g., username@domain.com.",
] = None,
is_online_meeting: Annotated[
bool, "Whether the event is an online meeting. Defaults to False"
] = False,
custom_meeting_url: Annotated[
str | None,
"The URL of the online meeting. If not provided and is_online_meeting is True, "
"then a url will be generated for you",
] = None,
) -> Annotated[dict, "A dictionary containing the created event details"]:
"""Create an event in the authenticated user's default calendar.
Ignores timezone offsets provided in the start_date_time and end_date_time parameters.
Instead, uses the user's default calendar timezone to filter events.
If the user has not set a timezone for their calendar, then the timezone will be UTC.
"""
# Validate & cleanse inputs
validate_emails(attendee_emails or [])
validate_date_times(start_date_time, end_date_time)
body, is_online_meeting = prepare_meeting_body(body, custom_meeting_url, is_online_meeting)
client = get_client(context.get_auth_token_or_empty())
time_zone = await get_default_calendar_timezone(client)
start_date_time = remove_timezone_offset(start_date_time)
end_date_time = remove_timezone_offset(end_date_time)
event = Event(
subject=subject,
body=body,
start=DateTimeTimeZone(date_time=start_date_time, time_zone=time_zone),
end=DateTimeTimeZone(date_time=end_date_time, time_zone=time_zone),
location=location or "",
attendees=[Attendee(address=attendee) for attendee in attendee_emails or []],
is_online_meeting=is_online_meeting,
).to_sdk()
request_config = create_timezone_request_config(time_zone)
response = await client.me.events.post(body=event, request_configuration=request_config)
return Event.from_sdk(response).to_dict() # type: ignore[arg-type]