add delete notion page approval ui

This commit is contained in:
CREDO23 2026-02-11 18:20:51 +02:00
parent 4da6892416
commit 8e6fa2ee58
8 changed files with 666 additions and 341 deletions

View file

@ -273,7 +273,10 @@ async def create_surfsense_deep_agent(
system_prompt=system_prompt,
context_schema=SurfSenseContextSchema,
checkpointer=checkpointer,
interrupt_on={"create_notion_page": True},
interrupt_on={
"create_notion_page": True,
"delete_notion_page": {"allowed_decisions": ["approve", "reject"]},
},
)
return agent

View file

@ -6,6 +6,6 @@ from .update_page import create_update_notion_page_tool
__all__ = [
"create_create_notion_page_tool",
"create_update_notion_page_tool",
"create_delete_notion_page_tool",
"create_update_notion_page_tool",
]

View file

@ -115,7 +115,7 @@ def create_create_notion_page_tool(
logger.error(f"Unexpected error creating Notion page: {e}", exc_info=True)
return {
"status": "error",
"message": f"Unexpected error creating Notion page: {str(e)}",
"message": f"Unexpected error creating Notion page: {e!s}",
}
return create_notion_page

View file

@ -55,7 +55,8 @@ def create_delete_notion_page_tool(
try:
# Get connector ID if not provided
if connector_id is None:
actual_connector_id = connector_id
if actual_connector_id is None:
from sqlalchemy.future import select
from app.db import SearchSourceConnector, SearchSourceConnectorType
@ -75,12 +76,12 @@ def create_delete_notion_page_tool(
"message": "No Notion connector found. Please connect Notion in your workspace settings.",
}
connector_id = connector.id
actual_connector_id = connector.id
# Create connector instance
notion_connector = NotionHistoryConnector(
session=db_session,
connector_id=connector_id,
connector_id=actual_connector_id,
)
# Delete the page
@ -95,7 +96,7 @@ def create_delete_notion_page_tool(
except Exception as e:
return {
"status": "error",
"message": f"Unexpected error deleting Notion page: {str(e)}",
"message": f"Unexpected error deleting Notion page: {e!s}",
}
return delete_notion_page

View file

@ -67,7 +67,8 @@ def create_update_notion_page_tool(
try:
# Get connector ID if not provided
if connector_id is None:
actual_connector_id = connector_id
if actual_connector_id is None:
from sqlalchemy.future import select
from app.db import SearchSourceConnector, SearchSourceConnectorType
@ -87,12 +88,12 @@ def create_update_notion_page_tool(
"message": "No Notion connector found. Please connect Notion in your workspace settings.",
}
connector_id = connector.id
actual_connector_id = connector.id
# Create connector instance
notion_connector = NotionHistoryConnector(
session=db_session,
connector_id=connector_id,
connector_id=actual_connector_id,
)
# Update the page
@ -109,7 +110,7 @@ def create_update_notion_page_tool(
except Exception as e:
return {
"status": "error",
"message": f"Unexpected error updating Notion page: {str(e)}",
"message": f"Unexpected error updating Notion page: {e!s}",
}
return update_notion_page

View file

@ -967,7 +967,7 @@ class NotionHistoryConnector:
"page_id": page_id,
"url": page_url,
"title": title,
"message": f"Created Notion page '{title}'",
"message": f"Created Notion page '{title}'",
}
except APIResponseError as e:
@ -1054,7 +1054,7 @@ class NotionHistoryConnector:
"page_id": page_id,
"url": page_url,
"title": page_title,
"message": f"Updated Notion page '{page_title}'",
"message": f"Updated Notion page '{page_title}'",
}
except APIResponseError as e:
@ -1107,7 +1107,7 @@ class NotionHistoryConnector:
return {
"status": "success",
"page_id": page_id,
"message": f"Deleted Notion page '{page_title}'",
"message": f"Deleted Notion page '{page_title}'",
}
except APIResponseError as e: