Skip to content

Commit 44fff96

Browse files
authored
Merge pull request #1027 from AnishSarkar22/feat/onedrive-connector
feat: Onedrive connector with sensitive actions using HITL
2 parents c74b517 + 5a3eece commit 44fff96

85 files changed

Lines changed: 4642 additions & 414 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docker/.env.example

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,10 +203,11 @@ STT_SERVICE=local/base
203203
# AIRTABLE_CLIENT_SECRET=
204204
# AIRTABLE_REDIRECT_URI=http://localhost:8000/api/v1/auth/airtable/connector/callback
205205

206-
# -- Microsoft Teams --
207-
# TEAMS_CLIENT_ID=
208-
# TEAMS_CLIENT_SECRET=
206+
# -- Microsoft OAuth (Teams & OneDrive) --
207+
# MICROSOFT_CLIENT_ID=
208+
# MICROSOFT_CLIENT_SECRET=
209209
# TEAMS_REDIRECT_URI=http://localhost:8000/api/v1/auth/teams/connector/callback
210+
# ONEDRIVE_REDIRECT_URI=http://localhost:8000/api/v1/auth/onedrive/connector/callback
210211

211212
# -- Composio --
212213
# COMPOSIO_API_KEY=

surfsense_backend/.env.example

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ DISCORD_CLIENT_SECRET=your_discord_client_secret_here
7474
DISCORD_REDIRECT_URI=http://localhost:8000/api/v1/auth/discord/connector/callback
7575
DISCORD_BOT_TOKEN=your_bot_token_from_developer_portal
7676

77-
# Atlassian OAuth Configuration
77+
# Atlassian OAuth Configuration (Jira & Confluence)
7878
ATLASSIAN_CLIENT_ID=your_atlassian_client_id_here
7979
ATLASSIAN_CLIENT_SECRET=your_atlassian_client_secret_here
8080
JIRA_REDIRECT_URI=http://localhost:8000/api/v1/auth/jira/connector/callback
@@ -95,10 +95,11 @@ SLACK_CLIENT_ID=your_slack_client_id_here
9595
SLACK_CLIENT_SECRET=your_slack_client_secret_here
9696
SLACK_REDIRECT_URI=http://localhost:8000/api/v1/auth/slack/connector/callback
9797

98-
# Teams OAuth Configuration
99-
TEAMS_CLIENT_ID=your_teams_client_id_here
100-
TEAMS_CLIENT_SECRET=your_teams_client_secret_here
98+
# Microsoft OAuth (Teams & OneDrive)
99+
MICROSOFT_CLIENT_ID=your_microsoft_client_id_here
100+
MICROSOFT_CLIENT_SECRET=your_microsoft_client_secret_here
101101
TEAMS_REDIRECT_URI=http://localhost:8000/api/v1/auth/teams/connector/callback
102+
ONEDRIVE_REDIRECT_URI=http://localhost:8000/api/v1/auth/onedrive/connector/callback
102103

103104
# Composio Connector
104105
# NOTE: Disable "Mask Connected Account Secrets" in Composio dashboard (Settings → Project Settings) for Google indexing to work.
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
"""Add OneDrive connector enums
2+
3+
Revision ID: 110
4+
Revises: 109
5+
Create Date: 2026-03-28 00:00:00.000000
6+
7+
"""
8+
9+
from collections.abc import Sequence
10+
11+
from alembic import op
12+
13+
revision: str = "110"
14+
down_revision: str | None = "109"
15+
branch_labels: str | Sequence[str] | None = None
16+
depends_on: str | Sequence[str] | None = None
17+
18+
19+
def upgrade() -> None:
20+
op.execute(
21+
"""
22+
DO $$
23+
BEGIN
24+
IF NOT EXISTS (
25+
SELECT 1 FROM pg_type t
26+
JOIN pg_enum e ON t.oid = e.enumtypid
27+
WHERE t.typname = 'searchsourceconnectortype' AND e.enumlabel = 'ONEDRIVE_CONNECTOR'
28+
) THEN
29+
ALTER TYPE searchsourceconnectortype ADD VALUE 'ONEDRIVE_CONNECTOR';
30+
END IF;
31+
END
32+
$$;
33+
"""
34+
)
35+
36+
op.execute(
37+
"""
38+
DO $$
39+
BEGIN
40+
IF NOT EXISTS (
41+
SELECT 1 FROM pg_type t
42+
JOIN pg_enum e ON t.oid = e.enumtypid
43+
WHERE t.typname = 'documenttype' AND e.enumlabel = 'ONEDRIVE_FILE'
44+
) THEN
45+
ALTER TYPE documenttype ADD VALUE 'ONEDRIVE_FILE';
46+
END IF;
47+
END
48+
$$;
49+
"""
50+
)
51+
52+
53+
def downgrade() -> None:
54+
pass

