6.2 KiB
6.2 KiB
phase, plan, subsystem, tags, dependency_graph, tech_stack, key_files, decisions, metrics
| phase | plan | subsystem | tags | dependency_graph | tech_stack | key_files | decisions | metrics | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 10-agent-capabilities | 02 | agent-capabilities |
|
|
|
|
|
|
Phase 10 Plan 02: Google Calendar OAuth and Calendar Tool CRUD Summary
Per-tenant Google Calendar OAuth install/callback with encrypted token storage, full CRUD calendar tool replacing the service account stub, and natural language tool result formatting (CAP-05, CAP-06).
Tasks Completed
Task 1: Google Calendar OAuth endpoints and calendar tool replacement (TDD)
Files created/modified:
packages/shared/shared/api/calendar_auth.py— OAuth install/callback/status endpointspackages/orchestrator/orchestrator/tools/builtins/calendar_lookup.py— Per-tenant OAuth calendar toolmigrations/versions/013_google_calendar_channel.py— Add google_calendar to CHECK constrainttests/unit/test_calendar_auth.py— 6 tests for OAuth endpointstests/unit/test_calendar_lookup.py— 10 tests for calendar tool
Commit: 08572fc
What was built:
calendar_auth_routerat/api/portal/calendarwith 3 endpoints:GET /install?tenant_id=— generates HMAC-signed state, returns Google OAuth URL with offline/consentGET /callback?code=&state=— verifies HMAC state, exchanges code for tokens, upserts ChannelConnectionGET /{tenant_id}/status— returns{"connected": bool}
calendar_lookup.pyfully replaced — no moreGOOGLE_SERVICE_ACCOUNT_KEYdependency:action="list"— fetches events for date, formats as- HH:MM: Event titleaction="check_availability"— lists busy slots or "entire day is free"action="create"— creates event with summary/start/end, returns confirmation- Token auto-refresh: google-auth refreshes expired access tokens, updated token written back to DB
- Returns informative messages for missing tenant_id, no connection, and errors
Task 2: Mount new API routers and update tool schema + prompt builder
Files modified:
packages/shared/shared/api/__init__.py— exportkb_routerandcalendar_auth_routerpackages/gateway/gateway/main.py— mount kb_router and calendar_auth_routerpackages/orchestrator/orchestrator/tools/registry.py— updated calendar_lookup schema with CRUD paramspackages/orchestrator/orchestrator/agents/builder.py— add tool result formatting instruction (CAP-06)
Commit: a64634f
What was done:
- KB and Calendar Auth routers mounted on gateway under Phase 10 section
- calendar_lookup schema updated:
action(enum),event_summary,event_start,event_endadded requiredupdated to["date", "action"]build_system_prompt()now appends "Never show raw data or JSON to user" when agent has tool_assignments- Confirmed CAP-04 (http_request): in registry, works, no changes needed
- Confirmed CAP-07 (audit logging): executor.py calls
audit_logger.log_tool_call()on every tool invocation
Deviations from Plan
Auto-fixed Issues
1. [Rule 2 - Missing functionality] Module-level imports for patchability
- Found during: Task 1 TDD GREEN phase
- Issue:
KeyEncryptionServiceandgoogleapiclient.buildimported lazily (inside function), making them unpatchable in tests with standardpatch()calls - Fix: Added module-level imports with try/except ImportError guard for the google library optional dep;
settingsandKeyEncryptionServiceimported at module level - Files modified:
packages/orchestrator/orchestrator/tools/builtins/calendar_lookup.py - Commit:
08572fc
2. [Rule 1 - Bug] Test patched non-existent module attribute
- Found during: Task 1 TDD GREEN phase
- Issue: Tests patched
get_async_sessionandKeyEncryptionServicebefore those names existed at module level; tests also neededsettingspatched to bypassplatform_encryption_keycheck - Fix: Updated tests to pass
_sessiondirectly (no need to patchget_async_session), extracted_make_mock_settings()helper, addedpatch(_PATCH_SETTINGS)to all action tests - Files modified:
tests/unit/test_calendar_lookup.py - Commit:
08572fc
3. [Already done] google_client_id/secret in Settings and GOOGLE_CALENDAR in ChannelTypeEnum
- These were already committed in plan 10-01 — no action needed for this plan
Requirements Satisfied
- CAP-05: Calendar availability checking and event creation — per-tenant OAuth, list/check_availability/create actions
- CAP-06: Natural language tool results — formatting instruction added to system prompt; calendar_lookup returns human-readable strings, not raw JSON
Self-Check: PASSED
All files verified:
- FOUND: packages/shared/shared/api/calendar_auth.py
- FOUND: packages/orchestrator/orchestrator/tools/builtins/calendar_lookup.py
- FOUND: migrations/versions/013_google_calendar_channel.py
- FOUND: tests/unit/test_calendar_auth.py
- FOUND: tests/unit/test_calendar_lookup.py
- FOUND: commit
08572fc(Task 1) - FOUND: commit
a64634f(Task 2)