surfsense_backend/app/agents/new_chat/chat_deepagent.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@
8484
"BOOKSTACK_CONNECTOR": "BOOKSTACK_CONNECTOR",
8585
"CIRCLEBACK_CONNECTOR": "CIRCLEBACK", # Connector type differs from document type
8686
"OBSIDIAN_CONNECTOR": "OBSIDIAN_CONNECTOR",
87+
"ONEDRIVE_CONNECTOR": "ONEDRIVE_FILE", # Connector type differs from document type
8788
# Composio connectors (unified to native document types).
8889
# Reverse of NATIVE_TO_LEGACY_DOCTYPE in app.db.
8990
"COMPOSIO_GOOGLE_DRIVE_CONNECTOR": "GOOGLE_DRIVE_FILE",
@@ -316,6 +317,12 @@ async def create_surfsense_deep_agent(
316317
]
317318
modified_disabled_tools.extend(google_drive_tools)
318319

320+
has_onedrive_connector = (
321+
available_connectors is not None and "ONEDRIVE_FILE" in available_connectors
322+
)
323+
if not has_onedrive_connector:
324+
modified_disabled_tools.extend(["create_onedrive_file", "delete_onedrive_file"])
325+
319326
# Disable Google Calendar action tools if no Google Calendar connector is configured
320327
has_google_calendar_connector = (
321328
available_connectors is not None

surfsense_backend/app/agents/new_chat/middleware/dedup_tool_calls.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"trash_gmail_email": "email_subject_or_id",
2727
"update_gmail_draft": "draft_subject_or_id",
2828
"delete_google_drive_file": "file_name",
29+
"delete_onedrive_file": "file_name",
2930
"delete_notion_page": "page_title",
3031
"update_notion_page": "page_title",
3132
"delete_linear_issue": "issue_ref",

surfsense_backend/app/agents/new_chat/tools/knowledge_base.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ async def _browse_recent_documents(
201201
"CRAWLED_URL",
202202
"CIRCLEBACK",
203203
"OBSIDIAN_CONNECTOR",
204+
"ONEDRIVE_FILE",
204205
]
205206

206207
# Human-readable descriptions for each connector type
@@ -230,6 +231,7 @@ async def _browse_recent_documents(
230231
"BOOKSTACK_CONNECTOR": "BookStack pages (personal documentation)",
231232
"CIRCLEBACK": "Circleback meeting notes, transcripts, and action items",
232233
"OBSIDIAN_CONNECTOR": "Obsidian vault notes and markdown files (personal notes)",
234+
"ONEDRIVE_FILE": "Microsoft OneDrive files and documents (personal cloud storage)",
233235
}
234236

235237

@@ -357,6 +359,7 @@ def _compute_tool_output_budget(max_input_tokens: int | None) -> int:
357359
"event_id",
358360
"calendar_id",
359361
"google_drive_file_id",
362+
"onedrive_file_id",
360363
"page_id",
361364
"issue_id",
362365
"connector_id",
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from app.agents.new_chat.tools.onedrive.create_file import (
2+
create_create_onedrive_file_tool,
3+
)
4+
from app.agents.new_chat.tools.onedrive.trash_file import (
5+
create_delete_onedrive_file_tool,
6+
)
7+
8+
__all__ = [
9+
"create_create_onedrive_file_tool",
10+
"create_delete_onedrive_file_tool",
11+
]

0 commit comments

Comments
 (0)